[{"Question":"Appium\nPython\niOS\nel.text and get_attribute('label') etc. all seem to pulling accessibility information. Is there a way to pull the actual text that is displayed on screen using Appium? I need to be able to pull for a given element.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2239,"Q_Id":49265166,"Users Score":0,"Answer":"It does not return visible text if you use .text\nYou need to ask the developer to add a new attribute in the iOS code with the actual mention of the original url text. Then you will be able to see the new attribute in the Appium element locator table. If this is not done there is no value in the appium element locator table to give you the visible text","Q_Score":1,"Tags":"appium,appium-ios,python-appium","A_Id":51236016,"CreationDate":"2018-03-13T20:17:00.000","Title":"Appium - Get actual, visible text that is displayed on screen","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hey I started to use the graphical orange canvas toolbox for data mining. Connecting nodes on the workspace can cause the execution of the associated tasks. I know that these automatic apply can be disabled, but in the case I missed that and accidently start a realy heavy process like outliner detection on a big dataset is there a way to stop the current pipeline task without killing the hole system process?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":199,"Q_Id":49267496,"Users Score":2,"Answer":"Unfortunately there is no such stopping functionality in Orange yet.\nThe developers of Orange are working towards making widgets compute in threads, which can let us control stopping. The Test & Learn widget, for example, already works in a separate thread. There, if the user changes options while widget is already working, it stops the current computation and starts a new one. But even there, there is no GUI option to just stop the computation.","Q_Score":0,"Tags":"python,process,orange","A_Id":49275664,"CreationDate":"2018-03-13T23:27:00.000","Title":"How to cancle process in Orange Canvas?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I get a model name as a \"string\" from a model instance. \nI know you can do something like type(model_instance)\nbut this is returning the class itself as an object <Model_Name: > not as a string.","AnswerCount":3,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":7372,"Q_Id":49268210,"Users Score":-3,"Answer":"By defining the str or unicode method ?","Q_Score":8,"Tags":"python,django,models","A_Id":49268219,"CreationDate":"2018-03-14T00:54:00.000","Title":"Get model name from instance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I tried to install MATLAB R2017b runtime Python 3.6 on to my ubuntu 16.4. As per the instruction that given in matlab community python installer (setup.py) should be in ..\/..\/v93\/extern\/engines\/python location. \nWhen I go there Icouldnt see that setup.py file in the location. I have tried so many time  re installing the MATLAB R2017b runtime. \nBut I couldn't find that python setup.py on the location. \ncould you please send me instruction how to install this MATLAB R2017b runtime on ubuntu 16.4 where I can access my matlab libries from python3.6","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":88,"Q_Id":49270176,"Users Score":1,"Answer":"The python installer should be in \/{matlab_root}\/extern\/engines\/python.\nThen python setup.py install\nHope it helps","Q_Score":1,"Tags":"python,matlab,computer-vision,ubuntu-16.04","A_Id":49274707,"CreationDate":"2018-03-14T05:14:00.000","Title":"In Matlab Runtime Python3.6 installer not found in order to install matlab python suport for ubunut 16.4","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":1,"Web Development":0},{"Question":"I develop HTTP GET Webservices (REST) in a distributed microservices architecture.\nFor performance issues, I need the cache on the clients of the webservices.\nIs there an urllib-like library that uses HTTP cache headers of the webservices to cache?\nNote: requests-cache does not seem to read http headers","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13,"Q_Id":49273441,"Users Score":0,"Answer":"Why we need to cache the HTTP headers?\nNormally, only GET responses are valuable to be cached on the client.","Q_Score":0,"Tags":"python-3.x,rest,web-services,urllib,microservices","A_Id":49355304,"CreationDate":"2018-03-14T09:02:00.000","Title":"urllib-like library that caches accordingly to HTTP headers in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to cluster a number of words using the KMeans algorithm from scikit learn.\nIn particular, I use pre-trained word embeddings (300 dimensional vectors) to map each word with a number vector and then I feed these vectors to KMeans and provide the number of clusters. \nMy issue is that there are certain words in my input corpus which I can not find in the pretrained word embeddings dictionary. This means that in these cases, instead of a vector, I get a numpy array full of nan values. This does not work with the kmeans algorithm and therefore I have to exclude these arrays. However, I am interested in seeing all these cases that were not found in the word embeddings and what is more, if possible throw them inside a separate cluster that will contain only them.\nMy idea at this point is to set a condition that if the word is returned with a nan-values array from the embeddings index, then assign an arbitrary vector to it. Each dimension of the embeddings vector lie within [-1,1]. Therefore, if I assign the following vector [100000]*300 to all nan words, I have created a set of outliers. In practice, this works as expected, since this particular set of vectors are forced in a separate cluster. However, the initialization of the kmeans centroids is affected by these outlier values and therefore all the rest of my clusters get messed up as well. As a remedey, I tried to initiate the kmeans using init = k-means++ but first, it takes significantly longer to execute and second the improvement is not much better.\nAny suggestions as to how to approach this issue?\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2184,"Q_Id":49273536,"Users Score":0,"Answer":"If you don't have data on a word, then skip it.\nYou could try to compute a word vector on the fly based on the context, but that essentially is the same as just skipping it.","Q_Score":2,"Tags":"python,cluster-analysis,k-means","A_Id":49294559,"CreationDate":"2018-03-14T09:08:00.000","Title":"Python KMeans Clustering - Handling nan Values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"There isn't any relevant document found from the webpage. thanks a lot for any hint.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":49273758,"Users Score":0,"Answer":"I went back to a single code-base approach.  I had had it split between 2.x, 3.0-2, and 3.3+ because I liked some of the enhancements in 3.3, but it was too big a headache trying to keep three versions in sync.\nEdit:  I also changed from using the strings 'read-only' and 'read-write' for opening databases to the constants dbf.READ_ONLY and dbf.READ_WRITE.\n0.97.001 now supports opening databases as read-only even when the files are read-only (yes, that was a bug.)","Q_Score":0,"Tags":"python,dbf","A_Id":49285341,"CreationDate":"2018-03-14T09:19:00.000","Title":"Just found the Python DBF package upgrade to dbf 0.97.0, who knows what's new in this upgrade?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I needed a way to pull 10% of the files in a folder, at random, for sampling after every \"run.\" Luckily, my current files are numbered numerically, and sequentially. So my current method is to list file names, parse the numerical portion, pull max and min values, count the number of files and multiply by .1, then use random.sample to get a \"random [10%] sample.\" I also write these names to a .txt then use shutil.copy to move the actual files.\nObviously, this does not work if I have an outlier, i.e. if I have a file 345.txt among other files from 513.txt - 678.txt. I was wondering if there was a direct way to simply pull a number of files from a folder, randomly? I have looked it up and cannot find a better method.\nThanks.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9105,"Q_Id":49280966,"Users Score":0,"Answer":"You can use following strategy:\n\nUse list = os.listdir(path) to get all your files in the directory as list of paths.\nNext, count your files with range = len(list) function.\nUsing rangenumber you can get random item number like that random_position = random.randrange(1, range)\nRepeat step 3 and save values in a list until you get enough positions (range\/10 in your case)\nAfter that you can get required files names like that list[random_position]\n\nUse cycle for for iterating.\nHope this helps!","Q_Score":6,"Tags":"python,random,sampling","A_Id":49281296,"CreationDate":"2018-03-14T14:56:00.000","Title":"Pulling random files out of a folder for sampling","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is such a simple question, but I cannot figure out the answer.\nI have installed the Eric 6 IDE for Python. It has an interactive console - great! How can I execute selected commands in the console?\nPyCharm has Shift+Ctrl+E, Spyder has Ctrl+Enter ... what is the corresponding command in Eric?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":567,"Q_Id":49282487,"Users Score":1,"Answer":"If you select your code and right click on it, it has an option for \"Execute Selection In Console\"\nThere is a \"Keyboard Shortcuts\" under the \"Settings\" menu, where several items can be personalized. However, I don't see a way to assign a shortcut for \"Execute Selection In Console\". If anyone else finds a way to do it, I would love to know.","Q_Score":1,"Tags":"python,ide,eric-ide","A_Id":50881411,"CreationDate":"2018-03-14T16:02:00.000","Title":"Python Eric IDE: Execute selection in console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a remote cron job that scrapes data using selenium every 30 minutes. Roughly 1 in 10 times the selenium script fails. When the script fails, I get an error output instead (various selenium error messages). Does this cause the cron job to stop? Shouldn't crontab try to run the script again in 30 minutes?\nAfter a failed attempt, when I type crontab -l, it still shows my cron job. \nHow do I ensure that the crontab tries again in 30 minutes?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":306,"Q_Id":49283567,"Users Score":0,"Answer":"ANSWER: The website I was scraping was sophisticated enough to find out I was using selenium because cron was running the job every 30 minutes on the dot. So they flagged my VM's IP address after the 4-5th attempt. \nMy solution was simple: add randomness to the interval with which I scrapped the website using random.uniform and time.sleep - now I have no issues scraping.","Q_Score":0,"Tags":"python-3.x,selenium,cron","A_Id":49321214,"CreationDate":"2018-03-14T16:56:00.000","Title":"Does cron job persist\/run again if the python script fails?","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 remote cron job that scrapes data using selenium every 30 minutes. Roughly 1 in 10 times the selenium script fails. When the script fails, I get an error output instead (various selenium error messages). Does this cause the cron job to stop? Shouldn't crontab try to run the script again in 30 minutes?\nAfter a failed attempt, when I type crontab -l, it still shows my cron job. \nHow do I ensure that the crontab tries again in 30 minutes?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":306,"Q_Id":49283567,"Users Score":0,"Answer":"Who is sending the error output?  If it's the cron daemon, then your job should be dead; if the selenium process itself is sending the mail, then it may still be running, and stuck.","Q_Score":0,"Tags":"python-3.x,selenium,cron","A_Id":49287487,"CreationDate":"2018-03-14T16:56:00.000","Title":"Does cron job persist\/run again if the python script fails?","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 may sound dumb, but I am unable to figure out how to update my main.py code using buildozer. I once created a file main.py and ran buildozer init . Afterwards I executed some android commands like buildozer android run. Now I would like to change the code of my main.py . But whenever I try to re-compile using buildozer android run the same not edited code is used. I found out that the file PROJECT\/.buildozer\/android\/app\/main.py is used. But I don't want to update this file because that seems unclean to me.\nEdit: I already tried buildozer android clean and buildozer android update and I already searched on the internet but I could not find anything.\nWhat is the solution to update the buildozer codebase?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":587,"Q_Id":49284459,"Users Score":1,"Answer":"Well, a very stupid solution. After 45 minutes of trial-and-error I found out that I just have to invoke buildozer android debug to compile the application. buildozer android run is independent and just runs the compiled application. As a user of the gradle build system I did not think about this case, because I was familar with the target-based build system.\nThe final solution to compile and run on the target device is therefore: buildozer android debug deploy run\nI hope this answer will help someone who expects the same problem.","Q_Score":0,"Tags":"android,python,kivy,buildozer","A_Id":49284548,"CreationDate":"2018-03-14T17:43:00.000","Title":"Buildozer update python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running Windows 7 with Python 3.6 and no other versions. I installed Django through pip successfully. Yet when I try to make new virtual project, I get \"DNS not authoritativer error\". I am logged in and running cmd prompt as Admin. What could be the issue here?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":418,"Q_Id":49285022,"Users Score":0,"Answer":"SOLVED. \nMy PATH variable was sloppy. Instead of ending the variable with \"\\\". I had ended it with \";\"","Q_Score":0,"Tags":"python,django,dns","A_Id":49289349,"CreationDate":"2018-03-14T18:16:00.000","Title":"\"mkvirtualenv myproject\" command giving \"DNS server not authoritative for the zone\" error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to transfer virtual environment data from a local host to a docker image via the ADD command? \nRather than doing pip installs inside the container, I would rather the user have all of that done locally and simply transfer the virtual environment into the container. Granted all of the files are the same name locally as in the docker container, along with all directories being nested properly. \nThis would save minutes to hours if it was possible to transfer virtual environment settings into a docker image. Maybe I am thinking about this in the wrong abstract. \nIt just feels very inefficient doing pip installs via a requirements.txt that was passed into the container, as opposed to doing it all locally, otherwise each time the image is started up it has to re-install the same dependencies that have not changed from each image's build.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5080,"Q_Id":49287441,"Users Score":2,"Answer":"While possible, it's not recommended.\n\nDependencies (library versions, globally installed packages) can be different on host machine and container.\nImage builds will not be 100% reproducible on other hosts.\nImpact of pip install is not big. Each RUN command creates it's own layer, which are cached locally and also in repository, so pip install will be re-run only when requirements.txt is changed (or previous layers are rebuilt).\n\nTo trigger pip install only on requirements.txt changes, Dockerfile should start this way:\n...\nCOPY requirements.txt .\/\nRUN pip install -r requirements.txt\nCOPY src\/ .\/\n...\n\nAlso, it will be run only on image build, not container startup.\nIf you have multiple containers with same dependencies, you can build intermediate image with all the dependencies and build other images FROM it.","Q_Score":7,"Tags":"python,docker,pip,virtualenv,dockerfile","A_Id":49287543,"CreationDate":"2018-03-14T20:53:00.000","Title":"Transfer virtualenv to docker image","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am applying Decision Tree to a data set, using sklearn \nIn Sklearn there is a parameter to select the depth of the tree - \ndtree = DecisionTreeClassifier(max_depth=10). \nMy question is how the max_depth parameter helps on the model.\nhow does high\/low max_depth help in predicting the test data more accurately?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":22441,"Q_Id":49289187,"Users Score":11,"Answer":"max_depth is what the name suggests: The maximum depth that you allow the tree to grow to. The deeper you allow, the more complex your model will become.  \nFor training error, it is easy to see what will happen. If you increase max_depth, training error will always go down (or at least not go up).  \nFor testing error, it gets less obvious. If you set max_depth too high, then the decision tree might simply overfit the training data without capturing useful patterns as we would like; this will cause testing error to increase. But if you set it too low, that is not good as well; then you might be giving the decision tree too little flexibility to capture the patterns and interactions in the training data. This will also cause the testing error to increase.  \nThere is a nice golden spot in between the extremes of too-high and too-low. Usually, the modeller would consider the max_depth as a hyper-parameter, and use some sort of grid\/random search with cross-validation to find a good number for max_depth.","Q_Score":2,"Tags":"python,scikit-learn,decision-tree","A_Id":49289462,"CreationDate":"2018-03-14T23:27:00.000","Title":"Decision Tree Sklearn -Depth Of tree and accuracy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"the code below replaces numbers with the token NUMB:\nraw_corpus.loc[:,'constructed_recipe']=raw_corpus['constructed_recipe'].str.replace('\\d+','NUMB')\nIt works fine if the numbers have a space before and a space after, but creates a problem if the numbers are included in another string. \nHow do I modify the code so that it only replaces numbers with NUMB if the numbers are surrounded by a space on both sides? e.g. do not modify this string: \"from url 500px\", but do modify this string: \"dishwasher 10 pods\" to \"dishwasher NUMB pods\".\nI'm not sure how to modify '\\d+' to make this happen. Any ideas?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":415,"Q_Id":49289969,"Users Score":0,"Answer":"I also tried ' \\d+ ' and that works! probably not \"pythonic\" though...","Q_Score":1,"Tags":"python,string,replace,whitespace","A_Id":49290127,"CreationDate":"2018-03-15T01:00:00.000","Title":"replace numbers with token if numbers have whitespace on both side","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"lets say i have used with selenium\nchrome_options.add_argument(\"--headless\")\nbut now i want the browser to open. Is this possible? thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":49290655,"Users Score":0,"Answer":"No, it isn\u2019t possible.\nThe --headless option is a command-line flag used to instantiate the browser, meaning it is being told to execute headlessly for the entirety of its existence.","Q_Score":0,"Tags":"python,selenium,selenium-chromedriver","A_Id":49301624,"CreationDate":"2018-03-15T02:31:00.000","Title":"How to open headless browser in selenium?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was asked to write a program to find string \"error\" from a file and print matched lines in python. \n\nWill first open a file with read more\ni use fh.readlines and store it in a variable\nAfter this, will use for loop and iterate line by line. check for the string \"error\".print those lines if found.\n\nI was asked to use pointers in python since assigning file content to a variable consumes time when logfile contains huge output.\nI did research on python pointers. But not found anything useful.\nCould anyone help me out writing the above code using pointers instead of storing the whole content in a variable.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":261,"Q_Id":49292360,"Users Score":0,"Answer":"I used below code instead of putting the data in a variable and then for loop.\nfor line in open('c182573.log','r').readlines():\n    if ('Executing' in line):\n        print line\nSo there is no way that we can implement pointers or reference in python.\nThanks all","Q_Score":0,"Tags":"python,file-io","A_Id":49292578,"CreationDate":"2018-03-15T05:48:00.000","Title":"Python pointers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was asked to write a program to find string \"error\" from a file and print matched lines in python. \n\nWill first open a file with read more\ni use fh.readlines and store it in a variable\nAfter this, will use for loop and iterate line by line. check for the string \"error\".print those lines if found.\n\nI was asked to use pointers in python since assigning file content to a variable consumes time when logfile contains huge output.\nI did research on python pointers. But not found anything useful.\nCould anyone help me out writing the above code using pointers instead of storing the whole content in a variable.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":261,"Q_Id":49292360,"Users Score":0,"Answer":"You can use a dictionary by using key-pair value. Just dump the log file into dictionary wherein the key would be words and value would be the line number. So if you search for string \"error\" you will get the line numbers they are present it and accordingly you can print them. Since searching in dictionary or hashtable is in constant time O(1) it will take less time. But yes storing might take time depends if you avoid collision.","Q_Score":0,"Tags":"python,file-io","A_Id":49292557,"CreationDate":"2018-03-15T05:48:00.000","Title":"Python pointers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"During the installation of exchangelib the installation tries to connect to the internet to get dependencies.\nOn this computer it is not possible to to open the firewalls to provide the access - it is a very restricted system.\nIs there a way for an offline installation of the exchangelib?\nBest Regards \nKlaus Heubisch","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":224,"Q_Id":49293207,"Users Score":0,"Answer":"You have a couple of different possibilities. I think the most simple one is to create a virtualenv on a system that does have Internet access and install exchangelib and its dependencies there. You can then copy that virtualenv to the system with no Internet access.\nVirtualenvs contain absolute paths, so you would need to either copy it to the same path on the other server, or make the virtualenv relocatable.","Q_Score":2,"Tags":"python-3.x,exchange-server,exchangelib","A_Id":49296477,"CreationDate":"2018-03-15T06:54:00.000","Title":"I cannot install exchangelib on a very restricted system which has no internet connection and it is not possible to create one","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with opencv in my last study's project. I have python 2.7 x86 and opencv 3.4 already installed.\nI developed my python project in windows 8 64 bit and I converted my application from .py to .exe through Pyinstaller and it's working fine .\nBut when I move my application to the industrial machine which is windows xp pack 3 32bit and i try to import cv2 I get the following error :\n\nImportError: DLL load failed: The specified module could not be found.\n\nNote that I have tried to install Microsoft visual c++ 2015 and didn't solve the problem and I try everything said about this problem on stackoverflow and didn't work with me .\nCan anyone help me here ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1365,"Q_Id":49296268,"Users Score":1,"Answer":"You should copy opencv.dll to directory contains .exe.","Q_Score":1,"Tags":"python,opencv,windows-xp","A_Id":49296319,"CreationDate":"2018-03-15T09:54:00.000","Title":"opencv for windows XP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Jupyter notebook containing python and R scripts as well as magic commands. What I need is to schedule a task using Windows Task scheduler that somehow triggers run of this notebook. My scripts run at night and I prefer Jupyter to be closed.\nSo I wonder if there is a way to do this?\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1439,"Q_Id":49296346,"Users Score":3,"Answer":"It is perfectly possible to do this\nCreate a bat file that you can reference in the windows task scheduler.\nCode as follows:\ncd C:\\path to your notebook\njupyter nbconvert --to notebook --execute NOTEBOOKTOEXECUTE.ipynb\nI needed to include the path, as the console would be run from the system path and thus unable to find the notebook.","Q_Score":1,"Tags":"python,python-3.x,jupyter-notebook","A_Id":49297540,"CreationDate":"2018-03-15T09:58:00.000","Title":"Run Jupyter notebook out of Jupyter environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to tie weights of the embedding layer and the next_word prediction layer of the decoder. The embedding dimension is set to 300 and the hidden size of the decoder is set to 600. Vocabulary size of the target language in NMT is 50000, so embedding weight dimension is 50000 x 300 and weight of the linear layer which predicts the next word is 50000 x 600. \nSo, how can I tie them? What will be the best approach to achieve weight tying in this scenario?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5192,"Q_Id":49299609,"Users Score":0,"Answer":"Did you check the code that kmario23 shared?  Because it is written that if the hidden size and the embedding sizes are not equal then raise an exception. So, this means if you really want to tie the weights then you should decrease the hidden size of your decoder to 300. \nOn the other hand, if you rethink your idea, what you really want to do is to eliminate the weight tying. Why? Because basically, you want to use a transformation which needs another matrix.","Q_Score":0,"Tags":"python,deep-learning,recurrent-neural-network,pytorch,seq2seq","A_Id":49598792,"CreationDate":"2018-03-15T12:33:00.000","Title":"Tying weights in neural machine translation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to tie weights of the embedding layer and the next_word prediction layer of the decoder. The embedding dimension is set to 300 and the hidden size of the decoder is set to 600. Vocabulary size of the target language in NMT is 50000, so embedding weight dimension is 50000 x 300 and weight of the linear layer which predicts the next word is 50000 x 600. \nSo, how can I tie them? What will be the best approach to achieve weight tying in this scenario?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5192,"Q_Id":49299609,"Users Score":3,"Answer":"You could use linear layer to project the 600 dimensional space down to 300 before you apply the shared projection. This way you still get the advantage that the entire embedding (possibly) has a non-zero gradient for each mini-batch but at the risk of increasing the capacity of the network slightly.","Q_Score":0,"Tags":"python,deep-learning,recurrent-neural-network,pytorch,seq2seq","A_Id":54236136,"CreationDate":"2018-03-15T12:33:00.000","Title":"Tying weights in neural machine translation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to recommend products by clickstream with LSTM in TensorFlow.\nI have historical user behaviour data using which I want to use to train model to recommend products (represented as classes on output) but I need to consider whether product was active in that moment on webpage(not to recommend inactive deals). \nSince I consider this very difficult using ground truth, I would like to use binary mask on output before it is compared to the target vector.\nIs there any native way to do this in TensorFlow?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":376,"Q_Id":49299761,"Users Score":0,"Answer":"You could use tf.boolean_mask on the softmax prediction output to remove the probabilities for inactive deals then get the maximum probabilities without them.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,lstm,bitmask","A_Id":49303974,"CreationDate":"2018-03-15T12:42:00.000","Title":"Binary mask for output vector in Tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm opening a text file and doing a:\nf.seek(mid) where mid= (0+f.seek(0,2))\/\/2\nNow I want to check if the read pointer is at the starting of a new line or not? \nBased on that I discard f.readline() if pointer is not at the start and read a new line.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":49300327,"Users Score":0,"Answer":"One trivial solution would be to do f.seek(mid-1) and check if f.read(1) == \"\\n\" or not.","Q_Score":0,"Tags":"python,python-3.x,seek","A_Id":50404859,"CreationDate":"2018-03-15T13:09:00.000","Title":"Check after f.seek(mid) if the pointer is at the start of new line or not?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I feel like this is incredibly easy to fix, but for some reason it isn't. \nI want to run a program in linux that opens python file filename.py by writing:\n\npython3 filename arg\n\nbut it only works if i write:\n\npython3 filename.py arg\n\nIs there an easy way to run it without adding the extension? And without removing the extension completely? I wouldn't have imagined this to be a problem at all, but here we are. \nThankful for help!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":125,"Q_Id":49301514,"Users Score":1,"Answer":"Your file is called filename.py, therefore you call it with python3 filename.py. If you want to call it with python3 filename, you'll need to rename the file.\nThe one thing you can do is call Python with the -m switch, which will try to import a module with that name, i.e. python3 -m filename. That should work without renaming the file.","Q_Score":0,"Tags":"python,terminal,file-extension","A_Id":49301592,"CreationDate":"2018-03-15T14:02:00.000","Title":"Running python in terminal without suffix","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I upgraded bokeh library by executing the following command: \n!pip install --user --upgrade bokeh \nTornado version 5 dependency was installed. After upgrading the library from the DSX Notebook the kernel stops responding after restart. I see \"Slow Kernel connection\" dialog.\nOpening another notebook for the same language displays the same error dialog.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":449,"Q_Id":49303168,"Users Score":2,"Answer":"Tornado 5.0 is incompatible with the current ipython kernel installation for DSX Notebooks. \nIf you are experiencing \"Slow kernel connection\" issue after upgrading Bokeh library try the following steps:\n\nSwitch to Python kernel with another version (e.g. if you installed Tornado 5 for \"Python 2\" kernel, switch kernel to \"Python 3.5\")\nExecute the following command in the notebook code cell: !rm -rf ~\/.local\/lib\/\nThis command will remove all python packages installed by user\nAll Python kernels should be started normally\n\nIf Tornado 5 was installed for both Python versions (Python 2 and Python 3) you could remove user's packages by switching to R kernel and executing the following command:\nsystem('!rm -rf ~\/.local\/lib\/')\nAfter that you could switch back to Python kernel.\nYou could upgrade bokeh library with the following command: \n!pip install --upgrade --upgrade-strategy only-if-needed bokeh\nIn this case Tornado package will not be updated","Q_Score":0,"Tags":"python,jupyter-notebook,tornado,bokeh,data-science-experience","A_Id":49303169,"CreationDate":"2018-03-15T15:17:00.000","Title":"Installing \"bokeh\" library upgrades Tornado to the version 5 that causes an issue with starting Python kernel in DSX Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am aware of the existence of the Csv package in OCaml, but as far as I know, it does not enable me to load a csv file like a stream of dictionares (as DictReader allows me to do it in Python).\nIs there a way to read such files as a stream of dictionaries ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":49304932,"Users Score":4,"Answer":"Streams in Python are Python's way of abstract iteration. On the other hand they are just objects that have a __next__ method. The Csv module you mention provides a value next which behaves in exactly the same way. Furthermore the module defines some more concrete iterators like fold_left and iter. Thus it is already easy to iterate over csv lines (as string list) and to wrap an Csv.in_channel into an object with much the same signature and behaviour as a Python stream of csv lines.\nIt remains to convert such lines into dictionaries. Which is just a matter of mapping a line-to-dictionary converter to the iterator or stream.","Q_Score":0,"Tags":"python,csv,ocaml","A_Id":49305814,"CreationDate":"2018-03-15T16:45:00.000","Title":"OCaml equivalent of Python DictReader","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed graphviz by trying pip install graphviz. It said it had been successfully installed but I still got the ImportError: No module named graphviz. BTW, I'm not running the program on Conda or Anaconda.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":4116,"Q_Id":49308693,"Users Score":-1,"Answer":"I had the same issue. The problem for me was the default python version that I was using for pip. I fixed it using python3 -m pip install desired_package. \nHope it solves your problem","Q_Score":1,"Tags":"python,graphviz","A_Id":59365999,"CreationDate":"2018-03-15T20:32:00.000","Title":"Why can't I import graphviz","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"some packages like numpy are installed as default in Google Colab. is there any way to not installing new packages and make it default just like numpy?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":936,"Q_Id":49308803,"Users Score":3,"Answer":"No, there's currently no way for users to choose additional packages to install by default.","Q_Score":1,"Tags":"python,pip,google-colaboratory","A_Id":49313978,"CreationDate":"2018-03-15T20:40:00.000","Title":"is there any way to not installing packages on Google Colab every time?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Simple question: I have a dataframe in dask containing about 300 mln records. I need to know the exact number of rows that the dataframe contains. Is there an easy way to do this?\nWhen I try to run dataframe.x.count().compute() it looks like it tries to load the entire data into RAM, for which there is no space and it crashes.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":12792,"Q_Id":49309523,"Users Score":1,"Answer":"If you only need the number of rows -\nyou can load a subset of the columns while selecting the columns with lower memory usage (such as category\/integers and not string\/object), there after you can run len(df.index)","Q_Score":12,"Tags":"python,dataframe,dask","A_Id":58624383,"CreationDate":"2018-03-15T21:27:00.000","Title":"Dask Dataframe: Get row count?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to spark. I am trying to read a file from my master instance but I am getting this error. After research I found out either you need to load data to hdfs or copy across clusters. I am unable to find the commands for doing either of these. \n\n--------------------------------------------------------------------------- Py4JJavaError                             Traceback (most recent call\n  last)  in ()\n  ----> 1 ncols = rdd.first().features.size  # number of columns (no class) of the dataset\n\/home\/ec2-user\/spark\/python\/pyspark\/rdd.pyc in first(self)    1359\n  ValueError: RDD is empty    1360         \"\"\"\n  -> 1361         rs = self.take(1)    1362         if rs:    1363             return rs[0]\n\/home\/ec2-user\/spark\/python\/pyspark\/rdd.pyc in take(self, num)    1311\n  \"\"\"    1312         items = []\n  -> 1313         totalParts = self.getNumPartitions()    1314         partsScanned = 0    1315 \n\/home\/ec2-user\/spark\/python\/pyspark\/rdd.pyc in getNumPartitions(self) \n  2438     2439     def getNumPartitions(self):\n  -> 2440         return self._prev_jrdd.partitions().size()    2441     2442     @property\n\/home\/ec2-user\/spark\/python\/lib\/py4j-0.10.4-src.zip\/py4j\/java_gateway.py\n  in call(self, *args)    1131         answer =\n  self.gateway_client.send_command(command)    1132         return_value\n  = get_return_value(\n  -> 1133             answer, self.gateway_client, self.target_id, self.name)    1134     1135         for temp_arg in temp_args:\n\/home\/ec2-user\/spark\/python\/pyspark\/sql\/utils.pyc in deco(*a, **kw)\n       61     def deco(*a, **kw):\n       62         try:\n  ---> 63             return f(*a, **kw)\n       64         except py4j.protocol.Py4JJavaError as e:\n       65             s = e.java_exception.toString()\n\/home\/ec2-user\/spark\/python\/lib\/py4j-0.10.4-src.zip\/py4j\/protocol.py\n  in get_return_value(answer, gateway_client, target_id, name)\n      317                 raise Py4JJavaError(\n      318                     \"An error occurred while calling {0}{1}{2}.\\n\".\n  --> 319                     format(target_id, \".\", name), value)\n      320             else:\n      321                 raise Py4JError(\nPy4JJavaError: An error occurred while calling o122.partitions. :\n  org.apache.hadoop.mapred.InvalidInputException: Input path does not\n  exist: file:\/home\/ec2-user\/PR_DATA_35.csv     at\n  org.apache.hadoop.mapred.FileInputFormat.singleThreadedListStatus(FileInputFormat.java:285)\n    at\n  org.apache.hadoop.mapred.FileInputFormat.listStatus(FileInputFormat.java:228)\n    at\n  org.apache.hadoop.mapred.FileInputFormat.getSplits(FileInputFormat.java:313)\n    at org.apache.spark.rdd.HadoopRDD.getPartitions(HadoopRDD.scala:194)\n    at\n  org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:252)\n    at\n  org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:250)\n    at scala.Option.getOrElse(Option.scala:121)     at\n  org.apache.spark.rdd.RDD.partitions(RDD.scala:250)    at\n  org.apache.spark.rdd.MapPartitionsRDD.getPartitions(MapPartitionsRDD.scala:35)\n    at\n  org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:252)\n    at\n  org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:250)\n    at scala.Option.getOrElse(Option.scala:121)     at\n  org.apache.spark.rdd.RDD.partitions(RDD.scala:250)    at\n  org.apache.spark.api.java.JavaRDDLike$class.partitions(JavaRDDLike.scala:61)\n    at\n  org.apache.spark.api.java.AbstractJavaRDDLike.partitions(JavaRDDLike.scala:45)\n    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at\n  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n    at\n  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n    at java.lang.reflect.Method.invoke(Method.java:498)     at\n  py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)  at\n  py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)    at\n  py4j.Gateway.invoke(Gateway.java:280)     at\n  py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)\n    at py4j.commands.CallCommand.execute(CallCommand.java:79)   at\n  py4j.GatewayConnection.run(GatewayConnection.java:214)    at\n  java.lang.Thread.run(Thread.java:748)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":49311592,"Users Score":0,"Answer":"Since you are in AWS already, it may be easier to just store your data files in s3, and open them directly from there.","Q_Score":0,"Tags":"python,apache-spark,amazon-ec2,pyspark","A_Id":49311725,"CreationDate":"2018-03-16T00:51:00.000","Title":"How to add your files across cluster on pyspark AWS","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I installed VSCode, downloaded official Python 3.6.4.\nVSCode detected and set the environment right - I do see \"python.pythonPath\" user setting set correctly.\nBut, when using VS Code using Ctrl+F5to run a Python file, I am always getting asked for \"select environment\" and it shows me two options\n - Python\n - Python Experimental\nWhat is this \"Python Experimental\"? How can I get rid of getting interrupted every time I try to run a script?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":13932,"Q_Id":49312540,"Users Score":53,"Answer":"Run > Add Configuration... => Choose one of the two options.\nAfter doing this it will no longer prompt you.","Q_Score":29,"Tags":"python,python-3.x,visual-studio-code","A_Id":49695873,"CreationDate":"2018-03-16T03:05:00.000","Title":"In vscode using Python, ctrl+F5 always asks for \"select environment\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am really new to Google API key.\nWhen am I testing my code on the local system, it is working fine but on an actual server it giving me SSLHandshakeError.\nServer configuration: nginx + unicorn + ubuntu + django + Python 2.7\nSSLHandshakeError at 'url'\n[Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":49313123,"Users Score":0,"Answer":"I just found the solution for my question, the error was coming due to package httplib2.\nI have just updated requests and httplib2.\npip install -U httplib2\npip install -U requests[security]","Q_Score":0,"Tags":"python,django,google-api","A_Id":49332855,"CreationDate":"2018-03-16T04:14:00.000","Title":"Google API key not working on server but working fine on local server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm wondering if there's a way how to share context between individual:\n\nthreads\ninstances\n\non Google App Engine. I assume memcache would do the job, but in my case the context is just a single integer and memcache sounds like an overkill.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":49324572,"Users Score":4,"Answer":"Assuming your application is running on GAE Standard:\n\nIn theory there may be ways to share state between threads that run on the same instance. In Python, this could take the form of a module level variable. This might make sense for extremely specialized types of caching, but it isn't reliable or durable because instances come and go over time. It also introduces the idea of cold and warm instances, which will make performance metrics harder to interpret.\nThere is not a way to share state between instances without using another system like Memcache or Datastore. It may seem like overkill for a small dataset, but those tools are probably what you're looking for.","Q_Score":1,"Tags":"python,google-app-engine","A_Id":49327295,"CreationDate":"2018-03-16T15:38:00.000","Title":"GAE: How to share context between threads and\/or instances","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have just inherited an extreemly legacy application (built on windows 95 - Magic7 for the connoisseurs) now backed against a recentish mssql db (2012). That's not the db system it was first designed on, and it thus comes with some seriously odd design for tables.\nI'm looking for a python ORM to help me talk to this thing easily. Namely, I'm after an ORM that can easily, for instance, merge 2 tables as if they were one.\nFor instance I may have tables BILLS and BILLS_HISTORY, with different column names, and perhaps even different column types, so different strictly speaking, but sementically containing the same information (same number of columns, sementically identical values).\nI'm looking for an ORM that lets me define only one Bill object, that maps to both tables, and that gives me the right hooks to decide where things go, and how to write them when tweaks are needed.\nAnother Example : say I have an object called a good. If a good is finished, it goes in the GOODS table, if it is not finished, it goes in the GOODS_UNFINISHED table. I'm looking for a goods object that can read both tables, and give me a finished property set to the right value depending which table it comes from  (and  with the hooks to change it from one table to the other if the property is set in some way).\nI'm fine with python, but I have not done much such db work before so my knowledge is limited there. I could, and might end up writing my own tailor made ORM, but that seems like a waste of time for something that will be thrown away in 6 months when the full transition is done to something new. Does anyone know of an ORM with such capabilities ? I'm planning to study ponyORM and SQLAlchemy, but I have a feeling it will take me a few days to come to a conclusion wether they are suitable for my use case. So I thought I'd ask the community too ...\nCheers","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":235,"Q_Id":49325336,"Users Score":0,"Answer":"For the record I've ended up with a hybrid approach using sqlalchemy.\nSqlalchemy was not flexible enough to do everything I wanted out of the box in a non verbose fashion, but had the required functionality to get a fair bit of the way along if one took the pain of writing explicitely everything needed. So I wrote a program that generates about 6000 lines of sqlalchemy code in order to have a 1 to 1 mapping between sqlalchemy objects to tables in the way required (basically defining everything explicitely for sqla). Sqlalchemy has a lot of hooks during autoload, but I have found it hard\/impossible to leverage different hooks and set fine grained behaviour at each hook at the same time, that's why I went the automated explicit way.\nOn top of these sqlalchemy objects, I've written objects that wraps them to hide the \"which table\" traffic control things. A bit of a kludge and I think that I could have done something with type heritance and sqlachemy objects, but time was passing and I only needed very little functionality or maintainability in that layer, so just charged ahead.","Q_Score":0,"Tags":"python,python-3.x,orm,sqlalchemy,ponyorm","A_Id":51031086,"CreationDate":"2018-03-16T16:19:00.000","Title":"Looking for a particular python ORM","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How does one properly and cleanly terminate a python program if needed? sys.exit() does not reliably perform this function as it merely terminates the thread it is called from, exit() and quit() are not supposed to be used except in terminal windows, raise SystemExit has the same issues as sys.exit() and is bad practice, and os._exit() immediately kills everything and does not clean up, which can cause issues with residuals.\nIs there a way to ALWAYS kill the program and all threads, regardless of where it is called from, while still cleaning up?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2043,"Q_Id":49325401,"Users Score":0,"Answer":"While your app is running Bad Things can happen, which we'd like to recover from. One example is Power Fail.\nThere is no computing technique for arranging for instructions to execute on a device that is powered off. So we may need to reset some state upon restart. Your app already has this requirement; I'm just making it explicit.\nIt is hard to reliably gain control just after each of the various Bad Things that might happen, as you found when you carefully considered several standard techniques. You weren't specific about the sort of items needing cleanup that you envision, but we could consider these cases:\n\ntransient - TCP connections, flock, etc.\npermanent - disk files, side effects on distant hosts\n\nRather than invoking your app directly, arrange for it to be run by a Nanny process which forks the app as a child. At some point the app will exit, the Nanny will regain control with all transient items having been tidied up by the OS, and then the Nanny can do any necessary cleanup on permanent items prior to an app restart. This is identical to the cleanup the Nanny will need to do on initial startup, for example after power fail events. The advantage of running your app under a parent process is that the parent can perform immediate cleanups after simple app failures such as SEGV.\nCleaning up permanent items likely involves timeouts on timestamped resources. If your system is able to reboot within say 2 seconds of a brief power outage, you may find it necessary to deliberately stay Down (sleep) for long enough to ensure that distant hosts have reliably detected your transition to Down, prior to announcing a transition to Up. Techniques like Virtual Synchrony and Paxos can help you drive toward rapid convergence.\nsummary\nSometimes an app will unexpectedly die before running cleanup code. Take a belt-and-suspenders approach: put essential cleanup code in the (simpler, more reliable) parent process.","Q_Score":8,"Tags":"python,python-3.x,exit-code","A_Id":49548156,"CreationDate":"2018-03-16T16:22:00.000","Title":"Proper method for terminating a python program regardless of call location, with cleanup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently on the search for differences in simulation software for python. Most hits from a search of google scholar that are comparisons of simulation software only mention DEVSimPy. \nSo my question is: are DEVSimPy and Simpy the same?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":198,"Q_Id":49325879,"Users Score":0,"Answer":"DEVSimPy has nothing to do with SimPy and I do not know why they are using such a similar name.","Q_Score":0,"Tags":"python-3.x,simpy","A_Id":49338128,"CreationDate":"2018-03-16T16:51:00.000","Title":"DEVSimPy vs Simpy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used a=\"string\" to initialize a string in Python.  I then used a.count(''); I did not write anything inside the quotes (not even a space). The count function returned 7 in this case. I also tried with a=str() and then repeated the countand got 1. Can anyone please explain it to me?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":49326487,"Users Score":2,"Answer":"As a result of the comparison iteration, Python \"finds\" a null string at every interstice of the string.  In this case, you have 6 characters, so there are 6+1 interstices (start, end, and five between the letters).\nSearching for a null string gets some results that are, at first, counter-intuitive.","Q_Score":0,"Tags":"python,string","A_Id":49326695,"CreationDate":"2018-03-16T17:31:00.000","Title":"Count function counting ' '","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A collaborator of mine wrote a software package in Python 2.7, took advantage of it to run some tests and obtain some scientific results. We wrote together a paper about the methods he developed and the results he obtained.\nEverything worked out well so he recently put this package publically available on his GitHub webpage.\nThen I thought it would have been useful to have a Python 3.5 version of that package. Therefore I downloaded the original software and made the proper changes to have it working on Python 3.5.\nNow I don't know how to properly release this Python 3.5 package.\nI envision three possibilities:\n\nShould I put it on his original GitHub project repository? This option would lead to some confusion, because people would have to download both the Python 2.7 and the Python 3.5 code.\nShould I create a new repository only for my Python 3.5 package, in addition to the Python 2.7 one released by my collaborator? This option would lead to the existence of two running code repositories, and to some confusion as well, because people might not know which is the \"official one\" to use.\nShould I create a new repository only for my Python 3.5 package, and ask my collaborator to delete his Python 2.7 repository? This option would make our paper inconsistent, because it states that tests were done with Python 2.7.\n\nDo you envision any other option I did not include?\nDo you have any suggestion?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":44,"Q_Id":49326559,"Users Score":1,"Answer":"I think number 1. and 2. should both work as long as you provide enough details in the README.md file in the repository. \nIn case of option 1, you should ask your collaborator to add you as a collaborator to the repository.\nIn case of number 2, you should definitely cross-link each other's repositories in your README-files respectively. \nI'd definitely add a requirements.txt file for each python version so that the users can conveniently install your dependencies with pip install -r requirements.txt or pip3 install -r requirements.txt.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,github,version","A_Id":49326823,"CreationDate":"2018-03-16T17:36:00.000","Title":"What's the best way to release two versions of the same software package 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 get an error when I execute python2 -m pip freeze this command. \nThe error message is as below:\n\/usr\/bin\/python: cannot import name HashMissing; 'pip' is a package and cannot be directly executed\nI had used apt-get remove --purge python python-pip fo removing the python2. \nThen, I do these path checking for knowing pip and python command path.  \n\n    john@mymachine:~$ whereis python\n    python: \/usr\/bin\/python \/usr\/bin\/python3.4m \/usr\/bin\/python3.4 \/usr\/bin\/python2.7 \/usr\/bin\/python2.7-config \/usr\/lib\/python3.4     \/usr\/lib\/python2.7 \/etc\/python3.4 \/etc\/python2.7 \/usr\/local\/lib\/python3.4 \/usr\/local\/lib\/python2.7 \/usr\/include\/python2.7 \/usr\/share\/python \/usr\/share\/man\/man1\/python.1.gz\n    john@mymachine:~$ which -a pip\n    \/usr\/local\/bin\/pip\n    jonh@mymachine:~$ whereis pip\n    pip: \/usr\/local\/bin\/pip \/usr\/local\/bin\/pip3.5 \/usr\/local\/bin\/pip2.7 \/usr\/local\/bin\/pip3.4\n    john@mymachine:~$ which -a python\n    \/usr\/bin\/python\n\nWish some help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":202,"Q_Id":49335903,"Users Score":0,"Answer":"Don't know the reason. But, I install the pip again.\nwget https:\/\/bootstrap.pypa.io\/get-pip.py\nand\npython get-pip.py\nThe problem is resolved.","Q_Score":0,"Tags":"python,pip","A_Id":49356101,"CreationDate":"2018-03-17T12:17:00.000","Title":"python2 -m pip freeze showing an 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":1,"Web Development":0},{"Question":"I've installed the new Anaconda 5.1. Before that, I had Anaconda 4 installed on my Windows 10 computer.\nHowever I'm only able to use the preinstalled anaconda modules like numpy, matplotlib. If I install a new module for example over pip I can't use it, because my IDE (Visual Studio Code, pyCharm or Jupyter Notebook) will not find it. If I open the python console directly, I can import any module. The IDEs use the correct python path.\nI've reinstalled anaconda a few times, but without any positive result.\nAnyone with the same problem have a solution?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":822,"Q_Id":49336202,"Users Score":0,"Answer":"Not sure if I understood your question on 100%, but you can try this approach:\n1) Open Anaconda prompt\n2) Type conda install [packagename]","Q_Score":0,"Tags":"python,anaconda","A_Id":49336400,"CreationDate":"2018-03-17T12:49:00.000","Title":"Can't find python module [Anaconda]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Scenario:  I have a graph, represented as a collection of nodes (0...n).  There are no edges in this graph.\nTo this graph, I connect nodes at random, one at a time.  An alternative way of saying this would be that I add random edges to the graph, one at a time.\nI do not want to create simple cycles in this graph.\nIs there a simple and\/or very efficient way to track the creation of cycles as I add random edges?  With a graph traversal, it is easy, since we only need to track the two end nodes of a single path.  But, with this situation, we have any number of paths that we need to track - and sometimes these paths combine into a larger path, and we need to track that too.\nI have tried several approaches, which mostly come down to maintaining a list of \"outer nodes\" and a set of nodes internal to them, and then when I add an edge going through it and updating it.  But, it becomes extremely convoluted, especially if I remove an edge in the graph.\nI have attempted to search out algorithms or discussions on this, and I can't really find anything.  I know I can do a BFS to check for cycles, but it's so so so horribly inefficient to BFS after every single edge addition.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":59,"Q_Id":49339575,"Users Score":1,"Answer":"Possible solution I came up with while in the shower.\nWhat I will do is maintain a list of size n, representing how many times that node has been on an edge.\nWhen I add an edge (i,j), I will increment list[i] and list[j].\nIf after an edge addition, list[i] > 1, and list[j] > 1, I will do a DFS starting from that edge.\nI realized I don't need to BFS, I only need to DFS from the last added edge, and I only need to do it if it at least has potential to be in a cycle (it's nodes show up twice).\nI doubt it is optimal.. maybe some kind of list of disjoint sets would be better.  But this is way better than anything I was thinking of before.","Q_Score":1,"Tags":"python,graph,graph-algorithm,traversal,graph-traversal","A_Id":49339891,"CreationDate":"2018-03-17T17:05:00.000","Title":"Tracking cycles while adding random edges to a sparse graph","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want assign the data which is retrieve from database (sqlit3) particular column  for a variable and call that variable for word tokenize.\nplease help with this\nI know tokenize part but I want to know how to assign the db value to a variable in python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":143,"Q_Id":49340877,"Users Score":0,"Answer":"This is worked but when using c.fetchall it didn't work.shows error saying TypeError: expected string or buffer\nimport sqlite3\nimport nltk\nfrom nltk.tokenize import sent_tokenize, word_tokenize\nconn = sqlite3.connect('ACE.db')\nc = conn.cursor()\nc.execute('SELECT can_answer FROM Can_Answer')\nrows = c.fetchone()\nfor row in rows:\n    print(row)\nprint(word_tokenize(row))","Q_Score":0,"Tags":"python,sqlite","A_Id":49361558,"CreationDate":"2018-03-17T19:12:00.000","Title":"how to assign db column value to variable and call it to tokenize in python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python distribution .h files are included in the include folder (C:\\Users\\x_user\\AppData\\Local\\Programs\\Python\\Python36-32\\include). I can not find the use of these .h files. How and where are these .h files are used (if in any python file)? I am running python 3.6.4 on Windows 8.1","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":166,"Q_Id":49340894,"Users Score":8,"Answer":"They are provided so that C extensions can be built against the Python installation.  It is all about support for third-party tools.\nIn general, day-to-day user has no need for those files.  It mainly affects them when they are installing an external tool that needs to be recompiled.","Q_Score":2,"Tags":"python,c,python-3.x,header-files","A_Id":49340937,"CreationDate":"2018-03-17T19:14:00.000","Title":"Why \"include\" folder contains .h files in python disribution (python 3.6.4)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The default database of the Django is sqlite, however I want to use MYSQL instead.Since the MYSQLdb module is not supported in python3.x, the official doc of django recommend using mysqlclient and MySQL Connector\/Pythoninstead.Here is the original doc:\n\nMySQL has a couple drivers that implement the Python Database API described in PEP 249:\n  \u2022 mysqlclient is a native driver. It\u2019s the recommended choice.\n  \u2022 MySQL Connector\/Python is a pure Python driver from Oracle that does not require the MySQL client library\n  or any Python modules outside the standard library.\n  These drivers are thread-safe and provide connection pooling.\n  In addition to a DB API driver, Django needs an adapter to access the database drivers from its ORM. Django provides\n  an adapter for mysqlclient while MySQL Connector\/Python includes its own.\n\nI've got the latest version of mysql-client and mysql-connector-python, but as I execute themigratecommand, error occurs.Here is part of the message:\n\nUnhandled exception in thread started by .wrapper at 0x7f2112e99d90>\n  Traceback (most recent call last):\n    File \"\/home\/lothakim\/anaconda3\/envs\/py36\/lib\/python3.6\/site-packages\/django\/db\/backends\/mysql\/base.py\", line 15, in \n      import MySQLdb as Database\n  ModuleNotFoundError: No module named'MySQLdb'django..........core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.Did you install mysqlclient?\n\nIt seems to be the problem of the database connection.But I followed every step of the official tutorial.How can I fix this problem?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":761,"Q_Id":49345950,"Users Score":1,"Answer":"It's a silly mistake...\nI confuse the mysql-client with mysqlclient.The former is part of the MYSQL application, while the latter is a python module.I didn't install the latter.Also note you should sudo apt-get install libmysqlclient-devbefore pip install mysqlclient.","Q_Score":3,"Tags":"python,mysql,django","A_Id":49346089,"CreationDate":"2018-03-18T08:33:00.000","Title":"How do I use MYSQL as the database in a Django project?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a csv file with traffic density data per road segment of a certain high way, measured in Annual average daily traffic (AADT). Now I want to visualize this data.\nSince I have the locations (lat and lon) of the road segments, my idea is to create lines between these points and give it a color which relates to the AADT value. So suppose, road segments \/ lines with high AADT are marked red and low AADT are marked green.\nWhich package should I use for this visualization?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":253,"Q_Id":49349788,"Users Score":0,"Answer":"It is difficult to say without any information about the structure of the data.\nIs it just points? Is it a shapefile? Probably you should start with geopandas....","Q_Score":0,"Tags":"python-3.x,data-visualization","A_Id":49357921,"CreationDate":"2018-03-18T15:41:00.000","Title":"traffic density visualization in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a huge NumPy matrix of dimension (1919090, 140, 37). Now it is not easy to fit something that large anywhere in the memory local or on a server.\nSo I was thinking of splitting the NumPy matrix into smaller parts say of (19,000, 140, 37) and then training a Keras model on it. I store the model, then loading it again and continue training on the next matrix portion. I repeat this until the model is trained on all the 100 or so matrix bits. \nIs there a way of doing it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":49354178,"Users Score":1,"Answer":"Yes, you can, but the concept is not called \"stages\" but batches and it is the most common method to train neural networks. You just need to make a generator function that loads batches of your data one at a time and use model.fit_generator to start training it.","Q_Score":0,"Tags":"python,numpy,tensorflow,deep-learning,keras","A_Id":49357236,"CreationDate":"2018-03-19T00:19:00.000","Title":"Can we train a Keras Model in Stages?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I save a python source code file, I want to re-run the script. Is there a command that works like this (sort of like nodemon for node)?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":30397,"Q_Id":49355010,"Users Score":2,"Answer":"I just use npx nodemon pythonfile.py\nand it works.Make sure you are using nodemon v2.0.x\nor above","Q_Score":64,"Tags":"python,nodemon","A_Id":63014698,"CreationDate":"2018-03-19T02:32:00.000","Title":"How do i watch python source code files and restart when i save?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a dedicated OAuth2 as a service for my application, where users will be both authenticating and authorizing themselves. \nI've the following concerns\n1) Is OAuth2 TokenScope similar to Django Permissions?\n2) If I want to make role-level hierarchy application, how do I go about building one with OAuth2?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":59,"Q_Id":49356867,"Users Score":1,"Answer":"Actually there is a difference between Django permissions and OAuth token scope, Django permissions use for define access level to your endpoint addresses like when you want just authenticated user see some data but OAuth token scope is for time you want to have third-party login and you define when somebody login what access he\/she has, like when you authenticate from Gmail in scope Gmail, for example, says read and you just have read access when you login .\nand I didn't get you concern number 2","Q_Score":1,"Tags":"python,django,django-permissions,django-oauth","A_Id":53847566,"CreationDate":"2018-03-19T06:18:00.000","Title":"Is OAuth2 TokenScope similar to Django Permissions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have some python code which is heavily dependent on greenlets.  I can use either gevent or eventlet.\nI have packaged some sections of the code in a C-extension but these calls do not yield to other greenlets.  Is it possible to write my extension such that it will yield control to other python threads while it does not require the GIL?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":49358984,"Users Score":0,"Answer":"You can use normal PyObject_CallFunction(eventlet\/greenlet.sleep) to yield control to other green threads. It must be run with GIL locked, like any other Python code.\nYou can not run Python code without GIL. (you can but it will quickly go sideways and corrupt memory).","Q_Score":1,"Tags":"python,gevent,eventlet,python-extensions,greenlets","A_Id":49380361,"CreationDate":"2018-03-19T08:56:00.000","Title":"Make C-Extension calls \"green\" 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 making a Stock Market Predictor machine learning application that will try to predict the price for a certain stock. It will take news articles\/tweets regarding that particular company and the company's historical data for this reason.\nMy issue is that I need to first construct a sentiment analyser for the headlines\/tweets for that company. I dont want to train a model to give me the sentiment scores rather, I want a sentiment lexicon that contains a bag of words related to stock market and finance.\nIs there any such lexicons\/dictionaries available that I can use in my project?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":2572,"Q_Id":49360828,"Users Score":2,"Answer":"Not readily available, but trivial to build on your own. Simply download a sentiment annotated twitter dataset, construct a dictionary of words for it, iterate over the entries and add +1\/(-1) to positive(\/negative) words. Finally, divide each word's values by its respective occurrence count and you'll have a naive sentiment score for each word, with values close to 1(\/-1) indicating strong sentiment charge, which you can use for your BoW task.","Q_Score":2,"Tags":"python,machine-learning,nlp,nltk,sentiment-analysis","A_Id":49361454,"CreationDate":"2018-03-19T10:35:00.000","Title":"Sentiment Lexicon for stock market prediction","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying test my python script using jenkins.Issue I am facing is with the test report generation\nI have created a folder 'test_reports' in my jenkins workspace.\nC:\\Program Files (x86)\\Jenkins\\jobs\\PythonTest\\test_reports\nBut then when I run the script from jenkins I get the error as,\nERROR: Step \u2018Publish JUnit test result report\u2019 failed: No test report files were found. Configuration error?\nHow do I actually configure the test report? Is the xml file generated automatically?\nAny help would be greatly appreciated","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":648,"Q_Id":49361114,"Users Score":0,"Answer":"This was an expected result because,The script file I wrote was not a unit-test module.It was just a normal python file(It wasn't supposed to create any XML results).\nOnce I created the script using unit-test framework and import the xml runner,I was able to generate the xml files of the result.","Q_Score":0,"Tags":"python,testing,jenkins,report","A_Id":49377372,"CreationDate":"2018-03-19T10:49:00.000","Title":"How to configure xml Report in jenkins","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 customer support bot which helps business users understand the meaning of certain technical terms or status of some of their requests. A typical sentence looks like below\n\nExplain me about Air Compressor\/Heating and cooling systems\/ Law Of\nThermodynamics \nGet me the status of Ticket123\/HEATER12\n\nWhat have I done so far\nI currently use Microsoft LUIS to identify the entities where I upload all the possible entities and LUIS does a string match and return them. The problem with this approach is \n\nThe entity list keeps getting bigger and needs to be updated everyday\nUser may type in spelling mistakes - In some cases, the word user types may not be a dictionary word for the spelling to be corrected.\n\nWhat's my solution (which doesn't seem to work well)\nI'm currently thinking of an approach to tag the POS and group the noun phrases\/nouns but I dont think this will be an effective method.\nAlso one thing to be noted is that the entities don't follow any pattern. What should be my approach here. Any pointers would be appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":49362788,"Users Score":0,"Answer":"You could possibly do below for your problems:\n\nList all your entities in Excel, if it keeps getting bigger you just need to add more rows in excel and not on your code. After that write a regex to match your entities with the required information.\nFor spelling mistakes: You can implement something like Fuzzywuzzy in Python. You will get the nearest match and then you can apply the step 1 to capture your entity.","Q_Score":0,"Tags":"python,nlp,nltk,azure-language-understanding","A_Id":52532384,"CreationDate":"2018-03-19T12:17:00.000","Title":"Varaiable entity extraction - No pattern in the entities of a sentence - NLP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a customer support bot which helps business users understand the meaning of certain technical terms or status of some of their requests. A typical sentence looks like below\n\nExplain me about Air Compressor\/Heating and cooling systems\/ Law Of\nThermodynamics \nGet me the status of Ticket123\/HEATER12\n\nWhat have I done so far\nI currently use Microsoft LUIS to identify the entities where I upload all the possible entities and LUIS does a string match and return them. The problem with this approach is \n\nThe entity list keeps getting bigger and needs to be updated everyday\nUser may type in spelling mistakes - In some cases, the word user types may not be a dictionary word for the spelling to be corrected.\n\nWhat's my solution (which doesn't seem to work well)\nI'm currently thinking of an approach to tag the POS and group the noun phrases\/nouns but I dont think this will be an effective method.\nAlso one thing to be noted is that the entities don't follow any pattern. What should be my approach here. Any pointers would be appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":49362788,"Users Score":0,"Answer":"I know this is quite an old question, but I wanted to add that the modern solution would be to use Machine-Learned entities instead of List or Regex or Patterns. You just tag the entity in each utterance, and it will learn based on the context of the sentence. For example, if you trained LUIS based on the utterances in bullet one, it would start to recognize any phrase after \"Explain me about...\". It can be a bit hit or miss on single vs. multiple word phrases, but as you add more utterances with tagged entities, it will be better about giving you the expected results.\nModern solution for spelling mistakes would be to use Bing Search to pre-process your utterance before sending it to LUIS (on older versions of LUIS you could attach your spell checking directly to the LUIS recognizer creation, but in the latest version you have to do it separately).","Q_Score":0,"Tags":"python,nlp,nltk,azure-language-understanding","A_Id":68836314,"CreationDate":"2018-03-19T12:17:00.000","Title":"Varaiable entity extraction - No pattern in the entities of a sentence - NLP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I import tensorflow in Python I get this error:\n\nC:\\Users\\Sathsara\\Anaconda3\\envs\\tensorflow\\Lib\\site-packages\\h5py__init__.py:36:\n  FutureWarning: Conversion of the second argument of issubdtype from\n  float to np.floating is deprecated. In future, it will be treated\n  as np.float64 == np.dtype(float).type.   from ._conv import\n  register_converters as _register_converters","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":1143,"Q_Id":49363172,"Users Score":4,"Answer":"You could upgrade h5py to a more recent version. It worked for me.\n\nsudo pip3 install h5py==2.8.0rc1","Q_Score":1,"Tags":"python,tensorflow,anaconda","A_Id":49890401,"CreationDate":"2018-03-19T12:37:00.000","Title":"I got a message when importing tensorflow in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I import tensorflow in Python I get this error:\n\nC:\\Users\\Sathsara\\Anaconda3\\envs\\tensorflow\\Lib\\site-packages\\h5py__init__.py:36:\n  FutureWarning: Conversion of the second argument of issubdtype from\n  float to np.floating is deprecated. In future, it will be treated\n  as np.float64 == np.dtype(float).type.   from ._conv import\n  register_converters as _register_converters","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":1143,"Q_Id":49363172,"Users Score":4,"Answer":"Its not an error, its just informing you that in future releases the this feature or behaviour is going to change or be no longer available.\nThis is important if you plan to reuse this code with different versions of python and tensorflow.","Q_Score":1,"Tags":"python,tensorflow,anaconda","A_Id":49363229,"CreationDate":"2018-03-19T12:37:00.000","Title":"I got a message when importing tensorflow in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right now, on the \"All releases\" page of the Python Software Foundation website, the \"Download latest release\" links to the Python 3.6.4 version.\nHowever, you can find on the page that the release is from the 2017-12-19 and there has been two others release since, for Python 3.5.5 and Python 3.4.8 .\n\nI understand why there is two parallel version of Python with 3 and 2.7, but I do not understand why they are multiple versions of Python 3, as it should be backward compatible with Python 3 code.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":256,"Q_Id":49365864,"Users Score":1,"Answer":"Python 3.x is not nesscarily backward compatible. For instance in python 3.6, string interpolation was introduced, aka f-string.\nIn python 3.5 type hints were introduced which would not be backwards compatible with older 3.x versions.","Q_Score":4,"Tags":"python,python-3.x,versioning","A_Id":49365953,"CreationDate":"2018-03-19T14:53:00.000","Title":"Why are they some new releases of Python 3 on older Python 3 versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right now, on the \"All releases\" page of the Python Software Foundation website, the \"Download latest release\" links to the Python 3.6.4 version.\nHowever, you can find on the page that the release is from the 2017-12-19 and there has been two others release since, for Python 3.5.5 and Python 3.4.8 .\n\nI understand why there is two parallel version of Python with 3 and 2.7, but I do not understand why they are multiple versions of Python 3, as it should be backward compatible with Python 3 code.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":256,"Q_Id":49365864,"Users Score":5,"Answer":"x.y.Z point releases are usually bug fix releases.\nx.Y releases are usually feature releases, but might contain minor backwards incompatibilities.\nX releases are large changes possibly breaking a lot of existing code.\nIn practice you cannot always upgrade your x.Y version immediately; reasons range from actual code incompatibilities which cannot be fixed quickly to internal deployment limitations to scheduling reasons. Linux distributions also often distribute one specific x.Y version and will pick up the next version only a year later in their annual release cycle or so. However, x.y.Z versions are often picked up soon and can typically be installed without breaking existing code.\nThe reason several x.y.Z versions are maintained in parallel is that users want to reap the benefits of bug fixes without being forced to upgrade to a new major version.","Q_Score":4,"Tags":"python,python-3.x,versioning","A_Id":49366160,"CreationDate":"2018-03-19T14:53:00.000","Title":"Why are they some new releases of Python 3 on older Python 3 versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the advantages of saving file in .pkl format over .txt or .csv format in Python?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4316,"Q_Id":49370591,"Users Score":1,"Answer":".pkl can serialize a very wide range of objects, not just text data.","Q_Score":3,"Tags":"python,pickle","A_Id":49370614,"CreationDate":"2018-03-19T19:06:00.000","Title":"What are the advantages of .pkl file over .txt or csv file 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":"Is there any other than HyperOpt that can support multiprocessing for a hyper-parameter search? I know that HyperOpt can be configured to use MongoDB but it seems like it is easy to get it wrong and spend a week in the weeds, is there anything that is more popular and effective?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1674,"Q_Id":49373721,"Users Score":1,"Answer":"Some models(say RandomForest) have \"njobs\" parameter for use of number of cores. You can try njobs=-1; thus even if hyperopt uses 1 core, each trial would use all the cores, speeding up the process.","Q_Score":1,"Tags":"python,mongodb,deep-learning,hyperparameters","A_Id":63932747,"CreationDate":"2018-03-19T22:55:00.000","Title":"Python: Alternative to hyperopt that can support multiprocessing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Anaconda 5.1 and Python 3.6 on a Windows 10 machine.\nI'm having quite a few problems ; I tried to add some useful tools such as lightGBM, tensorflow, keras, bokeh,... to my conda environment but once I've used\nconda install -c conda-forge packagename\non all of these, I end up having downgrading and upgrading of different packages that just mess with my installation and I can't use anything anymore after those installations.\nI wonder if it were possible to have multiples versions of packages & dependencies living alongside each other which won't kill my install?\nSorry if my question seems noobish and thanks for your help,\nNate","AnswerCount":4,"Available Count":2,"Score":-1.0,"is_accepted":false,"ViewCount":49725,"Q_Id":49374217,"Users Score":-4,"Answer":"You can try using different conda environments. For example:\nconda create -n myenv\nThen you can activate your environment with:\nconda activate myenv\nand deactivate with:\nconda deactivate","Q_Score":25,"Tags":"python-3.x,anaconda,packages","A_Id":70389655,"CreationDate":"2018-03-19T23:47:00.000","Title":"Dependencies and packages conflicts in Anaconda?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Anaconda 5.1 and Python 3.6 on a Windows 10 machine.\nI'm having quite a few problems ; I tried to add some useful tools such as lightGBM, tensorflow, keras, bokeh,... to my conda environment but once I've used\nconda install -c conda-forge packagename\non all of these, I end up having downgrading and upgrading of different packages that just mess with my installation and I can't use anything anymore after those installations.\nI wonder if it were possible to have multiples versions of packages & dependencies living alongside each other which won't kill my install?\nSorry if my question seems noobish and thanks for your help,\nNate","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":49725,"Q_Id":49374217,"Users Score":6,"Answer":"You could try disabling transitive deps updates by passing --no-update-dependencies or --no-update-deps to conda install command. Ex: \nconda install --no-update-deps pandas.","Q_Score":25,"Tags":"python-3.x,anaconda,packages","A_Id":49374371,"CreationDate":"2018-03-19T23:47:00.000","Title":"Dependencies and packages conflicts in Anaconda?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to pull invoices by Accounts and have not managed to find a way to link the two. Am I missing something? \nI tried through Contacts but it doesn't seem to have an Account or Account ID to match\nI am using Pyxero for this, however this doesn't seem relevant, more so the data from xero api.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":49382835,"Users Score":0,"Answer":"I've figured it out - these details only appear when pulling an invoice one by one or paginated in the line items column.","Q_Score":0,"Tags":"python,xero-api","A_Id":49387718,"CreationDate":"2018-03-20T11:18:00.000","Title":"Xero Api matching Accounts with Invoices","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to configuring and setting up Python from scratch.\nI have installed Anaconda and I plan to use Spyder for python development. I also have a older version of Python installed on the same machine elsewhere.\nI needed to get my hands on a package to use in Spyder which I needed to download and install.\nI downloaded and installed pip directly from the website and then I used this in the command line of the older python install to obtain the package I required.\nHowever I don't understand how I go about making this available to Spyder. I believe it works on a folder structure within it's own directory and I am unsure how to change this to get the package I have already downloaded.\nI thought I might be able to copy it across, or point it at the directory where the package was downloaded to but I cannot work out how to do this.\nI also tried using pip from within Spyder to work but it cannot find it.\nCan you please let me know what I need to check?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":49383201,"Users Score":0,"Answer":"Try to:\nOpen Anaconda Prompt and then do:  pip install whatever - to install wheels\nIf you want to install spyder the open Anaconda Navigator - and you should be in the home tab - then highlat spyder and press install - thats all.","Q_Score":0,"Tags":"python,packages","A_Id":49383321,"CreationDate":"2018-03-20T11:36:00.000","Title":"Install Python packages and directories (windows)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In LightFM, the evaluation methods e.g. precision_at_k have a preserve_rows parameter with default value False. In what cases would I make it True?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":86,"Q_Id":49384696,"Users Score":1,"Answer":"In case some other bit of your code expected your score arrays to maintain their size. I wouldn't expect this to be common.\nIn most cases you just take a mean of the result.","Q_Score":1,"Tags":"python,recommender-systems","A_Id":49630915,"CreationDate":"2018-03-20T12:50:00.000","Title":"LightFM: When do I make preserve_rows=True","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a box where we are running a internal web page build on perl-cgi. My knowledge is little limited about coding. but I want to run some pages built on python cgi. Technically is it possible to run both perl+python cgi on same server without doing much configuration change","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":95,"Q_Id":49386143,"Users Score":3,"Answer":"Yes. It's actually very easy. Because cgi doesn't care what language it's written it - it's just a script that the web server runs on demand, and passes parameters. \nYou can even use compiled C as your cgi language if you want. \nAll you need to do is be able to read the local environment (and pretty much every language can) and read STDIN - and pretty much every language can. \nYou can comfortably run perl and python scripts along side each other - the server simply doesn't care. \nTo get more complicated, you might want to preload\/prefork your cgi scripts, and then it starts to be a little more complicated to use arbitrary languages. \nBut for a basic run-on-demand cgi script, anything will suffice.","Q_Score":1,"Tags":"python,perl,cgi","A_Id":49386283,"CreationDate":"2018-03-20T13:54:00.000","Title":"Can we run perl and python cgi web portal from same server\/box","Data Science and Machine Learning":0,"Database and SQL":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 code which is quite heavy, my computer cant run it efficiently, therefore i want to run the python code on cloud.\nPlease tell me how to do it ? any step by step tutorial available\nthanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3979,"Q_Id":49386402,"Users Score":0,"Answer":"You can try Heroku. It's free and they got their own tutorials. But it's good enough only if you will use it for studying. AWS, Azure or google cloud are much better for production.","Q_Score":3,"Tags":"python,cloud","A_Id":49386557,"CreationDate":"2018-03-20T14:04:00.000","Title":"How to run python code on cloud","Data Science and Machine Learning":0,"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 automate a Python script on a Google Cloud VM using Crontab.\nWhen I run python Daily_visits.py my code runs as expected and generates a table in BigQuery.\nMy Crontab job is as follows: *\/2 * * * * \/usr\/bin\/python Daily_visits.py but generates no output.\nI've run which python and I get \/usr\/bin\/python back, and I have run chmod +x Daily_visits.sh on my file, what else am I missing?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":842,"Q_Id":49386938,"Users Score":4,"Answer":"You should write absolute path for Daily_visits.py file. Go to Daily_visits.py file's directory and run command:\npwd\nYou take output like it:\n\/var\/www\/Daily_visits.py\nCopy and paste it change into crontab.\n*\/2 * * * * \/usr\/bin\/python \/var\/www\/Daily_visits.py","Q_Score":0,"Tags":"python,linux,google-cloud-platform","A_Id":49387025,"CreationDate":"2018-03-20T14:28:00.000","Title":"Automating a Python script with 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 developing a service which has to copy multiple files from a central node to remote servers. \nThe problem is that each time the service is executed, there are new servers and new files to dispatch to these servers. I mean, in each execution, I have the information of which files have to be copied to each server and in which directory.\nObviously, this information is very dynamically changing, so I would like to be able to automatize this task. I tried to get a solution with Ansible, FTP and SCP over Python.\n\nI think Ansible is very difficult to automatize every scp task in each execution.\nSCP is ok but I need to build each SCP command in Python to launch it.\nFTP Is too much for this problem because there are not many files to dispatch to a single server.\n\nIs there any better solution than what I thinked about?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":938,"Q_Id":49387534,"Users Score":0,"Answer":"In case you send some the same file (or files) to different destinations (that can be organized as sets), you could profit from solutions as dsh or parallel-scp.\nIf this will make sense depends on your use-case.","Q_Score":0,"Tags":"python,automation","A_Id":49387782,"CreationDate":"2018-03-20T14:56:00.000","Title":"Best way to copy multiple files to multiple remote servers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm developing a service which has to copy multiple files from a central node to remote servers. \nThe problem is that each time the service is executed, there are new servers and new files to dispatch to these servers. I mean, in each execution, I have the information of which files have to be copied to each server and in which directory.\nObviously, this information is very dynamically changing, so I would like to be able to automatize this task. I tried to get a solution with Ansible, FTP and SCP over Python.\n\nI think Ansible is very difficult to automatize every scp task in each execution.\nSCP is ok but I need to build each SCP command in Python to launch it.\nFTP Is too much for this problem because there are not many files to dispatch to a single server.\n\nIs there any better solution than what I thinked about?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":938,"Q_Id":49387534,"Users Score":0,"Answer":"How about rsync ?\nExample: rsync -rave  \nWhere source or destination could be:\nuser@IP:\/path\/to\/dest\nIt knows incremental + you can Cron it or trigger a small script when anything changes","Q_Score":0,"Tags":"python,automation","A_Id":49392450,"CreationDate":"2018-03-20T14:56:00.000","Title":"Best way to copy multiple files to multiple remote servers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've been looking for a little time now, and can't find an answer to my problem.\nI'm coding on vim and I tried the new format string version f'whatever {a_var}', but my flake8 \/ syntastic keep telling me that's a syntax error.\nDo you have any idea on how to fix this ?\nI already had a problem with vim-jedi for python3.6 and virtualenv, and after hours of research I found a hack in some github issue, but here I can't find anything.\nThanks in advance for your help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1457,"Q_Id":49389635,"Users Score":5,"Answer":"You have to verify that your flake8 script uses python3.6. Run which flake8 in command line, open the file in vim (or directly run vim $(which flake8)) and see the shebang line (the first line of the file, it starts with #!). If it's not python3.6 \u2014 edit the line.","Q_Score":3,"Tags":"vim,python-3.6,flake8","A_Id":49391826,"CreationDate":"2018-03-20T16:35:00.000","Title":"Vim flake8 python 3.6 support","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write a migration which grants readonly permissions to each schema in my multi-tenant postgres DB. \nThe migrations run once per schema, so what I would like to do would be capture the name of the schema for which it is running, and then use that schema_name in my SQL statement to grant permissions for that schema. \nIn django, I can create a migration operation called 'RunPython', and from within that python code I can determine for which schema the migrations are currently running (schema_editor.connection.connection_name). \nWhat I want to do is pass that information to the next migration operation, namely \"RunSQL\", so that the SQL I run can be:\n\"GRANT SELECT ON ALL TABLES IN SCHEMA {schema_name_from_python_code} TO readaccess;\"\nIf anyone can shed any light on this issue it would be greatly appreciated. Cheers!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":668,"Q_Id":49389756,"Users Score":0,"Answer":"I was able to figure this out by getting rid of the migrations.runSQL. I just have migrations.RunPython. From within that python forward_func I am able to access the DB and write sql there (with the necessary string interpolation) \n:)","Q_Score":0,"Tags":"django,python-3.x,postgresql,multi-tenant,django-migrations","A_Id":49412917,"CreationDate":"2018-03-20T16:41:00.000","Title":"How to combine migrations.RunPython and migrations.RunSQL in django migration operation","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Hi everyone I am trying to write some script to automate my work in Maya. \nRight now I am looking for the way to add materials to the hypershade.\nI can't see anything on console (Script editor) so I can't se what python api I should use. \nI know that maya treat materials as sets, and to assign a material to polygon I need to put it in this set, but I don't know how to create a new set. \nSo my question is:\nHow I add a material to the scene using python maya-api?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":469,"Q_Id":49390281,"Users Score":1,"Answer":"you have to use createNode :\nnode = cmds.createNode('blinn', name='yipikai')","Q_Score":0,"Tags":"python,maya,maya-api","A_Id":49390999,"CreationDate":"2018-03-20T17:08:00.000","Title":"How to add an material to the maya scene?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Good day. I have a question about proceeding accepted connections. I have a pythons tornado IOLoop and listening socket. When a new client is connected and this connection is accepted by tornado handler client - interaction begins. That interaction includes multiple requests\/responses, so there is a reason to poll accepted socket for available bytes. How to do polling the correct way? The direct way is to use epoll\/select, but this is like reinventing IOLoop. But is this correct to create IOLoop for each new connection?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":49390862,"Users Score":0,"Answer":"I've searched how \"torando.web\" does it. It works with default IOLoop instance and that instance accepts connections and handles (processes) new sockets that were created after connections were accepted. The second part is done by IOStream.\nSo the answer is to use the same IOLoop object and not to poll sockets manually","Q_Score":0,"Tags":"python,select,tornado,epoll,ioloop","A_Id":49399600,"CreationDate":"2018-03-20T17:40:00.000","Title":"IOLoop\/epoll\/select for accepted connections","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"What is meant by Activation function in Machine learning. I go through with most of the articles and videos, everyone states or compare that with neural network. I'am a newbie to machine learning and not that much familiar with deep learning and neural networks. So, can any one explain me what exactly an Activation function is ? instead of explaining with neural networks. I struck with this ambiguity while I learning Sigmoid function for logistic regression.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":317,"Q_Id":49391576,"Users Score":0,"Answer":"Simply put, an activation function is a function that is added into an artificial neural network in order to help the network learn complex patterns in the data. When comparing with a neuron-based model that is in our brains, the activation function is at the end deciding what is to be fired to the next neuron. That is exactly what an activation function does in an ANN as well. It takes in the output signal from the previous cell and converts it into some form that can be taken as input to the next cell.","Q_Score":2,"Tags":"python,math,machine-learning,calculus,sigmoid","A_Id":62830161,"CreationDate":"2018-03-20T18:21:00.000","Title":"Activation Function in Machine learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed tensorflow on my mac and now I can't seem to open anaconda-navigator. When I launch the app, it appears in the dock but disappears quickly. When I launch anaconda-navigator the terminal I get the following error(s).\nKeyError: 'pip._vendor.urllib3.contrib'","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":49393300,"Users Score":0,"Answer":"I fixed the issue by downgrading to pip version 9.0.1. It appears anaconda doesn't like pip version 9.0.2 I ran: pip install pip==9.0.1","Q_Score":0,"Tags":"python,macos,tensorflow,terminal,anaconda","A_Id":49401566,"CreationDate":"2018-03-20T20:11:00.000","Title":"I installed tensorflow on mac and now I can't open Anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I type in: cqlsh in my terminal window, I get an error that says:\n-bash: \/usr\/local\/bin\/cqlsh: \/usr\/local\/opt\/python\/bin\/python2.7: bad interpreter: No such file or directory\nHowever, if I type Python --version the terminal verifies that  Python 2.7.10 installed on my computer.\nIt seems to me like cqlsh is trying to run python but it is in the wrong directory? \nAny help would be greatly appreciated!\nSome more context: I have a docker container with a scylla (cassandra look-alike) database, but I want to use cqlsh locally.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":404,"Q_Id":49393559,"Users Score":0,"Answer":"To run cqlsh the simplest is to do: sudo docker exec -it some-scylla10 cqlsh\nPython2.7 is under \/usr\/bin\/python2.7  inside the scylla container","Q_Score":0,"Tags":"python,linux,cassandra,cqlsh,scylla","A_Id":49419997,"CreationDate":"2018-03-20T20:29:00.000","Title":"cqlsh unable to find the version of Python it needs to execute","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to incorporate a particular performance metric into my portfolio managing software. This metric should be one where I can measure \n\"how much of the potential gains from the selected assets have been captured by the selected portfolio composition\". \nConsider the following table reporting a portfolio's performance with key metrics between dates 2017\/10 and 2018\/03  \nnetpeq: net $ profit gained over the period\naroc: annualized rate of change in asset's price over the period\ncagr: compounded annualized growth  of portfolio over the period  \nI need a metric which penalizes divergence between cagr (or netpeq) and aroc. Namely, positive aroc says these asset could have produced growth (as in BA, MSFT, CSCO) but the portfolio manager failed to make money out of these or even lost money. \nI would like to measure the extent the portfolio manager missed to capture\n a. the growth potential due to each asset in the portfolio\n b. the overall growth potential w.r.t portfolio as a whole.\n\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| name    | netpeq   | draw     | aroa    | cagr  | sharpe | rvalue | aroc   |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| BA      | -555.71  | 3439.15  | -36.54  | -1.25 | -0.17  | 0.42   | 64.58  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| DWDP    | 0        | 0        | 0       | 0     | 0      | 0      | -13.18 |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| CAT     | -447.66  | 1361.54  | -74.36  | -1.01 | -0.66  | -0.17  | 39.91  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| WMT     | 363.25   | 448.09   | 183.34  | 0.82  | 1.1    | 0.66   | 4.73   |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| UTX     | 0        | 0        | 0       | 0     | 0      | 0      | 18.96  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| NKE     | 690.34   | 498.24   | 313.36  | 1.57  | 1.21   | 0.84   | 67.19  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| VZ      | -76      | 76       | -226.16 | -0.17 | -2.18  | -0.63  | 4.73   |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| XOM     | -272.87  | 555.36   | -111.12 | -0.62 | -0.65  | -0.46  | -18.69 |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| GE      | 0        | 0        | 0       | 0     | 0      | 0      | -85.61 |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| MCD     | 1025.63  | 731.44   | 317.12  | 2.33  | 1.09   | 0.64   | -6.02  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| CSCO    | -313.88  | 313.88   | -226.16 | -0.71 | -1.81  | -0.39  | 75.23  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| JPM     | 961.69   | 267.33   | 813.59  | 2.19  | 1.72   | 0.86   | 45.46  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| V       | 3261.55  | 1969.88  | 374.46  | 7.53  | 1.76   | 0.9    | 31.18  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| GS      | 0        | 0        | 0       | 0     | 0      | 0      | 24.24  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| HD      | -32.32   | 960.59   | -7.61   | -0.07 | -0.06  | 0.09   | 20     |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| PFE     | 0        | 0        | 0       | 0     | 0      | 0      | 4.12   |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| KO      | 0        | 0        | 0       | 0     | 0      | 0      | -10.66 |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| MMM     | 0        | 0        | 0       | 0     | 0      | 0      | 17.01  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| DIS     | 0        | 0        | 0       | 0     | 0      | 0      | 11.43  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| CVX     | 357.2    | 1415.09  | 57.09   | 0.81  | 0.37   | 0.33   | -5.8   |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| INTC    | 1632.52  | 599.42   | 615.95  | 3.73  | 1.4    | 0.63   | 67.32  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| PG      | -197.12  | 314.7    | -141.66 | -0.45 | -1.25  | -0.72  | -32.05 |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| TRV     | -348.86  | 348.86   | -226.16 | -0.79 | -1.55  | -0.79  | 26.49  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| MSFT    | -205.86  | 680.29   | -68.44  | -0.46 | -0.42  | 0.25   | 47.6   |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| AAPL    | 0        | 0        | 0       | 0     | 0      | 0      | 28.32  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| JNJ     | 17.55    | 64.8     | 61.25   | 0.04  | 0.33   | 0.43   | -7.55  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| AXP     | -1366.89 | 1492.43  | -207.14 | -3.06 | -1.69  | -0.77  | 5.65   |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| IBM     | 0        | 0        | 0       | 0     | 0      | 0      | 20.59  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| UNH     | 877.04   | 676.82   | 293.06  | 1.99  | 1.13   | 0.79   | 39.98  |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| MRK     | 0        | 0        | 0       | 0     | 0      | 0      | -27.88 |\n+---------+----------+----------+---------+-------+--------+--------+--------+\n| RunPort | 5369.6   | 10091.44 | 120.34  | 12.56 | 0.65   | 0.73   | -1     |\n+---------+----------+----------+---------+-------+--------+--------+--------+","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":595,"Q_Id":49394773,"Users Score":0,"Answer":"A reasonable intensive measure of how much a market instrument within a portfolio captured its potential would be the geometric difference between its IRR for the period and its annualized market return for the same period.\nFor this you would need the cash flow amounts and dates into and out of the instrument, its actual opening and closing market value and the total market return of the component.\nIf the instrument or its IRR-implied value is ever short at any time during the period, then you would need to employ an advanced version of IRR instead of the standard calculations provided in Excel.\nWhat is usually the more relevant is the extensive measure of the achieved controllable relative success of the management of a portfolio. It is best captured by a well-formulated value-based decision attribution analysis using daily data.\nAndre Mirabelli","Q_Score":0,"Tags":"python,performance,portfolio,metric,attribution","A_Id":49500435,"CreationDate":"2018-03-20T21:56:00.000","Title":"Portfolio Performance Attribution Metrics","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a django app deployed on multiple VMs behind a load balancer. On each django. I want to setup celery and RabbitMQ for the app. Each django app would be running a celery worker, and some of the VMs should be running RabbitMQ in a cluster setup and if a celery worker executes a task others shouldn't execute the same task. Is this approach for setting up celery and RabbitMQ good. Can anyone guide me to how this can be setup (Configurations, tutorial, etc.)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":458,"Q_Id":49396130,"Users Score":0,"Answer":"For a better use case what you can do is run only a single RabbitMQ instance so if any celery worker can pick the task from queue and after picking up the task it will be removed from the queue so that it would not executed multiple times. Or another thing what you can do is to run celery and rabbitmq on a single separate VM and increase the number of workers of celery while running celery if this helps in your use case.","Q_Score":0,"Tags":"django,python-3.x,rabbitmq,celery,django-celery","A_Id":49414639,"CreationDate":"2018-03-21T00:10:00.000","Title":"Django and RabbitMQ setup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to implement some changes into a deployed Flask API.\nAm I able to edit files in the deployed API and have the changes take effect without having the restart the API build?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":119,"Q_Id":49396485,"Users Score":0,"Answer":"Webserver restart is necessary for changes to take effect.\nAfter changes issues below command. The lag will be only in seconds.\nsudo service apache2 restart\nPs. - Need root user permission for this.","Q_Score":1,"Tags":"python,flask,flask-sqlalchemy,flask-restful,flask-admin","A_Id":67429490,"CreationDate":"2018-03-21T00:54:00.000","Title":"Editing a Flask API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Okay, so I have the following issue. I have a Mac, so the the default Python 2.7 is installed for the OS's use. However, I also have Python 3.6 installed, and I want to install a package using Pip that is only compatible with python version 3. How can I install a package with Python 3 and not 2?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1081,"Q_Id":49396554,"Users Score":0,"Answer":"Just a suggestion, before you run any command that you don't know what is it, please use which your_cmd or whereis your_cmd to find its path.","Q_Score":1,"Tags":"python,pip","A_Id":49397412,"CreationDate":"2018-03-21T01:02:00.000","Title":"How to install Python packages for version 3.6 on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have imported numpy library in my python code. Now my question is, is it possible to get a list of all the functions that are covered under the numpy library? I know documentation is a thing, but I am looking for something else. \nI use spyder.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":49397462,"Users Score":0,"Answer":"print(dir(numpy))\nThe default dir() mechanism behaves differently with different types of objects, as it attempts to produce the most relevant, rather than complete, information:\n\nIf the object is a module object, the list contains the names of the\nmodule\u2019s attributes.\nIf the object is a type or class object, the list contains the names\nof its attributes, and recursively of the attributes of its bases.\nOtherwise, the list contains the object\u2019s attributes\u2019 names, the\nnames of its class\u2019s attributes, and recursively of the attributes of\nits class\u2019s base classes.","Q_Score":0,"Tags":"python,machine-learning,import,anaconda","A_Id":49397511,"CreationDate":"2018-03-21T03:07:00.000","Title":"functions covered under imported library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are trying our luck with robot framework for tests. Automation. I am stuck at database connection at this point.\nA DB connection using cx_Oracle is displaying an error saying \u201c No keyword withy the name  cx_Oracle\u2019 . If you have any idea please help . It will be helpful if you could put out an example of the Oracle dB connection sample.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4004,"Q_Id":49398152,"Users Score":0,"Answer":"It was indeed an installation issue. We had to use Anaconda3 and had to installed the library under its site-packages . I had this one under default Python folder.The issue is now resolved .","Q_Score":0,"Tags":"python,oracle,robotframework","A_Id":49469043,"CreationDate":"2018-03-21T04:22:00.000","Title":"Robot Framework : how to connect to Oracle database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I gave a requirement involving SMS and AWS platform, the requirement is - users can send SMS to a mobile number and I need to store the SMS and it's metadata into AWS RDS or DynamoDB or any AWS compatible storage. These SMS will be used to populate a realtime dashboard.\nAnyone here came across such a scenario? or any tools or technologies I could use to resolve it?\nThanks a ton for your replies,\nArun","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1531,"Q_Id":49399530,"Users Score":0,"Answer":"As far as I know, receiving international SMS is free and without hassle on the receiver's side. Unlike sending SMS which AWS SNS provide\nSo that separate the SMS receiving business and the storage business. To receive SMS you can look at Nexmo or Twilio.\nPlease note that SMS fails regularly and the sender is charged for international SMS most of the time","Q_Score":2,"Tags":"python,amazon-web-services,mobile,sms,amazon-sns","A_Id":49400763,"CreationDate":"2018-03-21T06:20:00.000","Title":"Receive SMS from users and store 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":"When trying to install the Teradata Python-module, I receive following error.\n\nCould not find a version that satisfies the requirement teradata (from versions: )\n  No matching distribution for teradata\n\nI'm running python 3.6.4 through the latest Anaconda distribution on Windows 7.0.\nDoes anybody have any suggestions?\nThanks\nEDIT: It seems this was a rookie problem. My company's firewall seems to block pip installs. Simply connecting to another network resolved this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1116,"Q_Id":49404376,"Users Score":1,"Answer":"It seems this was a rookie problem. My company's firewall seems to block pip installs. Simply connecting to another network resolved this.","Q_Score":2,"Tags":"python,teradata","A_Id":49733292,"CreationDate":"2018-03-21T10:51:00.000","Title":"Teradata module for python: could not find a version that satisfies the requirement teradata","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to remove from a TAR archive some file using tarfile? \nFor example: \nIf an x.tar file includes the files a.txt, b.txt and c.txt, is it possible to remove a.txt? \nIn other words: does any python solution exist to achieve something like this: \ntar -vf x.tar --delete a.txt?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2663,"Q_Id":49407659,"Users Score":1,"Answer":"Not with tarfile directly, although there may be some other library out there. A quick hack you can do is to extract the files, then recreate the tar minus the files you want to delete.","Q_Score":2,"Tags":"python,tar,tarfile","A_Id":49407753,"CreationDate":"2018-03-21T13:28:00.000","Title":"Python: Delete file from the TAR archive using tarfile","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python 2.7 installed (as default in Windows 7 64bit) and also have Python 3 installed in an environment (called Python3).\nI would like to use Spyder as my IDE. I have installed Spyder3 in my Python3 environment, but when I open Spyder 3 (from within my Python 3 env), then it opens Spyder for python 2.7 and not python 3.5 as I would've hoped for.). I don't know why.\nI have done TOOLS--Preferences--Python Interpreter -- Use the following Python interpreter: C:\\Users\\16082834\\AppData\\Local\\Continuum\\Anaconda2\\envs\\Python3\\python.exe, but this didn't work either.\nMany of us are running multiple python environments; I am sure some of you might have managed to use Spyder for these different environments.\nPlease tell me how I can get Python 3 using this method.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4452,"Q_Id":49408048,"Users Score":1,"Answer":"So, when you create a new environment with: conda create --name python36 python=3.6 anaconda \nThis will create an env. called python36 and the package to be installed is anaconda (which basically contains everything you'll need for python). \nBe sure that your new env. actually is running the ecorrect python version by doing the following:\nactivate python environmentwith: active python36\nthen type: python \nthis will indicate what python version is running in your env. It turns out, for some reason, my environment was running python2.7 and not 3.6\nThe cool thing is that anaconda distribution comes with spyder. Just be sure that you run Spyder from within your environment.\nSo to do this: activate python36\nthen type: spyder\nIt will automatically open spyder3 for python3. \nMy initial issue was therefore that even though i created a python3 environment, it was still running python2.7. But after removing the old python3 environment and creating a new python3 env. and installing the desired libraries\/packages it now works perfect. \nI have a 2.7 and 3.6 environment which can both be edited with spyder2 and spyder3 IDE","Q_Score":0,"Tags":"python,python-3.x,python-2.7,spyder","A_Id":49424870,"CreationDate":"2018-03-21T13:47:00.000","Title":"How to install Spyder for Python 2 and Python 3 and get Python 3 in my Spyder env?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python 2.7 installed (as default in Windows 7 64bit) and also have Python 3 installed in an environment (called Python3).\nI would like to use Spyder as my IDE. I have installed Spyder3 in my Python3 environment, but when I open Spyder 3 (from within my Python 3 env), then it opens Spyder for python 2.7 and not python 3.5 as I would've hoped for.). I don't know why.\nI have done TOOLS--Preferences--Python Interpreter -- Use the following Python interpreter: C:\\Users\\16082834\\AppData\\Local\\Continuum\\Anaconda2\\envs\\Python3\\python.exe, but this didn't work either.\nMany of us are running multiple python environments; I am sure some of you might have managed to use Spyder for these different environments.\nPlease tell me how I can get Python 3 using this method.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":4452,"Q_Id":49408048,"Users Score":2,"Answer":"One possible way is to run activate Python3 and then run pip install Spyder.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,spyder","A_Id":49408240,"CreationDate":"2018-03-21T13:47:00.000","Title":"How to install Spyder for Python 2 and Python 3 and get Python 3 in my Spyder env?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using MacOS High Sierra.\nI made a symlink to my virtualenv.py\n-rw-r--r--    1 myname  admin   99021  3  7 23:40 virtualenv.py\nAs you can see it has READ permission already.\nand now \/usr\/local\/bin\/virtualenv\nlrwxr-xr-x  1 myname  admin         91  3 21 22:51 virtualenv -> \/Library\/Frameworks\/Python.framework\/Versions\/3.5\/lib\/python3.5\/site-packages\/virtualenv.py\nI think there is no problem with these but I get permission denied error.\nI think I won't know what I'll be doing and I'm afraid to fix these kind of things myself, so I need someone's help.\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":314,"Q_Id":49408802,"Users Score":2,"Answer":"chmod -h 400 \/usr\/local\/bin\/virtualenv\nsolved my question. on MacOS -h option can modify symlink permission.","Q_Score":1,"Tags":"python,macos,virtualenv","A_Id":49408992,"CreationDate":"2018-03-21T14:19:00.000","Title":"virtualenv: permission denied error even though i have symlink","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Let say I have a list with len(list) == 5\nCan I be sure list[4] exists?\nOr maybe an item could get deleted and then the list would have indices 0,1,2,3,5 which would have length 5 but without index 4?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":49410978,"Users Score":0,"Answer":"When an element from a list is deleted, the index's shift down one.\nAn index is just an element located in a list.\nif you have a list of 1,2,3,4,5 and you delete list[3] then you now have 1,2,3,5 and now list[3] == 5","Q_Score":1,"Tags":"python,list","A_Id":49411106,"CreationDate":"2018-03-21T15:54:00.000","Title":"Can an index be skipped in a python list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed a virtual centos 7.3 server on my windows machine. And on centos server i have installed ipython notebook, by using pip\nI have browser installed on my same windows machine.\nWhen i'm trying to run the ipython notebook from centos server using the command ipython notebook --allow-root\nIt is giving me the link something like: \nhttp:\/\/localhost:8888\/?token=eaa9719ae6456b5d56fd419208a849b1886d8003051714\nand i'm pasting this link to browser, then i'm getting the warning as not able to connect.\nI'm new to ipython, so it would be really helpful if someone could guide me.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":49413082,"Users Score":0,"Answer":"After, lot of searching, i just tried unblocking the firewall, and yeah it worked.\nI followed the below steps:\n\nCheck the status of firewall systemctl status firewalld\nDisabling the firewall systemctl disable firewalld\nstop the firewall systemctl stop firewalld\n\nand yeah, it worked.","Q_Score":0,"Tags":"ipython","A_Id":49461783,"CreationDate":"2018-03-21T17:34:00.000","Title":"Run the ipython notebook from centos server to windows browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to build a whole sheet from scratch, and stay efficient while doing it.\nFor that purpose, I am trying to rely on bulk operations.\nI can build a massive list of rows and add them easily using add_rows().\nHowever, I need some rows to be children of other rows, and neither row.indent nor row.parent_id seem possible to set on new rows (since the fresh rows don't have an id yet).\nI could possibly: create the parent row > add_rows() > get_sheet() > find the row id in sheet > create the child row > add_rows() but I'm losing the benefits of bulk operations.\nIs there any way at all so set child\/parent relationships in python before ever communicating with the smartsheet server?\n[Edit] Alternatively, a way to export an excel file via the SDK (or other) would also work, as I'm able to create my table with xlsxwrite and upload it manually to smartsheet at the moment. (Which is not an option, as we're trying to generate dozens of sheets, multiple times a day, got to automate it.)\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":466,"Q_Id":49416108,"Users Score":0,"Answer":"You cannot create a sheet with hierarchy in a single call. All rows in a single POST or PUT must have the same location specifier.\nYou can either:\n(1) Add all rows as a flat list, then indent each contiguous group of child rows. Repeat down the hierarchy.\n(2) Add top level rows, then add each contiguous group of indented rows","Q_Score":1,"Tags":"python-2.7,smartsheet-api","A_Id":49416890,"CreationDate":"2018-03-21T20:41:00.000","Title":"Building whole sheet programmatically with Python SDK","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to find pid of a oracle process by using below command\nps -ef | grep pmon | grep orcl | grep -v grep\nWhen trying to use python \noracle_pid = os.system(\"echo ps -ef | grep pmon | grep %s | grep -v grep | awk '{print $2}'\" %(oracle_sid))\nprint(oracle_pid)\nit is printing 0 as value\nAny suggestions on how to achieve just the pid as output?\nRegards","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":49419095,"Users Score":0,"Answer":"Thanks for the reply !!!\nThe command works but it is adding extra characters\n\n\n\nimport subprocess\n      subprocess.check_output(\"ps -ef | grep pmon | grep orcl | grep -v grep | awk '{print $2}'\", stderr=subprocess.STDOUT, shell=True)\n      b'21648\\n'","Q_Score":1,"Tags":"python,python-3.6","A_Id":49436806,"CreationDate":"2018-03-22T01:28:00.000","Title":"Find pid using python by grepping two variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to match a string with specific letters but none of the letters should be duplicated. For example, [AEIOU] should not match 'AAEIOU' or 'AAEEIOU'. It should only match 'AEIOU' and the order of the letters should not matter. I tried using the exact quantifier with {} but did not work.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1049,"Q_Id":49419797,"Users Score":0,"Answer":"This maybe inefficient, but maybe use counters? Construct a counter for each, then check if they are equal?","Q_Score":1,"Tags":"python,regex,unique","A_Id":49419839,"CreationDate":"2018-03-22T02:56:00.000","Title":"Python regex to match multiple unique values","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the scikit-learn KNeighborsClassifier for classification on a dataset with 4 output classes. The following is the code that I am using:\nknn = neighbors.KNeighborsClassifier(n_neighbors=7, weights='distance', algorithm='auto', leaf_size=30, p=1, metric='minkowski')\nThe model works correctly. However, I would like to provide user-defined weights for each sample point. The code currently uses the inverse of the distance for scaling using the metric='distance' parameter.\nI would like to continue to keep the inverse distance scaling but for each sample point, I have a probability weight as well. I would like to apply this as a weight in the distance calculation. For example, if x is the test point and y,z are the two nearest neighbors for which distance is being calculated, then I would like the distance to be calculated as (sum|x-y|)*wy and (sum|x-z|)*wz respectively.\nI tried to define a function that was passed into the weights argument but then I also would like to keep the inverse distance scaling in addition to the user defined weight and I do not know the inverse distance scaling function. I could not find an answer from the documentation.\nAny suggestions?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1542,"Q_Id":49420191,"Users Score":2,"Answer":"KNN in sklearn doesn't have sample weight, unlike other estimators, e.g. DecisionTree.\nPersonally speaking, I think it is a disappointment. It is not hard to make KNN support sample weight, since the predicted label is the majority voting of its neighbours.\nA stupid walk around, is to generate samples yourself based on the sample weight. E.g., if a sample has weight 2, then make it appear twice.","Q_Score":4,"Tags":"python,scikit-learn,knn,nearest-neighbor","A_Id":53602315,"CreationDate":"2018-03-22T03:47:00.000","Title":"Providing user defined sample weights for knn classifier in scikit-learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the scikit-learn KNeighborsClassifier for classification on a dataset with 4 output classes. The following is the code that I am using:\nknn = neighbors.KNeighborsClassifier(n_neighbors=7, weights='distance', algorithm='auto', leaf_size=30, p=1, metric='minkowski')\nThe model works correctly. However, I would like to provide user-defined weights for each sample point. The code currently uses the inverse of the distance for scaling using the metric='distance' parameter.\nI would like to continue to keep the inverse distance scaling but for each sample point, I have a probability weight as well. I would like to apply this as a weight in the distance calculation. For example, if x is the test point and y,z are the two nearest neighbors for which distance is being calculated, then I would like the distance to be calculated as (sum|x-y|)*wy and (sum|x-z|)*wz respectively.\nI tried to define a function that was passed into the weights argument but then I also would like to keep the inverse distance scaling in addition to the user defined weight and I do not know the inverse distance scaling function. I could not find an answer from the documentation.\nAny suggestions?","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1542,"Q_Id":49420191,"Users Score":-1,"Answer":"sklearn.neighbors.KNeighborsClassifier.score() has a sample_weight parameter. Is that what you're looking for?","Q_Score":4,"Tags":"python,scikit-learn,knn,nearest-neighbor","A_Id":63655345,"CreationDate":"2018-03-22T03:47:00.000","Title":"Providing user defined sample weights for knn classifier in scikit-learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a plot using matplotlib.pyplot as plt.\nFor example plt.hist(df.amount, bins = 30)\nBut when I hit enter in the console it generates the graph.\nI want to apply xlim, ylim and title functions of plt but can't do this.\nAnyone familiar with this behavior? Should I change Spyder settings?\nSame behavior with Seaborn package.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":49425805,"Users Score":1,"Answer":"try typing %matplotlib or %matplotlib qt before doing plt.hist(df.amount, bins=30). This will switch the console out of \"inline\" mode.","Q_Score":0,"Tags":"python,matplotlib,spyder","A_Id":49432623,"CreationDate":"2018-03-22T10:08:00.000","Title":"Python 3.6 matplotlib.pyplot shows graph immediately without letting me apply other functions?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried downloading small files from google Colaboratory. They are easily downloaded but whenever I try to download files which have a large sizes it shows an error? What is the way to download large files?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7373,"Q_Id":49428332,"Users Score":0,"Answer":"Google colab doesn't allow you to download large files using files.download(). But you can use one of the following methods to access it:\n\nThe easiest one is to use github to commit and push your files and then clone it to your local machine.\nYou can mount google-drive to your colab instance and write the files there.","Q_Score":11,"Tags":"python-3.x,tensorflow,gpu,google-colaboratory","A_Id":49431101,"CreationDate":"2018-03-22T12:08:00.000","Title":"How to download large files (like weights of a model) from Colaboratory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using the warcio library to read and write warc files. \nWhen trying to write a record of a response object from requests.get(URL,stream=False), warcio is writing only HTTP headers to the record but not the payload. However, when stream mode is enabled it works fine. \nIs there a way store the payload when stream mode is not enabled?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":461,"Q_Id":49429211,"Users Score":0,"Answer":"I've found a workaround but not sure if it's the correct way. Instead of making request object streamable, I've made the payload streamable\nBytesIO(response.text.encode()) and this seems to work.","Q_Score":1,"Tags":"python,python-3.x,python-requests,warc","A_Id":49430305,"CreationDate":"2018-03-22T12:52:00.000","Title":"Creating a warc record with requests.get() response using warcio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Tensorflow to generate a transformation matrix for a set of input vectors (X) to target vectors (Y). To minimize the error between the transformed input and the target vector samples I'm using a gradient descent algorithm. Later on I want to use the generated matrix to transform vectors coming from the same source as the training input vectors so that they look like the corresponding target vectors. Linear regression, pretty much, but with 3-dimensional targets. \nI can assume that the input and target vectors are in cartesian space. Thus, the transformation matrix should consist of a rotation and a translation. I'm working solely with unit vectors, so I can also safely assume that there's no translation, only rotation. \nSo, in order to get a valid rotation matrix that I can turn into a rotation quaternion I understand that I have to make sure the matrix is orthogonal. \nThus, the question is, is it possible to give Tensorflow some kind of constraint so that the matrix it tries to converge to is guaranteed to be orthogonal? Can be a parameter, a mathematical constraint, a specific optimizer, whatever. I just need to make sure the algorithm converges to a valid rotation matrix.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":729,"Q_Id":49430178,"Users Score":0,"Answer":"It should be possible.\nI see two solutions.\nIf you don't care that the transformation is a perfect rotation, you can take the matrix, adjust it to what you think it's a good matrix (make it a perfect rotation) then compute the difference between the one you like and the original and add it as a loss.  With this approach you can push the model to do what you want but the model might not converge on a perfect rotation, especially if a perfect rotation is not a very good solution.\nAnother approach is to start with a proper rotation matrix and train the parameters of the rotation. In this case you would have the x,y,z of the rotation axis and the amount of rotation. So declare these as variables, compute the rotation matrix and use that in your model. The operations are derivable so gradient descent should work, but depending on the data itself you might depend on the start position (so try a few times).\nHard to say which one will work best in your case, so it might be worth trying both.","Q_Score":1,"Tags":"python,tensorflow","A_Id":49430423,"CreationDate":"2018-03-22T13:38:00.000","Title":"Is it possible to force Tensorflow to generate orthogonal matrix?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am utilizing Mysql.Connector in my python code to do multiple inserts\/updates to a DB. After performing all of the inserts\/updates + other processing, I determine if it was successful or not and then perform either a db.commit() or a db.rollback(). I'm concerned about what would happen in a couple different situations. If the process is unexpectedly terminated. e.g kill -9 program.py or if the host|container that the program is running in is shutdown.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":160,"Q_Id":49430879,"Users Score":3,"Answer":"The MySQL server will roll back uncommitted transactions if the connection is terminated.","Q_Score":0,"Tags":"mysql,python-3.x","A_Id":49430986,"CreationDate":"2018-03-22T14:12:00.000","Title":"What happens to my transaction when Mysql.Connector for Python is unexpectedly terminated?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My company needs me to create a tool to read and send messages over a controller area network(CANBUS).  I've been successful in creating one in an Ubuntu virtual environment. \n\nCan I use my Linux program in windows? (Written in python)\nIf I have to recreate it for windows, what would be the best coding language to interact with the bus and its hardware?\nAre there any libraries that work well with canbus through windows?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":602,"Q_Id":49431740,"Users Score":0,"Answer":"I'm not sure about (3), but here's what I can say for (1) and (2):\nIs it gonna work on Windows?\nI don't know.\nIt depends on the modules you used.\nMost of the time it is portable across platforms, but you might have to change some portions of the code.\nIf you mostly used TkInter and PySerial, it should work on Windows as well, but you need to give it a try.\nWhat's the best language for doing this on Windows?\nIf you have a working version of your program for Linux, you should stick to porting it onto Windows, it shouldn't be too hard if what you used was standard.\nThus, I'd say that the best language is the one that already works on another platform.\nHowever, if it happened that Python was definitely not suited for this program on Windows, then the best language would probably be the one you know best, as long as you're sure it provides the features you need.","Q_Score":2,"Tags":"python,windows,ubuntu,tkinter,can-bus","A_Id":49431984,"CreationDate":"2018-03-22T14:52:00.000","Title":"Python-Can or Pyserial in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My company needs me to create a tool to read and send messages over a controller area network(CANBUS).  I've been successful in creating one in an Ubuntu virtual environment. \n\nCan I use my Linux program in windows? (Written in python)\nIf I have to recreate it for windows, what would be the best coding language to interact with the bus and its hardware?\nAre there any libraries that work well with canbus through windows?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":602,"Q_Id":49431740,"Users Score":2,"Answer":"1. Can I use my Linux program in windows? (Written in python)\nYes, you can. Python is SO agnostic. You will obviously need to install Python for Windows. Check which driver dependancies has the library you used for Python as you may need to install some driver in your PC.\n2. If I have to recreate it for windows, what would be the best coding language to interact with the bus and its hardware?\nNo need to recreate it\n3. Are there any libraries that work well with canbus through windows?\nSame as on Linux.","Q_Score":2,"Tags":"python,windows,ubuntu,tkinter,can-bus","A_Id":49431976,"CreationDate":"2018-03-22T14:52:00.000","Title":"Python-Can or Pyserial in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"TF has tf.variable_scope() that allows users to access tf.Variable() anywhere in the code. Basically every variable in TF is a global variable.\nIs there a similar way to access class objects like tf.nn.rnn_cell.LSTMCell() or tf.layers.Dense()? To be more specific, can i create a new class object, let's say lstm_cell_2 (used for prediction) that uses the same weights and biases in lstm_cell_1 (used during training).\nI am building an RNN to do language modeling. What i am doing right now is to return the lstm_cell_1 then pass it onto the prediction function. This works, but i want to in the end use separate tf.Graph() and tf.Session() for training, inference and prediction. Hence comes the problem of sharing Tensorflow objects.\nAlso, my lstm_cell is an instance of tf.nn.rnn_cell.MultiRNNCell() which doesn't take a name argument.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":49432175,"Users Score":0,"Answer":"You can share final state that is one of the outputs of for example consider dynamic rnn. You get outputs,cell_final_state which you can share. You probably know about cell_final_state.c and cell_final_state.h. you can set that final state as initial state. lemme know if I cleared your question or not.\nJust noticed it's such an old question. Hopefully helps future people.","Q_Score":0,"Tags":"python,tensorflow,lstm,rnn","A_Id":50856659,"CreationDate":"2018-03-22T15:10:00.000","Title":"Sharing class objects in Tensorlfow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a Flask app that uses a docx template to build a Word document. If I set threaded=True in app.run() will Flask handle the critical region properly as multiple users access the file on the server concurrently?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":49434267,"Users Score":2,"Answer":"Flask doesn't know what your code does. It's up to you to put whatever checks you need before taking an action. HTTP is a stateless protocol, you cannot make assumptions about how and when workers will access other data.\nthreaded=True just enables multiple workers so that the development server can handle concurrent requests.","Q_Score":0,"Tags":"python,multithreading,flask","A_Id":49434779,"CreationDate":"2018-03-22T16:53:00.000","Title":"Do flask threads handle file access?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use Eclipse for Python development and depend on the F2 function key to send lines of code to the console. Recently, F2 has stopped working in my installation of Eclipse Neon. I have tried everything I can think of to get it to work again:\n\nclose and reopen the python module\nclose and reopen Eclipse (as recommended on Stackoverflow)\ncheck the key bindings to make sure F2 is properly bound, unbind it, rebind it, reset to default key bindings\nreboot my computer\ninstall new version of Eclipse, Oxygen, twice..\n\nIn one of the newly installed Oxygens, at least the first time I press F2, it does open the pop-up asking what console to start with, but then after the console is open it does nothing. \nIn the Neon installation and the other Oxygen installation, F2 just does nothing, not even open a new console when none is active.\nWould you have any idea I can try to get F2 back to work?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":566,"Q_Id":49434458,"Users Score":0,"Answer":"I fixed it by installing the updates for PyDev. In Eclipse, Help - Check for updates - install pending updates for PyDev. Now I can use F2 to run code from selection in the console.","Q_Score":4,"Tags":"python,eclipse,keyboard-shortcuts,pydev","A_Id":52117212,"CreationDate":"2018-03-22T17:03:00.000","Title":"The F2 key not working in Eclipse Pydev, despite restarting","Data Science and Machine Learning":0,"Database and SQL":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 Eclipse for Python development and depend on the F2 function key to send lines of code to the console. Recently, F2 has stopped working in my installation of Eclipse Neon. I have tried everything I can think of to get it to work again:\n\nclose and reopen the python module\nclose and reopen Eclipse (as recommended on Stackoverflow)\ncheck the key bindings to make sure F2 is properly bound, unbind it, rebind it, reset to default key bindings\nreboot my computer\ninstall new version of Eclipse, Oxygen, twice..\n\nIn one of the newly installed Oxygens, at least the first time I press F2, it does open the pop-up asking what console to start with, but then after the console is open it does nothing. \nIn the Neon installation and the other Oxygen installation, F2 just does nothing, not even open a new console when none is active.\nWould you have any idea I can try to get F2 back to work?","AnswerCount":4,"Available Count":3,"Score":-0.049958375,"is_accepted":false,"ViewCount":566,"Q_Id":49434458,"Users Score":-1,"Answer":"have the same issues after upgrading to \nEclipse IDE for C\/C++ Developers\nVersion: Oxygen.3 Release (4.7.3)\nBuild id: 20180308-1800\nPyDev for Eclipse 6.3.2.201803171248  org.python.pydev.feature.feature.group  Fabio Zadrozny","Q_Score":4,"Tags":"python,eclipse,keyboard-shortcuts,pydev","A_Id":49435666,"CreationDate":"2018-03-22T17:03:00.000","Title":"The F2 key not working in Eclipse Pydev, despite restarting","Data Science and Machine Learning":0,"Database and SQL":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 Eclipse for Python development and depend on the F2 function key to send lines of code to the console. Recently, F2 has stopped working in my installation of Eclipse Neon. I have tried everything I can think of to get it to work again:\n\nclose and reopen the python module\nclose and reopen Eclipse (as recommended on Stackoverflow)\ncheck the key bindings to make sure F2 is properly bound, unbind it, rebind it, reset to default key bindings\nreboot my computer\ninstall new version of Eclipse, Oxygen, twice..\n\nIn one of the newly installed Oxygens, at least the first time I press F2, it does open the pop-up asking what console to start with, but then after the console is open it does nothing. \nIn the Neon installation and the other Oxygen installation, F2 just does nothing, not even open a new console when none is active.\nWould you have any idea I can try to get F2 back to work?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":566,"Q_Id":49434458,"Users Score":1,"Answer":"I have gotten it back to work, by uninstalling pydev 6.3 and re-installing pydev 6.1. I'm not sure why this works as I was working in 6.2 when the issue first arose. I tried to solve it by upgrading to 6.3, but that didn't work. For some reason, downgrading back to 6.1 now makes it work again.","Q_Score":4,"Tags":"python,eclipse,keyboard-shortcuts,pydev","A_Id":49438248,"CreationDate":"2018-03-22T17:03:00.000","Title":"The F2 key not working in Eclipse Pydev, despite restarting","Data Science and Machine Learning":0,"Database and SQL":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 Django. Would be really helpful if someone can tell the difference between @cached_property and @lru_cache decorator in Django. \nAlso when should I use which decorator in Django. Use cases would be really helpful.\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":9063,"Q_Id":49436833,"Users Score":5,"Answer":"They serve different purposes. \nlru_cache saves the least recent uses - you should specify maxsize which distinguishes how many computations of your function you can save. Once you surpass this number, the 'oldest' result is discarded and the new one is saved.\ncached_property just computes the result and saves it. It doesn't take arguments unlike lru_cache (you can think of it as a lru_cache on an object type with maxsize = 1 with no arguments).","Q_Score":21,"Tags":"python,django","A_Id":49437018,"CreationDate":"2018-03-22T19:21:00.000","Title":"Difference between @cached_property and @lru_cache decorator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm creating a python script to extract values from jboss-cli.sh which by default return output in below format:\n\n\n    {\n        \"outcome\" => \"success\",\n        \"result\" => {\n            \"ActiveCount\" => \"0\",\n            \"AvailableCount\" => \"0\",\n            \"AverageBlockingTime\" => \"0\",\n            \"AverageCreationTime\" => \"0\",\n            \"CreatedCount\" => \"0\",\n            \"DestroyedCount\" => \"0\",\n            \"InUseCount\" => \"0\",\n            \"MaxCreationTime\" => \"0\",\n            \"MaxUsedCount\" => \"0\",\n            \"MaxWaitCount\" => \"0\",\n            \"MaxWaitTime\" => \"0\",\n            \"TimedOut\" => \"0\",\n            \"TotalBlockingTime\" => \"0\",\n            \"TotalCreationTime\" => \"0\",\n            \"statistics-enabled\" => false\n        }\n    }\n\n\nNow i'm converting this to JSON format using below code:\nfrom jbossply.jbossparser import JbossParser\nparser = JbossParser()\nprint(parser.parse(OUT))\nso it is giving output as:\n{u'outcome': u'success', u'result': {u'AverageBlockingTime': u'0', u'AvailableCount': u'0', u'statistics-enabled': False, u'MaxCreationTime': u'0', u'MaxUsedCount': u'0', u'CreatedCount': u'0', u'MaxWaitCount': u'0', u'TimedOut': u'0', u'InUseCount': u'0', u'ActiveCount': u'0', u'TotalBlockingTime': u'0', u'DestroyedCount': u'0', u'AverageCreationTime': u'0', u'TotalCreationTime': u'0', u'MaxWaitTime': u'0'}}\nNow how to extract \"AvailableCount\" out of it. Tried json.load but not working.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":135,"Q_Id":49436978,"Users Score":0,"Answer":"Finally I got the answer by myself, parsed json to a variable and extracted result like beow:\nparser = JbossParser()\ndata=(parser.parse(OUT))\nTOTAL_CN=(data[\"result\"][\"AvailableCount\"])","Q_Score":1,"Tags":"json,python-2.7,jboss-cli","A_Id":49446683,"CreationDate":"2018-03-22T19:29:00.000","Title":"reading json data from variable instead of file in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script deployed and running in azure virtual machine, however in the script, I have to read a local CSV file for further processing, that leads a failure, server came back with notice that: \"file does not exist \" \nMay I ask how can I running Python script in VM but read and save on my computer local file ?\nIf not possible, may I ask how to overcome this problem with cloud storage, particularly with Azure?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1594,"Q_Id":49438230,"Users Score":0,"Answer":"You could possible map the directory to the vm as a network resource?","Q_Score":0,"Tags":"python,virtual-machine","A_Id":49438506,"CreationDate":"2018-03-22T20:51:00.000","Title":"How to running Python script in virtual machine but read and save on computer local csv file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to deploy a Python app via mod_wsgi in Apache httpd, running into a strange error.\nI'm using my firm's custom python package (2.7), besides this there is another Python intsallation, shipped with the OS (different version, 2.6 something). The issue is, when I define the \nWSGIPythonHome and WSGIPythonPath variables in my httpd conf, I'm flooded with \"ImportError: no module named site\" errors in the error_log. Looking at other answers, defining those variables would be the solution for such errors.\nIf I switch user to the apache user, with being the PYTHONPATH and PYTHONHOME env variables set, when I try to start Python 2.7, I'm getting the same error.\nAfter unsetting the variables, Python is able to start normally.\nSo I've tried removing the WSGIPythonHome and WSGIPythonPath from the  httpd conf, but in that case, nothing happens, the wsgi script is not executed, as nothing is pointing Apache to my python executable.\nThe mod_wsgi.so has been installed with pip, and loaded from the same path as my PYTHONPATH would be for 2.7","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":542,"Q_Id":49438421,"Users Score":0,"Answer":"It is likely that mod_wsgi Apache is using is compiled for Python 2.6. You cannot make mod_wsgi compiled for Python 2.6, work with a Python 2.7 installation or virtual environment.\nYou should verify what Python version mod_wsgi was compiled for by running ldd on the mod_wsgi.so binary. Don't assume it is using the pip installed version, you may still have system mod_wsgi installed.\nIf it is the system mod_wsgi package and it is compiled for Python 2.6, you will need to uninstall it.","Q_Score":0,"Tags":"python,apache,mod-wsgi","A_Id":49438521,"CreationDate":"2018-03-22T21:02:00.000","Title":"Unable to run python with mod_wsgi","Data Science and Machine Learning":0,"Database and SQL":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 downloaded Python about a year ago, and back then, I had trouble executing files from the terminal. So, being ye of little faith, I quit trying and forgot most of my Python knowledge. Now, I' revisiting Python, and it still doesn't work (I updated Python. And deleted it. And updated again) But it still does not work. I made sure I'm in the directory that Python is supposedly in. Please help.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":9018,"Q_Id":49440211,"Users Score":1,"Answer":"Even easier,\nlaunch again the setup of Python and click on 'Modify'.\nIn the \"Advanced Options\", check \"Add Python to environment variables\"","Q_Score":0,"Tags":"python-3.x,command-line,terminal","A_Id":60899827,"CreationDate":"2018-03-22T23:40:00.000","Title":"Python command is not working in 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on a project written in Python that should perform some actions in an opened application window. For example I run application window with 3 buttons at 3 different positions. I write a script using auto-gui lib for python 3 and set x, y coordinates to click on 3 button positions. But my problem is: If I minimize this window, clicker clicks at the given position within another currently open window. \nMy main question: is there a way (with help of a lib or by any other means) to trigger or bind this script to work only with this opened (or specified) application. And if I minimize this window, clicker continues to work in this minimized window, not in the currently active one. Please suggest.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1023,"Q_Id":49445954,"Users Score":0,"Answer":"You should have a look at win32gui module, more specifically to SetActiveWindows, SetForegroundWindow, SetActiveWindows also EnumWindows to find your application.\nWith these you can detect a certain application by it's title using EnumWindows you can then maximize it and set it as active so it will be fullscreen and the first one you see on the monitor. This way you can now use the (x,y) coordinates for clicks because the windows will always be maximized therefore the buttons in the same position everytime.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,mouseclick-event","A_Id":52735508,"CreationDate":"2018-03-23T09:11:00.000","Title":"python: windows GUI automation working with a specific window regardless of its state","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I found an option to get python to play Presentation procedures, but not the other way around. I have a ton of code and rewriting it into a different language would be a nightmare.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":93,"Q_Id":49446868,"Users Score":2,"Answer":"No, there is no such conversion tool available at the moment.\nHowever, it is in principle possible to make it. PsychoPy Builder saves experiments in the open .psyexp format and then that is converted to Python code. Someone could write converters to other script structures and languages, for example, NeuroBS Presentation, PsychToolbox, etc.","Q_Score":1,"Tags":"python,psychopy,presentation,code-translation,neuroscience","A_Id":49451272,"CreationDate":"2018-03-23T09:56:00.000","Title":"Is there a way to implement a full Python (psychopy) procedure into neurobs Presentation without rewriting the whole 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 trying to implement a Q Learning agent to learn an optimal policy for playing against a random agent in a game of Tic Tac Toe.\nI have created a plan that I believe will work. There is just one part that I cannot get my head around. And this comes from the fact that there are two players within the environment. \nNow, a Q Learning agent should act upon the current state, s, the action taken given some policy, a, the successive state given the action, s', and any reward received from that successive state, r. \nLets put this into a tuple (s, a, r, s')\nNow usually an agent will act upon every state it finds itself encountered in given an action, and use the Q Learning equation to update the value of the previous state. \nHowever, as Tic Tac Toe has two players, we can partition the set of states into two. One set of states can be those where it is the learning agents turn to act. The other set of states can be where it is the opponents turn to act. \nSo, do we need to partition the states into two? Or does the learning agent need to update every single state that is accessed within the game?\nI feel as though it should probably be the latter, as this might affect updating Q Values for when the opponent wins the game. \nAny help with this would be great, as there does not seem to be anything online that helps with my predicament.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2280,"Q_Id":49451366,"Users Score":1,"Answer":"Q-Learning is an algorithm from the MDP (Markov Decision Process) field, i.e the MDP and Learning in practically facing a world that being act upon. and each action change the state of the agent (with some probability)\nthe algorithm build on the basis that for any action, the world give a feedback (reaction).\nQ-Learning works best when for any action there is a somewhat immediate and measurable reaction\nin addition this method looks at the world from one agent perspective \nMy Suggestion is to implement the agent as part of the world. like a be bot which plays with various strategies e.g random, best action, fixed layout or even a implement it's logic as q-learning \nfor looking n steps forward and running all the states (so later you can pick the best one) you can use monte-carlo tree search if the space size is too large (like did with GO) \nthe Tic-Tac-Toe game is already solved, the player can achieve win or draw if follows the optimal strategy, and 2 optimal players will achieve draw, the full game tree is fairly easy to build","Q_Score":7,"Tags":"python,tic-tac-toe,reinforcement-learning,q-learning","A_Id":49451732,"CreationDate":"2018-03-23T13:59:00.000","Title":"Q Learning Applied To a Two Player Game","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement a Q Learning agent to learn an optimal policy for playing against a random agent in a game of Tic Tac Toe.\nI have created a plan that I believe will work. There is just one part that I cannot get my head around. And this comes from the fact that there are two players within the environment. \nNow, a Q Learning agent should act upon the current state, s, the action taken given some policy, a, the successive state given the action, s', and any reward received from that successive state, r. \nLets put this into a tuple (s, a, r, s')\nNow usually an agent will act upon every state it finds itself encountered in given an action, and use the Q Learning equation to update the value of the previous state. \nHowever, as Tic Tac Toe has two players, we can partition the set of states into two. One set of states can be those where it is the learning agents turn to act. The other set of states can be where it is the opponents turn to act. \nSo, do we need to partition the states into two? Or does the learning agent need to update every single state that is accessed within the game?\nI feel as though it should probably be the latter, as this might affect updating Q Values for when the opponent wins the game. \nAny help with this would be great, as there does not seem to be anything online that helps with my predicament.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2280,"Q_Id":49451366,"Users Score":7,"Answer":"In general, directly applying Q-learning to a two-player game (or other kind of multi-agent environment) isn't likely to lead to very good results if you assume that the opponent can also learn. However, you specifically mentioned\n\nfor playing against a random agent\n\nand that means it actually can work, because this means the opponent isn't learning \/ changing its behaviour, so you can reliably treat the opponent as ''a part of the environment''.\nDoing exactly that will also likely be the best approach you can take. Treating the opponent (and his actions) as a part of the environment means that you should basically just completely ignore all of the states in which the opponent is to move. Whenever your agent takes an action, you should also immediately generate an action for the opponent, and only then take the resulting state as the next state. \nSo, in the tuple (s, a, r, s'), we have:\n\ns = state in which your agent is to move\na = action executed by your agent\nr = one-step reward\ns' = next state in which your agent is to move again\n\nThe state in which the opponent is to move, and the action they took, do not appear at all. They should simply be treated as unobservable, nondeterministic parts of the environment. From the point of view of your algorithm, there are no other states in between s and s', in which there is an opponent that can take actions. From the point of view of your algorithm, the environment is simply nondeterministic, which means that taking action a in state s will sometimes randomly lead to s', but maybe also sometimes randomly to a different state s''.\n\nNote that this will only work precisely because you wrote that the opponent is a random agent (or, more importantly, a non-learning agent with a fixed policy). As soon as the opponent also gains the ability to learn, this will break down completely, and you'd have to move on to proper multi-agent versions of Reinforcement Learning algorithms.","Q_Score":7,"Tags":"python,tic-tac-toe,reinforcement-learning,q-learning","A_Id":49451735,"CreationDate":"2018-03-23T13:59:00.000","Title":"Q Learning Applied To a Two Player Game","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I use GridSearchCV in scikit-learn library to find the best model, what will be the final model it returns? That said, for each set of hyper-parameters, we train the number of CV (say 3) models. In this way, will the function return the best model in those 3 models for the best setting of parameters?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5388,"Q_Id":49455806,"Users Score":2,"Answer":"This is given in sklearn:\n\u201cThe refitted estimator is made available at the best_estimator_ attribute and permits using predict directly on this GridSearchCV instance.\u201d\nSo, you don\u2019t need to fit the model again. You can directly get the best model from best_estimator_ attribute","Q_Score":5,"Tags":"python,machine-learning,scikit-learn","A_Id":68944912,"CreationDate":"2018-03-23T17:59:00.000","Title":"GridSearchCV final model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When doing python setup.py bdist_wheel I got an error:\nerror: error in setup.cfg: command 'bdist_wheel' has no such option 'universal'\nHow do I fix this?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1925,"Q_Id":49455926,"Users Score":2,"Answer":"Turns out my wheel package was out of date (v0.22 isn't new enough).  A quick pip install --upgrade wheel and it built happily. \nBefore I figured that out, though, I'd spent a fruitless half hour upgrading pip and setuptools and python-distutils-extra.","Q_Score":0,"Tags":"python,setuptools,python-wheel","A_Id":49455927,"CreationDate":"2018-03-23T18:07:00.000","Title":"How do I fix \"error: error in setup.cfg: command 'bdist_wheel' has no such option 'universal'\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Im am writing a piece of code where it is vital that the browser stays open however i need to be able to close windows, to stop the browser from over populating. I have been using the webbrowser module but it seems that webbrowser doesnt have a way of close the tab once open. Any ideas?\nRemember the browser must stay open, so killing all tabs will close the browser. I must only close the tabs that were opened by my code!\nAny help would be greatly appreciated.\nSorry if this isn't in the right place, feel free to move it.\nSoftware:\nPython 3.6.4 (32 bit)\nModules used:\nTime, Random and Webbrowser.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":49457439,"Users Score":0,"Answer":"Webbrowser is a limited api module for interfacing with popular browsers. \nThe way I see it you have a few options:\n\nFind a module pertaining to the particular browser you're dealing with.\nWork with the api of the browser(s) you're working with directly\nRequest feature of webbrowser in the future, but won't help you now, as they likely won't implement it any time soon.","Q_Score":0,"Tags":"python","A_Id":49458231,"CreationDate":"2018-03-23T19:56:00.000","Title":"I need to be able to close an internet tab, but i cannot close the browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using ldap3.\nI can connect and read all attributes without any issue, but I don't know how to display the photo of the attribute thumbnailPhoto.\nIf I print(conn.entries[0].thumbnailPhoto) I get a bunch of binary values like b'\\xff\\xd8\\xff\\xe0\\x00\\x10JFIF.....'.\nI have to display it on a bottle web page. So I have to put this value in a jpeg or png file.\nHow can I do that?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4282,"Q_Id":49458945,"Users Score":1,"Answer":"The easiest way is to save the raw byte value in a file and open it with a picture editor. The photo is probably a jpeg, but it can be in any format.","Q_Score":1,"Tags":"python-3.x,ldap","A_Id":49470034,"CreationDate":"2018-03-23T22:11:00.000","Title":"how to get and display photo from ldap","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to create a dashboard using R. However, all the data that I need to connect is from TM1.\nThe easiest way that I found is using an python library called TM1py to connect to tm1 data.\nI would like to know what is the easist to access to access TM1py library from R ?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":412,"Q_Id":49459591,"Users Score":1,"Answer":"It seems as if you only want to read data from tm1. Therefore a \"simple\" mdx query should be fine. Have a look at the package \"httr\" how to send POST-Requests. Then it's pretty staright forward to port the relevant parts from tm1py to R.","Q_Score":1,"Tags":"python,r","A_Id":49622289,"CreationDate":"2018-03-23T23:29:00.000","Title":"Tm1 to python to R","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to do this with WMI, but interactive processes cannot be started with it (as stated in Microsoft documentation). I see processes in task manager, but windows do not show.\nI tried with Paramiko, same thing. Process visible in task manager, but no window appears (notepad for example).\nI tried with PsExec, but the only case a window appears on the remote machine, is when you specify -i and it does not show normally, only through a message box saying something like \"a message arrived do you want to see it\".\nDo you know a way to start a program remotely, and have its interface behave like it would if you manually started it?\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":972,"Q_Id":49459745,"Users Score":0,"Answer":"Normally the (SSH) servers run as a Windows service.\nWindow services run in a separate Windows session (google for \"Session 0 isolation\"). They cannot access interactive (user) Windows sessions.\nAlso note that there can be multiple user sessions (multiple logged in users) in Windows. How would the SSH server know, what user session to display the GUI on (even if it could)?\nThe message you are getting is thanks to the \"Interactive Services Detection\" service that detects that a service is trying to show a GUI on an invisible Session 0 and allows you to replicate the GUI on the user session.\n\nYou can run the SSH server in an interactive Windows session, instead as a service. It has its limitations though.\n\nIn general, all this (running GUI application on Windows remotely through SSH) does not look like a good idea to me.\nAlso this question is more about a specific SSH server, rather that about an SSH client you are using. So you you include details about your SSH server, you can get better answers.","Q_Score":1,"Tags":"python,windows,ssh,paramiko,remote-desktop","A_Id":49462185,"CreationDate":"2018-03-23T23:51:00.000","Title":"Trying to remotely start a process with visible window with Python on Windows machines","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried to do this with WMI, but interactive processes cannot be started with it (as stated in Microsoft documentation). I see processes in task manager, but windows do not show.\nI tried with Paramiko, same thing. Process visible in task manager, but no window appears (notepad for example).\nI tried with PsExec, but the only case a window appears on the remote machine, is when you specify -i and it does not show normally, only through a message box saying something like \"a message arrived do you want to see it\".\nDo you know a way to start a program remotely, and have its interface behave like it would if you manually started it?\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":972,"Q_Id":49459745,"Users Score":0,"Answer":"ok i found a way. With subprocess schtasks( the windows task scheduler). For whatever reason, when i launch a remote process with it , it starts as if i had clicked myself on the exe. For it to start with no delay, creating the task to an old date like 2012 with schtasks \/Create \/F and running the then named task with schtasks \/Run will do the trick","Q_Score":1,"Tags":"python,windows,ssh,paramiko,remote-desktop","A_Id":49482445,"CreationDate":"2018-03-23T23:51:00.000","Title":"Trying to remotely start a process with visible window with Python on Windows machines","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"It would be really handy to have a button to copy raw code from a Jupyter notebook to the clipboard so it can be dumped into a text file, .py\/.R script, or straight into the terminal (a button like github has to copy to clipboard)\nDoes a button (or even a chrome add on) exist? \nObviously you could copy\/paste sections manually into a txt file, but that's laborious for long notebooks\/markdowns","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3727,"Q_Id":49460130,"Users Score":4,"Answer":"Yes,there is a button:\nFile > Download as > Python (.py)","Q_Score":7,"Tags":"python,r,jupyter-notebook","A_Id":57084695,"CreationDate":"2018-03-24T00:50:00.000","Title":"How to get raw code from a Jupyter notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"From PyQt4.QtGui Cannot import module uic\nI cannot seem to find this uic module to download or install it. I think it's suppose to come with the qt4 and qt designer packages.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":49460431,"Users Score":0,"Answer":"uic would be a c++ rather than a python command.\nI\u2019m guessing you want to convert qt file to a python compatible file if that is the case simply open a terminal and navigate to the directory where your Qt file is and the enter the following:\n$ pyuic your_file.ui -o your_file.py\nyou should now have in the same directory a .py file which you can incorporate in your project","Q_Score":0,"Tags":"python,qt,pyqt","A_Id":49516795,"CreationDate":"2018-03-24T01:50:00.000","Title":"Difficulty with running PyQt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I have a pandas dataframe looks like this:\n\n    col1    col2\n0   A       A60\n1   B       B23\n2   C       NaN\n\nThe data from is read from a csv file. Suppose I want to change each non-missing value of 'col2' to its prefix (i.e. 'A' or 'B'). How could I do this without writing a for loop?\nThe expected output is \n\n    col1    col2\n0   A       A\n1   B       B\n2   C       NaN","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":489,"Q_Id":49460990,"Users Score":0,"Answer":"You may need to use isnull():\n\ndf['col2'] = df['col2'].apply(lambda x: str(x)[0] if not pd.isnull(x) else x)","Q_Score":0,"Tags":"python,pandas","A_Id":49461632,"CreationDate":"2018-03-24T03:43:00.000","Title":"How to change values in certain columns according to certain rule in pandas dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying install TensorFlow on ubuntu 16.04, when I run python->import TensorFlow, \nI got error: \n\nserialized_pb=_b('\\n\/tensorflow\/core\/framework\/resource_handle.proto\\x12\\ntensorflow\\\"r\\n\\x13ResourceHandleProto\\x12\\x0e\\n\\x06\\x64\\x65vice\\x18\\x01\n  \\x01(\\t\\x12\\x11\\n\\tcontainer\\x18\\x02 \\x01(\\t\\x12\\x0c\\n\\x04name\\x18\\x03\n  \\x01(\\t\\x12\\x11\\n\\thash_code\\x18\\x04\n  \\x01(\\x04\\x12\\x17\\n\\x0fmaybe_type_name\\x18\\x05\n  \\x01(\\tB\/\\n\\x18org.tensorflow.frameworkB\\x0eResourceHandleP\\x01\\xf8\\x01\\x01\\x62\\x06proto3')\n  TypeError: init()got an unexpected keyword argument 'syntax'\n\nI have googled this, some one said the problem is wrong version of protobuf, when I type \"protobuf --version\" which shows Missing output directives, this was showing 3.3.0 before I installed bazel, but when I have tried : \" import google.protobuf \" and \"print google.protobuf.version \" which shows: 3.5.2.post1\nCan anyone tell me what is wrong !!!!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1292,"Q_Id":49463060,"Users Score":1,"Answer":"Try uninstalling protobuf and then check if Tensorflow works. If it still does not work try reinstalling Tensorflow.\nIf it still does not work trying using virtual environment in python.","Q_Score":1,"Tags":"python,tensorflow","A_Id":49463304,"CreationDate":"2018-03-24T09:15:00.000","Title":"python TensorFlow import failed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying install TensorFlow on ubuntu 16.04, when I run python->import TensorFlow, \nI got error: \n\nserialized_pb=_b('\\n\/tensorflow\/core\/framework\/resource_handle.proto\\x12\\ntensorflow\\\"r\\n\\x13ResourceHandleProto\\x12\\x0e\\n\\x06\\x64\\x65vice\\x18\\x01\n  \\x01(\\t\\x12\\x11\\n\\tcontainer\\x18\\x02 \\x01(\\t\\x12\\x0c\\n\\x04name\\x18\\x03\n  \\x01(\\t\\x12\\x11\\n\\thash_code\\x18\\x04\n  \\x01(\\x04\\x12\\x17\\n\\x0fmaybe_type_name\\x18\\x05\n  \\x01(\\tB\/\\n\\x18org.tensorflow.frameworkB\\x0eResourceHandleP\\x01\\xf8\\x01\\x01\\x62\\x06proto3')\n  TypeError: init()got an unexpected keyword argument 'syntax'\n\nI have googled this, some one said the problem is wrong version of protobuf, when I type \"protobuf --version\" which shows Missing output directives, this was showing 3.3.0 before I installed bazel, but when I have tried : \" import google.protobuf \" and \"print google.protobuf.version \" which shows: 3.5.2.post1\nCan anyone tell me what is wrong !!!!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1292,"Q_Id":49463060,"Users Score":0,"Answer":"Uninstall the protobuf and reinstall Tensorflow\nYou can use commands:\n\nconda uninstall protobuf\n\nNext \n\nconda install tensorflow","Q_Score":1,"Tags":"python,tensorflow","A_Id":53485860,"CreationDate":"2018-03-24T09:15:00.000","Title":"python TensorFlow import failed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have downloaded the package and it is in whl file when I try to install it, i get this error\n\nC:\\Python34\\Scripts>pip install C:\\Users\\213546472\\Downloads\\python_igraph-0.7.1.post6-cp34-cp34m-win_amd64.whl\n  python_igraph-0.7.1.post6-cp34-cp34m-win_amd64.whl is not a supported wheel on this platform.\n  Storing debug log for failure in C:\\Users\\213546472\\pip\\pip.log","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":517,"Q_Id":49463731,"Users Score":0,"Answer":"You're installing 64-bit wheel. Check that your Python is version 3.4 64 bit. If not \u2014 download a proper wheel (different Python version or 32 bit wheel).","Q_Score":0,"Tags":"python,python-3.x,python-3.4,python-wheel","A_Id":49464284,"CreationDate":"2018-03-24T10:40:00.000","Title":"how to install igraph package for python windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How do you divide a city such as San Francisco into equally sized blocks according to longitude and latitude coordinates? The aim of this is when I receive a coordinate of a location in the city I want to assign it automatically into one of these blocks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1719,"Q_Id":49467932,"Users Score":0,"Answer":"the naive approach is to find a big enough rectangle around the whole city (area you want to cover) and by the number of blocks desired you can deduce to how many parts divide the rectangular edges, it should be a fairly basic math\ngiven a point you can assign it to it's block in a very fast way (just check it's lan and long see where it falls in the grid)","Q_Score":0,"Tags":"python,python-3.x,google-maps,geolocation,data-visualization","A_Id":49467996,"CreationDate":"2018-03-24T17:50:00.000","Title":"Dividing City by Longitude and Latitude into Matrix","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to deploy a flask app I made to Heroku with success.\nThe app is generated but I get errors when I push the code to the Heroku repository.\nMy flask app is inside a module called server.py and the variable is named app.\nAt first I tried using gunicorn and writing \nweb: gunicorn server:app\nand deplying but no web dynos were up and I get an error stating it is the Procfile file.\nRed about it about and saw that Gunicorn is not really working on windows so I tried installing Waitress and deploying without success. this time my profcile was written as all of these (tried several times):\nweb: waitress-serve --listen=*:8000 server.wsgi:application\nweb: waitress-serve --listen=*:8000 app.wsgi:application\nAnd so on.\nto add a web dyno I should scale it because heroku ps: showes that there is no dynos.\nWhen I try to run heroku ps:scale web=1 I get:\nScaling dynos... !\n \u25b8    Couldn't find that process type.\nWhat am i doing wrong?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":873,"Q_Id":49468872,"Users Score":0,"Answer":"I was having the same problem. Particularly, waitress works locally in Windows (inside a Procfile.windows file web: waitress-serve index:server, then with heroku CLI heroku local -f Procfile.windows), but failed after Heroku deployment. Workaround for me was to locally test with waitress (like explained), but deploy with gunicorn (web: gunicorn index:server inside Procfile). Let me know if this works for you.","Q_Score":3,"Tags":"python,windows,heroku,waitress","A_Id":62723048,"CreationDate":"2018-03-24T19:19:00.000","Title":"Deploying a python flask web application on Heroku with Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying out the different optimization methods of tf.contrib.opt.ScipyOptimizerInterface and some of them (e.g. trust-exact) require the hessian of the objective function.\nHow can I use tf.hessians as hessian for tf.contrib.opt.ScipyOptimizerInterface? \nI tried to provide it with hess=tf.hessians(loss,variable) (which returns a list of tensors) but it needs a callable object. And if I input directly hess=tf.hessians I get TypeError: hessians() takes at least 2 arguments (1 given). \nIf you have any examples of tf.gradients or tf.hessians used with ScipyOptimizerInterface it would already be super useful!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":182,"Q_Id":49468976,"Users Score":0,"Answer":"This is not directly supported by TensorFlow's ScipyOptimizerInterface  but you should be able to build a hessian function that will be passed through the interface and work over its head. scipy.optimize.minimize expects a function that recieves a candidate solution p (in the form of a 1D numpy vector) and returns the Hessian.\nTherefore, define a Python function that receives a numpy vector p and evaluates the hessian for the solution defined by p using sess.run(hess,feed_dict=feed_dict). \nhess is a tensor defined once by hess=tf.hessians(loss,variable) outside this function (so you won't define another tf.hessians operation with each function call).\nfeed_dict is a dictionary with your tensorflow variable as a key and a numpy array p reshaped to fit your variable's shape as a value. In case you optimize more than one variable in parallel, dig in external_optimizer.py to see how it packs and unpacks multiple tensors into a single vector (look for _pack and _make_eval_func).\nNote that for most deep learning problems, calculating the Hessian is not practical because it's a matrix of the dimensions size(variable)xsize(variable) - which is typically too large. Hence the LBFGS optimizer is a more feasible second-order optimizer.","Q_Score":1,"Tags":"python,tensorflow","A_Id":49472921,"CreationDate":"2018-03-24T19:29:00.000","Title":"Tensoflow: Providing jacobians and hessians to ScipyOptimizerInterface","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to install and configure virtualenv and virtualenvwrapper for Python on MacOS?","AnswerCount":8,"Available Count":1,"Score":0.024994793,"is_accepted":false,"ViewCount":59827,"Q_Id":49470367,"Users Score":1,"Answer":"I had many problems to install the virtualenvwrapper in my mac os (big sur) but after I spent my whole sunday on that I finally got it. What I did I do:\n\nI reinstalled python3 using the homebrew. For some reason homebrew\nput your files in a non conventional directories (for exemple:\n\/opt\/homebrew\/bin\/python3 or \/opt\/homebrew\/bin\/virtualenv)\n\nThan I installed the virtualenv (even its already installed in python3\nby default) and I installed virtualenvwrapper in sudo mode: sudo pip3\ninstall virtualenvwrapper (without sudo, I could't find the\nvirtualenvwrapper.sh using whichvirtualenvwrapper).\n\nAfter that, in my home directory (\/\u02dc), I created the .bashrc file using\ntouch .bashrc because this file didn't existed in my home directory.\n\nI used the command \"which python3\", \"which virtualenv\" and \"which\nvirtualenvwrapper.sh\" to get the localization of them (it's important to\nget these location to fill the .bashrc file later). The result was:\n\n\/opt\/homebrew\/bin\/python3\n\/opt\/homebrew\/bin\/virtualenv\n\/opt\/homebrew\/bin\/virtualenvwrapper.sh\n\n\nThan, using vim editor, I wrote in this file like this:\nexport WORKON_HOME=$HOME\/.virtualenvs\nexport PROJECT_HOME=$HOME\/Devel\nexport VIRTUALENVWRAPPER_PYTHON=\/opt\/homebrew\/bin\/python3\nexport VIRTUALENVWRAPPER_VIRTUALENV=\/opt\/homebrew\/bin\/virtualenv\nsource \/opt\/homebrew\/bin\/virtualenvwrapper.sh\n\nThan, I saved this file using :wq command and run it using this command:\nsource .bashrc\n\nThan I testes using the writing \"workon\" command. It showed nothing so\nit worked\n\nFinally I create a virtual environment. It worked.\n\n\nI made a lot of mistakes and I really hope I did't damage my OS.","Q_Score":39,"Tags":"python-3.x,macos,virtualenv,virtualenvwrapper","A_Id":68433523,"CreationDate":"2018-03-24T21:57:00.000","Title":"Install virtualenv and virtualenvwrapper on MacOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I open Jupyter Notebooks, I see all of the folders under \"Owner\" on my computer (including My Documents, My Pictures, etc). I wanted to see if there was any way that I could install Anaconda or use Jupyter notebooks so that these folders are not seen. Having all of those folders clutters the screen, I just want folders for my datasets and notebooks. \nIn addition, when I open it in localhost and I see these folders (My Documents, My Pictures). \nDoes this mean that these files are copied onto python's servers?  Or would it only be accessible from my computer?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5893,"Q_Id":49471154,"Users Score":2,"Answer":"You can change the default directory of Jupyter Notebook.\n\nGo to .jupyter folder. It's usually in <USER NAME>\/.jupyter\n\nOpen the config file jupyter_notebook_config.py in a text editor\n\nIf the file was missing, create it first by running the command:\njupyter notebook --generate-config\n\nChange it at:\nc.NotebookApp.notebook_dir = 'D:\/'","Q_Score":2,"Tags":"python,jupyter-notebook","A_Id":49471689,"CreationDate":"2018-03-24T23:50:00.000","Title":"Folders visible when opening jupyter notebooks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"New to programming and interested to understand the internal implementation of methods and classes of Java and Python Languages. \nIs there any way to view the source code of these methods and or classes while using Eclipse and PyCharm ?\nWhat are the shortcuts?\nI understand the official documentation explains what the classes do but actually viewing the code really takes the veil off.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":123,"Q_Id":49471771,"Users Score":1,"Answer":"For the part of the Python standard library which is implemented in Python, you can use the standard PyCharm navigation shortcuts (Go to Definition, Go to Class) to jump to their source code.\nA large part of the Python standard library is implemented in C, though. The C source code needs to be downloaded separately, and there is no support in PyCharm for navigating to the C source code.\nFor Java and Eclipse, the regular navigation shortcuts should work too.","Q_Score":0,"Tags":"java,python,eclipse,pycharm","A_Id":49474125,"CreationDate":"2018-03-25T01:52:00.000","Title":"How to view internal code implementation of Python\/Java in Pycharm\/Eclipse respectively?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am newbie to python object oriented programming. I am trying to understand binary tree implantation code using python.  \nMy understanding is object.method is the way to call the function. But here the object is called as object[key]=\"value\" without explicitly calling the function like object.put(\"key\",\"value) . Please help me to understand this code.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":49472811,"Users Score":3,"Answer":"Like many languages that support object-oriented programming, Python has operators that can be overloaded by different classes as appropriate.\nFor example, when you write x + y, that calls x.__add__(y) (slightly oversimplified, but not in ways that are relevant here).\nThe [] here is just another operator. When you write object[key]=\"value\", that calls object.__setitem__(key, \"value\").\nSo, you are doing object-oriented method calling, just with a little bit of syntactic sugar on top to make it more readable.","Q_Score":0,"Tags":"python","A_Id":49472848,"CreationDate":"2018-03-25T05:26:00.000","Title":"Calling python method","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to choose a group of columns in a dask dataframe? \nThe slice df [['col_1', 'col_2']] does not seem to work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1478,"Q_Id":49473649,"Users Score":0,"Answer":"It was my mistake. I passed to the slicing operator a list of strings in a numpy array receiving a \"not implemented error\", passing a python list instead works correctly.","Q_Score":0,"Tags":"python,dataframe,dask","A_Id":49477081,"CreationDate":"2018-03-25T07:54:00.000","Title":"How to choose a group of columns in a Dask Dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get the following error when trying to use tensorflow\n\nimportError                               Traceback (most recent call\n  last)  in ()\n  ----> 1 import tensorflow as tf\n~\\Anaconda3\\lib\\site-packages\\tensorflow__init__.py in ()\n       22 \n       23 # pylint: disable=wildcard-import\n  ---> 24 from tensorflow.python import *\n       25 # pylint: enable=wildcard-import\n       26 \n~\\Anaconda3\\lib\\site-packages\\tensorflow\\python__init__.py in\n  ()\n       54 # imported using tf.load_op_library() can access symbols defined in\n       55 # _pywrap_tensorflow.so.\n  ---> 56 import numpy as np\n       57 try:\n       58   if hasattr(sys, 'getdlopenflags') and hasattr(sys, 'setdlopenflags'):\n~\\Anaconda3\\lib\\site-packages\\numpy__init__.py in ()\n      140         return loader(*packages, **options)\n      141 \n  --> 142     from . import add_newdocs\n      143     all = ['add_newdocs',\n      144                'ModuleDeprecationWarning',\n~\\Anaconda3\\lib\\site-packages\\numpy\\add_newdocs.py in ()\n       11 from future import division, absolute_import, print_function\n       12 \n  ---> 13 from numpy.lib import add_newdoc\n       14 \n       15 ###############################################################################\n~\\Anaconda3\\lib\\site-packages\\numpy\\lib__init__.py in ()\n        6 from numpy.version import version as version\n        7 \n  ----> 8 from .type_check import *\n        9 from .index_tricks import *\n       10 from .function_base import *\n~\\Anaconda3\\lib\\site-packages\\numpy\\lib\\type_check.py in ()\n        9            'common_type']\n       10 \n  ---> 11 import numpy.core.numeric as _nx\n       12 from numpy.core.numeric import asarray, asanyarray, array, isnan, zeros\n       13 from .ufunclike import isneginf, isposinf\n~\\Anaconda3\\lib\\site-packages\\numpy\\core__init__.py in ()\n       36 from . import numerictypes as nt\n       37 multiarray.set_typeDict(nt.sctypeDict)\n  ---> 38 from . import numeric\n       39 from .numeric import *\n       40 from . import fromnumeric\n~\\Anaconda3\\lib\\site-packages\\numpy\\core\\numeric.py in ()\n  1818     1819 # Use numarray's printing function\n  -> 1820 from .arrayprint import array2string, get_printoptions, set_printoptions    1821     1822 \n~\\Anaconda3\\lib\\site-packages\\numpy\\core\\arrayprint.py in ()\n       42 from .umath import absolute, not_equal, isnan, isinf, isfinite, isnat\n       43 from . import multiarray\n  ---> 44 from .multiarray import (array, dragon4_positional, dragon4_scientific,\n       45                          datetime_as_string, datetime_data, dtype, ndarray,\n       46                          set_legacy_print_mode)\n\nThis error occured after I tried to upgrade TF from version 1.1 to the latest version. So I dont know what current TF version I am using.\nI am using Windows 10 without a GPU.\nDo you know how to fix it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1449,"Q_Id":49477640,"Users Score":0,"Answer":"This looks like it is an issue with Numpy, which is a dependency of Tensorflow. Did you try upgrading your version of numpy using pip or conda?\nLike such: pip install --ignore-installed --upgrade numpy","Q_Score":0,"Tags":"python,python-3.x,tensorflow","A_Id":52206018,"CreationDate":"2018-03-25T15:41:00.000","Title":"TensorFlow: ImportError: cannot import name 'dragon4_positional'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"import cv2\n\nOn executing the above code, it shows the following error.\nError:\n\nTraceback (most recent call last)  in\n  ()\n  ----> 1 import cv2\nImportError: DLL load failed: The specified module could not be found.\n\nUnable to import cv2 in python\nI have installed OpenCV 2.4.13 and Anaconda3 with python 3.6.4.\nOpenCV location:C:\\Users\\harsh\\Anaconda3\nAnaconda location:C:\\Users\\harsh\\opencv.\nI have also added cv2.pyd in C:\\Users\\harsh\\Anaconda3\\Lib\\site-packages.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2644,"Q_Id":49479145,"Users Score":1,"Answer":"Try pip install opencv-python instead of pip install cv2. Although the name of the package changes, you can still import it as import cv2, It will work.","Q_Score":0,"Tags":"python,opencv,computer-vision,anaconda","A_Id":51741148,"CreationDate":"2018-03-25T18:07:00.000","Title":"Unable to import cv2 OpenCV 2.4.13 in python 3.6","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to log every Static Files request and the request IP address in Django. \nIn Console I am able to check the Static File Log, But I want access those logs inside an Django View with IP address of the request\nCan Suggest an solution or any work around.\nI am planning to server static files manually and perform logging.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":49479612,"Users Score":0,"Answer":"Solved, I Created an view to serve static files manually using Django in-built 'serve' method, In which I get the IP Address of the Request using meta data of the Request","Q_Score":0,"Tags":"python,django,file,logging,static","A_Id":49480708,"CreationDate":"2018-03-25T18:48:00.000","Title":"How to Access Static file logs inside an view in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a project to send, where basically I have to send an email using python.\nMy code is complete so I was about to send it.\nBecause of the fact the module smtplib needs my email log in, I compiled my code so people could no see my email and password, however, even compiled, when we look at the hex code, we can still see my email and password (and some print)\nIs there a way to compile so we have no information left after?\nThank you very much for your help and time !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":49480217,"Users Score":1,"Answer":"Generally it is a bad idea to hold sensitive information in the code. There is no uniformly the best way to do it, but common practices to store credentials include:\n\nin a separate code file not in your code base (local_settings.py, added to .gitignore)\nin a separate config file outside of the project (e.g. json or yml)\nenvironment variables (read using os.environ)\ncommand line parameters\nrequest as user input\na combination of all above","Q_Score":0,"Tags":"python,python-3.x,compilation,hex,pyc","A_Id":49480261,"CreationDate":"2018-03-25T19:47:00.000","Title":"remove remaining hex code in Pyc 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":"At first, I am learning Python and Django only... So I'm a noobie yet.\nI need to build a microservice architecture to I could run each my service on a separate server machine. In the Django I need to create an environment, project and apps. So, can I run these apps after on different servers? If no, how can I make it with Django? Do I need to create a separate project for each service?\nP.S. If my question is stupid, pls, explain where am I wrong. I am from Java Spring world where I was need to create just new app for each service.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":49480796,"Users Score":1,"Answer":"Either approach will work.\nIf it makes sense for your services to share the same code base, you can create a single project and use separate apps for each service and separate settings files for each deployment. The settings file would activate the desired app by listing it in INSTALLED_APPS, and would include settings specific to that service.\nOr, if you don't need the services to be coupled in that way, you could certainly make each one its own project.","Q_Score":0,"Tags":"django,python-3.x","A_Id":49482862,"CreationDate":"2018-03-25T20:50:00.000","Title":"Different IPs are for different apps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have never worked with audio before.\nFor a monophonic wav file read() returns an 1-D array of integers. What do these integers represent? Are they the frequencies? If not how do I use them to get the frequencies?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":152,"Q_Id":49481114,"Users Score":1,"Answer":"wavfile.read() returns two things:\ndata: This is the data from your wav file which is the amplitude of the audio taken at even intervals of time.\nsample rate: How many of those intervals make up one second of audio.","Q_Score":0,"Tags":"python-3.x,audio,scipy","A_Id":49957782,"CreationDate":"2018-03-25T21:26:00.000","Title":"What is returned by scipy.io.wavefile.read()?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Am using Python 3.6.5rcs , pip version 9.0.1 , selenium 3.11.0. The Python is installed in C:\\Python and selenium is in C:\\Python\\Lib\\site-packages\\selenium. The environment variables have been set. \nBut the code\nfrom selenium import webdriver\ngives an unresolved reference error.\nAny suggestion on how to fix the problem.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":8895,"Q_Id":49482586,"Users Score":1,"Answer":"I used this command to resolve my error.\npip install webdriver_manager","Q_Score":1,"Tags":"python,selenium,pycharm","A_Id":68728420,"CreationDate":"2018-03-26T00:59:00.000","Title":"Pycharm Referenced Error With Import Selenium Webdriver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Am using Python 3.6.5rcs , pip version 9.0.1 , selenium 3.11.0. The Python is installed in C:\\Python and selenium is in C:\\Python\\Lib\\site-packages\\selenium. The environment variables have been set. \nBut the code\nfrom selenium import webdriver\ngives an unresolved reference error.\nAny suggestion on how to fix the problem.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":8895,"Q_Id":49482586,"Users Score":1,"Answer":"I found this worked for me. I'm using PyCharm Community 2018.1.4 on Windows.\nNavigate to: File->Settings->Project: [project name] -> Project Interpreter\nOn this page click the configuration wheel at the top which should provide a drop down menu. Click \"Add\" and a window should appear called \"Add Python Interpreter\"\nYou will be defaulted onto \"Virtualenv Environment\" tab.\nThere should be a checkbox called \"Inherit global site-packages\". Check this.\nClick OK.\nAll your installed packages should be added.","Q_Score":1,"Tags":"python,selenium,pycharm","A_Id":51881788,"CreationDate":"2018-03-26T00:59:00.000","Title":"Pycharm Referenced Error With Import Selenium Webdriver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Am using Python 3.6.5rcs , pip version 9.0.1 , selenium 3.11.0. The Python is installed in C:\\Python and selenium is in C:\\Python\\Lib\\site-packages\\selenium. The environment variables have been set. \nBut the code\nfrom selenium import webdriver\ngives an unresolved reference error.\nAny suggestion on how to fix the problem.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":8895,"Q_Id":49482586,"Users Score":3,"Answer":"Pycharm > Preferences > Project Interpreter\nThen hit the '+' to install the package to your project path.\nOr you can add that path to your PYTHONPATH environment variable in your project.","Q_Score":1,"Tags":"python,selenium,pycharm","A_Id":49482631,"CreationDate":"2018-03-26T00:59:00.000","Title":"Pycharm Referenced Error With Import Selenium Webdriver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have using nltk packages and train a model using Naive Bayes. I have save the model to a file using pickle package. Now i wonder how can i use this model to test like a random text not in the dataset and the model will tell if the sentence belong to which categorize?\nLike my idea is i have a sentence : \" Ronaldo have scored 2 goals against Egypt\" And pass it to the model file and return categorize \"sport\".","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":147,"Q_Id":49484820,"Users Score":0,"Answer":"Just saving the model will not help. You should also save your VectorModel (like tfidfvectorizer or countvectorizer what ever you have used for fitting the train data). You can save those the same way using pickle. Also save all those models you used for pre-processing the train data like normalization\/scaling models, etc. For the test data repeat the same steps by loading the pickle models that you saved and transform the test data in train data format that you used for model building and then you will be able to classify.","Q_Score":0,"Tags":"python,nltk,text-mining,naivebayes","A_Id":49485045,"CreationDate":"2018-03-26T05:57:00.000","Title":"Text Categorization Test NLTK python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I understand correctly, the python syntax from ... import ... can be used in two ways\n\nfrom package-name import module-name\nfrom module-name import function-name\n\nI would like to know a bit of how Python internally treats the two different forms. Imagine, for example,  that the interpreter gets \"from A import B\", does the interpreter actually try to determine whether A is a package-name\/ module-name, or does it internally treat packages and modules as the same class of objects (something like Linux treats files and directories very similarly)?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":175,"Q_Id":49491650,"Users Score":-1,"Answer":"First of all, a module is a python file that contains classes and functions. when you say From A Import B python searches for A(a module) in the standard python library and then imports B(the function or class) which is the module if it finds A. If it doesn't it goes out and starts searching in the directory were packages are stored and searches for the package name( A ) and then if it finds it, it imports the Module name(B). If it fails in the past 2 processes it returns an error.\nHope this helps.","Q_Score":0,"Tags":"python,import,python-internals","A_Id":49491846,"CreationDate":"2018-03-26T12:36:00.000","Title":"How does Python internally distinguish \"from package import module\" between \"from module import function\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm training some models with my own NER pipe. I need to run spacy in lxc container so I can run it with python3.6 (which allow multi thread on training).\nBut.. on my 7 core authorized to run on my container only 1 run at 100% others run at 40-60% (actually they start at 100% but decrease after fews minutes). I would really like to improve this % core usage. Any idea to where to look ? Could it be a problem of Producer \/ Consumer ?\nEnv:\n- spaCy version 2.0.8\n- Location \/root\/.env\/lib\/python3.6\/site-packages\/spacy\n- Platform Linux-3.14.32-xxxx-grs-ipv6-64-x86_64-with-debian-buster-sid\n- Python version 3.6.4","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2172,"Q_Id":49492038,"Users Score":4,"Answer":"The only things that are multi-threaded are the matrix multiplications, which in v2.0.8 are done via numpy, which delegates them to a BLAS library. Everything else is single-threaded.\nYou should check what BLAS library your numpy is linked to, and also make sure that the library has been compiled appropriately for your machine. On my machine the numpy I install via pip comes with a copy of OpenBLAS that thinks my machine has a Prescott CPU. This prevents it from using AVX instructions. So if I install default numpy from pip on my machine, it runs 2-3x slower than it should.\nAnother problem is that OpenBLAS might be launching more threads than it should. This seems especially common in containers.\nFinally, the efficiency of parallelism very much depends on batch-size. On small batches, the matrices are small and the per-update routines such as the Adam optimiser take more of the time.\nI usually disable multi-threading and train on a single core, because this is the most efficient (in the sense of dollars-for-work) --- I then have more models training as separate processes (usually on separate  GCE VMs).\nWhen writing spaCy I haven't assumed that the goal is to use lots of cores. The goal is efficiency. It's not a virtue to use your whole machine to perform the same work that could be done on a single core. A lot of papers are very misleading in this respect. For instance, it might feel satisfying to launch 12 training processes across a cloud and optimize using an asynchronous SGD strategy such as Hogwild!. This is an efficient way to burn up a bunch of energy, but doesn't necessarily train your models any faster: using Adam and smaller batch sizes, training is more stable and often reaches the same accuracy in many fewer iterations. Similarly, we can make the network larger so the machines get their workout...But why? The goal is to train the model. Multiplying a bunch of matrices is a means, not an end.\nThe problem I've been most concerned with is the terrible BLAS linkage situation. This will be much improved in v2.1, as we'll be bringing our own OpenBLAS kernel. The kernel will be single-threaded by default.\nA simple thing to try if you suspect your BLAS is bad is to try installing numpy using conda. That will give you a copy linked against intel's MKL library.","Q_Score":2,"Tags":"python,multithreading,nlp,spacy","A_Id":49493806,"CreationDate":"2018-03-26T12:57:00.000","Title":"Spacy training multithread CPU usage","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python2.7 and python3.6 installed side by side in my computer. Now when I install a package using \"pip install\", how can I know in which python's site-packages is my package going to be installed?\nThank you.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":15344,"Q_Id":49492344,"Users Score":0,"Answer":"You can find the location of pip by which pip. Then you view the pip executable header using head `which pip` or using your preferred editor. You can find the python interpreter location on the first line. You may have a pip2 and a pip3 executable.\nBy the way, you can run pip as a python module by python -m pip <command>. In this way, you can specify your python interpreter.","Q_Score":4,"Tags":"python,python-2.7,python-3.6","A_Id":49492518,"CreationDate":"2018-03-26T13:12:00.000","Title":"Pip install location","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am testing complex and non-public webpages with python-selenium, which have interconnected iframes. \nTo proper click on a button or select some given element in a different iframe I have to switch to that iframe . Now, as contents of the pages might reload to the correct iframe I constantly have to check if the correct iframe is loaded yet, otherwise I have to go back to the default content, do the check again etc. \nI find this completely annoying and user-unfriendly behavior of selenium. \nIs there a basic workaround to find e.g. an element in ANY iframe? Because I do not care about iframes. I care about elements...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":717,"Q_Id":49492516,"Users Score":0,"Answer":"Unfortunately the API is built that way and you can't do anything about it. Each IFrame is a separate document as such, so eventually search a object in every IFrame would mean Selenium has to switch to every IFrame and do that for you. \nNow you can build a workaround by storing the IFrame paths and using helper methods to automatically switch to that IFrame hierarchy in your code. Selenium won't help you here, but you can ease your pain by writing helper methods designed as per your needs","Q_Score":0,"Tags":"python,selenium,iframe","A_Id":49492946,"CreationDate":"2018-03-26T13:21:00.000","Title":"Is there a workaround to avoid iframes in selenium testing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to build a Random Forest Regressor to model count data (Poisson distribution). The default 'mse' loss function is not suited to this problem. Is there a way to define a custom loss function and pass it to the random forest regressor in Python (Sklearn, etc..)? \nIs there any implementation to fit count data in Python in any packages?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10061,"Q_Id":49493331,"Users Score":0,"Answer":"If the problem is that the counts c_i arise from different exposure times t_i, then indeed one cannot fit the counts, but one can still fit the rates r_i = c_i\/t_i using MSE loss function, where one should, however, use weights proportional to the exposures, w_i = t_i.\nFor a true Random Forest Poisson regression, I've seen that in R there is the rpart library for building a single CART tree, which has a Poisson regression option. I wish this kind of algorithm would have been imported to scikit-learn.","Q_Score":10,"Tags":"python-3.x,scikit-learn,random-forest,statsmodels,poisson","A_Id":51396901,"CreationDate":"2018-03-26T14:00:00.000","Title":"Random Forest Regressor using a custom objective\/ loss function (Python\/ Sklearn)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm crawling web pages to create a search engine and have been able to crawl close to 9300 pages in 1 hour using Scrapy. I'd like to know how much more can I improve and what value is considered as a 'good' crawling speed.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":453,"Q_Id":49494093,"Users Score":-1,"Answer":"I'm no expert but I would say that your speed is pretty slow. I just went to google, typed in the word \"hats\", pressed enter and: about 650,000,000 results (0.63 seconds). That's gonna be tough to compete with. I'd say that there's plenty of room to improve.","Q_Score":5,"Tags":"python,scrapy,web-crawler","A_Id":49523000,"CreationDate":"2018-03-26T14:38:00.000","Title":"What is a good crawling speed rate?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm crawling web pages to create a search engine and have been able to crawl close to 9300 pages in 1 hour using Scrapy. I'd like to know how much more can I improve and what value is considered as a 'good' crawling speed.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":453,"Q_Id":49494093,"Users Score":0,"Answer":"It really depends but you can always check your crawling benchmarks for your hardware by typing scrapy bench on your command line","Q_Score":5,"Tags":"python,scrapy,web-crawler","A_Id":70224507,"CreationDate":"2018-03-26T14:38:00.000","Title":"What is a good crawling speed rate?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In maya, when creating a Vray rectangle light with Python, I am using the Maya createNode(type = \"VRayLightRectShape\") command. I am able to create the light, but it does not show up in the defaultLightSet group, I have to manually join it to the group, and even then, the light is not seen by any relationship editors such as the light linking editor. If I create another light, using the Maya GUI, then both my script created light and the new light will appear in the editors, but upon deleting the GUI created light, my script created light will also disappear from the light linking relationship editor. I am using Maya 2015.  Am I missing a connection somewhere in the creation process? Thanks for the help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":164,"Q_Id":49500276,"Users Score":0,"Answer":"I think you want to use the command :\ncmds.shadingNode('VRayLightRectShape', asLight=True)\nI don't have VRay so I can't test it but it should work.","Q_Score":1,"Tags":"python,maya","A_Id":49508559,"CreationDate":"2018-03-26T20:42:00.000","Title":"Maya, Python, Vray light not showing up for light linking","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering if there was a function in xlsxwriter that lets you sort the contents in the column from greatest to least or least to greatest? thanks!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":847,"Q_Id":49501501,"Users Score":2,"Answer":"Sorting isn't a feature of the xlsx file format. It is something Excel does at runtime.\nSo it isn't something XlsxWriter can replicate. A workaround would be to to sort your data using Python before you write it.","Q_Score":3,"Tags":"python,xlsxwriter","A_Id":49507909,"CreationDate":"2018-03-26T22:15:00.000","Title":"Is there a function in xlsxwriter that lets you sort a column?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a set of fairly complicated models that I am training and I am looking for a way to save and load the model optimizer states. The \"trainer models\" consist of different combinations of several other \"weight models\", of which some have shared weights, some have frozen weights depending on the trainer, etc. It is a bit too complicated of an example to share, but in short, I am not able to use model.save('model_file.h5') and keras.models.load_model('model_file.h5') when stopping and starting my training. \nUsing model.load_weights('weight_file.h5') works fine for testing my model if the training has finished, but if I attempt to continue training the model using this method, the loss does not come even close to returning to its last location. I have read that this is because the optimizer state is not saved using this method which makes sense. However, I need a method for saving and loading the states of the optimizers of my trainer models. It seems as though keras once had a model.optimizer.get_sate() and model.optimizer.set_sate() that would accomplish what I am after, but that does not seem to be the case anymore (at least for the Adam optimizer). Are there any other solutions with the current Keras?","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":21170,"Q_Id":49503748,"Users Score":2,"Answer":"upgrading Keras to 2.2.4 and using pickle solved this issue for me. with keras release 2.2.3 Keras models can now be safely pickled.","Q_Score":22,"Tags":"python,tensorflow,machine-learning,keras","A_Id":52691745,"CreationDate":"2018-03-27T03:06:00.000","Title":"Save and load model optimizer state","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to do clustering without providing any input apart from the data? The clustering method\/algorithm should decide from the data on how many logical groups the data can be divided, even it doesn't require me to input the threshold eucledian distance on which the clusters are built, this also needs to be learned from the data.\nCould you please suggest me what is closest solution for my problem?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":231,"Q_Id":49504271,"Users Score":1,"Answer":"Clustering is an explorative technique.\nThis means it must always be able to produce different results, as desired by the user. Having many parameters is a feature. It means the method can be adapted easily to very different data, and to user preferences.\nThere will never be a generally useful parameter-free technique. At best, some parameters will have default values or heuristics (such as Euclidean distance, such as standardizing the input prior to clusterings such as the gap statistic for choosing k) that may give a reasonable first try in 80% of cases. But after that first try, you'll need to understand the data, and try other parameters to learn more about your data.\nMethods that claim to be \"parameter free\" usually just have some hidden parameters set so it works on the few toy example it was demonstrated on.","Q_Score":0,"Tags":"python,cluster-analysis","A_Id":49528355,"CreationDate":"2018-03-27T04:15:00.000","Title":"clustering in python without number of clusters or threshold","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to do clustering without providing any input apart from the data? The clustering method\/algorithm should decide from the data on how many logical groups the data can be divided, even it doesn't require me to input the threshold eucledian distance on which the clusters are built, this also needs to be learned from the data.\nCould you please suggest me what is closest solution for my problem?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":231,"Q_Id":49504271,"Users Score":1,"Answer":"Why not code your algorithm to create a list of clusters ranging from size 1 to n (which could be defined in a config file so that you can avoid hard coding and just fix it once). \nOnce that is done, compute the clusters of size 1 to n. Choose the value which gives you the smallest Mean Square Error. \nThis would require some additional work by your machine to determine the optimal number of logical groups the data can be divided (bounded between 1 and n).","Q_Score":0,"Tags":"python,cluster-analysis","A_Id":49504632,"CreationDate":"2018-03-27T04:15:00.000","Title":"clustering in python without number of clusters or threshold","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"os.path.ismount() will verify whether the given path is mounted on the local linux machine. Now I want to verify whether the path is mounted on the remote machine. Could you please help me how to achieve this.\nFor example: my dev machine is : xx:xx:xxx\nI want to verify whether the '\/path' is mounted on yy:yy:yyy. \nHow can achieve this by using os.path.ismount() function","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":49504741,"Users Score":0,"Answer":"If you have access to both machines, then one way could be to leverage python's sockets. The client on the local machine would send a request to the server on the remote machine, then the server would do os.path.ismount('\/path') and send back the return value to the client.","Q_Score":0,"Tags":"python,python-2.7","A_Id":49505061,"CreationDate":"2018-03-27T05:06:00.000","Title":"Verify mountpoint in the remote server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Lets say I have a Django model object that requires to update a particular field if the last_updated datetime field is equal to today's date. \nIf I were to use F expression to avoid race condition, what would be the best way to compare the date from last_updated with current date using timezone.now().date()?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2059,"Q_Id":49507921,"Users Score":1,"Answer":"If you're looking to filter based on date, and your model has a DateTime field, you can simply use Django's __date lookup:\nMyModel.objects.filter(last_updated__date=timezone.now().date()).update(...)\nAlso, as a general note, remember that your code's timezone behavior will affect comparisons between timestamps and dates (i.e. the same timestamp might correspond to different dates depending on which timezone is in use).","Q_Score":3,"Tags":"python,django,django-models","A_Id":50280992,"CreationDate":"2018-03-27T08:28:00.000","Title":"Getting date from Django datetime field with F() expression","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"A robot is connected to a network with restricted outbound traffic. Only inbound traffic is allowed from one specific IP address(ours IP, e.g. 111.111.111.111). All outgoing traffic is forbidden.\nThere is settings and dhcp corresponding to external IP(e.g. 222.222.222.222). We want to connect to Pepper from the IP 111.111.111.111. The connection through SSH is fine with ssh nao@222.222.222.222 and password but we can not connect through Choregraphe or Python scripts. This is very important because we want to be able to connect with the robot remotely to upload different Choregraphe applications.\nThis is the error when we are trying to connect with a Python script:\n\n[W] 18872 qimessaging.transportsocket: connect: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond\n...\nRuntimeError: Failed to connect to service ALBehaviorManager on machine 1296211e-1921-3131-909b-69afa37\u0430\u0430\u043028. All endpoints are unavailable.\n\nThe Choregraphe hangs and crashes after a certain period of time.\nCan you give me some advice?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":490,"Q_Id":49508903,"Users Score":3,"Answer":"NAOqi connections go through port 9559 by default, so you could check whether that one is blocked.\nIf you are unable to connect through port 9559, you can do a port forwarding.  But I think this is a more network related question.","Q_Score":0,"Tags":"python,networking,connection,pepper,choregraphe","A_Id":49528384,"CreationDate":"2018-03-27T09:18:00.000","Title":"How to connect Choregraphe\/Python script to remote Pepper robot from different network?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have started learning Tensorflow recently and I am wondering if it is worth using in simple optimization problems (least squares, maximum likelihood estimation, ...) instead of more traditional libraries (scikit-learn, statsmodel)?\nI have implemented a basic AR model estimator using Tensorflow with MLE and the AdamOptimizer and the results are not convincing either performance or computation speed wise.\nWhat do you think?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":343,"Q_Id":49512935,"Users Score":6,"Answer":"This is somewhat opinion based, but Tensorflow and similar frameworks such as PyTorch are useful when you want to optimize an arbitrary, parameter-rich non-linear function (e.g., a deep neural network). For a 'standard' statistical model, I would use code that was already tailored to it instead of reinventing the wheel. This is true especially when there are closed-form solutions (as in linear least squares) - why go into to the murky water of local optimization when you don't have to? Another advantage of using existing statistical libraries is that they usually provide you with measures of uncertainty about your point estimates.\nI see one potential case in which you might want to use Tensorflow for a simple linear model: when the number of variables is so big the model can't be estimated using closed-form approaches. Then gradient descent based optimization makes sense, and tensorflow is a viable tool for that.","Q_Score":1,"Tags":"python,tensorflow","A_Id":49514082,"CreationDate":"2018-03-27T12:31:00.000","Title":"Is Tensorflow worth using for simple optimization problems?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does python have a function similar to the excel function IFERROR(value, value_if_error)\nCan I use np.where?\nMany Thanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4595,"Q_Id":49514486,"Users Score":1,"Answer":"No sure what you mean by an error in data in Python. \nDo you mean NA? Then try the fillna function in pandas.","Q_Score":1,"Tags":"python,pandas","A_Id":49514624,"CreationDate":"2018-03-27T13:39:00.000","Title":"Excel function IFERROR(value, value_if_error). Does it have a python equivalent?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to call the R function predict(fit_hs, type=\"quantile\", se.fit=True, p=0.5) where predict refers to survreg in library survival. \nIt gives an error about the se.fit parameter saying it's a keyword that can't be used.\nCould you please help finding a way to call this R function from Python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":49514535,"Users Score":0,"Answer":"In Python you can not use \".\" as part of keywords, replacing \".\" with \"_\", so \"se_fit\", should work.","Q_Score":1,"Tags":"python,r,prediction,rpy2","A_Id":67007173,"CreationDate":"2018-03-27T13:42:00.000","Title":"Calling R function with se.fit parameter with rpy2 from Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Good Day All, \nI finished writing the site blocker process and then i renamed the \"py\" file by appending \"w\", double clicked to run it yet the process did not show up in the task manager. I tried it a few times and yet nothing showed up. Mind you I am on Win 10 OS.\nYou have any suggestions to help fix this such that is shows up in the task manager as pythonw.exe process ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2157,"Q_Id":49516056,"Users Score":0,"Answer":"If the process isn't showing up in the Task Manager, it's very likely that it's immediately quitting with an error. Even trivial changes to the code cause this to occur. Without the console showing output it's hard to tell what that error is. Try renaming the file back to filename.py and running it to see if an error is occurring.\nAnother possibility is that the script is completing so fast you don't have time to see it. Did it run instantaneously when it was named filename.py?","Q_Score":0,"Tags":"python,python-3.x,windows-10,pythonw","A_Id":49517945,"CreationDate":"2018-03-27T14:48:00.000","Title":"how to run python 'pyw' file in Windows 10 process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using Python 27 in windows and I needed to install some modules in it so using pip I installed matplotlib which worked fine but then when I tried installing graphics,it didn't work. I also googled where I found that Graphics can be installed for 3x version. I am using 2x version because I wanted to use Vpython as well which doesn't work for 3x version (atleast I found it is very difficult to use with Python 34). Then I tried using both the Python 27 and 34 and then tried installing modules in Python 34 but since matplotlib is already installed before,I am unable to install for Python 34.Also there is not module in Python 34. I just started using Python and I am having all these problems. Please anyone who could help me with it?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3692,"Q_Id":49517915,"Users Score":0,"Answer":"Open Command Prompt and type exaclty what shown in the image","Q_Score":0,"Tags":"python-3.x,python-2.7,vpython","A_Id":54375996,"CreationDate":"2018-03-27T16:20:00.000","Title":"How to install graphics in python any version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I built a program in Linux using Python and used Pyinstaller to create an executable. When I run the executable on Windows 10, it tells me that the software is not compatible with Windows 10 and won't run.\nI tried the compatibility solver\/wizard and the program still won't run on Windows 10.\nIs there something I might have missed while using Pyinstaller?\nOr do I need to install some programs on windows 10 to make it work?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1117,"Q_Id":49521689,"Users Score":2,"Answer":"If you want your program to run on Windows you have to use PyInstaller on Windows to create the executable for Windows.","Q_Score":0,"Tags":"python,windows-10,pyinstaller","A_Id":49521777,"CreationDate":"2018-03-27T20:14:00.000","Title":"Executable made from pyinstaller is not compatible in windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After installing the Python extension, I find myself not being able to debug. When I select any of the default launch configurations and press the green arrow to start debugging, it notifies me with the error message in the title. I am not using any external modules, I am simply trying to run a single line hello world program and this error still appears. I have tried reinstalling the extension, deleting the .vscode folder and checking the path of my Python interpreter.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1081,"Q_Id":49522024,"Users Score":2,"Answer":"I had the same problem, it was gone after I delete c:\\users\\username\\ .code and reinstall vscode. hope that helps.\nLidong","Q_Score":0,"Tags":"python-3.x,visual-studio-code","A_Id":49523106,"CreationDate":"2018-03-27T20:38:00.000","Title":"Python extension - Debug adapter process has terminated unexpectedly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python3, I mainly use float or np.float32\/64 and when it comes to store it into a database, even if SQL type is Numeric\/Decimal we end up with 0.400000000000021 or something like that instead of 0.4\nIt may be a problem if such data is accessed from another application.\nWorking only with decimal.Decimal in python isn't an answer for us, since we heavely make use of pandas, and Decimal is not supported.\nA solution would be to cast float to Decimal just before inserting into SQL (SQL Server in our case but it's a detail). And then back from Decimal to float after SELECT.\nDo you have another (and nicer) way to handle such issue ?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":4457,"Q_Id":49522441,"Users Score":6,"Answer":"The problem is that the value of your float isn't 0.4, because there is no value in either float32 or float64 (or Python native float, which is usually the same as float64) that's 0.4. The closest float64 to 0.4 that is 0.400000000000021, which is exactly what you've got.\nSince that's the closest float value there is to 0.4, if you ask Python to convert it to a string (e.g., print(f)), it'll be friendly and give you the string 0.4.\nBut when you pass it to a database\u2026 Well, it actually depends on which database interface library you're using. With some, it will call repr, which would give you '0.4' (at least in Python 3.x), so you're asking the database to store the float value of the string '0.4'. But with others, it will pass the float value directly as a C double, so you're asking the database to store the float value 0.400000000000021.\n\nSo, what should you do?\n\nDo you want to use this database with other code that will be reading the values as strings and then converting them to something like Decimal or float80 or decimal64 or some other type? Then you almost certainly want to set a SQL data type like DECIMAL(12, 6) that matches your actual precision, and let the database take care of it. (After all, there is no difference between 0.4 rounded to 6 decimal places and 0.400000000000021 rounded to 6 decimal places.)\nDo you want to do math inside the database itself? Same as above.\nOtherwise? Do nothing.\n\nSeriously, if the other code that's going to use this database is just going to read the values as float64, or read them as strings and convert them to float64 (or float32), they are going to end up with 0.400000000000021 no matter what you do, so don't do anything.\nAlso, consider this: if the difference between 0.4 and 0.400000000000021 is going to make any difference for any of your code, then your code is already broken by using float64, before you even get to the database.","Q_Score":2,"Tags":"python,sql,floating-point,decimal,precision","A_Id":49523107,"CreationDate":"2018-03-27T21:09:00.000","Title":"how to store python float in SQL database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python3, I mainly use float or np.float32\/64 and when it comes to store it into a database, even if SQL type is Numeric\/Decimal we end up with 0.400000000000021 or something like that instead of 0.4\nIt may be a problem if such data is accessed from another application.\nWorking only with decimal.Decimal in python isn't an answer for us, since we heavely make use of pandas, and Decimal is not supported.\nA solution would be to cast float to Decimal just before inserting into SQL (SQL Server in our case but it's a detail). And then back from Decimal to float after SELECT.\nDo you have another (and nicer) way to handle such issue ?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4457,"Q_Id":49522441,"Users Score":0,"Answer":"If you don't wan't\/need the precision, you can use np.round(array,roundto)","Q_Score":2,"Tags":"python,sql,floating-point,decimal,precision","A_Id":49522460,"CreationDate":"2018-03-27T21:09:00.000","Title":"how to store python float in SQL database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python3, I mainly use float or np.float32\/64 and when it comes to store it into a database, even if SQL type is Numeric\/Decimal we end up with 0.400000000000021 or something like that instead of 0.4\nIt may be a problem if such data is accessed from another application.\nWorking only with decimal.Decimal in python isn't an answer for us, since we heavely make use of pandas, and Decimal is not supported.\nA solution would be to cast float to Decimal just before inserting into SQL (SQL Server in our case but it's a detail). And then back from Decimal to float after SELECT.\nDo you have another (and nicer) way to handle such issue ?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4457,"Q_Id":49522441,"Users Score":0,"Answer":"You have to define decimal places in SQL, e.g.: decimal(8,2)","Q_Score":2,"Tags":"python,sql,floating-point,decimal,precision","A_Id":49522639,"CreationDate":"2018-03-27T21:09:00.000","Title":"how to store python float in SQL database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to parse a c and\/or c++ header file in python using llvmlite.  Is this possible?  And if so, how do I create an IR representation of the header's contents?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":49523349,"Users Score":0,"Answer":"llvmlite is a python binding for LLVM, which is independent from C or C++ or any other language. To parse C or C++, one option is to use the python binding for libclang.","Q_Score":0,"Tags":"python,llvm,header-files","A_Id":49525779,"CreationDate":"2018-03-27T22:23:00.000","Title":"How to parse a c\/c++ header with llvmlite in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to update Python 3.6 code with Spyder 3.2.4 (through Anaconda), but when I make a change to the code that I am working on and attempt to run it, it will run the code that I started the session with.  Does anyone know of any solutions to this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1491,"Q_Id":49524514,"Users Score":0,"Answer":"change the directory of .py that you are working on. Right click to sample.py(which is above of console) and choose set console working directory. You can apply it for each python file while working on it.\nI had also same problem and did that , now it is okey.","Q_Score":3,"Tags":"python,anaconda,spyder","A_Id":58023725,"CreationDate":"2018-03-28T00:59:00.000","Title":"Spyder does not run new changes in code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to include google correlate into my application using Python but I require its API to do so. Please help me where to look at or share me some insights about it. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":218,"Q_Id":49526421,"Users Score":0,"Answer":"Google correlate data is valid up till 2017 March, not sure if it's deprecated but it definitely won't be useful if you're after up-to-date correlations","Q_Score":0,"Tags":"python-3.x","A_Id":55298815,"CreationDate":"2018-03-28T04:59:00.000","Title":"Is there any google correlate API that I can refer to?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Coding is entirely new to me. \nRight now, I am teaching myself Python. As of now, I am only going over algorithms. I watched a few crash courses online about the language. Based on that, I don't feel like I am able to code any sort of website or software which leads me wonder if the libraries and frameworks of any programming language are the most important bit?\nShould I spend more time teaching myself how to code with frameworks and libraries?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":49526618,"Users Score":1,"Answer":"First of all, you should try to be comfortable with every Python mechanisms (classes, recursion, functions... everything you usually find in any book or complete tutorial). It could be useful for any problem you want to solve. \nThen, you should start your own project using the suitable libraries and frameworks. You must set a clear goal, do you want to build a website or a software ? You won't use the same libraries\/framework for any purpose. Some of them are really often used so you could start by reading their documentation.\nAnyhow, to answer your question, framework and libraries are not the most important bit of coding. They are just your tools, whereas the way you think to solve problems and build your algorithms is your art.  \nThe most important thing to be a painter is not knowing how to use a brush (even if, of course, it's really useful)","Q_Score":1,"Tags":"python,frameworks,libraries","A_Id":49530470,"CreationDate":"2018-03-28T05:18:00.000","Title":"Are framework and libraries the more important bit of coding?","Data 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 page where anyone can see the homepage without login, Any idea?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":49529119,"Users Score":0,"Answer":"Simply Remove all the accesses for the public users in settings but check PORTAL USER box under Other Extra Rights. So when a user views the homepage, there won't be any login. Users can view the homepage without logged in.","Q_Score":0,"Tags":"python,web,odoo-8,odoo,qweb","A_Id":49531546,"CreationDate":"2018-03-28T08:01:00.000","Title":"ODOO-v8 :How to view the homepage alone without logged in?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have recently begun looking at Dask for big data. \nI have a question on efficiently applying operations in parallel.\nSay I have some sales data like this:\ncustomerKey    productKey    transactionKey    grossSales  netSales      unitVolume    volume transactionDate\n-----------  --------------  ----------------  ----------  --------      ----------    ------ --------------------\n    20353           189            219548     0.921058     0.921058              1         1  2017-02-01 00:00:00\n  2596618           189            215015     0.709997     0.709997              1         1  2017-02-01 00:00:00\n 30339435           189            215184     0.918068     0.918068              1         1  2017-02-01 00:00:00\n 32714675           189            216656     0.751007     0.751007              1         1  2017-02-01 00:00:00\n 39232537           189            218180     0.752392     0.752392              1         1  2017-02-01 00:00:00\n 41722826           189            216806     0.0160143    0.0160143             1         1  2017-02-01 00:00:00\n 46525123           189            219875     0.469437     0.469437              1         1  2017-02-01 00:00:00\n 51024667           189            215457     0.244886     0.244886              1         1  2017-02-01 00:00:00\n 52949803           189            215413     0.837739     0.837739              1         1  2017-02-01 00:00:00\n 56526281           189            220261     0.464716     0.464716              1         1  2017-02-01 00:00:00\n 56776211           189            220017     0.272027     0.272027              1         1  2017-02-01 00:00:00\n 58198475           189            215058     0.805758     0.805758              1         1  2017-02-01 00:00:00\n 63523098           189            214821     0.479798     0.479798              1         1  2017-02-01 00:00:00\n 65987889           189            217484     0.122769     0.122769              1         1  2017-02-01 00:00:00\n 74607556           189            220286     0.564133     0.564133              1         1  2017-02-01 00:00:00\n 75533379           189            217880     0.164387     0.164387              1         1  2017-02-01 00:00:00\n 85676779           189            215150     0.0180961    0.0180961             1         1  2017-02-01 00:00:00\n 88072944           189            219071     0.492753     0.492753              1         1  2017-02-01 00:00:00\n 90233554           189            216118     0.439582     0.439582              1         1  2017-02-01 00:00:00\n 91949008           189            220178     0.1893       0.1893                1         1  2017-02-01 00:00:00\n 91995925           189            215159     0.566552     0.566552              1         1  2017-02-01 00:00:00\nI want to do a few different groupbys, first a groupby-apply on customerKey.\nThen another groupby-sum on customerKey, and a column which will be the result of the previos groupby apply.\nThe most efficient way I can think of doing this would be do split this dataframe into partitions of chunks of customer keys. \nSo, for example I could split the dataframe into 4 chunks with a partition scheme for example like (pseudocode)\npartition by customerKey % 4\nThen i could use map_partitions to do these group by applies for each partition, then finally returning the result. However it seems dask forces me to do a shuffle for each groupby I want to do.\nIs there no way to repartition based on the value of a column?\nAt the moment this takes ~45s with 4 workers on a dataframe of only ~80,000 rows. I am planning to scale this up to a dataframe of trillions of rows, and already this seems like it is going to scale horribly.\nAm I missing something fundamental to Dask?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":9214,"Q_Id":49532824,"Users Score":-1,"Answer":"Setting index to the required column and map_partitions works much efficient compared to groupby","Q_Score":14,"Tags":"python,pandas,dataframe,dask,dask-distributed","A_Id":55154657,"CreationDate":"2018-03-28T11:02:00.000","Title":"Dask dataframe split partitions based on a column or function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a program for people at work that simply takes csvs, converts them, and turns them into a csv that can be read by a different program and I have made the program in Python. Everyone here uses Windows so I originally used py2exe to make an exe and it worked fine for everyone.\nRecently, I made some changes to the code to use the newest Python version which py2exe does not support so I used pyinstaller which worked great. However, when I passed it on to a few people at the office to test it, Windows SmartScreen caught it and the Anti-Virus program quarantined it for 3 hours. Obviously this is not ideal. What can I do to not make SmartScreen catch it? And why would py2exe not trigger the same warnings?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":365,"Q_Id":49537271,"Users Score":-1,"Answer":"SmartScreen show this warning for executables that are not popular and unfortunately Microsoft does't give a certain number of downloads to SmartScreen stop triggering out.","Q_Score":1,"Tags":"python,pyinstaller,smartscreen","A_Id":51065466,"CreationDate":"2018-03-28T14:30:00.000","Title":"PyInstaller app gets caught by SmartScreen","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So this is a bit of a tricky situation. Using Three.js\/ReactJS and canvas. \nScenario: When I click and drag a sphere beyond its boundaries a tooltip will show a warning message over the mouse pointer. When I release the mouse the tooltip will disappear. When I click and drag the sphere back to a position inside the boundaries, the tooltip will not be displayed once inside the boundaries.\nBear in mind this is tied into the state of the app handled by react, and in this instance the tooltip is being updated when the conditions are met and updated in the state. \nThe tooltip element is present however, the attributes and content gets updated on a click and hold when the sphere is out of bounds...\nusing\nActionChains(page.driver).move_to_element_with_offset(sphere_order_panel, -1047, 398).click_and_hold().move_to_element_with_offset(sphere_order_panel, -1633, 265).click_and_hold().perform()\nclicks on the element and drags it to the position outside of its boundaries, but the tooltip is NOT updated... i've put a breakpoint on the page once i manually click into the page, my sphere gets snapped to my mouse location (meaning click_and_hold is indeed working... but i check the html and verify that the tooltip is not updated. however if i manually use my mouse and click on the sphere the tooltip will update! is selenium automation not executing the click_and_hold correctly? I don't think this is the case. \nIs there a way to add the mouse pointer to the page using selenium?\nOr is there a way to use execute_script() to use javascript on the page to satisfy my conditions to get the tooltip to be updated?\nI'm really stuck on this.. and this is a tricky situation (for me at least)\nAny help greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":198,"Q_Id":49539286,"Users Score":0,"Answer":"to get around my issue, I had to do this \nchain = ActionChains(page.driver).move_to_element_with_offset(sphere_order_panel, -1047, 398).click_and_hold()\nchain = chain.move_to_element_with_offset(sphere_order_panel, -1047, 398) \nchain.perform()","Q_Score":0,"Tags":"python,reactjs,selenium,canvas,three.js","A_Id":49634904,"CreationDate":"2018-03-28T16:04:00.000","Title":"Python Selenium: Show Tooltip on Mouse Pointer (Three.js\/React\/Canvas)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Goal: how to convert (111, 222, 333) to ('111', '222', '333') for an sql query in Python?\nWhat I have done so far: \nI am calling a csv file to a df:\ndataset = pd.read_csv('simple.csv')\nprint(dataset)\nLIST\n0     111\n1     222\n2     333\nList11 = dataset.LIST.apply(str)\nprint(List1)\n0    111\n1    222\n2    333\nName: OPERATION, dtype: object\nmyString = \",\".join(List1)\nprint(myString)\n111,222,333\nsql = \"SELECT * FROM database WHERE list IN (%s)\" %myString\nThis does not work. Could you please help?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1305,"Q_Id":49541070,"Users Score":0,"Answer":"Please try this and verify if it helps-\nsql = \"SELECT * FROM database WHERE list IN (%s)\" % \",\".join(map(myString,List1))","Q_Score":2,"Tags":"python,sql,arrays,string,quote","A_Id":49542244,"CreationDate":"2018-03-28T17:49:00.000","Title":"(Sql + Python) df array to string with single quotes?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating an app for school and I could use some Machine Learning in it. Although, the libraries I know that I could use to process and predict my data are all for Python. \nIs there a way that I could get data from Flutter app, process it in a Python backend and return the output to the Flutter app? \nOr is there an alternative I could use on Flutter? I already plan to use Firebase in the app, is there any kind of machine learning tool for data stored on Firebase?\nThanks.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":2842,"Q_Id":49544896,"Users Score":1,"Answer":"Flutter builds the apps. The apps can communicate with any backend of your choice - or with multiple backends if you need it. For example, it can connect to Firebase for user data, etc., and connect to a different backend for machine learning (e.g. Google Cloud AI).","Q_Score":1,"Tags":"python,firebase,tensorflow,scikit-learn,flutter","A_Id":49545273,"CreationDate":"2018-03-28T22:02:00.000","Title":"Is there a way to work with Python (e.g.: TensorFlow or Sci-kit learn libs) in Flutter apps?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating an app for school and I could use some Machine Learning in it. Although, the libraries I know that I could use to process and predict my data are all for Python. \nIs there a way that I could get data from Flutter app, process it in a Python backend and return the output to the Flutter app? \nOr is there an alternative I could use on Flutter? I already plan to use Firebase in the app, is there any kind of machine learning tool for data stored on Firebase?\nThanks.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":2842,"Q_Id":49544896,"Users Score":1,"Answer":"Rather you can use python plus tensowflow in your jupyter notebook and train your model and then upload your custom model on the firebase ml kit and from their you can use it. \nThe ml kit in the firebase is very handy in applying machine learning.","Q_Score":1,"Tags":"python,firebase,tensorflow,scikit-learn,flutter","A_Id":53039686,"CreationDate":"2018-03-28T22:02:00.000","Title":"Is there a way to work with Python (e.g.: TensorFlow or Sci-kit learn libs) in Flutter apps?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Django application that is successfully being hosted on a remote server using Nginx. The production DB is PostgreSQL. \nI have a development server where I'd like to change the code for the Django application. When I use python manage.py runserver for testing, I'd ideally prefer to avoid touching the production DB at all. \nThis is my first time crossing this bridge. Can someone shed some light on the best practice for 'stubbing' the entire database for development? Can you do some if\/else statement in settings.py to use SQLite? Or is there a better solution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":87,"Q_Id":49544913,"Users Score":1,"Answer":"You can definitely use if\/else statements in settings.py, or any Python code really.\nCommon practice is to put values which differ, especially secrets like database passwords, in environment variables. You set these to different values in production or locally and access them in Python using os.environ.","Q_Score":0,"Tags":"python,django,postgresql","A_Id":49544986,"CreationDate":"2018-03-28T22:03:00.000","Title":"Best way to modify Django application without affecting production database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In select,there is a list for error socket or epoll has event for ERROR\nBut in selectors module just has events for EVENT_READ and EVENT_WRITE.\ntherefore\uff0chow can I know the error socket without event?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":624,"Q_Id":49547266,"Users Score":6,"Answer":"An error on the socket will always result in the underlying socket being signaled as readable (at least). For example, if you are waiting for data from a remote peer, and that peer closes its end of the connection (or abends, which does the same thing), the local socket will get the EVENT_READ marking. When you go to read it, you would then get zero bytes (end of file), telling you that the peer is gone (or at least finished sending).\nSimilarly, if you were waiting to send data and the peer resets the connection, you will get an EVENT_WRITE notification. When you then go to attempt a send, you will get an error from the send (which, in python, means an exception).\nThe only thing you lose here from select is the ability to detect exceptional conditions: the xlist from select.select or POLLPRI from select.poll. If you needed those, you would need to use the lower-level select module directly. (Priority\/out of band data is not commonly used so this is not an unreasonable choice.)\nSo the simplified interface provided by selectors really loses no \"error\" information. If there is an error on the socket that would have caused a POLLERR return from select.poll, a RST from the remote, say, you will get a EVENT_READ or EVENT_WRITE notification and whatever error occurred will be re-triggered as soon as you attempt send or recv.\nA good rule of thumb to keep in mind with select, poll and friends is that a result indicating \"readable\" really means \"will not block if you attempt to read\". It doesn't mean you will actually get data back from the read; you may get an error instead. \nLikewise for \"writable\": you may not be able to send data, but attempting the write won't block.","Q_Score":2,"Tags":"python-3.x,sockets","A_Id":49563017,"CreationDate":"2018-03-29T02:53:00.000","Title":"why python selectors module has no event for socket error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a python program that implements the Huffman Compression. However, it seems that I can only read \/ write to bin file byte by byte instead of bit by bit. Is there any workaround for this problem? Wouldn't processing byte by byte defeat the purpose of compression since extraneous padding would be needed. Also, it'd be great if someone can enlighten me about the application of Huffman Compression with regards to this byte-by-byte problem. w","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":501,"Q_Id":49547478,"Users Score":0,"Answer":"Layer your code. Have a bottom io layer that does all file reads and writes either entire file at once or with buffering. Have a layer above that which processes the Huffman code bitstream by bits.","Q_Score":1,"Tags":"python,algorithm,compression,huffman-code","A_Id":49547639,"CreationDate":"2018-03-29T03:22:00.000","Title":"Reading bit by bit for Huffman Compression","Data Science and Machine Learning":0,"Database and SQL":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 just opened up Komodo edit and can't run any code.\nI just get this message in the command output:\n\n\/usr\/bin\/python: can't open file 'Python3-1.py': [Errno 2] No such file or directory\n\nWhat do I do? I installed python3 again. Do I need to install it in the right place?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":851,"Q_Id":49547680,"Users Score":1,"Answer":"I think it say for you - I can't find your file.\nYou should try to check path to you file. \nThen you should try to run your code from terminal. Open terminal app (gnome-terminal, konsole, xfce-terminal or etc. what you always using for this) and try run directly you file in you folder like this:\npython Python3-1.py or python3 Python3-1.py or python3 -m Python3-1.py.\nIf all works fine - check you Komodo settings.Edit -> Preferences in Language block check in Python Default Python Interpreter\nIf not help you -please update you question for more information.\nP.S. and you should try VS Code for python development. It have awesome integrated terminal and you can learing run all programs on command line, like you will do it in real life. Komodo Edit good editor, but not the best for this.","Q_Score":1,"Tags":"python,komodo","A_Id":49547788,"CreationDate":"2018-03-29T03:44:00.000","Title":"Python 101 : Komodo edit - code not running in command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"to access google drive files, you need to call: google.colab.auth.authenticate_user(), which presents a link to an authetication screen, which gives a key you need to paste in the original notebook\n\nis it possible to skip this all together? after all the notebook is already 'linked' to a specific account \nis it possible to save this token hardcoded in the notebook for future runs?\nis it possible to create a token that can access only some files (useful when sharing the notebook with others - you want to give access only to some data files)\nis it possible to simplify the process (make it a single click, without needing to copy paste the token)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":763,"Q_Id":49548471,"Users Score":2,"Answer":"Nope, there's no way to avoid this step at the moment.\nNo, there's no safe way to save this token between runs.\nSharing the notebook doesn't share the token. Another user executing your notebook will go through the auth flow as themselves, and will only be able to use the token they get for Drive files they already have access to.\nSadly, not right now. :)","Q_Score":3,"Tags":"python,google-authentication,google-colaboratory","A_Id":49583498,"CreationDate":"2018-03-29T05:12:00.000","Title":"When accessing google driver from google colab, is it possible to eliminate, or simplify authentication?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Now i am developing a website in django. But i used MySQLdb to connect with the database instead of django ORM since django ORM doesn't support multiple keys.\nI will explain my question with a example, consider i am writing a dictionary to database having type longtext. Hence i have used json.dumps() method to write database.\nI am reading those field using another url, hence while coding view function for reading i have used json.loads() method to get the dictionary back and here is my question arise. Whether i need to handle the exception when database field hold a non json string. If database field hold a non json string json.loads() will produce ValueError.\nWhether i need to catch those type of error since chance of having database with non json string is very little.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":49550077,"Users Score":0,"Answer":"It's down to preference but personally I try to catch all potential errors, you never know what other issues they might expose.\nAnd ofcourse, there's the \"Zen of Python\": \"Errors should never pass silently.\nUnless explicitly silenced\"","Q_Score":0,"Tags":"python,json,django,django-testing","A_Id":49550213,"CreationDate":"2018-03-29T07:14:00.000","Title":"How to code a django site efficiently while accessing database using MySQLdb?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"1) I try to rename a model and the layers in Keras with TF backend, since I am using multiple models in one script.\nClass Model seem to have the property model.name, but when changing it I get \"AttributeError: can't set attribute\".\nWhat is the Problem here?\n2) Additionally, I am using sequential API and I want to give a name to layers, which seems to be possibile with Functional API, but I found no solution for sequential API. Does anonye know how to do it for sequential API?\nUPDATE TO 2): Naming the layers works, although it seems to be not documented. Just add the argument name, e.g. model.add(Dense(...,...,name=\"hiddenLayer1\"). Watch out, Layers with same name share weights!","AnswerCount":9,"Available Count":2,"Score":-1.0,"is_accepted":false,"ViewCount":40090,"Q_Id":49550182,"Users Score":-4,"Answer":"for 1), I think you may build another model with right name and same structure with the exist one. then set weights from layers of the exist model to layers of the new model.","Q_Score":27,"Tags":"python,keras","A_Id":51157225,"CreationDate":"2018-03-29T07:20:00.000","Title":"Keras rename model and layers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"1) I try to rename a model and the layers in Keras with TF backend, since I am using multiple models in one script.\nClass Model seem to have the property model.name, but when changing it I get \"AttributeError: can't set attribute\".\nWhat is the Problem here?\n2) Additionally, I am using sequential API and I want to give a name to layers, which seems to be possibile with Functional API, but I found no solution for sequential API. Does anonye know how to do it for sequential API?\nUPDATE TO 2): Naming the layers works, although it seems to be not documented. Just add the argument name, e.g. model.add(Dense(...,...,name=\"hiddenLayer1\"). Watch out, Layers with same name share weights!","AnswerCount":9,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":40090,"Q_Id":49550182,"Users Score":10,"Answer":"To rename a keras model in TF2.2.0:\nmodel._name = \"newname\"\nI have no idea if this is a bad idea - they don't seem to want you to do it, but it does work. To confirm, call model.summary() and you should see the new name.","Q_Score":27,"Tags":"python,keras","A_Id":63853924,"CreationDate":"2018-03-29T07:20:00.000","Title":"Keras rename model and layers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say we have some method foo we call during graph construction time that returns some tf.Tensors or a nested structure of them every time is called, and multiple other methods that make use of foo's result. For efficiency and to avoid spamming the TF graph with unnecessary repeated operations, it might be tempting to make foo cache its result (to reuse the subgraph it produces) the first time is called. However, that will fail if foo is ever used in the context of a control flow, like tf.cond, tf.map_fn or tf.while_loop.\nMy questions are:\n\nWhen is it safe to cache tf.Tensor objects in such a way that does not cause problems with control flows? Perhaps is there some way to retrieve the control flow under which a tf.Tensor was created (if any), store it and compare it later to see if a cached result can be reused?\nHow would the answer to the question above apply to tf.Operations?\n\n(Question text updated to make clearer that foo creates a new set of tensors every time is called)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":321,"Q_Id":49550723,"Users Score":0,"Answer":"TL;DR: TF already caches what it needs to, don't bother with it yourself.\nEvery time you call sess.run([some_tensors]) TF's engine find the minimum subgraph needed to compute all tensors in [some_tensors] and runs it from top to bottom (possibly on new data, if you're not feeding it the same data).\nThat means, caching of results in-between sess.run calls is useless towards saving computation, because they will be recomputed anyway.\nIf, instead, you're concerned with having multiple tensors using the same data as input in one call of sess.run, don't worry, TF is smart enough. if you have input A and B = 2*A, C = A + 1, as long as you do one sess.run call as sess.run([B,C]) A will be evaluated only once (and then implicitly cached by the TF engine).","Q_Score":1,"Tags":"python,tensorflow","A_Id":49551180,"CreationDate":"2018-03-29T07:51:00.000","Title":"When is it safe to cache tf.Tensors?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recently developed a python based UI script using tkinter and python 2.7 on Windows 10 OS. To distribute it to the users I converted the script into an single file exe using pyinstaller.\nThe script is working fine on all Windows 10 systems but creating issue on Windows 7 as:\n\"Fatal Error: Can not run ... script\"\nI cannot wrap my head around it.\nAny help is appreciated.\nThanx in advance..:)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1879,"Q_Id":49551660,"Users Score":1,"Answer":"When you use pyinstaller to compile your script to executable in windows 10 and want to use it in window 7 it won't work.\nBut you can compile it with pyinstaller in windows 7 and use the executable in windows 7, 8, and 10\nAlso take note of this, take into consideration 32-bit and 64-bit version of the operating systems when use windows 7 32-bit to compile your executable and want to use it in windows 7 64-bit operating system version it won't work and vice versa.\nSo when you compile in windows7 32-bit version it will work on only 32-bit version of operating systems and not on 64-bit version of windows operating system and vice versa","Q_Score":0,"Tags":"python,python-2.7,tkinter,exe,pyinstaller","A_Id":49554853,"CreationDate":"2018-03-29T08:47:00.000","Title":"Tkinter python script converted to exe using pyinstaller on Windows 10 not working on Windows7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just started learning Python, Pandas and NumPy and I want to find out what is the cleanest and most efficient way to solve the following problem.\nI have data which holds CarManufacturer, Car, TotalCarSales, bearing in mind that the data is not small:\nCarManufacturer Car TotalCarSales\nVolkswagen Polo 100 \nVolkswagen Golf 50 \nHonda Jazz 40 \nHonda Civic 100\nQuestion:\nWhich manufacturer sold the most cars according to it's top 3 best sellers?\nI'm struggling to solve this efficiently. I want to avoid iterating over the data. \nMy thoughts:\n- Load Data into DataFrame\n- Index data according to CarManufacturer, Car, TotalCarSales\n- Do I want to do a sort here? That would be slow? \n- Create a new DataFrame which has CarManufacturer, TotalSales. For each CarManufacturer I would need to get the top 3 TotalCarSales and take their sum - Is there a way of doing this without iterating over all records in DataFrame? What is best way to fetch the top 3? \n- Then if I sort the TotalSales and take the top 3, wouldn't the sort be slow? Is there a more efficient way?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":49553357,"Users Score":0,"Answer":"The best way to do when you are learning is to try it. \nIt's very unlikely your data will be too large (there aren't millions of car models), but in any case, you can use df.head(N) to take the top N rows to try your method and see if it's slow.\nOther useful functions include df.groupby, df.nlargest, df.sort_values","Q_Score":1,"Tags":"python,python-3.x,pandas","A_Id":49553542,"CreationDate":"2018-03-29T10:09:00.000","Title":"Python Pandas DataFrames Sorting, Summing and Fetching Max Data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"hash() method in python can match all immutable objects to unique hash value. However, I cannot understand the behavior of hash() method for objects of user-defined classes. Some of the resources say that if user-defined class do not contain __hash__() and __eq__() methods, that object cannot be hashed. On the other hand, the others claim the opposite one. \nIn other words, what is the role of __eq__() and __hash__() methods in order to hash custom objects ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":503,"Q_Id":49553652,"Users Score":0,"Answer":"Basically, 'hash' should be quick, and act as a \"triage\" calculation to know if two objects are equal or not.\nThe 'eq' should precisely be the function that tells if the objects are definitely \n equal or not. Maybe this funciton has to perform a lot of checks ( for instance if you want to define the equality of your objects by the equality of all the member fields, and maybe there is are a lot of them)\nThe purpose of these two functions is to have a quick way of saying \"no, they are not equal\" (the hash function), since the comparisons are often used a lot, and most often two objects are not supposed to be \"equals\".\nInstead of executing a lot of \"eq\" functions, you execute a lot of quick \"hash\" functions, and if both the hashes match, you execute \"eq\" to confirm the equality or not.","Q_Score":2,"Tags":"python,hash","A_Id":49554420,"CreationDate":"2018-03-29T10:23:00.000","Title":"Hashing Custom Objects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to connect to MSSQL database from AWS Lambda (using python) and really struggling to proceed further.\nI tried many options with pyodbc, pypyodbc, pymssql they work on local development machine (Windows 7), however AWS Lambda is unable to find the required packages when deployed on AWS. I use ZAPPA for deployment of Lambda package.\nI searched through many forums but unable to see the anything moving ahead, any help on this would be highly appreciated.\nMany thanks,\nAkshay","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2801,"Q_Id":49556382,"Users Score":1,"Answer":"Try to do import cython together with pymssql in your code.","Q_Score":5,"Tags":"python,sql-server,amazon-web-services,aws-lambda","A_Id":70156360,"CreationDate":"2018-03-29T12:42:00.000","Title":"Use MSSQL with AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How can I automatically run a python script, whenever a Word-File is added to a specific folder? This python script would need to work with the Word-File afterwards. My operating system is Windows.\nThanks for your help in advance.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19739,"Q_Id":49557421,"Users Score":0,"Answer":"you can use watchdog, and create your own eventHandler, like, overwriting original functions inside filesystemeventhandler, by creating a class using filesystemeventhandler(class MyHandler(fileSystemEventHandler):), you can change on_any_event or on_created_ or on_modified.","Q_Score":6,"Tags":"python,windows,directory","A_Id":66431678,"CreationDate":"2018-03-29T13:31:00.000","Title":"How to automatically run python script, when file is added to folder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I used to configure the application name in app.yaml. But I just re-read the latest docs, and they say:\n\nThe recommended approach is to remove the application element from your app.yaml file and instead, use a command-line flag to specify your application ID:\nTo use the gcloud app deploy command, you must specify the --project flag:\ngcloud app deploy --project [YOUR_PROJECT_ID]\nTo use the appcfg.py update command, you specify the -A flag:\nappcfg.py update -A [YOUR_PROJECT_ID]\n\nBut what about dev_appserver.py? How do I configure it with the project name?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":162,"Q_Id":49558119,"Users Score":3,"Answer":"dev_appserver.py also supports the -A flag to set the application id.\nFrom the output for dev_appserver.py -h:\n\n-A APP_ID, --application APP_ID\n                          Set the application, overriding the application value\n                          from the app.yaml file. (default: None)","Q_Score":3,"Tags":"google-app-engine,google-app-engine-python","A_Id":49559800,"CreationDate":"2018-03-29T14:02:00.000","Title":"How to configure application name when running dev_appserver.py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"In cases where I need to cancel an order, I need to know whether to void or refund the transaction.  I'm trying to learn whether the transaction has settled using the Transaction Details API. \ntransactionDetailsResponse.transaction.transactionStatus seems like it might be the right thing to look at. Does anyone know what the possible values are for transactionStatus.  At this point, I'm only in the sandbox where there is only one value, capturedPendingSettlement.\nDo transaction in the sandbox settle?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":49558617,"Users Score":0,"Answer":"That is the right place to look. The possible values for that field are:\n\nuthorizedPendingCapture\ncapturedPendingSettlement\ncommunicationError\nrefundSettledSuccessfully\nrefundPendingSettlement\napprovedReview\ndeclined\ncouldNotVoid\nexpired\ngeneralError\nfailedReview\nsettledSuccessfully\nsettlementError\nunderReview\nvoided\nFDSPendingReview\nFDSAuthorizedPendingReview\nreturnedItem\n\nItems in the sandbox do settle.","Q_Score":0,"Tags":"python,authorize.net","A_Id":49566293,"CreationDate":"2018-03-29T14:25:00.000","Title":"How can I tell if an authorize.net transaction has settled?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get PyHive working on a Windows 10 (64-bit) machine with Python 2.7.14.\nThe machine is secured to the point of it not having Internet access, but I can push files to it.\nI have pushed PyHive-0.5.1, future-0.9.0, and thrift-0.11.0 (.tar.gz files) to the machine, and run \"python setup.py build\" and \"python setup.py install\" on each of them.\nWhen I try a small test program that just tries to \"from pyhive import hive\" I get \"ImportError: No module named builtins\".\nUpgrading to Python 3 is not a viable option in this case.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":560,"Q_Id":49558930,"Users Score":0,"Answer":"I found a newer version of future, future-0.16.0 which seems to have resolved the issue.","Q_Score":1,"Tags":"python,python-2.7,hive,pyhive","A_Id":49561605,"CreationDate":"2018-03-29T14:40:00.000","Title":"ImportError: No module named builtins with PyHive using Python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to add a data augmentation on the WiderFace dataset and I would like to know, how is it possible to random crop an image and only keep the bouding box of faces with the center inside the crop using tensorflow ?\nI have already try to implement a solution but I use TFRecords and the TfExampleDecoder and the shape of the input image is set to [None, None, 3] during the process, so no way to get the shape of the image and do it by myself.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":972,"Q_Id":49560347,"Users Score":0,"Answer":"You can get the shape, but only at runtime - when you call sess.run and actually pass in the data - that's when the shape is actually defined.\nSo do the random crop manually in tesorflow, basically, you want to reimplement tf.random_crop so you can handle the manipulations to the bounding boxes.\nFirst, to get the shape, x = your_tensor.shape[0] will give you the first dimension. It will appear as None until you actually call sess.run, then it will resolve to the appropriate value. Now you can compute some random crop parameters using tf.random_uniform or whatever method you like. Lastly you perform the crop with tf.slice.\nIf you want to choose whether to perform the crop or not you can use tf.cond.\nBetween those components, you should be able to implement what you want using only tensorflow constructs. Try it out and if you get stuck along the way post the code and error you run into.","Q_Score":1,"Tags":"python,tensorflow","A_Id":49565369,"CreationDate":"2018-03-29T15:54:00.000","Title":"Random crop and bounding boxes in tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing a chatbot using heroku and python. I have a file fetchWelcome.py in which I have written a function. I need to import the function from fetchWelcome into my main file. \nI wrote \"from fetchWelcome import fetchWelcome\" in main file. But because we need to mention all the dependencies in the requirement file, it shows error. I don't know how to mention user defined requirement.\nHow can I import the function from another file into the main file ? Both the files ( main.py and fetchWelcome.py ) are in the same folder.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":694,"Q_Id":49561062,"Users Score":0,"Answer":"If we need to import function from fileName into main.py, write \"from .fileName import functionName\". Thus we don't need to write any dependency in requirement file.","Q_Score":0,"Tags":"python,heroku","A_Id":49571369,"CreationDate":"2018-03-29T16:33:00.000","Title":"Heroku Python import local functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I understand how random state is used to randomly split data into training and test set. As Expected, my algorithm gives different accuracy each time I change it. Now I have to submit a report in my university and I am unable to understand the final accuracy to mention there. Should I choose the maximum accuracy I get? Or should I run it with different RandomStates and then take its average? Or something else?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5696,"Q_Id":49561882,"Users Score":1,"Answer":"For me personally, I set random_state to a specific number (usually 42) so if I see variation in my programs accuracy I know it was not caused by how the data was split.\nHowever, this can lead to my network over fitting on that specific split.  I.E. I tune my network so it works well with that split, but not necessarily on a different split.  Because of this, I think it's best to use a random seed when you submit your code so the reviewer knows you haven't over fit to that particular state.\nTo do this with sklearn.train_test_split you can simply not provide a random_state and it will pick one randomly using np.random.","Q_Score":5,"Tags":"python,pandas,machine-learning,scikit-learn,svm","A_Id":49562017,"CreationDate":"2018-03-29T17:21:00.000","Title":"How to choose RandomState in train_test_split?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that I can find the square root of an expression using math.sqrt(x).\nI also know that I can find the square root using x**0.5.\nBut why both? Isn't this non-pythonic? What is the use of math.sqrt() when we can just raise it to the 0.5th power?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1306,"Q_Id":49561965,"Users Score":0,"Answer":"I wouldn't think too much about this. sqrt is just a simplification if raising to 1\/2; some python programmers may not know this and it's more idiomatic in my eyes.","Q_Score":3,"Tags":"python,math,square-root","A_Id":49562085,"CreationDate":"2018-03-29T17:27:00.000","Title":"Use Of The Square Root Function From The Math Module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Beam 2.3.0, the DoFn process API needed to return a generator through yield while in Beam 2.4.0, returning an object like dictionary from the process API works fine. \nIs there a change in programming model from 2.3.0 to 2.4.0 ? For large scale Google Cloud Dataflow processing, is yield (generator) preferred over returning objects (list, dict) from the DoFn process API ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2370,"Q_Id":49562470,"Users Score":2,"Answer":"My understanding is that you want to return an iterable. So if you return a dictionary, the output will really be the list of its keys. I stick with only using yield for simplicity.","Q_Score":2,"Tags":"python,google-cloud-dataflow,apache-beam","A_Id":49582755,"CreationDate":"2018-03-29T18:01:00.000","Title":"DoFn process return type","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I want to create a simple scheduler in Tornado, where along the course of the app, some job with a (time,callback) is generated dynamically, for example,\nSend a push notification 30 mins before an event, \nbut this reminder is created only after the job is created by the server, which may be through a POST request.\nI wanted to achieve this through PeriodicCallback, but I read that IOLoop.start() must be called after the PeriodicCallback is created. How can I add PeriodicCallback to already running IOLoop or is there any other way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":157,"Q_Id":49563653,"Users Score":1,"Answer":"There is no requirement that PeriodicCallbacks be started before the IOLoop. You can start them while the IOLoop is running. You have to schedule something before calling IOLoop.start() since that will run forever, but whatever you schedule on the IOLoop can go on to schedule other stuff.","Q_Score":1,"Tags":"python,tornado","A_Id":49568140,"CreationDate":"2018-03-29T19:24:00.000","Title":"Adding PeriodicCallback to already running IOLoop instance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to import dask.distributed package, but I keep getting this error: ImportError: cannot import name 'collections_to_dsk'. Help is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":311,"Q_Id":49564542,"Users Score":0,"Answer":"I resolved the error, there were some outdated packages including imageio which needed upgrade to work with dask.distributed and dask.dataframe.","Q_Score":1,"Tags":"python-3.x,importerror,dask-distributed","A_Id":49571075,"CreationDate":"2018-03-29T20:31:00.000","Title":"ImportError with dask.distributed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a virtual enviroment using virtualenv command with a standard procedure. Now, when I activate it or deactivate, the output of which pip or which python gives me same output \/usr\/local\/bin\/pip. However there is copies of python and pip commands in my vitrual enviroment directory - I have found them there. What might be the problem?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1558,"Q_Id":49567494,"Users Score":2,"Answer":"I think it happen when I moved the environment folder to a different location.\nI solved it by reinstalling virtualenv and creating a new environment","Q_Score":8,"Tags":"python,virtualenv","A_Id":57704304,"CreationDate":"2018-03-30T02:06:00.000","Title":"Activating python virtual environment does not switch to local versions of pip and python commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a virtual enviroment using virtualenv command with a standard procedure. Now, when I activate it or deactivate, the output of which pip or which python gives me same output \/usr\/local\/bin\/pip. However there is copies of python and pip commands in my vitrual enviroment directory - I have found them there. What might be the problem?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1558,"Q_Id":49567494,"Users Score":7,"Answer":"Did you move the virtual environment folder to a different name? The original path to the virtual environment is written into the generated activate script so if you move the environment activate will set your path to the old path of the virtual environment.\nTo fix this run virtualenv --relocatable $YOUR_VIRTUALENV_PATH then modify the VIRTUAL_ENV variable in the activate script to point to your new location.","Q_Score":8,"Tags":"python,virtualenv","A_Id":49567773,"CreationDate":"2018-03-30T02:06:00.000","Title":"Activating python virtual environment does not switch to local versions of pip and python commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Afternoon,\nI recently came across AWS Lambda and Azure Functions. AWS imposes a limit on the size of zipped as well as unzipped files, which for python scripts need to include all of the dependent modules. I have been using lambda-uploader to package my script and it's module dependencies, but the pandas package is too big.\nI have seen examples of people completing machine learning and using pandas on AWS Lambda (a little outdated though) but I can't see how they're doing it. Any suggestions?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":12267,"Q_Id":49567804,"Users Score":2,"Answer":"If you're using Python libraries, you can get rid of botocore, boto3 as they are already present in AWS's lambdas functions.","Q_Score":12,"Tags":"python,amazon-web-services,aws-lambda","A_Id":57400673,"CreationDate":"2018-03-30T02:57:00.000","Title":"How to reduce the size of packaged python zip files for 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently submitting my U-SQL jobs via the Python library and I want to add additional code in a C# or Python code-behind file. Are code-behind files supported, either in python or in a CLI-based method that I could easily automate? \nIdeally I'd like to use the Azure CLI or the Python library so this can run on both Linux and Windows (i.e. not relying on Visual Studio). I've check the documentation for both PowerShell and Python, but I don't see any instructions on how to submit jobs with code-behind logic.\nHere is my python code:\n\nfrom azure.mgmt.datalake.analytics.job import DataLakeAnalyticsJobManagementClient\n\nadlaJobClient = get_client_from_cli_profile(\n    DataLakeAnalyticsJobManagementClient,\n    adla_job_dns_suffix='azuredatalakeanalytics.net')\n\ndef submit_usql_job(script):\n    job_id = str(uuid.uuid4())\n    job_result = adlaJobClient.job.create(\n        ADLA_ACCOUNT_NAME,\n        job_id,\n        JobInformation(\n            name='Sample Job',\n            type='USql',\n            properties=USqlJobProperties(script=script)\n        )\n    )\n    print(\"Submitted job ID '{}'\".format(job_id))\n    return job_id","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":312,"Q_Id":49568032,"Users Score":1,"Answer":"Likely you're going to have to manage creating and registering the assembly yourself as an additional step in your job. Then reference the assembly as you normally would. If you need an example of what this might look like, submit a job from Visual Studio, for a query that has an accompanying code-behind file, and look at the script that it generates for you. You'll see that it is adding the above steps for you, transparently. Now, you can try applying this same approach\/pattern in your own code. \nEither that or move your code-behind logic to a dedicated library which you can upload and register separately, one-time, then reference it to your heart's content from your python-submitted jobs.","Q_Score":0,"Tags":"python,azure,azure-data-lake,u-sql","A_Id":49577265,"CreationDate":"2018-03-30T03:35:00.000","Title":"Programmatically submit a U-SQL job with code-behind","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am new to pytest and currently testing out different functionality. \nI currently have a testcase where I test out an endpoint, get a response, and this response has to be used in another test case to another endpoint, of which the result will be sued in a third testcase. \nIn a regular python script, this would be very simple (easy error handling as well).\nIs it possible to daisy chain test cases using pytest AND pass results (possibly as variables) from one test to the other?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1857,"Q_Id":49568232,"Users Score":0,"Answer":"That's bad practice. You do not want tests to be dependent.","Q_Score":1,"Tags":"python,pytest","A_Id":51505094,"CreationDate":"2018-03-30T04:09:00.000","Title":"How can I pass the result of one pytest to another pytest","Data Science and Machine Learning":0,"Database and SQL":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 Linear Programming(LP) optmisation to solve and I'd like to use GLPK solver. Anyone knows if I can use python to call GLPK? I mean, I can build my program and send to the solver only unsing python without using the interfaces Pyomo or PuLp OR pYglpk? Their sintaxe looks like a little differente from the python sintaxe and I don't know if I will be able to handle it. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":684,"Q_Id":49568373,"Users Score":0,"Answer":"I am not sure if it works with GLPK, but I know that it is possible with Gurobi. I mean then you should adapt your model in Gurobi modeling syntax. Maybe you should search for \"GLPK modelling\" on google? \nBut to be honest, either way you will have to read its documentation and spend time on learning its lib. Pyomo has a better(in my opinion) documentation and better support than any modeling language in python. So better read pyomo doc. and check its basic examples and ask questions here if you encounter with an error. They got a nice developer team here, who answers most of the hard questions.","Q_Score":1,"Tags":"python,glpk","A_Id":49618141,"CreationDate":"2018-03-30T04:28:00.000","Title":"GLPK in python. The interface Pyomo, PuLP or PyGLPK are mandatory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a problem in which I have to predict whether a sent email from a company is opened or not and if it is opened, I have to predict whether the recipient clicked on the given link or not.\nI have a data set with the following features:\n\nTotal links inside the emai`\nTotal internal links inside the\nemail \nNumber of images inside the email \nNumber of sections\ninside the email \nEmail_body \nEmail Subject\n\nFor the email body and subject I can use a CountVectorizer but how can I include my other feature to that sparse matrix created by said CountVectorizer.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":49570046,"Users Score":0,"Answer":"You could easily just concatenate these matrices and other feature columns to build one very large matrix.\nHowever, be aware that concatenating the matrix from email body and email subject will probably create an incredibly sparse matrix. When you then add other features you might risk to \"water down\" your other features. This depends mostly on the algorithm you choose to use for your prediction. \nIn all cases you would benefit from reducing the dimensionality of the two matrices for email subject and body or directly use a different approach than CountVectorizer - for example TFIDF.","Q_Score":0,"Tags":"python,tf-idf,text-classification,countvectorizer,tfidfvectorizer","A_Id":49902116,"CreationDate":"2018-03-30T07:13:00.000","Title":"CountVectorizer in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a problem in which I have to predict whether a sent email from a company is opened or not and if it is opened, I have to predict whether the recipient clicked on the given link or not.\nI have a data set with the following features:\n\nTotal links inside the emai`\nTotal internal links inside the\nemail \nNumber of images inside the email \nNumber of sections\ninside the email \nEmail_body \nEmail Subject\n\nFor the email body and subject I can use a CountVectorizer but how can I include my other feature to that sparse matrix created by said CountVectorizer.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":49570046,"Users Score":0,"Answer":"Your problem is you have two large sparse feature vectors (email body and subject) and also small dense feature vectors. Here is my simple suggestion:\n\n(Jerome's idea) Reduce the dimension of email body and subject (via PCA, AutoEncoder, CBOW, Doc2Vec, PLSA, or LDA) so that you will end up with a dense feature vector. Then, concatenate it with other meta information.\nI think concatenating the matrix with other features are okay. If you use a simple linear model, you can put more weights on meta information and scale down all weights learned from subject and body of the emails.\n\nThe real problem is when you use a bag-of-word representation (either term-frequency or TFIDF), your feature vector will be extremely sparse for a very short email. The model might not perform well.\nBy the way, I think the author information could be a good indicator whether the email will be opened or not.","Q_Score":0,"Tags":"python,tf-idf,text-classification,countvectorizer,tfidfvectorizer","A_Id":49936932,"CreationDate":"2018-03-30T07:13:00.000","Title":"CountVectorizer in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python function (using the Pythonista app) to show an image in the console. I have the image saved in a BytesIO object but the function requires a file path.\nIs there any way to give it a path to the bytesIO or somehow give it the image without needing to save it as a file?\nThe specific function is console.show_image(image_path)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":245,"Q_Id":49570299,"Users Score":1,"Answer":"The general answer is that if the function you call expects a filesystem path and cannot handle a file-like object instead then your only solution is to write your data to a file (and ask the function's author to add support for file-like object, or if it's OSS implement it by yourself and send a merge request).","Q_Score":0,"Tags":"python,file,pythonista","A_Id":49570784,"CreationDate":"2018-03-30T07:32:00.000","Title":"Python function requires path but I have an image stored in memory","Data 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 app that uses websockets and gevent. It's quite a big application in my personal experience.\nI've encountered a problem with it: when I run it on Windows (with 'pipenv run python myapp'), it can (suddenly but very rarily) freeze, and stop accepting messages. If I then enter CTRL+C in cmd, it starts reacting to all the messages, that were issued when it was hanging.\nI understand, that it might block somewhere, but I don't know how to debug theses types of errors, because I don't see anything in the code, that could do it. And it happens very rarily on completely different stages of the application's runtime.\nWhat is the best way to debug it? And to actually see what goes behind the scenes? My logs show no indication of a problem.\nCould it be an error with cmd and not my app?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":453,"Q_Id":49572547,"Users Score":0,"Answer":"Your answer may be as simple as adding timeouts to some of your spawns or gevent calls.  Gevent is still single threaded, and so if an IO bound resource hangs, it can't context switch until it's been received.  Setting a timeout might help bypass these issues and move your app forward?","Q_Score":0,"Tags":"python,websocket,gevent","A_Id":49618957,"CreationDate":"2018-03-30T10:14:00.000","Title":"Python application freezes, only CTRL-C helps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am writing a sql query using pandas within python. In the where clause I need to compare a date column (say review date 2016-10-21) with this value '2016Q4'. In other words if the review dates fall in or after Q4 in 2016 then they will be selected. Now how do I convert the review date to something comparable to 'yyyyQ4' format. Is there any python function for that ? If not, how so I go about writing one for this purpose ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":798,"Q_Id":49576487,"Users Score":1,"Answer":"Once you are able to get the month out into a variable: mon\nyou can use the following code to get the quarter information:\nfor mon in range(1, 13):\n  print (mon-1)\/\/3 + 1,\nprint\nwhich would return: \n\nfor months 1 - 3    : 1\nfor months 4 - 6    : 2\nfor months 7 - 9    : 3\nfor months 10 - 12  : 4","Q_Score":1,"Tags":"sql,python-3.x,pandas","A_Id":49577047,"CreationDate":"2018-03-30T14:45:00.000","Title":"How to compare date (yyyy-mm-dd) with year-Quarter (yyyyQQ) in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have millions of images, and I am able to use OCR with pytesseract to perform descent text extraction, but it takes too long to process all of the images.  \nThus I would like to determine if an image simply contains text or not, and if it doesn't, i wouldn't have to perform OCR on it. Ideally this method would have a high recall. \nI was thinking about building a SVM or some machine learning model to help detect, but I was hoping if anyone new of a method to quickly determine if an object contains text or not.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":285,"Q_Id":49576528,"Users Score":2,"Answer":"Unfortunately there is no way to tell if an image has text in it, without performing OCR of some kind on it.\nYou could build a machine learning model that handles this, however keep in mind it would still need to process the image as well.","Q_Score":0,"Tags":"python,classification,ocr,tesseract,text-extraction","A_Id":49577580,"CreationDate":"2018-03-30T14:47:00.000","Title":"Quick way to classify if an image contains text or not","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 new to superset.\nGoing to Sources > Databases for a new connection to my athena.\nI have downloaded JDBC driver and writing following connection line:\n\nawsathena+jdbc:\/\/AKIAJ2PKWTZYAPBYKRMQ:xxxxxxxxxxxxxxx@athena.us-east-1.amazonaws.com:443\/default?s3_staging_dir='s3:\/\/aws-athena-query-results-831083831535-us-east-1\/' as SQLAlchemy URI. First parameter being access key and 2nd being secret key(Modified a bit for privacy)\n\nI am getting error as:\nERROR: {\"error\": \"Connection failed!\\n\\nThe error message returned was:\\nCan't load plugin: sqlalchemy.dialects:awsathena.jdbc\"}\nWould be very thankful for support as I really wish to explore the open source visualisation using superset on my databases.\nThanks,\nRavi","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2417,"Q_Id":49578829,"Users Score":1,"Answer":"If you are sure you have done pip install \"PyAthenaJDBC>1.0.9\" in the same python environment as you start your superset. Try restarting Superset in the same environment.","Q_Score":2,"Tags":"python,sqlalchemy,amazon-athena,superset,apache-superset","A_Id":51992746,"CreationDate":"2018-03-30T17:36:00.000","Title":"Cant connect to superset using athena database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement an objective function that minimize the overlap of 2 irregular shaped 3d objects. While the most accurate measurement of the overlap is the intersection volume, it's too computationally expensive as I am dealing with complex objects with 1000+ faces and are not convex.\nI am wondering if there are other measurements of intersection between 3d objects that are much faster to compute? 2 requirements for the measurement are: 1. When the measurement is 0, there should be no overlap; 2. The measurement should be a scalar(not a boolean value) indicating the degree of overlapping, but this value doesn't need to be very accurate.\nPossible measurements I am considering include some sort of 2D surface area of intersection, or 1D penetration depth. Alternatively I can estimate volume with a sample based method that sample points inside one object and test the percentage of points that exist in another object. But I don't know how computational expensive it is to sample points inside a complex 3d shape as well as to test if a point is enclosed by such a shape.\nI will really appreciate any advices, codes, or equations on this matter. Also if you can suggest any libraries (preferably python library) that accept .obj, .ply...etc files and perform 3D geometry computation that will be great! I will also post here if I find out a good method.\nUpdate:\nI found a good python library called Trimesh that performs all the computations mentioned by me and others in this post. It computes the exact intersection volume with the Blender backend; it can voxelize meshes and compute the volume of the co-occupied voxels; it can also perform surface and volumetric points sampling within one mesh and test points containment within another mesh. I found surface point sampling and containment testing(sort of surface intersection) and the grid approach to be the fastest.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1361,"Q_Id":49584153,"Users Score":0,"Answer":"A sample-based approach is what I'd try first. Generate a bunch of points in the unioned bounding AABB, and divide the number of points in A and B by the number of points in A or B. (You can adapt this measure to your use case -- it doesn't work very well when A and B have very different volumes.) To check whether a given point is in a given volume, use a crossing number test, which Google. There are acceleration structures that can help with this test, but my guess is that the number of samples that'll give you reasonable accuracy is lower than the number of samples necessary to benefit overall from building the acceleration structure.\nAs a variant of this, you can check line intersection instead of point intersection: Generate a random (axis-aligned, for efficiency) line, and measure how much of it is contained in A, in B, and in both A and B. This requires more bookkeeping than point-in-polyhedron, but will give you better per-sample information and thus reduce the number of times you end up iterating through all the faces.","Q_Score":3,"Tags":"python,3d,computational-geometry,bin-packing","A_Id":49597211,"CreationDate":"2018-03-31T04:10:00.000","Title":"Measurement for intersection of 2 irregular shaped 3d object","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 implement an objective function that minimize the overlap of 2 irregular shaped 3d objects. While the most accurate measurement of the overlap is the intersection volume, it's too computationally expensive as I am dealing with complex objects with 1000+ faces and are not convex.\nI am wondering if there are other measurements of intersection between 3d objects that are much faster to compute? 2 requirements for the measurement are: 1. When the measurement is 0, there should be no overlap; 2. The measurement should be a scalar(not a boolean value) indicating the degree of overlapping, but this value doesn't need to be very accurate.\nPossible measurements I am considering include some sort of 2D surface area of intersection, or 1D penetration depth. Alternatively I can estimate volume with a sample based method that sample points inside one object and test the percentage of points that exist in another object. But I don't know how computational expensive it is to sample points inside a complex 3d shape as well as to test if a point is enclosed by such a shape.\nI will really appreciate any advices, codes, or equations on this matter. Also if you can suggest any libraries (preferably python library) that accept .obj, .ply...etc files and perform 3D geometry computation that will be great! I will also post here if I find out a good method.\nUpdate:\nI found a good python library called Trimesh that performs all the computations mentioned by me and others in this post. It computes the exact intersection volume with the Blender backend; it can voxelize meshes and compute the volume of the co-occupied voxels; it can also perform surface and volumetric points sampling within one mesh and test points containment within another mesh. I found surface point sampling and containment testing(sort of surface intersection) and the grid approach to be the fastest.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1361,"Q_Id":49584153,"Users Score":0,"Answer":"By straight voxelization:\nIf the faces are of similar size (if needed triangulate the large ones), you can use a gridding approach: define a regular 3D grid with a spacing size larger than the longest edge and store one bit per voxel.\nThen for every vertex of the mesh, set the bit of the cell it is included in (this just takes a truncation of the coordinates). By doing this, you will obtain the boundary of the object as a connected surface. You will obtain an estimate of the volume by means of a 3D flood filling algorithm, either from an inside or an outside pixel. (Outside will be easier but be sure to leave a one voxel margin around the object.)\nEstimating the volumes of both objects as well as intersection or union is straightforward with this machinery. The cost will depend on the number of faces and the number of voxels.","Q_Score":3,"Tags":"python,3d,computational-geometry,bin-packing","A_Id":49688037,"CreationDate":"2018-03-31T04:10:00.000","Title":"Measurement for intersection of 2 irregular shaped 3d object","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":"Like Spyder, you can execute code block. how can i do in Pycharm in science mode. in spyder you use \n# In[] \nHow can i do this in pycharm","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":94,"Q_Id":49585758,"Users Score":1,"Answer":"you can just import numpy to actvate science mode.\nimport numpy as np","Q_Score":1,"Tags":"python,machine-learning,pycharm","A_Id":49585883,"CreationDate":"2018-03-31T08:19:00.000","Title":"How executed code block Science mode in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Like Spyder, you can execute code block. how can i do in Pycharm in science mode. in spyder you use \n# In[] \nHow can i do this in pycharm","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":94,"Q_Id":49585758,"Users Score":1,"Answer":"pycharm use code cell. you can do with this\n'#%% '","Q_Score":1,"Tags":"python,machine-learning,pycharm","A_Id":49585817,"CreationDate":"2018-03-31T08:19:00.000","Title":"How executed code block Science mode in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In mininet-wifi examples, I found a sample (6LowPAN.py) that creates a simple topology contains 3 nodes.\nNow, I intend to create another topology as follows:\n\n1- Two groups of sensor nodes such that each group connects to a 'Sink\n  node' \n2- Connect each 'Sink node' to an 'ovSwitch' \n3- Connect the two switches to a 'Controller'\n\nIs that doable using mininet-wifi? Any tips how to do it??\nMany thanks in advance :)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":444,"Q_Id":49586831,"Users Score":1,"Answer":"Yes, you can do this with 6LowPAN.py. You then add switches and controller into the topology with their links.","Q_Score":0,"Tags":"python,emulation,sdn,mininet,openflow","A_Id":49602289,"CreationDate":"2018-03-31T10:41:00.000","Title":"Building WSN topology integrated with SDN controller (mininet-wifi)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"It is a common practice to normalize input values (to a neural network) to speed up the learning process, especially if features have very large scales.\nIn its theory, normalization is easy to understand. But I wonder how this is done if the training data set is very large, say for 1 million training examples..? If # features per training example is large as well (say, 100 features per training example), 2 problems pop up all of a sudden:\n- It will take some time to normalize all training samples\n- Normalized training examples need to be saved somewhere, so that we need to double the necessary disk space (especially if we do not want to overwrite the original data).\nHow is input normalization solved in practice, especially if the data set is very large?\nOne option maybe is to normalize inputs dynamically in the memory per mini batch while training.. But normalization results will then be changing from one mini batch to another. Would it be tolerable then?\nThere is maybe someone in this platform having hands on experience on this question. I would really appreciate if you could share your experiences.\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1045,"Q_Id":49593985,"Users Score":1,"Answer":"A large number of features makes it easier to parallelize the normalization of the dataset. This is not really an issue. Normalization on large datasets would be easily GPU accelerated, and it would be quite fast. Even for large datasets like you are describing. One of my frameworks that I have written can normalize the entire MNIST dataset in under 10 seconds on a 4-core 4-thread CPU. A GPU could easily do it in under 2 seconds. Computation is not the problem. While for smaller datasets, you can hold the entire normalized dataset in memory, for larger datasets, like you mentioned, you will need to swap out to disk if you normalize the entire dataset. However, if you are doing reasonably large batch sizes, about 128 or higher, your minimums and maximums will not fluctuate that much, depending upon the dataset. This allows you to normalize the mini-batch right before you train the network on it, but again this depends upon the network. I would recommend experimenting based on your datasets, and choosing the best method.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,neural-network,deep-learning","A_Id":49594057,"CreationDate":"2018-04-01T01:28:00.000","Title":"Neural Network - Input Normalization","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed the abcde CD utility but it's complaining that it can't find eyeD3, the Python ID3 program. This appears to be a well-known and unresolved deficiency in the abcde dependencies, and I'm not a Python programmer, so I'm clueless.\nI have the Python 2.7.12 came with Mint 18, and something called python3 (3.5.2). If I try to install eyeD3 with pip (presumably acting against 2.7.12), it says it's already installed (in \/usr\/lib\/python2.7\/dist-packages\/eyeD3). I don't know how to force pip to install under python3.\nIf I do a find \/ -name eyeD3, the only other thing it turns up is \/usr\/share\/pyshared\/eyeD3. But both of those are only directories, and both just contain Python libraries, not executables. \nThere isn't any other file called eyeD3 anywhere on disk.\nDoes anyone know what it's supposed to be called, where it's supposed to live, and how I can install it? \nP","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1262,"Q_Id":49599452,"Users Score":0,"Answer":"Gave up...waste of my time and everyone else's sorry.\nWhat I apparently needed was the eyed3 (lowercase 'd') non-python utility.","Q_Score":2,"Tags":"python,eyed3","A_Id":49675091,"CreationDate":"2018-04-01T15:08:00.000","Title":"Finding the eyeD3 executable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I just installed the abcde CD utility but it's complaining that it can't find eyeD3, the Python ID3 program. This appears to be a well-known and unresolved deficiency in the abcde dependencies, and I'm not a Python programmer, so I'm clueless.\nI have the Python 2.7.12 came with Mint 18, and something called python3 (3.5.2). If I try to install eyeD3 with pip (presumably acting against 2.7.12), it says it's already installed (in \/usr\/lib\/python2.7\/dist-packages\/eyeD3). I don't know how to force pip to install under python3.\nIf I do a find \/ -name eyeD3, the only other thing it turns up is \/usr\/share\/pyshared\/eyeD3. But both of those are only directories, and both just contain Python libraries, not executables. \nThere isn't any other file called eyeD3 anywhere on disk.\nDoes anyone know what it's supposed to be called, where it's supposed to live, and how I can install it? \nP","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1262,"Q_Id":49599452,"Users Score":1,"Answer":"I don't know how to force pip to install under python3.\n\npython3 -m pip install eyeD3 will install it for Python3.","Q_Score":2,"Tags":"python,eyed3","A_Id":49600355,"CreationDate":"2018-04-01T15:08:00.000","Title":"Finding the eyeD3 executable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I am used to typing source activate <environment> when starting a python Anaconda environment. That works just fine. But when I create new conda environments I am seeing the message on Ubuntu 16.04 to start the environments with conda activate instead. Besides the errors about how to set up my shell to use conda activate instead, I am still not clear on what is the difference between source activate ... and conda activate ... Is there a reason to change? Does anyone know the difference between these two commands? Thanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55627,"Q_Id":49600611,"Users Score":0,"Answer":"I am not sure who might find this useful, but if\n\nYour terminal lags due to the addition \">>> conda initialize\n\n\n\n\" in your .bashrc, then you decide to remove it and add anaconda to the path. If that is the case, then \"conda activate env_name\"\nwon't work, but \"source activate env_name\" will work, and then after\nthat, you can use either source activate or conda activate. If you\nclose the shell then to activate the environment again use \"source\nactivate env_name\"\n\n\n\n\nFYI, removing \">>> conda initialize >>>\" from my .bashrc file has\nspeedup my terminal and it doesn't lag anymore and I just default in\nusing \"source activate env_name\"\nI have Ubuntu 20.04, conda version : 4.10.3, and conda-build version\n: 3.21.5","Q_Score":59,"Tags":"python,anaconda,conda","A_Id":70789627,"CreationDate":"2018-04-01T17:14:00.000","Title":"Python Anaconda: should I use `conda activate` or `source activate` in linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In django, is there a way to find which rows were changed during a transaction?\nThere are CDC frameworks out there, however I would like to find the changes of a specific transaction with some sort of an ID. I would also want this to be synchronous with the rest of the runtime code.\nCheers","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":49601575,"Users Score":0,"Answer":"You can try django debug toolbar. There are many option to track requests.\nPretty sure you will find something.","Q_Score":0,"Tags":"python,django,database,transactions","A_Id":49601633,"CreationDate":"2018-04-01T18:57:00.000","Title":"Is there a way to track transaction changes in Django ORM?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Suppose you want to call a method foo on object bar, but somehow while typing the method invocation you intuitively treated foo as a property and you typed bar.foo instead of bar.foo() (with parenthesis). Now, both are syntactically correct, so no error is raised, but semantically very different. It happened to me several times already (my experience in Ruby makes it even worse) and caused me dearly in terms of long and confusing debugging sessions.\nIs there a way to make Python interpreter print a warning in such cases - whenever you access an attribute which is callable, but you haven't actually called it? \nFor the record - I thought about overriding __getattribute__ but it's messy and ultimately won't achieve the goal since function invocation via () happens after __getattribute__ has returned.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":189,"Q_Id":49602872,"Users Score":2,"Answer":"This can't be done in all cases because sometimes you don't want to call the method, e.g. you might want to store it as a callable to be used later, like callback = object.method.\nBut you can use static analysis tools such as pylint or PyCharm (my recommendation) that warn you if you write a statement that looks pointless, e.g. object.method without any assignment.\nFurthermore if you write x = obj.get_x but meant get_x(), then later when you try to use x a static analysis tool may be able to warn you (if you're lucky) that x is a method but an instance of X is expected.","Q_Score":4,"Tags":"python,debugging,methods,warnings,invocation","A_Id":49603081,"CreationDate":"2018-04-01T21:38:00.000","Title":"Python warn if method has not been called","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running my code from the shell(SSH) in google cloud as \n\npython3 mycode.py\n\nIf I close the shell, the computation stops. How can I start a computation and then close the shell(Computation takes a long Time:)).....come back later and see how it is doing. \nMy code keeps printing results after a certain number of iteration.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1024,"Q_Id":49603198,"Users Score":2,"Answer":"Well, in general what you can do is run the code in a way where you can detach from the interactive environment. Using a tool such as screen or tmux. However, Google Cloud Shell is not made for running background tasks, and if i recall correctly, it will terminate after an hour.\nYou might need to provision a virtual machine to run it on instead. I can recommend using tmux. With tmux, it will be as simple as running tmux and then in the new shell running your script python3 mycode.py. You can then detach using ctrl+b d or simply disconnect. When you reconnect you run tmux attach -dto get back to your script.","Q_Score":1,"Tags":"python-3.x,shell,google-cloud-platform,google-compute-engine","A_Id":49603363,"CreationDate":"2018-04-01T22:26:00.000","Title":"Google Cloud Shell scripting 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 am trying to read the dat file using pyspark csv reader and it contains newline character (\"\\n\") as part of the data. Spark is unable to read this file as single column, rather treating it as new row. \nI tried using the \"multiLine\" option while reading , but still its not working. \nspark.read.csv(file_path, schema=schema, sep=delimiter,multiLine=True)\nData is something like this. Here $ is CRLF for newline shown in vim.\n\nname,test,12345,$\n$\n,desc$\nname2,test2,12345,$\n$\n,desc2$\n\nSo pyspark is treating desc as next record. \nHow to read such data in pyspark . \nTried this in both spark2.2 and spark2.3 versions.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":648,"Q_Id":49603834,"Users Score":0,"Answer":"I created my own hadoop Custom Record Reader and was able to read it by invoking the api . \n\nspark.sparkContext.newAPIHadoopFile(file_path,'com.test.multi.reader.CustomFileFormat','org.apache.hadoop.io.LongWritable','org.apache.hadoop.io.Text',conf=conf)\nAnd in the Custom Record Reader implemented the logic to handle the newline characters encountered .","Q_Score":1,"Tags":"python-3.x,apache-spark,pyspark,spark-dataframe","A_Id":50748457,"CreationDate":"2018-04-02T00:11:00.000","Title":"pyspark read csv file multiLine option not working for records which has newline spark2.3 and spark2.2","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a few basic questions about using Numpy with GPU (nvidia GTX 1080 Ti).  I'm new to GPU, and would like to make sure I'm properly using the GPU to accelerate Numpy\/Python.  I searched on the internet for a while, but didn't find a simple tutorial that addressed my questions.  I'd appreciate it if someone can give me some pointers:\n1) Does Numpy\/Python automatically detect the presence of GPU and utilize it to speed up matrix computation (e.g. numpy.multiply, numpy.linalg.inv, ... etc)?  Or do I have code in a specific way to exploit the GPU for fast computation?\n2) Can someone recommend a good tutorial\/introductory material on using Numpy\/Python with GPU (nvidia's)?\nThanks a lot!","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49124,"Q_Id":49605231,"Users Score":50,"Answer":"Does Numpy\/Python automatically detect the presence of GPU and utilize\nit to speed up matrix computation (e.g. numpy.multiply,\nnumpy.linalg.inv, ... etc)?\n\nNo.\n\nOr do I have code in a specific way to exploit the GPU for fast\ncomputation?\n\nYes. Search for Numba, CuPy, Theano, PyTorch or PyCUDA for different paradigms for accelerating Python with GPUs.","Q_Score":52,"Tags":"python,numpy,gpu","A_Id":49605405,"CreationDate":"2018-04-02T04:14:00.000","Title":"Does Numpy automatically detect and use GPU?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I have an array A of dtype int32, and I want to cast it into float64.\nThe standard way to do this (that I know) is A.astype('float64').\nBut this allocates a new array for the result. If I run this command repeatedly (with different arrays of the same shape),  each time using the result and discarding it shortly after, then the overhead from these allocations can be non-negligible.\nSuppose I pre-allocated an array B, with the same shape of A and of type float64. Is there a way to use the memory of B for the result of the casting, instead of allocating new memory each time?\nufuncs and numpy.dot have an 'out' argument for this, but astpye does not.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":49607824,"Users Score":0,"Answer":"As Paul Panzer commented, this can be done simply by B[...] = A.","Q_Score":0,"Tags":"python,numpy","A_Id":49608006,"CreationDate":"2018-04-02T08:27:00.000","Title":"Casting a numpy array into a (different) pre-allocated array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The pygame.movie package is deprecated and I haven't found an alternative to blit a video on a surface (background for example) and blit other objects on the foreground? That's not possible with moviepy etc. Thank you so much!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":49608065,"Users Score":0,"Answer":"There is no such thing, unless if you want to upload every frame of the video as an image and play them frame by frame.","Q_Score":0,"Tags":"python,windows,python-3.x,pygame,pygame-surface","A_Id":49618130,"CreationDate":"2018-04-02T08:46:00.000","Title":"Is there still a possibility to blit a video on a PyGame surface?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to use Celery for:\n\nQueue a HTTP call to external URL with Form parameters (HTTP Post to\nURL)\nThe external URL will respond HTTP response, 200, 404, 400 etc, if\nresponse is in form of error non-200-ish response it will retry for\na certain number of retry and will retire as needed\nAdd Task \/ Job \/ Work queue into Celery using REST API, passing the URL to call and Form parameters","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":7519,"Q_Id":49608179,"Users Score":1,"Answer":"you can use flower rest API to do the same, as flower is a monitoring tool for celery. But it comes with rest api to add task and all\nhttps:\/\/flower.readthedocs.io\/en\/latest\/index.html","Q_Score":4,"Tags":"python,rest,celery","A_Id":58300556,"CreationDate":"2018-04-02T08:53:00.000","Title":"Celery REST API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Django currently has a complete system for routing urls.\nBut I have a very specific situation where I am using django but actually need to use urls like in classic PHP language.\nFor example:\nThe url - localhost\/reader\/theeffort  should take me to a folder called theeffort where I have my files index.html, 1.html, 2.html, 3.html\nand so on!\nNow all these files should be accessible by localhost\/reader\/theeffort\/*.html and not by Django's default url system. Is this possible to achieve that? If yes, how?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":102,"Q_Id":49610673,"Users Score":1,"Answer":"This isn't a thing you would do with Django's URLs. If you just want to serve HTML files within a folder, they are static files; they should therefore be served by the web server itself, eg Apache. You just need to configure an alias in the Apache conf to point to the folder where the static files are.","Q_Score":0,"Tags":"python,php,django,url","A_Id":49611215,"CreationDate":"2018-04-02T11:45:00.000","Title":"Redirect to a folder in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Happy Easter to y'all!\nSo my problem is essentially using SQL timestamp is causing me some issues. I have a Travel Booking website with a database made in PHPmyadmin and as mentioned two timestamp columns (one for departure time and one for arrival.) If there are times currently there for the journey they will be displayed, if not a tick box to set the current time as the timestamp, this i'm fine with. \nI don't know what html form element to use to display the entirety of the SQL timestamp, both the date and time section in the html form (or how to validate any of it xD) I have tried splitting the timestamp and displaying it in both a date and time field but had no luck and was told to stick to the timestamp by my group members. Cheers","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":48,"Q_Id":49612023,"Users Score":1,"Answer":"Solved the problem with some troubleshooting. The formatting difference between datetime-local and timestamp can be solved with some simple regex. \nVariableName = re.sub(r\"\\s+\", 'T', VariableName) \nSwaps any whitespace characters with a T. \nThis is because datetime-local likes to concatenates the date and time together using a capital T. If we simulate this using the regex above we can convert the timestamp into a readable format.","Q_Score":0,"Tags":"python,html,sql","A_Id":49677529,"CreationDate":"2018-04-02T13:14:00.000","Title":"Exchanging Information between HTML Form and SQL Database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wish to use classification metrics like matthews_corrcoef as a metric to a neural network built with CNTK. The way I could find as of now was to evaluate the value by passing the predictions and label as shown\nmatthews_corrcoef(cntk.argmax(y_true, axis=-1).eval(), cntk.argmax(y_pred, axis=-1).eval())\nIdeally I'd like to pass the metric to the trainer object while building my network.\nOne of the ways would be to create own custom metric and pass that to the trainer object. Although possible, it'll be better to be able to reuse the already existing metrics present in other libraries.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":49612908,"Users Score":0,"Answer":"Unless this metric is already implemented in CNTK, implement your own custom \"metric\" function in whatever format CNTK requires, and have it pass the inputs on to scikit-learn's metric function.","Q_Score":1,"Tags":"python,neural-network,cntk","A_Id":49613345,"CreationDate":"2018-04-02T14:12:00.000","Title":"How to use scikit-learn metrics in CNTK?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i use windows and pycharm 3.6\nand for some reason i can't import the csv package to my code.\nit just goes gray\ntried to use pip to install, didn't work.\nif someone can help or otherwise recommend a different package that does the same thing, it would be highly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":993,"Q_Id":49614096,"Users Score":3,"Answer":"Unless csv has a red underline, the grey foreground color simply means you haven't used that module in your project yet. If you mouse over it, it will indicate Unused import statement more...","Q_Score":0,"Tags":"python,pip,pycharm","A_Id":49614199,"CreationDate":"2018-04-02T15:32:00.000","Title":"Installing csv package in pycharm 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is starting to get aggravating. I'm getting the typical  'python' is not recognized as an internal or external command... message when trying to run python on the command line. This is a common issue, and I've found plenty of posts saying to fix it by adding python folder (C:\\Users\\ftake\\Anaconda3) my Windows path (restarted my PC after that) but nothing worked for me. The problem is that I've already Anaconda 1.8.2 installed on my computer and when trying to run python on CMD an error message occurs saying that python is not recognized as an internal...\nI've tried to install pyinstaller (or any other Python packages) using pip, a message occurs too 'pip' is not recognized as an internal or external command...\nEven though when trying to run (on CMD) the following command to create a virtual environment: virtualenv --python=python3.6.3 <env-name>\nI'm using:\nOS: Windows 10 Pro.\nAnaconda Version: 1.8.2","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":40737,"Q_Id":49616399,"Users Score":0,"Answer":"once and for all clarification when you get this python or pip is not recognised error in windows command prompt happens often when multiple IDE installations \nGo to environmental variables then to system variables where you change or add this\nsometimes your anaconda3 path maybe in allusers if you install it as administator so go through the C drive to get that \nexample C:\\Users\\All Users\\anaconda3\nIf not try py -m pip install yourpackage","Q_Score":12,"Tags":"python,pip,anaconda,virtualenv,conda","A_Id":53586478,"CreationDate":"2018-04-02T18:08:00.000","Title":"Windows: Anaconda 'python' is not recognized as an internal or external command on CMD (Updated)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"This is starting to get aggravating. I'm getting the typical  'python' is not recognized as an internal or external command... message when trying to run python on the command line. This is a common issue, and I've found plenty of posts saying to fix it by adding python folder (C:\\Users\\ftake\\Anaconda3) my Windows path (restarted my PC after that) but nothing worked for me. The problem is that I've already Anaconda 1.8.2 installed on my computer and when trying to run python on CMD an error message occurs saying that python is not recognized as an internal...\nI've tried to install pyinstaller (or any other Python packages) using pip, a message occurs too 'pip' is not recognized as an internal or external command...\nEven though when trying to run (on CMD) the following command to create a virtual environment: virtualenv --python=python3.6.3 <env-name>\nI'm using:\nOS: Windows 10 Pro.\nAnaconda Version: 1.8.2","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":40737,"Q_Id":49616399,"Users Score":1,"Answer":"Even i faced the same problem because of python path was not added in environment variable ,follow below steps :\n\nGo to Anaconda prompt type : where python\nsay it is C:\\ProgramFiles\\Anaconda3\\python.exe\nOpen \"Advanced system setting\" from main menu. In environment variable,edit path and add path :    C:\\ProgramFiles\\Anaconda3\nNow in command prompt you see by typing : python --version\n\n& the error \"python' is not recognized as an internal or external command on CMD\" will also go off.","Q_Score":12,"Tags":"python,pip,anaconda,virtualenv,conda","A_Id":55016424,"CreationDate":"2018-04-02T18:08:00.000","Title":"Windows: Anaconda 'python' is not recognized as an internal or external command on CMD (Updated)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm not quite sure this question belong to StackOverflow and not other SE website, but since it's python related I thought it might fit.\nRecently, I started getting error in my IDE (details on my IDE below) - I get an error \"cannot find reference 'path' in 'os.py'\"\nLooking into os.py, I realize that os.path is just an alias for posixpath.py (on Linux) or ntpath.py (on Windows).\nNow, no change has been made to my python installation, and when running scripts that import os.path (or from it), they all run fine, so there is no actual error, just annoying warning in my IDE. I tried changing the project interpreter in the IDE and it didn't work. I also tried running from terminal with the said IDE, and it worked fine. \nCould it be a bug in PyCharm? \nI looked online and couldn't find bug report or anyone struggling with the same problem. \n\nPyCharm build details:\nPyCharm 2018.1 (Community Edition)\nBuild #PC-181.4203.547, built on March 26, 2018\nJRE: 1.8.0_152-release-1136-b20 amd64\nJVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o\nLinux 4.7.0-0.bpo.1-amd64","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":912,"Q_Id":49617465,"Users Score":3,"Answer":"I suppose it is a bug (or behavior) introduced in the very last version of PyCharm. Indeed, it has been happening to me since the last update I recently installed.\nHowever, I temporary ignored these unresolved references in PyCharm to avoid the annoying and misleading warnings.\nTo do so, if you are importing os.path this way (e.g.):\nfrom os.path import join\nGo to PyCharm preferences -> Editor -> Inspections\nThen, look for \"Unresolved references\" under \"Python\" and add the following entries:\n\nos.path\njoin\n\nHope this helps, \nGiuliano","Q_Score":8,"Tags":"python,linux,pycharm","A_Id":49628737,"CreationDate":"2018-04-02T19:23:00.000","Title":"weird behavior when importing os.path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Trying to take data from a csv like this:\ncol1   col2\neggs   sara\nbacon  john\nham    betty\nThe number of items in each column can vary and may not be the same. Col1 may have 25 and col2 may have 3. Or the reverse, more or less.\nAnd loop through each entry so its output into a text file like this\nbreakfast_1\nbreakfast_item eggs\nperson sara\nbreakfast_2\nbreakfast_item bacon\nperson sara\nbreakfast_3\nbreakfast_item ham\nperson sara\nbreakfast_4\nbreakfast_item eggs\nperson john\nbreakfast_5\nbreakfast_item bacon\nperson john\nbreakfast_6\nbreakfast_item ham\nperson john\nbreakfast_7\nbreakfast_item eggs\nperson betty\nbreakfast_8\nbreakfast_item bacon\nperson betty\nbreakfast_9\nbreakfast_item ham\nperson betty\nSo the script would need to add the \"breakfast\" number and loop through each breakfast_item and person.\nI know how to create one combo but not how to pair up each in a loop?\nAny tips on how to do this would be very helpful.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":49619655,"Users Score":0,"Answer":"First, get a distinct of all breakfast items.\nA pseudo code like below \nIterate through each line\nCollect item and person in 2 different lists\nDo a set on those 2 lists\nSay persons, items\n\nCounter = 1\nfor  person in persons:\n  for  item in items:\n    Print \"breafastitem\", Counter\n    Print person, item","Q_Score":0,"Tags":"python,csv,text","A_Id":49623125,"CreationDate":"2018-04-02T22:28:00.000","Title":"python pair multiple field entries from csv","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's suppose we have a long script: Foo.pyx\nIf I execute it two times, they are going to run simultaneously.\nHow can I terminate the first one if I execute it two times?\nEdit: terminating the later ones can also work, I just want only one instance to run at any time.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2366,"Q_Id":49620862,"Users Score":1,"Answer":"When the script starts, check if a specific file exists.  A good name choice is myscript.lock, but any name will do.\nIf it exists, the script should exit immediately.  Otherwise create an empty file of that name and proceed with the script.  Then remove the file when the script finishes.","Q_Score":0,"Tags":"python,windows,python-3.x,terminate","A_Id":49620921,"CreationDate":"2018-04-03T01:19:00.000","Title":"How to make only one instance of the same script running at any time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Windows command netsh interface show interface shows all network connections and their names. A name could be Wireless Network Connection, Local Area Network or Ethernet etc.\nI would like to change an IP address with netsh interface ip set address \"Wireless Network Connection\" static 192.168.1.3 255.255.255.0 192.168.1.1 1 with Python script, but I need a network interface name. \nIs it possible to have this information like we can have a hostname with socket.gethostname()? Or I can change an IP address with Python in other way?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2892,"Q_Id":49624485,"Users Score":2,"Answer":"I don't know of a Python netsh API. But it should not be hard to do with a pair of subprocess calls. First issue netsh interface show interface, parse the output you get back, then issue your set address command.\nOr am I missing the point?","Q_Score":0,"Tags":"python,static-ip-address","A_Id":49625033,"CreationDate":"2018-04-03T07:25:00.000","Title":"How to find out Windows network interface name in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to setup virtualemv in python in windows 10 but I am unable to do that I don't know why because I am a beginner. I already install get-pip.py in my python\/tools\/scripts folder and after that, I have also upgraded my virtualemv.\nBut problem is that when I want to run this command I am getting error C:\\Users\\Ravi\\Documents\\Python\\my_virtual_emv>virtualemv emv --no-site-packages\n'virtualemv' is not recognized as an internal or external command,\noperable program or batch file.\nplease help me with that","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":49625742,"Users Score":1,"Answer":"I think it may be a mistake, spelling virtualenv not virtualemv","Q_Score":0,"Tags":"python-3.x","A_Id":49625884,"CreationDate":"2018-04-03T08:43:00.000","Title":"Python Virtualemv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We created a python program with tensorflow in python 3.5. Based on our research python 3.5 and tensorflow are not supported in xp. But if we converted it to an exe file using cx_freeze, will it work?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":169,"Q_Id":49626317,"Users Score":0,"Answer":"The situation won't be any different if you use cx_freeze. There's still the same Python interpreter (just without the interactive shell), and the same libraries (packaged more conveniently), and your scripts (in the form of .pyc files, i.e. Python bytecode). The .exe file you see there just initializes the interpreter (which resides in a dll) and commands it to execute your script.","Q_Score":1,"Tags":"python-3.x,opencv,tensorflow,windows-xp,cx-freeze","A_Id":49666923,"CreationDate":"2018-04-03T09:14:00.000","Title":"Running a standalone exe made from python 3.5 in windows xp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have n and m binary vectors(of length 1500) from set A and B respectively.\nI need a metric that can say how similar (kind of distance metric) all those n vectors and m vectors are.\nThe output should be total_distance_of_n_vectors and total_distance_of_m_vectors.\nAnd if total_distance_of_n_vectors > total_distance_of_m_vectors, it means Set B have more similar vectors than Set A.\nWhich metric should I use? I thought of Jaccard similarity. But I am not able to put it in this context. Should I find the distance of each vector with each other to find the total distance or something else ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1262,"Q_Id":49627823,"Users Score":0,"Answer":"There are two concepts relevant to your question, which you should consider separately.\nSimilarity Measure:\nIndependent of your scoring mechanism, you should find a similarity measure which suits your data best. It can be an Euclidean distance (not suitable for a 1500 dimensional space), a cosine (dot product based) distance, or a Hamiltonian distance (assuming your input features are completely independent, which rarely is the case).\nA lot can go on in your distance function, and you should find one which makes sense for your data.\nScoring Mechanism:\nYou mention total_distance_of_vectors in your question, which probably is not what you want. If n >> m, almost certainly the total sum of distances for n vectors is more than the total distance for m vectors.\nWhat you're looking for is most probably an average of the distances between the members of your sets. Then, depending on weather you want your average to be sensitive to outliers or not, you can go for average of the distances or average of squared distances.\nIf you want to dig deeper, you can also get the mean and variance of the distances within the two sets and compare the distributions.","Q_Score":1,"Tags":"python,machine-learning,similarity,cosine-similarity","A_Id":49630619,"CreationDate":"2018-04-03T10:30:00.000","Title":"Distance metric for n binary vectors","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm reading headfirst python and have just completed the section where I created a module for printing nested list items, I've created the code and the setup file and placed them in a file labeled \"Nester\" that is sitting on my desktop. The book is now asking for me to install this module onto my local copy of Python. The thing is, in the example he is using the mac terminal, and I'm on windows. I tried to google it but I'm still a novice and a lot of the explanations just go over my head. Can someone give me clear thorough guide?.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":888,"Q_Id":49629518,"Users Score":0,"Answer":"On Windows systems, third-party modules (single files containing one or more functions or classes) and third-party packages (a folder [a.k.a. directory] that contains more than one module (and sometimes other folders\/directories) are usually kept in one of two places: c:\\\\Program Files\\\\Python\\\\Lib\\\\site-packages\\\\ and c:\\\\Users\\\\[you]\\\\AppData\\\\Roaming\\\\Python\\\\. \nThe location in Program Files is usually not accessible to normal users, so when PIP installs new modules\/packages on Windows it places them in the user-accessible folder in the Users location indicated above. You have direct access to that, though by default the AppData folder is \"hidden\"--not displayed in the File Explorer list unless you set FE to show hidden items (which is a good thing to do anyway, IMHO). You can put the module you're working on in the AppData\\\\Roaming\\\\Python\\\\ folder.\nYou still need to make sure the folder you put it in is in the PATH environment variable. PATH is a string that tells Windows (and Python) where to look for needed files, in this case the module you're working on. Google \"set windows path\" to find how to check and set your path variable, then just go ahead and put your module in a folder that's listed in your path.\nOf course, since you can add any folder\/directory you want to PATH, you could put your module anywhere you wanted--including leaving it on the Desktop--as long as the location is included in PATH. You could, for instance, have a folder such as Documents\\\\Programming\\\\Python\\\\Lib to put your personal modules in, and use Documents\\\\Programming\\\\Python\\\\Source for your Python programs. You'd just need to include those in the PATH variable. \nFYI: Personally, I don't like the way python is (by default) installed on Windows (because I don't have easy access to c:\\\\Program Files), so I installed Python in a folder off the drive root: c:\\Python36. In this way, I have direct access to the \\\\Lib\\\\site-packages\\\\ folder.","Q_Score":0,"Tags":"python,python-3.x,cmd,module","A_Id":49639764,"CreationDate":"2018-04-03T11:57:00.000","Title":"how do I install my modual onto my local copy of python on windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Queryset.objects.all() return all objects and also,\nQueryset.objects.filter() return all objects too.\nI have two query that use Queryset.objects.filter() and i want to use it for return all objects.\nQuestion: Are both Queryset.objects.all() and Queryset.objects.filter() performance the same?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":8836,"Q_Id":49630802,"Users Score":11,"Answer":"Yes, both will perform the same in a database point of view once you are not passing any arguments on the filter. The filter will execute more processing steps, once it needs to check if you passed arguments or not, but the difference will be very little.\nIn this case, I suppose you should use the all() instead of filter just to make your code more clear about what are you doing.","Q_Score":11,"Tags":"python,django","A_Id":49630961,"CreationDate":"2018-04-03T13:02:00.000","Title":"django objects.all() vs objects.filter()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I've spent some time reading up on logging in python, but cannot find a clean solution to this particular problem.\nI have three separate packages-- two that stand alone and one that is a library used by both. I'm using pip and artifactory to manage that dependency. I've read that the convention for submodule inheriting is to instantiate the loggers using logging.getLogger(__name__), which works great if it's inside the same package. But as soon as it's another package, the module name starts at the beginning again.\nIs there a way to have my library package agnostically inherit the logger config from the package that is calling it?\nI could configure the default root logger, but it's definitely bad practice.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":585,"Q_Id":49631240,"Users Score":0,"Answer":"Is there a way to have my library package agnostically inherit the logger config from the package that is calling it?\n\nNB : I assume you mean \"inherit the logger instance\" - configuration is a totally distinct matter - actually separating loggers instanciation and calls from logging configuration is one of the raison d'\u00eatre of the logging module. \nAnd well, a logger is just another python object. You can pass it explicitely to all callables needed a logger but that's a bit cumbersome. The point is: why would you do such a thing anyway ? If you log something from your lib you certainly want it to be logged by your lib's own logger. As far as I'm concerned I wouldn't want a 3rd part lib to log anything under one of my own loggers.\nIf you perceive this as a problem chances are you're not using logging the right way. As I mentionned above, one of the points of the logging module is to totally separate logger's usage (instanciation and calls) from logging's config (setting up handlers, formatters, levels, propagation etc). Library code is not supposed to do any configuration - it only uses loggers. Configuring the logging is the application code responsability, and can range from merely configuring the root logger to print to sys.stderr to highly sophisticated configuration with different handlers \/ levels per sub-logger, dispatching to different outputs (syslog, emails, sentry etc) according to the level and\/or sub-logger.","Q_Score":0,"Tags":"python,logging,module,pip,package","A_Id":49631724,"CreationDate":"2018-04-03T13:23:00.000","Title":"Python logging inheritance in PIP installed packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently came across this way of slicing a list in Python. I've never seen this one before, so I would like to understand this clearly. \nI have a list [\"Peter\", \"James\", \"Mark\"] and if I slice it using the boolean value False it returns Peter and if I slice using True it returns James, as given below\n\n[\"Peter\", \"James\", \"Mark\"][False] => Peter\n[\"Peter\", \"James\", \"Mark\"][True] => James\n\nI would like to know what happens here and what is this method called as?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1879,"Q_Id":49633222,"Users Score":2,"Answer":"In Python, bool class is derived from of int\nHence True=1 and False=0\nprint (True + True) will give an output 2\nSo on a list ['peter', 'john', 'abhi'][True] returns 2nd element of the list i.e. john","Q_Score":4,"Tags":"python,python-3.x,list,slice","A_Id":49633641,"CreationDate":"2018-04-03T14:59:00.000","Title":"Slicing elements from a Python list using Boolean indexing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"By default django creates a test database when running tests which raises some inconvenience for me:\nThe API that i am writing test for uses a database. When i run the test, a new database is created, some dummy data is being inserted into the test database and a http post request is being sent to the API under test. What happens is that my API under test does not see inserted data.\nWith the problem explained, what are the right solutions \/ best practices for testing APIs with databases ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":49633359,"Users Score":0,"Answer":"I'm assuming you're doing REST service, preferably with Django Rest Framework (DRF). If not, look it up.\nThe correct approach to testing your own API is:\n\nCreate a class which inherits APITestCase.\nCreate a test function in the class, for example: test_my_thing(self):\nUse the django 'reverse' function to generate the URL to your tested API.\nUse self.client.get, self.client.post, self.client.delete and store the response in a variable.\nresponse.json() gives you the response body in a json format\nAssert the response.","Q_Score":1,"Tags":"python,django,python-3.x,unit-testing,python-unittest","A_Id":49633839,"CreationDate":"2018-04-03T15:05:00.000","Title":"Django unittesting different databases for api and for test","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to Appium. \nI want to control my android device via appium without sending any apk to phone.\nI have tried many examples but in each example everyone is pushing an apk and then controlling it using touches and keypress.\nI am not looking for an app testing instead I am looking for an android device testing using resorce id ,name,class or xpath.\nAnd will the procedure remain same for ios also ?\nCan anyone help me in writing a script in python?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1291,"Q_Id":49634265,"Users Score":0,"Answer":"I think the problem is like mine...want to control an android device or emulator with Appium, may be Mayank Shivhare already try to learn culebra and found the fact that....culebra is still not support by python 3 yet (same problem like me that prefer python 3.7 than python 2.7).\nI have the same problem..., what I understood right now is:\n\nAll environment should be set up first\nThe emulator should be run first...before type any code\nthen run Appium to make a gateway with IP and port.\nthe missing link is how to connect an emulator to appium via ip and port that provide by appium server.\nI can detect the emulator element by run 'uiautomatorviewer.bat' from sdk\\tools\\bin folder, the problem is the problem in number 3, is how to send a command to the emulator via appium. so the command to control emulator base on data that given by 'uiautomatorviewer.bat'\n\ncoding is about trial and error, so we need live interaction, to build source code. every developer has a personal interest in build a script or source code. so..to make easier, as beginner, we need live interaction that shows every error in every step our script or to make sure that every line of our script that we type is run smoothly in the android device or emulator.\nThe problem in learn appium is all manual already given finished script...without a really-really basic explanation...in my case, how to connect appium to emulator, send a command from python console, and see the script is work or not...\nwhat I mean is... we need the step by step explanation of script...because every beginner developers need a live 'trial and error' experience to understand how it works...","Q_Score":0,"Tags":"android,python,selenium,appium,android-uiautomator","A_Id":53939927,"CreationDate":"2018-04-03T15:50:00.000","Title":"How to control android device 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":"I want to make a small AI speaker.\nIt looks like Google Home, Apple Homepod.\nI installed the Google Assist SDK on my Ubuntu 16.04.\nI can register an action through gactions.\n$ pushtotalk.py --device-model-id ~\nI can use the Google assistant like this.\nBut the dialogue flow is only on the simulator in the actions on google web page.\nCan I use it like pushtotalk.py and can I use intents in the dialogue flow?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":362,"Q_Id":49634701,"Users Score":0,"Answer":"The Google Assistant SDK is just like using the Google Assistant. If you want, you can invoke and communicate with Dialogflow apps just like on a phone.\npushtotalk.py ... \"Talk to my app\"\npushtotalk.py ... \"Hello\"\nThat will go on as you want. You can also access 3P actions like Number Genie.","Q_Score":0,"Tags":"python,dialogflow-es,google-assistant-sdk","A_Id":49638480,"CreationDate":"2018-04-03T16:14:00.000","Title":"How can i use Google Assistant SDK + Dialogflow by CLI(Command Line Interface)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Or are there specific situations where one is better than the other?\nSo far, all I gathered is that future is only available for >=2.6 or >=3.3.\nThe current code I have is very basic and runs the same on python2 and 3 except for the use of print function calls. However, the code may get more complex over time and I would like to use the right approach for writing python2\/3 compatible code from the beginning.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1243,"Q_Id":49635526,"Users Score":4,"Answer":"The __future__ module is built-in to Python, and is provided to allow programmers to make advance use of feature sets which are not yet regarded as complete. Although some of the features (e.g., from __future__ import print_function) are provided specifically to assist with porting Python 2 programs to Python 3, it is also used to give early access to advance features of any release.\n__future__ is unique, in that some imports such as the print_function can actually change the syntax accepted by the interpreter.\npython-future is a third-party module, one of several to provide compatibility features. You could also take a look at six, though it's now somewhat long in the tooth, and python-modernize. It's quite likely you will find that you need to use both __future__ and future together.\nAnother strategy you may not have considered is to convert your source to Python 2 that can be translated automatically by the 2to3 utility. There is also a lib3to2 that will translate the other way, though I have no experience with it.","Q_Score":1,"Tags":"python,python-3.x,python-2.7,compatibility","A_Id":49635805,"CreationDate":"2018-04-03T17:02:00.000","Title":"Is it preferable to use __future__ or future to write code compatible with python2 and python3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a script that has multiple threads (created with threading.Thread) fetching URLs from a Queue using queue.get_nowait(), and then processing the HTML. I am new to multi-threaded programming, and am having trouble understanding the purpose of the queue.task_done() function.  \nWhen the Queue is empty, it automatically returns the queue.Empty exception. So I don't understand the need for each thread to call the task_done() function. We know that we're done with the queue when its empty, so why do we need to notify it that the worker threads have finished their work (which has nothing to do with the queue, after they've gotten the URL from it)? \nCould someone provide me with a code example (ideally using urllib, file I\/O, or something other than fibonacci numbers and printing \"Hello\") that shows me how this function would be used in practical applications?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":26152,"Q_Id":49637086,"Users Score":54,"Answer":"Queue.task_done is not there for the workers' benefit. It is there to support Queue.join.\n\nIf I give you a box of work assignments, do I care about when you've taken everything out of the box?\nNo. I care about when the work is done. Looking at an empty box doesn't tell me that. You and 5 other guys might still be working on stuff you took out of the box.\nQueue.task_done lets workers say when a task is done. Someone waiting for all the work to be done with Queue.join will wait until enough task_done calls have been made, not when the queue is empty.\n\neigenfield points out in the comments that it seems really weird for a queue to have task_done\/join methods. That's true, but it's really a naming problem. The queue module has bad name choices that make it sound like a general-purpose queue library, when it's really a thread communication library.\nIt'd be weird for a general-purpose queue to have task_done\/join methods, but it's entirely reasonable for an inter-thread message channel to have a way to indicate that messages have been processed. If the class was called thread_communication.MessageChannel instead of queue.Queue and task_done was called message_processed, the intent would be a lot clearer.\n(If you need a general-purpose queue rather than an inter-thread message channel, use collections.deque.)","Q_Score":34,"Tags":"python,queue,task","A_Id":49637357,"CreationDate":"2018-04-03T18:43:00.000","Title":"Python - What is queue.task_done() used for?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am fairly new to Django and could not figure out by reading the docs or by looking at existing questions. I looked into Django permissions and authentication but could not find a solution.\nLet's say I have a Detail View listing all instances of a Model called Item. For each Item, I want to control which User can view it, and for how long. In other words, for each User having access to the Item, I want the right\/permission to view it to expire after a specified period of time. After that period of time, the Item would disapear from the list and the User could not access the url detailing the Item.\nThe logic to implement is pretty simple, I know, but the \"per user \/ per object\" part confuses me. Help would be much appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":469,"Q_Id":49637924,"Users Score":1,"Answer":"Information about UserItemExpiryDate has to be stored in a separate table (Model). I would recommend using your coding in Django. \nThere are few scenarios to consider: \n1) A new user is created, and he\/she should have access to items. \nIn this case, you add entries to UserItemExpiry with new User<>Item combination (as key) and expiry date. Then, for logged in user you look for items from Items that has User<>Item in UserItemExpiry in the future. \n2) A new item is created, and it has to be added to existing users. \nIn such case, you add entries to UserItemExpiry with ALL users<> new Item combination (as key) and expiry date. And logic for \"selecting\" valid items is the same as in point 1. \nBest of luck, \nRadek Szwarc","Q_Score":1,"Tags":"python,django,django-admin,django-authentication,django-permissions","A_Id":49638105,"CreationDate":"2018-04-03T19:38:00.000","Title":"Django : how to give user\/group permission to view model instances for a specified period of time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working with the algorithmic problem called \"Find the longest substring with K unique characters\". Take string \u201caabbccdd\u201d as an example.\nif K is 1, the longest substring can be \u201caa\u201d.\nIf K is 2, the longest substring can be \u201caabb\u201d.\nIf K is 3, the longest substring can be \u201caabbcc\u201d.\nn this problem, you can take use of sliding window. Use a start pointer and an end pointer to represent a substring in a sliding window, if the current substring has K unique characters or less, it means the string can potentially be longer and you just need to move forward the end pointer by one character.\nIf after moving forward the end pointer the current substring exceeds K unique characters, it indicates that the previous substring is a potential candidate that has K unique characters. In this case, you just need to move forward the start pointer until the current substring has K or less unique characters.\nI don't understand why the time complexity of this is linear. Off the surface it appears to be quadratic. We have two pointers. Pointer i could potentially be an linear scan. j remains fixed through the linear scan. So this appears quadratic to me.\nTLDR: Can someone clearly deduce the linear time complexity for me? This isn't obvious to me. I like the notion of a sliding window to implictly iterate over the N^2 substrings. Then leveraging properties of the problem to set the start and end points to attempt to make this linear. But I don't see how this is linear. This looks quadratic in my analysis","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":457,"Q_Id":49638176,"Users Score":2,"Answer":"To deal with time complexity problems, it always helps to scale the problem up and think of a massive case.\nIf your string was thousands of characters long, we still only have one start pointer and one end pointer. The key thing is that both the pointers will only ever move forward (along the string). Therefore, the complexity of this is definitely O(n) since they are only moving forward together through the string - so the time this process would take is proportional to the length of the string (the time it takes to get to the end).\n\nA time complexity of O(n^2) would occur if we were to check all the windows for the end pointer from the start pointer to the end of the string, and then increment the start pointer and check all those substrings now again (from the start pointer to the end of the string). Here, we see that as we iterate over the string with the start pointer (O(n)), each iteration involves its own, nested iteration of moving the end pointer to the end of the string. That would make the complexity O(n^2).\nHowever, as previously stated, both your pointers only move forward, so at the most, this is of O(n) complexity.","Q_Score":3,"Tags":"python,string,algorithm,dynamic-programming","A_Id":49638555,"CreationDate":"2018-04-03T19:57:00.000","Title":"Time Complexity of \"Find the longest substring with k-unique characters\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with the algorithmic problem called \"Find the longest substring with K unique characters\". Take string \u201caabbccdd\u201d as an example.\nif K is 1, the longest substring can be \u201caa\u201d.\nIf K is 2, the longest substring can be \u201caabb\u201d.\nIf K is 3, the longest substring can be \u201caabbcc\u201d.\nn this problem, you can take use of sliding window. Use a start pointer and an end pointer to represent a substring in a sliding window, if the current substring has K unique characters or less, it means the string can potentially be longer and you just need to move forward the end pointer by one character.\nIf after moving forward the end pointer the current substring exceeds K unique characters, it indicates that the previous substring is a potential candidate that has K unique characters. In this case, you just need to move forward the start pointer until the current substring has K or less unique characters.\nI don't understand why the time complexity of this is linear. Off the surface it appears to be quadratic. We have two pointers. Pointer i could potentially be an linear scan. j remains fixed through the linear scan. So this appears quadratic to me.\nTLDR: Can someone clearly deduce the linear time complexity for me? This isn't obvious to me. I like the notion of a sliding window to implictly iterate over the N^2 substrings. Then leveraging properties of the problem to set the start and end points to attempt to make this linear. But I don't see how this is linear. This looks quadratic in my analysis","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":457,"Q_Id":49638176,"Users Score":2,"Answer":"An algorithm being O(n) means that the number of operations is eventually bounded by some linear function a * n where a is a constant.\nIn the case of algorithms that rely on list traversal it does not mean that they must traverse the list only once. It means they must traverse the list at most a times and that a does not depend on the list length.\nIn your case, you have two pointers, but they each traverse the list only once. This means you always traverse the list only twice.\nOne more remark is that while the number of substrings in a n-string grows by O(n^2), you are not traversing all of them. Indeed only up to n of them are valid and these are the only ones you are inspecting with the two-pointers traversal.\nBy example in the string 'abcdef' with k = 3, you do not check the substring 'abcd'.","Q_Score":3,"Tags":"python,string,algorithm,dynamic-programming","A_Id":49639151,"CreationDate":"2018-04-03T19:57:00.000","Title":"Time Complexity of \"Find the longest substring with k-unique characters\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Getting few \"package missing\" errors while installing ipython on High Sierra.\nmatplotlib 1.3.1 has requirement numpy>=1.5, but you'll have numpy 1.8.0rc1 which is incompatible.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1097,"Q_Id":49638201,"Users Score":3,"Answer":"I just met the same problem. It's a issue about numpy preinstall in Python has a version number issue(required >=1.5, but found 1.8.0rc1).\nTry running brew install python2 to upgrade your python which may solve this issue.","Q_Score":0,"Tags":"macos,numpy,matplotlib,ipython,homebrew","A_Id":49713880,"CreationDate":"2018-04-03T19:58:00.000","Title":"numpy version creating issue. python 2.7 already installed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed ansible on MAC High Sierra 10.13.3 and when I am trying to run \n\"ansible --version\" I am receiving following error \n-bash: \/usr\/local\/bin\/ansible: \/usr\/local\/opt\/python\/bin\/python2.7: bad interpreter: No such file or directory\nPlease let me know if you have ran into same issue or have solution.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":10718,"Q_Id":49643205,"Users Score":1,"Answer":"Changing the python version might be pushing into some compatibility issues\nIt happens, when we have multiple python versions installed in our OS.\nSimple steps for troubleshooting:\n\nCheck the python version\ncommand: which python \/usr\/bin\/python\nCreate a soft link to the path\ncommand : ln -s \/usr\/bin\/python \/usr\/local\/opt\/python\/bin\/python2.7\n\nI hope it will fix the error.","Q_Score":2,"Tags":"python,ansible","A_Id":54246317,"CreationDate":"2018-04-04T05:08:00.000","Title":"getting Ansible bad python interpreter error?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"In numpy, we use ndarray.reshape() for reshaping an array.\nI noticed that in pytorch, people use torch.view(...) for the same purpose, but at the same time, there is also a torch.reshape(...) existing.\nSo I am wondering what the differences are between them and when I should use either of them?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":88597,"Q_Id":49643225,"Users Score":16,"Answer":"Tensor.reshape() is more robust. It will work on any tensor, while Tensor.view() works only on tensor t where t.is_contiguous()==True.\nTo explain about non-contiguous and contiguous is another story, but you can always make the tensor t contiguous if you call t.contiguous() and then you can call view() without the error.","Q_Score":173,"Tags":"python,pytorch","A_Id":55976519,"CreationDate":"2018-04-04T05:09:00.000","Title":"What's the difference between reshape and view in pytorch?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In numpy, we use ndarray.reshape() for reshaping an array.\nI noticed that in pytorch, people use torch.view(...) for the same purpose, but at the same time, there is also a torch.reshape(...) existing.\nSo I am wondering what the differences are between them and when I should use either of them?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":88597,"Q_Id":49643225,"Users Score":0,"Answer":"I would say the answers here are technically correct but there's another reason for existing of reshape. pytorch is usually considered more convenient than other frameworks because it closer to python and numpy. It's interesting that the question involves numpy.\nLet's look into size and shape in pytorch. size is a function so you call it like x.size(). shape in pytorch is not a function. In numpy you have shape and it's not a function - you use it x.shape. So it's handy to get both of them in pytorch. If you came from numpy it would be nice to use the same functions.","Q_Score":173,"Tags":"python,pytorch","A_Id":69676338,"CreationDate":"2018-04-04T05:09:00.000","Title":"What's the difference between reshape and view in pytorch?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have rather unusual task, so I would like to ask for a piece of advice from experts :) \nI need to build small Flask-based web which will have build-in video player. Users will have to log-in to access videos. The problem is that I need to limit user by the amount of time they can spend using the service.\nCould someone please recommend a possible way to make it work or help me to find a place to get started?\nWhat I am thinking of... what if i create user's profile variable like \"credits_minutes\", and i could find a way to decrease credits_minutes every minute by one?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1049,"Q_Id":49645765,"Users Score":2,"Answer":"The sessions are based on requests from my understanding what you are trying to do is to actually get the amount of time spent on the site? You'll need to do some kind of keep alive from the client.\nSuch as web sockets, repetitive JavaScript calls or something else to know that they are on the actual site and base you logic on that.\nA simple solution would be to write something with jquery that polls an endpoint of you choice where you could do something time based for each poll. Such as saving the oldest call and comparing it to each new that is arriving. and when X minutes has elapsed, redirect the user.","Q_Score":1,"Tags":"python,session,web,flask,limit","A_Id":49646144,"CreationDate":"2018-04-04T08:02:00.000","Title":"Flask limiting user sessions by time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have installed bs4 using\npip install bs4\nI run pip list and beautifulsoup4 (4.6.0) bs4 (0.0.1) both appear. \nbut when I run python from the command line I get \nimport bs4\nImportError: No module named bs4\nI'm new to python so any help would be great.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":49646758,"Users Score":0,"Answer":"im guessing that you are trying to import like this:\nimport bs4\ntry this line instead\nfrom bs4 import BeautifulSoup","Q_Score":0,"Tags":"python,python-2.7,beautifulsoup","A_Id":49647971,"CreationDate":"2018-04-04T08:55:00.000","Title":"Beautiful Soup 4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'd like to create regex to match if they're substring of commands.\nExample: configure terminal\nMatch if have at least: conf t\nI tried to use : r'conf(igure)?\\s*t(erminal)?'\nbut it matched something like \"conf  txxxxx\" as well.\nalso, it's not matched \"config t\"\nmy questions is I'd like to create that match something like these.\nMatch:\nconfig ter\nconfigu term\nconf t\nnot matched:\nconfgure tminal\nif match optional, it's need to be in order.\nThanks!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":49646871,"Users Score":0,"Answer":"Just elaborating @usr2564301 comment here,\nimport re\npattern = r'conf(i(g(u(r(e)?)?)?)?)?\\st(e(r(m(i((n(a(l)?)?)?))?)?)?)?'\ntext='config t'\nprint(re.match(pattern, text))","Q_Score":0,"Tags":"python,python-2.7","A_Id":49649398,"CreationDate":"2018-04-04T09:01:00.000","Title":"Python Regex: How to match sub string of words","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I apologize if this is a duplicate but my search terms didn't find me what I was looking for. \nI only ever 'kill' my python script using its linux process id.\nThis has served me well but now I need to pickle certain things right before terminating. \nWhat is the best practice for communicating with a running Python script from the linux command line? Is there a library I should know about?\nExample action would be sending a terminate command to the running script, but also can see uses in the near future for modifying config variables etc.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":296,"Q_Id":49647444,"Users Score":1,"Answer":"There is no single best way. Depending on your requirements, you might choose between\n\nSignals. A single signal can communicate a few bits of information (with one signal, one bit; with two signals, two bits, because you can choose which one yon send, etc) and it's one-way; but it's reasonably real-time and asynchronous, so excellent for quick and easy one-way communications, perhaps as out-of-band information in addition to, or on top of, something more complex.\nShared memory is quick and efficient two-way communications but nontrivial to use in practice, and obviously constrained to processes running on the same host.\nSockets are very versatile and reasonably efficient for communication over a network, and reasonable for moderate amounts of data even on the same host.\n\nThis is pretty U*x-centric; Windows programmers tend to use threading and thus shared memory IPC a lot more.","Q_Score":1,"Tags":"python,command-line","A_Id":49654689,"CreationDate":"2018-04-04T09:30:00.000","Title":"Best way to communicate with Python script from command line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Trying to debug a TensorFlow model with the new TensorBoard debugger GUI. The communication between client (TensorFlow side) and server (TensorBoard side) fails with the following message: \ngrpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.RESOURCE_EXHAUSTED, Received message larger than max (11373336 vs. 4194304))>\nApparently the issue is well known in general and there are ways tricks to modify the max message size in grpc. However, in TensorFlow this is transparent to the user given that I am using the  tf_debug.TensorBoardDebugWrapperSession wrapper. \nMy question is how to increase the max message size so I can debug my model. I am using TensorFlow 1.6 with Python 3.6.\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":574,"Q_Id":49648395,"Users Score":0,"Answer":"Can you try creating TensorBoardDebugWrapperSession or TensorBoardDebugHook with the keyword argument send_source=False as a workaround? The root cause is that large source file sizes and\/or large number of source files causes the gRPC message to exceed the 4-MB message size limit.\nThe issue will be fixed in the next release of TensorFlow and TensorBoard.","Q_Score":2,"Tags":"python-3.x,debugging,tensorflow,grpc,tensorboard","A_Id":50514357,"CreationDate":"2018-04-04T10:11:00.000","Title":"TensorBoard debugger and gRPC max message size between client and server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"df.to_sql(name='hourly', con=engine, if_exists='append', index=False)\n\nIt inserts data not only to table 'hourly', but also to table 'margin' - I execute this particular line only.\nIt's Postgresql 10.\nWhile Creating table 'hourly', I inherited column names and dtypes from table 'margin'.\nIs it something wrong with the db itself or is it Python code?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":588,"Q_Id":49651442,"Users Score":0,"Answer":"Removing\n\nINHERITS (tablename);\n\non the slave table (creating it again without INHERITS)\nseems to have done the trick.\nOnly a matter of curiosity:\nWhy did it matter? I thought inheritance only gets columns and dtypes not the actual data.","Q_Score":1,"Tags":"python-3.x,postgresql,pandas","A_Id":49651837,"CreationDate":"2018-04-04T12:47:00.000","Title":"Pandas Dataframe.to_sql wrongly inserting into more than one table (postgresql)","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a excel file with large text data. 2 columns have lot of text data. Like descriptions, job duties. \nWhen i import my file in python df=pd.read_excel(\"form1.xlsx\"). It shows the columns with text data as NaN. \nHow do I import all the text in the columns ?\nI want to do analysis on job title , description and job duties. Descriptions and Job Title are long text. I have over 150 rows.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2378,"Q_Id":49652693,"Users Score":1,"Answer":"Try converting the file from .xlsx to .CSV \nI had the same problem with text columns so i tried converting to CSV (Comma Delimited) and it worked. Not very helpful, but worth a try.","Q_Score":0,"Tags":"excel,python-3.x,pandas,import","A_Id":49656081,"CreationDate":"2018-04-04T13:46:00.000","Title":"how to read text from excel file in python pandas?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm upgrading an old project running on Django 1.8 to at least Django 1.11 for LTS. I've heard upgrading a django project multiple versions can be difficult and frustrating. I haven't done this, so my question; is it better to do an upgrade per version, 1.8 -> 1.9 -> 1.10 -> 1.11. Or do you advice me to upgrade straightaway to 1.11 from 1.8. Please leave your best thoughts on this and other things I need to keep in mind while upgrading.\nThanks in advance","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3005,"Q_Id":49652893,"Users Score":1,"Answer":"Is not that far away from 1.8 to 1.11. I have updated versions like this before and I rarely ever had a problem. Usuary the problems that I had wasn't related to Django at all most of the time was because some libraries that were being used in the project that required to be updated as well as we update Django","Q_Score":9,"Tags":"python,django,upgrade,django-1.8,django-1.11","A_Id":49653185,"CreationDate":"2018-04-04T13:54:00.000","Title":"How to upgrade django project multiple versions (1.8 to 1.11+)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm upgrading an old project running on Django 1.8 to at least Django 1.11 for LTS. I've heard upgrading a django project multiple versions can be difficult and frustrating. I haven't done this, so my question; is it better to do an upgrade per version, 1.8 -> 1.9 -> 1.10 -> 1.11. Or do you advice me to upgrade straightaway to 1.11 from 1.8. Please leave your best thoughts on this and other things I need to keep in mind while upgrading.\nThanks in advance","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3005,"Q_Id":49652893,"Users Score":4,"Answer":"The upgrade can be difficult, depends on your situation.\nFirst, check the changelog for every version. The goal here is to understand if there is a major change that can affect your code. For example, the on_delete parameter in the foreign field models was optional, now is mandatory.\nIf you spot something, just update your code. \nWhat can really make the differences are the presence of tests. When we move from python2 to python3 and django 1.7 to 1.11 the tests were our insurance. \nWe just start to upgrade our code to a different branch using the virtualenv with the new python and new django and just fixing, testing and then merging in develop. If you don't have tests maybe is the right time to write some of them.\nI would not suggest you jump directly to django 2.0. Again, if you have tests you can update gradually and then check the deprecation warnings. Those are very helpful to prepare your code for the next version.\nUpdate\nDuring the process, we check our requirements and revise every package we had in our system to verify the compatibility. We clean up a little bit removing some packages and update some others. Again, if you have tests you have your insurance :-)\nConclusion\n\nCheck the changelogs\nUse a separate branch\n\nThen:\n\nUpdate gradually ( e.g. from 1.7 to 1.8)\n(write and) Run tests\nUpdate your code\/packages\nRun tests\nIf all it's ok then merge back\nin develop\nbranch again and go back to 1","Q_Score":9,"Tags":"python,django,upgrade,django-1.8,django-1.11","A_Id":49653287,"CreationDate":"2018-04-04T13:54:00.000","Title":"How to upgrade django project multiple versions (1.8 to 1.11+)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to know that if I can make a web server with Flask in my pc like xampp apache (php) for after I can access this page in others places across the internet. Or even in my local network trough the wifi connection or lan ethernet. Is it possible ? I saw some ways to do this, like using \"uwsgi\".. something like this... but I colud never do it.\nOBS: I have a complete application in Flask already complete, with databases and all things working. The only problem is that I don't know how to start the server and access by the others pc's.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5337,"Q_Id":49656877,"Users Score":2,"Answer":"Yes, you can.\nJust like you said, you can use uwsgi to run your site efficiently. There are other web servers like uwsgi: I usually use Gunicorn. But note that Flask can run without any of these, it will simply be less efficient (but if it is just for you then it should not be a problem).\nYou can find tutorials on the net with a few keywords like \"serving flask app\".\nIf you want to access your site from the internet (outside of your local network), you will need to configure your firewall and router\/modem to accept connections on port 80 (HTTP) or 443 (HTTPS).\nGood luck :)","Q_Score":2,"Tags":"python,html,web,flask","A_Id":49656968,"CreationDate":"2018-04-04T17:20:00.000","Title":"make a web server in localhost with flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been wanting to know how to make a GUI without using a module on Python, I have looked into GUI's in Python but everything leads to Tkinter or other Python GUI modules. The reason I do not want to use Tkinter is because I want to understand how to do it myself. I have looked at the Tkinter modules files but it imports like 4 other Modules.\nI don't mind the modules like system, os or math just not modules which I will use and not understand. If you do decide to answer my question please include as much detail and information on the matter. Thanks -- Darrian Penman","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1223,"Q_Id":49658301,"Users Score":1,"Answer":"For the same reason that you can't write to a database without using a database module, you can't create GUIs without a GUI module. There simply is no way to draw directly on the screen in a cross-platform way without a module.\nWriting GUIs is very complex. These modules exist to reduce the complexity.","Q_Score":0,"Tags":"python,python-3.x,user-interface,tkinter","A_Id":49658628,"CreationDate":"2018-04-04T18:48:00.000","Title":"Python - How do I make a window along with widgets without using modules like Tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been wanting to know how to make a GUI without using a module on Python, I have looked into GUI's in Python but everything leads to Tkinter or other Python GUI modules. The reason I do not want to use Tkinter is because I want to understand how to do it myself. I have looked at the Tkinter modules files but it imports like 4 other Modules.\nI don't mind the modules like system, os or math just not modules which I will use and not understand. If you do decide to answer my question please include as much detail and information on the matter. Thanks -- Darrian Penman","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1223,"Q_Id":49658301,"Users Score":1,"Answer":"You cannot write a GUI in Python without importing either a GUI module or importing ctypes.  The latter would require calling OS-specific graphics primitives, and would be far worse than doing the same thing in C.  (EDIT: see Roland comment below for X11 systems.)\nThe python-coded tkinter mainly imports the C-coded _tkinter, which interfaces to the tcl- and C- coded tk GUI package.  There are separate versions of tcl\/tk for Windows, *nix, and MacOS.","Q_Score":0,"Tags":"python,python-3.x,user-interface,tkinter","A_Id":49658596,"CreationDate":"2018-04-04T18:48:00.000","Title":"Python - How do I make a window along with widgets without using modules like Tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My website is hosted on Google App Engine using Standard Python.\nIn request handlers, I am setting HTTP header \"cache-control: max-age=3600, public\"\nSo frontend server \"Google Frontend\" caches the response for 1hr(which I want to save cost).\nIn rare cases the content of page changes and I want the content in frontend cache to be invalidated. How can I do that?\nIs there any API for it?\nI can't alter the URL as they have 90% traffic from Google Search.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":130,"Q_Id":49658369,"Users Score":2,"Answer":"When you set cache-control via the header or meta tag, that tells the browser to store the response.  So, the next time, it will not even ping your server.  This means that you cannot invalidate that cache after set.\nWhat you need is a backend cache. Frameworks like Django, Flask, etc. make this easy.  You can set a template cache, so it responds quickly, without much processing.\nYou can store the response in GAE's memcache, and send from there.  You can easily invalidate that cache, because you have complete control over it.\nAlternatively, you could change the url.  Google reads your canonical meta tag to get the desired indexed url, so you can add a query string, etc., but still save the Google score to that indexed url.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":49659939,"CreationDate":"2018-04-04T18:53:00.000","Title":"How to invalidate cashed URL response from GAE \"server: Google Frontend\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Currently I have multiple trained models for regression task, each model is of the same architecture but while training, I have dropout layer, to improve the performance, is that still possible for me to combine those trained models and calculate the mean of the weights as the combined, new model? I just heard that there is an ensemble prediction method which allow us to do, but I am not sure whether I can still do this because I already have random dropout layer.\nAny hint is much appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":137,"Q_Id":49659892,"Users Score":0,"Answer":"I think the presence of dropout is irrelevant to what you want to do. Ensembling should work just fine with dropout.","Q_Score":0,"Tags":"python,tensorflow,regression,prediction,robust","A_Id":49678287,"CreationDate":"2018-04-04T20:30:00.000","Title":"Ensemble (Combine) multiple deep learning regression models which already have dropout layers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing the cipher for python. I'm confused on how to use Regular Expression to find a paired word in a text dictionary. \nFor example, there is dictionary.txt with many English words in it. I need to find word paired with \"th\" at the beginning. Like they, them, the, their .....\nWhat kind of Regular Expression should I use to find \"th\" at the beginning?\nThank you!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":49660637,"Users Score":0,"Answer":"^(th\\w*) \n\ngives you all results where the string begins with th . If there is more than one word in the string you will only get the first.\n\n(^|\\s)(th\\w*)\n\nwil give you all the words begining with th even if there is more than one word begining with th","Q_Score":0,"Tags":"python,regex","A_Id":49660779,"CreationDate":"2018-04-04T21:19:00.000","Title":"Regular Expression in python how to find paired words","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This has been a very annoying problem for me and I couldn't find any keymaps or settings that could cause this behavior.\nSetup:\n\nPycharm Professional 2018.1 installed on redhat linux\nI remote into the linux machine using mobaX and launch pycharm with window forwarding\n\nScenario 1:\nI open a browser on windows, copy some text, go to editor or console, paste it somewhere without highlighting any text, hit ctrl+v, it pastes fine\nScenario 2:\nI open a browser on windows, copy some text, go to editor or console, highlight some text there, hit ctrl+v in attempt to replace the highlighted text with what's in my clipboard. The text didn't change. I leave pycharm and paste somewhere else, the text in clipboard has now become the text I highlighted.\nEdit:\nok I just realized this: as soon as I highlight the text, it gets copied...I've turned this feature off for terminal, but couldn't find a global settings for the editor etc. Anyone know how?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":360,"Q_Id":49661492,"Users Score":1,"Answer":"I figured it out: it's caused by the copy-on-select setting of my linux system. To turn it off, go to mobax-settings-configurations-x11-clipboard-disable 'copy on select'","Q_Score":0,"Tags":"python,ide,pycharm,copy-paste","A_Id":49679290,"CreationDate":"2018-04-04T22:36:00.000","Title":"pycharm ctrl+v copies the item in console instead paste when highlighted","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a model that starts with a Conv2D layer and so it must take input of shape (samples, rows, cols, channels) (and the model must ultimately output a shape of (1)). However, for my purposes one full unit of input needs to be some (fixed) number of samples, so the overall input shape sent into this model when given a batch of input ends up being (batch_size, samples, rows, cols, channels) (which is expected and correct, but...). How do I send each item in the batch through this model so that I end up with an output of shape (batch_size, 1)?\nWhat I have tried so far:\nI tried creating an inner model containing the Conv2D layer et al then wrapping the entire thing in a TimeDistributed wrapper, followed by a Dense(units=1) layer. This compiled, but resulted in an output shape of (batch_size, samples, 1). I feel like I am missing something simple...","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":587,"Q_Id":49662869,"Users Score":1,"Answer":"At the moment you are returning a 3D array.\nAdd a Flatten() layer to convert the array to 2D, and then add a Dense(1). This should output (batch_size, 1).","Q_Score":1,"Tags":"python,tensorflow,keras","A_Id":49662938,"CreationDate":"2018-04-05T01:37:00.000","Title":"In Keras, how to send each item in a batch through a model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I say problems, I mean 200% in over my head, in need of some serious hand-holding...\nTried to install Pygame and seems to work in the Command Prompt, the example 'aliens' game runs, when I enter the command \n'py -m pygame.examples.aliens'\nBut when I open PyCharm and try to import, it says no pygame module exists...\nCan someone please shed some light on this? I can tell you that I installed the pygame program to the desktop and all it put was 2 folders, one named 'Lib', the other named 'Include'...\nInside this Lib file is the site-packages file, which contains all the stuff you'd see in the External Libraries window in PyCharm, in fact I have ALL of those files and directories accessible in PyCharm, however, the whole site-packages file is red for some reason, and, like I said, trying to import does nothing.\nPlease Help!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":46,"Q_Id":49665655,"Users Score":1,"Answer":"Go to Pycharm File -> Project Settings -> find Project Interpreter\nIn the topright you'll find a plus sign. Click that, search for pygame in the list, install it from there.\nYou should now have a properly installed pygame usable in PyCharm.\nYou may want to clean up your Desktop, too.","Q_Score":0,"Tags":"python,pygame,pycharm,installation","A_Id":49665704,"CreationDate":"2018-04-05T06:39:00.000","Title":"Pygame Install Problems","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to train a neural net on a GPU using Keras and am getting a \"Resource exhausted: OOM when allocating tensor\" error.  The specific tensor it's trying to allocate isn't very big, so I assume some previous tensor consumed almost all the VRAM.  The error message comes with a hint that suggests this:\n\nHint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.\n\nThat sounds good, but how do I do it?  RunOptions appears to be a Tensorflow thing, and what little documentation I can find for it associates it with a \"session\".  I'm using Keras, so Tensorflow is hidden under a layer of abstraction and its sessions under another layer below that.\nHow do I dig underneath everything to set this option in such a way that it will take effect?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":26528,"Q_Id":49665757,"Users Score":2,"Answer":"OOM means out of memory. May be it is using more memory at that time.\nDecrease batch_size significantly. I set to 16, then it worked fine","Q_Score":27,"Tags":"python,tensorflow,keras,gpu","A_Id":64231036,"CreationDate":"2018-04-05T06:45:00.000","Title":"How to add report_tensor_allocations_upon_oom to RunOptions in Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"It is the first time that I am working with the LSTM networks. I have a video with a frame rate of 30 fps. I have a CNN network (AlexNet based) and I want to feed the last layer of my CNN network into the recurrent network (I am using tensorflow). Supposing that my batch_size=30, so equal to the fps, and I want to have a timestep of 1 second (so, every 30 frames). The output of the last layer of my network will be [bast_size, 1000], so in my case [30, 1000], now do I have to reshape the size of my output to [batch_size, time_steps, features] (in my case: [30, 30, 1000])? Is that correct? or am I wrong?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2027,"Q_Id":49668169,"Users Score":0,"Answer":"If you merge several small sequences from different videos to form a batch, the output of the last layer of your model (the RNN) should already be [batch_size, window_size, num_classes]. Basically, you want to wrap your CNN with reshape layers which will concatenate the frames from each batch:\n\ninput -> [batch_size, window_size, nchannels, height, width]\nreshape -> [batch_size * window_size, nchannels, height, width]\nCNN -> [batch_size * window_size, feat_size]\nreshape -> [batch_size, window_size, feats_size]\nRNN -> [batch_size, window_size, num_outputs]  (assuming frame-wise predictions)\n\nBut this will take a lot of memory, so you can set batch size to 1, which is what you seem to be doing if I understood correctly. In this case you can spare the first reshape.\nI'm not sure about the order of the axes above, but the general logic remains the same.\nAs a side note: if you plan on using Batch Normalization at some point, you may want to raise the batch size because consecutive frames from a single segment might not contain a lot of variety by themselves. Also give a double check on the batch normalization axes which should cover both time and batch axes.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,lstm","A_Id":49669130,"CreationDate":"2018-04-05T08:57:00.000","Title":"Feed the output of a CNN in a LSTM","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having a problem with elastic beanstalk, in my application there is some piece of code that creates some files dynamically and now I want to persist these files for future use, so is there any way that I can push my dynamically created files to GitHub automatically, so in next deployment these changes will remain, as elastic beanstalk replace the old code with new code after each deployment, So How can I commit my changes and push them to GitHub repo from code, any suggestions?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":120,"Q_Id":49670491,"Users Score":1,"Answer":"You can user aws S3 or other storage service as file back-end. This will sole you problem.","Q_Score":0,"Tags":"python,django,amazon-web-services,deployment,amazon-elastic-beanstalk","A_Id":49670735,"CreationDate":"2018-04-05T10:47:00.000","Title":"Auto Deploy Elastic Beanstalk Changes","Data Science and Machine Learning":0,"Database and SQL":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 problem with multilanguage and multi character encoded text. \nProject use OpenGraph and it will save in mysql database some information from websites. But database have problem with character encoding. I tryed encoding them  to byte. That is problem, becouse in admin panel text show us bute and it is not readable. \nPlease help me. How can i save multilanguage text in database and if i need encode to byte them how can i correctly decode them in admin panel and in views","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":49672291,"Users Score":0,"Answer":"You should encode all data as UTF-8 which is unicode.","Q_Score":0,"Tags":"python,django","A_Id":49672440,"CreationDate":"2018-04-05T12:22:00.000","Title":"Django multilanguage text and saving it on mysql","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The docs say\n\nh_n of shape (num_layers * num_directions, batch, hidden_size): tensor containing the hidden state for t = seq_len\n\nNow, the batch and hidden_size dimensions are pretty much self-explanatory. The first dimension remains a mystery, though.\nI assume, that the hidden states of all \"last cells\" of all layers are included in this output. But then what is the index of, for example, the hidden state of the \"last cell\" in the \"uppermost layer\"? h_n[-1]? h_n[0]? \nIs the output affected by the batch_first option?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1829,"Q_Id":49674079,"Users Score":8,"Answer":"The implementation of LSTM and GRU in pytorch automatically includes the possibility of stacked layers of LSTMs and GRUs.\nYou give this with the keyword argument nn.LSTM(num_layers=num_layers). num_layers is the number of stacked LSTMs (or GRUs) that you have. The default value is 1, which gives you the basic LSTM. \nnum_directions is either 1 or 2. It is 1 for normal LSTMs and GRUs, and it is 2 for bidirectional RNNs.\nSo in your case, you probably have a simple LSTM or GRU so the value of num_layers * num_directions would then be one.\nh_n[0] is the hidden state of the bottom-most layer (the one which takes in the input), and h_n[-1] of the top-most layer (the one which outputs the output of the network).  \nbatch_first puts the batch dimension before the time dimension (the default being the time dimension before the batch dimension), because the hidden state doesn't have a time dimension, batch_first has no effect on the hidden state shape.","Q_Score":5,"Tags":"python,neural-network,deep-learning,lstm,pytorch","A_Id":49686565,"CreationDate":"2018-04-05T13:50:00.000","Title":"How is the output h_n of an RNN (nn.LSTM, nn.GRU, etc.) in PyTorch structured?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install channels with pip in pycharm and I am getting the error:\n\ncommand 'cl.exe' failed: No such file or directory.\n\nI keep coming across Visual Studio solutions which do not help me.\nI am running on Windows.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":727,"Q_Id":49675361,"Users Score":1,"Answer":"You might be able to install it through PowerShell or Terminal outside of Pycharm, and then manually change your settings files and add your routing\/consumer files. I never set up my Pycharm environment when I did mine and only ran it through PowerShell, which seemed to work alright. Let me know!","Q_Score":1,"Tags":"python,django-channels","A_Id":49675557,"CreationDate":"2018-04-05T14:51:00.000","Title":"How do I install channels in Pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a bunch of Batch and Powershell scripts in my Ubuntu machine and I want to remotely execute them on windows and retrieve their results using python. \nPS: I've already tried paramiko but it only works when the scripts in question are already on the remote machine.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":188,"Q_Id":49675458,"Users Score":1,"Answer":"of course it \"only works when the scripts in question are already on the remote machine\". You can't \"remotely\" execute a local program (script, whatever), it has to be on the machine where it's supposed to be executed. The solution is plain simple: upload the script on the remote machine, then use paramiko to execute it.","Q_Score":0,"Tags":"python,linux,windows,scripting","A_Id":49675658,"CreationDate":"2018-04-05T14:55:00.000","Title":"Remotely execute a script ( batch\/powershell) in windows from linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"We're experiencing some slowdown, and frustrating database lockups with our current solution, which essentially consists of calling stored procedures on an MSSQL server to manipulate data. If two or more users try to hit the same table simultaneously, one is locked out and their request fails.\nThe proposed solution to this problem was to bring the data into python using sqlalchemy, and perform any manipulations \/ calculations on it in dataframes. This worked but was incredibly slow because of the network calls to the DB.\nIs there a better solution which can support multiple concurrent users, without causing too much of a slowdown?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":193,"Q_Id":49675751,"Users Score":1,"Answer":"You can use nolock keyword in stored procedure to remove this problem\nin your stored procedure where you specify table name in front of that write nolock keyword i hope it will be work for you\neg.\nselect * from tablename1 t1\njoin nolock tablename2 t2 on t2.id=t1.id","Q_Score":0,"Tags":"python,sql-server,sqlalchemy","A_Id":49684338,"CreationDate":"2018-04-05T15:08:00.000","Title":"Replacing MSSQL Server Stored Procedures to Prevent DB Locks","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have a hadoop cluster of 625 nodes. But some of them are centos 6 (python 2.6) and some are centos 7 (python 2.7). So how can I resolve this as I am getting this error constantly.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":562,"Q_Id":49676701,"Users Score":0,"Answer":"Install at least Python 2.7 on each node and configure SPARK_PYTHON environment variable to point to the required installation. Spark doesn't support mixed environments and doesn't support Python 2.6 anymore.","Q_Score":0,"Tags":"python,apache-spark,pyspark","A_Id":49676768,"CreationDate":"2018-04-05T15:58:00.000","Title":"Exception: Python in worker has different version 2.7 than that in driver 2.6, PySpark cannot run with different minor versions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a twisted web server with static files served in an htdocs\/... hierarchy. I would like to pass all .template files to mako\/jinja before returning them, but return non-templated static files directly. Does anyone have any insight on the best way to do this? I would like to avoid having to put them in a specific directory instead I would like to leave them in the natural file hierarchy.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":49679102,"Users Score":0,"Answer":"I attempted to use a file processor, but in the end I ended up subclassing static.File and overriding the render() method. The only complication was that I didn't realize that my type (MakoFile) would be instantiated for each child - this was causing me to lose my local mako context at times. In the end I realize the each instance of the File class has a Registry() handed down.\nSo I subclassed Registry as MakoRegistry, stuck my template lookup and context in there and pushed it into the top level object. This is working so far.","Q_Score":0,"Tags":"python,django-templates,webserver,jinja2,twisted","A_Id":49933007,"CreationDate":"2018-04-05T18:27:00.000","Title":"Custom filename extension handler in Twisted webserver for template rendering","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using python 2.7.10 virtualenv when running python codes in IntelliJ. I need to install requests[security] package. However I'm not sure how to add that [security] option\/config when installing requests package using the Package installer in File > Project Structure settings window.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":852,"Q_Id":49679283,"Users Score":0,"Answer":"Was able to install it by doing:\n\nActivating the virtualenv in the 'Terminal' tool window:\nsource <virtualenv dir>\/bin\/activate\nExecuting a pip install requests[security]","Q_Score":1,"Tags":"python,python-2.7,intellij-idea,virtualenv","A_Id":49679964,"CreationDate":"2018-04-05T18:38:00.000","Title":"How to Install requests[security] in virtualenv in IntelliJ","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After running brew install python@2, brew installs python into \/usr\/bin\/python, not \/usr\/local\/bin . \nThis prevents me from running certain commands since programs can't find python2. How can I get brew to install python in the 'correct' place?\nThis is causing problems.\nI have python3 correctly installed in \/usr\/local\/bin\/python3.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1266,"Q_Id":49680829,"Users Score":0,"Answer":"Try \"brew doctor\" to get a better picture of what is installed where and any issues to the installations using brew.\nOne suggestion is to let the installable be where the homebrew has installed. If you want any specific version to be used, try creating softlinks to the executable in any of the system Path's and use that softlink to invoke the version of Python2 you want.\nHope this will help you overcome your challenges.\nRegards,\nEby","Q_Score":1,"Tags":"python,homebrew","A_Id":49681003,"CreationDate":"2018-04-05T20:16:00.000","Title":"How to specify location of Brew install of Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm reading some python code and I came across a line of code that says arr = [-1]*n where arr is an array and n is an integer. What does this notation mean? What would arr look like after this?\nI feel bad asking this question here, because it feels more like a question for google, but I can't find anything on google by just googling the line of code, and I don't know the name of the notation.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":592,"Q_Id":49681524,"Users Score":3,"Answer":"It means, that the resulting array will be that cell repeated n times. In other words it will return an array with n elements when the initial array had one element. Every one of them will be -1 in this case.\nIn general it will produce an array repeated n-times, for example [1, 2, 3] * 2 == [1, 2, 3, 1, 2, 3].","Q_Score":1,"Tags":"python,arrays,python-3.x,python-2.7","A_Id":49681559,"CreationDate":"2018-04-05T21:06:00.000","Title":"What does setting an array equal to [-1]*n mean in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a azure http triggered fucntion to perform a task and I am passing the function key as http header parameter and then my payload is a json with some data that I invoking down stream procedures.I am using urllib(python lib) for this request and this is the response I am getting but the function is getting triggered. \nurllib.error.HTTPError: HTTP Error 417: Expectation Failed","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":410,"Q_Id":49682697,"Users Score":0,"Answer":"This was more of a Firewall issue.We have been trying to connect to a azure analysis service from ADW and we have added the IP filtering(Our Corporate public IP) for AAS and then when the Function's procedure is trying to connected to AAS it is facing some IP issue(this is NOT the corporate public IP). We have added that IP and now things are working fine.","Q_Score":0,"Tags":"python,azure,azure-functions","A_Id":49696760,"CreationDate":"2018-04-05T22:51:00.000","Title":"Azure HTTP trigger function call returning 417 error code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have multiple rosbag files with a ton of data, and what I would like to do is analyze these bag files using Jupyter Notebook, but the problem is that each bag has a different set of data parameters. So I have created msg files to subscribe to data from each bag file. Some msg files have the same variables since those variables are used in multiple plots.\nCan someone walk me through the process of getting the plots on the notebook file one at a time (from the data obtained from the bag files), for every bag file I have? Even if multiple files use the same topics?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":690,"Q_Id":49685635,"Users Score":0,"Answer":"Found this answer in one of the older .ipynb files. Plots can be obtained with Plotly library.  It really doesn't matter how many bag files are being scanned for topics and are plotted. Each bag file can be separately converted using the 'bag_to_dataframe' function from the \"rosbag_pandas\" package. \nEven in case of similar topics between bag files, it is possible to differentiate their values in the plots. Hope this helps, I'll share a sample bag file soon :)","Q_Score":0,"Tags":"python,jupyter-notebook,ros","A_Id":49817588,"CreationDate":"2018-04-06T05:00:00.000","Title":"Using Jupyter Notebook to plot data from rosbag files","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have an ontology but we need to use the reasoner HermiT to infer the sentiment of a given expression. We have no idea how to use and implement a reasoner in python and we could not find a good explanation on the internet. We found that we can use sync_reasoner() for this, but what does this do exactly? And do we have to call the reasoner manually everytime or does it happen automatically?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":736,"Q_Id":49687824,"Users Score":3,"Answer":"You do not need to implement the reasoner. The sync_reasoner() function already calls HermiT internally and does the reasoning for you. \nA reasoner will reclassify individuals and classes for you which means it creates a parent-child hierarchy of classes and individuals. When you load an ontology only explicit parent-child relations are represented. However, when you call the reasoner, the parent-child hierarchy is updated to include inferred relations as well.\nAn example of this is provided in Owlready2-0.5\/doc\/intro.rst. Before calling sync_reasoner() calling test_pizza.__class__ prints onto.Pizza, which is explicit information. However, after calling sync_reasoner() calling test_pizza.__class__ prints onto.NonVegetarianPizza, which is the inferred information.","Q_Score":5,"Tags":"python,ontology,reasoner,owlready,hermit","A_Id":49688765,"CreationDate":"2018-04-06T07:42:00.000","Title":"Use HermiT in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my framework, I am exposing a method to user which raises a custom exception and handling it in framework if raised.\nBut user has used generic catch block (Exception or except) while using my method, thus it is not handled as expected.\nIs there any way I can solve this issue either by ,\ni) Making my custom exception bypass generic except block (or get caught only by my custom except block).\nii) get the flow back to test_driver directly when condition is encountered.\nNote: I can not restrict user to using generic catch block.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":409,"Q_Id":49691232,"Users Score":0,"Answer":"No, there is no way to bypass a try ... except. Every exception that can be thrown can also be caught with an except. That's the whole point of exception handling.\nTrying to bypass an exception handler is not the correct solution. If your user catches your exception, there's nothing you can do about it. Look at it this way: The user caught an exception that he wasn't supposed to catch. This is a bug in the user's code. The correct way to deal with bugs is to fix them, not try to bypass them. It's not your responsibility to do anything about this problem - it's the user's responsibility to fix that bug.","Q_Score":0,"Tags":"python,python-2.7,exception,exception-handling","A_Id":49691671,"CreationDate":"2018-04-06T10:59:00.000","Title":"Bypass Base or Generic exception","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have installed some custom module. I have imported them through python console but when I try to import them in my pycharm project it does not recognise the module.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":54,"Q_Id":49698341,"Users Score":2,"Answer":"In PyCharm, use the shortcut key Ctrl + Alt + S to open settings. Under Project:Exp, select Project Interpreter. Use the \"+\" icon to install any module.","Q_Score":1,"Tags":"python,python-3.x,python-2.7,python-module","A_Id":49698561,"CreationDate":"2018-04-06T17:41:00.000","Title":"Cannot access custom python modules in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Pyinstaller to create my Python app from a set of scripts. This script uses a library that saves downloaded data to the '~\/' directory (using the os.join function).\nI was wondering how to edit the code in the library so that when it runs, it saves data to inside the app (like in the package, the Contents\/Resources maybe)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":148,"Q_Id":49698480,"Users Score":1,"Answer":"I was wondering how to edit the code in the library so that when it runs, it saves data to inside the app\n\nDon't do that. This isn't a standard practice in macOS applications, and will fail in some standard system configurations. For example, it will fail if the application is used by a non-administrator user, or if the application is run from a read-only disk image or network share.\nMore importantly, it'll also make it difficult or impossible to sign the application bundle with a developer certificate.","Q_Score":1,"Tags":"python,macos,pyinstaller,dylib","A_Id":49698626,"CreationDate":"2018-04-06T17:50:00.000","Title":"Saving data to MacOS python application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python to parse arguments. What I want to do is to check if there is no arguments given. However, parse_args() returns a namespace object.\nCurrently, I have to transfer the namespace to a dict, and check the value sets if there is one non-None element.\nI want to know if there is any simple way to do so.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":748,"Q_Id":49699290,"Users Score":0,"Answer":"parse_args() does not depopulate sys.argv. Therefore, len(sys.argv) == 1 is a good proxy for a no-argument check (since sys.argv still has a length of 1 when no arguments are passed).","Q_Score":0,"Tags":"python,argparse","A_Id":49699363,"CreationDate":"2018-04-06T18:48:00.000","Title":"How to check no argument is given to argparse in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm build RST files for my company's documentation.  One irritating thing is that enumerated lists don't seem to have any consistency in terms of line spacing.\nIs there a simple way to solve this?\nRobert","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1022,"Q_Id":49700502,"Users Score":1,"Answer":"I'm unsure how to apply Paebbels answer, however I was able to get rid of the <p> tags by changing to the html4 writer by adding this line to my conf.py.\nhtml4_writer = true\nThis obviously changes it to the html4 writer, so you'll need to determine whether this is acceptable or not.","Q_Score":4,"Tags":"python-sphinx,restructuredtext","A_Id":56822558,"CreationDate":"2018-04-06T20:22:00.000","Title":"Inconsistent line spacing in RestructuredText document","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm scrapping data from a subsection of Amazon. I want to be able to detect when a product is no longer available if I have previously scrapped that product. Is there a way to deal with outdated data like this? \nThe only solution I can think of so far is to completely purge the data and start the scrapping over but this will cause the metadata assigned to these items to be lost. My only other solution I can think of is an ad-hoc comparison of the two scrappings.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":49701840,"Users Score":0,"Answer":"How are you storing the data after each run?\nYou might consider just checking the for existence of a buy button on subsequent scrapings and marking a flag on the item as unavailable.","Q_Score":0,"Tags":"python,web-scraping,scrapy","A_Id":49702055,"CreationDate":"2018-04-06T22:31:00.000","Title":"Dealing with old records in Scrapy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"One thing I like about Rails projects is that you can create test content and place them in seeds.rb and seed them into the database by running rake db:seed instead of having to feed them one by one directly.\nIs there something similar for Python\/Django?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1058,"Q_Id":49702512,"Users Score":1,"Answer":"I would also recommend looking at Factory Boy for test data creation. One could create records in series of loops to population any number of tables and build sensible relationships between records.","Q_Score":4,"Tags":"python,django,python-3.x","A_Id":50101450,"CreationDate":"2018-04-07T00:08:00.000","Title":"Does Django have an equivalent of Rails's \u201crails db:seed\u201d?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am doing a project that requires me to repeatedly run a java function in python (it's like designing a learning algorithm in python but the value function was provided in java)\nSo what would be the practice for this scenario? Shall I use subprocess.run() to call the java function every time or shall I use the things like Py4J, Jython or JPype? What's the difference between using subprocess.run() and the others?\nThe efficiency should be the top concern since I need to run the same java function repeatedly.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":784,"Q_Id":49704105,"Users Score":3,"Answer":"Using subprocess has two problems. If neither one is relevant, it'll work fine.\n\n\nIf you're sending large amounts of data back and forth, you have to serialize it in some format to pass in via files and command-line arguments, or pipes or sockets, which can be slow.\nIf you're calling a whole lot of short functions instead of one occasional huge one, you'll be spending more time setting up and tearing down the JVM (and warming up the JIT) than doing actual work.\n\nJython has two problems. Again, if neither one affects you, it'll work fine.\n\n\nIt can't use many popular third-party libraries because they're built in C, for CPython.\nIt's out of date. The latest version implements Python 2.7, which is less than 2 years away from going out of support.\n\nJPype has one problem, but it's a doozy. If the current fork does what you need and has no bugs blocking you, maybe it's ok anyway.\n\n\nIt's a vaporware project abandoned over a decade ago. It was picked up and knocked into shape by someone else a few years ago, and the current maintainer is keeping it running, and occasionally gets patches for things like working in 64-bit cygwin or updating to OS X 10.9, but it's not exactly a vibrant project with major support behind it.\n\nPy4J has two problems.\n\n\nIt's incomplete. Not unusuable, and not completely moribund, but there hasn't been any visible work on it in over a year, and nobody seems interested in anything but the minimal functionality needed for Apache Spark.\nIt's doing the same kind of serialization you'd do with subprocess behind your back, and more beyond that for every call you make, and the FAQ justifies this by saying performance is not a priority. (Spark just ignores all of that and uses its own channels for everything.)\nFor more minimal use\u2014just starting up a JVM and setting up a socket to it\u2014it may be better than subprocess because you don't have to keep starting and tearing down a JVM, but writing a socket protocol on both sides is a little bit more work than storing files and passing filenames on the command line. (Not a huge hurdle, but a problem if you've never done this kind of thing before.)\n\nYou may also want to look at transpilers. I don't know much about any of them, but I've talked to people who are using BeeWare to compile Python 3.4 code to Java source code that they then build together with their native Java code. I'm pretty sure this won't work if you're using any C extension, but if that's not a problem for you, it might be worth considering.","Q_Score":0,"Tags":"java,python,subprocess,jython,jpype","A_Id":49704196,"CreationDate":"2018-04-07T05:12:00.000","Title":"What is the best way to run the same java function repeatedly in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am scraping a list of products every day using Scrapy but the products do not have unique ID numbers. So I have tried to manually assign 1,2,3,4 in the CSV file but this is not working since the products are changing from 1 to 5 for example if the site changes. Do you have any other solution that you can think so when I upload to my database the products will not duplicate?\nAlso, is there a way to ask Scrapy to automatically add 1,2,3,4 automatically?\nCheers.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":430,"Q_Id":49704710,"Users Score":0,"Answer":"If you are running on Scrapinghub Cloud, you can call the API to get the latest job ID when running, and the ID will be unique for the job.","Q_Score":0,"Tags":"python,scrapy,scrapy-spider","A_Id":54697103,"CreationDate":"2018-04-07T06:45:00.000","Title":"Scrapy - adding an unique ID to scraped data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on a web app project and I'm trying to use python and java, I get some problem with\n\nHow to communicate between java and python.  \n\nFor example, How a python project exchange data with java project, How to communicate between these two independent project. What should be use for sending result from python to java?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":92,"Q_Id":49704985,"Users Score":1,"Answer":"you can use files to write from one language and read from another language .\nuse sockets or use  http request  to communicate with each program.","Q_Score":0,"Tags":"java,python-2.7","A_Id":49705069,"CreationDate":"2018-04-07T07:24:00.000","Title":"How to send and receive result using Java and Python Project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to download the last 24hours of new files added to an S3 bucket - however, the S3 bucket contains a large number of files.\nFrom my understanding s3 buckets use a flat structure where files are stored alphabetically based on the key name. \nI've written a script to pull all the data stored on the bucket using threading. However, now I have all the files on my local system I want to update the database every 24hours with any new files that have been uploaded to S3. \nMost forums recommend using 'last modified' to search for the correct files and then download the files that match the data specified.\nFirstly, does downloading a file from the s3 bucket change the 'last modified'? Seems like this could cause problems.\nSecondly, this seems like a really in-efficient process - searching through the entire bucket for files with the correct 'last modified' each time, then downloading... especially since the bucket contains a huge number of files. Is there a better way to achieve this?\nFinally, does the pre-fix filter make this process any more efficient? or does this also require searching through all files.\nThanks in advance!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1708,"Q_Id":49710898,"Users Score":1,"Answer":"I'm going to go a different direction with this answer... You're right, that process is inefficient. I'm not sure the quantities and size of data you're dealing with but you're basically talking that you need a batch job to download new files. Searching a large number of keys is the wrong way to do it and is kind of an anti-pattern in AWS. At the root you need to keep track of new files as they come in.\nThe best way to solve this is using a Lambda Function (python since you're already familiar) that is triggered when a new object is deposited in your S3 bucket. What does that function do when a new file comes in?\nIf I had to solve this I would do one of the following:\n\nAdd the key of the new file to a DynamoDB table along with the timestamp. Throughout the day that table will grow whenever a new file comes in. When you're running your batch job read the contents of that table and download all the keys referenced, remove the row from the DynamoDB table. If you wanted to get fancy you could query based on the timestamp column and never clear rows from the table.\nCopy the file to a second \"pickup\" bucket. When your batch job runs you just read all the files out of this pickup bucket and delete them. You have to be careful with this one. It's really easy but you have to consider the size\/quantity of the files you're depositing so you don't run into the Lambda 5min execution limit.\n\nI can't really recommend one over the other because I'm not familiar with your scale, cost appetite, etc. For a typical use case I would probably go with the DynamoDB table solution. I think you'll be surprised how easy DynamoDB is to interact with in Python3.","Q_Score":0,"Tags":"python-3.x,amazon-web-services,amazon-s3,boto3","A_Id":49711565,"CreationDate":"2018-04-07T18:57:00.000","Title":"Efficiently downloading files from S3 periodically using python boto3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to download the last 24hours of new files added to an S3 bucket - however, the S3 bucket contains a large number of files.\nFrom my understanding s3 buckets use a flat structure where files are stored alphabetically based on the key name. \nI've written a script to pull all the data stored on the bucket using threading. However, now I have all the files on my local system I want to update the database every 24hours with any new files that have been uploaded to S3. \nMost forums recommend using 'last modified' to search for the correct files and then download the files that match the data specified.\nFirstly, does downloading a file from the s3 bucket change the 'last modified'? Seems like this could cause problems.\nSecondly, this seems like a really in-efficient process - searching through the entire bucket for files with the correct 'last modified' each time, then downloading... especially since the bucket contains a huge number of files. Is there a better way to achieve this?\nFinally, does the pre-fix filter make this process any more efficient? or does this also require searching through all files.\nThanks in advance!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1708,"Q_Id":49710898,"Users Score":1,"Answer":"Another solution to add here..\nYou could enable inventory on S3 which gives you a daily report of all files in the bucket, including meta data such as date in CSV format. \nWhen the CSV is generated (first one can take 48hours) you are able to generate a list of new files that you can download accordingly. The dynamo lambda option mentioned before will definitely give you a more real-time solution. \nAlso, I think modified date is only affected by PUT and POST actions","Q_Score":0,"Tags":"python-3.x,amazon-web-services,amazon-s3,boto3","A_Id":49712138,"CreationDate":"2018-04-07T18:57:00.000","Title":"Efficiently downloading files from S3 periodically using python boto3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to produce a graph from two sets of data files (txt and csv) and I have encountered a couple of issues using either R or Python and would be super super grateful if somebody could help :)\n\nHow to import to sets of data and how to choose specific column in each of them (would it be exactly the same as if dealing with one file)? \nOne of the file have much more data points than the other (3 600 000 vs 80 000). How can I select every nth row in the csv file? \n\nI would be grateful for any help in either R or python","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":52,"Q_Id":49713065,"Users Score":1,"Answer":"Ok, addressing the points as best I can without an example of what you tried that didn't work...\n\nHow to import to sets of data and how to choose specific column in each of them (would it be exactly the same as if dealing with one file)?\n\nYou'd import each file separately. Assuming your file has headers, something like\n\nd1 <- read.csv(\"your_file1_name.csv\", headers=TRUE)\nd2 <- read.csv(\"your_file2_name.csv\", headers=TRUE)\n\nIf your headers name useful names (e.g. \"Time\", \"88height\", \"number of octopus\", etc), your data frame will have the same column names, after running the headers through make.names(), which coverts the titles to legal R data frame column names.\ne.g.\n\nd1$Time\nd1$number.of.octopus\nd2$X88height\n\nIf you want the data frames merged into one big data frame, use rbind().\nIf you want a vector of all the data from a particular column from each data frame, you'd use c()\ne.g. \n\ntotal.octopus <- c(d1$number.of.octopus, d2$number.of.octopus)\n\n\nOne of the file have much more data points than the other (3 600 000 vs 80 000). How can I select every nth row in the csv file?\n\nTo select every 9th row of, say, d1, you'd index:\n\nidx <- seq(1, nrow(d1), by=9)\nd1_samp <- d1[idx,]  #note the comma and blank - means \"every column\"\n\nBecause of the lack of examples, this is only my interpretation of your needs. If it doesn't answer your question, you'll get there faster if you post a sample or toy example of code we can run that shows what you tried. For example, what kind of graph are you trying to make? Scatterplot? Trend? Barchart? And what kind of data? Time series? Number-vs-category? etc.","Q_Score":0,"Tags":"python,r,pandas,matplotlib,graph","A_Id":49714303,"CreationDate":"2018-04-07T23:44:00.000","Title":"Graphs from two sets of data files with different number of datapoints","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working a large graph, with 1.5 Million Nodes and 11 Million Edges.\nFor the sake of speed, I checked the benchmarks of the most popular graph libraries: iGraph, Graph-tool, NetworkX and Networkit. And it seems iGraph, Graph-tool and Networkit have similar performance. And I eventually used iGraph.\nWith the directed graph built with iGraph, the pagerank of all vertices can be calculated in 5 secs. However, when it came to Betweenness and Closeness, it took forever for the calculation.\nIn the documentation, it says that by specifying \"CutOff\", iGraph will ignore all path with length < CutOff value.\nI am wondering if there a rule of thumb to choose the best CutOff value to choose?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":676,"Q_Id":49713991,"Users Score":0,"Answer":"The cutoff really depends on the application and on the netwrok parameters (# nodes, # edges).\n\nIt's hard to talk about closeness threshold, since it depends greatly on other parameters (# nodes, # edges,...). \nOne thing you can know for sure is that every closeness centrality is somewhere between 2\/[n(n-1)] (which is minimum, attained at path) and 1\/(n-1) (which is maximum, attained at clique or star).\nPerhaps better question would be about Freeman centralization of closeness (which is somehow normalized version of closeness that you can better compare between various graphs).\n\n\nSuggestion:\nYou can do a grid search for different cutoff values and then choose the one that makes more sense based on your application.","Q_Score":1,"Tags":"python,igraph","A_Id":51268892,"CreationDate":"2018-04-08T03:04:00.000","Title":"Cutoff in Closeness\/Betweenness Centrality in python igraph","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For some reason unknown to me, everytime I startup Pycharm and open a project (Python3), the interpreter I previously setup will no longer be present. In the interpreter list, it's marked as invalid.\nI then have to recreate the interpreter and reinstall the packages I need.\nI also loose all settings I had (Ignored errors, spellings, etc.)\nDuring the setup, I keep the default location (\/tmp\/CNN_classifier.py\/venv) and default base interpreter (\/usr\/bin\/python3.5).\nIs there something I'm missing to make the interpreter permanent?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":250,"Q_Id":49714173,"Users Score":0,"Answer":"If you are opening individual files then try setting the default settings.\nFile > Default Settings > Project Interpreter.\nI think when you are opening individual files you are not loading the project. This sets a default interpreter so opening a file without loading the project should give it this interpreter.\nIf this doesn't work then open pycharm normally and select the project that you are working on.","Q_Score":0,"Tags":"python,python-3.x,pycharm","A_Id":49714434,"CreationDate":"2018-04-08T03:38:00.000","Title":"Pycharm venv interpreter resets at every launch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to do dynamic programming backtracking of maximum sum of non adjacent elements to construct the optimal solution to get the max sum.\nBackground:\nSay if input list is [1,2,3,4,5]\nThe memoization should be [1,2,4,6,9]\nAnd my maximum sum is 9, right?\nMy solution:\n\nI find the first occurence of the max sum in memo (as we may not choose the last item) [this is O(N)]\nThen I find the previous item chosen by using this formula:\nmax_sum -= a_list[index]\n\n\nAs in this example, 9 - 5 = 4, which 4 is on index 2, we can say that the previous item chosen is \"3\" which is also on the index 2 in the input list.\n\n\nI find the first occurence of 4 which is on index 2 (I find the first occurrence because of the same concept in step 1 as we may have not chosen that item in some cases where there are multiple same amounts together) [Also O(N) but...]\n\nThe issue:\nThe third step of my solution is done in a while loop, let's say the non adjacent constraint is 1, the max amount we have to backtrack when the length of list is 5 is 3 times, approx N\/\/2 times.\nBut the 3rd step, uses Python's index function to find the first occurence of the previous_sum [which is O(N)] memo.index(that_previous_sum)\nSo the total time complexity is about O(N\/\/2 * N)\nWhich is O(N^2) !!!\nAm I correct on the time complexity? Or am I wrong? Is there a more efficient way to backtrack the memoization list?\nP.S. Sorry for the formatting if I done it wrong, thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":128,"Q_Id":49715942,"Users Score":0,"Answer":"Solved:\n\nI looped from behind checking if the item in front is same or not\nIf it's same, means it's not first occurrence. If not, it's first occurrence.\nTada! No Python's index function to find from the first index! We find it now from the back\n\n\nSo the total time complexity is about O(N\/\/2 * N)\n\nNow O(N\/\/2 + 1), which is O(N).","Q_Score":0,"Tags":"python-3.x,performance,time-complexity,dynamic-programming,backtracking","A_Id":49716370,"CreationDate":"2018-04-08T08:26:00.000","Title":"Time complexity of my backtracking to find the optimal solution of the maximum sum non adjacent","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know after finding the closest match from the text section of the response table how chatterbot is generating the \"in_response_to\" list and the \"in_response_to_contains\" list. If somebody could enlight me this then it would be a great help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":49719767,"Users Score":0,"Answer":"The in_response_to list is generated based on previous input statements that the bot receives. So for example, lets say that the following interaction occurs:\n\nUser: \"Hello, how are you?\"\nBot: \"I am well, how are you.\"\nUser: \"I am also well.\"\n\nIn this case, the bot would learn based on how the user responded to it. So \"I am also well.\" is added to the in_response_to list of \"I am well, how are you.\"\n\nFor the second part of your question, the in_response_to__contains is an attributed used to tell the chat bot to query the database for statements where the in_response_to field contains a particular response.","Q_Score":1,"Tags":"python-3.x,chatterbot","A_Id":50184310,"CreationDate":"2018-04-08T15:51:00.000","Title":"how chatterbot is creating the in_response_to and in_response_to_contains list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Odoo (openERP) the default behavior for Tree view to list all items with pagination.\nIs there any possible way to not list any records by default and list when searched through search-bar or advanced search?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":601,"Q_Id":49724220,"Users Score":1,"Answer":"You can do this by creating wizard and then after closing that wizard you can get all your data. Create a menu, in its action just give a view id of your wizard. From wizard get all argument from user and then after successfully getting that data generate dynamic view from py.","Q_Score":3,"Tags":"python,xml,odoo","A_Id":49726437,"CreationDate":"2018-04-09T00:47:00.000","Title":"Don't display all record by default in odoo tree view","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am building my own Tensor class in Rust, and I am trying to make it like PyTorch's implementation. \nWhat is the most efficient way to store tensors programmatically, but, specifically, in a strongly typed language like Rust? Are there any resources that provide good insights into how this is done?\nI am currently building a contiguous array, so that, given dimensions of 3 x 3 x 3, my array would just have 3^3 elements in it, which would represent the tensor. However, this does make some of the mathematical operations and manipulations of the array harder.\nThe dimension of the tensor should be dynamic, so that I could have a tensor with n dimensions.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1685,"Q_Id":49724954,"Users Score":6,"Answer":"Contiguous array\nThe commonly used way to store such data is in a single array that is laid out as a single, contiguous block within memory. More concretely, a 3x3x3 tensor would be stored simply as a single array of 27 values, one after the other. \nThe only place where the dimensions are used is to calculate the mapping between the (many) coordinates and the offset within that array. For example, to fetch the item [3, 1, 1] you would need to know if it is a 3x3x3 matrix, a 9x3x1 matrix, or a 27x1x1 matrix - in all cases the \"storage\" would be 27 items long, but the interpretation of \"coordinates\" would be different. If you use zero-based indexing, the calculation is trivial, but you need to know the length of each dimension.\nThis does mean that resizing and similar operations may require copying the whole array, but that's ok, you trade off the performance of those (rare) operations to gain performance for the much more common operations, e.g. sequential reads.","Q_Score":14,"Tags":"python,python-3.x,rust,pytorch,tensor","A_Id":49734613,"CreationDate":"2018-04-09T02:59:00.000","Title":"How are PyTorch's tensors implemented?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Where can I find the list of all possible options\/values I can assign to this property ?\nSo far I only found people using: \"status:m\"\nfilterPanel.InteractiveSearchPattern = \"status:m\"","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":169,"Q_Id":49727576,"Users Score":1,"Answer":"great question!\nuhhhhhh I don't think there's a list though :)\nI did some digging through our support DB and found the following info. I have not had a chance to test these to validate.\n\nInteractiveSearchPattern can be set to the name of a filter to find, well, that specific filter (or a partial filter name to match multiple filters)\nstatus:m is abbreviated from status:modified, and will return a list of all modified filters\ndatatable:MyTable should match all filters from a given data table\n* should match all columns (unclear if this is regex matching or not)\n\nI inquired about this to TIBCO support, so if there are any additional points to list I'll make sure to update the answer :)","Q_Score":2,"Tags":"ironpython,spotfire","A_Id":49739825,"CreationDate":"2018-04-09T07:26:00.000","Title":"FilterPanel. InteractiveSearchPattern - list of possible values","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I defined some command line tools of python (take mycmd.py as an example), and saved them in the folder ~\/Scripts. Hence, I have to type (for example) python \/Scripts\/mycmd.py -o v. It is tedious to repeat the name of the folder \/Scripts. I want to run the command only inputting python mycmd.py -o v, even without cd. How should I do? Add a path to the original one?\nPS: in mac","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":66,"Q_Id":49728799,"Users Score":-1,"Answer":"Add the path to PYTHONPATH environment variable.","Q_Score":1,"Tags":"python,command-line,path","A_Id":49728849,"CreationDate":"2018-04-09T08:41:00.000","Title":"set path for command line of python (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":"while I am trying to update value that affect computed field I got this error:\n\nOdoo Server Error\n  Traceback (most recent call last):\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/http.py\", line 647, in _handle_exception\n      return super(JsonRequest, self)._handle_exception(exception)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/http.py\", line 684, in dispatch\n      result = self._call_function(**self.params)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/http.py\", line 320, in _call_function\n      return checked_call(self.db, *args, **kwargs)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/service\/model.py\", line 118, in wrapper\n      return f(dbname, *args, **kwargs)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/http.py\", line 313, in checked_call\n      result = self.endpoint(*a, **kw)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/http.py\", line 963, in call\n      return self.method(*args, **kw)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/http.py\", line 513, in response_wrap\n      response = f(*args, **kw)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/addons\/web\/controllers\/main.py\", line 904, in call_kw\n      return self._call_kw(model, method, args, kwargs)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/addons\/web\/controllers\/main.py\", line 896, in _call_kw\n      return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/api.py\", line 250, in wrapper\n      return old_api(self, *args, **kwargs)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/api.py\", line 381, in old_api\n      result = method(recs, *args, **kwargs)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/models.py\", line 6036, in onchange\n      record.mapped(field_seq)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/models.py\", line 5534, in mapped\n      recs = recs._mapped_func(operator.itemgetter(name))\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/models.py\", line 5514, in _mapped_func\n      vals = [func(rec) for rec in self]\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/models.py\", line 5752, in getitem\n      return self._fields[key].get(self, type(self))\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/fields.py\", line 829, in get\n      self.determine_value(record)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/fields.py\", line 927, in determine_value\n      record._prefetch_field(self)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/api.py\", line 248, in wrapper\n      return new_api(self, *args, **kwargs)\n    File \"\/Users\/abdalla\/projects\/greenway\/odoo-server\/openerp\/models.py\", line 3295, in _prefetch_field\n      assert self in records and field in fs\n  AssertionError","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":435,"Q_Id":49729015,"Users Score":0,"Answer":"finally I found the problem:\nthe problem is that the method of the computed field is not exist (I renamed it accidentally). so when odoo try to get the value of this field it failed, and show this strange error","Q_Score":0,"Tags":"python,odoo-8,odoo-10,odoo-9","A_Id":49730003,"CreationDate":"2018-04-09T08:53:00.000","Title":"odoo 9 AssertionError assert self in records and field in fs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to convert a list of tuple like a = [(1,2),(2,49),(3,45)]\nto numpy matrix : [[1,2],[2,49],[3,45]]\nCan anyone help me?\nthanks in advance","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1397,"Q_Id":49730922,"Users Score":-1,"Answer":"try this:\na = [(1,2),(2,49),(3,45)]\nprint map(list,a)","Q_Score":0,"Tags":"python,numpy,tuples","A_Id":49731077,"CreationDate":"2018-04-09T10:35:00.000","Title":"convert list of tuple () to numpy matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I install a package through pip (since it was not available on Anaconda), it also pulls all dependencies. It seems it will use the pip versions of the dependencies, even if conda versions (same name) are available.\nHow can I easily install a pip package, but use conda for the dependencies where such a package exists?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":511,"Q_Id":49731747,"Users Score":0,"Answer":"There is no easy way, I suspect. Create a virtual environment, install all anticipated dependencies using conda and then install the main package using pip without -U\/--upgrade. pip seeing dependencies installed will not install them again.","Q_Score":0,"Tags":"python,pip,anaconda,conda","A_Id":49736592,"CreationDate":"2018-04-09T11:21:00.000","Title":"How can I install a PyPI package while using Anaconda dependencies?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to crop and save images from tensorflow object detection API output with following code I created using previous stack overflow questions.\nBut after saving the image seemed to have high density of blue color.\nThe original image has normal color. Since both cropping and encoding refer image channel for format I am not sure about the source of the issue.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":197,"Q_Id":49732469,"Users Score":1,"Answer":"Your problem here is not related to Tensorflow at all but to OpenCV.\nFor some reason, OpenCV loads images in a BGR format and not RGB as Tensorflow expects them to be.\nInvert your first and third channels in your image before passing it to Tensorflow and everything should be fine.","Q_Score":0,"Tags":"python,tensorflow,computer-vision","A_Id":49732736,"CreationDate":"2018-04-09T12:00:00.000","Title":"Image becomes blue masked after applying tf.image.crop_to_bounding_box and tf.image.encode_jpeg","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I am facing the following problem:\nI have a ; separated csv, which has ; enclosed in quotes, which is corrupting the data.\nSo like abide;acdet;\"adds;dsss\";acde\nThe ; in the \"adds;dsss\" is moving \" dsss\" to the next line, and corrupting the results of the ETL module which I am writing. my ETL is taking such a csv from the internet, then transforming it (by first loading it in Pandas data frame, doing pre-processing and then saving it), then loading it in sql server. But corrupted files are breaking the sql server schema. \nIs there any solution which I can use in conjunction with Pandas data frame which allows me to fix this issue either during the read(pd.read_csv) or writing(pd.to_csv)( or both) part using Pandas dataframe?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2337,"Q_Id":49733229,"Users Score":0,"Answer":"The sep parameter of pd.read_csv allows you to specify which character is used as a separator in your CSV file. Its default value is ,. Does changing it to ; solve your problem?","Q_Score":2,"Tags":"python-3.x,pandas,csv,data-cleaning,quoting","A_Id":49733409,"CreationDate":"2018-04-09T12:41:00.000","Title":"Solving csv files with quoted semicolon in Pandas data frame","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"sorry for very basic question but i can't find a direct answer.\nI want to check a column to find the maximum value.  for now I assume there is only one maximum value, its unique.\nI then want to find the index name for that row.\nIs there a way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":49733632,"Users Score":0,"Answer":"Just df.index[df[your_column_name].argmax()] :)","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":49733693,"CreationDate":"2018-04-09T13:02:00.000","Title":"finding the maximum value of a column in pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering what others are doing to expose REST api endpoints with the datastore (using app engine standard). I want to use urlsafe keys but 1 - I'd rather not pass this data directly as it poses a security risk since app-engine to app-engine calls are exposed over a public ip, and 2 - the keys that are generated are very long and would not be great when multiple need to be passed as a query parameter to form a get request (and would probably exceed browser character limits).\nI was thinking maybe using compression of some sort to compress the urlsafe keys which would solve both 1 and 2, but want to see if there is a better way to create REST endpoints. Or if some type of compression method is already baked into ndb?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":90,"Q_Id":49737087,"Users Score":1,"Answer":"Google uses HTTPS internally so I'm not sure you need to worry about it.  \nAlso, you should probably design your app so that keys are not secret info and such that it is safe to expose them.\nI use key IDs for my REST calls, which I believe are 12 digit numbers.  That works as long as you know the entity type.  If you need to specify the entity type, you could add another parameter to your API call.","Q_Score":0,"Tags":"rest,google-app-engine,google-cloud-datastore,app-engine-ndb,google-app-engine-python","A_Id":49739232,"CreationDate":"2018-04-09T16:01:00.000","Title":"NDB urlsafe keys and REST api requests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Using matplotlib is it possible to take a 2D image of something and place it in a 3D figure? I'd like to take a 2D image and place it at z position of 0. I want to then move the other pixels in the image along the z-axis separately based on a calculation I am making.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1911,"Q_Id":49743901,"Users Score":0,"Answer":"If your image is a coloured image you must first ensure that it is an indexed image. This means that you can only have 2d matrix (and not 3 matricies for the RGB components). Command rgb2ind can help.\nThen you can directly show you image in a 3D way. Use the mesh or surf command.\nYou can also adjust perspective with angle and azimuth.","Q_Score":1,"Tags":"python,matplotlib","A_Id":49743935,"CreationDate":"2018-04-10T01:27:00.000","Title":"Plot 2D image in 3D axes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering what the difference is between the zip() function in python 2 and python 3 is. I noticed when using the timeit module on both functions that the python 3 function was a lot faster. Thanks so much in advance :)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6938,"Q_Id":49746487,"Users Score":5,"Answer":"Difference between Python 2 and Python 3 is Python 3 returns an iterators. Idea of this saving memory.","Q_Score":7,"Tags":"python,zip","A_Id":49746736,"CreationDate":"2018-04-10T06:09:00.000","Title":"Difference between zip() functions in Python 2 and Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given a pattern [1,1,0,1,1], and a binary list of length 100, [0,1,1,0,0,...,0,1]. I want to count the number of occurences of this pattern in this list. Is there a simple way to do this without the need to track the each item at every index with a variable? \nNote something like this, [...,1, 1, 0, 1, 1, 1, 1, 0, 1, 1,...,0] can occur but this should be counted as 2 occurrences.","AnswerCount":8,"Available Count":1,"Score":0.0748596907,"is_accepted":false,"ViewCount":6442,"Q_Id":49747835,"Users Score":3,"Answer":"you can always use the naive way : \nfor loop on slices of the list (as in the slice that starts at i-th index and ends at i+[length of pattern]).\nand you can improve it - notice that if you found an occurence in index i' you can skip i+1 and i+2 and check from i+3 and onwards (meaning - you can check if there is a sub-pattern that will ease your search ) \nit costs O(n*m)\nyou can use backwards convolution (called pattern matching algorithem)\nthis costs O(n*log(n)) which is better","Q_Score":5,"Tags":"python,python-3.x,python-2.7,list,count","A_Id":49748656,"CreationDate":"2018-04-10T07:29:00.000","Title":"Count the number of occurences of a pattern in a list in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I changed my project code from python 2.7 to 3.x. \nAfter these changes i get a message \"cannot find declaration to go to\" when hover over any method and press ctrl \nI'm tryinig update pycharm from 2017.3 to 18.1, remove directory .idea but my issue still exist.\nDo you have any idea how can i fix it?","AnswerCount":5,"Available Count":5,"Score":0.0399786803,"is_accepted":false,"ViewCount":28559,"Q_Id":49749981,"Users Score":1,"Answer":"I had a case where the method was implemented in a base class and Pycharm couldn't find it.\nI solved it by importing the base class into the module I was having trouble with.","Q_Score":24,"Tags":"python-3.x,pycharm","A_Id":52749421,"CreationDate":"2018-04-10T09:23:00.000","Title":"Pycharm - Cannot find declaration to go to","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I changed my project code from python 2.7 to 3.x. \nAfter these changes i get a message \"cannot find declaration to go to\" when hover over any method and press ctrl \nI'm tryinig update pycharm from 2017.3 to 18.1, remove directory .idea but my issue still exist.\nDo you have any idea how can i fix it?","AnswerCount":5,"Available Count":5,"Score":0.1973753202,"is_accepted":false,"ViewCount":28559,"Q_Id":49749981,"Users Score":5,"Answer":"I had same issue and invalidating cache or reinstalling the app didn't help.\nAs it turned out the problem was next: for some reasons *.py files were registered as a text files, not python ones. After I changed it, code completion and other IDE features started to work again.\nTo change file type go Preferences -> Editor -> File types","Q_Score":24,"Tags":"python-3.x,pycharm","A_Id":70948307,"CreationDate":"2018-04-10T09:23:00.000","Title":"Pycharm - Cannot find declaration to go to","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I changed my project code from python 2.7 to 3.x. \nAfter these changes i get a message \"cannot find declaration to go to\" when hover over any method and press ctrl \nI'm tryinig update pycharm from 2017.3 to 18.1, remove directory .idea but my issue still exist.\nDo you have any idea how can i fix it?","AnswerCount":5,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":28559,"Q_Id":49749981,"Users Score":66,"Answer":"Right click on the folders where you believe relevant code is located ->Mark Directory as-> Sources Root\nNote that the menu's wording \"Sources Root\" is misleading: the indexing process is not recursive. You need to mark all the relevant folders.","Q_Score":24,"Tags":"python-3.x,pycharm","A_Id":50335132,"CreationDate":"2018-04-10T09:23:00.000","Title":"Pycharm - Cannot find declaration to go to","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I changed my project code from python 2.7 to 3.x. \nAfter these changes i get a message \"cannot find declaration to go to\" when hover over any method and press ctrl \nI'm tryinig update pycharm from 2017.3 to 18.1, remove directory .idea but my issue still exist.\nDo you have any idea how can i fix it?","AnswerCount":5,"Available Count":5,"Score":0.1973753202,"is_accepted":false,"ViewCount":28559,"Q_Id":49749981,"Users Score":5,"Answer":"What worked for me was right-click on the folder that has the manage.py > Mark Directory as > Source Root.","Q_Score":24,"Tags":"python-3.x,pycharm","A_Id":63009947,"CreationDate":"2018-04-10T09:23:00.000","Title":"Pycharm - Cannot find declaration to go to","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I changed my project code from python 2.7 to 3.x. \nAfter these changes i get a message \"cannot find declaration to go to\" when hover over any method and press ctrl \nI'm tryinig update pycharm from 2017.3 to 18.1, remove directory .idea but my issue still exist.\nDo you have any idea how can i fix it?","AnswerCount":5,"Available Count":5,"Score":0.0399786803,"is_accepted":false,"ViewCount":28559,"Q_Id":49749981,"Users Score":1,"Answer":"The solution for me: remember to add an interpreter to the project, it usually says in the bottom right corner if one is set up or not. Just an alternate solution than the others.\nThis happened after reinstalling PyCharm and not fully setting up the ide.","Q_Score":24,"Tags":"python-3.x,pycharm","A_Id":68959559,"CreationDate":"2018-04-10T09:23:00.000","Title":"Pycharm - Cannot find declaration to go to","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I unpickle cifar-10 by python, I get a dictionary with 4 keys:'batch_label','data','filenames','labels'. But I don't konw what the key 'batch_label' represent for. It's a 'bytes' type data, length is 21. I konw I needn't to know it when I train a network. But I'm still curious about it. Thanks for any reply. ^_^","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":233,"Q_Id":49750513,"Users Score":1,"Answer":"The cifar10 dataset you are donwloading is splitted in serveral batches.\nEach batch has its own id (batch_label).\ndata is the actual batch if images, while filenames is the name of the images encoded. labels, of course, is the set of labels associated with the data","Q_Score":0,"Tags":"python,machine-learning","A_Id":49800463,"CreationDate":"2018-04-10T09:49:00.000","Title":"What does the key \" b'batch_label' \" in cifar-10 unpickle by python use for?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to try out user defined keywords as setup and teardown for test cases in a Robot Framework test suite and sub-test suites. I have following structure,\n\n    ROOT\n    |\n    |- tests\n        |- __init__.txt\n        |- sample.robot\n\n\n__init__.txt contains the following text\n\n\n    *** Settings ***\n    Test Setup    My Keyword1\n    Test Teardown    My Keyword2\n\n    *** Keywords ***\n    My Keyword1\n        Log    Inside My Keyword1\n\n    My Keyword2\n        Log    Inside My Keyword2\n\nSample.robot contains following code,\n\n\n    *** Test Cases ***\n    My Testcase1\n        Log    Inside My Testcase1\n\n\nRunning robot tests gives me the following error,\n\n\n    ==============================================================================\n    Tests\n    ==============================================================================\n    Tests.Sample\n    ==============================================================================\n    My Testcase1                                                          | FAIL |\n    Setup failed:\n    No keyword with name 'My Keyword1' found.\n\n    Also teardown failed:\n    No keyword with name 'My Keyword2' found.\n    ------------------------------------------------------------------------------\n    Tests.Sample                                                          | FAIL |\n    1 critical test, 0 passed, 1 failed\n    1 test total, 0 passed, 1 failed\n    ==============================================================================\n    Tests                                                                 | FAIL |\n    1 critical test, 0 passed, 1 failed\n    1 test total, 0 passed, 1 failed\n    ==============================================================================\n\n\nCan you please let me know what am I missing in the above structure? I need a mechanism which will allow me to execute a user keyword as setup or teardown for default. Also if required an individual test case can override the setup\/teardown.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1011,"Q_Id":49754614,"Users Score":0,"Answer":"Do not use \"Test setup\" and \"Test Teardown\" in the Settings section of your __init__ file. Instead use \"Suite Setup\" and \"Suite Teardown\". This is because your are going to execute this setup for all the test suites within this folder.\nAlso, it is a good idea to change the extension of the __init__ file to .robot instead of .txt.","Q_Score":2,"Tags":"python,robotframework","A_Id":49755548,"CreationDate":"2018-04-10T13:12:00.000","Title":"Keyword defined in __init__.txt doesn't get picked up for Test Setup and Test Teardown","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem.\nI need numpy 1.14.2, and my machine (Linux Mint 17.3) has only 1.8.2 installed.\nI then installed 1.14.2 through pip. But when I load it in ipython, it still says that it is 1.8.2.\nUsing yolk I saw that 1.14.2 is actually installed, but marked as non-active.\n\nnumpy           - 1.14.2       - non-active development\n  (\/usr\/local\/lib\/python2.7\/dist-packages)\n\nWhile for 1.8.2 it says \"active\".\nAlso, 1.8.2 is located in \"\/usr\/lib\/python2.7\/dist-packages\/numpy\".\nWhy is there a difference? I dont see a reason why there are two libraries.\nI read that python loads the libraries by the order in $PATH.\nAnd indeed, when I look at sys.path, I see that \/usr\/lib... is listet before \/usr\/local ....\nHow can I change that? I dont have anything in .bashrc, \/etc\/profile or \/etc\/rc.local which would set this specific order.\nThx.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":343,"Q_Id":49756369,"Users Score":0,"Answer":"You should use a virtual environment. Your system most likely will default to the most up to date version. \nTry installing:\npip install virtualenv \nthen run:\nvirtualenv -p python2.7 environment_name. \nSource the virtualenv with:\nsource environment_name\/bin\/activate \nthen pip install numpy=1.14.2.\nThen you will have a mini environment with the exact version you want and wont update. This way you can have multiple versions all contained in the same system.","Q_Score":0,"Tags":"python,linux,path","A_Id":49756505,"CreationDate":"2018-04-10T14:34:00.000","Title":"python not using latest numpy version","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Knowing the following:\n\nsys.getsizeof(int())\n24 (number of bytes?)\nint('11111111', 2)\n255\n\nHow long can the binary string be?\nexample this works as well:\n\nint('1111111111111111', 2)\n65535\n\nSo how long can my length of my binary string be maximum?!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":139,"Q_Id":49756433,"Users Score":0,"Answer":"Pretty sure you can make it as long as you want (of course depending on your RAM), because both ints and strings can have any length in Python.","Q_Score":0,"Tags":"python,binary,integer,byte,base","A_Id":49756547,"CreationDate":"2018-04-10T14:38:00.000","Title":"How long can a binary string be when converting? (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to browse HDFS File-system from an UI like Hue does using python?\nI want to list hdfs files from simple html UI","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":230,"Q_Id":49757912,"Users Score":1,"Answer":"This doesn't involve Python, but you can view this from the NameNode's web UI using \"Utilities -> Browse the file system\", located at http:\/\/your-namenode:50070\/explorer.html (assuming default http port of 50070)","Q_Score":0,"Tags":"python,hdfs","A_Id":49758107,"CreationDate":"2018-04-10T15:46:00.000","Title":"Browsing Hdfs Filesystem from UI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have the following data frame: \nParameters Year 2016 Year 2017 Year 2018.... \n0)   X           10          12      13\n1)    Y           12          12      45\n2)    Z           89          23      97\n3\n.\n.\n.\nI want to make a line chart with the column headers starting from Year 2016 to be on the x-axis and each line on the chart to represent each of the parameters - X, Y, Z\nI am using the matplotlib library to make the plot but it is throwing errors.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":403,"Q_Id":49762381,"Users Score":0,"Answer":"If you have a pandas DataFrame, let's call it df, for which your columns are X, Y, Z, etc. and your rows are the years in order, you can simply call df.plot() to plot each column as a line with the y axis being the values and the row name giving the x-axis.","Q_Score":1,"Tags":"python,pandas,matplotlib,visualization","A_Id":49762442,"CreationDate":"2018-04-10T20:29:00.000","Title":"Manipulate Python Data frame to plot line charts","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just made the transition from Spyder to VScode for my python endeavours. Is there a way to run individual lines of code? That's how I used to do my on-the-spot debugging, but I can't find an option for it in VScode and really don't want to keep setting and removing breakpoints.\nThanks.","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":18994,"Q_Id":49771589,"Users Score":3,"Answer":"In my ver of VSCode (1.25), shift+enter will run selection.  Note that you will want to have your integrated terminal running python.","Q_Score":15,"Tags":"python,debugging,visual-studio-code","A_Id":52346976,"CreationDate":"2018-04-11T09:36:00.000","Title":"VScode run code selection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just made the transition from Spyder to VScode for my python endeavours. Is there a way to run individual lines of code? That's how I used to do my on-the-spot debugging, but I can't find an option for it in VScode and really don't want to keep setting and removing breakpoints.\nThanks.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":18994,"Q_Id":49771589,"Users Score":0,"Answer":"I'm still trying to figure out how to make vscode do what I need (interactive python plots), but I can offer a more complete answer to the question at hand than what has been given so far:\n1- Evaluate current selection in debug terminal is an option that is not enabled by default, so you may want to bind the 'editor.debug.action.selectionToRepl' action to whatever keyboard shortcut you choose (I'm using F9). As of today, there still appears to be no option to evaluate current line while debugging, only current selection.\n2- Evaluate current line or selection in python terminal is enabled by default, but I'm on Windows where this isn't doing what I would expect - it evaluates in a new runtime, which does no good if you're trying to debug an existing runtime. So I can't say much about how useful this option is, or even if it is necessary since anytime you'd want to evaluate line-by-line, you'll be in debug mode anyway and sending to debug console as in 1 above. The Windows issue might have something to do with the settings.json entry\n\"terminal.integrated.inheritEnv\": true,\nnot having an affect in Windows as of yet, per vscode documentation.","Q_Score":15,"Tags":"python,debugging,visual-studio-code","A_Id":67669127,"CreationDate":"2018-04-11T09:36:00.000","Title":"VScode run code selection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background:\nI am using Django2 and Sentry for detecting my crash. In my gitlab pipe line. I used to has test job as a major concern to not break any features when deploy new feature.\nMany of my testcases contains Exception and Sentry does surge up.\nQuestion:\nDo I have any technique to suppress sentry for a while during pipeline running?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":19,"Q_Id":49771711,"Users Score":1,"Answer":"Well basically if there is a settings.py configuration that specify whether to send errors to Sentry, you could create a different one for test environment and turn off sentry logging.\nI currently use a separate test_settings.py file where I remove sentry (and related) from the INSTALLED_APPS. It works well enough for us.","Q_Score":0,"Tags":"python,sentry","A_Id":49841595,"CreationDate":"2018-04-11T09:42:00.000","Title":"Crash analytic surge up when runner running testcases","Data Science and Machine Learning":0,"Database and SQL":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 randomly encounter the same error whenever I run XGBoost model (both the normal run and grid search). The error message says this:\nH2OConnectionError: Local server has died unexpectedly. RIP.\nI don't know what happens, I tried to change versions but didn't work. I'm currently using the version 3.18.0.5. Does anyone have any idea what is happening? Thanks in advance","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":959,"Q_Id":49773582,"Users Score":1,"Answer":"The only time I've seen this happen is when H2O runs out of memory.  Please check that you have enough memory -- an H2O cluster should have at least 4x the amount of RAM as the dataset you're trying to train a model on (data size on disk).","Q_Score":4,"Tags":"python,machine-learning,artificial-intelligence,h2o,xgboost","A_Id":51889351,"CreationDate":"2018-04-11T11:11:00.000","Title":"Error every time running H2OXGBoostEstimator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using from dateutil import parser to parse an input but for some reason it is giving me back the wrong timezone.\nMy code:\nparser.parse(input_date)\nInput: Tue May 01 2018 13:23:00 GMT+0200 (CEST)\nOutput: 2018-05-01 13:23:00-02:00\nDoes anybody know why the parse method changes the +2 timezone to -2?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":216,"Q_Id":49774090,"Users Score":0,"Answer":"Because the issue is open on github as Paul said I had to make a custom solution. I parsed the input using re and changed it from:\nTue May 01 2018 13:23:00 GMT+0200 (CEST) to Tue May 01 2018 13:23:00 +0200, dateutil.parser.parse had no problem parsing this format.","Q_Score":2,"Tags":"python,python-2.7,python-dateutil","A_Id":49816378,"CreationDate":"2018-04-11T11:35:00.000","Title":"Parser.parse changes to wrong time zone","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Basically I downloaded django project from SCM, Usually I run the project with with these steps\n\ngit clone repository\nextract\nchange directory to project folder\npython manage.py runserver \n\nBut this project does not contains manage.py , how to run this project in my local machine???\nbr","AnswerCount":4,"Available Count":1,"Score":0.2449186624,"is_accepted":false,"ViewCount":4321,"Q_Id":49775020,"Users Score":5,"Answer":"Most likely, this is not supposed to be a complete project, but a plugin application. You should create your own project in the normal way with django-admin.py startproject and add the downloaded app to INSTALLED_APPS.","Q_Score":1,"Tags":"python,django","A_Id":49775359,"CreationDate":"2018-04-11T12:21:00.000","Title":"How to run a django project without manage.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a tika code in a server. I want to create an SFTP session with another server with files and run Apache tika on that server. I am using python as back end. Will this work ? is my approach correct ?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":49776224,"Users Score":0,"Answer":"So, what I was planning to do was not ideal . .\nApache Tika requires to scan physical files to fetch metadata. I made a bridge and started from sessions pulling files to the server Tika code was hosted.","Q_Score":0,"Tags":"python,sftp,apache-tika","A_Id":50650506,"CreationDate":"2018-04-11T13:19:00.000","Title":"using apache tika for scanning documents on servers using sftp","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 some add-ins that load on start up. I can't disable this from happening as I don't have administrator rights.\nI am writing a program that opens outlook and sends emails, but it is slowed down by these add ins. Is there a way to programmatically disable add-ins after opening outlook using python (e.g. using the win32com package)? \nI need to do the same thing for Excel too. Any advice would be appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":468,"Q_Id":49779995,"Users Score":1,"Answer":"You can disable the addins by setting the LoadBehavior value appropriately for the problematic addins in HKEY_CURRENT_USER\\Software\\Microsoft\\Office\\Outlook.","Q_Score":0,"Tags":"python,excel,outlook,outlook-addin,excel-addins","A_Id":49780598,"CreationDate":"2018-04-11T16:16:00.000","Title":"Python: How can I disable add-ins in Outlook and Excel?","Data Science and Machine Learning":0,"Database and SQL":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 add-ins that load on start up. I can't disable this from happening as I don't have administrator rights.\nI am writing a program that opens outlook and sends emails, but it is slowed down by these add ins. Is there a way to programmatically disable add-ins after opening outlook using python (e.g. using the win32com package)? \nI need to do the same thing for Excel too. Any advice would be appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":468,"Q_Id":49779995,"Users Score":0,"Answer":"Well the first advice is try to have the administrator rights on your computer to run the py script with no issue\nsecondly i think there is a way to do this as i came across a py lib in github but getting the administrative rights it better as it will be a issue in the future","Q_Score":0,"Tags":"python,excel,outlook,outlook-addin,excel-addins","A_Id":49780058,"CreationDate":"2018-04-11T16:16:00.000","Title":"Python: How can I disable add-ins in Outlook and Excel?","Data Science and Machine Learning":0,"Database and SQL":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 openshift, we are trying to deploy a python module in a pod which is accessed by other python code running in different pods. When i was deploying, the pod is running and immediately crash with status \"Crash Loop Back Off\".This python code is an independent module which does not have valid entrypoint. So how to deploy those type of python modules in openshift. Appreciate for any solutions","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":49783768,"Users Score":0,"Answer":"You don't. You deploy something that can run as a process, and as such, has a capability to contact with the external world in some way (ie. listen for requests, connect to message broker, send requests, read\/write to db etc.) you do not package and deploy libraries that on their own are inoperable to the cluster.","Q_Score":0,"Tags":"python,kubernetes,openshift","A_Id":49784080,"CreationDate":"2018-04-11T20:14:00.000","Title":"Kubernetes OpenShift for 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 new to Python programming and stumbled across this feature of subtracting in python that I can't figure out.  I have two 0\/1 arrays, both of size 400.  I want to subtract each element of array one from its corresponding element in array 2.  \nFor example say you have two arrays A = [0, 1, 1, 0, 0] and B = [1, 1, 1, 0, 1].\nThen I would expect A - B = [0 - 1, 1 - 1, 1 - 1, 0 - 0, 0 - 1] = [-1, 0, 0, 0, -1]\nHowever in python I get [255, 0, 0, 0, 255].\nWhere does this 255 come from and how do I get -1 instead?\nHere's some additional information:\nThe real variables I'm working with are Y and LR_predictions.\nY = array([[0, 0, 0, ..., 1, 1, 1]], dtype=uint8)\nLR_predictions = array([0, 1, 1, ..., 0, 1, 0], dtype=uint8)\nWhen I use either Y - LR_predictions or numpy.subtract(Y, LR_predictions) \nI get: array([[  0, 255, 255, ...,   1,   0,   1]], dtype=uint8)\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5861,"Q_Id":49784499,"Users Score":0,"Answer":"I can't replicate this but it looks like the numbers are 8 bit and wrapping some how","Q_Score":0,"Tags":"python,arrays,math,subtraction","A_Id":49784641,"CreationDate":"2018-04-11T21:08:00.000","Title":"Python - Subtracting the Elements of Two Arrays","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been using Python for a few months, but I'm sort of new to Files. I would like to know how to save text files into my Documents, using \".txt\".","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":546,"Q_Id":49786119,"Users Score":0,"Answer":"If you do not like to overwrite existing file then use a or a+ mode. This just appends to existing file. a+ is able to read the file as well","Q_Score":2,"Tags":"python","A_Id":49787478,"CreationDate":"2018-04-12T00:14:00.000","Title":"How do I save a text file in python, to my File Explorer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently started to use Google Colab to train my CNN model. It always needs about 10+ hours to train once. But I cannot stay in the same place during these 10+ hours, so I always poweroff my notebook and let the process keep going.\nMy code will save models automatically. I figured out that when I disconnect from the Colab, the process are still saving models after disconnection.\nHere are the questions:\n\nWhen I try to reconnect to the Colab notebook, it always stuck at \"INITIALIZAING\" stage and can't connect. I'm sure that the process is running. How do I know if the process is OVER?\nIs there any way to reconnect to the ongoing process? It will be nice to me to  observe the training losses during the training.\n\nSorry for my poor English, thanks alot.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3496,"Q_Id":49790025,"Users Score":0,"Answer":"It seems there's no normal way to do this. But you can save your model to Google Drive with current training epoch number, so when you see something like \"my_model_epoch_1000\" on your google drive, you will know that the process is over.","Q_Score":5,"Tags":"python,deep-learning,keras,jupyter-notebook,google-colaboratory","A_Id":49856665,"CreationDate":"2018-04-12T07:02:00.000","Title":"How to reconnect to the ongoing process on GoogleColab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently started to use Google Colab to train my CNN model. It always needs about 10+ hours to train once. But I cannot stay in the same place during these 10+ hours, so I always poweroff my notebook and let the process keep going.\nMy code will save models automatically. I figured out that when I disconnect from the Colab, the process are still saving models after disconnection.\nHere are the questions:\n\nWhen I try to reconnect to the Colab notebook, it always stuck at \"INITIALIZAING\" stage and can't connect. I'm sure that the process is running. How do I know if the process is OVER?\nIs there any way to reconnect to the ongoing process? It will be nice to me to  observe the training losses during the training.\n\nSorry for my poor English, thanks alot.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3496,"Q_Id":49790025,"Users Score":0,"Answer":"first question: restart runtime from runtime menu\nsecond question: i think you can use tensorboard to monitor your work.","Q_Score":5,"Tags":"python,deep-learning,keras,jupyter-notebook,google-colaboratory","A_Id":49854222,"CreationDate":"2018-04-12T07:02:00.000","Title":"How to reconnect to the ongoing process on GoogleColab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I eliminate a dummy dimension in python numpy ndarray?\nFor example, suppose that A.shape = (0, 1325, 3),\nthen how can eliminate '0' dimension so that A.shape = (1325,3).  \nBoth 'np.sqeeze(A)' or 'A.reshape(A.shape[1:])' don't work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":118,"Q_Id":49797656,"Users Score":3,"Answer":"You can't eliminate that 0 dimension.  A dimension of length 0 is not a \"dummy\" dimension.  It really means length 0.  Since the total number of elements in the array (which you can check with a.size) is the product of the shape attribute, an array with shape (0, 1325, 3) contains 0 elements, while an array with shape (1325, 3) contains 3975 elements.  If there was a way to eliminate the 0 dimension, where would that data come from?  \nIf your array is supposed to contain data, then you probably need to look at how that array was created in the first place.","Q_Score":1,"Tags":"python,numpy","A_Id":49797871,"CreationDate":"2018-04-12T13:18:00.000","Title":"How to eliminate a dummy dimension of ndarray?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a some automation work, as per my requirement I need to click on Chrome Physical buttons like left nav, right nav, bookmarks, menu etc. I can do with shortcuts but my requirement is to click on browser buttons. Any ideas would be helpful. Thanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1530,"Q_Id":49799864,"Users Score":0,"Answer":"This can't be done with selenium webdriver and I think also not with the standalone selenium server. Selenium only allows to interact with the DOM.\nThe only way to achieve what you want to do is to use an automation tool that actually runs directly in the OS that you use. Java can be used to write such a program.\nI would however recommend to not go this route. Instead try to convince whoever is responsible for your requirements to re-think and allow to use other means of achieving back and forward actions.","Q_Score":0,"Tags":"java,python,google-chrome,selenium,selenium-chromedriver","A_Id":49800000,"CreationDate":"2018-04-12T15:00:00.000","Title":"Selenium click chrome physical buttons like menu, left, right navigation, bookmarks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The pycharm cannot find python 2.7.14\nI have just update the version of python from 2.7.10 to 2.7.14. When I check the version in terminal by python --version or python2 --version, the version is 2.7.14.\nHowever, when I am using pycharm, it still use the 2.7.10 and I cannot find python 2.7.14.\nI have try \/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin\/python --version, and the version is 2.7.14. When I try \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin\/python2.7 --version the version is 2.7.10.\nso how can I delete the version of 2.7.10 and set pycharm as 2.7.14?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":62,"Q_Id":49800112,"Users Score":1,"Answer":"Python is a necessary library for the mac os system, so DO NOT DELETE IT at all costs, you'll break your OS. You need to tell PyCharm to use another Python version, which can be found under settings (Python Interpreter), where you'll be able to find your new version.","Q_Score":1,"Tags":"python,macos,python-2.7,pycharm","A_Id":49800170,"CreationDate":"2018-04-12T15:11:00.000","Title":"In Mac OS, Pycharm cannot find python 2.7.14","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would highly appreciate any help on this. I'm constructing dynamic highcharts at the backend and would like to send the data along with html to the frontend. \nIn highcharts, there is a specific field to accept Date such as:\nx:Date.UTC(2018,01,01)\nor x:2018-01-01. However, when I send dates from the backend, it is always surrounded by quotes,so it becomes: x:'Date.UTC(2018,01,01)'\nand x:'2018-01-01', which does not render the chart. Any suggestions on how to escape these quotes?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":49804663,"Users Score":0,"Answer":"Highcharts expects the values on datetime axes to be timestamps (number of miliseconds from 01.01.1970). Date.UTC is a JS function that returns a timestamp as Number. Values surrounded by apostrophes are Strings.\nI'd rather suggest to return a timestamp as a String from backend (e.g. '1514764800000') and then convert it to Number in JS (you can use parseInt function for that.)","Q_Score":0,"Tags":"python,jquery,web,highcharts,web.py","A_Id":49812323,"CreationDate":"2018-04-12T19:41:00.000","Title":"Send data from Python backend to Highcharts while escaping quotes for date","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying the run the TF object detection locally on my own dataset. Every step is happening perfectly except the Visualization of the BB on a test image.\nFirst I have run the Pascal VOC dataset on the Faster R-CNN Inception ResNet v2, modified the scripts as per the VOC dataset and Then followed the instructions from G3doc, everything worked perfectly, for the visualization, I am using the ipython jupyter notebook given in the objection detection. The visualization was awesome.\nThen I tried to do the same for my own dataset. Repeated all the steps same but no BB is showing on the image.\nCan someone help what might be going wrong?\nP.S. I am using ubuntu 16.04, 64GB ram system.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1054,"Q_Id":49805206,"Users Score":2,"Answer":"Try passing the bounding boxes to a print statement. Do you get any valid output? If so then it is probably nothing to do with your model and your bounding boxes are created just fine. What is your mAP? If it is very early on in the training process then your accuracy is probably too poor and do not meet a minimum threshold.\nTake a look at the visualize_boxes_and_labels_on_image_array() function from object_detection\/utils\/visualization_utils.py, note the default value for min_score_thresh. You can either change this default value or pass in min_score_thres=0 as an argument when you call the function.","Q_Score":0,"Tags":"python,tensorflow,ubuntu-16.04,object-detection","A_Id":51196523,"CreationDate":"2018-04-12T20:17:00.000","Title":"tensorflow Object detection, Bounding Boxes are not visible on the own dataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Trying to install quandl and need pandas, so I tried pip install pandas and get:\n\nCould not find a version that satisfies the requirement numpy==1.9.3 (from versions: 1.10.4, 1.11.0, 1.11.1rc1, 1.11.1, 1.11.2rc1, 1.11.2, 1.11.3, 1.12.0b1, 1.12.0rc1, 1.12.0rc2, 1.12.0, 1.12.1rc1, 1.12.1, 1.13.0rc1, 1.13.0rc2, 1.13.0, 1.13.1, 1.13.3, 1.14.0rc1, 1.14.0, 1.14.1, 1.14.2)\nNo matching distribution found for numpy==1.9.3.\n\nI'm using python 3.4, win32","AnswerCount":11,"Available Count":2,"Score":0.0363476168,"is_accepted":false,"ViewCount":57246,"Q_Id":49805576,"Users Score":2,"Answer":"Just Install Python 3.5 or higher.","Q_Score":9,"Tags":"python,python-3.x,pandas,numpy,quandl","A_Id":51225714,"CreationDate":"2018-04-12T20:45:00.000","Title":"Could not find a version that satisfies the requirement numpy == 1.9.3","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Trying to install quandl and need pandas, so I tried pip install pandas and get:\n\nCould not find a version that satisfies the requirement numpy==1.9.3 (from versions: 1.10.4, 1.11.0, 1.11.1rc1, 1.11.1, 1.11.2rc1, 1.11.2, 1.11.3, 1.12.0b1, 1.12.0rc1, 1.12.0rc2, 1.12.0, 1.12.1rc1, 1.12.1, 1.13.0rc1, 1.13.0rc2, 1.13.0, 1.13.1, 1.13.3, 1.14.0rc1, 1.14.0, 1.14.1, 1.14.2)\nNo matching distribution found for numpy==1.9.3.\n\nI'm using python 3.4, win32","AnswerCount":11,"Available Count":2,"Score":0.0181798149,"is_accepted":false,"ViewCount":57246,"Q_Id":49805576,"Users Score":1,"Answer":"Just use this command :\npip install pandas==0.19.0 .\nAn older version which will not cry with this error !!","Q_Score":9,"Tags":"python,python-3.x,pandas,numpy,quandl","A_Id":51056520,"CreationDate":"2018-04-12T20:45:00.000","Title":"Could not find a version that satisfies the requirement numpy == 1.9.3","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 options here: I can go to Python's website and select the link that says python for windows and download the language from there, and then use any supported compiler-interpreter linker and debugger for it. The other alternative is I can choose Python Deployment from Visual Studio's 2017 Installer. The current version in the Visual Studio installer for Python is 3.6.3 which I'm fairly sure that if I install it into Visual Studio and there are any updates Visual Studio will let me know. If I choose to download Python from their website there newest version is 3.6.5. I'm not too concerned about the differences in the versions. I just need to have a working version of the language with a supported compiler - interpreter... \nIs there any major difference from choosing the one over the other? I read through the MS docs about their tools for Visual Studio on Python and they do claim that if you already have it installed there is no need to check the boxes to install the core language through their installer as it will automatically detect if you have Python installed. For Windows 7 and Visual Studio 2017 which is more preferable: downloading Python from their website directly and then integrating it into Visual Studio; or just letting Visual Studio install its version for me? I am new to python; but I need a working version of it in order to build binaries for MPIR - MPFR - MPFRCPP.\nThe reason I asked is if I chose to install all the available options under Visual Studio it is about 18GB in size which would include Python's tools and different versions of Anaconda. However the Visual Studio documents also stated if you decide to use Python for Data Science to also select the Data Science & Analytical Applications from the workloads section. This would add about another 2GB. This would take some time to download and install postponing any and all of my project developments. I just want to know what I'm in store for and what is the better of my two options.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":199,"Q_Id":49807452,"Users Score":1,"Answer":"For Windows 7 and Visual Studio 2017 which is more preferable: downloading Python from their website directly and then integrating it into Visual Studio; or just letting Visual Studio install its version for me?\n\nJust let Visual Studio 2017 download it for you, it is much more easy, but still the choice still depends on you because installing it through VS or their Website is likely the same.","Q_Score":0,"Tags":"python,installation,windows-7,visual-studio-2017","A_Id":49807570,"CreationDate":"2018-04-13T00:01:00.000","Title":"Python Support for Windows 7 in Visual Studio 2017","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have around 20TB of time series data stored in big query.\nThe current pipeline I have is:\nraw data in big query => joins in big query to create more big query datasets => store them in buckets\nThen I download a subset of the files in the bucket:\nWork on interpolation\/resampling of data using Python\/SFrame, because some of the time series data have missing times and they are not evenly sampled.\nHowever, it takes a long time on a local PC, and I'm guessing it will take days to go through that 20TB of data.\n\nSince the data are already in buckets, I'm wondering what would the best Google tools for interpolation and resampling?\nAfter resampling and interpolation I might use Facebook's Prophet or Auto ARIMA to create some forecasts. But that would be done locally.\n\nThere's a few services from Google that seems are like good options.\n\nCloud DataFlow: I have no experience in Apache Beam, but it looks like the Python API with Apache Beam have missing functions compared to the Java version? I know how to write Java, but I'd like to use one programming language for this task.\nCloud DataProc: I know how to write PySpark, but I don't really need any real time processing or stream processing, however spark has time series interpolation, so this might be the only option?\nCloud Dataprep: Looks like a GUI for cleaning data, but it's in beta. Not sure if it can do time series resampling\/interpolation.\n\nDoes anyone have any idea which might best fit my use case?\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":522,"Q_Id":49809084,"Users Score":0,"Answer":"I would use PySpark on Dataproc, since Spark is not just realtime\/streaming but also for batch processing. \nYou can choose the size of your cluster (and use some preemptibles to save costs) and run this cluster only for the time you actually need to process this data. Afterwards kill the cluster.\nSpark also works very nicely with Python (not as nice as Scala) but for all effects and purposes the main difference is performance, not reduced API functionality.\nEven with the batch processing you can use the WindowSpec for effective time serie interpolation\nTo be fair: I don't have a lot of experience with DataFlow or DataPrep, but that's because out use case is somewhat similar to yours and Dataproc works well for that","Q_Score":1,"Tags":"python,apache-spark,google-cloud-platform,google-cloud-dataflow,google-cloud-dataproc","A_Id":49812019,"CreationDate":"2018-04-13T03:56:00.000","Title":"Google Cloud - What products for time series data cleaning?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was trying to use the new liberary request-html.\nBut when i use the render() function to parse a javascript page, it always pop up with the notes as below:\n\nError in atexit._run_exitfuncs: Traceback (most recent call last):\n  File \"C:\\Program Files\n  (x86)\\Python36-32\\lib\\site-packages\\pyppeteer\\launcher.py\", line 201,\n  in killChrome\n      self._cleanup_tmp_user_data_dir()   File \"C:\\Program Files (x86)\\Python36-32\\lib\\site-packages\\pyppeteer\\launcher.py\", line 130,\n  in _cleanup_tmp_user_data_dir\n      raise IOError('Unable to remove Temporary User Data') OSError: Unable to remove Temporary User Data\n\nI tried to solve the problems, but it seems that there is no solution right now. So i kind of hope someone here can help me. \nPS: it seems that i can not post it with the tag:requests-html, i do not have enought repution. So, very sorry for that.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2313,"Q_Id":49809600,"Users Score":0,"Answer":"I fixed this issue by switch to the administrator mode.","Q_Score":4,"Tags":"javascript,python,request,render","A_Id":54684002,"CreationDate":"2018-04-13T04:59:00.000","Title":"IOError happened while use requests-html to render a javascript page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I already have installed tensorflow 1.2, CUDA 8.0 and CuDNN 5.1 for python2.7. Now I want to use it for python3.5 but importing tensorflow fails. How do I install tensorflow for python3 again. And do I have to do the CUDA and CuDNN episodes again?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1667,"Q_Id":49811510,"Users Score":2,"Answer":"If you have already installed tensorflow 1.2, CUDA 8.0 and CuDNN 5.1 for python2.7. Then you can:\n\nyum install python3-pip\n\n(now you have python3 and pip3, however the python version may not be 3.5)\n\npython3 -m pip install --upgrade tensorflow-gpu==1.2\n\n(make sure the installed version is exactly same as that of python2)\nI made it after these two steps.","Q_Score":0,"Tags":"python-3.x,tensorflow","A_Id":57368807,"CreationDate":"2018-04-13T07:24:00.000","Title":"How to install tensorflow-gpu for both python2 and python3","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project in my school which requires me to install a couple python libraries. We have been blocked from using the CMD on the school computers which has proved problematic as this is the only way I know of which allows me to easily install any libraries. I also cannot see the location of the python install, I believe they are on some server which we do not have access too (although I am not confident in the matter). I believe each student is allocated  space on the server so I can install some things from the internet (however quite a few things are blocked). Most of my class has overcome this by using their own laptops however this isn't an option for me. If needs be I can try install anything at home to bring into school on a memory stick. The school computers use windows 10 and python 3.6. If there's any more information you may need please say. Thank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":49813052,"Users Score":0,"Answer":"If you can install PyCharm then it has its terminal\/cmd through you can install your python library. But important thing is that you must have permission to do it as you said you are on common server of the school.","Q_Score":0,"Tags":"python,python-3.x","A_Id":49813326,"CreationDate":"2018-04-13T08:58:00.000","Title":"Alternative install for python libraries?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to extract mimetype with magic number from iWork suite.\nHow do? Exiftool see \".pages\" etc. as \"application\/zip\". But the real mimetype isn't this. \nHow can i extract the correct mime?\nI can use an validation with python tool if needed. \n\"Apline for docker\".\nThanks for help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":283,"Q_Id":49814102,"Users Score":0,"Answer":"Phil Harvey has \"Improved identification of Apple iWork files\" in exiftool version 10.96.  Check to see if that works for you.","Q_Score":0,"Tags":"python,alpine,exiftool,iwork","A_Id":50262989,"CreationDate":"2018-04-13T09:51:00.000","Title":"How extract iWorks suite mimetype with Exiftool","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The small problem is, when I press Ctrl+F5, I want the code to be run immediately; but I have to\nSelect environment:\n\nPython\nPython Exprimental\nall the time. Is there a way to set default env in settings so I don't have to choose at each run?","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":12286,"Q_Id":49817786,"Users Score":4,"Answer":"File > Preferences > Settings > User tab > Extensions > python > Python Path \ntype your python path e.g.: c:\\python35\\python.exe","Q_Score":12,"Tags":"python,visual-studio-code","A_Id":56696013,"CreationDate":"2018-04-13T13:07:00.000","Title":"How to preselect (set default) python interpreter in python visual code extension?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use tensorflow-gpu. Using Anaconda, I installed the libraries and active both (tensorflow and tensorflow-gpu) I have also installed Keras in this anaconda environment as well\nNext I launch Spider IDE within my Anaconda environment and run my py script, that is when I get the following error:\ncannot import tensorflow - Import Error: cannot import name 'self_check'\nI'm totally lost. Any recommendations? \nUsing Python 3.5\nThanks","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2441,"Q_Id":49819253,"Users Score":2,"Answer":"pip install --upgrade tensorflow\nor\nyou can uninstall the tensorflow and re-install it.","Q_Score":2,"Tags":"python,tensorflow,anaconda","A_Id":50134947,"CreationDate":"2018-04-13T14:26:00.000","Title":"cannot import tensorflow - \"Import Error: cannot import name 'self_check' \"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to implement l1-regularization in Tensorflow using the l1_regularization_strength parameter in the ProximalAdagradOptimizer function from Tensorflow. (I am using this optimizer specifically to get a sparse solution.) I have two questions regarding the regularization.\n\nDoes the l1-regularization used in the optimizer apply to forward and backward propagation for a neural network or only the back propagation?\nIs there a way to break down the optimizer so the regularization only applies to specific layers in the network?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":425,"Q_Id":49824281,"Users Score":1,"Answer":"Regularization applies neither to forward or backpropagation but to the weight updates.\nYou can use different optimizers for different layers by explicitly passing the variables to minimize to each optimizer.","Q_Score":1,"Tags":"python,optimization,tensorflow,neural-network,regularized","A_Id":49908382,"CreationDate":"2018-04-13T19:58:00.000","Title":"Regularization Application in the Proximal Adagrad Optimizer in Tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a object with many fields. Each field has different range of values. I want to use hypothesis to generate different instances of this object.\nIs there a limit to the number of combination of field values Hypothesis can handle?  Or what does the search tree hypothesis creates look like? I don't need all the combinations but I want to make sure that I get a fair number of combinations where I test many different values for each field. I want to make sure Hypothesis is not doing a DFS until it hits the max number of examples to generate","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":75,"Q_Id":49825415,"Users Score":1,"Answer":"TLDR: don't worry, this is a common use-case and even a naive strategy works very well.\nThe actual search process used by Hypothesis is complicated (as in, \"lead author's PhD topic\"), but it's definitely not a depth-first search!  Briefly, it's a uniform distribution layered on a psudeo-random number generator, with a coverage-guided fuzzer biasing that towards less-explored code paths, with strategy-specific heuristics on top of that.\nIn general, I trust this process to pick good examples far more than I trust my own judgement, or that of anyone without years of experience in QA or testing research!","Q_Score":1,"Tags":"python-hypothesis","A_Id":49838147,"CreationDate":"2018-04-13T21:32:00.000","Title":"Hypothesis search tree","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to create a strategy C that, 90% of the time chooses strategy A, and 10% of the time chooses strategy B.\nThe random python library does not work even if I seed it since each time the strategy produces values, it generates the same value from random.\nI looked at the implementation for OneOfStrategy and they use \n            i = cu.integer_range(data, 0, n - 1)\nto randomly generate a number\ncu is from the internals\nimport hypothesis.internal.conjecture.utils as cu\nWould it be fine for my strategy to use cu.integer_range or is there another implementation?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":172,"Q_Id":49827010,"Users Score":3,"Answer":"Hypothesis does not allow users to control the probability of various choices within a strategy.  You should not use undocumented interfaces either - hypothesis.internal is for internal use only and could break at any time!\nI strongly recommend using C = st.one_of(A, B) and trusting Hypothesis with the details.","Q_Score":0,"Tags":"python-hypothesis","A_Id":49838288,"CreationDate":"2018-04-14T01:27:00.000","Title":"Have a Strategy that does not uniformly choose between different strategies","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed the word cloud library in python to use wordcloud. I am able to successfully use it in all editors like sublime, etc but when I am trying to use it in Jupyter notebook then it is giving me error:\nDLL load failed: The specified module could not be found\nI have been trying to solve this issue from last 2 days but not getting success. I would appreciate any kind of help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":412,"Q_Id":49827515,"Users Score":0,"Answer":"I too faced this issue.\nthe problem was when wordcloud is installed it gets python modules and stores in \n**C:\\Python27\\Lib\\site-packages** folder (in my case this is the python executable path this may vary for you) so when you import from jupyter it tries to find it in this path , but wordcloud creates one more folder with same name and downloads all wordcloud module in side this , this is one more level in directory so jupyter is unable to find. so the hack what i did is copied all modules from inner wordclod folder to one level outside i.e \n\ncopy all from C:\\Python27\\Lib\\site-packages\\wordcloud\\wordcloud ->\n  C:\\Python27\\Lib\\site-packages\\wordcloud\n\nso this made the trick and no more error.","Q_Score":1,"Tags":"python-3.x,jupyter-notebook,word-cloud","A_Id":50158768,"CreationDate":"2018-04-14T03:11:00.000","Title":"\"DLL load failed: The specified module could not be found\" error on using wordcloud in Jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I am trying to mimic human typing best as possible. Right now I am using pyautogui.typewrite(\"what i want to type\") to type and it is basically pasting it, is there anyway i can get it to maybe type the letters one by one but in a quick manner?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":334,"Q_Id":49828473,"Users Score":1,"Answer":"In order to mimic human typing as best as possible you need to study human (for example your own) typing first creating a database of \"time distances\" between the strokes of single keys within different words and use this database for setting the time.sleep(timeDistance) in the for e in text: loop (see the answer by \u1d21\u029c\u1d00\u1d04\u1d0b\u1d00\u1d0d\u1d00\u1d05\u1d0f\u1d0f\u1d05\u029f\u1d073000). \nAnother approach to understand how to mimic human typing as best as possible is to try to write an own detector of automated typing. Humans tend to repeat given patterns of own typing behavior with \"time distances\" between given combinations of keystrokes that don't vary by chance (hence the need for a database depending on the keystroke sequences).","Q_Score":1,"Tags":"python,web,automation,pyautogui","A_Id":49836015,"CreationDate":"2018-04-14T06:05:00.000","Title":"Python Automating Typing On Webpage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I was watching a video about installing pygame, and it told me to download the link from pygame  the most recent one. So I downloaded that and kept pressing the 'next' in wizard setup in order to install it. However, then when I did 'import pygame' it didn't work. Then on the pygame website it gave me this command to type into cmd promt - 'py -m pip install -U pygame --user'. Then when I did that and did import pygame, it didn't come up with an error. But I'm confused because the pygame I downloaded is in downloads, so I deleted it and removed it completely of computer, but import pygame still works. Why is this so? Sorry, I'm very much a noob at downloading\/installing stuff and I get concerned about small things like this, but if anyone could tell me why 'import pygame' still works, and if I even needed to download pygame in the first place, I'd very much appreciate it. Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":49831264,"Users Score":0,"Answer":"When you downloaded pygame, then it just get downloaded as a setup in your computer. For now, it isn't installed in your computer. So, importing it will not work, because python can't find that file installed in python root folder\nBut as soon as you execute this command py -m pip install -U pygame --user, then pip looks for a package  named pygame in your computer, and install it then the installed file of pygame moves somewhere in python root folder. So, Now importing pygame will work. \nAnd you said that you deleted the downloaded file. So, Python will not be affected anyways, because that was only a setup. Main stuff, which is the installed file get moved in python root folder. As a result it is still in your computer. So, importing pygame would definitely work, because python can still find pygame in its root folder.\nSo, this is how all this works!","Q_Score":0,"Tags":"python,pygame","A_Id":49831350,"CreationDate":"2018-04-14T12:07:00.000","Title":"New PC pygame concerns","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a website on AppEngine that is 99% static. It is running on Python 2.7 runtime. Now the time has come to evolve this webapp, and since I have almost none Python code in it, I'd prefer to write it in Go instead.\nCan I change runtime from Python 2.7 to Go, while keeping the project intact? Specifically, I want to keep the same app-ID, the same custom domain attached to it, the same SSL certificate, and so on. \nWhat do I have to do in order to do that? I surely have to change runtime in the app.yaml. Is there anything else?\nBonus question: will such change happen without a downtime?\nI'd be grateful for any links to documentation on exactly that (swapping runtime on a live app). I can't find any.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":562,"Q_Id":49831512,"Users Score":4,"Answer":"Specify a runtime as well as a new value for version.  When deployed you'll have an older version that is Python and a newer version that is Go.  There won't be any downtime (same as when deploying a newer version of Python).\nRather than trusting links\/docs (that may be out of date or not 100% exactly what you're trying to do), why not create a new GAE-Std project for testing purposes and try it yourself.  Having a GAE-Std test project is good for testing new function (especially by other testers who won't have access to the dev environ on your laptop).","Q_Score":2,"Tags":"google-app-engine,google-app-engine-python,google-app-engine-go","A_Id":49832513,"CreationDate":"2018-04-14T12:34:00.000","Title":"Change runtime from Python to Go in App Engine standard environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm working on a project on pythonanywhere.com and my code in Python (with Flask framework) manages requests of an Android app that wants to access the MySQL database.\nThe point is that I would like a notification to arrive on the Android smartphone when a row is added to a database table.\nIf I understand correctly, from Python to Android I can use Firebase Cloud Messaging, but I'm not sure what to use from MySQL to Python: a trigger that calls a script that will send the notification? Or Python listening to the database? Or what else?\nRemember that I'm not using personal servers and databases but those offered by the above mentioned domain so I'm not sure I can use everything I want (for example, if I'm not mistaken, it is not possible to implore a UDF).\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":862,"Q_Id":49833921,"Users Score":1,"Answer":"Where is the row added from ? If from Flask app you can use Signals in Model to send notification when the new row is added","Q_Score":0,"Tags":"android,python,mysql,firebase,push-notification","A_Id":49833949,"CreationDate":"2018-04-14T16:56:00.000","Title":"Python - send notification to Android app after the MySQL database has changed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to make something in python, but this always appears\n\nCannot update file menu Recent File list Your operating system says\n  [Errrno 13] Premission denied:\n  C:\\Users\\Eigenaar\\.idlerc\\recent-file.Ist\n  Select OK and IDLE will continue without updating.\n\nI read the answers here but nothing works!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":390,"Q_Id":49834648,"Users Score":0,"Answer":"I have the exact same problem. And, yes, it happens every time that I open IDLE. \nI have Python 3.6.5 in a folder in Program Files, while the files that I have written are in a folder labeled Python under C:\\Users\\John\\Documents.\nI have a hunch that Python wants the files that I have written in a different location, perhaps under C:\\Users\\John.idlerc?\nWhat do folks think?\nJohnR\nPS ~ I didn't see on this web page where to find the answers that others wrote to the original inquiry.","Q_Score":0,"Tags":"python","A_Id":50284449,"CreationDate":"2018-04-14T18:14:00.000","Title":"Cannot update file menu Recent File list Your operating system says [Errrno 13] Premission denied: C:\\\\Users\\\\Eigenaar\\\\.idlerc\\\\recent-file.Ist","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have to handle sparse matrix that can occasionally be very big, nearing or exceeding RAM capacity. I also need to support mat*vec and mat*mat operations.\nSince internally a csr_matrix is 3 arrays data, indices and indptr is it possible to create a csr matrix from numpy memmap.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":517,"Q_Id":49835342,"Users Score":1,"Answer":"This can partially work, until you try to do much with the array. There's a very good chance the subarrays will be fully read into memory if you subset, or you'll get an error.\nAn important consideration here is that the underlying code is written assuming the arrays are typical in-memory numpy arrays. Cost of random access is very different for mmapped arrays and in memory arrays. In fact, much of the code here is (at time of writing) in Cython, which may not be able to work with more exotic array types.\nAlso most of this code can change at any time, as long as the behaviour is the same for in-memory arrays. This has personally bitten me when some I learned some code I worked with was doing this, but with h5py.Datasets for the underlying arrays. It worked surprisingly well, until a bug fix release of scipy completely broke it.","Q_Score":1,"Tags":"python,numpy,scipy,sparse-matrix","A_Id":62990659,"CreationDate":"2018-04-14T19:26:00.000","Title":"Using memory mapped buffers for scipy sparse","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to handle sparse matrix that can occasionally be very big, nearing or exceeding RAM capacity. I also need to support mat*vec and mat*mat operations.\nSince internally a csr_matrix is 3 arrays data, indices and indptr is it possible to create a csr matrix from numpy memmap.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":517,"Q_Id":49835342,"Users Score":-2,"Answer":"This works without any problems.","Q_Score":1,"Tags":"python,numpy,scipy,sparse-matrix","A_Id":50985982,"CreationDate":"2018-04-14T19:26:00.000","Title":"Using memory mapped buffers for scipy sparse","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After I instantiate a scikit model (e.g. LinearRegression), if I call its fit() method multiple times (with different X and y data), what happens? Does it fit the model on the data like if I just re-instantiated the model (i.e. from scratch), or does it keep into accounts data already fitted from the previous call to fit()?\nTrying with LinearRegression (also looking at its source code) it seems to me that every time I call fit(), it fits from scratch, ignoring the result of any previous call to the same method. I wonder if this true in general, and I can rely on this behavior for all models\/pipelines of scikit learn.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":28564,"Q_Id":49841324,"Users Score":6,"Answer":"You can use term fit() and train() word interchangeably in machine learning. Based on classification model you have instantiated, may be a clf = GBNaiveBayes() or clf = SVC(),  your model uses specified machine learning technique.\nAnd as soon as you call clf.fit(features_train, label_train) your model starts training using the features and labels that you have passed.\nyou can use clf.predict(features_test) to predict.\nIf you will again call clf.fit(features_train2, label_train2) it will start training again using passed data and will remove the previous results. Your model will reset the following inside model:\n\nWeights\nFitted Coefficients\nBias\nAnd other training related stuff...\n\nYou can use partial_fit() method as well if you want your previous calculated stuff to stay and additionally train using next data","Q_Score":58,"Tags":"python,machine-learning,scikit-learn","A_Id":49841568,"CreationDate":"2018-04-15T11:19:00.000","Title":"What does calling fit() multiple times on the same model do?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I call any function in python3.6, I get the error below; however, it works fine in python3.4. Any idea? \nimport tensorflow as tf \ntf.Session()\nTraceback (most recent call last):\n  File \"\", line 1, in \nAttributeError: module 'tensorflow' has no attribute 'Session'\n\nHere is my  System information\n\n\nOS Platform and Distribution (e.g., Linux Ubuntu 16.04): Debian 8.7 \nTensorFlow installed from (source or binary): by pip3\nTensorFlow version (use command below): 1.7.0\nPython version: 3.6.5\nCUDA\/cuDNN version: cuda 9.0 and cudnn 7.0\nGPU model and memory: K80, 12 GB \nExact command to reproduce:\nimport tensorflow as tf \ntf.Session()","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":18023,"Q_Id":49846106,"Users Score":0,"Answer":"With the new version of python3.6 my problem is solved. \nI removed my previous python3.6 and installed the newest version. Then installed tensorflow through pip and it works.","Q_Score":3,"Tags":"tensorflow,python-3.6","A_Id":54985155,"CreationDate":"2018-04-15T19:47:00.000","Title":"AttributeError: module 'tensorflow' has no attribute 'Session'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have build an app in django to extract data from an mssql server and display the results on a table on a template.\nwhat i want to do now is to export the same sql query results to an excel file. I have used pymssql driver to connect to the db and pysqlalchemy.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":712,"Q_Id":49848167,"Users Score":0,"Answer":"my code actually worked. I thought it was going to save the excel file to 'C:\\excel' folder so i was looking for the file in the folder but i couldn't find the excel file. The excel file was actually exported to my django project folder instead. \nHow to i allow the end user to be able to download the file to their desktop instead of exporting it to the server itself","Q_Score":1,"Tags":"python,sql-server,django,sqlalchemy,django-views","A_Id":49850520,"CreationDate":"2018-04-16T00:36:00.000","Title":"python and Django export mssql query to excel","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I built a image classification model using convolutional neural network for 5 classes.It is giving the training accuracy as 100% and testing accuracy as 82%. But when I gave an image manually for predicting, the model is not able to classify them correctly.For 10 images the model is classifying only 3-4 images correctly.What is the mistake? What should I do??","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":49849715,"Users Score":0,"Answer":"This means that you are clearly overfitting.\nYour model is not able to generalize well to the images that you enter manually.\nThere are a few things that you could do.\n\nYou could try regularization so that your model does not overfit.\nTry getting more data\nData augmentation\n\nI hope that by introducing regularization, your model would work better on manually entered images.","Q_Score":0,"Tags":"python,tensorflow,classification,conv-neural-network","A_Id":49849810,"CreationDate":"2018-04-16T04:34:00.000","Title":"Regarding image classification using CNN","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I built a image classification model using convolutional neural network for 5 classes.It is giving the training accuracy as 100% and testing accuracy as 82%. But when I gave an image manually for predicting, the model is not able to classify them correctly.For 10 images the model is classifying only 3-4 images correctly.What is the mistake? What should I do??","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":49849715,"Users Score":0,"Answer":"Your model is not able to generalize properly. the training has gone very quickly through all the images in the training set and even started making predictions on the same images.  \n\nTry adding images and of different sizes.   \nTry flipping the    original images horizontally to create transformed images that might  also help in accurately training your model.","Q_Score":0,"Tags":"python,tensorflow,classification,conv-neural-network","A_Id":51365356,"CreationDate":"2018-04-16T04:34:00.000","Title":"Regarding image classification using CNN","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I built a image classification model using convolutional neural network for 5 classes.It is giving the training accuracy as 100% and testing accuracy as 82%. But when I gave an image manually for predicting, the model is not able to classify them correctly.For 10 images the model is classifying only 3-4 images correctly.What is the mistake? What should I do??","AnswerCount":4,"Available Count":3,"Score":-0.049958375,"is_accepted":false,"ViewCount":116,"Q_Id":49849715,"Users Score":-1,"Answer":"Besides that, probably your training set has way easier images than your test set (those image that you give manually). That can happen even if you are feeding the network from the same dataset.\nTo have better results on unseen images, you must have to reach a good generalisation level. Try what is said previously above...","Q_Score":0,"Tags":"python,tensorflow,classification,conv-neural-network","A_Id":70926699,"CreationDate":"2018-04-16T04:34:00.000","Title":"Regarding image classification using CNN","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm quite new to Python, and was wondering how I flatten the following nested list using list comprehension, and also use conditional logic.\nnested_list = [[1,2,3], [4,5,6], [7,8,9]]\nThe following returns a nested list, but when I try to flatten the list by removing the inner square brackets I get errors. \nodds_evens = [['odd' if n % 2 != 0 else 'even' for n in l] for l in nested_list]","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":630,"Q_Id":49850821,"Users Score":-1,"Answer":"To create a flat list, you need to have one set of brackets in comprehension code. Try the below code:\nodds_evens = ['odd' if n%2!=0 else 'even' for n in l for l in nested_list]\nOutput:\n['odd', 'odd', 'odd', 'even', 'even', 'even', 'odd', 'odd', 'odd']","Q_Score":3,"Tags":"python","A_Id":49850915,"CreationDate":"2018-04-16T06:29:00.000","Title":"Nested list comprehension to flatten nested list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here I've got a string looks like that '128,120,119,118,119,118,120,116,116,120,128,121' \nI want to make it to be a list like this\n[128,120,119,118,119,118,120,116,116,120,128,121]\nSo I have ever tried a command 'list' in python to make it be a list\nHowever, the result looks like that ['1', '2', '8', ',', '1', '2', '0', ',', '1', '1', '9', ',', '1', '1', '8', ',', '1', '1', '9', ',', '1', '1', '8', ',', '1', '2', '0', ',', '1', '1', '6', ',', '1', '1', '6', ',', '1', '2', '0', ',', '1', '2', '8', ',', '1', '2', '1'].\nAlthough the type of the string data is list, the cutting point is wrong.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":142,"Q_Id":49852018,"Users Score":0,"Answer":"Add a simple statement:\n\nd=[int(c) for c in b]\n\nwhere b=['1','2',....]","Q_Score":0,"Tags":"python","A_Id":49852165,"CreationDate":"2018-04-16T07:45:00.000","Title":"How to split a string into a list in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to upgrade my Python version from 2.6.6 to the newest version of 3.6.5 on a server. However, there is a program that has been running for multiple days and will be running for a week or more.\nWill my program continue to run until it finishes if I upgrade my Python version?\nP.S.: I ran my Python program with the screen command so I wouldn't have to stop it to be able to upgrade my Python version.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":340,"Q_Id":49852576,"Users Score":1,"Answer":"Yes, your Python 2 script should continue to run while you install\/upgrade Python 3, since Python 2 and 3 are different programs.\nHowever, the installation will be be platform specific and there might be common dependencies, so I would test this on a different machine (e.g. local virtual machine) first.","Q_Score":0,"Tags":"python,python-3.x,upgrade,python-2.x","A_Id":49852931,"CreationDate":"2018-04-16T08:17:00.000","Title":"Upgrade Python version while running a Python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to upgrade my Python version from 2.6.6 to the newest version of 3.6.5 on a server. However, there is a program that has been running for multiple days and will be running for a week or more.\nWill my program continue to run until it finishes if I upgrade my Python version?\nP.S.: I ran my Python program with the screen command so I wouldn't have to stop it to be able to upgrade my Python version.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":340,"Q_Id":49852576,"Users Score":1,"Answer":"Several aspects are to be considered here:\n\nIn general, a Python program that is running does not access the installed binaries of the interpreter anymore.  Also all the modules already loaded will not be read again from disk during the execution time of this program. (In this aspect it differs from e. g. a Bash script which reads its script source while executing.)  So you probably are safe in even removing the complete Python installation; of course that's not what you plan on and I wouldn't recommend it for other reasons, but even that should not influence your running Python program.  If, however, your running Python program tries to import a module for the first time after the removal or upgrade of your Python installation, this might fail due to incompatibilities between the versions.  Most programs do their imports only at the beginning of their runtime, though.\nPython 2 and 3 are different languages.  Scripts for the one need to be at least adjusted to run with the other.  Adjustments aren't too hard to do, though.  Most distributions have both installed side-by-side.  Most of the time, Python2 is still standard (and accessed by typing python).  python2 and python3 are then to make it explicit.  This means that you probably should not remove Python 2 from your system, even if you plan on installing Python 3.  There probably are scripts relying on the installation of Python 2.","Q_Score":0,"Tags":"python,python-3.x,upgrade,python-2.x","A_Id":49853261,"CreationDate":"2018-04-16T08:17:00.000","Title":"Upgrade Python version while running a Python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to select the inverse index in pd.DataFrame by using loc or iloc?\nI tried df.loc[!my_index,my_feature] but fail. \nAnd df.loc[[ind for ind in df.index.tolist() if ind not in my_index],my_feature] looks too dull. Any better idea?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":12631,"Q_Id":49854796,"Users Score":3,"Answer":"Assuming my_index are the row indices you want to ignore, you could drop these where they exist in the dataframe df:\ndf = df.drop(my_index, errors='ignore')","Q_Score":17,"Tags":"python,pandas,dataframe,indexing","A_Id":63833958,"CreationDate":"2018-04-16T10:13:00.000","Title":"Select the inverse index in pd.Dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We're currently trying to convert html files to PDF on AppEngine using Python. The HTML files are from a third-party vendor so we have no control over their format. Both the Flexible and Standard environments are options, but every path we go down we seem to hit a roadblock:\n\nPDFkit requires a wkhtml2pdf install, no PIP package available, however converts perfectly offline\nxhtml2pdf \/ PISA - works even on GAE Standard but doesn't support many features such as float and badly formatted HTML\nWeasyPrint - C dependencies in theory would run on the Flexible environment but no pip packages available for dependencies including Cairo and Pango\n\nHas anyone got a robust solution running on AppEngine with any of the above? Or with other libraries I am missing?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":870,"Q_Id":49859145,"Users Score":1,"Answer":"I ran into this same problem a year back and concluded that this is currently not possible in App Engine, at least with a good quality conversion. (Someone please point out if things have changed)\nxhtml2pdf - I was able to successfully run it in standard App Engine but not at all happy with the conversion quality.\nPDFkit - Ran into a similar problem and came up with a different solution. Hosted PDFkit on a Compute Engine Instance and exposed an endpoint wherein a POST request with the HTML file will return the converted PDF as a response. This gave me the best\/expected results in terms of quality\/speed of processing. \nIt did incur some extra charges but I was able to utilize the instance for something else too ;). I chose the least possible configuration initially since I was not storing anything on the Compute Engine Instance.","Q_Score":6,"Tags":"python-2.7,google-app-engine","A_Id":49923883,"CreationDate":"2018-04-16T13:59:00.000","Title":"HTML to PDF on Google AppEngine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am learning python language. I don't have a good understanding of threads and I can't think of a situation when you will need threading.Lock() as CPython's GIL only allows one thread to execute at a time so I think a critical section cannot be accessed by two threads at the same time.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":224,"Q_Id":49859287,"Users Score":3,"Answer":"The GIL guarantees that one single process is executed at any time.\nHowever, when using threads you may have files or other objects shared between threads. Even if only one thread is active at any moment (because of the GIL), multiple threads may have access to the same object, here is when locks enter into play. Using threading.Lock() avoids that a given object is accessed by a second thread while a first thread is already using it.\nLet's say you have a file and two threads want to write the same file. The GIL gurantee that only one WRITE operation it is executed at a given moment, the Lock will guarantee that only a single thread can write that file.","Q_Score":2,"Tags":"python,multithreading,python-multithreading,cpython,gil","A_Id":49859519,"CreationDate":"2018-04-16T14:06:00.000","Title":"What is the need of threading.Lock() when Cpython has GIL?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm reading through the Numpy docs, and it appears that the functions np.prod(...), np.product(...) and the ndarray method a.prod(...) are all equivalent. \nIs there a preferred version to use, both in terms of style\/readability and performance? Are there different situations where different versions are preferable? If not, why are there three separate but very similar ways to perform the same operation?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":13184,"Q_Id":49863633,"Users Score":5,"Answer":"This is what I could gather from the source codes of NumPy 1.14.0. For the answer relevant to the current Master branch (NumPy 1.15.0), see the answer of miradulo.\n\nFor an ndarray, prod() and product() are equivalent. \nFor an ndarray, prod() and product() will both call um.multiply.reduce().\nIf the object type is not ndarray but it still has a prod method, then prod() will return prod(axis=axis, dtype=dtype, out=out, **kwargs) whereas product will try to use um.multiply.reduce.\nIf the object is not an ndarray and it does not have a prod method, then it will behave as product(). \nThe ndarray.prod() is equivalent to prod().\n\nI am not sure about the latter part of your question regarding preference and readability.","Q_Score":16,"Tags":"python,numpy,numpy-ndarray","A_Id":49864136,"CreationDate":"2018-04-16T18:04:00.000","Title":"numpy.product vs numpy.prod vs ndarray.prod","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"First of all, I wonder who was the brainless genius that decided to have indentation based language, and why couldn't he simply used semi-colons. It is so frustrating that the tabs in python files are always go out of sync, specially when you change either an editor and\/or OS.\nJust wondering if there is an extension in VSCode that could fix this tab inconsistency?","AnswerCount":6,"Available Count":4,"Score":0.0665680765,"is_accepted":false,"ViewCount":37262,"Q_Id":49865751,"Users Score":2,"Answer":"I had similar issue and none of the above solution worked for me.\nThen my colleague helped me and told me to start selection from end of the line - where the IDE was showing the error for indentation and then press down arrow to select till the start of the next line of the code, Press Enter after that to remove any hidden chars in between. You can do the same for the line above - where IDE is showing the error.\nThis worked for me in vs code","Q_Score":30,"Tags":"python,visual-studio-code","A_Id":61325703,"CreationDate":"2018-04-16T20:30:00.000","Title":"VSCode Extension to fix inconsistent tab issue of Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"First of all, I wonder who was the brainless genius that decided to have indentation based language, and why couldn't he simply used semi-colons. It is so frustrating that the tabs in python files are always go out of sync, specially when you change either an editor and\/or OS.\nJust wondering if there is an extension in VSCode that could fix this tab inconsistency?","AnswerCount":6,"Available Count":4,"Score":0.1651404129,"is_accepted":false,"ViewCount":37262,"Q_Id":49865751,"Users Score":5,"Answer":"In the bottom right corner of VScode there is a small information bar that contains \"Spaces: 4\"\nIf you click that you will get a window that allows you to change all indentation to tabs or spaces.","Q_Score":30,"Tags":"python,visual-studio-code","A_Id":55777884,"CreationDate":"2018-04-16T20:30:00.000","Title":"VSCode Extension to fix inconsistent tab issue of Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"First of all, I wonder who was the brainless genius that decided to have indentation based language, and why couldn't he simply used semi-colons. It is so frustrating that the tabs in python files are always go out of sync, specially when you change either an editor and\/or OS.\nJust wondering if there is an extension in VSCode that could fix this tab inconsistency?","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":37262,"Q_Id":49865751,"Users Score":80,"Answer":"You can fix the tab inconsistency by converting all indentation to tab or spaces.\nIf you open the \"Show All Commands\" tab, ( by pressing Ctrl+Shift+P or F1 ) and search for \"convert indentation\", two options will by available:\n\nconvert indentation to tabs\nconvert indentation to spaces\n\nJust choose tabs if you use tabs or spaces if use spaces as your indentation method.","Q_Score":30,"Tags":"python,visual-studio-code","A_Id":57206412,"CreationDate":"2018-04-16T20:30:00.000","Title":"VSCode Extension to fix inconsistent tab issue of Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"First of all, I wonder who was the brainless genius that decided to have indentation based language, and why couldn't he simply used semi-colons. It is so frustrating that the tabs in python files are always go out of sync, specially when you change either an editor and\/or OS.\nJust wondering if there is an extension in VSCode that could fix this tab inconsistency?","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":37262,"Q_Id":49865751,"Users Score":7,"Answer":"click : ctrl+shift+p  or right click on the mouse and select\n'Command Plate'  - this will prompt a list.\n2.select from list: 'Convert Indentation to Spaces'","Q_Score":30,"Tags":"python,visual-studio-code","A_Id":65421184,"CreationDate":"2018-04-16T20:30:00.000","Title":"VSCode Extension to fix inconsistent tab issue of Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a kind of weird question--but would be immensely useful if it is possible--in Maya using Python, can I take in several points of user input and have Python create a separate script for me? In this instance, I want to take in controller and locator names and have Python spit out a complete IKFK match script also in Python (it's really just a lot of getAttr and setAttr commands, although with 6 if statements per limb for PV matching.) The only other wrinkle there is that it has to be able to prefix hierarchy names in the script if necessary if the rig is imported into a new scene rather than just opened. There's an expression component to my switches that it would be nice if Python could make for me, too.\nIs this possible or am I crazy?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":166,"Q_Id":49869166,"Users Score":1,"Answer":"That's no problem. Just write a textfile with a .py extension into a path where maya can find it. Then you have to import it somewhere. Creating expressions is not a problem either. \nMaybe it could make sense to think about the approach you choose. Imagine you have written a dozen of these new python files and you discover a problem in the script, you will have to redo it. I'd try to collect all data and only write the required informations into a textfile e.g. in json format. Then you can read the data and rebuild your skeletons.","Q_Score":0,"Tags":"python,maya,creation","A_Id":49872814,"CreationDate":"2018-04-17T02:56:00.000","Title":"Maya Python creating a script with a script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to train an RNN with different input size of sentence X, without padding. The logic used for this is that I am using Global Variables and for every step, I take an example, write the forward propagation i.e. build the graph, run the optimizer and then repeat the step again with another example. The program is extremely slow as compared to the numpy implementation of the same thing where I have implemented forward and backward propagation and using the same logic as above. The numpy implementation takes a few seconds while Tensorflow is extremely slow. Can running the same thing on GPU will be useful or I am doing some logical mistake ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":49869622,"Users Score":0,"Answer":"As a general guideline, GPU boosts performance only if you have calculation intensive code and little data transfer. In other words, if you train your model one instance at a time (or on small batch sizes) the overhead for data transfer to\/from GPU can even make your code run slower! But if you feed in a good chunk of samples, then GPU will definitely boost your code.","Q_Score":0,"Tags":"python,numpy,tensorflow,machine-learning,rnn","A_Id":49869744,"CreationDate":"2018-04-17T03:51:00.000","Title":"Training changing input size RNN on Tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When running scrapy shell [url] command i can use fetch() and other scrapy stuff all in ipython environment. What do i need to setup in ipython to be able run all scrapy shell methods in ipython?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":139,"Q_Id":49871847,"Users Score":0,"Answer":"Through scrapy\u2019s settings you can configure it to use any one of ipython, bpython or the standard python shell, regardless of which are installed. This is done by setting the SCRAPY_PYTHON_SHELL environment variable; or by defining it in your scrapy.cfg:\n[settings]\nshell = bpython","Q_Score":0,"Tags":"scrapy,ipython","A_Id":49878047,"CreationDate":"2018-04-17T07:05:00.000","Title":"how to setup ipython for scrapy debug","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python script that is scheduled to run at a fixed time daily\nIf I am not around my colleague will be able to access my computer to run the script if there is any error with the windows task scheduler\nI like to allow him to run my windows task scheduler but also to protect my source code in the script... is there any good way to do this, please?\n(I have read methods to use C code to hide it but I am only familiar with Python)\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":656,"Q_Id":49874829,"Users Score":1,"Answer":"Compile the source to the .pyc bytecode, and then move the source somewhere inaccessible.\n\nOpen a terminal window in the directory containing your script\nRun python -m py-compile <yourfile.py> (you should get a yourfile.pyc file)\nMove <yourfile.py> somewhere secure\nyour script can now be run as python <yourfile.pyc>\n\nNote that is is not necessarily secure as such - there are ways to decompile the bytecode - but it does obfuscate it, if that is your requirement.","Q_Score":0,"Tags":"python,password-protection","A_Id":49877159,"CreationDate":"2018-04-17T09:44:00.000","Title":"Password protect a Python Script that is Scheduled to run daily","Data Science and Machine Learning":0,"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 doing a pi project where pi communicates with a UHF ID card reader via hardware serial and read cards. Pi gets the card information through serial and upload them to a remote database. Also some other common peripherals like LCD, RTC are connected to pi. I programmed the project with python2.\nThe project works OK. But after 15 to 30 days later program crashes with error \n\nIllegal instruction\n\n. And when this happens python2 package no longer run. If I run python2 from a terminal it throws same error and exits. Just a single line as shown above.\nCan't understand why this is happening. I searched through internet and found that in some cases some modules cause this problem which are related to CPU instructions(Though they are for PCs). But in this case it is not some module which are the source of the problem because if it was then the python interpreter should work properly.\nWhat additional tests can I do to trace the problem?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":134,"Q_Id":49874904,"Users Score":0,"Answer":"Should upgrade to new version of python series such as python 3.7, 3.8 and 3.9, because python 2.7 will move to 3.7","Q_Score":1,"Tags":"python,raspberry-pi","A_Id":68694530,"CreationDate":"2018-04-17T09:48:00.000","Title":"Illegal instruction when running python 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":0,"Web Development":0},{"Question":"I regularly use Spyder's built in debugging. I find that whilst I am stepping through a program, I often want to make changes to the source. However, this will put the current line in the code editor (the line of code whose line number is bold) out of wack with the line being run by ipdb in the ipython console.\nWhilst ipdb seems to continue to work fine, makes me nervous that I shouldn't be editing files whilst debugging and I will end up with unexpected behaviour.\nMy questions are:\nShould I be able to edit files whilst debugging in Spyder?\nIf so, what is the best way to do this?\nIf not, does PyCharm or another IDE good for scientific computing support this?\nMany thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":392,"Q_Id":49874921,"Users Score":0,"Answer":"Yes, you should be able to do that. The editing and saving will just edit the original file and not the currently running code. It will just edit your running file if you have saved the file and re-run the python debugger command. It is not specific to Spyder, but to the ipdb \/ pdb commands, so it would be the same in other editors like PyCharm.","Q_Score":1,"Tags":"python,debugging,spyder,ipdb","A_Id":49878938,"CreationDate":"2018-04-17T09:49:00.000","Title":"Editing source whilst debugging in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using gremlinpython version 3.3.2 and AWS NEPTUNE.\nI try to drop all the edges (tried the vertices too) and it fails everytime.\ng.E().drop().iterate()\nGives me:  \n\ngremlin_python.driver.protocol.GremlinServerError: 597: Exception\n  processing a script on request [RequestMessage{,\n  requestId=ae49cbb7-e034-4e56-ac76-b62310f753c2, op='bytecode',\n  processor='traversal', args={gremlin=[[], [V(), drop()]],\n  aliases={g=g}}}].\n\nDid anyone already successfuly remove all vertices\/edges of a graph in AWS Neptune?\nEDIT:\nDropping a specific ID works:\ng.E(id).drop().iterate()\nEDIT2:\nHere is a backtrace done using gremlin console:  \n\ngremlin> g.E().count().next()  \n==>740839\n  gremlin> g.E().drop().iterate()\n  A timeout occurred within the script during evaluation of [RequestMessage{, requestId=24c3d14c-c8be-4ed9-a297-3fd2b38ace9a, op='eval',   > processor='', args={gremlin=g.E().drop().iterate(), bindings={}, batchSize=64}}] - consider increasing the timeout\n  Type ':help' or ':h' for help.\n  Display stack trace? [yN]y\n  org.apache.tinkerpop.gremlin.jsr223.console.RemoteException: A timeout occurred within the script during evaluation of [RequestMessage{,   > requestId=24c3d14c-c8be-4ed9-a297-3fd2b38ace9a, op='eval', processor='', args={gremlin=g.E().drop().iterate(), bindings={},   > batchSize=64}}] - consider increasing the timeout\n    at org.apache.tinkerpop.gremlin.console.jsr223.DriverRemoteAcceptor.submit(DriverRemoteAcceptor.java:178)\n    at org.apache.tinkerpop.gremlin.console.GremlinGroovysh.execute(GremlinGroovysh.groovy:99)\n    at org.codehaus.groovy.tools.shell.Shell.leftShift(Shell.groovy:122)\n    at org.codehaus.groovy.tools.shell.ShellRunner.work(ShellRunner.groovy:95)\n    at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$work(InteractiveShellRunner.groovy)\n    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n    at java.lang.reflect.Method.invoke(Method.java:498)\n    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)\n    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)\n    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)\n    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:145)\n    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:165)\n    at org.codehaus.groovy.tools.shell.InteractiveShellRunner.work(InteractiveShellRunner.groovy:130)\n    at org.codehaus.groovy.tools.shell.ShellRunner.run(ShellRunner.groovy:59)\n    at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$run(InteractiveShellRunner.groovy)\n    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n    at java.lang.reflect.Method.invoke(Method.java:498)\n    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)\n    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)\n    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)\n    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:145)\n    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:165)\n    at org.codehaus.groovy.tools.shell.InteractiveShellRunner.run(InteractiveShellRunner.groovy:89)\n    at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)\n    at org.apache.tinkerpop.gremlin.console.Console.(Console.groovy:146)\n    at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)\n    at org.apache.tinkerpop.gremlin.console.Console.main(Console.groovy:453)\n  gremlin>\n\nI would say it's a timeout problem, right?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1739,"Q_Id":49877928,"Users Score":2,"Answer":"OK so after some exchange with @stephen mallette in comment of the question and AWS support I finally found where the problem lies.\nAs it still a preview NEPTUNE still suffer some smalls issues and drop() is one.\nA workaround, given by the support is to perform drop() in batches via parallel connections:\n\ng.V().limit(1000).drop()  \n\nSo dropping table is hitting a timeout right now, even with a 5 minutes timeout and 700.000 edges.\nI will update this answer on NEPTUNE's release.","Q_Score":2,"Tags":"python,gremlin,amazon-neptune","A_Id":50076688,"CreationDate":"2018-04-17T12:17:00.000","Title":"Drop all edges on AWS Neptune using pythongremlin","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a queue and 3 consumers bind to the queue. Each consumer has a prefetch_count of 250(or say X) and manual acknowledgement is done  prefetch_count(X)\/2(i.e 125) messages - meaning consumer manually acknowledges 125 messages in a single go (which helps to reduce round-trip time and hence increases performance). Everything is working fine as expected but the only issue arises when there are no new messages in the queue and the consumers have some unacknowledged messages whose count is less 125.\nAs the acknowledgement is only sent when the count is 125, these unacknowledged messages keeps requeuing. How can I solve this ?\nHow can I know that my consumer has no new messages to process and can acknowledge all the remaining messages waiting to be acknowledged.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":439,"Q_Id":49878842,"Users Score":1,"Answer":"If I understand your scenario correctly, it sounds as though you have a series of messages that get published all at once, and then you process them in batches of 250 at a time until you have none left.  The problem is, that if you don't have a number of messages that is divisible by 125, then your final batch never gets acknowledged.  Clearly this is a logical problem, but it sounds like you are wondering if there is an easy way to deal with it.\nYour question \"How can I know that my consumer has no new messages to process?\" is based upon a premise which RabbitMQ does not support -- namely, the \"end\" of a sequence of messages.  RabbitMQ consumers expect to continue to receive messages indefinitely, so from their perspective, there is no such thing as \"done.\"\nThus, any such concept must be implemented elsewhere, higher up in your application logic.  Here are some options for you to consider:\n\nIf you know in advance how many messages will be processed, then send that count first and store. Send the final ack once you have processed that number (assuming no duplicates were processed).\nMonitor the in-memory collection at the consumer (all pre-fetched messages reside here until they are actually processed). When it drops below 125, you know that you have a batch size less than that.\nSimilar to #1, send a special \"last message\" that the consumer can receive and know to acknowledge upon receipt.\n\nCaveat: I would argue that you have some deeper design problem going on that is leading down the path where it would ever be desirable to do this in the first place. Each message should be 100% independent of any other message. If that assumption is violated, you will have a very fragile system.","Q_Score":1,"Tags":"python-3.x,rabbitmq","A_Id":49883276,"CreationDate":"2018-04-17T12:59:00.000","Title":"Acknowledging remaining messages for consumer in RabbitMQ","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Trying to read a matlab file into python. I am using the function loadmat from scipy.io to read it, and I'm getting back the error ValueError: negative dimensions are not allowed.\nHow can I fix this issue?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":131,"Q_Id":49879324,"Users Score":0,"Answer":"I found out that this was a binary file (was written with Matlab's fwrite).\nThe solution was saving the file as text, and then loading it in python not using loadmat.","Q_Score":0,"Tags":"python,scipy,mat","A_Id":49905936,"CreationDate":"2018-04-17T13:23:00.000","Title":"python: loadmat - ValueError: negative dimensions are not allowed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between plot() and iplot() in displaying a figure in Jupyter Notebook?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":28800,"Q_Id":49880314,"Users Score":1,"Answer":"Correct answer provided.I tried to run this code in pycharm IDE but could not. jupyter notebook is required to graph iplot.","Q_Score":10,"Tags":"python,pandas,matplotlib,plotly","A_Id":63543545,"CreationDate":"2018-04-17T14:07:00.000","Title":"What is difference between plot and iplot in Pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Library: Keras, backend:Tensorflow\nI am training a single class\/binary classification problem, wherein my final layer has a single node, with activation of sigmoid type. I am compiling my model with a binary cross entropy loss. When I run the code to train my model, I notice that the loss is a value greater than 1. Is that right, or am I going wrong somewhere? I have checked the labels. They're all 0s and 1s.  \nIs it possible to have the binary cross entropy loss greater than 1?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":10194,"Q_Id":49882424,"Users Score":6,"Answer":"Yes, its correct, the cross-entropy is not bound in any specific range, its just positive (> 0).","Q_Score":5,"Tags":"python,tensorflow,keras","A_Id":49885159,"CreationDate":"2018-04-17T15:47:00.000","Title":"Keras Tensorflow Binary Cross entropy loss greater than 1","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to generate a Python executable file with Pyinstaller on Linux. For this purpose I'm trying this implementation with a simple 'Hello World' file. \nThe issue I'm having is that when the executable file is generated and I execute it (double-click), nothing happens. There is no console popping out and I can see no execution. I have read in the documentation that in MacOS and Windows there are explicit options in order to make this console appear or not, but not in Linux.\nAny idea?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":491,"Q_Id":49882680,"Users Score":0,"Answer":"You should open your console, and use \"python file.py\" or \"python3 file.py\" command (it depends on Python version), where file.py is your file.\nI hope that I helped.","Q_Score":1,"Tags":"python,console,pyinstaller","A_Id":49883003,"CreationDate":"2018-04-17T16:00:00.000","Title":"Pyinstaller on Linux - How to show a console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working in vanilla Emacs 23 on various python programs, when I evaluate a buffer, an inferior python shell is started as expected and the scripts run fine...\nThis is all fine, however, when working on multiple (unrelated) projects, the same python instance is used, is there a way I can create a new inferior python shell per source file?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":358,"Q_Id":49886186,"Users Score":1,"Answer":"When I need a new inferior python shell in emacs and want to specify which python buffers send code to each shell I do the following.  This gives me a little more control.\n\nUse the M-x rename-buffer command to set the existing inferior shell buffer name to something like *Python-otherbuff*\n\n(setq-local python-shell-buffer-name \"Python-otherbuff\") in each buffer which should interact with the old inferior shell.\n\nUse the usual command to create a new inferior python shell (e.g. C-c C-p) which will create a buffer called *Python* which all python buffers will interact with by default.","Q_Score":2,"Tags":"python,emacs","A_Id":65496992,"CreationDate":"2018-04-17T19:36:00.000","Title":"Emacs: starting a new inferior python shell when evaluating buffer","Data 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 apologies if this is a silly question. \nI'm trying to use mlxtend, and have installed it using pip. Pip confirms that it is installed (when I type \"pip install mlxtend\" it notes that the requirement is already satisfied). However, when I try and import mlxtend in python using \"import mlxtend as ml\", I get the error: \"ModuleNotFoundError: No module named 'mlxtend'\". I used the same process for installing and importing pandas and numpy, and they both worked. Any advice?\nI should note that I have resorted to dropping in the specific code I need from mlxtend (apriori and association rules), which is working, but hardly a good long term strategy!\nI'm using python version 3.6.5. \nThanks!","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":19607,"Q_Id":49889524,"Users Score":0,"Answer":"Try this:\nconda install -c conda-forge mlxtend\nDon't mix pip and Conda environments. Last time I did this I broke my Python and needed to reinstall everything again.\nIf you must deal with different environments using pip and conda because of many projects, use pyenv.","Q_Score":8,"Tags":"python,python-import,importerror,mlxtend","A_Id":64196727,"CreationDate":"2018-04-18T00:56:00.000","Title":"Issues importing mlxtend python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to python, so apologies if this is a silly question. \nI'm trying to use mlxtend, and have installed it using pip. Pip confirms that it is installed (when I type \"pip install mlxtend\" it notes that the requirement is already satisfied). However, when I try and import mlxtend in python using \"import mlxtend as ml\", I get the error: \"ModuleNotFoundError: No module named 'mlxtend'\". I used the same process for installing and importing pandas and numpy, and they both worked. Any advice?\nI should note that I have resorted to dropping in the specific code I need from mlxtend (apriori and association rules), which is working, but hardly a good long term strategy!\nI'm using python version 3.6.5. \nThanks!","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":19607,"Q_Id":49889524,"Users Score":3,"Answer":"I had the same issue while using Anaconda, I tried to install it with Anaconda, however, Notebook didn't see it installed. You can also try to install it in CMD by just typing\npip install mlxtend --user or pip3 install mlxtend --user\nAfter installing it with CMD, Notebook didn't give error for my case. Just reply if this helps. Good luck all.","Q_Score":8,"Tags":"python,python-import,importerror,mlxtend","A_Id":58758122,"CreationDate":"2018-04-18T00:56:00.000","Title":"Issues importing mlxtend python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know the length of a tuple of tuple with only one element\nlen(((0, 1)))\nbut this statement return 2, if I modify to len(((0, 1),)) then return 1\nHowever len([[0, 1]]) directly return 1\nMay I know the difference here?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":346,"Q_Id":49890010,"Users Score":1,"Answer":"When you use len(((0,1))) you are in fact doing len((0,1)) which is 2. The outer parenthesis are remove since they are useless . (...) could be a math operation with parenthesis (like (1+3)*2) or a function call, so the constructor for a one element tuple was define as (1,). So, len(((0,1),)) will in fact be a tuple with (0,1) as his only element.\nFor [[]], it's a list within a list, so len([[]]) counts the number of element within the first list, which is one (only []).","Q_Score":0,"Tags":"python,python-2.7","A_Id":49890015,"CreationDate":"2018-04-18T02:01:00.000","Title":"different return value len(tuple of tuple) and len(list of list)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know the length of a tuple of tuple with only one element\nlen(((0, 1)))\nbut this statement return 2, if I modify to len(((0, 1),)) then return 1\nHowever len([[0, 1]]) directly return 1\nMay I know the difference here?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":346,"Q_Id":49890010,"Users Score":0,"Answer":"It is a one dimensional two dimensional difference.\nlen(((0, 1))) is have two element of tuple return a value of 2.\nlen(((0, 1),)) is have two element of tuple but separate by comma(,)\nRecognize that there are multiple tuples and return a value of 1.\nlen([[0, 1]]) is two dimension list return a value of 1.","Q_Score":0,"Tags":"python,python-2.7","A_Id":49890040,"CreationDate":"2018-04-18T02:01:00.000","Title":"different return value len(tuple of tuple) and len(list of list)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm translating a Python program which uses OpenCV to C# with Java bindings. I tested both Python and C# programs using the same image, and I realized the findContours method returns different contours between the 2 programs.\nPython: _, contours, hierarchy = cv2.findContours(edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)\nC#: Imgproc.FindContours(edges, contours, hierarchy, Imgproc.RetrTree, Imgproc.ChainApproxSimple);\nFor Python, I checked using len(contours), for C# contours.Count, and they return the values 94 and 106 respectively. I think this may be the cause to many discrepancies in my translated program, and I'm not sure why. What am I doing wrong here?\n\nAdd-on: The Canny method below is called before calling findContours. Anything before is just reading the image, and converting the image into a gray one, thus the grayImg variable.\n\nC#: Imgproc.Canny(grayImg, edges, 100, 200, 3, false);\nPython: edges = cv2.Canny(gray, 100, 200, apertureSize = 3)\nI previously thought it was because of differing OpenCV versions, but I realized both are using OpenCV 3. Unless the FindContours method is different in 3.1 than 3.4, I'm back to square one again as I don't know the cause of the problem.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":194,"Q_Id":49890287,"Users Score":0,"Answer":"I've finally found the answer to this phenomenon. The python program is using OpenCV 3.4, while the Java bindings of my C# program is using the older OpenCV 3.1 . The FindContours method may be found in both versions, but apparently returns different values.","Q_Score":0,"Tags":"c#,python,opencv,opencv-contour","A_Id":49896647,"CreationDate":"2018-04-18T02:37:00.000","Title":"Different return from Java and Python cv2.findContours","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a project developed in python\/django, i create my API interface for public a view of the db to my clients using POST GET and others calls, all done.\nNow i'am wondering what is the best way to create a real SDK for my program, i mean the possibility for my clients, using specific calls, to make my enviroment execute something and return result from their code.\nAre there some tools, like for example Django REST framework for the API, also for SDKs?\nThanks at all in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1281,"Q_Id":49892526,"Users Score":4,"Answer":"API is server side while SDK is client side. \nFor example, you can provide APIs using python\/django. But your customers can use nodejs, C++, C#, JAVA... anything they want to communicate with your server.\nIf you provide a SDK for C++, that's just for C++ customers. For JAVA customers, you still need to provide another SDK for JAVA.\nSo in short, you cannot find a cross-language-sdk-generator.","Q_Score":0,"Tags":"python,sdk,django-rest-framework","A_Id":49893270,"CreationDate":"2018-04-18T06:21:00.000","Title":"Python create an SDK instead just an API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"tensorflow version 1.5.0rc1 \npython version:3.5\nWhen reshape a rectangular image to [height,width]\nby using tf.reshape(x,[-1,x,y,1]) \n\neg. tf.reshape(x,[-1,14,56,1]) run conv2d returns:\n  InvalidArgumentError (see above for traceback): Input to reshape is a\n  tensor with 358400 values, but the requested shape requires a multiple\n  of 3136    [[Node: Reshape_1 = Reshape[T=DT_FLOAT, Tshape=DT_INT32,\n  _device=\"\/job:localhost\/replica:0\/task:0\/device:GPU:0\"](MaxPool_1, Reshape_1\/shape)]]\n\nwhich 3136 is the square of 56.\nthe tensor treats the reshape as 56x56 instead of 14*56 matrix.\nIs there a way to get rid of it and set my CNN to a non square image?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1803,"Q_Id":49893741,"Users Score":0,"Answer":"I don't exactly agree with reshaping a rectangular picture as you destroy the relationship between neighbour pixels. Instead, you have several options to apply CNNs on a non-quadratic image:\n1.) Use padding. During preprocessing, you could fill in pixels to get a quadratic image. Through this you can apply the quadratic filter.\n2.) Use different quadratic windows of that image for training. For example, create a quadratic window and run it over the image to get a number of sub-pictures.\n3.) You could use different strides for the dimensions of your picture.\n4.) You could stretch the picture in the needed direction, although I'm not exactly sure how this affects the performance later on. I would only try this as a last resort solution.","Q_Score":0,"Tags":"python,tensorflow","A_Id":49894197,"CreationDate":"2018-04-18T07:32:00.000","Title":"tensorflow: CNN for non square image","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got an issue with scrapy and python.\nI have several links. I crawl data from each of them in one script with the use of loop. But the order of crawled data is random or at least doesn't match to the link.\nSo I can't match url of each subpage with the outputed data.\nLike: crawled url, data1, data2, data3.\nData 1, data2, data3 => It's ok, because it comes from one loop, but how can I add to the loop current url or can I set the order of link's list? Like first from the list is crawled as first, second is crawled as second...","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":79,"Q_Id":49896079,"Users Score":-1,"Answer":"Ok, It seems that the solution is in settings.py file in scrapy.\nDOWNLOAD_DELAY = 3   \nBetween requests.\nIt should be uncommented. Defaultly it's commented.","Q_Score":0,"Tags":"python,scrapy","A_Id":49899202,"CreationDate":"2018-04-18T09:29:00.000","Title":"Scrapy - order of crawled urls","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've got an issue with scrapy and python.\nI have several links. I crawl data from each of them in one script with the use of loop. But the order of crawled data is random or at least doesn't match to the link.\nSo I can't match url of each subpage with the outputed data.\nLike: crawled url, data1, data2, data3.\nData 1, data2, data3 => It's ok, because it comes from one loop, but how can I add to the loop current url or can I set the order of link's list? Like first from the list is crawled as first, second is crawled as second...","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":49896079,"Users Score":0,"Answer":"time.sleep() - would it be a solution?","Q_Score":0,"Tags":"python,scrapy","A_Id":49898314,"CreationDate":"2018-04-18T09:29:00.000","Title":"Scrapy - order of crawled urls","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The \"Django-Rest-Framework (DRF) Throttling\" can help to prevent bruteforce attacks and failed login attempts.\nThen why do we need to use \"Django axes\", \"Django defender\", \"django-ratelimit\" or similar components?\nThanks In Advance","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1124,"Q_Id":49897735,"Users Score":6,"Answer":"Throttling, as provided by DRF, is very different to Authentication, which is the focus of Django Axes.\nIn DRF you can allow access to your resource (say a database) for a defined amount of times (i.e. 100 database lookups) in a given period (lets say a day), so they are throttled to that amount\/period, here 100\/day. In some use-cases the user need not even identify themselves necessarily to avail of your service, there is no authentication involved -here you look at the IP of the users system as a key to throttle the users activity.  Yes you can run throttling in conjunction with authentication in DRF, but one does not require the other.\nWhereas in Axes you are primarily concerned with having the user prove his identity (authentication) through the login process. You can also instruct Axes to deny a repeat-failing user the opportunity to authenticate, i.e. if you fail to login correctly for 10 attempts you are now banned from logging in for the next 5 minutes.  So typically a non authenticated user will never avail of your service and a repeat authenticate-failing attempts will result in that IP being denied the opportunity to authenticate for an extended time period.  The emphasis with Axes tends to be on determining why a user failed to authenticate and by which means they gained access to the system. For example from the Axes reports, you can determine how many users logged in that day using the link emailed to them from the registration page. Or which users logged in using facebook, and also how many users failed to login (IP, username or email for example).\nFurthermore, DRF is in effect an add-on to \"regular django\", and thus it\u00b4s throttling and authentication are tailored to the API service that it performs. Your users using an API are in general not likely to authenticate manually to the API but rather using some token (JWT,csrf) . Django Axes is also an add-on to regular django and typically services the needs of a typical web site with authenticating users. You can use both services, DRF and Axes on the one django platform, they work well together and do not clash.","Q_Score":3,"Tags":"python,django,django-rest-framework","A_Id":53496778,"CreationDate":"2018-04-18T10:44:00.000","Title":"What is different between \"DRF Throttling\" and \"Django Axes\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The \"Django-Rest-Framework (DRF) Throttling\" can help to prevent bruteforce attacks and failed login attempts.\nThen why do we need to use \"Django axes\", \"Django defender\", \"django-ratelimit\" or similar components?\nThanks In Advance","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1124,"Q_Id":49897735,"Users Score":0,"Answer":"As far as I know, those libraries you mentioned all do the same thing (with a few differences between them). You can choose the one which best suits your needs.\nIf you are using DRF, then you don't need an aditional library (axes, ratelimit, etc.) because DRF already has the throttling functionality build in.","Q_Score":3,"Tags":"python,django,django-rest-framework","A_Id":49898372,"CreationDate":"2018-04-18T10:44:00.000","Title":"What is different between \"DRF Throttling\" and \"Django Axes\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to write a script that imports a file, then does something with the file and outputs the result into another file.\ndf = pd.read_csv('somefile2018.csv')\nThe above code works perfectly fine. However, I'd like to avoid hardcoding the file name in the code.\nThe script will be run in a folder (directory) that contains the script.py and several csv files.\nI've tried the following:\nsomefile_path = glob.glob('somefile*.csv')\ndf = pd.read_csv(somefile_path)\nBut I get the following error:\nValueError: Invalid file path or buffer object type: <class 'list'>","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":14334,"Q_Id":49898742,"Users Score":1,"Answer":"Loop over each file and build a list of DataFrame, then assemble them together using concat.","Q_Score":8,"Tags":"python,pandas","A_Id":49898817,"CreationDate":"2018-04-18T11:36:00.000","Title":"Pandas reading csv files with partial wildcard","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use different models from the python library statsmodels (e.g. Arima and AR). However, I am not allowed to install Cython on my computer. Is there a way to use statsmodels without cython? I am using Python 2.7 and according to their website it should be possible for older version, but they lack to specify it further.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":165,"Q_Id":49899269,"Users Score":1,"Answer":"Cython is only needed to generate the C-files. \nEither using a binary or a source (sdist) distribution does not require cython anymore. An sdist includes the C-files generated by cython, and needs a C compiler but not cython.\nIt is possible to use parts of statsmodels without the C-extension, but that is just because some modules that are pure Python can be imported without importing also modules that depend on extension code.\nHowever, time series models like ARIMA or the statespace models make heavy use of Cython\/C extensions and will not work without the compiled extensions.","Q_Score":0,"Tags":"python,cython,statsmodels","A_Id":49902568,"CreationDate":"2018-04-18T12:03:00.000","Title":"Runnings statsmodels without cython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to crawl a webpage(news) and get only the latest links. \nI have a crawler code which gets all the links from a website and takes like 2-3 hours to get around 30000 links and stores in db.\nWhat if next time when I run the crawler I want only the new links to be inserted.\nI know I can do a filter before inserting in db, but I would want the crawler to fetch only new links other than crawling the old links again(basically entire website). \nIs it possible to do something like that?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":51,"Q_Id":49899506,"Users Score":1,"Answer":"You need some sort of a cache.\nOne solution which comes to my mind is storing a local version of the website. When you want to add the new links you can make a diff between the new version and your locally stored version. Afterwards you can crawl over the diff...","Q_Score":0,"Tags":"python,web-scraping,web-crawler","A_Id":49899582,"CreationDate":"2018-04-18T12:16:00.000","Title":"Is there a way to crawl a webpage in python where the crawler shoud fetch only the new links.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For one test in the middle of my test suite I need to use fullReset to completely clear any data stored in an app.  I don't want to set fullReset as a desired capability for the entire test run as this will significantly slow it down.  After each test I tear down and restart the app.  Is it possible to only trigger a fullReset on one specific test class?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":227,"Q_Id":49900096,"Users Score":1,"Answer":"Create another class for full reset in the base package and extend that class wherever you want the test to use fullReset.","Q_Score":0,"Tags":"appium,appium-ios,python-appium","A_Id":49900635,"CreationDate":"2018-04-18T12:46:00.000","Title":"Is it possible to set a desired capability (fullReset) for a single test out of many?","Data Science and Machine Learning":0,"Database and SQL":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 that is live right now, there is some SMTP stuff I want to change the settings.py of my Django project. I have made the changes, however, I cannot get the server to detect the changes, and it throws a SMTPAuthentication error because the settings.py is still using the old settings.\nThe server is set up with nginx, and I have tried service nginx reload several times, and apachectl restart several times. As well as deleting any *.pyc files.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2110,"Q_Id":49903923,"Users Score":3,"Answer":"nginx cannot be actually running the site, as it is not a WSGI server. Presumably it is running as a proxy to something like gunicorn or uWSGI; it is those that you need to restart.","Q_Score":3,"Tags":"python,django,nginx,uwsgi","A_Id":49903965,"CreationDate":"2018-04-18T15:47:00.000","Title":"Django settings.py not updating on production","Data Science and Machine Learning":0,"Database and SQL":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 been running a script on partner's computer for 18 hours.  We underestimated how long it would take, and now need to turn in the results.  Is it possible to stop the script from running, but still have access to all the lists we are building?\nWe need to add additional code to the one we are currently running that will use the lists being populated right now.  Is there a way to stop the process, but still use (what has been generated of) the lists in the next portion of code?\nMy partner was using python interactively.\n\nupdate\nWe were able to successfully print the results and copy and paste after interrupting the program with control-C.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7010,"Q_Id":49904516,"Users Score":0,"Answer":"I don't think so. Stopping the program should also release all of the memory it was using. \nedit: See Swenzel's comment for one way of doing it.","Q_Score":19,"Tags":"python","A_Id":49904589,"CreationDate":"2018-04-18T16:19:00.000","Title":"Stop a python script without losing data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am just getting familiar with Luigi, so I apologize if this is an obvious question, but I am having a hard time understanding it from the documentation.\nIn a situation where I run a workflow with three tasks, and the second task fails, how can I manually re-run the pipeline beginning at the second task? From what I am reading, you can only configure automatic retries. What do you do if all of the auto-retries fail? Do you simply need to kick off a new workflow entirely?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":902,"Q_Id":49906756,"Users Score":0,"Answer":"When you run Luigi, the task scheduler checks which tasks have already completed. If a task as already completed, successfully, it won't run that task again.\nSo if you run it same pipeline again, it should continue where it left off last time, as long as none of the parameter values have changed (which would change the task signature and thus Luigi would create new tasks instead of checking the previous ones, because the same task class executed with different parameters are considered different tasks).","Q_Score":1,"Tags":"python,luigi","A_Id":63567745,"CreationDate":"2018-04-18T18:35:00.000","Title":"Luigi - How to deal with failed workflows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm looking for a way to hide code cells (inputs) when export my .iipynb file to a HTML. I don't want the code cells to be visible at all (not some button that turn them off\/on). The output is for people that have no idea what a programming language is. I tried many things that I found on the internet but nothing seems to work. \nThanks","AnswerCount":11,"Available Count":1,"Score":0.0181798149,"is_accepted":false,"ViewCount":69341,"Q_Id":49907455,"Users Score":1,"Answer":"Conversion of ipynb code file to a HTML file without code(Using Python)::\nStep1: Suppose your file Untitled.ipynb is saved in your laptop's Downloads folder.\nStep2: Open Anaconda prompt or Cmd , Paste the below command to hide the codes and save the file as Untitled.html:\n\ncd Downloads\njupyter nbconvert Untitled.ipynb --to=html --TemplateExporter.exclude_input=True\n\nNote: path to the Untitled.ipynb could be different and needs to be changed where we are using cd Downloads to cd new_path.","Q_Score":70,"Tags":"python,jupyter","A_Id":69387570,"CreationDate":"2018-04-18T19:18:00.000","Title":"Hide Code when exporting Jupyter notebook to HTML","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Another team created python scripts within our organization for my team to run. Up until two weeks ago, we all ran them without any problems. Then one day, some users have been unable to run them successfully on the same machine.\nAll users are admins with LUA disabled. All users should have the same permissions. \nThe complicating factor here is the team created a \"framework\" which generates code from a combination of the framework, and an excel file for the tests being run. This prevents me from stepping through the code and finding where it's specifically failing. Beyond that, the same exact script runs on the same machine when another user trying to run it.\nSpecifically, in the script, it appears that when the affected users are running the script, IEDriverserver doesn't appear to open. No errors are given.\nIs there any environmental variables that could be specific to users that would cause this? Even a direction to look would be extremely helpful.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":612,"Q_Id":49908242,"Users Score":0,"Answer":"I encountered the similar issue today. I happen to solve it by unset PYTHONHOME and PYTHONPATH. Not sure if this helps.","Q_Score":0,"Tags":"python-3.x,selenium,selenium-webdriver,windows-7","A_Id":61651681,"CreationDate":"2018-04-18T20:10:00.000","Title":"Python script works for one user, but not another on same 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Another team created python scripts within our organization for my team to run. Up until two weeks ago, we all ran them without any problems. Then one day, some users have been unable to run them successfully on the same machine.\nAll users are admins with LUA disabled. All users should have the same permissions. \nThe complicating factor here is the team created a \"framework\" which generates code from a combination of the framework, and an excel file for the tests being run. This prevents me from stepping through the code and finding where it's specifically failing. Beyond that, the same exact script runs on the same machine when another user trying to run it.\nSpecifically, in the script, it appears that when the affected users are running the script, IEDriverserver doesn't appear to open. No errors are given.\nIs there any environmental variables that could be specific to users that would cause this? Even a direction to look would be extremely helpful.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":612,"Q_Id":49908242,"Users Score":0,"Answer":"Does it always fail in the same part of the Python code?  Does opening the Excel file have anything to do with it, perhaps?  I mean, if someone has the Excel file open on a network drive, and someone else is trying to write to the file, i'm pretty sure this will trigger an error, unless the Excel file is 'shared'.  Just a couple thoughts.","Q_Score":0,"Tags":"python-3.x,selenium,selenium-webdriver,windows-7","A_Id":50203447,"CreationDate":"2018-04-18T20:10:00.000","Title":"Python script works for one user, but not another on same 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In influxdb 1.5, the \/write path can accept multiple points in a POST request.\nWhat is a reasonable maximum payload size for this? 100 point? 1,000? 10,000? More?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1591,"Q_Id":49908395,"Users Score":1,"Answer":"I had some problems with 25000 and more points. The points were written by a little python script out of a pandas dataframe. The code was near by the example from influx (dataframe to influxdb with python). \nIt did not matter how many lines and columns were present, the error was reproducible over the sum to be written points.\nIt is better to stay below 20000 points per transfer to avoid exceptions.","Q_Score":1,"Tags":"influxdb,influxdb-python","A_Id":53751719,"CreationDate":"2018-04-18T20:20:00.000","Title":"What's the maximum number of points I should write to influxdb in a single request?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am installing pyodbc on Redhat 6.5.  Python 2.6 and 2.7.4 are installed.  I get the following error below even though the header files needed for gcc are in the \/usr\/include\/python2.6.\nI have updated every dev package:  yum groupinstall -y 'development tools'\nAny ideas on how to resolve this issue would be greatly appreciated???\nInstalling pyodbc...\nProcessing .\/pyodbc-3.0.10.tar.gz\nInstalling collected packages: pyodbc\n Running setup.py install for pyodbc ... error\n    Complete output from command \/opt\/rh\/python27\/root\/usr\/bin\/python -u -c \"import setuptools, tokenize;file='\/tmp\/pip-JAGZDD-build\/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\\r\\n', '\\n'), file, 'exec'))\" install --record \/tmp\/pip-QJasL0-record\/install-record.txt --single-version-externally-managed --compile:\n    running install\n    running build\n    running build_ext\n    building 'pyodbc' extension\n    creating build\n    creating build\/temp.linux-x86_64-2.7\n    creating build\/temp.linux-x86_64-2.7\/tmp\n    creating build\/temp.linux-x86_64-2.7\/tmp\/pip-JAGZDD-build\n    creating build\/temp.linux-x86_64-2.7\/tmp\/pip-JAGZDD-build\/src\n    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYODBC_VERSION=3.0.10 -DPYODBC_UNICODE_WIDTH=4 -DSQL_WCHART_CONVERT=1 -I\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/MacOSX.platform\/Developer\/SDKs\/MacOSX10.8.sdk\/usr\/include -I\/opt\/rh\/python27\/root\/usr\/include\/python2.7 -c \/tmp\/pip-JAGZDD-build\/src\/cnxninfo.cpp -o build\/temp.linux-x86_64-2.7\/tmp\/pip-JAGZDD-build\/src\/cnxninfo.o -Wno-write-strings\n    In file included from \/tmp\/pip-JAGZDD-build\/src\/cnxninfo.cpp:8:\n    **\n**\/tmp\/pip-JAGZDD-build\/src\/pyodbc.h:41:20: error: Python.h: No such file or directory \/tmp\/pip-JAGZDD-build\/src\/pyodbc.h:42:25: error: floatobject.h: No such file or directory \/tmp\/pip-JAGZDD-build\/src\/pyodbc.h:43:24: error: longobject.h: No such file or directory \/tmp\/pip-JAGZDD-build\/src\/pyodbc.h:44:24: error: boolobject.h: No such file or directory \/tmp\/pip-JAGZDD-build\/src\/pyodbc.h:45:27: error: unicodeobject.h: No such file or directory \/tmp\/pip-JAGZDD-build\/src\/pyodbc.h:46:26: error: structmember.h: No such file or directory\n**\n    In file included from \/tmp\/pip-JAGZDD-build\/src\/pyodbc.h:137,\n                     from \/tmp\/pip-JAGZDD-build\/src\/cnxninfo.cpp:8:\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:61:28: error: stringobject.h: No such file or directory\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:62:25: error: intobject.h: No such file or directory\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:63:28: error: bufferobject.h: No such file or directory\n    In file included from \/tmp\/pip-JAGZDD-build\/src\/cnxninfo.cpp:8:\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbc.h: In function \u2018void _strlwr(char*)\u2019:\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbc.h:92: error: \u2018tolower\u2019 was not declared in this scope\n    In file included from \/tmp\/pip-JAGZDD-build\/src\/pyodbc.h:137,\n                     from \/tmp\/pip-JAGZDD-build\/src\/cnxninfo.cpp:8:\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h: At global scope:\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:71: error: expected initializer before \u2018*\u2019 token\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:81: error: \u2018Text_Buffer\u2019 declared as an \u2018inline\u2019 variable\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:81: error: \u2018PyObject\u2019 was not declared in this scope\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:81: error: \u2018o\u2019 was not declared in this scope\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:82: error: expected \u2018,\u2019 or \u2018;\u2019 before \u2018{\u2019 token\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:93: error: \u2018Text_Check\u2019 declared as an \u2018inline\u2019 variable\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:93: error: \u2018PyObject\u2019 was not declared in this scope\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:93: error: \u2018o\u2019 was not declared in this scope\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:94: error: expected \u2018,\u2019 or \u2018;\u2019 before \u2018{\u2019 token\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:104: error: \u2018PyObject\u2019 was not declared in this scope\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:104: error: \u2018lhs\u2019 was not declared in this scope\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:104: error: expected primary-expression before \u2018const\u2019\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:104: error: initializer expression list treated as compound expression\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:109: error: \u2018Text_Size\u2019 declared as an \u2018inline\u2019 variable\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:109: error: \u2018PyObject\u2019 was not declared in this scope\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:109: error: \u2018o\u2019 was not declared in this scope\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:110: error: expected \u2018,\u2019 or \u2018;\u2019 before \u2018{\u2019 token\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:118: error: \u2018TextCopyToUnicode\u2019 declared as an \u2018inline\u2019 variable\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:118: error: \u2018Py_UNICODE\u2019 was not declared in this scope\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:118: error: \u2018buffer\u2019 was not declared in this scope\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:118: error: \u2018PyObject\u2019 was not declared in this scope\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:118: error: \u2018o\u2019 was not declared in this scope\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:118: error: initializer expression list treated as compound expression\n    \/tmp\/pip-JAGZDD-build\/src\/pyodbccompat.h:119: error: expected \u2018,\u2019 or \u2018;\u2019 before \u2018{\u2019 token\n    error: command 'gcc' failed with exit status 1","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":441,"Q_Id":49908470,"Users Score":0,"Answer":"The resolution was to re-install Python2.7","Q_Score":0,"Tags":"python,python-2.7,gcc,pyodbc,python-2.6","A_Id":50045919,"CreationDate":"2018-04-18T20:24:00.000","Title":"gcc error when installing pyodbc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a large (9.3 GB) .npy file containing a uint8 values in an (67000, 9, 128, 128) ndarray. I created it using np.save() and when loading it using x = np.memmap('file.npy', \"uint8\", shape=(67000, 9, 128, 128), mode=\"r\"), np.sum(x[0,0,:,0]) returns 13783. The \"problem\" is that when I try loading it with np.load(\"file.npy\") and run the same function, I get the sum to 13768.\nSince np.load() loads the whole file in memory, I'd assume that the sum computed on its ndarray is correct, while the one returned by the ndarray loaded with memmap is wrong, but why are they different ? If it was a reading error the sum should be really off, so why is it off by only 15 ??! \nI have no clue why that is the case. This won't affect my computation per say but it could be significant for other tasks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":379,"Q_Id":49908788,"Users Score":4,"Answer":"numpy.memmap is for treating raw data in a file as a numpy array.  Your filename is 'file.npy', so that is not \"raw\" data.  It is a NPY file, which has a header containing meta-information about the array stored in it.\nTo memory-map a NPY file, use the mmap_mode argument of numpy.load().","Q_Score":0,"Tags":"python,numpy,memory","A_Id":49908880,"CreationDate":"2018-04-18T20:48:00.000","Title":"Sum of values accessed through numpy memmap is wrong","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been searching for a bit now and haven't been able to find anything similar to my question. Maybe i'm just not searching correctly. Anyways this is a question from my exam review. Given a binary tree, I need to output a list such that each item in the list is the number of nodes on a level in a binary tree at the items list index. What I mean, lst = [1,2,1] and the 0th index is the 0th level in the tree and the 1 is how many nodes are in that level. lst[1] will represent the number of nodes (2) in that binary tree at level 1. The tree isn't guaranteed to be balanced. We've only been taught preorder,inorder and postorder traversals, and I don't see how they would be useful in this question. I'm not asking for specific code, just an idea on how I could figure this out or the logic behind it. Any help is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1773,"Q_Id":49909109,"Users Score":1,"Answer":"The search ordering doesn't really matter as long as you only count each node once. A depth-first search solution with recursion would be:\n\nCreate a map counters to store a counter for each level. E.g. counters[i] is the number of nodes found so far at level i. Let's say level 0 is the root.\nDefine a recursive function count_subtree(node, level): Increment counters[level] once. Then for each child of the given node, call count_subtree(child, level + 1) (the child is at a 1-deeper level).\nCall count_subtree(root_node, 0) to count starting at the root. This will result in count_subtree being run exactly once on each node because each node only has one parent, so counters[level] will be incremented once per node. A leaf node is the base case (no children to call the recursive function on).\nBuild your final list from the values of counters, ordered by their keys ascending.\n\nThis would work with any kind of tree, not just binary. Running time is O(number of nodes in tree). Side note: The depth-first search solution would be easier to divide and run on parallel processors or machines than a similar breadth-first search solution.","Q_Score":3,"Tags":"python,python-3.x,tree,binary-tree,tree-traversal","A_Id":49911007,"CreationDate":"2018-04-18T21:14:00.000","Title":"Count number of nodes per level in a binary tree","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Keras for a regression task and want to restrict my output to a range (say between 1 and 10)\nIs there a way to ensure this?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":8004,"Q_Id":49911206,"Users Score":6,"Answer":"Normalize your outputs so they are in the range 0, 1. Make sure your normalization function lets you transform them back later.\nThe sigmoid activation function always outputs between 0, 1. Just make sure your last layer has sigmoid activation to restrict your output into that range. Now you can take your outputs and transform them back into the range you wanted.\nYou could also look into writing your own activation function to transform your data.","Q_Score":8,"Tags":"python,neural-network,keras,regression","A_Id":49911299,"CreationDate":"2018-04-19T01:13:00.000","Title":"How to restrict output of a neural net to a specific range?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm getting the ModuleNotFoundError: No module named 'lxml' while trying run a python script in Mac os. \nI've installed python in \/usr\/local\/bin. All the libraries are also successfully installed. \nI tried setting the PATH to include the location where the libraries are installed, but it didn't help. Please advise.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":358,"Q_Id":49912414,"Users Score":0,"Answer":"This is fixed by setting the PYTHONPATH Variable in OS X.","Q_Score":0,"Tags":"python,macos","A_Id":49923516,"CreationDate":"2018-04-19T03:50:00.000","Title":"ModuleNotFoundError in Python3.6 Mac OS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"This is the error : \nSolving environment: failed\nUnsatisfiableError: The following specifications were found to be in conflict:\n  - numba -> numpy[version='>=1.14,<1.15.0a0']\n  - tensorflow\nUse \"conda info \" to see the dependencies for each package.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1294,"Q_Id":49914882,"Users Score":3,"Answer":"You have to run the conda info tensorflow and conda info numba to see each dependencies for each package and then you have to install those package like conda install package=version to fix the problem.","Q_Score":0,"Tags":"python,tensorflow,anaconda,jupyter-notebook,conda","A_Id":49915763,"CreationDate":"2018-04-19T07:12:00.000","Title":"I get the following error whenever I try to run conda install tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the Spyder editor and I have to go back and forth from the piece of code that I am writing to the definition of the functions I am calling. I am looking for shortcuts to move given this issue. I know how to go to the function definition (using Ctrl + g), but I don't know how to go back to the piece of code that I am writing. Is there an easy way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2018,"Q_Id":49915867,"Users Score":4,"Answer":"(Spyder maintainer here) You can use the shortcuts Ctrl+Alt+Left and Ctrl+Alt+Right to move to the previous\/next cursor position, respectively.","Q_Score":3,"Tags":"python,keyboard-shortcuts,spyder","A_Id":49985209,"CreationDate":"2018-04-19T08:06:00.000","Title":"Going back to previous line in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using PyCharm in ubuntu. I have access to an external server to which I connect my PC via ssh.\nHow can I edit codes using PyCharm on my PC but run the codes within PyCharm (by hitting Ctrl+F5 to be clear, so without the server's terminal) using the server's python (and computing power)? \nIs there any other IDE capable of doing it?\nAlso, if inputs are needed and outputs are created, can they be stored locally on my PC?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":49919115,"Users Score":0,"Answer":"Yeah, but you need Professional version of PyCharm.\nFirst, you need to establish an interpreter:\n\nGo to File -> Settings -> Project -> Project Interpreter -> wheel button -> Add -> SSH Interpreter. \nConfigure host, port, username and press Next. \nConfigure your authentication option (password or key pair). \nPress Next and configure your python environment (by default: \/usr\/bin\/python). You can put here your Python executable of your virtualenv.\n\nSecond, configure Deployment:\n\nGo to File -> Settings -> Build, Execution, Deployment -> Deployment. \nAdd a new one by hitting the + green button. \nIn Type, choose SFTP. \nConfigure host, port, username and authentication in Connection. \nIn Mappings, you need to configure where the project is on your local and remote hosts.\n\nThen, in Tools -> Deployment, check \"Automatic Upload (always)\".\nNow, when you hit Ctrl + S to save, or run your project, it automatically saves in your local and remote hosts, and runs in the remote server.\nIf you need to access to the files in the remote host, you can add an FTP view in Tools -> Deployment -> Browse Remote Host.","Q_Score":0,"Tags":"python,bash,ssh,pycharm","A_Id":49919597,"CreationDate":"2018-04-19T10:43:00.000","Title":"Python run via ssh bur edit locally","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've written a program that has a common resource \"Candle Set\", 5 thread agents that get candles from the candle set, call them \"Workers\", and another thread agent that updates the candle set, called \"Candle Agent\".\nAll threads hold on to the same threading.Condition()\nWorkflow is as follows:\nWorkers wait() on the condition until the candle agent updated the candle set. Candle agent updates candle set, does a notifyAll() on the condition and goes to time.sleep() for 5 minutes.\nMeanwhile, the workers wake up, each one takes a candle from the candle set, does some action and goes back to wait() on the condition again.\nIt all seems to works fine, problem is, for some reason when all threads are in wait() state and the candle agent is in time.sleep(), the task manager of my computer shows python is taking up to 23%.\nI also reduced the amount of workers to 1, thus having 1 worker thread and 1 candle agent thread, and still the same CPU consumption...\nWhy is this happening and how can I reduce the CPU consumption when there should be no thread activity? Please help...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":180,"Q_Id":49920154,"Users Score":0,"Answer":"Found the problem! If anyone stumbles upon this in the future, check your main thread for loops! That was the bug in my case","Q_Score":0,"Tags":"python,multithreading,cpu","A_Id":50164652,"CreationDate":"2018-04-19T11:38:00.000","Title":"Python: Why waiting threads take so much CPU","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to run a python script on my mac computer, but I ended up in troubles as it needed to install pandas as a dependency.\nI tried to get this dependency, but to do so I installed different components like brew, pip, wget and others including different versions of python using brew, .pkg package downloaded from python.org.\nIn the end, I was not able to run the script anyway.\nNow I would like to sort out the things and have only one version of python (3 probably) working correctly.\nCan you suggest me the way how to get the overview what I have installed on my computer and how can I clean it up?\nThank you in advance","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":5129,"Q_Id":49920886,"Users Score":4,"Answer":"Use brew list to see what you've installed with Brew. And Brew Uninstall as needed. Likewise, review the logs from wget to see where it installed things. Keep in mind that MacOS uses Python 2.7 for system critical tasks; it's baked-into the OS so don't touch it.\nAnything you installed with pip is saved to the \/site-packages directory of the Python version in which you installed it so it will disappear when you remove that version of Python.\nThe .pkg files installed directly into your Applications folder and can be deleted safely like any normal app.","Q_Score":2,"Tags":"python,macos,pip,homebrew","A_Id":49921063,"CreationDate":"2018-04-19T12:15:00.000","Title":"clean up python versions mac osx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using MicroPython extension, and have successfully flashed the MicroPython firmware (Operating System) to the ESP8266 target device using the NodeMCU flasher tool through a serial COM port.\nAfter creating a new project by selecting the project folder I'm told auto detection of COM ports isn't available for Windows version of Visual Studio Code. I'm prompted to manually enter the COM port I've connected the target MicroPython device to, and VSC then says:\nPort not exist, please connect device and try again!\nI've tried all 4 USB ports, reinstalled the driver software, rebooted the computer, power cycled the target device and made sure the target device is in program flash mode (to allow application to be written to it) each time I attempt to connect VSC to it!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":894,"Q_Id":49922339,"Users Score":0,"Answer":"I'd suggest using the pycom pymakr extension. \npymakr connects via both serial USB as well as over TCP if your board\/firmware can run telnet","Q_Score":0,"Tags":"python,visual-studio-code,esp8266,micropython","A_Id":53960757,"CreationDate":"2018-04-19T13:28:00.000","Title":"USB visible in firmware flasher tool, but not Visual Studio Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an numpy array in python that represent an image its size is 28x28x3 while the max value of it is 0.2 and the min is -0.1. I want to scale that image between 0-255. How can I do so?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":18784,"Q_Id":49922460,"Users Score":3,"Answer":"You can also use uint8 datatype while storing the image from numpy array.\nimport numpy as np\n from PIL import Image\n img = Image.fromarray(np.uint8(tmp))\ntmp is my np array of size 255*255*3.","Q_Score":10,"Tags":"python,image,numpy","A_Id":52469364,"CreationDate":"2018-04-19T13:34:00.000","Title":"Scale a numpy array with from -0.1 - 0.2 to 0-255","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can write 'something '.strip() and get something in return or I can type str(8) and get '8' in return. Also, type ('a') returns str as the response. Is str a function (which converted a numeric 8 to '8') or a class, which has methods such as strip(), etc.?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":165,"Q_Id":49922996,"Users Score":2,"Answer":"It is a class, whose constructor can get any Python object, and attempts to convert that to a string according to rules built-in the language.\nThe first thing it tries to do is to call the __str__ method in the passed in object. If that does not exist, it tries to call the __repr__ method. Whatever is returned is used as the new built string.\nHowever, str is trully the  string class in Python, were all string methods are defined.","Q_Score":0,"Tags":"python","A_Id":49923202,"CreationDate":"2018-04-19T13:58:00.000","Title":"str - Function, Class or Method","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am loading the data using COPY command. \nMy Dates are in the following format. \n\nD\/MM\/YYYY eg. 1\/12\/2016\nDD\/MM\/YYYY eg. 23\/12\/2016\n\nMy target table data type is DATE. I am getting the following error \"Invalid Date Format - length must be 10 or more\"","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1414,"Q_Id":49926250,"Users Score":2,"Answer":"As per the AWS Redshift documentation, \n\nThe default date format is YYYY-MM-DD. The default time stamp without\n  time zone (TIMESTAMP) format is YYYY-MM-DD HH:MI:SS.\n\nSo, as your date is not in the same format and of different length, you are getting this error. Append the following at the end of your COPY command and it should work.\n[[COPY command as you are using right now]] + DATEFORMAT 'DD\/MM\/YYYY'\nNot sure about the single digit case though. You might want to pad the incoming values with a 0 in the beginning to match the format length.","Q_Score":2,"Tags":"python,amazon-redshift","A_Id":49926489,"CreationDate":"2018-04-19T16:46:00.000","Title":"Redshift COPY Statement Date load error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to process linux file with multiple parts in the name like:\nabc.def.gh.bz2\nbz2 is the real extension, I need to get abc.def.gh\nCan anyone tell me an elegant way to do this in python?\nThank you very much.","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2511,"Q_Id":49927030,"Users Score":2,"Answer":".rfind() to find the last dot.\n\ne.g \"abc.def.gh.bz2\".rfind(\".\") would find the index of the last dot\nAny dot below that index would not often* be indicator of filetype. So you could then do e.g filename = \"abc.def.gh.bz2\"[:\"abc.def.gh.bz2\".rfind(\".\")] which should slice away the extension, making filename to be a string of abc.def.gh\n*Though, keep in mind that in some cases e.g tar.gz or gh.bz2 should perhaps be counted as filename extensions. So keep in mind that what is a filename is a rather fleetly subject\nUsing import os.path.splitext is no guarantee at all to getting the \"filename\". and all it will do is slice the . extension from the string passed to it","Q_Score":2,"Tags":"python,string","A_Id":49927079,"CreationDate":"2018-04-19T17:36:00.000","Title":"What's the elegant way to get filename that contains more than one dot in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am looking for a good approach using python libraries to tackle the following problem:\nI have a dataset with a column that has product description. The values in this column can be very messy and would have a lot of other words that are not related to the product. I want to know which rows are about the same product, so I would need to tag each description sentence with its main topics. For example, if I have the following: \n\"500 units shoe green sport tennis import oversea plastic\", I would like the tags to be something like: \"shoe\", \"sport\". So I am looking to build an approach for semantic tagging of sentences, not part of speech tagging. Assume I don't have labeled (tagged) data for training. \nAny help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":184,"Q_Id":49929066,"Users Score":2,"Answer":"Lack of labeled data means you cannot apply any semantic classification method using word vectors, which would be the optimal solution to your problem. An alternative however could be to construct the document frequencies of your token n-grams and assume importance based on some smoothed variant of idf (i.e. words that tend to appear often in descriptions probably carry some semantic weight). You can then inspect your sorted-by-idf list of words and handpick(\/erase) words that you deem important(\/unimportant). The results won't be perfect, but it's a clean and simple solution given your lack of training data.","Q_Score":1,"Tags":"python-2.7,nlp,nltk,gensim,semantic-analysis","A_Id":49935903,"CreationDate":"2018-04-19T19:44:00.000","Title":"Clear approach for assigning semantic tags to each sentence (or short documents) in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a API build using Python\/Flask, and I have a endpoint called \/build-task that called by the system, and this endpoint takes about 30 minutes to run. \nMy question is that how do I lock the \/build-task endpoint when it's started and running already? So so other user, or system CANNOT call this endpoint.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":709,"Q_Id":49930033,"Users Score":2,"Answer":"You have some approaches for this problem:\n1 - You can create a session object, save a flag in the object and check if the endpoint is already running and respond accordingly.\n2 - Flag on the database, check if the endpoint is already running and respond accordingly.","Q_Score":1,"Tags":"python,flask","A_Id":49930152,"CreationDate":"2018-04-19T20:49:00.000","Title":"Python\/Flask: only one user can call a endpoint at one time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have Redis as my Cache Server. When I call delay() on a task,it takes more than 10 tasks to even start executing. Any idea how to reduce this unnecessary lag?\nShould I replace Redis with RabbitMQ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":788,"Q_Id":49930990,"Users Score":0,"Answer":"It's very difficult to say what the cause of the delay is without being able to inspect your application and server logs, but I can reassure you that the delay is not normal and not an effect specific to either Celery or using Redis as the broker. I've used this combination a lot in the past and execution of tasks happens in a number of milliseconds.\nI'd start by ensuring there are no network related issues between your client creating the tasks, your broker (Redis) and your task consumers (celery workers).\nGood luck!","Q_Score":1,"Tags":"python,django,asynchronous,redis,celery","A_Id":49931421,"CreationDate":"2018-04-19T22:13:00.000","Title":"After delay() is called on a celery task, it takes more than 5 to 10 seconds for the tasks to even start executing with redis as the 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 trying to import spacy using Jupyter Notebooks and running into a problem. Every time I try to import it, it says that it cannot find the module, even though the regular python shell interpreter works just fine.\nInformation:\n\nConda Environment\ninstalled using conda install -c conda-forge spacy\nshows up in conda list | grep spacy\nJupyter can find other packages in the conda env, just not spacy\n\nThank you for any help you can provide.\nEDIT: Terminal Commands:\n1. cd into project directory\n2. conda create -n <env name>\n3. source activate <env name>\n4. conda install -c conda-forge spacy\n5. python -m spacy download en\n6. python\n- import spacy            #works!\n- nlp = spacy.load('en')  #works!\n- quit()\n7. ipython\n- import spacy\nModuleNotFoundError: No module named 'spacy'\n\nEDIT2:\nFigured it out. My sys.path was different in ipython and wasn't searching through the conda env. I had to run conda install jupyter in the env and then everything worked. Apparently the root jupyter doesn't detect if you're inside an environment or not.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":9968,"Q_Id":49933974,"Users Score":0,"Answer":"I faced a similar issue when I installed Spacy in Windows. I just had to run my command window as administrator. \nSometimes we make stupid mistakes :)","Q_Score":8,"Tags":"python,path,nlp,anaconda,jupyter-notebook","A_Id":52667869,"CreationDate":"2018-04-20T04:24:00.000","Title":"'No module named spacy' in ipython, but works fine in regular python interpretter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently trying to import spacy using Jupyter Notebooks and running into a problem. Every time I try to import it, it says that it cannot find the module, even though the regular python shell interpreter works just fine.\nInformation:\n\nConda Environment\ninstalled using conda install -c conda-forge spacy\nshows up in conda list | grep spacy\nJupyter can find other packages in the conda env, just not spacy\n\nThank you for any help you can provide.\nEDIT: Terminal Commands:\n1. cd into project directory\n2. conda create -n <env name>\n3. source activate <env name>\n4. conda install -c conda-forge spacy\n5. python -m spacy download en\n6. python\n- import spacy            #works!\n- nlp = spacy.load('en')  #works!\n- quit()\n7. ipython\n- import spacy\nModuleNotFoundError: No module named 'spacy'\n\nEDIT2:\nFigured it out. My sys.path was different in ipython and wasn't searching through the conda env. I had to run conda install jupyter in the env and then everything worked. Apparently the root jupyter doesn't detect if you're inside an environment or not.","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":9968,"Q_Id":49933974,"Users Score":6,"Answer":"Figured it out. My sys.path was different in ipython v python shell. ipython wasn't searching through the conda env. \nI had to run conda install jupyter in the env and then everything worked. Apparently the root jupyter doesn't detect if you're inside an environment or not. This makes sense now that I know some more about the internals as it needs to identify with a specific ipykernel.\nHope this helps anyone else running into the same issue.","Q_Score":8,"Tags":"python,path,nlp,anaconda,jupyter-notebook","A_Id":49947290,"CreationDate":"2018-04-20T04:24:00.000","Title":"'No module named spacy' in ipython, but works fine in regular python interpretter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi I have a Python(version 3.6) script which i developed in my laptop. But i would need to run the script from another server. I have installed the same version of Python on the server but not the modules which are imported in my script. These modules are installed on my laptop though. \nIs it possible to run the puthon script from the server without installing the imported modules in the server?\nThanks\nShanto","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2326,"Q_Id":49934177,"Users Score":0,"Answer":"I think you can use pynistaller or py2exe or any other package for converting python scripts to executable files. \nOnce executable files(.exe) files are created you can run that file without installing python modules","Q_Score":2,"Tags":"python,module,server,libraries","A_Id":50198799,"CreationDate":"2018-04-20T04:48:00.000","Title":"Is it possible to run python script from another machine without installing imported 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":"Today I went from Windows 7 to Windows 10, and sadly I meet troubles with Sublime Text which is my main text editor. (my main specs are Intel Core i7, 8 GBRAM, 500 GB SSD on a laptop Dell XPS 14 L421x)\nRunning python in Spider is extremely fast (<1s). But in Sublime Text 3, just importing numpy, matplotlib and scipy takes up to 4 secondes. I really don't understand what is going on. I installed the last version of python 3.6.5 through Anaconda. I tested the same version on a Windows 7 computer and it does not have this issue (~1.5s for just the import).\nWould you have any clue about what is going on? Thank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":49934424,"Users Score":0,"Answer":"I found the problem, it is just because my account was not Administrator of Windows. I don't know why dip down, but it solved the situation.","Q_Score":0,"Tags":"python,windows-10,sublimetext3","A_Id":49951255,"CreationDate":"2018-04-20T05:12:00.000","Title":"Import python packages slower on Windows 10 in Sublime 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 know GIL blocks python from running its threads across cores. If it does so, why python is being used in webservers, how are the companies like youtube, instagram handling it.\nPS: I know alternatives like multiprocessing can solve it. But it would be great if anyone can post it with a scenario that was handled by them.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":1423,"Q_Id":49934932,"Users Score":4,"Answer":"Python is used for server-side handling in webservers, but not (usually) as webserver.\nOn normal setup: we have have Apache or other webserver to handles a lot of processes (server-side) (python uses usually wsgi). Note usually apache handles directly \"static\" files. So we have one apache server, many parallel apache processes (to handle connection and basic http) and many python processes which handles one connection per time.\nEach of such process are independent each others (they just use the same resources), so you can program your server side part easily, without worrying about deadlocks. It is mostly a trade-off: performance of code, and easy and quickly to produce code without huge problems. But usually webserver with python scale very well (also on large sites), and servers are cheaper then programmers.\nNote: security is also increased by having just one request in a process.","Q_Score":7,"Tags":"python,django,web-services,gil","A_Id":49938239,"CreationDate":"2018-04-20T05:56:00.000","Title":"Regarding GIL in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Idea behind nullifying\/ignoring a feature from test set is to understand how important is it considered by the model to predict the target variable (by comparing the evaluation metric's value). For numerical variables, I thought of setting them to 0, assuming the multiplication (with weights) would be 0 and thus it would get eliminated from the set. Is this approach right, else what should be done?\nI am using tensorflow's DNNRegressor for modelling.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":49935491,"Users Score":0,"Answer":"For deep models there's no general input-independent way to do this kind of feature ablation you want (take a pretrained model and just change that feature's representation on the test set).\nInstead I recommend you do training time ablation: train different variations of your model with different feature combinations and compare their validation set performances. This will actually tell you how much each feature helps.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,deep-learning,regression","A_Id":50009358,"CreationDate":"2018-04-20T06:37:00.000","Title":"Is there a way to nullify a specific feature in test set while evaluating a tensorflow model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created several Keras models (Model_1, Model_2...Model_N) in one code. I would like to clear only one specified model (e.g. Model_1).\nI guess K.clear_session(), which will clear all models from the memory, is not useful in this case. Is there any solution?\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":49936467,"Users Score":0,"Answer":"you can use del[] to explicitly delete the variables you no longer need, this triggers python's garbage collector. so put all the variables associated with that model inside del[] and python would free the memory.","Q_Score":2,"Tags":"python,keras","A_Id":49936800,"CreationDate":"2018-04-20T07:36:00.000","Title":"How can a specific model be cleared from the memory?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a program that is using . as decimal symbol. But my friend in Vietnam uses , as decimal symbol. Is there a way to change that using a python script?\nEdit 1: I'm talking about system wide. I need a python script that autochange system decimalsymbol to the dot '.'. Thank @CristiFati","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":158,"Q_Id":49936803,"Users Score":0,"Answer":"I'm done with Googling. Just using registry and set decimal value.","Q_Score":0,"Tags":"python,windows,python-3.x","A_Id":50210717,"CreationDate":"2018-04-20T07:57:00.000","Title":"can I change the Window system format via python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a giant English words dictionary and I'm trying to get all the words that contain the same letters of another word, for example, if given aplep, I want it to give apple or if given applej it should be apple as well, I've tried gaining all the permutations from the word but then it becomes unreasonable for big words, anyone has any thoughts? \nEDIT: The dictionary is a txt file with line delimiter\nThanks.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":49940847,"Users Score":0,"Answer":"To iterate on @Jean-Fran\u00e7oisFabre's answer.\nYou can store the sorted words in a sort of prefix tree, a data structure that has the sorted words in leaves and the path to a word is an increasing prefix of those words. \nFor example: if you have 'abc' and 'abd' in your dictionary the structure would look like \na\n  \\\n  ab\n \/ \\\nabc abd\nIf you want all words containing 'ab' you traverse the tree, and use all following nodes as keys in a dictionary to find the unsorted words","Q_Score":0,"Tags":"python","A_Id":49941100,"CreationDate":"2018-04-20T11:40:00.000","Title":"Finding all letters of a word in a textfile","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question concerning tuning hyperparameters for the Inception ResNet V2 model (or any other DL model), which I can't really wrap my head around.\nRight now, I have certain set certain hyperparameters, such as learning_rate, decay_factor and decay_after_nr_epochs. My model saves checkpoints, so it can continue at these points later on. \nIf I run the model again, with more epochs, it logically continues at the last checkpoint to continue training.\nHowever, if I would set new hyperparameters, such as learning_rate = 0.0001 instead of learning_rate = 0.0002, does it make sense to continue on the checkpoints, or is it better to use new hyperparameters on the initial model? \nThe latter sounds more logical to me, but I'm not sure whether this is necessary. \nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":470,"Q_Id":49941265,"Users Score":1,"Answer":"Both the methods are okay but you have to see your training loss after adjusting them. If they are converging in both the cases then it's fine otherwise adjust accordingly.\nHowever, people adopt these two methods as far as I know 1. Keep a higher learning rate initially and keep a decay factor, thus reducing your learning rate slowly as it starts converging. 2. You can keep an eye on loss function and do early stopping if you think you can adjust to better learning rate.","Q_Score":0,"Tags":"python,tensorflow,deep-learning","A_Id":49943047,"CreationDate":"2018-04-20T12:04:00.000","Title":"Tuning hyperparameters Inception model with checkpoints","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently installed Komodo Editor to write some Python 3 code. I can open the files provided by instructor, however cannot create and run my own files. \nWhen I try to run them, I get the following \"env. (file directory) \": Permission denied\". \nHow to create and run new Python programs in Komodo editor?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1061,"Q_Id":49943588,"Users Score":2,"Answer":"you can check the permissions of the file by using the command in terminal ls -l \"(file directory)\/filename.py\" if it is missing the x in rwx like mine was, you can reset it by using chmod 700 \"file directory\/filename.py\" \nor do:\nchmod +x \"file directory\/filename.py\"","Q_Score":1,"Tags":"python,python-3.x,komodo","A_Id":52348404,"CreationDate":"2018-04-20T14:09:00.000","Title":"Can't create and run new python file in Komodo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using lightgbm.train with valid_sets, early_stopping_rounds and feval function for multiclass problem with \"objective\": \"multiclass\". I want to find best_iteration and best_score for my custom evaluation function. But it finds them for multi_logloss metrics, which is corresponding to specified objective. So the question is can I find in LightGBM best_iteration and best_score for my feval function and how?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":472,"Q_Id":49943689,"Users Score":0,"Answer":"You can use objective:\"multi_error\", or also you can combine objectives as\nobjective: \"multi_error\", \"multi_logloss\"\nMulti_error will directly focus on the accuracy.","Q_Score":0,"Tags":"python-3.x,lightgbm","A_Id":52770137,"CreationDate":"2018-04-20T14:13:00.000","Title":"LightGBM Python API. Best_iteration and best_score for custom evaluation function (feval)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have built a predictive model  in Windows to train the dataset using python 3.6.1. I have used pickle to save the train model as a Pickle file\nNow I have written a another python script to read and load the train pickle file to predict the test data.\nI have got results successful in Windows.\nNow I want to move the Train pickle file and the Python script (that used the Train pickle file to predict the model using test data) to Linux environment which has the similar version of python installation as that of windows.But the python installation in Linux doesn't include machine learning libraries.\nIn such a case will the Train pickle file of windows behave as a exe file having all the machine learning libraries?\nWill the python script that loads and read the train pickle file to predict the data fail in Linux as it does not any machine learning libraries installed.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":984,"Q_Id":49947850,"Users Score":1,"Answer":"Pickling is just the python form of serialization.  Serialization only preserves raw data, such as strings, integers, floats, lists, and similar things.\nIf you pickle a model, you can unpickle it and use it later, but if you don't have the libraries (keras, tensorflow, or whatever you need), you cannot use it on that machine.","Q_Score":1,"Tags":"python","A_Id":49947979,"CreationDate":"2018-04-20T18:38:00.000","Title":"Python pickle for Machine Learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using cartopy to plot images on geographic axes. I used the Mercator projection to plot my data. However I realized that the equal aspect ratio is based on degrees and not in km. How can I do to force the map to respect a 1 km x 1 km aspect ratio instead of a 1\u00b0 x 1\u00b0 aspect ratio.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":160,"Q_Id":49950672,"Users Score":1,"Answer":"The aspect ratio of a Mercator projection isn't actually 1\u00b0:1\u00b0, but is instead 1:1 in cartesian \"Mercator units\". The Mercator projection doesn't preserve distance along the meridians, and therefore the higher (or lower) you go in latitude in the Mercator projection, the longer (in physical distance) 1 Mercator unit is in the y direction.\nAs 1\u00b0 has approximately the same length anywhere on the Earth (assuming a perfect sphere), you are actually looking for a projection that does preserve the 1\u00b0 x 1\u00b0 aspect ratio. At high-resolution, many map projections are good representations of 1km:1km, but at global scale there are only a few good choices.\nEssentially, you are looking for a projection that is equidistant along both parallels and meridians, and the most obvious projection with that property is Plate Carree \/ Equirectangular (all cylindrical projections are equidistant along parallels, but Plate Carree is equidistant along meridians too).","Q_Score":0,"Tags":"python-3.x,cartopy","A_Id":51285200,"CreationDate":"2018-04-20T22:54:00.000","Title":"Using Cartopy by respecting 1 to 1 km aspect ratio","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a very large HDF5 file created using Python\/ h5py. I cannot open the file on HDFView 2.14, when I try to open the file nothing happens. Any suggestions on how I can open\/ view the file? It contains just 5 datasets, but each dataset has 778 million rows.. hence the problem. \nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":626,"Q_Id":49950725,"Users Score":0,"Answer":"you can edit your hdfview.bat and add more memory on the switch\nthis is the line on .bat file:\nstart \"HDFView\" \"%JAVABIN%\\javaw.exe\" %JAVAOPTS% -Xmx1024M -Djava.library.path=\"%INSTALLDIR%\\lib;%INSTALLDIR%\\lib\\ext\" -Dhdfview.root=\"%INSTALLDIR%\" -cp \"%INSTALLDIR%\\lib\\fits.jar;%INSTALLDIR%\\lib\\netcdf.jar;%INSTALLDIR%\\lib\\jarhdf-3.3.2.jar;%INSTALLDIR%\\lib\\jarhdf5-3.3.2.jar;%INSTALLDIR%\\lib\\slf4j-api-1.7.5.jar;%INSTALLDIR%\\lib\\extra\\slf4j-nop-1.7.5.jar;%INSTALLDIR%\\lib\\HDFView.jar\" hdf.view.HDFView %*\nyou can edit -Xmx1024M to more like: -Xmx4024M\nit add more memory to java machine","Q_Score":1,"Tags":"python,out-of-memory,hdf5,h5py,hdf","A_Id":50278726,"CreationDate":"2018-04-20T23:01:00.000","Title":"Viewing a large (12.5GB) HDF5 file written using h5py on HDFView 2.14","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to have a virtual environment setup with python 3 if my OS has python 2.7 installed, I am using \"$ virtualenv python3env -p python3\" but its trying to look for a PATH for python3 on my system. Is there a work around for this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":49951134,"Users Score":0,"Answer":"install python3, DON'T delete your python2\nafter installing python3, make sure the to add the directory to PATH\nchange the binary(python,pythonw) inside python3 to python3\/pythonw3\ntry to setup virtual environment using the same command in your post and you should now created a python3 virtual environment","Q_Score":1,"Tags":"python,python-3.x,virtualenv","A_Id":49951186,"CreationDate":"2018-04-21T00:08:00.000","Title":"How to install virtual environment with python 3 without upgrading existing version of python on my OSX which is 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am going to implement RNN using Pytorch . But , before that , I am having some difficulties in understanding the character level one-hot encoding which is asked in the question .\nPlease find below the question \n\nChoose the text you want your neural network to learn, but keep in mind that your\ndata set must be quite large in order to learn the structure! RNNs have been trained\non highly diverse texts (novels, song lyrics, Linux Kernel, etc.) with success, so you\ncan get creative. As one easy option, Gutenberg Books is a source of free books where\nyou may download full novels in a .txt format.\nWe will use a character-level representation for this model. To do this, you may use\nextended ASCII with 256 characters. As you read your chosen training set, you will\nread in the characters one at a time into a one-hot-encoding, that is, each character\nwill map to a vector of ones and zeros, where the one indicates which of the characters\nis present:\nchar \u2192 [0, 0, \u00b7 \u00b7 \u00b7 , 1, \u00b7 \u00b7 \u00b7 , 0, 0]\nYour RNN will read in these length-256 binary vectors as input.\n\nSo , For example , I have read a novel in python. Total unique characters is 97. and total characters is somewhere around 300,000 .\nSo , will my input be 97 x 256 one hot encoded matrix ?\nor will it be 300,000 x 256 one hot encoded matrix ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":147,"Q_Id":49954852,"Users Score":1,"Answer":"One hot assumes each of your vector should be different in one place. So if you have 97 unique character then i think you should use a 1-hot vector of size ( 97 + 1 = 98). The extra vector maps all the unknown character to that vector. But you can also use a 256 length vector. So you input will be:\nB x N x V ( B = batch size, N = no of characters , V = one hot vector size).\nBut if you are using libraries they usually ask the index of characters in vocabulary and they handle index to one hot conversion. Hope that helps.","Q_Score":0,"Tags":"python-3.x,recurrent-neural-network,pytorch,rnn","A_Id":49956444,"CreationDate":"2018-04-21T10:32:00.000","Title":"RNN Implementation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have code like this, I want to check in the time range that has overtime and sum it.\ncurrently, am trying out.hour+1 with this code, but didn't work.\n\n\n    overtime_all = 5\n    overtime_total_hours = 0\n    out = datetime.time(14, 30)\n\n    while overtime_all > 0:\n        overtime200 = object.filter(time__range=(out, out.hour+1)).count()\n        overtime_total_hours = overtime_total_hours + overtime200\n        overtime_all -=1\n\n    print overtime_total_hours\n\n\nhow to add 1 hour every loop?...","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2174,"Q_Id":49955821,"Users Score":1,"Answer":"Timedelta (from datetime) can be used to increment or decrement a datatime objects. Unfortunately, it cannot be directly combined with datetime.time objects. \nIf the values that are stored in your time column are datetime objects, you can use them (e.g.: my_datetime + timedelta(hours=1)). If they are time objects, you'll need to think if they represent a moment in time (in that case, they should be converted to datetime objects) or a duration (in that case, it's probably easier to store it as an integer representing the total amount of minutes, and to perform all operations on integers).","Q_Score":2,"Tags":"python,django","A_Id":49955858,"CreationDate":"2018-04-21T12:34:00.000","Title":"add +1 hour to datetime.time() django on forloop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have code like this, I want to check in the time range that has overtime and sum it.\ncurrently, am trying out.hour+1 with this code, but didn't work.\n\n\n    overtime_all = 5\n    overtime_total_hours = 0\n    out = datetime.time(14, 30)\n\n    while overtime_all > 0:\n        overtime200 = object.filter(time__range=(out, out.hour+1)).count()\n        overtime_total_hours = overtime_total_hours + overtime200\n        overtime_all -=1\n\n    print overtime_total_hours\n\n\nhow to add 1 hour every loop?...","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2174,"Q_Id":49955821,"Users Score":1,"Answer":"I found the solution now, and this is work.\n\n\n    overtime_all = 5\n    overtime_total_hours = 0\n    out = datetime.time(14, 30)\n\n    while overtime_all > 0:\n        overtime200 = object.filter(time__range=(out,datetime.time(out.hour+1, 30))).count()\n        overtime_total_hours = overtime_total_hours + overtime200\n        overtime_all -=1\n\n    print overtime_total_hours\n\ni do change out.hour+1 to datetime.time(out.hour+1, 30) its work fine now, but i dont know maybe there more compact\/best solution.\nthank you guys for your answer.","Q_Score":2,"Tags":"python,django","A_Id":49956349,"CreationDate":"2018-04-21T12:34:00.000","Title":"add +1 hour to datetime.time() django on forloop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to crawl IMDB and download the trailers of movies (either from YouTube or IMDB) that fit some criteria (e.g.: released this year, with a rating above 2). \nI want to do this in Python - I saw that there were packages for crawling IMDB and downloading YouTube videos. The thing is, my current plan is to crawl IMDB and then search youtube for '$movie_name' + 'trailer' and hope that the top result is the trailer, and then download it.\nStill, this seems a bit convoluted and I was wondering if there was perhaps an easier way. \nAny help would be appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1369,"Q_Id":49957297,"Users Score":0,"Answer":"There is no easier way. I doubt IMDB allows people to scrap their website freely so your IP is probably gonna get blacklisted and to counter that you'll need proxies. Good luck and scrape respectfully.\nEDIT: Please take a look at @pds's answer below. My answer is no longer valid.","Q_Score":0,"Tags":"python,youtube,web-crawler","A_Id":49957379,"CreationDate":"2018-04-21T15:23:00.000","Title":"Crawling IMDB for movie trailers?","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-set for which consist 2000 lines in a text file.\nEach line represents x,y,z (3D coordinates location) of 20 skeleton joint points  of human body (eg: head, shoulder center, shoulder left, shoulder right,......, elbow left, elbow right). I want to do k-means clustering of this data.\nData is separated by  'spaces ', each joint is represented by 3 values (Which represents x,y,z coordinates). Like head and shoulder center represented by \n.0255...  .01556600 1.3000...  .0243333 .010000 .1.3102000 .... \nSo basically I have 60 columns in each row, which which represents 20 joints and each joins consist of three points.  \nMy question is how do I format or use this data for k-means clustering,","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":394,"Q_Id":49961977,"Users Score":0,"Answer":"You don't need to reformat anything.\nEach row is a 60 dimensional vector of continous values with a comparable scale (coordinates), as needed for k-means.\nYou can just run k-means on this.\nBut assuming that the measurements were taken in sequence, you may observe a strong correlation between rows, so I wouldn't expect the data to cluster extremely well, unless you set up the use to do and hold certain poses.","Q_Score":0,"Tags":"python,cluster-analysis,k-means,data-science","A_Id":49968114,"CreationDate":"2018-04-22T02:32:00.000","Title":"k-means clustering multi column data in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create table in odoo 10 with the following columns: quantity_in_the_first_day_of_month,input_quantity,output_quantity,quantity_in_the_last_day_of_the_month.\nbut i don't know how to get the quantity  of the specified date","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":185,"Q_Id":49965402,"Users Score":0,"Answer":"You can join the sale order and sale order line to get specified date.\nselect \n    sum(sol.product_uom_qty)\nfrom \n    sale_order s,sale_order_line sol \nwhere \n    sol.order_id=s.id and\n    DATE(s.date_order) = '2018-01-01'","Q_Score":0,"Tags":"python,python-3.x,python-2.7,odoo,odoo-10","A_Id":50134759,"CreationDate":"2018-04-22T11:28:00.000","Title":"How to get the quantity of products in specified date in odoo 10","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have an RNN and way too much training data. Iterating through the data in its entirety will take years. Right now I have two options for training:\n1. Do one pass over as much data as possible\n2. Find a select portion of the data and train for multiple epochs on it\nWhich one is better and why?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":418,"Q_Id":49968000,"Users Score":3,"Answer":"Option 1 is far superior, supposing the data has the same quality throughout.\nThe reason being is that it helps avoid overfitting. One of the biggest issues in ML is that you have a limited amount of data to train on, and the networks tend to overfit that is learn the specific of the set of data instead of generalizing to the problem intended.\nNever repeating the data is actually the ideal situation for training.\nThe only caveat being is if you have the labels very accurately set in certain parts and more sloppily done in others - in that case sticking with the better quality data might be better.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,neural-network,keras","A_Id":49968205,"CreationDate":"2018-04-22T16:07:00.000","Title":"How to train a model when there is too much training data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an RNN and way too much training data. Iterating through the data in its entirety will take years. Right now I have two options for training:\n1. Do one pass over as much data as possible\n2. Find a select portion of the data and train for multiple epochs on it\nWhich one is better and why?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":418,"Q_Id":49968000,"Users Score":2,"Answer":"The question is asked in general terms, so the following is also in general terms.  I hope this contributes something to helping you with your specific problem.\nOne approach would be a variant of cross validation.  You randomly select some portion of the data, and evaluate the result on a second portion of the data. Repeat the entire process until you satisfy your convergence criteria or exhaust your count.  The convergence criteria might be something like getting the same or similar network at some rate.  You can do this in either of two modes, allowing or not allowing reuse of the data.\nA second point to keep in mind is that your execution time depends on the length of your \"feature vectors\" or whatever serves that function in your application.  Selecting the important components of your feature vectors, both reduces the processing time and also can help the training be more successful. Scikit learn has a function SelectKBest() that may be helpful for this.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,neural-network,keras","A_Id":49968311,"CreationDate":"2018-04-22T16:07:00.000","Title":"How to train a model when there is too much training data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Imagine you are measuring the distance of something with a Raspberry Pi. You have a nice python script which measures the distance via a sensor and returns a variable.\nImagine you would like to automate the process and view the results on a web page created with Flask. Basically, be able to turn it on and have it run once a minute regardless of whatever else you do in that web page or anywhere else on the \"website\".\nGraphically:\nclick a button on a web page -> Script starts -> Script runs once a minute, regardless of whether you close the page, navigate to another page, etc.\nHow would you go about it? \nConsider that the script can run forever if necessary, kind of a fire and forget thing","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":62,"Q_Id":49968037,"Users Score":0,"Answer":"you could create a second e.g. python script that would wait for a signal from the web server. With your server, after a user clicked a button, you could write to a file, that the python script periodically checks. Then, after writing \"1\" into the file, the script would do what you want, e.g. read sensor data every minute.\nSo you would run your web server and the python script alongside it. The script would be waiting for changes in the dedicated \"signal\" file. Then after the signal the script would do whatever you wanted.","Q_Score":0,"Tags":"python,python-3.x,flask,automation,raspberry-pi","A_Id":49968268,"CreationDate":"2018-04-22T16:10:00.000","Title":"Run a script repeatedly and externally from Flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have repeatedly installed and uninstalled beautifulsoup4, but no matter what I try to do, when I try to import bs4 in shell, I get ModuleNotFoundError. \nI'm on Windows 10 and using Python 3.6.4. I'm new to programming, but am on my third Python book and this is the first time I've run into a big problem trying to import a module, including those I've installed using pip.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":964,"Q_Id":49969085,"Users Score":0,"Answer":"So, I don't really understand what is happening, but I at least temporarily solved my problem. I have two different \"Lib > site-packages\" directories in my C: drive, and pip is installing in a different one from what Python is using. So I just copied the BeautifulSoup and bs4 folders and pasted them into the one that Python is using, and now it works. \nPython is using this folder: \"C:\\Users\\Victor Hart\\AppData\\Local\\Programs\\Python\\Python36-32\", while pip is installing bs4 and BeautifulSoup here: \"C:\\Users\\Victor Hart\\Envs\\virtual\", which doesn't make any sense to me.","Q_Score":2,"Tags":"python,beautifulsoup,pip","A_Id":49970573,"CreationDate":"2018-04-22T18:03:00.000","Title":"I have installed beautifulsoup4, but when I try to import bs4 in python shell, I get ModuleNotFound Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have repeatedly installed and uninstalled beautifulsoup4, but no matter what I try to do, when I try to import bs4 in shell, I get ModuleNotFoundError. \nI'm on Windows 10 and using Python 3.6.4. I'm new to programming, but am on my third Python book and this is the first time I've run into a big problem trying to import a module, including those I've installed using pip.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":964,"Q_Id":49969085,"Users Score":1,"Answer":"Are you writing-\npip install beautifulsoup4 ?\nThis will install only beautifulsoup4 module and not bs4.\nDo this:-\npip install bs4\nAnd then do this in your python file:-\nfrom bs4 import BeautifulSoup\nAlso you may need administrator access for installing.","Q_Score":2,"Tags":"python,beautifulsoup,pip","A_Id":49969489,"CreationDate":"2018-04-22T18:03:00.000","Title":"I have installed beautifulsoup4, but when I try to import bs4 in python shell, I get ModuleNotFound Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"\/usr\/lib64\/python3.6\/lib-dynload\/_posixsubprocess.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _Py_set_inheritable_async_safe\nafter installing the python3-idle on my opensuse , this message will appear when I try to import something","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1721,"Q_Id":49975494,"Users Score":0,"Answer":"If this happens when importing or using a third-party package, simply uninstall and reinstall the third-party package in question. This fixed it for me. If you don't know which third-party package is relevant, uninstall and reinstall them all.\nThe problem is evidently not with subprocess or _posixsubprocess.","Q_Score":3,"Tags":"linux,python-3.6","A_Id":50220151,"CreationDate":"2018-04-23T07:24:00.000","Title":"Python 3 import error _Py_set_inheritable_async_safe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Can we use Two amazon lambda functions for one lex bot if one lambda function in python and other in node.js?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":506,"Q_Id":49980575,"Users Score":0,"Answer":"you can have two lambda functions for two different intents. You cannot have two lambda functions for the same intent","Q_Score":0,"Tags":"python,machine-learning,aws-lambda,chatbot,amazon-lex","A_Id":49984458,"CreationDate":"2018-04-23T11:59:00.000","Title":"Two amazon lambda functions for one lex 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to be able select the first tab with \u23181, second tab with \u23182, and so on, just like I would in Atom or web browser.\nI couldn't find a way using PyCharm settings, is there some way to do it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":137,"Q_Id":49983219,"Users Score":1,"Answer":"The easiest way navigate through opened tabs with keyboard is:\n\nby using LEFT ALT + LEFT or RIGHT KEY to swich to the left or right.\nor by using CTRL+TAB to enter switcher.","Q_Score":0,"Tags":"python,pycharm,editor,jetbrains-ide","A_Id":49983493,"CreationDate":"2018-04-23T14:06:00.000","Title":"Is there a keyboard shortcut to select tab by number in PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"can I convert all the images to an array saved in one file csv then use those arrays for clustering,\nor do I have to convert one by one image into array form then merge them for used in clustering?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":49983588,"Users Score":0,"Answer":"If you want save data for subsequent uses other than this one you should use csv. Otherwise you could load images directly in arrays, in this case take a look at spark.","Q_Score":0,"Tags":"python,arrays,image,cluster-analysis","A_Id":51364465,"CreationDate":"2018-04-23T14:25:00.000","Title":"Python : Image Clustering","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating an image detection module, and I do a lot of math calculations around arrays.\nI know that C\/C++\u2019s array iterates faster than Python\u2019s\nI can't move my project to C\/C++, so I wanted to create an array module in C\/C++ and call it in Python.\nWhat I want to know:\n1) Is this viable? Or calling a module from another interpreter will slow down my program more than it will speed it up?\n2) Is there some Python package that does what I want?\nI feel like I haven\u2019t written enough info, but I can't think of anything else important.\n[EDIT] So I just went with numpy and it has everything I need :p, thanks everyone","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":111,"Q_Id":49984220,"Users Score":3,"Answer":"Both the array and the low level operations on it would have to be in C++; switching on a per element basis will have little benefit.\nThere are many python modules that have internal C\/C++ implementations.  Simply wrapping a C or C++ style array would be pointless, as the built in python data types can basically be that.","Q_Score":0,"Tags":"python,c++,c,arrays","A_Id":49984333,"CreationDate":"2018-04-23T15:01:00.000","Title":"C++ Vector in Python for Perfomance","Data Science and Machine Learning":1,"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'm creating an image detection module, and I do a lot of math calculations around arrays.\nI know that C\/C++\u2019s array iterates faster than Python\u2019s\nI can't move my project to C\/C++, so I wanted to create an array module in C\/C++ and call it in Python.\nWhat I want to know:\n1) Is this viable? Or calling a module from another interpreter will slow down my program more than it will speed it up?\n2) Is there some Python package that does what I want?\nI feel like I haven\u2019t written enough info, but I can't think of anything else important.\n[EDIT] So I just went with numpy and it has everything I need :p, thanks everyone","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":49984220,"Users Score":0,"Answer":"Try boost.python.\nIf you can port all the computational heavy stuff to C++, it'll be quite fast but if you need to switch continuously between C++ and python, you won't get much improvement.","Q_Score":0,"Tags":"python,c++,c,arrays","A_Id":49984679,"CreationDate":"2018-04-23T15:01:00.000","Title":"C++ Vector in Python for Perfomance","Data Science and Machine Learning":1,"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":"General python question- \nI have built a script using numpy and pandas libraries. I have now been told that I cannot use any libraries- only base python to code. This is because apparently open source libraries are not approved. \n\nDoes this restriction make sense? Isn't base python as open source as pandas\/numpy libraries are?\nIs it possible to convert pandas\/numpy code to base python? Does this sound like a simple exercise or does it require learning a lot of new functions? Majority of the code is reading tables and then using if\/then type statements and looking up values from other tables to generate and populate new tables.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":49984571,"Users Score":0,"Answer":"I'm only going to address the 2nd point. Reimplementing all of numpy\/pandas is certainly a very large and useless task. But you're not reimplementing all of it, you only need some parts, and if it's only a few functions, than it's certainly possible.\nI'd start from a working script, replace arrays by python lists, and implement the needed fucntions one by one. For SO specifically, I suspect you're better off asking specific questions, e.g. how to implement an analog of a function X in pure python etc.","Q_Score":0,"Tags":"python,pandas,numpy","A_Id":49994600,"CreationDate":"2018-04-23T15:21:00.000","Title":"Feasibility of converting all python pandas\/numpy code to base python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In order for Python to talk to MariaDB I need to install mariadb-devel and python34-mysql-debug packages before using pip to install mysqlclient. I have done this with Python and MariaDB on a single server.  Now, I'm installing this in an environment with two servers: AppServer which runs Python code and DBServer which is running MariaDB.    So, do maradb-devel and python34-mysql-debug need to be installed on AppServer or on DBServer?\n\nBoth servers are running RHEL 7.4.\nMariaDB is version 10.1\nPython is version 3.4\n\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":130,"Q_Id":49987101,"Users Score":0,"Answer":"mariadb-devel and python34-mysql-debug packages need to be installed on the application server where Python is running.  I tested this and it is working - I was able to run a simple Python script and connect to the database on the other server.","Q_Score":0,"Tags":"python,mysql,mariadb","A_Id":50026461,"CreationDate":"2018-04-23T17:48:00.000","Title":"Where to install mariadb-devel and python34-mysql-debug packages for python in a split app server \/ db server environment","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two identical neural networks running on two separate computers (to reduce the time taken to train the network), each having a subset of a complete data set (MNIST).\nMy question is; can I combine the two weight matrices of both networks into one matrix, while remaining a proper accuracy? I have seen several articles about 'batching' or 'stochastic gradient descent', but I don't think this is applicable to my situation.\nIf this is possible, could you also provide me with some pseudo code?\nAny input is valuable!\nThank you,","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3859,"Q_Id":49988009,"Users Score":8,"Answer":"In general if you combine the weights \/ biases entirely after training, this is unlikely to produce good results.  However, there are ways to make it work.\nIntuition about combining weights  Consider the following simple example:  You have a MLP with one hidden layer.  Any two instances of the MLP can produce identical outputs for identical inputs if the nodes in the hidden layer are permuted, the weights input->hidden are permuted the same way, and the weights hidden->output are permuted using the inverse permutation.  In other words, even if there was no randomness in what the final network you end up with does, which hidden node corresponds to a particular feature would be random (and determined from the noise of the initializations).  \nIf you train two MLPs like that on different data (or random subsets of the same data), they would likely end up with different permutations of the hidden nodes even if the initializations are all the same, because of the noise of the gradients during training.\nNow, if that a certain property of the input activates most strongly the i-th node of network A and the j-th node of network B (and in general i != j), averaging the weights between the i-th node of A and i-th node of B (which corresponds to a different feature) is likely to decrease performance, or even produce a network that produces nonsense outputs.\nThere are two possible fixes here - you can use either one, or both together.  The idea is to either figure out which nodes match between the two networks, or to force the nodes to match.\nSolution A:  Train both networks on different data for a few iterations.  Average the weights of both, and replace both networks with the average weights.  Repeat.  This makes the i-th node of each network learn the same feature as the matching node of the other network, since they can't ever diverge too far.  They are frequently re-initialized from the average weights, so once the permutation is determined it is likely to stay stable.  \nA reasonable value for how often to average is somewhere between once per epoch and once every few minibatches. Learning is still faster than training one network on all the data sequentially, although not quite 2x faster with 2 networks.  Communication overhead is a lot lower than averaging weights (or gradients) after every minibatch.  This can be run on different machines in a cluster: transferring weights is not prohibitive since it is relatively infrequent.  Also, any number of networks trained at the same time (and splits of the data) can be more than two: up to 10-20 works okay in practice.\n(Hint: for better results, after every epoch, do a new random split of the data between the networks you're training)\nThis is similar in effect to \"gradient aggregation\" that was mentioned here, but aggregates a lot less often.  You can think of it as \"lazy aggregation\". \nSolution B: Try to figure out which hidden layer nodes match before averaging.  Calculate some similarity metric on the weights (could be L2 or anything along those lines), and average the weights of pairs of most-similar nodes from the two networks.  You can also do a weighted average of more than just a pair of nodes; for example you can average all nodes, or the k-most similar nodes, where the weights used are a function of the similarity.  \nFor deep networks, you have to keep track of the pairings all the way up from the input, and permute the weights according to the highest-similarity pairings of the lower level before calculating similarity on the next level (or if doing weighted averaging, propagate the weights).\nThis probably works for a networks with a few layers but I think for very deep networks this is unlikely to work perfectly.  It will still work okay for the first few layers, but tracking the permutations will likely fail to find good matching nodes by the time you get to the top of the network.  \nAnother way to deal with deep networks (other that tracking the permutations up from the bottom) is to run both networks on a test dataset and record the activations of all nodes for each input, then average the weights of nodes which have similar activation pattern (ie which tend to be activated strongly by the same inputs).  Again this could be based on just averaging the most similar pair from A and B, or a suitable weighted average of more than two nodes.\nYou can use this technique together with \"Solution A\" above, to average weights somewhat less often.  You can also use the weighted averaging by node similarity to speed the convergence of \"Solution A\".  In that case it is okay if the method in \"Solution B\" doesn't work perfectly, since the networks are replaced with the combined network once in a while - but the combined network could be better if it is produced by some matching method rather than simple averaging.  Whether the extra calculations are worth it vs the reduced communication overhead in a cluster and faster convergence depends on your network architecture etc.","Q_Score":9,"Tags":"python,matrix,machine-learning,neural-network,mnist","A_Id":50057446,"CreationDate":"2018-04-23T18:49:00.000","Title":"How do I merge two trained neural network weight matrices into one?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As the title suggests, is it possible to check whether a tkinter window is withdrawn or not?\nI am aware of the fact, that I can have a variable toggled True\/False whenever I withdraw\/deiconify a window, but in my case, that will simply be too messy.","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":600,"Q_Id":49989727,"Users Score":5,"Answer":"You can call the method winfo_viewable which returns whether or not the widget is visible. \nFrom the official tcl\/tk documentation:\n\nReturns 1 if window and all of its ancestors up through the nearest toplevel window are mapped. Returns 0 if any of these windows are not mapped.","Q_Score":3,"Tags":"python,tkinter","A_Id":49990093,"CreationDate":"2018-04-23T20:49:00.000","Title":"Check if tkinter window is withdrawn?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I am running multiple python processes(not threads) on a multi core CPU (say 4). GIL is process level so GIL within a particular process won't affect other processes.\nMy question here is if the GIL within one process will take hold of only single core out of 4 cores or will it take hold of all 4 cores?\nIf one process locks all cores at once, then multiprocessing should not be any better than multi threading in python. If not how do the cores get allocated to various processes?\n\nAs an observation, in my system which is 8 cores (4*2 because of\n  hyperthreading), when I run a single CPU bound process, the CPU usage\n  of 4 out of 8 cores goes up.\n\nSimplifying this:\n4 python threads (in one process) running on a 4 core CPU will take more time than single thread doing same work (considering the work is fully CPU bound). Will 4 different process doing that amount of work reduce the time taken by a factor of near 4?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3869,"Q_Id":49993687,"Users Score":0,"Answer":"Process to CPU\/CPU core allocation is handled by the Operating System.","Q_Score":0,"Tags":"python,multiprocessing,gil","A_Id":49993795,"CreationDate":"2018-04-24T04:53:00.000","Title":"How do CPU cores get allocated to python processes in multiprocessing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've to run a python script from my HTML page button. When I click on the button, it should run the command \"python filename.py\". But I'm not getting any solutions, please help!\nThank You","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6251,"Q_Id":49994136,"Users Score":2,"Answer":"Sorry to say but this is not possible unless your 'filename.py' is on a server e.g. flask, or else this will not work. If setup a flask server, and with a certain route it runs your code, then you can have your HTML code make a POST or GET request to this flask server, and the code should run.","Q_Score":0,"Tags":"javascript,python,jquery,html","A_Id":49994177,"CreationDate":"2018-04-24T05:38:00.000","Title":"How to execute python script from a button in HTML page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've to run a python script from my HTML page button. When I click on the button, it should run the command \"python filename.py\". But I'm not getting any solutions, please help!\nThank You","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6251,"Q_Id":49994136,"Users Score":0,"Answer":"You can\u2019t.\nPython runs in the server. HTML isn\u2019t a programming language, it\u2019s content, and it sits in the browser. About the best you can do is use AJAX to call a function in the server (which you\u2019d have written in Python) and, if it returns a value, return it via AJAX.","Q_Score":0,"Tags":"javascript,python,jquery,html","A_Id":49994299,"CreationDate":"2018-04-24T05:38:00.000","Title":"How to execute python script from a button in HTML page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there a recommended approach in terms of using either Azure CLI or the Azure Python SDK? \nThe CLI seems to be better documented but since it's built on Python, I would assume it will eventually share a lot of the functionality of the Azure Python SDK.\nAny thoughts? Is one more supported over the other?\nFor reference we are building an app built on Linux with both python and the occasional shell script. So we could use either, though we have found the CLI to be easier since it has better documentation.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1974,"Q_Id":49994422,"Users Score":19,"Answer":"The Azure CLI v2.0 is written in Python, and then depends on the Azure Python SDK. In order for a feature to go in the CLI, the SDK is required to be released first. So you have 100% equivalent features in both. SDK might be in advance sometimes, waiting for the CLI commands to be written. In addition, this is the same team with the same manager, support is equivalent.\nSDK is more oriented for a RestAPI experience, and will usually be closer to a direct Rest call, but in a Pythonic way. CLI is more oriented \"user friendly\", enabling basic scenarios to be simple with a lot of default parameters. Also, CLI can also provide some complete scenario in one command (i.e. \"create a KV account\") where SDK might take several calls to do the same (under the hood that's the same calls).\nAt the end of the day, if your need is complex, both will be complex anyway. So it's a matter of what you prefer to write.\n(full disclosure, I'm the lead dev in the Azure SDK for Python at Microsoft.)","Q_Score":5,"Tags":"azure,azure-cli,azure-sdk-python","A_Id":50005660,"CreationDate":"2018-04-24T06:00:00.000","Title":"Azure CLI vs Python SDK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there a recommended approach in terms of using either Azure CLI or the Azure Python SDK? \nThe CLI seems to be better documented but since it's built on Python, I would assume it will eventually share a lot of the functionality of the Azure Python SDK.\nAny thoughts? Is one more supported over the other?\nFor reference we are building an app built on Linux with both python and the occasional shell script. So we could use either, though we have found the CLI to be easier since it has better documentation.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1974,"Q_Id":49994422,"Users Score":2,"Answer":"There is no real answer to this. I was working on a project where we used both Azure CLI (node one) and Python SDK. I find working with SDK better as this is more native experience than calling shell commands. But, again, this isnt a rule or a law.","Q_Score":5,"Tags":"azure,azure-cli,azure-sdk-python","A_Id":49994476,"CreationDate":"2018-04-24T06:00:00.000","Title":"Azure CLI vs Python SDK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I appreciate that in many circumstances it is important to explicitly state what dependency versions we are working with and that this thus applies to the nested dependencies as well. \nHowever, it becomes very messy when we decide to remove a dependency and need to use something like pideptree to find out if it had any dependencies of its own which we also installed and additionally make sure that these nested dependencies are not being used by our other first-level dependencies.\nAssuming we don't need to freeze our dependency versions what is the advantage of including the nested dependencies rather than just letting pip take care of it for us?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1446,"Q_Id":49996481,"Users Score":2,"Answer":"Actually, you are right. If you have tried pipenv, you will find it is the thing what you want.\nThe reason why people write all nested dependencies in requirements.txt is just because pip freeze > requirements.txt will list all installed packages.\nAnd pipenv use a better way to manage dependencies which likes npm or yarn so you can easily delete all nested dependencies for a top module.\nBut it is still reasonable to list all nested dependencies. A case I met before, that is a third-party A rely on another third-party B. And the dependency of B in A is B>=4.10.0. But in B==4.12.0, some packages were migrated from one module to another module. As the importation broke so that the whole lib A broke too.","Q_Score":3,"Tags":"python,python-3.x,pip,dependencies,requirements.txt","A_Id":49998082,"CreationDate":"2018-04-24T08:08:00.000","Title":"Why is it best practice to include the dependencies' dependencies in requirements.txt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My goal here is to use Puppeteer to generate a PDF from a HTML view in Django. Preferably, this happens every time a certain model is saved. The view requires the user to be logged-in and own the model instance used in the view. This, of course, creates problems when trying to launch a Puppeteer instance to access the view and turn it into a PDF -- all I get is a PDF of the login page.\nI can think of a few ways, none of which stand out as The Right Way to do things:\n\nGet the users session ID and set the corresponding cookie in Puppeteer, either on the command line or using an environment variable -- I'm not sure this will actually work, I think there are security issues and as I'd like to do this in the model.save() method I don't necessarily have access to the user session ID.\nMake the view require login only when not accessed from localhost -- this seems like a security issue.\n\nOther ways to do this would be to use a HTML-to-PDF library, but these come with a lot of limitations on the HTML\/CSS they can understand, or to draw the PDF directly using reportlab without going through the intermediate HTML stage.\nAny ideas or solutions I'm missing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":391,"Q_Id":49997125,"Users Score":1,"Answer":"The simplest way is to render the template yourself, save the output to a temporary static HTML file and open that file with Puppeteer.\nYou will probably need to adjust the generated HTML to make sure all the static assets are accessible via proper absolute URL and protocol.","Q_Score":1,"Tags":"python,django,pdf,puppeteer","A_Id":49998257,"CreationDate":"2018-04-24T08:42:00.000","Title":"How do I allow Puppeteer to access a login-required view in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Currently, we need a interpolation in a Image. I have used the scipy.misc.imresize. This function has two drawback:\n\nit can only output interger matrix, but I need a float result. \nthe speed of scipy.misc.imresize is a little slow","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":259,"Q_Id":49998519,"Users Score":0,"Answer":"cv2.resize is slightly faster than scipy.misc.imresize","Q_Score":0,"Tags":"python,image,performance,interpolation","A_Id":52720246,"CreationDate":"2018-04-24T09:50:00.000","Title":"which imresize is fastest 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 got this error ModuleNotFoundError: No module named 'django.db.migrations.migration' after i tried these below steps\n\npython3 manage.py migrate --fake resources zero (resources is my\napp name)\nfind . -path \"*\/migrations\/*.py\" -not -name \"__init__.py\" -delete\nfind . -path \"*\/migrations\/*.pyc\"  -delete\npython3 manage.py showmigrations\n\nNote: used PostgreSQL\nHow to resolve this issue?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":5056,"Q_Id":50001428,"Users Score":6,"Answer":"By running those commands you might have accidentally deleted the migrations module. Try reinstalling Django via pip.\npip uninstall django\npip install django\nTake note of the version of Django you are using. In case you aren't using the latest version for your python environment install using the following command\npip install django==<version goes here>\nEdit:-\nDrop the existing database schema. Delete the migrations folder and recreate an empty one in its place.","Q_Score":3,"Tags":"django,python-3.x,django-models,wagtail","A_Id":50009168,"CreationDate":"2018-04-24T12:15:00.000","Title":"Python-ModuleNotFoundError: No module named 'django.db.migrations.migration'","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Since my app has background tasks, I use the Flask context. For the context to work, the Flask setting SERVER_NAME should be set.\nWhen the SERVER_NAME is set the incoming requests are checked to match this value or the route isn't found. When placing an nginx (or other webserver in front), the SERVER_NAME should also include the port and the reverse proxy should handle the rewrite stuff, hiding the port number from the outside world (which it does).\nFor session cookies to work in modern browsers, the URL name passed by the proxy should be the same as the SERVER_NAME, otherwise the browser refuses to send the cookies. This can be solved by adding the official hostname in the \/etc\/hosts and setting it to 127.0.0.1.\nThere is one thing that I haven't figured out yet and it is the URL in the background tasks. url_for() is used with the _external option to generate URLs in the mail it sends out. But that URL includes the port, which is different from the 443 port used by my nginx instance.\nRemoving the port from the SERVER_NAME makes the stuff described in the first paragraph fail.\nSo what are my best options for handling the url_for in the mail. Create a separate config setting? Create my own url_for?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":686,"Q_Id":50001950,"Users Score":0,"Answer":"You should use url_for(location, _external=True)\nor include proxy_params if you use nginx.","Q_Score":12,"Tags":"python,email,flask,nginx-reverse-proxy,celery-task","A_Id":54558887,"CreationDate":"2018-04-24T12:39:00.000","Title":"Flask SERVER_NAME setting best pratices","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a model already trained by dynet library. But i forget the --dynet-seed parameter when training this model. \nDoes anyone know how to read back this parameter from the saved model?\nThank you in advance for any feedback.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":50003397,"Users Score":0,"Answer":"You can't read back the seed parameter. Dynet model does not save the seed parameter. The obvious reason is, it is not required at testing time. Seed is only used to set fixed initial weights, random shuffling etc. for different experimental runs. At testing time no parameter initialisation or shuffling is required. So, no need to save seed parameter.\nTo the best of my knowledge, none of the other libraries like tensorflow, pytorch etc. save the seed parameter as well.","Q_Score":0,"Tags":"python,lstm,dynet","A_Id":50051554,"CreationDate":"2018-04-24T13:49:00.000","Title":"How to read back the \"random-seed\" from a saved model of Dynet","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"when I want to put my project on GAE i get this error in SDK shell:\nERROR: (gcloud.app.deploy) Permissions error fetching application [apps\/responsive-my-super-app-201910]. Please make sure you are using the correct project ID and that you have permission to view applications on the project.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":47,"Q_Id":50005300,"Users Score":1,"Answer":"You haven't authenticated the cloud SDK. Try running gcloud auth list. Is your email included in the credentialed accounts? If not, run glcoud auth login.\nIf you are listed in the credentialed accounts, then perhaps you haven't properly associated your project with your login, or you have a typo in your project name.","Q_Score":1,"Tags":"python-2.7,google-app-engine","A_Id":50029739,"CreationDate":"2018-04-24T15:18:00.000","Title":"deploying web application on GAE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"vsample_data = credit_card.sample(n=100, replace='False')\nprint(vsample_data)\nHere, I was trying to sample 100 data points from a data set but not able to get correct sample data such that it preserves the original distribution of the credit card fraud data-set i.e Class-0( Non- Fraud) and Class-1(Fraud).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":537,"Q_Id":50005578,"Users Score":0,"Answer":"Increase your sample size (n>>100). The data you are sampling from is itself a random sample. Creating a subset through random selection is itself a random process. If one of the data classes has a low frequency then the problem is that your sample size (100) is too low.\nIf you change the replace flag to 'True' and do repeated samples, you are doing something called bootstrapping. Assuming the complete data set represents the true population distribution this resampling will give you examples of what kind of measurements you might get for lower values of n (n=100).\nThe alternative is a stratification strategy as suggested by some above. However, you are not creating random subsets when you do this, and the assumption of distribution is now built into your smaller data sets. Note that you can only achieve this after having looked at the entire data set to determine its distribution. Probably not what you want.\nIf you are creating a (supervised) training data set from the data you can repeat under-represented data to manipulate the bias.","Q_Score":0,"Tags":"python-3.x,pandas","A_Id":50011442,"CreationDate":"2018-04-24T15:30:00.000","Title":"Sampling data such that distribution is preserved","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any shortcut key that I can use to run my program? Sick and tired of going to the top of the screen and clicking on the green run button. And yes, I've looked everywhere to find for a shortcut and trust me, I can't find it anywhere.\nI'm currently working with Python 3.x and using a Mac.\nAnd no, Ctrl+F11 does not work. It only increases my volume.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3038,"Q_Id":50009260,"Users Score":0,"Answer":"Try F9. On Windows it is working.","Q_Score":3,"Tags":"eclipse,python-3.x,keyboard-shortcuts","A_Id":56410073,"CreationDate":"2018-04-24T19:13:00.000","Title":"Eclipse -> Run Button -> Shortcut","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any shortcut key that I can use to run my program? Sick and tired of going to the top of the screen and clicking on the green run button. And yes, I've looked everywhere to find for a shortcut and trust me, I can't find it anywhere.\nI'm currently working with Python 3.x and using a Mac.\nAnd no, Ctrl+F11 does not work. It only increases my volume.","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":3038,"Q_Id":50009260,"Users Score":3,"Answer":"Alright, so it turns out that to run it without going all the way up would be: Shift + Command + F11. \nIs there anyways I can edit this key to a different key? Thanks!","Q_Score":3,"Tags":"eclipse,python-3.x,keyboard-shortcuts","A_Id":50010588,"CreationDate":"2018-04-24T19:13:00.000","Title":"Eclipse -> Run Button -> Shortcut","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any shortcut key that I can use to run my program? Sick and tired of going to the top of the screen and clicking on the green run button. And yes, I've looked everywhere to find for a shortcut and trust me, I can't find it anywhere.\nI'm currently working with Python 3.x and using a Mac.\nAnd no, Ctrl+F11 does not work. It only increases my volume.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3038,"Q_Id":50009260,"Users Score":0,"Answer":"On Windows, it works for Ctrl + F11 key combination.","Q_Score":3,"Tags":"eclipse,python-3.x,keyboard-shortcuts","A_Id":62103981,"CreationDate":"2018-04-24T19:13:00.000","Title":"Eclipse -> Run Button -> Shortcut","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently working on gateway with an embedded Linux and a Webserver. The goal of the gateway is to retrieve data from electrical devices through a RS485\/Modbus line, and to display them on a server.\nI'm using Nginx and Django, and the web front-end is delivered by \"static\" files. Repeatedly, a Javascript script file makes AJAX calls that send CGI requests to Nginx. These CGI requests are answered with JSON responses thanks to Django. The responses are mostly data that as been read on the appropriate Modbus device.\nThe exact path is the following :\nRandomly timed CGI call -> urls.py -> ModbusCGI.py (import an other script ModbusComm.py)-> ModbusComm.py create a Modbus client and instantly try to read with it.\nNext to that, I wanted to implement a Datalogger, to store data in a DB at regular intervals. I made a script that also import the ModbusComm.py script, but it doesn't work : sometime multiple Modbus frames are sent at the same time (datalogger and cgi scripts call the same function in ModbusComm.py \"files\" at the same time) which results in an error.\nI'm sure this problem would also occur if there are a lot of users on the server (CGI requests sent at the same time). Or not ? (queue system already managed for CGI requests? I'm a bit lost)\nSo my goal would be to make a queue system that could handle calls from several python scripts => make them wait while it's not their turn => call a function with the right arguments when it's their turn (actually using the modbus line), and send back the response to the python script so it can generate the JSON response.\nI really don't know how to achieve that, and I'm sure there are better way to do this. \nIf I'm not clear enough, don't hesitate to make me aware of it :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":389,"Q_Id":50010615,"Users Score":0,"Answer":"I had the same problem when I had to allow multiple processes to read some Modbus (and not only Modbus) data through a serial port. I ended up with a standalone process (\u201cserial port server\u201d) that exclusively works with a serial port. All other processes work with that port through that standalone process via some inter processes communication mechanism (we used Unix sockets).\nThis way when an application wants to read a Modbus register it connects to the \u201cserial port server\u201d, sends its request and receives the response. All the actual serial port communication is done by the \u201cserial port server\u201d in sequential way to ensure consistency.","Q_Score":0,"Tags":"python,django,multithreading,asynchronous,concurrency","A_Id":50105654,"CreationDate":"2018-04-24T20:57:00.000","Title":"Django\/Python - Serial line concurrency","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to ask if it is possible to make Python 3 a default interpreter on Mac OS 10 when typing python right away from the terminal? If so, can somebody help how to do it? I'm avoiding switching between the environments.\nCheers","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":13084,"Q_Id":50011518,"Users Score":1,"Answer":"You can do that by changing alias, typing in something like $ alias python=python3 in the terminal.\nIf you want the change to persist open ~\/.bash_profile using nano and then add alias python=python3. CTRL+O to save and CTRL+X to close.\nThen type $ source ~.\/bash_profile in the terminal.","Q_Score":3,"Tags":"python,python-3.x,macos","A_Id":50011593,"CreationDate":"2018-04-24T22:23:00.000","Title":"Make Python 3 default on Mac OS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Trying to Import 200 contacts from CSV file to telegram using Python3 Code. It's working with first 50 contacts and then stop and showing below:\ntelethon.errors.rpc_error_list.FloodWaitError: A wait of 101 seconds is required\nAny idea how I can import all list without waiting?? Thanks!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":287,"Q_Id":50012489,"Users Score":0,"Answer":"You can not import a large number of people in sequential. \u064fThe telegram finds you're sperm.\nAs a result, you must use \u200dsleep between your requests","Q_Score":0,"Tags":"python,csv,telegram,telethon","A_Id":50310718,"CreationDate":"2018-04-25T00:38:00.000","Title":"can't import more than 50 contacts from csv file to telegram using Python3","Data Science and Machine Learning":1,"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 filter a python 3 string so that only utf8 characters of 3 bytes or less are kept (I am writing to a SQL db that is utf8_general_ci which can take only 3 bytes or less). Is there a straightforward way to do this in Python? Any help would be very appreciated.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":560,"Q_Id":50013072,"Users Score":0,"Answer":"Thank you Giacomo Catenazzi. Answer is:\n''.join(c for c in my_string if ord(c) <= 0xffff)\nAlternative answer of \n''.join([_ for _ in my_string if len(_.encode('utf-8')) <=3])\nruns at half the speed of ''.join(c for c in my_string if ord(c) <= 0xffff) .","Q_Score":1,"Tags":"python-3.x,utf-8,utf","A_Id":50032953,"CreationDate":"2018-04-25T02:12:00.000","Title":"Filter Python String to utf8 character of bytes 3 or less","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning to implement Flask application.\nAnd using mysql as a database.\nI tried MySQLdb, flask_mysql & flask_sqlalchemy.\nBut still getting this error, when i try to perform any action on database :\nsqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (2059, \"Authentication plugin 'caching_sha2_password' cannot be loaded: The specified module could not be found.\\r\\n\")\nI also tried :\nALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password  BY 'root';\nPlease help.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2259,"Q_Id":50015205,"Users Score":0,"Answer":"You probably need to install the mysql client. On Debian based systems you can use sudo apt install mysql-client -y. I ran into this while using the Python 3.6 Docker image.","Q_Score":1,"Tags":"python-3.x,flask,flask-sqlalchemy,mysql-python","A_Id":50295359,"CreationDate":"2018-04-25T06:15:00.000","Title":"sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (2059, \"Authentication plugin 'caching_sha2_password'","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have preprocessor which opens .jpg files in input\/subfolders, process them and write to processed\/subfolders\/filename.npy\nI need to process only unprocessed files in case of script failure. How can I check all files in processed\/subfolders\/ and exclude from execution all .jpg's with the same filename as processed .npy's? Thank you! \nReason: processing takes 43 hours and if it fails - starting from the beginning will be expensive.\nNOTE: There is different number of subfolders in 'input' and 'processed'.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":212,"Q_Id":50015784,"Users Score":0,"Answer":"For long process it's always good to generate a log file.\nwhere you could put for example:\n\ninput filenameInput ->output succeed filenameOutput\ninput filenameInput ->output failed filenameOutput\n\nand then do a script that read this log file and rerun (with different input parameter I guess) the process which failed.","Q_Score":0,"Tags":"python","A_Id":50016046,"CreationDate":"2018-04-25T06:51:00.000","Title":"PYTHON How to exclude files that already processed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"today I come to you for inspiration or maybe ideas how to solve a task not killing my laptop with massive and repetitive code.\nI have a CSV file with around 10k records. I also have a database with respective records in it. I have four fields inside both of these structures: destination, countryCode,prefix and cost\nEvery time I update a database with this .csv file I have to check if the record with given destination, countryCode and prefix exist and if so, I have to update the cost. That is pretty easy and it works fine.\nBut here comes the tricky part: there is a possibility that the destination may be deleted from one .csv file to another and I need to be aware of that and delete that unused record from the database. What is the most efficient way of handling that kind of situation?\nI really wouldn't want to check every record from the database with every row in a .csv file: that sounds like a very bad idea.\nI was thinking about some time_stamp or just a bool variable which will tell me if the record was modified during the last update of the DB BUT: there is also a chance that neither of params within the record change, thus: no need to touch that record and mark it as modified.\nFor that task, I use Python 3 and mysql.connector lib. \nAny ideas and advice will be appreciated :)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":425,"Q_Id":50016819,"Users Score":0,"Answer":"If you're keeping a time stamp why do you care if it's updated even if nothing was changed in the record? If the reason is that you want to save the date of the latest update you can add another column saving a time stamp of the last time the record appeared in the csv and afterwords delete all the records that the value of this column in them is smaller than the date of the last csv.","Q_Score":0,"Tags":"mysql,database,python-3.x,csv,database-design","A_Id":50020530,"CreationDate":"2018-04-25T07:52:00.000","Title":"Check if a record from database exist in a csv file","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using pytest to test my app.\npytest supports 2 approaches (that I'm aware of) of how to write tests:\n\nIn classes:\n\n\ntest_feature.py -> class TestFeature -> def test_feature_sanity\n\n\nIn functions:\n\n\ntest_feature.py -> def test_feature_sanity\n\nIs the approach of grouping tests in a class needed? Is it allowed to backport unittest builtin module?\nWhich approach would you say is better and why?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":39428,"Q_Id":50016862,"Users Score":57,"Answer":"There are no strict rules regarding organizing tests into modules vs classes. It is a matter of personal preference. Initially I tried organizing tests into classes, after some time I realized I had no use for another level of organization. Nowadays I just collect test functions into modules (files).\nI could see a valid use case when some tests could be logically organized into same file, but still have additional level of organization into classes (for instance to make use of class scoped fixture). But this can also be done just splitting into multiple modules.","Q_Score":59,"Tags":"python,pytest","A_Id":50028551,"CreationDate":"2018-04-25T07:54:00.000","Title":"Grouping tests in pytest: Classes vs plain 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":0,"Web Development":0},{"Question":"I'm using pytest to test my app.\npytest supports 2 approaches (that I'm aware of) of how to write tests:\n\nIn classes:\n\n\ntest_feature.py -> class TestFeature -> def test_feature_sanity\n\n\nIn functions:\n\n\ntest_feature.py -> def test_feature_sanity\n\nIs the approach of grouping tests in a class needed? Is it allowed to backport unittest builtin module?\nWhich approach would you say is better and why?","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":39428,"Q_Id":50016862,"Users Score":20,"Answer":"Typically in unit testing, the object of our tests is a single function. That is, a single function gives rise to multiple tests. In reading through test code, it's useful to have tests for a single unit be grouped together in some way (which also allows us to e.g. run all tests for a specific function), so this leaves us with two options:\n\nPut all tests for each function in a dedicated module\nPut all tests for each function in a class\n\nIn the first approach we would still be interested in grouping all tests related to a source module (e.g. utils.py) in some way. Now, since we are already using modules to group tests for a function, this means that we should like to use a package to group tests for a source module.\nThe result is one source function maps to one test module, and one source module maps to one test package.\nIn the second approach, we would instead have one source function map to one test class (e.g. my_function() -> TestMyFunction), and one source module map to one test module (e.g. utils.py -> test_utils.py).\nIt depends on the situation, perhaps, but the second approach, i.e. a class of tests for each function you are testing, seems more clear to me. Additionally, if we are testing source classes\/methods, then we could simply use an inheritance hierarchy of test classes, and still retain the one source module -> one test module mapping.\nFinally, another benefit to either approach over just a flat file containing tests for multiple functions, is that with classes\/modules already identifying which function is being tested, you can have better names for the actual tests, e.g. test_does_x and test_handles_y instead of test_my_function_does_x and test_my_function_handles_y.","Q_Score":59,"Tags":"python,pytest","A_Id":57532692,"CreationDate":"2018-04-25T07:54:00.000","Title":"Grouping tests in pytest: Classes vs plain 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":0,"Web Development":0},{"Question":"I'am using Spacy 2.0.11 with Dutch language model nl_core_news_sm (nl).  How can I add the lemmatization lookup similar to the implementation for German (de)?\nI tried the following steps:\n\nadd lookup to init.py in the language folder (nl)\nadd lemmatizer.py in the language folder (nl)   \n\nThis resulted in the following error after 'nlp = nl_core_news_sm.load()' or 'from spacy.lang.nl import Dutch':\nModuleNotFoundError: No module named 'spacy.lang.nl.lemmatizer'\nImportError: [E048] Can't import language nl from spacy.lang","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1755,"Q_Id":50016956,"Users Score":1,"Answer":"In theory, your approach is correct\u00a0\u2013 if you copy exactly how it's implemented in German and other languages that implement the lookup, it should work.\nI suspect your problem here is actually a different one: According to the error message, it can't actually find the spacy.lang.nl.lemmatizer module, so spaCy now fails to import the Dutch language class. Are you sure the lemmatizer.py file exists in the correct place, and is imported correctly? (If you're not doing it already, I'd also recommend running your development installation in a separate environment and build spaCy from source, to make sure there are no weird conflicts).","Q_Score":2,"Tags":"python,spacy,lemmatization","A_Id":50215479,"CreationDate":"2018-04-25T07:59:00.000","Title":"spacy: add lemmatizer lookup for Dutch (nl) language","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose we have a joint distribution p(x_1,x_2), and we know x_1,x_2,p. Both are discrete, (x_1,x_2) is scatter, its contour could be drawn, marginal as well. I would like to show the area of 95% quantile (a scale of 95% data will be contained) of the joint distribution, how can I do that?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":305,"Q_Id":50017251,"Users Score":0,"Answer":"If you are interested in finding a pair x_1, x_2 of real numbers such that\nP(X_1<=x_1, X_2<=x_2) = 0.95 and your distribution is continuous then there will be infinitely many of these pairs. You might be better of just fixing one of them and then finding the other","Q_Score":0,"Tags":"python,numpy,scipy,confidence-interval,credible-interval","A_Id":50017530,"CreationDate":"2018-04-25T08:16:00.000","Title":"How to calculate a 95 credible region for a 2D joint distribution?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose we have a joint distribution p(x_1,x_2), and we know x_1,x_2,p. Both are discrete, (x_1,x_2) is scatter, its contour could be drawn, marginal as well. I would like to show the area of 95% quantile (a scale of 95% data will be contained) of the joint distribution, how can I do that?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":305,"Q_Id":50017251,"Users Score":1,"Answer":"As the other points out, there are infinitely many solutions to this problem. A practical one is to find the approximate center of the point cloud and extend a circle from there until it contains approximately 95% of the data. Then, find the convex hull of the selected points and compute its area.\nOf course, this will only work if the data is sort of concentrated in a single area. This won't work if there are several clusters.","Q_Score":0,"Tags":"python,numpy,scipy,confidence-interval,credible-interval","A_Id":50017700,"CreationDate":"2018-04-25T08:16:00.000","Title":"How to calculate a 95 credible region for a 2D joint distribution?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Trying to make a script to scrape one or two articles (article URLs only) from different websites, i was able to make a Python script that uses BeautifulSoup to get the website's HTML, find the website's Navbar menu via its Class name, and loop trough each website section, the problem is that each website has a different Class name or Xpath for the Navbar menu and its sections ..\nIs there a way to make the script work for multiple websites with as little human intervention as possible ? \nAny suggestions are more than welcome,\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":50018551,"Users Score":1,"Answer":"Did it, i have only needed to use Python and Selenium, an Xpath for the Navbar Elements for each website and another Xpath for all types of articles on the different website pages, saved everything on a database and the rest is just customized for our specific needs, it wasn't that complicated in the end, thanks for the help <3","Q_Score":0,"Tags":"python,web-scraping,beautifulsoup,scrape,scraper","A_Id":51704866,"CreationDate":"2018-04-25T09:23:00.000","Title":"Is it possible to automatically scrape articles from websites - Python & Beautiful Soup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to a simple make a http request to a server inside my company, from a dev server. I figured out that depending on the origin \/ destination server, I might, or not, to be forced to use qualified name of the destination server, like srvdestination.com.company.world instead of just srvdestination.\nI am ok with this, but I don't understand how come my DB connection works?\nLet's say I have srvorigin. Now, to make http request, I must use qualified name srvdestination.com.company.world. However, for database connection,  the connection string with un-qualified name is enough psycopg.connect(host='srvdestination', ...) I understand that protocols are different, but how psycopg2 does to resolve the real name?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":134,"Q_Id":50018843,"Users Score":0,"Answer":"First it all depend on how the name resolution subsystem of your OS is configured. If you are on Unix (you did not specify), this is governed by \/etc\/resolv.conf.  Here you can provide the OS with a search list: if a name has not \"enough\" dots (the number is configurable) then a suffix is added to retry resolution.\nThe library you use to do the HTTP request may not query the OS for name resolution and do its DNS resolution itself. In which case, it can only work with the information you give it (but it could as well re-use the OS \/etc\/resolv.conf and information in it), hence the need to use the full name.\nOn the contrary, the psycopg2 may use the OS resolution mechanism and hence dealing with \"short\" names just fine.\nBoth libraries should have documentation on how they handle hostnames... or otherwise you need to study their source code. I guess psycopg2 is a wrapper around the default libpq standard library, written in C if I am not mistaken, which hence certainly use the standard OS resolution process. \nI can understand the curiosity around this difference but anyway my advice is to keep short names when you type commands on the shell and equivalent (and even there it could be a problem), but always use FQDNs (Fully Qualified Domain Names) in your program and configuration files. You will avoid a lot of problems.","Q_Score":0,"Tags":"python,dns,psycopg2","A_Id":50476805,"CreationDate":"2018-04-25T09:37:00.000","Title":"Name resolving in http requests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a non trivial input pipeline, which consists of reading ground truth and raw data and performing preprocessing on them, written in Python. It takes a long time to run the input pipeline for a single sample so I have multiple processes (from python multiprocessing package) running in parallel and queues to perform the operation quickly and prefetch data. The output is then fed to my network using feed_dict. The overhead of this process in my training loop is 2 orders of magnitude less than the actual tf.Session.run() time.\nI'm trying to move to the tf.data API, by wrapping with tf.py_func my read+preprocess functions but it runs slowly, probably due to GIL, even when increasing the number of multiple calls.\nI want to scale up my training to multiple machines and am not sure how data fetching behaves in such a case, also there's the performance issue for a single machine as well :)\nSo, basically my question is:\nHow to run python functions in tf.data api input pipeline in parallel on multiple CPU cores?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":932,"Q_Id":50022168,"Users Score":0,"Answer":"Recently Google has released Tensorflow Extended (TFX). It essentially consists of:\n\nA set of operators which each use Apache Beam to do data distribution (They call them components).\nA standardization of both data and parameter format (what they call protobuf)\nAutomated dependency management of operators (workflow\/orchestration)\nTracking of runs.  This allows the system to skip operations that have already been performed under the same conditions.\n\nI would suggest either take a look at TFX.  Or, for a more modest leap, look at Apache Beam.","Q_Score":5,"Tags":"python,tensorflow,tensorflow-datasets","A_Id":57815167,"CreationDate":"2018-04-25T12:18:00.000","Title":"How to parallelise python input pipeline in Distributed Tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Recently started working on influxDB, can't find how to add new measurements or make a table of data from separate measurements, like in SQL we have to join table or so.\nThe influxdb docs aren't that clear. I'm currently using the terminal for everything and wouldn't mind switching to python but most of it is about HTTP post schemes in the docs, is there any other alternative?\nI would prefer influxDB in python if the community support is good","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":176,"Q_Id":50022212,"Users Score":1,"Answer":"The InfluxDB query language does not support joins across measurements. \nIt instead needs to be done client side after querying data. Querying, without join, data from multiple measurements can be done with one query.","Q_Score":1,"Tags":"influxdb,influxdb-python","A_Id":50022881,"CreationDate":"2018-04-25T12:20:00.000","Title":"queires and advanced operations in influxdb","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do i configure the system to email me when an employees contract is going to expire? For example I need to get an email 30 days before the expiration.  i tried to  create an automated action following some tutorial but i don't find the filed  Timer Trigger Date and  Delay After Trigger Date in odoo 8 any help please ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":50025439,"Users Score":0,"Answer":"hr_contract model have end date_end based on that write corn job or what ever you want","Q_Score":0,"Tags":"python-2.7,odoo-8","A_Id":50026756,"CreationDate":"2018-04-25T14:57:00.000","Title":"How to configure alerts for employee contract expiration in odoo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I looked into different cases but could not understand what I have to choose. My code is also working but my prediction looks strange only having 2 parallel lines. I have an LSTM Autoencoder for regression of time series. Autoencoder because I need to reduce the dimensions. Mydata looks like: 400 samples with each of them containing 5.000 rows.I concatenated them into an array. (Between the samples in real I have 5 minutes). How do I have to choose time steps for the model ? is it like (400,10,5000) ?can anyone please give me an advise with an example also in regarding to the batchsize?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":484,"Q_Id":50028127,"Users Score":1,"Answer":"Sample: an individual \"sequence\", not connected or related to any other sequence    \nTimesteps: the length of your sequences, each sequence has a start and an end, between them the sequence has steps     \nFeatures (the last dimension): different parallel variables measured in a same sequence.   \n\nOnly you can organize your data based on what you know about it. Number of rows and columns don't say anything about it. You must know what they mean and organize them in a shape (samples, timesteps, features) according to those definitions above. \nExample:\nYou measured vital signs in patients for 10 hours. \nYou had 5 patients, each one was measured for ten hours, and you have the features: body temperature, heartbeat frequency, breath frequency, every five minutes. \nThen you have\n\n5 individual sequences (they're not related to each other)    \n10 hours in steps for each 5 minutes (120 steps)    \n3 features","Q_Score":0,"Tags":"python,keras","A_Id":50028462,"CreationDate":"2018-04-25T17:27:00.000","Title":"lstm autoencoder time series data input shape","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here is a cell like: x1, x2, x3.\nMy program can find the specific word x2, and I want to mark this word(x2) only.\nHow can I use openpyxl to mark the character only x2?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":484,"Q_Id":50036503,"Users Score":0,"Answer":"Although excel supports formatting partial cells, openpyxl only supports formatting whole cells and not partial cells.","Q_Score":0,"Tags":"python-3.x,openpyxl","A_Id":50044660,"CreationDate":"2018-04-26T06:47:00.000","Title":"openpyxl - how can I style on character partial cell","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to construct a variational autoencoder where one sample is an N*M matrix where for each row, there are M categories. Essentially one sample is a list of categorical data where only one category can be selected - a list of one-hot vectors.\nCurrently, I have a working autoencoder for this type of data - I use a softmax on the last dimension to create this constraint and it works (reconstruction cross entropy is low).\nNow, I want to use tf.distributions to create a variational autoencoder. I was wondering what kind of distribution would be appropriate.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":794,"Q_Id":50037919,"Users Score":2,"Answer":"Does tf.contrib.distributions.Categorical satisfy your needs? Samples should be from (0 to n - 1), where n represents the category.\nExample:\n# logits has shape [N, M], where M is the number of classes\ndist = tf.contrib.distributions.Categorical(logits=logits) \n# Sample 20 times. Should give shape [20, N].\nsamples = dist.sample(20)\n# depth is the number of categories.\none_hots = tf.one_hot(samples, depth=M)","Q_Score":0,"Tags":"python,tensorflow,machine-learning","A_Id":50339467,"CreationDate":"2018-04-26T08:08:00.000","Title":"What tensorflow distribution to represent a list of categorical data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While learning Doc2Vec library, I got stuck on the following question.\nDo gensim Doc2Vec distinguish between the same Sentence with positive and negative context?\nFor Example:\nSentence A: \"I love Machine Learning\"\nSentence B: \"I do not love Machine Learning\"\nIf I train sentence A and B with doc2vec and find cosine similarity between their vectors:\n\nWill the model be able to distinguish the sentence and give a cosine similarity very less than 1 or negative?\nOr Will the model represent both the sentences very close in vector space and give cosine similarity close to 1, as mostly all the words are same except the negative word (do not).\n\nAlso, If I train only on sentence A and try to infer Sentence B, will both vectors be close to each other in vector space.?\nI would request the NLP community and Doc2Vec experts for helping me out in understanding this.\nThanks in Advance !!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":806,"Q_Id":50038347,"Users Score":0,"Answer":"use textblob and set the sentiment and polarity for each sentence. tokenize the sentences using nlp","Q_Score":4,"Tags":"python,nlp,gensim,doc2vec","A_Id":65922663,"CreationDate":"2018-04-26T08:31:00.000","Title":"Do gensim Doc2Vec distinguish between same Sentence with positive and negative context.?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am actually new to python scripting and I have a requirement where we have a line chart (each line shows tasks and y axis the time it took to complete).\nUsing lines and curves I have added average, upper control and lower control limits to the line chart. I also have a filter which shows the tasks.\nwhenever a task is selected i want these lines(average and control lines) to appear and whenever I select more than one task or None these lines should disappear.\nI saw an example which shows to create a property control for filter and then trigger the functions. Can we trigger the same functions when there is a change in the filter values instead of property control?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":339,"Q_Id":50042009,"Users Score":1,"Answer":"there isn't a way to react to filter changes as far as I know, but you can \"recreate\" the filter as a property control and execute the script when that property value changes. \ntypical example is for a listbox\/dropdown property control representing a listbox filter.","Q_Score":0,"Tags":"python,line,spotfire,tibco","A_Id":50044405,"CreationDate":"2018-04-26T11:37:00.000","Title":"spotfire - Disappear lines when value in filters are selected","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using tweepy to get tweets pertaining to a certain hashtag(s) and then I send them to a certain black box for some processing. However, tweets containing any URL should not be sent. What would be the most appropriate way of removing any such tweets?","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":1195,"Q_Id":50044690,"Users Score":5,"Answer":"In your query add -filter:links.\nThis will exclude tweets containing urls.","Q_Score":1,"Tags":"python,twitter,tweepy","A_Id":50048998,"CreationDate":"2018-04-26T13:47:00.000","Title":"How do I filter out tweets containing any URL?","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":"While I installed properly the matplotlib and seaborn. I was able to import matplotlib but when I was trying to import the seaborn I got the following error message. ModuleNotFoundError: No module named 'matplotlib._path' . Same if I was trying to import matplotlib.pyplot.\nAfter spending a lot of time googling and trying this and that, installing and unistaling, finally, I\nfirst checked out the \nimport sys\nsys.path to see what are the folders that it searches for the installed packages.\nmy result was something like this.\n['',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\python36.zip',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\DLLs',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\lib',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Roaming\\\\Python\\\\Python36\\\\site-packages',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\lib\\\\site-packages',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\lib\\\\site-packages\\\\win32',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\lib\\\\site-packages\\\\win32\\\\lib',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\lib\\\\site-packages\\\\Pythonwin',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\lib\\\\site-packages\\\\IPython\\\\extensions',\n 'C:\\\\Users\\\\gsotiropoulos\\\\.ipython']\nthen as suggested I import matplotlib as mpl and mpl.__path__ seeing that I import matplotlib from the folder 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Roaming\\\\Python\\\\Python36\\\\site-packages' Which is not the one from anaconda and it is older. I am not sure if it would be better to just remove this folder completely.\nHowever, as I understand, python first searched there and found a matplotlib package which was outdated. I simply changed the name of the `matplotlib' to something like 'matplotlib_test' and then the library is installed from one of the anaconda folders and the problem is solved.\nAs I understand I installed in the past python but the 'roaming' folder did not get unistalled. Is that right?\nI wonder if I should delete the \"roaming\" folder to avoid similar other problems.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":925,"Q_Id":50045758,"Users Score":1,"Answer":"A temporary solution is to add the line sys.path.append(\/path\/to\/located\/package).\nA permanent solution is to add the path to .bashrc","Q_Score":1,"Tags":"python,matplotlib,anaconda","A_Id":50046198,"CreationDate":"2018-04-26T14:36:00.000","Title":"ModuleNotFoundError: No module named 'matplotlib._path'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While I installed properly the matplotlib and seaborn. I was able to import matplotlib but when I was trying to import the seaborn I got the following error message. ModuleNotFoundError: No module named 'matplotlib._path' . Same if I was trying to import matplotlib.pyplot.\nAfter spending a lot of time googling and trying this and that, installing and unistaling, finally, I\nfirst checked out the \nimport sys\nsys.path to see what are the folders that it searches for the installed packages.\nmy result was something like this.\n['',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\python36.zip',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\DLLs',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\lib',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Roaming\\\\Python\\\\Python36\\\\site-packages',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\lib\\\\site-packages',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\lib\\\\site-packages\\\\win32',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\lib\\\\site-packages\\\\win32\\\\lib',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\lib\\\\site-packages\\\\Pythonwin',\n 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Local\\\\conda\\\\conda\\\\envs\\\\py36\\\\lib\\\\site-packages\\\\IPython\\\\extensions',\n 'C:\\\\Users\\\\gsotiropoulos\\\\.ipython']\nthen as suggested I import matplotlib as mpl and mpl.__path__ seeing that I import matplotlib from the folder 'C:\\\\Users\\\\gsotiropoulos\\\\AppData\\\\Roaming\\\\Python\\\\Python36\\\\site-packages' Which is not the one from anaconda and it is older. I am not sure if it would be better to just remove this folder completely.\nHowever, as I understand, python first searched there and found a matplotlib package which was outdated. I simply changed the name of the `matplotlib' to something like 'matplotlib_test' and then the library is installed from one of the anaconda folders and the problem is solved.\nAs I understand I installed in the past python but the 'roaming' folder did not get unistalled. Is that right?\nI wonder if I should delete the \"roaming\" folder to avoid similar other problems.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":925,"Q_Id":50045758,"Users Score":0,"Answer":"I finally started using anaconda and installing everything in one environment. In this way, I save and import everything that I want in this environment without any confusion.","Q_Score":1,"Tags":"python,matplotlib,anaconda","A_Id":52482106,"CreationDate":"2018-04-26T14:36:00.000","Title":"ModuleNotFoundError: No module named 'matplotlib._path'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"SciPy can read only read unsymmetric matrices with hb_read.  Anyone know if it is possible to read symmetric matrices in Python (3)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":202,"Q_Id":50046865,"Users Score":0,"Answer":"I found a solution using BeBOP Sparse Matrix Converter to convert to MarketMatrix and then importing this into Python.","Q_Score":0,"Tags":"python,scipy,sparse-matrix,eigenvalue,finite-element-analysis","A_Id":52635273,"CreationDate":"2018-04-26T15:29:00.000","Title":"Reading symmetrical Harwell-Boeing matrix in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a newbie in machine learning and trying to make a segmentation with clustering algorithms. However, Since my dataset has both categorical variables (such as gender, marital status, preferred social media platform etc) as well as numerical variables ( average expenditure, age, income etc.), I could not decide which algorithms worth to focus on.\nWhich one should I try: fuzzy c means, k-medoids, or latent class to compare with k-means++? which ones would yield better results for these type of mixed datasets?\nBonus question: Should I try to do clustering without dimensionality reduction? or should I use PCA or K-PCA in any case to decrease dimensions? Also, how can I understand and interpret results without visualization if the dataset has more than 3 dimensions ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":330,"Q_Id":50046876,"Users Score":1,"Answer":"The best thing to try is hierarchical agglomerative clustering with a distance metric such as Gower's.\nMixed data with different scales usually does not work in any statistical meaningful way. You have too many weights to choose, so no result will be statistically well founded, but largely a result of your weighting. So it's impossible to argue that some result is the \"true\" clustering. Don't expect the results to be very good thus.","Q_Score":0,"Tags":"python,machine-learning,cluster-analysis,dimensionality-reduction","A_Id":50056349,"CreationDate":"2018-04-26T15:30:00.000","Title":"Deciding to the clustering algorithm for the dataset containing both categorical and numerical variables","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the benefit in applying tf.image.per_image_standardization() before the first layer of the deep neural network over adding the Batch_Norm layer as the first layer? \nIn order to normalize the [0.0, 255.0] float value image pixels before feeding into the network, which method would be suitable?\n\ntf.image.per_image_standardization()\nBatch_Norm - layer","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":661,"Q_Id":50047909,"Users Score":0,"Answer":"They both do similar things, and one could indeed use batch norm to normalize input images.\nHowever, I would not use batch norm for this purpose:\n\nIt is clearer to use tf.image.per_image_standardization for image normalization than batch norm.\nBatch normalization is a broader concept than a per-channel normalization. Libraries like tensorflow let you normalize along any axis you want.\nBatch normalization is usually paired with streaming statistics of the means and variances used for normalization, that are meant to be used for testing and deployement. You don't need those statistics when you normalize your input image per sample.","Q_Score":0,"Tags":"python,tensorflow,deep-learning","A_Id":50048886,"CreationDate":"2018-04-26T16:27:00.000","Title":"Benefit of applying tf.image.per_image_standardization() over batch_norm layer in Tensorflow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering if there was a way to create an instance without a Key-Pair for testing purposes.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":225,"Q_Id":50047929,"Users Score":0,"Answer":"You can create an instannce without keypair however you will not be able to ssh into it or you can start it with ssm agent installed and running and use ec2 ssm service to send shell commands.","Q_Score":0,"Tags":"python,boto3","A_Id":50048241,"CreationDate":"2018-04-26T16:28:00.000","Title":"Boto3 Create Instance without a Key-Pair","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 would like to check the appearance of my GUI while coding, for several OS where it should be distributed.\nHow can I do ?\nThe problem is that the \u2018previsualisation\u2019 proposed by QT Designer is very different from the appearance of the distributed release. I even have spots in tabs that appear with same font and size in \u2018previsualisation\u2019 but have different sizes on Windows... I work with: python 3.5, a GUI designed with QT Designer, developed on mac OS 10.11 and shared with Windows 7 and Windows 10 systems (installed with a recent pyinstaller)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":50048117,"Users Score":0,"Answer":"ok. For the moment, I developed a ui file for each OS and test the appearance \"for real\". That's awkward and, moreover, in a given ui file, some strings that have exactly the same apparent properties in Qt Designer may appear differently in the final release","Q_Score":0,"Tags":"python,windows,pyinstaller,qt-designer","A_Id":51113469,"CreationDate":"2018-04-26T16:40:00.000","Title":"appearance of my GUI in several OS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to check the appearance of my GUI while coding, for several OS where it should be distributed.\nHow can I do ?\nThe problem is that the \u2018previsualisation\u2019 proposed by QT Designer is very different from the appearance of the distributed release. I even have spots in tabs that appear with same font and size in \u2018previsualisation\u2019 but have different sizes on Windows... I work with: python 3.5, a GUI designed with QT Designer, developed on mac OS 10.11 and shared with Windows 7 and Windows 10 systems (installed with a recent pyinstaller)","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":45,"Q_Id":50048117,"Users Score":2,"Answer":"The preview uses some approximation of the final style drawn completely by Qt, but the style used \"for real\" in most platform plug-ins either employs real, native widgets, or emulates them asking for theme parts straight from the machine where it's running. So, it's not possible to have a completely faithful preview unless you use a style that is always drawn completely by Qt (such as Fusion).\nLong story short: to see how your application will really look on different platforms you'll have to test it \"for real\".","Q_Score":0,"Tags":"python,windows,pyinstaller,qt-designer","A_Id":50048245,"CreationDate":"2018-04-26T16:40:00.000","Title":"appearance of my GUI in several OS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to write a defense system by using mininet + pox.\nI have l3_edited file to calculate entropy. I understand when a host attacked. \nI have my myTopo.py file that create a topo with Mininet. \nNow my question:\nI want to change hosts' ips when l3_edited detect an attack. Where should I do it?\nI believe I should write program and run it in mininet. (not like custom topo but run it after create mininet, in command line). If it's true, how can I get hosts' objest? If I can get it, I can change their IPs.\nOr should I do it on my myTopo.py ??? Then, how can I run my defense code, when I detect an attack?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":185,"Q_Id":50052832,"Users Score":0,"Answer":"If someone looking for answer...\nYou can use your custom topology file to do other task. Multithread solved my problem.","Q_Score":0,"Tags":"python,mininet,pox","A_Id":51859775,"CreationDate":"2018-04-26T22:40:00.000","Title":"Run external python file with Mininet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some questions about saltstack.\nI'm trying to deploy my Django project with saltstack and made that minion install required packages with pip by setting it's bin_env. (django lib, etc...)\nBut when I run a command (python manage.py something) It says there's no django and to activate virtual environment.\nI read salt docs about venv module(state) but the only thing in there was creating venv.\nHow can I activate the minion's venv?\nthank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":812,"Q_Id":50054591,"Users Score":0,"Answer":"$  source \/(directory path you put for bin_env)\/bin\/activate","Q_Score":2,"Tags":"python,django,salt-stack","A_Id":50055852,"CreationDate":"2018-04-27T03:03:00.000","Title":"Salt: Activate virtual environment on salt minion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to build a recommender system using collaborative filtering. The issues I am facing are :\n\nThe User-Item dataset has mostly categorical variables, so cant find the best way to calculate similarity matrix. Euclidean \/ Cosine distance will not work here, trying with Jaccard distance.\nThe dataset does not have User rating for items, instead, we have classifiers - \"did not buy\", \"buy\", \"added to cart but did not buy\".\n\nWe have used XGB to get the likelihood to buy a particular item by a particular user, but this kind of dataset is not helping for the recommendation.\nCan you please suggest any recommendation algorithm (preferably in python) which handles classification and categorical data?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":895,"Q_Id":50059020,"Users Score":0,"Answer":"Association rule mining will be helpful here. It calculates the relative likelihood that items will appear together in a user's history. It's different from, and differently useful from, collaborative filtering recommendation techniques.","Q_Score":1,"Tags":"python,recommendation-engine,collaborative-filtering,multiclass-classification","A_Id":50177881,"CreationDate":"2018-04-27T09:10:00.000","Title":"Collaborative Filtering using categorical features","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have looked for this everywhere and already installed a few softwares that did not help me.\nThe thing is, I am studying and researching image and video quality analysis and part of the process is applying my work to different types of lossy compression formats.\nRegarding the image part of the work, to do so for JPEG was the simplest thing. I was using something like this command line:\nmogrify -format jpg -quality 15 img01.bmp\nHowever, when I tried to move the study to other lossy compression formats, I could not find anything that allowed me to compress an image to different values of quality with a format that was not JPG. Just a few examples would be PGF, CPC, Fractual Compression etc.\nIt's important to say that Lossless Compression, such as PNG, won't help me.\nI want to ask if anyone knows a software, a package or a library for python that allows me to compress an image to a lossy compression format (other that JPEG) and change the quality of it, even to the point of where the image is really terrible (5% quality on JPEG, for example).\nThank you very much for the help and attention.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":305,"Q_Id":50062696,"Users Score":0,"Answer":"There is no \"quality\" setting in JPEG. Some encoders use quality as a simplified interface method for selecting quantization tables. You mentioned PNG. You can control the compression settings. The difference is that in JPEG compression setting trade off variations from the original against the output stream size. In PNG the compression settings trade off the time to do the compression against the output stream size.\nYou are unlikely to find compression values analogous to encoder-specific quality settings among various compression formats.","Q_Score":0,"Tags":"python,compression,jpeg","A_Id":50067974,"CreationDate":"2018-04-27T12:43:00.000","Title":"Image Lossy Compression to Different Formats","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install ibm_db driver in Linux for Python. I test the installation using import ibm_db. The installation was successful. When I test using 'import ibm_db' I get the following error: \nImportError: \/usr\/lib\/python2.7\/site-packages\/ibm_db-2.0.3-py2.7-linux-x86_64.egg\/ibm_db.so: undefined symbol: PyUnicodeUCS2_FromObject\nPlease help me to resolve this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":461,"Q_Id":50062872,"Users Score":0,"Answer":"Please try installing the current version of the ibm_db driver (which at time of writing is 2.0.8a),  which you can do via:\npip install \"ibm_db==2.0.8a\"\nYou need the version of pip that matches your python version.","Q_Score":0,"Tags":"python-2.7,db2","A_Id":50063192,"CreationDate":"2018-04-27T12:55:00.000","Title":"Error installing Python ibm-db driver on Linux","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on a Dataframe with 1116 columns, how could I select just the columns in a period of 17 ? \nMore clearly select the 12th, 29th,46th,63rd... columns","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":50062936,"Users Score":0,"Answer":"df.iloc[:,[i*17 for i in range(0,65)]]","Q_Score":1,"Tags":"python,pandas,dataframe","A_Id":50063200,"CreationDate":"2018-04-27T12:58:00.000","Title":"Select columns periodically on pandas DataFrame","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm actually aware that I can get the address which the email is sent from, but I wonder if I can get the user name of de sender too. I searched on the email module documentation but I didn't find anything about it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":50063795,"Users Score":0,"Answer":"Short answer: no, you can't.\nUsername of the sender remains between the SMTP server and the sender; it's never included in the data sent outside, unless the sender explicitly typed it into the email text. Note that there can be several hops between the originating SMTP server and the receiving SMTP server.\nIMAP servers are used to access received mail; they have no idea how it was sent.","Q_Score":0,"Tags":"python,email","A_Id":50066623,"CreationDate":"2018-04-27T13:47:00.000","Title":"Is there anyway I can get user name from a MIME object 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 text file that contains 3 columns of useful data that I would like to be able to extract in python using numpy.  The file type is a *.nc and is NOT a netCDF4 filetype.  It is a standard file output type for CNC machines.  In my case it is sort of a CMM (coordinate measurement machine).  The format goes something like this:\nX0.8523542Y0.0000000Z0.5312869\nThe X,Y, and Z are the coordinate axes on the machine.  My question is, can I delimit an array with multiple delimiters?  In this case: \"X\",\"Y\", and \"Z\".","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":50065295,"Users Score":0,"Answer":"I ended up using the Pandas solution provided by Scott.  For some reason I am not 100% clear on, I cannot simply convert the array from string to float with float(array).  I created an array of equal size and iterated over the size of the array, converting each individual element to a float and saving it to the other array.\nThanks all","Q_Score":0,"Tags":"python-3.x,numpy,csv","A_Id":50069637,"CreationDate":"2018-04-27T15:05:00.000","Title":"Delimit array with different strings","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Cython-based package which depends on other C++ SO libraries. Those libraries are binary different between Ubuntu (dev) and RedHat (prod). So the SO file generated by Cython has to be different as well. If I use Wheel to package it the file name is same for both environments:\npackage-version-cp27-cp27mu-linux_x86_64.whl\nSo if I upload it to pypi it will conflict with RedHat based distribution of the same package. I have to upload it to pypi because the project is then PEX-ed (via Pants) and PEX tries to download  from pypi and fails if it does not find it with the following exception.\nException caught: 'pex.resolver.Unsatisfiable'\nAny ideas how to resolve it?\nThx.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":211,"Q_Id":50065595,"Users Score":0,"Answer":"I found a solution by using a different PyPi instance. So our DEV Ubuntu environment and PROD RedHat just use two different PyPi sources.\nTo do that I had to make two configurations ~\/.pypic and ~\/.pip\/pip.conf to upload.","Q_Score":0,"Tags":"python,ubuntu,cython,redhat","A_Id":50101049,"CreationDate":"2018-04-27T15:23:00.000","Title":"How to create different Python Wheel distributions for Ubuntu and RedHat","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to make an app that uses Python to search for specific names on a website. For instance, I have to check if the string \"Robert Paulson\" is being used on a website. If it is, it returns True. Else, false. Also,is there any library that can help me make that?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":469,"Q_Id":50066306,"Users Score":1,"Answer":"Since you have not attempted to make your application first, then I am not going to post code for you. I will however, suggest using:\nurllib2: \nA robust module for interacting with webpages. i.e. pull back the html of a webpage.\nBeautifulSoup (from bs4 import BeautifulSoup):\nAn awesome module to \"regex\" html to find what is is that you're looking for.\nGood luck my friend!","Q_Score":2,"Tags":"python,string,url,web","A_Id":50066699,"CreationDate":"2018-04-27T16:05:00.000","Title":"Finding specific names on a website using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I create a conda environment with the development version of python? Or does it already include all the necessary extension when I create one.\nconda create -n py36 python=3.6","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":10837,"Q_Id":50067231,"Users Score":4,"Answer":"conda search python has a maximum version of 3.6.5, so I think only stable releases are available through conda.\nedit: some dev versions are available on conda-forge:\nconda search python --channel conda-forge to see them\nconda create --name dev python=[version here] --channel conda-forge to install","Q_Score":10,"Tags":"python,conda","A_Id":50068178,"CreationDate":"2018-04-27T17:08:00.000","Title":"Equivalent of apt-get install python3.6-dev for conda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried installing Anaconda in my windows 10 but for using with atom editor. But it only works with anaconda prompt and not with terminal of atom for python","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":860,"Q_Id":50068554,"Users Score":2,"Answer":"First of all have you set the anaconda python path in the system variable\n cause atom wont be able to find the anaconda version of python and will get default python or will break.\nThen to check whether Anaconda is installed properly try opening Anaconda Navigator if no then re install.\nFurther it is not dependent on Atom in any ways possible as it is simply an editor.\nVerify your system settings and then try again.Also see to it that the path must contain the anaconda version of python and not other version.\nAfter adding it to the path you will be able to use it from anywhere on your system.","Q_Score":0,"Tags":"python,anaconda,atom-editor","A_Id":50069680,"CreationDate":"2018-04-27T18:45:00.000","Title":"Anaconda not working with atom terminal for python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"There are bunch of text files in a directory. I want to add each text file to the last column in a row. Can this be achieved using pandas?\nEg:\nDirectory1>\n\nFile1.txt\nFile2.txt\nFile3.txt.... (Size of these files are close to 70KB)\n\nDataframe:\nColumn1      Column2      column3\nValue1       Value2       (Trying to add File1.txt content here)\nIs it possible using pandas? Thank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":149,"Q_Id":50068665,"Users Score":0,"Answer":"You can concatenate the files to one file with a delimiter of your choice (make sure that the delimiter is not included in any of the text files), and then use pd.read_csv() to read the concatenated file.","Q_Score":0,"Tags":"python,pandas","A_Id":50068729,"CreationDate":"2018-04-27T18:54:00.000","Title":"How to append a contents of text file to a column in dataframe (pandas python)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to tensorflow. When I am using import tensorflow.contrib.learn.python.learn   for using the DNNClassifier it is giving me an error: module object has no attribute python \nPython version 3.4\nTensorflow 1.7.0","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1041,"Q_Id":50070398,"Users Score":0,"Answer":"It looks like you have an error in your import statement. Try\nfrom tensorflow.contrib.learn import DNNClassifier","Q_Score":1,"Tags":"python,python-3.x,tensorflow,scikit-learn,deep-learning","A_Id":50070463,"CreationDate":"2018-04-27T21:14:00.000","Title":"Import tensorflow contrib learn python learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on writing a blog and came across two different alternatives on the internet for making pagination. I couldn't decide which to use. Url types are like ;\n\nblog\/page\/2\nblog\/?page=2\n\nDoes one of these have an advantage over the other?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6232,"Q_Id":50071884,"Users Score":11,"Answer":"Best practices are that path parameters are used to identify a specific resource, and query parameters filter or sort that resource.\nIf you are adding a pagination with articles, it would be ideal to use query parameters to sort through the articles. It is common for this query parameter to be referred to as offset, as you would be filtering through your articles. \nSo for example if you had 100 articles you've posted, and you want to display 10 articles per pagination page, and you were on page 2 of 10 in your pagination, your offset query parameter would be ?offset=10  because you would be filtering for articles 10-19 to display. (because articles 0-9 were displayed on your first pagination page)\nThis offset query parameter would increase by 10 every pagination page you increase, then filtering to the next 10 articles.","Q_Score":8,"Tags":"python,django,url,pagination,url-pattern","A_Id":50071982,"CreationDate":"2018-04-28T01:08:00.000","Title":"Pagination with URL path or the query parameters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Multiprocessing's Pipes and Queue are based on anonymous pipes, does the multiprocessing of Python provide named pipes \uff08FIFO\uff09?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1447,"Q_Id":50074545,"Users Score":1,"Answer":"class multiprocessing.connection.Listener([address[, family[, backlog[, authkey]]]])\nA wrapper for a bound socket or Windows named pipe which is \u2018listening\u2019 for connections.address is the address to be used by the bound socket or named pipe of the listener object.","Q_Score":3,"Tags":"python,multiprocessing,named-pipes","A_Id":50084044,"CreationDate":"2018-04-28T08:35:00.000","Title":"Does multiprocessing support named pipes \uff08FIFO)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using python 3. Lets say I am processing a loop around a large database query.  Effectively my loop around the result set cursor can be a billion iterations.  \nI'd like to give a user an ability to call out to an http server embedded in the same process that would give some statistics on the progress of the query.\nSo far I have tried this with IOLoop using Tornado http server.  The problem is that I have to basically transfer the control back to IOLoop on some number of rows to get the HTTP request to get serviced.  That seems wasteful.  Transferring that control has a price.  Tornado would let me support multiple connections, but I don't actually care for that - one connection is fine.  \nWhat I would prefer would be to simply interrupt the loop, service the HTTP request and resume.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":50080496,"Users Score":0,"Answer":"I guess this is probably open to too many possiblities...but using tornado I've just started an instance on a thread.  Threading issues with python aside, it basically does what i want.","Q_Score":0,"Tags":"python,multithreading,tornado","A_Id":50081629,"CreationDate":"2018-04-28T19:52:00.000","Title":"Embed an http server in a long running python process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a program that reads .gz archived log files from an SD card. If I open a .gz archive for reading using the gzip library, will it write a temporary copy to the SD card (I don't want it to), or does it decompress the file in RAM?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":50080548,"Users Score":0,"Answer":"You didn't show how exactly you're doing it, but if you are using gzip.open() and read(), then there are no temporary files. It is decompressed in memory.","Q_Score":0,"Tags":"python,gzip","A_Id":50088560,"CreationDate":"2018-04-28T19:59:00.000","Title":"Python: does gzip write to disk when opening a file for read?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python and thought it would be great to have my very first python project running on AWS infrastructure. Given my previous node.js experience with lambdas, I thought that every function would have its own code and the app is only glued together by the persistence layer, everything else are decoupled separate functions.\nIn Python lambdas there are serverless microframeworks like Chalice or Zappa that seem to be an accepted practice. For me though it feels like they are hacking around the concept of serverless approach. You still have a full-blown app build on let's say Flask, or even Django, and that app is served through lambda. There is still one application that has all the routing, configs, boilerplate code, etc instead of small independent functions that just do their job. I currently do not see how and if this makes like any easier.\n\nWhat is the benefit \/ reason for having the whole code base served through lambdas as opposed to individual functions?\nIs there an execution time penalty if using flask\/django\/whatever else with serverless apps? \nIf this depends on the particular project, what would be the guidance when to use framework, and when to use individual functions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":596,"Q_Id":50080592,"Users Score":0,"Answer":"Benefits. You can use known concept, and adopt it in serverless.\nPerformance. The smaller code is the less ram it takes. It must be loaded, processed, and so on. Just to process single request? For me that was always too much.\nLet's say you have diango project, that is working on elastic beanstalk, and you need some lamdas to deal with limited problems. Now. Do you want to have two separate configurations? What about common functions? \n\nServerless looks nice, but... let's assume that you have permissions, so your app, for every call will pull that stuff. Perhaps you have it cached - in redis, as a hole permissions for user... Other option is dynamodb, which is even more expensive. Yes there is nice SLA, but API is quite strange, also if you plan keeping more data there... the more data you have the slower it work - for same money. In other words - if you put more data, fetching will cost more - if you want same speed.","Q_Score":3,"Tags":"python,python-3.x,aws-lambda","A_Id":50080743,"CreationDate":"2018-04-28T20:06:00.000","Title":"Why use zappa\/chalice in serverless python 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am going to implement a Practical Byzantine Fault Tolerance ( PBFT ).\nHence, I am going to have multiple processes, P0 is going to initialize a round, by sending a first message.\nIs it possible to broadcast a message to all other processes using ZeroMQ? \nWith PUB\/SUB, I need to bind\/connect sockets. But I am going to take the number of processes as arguments, it seems impractical to connect all other ports ( I do not know if this is possible ?! ). I could not write any code since I am stuck in the beginning.\nBasically, if I find the way to connect processes I will do this:\nThe proposer selects a random message m and sends it to all validators.\nUpon reception each validator sends the message to other validators and the proposer.\nIf a validator (or proposer) receives at least 2k messages from the other\nprocesses that are identical to its own it proceeds to the next\nround of the consensus algorithm.\nOne more addition: Processes are going to communicate with each other directly. But connecting to all other processes sockets with REQ\/REP is not clever, though.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":562,"Q_Id":50081460,"Users Score":0,"Answer":"Is it possible to broadcast a message to all other processes using ZeroMQ?\n\nOh sure, it is .\nThis is exactly why all messaging and signalling tools, like ZeroMQ, nanomsg and others, were developed for.\nThe beauty and the trick of PBFT is, that there ought be zero-singular point of defection, ought be there?\nSo any other approach, but the circular-message actually being sent and delivered one-after-another, will not help the PBFT, will it?\nFeel free to sketch the solution, the port-mapping will not be your main issue in this. ZeroMQ can .bind()\/.connect() in a very flexible manner. One may even create an ad-hoc, non-persistent, connectivity setup in a similarly circular-manner, if ports are indeed a scarce resource, so get a bit more courage and go get it done :o)","Q_Score":3,"Tags":"python,zeromq,fault-tolerance","A_Id":50083751,"CreationDate":"2018-04-28T22:03:00.000","Title":"Python ZeroMQ broadcasting messages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I define a list that is empty at first and append to it but not have it clear when I restart my app? I am using python language\nThe list has the proper values in it when the app is first ran, it is only when I restart my app that the list clears because of the empty list variable over rides the list that was just created. Thanks in advance","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":29,"Q_Id":50082370,"Users Score":1,"Answer":"A list doesn\u2019t get saved when closing a python program. If you want this you should save the list in a specific file and load this file everytime your python program opens. One of the basics of python is that lists, dictionairies etc don\u2019t get saved on change or exit.","Q_Score":0,"Tags":"python,list","A_Id":50082479,"CreationDate":"2018-04-29T00:46:00.000","Title":"list clears when i end my app and re run it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have looked up definitions, but all of them seem confusing.\nSorry I am a very new to this and I would improve it if there were a simpler way of putting it.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":72,"Q_Id":50083391,"Users Score":1,"Answer":"All of your programs, consist of too many blocks.\nA block is just a concept and you can't see it like as function. A block is the structure of code to separate part of the code from another part of the code.\nA function is a block, and classes are blocks and self consist of many blocks inside.","Q_Score":1,"Tags":"python","A_Id":50083754,"CreationDate":"2018-04-29T04:29:00.000","Title":"What are blocks of code in Python? The definitions are all confusing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to deploy my project for approx 1.5 hours but I don't seem to have made any progress. Up to 10 solid minutes pass after I run the \"gcloud app deploy --project [my project name here]\" and nothing ever happens. The console shows that it's attempting to process the command but never progresses to show anything (except that my python which statements failed - I can run Python fine though so I don't that that's an issue). I have tried:\n\nfollowing the quickstart guide (twice to make sure I followed the steps)\nre-ran gcloud components install app-engine-python command\nran the gcloud components update command\n\nI've also spent this time researching as many forum posts as I reasonably could but to no avail. If anyone has advice on how to resolve this I would greatly appreciate the assist.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":377,"Q_Id":50084272,"Users Score":2,"Answer":"Found the solution. For some reason I can't use the command while in the GitBash terminal - I had to use the Windows Command Line. This may seem like a silly mistake, but I hope that it saves someone some time in the future.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":50084297,"CreationDate":"2018-04-29T07:17:00.000","Title":"App Engine - Deploying Stuck With No Progression","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm currently developing a keyword-spotting system that recognizes digits from 0 to 9 using deep neural networks. I have a dataset of people saying the numbers(namely the TIDIGITS dataset, collected at Texas Instruments, Inc), however the data is not prepared to be fed into a neural network, because not all the audio data have the same audio length, plus some of the files contain several digits being spoken in sequence, like \"one two three\".\nCan anyone tell me how would I transform these wav files into 1 second wav files containing only the sound of one digit? Is there any way to automatically do this? Preparing the audio files individually would be time expensive.\nThank you in advance!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3097,"Q_Id":50087271,"Users Score":1,"Answer":"I would split each wav by the areas of silence. Trim the silence from beginning and end. Then I'd run each one through a FFT for different sections. Smaller ones at the beginning of the sound. Then I'd normalise the frequencies against the fundamental. Then I'd feed the results into the NN as a 3d array of volumes, frequencies and times.","Q_Score":3,"Tags":"python,audio,machine-learning,deep-learning,speech-recognition","A_Id":50088667,"CreationDate":"2018-04-29T13:47:00.000","Title":"How to preprocess audio data for input into a Neural Network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using an API that sends a date in a wierd format \"YYYY-MM-DDTHH:MM:SSZ\".\nSo the date comes out as 2018-04-27T23:59:18Z, I have never seen a date and time formatted like this. Its a string and I would like to format it as MM-DD-YYYY HH:MM:SS. I can't even wrap my head around removing the T and Z. Any help would be appreciated! Thanks in advance!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":138,"Q_Id":50088343,"Users Score":1,"Answer":"That looks like the ISO 8601 time format.\nFor reasons that I really don't understand, there's no standard library function that parses ISO 8601 correctly. The dateutil package that you can find on PyPI will parse it for you though.","Q_Score":2,"Tags":"python,python-3.x","A_Id":50088441,"CreationDate":"2018-04-29T15:34:00.000","Title":"Python3 date and time formatting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering how to generate a random 4 digit number that has no duplicates in python 3.6\nI could generate 0000-9999 but that would give me a number with a duplicate like 3445, Anyone have any ideas\nthanks in advance","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":537,"Q_Id":50091226,"Users Score":-1,"Answer":"Generate a random number\ncheck if there are any duplicates, if so go back to 1\nyou have a number with no duplicates\n\nOR\nGenerate it one digit at a time from a list, removing the digit from the list at each iteration.\n\nGenerate a list with numbers 0 to 9 in it.\nCreate two variables, the result holding value 0, and multiplier holding 1.\nRemove a random element from the list, multiply it by the multiplier variable, add it to the result.\nmultiply the multiplier by 10\ngo to step 3 and repeat for the next digit (up to the desired digits)\nyou now have a random number with no repeats.","Q_Score":1,"Tags":"python,python-3.x,random","A_Id":50091280,"CreationDate":"2018-04-29T20:58:00.000","Title":"How would i generate a random number in python without duplicating numbers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have this doubt when I fit a neural network in a regression problem. I preprocessed the predictors (features) of my train and test data using the methods of Imputers and Scale from sklearn.preprocessing,but I did not preprocessed the class or target of my train data or test data.\nIn the architecture of my neural network all the layers has relu as activation function except the last layer that has the sigmoid function. I have choosen the sigmoid function for the last layer because the values of the predictions are between 0 and 1.\ntl;dr: In summary, my question is: should I deprocess the output of my neuralnet? If I don't use the sigmoid function, the values of my output are < 0 and > 1. In this case, how should I do it?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":50103377,"Users Score":0,"Answer":"Usually, if you are doing regression you should use a linear' activation in the last layer. A sigmoid function will 'favor' values closer to 0 and 1, so it would be harder for your model to output intermediate values. \nIf the distribution of your targets is gaussian or uniform I would go with a linear output layer. De-processing shouldn't be necessary unless you have very large targets.","Q_Score":0,"Tags":"python,scikit-learn,neural-network,keras","A_Id":53323802,"CreationDate":"2018-04-30T15:12:00.000","Title":"Keras Neural Network. Preprocessing","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use python3.x,I want to know the scope of numerical type.\nFor example, the float, the maximum and the minimum.\nI know the scope of java's float and int, but in python I can't find it now.\nFor example,java float from 10^-38 to 10^38,so python's float?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":50109804,"Users Score":0,"Answer":"int and float are the names of built-in types and are always in scope in Python.  I don't know what you mean by \"the maximum and the minimum\" but max and min are built-in functions, thus always in scope.","Q_Score":0,"Tags":"python,python-3.x","A_Id":50109826,"CreationDate":"2018-05-01T00:05:00.000","Title":"Python scope of numerical type","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've started the Anaconda python distribution. This comes with something called\n'Anaconda prompt' that has conda and git available at the Windows command line.\nWhen I make a commit from this command line, Vim comes up as the editor.\nWhen I type 'vim' or 'vi' at this prompt I get the message:\n\n'vim' is not recognized as an internal or external command, operable\n  program or batch file.\n\nHow can I access vim from the Anaconda prompt?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3090,"Q_Id":50110474,"Users Score":0,"Answer":"I am on a mac, but have been using the anaconda prompt on my Windows work machine. You need to add the path of the vim tool to the Windows path environmental variable. I set mine up to use notepad++ when I did a recent install. You can probably find vim in the %APPDATA% directory where anaconda is located if you installed it under the user and not the system. If you search for vim there, you might fine it. If it isn't there it might have gotten installed with another tool.","Q_Score":3,"Tags":"python,windows,vim","A_Id":50110608,"CreationDate":"2018-05-01T01:58:00.000","Title":"How can I access the vim installed with the anaconda prompt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Code on a Mac uses 2.7 version regardless of \"python.pythonPath\" setting explicitly set to \/usr\/local\/bin\/python3. Selecting interpreter interactively via command palette has no effect either. \nRunning python in the terminal launches 3.6 which should be picked up by the Code with default \"python.pythonPath\" setting, but it is not.\nNo matter what I do Code keeps using 2.7.\nWhat am I missing?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1346,"Q_Id":50110691,"Users Score":0,"Answer":"I can't add a comment, but you could change the \"python.pythonPath\" setting from usr\/bin\/local\/python3 to \/usr\/local\/bin\/python3","Q_Score":1,"Tags":"python,python-3.x,visual-studio-code","A_Id":50111958,"CreationDate":"2018-05-01T02:33:00.000","Title":"Unable to select Python interpreter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Code on a Mac uses 2.7 version regardless of \"python.pythonPath\" setting explicitly set to \/usr\/local\/bin\/python3. Selecting interpreter interactively via command palette has no effect either. \nRunning python in the terminal launches 3.6 which should be picked up by the Code with default \"python.pythonPath\" setting, but it is not.\nNo matter what I do Code keeps using 2.7.\nWhat am I missing?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1346,"Q_Id":50110691,"Users Score":0,"Answer":"Since you have multiple versions of python, I suggest you use virtual environments. These define which version of python you use and keeps everything straight. If you used Anaconda to download python, the Anaconda documentation is very clear on how to create and run from a virtual environment. If you didn't use anaconda, Unix has a simple way to define virtual environments.\nI have virtual environments for python 2.7.13 and python 3.6.  I can just activate the appropriate environment depending on which version of python I wish to use. I use this and I'm running VScode on my iMac.","Q_Score":1,"Tags":"python,python-3.x,visual-studio-code","A_Id":50142754,"CreationDate":"2018-05-01T02:33:00.000","Title":"Unable to select Python interpreter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on Json Web Tokens and wanted to reproduce it using python, but I'm struggling on how to calculate the HMAC_SHA256 of the texts using a public certificate (pem file) as a key.\nDoes anyone know how I can accomplish that!?\nTks","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1106,"Q_Id":50110748,"Users Score":2,"Answer":"In case any one found this question. The answer provided by the host works, but the idea is wrong. You don't use any RSA keys with HMAC method. The RSA key pair (public and private) are used for asymmetric algorithm while HMAC is symmetric algorithm.\nIn HMAC, the two sides of the communication keep the same secret text(bytes) as the key. It can be a public_cert.pem as long as you keep it secretly. But a public.pem is usually shared publicly, which makes it unsafe.","Q_Score":1,"Tags":"python,jwt,hmac","A_Id":51356271,"CreationDate":"2018-05-01T02:43:00.000","Title":"How to calculate the HMAC(hsa256) of a text using a public certificate (.pem) as 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":0},{"Question":"I'm coding watermarking images in JES and I was wondering how to Watermark a picture by automatically scaling a watermark image?\nIf anyone can help me that would be great.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":50111820,"Users Score":0,"Answer":"Ill start by giving you a quote from the INFT1004 assignment you are asking for help with.\n\"In particular, you should try not to use code or algorithms from external sources, and not to obtain help from people other than your instructors, as this can prevent you from mastering these concepts\"\nIt specifically says in this assignment that you should not ask people online or use code you find or request online, and is a breach of the University of Newcastle academic integrity code - you know the thing you did a module on before you started the course. A copy of this post will be sent along to the course instructor.","Q_Score":1,"Tags":"python,python-3.x,python-2.7,jython,jes","A_Id":50282582,"CreationDate":"2018-05-01T05:40:00.000","Title":"How to auto scale in JES","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to run a project in selenium with chrome driver, but after I didn't use it for a month ( Was an update to chrome).\nWhen I run the project its opens thechrome browser and then immediately closes.\nI reciving the following error:\n\nTraceback (most recent call last):\n    File \"C:\\Users\\maorb\\OneDrive\\Desktop\\Maor\\python\\serethd\\tvil_arthur.py\", line 27, in \n      driver = webdriver.Chrome()\n    File \"C:\\Program Files (x86)\\Python36-32\\lib\\site-packages\\selenium\\webdriver\\chrome\\webdriver.py\", line 67, in init\n      desired_capabilities=desired_capabilities)\n    File \"C:\\Program Files (x86)\\Python36-32\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 91, in init\n      self.start_session(desired_capabilities, browser_profile)\n    File \"C:\\Program Files (x86)\\Python36-32\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 173, in start_session\n      'desiredCapabilities': desired_capabilities,\n    File \"C:\\Program Files (x86)\\Python36-32\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\", line 233, in execute\n      self.error_handler.check_response(response)\n    File \"C:\\Program Files (x86)\\Python36-32\\lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py\", line 194, in check_response\n      raise exception_class(message, screen, stacktrace)\n  selenium.common.exceptions.WebDriverException: Message: session not created exception\n  from disconnected: Unable to receive message from renderer\n    (Session info: chrome=63.0.3239.108)\n    (Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 10.0.16299 x86_64)\n\nI am using chrome web driver version 2.36 & Google chrome  version 63.0.3239.10\nI tried to use latest Chrome & Chrome webdriver version but Its opening the chrome but its just opening and not doing any of code.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1266,"Q_Id":50113359,"Users Score":0,"Answer":"Usually people get this error when your script cannot find the chromedriver maybe re look at where you specified the path to be and add a executable path","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,selenium-chromedriver","A_Id":50156979,"CreationDate":"2018-05-01T08:20:00.000","Title":"python selenium not running with chrome driver & chrome version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have built a web app in Python and Flask and am having trouble pulling the date and time from my SQLite database.\nI enter the date into the DB with the following line-\norder.order_placed = datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\nWhich with my current example enters the following into the DB -\n2018-05-01 12:08:49\nBut when I call order.order_placed I get datetime.date(2018, 5, 1)\nEven if I call str(order.order_placed) I get '2018-05-01'\nCan someone help me get the full date and time out of the database? Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":252,"Q_Id":50115624,"Users Score":1,"Answer":"It's possible that you're using DateField when in actuality you want to use DateTimeField.\nFurthermore, you don't need to call strftime before storing the data. Peewee works nicely with Python datetime objects.","Q_Score":1,"Tags":"python,sqlite,flask,peewee","A_Id":50118318,"CreationDate":"2018-05-01T11:23:00.000","Title":"Peewee and SQLite returning incorrect date format","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Conscious that dbscan clusters don't necessarily have cluster centres, but for an anomaly detection task, I want to spot data that are outliers\/away from the normal clusters. Is there a way to do this using sklearn's dbscan?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":62,"Q_Id":50116265,"Users Score":0,"Answer":"For anomaly detection use an anomaly detection algorithm instead.\nThere are siblings derived from DBSCAN for exactly this purpose. For example, LOF and LoOP and kNN and ...","Q_Score":0,"Tags":"python,scikit-learn,dbscan","A_Id":50125190,"CreationDate":"2018-05-01T12:12:00.000","Title":"Using DBSCAN to find data that are far from high density clusters?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I realize there's another question with a similar title, but my dataset is very different.\nI have nearly 40 million rows and about 3 thousand labels. Running a simply sklearn train_test_split takes nearly 20 minutes.\nI initially was using multi-class classification models as that's all I had experience with, and realized that since I needed to come up with all the possible labels a particular record could be tied to, I should be using a multi-label classification method.\nI'm looking for recommendations on how to do this efficiently. I tried binary relevance, which took nearly 4 hours to train. Classifier chains errored out with a memory error after 22 hours. I'm afraid to try a label powerset as I've read they don't work well with a ton of data. Lastly, I've got adapted algorithm, MlkNN and then ensemble approaches (which I'm also worried about performance wise).\nDoes anyone else have experience with this type of problem and volume of data? In addition to suggested models, I'm also hoping for advice on best training methods, like train_test_split ratios or different\/better methods.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":450,"Q_Id":50117450,"Users Score":2,"Answer":"20 minutes for this size of a job doesn't seem that long, neither does 4 hours for training. \nI would really try vowpal wabbit. It excels at this sort of multilabel problem and will probably give unmatched performance if that's what you're after. It requires significant tuning and will still require quality training data, but it's well worth it. This is essentially just a binary classification problem. An ensemble will of course take longer so consider whether or not it's necessary given your accuracy requirements.","Q_Score":2,"Tags":"python,scikit-learn,multilabel-classification","A_Id":50117662,"CreationDate":"2018-05-01T13:33:00.000","Title":"Multi-label classification methods for large dataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I have a package MyPackage hosted on Pypi with two versions: 1.0 and 2.0\nWhen a user runs the command pip install MyPackage I want them to download and install 1.0.\nIs it possible to set a default\/recommended package version in this manner?\nI want to stray away from doing any beta releases i.e. 2.0b1","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":50123112,"Users Score":1,"Answer":"No, this is not possible.  pip install MyPackage will always install the highest available version of MyPackage, excluding prelease (\"beta\") versions unless the --pre flag is given.  There are no provisions anywhere in the packaging system for it to do anything else.","Q_Score":2,"Tags":"python,pip,pypi","A_Id":50123301,"CreationDate":"2018-05-01T20:08:00.000","Title":"Python packages and default\/recommended versions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How would one refer to p2 in :\nlayout1=layout(row(p1,p2), p3)\nwhere p1, p2, and p3 are plots?\nI've attempted layout1.children[0][1] but to no avail","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7,"Q_Id":50123144,"Users Score":0,"Answer":"Oftentimes, posting a question quickly boosts my research ability, and it is no different here. To refer to p2 in:\nlayout1=layout(row(p1,p2), p3)\nit is:\nlayout1.children[0].children[1]\nNow I can speak to all my grandchildren!","Q_Score":0,"Tags":"python,reference,bokeh","A_Id":50123218,"CreationDate":"2018-05-01T20:11:00.000","Title":"Bokeh- refer to child within a row within a layout","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking to set up a constraint-check in Python using PULP. Suppose I had variables A1,..,Xn and a constraint (AffineExpression) A1X1 + ... + AnXn <= B, where A1,..,An and B are all constants. \nGiven an assignment for X (e.g. X1=1, X2=4,...Xn=2), how can I check if the constraints are satisfied? I know how to do this with matrices using Numpy, but wondering if it's possible to do using PULP to let the library handle the work.\nMy hope here is that I can check specific variable assignments. I do not want to run an optimization algorithm on the problem (e.g. prob.solve()).\nCan PULP do this? Is there a different Python library that would be better? I've thought about Google's OR-Tools but have found the documentation is a little bit harder to parse through than PULP's.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":965,"Q_Id":50123308,"Users Score":1,"Answer":"It looks like this is possible doing the following:\n\nDefine PULP variables and constraints and add them to an LpProblem\nMake a dictionary of your assignments in the form {'variable name': value}\nUse LpProblem.assignVarsVals(your_assignment_dict) to assign those values\nRun LpProblem.valid() to check that your assignment meets all constraints and variable restrictions\n\nNote that this will almost certainly be slower than using numpy and Ax <= b. Formulating the problem might be easier, but performance will suffer due to how PULP runs these checks.","Q_Score":1,"Tags":"python,optimization,constraints,pulp","A_Id":50138245,"CreationDate":"2018-05-01T20:23:00.000","Title":"PULP: Check variable setting against constraints","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a way to duplicate \/ clone an excel file from a source directory to a destination directory.  Importantly, the source file(s) must remain in the source directory.  Every example I've been able to find, however, uses the copy function of the shutil module which actually moves the source file to the destination.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":209,"Q_Id":50135539,"Users Score":0,"Answer":"What you can do is read the contents of the file into a variable, then create a new file where you want and write the contents of your variable in there.\nOf course, there are better ways to do it, but this can be made cross-platform and will probably suit all your needs as long as you don't manage big files.","Q_Score":1,"Tags":"windows,python-3.x,shutil","A_Id":50136555,"CreationDate":"2018-05-02T13:12:00.000","Title":"Copy & Paste not Cut & Paste Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Could you please help me with the following error? I am trying to deploy a web app to Azure and I encounter the following issue: \n\nEven if by requirements, a newer version of setuptools is installed,\n  the deployment fails with the error:\"  RuntimeError: cryptography\n  requires setuptools 18.5 or newer, please upgrade to a newer version\n  of setuptools\".\n\nThe whole log is as it follows: \n\nCommand: \"D:\\home\\site\\deployments\\tools\\deploy.cmd\" Handling python\n  deployment. Detected requirements.txt.  You can skip Python specific\n  steps with a .skipPythonDeployment file. Detecting Python runtime from\n  site configuration Detected python-3.4 Found compatible virtual\n  environment. Pip install requirements. Downloading\/unpacking\n  setuptools>=18.5 (from -r requirements.txt (line 1)) Requirement\n  already satisfied (use --upgrade to upgrade): Flask==0.12.1 in\n  d:\\home\\site\\wwwroot\\env\\lib\\site-packages (from -r requirements.txt\n  (line 2)) Downloading\/unpacking azure-storage-file==1.1.0 (from -r\n  requirements.txt (line 3))   Downloading\n  azure_storage_file-1.1.0-py2.py3-none-any.whl Downloading\/unpacking\n  azure-storage-common>=1.1.0,<1.2.0 (from azure-storage-file==1.1.0->-r\n  requirements.txt (line 3)) Downloading\/unpacking\n  azure-storage-nspkg>=2.0.0 (from azure-storage-file==1.1.0->-r\n  requirements.txt (line 3))   Downloading\n  azure_storage_nspkg-3.0.0-py2.py3-none-any.whl Downloading\/unpacking\n  azure-common>=1.1.5 (from azure-storage-file==1.1.0->-r\n  requirements.txt (line 3))   Downloading\n  azure_common-1.1.10-py2.py3-none-any.whl Downloading\/unpacking\n  cryptography (from\n  azure-storage-common>=1.1.0,<1.2.0->azure-storage-file==1.1.0->-r\n  requirements.txt (line 3))   Running setup.py\n  (path:D:\\home\\site\\wwwroot\\env\\build\\cryptography\\setup.py) egg_info\n  for package cryptography\n      Traceback (most recent call last):\n        File \"\", line 17, in \n        File \"D:\\home\\site\\wwwroot\\env\\build\\cryptography\\setup.py\", line 28, in \n          \"cryptography requires setuptools 18.5 or newer, please upgrade to a \"\n      RuntimeError: cryptography requires setuptools 18.5 or newer, please upgrade to a newer version of setuptools\n      Complete output from command python setup.py egg_info:\n      Traceback (most recent call last):   File \"\", line 17, in    File\n  \"D:\\home\\site\\wwwroot\\env\\build\\cryptography\\setup.py\", line 28, in\n  \n      \"cryptography requires setuptools 18.5 or newer, please upgrade to a \" RuntimeError: cryptography requires setuptools 18.5 or newer,\n  please upgrade to a newer version of setuptools\n  ---------------------------------------- Cleaning up... Command python setup.py egg_info failed with error code 1 in\n  D:\\home\\site\\wwwroot\\env\\build\\cryptography Storing debug log for\n  failure in D:\\home\\pip\\pip.log An error has occurred during web site\n  deployment. \\r\\nD:\\Program Files\n  (x86)\\SiteExtensions\\Kudu\\73.10426.3381\\bin\\Scripts\\starter.cmd\n\"D:\\home\\site\\deployments\\tools\\deploy.cmd\"\n\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1123,"Q_Id":50135928,"Users Score":0,"Answer":"You need to upgrade the python module setuptools installed on your target.\nIf you used python3 (it looks to be case from the log), run this command: pip3 install --upgrade setuptools\nIf you are still using python2 then this command pip install --upgrade setuptools.\nIf you do not have permission access then use the flag --user: pip3 install --user --upgrade setuptools","Q_Score":0,"Tags":"python,azure,deployment,setuptools,azure-web-app-service","A_Id":50253268,"CreationDate":"2018-05-02T13:31:00.000","Title":"Error Deployment on Azure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have an excel table that I am building using python logic via xlwings. Once calculated, I would like to copy that table (ie its range) and save it as an image (similar format to select range -> copy -> right click -> paste as image ). End goal is to use pptx to include the table in a powerpoint presentation\nIs this possible?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1679,"Q_Id":50136831,"Users Score":0,"Answer":"I found that the best solution for this is to embed the excel range into the powerpoint presentation. \nCopy your excel range, go to the ribbon and click on the triangle under 'Paste', 'Paste Special', 'Paste Link'\nThis will automatically reflect the changes in the presentation","Q_Score":2,"Tags":"xlwings,python-pptx","A_Id":50138205,"CreationDate":"2018-05-02T14:14:00.000","Title":"xlwings: copy range and save as an image","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a novice python user and I use Atom to code in python. Sometimes, I use python 'os' module to get the working directory and in some cases, I have to navigate through directory\/folders to get to where I want the code to run. e.g. say my starting working directory is \"C:\\Users\\XYZ\" and I want to change directory to some folder named \"ABC\" in some directory path under D:. Currently, I have to open an explorer window to figure out where the 'ABC' folder is and then copy paste the directory in Atom and swap '\\' with '\\' and use os.chdir function. Is there an easier way or some Atom package where I press the first letter of the folder and it gives me autocomplete suggestions? I tried os.listdir() but copy paste using that is too cumbersome. I know that I can just create my file in that directory to start with but I want to learn if I can navigate through folders the way using autocomplete suggestions.\nAny help would be great.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":479,"Q_Id":50137099,"Users Score":0,"Answer":"This is not exactly what you want but may help you. There is an Atom extension \"platformio-ide-terminal\" which when run will open a regular bash shell at the bottom of your Atom window. Using this you can easily move around your directories using unix commands. Hope this helps some.","Q_Score":0,"Tags":"python,python-3.x,ide,intellisense,atom-editor","A_Id":50142286,"CreationDate":"2018-05-02T14:26:00.000","Title":"Autocomplete directory\/folder path in Atom (for 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":"Tensorflow provides all sorts of nice streaming operations to aggregate statistics along batches, such as tf.metrics.mean.\nHowever I find that accumulating all values since the beginning often does not make a lot of sense. For example, one could rather want to have statistics per epoch, or any other time window that makes sense in a given context.\nIs there any way to restrict the history of such streaming statistics, for example by reseting streaming operations so that they start over the accumulation?\nWork-arounds:\n\naccumulate by hand accross batch\nuse a \"soft\" sliding window using EMA","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":275,"Q_Id":50137369,"Users Score":0,"Answer":"The metrics in tf.contrib.eager.metrics (which work both with and without eager execution) have a init_variable() op you can call if you want to reset their internal variables.","Q_Score":0,"Tags":"python,tensorflow","A_Id":50219125,"CreationDate":"2018-05-02T14:41:00.000","Title":"How to window or reset streaming operations in tensorflow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am quite new in Python coding, and I am dealing with a big dataframe for my internship.\nI had an issue as sometimes there are wrong values in my dataframe. For example I find string type values (\"broken leaf\") instead of integer type values as (\"120 cm\") or (NaN).\nI know there is the df.replace() function, but therefore you need to know that there are wrong values. So how do I find if there are any wrong values inside my dataframe?\nThank you in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1435,"Q_Id":50138110,"Users Score":0,"Answer":"\"120 cm\" is a string, not an integer, so that's a confusing example.  Some ways to find \"unexpected\" values include:\nUse \"describe\" to examine the range of numerical values, to see if there are any far outside of your expected range.\nUse \"unique\" to see the set of all values for cases where you expect a small number of permitted values, like a gender field.\nLook at the datatypes of columns to see whether there are strings creeping in to fields that are supposed to be numerical.\nUse regexps if valid values for a particular column follow a predictable pattern.","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":50140995,"CreationDate":"2018-05-02T15:18:00.000","Title":"How to find if there are wrong values in a pandas dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pandas dataframe (wrapped in holoviews typically) that has three columns.  Col1 is a datetime, Col2 are categorical strings (i.e. one of 'Cat', 'Dog', 'Bird'), and Col3 being an integer count.  \nI'm trying to find a way to use the bokeh library to downsample the datetime to months, quarters, years, etc. similar to that available in pandas.DataFrame.resample or pandas.DataFrame.groupby([pd.Grouper(key='Date', freq=sample)]).  \nDoes anyone know if there is a native bokeh ability to do this, or do I need to provide all the data already sampled from pandas?  Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":151,"Q_Id":50139193,"Users Score":1,"Answer":"You will need to do your own downsampling. Bokeh does not generally do any sort of data aggregations itself. The few exceptions are: \n\nhexbin to generate data binned on a hex tile grid\npassing a pandas GroupBy to initialize a CDS will create a CDS with columns for the aggregates\n\nAnd even in the second case, arguably it's not Bokeh itself doing the aggragation.","Q_Score":0,"Tags":"python-3.x,pandas,bokeh,holoviews","A_Id":50139776,"CreationDate":"2018-05-02T16:17:00.000","Title":"Bokeh or Holoviews: BarChart by downsampling date time to months\/years\/etc","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to have a python program react to an opened file?  For example, can I get it to do something when I open a text file or another python file?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":50142547,"Users Score":0,"Answer":"You can get alerts on create, delete, modify and move of directories \/ files using tools like inotify, fswatch (for OSX) or watchdog. However I'm not aware of a way to get an alert on a file open in the general case. You'd probably need to use lsof, or do what lsof does for you: scan through \/proc\/*\/fs - polling, not an event-driven approach which is what it sounds like you want.","Q_Score":1,"Tags":"python,python-3.x","A_Id":50142769,"CreationDate":"2018-05-02T19:55:00.000","Title":"Can Python 3 react to opened files on my mac?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to leave a script running on an EC2 instance after I close the SSH client. The script is running on an activated tensorflow_p36 virtual anaconda environment.\nI have tried to use screen and tmux but to no avail ( I issue these commands when the venv is active). I get a ModuleNotFoundError: No module named 'tensorflow' even though when I try conda env list I see that I'm using the tensorflow_p36 environment.\nDo you have any ideas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":319,"Q_Id":50142626,"Users Score":1,"Answer":"Have you tried using nohup {your command} &? \nThis has previously worked for me.","Q_Score":0,"Tags":"python,tensorflow,amazon-ec2,ssh,anaconda","A_Id":50142728,"CreationDate":"2018-05-02T20:00:00.000","Title":"Leave a tensorflow (anaconda venv) script running 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":0,"Web Development":0},{"Question":"You can tell where this is going from the title..\nI work at a small post house, and to replace one of our older Mac Pros, we were looking at building a mid-range PC (doesn't need to do much heavy lifting - not worth the price of a new Mac Pro)..\nThe problem is, we have a number of scripts that we use for footage transcoding and media management, and they were coded for our Mac-exclusive environment..\nThe basic procedure for setting up a new workstation is:\nInstall pip using easy_install\nUse pip to install:\nyoutube_dl\npexpect\nparsedatetime\nXlsxWriter\nInstall MacPorts..  Use MacPorts to install ffmpeg, lftp, and ImageMagick.  From there, install a couple custom in-house scripts (that rely mostly on the preceding dependencies and python 2.7 (via xcode). \nI'm NOT going to ask how to adapt this to PC, since that would be way outside the scope of a single question. My question is, without a strong python developer on-site (the custom scripts were written years ago by someone who's no longer with the company), is it even feasible to adapt the install scripts to a PC environment?  We have a freelance Python developer that we consult for minor script changes and he wasn't sure (his response was \"I would first double check to make sure some of the utilities can even run on windows. I\u2019m not 100% sure they can or not\").  Do any of the utilities jump out as something that would not be adaptable to a Windows environment?\nThanks very much in advance - I know it's a rather broad question.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":50143215,"Users Score":0,"Answer":"If you \"don't need heavy lifting\", why upset your workflow this way?\nIf you are determined to buy a PC, why not run Linux on it rather than Windows?  The setup process you described will be almost exactly the same on a Linux machine except for involving a different package manager instead of MacPorts.  \nCraig\nPS the Python modules you listed are all available via MacPorts.  It would simplify the software management process to install everything that way.","Q_Score":0,"Tags":"python,windows,pip,macports,easy-install","A_Id":50154802,"CreationDate":"2018-05-02T20:39:00.000","Title":"Small Mac-based post house looking to run a Windows box, but we rely on some Python scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I don't think the other questions on stack overflow that sound like this are actually this question. (I did read several of them.)\nI downloaded a module, thinkbayes.py. When I'm in IDLE, typing \"from thinkbayes import pmf\" gives the following.\nTraceback (most recent call last):\n  File \"\", line 1, in \n    from thinkbayes import pmf\nModuleNotFoundError: No module named 'thinkbayes'\nI copied thinkbayes.py to many directories where python is installed, and that didn't help. So, I searched online for this and found recommendations like:\nSET SAVE=%PYTHONPATH%\nSET PYTHONPATH=.\npython scripts\/doit.py\nSET PYTHONPATH=%SAVE%\n(in stack overflow)\nI tried that (and other recommendations) both in IDLE and in the Windows command-line interface. Neither one recognizes those commands. I changed directories to C: -- no improvement.\nWhat am I missing here that everyone else knows? To repeat, I'm trying to get a Python 3 installation to recognize a .py file that I've copied into the 'Scripts' directory, the 'include' directory, etc.\nThanks,\nSakyataksis","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":820,"Q_Id":50143360,"Users Score":0,"Answer":"Do not put a python file in pythonxy\/include, which is for C .h header files.\npythonxy\/scripts is for startup files and support files for startup files.  But this only works if pythonxy\/scripts is on the system PATH.   The installer asks you if you want this.  But this in turn is problematic if you have more than one python version installed.\nOn Windows, downloaded files and packages should generally go in pythonxy\/Lib\/site-packages.  If you use pip to get file xyz, this is where it will put it.  Then when you run pythonxy, import xyz should work.\nNone of this has anything to do with IDLE.","Q_Score":0,"Tags":"python,windows,path,python-idle","A_Id":50147245,"CreationDate":"2018-05-02T20:50:00.000","Title":"IDLE's path, not Windows' path: How do I edit Python's path in MS Windows to include a .py module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm new using Keras and I'm building a model to classify medical images. \nThe dataset is very large and I am using fit_generator() function to optimize RAM space. \nWhen the model trains by batches, it shows statistics of each batch such as loss, precision, etc; and finally when it ends with all the batches at the end of the epoch, it gives me what I suppose is the average of these previous values, now the problem is: when I write a callback to save the training history, I get different values, close to those shown in the console but definitely different.\nCould this be a floating point error or something like that?\nThis did not happen to me when I used the function fit () that showed me the same information as the one I got in the history object. \nI would appreciate any help on the subject, thank you for your time.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":50144314,"Users Score":0,"Answer":"Even the metrics shown in verbose mode (val_loss, val_acc, etc...) has rounding and sometimes the rounding conflict with EarlyStopping or ModelCheckPoint callbacks behaviour.\nI think that this isn't really a problem, just a summary point of view. If you really need these numbers with all decimals places, the history is the right place to get it.","Q_Score":1,"Tags":"python,tensorflow,machine-learning,keras","A_Id":55172665,"CreationDate":"2018-05-02T22:13:00.000","Title":"Keras: Getting different values shown by fit_generator (verbose=1) and the metrics in the history object","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to compile a old VS2010 project in VS2015 with boost.python 1_67_0 from 1_53 and python 35.\nGetting it compile was not too hard, just a few tweaks to include path and updating a couple of python 2 string handling to python 3. \nBut I am stuck on linking because the linker fails at:\nLINK : fatal error LNK1104: cannot open file 'boost_python-vc100-mt-gd-1_67.lib'\nWhich really does not make sense because the library version should be vc140. In the library path there does exist libboost_python35-vc140-mt-gd-x32-1_67.lib and a few others libboost_python35-vc140* options.\nWhere is it getting the name 'boost_python-vc100-mt-gd-1_67.lib' from? (i.e. is this something I missed in the configuration?)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":206,"Q_Id":50144712,"Users Score":0,"Answer":"Under Visual Studio Boost uses boost\/configure\/auto_link.hpp to generate the library names and add them to the linker's dependencies. One of the arguments to this bit of code is BOOST_LIB_NAME which for boost::python is defined in boost\/python\/detail\/config.hpp. In version 1_67_0 this is currently: \n#define BOOST_LIB_NAME boost_python##PY_MAJOR_VERSION##PY_MINOR_VERSION\nWhere the python patchlevel.h has the definitions for PY_MAJOR_VERSION and PY_MINOR_VERSION.\nThis means that the library name itself does not need to explicitly added to the your Visual Studio project. Just the path to the boost libraries directory.\nFor me I needed to remove any (boost) library names from: \n\nConfiguration Properties > Linker > Input > Additional Dependencies\nConfiguration Properties > Linker > All Options > Additional Dependencies\n\nAnd needed to ensure that I built boost::python with the shared (dll) libraries since I would building a DLL. The static libraries are libboost*.lib and the shared libraries are boost*.lib. To force the generation of the shared libraries I used:\nC:\\dev\\boost\\boost_1_67_0> b2.exe link=shared,static --with-python -a","Q_Score":0,"Tags":"c++,boost-python,programmers-notepad","A_Id":50219742,"CreationDate":"2018-05-02T23:00:00.000","Title":"VisualStudio 2015 linker looking for VS 2010 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 have created a DLAMI (Deep Learning AMI (Amazon Linux) Version 8.0 - ami-9109beee on g2.8xlarge) and installed jupyter notebook to create a simple Keras LSTM. When I try to turn my Keras model into a GPU model using the multi_gpu_model function, I see the following error logged:\n\nIgnoring visible gpu device (device: 0, name: GRID K520, pci bus id:\n  0000:00:03.0, compute capability: 3.0) with Cuda compute capability\n  3.0. The minimum required Cuda capability is 3.5.\n\nI've tried reinstalling tensorflow-gpu to no avail. Is there any way to align the compatibilities on this AMI?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":683,"Q_Id":50146392,"Users Score":2,"Answer":"This was resolved by uninstalling, then reinstalling tensorflow-gpu through the conda environment provided by the AMI.","Q_Score":0,"Tags":"python,amazon-web-services,tensorflow,amazon-ec2,keras","A_Id":50218148,"CreationDate":"2018-05-03T03:16:00.000","Title":"AWS DLAMI - GPUs not showing up for Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can someone provide the steps and the necessary links of the dependencies to install external python package \"opencv-python\" for image processing?\nI tried installing it in pycharm, but it was not able to import cv2(opencv) and was throwing version mismatch with numpy!\nPlease help!","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":9045,"Q_Id":50147385,"Users Score":1,"Answer":"The good thing with anaconda is that it should make your life easier without getting your hands too dirty. If you use only basic libs, only install packages with anaconda commands to be sure not to corrupt your python environment.\nif you're on linux, use conda install -c conda-forge opencv\non windows, do the same with the \"anaconda prompt\" terminal.\nIf you still have some trouble with you numpy version, try conda update numpy","Q_Score":1,"Tags":"python-2.7,opencv,image-processing,ide,anaconda","A_Id":50984130,"CreationDate":"2018-05-03T05:14:00.000","Title":"Install opencv python package in Anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can someone provide the steps and the necessary links of the dependencies to install external python package \"opencv-python\" for image processing?\nI tried installing it in pycharm, but it was not able to import cv2(opencv) and was throwing version mismatch with numpy!\nPlease help!","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":9045,"Q_Id":50147385,"Users Score":0,"Answer":"Create a virtual env. Following which run following instals\npip install numpy scipy matplotlib scikit-learn jupyter\npip install opencv-contrib-python\npip install dlib\nYou may verify the install via this script in Python environment- \nimport cv2\ncv2.version","Q_Score":1,"Tags":"python-2.7,opencv,image-processing,ide,anaconda","A_Id":54570301,"CreationDate":"2018-05-03T05:14:00.000","Title":"Install opencv python package in Anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can someone provide the steps and the necessary links of the dependencies to install external python package \"opencv-python\" for image processing?\nI tried installing it in pycharm, but it was not able to import cv2(opencv) and was throwing version mismatch with numpy!\nPlease help!","AnswerCount":3,"Available Count":3,"Score":-0.0665680765,"is_accepted":false,"ViewCount":9045,"Q_Id":50147385,"Users Score":-1,"Answer":"Remove all previous\/current (if any) python installation\nInstall Anaconda and add anaconda to PATH(Envirnoment variables:: Adavanced system setting->Environment variables->under system variables go to variable PATHand click edit to add new envirnomental variables)\n(During installation check box involve PATH)\nOpen anaconda prompt with admin access. Type and enter:-\nconda update --all\nconda install -c conda-forge opencv\nconda install spyder=4.0.0  (spyder updation)\nconda update python (for python updation)\n\nTo install this package with conda run one of the following:\nconda install -c conda-forge opencv   \nconda install -c conda-forge\/label\/gcc7 opencv\nconda install -c conda-forge\/label\/broken opencv\nconda install -c conda-forge\/label\/cf201901 opencv","Q_Score":1,"Tags":"python-2.7,opencv,image-processing,ide,anaconda","A_Id":59453381,"CreationDate":"2018-05-03T05:14:00.000","Title":"Install opencv python package in Anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to do create plot using columns on pandas. But the number of columns are many and some of the columns are not shown on Jupyter notebook. And when I use the columns which are not shown on Jupyter Notebook, the plot cannot be created corrctly. Like when I do this, sns.pairplot(data[['col1', 'col13(cannot see on Jupyter Notebook)']]) col1 is used as y-label instead of col13(cannot see on Jupyter Notebook). \nHow can I fix this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":64,"Q_Id":50148502,"Users Score":0,"Answer":"You can try: pandas.set_option('display.max_columns', None) in order to display all columns. \nTo reset it, type: pandas.reset_option('display.max_columns'). \nYou may change None to whatever number of columns you wish to have.","Q_Score":0,"Tags":"python,pandas,jupyter-notebook","A_Id":50148675,"CreationDate":"2018-05-03T06:43:00.000","Title":"Jupyter Notebook; Cannot use columns which are not shown on Jupyter notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for any libraries like \"jks\" which is used to manage jks keystore.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":228,"Q_Id":50150262,"Users Score":1,"Answer":"Not in any meaningful way that I am aware of, but most software that uses CMS *.kdb files can use PKCS12 files nowadays which are not proprietary. \nThe PKCS12 files just have to meet a few simple criteria to be used with IBM GSKit-based SW:\n\nThe file must have a password\nThe private keys inside can be unencrypted or encrypted with the same password, but not a different password.\nCertificates accompanied by private keys should have pkcs12 \"friendly names\" to use as labels.","Q_Score":1,"Tags":"python-3.x,keystore,ibmhttpserver","A_Id":50152980,"CreationDate":"2018-05-03T08:21:00.000","Title":"Is there a way to manage KDB keystore from python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This Twilio is really awesome. I just have a question to which I was not able to find a straightforward answer. \nAll calls in twilio(Incoming and Outgoing) take place through webhooks.i.e you have to specify to which URL an incoming call needs to be redirected. Say suppose, once an incoming call to a twilio number is redirected to the URL, the set of actions defined in the URL are being provided as response to the caller. \nInstead of this, is it possible for a real person to answer an incoming call to a twilio number. I am already aware of the \"dial\" verb where you can redirect the call to a different number. My exact question is whether is it possible to make a real person answer a call directly in the twilio number itself?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":518,"Q_Id":50150568,"Users Score":0,"Answer":"Yes, a real person can answer a Twilio inbound call.  The way you do that is to Forward that call to the real person's real phone number.","Q_Score":1,"Tags":"python,twilio,twilio-api,twilio-twiml","A_Id":50224548,"CreationDate":"2018-05-03T08:39:00.000","Title":"Make real people answer calls in Twilio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a device which is sending packet with its own specific construction (header, data, crc) through its ethernet port.\nWhat I would like to do is to communicate with this device using a Raspberry and Python 3.x.\nI am already able to send Raw ethernet packet using the \"socket\" Library, I've checked with wireshark on my computer and everything seems to be transmitted as expected.\nBut now I would like to read incoming raw packet sent by the device and store it somewhere on my RPI to use it later.\nI don't know how to use the \"socket\" Library to read raw packet (I mean layer 2 packet), I only find tutorials to read higher level packet like TCP\/IP.\nWhat I would like to do is Something similar to what wireshark does on my computer, that is to say read all raw packet going through the ethernet port.\nThanks,\nAlban","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":914,"Q_Id":50151655,"Users Score":0,"Answer":"Did you try using ettercap package (ettercap-graphical)? \nIt should be available with apt. \nAlternatively you can try using TCPDump (Java tool) or even check ip tables","Q_Score":2,"Tags":"python,linux,sockets,raspberry-pi,ethernet","A_Id":50182669,"CreationDate":"2018-05-03T09:34:00.000","Title":"Read raw ethernet packet using python on Raspberry","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 build a relation extraction system for drug-drug interactions using a CNN and need to make embeddings for the words in my sentences. The plan is to represent each word in the sentences as a combination of 3 embeddings: (w2v,dist1,dist2) where w2v is a pretrained word2vec embedding and dist1 and dist2 are the relative distances between each word in the sentence and the two drugs that are possibly related.\nI am confused about how I should approach the issue of padding so that every sentence is of equal length. Should I pad the tokenised sentences with some series of strings(what string?) to equalise their lengths before any embedding?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":354,"Q_Id":50154465,"Users Score":0,"Answer":"You can compute the maximal separation between\nentity mentions linked by a relation and choose an\ninput width greater than this distance. This will ensure\nthat every input (relation mention) has same length\nby trimming longer sentences and padding shorter\nsentences with a special token.","Q_Score":1,"Tags":"python,nlp,keras,word2vec,word-embedding","A_Id":50159650,"CreationDate":"2018-05-03T11:52:00.000","Title":"embedding word positions in keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Google Assistant SDK: My user input is always constant, meaning same user command all the time, so instead of asking the user to everytime record a voice commandvia a device microphone, I want to have the user press a button and execute the command by passing a pre-recorded audio file as input. Is that possible with the Google assistant SDK? Preferably in Python as I want to built an API endpoint around it\nAny links, blogs, tutorials, samples etc would be very helful","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1035,"Q_Id":50156074,"Users Score":0,"Answer":"py -m googlesamples.assistant.grpc.pushtotalk --device-id \"your device id\" --device-model-id \"your device model\" -i \"your_sound_file.wav\"'\nthis will not wait for you to play a file, it will send the file and exeute and exit. but anyways, I had went to a website, can't remember which, but it would generate wav files of whatever you wanted. I did \"turn on the porch light\". Now I have a script that loops infinitely, checks if it can ping my cell phone on my home network, and if it detects its arrival, and it is between 7pm and 7am, it will turn on the porch light for me automatically. The only thing I have a problem with is, I do not need to hear the assistants voice. I wish there was a way to send an arg that muted assistant responses for the current \"conversation\". I use nircmd, copied to system32 folder in windows, to get around this though and I set the volume to 0, then do the assistant thing, then set the volume back to 20%. Works pretty good.","Q_Score":0,"Tags":"python,python-3.x,google-assistant-sdk,google-assist-api","A_Id":67032898,"CreationDate":"2018-05-03T13:18:00.000","Title":"Python: Can you directly pass an audio file as user input command to Google Assistant SDK?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm using tempfile.mkstemp(dir=tempdir.name, prefix=\"out_\") to create a bunch of temporary files. \ntempdir was created as a tempdir.TemporaryDirectory(dir=\"\/asdf\").\nDespite the fact that the documentation says that the user is responsible for deleting these files, which I don't do, and don't want, all my temporary files are gone after the Python process exits. Is this intentional? How can I fix this?\nFor debugging purposes, I want to keep these files around after the process closes.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":426,"Q_Id":50160121,"Users Score":0,"Answer":"I created all temporary files in a TemporaryDirectory. Even without using a context manager, TemporaryDirectory calls shutil.rmdir on all its contents (i.e., cleans itself and all its contents no matter what files it contains) when it is garbage collected.","Q_Score":2,"Tags":"python,python-3.x,temporary-files","A_Id":50160217,"CreationDate":"2018-05-03T16:46:00.000","Title":"Python3: tempfile.mkstemp file gets deleted on its own","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to install xlrd into my computer but keep on popping out the below error msg. \n\n'pip' is not recognized as an internal or external command,\n  operable program or batch file.\n\nI am not sure what I am doing wrong here. \nVersion of Python is 3.6 in my computer\nThanks","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":8687,"Q_Id":50161691,"Users Score":3,"Answer":"you should be doing python3 -m pip install xlrd\nThis is because pip is a module within python not an actual command on your computer.","Q_Score":2,"Tags":"python,xlrd","A_Id":50161818,"CreationDate":"2018-05-03T18:28:00.000","Title":"installing xlrd in to python3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing an opencv project which needs to detect a image on the screen, which will disappear after some time it shows up. It needs to save the most amount of frames possible while the image is showing, and stop when it disappears. I plan to use the data collected to do a ConvNet, so the more frames I can capture, the better.\nI was using template matching full-screen to search for the image and to identify when it disappears, but I was only capturing about 30% of the total frames, with the screen at 30FPS.  \nWanting to increase frame capture rate, I changed to searching full-screen with template matching until the image was found, and then the area for searching was reduced to the coordinates found of the image with a little margin, so the program could identify when the image disapeared using a lot less resources (because of a very smaller \u00e1rea to check if the image was still there). This allowed me to capture 60% of the frames.  \nHowever I want to know, can I do something else to allow me to optimize my program? I feel like doing template matching for every frame is overkill. Is object tracking better in this case, or it won't even work because the image disapears?\nPS: the image stays for about 7~10 seconds on the screen and takes about the same time to pop up again.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":118,"Q_Id":50165274,"Users Score":1,"Answer":"I ended using numpy to save the captured frames and reached 99% efficiency with the reduced area, no resizing of the images or multiprocessing.","Q_Score":1,"Tags":"python,python-3.x,opencv","A_Id":50185377,"CreationDate":"2018-05-03T23:53:00.000","Title":"How to identify when a certain image disappear","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using server(server_name.corp.com) inside a corporate company. On the server i am running a flask server to listen on 0.0.0.0:5000.\nservers are not exposed to outside world but accessible via vpns.\nNow when i run host server_name.corp.com in the box i get some ip1(10.*.*.*)\nWhen i run ifconfig in the  box it gives me ip2(10.*.*.*).\nAlso if i run ping server_name.corp.com in same box i get ip2.\nAlso i can ssh into server with ip1 not ip2\nI am able to access the flask server at ip1:5000 but not on ip2:5000.\nI am not into networking so fully confused on why there are 2 different ips and why i can access ip1:5000 from browser not ip2:5000.\nAlso what is equivalent of host command in python ( how to get ip1 from python. I am using socktet.gethostbyname(server_name.corp.com) which gives me ip2)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":50166145,"Users Score":0,"Answer":"Not quite clear about the network status by your statements, I can only tell that if you want to get ip1 by python, you could use standard lib subprocess, which usually be used to execute os command. (See subprocess.Popen)","Q_Score":0,"Tags":"python,linux,networking,server,ip","A_Id":50166912,"CreationDate":"2018-05-04T02:07:00.000","Title":"Host command and ifconfig giving different ips","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We are currently using Protocol Buffers as serialization mechanism for kafak message. We are going to move to Avro. We tested Avro Confluent consumer with Schema Registry and according to those tests, Avro consumer is little bit slow compare to protobuff consumer.\nMy question is do we need to manually cash schemas or Python AvroConsumer handle cash it self? \nI'm using confluent_kafka AvroConsumer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":665,"Q_Id":50168243,"Users Score":1,"Answer":"I had the same problem some time ago, there is additional latency when you're moving from Google protobuf, which is really fast, to something like Avro + Schema Registry. \nYou definitely have the option to cache the schemas manually. However, most decent kafka clients that talk to SchemaRegistry should already do this. At least, Confluent's Java kafka client does this automatically. So, the only time it has to send a request to Schema Registry is when it encounters a schema version it hasn't seen yet.","Q_Score":0,"Tags":"python,apache-kafka,avro,confluent-platform,confluent-schema-registry","A_Id":51750830,"CreationDate":"2018-05-04T06:09:00.000","Title":"Do we need to manually cache schema registry?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to import tensorflow in PyCharm, however I get an error that the module is not found.\nI used pip install to install tensorflow.\nAlso when I look at the interpreter in PyCharm it says I have pip version 9.0.1 and the latest is 10.0.1. I have upgraded to 10.0.1 using the pip commands, and when I run pip --version it says I got 10.0.1.\nI have tried both reinstalling pycharm and making new projects with no luck.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9399,"Q_Id":50169945,"Users Score":5,"Answer":"Go to Files -> Settings -> Project:projectname -> Project Interpreter\nIt's possible, that there is a different interpreter choosen for your project then the one you installed tensorflow in.\nIf you're running on linux you can check with \"which pip\" the path to your python distro in which you installed tensorflow.","Q_Score":1,"Tags":"python,tensorflow,pycharm","A_Id":50170204,"CreationDate":"2018-05-04T07:55:00.000","Title":"Can't import tensorflow in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am newbie to python and was googling for ages although never found an answer to my question - may be you could help me directing\nI am working on automating of one application deployment which has the part of changing the local server timezone (windows is the platform). Moreover, I am using the Listbox from tkinter to gather the input of the required timezone from user (listbox is filled with common_timezones from pytz).\nI wanted to change it with a python, using pytz and transferring the result to tzutils but never succeeded, as the result of pytz is in Unix format and tzutils accepts 'UTC+'. \nIs there any native fuction in python which could help me in changing the timezone locally or may be way to convert result of pytz to the input format which will be accepted by tzutils? Or I am going some wrong way?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":320,"Q_Id":50170494,"Users Score":0,"Answer":"Problem is solved, I used powershell call from python script for this. thank you.","Q_Score":0,"Tags":"windows,python-3.x,timezone","A_Id":50175429,"CreationDate":"2018-05-04T08:27:00.000","Title":"Python on Windows - change local timezone","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was asked to write a function in Python 3 for:\nWrite a function called general_poly, that would, for example, evaluate general_poly([1, 2, 3, 4])(10) to 1234 because 1*10^3 + 2*10^2 + 3*10^1 + 4*10^0.\nNow I don't understand what the second parenthesis, (10), means.\nHow would my function general_poly know, to take that value inside itself and use it?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":566,"Q_Id":50170505,"Users Score":1,"Answer":"The second set of paranthesis don't actually interact with the function, they apply to whatever the function returns. It's the same principle as returnsAList()[0], which would give you the first element of the list returned by returnsAList().","Q_Score":7,"Tags":"python,python-3.x,function","A_Id":50171277,"CreationDate":"2018-05-04T08:28:00.000","Title":"What does the parenthesis after the function mean","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python wheel file: psutil-5.4.5-cp26-none-linux_x86_64.whl\nHow can I list the dependencies this wheel has?","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":20661,"Q_Id":50170588,"Users Score":9,"Answer":"I just tried to unzip (not gunzip) a wheel package I had lying around. The packagename-version.dist-info\/METADATA file contains a list of Requires-Dist: entries that contain the compiled requirements from setup.py.","Q_Score":37,"Tags":"python,python-wheel","A_Id":50208939,"CreationDate":"2018-05-04T08:33:00.000","Title":"List dependencies of Python wheel file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have Python wheel file: psutil-5.4.5-cp26-none-linux_x86_64.whl\nHow can I list the dependencies this wheel has?","AnswerCount":7,"Available Count":3,"Score":0.1137907297,"is_accepted":false,"ViewCount":20661,"Q_Id":50170588,"Users Score":4,"Answer":"You can install the wheel file in a separate virtual environment and then look which all other packages are installed.\nUse pip freeze command to see all installed packages.","Q_Score":37,"Tags":"python,python-wheel","A_Id":50208857,"CreationDate":"2018-05-04T08:33:00.000","Title":"List dependencies of Python wheel file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have Python wheel file: psutil-5.4.5-cp26-none-linux_x86_64.whl\nHow can I list the dependencies this wheel has?","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":20661,"Q_Id":50170588,"Users Score":1,"Answer":"I use to install my virtual envs with pipenv that installs pew as a requirement. pew lets you install temporary virual environments that are deleted as you exit those special virtual environments. So...\nMake a new empty virtual environment and activate it on the fly:\npew mktmpenv -p \/usr\/bin\/python3.6\nInstall your package:\npip install somedistro\nSee what are the requirements of your distro (as well as requirements of requirements...):\npip list\nDeactivate and delete the temporary environment.\nexit\nIn addition, temporary virtual environments are very useful at packaging tests.","Q_Score":37,"Tags":"python,python-wheel","A_Id":50308083,"CreationDate":"2018-05-04T08:33:00.000","Title":"List dependencies of Python wheel file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I created a keras model (tensorflow) and want to store it in my MS SQL Server database. What is the best way to do that? pyodbc.Binary(model) throws an error. I would prefer a way without storing the model in the file system first.\nThanks for any help","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3587,"Q_Id":50174189,"Users Score":3,"Answer":"It seems that there is no clean solution to directly store a model incl. weights into the database. I decided to store the model as h5 file in the filesystem and upload it from there into the database as a backup. For predictions I load anyway the model from the filesystem as it is much faster than getting it from the database for each prediction.","Q_Score":2,"Tags":"sql-server,database,python-3.x,tensorflow,keras","A_Id":50363845,"CreationDate":"2018-05-04T11:46:00.000","Title":"Save keras model to database","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a keras model (tensorflow) and want to store it in my MS SQL Server database. What is the best way to do that? pyodbc.Binary(model) throws an error. I would prefer a way without storing the model in the file system first.\nThanks for any help","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3587,"Q_Id":50174189,"Users Score":1,"Answer":"The best approach would be to save it as a file in the system and just save the path in the database. This technique is usually used to store large files like images since databases usually struggle with them.","Q_Score":2,"Tags":"sql-server,database,python-3.x,tensorflow,keras","A_Id":57933840,"CreationDate":"2018-05-04T11:46:00.000","Title":"Save keras model to database","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to rename a variable everywhere in your current jupyter notebook file?\nI.e. let's say my notebook referencing a variable \"foo\" in multiple functions and locations through my script. Later I decide I want to rename this variable to \"bar\" for better readability...\nIn xcode, you can highlight and right click to do this. Sort of a smart search\/replace command.\nWould love to be able to do the same thing.\nThanks!","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":23709,"Q_Id":50177616,"Users Score":7,"Answer":"I hope you have already solved this. But, my answer will help someone who has similar problem like that.\nI think this can be accomplished using the Find and Replace option which can be found under the edit menu of the notebook. If you're in command mode, you can easily press the F key and bring up the find and replace dialog. Thank you!","Q_Score":37,"Tags":"python,jupyter-notebook","A_Id":62360659,"CreationDate":"2018-05-04T14:46:00.000","Title":"Renaming a variable everywhere in Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to rename a variable everywhere in your current jupyter notebook file?\nI.e. let's say my notebook referencing a variable \"foo\" in multiple functions and locations through my script. Later I decide I want to rename this variable to \"bar\" for better readability...\nIn xcode, you can highlight and right click to do this. Sort of a smart search\/replace command.\nWould love to be able to do the same thing.\nThanks!","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":23709,"Q_Id":50177616,"Users Score":2,"Answer":"From a Mac, highlighting and using control-right click gives an option (\u2318-F2 is a shortcut) to change all occurrences. I suspect this is what you want, but if your variable names are too short (e.g. i, j, k), it could really mess up your code.","Q_Score":37,"Tags":"python,jupyter-notebook","A_Id":65416259,"CreationDate":"2018-05-04T14:46:00.000","Title":"Renaming a variable everywhere in Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sometimes I resort to using ipdb for debugging a Python script, which has a very nice autocomplete feature.\nThe problem is, the script usually runs through a shell pipeline that processes its output (for instance python script.py |& tee \"stdout.txt\").\nTo me it seems like there is no answer to this (either live without autocomplete, or disable the stdout piping).\nMy question is made up of two parts: \n\nIs there any way to have both autocomplete and stdout processing?\nIf not, exactly why not?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":50177948,"Users Score":0,"Answer":"In the end I worked around this by avoiding shell pipes, and writing the output file from Python itself. \nI can watch the file change live using less +F.\nI guess I was asking for too much interactivity from L\/Unix pipes.","Q_Score":2,"Tags":"shell,autocomplete,pipe,ipython,ipdb","A_Id":59560248,"CreationDate":"2018-05-04T15:04:00.000","Title":"Tab completion in ipdb not working when output is processed","Data Science and Machine Learning":0,"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 use pyenv to install and manage both different versions of python and virtual environments for various projects on my system.  But pipenv is the recommended tool for managing virtual environments now, and I like a lot of its features.  Everything works for the most part, but pipenv seems to have a leak or something when it comes to Jupyter notebook.  Here are the steps which replicate the problem on my machine.\n\nInstall pipenv using brew install pipenv.\nInstall a new version of Python using, say, pyenv install 3.6.3, and activate it via pyenv global 3.6.3.\nInstall Jupyter notebook and another package, e.g. pip install jupyter requests.\nCreate a new directory and navigate into it; create a pipenv project using pipenv install\nActivate the pipenv virtual environment using pipenv shell.\nDo not install any packages, and confirm that none are installed in the current virtualenv using pip list.  (I only get pip, setuptools, and wheel.)\nRun jupyter notebook.  My expectation: the console errors out with jupyter: command not found.  Actual: the notebook server and browser UI launch as normal.\nCreate a new notebook and import the auxiliary package from step 3: import requests.  My expectation: a ModuleNotFoundError is thrown.  Actual: the package is imported and can be used as normal.\n\nIf I try to import the auxiliary package in the pipenv virtual environment but outside Jupyter notebook (in the repl or in a Python script) , I get a ModuleNotFoundError as expected.  So somehow the problem is with jupyter specifically.  Note that if I try to recreate this problem using a pyenv virtual environment instead of a pipenv virtual environment then the expected behavior occurs: jupyter notebook produces a jupyter: command not found error in the console.\n\nMy question is: am I using pipenv in a way that was not intended, or is there an alternative way to use pipenv that avoids this problem?\n\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3020,"Q_Id":50182498,"Users Score":2,"Answer":"The Problem\nIn step 1 you install pipenv with brew. The brew installation of pipenv also installs a python environment alongside it which is directly used. The command itself is on your path, so you can invoke it independent of the virtualenv you have loaded.\nIn step 2 you install and load a pyenv virtualenv. Loading the pyenv virtualenv changes your path. When you use pip now, it is the pyenv 3.6.3 pip and it will install into that pyenv. So when, in step 3, you run pip install jupyter requests they go into the pyenv virtualenv.\nWhen you run pipenv, in step 4, it will use it's own python, so it is able to load itself. Your load of the pipenv virtualenv in step 5 then adds the bin folder for that to the your path, allowing you to run things you install. It does not undo the changes pyenv made. When you run pip in step 6 it runs inside this pipenv virtualenv and so prints the limited list of installed packages.\nIn step 7 you run jupyter. This is not inside the pipenv virtualenv, however it is inside the pyenv one. The pyenv path additions still exist so it is runnable. The jupyter command is a bash script and it does magic to reset the python path before running. That is how it can find the requests module in step 8.\nYou finally run some form of python repl. This presumably is in your pipenv virtualenv so it is loads modules which are in that environment.\nThe Solution\nYou need to unload the global pyenv. Since you have installed packages into your 3.6.3 python install I would also clear any virtualenvs and python versions you have installed. You can just reinstall them.\nYour install of pipenv is fine, that can stay. It is also the primary tool that you should be using. You should not need to execute pip or pyenv directly.\nYou should install jupyter into the pipenv virtualenv and you should then have an install which only works when the pipenv virtualenv is loaded.","Q_Score":4,"Tags":"python,jupyter-notebook,pyenv,pipenv","A_Id":50183177,"CreationDate":"2018-05-04T20:17:00.000","Title":"pipenv + pyenv + jupyter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering, which is better to use with GridSearchCV( ..., n_jobs = ... ) to pick the best parameter set for a model, n_jobs = -1 or n_jobs with a big number, like n_jobs = 30 ?\nBased on Sklearn documentation:\n\nn_jobs = -1 means that the computation will be dispatched on all the\n  CPUs of the computer.\n\nOn my PC I have an Intel i3 CPU, which has 2 cores and 4 threads, so does that mean if I set n_jobs = -1, implicitly it will be equal to n_jobs = 2 ?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":4600,"Q_Id":50183080,"Users Score":4,"Answer":"An additional simpler answer by Prof. Kevyn Collins-Thompson, from course Applied Machine Learning in Python:\nIf I have 4 cores in my system, n_jobs = 30 (30 as an example) will be the same as n_jobs = 4. So no additional effect\n\nSo the maximum performance that can be obtained always is using n_jobs = -1","Q_Score":6,"Tags":"python,machine-learning,parallel-processing,scikit-learn,parallelism-amdahl","A_Id":50494869,"CreationDate":"2018-05-04T21:09:00.000","Title":"How to find an optimum number of processes in GridSearchCV( ..., n_jobs = ... )?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know how to check if a subdomain exists on a website?\nI am doing a sign up form and everyone gets there own subdomain, I have some javascript written on the front end but I need to find a way to check on the backend.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":237,"Q_Id":50185118,"Users Score":1,"Answer":"Do a curl or http request on subdomain which you want to verify, if you get 404 that means it doesn't exists, if you get 200 it definitely exists","Q_Score":0,"Tags":"javascript,python,subdomain","A_Id":50185326,"CreationDate":"2018-05-05T02:23:00.000","Title":"how to use python to check if subdomain exists?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Does anyone know how to check if a subdomain exists on a website?\nI am doing a sign up form and everyone gets there own subdomain, I have some javascript written on the front end but I need to find a way to check on the backend.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":237,"Q_Id":50185118,"Users Score":0,"Answer":"Put the assigned subdomain in a database table within unique indexed column. It will be easier to check from python (sqlalchemy, pymysql ect...) if subdomain has already been used + will automatically prevent duplicates to be assigned\/inserted.","Q_Score":0,"Tags":"javascript,python,subdomain","A_Id":50185317,"CreationDate":"2018-05-05T02:23:00.000","Title":"how to use python to check if subdomain exists?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i have both 2.7 as well as 3.6.5 installed , at first in ubuntu 18.04 the only python version available was 3.6 but after i installed numpy package, along with it 2.7 got installed as well and it turned into default.\nIs there any solution so as to  make 3.6 the default one instead of 2.7??","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":16219,"Q_Id":50186129,"Users Score":16,"Answer":"Open .bashrc file nano ~\/.bashrc. Type alias python=python3 on to a new line at the top of the file then save and close the file with ctrl+o and ctrl+x.","Q_Score":3,"Tags":"python,python-3.x,python-2.7,ubuntu","A_Id":50186206,"CreationDate":"2018-05-05T05:41:00.000","Title":"How can i remove python 2.7 as i already have 3.6.5 installed on ubuntu?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have both 2.7 as well as 3.6.5 installed , at first in ubuntu 18.04 the only python version available was 3.6 but after i installed numpy package, along with it 2.7 got installed as well and it turned into default.\nIs there any solution so as to  make 3.6 the default one instead of 2.7??","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":16219,"Q_Id":50186129,"Users Score":1,"Answer":"I set python 3 version as default using the following commands:\n\nCheck python version on terminal - python --version\nGet root user privileges. On terminal type - sudo su\nIf needed write down the root user password.\nExecute this command to switch to python 3.6. update-alternatives --install \/usr\/bin\/python python \/usr\/bin\/python3 1\nCheck python version - python --version\nWrite exit to exit the root mode","Q_Score":3,"Tags":"python,python-3.x,python-2.7,ubuntu","A_Id":67569751,"CreationDate":"2018-05-05T05:41:00.000","Title":"How can i remove python 2.7 as i already have 3.6.5 installed on ubuntu?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a string of str = '\\+234', from which I would like to create another string of '\\\\+'. And the statement '\\' + str[1]  gives the following error:\n\nSyntaxError: EOL while scanning string literal\n\nBut the str[1] is '+'. Why the two characters cannot be joined?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":50186758,"Users Score":0,"Answer":"That's because \"\\\" is an escaping char.\nTry to use double \\ instead.","Q_Score":0,"Tags":"python,string,python-3.5,string-literals","A_Id":50186833,"CreationDate":"2018-05-05T07:08:00.000","Title":"how to extract '\\+' in string of '\\+234' in python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a string of str = '\\+234', from which I would like to create another string of '\\\\+'. And the statement '\\' + str[1]  gives the following error:\n\nSyntaxError: EOL while scanning string literal\n\nBut the str[1] is '+'. Why the two characters cannot be joined?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":50186758,"Users Score":0,"Answer":"Because \\ is an escape character in python. Try '\\\\'+str[1]","Q_Score":0,"Tags":"python,string,python-3.5,string-literals","A_Id":50186808,"CreationDate":"2018-05-05T07:08:00.000","Title":"how to extract '\\+' in string of '\\+234' in python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an interesting problem I'd like to find a solution to.\nI have a MySQL server running on Ubuntu (16.04). I also have a number of servers that store system information like CPU temperature, network traffic data & CPU loads in a database on the MySQL server. To accomplish this I have a couple of Python programs running on each server that harvest the data and push it to the database.\nOn those servers I've also got a number of scripts that periodically query the database for historical data that they then graph and present on a webpage.\nThe way I've set this up right now results in all the servers tending to query the database at about the same time. This causes a high load on the MySQL server followed by a long period of virtually no load.\nWhat options are there for me (preferably client-side Python) that can help me spread the load on the SQL server more evenly?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":491,"Q_Id":50187126,"Users Score":1,"Answer":"This is generally known as a stampeding or thundering herd problem. All of a sudden a ton of clients want something, and then activity goes back to nothing. There are different ways of coping with that. If you have some intermediary between the client and the server, e.g. a load balancer, you can use that to spread the load around and perhaps even use it to spin up new server instances as needed.\nIn the case of a direct client-MySQL connection that typically isn't an option. Perhaps you can switch to read-only replicated slaves, which can more easily absorb the impact (i.e. scale horizontally). Or you get a bigger server which has a better peak-load performance. Of course, if 99% of the time there's no load whatsoever, these solutions aren't very cost-effective.\nThe cheap solution is to avoid all clients stampeding towards the server at the same time. Either offset each client individually (e.g. schedule their cron job for 0 * * * *, 5 * * * *, 10 * * * * etc.), or simply delay each client by a random amount each time (sleep(randint(0, 360)) in Python, sleep $((RANDOM % 360)) && ... in bash).","Q_Score":0,"Tags":"python,mysql,python-3.x,debian-based","A_Id":50211918,"CreationDate":"2018-05-05T07:58:00.000","Title":"Client-side (Python) load-balancing a MySQL server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a program that will pick a random word from a list, and display that word with alternate letters being replaced by hyphens. for example, the word \"monkey\" would be displayed as \"-o-k-y\".\nI can get a random word selected easy enough using random.choice, I know I should use a FOR loop, but I just can't seem to get my head around it.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":967,"Q_Id":50187485,"Users Score":0,"Answer":"You could use a for loop as follows to get each letter in the string one by one:\nfor character in string:\nThen create a new string where for every other you either append the '-' or the character.","Q_Score":1,"Tags":"python","A_Id":50187558,"CreationDate":"2018-05-05T08:43:00.000","Title":"Replacing every 2nd character in a string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If you have never installed anaconda, it seems to be rather simple. In the installation process of Anaconda, you choose to install visual studio code and that is it. \nBut I would like some help in my situation:\nMy objective: I want to use visual studio code with anaconda\n\nI have a mac with anaconda 1.5.1 installed. \nI installed visual studio code.\nI updated anaconda (from the terminal) now it is 1.6.9\n\nFrom there, I don't know how to proceed. \nany help please","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2644,"Q_Id":50190482,"Users Score":2,"Answer":"You need to select the correct python interpreter. When you are in a .py file, there's a blue bar in the bottom of the window (if you have the dark theme), there you can select the anaconda python interpreter.\nElse you can open the command window with ctrl+p or command+p and type '>' for running vscode commands and search '> Python Interpreter'. \nIf you don't see anaconda there google how to add a new python interpreter to vscode","Q_Score":0,"Tags":"python,anaconda","A_Id":50190821,"CreationDate":"2018-05-05T14:24:00.000","Title":"How to use visual studio code >after< installing anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have a Java application in our project and what we want is to call some Python script and return results from it. What is the best way to do this?\nWe want to isolate Python execution to avoid affecting Java application at all. Probably, Dockerizing Python is the best solution. I don't know any other way.\nThen, a question is how to call it from Java.\nAs far as I understand there are several ways:\n\nstart some web-server inside Docker which accepts REST calls from Java App and runs Python scripts and returns results to Java via REST too.\nhandle request and response via Docker CLI somehow.\nuse Java Docker API to send REST request to Docker which then converted by Docker to Stdin\/Stdout of Python script inside Docker.\n\nWhat is the most effective and correct way to connect Java App with Python, running inside Docker?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1012,"Q_Id":50191768,"Users Score":2,"Answer":"You don\u2019t need docker for this. There are a couple of options, you should choose depending on what your Java application is doing. \n\nIf the Java application is a client - based on swing, weblaunch, or providing UI directly - you will want to turn the python functionality to be wrapped in REST\/HTTP calls. \nIf the Java application is a server\/webapp - executing within Tomcat, JBoss or other application container - you should simply wrap the python scrip inside a exec call. See the Java Runtime and ProcessBuilder API for this purpose.","Q_Score":0,"Tags":"java,python,docker","A_Id":50197429,"CreationDate":"2018-05-05T16:40:00.000","Title":"Calling Python scripts from Java. Should I use Docker?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I understand how in recursion every recursive call stacks on the stack; if the stack limit is exceeded, you get a stack overflow.\nWhy then does Python's sys.getrecursionlimit() return a number; a max depth of recursive calls?\nDoes it not depend on what I do in that recursive function? Or does it somehow save the variables somewhere else, other than the stack? How does it work?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1699,"Q_Id":50193138,"Users Score":12,"Answer":"The easy, if oversimplified, way to think about this is that the Python stack is not actually a giant array with all the frames concatenated, but a linked list of frames.1 But even that can be misleading if you're thinking in, say, C terms. Which you seem to be:\n\nOr does it somehow save the variables somewhere else, other than the stack?\n\nIt does\u2014in CPython, local variables2 are stored in an array on the heap-allocated frame object\u2014but that usually isn't the relevant question.\nIn C, a variable is a typed memory location. When you write int lst[100];, that allocates 400 bytes on the stack and names it lst.\nIn Python, a variable is just a name (in some namespace) for a value. Memory locations (and types) are a property of values, not variables, and they always live somewhere in the heap.3 Variables are just references to them. So, if you write lst = [0]*100, that's just 8 bytes for the variable (pointer) in the locals array, and then 864 bytes for the list object on the heap.4\n\nThe RecursionError limit is there because most Python code that goes to a depth of 1000 is probably going to just take a very long time allocate a whole bunch of Python frames before failing on either a MemoryError or a stack overflow segfault, so it's better to stop you before allocating all that memory and burning all that CPU.\nMore importantly, as tdelaney points out in a comment, recovering from either of those conditions is very difficult in Python\u2014but recovering from a RecursionError is pretty simple; it unwraps the stack to the top of the recursion for you and leaves you in a predictable state.\nBut that rule of thumb doesn't apply to every program, just most of them\u2014so if you know you have an algorithm that may go a few thousand frames deep without any problems, Python lets you increase the limit to, say, 10000 instead of 1000.\n\n1. This is oversimplified because (at least in CPython) the interpreter is often actually chaining up calls on the C stack\u2014but it's still useful to remember that there's a new frame object (and the other stuff the frame allocates) being heap allocated every time you recurse in Python, whether the interpreter is recursing or not. (Especially since Python is defined as never doing tail call elimination at the Python level, even if the interpreter actually does so in the eval loop.)\n2. Technically, in Python, all variables are stored in a namespace, a mapping from names to references to values. But CPython optimizes local variables by storing an array of pointers, and then having the compiler convert local references into array lookups instead of mapping lookups.\n3. And of course that \"somewhere\" is unspecified\u2014Python is garbage-collected, whether using automatic refcounting plus a cycle detector as in CPython, or whatever the underlying JVM uses as in Jython. But in CPython, there's also a defined C API, where objects are C pointers to structs\u2014and you can see the value of this pointer with the id function.\n4. Also, that 864 bytes is mostly just a list of 100 pointers to a single immutable 0 object, unlike C, where there are 100 separate mutable int slots that all have the value 0 in them.","Q_Score":3,"Tags":"python,recursion,stack","A_Id":50193197,"CreationDate":"2018-05-05T19:13:00.000","Title":"Python recursion limit vs stack size?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm playing around with ethereum and python and I'm running into some weird behavior I can't make sense of. I'm having trouble understanding how return values work when calling a contract function with the python w3 client. Here's a minimal example which is confusing me in several different ways:\nContract:\n\npragma solidity ^0.4.0;\n\ncontract test {\n    function test(){\n\n    }\n\n    function return_true() public returns (bool) {\n        return true;\n    }\n\n    function return_address() public returns (address) {\n        return 0x111111111111111111111111111111111111111;\n    }\n}\n\nPython unittest code\n\nfrom web3 import Web3, EthereumTesterProvider\nfrom solc import compile_source\nfrom web3.contract import ConciseContract\nimport unittest\nimport os\n\n\ndef get_contract_source(file_name):\n    with open(file_name) as f:\n        return f.read()\n\n\nclass TestContract(unittest.TestCase):\n    CONTRACT_FILE_PATH = \"test.sol\"\n    DEFAULT_PROPOSAL_ADDRESS = \"0x1111111111111111111111111111111111111111\"\n\n    def setUp(self):\n        # copied from https:\/\/github.com\/ethereum\/web3.py\/tree\/1802e0f6c7871d921e6c5f6e43db6bf2ef06d8d1 with MIT licence\n        # has slight modifications to work with this unittest\n        contract_source_code = get_contract_source(self.CONTRACT_FILE_PATH)\n        compiled_sol = compile_source(contract_source_code)  # Compiled source code\n        contract_interface = compiled_sol[':test']\n        # web3.py instance\n        self.w3 = Web3(EthereumTesterProvider())\n        # Instantiate and deploy contract\n        self.contract = self.w3.eth.contract(abi=contract_interface['abi'], bytecode=contract_interface['bin'])\n        # Get transaction hash from deployed contract\n        tx_hash = self.contract.constructor().transact({'from': self.w3.eth.accounts[0]})\n        # Get tx receipt to get contract address\n        tx_receipt = self.w3.eth.getTransactionReceipt(tx_hash)\n        self.contract_address = tx_receipt['contractAddress']\n        # Contract instance in concise mode\n        abi = contract_interface['abi']\n        self.contract_instance = self.w3.eth.contract(address=self.contract_address, abi=abi,\n                                                      ContractFactoryClass=ConciseContract)\n\n    def test_return_true_with_gas(self):\n        # Fails with HexBytes('0xd302f7841b5d7c1b6dcff6fca0cd039666dbd0cba6e8827e72edb4d06bbab38f') != True\n        self.assertEqual(True, self.contract_instance.return_true(transact={\"from\": self.w3.eth.accounts[0]}))\n\n    def test_return_true_no_gas(self):\n        # passes\n        self.assertEqual(True, self.contract_instance.return_true())\n\n    def test_return_address(self):\n        # fails with AssertionError: '0x1111111111111111111111111111111111111111' != '0x0111111111111111111111111111111111111111'\n        self.assertEqual(self.DEFAULT_PROPOSAL_ADDRESS, self.contract_instance.return_address())\n\nI have three methods performing tests on the functions in the contract. In one of them, a non-True value is returned and instead HexBytes are returned. In another, the contract functions returns an address constant but python sees a different value from what's expected. In yet another case I call the return_true contract function without gas and the True constant is seen by python.\n\nWhy does calling return_true with transact={\"from\": self.w3.eth.accounts[0]} cause the return value of the function to be HexBytes(...)?\nWhy does the address returned by return_address differ from what I expect?\n\nI think I have some sort of fundamental misunderstanding of how gas affects function calls.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":792,"Q_Id":50194364,"Users Score":2,"Answer":"The returned value is the transaction hash on the blockchain. When transacting (i.e., when using \"transact\" rather than \"call\") the blockchain gets modified, and the library you are using returns the transaction hash. During that process you must have paid ether in order to be able to modify the blockchain. However, operating in read-only mode costs no ether at all, so there is no need to specify gas.\nDiscounting the \"0x\" at the beginning, ethereum addresses have a length of 40, but in your test you are using a 39-character-long address, so there is a missing a \"1\" there. Meaning, tests are correct, you have an error in your input.\n\nOfftopic, both return_true and return_address should be marked as view in Solidity, since they are not actually modifying the state. I'm pretty sure you get a warning in remix. Once you do that, there is no need to access both methods using \"transact\" and paying ether, and you can do it using \"call\" for free.\nEDIT\nForgot to mention: in case you need to access the transaction hash after using transact you can do so calling the .hex() method on the returned HexBytes object. That'll give you the transaction hash as a string, which is usually way more useful than as a HexBytes.\nI hope it helps!","Q_Score":0,"Tags":"python,ethereum,solidity,web3","A_Id":58494505,"CreationDate":"2018-05-05T21:56:00.000","Title":"Unintuitive solidity contract return values in ethereum 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":"Google Colab is awesome to work with, but I wish I can run Colab Notebooks completely locally and offline, just like Jupyter notebooks served from the local?\nHow do I do this? Is there a Colab package which I can install?\n\nEDIT: Some previous answers to the question seem to give methods to access Colab hosted by Google. But that's not what I'm looking for.\nMy question is how do I pip install colab so I can run it locally like jupyter after pip install jupyter. Colab package doesn't seem to exist, so if I want it, what do I do to install it from the source?","AnswerCount":3,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":41922,"Q_Id":50194637,"Users Score":-4,"Answer":"Google Colab is a cloud computer\uff0cit only runs through Internet\uff0cyou can design your Python script\uff0cand run the Python script through Colab\uff0crun Python will use Google Colab hardware\uff0cGoogle will allocate CPU, RAM, GPU and etc for your Python script\uff0cyour local computer just submit Python code to Google Colab\uff0cand run\uff0cthen Google Colab return the result to your local computer\uff0ccloud computation is stronger than local\ncomputation if your local computer hardware is limited\uff0csee this question link will inspire you\uff0casked by me\uff0chttps:\/\/stackoverflow.com\/questions\/48879495\/how-to-apply-googlecolab-stronger-cpu-and-more-ram\/48922199#48922199","Q_Score":23,"Tags":"python,pip,google-colaboratory,productivity-power-tools","A_Id":50194820,"CreationDate":"2018-05-05T22:40:00.000","Title":"Colaboratory: How to install and use on local machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What's the difference between tkinter's Entry() and Text() functions?\nCouldn't find anything online, so after figuring it out, wanted to make it available online for others.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":6118,"Q_Id":50194711,"Users Score":1,"Answer":"The Entry widget has validation commands (ie, possibility to have only lowercase, only digits etc). This needs some workaround to make work in Text widgets.","Q_Score":3,"Tags":"python,python-3.x,user-interface,tkinter","A_Id":56186574,"CreationDate":"2018-05-05T22:54:00.000","Title":"What's the difference between Entry() and Text()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I get something like Spyder's runfile function in IPython?  (I'm using IPython v. 4.1.2 under Python 2.7.9.)","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3642,"Q_Id":50195402,"Users Score":2,"Answer":"FWIW, runfile is also included as a builtin function in PyCharm, another IDE. PyCharm's Python Console use IPython by default if you have it installed, and runfile works there. Just another option.","Q_Score":5,"Tags":"python,ipython","A_Id":56728642,"CreationDate":"2018-05-06T01:11:00.000","Title":"Equivalent of Spyder's runfile for IPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been self-learning machine learning lately, and I am now trying to solve a binary classification problem (i.e: one label which can either be true or false). I was representing this as a single column which can be 1 or 0 (true or false).\nNonetheless, I was researching and read about how categorical variables can reduce the effectiveness of an algorithm, and how one should one-hot encode them or translate into a dummy variable thus ending with 2 labels (variable_true, variable_false).\nWhich is the correct way to go about this? Should one predict a single variable with two possible values or 2 simultaneous variables with a fixed unique value?\nAs an example, let's say we want to predict whether a person is a male or female:\nShould we have a single label Gender and predict 1 or 0 for that variable, or Gender_Male and Gender_Female?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":381,"Q_Id":50198094,"Users Score":0,"Answer":"it's basically the same, when talking about binary classification, you can think of a final layer for each model that adapt the output to other model\ne.g if the model output 0 or 1 than the final layer will translate it to vector like [1,0] or [0,1] and vise-versa by a threshold criteria, usually is >= 0.5\na nice byproduct of 2 nodes in the final layer is the confidence level of the model in it's predictions [0.80, 0.20] and [0.55, 0.45] will both yield [1,0] classification but the first prediction has more confidence\nthis can be also extrapolate from 1 node output by the distance of the output from the fringes 1 and 0 so 0.1 will be considered with more confidence than 0.3 as a 0 prediction","Q_Score":0,"Tags":"python,machine-learning","A_Id":50198173,"CreationDate":"2018-05-06T09:13:00.000","Title":"Predicting binary classification","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to initialize an empty list of given size. I've found the following on SO:lst = [None] * nWhat is complexity of this piece of code? Is it constant or linear? If it's linear then what are the constant ways?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1620,"Q_Id":50198421,"Users Score":4,"Answer":"Creating a list of size N will always be O(N) in Python.  If you want to create lists in constant time but with variable length, you'll need to write your own data structure which does it in a \"virtual\" way.  For example, imagine a class similar to list but with an extra member \"_virtual_len\" which is returned by __len__().  Then when iterating, this special list-like class can iterate over the actual values it contains, plus some number of \"empty\" values to reach _virtual_len.  Constructing such a list would be O(1).","Q_Score":2,"Tags":"python","A_Id":50198446,"CreationDate":"2018-05-06T09:57:00.000","Title":"Complexity of initializing a list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For python celery.\nI have 2 queues (say q1 and q2) and several tasks for them.\nSome memory-consuming tasks will be drop into q2 and others to q1. And I don't want 2 q2 tasks (memory consuming tasks) executing at the same time. Can I leave some limitations for them to prevent 2 or more workers doing q2 tasks at the same time? Like set concurrency for each queue? How to do that?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":50198622,"Users Score":0,"Answer":"Take a look at asyncio. This package can help you define and manage your concurrent tasks as you wish.","Q_Score":0,"Tags":"python,concurrency,task,celery","A_Id":50198822,"CreationDate":"2018-05-06T10:24:00.000","Title":"How to limit workers doing tasks in a specific queue? [Celery][Python]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I haven't found any examples how to add a retry logic on some rpc call. Does gRPC have the ability to add a maximum retry for call? \nIf so, is it a built-in function?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1347,"Q_Id":50204638,"Users Score":1,"Answer":"Retries are not a feature of gRPC Python at this time.","Q_Score":4,"Tags":"python,grpc","A_Id":50340007,"CreationDate":"2018-05-06T21:22:00.000","Title":"Does gRPC have the ability to add a maximum retry for 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pipenv seems to work only in the directory where the Pipfile lives. Maybe I'm trying to use it in a way it is not designed for.\nFor example, I installed a tool called \"leo\" (an editor) and no surprise that I will go to many folders and start pipenv run Leo and it will start to install another virtual environment. What's the workaround?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":10256,"Q_Id":50205311,"Users Score":1,"Answer":"It's really hard to google this but I found the best solution.\nTo easily activate a virtual environment anywhere with pipenv, you can use pew.\nOnce you pip install pew, you can easily do \"pew workon myvenv\".\nPew uses pipenv under the hood and it works on Windows too.","Q_Score":15,"Tags":"python,virtualenv,pipenv","A_Id":50288075,"CreationDate":"2018-05-06T23:05:00.000","Title":"pipenv: only works in a installed 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":1,"Web Development":0},{"Question":"I installed Python 3.6.5 on Windows 10. I see that there is a sqlite3 folder in ...\\Python\\Python36\\Lib directory. I added Python PATH to environment variable. However, I can't run the command \"sqlite3\" from Powershell nor Git Bash. It would say \"command not found\". What did I do wrong?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8283,"Q_Id":50205804,"Users Score":0,"Answer":"I had an issue with installing brotab, and I always got the message that sqlite3 was not found. I had just installed python beforehand, and in list of modules, I saw sqlite3. When I started py.exe console, I also could import that module. It turned out that I had a entry in my Path to c:\\Program Files\\LibreOffice\\program, which contained an older version of python.exe.\nI ran python.exe -m pydoc -b inside that program folder to see the Index of modules, and there was no mention of sqlite3. I removed that entry from my Path, and kept the newly installed python.exe, and it fixed the issue","Q_Score":5,"Tags":"python,python-3.x,sqlite","A_Id":69244735,"CreationDate":"2018-05-07T00:43:00.000","Title":"sqlite3: command not found Python 3 on Windows 10","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Python 3.6.5 on Windows 10. I see that there is a sqlite3 folder in ...\\Python\\Python36\\Lib directory. I added Python PATH to environment variable. However, I can't run the command \"sqlite3\" from Powershell nor Git Bash. It would say \"command not found\". What did I do wrong?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8283,"Q_Id":50205804,"Users Score":0,"Answer":"So, apparently Sqlite3's CLI does not come installed with Python (Python 3.6). What comes pre-installed is Python's Sqlite3 library.So, you can access the Sqlite3 DB either through the library, or by manually installing Sqlite3 CLI.","Q_Score":5,"Tags":"python,python-3.x,sqlite","A_Id":53717912,"CreationDate":"2018-05-07T00:43:00.000","Title":"sqlite3: command not found Python 3 on Windows 10","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to create a classifier to identify some aphids.\nMy project has two parts, one with a computer vision (OpenCV), which I already conclude. The second part is with Machine Learning using TensorFlow. But I have no idea how to do it.\nI have these data below that have been removed starting from the use of OpenCV, are HuMoments (I believe that is the path I must follow), each line is the HuMoments of an aphid (insect), I have 500 more data lines that I passed to one CSV file.\nHow can I make a classifier from a CSV file using TensorFlow?\n\nHuMoments (in CSV file):\n  0.27356047,0.04652453,0.00084231,7.79486673,-1.4484489,-1.4727380,-1.3752532\n  0.27455502,0.04913969,3.91102408,1.35705980,3.08570234,2.71530819,-5.0277362\n  0.20708829,0.01563241,3.20141907,9.45211423,1.53559373,1.08038279,-5.8776765\n  0.23454372,0.02820523,5.91665789,6.96682467,1.02919203,7.58756583,-9.7028848","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":50206222,"Users Score":0,"Answer":"You can start with this tutorial, and try it first without changing anything; I strongly suggest this unless you are already familiar with Tensorflow so that you gain some familiarity with it.\nNow you can modify the input layer of this network to match the dimensions of the HuMoments. Next, you can give a numeric label to each type of aphid that you want to recognize, and adjust the size of the output layer to match them.\nYou can now read the CSV file using python, and remove any text like \"HuMoments\". If your file has names of aphids, remove them and replace them with numerical class labels. Replace the training data of the code in the above link, with these data.\nNow you can train the network according to the description under the title \"Train the Model\".\nOne more note. Unless it is essential to use Tensorflow to match your project requirements, I suggest using Keras. Keras is a higher level library that is much easier to learn than Tensorflow, and you have more sample code online.","Q_Score":0,"Tags":"python,csv,tensorflow","A_Id":50206803,"CreationDate":"2018-05-07T02:06:00.000","Title":"Tensorflow How can I make a classifier from a CSV file using TensorFlow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If i have a list of list of integers S:  [[1,2,3],[3,4,5],[5,6,7]], and a single list T: [2,3,1]. I want to return true if T as a combination is contained in S. Assuming each element of S has same length as that of T.\nIn this case, I want to return true.\nRestrictions: No sorting of any kind, and note S has all unique lists, but within a list, it can have duplicate elements.\nHow can I do this as efficiently as possible. I can iterate through each element of S and turn it into a set and compare it with set(T), but that seems very slow if size of S and length of each element of S gets bigger.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":243,"Q_Id":50207041,"Users Score":0,"Answer":"If a stipulation is without sorting, you might want to look into an order-independent hash function for the combinations. Two starting points I liked were (1) the sum of the hashes of the individual elements of the combination, and (2) a tuple (sum(combination), product(combination)).","Q_Score":2,"Tags":"python,algorithm,big-o","A_Id":50212697,"CreationDate":"2018-05-07T04:17:00.000","Title":"Checking existence of combination in a list against a list of lists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I developed a gomory cut for a LP problem (based on 'test-gomory.py' test file) which I could not manage to run. Finally, I copied the test file to check whether I'd the same trouble. Indeed I got the same message:\nif not scip.isLPSolBasic():\nAttributeError: 'pyscipopt.scip.Model' object has no attribute 'isLPSolBasic'\nI have downloaded SCIPOptSuite 5.0.1 win64, set up path and installed pyscipiopt using pip on conda. \nI cannot figure what is wrong, except that I may have failed to install pyscipopt properly? Thank you for pointing me in the right direction.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":50209928,"Users Score":0,"Answer":"Your assumption is correct: The pip version of PySCIPOpt was outdated and did not yet include the latest updates with respect to cutting plane separators. I just triggered a new release build (v.1.4.6) that should be available soon.\nWhen in doubt, you can always build PySCIPOpt from source by running python setup.py install from within the project directory.","Q_Score":0,"Tags":"python,discrete-mathematics,scip","A_Id":50210208,"CreationDate":"2018-05-07T08:23:00.000","Title":"PySCIPOpt\/SCIP - isLPSolBasic() not in pyscipopt.scip.Model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to import socketserver and it asked me to install, so i went with the command \"pip install socketserver\" and it says: \n\"Could not find a version that satisfies the requirement socketserver (from versions:) \nNo matching distribution found for socketserver\" \nAny sort of help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":5929,"Q_Id":50211310,"Users Score":3,"Answer":"socketserver is a standard library module so you don't need to install it. It looks like you are using Python 2 so use SocketServer, In Python 3 it's renamed to socketserver.","Q_Score":2,"Tags":"python,python-3.x,python-2.7,websocket,serversocket","A_Id":50212231,"CreationDate":"2018-05-07T09:48:00.000","Title":"No matching distribution found for socketserver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This one drive me crazy as I try to solve it for 3 days now with no success. \nI have a python script that automate some stuff, one of its main objectives is to run cmd commands whenever the user want this (User want to print something to console) as an example\n\nPyH1,PyH2,i1,i2 = win32process.CreateProcess(None,Command ,None,None,1,\\\n                                             CreationFlag,\\\n                                             None,None,PySTARTUPINFO)\ngive me this error pywintypes.error: (2, 'CreateProcess', 'The system cannot find the file specified.')\nI am Just sending \"echo Hello World\" to the cmd through python command variable in the CreateProcess second argument. \nMy Operating system is Win7(x64)\nPython Version : Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)]\non win32\nI tried to reinstall Pywin (32 & 64) both didn't work, and I am confused, which file dosen't exist, as I don't supply or need any!! \nI tried to include cmd path in Windows Environment variables with no succss. \nI tried to include a path to notepad instead of my original echo hello world, it works and opened notepad normally, so CreateProcess is not damaged for any reason.\nI hav another Python version on my machine \nPython 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32\nWhere should I look, is it some 64\/32 bit issue or more than that!\nI really apprecite help at that one, thank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1191,"Q_Id":50212849,"Users Score":1,"Answer":"Try to pass cmd.exe as first argument to CreateProcess and \/c \"echo Hello world\" as second\nOr leave 1st as None and pass to second full cmd line: cmd.exe \/c \"echo Hello world\"","Q_Score":0,"Tags":"python,pywin32","A_Id":50213148,"CreationDate":"2018-05-07T11:12:00.000","Title":"can't run CMD command through Python win32Process.Create Process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on something using gensim.\nIn gensim, var index usually means an object of gensim.similarities.<cls>.\nAt first, I use gensim.similarities.Similarity(filepath, ...) to save index as a file, and then loads it by gensim.similarities.Similarity.load(filepath + '.0'). Because gensim.similarities.Similarity default save index to shards file like index.0.\nWhen index file becoming larger, it automatically seperate into more shards, like index.0,index.1,index.2......\nHow can I load these shards file? gensim.similarities.Similarity.load() can only load one file.\nBTW: I have try to find the answer in gensim's doc, but failed.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":473,"Q_Id":50213754,"Users Score":0,"Answer":"shoresh's answer is correct. The key part that OP was missing was \n    index.save(output_fname)\nWhile just creating the object appears to save it, it's really only saving the shards, which require saving a sort of directory file (via index.save(output_fname) to be made accessible as a whole object.","Q_Score":1,"Tags":"python,gensim","A_Id":58696815,"CreationDate":"2018-05-07T12:01:00.000","Title":"How to load index shards by gensim.similarities.Similarity\uff1f","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have list of dictionary in dataflow. I have converted the columns into dictionary of key value pair. Now I want to get distinct values of each column. How can i do this in dataflow without sending the entire data as side input. I can achieve this as a side input data.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1133,"Q_Id":50214887,"Users Score":0,"Answer":"you may create a combiner for a groupbykey operation that counts the occurrences of a key. In that way you'll get a list of couples (key, count). This is feasible as long as you have only few keys to check, IMHO.","Q_Score":1,"Tags":"python,google-cloud-dataflow,apache-beam","A_Id":55327004,"CreationDate":"2018-05-07T13:01:00.000","Title":"Apache beam python get distinct values from list of dictionary","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've build before server-client programs (both sides where build in python by far).\nRecently I started building app using swift and my goal is to add a backend to my apps using python (My app is a chat app)\nI searched in the Internet a tutorials to do so, and I only saw two options to communicate between server side and mobile application, the first one is to create an API (REST) (request - response) - I can't use this solution because I want a real-time chat.\nAnd the second option was web-sockets (socket.IO).\nSO, my question is why not use the simple socket technology (like I used to use when it was only python server side to python client side -> import sockets) -  no sockets over web","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1859,"Q_Id":50216417,"Users Score":3,"Answer":"following Features You will get if you are using Socket.io or socketcluster.io (which is developed on the top of Socket IO)\n\nscalability :- It will scale horizontally adding more nodes (scale-out) & Linearly(scale-up)\nReduces Payload size as message payload is compressed\nAuthorisation via middle ware functions\nReconnects Automatically if Connection drops\n\nIf You want to use your own implementation then you have to take care of the above features\/Solutions to problems which arises when User-base is increases.","Q_Score":1,"Tags":"python,swift,sockets,websocket,socket.io","A_Id":50216729,"CreationDate":"2018-05-07T14:17:00.000","Title":"Why Use Socket IO and not just Socket?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is more of an architectural question. If I should be asking this question elsewhere, please let me know and I shall.\nI have a use-case where I need to run the same python script (could be long-running) multiple times based on demand and pass on different parameters to each of them. The trigger for running the script is external and it should be able to pass on a STRING parameter to the script along with the resource configurations each script requires to run. We plan to start using AWS by next month and I was going through the various options I have. AWS Batch and Fargate both seem like feasible options given my requirements of not having to manage the infrastructure, dynamic spawning of jobs and management of jobs via python SDK. \nThe only problem is that both of these services are not available in India. I need to have my processing servers in India physically. What options do I have? Auto-scaling and Python SDK management (Creation and Deletion of tasks) are my main requirements (preferably containerized).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":50217591,"Users Score":0,"Answer":"Why are you restricted to India? Often restrictions are due to data retention, in which case just store your data on Indian servers (S3, DynamoDB etc) and then you are able to run your 'program' in another AWS region","Q_Score":0,"Tags":"python,amazon-web-services,containers,autoscaling,serverless","A_Id":50270433,"CreationDate":"2018-05-07T15:22:00.000","Title":"AWS: containarised serverless solutions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a question about PyQt4 in motionbuilder 2016\nI have successfully installed Pyqt4 from pip\nand it show up \"have Requirement already satisfied: PyQt4 in c:\\python27\\lib\\site-packages (4.11.4) \"\nbut when import the module in motionbuilder by using import PyQt4\nis have  the error : \"ImportError: No module named PyQt4\"\nAny suggestions would be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":496,"Q_Id":50218411,"Users Score":0,"Answer":"I have found out the problem and solved\nUninstall the Python2.7 and reinstall again, getting the new version of Pip, install the whl file by using pip\nit solved, i think is my sys.path mass up!","Q_Score":0,"Tags":"python,python-2.7,pyqt4,motionbuilder","A_Id":50251538,"CreationDate":"2018-05-07T16:11:00.000","Title":"motionbuilder 2016 PyQt4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background: I am working on classifying data from a ticketing system data into a failed or successful requests. A request goes into various stages before getting completed. Each request is assigned to different teams and individuals before being marked as complete. \nMaking use of historical data I want to create predictions for these tickets at a final state x before they are marked as complete(success or fail).\nAmongst the various features, individual's name who work on the records & team names are very important factors in analysing this data. Being a huge organization I expect 5-10 new names being added every day.\nHistorical data \n60k records (used for training, validation and testing)\nHas 10k unique individual names \nCurrent data\nOveral 1k records\n- Has 200 individual names\nI'm facing a challenge due to high cardinality data like individual names whose number is not fixed and keeps on growing.\n1. Challenge while making actual predictions - The no. of columns for the current data will be different every time and would never match the feature length of training data. \n- So I have to train my model every single time, I want to make predictions.\n2. Challenge while data prep -  The above also presents a challenge for data prep as now I always have to encode the complete data and the query encoded data to split into current and future data.\nSorry for the long story. \nWhat am I looking for?\nIs there a better way to approach? \nThese high & constantly changing dimensions is a pain. Any suggestions on how can I handle them, to avoid training every time?\nNote: I tried using PCA and Autoencoders for dim red. (The results were not great for my highly unbalanced dataset so I'm working on the data with high dimensions only)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":254,"Q_Id":50219738,"Users Score":0,"Answer":"You can use replace all id numbers and names in the data with a standard token like <ID> or <NAME>. This should be done during preprocessing. Next you should pick a fixed vocabulary. Like all words that occur at least 5 times in the training data.","Q_Score":1,"Tags":"python,machine-learning,data-science,dimensionality-reduction,cardinality","A_Id":50225476,"CreationDate":"2018-05-07T17:42:00.000","Title":"Challenges with high cardinality data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background: I am working on classifying data from a ticketing system data into a failed or successful requests. A request goes into various stages before getting completed. Each request is assigned to different teams and individuals before being marked as complete. \nMaking use of historical data I want to create predictions for these tickets at a final state x before they are marked as complete(success or fail).\nAmongst the various features, individual's name who work on the records & team names are very important factors in analysing this data. Being a huge organization I expect 5-10 new names being added every day.\nHistorical data \n60k records (used for training, validation and testing)\nHas 10k unique individual names \nCurrent data\nOveral 1k records\n- Has 200 individual names\nI'm facing a challenge due to high cardinality data like individual names whose number is not fixed and keeps on growing.\n1. Challenge while making actual predictions - The no. of columns for the current data will be different every time and would never match the feature length of training data. \n- So I have to train my model every single time, I want to make predictions.\n2. Challenge while data prep -  The above also presents a challenge for data prep as now I always have to encode the complete data and the query encoded data to split into current and future data.\nSorry for the long story. \nWhat am I looking for?\nIs there a better way to approach? \nThese high & constantly changing dimensions is a pain. Any suggestions on how can I handle them, to avoid training every time?\nNote: I tried using PCA and Autoencoders for dim red. (The results were not great for my highly unbalanced dataset so I'm working on the data with high dimensions only)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":254,"Q_Id":50219738,"Users Score":0,"Answer":"Since you have a dynamic data like you said, you can use neural net to identify and merge updating variables and data.\nAlso you should use classifiers like\n\nCVParameterSelection : For cross validation parameter selection.\nPART : For making a decision tree, great utility as it works on divide and conquer rule.\nREP Tree (Pruned) : For reduced error in output by splitting error values\n\nAnd finally when you have the systems in place, you can run the prediction model!","Q_Score":1,"Tags":"python,machine-learning,data-science,dimensionality-reduction,cardinality","A_Id":50226408,"CreationDate":"2018-05-07T17:42:00.000","Title":"Challenges with high cardinality data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a python script on linux terminal. The script has an infinite calculus loop and it never ends, so for now I'm stopping it with ctrl+C. After that, all the ram memory consumed by the program (which is a lot, and I don't find the leakage yet) is still consumed, until the moment I close the terminal. What can be happening?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":50220796,"Users Score":0,"Answer":"it may be an infinte loop or just some calculations that took too much time, for the sake of completeness, can you please post your code?","Q_Score":0,"Tags":"python,memory,memory-management,memory-leaks,terminal","A_Id":50220906,"CreationDate":"2018-05-07T19:00:00.000","Title":"ram memory consumed after program exit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying my hand at writing my first decorator. I have seen lots of video tutorials and blog posts about it, but I have not seen anything about where to put the decorator so that the function being decorated can find it. That seems pretty basic, and maybe it is 'obvious' to those who have done it before, but since that's not me, I am asking. Note I am not asking where to put @decorator. I know that goes on the line above the function being decorated. But the decorator itself has to be written and put somewhere where the @ syntax can find and apply it. All the examples I've seen have them both in the same file or script, but I have never seen a decorator like that in actual practice, nor have I seen an import statement that brings it into the app. So where should it be, and how does the decorated app \/ python find it?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":75,"Q_Id":50221717,"Users Score":2,"Answer":"As you probably know, the decorator is just a function just like any other function. So you place it just like you would place any other function\n\nIn the same file\nIn a different file. In this case you need to also import the function","Q_Score":4,"Tags":"python,decorator,python-decorators","A_Id":50221738,"CreationDate":"2018-05-07T20:09:00.000","Title":"Where do you put a decorator after you've written it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to fill a Tkinter canvas polygon with an image using PIL or another libraries? I need to transform an image or draw it by pixel.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":442,"Q_Id":50222253,"Users Score":0,"Answer":"You can draw a polygon around an image, but you can't fill a polygon with an image. You would have to calculate the space of a polygon, and then use an external library or program to change the size of the image. Tkinter can  only double or halve the size of images.","Q_Score":0,"Tags":"python,tkinter","A_Id":50222299,"CreationDate":"2018-05-07T20:50:00.000","Title":"Filling a Tkinter Canvas Polygon with an Image","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I am using my second computer to gather some data and insert it into the SQL database. I set up everything when it comes to reading and writing the database remotely, and I can insert new rows just by using the normal SQL.\nWith pyodbc I can read tables, but when I insert new data, nothing happens. No error message, but also no new rows in the table. \nI wonder if anyone has faced this issue before and knows what the solution is.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":50223255,"Users Score":0,"Answer":"The cursor.execute() method only prepares the SQL statement. Then, since this is an INSERT statement, you must use the cursor.commit() method for the records to actually populate your table. Likewise for a DELETE statement, you need to commit, as well.\nWithout more perspective here, I can only assume that you are not committing the insert.\nNotice, similarly, that when you run cursor.execute(\"\"\"select * from yourTable\"\"\"), you need to run cursor.fetchall() or another fetch statement to actually retrieve and view your query.","Q_Score":1,"Tags":"python,pyodbc","A_Id":50583744,"CreationDate":"2018-05-07T22:17:00.000","Title":"Inserting into SQL with pyodbc from remote computer","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I asked a similar questions some days ago but it was a bit unclear so I deleted it and made this new one here.\nI have a project that fetches market data from cryptocurrency exchanges (Binance, Kraken, Poloniex, etc...). I want to be able to add additional exchanges while the project is up and running. For example I am pulling data every 10 seconds from Binance and Poloniex but now I want to add support for Kraken. How can I keep fetching data from the other two exchanges (add Kraken without restarting the program).\nI currently have 2 solutions in mind.\n\nStart the client that is fetching the data as a new process for each exchange\nUse importlib.import_module() to load new modules and handle every exchange in the same process (using asyncio)\n\nAlso, what if I want to add functionality like fetching data from another API endpoint. Method 1 would probably require a restart, with method 2 I could reload all modules and update the class instances between the fetch calls. But I am unsure about the side effects this can cause. \nMaybe there is a default way how such a project is implemented?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":50223336,"Users Score":0,"Answer":"I would consider designing a base class, named something like CryptoCurrencyExchangeParser.  This class would have methods that allowed client code to extract data in a standard way, no matter which exchange it came from.  Each specific exchange would then be a subclass, containing methods (possibly defined as abstract in the base class) to access and parse the data.\nThen I would write a factory function to load one parser, probably specified by a string.  This factory function would use the python import machinery to find the code for the requested parser.  The main program would keep a list of the active parsers.\nSuch a design would mean that all of the parsers used exactly the same mechanism, whether they were loaded on program start or ten years later.  Whether to use multiprocessing, multithreading or some other approach would be factored out as a separate design decision.","Q_Score":0,"Tags":"python,api,fetch,python-asyncio,cryptocurrency","A_Id":50223595,"CreationDate":"2018-05-07T22:26:00.000","Title":"Python dynamically update\/add\/remove modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to Scrapy and Scrapyd and I'm experimenting with them. \nI have deployed a simple Flask app with Gunicorn that has an API endpoint that sends a call to scrapyd to schedule a spider.\nLocally I have to launch scrapyd in a separate terminal to listen to calls from the Flask endpoint, but how is it possible to do the same on Heroku? I mean to be able to process requests to the Flask's endpoint and to listen to calls from the Flask to scrapyd at the same time. \nAny help much appreciated.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":307,"Q_Id":50223446,"Users Score":0,"Answer":"You can use scrapyd endpoint to schedule an spider from your flask front-end which sends an http request to scrapyd and for checking if the jobs is finished you can call running jobs if job-id exist in running jobs or not . There can also be better way to do it you can return an signal after the crawling has been finished.","Q_Score":0,"Tags":"python,flask,scrapyd","A_Id":52906522,"CreationDate":"2018-05-07T22:41:00.000","Title":"Is there a way to run scrapyd while running flask on Heroku","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working with Python and Selenium to do some automation in the office, and I need to fill in an \"upload file\" dialog box (a windows \"open\" dialog box), which was invoked from a site using a headless chrome browser. Does anyone have any idea on how this could be done?\nIf I wasn't using a headless browser, Pywinauto could be used with a line similar to the following, for example, but this doesn't appear to be an option in headless chrome:\napp.pane.open.ComboBox.Edit.type_keys(uploadfilename + \"{ENTER}\")\nThank you in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":533,"Q_Id":50223735,"Users Score":0,"Answer":"This turned out to not be possible. I ended up running the code on a VM and setting a registry key to allow automation to be run while the VM was minimized, disconnected, or otherwise not being interacted with by users.","Q_Score":1,"Tags":"python,google-chrome,selenium,automation,headless","A_Id":50398443,"CreationDate":"2018-05-07T23:22:00.000","Title":"How can you fill in an open dialog box in headless chrome in Python and Selenium?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"this is rather a straightforward question, i've tried to find something about it but either im totally out of my mind or it is not so easy to find out, Is there a way to have say: Microservice 1 (in Nodejs) and Microservice 2 (in Python) under the same ApiGateWay (Nodejs Express) ... i made it work using Nodejs (express) as gateWay and 2 Microservices in Nodejs (Cote.js) with no problem at all, but now i need part of the logic in python (Flask) .. what is the best approach to use a second language? i read something about an internal restApi but i could not find any clear example.\nby the way: If Docker helps i can totally use it, don't hesitate about it.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1401,"Q_Id":50225125,"Users Score":2,"Answer":"Its a rather usual case to have different microservices use different technologies. However they need an api to communicate with each other. Often that is a rest api. For example Microservice 1 listens on port x to requests. Depending on the requested url path (e.g \/hello-world) it will return a string representation (e.g json) of the requested data.\nDocker can help you with setting the ports of the services and glueing everything together.","Q_Score":1,"Tags":"node.js,python-3.x,docker,microservices","A_Id":50227627,"CreationDate":"2018-05-08T02:57:00.000","Title":"Multiple-language microservice approach","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am doing a mini project, where I need to create labels using tkinter library of python. I need to attach a link to each of the label, so that whenever I will click on a particular label, it should stream its online video. Videos can be YouTube videos. So I was wondering is there any way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":185,"Q_Id":50226886,"Users Score":1,"Answer":"You cannot easily do what you want. Tkinter has no way to render html. You would have to parse the HTML and CSS and Javascript yourself, and translate the information for display on a canvas or text widget.","Q_Score":0,"Tags":"python,tkinter","A_Id":50226992,"CreationDate":"2018-05-08T06:04:00.000","Title":"Is there any way to stream online videos in python tkinter window?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm aware of the Run Keyword and Continue on Failure \/ Run Keyword And Ignore Error \/ Run keyword and return status Builtin keywords but I have a very wide set of test cases that should not be stopped for any reason on a specific scenario and I was wondering if there is an option not to make the execution stop on a failure by default, without having to manage it through these keywords and adding a non-business related syntax in my upper layer keywords.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2227,"Q_Id":50227900,"Users Score":1,"Answer":"Although it feels a bit counter intuitive that you should want to continue when you've encountered an erronous situation, given that you may no longer be in control of the application. This in itself should be prevented. However, that said. \nGiven that you are already familiar with the family of Run and continue keywords, there is not much else to suggest and to answer the question with an affirmative: No. \nThe only approach is to wrap the keywords in a Run and Continue keyword.","Q_Score":0,"Tags":"python,testing,automated-tests,robotframework,atdd","A_Id":50230159,"CreationDate":"2018-05-08T07:11:00.000","Title":"Is there a way to configure Robot Framework so the execution is not stopped by a failure","Data Science and Machine Learning":0,"Database and SQL":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 running a Django project with an virtualenv, I want to get in views the path of running python or of the virtual environment that I'm using\nThe goal is to pass this path to subprocess to execute a script\nThank you","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":108,"Q_Id":50230563,"Users Score":0,"Answer":"The idea of @DanielRoseman was great, I used management.call_command instead of subprocess and it works fine, the correct virtual environement is passed implicitly","Q_Score":2,"Tags":"django,python-3.x,subprocess,virtualenv","A_Id":50253752,"CreationDate":"2018-05-08T09:41:00.000","Title":"Get virtualenv or python path in views","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm running a Django project with an virtualenv, I want to get in views the path of running python or of the virtual environment that I'm using\nThe goal is to pass this path to subprocess to execute a script\nThank you","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":108,"Q_Id":50230563,"Users Score":1,"Answer":"Have you tried request.META? \nI found out some useful information there.\n(I'm using pyenv now and I found PATH, PYENV_DIR, PYENV_ROOT, PYENV_VIRTUAL_ENV, VIRTUAL_ENV and so on.)","Q_Score":2,"Tags":"django,python-3.x,subprocess,virtualenv","A_Id":50231575,"CreationDate":"2018-05-08T09:41:00.000","Title":"Get virtualenv or python path in views","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I try to collect data for a database inside my tool. At the moment I have only a few variables so I have some entry widgets where the user puts the data in.\nSo now if I think a bit further I may have 25 or more variables. But I don't want to overflow my GUI with 25 or more entry widgets.\nI hope its okay to not include any code, I think entry widgets are well known.\nSo my question is:\nIs there a better widget to collect many inputs? I tried it with a treeview but I cant find a way to make the cells editable or anything similar.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":50230581,"Users Score":1,"Answer":"You could have one entry field and next to it a dropdown menu with which the user specifies which data he is entering. \nIf you can categorize the inputs, you could look into notebooks\/tabs for tkinter to seperate them nicely.","Q_Score":0,"Tags":"python,tkinter","A_Id":50230612,"CreationDate":"2018-05-08T09:41:00.000","Title":"Tkinter GUI many entry widgets, is there a better way?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know how to run a python script as a background process, but is there any way to compile a python script into exe file using pyinstaller or other tools so it could have no console or window ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":427,"Q_Id":50231913,"Users Score":0,"Answer":"If you want to run it in background without \"console and \"window\" you have to run it as a service.","Q_Score":0,"Tags":"python,compilation","A_Id":50232373,"CreationDate":"2018-05-08T10:55:00.000","Title":"How to \"compile\" a python script to an \"exe\" file in a way it would be run as background process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Any suggestion to make arabic letters appears correctly in python for visual studio 2017, for me it appears like this (????). Thanks for your help.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":50232061,"Users Score":0,"Answer":"Change the encoding to UTF-8 in Settings Menu.","Q_Score":0,"Tags":"python,visual-studio,arabic","A_Id":50232246,"CreationDate":"2018-05-08T11:03:00.000","Title":"Arabic Letters in python 3.6 for visual studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Any suggestion to make arabic letters appears correctly in python for visual studio 2017, for me it appears like this (????). Thanks for your help.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":50232061,"Users Score":0,"Answer":"the problem was fixed by right click on the top of the windows of the python IDLE, in default\/font i change the police to \"CourierNew\". But the letter are from the left to the right , is there any solution to fix that.","Q_Score":0,"Tags":"python,visual-studio,arabic","A_Id":50236708,"CreationDate":"2018-05-08T11:03:00.000","Title":"Arabic Letters in python 3.6 for visual studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to train a classifier, and my target variable has 300 unique values, and its type is character\/string\nIs there an automated process with pandas that can automatically trnsform each string into a number?\nThanks a lot","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":486,"Q_Id":50232939,"Users Score":0,"Answer":"You can use the pandas factorize method for converting strings into numbers.  numpy.unique can also be used but will be comparatively slower.","Q_Score":1,"Tags":"python-3.x","A_Id":50233334,"CreationDate":"2018-05-08T11:51:00.000","Title":"action when target variable is character\/string","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to let a class run on my server, which contains a connected bluetooth socket and continously checks for incoming data, which can then by interpreted. In principle the class structure would look like this:\nInterpreter:\n-> connect (initializes the class and starts the loop)\n-> loop (runs continously in the background)\n-> disconnect (stops the loop)\nThis class should be initiated at some point and then run continously in the background, from time to time a http request would perhaps need data from the attributes of the class, but it should run on its own.\nI don't know how to accomplish this and don't want to get a description on how to do it, but would like to know where I should start, like how this kind of process is called.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":359,"Q_Id":50233238,"Users Score":0,"Answer":"Django on its own doesn't support any background processes - everything is request-response cycle based.\nI don't know if what you're trying to do even has a dedicated name. But most certainly - it's possible. But don't tie yourself to Django with this solution.\nThe way I would accomplish this is I'd run a separate Python process, that would be responsible for keeping the connection to the device and upon request return the required data in some way. \nThe only difficulty you'd have is determining how to communicate with that process from Django. Since, like I said, django is request based, that secondary app could expose some data to your Django app - it could do any of the following:\n\nExpose a dead-simple HTTP Rest API\nExpose an UNIX socket that would just return data immediatelly after connection\nContinuously dump data to some file\/database\/mmap\/queue that Django could read","Q_Score":1,"Tags":"python,django,asynchronous,webserver,channels","A_Id":50233425,"CreationDate":"2018-05-08T12:08:00.000","Title":"(Django) Running asynchronous server task continously in the background","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"in my Python Script there is an ERROR with the line\nimport win32events\nI still installed the package pypiwin32 (with pip install pypiwin32) but it seems that this is nor the right package.\nDoes someone know what I need to install to use win32events in Python?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":2805,"Q_Id":50234342,"Users Score":3,"Answer":"You should install pywin32 package (not pypiwin32)!!!","Q_Score":1,"Tags":"python-3.x","A_Id":53041215,"CreationDate":"2018-05-08T13:04:00.000","Title":"Python ModuleNotFoundError: No module named 'win32event'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When searching my db all special characters work aside from the \"+\" - it thinks its a space. Looking on the backend which is python, there is no issues with it receiving special chars which I believe it is the frontend which is Javascript\nwhat i need to do is replace \"+\" == \"%2b\". Is there a way for me to use create this so it has this value going forth?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":50240427,"Users Score":1,"Answer":"You can use decodeURIComponent('%2b'), or encodeUriComponent('+');\nif you decode the response from the server, you get the + sign-\nif you want to replace all ocurrence just place the whole string insde the method and it decodes\/encodes the whole string.","Q_Score":0,"Tags":"javascript,python,replace,syntax","A_Id":50240590,"CreationDate":"2018-05-08T18:49:00.000","Title":"Replace character with a absolute value","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This is my first time coding a \"project\" (something more than solving exercises in single files). A number of my .py files have variables imported from a specific path. I also have a main \"Run\" file where I import things I've written in other files and execute the project as a whole. \nRecently I've started working on this project on several different machines (home, work, laptop etc) and have just started learning how to use GitHub.\nMy question is, how do I deal with the fact that every time I open up my code on a different machine I need to go around changing all the paths to fit the new machine, and then change them back again when I'm home? I started writing a Run file for each location I work at so that my sys.path commands are ok with that machine, but it doesn't solve the problem of my other modules importing variables from specific paths that vary from machine to machine. Is there a way round this or is the problem in how I'm setting up the project itself?\nIn an ideal world it would all just work without me having to change something before I run, depending on the machine I'm working on, but I don't know if that's possible.\nMy current thoughts are whether there is some command I'm not aware of that can set variables inside a .py file from my main Run.py file - that way I can just have a run file for each machine.\nAny suggestions are gladly taken! Whatever it is, it must be better than commenting back in the correct file path each time I open it on a different machine!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":201,"Q_Id":50242220,"Users Score":0,"Answer":"You should always use relative paths, not static which I assume you have got.\nAssuming your in an index file and you need to access images folder, you probably have something like \/users\/username\/project\/images\/image.png\nInstead you want something like ..\/images\/image.png, this tells your index file to go backwards one folder to say the root of the project, then proceed into our images folder etc.\nRelative paths mean you create a path from where your file exists, and not an entire path from ground up.","Q_Score":0,"Tags":"python,github,import,path,project","A_Id":50242289,"CreationDate":"2018-05-08T21:02:00.000","Title":"How to deal with working on one project on different machines (paths)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I run python manage.py shell_plus there are many pre and post imports there. How can I hide them(I want to use it but not to see it). I use python 3.4.3 and ipython 6.2.1","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":95,"Q_Id":50246070,"Users Score":-1,"Answer":"shell_plus imports all of the models from your INSTALLED_APPS, plus a few from Django itself. You can tell it not to load some of your apps and models with SHELL_PLUS_DONT_LOAD but there is no way to hide the report of what's been imported. \nOut of curiosity, why would you not want to? They scroll past in a flash and aren't in your way, and are sometimes important to telling you what's been imported from where. \nYou would have to contribute this feature to the project if you really need it, but I have to say it's hard to imagine a use case for it.","Q_Score":0,"Tags":"python,django,ipython,django-extensions","A_Id":50246437,"CreationDate":"2018-05-09T05:25:00.000","Title":"django extensions hide pre and post imports","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I hope to know a general approach when do data engineering.\nI have a data set with some variables with too many categories, and including these variables into a predictive model definitely would increase the complexity of the model, thus leads to overfit.\nWhile normally I would group those categories into fewer groups by drawing plots to see if the response variable is significantly different among these groups. Is there a more efficient way dealing with this issue, like automatically carry out some statistical test?\nADDED: In a nutshell, I hope to group or bin values in a variable  so that the response variable in each group has very different distribution.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":339,"Q_Id":50248547,"Users Score":0,"Answer":"I am not sure if I understand by \"automatically\". However, instead of plotting (which can be a hard task if you have many attributes for each sample), you can try to automatically group your samples using clustering techniques such as K-Means, Hierarchical clustering, SOM (or any clustering technique that fits to your problem). Then, for each group, you may extract any statistical information of interest.","Q_Score":0,"Tags":"python,r","A_Id":50252474,"CreationDate":"2018-05-09T08:13:00.000","Title":"Data with too many categories","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have a service running on Tornado, it is written asynchronously. I suspect that somewhere in the code there is a blocking call that hurts performance.\nIs there a way in Tornado to find this code section \/ function call? \nOr can I find code that holds the IOLoop longer than X ms?\nThanks\nAlex","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":211,"Q_Id":50257066,"Users Score":3,"Answer":"In Python 3+ and Tornado 5+, set the environment variable PYTHONASYNCIODEBUG=1. In older versions of either Tornado or Python, call IOLoop.current().set_blocking_log_threshold(0.5).\nEither way, this will cause a message to be logged whenever a call blocks for more than half a second.","Q_Score":2,"Tags":"python,tornado","A_Id":50257492,"CreationDate":"2018-05-09T15:31:00.000","Title":"How can I find a blocking call inside Tornado webserver?","Data Science and Machine Learning":0,"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 transitioning from MATLAB to Python and I found that the Spyder IDE is the closest environment I found that resembles MATLAB.  Does the Spyder IDE include a GUI builder like GUIDE from MATLAB? If not, is there a way to incorporate a GUI environment to Spyder?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2134,"Q_Id":50257458,"Users Score":1,"Answer":"(Spyder maintainer here) There's no such facility in Spyder and we don't have plans to add it in the future, sorry.","Q_Score":0,"Tags":"python,python-3.x,matlab,spyder","A_Id":50283134,"CreationDate":"2018-05-09T15:52:00.000","Title":"Does the Spyder IDE include a GUI builder like GUIDE from MATLAB?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently looking over the Eager mode in Tensorflow and wanted to know if I can extract the graph to use in Tensorboard. I understand that Tensorflow Eager mode does not really have a graph or session system that the user has to create. However, from my understanding there is one under the hood. Could this hidden Graph and Session be exported to support a visual graph view in Tensorboard? Or do I need to redo my model into a Graph\/Session form of execution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4878,"Q_Id":50257614,"Users Score":10,"Answer":"No, by default there is no graph nor sessions in eager executing, which is one of the reasons why it is so appealing. You will need to write code that is compatible with both graph and eager execution to write your net's graph in graph mode if you need to.\nNote that even though you can use Tensorboard in eager mode to visualize summaries, good ol' tf.summary.FileWriter is incompatible with eager execution: you need to use tf.contrib.summary.create_file_writer instead (works in graph mode too, so you won't have to change your code).","Q_Score":9,"Tags":"python,tensorflow,machine-learning","A_Id":50260668,"CreationDate":"2018-05-09T16:01:00.000","Title":"Tensorflow Eager and Tensorboard Graphs?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here in Brazil, the government made an app that you can type in the name of the item, for example \"Refined Sugar 2kg\" and the app return to you the location of the nearest market that has the cheapest item.\nIt extends to all sort of products, and I'm thinking about creating an app using that database. It is public, so it's not a crime, but they do not list all the products on the screen right away with categories and etc. The app only have a search bar, and that's it.\nHow can I get that database? I thought of an crawler (probably python), but all the crawlers that i see has an webpage as a 'target'. I never programmed mobile, so I don't know if a crawler can do that job.\nSo, what should I study in order to make an tool to extract that information?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":54,"Q_Id":50260803,"Users Score":2,"Answer":"\"How can I get that database? \"  The legal way would be to just ask them for it. Their database likely has passwords\/etc which means it is not meant for public use outside of the functionality that the application you mentioned provides. Are there ways to access this data without asking the owner of the information? Possibly. But to attain the data in any other way then asking for it and receiving it, then my friend you are entering a grey area. A crawler won't be much help for what you're trying to do.","Q_Score":0,"Tags":"python,database,mobile,web-crawler,extract","A_Id":50260896,"CreationDate":"2018-05-09T19:32:00.000","Title":"How can I get the database of an app that only has a search field","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I try to use Flask extensions, my application is raising ModuleNotFound errors on lines like from flask.ext.sqlalchemy import SQLAlchemy or from flask.exthook import ExtDeprecationWarning. I have Flask and the extension installed. Why do I get this error?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":5032,"Q_Id":50261135,"Users Score":21,"Answer":"Something in your code, or in code you're using, is trying to import flask.ext or flask.exthook, which no longer exists in Flask 1.0. They were completely removed after being visibly deprecated for at least a year, and implicitly deprecated for many years before that. Anything that still depends on it must be upgraded.\nAny use of from flask.ext import ... should be replaced with a direct import of the extension. For example flask.ext.sqlalchemy becomes flask_sqlalchemy.\nThe only reason to import from flask.exthook import ExtDeprecationWarning is to silence the previous deprecation warnings. Since it no longer exists, there is no warning to silence, and that code can be removed.","Q_Score":14,"Tags":"python,flask","A_Id":50261872,"CreationDate":"2018-05-09T19:58:00.000","Title":"Importing flask.ext raises ModuleNotFoundError","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How do you know which python modules\/packages you need to import in the beginning of your code?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":50262722,"Users Score":0,"Answer":"It depends on what you want your code to do.\nModules are usually just collections of functions that do different things.  For example, the module \"random\" contains functions for generating random numbers; and \"colored\" lets you change the font and background of the text you print in your terminal.\nYou can look around on sites like github.com to find cool libraries that may help you, or you may simply google around.","Q_Score":0,"Tags":"python,packages,python-import","A_Id":50262817,"CreationDate":"2018-05-09T22:05:00.000","Title":"How to know what packages\/modules you need to import in Python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Perhaps this is a broad question, but I haven't found an answer elsewhere, so here goes.\nThe Python script I'm writing needs to run constantly (in a perfect world, I recognize this may not be exactly possible) on a deployed device. I've already dedicated time to adding \"try...except\" statements throughout so that, should an issue arise, the script will recover and continue to work.\nThe issue is that I'm not sure I can (nor should) handle every single possible exception that may be thrown. As such, I've decided it may be better to allow the script to die and to use systemd to restart it.\nThe three options:\n\nMaking no attempt to handle any exception, and just allowing systemd to restart it whenever it dies.\nMeticulously creating handlers for every possible exception to guarantee that, short of loss of power, interpreter bug, or heat death of the universe, the script will always run.\nA mix of the two -- making an effort to prevent crashes in some cases while allowing them in others and letting systemd restart the script.\n\nThe third choice seems the most reasonable to me. So the question is this: What factors should be considered when optimizing between \"crash-proof\" code and allowing a crash and restart by systemd?\nFor some more application specific information: there is a small but noticeable overhead involved with starting the script, the main portion will run between 50 to 100 times per second, it is not \"mission critical\" in that there will be no death\/damage in the event of failure (just some data loss), and I already expect intermittent issues with the network it will be on.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":50262750,"Users Score":1,"Answer":"All known exceptional cases should be handled. Any undefined behavior is a potential security issue. \nAs you suggest, it is also prudent to plan for unknown exceptions. Perhaps there's also a small memory leak that will also cause the application to crash even when it's running correctly. So, it's still prudent to have systemd automatically restart it if it fails, even when all expected failure modes have been handled.","Q_Score":0,"Tags":"python,exception-handling,crash,systemd","A_Id":50263853,"CreationDate":"2018-05-09T22:08:00.000","Title":"\"Crash-proofing\" script vs.using systemd to guarantee near-constant operation","Data Science and Machine Learning":0,"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 are having n number of documents. Upon submission of new document by user, our goal is to inform him about possible duplication of existing document (just like stackoverflow suggests questions may already have answer).\nIn our system, new document is uploaded every minute and mostly about the same topic (where there are more chance of duplication).\nOur current implementation includes gensim doc2vec model trained on documents (tagged with unique document ids). We infer vector for new document and find most_similar docs (ids) with it. Reason behind choosing doc2vec model is that we wanted to take advantage of semantics to improve results. As far as we know, it does not support online training, so we might have to schedule a cron or something that periodically updates the model. But scheduling cron will be disadvantageous as documents come in a burst. User may upload duplicates while model is not yet trained for new data. Also given huge amount of data, training time will be higher.\nSo i would like to know how such cases are handled in big companies. Are there any better alternative? or better algorithm for such problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":418,"Q_Id":50264369,"Users Score":2,"Answer":"You don't have to take the old model down to start training a new model, so despite any training lags, or new-document bursts, you'll always have a live model doing the best it can.\nDepending on how much the document space changes over time, you might find retraining to have a negligible benefit. (One good model, built on a large historical record, might remain fine for inferring new vectors indefinitely.)\nNote that tuning inference to use more steps (especially for short documents), or a lower starting alpha (more like the training default of 0.025) may give better results. \nIf word-vectors are available, there is also the \"Word Mover's Distance\"  (WMD) calculation of document similarity, which might be ever better at identifying close duplicates. Note, though, it can be quite expensive to calculate \u2013 you might want to do it only against a subset of likely candidates, or have to add many parallel processors, to do it in bulk. There's another newer distance metric called 'soft cosine similarity' (available in recent gensim) that's somewhere between simple vector-to-vector cosine-similarity and full WMD in its complexity, that may be worth trying. \nTo the extent the vocabulary hasn't expanded, you can load an old Doc2Vec model, and continue to train() it \u2013 and starting from an already working model may help you achieve similar results with fewer passes. But note: it currently doesn't support learning any new words, and the safest practice is to re-train with a mix of all known examples interleaved. (If you only train on incremental new examples, the model may lose a balanced understanding of the older documents that aren't re-presented.)\n(If you chief concern is documents that duplicate exact runs-of-words, rather than just similar fuzzy topics, you might look at mixing-in other techniques, such as breaking a document into a bag-of-character-ngrams, or 'shingleprinting' as in common in plagiarism-detection applications.)","Q_Score":3,"Tags":"python,machine-learning,nlp,gensim,doc2vec","A_Id":50265639,"CreationDate":"2018-05-10T01:53:00.000","Title":"Document similarity in production environment","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run Apache Airflow's webserver from a virtualenv on a Redhat machine, with some configuration options from a Gunicorn config file. Gunicorn and Airflow are both installed in the virtualenv. The command airflow webserver starts Airflow's webserver and the Gunicorn server. The config file has options to make sure Gunicorn uses\/accepts TLSv1.2 only, as well as a list of ciphers to use. \nThe Gunicorn config file is gunicorn.py. This file is referenced through an environment variable GUNICORN_CMD_ARGS=\"--config=\/path\/to\/gunicorn.py ...\" in .bashrc. This variable also sets a couple of other variables in addition to --config. However, when I run the airflow webserver command, the options in GUNICORN_CMD_ARGS are never applied. \nSeeing as how Gunicorn is not called from command line, but instead by Airflow, I'm assuming this is why the GUNICORN_CMD_ARGS environment variable is not read, but I'm not sure and I'm new to both technologies...\nTL;DR:\nIs there another way to set up Gunicorn to automatically reference a config file, without the GUNICORN_CMD_ARGS environment variable? \nHere's what I'm using:\n\ngunicorn 19.8.1\napache-airflow 1.9.0\npython 2.7.5","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2243,"Q_Id":50264760,"Users Score":1,"Answer":"When Gunicorn is called by Airflow, it uses ~\\airflow\\www\\gunicorn_config.py as its config file.","Q_Score":1,"Tags":"python,virtualenv,config,gunicorn,airflow","A_Id":50646740,"CreationDate":"2018-05-10T02:52:00.000","Title":"Apache Airflow: Gunicorn Configuration File Not Being Read?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I recently imported .trc files and can't open them on my python terminal. Is there any way to do it? \nIf not, is there any way to convert .trc files into .csv?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":933,"Q_Id":50264879,"Users Score":0,"Answer":"Just an idea:\nCould it be that the .trc file is a record consisting of a header and a binary dump after the header?\nI have a USB scope that delivers the following:\n32 byte header (Instrument name+length of the record+length of the data field (body))\nbody:\nVariable length depending on numbers of samples. It is coded 1byte=1 ADC sample value.\n93 byte trailer:\nholding instrument setting (vertical gain, timescale, window shift (if the visible window is less than the total number of samples, offset).\nThe trailer is somehow binary coded but it looks a bit like an array of 32bit intergers and I didn't succeed to decypher it completely yet.\nI poked out the coding making test dumps with known changes and comparing them with dhex (a little linux hex comparing program).","Q_Score":1,"Tags":"python,file,csv,oscilloscope","A_Id":68942181,"CreationDate":"2018-05-10T03:08:00.000","Title":"How can I import .trc files in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Without considering an option to open a notepad first and saving it with the extension \".py\" , how to create a new \".py\" file in a corresponding directory using cmd ?\nNote : As a beginner python learner I request you to kindly ignore if this was a silly question ...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":50266364,"Users Score":0,"Answer":"on windows:\nC:\\Users\\username\\Desktop> echo \"the script\" > hello_world.py\nNote: replace the username with your actual user account.","Q_Score":1,"Tags":"python,python-3.x","A_Id":50266620,"CreationDate":"2018-05-10T05:55:00.000","Title":"How to create a new text document from scratch and save it as .py file using cmd?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm going to write a python script that copies some of the tables in a MySQL database from one remote machine(remote1) to another database on another remote machine(remote2) everyday.\nWhat's the most convenient way to do this?\nBecause the two tables are on different machines, the following MySQL command doesn't work.\n\nCREATE TABLE newtable LIKE oldtable; \nINSERT newtable SELECT * FROM oldtable;\n\nCurrently, my idea is:\n\nRead the table schema of srcTable on remote1. Create the table on remote2.\nRun SELECT * FROM theTable; on remote1. Save the result into a variable.\nRun INSERT INTO table_name (column1, column2, column3, ...)\nVALUES (value1, value2, value3, ...); on remote2 using the values in the variable.\n\nIs there any better solution which is simpler?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":50267306,"Users Score":0,"Answer":"single command for Export & Import:\n\/opt\/lampp\/bin\/mysqldump -u root -ppass bd_name table_name_optional | ssh root@192.168.3.252 \/opt\/lampp\/bin\/mysql -u root -ppass db_name\nTwo step: first export by below command:\n\/opt\/lampp\/bin\/mysqldump -u user-ppass db_name [table name separated by space  -optional] > \/opt\/db_backup\/db_name.sql\n\nsecond command for import:\n\/opt\/lampp\/bin\/mysql -u user-ppass db_name < \/opt\/db_backup\/db_name.sql\nHope help you.","Q_Score":0,"Tags":"python,mysql","A_Id":50267725,"CreationDate":"2018-05-10T06:59:00.000","Title":"Best way to copy mysql tables from a remote machine to another","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am from R background where we can use Plumber kind tool which provide visualization\/graph as Image via end points so we can integrate in our Java application.\nNow I want to integrate my Python\/Juypter visualization graph with my Java application but not sure how to host it and make it as endpoint. Right now I using AWS sagemaker to host Juypter notebook","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":75,"Q_Id":50271174,"Users Score":1,"Answer":"Amazon SageMaker is a set of different services for data scientists. You are using the notebook service that is used for developing ML models in an interactive way. The hosting service in SageMaker is creating an endpoint based on a trained model. You can call this endpoint with invoke-endpoint API call for real time inference. \nIt seems that you are looking for a different type of hosting that is more suitable for serving HTML media rich pages, and doesn\u2019t fit into the hosting model of SageMaker. A combination of EC2 instances, with pre-built AMI or installation scripts, Congnito for authentication, S3 and EBS for object and block storage, and similar building blocks should give you a scalable and cost effective solution.","Q_Score":0,"Tags":"python,amazon-sagemaker","A_Id":50300373,"CreationDate":"2018-05-10T10:48:00.000","Title":"How to make a Python Visualization as service | Integrate with website | specially sagemaker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using PyDotnet to expose a .Net library in Python. I've hit a snag where I need to call a generic method, but can't figure out the syntax or if it's simply not support.\ne.g.\npublic T DoSomething(T myData) { .... }\nHow would I call this from Python?\n\nUpdate:\nThat is the correct syntax, thanks. However, in my case I get an exception trying to call the method with the type. I'm not sure what I'm doing wrong. I'm using that syntax but am getting an exception.\nThe .NET method declaration looks like:\npublic T SpliceSeries(\n            T lowPriorityTimeSeries, \n            T highPriorityTimeSeries)\n        where T : UserScripting.TimeSeries\nIn python I'm calling it as follows:\nmyInstance.SpliceSeries[DerivedTimeSeriesType](myarg1, myarg2)\nNB where myarg1 & 2 are of type DerivedTimeSeriesType, which is .NET class derived from UserScripting.TimeSeries.\nThe exception is:\nException: System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception. at InteropPython.throw_invalid_cast(basic_string\\,std::allocator > ) at InteropPython.DynamicCallableInstance.Invoke(DynamicCallableInstance , object , tuple args)\nIs there anything I can do to debug this under the hood?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":109,"Q_Id":50271422,"Users Score":0,"Answer":"I'm not sure but I think generics are supported through [] syntax,\nDoSomething[T]","Q_Score":0,"Tags":"c#,python,generics","A_Id":50368810,"CreationDate":"2018-05-10T11:02:00.000","Title":"PyDotNet call generic method 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a reference image captured from a cc-camera and need to capture current image from the cc-camera to check if the camera is shifted or not at regular intervals. If shifted, the shift angle must also be needed. How can I achieve this using python?   Is the cv2.phaseCorrelate() function be helpful for this. Please give me some suggestions.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":352,"Q_Id":50273650,"Users Score":1,"Answer":"Use of hanning window will be more accurate for getting the phase values. Use phase correlate function with the window will give you a right phase shift.","Q_Score":1,"Tags":"python,opencv,image-processing,scipy,computer-vision","A_Id":50737007,"CreationDate":"2018-05-10T13:06:00.000","Title":"python: Find camera shift angle using a reference image and current image from the camera","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building REST API with Flask-restplus. One of my endpoints takes a file uploaded from client and run some analysis. The job uses up to 30 seconds. I don't want the job to block the main process. So the endpoint will return a response with 200 or 201 right away, the job can still be running. Results will be saved to database which will be retrieved later.\nIt seems I have two options for long-running jobs. \n\nThreading\nTask-queue\n\nThreading is relatively simpler. But problem is, there is a limit of thread numbers for Flask app. In a standalone Python app, I could use a queue for the threads. But this is REST api, each request call is independent. I don't know if there is a way to maintain a global queue for that. So if the requests exceed the thread limit, it won't be able to take more requests.\nTask-queue with Celery and Redis is probably better option. But this is just a proof of concept thing, and time line is kind of tight. Setting up Celery, Redis with Flask is not easy, I am having lots of trouble on my dev machine which is a Windows. It will be deployed on AWS which is kind of complex. \nI wonder if there is a third option for this case?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":15984,"Q_Id":50275646,"Users Score":2,"Answer":"Celery is a fantastic solution to this problem I have used quite successfully in the past to manage millions of jobs per day.\nThe only real downside is the initial learning curve and complexity of debugging when things go sour (it can happen, especially with millions of jobs).","Q_Score":14,"Tags":"python,multithreading,flask,queue,celery","A_Id":52320299,"CreationDate":"2018-05-10T14:46:00.000","Title":"How do I run background job in Flask without threading or task-queue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have to deal with python code on Windows, so I installed miniconda. The installer suggested not adding conda to the PATH, so I didn't. I have created an environment by using Anaconda Prompt conda create -n playground python=3.6 command, but now I am confused. If I activate the environment by using conda activate env it only activates in the Anaconda Prompt shell and not anywhere else. If I start a cmder or an editor, it cannot find python or conda or pip or anything python related. How do I use conda environments outside of the Anaconda Prompt?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4865,"Q_Id":50279022,"Users Score":0,"Answer":"You have to add conda into PATH. Otherwise, conda and environment switches with command conda are only available within \"Anaconda Prompt\".\nAfter adding conda in PATH, whic makes the command conda is available in every terminal, like cmd.exe, powershell.exe and \"Anaconda Prompt\".\n\"Anaconda Prompt\" could be deemed as a wrapper of cmd.exe that does conda activate base for you automatically.","Q_Score":1,"Tags":"python,conda,miniconda","A_Id":57985562,"CreationDate":"2018-05-10T18:09:00.000","Title":"How to activate an environment in miniconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to deal with python code on Windows, so I installed miniconda. The installer suggested not adding conda to the PATH, so I didn't. I have created an environment by using Anaconda Prompt conda create -n playground python=3.6 command, but now I am confused. If I activate the environment by using conda activate env it only activates in the Anaconda Prompt shell and not anywhere else. If I start a cmder or an editor, it cannot find python or conda or pip or anything python related. How do I use conda environments outside of the Anaconda Prompt?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":4865,"Q_Id":50279022,"Users Score":1,"Answer":"The simple answer is - you don't. The activation is literally just some changes to the environment variables, mainly PATH.\nWhen you need to use a conda environment in some other program, you have two options:\n\nIf the program doesn't know anything about Python, make sure that the program is started with the correct environment variables. E.g. just start it from within the shell with the activated conda environment.\nIf the program does know about Python (e.g. some IDE), just point it to the correct python executable within the desired conda environment.","Q_Score":1,"Tags":"python,conda,miniconda","A_Id":50279509,"CreationDate":"2018-05-10T18:09:00.000","Title":"How to activate an environment in miniconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to deal with python code on Windows, so I installed miniconda. The installer suggested not adding conda to the PATH, so I didn't. I have created an environment by using Anaconda Prompt conda create -n playground python=3.6 command, but now I am confused. If I activate the environment by using conda activate env it only activates in the Anaconda Prompt shell and not anywhere else. If I start a cmder or an editor, it cannot find python or conda or pip or anything python related. How do I use conda environments outside of the Anaconda Prompt?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4865,"Q_Id":50279022,"Users Score":0,"Answer":"How do I use conda environments outside of the Anaconda Prompt?\n\nNot sure if I get the \"outside of Anaconda Prompt\" correctly. But if you want to start the miniconda in say VScode's terminal, then the below method works for me.\nIf you don't want to add conda into PATH. The other way is to use the activation script in the miniconda folder to activate your venv.\n\nLook for your miniconda location.\nFor example, my miniconda is located in C:\\Users\\User\\miniconda3\nNavigate to ~\\miniconda3\\Scripts and copy the path of activate.bat\n(i.e, copy C:\\Users\\User\\miniconda3\\Scripts\\activate.bat)\nOpen a command prompt, paste, and execute the above bat file.\nYour miniconda should be activated, and you can use your conda command now.\n\nThis way you leave conda outside the PATH, but the downside is that you will need to do this everytime you want to activate your venv.","Q_Score":1,"Tags":"python,conda,miniconda","A_Id":71724324,"CreationDate":"2018-05-10T18:09:00.000","Title":"How to activate an environment in miniconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am clustering a number of molecules from Smiles files. I read them, convert them to mols and then convert them to Morgan Fingerprints, which I use to compute similarity and then clustering. \nHowever I would like to output the clustering result to a file. Ideally this is done in Smiles format such that it can then be read again for evaluation.\nHow can this be done please?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":819,"Q_Id":50281842,"Users Score":0,"Answer":"The only way I found was by getting the list Smiles, convert them to Mols and then to Fingerprints. The list of fingerprints and molecules are of the same size and order therefore \nFingerprints[0] == Mols[0] \nin terms of the molecule they are representing. Clustering fingerprints returns the index of the fingerprint in the list, thus the indexes may be used to retrieve the molecule from the Mol list. \nI do not think that it is the cleanest solution, but works.","Q_Score":1,"Tags":"python,rdkit","A_Id":50303668,"CreationDate":"2018-05-10T21:35:00.000","Title":"RDKit How to change from Fingerprint to Mol or Smiles","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I quickly switch between running tensorflow code with my CPU and my GPU?\nMy setup:\nOS = Windows 10\nPython = 3.5\nTensorflow-gpu = 1.0.0\nCUDA = 8.0.61\ncuDNN = 5.1\nI saw a post suggesting something about setting CUDA_VISIBLE_DEVICES=0 but I don't have this variable in my environment (not sure if it's because I'm running windows or what) but if I do set it using something like os.environ it doesn't effect how tensorflow runs code.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2716,"Q_Id":50282567,"Users Score":4,"Answer":"If you set the environment variable CUDA_VISIBLE_DEVICES=-1 you will use the CPU only. If you don't set that environment variable you will allocate memory to all GPUs but by default only use GPU 0. You can also set it to the specific GPU you want to use. CUDA_VISIBLE_DEVICES=0 will only use GPU 0. \nThis environment variable is created by the user, it won't exist until you create it. You need to set the variable before tensorflow is imported (usually that is before you start your script).","Q_Score":3,"Tags":"python-3.x,tensorflow","A_Id":50282794,"CreationDate":"2018-05-10T22:49:00.000","Title":"Tensorflow: switch between CPU and GPU [Windows 10]","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to get list of all created rooms in Django channels 2.x?\nI have checked documentation and there is no method which returns list of created rooms.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1312,"Q_Id":50282878,"Users Score":0,"Answer":"There isn't a built in way for Channels to get a list of groups but you can achieve this by adding\/removing group names to a model field with some logic in your consumer's connect() and disconnect() methods.","Q_Score":1,"Tags":"python,django","A_Id":50283013,"CreationDate":"2018-05-10T23:28:00.000","Title":"Get list of all rooms (Django channels 2)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working one file python project.\nI integrated google-cloud-API for realtime speech streaming and recognition.\nIt works with python aaa.py command well.\nNow I need windows build file(.exe), so I used pyinstaller program and I got aaa.exe file successfully.\nBut I got this error while running speech streaming by using Google cloud API.\n\n[Errno 2] No such file or directory:\n  'D:\\AI\\ai\\dist\\AAA\\google\\cloud\\gapic\\speech\\v1\\speech_client_config.json'\n\nSo I copied this speech_client_config.json file in needed path, after that I got below error again.\n\nException  in 'grpc._cython.cygrpc.ssl_roots_override_callback'\n  ignored E0511 01:13:14.320000000  3108\n  src\/core\/lib\/security\/security_connector\/security _connector.cc:1170]\n  assertion failed: pem_root_certs != nullptr\n\nThen, I can not find solution to get working version with google-cloud API.\nI am using python version 2.7.14\nI need your friendly help.\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":909,"Q_Id":50282890,"Users Score":4,"Answer":"I had the same problem. If you are willing to distribute roots.pem with your executable (just search for the file - it should be buried deep within the installation directory of grpcio), I had luck fixing this by setting GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment variable to the full path of this roots.pem file.","Q_Score":1,"Tags":"python,python-2.7,google-cloud-platform,pyinstaller","A_Id":53107197,"CreationDate":"2018-05-10T23:30:00.000","Title":"Got errors, while running exe file built with pyinstaller and Google Cloud API integration in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a virtualenv environment running python 3.5\nToday, when I booted up my MacBook, I found myself unable to install python packages for my Django project. I get the following error:\n\nCould not fetch URL <package URL>: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:646) - skipping\n\nI gather that TLS 1.0 has been discontinued, but from what I understand, newer versions of Python should be using TLS1.2, correct? Even outside of my environment, running pip3 trips the same error. I've updated to the latest version of Sierra and have updated Xcode as well. Does anyone know how to resolve this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":50284838,"Users Score":1,"Answer":"Here is the fix:\ncurl https:\/\/bootstrap.pypa.io\/get-pip.py | python\nExecute from within the appropriate virtual environment.","Q_Score":0,"Tags":"python,django,macos","A_Id":50379383,"CreationDate":"2018-05-11T04:04:00.000","Title":"Python - Enable TLS1.2 on OSX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using SVM for text classification (tf-idf score based classification).\nIs it possible to plot SVM having more than 100 attributes and 10 labels. Is there any way to reduce the features and then plot the same multiclass SVM.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":150,"Q_Id":50289947,"Users Score":1,"Answer":"For input data of higher dimensionality, I think that there is not a direct way to render a SVM. You should apply a dimensionality reduction, in order to have something to plot in 2-d or 3-d.","Q_Score":1,"Tags":"python,machine-learning,plot,svm,text-classification","A_Id":50290731,"CreationDate":"2018-05-11T10:08:00.000","Title":"Visualize a SVM model having100 attributes in 2D plot python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I issue this statement: db = cx_Oracle.connect(\"user\/pass@IP\/BKTDW\")\nand I get this error: \nTraceback (most recent call last):\n  File \"\", line 1, in \ncx_Oracle.DatabaseError: Error while trying to retrieve text for error ORA-01804\nIt seems that connect method doen't work at all. I have installed the Oracle Client and I am connecting normally via Toad or Sql Developer. \nPlease Help!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2921,"Q_Id":50295008,"Users Score":0,"Answer":"I had to set the ORACLE_HOME variable in the system variables and also add the bin directory in the PATH system variable. THNX","Q_Score":0,"Tags":"python,oracle,cx-oracle","A_Id":50345205,"CreationDate":"2018-05-11T14:53:00.000","Title":"Can't connect with cx_Oracle of Python to oracle remote database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I issue this statement: db = cx_Oracle.connect(\"user\/pass@IP\/BKTDW\")\nand I get this error: \nTraceback (most recent call last):\n  File \"\", line 1, in \ncx_Oracle.DatabaseError: Error while trying to retrieve text for error ORA-01804\nIt seems that connect method doen't work at all. I have installed the Oracle Client and I am connecting normally via Toad or Sql Developer. \nPlease Help!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2921,"Q_Id":50295008,"Users Score":0,"Answer":"Ensure that sqlplus is working from cmd line. It could be if on 64bit windows in has in PATH there is a target to non-64 bin version of oracle bin folder. In our case we ensured that 64bit location is placed in PATH . For instance place c:\\Oracle\\Ora11g_r2_x64\\bin\\  and remove c:\\Oracle\\ora11g_2\\bin\\, it was not related with ORACLE_HOME .","Q_Score":0,"Tags":"python,oracle,cx-oracle","A_Id":62171520,"CreationDate":"2018-05-11T14:53:00.000","Title":"Can't connect with cx_Oracle of Python to oracle remote database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a project where I need to switch between Python 2.7 and Python 3.6 occasionally. So I recently set up a Python 2.7 environment in Anaconda using the following command.\nconda create -n py27 python=2.7 anaconda\nBy default, Anaconda uses a Python 3.6 environment and Spyder (and the IPython console) had been working perfectly prior to the creation of the Python 2.7 environment. However, after creating the new environment, I can no longer use the IPython console in Spyder when I launch in the Python 3.6 environment (works fine for my new Python 2.7 environment) because for some reason it doesn't recognize the ipykernel and cloudpickle modules (even though I've checked and re-installed these modules for my Python 3.6 environment). Below is the error continue to get. \n\nAn error ocurred while starting the kernel Your Python environment or\n  installation doesn't have the ipykernel and cloudpickle modules\n  installed on it. Without these modules is not possible for Spyder to\n  create a console for you.\nYou can install them by running in a system terminal:\npip install ipykernel cloudpickle\nor\nconda install ipykernel cloudpickle\n\nIf anyone has any ideas how I can fix this, let me know. Thank you!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2080,"Q_Id":50295889,"Users Score":2,"Answer":"(Spyder maintainer here) The creation of kernels in external interpreters is semi-broken in our current version (Spyder 3.2.8). By this I mean that the process is very brittle (i.e. sometimes work and others don't, depending on your particular configuration).\nWe'll fix this in Spyder 3.3, to be released in June\/2018.","Q_Score":1,"Tags":"python,ipython,anaconda,spyder","A_Id":50301504,"CreationDate":"2018-05-11T15:47:00.000","Title":"Python 3.6 IPython console can't find ipykernel or cloudpickle after adding new conda environment for Python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an include statement with lots of variables being passed in.\nWas wondering if there was any way to make it multiline.\nEx:{% include 'foo.html' with img_src='bar.jpg' img_text='baz' %}\ninto {% include 'foo.html' with \nimg_src='bar.jpg' \nimg_text='baz' %}.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":352,"Q_Id":50295892,"Users Score":-1,"Answer":"I'm sorry but you can not do that. The idea is to obtain the template as clean as possible.\nIf the problem is just a visual problem, you can not do that. If the problem is that the code grows and is difficult to maintain and is not verbose, may be necessary to rethink the variables.\nIn the view you can implement get_context_data and send an dict with the src and text. You get now only one variable.","Q_Score":1,"Tags":"python,django","A_Id":50296716,"CreationDate":"2018-05-11T15:47:00.000","Title":"How to have a multi line statement in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using flask with WTForms to create online form. In this form I have a section where user has 10 dropdown menus (with same content; they need to rank items). I'd like to ensure that the same item is not selected multiple times. However, I can't find a way to do so. In WTForms there is a validator Equals() which checks if the field equals to another field, but no such validator to check if it does not equal. \nAny help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":50296012,"Users Score":0,"Answer":"You can write your own validator and use it as you wish.","Q_Score":0,"Tags":"python,flask-wtforms","A_Id":50296592,"CreationDate":"2018-05-11T15:54:00.000","Title":"Python Flask WTForms ensure uniqueness of a field","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Algo (Source: Elements of Programming Interviews, 5.16) \n\nYou are given n numbers as well as probabilities p0, p1,.., pn-1\n  which sum up to 1. Given a rand num generator that produces values in\n  [0,1] uniformly, how would you generate one of the n numbers according\n  to their specific probabilities.\n\nExample\n\nIf numbers are 3, 5, 7, 11, and the probabilities are 9\/18, 6\/18,\n  2\/18, 1\/18, then in 1000000 cals to the program, 3 should appear\n  500000 times, 7 should appear 111111 times, etc.\n\nThe book says to create intervals p0, p0 + p1, p0 + p1 + p2, etc so in the example above the intervals are [0.0, 5.0), [0.5, 0.0.8333), etc and combining these intervals into a sorted array of endpoints could look something like [1\/18, 3\/18, 9\/18, 18\/18]. Then run the random function generator, and find the smallest element that is larger than the generated element - the array index that it corresponds to maps to an index in the given n numbers.\nThis would require O(N) pre-processing time and then O(log N) to binary search for the value.\nI have an alternate solution that requires O(N) pre-processing time and O(1) execution time, and am wondering what may be wrong with it.\nWhy can't we iterate through each number in n, multiplying [n] * 100 * probability that matches with n. E.g [3] * (9\/18) * 100. Concatenate all these arrays to get, at the end, a list of 100 elements, with the number of elements for each mapping to how likely it is to occur. Then, run the random num function and index into the array, and return the value.\nWouldn't this be more efficient than the provided solution?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":556,"Q_Id":50296427,"Users Score":2,"Answer":"Your number 100 is not independent of the input; it depends on the given p values. Any parameter that depends on the magnitude of the input values is really exponential in the input size, meaning you are actually using exponential space. Just constructing that array would thus take exponential time, even if it was structured to allow constant lookup time after generating the random number.\nConsider two p values, 0.01 and 0.99. 100 values is sufficient to implement your scheme. Now consider 0.001 and 0.999. Now you need an array of 1,000 values to model the probability distribution. The amount of space grows with (I believe) the ratio of the largest p value and the smallest, not in the number of p values given.","Q_Score":1,"Tags":"python,arrays,algorithm","A_Id":50296509,"CreationDate":"2018-05-11T16:20:00.000","Title":"Generate non-uniform random numbers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Algo (Source: Elements of Programming Interviews, 5.16) \n\nYou are given n numbers as well as probabilities p0, p1,.., pn-1\n  which sum up to 1. Given a rand num generator that produces values in\n  [0,1] uniformly, how would you generate one of the n numbers according\n  to their specific probabilities.\n\nExample\n\nIf numbers are 3, 5, 7, 11, and the probabilities are 9\/18, 6\/18,\n  2\/18, 1\/18, then in 1000000 cals to the program, 3 should appear\n  500000 times, 7 should appear 111111 times, etc.\n\nThe book says to create intervals p0, p0 + p1, p0 + p1 + p2, etc so in the example above the intervals are [0.0, 5.0), [0.5, 0.0.8333), etc and combining these intervals into a sorted array of endpoints could look something like [1\/18, 3\/18, 9\/18, 18\/18]. Then run the random function generator, and find the smallest element that is larger than the generated element - the array index that it corresponds to maps to an index in the given n numbers.\nThis would require O(N) pre-processing time and then O(log N) to binary search for the value.\nI have an alternate solution that requires O(N) pre-processing time and O(1) execution time, and am wondering what may be wrong with it.\nWhy can't we iterate through each number in n, multiplying [n] * 100 * probability that matches with n. E.g [3] * (9\/18) * 100. Concatenate all these arrays to get, at the end, a list of 100 elements, with the number of elements for each mapping to how likely it is to occur. Then, run the random num function and index into the array, and return the value.\nWouldn't this be more efficient than the provided solution?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":556,"Q_Id":50296427,"Users Score":2,"Answer":"If you have rational probabilities, you can make that work.  Rather than 100, you must use a common denominator of the rational proportions.  Insisting on 100 items will not fulfill the specs of your assigned example, let alone more diabolical ones.","Q_Score":1,"Tags":"python,arrays,algorithm","A_Id":50296535,"CreationDate":"2018-05-11T16:20:00.000","Title":"Generate non-uniform random numbers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I clustered a data set using sklearn's K-means. \nI can see the centroids easily using KMeans.cluster_centers_ but I need to get the clusters as I get centroids.\nHow can I do that?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":5157,"Q_Id":50297142,"Users Score":2,"Answer":"You probably look for the attribute labels_.","Q_Score":2,"Tags":"python-3.x,scikit-learn,k-means,data-science","A_Id":50298062,"CreationDate":"2018-05-11T17:11:00.000","Title":"Get cluster points after KMeans in a list format","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This question specifically aims for a Django 2.0 answer as the registration module isn't available (yet) for it.\nMore, this might seem to broad, but I often found myself in situations where I can't use any 3rd party module because ... oh well..policies. I'm sure many did. And I know that looking and putting together information taken from here or django docs was a headache.\n\nWorkflow:\nLet's suppose we need the following flow:\n\nThe user goes to the sign-up page and fills in the following fields: first_name, last_name and email (the email will be used as the username).\nThe user submits the form and receives a confirmation email with an URL containing a unique token.\nWhen the user clicks on the received link, he's redirected to a page where he'll set his password. When done, he's logged in to the dashboard page.\n\nExtra-info: The user will later log in by using his email (which is actually his username) and password.\n\nSpecific question:\n\nHow will the models\/views (using CBVs)\/forms\/urls look like?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":14138,"Q_Id":50298114,"Users Score":2,"Answer":"In addition to Peter's answer, if you are using Django 2 then the encoding and decoding parts are a bit differents.\nEncoding :\nChange 'uid': urlsafe_base64_encode(force_bytes(user.pk)),\nTo 'uid': urlsafe_base64_encode(force_bytes(user.pk)).decode(),\nDecoding :\nChange uid = force_text(urlsafe_base64_decode(uidb64))\nTo uid = urlsafe_base64_decode(uidb64).decode()\nDjango 3 Edit :\nEncoding : uid = urlsafe_base64_encode(force_bytes(user.pk))\nDecoding : uid = urlsafe_base64_decode(uidb64).decode()","Q_Score":21,"Tags":"python,django,authentication","A_Id":53433216,"CreationDate":"2018-05-11T18:20:00.000","Title":"Django 2 - How to register a user using email confirmation and CBVs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"As a newbie to scons, I'm faced with converting a project with multiple modules in the one repo with a common top-level build.\nEach module already has a SConstruct file - to allow building them on their own.\nReading on hierarchical scons setup, I see the idea is to use a top-level SConstruct which loads the sub-projects' build files using SConscript() function, and that those files are\/should be called SConscript.\nI find the rest of the info somewhat vague (or maybe TLDR?) - so \n\nwondering is that a requirement for those lower-level scripts to be\nSConscript files? \nIOW, is there a semantic\/scope\/evaluation\ndifference between SConscripts and SConstructs apart from one\nintended as an entry point, whereas the other one just a \"sub-build\nfile\"?   \nIs there any point in refactoring those sub-project's SConstructs to\nbe one liners to call a SConscript in the same level +\nchaining these up to the top level Sconstruct?\n\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2437,"Q_Id":50298132,"Users Score":2,"Answer":"Answer to your questions in order\n\nNo the lower level files can be called anything, as you specify the path and filename in the SConscript() call\nEach SConscript is evaluated in it's own scope. You can pass via Export() (or SConscripts exports= argument) and bring into the SConscript (whatever you end up calling it) via Import().\nEntirely depends if you want to do any central\/top level configuration to be propagated to your sub projects.  This could still be done via Import() statements in the subproject's SConstruct and then checking if the variable you expect to have imported is defined (via try\/except perhaps)\n\nThis sub project has SConstructs has been done before.  Likely it's cleaner to use Import() in your SConstructs in your sub project and then verify that whatever you expect to have passed is there or not before using it.  Wrapping that with copious comments as to why you are doing so if the sub projects are also used standalone..\nDoes this answer your question?","Q_Score":3,"Tags":"python,scons","A_Id":50311623,"CreationDate":"2018-05-11T18:21:00.000","Title":"difference between SConscript and SConstruct files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on a project that would allow me to serve a web page to multiple local devices and use each client as controls for Pygame input. I am having trouble finding out if I can even pass data in-between the two (Pygame and flask) let alone having them run side by side using something like async. (Please note i am just getting started digging into python programming). I was thinking of two ways that this could happen if it is possible to have them communicate.. \n1) Use flask to pass the data to Pygame.\n2) Use something like Brython to run python localy on the device via browser and connect them using sockets.\nIs it possible or is this just a pipe dream?\nThanks,","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":154,"Q_Id":50299695,"Users Score":0,"Answer":"This is not possible.\nPyGame is intended for rendering graphics on the computer running the Python binary, while Flask is intended to generate HTML to be sent to a remote computer. The only way to interact with a remote user through a browser is through HTML and JavaScript.\nMoreover, this there is no way to interface PyGame with HTML\/JS because PyGame's method of accessing the local screen, keyboard and mouse is very different from HTML's method of interacting with the user. To give just one major obstacle, PyGame's fundamental mode of operation is to block the UI thread until an event (such as a mouse click) occurs, using the function pygame.event.wait(). In HTML, by contrast, this is not allowed, and you are expected instead to register handlers for events such as mouse clicks.","Q_Score":1,"Tags":"python,html,asynchronous,flask,pygame","A_Id":64150040,"CreationDate":"2018-05-11T20:18:00.000","Title":"Using python generated web page as input for Pygame controls","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I installed python3 to my my late 2014 iMac through brew.sh and my terminal is still defaulting to an older version of python unless I specifically prompt it with the command python3.  Is there any way I can fix this so that the terminal just automatically defaults to python3, without me having to type in python3 every single time?  I really need to run django, and the fact that my system is still defaulting to python 2.7 is really getting in the way.  Is there perhaps any way I can uninstall the older version of python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14,"Q_Id":50299956,"Users Score":0,"Answer":"Yes, you should set up virtual environments for python 2.7.13 and python 3.6. when you want to run python2, just activate the python 2 environments. Same for python3.\nIf you installed python using Anaconda, there are instructions in the Anaconda documentation for creating virtual environments.\nIf you did not use Anaconda, you can find instructions for creating virtual environments by googling on 'virtual environment python' and there are many hits.\nI would advise against deleting any version of python. Macs come with a version of python installed that it uses and should not be removed.","Q_Score":0,"Tags":"python-3.x,macos,installation","A_Id":50302596,"CreationDate":"2018-05-11T20:39:00.000","Title":"Python 3 installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"Basically, it is a multi-threaded crawler program, which uses requests mainly. After running the program for a few hours, I keep getting the error \"Too many open files\".\nBy running: lsof -p pid, I saw a huge number of entries like below:\npython  75452 xxx 396u  a_inode    0,11        0    8121 [eventpoll]\nI cannot figure out what it is and how to trace back to the problem.\nPreviously, I tried to have it running in Windows and never seen this error.\nAny idea how to continue investigating this issue? thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":528,"Q_Id":50300407,"Users Score":0,"Answer":"I have figured out that it is caused by Gevent. After replacing gevent with multi-thread, everything is just OK. \nHowever, I still don't know what's wrong with gevent, which keeps opening new files(eventpoll).","Q_Score":0,"Tags":"python,ubuntu,memory-leaks,python-requests","A_Id":50348191,"CreationDate":"2018-05-11T21:19:00.000","Title":"python Ubuntu: too many open files [eventpoll]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've recently started freelance python programming, and was hired to write a script that scraped certain info online (nothing nefarious, just checking how often keywords appear in search results).\nI wrote this script with Selenium, and now that it's done, I'm not quite sure how to prepare it to run on the client's machine. \nSelenium requires a path to your chromedriver file. Am I just going to have to compile the py file as an exe and accept the path to his chromedriver as an argument, then show him how to download chromedriver and how to write the path?\nEDIT: Just actually had a thought while typing this out. Would it work if I sent the client a folder including a chromedriver.exe inside of said folder, so the path was always consistent?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":582,"Q_Id":50301263,"Users Score":0,"Answer":"Option 1)  Deliver a Docker image if customer not to watch the browser during running and they can setup Docker environment. The Docker image should includes following items:\n\nPython\nDependencies for running your script, like selenium\nHeadless chrome browser and compatible chrome webdriver binary\nYour script, put them in github and\nfetch them when start docker container, so that customer can always get\nyour latest code\n\nThis approach's benefit: \n\nYou only need to focus on scripts like bug fix and improvement after delivery \nCustomer only need to execute same docker command\n\nOption 2) Deliver a Shell script to do most staff automatically. It should accomplish following items: \n\nInstall Python (Or leave it for customer to complete)\nInstall Selenium library and others needed\nInstall latest chrome webdriver binary (which is compatible backward)\nFetch your script from code repo like github, or simply deliver as packaged folder\nRun your script.\n\nOption 3) Deliver your script and an user guide, customer have to do many staff by self. You can supply a config file along with your script for customer to specify the chrome driver binary path after they download.  Your script read the path from this file, better than enter it in cmd line every time.","Q_Score":0,"Tags":"python,selenium","A_Id":50301550,"CreationDate":"2018-05-11T22:56:00.000","Title":"How to prepare Python Selenium project to be used on client's machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use python to manage my company's Active Directory.\nbut it was establish without ssl certificate.\ni use the python lib \"ldap3\"\nuse the function \"extend.microsoft.modify_password()\"\nthis raise an expection \"unwillingToPerform\"","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":50304365,"Users Score":0,"Answer":"I don't know Python, but I know Active Directory. Whenever I've seen an \"unwilling to perform\" error, it usually means you're doing something wrong. Either your giving it the wrong (or malformed) distinguished name, or you're giving it the wrong old password. Maybe something else. If you show your code we might be able to help more.","Q_Score":0,"Tags":"python,active-directory,ldap","A_Id":50321803,"CreationDate":"2018-05-12T08:40:00.000","Title":"How to use python to update Microsoft Active Directory password without ssl certificate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use python to manage my company's Active Directory.\nbut it was establish without ssl certificate.\ni use the python lib \"ldap3\"\nuse the function \"extend.microsoft.modify_password()\"\nthis raise an expection \"unwillingToPerform\"","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":50304365,"Users Score":0,"Answer":"You need a TLS secured connection for changing passwords via LDAP. It cannot be done with a cleartext connection.","Q_Score":0,"Tags":"python,active-directory,ldap","A_Id":50422772,"CreationDate":"2018-05-12T08:40:00.000","Title":"How to use python to update Microsoft Active Directory password without ssl certificate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The default version of python installed on my mac is python 2. I also have python 3 installed but can't install python 2.\nI'd like to configure Hyrdrogen on Atom to run my script using python 3 instead.\nDoes anybody know how to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4266,"Q_Id":50304519,"Users Score":0,"Answer":"I used jupyter kernelspec list and I found 2 kernels available, one for python2 and another for python3\nSo I pasted python3 kernel folder in the same directory where python2 ken=rnel is installed and removed python2 kernel using 'rm -rf python2'","Q_Score":3,"Tags":"python,python-3.x,jupyter,atom-editor,hydrogen","A_Id":56453522,"CreationDate":"2018-05-12T09:01:00.000","Title":"Using Hydrogen with Python 3","Data Science and Machine Learning":0,"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 Ubuntu 16.04 . Where is the python 3 installation directory ?\nRunning \"whereis python3\" in terminal gives me:\n\npython3: \/usr\/bin\/python3.5m-config  \/usr\/bin\/python3 \n  \/usr\/bin\/python3.5m \/usr\/bin\/python3.5-config  \/usr\/bin\/python3.5 \n  \/usr\/lib\/python3  \/usr\/lib\/python3.5  \/etc\/python3  \/etc\/python3.5\n  \/usr\/local\/lib\/python3.5   \/usr\/include\/python3.5m \n  \/usr\/include\/python3.5  \/usr\/share\/python3 \n  \/usr\/share\/man\/man1\/python3.1.gz\n\nAlso where is the intrepreter i.e the python 3 executable ? And how would I add this path to Pycharm ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10136,"Q_Id":50304901,"Users Score":5,"Answer":"you can try this :\nwhich python3","Q_Score":3,"Tags":"python,python-3.x","A_Id":50304923,"CreationDate":"2018-05-12T09:48:00.000","Title":"Python 3 install location","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have trained a model successfully and now I want to continue training it with new data. If a given data with the same amount of classes it works fine. But having more data then initially it will give me the error:\n\nValueError: Shapes (?, 14) and (?, 21) are not compatible\n\nHow can I dynamically increase the number of classes in my trained model or how to make the model accept a lesser number of classes? Do I need to save the classes in a pickle file?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":50305294,"Users Score":0,"Answer":"Best thing to do is to train your network from scratch with the output layers adjusted to the new output class size.\nIf retraining is an issue, then keep the trained network as it is and only drop the last layer. Add a new layer with the proper output size, initialized to random weights and then fine-tune (train) the entire network.","Q_Score":1,"Tags":"python-3.x,tensorflow,machine-learning,rnn","A_Id":50305713,"CreationDate":"2018-05-12T10:36:00.000","Title":"How to continue to train a model with new classes and data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python program which features a C++ core python wrapped. It's written in parallel as it is computationally very expensive and I'm currently making it run on a server in remote on a Ubuntu 16.04 platform.\nThe problem I'm experiencing is that, at a certain number of cycles (let's say 2000) for my test case, it freezes abruptly without giving error messages or anything. I detected the part of the code where it stops and is a python function which doesn't feature any for cycle (so I assume it's not stuck into a loop). I tried to simply comment the function where it gets stuck out of the code, as it does minor calculations and now, at the exact same number of cycles, it gets stuck a little bit ahead, this time inside the C++ written part. I'm starting to assume that a possibility is some memory problem related to the server. \nDoing htop from terminal when the code is stuck I can see the units involved in the computation are fully loaded as they are currently involved in some unknown calculations. Moreover, the memory involved in the process (at least when the process is already stuck) is not fully occupied so it may not be a RAM problem neither. \nI also tried to reduce drastically the number of output written at every cycle (which, I admit, where consistent in size) but nothing. With the optimum number of processors it takes like 20 minutes to get to the critical point of 2000 cycles so the problem is not easy reproducible.\nIt is the first time I'm experiencing these sort of problems, Is there anything else I can do to highlight the issue?\nThanks for the answer","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":50307008,"Users Score":1,"Answer":"Here is something you could try.\nWrite a code which checks which iterations is taking place and store all the variables at the start of the 2000th iteration.\nThen use the same variable set to run the iteration again. \nIt won't solve your problem, but it will help in reducing the testing time, and consequently the time it takes for you to find the problem.\nIf it is definitely a memory issue, the code will not get stuck at 2000 (That's where you start) but will get stuck at 4000.\nThen you can monitor memory at 2000th iteration and replicate that.","Q_Score":0,"Tags":"python,c++,memory,server,freeze","A_Id":50307173,"CreationDate":"2018-05-12T13:58:00.000","Title":"Parallel Python-C++ program freezes (memory?)","Data 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 work with the object detection api by tensorflow but was unable to install that properly. I looked up every solution in the internet and everything was in vain. Below is the error message I am getting: \n\n\u201cC:\\Program Files\\protoc-3.5.0-win32\\bin\\protoc.exe\u201d object_detection\/protos\/*.proto --python_out=.\nobject_detection\/protos\/*.proto: No such file or directory","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":353,"Q_Id":50307347,"Users Score":0,"Answer":"Currently you are in which directory?\nYou can set the Path variable to point to protoc.exe and run the command from object detection directory","Q_Score":0,"Tags":"python,tensorflow,object-detection,protoc","A_Id":50632788,"CreationDate":"2018-05-12T14:33:00.000","Title":"protoc executable unable to find object detection .protos file in tensorflow models","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python3 script that reads non ascii text files, makes modifications and writes them back. I can launch that script from Atom with Package\u2192Script\u2192Run Script menu command and python3 complains that input text files are not Ascii:\nUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 37: ordinal not in range(128)\nBut when I copy the very command used by Atom (the first line in the output pane) into the terminal, then everything works as expected and all the files are processed correctly.\nHow can I tell Atom to not restrict python3 to ascii?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":435,"Q_Id":50308426,"Users Score":1,"Answer":"The problem is that when launched from Atom's script package, python does not inherit the system context.\nOne solution is to create a profile from menu Packages\u2192Script\u2192Configure script for which the environment variable field reads for example LANG=fr_FR.UTF-8, what is important is the UTF-8 part.","Q_Score":0,"Tags":"python-3.x,atom-editor,non-ascii-characters","A_Id":50313900,"CreationDate":"2018-05-12T16:30:00.000","Title":"configure python3 in Atom for non ascii 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":0},{"Question":"Moving an image to an array then flattening it and shuffling with given x seed it should be easy to unshuffle it with the given seed and indexes from the shuffling process.\n\nread image IMG.jpg\nrandom.seed(x) and shuffle -> indexes, shuffle_img.jpg\n\n\nunshuffle\n\n\nHowever, this RESULT shows that the resulting IMG is simmilar but not 1:1 as the input image with this grain noise. \nWhy the unshuffling gives so much noise if it is not the RNG, only PRNG?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":287,"Q_Id":50308623,"Users Score":2,"Answer":"This has nothing to do with your random numbers.\nNotice that you use the random number generator only once when you create the shuffled indices. When you load the indices from the file, the random number generator is not used, since only a file is read.\nYour issue occurs at a different place: You save the scrambled Lena as a .jpg. Thereby, poor Lena's scrambled image gets compressed and the colour values change a little bit. When you load the image again and reorder the indices, you do not get the original colours back but only the values after the compression.\nSolution: Save your images as a *.png and everything works out.\nIf you run into problems with an alpha channel, just convert the image back to RGB: scrambled_img = Image.open(img_path).convert(\"RGB\")","Q_Score":0,"Tags":"python,numpy,random,pillow","A_Id":50309756,"CreationDate":"2018-05-12T16:54:00.000","Title":"How to revert shuffled array in python with default PRNG and indexes?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm implementing a custom sklearn Transformer, which requires an optimization step which has been coded in Tensorflow. TF requires a Session, which should be used as a context manager or explicitly closed. The question is: adding a close() method to the Transformer would be odd (and unexpected for a user), what is the best place to close the session? Should I open and close a new session for a every call to fit()? Or should I keep it open and leave the session.close() to the __del__ method of the transformer? Any other options?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":143,"Q_Id":50310515,"Users Score":1,"Answer":"Don't open a session at each function call, that could be very inefficient if the function is called many times.\nIf for some reason, you don't want to expose a context manager, then you need to open the session yourself, and leave it open. It is perhaps a bit simpler for the user, but sharing the tf.Session with other objects or libraries might be more difficult. Also trying to hide the fact that you are using tensorflow may be a bit vain, as it is potentially incompatible with other libraries also relying on the GPU. (Also the user will need to install tensorflow to use the library, s\/he will definitely know that you are using it).\nSo I would not try to encapsulate things that can't or shouldn't (in my opinion) and use a context manager for the tf.Session (maybe even using directly a tf.Session itself if I don't mind exposing tensorflow, otherwise wrapping it in my own context manager).","Q_Score":1,"Tags":"python,tensorflow,scikit-learn","A_Id":50333204,"CreationDate":"2018-05-12T20:43:00.000","Title":"How to efficiently use a Session from within a python object to keep tensorflow as an implementation detail?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For example are 4 space characters equivalent to 1 tab character for new line indents? \nOr will it only scan for just one and not the other?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":142,"Q_Id":50311985,"Users Score":2,"Answer":"Python 3.x (and Python 2.x when passed -tt) will refuse to run code with mixed tabulation.\nPython 2.x without -tt will run code with mixed tabulation, and consider a tab to be equivalent to a run of 8 spaces.\n(And Python 2.x with -t will run it, but complain.)","Q_Score":0,"Tags":"python","A_Id":50311998,"CreationDate":"2018-05-13T01:31:00.000","Title":"Does the Python interpreter check indents to be space or tab characters?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If there is chinese in .py document , it needs to add #coding=utf-8 and #coding=gbk. But what is the difference between #coding=utf-8 and #coding=gbk in python?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":824,"Q_Id":50313731,"Users Score":1,"Answer":"The coding comment declares the encoding of the source file itself. If you save the source file in UTF-8 encoding, use #coding=utf8. If you save the source file in GBK encoding, use #coding=gbk.","Q_Score":0,"Tags":"python,unicode,encode","A_Id":50321482,"CreationDate":"2018-05-13T07:25:00.000","Title":"difference between #coding=utf-8 and #coding=gbk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If there is chinese in .py document , it needs to add #coding=utf-8 and #coding=gbk. But what is the difference between #coding=utf-8 and #coding=gbk in python?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":824,"Q_Id":50313731,"Users Score":0,"Answer":"If you have Unicode characters in your source code, you promise that they will be encoded with the encoding you specify in the # coding line.\nE.g. character \u4e07 will be encoded completely differently in UTF-8 and GBK.\nASCII characters will be encoded the same as ASCII in either case.","Q_Score":0,"Tags":"python,unicode,encode","A_Id":50321890,"CreationDate":"2018-05-13T07:25:00.000","Title":"difference between #coding=utf-8 and #coding=gbk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The stack size limit on python application on my system is \nlimit\nstacksize    40960 kbytes.\nIf threading.stack_size() is used to set the thread stack size to a value higher than 40960KB, will the stack size allocated to python application increase automatically?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":197,"Q_Id":50313960,"Users Score":1,"Answer":"threading.stack_size sets or retrieves the stack size allocated for new threads. It cannot resize the stack for existing threads.\nIf your system has a default stack size of 40960 KB, that doesn't matter. threading.stack_size will override the default. That's the point.\nIf your system has a hard cap of 40960 KB for stack sizes, threading.stack_size will raise a ValueError on attempts to set a bigger stack size than that.","Q_Score":0,"Tags":"python","A_Id":50314029,"CreationDate":"2018-05-13T07:54:00.000","Title":"What happens if threading.stack_size() is used to set stack size beyond the allocated stack size for python application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The official Python documentation explains ord(c) \n\nord(c):\n  Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. For example, ord('a') returns the integer 97 and ord('\u20ac') (Euro sign) returns 8364. This is the inverse of chr().\n\nIt does not specify the meaning of ord, google searches are not helpful.\nWhat's the origin of it?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":7187,"Q_Id":50314440,"Users Score":4,"Answer":"Return the integer ordinal of a one-character string.\nI took this from ord.doc in python command line. ord meaning ordinal of a one character.","Q_Score":26,"Tags":"python,unicode,built-in,ordinal,ord","A_Id":57918743,"CreationDate":"2018-05-13T08:58:00.000","Title":"What does the name of the ord() function stand for?","Data 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":"Apparently if you add any parse action and return a result in that action, the result will always be encapsulated into a list 'deepening' the output tree.\nI suppose this is for returning multiple values but it makes casual use of the library far harder because you then have to remember which parts of the tree you replaced and call result.normalstruct.replaced[0] (or even worse result.normalstruct['replaced'][0])\nThis is a bit strange and makes refactoring harder, so i'd like a way to avoid it. Any tips?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":39,"Q_Id":50315596,"Users Score":1,"Answer":"The problem here is that the argument token of setParseAction is already a list. Instead of operating on str(token_argument) i should operate on str(token_argument[0]) and return that. No more deepening.\nedit: though apparently it doesn't happen always. Happened to me with a word action but when i tried to 'unwrap' element zero of a 'And' expression result from a setParseAction functor it gave me the first subexpression.\nMan, i'd like consistency here.","Q_Score":1,"Tags":"python-3.x,pyparsing","A_Id":50316016,"CreationDate":"2018-05-13T11:24:00.000","Title":"Pyparsing will always insert a list on 'setParseAction'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make access from remote ubuntu server to local machine because I have multiple files in this machine and I want to transfer it periodically (every minute) to server how can I do that using python","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":312,"Q_Id":50315821,"Users Score":0,"Answer":"You can easily transfer files between local and remote or between two remote servers. If both servers are Linux-based and require to transfer multiple files and folder using single command, however, you need to follow up below steps:\n\nUser from one remote server should have access to another remote server to corresponding directory you want to transfer the file.\n\nYou might need to create a policy or group and assign to server list to that group\nwhich you want to access and assign the user to that group so 2 different remote\nserver can talk to each other.\n\nRun the following scp command:-\n\n\n  scp [options] username1@source_host:directory1\/filename1 \n  username2@destination_host:directory2\/filename2","Q_Score":0,"Tags":"python","A_Id":68788882,"CreationDate":"2018-05-13T11:51:00.000","Title":"transfer files between local machine and remote server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've been trying to install Peter Chervenski's MultiNEAT and ran into a problem while running setup.py (python setup.py build_ext):\n\nFile \"c:\/Users\/1234\/Documents\/Alex\/multineat\/peter-ch-MultiNEAT-f631e2f\/setup.py\", line 7, in \n      from site-packages import psutil'\n\nAnd I made sure this module is installed: used pip install a couple of times and it said: \n\nRequirement already satisfied: psutil in\n  c:\\users\\1234\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\n\nAnd I checked this directory myself and found psutil module there (I even deleted it and reinstalled one more time). And after that, I still got the same error with Python not seeing psutil. Is there any way I can solve this problem? (I am using Windows 10, latest version of Python)","AnswerCount":9,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":117101,"Q_Id":50316358,"Users Score":0,"Answer":"Inconsistencies can happen if you have multiple versions of windows installed on your system. Check for the default python directory path and make sure 'psutils' is updated in that directory.","Q_Score":17,"Tags":"python,psutil","A_Id":64841817,"CreationDate":"2018-05-13T12:56:00.000","Title":"Error : No module named 'psutil'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been trying to install Peter Chervenski's MultiNEAT and ran into a problem while running setup.py (python setup.py build_ext):\n\nFile \"c:\/Users\/1234\/Documents\/Alex\/multineat\/peter-ch-MultiNEAT-f631e2f\/setup.py\", line 7, in \n      from site-packages import psutil'\n\nAnd I made sure this module is installed: used pip install a couple of times and it said: \n\nRequirement already satisfied: psutil in\n  c:\\users\\1234\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\n\nAnd I checked this directory myself and found psutil module there (I even deleted it and reinstalled one more time). And after that, I still got the same error with Python not seeing psutil. Is there any way I can solve this problem? (I am using Windows 10, latest version of Python)","AnswerCount":9,"Available Count":4,"Score":0.022218565,"is_accepted":false,"ViewCount":117101,"Q_Id":50316358,"Users Score":1,"Answer":"I had that problem trust me this works 100%. I am using VS Code you just have to install it with pip normally but sometimes it doesn't add it to your working directories (venv\\lib\\site-packages\\) folder your editor is using. So just copy and paste it there from here C:\\Users\\(your username)\\AppData\\Roaming\\Python\\Python39\\site-packages","Q_Score":17,"Tags":"python,psutil","A_Id":65511665,"CreationDate":"2018-05-13T12:56:00.000","Title":"Error : No module named 'psutil'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been trying to install Peter Chervenski's MultiNEAT and ran into a problem while running setup.py (python setup.py build_ext):\n\nFile \"c:\/Users\/1234\/Documents\/Alex\/multineat\/peter-ch-MultiNEAT-f631e2f\/setup.py\", line 7, in \n      from site-packages import psutil'\n\nAnd I made sure this module is installed: used pip install a couple of times and it said: \n\nRequirement already satisfied: psutil in\n  c:\\users\\1234\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\n\nAnd I checked this directory myself and found psutil module there (I even deleted it and reinstalled one more time). And after that, I still got the same error with Python not seeing psutil. Is there any way I can solve this problem? (I am using Windows 10, latest version of Python)","AnswerCount":9,"Available Count":4,"Score":0.022218565,"is_accepted":false,"ViewCount":117101,"Q_Id":50316358,"Users Score":1,"Answer":"I resolved this issue as below:\nIt seems, every time i was trying to upgrade psutil using \"pip install psutil\" it just showing the requirement is satisfied and showing 5.7.2.\n\nGo to the folder where Python is install and psutil is available e.g.\n\"C:\\Python\\Lib\\site-packages\"\nfind all psutil related filesand rename them to something else e.g.\nOld__psutil\nOld_psutil-5.7.2.dist-info\nRun \"pip install psutil\" from bash or command line\nIt updated for me to 5.8.0\n\nThis resolved my issue.","Q_Score":17,"Tags":"python,psutil","A_Id":66896082,"CreationDate":"2018-05-13T12:56:00.000","Title":"Error : No module named 'psutil'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been trying to install Peter Chervenski's MultiNEAT and ran into a problem while running setup.py (python setup.py build_ext):\n\nFile \"c:\/Users\/1234\/Documents\/Alex\/multineat\/peter-ch-MultiNEAT-f631e2f\/setup.py\", line 7, in \n      from site-packages import psutil'\n\nAnd I made sure this module is installed: used pip install a couple of times and it said: \n\nRequirement already satisfied: psutil in\n  c:\\users\\1234\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\n\nAnd I checked this directory myself and found psutil module there (I even deleted it and reinstalled one more time). And after that, I still got the same error with Python not seeing psutil. Is there any way I can solve this problem? (I am using Windows 10, latest version of Python)","AnswerCount":9,"Available Count":4,"Score":0.0886555158,"is_accepted":false,"ViewCount":117101,"Q_Id":50316358,"Users Score":4,"Answer":"I solved a problem and if you had a similar problem you should try this: \n\nupgrade pip to the latest version (python -m pip install --upgrade pip) \ndelete psutil (C:\\Users\\(your username)\\AppData\\Local\\Programs\\Python\\Python36-32\\Lib\\site-packages) if \nyou have it installed already \nreupload psutilnow using pip install psutil\n\n. It helped me and if you have a permission error, try opening cmd as administrator.","Q_Score":17,"Tags":"python,psutil","A_Id":50318834,"CreationDate":"2018-05-13T12:56:00.000","Title":"Error : No module named 'psutil'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python Markdown is a very nice extension for the jupyter notebook, which is in turn great for literate programming, i.e. mixing text and code.\nPython Markdown makes it possible to include short inline code in Markdown cells in Jupyter like in the following example:\nPython cell: a = 3.1415\nMarkdown cell: The value of a was {{a}}.\nEverything works fine in the browser interface, but when I export it to LaTeX (or PDF via LaTeX), the output will still contain {{a}} as an unevaluated expression.\nIt would of course be really helpful to have the evaluated expression in the output for generating reports.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1227,"Q_Id":50316719,"Users Score":1,"Answer":"The solution was actually rather trivial:\nWhen enabling a certain option on the command line, this will create an entry in the web interface irrespective of this option actually exists.\nI had mispelled Python Markdown with python-markdown and ended up with this second entry in the web interface.\nEnabling the first entry fixed the problem.\nThe second entry could be savely removed.","Q_Score":3,"Tags":"python,latex,jupyter-notebook,jupyter,pandoc","A_Id":50336200,"CreationDate":"2018-05-13T13:37:00.000","Title":"Jupyter Python Markdown: Evaluated Inline code in LaTeX output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently writing an application in python that mainly works with files. So the algorithm works like this:\nA user submits a file through an API, imagine a post request with the file and some data.\nThen the program works with the file and extracts some conclusions.\nAfter that, those conclusions are stored inside a DB.\nThen the user is able to query the db and ask for conclusions.\nAs the user is able to submit a file through an API and this can be done simultaneously by many users in many systems and the process of file processing may take some time. I want to explore a way to implement a work queue such as:\nOnly one file can be processed at a time, so when a user submits a file, that file is put inside a work queue and so has to wait before getting inside the \"processing function\".\nHow can I do that, any reference or tutorial?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":300,"Q_Id":50318604,"Users Score":1,"Answer":"Checkout Celery, there are many good tutorials online.\nIt works with workers so it also doesn't block you api listening.\nAlso it could provide the option to process multiple files at once concurently if you'd want.","Q_Score":0,"Tags":"python,queue","A_Id":50318631,"CreationDate":"2018-05-13T17:08:00.000","Title":"How to work with queues for file processing in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I hope this is not too opinionated because I'm looking for a finite answer.\nI'm developing a UDP server in Python 3.x that is utilizing asyncio. The server is going to work with a game engine to process pretty much every interaction a player makes in the game. Therefore, I have to authenticate the game client with the game server in some way as well ensure replay attacks do not happen on top of everything else that could harm or spoof the game server.\nWhen it comes to authenticating with UDP, I'm at a loss. My plan is to have both the game client and game server authenticate per user and game session. That means having something like a public key on the client end and a private key on the server end where the server can authenticate the client is approved.\nDuring that authentication, I am going to generate a symmetric key that the game server makes and passes it down to the game client so every packet sent can be verified with that symmetric key using HMAC. If not, all packets are dropped.\nMy Question\nIs this the best approach? Creating some type of public key where something like a token is generated per session to ensure packets coming to the UDP server are from authenticated clients? My worry here is the keys are still stored in a Windows EXE file and still likely can be cracked and extracted or am I just too paranoid?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":465,"Q_Id":50319570,"Users Score":0,"Answer":"Going to answer my own question!\nNo It's Not The Best Approach\nThe reason this is not the best approach is because even with this process, my use of public\/private key was incorrect. I was not referring to encrypting data between the client and server, I was referring to creating a nonce with having some type of password on the client that matches the password on the server.\nThis means the moment I send credentials from the client to the server, it's being sent without encryption on the line or in the buffer to the server. Once this authentication is accepted by the server, it will hash the password, store it and then send the nonce back to the client, which will also be without encryption.\nThe username, the password, and the nonce will be vulnerable to Man in the Middle attacks from both a third-party and the client itself. Which means they can sniff the packets, snag the transmission and crack the user or attempt replays being they have the nonce.\nSolution\nMy game client does not have SSL\/TSL\/DTSL options. This is why I actually posted the question, but did not clarify this. My server, as it's custom within Python, does have that ability though. But, I found a plugin for the game engine last night that allows for AES encryption of the data being written to the buffer before said buffer is sent as a packet to the UDP server, which means I can encrypt the passing of data in those packets in a secure way that hopefully the server can decrypt with a legit private key.\nDoing this will be a good option because it likely will be my only option. Now when a malicious user sniffs the traffic, they wont be able to see credentials or the nonce. The only issue after that is cracking the EXE, which I'm fine with for now.","Q_Score":0,"Tags":"python,ssl,udp","A_Id":50331500,"CreationDate":"2018-05-13T18:53:00.000","Title":"What is the best way to secure UDP server with HMAC?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My goal is to make an easy neural network fit by providing 2 verticies of a certain Graph and 1 if there's a link or 0 if there's none.\nI fit my model, it gets loss of about 0.40, accuracy of about 83% during fitting. I then evaluate the model by providing a batch of all positive samples and several batches of negative ones (utilising random.sample). My model gets loss of ~0.35 and 1.0 accuracy for positive samples and ~0.46 loss 0.68 accuracy for negative ones.\nMy understanding of neural networks if extremely limited, but to my understanding the above means it theoretically always is right when it outputs 0 when there's no link, but can sometimes output 1 even if there is none.\nNow for my actual problem: I try to \"reconstruct\" the original graph with my neural network via model.predict. The problem is I don't understand what the predict output means. At first I assumed values above 0.5 mean 1, else 0. But if that's the case the model doesn't even come close to rebuilding the original.\nI get that it won't be perfect, but it simply returns value above 0.5 for random link candidates.\nCan someone explain to me how exactly model.predict works and how to properly use it to rebuild my graph?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":343,"Q_Id":50319873,"Users Score":0,"Answer":"The model that you trained is not directly optimized w.r.t. the graph reconstruction. Without loss of generality, for a N-node graph, you need to predict N choose 2 links. And it may be reasonable to assume that the true values of the most of these links are 0.\nWhen looking into your model accuracy on the 0-class and 1-class, it is clear that your model is prone to predict 1-class, assuming your training data is balanced. Therefore, your reconstructed graph contains many false alarm links. This is the exact reason why the performance of your reconstruction graph is poor.\nIf it is possible to retrain the model, I suggest you do it and use more negative samples.\nIf not, you need to consider applying some post-processing. For example, instead of finding a threshold to decide which two nodes have a link, use the raw predicted link probabilities to form a node-to-node linkage matrix, and apply something like the minimum spanning tree to further decide what are appropriate links.","Q_Score":2,"Tags":"python,tensorflow,machine-learning,keras,predict","A_Id":50326237,"CreationDate":"2018-05-13T19:28:00.000","Title":"Need help using Keras' model.predict","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have libraries for reading sensor chips for two a pressure temperature sensors.\nOne is ms5837 and this one works but I want to use ms5803.\nimport ms5837 works and also the line import 5803 works.\nIn using the ms5837 I can run the line\nsensor = ms5837.MS5837_BA() and then do stuff.\nI don't know the function entry names possible for ms5803:\n\ndir(ms5837)   produces\n[__doc__','__loader__','__name__','__package__','__path__','__spec__']\nno sign of the MS5837_BA() function\ndir(ms5803) gives the same result with no indication of the libraries available.\n\nHow can I list the function is either of these imports?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":50322925,"Users Score":0,"Answer":"Yes I am using a Raspberry Pi. Guilty!\nThe problem was with PYTHONPATH or in my case, python or the python program had to run in the directory with the ms5837 library that is downloaded. \nAfter changing into the directory all the functions appear when using the dir(ms5837)   commend.\nWhat was confusing to me was that the statement \"import ms5837\" worked and then the objects that should have come with that statemetn were not there.","Q_Score":0,"Tags":"python,function,package,sensors","A_Id":50340088,"CreationDate":"2018-05-14T04:00:00.000","Title":"How can I see function for sensor in 'ms5837-python' package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I build two graphs in my code, graph1 and graph2. \nThere is a tensor, named embedding, in graph1. I tied to use it in graph2 by using get_variable, while the error is tensor must be from the same graph as Tensor. I found that this error occurs because they are in different graphs.\nSo how can I use a tensor in graph1 to graph2?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":50323744,"Users Score":0,"Answer":"expanding on @jdehesa's comment,\nembedding could be trained initially, saved from graph1 and restored to graph2 using tensorflows saver\/restore tools. for this to work you should assign embedding to a name\/variable scope in graph1 and reuse the scope in graph2","Q_Score":0,"Tags":"python,tensorflow,graph","A_Id":50329741,"CreationDate":"2018-05-14T05:48:00.000","Title":"How to used a tensor in different graphs?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to identify the type of feature in a dataset which can be either categorical\/bag of words\/ floats. \nHowever I am unable to reach to a accurate solution to distinguish between categorical and bag of words due to following reasons.\n\nCategorical data can either be object or float. Counting the unique values in a feature does not ensure the accurate solution as different samples can have the same feature value which necessarily may not be categorical.\nFor bag or words, I thought of counting the number of words but again this is not the correct way as text can be written in a single word or may be missing.\n\nwhat can be the best way to identify the type of features?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":183,"Q_Id":50326774,"Users Score":1,"Answer":"Well you're confused between those two terms:\nCategorical Data is the kind of data which can be categorized between different categories especially more than two classes or multi-class. Search for 20 Newsgroup Dataset.\nWhereas,\nBag of Words is a technique of storing features. Identification of features is done on the basis of what outcome is required. There are techniques to extract features like TF-IDF Vectorizer from sklearn, Word2Vec, Doc2Vec, etc. But identification of features is solely based on the dataset you use and the application it is used for. Always remember, if you convert textual data to numerical form or whatsoever, the column names are your Features or Dimensions whereas the rows are your samples or instances or records.","Q_Score":1,"Tags":"python,pandas,machine-learning","A_Id":50327148,"CreationDate":"2018-05-14T09:11:00.000","Title":"identifying feature type in a dataset : categorical or bag of words","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I downloaded Python 3.6.5 and while I trying to run my program, opened a black window and closed (like a cmd window).\nWhat I need to do?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":50330952,"Users Score":0,"Answer":"Install any client where you can execute the commands. And execute the command python file.py.","Q_Score":0,"Tags":"python,python-3.6","A_Id":50331005,"CreationDate":"2018-05-14T12:59:00.000","Title":"Can't running my program in Python 3.6.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know if there is a way to manipulate the recognition of phone numbers when using the Google Speech API?  I am trying to implement a transcription scenario where a caller will say a string of letters and numbers, but the logic out of the box seems to be to try to fit any sequence of numbers to a phone number scheme, even if it means rendering letters into numbers they may sound vaguely similar to (or not).  I have tried using speech contexts to manipulate the values within the \"phone number\" by typing out and giving the entire thing as it should be as a speech context (\"eight seven seven two bee three seven\", for example), but it refuses to override the digits being interpreted as a phone number.  Has anyone encountered this issue or is aware of any way in which this could be worked around?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":571,"Q_Id":50334029,"Users Score":0,"Answer":"In at least one case, setting the language to en-PH (English Philippines) seems to have fixed, or at least notably improved, this problem. Other English language options might work as well. \nen-GB comes back as a UK formatted number where they put one digit first then the rest of the number.","Q_Score":1,"Tags":"google-cloud-platform,speech-recognition,speech-to-text,google-speech-api,google-python-api","A_Id":51776051,"CreationDate":"2018-05-14T15:30:00.000","Title":"google-speech-api and overriding phone number recognition","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to compile python3 from source so I followed the instructions. \nHowever, during the make command I get the error\n.\/Modules\/zlibmodule.c:10:18: fatal error: zlib.h: No such file or directory\nHow do I solve this without having to install zlib as I do not have root access. Is there a way to skip this file while compilation?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":580,"Q_Id":50334983,"Users Score":0,"Answer":"You can try and use python-dev instead, it includes header files, a static library and development tools for building Python modules, extending the Python interpreter or embedding Python in applications. To install this package, enter:\nFor Python version 3.x+\n$ sudo apt-get install python3-dev","Q_Score":1,"Tags":"makefile,python-3.6,zlib","A_Id":50335420,"CreationDate":"2018-05-14T16:27:00.000","Title":"Compiling Python3.6 gives fatal error: zlib.h: 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":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When trying to execute the following command:\n\nimport matplotlib.pyplot as plt\n\nThe following error occurs:\n\nfrom _bz2 import BZ2Compressor, BZ2Decompressor ImportError: No module\n  named '_bz2'\n\nSo, I was trying to install bzip2 module in Ubuntu using :\n\nsudo pip3 install bzip2\n\nBut, the following statement pops up in the terminal:\n\nCould not find a version that satisfies the requirement bzip2 (from\n  versions: ) No matching distribution found for bzip2\n\nWhat can I do to solve the problem?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":17593,"Q_Id":50335503,"Users Score":16,"Answer":"If you compiling python yourself, you need to install libbz2 headers and .so files first, so that python will be compiled with bz2 support.\nOn ubuntu, apt-get install libbz2-dev then compile python.","Q_Score":15,"Tags":"python,python-3.x,matplotlib,importerror,bzip2","A_Id":53698659,"CreationDate":"2018-05-14T17:00:00.000","Title":"No module named '_bz2' in python3","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When trying to execute the following command:\n\nimport matplotlib.pyplot as plt\n\nThe following error occurs:\n\nfrom _bz2 import BZ2Compressor, BZ2Decompressor ImportError: No module\n  named '_bz2'\n\nSo, I was trying to install bzip2 module in Ubuntu using :\n\nsudo pip3 install bzip2\n\nBut, the following statement pops up in the terminal:\n\nCould not find a version that satisfies the requirement bzip2 (from\n  versions: ) No matching distribution found for bzip2\n\nWhat can I do to solve the problem?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":17593,"Q_Id":50335503,"Users Score":1,"Answer":"I found a pattern in those issue.\nIt happens mostly if you are missing dev tools and other important libraries important to compile code and install python.\nFor me most of those step did not work. But I had to do the following :\n\nRemove my python installation\n\npyenv uninstall python_version\n\nThen install all the build tools to make sure I am not missing any\n\nsudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \\ libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \\ xz-utils tk-dev libffi-dev liblzma-dev python-openssl git\n\nReinstall the new python version\n\npyenv install python_version\nI hope that solves your issues.","Q_Score":15,"Tags":"python,python-3.x,matplotlib,importerror,bzip2","A_Id":71457141,"CreationDate":"2018-05-14T17:00:00.000","Title":"No module named '_bz2' in python3","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing scientific calculations with both very small and large numbers, so obviously if I'm using python the decimal.Decimal() representation is key. The problem is the tedium. Having to type Decimal() around every relevant operation is cumbersome. \nIs there a way to set the default numeric representation as Decimal somewhere, anywhere?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":71,"Q_Id":50336008,"Users Score":1,"Answer":"Not possible. The use of floats is hardcoded all over the place, and many numeric routines literally can't operate on anything else, particularly stuff written in C.","Q_Score":4,"Tags":"python,decimal","A_Id":50337609,"CreationDate":"2018-05-14T17:34:00.000","Title":"Set Python's default numerical representation to \"Decimal\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm sorry if the title is a little ambiguous. Let me explain what I mean by that : \nI have a python script that does a few things : creates a row in a MySQL table, inserts a json document to a MongoDB, Updates stuff in a local file, and some other stuff, mostly related to databases. Thing is, I want the whole operation to be atomic. Means - If anything during the process I mentioned failed, I want to rollback everything I did. I thought of implementing a rollback function for every 'create' function I have. But I'd love to hear your opinion for how to make some sort of a linked list of operations, in which if any of the nodes failed, I want to discard all the changes done in the process.\nHow would you design such a thing? Is there a library in Python for such things?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":50336747,"Users Score":0,"Answer":"You should implement every action to be reversible and the reverse action to be executable even if the original action has failed. Then if you have any failures, you execute every reversal.","Q_Score":2,"Tags":"python,database,design-patterns","A_Id":50347347,"CreationDate":"2018-05-14T18:25:00.000","Title":"Best practice for rollbacking a multi-purpose python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a discord bot, and I want to add it to group DM's so I can keep my server levels lower. However, you can't add people who aren't friends to group DM's. Is there a way to get a discord bot to accept friend requests?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7073,"Q_Id":50337904,"Users Score":6,"Answer":"Not possible. Bot accounts do not have permission to use Discord's relationships endpoint. This means no friending and no blocking, and by extension means no bots in group DMs.","Q_Score":2,"Tags":"python,discord.py","A_Id":50338842,"CreationDate":"2018-05-14T19:44:00.000","Title":"How to make a discord bot add you as friend","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 basically want a workflow that goes like this:\nI'm working on a script and run into some issues so I:\n\nMove the script to the interactive console (shift+alt+e on Mac)\nRun a few queries against my variables to figure things out. This step is over when I find a line of code that works.\nUse a keyboard shortcut to add it to the end of the file I have open.\nRepeat as necessary until I feel good about just editing the file directly again.\n\nOptions I'm aware of (that I don't care for)\n\nScroll up, copy, paste.\nUse shortcut to open up history panel.  Select line, copy, close panel, click on script, paste.\n\nI feel it would be a lot smoother for my workflow if I could just hit some key combo and BAM! the last line of code I executed is just put at the bottom of the current file.\nCan it be done?  Anyone have some insight?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":212,"Q_Id":50339145,"Users Score":1,"Answer":"If you've just typed a statement, hit enter, seen that it looks right, and have an empty prompt waiting, you can:\n\nPress the up arrow key to bring back the last statement\nPress Cmd+A to select the whole statement\nPress Cmd+C to copy\n\nIf the whole statement fits on a single line, you can skip step 2: in general if nothing is selected then Cmd+C copies the whole line at the cursor.\nThe prompt >>> or In[x] will not be copied.\nYou still have to click in the editor to paste, and I don't see a way around that. But at least for the copying you can save on some mouse movement.","Q_Score":0,"Tags":"python,pycharm,interactive","A_Id":50339399,"CreationDate":"2018-05-14T21:17:00.000","Title":"Move last command in PyCharm interactive shell to script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to import another .py file in the same folder, but fails. I can't figure out why.\nfolder A contains folder B, file c.py and d.py is in folder B, I am trying to import c to d, and there is a \\__init__.py file in folder, I also tried something like write \\__all__ = ['c'] in file \\__init__.py because import c was not working","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":50343062,"Users Score":0,"Answer":"Try something like;\nfrom c import *","Q_Score":0,"Tags":"python,import,python-import","A_Id":50343323,"CreationDate":"2018-05-15T05:45:00.000","Title":"python import file at same folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Getting an error that Kivy module is not found after installing Kivy for Python 3.6 using pip3 and brew. \nPlease advise.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":114,"Q_Id":50343129,"Users Score":0,"Answer":"pip3 install pygame\nInstalling pygame and setting the PATH correctly fixed this issue.","Q_Score":0,"Tags":"python,python-3.x,kivy","A_Id":50352715,"CreationDate":"2018-05-15T05:52:00.000","Title":"Module not found error Kivy Python 3.6 Mac OS High Sierra","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a Python project simulating the sounds produced by vibrating strings. If for a given string, I have determined the Fourier transform of the motion, those results can by a simple operation be changed into the data showing the amplitude per (audio) frequency. \nIs it possible to then turn those (frequency, amplitude)-data into the corresponding sound using Python?\nI have tried it using IPython.display.audio but didn't manage to get it working properly.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":322,"Q_Id":50345002,"Users Score":0,"Answer":"If i understand you correctly,you can extract and convert a specific (frequency, amplitude)-data into wav file with scipy.io.wavfile.write. Just don't forget to convert your array to [sample,channel] format.","Q_Score":3,"Tags":"python,audio,fft,physics","A_Id":50345861,"CreationDate":"2018-05-15T07:52:00.000","Title":"Is it possible to convert (frequency, amplitude)-data to the corresponding (audio) sound in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to write 0644 (0o644) in Python 2 and 3 compatible way. How to do it? The only ideas I have is to parse this from string or convert into hex or decimal. That's not human-readable. I don't mind slow speed, it's called just once.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2609,"Q_Id":50345204,"Users Score":11,"Answer":"0o644 is compatible with both python2 and python3","Q_Score":7,"Tags":"python","A_Id":50345334,"CreationDate":"2018-05-15T08:03:00.000","Title":"How to write an octal value in Python 2 & 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have looked at a few python GUI frameworks like PyQt, wxPython and Kivy, but have noticed there aren\u2019t many popular (used widely) python applications, from what I can find, that use them.\nBlender, which is pretty popular, doesn\u2019t seem to use them. How would one go about doing what they did\/what did they do and what are the potential benefits over using the previously mentioned frameworks?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":469,"Q_Id":50346411,"Users Score":1,"Answer":"I would say that python isn't a popular choice when it comes to making a GUI application, which is why you don't find many examples of using the GUI frameworks. tkinter, which is part of the python development is another option for GUI's.\nBlender isn't really a good example as it isn't a GUI framework, it is a 3D application that integrates python as a means for users to manipulate it's data. It was started over 25 years ago when the choice of cross platform frameworks was limited, so making their own was an easier choice to make. Python support was added to blender about 13 years ago. One of the factors in blender's choice was to make each platform look identical. That goes against most frameworks that aim to implement a native look and feel for each target platform.\nSo you make your own framework when the work of starting your own framework seems easier than adjusting an existing framework to your needs, or the existing frameworks all fail to meet your needs, one of those needs may be licensing with Qt and wxWidgets both available under (L)GPL, while Qt also sells non-GPL licensing.\nThe benefit to using an existing framework is the amount of work that is already done, you will find there is more than you first think in a GUI framework, especially when you start supporting multiple operating systems.","Q_Score":0,"Tags":"python,python-3.x,user-interface,blender","A_Id":50404266,"CreationDate":"2018-05-15T09:13:00.000","Title":"Why and how would you not use a python GUI framework and make one yourself like many applications including Blender do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to transfer files from one S3 bucket to another S3 bucket using AWS Glue through a Python Script?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1360,"Q_Id":50348880,"Users Score":0,"Answer":"Create a Crawler for your bucket - it will discover the schema of your data and add it as table to Glue Catalog\nUse Job wizard and select your table as source, and new table as target\nGlue will generate the code for you where you have to select the destination of your data, specify format etc.","Q_Score":0,"Tags":"python-3.x,amazon-s3,aws-glue","A_Id":50351216,"CreationDate":"2018-05-15T11:18:00.000","Title":"Transfer files within S3 buckets using AWS Glue","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Anaconda 2 & 3 in my system. Anaconda 2 contains python 2.7 & Anaconda 3 contains python 3.6.\nI need to run my python code using command prompt & I need to use python 3.6\nWhile I'm running python --version, I'm getting python 2.7.14. How do I change it to python 3.6?","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":82839,"Q_Id":50348975,"Users Score":0,"Answer":"If Anaconda 3's is the only python3 interpreter in the system you can run python3 instead of python in your command line and it should work.\n\nYou can alter PATH parameter inverting the positions of both interpreters.","Q_Score":8,"Tags":"python","A_Id":50349051,"CreationDate":"2018-05-15T11:23:00.000","Title":"How to change python version in command prompt if I have 2 python version installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Anaconda 2 & 3 in my system. Anaconda 2 contains python 2.7 & Anaconda 3 contains python 3.6.\nI need to run my python code using command prompt & I need to use python 3.6\nWhile I'm running python --version, I'm getting python 2.7.14. How do I change it to python 3.6?","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":82839,"Q_Id":50348975,"Users Score":0,"Answer":"I made a small trick to solve this problem. For me\n\nC:\\Python27\n\nand\n\nC:\\Python27\\Scripts\n\nwere at the top of the PATH Environment variable list. I simply selected them and clicked on Moved Down to shift them to the end of the list.\n\nJust make sure that your path of Python3 and its Script folder is above Python2 path.\n\nAnd it solved the problem for me. Hope it would help you too.\nReason :\n\nHow does the cmd run commands?\nIt searches for an executable with the same name in the directory the cmd has been opened in, then goes and searches for the command in the locations provided in the Windows PATH variable, from TOP to BOTTOM. Which means, it gets the path to Python2 before it can get to the path of Python3. Therefore, every time you type python in your cmd, it runs Python2.\nBoth Python2 and Python3 executables have the same name in Windows so it never runs python3.\n\nreason is taken from the accepted answer to this question.","Q_Score":8,"Tags":"python","A_Id":61691955,"CreationDate":"2018-05-15T11:23:00.000","Title":"How to change python version in command prompt if I have 2 python version installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a CNN model on tensorflow with input placeholder - [None, 32, 32, 3]tf.placeholder(tf.float32, [None, 24, 24, 3]). Then I want to use that model in Android application and for that reason I froze the model. When I include the library I noticed that I can feed only with two dimensional array or ByteBuffer. How can I feed the bitmap from the camera? Do I have to change the input size of the placeholder and what should the size be? \nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":50355139,"Users Score":0,"Answer":"tensorInferenceInterface.feed(\"the_input\", pixels, batch_size, width, height, dims); \nhope this will work for you","Q_Score":0,"Tags":"android,python,tensorflow","A_Id":54786075,"CreationDate":"2018-05-15T16:29:00.000","Title":"Tensorflow android feed with specific array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Performing .shape is giving me the following error. \n\nAttributeError: 'DataFrame' object has no attribute 'shape'\n\nHow should I get the shape instead?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":16817,"Q_Id":50355598,"Users Score":1,"Answer":"To get the shape we can try this way:\n dask_dataframe.describe().compute()  \n\"count\" column of the index will give the number of rows\n len(dask_dataframe.columns) \nthis will give the number of columns in the dataframe","Q_Score":25,"Tags":"python,dask","A_Id":53350392,"CreationDate":"2018-05-15T16:57:00.000","Title":"How should I get the shape of a dask dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I run command prompt in Atom Editor? Do I need to install any package for the same? I could not find any videos or links regarding this issue.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":30297,"Q_Id":50357944,"Users Score":1,"Answer":"There are 2 packages that I use to open a terminal window in Atom. They are 'platformio-ide-terminal' and Termination. Load either one of these and the name will appear under the package menu. Selecting either one will allow you to open a terminal window in bottom third of Atom window.","Q_Score":7,"Tags":"python-3.x,cmd,atom-editor","A_Id":50384946,"CreationDate":"2018-05-15T19:35:00.000","Title":"How to open command prompt in Atom editor?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I run command prompt in Atom Editor? Do I need to install any package for the same? I could not find any videos or links regarding this issue.","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":30297,"Q_Id":50357944,"Users Score":10,"Answer":"Go to File -> Settings -> Install\nSearch for package -> platformio-ide-terminal\nAfter installation of this package\nGo to Packages tab in a menu bar where you can see all the packages installed\nclick on platformio-ide-terminal -> New Terminal [Now you will get the terminal window]","Q_Score":7,"Tags":"python-3.x,cmd,atom-editor","A_Id":54021755,"CreationDate":"2018-05-15T19:35:00.000","Title":"How to open command prompt in Atom editor?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have Python version 3.5 which is located here C:\\Program Files(x86)\\Microsoft Visual Studio\\Shared\\Python35_64 If I install kivy and its components and add-ons with this command: python -m pip install kivy, then it does not install in the place that I need. I want to install kivy in this location C:\\Program Files(x86)\\ Microsoft Visual Studio\\Shared\\Python35_64\\Lib\\site-packages, how can I do this?\nI did not understand how to do this from the explanations on the official website.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":247,"Q_Id":50358110,"Users Score":1,"Answer":"So it turned out that I again solved my problem myself, I have installed Python 3.5 and Python 3.6 on my PC, kiwy was installed in Python 3.6 by default, and my development environment was using Python 3.5, I replaced it with 3.6 and it all worked.","Q_Score":1,"Tags":"python,python-3.x,kivy,python-3.5,site-packages","A_Id":50400643,"CreationDate":"2018-05-15T19:46:00.000","Title":"Installing Kivy to an alternate location","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using scipy.optimize.least_squares to solve an interval constrained nonlinear least squares optimization problem.  The form of my particular problem is that of finding a0, a1, b0, and b1 such that the cost function:\n\\sum^N_{n=1} ( g_n - (y_n - b0 e^-(tn\/b1)) \/ a0 e^-(tn\/a1) )^2\nis minimized where g_n, y_n and t_n are known and there are interval constraints on a0, a1, b0, and b1.\nThe four unknown parameters span approximately four orders of magnitude (e.g, a0 = 2e-3, a1 = 30, similar for b0 and b1).  I have heard that a high dynamic range of unknown parameters can be numerically problematic for optimization routines.   \nMy first question is whether four or so orders of magnitude range would be problematic for scipy.optimize.minimize. The routine appears to converge on the data I've applied so far. \nMy second question relates to the form of the cost function.  I can equivalently write it as:\n\\sum^N_{n=1} ( g_n - ( 1\/a0 e^(tn\/a1) y_n - b0\/a0 e^-(tn\/b1) +tn\/a1) \/ )^2\n=\n\\sum^N_{n=1} ( g_n - ( a0' e^(tn\/a1) y_n - b0' e^-(tn*b1')) )^2\nwhere the new parameters are simple transformations of the original parameters.  Is there any advantage to doing this in terms of numerical stability or the avoidance of local minima?  I haven't proven it, but I wonder whether this new cost function would be convex as opposed to the original cost function.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":176,"Q_Id":50358434,"Users Score":0,"Answer":"Most solvers are designed for variables in the 1-10 range. A large range can cause numerical problems, but it is not guaranteed to be problematic. Numerical problems sometimes stem from the matrix factorization step of the linear algebra for solving the Newton step, which is more dependent of the magnitude of the derivatives. You may also encounter challenges with termination tolerances for values outside the 1-10 range. Overall, if it looks like it's working, it's probably fine. You could get a slightly better answer by normalizing values.\nDivision by a degree of freedom can cause difficulties in three ways:\n\ndivision by zero\ndiscontinuous derivatives around 0\nvery steep derivatives near 0, or very flat derivatives far from 0\n\nFor these reasons, I would recommend \\sum^N_{n=1} ( g_n - ( a0' e^(tn\/a1) y_n - b0' e^-(tn*b1')) )^2. However, as previously stated, if it's already working it may not be worth the effort to reformulate your problem.","Q_Score":0,"Tags":"python,scipy,mathematical-optimization,least-squares,nonlinear-optimization","A_Id":50400053,"CreationDate":"2018-05-15T20:09:00.000","Title":"Dynamic range of unknown parameters and form of cost function in scipy.optimize.least_squares","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with a fresh install of python-mode (installed with Vundle on Vim 8) and find that \"go to definition\" mapping never works no matter how I set g:pymode_rope_goto_definition_bind.\nThen I found RopeGotoDefinition is not an editor command. How could this happen? I'm confused.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":527,"Q_Id":50358697,"Users Score":0,"Answer":"Solved it by myself before someone thinks I can't even do a git clone.\nAfter digging into the plugin code, I found g:pymode_rope_goto_definition_bind is actually mapped to :call pymode#rope#goto_definition()<CR> rather than :RopeGotoDefinition which appears only once in the whole repo.\nAfter verifying :call pymode#rope#goto_definition()<CR> command works as expected, I found my problem (failing to map) was caused by terminal emulator and Vim eating up all Ctrl+letter combinations. Something other than that works well, e.g. let g:pymode_rope_goto_definition_bind='<leader>pg'.\nAs for :RopeGotoDefinition, maybe it's just the remnant of old code lingering in the documentation.","Q_Score":0,"Tags":"vim,python-mode","A_Id":50359222,"CreationDate":"2018-05-15T20:28:00.000","Title":"Not an editor command: RopeGotoDefinition","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some modbus TCP code written under pymodbus 1.2\nthe relevent code was\nresult = modbus_client.read_holding_registers(40093, 3)\nAfter updating to pymodbus 1.4.0 it wouldn't work until I cargo culted the new unit parameter into the function call (teh examples all had unit=1 in\nthem):\nresult = modbus_client.read_holding_registers(40093, 3, unit=1)\nwhat does the unit parameter in pymodbus read_ holding_registers() mean?\nI can't seem to find an explanation anywhere.\nThe source says \":param unit: The slave unit this request is targeting\",\nbut I don't understand what this means, nor what selection other than 1 might be used.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1866,"Q_Id":50359986,"Users Score":6,"Answer":"The Modbus protocol was originally developed long before TCP\/IP was popular (late 70s I think). It was used on serial connections mostly. Some serial hardware protocols like RS485 allow daisy-chaining. The modbus master (in your case Python) can poll many slaves on a single serial port. Only the slave that was requested will respond. The address of the slave is the Unit in this case. Once Modbus was adapted to TCP\/IP, the protocol allowed this \"unit address\" to be used to create multiple slaves behind a single IP address. Most of the time, if using TCP\/IP there is a single address of 1. On Wikipedia they refer to this as \"Station address.\"\nI'm not sure why you would need to include this in the call to the method since it is a kwarg that is defaulted to 1 anyway.","Q_Score":5,"Tags":"python,modbus,modbus-tcp,pymodbus","A_Id":50360335,"CreationDate":"2018-05-15T22:25:00.000","Title":"What does the pymodbus \"unit\" parameter 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a notification model with Redis as database. With every addition to a particular key in the database, I notify the  remote client(written with Redis-py) using Redis's pubsub feature and also a HTTP based notification. \nWhile running performance test and comparing the times between Redis PUBSUB notification and HTTP Response are fairly close( redis still being faster than HTTP by a few ms. Example. Redis notification takes 47 ms and HTTP notification takes 56 ms). \nI was assuming Redis PUBSUB would be much faster than HTTP. Is this the expected performance of redis notification over HTTP ? Is there a faster way to push notifications from Redis db (faster than HTTP)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1261,"Q_Id":50360981,"Users Score":0,"Answer":"What is your ping to client instance? If underlying network is slow, there is nothing much you can do. Only switch to UDP custom protocol. Because expected performance of Redis PUBSUB is about 4k op\/s with regular hardware. Also what is the message size you are transferring? If it is high, you're also bound to your network speed.","Q_Score":0,"Tags":"python,http,testing,redis,notifications","A_Id":50368728,"CreationDate":"2018-05-16T00:46:00.000","Title":"Redis Pubsub performance for remote clients","Data Science and Machine Learning":0,"Database and SQL":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 know my question sounds like a duplicate, but I've looked everywhere without finding any solution.\nI am working on implementing social logins for my django webapp. So far google, twitter and yahoo logins have worked as expected. But facebook always gives the error below:\nURL blocked: This redirect failed because the redirect URI is not white-listed in the app's client OAuth settings. Make sure that the client and web OAuth logins are on and add all your app domains as valid OAuth redirect URIs.\nAfter some digging I got to learn how to setup my facebook login properly: Facebook app settings below\nApp Domains set to domain.ext\nSite URL set to https:\/\/www.domain.ext\/\nValid OAuth Redirect URIs set to https:\/\/domain.ext\/social\/complete\/facebook\/\nI also looked at the redirect url (shown below) and found that it contains a state variable, state=kMQH3TdKSdF8oYGGx7Xri4KgFaEQ9OyU. Full url below\nhttps:\/\/www.facebook.com\/v2.9\/dialog\/oauth?client_id=977674249054153&redirect_uri=https%3A%2F%2Fwww.domain.ext%2Fsocial%2Fcomplete%2Ffacebook%2F&state=kMQH3TdKSdF8oYGGx7Xri4KgFaEQ9OyU&return_scopes=true&scope=email%2Cpublic_profile\nMy facebook login url on my django app is {% url 'social:begin' 'facebook' %} and I have this 'social_core.backends.facebook.FacebookOAuth2' in AUTHENTICATION_BACKENDS\nI searched and found there's such issue already on the social-core github page which has been resolved. It says that from v1.7.0, this line REDIRECT_STATE = False has been added to the facebook backend. I dug into the sourcecode and found that to be the case. But my app's url keep sending the state variable and I have no idea why that is the case. Please has someone else encountered this odd behaviour, and if yes how did you go about working it out?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1285,"Q_Id":50363059,"Users Score":0,"Answer":"Have you tried django-allauth? I find it to be a much better solution. It takes care of third party provider integration for you with builtin support for many providers and custom providers.","Q_Score":3,"Tags":"python,django,python-social-auth,django-socialauth","A_Id":50363382,"CreationDate":"2018-05-16T05:30:00.000","Title":"social-auth-app-django facebook backend state with redirect_uri","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know my question sounds like a duplicate, but I've looked everywhere without finding any solution.\nI am working on implementing social logins for my django webapp. So far google, twitter and yahoo logins have worked as expected. But facebook always gives the error below:\nURL blocked: This redirect failed because the redirect URI is not white-listed in the app's client OAuth settings. Make sure that the client and web OAuth logins are on and add all your app domains as valid OAuth redirect URIs.\nAfter some digging I got to learn how to setup my facebook login properly: Facebook app settings below\nApp Domains set to domain.ext\nSite URL set to https:\/\/www.domain.ext\/\nValid OAuth Redirect URIs set to https:\/\/domain.ext\/social\/complete\/facebook\/\nI also looked at the redirect url (shown below) and found that it contains a state variable, state=kMQH3TdKSdF8oYGGx7Xri4KgFaEQ9OyU. Full url below\nhttps:\/\/www.facebook.com\/v2.9\/dialog\/oauth?client_id=977674249054153&redirect_uri=https%3A%2F%2Fwww.domain.ext%2Fsocial%2Fcomplete%2Ffacebook%2F&state=kMQH3TdKSdF8oYGGx7Xri4KgFaEQ9OyU&return_scopes=true&scope=email%2Cpublic_profile\nMy facebook login url on my django app is {% url 'social:begin' 'facebook' %} and I have this 'social_core.backends.facebook.FacebookOAuth2' in AUTHENTICATION_BACKENDS\nI searched and found there's such issue already on the social-core github page which has been resolved. It says that from v1.7.0, this line REDIRECT_STATE = False has been added to the facebook backend. I dug into the sourcecode and found that to be the case. But my app's url keep sending the state variable and I have no idea why that is the case. Please has someone else encountered this odd behaviour, and if yes how did you go about working it out?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1285,"Q_Id":50363059,"Users Score":0,"Answer":"I've spent hours on this issue, but it turns out I only needed to do this Valid OAuth Redirect URIs set to https:\/\/www.domain.ext\/social\/complete\/facebook\/\nNote the www.","Q_Score":3,"Tags":"python,django,python-social-auth,django-socialauth","A_Id":50364398,"CreationDate":"2018-05-16T05:30:00.000","Title":"social-auth-app-django facebook backend state with redirect_uri","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In tensorflow Object Detection API we are using ssd_mobilenet_v1_coco_2017_11_17 model to detect 90 general objects. I want to use this model for detection.\nNext, I have trained faster_rcnn_inception_v2_coco_2018_01_28 model to detect a custom object. I wish to use this in the same code where I will be able to detect those 90 objects as well as my new trained custom object. How to achieve this with single code?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2781,"Q_Id":50364281,"Users Score":2,"Answer":"You cant combine both the models. Have two sections of code which will load one model at a time and identify whatever it can see in the image. \nOther option is to re-train a single model that can identify all objects you are interested in","Q_Score":7,"Tags":"python,tensorflow,object-detection","A_Id":50632652,"CreationDate":"2018-05-16T06:58:00.000","Title":"How to use two models in Tensorflow object Detection API","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to write an application which is portable.\nWith \"portable\" I mean that it can be used to access these storages:\n\namazon s3\ngoogle cloud storage\nEucalyptus Storage\n\nThe software should be developed using Python.\nI am unsure how to start, since I could not find a library which supports all three storages.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":225,"Q_Id":50364766,"Users Score":3,"Answer":"You can use boto3 for accessing any services of Amazon.","Q_Score":7,"Tags":"python,amazon-s3,google-cloud-storage,portability","A_Id":50364799,"CreationDate":"2018-05-16T07:28:00.000","Title":"Portable application: s3 and Google cloud storage","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"With training & validation through a dataset for nearly 24 epochs, intermittently 8 epochs at once and saving weights cumulatively after each interval. \nI observed a constant declining train & test-loss for first 16 epochs, post which the training loss continues to fall whereas test loss rises so i think it's the case of Overfitting.\nFor which i tried to resume training with weights saved after 16 epochs with change in hyperparameters say increasing dropout_rate a little.\nTherefore i reran the dense & transition blocks with new dropout to get identical architecture with same sequence & learnable parameters count.\nNow when i'm assigning previous weights to my new model(with new dropout) with model.load_weights() and compiling thereafter.\ni see the training loss is even higher, that should be initially (blatantly with increased inactivity of random nodes during training) but later also it's performing quite unsatisfactory,\nso i'm suspecting maybe compiling after loading pretrained weights might have ruined the performance? \nwhat's reasoning & recommended sequence of model.load_weights() & model.compile()? i'd really appreciate any insights on above case.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1304,"Q_Id":50367540,"Users Score":2,"Answer":"The model.compile() method does not touch the weights in any way. \nIts purpose is to create a symbolic function adding the loss and the optimizer to the model's existing function. \nYou can compile the model as many times as you want, whenever you want, and your weights will be kept intact. \nPossible consequences of compile\nIf you got a model, well trained for some epochs, it's optimizer (depending on what type and parameters you chose for it) will also be trained for that specific epochs. \nCompiling will make you lose the trained optimizer, and your first training batches might experience some bad results due to learning rates not suited to the current state of the model. \nOther than that, compiling doesn't cause any harm.","Q_Score":1,"Tags":"python,keras,deep-learning","A_Id":50370068,"CreationDate":"2018-05-16T09:47:00.000","Title":"should model.compile() be run prior to using model.load_weights(), if model has been only slightly changed say dropout?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I run my pyspark program in vscode, and get error:\nPicklingError: Could not serialize object: ImportError: No module named visualstudio_py_debugger .\nI suppose it has something to do with my vscode setting?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":185,"Q_Id":50367947,"Users Score":0,"Answer":"Somehow your code is trying to pickle the debugger itself. Do make sure you are running the debugger using the PySpark configuration.","Q_Score":0,"Tags":"python,pyspark,visual-studio-code","A_Id":50518560,"CreationDate":"2018-05-16T10:05:00.000","Title":"get vscode python error when run pyspark program using vs code","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to create a hyperlink for a specific sheet of an excel file?\nI want to open a sheet on the click of a cell which is on another sheet of the same excel file. For example, if someone clicks on 'A1' cell which is in the sheet2 the sheet1 will be opened and both the sheets are in the abc.xlsx file.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":7157,"Q_Id":50369352,"Users Score":1,"Answer":"I was unable to get this to work using the \"write_url(A1, \"internal:'sheet name'!A2\")\" form.  Can someone provide some guidance on this?\nI was able to successfully add hyperlinks to internal cells using the form: \nwrite('A1', '=HYPERLINK(CELL(\"address\", 'sheet name'!A2), \"Friendly Name\")\nNOTE: the word 'address' is literal\/not a generic reference, and, the quotes need to be specified as shown (i.e., single quotes for a multi-word sheet name, and double quotes for the word 'address' and the 'Friendly Name'...","Q_Score":5,"Tags":"python-3.x,xlsxwriter","A_Id":58612395,"CreationDate":"2018-05-16T11:11:00.000","Title":"Creating a hyperlink for a excel sheet: xlsxwriter","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python flask framework for an object detection task. I have set threaded=Trueand multiple requests are handled well. As the detection process uses more processing power and time, I need to control the number of background threads to a certain limit. As of my knowledge, OS can manage the number of threads. But I need to limit the thread count to 4 or 5 and provide a server busy result if the request is overloaded. How can I achieve this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2387,"Q_Id":50370225,"Users Score":3,"Answer":"When using threaded true, the number of threads will be depend on the system configuration. You need to use any production environment like gunicorn for this as flask is not supporting production environment officially. Limiting of thread count using flask is also very hard to execute.","Q_Score":1,"Tags":"python,multithreading,flask","A_Id":50737176,"CreationDate":"2018-05-16T11:52:00.000","Title":"Python Flask: How to control the number of background threads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"How do I turn my python turtle script to .exe? I tried py2exe and it did execute my script but the cmd showed up for like 1 milisecond. I think it is because I am using turtle graphics instead of normal python script. Is there any way to turn my turtle program into .exe?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":819,"Q_Id":50370233,"Users Score":1,"Answer":"Use done() or exitonclick() for the last command","Q_Score":0,"Tags":"python,python-3.x,py2exe,turtle-graphics","A_Id":50370355,"CreationDate":"2018-05-16T11:53:00.000","Title":"How to turn Python Turtle 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to execute a python file coded for Graphical user Interface using pyqt modules using ssh. It gives me a message \nX11 connection rejected because of wrong authentication.\nQXcbConnection: Could not connect to display localhost:10.0\nI tried several ways checking for the x11 forwarding etc etc.Nothing seems to work. Please help me out.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1490,"Q_Id":50372055,"Users Score":0,"Answer":"ssh by default does not forward the X session, so your program on will try to open its window on the remote host (where it will be rejected in most cases because the X server on the remote host is either not running at all (e. g. if it is a headless server) or because it isn't configured to display the stuff.  And even if it would accept the window of your application, it would display it on the remote host's display, not on your local one.  So that wouldn't be what you want either.\nTry ssh -X \u2026 when starting your application via ssh.  This will tell ssh to forward the X session so that your application on the remote host will send its window back to the X server running on your local machine which it will be accepted and displayed.","Q_Score":1,"Tags":"python,python-2.7,ssh,pyqt5","A_Id":50372449,"CreationDate":"2018-05-16T13:18:00.000","Title":"Executing pyqt files 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":0,"Web Development":0},{"Question":"I am currently working with IBMi. I want an automatic mail after completing few jobs for confirmation. How can I achieve this? I can run Python in my system.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":321,"Q_Id":50372456,"Users Score":3,"Answer":"IBM has built in commands depending on your OS release.  They do require setting up the IBM SMTP server.  SNDSMTPEMM and SNDDST are the most used.\nThere are also third party products like my MAILTOOL software (www.bvstools.com\/mailtool.html) that makes interacting with cloud servers like Office 365 and Gmail much easier than then IBM SMTP server.\nPHP may also have some built in email capabilities as well as python.  But if you're looking for a command line interface after running jobs the first two are probably your best bet, depending on if you want to set up the IBM SMTP server or not.","Q_Score":1,"Tags":"python-3.x,ibm-midrange","A_Id":50372734,"CreationDate":"2018-05-16T13:37:00.000","Title":"How to automate mail in IBM i 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 new in mininet. I created a custom topology with 2 linear switches and 4 nodes. I need to write a python module accessing each nodes in that topology and do something but I don't know how.\nAny idea please?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":155,"Q_Id":50373532,"Users Score":0,"Answer":"try the following:\ns1.cmd('ifconfig s1 192.168.1.0')\nh1.cmd('ifconfig h1 192.168.2.0')","Q_Score":0,"Tags":"python,mininet,pox","A_Id":50385916,"CreationDate":"2018-05-16T14:25:00.000","Title":"How to access created nodes in a mininet topology?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In order to manage all my python paths for my project and have them available as soon as I start python interpreter, I created a project.pth in the project home directory having relative paths in it,\nActually, to be read, I need to do a site.addsitedir(my_project_home_dir) each time I start the interpreter. \nI tried setting PYTHONPATH or create a .pth in site-packages pointing to my project home directory, but project.pth is still not read automatically when I start the interpreter.\nThe only thing that works is to put my project.pth in site-packages, but by doing that, I have to transform my project relative paths to absolute paths.\nSo it there a master .pth file where I can specify my project home directory so I can have my project.pth located in that directory to be read automatically ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":50373834,"Users Score":0,"Answer":"Finally I found 2 ways : \n1) First, note that .pth files also accept lines beginning with 'import' and execute them. So the solution was to create project.pth inside site-packages importing a module in my project home dir that do actually the site.addsitedir()\n2) Other possibility : use the environment variable PYTHONSTARTUP : it will execute any module you want at python startup. You can specify a module that do the site.addsitedir() or even directly add paths into sys.path","Q_Score":0,"Tags":"python","A_Id":50405275,"CreationDate":"2018-05-16T14:40:00.000","Title":"Is possible to add a python site directory permanently?","Data 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 question regarding the Python API of Interactive Brokers.\nCan multiple asset and stock contracts be passed into reqMktData() function and obtain the last prices?  (I can set the snapshots = TRUE in reqMktData to get the last price.  You can assume that I have subscribed to the appropriate data services.)\nTo put things in perspective, this is what I am trying to do:\n1) Call reqMktData, get last prices for multiple assets.\n2) Feed the data into my prediction engine, and do something\n3) Go to step 1.\nWhen I contacted Interactive Brokers, they said:\n\"Only one contract can be passed to reqMktData() at one time, so there is no bulk request feature in requesting real time data.\"\nObviously one way to get around this is to do a loop but this is too slow.  Another way to do this is through multithreading but this is a lot of work plus I can't afford the extra expense of a new computer.  I am not interested in either one.\nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2183,"Q_Id":50374498,"Users Score":1,"Answer":"You can only specify 1 contract in each reqMktData call.  There is no choice but to use a loop of some type.  The speed shouldn't be an issue as you can make up to 50 requests per second, maybe even more for snapshots.\nThe speed issue could be that you want too much data (> 50\/s) or you're using an old version of the IB python api, check in connection.py for lock.acquire, I've deleted all of them.  Also, if there has been no trade for >10 seconds, IB will wait for a trade before sending a snapshot.  Test with active symbols.\nHowever, what you should do is request live streaming data by setting snapshot to false and just keep track of the last price in the stream.  You can stream up to 100 tickers with the default minimums.  You keep them separate by using unique ticker ids.","Q_Score":6,"Tags":"python-3.x,api,finance,quantitative-finance,interactive-brokers","A_Id":50413302,"CreationDate":"2018-05-16T15:13:00.000","Title":"Getting Multiple Last Price Quotes from Interactive Brokers's API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 700+ Word documents (mostly in .docm format), the contents being a mixture of text and tables. \nI'm trying to extract info from the tables. After much searching the only Python library that can detect tables is python-docx, which breaks when pointed at .docm files. The GitHub thread indicates this issue hasn't been addressed.\nFurther searching implies to convert .docm to .docx will require me to learn VB or C#, which isn't happening in the timescale I have unless I can acquire an absolutely clear explain-like-i'm-five kinda solution.\nIs there any way to achieve this or a potential alternative route?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1669,"Q_Id":50375455,"Users Score":1,"Answer":"The python library you are looking for is called docx2python. I had an almost identical problem and it worked great with .docm files.","Q_Score":1,"Tags":"python-3.x,python-docx","A_Id":61878579,"CreationDate":"2018-05-16T16:04:00.000","Title":"Processing .docm files with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been researching like forever, but couldn't find an answer. I'm using OpenCV to detect faces, now I want to calculate the distance to the face. When I detect a face, I get a matofrect (which I can visualize with a rectangle). Pretty clear so far. But now: how do I get the width of the rectangle in the real world? There has to be some average values that represent the width of the human face. If I have that value (in inch, mm or whatever), I can calculate the distance using real width, pixel width and focal length. Please, can anyone help me?\nNote: I'm comparing the \"simple\" rectangle solution against a Facemark based distance measuring solution, so no landmark based answers. I just need the damn average face \/ matofrectwidth :D\nThank you so much!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":138,"Q_Id":50375489,"Users Score":2,"Answer":"OpenCV's facial recognition is slightly larger than a face, therefore an average face may not be helpful. Instead, just take a picture of a face at different distances from the camera and record the distance from the camera along with the pixel width of the face for several distances. After plotting the two variables on a graph, use a trendline to come up with a predictive model.","Q_Score":1,"Tags":"python,opencv,distance,face-detection,measure","A_Id":50375996,"CreationDate":"2018-05-16T16:07:00.000","Title":"Real width of detected face","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Could some one please explain with an example about how we can send the pivot table output from pandas to word document without losing format.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2260,"Q_Id":50376081,"Users Score":-1,"Answer":"I suggest exporting it to csv using pandas.to_csv(), and then read the csv to create a table in a word document.","Q_Score":1,"Tags":"python,python-2.7,pandas,ms-word,pivot-table","A_Id":50376159,"CreationDate":"2018-05-16T16:42:00.000","Title":"How can I print pandas pivot table to word document","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a ton of PDF files that are laid out in two columns. When I use PyPDF2 to extract the text, it reads the entire first column (which are like headers) and the entire second column. This makes splitting on the headers impossible. It's laid out in two columns:\n____       __________\n|Col1           Col2                  |\n|Col1                                 Col2   |\n|Col1                                 Col2   |\n|Col1                                 Col2   |\n____       __________  \nI think I need to split the PDF in half along the edge of the column, then read each column left to right. It's 2.26 inches width on an 8x11 PDF. I can also get the coordinates using PyPDF2.\nDoes anyone have any experience doing this or know how I would do it?\nEdit: When I extractText using PyPDF2, the ouput has no spaces: Col1Col1Col1Col1Col2Col2Col2Col2","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":783,"Q_Id":50376895,"Users Score":1,"Answer":"Using pdfminer.six successfully read from left to right with spaces in between.","Q_Score":1,"Tags":"python,pdf,pypdf2","A_Id":50377964,"CreationDate":"2018-05-16T17:31:00.000","Title":"Split a PDF file into two columns along a certain measurement in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Title says it all really. I am running a program on a Linux EC2 instance with 4 threads. Three of these are listening to different websockets and the final one is webscraping and calling off a set of other functions when needed.\nIs it possible that if the GIL is owned by the 4th thread (i.e it is currently running its calculation through the single core) that websocket messages could be 'missed' by the threads listening? \nI am beginning to think it isn't possible, but have no understanding as to why. I have looked around, but to little avail.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":50379706,"Users Score":0,"Answer":"Not really, even if your application is completely blocked say by scheduling or simply sleeping the operating system will queue the incoming network messages. You might lose messages say if the TCP buffer starts to overflow, I reckon that is unlikely in your case. You can test your idea by deliberately sleeping in the 4th thread for some time and see if messages are dropped.","Q_Score":0,"Tags":"python,multithreading,websocket,python-multithreading,gil","A_Id":50379960,"CreationDate":"2018-05-16T20:52:00.000","Title":"If I am listening to a websocket in one thread and running a function in another thread is it possible to miss messages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This a question about architecture. Say I have a long running process on a server such as machine learning in a middle of a training. Now as this run on external machine I would like to have a tool to quickly see from time to time the results. So I thought the best way would be to have a website which quickly connects to the process for example using RPC to display the results as this allows me to always check in. Now the question is how should Django view gather the information from the server process:\n1) Using RPC calls such as rpyc directly in the views?\n2) Using some kind of messaging queue such as celery ?\n3) Or in a completely different way I am not seeing ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":157,"Q_Id":50381129,"Users Score":0,"Answer":"There's at least 2 possible ways to do this.\n\nImplement your data-refreshing function as a view and visit it by ajax(sync)+javascript timer.Since you visit your page that contains these js, it will fetch your data silently and update the page. However,this solution does not work well when you need to record all the data in a given frequency;the ajax\/view only executes when the web page is open.\nUse messaging queue like selcuk suggests.Alongside celery, APscheduler is also a good choice because it's easier to install and use.You can implement a task(as modal) queue with status(queue\/done\/stoped\/whatever as field) and check them at the frequency you wanted,save the date you retrieved and do all the other stuff.","Q_Score":0,"Tags":"python,django,ipc,rpc","A_Id":50385869,"CreationDate":"2018-05-16T23:04:00.000","Title":"Using Django as GUI for long running python process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've going on a little competition with friends: We're writing models for the upcoming worldcup to see whoms model gets the most points out of a tip game.\nSo my approach would be to write a neural network and train it with previous worldcup results regarding to the anticipated wining rates (back then), to maximize the score of the tip game (e.g. 6 points for the exact score, 4 correct goal difference, 3 correct winner).\nScrap rates from various sites (bwin etc.) and let the network tip for me.\nI'm familiar with linear algebra, probability calculus etc., but have never programmed a neural network yet.\nSince I have not much time left, could someone help me by picking the best approach (like which concept\/algorithm I should use) or link me a tutorial to a similar problem or the approach that would fit?\nBest,\n  Hannes","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":968,"Q_Id":50382706,"Users Score":1,"Answer":"I did this for the 2017 UK Premier league season. However I accumulated the first 19 (out of 38 Games), in order to try and help with my predictions.\nI would attack this in the following manner\n\nGet Data on the Teams (What you consider data I will leave up to you)\nGet the History of previous matches (Personally I think this is not going to help, as teams change so much)\nPython\n\n\nPandas\n\n\nCreate New Features\n\nKeras\nModel away\n\n\nWhen I was playing with the UK Premier league, got a prediction accuracy of aprox 62%. So how to make it better ?\n\nDistance travelled\n\n\nImproved it by 1.2%. Some teams do not like traveling it seems.\n\nWeather\n\n\nI got the weather forecast per ground @ Kick-Off-Time (What a pain)\nAccuracy improved by 0.5%\n\n\nWhat I did not do - was get a list of Players who were playing per game, per day. And attribute things like distance run, passing percentage, goals, fouls, yellow cards etc","Q_Score":0,"Tags":"python,c,tensorflow,neural-network","A_Id":50382763,"CreationDate":"2018-05-17T02:58:00.000","Title":"Neural Network Predict Soccer Results","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am importing some data from file and every time I get different format of date. So I want to get date format by any function of postgres from database field which is char.\nFor example,\nmy_date\n-----------\n2018-01-30\nor\nmy_date\n-----------\n30.01.2018","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":998,"Q_Id":50384184,"Users Score":0,"Answer":"The solution is very simple\nto_char(mydate, 'DD-MM-YYYY')\nother types of date formats :\n'DD\/MON\/YYYY'\n'DD\/MON\/YY'\n'MON\/DD\/YYYY'\nu can switch \/ with a - or .","Q_Score":0,"Tags":"python,postgresql","A_Id":50391086,"CreationDate":"2018-05-17T05:51:00.000","Title":"postgres - How to get date format from string date","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to solve a regression problem, where in one of my features can take up two values ('1','0') in the train set but can be valued only '1' in the test data. Intuitively, including this feature seems wrong to me but I am unable to find a concrete logic to support my assumption.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":50385511,"Users Score":0,"Answer":"well, It depends on how many features you have in total. If very few (say less than five), that single feature will most likely play an important role in your classification. In this case, I would say you have \"Data Mismatch\" problem; meaning that your training and test data are coming from different distributions. One simple way to solve it is to put the two sets together, shuffle the whole set, and split your data again.","Q_Score":0,"Tags":"python,machine-learning,regression,data-science,feature-selection","A_Id":50385903,"CreationDate":"2018-05-17T07:15:00.000","Title":"What if a categorical column has multiple values in the train set but only one in test data? Would such a feature be useful in model training at all?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a model with some charField called custom_id.\nI am generating this ID randomly, and check if already exists in database before assigning it.\nSo all my custom_ids are unique.\nHowever if I delete some entry from the database. The custom_id will become available again. I want to prevent that. I want the custom_id not to be ever usable again.\nHow is that possible ? Is there a clean way to achieve that ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":50386923,"Users Score":0,"Answer":"You can write your code in a try-catch block.\nsince the custom_id field is unique, while inserting into DB it will throw integrity error if custom id already exists. \nYou can do whatever you want in catch block custom_id is already exist.","Q_Score":0,"Tags":"python,django","A_Id":50387047,"CreationDate":"2018-05-17T08:37:00.000","Title":"How to ensure some custom ID has not been created already in the past?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can I do more complex if expressions than strict a = b if c else d. Can I string together serial expressions, or nest an if expression inside another if expression?  I cannot find an answer in the docs or online.\nCONTEXT (some of it is only relevant to explain why I am seeking this, rather than another solution):     \n\nI have two scalar variables (a and c) that either have an actual value or are set to -1. If they have a value this is always true c - a = 2 (they are list indexes, for specific items in a list, but the items are not always present. \nIf either a or c has a value other than -1 , then I want to create a third scalar variable b that has a specific value (the value between a and c).\nif neither a nor c has a value, then I want to set b = -1\n\nso would ideally write something like this: \nb = a+1 if a != -1 else c-1 if c != -1 else -1 \nI cannot figure out if this is allowed - legal. And if it is legal, does it get evaluated sequentially? An alternative specification would be hierarchical:\nb = (a+1 if a != -1 else c-1) if (c != -1 or a != -1) else -1 \nIs either of these legal? Advisable? Thanks.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":45,"Q_Id":50387418,"Users Score":2,"Answer":"Just don't.... you should make sure your code is readable and maintainable over making it all fit on one line. So separate it out into multiple different if statements as required or look into refactoring the logic involved.\nAbove all, when you introduce real variable names you'll have trouble trying to make it conform to pep8 standards.","Q_Score":0,"Tags":"python","A_Id":50387472,"CreationDate":"2018-05-17T09:01:00.000","Title":"Nested \/ serial if expressions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't want to check if it has Internet connectivity! I just want to check if it's connected to the WiFi network (I'd have already given its SSID in the WPA_supplicant file).. This network won't have Internet access.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19922,"Q_Id":50388069,"Users Score":0,"Answer":"t=\"$(ifconfig wlan0 | awk '\/inet addr\/{print substr($2,6)}')\"\necho $t\nw=${#t}\necho $w\ni run this code output comes 0.\nif i am running simple is command\nt=\"$(ifconfig wlan0 | awk '\/inet addr\/{print substr($2,6)}')\" echo $t w=${#t} echo $w\noutput comes like w=0 echo","Q_Score":2,"Tags":"python,python-3.x,raspberry-pi,wifi,raspbian","A_Id":68903032,"CreationDate":"2018-05-17T09:33:00.000","Title":"Check status if Raspberry Pi is connected to any WiFi network (Not Internet necessarily) 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":"Hi all I am tried to install the superset on OSX using the Python3. After the installation finished when I tried to add the Database using the mysql:\/\/ it said error No Module name MySQLDb. I tried to explore how to solved this, one of tutorial said try to install mysqlclient using pip3 install mysqlclient failed to install with error code mysql.h not found.\nThan I following another tutorial used the mysql-connector. After I installed it, finally I can connect to mysql DB and insert table to the system. But when I tried to run the analysis from superset it said no data. Also I tried using SQL Lab and got the error args.\nUpdated: on my superset currently I am used the mysql+mysql-connector as URI Database connected properly, but when I tested to run a query it said execute() got an unexpected keyword argument 'args'. How to solve this?\nAnyone have experience with this problem?\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1327,"Q_Id":50389982,"Users Score":0,"Answer":"Finally I got it working now. \nWhat I am doing is reinstall the superset, run the brew install mysql-connector-c than run pip install mysqlclient","Q_Score":0,"Tags":"mysql,python-3.x,mysql-connector,apache-superset","A_Id":50411232,"CreationDate":"2018-05-17T11:10:00.000","Title":"Apache superset on Mac osx","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to train CNN where image-dimension is 128*512, then I want to use this weight file to train other data which has 128*1024 dimension. That means I want to use pre-trained weight file during the training time of different data(128*1024).\nIs it possible or How can I do it?\nI want to do this because I have only 300 images which have 128*1024 dimension, while I have 5000 images which have 128*512 dimension and both datasets are different.\nThank you","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":97,"Q_Id":50392211,"Users Score":1,"Answer":"If your model is fully CNN, there is absolutely no need to have different models. \nA CNN model can take images of any size. Just make sure the input_shape=(None,None,channels)\nYou will need separate numpy arrays though, one for the big images, another for the small images, and you will have to call a different fit method for each.\n(But probably you will be working with a generator anyway)","Q_Score":2,"Tags":"python,keras,deep-learning,convolutional-neural-network","A_Id":50392683,"CreationDate":"2018-05-17T13:04:00.000","Title":"Weight file use for different size image","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed face_recognition model using command\n\npip3 install face_recognition\n\nand it is installed in my AWS instance. But while importing face_recognition in my jupyter notebook it is giving me import error.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":50392373,"Users Score":0,"Answer":"Are you using a python environment? you have to make sure that the python interpreter that is running your code is the same one that has the face_recognition requirement installed.","Q_Score":0,"Tags":"python,amazon-ec2,pip","A_Id":50401446,"CreationDate":"2018-05-17T13:12:00.000","Title":"Not able to use installed libraries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am currently developing a terminal tool which analyse the output of an command. \nI write the tool in python.\nNow I would like to start my tool as an argument within every command, example: python program.py -analyse\nIn this case, python program.py is the command and I would like to start my own project anaylse.py with the argument -analyse which analyse the output from the project and writes its own output to a file. Now my question:\nHow do I get to start my own program analyse.py from the argument -analyse and how can I catch and read the output from python program.py?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":50395613,"Users Score":0,"Answer":"Adding -analyse as an argument will pass it to program.py.  I don't think that is what you are looking for.  I think you are looking for python program.py | python analyse.py.  Then just read the output from stdin.\nThrow #!\/usr\/bin\/python at the top of analyse.py and change the permissions to executable to make it simpler yet: python program.py | analyse.py","Q_Score":0,"Tags":"python,linux,shell,terminal,command","A_Id":50396474,"CreationDate":"2018-05-17T15:45:00.000","Title":"Start own termianl tool as an argument of an command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I get a db record as an sqlalchemy object and I need to consult the original values during some calculation process, so I need the original record till the end. However, the current code modifies the object as it goes and I don't want to refactor it too much at the moment. \nHow can I make a copy of the original data? The deepcopy seems to create a problem, as expected. I definitely prefer not to copy all the fields manually, as someone will forget to update this code when modifying the db object.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1099,"Q_Id":50396458,"Users Score":0,"Answer":"You can have many options here to copy your object.Two of them which I can think of are :\n\nUsing __dict__ it will give the dictionary of the original sqlalchemy object and you can iterate through all the attributes using .keys() function which will give all the attributes.\nYou can also use inspect module and getmembers() to get all the attributes defined and set the required attributes using setattr() method.","Q_Score":1,"Tags":"python,python-2.7,sqlalchemy,copy","A_Id":50397021,"CreationDate":"2018-05-17T16:34:00.000","Title":"how to make a copy of an sqlalchemy object (data only)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to install Hyperledger Sawtooth as per below link but unlike the supported 16.04 version of Ubuntu, I'm using Ubuntu 18.04 LTS that was released earlier this month. Could you please share thoughts on how I can resolve this issue?\nWarm Regards,\nRishi\nRishi@Explorer-Ubuntu:~$ sudo apt-get install -y sawtooth\nReading package lists... Done\nBuilding dependency tree       \nReading state information... Done\nSome packages could not be installed. This may mean that you have\nrequested an impossible situation or if you are using the unstable\ndistribution that some required packages have not yet been created\nor been moved out of Incoming.\nThe following information may help to resolve the situation:\n\nThe following packages have unmet dependencies:\n sawtooth : Depends: python3-sawtooth-cli but it is not going to be installed\n            Depends: python3-sawtooth-intkey but it is not going to be installed\n            Depends: python3-sawtooth-poet-cli but it is not going to be installed\n            Depends: python3-sawtooth-poet-core but it is not going to be installed\n            Depends: python3-sawtooth-poet-families but it is not going to be installed\n            Depends: python3-sawtooth-poet-simulator but it is not going to be installed\n            Depends: python3-sawtooth-rest-api but it is not going to be installed\n            Depends: python3-sawtooth-sdk but it is not going to be installed\n            Depends: python3-sawtooth-settings but it is not going to be installed\n            Depends: python3-sawtooth-signing but it is not going to be installed\n            Depends: python3-sawtooth-validator but it is not going to be installed\n            Depends: python3-sawtooth-xo but it is not going to be installed\nE: Unable to correct problems, you have held broken packages.\nRishi@Explorer-Ubuntu:~$ python3 --version\nPython 3.6.5","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1819,"Q_Id":50396715,"Users Score":1,"Answer":"It seems like Ubuntu 18.04 is not yet supported. Let us wait for Hyperledger to support it.\n\nandroid@baymax:~$ .\/prereqs-ubuntu.sh\nError: Ubuntu bionic is not supported","Q_Score":2,"Tags":"python-3.x,ubuntu,hyperledger,ubuntu-18.04,hyperledger-sawtooth","A_Id":50453538,"CreationDate":"2018-05-17T16:50:00.000","Title":"Hyperledger Sawtooth Install problems on Ubuntu 18.04 LTS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I don't have any struggle with any code or similar, but I wonder, why don't we always have to import everything we use (like for example BoxLayout or GridLayout)? I can use a BoxLayout even without importing it, so my question is: When is it mandatory to import a module and when isn't it really necessary? I couldn't find anything about it on the internet so I thought I could get some information here.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":99,"Q_Id":50397890,"Users Score":1,"Answer":"The reason you could use classes like BoxLayout and GridLayout even without explicitly importing them is because they are parts of the library anyway.\nAs for your question on when is it necessary to explicitly import libraries, I think it's a good programming practice to always do so. This way, you'll be able to avoid confusion in referring to classes or functions.","Q_Score":0,"Tags":"python,import,module,kivy,boxlayout","A_Id":50398080,"CreationDate":"2018-05-17T18:04:00.000","Title":"Why are not all modules imported, but can still be used?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have looked through StackExchange sites, Google, Wikipedia, and all the other usual sources and have been unable to find a good answer to my question.\n\"Does the size in bits matter when seeding a pseudo-random number generator?\nI understand that, in many or most cases, time is used as the seed value but the explanations give for why this is so all deal with it being a useful method of getting a constantly changing seed value. Size does not seem to be an issue.\nI am starting to dig into some crypto related issues and this has piqued my curiosity. As a layman, it would seem that the numbers generated could be easily reproduced through brute force if using, for example, an integer between 1 and 100 as the seed. I have seen 0 and 1 used quite often. Even with time as a random see, it might be brute forced if the starting time could be closely monitored. But brute forcing a random 256 bit number would be pretty tough.\nAm I correct or is there some mechanism unknown to me that makes this a non-issue?\nI will not even pretend to be more than a end-user of others work in this area and understand that my question may be naive. Yet it is something I do not understand and would appreciate some help.\nI am currently working on a project in python 3.x (which is also pretty new to me) so tagged the question with that string but the question is really more generic than a particular languages implementation (I think).","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":982,"Q_Id":50402168,"Users Score":1,"Answer":"The seed is only important from a predictability perspective. This seed has no impact on how \"random\" the numbers are that come out of the PRNG after it's seeded.\nIf you need your numbers to be unpredictable, as in if someone could figure out your seed and generate the same sequence of numbers That Would Be Bad, such as if you were running a casino for real money or generating private keys for cryptography, then you cannot use tiny seeds.\nYou must use unpredictable, highly random sources of \"entropy\" to seed your PRNG. These are often provided by your operating system (e.g. \/dev\/rand) but many cryptographic-grade libraries also provide really good random number generator functions because of how important those functions are.\nThe classic srand(time(NULL)) call, which seeds the PRNG in C with the epoch time in seconds, shows up all over the place. If you can guess what time the program was started at you can determine, precisely, what numbers come out of their generator. You can \"predict\" everything about that PRNG. Since there's only ~2.1 billion possible times, you could even brute-force this. If you know +\/- a few hours it's only a few thousand possibilities to try, making it even more trivial.\nRemember the \"P\" in PRNG stands for \"pseudo\" which means \"fake\". The numbers look random but are procedurally generated and the only way you can prevent people from discovering what those numbers are is by seeding your PRNG properly.","Q_Score":9,"Tags":"python-3.x,random","A_Id":50402204,"CreationDate":"2018-05-18T00:27:00.000","Title":"Does the size of the seed (in bits) for a PRNG make any difference?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have looked through StackExchange sites, Google, Wikipedia, and all the other usual sources and have been unable to find a good answer to my question.\n\"Does the size in bits matter when seeding a pseudo-random number generator?\nI understand that, in many or most cases, time is used as the seed value but the explanations give for why this is so all deal with it being a useful method of getting a constantly changing seed value. Size does not seem to be an issue.\nI am starting to dig into some crypto related issues and this has piqued my curiosity. As a layman, it would seem that the numbers generated could be easily reproduced through brute force if using, for example, an integer between 1 and 100 as the seed. I have seen 0 and 1 used quite often. Even with time as a random see, it might be brute forced if the starting time could be closely monitored. But brute forcing a random 256 bit number would be pretty tough.\nAm I correct or is there some mechanism unknown to me that makes this a non-issue?\nI will not even pretend to be more than a end-user of others work in this area and understand that my question may be naive. Yet it is something I do not understand and would appreciate some help.\nI am currently working on a project in python 3.x (which is also pretty new to me) so tagged the question with that string but the question is really more generic than a particular languages implementation (I think).","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":982,"Q_Id":50402168,"Users Score":2,"Answer":"The size of the seed is important at least in the sense that it is ideally equal to the state length of the PRNG. Although seeds that have been used in common practice are 32 or 64 bits long, such seeds are generally appropriate only if the underlying PRNG's state length is 32 or 64 bits, respectively. Many modern PRNGs have longer state lengths, though. (In general, the greater the variety of seeds, the greater the variety of random number sequences a PRNG can generate.)","Q_Score":9,"Tags":"python-3.x,random","A_Id":50411024,"CreationDate":"2018-05-18T00:27:00.000","Title":"Does the size of the seed (in bits) for a PRNG make any difference?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I work for a company in a department where I have been asked to create a form or document that managers can go into to submit team changes for an employee. employees can support different teams month over month within the business. my goal is to build a form or application in which managers can go in, choose an employee from a given list and select a team name, as well as an effective date of the change. my question is what can i use to build such a tool where i can gather data input and also have it stored somewhere for my reference. the current limitations are that we don't have our own SQL server and because it is a large bank i don't see us being able to create a web page or anything. Any advice?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":54,"Q_Id":50402840,"Users Score":3,"Answer":"There is a lot to unpack from your question.  I've created several apps with forms for CRUD using Flask with SQLite. SQLite is a free and simple one file database with very low maintenance overhead.  Flask is a dead simple to get started yet has many specific packages available to create sophisticated apps.  Tons of documentation and support on the web and youtube.  You can create a prototype on your own machine then use an internal Linux server or better yet, a cloud provider like pythonanywhere.com or digitalocean.com once you want to share your app with others in your company.  I strongly encourage anyone taking this path to learn how to use virtual environment and git\/GitHub before getting started.","Q_Score":1,"Tags":"python,sql,sql-server,python-3.x,forms","A_Id":50403315,"CreationDate":"2018-05-18T02:11:00.000","Title":"How to create an internal web form\/application to gather user input and store it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using a pi3 which talks to an arduino via serial0 (ttyAMA0)\nIt all works fine.  I can talk to it with minicom, bidirectionally.  However, a python based server also wants this port.  I notice when minicom is running, the python code can write to serial0 but not read from it.  At least minicom reports the python server has sent a message.\nCan someone let me know how this serial port handles contention, if at all?  I notice running two minicom session to the same serial port wrecks both sessions.  Is it possible to have multiple writers and readers if they are coordinated not to act at the same time?  Or can there be multiple readers (several terms running cat \/dev\/serial0)\nI have googled around for answers but most hits are about using multiple serial ports or getting a serial port to work at all.\nCheers","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":68,"Q_Id":50404863,"Users Score":1,"Answer":"Since two minicoms can attempt to use the port and there are collisions minicom must not set an advisory lock on local writes to the serial port.  I guess that the first app to read received remote serial message clears it, since serial doesn't buffer.  When a local app writes to serial, minicom displays this and it gets sent.  I'm going to make this assumed summary\n\nwhen a local process puts a message on the serial port everyone can\nsee it and it gets sent to remote. \nwhen a remote message arrives on\nserial, the first local process to get it, gets it.  The others\ncan't see it. \nfor some reason, minicom has privilege over arriving\nmessages.  This is why two minicoms break the message.","Q_Score":0,"Tags":"python,serial-port,raspberry-pi3","A_Id":50575853,"CreationDate":"2018-05-18T06:14:00.000","Title":"basic serial port contention","Data Science and Machine Learning":0,"Database and SQL":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 web application build out of Django version 2.0.1\nA user uploads a file, and based on the content, there are tasks which are executed in a serial fashion. After execution the results are shown to the user. Some of the tasks are independent of each other. \nI want to execute the independent tasks in parallel. I tried using multiprocessing within views.py but there are some errors thrown when the processes are spawned. These tasks analyse some information and write to a file. The files are then combined to show the results to the user.\nThese tasks cannot be done asynchronous as the results produced needs to be shown to the user waiting. So I have dropped the idea of using Celery as recommended in other discussions. \nAnyone's suggestions would be helpful.\nThanks\nError got\nThis was the error we gotTraceback (most recent call last):\n  C:\\Users\\idea\\AppData\\Local\\Enthought\\Canopy\\edm\\envs\\python\\lib\\multiprocessing\\spawn.py\", line 106, in spawn_main\n    exitcode = _main(fd)\n  File \"C:\\Users\\idea\\AppData\\Local\\Enthought\\Canopy\\edm\\envs\\python\\lib\\multiprocessing\\spawn.py\", line 116, in _main\n    self = pickle.load(from_parent)\n  File \"G:\\work\\gitrepo\\suprath-github\\smartdata\\ssd\\FinalPlots\\uploads\\core\\views.py\", line 6, in \n    from uploads.core.models import Document\n  File \"G:\\work\\gitrepo\\suprath-github\\smartdata\\ssd\\FinalPlots\\uploads\\core\\models.py\", line 7, in \n    class Document(models.Model):\n  File \"C:\\Users\\idea\\AppData\\Local\\Enthought\\Canopy\\edm\\envs\\python\\lib\\site-packages\\django\\db\\models\\base.py\", line 100, in new\n    app_config = apps.get_containing_app_config(module)\n  File \"C:\\Users\\idea\\AppData\\Local\\Enthought\\Canopy\\edm\\envs\\python\\lib\\site-packages\\django\\apps\\registry.py\", line 244, in get_containing_app_config\n    self.check_apps_ready()\n  File \"C:\\Users\\idea\\AppData\\Local\\Enthought\\Canopy\\edm\\envs\\python\\lib\\site-packages\\django\\apps\\registry.py\", line 127, in check_apps_ready\n    raise AppRegistryNotReady(\"Apps aren't loaded yet.\")\ndjango.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.\nTraceback (most recent call last):","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":643,"Q_Id":50405413,"Users Score":2,"Answer":"These tasks cannot be done asynchronous as the results produced needs to be shown to the user waiting\n\nThat doesn't mean you can't use an async queue (celery or other). We have a very similar use case and do use celery to run the tasks. The tasks (part parallel, part serial) store their progress in redis, and the frontend polls to get the current state and display progress to the user, then when the whole process is done (either successfuly or not) we display the result (or errors).","Q_Score":1,"Tags":"python,django,python-multiprocessing","A_Id":50406016,"CreationDate":"2018-05-18T06:52:00.000","Title":"Django: running a few tasks in parallel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a web application build out of Django version 2.0.1\nA user uploads a file, and based on the content, there are tasks which are executed in a serial fashion. After execution the results are shown to the user. Some of the tasks are independent of each other. \nI want to execute the independent tasks in parallel. I tried using multiprocessing within views.py but there are some errors thrown when the processes are spawned. These tasks analyse some information and write to a file. The files are then combined to show the results to the user.\nThese tasks cannot be done asynchronous as the results produced needs to be shown to the user waiting. So I have dropped the idea of using Celery as recommended in other discussions. \nAnyone's suggestions would be helpful.\nThanks\nError got\nThis was the error we gotTraceback (most recent call last):\n  C:\\Users\\idea\\AppData\\Local\\Enthought\\Canopy\\edm\\envs\\python\\lib\\multiprocessing\\spawn.py\", line 106, in spawn_main\n    exitcode = _main(fd)\n  File \"C:\\Users\\idea\\AppData\\Local\\Enthought\\Canopy\\edm\\envs\\python\\lib\\multiprocessing\\spawn.py\", line 116, in _main\n    self = pickle.load(from_parent)\n  File \"G:\\work\\gitrepo\\suprath-github\\smartdata\\ssd\\FinalPlots\\uploads\\core\\views.py\", line 6, in \n    from uploads.core.models import Document\n  File \"G:\\work\\gitrepo\\suprath-github\\smartdata\\ssd\\FinalPlots\\uploads\\core\\models.py\", line 7, in \n    class Document(models.Model):\n  File \"C:\\Users\\idea\\AppData\\Local\\Enthought\\Canopy\\edm\\envs\\python\\lib\\site-packages\\django\\db\\models\\base.py\", line 100, in new\n    app_config = apps.get_containing_app_config(module)\n  File \"C:\\Users\\idea\\AppData\\Local\\Enthought\\Canopy\\edm\\envs\\python\\lib\\site-packages\\django\\apps\\registry.py\", line 244, in get_containing_app_config\n    self.check_apps_ready()\n  File \"C:\\Users\\idea\\AppData\\Local\\Enthought\\Canopy\\edm\\envs\\python\\lib\\site-packages\\django\\apps\\registry.py\", line 127, in check_apps_ready\n    raise AppRegistryNotReady(\"Apps aren't loaded yet.\")\ndjango.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.\nTraceback (most recent call last):","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":643,"Q_Id":50405413,"Users Score":0,"Answer":"I agree with the solution provided by @bruno desthuillieres, however, you can implement some socket solution to reach back to the user.\nSince polling from user may have huge performance impacts, the socket solution will ideal for this case.","Q_Score":1,"Tags":"python,django,python-multiprocessing","A_Id":50420302,"CreationDate":"2018-05-18T06:52:00.000","Title":"Django: running a few tasks in parallel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I need to perform image recognition thing on real time camera feed. The video is embedded in shtml hosted on a IP. How do I access the video and process things using openCV.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":378,"Q_Id":50406354,"Users Score":0,"Answer":"First,you need to find the actual path to camera stream. It is mjpeg or rtsp stream. Use developer option in this page to find the stream, like http:\/\/ip\/video.mjpg or rtsp:\/\/ip\/live.sdp. When you find the stream url,create python script which will use stream like capture = cv2.VideoCapture(stream_url). But,as noticed,this is too broad which mean you are asking for full tutorial. This is some directions,and when you have some code,ask a question about issues with your code and you'll get an answer.","Q_Score":0,"Tags":"python,opencv,camera,video-streaming","A_Id":50410930,"CreationDate":"2018-05-18T07:49:00.000","Title":"How do I capture a live IP Camera feed (eg: http:\/\/61.60.112.230\/view\/viewer_index.shtml?id=938427) to python application?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've searched everywhere for a solution to this problem but I haven't found it yet. \nI know that Autodesk Inventor can be automated with Python using win32com package by:\nwin32com.client.Dispatch(\"Inventor.Application\")\nHowever I can't find the \"prodID\" that is needed to use this package with Fusion 360 and no documentation for automation ever being done this way with this package.\nI need to be able to control a range of other processes so it would be ideal if I could use Python to launch Fusion 360 and perform operations without having to load the script within the application itself. Any help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":302,"Q_Id":50411526,"Users Score":0,"Answer":"The Fusion 360 API is not a COM API so it's not possible to use win32com to drive it.   To use the API, your program must be either an add-in or script running from within Fusion 360.","Q_Score":0,"Tags":"python,api,win32com,autodesk,fusion360","A_Id":51386354,"CreationDate":"2018-05-18T12:37:00.000","Title":"Python to Automate Fusion 360 with 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":0,"Web Development":0},{"Question":"I have a CNN trained on a classification task (Network is simple, 2 convolution + pooling layers and 2x fully connected layers). I would like to use this to reconstruct an image if I input a classification label. \nIs this possible to achieve? \nIs it possible to share weights between corresponding layers in the 2 networks?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":50412204,"Users Score":0,"Answer":"You should have a look to cGAN implementation and why not DeepDream from Google ;)\nThe answer is yes it is possible, however it's not straight forward","Q_Score":0,"Tags":"python,tensorflow,convolutional-neural-network,deconvolution","A_Id":50412247,"CreationDate":"2018-05-18T13:15:00.000","Title":"Reconstructing a classified image from a simple Convolution Neural Network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am coming from a C++ programming background and am wondering if there is a pass by reference equivalent in python. The reason I am asking is that I am passing very large arrays into different functions and want to know how to do it in a way that does not waste time or memory by having copy the array to a new temporary variable each time I pass it. It would also be nice if, like in C++, changes I make to the array would persist outside of the function.\nThanks in advance,\nJared","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":507,"Q_Id":50414041,"Users Score":4,"Answer":"Python handles function arguments in the same manner as most common languages: Java, JavaScript, C (pointers), C++ (pointers, references).\nAll objects are allocated on the heap.  Variables are always a reference\/pointer to the object.  The value, which is the pointer, is copied.  The object remains on the heap and is not copied.","Q_Score":0,"Tags":"python,python-3.x","A_Id":50414131,"CreationDate":"2018-05-18T14:53:00.000","Title":"Effective passing of large data to python 3 functions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed a specific version of python with pyenv. When typed pyenv version in terminal, i see 3.5.0 (set by \/Users\/lcherukuri\/.python-version). But when I typed python3, I got python3 command not found. How to fix this? pip3 is Also not found","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":14202,"Q_Id":50417434,"Users Score":1,"Answer":"I had the python3 in path. I also executed pyenv global 2.x.x 3.x.x. But I still got the same error.\nWhat eventually worked for me is executing this line in the project root (with whichever version replacing 3.X.X)\npyenv shell 3.X.X\nNote: This sets the shell specific python version so it's not really a solution to the problem posted. Just a workaround to get python3 working.","Q_Score":9,"Tags":"python,pip,pyenv","A_Id":64914310,"CreationDate":"2018-05-18T18:39:00.000","Title":"python3 command not found after installing python with pyenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to convert the kitti dataset into the tensorflow .record. After I typed the command:\n\npython object_detection\/dataset_tools\/create_kitti_tf_record.py \n  --lable_map_path=object_detection\/data\/kitti_label_map.pbtxt  --data_dir=\/Users\/zhenglyu\/Graduate\/research\/DataSet\/kitti\/data_object_image_2\/testing\/image_2\n  --output_path=\/Users\/zhenglyu\/Graduate\/research\/DataSet\/kitti2tf\/train.record\n  validation_set_size=1000\n\nI got this error:\n\nTraceback (most recent call last):   File\n  \"object_detection\/dataset_tools\/create_kitti_tf_record.py\", line 310,\n  in \n      tf.app.run()   File \"\/Users\/zhenglyu\/tensorflow\/lib\/python3.6\/site-packages\/tensorflow\/python\/platform\/app.py\",\n  line 126, in run\n      _sys.exit(main(argv))   File \"object_detection\/dataset_tools\/create_kitti_tf_record.py\", line 307,\n  in main\n      validation_set_size=FLAGS.validation_set_size)   File \"object_detection\/dataset_tools\/create_kitti_tf_record.py\", line 94,\n  in convert_kitti_to_tfrecords\n      label_map_dict = label_map_util.get_label_map_dict(label_map_path)   File\n  \"\/Users\/zhenglyu\/Graduate\/research\/TensorFlow\/model\/research\/object_detection\/utils\/label_map_util.py\",\n  line 152, in get_label_map_dict\n      label_map = load_labelmap(label_map_path)   File \"\/Users\/zhenglyu\/Graduate\/research\/TensorFlow\/model\/research\/object_detection\/utils\/label_map_util.py\",\n  line 132, in load_labelmap\n      label_map_string = fid.read()   File \"\/Users\/zhenglyu\/tensorflow\/lib\/python3.6\/site-packages\/tensorflow\/python\/lib\/io\/file_io.py\",\n  line 120, in read\n      self._preread_check()   File \"\/Users\/zhenglyu\/tensorflow\/lib\/python3.6\/site-packages\/tensorflow\/python\/lib\/io\/file_io.py\",\n  line 80, in _preread_check\n      compat.as_bytes(self.name), 1024 * 512, status)   File \"\/Users\/zhenglyu\/tensorflow\/lib\/python3.6\/site-packages\/tensorflow\/python\/framework\/errors_impl.py\",\n  line 519, in __exit\n      c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.NotFoundError:\n  data\/kitti_label_map.pbtxt; No such file or directory\n\nThe file exists for sure. And I don't know why as I set the label_map_path to another one (object_detection\/data\/kitti_label_map.pbtxt), the path still remains the default setting (data\/kitti_label_map.pbtxt).\nI know there's a lot of related problem but none of the solutions that I found works for me. I used Virtualenv to install the tensorflow and using python 3.6. Could these be the problem? Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4898,"Q_Id":50417709,"Users Score":0,"Answer":"I don't have a definitive solution to this but here is what resolved it.\nFirst, I copied the kitti_label_map.pbtxt into the data_dir. Then I also copied create_kitti_tf_record.py into the data_dir. And now I copied(this is what made it run in the end) the name and absolute path of the kitti_label_map.pbtxt and pasted it as label_map_path\nI have no idea why but it worked.","Q_Score":1,"Tags":"python,python-3.x,tensorflow","A_Id":52691471,"CreationDate":"2018-05-18T18:57:00.000","Title":"tensorflow.python.framework.errors_impl.NotFoundError: data\/kitti_label_map.pbtxt; No such file or directory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What happens to slave widgets when the parent widget is destroyed?\nHow can we faster remove all references on objects related with GUI after calling my_gui.destroy() in python tkinter?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":30,"Q_Id":50420219,"Users Score":1,"Answer":"The references stay around according to the normal python rules. The underlying widget objects are all destroyed when the root window is destroyed.","Q_Score":0,"Tags":"python,python-3.x,tkinter","A_Id":50420419,"CreationDate":"2018-05-18T22:58:00.000","Title":"what happen with references on gui objects when the root is destroyed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to fix this FFMPEG command to record audio.\nI have tried using the parts recommended on the official stackoverflow site but they didn't work\nOrignal Command\nffmpeg_stream = '\/usr\/bin\/ffmpeg -f x11grab -s 1280x720 -r 24 -i :%d+nomouse -c:v libx264 -preset superfast -pix_fmt yuv420p -s 1280x720 -threads 0 -f flv \"%s\"' % (xvfb.new_display, info['destination'])\nCommand with attempted audio\nffmpeg_stream = '\/usr\/bin\/ffmpeg -f x11grab -s 1280x720 -r 24 -i :%d+nomouse -c:v libx264 -preset superfast -pix_fmt yuv420p -s 1280x720 -threads 0 -f alsa -ac 2 -i hw:0 -f flv \"%s\"' % (xvfb.new_display, info['destination'])","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":50421185,"Users Score":0,"Answer":"FFmpeg expects a specific arrangement in command line: all inputs first followed by outputs.\nSo,\nffmpeg_stream = '\/usr\/bin\/ffmpeg -f x11grab -video_size 1280x720 -framerate 24 -i :%d+nomouse -f alsa -channels 2 -i hw:0 -c:v libx264 -preset superfast -pix_fmt yuv420p -f flv \"%s\"' % (xvfb.new_display, info['destination']","Q_Score":0,"Tags":"python,ffmpeg","A_Id":50422511,"CreationDate":"2018-05-19T02:13:00.000","Title":"How to fix this FFMPEG command to record audio as well?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Hi I want to set  filter on field date where the value of date field should within 24 hours.\n<filter name=\"date\" string=\"Scheduled Date\" domain=\"[('date', '&gt;=', datetime.datetime.now().strftime('%Y-%m-%d 00:00:00')),('date', '&lt;=', datetime.datetime.now().strftime('%Y-%m-%d 23:23:59'))]\"\/>\nI tried this one, but this retrieves only the data where the date field contains today's date\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":594,"Q_Id":50423340,"Users Score":1,"Answer":"For this you can also use schedule action. Within scheduler action you can define you method with appropriate setting.","Q_Score":1,"Tags":"xml,python-2.7,odoo,odoo-10","A_Id":50522243,"CreationDate":"2018-05-19T08:30:00.000","Title":"How to set filter on a field to get data within 24 hours?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to make a program which will differentiate a function, but I have no idea how to do this. I've only made a part which transforms the regular expression(x ^ 2 + 2 for example ) into reverse polish notation. Can anybody help me with creating a program which will a find symbolic derivatives of expression with + * \/ - ^","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1646,"Q_Id":50424344,"Users Score":1,"Answer":"Hint: Use a recursive routine. If an operation is unary plus or minus, leave the plus or minus sign alone and continue with the operand. (That means, recursively call the derivative routine on the operand.) If an operation is addition or subtraction, leave the plus or minus sign alone and recursively find the derivative of each operand. If the operation is multiplication, use the product rule. If the operation is division, use the quotient rule. If the operation is exponentiation, use the generalized power rule. (Do you know that rule, for u ^ v? It is not given in most first-year calculus books but is easy to find using logarithmic differentiation.) (Now that you have clarified in a comment that there will be no variable in the exponent, you can use the regular power rule (u^n)' = n * u^(n-1) * u' where n is a constant.) And at the base of the recursion, the derivative of x is 1 and the derivative of a constant is zero.\nThe result of such an algorithm would be very un-simplified but it would meet your stated requirements. Since this algorithm looks at an operation then looks at the operands, having the expression in Polish notation may be simpler than reverse Polish or \"regular expression.\" But you could still do it for the expression in those forms.\nIf you need more detail, show us more of your work.","Q_Score":0,"Tags":"python,math","A_Id":50424748,"CreationDate":"2018-05-19T10:36:00.000","Title":"How to find symbolic derivative using python without sympy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a task that involves quite a few images and text data and I need to write them into an RTF file in Python. \nIs that possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":458,"Q_Id":50424879,"Users Score":0,"Answer":"Using Spyder-iPython, print your text and plot all your graphs and images; then, right-click from the console where the text and graphs are and do Save As HTML\/XML (select inline). Everything will be exported as an HTML file that you can load with any text editor, MS Word, LibreOffice Writer, etc.\nEnjoy!","Q_Score":1,"Tags":"python-3.x,image,text,rtf","A_Id":50425759,"CreationDate":"2018-05-19T11:39:00.000","Title":"Exporting image and text data to RTF file in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting the API response from the URL as follows : \nI am not sure what encoding scheme is used. I am not sure how to check this and decode the string. I tried base64 decode and its not the one. \nTo give you a background : \nI used Packet Capture App to capture the request sent by the APP and the response. So there was no API documentation. \n\nF\/VDFb\/tLplCXIgvPGlpppHawetuV1a5DtWOtmO1ZkQGN1sV8hZmieyIbMC7pjj4wh81IrsWFmOWJZBtmRmHnu\/Y\/c4lR9EXXAmO2h8hcB6W+ls6cE9S7GFun1lYw2EPBXzxJ+ST2HPaBMsjulnxTJjqftkSf\/tOPJBXTQSjrxJqHpUAMfey5qpu8V\/cZ\/uFEhy5JmpNOZVtoKh+M3YPmKzc88XZS22+35It8HW7CXmzD1UHFE6tmNa3lfFfemqfQU+GMtga0pvU6c+0L1lJTY1HoH64Nf2u4xQ3nidT24ap6NUU4SOi3wg6VqLtSLaVwMWNuXcQmgoW5edj3L\/ThGKGmq7ZVFKYO7InGhfxunNhTBbDB8QYxhDZ0GuyC+0pJXyGfcD0HItfeqnIJYqkr3uOaJVaGs\/\/wyF2Q\/RBivSvyXf9yRM8kvBIoNH\/784XqIEwWnCH5Cqpn\/Cvq\/\/ktTz6Gs\/atSfP+G5TdcNJ0hf3vDZ4Zle04vsDCGxREp83Wy\/MIVN8apRpa5dJCFp0KC5SY3X5miO0Nq7UnGZkBl2zcVb9+ZKlVqgjr1hA1SCzQIArdae2rP14CqTZqP9HNs4DJGvYwYDwnDL4njf5rX9uzIJN5Xdm\/+r6bN6I2\/IZXRXIj2JU9x8VQFOlTCygR+rCVVkOUZNww0fF6MG3NCc\\u003d\n\nAny help in this regard would be really helpful","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":278,"Q_Id":50427125,"Users Score":1,"Answer":"It is Base64, the error is the last character \"\\u003d\" which is a UTF-16 \"=\", replace \"\\u003d\"' with \"=\" and it decodes properly to binary. Trailing Base64 encoded \"=\"characters are padding.\nSince it decode as Base64 and the trailing \"=\" character it sure seems to be Base64 encoded data.\nThe Base64 decoded binary in a hex representation is:\n        17F54315BFED2E99425C882F3C6969A691DAC1EB6E5756B90ED58EB663B5664406375B15F2166689EC886CC0BBA638F8C21F3522BB1616639625906D9919879EEFD8FDCE2547D1175C098EDA1F21701E96FA5B3A704F52EC616E9F5958C3610F057CF127E493D873DA04CB23BA59F14C98EA7ED9127FFB4E3C90574D04A3AF126A1E950031F7B2E6AA6EF15FDC67FB85121CB9266A4D39956DA0A87E33760F98ACDCF3C5D94B6DBEDF922DF075BB0979B30F5507144EAD98D6B795F15F7A6A9F414F8632D81AD29BD4E9CFB42F59494D8D47A07EB835FDAEE314379E2753DB86A9E8D514E123A2DF083A56A2ED48B695C0C58DB977109A0A16E5E763DCBFD38462869AAED95452983BB2271A17F1BA73614C16C307C418C610D9D06BB20BED29257C867DC0F41C8B5F7AA9C8258AA4AF7B8E68955A1ACFFFC3217643F4418AF4AFC977FDC9133C92F048A0D1FFEFCE17A881305A7087E42AA99FF0AFABFFE4B53CFA1ACFDAB527CFF86E5375C349D217F7BC36786657B4E2FB03086C51129F375B2FCC21537C6A94696B9749085A74282E526375F99A23B436AED49C6664065DB37156FDF992A556A823AF5840D520B340802B75A7B6ACFD780AA4D9A8FF4736CE03246BD8C180F09C32F89E37F9AD7F6ECC824DE57766FFEAFA6CDE88DBF2195D15C88F6254F71F154053A54C2CA047EAC255590E519370C347C5E8C1B73427\nTo me that looks like random data which is what encrypted data looks like, if so without the decryption key you will not be able to further decrypt it. It is 512 bytes in length which is multiple of common encryption block sizes.","Q_Score":0,"Tags":"python,json,encryption,base64,decode","A_Id":50427755,"CreationDate":"2018-05-19T16:04:00.000","Title":"How to check the Encoding scheme on the API response","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a django application and a mysql database table having around 30,000 entries. \nI have to process each entry one by one, do some computation and store the result   in database.\nWhen I start processing, the time taken to process 100 entries is around 40 seconds. But this time keeps on growing. So after processing 1000 entries, the time goes to 1 minute, then after processing 2000 entries, the time to compute 100 entries move to 1 minute 30 seconds. \nIf I stop the server, and start computing again from say 2000th entry, then the time taken to process 100 entries becomes 40 seconds again, but keeps on increasing as more entries are processed.\nDoes anyone know why is this happening?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":50429609,"Users Score":0,"Answer":"Sounds like you need an index.\nDon't process one row at a time; use SQL to process all rows 'simultaneously'.  Describe the processing; we may be able to get more specific.","Q_Score":0,"Tags":"python,mysql,django,performance","A_Id":50498291,"CreationDate":"2018-05-19T21:23:00.000","Title":"Django queries gets slower over time","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have an array of integers(nodes or destinations) i.e array[2,3,4,5,6,8] that need to be visited in the given sequence.\nWhat I want is, to get the shortest distance using pgr_dijkstra. But the pgr_dijkstra finds the shortest path for two points, therefore I need to find the distance of each pair using pgr_dijkstra and adding all distances to get the total distance.\nThe pairs will be like\n2,3\n3,4 \n4,5 \n5,6 \n6,8.\nIs there any way to define a function that takes this array and finds the shortest path using pgr_dijkstra.\nQuery is:\nfor 1st pair(2,3)\nSELECT * FROM pgr_dijkstra('SELECT gid as id,source, target, rcost_len AS cost FROM finalroads',2,3, false);\nfor 2nd pair(3,4)\nSELECT * FROM pgr_dijkstra('SELECT gid as id,source, target, rcost_len AS cost FROM finalroads'***,3,4,*** false)\nfor 3rd pair(4,5)\nSELECT * FROM pgr_dijkstra('SELECT gid as id,source, target, rcost_len AS cost FROM finalroads'***,4,5,*** false);\nNOTE: The array size is not fixed, it can be different.\nIs there any way to automate this in postgres sql may be using a loop etc?\nPlease let me know how to do it.\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":708,"Q_Id":50429760,"Users Score":0,"Answer":"If you want all pairs distance then use\nselect * from pgr_apspJohnson ('SELECT gid as id,source, target, rcost_len AS cost FROM finalroads)","Q_Score":1,"Tags":"mysql,sql,postgresql,mysql-python,pgrouting","A_Id":51161622,"CreationDate":"2018-05-19T21:46:00.000","Title":"how to get the distance of sequence of nodes in pgr_dijkstra pgrouting?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question about performance.\nIf I have a case when I pass a mutable object to a function and I make changes to that object, I know that in python it will change the value and all the pointers will point to the value that has been changed.\nBut what is the right way to write code?\nShould I use the return statement and assign all over again the pointer to the output of the function to show to the one that reads the code that it is being changed?\nHow hard is it hurting the performance if you preform an assignment of a pointer to the same memory it is already pointing?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":885,"Q_Id":50430543,"Users Score":4,"Answer":"a) It has no significant effect on the performance.\nb) If your function takes a object and changes it, this is a side-effect and you should therefore not return that object. That would be confusing and misleading as it implies that the input is different from the output.\nc) If you think you should write code that is useless just to provide information to readers of your code, use comments instead.","Q_Score":2,"Tags":"python,python-3.x","A_Id":50430593,"CreationDate":"2018-05-20T00:03:00.000","Title":"Returning a mutable object","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Should sys.argv for checking command line arguments be done in the beginning of a script, after the import statements? \nIs it acceptable to check for a command line argument anywhere but the start of a script? I couldn't find it in PEP8.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":643,"Q_Id":50430795,"Users Score":4,"Answer":"PEP8 is about code style, not the algorithms that code implements. It's completely up to you.\nMore often that not, a program needs the result of its command line parsing early so that it knows what to do. If the command line includes logging options, you probably need it ASAP 'cuz you need to set up logging ASAP to, like, log any unhandled exceptions that can occur anywhere -- or you won't know about them ifwhen they happen!\nThat's the sole reason why command line is usually parsed early.","Q_Score":1,"Tags":"python,command-line-arguments","A_Id":50430863,"CreationDate":"2018-05-20T00:55:00.000","Title":"When to parse command line in a Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Through carelessness, I have two Anaconda install locations: one on C:\\Anaconda3\\ (on a smallish SSD with Windows 10 installed) and one on X:\\Anaconda3\\ (on a large HDD with no OS installed), and I would like to keep the one on X as my only installation. I have X:\\Anaconda3, X:\\Anaconda3\\Scripts, and X:\\Anaconda3\\Library\\bin folders in my PATH.\nI've noticed is that I can't used any conda commands with my X:\\ installation in the PATH variable. I get the usual \"conda is not a recognized command\" error. But if I change the drive of the folders in PATH to C:\\, suddenly everything works great. I've also tried making my current directory be on X:\\ while running these commands, and conda still doesn't work.\nHow might I fix this issue? There must be something I'm missing about how the PATH variable or the conda command works. Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1688,"Q_Id":50431294,"Users Score":0,"Answer":"@abarnert Thanks to you I managed to find the issue.\nOn looking into both install paths, I found that only the C:\\ installation had C:\\Anaconda3\\Scripts\\conda.exe. The X:\\ installation had C:\\Anaconda3\\Scripts\\conda.exe.c~. I still don't know what that file's for, but I assume it pointed to the conda.exe on C:. Anyway, a complete uninstall of both locations followed by a fresh install on X:\\ got everything to work. I can now run commands like conda env list and similar using the installation on X:\\\nThanks again!","Q_Score":0,"Tags":"python,windows,path,anaconda,conda","A_Id":50435723,"CreationDate":"2018-05-20T03:03:00.000","Title":"Anaconda3 Custom Install Location: 'conda' Not Working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting an below error while running manage.py run server.\nDirectory: C:\\Users\\home\\Desktop\\website_dj>ls\n557 manage.py\nPS C:\\Users\\home\\Desktop\\website_dj> python manage.py runserver\nImportError: No module named 'website_dj'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":50432712,"Users Score":0,"Answer":"Have you registered 'website_dj' in your installed apps in settings.py?","Q_Score":0,"Tags":"python,django,powershell,pycharm","A_Id":50435928,"CreationDate":"2018-05-20T07:44:00.000","Title":"ImportError: No module named \"webisite_dj\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am starting my own Django-Oscar project, and am wondering about the possibility of changing the location of the 'oscar'-directory (containing all apps, a models.py etc), moving it from the default on-installation site-packages directory within my virtual environment - into my project root directory. \nWould it be possible to simply copy the 'oscar'-directory, and paste it into a new location, assuming I also change the locations of the 'INSTALLED_APPS', and make sure that my project-structure is the same (i.e. not changing things like the directory-name 'oscar' so that imports etc break)? If so, would that mean that I could delete it all together from site-packages (DRY-solution)? \nThis would mimic the sandbox-installation, and would be a set up I'd feel more comfortable with as a beginner who needs visible overhead. \nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":50433131,"Users Score":1,"Answer":"Yes, you can do that. Although, it's not recommended, because then it'd be harder for you to incorporate latest oscar changes into your project, and it's not the recommended way to customize \/ extend oscar functionality.\nInstead of deleting oscar from site-packages you should rather pip uninstall django-oscar.\nAlso, it's possible to have oscar installed, as well as copied into your project directory at the same time. By Python defaults, the one in your project directory would be the one that will get imported (instead of the installed). This way, you can have the comfort of working with it locally. I sometimes do this so that I can safely test certain django apps (like oscar) with minor changes (in development environment), but not having to commit \/ push these changes into a production environment mostly because it's easier this way than following recommended methods to extend the app.","Q_Score":1,"Tags":"python,django,django-oscar,site-packages","A_Id":50437287,"CreationDate":"2018-05-20T08:47:00.000","Title":"Django: Moving 'oscar' site-package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"After spark installation 2.3 and setting the following env variables in .bashrc (using gitbash)\n\nHADOOP_HOME\nSPARK_HOME\nPYSPARK_PYTHON\nJDK_HOME\n\nexecuting $SPARK_HOME\/bin\/spark-submit is displaying the following error.\n\nError: Could not find or load main class org.apache.spark.launcher.Main\n\nI did some research checking in stackoverflow and other sites, but could not figure out the problem.\nExecution environment\n\nWindows 10 Enterprise\nSpark version - 2.3\nPython version - 3.6.4\n\nCan you please provide some pointers?","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":10707,"Q_Id":50435286,"Users Score":4,"Answer":"I had that error message. It probably may have several root causes but this how I investigated and solved the problem (on linux): \n\ninstead of launching spark-submit, try using bash -x spark-submit to see which line fails.\ndo that process several times ( since spark-submit calls nested scripts ) until you find the underlying process called : in my case something like : \n\n\/usr\/lib\/jvm\/java-8-openjdk-amd64\/jre\/bin\/java -cp '\/opt\/spark-2.2.0-bin-hadoop2.7\/conf\/:\/opt\/spark-2.2.0-bin-hadoop2.7\/jars\/*' -Xmx1g org.apache.spark.deploy.SparkSubmit --class org.apache.spark.repl.Main --name 'Spark shell' spark-shell\nSo, spark-submit launches a java process and can't find the org.apache.spark.launcher.Main class using the files in \/opt\/spark-2.2.0-bin-hadoop2.7\/jars\/* (see the -cp option above). I did an ls in this jars folder and counted 4 files instead of the whole spark distrib (~200 files).\nIt was probably a problem during the installation process. So I reinstalled spark, checked the jar folder and it worked like a charm.\nSo, you should:\n\ncheck the java command (cp option)\ncheck your jars folder ( does it contain ths at least all the spark-*.jar ?)\n\nHope it helps.","Q_Score":3,"Tags":"python,apache-spark,windows-10","A_Id":50588237,"CreationDate":"2018-05-20T13:23:00.000","Title":"Spark installation - Error: Could not find or load main class org.apache.spark.launcher.Main","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"After spark installation 2.3 and setting the following env variables in .bashrc (using gitbash)\n\nHADOOP_HOME\nSPARK_HOME\nPYSPARK_PYTHON\nJDK_HOME\n\nexecuting $SPARK_HOME\/bin\/spark-submit is displaying the following error.\n\nError: Could not find or load main class org.apache.spark.launcher.Main\n\nI did some research checking in stackoverflow and other sites, but could not figure out the problem.\nExecution environment\n\nWindows 10 Enterprise\nSpark version - 2.3\nPython version - 3.6.4\n\nCan you please provide some pointers?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":10707,"Q_Id":50435286,"Users Score":0,"Answer":"Check Spark home directory contained all folder and files(xml, jars etc.) otherwise install Spark.\nCheck your JAVA_HOME and SPARK_HOME environment variable are set in your .bashrc file, try setting the below:\n\n\nexport JAVA_HOME=\/usr\/lib\/jvm\/java-8-openjdk-amd64\/\n\n\nexport SPARK_HOME=\/home\/ubuntu-username\/spark-2.4.8-bin-hadoop2.6\/\n\nOr wherever your spark is downloaded to\n\nexport SPARK_HOME=\/home\/Downloads\/spark-2.4.8-bin-hadoop2.6\/\n\nonce done, save your .bash and run bash command on terminal or restart the shell and try spark-shell","Q_Score":3,"Tags":"python,apache-spark,windows-10","A_Id":68046423,"CreationDate":"2018-05-20T13:23:00.000","Title":"Spark installation - Error: Could not find or load main class org.apache.spark.launcher.Main","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"After spark installation 2.3 and setting the following env variables in .bashrc (using gitbash)\n\nHADOOP_HOME\nSPARK_HOME\nPYSPARK_PYTHON\nJDK_HOME\n\nexecuting $SPARK_HOME\/bin\/spark-submit is displaying the following error.\n\nError: Could not find or load main class org.apache.spark.launcher.Main\n\nI did some research checking in stackoverflow and other sites, but could not figure out the problem.\nExecution environment\n\nWindows 10 Enterprise\nSpark version - 2.3\nPython version - 3.6.4\n\nCan you please provide some pointers?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":10707,"Q_Id":50435286,"Users Score":0,"Answer":"Verify below steps :\n\nspark-launcher_*.jar is present at $SPARK_HOME\/jars folder?\nexplode spark-launcher_*.jar to verify if you have Main.class or not.\n\nIf above is true then you may be running spark-submit on windows OS using cygwin terminal.\nTry using spark-submit.cmd instead also cygwin parses the drives like \/c\/ and this will not work in windows so its important to provide the absolute path for the env variables by qualifying it with 'C:\/' and not '\/c\/'.","Q_Score":3,"Tags":"python,apache-spark,windows-10","A_Id":69961052,"CreationDate":"2018-05-20T13:23:00.000","Title":"Spark installation - Error: Could not find or load main class org.apache.spark.launcher.Main","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Typically when using rubygems in the ruby ecosystem or npm\/yarn in the JavaScript ecosystem packages are installed somewhere on the $PATH or at least you are instructed to add the package install location to your path $PATH.\nIt seems like with pip in the python ecosystem there is never an emphasis on this. Instead, you are encouraged to run modules via python -m <name>, etc.\nSeems a bit odd to me, was this just a design decision? Is it good practice to put site-packages or whatever location pip is using into $PATH? Sometimes a binary is added to \/usr\/local\/bin (and sometimes with a different name than the package itself e.g django-admin instead of django with pip install Django whereas the binary is usually the same as the package name in ruby\/JavaScript ecosystems), for example, I see, but is that all of the time?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":4966,"Q_Id":50437251,"Users Score":2,"Answer":"The site-packages directory for a particular python installation is automatically added to sys.path when you run the binary for the installation.  When that binary executes import modname, it looks in the directories on sys.path.  So when you run pip install with a particular python binary, pip, by default, puts the package in the site-packages for that binary so that binary can import the package.  Advanced used can do more complicated things.","Q_Score":3,"Tags":"python,path,pip,environment,package-managers","A_Id":50437417,"CreationDate":"2018-05-20T16:53:00.000","Title":"Why are pip packages not installed to $PATH to by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Typically when using rubygems in the ruby ecosystem or npm\/yarn in the JavaScript ecosystem packages are installed somewhere on the $PATH or at least you are instructed to add the package install location to your path $PATH.\nIt seems like with pip in the python ecosystem there is never an emphasis on this. Instead, you are encouraged to run modules via python -m <name>, etc.\nSeems a bit odd to me, was this just a design decision? Is it good practice to put site-packages or whatever location pip is using into $PATH? Sometimes a binary is added to \/usr\/local\/bin (and sometimes with a different name than the package itself e.g django-admin instead of django with pip install Django whereas the binary is usually the same as the package name in ruby\/JavaScript ecosystems), for example, I see, but is that all of the time?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4966,"Q_Id":50437251,"Users Score":2,"Answer":"You're confusing $PATH and $PYTHONPATH. site-packages is for libraries,  $PATH is for programs (binaries and scripts). pip installs libraries into its site-packages and scripts to the corresponding bin\/ directory; e.g. if site-packages is \/usr\/local\/lib\/pythonX.Y\/site-packages scripts are installed into \/usr\/local\/bin\/.\npip doesn't check if \/usr\/local\/bin\/is in $PATH. Well, I agree with you \u2014 it should check and remind user to add bin\/ directory to $PATH if it's not already there.","Q_Score":3,"Tags":"python,path,pip,environment,package-managers","A_Id":50438937,"CreationDate":"2018-05-20T16:53:00.000","Title":"Why are pip packages not installed to $PATH to by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Recently, I decided to use Django-summernote to edit model-form text fields. I can use the editor without any problem. When it comes to rendering output of the text edited with this tool, it displays with html tags. Looked around a while but not found any solution. \nAny thoughts on this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":740,"Q_Id":50440350,"Users Score":1,"Answer":"Make sure that you're including the |safe filter on the content (and that you trust the content to be, in fact, safe).","Q_Score":2,"Tags":"python,django,rich-text-editor,summernote","A_Id":50440540,"CreationDate":"2018-05-20T23:40:00.000","Title":"Django-summernote works properly, but shows text with HTML tags","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Odroid running Ubuntu Mate 16.04 and ROS Kinetic. I have wiringPi2 installed for accessing the GPIO pins. I am able to use the GPIO pins through a Python script, but they require sudo access. I have a ROS node (written in Python) in which I want to access the GPIO pin data and publish to a topic. But, I am not able to do so, because wiringPi2 required sudo access, and ROS is not defined in root.\nI have tried using wiringPiSetupSys() function which does not require sudo access, but that does not work i.e. I am not able to get the GPIO pin data without sudo access.\nAll the solutions to similar problems for Raspberry Pi platform don't seem to work for Odroid.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":315,"Q_Id":50443037,"Users Score":0,"Answer":"Unfortunately, I could not find a fix to the problem with the exact specifications mentioned. However, when I tested the same code on a Raspberry Pi 3 with Raspbian, it works correctly. \nSo, I have concluded that the issue lies in the OS used i.e. Ubuntu Mate 16.04. \nSo, a solution might be to use Raspbian on Odroid itself. I am yet to test whether that works out.\nUpdate : Raspbian doesn't exist as such for Odroid, so some other work around might be required.","Q_Score":0,"Tags":"python,ros,gpio,odroid,wiringpi","A_Id":50580997,"CreationDate":"2018-05-21T06:17:00.000","Title":"Odroid GPIO pins in ROS without sudo 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":"Is there something sys.minint in python similar to sys.maxint ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3394,"Q_Id":50446353,"Users Score":1,"Answer":"You can use float('-inf') if that meets your criteria otherwise you can do -1*sys.maxsize","Q_Score":4,"Tags":"python,mapreduce","A_Id":69917530,"CreationDate":"2018-05-21T10:00:00.000","Title":"Is there something sys.minint in python similar to sys.maxint?","Data 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 Azure SDK for python to create resource using python script.After giving the required credentials like CLIENT_ID,TENANT_ID,CLIENT_SECRET,SUBSCRIPTION_ID..It throws a error message like\n\n\"msrestazure.azure_exceptions.CloudError: \n  Azure Error: AuthorizationFailed\n  Message: The client 'CLIENT_ID' with object id 'OBJECT_ID' does not have authorization to perform action 'Microsoft.Resources\/subscriptions\/resourcegroups\/read' over scope ''.\"\n\n(I am using azure in free trial type of subscription)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1517,"Q_Id":50446620,"Users Score":0,"Answer":"There needs to be a service principal(SP) associated with the application. Also, to assign a role to SP you need to be an 'owner' or the Azure portal does not show you that option if you are a 'contributor' in UI.","Q_Score":0,"Tags":"python,azure,azure-active-directory,azure-sdk-python","A_Id":53051636,"CreationDate":"2018-05-21T10:15:00.000","Title":"Azure Error: AuthorizationFailed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have built a chatbot using AWS Lex and lambda. I have a use case where in a user enters a question (For example: What is the sale of an item in a particular region). I want that once this question is asked, a html form\/pop up appears that askes the user to select the value of region and item from dropdown menus and fills the slot of the question with the value selected by the user and then return a response. Can some one guide how can this be achieved? Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":224,"Q_Id":50447302,"Users Score":0,"Answer":"Lex has something called response cards where your can add all the possible values. These are called prompts. The user can simply select his\/her choice and the slot gets filled. Lex response cards work in Facebook and slack. \nIn case of custom channel, you will have to custom develop the UI components.","Q_Score":0,"Tags":"python-3.x,amazon-web-services,aws-lambda,chatbot,amazon-lex","A_Id":50462554,"CreationDate":"2018-05-21T10:54:00.000","Title":"Using aws lambda to render an html page in aws lex 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":1},{"Question":"I have string like in main.py:\n    mystring=\"<ol><li>shiva<\/li><li>putra<\/li>\"\nand i want this value to display to in index.html using python webapp2. i have called {{mystring}}\nNow it is displaying as it is i.e: <ol><li>shiva<\/li><li>putra<\/li>\nBut I want output Like:\n\nshiva\nputra\n\nHow would i display this please help me.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":47,"Q_Id":50447419,"Users Score":1,"Answer":"use safe keyword {{ mystring |safe}} it should work.","Q_Score":1,"Tags":"html,python-2.7,webapp2","A_Id":51671139,"CreationDate":"2018-05-21T10:59:00.000","Title":"i have string containing html tags and i need to display that string in html page in web app2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using the tf.nn.dynamic_rnn class to create an LSTM. I have trained this model on some data, and now I want to inspect what are the values of the hidden states of this trained LSTM at each time step when I provide it some input.\nAfter some digging around on SO and on TensorFlow's GitHub page, I saw that some people mentioned that I should write my own LSTM cell that returns whatever I want printed as part of the output of the LSTM. However, this does not seem straight forward to me since the hidden states and the output of the LSTM do not have the same shapes.\nMy output tensor from the LSTM has shape [16, 1] and the hidden state is a tensor of shape [16, 16]. Concatenating them results in a tensor of shape [16, 17]. When I tried to return it, I get an error saying that some TensorFlow op required a tensor of shape [16,1].\nDoes anyone know an easier work around to this situation? I was wondering if it is possible to use tf.Print to just print the required tensors.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":50447786,"Users Score":0,"Answer":"Okay, so the issue was that I was modifying the output but wasn't updating the output_size of the LSTM itself. Hence the error. It works perfectly fine now. However, I still find this method to be extremely annoying. Not accepting my own answer with the hope that somebody will have a cleaner solution.","Q_Score":0,"Tags":"python,debugging,tensorflow,lstm","A_Id":50448522,"CreationDate":"2018-05-21T11:22:00.000","Title":"TensorFlow: Print Internal State of RNN at at Every Time Step","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using raspberry pi to get sensor data as csv files, I wanted to upload these files in mongodb atlas, but the mongodb shell required is +3.4 but the one in raspberry is 2.4.\nI thought about a solution, that I send these csv files to windows then import from there.\nIs there a command line to send csv file from raspberry to windows using python ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":50453231,"Users Score":0,"Answer":"Use scp to copy from raspberry pi machine  to windows machine (if you are using linux distro on raspberry pi)","Q_Score":0,"Tags":"python,mongodb,raspberry-pi,cloud","A_Id":50453645,"CreationDate":"2018-05-21T16:45:00.000","Title":"Send csl file from raspberry to windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My question is more theory than specific, but if you are developing a Python package where two subpckages (same level) need each other to function, should you keep them still as separate child packages because their organization makes sense to separate based off their purposes or make them a single subpackage because they are necessarily intertwined? \nI am not sure if there is a straightforward answer here and would like some input from the more seasoned Python community- what is considered \"more Pythonic\"?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":50457854,"Users Score":0,"Answer":"Subpackages should be in separate child packages that make sense in terms of structure and functionality. \nJust as classes, it makes them easier to understand and maintain and upgrade in the future. It also makes them potentially reusable for other applications.","Q_Score":0,"Tags":"python,package","A_Id":50458177,"CreationDate":"2018-05-21T23:36:00.000","Title":"Python package structure - submodules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just a general question. Instead of having a popup window appear when I use imshow, is it possible to have this window open up in a GUI application (could be any GUI framework, I am just wondering if this is possible) view instead?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":366,"Q_Id":50458452,"Users Score":0,"Answer":"It is possible to design a Window-based application using highgui, the same api that you use for displaying pop-up windows. But I am not sure how powerful it is, when it comes to designing a fully fledged application.\nIf you are using python, pyqt is generally easy to work with. For c++, you have choices like Qt (multiplatform), Quartz (Mac, with Objective C or Swift), etc.","Q_Score":3,"Tags":"python,c++,opencv,graphics,computer-vision","A_Id":50459232,"CreationDate":"2018-05-22T01:12:00.000","Title":"Is there anyway to take an opencv display window and save it to a GUI window?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to write a script in Python to read a public Twitter profile. Specifically, I'd like to check for Tweets with images, and download those images (eventually, I'd like to add this as a cron job). I was looking into tweepy as a Twitter API wrapper. However, from what I understand, the Twitter API requires authentication even for actions that access public data - is that correct?\nSince all I need is to access a single public user timeline, going through the rigmarole of authenticating (and then having those credentials sitting on my computer in I'm not sure how secure a form) seems a little overkill.\nAre there other solutions out there (particularly Python-based) for reading public Twitter data?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2189,"Q_Id":50459620,"Users Score":3,"Answer":"Yes, Twitter does require, authentication to access any public\/private data of user. You need to create an app on Twitter to access the data. The app is required to keep a check on the number of requests, etc. made by a particular client, to prevent any abuse. This authentication is a general process followed by other API providers as well and this is the only recommended way. \nAnother advantage of creating a Twitter App is that other users can give permissions to your app and then you can access their private data as well such as DM, etc. \nAnother approach is web-scraping, but I would consider it as unethical as twitter is already providing it's API. Also you would need to update your scraping script each time there is some front end change by the Twitter developers.","Q_Score":2,"Tags":"python,twitter","A_Id":50459886,"CreationDate":"2018-05-22T04:07:00.000","Title":"Building script to access public Twitter data, without authentication","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":"Since CPU-bound parellelization is not achievable in CPython due to GIL.\nThe official documentation recommends to use multiprocessing instead of multithreading.\nSo, is the use of multiple processes more intensive on resources than multiple threads, if compared to multiprocessing\/multithreading performance of any other programming language like Java or C++ which support true parellelization in both multiprocessing and multithreading?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":176,"Q_Id":50460341,"Users Score":1,"Answer":"There is little inherent additional cost to multiprocessing in python beyond the cost of forking (unix-like systems) or respawning a process. The expense is when data or state needs to be shared among the processes. This could be anything from the iterable given to Pool.map to the proxies in Manager. As long as those costs are kept low compared to the per-process work load, its a wash. (Note that python is usually slower than java and c++ for other reasons unrelated to mp).","Q_Score":0,"Tags":"python,multithreading,multiprocessing,python-multiprocessing","A_Id":50460506,"CreationDate":"2018-05-22T05:23:00.000","Title":"Is Python multiprocessing intensive on resources?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python and I am using Python 3.6.4. I also use PyCharm editor to write all my code. Please let me know how can I install Image library in Windows 7 and would it work in PyCharm too.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":434,"Q_Id":50461995,"Users Score":0,"Answer":"From pycharm, \n\ngoto settings -> project Interpreter\nClick on + button on top right corner and you will get pop-up window of \nAvailable packages. Then search for pillow, PIL image python packages.\nThen click on Install package to install those packages.","Q_Score":0,"Tags":"python,windows,python-3.x,image,pycharm","A_Id":50463283,"CreationDate":"2018-05-22T07:22:00.000","Title":"How to install image library in python 3.6.4 in windows 7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to build Linear Regression model with training data in Jupyter notebook, python has stopped working, with error as shown below. I am using Anaconda 3.5 on windows7, Python 3.6 version.\nProblem signature:\n  Problem Event Name:   APPCRASH\n  Application Name: python.exe\n  Application Version:  3.6.4150.1013\n  Application Timestamp:    5a5e439a\n  Fault Module Name:    mkl_core.dll\n  Fault Module Version: 2018.0.1.1\n  Fault Module Timestamp:   59d8a332\n  Exception Code:   c000001d\n  Exception Offset: 0000000001a009a3\n  OS Version:   6.1.7600.2.0.0.256.48\n  Locale ID:    1033\n  Additional Information 1: 7071\n  Additional Information 2: 70718f336ba4ddabacde4b6b7fbe73e3\n  Additional Information 3: de32\n  Additional Information 4: de328b4df988a86fd2d750fb0942dbd1\nI am not able to get any help from google when I search with this error, even I tried\n1 Uninstalled and again installed\n2. Ran below commands but no use\n   conda update conda\n   conda update ipython ipython-notebook ipython-qtconsole\nI suspect this error related to Windows, but not sure how to fix it. \nThanks,\nSagar.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2067,"Q_Id":50463731,"Users Score":0,"Answer":"Updated all the libraries to latest version in Anaconda and try.\nI was facing a similar situation when I was running the code for Convolutional Neural Network in Spyder under Anaconda environment (Windows 7) I was getting following error\n\nProblem Event Name:  APPCRASH\n    Application Name: pythonw.exe\n    Fault Module Name:    StackHash\n    Exception Code:   c0000005\n    OS Version:   6.1.7601.2.1.0.256.1  \n\nI updated all the libraries to latest version in Anaconda and the problem is resolved.","Q_Score":0,"Tags":"python,anaconda","A_Id":53102357,"CreationDate":"2018-05-22T09:01:00.000","Title":"Python has stopped working(APPCRASH) Anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 data sets with different variables.  But both includes a variable, say NUM, that helps to identify the occurrence of an event. With the NUM, I was able to identify the event, by labelling it. How can one run RF to effectively include considerations of the 2 datasets? I am not able to append them (column wise) as the number of records for each NUM differs.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":50469243,"Users Score":0,"Answer":"You could try to put NUM as a single column, and the first and second datasets would use completely independent columns, with the non-matching cells containing empty data. Whether the results will be any good, will depend much on your data.","Q_Score":0,"Tags":"python,random-forest","A_Id":50487464,"CreationDate":"2018-05-22T13:41:00.000","Title":"How to use classifier random forest in Python for 2 different data sets?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a django sitemap and wagtail sitemap for my site.\nThe django sitemap is using https by simply setting the protocol variable in the class, but I can't figure out a way to do this for the wagtail sitemap without overriding many internal methods.\nIs there a simple way to use https for my wagtail sitemaps?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":814,"Q_Id":50471616,"Users Score":15,"Answer":"In the Wagtail admin, under Settings -> Sites, change the port number of your site to 443.","Q_Score":5,"Tags":"python,django,seo,wagtail","A_Id":50473994,"CreationDate":"2018-05-22T15:38:00.000","Title":"How to change protocol to https on wagtail sitemaps?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to solve a linear system spanning somewhat between hundred thousand and two hundred thousand equations with numpy.linalg.lstsq but is taking waaaaay too long. What can I do to speed this up?\nThe matrix is sparse with hundreds of columns (the dimensions are approximately 150 000 x 140) and the system is overdetermined.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2001,"Q_Id":50472095,"Users Score":0,"Answer":"If your coefficient matrix is sparse, use \"spsolve\" from \"scipy.sparse.linalg\".","Q_Score":0,"Tags":"python,performance,numpy,math,computer-science","A_Id":56719666,"CreationDate":"2018-05-22T16:06:00.000","Title":"How can I solve a system of linear equations in python faster than with numpy.linalg.lstsq?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm testing Apache superset Dashboards, It s a great tool.\nI added an external Database source (Oracle), and I created nice Dashboards very easily.\nI would like to see my Dashboards updated regularly and automatically (3 times a day) in superset.\nBut my Dashboards are not updated.\nI mean when a row is inserted into the Oracle Tables, if I refresh the Dashboard, I cannot view the new data in the Dashboard.\nWhat is the best way to do it ?\n=> Is there a solution \/ an option to force the Datasource to be automatically updated regularly ? in a frequency ? What is the parameter \/ option ? \n=> is there a solution to import in batch csv files (for instance in python), then this operation will update the Dashboard ?\n=> other way ?\nIf you have examples to share... :-)\nMy environment: \nSuperset is Installed on ubuntu 16.04 and Python 2.7.12.\nOracle is installed on another Linux server.\nI connect from  google chrome to Superset.\nMany thanks for your help","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1509,"Q_Id":50472282,"Users Score":0,"Answer":"You could set the auto-refresh interval for a dashboard if you click on the arrow next to the Edit dashboard-button.","Q_Score":1,"Tags":"python,oracle,superset","A_Id":59359358,"CreationDate":"2018-05-22T16:16:00.000","Title":"superset dashboards - dynamic updates","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm testing Apache superset Dashboards, It s a great tool.\nI added an external Database source (Oracle), and I created nice Dashboards very easily.\nI would like to see my Dashboards updated regularly and automatically (3 times a day) in superset.\nBut my Dashboards are not updated.\nI mean when a row is inserted into the Oracle Tables, if I refresh the Dashboard, I cannot view the new data in the Dashboard.\nWhat is the best way to do it ?\n=> Is there a solution \/ an option to force the Datasource to be automatically updated regularly ? in a frequency ? What is the parameter \/ option ? \n=> is there a solution to import in batch csv files (for instance in python), then this operation will update the Dashboard ?\n=> other way ?\nIf you have examples to share... :-)\nMy environment: \nSuperset is Installed on ubuntu 16.04 and Python 2.7.12.\nOracle is installed on another Linux server.\nI connect from  google chrome to Superset.\nMany thanks for your help","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1509,"Q_Id":50472282,"Users Score":1,"Answer":"I just found the origin of my error... :-)\nIn fact I added records in the future (tomorow, the day after, ...)... \nAnd My dashboard was only showing all Records to the today date...\nI inserted a record before, I refreshed and It appeared.\nThanks to having read me...","Q_Score":1,"Tags":"python,oracle,superset","A_Id":50473011,"CreationDate":"2018-05-22T16:16:00.000","Title":"superset dashboards - dynamic updates","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to retrieve fares between two different cities on a travel website. In the request headers, I see the following.\n'x-api-idtoken':'null',\n'x-api-key':'l7xx944d175ea25f4b9c903a583ea82a1c4c',\nDo they change\/expire with time?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":834,"Q_Id":50474098,"Users Score":2,"Answer":"They could change over time and in many cases do. Access keys\/tokens can be given a limited life span, but it is up to the service in question to control refresh, expiration and\/or revocation.\nGiven that the question does not contain an explicit reference to the web service involved, it is not possible to answer specifically for this case. Typically, the access management scheme is documented as part of the API.","Q_Score":0,"Tags":"python,python-3.x,http-headers","A_Id":52833525,"CreationDate":"2018-05-22T18:16:00.000","Title":"x-api-key in request headers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As I understand it you install a module from sources with pip install -e \/my_module \nWhen I do this pip show -f my_module | grep Location\n gives ~\/my_module as the location instead of my virtual environment's site-packages\nI have my virtual environment activated when I install the module. I've also tried moving my module's folder into my virtual environment's site-packages but it installs it in site-packages\/my_module instead of just site-packages.\nI am doing this so that I can edit an existing module to work with my data's shape.\nWhat is the correct way to install a module from sources onto a virtual environment?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2118,"Q_Id":50477348,"Users Score":1,"Answer":"As I understand it you install a module from sources with pip install -e \/my_module\n\nNo, not exactly. pip install -e installs in \"editable\", i.e. development mode. Instead of copying installed files into site-packages\/ directory pip configures site-packages\/ and your sources so that python imports your modules from you source directory. That way you can edit the modules and the changes are immediately available to python. Without -e pip would install the package in the usual way \u2014 by copying it to site-packages\/ so if you edit your code you need to reinstall. \n\nWhen I do this pip show -f my_module | grep Location gives ~\/my_module as the location instead of my virtual environment's site-packages\n\nYes, that's how pip install -e works. If you want your code to be copied to virtual environment's site-packages\/ don't use -e.\n\nI am doing this so that I can edit an existing module to work with my data's shape.\n\nThen you certainly need -e so that your modules can be imported from the source directory.\n\nWhat is the correct way to install a module from sources onto a virtual environment?\n\nBoth pip install and pip install -e are correct, they are for different use cases.","Q_Score":2,"Tags":"python,pip,virtualenv,python-module","A_Id":50478464,"CreationDate":"2018-05-22T22:34:00.000","Title":"How to install python modules from sources onto a virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As I understand it you install a module from sources with pip install -e \/my_module \nWhen I do this pip show -f my_module | grep Location\n gives ~\/my_module as the location instead of my virtual environment's site-packages\nI have my virtual environment activated when I install the module. I've also tried moving my module's folder into my virtual environment's site-packages but it installs it in site-packages\/my_module instead of just site-packages.\nI am doing this so that I can edit an existing module to work with my data's shape.\nWhat is the correct way to install a module from sources onto a virtual environment?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2118,"Q_Id":50477348,"Users Score":1,"Answer":"Assuming you have a setup.py setup file in your library\nStep 1: Activate your virtual environment.\nStep 2: Navigate to your library source folder.\nStep 3: Install the library usually with 'python setup.py install'.","Q_Score":2,"Tags":"python,pip,virtualenv,python-module","A_Id":59888800,"CreationDate":"2018-05-22T22:34:00.000","Title":"How to install python modules from sources onto a virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python list(containing integers), and I want to find the indices of N highest values in a list. Where N is less than the length of the list.\nI can find the N maximum values by sorting the list, but is there good way to find the location of these N maximum values?\nAs an example, my list is a = [10, 16, 29, 1, 4, 5, 7, 9, 13, 15], and I need to find the location of 3 highest values.\nExpected result is [2, 1, 9]","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":6034,"Q_Id":50477976,"Users Score":2,"Answer":"The numpy library has tools and a functional programming paradigm that sometimes makes things like this easy.  You convert to a numpy.array type (Let\u2019s call it x) then x.argmax() gives you the position of the largest.  Put a \u20181\u2019 in another array of the same length that is zeros in all other places (which you do by saying index- numpy.zeros(len(x))).  \nFrom there you can figure out how to do it twice more, but excluding the values that have something other than zero in the index array.\nI suspect numpy even has a method that, for a given input array, gives you the indexes sorted by increasing value. In that case it\u2019s trivial: just take the first three indexes in the list you get from that method ( it might be .sort()).\nNUMPY is definitely worth getting to know above almost all other libraries","Q_Score":5,"Tags":"python","A_Id":50478103,"CreationDate":"2018-05-22T23:52:00.000","Title":"Location of N max values in a python list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to learn how to create a website using python. I have been going off the advice of various websites including stackoverflow. Currently I can run code in eclipse using pydev, but I need to install django. I have no idea how to do this and I don't know who to ask or where to begin. Please help","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":50478204,"Users Score":0,"Answer":"I would recommend the following:\n\nInstall virtual environment\n\n$pip install virtualenv\n\nCreate a new virtualenvironment\n\n$ virtualenv django-venv\n\nActivate virtual environment & use\n\n$ source django-venv\/bin\/activate\n\nAnd install django as expected\n\n(django-venv)$ pip install django==1.11.13\n(Replace with django version as needed)","Q_Score":0,"Tags":"python,django,eclipse,pydev","A_Id":50478352,"CreationDate":"2018-05-23T00:28:00.000","Title":"I have downloaded eclipse and pydev, but I am unsure how to get install django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"At least some workaround would be appreciated. I am trying to save the figures as pdfs and then use it with latex as an animation. If there is a way to automatically add captions that will be really helpful as I am going to have about 50-60 figures.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":128,"Q_Id":50478853,"Users Score":3,"Answer":"I don't know if it is possible natively, but you can put the graph drawn by graph-tool in a matplotlib Figure() using the mplfig option in graph_draw(). With that you have access to all the flexibility of matplotlib around your graph.","Q_Score":0,"Tags":"python,graph-tool","A_Id":51139872,"CreationDate":"2018-05-23T02:11:00.000","Title":"Is there a way to add a title or a caption to the drawing using graph_tool","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running Spyder on my Mac with High Sierra. I have 2 virtual environments defined using Anaconda. The virtual environments are py27 for python 2.7.13 and py36 for python 3.65. When I go to py36 and run Spyder, everything seems to work fine. When I go to py27, immediately after I start spyder from the command line I get 9 warnings written to the terminal. The warning is:\n[warn] kq_init: detected broken kqueue; not using.: Undefined error: 0\nAfter these messages, Spyder opens using the correct version of python and seems to run fine.  My question is should I be concerned about these warnings, why do they occur when running in py27 but not py36, and is spyder running fine with these warnings.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":111,"Q_Id":50479258,"Users Score":1,"Answer":"(Spyder maintainer here) This is a harmless warning, so you can safely ignore it.\nNote: This is not a problem in Spyder, however we'll make the warning go away in our next version (Spyder 3.3), to be released in June\/2018.","Q_Score":2,"Tags":"python,spyder,macos-high-sierra","A_Id":50499289,"CreationDate":"2018-05-23T03:11:00.000","Title":"kq_init warning when starting Spyder through the terminal on macOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running Spyder on my Mac with High Sierra. I have 2 virtual environments defined using Anaconda. The virtual environments are py27 for python 2.7.13 and py36 for python 3.65. When I go to py36 and run Spyder, everything seems to work fine. When I go to py27, immediately after I start spyder from the command line I get 9 warnings written to the terminal. The warning is:\n[warn] kq_init: detected broken kqueue; not using.: Undefined error: 0\nAfter these messages, Spyder opens using the correct version of python and seems to run fine.  My question is should I be concerned about these warnings, why do they occur when running in py27 but not py36, and is spyder running fine with these warnings.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":50479258,"Users Score":1,"Answer":"You need to run:\nconda update conda in your default environment, & conda update anaconda in your 2.7 environment?","Q_Score":2,"Tags":"python,spyder,macos-high-sierra","A_Id":50499747,"CreationDate":"2018-05-23T03:11:00.000","Title":"kq_init warning when starting Spyder through the terminal on macOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My task : I cannot speak openly about what the specifics of my task are, but here is an analogy : every two hours, I get a variable number of spoken audio files. Sometimes only 10, sometimes 800 or more. Let's say I have a costly python task to perform on these files, for example Automatic Speech Recognition. I have a Google Intance managed group that can deploy any number of VMs for executing this task.\nThe issue : right now, I'm using Google PubSub. Every two hours, a topic is filled with audio ids. Instances of the managed group can be deployed depending on the size of queue. The problem is, only one worker get all the messages from the PubSub subscription, while the others are not receiving any, perhaps because the queue is not that long (maximum ~1000 messages). This issue is reported in a few cases in the python Google Cloud github, and it is not clear if it is the intended purpose of PubSub, or just a bug.\nHow could I implement the equivalent of a simple serverless task queue in Python and Google Cloud, and can spawn instances based on a given metric, for example the size of the queue ? Is this the intended purpose of PubSub ?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":442,"Q_Id":50484098,"Users Score":1,"Answer":"In App Engine you can create push queues and set rate\/concurrency limits and Google will handle the rest for you. App Engine will scale as needed (e.g. increase Python instances).  \nIf you're outside of App Engine (e.g. GKE), the pubsub Python client library may be pulling many messages at once. We had a hard time controlling this (for google-cloud-pubsub==0.34.0) as well so we ended up writing a small adjustment on top of  google-cloud-pubsub calling SubscriberClient.pull with max_messages set). The server side pubsub API does adhere to max_messages.","Q_Score":0,"Tags":"python-2.7,google-cloud-platform,google-cloud-pubsub","A_Id":50490692,"CreationDate":"2018-05-23T09:01:00.000","Title":"Simple task queue using Google Cloud Platform : issue with Google PubSub","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a few .py files that I want to run in a Docker image.\nBut they need the scrapy-splash Docker image to function well. How will I be able to run those .py files in a Docker container or image while also running scrapy-splash? I am planning to run it on a VPS server.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":236,"Q_Id":50489366,"Users Score":0,"Answer":"You have two choices:\n\nRun the python scripts in the entrypoint, after splash. To run splash in background and then execute your scripts you'll need an entrypoint like this:\n\nENTRYPOINT [\"\/bin\/bash\", \"-c\", \"python3 splash <SPLASH OPTIONS> & python3 your_script.py && python3 your_second_script.py\"]\nThis way the container will end after running the scripts.\n\nRun the splash container in detached mode and then execute the scripts with docker exec.","Q_Score":1,"Tags":"python,docker,scrapy,scrapy-splash","A_Id":50495005,"CreationDate":"2018-05-23T13:12:00.000","Title":"How to run multiple Python scripts in a Docker image or container that depends on another image?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"i have a webservice which gets user requests and produces (multiple) solution(s) to this request.\nI want to return a solution as soon as possible, and send the remaining solutions when they are ready.\nIn order to do this, I thought about using Django's Http stream response. Unfortunately, I am not sure if this is the most adequate way of doing so, because of the problem I will describe below.\nI have a Django view, which receives a query and answers with a stream response. This stream returns the data returned by a generator, which is always a python dictionary.\nThe problem is that upon the second return action of the stream, the Json content breaks.\nIf the python dictionary, which serves as a response, is something like {key: val}, after the second yield the returned response is  {key: val} {key: val}, which is not valid Json.\nAny suggestions on how to return multiple Json objects at different moments in time?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":928,"Q_Id":50491360,"Users Score":0,"Answer":"Try decoding with something like \nfor example \n\n\n\nimport json\njson.dumps( {key: val} {key: val}, separators=('}', ':'))  #check it","Q_Score":1,"Tags":"python,json,django","A_Id":58790635,"CreationDate":"2018-05-23T14:46:00.000","Title":"Proper way of streaming JSON with Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know there is a method where you can call a stored process via the SAS Stored Process Web Application, but I was wondering if there is a method where i can call the stored process server directly.\nThe goal is to call a stored process which delivers data (via the _webout file?) to python, as efficiently as possible. So maybe it could reduce processing time by skipping the SAS Web Application.\nI don't think it is possible with SASPy (seems to be using Workspace servers).\nRegards.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":461,"Q_Id":50492155,"Users Score":1,"Answer":"There are 2 ways to call a stored process server in code, using the Java libraries and using the .NET libraries.\nPersonally, I have used .NET to create a command line application that calls the stored process and returns the stream to STDOUT.  From Python, you just read that output.  You can replicate this from Java (but the .NET libraries are easier to use).\nThe other method would be to use a library that allows you to call Java from your flavor of Python (or .NET if you are using the MS Python) and integrate it that way.\nIn the end, for most use cases, it is just easier to use the STP Web Application.  You can log in once, store the authorization token, and pass that back, negating the overhead of re-logging in for each call.","Q_Score":2,"Tags":"python,sas,sas-stored-process,saspy","A_Id":50492460,"CreationDate":"2018-05-23T15:25:00.000","Title":"Execute SAS Stored Process with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have been using pycharm for a while now, and I have to say that I am a real fan of it's features. I have one issue though, when I try to run a .py file from either the desktop or command prompt, I am instead prompted to use the run feature in pycharm. I consider this an issue because if I try to create a program for someone who doesn't know how to code, they would probably be scared off by opening pycharm. I don't, however, want to uninstall pycharm because it is so useful when writing code. Does anyone have any Ideas for me? By the way, I am using a dell Inspiron 15 7000 Gaming laptop with the current version of Windows 10 installed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":50492727,"Users Score":0,"Answer":"You can try running the direct path of the file, I'm not sure what you have tried.\nIf you wanted to run it as I just described you would do:\npy C:\\~AppData\\Local\\Programs\\Python\\Python36-32\\hello.py\nIf you move the file into your current working directory when programming, you should just be able to run py hello.py.","Q_Score":0,"Tags":"python,pycharm","A_Id":50492782,"CreationDate":"2018-05-23T15:52:00.000","Title":"pycharm won't let me run from desktop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been looking for a fast and relatively easy way of searching (grep-ish) for user-defined strings in files of varying formats, i.e xlsx, docx, pptx, pdf using Python.\nMy research has led me to believe that there might not be a convenient way of doing this, as per a single module or similar. Am I forced to use a separate module for each file type? And if so are these approriate?\ndocx\nopenpyxl\npptx \nslate\nI also looked at forms of decompression to get to the xml-files containing actual text but it seems unwieldy. I just want to be sure that there is no simple, uniform way of handling all of these different filetypes.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":50493670,"Users Score":0,"Answer":"Well, I've mostly figured it out. In the end I decided to use powershell combined with \"itextsharp.dll\" to process the files. It turned out to be simpler than using portable python. Thanks for the answers:-)","Q_Score":0,"Tags":"python,string,windows,parsing,ms-office","A_Id":50570435,"CreationDate":"2018-05-23T16:52:00.000","Title":"Search office documents for string python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I work on a large python code base with several teammates. We are often installing or updating dependencies on other python packages, and inevitably this causes problems when someone else updates their master branch from git, or we deploy on a new system. \nI've seen many tools available for deploying environments on new computers, which are great. The problem is that these tools only work if everyone is consistently updating the relevant files (e.g. requirements.txt, setup.py, tarballs on a PyPI server...) every time they update or add a package.\nWe use Github's pull request system for code reviews. What would be great would be some means of indicating to the reviewer that the dependency structure has changed, prompting the reviewer to check for the necessary updates (also good would be to build in a checklist that the reviewer has to complete, reminding them to do the check).\nHow have other folks dealt with this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":50495947,"Users Score":0,"Answer":"I would enforce the use of tools with a network proxy or network ACL, to block public sites and stand up internal services like gitlab, bitbucket, GitHub enterprise, or internal pypi server, to force the use of certain standards.","Q_Score":0,"Tags":"python,github,workflow,dependency-management,collaboration","A_Id":50496519,"CreationDate":"2018-05-23T19:17:00.000","Title":"Enforcing use of a package management system when developing with a team","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm programming a bit of server code and the MQTT side of it runs in it's own thread using the threading module which works great and no issues but now I'm wondering how to proceed. \nI have two MariaDB databases, one of them is local and the other is remote (There is a good and niche reason for this.) and I'm writing a class which handles the databases. This class will start new threads of classes that submits the data to their respected databases. If conditions are true, then it tells the data to start a new thread to push data to one database, if they are false, the data will go to the other database. The MQTT thread has a instance of the \"Database handler\" class and passes data to it through different calling functions within the class.\nWill this work to allow a thread to concentrate on MQTT tasks while another does the database work? There are other threads as well, I've just never combined databases and threads before so I'd like an opinion or any information that would help me out from more seasoned programmers.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":50497250,"Users Score":0,"Answer":"Writing code that is \"thread safe\" can be tricky.  I doubt if the Python connector to MySQL is thread safe; there is very little need for it.\nMySQL is quite happy to have multiple connections to it from clients.  But they must be separate connections, not the same connection running in separate threads.\nVery few projects need multi-threaded access to the database.  Do you have a particular need?  If so let's hear about it, and discuss the 'right' way to do it.\nFor now, each of your threads that needs to talk to the database should create its own connection.  Generally, such a connection can be created soon after starting the thread (or process) and kept open until close to the end of the thread.  That is, normally you should have only one connection per thread.","Q_Score":0,"Tags":"python,database,multithreading,mariadb","A_Id":50634340,"CreationDate":"2018-05-23T20:49:00.000","Title":"Calling database handler class in a python thread","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to implement an observer design pattern. My thoughts are, if this is deployed, and another system update has occurred and restarted the server, would the observers\/subscribers be lost when the server has restarted?\nSorry for this newbie question.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":50499733,"Users Score":1,"Answer":"Your question doesn't specify any tools you are using neither the deployment methods and softwares so the best I can say is that any non-persistent data will be deleted on restart. This counts for the subscribers your server has saved in a variable, for example.\nIn web development, you go around this problem (and that of lost of connection) by having \"temporary subscriptions\" and by not implementing functionalities with solutions needing consistency in connection.\nHowever, what you could do is give the clients some sort of unique id which could be stored in a database along with data that can restore the connection.","Q_Score":0,"Tags":"python,deployment,observer-pattern,production-environment","A_Id":50499841,"CreationDate":"2018-05-24T01:45:00.000","Title":"how observer design pattern on production behave?","Data Science and Machine Learning":0,"Database and SQL":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 quite familiar with Django, but recently noticed there exists a on_delete=models.CASCADE and on_delete=models.PROTECT options with the models,\n\non_delete=models.CASCADE and on_delete=models.PROTECT both are doing same things.\nOr both are same (I used the only on_delete=models.CASCADE, when I remove the parent entry it will remove all related entries )\nI have searched for the documentation for the same but couldn't find anything more than:\n\n\nDjango 2.0\nA many-to-one relationship. Requires two positional arguments: the\n  class to which the model is related and the on_delete option.\n       To create a recursive relationship \u2013 an object that has a many-to-one relationship with itself \u2013 use models.ForeignKey('self',\n  on_delete=models.CASCADE).","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27010,"Q_Id":50502537,"Users Score":49,"Answer":"CASCADE\nCascade deletes. Django emulates the behavior of the\nSQL constraint ON DELETE CASCADE and also deletes the object\ncontaining the ForeignKey.\nPROTECT \nPrevent deletion of the referenced object by raising\nProtectedError, a subclass of django.db.IntegrityError.\n\nthe things get deleted because once you change your model you need to do makemigrations and migrate to see the change.","Q_Score":26,"Tags":"python,django,django-models","A_Id":50502731,"CreationDate":"2018-05-24T06:37:00.000","Title":"what does on_delete=models.PROTECT and on_delete=models.CASCADE do on Django models?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am making graphs using bokeh in python and for that I was calling an HTML page to fetch data inside my dataframe but now I want to fetch data directly from database inside my dataframe. So which method is more efficient?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":50506046,"Users Score":0,"Answer":"This depends on a lot of things, namely:\n\nis your database in the same local network as your application server?\nis the website used in the same local network as your application server?\nhow large is the table you have in the website?\nhow large is your database?\ncan a user do some trusted changes on the webpage that is not inside the database yet?\n\nAll in all, the most common case is that your database is in the same local network as your application server, but there is a lot of data stored in there. So, it is difficult to answer in terms of efficiency, it might be quicker to load data from your local network, but selecting items from the database can be very time-consuming, to such an extent that it will be less efficient than loading data from the webpage. So, to compare efficiency, you will have to do a lot of tests and estimations for the future.\nHowever, there are some other aspects\nServer load\nIf you always load from the database, then you have higher server load, which will affect scalability and even performance when longer database tasks are running, for instance some maintenance cron jobs.\nSecurity\nIf a hacker sends some valid requests but with wrong data, you might be misled, so you will need to validate any input from users you do not trust. And you should not trust the users generally, trusted users should be the exception.\nData structure\nYou might cache data for this purpose if you do this with the database and you may use JSON when you send the content of the table to the server, so network communication will not increase.\nNetwork burden\nIf data is sent from the webpage back, then in the case of usage spikes a lot of data might be sent, which might affect the responsiveness of your application.","Q_Score":0,"Tags":"python,database,pandas,api,dataframe","A_Id":50506830,"CreationDate":"2018-05-24T09:42:00.000","Title":"Which is more efficient ? Fetching data directly from databse or from an HTML page in pandas dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to use pytest to run some tests. My package contains a setup.cfg file where I've stated all the pytest options\n[tool:pytest]\n addopts =\n --verbose\n unit\n\nas it is visible I've added the unit directory to find the test files. This works fine and all the tests from the directory get executed during the normal build process.\nActual Problem - \nNow I have another directory integ where I have my integration tests which I want to run sometimes but do not want them as a part of my build process. I have created another command line option to run my integ tests but I am not able to figure out how to provide the file set correctly for the same\nI've tried pytest --ignore=unit integ through command line but it runs all my tests from unit as well as integ. I want to run the tests present in integ only and ignore the tests from unit. What am I missing here?\n[update]\nWhen I run pytest --ignore=unit\/test_file.py integ it ignores the tests in test_file but when I use pytest --ignore=unit\/*.py integ it says no matches found: --ignore=test\/*.py\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":761,"Q_Id":50508746,"Users Score":1,"Answer":"--override-ini=testpaths=test_integ solved my problem. I was able to override the options from my setup.cfg file using this.","Q_Score":1,"Tags":"python,unit-testing,pytest","A_Id":50510001,"CreationDate":"2018-05-24T11:53:00.000","Title":"Python Pytest ignore tests from a directory mentioned in the setup.cfg 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":"Wanted to ask, why \n5 \/ 100 \nreturns\n0\n, but it works with \n5 * 0.01\n, even though arithmetically both should return the same value?\neven float(5 \/ 100) returns 0.0","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":145,"Q_Id":50510015,"Users Score":1,"Answer":"5\/100 return 0 because you are dividing two integers, not floating point numbers. Division of any two integers will return an integer number.\nSame reason for float(5\/100). In this case you are first dividing two integers and then converting its result, which is integer 0, to floating point number.\nIf any of the number in the arithmetic operation is a floating point number, then the result would be also be a floating point number.\nFor example, float(5)\/100. This will return 0.05 because you are dividing a floating point number, i.e. float(5), by an integer 100.","Q_Score":0,"Tags":"python","A_Id":50510095,"CreationDate":"2018-05-24T12:54:00.000","Title":"returning float with all the numbers after period","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello  im  new  in  programming  with  openerp  ODOO  ,  well  my  issue  is  where  i  can  find  the  functions  of  inserting  into  odoo database  ,  well  i  created  a  new  field  and  i  want  to  insert  the  data  of  this  field  into  the  db","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":513,"Q_Id":50511857,"Users Score":0,"Answer":"If you want to store field value in database then add store=True within your field in python file. Then Your value store into database.","Q_Score":0,"Tags":"python,postgresql,odoo","A_Id":50522026,"CreationDate":"2018-05-24T14:27:00.000","Title":"From where i can insert field input to odoo database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm running python code from notepad ++ with a shortcut \n\u201d C:\\Python27\\Lib\\idlelib\\idle.bat -r \"$(FULL_CURRENT_PATH)\"\nwhen it runs it pops up in the middle for the screen.\nHow do I specify where it should pop up? I want to put it in the top right corner of the screen.\nI would also like to be able to specify how big the size of the python shell should be.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":291,"Q_Id":50514178,"Users Score":0,"Answer":"For initial shell and editor size, open Options => Configure IDLE => General tab.  Find Initial Window Size and set the height and width in lines and characters.\nThere is no setting for initial position, as it would be a bad idea to have all windows open in exactly the same position.  Better to let the OS cascade them.\nOn the other hand, initial position of the first window would be useful.  For your use, a command line option, say -x pixels_from left, -y pixels from top, would work.  But most people either use the IDLE editor for .py files or link the python shell to other editors, and do not explicitly use a command line.  So I will consider adding Initial Position of First Window to the config dialog.","Q_Score":0,"Tags":"python,notepad++,python-idle","A_Id":50537600,"CreationDate":"2018-05-24T16:33:00.000","Title":"launching Python from notepad ++ specify location and size of window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How to make sure that Process A has completely written large file (5+ GB) in AWS S3 Bucket A before Process B starts copying file to AWS S3 Bucket B using boto3?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2604,"Q_Id":50515323,"Users Score":1,"Answer":"You should definitely  use s3 event notification as a trigger to a lambda function that copies your file from Bucket A to Bucket B. The trigger ensures that your copying will start once the file gets uploaded completely. \nMoreover, if you have further operations to perform you can use AWS step functions in which you can define the workflow of your processes , e.g. process B will start after 2 seconds from process A, process C and D will execute in parallel after process B ends it's execution , etc.","Q_Score":1,"Tags":"python,amazon-s3,aws-lambda,boto3","A_Id":50525469,"CreationDate":"2018-05-24T17:47:00.000","Title":"Python Boto3 - how to check if s3 file is completely written before process start copying to another bucket","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How to make sure that Process A has completely written large file (5+ GB) in AWS S3 Bucket A before Process B starts copying file to AWS S3 Bucket B using boto3?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2604,"Q_Id":50515323,"Users Score":0,"Answer":"I also do uploads of up to 40GB.  \nSince I do multi-part uploads, I check if the file I am writing to is closed. An S3 file(object) is only closed when all operations are finished.\nAnother way is to use asynchronous task queue like Celery. You will get notifications when a task is done.\nI now use Golang but both those methods have worked very well for me.","Q_Score":1,"Tags":"python,amazon-s3,aws-lambda,boto3","A_Id":52595074,"CreationDate":"2018-05-24T17:47:00.000","Title":"Python Boto3 - how to check if s3 file is completely written before process start copying to another bucket","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to  install python 3.5 in linux that has   python 3.4 \nvia virtualenv or any other mean.\nsince the system version is 3.4 ,I don't want to upgrade it so the system don't crash .","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":176,"Q_Id":50515699,"Users Score":0,"Answer":"Using sudo apt-get install package python3 should install the latest version of Python, and remove the older one.","Q_Score":0,"Tags":"linux,python-3.x,virtualenv","A_Id":50515738,"CreationDate":"2018-05-24T18:13:00.000","Title":"How to install python3.5 or 3.6 in linux that has python 3.4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to generate a matrix of N random integers between 1 and K, where each number appears at least once, having K \u2264 N.\nI have no problem using a call to numpy.random.random_integers() and checking the number of distinct elements, when K is much less than N, but it's harder to get a valid array when K approximates to N.\nIs there any nice way to get this done? Any hint would be appreciated.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":152,"Q_Id":50517089,"Users Score":1,"Answer":"Fill the matrix iteratively with numbers 1-K so if K was 2, and N was 4, [1,2,1,2]. Then randomly generate 2 random numbers between 1-N where the numbers don't equal, and swap the numbers at those positions.","Q_Score":0,"Tags":"python,numpy,random","A_Id":50517141,"CreationDate":"2018-05-24T19:47:00.000","Title":"Generate an array of N random integers, between 1 and K, but containing at least one of each number","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to generate a matrix of N random integers between 1 and K, where each number appears at least once, having K \u2264 N.\nI have no problem using a call to numpy.random.random_integers() and checking the number of distinct elements, when K is much less than N, but it's harder to get a valid array when K approximates to N.\nIs there any nice way to get this done? Any hint would be appreciated.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":152,"Q_Id":50517089,"Users Score":1,"Answer":"Fill K numbers using xrange(k) and then fill (n-k) number using random number generator","Q_Score":0,"Tags":"python,numpy,random","A_Id":50517145,"CreationDate":"2018-05-24T19:47:00.000","Title":"Generate an array of N random integers, between 1 and K, but containing at least one of each number","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've looked at the other solutions for this and none of them help. \nI installed my package and it doesn't add my entry_point when using --user\nAfter doing pip install --user module \nthe entry point is not adding to .local\nDoes anyone know why it's not getting added to .local\/bin?\nDeveloping in python 2.7\nThanks","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":82,"Q_Id":50518518,"Users Score":2,"Answer":"Fix: conole_scripts -> console_scripts. Missed s.","Q_Score":1,"Tags":"python,python-2.7,pip,setuptools","A_Id":50518936,"CreationDate":"2018-05-24T21:36:00.000","Title":"Python setup.py not adding console_script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've looked at the other solutions for this and none of them help. \nI installed my package and it doesn't add my entry_point when using --user\nAfter doing pip install --user module \nthe entry point is not adding to .local\nDoes anyone know why it's not getting added to .local\/bin?\nDeveloping in python 2.7\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":50518518,"Users Score":0,"Answer":"It appears there is a spelling mistake in the entry_points, you have conole_scripts instead of console_scripts (missing the \"s\" in console).  Was this directly copied and pasted from your code?","Q_Score":1,"Tags":"python,python-2.7,pip,setuptools","A_Id":50518944,"CreationDate":"2018-05-24T21:36:00.000","Title":"Python setup.py not adding console_script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a model that has an LSTM layer of 100 units with input dimensions (16,48,12) (16 is the batch size as it takes input through a generator function). The generator function produces an expected output of (16, 1, 2) (16 is the batch size) and I want to use as output a dense layer with a softmax activation fucntion. What would be the best way to do that? I am fairly new to keras and I can't quiet get the grasp of using generator functions...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":240,"Q_Id":50518710,"Users Score":0,"Answer":"Personally, it is recommended to use the PReLU activation function before the fully connected dense layer.\nFor example\uff1a\nmodel.add(LSTM(128,input_shape=(train_X.shape[1],train_X.shape[2])))\nmodel.add(BatchNormalization())\nmodel.add(Dropout(.2))\nmodel.add(Dense(64))\nmodel.add(PReLU())","Q_Score":0,"Tags":"python,neural-network,keras,lstm,recurrent-neural-network","A_Id":50520768,"CreationDate":"2018-05-24T21:53:00.000","Title":"LSTM using generator function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to build a custom conda package that upon running conda install <package_name> would create a new conda environment. I wanted to use a environment.yaml file for this purpose. Unfortunately, I can't find any documentation that let's me run conda create -n <env_name> -f environment.yaml inside the recipe. Is there any way I could call such commands inside the recipe?\nI am a beginner in conda and thus, please bear with my loose terminology.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":694,"Q_Id":50519802,"Users Score":0,"Answer":"I'm not and expert in conda and don't know if this is the better way to solve this, but in case it helps someone, I had the same problem, and I solved it out including the depedencies (conda and pip) in a environment.yam, and call conda update in the build.sh.\n\nInclude dependencies in a file called environment.yml.\nMake sure, the environment.yml is included in a folder referenced in the source section of the meta.yaml.\nCall conda update in the build.sh: conda env update -f=environment.yml","Q_Score":0,"Tags":"python,linux,bash,anaconda,conda","A_Id":54406350,"CreationDate":"2018-05-25T00:09:00.000","Title":"Build a conda package that creates a conda environment from env.yaml file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a program that I want to run in python on about 20 cores (for a research math question) but the code has a bit of a memory leak. It is ok running small batches of this code but I would really like to just let it run on these cores for say a couple weeks. Is there any way in Python to build in an automatic restart or something to avoid the long-term memory issues? Delete function does not help. Any help is appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":896,"Q_Id":50521070,"Users Score":1,"Answer":"first, persistent your compute status and result, then write a detect function to detect the memory leak, stop the program, using supervisor or pm2 to restart it.","Q_Score":0,"Tags":"python,memory-leaks,reset","A_Id":50521164,"CreationDate":"2018-05-25T03:24:00.000","Title":"How to automatically restart python to fix memory leak?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a working html build on sphinx v1.1.3 and html pages automatically resize as I change the window size.\nIf I upgraded to sphinx 1.7.4 the page displays with fixed width, with black background on the right. Changing the window size doesn't increase the width beyond a certain max, but shrinking it still shrinks the size of the content and the text wraps. This new behavior is different than v1.1.3 and nothing other than the version of Sphinx was changed.\nI have nothing fancy - looking at html source the only .css files included are classic.css, pygments.css, and html_style.css. Can anyone suggest where to look next to solve the problem?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1110,"Q_Id":50524871,"Users Score":1,"Answer":"Fixed by adding \"body_max_width\": \"none\" to html_theme_options in conf.py","Q_Score":2,"Tags":"css,python-sphinx,restructuredtext","A_Id":50673139,"CreationDate":"2018-05-25T08:32:00.000","Title":"How do I get sphinx or reStructuredText to fit and resize the width of the content to the width of the window?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"After learning a bit about encoder\/decoder models in deep learning (mostly in Keras), i still cannot understand where the learning takes place.\nDoes the encoder just create the feature map and then the decoder tries to get as close as possible as the result with BackProp, or does the encoder learn as well when the model is trained?\nOne last question: if i understood correctly, the filters are the equivalent of the nodes in a classic machine learning model, changing its weights to learn, am i right?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":135,"Q_Id":50524927,"Users Score":0,"Answer":"The encoder learns a compressed representation of the input data and the decoder tries to learn how to use just this compressed representation to reconstruct the original input data as best as possible. Let's say that the initial weights (usually randomly set) produce a reconstruction error of e. During training, both the encoder and decoder layer weights are adjusted so that e is reduced. \nLater on, usually, the decoder layer is removed and the output of the encoder layer (the compressed representation) is used as a feature map of the input.\nWhat does compressed representation mean? If your input is an image of size 20 * 20 = 400 elements, your encoder layer might be of size 100 with a compression factor of 4. In other words, you are learning how to capture the essence of the data with 400 elements in only 100 while still being able to reconstruct the 400 element data with minimum error.\nYou are correct about filters being equivalent of nodes and changing the weights to learn the best representation for the input during training.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,keras","A_Id":50525619,"CreationDate":"2018-05-25T08:36:00.000","Title":"How do Encoder\/Decoder models learn in Deep Learning?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I create a python GUI by PyQt4, and now I'm trying to save this program into Google Cloud Platform(Compute engine) so that I can remotely execute it. But after I execute my python program, there's a problem showed up, the console showed the message :\"cannot connect to X server\". I also try to run with \"xvfb-run python GUI.py\", although it started to run but the graphical user interface didn't showed up, is there any suggestion?  Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":769,"Q_Id":50526152,"Users Score":1,"Answer":"In order to run a GUI application remotely on a Linux\/Unix box, you need to have a X server running on your local machine and ready to accept a connection.  Easiest way to do this is to SSH in and enable X11Forwarding either in your client config, your personal version of the client config, or on the command line (ie, the -X or -Y options).\nUs Linux folks already have an X server, as do them BSD folks.  Mac users can install it and it integrates quite nicely on OS X.  Windows users need to either pay some $ and buy a license for a commercial product, or use cygwin-x.","Q_Score":1,"Tags":"python-2.7,user-interface,google-cloud-platform,xserver","A_Id":50558432,"CreationDate":"2018-05-25T09:41:00.000","Title":"cannot connect to X server error showed up in GCP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I work with caffe and I can run my python code and train network successfully. but I need to draw some plots interactively during trainig so I try to use jupyter notebook and IPython but jupyter cannot import caffe and raise this error:\nImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory\nAny suggestion to solve the problem or to live plot without IPython??\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1203,"Q_Id":50526700,"Users Score":0,"Answer":"Add  export PYTHONPATH=\"${PYTHONPATH}:\/caffe\/path\/caffe\/python\" to the end of ~\/.profile or ~\/.bashrc or ~\/.bash_profile file.\nAfter adding the above line to the file  run source whichever file you have edited. \nIf your are using bash,  ~\/.bashrc is to be edited and if your on MAC, ~\/.profile to be edited\nFor only one Jupyter Session \nimport sys\ncaffe_root = '\/home\/basha\/caffe\/python'\nsys.path.insert(0,caffe_root)\nimport caffe","Q_Score":0,"Tags":"plot,ipython,jupyter-notebook,jupyter,caffe","A_Id":50536580,"CreationDate":"2018-05-25T10:08:00.000","Title":"Jupyter notebook cannot import caffe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have some Python Code (Running Python 2.7.12), which uses VEP to annotate a vcf file against specific transcripts.\nWhen I run the script by double clicking on it (Or running it from command prompt) it gives the following error:\n\nC:\\annotatetsca_KH\\annotate.py:364: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal\nif transcript in specified_transcripts:\n\nThis then causes some variants to not be annotated against specified transcript. However if I load the script into IDLE and then run exactly the same code through IDLE I do not get this error and the variants are annotated correctly.\nDoes anyone know why running the script through IDLE would yield different results? As far as I knew, and from some colleagues I've spoken to, IDLE and Python should treat everything exactly the same. And does anyone know a way to get around having to run the script through IDLE to avoid this error as this script is used by a number of people who aren't familiar with Python\/IDLE and would find it much easier to just run the script by double clicking it (like any other Windows application).\nEDIT (SOLVED):\nI found the cause of the problem. The a few of the transcripts in the transcript list had a space at the end. It appears that IDLE strips trailing spaces but running the python script directly does not. So when running it directly the trailing space got converted to \"\\xa0\", so when it was trying to match the transcript to one in the specified list it did not match. I've removed all spaces and it works fine, and I'll also add a line to remove any spaces when loading in the transcript list!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":159,"Q_Id":50529522,"Users Score":0,"Answer":"I found the cause of the problem. The a few of the transcripts in the transcript list had a space at the end. It appears that IDLE strips trailing spaces but running the python script directly does not. So when running it directly the trailing space got converted to \"\\xa0\", so when it was trying to match the transcript to one in the specified list it did not match. I've removed all spaces and it works fine, and I'll also add a line to remove any spaces when loading in the transcript list!","Q_Score":3,"Tags":"python,windows,bioinformatics,vcf-variant-call-format","A_Id":60548068,"CreationDate":"2018-05-25T12:43:00.000","Title":"Running with IDLE vs running the script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i'm trying to cluster some documents with word2vec and numpy.\nw2v = W2VTransformer()\nX_train = w2v.fit_transform(X_train)\nWhen I run the fit or fit_transform I get this error:\n\nException in thread Thread-8:\n  Traceback (most recent call last):\n    File \"C:\\Users\\lperona\\AppData\\Local\\Continuum\\anaconda3\\lib\\threading.py\", line 916, in _bootstrap_inner\n      self.run()\n    File \"C:\\Users\\lperona\\AppData\\Local\\Continuum\\anaconda3\\lib\\threading.py\", line 864, in run\n      self._target(*self._args, **self._kwargs)\n    File \"C:\\Users\\lperona\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\gensim\\models\\base_any2vec.py\", line 99, in _worker_loop\n      tally, raw_tally = self._do_train_job(data_iterable, job_parameters, thread_private_mem)\n    File \"C:\\Users\\lperona\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\gensim\\models\\word2vec.py\", line 539, in _do_train_job\n      tally += train_batch_cbow(self, sentences, alpha, work, neu1, self.compute_loss)\n    File \"gensim\/models\/word2vec_inner.pyx\", line 458, in gensim.models.word2vec_inner.train_batch_cbow\n  ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()\n\n(X_train is a 2D numpy array of strings)\nDoes anyone know a solution?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":380,"Q_Id":50531181,"Users Score":0,"Answer":"It seems that gensim's word2vec has some problems when working with numpy arrays. Converting data to python lists helped me.","Q_Score":1,"Tags":"python,arrays,python-3.6,word2vec,gensim","A_Id":52078671,"CreationDate":"2018-05-25T14:13:00.000","Title":"Fit method of gensim.sklearn_api.w2vmodel.W2VTransformer throws error when inputed 2-dimensional array of strings","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have multiple modules and they each have their own log. The all write to the log correctly however when a class is instantiated more than once the log will write the same line multiple times depending on the number of times it was created. \nIf I create the object twice it will log every messages twice, create the object three times it will log every message three times, etc...\nI was wondering how I could fix this without having to only create each object only once.\nAny help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10,"Q_Id":50535298,"Users Score":0,"Answer":"I was adding the handler multiple times after each instantiation of a log. I checked if the handler had already been added at the instantiation and that fixed the multiple writes.","Q_Score":0,"Tags":"python-2.7,logging","A_Id":50535472,"CreationDate":"2018-05-25T18:54:00.000","Title":"python logging multiple calls after each instantiation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a program with mainly OpenCV and NumPy, with some SciPy as well. The system needs to be a real-time system with a frame rate close to 30 fps but right now only about 10 fps. Will using Cython help speed this up? I ask because OpenCV is already written in C++ and should already be quite optimized, and NumPy, as far as I understand, is also quite optimized. So will the use of Cython help improve the processing time of my program?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7781,"Q_Id":50535498,"Users Score":0,"Answer":"It all depends on what your program is doing.\nIf you program is just stringing together large operations that are implemented in C++ then cython isn't going to help you much if at all.\nIf you are writing code that works directly on individual pixels then cython could be a big help.","Q_Score":8,"Tags":"python,numpy,opencv,cython","A_Id":61811370,"CreationDate":"2018-05-25T19:09:00.000","Title":"Cython + OpenCV and NumPy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Skip the first two paragraphs if your not interested in why I'm asking this question.\nHere is the situation: I'm using a Moto Z Play with the Projector Modification, the mod is really cool and allows me to literally project my phone screen onto the wall. I've been writing a personal assistant program that helps me with my daily life I.E. Sorting gmails, reminding me of calendar events, keeping track of anything I want it to remember and reminding me of those things when I've asked it to, and much more. Its basically a personal secretary.\nOne new feature I just added was a habit tracker. I created a small graphical interface on my phone using Tasker that would email my \"assistant\" who would then record the habit and create a really cool graph that shows my past habit record as well as using a neural network to predict the next days habit. Only problem is, the graph got really intricate really fast. I want to show a months worth of habits (16 total habits), creating what can be up to a 16 x 31 floating point graph with labels. My laptop screen is just not big enough to display all of that without it just being a mess! I really want to display the graph from my projector mod, the entire wall will definitely be big enough to show all that data.\nOk, now my question (thanks for hanging in there I know that was a lot):\nIs there any way that I can display an image on my phone from a Python program without creating a standalone app? Even if my phone needs to be plugged into my computer to stream the data through a cable.\nI would use a service like Kivy to create a standalone app, but then it wouldn't be hooked up to my assistant, completely defeating the purpose.\nI'm not looking for anything similar to a notification, I really want to draw over the entire screen of my phone. This is something I did with Processing (Java library) a while back, but now I'm using Python because it's more machine learning friendly.\nI've looked into a lot of services but nothing seems to be able to do this. Remember that I dont need to send anything back from my phone, simply display an image on the screen until the desktop side program tells it to stop.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":397,"Q_Id":50536582,"Users Score":0,"Answer":"Not my expertise but if I would need to do something like that I would make a web-service of the python app using django and go to the url with my phone. Don't know if it help....","Q_Score":0,"Tags":"android,python,image,cross-platform","A_Id":50536668,"CreationDate":"2018-05-25T20:41:00.000","Title":"Python: Displaying Graphics on Android Screen from Desktop Script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Skip the first two paragraphs if your not interested in why I'm asking this question.\nHere is the situation: I'm using a Moto Z Play with the Projector Modification, the mod is really cool and allows me to literally project my phone screen onto the wall. I've been writing a personal assistant program that helps me with my daily life I.E. Sorting gmails, reminding me of calendar events, keeping track of anything I want it to remember and reminding me of those things when I've asked it to, and much more. Its basically a personal secretary.\nOne new feature I just added was a habit tracker. I created a small graphical interface on my phone using Tasker that would email my \"assistant\" who would then record the habit and create a really cool graph that shows my past habit record as well as using a neural network to predict the next days habit. Only problem is, the graph got really intricate really fast. I want to show a months worth of habits (16 total habits), creating what can be up to a 16 x 31 floating point graph with labels. My laptop screen is just not big enough to display all of that without it just being a mess! I really want to display the graph from my projector mod, the entire wall will definitely be big enough to show all that data.\nOk, now my question (thanks for hanging in there I know that was a lot):\nIs there any way that I can display an image on my phone from a Python program without creating a standalone app? Even if my phone needs to be plugged into my computer to stream the data through a cable.\nI would use a service like Kivy to create a standalone app, but then it wouldn't be hooked up to my assistant, completely defeating the purpose.\nI'm not looking for anything similar to a notification, I really want to draw over the entire screen of my phone. This is something I did with Processing (Java library) a while back, but now I'm using Python because it's more machine learning friendly.\nI've looked into a lot of services but nothing seems to be able to do this. Remember that I dont need to send anything back from my phone, simply display an image on the screen until the desktop side program tells it to stop.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":397,"Q_Id":50536582,"Users Score":0,"Answer":"Regardless of \"how\" or \"what\", the answer is, you will always need some software running on the Android to capture the stream of data (images) and display it in the screen.\nThe point is, you don't have to write this software yourself. The obvious example that come to mind is use any DLNA compatible software, VLC for example, and have your python to generate a h264 stream and point VLC to it. Another way would be use some http service from your python and simply load it in the browser.\nhope it helps.","Q_Score":0,"Tags":"android,python,image,cross-platform","A_Id":50537235,"CreationDate":"2018-05-25T20:41:00.000","Title":"Python: Displaying Graphics on Android Screen from Desktop Script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Setup\n\nI am running on windows 10\nHave python 3.6 and Java 8\n\ndescription\nI have a Java program which calls and passes an argument to a python program and then receives its output using system commands and cmd. \nQuestion\nHow do I convert it into a single exe file that is the user can run it without installing java(jdk or jre)  and python. \nBoth are a part of my system variable \nThank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3780,"Q_Id":50539030,"Users Score":0,"Answer":"Use pyinstaller to package the python file in a exe.\nThen in the java program replace xyz.py with xyz.exe\nUse JarToExe to convert the jar into a Windows .exe file.\n\nThis way you would have two exe files but the user would not need to install java or python","Q_Score":1,"Tags":"java,python,integration,executable-jar","A_Id":50539385,"CreationDate":"2018-05-26T03:21:00.000","Title":"Converting a jar file to exe file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I moved Python code to another module in the same project and added the module root to a virtualenv using add2virtualenv.\nI configured both modules to use the virtualenv python as SDK. \nThe code runs fine from IntelliJ and from command line, but I get These errors in GUI:\nUnresolved reference '...' less... (\u2318F1) \nThis inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.\nand I have no autocomplete and IDE functions.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":50541404,"Users Score":0,"Answer":"After declaring a source folder in the new module autocomplete and IDE functions were restored.","Q_Score":0,"Tags":"python,intellij-idea,intellisense","A_Id":50543755,"CreationDate":"2018-05-26T09:44:00.000","Title":"IntelliJ Python intellisense doesn't recognize a library added to virtualenvwrapper using add2virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to debug celery task to see whether it is working properly or not, So I put some print statements inside tasks.py. While running the project I have observed that task successfully runs but doesn't print anything on the console. How can I debug the celery task.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3323,"Q_Id":50544020,"Users Score":3,"Answer":"When Celery actually does the work, tasks are being handled by different Python processes. Depending on how you have things configured, those separate processes might have no access to your console. Instead, they will write to Celery's log file (which can be configured in various ways). Find that file, and you'll see print output from your tasks.\nAll of that assumes that you have indeed restarted the Celery workers, as suggested by the comment from Gaurav Tomer.","Q_Score":3,"Tags":"python,django,celery","A_Id":50545722,"CreationDate":"2018-05-26T14:57:00.000","Title":"print statement inside celery task not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"when i import mxnet using import mxnet as mx in intellij (python) then compier generate error \n\nOSError: [WinError 126] The specified module could not be found\" \n\nand shows trackcall shows \n\nline 1 \"import mxnet as mx\" in test.python \n  mxnet already in env\/lib","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":284,"Q_Id":50545193,"Users Score":0,"Answer":"I had the same problem.\nPip did not download correct version of MXnet for my version of CUDA (10.2).\nThe DLL which is not found is for the CUDA version for which MXNet was downloaded. \nI solved the problem by accessing the repository and directly downloading the correct package.\nIn my case it was mxnet_cu102mkl-2.0.0b20200504-py2.py3-none-win_amd64.whl.\nIt worked normally after this.","Q_Score":0,"Tags":"python,intellij-idea,mxnet","A_Id":62376387,"CreationDate":"2018-05-26T17:07:00.000","Title":"importing mxnet in python window 10 using intellj","Data Science and Machine Learning":0,"Database and SQL":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 use tensorlayer.prepro.threading_data, but I'm getting a different return type for different inputs. Sometimes it returns an ndarray and sometimes it returns a list. The documentation doesn't specify what's the reason for the different return types.\nCan anyone shed some light on this?\nAnswer:\nIt seems that what was causing this problem was having items with different shapes in the list. In this instance, PNG images with 3 and 4 channel.\nRemoving the alpha channel (the fourth channel) from all PNG images solved this for me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":50545324,"Users Score":0,"Answer":"It seems that what was causing this problem was having items with different shapes in the list. In this instance, PNG images with 3 and 4 channel. Removing the alpha channel (the fourth channel) from all PNG images solved this for me.","Q_Score":1,"Tags":"python,list,types,return,numpy-ndarray","A_Id":50557193,"CreationDate":"2018-05-26T17:23:00.000","Title":"What affects tensorlayer.prepro.threading_data's return type?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I downloaded multiple modules (Discord API, cx_Freeze) (pip download, Windows 10) and now I wanted to use them. \nBut when I want to import them, it says there isn\u2019t any module. \nFrom my former Python using (before resetting computer) I\u2018ve added a pycache folder and it worked for one module. I\u2018m not able to reproduce it for other modules. What to do?\n\nI\u2018ve only one Python version (3.6.5) on PC.\nI\u2018ve checked the \\site-packages folder and they\u2018re there.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":464,"Q_Id":50546451,"Users Score":0,"Answer":"If you are using python3 then try downloading the library using \n\npip3 install libname\n\nbut if you are using python2 then install the library using \n\npip2 install libname or just pip install libname\n\ntry with these command and reply","Q_Score":0,"Tags":"python,python-3.x,api,module,python-import","A_Id":50546470,"CreationDate":"2018-05-26T19:45:00.000","Title":"Python: ModuleNotFound 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a Python script talking to a MySQL database.\nThis script has been working fine for months.\nAll of a sudden it isn't actually adding anything to the tables it's supposed to modify.\nThe script has a lot of print statements and error handlers and it still runs exactly as if it was working, but nothing shows up in the database.\nIt even prints out \"rows affected: 108\" or whatever, but when I go look at the database in phpMyAdmin it says there are zero rows in the table.\nThe only thing it will do is truncate the tables. There's a section at the beginning that truncates the relevant tables so the script can start filling them up again. If I manually create a new row in a table through phpMyAdmin, that row will disappear when the script runs, like it's properly truncating the tables. But nothing after that does anything. It still runs without errors, but it doesn't actually modify the database.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":50547017,"Users Score":0,"Answer":"Thanks, yeah for some reason the script was no longer autocommitting by default.\nI added \"cnx.autocommit(True)\" and it's working again.","Q_Score":0,"Tags":"python,mysql,rows","A_Id":50548886,"CreationDate":"2018-05-26T21:08:00.000","Title":"mysql rows affected yes but table is still empty","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Python 3.6.5.\nClass A, below for me represents a database table, using SQLAlchemy.\nI'm defining a @staticmethod method that returns a row, but if there's no result, it would return None.\nSince it returns an instance of class A, then the notation normally goes:\n-> A: \nat the end of the def signature, but because A is not yet defined, as it's on class A itself, you are supposed to quote it as:\n-> 'A':\nIs the -> 'A': sufficient?\nOr is there some sort of OR syntax?\nThanks in advance for your advice.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":150,"Q_Id":50547498,"Users Score":1,"Answer":"You can use Optional[A], this means that it can return A or None\nTo make a \"or\" between classes A and B, use Union[A, B]\nNote that you should import Optional and Union from typing","Q_Score":1,"Tags":"python-3.6,type-hinting","A_Id":50547527,"CreationDate":"2018-05-26T22:27:00.000","Title":"Python PEP 484 Type Hints -> return type either class name or None?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two CSV file one contain points for polygon around 2000 point (lat, long). another file has more than 1 billion row ( id, lat, long). how to extract only the points intersect(inside) the polygon by pyspark","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":222,"Q_Id":50548575,"Users Score":-1,"Answer":"Insert csv on map and polygons layer for selection.\ntake Select by Location tools and insert to processing.\nTarget layer is point (csv), Source Layer is Polygon layer.\nSpatial selection for target layer feature(s) is completely contain the source layer feature selected.\nAnd click apply.\nNotes: You must configure porjection same this two layers.","Q_Score":1,"Tags":"python,pyspark,arcgis,pyspark-sql,point-in-polygon","A_Id":68709535,"CreationDate":"2018-05-27T02:35:00.000","Title":"Extract only points inside polygon","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm struggling to find a way of seeing the content of a xml file. I have done a lot of searching and the only progress I am making is to keep running my code without any results","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":587,"Q_Id":50550467,"Users Score":0,"Answer":"Have a look at the BeautifulSoup package and use the lxml parser.","Q_Score":0,"Tags":"python","A_Id":50550515,"CreationDate":"2018-05-27T08:45:00.000","Title":"How can i see the content of a xml file in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running periodically futurize -stage1 to validate changes in my project. There is a class defining a has_key method that flags the has_key fixer. Is it there a way to disable a check in a line or in a file?\nSomething similar to # pylint: disable=... that can be added in a file or inline with a command.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":247,"Q_Id":50558480,"Users Score":0,"Answer":"None of the features requested seems to be available there at the moment. \nWhat you can do is\n\ndisable a specific fixer with -x <fixer specification>\nrun futurize with a list of files to convert, to avoid processing a specific file\nrun futurize as usual and revert\/ignore changes from files\/places you don't care about\n\nSolutions 2 and 3 would require some scripting and I can imagine ignoring changes at the line level using something like # futurize: ignore","Q_Score":0,"Tags":"python,python-3.x,python-2.7,pylint","A_Id":55257854,"CreationDate":"2018-05-28T02:44:00.000","Title":"Disable a check in a file when using Python futurize","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just started using Ubuntu on Windows and was impressed with what it could interact with that was Windows things, files and some programs, etc. but I was wondering if anyone has tried or knew more about the possibility of setting up a virtual environment for python that could be used by both windows and the Linux subsystem. Ideally my thought process would be to have the venv that I could install packages to from either a windows pip command or a Linux pip command. Would this work?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":884,"Q_Id":50558538,"Users Score":1,"Answer":"Not exactly a 100% solution, but I have found a way to do this with the IDEs that I use. In Jetbrains software you can set up an ssh interpreter. You can set up a localhost ssh in your WSL and use that python environment. This also works with clion.","Q_Score":1,"Tags":"windows,python-3.x,windows-subsystem-for-linux,python-venv","A_Id":50780467,"CreationDate":"2018-05-28T02:54:00.000","Title":"Python Venv with Windows Linux Subsystem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Can you write video to memory? I use Raspberry Pi and I don't want to keep writing and deleting videowriter objects created on sd card (or is it ok to do so?).\nIf conditions are not met I would like to discard written video every second. I use type of motion detector recording and I would like to capture moment (one second in this case) before movement has been detected, because otherwise written video loses part of what happened. I use opencv in python environment.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1432,"Q_Id":50559105,"Users Score":1,"Answer":"Video files will often, or even generally, be too big to fit in your main memory so you will be unlikely to be able to just keep the entire video there.\nIt also worth noting that your OS itself may decide to move data between fast memory, slower memory, disk etc as it manages multiple processes but that is likely not important in this discussion.\nIt will depend on your use case but a typical video scenario might be:\n\nreceive video frame from camera or source stream\ndo some processing on the video frame - e.g. transcode it, detect an object, add text or images etc\nstore or send the updated frame someplace\ngo back to first step\n\nIn a flow like this, there is obviously advantage in keeping the frame in memory while working on it, but once done then it is generally not an advantage any more so its fine to move it to disk, or send it to its destination.\nIf you use cases requires you to work on groups of frames, as some encoding algorithms do, then it may make sense to keep the group of frames in memory until you are finished with them and then write them to disk.\nI think the best answer for you will depend on your exact use case, but whatever that it is it is unlikely that keeping the entire video in memory would be necessary or even possible.","Q_Score":0,"Tags":"python,python-3.x,opencv,video,video-capture","A_Id":50564217,"CreationDate":"2018-05-28T04:25:00.000","Title":"How to write video to memory in 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 have 6 points in each row and have around 20k such rows. Each of these row points are actually points on a curve, the nature of curve of each of the rows is same (say a sigmoidal curve or straight line, etc). These 6 points may have different x-values in each row.I also know a point (a,b) for each row which that curve should pass through. How should I go about in finding the rows which may be anomalous or show an unexpected behaviour than other rows? I was thinking of curve fitting but then I only have 6 points for each curve, all I know is that majority of the rows have same nature of curve, so I can perhaps make a general curve for all the rows and have a distance threshold for outlier detection.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":185,"Q_Id":50561180,"Users Score":0,"Answer":"What happens if you just treat the 6 points as a 12 dimensional vector and run any of the usual outlier detection methods such as LOF and LoOP?\nIt's trivial to see the relationship between Euclidean distance on the 12 dimensional vector, and the 6 Euclidean distances of the 6 points each. So this will compare the similarities of these curves.\nYou can of course also define a complex distance function for LOF.","Q_Score":0,"Tags":"python-3.x,cluster-analysis,curve-fitting,outliers,lmfit","A_Id":50597931,"CreationDate":"2018-05-28T07:27:00.000","Title":"Unsupervised Outlier detection","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been moving from php to python for my web-development. Have selected django as my prefeered framework. One thing that bugs is the time it takes for my changes of the python code to reload during development. ~10 sec roughly. \nProbably some of my seconds are due to my selected setup of docker-for-mac with mounted volume. But even if it was down to 5sec it would be annoying. I have moved away from the built-in django development server, over to apache 2.4 with mod_wgsi, this improves the speed of the application a lot, but no the python code reloading.\nI know it's like comparing apples and oranges, but coming from php my code changes are available immediately. Does anyone have any tips to speed this up?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1326,"Q_Id":50562698,"Users Score":4,"Answer":"Traced it back to slow disk access with Docker for Mac.","Q_Score":0,"Tags":"python,django,macos,docker,development-environment","A_Id":51999326,"CreationDate":"2018-05-28T09:04:00.000","Title":"How to speed up django development - Code reload","Data Science and Machine Learning":0,"Database and SQL":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 creating an AWS lambda package I noticed that the ZIP became a lot smaller when I updated from numpy 1.14.0 to 1.14.3. From 24.6MB to 8.4MB.\nThe directory numpy\/random went from 4.3MB to 1.2MB, according to Ubuntus Disc Usage analyzer. When I, however, compare the directories with meld they seem to be identical. So I had a closer look at this and found that only one file (mtrand.cpython-36m-x86_64-linux-gnu.so) differs that much. I guess it is a similar reason why the core became smaller.\nCould somebody explain why this became so much smaller?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":50565322,"Users Score":0,"Answer":"It appears that the difference is in the debug symbols.  Perhaps one was built with a higher level of debug symbols than the other, or perhaps the smaller one was built with compressed debug info (a relatively new feature).  One way to find out more would be to inspect the compiler and linker flags used during each build, or try to build it yourself.","Q_Score":1,"Tags":"python,numpy,shared-libraries","A_Id":50574746,"CreationDate":"2018-05-28T11:26:00.000","Title":"Why did the numpy core size shrink from 1.14.0 to 1.14.1?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python, I can open a file with f= open(<filename>,<permissions>). This returns an object f which I can write to using f.write(<some data>).\nIf, at this point, I access the original final (eg with cat from a terminal), it appears empty: Python stored the data I wrote to the object f and not the actual on-disk file. If I then call f.close(), the data in f is persisted to the on-disk file (and I can access it from other programs).\nI assume data is buffered to improve latency. However, what happens if the buffered data grows a lot? Will Python initiate a write? If so, details on the internals (what influences the buffer size? is the disk I\/O handled within Python or by another program\/thread? is there a chance Python will just hang during the write?) would be much appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":431,"Q_Id":50566484,"Users Score":1,"Answer":"The general subject of I\/O buffering has been treated many times (including in questions linked from the comments).  But to answer your specific questions:\n\nBy default, when writing to a terminal (\u201cthe screen\u201d), a newline causes the text to be flushed up through it.  For all files, the buffer is flushed each time it fills.  (Large single writes might flush any existing buffer contents and then bypass it.)\nThe buffer has a fixed size and is allocated before any data is written; Python\u00a03 doesn\u2019t use stdio, so it chooses its own buffer sizes.  (A few kB is typical.)\nThe \u201cdisk I\/O\u201d (really kernel I\/O, which is distinguishable only in certain special circumstances like network\/power failure) happens within whatever Python write triggers the flush.\nYes, it can hang, if the file is a pipe to a busy process, a socket over a slow network, a special device, or even a regular file mounted from a remote machine.","Q_Score":1,"Tags":"python,python-3.x,io,cpython,disk-io","A_Id":50568224,"CreationDate":"2018-05-28T12:28:00.000","Title":"When is a write to disk triggered?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am having trouble mocking the function. Even if I mock, it still sends an email.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":853,"Q_Id":50566566,"Users Score":1,"Answer":"Propagate a boolean \"mock_if_true\" and at the very last moment do not send the email. This is simple\/stupid and OK as long as you do not have many such booleans.\nOR: override the python class method (if you have one) to mock it\nOR: consider separating the code building the email object from the code sending it. So you may easily test if the object is properly built.","Q_Score":0,"Tags":"python-3.x,unit-testing,python-unittest","A_Id":50566622,"CreationDate":"2018-05-28T12:32:00.000","Title":"How to unit test mock a mail sending function without sending mail python? I am using unittest.mock 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have read that python generates a .pyc file when we execute a python script for the first time and stores it in a _pycache directory but what will happen if python script has an error at some line. will it generate bytecode?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":50567248,"Users Score":1,"Answer":"Python never deletes a cache (bytecode) file, so if it gets written it stays.  It gets written after compilation (if there are no SyntaxErrors) and before execution\u2014even before finding out that, say, an import foo on the first line refers to a nonexistent module.\nSo you can almost say that the file is written unless a SyntaxError is raised, except that other things can raise that: an import inside the first module, an exec\/eval\/compile, or an explicit raise.  It is possible to distinguish these programmatically if needed by counting traceback frames to see if the (first) module ever began execution.","Q_Score":0,"Tags":"python,python-3.x","A_Id":50567979,"CreationDate":"2018-05-28T13:08:00.000","Title":"what happens if a python program contains an error, will it generate a .pyc 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 crawl some websites and while I am using headless chrome browser with selenium to render some HTLM that have embedded JS, I would also like to simply use requests, for the cases where there is no need for JS code rendering. \nIs there a way to know if the HTML needs to be rendered by a browser or if a simple requests.get() would give me the complete HTML content?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":50568534,"Users Score":0,"Answer":"Any HTML code generated by  tags won't be retrieved by requests. \nThe only way to know if a page would need to be rendered by a browser to generate the whole content is to check if its HTML code has  tags.\nStill, if the information you are interested on is not generated by JS, requests.get() will serve you well.","Q_Score":1,"Tags":"javascript,python,html,selenium,python-requests","A_Id":55472306,"CreationDate":"2018-05-28T14:26:00.000","Title":"How to know HTML page needs to be rendered by JS compiler?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use celery for doing snmp requests with easysnmp library which have a C interface.\nThe problem is lots of time is being wasted on I\/O. I know that I should use eventlet or gevent in this kind of situations, but I don't know how to handle patching a third party library when it uses C extensions.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":283,"Q_Id":50569140,"Users Score":1,"Answer":"Eventlet and gevent can't monkey-patch C code.\nYou can offload blocking calls to OS threads with eventlet.tpool.execute(library.io_func)","Q_Score":0,"Tags":"python,celery,gevent,eventlet","A_Id":50585353,"CreationDate":"2018-05-28T15:00:00.000","Title":"using c extension library with gevent","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"i have an unbalanced data set which has two categorical values. one has around 500 values of a particular class and other is only one single datapoint with another class.Now i would like to split this data into test train with 80-20 ratio. but since this is unbalanced , i would like to have the second class to be present in both the test and train data.\nI tried using the test-train-split from sklearn, but it does not give the second class data to be present in both of them. I even tried the stratified shuffle split, but that was also not giving data as i thought.\nIs there any way we can split the data from a data frame forcing both the test and train datasets to have the single datapoint?. I am new to python so having difficulty figuring it out.\nthe data looks like:\na  b  c  d  label\n1  0  0  1   1\n1  1  1  0   1 \n..........\n........\n1  0  0   1  0.\nthe label has only 1 and 0 but the 0 is only one single observation but the rest of the 500 data points are having label as 1","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":50569782,"Users Score":0,"Answer":"Try to do oversampling as you have less amount of data points. Or else you can use neural network preferably MLP, That works fine with unbalanced data.","Q_Score":0,"Tags":"python,machine-learning","A_Id":50583288,"CreationDate":"2018-05-28T15:43:00.000","Title":"splitting data in to test train data when there is unbalance of data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose, I have a model that is already trained with 100 epoch. I tested the model with test data and the performance is not satisfactory. So I decide to train for another 100 epoch. How can I do that?\nI trained with \nmodel.fit(data, target, epochs=100, batch_size=batch_size)\nNow I want to train the same model without adding new data for another 100 epoch. How can I do that?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1201,"Q_Id":50572884,"Users Score":2,"Answer":"Simply call model.fit(data, target, epochs=100, batch_size=batch_size) again to carry on training the same model. model needs to be the same model object as in the initial training, not re-compiled.","Q_Score":1,"Tags":"python-3.x,tensorflow,keras,deep-learning","A_Id":50573045,"CreationDate":"2018-05-28T20:07:00.000","Title":"How to increasing Number of epoch in keras Conv Net","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a project that requires the recognition of just people in a video or a live stream from a camera. I'm currently using the tensorflow object recognition API with python, and i've tried different pre-trained models and frozen inference graphs. I want to recognize only people and maybe cars so i don't need my neural network to recognize all 90 classes that come with the frozen inference graphs, based on mobilenet or rcnn, as it seems this slows the process, and 89 of this 90 classes are not needed in my project. Do i have to train my own model or is there a way to modify the inference graphs and the existing models? This is probably a noob question for some of you, but mind that i've worked with tensorflow and machine learning for just one month.\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":980,"Q_Id":50572962,"Users Score":0,"Answer":"Shrinking the last layer to output 1 or two classes is not likely to yield large speed ups. This is because most of the computation is in the intermediate layers. You could shrink the intermediate layers, but this would result in poorer accuracy.","Q_Score":1,"Tags":"python,python-3.x,tensorflow,object-detection,object-detection-api","A_Id":50594107,"CreationDate":"2018-05-28T20:14:00.000","Title":"Managing classes in tensorflow object detection API","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python Ray looks interesting for machine learning applications. However, I wonder how large Python Ray can handle. Is it limited by memory or can it actually handle data that exceeds memory?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":466,"Q_Id":50575443,"Users Score":2,"Answer":"It currently works best when the data fits in memory (if you're on a cluster, then that means the aggregate memory of the cluster). If the data exceeds the available memory, then Ray will evict the least recently used objects. If those objects are needed later on, they will be reconstructed by rerunning the tasks that created them.","Q_Score":2,"Tags":"python,ray","A_Id":51431522,"CreationDate":"2018-05-29T02:13:00.000","Title":"How large data can Python Ray handle?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python when using np.empty(), for example np.empty((3,1)) we get an array that is of size (3,1) but, in reality, it is not empty and it contains very small values (e.g., 1.7*(10^315)). Is possible to create an array that is really empty\/have no values but have given dimensions\/shape?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":4649,"Q_Id":50579027,"Users Score":1,"Answer":"I am guessing that by empty, you mean an array filled with zeros.\nUse np.zeros() to create an array with zeros. np.empty() just allocates the array, so the numbers in there are garbage. It is provided as a way to even reduce the cost of setting the values to zero. But it is generally safer to use np.zeros().","Q_Score":2,"Tags":"python,numpy","A_Id":50579077,"CreationDate":"2018-05-29T07:48:00.000","Title":"Creating an empty multidimensional array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a sparse matrix and another vector and I want to multiply the matrix and vector so that each column of the vector where it's equal to zero it'll zero the entire column of the sparse matrix. \nHow can I achieve that?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":357,"Q_Id":50580459,"Users Score":0,"Answer":"If you don't like the speed of matrix multiplication, then you have to consider modification of the matrix attributes directly.  But depending on the format that may be slower.\nTo zero-out columns of a csr, you can find the relevant nonzero elements, and set the data values to zero.  Then run the eliminate_zeros method to remove those elements from the sparsity structure.\nSetting columns of a csc format may be simpler - find the relevant value in the indptr.  At least the elements that you want to remove will be clustered together.  I won't go into the details.\nZeroing rows of a lil format should be fairly easy - replace the relevant lists with [].\nAnyways with familiarity of the formats it should possible to work out alternatives to matrix multiplication.  But without doing so, and doing sometimes, I could say which ones are faster.","Q_Score":1,"Tags":"python,numpy,scipy,sparse-matrix,linear-algebra","A_Id":50711224,"CreationDate":"2018-05-29T09:08:00.000","Title":"For a given sparse matrix, how can I multiply it with a given vector of binary values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a sparse matrix and another vector and I want to multiply the matrix and vector so that each column of the vector where it's equal to zero it'll zero the entire column of the sparse matrix. \nHow can I achieve that?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":357,"Q_Id":50580459,"Users Score":1,"Answer":"The main problem is the size of your problem and the fact you're using Python which is on the order of 10-100x slower for matrix multiplication than some other languages. Unless you use something like Cython I don't see you getting an improvement.","Q_Score":1,"Tags":"python,numpy,scipy,sparse-matrix,linear-algebra","A_Id":50589936,"CreationDate":"2018-05-29T09:08:00.000","Title":"For a given sparse matrix, how can I multiply it with a given vector of binary values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want tensor-flow-on-spark programs(for learning purpose),& I don't have a gpu support . Is it possible to execute tensor-flow on spark program without GPU support? \nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":50580534,"Users Score":0,"Answer":"Yes, it is possible to use CPU. Tensorflow will automatically use CPU if it doesn't find any GPU on your system.","Q_Score":1,"Tags":"python,apache-spark,tensorflow,pyspark","A_Id":50580610,"CreationDate":"2018-05-29T09:11:00.000","Title":"Is it possible to execute tensorflow-on-spark program without gpu suppport?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can a login\/ authentication page for a Google app engine (python)  web application be created, without using the Google identity platform (but possibly a platform common for users having emails on other domains)?\nNote: Other email address domains not other social media applications.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":346,"Q_Id":50582119,"Users Score":0,"Answer":"Google AppEngine is a generic platform and you can implement any authentication option that supports web. For example Facebook Connect, Linked In, GitHub, etc.\nRefer to a specific authentication platform documentation for implementation details.","Q_Score":1,"Tags":"google-app-engine,google-oauth,openid,google-app-engine-python,google-openid","A_Id":50582453,"CreationDate":"2018-05-29T10:29:00.000","Title":"On Google app engine web applications, what are the authentication options other than Google identity platforms?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have two containers Auth and Frontend. I have managed to get both the containers working independently, I need to establish the link between the two to send and receive HTTP requests.\nGenerally, the connections are made in angular like http:\/\/localhost:3000\/auth\/.\nNote: Both are in different deployments and services.\nShould I be using Ingress or Nginx?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":391,"Q_Id":50582556,"Users Score":0,"Answer":"service will do the job, you just need to replace localhost with service name.","Q_Score":1,"Tags":"python,angular,docker,kubernetes","A_Id":50584666,"CreationDate":"2018-05-29T10:52:00.000","Title":"Kubernetes - Configuring Angular to Work with a Backend API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have two containers Auth and Frontend. I have managed to get both the containers working independently, I need to establish the link between the two to send and receive HTTP requests.\nGenerally, the connections are made in angular like http:\/\/localhost:3000\/auth\/.\nNote: Both are in different deployments and services.\nShould I be using Ingress or Nginx?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":391,"Q_Id":50582556,"Users Score":0,"Answer":"If your Frontend angular application, needs to connect to the Auth application an the two run on different networks, then just use the IP of your host running the Auth container. If your app requires load balancing, security or you just want to add another level of abstraction and control you may use a proxy like Nginx.","Q_Score":1,"Tags":"python,angular,docker,kubernetes","A_Id":50586256,"CreationDate":"2018-05-29T10:52:00.000","Title":"Kubernetes - Configuring Angular to Work with a Backend API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a django oscar shop that I'm attempting to upgrade to Oscar 1.6.  My shop extends Oscar's promotions model (although at this stage, does little with it).\nIt works fine if I remove the promotions app from the project, and it works fine in django 1.5.  However when I try to start the app in Oscar 1.6, I get the following error.\nLookupError: App 'promotions' doesn't have a 'KeywordPromotion' model.\nIt seems that none of Oscar's promotions models are being loaded at startup.  There's a message in the release notes that says:\n\nThe majority of the Oscar class imports now use dynamic loading,\n  instead of direct imports, for better extensibility and\n  customisability.\n\nDoes anyone know if this, or otherwise is preventing the promotions model from loading?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":538,"Q_Id":50584891,"Users Score":1,"Answer":"In my case I didn't have a models.py in my overridden promotions app...  It just needs to contain this:\n\nfrom oscar.apps.promotions.models import *","Q_Score":0,"Tags":"python,django,django-oscar","A_Id":50585558,"CreationDate":"2018-05-29T12:50:00.000","Title":"LookupError: App 'promotions' doesn't have a 'KeywordPromotion' model when upgrading to django oscar 1.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Getting bored with the traditional cmd on windows, so wanted to build one myself. Any tutorial, library, etc would help.\nThanks in advance! :)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3790,"Q_Id":50585963,"Users Score":3,"Answer":"The shell in the sense of the CLI command interpretor (which are bash or cmd.exe) can be OS independant. The window holding it will have to either depend on a GUI framework (and could be more less OS independant) or directly use an special OS facility. For example on Windows executable can be tagged as GUI processes and have to provide a Windows interface or as console processes. In that latter case, the system automatically provides them with a console system object (which is erroneously called cmd windows) connected to the Stdin, Stdout and Stderr streams.\nIn Unix or Linux, you can find a number of terminal emulators (the xterm family and derivatives like konsole) that by default host the standard shell of the user but can host any other command interpretor.\nThe interpretor will be easy to write in Python - even if a parser like PLY could help - , and will still be easy to install in a console on terminal emulator. If you need to build a GUI to host it, you will have to use a Python GUI framework like tkinter (standard), PyQt, wxWindows, PyGTK, Kivy, etc.","Q_Score":1,"Tags":"python,python-3.x,shell,terminal,terminal-emulator","A_Id":50586463,"CreationDate":"2018-05-29T13:45:00.000","Title":"How to create a terminal emulator in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have measurements of channel impulse responses as complex CSI's. There are two transmitters Alice and Bob and the measurements look like\n[real0], [img0], [real1], [img1], ..., [real99], [img99] (100 complex values).\nAmplitude for the Nth value is ampN = sqrt(realN^2 + imgN^2)\nHow do I get the frequency and phase values out of the complex CSI's?\nAny help would be appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":364,"Q_Id":50587784,"Users Score":0,"Answer":"In Matlab, you do abs(csi) to get the amplitude. To get the phase, angle(csi). Search for similar functions in python","Q_Score":1,"Tags":"python,frequency,phase,amplitude,csi","A_Id":52261793,"CreationDate":"2018-05-29T15:14:00.000","Title":"How to get phase and frequency of complex CSI for channel impulse responses?","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 measurements of channel impulse responses as complex CSI's. There are two transmitters Alice and Bob and the measurements look like\n[real0], [img0], [real1], [img1], ..., [real99], [img99] (100 complex values).\nAmplitude for the Nth value is ampN = sqrt(realN^2 + imgN^2)\nHow do I get the frequency and phase values out of the complex CSI's?\nAny help would be appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":364,"Q_Id":50587784,"Users Score":0,"Answer":"complex-valued Channel State Information ?\npython has cmath, a standard lib for complex number math\nbut numpy and scipy.signal will probably ultimately be more useful to you","Q_Score":1,"Tags":"python,frequency,phase,amplitude,csi","A_Id":50593481,"CreationDate":"2018-05-29T15:14:00.000","Title":"How to get phase and frequency of complex CSI for channel impulse responses?","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 would like to create a test case that solves a rebase conflict, but first I need a way to cause the rebase conflict when doing a git pull --rebase.\nIs there a programmatic way of creating a rebase conflict scenario?\nThe test will be for a GitPython program.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":102,"Q_Id":50588986,"Users Score":2,"Answer":"To quickly create a rebase conflict, you can do the following:\n\nmodify a file, commit and push to the remote repository\nmake a change to the same file on the same line\namend the last commit with git commit -a --amend -C HEAD. The HEAD commit hash has now changed\nrun git pull --rebase\n\nYou'll end up with a conflict at the line you modified.\nTo clean up: you may want to git reset --hard origin\/[your-branch] after your test to get back to step 1.","Q_Score":0,"Tags":"git,git-rebase,git-pull,gitpython,git-merge-conflict","A_Id":50590695,"CreationDate":"2018-05-29T16:28:00.000","Title":"How to create a git pull --rebase conflict for testcase?","Data 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 work with python and data mine some content which I categorize into different categories. \nThen I go to a specific webpage and submit manually the results. \nIs there a way to automate the process? I guess this is a \"form-submit\" thread but I haven't seen any relevant module in Python. Can you suggest me something?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":50589351,"Users Score":0,"Answer":"If you want make this automatic yo have to see which params are send in the form and make a request with this params to the endpoint but directly from your python app, or search a package that simulate a browser and fill the form, but I think that the correct way is making the request directly from your app","Q_Score":0,"Tags":"python,form-submit","A_Id":50589450,"CreationDate":"2018-05-29T16:52:00.000","Title":"How to fill textareas and select option (select tag) and hit submit (input tag) via python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I work with python and data mine some content which I categorize into different categories. \nThen I go to a specific webpage and submit manually the results. \nIs there a way to automate the process? I guess this is a \"form-submit\" thread but I haven't seen any relevant module in Python. Can you suggest me something?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":50589351,"Users Score":0,"Answer":"Selenium Webdriver is the most popular way to drive web pages, but Python also has beautifulsoup;  Either library will work.","Q_Score":0,"Tags":"python,form-submit","A_Id":50589446,"CreationDate":"2018-05-29T16:52:00.000","Title":"How to fill textareas and select option (select tag) and hit submit (input tag) via python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to make a Discord bot in Python that a user can request a unit every few minutes, and later ask the bot how many units they have. Would creating a google spreadsheet for the bot to write each user's number of units to be a good idea, or is there a better way to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":50590788,"Users Score":0,"Answer":"Using a database is the best option. If you're working with a small number of users and requests you could use something even simpler like a text file for ease of use, but I'd recommend a database.\nEasy to use database options include sqlite (use the sqlite3 python library) and MongoDB (I use the mongoengine python library for my Slack bot).","Q_Score":0,"Tags":"python,python-3.x,discord.py","A_Id":50590881,"CreationDate":"2018-05-29T18:31:00.000","Title":"Discord bot with user specific counter","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 spyder onto my computer a few months ago and it has worked fine until I needed to produce a map with station plots and topography. I simply tried to import matplotlib-basemap and get the following error:\n\nFile \"<ipython-input-12-6634632f8d36>\", line 1, in \n  runfile('C:\/Users\/Isa\/Documents\/Freedman\/2018\/ENVIROCOMP\/Stationplots.py', wdir='C:\/Users\/Isa\/Documents\/Freedman\/2018\/ENVIROCOMP')\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\spyder\\utils\\site\\sitecustomize.py\", line 710, in runfile\n      execfile(filename, namespace)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\spyder\\utils\\site\\sitecustomize.py\", line 101, in execfile\n      exec(compile(f.read(), filename, 'exec'), namespace)\nFile \"C:\/Users\/Isa\/Documents\/Freedman\/2018\/ENVIROCOMP\/Stationplots.py\", line 15, in \n      from mpl_toolkits.basemap import Basemap, shiftgrid, cm\nFile \"<frozen importlib._bootstrap>\", line 971, in _find_and_load\nFile \"<frozen importlib._bootstrap>\", line 951, in _find_and_load_unlocked\nFile \"<frozen importlib._bootstrap>\", line 890, in _find_spec\nFile \"<frozen importlib._bootstrap>\", line 864, in _find_spec_legacy\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\pyximport\\pyximport.py\", line 253, in find_module\n      fp, pathname, (ext,mode,ty) = imp.find_module(fullname,package_path)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\imp.py\", line 271, in find_module\n      \"not {}\".format(type(path)))\nRuntimeError: 'path' must be None or a list, not <class '_frozen_importlib_external._NamespacePath'>\n\nIf anyone has gone through this or understands this type of error suggest a way to make basemap work on spyder?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":453,"Q_Id":50591637,"Users Score":0,"Answer":"(Spyder maintainer here) This error was fixed in our 3.2.8 version, released in March\/2018.\nSince you're using Anaconda, please open the Anaconda prompt and run there\nconda update spyder\nto get the fix.","Q_Score":0,"Tags":"python,runtime-error,spyder,matplotlib-basemap","A_Id":50591996,"CreationDate":"2018-05-29T19:29:00.000","Title":"Runtime error when importing basemap into spyder","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know if there is a command that will put the image in the foreground, set it to transparent and block it, that is, the picture will look like a background for a text editor","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":50592183,"Users Score":0,"Answer":"No, there is not. You can't use a picture for the background of a text widget.","Q_Score":0,"Tags":"python,tkinter,python-imaging-library","A_Id":50592323,"CreationDate":"2018-05-29T20:07:00.000","Title":"Add background Image on widget Text using PIL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created virtual environment named virualenv. I have scrapy project and I am using there some programs installed in my virtualenv. When I run it from terminal in VSC I can see errors even when I set up my virtual environment via Ctrl+Shift+P -> Python: Select Interpreter -> Python 3.5.2(virtualenv). Interpreter works in some way, I can import libs without errors etc, but I am not possible to start my scrapy project from terminal. I have to activate my virtual environment first via \/{path_to_virtualenv}\/bin\/activate. Is there a way, how to automatically activate it? Now I am using PyCharm and it is possible there, but VSC looks much better according to me.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2194,"Q_Id":50593213,"Users Score":1,"Answer":"One way I know how,\nStart cmd\nStart you virtual env\n(helloworld) \\path\\etc> code .\nIt will start studio code in this environment. Hope it helps","Q_Score":3,"Tags":"python-3.x,visual-studio-code,virtualenv","A_Id":54950619,"CreationDate":"2018-05-29T21:28:00.000","Title":"How execute python command within virtualenv with Visual Studio Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to install python package python-Levenshtein using:\n\npython setup.py install\n\nBut I return an error:\n\nerror: [WinError 3] The system cannot find the path specified: 'C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v8.1\\lib'\n\nThen,I use \n\npip install python-Levenshtein\n\nbut it returns the same error.I try to install other python packages(i.e. jieba),it works!I don't know why I can't install python-Levenshtein.\nMy OS is 64-bit,and python3.6 is 32-bit.Is there any influence?\nCan anyone help me?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3530,"Q_Id":50595210,"Users Score":1,"Answer":"The package is probably relying on some dependency that you don't have installed. I ran into a similar issue with another package and solved using an anaconda environment (it solved the dependencies problems). Maybe you should try to install it using anaconda?\nOr try installing the Windows SDK, but it will use some GBs of disk space.","Q_Score":1,"Tags":"python,installation,levenshtein-distance","A_Id":50595294,"CreationDate":"2018-05-30T01:37:00.000","Title":"python setup.py install error [WinError 3] The system cannot find the path specified","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I try to install python package python-Levenshtein using:\n\npython setup.py install\n\nBut I return an error:\n\nerror: [WinError 3] The system cannot find the path specified: 'C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v8.1\\lib'\n\nThen,I use \n\npip install python-Levenshtein\n\nbut it returns the same error.I try to install other python packages(i.e. jieba),it works!I don't know why I can't install python-Levenshtein.\nMy OS is 64-bit,and python3.6 is 32-bit.Is there any influence?\nCan anyone help me?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3530,"Q_Id":50595210,"Users Score":1,"Answer":"There shouldn't be any problem with the python package python-Levenshtein, it probably should be with the path as the error clearly says, please check if such a path exists. Or go to that path first, copy paste that into the cmd followed by 'cd' (Hope you're already aware of that.) Then try installing it. Just might work if you had made some typing error while entering the path.","Q_Score":1,"Tags":"python,installation,levenshtein-distance","A_Id":50595997,"CreationDate":"2018-05-30T01:37:00.000","Title":"python setup.py install error [WinError 3] The system cannot find the path specified","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am looking for a wait to schedule tasks based on the reception of an email. \nMore precisely, I received an email with some attached data every week and I need to add these data into a database (and process some information). Is there a way to do it automatically? \nWould airflow be a good option to do this? I found that airflow can send email but I did not find anything about reading mails. \nI know it is possible to read email and download attached file in python. But what would be the best way to check if a specific email is received (defined by a sender) and process its data as soon as it is received ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":912,"Q_Id":50601903,"Users Score":0,"Answer":"You could schedule some BashOperator or PythonOperator that periodically checks new mail and if they find one they start processing it. While I cannot give you any specific library, I am sure there must be a way to read and handle email in Python.","Q_Score":4,"Tags":"python-3.x,email,airflow","A_Id":50606478,"CreationDate":"2018-05-30T10:05:00.000","Title":"airflow : wait to receive email and process data contained in attached 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":"When I am using the below line in my code\nvocab_processor = learn.preprocessing.VocabularyProcessor(max_document_length, vocabulary=bow)\nI get theses warnings. How do I eliminate them ?\nWARNING:tensorflow:From \/usr\/local\/lib\/python3.5\/dist-packages\/tensorflow\/contrib\/learn\/python\/learn\/datasets\/base.py:198: retry (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.\nInstructions for updating:\nUse the retry module or similar alternatives.\nWARNING:tensorflow:From \/tmp\/anyReader-376H566fJpAUSEt\/anyReader-376qtSRQxT2gOiq.tmp:67: VocabularyProcessor.__init__ (from tensorflow.contrib.learn.python.learn.preprocessing.text) is deprecated and will be removed in a future version.\nInstructions for updating:\nPlease use tensorflow\/transform or tf.data.\nWARNING:tensorflow:From \/usr\/local\/lib\/python3.5\/dist-packages\/tensorflow\/contrib\/learn\/python\/learn\/preprocessing\/text.py:154: CategoricalVocabulary.__init__ (from tensorflow.contrib.learn.python.learn.preprocessing.categorical_vocabulary) is deprecated and will be removed in a future version.\nInstructions for updating:\nPlease use tensorflow\/transform or tf.data.\nWARNING:tensorflow:From \/usr\/local\/lib\/python3.5\/dist-packages\/tensorflow\/contrib\/learn\/python\/learn\/preprocessing\/text.py:170: tokenizer (from tensorflow.contrib.learn.python.learn.preprocessing.text) is deprecated and will be removed in a future version.\nInstructions for updating:\nPlease use tensorflow\/transform or tf.data.","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1335,"Q_Id":50602085,"Users Score":-2,"Answer":"All of these warning have instructions for updating. Follow the instructions: switch to tf.data for preprocessing.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,deprecation-warning","A_Id":50611284,"CreationDate":"2018-05-30T10:14:00.000","Title":"Tensorflow contrib learn deprecation warnings","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Python 3.5, and I made an exe flle with pyinstaller.\nI made exe file successfully, and it runs well on my computer.\nBut, when I run it on other computer, it has delay.\nI made exe file by coding 'pyinstaller --onefile --noconsole THEFILE.py'\nWhat's the problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":448,"Q_Id":50602203,"Users Score":1,"Answer":"I assume this delay (according to the OP from of 3 to 8 seconds slower) comes from the HDD which is (due to the storage technology that it uses) slower than an SSD. If you can, I would suggest either:\n\nOptimize your code to be less disk-incriminating\nUpgrade from a HDD to an SSD\n\nBut keep in mind that both options require some actions, so consider first if it's really worth or if you can live with that performance.","Q_Score":1,"Tags":"python,python-3.x,pyinstaller","A_Id":50602679,"CreationDate":"2018-05-30T10:20:00.000","Title":"exe file made by pyinstaller has delay on other computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to run a python app, it opens a window with a prompt instead. Same in Visual Studio Code. I'm Using Python 3.x via Miniconda on Windows 7","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":50605857,"Users Score":0,"Answer":"The problem is caused by file infector malware, replacing executable files","Q_Score":0,"Tags":"windows,python-3.x,visual-studio-code,anaconda,miniconda","A_Id":51195236,"CreationDate":"2018-05-30T13:23:00.000","Title":"What's causing spawning of Python prompt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new (obviously) to python, but not so new to TensorFlow\nI've been trying to debug my program using breakpoint, but everytime I try to check the content of a tensor in the variable view of my Visual Studio Code debugger, the content doesn't show I get this warning in the console:\n\nWARNING:tensorflow:Tensor._shape is private, use Tensor.shape instead. Tensor._shape will eventually be removed.\n\nI'm a bit confused on how to fix this issue. Do I have to wait for an update of TensorFlow before it works?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1348,"Q_Id":50609002,"Users Score":0,"Answer":"You can simply stop at the break point, and switch to DEBUG CONSOLE panel, and type var.shape. It's not that convenient, but at least you don't need to write any extra debug code in your code.","Q_Score":0,"Tags":"python,debugging,tensorflow,visual-studio-code","A_Id":51165112,"CreationDate":"2018-05-30T15:56:00.000","Title":"TensorFlow debug: WARNING:tensorflow:Tensor._shape is private, use Tensor.shape instead. Tensor._shape will eventually be removed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new (obviously) to python, but not so new to TensorFlow\nI've been trying to debug my program using breakpoint, but everytime I try to check the content of a tensor in the variable view of my Visual Studio Code debugger, the content doesn't show I get this warning in the console:\n\nWARNING:tensorflow:Tensor._shape is private, use Tensor.shape instead. Tensor._shape will eventually be removed.\n\nI'm a bit confused on how to fix this issue. Do I have to wait for an update of TensorFlow before it works?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1348,"Q_Id":50609002,"Users Score":0,"Answer":"Probably yes you may have to wait. In the debug mode a deprecated function is being called. \nYou can print out the shape explicitly by calling  var.shape() in the code as a workaround. I know not very convenient.","Q_Score":0,"Tags":"python,debugging,tensorflow,visual-studio-code","A_Id":50609100,"CreationDate":"2018-05-30T15:56:00.000","Title":"TensorFlow debug: WARNING:tensorflow:Tensor._shape is private, use Tensor.shape instead. Tensor._shape will eventually be removed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have django 1.11 with latest django-storages, setup with S3 backend.\nI am trying to programatically instantiate an ImageFile, using the AWS image link as a starting point. I cannot figure out how to do this looking at the source \/ documentation. \nI assume I need to create a file, and give it the path derived from the url without the domain, but I can't find exactly how.\nThe final aim of this is to programatically create wagtail Image objects, that point to S3 images (So pass the new ImageFile to the Imagefield of the image). I own the S3 bucket the images are stored in it.\nUploading images works correctly, so the system is setup correctly.\nUpdate\nTo clarify, I need to do the reverse of the normal process. Normally a physical image is given to the system, which then creates a ImageFile, the file is then uploaded to S3, and a URL is assigned to the File.url. I have the File.url and need an ImageFile object.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2104,"Q_Id":50609686,"Users Score":6,"Answer":"It turns out, in several models that expect files, when using DjangoStorages, all I had to do is instead of passing a File on the file field, pass the AWS S3 object key (so not a URL, just the object key).\nWhen model.save() is called, a boto call is made to S3 to verify an object with the provided key is there, and the item is saved.","Q_Score":4,"Tags":"django,boto3,wagtail,python-django-storages","A_Id":50804853,"CreationDate":"2018-05-30T16:38:00.000","Title":"Django storages S3 - Store existing file","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am a beginner in learning pyqt5. when I run the command from Section3.Dialog import Ui_Dialog as the tutorial taught, It gave me the Error: ModuleNotFoundError: No module named 'Section3'.\n Any guidance will be appreciated as I have already searched the error in net but have no idea yet.\nI watched the tutorial PYQT5 video namely \"Packtpub Python GUI Programming Recipes using PyQt5 [Video]_git.ir\" while in the third folder named \"3. Enhancing the Qt5 GUI Functionality\" in the file namely \"11.Calling Dialogs from the Main Window.mp4\" at the time :\"05:52\" teacher writes this command from Section3.Dialog import Ui_Dialog but when I run it it gave me the error :from Section3.Dialog import Ui_Dialog.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":268,"Q_Id":50610214,"Users Score":1,"Answer":"The python interpreter is looking for a folder called \"Section3\" located in the same directory as your python script. Inside the 'Section3' folder there needs to be a python script called 'Dialog' which has a class or function called 'Ui_Dialog'. Make sure that the folder 'Section3' exists and is located in the same folder as your script, and it should import just fine.","Q_Score":0,"Tags":"python,module,pyqt5","A_Id":50610976,"CreationDate":"2018-05-30T17:13:00.000","Title":"How to solve the Error: No module named 'Section3' while using Pyqt5?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Instead of iterating through each element in a matrix and checking if random() returns lower than the rate of mutation, does it work if you generate a certain amount of random indices that match the rate of mutation or is there some other method?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":50610831,"Users Score":0,"Answer":"Yes. \nSuppose your gene length is 100 and your mutation rate is 0.1, then picking 100*0.1=10 random indices and mutating them is faster than generating & checking 100 numbers.","Q_Score":0,"Tags":"python,numpy,statistics,genetic-algorithm","A_Id":50734768,"CreationDate":"2018-05-30T17:55:00.000","Title":"Mutation algorithm efficiency","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 getting an error with importing seaborn. Does anybody know what I did wrong?\n import seaborn as sns\nImportError: No module named 'seaborn'","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":5086,"Q_Id":50611287,"Users Score":2,"Answer":"You have to install it first.\npip install seaborn \nIf you are using python3 and have both p2 and p3 installed then \npip3 install seaborn\nYou can confirm the import by executing\npython -c \"import seaborn\" or python3","Q_Score":0,"Tags":"python-3.x","A_Id":50611598,"CreationDate":"2018-05-30T18:27:00.000","Title":"How to import seaborn in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement Kernel PCA to my dataset which has both categorical (encoded with one hot encoder) and numeric features and decreases the number of dimensions from 22 to 3 dimensions in total. After that, I will continue with clustering implementation. I use Spyder as IDE.\nIn order to understand the structure of my yielded clusters from the algorithm, I want to interpret which features affect the derived principal components and how they affect them.\nIs it possible? If so, how can I interpret this, is there any method?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":50613294,"Users Score":0,"Answer":"Since you are applying PCA in the kernel space, there is a strictly nonlinear relation with your original features and the features of the reduced data; the eigenvectors you calculate are in the kernel space to begin with. This obstructs a straightforward approach, but maybe you can do some kind of sensitivity analysis. Apply small perturbations to the original features and measure how the final, reduced features react to them. The Jacobian of the final features with respect to the original features can be also a good place to start.","Q_Score":1,"Tags":"python,machine-learning,cluster-analysis,pca,kernel-density","A_Id":50645446,"CreationDate":"2018-05-30T21:00:00.000","Title":"Finding original features' effect to the principal components used as inputs in Kernel PCA","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why standard deviation of uniform distribution calculated with pymc.Uniform(\"stds\",0,100) is different each time?\nI think standard deviation is calculated with this formula '(100-0)\/2\u221a3', so I think there is only one value with one uniform distribution.\nWhat is pymc.Uniform doing? \nIf you know the information about pymc.Uniform with \"std\", please teach me.\nthanks!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":207,"Q_Id":50617502,"Users Score":0,"Answer":"Sorry I made a huge mistake. I thought pymc.Uniform(\"stds\",0,100) do something like calculate standard deviation of uniform distribution. But it just make uniform distribution and just get one of that as value named \"stds\". thank you for your answer!","Q_Score":0,"Tags":"python,pymc,uniform-distribution","A_Id":50633784,"CreationDate":"2018-05-31T05:51:00.000","Title":"Why standard deviation of uniform distribution calculated with pymc.Uniform(\"stds\",0,100) is different each time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm completly stuck on this. I keep getting error message \n\nProcess finished with exit code -1073741819 (0xC0000005)\n\nI'm using pycharm with pyqt5.6 and qt5.6.2 and the problem started when I upgraded to these versions.\nI've tried searching as much as I can, but have not been able to find an answer. Can anyone help please?","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":46053,"Q_Id":50620954,"Users Score":0,"Answer":"Same problem,  this resolved in my case:\n\ntry run from command line (no pycharm), it works ( exception only in debug )\nclosed pycharm\ndeleted \".idea\" folder inside project path\nopened pycharm\nreconfigure python runtime version and command line parameter\ndebug works","Q_Score":23,"Tags":"python,pycharm,pyqt5","A_Id":71405983,"CreationDate":"2018-05-31T09:26:00.000","Title":"Process finished with exit code -1073741819 (0xC0000005) Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm completly stuck on this. I keep getting error message \n\nProcess finished with exit code -1073741819 (0xC0000005)\n\nI'm using pycharm with pyqt5.6 and qt5.6.2 and the problem started when I upgraded to these versions.\nI've tried searching as much as I can, but have not been able to find an answer. Can anyone help please?","AnswerCount":8,"Available Count":5,"Score":-0.024994793,"is_accepted":false,"ViewCount":46053,"Q_Id":50620954,"Users Score":-1,"Answer":"I had the same problem today when plotting a simple matrix. For me just changing the Python interpreter helped. I am not sure why, but I could imagine it has something to do with the installed libraries.","Q_Score":23,"Tags":"python,pycharm,pyqt5","A_Id":69899161,"CreationDate":"2018-05-31T09:26:00.000","Title":"Process finished with exit code -1073741819 (0xC0000005) Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm completly stuck on this. I keep getting error message \n\nProcess finished with exit code -1073741819 (0xC0000005)\n\nI'm using pycharm with pyqt5.6 and qt5.6.2 and the problem started when I upgraded to these versions.\nI've tried searching as much as I can, but have not been able to find an answer. Can anyone help please?","AnswerCount":8,"Available Count":5,"Score":0.049958375,"is_accepted":false,"ViewCount":46053,"Q_Id":50620954,"Users Score":2,"Answer":"I just ran into this error, and found it was caused by using a method from a newer version of Python than my venv was configured (match\/case in 3.10.0 with 3.8 as the interpreter)","Q_Score":23,"Tags":"python,pycharm,pyqt5","A_Id":69586586,"CreationDate":"2018-05-31T09:26:00.000","Title":"Process finished with exit code -1073741819 (0xC0000005) Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm completly stuck on this. I keep getting error message \n\nProcess finished with exit code -1073741819 (0xC0000005)\n\nI'm using pycharm with pyqt5.6 and qt5.6.2 and the problem started when I upgraded to these versions.\nI've tried searching as much as I can, but have not been able to find an answer. Can anyone help please?","AnswerCount":8,"Available Count":5,"Score":0.0748596907,"is_accepted":false,"ViewCount":46053,"Q_Id":50620954,"Users Score":3,"Answer":"Not sure if this is the 'right' way to do it but I ended up completely uninstalling anaconda and rebuilding it. When I then made a new virtual environment the problem resolved. If others have the same issue this might work too. By the way the problem first occurred with an update to pyqt5.","Q_Score":23,"Tags":"python,pycharm,pyqt5","A_Id":50642745,"CreationDate":"2018-05-31T09:26:00.000","Title":"Process finished with exit code -1073741819 (0xC0000005) Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm completly stuck on this. I keep getting error message \n\nProcess finished with exit code -1073741819 (0xC0000005)\n\nI'm using pycharm with pyqt5.6 and qt5.6.2 and the problem started when I upgraded to these versions.\nI've tried searching as much as I can, but have not been able to find an answer. Can anyone help please?","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":46053,"Q_Id":50620954,"Users Score":0,"Answer":"I had the same problem solve it by updating my tensorflow. There is probably some kind of compatibility problem. I realize the problem was from my \"import tensorflow\" because i was not getting an obvious error right after the import line.","Q_Score":23,"Tags":"python,pycharm,pyqt5","A_Id":53706693,"CreationDate":"2018-05-31T09:26:00.000","Title":"Process finished with exit code -1073741819 (0xC0000005) Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a bunch of python classes that are responsible for validating files like so:\n\njava file validator\nhtml file validator\ncss file validator\njavascript file validator\n\nAll of these classes define a validate_file(path) and validate_string(string) function.\nIn the client code of my application, I store all of these validators in an array and I iterate through all of them and call the methods on them in exactly the same way.\nIs there a purpose in my case of defining a base \"validator\" class which defines these methods as abstract? How can I benefit from making these individual classes adhere to the base class? Or maybe in other words, what features would be unlocked if I had a base class with all of these validators implementing it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":50622529,"Users Score":3,"Answer":"If you ever write code that needs to process mixed types, some of which might define the API method, but which shouldn't be considered \"validators\", having a common base class for \"true\" validators might be helpful for checking types ahead of time and only processing the \"true\" validators, not just \"things that look like validators\". That said, the more complex the method name, the less likely you are to end up with this sort of confusion; the odds of a different type implementing a really niche method name by coincidence are pretty small.\nThat said, that's a really niche use case. Often, as you can see, Python's duck-typing behavior is good enough on its own; if there is no common functionality between the different types, the only meaningful advantages to having the abstract base class are for the developer, not the program itself:\n\nHaving a common point of reference for the API consumer makes it clear what methods they can expect to have access too\nFor actual ABCs with @abstractmethod decorated methods, it provides a definition-time check for subclasses, making it impossible for maintainers to omit a method by accident","Q_Score":1,"Tags":"python,oop","A_Id":50622721,"CreationDate":"2018-05-31T10:48:00.000","Title":"What is the purpose of base classes in Python if you're already referring to the implementation classes consistently","Data 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 have a bunch of python classes that are responsible for validating files like so:\n\njava file validator\nhtml file validator\ncss file validator\njavascript file validator\n\nAll of these classes define a validate_file(path) and validate_string(string) function.\nIn the client code of my application, I store all of these validators in an array and I iterate through all of them and call the methods on them in exactly the same way.\nIs there a purpose in my case of defining a base \"validator\" class which defines these methods as abstract? How can I benefit from making these individual classes adhere to the base class? Or maybe in other words, what features would be unlocked if I had a base class with all of these validators implementing it?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":41,"Q_Id":50622529,"Users Score":2,"Answer":"Base classes in Python serve to share implementation details and document likenesses. We don't need to use a common base class for things that function similarly though, as we use protocols and duck typing. For these validation functions, we might not have a use for a class at all; Java is designed to force people to put everything inside classes, but if all you have in your class is one static method, the class is just noise. Having a common superclass would enable you to check dynamically for that using isinstance, but then I'd really wonder why you're handling them in a context where you don't know what they are. For a programmer, the common word in the function name is probably enough.","Q_Score":1,"Tags":"python,oop","A_Id":50622740,"CreationDate":"2018-05-31T10:48:00.000","Title":"What is the purpose of base classes in Python if you're already referring to the implementation classes consistently","Data 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":"The encrypted picture should be decrypted by the xor the key using the first byte 0x89 if the of the PNG file and switching the place of the pictures","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":828,"Q_Id":50623188,"Users Score":0,"Answer":"It's hard to understand what exactly don't work: \nThe code you showed? If yes I'm guessing that it's \"key_transformator\" that is missing. It probably have a function that encode the key based on some algorithm.\nMaybe you trying to decrypt a file made by this code (is this a CTF challenge?): Even if you have the missing function you'll still need the original random key. \nIf you have it you need to xor it with the first one you're file and then find a way to understand what was the next key","Q_Score":0,"Tags":"python,image,encryption,png,python-cryptography","A_Id":50725432,"CreationDate":"2018-05-31T11:24:00.000","Title":"How to decrypt the file in the encryption code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The encrypted picture should be decrypted by the xor the key using the first byte 0x89 if the of the PNG file and switching the place of the pictures","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":828,"Q_Id":50623188,"Users Score":0,"Answer":"The idea is to solve the CSA challenge by your own, not to stackoverflow it ^^\nSince challenge only ends up on Sep, I won't post a full solution.\nHere are few (heavy) tips on how to solve this challenge (png++):\n1) KNOWN file format has KNOWN file header.\n2) Pay close attention the key size is 4 (not by coincidence).\n3) Ask yourself what happens with key_transformation when reaching 0xFF, can it go to 0x100 ??\nThis above should be suffice for you to write your own decryptor, convert the encrypted.png to flag.pnh & get the flag along with it's 30 points","Q_Score":0,"Tags":"python,image,encryption,png,python-cryptography","A_Id":51001790,"CreationDate":"2018-05-31T11:24:00.000","Title":"How to decrypt the file in the encryption code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have developed a Tkinter GUI and need to add a button in the GUI window top panel, next to the minimise, maximise and close buttons. The button then calls a function. How can this be done?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":132,"Q_Id":50624741,"Users Score":1,"Answer":"Tkinter doesn't have any support to do what you want. You'll have to find some sort of platform-specific library to alter what is shown in the window border. \nYour only other option is to turn off the window border provided by your OS with overrideredirect, and then create your own border with whatever controls you want. This requires a lot of work because you also have to write the code for moving and resizing the window, but it's possible.","Q_Score":1,"Tags":"python,tkinter,tkinter-canvas,tkinter-menu","A_Id":50625498,"CreationDate":"2018-05-31T12:48:00.000","Title":"Add button to Tkinter Window panel before minimise, maximise buttons","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I do have a nice piece of software code here (written in Python) which translates a given English number \u2013 e.g., two thousand three hundred forty five \u2013 into the Arabic number \u2013 2345 \u2013 and then in its German equal \u2013 zweitausenddreihundertf\u00fcnfundvierzig. \nOne speciality of the German language is that it \u201ctwists\u201d the tens and the singles, i.e., word-by-word translated, the number 2345 reads in German: two-thousand three-hundred five and forty. \nThe code does that perfectly for any number I entered. Back and forth, from English to German, from German to English.\nYet: How to test systematically that it works correctly for any number? \nIf the code processes a finite set of values, this would be easy, as I could simply could test all values against a table of the correct (= expected) answers\/results. \nHow to test \u2013 at least, partly, \u2013 the code? Any idea will be appreciated :-)","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":70,"Q_Id":50626360,"Users Score":4,"Answer":"Test the small cases. Test the edge cases. Test a few things in between. Testing an infinite number of values is not possible, but systematically checking all plausible failure points and adding tests as bugs are observed will ensure that going forward your library never regresses in quality.\nIn particular, have a few tests for negatives (if your library handles those), have tests for every number from 0-101 (these being the most variable in most languages), have all of the important break-points (999, 1000, 1001, 9999, 10000, 10001, etc...), and have a few things in between.\nAs far as how to actually do that systematically, unittest is the testing module that comes with Python. Many people prefer nose.py or py.test for testing as well. There are plenty of in-depth tutorials on how to use any of those.\nAs @FredLarson just mentioned, using a code coverage tool like coverage.py is a good way to ensure that your tests are all running properly.","Q_Score":1,"Tags":"python","A_Id":50626506,"CreationDate":"2018-05-31T14:11:00.000","Title":"How to verify a number translator?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I do have a nice piece of software code here (written in Python) which translates a given English number \u2013 e.g., two thousand three hundred forty five \u2013 into the Arabic number \u2013 2345 \u2013 and then in its German equal \u2013 zweitausenddreihundertf\u00fcnfundvierzig. \nOne speciality of the German language is that it \u201ctwists\u201d the tens and the singles, i.e., word-by-word translated, the number 2345 reads in German: two-thousand three-hundred five and forty. \nThe code does that perfectly for any number I entered. Back and forth, from English to German, from German to English.\nYet: How to test systematically that it works correctly for any number? \nIf the code processes a finite set of values, this would be easy, as I could simply could test all values against a table of the correct (= expected) answers\/results. \nHow to test \u2013 at least, partly, \u2013 the code? Any idea will be appreciated :-)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":50626360,"Users Score":0,"Answer":"The way I see it is to convert a type sensitive case of an fraction before operation, so if some language has peculiar \"wording\" for specific sets of decimal, you can have a test case that is part of an number of infinite set. \nSince every living language that I know uses decimal system, we have a nice rule about it, the 100, 1000 and etc are most stable digits for pronounciation , since they are always plural in form. So singular forms are often based up to base 10 (we have that much fingers ) by language barrier, for example in my native language after number 5 all numbers become plural because 5 is one whole hand and every number afterwards needs second hand to count it on. This plural\/singular form in then transcribed into linguistics, since 4321 would be written as 4320 and 1 form. I am guessing that most of other languages have some similar elements to their linguistics. So you generally need to check first 2 digits, the 1 place and 10 place to verify your translator.   \nSo in the number of n by converting it to int and testing it by n\/\/10+n\/\/1 in that specific translator and then doing simple comparison of strings you could be able to generate pretty good verification for most of the languages. Then it is just inputting the exceptions for different language groups.   \nBut I must say this is up most based on logic , I am not a linguist or anything. I hope this helped.","Q_Score":1,"Tags":"python","A_Id":50627443,"CreationDate":"2018-05-31T14:11:00.000","Title":"How to verify a number translator?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can the virtualenv command installed by pip3 install virtualenv be used to safely create python2 environments (E.G. python3 -m virtualenv -p \"$(which python2)\" venv2 and vice versa?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17,"Q_Id":50627217,"Users Score":0,"Answer":"Yes, I use that all the time. I have one version of virtualenv and create virtual environments for many Python versions from 2.7 to 3.6 and also for PyPy.","Q_Score":1,"Tags":"python-3.x,virtualenv,python-2.x","A_Id":50634019,"CreationDate":"2018-05-31T14:55:00.000","Title":"Can a python3 implementation of virtualenv safely create python2 environments (and vice versa)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've created a fully functioning blog application in django . But i want to create multiple blogs like i can create multiple posts on blog. How to approach this problem?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":50627239,"Users Score":0,"Answer":"You can just have a one a app per django project beacuse we should import view.py and models.py and urls.py and ... in your some files !","Q_Score":0,"Tags":"python,django","A_Id":50627738,"CreationDate":"2018-05-31T14:56:00.000","Title":"Can i create the same app multiple times in django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've created a fully functioning blog application in django . But i want to create multiple blogs like i can create multiple posts on blog. How to approach this problem?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":132,"Q_Id":50627239,"Users Score":2,"Answer":"No, you cannot have multiple Django apps of the same name. But, much like you\u2019d have a Post model for a singular blog you can create a Blog table and have each Post have a foreign key to the Blog that post belongs to.","Q_Score":0,"Tags":"python,django","A_Id":50627440,"CreationDate":"2018-05-31T14:56:00.000","Title":"Can i create the same app multiple times in django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So for example: if I'm working in an arbitrary application and or model but I want to get a handle to the application and \/ or model that will be actually handling the current URL in the browser address bar.\nUPDATE: my question was perhaps not clear enough. I need the reference to the application inside a model, not a view.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":50628321,"Users Score":0,"Answer":"self.request.resolver_match.namespace","Q_Score":0,"Tags":"python,django","A_Id":50661547,"CreationDate":"2018-05-31T15:54:00.000","Title":"How to tell which application or model will be processing a given URL?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am fairly new to OpenCV 3+ in Python. It looks to me that FileStorage under Python does not support, for example, a writeObj() method. Is it possible to save the SimpleBlobDetector_create to an XML or YAML file using OpenCV 3+ in Python?  Another way to put it is this: using Python OpenCV, can I save XML\/YAML data that is not a numpy array or a scalar (e.g. an object)?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":362,"Q_Id":50630168,"Users Score":0,"Answer":"I have lately had some troubles when using FileStorage with XML or YAML (It appears to be some kind of bug in the OpenCV sourcecode). I would recommend you to try it with JSON. In oder to do so, just change the name of the file to XXXX.json. If you are saving self-constructed structures as well, just construct the structure as if it was a YAML and change the filename to .json.\nI hope this helps you further. \nRegards, David","Q_Score":0,"Tags":"python-3.x,opencv,file-storage","A_Id":50633400,"CreationDate":"2018-05-31T17:56:00.000","Title":"Will OpenCV 3.2+ FileStorage save the SimpleBlobDetector_create object in XML or YML?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing the ad-hoc network. I want to get MAC address of remote raspberry using his IP address. \nI am doing this code \nimport sys,os\nos.system ('sudo arp -n 115.0.0.2') \ni am getting all things like hWthype, name of device and Flags Mask, HWaddress but i need only HWaddress \nCan i body help me how I can extract only MAC address of remote raspberry using python code instead of cmd command?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":196,"Q_Id":50631473,"Users Score":0,"Answer":"you should use Grep command an catch MAC address with a regular expression to retrieve the line of the mac address.\nThen use cut command to select only the address.\nPost ifconfig output so we can help you better","Q_Score":0,"Tags":"python-3.x,networking,raspberry-pi3,mac-address","A_Id":50640031,"CreationDate":"2018-05-31T19:27:00.000","Title":"How to get the MAC address of remote raspberry using his ip address using 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":1,"Web Development":0},{"Question":"Wrote a game and compiled it with pyinstaller.  An EXE file was created but when I go to run it, it thinks for 3-4 seconds and then it returns to command prompt.\nClicking from the folder in Windows does nothing.\nNo errors, nothing!  Do I need something in my code to allow this to run?  The only imports are tkinter and random.\nEdit 1: tested a \"hello world\" script to see if there were issues with pyinstaller, it ran fine.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":594,"Q_Id":50633440,"Users Score":0,"Answer":"I understand that the post is older, but it may be useful for other member who may come across the similar problem.\nI had created a script using Jupiter notebook and it creates ipynb file.\nWhen I create an exe file using pyinstaller, the exe was doing nothing.\nI resolved it by first converting ipynb file to py file using below command:\npyinstaller my_script.py\nIt will create the py file under same location.\nNow, execute below command to create exe file:\npyinstaller my_script.py\nIt will create exe file under dist folder.\nAnd it works.","Q_Score":0,"Tags":"python,tkinter,compilation,pyinstaller","A_Id":56474512,"CreationDate":"2018-05-31T22:05:00.000","Title":"pyinstaller compiled .exe does nothing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed miniconda for Windows10 successfully and then I could install numpy, scipy, sklearn successfully, but when I run import sklearn in python IDLE I receive No module named 'sklearn' in anaconda prompt. It recognized my python version, which was 3.6.5, correctly. I don't know what's wrong, can anyone tell me how do I import modules in IDLE ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1095,"Q_Id":50633488,"Users Score":0,"Answer":"Why bot Download the full anaconda and this will install everything you need to start which includes Spider IDE, Rstudio, Jupyter and all the needed modules..\nI have been using anaconda without any error and i will recommend you try it out.","Q_Score":2,"Tags":"python,import,scikit-learn","A_Id":50634001,"CreationDate":"2018-05-31T22:09:00.000","Title":"import sklearn in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cannot install tensorflow in pycharm on windows 10, though I have tried many different things:\n\nwent to settings > project interpreter and tried clicking the green plus button to install it, gave me the error: non-zero exit code (1) and told me to try installing via pip in the command line, which was successful, but I can't figure out how to make Pycharm use it when it's installed there\ntried changing to a Conda environment, which still would not allow me to run tensorflow since when I input into the python command line: pip.main(['install', 'tensorflow']) it gave me another error and told me to update pip\nupdated pip then tried step 2 again, but now that I have pip 10.0.1, I get the error 'pip has no attribute main'. I tried reverted pip to 9.0.3 in the command line, but this won't change the version used in pycharm, which makes no sense to me. I reinstalled anaconda, as well as pip, and deleted and made a new project and yet it still says that it is using pip 10.0.1 which makes no sense to me\n\nSo in summary, I still can't install tensorflow, and I now have the wrong version of pip being used in Pycharm. I realize that there are many other posts about this issue but I'm pretty sure I've been to all of them and either didn't get an applicable answer or an answer that I understand.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":16417,"Q_Id":50634751,"Users Score":0,"Answer":"what worked for is this;\n\nI installed TensorFlow on the command prompt as an administrator using this command pip install tensorflow\nthen I jumped back to my pycharm and clicked the red light bulb pop-up icon, it will have a few options when you click it, just select the one that says install tensor flow. This would not install in from scratch but basically, rebuild and update your pycharm workspace to note the newly installed tensorflow","Q_Score":3,"Tags":"python,tensorflow,pip,pycharm,conda","A_Id":69603564,"CreationDate":"2018-06-01T01:04:00.000","Title":"Pycharm Can't install TensorFlow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large file almost 20GB, more than 20 mln lines and each line represents separate serialized JSON.\nReading file line by line as a regular loop and performing manipulation on line data takes a lot of time. \nIs there any state of art approach or best practices for reading large files in parallel with smaller chunks in order to make processing faster?\nI'm using Python 3.6.X","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":4432,"Q_Id":50636059,"Users Score":3,"Answer":"Unfortunately, no.  Reading in files and operating on the lines read (such as json parsing or computation) is a CPU-bound operation, so there's no clever asyncio tactics to speed it up.  In theory one could utilize multiprocessing and multiple cores to read and process in parallel, but having multiple threads reading the same file is bound to cause major problems.  Because your file is so large, storing it all in memory and then parallelizing the computation is also going to be difficult.\nYour best bet would be to head this problem off at the pass by partitioning the data (if possible) into multiple files, which could then open up safer doors to parallelism with multiple cores.  Sorry there isn't a better answer AFAIK.","Q_Score":5,"Tags":"python,multithreading,python-3.x","A_Id":50636373,"CreationDate":"2018-06-01T04:21:00.000","Title":"How to read \/ process large files in parallel with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large file almost 20GB, more than 20 mln lines and each line represents separate serialized JSON.\nReading file line by line as a regular loop and performing manipulation on line data takes a lot of time. \nIs there any state of art approach or best practices for reading large files in parallel with smaller chunks in order to make processing faster?\nI'm using Python 3.6.X","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4432,"Q_Id":50636059,"Users Score":1,"Answer":"There are several possibilites, but first profile your code in find the bottlenecks. Maybe your processing does some slows things which can be speed up - which would be vastly preferable to multiprocessing.\nIf that does not help, you could try:\n\nUse another file format. Reading serialized json from text is not the fastest operation in the world. So you could store your data (for example in hdf5) which could speed up processing.\nImplement multiple worker processes which can read portions of the file (worker1 reads lines  0 - 1million, worker2 1million - 2million etc). You can orchestrate that with joblib or celery, depending on your needs. Integrating the results is the challenge, there you have to see what your needs are (map-reduce style?). This is more difficult in python due to no real threading than in other languages, so maybe you could switch the language for that.","Q_Score":5,"Tags":"python,multithreading,python-3.x","A_Id":50636561,"CreationDate":"2018-06-01T04:21:00.000","Title":"How to read \/ process large files in parallel with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I make a python program that periodically (interval of 1 secs) grabs some data from ~700 files and queries to a server with the grabbed data. For a single query response time is about 2 ~ 3 msecs usually, but for some case it could take up to 200 msecs. The program consists of:\n\nOne extracting thread: every 1 sec iterates over 700 files, grabs data then dispatches grabbed data to a shared queue of a so called query pool.\nA pool of N threads: each thread picks data from the shared queue and sends query to the server.\n\nWith N being 4 the program shows the best performance. If I increase N being 8 then the performance degrades significantly. I guess this is because of GIL of python.\nMost of time the program works well but if there is a query that takes much time (due to late responding from the server) then the whole followed queries are dramatically affected.\nI really want to take advantage of threading so I have been looking at gevent but not sure if it may help.\nMy questions:\n\nHow does my current design look like? Is there a better design for it?\nWill gevent help in this problem?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":55,"Q_Id":50637772,"Users Score":1,"Answer":"For your first question, it looks like unclear. You should first figure out where is the bottleneck.\nIf I understand properly, every 1 second your extracting thread add 700 tasks into queue, and then every work thread just take one of these tasks and send a request to a remote server. Am I right?\nIn this case, does the network cause slow down? Could you confirm it? If you think GIL leads to poor performance when using more threads, does that mean there is some calculation bottleneck in your program?\nAnd then for your second question, gevent will help you a lot if the slow down is caused by network.","Q_Score":0,"Tags":"python,python-2.7,gevent,gil","A_Id":50637892,"CreationDate":"2018-06-01T06:59:00.000","Title":"How can I improve performance of my multi-threaded python program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a super newb, so forgive me if my question seems silly. I messed around a little bit with Python back in the day when Python 3.x didn't even exist, and I'm looking to do some web scraping, so I decided to re-familiarize myself with Python in order to use Scrapy. However, in the Scrapy documentation it suggests installing Anaconda, which I'm in the process of doing, but the only two downloads on the Anaconda website are: Python 3.6 version * and Python 3.6 version * (and I can't seem to find any information pertaining to *).\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1534,"Q_Id":50637990,"Users Score":2,"Answer":"Yes it will:\nyou will have to wait for an iPython 3.7 distribution, and install it. In all likeliness, it will be published shortly after the python 3.7 final version, which is due around mid of June","Q_Score":1,"Tags":"python,python-3.x,anaconda","A_Id":50638040,"CreationDate":"2018-06-01T07:14:00.000","Title":"Will Anaconda work with Python 3.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list of S3 keys for the same bucket my_s3_bucket.\nWhat is the most efficient way to figure out which of those keys actually exist in aws S3. By efficient I mean with low latency and hopefully low network bandwidth usage.\nNote: the keys don't share the same prefix so filtering by a single prefix is not effective\nThe two suboptimal approaches I can think of:\n\nCheck the existence of each key, one-by-one\nList all keys in the bucket and check locally. This is not good if the total number of keys is large since listing the keys will still incur many network calls.\n\nIs there any better alternative?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":208,"Q_Id":50638573,"Users Score":2,"Answer":"To answer your question: there is not alternative exposed by the S3 API.\nUsing multiple threads or asynchronous I\/O are solid ways to reduce the real time required to make multiple requests, by doing them in parallel, as you mentioned.\nA further enhancement that might be worth considering would be to wrap this logic up in an AWS Lambda function that you could invoke with a bucket name and a list of object keys as arguments.  Parallellize the bucket operations inside the Lambda function and return the results to the caller already parsed and interpeted, in one tidy response.  This would put most of the bandwidth usage between the function and S3 on the AWS network within the region, which should be the fastest possible place for it to happen.  Lambda functions are an excellent way to abstract away any AWS interaction that requires multiple API requests.  \nThis also allows your Lambda function to be written in a different language than the main project, if desired, because the language does not matter across that boundary -- it's just JSON crossing the border between the two.  Some AWS interactions are easier to do (or to execute in complex series\/parallel fashion) in some languages than in others, in my opinion, so for example, your function could be written in Node.JS even though your project is written in python, and this would make no difference when it comes to invoking the funcrion and using the response it generates.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-s3,boto3","A_Id":50645869,"CreationDate":"2018-06-01T07:49:00.000","Title":"What is the most efficient way in python of checking the existence of multiple s3 keys in the same bucket?","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 temperature, pressure, and altitude readings on my PI using a sensor:\n\nThe problem is, to see the results, I have to execute the code.py every time by myself. I am trying to automate it somehow so it will keep running itself for the time I want. \nOnce that is automated, would like to save the results and analyze the output after some time.\n\nIs there a way I can write code for both the tasks?\nThank you.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":540,"Q_Id":50640980,"Users Score":0,"Answer":"The time module is your friend here. You can set up an infinite loop with while True: and use time.sleep(secs) at the end of the loop (after output).","Q_Score":1,"Tags":"python,python-2.7","A_Id":50641103,"CreationDate":"2018-06-01T10:03:00.000","Title":"How to write an autoscript 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 using Django channels 2.1.1\nSo, this is my logic, one Websocket instance is getting messages of the same type \"alarm.data\" from 2 differents groups. One group \"alarms\" and another groupr \"alarms_specific_for_user_IDUSER\"\nCould I know where they come from whitout adding a \"tag\" in the text message?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":158,"Q_Id":50642592,"Users Score":3,"Answer":"No you will need to put it into the message from the self.scope['user'] property from the Channel that created the message.","Q_Score":1,"Tags":"django,python-3.x,django-channels","A_Id":50652595,"CreationDate":"2018-06-01T11:37:00.000","Title":"Django Channels: Could I know who is the sender of a message?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Just curious if anybody knows why this happens. \nI have python code that triggers and runs a macro in a workbook. The macro can take several hours to run. If I run the macro without the use of Python, my workbook is open and for the time it takes the macro to run I am unable to use excel until the macro is completed. \nWhat I noticed when I run the macro via Python, the sheet doesn't open and not only that but I am able at the same time python runs the excel macro I can actually open up other workbooks. \nHow does this happen? and where is the python triggered workbook macro run from? It doesn't even pop up in the Task Manager?\nIf anybody knows how this happens I would love to know! \nRegards,\nT","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":136,"Q_Id":50645044,"Users Score":1,"Answer":"Python is creating an instance of Excel, setting Application.Visible=False and doing its thing there. It's actually tying up the UI thread of that instance, but you can't see it. During that time, you are able to open another instance of Excel by clicking on the Start Menu link (or double clicking a file), and you can use the UI thread of that instance to do other things.\nWhen you open Excel, by default, it sets Application.Visible=True. Your macro is running in that instance and blocking the UI. Since you're using the default UI instance, it's blocked and you don't get the option to create another instance.","Q_Score":0,"Tags":"python,vba,excel","A_Id":50645464,"CreationDate":"2018-06-01T13:56:00.000","Title":"Running Macro through Python and still able open new excel sheets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to using python modules.\nI'm currently working on a python 2.7 script that will be deployed to many remote computers (which have python 2.7 on them). The problem is that the script needs to use a module, which I am not allowed to install on those computers.\nI'm wondering if it is possible to include the module files in the same package as my script (possibly have them compiled first), and then have the script import the library from that local folder, thus achieving a \"portable\" script.\nIf that is possible, how would I go about doing that?\n\nSpecifics: I'm running 2.7.11 on Windows needing to use Paramiko.\nI'm asking this question because the similar questions that I can find either do not answer mine, or expect me to be familiar with core python structures with which I am not. I also DON'T want to include the entirety of python and then install the module onto that, something I see is often called Portable Python. I just want to send my script and the module and nothing more.\n\nMany thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":890,"Q_Id":50645396,"Users Score":2,"Answer":"To install modules in a specific directory, you can try  pip install module --target=.\nBy default python search for those modules in same directory as the script first, then, if not available, it will search for python install lib files.","Q_Score":1,"Tags":"python,module,portability","A_Id":50646131,"CreationDate":"2018-06-01T14:13:00.000","Title":"Portable Python Script with Module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to run official Django tutorial. I've installed Django using pip, and started the project. And when I run python manage.py runserver the console shows the same thing as in tutorial, but when I open the page http:\/\/127.0.0.1:8000\/ or localhost:8000 I only see 404 not found.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":323,"Q_Id":50645707,"Users Score":1,"Answer":"You are getting the 404 error because in your urls.py you have not added url for \/.\nTry in your browser: localhost:8000\/admin and it should work.","Q_Score":0,"Tags":"python,django","A_Id":50645856,"CreationDate":"2018-06-01T14:29:00.000","Title":"Can't run Django project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Suppose I want to select a range of columns from a dataframe: Call them 'column_1' through 'column_60'. I know I could use loc like this:\ndf.loc[:, 'column_1':'column_60']\nThat will give me all rows in columns 1-60. \nBut what if I wanted that range of columns plus 'column_81'. This doesn't work:\ndf.loc[:, 'column_1':'column_60', 'column_81']\nIt throws a \"Too many indexers\" error. \nIs there another way to state this using loc? Or is loc even the best function to use in this case? \nMany thanks.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4458,"Q_Id":50647832,"Users Score":0,"Answer":"You can use pandas.concat():\npd.concat([df.loc[:,'column_1':'columns_60'],df.loc[:,'column_81']],axis=1)","Q_Score":9,"Tags":"python,python-3.x,pandas,dataframe","A_Id":50648721,"CreationDate":"2018-06-01T16:44:00.000","Title":"Can you use loc to select a range of columns plus a column outside of the range?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After reinstalling anaconda, I set up a new Pycharm project. When I debug one of my python scripts it get this error:\n\npydev debugger: process 12636 is connecting \n  Process finished with exit code -1073741819 (0xC0000005)\n\nThis only happens when I debug. Any advice?  \nFor reference, these are the software versions I am currently using:\n\nPython version: 3.5\n  Pycharm version: 2017.3\n  Anaconda Navigator version:1.8.7","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2753,"Q_Id":50649827,"Users Score":0,"Answer":"Similar to above I've encountered this with a range of packages with pyCharm--usually closing and opening pyCharm fixes the issue (updating pyCharm version).\nIf that doesn't work, I methodically update all python packages.","Q_Score":5,"Tags":"python,debugging,pycharm,anaconda","A_Id":56296925,"CreationDate":"2018-06-01T19:18:00.000","Title":"Pycharm debugger can't start: finished with exit code -1073741819 (0xC0000005)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"After reinstalling anaconda, I set up a new Pycharm project. When I debug one of my python scripts it get this error:\n\npydev debugger: process 12636 is connecting \n  Process finished with exit code -1073741819 (0xC0000005)\n\nThis only happens when I debug. Any advice?  \nFor reference, these are the software versions I am currently using:\n\nPython version: 3.5\n  Pycharm version: 2017.3\n  Anaconda Navigator version:1.8.7","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2753,"Q_Id":50649827,"Users Score":1,"Answer":"Same problem as you Bob.\nHere is my workaround (not a complete fix but it does the job) :\nCopy\/paste the entire sites-packages folder from the anaconda (or miniconda => works for me too) to the default python interpreter and switch to this default python.exe interpreter inside your project (Settings -> Project Interpreter).\nFor example overwrite the folder C:\\Miniconda3\\Lib\\site-packages to C:\\Users\\ YOUR_ACCOUNT\\venv\\Lib\\site-packages\nAfter that run AND debug modes are both available.\nHope this help !","Q_Score":5,"Tags":"python,debugging,pycharm,anaconda","A_Id":50769555,"CreationDate":"2018-06-01T19:18:00.000","Title":"Pycharm debugger can't start: finished with exit code -1073741819 (0xC0000005)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Trying to figure this out, because there is an inconsistency between when I run the code from Pycharm and from terminal.\nPycharm add automatically the current working directory; so if I add a module that is contained in my CWD, that is not in Pythonpath, it works just fine.\nBut when running from terminal, Python does complain, because my import statements refer to modules that are not reachable, because the CWD is not added to PYTHONPATH (I did verify this printing out the content of the variable, while running from Pycharm and from Terminal).\nSo at this point I am assuming that in my startup code, I need to add to Pythonpath the current directory, or this is not correct? I have no way to tell where the final user may put my code in; I just assume that the whole directory containing all my different modules, is located in a specific place.\nTo be more specific, this is where I am at:\n\nmy CWD when I run from Pycharm is \/apps\/myapp\/logic\/, I run the script after cd in that directory, and I call the script with .\/myscript.py\nThe script has the #!\/usr\/bin\/python3 line as first line, instead of running it with python3 -m myscript.py\nThe error I get, is when loading a module that is either in the same directory of my script (\/apps\/myapp\/logic\/) or one level above (\/apps\/myapp\/); sadly the module load happen before my __main__ is running; so I can't add to sys.path the current directory from which the script run. \nAll these issues are not happening if I just run the script from Pycharm","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":451,"Q_Id":50650521,"Users Score":0,"Answer":"After various trial and error, and thanks to the info that I did get from the comments; I did find 2 ways to solve the issue.\n1) Create a shell script or another python script, which is adding the current directory (where all the files lives), and have no import in this file. Then the script call the script that has the main function.\n2) On the top of the module, right after import sys, add the statement to add the path, in this way the current directory will be added to the PATH and it will be accessible, when the import try to access the module.\nNeither look very nice, but this is all that I was able to find, to solve the issue. Pretty sure there is a more elegant way to do so","Q_Score":0,"Tags":"python","A_Id":50652494,"CreationDate":"2018-06-01T20:20:00.000","Title":"Pycharm run the code adding the current working dir to PYTHONPATH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to add in multiple log files into a Logs folder, but instead of having to change the code each time you start the program, i want to make the log file's name \"Log(the time).log\". I'm using logger at the moment, but i can switch. I've also imported time.\nEdit: Here is some of the code i am using:\nimport logging\nlogger = logging.getLogger('k')\nhdlr = logging.FileHandler('Path to the log file\/log.log')\nformatter = logging.Formatter('At %(asctime)s, KPY returned %(message)s at level %(levelname)s\nhdlr.setFormatter(formatter)\nlogger.addHandler(hdlr)\nlogger.setLevel(logging.DEBUG)\nlogger.info('hello')","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":115,"Q_Id":50651797,"Users Score":0,"Answer":"I got help from another website.\nYou have to change the hdlr to:\n({FOLDER LOCATION}\/Logs\/log{}.log'.format(datetime.datetime.strftime(datetime.datetime.now(), '%Y%m%d%H%M%S_%f')))","Q_Score":2,"Tags":"python,logging,time","A_Id":50667780,"CreationDate":"2018-06-01T22:39:00.000","Title":"Add the time in a log name using logger","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I started learning django a few days back and started a project, by luck the project made is good and I'm thinking to deploy it. However I didn't initiate it in virtual environment. have made a virtual environment now and want to move project to that. I want to know how can I do that ? I have created requirements.txt whoever it has included all the irrelevant library names. How can I get rid of them and have only that are required for the project.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":863,"Q_Id":50654965,"Users Score":1,"Answer":"Django is completely unrelated to the environment you run it on.  \nThe environment represents which python version are you using (2,3...) and the libraries installed.\nTo answer your question, the only thing you need to do is run your manage.py commands from the python executable in the new virtual environment. Of course install all of the necessary libraries in the new environment if you haven't already did so.\nIt might be a problem if you created a python3 environment while the one you created was in python2, but at that point it's a code portability issue.","Q_Score":1,"Tags":"python,django,virtualenv","A_Id":50655762,"CreationDate":"2018-06-02T08:27:00.000","Title":"How should I move my completed Django Project in a Virtual Environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"from wordcloud import WordCloud\nWhile importing WordCloud I get below issue.Can you help with this?\nRuntimeWarning: The _imaging extension was built for another version of Pillow or PIL:\nCore version: 5.1.0\nPillow version: 4.2.1\n  \"The _imaging extension was built for Python with UCS2 support; \"\n\nImportError                               Traceback (most recent call last)\n in ()\n----> 1 from wordcloud import WordCloud\n:\\Users\\jhaas\\Anaconda2\\lib\\site-packages\\wordcloud__init__.py in ()\n----> 1 from .wordcloud import (WordCloud, STOPWORDS, random_color_func,\n      2                         get_single_color_func)\n      3 from .color_from_image import ImageColorGenerator\n      4 \n      5 all = ['WordCloud', 'STOPWORDS', 'random_color_func',\nC:\\Users\\jhaas\\Anaconda2\\lib\\site-packages\\wordcloud\\wordcloud.py in ()\n     17 from operator import itemgetter\n     18 \n---> 19 from PIL import Image\n     20 from PIL import ImageColor\n     21 from PIL import ImageDraw\nC:\\Users\\jhaas\\Anaconda2\\lib\\site-packages\\PIL\\Image.py in ()\n     65                           \"Pillow version: %s\" %\n     66                           (getattr(core, 'PILLOW_VERSION', None),\n---> 67                            PILLOW_VERSION))\n     68 \n     69 except ImportError as v:\nImportError: The _imaging extension was built for another version of Pillow or PIL:\nCore version: 5.1.0\nPillow version: 4.2.1","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":50655939,"Users Score":0,"Answer":"This is a Pillow problem, rather than a WordCloud problem. As it says, your Pillow installation has somehow become part 4.2.1, part 5.1.0. The simplest solution would be to reinstall Pillow.","Q_Score":0,"Tags":"python,python-imaging-library,python-import,word-cloud","A_Id":51454563,"CreationDate":"2018-06-02T10:28:00.000","Title":"Wordcloud-Pillow issue","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a web application using flask. I have already gotten somewhat comfortable with using python, and have done so using spyder, inside of Anacanda Navigator. Now I am playing around with flask doing basic functions and have successful so far by testing it out in local server 127.0.0.1:5000. The problem I am having is that I cannot stop the server once I run the script in spyder. I have stopped the script and run other scripts through the console, but the local server remains the same. \nThe reason this is a problem for me is because when I try to change files and run a different flask script, the server does not update with the new information. For example, if I run a flask script that returns \"Hello World\" on the main page, and then I stop that file, open a new file that has a different flask script that returns \"The sky is blue\" the server does not change when I check it on chrome or any other browser. It will onyl return \"Hello World\"\nI have been able to fix this problem by completely restarting my computer, but I am wondering if there is another way, just to restart the local server, 127.0.0.1:5000. Thank You!\nAlso I am using windows","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1455,"Q_Id":50659044,"Users Score":0,"Answer":"I do : \"Run > Configuration per file > Execute in an external system terminal\",\nthen when you run your .py containing the app.run, it will be launched in an external console. If you close the console the server will be closed too.","Q_Score":1,"Tags":"python,flask,localserver","A_Id":70109368,"CreationDate":"2018-06-02T16:41:00.000","Title":"using flask in spyder stuck in local server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to create a web application using flask. I have already gotten somewhat comfortable with using python, and have done so using spyder, inside of Anacanda Navigator. Now I am playing around with flask doing basic functions and have successful so far by testing it out in local server 127.0.0.1:5000. The problem I am having is that I cannot stop the server once I run the script in spyder. I have stopped the script and run other scripts through the console, but the local server remains the same. \nThe reason this is a problem for me is because when I try to change files and run a different flask script, the server does not update with the new information. For example, if I run a flask script that returns \"Hello World\" on the main page, and then I stop that file, open a new file that has a different flask script that returns \"The sky is blue\" the server does not change when I check it on chrome or any other browser. It will onyl return \"Hello World\"\nI have been able to fix this problem by completely restarting my computer, but I am wondering if there is another way, just to restart the local server, 127.0.0.1:5000. Thank You!\nAlso I am using windows","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1455,"Q_Id":50659044,"Users Score":0,"Answer":"To Kill the local server, you may use Ctrl+C command and not any other command. This command is also mentioned when the server is up and running.","Q_Score":1,"Tags":"python,flask,localserver","A_Id":52691604,"CreationDate":"2018-06-02T16:41:00.000","Title":"using flask in spyder stuck in local server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Even after installing selenium using pip on Python 3.6.3, whenever I try to run a code with import selenium I get the message that ModuleNotFoundError: No module named 'selenium'.\nI usually use Anaconda Prompt and run my codes in Jupyter notebook, but I made the installation also in regular cmd.\nDoes anyone have an idea about how to solve this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":170,"Q_Id":50660585,"Users Score":0,"Answer":"I think you have both python 2.x and python 3.x installed on your system.\nWhen you do pip install selenium, the module gets installed for python 2.x.\nTo install the module for python 3.x, use pip3 install selenium.","Q_Score":0,"Tags":"python,selenium,anaconda,jupyter-notebook","A_Id":50660627,"CreationDate":"2018-06-02T19:47:00.000","Title":"Python not finding modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing a convolution neural network (CNN) model to predict whether a patient in category 1,2,3 or 4. I use Keras on top of TensorFlow.\nI have 64 breast cancer patient data, classified into four category (1=no disease, 2= \u2026., 3=\u2026.., 4=progressive disease). In each patient's data, I have 3 set of MRI scan images taken at different dates and inside each MRI folder, I have 7 to 8 sub folders containing MRI images in different plane (such as coronal plane\/sagittal plane etc). \nI learned how to deal with basic \u201cCat-Dog-CNN-Classifier\u201d, it was easy as I put all the cat & dog images into a single folder to train the network. But how do I tackle the problem in my breast cancer patient data? It has multiple folders and sub-solders.\nPlease suggest.","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":1045,"Q_Id":50664485,"Users Score":-1,"Answer":"Use os.walk to access all the files in sub-directories recursively and append to the dataset.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":55304529,"CreationDate":"2018-06-03T08:14:00.000","Title":"Train CNN model with multiple folders and sub-folders","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to output formatted raw HTML code in Jupyter as with prettify from BeautifulSoup?\nWhen I call prettify in Jupyter, it gives me the same messy output as with simply calling .content on the result I get from requests.get.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":986,"Q_Id":50665045,"Users Score":0,"Answer":"Have you tried to use a print?\nJupyter (like ipython) calls the __repr__ method for the result of the operation.\nIn this case, it's the __repr__ of a string, which adds the simple quotes and escapes the special characters (\\n, \\t...) so they are not interpreted.\nBut those characters are interpreted with print","Q_Score":0,"Tags":"python,html,web-scraping,beautifulsoup,jupyter","A_Id":50665835,"CreationDate":"2018-06-03T09:41:00.000","Title":"How to show formatted\/indented HTML code in Jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have started using Atom recently and for the past few days, I have been searching on how to change the default version used in Atom (The default version is currently python 2.7 but I want to use 3.6). Is there anyone I can change the default path? (I have tried adding a profile to the \"script\" package but it still reverts to python 2.7 when I restart Atom. Any help will be hugely appreciated!! Thank you very much in advance.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":11411,"Q_Id":50667214,"Users Score":0,"Answer":"I would look in the atom installed plugins in settings.. you can get here by pressing command + shift + p, then searching for settings.\nThe only reason I suggest this is because, plugins is where I installed swift language usage accessibility through a plugin that manages that in atom.\nOther words for plugins on atom would be \"community packages\"\nHope this helps.","Q_Score":3,"Tags":"python,python-3.x,editor,atom-editor","A_Id":50682856,"CreationDate":"2018-06-03T14:02:00.000","Title":"How can I change the default version of Python Used by Atom?","Data 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 started using Atom recently and for the past few days, I have been searching on how to change the default version used in Atom (The default version is currently python 2.7 but I want to use 3.6). Is there anyone I can change the default path? (I have tried adding a profile to the \"script\" package but it still reverts to python 2.7 when I restart Atom. Any help will be hugely appreciated!! Thank you very much in advance.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":11411,"Q_Id":50667214,"Users Score":0,"Answer":"Yes, there is. After starting Atom, open the script you wish to run. Then open command palette and select 'Python: Select interpreter'. A list appears with the available python versions listed. Select the one you want and hit return. Now you can run the script by placing the cursor in the edit window and right-clicking the mouse. A long menu appears and you should choose the 'Run python in the terminal window'. This is towards the bottom of the long menu list. The script will run using the interpreter you selected.","Q_Score":3,"Tags":"python,python-3.x,editor,atom-editor","A_Id":50846354,"CreationDate":"2018-06-03T14:02:00.000","Title":"How can I change the default version of Python Used by Atom?","Data 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 started using Atom recently and for the past few days, I have been searching on how to change the default version used in Atom (The default version is currently python 2.7 but I want to use 3.6). Is there anyone I can change the default path? (I have tried adding a profile to the \"script\" package but it still reverts to python 2.7 when I restart Atom. Any help will be hugely appreciated!! Thank you very much in advance.","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":11411,"Q_Id":50667214,"Users Score":10,"Answer":"I am using script 3.18.1 in Atom 1.32.2\nNavigate to Atom (at top left) > Open Preferences > Open Config folder.\nNow, Expand the tree as script > lib > grammars\nOpen python.coffee and change 'python' to 'python3' in both the places in command argument","Q_Score":3,"Tags":"python,python-3.x,editor,atom-editor","A_Id":53507376,"CreationDate":"2018-06-03T14:02:00.000","Title":"How can I change the default version of Python Used by Atom?","Data 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 started using Atom recently and for the past few days, I have been searching on how to change the default version used in Atom (The default version is currently python 2.7 but I want to use 3.6). Is there anyone I can change the default path? (I have tried adding a profile to the \"script\" package but it still reverts to python 2.7 when I restart Atom. Any help will be hugely appreciated!! Thank you very much in advance.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":11411,"Q_Id":50667214,"Users Score":0,"Answer":"I came up with an inelegant solution that may not be universal.  Using platformio-ide-terminal, I simply had to call python3.9 instead of python or python3.  Not sure if that is exactly what you're looking for.","Q_Score":3,"Tags":"python,python-3.x,editor,atom-editor","A_Id":71299879,"CreationDate":"2018-06-03T14:02:00.000","Title":"How can I change the default version of Python Used by Atom?","Data 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 working on a Django application which uses django-leaflet, but this question applies to any python library. I want to change some django-leaflet code to see if the changes would solve a problem we are having. What are my options? Do I need to create an example app in the django-leaflet repository and preform my modify-test loop there? Or do I need to upload individual re-named versions of django-leaflet to pypi?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":430,"Q_Id":50668530,"Users Score":2,"Answer":"You can modify your 3rd party app by uninstalling it using pip uninstall, then copying (or git cloning) the app into your source tree. You may need to temporarily add a line like sys.path.append(\".\/django-leaflet\") to your manage.py file so that the 3rd party modules will be in scope.\nOnce you are happy with your changes, you can send them to the original author as a pull request or upload your own version of the app.","Q_Score":3,"Tags":"python,django,pypi","A_Id":50668531,"CreationDate":"2018-06-03T16:26:00.000","Title":"How do I effectively make changes to a 3rd party django app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've started tinkering with python recently and I'm on my way to create my very first telegram bot mainly for managing my Raspberry Pi and a few things connected to it. The bot is done but I would like to send a message to all the users that have already interacted with the bot when it starts, basically saying something like \"I'm ready!\", but I haven't been able to find any information about it.\nIs there any specific method in the API already done to do this? Or should I create another file to store the chat_id from all the users and read it with python?\nThank you all for your help!! Regards!","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":3875,"Q_Id":50668567,"Users Score":1,"Answer":"You should save users in database or file.After that use for to send_message one by one to all users that you have in database or file.","Q_Score":1,"Tags":"python,telegram-bot,python-telegram-bot","A_Id":50695439,"CreationDate":"2018-06-03T16:31:00.000","Title":"Send a message to all users when the bot wake up","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":"Working with Professional edition of PyCharm, I'm trying to configure a server for remote deployment of my project over SFTP with OpenSSH + authentication agent as auth type. I have tried to configure PyCharm in Settings > Build, Execution and Deployment > Add server. However, even though I setup and verify successful configuration by Test SFTP connection button, as soon as I click Apply or OK, the User name becomes blank for some reason. Thereafter, when I try to sync with the remote server, the connection fails.\nI've found a possible workaround by changing Host name to user@host form instead, which works, but then I can't use the same server configuration when I try to setup a remote interpreter under Project > Project Interpreter > Add SSH interpreter. (there it shows my host url as ssh:\/\/null@host). I'm guessing the null is there because PyCharm is somehow not saving the username. I've tried to edit the .idea\/webServers.xml file, but couldn't find appropriate key-value pair to change there for user name to be preserved.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4374,"Q_Id":50671746,"Users Score":21,"Answer":"I solved it by changing the standard way to change credentials in Pycharm. \nTo do this go to Settings\/Preferences | Appearance & Behavior | System Settings | Passwords and choose the KeePass option. \nThat solved the problem for me. \nApparently there are problems storing on native keychain. (I'm on Mint 18.3)","Q_Score":18,"Tags":"python,pycharm,jetbrains-ide","A_Id":51944689,"CreationDate":"2018-06-03T23:01:00.000","Title":"PyCharm remote deployment: user name not being saved","Data Science and Machine Learning":0,"Database and SQL":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":"Working with Professional edition of PyCharm, I'm trying to configure a server for remote deployment of my project over SFTP with OpenSSH + authentication agent as auth type. I have tried to configure PyCharm in Settings > Build, Execution and Deployment > Add server. However, even though I setup and verify successful configuration by Test SFTP connection button, as soon as I click Apply or OK, the User name becomes blank for some reason. Thereafter, when I try to sync with the remote server, the connection fails.\nI've found a possible workaround by changing Host name to user@host form instead, which works, but then I can't use the same server configuration when I try to setup a remote interpreter under Project > Project Interpreter > Add SSH interpreter. (there it shows my host url as ssh:\/\/null@host). I'm guessing the null is there because PyCharm is somehow not saving the username. I've tried to edit the .idea\/webServers.xml file, but couldn't find appropriate key-value pair to change there for user name to be preserved.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4374,"Q_Id":50671746,"Users Score":0,"Answer":"What worked for me was first going to the following tab:\nPreferences -> Build, Execution, Deployment -> Deployment [Connection Tab]\nand then inserting my  in the \"User name\" blank.\nNote: your user name appears in the ip address of you ec2. e.g. username@@xxx.amazonaws.com","Q_Score":18,"Tags":"python,pycharm,jetbrains-ide","A_Id":63552421,"CreationDate":"2018-06-03T23:01:00.000","Title":"PyCharm remote deployment: user name not being saved","Data Science and Machine Learning":0,"Database and SQL":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 scanned PDFs (image based) of bank statements.\nGoogle vision API is able to detect the text pretty accurately but it returns blocks of text and I need line by line text (bank transactions).\nAny idea how to go about it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3081,"Q_Id":50673749,"Users Score":0,"Answer":"In Google Vision API there is a method fullTextAnnotation which returns a full text string with \\n specifying the end of the line, You can try that.","Q_Score":2,"Tags":"python,pdf,ocr,google-cloud-vision","A_Id":62009637,"CreationDate":"2018-06-04T05:13:00.000","Title":"Line by line data from Google cloud vision API OCR","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Django with Django Cachalot and I need know what is cached with cachalot in my server? I want to use CACHALOT_UNCACHABLE_TABLES parameter and I need to know if this works and certain tables are not cached. I hope that somebody can help me, thank you.\nI initialized the parameter like this: CACHALOT_UNCACHABLE_TABLES = frozenset(('django_migrations', 'company_company', 'customers_customer, 'auth_user'))","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":383,"Q_Id":50678758,"Users Score":-2,"Answer":"Correctly, I checked this. If you use CACHALOT_UNCACHABLE_TABLES setting this variable with the table names that tables doesn't cache with Cachalot.","Q_Score":1,"Tags":"python,django,caching","A_Id":50975064,"CreationDate":"2018-06-04T10:43:00.000","Title":"How can I know what is cached with django cachalot on my server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a very large data set and am using Keras' fit_generator to train a Keras model (tensorflow backend).  My data needs to be normalized across the entire data set however when using fit_generator, I have access to relatively small batches of data and normalization of the data in this small batch is not representative of normalizing the data across the entire data set.  The impact is quite large (I tested it and the model accuracy is significantly degraded).\nMy question is this:  What is the correct practice of normalizing data across entire data set when using Keras' fit_generator?  One last point:  my data is a mix of text and numeric data and not images, and hence I am not able to use some of the capabilities in Keras' provided image generator which may address some of the issues for image data.\nI have looked at normalizing the full data set prior to training (\"brute-force\" approach, I suppose) but I am wondering if there is a more elegant way of doing this.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2686,"Q_Id":50682119,"Users Score":3,"Answer":"The generator does allow you to do on-the-fly processing of data but pre-processing the data prior to training is the preferred approach:\n\nPre-process and saving avoids processing the data for every epoch, you should really just do small operations that can be applied to batches. One-hot encoding for example is a common one while tokenising sentences etc can be done offline.\nYou probably will tweak, fine-tune your model. You don't want to have the overhead of normalising the data and ensure every model trains on the same normalised data.\n\nSo, pre-process once offline prior to training and save it as your training data. When predicting you can process on-the-fly.","Q_Score":3,"Tags":"python,tensorflow,machine-learning,keras,keras-2","A_Id":50683342,"CreationDate":"2018-06-04T13:46:00.000","Title":"How to normalize data when using Keras fit_generator","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've seen it being used in a couple of projects in conjunction with yield and Deferred like so: yield ~ some_fun(). Sometimes it works without the ~ bit, sometimes it doesn't. Can't figure out what it actually does, help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":137,"Q_Id":50682485,"Users Score":3,"Answer":"Check the class being 'inverted' has a __invert__(self) method, if so, that's overriding the tilde operator.","Q_Score":1,"Tags":"python","A_Id":50682569,"CreationDate":"2018-06-04T14:05:00.000","Title":"What does \"~\" do in python besides being a bitwise negation op?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Python IDLE 2.7.8. The IDLE shows \"No Subprocess\" as follow:\nPython 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32\nType \"copyright\", \"credits\" or \"license()\" for more information.\n==== No Subprocess ====\nI could import subprocess module successfully. But how can I switch to \"==== Subprocess ====\" mode? I spend hours but find no way to do that. who could help me please?\nThanks a lot","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":50684074,"Users Score":0,"Answer":"If one starts IDLE with -n, which means \"no subprocess, run user code in the IDLE process\", then it prints \"No Subprocess\" after the rest of the startup header as a reminder that one in not running in normal mode.\nThe way to start in normal 'run user code in a subprocess' mode is to not pass the '-n' flag.  Look at how your are starting IDLE.  It must involve a startup line with '-n' somewhere.","Q_Score":0,"Tags":"python,subprocess,python-idle","A_Id":50688145,"CreationDate":"2018-06-04T15:30:00.000","Title":"how to switch \"process\" on with Python IDLE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I ran python3 -m pip install -U discord.py but it only installed discord.py v0.16.x. How do I install the new discord.py rewrite v1.0? \nI uninstalled the old discord.py using pip uninstall discord.py and re-ran pip to install discord.py, only to get version v0.16.x again instead of the new v1.0 version.","AnswerCount":18,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":46947,"Q_Id":50686388,"Users Score":0,"Answer":"If your also having trouble with all the above install python using the Microscoft Store and use the commands above in command prompt","Q_Score":13,"Tags":"python,anaconda,discord,discord.py,discord.py-rewrite","A_Id":65622492,"CreationDate":"2018-06-04T18:06:00.000","Title":"How to install discord.py rewrite?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I ran python3 -m pip install -U discord.py but it only installed discord.py v0.16.x. How do I install the new discord.py rewrite v1.0? \nI uninstalled the old discord.py using pip uninstall discord.py and re-ran pip to install discord.py, only to get version v0.16.x again instead of the new v1.0 version.","AnswerCount":18,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":46947,"Q_Id":50686388,"Users Score":0,"Answer":"pip install discord.py\nInstalling from the source[branch:master] is not recommended since it is in the testing phase(Writing as of 5\/30\/2021).If you want to test out  buttons then sure go ahead and run pip install -U git+https:\/\/github.com\/Rapptz\/discord.py@master","Q_Score":13,"Tags":"python,anaconda,discord,discord.py,discord.py-rewrite","A_Id":67759391,"CreationDate":"2018-06-04T18:06:00.000","Title":"How to install discord.py rewrite?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I ran python3 -m pip install -U discord.py but it only installed discord.py v0.16.x. How do I install the new discord.py rewrite v1.0? \nI uninstalled the old discord.py using pip uninstall discord.py and re-ran pip to install discord.py, only to get version v0.16.x again instead of the new v1.0 version.","AnswerCount":18,"Available Count":6,"Score":0.022218565,"is_accepted":false,"ViewCount":46947,"Q_Id":50686388,"Users Score":2,"Answer":"Open Command Prompt and type in;\npip install discord.py\nor;\npip install discord.py==1.0.1\nand then if you want voice do;\npip install discord.py[voice]","Q_Score":13,"Tags":"python,anaconda,discord,discord.py,discord.py-rewrite","A_Id":56053192,"CreationDate":"2018-06-04T18:06:00.000","Title":"How to install discord.py rewrite?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I ran python3 -m pip install -U discord.py but it only installed discord.py v0.16.x. How do I install the new discord.py rewrite v1.0? \nI uninstalled the old discord.py using pip uninstall discord.py and re-ran pip to install discord.py, only to get version v0.16.x again instead of the new v1.0 version.","AnswerCount":18,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":46947,"Q_Id":50686388,"Users Score":0,"Answer":"Open CMD and go to the folder of your discord bot eg:\ncd C:\\Users\\max\\Desktop\\DiscordBot\nNext type this in CMD: pip install discord.py\nThat should work","Q_Score":13,"Tags":"python,anaconda,discord,discord.py,discord.py-rewrite","A_Id":63932305,"CreationDate":"2018-06-04T18:06:00.000","Title":"How to install discord.py rewrite?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I ran python3 -m pip install -U discord.py but it only installed discord.py v0.16.x. How do I install the new discord.py rewrite v1.0? \nI uninstalled the old discord.py using pip uninstall discord.py and re-ran pip to install discord.py, only to get version v0.16.x again instead of the new v1.0 version.","AnswerCount":18,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":46947,"Q_Id":50686388,"Users Score":0,"Answer":"Go to python.org and click on download python.\n\nNow, open and run it. Make sure you add python to the path. Click on Install. Once installed you can close it.\n\nGo to git-scm.com and click on Download for Windows.\n\nOnce installed open it. Make sure Use git from windows command prompt is selected.\nThen after clicking on next on everything, click on install.\n\nOnce install is finished, hit finish.\n\nCopy your script address. In my case, it was Local\/\/Programs\/\/Python\/\/Python39\/\/Scripts\n\nOpen your command prompt and type cd Local\/\/Programs\/\/Python\/\/Python39\/\/Scripts. Paste your address there, mine will not work for you. Hit Enter.\n\nThen type py -3 -m pip install -U discord.py. Hit enter again. Once the install is finished close the command prompt.\n\n\nNow you are ready to go ;)","Q_Score":13,"Tags":"python,anaconda,discord,discord.py,discord.py-rewrite","A_Id":64515264,"CreationDate":"2018-06-04T18:06:00.000","Title":"How to install discord.py rewrite?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I ran python3 -m pip install -U discord.py but it only installed discord.py v0.16.x. How do I install the new discord.py rewrite v1.0? \nI uninstalled the old discord.py using pip uninstall discord.py and re-ran pip to install discord.py, only to get version v0.16.x again instead of the new v1.0 version.","AnswerCount":18,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":46947,"Q_Id":50686388,"Users Score":0,"Answer":"Easy, open Command Prompt and type \"pip install discord.py\"\nIf you do that you're most probably going to want \"pip install requests\"\nIf the pip command doesn't work, open your python installer and make sure to click on the add to evironment variables option!\nThat's all your good to go!\nUse Visual Studio Code or Atom, they are the best so far that I have used for my bot!","Q_Score":13,"Tags":"python,anaconda,discord,discord.py,discord.py-rewrite","A_Id":62136173,"CreationDate":"2018-06-04T18:06:00.000","Title":"How to install discord.py rewrite?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The 'merror' and 'logloss' result from XGB multiclass classification differs by about 0.01 or 0.02 on each run, with the same parameters. Is this normal? \nI want 'merror' and 'logloss' to be constant when I run XGB with the same parameters so I can evaluate the model precisely (e.g. when I add a new feature).\nNow, if I add a new feature I can't really tell whether it had a positive impact on my model's accuracy or not, because my 'merror' and 'logloss' differ on each run regardless of whether I made any changes to the model or the data fed into it since the last run.\nShould I try to fix this and if I should, how can I do it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1725,"Q_Id":50688189,"Users Score":0,"Answer":"Managed to solve this. First I set the 'seed' parameter of XgBoost to a fixed value, as Hadus suggested. Then I found out that I used sklearn's train_test_split function earlier in the notebook, without setting the random_state parameter to a fixed value. So I set the random_state parameter to 22 (you can use whichever integer you want) and now I'm getting constant results.","Q_Score":1,"Tags":"python,performance,machine-learning,xgboost","A_Id":50723630,"CreationDate":"2018-06-04T20:20:00.000","Title":"XgBoost accuracy results differ on each run, with the same parameters. How can I make them constant?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I accidentally installed a wrong version of wxPython (3.0.2.0).\nWhen I try to install the latest wxPython-4.0.1, I get the following error:\n\nFound existing installation: wxPython 3.0.2.0\n  Cannot uninstall 'wxPython'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.\n\nSo, I searched around a bit and apparently you have to use the uninstaller found within your original wxPython-3.0.2.0 dmg file in order to uninstall it. I did not have the file anymore it seemed, and went through my history to get the exact download and version from Sourceforge (I think!), but when I use the uninstaller, I get the following:\n\n* No wxPython installations found!  *\n\nHow am I able to remove this old version of wxPython?\nI am very new to this, so sorry if this sounds stupid.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1068,"Q_Id":50688630,"Users Score":1,"Answer":"As you've discovered wxPython Classic and wxPython Phoenix use different installation strategies. In fact, Classic's approach is quite messy compared to Phoenix's, the uninstallation script was created to help to undo some of that (especially the things left behind by the OSX Installer tool.)\nThe good news however is that you can manually clean up the parts that pip is complaining about. I don't have it installed here any longer to be able to give you exact instructions, but from memory it should be something like this.\n\nIn your Python's site-package folder, (something like \/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/site-packages) remove folders and files starting with wx.\nIn \/usr\/local\/lib remove any folders starting with wxPython\n\nAdditionally, wxPython Phoenix is not required to be installed globally like Classic was. If you use virtualenvs or Python3's venvs then you can install the wheel in them instead of your global Python environment if you prefer.","Q_Score":1,"Tags":"wxpython,uninstallation","A_Id":50733198,"CreationDate":"2018-06-04T20:54:00.000","Title":"Cannot uninstall wxPython 3.0.2.0 (macOS)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I made a program that grabs the top three new posts on the r\/wallpaper subreddit. It downloads the pictures every 24 hours and adds them to my wallpapers folder. What I'm running into is how to have the program running in the background. The program resumes every time I turn the computer on, but it pauses whenever I close the computer. Is there a way to close the computer without pausing the program? I'm on a mac.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":50690141,"Users Score":0,"Answer":"Programs can't run when the computer is powered off. However, you can run a computer headlessly (without mouse, keyboard, and monitor) to save resources. Just ensure your program runs over the command line interface.","Q_Score":0,"Tags":"python,macos,praw","A_Id":50690315,"CreationDate":"2018-06-04T23:38:00.000","Title":"How to keep python programming running constantly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Series of problems!\nShould probably have made env first - which now I am doing,,but cannot overturn what is done- and installed the package within it, so as not to affect dependencies of others. But this is done already. \nNow the installed module is imported finely, but IDE does not recognize the interpreter anymore. I was using python 3.5 previously. Now with graph-tool library from the awesome http:\/\/conda.anaconda.org\/vgauthier channel,, (works for OS X perfectly) \nFollowing either makes sense, or.. was resolved,\n\nI cannot use all the libraries installed on the previous python version\nI cannot set Interpreter setting on IDE preferences tab, (maybe my lack of knowledge)\nwhereis python, which python on terminal & sys.executable on python all point to what they did before the upgraded python was executed on the terminal. So this could be why I am not sure where to designate for path on IDEs\n\nbut why can I not execute python 3.5 like I can with 2.7? Is it because conda-installed 3.5 was upgraded to 3.6?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":18,"Q_Id":50690990,"Users Score":0,"Answer":"Just located alias and designated, IDE recognized it.\nProbably have to remove all previous versions of python though.\nOr use them separately for different working environments (not very meaningful using one Mac)","Q_Score":0,"Tags":"path,ide,dependencies,python-3.6","A_Id":50691165,"CreationDate":"2018-06-05T01:56:00.000","Title":"Python upgraded installing other library, previous version paths are there, but not executable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script that I am trying to execute every 2 seconds.. to begin it reads a .csv with pd.read_csv. Then executes modifications on the df and finally overwrites the original .csv with to_csv.\nI'm running into a PermissionError: [Errno 13] Permission denied: and from my searches I believe it's due to trying to open\/write too often to the same file though I could be wrong.\n\nAny suggestions how to avoid this?\nNot sure if relevant but the file is stored in one-drive folder.\nIt does save on occasion, seemingly randomly.\nIncreasing the timeout so the script executes slower helps but I want it running fast!\n\nThanks","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1596,"Q_Id":50692295,"Users Score":-1,"Answer":"Close the file that you are trying to read and write and then try running your script.\nHope it helps","Q_Score":0,"Tags":"python,pandas,csv,io","A_Id":50692350,"CreationDate":"2018-06-05T04:53:00.000","Title":"Pandas - Read\/Write to the same csv quickly.. getting permissions error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new comer of Selenium, and I can use selenium with Chromedriver to do basic auto-test now, the code works fine, but the problem is Chrome browser always update automatically at the backend, and code always fail to run after Chrome update. I know I need to download new chromedriver to solve this issue, but I wonder if there's any way to solve this issue without disabling chromebrowser update? tks.\nI'm using Windows 10 \/ Chrome Version 67 \/ Python 3.6.4 \/ Selenium 3.12.0","AnswerCount":8,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":32246,"Q_Id":50692358,"Users Score":0,"Answer":"For me this resolve the issue:\npip install --upgrade --force-reinstall chromedriver-binary-auto","Q_Score":10,"Tags":"python,google-chrome,selenium,selenium-webdriver,selenium-chromedriver","A_Id":70550827,"CreationDate":"2018-06-05T05:00:00.000","Title":"How to work with a specific version of ChromeDriver while Chrome Browser gets updated automatically through Python selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new comer of Selenium, and I can use selenium with Chromedriver to do basic auto-test now, the code works fine, but the problem is Chrome browser always update automatically at the backend, and code always fail to run after Chrome update. I know I need to download new chromedriver to solve this issue, but I wonder if there's any way to solve this issue without disabling chromebrowser update? tks.\nI'm using Windows 10 \/ Chrome Version 67 \/ Python 3.6.4 \/ Selenium 3.12.0","AnswerCount":8,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":32246,"Q_Id":50692358,"Users Score":0,"Answer":"Maybe this will help you.\nI managed to use ChromeDriver version 96.0.4664.45 editing in JUPYTER, I was using Pycharm before and it didn't respond.","Q_Score":10,"Tags":"python,google-chrome,selenium,selenium-webdriver,selenium-chromedriver","A_Id":70526550,"CreationDate":"2018-06-05T05:00:00.000","Title":"How to work with a specific version of ChromeDriver while Chrome Browser gets updated automatically through Python selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training with some documents with gensim's Doc2vec.  \nI have two types of inputs:  \n\nWhole English Wikipedia: Each article of Wikipedia text is considered as one \ndocument for doc2vec training. (Total around 5.5 million articles or documents)\nSome documents related to my project that are manually prepared and collected from some websites. (around 15000 documents).\nWhere each document the size is around 100 sentences.\n\nFurther, I want to use this model to infer sentences of size (10~20 words).\nI request some clarification on my approach.\nIs the method of training over documents(size of each document approx. 100 sentences each) and then inferring over new sentence correct. ?\nOr, should I train over only sentences and not documents and then infer over the new sentence.?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":332,"Q_Id":50692739,"Users Score":1,"Answer":"Every corpus and project goals are different. Your approach of training on larger docs but then inferring on shorter sentences could plausibly work, but you have to try it to see how well, and then iteratively test whether perhaps shorter training docs (as single sentences or groups-of-sentences) work better, for your specific goal. \nNote that gensim Doc2Vec inference often gains from non-default parameters \u2013 especially more steps (than the tiny default 5) or a smaller starting alpha (more like the training default of 0.025), especially on shorter documents. And, that inference also may work better or worse depending on original model metaparameters.\nNote also that an implementation limit means that texts longer than 10,000 tokens are silently truncated in gensim Word2Vec\/Doc2Vec training. (If you have longer docs, you can split them into less-than-10K-token subdocuments, but then repeat the tags for each subdocument, to closely simulate what effect training with a longer document would have had.)","Q_Score":0,"Tags":"python,gensim,training-data,doc2vec","A_Id":50709075,"CreationDate":"2018-06-05T05:38:00.000","Title":"Can doc2vec be useful if training on Documents and inferring on sentences only","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I managed to succefully install django-allauth and configure my app to allow authentication via Google Oauth2, but when i try to configure GitLab Oauth2 integration it juste fail with the message:\n\nThe redirect URI included is not valid.\n\nI did set \nhttp:\/\/xxx.xxx.xx\/accounts\/gitlab\/login\/callback\/ as Callback url \nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1718,"Q_Id":50696207,"Users Score":0,"Answer":"You need to whitelist the redirect URLs of your app in GitLab.\nAdmin Area -> Applications -> Your Django App -> Callback URL","Q_Score":1,"Tags":"python,django,django-allauth","A_Id":52316520,"CreationDate":"2018-06-05T09:03:00.000","Title":"Using self-hosted GitLab as Oauth Provider","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I want to match ip address which comes in below format,\nExample :   .1.9.2...1.6.8...2.3.4...1.3.4.\nNot sure how to match the dots between the digits.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":64,"Q_Id":50703995,"Users Score":1,"Answer":"Figured out the solution.. So the basic issue was how the base64decoding is done. It varies depending on the OS. So on some machines it was decoding and showing the ip in form [1.9.2...1.6.8...2.5.4...1.2.2.] for such input the above code works perfectly.\nBut i observed in some machine with same code n python version the output came in different format, so on such cases the above code would fail. The best possible solution was to decode the base64 string to consistent format.\nAfter alot of hit n try, observed that converting the encoding ndecoding to 'utf-16' resulted in providing a better readable string with now the ip showing up as normal:192.168.254.122 so on this you may use a basic ip match regex and move forward.","Q_Score":1,"Tags":"python-3.x","A_Id":50755981,"CreationDate":"2018-06-05T15:37:00.000","Title":"Working on a regex expression","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are building a Python app to receive file from another app, process the received file and send the processed file back to that app.\nFor the transfer of file we are considering options SFTP and messaging queue.Below are our requirements\n\nSecurely transfer files\nAcknowledge the file and notify the sender apps for any failures\nLoad balance the requests for file processing\nTo be able verify the status of file sent by the sender app \n\nWhich do you think is better suited given this scenario SFTP or message queue? I know each one has its own merits and demerits but wanted to get some insight and also find if something is being overlooked","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":135,"Q_Id":50705041,"Users Score":0,"Answer":"Message-driven systems depend almost entirely on the quality and reliability of their broker, and as I have no experience with QPID's brokers I cannot comment on that crucial facet of the decision. However, Qpid uses AMQP, and should you run into trouble with the selected broker, switching to another should not be overly complex.\nNow that is is out of the way, let's have a look at your requirements. In my opinion your requirements are mostly \"natural\" properties of a good messaging system, so you get properly working, reliable implementations of your requirements without having to layer mechanisms on top of a file transfer protocol.\n\nSecurely transfer files\n\nAMQP and SFTP are probably quite comparable wrt security, if properly implemented\n\nAcknowledge the file and notify the sender apps for any failures\n\nAlmost automatic using the appropriate delivery guarantee mode for QPID, messy to do via sftp.\n\nLoad balance the requests for file processing\n\nAlso effortless by having all consumers attached to the same queue, avoiding double consumption in a way that avoids message loss is hard to get right with just sftp. \n\nTo be able verify the status of file sent by the sender app\n\nNot 100% sure what you mean here, but AMQP has mechanisms to ensure that the sender knows with certainty that a message has been properly accepted by the broker, and that a file has been correctly received and processed by the receiver (manual acknowledgement mode).\nOne argument that wasn't mentioned yet is high availability: message brokers, being crucial elements of many enterprise processing chains, have extensive high availability features to avoid downtime and message loss.","Q_Score":0,"Tags":"python-3.x,sftp,message-queue,messaging","A_Id":50705844,"CreationDate":"2018-06-05T16:38:00.000","Title":"File transfer between 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed XDebug as well as Python Debugger.\nI have written a simple program: print(\"OK\"). \nI was also able to do Ctrl + B and build.\nHowever, all I get in the console is: [Finished in 0.1s] while I would like to see the output as well:\"OK\". \nTools > XDebug has no Run command, nor has it Step In command nor any other command that would help me run my program. \nHow do I recover from this situation, please?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":50705542,"Users Score":0,"Answer":"def do_stuff():\n    print(\"doin' stuff\")\nHit Ctrl+B\nOutput:\n[Finished in 0.1s]","Q_Score":1,"Tags":"python","A_Id":50715891,"CreationDate":"2018-06-05T17:11:00.000","Title":"Python Sublime and XDebug","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to deploy WSGi based app that's built using Python, Flask on AWS Lambda. \nBut, it seems that the round trip of the request is going but when the request is being returned the werkzeug module is not able to call LambdaContext: Not a callable object. \n'LambdaContext' object is not callable: TypeError\nTraceback (most recent call last):\nFile \"\/home\/ubuntu\/venv\/local\/lib\/python2.7\/site-packages\/flask\/app.py\", line 1997, in call\nFile \"\/home\/ubuntu\/venv\/local\/lib\/python2.7\/site-packages\/flask\/app.py\", line 1989, in wsgi_app\nFile \"\/tmp\/pip-install-Xytrxp\/Werkzeug\/werkzeug\/wrappers.py\", line 1277, in call\nTypeError: 'LambdaContext' object is not callable\nI am trying to use serverless to deploy but my problem is that when i build a deployment package using serverless it's going to go beyond 250 MB which is the limit of AWS Lambda\nI have built the package using Zappa by removing some of the unnecessary files in python packages and the size of that is 248 MB. I am able to use that to deploy but using serverless deploy is throwing issues. \nSo, is any one aware of what actually serverless does? Can we include serve.py and wsgi.py files in the AWS Lambda deployment package? \nIf yes, what are more changes needed to be able to just add these python files to deployment package to make the application wrapped on serverless.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":833,"Q_Id":50711086,"Users Score":0,"Answer":"I was able to handle this by using serverless-wsgi. We just need to include wsgi.py and .wsgi_app files and need to put wsgi.handler as the Lambda Function Handler","Q_Score":1,"Tags":"python,amazon-web-services,aws-lambda,serverless","A_Id":50750689,"CreationDate":"2018-06-06T01:34:00.000","Title":"Deploying WSGi app on 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":"It seems I have a conflict when trying to install pytrends via anaconda. After submitting \"pip install pytrends\" the following error arises:\ntensorflow-tensorboard 1.5.1 has requirement bleach==1.5.0, but you'll have bleach 2.0.0 which is incompatible.\ntensorflow-tensorboard 1.5.1 has requirement html5lib==0.9999999, but you'll have html5lib 0.999999999 which is incompatible.\nI also have tensorflow but don't necessarily need it. But I'd prefer a means to operate with both.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":333,"Q_Id":50712246,"Users Score":1,"Answer":"Try upgrading your version of tensorflow. I tried it with Tensorflow 1.6.0 ,tensorboard 1.5.1 and it worked fine. I was able to import pytrends.","Q_Score":1,"Tags":"python,tensorflow,anaconda","A_Id":50713079,"CreationDate":"2018-06-06T04:26:00.000","Title":"Pytrends anaconda install conflict with TensorFlow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"back then i used to work in linux environment, but in my current work i got bound to using only windows. Everything worked fine eventually but then just recently i got to problem wherein i need to use uwsgi package which is incompatible with windows, so i my solution was to use virtualbox, install ubuntu there and then just run that single standalone module which needs uwsgi and the rest still with windows (each module communicates through HTTP, so they kind of like microservices). Now the thing is all of them depends in google cloud sdk which currently installed in my windows machine (host) so my plan is to move that installation to the shared folder between the guest and host to be able to be used by them, but wondering if it will work? as much as possible i dont like make the guest ubuntu to be bulky that much","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":50716213,"Users Score":0,"Answer":"Sharing the folder of the Cloud SDK installed on the host machine with a guest OS on Virtualbox should be working as long as the required environmental variables (e.g $PATH) are appropriately configured on the guest OS.","Q_Score":0,"Tags":"python,virtualbox,google-cloud-sdk","A_Id":51071550,"CreationDate":"2018-06-06T08:57:00.000","Title":"Is it possible to use google cloud sdk installed in windows host from ubuntu guest?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been working on creating and training a Deep Learning model for the first time. I did not have any knowledge about the subject prior to the project and therefor my knowledge is limited even now.\nI used to run the model on my own laptop but after implementing a well working OHE and SMOTE I simply couldnt run it on my own device anymore due to MemoryError (8GB of RAM). Therefor I am currently running the model on a 30GB RAM RDP which allows me to do so much more, I thought. \nMy code seems to have some horribly inefficiencies of which I wonder if they can be solved. One example is that by using pandas.concat my model's RAM usages skyrockets from 3GB to 11GB which seems very extreme, afterwards I drop a few columns making the RAm spike to 19GB but actually returning back to 11GB after the computation is completed (unlike the concat). I also forced myself to stop using the SMOTE for now just because the RAM usage would just go up way too much. \nAt the end of the code, where the training happens the model breaths its final breath while trying to fit the model. What can I do to optimize this?\nI have thought about splitting the code into multiple parts (for exmaple preprocessing and training) but to do so I would need to store massive datasets in a pickle which can only reach 4GB (correct me if I'm wrong). I have also given thought about using pre-trained models but I truely did not understand how this process goes to work and how to use one in Python. \nP.S.: I would also like my SMOTE back if possible \nThank you all in advance!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1499,"Q_Id":50719405,"Users Score":0,"Answer":"Slightly orthogonal to your actual question, if your high RAM usage is caused by having entire dataset in memory for the training, you could eliminate such memory footprint by reading and storing only one batch at a time: read a batch, train on this batch, read next batch and so on.","Q_Score":0,"Tags":"python,deep-learning,ram,rdp","A_Id":50723414,"CreationDate":"2018-06-06T11:33:00.000","Title":"Optimizing RAM usage when training a learning model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got django running with models.\nNow, I want that fill todatabase with information from different websites.\nThere comes scraping, I know. What I'm missing is knowledge if there's any tool to scrape pages with Django that gives compatibility with existing database\/models?\nPlease note that I'd like to run this scraping task every 5 mins for example, so it won't be one-run script.\nCould you please point me out which tools should I use? Should I stay with Django or use something external?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":147,"Q_Id":50721473,"Users Score":2,"Answer":"You can use Celery in your Django project, with Celery you will create tasks to scrape the websites you want and use it inside your Models.\nThe hardest part should be the scrape it self, insert the data inside your models is easy.","Q_Score":1,"Tags":"python,django,web-scraping","A_Id":50722916,"CreationDate":"2018-06-06T13:16:00.000","Title":"Django&Python, scrape page to fill up database","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can we verify the window\/web page, font size and font color using Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":141,"Q_Id":50721906,"Users Score":2,"Answer":"HTML Text objects should have a 'currentStyle' collection property. That property will consist of every aspect of the text, from font size to color listed as a 'Field'. You can use checkpoints to evaluate that data or just access the data during testing.\nOn the Page object there is a 'contentDocument' collection which has all the details of the page from general sizes, fonts, and colors, etc.\nThe Page object also has a 'Height' and 'Width' property for that specific page. If you need to get to granular level all the data is at the page level.\nYou can investigate these using the object spy and then looking through all the available properties and fields of the objects","Q_Score":0,"Tags":"python-2.7,automation,testcomplete","A_Id":50843320,"CreationDate":"2018-06-06T13:36:00.000","Title":"How can verify the font size and color in Python (web page)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say that I'm training a (Gensim) Word2Vec model with min_count=5. The documentation learns us what min_count does:\n\nIgnores all words with total frequency lower than this.\n\nWhat is the effect of min_count on the context? Lets say that I have a sentence of frequent words (min_count > 5) and infrequent words (min_count < 5), annotated with f and i:\n\nThis (f) is (f) a (f) test (i) sentence (i) which (f) is (f) shown (i) here (i)\n\nI just made up which word is frequently used and which word is not for demonstration purposes.\nIf I remove all infrequent words, we get a completely different context from which word2vec is trained. In this example, your sentence would be \"This is a which is\", which would then be a training sentence for Word2Vec. Moreover, if you have a lot of infrequent words, words that were originally very far away from each other are now placed within the same context.\nIs this the correct interpretation of Word2Vec? Are we just assuming that you shouldn't have too many infrequent words in your dataset (or set a lower min_count threshold)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6773,"Q_Id":50723303,"Users Score":8,"Answer":"Words below the min_count frequency are dropped before training occurs. So, the relevant context window is the word-distance among surviving words. \nThis de facto shrinking of contexts is usually a good thing: the infrequent words don't have enough varied examples to obtain good vectors for themselves. Further, while individually each infrequent word is rare, in total there are lots of them, so these doomed-to-poor-vector rare-words intrude on most other words' training, serving as a sort of noise that makes those word-vectors worse too.\n(Similarly, when using the sample parameter to down-sample frequent words, the frequent words are randomly dropped \u2013 which also serves to essentially \"shrink\" the distances between surviving words, and often improves overall vector quality.)","Q_Score":3,"Tags":"python,word2vec,gensim","A_Id":50730108,"CreationDate":"2018-06-06T14:46:00.000","Title":"How is Word2Vec min_count applied","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python3 on repl.it. I was trying to print a backspace but it prints  instead print(\"hello\\bworld\") should print hellworld but it prints helloworld. I tried to use sys.stdout.write(\"\\b\") but it still prints .Can someone please help?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":145,"Q_Id":50727516,"Users Score":0,"Answer":"Use repr. repl.it uses the browser to render the characters. If you compare the number of characters in the output (by using Chrome's JS console, for example), you'll see that print('abc') has the same number as print('a\\bc').","Q_Score":1,"Tags":"python,python-3.x,repl.it","A_Id":50727868,"CreationDate":"2018-06-06T18:48:00.000","Title":"How to print a backspace character with python using repl.it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to install spyder in the virtual environment on anaconda, but ended up with this debugging error.\n\nExecuting transaction: \n  \\ DEBUG menuinst_win32:init(199): Menu: name: 'Anaconda${PY_VER} ${PLATFORM}', prefix: 'C:\\Users\\Public\\Anaconda\\envs\\tensorflow', env_name: 'tensorflow', mode: 'None', used_mode: 'user'\n  DEBUG menuinst_win32:create(323): Shortcut cmd is C:\\Users\\Public\\Anaconda\\pythonw.exe, args are ['C:\\Users\\Public\\Anaconda\\cwp.py', 'C:\\Users\\Public\\Anaconda\\envs\\tensorflow', 'C:\\Users\\Public\\Anaconda\\envs\\tensorflow\\pythonw.exe', 'C:\\Users\\Public\\Anaconda\\envs\\tensorflow\\Scripts\\spyder-script.py']\n  | DEBUG menuinst_win32:create(323): Shortcut cmd is C:\\Users\\Public\\Anaconda\\python.exe, args are ['C:\\Users\\Public\\Anaconda\\cwp.py', 'C:\\Users\\Public\\Anaconda\\envs\\tensorflow', 'C:\\Users\\Public\\Anaconda\\envs\\tensorflow\\python.exe', 'C:\\Users\\Public\\Anaconda\\envs\\tensorflow\\Scripts\\spyder-script.py', '--reset']\n\nI have also tried to clear the debugging errors using \nconda config --set quiet True , but no use.\nCan anyone help me with this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":777,"Q_Id":50728057,"Users Score":1,"Answer":"You should activate your virtual environment and then type: conda install spyder.  That should install spyder for that particular virtual environment. If you used pip or pip3 you may have problems.","Q_Score":1,"Tags":"python,python-3.x,anaconda,spyder","A_Id":50787466,"CreationDate":"2018-06-06T19:21:00.000","Title":"Not able to install Spyder in the virtual environment on Anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"From my current and very basic understanding, users need to define their entire model using add_input,add_output,add_design_var,etc... in Python if they want to run analysis\/optimization in OpenMDAO. \nThere is no GUI interface, so is there an easier way to create models or to send SysML to OpenMDAO for optimization or would a user have to define their model twice, once in SysML and once in Python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":50728584,"Users Score":0,"Answer":"The OpenMDAO GUI was removed as of version 1, and there are no current plans to re-introduce it into version 2. \nThere isn't any current links between sysml tools and OpenMDAO. You could certainly write something that would read a sysml file and build the appropriate OpenMDAO model from it, but nothing like that exists currently. \nThe major hurdle with a system like this is how you keep the two systems (sysml and OpenMDAO) in sync. If you generate the model from a sysml tool, then modify it by hand later, how do those updates get fed back into the OpenMDAO model. \nI think the idea would work as long as it was uni-directional. sysml -> OpenMDAO.","Q_Score":0,"Tags":"python,openmdao","A_Id":50728889,"CreationDate":"2018-06-06T19:59:00.000","Title":"How would I utilize OpenMDAO to interface with SysML?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was adding final touches to a python code when my computer unexpectedly shut down. When I turned it back on and opened the file, it was blank. Is it possible for me to recover the contents of that file?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":203,"Q_Id":50729289,"Users Score":0,"Answer":"Unless it was backed up somewhere automatically, it's gone permanently.","Q_Score":0,"Tags":"python,recovery","A_Id":50730707,"CreationDate":"2018-06-06T20:43:00.000","Title":"Unexpected computer shutdown while python file wasn't saved","Data 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":"Specifically the source code of lock, which is implemented directly by the _thread extension module.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":386,"Q_Id":50729644,"Users Score":1,"Answer":"Answered by Tim Peters, the Cpython implementation:\ngithub.com\/python\/cpython\/blob\/master\/Modules\/_threadmodule.c","Q_Score":1,"Tags":"python,thread-synchronization","A_Id":50836546,"CreationDate":"2018-06-06T21:09:00.000","Title":"where can I find the source code for python Low-level threading API _thread extension module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a game in Python tkinter that involves a rocket ship and some asteroids. The problem is, the rocket ship is made up of multiple shapes. I don't need advice on how to simplify the rocket's shape, but if I could get pointers on using images in a canvas, that might be better.\nAnyway, I was researching methods on how to combine multiple shapes into a single shape, or moving multiple shapes at once. This involved the use of IDs and tags, and I'm unclear on which I should use and why.\nWhy do I need to move multiple shapes at once? The rocket ship is made up of multiple shapes, and it needs to move from side to side. I really don't want a bunch of self.canvas.move() methods cluttering up my code, so if anyone could help me, I would greatly appreciate it. Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1022,"Q_Id":50732085,"Users Score":7,"Answer":"Overview\nYou're speaking of canvas objects. Every canvas object has a unique integer id. No two objects can have the same id. The id is assigned by tkinter and returned to your code when you create the object. This id is necessary to later be able to refer to each individual object. \nTags on the other hand are completely arbitrary (except they can't be a sequence of digits) and assigned by you. You can assign one or more tags to an object (or no tags to an object), and multiple objects can share the same tags.\nUsage\nBoth tags and ids can be used by many of the canvas methods such as move, bbox, coords, etc. \nThe most common use of tags are to group multiple objects into a single logical object. A ship might have a body, some wings, maybe some other parts. Each of those parts may have a unique id, but you can assign the same tag to all of the parts so that you can move all parts together in unison. \nFor a concrete example, let's say you make a ship out of a rectangle for the body and a two triangles for wings. Each will have a unique id. If you want to move those three together as if they were one, you might give each of them the tag \"ship-1\". If you call `canvas.move(\"ship-1\", 10, 0), all three of those objects will be moved ten pixels to the right.\nIf you create a second ship, you might give the pieces of that ship the tag \"ship-2\". In that way you can move just \"ship-1\" or just \"ship-2\". Further, if you also give each of those objects the tag \"Ship\" in addition to their unique \"ship-\" tag, then you can move all ships at once.\nTaking it another step further, lets say you are simulating a space battle. Half the ships are the good guys and half are the bad guys. So now, in addition to giving each piece of a ship the tag \"ship-1\", and also giving each piece of a ship the tag \"Ship\", you can also give each piece of the ship the tag \"good\" or \"bad\"\nUse-case\nWith all of the above in place, you can now do the following:\n\nmove one individual piece  of one ship by using the id\nmove all pieces for the first ship with \"ship-1\"\nmove all pieces for the second ship with \"ship-2\"\nmove all of the \"good\" ships together in formation with \"good\"\nmove all of the \"bad\" ships together in formation with \"bad\"\nmove all ships using \"Ship\"\nmove everything with the special tag \"all\" which automatically refers to everything on the canvas.\n\nAnd, of course, instead of moving you can also change the color of any of those, or delete all of the objects for any of those, move an object or objects on top of or underneath other objects (z-index), etc.","Q_Score":0,"Tags":"python,python-3.x,tkinter,tkinter-canvas","A_Id":50732333,"CreationDate":"2018-06-07T02:16:00.000","Title":"Difference Between 'ID' and 'tag' with Tkinter objects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using pythonnet to access some dlls from python and the dlls are not able to access the linux directories no matter what owner or permissions are set to.  Just get an access denied message like this.\nAccess to the path '\/tmp\/work' is denied.\nSeems like it should work.  Anyone have a tip on this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":278,"Q_Id":50732366,"Users Score":1,"Answer":"In using the release build of the .Net dlls it was only giving the vague permission denied error message (checking the return .error variable).  That was not the problem at all although I spend a lot of time trying to fix it.  Per the tip from denfromufa I changed to use the debug build of the .Net dll and it throws a proper exception.  I was missing a reference.  So the lesson for me is it is better to use the debug build of .Net dlls if you run them with pythonnet.","Q_Score":1,"Tags":"python,.net,linux,python.net,pythonnet","A_Id":50827959,"CreationDate":"2018-06-07T03:06:00.000","Title":"pythonnet dll directory access denied","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Any library in Robot Framework has two categories of keywords. The keywords to carry out a regular test step (e.g. Click Button) and the keywords that verify certain thing (e.g. Table Column Should Contain). The latter keywords typically have the word \"Should\" in them.\nI assume that Robot Framework only puts PASS or FAIL status for the executed test cases in the report. How can I distinguish the FAIL test cases failed due to test step keywords versus failed due to test verification keywords?\nFor example, the calculator test case clicks 2, +, 2, = buttons and then verifies answer 4 as part of the last keyword (e.g. Should Be Equal As Numbers). If it fails while failing to click any button then I will consider it as \"Failed to carry out its actual verification\" (my result processing script will not log a bug here). However, if it fails while actually verifying the result then it is a valid bug associated with the test case (my result processing script can take action accordingly, like logging a bug).\nIf there are no techniques for generating the result file as per my requirement (PASS, FAIL and maybe FAIL_TO_VERIFY statuses), then I am seeking a technique to process the result or log xml to identify the kind of failure (FAIL vs FAIL_TO_VERIFY) for every FAIL test case.\nPS: I have already figured out the bug logging part in my result processing script. So consider it as out of scope for the above question.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3153,"Q_Id":50732910,"Users Score":0,"Answer":"Can you please check this keyword Register Keyword To Run On Failure in selenium2library  , this keyword will allow to execute any other keyword when your slenium2library keywords fail. so you can call your bug reporting keyword here","Q_Score":1,"Tags":"python,robotframework","A_Id":50733615,"CreationDate":"2018-06-07T04:21:00.000","Title":"Robot Framework: How to distinguish the test case FAIL due to regular test step keyword failure versus verification test step failure","Data Science and Machine Learning":0,"Database and SQL":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'm trying to structure an MCP for Pyomo (with Python 3) where there's only one solution which fits all the complementary conditions, making the objective function redundant. Do I need to define an objective at all, or is there any way to define a dummy objective?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":108,"Q_Id":50734688,"Users Score":0,"Answer":"It depends on the solver that you are using. Some solvers will complain without the presence of an objective. My favorite ways to add a dummy include:\n\nmodel.dummy = Objective(expr=1)\nmodel.dummy_var = Var(bounds=(0, 1)) with model.dummy = Objective(expr=model.dummy_var)","Q_Score":0,"Tags":"python,pyomo","A_Id":50753883,"CreationDate":"2018-06-07T06:52:00.000","Title":"Defining a dummy Objective in Pyomo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to modelize the service of selling seats on an airplane as an MDP( markov decision process) to use reinforcement learning for airline revenues optimization, for that I needed to define what would be: states, actions, policy, value and reward. I thought a little a bit about it, but i think there is still something missing.\nI modelize my system this way:\n\nStates = (r,c) where r is the number of passengers and c the number of seats bought so r>=c.\nActions = (p1,p2,p3) that are the 3 prices. the objective is to decide which one of them give more revenues.\nReward: revenues.\n\nCould you please tell me what do u think and help me?\nAfter the modelization, I have to implement all of that wit Reinforcement Learning. Is there a package that do the work ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":232,"Q_Id":50737705,"Users Score":0,"Answer":"I think the biggest thing missing in your formulation is the sequential part. Reinforcement learning is useful when used sequentially, where the next state has to be dependent on the current state (thus the \"Markovian\"). In this formulation, you have not specified any Markovian behavior at all. Also, the reward is a scalar which is dependent on either the current state or the combination of current state and action. In your case, the revenue is dependent on the price (the action), but it has no correlation to the state (the seat). These are the two big problems that I see with your formulation, there are others as well. I will suggest you to go through the RL theory (online courses and such) and write a few sample problems before trying to formulate your own.","Q_Score":0,"Tags":"python,optimization,reinforcement-learning,markov-decision-process","A_Id":50748029,"CreationDate":"2018-06-07T09:27:00.000","Title":"Reinforcement Learning with MDP for revenues optimization","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a .exe. Python is called from my .exe and I have included the python package along with that for python to work. I find the package is of high size. Is there any way to reduce the python package size .","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":210,"Q_Id":50737719,"Users Score":1,"Answer":"Well, I would suggest going through the folder and cherry picking what you don't use. Some that might be good to get rid of :\n\n\/Doc, which contains the Python documentation for your version\n\/Scripts, which has stuff like pip in it\n\/tcl, which contains the several megabytes of data for Python-Tcl interfaces to work\n. You only need this if you're using Tkinter.\nanything in \/Lib that you don't import. That's where the standard modules are stored\n\/include, which stores the Python-C interface*\n\/Tools\/demo, which contains examples of python\n\n*Only delete this if you aren't using any C-based 3rd party library's. If you are unsure, don't risk it.","Q_Score":0,"Tags":"python,c++,python-2.7","A_Id":50752932,"CreationDate":"2018-06-07T09:27:00.000","Title":"Is there any way to reduce the size of python 2.7.6 package (unnessary folders or not needed folders or less needed folders inside python package))","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am reading a file using\n file=pd.read_csv('file_1.csv')\nwhich is taking a long time on CPU.\nIs there any method to read this using GPU.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":810,"Q_Id":50738058,"Users Score":3,"Answer":"No. The biggest bottleneck is IO and that\u2019s handled by the CPU.","Q_Score":1,"Tags":"python-3.x,gpu,h2o,h2o4gpu","A_Id":50739411,"CreationDate":"2018-06-07T09:44:00.000","Title":"How can I read a csv file using panda dataframe from GPU?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a project shared by a friend which includes headers that have case conflicts (eg: #include \"xyz.h\" but the actual file is Xyx.h). \nHow should I solve this?  I decided to write a python or bash script to parse all the #include's and then search if they are actually in the directory. Is this a good approach? \nWhich one should I use, python or bash. I think bash would be easier because it can handle files and replace names easier. But will I have to write regular expressions in my bash script?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":50739241,"Users Score":1,"Answer":"One single bullet proof solution:\n\nchoose a name convention - all lower case is probably the most common one\nrename all include files to their lower case equivalent - do nothing if they are already lower case\nconsistently check all source files and ensure that they actually include the lower case name - this should be done by hand because you do not want to process a litteral string containing #include\n\nThat being said, if the number of files is small, and if files are not too complex, this can possibly be automated. But my opinion is that the gain of time is not worth the development of a tool and the risk of error in it.","Q_Score":0,"Tags":"python,bash,parsing","A_Id":50740386,"CreationDate":"2018-06-07T10:44:00.000","Title":"Find and replace file names to C standard","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Trying to switch from rabbitMQ to activeMQ keeping kombu library but my script just hang on. Does kombu supports activeMQ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":50739516,"Users Score":0,"Answer":"I've never heard of anyone using it with ActiveMQ but given it is seemingly designed for Rabbit I'd guess not as Rabbit is not based on an official AMQP version but the draft AMQP 0.9 versions.  ActiveMQ implements AMQP v1.0 which is the official AMQP version an so that library would need to implement that in order to be compatible.  \nThe Apache Qpid project supplies a number of clients that can be used against ActiveMQ","Q_Score":0,"Tags":"python,activemq,amqp,kombu","A_Id":50742888,"CreationDate":"2018-06-07T10:59:00.000","Title":"Is it possible to use kombu as client library for activeMQ?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been doing a lot of Image Processing recently on Python using OpenCV and I've worked all this while with 2-D Images in the generic BGR style.\nNow, I'm trying to figure out how to incorporate depth and work with depth information as well.\nI've seen the documentation on creating simple point clouds using the Left and Right images of a Stereocamera, but I was hoping to gain some intuition on Depth-based cameras themselves like Kinect.\nWhat kind of camera should I use for this purpose, and more importantly: how do I process these images in Python - as I can't find a lot of documentation on handling RGBD images in OpenCV.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":280,"Q_Id":50743476,"Users Score":0,"Answer":"If you want to work with depth based cameras you can go for Time of Flight(ToF) cameras like picoflexx and picomonstar cameras. They will give you X,Y and Z values. Where your x and y values are distances from camera centre of that point (like in 2D space) and Z will five you the direct distance of that point (not perpendicular) from camera centre. \nFor this camera and this 3d data processing you can use Point Cloud Library fro processing.","Q_Score":1,"Tags":"python,opencv","A_Id":50776543,"CreationDate":"2018-06-07T14:13:00.000","Title":"Processing Images with Depth Information","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My influxdb measurement have 24 Field Keys and 5 tag keys.\nI try to do 'select last(cpu) from mymeasurement', and found result :\n\nWhen there is no client throwing data into it, it'll take around 2 seconds to got the result\nBut when I run 95 client throwing data (per 5 seconds) into it, the query will take more than 10 seconds before it show the result. is it normal ?\n\nNote :\nMy system is a Centos7 VM in xenserver with 4 vcore CPU and 8 GB ram, the top command show 30% cpu while that clients throw datas.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":642,"Q_Id":50743503,"Users Score":1,"Answer":"Some ideas:\nCheck your vCPU configuration on other VMs running on the same host. Other VMs you might have that don't need the extra vCPUs should only be configured with one vCPU, for a latency boost. \nIf your DB server requires 4 vCPUs and your host already has very little CPU% used during queries, you might want to check the storage and memory configurations of the VM in case your server is slow due to swap partition use, especially if your swap partition is located on a Virtual Disk over the network via iSCSI or NFS. \nIt might also be a memory allocation issue within the VM and server application. If you have XenTools installed on the VM, try on a system without the XenTools installed to rule out latency issues related to the XenTools driver.","Q_Score":0,"Tags":"influxdb,influxdb-python","A_Id":50922084,"CreationDate":"2018-06-07T14:14:00.000","Title":"influxDB query speed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've installed a module with the --target argument and the console entry points are installed at the target in a \/bin directory. Therefore they are not accessible via the command line. Usually they would install to \/usr\/bin.\nI've tried adding --install-option=\"--install-scripts=\/usr\/bin\" but the behaviour doesn't change. \nThe full install command that doesn't install the entry points to \/usr\/bin:\n\/usr\/bin\/pip install my-package-1.0.0-py2-none-any.whl --target \/opt\/myproject\/ --upgrade --install-option=\"--install-scripts=\/usr\/bin\"\nTIA","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":50743951,"Users Score":0,"Answer":"When you use --target you're on your own. Add \/opt\/myproject\/bin to $PATH and \/opt\/myproject\/lib\/pythonX.Y to $PYTHONPATH.","Q_Score":1,"Tags":"python,pip,setuptools","A_Id":50745378,"CreationDate":"2018-06-07T14:35:00.000","Title":"Console entry points not working with the --target argument with pip install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am getting the following error while deploying the google app engine\nERROR: gcloud crashed (SSLHandshakeError): [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)\nIf you would like to report this issue, please run the following command:\n  gcloud feedback\nTo check gcloud for common problems, please run the following command:\n  gcloud info --run-diagnostics\nI am using python 2.7 also tried turning off firewall settings but doesnot help. Any suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":894,"Q_Id":50747034,"Users Score":1,"Answer":"This is a common network issue seen when there is a networking proxy present on your network or antivirus and similar software that might prevent the connection. \nAs you mentioned the issue was solved when deactivating an antivirus software. If you still want to run the antivirus, you can configure it properly to allow the connection to GCP.","Q_Score":1,"Tags":"google-app-engine,google-cloud-platform,ssl-certificate,google-app-engine-python","A_Id":50756281,"CreationDate":"2018-06-07T17:27:00.000","Title":"ssl handshake error while deploying google app engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a time series data which looks something like this\nLoan_id Loan_amount Loan_drawn_date\n  id_001    2000000    2015-7-15\n  id_003     100       2014-7-8\n  id_009     78650     2012-12-23\n  id_990      100      2018-11-12\nI am trying to build a Arima forecasting model on this data which has round about 550  observations. These are the steps i have followed     \n\nConverted the time series data into daily data and replaced NA values with 0. the data look something like this           \nLoan_id Loan_amount Loan_drawn_date \nid_001    2000000    2015-7-15\nid_001    0          2015-7-16\nid_001    0          2015-7-17\nid_001    0          2015-7-18\nid_001    0          2015-7-19\nid_001    0          2015-7-20\n....\nid_003     100       2014-7-8\nid_003     0       2014-7-9\nid_003     0       2014-7-10\nid_003     0        2014-7-11\nid_003     0       2014-7-12\nid_003     0       2014-7-13\n....\nid_009     78650     2012-12-23\nid_009     0     2012-12-24\nid_009     0     2012-12-25\nid_009     0     2012-12-26\nid_009     0     2012-12-27\nid_009     0     2012-12-28\n...\nid_990      100      2018-11-12\nid_990      0      2018-11-13\nid_990      0      2018-11-14\nid_990      0      2018-11-15\nid_990      0      2018-11-16\nid_990      0      2018-11-17\nid_990      0      2018-11-18\nid_990      0      2018-11-19\nCan Anyone please suggest me how do i proceed ahead with these 0 values now?\nSeeing the variance in the loan amount numbers i would take log of the of the loan amount. i am trying to build the ARIMA model for the first time and I have read about all the methods of imputation but there is nothing i can find. Can anyone please tell me how do i proceed ahead in this data","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":148,"Q_Id":50747097,"Users Score":0,"Answer":"I don't know exactly about your specific domain problem, but these things apply usually in general:\n\nIf the NA values represent 0 values for your domain specific problem, then replace them with 0 and then fit the ARIMA model (this would for example be the case if you are looking at daily sales and on some days you have 0 sales)\nIf the NA values represent unknown values for your domain specific problem then do not replace them and fit your ARIMA model. (this would be the case, if on a specific day the employee forgot to write down the amount of sales and it could be any number). \n\nI probably would not use imputation at all. There are methods to fit an ARIMA model on time series that have missing values. Usually these algorithms should probably also implemented somewhere in python. (but I don't know since I am mostly using R)","Q_Score":0,"Tags":"python,time-series,missing-data,arima","A_Id":50774913,"CreationDate":"2018-06-07T17:31:00.000","Title":"ARIMA Forecasting","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm pretty new the LightGBM, and when I try to apply lightgbm.train on my dataset, I got this error:\nLightGBMError: Length of label is not same with #data\nI'm not sure where I made a mistake. I tried\nmodel = lightgbm.train(params, train_data, valid_sets=test_data, early_stopping_rounds=150, verbose_eval=200)\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4332,"Q_Id":50747460,"Users Score":0,"Answer":"It simply means that the dimensions of your training examples and the respective list of labels do not match. In other words, if you have 10 training instances you need exactly 10 labels. (For a multi-label scenarios a better formulation would be to replace label by labelling, or refer to the size of the array.)","Q_Score":3,"Tags":"python,lightgbm","A_Id":50774153,"CreationDate":"2018-06-07T17:57:00.000","Title":"what does the error \"Length of label is not same with #data\" when I call lightgbm.train","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script which uses readlines and numpy.loadtxt to load a csv file. It works perfectly fine on my desktop running ubuntu 16.04. On my laptop running 18.04 I get (loading the same file) the following error: UnicodeDecodeError: 'utf8' codec can't decode byte 0xb5 in position 446: invalid start byte\nWhat can I do to make the script working?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":322,"Q_Id":50748564,"Users Score":1,"Answer":"Adding encoding='ISO-8859-1' to readlines and loadtxt did the trick.","Q_Score":0,"Tags":"python,numpy,ubuntu","A_Id":50753840,"CreationDate":"2018-06-07T19:07:00.000","Title":"readlines and numpy loadtxt gives UnicodeDecodeError after upgrade 18.04","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Everytime I try to run a django app in terminal using a python manage.py runserver command I get the following error:\nReferenced from: \/Users\/myname\/anaconda\/lib\/python2.7\/site-packages\/_mysql.so\n  Reason: image not found.\nDid you install mysqlclient or MySQL-python?\n\nTo fix it, I just paste\nexport DYLD_LIBRARY_PATH=\/usr\/local\/mysql\/lib\/\n\ninto my terminal. How can I rearrange my files so that I don't have to paste this in every time? I am working on a Mac.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":254,"Q_Id":50751008,"Users Score":2,"Answer":"Assuming you're just using the default terminal, you could put the command in your .bash_profile\/.bashrc by running something like\necho \"export DYLD_LIBRARY_PATH=\/usr\/local\/mysql\/lib\/\" >> ~\/.bash_profile\nSwitching .bash_profile with your equivalent.Then when you start a new terminal it should already be applied. To apply it immediately just run\nsource ~\/.bash_profile","Q_Score":0,"Tags":"python,mysql,django,macos","A_Id":50751138,"CreationDate":"2018-06-07T22:31:00.000","Title":"MySQL and Python - \"image not found\" -- permanent fix?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I would like to ask if there is another way to disable creation of __pycache__ in the server. \nMy problem is it keeps generating even if I already set environment variable to PYTHONDONTWRITEBYTECODE=1\nI want to disable __pycache__ because I only keep 5 releases in deployment. This cache is preventing the deletion of the 6th release because the cache is owned by root and can only be deleted through sudo. \nI am using capistrano for deployment.\nThank you for your response!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":11666,"Q_Id":50752302,"Users Score":19,"Answer":"I already resolved this issue. export PYTHONDONTWRITEBYTECODE=1 works. The generation of pycache folder is in the docker (I used docker as well). What I did is inside the docker, I have this export PYTHONDONTWRITEBYTECODE=1 So it solved the issue. thank you for your help.","Q_Score":12,"Tags":"python,python-3.x,capistrano","A_Id":50789208,"CreationDate":"2018-06-08T01:53:00.000","Title":"Python3 __pycache__ generating even if PYTHONDONTWRITEBYTECODE=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":"I just got acquainted with the keyboard buttons for telegram bots using the .KeyboardButton from the Telegram API documentation but I have an issue; so far I've only been able to design the buttons such that the output after clicking on the button is the same as it's caption\/placeholder which is really not helpful for what I want to do.\nI have commands set and all already so for example I want the output of a button labeled \"Rules\" to be \/rules in order to initiate the command action instead of the bot output being \"Rules\". I'm working with Python although I'm open to anyone working on the same stuff in other languages.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":4783,"Q_Id":50755566,"Users Score":-1,"Answer":"you may add a space character to the KeyboardButton text and then parse it from the message, or, if you don't like spaces to appear at the start, just add them to the end. heh, that's not enough right, so soft hyphen might be used, it's hex is \\xC2\\xAD (it doesn't show up, at least at my telegrams).\nso, that works for me,\nhope mr.durov won't change that..\nI've got pinged at SF because of downvote.. ye, okay, The question is about keyboard_markup, which creates buttons below text input area, they produce instant input, which prints button caption in the chat, the bot may parse them as commands (which normally start with \"\/\" character), so the question is about how to distinguish them properly.. This is not recommended route (as it seems).\nWith inline_markup, you create buttons that produce callbacks with custom data, so there will be no user input in the chat.","Q_Score":4,"Tags":"python,telegram,telegram-bot,python-telegram-bot,php-telegram-bot","A_Id":66487402,"CreationDate":"2018-06-08T07:31:00.000","Title":"How to make telegram keyboard button issue commands?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The arrays are of following dimensions:\ndists: (500,5000)\ntrain: (5000,)\ntest:(500,)\nWhy does the first two statements throw an error whereas the third one works fine?\n\ndists += train + test\n\nError: ValueError: operands could not be broadcast together with shapes (5000,) (500,) \n\ndists += train.reshape(-1,1) + test.reshape(-1,1)\n\nError: ValueError: operands could not be broadcast together with shapes (5000,1) (500,1)\n\ndists += train + test.reshape(-1,1)\nThis works fine!\n\nWhy does this happen?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":13229,"Q_Id":50758165,"Users Score":6,"Answer":"It's to do with NumPy's broadcasting rules. Quoting the NumPy manual:\n\nWhen operating on two arrays, NumPy compares their shapes element-wise. It starts with the trailing dimensions, and works its way forward. Two  dimensions are compatible when\n\nthey are equal, or\none of them is 1\n\n\nThe first statement throws an error because NumPy looks at the only dimension, and (5000,) and (500,) are inequal and cannot be broadcast together.\nIn the second statement, train.reshape(-1,1) has the shape (5000,1) and test.reshape(-1,1) has the shape (500,1). The trailing dimension (length one) is equal, so that's ok, but then NumPy checks the other dimension and 5000 != 500, so the broadcasting fails here.\nIn the third case, your operands are (5000,) and (500,1). In this case NumPy does allow broadcasting. The 1D-array is extended along the trailing length-1 dimension of the 2D-array.\nFWIW, the shape and broadcasting rules can be a bit tricky sometimes, and I've often been confused with similar matters.","Q_Score":6,"Tags":"python,python-3.x,numpy,array-broadcasting","A_Id":50758844,"CreationDate":"2018-06-08T10:03:00.000","Title":"Why the following operands could not be broadcasted together?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"1.I already have nvcuda.dll in system32.\n2.I have path C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.2\\bin.\n3.The program already upgraded tensorflow and GPU tensorflow.\nI check import still have the error. \n\nImportError: Could not find 'nvcuda.dll'. TensorFlow requires that\n  this DLL be installed in a directory that is named in your %PATH%\n  environment variable. Typically it is installed in\n  'C:\\Windows\\System32'. If it is not present, ensure that you have a\n  CUDA-capable GPU with the correct driver installed.\n\nWhy?\nHow to fix this problem shown by the message error ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2669,"Q_Id":50758472,"Users Score":0,"Answer":"As the comment mentioned, you need to ensure the time you import the tensorflow, the path environment points to c:\\windows\\system32 and as you said you have nvcuda.dll, ensure the file is there too. There is no need to set the libraries.","Q_Score":0,"Tags":"python-3.x,tensorflow,spyder,dllimport","A_Id":57155250,"CreationDate":"2018-06-08T10:20:00.000","Title":"How to fix import error 'nvcuda.dll' in spyder for python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a way to randomize lists in python (which I already know how to do) but to then make sure that two things aren't next to each other. For example, if I were to be seating people and numbering the listing going down by 0, 1, 2, 3, 4, 5 based on tables but 2 people couldn't sit next to each other how would I make the list organized in a way to prohibit the 2 people from sitting next to each other.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":50759439,"Users Score":1,"Answer":"As you say that you know how to shuffle a list, the only requirement is that two elements are not next to each other.\nA simple way is to:\n\nshuffle the full list\nif the two elements are close, choose a random possible position for the second one\nexchange the two elements\n\nMaximum cost: one shuffle, one random choice, one exchange","Q_Score":2,"Tags":"python,python-3.x","A_Id":50759628,"CreationDate":"2018-06-08T11:15:00.000","Title":"Randomizing lists with variables in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am facing issue with my inception model during the performance testing with Apache JMeter.\n\nError: OOM when allocating tensor with shape[800,1280,3] and type\n  float on \/job:localhost\/replica:0\/task:0\/device:GPU:0 by allocator\n  GPU_0_bfc      [[Node: Cast = CastDstT=DT_FLOAT, SrcT=DT_UINT8,\n  _device=\"\/job:localhost\/replica:0\/task:0\/device:GPU:0\"]]\n  Hint: If you want to see a list of allocated tensors when OOM happens,\n  add report_tensor_allocations_upon_oom to RunOptions for current\n  allocation info.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":34640,"Q_Id":50760543,"Users Score":19,"Answer":"OOM stands for Out Of Memory.  That means that your GPU has run out of space, presumably because you've allocated other tensors which are too large.  You can fix this by making your model smaller or reducing your batch size.  By the looks of it, you're feeding in a large image (800x1280) you may want to consider downsampling.","Q_Score":16,"Tags":"python-3.x,tensorflow,gpu,gunicorn","A_Id":50764934,"CreationDate":"2018-06-08T12:20:00.000","Title":"Error: OOM when allocating tensor with shape","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have a string that I am trying to search through using re.search. The string is combined of an Id and then a string after it. So it looks like this: <@randomId> string after\nI am using the regex pattern \"^@(|[WU].+?)>(.*)\" in my re.search method to try and get two different groups. The first group is the id, minus the < >. So it would just be \"@randomId\". And the second group would be the \"string after\" text that comes after the Id. So if the text I am passing into re.search is \"<@QWE1234> do this\" I want to match and return \"@QWE1234\" and \"do this\".\nWith the regex I am using I am getting a return type of None, and when I add in < to the regex pattern, so it looks like this: \"^<@(|[WU].+?)>(.*)\" I get the whole string.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":545,"Q_Id":50761951,"Users Score":0,"Answer":"So the regex \"^<@(|[WU].+?)>(.*)\" was the correct one, but I was not returning the correct search group from the re.search method. I had to specify return (matches.group(1), matches.group(2).strip())","Q_Score":1,"Tags":"python,regex,search","A_Id":50762474,"CreationDate":"2018-06-08T13:40:00.000","Title":"regex end search on specific character","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a rather silly question...yet it bugs the heck out of me. In the threading module we have a Thread.join() method.\nI understand that it blocks the calling thread, but why is .join() called 'join'?  Why is it not called main_thread_wait or block_parent_thread or something like that?\nEvery time I see .join(), I feel the child thread is joining something to get caclulations done. Is there some reason why this particular keyword was chosen for a method name?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":111,"Q_Id":50765460,"Users Score":1,"Answer":"The child-thread joins the parent. Thread.start makes the parent give birth to a thread and let it free. Thread.join makes the parent block (wait) until the child is done doing its job.\nYou can imagine it like this:\n\nthe parent thread is a mighty god that can live for a long time\nwith Thread.start it gives birth to a mortal\nright after its birth, the mortal runs away and starts living its own life (executing its run method)\nthe god may continue minding his own business\nhe also may want to take a look at his offspring, to see whether, literally, it is_alive\nhe also may start observing the whole life of the offspring, waiting for him to come back, right until the death of the latter (this is the join method). While doing that, the god cannot do anything else, because he enjoys admiring his creature so much (the call to join blocks the parent thread), but after the mortal dies, the god can continue his life","Q_Score":1,"Tags":"python,multithreading,python-multithreading","A_Id":50765825,"CreationDate":"2018-06-08T17:07:00.000","Title":"Why is .join() method called .join() in the threading module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a custom conda package for tensorflow. When I name the package \"tensorflow\" it takes it more than 3 minutes to get past the \"solving environment\" part but if I change the package name even a little bit, to \"tensorflowp3\" it loads in around 10 seconds. \nI am using the commands - \nconda install -c <my_channel> tensorflow\nconda install -c <my_package> tensorflowp3\nI am not sure why setting a slightly different package name causes such a significant time change. I am specifying which channel the package should be loaded from in the command as well. I have tried doing the same with locally stored packages using the --use-local tag as well but it still behaves the same way as with the channel name. Any help would be very appreciated.","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":21062,"Q_Id":50765892,"Users Score":6,"Answer":"I solved by doing this\n\nopen Anaconda Navigator application \nselect Environment from menu\nchoose the environment you wanna use (base enviroment if you don't use multiple enviroments)\nUpdate index\nClick on channels and remove all eventual channel, but default\n\nNow, for me it takes a reasonable abount of time to install a new packet.","Q_Score":14,"Tags":"python,tensorflow,anaconda,conda","A_Id":53469361,"CreationDate":"2018-06-08T17:40:00.000","Title":"\"Solving Environment\" during `conda install -c  tensorflow` takes 3+ min but changing the name a bit reduces the time significantly","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to check the SD card size in bash or python. Right now I know df can check it when the SD card is mounted or fdisk -l if root is available.\nBut I want to know how to check the SD card size without requiring mounting the card to the file system or requiring the root permission? For example, if the SD card is not mounted and I issue df -h \/dev\/sdc, this will return a wrong size. In python, os.statvfs this function returns the same content as well. I search on stack overflow but did not find a solution yet.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":413,"Q_Id":50769974,"Users Score":0,"Answer":"Well, I found the lsblk -l can do the job. It tells the total size of the partitions.","Q_Score":0,"Tags":"python,linux,bash","A_Id":50802107,"CreationDate":"2018-06-09T00:49:00.000","Title":"how to check the SD card size before mounted and do not require root","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"What's the best approach in python to do something like what happens when you run jupyter notebook, in other words, run a server (for example, with http.server) on some available port if the default one isn't available? Is it common to just catch the error if starting the server fails and try a different port until it works?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":69,"Q_Id":50770485,"Users Score":1,"Answer":"You can use port 0 - this will bind your server to some port that is currently known to be available by kernel. However, that makes a problem of service discovery - how your clients will know which port number server is listening on? If that's only you, shouldn't be big deal.","Q_Score":1,"Tags":"python,server","A_Id":50770554,"CreationDate":"2018-06-09T02:49:00.000","Title":"find available port to run server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any solid refernce as to how multiple parameters can fit within response.meta.get(\"something\",\"someotherthing\")in scrapy? If it is posible then how someotherthing relates to something?\nI searched a lot but could not find anywhere the exact answer I'm after.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":50775373,"Users Score":1,"Answer":"response.meta in scrapy it's just a normal python dict, and as a python dict it has the method get which is None safe - when the second parameter is a default value that take place in case the first parameter is not in the dict.\nfor example:\nwhile response.meta['unknown_key'] will raise KeyError exception,\nresponse.meta.get('unknown_key') will return None, and \nresponse.meta.get('unknown_key', 'abc') will return abc","Q_Score":1,"Tags":"python,python-3.x,web-scraping,scrapy,scrapy-spider","A_Id":50777116,"CreationDate":"2018-06-09T14:36:00.000","Title":"Multiple parameters within response.meta.get()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was thinking of how you execute code only once in Python. What I mean is setup code like when you set-up software; it only happens once and remembers you have already set up the software when you start the program again.\nSo in a sense I only want Python to execute a function once and not execute the function again even if the program is restarted.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2688,"Q_Id":50775733,"Users Score":0,"Answer":"If you need a kind of Setup-Script to install a program or to setup your operating system's environment, then I would go even further. Imagine that your setup became inconsistent in the mean-time and the program does not work properly anymore. Then it would be good to provide the user a script to repair that.\nIf you execute the script the second time, then you can:\n\neither check, if the setup was correct and print an error message to the user, if the setup became inconsistent in the mean-time\nor check the setup and repair it automatically, if inconsistent\n\nJust reading a text file or something similar (f.e. storing a key in the registry of windows) may bring you into the situation that the setup became inconsistent, but your setup-script will say that everything is fine, because the text file (or the registry key) has been found.\nFurthermore, if doing so, this facilitates also to \"uninstall\" your program. Since you know exactly what has been changed for installation, you can revert it by an uninstall script.","Q_Score":2,"Tags":"python,python-3.x,function","A_Id":51121332,"CreationDate":"2018-06-09T15:16:00.000","Title":"How do I make Python code to execute only once?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is a website that claims to predict the approximate salary of an individual on the basis of the following criteria presented in the form of individual drop-down\n\nAge : 5 options\nEducation : 3 Options\nSex : 3 Options\nWork Experience : 4 Options\nNationality: 12 Options\n\nOn clicking the Submit button, the website gives a bunch of text as output on a new page with an estimate of the salary in numerals. \nSo, there are technically 5*3*3*4*12 = 2160 data points. I want to get that and arrange it in an excel sheet. Then I would run a regression algorithm to guess the function this website has used. This is what I am looking forward to achieve through this exercise. This is entirely for learning purposes since I'm keen on learning these tools.\nBut I don't know how to go about it? Any relevant tutorial, documentation, guide would help! I am programming in python and I'd love to use it to achieve this task!\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":50776071,"Users Score":1,"Answer":"If you are uncomfortable asking them for database as roganjosh suggested :) use Selenium. Write in Python a script that controls Web Driver and repeatedly sends requests to all possible combinations. The script is pretty simple, just a nested loop for each type of parameter\/drop down.\nIf you are sure that value of each type do not depend on each other, check what request is sent to the server. If it is simple URL encoded, like age=...&sex=...&..., then Selenium is not needed. Just generate such URLa for all possible combinations and call the server.","Q_Score":1,"Tags":"python,selenium,selenium-webdriver,web-scraping,regression","A_Id":50776223,"CreationDate":"2018-06-09T15:59:00.000","Title":"How to write a python program that 'scrapes' the results from a website for all possible combinations chosen from the given drop down menus?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem with rasa core, let's suppose that I have a rasa-nlu able to detect time  \neg \"let's start tomorrow\" would get the entity time: 2018-06-10:T18:39:155Z\nOk, now I want next branches, or decisions to be conditioned by:  \n\ntime is in the past  \ntime before one month from now \ntime is beyond 1\nmonth\n\nI do not know how to do that. I do not know how to convert it to a slot able to influence the dialog. My only idea would be to have an action that converts the date to a categorical slot right after detecting time, but I see two problems with that approach:  \n\none it would already be too late, meaning that if I do it with a\nposterior action it means the rasa-core has already decided what\ndecision to take without using the date\nand secondly, I do know how to save it, because if I have a\nstories.md that compares a detecting date like in the example with\nthe current time, maybe in the time of the example it was beyond one\nmonth but now it is in the past, so the reset of that story would be\nwrong.\n\nI am pretty lost and I do not know how to deal with this, thanks a lot!!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":568,"Q_Id":50776518,"Users Score":0,"Answer":"I think you could have a validation in the custom form.\nWhere it perform validation on the time and perform next action base on the decision on the time.\nYour story will have to train to handle different action paths.","Q_Score":0,"Tags":"python,date,rasa-nlu,rasa-core","A_Id":54032632,"CreationDate":"2018-06-09T16:51:00.000","Title":"Rasa-core, dealing with dates","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a bit out there but I have a module that I can import, but i dont know where it is, and module.__file__ doesnt work on it.\nIm trying to set up VSCode for 3ds Max python development and this one module (pymxs) is somehow hidden somewhere where intellisense or pylint cant see it, so I get errors every time i use it, and autocomplete doesnt work. The code runs just fine though, and i can use inspect.getmembers() on it just fine.\nNow what I would be interested in doing is just outputting the whole module in to a text file, so that hopefully intellisense\/pylint will be able to read it.\nIs that possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":50776805,"Users Score":0,"Answer":"The file pymxs.py unfortunately doesn't exist, the module only exists at runtime, i.e. when running your script in 3ds max. So at this point there's no existing solution to get autocomplete for pymxs in an external editor.\nIn the editor inside 3ds max however they have autocomplete these days, so maybe (just maybe) it's possible to create a plugin that communicates with max and retrieves this information during runtime, but no idea where you would even start with that, or if it's even possible.\nAnother solution could be to create wrapper functions for your most commonly used pymxs functions, and in that way get autocomplete from your wrapper library. Note however that with this approach everything in pymxs might not be possible to add here as it is using runtime information. Let's for example say you run myobject = rt.selection[0] Depending on if myobject becomes a teapot or a box or whatever at runtime, different functions will be available, such as radius and height. If you know what you will get maybe you can cast the output to your wrapper class or something like that.","Q_Score":0,"Tags":"python,visual-studio-code,3dsmax","A_Id":68572493,"CreationDate":"2018-06-09T17:23:00.000","Title":"Extracting an imported python module 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 am trying to  import the thing in python that will enable me to copy and past things. It seems to have a problem. I later searched my entire C drive for pyperclip and it seems to be not have it at all. How can I go about fixing this? Or am I not looking in the right area? Here is the error:\n\nimport pyperclip\nTraceback (most recent call last):\nFile \"\", line 1, in \nimport pyperclip\nModuleNotFoundError: No module named 'pyperclip'\n\nBTW I'm on windows 10","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":461,"Q_Id":50777164,"Users Score":0,"Answer":"You seems a new learner for Python. You can try to install that package via pip command. For other problem like how to use pip or which user to run pip, just go to search and solve it by yourself.","Q_Score":0,"Tags":"python,python-3.x,compiler-errors,python-import,pyperclip","A_Id":50777216,"CreationDate":"2018-06-09T18:07:00.000","Title":"Python IDLE seems to be unable to import Pyperclip in python 36?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to  import the thing in python that will enable me to copy and past things. It seems to have a problem. I later searched my entire C drive for pyperclip and it seems to be not have it at all. How can I go about fixing this? Or am I not looking in the right area? Here is the error:\n\nimport pyperclip\nTraceback (most recent call last):\nFile \"\", line 1, in \nimport pyperclip\nModuleNotFoundError: No module named 'pyperclip'\n\nBTW I'm on windows 10","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":461,"Q_Id":50777164,"Users Score":0,"Answer":"So yes you're right. You need to open up cmd prompt. use the cd to change the directory to the one inside Python36\\Scripts. Then run the  command \n    pip install pyperclip","Q_Score":0,"Tags":"python,python-3.x,compiler-errors,python-import,pyperclip","A_Id":50778183,"CreationDate":"2018-06-09T18:07:00.000","Title":"Python IDLE seems to be unable to import Pyperclip in python 36?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have just tried different API for speech recognition (google one, MS one and Houndify) but I am not satisfied beacause it takes too long to give the output (5-10\"). So, since it has to understand only few of words (switch off, switch on...) I'd like to know whether there is a way to train the pc with those words in Python.\nWhich tools do I need? Is it feasible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":222,"Q_Id":50777532,"Users Score":0,"Answer":"You can use pocketsphinx and specify a grammar or keyword list.","Q_Score":0,"Tags":"python,speech-recognition,speech-to-text","A_Id":51913368,"CreationDate":"2018-06-09T18:55:00.000","Title":"Train speech recognition for specific words in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've built PyQt5 5.10.1 against Qt 5.5 with the --qml-debug flag.\nWhen I import QtQml I get the message \"QML debugging is enabled. Only use this in a safe environment.\"\nbut whenever I try to run my application, passing arguments to the QApplication constructor, there's no indication that running my app with the -qmljsdebugger=port:1234,block option does anything. I'm expecting a message like \"QML Debugger: Waiting for connection on port 1234\", or \"QML Debugger: Ignoring \"qmljsdebugger=port:1234\". Debugging has not been enabled.\", but neither of these messages are displayed.\nI've tried printing QApplication.arguments(), and the qmljsdebugger argument is not there, but the name of the program is.\nI've tried passing ['program.py', '-qmljsdebugger=port:1234,block'] directly to the QApplication() constructor, but the second argument is not visible from the call to QApplication.arguments(). Funny enough if i remove the leading '-' from the argument, it shows up in that list but doesn't do anything.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":537,"Q_Id":50778388,"Users Score":1,"Answer":"debugging was not being turned on because i was using QQmlEngine instead of QQmlApplicationEngine.","Q_Score":1,"Tags":"python,debugging,qml,pyqt5","A_Id":50801153,"CreationDate":"2018-06-09T20:45:00.000","Title":"PyQt5 QML Debugging enabled, qmljsdebugger option doesn't do anything","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used tf.layers.dense to build a fully connected autoencoder. and I want to save it and restore only the encoder to get the embedding output.\nHow to use tf.train.saver to restore only the encoder? Because I want to set different batch size of the restored model, to input only one data into it. \nI saw many tutorials but there is no tutorials about this.\nIs there any standard solution about this\nThank you very much","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":341,"Q_Id":50778593,"Users Score":0,"Answer":"If you don't care about memory space the easiest way is by saving the whole graph (encoder and decoder) and when using it for prediction, you can pass the last layer of the encoder as the fetch argument. Tensorflow will only calculate to this point and you don't have any computational difference compared to only saving the encoder. \nOtherwise you can create two graphs (one for the encoder, one for the decoder) an train them at the same time and train them together. But this is I bit more complex.","Q_Score":0,"Tags":"python,tensorflow","A_Id":50781250,"CreationDate":"2018-06-09T21:13:00.000","Title":"tensorflow save and restore autoencoder","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a class that supports easy-to-use API to add different settings to run a given program (class.add(args)) and to benchmark all settings with multiprocessing (class.benchmark(num_processes=5)). \nFrom the documentation of multiprocessing.Process, it seems all cases using if __name__ == '__main__'.  Is it safe to skip using it ?\nFor example, the class method benchmark(num_processes=5) starts and joins processes, and another python file file.py creates a class and simply call class.benchmark(num_processes=5). Will it work as usual ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2667,"Q_Id":50781216,"Users Score":1,"Answer":"if __name__ == '__main__': is used to indicate which code to run when the module is loaded. Basically, it is loaded either when you run it as a script or when you import it as a library. In the first case, one usually writes it so that all of the written code executes so it is not necessary to include it. But when you are writing a library, there might by some code which you don't wont to run when other people import it, such as a short example or tests. So in the later case, you definitely want to include it.\nTo answer you question from the comments above, I don't think it makes sense to include it in a class method, as it is top-level construct and so it loads always.","Q_Score":1,"Tags":"python,python-multiprocessing","A_Id":50781322,"CreationDate":"2018-06-10T06:47:00.000","Title":"In Python multiprocessing.Process , do we have to use `__name__ == __main__`?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a recommender system which does Multi Criteria based ranking of car alternatives. I just need to do ranking of the alternatives in  a meaningful way. I have ways of asking user questions via a form.\nEach car will be judged on the following criteria: price, size, electric\/non electric, distance etc. As you can see its a mix of various data types, including ordinal, cardinal(count) and quantitative dat.\nMy question is as follows:\n\nWhich technique should I use for incorporating all the models into a single score Which I can rank. I looked at normalized Weighted sum model, but I have a hard time assigning weights to ordinal(ranked) data. I tried using the SMARTER approach for assigning numerical weights to ordinal data but Im not sure if it is appropriate. Please help!\nAfter someone can help me figure out answer to finding the best ranking method, what if the best ranked alternative isnt good enough on an absolute scale? how do i check that so that enlarge the alternative set further?\n\n3.Since the criterion mention above( price, etc) are all on different units, is there a good method to normalized mixed data types belonging to different scales? does it even make sense to do so, given that the data belongs to many different types?\nany help on these problems will be greatly appreciated! Thank you!","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":972,"Q_Id":50784441,"Users Score":-2,"Answer":"I am happy to see that you are willing to use multiple criteria decision making tool. You can use Analytic Hierarchy Process (AHP), Analytic Network Process (ANP), TOPSIS, VIKOR etc. Please refer relevant papers. You can also refer my papers. \nKrishnendu Mukherjee","Q_Score":1,"Tags":"python,statistics,ranking,recommendation-engine,economics","A_Id":50991998,"CreationDate":"2018-06-10T13:57:00.000","Title":"Multi crtieria alterative ranking based on mixed data types","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed docker, and while trying to pull scrapinghub\/splash -  It says \n\"image operating system \"linux\" cannot be used on this platform\". i'm using win 10.\nOther commands and pull requests are working fine.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":4619,"Q_Id":50786984,"Users Score":1,"Answer":"Open Docker Desktop option-->\nSelect switch to linux container option\nThats all","Q_Score":2,"Tags":"python,docker,splash-screen","A_Id":62139222,"CreationDate":"2018-06-10T18:47:00.000","Title":"Docker - \"image operating system \"linux\" cannot be used on this platform\" while trying to pull splash. from scrapinghub\/splash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have installed docker, and while trying to pull scrapinghub\/splash -  It says \n\"image operating system \"linux\" cannot be used on this platform\". i'm using win 10.\nOther commands and pull requests are working fine.","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":4619,"Q_Id":50786984,"Users Score":6,"Answer":"Set in Docker Desktop -> Docker Engine tab -> mode \"experimental\": true. It helps me","Q_Score":2,"Tags":"python,docker,splash-screen","A_Id":64938596,"CreationDate":"2018-06-10T18:47:00.000","Title":"Docker - \"image operating system \"linux\" cannot be used on this platform\" while trying to pull splash. from scrapinghub\/splash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am writing a machine learning toolkit to run algorithm with different settings in parallel (each process run the algorithm for one setting). I am thinking about either to use mpi4py or python's build-in multiprocessing ? \nThere are a few pros and cons I am considering about. \n\nEasy-to-use:\n\nmpi4py: It seems more concepts to learn and a bit more tricks to make it work well\nmultiprocessing: quite easy and clean API\n\nSpeed:\n\nmpi4py: people say it is more low level, so I am expect it can be faster than python multiprocessing ?\nmultiprocessing: compared with mpi4py, much slower ?\n\nClean and short code:\n\nmpi4py: seems more code to write\nmultiprocessing: preferred, easy to use API\n\n\nThe working context is I am aiming at running the code basically in one computer or a GPU server. Not really targeting at running in different machines in the network (which only MPI can do it).\nAnd since the main goal is doing machine learning, so the parallelization is not really required to be very optimal, the key goal I want to have is to balance easy, clean and quick to maintain code base but at the same time like to exploit the benefits of parallelization. \nWith the background described above, is it recommended that using multiprocessing should just be enough ? Or is there a very strong reason to use mpi4py ?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3083,"Q_Id":50787392,"Users Score":2,"Answer":"By using mpi4py you can divide the task into multiple threads, but with a single computer with limited performance or number of cores the usability will be limited. However you might find it handy during training.\nmpi4py is constructed on top of the MPI-1\/2 specifications and provides an object oriented interface which closely follows MPI-2 C++ bindings.\nMPI for Python provides MPI bindings for the Python language, allowing programmers to exploit multiple processor computing systems.\nMPI for Python supports convenient, pickle-based communication of generic Python object as well as fast, near C-speed, direct array data communication of buffer-provider objects","Q_Score":8,"Tags":"mpi,python-multiprocessing","A_Id":58026950,"CreationDate":"2018-06-10T19:38:00.000","Title":"mpi4py or multiprocessing in Python ?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a huge file (>400MB) of NDJson formatted data and like to flatten it into a table format for further analysis. \nI started iterate through the various objects manually but some are rather deep and might even change over time, so I was hoping for a more general approach.\nI was certain pandas lib would offer something but could not find anything that would help my case. Also, the several other libs I found seem to not \u2018fully\u2019 provide what I was hoping for (flatten_json). It all seems very early on. \nIs it possible that there is not good (fast and easy) solve for this at this time?\nAny help is appreciated","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":521,"Q_Id":50787438,"Users Score":2,"Answer":"pandas read_json has a bool param lines, set this to True to read ndjsons\ndata_frame = pd.read_json('ndjson_file.json', lines=True)","Q_Score":1,"Tags":"python,ndjson","A_Id":63611068,"CreationDate":"2018-06-10T19:43:00.000","Title":"How to best flatten NDJson data in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently started using the Spyder IDE (Python 3.6) and I'm having some difficulties getting used to the keyboard shortcuts, which is complicated due to me using an azerty keyboard. The ctrl + 1 keyboard shortcut to comment out lines becomes ctrl + shift + 1 due to this (azerty keyboards only read numbers when holding the shift key). Therefore I was wondering if there was any way to change the keyboard shortcuts in Spyder.\nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6874,"Q_Id":50787884,"Users Score":5,"Answer":"(Spyder maintainer here) To change our shortcuts you need to go to\nTools > Preferences > Keyboard shortcuts\nand introduce the one you want to use.","Q_Score":3,"Tags":"python,comments,spyder,shortcut,personalization","A_Id":50788727,"CreationDate":"2018-06-10T20:44:00.000","Title":"Change keyboard shortcut to comment out lines in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python 3.6 script which is multi-threaded and runs on a windows 10 machine with 12 cores.\nI want to run multiple instances of the script but I am worried about Pythons GIL issue in terms of the performance of each instance of the script.\nWould doing any of the below work around this as I am under the impression that when I run an instance of the script, the Python process it runs within is running on just one CPU core and each thread called from within the script 'time slices' on that one core...\nTherefore would:\nA: Starting each instance of the script in its own CMD window allow the OS to automatically deal with starting each scripts parent Python processes on its own core and prevent any locking taking place...\nor\nB: Starting each CMD session via a shortcut that sets its affinity to a specific core and then run the Python script so that the python process and its threads run on the specific core the CMD process has been set to use...\nor \nC: My understanding of how threading and the Python GIL works is not correct and I need understand...\nAny help will be much appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":50788535,"Users Score":3,"Answer":"I want to run multiple instances of the script\n\nThen go ahead and do it!\n\nI am worried about Pythons GIL issue in terms of the performance of each instance of the script.\n\nThe \"GIL issue\" is only an issue within any single multi-threaded Python process:  No more than one thread belonging to the same Python process will ever execute Python code at the same instant.  But, each Python process has its own GIL, and nothing prevents a thread in one Python process from running at the same time as a thread in some other Python process.\n\nwould (A) Starting each instance of the script in its own CMD window [...run each] Python processes on its own core.\n\nNo, because it is not normal for any process on an SMP platform (i.e., most multi-processor systems) to have \"its own core.\" Cores are a resource that the operating system uses to run threads\/processes, and applications normally have no reason to know or care which core is running which thread\/process at any given moment in time.\n\n(B) Starting each CMD session via a shortcut that sets its affinity to a specific core.\n\nSome operating systems let you do that, but usually there is no benefit unless your application has very special needs.  Normally, you should just trust the operating system scheduler to schedule processes and threads as efficiently as possible.","Q_Score":0,"Tags":"multithreading,python-3.x,multiprocessing","A_Id":50788884,"CreationDate":"2018-06-10T22:17:00.000","Title":"Python 3.6: Will running the same multi-threaded python script in separate CMD sessions get around Pythons GIL issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to wrap the text in the cells of the wxpython dataviewctrl?  I have some long strings which are making the grid cells very large.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":86,"Q_Id":50789881,"Users Score":0,"Answer":"OK I was able to get the cells to wrap by using textwrap in a function called from GetValueByRow().  It seems to work; but, does gives a somewhat strange string of text when editing the cell.","Q_Score":0,"Tags":"dataview,wxpython","A_Id":50867302,"CreationDate":"2018-06-11T02:43:00.000","Title":"wxpython DataViewIndexListModel Text Wrap","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I plan to install Python and Selenium on MacOS 10.12.1. \nWhat would be the better choice - Python 2.7 or 3.6.5? On windows I use 2.7, because I read that it works faster. But are there any proven obstacles while working with Python 3 and Selenium on Mac?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":50792163,"Users Score":0,"Answer":"I have been using Python 3 for quite a long time now. There is not really a performance issue that is quite noticeable. I would suggest Python 3 or which ever is the newer one because as they keep developing they will be adding new things that you might need and remove some older vulnerabilities. I would suggest you upgrade to Python 3. There might be some getting used to the new syntax but it can be quickly come over as you keep developing.","Q_Score":0,"Tags":"python,macos","A_Id":50792233,"CreationDate":"2018-06-11T07:10:00.000","Title":"MacOS Sierra 10.12.1 - selenium - which version of Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the time complexity of bin(n) in Python, where n is a decimal number (integer)?\nFor example:\nif n = 10, then bin(n) = 0b1010, so here what is happening behind the scenes? How much time does it take to convert from decimal to binary? What is Big O notation for this ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3619,"Q_Id":50793388,"Users Score":1,"Answer":"It is log(n). Think about the simple division, we divide the number by 2 until the remainder becomes 0 or 1 just like tree traversal.","Q_Score":9,"Tags":"python,python-3.x,binary,time-complexity,big-o","A_Id":64215196,"CreationDate":"2018-06-11T08:28:00.000","Title":"Time complexity of bin() in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When a python script with non ASCII character is compiled using py_compile.compile it does not complaint about encoding. But when imported gives in python 2.7\nSyntaxError: Non-ASCII character '\\xe2' in file\nWhy is this happening? whats the difference between importing and compiling using py_compile?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":172,"Q_Id":50795296,"Users Score":1,"Answer":"It seems that Python provides two variants of its lexer, one used internally when Python itself parses files, and one that is exposed to Python through e.g. __builtins__.compile or tokenizer.generate_tokens. Only the former one checks for non-ASCII characters, it seems. It's controlled by an #ifdef PGEN in Parser\/tokenizer.c.\nI have a qualified guess on why they did it this way: In Python 3, non-ASCII characters are permitted in .py files, and are interpreted as utf-8 IIRC. By silently permitting UTF-8 in the lexer, 2.7's tokenizer.generate_tokens() function can accept all valid Py3 code.","Q_Score":3,"Tags":"python-2.7,encoding,compilation,python-import","A_Id":55231546,"CreationDate":"2018-06-11T10:09:00.000","Title":"encoding in py_compile 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":0,"Web Development":0},{"Question":"After installing Tensorflow with cpu support, I am getting some problems in the verification of Tensorflow.\nI don't have any GPU in my laptop and used pip3  for installation","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":50796923,"Users Score":0,"Answer":"Pls, explain a little more where you're getting that error also it's quite possible that code you're using for verification is using codes which involve GPU. Hit me back on this one.","Q_Score":2,"Tags":"python-3.x","A_Id":50798156,"CreationDate":"2018-06-11T11:42:00.000","Title":"No module named tensorflow found in Windows 10 64bit version","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have django oscar application which use PayU as a payment provider. I'm writing tests, to test my refund mechanism. So I am using sandbox service for do such things. I have created test, which place request to PayU \"create order\". Then I got a redirect url, where I can (in browser) do fake payment using my bank account. But in test, I would like to do it programatically. I read whole documentation, but I didn't find such option. On SoF there is no similar questions. PayU support didn't aswer my question(they have 24h).\nI'm wondering if there is possibility to post proper form to proper url on payu - but after quick html review I think it may be tricky.\nDo you have any ideas how to solve this problem?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":248,"Q_Id":50797314,"Users Score":0,"Answer":"After reading documentation I have found sollution.\nFirst of all, I should not use \"pay with bank account\". \nI should use \"pay with credit\/debit card\".\nAnd in payu documentation there is information which data use to complete payment programatically (by sending POST data).","Q_Score":0,"Tags":"python,testing,payu","A_Id":50797446,"CreationDate":"2018-06-11T12:04:00.000","Title":"How can I programatically do fake payment in payu sandbox?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using Facebook's faiss index with custom indexes using the add_with_ids method. In inference time I use distance, ID = model.search() which returns the custom ID it was trained with. Is it possible to return also a unique id without retraining? Or just return the actual closest vector?\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1900,"Q_Id":50798515,"Users Score":2,"Answer":"Since you provided the actual vectors, you presumably know how to map ids to vectors. \nMost Faiss indexes in do not store the vectors, because they need to be compressed to fit in RAM.","Q_Score":1,"Tags":"python,knn","A_Id":51878585,"CreationDate":"2018-06-11T13:08:00.000","Title":"How to return 'faiss' unique vector id on 'add_with_ids' trained index?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am brand new to Python and Visual Studio, but keep getting this error when running in debug mode. I had Python 3.7 installed and it looks like Visual Studio installed Python 3.6. I am wondering if this is part of the issue.\n\nwarning: Debugger speedups using cython not found. Run '\"C:\\Program\n  Files\\python.exe\" \"C:\\Program Files (x86)\\Microsoft Visual\n  Studio\\2017\\Community\\Common7\\IDE\\Extensions\\Microsoft\\Python\\Core\\Packages\\ptvsd\\pydevd\\setup_cython.py\"\n  build_ext --inplace' to build. pydev debugger: starting","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":324,"Q_Id":50801680,"Users Score":0,"Answer":"I am using Visual Studio 2017 and Python  and was having the same issue. I managed to get rid of the error by going to Tools->Options->Python->Experimental and ticking off 'Use experimental debugger', then shutting down and restarting Visual Studio. It is early days so far but the\n\nwarning: Debugger speedups using cython not found. Run '\"C:\\Program Files\\python.exe\" \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\Common7\\IDE\\Extensions\\Microsoft\\Python\\Core\\Packages\\ptvsd\\pydevd\\setup_cython.py\" build_ext --inplace' to build. pydev debugger: starting\n\nis gone now.","Q_Score":0,"Tags":"python,visual-studio","A_Id":53041937,"CreationDate":"2018-06-11T15:52:00.000","Title":"Visual-Studio-Python-: Debugger speedups using cython not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created an application where users can add posts. I would like to add the post status. Post after adding has the status \"active.\" After 30 days, changes the status to \"inactive\" How can I do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":50802188,"Users Score":0,"Answer":"I think you don't have any idea to solve this issue so here is two:\n\nwrite a background worker (like celery) run it every few hours and mark old posts as inactive\nadd a created_at field to your db and instead of marking post as inactive rememvber if created_at is older than 30 days you can't edit\/update that post.\n\nI personally prefer second solution because that doesn't need a bacground worker","Q_Score":0,"Tags":"python,django","A_Id":50802265,"CreationDate":"2018-06-11T16:23:00.000","Title":"Status post. Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Using the command prompt, I installed pyexcel using \nconda install -c conda-forge pyexcel. I went to Anaconda Navigator and then confirmed that it was installed in the base(root) environment. \nAfter creating a new environment called envda, I found that pyexcel was not available to envda. I even selected \"Update index\", but the package will still not appear. Then from envda, I opened up a terminal window and typed conda install --name envda pyexcel, but the error message from conda reports that the package is not available from the channel. \nPuzzled by this as it should install the package from the base environment to the new environment being envda. Also don't know why in Anaconda Navigator, that pyexcel is not available to be selected for installation in environment envda.\nHow can I make sure that the package pyexcel is installed in my environment envda?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":252,"Q_Id":50805460,"Users Score":0,"Answer":"Puzzled by this as it should install the package from the base environment to the new environment being envda.\n\nThis is not how conda works. You need to specify the channel every time you install the package. Conda will avoid downloading the package again, if it can, but it does not automatically \"copy\" packages from one environment to the other with the install command.","Q_Score":0,"Tags":"python-3.x,anaconda,conda,pyexcel","A_Id":50835155,"CreationDate":"2018-06-11T20:22:00.000","Title":"Unable to install pyexcel in Anaconda in new environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is plenty of info on how to use what seems to be third-party packages that allow you to access your sFTP by inputting your credentials into these packages.  \nMy dilemma is this: How do I know that these third-party packages are not sharing my credentials with developers\/etc?\nThank you in advance for your input.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":50806632,"Users Score":0,"Answer":"Thanks everyone for comments. \nTo distill it: Unless you do a code review yourself or you get a the sftp package from a verified vendor (ie - packages made by Amazon for AWS), you can not assume that these packages are \"safe\" and won't post your info to a third-party site.","Q_Score":0,"Tags":"python,security,sftp,paramiko","A_Id":50827731,"CreationDate":"2018-06-11T22:00:00.000","Title":"Security of SFTP packages 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":"Can someone point me the right direction to where I can sync up a live video and audio stream?\nI know it sound simple but here is my issue: \n\nWe have 2 computers streaming to a single computer across multiple networks (which can be up to hundreds of miles away).\nAll three computers have their system clocks synchronized using NTP\nVideo computer gathers video and streams UDP to the Display computer\nAudio computer gathers audio and also streams to the Display computer\n\nThere is an application which accepts the audio stream.  This application does two things (plays the audio over the speakers and sends network delay information to my application).  I am not privileged to the method which they stream the audio.\nMy application displays the video and two other tasks (which I haven't been able to figure out how to do yet).\n- I need to be able to determine the network delay on the video stream (ideally, it would be great to have a timestamp on the video stream from the Video computer which is related to that system clock so I can compare that timestamp to my own system clock).\n- I also need to delay the video display to allow it to be synced up with the audio.\nEverything I have found assumes that either the audio and video are being streamed from the same computer, or that the audio stream is being done by gstreamer so I could use some sync function.  I am not privileged to the actual audio stream.  I am only given the amount of time the audio was delayed getting there (network delay).\nSo intermittently, I am given a number as the network delay for the audio (example: 250 ms).  I need to be able to determine my own network delay for the video (which I don't know how to do yet).  Then I need to compare to see if the audio delay is more than the video network delay.  Say the video is 100ms ... then I would need to delay the video display by 150ms (which I also don't know how to do).  \nANY HELP is appreciated.  I am trying to pick up where someone else has left off in this design so it hasn't been easy for me to figure this out and move forward.  Also being done in Python ... which further limits the information I have been able to find. Thanks.  \nScott","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3020,"Q_Id":50807114,"Users Score":0,"Answer":"A typical way to synch audio and video tracks or streams is have a timestamp for each frame or packet, which is relative to the start of the streams.\nThis way you know that no mater how long it took to get to you, the correct audio to match with the video frame which is 20001999 (for example) milliseconds from the start is the audio which is also timestamped as 20001999 milliseconds from the start.\nTrying to synch audio and video based on an estimate of the network delay will be extremely hard as the delay is very unlikely to be constant, especially on any kind of IP network.\nIf you really have no timestamp information available, then you may have to investigate more complex approaches such as 'markers' in the stream metadata or even some intelligent analysis of the audio and video streams to synch on an event in the streams themselves.","Q_Score":0,"Tags":"python,video,udp,gstreamer,ntp","A_Id":50833346,"CreationDate":"2018-06-11T22:56:00.000","Title":"How to sync 2 streams from separate sources","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to create a regex to find all the variables in a perl code. \nThe variables look like : $variable_test. \nSo here is the regex I use : ^\\$\\w+$\nThis gives me this line in Python : \nmatch = re.findall(r'^\\$\\w+$',line)\nIt works, except when the variable is surrounded by special characters such as ',\",\\,\/ and I don't understand why. So for a variable like \/\"$test for example, there will be no match. I can't figure out why it is happening and how to solve the problem.\n\nThank you for your help","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":50807156,"Users Score":1,"Answer":"The first character of your regexp, '^' matches the beginning of the string, and the last char of your regexp, '$', matches the end of the string.\nSo, your regexp only matches strings that consist of the variable name and nothing else.\nChange your regexp to r'\\$\\w+'.","Q_Score":1,"Tags":"python,regex","A_Id":50807303,"CreationDate":"2018-06-11T22:59:00.000","Title":"Python findall regex does not work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install numpy on macOS X but after executing the command pip install numpy I am getting the error:\n\nEnvironment error :[error 13]: permission denied : 'usr\/local\/bin\/f2py\n\nHow do I fix it?","AnswerCount":11,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":298104,"Q_Id":50807507,"Users Score":0,"Answer":"On Windows this has worked for me. From the command line, specify the path to the exe for Python:\n& \"C:\/Program Files (x86)\/Python37-32\/python.exe\" -m pip install --upgrade pip --user","Q_Score":99,"Tags":"python,macos,numpy","A_Id":57720740,"CreationDate":"2018-06-11T23:50:00.000","Title":"Could not install packages due to a \"Environment error :[error 13]: permission denied : 'usr\/local\/bin\/f2py'\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to install numpy on macOS X but after executing the command pip install numpy I am getting the error:\n\nEnvironment error :[error 13]: permission denied : 'usr\/local\/bin\/f2py\n\nHow do I fix it?","AnswerCount":11,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":298104,"Q_Id":50807507,"Users Score":0,"Answer":"It is always preferred to use a virtual environment ,Create your virtual environment using :\npython -m venv <name_of_virtualenv>\ngo to your environment directory and activate your environment using below command on windows:\nenv_name\\Scripts\\activate.bat\nthen simply use\npip install package_name","Q_Score":99,"Tags":"python,macos,numpy","A_Id":64059034,"CreationDate":"2018-06-11T23:50:00.000","Title":"Could not install packages due to a \"Environment error :[error 13]: permission denied : 'usr\/local\/bin\/f2py'\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to install numpy on macOS X but after executing the command pip install numpy I am getting the error:\n\nEnvironment error :[error 13]: permission denied : 'usr\/local\/bin\/f2py\n\nHow do I fix it?","AnswerCount":11,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":298104,"Q_Id":50807507,"Users Score":9,"Answer":"I too had to face the same problem. This worked for me. Right click and run as admin than run usual command to install. But first run update command to update the pip\npython -m pip install --upgrade pip","Q_Score":99,"Tags":"python,macos,numpy","A_Id":53027283,"CreationDate":"2018-06-11T23:50:00.000","Title":"Could not install packages due to a \"Environment error :[error 13]: permission denied : 'usr\/local\/bin\/f2py'\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to find the distribution that best fit some data. This would typically be some sort of measurement data, for instance force or torque.\nIdeally I want to run Anderson-Darling with multiple distributions and select the distribution with the highest p-value. This would be similar to the 'Goodness of fit' test in Minitab. I am having trouble finding a python implementation of Anderson-Darling that calculates the p-value.\nI have tried scipy's stats.anderson() but it only returns the AD-statistic and a list of critical values with the corresponding significance levels, not the p-value itself.\nI have also looked into statsmodels, but it seems to only support the normal distribution. I need to compare the fit of several distributions (normal, weibull, lognormal etc.).\nIs there an implementation of the Anderson-Darling in python that returns p-value and supports nonnormal distributions?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":2819,"Q_Id":50811061,"Users Score":2,"Answer":"I would just rank distributions by the goodness-of-fit statistic and not by p-values. We can use the Anderson-Darling, Kolmogorov-Smirnov or similar statistic just as distance measure to rank how well different distributions fit.\nbackground:\np-values for Anderson-Darling or Kolmogorov-Smirnov depend on whether the parameters are estimated or not. In both cases the distribution is not a standard distribution.\nIn some cases we can tabulate or use a functional approximation to tabulated values. This is the case when parameters are not estimated and if the distribution is a simple location-scale family without shape parameters.\nFor distributions that have a shape parameter, the distribution of the test statistic that we need for computing the p-values depends on the parameters. That is we would have to compute different distributions or tabulated p-values for each set of parameters, which is impossible.\nThe only solution to get p-values in those cases is either by bootstrap or by simulating the test statistic for the specific parameters.\nThe technical condition is whether the test statistic is asymptotically pivotal which means that the asymptotic distribution of the test statistic is independent of the specific parameters.\nUsing chisquare test on binned data requires fewer assumption, and we can compute it even when parameters are estimated. (Strictly speaking this is only true if the parameters are estimated by MLE using the binned data.)","Q_Score":4,"Tags":"python,statistics,p-value,hypothesis-test,goodness-of-fit","A_Id":50819970,"CreationDate":"2018-06-12T07:00:00.000","Title":"Is there an Anderson-Darling implementation for python that returns p-value?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that records audio from an I2S MEMS microphone, connected to a Raspberry PI 3. \nThis script runs as supposed to, when accessed from the terminal. The problem appears when i run it as a service in the background. \nFrom what i have seen, the problem is that the script as service, has no access to a software_volume i have configured in asoundrc. The strange thing is that i can see this \"device\" in the list of devices using the get_device_info_by_index() function.\nFor audio capturing i use the pyaudio library and for making the script a service i have utilized the supervisor utility.\nAny ideas what the problem might be and how i can make my script to have access to asoundrc when it runs as a service?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":127,"Q_Id":50812469,"Users Score":2,"Answer":"The ~\/.asoundrc file is looked for the home directory of the current user (this is what ~ means).\nPut it into the home directory of the user as which the service runs, or put the definitions into the global ALSA configuration file \/etc\/asound.conf.","Q_Score":1,"Tags":"python,raspbian,audio-recording,alsa","A_Id":50812689,"CreationDate":"2018-06-12T08:22:00.000","Title":"Python script as service has not access to asoundrc configuration 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":"I'm using Hec-Ras for 2D unsteady modeling of a river delta. My model is simulated for one year. I need to extract the velocities and\/or discharges and compare them with the velocities from a already done 1DSA model. I wanted to do it in python but I'm new in programming and I wanted to see if anyone has experience with this kind of problem or has any idea on how I can compare the results the easiest because there is a big amount of data and manually doing it from the ras mapper would take a lot of time.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":319,"Q_Id":50813889,"Users Score":0,"Answer":"Maybe can use vector data, first with a classified and get different values between areas, after a statistical analysis.","Q_Score":1,"Tags":"python,data-modeling,data-extraction","A_Id":58000976,"CreationDate":"2018-06-12T09:36:00.000","Title":"Data extraction from HEC-RAS","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We've recently moved from App Service to App Service Environment on Azure. We need Python 3.6 to run the web API. But we're not able to install the extensions. Are extensions disabled on App service environment. Azure by default offers Python 3.4.1. But few of the libraries need a minimum of 3.6.4 which is available as a extensions. Is there a workaround for this or are we limited to the default Python 3.4.1 available with Azure ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":984,"Q_Id":50816456,"Users Score":0,"Answer":"This is indeed possible but took a bit of experimenting. I had to open the Kudu console from a VM which is inside the same VNet as the App Service Environment. From there on, it's a cake walk. You can also configure Web Jobs from the VM which is otherwise not possible from the portal.","Q_Score":0,"Tags":"python,azure,azure-app-service-envrmnt","A_Id":51572844,"CreationDate":"2018-06-12T11:49:00.000","Title":"Extensions not supported on Azure App Service Environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"What are pros and cons of Fabric and Plumbum python libraries for local\/remote command execution? What are use cases when one library should be used and other is not? What are the differences attention should be drawn to?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":799,"Q_Id":50816468,"Users Score":3,"Answer":"background and suggested comparison methodology\n(oops it's a dead post)\nBoth tools are fun, allow either local or remote work, but have differences in the things they are supposed to solve, i.e. \"terminology\", and both are basically pretty much obsolete by modern deployment\/automation tooling (like ansible, and many others that chose DSL way, e.g. terraform).\nTheir advantage over more modern ones are lack of \"opinionated\" approach about the \"how\", and more on \"what\".\nSuggested comparison criteria:\n\n\"Pythonness\" vs. \"Shellness\" (i.e. how \"pythonic\" the user code with each is)\nSpecial Capabilities\nROI with 2 types of maintainers of your \"automation\" code (ops vs. devs, let's put \"QA\" as something in between)\n\nFabric (my last work was done at 1.8 take this with a grain of time salt):\n\nmore pythonic, than shellish, this means easy to support by both old tools and new - i.e. editors, IDEs would be easy to setup\nmany many context processors, many decorators, very nice\neasier to adopt by developers, a bit more traction would come from ops people\n\nPlumbum\n\nThe user code can be either pythonic or shellish\n\"shell combinators\" are a killer feature to get senior shell\/perl folk onboard, but it uses dynamic imports, so editors\/IDEs are a bit trickier to setup.\nDue to 1. You will get 'ops' people on board easier, because of mimicking shell constructs in Plumbum, but please install good coding conventions.\n\nEpilogue\nHaving worked with both toolkits (with lots of fun) and then having switched to ansible - I feel confident to claim - both tools are now superseded by ansible.\nyou can do most automation tasks with existing ansible modules, and what you can't - you can write a plugin or module for it (in any language), or just call shell module.\nMy consideration would be this:\n\nif your team of maintainers has good level of programming skills (Esp. in python), as a requirement - you'd be ok with using either fabric, Plumbum (it has more cool hacks ;)) or Ansible.\nif you have multi-level multi-team organization, I would simply bet on Ansible - it has lower learning curve, and allows to grow up easily.\n\nGood day.","Q_Score":4,"Tags":"python,compare,fabric,plumbum","A_Id":51920412,"CreationDate":"2018-06-12T11:49:00.000","Title":"Fabric vs Plumbum: differences, use cases, pros and cons","Data Science and Machine Learning":0,"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":"What are pros and cons of Fabric and Plumbum python libraries for local\/remote command execution? What are use cases when one library should be used and other is not? What are the differences attention should be drawn to?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":799,"Q_Id":50816468,"Users Score":0,"Answer":"They're pretty much the same thing.  The biggest win for fabric over plumbum is the ability to connect to multiple hosts in parallel, which is more or less indispensible when you're working with a non-trivial setup.  fabric also offers a couple of contrib helpers that let you upload jinja templates, upload files, and transfer files back to the local system.  I personally find the fabric api to be far more intuitive for working with remote servers.\nYMMV, of course, but both are geared towards being very close to shell commands.  That said, my team and I are focused on ansible for most configuration \/ deploy flows.  Fabric does offer some power over ansible at the expense of having to roll your own idempotence.","Q_Score":4,"Tags":"python,compare,fabric,plumbum","A_Id":51397324,"CreationDate":"2018-06-12T11:49:00.000","Title":"Fabric vs Plumbum: differences, use cases, pros and cons","Data Science and Machine Learning":0,"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 python package dialogflow to connect to my dialogflow agent. I have 2 doubts regarding dialogflow agent training\n\nWhen I add intents using RPC, do I need to explicitly train? And by train I mean call the TrainAgent function and wait for it to complete.\nIf I call TrainAgent twice in succession without waiting between those calls, will dialogflow train twice or just take the recentmost request and train once?","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":476,"Q_Id":50816996,"Users Score":5,"Answer":"Training will happen automatically each time you make a change to the agent and its intents. Calling TrainAgent twice will effectively restart the training from the second time that you call it.","Q_Score":2,"Tags":"python,chatbot,dialogflow-es","A_Id":50863060,"CreationDate":"2018-06-12T12:15:00.000","Title":"Training Dialogflow Doubts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python package dialogflow to connect to my dialogflow agent. I have 2 doubts regarding dialogflow agent training\n\nWhen I add intents using RPC, do I need to explicitly train? And by train I mean call the TrainAgent function and wait for it to complete.\nIf I call TrainAgent twice in succession without waiting between those calls, will dialogflow train twice or just take the recentmost request and train once?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":476,"Q_Id":50816996,"Users Score":2,"Answer":"Whenever you change anything in your intent, the training will be started automatically.\nBut if you want to explicitly start training your agent then you need to call \"TrainAgent\" function.\nIf you call the function twice, the agent training will start again only after the first training completes.","Q_Score":2,"Tags":"python,chatbot,dialogflow-es","A_Id":67725633,"CreationDate":"2018-06-12T12:15:00.000","Title":"Training Dialogflow Doubts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a programming newbie and I'm trying to understand how stdin, stdout, and stderr work. As I understand it, stdout and stderr are two different places where we can direct output from programs. I guess I don't understand what's the point of having a second \"stream\" of output just for errors with stderr? Why not have errors on the regular stdout? What does having errors on stderr allow me to do (basically why is stderr useful)?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":537,"Q_Id":50818465,"Users Score":0,"Answer":"In UNIX (and Linux, and other Posix-compatible systems) programs are often combined with pipes, so that one program takes the output of another one as input. If you would mix normal output and error information, every program would need to know how to treat diagnostic info from its pipe data producer differently from normal data. In practice, that is impossible due to the large number of program combinations.\nBy writing error information to stderr, each program makes it possible for the user to get this info without needing to filter it out of the data stream intended to be read by the next program in the pipe.","Q_Score":5,"Tags":"python,error-handling,stdout,stdin,stderr","A_Id":50818776,"CreationDate":"2018-06-12T13:28:00.000","Title":"What is the point of \"stderr\" in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a programming newbie and I'm trying to understand how stdin, stdout, and stderr work. As I understand it, stdout and stderr are two different places where we can direct output from programs. I guess I don't understand what's the point of having a second \"stream\" of output just for errors with stderr? Why not have errors on the regular stdout? What does having errors on stderr allow me to do (basically why is stderr useful)?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":537,"Q_Id":50818465,"Users Score":5,"Answer":"There are two \"points\" to supporting distinct stout and stderr streams:\n\nWhen you are writing applications that can be chained together (e.g. using pipelines) you don't want the \"normal\" output to get mixed up with errors, warnings, debug info and other \"chit chat\".  Mixing them in the same stream would make life difficult for the next program in the chain \/ pipeline.\nExample:\n$ cat some-file | grep not\n$ echo $?\nIf the cat command did not write its error messages to stderr, then the grep command would see a \"file not found\" message if \"some-file\" did not exist.  It would then (incorrectly) match on the \"not\", and set the return code for the pipeline incorrectly.  Constructing pipelines that coped with this sort of thing would be hellishly difficult.\n\nSeparate stdout and stderr streams have been support in (at least) UNIX and UNIX-like system since ... umm ... the 1970's.  And they are part of the POSIX standard.  If a new programming language's runtime libraries did not support this, then it would be considered to be crippled; i.e. unsuitable for writing production quality applications.\n(In the history of programming languages, Python is still relatively new.)\n\n\nHowever, nobody is forcing to write your applications to use stderr for its intended purpose.  (Well ... maybe your future co-workers will :-) )","Q_Score":5,"Tags":"python,error-handling,stdout,stdin,stderr","A_Id":50818699,"CreationDate":"2018-06-12T13:28:00.000","Title":"What is the point of \"stderr\" in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Odoo 10 mass mailing module to send newsletters. I have configured it but I don't know how to configure bounced emails. It is registering correctly sent emails, received (except that it is registering bounced as received), opened and clicks.\nCan anyone please help me?\nRegards","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":520,"Q_Id":50819764,"Users Score":0,"Answer":"I managed to solve this problem. Just configured the 'bounce' system parameter to an email with the same name.\nExample:\nI created an email bounce-register@example.com. Also remember to configure the alias domain in your general settings to 'example.com'\nAfter configuring your email to register bounces you need to configure an incomming mail server for this email (I configured it as an IMAP so I think that should do altough you can also configure it as a POP). That would be it.\nHope this info server for you","Q_Score":0,"Tags":"python,email,odoo,odoo-10","A_Id":50861301,"CreationDate":"2018-06-12T14:34:00.000","Title":"Odoo 10 mass mailing configure bounces","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to start a python script via java and send the data via socket back to the java program.\nMy problem is that when I start the python script after the SocketServer is created with Runtime.getRuntime().exec(\"python3 ~\/Documents\/sensor\/sensorADC.py\");\nno connection is established and no data is transmitted.\nBut when I start the script manually via CLI, everything works fine.\nThe timing of the program start shouldn't be the problem, because I already tried different ways and orders.\nThe java program is a javaFx application.\nEDIT: tested in Linux\n2nd Edit:\n    private void startPythonScript () {\n        try {\n            measureProcess = Runtime.getRuntime().exec(\"python3 ~\/Documents\/sensor\/sensorADC.py\")); \n        } catch (IOException e) {\n                e.printStackTrace();\n        }\n    }\nWhat am I missing?\nThank you in advance","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":50821130,"Users Score":0,"Answer":"I \"solved\" it.\nI compiled it with pyinstaller and now it works. Python seems to be the problem here.\nBut I don't know why....\nFor others I compiled it to an executable with pyinstaller --onefile sensor.py","Q_Score":3,"Tags":"java,python","A_Id":50843052,"CreationDate":"2018-06-12T15:46:00.000","Title":"Java start python process","Data Science and Machine Learning":0,"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":"What does -m in python -m pip install <package> mean ? \nor while upgrading pip using python -m pip install --upgrade pip.","AnswerCount":6,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":69978,"Q_Id":50821312,"Users Score":15,"Answer":"When -m is used with a python statement on the command line, followed by a <module_name>, then it enables the module to be executed as an executable file.\nYou can refer to python docs for the same, or run python --help","Q_Score":122,"Tags":"python,python-3.x,pip","A_Id":61049005,"CreationDate":"2018-06-12T15:54:00.000","Title":"Meaning of python -m flag","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I routinely use pickle.dump() to save large files in Python 2.7. In my code, I have one .pickle file that I continually update with each iteration of my code, overwriting the same file each time.\nHowever, I occasionally encounter crashes (e.g. from server issues). This may happen in the middle of the pickle dump, rendering the pickle incomplete and the pickle file unreadable, and I lose all my data from the past iterations.\nI guess one way I could do it is to save one .pickle file for each iteration, and combine all of them later. Are there any other recommended methods, or best practices in writing to disk that is robust to crashing?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":175,"Q_Id":50822127,"Users Score":0,"Answer":"You're effectively doing backups, as your goal is the same: disaster recovery, lose as little work as possible.\nIn backups, there are these standard practices, so choose whatever fits you best:\n\nbacking up \n\n\nfull backup (save everything each time)\nincremental backup (save only what changed since the last backup)\ndifferential backup (save only what changed since the last full backup)\n\ndealing with old backups\n\n\ncircular buffer\/rotating copies (delete or overwrite backups older than X days\/iterations, optionally change indices in others' names)\nconsolidatating old incremental\/differential copies into the preceding full backup (as a failsafe, consolidate into a new file and only then delete the old ones)","Q_Score":1,"Tags":"python,pickle","A_Id":50822329,"CreationDate":"2018-06-12T16:53:00.000","Title":"How to perform a pickling so that it is robust against crashing?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I create up to 100 keras models in separated script an save them localy with model.save().\nFor Training them, I use multiprocessing.pool. In those processes I load each model separately. Because of occuring Memory Errors I used keras.backend.clear_session(). This seems to work but I have also read that it deletes the weights of models.\nSo to come back to my question, if I import \"from keras import backend as K\" in each process of the pool and at the end, after I saved the models, I use K.clear_session(), do I clear important data of parallel running processes or just data of this process?\nIf it deletes important data of parallel running processes. Is there any possibility of creating a local tensorflow session inside the process. Then assign the needed model to this session and then clear_session() this local one?\nI\u00b4m thankful for any input. \nIn adition it would be helpful if anyone knows the exact functionality of clear_session(). The explanation of this function is not very informative especially for beginners like me.\nThank you :)","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":1899,"Q_Id":50823233,"Users Score":3,"Answer":"I faced similar kind of issue but I am not running models in parallel but alternatively i;e; either of the models (in different folders but same model file names) will run. \nWhen I run the models directly without clear_session it was conflicting with the previously loaded model and cannot switch to other model. After including clear_session at the beginning of statements (which loads the model) it was working, however it was also deleting global variables declared at the beginning of the program which are necessary for prediction activity. \nlesson learnt:\nclear_session will not only \"Destroys the current TF graph and creates a new one.\" as mentioned in the documentation but also deletes global variables defined in the program. \nSo I defined the global variables just after the clear_session statement\n** feedback appreciated","Q_Score":5,"Tags":"python,tensorflow,keras,multiprocessing","A_Id":53845674,"CreationDate":"2018-06-12T18:05:00.000","Title":"Does keras.backend.clear_session() deletes sessions in a process or globally?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am experimenting with python and data analytics. I collected tweets, counted the distinct users, and summed them ,grouped by their locations. Then i have calculated the percentage of users per country population. To make my graphs look better i have standardised my data using the z-score formula. Now i observe that i have a few outliers that ruin my graphs, so i will exclude them. My question is, do i have to exlude them from the original dataset and then re standardise my data, or is it correct to just exclude the standardised form from my analysis and proceed with the values i have already calculated?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":50824847,"Users Score":0,"Answer":"As part of the Exploratory Data Analysis(EDA) Process, you'll want to visualize your data with all data points, identify outliers and then further investigate those outliers to figure out what to do with them. Are these outliers inaccurate values that need to be corrected? Perhaps erroneous entries in the raw data? Or are they valid data points that might point to something interesting? You can also assess the distribution of your data with df.describe()\nIf they are errors, correct them in your dataset and don't delete them. If they are accurate, valid outliers, just exclude them from the visualization to have a better picture of the rest of your data. Does this help?","Q_Score":0,"Tags":"python,data-visualization,data-analysis","A_Id":50825599,"CreationDate":"2018-06-12T19:51:00.000","Title":"Re- standardise data after excluding outliers?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a neural network with 3 consecutive linear layers (convolution), with no activation functions in between. After training the network and obtaining the weights, I would like to collapse all 3 layers into one layer. \nHow can this be done in practice, when each layer has different kernel size and stride?\nThe layers are as follows:\n\nConvolution layer with a 3x3 kernel, 5 input channels and 5 output channels (a tensor of size 3x3x5x5), with stride 1 and padding \"same\"\nConvolution layer with a 5x5 kernel, 5 input channels and 50 output channels (a tensor of size 5x5x5x50), with stride 2 and padding \"same\"\nConvolution layer with a 3x3 kernel, 50 input channels and 50 output channels (a tensor of size 3x3x50x50), with stride 1 and padding \"same\"\n\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":223,"Q_Id":50835327,"Users Score":1,"Answer":"Permute the dimensions of the first-layer kernels such that input channels are in the \"mini-batch\" dimension and output channels are in the \"channels\" dimension. Apply the second layer to that as if that were an image. Then apply the third layer to the result of that. The final result are kernels of the \"collapsed\" layer.\nUse \"full\" padding all these operations. If that works roughly correctly (apart from padding), try fixing the padding (probably it should be \"same\" in the last operation).","Q_Score":1,"Tags":"python,machine-learning,neural-network,convolution,convolutional-neural-network","A_Id":50840894,"CreationDate":"2018-06-13T10:49:00.000","Title":"Collapsing consecutive linear layers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Maximum number of subscription possible by paho-mqtt python  library.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":481,"Q_Id":50835415,"Users Score":1,"Answer":"Normally subscriptions are held by the broker, not the client. The broker just forwards messages to the client that match a topic pattern and the client passes that received message to the callback.\nHow those topic patterns are stored will differ from broker to broker, but assuming even the most naive implementation of an array then the limit would likely to be the size of an int on the platform the broker was running on, which is likely to be larger than any sensible system would ever hit.\nIf the client library is keeping track of the list of subscribed topics (which I don't believe the Paho libraries do as there is no need), then the list is likely to be on the same scale as the broker.\nAlso be aware that you can subscribe to wildcard topics, this would hold a single slot in any list, but could match any number of actual topic a message is published on.","Q_Score":0,"Tags":"python-3.x,mqtt,paho","A_Id":50836002,"CreationDate":"2018-06-13T10:54:00.000","Title":"what is maximum number for subsciption can be handle by 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":"I have an MVN project and would like to add a Python program in the project. The IDE I am using in Intellij.\n\nI have added the MVN pom file as below:\n\norg.codehaus.mojo\nversions-maven-plugin\n2.1\n\n\n\npython\nsrc\/main\/resources\/pythonlib \n\nPYTHONPATH\n\n\n\n\nAdded the Python plugin\nWhile trying to run from the editor it is asking for Python interpreter:\n\nWhich has 2 radio buttons:\n\nUse SDK of the module\nUse specified interpreter.\n\nIn both the list does not have any Python interpreter. How to have the list display a Python interpreter.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":50835836,"Users Score":0,"Answer":"Added the interpreter at module level in project settings an it worked fine for me. \nProject Settings -> Modules -> Click + an added the python home directory.","Q_Score":1,"Tags":"python,maven,intellij-idea","A_Id":50839568,"CreationDate":"2018-06-13T11:15:00.000","Title":"Intellij - Python interpretor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I try to manage if condition in Django.\nIt's working fine but getting an error when trying to check with flake8\nflake8 data\/view.py\nMy condition like this:\nif user.item.purchase.status == True:\nHere user, item and purchase is model and status is a field of purchase. \nand Status have Three values 1)Undefine 2)True 3)False\n\nI'm doing something wrong?\n\nFlake8 error E712 comparison to True should be 'if cond is True:' or 'if cond:'\nThanks in advance","AnswerCount":3,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":4124,"Q_Id":50836584,"Users Score":-3,"Answer":"use \"is\" instead of \"==\"","Q_Score":3,"Tags":"python,django,python-3.x,if-statement,django-rest-framework","A_Id":65944875,"CreationDate":"2018-06-13T11:52:00.000","Title":"Flake8 error `E712 comparison to True should be 'if cond is True:' or 'if cond:'` in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am optimizing the hyper-parameters of my neural-network, for which I am recursively training the network using different hyper-parameters. It works as expected until after some iterations, when creating a new network for training, it dies with the error \"Segmentation fault (core dumped)\".\nFurthermore, I am using GPU for training and I am doing this on a Nvidia Jetson TX2 and Python3.5. Also, I am using Keras with TensorFlow backend.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1251,"Q_Id":50840749,"Users Score":2,"Answer":"If you run K.clearsession() on a GPU with Keras 2, you may get a segmentation fault.\nIf you have this in your code, try removing it!","Q_Score":2,"Tags":"python-3.x,tensorflow,segmentation-fault,keras,nvidia-jetson","A_Id":51275732,"CreationDate":"2018-06-13T15:15:00.000","Title":"Segmentation fault (core dumped) when training more than one Keras NN models","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to automate my mobile web app.Every time it loads, it will ask \"___ would like to use your location\". User can either hit \"don't allow\" or \"OK.\"\nI am using self.driver.switch_to.alert.accept(), but it is accepting the default, which is \"don't allow.\" How can I accept the \"OK\" instead of \"don't allow\"?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1548,"Q_Id":50842653,"Users Score":0,"Answer":"I understood that you are asking for the device location alert. You can identify and use the Xpath of OK button to click. I have used the following code (in java) for an alert appears in the app.\ndriver.findElement(By.xpath(\"\/\/UIAApplication[1]\/UIAWindow[7]\/UIAAlert[1]\/UIACollectionView[1]\/UIACollectionCell[1]\/UIAButton[1]\")).click();","Q_Score":1,"Tags":"python,ios,mobile,automation,appium","A_Id":51200905,"CreationDate":"2018-06-13T17:03:00.000","Title":"How to press \"OK\" for location popup on iOS Appium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am doing a Kaggle competition which requires imputing some missing data. I have installed latest Anaconda(4.5.4) with all relevant dependencies (i.e scikit-learn (0.19.1)).\nWhen I try to import the modules I am getting the following error:\n\nModuleNotFoundError: No module named 'sklearn.impute'\n\nI have tried to import different sklearn modules without any problems. It seems that only sklearn.impute is missing.","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":17981,"Q_Id":50843757,"Users Score":0,"Answer":"Another option is SimpleImputer, it works fine:\nfrom sklearn.impute import SimpleImputer","Q_Score":12,"Tags":"python-3.x,scikit-learn,anaconda","A_Id":64878625,"CreationDate":"2018-06-13T18:17:00.000","Title":"Getting \"ModuleNotFoundError: No module named 'sklearn.impute'\" despite having latest sklearn installed (0.19.1)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a Kaggle competition which requires imputing some missing data. I have installed latest Anaconda(4.5.4) with all relevant dependencies (i.e scikit-learn (0.19.1)).\nWhen I try to import the modules I am getting the following error:\n\nModuleNotFoundError: No module named 'sklearn.impute'\n\nI have tried to import different sklearn modules without any problems. It seems that only sklearn.impute is missing.","AnswerCount":7,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":17981,"Q_Id":50843757,"Users Score":10,"Answer":"As BallpointBen pointed out, sklearn.impute is not yet released in the latest stable release (0.19.1). Currently it's supported only in 0.20.dev0.","Q_Score":12,"Tags":"python-3.x,scikit-learn,anaconda","A_Id":50844299,"CreationDate":"2018-06-13T18:17:00.000","Title":"Getting \"ModuleNotFoundError: No module named 'sklearn.impute'\" despite having latest sklearn installed (0.19.1)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a Kaggle competition which requires imputing some missing data. I have installed latest Anaconda(4.5.4) with all relevant dependencies (i.e scikit-learn (0.19.1)).\nWhen I try to import the modules I am getting the following error:\n\nModuleNotFoundError: No module named 'sklearn.impute'\n\nI have tried to import different sklearn modules without any problems. It seems that only sklearn.impute is missing.","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":17981,"Q_Id":50843757,"Users Score":1,"Answer":"It's a version error. Here's a fix that worked for me while working in Jupyter Notebook. From your Terminal:\nconda update anaconda\nconda update scikit-learn\n\nThen restart your jupyter kernal","Q_Score":12,"Tags":"python-3.x,scikit-learn,anaconda","A_Id":54895196,"CreationDate":"2018-06-13T18:17:00.000","Title":"Getting \"ModuleNotFoundError: No module named 'sklearn.impute'\" despite having latest sklearn installed (0.19.1)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a Kaggle competition which requires imputing some missing data. I have installed latest Anaconda(4.5.4) with all relevant dependencies (i.e scikit-learn (0.19.1)).\nWhen I try to import the modules I am getting the following error:\n\nModuleNotFoundError: No module named 'sklearn.impute'\n\nI have tried to import different sklearn modules without any problems. It seems that only sklearn.impute is missing.","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":17981,"Q_Id":50843757,"Users Score":0,"Answer":"you can use \nfrom sklearn.preprocessing import Imputer\nit works.","Q_Score":12,"Tags":"python-3.x,scikit-learn,anaconda","A_Id":57499632,"CreationDate":"2018-06-13T18:17:00.000","Title":"Getting \"ModuleNotFoundError: No module named 'sklearn.impute'\" despite having latest sklearn installed (0.19.1)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python 3 file that run a SVN deployment. Basically run \"python3 deploy.py update\" and following things happen:\n\nClose site\nBackup Ignore but secure files\nSVN revert -R .\nSVN update \nTrigger tasks\nOpen site\n\nThat all sounds simple and logical, but for one thought going around my head \"SVN is writing files, including python files and sub module helpers that are trigger the SVN subprocess\" \nI understand that python files are read and processed and only through some tricky reload will python reload. And I understand if SVN change python source then update would only take effect on next run. \nBut question is \"should keep this structure or move file to root and run SVN to be safe side\" \nApplies to GIT or any python changes","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1449,"Q_Id":50844415,"Users Score":0,"Answer":"From what I know it is safe to change python (i.e. .py) file while python is running, after .pyc file has been created by python (i.e. your situation). You can even remove .py file and run .pyc just fine. \nOn the other hand SVN revert -R . is dangerous here as it would attempt removing .pyc files, so either screw up your python or fail by itself.","Q_Score":0,"Tags":"python,git,svn,deployment","A_Id":50844763,"CreationDate":"2018-06-13T18:58:00.000","Title":"Safe to change python file during run 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":1,"Web Development":0},{"Question":"I'm trying to use pyinstaller to create an single exe file of my Python program, but when the process completes, the exe can't be run. After reviewing the console output from the process, I can see that following the line: \n126946 INFO: Looking for dynamic libraries\nI get several hundred lines of \"WARNING: lib not found: api-ms-win-crt-any number of different .dll dependency of path to where the dll or pyd is saved\nI installed Python using a default configuration and have always installed Python packages using pip. Pyinstaller is supposed to be straight-forward and not need a lot of extra steps, like creating a setup.py file, but it seems something is missing which tells pyinstaller where to look for those missing libraries. Is there a workaround for this? Or even a better python to exe compiler that I should use?\nEDIT:\nTo provide more info - My program is made up of 5 modules, and among those I use three 3rd party packages including: PyQt5, pandas and ArcGIS. Additionally, I have two sql files that are part of the program as well. I have a feeling that pyinstaller can only compile simple scripts and by using other packages, modules and external files, it just it's made to handle that kind of stuff.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8533,"Q_Id":50844709,"Users Score":0,"Answer":"You need to install the Windows 10 SDK and then update your Path to include the ucrt dlls, which may be found here post-installation:\nC:\\Program Files (x86)\\Windows Kits\\10\\Redist\\ucrt\\DLLs\\x86","Q_Score":1,"Tags":"python,compilation,libraries,pyinstaller","A_Id":50849106,"CreationDate":"2018-06-13T19:17:00.000","Title":"What to do if pyinstaller can't find dynamic or custom libraries?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The module 'discord' I installed in the command prompt which I ran as administrator can't be found. It's located in my site-packages directory along with some other modules such as setuptools which when I import, are imported successfully without error. However, discord which is in the same directory doesn't. In the environment variables I have Path which I've specified to site-packages but I still receive the error that discord cannot be found.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2176,"Q_Id":50848070,"Users Score":0,"Answer":"That error is common on Python version 3.7\n\nIf you are trying to run your bot or discord app with Python 3.7 and getting an error such as Invalid Syntax, we recommend that you install Python 3.6.x instead. Discord.py isn't supported on 3.7 due to asyncio not supporting it.\n  Remember to add Python to PATH!\n\nInstall an older version of PY to run discord!","Q_Score":0,"Tags":"python,module,discord","A_Id":51535001,"CreationDate":"2018-06-14T00:33:00.000","Title":"I Installed a Module Called Discord and When Using \"import discord\" I Get the Error: \"ModuleNotFoundError: No module named '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":"As far as I have read it seems like Jinja is only for creating HTML files. Can it be used for creating python files as well?","AnswerCount":2,"Available Count":1,"Score":-0.2913126125,"is_accepted":false,"ViewCount":1778,"Q_Id":50850819,"Users Score":-3,"Answer":"Jinja is mainly to embed python code into html templates, similar to PHP's <?php echo \"Hello\" ?> if you're familiar with PHP.","Q_Score":3,"Tags":"python,jinja2","A_Id":50850931,"CreationDate":"2018-06-14T06:19:00.000","Title":"Is It possible to create Python files using Jinja","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a byte representation of a string, no idea what is the encoding, I know that b'\\x04\\x00\\x00\\x00\\xf0\\x9f\\x90\\x9f\\x00' represents (fish character). Is it possible to find the encoding based on this information?\nI checked  print(b'\\x04\\x00\\x00\\x00\\xf0\\x9f\\x90\\x9f\\x00')  prints , so terminal knows its encoding, not me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":387,"Q_Id":50852989,"Users Score":0,"Answer":"\\xf0\\x9f\\x90\\x9f is the UTF-8 encoded character U+1F41F FISH.\nThe rest are useless NUL bytes and one 0x04 EOT byte, which don't do a lot usually.","Q_Score":0,"Tags":"python,encoding,character-encoding","A_Id":50853166,"CreationDate":"2018-06-14T08:29:00.000","Title":"Find encoding based on 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":"What is the difference between  APIView class and generics.GenericAPIView","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5328,"Q_Id":50853915,"Users Score":9,"Answer":"APIView is a base class. It doesn't assume much and will allow you to plug pretty much anything to it.\nGenericAPIView is meant to work with Django's Models. It doesn't assume much beyond all the bells and whistles the Model introspection can provide.","Q_Score":10,"Tags":"python,django-rest-framework","A_Id":50854015,"CreationDate":"2018-06-14T09:18:00.000","Title":"What is the difference between APIView class and generics.GenericAPIView","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between  APIView class and generics.GenericAPIView","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":5328,"Q_Id":50853915,"Users Score":7,"Answer":"APIView is the base class based view. Viewsets have APIView as a parent class.\nWith APIview you code methods etc for the different HTTP call methods such as post, get, put etc. These come with no standard configuration, so you can customise to your needs\nWith Viewsets, you code more specific methods . For example the \u2018retrieve\u2019 method, will expect arguments of the request and the pk of the object to be retrieved. Thus you write methods for create, retrieve, list, etc instead of post,get\u2026\nMoving on from that, you also have the routers. These work with viewsets and will create the urls for you based on how you coded the Viewset","Q_Score":10,"Tags":"python,django-rest-framework","A_Id":60296270,"CreationDate":"2018-06-14T09:18:00.000","Title":"What is the difference between APIView class and generics.GenericAPIView","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Google's Word2vec and I'm wondering how to get the top words that are predicted by a skipgram model that is trained using hierarchical softmax, given an input word?\nFor instance, when using negative sampling, one can simply multiply an input word's embedding (from the input matrix) with each of the vectors in the output matrix and take the one with the top value. However, in hierarchical softmax, there are multiple output vectors that correspond to each input word, due to the use of the Huffman tree. \nHow do we compute the likelihood value\/probability of an output word given an input word in this case?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":342,"Q_Id":50860649,"Users Score":0,"Answer":"I haven't seen any way to do this, and given the way hierarchical-softmax (HS) outputs work, there's no obviously correct way to turn the output nodes' activation levels into a precise per-word likelihood estimation. Note that:\n\nthe predict_output_word() method that (sort-of) simulates a negative-sampling prediction doesn't even try to handle HS mode\nduring training, neither HS nor negative-sampling modes make exact predictions \u2013 they just nudge the outputs to be more like the current training example would require\n\nTo the extent you could calculate all output node activations for a given context, then check each word's unique HS code-point node values for how close they are to \"being predicted\", you could potentially synthesize relative scores for each word \u2013 some measure of how far the values are from a \"certain\" output of that word. But whether and how each node's deviation should contribute to that score, and how that score might be indicative of a interpretable liklihood, is unclear. \nThere could also be issues because of the way HS codes are assigned strictly by word-frequency \u2013 so 'neighbor' word sharing mostly-the-same-encoding may be very different semantically. (There were some hints in the original word2vec.c code that it could potentially be beneficial to assign HS-encodings by clustering related words to have similar codings, rather than by strict frequency, but I've seen little practice of that since.)\nI would suggest sticking to negative-sampling if interpretable predictions are important. (But also remember, word2vec isn't mainly used for predictions, it just uses the training-attempts-at-prediction to bootstrap a vector-arrangment that turn out to be useful for other tasks.)","Q_Score":2,"Tags":"python,c++,nlp,word2vec,gensim","A_Id":50868421,"CreationDate":"2018-06-14T15:07:00.000","Title":"How to predict word using trained skipgram model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Below is the error when I am trying to install the particular version(1.2.1) of sceptre not the latest version,Please advise. Thanks.\n$ pip install -e sceptre-1.2.1\nsceptre-1.2.1 should either be a path to a local project or a VCS url beginning with svn+, git+, hg+, or bzr+","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":308,"Q_Id":50863679,"Users Score":0,"Answer":"So the pip -e flag (edit mode) is maybe not doing what you think it should do here. \nIf you want to install a specific version of a package using pip you should do: \npip install sceptre==1.2.1\nIf you have installed sceptre globally across your system, rather than using a virtualenv then you may need to uninstall that package to use this specific version, but it is best to use a virtualenv.","Q_Score":0,"Tags":"python,python-2.7,sceptre","A_Id":50872754,"CreationDate":"2018-06-14T18:21:00.000","Title":"Error downloading the Sceptre","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on building a neural net model that targets to predict success\/failure of server update. \nHowever, the existing data is highly imbalanced. I.e. only 3 % of the records are failures, the rest is all success record.\nI am now trying to do some data exploration using confusion matrix. In this case, should I assign 'positive(1)' label to 'failure' label? or does it even matter which label that I assign to ?\nThanks in advances.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":50864233,"Users Score":0,"Answer":"It is a binary classification problem. Usually the classes labeled as positive =1, and negative =0","Q_Score":0,"Tags":"python,neural-network","A_Id":50864355,"CreationDate":"2018-06-14T19:02:00.000","Title":"Defining label in confusion matrix with highly imbalanced dataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm automating some software tests at the moment and I was wondering if it's possible to pass or fail a test in python so that RF shows the same result. For example, I'm doing an install test and at the end I check through the registry to confirm a clean install. If anything is missing I want to be able to essentially exit(0) and have RF show a fail, but just returns \"[ ERROR ] Execution stopped by user.\"","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1648,"Q_Id":50864593,"Users Score":2,"Answer":"Tests fail when a keyword fails. Keywords fail when they throw an exception (or call a keyword that throws an exception). So, you can write a keyword that executes your script and throws an exception if the return code is non-zero.\nIn other words, what you want won't happen automatically, but is extremely easy to implement.","Q_Score":1,"Tags":"python,automation,robotframework","A_Id":50866020,"CreationDate":"2018-06-14T19:29:00.000","Title":"Returning a pass\/fail to robot framework from 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 use numpy.memmap to load only the parts of arrays into memory that I need, instead of loading an entire huge array. I would like to do the same with bool arrays.\nUnfortunately, bool memmap arrays aren't stored economically: according to ls, a bool memmap file requires as much space as a uint8 memmap file of the same array shape.\nSo I use numpy.unpackbits to save space. Unfortunately, it seems not lazy: It's slow and can cause a MemoryError, so apparently it loads the array from disk into memory instead of providing a \"bool view\" on the uint8 array.\nSo if I want to load only certain entries of the bool array from file, I first have to compute which uint8 entries they are part of, then apply numpy.unpackbits to that, and then again index into that.\nIsn't there a lazy way to get a \"bool view\" on the bit-packed memmap file?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":163,"Q_Id":50865421,"Users Score":2,"Answer":"Not possible. The memory layout of a bit-packed array is incompatible with what you're looking for. The NumPy shape-and-strides model of array layout does not have sub-byte resolution. Even if you were to create a class that emulated the view you want, trying to use it with normal NumPy operations would require materializing a representation NumPy can work with, at which point you'd have to spend the memory you don't want to spend.","Q_Score":0,"Tags":"python,numpy,boolean,mmap,numpy-memmap","A_Id":50865504,"CreationDate":"2018-06-14T20:26:00.000","Title":"Lazy version of numpy.unpackbits","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I recently downloaded python3 and django-2 but I realised my computer has already python 2 and django 1.11, so I managed to create project with django 3 using python3 django -m startproject or something like this, even I managed to create a django 2 project, this time at the urls.py, it says \"No name 'path' in module 'django.urls'.\nCan you help me with how to create a project using django2 and python3 in lubuntu and this error.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":150,"Q_Id":50867343,"Users Score":0,"Answer":"first install the django by sudo python3 -m pip install django after that check for the version by python3 -m django --version it will surely be the latest version of the django and then start your project by django-admin startproject mysite where mysite is the name of project you want to start. This problem may be arised due to an old version of django, so you have to use the latest version of django.\nHope it will help you.","Q_Score":0,"Tags":"python,django,path,pip","A_Id":50867576,"CreationDate":"2018-06-14T23:40:00.000","Title":"No name 'path' issue, unable to start project in django, lubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I got to thinking that if we store data in a text file, it is stored in a linear fashion. While you can store things in sorted order, there\u2019s always the chance that the thing you\u2019re looking for is last in the file. \nIn my algorithms course, there was a lot of talk about efficient ways to organize data within a Java\/python\/C program. You can create a binary search tree object, and all is well. But nothing was mentioned about storing a hard copy of said data in an efficient manner. \nMy question is this: Is there a way to store a hard copy of some data in a binary search tree format? So that when you go to read from the file in Java, for example, Java can quickly \u201cjump\u201d left or right, and process the data in an efficient manner?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":50868156,"Users Score":0,"Answer":"My question is this: Is there a way to store a hard copy of some data\n  in a binary search tree format? So that when you go to read from the\n  file in Java, for example, Java can quickly \u201cjump\u201d left or right, and\n  process the data in an efficient manner?\n\nThere is no special impediment to storing binary search tree data on disk -- even in ways that can be processed fairly directly.  You rely on fixed-size storage units, and that allows you to use some form of storage unit indices in place of pointers.  Disk storage is basically random-access, though at the device and O\/S levels, I\/O is performed in blocks of device- and filesystem-dependent size.\nThere are other variations on search trees that tend to be more efficient for use with disk storage, however.  B-trees, for example, were designed and are used for this purpose.  In general, these variations produce shorter, wider trees, often tuned so that nodes are the size of one disk block.","Q_Score":0,"Tags":"java,python,c,text-files,binary-search-tree","A_Id":50869325,"CreationDate":"2018-06-15T01:49:00.000","Title":"Storing a hard copy of data in a binary search tree format","Data Science and Machine Learning":0,"Database and SQL":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 dataset to do sentiment analysis on news articles. I'm using Newspaper3k to scrape articles from the website. I scraped a few websites but didn't store the articles properly and hence I can't use them. When I try scraping the same websites again it only scrapes the new articles and not the ones it already scraped. Is there a way for me to scrape the articles I already scraped again??","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":367,"Q_Id":50868855,"Users Score":1,"Answer":"By default, newspaper caches all previously extracted articles and eliminates any article which it has already extracted.\nThis feature exists to prevent duplicate articles and to increase extraction speed.\nYou may opt out of this feature with the memoize_articles parameter.\nFor example, in your case set it to False:\nnewspaper.build('http:\/\/cbs.com', memoize_articles=False)","Q_Score":2,"Tags":"python,nlp,sentiment-analysis,python-newspaper","A_Id":50977391,"CreationDate":"2018-06-15T03:49:00.000","Title":"How to reread the news on website using newspaper3k","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I'm learning that instance objects have bound methods but you may also call the function by accessing the class because a function can be an attribute of said class. \nMy question would then be, how does python pass in self into the __init__ method automatically when no self has been created? Is there some behind the scenes process that I'm not familiar with? It seems like a chicken before the egg kind of thing. \nI know that other function calls do require you to pass the instantiated object but init seems pretty mysterious to me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":177,"Q_Id":50869118,"Users Score":1,"Answer":"My question would then be, how does python pass in self into the init method automatically when no self has been created? Is there some behind the scenes process that I'm not familiar with? It seems like a chicken before the egg kind of thing.\n\nYes, you are correct. The __init__ is called after a class instance has been created. __init__ does not create a class instance, it simply allows one to 'customize' the instance. The __new__ is the method that is actually used to create new class instances. It takes in a reference to a class object, and any arguments passed to said class object.\nHere is the documentation for the __init__ and __new__ methods:\n__init__:\n\nCalled after the instance has been created (by __new__()), but before it is returned to the caller. The arguments are those passed to the class constructor expression. If a base class has an __init__() method, the derived class\u2019s __init__() method, if any, must explicitly call it to ensure proper initialization of the base class part of the instance; for example: super().__init__([args...]).\nBecause __new__() and __init__() work together in constructing objects (__new__() to create it, and __init__() to customize it), no non-None value may be returned by __init__(); doing so will cause a TypeError to be raised at runtime.\n\n__new__:\n\nCalled to create a new instance of class cls. __new__() is a static method (special-cased so you need not declare it as such) that takes the class of which an instance was requested as its first argument. The remaining arguments are those passed to the object constructor expression (the call to the class). The return value of __new__() should be the new object instance (usually an instance of cls).\nTypical implementations create a new instance of the class by invoking the superclass\u2019s __new__() method using super().__new__(cls[, ...]) with appropriate arguments and then modifying the newly-created instance as necessary before returning it.\nIf __new__() returns an instance of cls, then the new instance\u2019s __init__() method will be invoked like __init__(self[, ...]), where self is the new instance and the remaining arguments are the same as were passed to __new__().\nIf __new__() does not return an instance of cls, then the new instance\u2019s __init__() method will not be invoked.","Q_Score":0,"Tags":"python,python-3.x","A_Id":50869222,"CreationDate":"2018-06-15T04:30:00.000","Title":"How would I create an object with __init__ by directly referencing the class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have spyder installed for different conda environments. Despite this, when I open any spyder for python 2.X I have the same source files open. The same goes for any spyder for python 3.X.\nI would like to have different source files open in spyder per every environment.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":118,"Q_Id":50869441,"Users Score":1,"Answer":"(Spyder maintainer here) To have that you need to create a Spyder project per each conda environment by going to the menu\nProjects > New project...\nand associating a directory with it.\nThis is because our saves and loads the set of open files in our Editor associated with each project.\nNote: This will improved in Spyder 4 (to be released in 2019), when we add the possibility to associate pip\/conda envs to our projects.","Q_Score":0,"Tags":"python,anaconda,spyder,conda","A_Id":50876958,"CreationDate":"2018-06-15T05:11:00.000","Title":"Remember a different set of files in Spyder with different conda environments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use windows 7 and python 2.7\nWhen I used py2exe to make an .exe file I get the error;\nTraceback (most recent call last):\nFile \"mainpy\", line 17, in\nFile \"main.py\", line 17, in\nFile \"zipextimporter.pyc\", line 82, in load_module\nFile \"zipextimporter.pyc\", line 82, in load_module\nFile \"logging_init_.pyc\", line 26, in\nFile \"zipextimporter.pyc\", line 82, in load_module\nFile \"weakref.pyc\", line 14, in\nImportError: cannot import name _remove_dead_weakref\nThe same code could be used to make an .exe file in another computer so there is nothing wrong with the code in main.py. The minor environmental difference may cause this problem. I used pycharm, python 2.7.10 and py2exe 0.6.9. On another computer all other config are the same except using sublimetext instead of pycharm.\nCould anyone please tell me how to fix that?\nAnother tricky thing is that","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":475,"Q_Id":50870204,"Users Score":0,"Answer":"It is possible that the library does not exists for the other computer.Please check whether the library exists or not.","Q_Score":0,"Tags":"python-2.7,py2exe","A_Id":50870246,"CreationDate":"2018-06-15T06:29:00.000","Title":"ImportError: cannot import name _remove_dead_weakref python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a project on extracting a semantic orientation from a review stored in a text file.\nI have a 400*2 array, each row contains a word and it's weight. I want to check which of these words is in the text file, and calculate the weight of the whole content. \nMy question is - \nwhat is the most efficient way to do it? Should I search for each word separately, for example with a for loop? \nDo I get any benefit from storing the content of the text file in a string object?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":194,"Q_Id":50871201,"Users Score":0,"Answer":"This may be out of the box thinking, but if you don't care for semantic\/grammatic connection of the words:\n\nsort all words from the text by length\nsort your array by length \n\n.\n\nWrite a for-loop:\nCall len() (length) on each word from the text. \nThen only check against those words which have the same length. \n\nWith some tinkering it might give you a good performance boost instead of the \"naive\" search. \nAlso look into search algorithms if you want to achieve an additional boost (concerning finding the first word (of the 400) with e.g. 6 letters - then go \"down\" the list until the first word with 5 letters comes up, then stop. \nAlternatively you could also build an index array with the indexes of the first and last of all 5-letter words (analog for the rest), assuming your words dont change.","Q_Score":0,"Tags":"python,arrays,text","A_Id":50871541,"CreationDate":"2018-06-15T07:46:00.000","Title":"How to search for a set of words in a 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'm trying to write a function which finds the length of a linked list in O(1).\nI know how to implement it in O(n) but I can't figure out how to do it in constant time... is that even possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":383,"Q_Id":50871476,"Users Score":0,"Answer":"Its not possible because you have to atleast pass through entire linked list and it takes O(n)\nElse you have to use a variable which counts when inserting elements into linked list","Q_Score":0,"Tags":"python,list,linked-list,time-complexity","A_Id":54593506,"CreationDate":"2018-06-15T08:06:00.000","Title":"finding length of linked list in constant time python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use tesseract-ocr on AWS EC2 machine using python.\nI have install tesseract-ocr, pytesseract and set TESSDATA_PREFIX=\/usr\/local\/share\/tessdata... but still geting below error while calling image_to_string method of pytesseract.\n\npytesseract.pytesseract.TesseractNotFoundError: tesseract not\n  installed or it's not in your path","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":885,"Q_Id":50874626,"Users Score":0,"Answer":"you have to add tesseract installation folder to path too. if you have done that already, you might need to restart once or at least sign out and sign in. TESSDATA is the path you give for tesseract to access the language data.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-ec2,ocr,python-tesseract","A_Id":50874671,"CreationDate":"2018-06-15T11:23:00.000","Title":"AWS EC2 machine giving \"pytesseract.pytesseract.TesseractNotFoundError: tesseract not installed or it's not in your 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":0,"Web Development":1},{"Question":"I am trying to convert PNG image file to text using pytesseract. It is giving me the below error.\nTesseractError: (1, 'Tesseract Open Source OCR Engine v3.05.00dev with Leptonica Warning in pixReadMemPng: work-around: writing to a temp file \nlibpng warning: Application built with libpng-1.4.3 but running with 1.5.14 Error in pixReadStreamPng: png_ptr not made Error in pixReadMemPng: pix not read Error in pixReadMem: png: no pix returned Error during processing.')\nWhen i do tesseract -v\ntesseract 3.05.00dev\n leptonica-1.72\n  libjpeg 9 : libpng 1.5.14 : libtiff 4.0.3 : zlib 1.2.5 : libopenjp2 2.1.0","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2484,"Q_Id":50876458,"Users Score":0,"Answer":"I also meet this problem, and I can't find the answer on the internet.\nBut I try to download the tesseract-ocr and install it, then:\n\nset environment variable, TESSDATA_PREFIX:\"C:\\Program Files (x86)\\Tesseract-OCR\\tessdata\"\nadd C:\\Program Files (x86)\\Tesseract-OCR to the path variable.\nedit pytesseract.py in Line 35, tesseract_cmd = 'C:\\\\Program Files (x86)\\\\Tesseract-OCR\\\\tesseract.exe'\n\nWhen I call pytesseract.image_to_string(img) in anaconda prompt, it return a string. My Environment\uff1a\n\npytesseract 0.2.6\npillow 5.2.0\ntesseract 4.00.00alpha","Q_Score":0,"Tags":"python-3.x,libpng,python-tesseract,libtiff,leptonica","A_Id":54167994,"CreationDate":"2018-06-15T13:18:00.000","Title":"Tesseract Open Source OCR Engine v3.05.00dev with Leptonica Warning in pixReadMemPng","Data Science and Machine Learning":0,"Database and SQL":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":"Windows 10\nWhen I tried install with below command\npython3 -m pip install jupyter\ngetting an error:\n'python3' is not recognized as an internal or external command, operable program or batch file.\n\nPath variable is setup\npip is also working fine.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":12385,"Q_Id":50880444,"Users Score":3,"Answer":"Thanks @emsimpson92\nIssue resolved by using python instead of python3","Q_Score":1,"Tags":"python-3.x,jupyter-notebook","A_Id":50880576,"CreationDate":"2018-06-15T17:45:00.000","Title":"Windows10 'python3' 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":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I delete a Django model without effecting the table it works with.\nPreviously we've used the model and table normally but have since moved the models functionality to a microservice which still operates on the same table.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":102,"Q_Id":50881441,"Users Score":0,"Answer":"You can rename your sql table and then delete the model and then rename back.","Q_Score":0,"Tags":"python,mysql,django,database,models","A_Id":50881461,"CreationDate":"2018-06-15T19:09:00.000","Title":"How to delete a Django model without deleting the table","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"While running pip install InstagramAPI I have 2 errors that I didn't manage to fix yet.\nThe first error I have is\n\n\"networkx 2.1 has requirement decorator>=4.1.0, but you'll have decorator 4.0.11 which is incompatible\"\n\nI tried to run manually pip install decorator but the version 4.0.11 is indeed installed and not version 4.1.0.\nThe second error i receive is:\n\n\"Cannot uninstall 'imageio'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3499,"Q_Id":50882504,"Users Score":0,"Answer":"I would use a virtual environment (the python package) It should take care of most of these dependency problems.","Q_Score":3,"Tags":"python,instagram-api","A_Id":54875304,"CreationDate":"2018-06-15T20:51:00.000","Title":"networkx 2.1 has requirement decorator>=4.1.0, but you'll have decorator 4.0.11 which is incompatible","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using bs4 and urllib.request in python 3.6 to webscrape. I have to open tabs \/ be able to toggle an \"aria-expanded\" in button tabs in order to access the div tabs I need.\nThe button tab when the tab is closed is as follows with <> instead of --:\nbutton id=\"0-accordion-tab-0\" type=\"button\" class=\"accordion-panel-title u-padding-ver-s u-text-left text-l js-accordion-panel-title\" aria-controls=\"0-accordion-panel-0\" aria-expanded=\"false\"\nWhen opened, the aria-expanded=\"true\" and the div tab appears underneath.\nAny idea on how to do this?\nHelp would be super appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1681,"Q_Id":50882732,"Users Score":0,"Answer":"BeautifulSoup is used to parse HTML\/XML content. You can't click around on a webpage with it. \nI recommend you look through the document to make sure it isn't just moving the content from one place to the other. If the content is loaded through AJAX when the button is clicked then you will have to use something like selenium to trigger the click.\nAn easier option could be to check what url the content is fetched from when you click the button and make a similar call in your script if possible.","Q_Score":0,"Tags":"python-3.x,dom,web-scraping,beautifulsoup,urlopen","A_Id":50882877,"CreationDate":"2018-06-15T21:13:00.000","Title":"Accessing Hidden Tabs, Web Scraping With Python 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using the VADER sentiment lexicon in Python's nltk library to analyze text sentiment.  This lexicon does not suit my domain well, and so I wanted to add my own sentiment scores to various words.  So, I got my hands on the lexicon text file (vader_lexicon.txt) to do just that.  However, I do not understand the architecture of this file well.  For example, a word like obliterate will have the following data in the text file: \n    obliterate  -2.9    0.83066 [-3, -4, -3, -3, -3, -3, -2, -1, -4, -3]\nClearly the -2.9 is the average of sentiment scores in the list.  But what does the 0.83066 represent?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1281,"Q_Id":50882838,"Users Score":3,"Answer":"The vader_lexicon.txt file has four tab delimited columns as you said.\n\nColumn 1: The Token\nColumn 2: It is the Mean of the human Sentiment ratings\nColumn 3: It is the Standard Deviation of the token assuming it follows Normal Distribution\nColumn 4: It is the list of 10 human ratings taken during experiments\n\nThe actual code or sentiment calculation does not use the 3rd and 4th columns. So if you want to update the lexicon according to your requirement you can leave the last two columns blank or fill in with a random number and a list.","Q_Score":3,"Tags":"python,nltk,lexicon,vader","A_Id":54122776,"CreationDate":"2018-06-15T21:23:00.000","Title":"Python VADER lexicon Structure for sentiment analysis","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with an instrument that provided the shared libraries to use with C\/C++. As my group is working with Python I wrote a ctypes wrapper using the provided DLLs (loading them with windll) and everything was working right because we were testing the code using Windows.\nThe final machine in which I will need to run the code is OS X, and I think I've hit a wall since the libraries the manufacturer provided don't include .so files, only .dll's.\nIs there any way I can write a wrapper for using this instrument (and its provided DLL files) on Mac OS X without having access to the source code? Or would my best option be finish the program in Windows, create an executable and then running it with Wine?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1049,"Q_Id":50883180,"Users Score":0,"Answer":"There's not enough info to know what a good solution would be, but I can throw an idea or two out there. The device you have probably requires drivers, which are OS specific (in which case it is highly unlikely Wine solutions will work for you). If the device can be connected to a Windows box, but the user application runs on Mac OS, then there are some good possibilities.  You could create a Windows service that opens a network socket to send\/receive data on which the user app running on Mac OS can access.  Or, instead of a Windows service, a simple Windows console app could open the socket.  The Windows service (or console app) would access the device connected to the Windows system via whatever API the manufacturer provides in their libraries while it takes commands from the socket connection and sends data back.","Q_Score":3,"Tags":"python,macos,ctypes","A_Id":51274363,"CreationDate":"2018-06-15T22:00:00.000","Title":"Calling DLLs using python's ctypes in OS X","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"For the app I'm building I need to be able to create a new data model in models.py as fast as possible automatically. \nI created a way to do this by making a seperate python program that opens models.py, edits it, closes it, and does server migrations automatically but there must be a better way.\nedit: my method works on my local server but not on pythonanywhere","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":50886139,"Users Score":1,"Answer":"In the Django documentation, I found SchemaEditor, which is exactly what you want. Using the SchemaEditor, you can create Models, delete Models, add fields, delete fields etc..\nHere's an excerpt:\n\nDjango\u2019s migration system is split into two parts; the logic for\n  calculating and storing what operations should be run\n  (django.db.migrations), and the database abstraction layer that turns\n  things like \u201ccreate a model\u201d or \u201cdelete a field\u201d into SQL - which is\n  the job of the SchemaEditor.","Q_Score":0,"Tags":"django,python-3.x,django-models","A_Id":50940394,"CreationDate":"2018-06-16T08:08:00.000","Title":"How can I add new models and do migrations without restarting the server manually?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I run this simple code:\nfrom flask import Flask,render_template\napp = Flask(__name__)\n@app.route('\/')\ndef index():\n    return 'this is the homepage'\nif __name__ ==  \"__main__\":\n    app.run(debug=True, host=\"0.0.0.0\",port=8080)\nIt works fine but when I close it using ctrl+z in the terminal and try to run it again I get OSError: [Errno 98] Address already in use\nSo I tried changing the port address and re-running it which works for some of the port numbers I enter. But I want to know a graceful way to clear the address being used by previous program so that it is free for the current one. \nAlso is what is the apt way to shutdown a server and free the port address.\nKindly tell a simple way to do so OR explain the method used fully because I read solutions to similar problems but didn't understand any of it.\nWhen I run\nnetstat -tulpn\nThe output is : \n(Not all processes could be identified, non-owned process info\n will not be shown, you would have to be root to see it all.)\nActive Internet connections (only servers)\nProto Recv-Q Send-Q Local Address           Foreign Address         State       PID\/Program name\ntcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN      -\ntcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -\ntcp        0      0 0.0.0.0:3689            0.0.0.0:*               LISTEN      4361\/rhythmbox\ntcp6       0      0 ::1:631                 :::*                    LISTEN      -\ntcp6       0      0 :::3689                 :::*                    LISTEN      4361\/rhythmbox\nudp        0      0 0.0.0.0:5353            0.0.0.0:*                           3891\/chrome\nudp        0      0 0.0.0.0:5353            0.0.0.0:*                           -\nudp        0      0 0.0.0.0:39223           0.0.0.0:*                           -\nudp        0      0 127.0.1.1:53            0.0.0.0:*                           -\nudp        0      0 0.0.0.0:68              0.0.0.0:*                           -\nudp        0      0 0.0.0.0:631             0.0.0.0:*                           -\nudp        0      0 0.0.0.0:58140           0.0.0.0:*                           -\nudp6       0      0 :::5353                 :::*                                3891\/chrome\nudp6       0      0 :::5353                 :::*                                -\nudp6       0      0 :::41938                :::*                                -\nI'm not sure how to interpret it.    \nthe output of ps aux | grep 8080 \nis :\nshreyash 22402  0.0  0.0  14224   928 pts\/2    S+   01:20   0:00 grep --color=auto 8080\nI don't know how to interpret it.\nWhich one is the the process name and what is it's id?","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":10441,"Q_Id":50891073,"Users Score":-1,"Answer":"You will have another process listening on port 8080. You can check to see what that is and kill it. You can find processes listening on ports with netstat -tulpn. Before you do that, check to make sure you don't have another terminal window open with the running instance.","Q_Score":0,"Tags":"python,flask","A_Id":50891141,"CreationDate":"2018-06-16T19:30:00.000","Title":"How to I close down a python server built using flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"When I run this simple code:\nfrom flask import Flask,render_template\napp = Flask(__name__)\n@app.route('\/')\ndef index():\n    return 'this is the homepage'\nif __name__ ==  \"__main__\":\n    app.run(debug=True, host=\"0.0.0.0\",port=8080)\nIt works fine but when I close it using ctrl+z in the terminal and try to run it again I get OSError: [Errno 98] Address already in use\nSo I tried changing the port address and re-running it which works for some of the port numbers I enter. But I want to know a graceful way to clear the address being used by previous program so that it is free for the current one. \nAlso is what is the apt way to shutdown a server and free the port address.\nKindly tell a simple way to do so OR explain the method used fully because I read solutions to similar problems but didn't understand any of it.\nWhen I run\nnetstat -tulpn\nThe output is : \n(Not all processes could be identified, non-owned process info\n will not be shown, you would have to be root to see it all.)\nActive Internet connections (only servers)\nProto Recv-Q Send-Q Local Address           Foreign Address         State       PID\/Program name\ntcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN      -\ntcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -\ntcp        0      0 0.0.0.0:3689            0.0.0.0:*               LISTEN      4361\/rhythmbox\ntcp6       0      0 ::1:631                 :::*                    LISTEN      -\ntcp6       0      0 :::3689                 :::*                    LISTEN      4361\/rhythmbox\nudp        0      0 0.0.0.0:5353            0.0.0.0:*                           3891\/chrome\nudp        0      0 0.0.0.0:5353            0.0.0.0:*                           -\nudp        0      0 0.0.0.0:39223           0.0.0.0:*                           -\nudp        0      0 127.0.1.1:53            0.0.0.0:*                           -\nudp        0      0 0.0.0.0:68              0.0.0.0:*                           -\nudp        0      0 0.0.0.0:631             0.0.0.0:*                           -\nudp        0      0 0.0.0.0:58140           0.0.0.0:*                           -\nudp6       0      0 :::5353                 :::*                                3891\/chrome\nudp6       0      0 :::5353                 :::*                                -\nudp6       0      0 :::41938                :::*                                -\nI'm not sure how to interpret it.    \nthe output of ps aux | grep 8080 \nis :\nshreyash 22402  0.0  0.0  14224   928 pts\/2    S+   01:20   0:00 grep --color=auto 8080\nI don't know how to interpret it.\nWhich one is the the process name and what is it's id?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":10441,"Q_Id":50891073,"Users Score":2,"Answer":"It stays alive because you're not closing it. With Ctrl+Z you're removing the execution from current terminal without killing a process.\nTo stop the execution use Ctrl+C","Q_Score":0,"Tags":"python,flask","A_Id":50891134,"CreationDate":"2018-06-16T19:30:00.000","Title":"How to I close down a python server built using flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"My question is trivial, nevertheless I need your help. It's not a problem to take a np.log(x) of an array. But in my case this array could be N-dimensional\/Tensor (N=2..1024 and 100 samples in each dimension). \nFor N=4 calculation of element-wise np.log(x) takes 10 seconds. I need to take this log(x) in a cost function for optimization, thus, all process of optimization takes roughly 2 hours.\nSo, the question is how this log(x) can be implemented in faster way for N-dimensional arrays. Is it really possible?  \nThanks in advance.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":50892030,"Users Score":0,"Answer":"The numpy log function is implemented in C and optimised for handling arrays, so although you may be able to scrape a bit of overhead off by writing your own custom log function in a lower-level language, this will still remain the bottleneck. If you want to see a big speed increase, you'll need to implement your algorithm differently.\nIs it really necessary to take the log of all these elements? You mention that each dimension can have 100 samples, do you plan on averaging these samples? If so you can reduce the number of logarithms you need to compute by using the fact that log(a) + log(b) = log(ab), and so the average [log(a0) + log(a1) + ... + log(aN)]\/(a0 + a1 + ... + aN) is the same as log(a0*a1*...*aN)\/(a0 + a1 + ... + aN).","Q_Score":0,"Tags":"python,arrays","A_Id":50897886,"CreationDate":"2018-06-16T21:47:00.000","Title":"Python faster way to take logarithm of N-dimensional array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is trivial, nevertheless I need your help. It's not a problem to take a np.log(x) of an array. But in my case this array could be N-dimensional\/Tensor (N=2..1024 and 100 samples in each dimension). \nFor N=4 calculation of element-wise np.log(x) takes 10 seconds. I need to take this log(x) in a cost function for optimization, thus, all process of optimization takes roughly 2 hours.\nSo, the question is how this log(x) can be implemented in faster way for N-dimensional arrays. Is it really possible?  \nThanks in advance.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":50892030,"Users Score":0,"Answer":"Thanks guys,\nthe problem was a big amount of entries that I had to go through for processing. I just found another cost function for my optimization.\nBut, to speed up exactly this code - I think the idea with self made log table exactly for my type of signal can make it work.","Q_Score":0,"Tags":"python,arrays","A_Id":51058038,"CreationDate":"2018-06-16T21:47:00.000","Title":"Python faster way to take logarithm of N-dimensional array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is trivial, nevertheless I need your help. It's not a problem to take a np.log(x) of an array. But in my case this array could be N-dimensional\/Tensor (N=2..1024 and 100 samples in each dimension). \nFor N=4 calculation of element-wise np.log(x) takes 10 seconds. I need to take this log(x) in a cost function for optimization, thus, all process of optimization takes roughly 2 hours.\nSo, the question is how this log(x) can be implemented in faster way for N-dimensional arrays. Is it really possible?  \nThanks in advance.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":50892030,"Users Score":0,"Answer":"Maybe multiprocessing can help you on this situation","Q_Score":0,"Tags":"python,arrays","A_Id":50892434,"CreationDate":"2018-06-16T21:47:00.000","Title":"Python faster way to take logarithm of N-dimensional array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My distribution is WinPython and I use Spyder as an IDLE, my python version is 3.6.5.\nAlthough I have so many modules (from the WinPython download) like pip, pandas, and numpy that work perfectly, I want now to download another package called Swampy.\nSo, I wrote to my IPython console: !pip install Swampy\nand it worked perfectly but when I wrote import Swampy the result was a ModuleNotFoundError!\nLastly, I have to mention that all the packages seem to be here C:\\Users\\MY_USERNAME\\Downloads\\WinPython\\python-3.6.5.amd64\\Lib\\site-packages","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":50892066,"Users Score":0,"Answer":"You should installing package via this syntax <your python interpreter> -m pip install ...\nThe thing is, pip in your system can be tied to another python interpreter, not the one you're using. You say that your python version is 3.6.1, but packages are installed in python-3.6.5 directory, makes it likely to be a mismatch.","Q_Score":1,"Tags":"python,python-import","A_Id":50892139,"CreationDate":"2018-06-16T21:52:00.000","Title":"ModuleNotFoundError while package already installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My distribution is WinPython and I use Spyder as an IDLE, my python version is 3.6.5.\nAlthough I have so many modules (from the WinPython download) like pip, pandas, and numpy that work perfectly, I want now to download another package called Swampy.\nSo, I wrote to my IPython console: !pip install Swampy\nand it worked perfectly but when I wrote import Swampy the result was a ModuleNotFoundError!\nLastly, I have to mention that all the packages seem to be here C:\\Users\\MY_USERNAME\\Downloads\\WinPython\\python-3.6.5.amd64\\Lib\\site-packages","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":180,"Q_Id":50892066,"Users Score":1,"Answer":"I realized that all this time I was writing the name of the package wrong! Although I installed it as Swampy it only works if you write import swampy.\nOh god! I suck...\nAnyway, thank you all for your valuable time!","Q_Score":1,"Tags":"python,python-import","A_Id":50895161,"CreationDate":"2018-06-16T21:52:00.000","Title":"ModuleNotFoundError while package already installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sorry if this question is too stupid but I can't find an answer to it.\nI'm a beginner in terms of databases so I'm taking a course in Udacity. In the course, they tell us to install Vagrant and VirtualBox in order to run an ubuntu virtual machine to make the exercises of the course. The problem is that my pc is not working properly with that virtual machine running, so I decided not to virtualize and do the stuff in my \"normal\" programming environment (in the course we use flask, sqlite and sqlalchemy in order to create a website using a database, and in the next lesson they teach to build a web server that uses our database). Somewhere on the internet I read about virtual machines being useful to work in your computer without messing our computer's configuration up. My question is, can this happen? Or what does it mean to \"mess the configuration up\"? Is it possible to make an important mistake that will make me wish I had virtualized?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":50892275,"Users Score":0,"Answer":"It shouldn\u2019t mess any configuration in your PC. The whole point of virtualizing your programming environment is for security reasons, or because developing is easier on a Linux machine. If you\u2019re going to do sql exercises, the worst you can possibly do is mess the database.","Q_Score":0,"Tags":"python,database,sqlite,sqlalchemy,virtualization","A_Id":50892290,"CreationDate":"2018-06-16T22:29:00.000","Title":"Can something go wrong if I choose not to virtualize even though I was told to do it?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sorry if this question is too stupid but I can't find an answer to it.\nI'm a beginner in terms of databases so I'm taking a course in Udacity. In the course, they tell us to install Vagrant and VirtualBox in order to run an ubuntu virtual machine to make the exercises of the course. The problem is that my pc is not working properly with that virtual machine running, so I decided not to virtualize and do the stuff in my \"normal\" programming environment (in the course we use flask, sqlite and sqlalchemy in order to create a website using a database, and in the next lesson they teach to build a web server that uses our database). Somewhere on the internet I read about virtual machines being useful to work in your computer without messing our computer's configuration up. My question is, can this happen? Or what does it mean to \"mess the configuration up\"? Is it possible to make an important mistake that will make me wish I had virtualized?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":50892275,"Users Score":0,"Answer":"I don\u2019t think so. \nVM is useful here in two ways: first, it teaches you to work with DB as with remote server, like in real world. \nSecond: it prevents your main OS from junking up. It\u2019s not a big problem now, but windows can slow down due to many applications leaving junk in registry or whatever... I think it was mostly dealt with in win7, but was on Mac by that time.\nYou are probably fine, just don\u2019t use shutil.rmtree() on C:\\ ;)","Q_Score":0,"Tags":"python,database,sqlite,sqlalchemy,virtualization","A_Id":50892318,"CreationDate":"2018-06-16T22:29:00.000","Title":"Can something go wrong if I choose not to virtualize even though I was told to do it?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a class which parses a LOT of strings. There are 6 main variables being written into by 6 threads. Total character count of all strings together will cross 500,000 characters.\nEach thread works independently, ie, all of their strings does not collide with or are referenced by other strings. Meaning all threads work exclusive of each other regarding inputs and when outputting, they only write to their variable in the class.\nShould I implement a lock mechanism in the class during writing into those variables?\nEDIT1: Completed the threading. However, to compare speed of execution, I ran all concurrently too. I found it takes 1.44 seconds when run sequentially and takes 2.33 seconds when threaded. What am i doing wrong?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1029,"Q_Id":50893772,"Users Score":0,"Answer":"If the memory accessed by each thread is independent then you don't need any synchronization. If you plan on accessing these results from a main thread afterwards you need some synchronization at the end, but waiting for the worker threads to finish should be enough.\nThat's the general answer. Python's threading is limited due to the GIL, so you probably don't need anything at all. You won't see the speedup you expect either.","Q_Score":0,"Tags":"python,multithreading,thread-safety,locking,python-multithreading","A_Id":50893827,"CreationDate":"2018-06-17T04:45:00.000","Title":"Should I use a lock to write to class variables (during threading) even if each variable is not accessed\/written into by other threads?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am programming python 3 with Microsoft Code.\nWhen I press \"F5\" to start the programm I always get a menu with the following selection:\n\nPython\nPython Experimental\nMore\nto select the execution environment.\n\nHowever, I directly want standard python to be run, when pressing F5.\nI have googled a lot and already checked the configuration of Microsoft Code (there is only one python installed and selected) but did not find a switch to switch \"Experimental\" off.\nMany thanks for your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":50895399,"Users Score":0,"Answer":"Happened to me once. Seems like the Python Debug Configurations didnt load correctly.\nAfter reselecting my Interpreter I was able to select the Debug Configuration \"Python: Current File\" again and run it without prompting me to select a Config.","Q_Score":2,"Tags":"python,visual-studio-code","A_Id":51199579,"CreationDate":"2018-06-17T09:34:00.000","Title":"Python with Visual Studio Code - How to deactive \"Python Experimental\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Briefly speaking, I want to install rpy2 to connect python seamlessly with R. I have already installed the python 3 in anaconda and installed the system R with Rstudio and both of them work properly in general. Now I want to setup the rpy2 to connect them together, however, when I type conda install rpy2 in terminal (I'm a Mac OSX user), it will install the r-base within the anaconda which is not what I intend to do. I wonder whether it's feasible that it wouldn't install this r-base, but integrates the anaconda python with the system R instead as I've already had all the needed packages installed in this version of R(studio).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":417,"Q_Id":50897395,"Users Score":0,"Answer":"If the R installation you wish to use is the first one found through the environment variable PATH, just use python -m pip install rpy2 to install.","Q_Score":1,"Tags":"python,r,anaconda,rstudio,rpy2","A_Id":50897778,"CreationDate":"2018-06-17T14:03:00.000","Title":"Is it possible to set up the rpy2 with system R","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a virtual environment in my new directory with virtualenv env and then in Windows Git Bash ran env\/Scripts\/activate, which seemed to work. I didn't notice my virtualenv being displayed in parens at the beginning of the line (question1: can I set it up to work like that?), so to check if it was indeed activated I ran pip -V which gave me:\npip 9.0.1 from c:\\tools\\python2\\lib\\site-packages (python 2.7)\nShouldn't that be giving the directory of my virtualenv rather than site-packages? I also ran pip list and it gave me a list of installs that I had (naughtily) installed globally for a different project. So I can only assume my virtualenv did not activate and I don't know why that is.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4617,"Q_Id":50902497,"Users Score":2,"Answer":"Your suspicions are correct. Try source Scripts\/activate. What you did will run the command in a new and temporary shell instance.","Q_Score":3,"Tags":"python,virtualenv,git-bash","A_Id":50902578,"CreationDate":"2018-06-18T03:56:00.000","Title":"How to tell if virtualenv is activated in Windows Git Bash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am a python newbie  and i have a controler that get Post requests.\nI try to print to log file the request that it receive, i am able to print the body but how can i extract all the request include the headers?\nI am using request.POST.get() to get the body\/data from the request.\nThanks","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":264,"Q_Id":50903244,"Users Score":-1,"Answer":"request.POST should give you the POST body if it is get use request.GET\nif the request body is json use request.data","Q_Score":0,"Tags":"python,django","A_Id":50903304,"CreationDate":"2018-06-18T05:46:00.000","Title":"How to print all recieved post request include headers in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In feature extraction and detection using SIFT, I could extract features from 2 image. But I have 400 frames in video and want to have features from all 400 images in python. Can someone help me out with this?\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":520,"Q_Id":50904849,"Users Score":0,"Answer":"Key-points extracted from SIFT describe numerous features. If you wish to compare all 400 frames from a video to an image that you have, you will have to make a loop over your process and run SIFT iteratively. This will be computationally expensive.\nOne method to make this fast would be to read all key-points of these 400 frames and store them into a file so that you don't have to detect them each time you want to compare them with a test image.\nThis is what I've made from the question that you've asked.","Q_Score":0,"Tags":"python-3.x,image-processing","A_Id":50905356,"CreationDate":"2018-06-18T07:48:00.000","Title":"Feature extraction from multiple images in python using SIFT","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create an Amazon RDS database from a snapshot but I'm getting this error:\n\nbotocore.errorfactory.KMSKeyNotAccessibleFault: An error occurred (KMSKeyNotAccessibleFault) when calling the RestoreDBInstanceFromDBSnapshot operation: The specified KMS key [arn:aws:kms:ap-southeast-2:ddddddddd] does not exist, is not enabled or you do not have permissions to access it.\n\nI am not sure which permissions are needed for my Jenkins job to run this task. Is it just a read-only IAM policy?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2132,"Q_Id":50905214,"Users Score":3,"Answer":"Go to IAM Console, choose Encryption Keys menu on the left side bar\nChoose the region from the drop down menu (just below the \"Create Key\" button)\nSearch for the the mentioned key and see if exists. \nIf it does not exist, you can never recover back the RDS instance from the snapshot.\nIf exists, \n\nSee whether the status is Enabled for the Key. If not, select the checkbox and Choose \"Actions -> Enable\"\nClick on it. Under \"Key Policy\" -> \"Key Users\", add your IAM user\nand you will be able to restore RDS instance from Snapshot.","Q_Score":2,"Tags":"python-3.x,amazon-web-services,amazon-rds,boto3","A_Id":50906398,"CreationDate":"2018-06-18T08:14:00.000","Title":"Python boto Amazon RDS error: KMSKeyNotAccessibleFault","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am having trouble adding conda to my environment variables on windows. I installed anaconda 3 though I didn't installed python, so neither pip or pip3 is working in my prompt. I viewed a few post online but I didn't find anything regarding how to add conda to my environment variables. \nI tried to create a PYTHONPATH variable which contained every single folder in Anaconda 3 though it didn't worked.\nMy anaconda prompt isn't working too. :(\nso...How do I add conda and pip to my environment variables or path ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20117,"Q_Id":50906037,"Users Score":0,"Answer":"Thanks guys for helping me out. I solved the problem reinstalling anaconda (several times :[ ), cleaning every log and resetting the path variables via set path= in the windows power shell (since I got some problems reinstalling anaconda adding the folder to PATH[specifically \"unable to load menus\" or something like that])","Q_Score":2,"Tags":"python,path,environment-variables,anaconda","A_Id":50909686,"CreationDate":"2018-06-18T09:08:00.000","Title":"Add conda to my environment variables or path?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a code that will be implemented alongside my company's software. My code is written in Python and requires access to a data file (.ini format) that will be stored on the user's desktop, inside the software's shortcuts folder.\nThis being said, I want to be able to read\/write from that file, but I can't simply reference the desktop as C:\\USERS\\DESKTOP\\Parameters\\ParameterUpdate.ini, since the absolute path will be different across different systems.\nIs there a way to ensure that I am referencing whatever the desktop's absolute path is?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":93,"Q_Id":50909754,"Users Score":1,"Answer":"You can use something like os.path.join(os.path.expanduser('~'), 'Desktop', 'Parameters', 'ParameterUpdate.ini').","Q_Score":1,"Tags":"python,path","A_Id":50909947,"CreationDate":"2018-06-18T12:39:00.000","Title":"Referencing folder without absolute path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to set up a beta environment on Heroku for my Django-based project, but when I install I am getting:\n\nerror in cryptography setup command: Invalid environment marker:\n  python_version < '3'\n\nI've done some googling, and it is suggested that I upgrade setuptools, but I can't figure out how to do that.  (Putting setuptools in requirements.txt gives me a different error message.) \nSadly, I'm still on Python 2.7, if that matters.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":500,"Q_Id":50913601,"Users Score":0,"Answer":"The problem ended up being the Heroku \"buildpack\" that I was using.  I had been using the one from \"thenovices\" for a long time so that I could use numpy, scipy, etc.  \nSadly, that buildpack specifies an old version of setuptools and python, and those versions were not understanding some of the new instructions (python_version) in the newer setup files for cryptography.\nIf you're facing this problem, Heroku's advice is to move to Docker-based Heroku, rather than \"traditional\" Heroku.","Q_Score":0,"Tags":"python,heroku","A_Id":51125635,"CreationDate":"2018-06-18T16:13:00.000","Title":"getting \"invalid environment marker\" when trying to install my python project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a large pretrained Word2Vec model in gensim from which I want to use the pretrained word vectors for an embedding layer in my Keras model. \nThe problem is that the embedding size is enormous and I don't need most of the word vectors (because I know which words can occure as Input). So I want to get rid of them to reduce the size of my embedding layer.\nIs there a way to just keep desired wordvectors (including the coresponding indices!), based on a whitelist of words?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2182,"Q_Id":50914729,"Users Score":0,"Answer":"There's no built-in feature that does exactly that, but it shouldn't require much code, and could be modeled on existing gensim code. A few possible alternative strategies:\n\nLoad the full vectors, then save in an easy-to-parse format - such as via .save_word2vec_format(..., binary=False). This format is nearly self-explanatory; write your own code to drop all lines from this file that aren't on your whitelist (being sure to update the leading line declaration of entry-count). The existing source code for load_word2vec_format() & save_word2vec_format() may be instructive. You'll then have a subset file. \nOr, pretend you were going to train a new Word2Vec model, using your corpus-of-interest (with just the interesting words). But, only create the model and do the build_vocab() step. Now, you have untrained model, with random vectors, but just the right vocabulary. Grab the model's wv property - a KeyedVectors instance with that right vocabulary. Then separately load the oversized vector-set, and for each word in the right-sized KeyedVectors, copy over the actual vector from the larger set. Then save the right-sized subset.\nOr, look at the (possibly-broken-since-gensim-3.4) method on Word2Vec intersect_word2vec_format(). It more-or-less tries to do what's described in (2) above: with an in-memory model that has the vocabulary you want, merge in just the overlapping words from another word2vec-format set on disk. It'll either work, or provide the template for what you'd want to do.","Q_Score":8,"Tags":"python,keras,word2vec,gensim,word-embedding","A_Id":50916669,"CreationDate":"2018-06-18T17:32:00.000","Title":"Gensim Word2Vec select minor set of word vectors from pretrained model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Not sure what happened but whenever I use ipython, hydrogen (atom) or jupyter notebook can't find any of the installed modules. I know I have pandas installed but the notebook says its not found.\nI should add that when I run the script normally (python script.py) it does import without any errors.\nSuggestions?\nThanks!","AnswerCount":8,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":43014,"Q_Id":50914761,"Users Score":0,"Answer":"I had the same issue with other packages (scikit-commpy and ModulationPy).\nimport <package_name> was working on a script.py but not on a notebook.ipynb\nWhat worked for me:\nto run !pip install <package_name> inside the notebook.\nYou only need to do it once\n(it will probably say \"dependencies already installed\" but afterwards it will solve the issue).\nwhat didn't work for me but might be helpful:\n\ncompare sys.version from both script.py and notebook.ipynb\ncall help('modules') on both and compare\n\nyou can also do help('modules <package_name>') for filtering the long list to your specific package.\n\n\nreinstalling any of the following packages:\n\ndefected package\nipython\nipykernel\n\n\non Pycharm: File > Invalidate caches","Q_Score":24,"Tags":"python,python-3.x,jupyter-notebook,atom-editor,hydrogen","A_Id":71033261,"CreationDate":"2018-06-18T17:35:00.000","Title":"Jupyter Notebook can't find modules for python 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Not sure what happened but whenever I use ipython, hydrogen (atom) or jupyter notebook can't find any of the installed modules. I know I have pandas installed but the notebook says its not found.\nI should add that when I run the script normally (python script.py) it does import without any errors.\nSuggestions?\nThanks!","AnswerCount":8,"Available Count":2,"Score":0.024994793,"is_accepted":false,"ViewCount":43014,"Q_Id":50914761,"Users Score":1,"Answer":"Issue seems to be resolved by running \npip3 install rather than pip install","Q_Score":24,"Tags":"python,python-3.x,jupyter-notebook,atom-editor,hydrogen","A_Id":50916186,"CreationDate":"2018-06-18T17:35:00.000","Title":"Jupyter Notebook can't find modules for python 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to have all cost and ressources used of each IAM users. \nUnfortunately, i can have only the cost of my master account. I know that i can create a organization and set OU and users AWS account to have a detail and record each events, but the ressources used by 'users' are used only for my application, i don't need to have real account, and i can't automatises all deployements if i must set password and credentials manually . \nOne solutions also is to create CloudTrail and Cloudwatch to record each events services but i found this 'too heavy' and i will need to calculate myself the cost because it only get the datas which are used. \nI would like to know if they are exists others systemes to do that in preference with boto3.\nThank you for your responses. \nHave a nice day\/night.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":123,"Q_Id":50918798,"Users Score":5,"Answer":"Costs are not easily associated back to \"users\".\nAWS resources are associated with an AWS Account. When a user creates a resource (eg an Amazon EC2 instance), IAM will confirm that they have permission to launch the resource, but the resource itself is not associated with the user who created it.\nYou would need to add tags to resources to have more fine-grained association of costs to people\/projects\/departments. These tags can be used in billing reports to provide cost breakdowns.","Q_Score":1,"Tags":"python-3.x,amazon-web-services,boto3","A_Id":50919163,"CreationDate":"2018-06-18T23:37:00.000","Title":"How to get a summary of ressources\/cost used per IAM users 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":"using windows10 python 2.7\nmy code for decryption\n\n\n    def decrypt(self, enc):\n            enc = b64decode(enc)\n            iv = enc[:16]\n            cipher = AES.new(self.key, AES.MODE_CBC, iv)\n            print cipher,\"======\"\n            dec = cipher.decrypt(enc[16:])\n            #print dec,\"========\",dec\n            unp = unpad(dec)\n            print unp,\"=========\",\"=fdkjfsdklfsdjndjdjk\"\n            decode = unp.decode('utf8')\n            #decode = unp.decode('utf8')\n            print decode\n            # unpad(cipher.decrypt(enc[16:])).decode('utf8')\n            return decode\n\n\nwhile decrypting the encrypted response cipher.decrypt(enc[16:]) line gives me below output. But actually It should be the XML format.\n\n )^\u00bb3(Fm\u2560\u00a1O\u00e5\u2524\u2556\u00a2iO\u00d1>s\u258cB\u00bf\u258c\u2565\u2265\u2510\u00c9j6\u256c\u2591\u00a2\u221a(\u00e5\u00a5  2?J\u2264\u00f4GOL\u2550\\\u00a5\u00b0t\u256c\u255a\u0393\u00dc\u2590\u255d\u03a6\u00f7\u2550AQw\u2265[&n\u03a3\u00b1\u0192\u2229(\u2569\u00fbGN~[3bgrHP\u00dc4%\u2556H\u2321\u2584w\u00c5|\u25a0\u00c7q\u2265\u00bd\u00f7\u03c3H\u00f1x\u00ecd\u00baw\u00eb\u00b1!\u2502\u2590\u00edW\u00c7\u00ff\u0398\u2566\u03c3\u2556\u00e8#X\u2593\u25242\u00ff       \u2518\u255f\u0192\u03a3\u00b0Y\u2591\u00e7N\u00df\u00e6\u00c5\u03b1b3f\u00ab\u2500O(Wo9\u2510A\u2555t\u00a3\u2567{K [X\u2534\u252c\u00dcH\u0398\u2320X4\u252c\u00c6\u2261~\u2560h3\u03b5\u2518\u03c3m\u00c9f\u00fa.F\u00fa\u255c\u20a7c!_\u2552\u2590w\u03b1\u00b2A\/\u2552|\u2500sY%=\u2310\u2592Y\u00f6\u2555[\u255e\u03b5\u2591::tA\u2534\u20a7\u00b5\u2264\u00b2\u2219C\u2500A\u2588\u20a7\u2555\u2567\u03c4\u2559x\u2264r\u0192\u00fa\u2591u\u00fa\u2588\u00e5\u252c-\u2564`\u2561f\u2555^\u221et\u03a6\u00bdq\u2557&\u256a\u2500\u2558\u00a5&\u2510\u03a3\u20a7\u258c(\u2559\u250cJ\u00fc\u00f1\u00c7\u00e4Q\u00a5\/*\u00f3\u2590H!C\u252c+\u03b4\u00e0\\Bah\u2558\u00e1\u00c6Xu\u2565C\u2588\u2502\u00bc)\u00eb\u2569\u2553*E(\u00f7\u00b7\u251c\u00e0\u221a\u00bf\u2568\u25671\u0398\u00b70\u2248\u00ba\u00b2\u2551\u00c5s\u252cxO\u00f2}a\u256a\u2554\u256bH\u00dcq\u252cgq\u00c5\u00d6\u23104~v\u2556\u00b79\u2565\u00dc$w\u00e7Z\u258c\u2557\u252c?\u00a0\/Zj12^}&t$F=SBKh\u00f6\u00e5\u03b5 \u00e8\u255do\u256a\u2588\u00ba8f\u00ec\u00ee\u00e9\u256b=\u00ab\u00b7gO:Z\u2562\u22612\u2554K\u00ab\u0398 u\u00e8\/\u2569\u00a0{\u2310\u00c5ww\u03b5^\u03b1\u253c\u00b5k4\u2518\u00d1\u2567:\u019216\u2551\u255e\u207fB\u00b0\u00a2\u00fcd\u00f3?eB\u253cP\u250cL_90]\\5W\u2565\u00b5A\u2310\n    #Mq\u2564\u00ec\u207f\u00b2\u00e7\u2265\u0398\u00b7\u2593F\u20a7\u2580)\u00a0\u00e7@\u00eb\u2552\u2556\u00e0s2\u2561}\u03c0L\u2555\u256860\u00e4\u250c\u00f96\u2592.rn\u2554j\u207fR\u00a2\u2219\u00b5I\u00eb\u00c9\u255d\u00b5\u00e8}c\u2248\u03c3\u00df_\u03b1\u00e4c\u00aa\/\u2564\"lK*\u2514qX2H \u00f6\u03c6q#\u00e2\u00bd\u00e6\u0398j\u00c4% \u00e96#\u00fcY\u2588\u2593aF\u00df\u03b1\u2588\u00f7I\u2551n+\u2321\u2584\u00c4!jT\u00c4\u221a\u2229yr\u00a5d\"\u255b\u00acz\u221a\u207f\u00b5\u00ba\u00bd\u00eaY\u207f\u03c0\u00ac2[\u2555\u00bf\u2261\u00ff \u2502Uv?{\u03c4\u00e6\u03c4\u00b0Q\u00dc\u00c4\u00b5\u2568\u00edkUF\u03c0\u255aB\u03c0\u00c6! Hi\u00e5\u0192\u2552\u00a3\u03b1\u00ec\u2265\u00c6\u03b5tr\u2588[\u2564\u00e0\u00c6\u2588o\u00ed\u03a9(\"\u2524\u255e\u00e5M\u00dc\u00f2\u255dD3\u256c\u00bfV\u03c4\u03a9r\u2593\u00dc\u00c6\u00ff$\u250c)\u2320\u2261\\~\u2569\u2580Rr\u2261y\u00a3\u20a7\u2264\u2551L>\u2559 \u2558\u00b5v9\u00ff\u00e6\u251c@B\u2261\u00b5\u00a3\u2555Ew\u2557y\u00fftXeY.\u03b1\u00d1s\u00fa\u00a0Y\u00b1\u00a3\u2229=yy\u00a5\u00f3\u00fc\u03a3\u00c6F\u2567\u2566\u00e1\u2500}      O\u0192\u2265-9[\u2264\u00a2f\u00fa\u03a3e3&\u00d6\u00ff\u2591\u00ec\u00e7\u00b7nt\u00c4O\n    l\u2219m\u00a5\\\u255e&K\u00ea\u00ebR\u00bbs\u2554E2\u2568\u00aa\u2502OV\u2265\u2591m\u2550\u256c2\u252c\u20a7\u00fa(\u00fb\u00f6z\u00a2\u00bc\u2563\\\u22645nq\u00f2+\u255d\u00b1\u00c4m{G\u03c3\u255dRO\u03c6N\u00b5\u00e0g\u255bRV\u2568;L\u03b4a ,\u00e9\/\u207fY\u255c|\u2524\u00f1\u2554\u00f7\u03c0v\u207f\u255eW\u2593\u03c0}R\u00e5#h$*\u03c0A\u00f2\u00bc2\u255dC\u00c5k*l\"h\u2555\u2265a\u00c6h\u00e6t)9\u2590\u2591\u255d.]B}-\u2562\u2514\u2229I\u03c3w\u252c\u255aD&5\u2261\u2592\u00b2`WJ\u2554\u256b\u2321K1\u2229        f\u00fa~A\u258cc\u2584m\u00d1\u2534?\u00f4Q\u2569\u0192\u207f|\u2568{\u00e7\u2592\u00b7\u0398B\u2561\u03a6\u03c4\u258c\u2320\u2500\u2558q?n\u207fC\/v>\u03c3\u00b0\u252c#'L\u250c 0K\u00e8\u00a3\n    \u2569[\u00c9rekx\u00abw\u00eb,\\\u00a5\u2500K\\a\u2561\u00b7\u2510PDIF\u2569l\u2564YH\u255eF$c6\u2248G\u00a1\u00dcc^r=pbi\u00b5\u03a6\u2518\u00b1\u00ff\u2593z\u03a6\u00bf0\u2591\u00ec\u2510\u00e17\u250co\u25a0\u00ab-\u207f#,\n\nWhile decoding i.e at line unp.decode('utf8') gives me the following error\n\n    Traceback (most recent call last):\n      File \"nic_dycrypt_encrypt.py\", line 99, in \n        print('Ciphertext:', AESCipher(key).decrypt(ciphertext))\n      File \"nic_dycrypt_encrypt.py\", line 86, in decrypt\n        decode = unp.decode('utf8').strip()\n      File \"C:\\Python27\\lib\\encodings\\utf_8.py\", line 16, in decode\n        return codecs.utf_8_decode(input, errors, True)\n    UnicodeDecodeError: 'utf8' codec can't decode byte 0xaf in position 3: invalid start byte\n\nPlease any one help me to know what is that format and why the error is coming and how to resolve","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":739,"Q_Id":50919256,"Users Score":0,"Answer":"Simply put not all bytes and\/or byte sequences map to unicode characters. In fact most byte sequences do not have a UTF-8 character mapping.\nThe common solution is to convert binary to an encoding that can handle all byte values, the most common are Base64 and Hexadecimal.","Q_Score":0,"Tags":"python-2.7","A_Id":50919371,"CreationDate":"2018-06-19T00:55:00.000","Title":"UnicodeDecodeError: 'utf8' codec can't decode byte 0xaf in position 3: invalid start byte in python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been implementing some deep nets in Keras, but have eventually gotten frustrated with some limitations (for example: setting floatx to float16 fails on batch normalization layers, and the only way to fix it is to actually edit the Keras source; implementing custom layers requires coding them in backend code, which destroys the ability to switch backends), there appear to be no parallel training mechanisms [unlike tf.Estimator], and even vanilla programs run 30% slower in Keras than in tf (if one is to trust the interwebs), and was grumbling about moving to tensorflow, but was pleased to discover that TensorFlow (especially if you use tf.layers stuff) is not actually any longer for anything imaginable you might want to do. Is this a failure of my imagination, or is tf.layers basically a backporting of Keras into core TensorFlow, and is there any actual use case for Keras?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":423,"Q_Id":50920425,"Users Score":3,"Answer":"Keras used to have an upper hand on TensorFlow in the past but ever since the author is now affiliated with Google all the features that made it attractive are being implemented into TensorFlow you can check version 1.8, like you rightfully pointed out tf.layers is one such example.","Q_Score":1,"Tags":"python,tensorflow,keras","A_Id":50926356,"CreationDate":"2018-06-19T03:56:00.000","Title":"Keras vs TensorFlow - does Keras have any actual benefits?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Have a linux setup, where I need 2 Python processes to use the same comport, how can I easily share that serial port resource between to separate processes?\nIts only the server program that need to open the serial port and then the client shall connect to server and use the same serial port.\nShall i go after socket or something else?\nAny point to code example will be appreciated.\nBr \nEsben","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":236,"Q_Id":50920990,"Users Score":0,"Answer":"My solution was to build a multiprocessing server handling the serial trafic, Then post message to and from the servers through a queue from my client programs.","Q_Score":0,"Tags":"python,linux,serial-port","A_Id":58409440,"CreationDate":"2018-06-19T05:09:00.000","Title":"How can i share a serialport between 2 different processes in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I use VGG-16 pre-trained model and fine-tune the last 3 FC layers. \nBut in my case, I only use 3 classes as my classification.\nI want to ask how to choose the perceptron of FC layers.\nShould I visualize the Conv5_3 layer, then making a decision?\nBTW, VGG-16 official model is 4096, 4096, 1000 perceptron in FC layers.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":50922606,"Users Score":0,"Answer":"The easiest way to adapt your network is to add another FC layer on top of the VGG (with weight kernel of size 1000x3).\nAlternatively, replace the last FC layer (of size 4096x1000) with an FC layer of size 4096x3.\nDon't forget to properly initialize your newly added layers.","Q_Score":0,"Tags":"python,tensorflow","A_Id":50923449,"CreationDate":"2018-06-19T07:17:00.000","Title":"How to choose number of perceptron in fine-tuning FC layer?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a bit confused regarding unittests. I have an embedded system I am testing from outside with Python.\nThe issue is that after each test is passed I need to reset the system state. However if a test fails it could leave the system in an arbitrary state I need to reset. After each test I go back to the initial state but if an assertion fails it will skip that part.\nTherefore, what's the proper way to handle this situation? Some ideas I have are:\n\nPut each test in a try, catch, finally but that doesn't seem so right (unittest already handles test exceptions).\nPut each test in a different class and invoke tearDown() method at the end of it\nCall initSystemState() at the beggining of each test to go back to init state (but it is slower than resetting only what needs to be reset at the end of the test)\n\nAny suggestions? Ideally if I have testSpeed() test there should be a testSpeedOnStop() function to be called at the end. Perhaps unittest is not the right tool for this job also as all the functions have side-effects and are working together so maybe I should lean more towards integration tests libraries which I haven't explored.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":50923683,"Users Score":0,"Answer":"Setting state is done in the setUp(self) method of the test class.\nThis method is automatically called prior to each test and provides a fresh state for each instance of the tests.\nAfter each test, the tearDown method is run to possibly clean up remnants of failed tests.\nYou can write a setUp \/ tearDowm to be executed befora and after all tests; more elaborate tests may require stubbing or mocking objects to be build.","Q_Score":0,"Tags":"python,unit-testing,integration-testing,python-unittest","A_Id":50923716,"CreationDate":"2018-06-19T08:17:00.000","Title":"Execute system state reset upon unittest assertation fail","Data Science and Machine Learning":0,"Database and SQL":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 flask RESTapi and i am using postman to make http post requests to my api , i want to use the werkzeug debugger , but postman wont allow me to put in the debugging pin and debug the code from postman , what can i do ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":331,"Q_Id":50926542,"Users Score":0,"Answer":"Never needed any debugger for postman. This is not the tool you need the long blanket of code for one endpoint to test.\nIt gives a good option - console. I have never experienced any trouble this simple element didn't help me so far.","Q_Score":2,"Tags":"python-3.x,postman,flask-restful,werkzeug","A_Id":50954032,"CreationDate":"2018-06-19T10:47:00.000","Title":"how to use the Werkzeug debugger in postman?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"On my dev machine I installed and configured celery within a django app and it works without issues using python3.5 and the django dev webserver.\nWhen I deploy that app to my production server I get an error \"no module named celery\". On the production server runs python3.6 with apache2 and mod_wsgi.\nOn both machines I use django-1.11 and celery-4.1.0 within a virtualenv. I suspect that it's either an issue with python3.6 or with mod_wsgi.\nI haven't found any real solution to my issue so I'm trying my luck here :)\nCheers\nMichael","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":197,"Q_Id":50929437,"Users Score":0,"Answer":"So, I figured it out. Apparently my virtualenv was pointing to another directory and not to the one apache was using. No idea how this happend. Anyway, after removing and recreating the virtualenv it worked.\nThanks for your help!","Q_Score":0,"Tags":"python,django,celery","A_Id":50931395,"CreationDate":"2018-06-19T13:14:00.000","Title":"No module named celery using python 3.6 and apache2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"On my dev machine I installed and configured celery within a django app and it works without issues using python3.5 and the django dev webserver.\nWhen I deploy that app to my production server I get an error \"no module named celery\". On the production server runs python3.6 with apache2 and mod_wsgi.\nOn both machines I use django-1.11 and celery-4.1.0 within a virtualenv. I suspect that it's either an issue with python3.6 or with mod_wsgi.\nI haven't found any real solution to my issue so I'm trying my luck here :)\nCheers\nMichael","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":197,"Q_Id":50929437,"Users Score":0,"Answer":"As a sanity check, make sure the celery is actually installed in the virtual environment you use.\nIf you are using virtual environment with mod_wsgi, you may need to setup python-home=<path_to_your_virtual_env> in the WSGIDaemonProcess directive. \n\nExample:\n\nWSGIDaemonProcess django python-path=\/opt\/portal\/src\/ python-home=\/opt\/venv\/django home=\/opt\/portal\/ \n\nYou can use the comma-separated list if more than one directory is required in python-path","Q_Score":0,"Tags":"python,django,celery","A_Id":50930345,"CreationDate":"2018-06-19T13:14:00.000","Title":"No module named celery using python 3.6 and apache2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm new to coding and I have been learning it on Jupyter. I have anaconda, Sublime Text 3, and the numpy package installed on my Mac. \nOn Jupyter, we would import numpy by simply typing\n    import numpy as np\nHowever, this doesnt seem to work on Sublime as I get the error ModuleNotFoundError: No module named 'numpy'\nI would appreciate it if someone could guide me on how to get this working. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1514,"Q_Id":50929439,"Users Score":1,"Answer":"If you have Annaconda, install Spyder. \nIf you continue to have this problem, you could check all the lib install from anaconda.\nI suggest you to install nmpy from anaconda.","Q_Score":1,"Tags":"python,numpy,sublimetext3","A_Id":50929501,"CreationDate":"2018-06-19T13:14:00.000","Title":"Importing Numpy into Sublime Text 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is best practice for incorporating git repositories into the own project which do not contain a setup.py? There are several ways that I could imagine, but it doesn't seem clear which is best.\n\nCopy the relevant code and include it into the own project \npro:\n\nOnly use the relevant code, \n\ncon: \n\ngit repo might be updated\nneed to do this for every project again\nfeels like stealing\n\nCloning the repository and writing a setup.py and install it with pip\npro:\n\neasy\npackage can be updated\ncan use package like any normal pip package\n\ncon: \n\nfeels weird\n\nClone the repository and add the path to the project's search path \npro:\n\neasy\npackage can be updated\n\ncon: \n\nneeding to adjust the search path also feels strange","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":50930336,"Users Score":1,"Answer":"In my opinion, you forgot the best option: Ask the original project maintainer to make the package available via pip. Since pip can install directly from git repositories this doesn't take more than a setup.py -- in particular, you don't need a PyPI account, you don't need to tag releases, etc.\nIf that's not possible then I would opt for your second option, i.e. provide my own setup.py file in a fork of the project. This makes incorporating upstream changes pretty easy (basically you simply git pull them from the upstream repo) and gives you all the benefits of package management (automatic installation, dependency management, etc.).","Q_Score":0,"Tags":"python,git,pip","A_Id":50930519,"CreationDate":"2018-06-19T14:00:00.000","Title":"Python: incorporate git repo in 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},{"Question":"I would like to know if there's a technique to simply undo a change that was done using Pandas. \nFor example, I did a string replacement on a few thousand rows of Pandas Dataframe, where, every occurrence of \"&\" in its string be replaced with \"and\". However after performing the replacement, I found out that I've made a mistake in the changes and would want to revert back to the Dataframe's most latest form before that string replacement was done.\nIs there a way to do this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4868,"Q_Id":50931697,"Users Score":0,"Answer":"Yes, there is a way to do this. If you're using the newest iteration of python and pandas you could do it this way:\ndf.replace(to_replace='and', value='&', inplace=true)\nThis is the way I learned it!","Q_Score":6,"Tags":"python,pandas","A_Id":64109376,"CreationDate":"2018-06-19T15:10:00.000","Title":"Undo a change that was performed using Pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know if there's a technique to simply undo a change that was done using Pandas. \nFor example, I did a string replacement on a few thousand rows of Pandas Dataframe, where, every occurrence of \"&\" in its string be replaced with \"and\". However after performing the replacement, I found out that I've made a mistake in the changes and would want to revert back to the Dataframe's most latest form before that string replacement was done.\nIs there a way to do this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4868,"Q_Id":50931697,"Users Score":0,"Answer":"If you have cells structured in step, and the mess is because of running a couple of cells that have affected the dataset, you can stop the kernel and run all the cells from the beginning.","Q_Score":6,"Tags":"python,pandas","A_Id":67360151,"CreationDate":"2018-06-19T15:10:00.000","Title":"Undo a change that was performed using Pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote an app to plot a graph from an input file when you drag and drop the file onto a gui interface. However after the execution of plt.show() in the program, the gui interface becomes inactve. \nUsing plt.draw() instead of plt.show() or using plt.ion() solves this issue, but then the python graph stop updating, ie. resizing\/ closing the graph doesn't work until the next time a file is dragged and dropped.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":50932413,"Users Score":0,"Answer":"Try to make two different files and put the plt.show() in the other one, to see if it works.","Q_Score":0,"Tags":"python,matplotlib","A_Id":50932563,"CreationDate":"2018-06-19T15:51:00.000","Title":"plt.show() stops gui interface from updating","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python 3.7 introduced the PYTHONUTF8 environment variable to enable UTF-8 encoding by default. How do I set this variable from within a Python program? (I can't find it in my operating system's list of environment variables.)","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":7077,"Q_Id":50933194,"Users Score":2,"Answer":"You can technically set it using os.environ[\"PYTHONUTF8\"] = \"on\" (the value doesn't matter), but this won't affect the running script. By the time you do it in a Python script, Python has already started and checked for this variable, didn't find it, and therefore isn't using UTF-8 encoding by default. It would affect any Python interpreter you launched from your script, though.\nThe point of the environment variable is to set it before you launch your Python script. You do this in the same way you would set any other environment variable. You don't mention what OS you're using, but on Linux, you generally add the appropriate command to ~\/.bash_profile. On Windows, you set them using a button on the Advanced page of the System Properties dialog.\nObviously you won't find this environment variable in your system's list of environment variables if you haven't set it yet.","Q_Score":5,"Tags":"python,python-3.x,utf-8","A_Id":50933384,"CreationDate":"2018-06-19T16:39:00.000","Title":"How do I set the PYTHONUTF8 environment variable to enable UTF-8 encoding by default in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given I trained a simple neural network using Tensorflow and Python on my laptop and I want to use this model on my phone in C++ app.\nIs there any compatibility format I can use? What is the minimal framework to run neural networks (not to train)?\nUDP. I'm also interested in Tensorflow to NOT-Tensorflow compatibility. Do I need to build it up from scratch or there're any best practices?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":117,"Q_Id":50933736,"Users Score":1,"Answer":"Technically you don't need a framework at all. A conventional fully connected neural network is simple enough that you can implement it in straight C++. It's about 100 lines of code for the matrix multiplication and a dozen or so for the non-linear activation function. \nThe biggest part is figuring out how to parse a serialized Tensorflow model, especially given that there are quite a few ways to do so. You probably will want to freeze your TensorFlow model; this inserts the weights from the latest training into the model.","Q_Score":0,"Tags":"python,c++,tensorflow,neural-network","A_Id":50947050,"CreationDate":"2018-06-19T17:17:00.000","Title":"How to use trained neural network in different platform\/technology?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script called \"RiskTemplate.py\" which generates a pandas dataframe consisting of 156 columns.  I created two additional columns which gives me a total count of 158 columns.  However, when I run this \"RiskTemplate.py\" script in another script using the below code, the dataframe only pulls the original 156 columns I had before the two additional columns were added.\nexec(open(\"RiskTemplate.py\").read()) \nhow can I get the reference script to pull in the revised dataframe from the underlying script \"RiskTemplate.py\"?\nhere are the lines creating the two additional dataframe columns, they work as intended when I run it directly in the \"RiskTemplate.py\" script.  The original dataframe is pulling from SQL via df = pd.read_sql(query,connection)\ndf['LMV % of NAV'] = df['longmv']\/df['End of Month NAV']*100\ndf['SMV % of NAV'] = df['shortmv']\/df['End of Month NAV']*100","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":21,"Q_Id":50934946,"Users Score":1,"Answer":"I figured it out, sorry for the confusion.  I did not save the risktemplate that I updated the dataframe to in the same folder that the other reference script was looking at!  Newbie!","Q_Score":0,"Tags":"python,dataframe,reference","A_Id":50935236,"CreationDate":"2018-06-19T18:36:00.000","Title":"dataframe from underlying script not updating","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to accept only those strings having the pattern 'wild.flower', 'pink.flower',...i.e any word preceding '.flower', but the word should not contain dot. For example, \"pink.blue.flower\" is unacceptable. Can anyone help how to do this in python using regex?","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":1085,"Q_Id":50939145,"Users Score":2,"Answer":"You are looking for \"^\\w+\\.flower$\".","Q_Score":0,"Tags":"python,regex","A_Id":50939346,"CreationDate":"2018-06-20T01:59:00.000","Title":"Python regex to match words not having dot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to accept only those strings having the pattern 'wild.flower', 'pink.flower',...i.e any word preceding '.flower', but the word should not contain dot. For example, \"pink.blue.flower\" is unacceptable. Can anyone help how to do this in python using regex?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1085,"Q_Id":50939145,"Users Score":0,"Answer":"Your case of pink.blue.flower is unclear. There are 2 possibilities:\n\nMatch only blue (cut off preceding dot and what was before).\nReject this case altogether (you want to match a word preceding .flower\nonly if it is not preceded with a dot).\n\nIn the first case accept other answers.\nBut if you want the second solution, use: \\b(?<!\\.)[a-z]+(?=\\.flower).\nDescription:\n\n\\b - Start from a word boundary (but it allows the \"after a dot\" case).\n(?<!\\.) - Negative lookbehind - exclude the \"after a dot\" case.\n[a-z]+ - Match a sequence of letters.\n(?=\\.flower) - Positive lookahead for .flower.\n\nI assumed that you have only lower case letters, but if it is not the case,\nthen add i (case insensitive) option.\nAnother remark: Other answers include \\w, which matches also digits and\n_ or even [^\\.] - any char other than a dot (including e.g. \\n).\nAre you happy with that? If you aren't, change to [a-z] (again, maybe\nwith i option).","Q_Score":0,"Tags":"python,regex","A_Id":50941395,"CreationDate":"2018-06-20T01:59:00.000","Title":"Python regex to match words not having dot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to call an external program in Linux and also pass some arguments to it?\nFor example I want to open 'nedit' in Linux and pass some text there..\nIs it possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":50939677,"Users Score":0,"Answer":"import os\ncommand = r'...\/...externalProgram'\nos.system(command)\nor \nimport subprocess\ncommand = r'...\/...externalProgram'\nsubprocess.run(command)","Q_Score":0,"Tags":"python-3.x,python-2.7","A_Id":50944284,"CreationDate":"2018-06-20T03:18:00.000","Title":"Calling external programs using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"import fibo\nImportError: No module named fibo\nfibo path location\nLocation: \/home\/mydirectory\/.local\/lib\/python2.7\/site-packages","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":118,"Q_Id":50940051,"Users Score":1,"Answer":"It is import Fibo not import fibo","Q_Score":2,"Tags":"python","A_Id":50940125,"CreationDate":"2018-06-20T04:04:00.000","Title":"using pip i install packages when i try to import the packages it shows some error ImportError no module names \"package name\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I say to dataframes.\ndf_A has columns A__a, B__b, C. (shape 5,3)\ndf_B has columns A_a, B_b, D. (shape 4,3)\nHow can I unify them (without having to iterate over all columns) to get one df with columns A,B ? (shape 9,2) - meaning A__a and A_a should be unified to the same column.\nI need to use merge with applying the function lambda x: x.replace(\"_\",\"\"). Is it possible?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":200,"Q_Id":50941528,"Users Score":0,"Answer":"A simple concatenation will do \npd.concat([df_A, df_B], join='outer')[['A', 'B']].copy().\nor\n'pd.concat([df_A, df_B], join='inner')","Q_Score":0,"Tags":"python-3.x,pandas,dataframe,merge,concat","A_Id":50941849,"CreationDate":"2018-06-20T06:23:00.000","Title":"Pandas dataframe merge by function on column names","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to reproduce the results of someone else's Python code for a project. I have the entire setup - conda on my machine, the virtual environment .yml file, the relevant packages, and the data. \nHowever, the code relies on one package from the conda repo that is only available for Linux, and not MacOS. I'm confused and I'm looking for any ways by which I could still use this package on my Mac. Googling doesn't seem to help. The package does have a gitlab page with the code given there, but I don't know how to use it. Any advice\/help would be appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":256,"Q_Id":50942277,"Users Score":0,"Answer":"I suggest you to try to install it using pip \/ pip3.  \nCreate your conda environment, here's a random example:\nconda -create -n ENVIRONMENTNAME python=3.6 numpy pandas\nand then...\nIf you are using Python2:\npip install tfbio\nIf you are using Pyton3:\npip3 install tfbio","Q_Score":0,"Tags":"python,package,anaconda,conda","A_Id":50942389,"CreationDate":"2018-06-20T07:09:00.000","Title":"Conda package unavailable for my OS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I am new to Python (and programming in general) and I am trying to install it on my Mac. Forgive me if I might ask silly questions.\nI currently have Python 3.6 and django 2.0 installed with it\n- I just installed virtualenv and pipenv which I don't get the difference but my terminal says that those scripts are not on PATH. How do I add those directories to the PATH and how can I check that they are on the right path?\nDo I need something more before starting to code?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1786,"Q_Id":50943130,"Users Score":1,"Answer":"You need to add those directories to your PATH variable. Thus you can use them on shell without writing directories all the time.\necho 'export PATH=YOUR_VIRENV_PATH:$PATH' >> ~\/.profile","Q_Score":0,"Tags":"python,django,path,installation,virtualenv","A_Id":50943712,"CreationDate":"2018-06-20T07:57:00.000","Title":"Scripts for Python are not on PATH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm developing a python project with multiple files, it's annoying that I have to select the file where main is described and called before click run because if not Spyder3(Anaconda) runs the current selected file.\nHow can I do to run my project from main() in mainPrjPy.py independent if the file is opened and selected?\nThanks\nEDIT: I want to explain that I'm using Spyder as Matlab substitute for Physics and math simulation for electronic design, this project would grow with different people generating different algorithms and data processor.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2247,"Q_Id":50943962,"Users Score":3,"Answer":"(Spyder maintainer here) We don't have this functionality at the moment (November 2019), sorry.","Q_Score":5,"Tags":"python,anaconda,project,spyder","A_Id":50955461,"CreationDate":"2018-06-20T08:45:00.000","Title":"How to always run a main file in Spyder Project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing a python project with multiple files, it's annoying that I have to select the file where main is described and called before click run because if not Spyder3(Anaconda) runs the current selected file.\nHow can I do to run my project from main() in mainPrjPy.py independent if the file is opened and selected?\nThanks\nEDIT: I want to explain that I'm using Spyder as Matlab substitute for Physics and math simulation for electronic design, this project would grow with different people generating different algorithms and data processor.","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":2247,"Q_Id":50943962,"Users Score":4,"Answer":"Found a way to do this:\nUse \"Run Again Last file\" Shortcut key F6 on windows.\nIt's working fine on Spyder 3.3.6","Q_Score":5,"Tags":"python,anaconda,project,spyder","A_Id":61999875,"CreationDate":"2018-06-20T08:45:00.000","Title":"How to always run a main file in Spyder Project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need your help for installing Shapely. The project where I work is on PyCharm and I need to install Shapely to compile the project:\n\nfrom shapely.geometry import Point, Polygon, MultiPolygon, asShape\n\nI've tried to install it from the interpretor (Settings > Interpretor > +) but it says me that\n\n\"WindowsError: [Error 126] The specified module could not be found\". \n\nSo I decided to install it from the command line. I think that I've Python 2.7 and Python 3.5 installed on my Windows 10 laptop (Python --version returns Python 2.7.12 and python3 --version returns Python 3.5.2). I executed the following line:\n\nimport pip._internal; print(pip._internal.pep425tags.get_supported())\n  [('cp27', 'cp27m', 'win_amd64'), ('cp27', 'none', 'win_amd64'),...]\n\nWhen I run from my Download folder (where the .whl is)\n\npip install Shapely-1.6.4.post1-cp27-cp27m-win_amd64.whl \n\nI have the following message error:\n\nShapely-1.6.4.post1-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform.\n\nI have Python 2.7 (cp27) and my pip supports win_amd64. I don't really know what I can do now.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":2385,"Q_Id":50944006,"Users Score":3,"Answer":"Try using conda install shapely, that helps avoid breaking your packages as well.","Q_Score":3,"Tags":"python,pycharm,shapely","A_Id":55845164,"CreationDate":"2018-06-20T08:48:00.000","Title":"Install Shapely on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a process that updates some entries in my mongo db using Pymongo. I have another process who does polling on these entries (using 'find' evrey minutes) to see if the other process is done. \nI noticed that after about 30-40 minutes I get an empty cursor even though these entries are still in the database. \nAt first I thought it happens due to changing these entries but then I run a process that just use the same query once every minute and I saw the same phenomena: After 30-40 minutes I get no results.\nI noticed that if I wait 2-3 minutes I get the results I am requesting.\nI tried to use the explain function but couldn't find anything helpful there.\nDid you ever see something similar? If so what can I do?\nIs there a way to tell that the cursor is empty? Is the rate limit configurable?\nthank you in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":149,"Q_Id":50944128,"Users Score":0,"Answer":"Apparently it was due to high CPU in mongo. \nThe database was synced with another one once every hour and during that time the queries returned empty results. \nWhen we scheduled the sync to happen only once a day we stopped seeing this problem (we also added a retry mechanism to avoid error on the sync time. However, this retry will be helpful only when you know for sure that the query should not return an empty cursor).","Q_Score":1,"Tags":"python,mongodb,pymongo","A_Id":51122090,"CreationDate":"2018-06-20T08:54:00.000","Title":"MongoDB query returns no results after a while","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to set up a virtual environment for a Django project, using Python 2.7. Both Python 2.7 and 3.6 are installed on my Mac.\nI run the command, specifying the path to Python 2.7 virtualenv --python=\/usr\/bin\/python2.7 venv and everything seems to work fine. However, when I run venv source\/bin\/activate it tells me venv: command not found.\nSomething is broken. I have read similar answers on Stack Overflow but nothing seems to be working. I have installed and uninstalled virtualenv with pip, tried running with superuser etc.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":482,"Q_Id":50946055,"Users Score":1,"Answer":"I guess you need source venv\/bin\/activate. source is a command, venv is the directory your virtualenv is located in.","Q_Score":0,"Tags":"python,django,virtualenv","A_Id":50946114,"CreationDate":"2018-06-20T10:29:00.000","Title":"Cannot execute virtualenv commands when using Python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have to write automation scripts using python and Robot framework. I have installed python, Robotframework, RIDE, wxpython. I have installed sikuli library but when I import it in my project, library is not imported. I have tried 'Import Library Spec XML'. My question is from where do I import this .xml or how do I create it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1441,"Q_Id":50949412,"Users Score":0,"Answer":"First check whether Sikuli is installed in python directory's \\Lib\\site-packages.\nRobot test should contain as below:\n* Settings *\nDocumentation     Sikuli Library Demo\nLibrary           SikuliLibrary    mode=NEW\n* Test Cases *\nSample_Sikuli_Test\nblabh blabh etc","Q_Score":0,"Tags":"python-2.7,robotframework,sikuli","A_Id":51034898,"CreationDate":"2018-06-20T13:27:00.000","Title":"Unable to import sikuli library in RIDE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How do I pass a complete folder from a master node to a worker node in spark?  \nI am using one master node and one worker node in a standalone cluster.  \nsc.addFile() passes a file from master to worker, but I want to pass a folder. \nThanks for the help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":50950170,"Users Score":0,"Answer":"There is another method available:\n\npublic void addFile(String path,\n                     boolean recursive)\nrecursive - if true, a directory can be given in path. Currently directories are only supported for Hadoop-supported filesystems.","Q_Score":0,"Tags":"python,apache-spark,pyspark,spark-streaming","A_Id":50951871,"CreationDate":"2018-06-20T14:05:00.000","Title":"How to pass folder from master node to worker node?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Python 3.6 and the \"Edit with IDLE\" option is missing. I have read numerous threads here on Stack Overflow and other websites about editing the registry, but nothing works. I have re-installed completely Python 3.6, also tried with Python 2.7 but I just don't get the option anymore. Any ideas?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4020,"Q_Id":50953131,"Users Score":6,"Answer":"Not strictly a programming question, but here are the registry keys that are responsible for the context menu entries on Python files in the Windows Explorer.\nI've made an \"Edit with IDLE\" sub-menu as there are multiple versions of Python installed on my machine.\n(Disclaimer: This is hand-crafted and will not be removed automatically when you uninstall Python. You have to clean it up yourself.)\n\nWindows Registry Editor Version 5.00\n\n[HKEY_CLASSES_ROOT\\Python.File\\shell\\editwithidle]\n\"MUIVerb\"=\"&Edit with IDLE\"\n\"Subcommands\"=\"\"\n\n[HKEY_CLASSES_ROOT\\Python.File\\shell\\editwithidle\\shell]\n\n; Python 2.7 -----------------------------------------------------------------------\n\n[HKEY_CLASSES_ROOT\\Python.File\\shell\\editwithidle\\shell\\edit27-32]\n\"MUIVerb\"=\"Edit with IDLE 2.7 (32-bit)\"\n\n[HKEY_CLASSES_ROOT\\Python.File\\shell\\editwithidle\\shell\\edit27-32\\command]\n@=\"\\\"C:\\\\Python27\\\\pythonw.exe\\\" \\\"C:\\\\Python27\\\\Lib\\\\idlelib\\\\idle.pyw\\\" -e \\\"%1\\\"\"\n\n; Python 3.6 -----------------------------------------------------------------------\n\n[HKEY_CLASSES_ROOT\\Python.File\\shell\\editwithidle\\shell\\edit36-32]\n\"MUIVerb\"=\"Edit with IDLE 3.6 (32-bit)\"\n\n[HKEY_CLASSES_ROOT\\Python.File\\shell\\editwithidle\\shell\\edit36-32\\command]\n@=\"\\\"C:\\\\Python36\\\\pythonw.exe\\\" -m idlelib \\\"%L\\\" %*\"\n\nOf course change the paths according to your installation directories. Add\/remove sections according to the installed Python versions. Then save as .reg file and import.\nAlso note that I've picked sensible subkey names like edit36-32. It's not strictly required, these only need to be unique, but if I'm creating registry entries, I like them to contain what they say. So, adapt those accordingly.\n\nIf you have only one Python version installed and never plan on getting a second installation, or if you like the menu entries in the top level instead of in a sub-menu:\n\nWindows Registry Editor Version 5.00\n\n[HKEY_CLASSES_ROOT\\Python.File\\shell\\editwithidle]\n@=\"Edit with IDLE 3.6 (32-bit)\"\n\n[HKEY_CLASSES_ROOT\\Python.File\\shell\\editwithidle\\command]\n@=\"\\\"C:\\\\Python36\\\\pythonw.exe\\\" -m idlelib \\\"%L\\\" %*\"","Q_Score":3,"Tags":"python","A_Id":50953378,"CreationDate":"2018-06-20T16:35:00.000","Title":"\"Edit with IDLE\" option missing Python 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Python 3.6 and the \"Edit with IDLE\" option is missing. I have read numerous threads here on Stack Overflow and other websites about editing the registry, but nothing works. I have re-installed completely Python 3.6, also tried with Python 2.7 but I just don't get the option anymore. Any ideas?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4020,"Q_Id":50953131,"Users Score":0,"Answer":"I had this problem before. Obviously reinstalling the system will work, but I am kidding, you don't have to do that. I will suggest one way which will work for sure as follows:\n1. open regedit\n2. under edit: search for \"python\"\n3. delete any term you find and search for next until all terms related to \"python\" is deleted.\n4. Reinstall python, any version you want, Done!!!","Q_Score":3,"Tags":"python","A_Id":52048959,"CreationDate":"2018-06-20T16:35:00.000","Title":"\"Edit with IDLE\" option missing Python 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just updated my nvidia GPU driver and got this error when i import tensorflow like that:\nimport tensorflow as tf\nConfig:\nUbuntu 16.04\nNVIDIA Corporation GM204M [GeForce GTX 970M]\n16GB RAM\ni7 6700HQ\nPython 3.5.2\nGCC 5.4.0\nCuda 9.0.176\nTensorflow 1.8\nCudNN 7\nThis error had no result on Google ...\nMaybe i should downgrade any version like my GPU driver or update CudNN ?\nThanks for any help","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":798,"Q_Id":50955454,"Users Score":0,"Answer":"Running\nexport LD_LIBRARY_PATH=\/usr\/lib\/nvidia-396 fixed it\nnow i have another error","Q_Score":0,"Tags":"python,tensorflow","A_Id":50955970,"CreationDate":"2018-06-20T19:12:00.000","Title":"ImportError: libnvidia-fatbinaryloader.so.396.24.02: cannot open shared object file: No such file or directory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"During one of my IDLE sessions, I cut a text selection and mistakenly closed the IDLE and I lost the cut text. Is there a way to get this text back, perhaps, if I can get the path of its clipboard?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":50957098,"Users Score":0,"Answer":"Unfortunately there is no method to do that but maybe view last restart shell option may help you.","Q_Score":0,"Tags":"python,ide","A_Id":50957160,"CreationDate":"2018-06-20T21:12:00.000","Title":"How to retrieve data from Python IDLE manually","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background\nI have two python projects. Project A and Project B.\nEach project has its own virtual environment and its own setup.py.\nBoth projects are not pure py files and has \"build\" process like building extensions, generate source etc.\nA is dependent on B (setup.py install_requires points on B).\nEach project is built and published\/distributed as a wheel to pypi on-premise repository.\npip install w\/wo -e (development mode) of project A, nicely installs project B into project A venv site-packages.\nSo far everything is working nicely and \"by the book\".\nNow, my story get complicated ...\nI would like to develop the two projects together without having to publish B in order A to consume it.\nAs example, I would like to:\n\nChange something in B.\nbuild B (setup.py build).\nNOT publish B as wheel to pypi.\nGoal - Project A will \"know\" the modified Project B. WITHOUT manually tweaking sys.path.\n\nI actually want the pip install -e of project A to install project B in development mode too.\nAfter some reading I understood (hopefully correctly) that one can define a \"distribution\" as a local source folder by --find-links flag. \nI defined project B root folder in --find-links.\nI tried it with (on project A setup.py folder):\n\npip install . -e --find-links = file:\/\/\/path\/to\/B\npip install . -e --find-links = git+file:\/\/path\/to\/B\n\nBoth did not work.\nBTW, Puting in the path to B wheel or egg of B,\nex: pip install . -e --find-links = file:\/\/\/path\/to\/B.whl\ndid work but this is not what I am looking for.\nHope you are still with me :-) (sorry for the tedious story)\nWhat am I missing?\nTx","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1887,"Q_Id":50957833,"Users Score":1,"Answer":"Let me try and restate the problem:\n\nYou work on two python packages, package A and package B. A depends on B.\nYou have chosen to develop these two packages in separate virtual environments.\nYou would like to make some local changes to package B and have package A use the modified version of package B.\n\nI apologize if I'm missing something here, but why not simply install both packages in the same virtual environment, which will make this problem go away?\nI.e. after creating your environment, you install package B in editable mode, followed by installing package A. Any changes in B will be picked up by A, no changes needed.","Q_Score":6,"Tags":"python,python-3.x,pip,setuptools,python-wheel","A_Id":56411443,"CreationDate":"2018-06-20T22:16:00.000","Title":"python pip - development mode with local dependencies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"My PC used to have an ealier version of Python, with a few .py scripts that was excecuted from a .bat file, and that .bat file was excecuted by another program.\nIt was time to learn Python, so I upgraded to the latest version, 3.6.5\nAt first I thought by installing the latest version, it will obveride the older versions. But found out when open the .py file with Edit with IDLE, the older version's number appeared in the window within the script.\nSo I uninstalled all older versions of Python, and re-installed again the latest version.\nBut now there is no Edit with IDLE on the context menu.\nI am vey new to Python, I had the initial scripts written by someone else long time ago using the older version of Python.\nSo How do I get the Edit with IDLE back on the context menu, is it something I have download ?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":50958962,"Users Score":0,"Answer":"Solution 1:\nConfigure environmental variable as sudonym's answer.\nSolution 2:\nUse a IDE as PyCharm or PyDev for coding.","Q_Score":0,"Tags":"python","A_Id":50959321,"CreationDate":"2018-06-21T01:01:00.000","Title":"Upgraded to latest Python on Win 7 Pro","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using the openpyxl library in Python and I'm trying to read in the value of a cell. The cells value is a date in the format MM\/DD\/YYYY. I would like for the value to be read into my script simply as a string (i.e. \"8\/6\/2014\"), but instead Python is somehow automatically reading it as a date object (Result is \"2014-08-06 00:00:00\") I don't know if this is something I need to fix in Excel or Python, but how do I get the string I'm looking for?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2412,"Q_Id":50959226,"Users Score":2,"Answer":"I would suggest changing it in your Excel if you want to preserve what is being read in by openpyxl. That said, when a cell has been formatted to a date in Excel, it becomes altered to fit a specified format so you've lost the initial string format in either case.\nFor example, let's say that the user enters the date 1\/1\/2018 into a cell that is formatted MM\/DD\/YYYY, Excel will change the data to 01\/01\/2018 and you will lose the original string that was entered.\nIf you only care to see data of the form MM\/DD\/YYYY, an alternate solution would be to cast the date with date_cell.strftime(\"%m\/%d\/%Y\")","Q_Score":1,"Tags":"python,excel,parsing,openpyxl","A_Id":50959375,"CreationDate":"2018-06-21T01:45:00.000","Title":"Python: Reading Excel and automatically turning a string into a Date object?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Python Django. I want to have a dynamic homepage. To be exact, I want to show different lists of books. For example one list might be best sellers and the other might be old books. These lists could be added in the future and I need them to be dynamic. Each list has a title and a queryset corresponding to books within that list. What is the best practice to handle this? What should be the properties of my List model?\nUpdate\nThe thing is that I do not want to change my front-end design each time that I might have a new list. These lists should be dynamic. For example, I might want to add a new list let's say top of 2018 and I know what the queryset is. I want to have a model such that every instance of that model corresponds to one of these lists and then the only thing I need to do is to create a new instance which has the queryset and title of the list. Then I want my website to return all of these lists when some one requests to get the home page.","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":39,"Q_Id":50959469,"Users Score":-1,"Answer":"Sorry not going to give you any code as I am not going to do the work for you. I would suggest you think about how you would want to design your database. \nFor example, do you want just one model that has all the books and than has a couple fields that indicate if it is a \"best seller\" or considered an \"old book\". \nSo for this case, to find \"old books\" you might want a timestamp field and then run a query that considers books passed a certain date to be old. That could be one list.\nFor best sellers, you could have a boolean field where you yourself indicate if that book is a best seller. Then you run a query filtering by that boolean field. That could be another list.\nSo just think of what are the exact lists you want, and how could you efficiently query for this for this.","Q_Score":0,"Tags":"python,django,design-patterns","A_Id":50959754,"CreationDate":"2018-06-21T02:24:00.000","Title":"Create a model filed which corresponds to a queryset","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using Python 3.6 through Spyder in Anaconda3.\nI have both the Anaconda installation and a \"clean\" python installation. \nBefore I installed the \"clean\" python, when I ran the Python -V command in cmd I got the following version description Python 3.6.5 :: Anaconda, Inc. Now when I run the command it just says Python 3.6.5. and the pip list is a whole lot shorter.\nWhen ever I open Spyder and find some package that I don't have... how would I go about installing said package?\nIf I just open cmd and write pip install ... it will install in the \"clean\" python directory.\nHow do I tell it to connect to Spyder?","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":128310,"Q_Id":50963625,"Users Score":3,"Answer":"I know it's a very late answer, but it may help other people.\nWhen you are working with anaconda you can use the basic environement or create a new one (it may be what's you call a \"clean\" python installation). To do that just do the following :\n\nOpen you anaconda navigator\nGo to \"Environments\"\nClick on the button create. Here by the way you can choose you python version\n\nThen to install your lib you can use your Anaconda GUI :\n\nDouble click on you environment\nOn the right side you have all you installed lib. In the list box select \"Not installed\"\nLook for your lib, check it and click on \"apply\" on the bottom right\n\nYou can also do it in your windows console (cmd), I prefer this way (more trust and you can see what's going on) :\n\nOpen you console\nconda activate yourEnvName\nconda install -n yourEnvName yourLib\nOnly if your conda install did not find your lib do pip install yourLib\nAt the end conda deactivate\n\n\/!\\ If you are using this way, close your Anaconda GUI while you are doing this\nIf you want you can find your environement(s) in (on Windows) C:\\Users\\XxUserNamexX\\AppData\\Local\\Continuum\\anaconda3\\envs. Each folder will contains the library for the named environement.\nHope it will be helpfull\nPS : Note that it is important to launch spyder through the Anaconda GUI if you want Spyder to find your lib","Q_Score":9,"Tags":"python,pip,anaconda,spyder","A_Id":55653655,"CreationDate":"2018-06-21T08:15:00.000","Title":"Pip install in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Python 3.6 through Spyder in Anaconda3.\nI have both the Anaconda installation and a \"clean\" python installation. \nBefore I installed the \"clean\" python, when I ran the Python -V command in cmd I got the following version description Python 3.6.5 :: Anaconda, Inc. Now when I run the command it just says Python 3.6.5. and the pip list is a whole lot shorter.\nWhen ever I open Spyder and find some package that I don't have... how would I go about installing said package?\nIf I just open cmd and write pip install ... it will install in the \"clean\" python directory.\nHow do I tell it to connect to Spyder?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":128310,"Q_Id":50963625,"Users Score":0,"Answer":"I installed spyder without anaconda on linux, and i was missing a module, all i did was installing pip on the linux terminal\nsudo apt install python3-pip    and then pip install \"the library name \" \nand it worked in spyder without any other modification.","Q_Score":9,"Tags":"python,pip,anaconda,spyder","A_Id":67743676,"CreationDate":"2018-06-21T08:15:00.000","Title":"Pip install in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Python 3.6 through Spyder in Anaconda3.\nI have both the Anaconda installation and a \"clean\" python installation. \nBefore I installed the \"clean\" python, when I ran the Python -V command in cmd I got the following version description Python 3.6.5 :: Anaconda, Inc. Now when I run the command it just says Python 3.6.5. and the pip list is a whole lot shorter.\nWhen ever I open Spyder and find some package that I don't have... how would I go about installing said package?\nIf I just open cmd and write pip install ... it will install in the \"clean\" python directory.\nHow do I tell it to connect to Spyder?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":128310,"Q_Id":50963625,"Users Score":0,"Answer":"There is a pip.exe included in the anaconda\/Spyder package which can cleanly add mopdules to Spyder. It's not installed in the windows path by default, probably so it' won't interfere with the \"normal\" pip in my \"normal\" python package.\nCheck \"\/c\/Users\/myname\/Anaconda3\/Scripts\/pip.exe\". It seems to depend on local DLLs - it did not work (just hung) until I cd'd into it's directory. Once there I used it to install pymongo in the usual way, and the pymongo package was picked up by Spyder.\nHope that helps...","Q_Score":9,"Tags":"python,pip,anaconda,spyder","A_Id":52729167,"CreationDate":"2018-06-21T08:15:00.000","Title":"Pip install in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given a model that has to classify 10 table-cloth items (spoons, forks, cups, plate etc,) and must be tested on an image of a table with all the table-cloth items in it (test_model_accuracy,) which is the best approach for training:\n\nA: Train the model on individual items then test on test_model_accuracy \nB: Train the model on an entire table with bounding boxes then test on test_model_accuracy\nC: Start with A, then B or vice-versa, then test on test_model_accuracy","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":140,"Q_Id":50964401,"Users Score":1,"Answer":"The strategy that you will choose depends mainly on the structure of the CNN that you are going to create.\nIf you train a model that is able to recognize if an image contains a spoon or a fork, you will not be able to test on a table with several table-cloth items (e.g. both a fork and a spoon) because the network will try to answer if in the image there is a spoon or a fork indeed.\nAnyway, it is still possible to train the network to classify several features (strategy \"A\") but in that case you need a model that is able to do Multi-label classification.\nFinally, I would suggest to go for the \"B\" strategy because, in my humble opinion, it fits good the application domain.\nHope this answer is clear and helpful!\nCheers.","Q_Score":2,"Tags":"python,machine-learning,classification,conv-neural-network","A_Id":50964829,"CreationDate":"2018-06-21T08:56:00.000","Title":"Image classification: Best approach to training the model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make a .txt file with all the python packages my environment is using, and include it in the git repo, so that anyone who needs to run the code, can just make an environment, install all the packages from the list and use it.\nI have two questions, first, how can I create that .txt files with all the installed packages? Second, how can someone with the .txt file install everything from it (using pip3?) in their fresh anaconda environment?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2499,"Q_Id":50964992,"Users Score":7,"Answer":"After activating your environment, you can do this:\npip freeze > requirements.txt\nAnd to install all these packages in a fresh environment:\npip install -r requirements.txt\nHope this helps!","Q_Score":3,"Tags":"python-3.x,pip,anaconda","A_Id":50965072,"CreationDate":"2018-06-21T09:24:00.000","Title":"Save all currently installed packages in anaconda to a file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In order to do proper CV it is advisable to use pipelines so that same transformations can be applied to each fold in the CV. I can define custom  transformations by using either sklearn.preprocessing.FunctionTrasformer or by subclassing sklearn.base.TransformerMixin. Which one is the recommended approach? Why?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":10493,"Q_Id":50965004,"Users Score":11,"Answer":"The key difference between FunctionTransformer and a subclass of TransformerMixin is that with the latter, you have the possibility that your custom transformer can learn by applying the fit method.\nE.g. the StandardScaler learns the means and standard deviations of the columns during the fit method, and in the transform method these attributes are used for transformation. This cannot be achieved by a simple FunctionTransformer, at least not in a canonical way as you have to pass the train set somehow.\nThis possibility to learn is in fact the reason to use custom transformers and pipelines - if you just apply an ordinary function by the usage of a FunctionTransformer, nothing is gained in the cross validation process. It makes no difference whether you transform before the cross validation once or in each step of the cross validation (except that the latter will take more time).","Q_Score":14,"Tags":"python,machine-learning,scikit-learn,cross-validation","A_Id":62225211,"CreationDate":"2018-06-21T09:24:00.000","Title":"Sklearn custom transformers: difference between using FunctionTransformer and subclassing TransformerMixin","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Docker image which runs a python subprocess, which is a node.js server exposing an end point \/check. The whole thing is put inside a Kubernetes pod and uses \/check as the readinessProbe endpoint.\nNow at some point, I want to close this endpoint or force-fail all the requests coming at it. Ideally, I want to do this via higher-level entities (i.e. Kubernetes lifecycle hooks) so as not to touch the lower-level implementation (such as opening a new endpoint \/stop that switch some boolean flag and force the \/check to fail)\nIs that possible at all? If not, what is the best alternative?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":50966018,"Users Score":1,"Answer":"Is that possible at all? If not, what is the best alternative?\n\nI believe there are a few:\n\nremote address filtering\nmagic headers\na formal proxy container\n\nremote address\nRequests to \/check coming from kubernetes will come from the Node's SDN IP address (so if a Node's SDN subnet is 10.10.5.0\/24, then requests will come from 10.10.5.1), so you could permit the checks from the .1 of the \/24 assigned to the Pod\nmagic headers\nThe httpGet readinessProbe allows httpHeaders: so you could turn on HTTP Basic auth for \/check and then put the - name: Authentication value: Basic xxyyzz== in the httpHeaders:\na formal proxy container\nAdd a 2nd container to the Pod that runs haproxy and filters \/check requests to return 401 or 404 or whatever you want. Since all containers in a Pod share the same networking namespace, configuring haproxy to speak to your node.js server will be super trivial, and your readinessProbe (as well as liveliness) can continue to use the URL because only kubernetes will have access to it by using the non-haproxy container's port. To complete that loop, point the Service at the haproxy container's port.","Q_Score":0,"Tags":"python,node.js,docker,kubernetes","A_Id":50981018,"CreationDate":"2018-06-21T10:15:00.000","Title":"Close off an endpoint on node.js server by via Kubernetes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I know that question is really simple, but I didn't find how to bypass the issue:\nI'm processing images, the output pixels are float32, and values are in range [-1; 1]. The thing is, when saving using openCV, all negative data and float values are lost (I only get images with 0 or 1 values)\nSo I need to convert those images to [0; 255] (Int8)\nI've tried\n\nimg * 255, but doing this does not help with negative values. \n(img + 1) * 255, I'm removing the negative values, but I'm creating\nan overflow\n\nIs there a (clean) way to do it ?\nI'm using Python35, OpenCV2 and Numpy, but I think it's more a math problem than a library thing","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30202,"Q_Id":50966204,"Users Score":12,"Answer":"As you have found, img * 255 gives you a resulting range of  [-255:255], and (img + 1) * 255 gives you a result of [0:510]. You're on the right track.\nWhat you need is either: int((img + 1) * 255 \/ 2) or round((img + 1) * 255 \/ 2). This shifts the input from [-1:1] to [0:2] then multiplies by 127.5 to get [0.0:255.0]. \nUsing int() will actually result in [0:254]","Q_Score":11,"Tags":"python,numpy,opencv","A_Id":50966711,"CreationDate":"2018-06-21T10:25:00.000","Title":"convert images from [-1; 1] to [0; 255]","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"But when i run command sudo apt-get install python3-pip. It is installed but inot as python3.6. It is installed in python3.5.I have also specified the version in command i.e sudo apt-get install python3.6-pip.But it gives me an error.\nReading package lists... Done\nBuilding dependency tree\nReading state information... Done\nE: Unable to locate package python3.6-pip\nE: Couldn't find any package by glob 'python3.6-pip'\nE: Couldn't find any package by regex 'python3.6-pip'","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3123,"Q_Id":50966768,"Users Score":0,"Answer":"This will help you fix the above problem\nYou need to add following personal package repository:\nsudo add-apt-repository ppa:deadsnakes\/ppa\nCheck for updates\nsudo apt-get update\ninstall python using following command\nsudo apt-get install python3.6","Q_Score":0,"Tags":"python,pip","A_Id":63793923,"CreationDate":"2018-06-21T10:54:00.000","Title":"I want to install pip for python3.6. When i allready have another version of python3 is installed.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"But when i run command sudo apt-get install python3-pip. It is installed but inot as python3.6. It is installed in python3.5.I have also specified the version in command i.e sudo apt-get install python3.6-pip.But it gives me an error.\nReading package lists... Done\nBuilding dependency tree\nReading state information... Done\nE: Unable to locate package python3.6-pip\nE: Couldn't find any package by glob 'python3.6-pip'\nE: Couldn't find any package by regex 'python3.6-pip'","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3123,"Q_Id":50966768,"Users Score":0,"Answer":"It was easy. I just changed my default python3 version:\nsudo gedit ~\/.bashrc  alias python3=\"python3.6\"\nNow I  can install the packages using python3.6 with\n-m pip install 'packagenae'","Q_Score":0,"Tags":"python,pip","A_Id":50967592,"CreationDate":"2018-06-21T10:54:00.000","Title":"I want to install pip for python3.6. When i allready have another version of python3 is installed.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"But when i run command sudo apt-get install python3-pip. It is installed but inot as python3.6. It is installed in python3.5.I have also specified the version in command i.e sudo apt-get install python3.6-pip.But it gives me an error.\nReading package lists... Done\nBuilding dependency tree\nReading state information... Done\nE: Unable to locate package python3.6-pip\nE: Couldn't find any package by glob 'python3.6-pip'\nE: Couldn't find any package by regex 'python3.6-pip'","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":3123,"Q_Id":50966768,"Users Score":2,"Answer":"You can install python packages using python3.6 -m pip install [Package_to_install] straight away.","Q_Score":0,"Tags":"python,pip","A_Id":50966836,"CreationDate":"2018-06-21T10:54:00.000","Title":"I want to install pip for python3.6. When i allready have another version of python3 is installed.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to install google earth engine python API on my pc. \nDuring installation process i received this error message \"distributed 1.21.8 requires msgpack, which is not installed\". I looked for the different possilities to install this package but, it didn't function. \nHow can I do?\nMy pc is windows and I used Anaconda\nthanks so much","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4433,"Q_Id":50967358,"Users Score":3,"Answer":"I had the same problem. Try this here:  pip install msgpack","Q_Score":0,"Tags":"python,anaconda,google-earth","A_Id":50977048,"CreationDate":"2018-06-21T11:22:00.000","Title":"Distributed 1.21.8 requires msgpack","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to understand how Exception Handling is done in Robot. I want to handle exceptions from multiple testcases using some generic way.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2153,"Q_Id":50969989,"Users Score":0,"Answer":"You can use below two keywords for that:\n\nRun Keyword And Continue On Failure\nRun Keyword And Ignore Error    based on ur requirement, however i suggest to go with 2nd one as you'll be able to store output and status","Q_Score":0,"Tags":"java,python,robotframework","A_Id":51022339,"CreationDate":"2018-06-21T13:37:00.000","Title":"How to handle exceptions in 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to get the maximum (2 or more) indexes set to 1 from the output of tf.nn.softmax(). \ngiven tf.nn.softmax's  outputs as [0.1, 0.4, 0.2, 0.1, 0.8] I want to get something like [0,1,0,0,1] since those indexes have the maximum numbers (in this case I chose just the maximum 2). Thank you in advance!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":445,"Q_Id":50973687,"Users Score":0,"Answer":"tf.nn.softmax forces everything to add up to 1.0 to make a valid probability distribution. If you want multiple values in the vector to be ones then you should use tf.nn.sigmoid instead. \nIf you want to retrieve the maximum numbers in the vector use tf.nn.top_k.","Q_Score":0,"Tags":"python,tensorflow,softmax","A_Id":50974355,"CreationDate":"2018-06-21T16:43:00.000","Title":"How to get two or more maximum indexes values set to 1 from tf.softmax's output","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"From what I understand about Docker, it's a tool used for virtual environments. In their lingo, its called \"containerization\". This is more or less what Python's virtualenv does. However, you can use virtualenv in Docker. So, is it a virtual environment inside a virtual environment? I'm confused as to how this would even work, so could someone please clarify?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":42477,"Q_Id":50974960,"Users Score":15,"Answer":"Adding to the above: there is a case for combining docker and venv: some OSs ship with python installed to provide 'OS-near' apps, e.g., to my knowledge, apt on debian (and its derivatives). The python venv enables a developer to ship a python app which requires a different interpreter version without affecting the shipped-with-the-OS python. Now, since Docker 'isolates the whole OS' as stated above, the same applies to a Docker image. Hence, in my view, if a Docker image is required\/desired, it is best practice to create a venv inside the Docker image for your python app.","Q_Score":158,"Tags":"python,docker,virtualenv","A_Id":53268363,"CreationDate":"2018-06-21T18:00:00.000","Title":"What's the difference between Docker and Python virtualenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"From what I understand about Docker, it's a tool used for virtual environments. In their lingo, its called \"containerization\". This is more or less what Python's virtualenv does. However, you can use virtualenv in Docker. So, is it a virtual environment inside a virtual environment? I'm confused as to how this would even work, so could someone please clarify?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":42477,"Q_Id":50974960,"Users Score":35,"Answer":"Python virtual environment will \"containerize\" only Python runtime i.e. python interpreter and python libraries whereas Docker isolates the whole system (the whole file-system, all user-space libraries, network interfaces) . Therefore Docker is much closer to a Virtual Machine than virtual environment.","Q_Score":158,"Tags":"python,docker,virtualenv","A_Id":50975029,"CreationDate":"2018-06-21T18:00:00.000","Title":"What's the difference between Docker and Python virtualenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"From what I understand about Docker, it's a tool used for virtual environments. In their lingo, its called \"containerization\". This is more or less what Python's virtualenv does. However, you can use virtualenv in Docker. So, is it a virtual environment inside a virtual environment? I'm confused as to how this would even work, so could someone please clarify?","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":42477,"Q_Id":50974960,"Users Score":2,"Answer":"\"a virtual environment, a self-contained directory tree that contains a Python installation for a particular version of Python, plus a number of additional packages\"\nA docker container provides a higher level of abstraction\/isolation, it can has its own \"process space, file system, network space, ipc space, etc.\"","Q_Score":158,"Tags":"python,docker,virtualenv","A_Id":66633116,"CreationDate":"2018-06-21T18:00:00.000","Title":"What's the difference between Docker and Python virtualenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am creating scatterplots of data with integer targets.  Naturally, I represent the targets as color in the scatterplot.  However, sometimes my models, because of the nature of the model, predict targets that are not in the original set.  I.e., my training targets are chosen from [0,1,2], and my model occasionally predicts 3, because it is not very bright.\nThe problem is that when I scatterplot my data, and then separately scatterplot the predictions, the target 2 gets mapped to a different color in each scatter, which makes for a bad picture.  This is because matplotlib by default scales the values in my color list to be between some given values.  I would like to override this default behavior, and have my color list (which are integers), always map to the same color, e.g. 1 maps to green, regardless of how many different classes are in my c=targets parameter.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":174,"Q_Id":50975047,"Users Score":1,"Answer":"Create a list of colors, say colors = ['blue', 'red', 'green', 'purple'], that has as many colors as you have different targets. Then, set c=colors[target] with target being the integer your model popped out. This means you will need to plot each point one at a time unless you sort all the targets and plot at the end.","Q_Score":0,"Tags":"python,matplotlib","A_Id":50975222,"CreationDate":"2018-06-21T18:06:00.000","Title":"matplotlib colormap without normalization","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Some of the standard matplotlib cmaps, such as viridis or jet show dark colors in small values. While this is what I need, I like them to show nothing, i.e. white background if the value is exactly zero. For non zero values the usual colors of that color map are fine.\nIs it possible to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4611,"Q_Id":50976177,"Users Score":2,"Answer":"You would rather mask zero out of your data, e.g. setting those values to nan or use a masked array. Then you can just set_bad(\"white\") for your colormap.","Q_Score":3,"Tags":"python,matplotlib,colormap","A_Id":50977040,"CreationDate":"2018-06-21T19:25:00.000","Title":"matplotlib modified color map with white as zero","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While doing some python programming on raspberry pi running raspbian, I installed python 3.6 and subsequently many packages via apt-get, pip and I think from setup files too. All of it was done globally , but my understanding it is better and cleaner to install via pip in virtualenv.\nIs there a more efficient way to clean up and reinstall all my packages outside of reimaging my raspberry pi and reinstalling python3.6?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1259,"Q_Id":50977789,"Users Score":0,"Answer":"All user-installed packages go to \/usr\/lib\/python3.6\/site-packages or \/usr\/local\/lib\/python3.6\/site-packages; Debian-based distributions also use \/usr\/local\/lib\/python3.6\/dist-packages. Clear these directories and you're done. Perhaps you'd want to preserve pip-related packages \u2014 pip, setuptools, requests\u2026","Q_Score":0,"Tags":"python-3.x,raspberry-pi,pip,raspberry-pi3","A_Id":50978175,"CreationDate":"2018-06-21T21:40:00.000","Title":"python - How remove all user installed python packages and or python itself in order to start again with a clean install?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a whole bunch of code interacting with hdf files through h5py.  The code has been working for years. Recently, with a change in python environments, I am receiving this new error message.  \nIOError: Unable to open file (unable to lock file, errno = 11, error message = 'Resource temporarily unavailable')\nWhat is interesting is the error occurs intermittently in some places and persistently in others. In places where it is occuring routinely, I have looked at my code and confirm that there is no other h5py instance connected to the file and that the last connection was properly flushed and closed.  Again this was all working fine prior to the environment change.  \nHeres snippets from my conda environment:\nh5py                      2.8.0            py27h470a237_0    conda-forge\nhdf4                      4.2.13                        0    conda-forge\nhdf5                      1.10.1                        2    conda-forge","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":7784,"Q_Id":50977839,"Users Score":0,"Answer":"with h5py.File(), the same .h5 file can be open for read (\"r\") multiple times. But h5py doesn't support more than a single thread. You can experience bad data with multiple concurrent readers.","Q_Score":3,"Tags":"python-2.7,hdf5,h5py,hdf","A_Id":57412703,"CreationDate":"2018-06-21T21:46:00.000","Title":"Locking of HDF files using h5py","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a whole bunch of code interacting with hdf files through h5py.  The code has been working for years. Recently, with a change in python environments, I am receiving this new error message.  \nIOError: Unable to open file (unable to lock file, errno = 11, error message = 'Resource temporarily unavailable')\nWhat is interesting is the error occurs intermittently in some places and persistently in others. In places where it is occuring routinely, I have looked at my code and confirm that there is no other h5py instance connected to the file and that the last connection was properly flushed and closed.  Again this was all working fine prior to the environment change.  \nHeres snippets from my conda environment:\nh5py                      2.8.0            py27h470a237_0    conda-forge\nhdf4                      4.2.13                        0    conda-forge\nhdf5                      1.10.1                        2    conda-forge","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":7784,"Q_Id":50977839,"Users Score":0,"Answer":"Similar as with the other answers I had already opened the file, but for me it was in a separate HDF5 viewer.","Q_Score":3,"Tags":"python-2.7,hdf5,h5py,hdf","A_Id":71661095,"CreationDate":"2018-06-21T21:46:00.000","Title":"Locking of HDF files using h5py","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a whole bunch of code interacting with hdf files through h5py.  The code has been working for years. Recently, with a change in python environments, I am receiving this new error message.  \nIOError: Unable to open file (unable to lock file, errno = 11, error message = 'Resource temporarily unavailable')\nWhat is interesting is the error occurs intermittently in some places and persistently in others. In places where it is occuring routinely, I have looked at my code and confirm that there is no other h5py instance connected to the file and that the last connection was properly flushed and closed.  Again this was all working fine prior to the environment change.  \nHeres snippets from my conda environment:\nh5py                      2.8.0            py27h470a237_0    conda-forge\nhdf4                      4.2.13                        0    conda-forge\nhdf5                      1.10.1                        2    conda-forge","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":7784,"Q_Id":50977839,"Users Score":2,"Answer":"My issue! Failed to close the file in an obscure method.  Interesting thing is that unlocking the file in some cases just took a restart of ipython, other times took a full reboot.","Q_Score":3,"Tags":"python-2.7,hdf5,h5py,hdf","A_Id":51071193,"CreationDate":"2018-06-21T21:46:00.000","Title":"Locking of HDF files using h5py","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a whole bunch of code interacting with hdf files through h5py.  The code has been working for years. Recently, with a change in python environments, I am receiving this new error message.  \nIOError: Unable to open file (unable to lock file, errno = 11, error message = 'Resource temporarily unavailable')\nWhat is interesting is the error occurs intermittently in some places and persistently in others. In places where it is occuring routinely, I have looked at my code and confirm that there is no other h5py instance connected to the file and that the last connection was properly flushed and closed.  Again this was all working fine prior to the environment change.  \nHeres snippets from my conda environment:\nh5py                      2.8.0            py27h470a237_0    conda-forge\nhdf4                      4.2.13                        0    conda-forge\nhdf5                      1.10.1                        2    conda-forge","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":7784,"Q_Id":50977839,"Users Score":1,"Answer":"I had other process running that I did not realize. How did I solved my problem:\n\nUsed ps aux | grep myapp.py to find the process number that was running myapp.py.\nKill the process usill the kill command\nRun again","Q_Score":3,"Tags":"python-2.7,hdf5,h5py,hdf","A_Id":65687853,"CreationDate":"2018-06-21T21:46:00.000","Title":"Locking of HDF files using h5py","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to validate JSON format without loading the file? I am copying files from one S3 bucket to another S3 bucket. After JSONL files are\ncopied , I want to check if file format is correct in the sense curly braces and commas are fine.\nI don't want to use json.load() because file size and number are big and it will slow down the process plus file is already copied so no need to parse it , just validation is requirement.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":455,"Q_Id":50978456,"Users Score":1,"Answer":"There is no capability within Amazon S3 itself to validate the content of objects.\nYou could configure S3 to trigger an AWS Lambda function whenever a file is created in the S3 bucket. The Lambda function could then parse the file and perform some action (eg send a notification or move the object to another location) if the validation fails.","Q_Score":0,"Tags":"python,json,amazon-s3","A_Id":50978931,"CreationDate":"2018-06-21T22:53:00.000","Title":"JSON format validation without loading file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to cluster Object A with Object B or Object C. But value of Cosine Similarity Object A with Object B is 0 and Cosine Similarity Object A with Object C is 0. Before it directly clustered, I need to cluster those object step by stem, which one should be combined first Object A with B or Object A with C?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":50980199,"Users Score":0,"Answer":"With Cosine similarity, you'll probably want to stop at 0...\nBut of course the problem of ties can arise with any distance function, too.\nBut there obviously is no mathematical answer. They are all equally good. Usually, one hopes that the order does not matter. For a it doesn't, but for all other it does. Don't forget that HAC cannot guarantee to find the best solution (except for single link).\nSo just choose any, or even all at once. It's fairly common to choose the first found. This allows getting different versions by shuffling the data.","Q_Score":0,"Tags":"python-2.7,cluster-analysis,hierarchical-clustering,cosine-similarity","A_Id":50995396,"CreationDate":"2018-06-22T03:23:00.000","Title":"How to cluster some object in HAC but they have same value of Cosine Similarity","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just started learning Django, and not able to understand that what is the actual difference between URL and path in Django.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5998,"Q_Id":50980660,"Users Score":3,"Answer":"I know that this is an older question, but to answer the question directly:\n\nSince Django 2.0, the url() function is an alias to django.urls.re_path()\nAnd, it is listed as deprecated since Django 3.1.\n\nSo, you should use either path() or re_path() moving forward, depending on which meets your needs.","Q_Score":4,"Tags":"python,django","A_Id":69890081,"CreationDate":"2018-06-22T04:24:00.000","Title":"difference between URL and path in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to Jupyter Notebook, what is the key difference between the Jupyter Notebook and JupyterLab, suggest me to choose the best one, which should be used in future.","AnswerCount":6,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":199052,"Q_Id":50982686,"Users Score":10,"Answer":"(I am using JupyterLab with Julia)\nFirst thing is that Jupyter lab from my previous use offers more 'themes' which is great on the eyes, and also fontsize changes independent of the browser, so that makes it closer to that of an IDE. There are some specifics I like such as changing the 'code font size' and leaving the interface font size to be the same.\nMajor features that are great is\n\nthe drag and drop of cells so that you can easily rearrange the code\ncollapsing cells with a single mouse click and a small mark to remind of their placement\n\nWhat is paramount though is the ability to have split views of the tabs and the terminal. If you use Emacs, then you probably enjoyed having multiple buffers with horizontal and vertical arrangements with one of them running a shell (terminal), and with jupyterlab this can be done, and the arrangement is made with drags and drops which in Emacs is typically done with sets of commands.\n(I do not believe that there is a learning curve added to those that have not used the 'notebook' original version first. You can dive straight into this IDE experience)","Q_Score":326,"Tags":"python,jupyter-notebook,jupyter,jupyter-lab","A_Id":62854226,"CreationDate":"2018-06-22T07:19:00.000","Title":"What is the difference between Jupyter Notebook and JupyterLab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with Python 3 and trying to read a excel worksheet using xlrd.\nI ran pip install xlrd to install it but it still shows me the ImportError. \nI tried the following:\n\npip3 install xlrd\npip install --upgrade xlrd \n\nBut both  of them show requirements already satisfied and up to date respectively.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2527,"Q_Id":50982801,"Users Score":2,"Answer":"python3 uses pip3. Please check if you are using the correct pip and python version.","Q_Score":1,"Tags":"python-3.x,importerror","A_Id":50983030,"CreationDate":"2018-06-22T07:27:00.000","Title":"ImportError: No module named xlrd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"when i run python manage.py makemigrations and migrate every thing is ok and changes are made but process does not end and I must press control+z to end process \nwhy this happend??\nis it normal?\ndb backend : mysql\npython 2.7 \ndjango 1.11\nOS: ubuntu 16.04 TLS\nEDIT: because threading I using threading and it make problem in migration and makemigration","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":479,"Q_Id":50985703,"Users Score":0,"Answer":"In my case the problem was, that I have started a thread from views.py. And this thread was running forever. Django could not end, inclusing the migration calls, until this thread was ended. Removing the thread solved the problem.","Q_Score":1,"Tags":"python,django,django-migrations,django-1.11","A_Id":66969160,"CreationDate":"2018-06-22T10:13:00.000","Title":"django : makemigrations process does not end","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to test celery task using pytest in Django. \nIf I use celery_worker parameter in test function then I get an error:\n\n{OperationalError}database table is locked (sqllite).\n\nIf I run worker before tests and do not use celery_worker parameter then task run seccesfully but I can't locate changes in the test database (pytestmark = pytest.mark.django_db) as all updates links to the original database.\nI try to run the test in Docker (postgresql db) but with parameter celery_worker I get error:\n\npsycopg2.InterfaceError: connection already closed","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":347,"Q_Id":50986520,"Users Score":1,"Answer":"Need to use celery_worker parameter in pair with pytest mark @pytest.mark.django_db(transaction=True).","Q_Score":1,"Tags":"python,django,postgresql,celery,pytest","A_Id":50987884,"CreationDate":"2018-06-22T11:03:00.000","Title":"Pytest celery: cleaned up database after task call","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to send an ACK with a data payload using the socket library but I cannot understand how to do it.\nIs this supported and if not, what are the alternatives?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3315,"Q_Id":50989064,"Users Score":0,"Answer":"you can't do this , Socket library uses high level APIs like :\nbind()\nlisten()\naccept() ... etc\nthe acks will be handled for you ,","Q_Score":0,"Tags":"python,tcp","A_Id":50989676,"CreationDate":"2018-06-22T13:28:00.000","Title":"How to send ACK with data payload using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I basically have a large (multi-terabyte) dataset of text (it's in JSON but I could change it to dict or dataframe). It has multiple keys, such as \"group\" and \"user\". \nRight now I'm filtering the data by reading through the entire text for these keys. It would be far more efficient to have a structure where I filter and read only the key.\nDoing the above would be trivial if it fit in memory, and I could use standard dict\/pandas methods and hash tables. But it doesn't fit in memory.\nThere must be an off the shelf system for this. Can anyone recommend one?\nThere are discussions about this, but some of the better ones are old. I'm looking for the simplest off the shelf solution.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":64,"Q_Id":50992440,"Users Score":1,"Answer":"I suggest you to split your large file to multiple small files with method readlines(CHUNK) and then you can process it one by one.\nI worked with large Json and at beginning, the process was 45sec by file and my program ran while 2 days but when I splintered it, the program finished only for 4h","Q_Score":0,"Tags":"python,database,hashtable","A_Id":50993619,"CreationDate":"2018-06-22T16:50:00.000","Title":"Best structure for on-disk retrieval of large data using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used pip install django-celeryand pip3 install django-celery in Pycharm.\nAfter that I use import djcelery,but Pycharm reminds me no module named djcelery.\nThen I used pip list I can see django-celery          3.2.2   in the list.\nBut when I went to virtual environment path myenv\/lib\/site-packages where I can see all the module or app that I have installed such as django-pure-pagination.But I can't find django-celery there.\nAny friend has any idea, how to fix it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":97,"Q_Id":50993171,"Users Score":2,"Answer":"Seems like you've installed django-celery in another environment. Try to install it with PyCharm:\n\nFile > Settings > Project > Project Interpreter.","Q_Score":0,"Tags":"python,django,django-models,pycharm,django-celery","A_Id":50993837,"CreationDate":"2018-06-22T17:43:00.000","Title":"module can't be installed in Django virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been successfully using PyCharm for my python work.All the packages can be easily installed by going to settings and then project interpreter but tensorflow installation is showing error.In suggestions it asked me to upgrade pip module.But even after that it shows error with following message: \n\"   Could not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow\"\nI am able to install all other packages but error is with tensorflow only.I am using windows.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":50993189,"Users Score":0,"Answer":"Please run pip install tensorflow in command line and post the output here. Tensorflow can be installed on Windows but the process is often annoying.","Q_Score":0,"Tags":"python-3.x,tensorflow,pycharm","A_Id":51001967,"CreationDate":"2018-06-22T17:44:00.000","Title":"Tensor flow package installation in PyCharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been successfully using PyCharm for my python work.All the packages can be easily installed by going to settings and then project interpreter but tensorflow installation is showing error.In suggestions it asked me to upgrade pip module.But even after that it shows error with following message: \n\"   Could not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow\"\nI am able to install all other packages but error is with tensorflow only.I am using windows.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":50993189,"Users Score":0,"Answer":"You could also tried anaconda. It is has very nice UI and you could switch between different version.","Q_Score":0,"Tags":"python-3.x,tensorflow,pycharm","A_Id":51021687,"CreationDate":"2018-06-22T17:44:00.000","Title":"Tensor flow package installation in PyCharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Quite simple, \nIf I perform t-SNE in Python for high-dimensional data then I get 2 or 3 coordinates that reflect each new point. \nBut how do I map these to the original IDs? \nOne way that I can think of is if the indices are kept fixed the entire time, then I can do: \n\nPick a point in t-SNE\nSee what row it was in t-SNE (e.g. index 7)\nGo to original data and pick out row\/index 7.\n\nHowever, I don't know how to check if this actually works. My data is super high-dimensional and it is very hard to make sense of it with a normal \"sanity check\".\nThanks a lot!\nBest,","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":660,"Q_Id":50993934,"Users Score":1,"Answer":"If you are using sklearn's t-SNE, then your assumption is correct. The ordering of the inputs match the ordering of the outputs. So if you do y=TSNE(n_components=n).fit_transform(x) then y and x will be in the same order so y[7] will be the embedding of x[7]. You can trust scikit-learn that this will be the case.","Q_Score":3,"Tags":"python,mapping","A_Id":50994909,"CreationDate":"2018-06-22T18:41:00.000","Title":"Getting IDs from t-SNE plot?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have this large XML file on my drive. The file is too large to be opened with sublimetext or other text editors. \nIt is also too large to be loaded in memory by the regular XML parsers.\nTherefore, I dont even know what's inside of it!\nIs it just possible to \"print\" a few rows of the XML files (as if it was some sort of text document) so that I have an idea of the nodes\/content? \nI am suprised not to find an easy solution to that issue.\nThanks!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1845,"Q_Id":50994801,"Users Score":1,"Answer":"This is one of the few things I ever do on the command line: the \"more\" command is your friend. Just type\n\nmore big.xml","Q_Score":0,"Tags":"python,xml","A_Id":50995481,"CreationDate":"2018-06-22T19:56:00.000","Title":"how to print the first lines of a large XML?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running Tensorflow 1.5.0 on a docker container because i need to use a version that doesn't use the AVX bytecodes because the hardware i am running on is too old to support it.\nI finally got tensorflow-gpu to import correctly (after downgrading the docker image to tf 1.5.0) but now when i run any code to detect the GPU it says the GPU is not there.\nI looked at the docker log and Jupyter is spitting out this message\nIgnoring visible gpu device (device: 0, name: GeForce GTX 760, pci bus id: 0000:01:00.0, compute capability: 3.0) with Cuda compute capability 3.0. The minimum required Cuda capability is 3.5.\nThe tensorflow website says that GPUs with compute capability of 3.0 is supported so why does it says it needs compute capability 3.5?\nIs there any way to get a docker image for tensorflow and jupyter that uses tf 1.5.0 but supports GPUs with compute capability?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":9306,"Q_Id":50995707,"Users Score":1,"Answer":"I just spent a day trying to build this thing from source and what worked for me finally is quite surprising: the pre-built wheel for TF 1.5.0 does not complain about this anymore, while pre-built wheel for TF 1.14.0 does complain. It seems you have used the same version, so it's quite interesting, but I thought I would share, so if anyone struggles with this, there seems to be an easy way out.\nConfigs:\n\nVisual Studio version: 2017\nCuda compute capabilitz: 3.0\nGPU: two Geforce GPU 755M\nOS: Windows 10\nPython: 3.6.8\nCuda Toolkit: 9.0\nCuDNN: 7.0 (the earliest available is needed from, but it will complain anyway)","Q_Score":4,"Tags":"python,docker,tensorflow","A_Id":56987465,"CreationDate":"2018-06-22T21:16:00.000","Title":"Ignoring visible gpu device with compute capability 3.0. The minimum required Cuda capability is 3.5","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I send POST request with a csv or a text file to the server running on a localhost using cURL. \nI have tried curl -X POST -d @file.csv http:\/\/localhost:5000\/upload but I get \n\n{\n      \"message\": \"The browser (or proxy) sent a request that this server could not understand.\"\n  }\n\nMy server is flask_restful API. Thanks a lot in advance.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":23637,"Q_Id":50998620,"Users Score":2,"Answer":"Curl's default Content-Type is application\/x-www-form-urlencoded so your problem is probably that the data you are POSTing is not actually form data. It might work if you set the content type header properly:\n\n-H \"Content-Type: text\/csv\"\n\nThough it does depend on the server.","Q_Score":14,"Tags":"python-3.x,curl,flask,flask-restful","A_Id":50998749,"CreationDate":"2018-06-23T06:36:00.000","Title":"POST csv\/Text file using cURL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I don't quite understand output received from:\n\nprint(print(print('aaa')))\naaa\nNone\nNone\n\nFirst aaa is clear. But I thought that second print(aaa) will throw an error as variable aaa is not defined...","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":4251,"Q_Id":51000516,"Users Score":7,"Answer":"print(print('aaa'))\n\nThe outer print will receive as argument not what inner print printed to stdout, but what inner print returned. And print function never returns anything (equivalent to returning None). That's why you see this output.","Q_Score":7,"Tags":"python,python-3.x","A_Id":51000534,"CreationDate":"2018-06-23T11:00:00.000","Title":"Python output from print(print(print('aaa')))","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't quite understand output received from:\n\nprint(print(print('aaa')))\naaa\nNone\nNone\n\nFirst aaa is clear. But I thought that second print(aaa) will throw an error as variable aaa is not defined...","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":4251,"Q_Id":51000516,"Users Score":1,"Answer":"print prints on the standard output and returns None. Your second print statement gets result of first print which is None","Q_Score":7,"Tags":"python,python-3.x","A_Id":51000539,"CreationDate":"2018-06-23T11:00:00.000","Title":"Python output from print(print(print('aaa')))","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have my sqlite3 database in linux machine. And I would like to pull data from this database to my windows machine in a GUI fashion.\nI haven't finalized on the design yet (so no code to provide).\nI am contemplating on using Flask for windows which will talk to HTTP server in linux machine. This server makes connection to the database and provides data to respective client.\nI am also rather new to GUI. Is there any loophole in this approach? Am not planning on anything exhuberant. Any help is much appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1543,"Q_Id":51000711,"Users Score":0,"Answer":"SQLite is not a server-based database, but rather it is a file-based database, i.e., it is not designed to be accessed over the server, but only to save the data locally.\nI would change the design and use another server-based database (MySQL, PostGreSQL, etc.).\nIf you really cannot use anything else, and want to access it Sqlite database over network, I would expose the SQLite database file over the network (for example share it on the network using Samba if you are using linux). Another example to access SQLite file is to access the server remotely using SSH.\nAnother better approach is to program a web service on the server where the SQLite file exists, and use the API of that web service to CRUD the data from the database.\nAFAIK, this is approach i the only possible way.","Q_Score":0,"Tags":"python-3.x,http,flask","A_Id":51000756,"CreationDate":"2018-06-23T11:28:00.000","Title":"Need to pull data from remote sqlite3 database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had installed opencv in python 3.6 32 bit version using the command 'pip install opencv-python', which I successfully used. Later when I upgraded my version to 64 bit as to use tensorflow as well, and ran the same command 'pip install opencv-python', opencv was already present, yet when I tried to import cv2 module, it showed the error that any module named cv2 is not found.\nNow I don't understand what to do next. Hope someone can help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":433,"Q_Id":51001356,"Users Score":0,"Answer":"You may uninstall previous opencv installation via pip uninstall opencv-python then do the pip install opencv-python.","Q_Score":0,"Tags":"python,opencv","A_Id":51002024,"CreationDate":"2018-06-23T12:54:00.000","Title":"Unable to import cv2 in 64 bit version of python 3.6.5","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Failed building wheel for hmmlearn\n  Command \"C:\\Users\\Akash\\PycharmProjects\\hello\\venv\\Scripts\\python.exe -u -c\n  \"import setuptools,\n  tokenize;file='C:\\Users\\Akash\\AppData\\Local\\Temp\\pycharm-packaging\\hmmlearn\\setup.py';f=getattr(tokenize,\n  'open', open)(file);code=f.read().replace('\\r\\n',\n  '\\n');f.close();exec(compile(code, file, 'exec'))\" install\n  --record C:\\Users\\Akash\\AppData\\Local\\Temp\\pip-record-z6k7p8b8\\install-record.txt\n  --single-version-externally-managed --compile --install-headers C:\\Users\\Akash\\PycharmProjects\\hello\\venv\\include\\site\\python3.6\\hmmlearn\"\n  failed with error code 1 in\n  C:\\Users\\Akash\\AppData\\Local\\Temp\\pycharm-packaging\\hmmlearn\\\n\nthis is the error showing in cmd and in pycharm also. \ni found that Microsoft Visual Studio C++ 14 is required","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8363,"Q_Id":51002441,"Users Score":0,"Answer":"I had the exact same issue - another source for the package which I wanted to install did it for me.\nFor example 'conda install hmmlearn' would cause the issue above.\nBut after checking anaconda.org for packages, I found the command\n'conda install -c omnia hmmlearn'\nwhich solved the situation for me without any further Microsoft Visual C++ installation or action...\nBest,\nLania","Q_Score":2,"Tags":"python,pycharm,hmmlearn","A_Id":53725279,"CreationDate":"2018-06-23T15:09:00.000","Title":"Unable to install hmmlearn in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Failed building wheel for hmmlearn\n  Command \"C:\\Users\\Akash\\PycharmProjects\\hello\\venv\\Scripts\\python.exe -u -c\n  \"import setuptools,\n  tokenize;file='C:\\Users\\Akash\\AppData\\Local\\Temp\\pycharm-packaging\\hmmlearn\\setup.py';f=getattr(tokenize,\n  'open', open)(file);code=f.read().replace('\\r\\n',\n  '\\n');f.close();exec(compile(code, file, 'exec'))\" install\n  --record C:\\Users\\Akash\\AppData\\Local\\Temp\\pip-record-z6k7p8b8\\install-record.txt\n  --single-version-externally-managed --compile --install-headers C:\\Users\\Akash\\PycharmProjects\\hello\\venv\\include\\site\\python3.6\\hmmlearn\"\n  failed with error code 1 in\n  C:\\Users\\Akash\\AppData\\Local\\Temp\\pycharm-packaging\\hmmlearn\\\n\nthis is the error showing in cmd and in pycharm also. \ni found that Microsoft Visual Studio C++ 14 is required","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":8363,"Q_Id":51002441,"Users Score":1,"Answer":"I'm running Windows 10. The only channel and subsequent command that worked for me was conda-forge:\nconda install -c conda-forge hmmlearn","Q_Score":2,"Tags":"python,pycharm,hmmlearn","A_Id":54620725,"CreationDate":"2018-06-23T15:09:00.000","Title":"Unable to install hmmlearn in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just started learning Python and one thing is bugging me is the exact type of \"__main__\". So far, I have seen that \"__main__\" is mostly used as string literal like __name__ == \"__main__\".\nI mean, it is not a function, it is not a variable. With all the other built-in variables and functions starting with __ it is just confusing. Any special reason it has to start with __? I know it has special meaning in the context of modules and namespaces, but I am talking purely in the terms of basic\/primitive data types.","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":352,"Q_Id":51003126,"Users Score":3,"Answer":"Yes, \"__main__\" is a string literal, since module names are strings. The module is called __main__ to distinguish it from modules named main, and since it is a system-assigned name.","Q_Score":3,"Tags":"python","A_Id":51003152,"CreationDate":"2018-06-23T16:39:00.000","Title":"Is \"__main__\" just a string literal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just started learning Python and one thing is bugging me is the exact type of \"__main__\". So far, I have seen that \"__main__\" is mostly used as string literal like __name__ == \"__main__\".\nI mean, it is not a function, it is not a variable. With all the other built-in variables and functions starting with __ it is just confusing. Any special reason it has to start with __? I know it has special meaning in the context of modules and namespaces, but I am talking purely in the terms of basic\/primitive data types.","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":352,"Q_Id":51003126,"Users Score":2,"Answer":"Yes, it is a string literal. Like magic methods like __init__ start and end with 2 underscores in order not to be mixed with other methods,  __main__ has such naming not to be mixed with names of existing files.","Q_Score":3,"Tags":"python","A_Id":51003155,"CreationDate":"2018-06-23T16:39:00.000","Title":"Is \"__main__\" just a string literal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to insert quotes within a bracket they will not complete. The quotes will auto complete if they are on their own but if I put quotes within a bracket it will not complete and will look like this\n[\"]\nAnyone else having this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":225,"Q_Id":51006038,"Users Score":0,"Answer":"(Spyder maintainer here) The reason you're observing this behavior is because quotes are only automatically closed when there's no text to the right of the cursor.","Q_Score":0,"Tags":"python,spyder","A_Id":51014781,"CreationDate":"2018-06-24T00:20:00.000","Title":"Quotes not auto-closed within brackets in Spyder's Editor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed Canopy because I had some issues running code in Jupyter Notebook.\nI have an Anaconda distribution installed.\nI installed OpenCV through anaconda and can easily import cv2 in Jupyter Notebook.\nHowever, when I import cv2 in Canopy IDE it says \"No module named cv2\".\nHow can I safely fix this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":327,"Q_Id":51006130,"Users Score":1,"Answer":"Each Python environment is independent. Installing a package into an anaconda Python environment does not install it into a Canopy Python environment (nor into a different anaconda Python environment). This is a feature, not a bug; it allows different Python environments to be configured differently, even incompatibly.\nTo use OpenCV in Canopy User Python environment, first install it using the Canopy Package Manager.","Q_Score":0,"Tags":"python,jupyter,canopy","A_Id":51012003,"CreationDate":"2018-06-24T00:45:00.000","Title":"importing library Jupyter Notebook vs Canopy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A third party monitoring app expects the host header to be set to a certain value in order to recognise the message I send it (it defaults to localhost when sending locally). So I need to set it manually. \nMy syslog message is sent via simple python socket connection (socket.send) and I have tried prepending date time followed by host to the message string I pass in as parameter. However the 3rd party system still detects it as localhost, indicating that is not setting the header.\nHow do I set the header of a syslog message via python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":250,"Q_Id":51008666,"Users Score":0,"Answer":"The hostname is added to the message by the local syslog server, i.e. is not set inside Python at all. Thus, your local system needs to be configured properly in order to send the correct hostname when forwarding syslog messages to other systems.","Q_Score":0,"Tags":"python,sockets,syslog","A_Id":51008937,"CreationDate":"2018-06-24T09:38:00.000","Title":"How to set host header field in a syslog message?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my code, I have a few debug lines using logging modules.\nHowever, when running the program, I saw a lot of other debug messages that is not from my code. \nLooks like it is from the other modules that I use in the code, is there a way to disable the log (debug) messages that is not from my code (modules)?\nIf not, what is usually the common practice?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":51012313,"Users Score":0,"Answer":"logging.setLevel(logging.CRITICAL) will disable pretty much all non-critial logging accross all loggers (I think at least...)\nafter that you can set your logger to have a more reasonable threshold\nlogging.getLogger(\"my_logger\").setLevel(logging.DEBUG)\nI think that should work ... without extensively testing it at all","Q_Score":0,"Tags":"python,logging,module","A_Id":51012462,"CreationDate":"2018-06-24T17:26:00.000","Title":"Is there a way to disable log message that is from module I use?","Data Science and Machine Learning":0,"Database and SQL":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 convert a .py to .exe using pyinstaller. When I type pyinstaller my_code.py everything seems to be working and after a couple of minutes the process stops and I get the recursion error. I have tried to create a my_code.spec file in the same folder, edit it and change the number of recursions but when I run pyinstaller apparently a new .spec is created since I can't find the sys.setrecursionlimit() command that I had previously added to the my_code.spec file.\nI am running all the above from the anaconda command prompt and not from the command line but I think that this is not a problem since I have tried to convert to .exe a simple \"hello world\" script and it works perfectly.\nI have python 3.6.3 installed.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":5971,"Q_Id":51012750,"Users Score":2,"Answer":"It's better to build a different environment for when wanting to make an executable python file. This should work to the python version your executable compiler works better. Usually, the older the python version the easiest is to compile.","Q_Score":5,"Tags":"python,recursion,pyinstaller","A_Id":52986514,"CreationDate":"2018-06-24T18:22:00.000","Title":"pyinstaller Recursion error: maximum recursion depth exceeded","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used win10. When I installed Visual Studio2017, I configure the Python3 environment. And then after half year I installed Anaconda(Python3) in another directory. Now I have two interpreters in different directories. \n\nNow, no matter in what IDE I code the codes, after I save it and double click it in the directory, the Python File is run by the interpreter configured by VS2017.\n\nWhy do I know that? I use sys.path to get to know it. But when I use VS2017 to run the code, it shows no mistake. The realistic example is that I pip install requests in cmd, then I import it in a Python File. Only when I double click it, the Traceback says I don't have this module. In other cases it works well.\n\nSo, how to change the default python interpreter of the cmd.exe?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":51016767,"Users Score":0,"Answer":"Just change the interpreter order of the python in the PATH is enough.\nIf you want to use python further more, I suggest you to use virtual environment tools like pipenv to control your python interpreters and modules.","Q_Score":0,"Tags":"python,windows,python-3.x,cmd","A_Id":51024834,"CreationDate":"2018-06-25T05:26:00.000","Title":"Two python3 interpreters on win10 cause misunderstanding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have many numpy arrays of shape (Ni,227,227,3), where Ni of each array is different.\nI want to join them and make array of shape (N1+N2+..+Nk,227,227,3) where k is the number of arrays.\nI tried numpy.concatenate and numpy.append but they ask for same dimension in axis 0. I am also confused on what is axis 1 and axis 2 in my arrays.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1321,"Q_Id":51017203,"Users Score":0,"Answer":"So, the main problem here was with the one of the arrays of shape (0,) instead of (0,227,227,3). \nnp.concatenate(alist,axis=0) works.","Q_Score":0,"Tags":"python,numpy,concatenation","A_Id":51192080,"CreationDate":"2018-06-25T06:08:00.000","Title":"numpy concatenate multiple arrays arrays","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I installed the new version of python 3.6.5, JGRASP was using the previous version, how can I use the new version on JGRASP?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":512,"Q_Id":51018026,"Users Score":0,"Answer":"By default, jGRASP will use the first \"python\" on the system path. \nThe new version probably only exists as \"python3\". If that is the case, install jGRASP 2.0.5 Beta if you are using 2.0.4 or a 2.0.5 Alpha. Then, go to \"Settings\" > \"Compiler Settings\" > \"Workspace\", select language \"Python\" if not already selected, select environment \"Python 3 (python 3) - generic\", hit \"Use\" button, and \"OK\" the dialog.","Q_Score":0,"Tags":"python,python-3.x,macos,jgrasp","A_Id":51036825,"CreationDate":"2018-06-25T07:13:00.000","Title":"How can I update Python version when working on JGRASP on mac os?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have an empty data frame with about 120 columns, I want to fill it using data I have in a file.\nI'm iterating over a file that has about 1.8 million lines.\n(The lines are unstructured, I can't load them to a dataframe directly)\nFor each line in the file I do the following:\n\nExtract the data I need from the current line\nCopy the last row in the data frame and append it to the end df = df.append(df.iloc[-1]). The copy is critical, most of the data in the previous row won't be changed.\nChange several values in the last row according to the data I've extracted df.iloc[-1, df.columns.get_loc('column_name')] = some_extracted_value\n\nThis is very slow, I assume the fault is in the append.\nWhat is the correct approach to speed things up ? preallocate the dataframe ? \nEDIT:\nAfter reading the answers I did the following:\n\nI preallocated the dataframe (saved like 10% of the time)\nI replaced this : df = df.append(df.iloc[-1]) with this : df.iloc[i] = df.iloc[i-1] (i is the current iteration in the loop).(save like 10% of the time).\nDid profiling, even though I removed the append the main issue is copying the previous line, meaning : df.iloc[i] = df.iloc[i-1] takes about 95% of the time.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":51018628,"Users Score":0,"Answer":"The Fastest way would be load to dataframe directly via pd.read_csv()\nTry separating the logic to clean out unstructured to structured data and then use pd.read_csv to load the dataframe.\nYou can share the sample unstructured line and logic to take out the structured data, So that might share some insights on the same.","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":51018770,"CreationDate":"2018-06-25T07:56:00.000","Title":"How to add rows to pandas dataframe with reasonable performance","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an empty data frame with about 120 columns, I want to fill it using data I have in a file.\nI'm iterating over a file that has about 1.8 million lines.\n(The lines are unstructured, I can't load them to a dataframe directly)\nFor each line in the file I do the following:\n\nExtract the data I need from the current line\nCopy the last row in the data frame and append it to the end df = df.append(df.iloc[-1]). The copy is critical, most of the data in the previous row won't be changed.\nChange several values in the last row according to the data I've extracted df.iloc[-1, df.columns.get_loc('column_name')] = some_extracted_value\n\nThis is very slow, I assume the fault is in the append.\nWhat is the correct approach to speed things up ? preallocate the dataframe ? \nEDIT:\nAfter reading the answers I did the following:\n\nI preallocated the dataframe (saved like 10% of the time)\nI replaced this : df = df.append(df.iloc[-1]) with this : df.iloc[i] = df.iloc[i-1] (i is the current iteration in the loop).(save like 10% of the time).\nDid profiling, even though I removed the append the main issue is copying the previous line, meaning : df.iloc[i] = df.iloc[i-1] takes about 95% of the time.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":51018628,"Users Score":0,"Answer":"Where you use append you end up copying the dataframe which is inefficient. Try this whole thing again but avoiding this line: \ndf = df.append(df.iloc[-1]) \nYou could do something like this to copy the last row to a new row (only do this if the last row contains information that you want in the new row): \ndf.iloc[...calculate the next available index...] = df.iloc[-1]\nThen edit the last row accordingly as you have done \ndf.iloc[-1, df.columns.get_loc('column_name')] = some_extracted_value","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":51018824,"CreationDate":"2018-06-25T07:56:00.000","Title":"How to add rows to pandas dataframe with reasonable performance","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to download a package to call sc2 and when I write pip install sc2 into cmd prompt, I receive the error:\n\nCommand \"python setup.py egg_info\" failed with error code 1 in c:\\users\\user\\appdata\\local\\temp\\pip-install-q3ixb0\\websockets.\n\nAny help?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":892,"Q_Id":51020212,"Users Score":0,"Answer":"Maybe are you behind a proxy or not connected? has you try to make ping to any url ?","Q_Score":0,"Tags":"python,pip","A_Id":51020333,"CreationDate":"2018-06-25T09:28:00.000","Title":"Pip install Command \"python setup.py egg_info\" failed with error code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to download a package to call sc2 and when I write pip install sc2 into cmd prompt, I receive the error:\n\nCommand \"python setup.py egg_info\" failed with error code 1 in c:\\users\\user\\appdata\\local\\temp\\pip-install-q3ixb0\\websockets.\n\nAny help?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":892,"Q_Id":51020212,"Users Score":1,"Answer":"easy_install Worked of me.\neasy_install sc2","Q_Score":0,"Tags":"python,pip","A_Id":51020599,"CreationDate":"2018-06-25T09:28:00.000","Title":"Pip install Command \"python setup.py egg_info\" failed with error code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to pass data from scenario 1 to scenario 2 are there any inbuilt methods exists? \nscenario1: I am generating user with details\nscenarioa2: I want to fetch generated user name from scenario1 and use in further steps","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1100,"Q_Id":51021969,"Users Score":0,"Answer":"I think instead of messing with logics of behave, you should save that data on excel data or any file, then parse that data on your other function.","Q_Score":1,"Tags":"cucumber,python-behave","A_Id":64811486,"CreationDate":"2018-06-25T11:03:00.000","Title":"output of scenario 1 to pass as input to scenario 2 in cucumber python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've spent a good deal of time trying to find out what these \"subsample\", \"colsample_by_tree\", and \"colsample_bylevel\" actually did in XGBClassifier() but I can't exactly find out what they do. Can someone please explain briefly what it is they do?\nThanks!","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":13307,"Q_Id":51022822,"Users Score":14,"Answer":"The idea of \"subsample\", \"colsample_by_tree\", and \"colsample_bylevel\" comes from Random Forests. \nIn it, you build an ensemble of many trees and then group them together when making a prediction. \nThe \"random\" part happens through random sampling of the training samples for each tree (bootstrapping), and building each tree (actually each tree's node) only considering a random subset of the attributes.\nIn other words, for each tree in a random forest you:\n\nSelect a random sample from the dataset to train this tree;\nFor each node of this tree, use a random subset of the features.\nThis avoids overfitting and decorrelates the trees.\n\nSimilarly to random forests, XGB is an ensemble of weak models that when put together give robust and accurate results.\nThe weak models can be decision trees, which can be randomized in the same way as random forests.\nIn this case:\n\n\"subsample\" is the fraction of the training samples (randomly selected) that will be used to train each tree.\n\"colsample_by_tree\" is the fraction of features (randomly selected) that will be used to train each tree.\n\"colsample_bylevel\" is the fraction of features (randomly selected) that will be used in each node to train each tree.","Q_Score":8,"Tags":"python-3.x,xgboost","A_Id":56691091,"CreationDate":"2018-06-25T11:50:00.000","Title":"subsample, colsample_bytree, colsample_bylevel in XGBClassifier() Python 3.x","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Please suggest a way to execute SQL statement and pandas dataframe .to_sql() in one transaction\nI have the dataframe and want to delete some rows on the database side before insertion\nSo basically I need to delete and then insert in one transaction using .to_sql of dataframe\nI use sqlalchemy engine with pandas.df.to_sql()","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1173,"Q_Id":51023642,"Users Score":0,"Answer":"After further investigation I realized that it is possible to do only with sqllite3, because to_sql supports both sqlalchemy engine and plain connection object as conn parameter, but as a connection it is supported only for sqllite3 database\nIn other words you have no influence on connection which will be created by to_sql function of dataframe","Q_Score":1,"Tags":"python,pandas,dataframe,transactions,sqlalchemy","A_Id":51035810,"CreationDate":"2018-06-25T12:36:00.000","Title":"Python pandas dataframe transaction","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a PWA for a friend. the database has users and the users have json strings associated with them. I know that I can just ask the database for that user's Json in html or js, but I want to know if its possible to have the database look at that json String, and automatically divvy out the details in it to the database say every hour. \nI know there is a simpler way of just putting the json string in the database under the user, then just parsing it when the user logs into the page and asks for it. just wondering if I can skip a step and just make the database auto update the json string into the DB itself.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":51024428,"Users Score":0,"Answer":"Yes, you may use crontab to schedule tasks for your system to complete. Update the database information using one of these tasks. You may also use Celery, but crontab is easier to implement.","Q_Score":0,"Tags":"python,sql,json,django,pwa","A_Id":51025459,"CreationDate":"2018-06-25T13:16:00.000","Title":"Json Database. I want to get a number from a json string and put it into a database.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a html page with text box and submit button. When somebody enters data in text box and click submit, i have to pass that value to a python script which does some operation and print output. Can someone let me now how to achieve this. I did some research on stackoverflow\/google but nothing conclusive. I have python 2.7, Windows 10 and Apache tomcat. Any help would be greatly appreciated.\nThanks,\nJagadeesh.K","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":222,"Q_Id":51024719,"Users Score":0,"Answer":"Short answer:  You can't just run a python script in the clients browser.  It doesn't work that way.\nIf you want to execute some python when the user does something, you will have to run a web app like the other answer suggested.","Q_Score":0,"Tags":"python,windows,apache,flask","A_Id":51027426,"CreationDate":"2018-06-25T13:30:00.000","Title":"Passing command line parameters to python script from html page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When talking about imbalanced datasets, most articles would refer to maximising the prediction of the minority class (e.g. for fraud detection). I have an imbalanced dataset (ratio approximately 1:20). where I am interested to achieve the highest prediction accuracy for the majority class. My work is in Python. Possible solutions I have researched are:\n\nOversampling of the minority class\nChanging the loss\/cost matrix for some classification models\n\nWhat are the pros and cons of using each method? Are there any other methods I could try?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":129,"Q_Id":51025178,"Users Score":0,"Answer":"You are thinking about this the wrong way. If all you cared about was the majority class, you could just predict everything as belonging to the majority class. You'd get 100% of them right. You would have lots of false positives, but you don't care about those right? \nAh, if you do care about the false positives, then that means you actually care about the minority class after all. The more things in the minority class you predict correctly, the less false positives you have. \nThis is two sides of the same coin.","Q_Score":0,"Tags":"python,optimization,classification,data-science","A_Id":51275886,"CreationDate":"2018-06-25T13:53:00.000","Title":"Maximising prediction accuracy of the majority class in an imbalanced dataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I do have a problem which many people faced already, but after searching through different solutions for hours, I still haven't solved my problem.\nFor a project, I need Phyton to read my Data from my arduino-uno. Therefore I need the import serial (or import pyserial, I tried both) this doesn't work. I tried installing the library (not really sure where to store it than) but that didn't help either. I also tried using \"pip install pyserial\" in the console, but that didn't work as well.\nWhatever i do i allwas get this error:\n\n\n\npip install pyserial\n        File \"\", line 1\n          pip install pyserial\n                    ^\n      SyntaxError: invalid syntax\n\n\n\nI reinstalled Python now as 2.7 and deleted everything Python related. But when i put in pip install pyserial i still geht the same Error\nCould someone please help me with this?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11832,"Q_Id":51025585,"Users Score":0,"Answer":"Problem Solved!\nSeems like my computer doesn't like python.\nThanks for your help","Q_Score":1,"Tags":"python,arduino-uno","A_Id":51068968,"CreationDate":"2018-06-25T14:13:00.000","Title":"Import serial to 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 a week old in gremlin and graph databases. My question is: Is there a way to add nodes to the graph database using gremlin-python ? \nAny help is appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":51026783,"Users Score":2,"Answer":"The gremlin-python library gives you full access to the Gremlin language which includes mutating steps like addV() for adding vertices and addE() for adding edges...so, sure, just use Gremlin to add vertices\/edges in python as you would with any other language that Gremlin supports.","Q_Score":0,"Tags":"python,graph-databases,gremlin","A_Id":51027498,"CreationDate":"2018-06-25T15:15:00.000","Title":"How to add nodes continuously in graph databases using gremlin-python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently found an article that indicates that the conventional methods for downloading python machine learning modules such as tensorflow and keras are not optimized for computers with a cpu.  How can I configure tensorflow and keras to make it most compatible with my processor on MacOSX in python 2.7?  \nIf it helps, I use pycharm to download most of my libraries and for my coding interface.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":784,"Q_Id":51026983,"Users Score":0,"Answer":"I think what you read meant that tensorflow programs work much faster if your computer has a GPU. You need a Nvidia GPU in your computer to install tensorflow with GPU support on your Mac and as far as I know, after version 1.2 tensorflow no longer provides GPU support for MacOS","Q_Score":1,"Tags":"python,macos,python-2.7,tensorflow,cpu","A_Id":51027093,"CreationDate":"2018-06-25T15:25:00.000","Title":"Install Keras\/Tensorflow on Mac with cpu python2.7","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was using scrapy framework which is running fine. But suddenly today when i crawl my spider, i experience this error\n\n2018-06-25 21:33:22 [scrapy.utils.log] INFO: Scrapy 1.5.0 started\n  (bot: sam_amazon) Traceback (most recent call last):   File\n  \"C:\\Users\\sa\\Anaconda3\\Scripts\\scrapy-script.py\", line 5, in \n      sys.exit(scrapy.cmdline.execute())   File \"C:\\Users\\sa\\Anaconda3\\lib\\site-packages\\scrapy\\cmdline.py\", line 149,\n  in execute\n      cmd.crawler_process = CrawlerProcess(settings)   File \"C:\\Users\\sa\\Anaconda3\\lib\\site-packages\\scrapy\\crawler.py\", line 252,\n  in init\n      log_scrapy_info(self.settings)   File \"C:\\Users\\sa\\Anaconda3\\lib\\site-packages\\scrapy\\utils\\log.py\", line\n  149, in log_scrapy_info\n      for name, version in scrapy_components_versions()   File \"C:\\Users\\sa\\Anaconda3\\lib\\site-packages\\scrapy\\utils\\versions.py\",\n  line 35, in scrapy_components_versions\n      (\"pyOpenSSL\", _get_openssl_version()),   File \"C:\\Users\\sa\\Anaconda3\\lib\\site-packages\\scrapy\\utils\\versions.py\",\n  line 43, in _get_openssl_version\n      import OpenSSL   File \"C:\\Users\\sa\\Anaconda3\\lib\\site-packages\\OpenSSL__init__.py\", line 8,\n  in \n      from OpenSSL import crypto, SSL   File \"C:\\Users\\sa\\Anaconda3\\lib\\site-packages\\OpenSSL\\crypto.py\", line 16,\n  in \n      from OpenSSL._util import (   File \"C:\\Users\\sa\\Anaconda3\\lib\\site-packages\\OpenSSL_util.py\", line 6, in\n  \n      from cryptography.hazmat.bindings.openssl.binding import Binding   File\n  \"C:\\Users\\sa\\Anaconda3\\lib\\site-packages\\cryptography\\hazmat\\bindings\\openssl\\binding.py\",\n  line 13, in \n      from cryptography.hazmat.bindings._openssl import ffi, lib ImportError: DLL load failed: The operating system cannot run %1.\n\nI have tried to uninstall and install scrapy again. But it did not work. Please help. I am stuck with this error.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":474,"Q_Id":51027761,"Users Score":0,"Answer":"My Problem is solved by installing the previous version of openssl.","Q_Score":0,"Tags":"python,scrapy","A_Id":51040202,"CreationDate":"2018-06-25T16:10:00.000","Title":"Suddenly, scrapy stops working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Connectivity to pypi.org is blocked in corporate windows laptop hence not able to install pip,selenium etc... Is there any other way to achieve this?\nERROR \n\nH:\\script>python get-pip.py Collecting pip   Retrying (Retry(total=4,\n  connect=None, read=None, redirect=None, status=None)) after connection\n  broken by\n  'ConnectTimeoutError(, 'Connection to pypi.org timed out.\n  (connect timeout=15)')': \/simple\/pip\/ Operation cancelled by user","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":450,"Q_Id":51035406,"Users Score":2,"Answer":"Use proxy to install python packages on corporate servers behind firewall. \nsomething like this:\npip install --proxy www-proxy.xxxxxxx.com:8080 psutil","Q_Score":1,"Tags":"python","A_Id":53090042,"CreationDate":"2018-06-26T05:25:00.000","Title":"Not able to install python modules such as pip,selenium etc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using dlib's correaltion tracker and would like to restart it on some que. When \nI pass None as the image it crashes. How can I tell the tracker a new video is starting?\nI'm using multiple thread and would not like to open a new tracker every time. \nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":213,"Q_Id":51037016,"Users Score":0,"Answer":"Call the correlation_tracker's start_track() member function.","Q_Score":0,"Tags":"python,tracking,dlib","A_Id":51041372,"CreationDate":"2018-06-26T07:17:00.000","Title":"How to restart dlib's correlation tracker","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If the dataset contains features some of which are Categorical Variables and some of the others are continuous variable Decision Tree is better than Linear Regression,since Trees can accurately divide the data based on Categorical Variables. Is there any situation where Linear regression outperforms Random Forest?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":9961,"Q_Id":51037363,"Users Score":3,"Answer":"There for sure have to be situations where Linear Regression outperforms Random Forests, but I think the more important thing to consider is the complexity of the model.\nLinear Models have very few parameters, Random Forests a lot more. That means that Random Forests will overfit more easily than a Linear Regression.","Q_Score":5,"Tags":"python,data-science","A_Id":51039032,"CreationDate":"2018-06-26T07:35:00.000","Title":"Linear Regression vs Random Forest performance accuracy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If the dataset contains features some of which are Categorical Variables and some of the others are continuous variable Decision Tree is better than Linear Regression,since Trees can accurately divide the data based on Categorical Variables. Is there any situation where Linear regression outperforms Random Forest?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":9961,"Q_Id":51037363,"Users Score":2,"Answer":"Key advantages of linear models over tree-based ones are:\n\nthey can extrapolate (e.g. if labels are between 1-5 in train set, tree based model will never predict 10, but linear will)\ncould be used for anomaly detection because of extrapolation\ninterpretability (yes, tree based models have feature importance, but it's only a proxy, weights in linear model are better)\nneed less data to get good results\nhave strong online learning implementations (Vowpal Wabbit), which is crucial to work with giant datasets with a lot of features (e.g. texts)","Q_Score":5,"Tags":"python,data-science","A_Id":51062800,"CreationDate":"2018-06-26T07:35:00.000","Title":"Linear Regression vs Random Forest performance accuracy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was surprised to be unable to find any information anywhere on the web on how to do this properly, but I suppose my surprise ought to be mitigated by the fact that normally this can be done via Microsoft's 'Add or Remove Programs' via the Control Panel. \nThis option is not available to me at this time, since I had installed Python again elsewhere (without having uninstalled it), then uninstalled that installation the standard way. Now, despite no option for uninstalling conda via the Control Panel, conda persists in my command line.\nNow, the goal is to remove every trace of it, to end up in a state as though conda never existed on my machine in the first place before I reinstall it to the necessary location. \nI have a bad feeling that if I simply delete the files and then reinstall, this will cause problems. Does anyone have any guidance in how to achieve the above?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":12353,"Q_Id":51039936,"Users Score":6,"Answer":"Open the folder where you installed miniconda, and then search for uninstall.exe. Open that it will erase miniconda for you.","Q_Score":6,"Tags":"python,windows,conda,uninstallation,miniconda","A_Id":65146967,"CreationDate":"2018-06-26T09:53:00.000","Title":"How to uninstall (mini)conda entirely on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python-gnupg to decrypt files I am downloading that are encrypted. I have already built an executable that works perfectly but the issue I am having is when I run it as a Windows Service. For some odd reason when I install and run my executable as a Windows Service it fails to decrypt my files. \nI think my issue may be with the scope of the service\/where my files reside but I can't seem to find out why. I have added the path to gpg.exe to my PATH environment variable for the system and the gpg files are in my C: drive (not a local users).  \nI am using Kleopatra to store my certificates as well. \nSo essentially there is some conflict between GPG and Windows Services and I cannot figure out why. Any help would be greatly appreciated, thank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":575,"Q_Id":51044613,"Users Score":1,"Answer":"by giving a direct path to the gpg home directory and to the gpg binary location within my python script like this gpg = gnupg.GPG(gnupghome=\"C:\\path_to_gnupg\" ,gpgbinary=\"C:\\path_to_gpg.exe\") the service was able to run directly. It must have been having troubles locating the secret keys on its own.","Q_Score":1,"Tags":"python,windows,service,gnupg","A_Id":51066237,"CreationDate":"2018-06-26T13:53:00.000","Title":"GPG Decryption Using Python (as a Windows Service)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to figure out the minimum amount of room I will need to train neural networks on my machine. Often times (image) data sets are relatively small in their raw forms, but when we transform them (in keras w\/ flow_from_dir) we augment the images and kind of multiply the size of the data set to our desire. \nMy question is: how does flow_from_directory work with storing the augmented images? If I don't specify that the images need to be stored (parameter of the class) does keras augment the image, train with it and discard it or does it save it for a period of time, weighing down my computer until training is over?\nAlso, would those images be in persistent memory or RAM? Thank you in  advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":369,"Q_Id":51048421,"Users Score":0,"Answer":"By default, ImageDataGenerator does data augmentation on the fly and does not store the augmented images anywhere. As you mention, doing so would require too much space. So you should only worry about having enough RAM to fit a certain number of augmented batches, not the whole dataset.","Q_Score":0,"Tags":"python-3.x,tensorflow,machine-learning,neural-network,keras","A_Id":51051880,"CreationDate":"2018-06-26T17:21:00.000","Title":"how does Keras flow_from_directory affect computer storage?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a program which uses multiple cores to process images before drawing to a canvas for a main view (using multiprocessing). I would like to know the best way to tackle this problem.\nIs it possible to have each core drawing to its own canvas which are layered on-top of each other in the same view? Is it possible to have this behavior?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":588,"Q_Id":51048950,"Users Score":2,"Answer":"No, it is not possible. GUI widgets cannot be shared between processes. On some platforms, it just isn't possible at all; on other platforms, it would be possible, but only by doing things very differently from the way Tk does; on others, it sort of works, but the event loops are all screwed up. So, the result may be that nothing shows up, that one or both processes freezes, that the GUI doesn't respond to events, that tkinter raises an exception in the child, that tkinter creates a whole separate independent GUI, or, if you're really unlucky, that things unpredictably work sometimes but do one of the other things other times.\n\nHowever, that doesn't mean there's no way to do what you want, just that you can't do it directly.\nThe simplest solution is to marshal your Canvas commands and pass them over a Pipe or Queue for the main process to execute.\nA fully general solution isn't that hard, but in your case, it should be even simpler: all you want the background process to do is process an image and then display it. So the only Canvas command you need is create_image.\nAnd, in fact, you can probably do with tasks on a Pool, which just return the image when they're done, with the main process doing the create_image with the results.\nMixing waiting on multiprocessing async results with a tkinter event loop is a bit of a pain, but if you use concurrent.futures, you can just attach the create_image as a callback on the Future returned by the task.\n\nA different option is to have the background processes create off-screen Canvas objects, draw to them, then capture the results as a BitmapImage or a postscript rendering, which you can then pass to the main process to blit onto a Canvas of its own. But this is a lot more complicated; I think the other solution will probably work a lot better for you.","Q_Score":0,"Tags":"python,tkinter,multiprocessing,tkinter-canvas","A_Id":51049107,"CreationDate":"2018-06-26T17:57:00.000","Title":"Python Multiprocessing Drawing to Tkinter Canvas","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a 2D platformer using my own engine in Python\/Pygame and have made a good start. I've also made a level designer that exports the level tile map and the game imports it, but I need to associate different things, like switches that open specific doors (or to be more precise, pressure plates that hold a specific door open) but my tile map array currently only holds the tile image index number. What's the best way to include associated tiles (like which switch opens which door etc)?\nDo I make an extra file with that data? Or do I have 2 values for each tile? I've tried Googling, but it's not really covered anywhere. I'm sure there's someone with this kind of experience out there... I don't really want to hard-code it in as I want the game to be as versatile as possible.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":921,"Q_Id":51051198,"Users Score":1,"Answer":"I would change your file format from storing one tile index per 2D cell to storing some more complex data object.  My first thought would be a dictionary per cell for maximum flexibility moving forward, but serializing that and storing it will be quite large.  There's a trade-off here between flexibility and storage size.\nAnother option would be using NamedTuples to store a fixed number of parameters per cell, while preserving a concise serialization.  NamedTuples are nice because they let you very concisely represent a data object in a way that both serializes well and can be queried into using named fields.\nThe questions you need to ask yourself are \"what metadata do I need to know about each cell on the map\" and \"how much do I care about concise file size to represent them\".","Q_Score":0,"Tags":"python,pygame,game-engine","A_Id":51051536,"CreationDate":"2018-06-26T20:51:00.000","Title":"Best way to save a 2D Pygame platformer level tile map with extra data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I already installed python3.5.2, tensorflow(with python3.5.2).\nI want to install protobuf now. However, protobuf supports python3.5.0; 3.5.1; and 3.6.0\nI wonder which version should I install.\nMy question is should I upgrade python3.5.2 to python3.6, or downgrade it to python3.5.1.\nI see some people are trying downgrade python3.6 to python3.5\nI googled how to change python3.5.2 to python3.5.1, but no valuable information. I guess this is not usual option.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":51053760,"Users Score":0,"Answer":"So it is version problem\none google post says change python version to a more general version.\nI am not sure how to change python3.5.2 to python3.5.1\nI just installed procobuf3.6\nI hope it works","Q_Score":0,"Tags":"python,tensorflow,protocol-buffers","A_Id":51164732,"CreationDate":"2018-06-27T02:35:00.000","Title":"protobuf, and tensorflow installation, which version to choose","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I successfully added a new JDBC interpreter to my preferred DB, by using the normal zeppelin UI. It works. My Zeppelin is running on a docker container on my machine. I noticed it added my interpreter configuration to \/zeppelin\/conf\/interpreter.json file.\nI extracted the piece of json that was inserted on the file, under interpreterSettings collection. I built a script that would programmatically add that json block to \/zeppelin\/conf\/interpreter.json so that my container would start with that interpreter configured out of the box.\nBut after I run my script on a brand new Zeppelin container what happen is that:\n 1) it works - the piece of json is successfully inserted into \/zeppelin\/conf\/interpreter.json\n 2) Zeppelin won't show my interpreter on its UI\nWhat else must I do to programmatically add this interpreter to my Zeppelin container?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":351,"Q_Id":51055457,"Users Score":0,"Answer":"I believe you approach will work in new version 0.8.0. In 0.8.0 interpreter ID equals interpreter name.\nIn previous versions interpreters have unique ID and this maybe reason of your question.\nRemember that Zeppelin server must be off while editing conf\/interpreter.json","Q_Score":0,"Tags":"python,docker,jdbc,interpreter,apache-zeppelin","A_Id":51195921,"CreationDate":"2018-06-27T05:56:00.000","Title":"How to add a new jdbc interpreter to Zeppelin by editing its conf\/interpreter.json file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I successfully added a new JDBC interpreter to my preferred DB, by using the normal zeppelin UI. It works. My Zeppelin is running on a docker container on my machine. I noticed it added my interpreter configuration to \/zeppelin\/conf\/interpreter.json file.\nI extracted the piece of json that was inserted on the file, under interpreterSettings collection. I built a script that would programmatically add that json block to \/zeppelin\/conf\/interpreter.json so that my container would start with that interpreter configured out of the box.\nBut after I run my script on a brand new Zeppelin container what happen is that:\n 1) it works - the piece of json is successfully inserted into \/zeppelin\/conf\/interpreter.json\n 2) Zeppelin won't show my interpreter on its UI\nWhat else must I do to programmatically add this interpreter to my Zeppelin container?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":351,"Q_Id":51055457,"Users Score":0,"Answer":"My problem was happening because after the Zeppelin container started, it was already too late. Zeppelin service was up and running and it would have already loaded interpreter.json. So, what I did was to configure my Dockerfile ENTRYPOINT to a script of mine, overwriting the standard Zeppelin container's entry point. My script would do the injection of the additional configurations I needed on interpreter.json file and call \/zeppelin\/bin\/zeppelin.sh to start zeppelin.\nThis way, I could do whatever I want with the configuration files BEFORE Zeppelin was actually started inside the container. \nKind regards,\nAS","Q_Score":0,"Tags":"python,docker,jdbc,interpreter,apache-zeppelin","A_Id":51215244,"CreationDate":"2018-06-27T05:56:00.000","Title":"How to add a new jdbc interpreter to Zeppelin by editing its conf\/interpreter.json file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm still new to writing scripts with Python and would really appreciate some guidance.\nI'm wondering how to continue executing my Python script from where it left off after a system restart.\nThe script essentially alternates between restarting and executing a task for example: restart the system, open an application and execute a task, restart the system, open another application and execute another task, etc... \nBut the issue is that once the system restarts and logs back in, all applications shut down including the terminal so the script stops running and never executes the following task. The program shuts down early without an error so the logs are not really of much use. Is there any way to reopen the script and continue from where it left off or prevent applications from being closed during a reboot ? Any guidance on the issue would be appreciated.\nThanks!\nAlso, I'm using a Mac running High Sierra for reference.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1385,"Q_Id":51055649,"Users Score":0,"Answer":"You could write your current progress to a file just before you reboot and read said file on Programm start.\nAbout the automatic restart of the script after reboot: you could have the script to put itself in the Autostart of your system and after everything is done remove itself from it.","Q_Score":2,"Tags":"python,scripting-language","A_Id":51055706,"CreationDate":"2018-06-27T06:09:00.000","Title":"How to Resume Python Script After System Reboot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am making a school-related app for school using Python and the PeeWee module. Everything is working fine, but the problem I am facing is as follows:\nWhen creating user accounts, a student account can ONLY be created if there is at least 1 teacher account in the database (every student gets a teacher assigned). How do I check if my teacher table has any instances? I want to check this before a student user account can be made.\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":385,"Q_Id":51055956,"Users Score":0,"Answer":"If I understand your problem clearly then it seems you need foreign key in student table. If you have column like teacher_id in student table then do the below steps\n\nCreate primary key for id in teacher table\nCreate foreign key for teacher_id in student table and teacher_id is not null\n\nOnce you have foreign key in student table then database will automatically will check teacher exists or not. if teacher not exists then it will throw error.","Q_Score":0,"Tags":"python,database,peewee","A_Id":51061550,"CreationDate":"2018-06-27T06:29:00.000","Title":"Checking if a table has records - Peewee module","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am building a machine learning model to forecast future prices in scikit-learn. The dependent variable price is not normally distributed, thus, I will perform log transformation on only dependent variable price using np.log(price).  After this, I will split complete data-set into train and test sets. Thus y_train and y_test both are now log transformed prices. After machine learning model fitting, I have to calculate forecasting performance metrics like MAPE error for the fitted model.\n\nShould the data (price) be transformed back to its original scale before calculating MAPE using np.exp() for both model.predict method and y_test set ?  \nOr we should first split the data into train and test, apply log transformation on training set y_train only, after this apply inverse transform on model.prediction set. Thus, y_test set (original) and np.exp(model.predict()) would then be used to calculate MAPE  \nOr the values of MAPE or MAE metric is independent of scaling of response variable y and MAPE can be reported using transformed log values of dependent variable price?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":514,"Q_Id":51057993,"Users Score":0,"Answer":"I would say that in your circumstance it is necessary to scale back to true prices. This is not an absolute statement, but really depends on the setup of your problem: if you have a true price that is \"1\", then its log will be \"0\" and, whatever you predict for that single point, you'll get undefined \/ infinite MAPE. So I'd say yes, at least scale it back to exp before doing it.\nAlso I don't understand the difference between \"1\" and \"2\": they seem identical to me, in \"1\" you're just taking the log of the price for the test set and then taking the exp again, in \"2\" you're just avoiding doing the two operations...\nAs for \"3\", no, definitely they aren't independent on all transformations - in particular not log. MAPE is only independent to rescaling data by a constant factor, MAE by shifting it by a constant addend.\nOn this point, beware that no measure gives a perfect truth and you might get very bad results just applying them. For example, using MAPE, if you have something with price of 1 cent and you're estimating it at 1$ you'll give it the same (huge) error as if it had price 1000$ and you're estimating it at 100k. On the other hand, since you're taking logs in training, that's basically the same rule you're using to train your model, so it might not be catastrophic. Just beware if you have true prices that are very close to, or worse exactly, 0.\n(MAE is probably worse in this case, because it will basically give all the weight to the few very expensive items in your database, but I can't say for sure from here)","Q_Score":2,"Tags":"python,logging,machine-learning,transformation,metrics","A_Id":51058681,"CreationDate":"2018-06-27T08:24:00.000","Title":"Evaluation of Forecasting performance Metric on original or transformed Dependent Variable","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to test a function that should return an OSError if it can't find a specific key in os.environ, but I can't figure out how to mock it.\nI'm fine with mocking os.environ completely empty as well.\nwith mock.patch.dict('os.environ', dict()):\n    print(os.environ)\nor\nwith mock.patch.dict(os.environ, dict()):\n    print(os.environ)\nWill print my entire environment regardless.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":248,"Q_Id":51061288,"Users Score":0,"Answer":"I've resorted to MonkeyPatching the os.environ instead:\n\n        old_os_environ = os.environ\n        try:\n            os.environ = {}\n            self.assertRaises(OSError, my_function)\n        finally:\n            os.environ = old_os_environ","Q_Score":0,"Tags":"python,mocking","A_Id":51065775,"CreationDate":"2018-06-27T11:10:00.000","Title":"Mocking a key away from os.environ","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem with \"TESSEROCR\" python library.\nI am using ubuntu 16 (remote connection) , python 3.6, tesseract 4.\nI have managed to install it using PIP or CPPFLAGS=-I\/usr\/local\/include pip install tesserocr method.\nHowever the problem is:\nOnce I open Python and type: import tesserocr python shuts down and I'm back into terminal. I tried to reinstall, build from source and even multiple combination of different versions. \nI have no idea where to look for.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":273,"Q_Id":51062268,"Users Score":0,"Answer":"So there are two problems which I faced while installing Tesserocr library to use System Tesserocr:\n\nI needed to install python-dev as the TesserOCR Library has some dependences which are available only in python-dev. sudo apt install python3-dev\nYou need to set your locale, for which I used export LC_ALL=C.\n\nAfter activating my virtualenv, I did simply pip install tesserocr and it worked like charm.","Q_Score":0,"Tags":"python,ubuntu,tesseract","A_Id":59137298,"CreationDate":"2018-06-27T11:59:00.000","Title":"Tesserocr crashes 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":1,"Web Development":0},{"Question":"I am using tempfile.mkstemp to generate a random available filename and write some content with os.fdopen. I then pass the filename to a task via celery. \nThis task opens the file, processes the content, and finally removes the file.\nIn testing this works fine, however I have realised that this will break in my live environment where the user running the task is not the same as the one which creates the file. \nThis means that the user cannot open the file because tempfile.mkstemp sets the permissions to 600(-rw-------). \nI cannot make both processes run by the same user, so is there some way to modify the file permissions set by tempfile.mkstemp? \nI am running Python 3.6 on Ubuntu 14.04.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1930,"Q_Id":51063378,"Users Score":4,"Answer":"Given that you use os.fdopen after you call mkstemp(), you may be better off using tempfile.NamedTemporaryFile(delete=False). It returns a Python file object instead of an fd.\nEither way, the returned file will have mode=0600, so you will need to change it. Use os.fchmod(temp_file.fileno(), 0640) or similar (change the mode as per your needs).","Q_Score":3,"Tags":"python,file-permissions,mkstemp","A_Id":51063833,"CreationDate":"2018-06-27T12:56:00.000","Title":"tempfile.mkstemp permissions settings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"As the title suggests, is there a builtin library for moving a file and replacing an existing file if it exists?\nI tried os.rename(path1, path2), but that doesn't seem to handle overwriting existing files.\nWorking with a pycom gpy, if that matters.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":51063878,"Users Score":1,"Answer":"POSIX semantics require overwriting the target file in this case (and even atomically). So, \"pycom gpy\" seems to have a bug (or misfeature) in that regard. As a workaround, you can remove the target file with os.remove(path2) before rename.","Q_Score":0,"Tags":"micropython","A_Id":52769675,"CreationDate":"2018-06-27T13:19:00.000","Title":"Is there a builtin library for moving and replacing a file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run a function written in matlab in a python script using matlab.engine.\nThe first time I run the script everything works fine, but when I try to run the script again I get the error \"ImportError: cannot import name 'TimeoutError'\" on importing the matlab engine. Restarting the kernel allows me to run the script again. I am also using import matlab.engine and not from matlab.engine import to avoid circular importing.\nAny suggestions on how I can solve the issue?\nI am using Ubuntu 16.04 and working with spyder.\nMany Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":429,"Q_Id":51064328,"Users Score":0,"Answer":"I get a similar running error. But after trying several times, I found that for the same *.py manuscript, the phrase import matlab.engine and eng = matlab.engine.start_matlab() should be implemented only once\nI commented them, by doing this I can re-run the script *.py again. \nOtherwise, it will post the error\n\nImportError: cannot import name 'TimeoutError'.\n\nI think using the import matlab.engine to start a new MATLAB\u00ae process is just like to open a door before we close the door, everyone can enter the room or go out again and again, but do not need open the door again because it is not closed yet. \n\"Restarting the kernel\" is just like close the door automatically (the Python stops the engine and its MATLAB process).","Q_Score":1,"Tags":"python,matlab,matlab-engine","A_Id":55392343,"CreationDate":"2018-06-27T13:40:00.000","Title":"TimeoutError import error when using matlab engine with python 3.5","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python, what is the best to run fft using cuda gpu computation?\nI am using pyfftw to accelerate the fftn, which is about 5x faster than numpy.fftn.\nI want to use pycuda to accelerate the fft. I know there is a library called pyculib, but I always failed to install it using conda install pyculib.\nIs there any suggestions?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1084,"Q_Id":51066245,"Users Score":1,"Answer":"I want to use pycuda to accelerate the fft\n\nYou can't. PyCUDA has no built-in FFT support of any kind.","Q_Score":1,"Tags":"python,cuda,cufft","A_Id":51066356,"CreationDate":"2018-06-27T15:12:00.000","Title":"the best way to conduct fft using GPU accelaration with cuda","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 question in relation to encryption on the server.\nSo I am making a chat\/mail system in which users are able to send messages to one another.\nBefore the message is sent, I run a script on my backend that encrypts the message, my question has to do with the decrypting.\nIn my database, I have a table that holds the encrypted messages, I do not want my database to hold any decrypted message. How do get the decrypted message to the users without holding any decrypted messages on my server?\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":51069309,"Users Score":0,"Answer":"Your question is almost certainly misguided. You usually don't want to encrypt messages from one user to another on the server, and you almost never want to decrypt them on the server.\n\nFirst, the whole point of public-key encryption is that nobody but the user and their own trusted software has access to the user's private key.\nYou don't want to store users' private keys on the server\u2014that would mean that if your server gets hacked, or some disgruntled employee wants to sabotage your company, they can decrypt every message in the world. Most users won't trust such a system, and they shouldn't.\nSo you have to do the decryption on the receiving user's client, where their private key is accessible.\n\nUsually, you also want to do the encryption on the sending user's client. Otherwise, every message is being sent in plaintext to the server, where a hacker (or an unscrupulous server company) could easily steal it before it's encrypted. Again, users won't, and shouldn't, trust such a design.\nThis means the sending client needs the recipient's public key, of course. But that's easy to manage: You store everyone's public key on the server, and add a command that the sending client can use to fetch the recipient's public key.\nIn some designs, you want to use a separate out-of-band mechanism for sharing public keys instead. For example, if you're using GPG, and want to rely on its web of trust instead of using your server to manage trust in identities, you'd give the client a way to import public keys and store them, or you'd give it a way to interact with an existing key store.\n\nIf you really want to do PK encryption entirely on the server, you can. It just doesn't provide much security benefit.\nTo do this, you could store every user's private key in the database. Then, you just fetch the encrypted message and the private key and decrypt it before sending. Then the plaintext is only available in some short-lived memory buffer, instead of in the database. But notice that this is no better than just not encrypting things at all. Sure, anyone who can access your database can't directly get the decrypted messages\u2014but they can get the encrypted messages and the keys needed to decrypt them, which is just as good. In fact, it's better for the attacker, because now they can decrypt other messages using the same private key, sign messages to impersonate the user, etc.\nAlternatively, you can have the user submit the private key whenever they want to fetch a message. You then pull the encrypted message out of the database, decrypt it with the private key, and send it to the user. Now both the private key and the plaintext live only in temporary memory. But this still adds almost nothing over not encrypting at all. The messages\u2014and, worse, the private keys\u2014are traveling as plaintext over the open internet. Plus, anyone who can hack your server can't pull the private keys out of your database, but they can just store them as they come in.","Q_Score":0,"Tags":"python,encryption","A_Id":51069417,"CreationDate":"2018-06-27T18:29:00.000","Title":"Public and private key encryption delivery","Data Science and Machine Learning":0,"Database and SQL":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 long running python batch process that is processing data from a REST API. In case the program crashes or terminates for some reason I want to save info about the position of my last processing so I can restart and resume. I do not want to loose that info (store it on disk and not only in RAM).\nHow can I handle this if possible with a lightweight solution maybe without a database?\nThanks\nPhilip","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":217,"Q_Id":51070285,"Users Score":3,"Answer":"You might want to look at the python module 'shelve'.\nIt allows you to save data on disk and then retrieve it when needed.","Q_Score":0,"Tags":"python,batch-processing","A_Id":51070349,"CreationDate":"2018-06-27T19:40:00.000","Title":"Python: How do I save data even when a long running batch process crashes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"X: a list of lists, where each list element corresponds to a label in Y\nY: a binary list of labels (values are either 1 or 0)\nI want to extract the elements in X according to the value at the corresponding index in Y, as follows:\ngood = values of X where the label\/value in Y is 1\nbad = values of X where the label\/value in Y is 0\nI am still fairly new to sub-setting in Python and not really sure of a good way to do this.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":123,"Q_Id":51071467,"Users Score":0,"Answer":"list(itertools.compress(X, Y)) will get you the list of good lists. list(itertools.compress(X, [not a for a in Y])) will get you the list of bad lists.","Q_Score":0,"Tags":"python","A_Id":51071525,"CreationDate":"2018-06-27T21:11:00.000","Title":"Separate a list based on values in a second list","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the R programming language, there is a site.profile file that defines some code that R processes execute on start up. Is there similar functionality in Python?\nEdit: to clarify, this script should be executed if the user calls python from the command line, but also if python is spawned from another process (e.g. if the user's script uses subprocess to spawn another python).","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1358,"Q_Id":51071691,"Users Score":0,"Answer":"File pointed by your environmental variable PYTHONSTARTUP would be run on starting an interactive python session\nAnd USER_SITE\/usercustomize.py will be run for non-interactive python session.\nRun python -c \"import site; print(site.USER_SITE)\" to find the USER_SITE dir location","Q_Score":1,"Tags":"python,startup","A_Id":51071772,"CreationDate":"2018-06-27T21:29:00.000","Title":"Is there a way to always execute a script when python starts? (similar site.profile in R)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a dataset where over 5 years, for each person, i have 3 stats (for, against, neutral) which are represented as percentage.\nDo you have any ideas on how to plot this over time for each person ?\nI tought of a pie chart for each year, is it good idea ?\nyear|x|y|z|uniq_key\n2011|0.005835365238989241|0.7761263149278178|0.21803831983319283|P1\n2012|0.009289549431275945|0.7361277645833669|0.2545826859853564|P1\n2013|0.008078032727124805|0.7392018809692821|0.2527200863035934|P1\n2011|0.0069655450457009405|0.7275518410866034|0.26548261386769734|P2\n2012|0.008719188605542267|0.7855644106925562|0.20571640070190217|P2\n2013|0.011938649525870312|0.8028230127919557|0.1852383376821743|P2","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":51076577,"Users Score":0,"Answer":"A line chart for each stat with year on the x-axis, percentage on the y-axis and a line for each user.","Q_Score":0,"Tags":"python,matplotlib,time,statistics","A_Id":51078286,"CreationDate":"2018-06-28T07:01:00.000","Title":"how to plot different stats for every year","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a SSIS package which i am currently running using Visual Studio. I want to know is there any mechanism in python by which i can execute those SSIS packages.","AnswerCount":4,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":5401,"Q_Id":51077064,"Users Score":-2,"Answer":"You can do this with an 'Execute Process Task'.  Use the following entries\n\nExecutable: pythonw.exe\nArguments: this will be your script file\n\nStill working on cleaning up the error processing so that it can report errors better, but it is processing the script correctly.","Q_Score":2,"Tags":"python,ssis,etl","A_Id":63284951,"CreationDate":"2018-06-28T07:26:00.000","Title":"How to execute SSIS ETL package using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running a miner on my Raspberry Pi at 100% CPU performance. I want the Raspberry Pi to send some tweets about his temperature and Hashrate over twitter. So far I've written a script which does its job well... To keep the miners performance it's important for me which method consumes less power\/performance.\nWhat would you use? Cronjobs or sleep?\nAny help would be very appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":51077547,"Users Score":2,"Answer":"Cronjobs should be more efficient. There are always being check out by the system, if you use sleep you would be still checking for cronjobs (even if there's no job to run) so sleep is innecesary.","Q_Score":1,"Tags":"python,performance,cron,sleep","A_Id":51077745,"CreationDate":"2018-06-28T07:53:00.000","Title":"Do cronjobs have better performance than sleep 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just out of curiosity, if dask enables both len() and size, why is there not shape as well?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":660,"Q_Id":51080681,"Users Score":2,"Answer":"This has been discussed in dask. First I'll point out that in the python spec, len() is always supposed to return a concrete integer. Dask respects this, and so len(df) blocks, unlike most operations on a data-frame. There is no such constraint on .size, which is therefore lazy.\nThe metadata of the dataframe is immediately available, however, the number, names and types of the columns are known without computing any of the data. Therefore, .shape would be a combination of a known value and either a lazy or a slowly-computed concrete value. This doesn't seem necessary.","Q_Score":0,"Tags":"python,dataframe,dask","A_Id":51085292,"CreationDate":"2018-06-28T10:33:00.000","Title":"Why doesn't Dask dataframe have a shape attribute?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I change the model fields attributes in django should I remigrate them? will it afftect the data that is already stored there? is it safe to make that change in an already running project?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":258,"Q_Id":51081200,"Users Score":0,"Answer":"If I change the model fields attributes in django should I remigrate them? \n\nYes of course. Until you're willing to throw away your whole existing database,  that is.\n\nwill it afftect the data that is already stored there?\n\nDepends on your exact changes (some field attributes like blank or editable won't impact the db schema at all, only the Django code).\nNow if your schema changes are to affect your data, you can write data migrations too  \n\nis it safe to make that change in an already running project?\n\nWell that's what migrations (schema and data migrations) are for: having a safe, reliable, repetible, testable way to alter your db schema.","Q_Score":0,"Tags":"python,django","A_Id":51081343,"CreationDate":"2018-06-28T10:59:00.000","Title":"Django change model fields attributes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I tried to load the movie_lens dataset using the code below\nfrom lightfm.datasets import fetch_movielens\nrunning this  i am getting:\nImportError: No module named 'lightfm.datasets'; 'lightfm' is not a package","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1266,"Q_Id":51081216,"Users Score":0,"Answer":"since i have already tried many ways and failed,finally i run my python terminal from the default python3.5 saved folder -->for me it is \/usr\/bin ,then i created a new project in pycharm IDE ,istalled lightfm using pip3 it worked there too ,now i can import LightFM","Q_Score":3,"Tags":"python,pycharm,recommendation-engine","A_Id":51103271,"CreationDate":"2018-06-28T11:00:00.000","Title":"Pycharm: cannot import lightfm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to load the movie_lens dataset using the code below\nfrom lightfm.datasets import fetch_movielens\nrunning this  i am getting:\nImportError: No module named 'lightfm.datasets'; 'lightfm' is not a package","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1266,"Q_Id":51081216,"Users Score":3,"Answer":"It sounds like the lightfm package is not installed in your environment. You can check in File>Project Structure>SDKs make sure lightfm is present in the Packages tab of the environment you're using for your project. Otherwise you can add the package from that same window.","Q_Score":3,"Tags":"python,pycharm,recommendation-engine","A_Id":51082163,"CreationDate":"2018-06-28T11:00:00.000","Title":"Pycharm: cannot import lightfm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using on-line data augmentation of images I feed into my Convolutional Neural Network. I am using the Keras ImageDataGenerator for this. The images are augmented in each batch and then the model is trained on these images.\nI am comparing different models, but since the images are augmented on the fly, is this really fair, since each models is getting slightly different images?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":424,"Q_Id":51081439,"Users Score":2,"Answer":"If I understand you correct you are wondering whether the randomness caused by the data augmentation affects the result?\nThe randomness of the augmentation does not affect the result (at least not to a degree that makes a difference anyway) if you train long enough. The other options you have are (as I think about it):\n\nAugment your data deterministically applying the same transformation to your images before inserting them to your model. Those transformation could be (a) either random ones, e.g. rotate your images by a random degree between some limits, or (b) predetermined ones, e.g. rotate all your images by 1, 3 and 5 degrees.\nDon't augment your data at all. Use your initial data to train your model.\n\nThe effect of those choices are:\n\nThe number of transformation you would apply is limited and even if choice 1a is chosen would be predefined set. If you are willing to increase this dramatically other issues arise like where are you going to store all this data, how are you going to handle it during training etc. So, on the fly has the advantage that the storage of your data does not change, neither is the way you deal with your data. The disadvantage of course being a slower procedure is used (which depending on the transformation could make quite a difference).\nThis choice to be valid means that you have a lot of data. And by meaning a lot (depending on the problem of course) sometimes a lot is not enough. Since your are (probably) using different data for testing differences appear between your training and testing data in many aspects. For example for human detection (arbitrary choice) differences in poses, colors, light conditions, image clarity, image size, aspect ratio are common. How do you deal with that? You either collect a super huge collection of data or (probably) use data augmentation, right?\n\nTo sum it up, it's fair because on the long run it does not make a big difference. Consider the option of early stopping for your model for example. Is it fair to compare models that have stopped their training not in the best iteration? Well, it's not completely fair but it does not make a difference.","Q_Score":2,"Tags":"python,tensorflow,machine-learning,keras,convolutional-neural-network","A_Id":51082005,"CreationDate":"2018-06-28T11:11:00.000","Title":"Is the usage of on-line data augmentation a fair comparison between CNN models","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using on-line data augmentation of images I feed into my Convolutional Neural Network. I am using the Keras ImageDataGenerator for this. The images are augmented in each batch and then the model is trained on these images.\nI am comparing different models, but since the images are augmented on the fly, is this really fair, since each models is getting slightly different images?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":424,"Q_Id":51081439,"Users Score":1,"Answer":"In my opinion, you already give part of the answer within your question:\n\nimages are augmented on the fly, is this really fair, since each models is getting slightly different images?\n\n\nFor Evaluation \/ Validation I usually try to provide situations as similar as possible over the different architectures - otherwise you might induce unnecessary bias you are not able to account for.\nAlso you could reduce computational effort by offline-Augmentation and then directly handing over the same augmented Training samples","Q_Score":2,"Tags":"python,tensorflow,machine-learning,keras,convolutional-neural-network","A_Id":51081966,"CreationDate":"2018-06-28T11:11:00.000","Title":"Is the usage of on-line data augmentation a fair comparison between CNN models","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting the following error when using import cv2:\nModuleNotFoundError: No module named 'cv2'\nMy version of Python is 3.6 64 bit. I have downloaded the whl file to install it via pip manually, and have also installed it with pip install opencv-python however I still get ModuleNotFoundError. \npip outputs Requirement already satisfied: opencv-python in c:\\...\\python36\\site-packages\nHelp would be much appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1891,"Q_Id":51082504,"Users Score":0,"Answer":"Use pip install -U opencv-python","Q_Score":0,"Tags":"python,module,pip","A_Id":51082709,"CreationDate":"2018-06-28T12:06:00.000","Title":"OpenCV install on Python 3.6: ModuleNotFoundError","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting the following error when using import cv2:\nModuleNotFoundError: No module named 'cv2'\nMy version of Python is 3.6 64 bit. I have downloaded the whl file to install it via pip manually, and have also installed it with pip install opencv-python however I still get ModuleNotFoundError. \npip outputs Requirement already satisfied: opencv-python in c:\\...\\python36\\site-packages\nHelp would be much appreciated.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1891,"Q_Id":51082504,"Users Score":2,"Answer":"Your download must have been corrupted. It happened to me too. Simply uninstall the package and use \nsudo apt-get install python open-cv","Q_Score":0,"Tags":"python,module,pip","A_Id":51082582,"CreationDate":"2018-06-28T12:06:00.000","Title":"OpenCV install on Python 3.6: ModuleNotFoundError","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I am doing a small function to strip all the weird chars from a string, eg. #$& will be replaced just for a \" \"\nThe chars I am trying to remove are the following, defined into a string: \nxChars = r\"#$%()'^*\\;:\/|+_.\u2013\u00b0\u00aa\u00ba\"\nHowever I kepp getting the warning: \nAnomalous backslash in string: '\\;'. String constant might be missing an r prefix \nHowever, when i used the r prefix eg. r\"\\\" python rules out some of the special chars i want to replace. It doesnt produce an error it just thinks that those chars are ok or something and it rules them out.\nAny ideas on how to fix this ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1826,"Q_Id":51082866,"Users Score":1,"Answer":"Normally backslashes escape characters, therefore the compiler isn\u00b4t sure if the backslash has to be escaped. Maybe try using a double backslash to escape the backslash itself like: xChars = r\"#$%()'^*\\\\;:\/|+_.\u2013\u00b0\u00aa\u00ba\"","Q_Score":2,"Tags":"r,python-3.x","A_Id":51082986,"CreationDate":"2018-06-28T12:24:00.000","Title":"Warning on regex string in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it a way in Python to convert any unicode string to key codes (on a keyboard) which is required the string to be typed?\nSay, if English 'h' and Russian '\u0440' are both typed by one key then these keys must have the same codes.\nIn result I need string representation as array of the key codes.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":791,"Q_Id":51087052,"Users Score":2,"Answer":"Given that there is a large number of keyboard layouts out there, you would need a way to have an answer to the question \"which keyboard map to use?\". For example, on a US keyboard, \"Q\" is scancode 24, but on a French one, the same letter is on a different scan code (and \"A\" -> 24 instead).\nYou could limit this to the keyboard layout(s) installed on the host that you run this on. Then, for any character that can be typed on that host, you can find which key it came from (assuming you don't have two layouts that have the same letters, but on different locations - e.g., US (qwerty) and French or Dvorak).\nThe way you get the key maps is specific to the OS, e.g., if this is a desktop with XOrg driving display and keyboard, you could run xmodmap -pk and read its output. It has the list of all keycodes and all characters they map to (one line per key code, with several characters that it maps to). Use the subprocess module to run xmodmap or whatever utility your OS has to get the keymaps and read it into your program.","Q_Score":1,"Tags":"python","A_Id":51089646,"CreationDate":"2018-06-28T15:52:00.000","Title":"Convert any unicode string to corresponding virtual key (scan-) codes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to speed up the loading time for pages on selenium because I don't need anything more than the HTML (I am trying to scrape all the links using BeautifulSoup). Using PageLoadStrategy.NONE doesn't work to scrape all the links, and Chrome no longer supports PageLoadStrategy.EAGER. Does anyone know of a workaround to get PageLoadStrategy.EAGER in python?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6458,"Q_Id":51087832,"Users Score":1,"Answer":"You only use normal or none as the pageLoadStrategy in chromdriver. So either choose none and handle everything yourself or wait for the page load as it normally happens","Q_Score":3,"Tags":"python-3.x,selenium,web-scraping,selenium-chromedriver,pageloadstrategy","A_Id":51088883,"CreationDate":"2018-06-28T16:41:00.000","Title":"\"Eager\" Page Load Strategy workaround for Chromedriver Selenium in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For a project I'm working on, I'm supposed to use XBee radio modules, which isn't super important, except that I have to read and write to their serial port in order to use them. I'm currently working with Python and ROS, so I'm attempting to send TransformStamped messages over the XBees.\nMy question is, unless I'm misunderstanding how Serial.read() and Serial.write() work, how can I tell how many bytes to read? I was planning on using Pickle to serialize the data into a string, and then sending that over the serial ports. Is there a better way that I've overlooked? Is there some sort of loop that would work to read data until the end of the pickled string is read?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":144,"Q_Id":51089252,"Users Score":0,"Answer":"The short answer is, serial.read() cannot tell you how many bytes to read. Either you have some prior knowledge as to how long the message is, or the data you send has some means of denoting the boundaries between messages. \nHint; knowing how long a message is is not enough, you also need to know whereabouts in the received byte stream a message has actually started. You don't know for sure that the bytes received are exactly aligned with the sent bytes: you may not have started the receiver before the transmitter, so they can be out of step. \nWith any serialisation one has to ask, is it self delimiting, or not? Google Protocol buffers are not. I don't think Pickle is either. ASN.1 BER is, at least to some extent. So is XML.\nThe point is that XBee modules are (assuming you're using the ones from Digi) just unreliable byte transports, so whatever you put through them has to be delimited in some way so that the receiving end knows when it has a complete message. Thus if you pickle or Google Protocol Buf your message, you need some other way of framing the serialised data so that the receiving end knows it has a complete message (i.e. it's seen the beginning and end). This can be as simple as some byte pattern (e.g. 0xffaaccee00112233) used to denote the end of one message and the beginning of the next, chosen so as to be unlikely to occur in the sent messages themselves. Your code at the receiving end would read and discard data until is saw that pattern, would then read subsequent data into a buffer until it saw that pattern again, and only then would it attempt to de-pickle \/ de-GPB the data back into an object. \nWith ASN.1 BER, the data stream itself incorporates effectively the same thing, saving you the effort. It uses tags, values and length fields to tell its decoders about the incoming data, and if the incoming data makes no sense to the decoder in comparison to the original schema, incorrectly framed data is easily ignored.\nThis kind of problem also exists on tcp sockets, though at least with those delivery is more or less guaranteed (the first bytes you receive are the first bytes sent). A Digimesh connection does not quite reach the same level of guaranteed delivery as a tcp socket, so something else is needed (like a framing byte pattern) for the receiving application to know that it is synchronised with the sender.","Q_Score":0,"Tags":"python,serialization,deserialization,ros,robotics","A_Id":51144344,"CreationDate":"2018-06-28T18:27:00.000","Title":"Using serializing an object in python for use with an XBee","Data Science and Machine Learning":0,"Database and SQL":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 implementing soap toolkit api. After submitting credit card info it redirects me towards the 3rd party page to get the password. I want to avoid that redirection is it possible to load that page within my domain or on my custom page using IFRAME.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":150,"Q_Id":51091419,"Users Score":0,"Answer":"Not exactly an answer but more of a request for clarifying information: When you say \"it redirects me towards the 3rd party page to get the password\", are you talking about the 3D-Secure process?  I think I understand what you are trying to accomplish, but in order to use 3D Secure, I think the idea is to guide the end-user through the process of the additional Verification (security) process. So I think the redirection is required as a matter of how the Business Process (or 3D-Secure) works.","Q_Score":0,"Tags":"python,soap-client,cybersource","A_Id":51107797,"CreationDate":"2018-06-28T21:22:00.000","Title":"Cybersource soap toolkit api avoid redirection on 3rd party domain","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I package my python (flask) application with docker. Within my app I'm generating UTC date with datetime library using datetime.utcnow().\nUnfortunately, when I inspect saved data with MongoDB Compass the UTC date is offset two hours (to my local time zone). All my docker containers have time zone set to Etc\/UTC. Morover, mongoengine connection to MongoDB uses tz_aware=False and tzinfo=None, what prevents on fly date conversions.\nWhere does the offset come from and how to fix it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5085,"Q_Id":51098943,"Users Score":15,"Answer":"Finally, after trying to prove myself wrong, and hairless head I found the cause and solution for my problem. \nWe are living in the world of illusion and what you see is not what you get!!!. I decided to inspect my data over mongo shell client\nrather than MongoDB Compass GUI. I figure out that data that arrived to database contained correct UTC date. This narrowed all my previous\nassumption that there has to be something wrong with my python application, and environment that the application is living in. What left was MongoDB Compass itself.\nAfter changing time zone on my machine to a random time zone, and refreshing collection within MongoDB Compass, displayed UTC date changed to a date that fits random time zone. \nBe aware that MongoDB Copass displays whatever is saved in database Date field, enlarged about your machine's time zone. Example, if you saved UTC time equivalent to 8:00 am, \nand your machine's time zone is Europe\/Warsaw then MongoDB Compass will display 10:00am.","Q_Score":5,"Tags":"python,mongodb,docker,mongoengine,mongodb-compass","A_Id":51099120,"CreationDate":"2018-06-29T09:49:00.000","Title":"Incorrect UTC date in MongoDB Compass","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I\u2019m working on a functionality where I need to convert a huge html file (size more than 1 mb) into pdf. I\u2019ve tried below two open-source python libraries.\n1.  Xhtml2pdf (Pisa)\n2.  Weasyprint\nBut none of them solves my problem as they take around 4-5 mins in generating 1 MB PDF file (around 500 pages) causing my app server\u2019s worker process (Gunicorn and Nginx) to get down and throwing \u2018GATEWAY TIMEOUT ERROR\u2019 on browser. CPU utilization also goes up to 100% while PDF conversion is in process.\nIf anybody is having any idea which API\/library will be a best suit for large html files.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":339,"Q_Id":51100005,"Users Score":1,"Answer":"Generating a 500 pages PDF will take time whatever technologie you use, so the solution is to send the job to an async task queue (celery, huey, django-queue, ...), eventually with some polling to show a progressbar. Even if you manage to optimize the crap out of the generation process, it will STILL takes too much time to fit in an HTTP request\/response cycle (from the user's POV at least even one minute is already way to long) \nNB : having your CPU maxing out is nothing surprising either - generating a huge PDF not only takes time, it's also a computation-heavy process, and one that easily eats your memory too. This by itself is another reason to use a distributed task queue so you can run the process on a distinct node and avoid killing your front server).","Q_Score":0,"Tags":"python,html,django,unix,pdf","A_Id":51100551,"CreationDate":"2018-06-29T10:48:00.000","Title":"Convert Html to PDF Python\/Django on Unix Platform","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to find out if anyone has suggestions on how to create a script that can easily be edited to create a custom Maya node with just adding in some arbitrary values of any type.\nBasically, I would want to be able to specify an attribute type (string type, float type, ect), and to be able to fill in the values for those types and have the script generate a custom node easily.\nExcited to hear back any suggestions.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":940,"Q_Id":51101012,"Users Score":1,"Answer":"You can create an empty group node and add any arbitrary attribute to it. This has the disadvantage that you cannot filter by node type. But you can use a special naming convention to filter for these type of nodes.\nIf you need your own node type, you can easily create your own nodetype with a simple python api script. Then you can fill in any additional attributes as you like.","Q_Score":1,"Tags":"python,maya,maya-api","A_Id":51103390,"CreationDate":"2018-06-29T11:45:00.000","Title":"Autodesk Maya API Custom Node","Data Science and Machine Learning":0,"Database and SQL":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 set of files (compiled software) that I want to give an unique fingerprint before distribution. The idea is to write a script that:\n\nRandomly generates a character sequence\nAppends the character sequence to a file in the project \nStores the fingerprint in a database with the addressee\nDistributes the software to the addressee\n\nThe requirements for the fingerprint process is that:\n\nThe fingerprint is difficult to detect (i.e. not stored in the file metadata or easily accessible areas)\nThe fingerprint does not corrupt the data of the file the sequence is added to\nThe fingerprint can be added to an executable or dll file \nIt's easy to read the fingerprint if you know where to look\n\nAre there any open source solutions that is built for the purpose of fingerprinting files?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":188,"Q_Id":51101594,"Users Score":0,"Answer":"Since you are talking about compiled software, maybe an alternative solution could be to use an execbinary encrypting tool. When you execute the file it will ask for a password, if it's correct then it will use the password to generate a key. Then it uses that key to decrypt the program directly in memory. That way they won't be able to analyze the binary and even with the key it would be a lot more difficult to do so, much less modify it. You can put as many fingerprints as you like, regular text strings, into the code and they will most likely stay there.","Q_Score":1,"Tags":"python,windows,bash,powershell,jenkins","A_Id":51105962,"CreationDate":"2018-06-29T12:18:00.000","Title":"Append unique fingerprint to file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When creating Python script on Jupyter, is it possible to call a function from another Python file?\nWhen I try to call, it works on Terminal but does not work on Jupyter.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":6426,"Q_Id":51102243,"Users Score":1,"Answer":"Just restart the kernel and it should work fine :)","Q_Score":3,"Tags":"python,jupyter-notebook,jupyter","A_Id":63761168,"CreationDate":"2018-06-29T12:53:00.000","Title":"Is it possible to call function from another Python file on Jupyter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For some reason, whenever I try incorporating the while loop into my tkinter program, the window I created freezes and says \"not responding\". Is this because while is not compatible with tkinter? If so, please let me know a way around this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":51102703,"Users Score":0,"Answer":"\"not compatible\" is not the right word. Tkinter programs can certainly use while loops. In fact, mainloop itself is a while loop. \nThe issue isn't compatibility, it's just that tkinter is single-threaded and can do only one thing at a time. If python is running your loop, it can't also be updating the screen and processing events at the same time unless you explicitly make that happen.\n\nIf so, please let me know a way around this.\n\nThat part of the question is too broad for stackoverflow. There are many ways around it, but it depends on what you're actually trying to do in that while loop. For example, you could run the loop in another thread. You could run it in a separate process. you could break it down to smaller chunks that run inbetween the moments when tkinter needs to update the screen, or you could explicitly ask tkinter to update the screen in the middle of the loop.","Q_Score":0,"Tags":"python,tkinter","A_Id":51103483,"CreationDate":"2018-06-29T13:18:00.000","Title":"Is the while loop not compatible with tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried to run a script with pandas in python3, but it appears to have an terrible error I even don't understand. Note: my script is \"gh.py\" and has an error in line 1, i can't import pandas.\nFile \"gh.py\", line 1\n    from pandas as pd\n                 ^\nSyntaxError: invalid syntax","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":51105431,"Users Score":0,"Answer":"Maybe you\u2019re using python2 instead of python3. Use the appropiate syntax to import pandas and also try \n\npip install pandas","Q_Score":2,"Tags":"python-3.x,pandas","A_Id":51105559,"CreationDate":"2018-06-29T15:50:00.000","Title":"Error by running script with python3","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to deploy a simple service to AWS Lambda (on Python 3.6) that requires PIL.  I'm using the serverless framework, so to start I simply did pip3 freeze > requirements.txt on an ec2 instance with my code and all of the dependencies installed, and when I called the Lambda function I got the following error (from CloudWatch logs):\nUnable to import module 'lambda_function': No module named 'PIL'\nI then tried to install & package pillow manually by doing pip3 install pillow -t .vendor and added the following to my serverless.yml:\npackage:\n  include:\n    - .vendor\/**\nBut I'm still getting the same error.  Am I doing something wrong?\nEDIT: It seems that not using the serverless architecture and instead packaging the dependencies myself fixed the issue.  Why is this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1110,"Q_Id":51106025,"Users Score":0,"Answer":"This is because pillow is not a standard python library found in AWS Lambda environment by default. To include and use it in your code you need to make a custom deployment package with all your dependicies and your code included and then deploy it. \nAnd this is what you did to make it run.","Q_Score":0,"Tags":"python-3.x,aws-lambda,pillow,serverless-framework,serverless","A_Id":51166542,"CreationDate":"2018-06-29T16:30:00.000","Title":"AWS Lambda Python PIL\/pillow import 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 have a classification problem which requires some optimization, as my results are not quite adequate.\nI'm using the DNNClassifier for a huge dataset in order to classify items in 5 different classes (labels). I have over 2000 distinct items (in a hashbucket column with size 2000 and dims 6 - is this adequate?) and multiple numeric columns for said classification.\nMy problem is the following: the amount of items belonging in each class is very variable. Class 1 is very common, class 2 is common but classes 3 4 and 5 are highly uncommon (under 2% of the dataset) but they are the most interesting ones in my test case. Even if I tweak the network size\/number of neurons or the training epoch, I get close to no results in classes 3, 4 and 5, so class 1 and 2 are clearly overfitted.\nI saw the weight_column option in the documentation - would that be a good idea to change the learning weight of these three class to \"normalize\" the weight in each class ? Is there a more efficient way to get better results on rarer cases without losing the detection precision on the common classes?\nMany thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":51106402,"Users Score":0,"Answer":"What you said is considered one approach to solving this issue, as this prevents your computed gradient from being dominated by Classes 1 and 2. Depending on your data, it may be effective to add some Gaussian noise to the underrepresented samples to create similar samples. Another good idea in general to avoid overfitting is to apply a dropout if you have not already.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,artificial-intelligence","A_Id":51106833,"CreationDate":"2018-06-29T16:57:00.000","Title":"Tensorflow 1.9 DNNClassifier unequal output labels optimization","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to compile  .py scripts to .obj files if it is possible ?\nCan a python script and a c file be compiled and linked to an exe.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":293,"Q_Id":51108008,"Users Score":0,"Answer":"I'm not sure what problem you're trying to solve. Your question is too broad.\nPython compiles all code automatically, but it generates .pyc files with the python bytecode, then needs a VM to execute it, similar to other languages like C# and java.\nTo integrate with C the usual approach is to make a C extension to python, then you can call it from the python code.\nIf you want to generate a .exe from python code, the go-to method is to use something like pyinstaller, that bundles python, all libraries and your code in a single .exe file and unpacks it on execution.\nIf you really want to convert a python code to machine-readable x86 code (why) then you can use something like cython (converts python-like code to C code); The results are probably not what you expect though.","Q_Score":0,"Tags":"python,c++","A_Id":51108097,"CreationDate":"2018-06-29T19:08:00.000","Title":"Python script to c .obj files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering if it was possible to get the file path of a temporary file made using the tempfile library. Basically, I'm trying to make a function that intakes some data, and generates a temporary csv file based off of said data. I was wondering if there was a way to get the path of this temporary file?","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":36409,"Q_Id":51110783,"Users Score":3,"Answer":"Anyway, if you need the path of the tempfile directory you can use tempfile.gettempdir()","Q_Score":34,"Tags":"python,temporary-files","A_Id":59497848,"CreationDate":"2018-06-30T00:27:00.000","Title":"Is it possible to get the path of a tempfile in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had implemented my project along with daily commits to Github, which is a website implemented using Flask and Python, while daily commits I used to    git add --a, thus it has added all folders like __pycache__ and flask_session. I think it is safe to delete those from my Github, Is it so? If not why?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2564,"Q_Id":51112474,"Users Score":3,"Answer":"In layman language, YES because these things can be generated again by Flask thus it's good practise to not push it to a repo and generate locally individually.","Q_Score":6,"Tags":"python,git,github,flask","A_Id":59296998,"CreationDate":"2018-06-30T06:47:00.000","Title":"git-flask-python : Is it safe to remove pycache and flask session folders","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I had implemented my project along with daily commits to Github, which is a website implemented using Flask and Python, while daily commits I used to    git add --a, thus it has added all folders like __pycache__ and flask_session. I think it is safe to delete those from my Github, Is it so? If not why?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2564,"Q_Id":51112474,"Users Score":3,"Answer":"Both these folders contain temporary objects that are created in runtime, and there's no point in committing them to git.\nI'd remove those folders from your repository and then add them to .gitignore to prevent them from being re-added there by mistake.","Q_Score":6,"Tags":"python,git,github,flask","A_Id":51112501,"CreationDate":"2018-06-30T06:47:00.000","Title":"git-flask-python : Is it safe to remove pycache and flask session folders","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Im making a web application using flask api. When a user is created, a folder is created for them on the file system. They use this for uploading their own images. When uploding the image path is stored in the db. My problem is that this image path should only be allowed for that specific user. The paths gets returned by the api, but If known everyone can request the image src. How can i restrict that to the owner only?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":235,"Q_Id":51112711,"Users Score":1,"Answer":"Set an owner_ID to each link entry in DB.\nThan you can selecet the link by link_id and owner_ID.\nIf the curr user not the user of the directory you can return a permission_denied(403)","Q_Score":0,"Tags":"python,flask","A_Id":51112855,"CreationDate":"2018-06-30T07:23:00.000","Title":"Protect image path in Flask API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've got a simple Telegram bot, I don't think the code matters but I used telebot library.\nI uploaded it to pythonanywhere, installed virtual environment and all libraries that needed. \nWhenever I type python.script.py in the bash console, script works for, say, 5 hours, then it stops. How do I make it run forever?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":241,"Q_Id":51115038,"Users Score":2,"Answer":"PythonAnywhere does not keep consoles running forever. They need to be stopped on occasion to manage the service. See the PythonAnywhere documentation for details about keeping tasks running.","Q_Score":0,"Tags":"python,telegram,pythonanywhere","A_Id":51116139,"CreationDate":"2018-06-30T12:44:00.000","Title":"Telegram bot stops after a few hours 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":"How to set path for python 3.7.0?\nI tried the every possible way but it still shows the error!\n\nCould not install packages due to an EnvironmentError: [WinError 5]\nAccess is denied: 'c:\\program files (x86)\\python37-32\\lib\\site-packages\\pip-10.0.1.dist-info\\entry_points.txt'\nConsider using the --user option or check the permissions","AnswerCount":9,"Available Count":3,"Score":-0.022218565,"is_accepted":false,"ViewCount":67409,"Q_Id":51115744,"Users Score":-1,"Answer":"I wanted to throw an answer out here because I've been against a rock wall since upgrading to python 3.18.  Pip install  stopped working with a module error which was rectified with py -m pip install  --user.  but I would still get this permissions error.  I uninstalled, reinstalled, and downgraded Python and Pip.  I ran command prompt as administrator.  None of it worked.\nThe only thing that worked was to pip download  and then pip install the package from my c:\/ drive.  Totally BS workaround, but if you'r as stuck as I was it works.","Q_Score":31,"Tags":"python","A_Id":59008965,"CreationDate":"2018-06-30T14:17:00.000","Title":"Access is denied when trying to pip install a package on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to set path for python 3.7.0?\nI tried the every possible way but it still shows the error!\n\nCould not install packages due to an EnvironmentError: [WinError 5]\nAccess is denied: 'c:\\program files (x86)\\python37-32\\lib\\site-packages\\pip-10.0.1.dist-info\\entry_points.txt'\nConsider using the --user option or check the permissions","AnswerCount":9,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":67409,"Q_Id":51115744,"Users Score":0,"Answer":"The question was for windows but if any linux users that stumbled here (like me) : Permission Error Persists by adding --user in my virtualenv on Ubuntu 19 when I want to generate requirements.txt. Also, I can't pip install --user as well since I'm in an virtualenv. My solution was just using sudo pip3 install pipreqs to install another pipreqs for super user.","Q_Score":31,"Tags":"python","A_Id":71598398,"CreationDate":"2018-06-30T14:17:00.000","Title":"Access is denied when trying to pip install a package on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to set path for python 3.7.0?\nI tried the every possible way but it still shows the error!\n\nCould not install packages due to an EnvironmentError: [WinError 5]\nAccess is denied: 'c:\\program files (x86)\\python37-32\\lib\\site-packages\\pip-10.0.1.dist-info\\entry_points.txt'\nConsider using the --user option or check the permissions","AnswerCount":9,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":67409,"Q_Id":51115744,"Users Score":13,"Answer":"Run your command Prompt on Admin-Mode in Windows,it will stop throwing errors for user-rights.\nSteps:\n\nOn Windows, type \"Cmd\" on searchbox to search for command prompt.\nWhen \"Command Prompt\" search result appears,right-click>Run as Administrator.","Q_Score":31,"Tags":"python","A_Id":54334551,"CreationDate":"2018-06-30T14:17:00.000","Title":"Access is denied when trying to pip install a package on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do you change the names of commands within a terminal - I want to customise some of the commands just for a bit of fun, eg, instead of having to type python, I want to be able to type snek. I know it's silly but it's been a long day and I'd love something to cheer myself up - any help at all would be greatly appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":569,"Q_Id":51116277,"Users Score":1,"Answer":"Steps:\n\nGo to your .bashrc file in your home folder\nUse an editor like vim or nano to edit the file\nGo at the bottom and on a new line write alias snek='python'\nClose the file and run source .bashrc. This will load the .bashrc file again.\nNow you can just write snek and python prompt will open.","Q_Score":0,"Tags":"python,command-line,terminal,renaming","A_Id":51116337,"CreationDate":"2018-06-30T15:37:00.000","Title":"Changing command names within the terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Im using Django Channels (and loving it) but new consumers to the layer only see data from the time they join into the future.  Is there a way for new consumers to see previous data belonging to the layer?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":51117355,"Users Score":0,"Answer":"You need to send the existing data either from something like the database or the cache. Do this on the connect method of the consumer. If you are using async methods you must always use an async library for IO or wrap the IO in sync_to_async or database_sync_to_async. This is so you don't block the event loop.","Q_Score":0,"Tags":"python,django,django-channels","A_Id":51144230,"CreationDate":"2018-06-30T18:04:00.000","Title":"Allow New Consumer To See Existing Data in Django Channels Layer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am developing a data collection application that involves constant insertion into a MySQL database. I am using Python and PyMySQL to accomplish this. I need to insert about 100 rows into the main table a second. The python process is constantly running and maintains a constant connection to the MySQL database which resides on a remote server.\nI know that, in general, it is best to insert data as buffers (multiple rows at once) rather than making individual insertions. Would making commits (connection.commit() in PyMySQL) every 100 or so insertions achieve some of the same overhead reductions as inserting large amounts of data at once would?\nFor syntactical reasons, it is easier to separate the row insertions into individual operations.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":249,"Q_Id":51117782,"Users Score":0,"Answer":"You should find that the biggest overhead with a distant server is not processing time, but rather the round-trip time for each query to be sent to the server and return a response... if the server is more than ~10ms distant, inserting 100 rows\/sec individually is impossible because too much time is wasted on the wire, waiting.\nThere are internal reasons that make bulk inserts or infrequent commits perform better, but those become less and less relevant when the server is more distant.  Individual inserts will be always slower from your perspective than bulk inserts, simply because of the number of round trips.\nAt the server, itself, bulk inserts convey a small advantage... and in a transaction, committing after every n inserts will convey a small advantage... but again any difference in performance from using these strategies will disappear into the noise over a distant connection.\nIn short, inserting multiple rows in a single query rather than multiple queries is the only meaningful improvement you can make, because server performance is not your primary issue -- it's distance.\nOf course, if there is some reason why individual insert queries are more desirable, then using multiple threads in your program and multiple connections to the database is a possible strategy to improve the performance, since n connections can execute n queries in parallel, thus reducing the net practical impact of round trip time t down to something near t \/ n.","Q_Score":0,"Tags":"python,mysql,pymysql","A_Id":51119697,"CreationDate":"2018-06-30T19:06:00.000","Title":"Is buffering commits in MySQL\/PyMySQL a viable alternative to inserting multiple rows at once?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have multiple computers running python applications, each using the same MySQL server. Each of the applications contains a tkinter GUI that allows editing of a set of data (corresponding to data in a table in the MySQL server). Whenever the data is updated one machine (and in turn updated on the MySQL server), I would like the other machines to be prompted to update there displayed data by pulling from the server. I know I could simply have the applications self-update after a given interval, but I would prefer to only update when there is new data to pull.\nHow should I go about this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":51119912,"Users Score":2,"Answer":"This isn't something you can do with MySQL.  \nThere is no provision in the client\/server protocol for the server to spontaneously emit messages to a client, so there is no mechanism in MySQL that allows connected clients to be notified of events via a push notification.","Q_Score":0,"Tags":"mysql,python-3.x,server","A_Id":51120353,"CreationDate":"2018-07-01T02:16:00.000","Title":"How can I communicate with other client connections on a MySQL server using python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have multiple computers running python applications, each using the same MySQL server. Each of the applications contains a tkinter GUI that allows editing of a set of data (corresponding to data in a table in the MySQL server). Whenever the data is updated one machine (and in turn updated on the MySQL server), I would like the other machines to be prompted to update there displayed data by pulling from the server. I know I could simply have the applications self-update after a given interval, but I would prefer to only update when there is new data to pull.\nHow should I go about this?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":37,"Q_Id":51119912,"Users Score":2,"Answer":"I would suggest that your other client to do a long polling to your database and return a response if there are any feedback.","Q_Score":0,"Tags":"mysql,python-3.x,server","A_Id":51120370,"CreationDate":"2018-07-01T02:16:00.000","Title":"How can I communicate with other client connections on a MySQL server using python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have an UI written using C#, and I'd like to press a button and call a python script (which depends on a number of external python library, such as matplotlib). My final application have to be deployed in Windows platform. Which should be the approach to do?\n\nIronPython: It does not support Python3 yet, and I cannot use it.\nPython For .NET: I still get confused on the use of Python for .NET, can this serve my purpose? Any recommended tutorial?\nCalling Python script with StartProcessInfo class of C#. I can do it, but I feel that it is not the most elegant way to do so.\nPython rest API. However, there will be overhead on setting up server etc. \n\nWhich should be the way to do that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":51121099,"Users Score":0,"Answer":"\"Calling Python script with StartProcessInfo\"  is clean and hassle-free.","Q_Score":0,"Tags":"c#,python,.net","A_Id":51133312,"CreationDate":"2018-07-01T06:59:00.000","Title":"C# interface calling Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In pandas, how do I replace &amp; with '&' from all columns where &amp could be in any position in a string?\nFor example, in column Title if there is a value 'Good &amp; bad', how do I replace it with 'Good & bad'?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11751,"Q_Id":51121170,"Users Score":0,"Answer":"Try this\ndf['Title'] = titanic_df['Title'].replace(\"&amp;\", \"&\")","Q_Score":5,"Tags":"python,python-3.x,pandas","A_Id":51121201,"CreationDate":"2018-07-01T07:10:00.000","Title":"How to replace all string in all columns using pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am newbie to pycharm , I have installed this and everytime I got an error when I created a new project , K am not able to find the solution  plz help me out .\n[ No R interpreter defined. Many R related features like completion, code checking and help won't be available.You can set an interpreter under Preference->Languages->R ]\nI tried to fix this as mentioned but I am not able to find where is \"preference\" .","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":20767,"Q_Id":51121413,"Users Score":4,"Answer":"If you are working in Python and you are getting such error, Then this may be due to adding of the plugin R Language Support during installation of JetBrains Pycharm.\nSo, to remove this error you need to go to settings->plugins->Installed\nThere you can select The R Language Support plugin and uninstall that plugin","Q_Score":11,"Tags":"pycharm,python-3.6","A_Id":53670297,"CreationDate":"2018-07-01T07:52:00.000","Title":"No R interpreter defined: Many R related features like combination, code checking and help won't be available","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a simple game in Python 3 and I need to draw a rectangle rotated by a given angle and around a specific centre of rotation. \nIs there a simple way of doing this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":51122198,"Users Score":0,"Answer":"As long as you are using the pygame library, the pygame.transform.rotate(*Surface*,*angle*) function may be worth a try. \nWithout a code sample it is hard to understand the context you are trying to apply this in.","Q_Score":1,"Tags":"python-3.x","A_Id":51145896,"CreationDate":"2018-07-01T09:47:00.000","Title":"Drawing a rotated rectangle in python 3, pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using pyperclip in Python 3.6\nIf i have a giant 2D array(640X480) how can I copy it in one program and paste it another program using pyperclip copy() and paste() functions.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":362,"Q_Id":51122730,"Users Score":0,"Answer":"You could convert the array to a JSON string or perhaps a pickle, copy the string, then paste it into the other program. The other program will need to be able to decode the JSON string or pickle.","Q_Score":2,"Tags":"python,arrays,pyperclip","A_Id":51122832,"CreationDate":"2018-07-01T11:08:00.000","Title":"Using Pyperclip to copy and paste a 2d array","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install MySQLdb for Python on Mac OS.\nWhen I digit pip install MySQL-python shell returns to this:\n Collecting MySQL-python\n  Using cached https:\/\/files.pythonhosted.org\/packages\/a5\/e9\/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad\/MySQL-python-1.2.5.zip\n    Complete output from command python setup.py egg_info:\n    Traceback (most recent call last):\n      File \"\", line 1, in \n      File \"\/private\/var\/folders\/9h\/2lp9kx993ygbrfk1lxr0sz500000gq\/T\/pip-install-7xyyBe\/MySQL-python\/setup.py\", line 17, in \n        metadata, options = get_config()\n      File \"setup_posix.py\", line 53, in get_config\n        libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag(\"l\")) ]\n      File \"setup_posix.py\", line 8, in dequote\n        if s[0] in \"\\\"'\" and s[0] == s[-1]:\n    IndexError: string index out of range\n\n    ----------------------------------------\nCommand \"python setup.py egg_info\" failed with error code 1 in \/private\/var\/folders\/9h\/2lp9kx993ygbrfk1lxr0sz500000gq\/T\/pip-install-7xyyBe\/MySQL-python\/\n\nWhat can I do? I searched everywhere but I couldn't find an answer.\n(I had installed Python 2.7)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3629,"Q_Id":51123044,"Users Score":7,"Answer":"I fixed the error. If anyone have this error just follow these steps:\n\nFirst of all install mysql connector\n\nbrew install mysql-connector-c\n\n\nYou have to modify lines in mysql_config (this is an alias)\n\n\nvim \/usr\/local\/bin\/mysql_config \n\n(I sincerely consider to open mysql_config with a file editor, you can find the \n exact folder here)\n\n\/usr\/local\/Cellar\/mysql-connector-c\/6.1.11\/bin\/ \n\n\nReplace these lines.\n\n\n\n  # Create options \n  libs=\"-L$pkglibdir\"\n  libs=\"$libs -l \"\n\nshould be:\n  \n  # Create options \n  libs=\"-L$pkglibdir\"\n  libs=\"$libs -lmysqlclient -lssl -lcrypto\"\n\n\n\nSet environment variable\n\n\nbrew info openssl\n\nit would tell what\u2019s needed\n\n For compilers to find this software you may need to set:\n      LDFLAGS:  -L\/usr\/local\/opt\/openssl\/lib\n      CPPFLAGS: -I\/usr\/local\/opt\/openssl\/include\n  For pkg-config to find this software you may need to set:\n      PKG_CONFIG_PATH: \/usr\/local\/opt\/openssl\/lib\/pkgconfig\n\n\n\nThen you can install MySQL\n\n\npip install MySQL-python\n\n\nYou can test if MySQL is installed with this:\n\n\npython -c \"import MySQLdb\" \n\nHope this works also for you!","Q_Score":2,"Tags":"python,macos,mysql-python","A_Id":51132141,"CreationDate":"2018-07-01T11:53:00.000","Title":"pip install MySQL-python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on a project to execute a multi-noded python script on a SLURM cluster. The solution should be p2p. The problem is that I don't really have an idea where to start. Though, I should broadcast first right? Finding out which nodes are assigned to my job (4 nodes), and then, utilize every node with 1\/4 part of the job(?). Every node must keep track of which part of the job has been done, right? I heard someone mention a file-based solution, but I didn't quite understand that. Hope you guys can help me with this. ALso, no MPI or anything like that, should be used.\n(the job I should submit, is reading in a large file, and processing every line of that file)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":121,"Q_Id":51123474,"Users Score":0,"Answer":"You say the overall task is to read a large file and process every line.\nFirst, you need a strategy to divide the work.  Having a single process read the entire file and then send it to the rest might make sense if your disk is very slow and your network is very fast, but more likely you want to divide the reading task.\nYou can often do these things without explicit communication between the processes.  Just have the first process read the first 25% of the file's bytes, then continue reading until it sees one more newline.  The second process reads 25% to 50% within the file, then continues until it sees one more newline.  And so on.\nThis way, all you need to do is tell the processes three facts on startup:\n\nThe file path.\nThe number of processes (N) which will process the file.\nThe index of each specific process (0 to N), so that it can infer which portion to read.","Q_Score":0,"Tags":"python,nodes,slurm","A_Id":51123608,"CreationDate":"2018-07-01T12:52:00.000","Title":"Multi-node SLURM pure python solution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been looking an so far have been unable to find any way of enabling syntax highlighting for jenkinsfile in PyCharm. Does anyone know of a method to do this? I am specifically using scripted pipeline.","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":15863,"Q_Id":51124878,"Users Score":3,"Answer":"You can't associate Jenkinsfile with Groovy in PyCharm, but you can associate them with Java. Not perfect, but the syntax is similar enough to be useful for simple files. \nTo do that (in PyCharm 2018.3):\nPyCharm > Preferences > Editor > File Types > Select \"Java\" under \"Recognized File Types\" > Click the + > Type \"Jenkinsfile\"","Q_Score":27,"Tags":"python,jenkins,pycharm,jenkins-pipeline,jetbrains-ide","A_Id":56991005,"CreationDate":"2018-07-01T16:01:00.000","Title":"Jenkinsfile syntax highlighting in PyCharm Idea","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Why does pip need to use virtual environments to isolate packages per-project, instead of just installing them in a default directory in the project? This seems like added complexity without benefit.\nNPM, for example, installs packages in the <project_root>\\node_modules by default. No virtual environment necessary, and packages are still installed in a project-independent way.\nEdit: To be clear, I'm interested in the practical advantages to pip's use of virtual environments over package management systems like NPM, Nuget, and Webpack, which all use directories in the project. Otherwise, if this is just a limitation of Python's modules system, then I'd be interested to know that too.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":62,"Q_Id":51126930,"Users Score":1,"Answer":"Because Python's module system doesn't work that way.  If pip were to install, say, requests by just downloading it to a python_modules directory, that wouldn't be enough to for import requests to work; it would have to be import python_modules.requests, but then we'd still have problems whenever requests tried to import one of its dependencies, as that would need python_modules prepended, too, and it'd just be a big mess.  The solution that virtual environments use is to modify the PYTHONPATH environment variable to include python_modules, plus some extra stuff to take care of executable scripts and not importing packages from outside the virtualenv.","Q_Score":0,"Tags":"python,pip,virtualenv","A_Id":51126980,"CreationDate":"2018-07-01T20:52:00.000","Title":"pip Virtualenv vs. directory in project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering what the symbol is or if I am even able to get historical price data on BTC, ETH, etc. denominated in United States Dollars. \nright now when if I'm making a call to client such as: \nClient.get_symbol_info('BTCUSD')\nit returns nothing\nDoes anyone have any idea how to get this info?  Thanks!","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":4098,"Q_Id":51127720,"Users Score":3,"Answer":"You can not make trades in Binance with dollars but instead with Tether(USDT) that is a cryptocurrency that is backed 1-to-1 with dollar.\nTo solve that use BTCUSDT\nChange BTCUSD to BTCUSDT","Q_Score":2,"Tags":"python,api,bitcoin,cryptocurrency,binance","A_Id":51128924,"CreationDate":"2018-07-01T23:33:00.000","Title":"Binance API: how to get the USD as the quote asset","Data Science and Machine Learning":0,"Database and SQL":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 game where I've (foolishly) made the db key equal to the users login email.  I did this several years ago so I've got quite a few users now. Some users have asked to change their email login for my game.  Is there a simple way to change the key?  As far as I can tell I'd need to make a new entry with the new email and copy all the data across, then delete the old db entry. This is the user model but then I've got other models, like one for each game they are involved in, that store the user key so I'd have to loop though all of them as well and swap out for the new key. \nBefore I embark on this I wanted to see if anyone else had a better plan. There could be several models storing that old user key so I'm also worried about the process timing out. \nIt does keep it efficient to pull a db entry as I know the key from their email without doing a search, but it's pretty inflexible in hindsight","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":191,"Q_Id":51127822,"Users Score":0,"Answer":"I ended up adding a new property to my user model and running a crawler to copy the string key (the email) to that new property. I changed my code search for that property rather then the key string to get a user item.  Most of my users still have keys that equal their email, but I can safely ignore them as if the string is meaningless.  I can now change a users email easily without making a new recored and my other models that have pointers to these user keys can remain unchanged.","Q_Score":1,"Tags":"google-app-engine,app-engine-ndb,google-app-engine-python","A_Id":51229386,"CreationDate":"2018-07-01T23:56:00.000","Title":"Change appengine ndb key","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I created one task, where I have white background and black digits.\nI need to take the largest by thickness digit. I have made my picture bw, recognized all symbols, but I don't  understand, how to scale thickness. I have tried arcLength(contours), but it gave me the largest by size. I have tried morphological operations, but as I undestood, it helps to remove noises and another mistakes in picture, right? And I had a thought to check the distance between neighbour points of contours, but then I thought that it would be hard because of not exact and clear form of symbols(I draw tnem on paint). So, that's all Ideas, that I had. Can you help me in this question by telling names of themes in Comp. vision and OpenCV, that could help me to solve this task? I don't need exact algorithm of solution, only themes. And if that's not OpenCV task, so  which is? What library? Should I learn some pack of themes and basics before the solution of my task?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2238,"Q_Id":51133962,"Users Score":1,"Answer":"One possible solution that I can think of is to alternate erosion and find contours till you have only one contour left (that should be the thicker). This could work if the difference in thickness is enough, but I can also foresee many particular cases that can prevent a correct identification, so it depends very much on how is your original image.","Q_Score":2,"Tags":"python,image,opencv,computer-vision","A_Id":51134741,"CreationDate":"2018-07-02T10:22:00.000","Title":"How can i scale a thickness of a character in image using python OpenCV?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to make a simple API using Python.\nThere are many tutorials to make a REST API using Django REST framework, but I don't need REST service, I just need to be able to process POST requests.\nHow can I do that? I'm new to Python.\nThank you!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5025,"Q_Id":51134093,"Users Score":0,"Answer":"Well if you don't need the whole DRF stuff than just don't use it. \nDjango is built around views  which take HTTP requests (whatever the verb - POST, GET etc) and return HTTP responses (which can be html, json, text, csv, binary data, whatever), and are mapped to urls, so all you have to do is to write your views and map them to url.","Q_Score":0,"Tags":"python,django,api,post","A_Id":51134824,"CreationDate":"2018-07-02T10:30:00.000","Title":"Python simple API application without Django REST framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Regarding word2vec with gensim,\nSuppose you already trained a model on a big corpus, and you want to update it with new words from new sentences, but not update the words which already have a vector.\nIs it possible to freeze the vectors of some words and update only some chosen words (like the new words) when calling model.train ?\nOr maybe is there a trick to do it ?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":436,"Q_Id":51135118,"Users Score":1,"Answer":"There is! But it's an experimental feature with little documentation \u2013 you'd need to read the source to fully understand it, and directly mutate your model to make use of it.\nLook through the word2vec.py source for properties ending _lockf \u2013 specifically in the latest code, one named vectors_lockf. It's a sort of mask which either allows, weakens, or stops training of certain words. For each word, if it's value is 1.0, normal full backpropagated updates are applied. Any lower value weakens the update \u2013 so 0.0 freezes a word against updates. (The potential update is still calculated \u2013 so there's no net speedup \u2013 it's just multiplied-by-0.0 before final application to particular frozen words.)","Q_Score":0,"Tags":"python,word2vec,gensim","A_Id":51139393,"CreationDate":"2018-07-02T11:26:00.000","Title":"Gensim Word2vec Freeze some wordvectors and Update others","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently wasted a lot of time trying to fix the row height in one of my Py-PPTX generated tables. The margin-top and margin-height parameters given were '0'. I also tried to control the height using the row.height parameter of the table. But the row was stuck at a larger height.\nAccidentally I discovered, this was happening because a few of the cells in my row were empty. As soon as I added some text to the cells, the row height resized to the desired values. \nI'm unable to understand why this could be happening, as in, why can't my row show up with the given height and margins without any text in them. I'd appreciate it, if anyone here understands this and could elaborate on it.\n[ At the moment, I'm having to fill a space instead of empty text in the table cells. This seems very hacky. ]\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":593,"Q_Id":51135478,"Users Score":0,"Answer":"I know this is old, but I may have an answer.\nThe empty cells may have a default text styling applied to them with a large point size. PowerPoint will often make default table text 17.8pt when inserting tables manually.\nWithout your code, it's difficult to know for sure, but if you're applying text styles to the table cell by cell, and it skips blank cells, it may be inheriting the default styling.","Q_Score":1,"Tags":"python,python-3.x,python-pptx","A_Id":62782879,"CreationDate":"2018-07-02T11:46:00.000","Title":"Python-PPTX: Why does the row height in a table expand if any of the cells in the row have empty text?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I first execute this command it create model in my model.py but when I call it second time for  another table in same model.py file then that second table replace model of first can anyone told the reason behind that because I am not able to find perfect solution for that?\n$ python manage.py inspectdb tablename > v1\/projectname\/models.py\nWhen executing this command second time for  another table then it replace first table name.\n$ python manage.py inspectdb tablename2 > v1\/projectname\/models.py","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1132,"Q_Id":51137859,"Users Score":0,"Answer":"python manage.py inspectdb table1 table2 table3... > app_name\/models.py\nApply this command for inspection of multiple tables of one database in django.","Q_Score":1,"Tags":"django,python-3.x","A_Id":58061835,"CreationDate":"2018-07-02T13:55:00.000","Title":"django inspectdb, how to write multiple table name during inspection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have list of paths as strings\n>>> p = ['\/path\/one\/foo.txt', '\/path\/two\/foo.txt', '\/path\/three\/foo.txt', '\/path\/four\/foo.txt]\nI know I can remove an entry containing a word from the list using something like\n>>> p = [x for x in p if 'two' not in x]\n>>> p\n['\/path\/one\/foo.txt', '\/path\/three\/foo.txt', '\/path\/four\/foo.txt']\nHowever, this doesn't seem to work\n>>> p = [x for x in p if 'two' or 'three' not in x]\n>>> p\n['\/path\/one\/foo.txt', '\/path\/two\/foo.txt', '\/path\/three\/foo.txt', '\/path\/four\/foo.txt]`\nHow can I remove all entries in p containing two or three?\nNote, I am pull values two and three from separate keys in a dict so it might not be simple to create a single list.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":65,"Q_Id":51140707,"Users Score":1,"Answer":"p = [x for x in p if 'two' not in x and 'three' not in x]\nIn Python, you have two separate Boolean statements: 'two' in x and 'three' in x. The syntax you were using does not work because Python is unable to recognize that syntax as two separate Boolean statements.","Q_Score":1,"Tags":"python,string,python-2.7,list,filepath","A_Id":51140743,"CreationDate":"2018-07-02T17:00:00.000","Title":"Remove list entries containing multiple conditions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I had a column in a dataframe, and that column contained two possible categorical variables, how do I count how many times each variable appeared? \nSo e.g, how do I count how many of the participants in the study were male or female?\nI've tried value_counts, groupby, len etc, but seem to be getting it wrong. \nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2617,"Q_Id":51140765,"Users Score":0,"Answer":"You could use len([x for x in df[\"Sex\"] if x == \"Male\"). This iterates through the Sex column of your dataframe and determines whether an element is \"Male\" or not. If it is, it is appended to a list via list comprehension. The length of that list is the number of Males in your dataframe.","Q_Score":0,"Tags":"python,python-3.x,pandas","A_Id":51140808,"CreationDate":"2018-07-02T17:04:00.000","Title":"Count Specific Values in Dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Kafka. I am sending a request to REST server and send the response of the request to kafka server as messages.\nWhen i consume the data from consumer the message is split into multiple smaller messages. How do i avoid this. The response is a JSON row. I want each json row to be one message. Any help would be appreciated. The size of the Json is also not very big. A json with over 1500 rows is about 2 MB\nFor eg \n\nConsumerRecord(topic='meetup_sample', partition=0, offset=445386, >timestamp=1530554568191, timestamp_type=0, >key=b'5fa4964b035c072a81fedb93cfca8f0ecb562cf913c69f63efbbf4e799871f05', >value=b':\"food-and-drink\",\"topic_name\":\"Food and Drink\"},{\"urlkey\":\"newintown\",\"topic_name\":\"New In Town\"},{\"urlkey\":\"beer\",\"topic_name\"', >checksum=None, serialized_key_size=64, serialized_value_size=128)\n  \n  ConsumerRecord(topic='meetup_sample', partition=0, offset=445387, >timestamp=1530554568192, timestamp_type=0, >key=b'1f170ceabf91335d332487ebb0890f0bd0ed69018c618ecc2c789a260d561f43', >value=b':\"Beer\"},{\"urlkey\":\"game-night\",\"topic_name\":\"Game Night\"},{\"urlkey\":\"happy-hours\",\"topic_name\":\"Happy Hour\"},{\"urlkey\":\"water-s', >checksum=None, serialized_key_size=64, serialized_value_size=128)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":556,"Q_Id":51141942,"Users Score":0,"Answer":"Once use fetch.message.max.bytes=2000000 in consumer side","Q_Score":0,"Tags":"python-3.x,apache-kafka,streaming","A_Id":71822982,"CreationDate":"2018-07-02T18:32:00.000","Title":"Kafka Messages are split in consumer","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am facing error while importing Keras.\nBelow is the error trace:\nUsing TensorFlow backend.\nTraceback (most recent call last):\n  File \"recognize.py\", line 8, in <module>\n    import keras\n  File \"\/home\/pi\/.local\/lib\/python2.7\/site-packages\/keras\/__init__.py\", line 3, in <module>\n    from . import utils\n  File \"\/home\/pi\/.local\/lib\/python2.7\/site-packages\/keras\/utils\/__init__.py\", line 6, in <module>\n    from . import conv_utils\n  File \"\/home\/pi\/.local\/lib\/python2.7\/site-packages\/keras\/utils\/conv_utils.py\", line 9, in <module>\n    from .. import backend as K\n  File \"\/home\/pi\/.local\/lib\/python2.7\/site-packages\/keras\/backend\/__init__.py\", line 87, in <module>\n    from .tensorflow_backend import *\n  File \"\/home\/pi\/.local\/lib\/python2.7\/site-packages\/keras\/backend\/tensorflow_backend.py\", line 5, in <module>\n    import tensorflow as tf\n  File \"\/home\/pi\/.local\/lib\/python2.7\/site-packages\/tensorflow\/__init__.py\", line 24, in <module>\n    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import\n  File \"\/home\/pi\/.local\/lib\/python2.7\/site-packages\/tensorflow\/python\/__init__.py\", line 63, in <module>\n    from tensorflow.python.framework.framework_lib import *  # pylint: disable=redefined-builtin\n  File \"\/home\/pi\/.local\/lib\/python2.7\/site-packages\/tensorflow\/python\/framework\/framework_lib.py\", line 25, in <module>\n    from tensorflow.python.framework.ops import Graph\n  File \"\/home\/pi\/.local\/lib\/python2.7\/site-packages\/tensorflow\/python\/framework\/ops.py\", line 54, in <module>\n    from tensorflow.python.platform import app\n  File \"\/home\/pi\/.local\/lib\/python2.7\/site-packages\/tensorflow\/python\/platform\/app.py\", line 24, in <module>\n    from tensorflow.python.platform import flags\n  File \"\/home\/pi\/.local\/lib\/python2.7\/site-packages\/tensorflow\/python\/platform\/flags.py\", line 33, in <module>\n    disclaim_key_flags()  # pylint: disable=undefined-variable\nNameError: name 'disclaim_key_flags' is not defined\n\nThis was found in RaspberryPi 3 Model B. OS: Raspbian Strech","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":588,"Q_Id":51142979,"Users Score":1,"Answer":"pip install --upgrade pip setuptools  work for me.","Q_Score":1,"Tags":"python,tensorflow,keras","A_Id":52422681,"CreationDate":"2018-07-02T19:59:00.000","Title":"Error while importing Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between tensor.permute() and tensor.view()? \nThey seem to do the same thing.","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":25972,"Q_Id":51143206,"Users Score":2,"Answer":"tensor.permute() permutes the order of the axes of a tensor.\ntensor.view() reshapes the tensor (analogous to numpy.reshape) by reducing\/expanding the size of each dimension (if one increases, the others must decrease).","Q_Score":27,"Tags":"python,multidimensional-array,deep-learning,pytorch,tensor","A_Id":66550315,"CreationDate":"2018-07-02T20:18:00.000","Title":"Difference between tensor.permute and tensor.view in PyTorch?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to find the publication date of newspaper articles published online using Python, but each website uses their own unique style for their html and the publication time in the page meta isn't consistent between different domains.  \nI've tried using the dateparser package, but it includes a relative dating system that incorrectly reads some words (like the string: 'a day') as relative times.  \nIs there a good list of regular expressions out there that someone knows of\/can share that includes as many ways to format a timestamp as possible, including support for reading timezones?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":51144283,"Users Score":0,"Answer":"In general, no - this task is not possible because humans infer context that you are probably not taking into account.\nConsider if your code encountered a string like 01\/05\/13.  What date is that?  Is it January 5th 2013? Or maybe it's May 1st 2013? Or May 13th 1801?  A human reader might pick up on the contexts of localization and century of publication, but unless you supply them separately - computer code will not.\nLikewise, consider if your code encountered a string like 3.14.   Is it March 14th? Or is it an approximation for the mathematical symbol \u03c0 ?  Without context of understanding the surrounding text, it's impossible to know.","Q_Score":0,"Tags":"python,regex,time,web-scraping,timezone","A_Id":51159351,"CreationDate":"2018-07-02T22:07:00.000","Title":"Finding all timestamps in a page using regular expressions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The best way I can think to explain my question is with the following example. Note that \"a conditional returning True\" is actually a response from an asynchronous websocket.\nSay, as a while True loop is running, there is a variable x assigned to a list of 15 dicts, each dict having 5 key\/value pairs, with each pair having been chosen randomly from a dict y of 26 key\/value pairs, where each key is a letter of the alphabet. It is known that none of the values of the dicts in x sum to > 50.\nSay some some conditional in the while True loop turns true, and the value for key a in y is now 30. Besides brute forcing, is there any faster way to check if the values of any dict in x now sum to > 50, accounting for the change to a? \nNote: I am looking for a solution that applies to all keys in y, not just a.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":42,"Q_Id":51144354,"Users Score":1,"Answer":"You could store how much \"space\" every dict still has left.\nSay dict1 sums 42, you would store 8.\nNow, every time you change some value in y, you need to know by how much you've changed. If the value was 10 and now is 22, you would see that 12 is bigger than 8, in other words, dict1 sums more than 50...\nRemember to update how much every dict still has left! If you changed 10 to 12, you will note that 2 is less than 8, meaning that dict1 still sums less than 50 after the change in y, bu know it only has 6...","Q_Score":0,"Tags":"python,algorithm,dictionary,optimization,websocket","A_Id":51144397,"CreationDate":"2018-07-02T22:17:00.000","Title":"Fastest way to run an algorithm on several arguments, having run it in the past, after a change to one variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know the difference between importing sklearn.model_estimation and sklearn.cross_validation when I run Python code for linear regression.\nI found out that sklearn.model_estimation calls a method called next(ShuffleSplit().split(X, y)) and sklearn.cross_validation calls a method called next(iter(ShuffleSplit(n_samples))) but I am still in darkness as to what is the difference between what these two methods actually perform. \nLooking for help.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":819,"Q_Id":51149995,"Users Score":3,"Answer":"cross_validation is an older package used previously in scikit. model_selection is newer replacement of the cross_validation (and some others too). It has some structural changes in the classes defined in it. \nSo same class which was previously in cross_validation is now present in model_selection but with changed behaviour (input params, output type, attributes etc).\nSo you should always use classes from model_selection.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn","A_Id":51153467,"CreationDate":"2018-07-03T08:31:00.000","Title":"What is the difference between sklearn.cross_validation and sklearn.model_estimation?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm stuck on a problem. I'm exporting code to .exe with pyinstaller. Code includes tkinter, PIL and keyboard modules.\nSoftware runs perfectly on my PC with Python, whereas on the one without Python it crashes whenever I use something linked to keyboard.\nTherefore, I concluded that keyboard module wasn't included properly when \"converting\" to .exe. \nI've tried including it with adding --hidden-import=keyboard in the script, but it also doesn't seem to work.\nHave You got any idea, how to possibly solve this and include that module into output?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":320,"Q_Id":51150492,"Users Score":0,"Answer":"I resolved it by changing application logic and hotkey management system. After a rigorous research, I came to a conclusion that this cannot be done in other way.","Q_Score":2,"Tags":"python,keyboard,pyinstaller","A_Id":68445006,"CreationDate":"2018-07-03T08:58:00.000","Title":"Pyinstaller & Keyboard","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm stuck on a problem. I'm exporting code to .exe with pyinstaller. Code includes tkinter, PIL and keyboard modules.\nSoftware runs perfectly on my PC with Python, whereas on the one without Python it crashes whenever I use something linked to keyboard.\nTherefore, I concluded that keyboard module wasn't included properly when \"converting\" to .exe. \nI've tried including it with adding --hidden-import=keyboard in the script, but it also doesn't seem to work.\nHave You got any idea, how to possibly solve this and include that module into output?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":320,"Q_Id":51150492,"Users Score":0,"Answer":"I had the same problem my Solution was to use the -p [Path] argument:\npyinstaller Proc.py -p \"C:\\Users\\New\\Desktop\\Project\\virtualenv\\Lib\\site-packages\"\nin the \"Lib\\site-packages\" was the Keyboard module installation.","Q_Score":2,"Tags":"python,keyboard,pyinstaller","A_Id":63799615,"CreationDate":"2018-07-03T08:58:00.000","Title":"Pyinstaller & Keyboard","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 6 dimension tables, all in the form of csv files. I have to form a star schema using Python. I'm not sure how to create the fact table using Python. The fact table (theoretically) has at least one column that is common with a dimension table. \nHow can I create the fact table, keeping in mind that quantities from multiple dimension tables should correspond correctly in the fact table?\nI am not allowed to reveal the code or exact data, but I'll add a small example. File 1 contains the following columns: student_id, student_name. File 2 contains : student_id, department_id, department_name, sem_id. Lastly File 3 contains student_id, subject_code, subject_score. The 3 dimension tables are in the form of csv files. I now need the fact table to contain: student_id, student_name, department_id, subject_code. How can I form the fact table in that form? Thank you for your help.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1539,"Q_Id":51151263,"Users Score":0,"Answer":"Reading certain blogs look like it is not a good way to handle such cases in python in memory but still if the below post make sense you cn use it\nFact Loading\nThe first step in DW loading is dimensional conformance. With a little cleverness the above processing can all be done in parallel, hogging a lot of CPU time. To do this in parallel, each conformance algorithm forms part of a large OS-level pipeline. The source file must be reformatted to leave empty columns for each dimension's FK reference. Each conformance process reads in the source file and writes out the same format file with one dimension FK filled in. If all of these conformance algorithms form a simple OS pipe, they all run in parallel. It looks something like this.\nsrc2cvs source | conform1 | conform2 | conform3 | load\nAt the end, you use the RDBMS's bulk loader (or write your own in Python, it's easy) to pick the actual fact values and the dimension FK's out of the source records that are fully populated with all dimension FK's and load these into the fact table.","Q_Score":0,"Tags":"python,csv,star-schema","A_Id":51152822,"CreationDate":"2018-07-03T09:37:00.000","Title":"Creating star schema from csv files using Python","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Dask library.I wanted to know if we implement parallel computation using dask on two systems ,then is the data frame on which we apply the computation stored on both the systems ? How actually does the parallel computation takes place,it is not clear from the documentation.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":51155513,"Users Score":0,"Answer":"Dask dataframes are chunked, so in general you have one big dataframe made up of smaller dataframes spread across your cluster.  Computations apply to each chunk individually with shuffling of results where required (such as groupby, sum and other aggregate tasks).","Q_Score":0,"Tags":"python-2.7,parallel-processing,dask,dask-distributed","A_Id":51211614,"CreationDate":"2018-07-03T13:11:00.000","Title":"How is dask implemented on multiple systems?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I try to run the file that I'm currently editing, it opens a new Python console window each time. \nHow can I make PyCharm run the current file using the console I already have open (i.e. the one that opens under Tools > Python Console...)?\nI know there is an \"Execute Selection in Console\" feature, but I don't want to onerously select code. I want to run the entire file.\nI'm trying to emulate the F5 run functionality in Spyder.\nEdit:\nSpyder also has a User Module Reloader (UMR) feature that reloads user-defined modules each time a file is run in the interactive console (as opposed to manually doing imp.reload()). Does PyCharm also have such a feature?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1670,"Q_Id":51158946,"Users Score":1,"Answer":"If I understand you correctly: Since PyCharm 2017.3 there is an action \"Execute File in Console\" which does exactly that. You can find it with Find action (Ctrl + Shift + A) and execute currently selected file.","Q_Score":4,"Tags":"python,pycharm","A_Id":51159170,"CreationDate":"2018-07-03T16:07:00.000","Title":"How can I make PyCharm run the current file in the existing console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I try to run the file that I'm currently editing, it opens a new Python console window each time. \nHow can I make PyCharm run the current file using the console I already have open (i.e. the one that opens under Tools > Python Console...)?\nI know there is an \"Execute Selection in Console\" feature, but I don't want to onerously select code. I want to run the entire file.\nI'm trying to emulate the F5 run functionality in Spyder.\nEdit:\nSpyder also has a User Module Reloader (UMR) feature that reloads user-defined modules each time a file is run in the interactive console (as opposed to manually doing imp.reload()). Does PyCharm also have such a feature?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1670,"Q_Id":51158946,"Users Score":0,"Answer":"On Pycharm 2018.1.4 you have to select \"Run File in Console\" the first time you wish to run a file in the console. Subsequently, you have to select the green arrowhead or press Shift+F10. All subsequent runs after the first will be executed in the open python terminal.","Q_Score":4,"Tags":"python,pycharm","A_Id":51850430,"CreationDate":"2018-07-03T16:07:00.000","Title":"How can I make PyCharm run the current file in the existing console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to delete some old python files via file explorer (Windows 10)  but I cannot find the files, except in the quick-access folder. There is no way to delete files in the quick-access folder. Can you help me? I'm looking for a folder \nwhich includes all my python files. Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":160,"Q_Id":51159489,"Users Score":3,"Answer":"If you right click on the folder itself, you should see something like \"Go to directory\" or \"Go to file location\" or anything similar to that. Once you go there, delete the folder.","Q_Score":2,"Tags":"windows,python-3.x,windows-10","A_Id":51159543,"CreationDate":"2018-07-03T16:46:00.000","Title":"How to delete Python files via explorer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We receive a .tar.gz file from a client every day and I am rewriting our import process using SSIS. One of the first steps in my process is to unzip the .tar.gz file which I achieve via a Python script.\nAfter unzipping we are left with a number of CSV files which I then import into SQL Server. As an aside, I am loading using the CozyRoc DataFlow Task Plus.\nMost of my CSV files load without issue but I have five files which fail. By reading the log I can see that the process is reading the Header and First line as though there is no HeaderRow Delimiter (i.e. it is trying to import the column header as ColumnHeader1ColumnValue1\nI took one of these CSVs, copied the top 5 rows into Excel, used Text-To-Columns to delimit the data then saved that as a new CSV file.\nThis version imported successfully.\nThat makes me think that somehow the original CSV isn't using {CR}{LF} as the row delimiter but I don't know how to check. Any suggestions?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2081,"Q_Id":51160071,"Users Score":0,"Answer":"Seeing that you have EmEditor, you can use EmEditor to find the eol character in two ways:\n\nUse View > Character Code Value... at the end of a line to display a dialog box showing information about the character at the current position.\nGo to View > Marks and turn on Newline Characters and CR and LF with Different Marks to show the eol while editing. LF is displayed with a down arrow while CRLF is a right angle.\n\nSome other things you could try checking for are: file encoding, wrong type of data for a field and an inconsistent number of columns.","Q_Score":2,"Tags":"python,csv,ssis,delimiter,eol","A_Id":51195993,"CreationDate":"2018-07-03T17:27:00.000","Title":"Which newline character is in my CSV?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I built an image classifier using CNTK. The images are grayscale. Therefore, I entered the number of channels as 1. So, the model requires (1x64x64) data (64 being the image height and width).\nThe problem is, when I try to predict the class of a new image, it is seen as (64x64) only. So, the code errors out due to data mismatch.\nTherefore, I reshaped the image using:\nimage_data = image_data.reshape((1, image_data.shape[0], image_data.shape[1]))\nThis generated (1x64x64) - which worked. Though the predictions are coming the same class for every image I select. I wonder if it is because of this reshaping or not. Can someone chime in? Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":72,"Q_Id":51160298,"Users Score":1,"Answer":"Reshaping your input would not affect the output of the model.  If it is only predicting one class for every image, it is an issue with model training.  I would suggest you try predicting on your training data to see if it only predicts one class on the training data.  If that is the case, it is definitely a model training issue.","Q_Score":1,"Tags":"python,image,classification,cntk","A_Id":51160557,"CreationDate":"2018-07-03T17:43:00.000","Title":"CNTK evaluation for image classification","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi I know it sounds a dumb question but it actually confuses me like what does text decoder give? \nI can understand with respect to audio\/video decoder that it gives the samples that can be converted to analog data that comes out from output devices.\nBut I actually cannot understand that what text decoder gives and how any decoded text can be taken to encode with any encoding schemes.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":141,"Q_Id":51160514,"Users Score":1,"Answer":"You assume there is no encoding scheme for text. This is wrong. There are dozens. For example, the character \u5678 as octet sequences in a few popular encodings:\n\nUTF-8: 0xe5 0x99 0xb8\nUTF-16-BE: 0x56 0x78\nGB18030: 0x87 0x8d\nUS-ASCII: impossible, the character does not belong to the encoding's character repertoire\nLatin9: impossible, the character does not belong to the encoding's character repertoire\n\nAnother one: \u00df\n\nUTF-8: 0xc3 0x9f\nUTF-16-BE: 0x00 0xdf\nGB18030: 0x81 0x30 0x89 0x38\nUS-ASCII: impossible, the character does not belong to the encoding's character repertoire\nLatin9: 0xdf\n\nAnother one: u\n\nUTF-8: 0x75\nUTF-16-BE: 0x00 0x75\nGB18030: 0x75\nUS-ASCII: 0x75\nLatin9: 0x75\n\nVerify this manually! Download this web page, open it in a hex editor and try to find the UTF-8 sequences above.\nA text decoder takes the octets as input and turns them into usable text again.\nYou probably haven't noticed this concept yet because you only worked with Latin characters so far, and although you neglected to care about text encoding and decoding everything worked out without apparent problems. This is because many encodings are somewhat backward compatible with granddaddy US-ASCII as you can see from the last example.\nPython, like many other programming languages, adheres to Unicode to a high degree, and so does its text processing model. The clear separation of text as a series of characters or graphemes (within the programming language) and encoded text as a series of octets (outside of the programming language, in disk files, standard I\/O streams, databases, command-line arguments, environment variables, network sockets etc.) is very necessary, otherwise you get the wrong result when you try to determine the size of text, or try to line-break it.\nA text codec is the precise boundary between these worlds.","Q_Score":0,"Tags":"unicode,decode,encode,codec,python-unicode","A_Id":51205697,"CreationDate":"2018-07-03T17:58:00.000","Title":"What is the output of text decoder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two custom-written C routines that I would like to use as a part of a large Python application. I would prefer not to rewrite the C code in pure Python (or Cython, etc.), especially to maintain speed.\nWhat is the cleanest, easiest way that I can use my C code from my Python code? Or, what is the cleanest, easiest way for me to wrap my C code for use in my Python source?\nI know \"cleanest\" and \"easiest\" will attract opinions, but I really just need some good options for using custom pre-written code, versus many of the other answers\/tutorials which describe how to use full-on C libraries as CPython extensions.\nEDIT:\nCython and ctypes have both been suggested. Which is a better choice in my case? Each of the two routines I mentioned originally are very computationally intensive. They are used for image calculations and reconstructions, so my plan is to build a Python application around their use (with other functionality in mind that I already have in Python) with the C code run as needed for processing.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":178,"Q_Id":51160830,"Users Score":1,"Answer":"Use cython to wrap your C code. In other words, create a CPython extension using Cython, that calls your C code.","Q_Score":0,"Tags":"python,c,python-3.x,python-3.5,python-c-api","A_Id":51160991,"CreationDate":"2018-07-03T18:21:00.000","Title":"Calling custom C subroutines in a Python application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been asked to create a system which has different functionalities. Assume service 1, service 2 and service 3. I need to run these services per hour to do something. \nTo make the system of those services I need: database, web interface for seeing the result of the process, caching and etc.\nThis is what I have thought about so far:\n\nI need kubernetes to orchestrate my services which are packaged as docker containers. I will deploy mySql to save my data and I can use Redis cache for caching.\nMy service are written by python scripts and Java and need to interact with each other through APIs.\nI think I can use AWS EKS for my kubernetes cluster \n\n\nthis is what I need to know: \n\nhow to deploy python or Java applications and connect them to each other and also connect them to a database service\nI also need to know how to schedule the application to run per hour so I can see the results in the web interface.\n\nPlease shoot any ideas or questions you have. \nAny help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":42,"Q_Id":51164215,"Users Score":1,"Answer":"For python\/java applications, create docker images for both applications. If these application run forever to serve traffic then deploy them as deployments.If you need to have only cron like functionality, deploy as  Job in kubernetes.\nTo make services accessible, create services as selector for applications, so these services can route traffic to specific applications.\nDatabase or cache should be exposed as service endpoints so your applications are environment independent.","Q_Score":0,"Tags":"java,python,docker,kubernetes","A_Id":51166017,"CreationDate":"2018-07-04T00:03:00.000","Title":"kubernetes architecture for microservices application - suggestions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I would like to crop the circular image attached below according to the following:\n\ncrop input circular image to the unique square inscribed in the circle.\ncrop the square image down to the circle inscribed in the square\ncrop the circular image from the previous step down to square that inscribes image.\n\nI am using python, opencv, and PIL. I have tried cropping with hard coding coordinates, but this obviously causes problems when applied to other images, so I would like a universal solution.\nI have included a rough visualization of how I would like to crop it:\nIn addition, I have included the original image:\nA code snippet with brief explanation would be greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":577,"Q_Id":51164645,"Users Score":2,"Answer":"The image you want to crop to is, geometrically, a square centered on the input image, half as large. This is because you're inscribing twice, each time the square shrinks by the square root of two, and dividing by SQRT(2) twice is the same thing as dividing by 2.\nSo if you have an input square of side D (or a circular image of diameter D), what you need to do is crop with center (D\/2, D\/2) and a side of D\/2.","Q_Score":0,"Tags":"python,image,opencv,image-processing,python-imaging-library","A_Id":51180855,"CreationDate":"2018-07-04T01:22:00.000","Title":"How to crop a circular image to inscribed square, then crop to inscribed circle, and finally crop to inscribed square?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have read some journals and paper of HMM and MFCC but i still got confused on how it works step by step with my dataset (audio of sentences dataset).\nMy data set Example (Audio Form) :\n\nhello good morning\ngood luck for you exam\netc\nabout 343 audio data and 20 speaker (6800 audio data)\n\nAll i know :\n\nMy sentences datasets is used to get the transition probabilty\nHmm states is the phonemes\n39 MFCC features is used to train the HMM models\n\nMy Questions :\n\nDo i need to cut my sentences into words or just use sentences for train \nHMM models?\nDo I need phonemes dataset for train ? if yes do i need to train it use HMM too ? if not how my program recognize the phonemes for HMM predict input?\nWhat steps i must do first ?\n\nNote : Im working with python and i used hmmlearn and python_speech_features as my library.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":795,"Q_Id":51165305,"Users Score":1,"Answer":"Do i need to cut my sentences into words or just use sentences for train HMM models?\n\nTheoretically you just need sentences and phonemes. But having isolated words may be useful for your model (it increases the size of your training data)\n\nDo I need phonemes dataset for train ? if yes do i need to train it use HMM too ? if not how my program recognize the phonemes for HMM predict input?\n\nYou need phonemes, otherwise it will be too hard for your model to find the right phoneme segmentation if it does not have any example of isolated phonemes. You should first train your HMM states on the isolated phonemes and then add the rest of the data. If you have enough data, your model may be able to learn without the isolated phoneme examples, but I wouldn't beat on this.\n\nWhat steps i must do first ?\n\nBuild your phoneme examples and use them to train a simple HMM model you don't model the transition between phonemes. Once your hidden states have some information about phonemes, you may continue the training on isolated words and sentences.","Q_Score":3,"Tags":"python,tensorflow,speech-recognition,mfcc,hmmlearn","A_Id":51167856,"CreationDate":"2018-07-04T03:22:00.000","Title":"How to train HMM with audio senteces dataset for speech recognition?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have multiple csv files in the form of a star schema. To perform analytics using Python, is it better to combine all these csv files into one csv file, or to extract data from each csv file and then do analytics? People online have almost always combined all files into one and have then performed analytics. However, combining all csv files would eliminate my star schema.  I currently have approximately 25,000 rows and 10 columns in each csv file. The size of each csv file is around 7 MB. Thank you in advance for your help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":143,"Q_Id":51165589,"Users Score":1,"Answer":"I feel you can leave the fact tables as is and combine the rest of the data with which you can reduce the amount of data your dealing with and have the star schema intact too..\nThanks,\nRam","Q_Score":0,"Tags":"python,data-analysis","A_Id":51165703,"CreationDate":"2018-07-04T04:04:00.000","Title":"Data analytics using Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python program which I compiled into a .exe file using PyInstaller. When you open the .exe, there should be no console, no command prompt or whatever. It should run the Python program in the background completely silently.\nIs it possible to put something in the Python script so that it does not open a command prompt and executes silently?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":716,"Q_Id":51168728,"Users Score":1,"Answer":"You can use the --noconsole option, if this doesn't work\nchange the spec file setting \"console\" to False.","Q_Score":0,"Tags":"python,windows,batch-file","A_Id":51168927,"CreationDate":"2018-07-04T08:06:00.000","Title":"Start Python program in the background","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have three scripts:\nconfig.yaml and script.py and slurm.sh\nI am submitting job to the job scheduler in Slurm using the slurm.sh file which calls the script.py file and the script.py files loads the config from the config.yaml file.\nIt would look like this:\nsbatch slurm.sh\nNow, I change the config.yaml and submit another job. However, if both jobs are in the queue, the config.yaml file will be overwritten and both jobs will use the same configuration. \nIs there any way to tell the slurm scheduler to cache the config.yaml file as well? I know it is dont for the slurm.sh file.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":51169224,"Users Score":1,"Answer":"There is no way to achieve that. You should modify your script (.sh) to point to the proper configuration file before submission, and create as many configuration files as needed.\nAnother option could be to convert the configuration file entries to command line parameters (if possible) before submission and submit a script with a fully configured command line (so no need to read the .yaml file).","Q_Score":0,"Tags":"python,config,slurm,sbatch","A_Id":51175506,"CreationDate":"2018-07-04T08:33:00.000","Title":"How to tell slurm to cache config file for multiple submissions","Data Science and Machine Learning":0,"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 use pytorch in MSVS2017.  I started a pytorch project, have anaconda environment set using python3.6, but when I run the debugger, I get a \"module not found\" error on the first import statement \"import torch\".  I've tried various methods for installing pytorch in a way that allows MSVS2017 to use it, including command line and Anaconda command line installations (using tips from other closely related StackOverflow questions), but I cannot clear the error.  This is a native MSVS2017 project type that came with their AI Tools module.  What am I doing wrong?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":92,"Q_Id":51173695,"Users Score":1,"Answer":"Probably, at the date of our MSVS2017 installation (esp. if prior to April 2018), there were no official .whl files for Windows pytorch (this has since changed).  Also, given the default installation pathway, permissions on Windows (or file lock access) may be a problem (for example, when attempting to install to the \"c:\\ProgramData\" folder).  \nThe solution is to 1) ensure all pytorch requisites are installed first (for example, if, during your failed pytorch installation you get a \"_____ requires _____ which is not installed, for example cython, then install cython) 2) avoid permission errors by using the --user switch, and 3) install directly from the online repository.  \nSo, at the environment command line (top right corner in the \"Python Environments\" tool) provide --user  http:\/\/download.pytorch.org\/whl\/cpu\/torch-0.4.0-cp36-cp36m-win_amd64.whl.  \nThis operation will create and execute the command: pip install --user  http:\/\/download.pytorch.org\/whl\/cpu\/torch-0.4.0-cp36-cp36m-win_amd64.whl.\nIncidentally, you can install all packages at this environmental command line simply by typing the package name (e.g., cython, torchvision, scipy, etc...).","Q_Score":1,"Tags":"python,installation,anaconda,pytorch","A_Id":51173697,"CreationDate":"2018-07-04T12:26:00.000","Title":"How do I install and run pytorch in MSVS2017 (to avoid \"module not found\" error on \"import torch\" statement)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using search_ext_s() method of python-ldap to search results on the basis of filter_query, upon completion of search I get msg_id which I passed in result function like this ldap_object.result(msg_id) this returns tuple like this (100, attributes values) which is correct(I also tried result2, result3, result4 method of LDAP object), But how can I get response code for ldap search request, also if there are no result for given filter_criteria I get empty list whereas in case of exception I get proper message like this \nldap.SERVER_DOWN: {u'info': 'Transport endpoint is not connected', 'errno': 107, 'desc': u\"Can't contact LDAP server\"}\nCan somebody please help me if there exists any attribute which can give result code for successful LDAP search operation.\nThanks,\nRadhika","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":549,"Q_Id":51174045,"Users Score":0,"Answer":"An LDAP server simply may not return any results, even if there was nothing wrong with the search operation sent by the client. With python-ldap you get an empty result list. Most times this is due to access control hiding directory content. In general the LDAP server won't tell you why it did not return results.\n(There are some special cases where ldap.INSUFFICIENT_ACCESS is raised but you should expect the behaviour to be different when using different LDAP servers.)\nIn python-ldap if the search operation did not raise an exception the LDAP result code was ok(0). So your application has to deal with an empty search result in some application-specific way, e.g. by also raising a custom exception handled by upper layers.","Q_Score":0,"Tags":"python-ldap","A_Id":51365948,"CreationDate":"2018-07-04T12:45:00.000","Title":"search_s search_ext_s search_s methods of python-ldap library doesn't return any Success response 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 accidentally deleted my migrations folders for all my apps including __init__.py. Is there any way to reset or retrieve these? Thank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4733,"Q_Id":51174718,"Users Score":12,"Answer":"Just create migrations folder the folder again, then create __init__.py file. After that run manage.py makemigrations","Q_Score":3,"Tags":"python,django","A_Id":51175021,"CreationDate":"2018-07-04T13:20:00.000","Title":"Deleted Django Migrations Folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working in a project that retrieves some data from a rest service. One of the retrieved fields is a department number that need to be searched in a set of data in order to get the department name. That set of data has been given to me in a csv file (at least is not excel) with 1200 records.\nThe dataset is fixed and will not be updated (let's assume that's true) and the project doesn't have a database.\nSo I'm looking for the best alternative for storing this set: could be a hard coded dictionary or sqlite, what do you think? is there a better alternative?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":64,"Q_Id":51178233,"Users Score":2,"Answer":"For a REST service, storing the data in sqlite is better because loading 1200 records from a hard-coded python dict creates overhead in both memory and loading time every time your REST service is called. sqlite is fully indexed on the filesystem so all data retrieval will be on an as-needed basis, which will create only a minimal overhead to each of your REST service call.","Q_Score":0,"Tags":"python,django","A_Id":51178409,"CreationDate":"2018-07-04T16:58:00.000","Title":"Store fixed data in Django: dictionary or sqlite?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I am using Pycharm IDE on Windows 10, but in Windows' most recent update they have added a new keyboard shortcut (Alt+Shift+F10) for changing the screen display to negative. The problem is this shortcut is the same as the \"Run\" shortcut in Pycharm which I use very frequently. As far as I'm aware there is no way to change the keyboard shortcuts in Windows 10, but perhaps there is a way to change shortcuts in Pycharm? Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":247,"Q_Id":51179120,"Users Score":3,"Answer":"In File -> Settings -> Keymap you can modify the shortcuts the way you want.","Q_Score":1,"Tags":"python,windows-10,pycharm","A_Id":51179193,"CreationDate":"2018-07-04T18:14:00.000","Title":"Pycharm\/Windows 10 keyboard shortcut clash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just started using Freeling, and I am using it to obtain the lemma form (get_lemma() ) and saving it on a string of some Spanish reviews I get from Google Maps API. Freeling works well with sentences that have full stop at the end (for example, \u201cBuen lugar, comodo y agradable.\"), but it does not when the review doesn\u2019t have full stop (for example, Buen lugar. Trato amigable). In that case, Freeling won\u2019t return the lemma form of each one of the words in the sentence, so the string remains empty.\nIs there any way of making Freeling return the lemma form of sentences that doesn\u2019t have a full stop, other than adding it manually to the sentence?\nI\u2019m writting the code in Python, using the example from sample.py.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":90,"Q_Id":51179345,"Users Score":0,"Answer":"You can add the option \"flush=true\" to the splitter.\nPlease check the user manual, this is described there.\nIf you ask your questions in FreeLing forum, answers may come faster...","Q_Score":0,"Tags":"python-3.x,freeling","A_Id":52170111,"CreationDate":"2018-07-04T18:33:00.000","Title":"Use Freeling with sentences without full stop at the end?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have deployed my django application to a CentOS server and everything is working fine. I can see the list of users and groups from the Django Administration page. I was able to add\/edit users as well before. But now, when I'm trying to add new user, an Server Error (500) is returned. \nIs there any limitations about the number of users can be added using Django Admin page?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":349,"Q_Id":51179393,"Users Score":0,"Answer":"run:- python manage.py makemigrations and python manage.py migrate if you add any model","Q_Score":0,"Tags":"python,django","A_Id":51179502,"CreationDate":"2018-07-04T18:37:00.000","Title":"Django administration add user returns Server Error (500)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Let's say I have 100x200 numpy array of random numbers and wish to average blocks of 5x5 in the this array, that is I need the operation to be done on all 800 distinct blocks that are 5x5. I wonder if there is an efficient way to do this without nested loop and possibly without any loop.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":51180854,"Users Score":0,"Answer":"You can iterate over the array and just call numpy.average on the 5x5 blocks ?","Q_Score":0,"Tags":"python,vectorization","A_Id":51180929,"CreationDate":"2018-07-04T21:19:00.000","Title":"operation on blocks of a matrix efficiently in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get the error: \n\nmodule 'matplotlib.colors' has no attribute 'to_rgba',\n\nwhen i import chainer in ipynb.\nI am using python 2 ,anaconda 4.1.1 ,chainer 4 and matplotlib 1.5.1.could anyone asses the problem","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":322,"Q_Id":51184116,"Users Score":0,"Answer":"Try restarting your text editor and trying it, sometimes it needs to be restarted for changes to take effect.","Q_Score":0,"Tags":"python,anaconda,chainer","A_Id":51184234,"CreationDate":"2018-07-05T05:46:00.000","Title":"Import chainer in python throws error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a corpus consisting of around 160,000 documents. I want to do a topic modeling on it using LDA in R (specifically the function lda.collapsed.gibbs.sampler in lda package). \nI want to determine the optimal number of topics. It seems the common procedure is to have a vector of topic numbers, e.g., from 1 to 100, then run the model for 100 times and the find the one has the largest harmonic mean or samllest perplexity. \nHowever, given the large amount of documents, the optimal number of topics can easily go to several hundreds or even thousands. I find that as the number of topic increases, the computation time grows significantly. Even if I use parallel computing, it will several days or weeks. \nI wonder is there a better (time-efficient) way to choose the optimal number of topics? or is there any suggestion to reduce the computation time?\nAny suggestion is welcomed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":826,"Q_Id":51185358,"Users Score":0,"Answer":"Start with some guess in middle. decrease and increase the number of topics by say 50 or 100 instead of 1. Check in which way Coherence Score is increasing. I am sure it will converge.","Q_Score":1,"Tags":"python,r,lda,topic-modeling","A_Id":51226434,"CreationDate":"2018-07-05T07:15:00.000","Title":"Fast way to determine the optimal number of topics for a large corpus using LDA","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running a large suite of python tests using pytest, and some test results depend on the running order of the tests. For example if test B runs after test A then it can fail due to some initializations done in test A that affect test B.\nTo circumvent this problem I would like to run each test in a new process, but the tests should still run sequentially and not in parallel.\nIs there a way to do that with pytest?","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1955,"Q_Id":51187188,"Users Score":-2,"Answer":"I would recommend that you implement setup_method() and teardown_method() that can cleanup initializations you do in the tests. This way you can get rid of dependencies you have with the order of execution of your tests.\nThe other alternative would be to use a fixture. \nBut if you dont want to run the tests in parallel, I dont see the advantage of starting each test in a new process. Although if you still need it, you can start a new process in your setup_method() and attach the current test to this process. Your teardown_method() can then kill this process.","Q_Score":4,"Tags":"python,pytest","A_Id":51187357,"CreationDate":"2018-07-05T08:57:00.000","Title":"pytest - run each test in a separate process","Data 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 the title says. I'll give some background as to why I ask this question. I have just started learning a bit of python, and embarrassingly I have re-named all the files in the anaconda folder by running a script I had written in the wrong folder due to misinterpreting the code I was using as an example. This is incredibly frustrating as you can imagine and seems to be quite an easy mistake for a beginner to make. I was wondering if there are any techniques to prevent this sort of thing happening when you're learning, other than being more careful?\nThanks for your advice.\nChristian","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":51191863,"Users Score":1,"Answer":"With low level languages like Assembly, it was much more common for beginners to make damaging mistakes but now adays, you cant do too much damage without really trying to do damage if that makes sense.\nWhen it comes to scripts you don't entirely follow, you should look for things like \n\nDoes it modify\/read a file?\nDoes it run any system commands like \"rm -rf\"\nDoes it have any infinite loops or anything that seems strange?\n\nOf course this is just a very simple list, there is no actual check list for \"bad stuff\".\nIn your case, it sounds like you just got unlucky. Don't look at it as a failure, look at it as you learned what the script can do. \nYou can also set up a Virtual Machine to use as a \"sandbox\" for your applications.\nOne last thing, since you are starting on this journey, it is important to make backups of your code\/workspace and your important computer files. This is because you might want to go back to a previous version of your code.","Q_Score":0,"Tags":"python,visual-studio","A_Id":51192075,"CreationDate":"2018-07-05T12:54:00.000","Title":"What are good ways to protect yourself against damaging your system when starting to learn coding\/ a new language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As the title says. I'll give some background as to why I ask this question. I have just started learning a bit of python, and embarrassingly I have re-named all the files in the anaconda folder by running a script I had written in the wrong folder due to misinterpreting the code I was using as an example. This is incredibly frustrating as you can imagine and seems to be quite an easy mistake for a beginner to make. I was wondering if there are any techniques to prevent this sort of thing happening when you're learning, other than being more careful?\nThanks for your advice.\nChristian","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":38,"Q_Id":51191863,"Users Score":1,"Answer":"I prefere setting up a virtual machine while coding \n\"potential dangerous things\" \nVM's also have the advantage of making snapshots before running the code that afterwards easily can be reset (e.g. for testing things multiple times)","Q_Score":0,"Tags":"python,visual-studio","A_Id":51192104,"CreationDate":"2018-07-05T12:54:00.000","Title":"What are good ways to protect yourself against damaging your system when starting to learn coding\/ a new language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to use github3.py python library to access github with a SSH key?\nI'm trying to create a service that writes on some repositories using a machine user for security reasons.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":138,"Q_Id":51192262,"Users Score":1,"Answer":"Unfortunately, the GitHub API doesn't provide a way to authenticate with SSH keys. Thus, github3.py provides no way to login using SSH keys.","Q_Score":0,"Tags":"python,github-api,github3.py","A_Id":51211308,"CreationDate":"2018-07-05T13:13:00.000","Title":"github3.py login using ssh keys","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'd like to generate an .exe file with --onedir and move the generated exe out of the dist folder to elsewhere (e.g. Desktop) and set up some absolute path to the dist folder so that the .exe can still work properly.\nI've tried things such as, set up the Python env or the load library inside the python script to the Dist folder, but, nothing worked so far. I also looked into the manual but I couldn't find anything relevant regarding this issue. \nDoes anybody have any suggestions?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2033,"Q_Id":51197350,"Users Score":2,"Answer":"You can just make a shortcut to your .exe file. Keep the folder in your C drive or anywhere you want it, but right click on the .exe and select create shortcut.","Q_Score":1,"Tags":"python,dependencies,exe,pyinstaller,lib","A_Id":51198587,"CreationDate":"2018-07-05T17:54:00.000","Title":"Move the exe out of the dist folder and make it work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'd like to generate an .exe file with --onedir and move the generated exe out of the dist folder to elsewhere (e.g. Desktop) and set up some absolute path to the dist folder so that the .exe can still work properly.\nI've tried things such as, set up the Python env or the load library inside the python script to the Dist folder, but, nothing worked so far. I also looked into the manual but I couldn't find anything relevant regarding this issue. \nDoes anybody have any suggestions?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2033,"Q_Id":51197350,"Users Score":1,"Answer":"The --onedir parameter creates a folder containing all your exe needs to run. You need to move the entire folder elsewhere, not just the .exe, because that's how it works.\nIf you want everything contained in a single exe, use --onefile instead. This would increase the size of your exe, but you would have to deal with only one file instead of a dir, easing portability.","Q_Score":1,"Tags":"python,dependencies,exe,pyinstaller,lib","A_Id":51197827,"CreationDate":"2018-07-05T17:54:00.000","Title":"Move the exe out of the dist folder and make it work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"In flat sequences(eg. str, bytes, bytearray etc) can we have in operator unlike container sequence(eg. list, tuple, collections.deque etc)? Is there anywhere else we can use in operator other than container sequence?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":234,"Q_Id":51197740,"Users Score":0,"Answer":"Any class can implement __contains__ in any fashion it desires. For example, a class that subclasses int can implement __contains__ so it checks if a number is a factor of the integer that it represents., eg 2 in special_integer(6).\nI tend to disagree with your assessment that str, bytes (and obviously bytearray) are \"flat\". After all, they are all iterable.","Q_Score":1,"Tags":"python,containers","A_Id":51197802,"CreationDate":"2018-07-05T18:24:00.000","Title":"Can a flat sequence have 'in' operator in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to create column with sequential numbers in pyspark dataframe starting from specified number. For instance, I want to add column A to my dataframe df which will start from 5 to the length of my dataframe, incrementing by one, so 5, 6, 7, ..., length(df). \nSome simple solution using pyspark methods?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":11579,"Q_Id":51200217,"Users Score":2,"Answer":"Three simple steps:\nfrom pyspark.sql.window import Window\nfrom pyspark.sql.functions import monotonically_increasing_id,row_number\ndf =df.withColumn(\"row_idx\",row_number().over(Window.orderBy(monotonically_increasing_id())))","Q_Score":2,"Tags":"python,dataframe,pyspark,sequential-number","A_Id":63504519,"CreationDate":"2018-07-05T21:37:00.000","Title":"How to create sequential number column in pyspark dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently running an airflow (1.9.0) instance on python 3.6.5. I have a manual workflow that I'd like to move to a DAG. This manual workflow now requires code written in python 2 and 3. Let's simplify my DAG to 3 steps:\n\nDataflow job that processes data and sets up data for Machine\nLearning Training \nTensorflow ML training job\nOther\nPythonOperators that I wrote using python 3 code\n\nThe dataflow job is written in python 2.7 (required by google) and the tensorflow model code is in python 3. Looking at \"MLEngineTrainingOperator\" in airflow 1.9.0 there is a python_version parameter which sets the \"The version of Python used in training\".\nQuestions:\n\nCan I dynamically specify a specific python version in a worker\nenvironment?\nDo I have to just install airflow on python 2.7 to make step 1) run?\nCan I have tensorflow model code in python 3 that just gets packaged up and submitted via MlEngineTraining running on python 2?\nDo I have to rewrite my 3) operators in python 2?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4405,"Q_Id":51201188,"Users Score":4,"Answer":"There isn't a way specify the python version dynamically on a worker. However if you are using the the Celery executor, you can run multiple workers either on difference servers\/vms or in different virtual environments.  \nYou can have one worker running python 3, and one running 2.7, and have each listening to different queues.  This can be done three different ways:\n\nWhen starting the worker you can add a -q [queue-name] flag\nset an env of AIRFLOW__CELERY__DEFAULT_QUEUE\nupdating default_queue under [celery] in the airflow.cfg. \n\nThen in your task definitions specify a queue parameter, changing the queue up depending on which python version the task needs to run.\nI'm not familiar with the MLEngineOperator, but you can specify a python_version in the PythonOperator which should run it in a virtualenv of that version.  Alternative you can use the BashOperator, write the code to run in a different file and specify the python command to run it using the absolute path the version of python you want to use.\nRegardless of how the task is run, you just need to ensure the DAG itself is compatible with python version you are running it as it. ie. if you are going to start an airflow worker in different python versions, the DAG file itself needs to be python 2 & 3 compatible. The DAG can have addition file dependencies that it uses have version incompatibilities.","Q_Score":4,"Tags":"python,tensorflow,google-cloud-dataflow,airflow","A_Id":51209553,"CreationDate":"2018-07-05T23:32:00.000","Title":"Python 3.6 airflow with a Operator that requires 2.7","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to learn ML using Kaggle datasets. In one of the problems (using Logistic regression) inputs and parameters matrices are of size (1110001, 8) & (2122640, 8) respectively.\nI am getting memory error while doing it in python. This would be same for any language I guess since it's too big. My question is how do they multiply matrices in real life ML implementations (since it would usually be this big)?\nThings bugging me :\n\nSome ppl in SO have suggested to calculate dot product in parts and then combine. But even then matrix would be still too big for RAM (9.42TB? in this case)\n\nAnd If I write it to a file wouldn't it be too slow for optimization algorithms  to read from file and minimize function?\n\nEven if I do write it to file how would fmin_bfgs(or any opt. function) read from file?\n\nAlso Kaggle notebook shows only 1GB of storage available. I don't think anyone would allow TBs of storage space.\n\nIn my input matrix many rows have similar values for some columns. Can I use it my advantage to save space? (like sparse matrix for zeros in matrix)\nCan anyone point me to any real life sample implementation of such cases. Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":102,"Q_Id":51205149,"Users Score":0,"Answer":"I have tried many things. I will be mentioning these here, if anyone needs them in future:\n\nI had already cleaned up data like removing duplicates and\nirrelevant records depending on given problem etc. \nI have stored large matrices which hold mostly 0s as sparse matrix.  \nI implemented the gradient descent using mini-batch method instead of plain old Batch method (theta.T dot X).\n\nNow everything is working fine.","Q_Score":0,"Tags":"python,numpy,machine-learning,scipy,logistic-regression","A_Id":51456740,"CreationDate":"2018-07-06T07:29:00.000","Title":"How to find dot product of two very large matrices to avoid memory error?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed several packages as sudoer using sudo pip install package_name command. The packages are installed and work well in this user.\nAfterwards, I have defined a new user. My problem is that the packages are not available in the new user and when trying to import them this error is appeared: No module named package_name. Is there any way in which I do not need to reinstall the packages for new user and use the packages installed by the sudoer?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":224,"Q_Id":51205924,"Users Score":0,"Answer":"The environment variables must be defined for the new user again.Try setting the environment variables for python and pip for the new user","Q_Score":0,"Tags":"python,python-2.7,ubuntu,pip,ubuntu-16.04","A_Id":51207221,"CreationDate":"2018-07-06T08:18:00.000","Title":"pip packages not available for new user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is most likely a dumb question but being a beginner in Python\/Numpy I will ask it anyways. I have come across a lot of posts on how to Normalize an array\/matrix in numpy. But I am not sure about the WHY. Why\/When does an array\/matrix need to be normalized in numpy? When is it used?\nNormalize can have multiple meanings in difference context. My question belongs to the field of Data Analytics\/Data Science. What does Normalization mean in this context? Or more specifically in what situation should I normalize an array?\nThe second part to this question is - What are the different methods of Normalization and can they be used interchangeably in all situations? \nThe third and final part - can Normalization be used for Arrays of any dimensions?\nLinks to any reference material (for beginners) will be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":229,"Q_Id":51208733,"Users Score":2,"Answer":"Consider trying to cluster objects with two numerical attributes A and B. Both are equally important. Attribute A can range from 0 to 1000 and attribute B can range from 0 to 5. \nIf you did not normalize A and B you would end up with attribute A completely overpowering attribute B when applying any standard distance metric.","Q_Score":0,"Tags":"python,arrays,numpy,normalization","A_Id":51208845,"CreationDate":"2018-07-06T10:48:00.000","Title":"Python, Numpy - Normalize a matrix\/array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In our setup we have a central RabbitMQ instance running on three hosts, each with its own URL.\nFor maintenance, any of these hosts may go down at any time for several hours. When this happens, we would like to connect to one of the other hosts.\nWe have been using aio_pika.connect_robust to connect, but it only accepts a single host as parameter.\nIt would be perfect if the reconnect could happen seamlessly in the background. A worker could get a message from the connection to one host, work on it and then acknowledge it over a different connection.\nWhat would be the best way to solve this?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1779,"Q_Id":51210556,"Users Score":2,"Answer":"A worker could get a message from the connection to one host, work on it and then acknowledge it over a different connection\n\nThat's not possible, since acks are tied to channels. When the first channel closes, RabbitMQ will re-enqueue the message and will re-deliver it to another consumer.\nIt looks as though aio-pika does not support multiple hosts from which to choose to connect. I recommend either trapping connection-related exceptions yourself to choose another host, or put haproxy between your application and RabbitMQ.","Q_Score":3,"Tags":"rabbitmq,python-asyncio,pika,reconnect","A_Id":51223805,"CreationDate":"2018-07-06T12:30:00.000","Title":"Robust aio-pika connection to multiple RabbitMQ hosts","Data Science and Machine Learning":0,"Database and SQL":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 file with various functions, called mypyfile. For a while now I have had custom functions there that I use, and I import them in using import mypyfile. I recently moved to 3.6 from 3.4 because of dependencies from a specific package I was using. I am now trying to import mypyfile, but the update that I made to the file and saved it, is not working. \nThe mypyfile.py exists in the main working directory. The import function does work, and it does import my file in. When I use the newly changed function from that file is when it fails, indicating that the changes I made were not updated. \nI'm likely not doing the package thing right in python, I just have a .py file with functions in it, no init.py file, or structured package folder. just one .py file with a bunch of functions in it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":767,"Q_Id":51214041,"Users Score":2,"Answer":"It's possible that Python is using a cached bytecode version of your file, rather than reading the new version. If you have a __pycache__ directory, or any files with the extension .pyc, try deleting them and importing your file again.","Q_Score":0,"Tags":"python,module","A_Id":51214336,"CreationDate":"2018-07-06T16:00:00.000","Title":"updates from updated py file not working when imported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a 2D array of ~200,000 points, and wish to \"jitter\" these points such that the distance between any point and its nearest neighbor is >= some minimum value.\nBefore writing this algorithm from scratch, I wanted to ask: Are there any canonical approaches or often-used algorithms to implement this behavior? I thought it would make sense to start by reviewing those algorithms before setting out on this.\nAny suggestions others can offer on this question would be greatly appreciated.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":625,"Q_Id":51214496,"Users Score":0,"Answer":"compute pairwise distances between all points -\nsklearn.metrics.pairwise.euclidean_distances \ncompute minimum of all pairwise distances\nif minimum is small enough, exit\ncompute pairwise vectors between each two points so they point away\nfrom each other\ndivide by pairwise distances so they are unit\nvectors\nfor each point, compute how far to nudge it as sum over\nother points of: pairwise vector\/pairwise distance squared * some\nconstant (the force - constant should be set so that when points are at the minimum distance force is small but not infinitesimal)\nnudge all the points by amount\ncomputed in 6. should also cap the nudge at maybe minimum\/10, so if 2 points end up in same spot, they don't get nudged an infinite distance apart\nrepeat until minimum is small enough\n\nShould converge in all cases but will expand canvas as necessary. Also it is memory and compute intensive for e.g. 200,000 points, but a sparse matrix that ignores large vectors\/small forces makes it more tractable.","Q_Score":4,"Tags":"python,algorithm,numpy","A_Id":54048062,"CreationDate":"2018-07-06T16:32:00.000","Title":"Python: Ensure each pairwise distance is >= some minimum distance","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the code ...\nplugins.TimestampedGeoJson (\n        {\n                'type': 'FeatureCollection',\n                'features': features\n        },\n        period = 'PT1M',\n        transition_time = 100,\n        loop = False,\n        auto_play = False,\n        duration = 'PT1M'\n).add_to(m)\nand I'm getting the error message ...\nTypeError: init() got an unexpected keyword argument 'duration'\nThe same happens with the parameter time_slider_drag_update. The map and time animation works fine without these parameters but I'm getting a stack of markers on top of each other because I'm not removing the markers after the timestamp has finished if that makes sense. I want the map to refresh not build.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":249,"Q_Id":51215496,"Users Score":0,"Answer":"The duration parameter was added to the TimestampedGeoJson plugin in version 0.6.0. Double-check the version of folium you're using with pip freeze | grep folium and if it's < 0.6 then upgrade it with pip install -U folium.","Q_Score":0,"Tags":"python,geojson,folium","A_Id":52014346,"CreationDate":"2018-07-06T17:47:00.000","Title":"duration parameter not working with Folium plugin timestampedGeoJson","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use VS code for my Python projects and we have unit tests written using Python's unittest module. I am facing a weird issue with debugging unit tests.\nVSCode Version: May 2018 (1.24)\nOS Version: Windows 10  \nLet's say I have 20 unit tests in a particular project.\nI run the tests by right clicking on a unit test file and click 'Run all unit tests'\nAfter the run is complete, the results bar displays how many tests are passed and how many are failed. (e.g. 15 passed, 5 failed).\nAnd I can run\/debug individual test because there is a small link on every unit test function for that.\nIf I re-run the tests from same file, then the results bar displays the twice number of tests. (e.g. 30 passed, 10 failed)\nAlso the links against individual test functions disappear. So I cannot run individual tests.\nThe only way to be able to run\/debug individual tests after this is by re-launching the VS code.\nAny suggestions on how to fix this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2562,"Q_Id":51215617,"Users Score":0,"Answer":"This was a bug in Python extension for VS code and it is fixed now.","Q_Score":1,"Tags":"python,python-2.7,visual-studio-code","A_Id":53988353,"CreationDate":"2018-07-06T17:58:00.000","Title":"Python Unit test debugging in VS 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":"total beginner in Python here. I installed Python 3.6.5 on my Mac and I am using the default IDLE. When I did VBA or Java (long time ago), there used to be pop-up help\/completion suggestions after you typed \".\" (for example).\nHow do I make it happen in IDLE?\nEDIT\/\/ There is another thread asking essentially the same question however,  it is six years old. I did not want to ressurect such an old thread since a lot has changed, I assume.\nBottom Line:\nIs it possible to have an \"interactive help\" pop up as I am typing using the IDE which came with Python?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2800,"Q_Id":51216567,"Users Score":1,"Answer":"When I run Idle I use the tab key for autocompletion.  If I type pri for example, and then hit tab key, pri becomes print. If there are multiple commands tab key opens a pop-up for you to chose.","Q_Score":2,"Tags":"macos,autocomplete,popup,python-idle","A_Id":51218980,"CreationDate":"2018-07-06T19:23:00.000","Title":"Mac Python IDLE Autocomplete\/Pop-up not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have a python project on my VPS that I want to always be running, and when I push an update through git, it updates its files and restarts. How would I do this? (A discord.py rewrite bot exactly)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":332,"Q_Id":51218139,"Users Score":1,"Answer":"You could add a GitHub webhook to a Discord channel and make your bot listen to it. If it detects a push message, make it run git pull and quit. Then, just run the bot in a loop with while true; do python bot.py; done.\nAlternatively, write another script that will listen for HTTP requests from a GitHub webhook and kill the bot. You'll probably need to save the PID using bash.","Q_Score":1,"Tags":"python-3.x,git,ubuntu,vps,discord.py-rewrite","A_Id":51218248,"CreationDate":"2018-07-06T22:02:00.000","Title":"How to have a VPS auto update on git pushes","Data Science and Machine Learning":0,"Database and SQL":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 do a simple bot in Python, I have written the body and I wanted to try it on real data. So I ran it, it runs in an infinite loop and at the end of the loop it sleeps for 6 seconds because it gets data from server and needs to sleep so it does not get kicked from server. Anyway, by the time I sat in front of the PC and was doing my stuff the script was running (I am running it from Windows command prompt) but when I turned off the screen and came back, the script was not running anymore. I have tried this few times with different lengths of the runs of script and always it stopped after i turned off the screen. \n\nHow to keep python script running once the computer screen is turned off","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":16629,"Q_Id":51222304,"Users Score":1,"Answer":"Change \"Battery saver\" mode to \"Best Performance\" mode.\nThis worked for me, in continue running the scripts when screen turned off","Q_Score":10,"Tags":"python,sleep-mode","A_Id":68382716,"CreationDate":"2018-07-07T10:34:00.000","Title":"Python script stops running when screen turns off","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to do a simple bot in Python, I have written the body and I wanted to try it on real data. So I ran it, it runs in an infinite loop and at the end of the loop it sleeps for 6 seconds because it gets data from server and needs to sleep so it does not get kicked from server. Anyway, by the time I sat in front of the PC and was doing my stuff the script was running (I am running it from Windows command prompt) but when I turned off the screen and came back, the script was not running anymore. I have tried this few times with different lengths of the runs of script and always it stopped after i turned off the screen. \n\nHow to keep python script running once the computer screen is turned off","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":16629,"Q_Id":51222304,"Users Score":12,"Answer":"Check \"Power Options\" in the Control panel.\n\nYou don't need to worry about the screen locking or turning off as these wont affect running processes in python. However, if your system is set to sleep after a set amount of time you may need to change this to Never. Keep in mind there are separate settings depending on whether or not the system is plugged in.","Q_Score":10,"Tags":"python,sleep-mode","A_Id":51222415,"CreationDate":"2018-07-07T10:34:00.000","Title":"Python script stops running when screen turns off","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Python 3.7 on Windows.\nI'm not looking for the packages which are shipped with Python.\nI just want the names of the 3rd party packages that I have manually installed using pip.\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":356,"Q_Id":51222918,"Users Score":2,"Answer":"You can use pip list or pip list --local","Q_Score":0,"Tags":"python,python-3.x,pip","A_Id":51222965,"CreationDate":"2018-07-07T11:48:00.000","Title":"How do I get the list of third-party python packages that I have installed with pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Python 2.6 in centos. I'm trying to connect with MySQL server. I've tried pip install mysql-connector, mysql-connector-python and mysql-connector-python-rf yet I can't mysql_connector.so not found in pip libs. I get error: module not found MySQL.connector!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":693,"Q_Id":51223180,"Users Score":0,"Answer":"Perhaps try below:\n    pip install mysql-connector=2.1.4","Q_Score":0,"Tags":"mysql-python,python-2.6","A_Id":51223206,"CreationDate":"2018-07-07T12:21:00.000","Title":"How to use mysql.connector in Python 2.6","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am coding a tkinter program whereby a user can login. I want my entry box for the password to be able to show 'Password' and then when a user starts typing I want to use the 'show' option to make it so the characters are hidden. The issue is 'show' does not update like for example the textvariable option. Is there any workaround for this?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":487,"Q_Id":51224905,"Users Score":4,"Answer":"I just figured it out, I can use entry.config(show=\"*\") to change the state of the option while the program is running.","Q_Score":2,"Tags":"python,tkinter","A_Id":51225078,"CreationDate":"2018-07-07T16:18:00.000","Title":"Tkinter entry widget 'show' option","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to conveniently open a file in a IPython terminal without switching to another terminal outside IPython. Specifically, can I open vim or other common text editors in a IPython terminal?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1567,"Q_Id":51225294,"Users Score":2,"Answer":"Just use !vim myfile.py inside ipython.\n!, like in VIm, is allowing you to run external commands.","Q_Score":0,"Tags":"python,ipython","A_Id":51225374,"CreationDate":"2018-07-07T17:09:00.000","Title":"Edit text file in IPython terminal without switching terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do you manually stop a Python script running on Visual Studio Code?\nI am on Mac. Thanks","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":384,"Q_Id":51226086,"Users Score":2,"Answer":"I'm assuming you are using a terminal, if so then press ctrl+c to stop a script. If taht doesn't work try ctrl+z. These commands should stop any terminal program.","Q_Score":2,"Tags":"python,python-3.x,visual-studio-code","A_Id":51226100,"CreationDate":"2018-07-07T18:51:00.000","Title":"Regarding Python on Visual Studio Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How do you manually stop a Python script running on Visual Studio Code?\nI am on Mac. Thanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":384,"Q_Id":51226086,"Users Score":1,"Answer":"For quitting the process and terminating from background aswell. Use CTRL+\\\nYou can stop the interactive python by using CTRL+D.\nFor stopping python scripts use CTRL+Z. (Process won't be terminated though. Use killall for that.)\nTo terminate all python scripts running in background. Run killall python or sudo killall python. Run with caution\nAnd to stop other scripts use CTRL+C","Q_Score":2,"Tags":"python,python-3.x,visual-studio-code","A_Id":51226312,"CreationDate":"2018-07-07T18:51:00.000","Title":"Regarding Python on Visual Studio Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Recently I converted a .py file to a .exe file.\nI lost the original .py file and I'm left with the exe file.\nI converted it with pyinstaller.\nIs there anyway to reverse this to get my original .py file back?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24024,"Q_Id":51227091,"Users Score":0,"Answer":"It doesnt create the .pyc file at all i typed \"python pyinstxtractor.py spam.exe\" spam is my .exe name","Q_Score":11,"Tags":"python,python-2.7,pyinstaller","A_Id":70595963,"CreationDate":"2018-07-07T21:31:00.000","Title":"How to convert exe back to Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"There are some packages that returns values as bytes in my project. There is some configuration or environment variable to set so I don't need to decode bytes to string ever again? And if so, what is it?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":178,"Q_Id":51227323,"Users Score":1,"Answer":"No, I don't believe so. It is up to the packages as to how they return values in their methods.","Q_Score":1,"Tags":"python,python-3.x,encoding,decode","A_Id":51227332,"CreationDate":"2018-07-07T22:16:00.000","Title":"How to avoid decoding bytes to string all the time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There are some packages that returns values as bytes in my project. There is some configuration or environment variable to set so I don't need to decode bytes to string ever again? And if so, what is it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":178,"Q_Id":51227323,"Users Score":3,"Answer":"Python 2 by default  can do what you want.\nBut let me advise: this is NOT what one really wants and that's why Python 3 does not do that automatically.\nTo convert bytes to str, you need to know the coding of the bytes:\ns = b.decode(coding)\nTo convert str to bytes, you also need to know the desired coding:\nb = s.encode(coding)\nPython 2 assumed coding == 'ASCII' and thus worked for english \/ plain ASCII texts, but raised exceptions at runtime for everything else.\nSo, what you have to do is:\n\ndecide whether something should be processed as text (in that case you use str) or as binary (then you keep bytes)\ndecode early (after loading, receiving the bytes)\nprocess as str\nencode late (before saving, sending the bytes)\n\nNowadays utf-8 encoding is the most popular, so use that if you have no other requirements.","Q_Score":1,"Tags":"python,python-3.x,encoding,decode","A_Id":51227998,"CreationDate":"2018-07-07T22:16:00.000","Title":"How to avoid decoding bytes to string all the time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to make a program where I detect red. However sometimes it is darker than usual so I can't just use one value.\nWhat is a good range for detecting different shades of red?\nI am currently using the range 128, 0, 0 - 255, 60, 60 but sometimes it doesn't even detect a red object I put in front of it.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":18158,"Q_Id":51229126,"Users Score":1,"Answer":"Please, use HSV or HSL (hue, saturation, luminance) instead of RGB, in HSV the red color can be easily detected using the value of hue within some threshold.","Q_Score":4,"Tags":"python,opencv,colors","A_Id":51229167,"CreationDate":"2018-07-08T05:32:00.000","Title":"How to find the RED color regions using OpenCV?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using PRAW. In my code, an instance of a class in PRAW is declared in a module and return. Do I have to import the class or PRAW in my main module to be able to use its sub methods and variables?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":103,"Q_Id":51230457,"Users Score":0,"Answer":"The short answer is \"no\".\nIf you have an instance of some class, the definition of that class is already lying somewhere in the Python process - if it was defined in a module (in contrast with dynamically constructed using type), that module was imported somewhere else, and the class definition can be found there.\nThe \"import\" mechanism in Python is quite efficient, so if you do import a module that is not yet loaded into the current process, its code is actually run. Afterwards, a reference to that module is kept in a central registry, which is exposed in the sys.modules dictionary (that is a plain dictionary in the sys module). \nWhenever new module imports, or name imports from modules that are already present there take place, all that Python does is to assign a variable in the scope  the import is taking place, referring to the object already in memory - so, import on an \"already known\" object is just an assignment, quite the same thing the \"=\" symbol performs. \nBut when you have an instance of a class, it already contains a reference to its class, there is no need to bring it into the current namespace. (That reference is on the instance's __class__ attribute, btw).","Q_Score":0,"Tags":"python,import,module","A_Id":51232903,"CreationDate":"2018-07-08T09:10:00.000","Title":"Do I have to import the class if an instance of the class will be used in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a txt file to import in pandas but the data contains characters like L\\E9on, which translates to L\u00e9on. How can I import this kind of data in pandas? I have tried using encoding as utf-8 and raw_unicode_escape. It still gives out an error multiple repeat at position 2.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":51230915,"Users Score":0,"Answer":"To process accented character please try encoding='iso-8859-1'.","Q_Score":0,"Tags":"python,pandas","A_Id":51231004,"CreationDate":"2018-07-08T10:09:00.000","Title":"escaped character in data for pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a txt file to import in pandas but the data contains characters like L\\E9on, which translates to L\u00e9on. How can I import this kind of data in pandas? I have tried using encoding as utf-8 and raw_unicode_escape. It still gives out an error multiple repeat at position 2.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":51230915,"Users Score":0,"Answer":"Interesting!!!\nTo re-produce this issue at my end, I have created dummy data with consists of the text specified by you and saved it as a .txt file\nI am able to import this txt file content into pandas data frame without any issues using read_csv method\ndf=pd.read_csv('spcl.txt')","Q_Score":0,"Tags":"python,pandas","A_Id":51232652,"CreationDate":"2018-07-08T10:09:00.000","Title":"escaped character in data for pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a TensorFlow model in which I want to pass an image to it in order for it to determine the object within the image.\nHowever, the model is complaining of the shape of the image saying it wants it in the form (1, 1, 1, 2048) however it's receiving (1, 7, 7, 2048).\nI have tried doing a numpy.reshape() on the image by doing either numpy.reshape(myObj, (1, 1, 1, 2048)) or numpy.reshape(myObj, (1, 1, 1, -1)). However, the former just complains that it can't reshape array of size 100352 to (1, 1, 1, 2048) and the latter resizes the last element of the array to the multiple of (7, 7, 2048), i.e. 100352.\nHow would one go about reshaping an odd array size, or is this not how Numpy shapes\/reshapes work? Is there an alternative way to do what I'm asking for if not possible with Numpy?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1912,"Q_Id":51231925,"Users Score":0,"Answer":"You cannot reshape an array of n elements into an array of m elements if n and m are not equal. The operation of reshaping an array is really just the operation of obtaining a new view of the same array.\nYour input array has n=1*7*7*2048=100353 elements while you're trying to reshape to an array with m=1*1*1*2048=2048 elements.\nAs pointed out by hpaulj, your problem lies in your input shape. From the shapes you mention, (1, 7, 7, 2048) and (1, 1, 1, 2048), it looks like your expected input should probably be extracted from a later layer (maybe after a global pooling stage) but we cannot say much more without more details on your models.","Q_Score":0,"Tags":"python,arrays,numpy","A_Id":51233015,"CreationDate":"2018-07-08T12:17:00.000","Title":"Numpy - How to reshape odd array sizes?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"According to the documentation the cursor's rewind() method \n\nrewinds this cursor to its unevaluated state.\n\nWhy the term unevaluated state? Is some evaluation going on behind the scenes when cursor is first retrieved, or is this only a misleading term for the initial position?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":51232936,"Users Score":1,"Answer":"A cursor is like an iterator over a MongoDB query result; lazy evaluation. Thus is evaluated and can only be consumed during iteration. \nCalling rewind set the Cursor to its unevaluated state, as if it wasn't consumed. But note that new iteration will send a new query to the server and the result might be different.","Q_Score":0,"Tags":"python,mongodb,pymongo","A_Id":51260741,"CreationDate":"2018-07-08T14:28:00.000","Title":"What is Mongo cursor's unevaluated state?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"According to the documentation the cursor's rewind() method \n\nrewinds this cursor to its unevaluated state.\n\nWhy the term unevaluated state? Is some evaluation going on behind the scenes when cursor is first retrieved, or is this only a misleading term for the initial position?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":51232936,"Users Score":0,"Answer":"it's just a cursor, rewind to the initial position.","Q_Score":0,"Tags":"python,mongodb,pymongo","A_Id":51260355,"CreationDate":"2018-07-08T14:28:00.000","Title":"What is Mongo cursor's unevaluated state?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Python 3.6 on my Mac, GDAL and QGIS 3.0. But if I use a tool, like merge raster from GDAL, QGIS stops the work and says: \"env: python3.6: No such file or directory\" \nI have set Python and GDAL to my $PATH, and added the Values in QGIS-Settings, too.\nHow can I stop getting this error?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":861,"Q_Id":51234328,"Users Score":0,"Answer":"You need to append :\/Library\/Frameworks\/Python.framework\/Versions\/3.6\/bin\/ to your $PATH env variable in the settings.\nIf you've already append :\/Library\/Frameworks\/GDAL.framework\/Programs it should be :\/Library\/Frameworks\/GDAL.framework\/Programs:\/Library\/Frameworks\/Python.framework\/Versions\/3.6\/bin\/ in QGIS settings.","Q_Score":0,"Tags":"python,gis,raster,gdal","A_Id":52726126,"CreationDate":"2018-07-08T17:12:00.000","Title":"Error for GDAL merge in QGIS 3 for missing Python3.6 on Mac 10.11.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am all new to python and I just got to know methods I am using python 3.7.0 64 bit and I want to know what is the difference between methods and functions. but please in very very basic explanation because I am also all new to programming.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":51234377,"Users Score":0,"Answer":"The difference between methods and functions is that functions are declared in a class, whereas methods are declared in an object.","Q_Score":0,"Tags":"python,python-3.x","A_Id":51234453,"CreationDate":"2018-07-08T17:19:00.000","Title":"What is the difference between methods and functions? (Very basic explanation please)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am all new to python and I just got to know methods I am using python 3.7.0 64 bit and I want to know what is the difference between methods and functions. but please in very very basic explanation because I am also all new to programming.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":51234377,"Users Score":0,"Answer":"Let's have two examples\nlen(), and list.sort()\nHere len() is called as function because it is invoked before declaring the object on which it is to be used.\nOn the other hand, we would call sort as a method of list object.","Q_Score":0,"Tags":"python,python-3.x","A_Id":51234425,"CreationDate":"2018-07-08T17:19:00.000","Title":"What is the difference between methods and functions? (Very basic explanation please)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cloned a Github Repository into Colaboratory although it was cloned but i couldn't view it in that particular folder. I changed into \"drive\" as my working directory but i don't know which directory is that on drive. I moved into drive folder and viewed it's contents, it was present in the drive folder. Please tell me which is the drive folder on Google Drive. Thanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2646,"Q_Id":51234981,"Users Score":0,"Answer":"Try to change Run type to GPU and retry the clone.\nI met the same problem when using default Jupyter notebook.","Q_Score":0,"Tags":"python,google-colaboratory,google-drive-shared-drive","A_Id":58157262,"CreationDate":"2018-07-08T18:37:00.000","Title":"Can't view Github Repos after cloning them into Colaboratory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I was trying to install kivy, which lead me to install pip, and I went down a rabbit hole of altering directories. I am using PyCharm for the record.\nI would like to remove everything python related (including all libraries like pip) from my computer, and start fresh with empty directories, so when I download pycharm again, there will be no issues. \nI am using a Mac, so if any of you could let me know how to do that on a Mac, it would be greatly appreciated.\nCould I just open finder, search python, and delete all of the files (there are tons) or would that be too destructive?\nI hope I am making my situation clear enough, please comment any questions to clarify things.\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1027,"Q_Id":51236750,"Users Score":2,"Answer":"If you are familiar with the Terminal app, you can use command lines to uninstall Python from your Mac. For this, follow these steps:\n\n\nMove Python to Trash.\nOpen the Terminal app and type the following command line in the window: ~ alexa$ sudo rm -rf \/Applications\/Python\\ 3.6\/\nIt will require you to enter your administrator password to confirm the deletion.\n\n\nAnd for the PyCharm:\n\nJust remove the ~\/Library\/Caches\/PyCharm20 and\n  ~\/Library\/Preferences\/PyCharm20 directories.\n\nOr if that won't be enough:\n\n\nGo to Applications > right click PyCharm > move to trash\nopen a terminal and run the following: find ~\/Library\/ -iname \"pycharm\"\nverify that all of the results are in fact related to PyCharm and not something else important you need to keep. Then, remove them all\n  using the command: find ~\/Library -iname \"pycharm\" -exec rm -r \"{}\"\n  \\;","Q_Score":2,"Tags":"python-3.x,directory,pycharm","A_Id":51237145,"CreationDate":"2018-07-08T23:33:00.000","Title":"Wondering how I can delete all of my python related files on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently interesting in web development using python language, but evertime I'm searching for reference, we only given two frameworks option between Django and flask. Can we just develop web app without using any of those framework","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":354,"Q_Id":51237088,"Users Score":1,"Answer":"Yes, you can build a web-app using no framework. However it will require you writing a large amount of boiler plate code to send, receive, and parse HTTP data. It is generally highly recommended that you use a framework in order to save yourself a large amount of time and effort, and to ensure the product that you build is good quality.\nYou will also struggle to find resources on building a web-app without a framework, while there are a wealth of resources available for working with existing frameworks.","Q_Score":0,"Tags":"python,web-applications,frameworks","A_Id":51237133,"CreationDate":"2018-07-09T00:53:00.000","Title":"Is it possible to build a python web app without any framework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What is the difference between MinMaxScaler and standard scaler.\nMMS= MinMaxScaler(feature_range = (0, 1)) ( Used in Program1)\nsc = StandardScaler() ( In another program they used Standard scaler and not minMaxScaler)","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":48259,"Q_Id":51237635,"Users Score":6,"Answer":"Many machine learning algorithms perform better when numerical input variables are scaled to a standard range.\nScaling the data means it helps to  Normalize the data within a particular range.\nWhen MinMaxScaler is used the it is also known as Normalization and it transform all the values in range between (0 to 1)\nformula is x = [(value - min)\/(Max- Min)]\nStandardScaler comes under Standardization and its value ranges between (-3 to +3)\nformula is z = [(x - x.mean)\/Std_deviation]","Q_Score":31,"Tags":"python,data-science","A_Id":64356403,"CreationDate":"2018-07-09T02:42:00.000","Title":"Difference between Standard scaler and MinMaxScaler","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between MinMaxScaler and standard scaler.\nMMS= MinMaxScaler(feature_range = (0, 1)) ( Used in Program1)\nsc = StandardScaler() ( In another program they used Standard scaler and not minMaxScaler)","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":48259,"Q_Id":51237635,"Users Score":71,"Answer":"MinMaxScaler(feature_range = (0, 1)) will transform each value in the column proportionally within the range [0,1]. Use this as the first scaler choice to transform a feature, as it will preserve the shape of the dataset (no distortion).\nStandardScaler() will transform each value in the column to range about the mean 0 and standard deviation 1, ie, each value will be normalised by subtracting the mean and dividing by standard deviation. Use StandardScaler if you know the data distribution is normal.\nIf there are outliers, use RobustScaler(). Alternatively you could remove the outliers and use either of the above 2 scalers (choice depends on whether data is normally distributed)\nAdditional Note: If scaler is used before train_test_split, data leakage will happen. Do use scaler after train_test_split","Q_Score":31,"Tags":"python,data-science","A_Id":58850139,"CreationDate":"2018-07-09T02:42:00.000","Title":"Difference between Standard scaler and MinMaxScaler","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an application which uses a hash algorithm (currently MD5) to generate a unique ID in a database table. The hash is calculated based on some fields of a row, but nothing checks that calculation, for when those fields are changed later on, the ID of that row doesn't change.\nNow I want to change the code to add some new features, while generating a purely random number for the ID could simplify my work a lot (it's a long story to tell why it is much easier for me to generate that ID before I'm able to get all the necessary fields' content for the hash algorithm)\nI know that usually the programming language's own random generator generates pseudo random number, but I'm using Python's random.SystemRandom(), which uses operating system's cryptography level 'true' random generator, so I believe it should be the same collision probability comparing with generating the ID with hash algorithm.\nIs my understanding correct? If not, why?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":406,"Q_Id":51237701,"Users Score":2,"Answer":"Generating X number of bytes of random data gives exactly the same collision probability as using the hash function on some ID's... \nASSUMING...\n\nThe columns you're using the hash function on are themselves unique.\nYou haven't made mistakes doing #1\n\nI would recommend using the system's cryptographic random number provider.  Because you've probably made mistakes.  Here's an easy one:\nYour system:  Concatenate column 1 and column 2, and hash the result.  You can guarantee you'll never ever do this on those values of column 1 and column 2 ever again.  NEVER.\nWhat about when:\n\nColumn 1 = \"abc\"\nColumn 2 = \"def\"\n\nvs\n\nColumn 1 = \"ab\"\nColumn 2 = \"cdef\"\n\nThose would create the same hash function.\nSo who would you trust more to give you random data?  Yourself?  Or a team of operating system developers including cryptography experts and decades of research and experience? :)\nGo with the system's cryptographic random function.","Q_Score":3,"Tags":"python,random,md5,uuid","A_Id":51237819,"CreationDate":"2018-07-09T02:54:00.000","Title":"Can hash algorithm such as MD5\/SHA-1 generate an ID with less probability of collision than pure random number?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a weird problem! I made a client \/ server Python code with Bluetooth in series, to send and receive byte frames (for example: [0x73, 0x87, 0x02 ....] ) \nEverything works, the send reception works very well ! \nThe problem is the display of my frames, I noticed that the bytes from 0 to 127 are displayed, but from 128, it displays the byte but it adds a C2 (194) behind, for example: [0x73, 0x7F, 0x87, 0x02, 0x80 ....] == [115, 127, 135, 2, 128 ....] in hex display I would have 73 7F C2 87 2 C2 80 .. , we will notice that he adds a byte C2 from nowhere! \nI think that since it is from 128! that it is due to a problem of signed (-128 to 127) \/ unsigned (0 to 255).\nAnyone have any indication of this problem?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":51242202,"Users Score":0,"Answer":"0xc2 and 0xc3 are byte values that appear when encoding character values between U+0080 and U+00FF as UTF-8. Something on the transmission side is trying to send text instead of bytes, and something in the middle is (properly) converting the text to UTF-8 bytes before sending. The fix is to send bytes instead of text in the first place.","Q_Score":1,"Tags":"python-3.x,bluetooth,byte,frames","A_Id":51245089,"CreationDate":"2018-07-09T09:26:00.000","Title":"Trouble displaying signed unsigned bytes with 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":"In our company some database administrators are still querying MS SQL Server DB with Visual Foxpro.\nEventhough I'm not a DB administrator, I reckon it's time to migrate those queries to a more recent DB management system.\nQuestion 1:\nWhat are good substitutions\/alternatives for Visual Foxpro?\nWould Python be able to carry out all the task Visual Foxpro can?\nQuestion 2:\nThe administators still defend the use of this language, eventhough support stopped in 2007. Is it still justifiable to keep using Visual Foxpro in 2018?\nThank you for your help!","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":2486,"Q_Id":51244350,"Users Score":1,"Answer":"This question was 2 years ago, but I would like to contribute something.\nA2Q-1. MSSQL Server, MySQL, Postgre and other latest database applications are now more reliable and more secure. You should try them and then choose which is comfortable for you.\nA2Q-2. It is still justifiable to use VFP. I know a large company who is still using it and are not having a hard time maintaining it. They've been using it for almost 30 years now. They are now the experts, they no longer need any support from the original creators of VFP.","Q_Score":0,"Tags":"python,database,foxpro","A_Id":64473383,"CreationDate":"2018-07-09T11:21:00.000","Title":"Visual FoxPro in 2018","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In our company some database administrators are still querying MS SQL Server DB with Visual Foxpro.\nEventhough I'm not a DB administrator, I reckon it's time to migrate those queries to a more recent DB management system.\nQuestion 1:\nWhat are good substitutions\/alternatives for Visual Foxpro?\nWould Python be able to carry out all the task Visual Foxpro can?\nQuestion 2:\nThe administators still defend the use of this language, eventhough support stopped in 2007. Is it still justifiable to keep using Visual Foxpro in 2018?\nThank you for your help!","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":2486,"Q_Id":51244350,"Users Score":6,"Answer":"In our company some database administrators are still querying SQL Server database with Visual Foxpro.  \n\nYou need to find out if they are just manually querying the SQL Server data for reports or are they actually using a VFP Application (which itself queries the SQL Server data).  \nIf they are running a VFP Application, then to change, you (or they) will have to totally redesign and redevelop the application in the replacement language - depending on the complexity of the application - most often not an insignificant task.  \nIf you are considering changing to another language rather than just following someone's advice or their 'gut' feeling such as  \n\nI reckon it's time to migrate those queries to a more recent database management system\n\nYou need to do a business analysis. At the very least you should ask the following questions.  \n\nIs the current operation Business Critical to the operations?   \nWhat is the REAL reason for changing?  \nWhat advantages will be gained by changing?  \nWhat will the timeline and budget look like to make the change?  \nIs this software to be run in-house only or will it be run across the web?  \n\nIn regards to Question 2  \nSure VFP is a 'dated language', and its support from Microsoft is no longer available, but there is a VERY Active community of VFP developers who are available in various web forums who can offer far superior support to VFP questions than MS ever did.  \nThose VFP developers are still using the language and plan to continue to do so for quite a while. So 'language support', by itself, seems like a moot issue.    \nIn regards to question 1  \nThere are a number of languages to change to. Some are rather simplistic and others are more full-featured.  \nAgain, if this is a VFP Application which is to be changed rather than just a few queries, then plan for an extensive effort no matter what language you change to.  \nAlso your answers to the Business Analysis questions may guide you towards one language over another.  \nI do find it odd that you say  \n\nWe also observe a lot of time going to problem solving rather than improving the services\n\nI have developed FP\/VFP applications for 30+ years now (currently in addition to Android and VB.ASP) and have found that once developed and implemented these are very stable applications.  Sure there can be Network issues and data change issues which are problematic, but it is not the VFP software that is 'mis-behaving' - instead it is 'external' things which are causing the stable VFP application to no longer behave as expected.  \nAlthough I will say that a poorly designed application (VFP or other) will be frequently problematic.  \nWhichever way you go - good luck.","Q_Score":0,"Tags":"python,database,foxpro","A_Id":51250704,"CreationDate":"2018-07-09T11:21:00.000","Title":"Visual FoxPro in 2018","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In our company some database administrators are still querying MS SQL Server DB with Visual Foxpro.\nEventhough I'm not a DB administrator, I reckon it's time to migrate those queries to a more recent DB management system.\nQuestion 1:\nWhat are good substitutions\/alternatives for Visual Foxpro?\nWould Python be able to carry out all the task Visual Foxpro can?\nQuestion 2:\nThe administators still defend the use of this language, eventhough support stopped in 2007. Is it still justifiable to keep using Visual Foxpro in 2018?\nThank you for your help!","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2486,"Q_Id":51244350,"Users Score":0,"Answer":"Question 1: What are good substitutions\/alternatives for Visual\n  Foxpro? Would Python be able to carry out all the task Visual Foxpro\n  can?  \n\nI think you might want to look into Visual C# or Visual Basic using the .NET framework.\nPython might be able to replace Visual FoxPro from what I hear.  \n\nQuestion 2: The administators still defend the use of this language, eventhough support stopped in 2007. Is it still justifiable to keep using Visual Foxpro in 2018?  \n\nIt might be justifiable but you might want to use the latest .NET frameworks to keep up with security patches or new features.","Q_Score":0,"Tags":"python,database,foxpro","A_Id":51244694,"CreationDate":"2018-07-09T11:21:00.000","Title":"Visual FoxPro in 2018","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In our company some database administrators are still querying MS SQL Server DB with Visual Foxpro.\nEventhough I'm not a DB administrator, I reckon it's time to migrate those queries to a more recent DB management system.\nQuestion 1:\nWhat are good substitutions\/alternatives for Visual Foxpro?\nWould Python be able to carry out all the task Visual Foxpro can?\nQuestion 2:\nThe administators still defend the use of this language, eventhough support stopped in 2007. Is it still justifiable to keep using Visual Foxpro in 2018?\nThank you for your help!","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":2486,"Q_Id":51244350,"Users Score":1,"Answer":"I will say that, for our purposes VFP is the quickest way we have right now to convert data.  That said, we run it a lot in server 2012 and it's really buggy.  Requiring a lot of time clearing problems and restarting programs.  It's days are numbered for us, I would continue to use it if we could get it updated a bit so it works on better on modern operating systems.","Q_Score":0,"Tags":"python,database,foxpro","A_Id":51245400,"CreationDate":"2018-07-09T11:21:00.000","Title":"Visual FoxPro in 2018","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"when using the dask dataframe to_parquet method is there any way to set the default parquet file size like in spark ?\nmy problem is that when I save it with the partition_on kwarg i get several small files per partition dir and thus resulting very slow queries using \"Amazon Athena\".\nThe intermediate desired result (if file size control is not available) is n files (right now 1 will suffice) per partition dir.\nThe only way i thought of guaranteeing 1 file per partition dir is repartitioning to one partition and then using the to_parquet method (however this is highly inefficient).\nis there a better way ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":940,"Q_Id":51249295,"Users Score":1,"Answer":"The current behaviour is by design, allowing each worker to process a partition independently, and write to files which no other process is writing to. Otherwise, there would need to be some kind of lock, or some consolidation step after writing for each directory.\nWhat you could do, is to use set_index to shuffle the data into one partition for each value of the column you want to partition by (perhaps using the divisions= keyword); now a to_parquet would result in a file for each of these values. If you wanted the files to automatically end up in the correct directories, and have the now-redundant index trimmed, you would want to use to_delayed() and create a delayed function, which takes one partition (a pandas dataframe) and writes it to the correct location.","Q_Score":2,"Tags":"python,parquet,filesize,dask","A_Id":51252563,"CreationDate":"2018-07-09T15:39:00.000","Title":"set size of Parquet output files in dask","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to work with sql server in orange through anaconda.\nWhen installing pymssql I am getting the attached error.\nAfter hours of googling I could not find a solution for anaconda.\nPlease help!\nThank you\nMichael\n_mssql.c(266): fatal error C1083: Cannot open include file: 'sqlfront.h': No such file or directory\n  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1519,"Q_Id":51251584,"Users Score":1,"Answer":"I faced a similar issue before.\nI would recommend downloading v2 of pymssql: \n    pip install pymssql==2.1.3","Q_Score":2,"Tags":"python,sql-server,anaconda,pymssql","A_Id":51251644,"CreationDate":"2018-07-09T18:06:00.000","Title":"pip install pymssql fails in anaconda windows","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a great package for Bayesian optimization of hyperparameters (especially mixed integer\/continuous\/categorical...and has shown to be better than Spearmint in benchmarks).  However, clearly it is meant for Linux.  What do I do...?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":51254986,"Users Score":0,"Answer":"First you need to download swig.exe (the whole package) and unzip it.  Then drop it somewhere and add the folder to path so that the installer for SMAC3 can call swig.exe.\nNext, the Resource module is going to cause issues because that is only meant for Linux.  That is specifically used by Pynisher.  You'll need to comment out import pynisher in the execute_func.py module.  Then, set use_pynisher:bool=False in the def __init__(self...) in the same module.  The default is true.\nThen, go down to the middle of the module where an if self.use_pynisher....else statement exists.  Obviously our code now enters the else part, but it is not setup correctly.  Change result = self.ta(config, **obj_kwargs) to result = self.ta(list(config.get_dictionary().values())).  This part may need to be adjusted yet depending on what kind of inputs your function handles, but essentially you can see that this will enable the basic example shown in the included branin_fmin.py module.  If doing the random forest example, don't change at all...etc.","Q_Score":0,"Tags":"python-3.x,optimization,bayesian","A_Id":51254987,"CreationDate":"2018-07-09T22:42:00.000","Title":"How to get SMAC3 working for Python 3x on Windows","Data Science and Machine Learning":0,"Database and SQL":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 write a python script to read a large logfile (1GB+), extract IP addresses in each line, store these IPs, remove duplicates, locate in another files the the hostnames related to these IPs and rewrite the hostnames to a new logfile containing the original data.\nNow the question: What is the best way to deal with memory, files, etc? I mean, I see two approaches:\n\nRead the original logfile, extract IPs and write to a new file (tmp_IPS.txt, remove dupes, search these IPs line by line on another files (hostnames.txt), write the results to tmp_IPS.txt, read and rewrite original logfile. In this case, I will process less IPs (without the dupes).\nRead the original logfile, read the IPs and search each IP on the hostnames.txt, write the rows on original logfile + hostnames. In this case, I will process a lot of duplicated IPs. I can also write the found IPs and hostnames to a new file or to memory, but I really don't know what is better.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":950,"Q_Id":51255950,"Users Score":0,"Answer":"The most efficient way to deal with large log files in this case is to read and write at the same time, line by line, to avoid loading large files into memory. You should load the IP-to-hostname mapping file hostnames.txt in to a dict first if hostnames.txt is relatively small; otherwise you should consider storing the mapping in an indexed database)","Q_Score":0,"Tags":"python,memory,file-io","A_Id":51256102,"CreationDate":"2018-07-10T01:09:00.000","Title":"The most efficient (or professional) way to read, proccess and write a file 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":"I'm trying to learn machine learning. \nI had a doubt about one hot encoding:\nI have a data set split into 2 excel sheets of data. One sheet has train and other has test data. I first trained my model by importing the train data sheet with pandas. There are categorical features in the data set that have to be encoded. I one hot encoded them.  \nAfter importing the test dataset , if I one hot encode it, will the encoding be the same as of the train data set or will it be different. If so, how can I solve this issue?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1910,"Q_Id":51256927,"Users Score":0,"Answer":"you have 2 seperate sheets ( for test and train data set). you have to one-hot encode both the sheets seperately after importing it into the pandas data frame.\nand YES one hot encoding will be the same for the same data set no matter you apply on different data sheets, make sure you have same categorical values in that column in each of your data sheet","Q_Score":1,"Tags":"python,pandas,machine-learning","A_Id":52307049,"CreationDate":"2018-07-10T03:41:00.000","Title":"One hot encoding in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can i copy one column from one collection to another collection in mongoDB using Python?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":51258258,"Users Score":0,"Answer":"document:{\n  _id: Object_ID\n  username: \"john\"\n  email: \"john@email.com\"\n  age: 24\n}\nNow, you want to copy username column from this document of some collection1 to a document of collection2, for that,\nlet say you have build connection with MongoDB, and we use db object to further data manipulation.\n\nwe need to get that intended column data with column name\ndata = db.collection1.find_one(\n  {\"email\": \"john@email.com\"},\n  {\"username\": 1}\n)\n\/\/ now data is a python dictionary contains value of username on key username\nnow we are going to create a new document in another collection(or we can update that data based on some condition if you wish)\ndb.users.collection2.insert_one(data) \/\/hence we got our new document with that data in collection2\n\nNow here I use find_one to exactly collect a single data, but if you need to collect a list of data then, just iterate through the list while inserting those data into a collection.","Q_Score":0,"Tags":"python,mongodb","A_Id":51259901,"CreationDate":"2018-07-10T06:10:00.000","Title":"Adding column in different collection","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my python code, I need to kill any java.exe subprocess, I am using subprocess.call(\"taskkill \/f \/im java.exe\"), this is working fine when java.exe subprocess exists but it failed with \"ERROR: The process \"java.exe\" not found\" if java.exe subprocess does not exist, so I want to know if there is any way to detect if any java.exe subprocess is running and then try to kill it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":214,"Q_Id":51261815,"Users Score":0,"Answer":"You can use subprocess.call to run tasklist or wmic process get description first to get a full list of running processes and see if java.exe is among them.","Q_Score":0,"Tags":"python,subprocess","A_Id":51262036,"CreationDate":"2018-07-10T09:34:00.000","Title":"How to conditionally use subprocess.call(\"taskkill \/f \/im java.exe\")","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm trying to convert m4a audio file with artwork (cover) to mp3. I'm using ffmpeg to convert the audio.\nOnce it copies, the artwork is lost. I'm quite not sure, how to retain the cover. I found some reference about mutagen library but not sure again how to use to copy the artwork.\nAny help would be great.\n\nffmpeg -i source\/file -acodec libmp3lame -ab 128k destination.mp3\n\nUpdate:\nI'm reading the artwork and m4a to be able to attache it back. \nI can get the artwork by using\n\nartwork = audio.tags['covr']\n\nNow my problem is how do I save the artwork as image in a new file?\nI tried the Following:\n\nwith open(path\/to\/write, 'wb') as img:\n    img.write(artwork)\n\nThis gives me an error\n\n'list' does not support the buffer interface line\n\nAny suggestion, how I can save the artwork extracted covr data?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":347,"Q_Id":51262309,"Users Score":0,"Answer":"If anyone is having the same issue;\nI ended up reading the artwork from original file and attaching it back to mp3\n\nif audioFileNameWithM4AExtension.startswith(\"covr\"): #checks if it has cover\n    cover = audioFileNameWithM4AExtension.tags['covr'][0] #gets the cover","Q_Score":0,"Tags":"python,mp3,m4a,audio-converter","A_Id":51386699,"CreationDate":"2018-07-10T09:58:00.000","Title":"Lost artwork while converting .m4a to .mp3 (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've installed in Windows 10 Anaconda 1.8.7 with Python 3.6.5 and Spyder 3.2.8\nThe issue is the following : when I launch Spyder from Anaconda navigator Spyder freeze when loading the editor.\nI've uninstall Anaconda an reinstall it whithout succes\nI've launched Spyder from commmand line and I've no specific output in the terminal\nI've deleted the .spyder-py3  .anaconda .ipython and .conda whithout change\nDoes someone has an idea?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":953,"Q_Id":51263934,"Users Score":0,"Answer":"Finally I've reinstalled windows and Anaconda and now everything work like a charm","Q_Score":0,"Tags":"python,windows-10,anaconda,spyder","A_Id":51362691,"CreationDate":"2018-07-10T11:23:00.000","Title":"Spyder won't load","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i want to find what libraries are installed in Robotframework. Maybe like with a pip command or something similar. Do you know any way for doing this? I already checked the documentation but could not find this. Many thanks !","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":3021,"Q_Id":51264172,"Users Score":5,"Answer":"Unfortunately, there's no way to know all of the robot framework libraries that have been installed. All of the built-in libraries are easy to determine, but it's impossible to know what other libraries are there since they each get installed in their own folder.\nAssuming that the libraries all follow the common pattern of \"robotframework-_libraryname\", you can grep the output of pip freeze (eg: pip freeze | fgrep robotframework-. Though, if you have a library that doesn't follow that convention then it may go undetected.","Q_Score":0,"Tags":"python,pip,robotframework,libraries","A_Id":51267521,"CreationDate":"2018-07-10T11:35:00.000","Title":"What libraries are installed in Robotframework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python, is it possible to set application context to the second gui which is invoked by the GUI under test.\nEx: We start an application called test1.exe using startApplication. Clicking a button in text1.exe GUI invokes another  GUI application called test2.exe.\nNow is it possible to set application context to test2.exe GUI?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":733,"Q_Id":51264303,"Users Score":0,"Answer":"Try selecting 'Hook in to sub-processes...' in the test suite settings.","Q_Score":0,"Tags":"python,qt,squish","A_Id":52657280,"CreationDate":"2018-07-10T11:42:00.000","Title":"Squish set application context to aut started by aut under test","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a list that contains all lower cases, upper cases, and numbers in python?\n\"string\" does not have such a list.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5853,"Q_Id":51265716,"Users Score":9,"Answer":"There is actually, inside string module\n\nstring.ascii_lowercase\nstring.ascii_uppercase\nstring.digits\nas well as a few others\n\nEach is given as a single string. If you want to convert them to a list, you can simply use list(string.ascii_lowercase + string.ascii_uppercase + string.digits)","Q_Score":2,"Tags":"python","A_Id":51265755,"CreationDate":"2018-07-10T12:50:00.000","Title":"Is there a list of all alphanumeric signs in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to detect whether Python is running in a Conda environment?\nI would prefer solutions that don't rely on running shell commands in a subprocess, but if that's the only option then so be it. I would assume there is something simple like an environment variable that is set inside the environment, but this kind of thing is hard to search for (and Conda documentation is not great).","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":601,"Q_Id":51266880,"Users Score":3,"Answer":"After some testing, it looks like you can detect Conda usage with the CONDA_DEFAULT_ENV and CONDA_PREFIX environment variables. These only appear to be set when a Conda environment is active.\nI will try to get an \"official\" answer from the Conda team and update.","Q_Score":5,"Tags":"python,environment-variables,conda","A_Id":60888441,"CreationDate":"2018-07-10T13:42:00.000","Title":"Detect if Python is running in a Conda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am Creating a python custom code to Visualise scientific\/medical data in 3D. \nThis code should be implemented in the GUI I am creating with TKInter, so as to visualise these data sets directly in the GUI. \nIf I already have the code written up is there a way I can run this code in my GUI and subsequently open and run the visualisation window directly in the TKInter GUI???\nIs it possible to create custom windows inside with TKInter which contain more complex code and allow the user to visualise the image output of the code??\nAdditional info: The visualisation code for the 3d data is created with VTK (Visualisation ToolKit) and opens a custom Visualisation window.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":560,"Q_Id":51268131,"Users Score":0,"Answer":"Unless the VTK binding for Python contains a dedicated library for interaction with TKInter, no, you can't.\nEvery GUI toolkit contains it's own set of widgets designed to interact with each other in exactly the ways defined by the toolkit, so you generally can't simply mix widgets from two libraries in one window.\nYou can, of course, write a Python program that imports both libraries and then opens two windows, one from TKInter and one from VTK. By making it handle events from both windows, you can also provide some very basic interaction between them. This might be the closest to what you want.","Q_Score":0,"Tags":"python-3.x,tkinter,3d,window,vtk","A_Id":51268647,"CreationDate":"2018-07-10T14:42:00.000","Title":"Python TkInter: Creating a Window which runs my custom code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Gensim's Word2Vec model takes as an  input a list of lists with the inner list containing individual tokens\/words of a sentence. As I understand Word2Vec is used to \"quantify\" the context of words within a text using vectors. \nI am currently dealing with a corpus of text that has already been split into individual tokens and no longer contains an obvious sentence format (punctuation has been removed). I was wondering how should I input this into the Word2Vec model? \nSay if I simply split the corpus into \"sentences\" of uniform length (10 tokens per sentence for example), would this be a good way of inputting the data into the model? \nEssentially, I am wondering how the format of the input sentences (list of lists) affects the output of Word2Vec?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":98,"Q_Id":51269058,"Users Score":1,"Answer":"That sounds like a reasonable solution. If you have access to data that is similar to your cleaned data you could get average sentence length from that data set. Otherwise, you could find other data in the language you are working with (from wikipedia or another source) and get average sentence length from there.\nOf course your output vectors will not be as reliable as if you had the correct sentence boundaries, but it sounds like word order was preserved so there shouldn't be too much noise from incorrect sentence boundaries.","Q_Score":0,"Tags":"python,nlp,gensim,word2vec,word-embedding","A_Id":51270563,"CreationDate":"2018-07-10T15:26:00.000","Title":"Use proxy sentences from cleaned data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that a.sort(key=lambda x: x[1]) means it sorts with respect to second element.\nBut x[-1]??\nShouldn't there be only two configurations x[0] and x[1]?\nOr am I missing something obvious?\nLets consider a = [(10, 4), (3, 5), (7, 1)]","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7655,"Q_Id":51269263,"Users Score":0,"Answer":"You are sorting by the last element of every tuple (ie, by 4, 5, 1 instead of by 10, 3, 7, resp.)","Q_Score":2,"Tags":"python,sorting,lambda,key","A_Id":51269292,"CreationDate":"2018-07-10T15:35:00.000","Title":"\"What does this mean: key=lambda x: x[-1] ?\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I did this command to check results of tensorflow training.\n\n\n    python label_image.py --image xxx.jpg --graph retrained_graph.pb --labels retrained_labels.txt\n\n\nAnd found following errors.\n\n\n    \/Users\/xxx\/anaconda3\/lib\/python3.6\/site-packages\/h5py\/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n      from ._conv import register_converters as _register_converters\n    2018-07-11 00:39:22.028051: I tensorflow\/core\/platform\/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA\n    Traceback (most recent call last):\n      File \"label_image.py\", line 131, in \n        input_operation = graph.get_operation_by_name(input_name)\n      File \"\/Users\/xxx\/tensorFlow\/lib\/python3.6\/site-packages\/tensorflow\/python\/framework\/ops.py\", line 3718, in get_operation_by_name\n        return self.as_graph_element(name, allow_tensor=False, allow_operation=True)\n      File \"\/Users\/xxx\/tensorFlow\/lib\/python3.6\/site-packages\/tensorflow\/python\/framework\/ops.py\", line 3590, in as_graph_element\n        return self._as_graph_element_locked(obj, allow_tensor, allow_operation)\n      File \"\/Users\/xxx\/tensorFlow\/lib\/python3.6\/site-packages\/tensorflow\/python\/framework\/ops.py\", line 3650, in _as_graph_element_locked\n        \"graph.\" % repr(name))\n    KeyError: \"The name 'import\/Mul' refers to an Operation not in the graph.\"\n\n\nlabel_image.py is following lines.\n\n\n      input_height = 299\n      input_width = 299\n      input_mean = 0\n      input_std = 255\n      input_layer = \"Mul\"\n      output_layer = \"final_result\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1478,"Q_Id":51269683,"Users Score":0,"Answer":"python label_image.py --image cat3.jpg --graph retrained_graph.pb --labels retrained_labels.txt --input_layer=Placeholder \nThis command, the problem was solved.","Q_Score":2,"Tags":"python,python-3.x,tensorflow,machine-learning","A_Id":51269893,"CreationDate":"2018-07-10T15:57:00.000","Title":"tensorflow error KeyError: \"The name 'import\/Mul' refers to an Operation not in the graph.\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've recently begun using Tensorflow via Keras and Python 3.5 to analyze company data, and I am by no means an expert and only recently built my first \"real-world\" model. \nWith my experimental data I used Tensorboard to visualiza how my neural network was working, and I would like to do the same with my real data. However, my company is extremely strict about company data leaving our servers -  so my question is this:\nDoes tensorboard take the raw data used in the model and upload it off-site to generate its reports\/visuals or does it only use processed data\/results from my model?\nI've done several google searches already, and I haven't found anything conclusive one way or the other.\nIf I'm not asking this question correctly, please let me know - I'm new to all of this.\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":51271790,"Users Score":0,"Answer":"No, Tensorboard does not upload the data to \"the cloud\" or anywhere outside the computer where it is running, it just interprets data produced by the model.","Q_Score":2,"Tags":"python,tensorflow,keras,tensorboard,privacy","A_Id":51272378,"CreationDate":"2018-07-10T18:17:00.000","Title":"Data Privacy with Tensorboard","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have this issue: \n\nContextualVersionConflict: (pandas 0.22.0 (...),\n  Requirement.parse('pandas<0.22,>=0.19'), {'scikit-survival'})\n\nI have even tried to uninstall pandas and install scikit-survival + dependencies via anaconda. But it still does not work....\nAnyone with a suggestion on how to fix?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":2454,"Q_Id":51272642,"Users Score":5,"Answer":"Restarting jupyter notebook fixed it. But I am unsure why this would fix it?","Q_Score":3,"Tags":"python,pandas,scikit-learn","A_Id":51272663,"CreationDate":"2018-07-10T19:19:00.000","Title":"Python: ContextualVersionConflict: pandas 0.22.0; Requirement.parse('pandas<0.22,>=0.19'), {'scikit-survival'})","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python app that I'd like to call on some images, by something like this:\n\nright clicking on images in windows\nmenu pops up => shows the python application in the list of items\nwhen clicked, batch runs on the images\n\nCan this be done w\/o using Visual Studio?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":51274400,"Users Score":0,"Answer":"That \"list of items\" is called the context menu. That is controlled by \"The Registry\", which is only accessible by the computer's administrator.\nMANDATORY WARNING: THE REGISTRY IS NOT A TOY, AND WILL BREAK YOUR COMPUTER IF YOU DO NOT KNOW WHAT YOU ARE DOING. IF YOU ARE NOT AT LEAST 80% CONFIDENT, DON'T TOUCH IT. I TAKE NO RESPONSIBILITY IF YOU BREAK YOUR COMPUTER. \nThat's not to say you will though. If you still want to continue, you should definitely back it up: \n\nOpen the registry\n\n\nPress (Windows key) + R to open the run dialog\nType in \"regedit.exe\" and then enter\nEnter you Administrative approval when prompted\n\nOnce in the registry, look at the panel on the left and all the way at the top there should be a \"folder\" (called \"key\" in the registry) called \"HKEY_CLASSES_ROOT\". Click on it. (If you can't find it, it might be under \"Computer\". Just expand it.). You should now see a lot of keys.\nBackup the registry (optional but recommended)\n\nClick on \"File\" (top) => \"Export\". \nOn the bottom, choose \"Selected branch\". If you want though, you could export the whole registry by selecting \"All\" just to be safe (it's a HUGE file though, and probably not necessary)\nChoose a file to save it to and click \"Save\". Wait for the loading to finish.\n\nDecide which file type you want. You said: image. That could be: \".jpg\", \".png\", \".bmp\", etc. Just repeat the following steps for all desired file types.\nFind the \"file type association\"\n\n\nUnder your selected key, find the key with the file extension you want (eg. \".jpg\"). Click on it \nThere will be a couple of \"values\" on the side. Check the one called \"(Default)\". This has the name of the file. (eg: \"jpegfile\")\n\nNavigate to the file. Still in the same key as the extension (\".jpg\"), locate the key with the name from step 5. Open it.\nMake a new command.\n\n\nRight-Click the \"shell\" key, select \"New\" => \"key\"\nName this new key with a logical, one word name (eg \"process\").\nThis new key has a \"(Default\") value. Change it's value (not the name) to what you want to appear on the right click menu. \nUnder your new key, make a new key called \"command\".\nSet this key's default value to the full path of your Python installation, a space, then the script path, including any arguments. You can pass \"%L%\" as an argument to have the registry replace it with the path to the right-clicked file. (eg. \"path\/to\/python.exe path\/to\/script.py %L%\"). Just  make sure your Python script can take arguments.\n\n\nDone!\nFeel free to comment with questions","Q_Score":2,"Tags":"python,windows,mouseevent","A_Id":51274809,"CreationDate":"2018-07-10T21:52:00.000","Title":"Is there a way to invoke python from Windows click?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python program using a RotatingFileHandler for logging.  The logging file handler opens the logfile in exclusive mode (once) and keeps it open until the app closes.  The problem is that I need to allow other processes to read the logfile while the Python program is still running.\nIn past projects using C++, I created a queued logger.  It maintained a queue of log entries.  A secondary worker thread would regularly check the queue and if there were any entries, open the logfile, dump the entries to the file, and immediately close the file until more log entries are queued.  This meant that (in processor time) >99% of the time, the file would be closed and available for other processes to peek into the logfile.\n(From a bit of digging, I'm under the impression that the Python logging class already handles the queuing of log entries...  That's not the part I'm asking about.)\nIs there a simple way to accomplish a normally-closed logfilehandler in Python?  (Preferably without having to add a 3rd party library or subsystem.)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":51274541,"Users Score":0,"Answer":"To me it seems that creating a separate thread managing this specific topic. As you pointed would be the best strategy.\nThe thread could perform read\/write for every other programs.\nYou can perfectly design this thread in python using the logging library.\nAnother strategy would be to use a system such as Sentry or Kibana","Q_Score":1,"Tags":"python,logging,logfile","A_Id":51274558,"CreationDate":"2018-07-10T22:06:00.000","Title":"Looking for a Python approach to normally-closed logfiles","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"In Python, let's say I'm using a library like flake8 to do style guide enforcement for my project and I've also told my fellow coders working on the same project that flake8 guidelines is what we will be using as the style guide. However, I'm not using it for anything directly in my project. I run flake8 in the command line to check if my project follows flake8 guidelines, but don't use it in my project for anything other that. If this is the case, Is flake8 something that belongs in the requirements.txt file? Or can it be omitted and only the dependencies actually used in the project need to go inside the requirements.txt file?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":261,"Q_Id":51276429,"Users Score":0,"Answer":"A requirements file should only include required dependencies of your program.  Since flake8 is a supporting module to ensure styling consistency it does not fall into this category.  I would not include it.","Q_Score":0,"Tags":"python,dependencies,requirements.txt,flake8","A_Id":51276592,"CreationDate":"2018-07-11T02:36:00.000","Title":"Python3: Should you include dependencies that you don't necessarily use in the project in the requirements.txt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a Python project which includes multiple repositories - it's an automation project. So the main runner triggers different scripts across all the repositories. I've noticed that I can debug (breakpoint) just on one of the repository , which is the one that the main script is called from. \nAnd if I put a breakpoint in a script that isn't in this repository and not getting to it. \nIn Pychram i've defined the in project structure the main folders of each repository as source, thinking it would solve this, but with no success. \nAll the folders are sitting under one main \"git\" folder. \nany ideas ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":111,"Q_Id":51278235,"Users Score":1,"Answer":"Do I get it right that your main script runs the other projects (\"repositories\", but let's call them \"subprojects\") as child processes, not as an in-process Python calls? \nIf so, you have to:\n\nattach PyCharm's debugger to those processes by hand, if they run for a noticeable time or can be paused;\nor make your main script only print the subproject invocation arguments, but not run it. Then create a new PyCharm run configuration for the subproject in question by hand, and set its command line arguments the way main script does.","Q_Score":1,"Tags":"python,debugging,pycharm,breakpoints","A_Id":51313971,"CreationDate":"2018-07-11T06:02:00.000","Title":"Breakpoints debug in Pycharm - multi repository project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I captured some Internet packets via Wireshark, now i want to extract the payload length only from the total length of the packet Using PYTHON. I can get the full length of the packet using pkt.length or pkt.captured_length. But i didn't find any command for extracting only payload size.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1999,"Q_Id":51279053,"Users Score":2,"Answer":"Payload size must be calculated based on the embedded protocol headers and lengths.  For example, the IP total length (which is most likely what you are seeing as \"packet length\") is the length of the entire IP datagram, including IP header, embedded protocol headers, and data.  To find the payload length you must, just as an IP stack would:\n\ndetermine the length of the IP header (likely 20, but it can have options) by multiplying the low order nibble of the first byte by 4.  \nDetermine the embedded protocol header based on the value of the 9th byte in the IP header\nDetermine the header length of the embedded protocol header; for instance, if this is TCP, multiplying the high order nibble of the twelfth byte by 4 to determine the total header length of the TCP header including options.\n\nIf you add up these values, you can then subtract them from the IP total length (packet length) to determine the payload length.\nOf course, from an IP point of view, you could just subtract the length of the IP header from the total length; from IP's point of view, everything inside of it is just payload. :)","Q_Score":1,"Tags":"python,wireshark,packet-capture,payload","A_Id":51286456,"CreationDate":"2018-07-11T06:55:00.000","Title":"Extracting Packet payload length","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got an automated mailing system with MIMEText, and I would like to change the font of the text in one line.\nHow do I do that, can you help me please?\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2587,"Q_Id":51285184,"Users Score":0,"Answer":"MIMEText should support HTML tags, so you can just wrap <font face=\"Font name\">Text<\/font> tags around it. This is of course assuming that your clients are reading the message with a client that will parse the HTML tags.","Q_Score":0,"Tags":"python,email,fonts,size","A_Id":51285274,"CreationDate":"2018-07-11T12:11:00.000","Title":"Python - How to change the font with MIMEText","Data 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 got an automated mailing system with MIMEText, and I would like to change the font of the text in one line.\nHow do I do that, can you help me please?\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2587,"Q_Id":51285184,"Users Score":2,"Answer":"MIMEText will generate the mail in plaintext (which is generated in a monospaced font, and there's nothing you can do about it) and as HTML.\nWith HTML, you could simply wrap your e-mail in a font or font face (the last one, if you need to indicate only the font's family) tag:\n<font=\"Font Name Here\">Your e-mail here<\/font>\nObs: you can only accomplish that if your recipient is reading mail in an HTML capable email client.","Q_Score":0,"Tags":"python,email,fonts,size","A_Id":51285279,"CreationDate":"2018-07-11T12:11:00.000","Title":"Python - How to change the font with MIMEText","Data 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 the sample() method for a KernelDensity that is fitted to my data's percentage changes. Are the samples from the sample method in the same units as my input data? I ask because documentation says that for the score_sample() method it actually returns the log density and I just want to make sure the same doesn't happen with the sample method or if there's a need to adjust the output.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":118,"Q_Id":51287512,"Users Score":0,"Answer":"Answer: yes, the sample is in the same unit as my input data. I checked carefully and with a cold head :)","Q_Score":0,"Tags":"python-3.x,scikit-learn,kernel-density","A_Id":51949438,"CreationDate":"2018-07-11T14:02:00.000","Title":"sampling from sklearn Kernel Density estimation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to divide a city into n squares. \nRight now, I'm calculating the coordinates for all square centres and using the ox.graph_from_point function to extract the OSM data for each of them.\nHowever, this is getting quite long at high n due to the API pausing times.\nMy question:\nIs there a way to download all city data from OSM, and then divide the cache file into squares (using ox.graph_from_point or other) without making a request for each?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":161,"Q_Id":51287813,"Users Score":1,"Answer":"Using OSMnx directly - no, there isn't. You would have to script your own solution using the existing tools OSMnx provides.","Q_Score":1,"Tags":"python-3.x,osmnx","A_Id":51637340,"CreationDate":"2018-07-11T14:15:00.000","Title":"OSMnx: Divide a cache ox.graph into equal squares without redownloading each","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between $PATH variable, sys.path and os.environ? I understand that they both serve as paths where python searches packages. But it'd be nice to have more elaborate response.\nJust a working case from my practice is when I used the script with only os.environ before import on Ubuntu 16.04 I got ImportError: No module named XXX. At the same time on MacOS it worked well. After I added sys.path on Ubuntu I could get import module well.\nThanks for the explanation at Advance.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":8363,"Q_Id":51288512,"Users Score":4,"Answer":"sys.path\nIs a list of strings that specifies the search path for modules. Initialized from the environment variable PYTHONPATH, plus an installation-dependent default.\nos.environ\nIs a mapping object representing the string environment. For example, environ['HOME'] is the pathname of your home directory (on some platforms), and is equivalent to getenv(\"HOME\") in C.\nEnvironment variable PATH\nSpecifies a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting.","Q_Score":17,"Tags":"python-3.x","A_Id":51291905,"CreationDate":"2018-07-11T14:48:00.000","Title":"Difference between $PATH, sys.path and os.environ","Data 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 write a program in Python (with OpenCV) that compares 2 images, shows the difference between them, and then informs the user of the percentage of difference between the images.  I have already made it so it generates a .jpg showing the difference, but I can't figure out how to make it calculate a percentage.  Does anyone know how to do this?\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12248,"Q_Id":51288756,"Users Score":0,"Answer":"You will need to calculate this on your own. You will need the count of diferent pixels and the size of your original image then a simple math: (diferentPixelsCount \/ (mainImage.width * mainImage.height))*100","Q_Score":6,"Tags":"python,opencv","A_Id":51289142,"CreationDate":"2018-07-11T15:01:00.000","Title":"How do I calculate the percentage of difference between two images using Python and OpenCV?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I noticed that the de facto standard for array manipulation in Python is through the excellent numpy library. However, I know that the Python Standard Library has an array module, which seems to me to have a similar use-case as Numpy.\nIs there any actual real-world example where array is desirable over numpy or just plain list?\nFrom my naive interpretation, array is just memory-efficient container for homogeneous data, but offers no means of improving computational efficiency.\n\nEDIT\nJust out of curiosity, I searched through Github and import array for Python hits 186'721 counts, while import numpy hits 8'062'678 counts.\nHowever, I could not find a popular repository using array.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2898,"Q_Id":51290791,"Users Score":0,"Answer":"Yes, if you don't want another dependency in your code.","Q_Score":7,"Tags":"python,arrays,numpy","A_Id":51290834,"CreationDate":"2018-07-11T16:59:00.000","Title":"Numpy arrays vs Python arrays","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to update an account on salesforce using an external custom field? \nI've tried sf.Account.Update(\"Custom_Field__c:{}.format(field), data) and I cannot seem to get it to work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":337,"Q_Id":51291908,"Users Score":0,"Answer":"I know this is really late, but in case somebody else stumbles on this:\nThe answer is yes, however your code is formatted incorrectly.\nThe update method that you're asking about is actually lower-case, it typically takes two arguments to evaluate correctly, a valid SF Id as a string, and the data you want to update with as a dictionary. So to fix what's going on in your question it would look like:\nsf.Account.update(\"15characterIdoftheAccount\", {\"Custom_Field__c:{}.format(thevalueyouwanttoshowupinSF)})","Q_Score":0,"Tags":"python,salesforce,simple-salesforce","A_Id":52012065,"CreationDate":"2018-07-11T18:14:00.000","Title":"simple salesforce update on custom field","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While using tweepy I came to know about encode(utf-8). I believe encode utf-8 is used to display tweets only in English, Am i right in this regard beacuse I want to make data sets of tweets which are only Written in English, so I can process that tweets for NLP","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":875,"Q_Id":51292190,"Users Score":0,"Answer":"No, UTF-8 is a mechanism for encoding Unicode content. This means that it supports almost all scripts of the vast majority of human languages.","Q_Score":1,"Tags":"python,utf-8,internationalization,tweepy","A_Id":51292254,"CreationDate":"2018-07-11T18:35:00.000","Title":"Python Tweepy Encode(utf-8)","Data 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 a conceptual question. I am unit testing a script I wrote that has multiple modules. I have a main.py and a formatting.py. My coverage is at 100% for formatting but my main.py is at 30%. In my main, I just call all of the functions inside formatting. Do i need to just test them again in main directly? This seems like a waste of time? Maybe I am not understanding correctly. Thanks in advance","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":117,"Q_Id":51292465,"Users Score":1,"Answer":"Usually the trick is to test what external function does by itself and not other functions that are called and are already tested. This is not a problem if internal functions are actually called, just avoid testing them again.\nIf you want to avoid calling internal functions though, you may try dependecy injection or mocking.\nIf your external function is simple enough, you may forgo testing it, 100% coverage is not a rule.","Q_Score":1,"Tags":"python,unit-testing","A_Id":51292632,"CreationDate":"2018-07-11T18:56:00.000","Title":"unit test main.py with other 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 more a conceptual question. I am unit testing a script I wrote that has multiple modules. I have a main.py and a formatting.py. My coverage is at 100% for formatting but my main.py is at 30%. In my main, I just call all of the functions inside formatting. Do i need to just test them again in main directly? This seems like a waste of time? Maybe I am not understanding correctly. Thanks in advance","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":117,"Q_Id":51292465,"Users Score":1,"Answer":"The fact that internal pieces are tested allows you to capitalize on it by reducing the number of the tests required for the new, higher level method.\nThere always will be some redundancy between those, but decent and straightforward seams would allow you to have a very few tests for the new level. \nThe guys in the other answers are talking about considering those tests as integrational, but I would claim that you also would need some tests in isolation for the upper function itself with all already tested dependencies being mocked and excluded. \nIt's not always necessary, but please be aware that you end up with a mixed test otherwise, since there's a new functionality on the top level.","Q_Score":1,"Tags":"python,unit-testing","A_Id":51293145,"CreationDate":"2018-07-11T18:56:00.000","Title":"unit test main.py with other 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 more a conceptual question. I am unit testing a script I wrote that has multiple modules. I have a main.py and a formatting.py. My coverage is at 100% for formatting but my main.py is at 30%. In my main, I just call all of the functions inside formatting. Do i need to just test them again in main directly? This seems like a waste of time? Maybe I am not understanding correctly. Thanks in advance","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":117,"Q_Id":51292465,"Users Score":1,"Answer":"A good rule of thumb for unit testing is to:\n\nseparate your code from the part that does logic and the part that does input\/output\nunit test the part that does logic\nnot unit test the part that does i\/o\n\nBut how will you know the program works then? Well, how about some integration tests? For example, if you're writing a command line script, an integration test might run it the whole script with some inputs and check if the script did the right thing, without even considering how it is structured.\nDepending on your needs and the size of the script, you might decide to have unit tests, integration tests or both.","Q_Score":1,"Tags":"python,unit-testing","A_Id":51292746,"CreationDate":"2018-07-11T18:56:00.000","Title":"unit test main.py with other 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":"I would like to use Pycharm to write some data science code and I am using Visual Studio Code and run it from terminal. But I would like to know if I could do it on Pycharm? I could not find some modules such as cluster and pylab on Pycharm? Anyone knows how I could import these modules into Pycharm?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":4718,"Q_Id":51294349,"Users Score":1,"Answer":"Go to the Preferences Tab -> Project Interpreter, there's a + symbol that allows you to view and download packages. From there you should be able to find cluster and pylab and install them to PyCharm's interpreter. After that you can import them and run them in your scripts.\nAlternatively, you may switch the project's interpreter to an interpreter that has the packages installed already. This can be done from that same menu.","Q_Score":2,"Tags":"python,pycharm,data-science","A_Id":51294446,"CreationDate":"2018-07-11T21:22:00.000","Title":"How to import 'cluster' and 'pylab' into Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed Anaconda on Linux. When trying to open spyder (either from navigator or terminal), it does not work. I get the following error when I try to open it in terminal: \nSegmentation fault (core dumped) \nI updated Conda completely but can't solve the problem. I am using Conda version 4.5.5 and Ubuntu 18.04. Any idea?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7490,"Q_Id":51294499,"Users Score":11,"Answer":"(Spyder maintainer here) This problem is caused by faulty graphical card drivers and there are two ways to fix it:\n\nUpdate to Spyder 3.3 or higher.\nInstall pyopengl with conda.","Q_Score":4,"Tags":"python,anaconda,spyder","A_Id":51306671,"CreationDate":"2018-07-11T21:35:00.000","Title":"Spyder anaconda crashes on Linux with segmentation fault","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed Anaconda on Linux. When trying to open spyder (either from navigator or terminal), it does not work. I get the following error when I try to open it in terminal: \nSegmentation fault (core dumped) \nI updated Conda completely but can't solve the problem. I am using Conda version 4.5.5 and Ubuntu 18.04. Any idea?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7490,"Q_Id":51294499,"Users Score":0,"Answer":"I saw issue on brand new Fedora with new anaconda installation. Just updating the spyder to latest version (in my case 3.3.1) fixed it, without anything else. \n(BTW: You can do this even from anaconda navigator itself, just look after the wheel within each application panel in the right corner).\nWould recommend to fix anything stepwise, start with upgrading to the latest spyder and if this doesn't work, try the other stuff.","Q_Score":4,"Tags":"python,anaconda,spyder","A_Id":52031135,"CreationDate":"2018-07-11T21:35:00.000","Title":"Spyder anaconda crashes on Linux with segmentation fault","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a severe space limitation on my deployment device that mean I cannot fit the entire \"Keras\" package.\nIs there a way to get a prediction from a trained keras model without the entire keras package?\nI have noted that the Keras docker is ~1GB. I would need it to be < 650MB","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":137,"Q_Id":51297972,"Users Score":0,"Answer":"I was able to get my docker container small enough by using a different backend when predicting ( theano ) as opposed to tensorflow.\nThe other solutions I investigated are some C++ libraries, e.g. ( frugally deep, kerasify, keras2cpp ) but the preprocessng of my data became much harder ( for me anyway ). So I went with the theano backend as above!\nOf course you could manually do the convolutions for each filter etc in python.. but that would be even harder","Q_Score":3,"Tags":"python,tensorflow,keras","A_Id":51536067,"CreationDate":"2018-07-12T05:34:00.000","Title":"\"Mini Keras\" Is there a way get a prediction form a trained keras model without the entire keras package?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently started having a need for a task queue in my Django program, and I'm worried about how robust it will be in the future or what will need to be overcome for a production deployment. \nI'm using the Redis-Queue or RQ library for Python, which markets itself as easier to learn and use than something like Celery (which I haven't quite learned). Does anyone have any input on this? Do you think RQ coupled with Redis would be OK in production, or would you use something else? What do large-scale apps use for task queueing?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1130,"Q_Id":51299464,"Users Score":0,"Answer":"Celery works in production, as far as I know, for Python\/Django, the most mature implementation of synchronous task queue\/job queue based on distributed message passing, with Redis as a broker works just fine.\nWhat you would need in production is not only send a simple message but a high-level API for:\n\nScale, auto-scale.\nReal-time monitor.\nTask schedulers.\nPrioritization.\nMulti broker support.\nWorkflow based tasks.\n\nFor which Celery is ready.","Q_Score":0,"Tags":"python,django,redis,task,production-environment","A_Id":51302458,"CreationDate":"2018-07-12T07:17:00.000","Title":"Redis-Queue (RQ) Task Queues in Production","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I recently started having a need for a task queue in my Django program, and I'm worried about how robust it will be in the future or what will need to be overcome for a production deployment. \nI'm using the Redis-Queue or RQ library for Python, which markets itself as easier to learn and use than something like Celery (which I haven't quite learned). Does anyone have any input on this? Do you think RQ coupled with Redis would be OK in production, or would you use something else? What do large-scale apps use for task queueing?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1130,"Q_Id":51299464,"Users Score":0,"Answer":"Yes, redis and redis-queue is very easy to setup. And yes, they can be used in a production system. You can also take a look at RabbitMQ. It can be used as task queue. It support persistence and clustering for scaling.","Q_Score":0,"Tags":"python,django,redis,task,production-environment","A_Id":51316460,"CreationDate":"2018-07-12T07:17:00.000","Title":"Redis-Queue (RQ) Task Queues in Production","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to translate PDFs files using translation API and output it as PDF by keeping the format same. My approach is to convert the PDF to word doc and to translate the file and then convert it back to PDF. But the problem, is there no efficient way to convert the PDF to word. I am trying to write my own program but the PDFs has lots of formats.  So I guess it will take some effort to handle all the formats. So my question, is there any efficient way to translate there PDFs without losing the format or is there any efficient way to convert them to docx. I am using python as programing language.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3080,"Q_Id":51303812,"Users Score":1,"Answer":"Probably not.\nPDFs aren't meant to be machine readable or editable, really; they describe formatted, laid-out, printable pages.","Q_Score":0,"Tags":"python,pdf,docx","A_Id":51303850,"CreationDate":"2018-07-12T10:54:00.000","Title":"Translate pdf file by keeping the formating 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 noticed that when I do an editable install (pip install --user -e .), sometimes, setuptools make a build directory and egg-links to \/...\/my_module\/build\/lib.\nWhile sometimes (if I do it in another project), it does not create this directory and simply egg-links to \/...\/my_module\nHowever, I can't figure out why. In the first case, the project is not really editable (since it seems to build the package, and link to the build version)\nWhat does cause setup tools to use build\/lib rather than the package dev directory ?\n(Note : these are full python projects that are intended to be distributed with sdist)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":51306780,"Users Score":0,"Answer":"The setuptools build_py command seems to be automatically called when there is a build step specified int the setup.py, typical example is use_2to3=True. Then, the \"editable\" is not \"respected\" in a way, since you need to rebuild each time.","Q_Score":1,"Tags":"python,pip,setuptools","A_Id":51308868,"CreationDate":"2018-07-12T13:19:00.000","Title":"When does setuptools install editable link to \/...\/my_module\/build\/lib\/ andwhen does it link to \/...\/my_module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just upgraded to python 3.7 and I realized that all my modules stuck with the previous version. Even Django is not recognised anymore. How can I do to transfer everything to the new version? I am a little lost right now, don't even know where the new version has been installed.\nEdit:\nWhen I do $ which python3.6 the terminal tells me it doesn't exist, but I have a python3.6 directory in \/usr\/local\/lib\/, where all modules are installed.\nIn the same directory \/usr\/local\/lib\/ I also have a python3.7 directory with some modules installed but many are missing. However when I search for the file python3.7 in my finder it doesn't appear. when I do $ which python3.7 the path is \/usr\/local\/bin so not the same path as the directory.\nAnyone sees what happened and knows how I can transfer all modules to python3.7?","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21318,"Q_Id":51308683,"Users Score":0,"Answer":"I faced a similar problem, now that I upgraded from python 3.7 to python 3.8 (new)\nI installed Python 3.8, but the system kept the python37 subfolder with the already installed packages(...\\Python37-32\\Lib\\site-packages)  even with the  Pyhton38 subfolder created, with the new python.exe.\nUsually, it's possible to keep on using the old libraries on your new Python version, because the existent libraries installation folder are already registered in your local computer  system path (*).\nEven though, I've had problems to use some libraries (some worked  in Jupyter Notebook but not in Spyder). I tried the alternatives others proposed to migrate libraries  but it did not worked (maybe I did not\nSo I used brutal force solution.. Not elegant at all, but it worked:\n\nremove the OLD python version folders from the system path  or even remove the folder itself for good..\nFolders:  C:\\Users\\USERNAME\\AppData\\Roaming\\Python\\Python37\nC:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python37\n\nReinstall the packages you need, preferably via Anaconda prompt.\npython -mpip install library_name\nOR\npip install --user --force-reinstall package_name\nOR\npip install --user --force-reinstall package_name == specify_package_version\n\n\nThe libraries will be installed  at  c:\\users\\USERNAME\\anaconda3\\lib\\site-packages and recognized by your new python version.\n(*) to add the folder to the PATH:  System properties --> environment variables --> click \"Path\"--> edit --> add folder name)","Q_Score":26,"Tags":"python,package,updates,python-module","A_Id":63197461,"CreationDate":"2018-07-12T14:49:00.000","Title":"How to move all modules to new version of Python (from 3.6 to 3.7)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was trying to pack and release a project which uses tensorflow-gpu. Since my intention is to make the installation as easy as possible, I do not want to let the user compile tensorflow-gpu from scratch so I decided to use pipenv to install whatsoever version pip provides.\nI realized that although everything works in my original local version, I can not import tensorflow in the virtualenv version.\nImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory\nAlthough this seems to be easily fixable by changing local symlinks, that may break my local tensorflow and is against the concept of virtualenv and I will not have any idea on how people installed CUDA on their instances, so it doesn't seems to be promising for portability.\nWhat can I do to ensure that tensorflow-gpu works when someone from internet get my project only with the guide of \"install CUDA X.X\"? Should I fall back to tensorflow to ensure compatibility, and let my user install tensorflow-gpu manually?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":124,"Q_Id":51309596,"Users Score":1,"Answer":"Having a working tensorflow-gpu on a machine does involve a series of steps including installation of cuda and cudnn, the latter requiring an NVidia approval. There are a lot of machines that would not even meet the required config for tensorflow-gpu, e.g. any machine that doesn't have a modern nvidia gpu. You may want to define the tensorflow-gpu requirement and leave it to the user to meet it, with appropriate pointers for guidance. If the  project can work acceptably on tensorflow-cpu, that would be a much easier fallback option.","Q_Score":0,"Tags":"python,tensorflow","A_Id":51310630,"CreationDate":"2018-07-12T15:34:00.000","Title":"Can I let people use a different Tensorflow-gpu version above what they had installed with different CUDA dependencies?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a variable in my python script that holds the path to a file as a string. Is there a way, through a python module, etc, to keep the file path updated if the file were to be moved to another destination?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":51310177,"Users Score":0,"Answer":"Short answer: no, not with a string.\nLong answer: If you want to use only a string to record the location of this file, you're probably out of luck unless you use other tools to find the location of the file, or record whenever it moves - I don't know what those tools are. \nYou don't give a lot of info in your question about what you want this variable for; as @DeepSpace says in his comment, if you're trying to make this String follow the file between different runs of this program, then you'd be better off making an argument for the script. If, however, you expect the file to move sometime during the execution of your program, you might be able to use a file object to keep track of it. Or, rather - instead of keeping the filepath in memory, keep a file descriptor in memory instead (the kind you would generate by using the open() function, and just never close that file until the program terminates. You can use seek to return to the start of the file if you needed to read it multiple times. Problems with this include that it's not memory-safe, and it's absolutely not a best practice.","Q_Score":1,"Tags":"python,python-2.7","A_Id":51310363,"CreationDate":"2018-07-12T16:05:00.000","Title":"Python module to keep a file location variable updated?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a variable in my python script that holds the path to a file as a string. Is there a way, through a python module, etc, to keep the file path updated if the file were to be moved to another destination?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":51310177,"Users Score":0,"Answer":"TL;DR\nYour best bet is probably to go with a solution like @DeepSpace mentioned where you could go and call your script with a parameter in command-line which will then force the user to input a valid path.\n\nThis is actually a really good question, but unfortunately purely Pythonly speaking, this is impossible. \nNo python module will be able to dynamically linked a variable to a path on the file-system. You will need an external script or routine which will update any kind of data structure that will hold the path value. \nEven then, the name of the file could change, but not it's location. here is what I mean by that.\nLet's say you were to wrapped that file in a folder only containing that specific file. Since you now know that it's location is fixed (theoretically speaking), you can have another python script\/routine that will read the filename and store it in a textfile. Your other script could go and get that file name (considering your routine would sync that file on a regular basis). But, as soon as the location of the file changes, how can you possibly know where it is now. It has to be manually hard coded somewhere to have something close to the behavior your expecting.\nNote that my example is not in any way a solution to go-to for your problem. I'm actually trying to underline the shortcomings of such a feature.","Q_Score":1,"Tags":"python,python-2.7","A_Id":51310528,"CreationDate":"2018-07-12T16:05:00.000","Title":"Python module to keep a file location variable updated?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have python scripts developed using py3.6, but while deploying we found that liunx machines are on 2.7.  \nIs there any way we still execute our 3.6 version scripts on 2.7 ?\nI found the other way of running , but not getting the leads for 3.6 on 2.7.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":554,"Q_Id":51310762,"Users Score":1,"Answer":"One think we can do about running the the code written in Python3  on Python2 compiler. Convert the python3 files to Python2 files by using the package \npython-3to2\nInstall(for ubuntu, for Redhat use yum)\nsudo apt install python-3to2\nand then Run\n3to2 -w python_3_file.py\nIt will modify the file to python 2 compatible and then you can start execute using Python2","Q_Score":0,"Tags":"python,python-3.x","A_Id":51311187,"CreationDate":"2018-07-12T16:43:00.000","Title":"Run python 3.6 on 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a working application that successfully uses the python-can module to receive incoming messages on a kvaser CAN bus. When I used PyInstaller to convert this program to an executable file, the terminal logged that it \"loaded kvaser's CAN library.\" The outputted .exe GUI runs as normal, yet the program suddenly doesn't receive any more CAN messages like it had beforehand. In the terminal, I printed the error it catches: \n\"Cannot import module can.interfaces.kvaser for CAN interface 'kvaser': No module named 'can.interfaces.kvaser\". \nNote that in the .spec file that I used to create the executable, I added \"import can.interfaces.kvaser\" at the top. I am not sure if the error I am getting is because I am not using pyinstaller correctly or if it is because I am somehow importing the CAN dependencies incorrectly, yet I suspect it is likely due to the latter. Is there a different way to import the python-can kvaser module that may solve this discrepancy between CAN functionality of the program before and after it was converted to an executable?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":812,"Q_Id":51312059,"Users Score":2,"Answer":"Figured it out. It turns out that PyInstaller specifically installs the dependencies at the top of the main file you want to execute. Dependencies in other python files that you import into the main file aren't detected by PyInstaller. I added all the import calls I needed to the main file and it worked.","Q_Score":2,"Tags":"python,exe,pyinstaller,can-bus","A_Id":51326002,"CreationDate":"2018-07-12T18:12:00.000","Title":"Kvaser's CAN library has been loaded, but program executable outputs a \"No module named 'can.interfaces.kvaser'\" error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the following problem:\nI'm working on a formula to calculate some network effects. The idea is that I have 450 \"red users\" and 6550 \"blue users\" which sums up to 7000 users in total. Now I would like to plot \"picking x users (the same user cannot be picked twice, so this is sampling without replacement) and calculate the probability that at least 1 user is red\". \nE.g for x = 3, that means I'm picking 3 random users out of 7000 and check if any of these are \"red users\"\nThe probability for having at least 1 red user is p = 1 - the probability all 3 picks are blue users and the probability for a blue user is equal to p = 6550\/7000, right? \nResulting in a probability for at least 1 red user:\n* p = 1 - 6550\/7000 * 6549\/6999 * 6548\/6998 *\nTherefore i came up with the formula:\nf(x) = e^-(1- sum of (6500-i)\/(7000-i)); for i = 0, till x)\nWhat I've realized is that the curve is pretty edgy since it's just going from a value in \u2115 to the next value in \u2115. \nAlthough adding decimal numbers wouldn't make that much sense since \"picking 0,5 users or even 0,01 users\" is just stupid, I would like to see the full graph in order to be able to compare the formula to some others. \nIs there any way I can implement this in python?\nBest regards,\nKorbi","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":51312546,"Users Score":0,"Answer":"In your formula, wouldn't it be the product instead of the sum? Anyways, my original thought was to use the Poisson distribution, but that wouldn't work since it's without replacement. The problem is that the factorial function is only defined for whole numbers, so you'd need to use the gamma function.","Q_Score":0,"Tags":"python,numpy,matplotlib,probability-theory","A_Id":51313130,"CreationDate":"2018-07-12T18:47:00.000","Title":"Plot Probability Curve with Summation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I would like to ask if is possible to update my app with a socket server like in other apps when there is an update so its downloading and updating the code without downloading the app again","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":51313649,"Users Score":0,"Answer":"To answer you question directly, \"yes, it is possible\".  Python is a general purpose language and can do that kind of thing readily enough.  the \"how\" will depend your app.","Q_Score":0,"Tags":"python,python-3.x,updates","A_Id":51313884,"CreationDate":"2018-07-12T20:07:00.000","Title":"UPDATE my script in python with python socket","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've set up a simple appJar UI, which has an \"execute\" button that calls a function containing code that takes a minute to run. I have injected my gui() variable, app, into this function.\nThere are 4 major steps, after each of which I would like a Statusbar to update to reflect that a step has been completed. However, what tends to happen is that as the function code runs, the GUI becomes unresponsive and it isn't until the code completes execution that ALL of the changes to the status bar are displayed at once.\nMy question is how should I be handling the UI such that the Statusbar is updated in real time?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":284,"Q_Id":51313880,"Users Score":1,"Answer":"appJar is just a wrapper around python tkinter module from standard library.\nWhile your code is running, the ui is not running, thus it becomes unresponsive. If you want the ui to remain responsible, you have to return control from your code to the ui library from time to time. \nThat can be done by calling gui.topLevel.update() in your code, or by using asynchronous programming and having the main async loop call it, or by using threads.\nWhich one of those is the best, depends on what your program is doing.","Q_Score":0,"Tags":"python,user-interface","A_Id":51313975,"CreationDate":"2018-07-12T20:23:00.000","Title":"appJar status bar doesn't update in real time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have like 3 columns in a data frame for example\nColumn_A has 2 categorical values like A,B \nColumn_B also has 3 categorical values like Type1, Type2, Type3    \nDate column has values like 2010-06-13,2010-06-10\nThere are about 20,000 rows so the Categorical Column A,B's values keep repeating.\nSo  I need the find min date where Column_A='A' and Column_B='type 1' using Python(Pandas,Numpy)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":51314716,"Users Score":0,"Answer":"Use boolean index with loc and min:\ndf.loc[(df['Column_A'] == 'A') & (df['Column_B'] == 'type 1'), 'Date'].min()","Q_Score":0,"Tags":"python-3.x,pandas,numpy,jupyter-notebook","A_Id":51314759,"CreationDate":"2018-07-12T21:27:00.000","Title":"Groupby to find min date with conditions in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the Pycharm Editor, say my caret now is at the 30th row, the first character.\nWhat is the shortcut to move to the 30th row, the 80th character?\nThe recommended line length for Python is 80. When working on someone else' code using 120 character length, I found myself frequently need to move my caret to the 80th character and hit an Enter.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":615,"Q_Id":51315250,"Users Score":1,"Answer":"In Settings -> Code Style, you can set \"Visual guides\" to 80 columns. This will give a vertical bar in your editor to show you the 80 column width. You can then press Alt-Ctrl-L to reformat your code to fit within that width. This will also format your code to conform with all other PEP8 conventions.","Q_Score":0,"Tags":"python,intellij-idea,pycharm","A_Id":51315877,"CreationDate":"2018-07-12T22:21:00.000","Title":"IntelliJ Pycharm how to move caret to a certain nth character of the row","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on OS X and have initially installed python3 with homebrew, together with some packages (numpy, scipy, matplotlib, ipython) that I installed using pip.\nIs it now possible to install conda\/anaconda and create isolated conda environments that are independent of my system-wide installation?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":338,"Q_Id":51319551,"Users Score":3,"Answer":"Yes, it is. Anaconda will install python 2.7.15 or python 3.6.5, but you can create conda environments for any version of python you wish. The commandconda create -n yourenv python=3.4 creates a conda environment tied to python 3.4, for example. the Anaconda documentation has more options for creating conda environments which may be helpful in your particular case.","Q_Score":1,"Tags":"python,macos,pip,conda","A_Id":51329503,"CreationDate":"2018-07-13T07:10:00.000","Title":"Using conda when systemwide python is available","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I implement magic\/special methods inside a class (__len__, __contains__, __iter__), are they usually placed above other methods I implement (right after __init__) or below? Also, is there an order that these magic methods are typically placed in? Alphabetically or...?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":51329091,"Users Score":0,"Answer":"There is no predefined style, so you should follow the standards of the project\/team you're working in. \nA good idea is to group them logically, in the way that makes your code intent easier to understand.\nThat said, this question is mostly opinion based and offtopic here, so I'm voting to close it.","Q_Score":1,"Tags":"python","A_Id":51329200,"CreationDate":"2018-07-13T16:08:00.000","Title":"Where should magic methods be placed inside a class relative to other methods?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I implement magic\/special methods inside a class (__len__, __contains__, __iter__), are they usually placed above other methods I implement (right after __init__) or below? Also, is there an order that these magic methods are typically placed in? Alphabetically or...?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":51329091,"Users Score":0,"Answer":"If it's not covered in a PEP document, there's no community \"standard\".\nThese decisions are something to work out with whomever will be reading and maintaining your code.\nIn my most recent project, we arrange them in order of incremental development: put the house-keeping methods (e.g. __init__) first, then those useful for debugging (e.g. __repr__), then the basic comparators (__lt__, __contains__), iteration support, continuing in order of type-specificity.","Q_Score":1,"Tags":"python","A_Id":51329251,"CreationDate":"2018-07-13T16:08:00.000","Title":"Where should magic methods be placed inside a class relative to other methods?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Parcels_All.csv which I compiled by merging many smaller\nparcel files, using the command line copy *.csv\nI have WKT_Revisions_Combined.csv that needs to go into\nParcels_All.csv to update certain sections of data.\nI have vlookup.py script that can print the data from\nWKT_Revisions_Combined.csv into Parcels_All.csv by referencing row\nID's and column headers.\n\nVlookup.py has not been able to successfully run because it seems there is an error within Parcels_All.csv. When I open the file in EmEditor (a big data text editor) it gives the error message \"Inconsistent number of columns detected\" for a few rows\nThe interesting thing is when I open Parcels_All.csv in Excel the data is organized and in place; no inconsistent columns.\nAny thoughts? Could it be an encoding issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1552,"Q_Id":51329549,"Users Score":0,"Answer":"When a CSV file with different number of columns are imported to Excel, the differences in row lengths are not evident. Excel has an infinitely wide table by default, so the real size of the CSV file is not shown. I suspect there are empty fields in the last column somewhere, because these would not be evident in Excel.","Q_Score":1,"Tags":"python,csv,encoding,emeditor","A_Id":51385960,"CreationDate":"2018-07-13T16:40:00.000","Title":"Inconsistent number of columns","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pretty self-explanatory, trying to do a small web scraper from a google search, but when trying to import, using \"from google import search\" I get the error:\n\nModuleNotFoundError: No module named 'google'. \n\nWhen trying to install google again from the command prompt using \"pip install google\" I get the error: \nRequirement already satisfied: google in c:\\users\\dsimard\\python\\lib\\site-packages (2.0.1)\nRequirement already satisfied: beautifulsoup4 in c:\\users\\dsimard\\python\\lib\\site-packages (from google) (4.6.0)\nI am writing this program in eclipse.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":432,"Q_Id":51331133,"Users Score":0,"Answer":"Try from googlesearch import search","Q_Score":0,"Tags":"python,eclipse","A_Id":51573332,"CreationDate":"2018-07-13T18:40:00.000","Title":"getting error \"modulenotfounderror: No module named 'google'\" but when trying to install through command prompt it says requirement already satisfied","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a needs to do calculation like average of selected data grouped by time rage collections.\nExample:\nTable which is storing data has several main columns which are:\n  | time_stamp | external_id | value |\nNow i want to calculate average for 20 (or more) groups of date ranges:\n1) 2000-01-01 00-00-00 -> 2000-01-04 00-00-00\n2) 2000-01-04 00-00-00 -> 2000-01-15 00-00-00\n...\nThe important thing is that there are no gaps and intersections between groups so it means that first date and last date are covering full time range.\nThe other important thing is that in set of \"date_from\" to \"date_to\" there can be rows for outside of the collection (unneeded external_id's).\nI have tried 2 approaches:\n1) Execute query for each \"time range\" step with average function in SQL query (but i don't like that - it's consuming too much time for all queries, plus executing multiple queries sounds like not good approach)\n2) I have selected all required rows (at one SQL request) and then i made loop over the results. The problem is that i have to check on each step to which \"data group\" current datetime belongs. This seams like a better approach (from SQL perspective) but right now i have not too good performance because of loop in the loop. I need to figure out how to avoid executing loop (checking to which group current timestamp belongs) in the main loop.\nAny suggestions would be much helpful.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":57,"Q_Id":51333360,"Users Score":1,"Answer":"Actually both approaches are nice, and both could benefit on the index on the time_stamp column in your database, if you have it. I will try to provide advice on them:\n\nMultiple queries are not such a bad idea, your data looks to be pretty static, and you can run 20 select avg(value) from data where time_stamp between date_from and date_to-like queries in 20 different connections to speed up the total operation. You'll eliminate need of transferring a lot of data to your client from DB as well. The downside would be that you need to include an additional where condition to exclude rows with unneeded external_id values. This complicates the query and can slow the processing down a little if there are a lot of these values.\nHere you could sort the data on server by time_stamp index before sending and then just checking if your current item is from a new data range (because of sorting you will be sure later items will be from later dates). This would reduce the inner loop to an if statement. I am unsure this is the bottleneck here, though. Maybe you'd like to look into streaming the results instead of waiting them all to be fetched.","Q_Score":1,"Tags":"python,postgresql","A_Id":51333655,"CreationDate":"2018-07-13T22:04:00.000","Title":"Calculating average of multiple sets of data (performance issue)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to get pip3 running on my Mac terminal for a project. I have python3 installed, and I can run it, but when I try to run pip3 freeze, it says my command is not found.\nI thought it would be automatically installed when I installed Python3. I tried to sudo install it, but it still didn't do anything. What can I do?","AnswerCount":4,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2599,"Q_Id":51334492,"Users Score":-2,"Answer":"You could try brew install pip3. Or check where pip is installed, that might point to Python 3's version.","Q_Score":0,"Tags":"python,python-3.x,macos,pip","A_Id":51334542,"CreationDate":"2018-07-14T01:32:00.000","Title":"Python3 running on Mac but no Pip3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Converting python to C# is an option. Are there any ready-made converters to do this? Or are there any other ways to realize a uwp app from a python code? You help is very much appreciated.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5628,"Q_Id":51335488,"Users Score":0,"Answer":"I think your best bet would be converting, and then learning a little. Based on the difficulty and how many different or new things you need to learn to alter the app, you should maybe just consider learning the language basics and then go from their creating it in C#, You'll gain some skills in another language. Who knows maybe like it more. \nYou could try one of many other converters, to another language that works or even convert to a language to convert. There is a C++ converter of some kind that may be a bit better, and then I guess perhaps you could convert from their with other tools, seriously may work better. More things are out their for C++ than C# and considering the commonalities, I bet a decent converter exists. Maybe convert to C or C++ or even Javascript because they have good conversion tools. With Java Script it would be kind easy to convert and learn a tiny bit to fix if you have a converter to C#.\nOtherwise converter between the two Python and C# isn't a main priority for many people, if anyone at all. Since they are so similar yet the Syantax is so different, it must be hard to create, and usually people stick with one or the other, or learn both because they do a lot of Object Oriented Code. I mean just Syntax needs to be learned. Also the modules mentioned or packages probably wont ever convet to C#. I'm pretty sure they would just need to build the packages from the ground up for C#, witch is possible.","Q_Score":4,"Tags":"c#,python,uwp,converter","A_Id":57502620,"CreationDate":"2018-07-14T05:16:00.000","Title":"How to use python code to create a universal windows platform application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Unity3D has a package for Reinforcement Learning called ML-agents that I am playing with to understand its components. For my project, I am in the situation that I need to write my own logic to set the reward out of Unity3D (not 'addReward' using C# logic, but write a Python code to set the reward out of Unity).\nI wonder if I can use the Python API given by the ML-agents package for using the env observations and update the reward with a custom logic set out of Unity (and send back to Unity)? And where to look for doing so?\nIn other words (example). In the 3DBall example, a reward logic is set in Unity3D as such if the ball stays on the platform gets a positive reward and if it falls from the platform it receives a negative reward. This logic is implemented in Unity3D by using C# and determine the position of the Ball (vector position) compare to the platform. For every action, the agent calls the env.step(action) and get the tuple of (reward, state...). What if I want to write the logic outside Unity? For example, if I want to write a python program that reads the observation (from Unity3D) and update the reward without using the Unity reward logic? Is this possible? I cannot understand where this option is in the Python API of ML-agents.\nAt the moment I am thinking to run an external python program in-between the line where I set the reward in C# in Unity3D, but I wonder if this is overcomplicated and that there is an easier solution.\nAny help would be really appreciated.\nRegards\nGuido","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":464,"Q_Id":51337634,"Users Score":0,"Answer":"According to my Reinforcement Learning understanding, the reward is handled by the environment and the agent just get it together with the next observation. You could say it's part of the observation. \nTherefore the logic which rewards to get when is part of the environment logic, i.e. in case of Unity-ML the environment lives in Unity, so you have to implement the reward function in Unity (C#). \nSo in order to keep the clear separation between environment (Unity) and agent (Python). I think its best to keep the reward logic in Unity\/C# and don't tinker with it in Python.\ntl;dr: I think it's intended that you cannot set the reward via the Python API to keep a clear environment-agent separation.","Q_Score":2,"Tags":"c#,python,unity3d,reinforcement-learning,ml-agent","A_Id":51348285,"CreationDate":"2018-07-14T10:36:00.000","Title":"Reward Logic out of Unity3D in ml-agents package","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have this website that I made in web2py and launched using python anywhere. I am using godaddy to host the domain. \nWhen I go to the website though it is not https and is not trusted. So, I bought the trusted site trustmark from godaddy and they are telling me to add a line of javascript into the code of the website to make it trusted. \nBut, I can't figure out where to put this line of code. What file do I put this code in in web2py to make the entire site https?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":54,"Q_Id":51341005,"Users Score":1,"Answer":"Add the specified <script> tag near the bottom of the \/views\/layout.html file of the web2py app, which will result in it being included in every page that extends that layout (if you serve some pages with a different layout or without extending a layout, then you'll need to separately include the code in those views as well).","Q_Score":0,"Tags":"https,web2py,pythonanywhere,godaddy-api,trusted-sites","A_Id":51341232,"CreationDate":"2018-07-14T15:50:00.000","Title":"How to make a web2py site a trusted site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have created a single page app before with Vue and Vuex for state management and am looking into multi page apps with the django backend framework. I am curious to know if there would be any pros to including vuex state management or would the backend take care of state management in this case?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":900,"Q_Id":51341349,"Users Score":1,"Answer":"Vuex still has use cases, even if you are navigating (and thus clearing the store) between pages.\n\nYou can create and restore a store from localStorage, allowing you to keep a local state between pages. Depending on how much data you try to store in the store this may be bad for performance.\nWhen communicating between components, you usually do this with the prefered method of using props and events. However, when two components do not have a direct relation with each other, passing data through several components is usually a burden. You can either use a vuex store to manage shared data, or use a bus to make that easier.\n\nThat said, you probably only want to add a store when you feel the need to have one. Adding a store is usually trivial.","Q_Score":0,"Tags":"python,django,vue.js,vuex","A_Id":51342050,"CreationDate":"2018-07-14T16:33:00.000","Title":"Would vuex state management be useful in implementing a multi page app with django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use Keras for a CNN and have two types of Inputs: Images of objects, and one or two more parameters describing the object (e.g. weight). How can I train my network with both data sources? Concatenation doesn't seem to work because the inputs have different dimensions. My idea was to concatenate the output of the image analysis and the parameters somehow, before sending it into the dense layers, but I'm not sure how. Or is it possible to merge two classifications in Keras, i.e. classifying the image and the parameter and then merging the classification somehow?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1717,"Q_Id":51341613,"Users Score":1,"Answer":"You can use Concatenation layer to merge two inputs. Make sure you're converting multiple inputs into same shape; you can do this by adding additional Dense layer to either of your inputs, so that you can get equal length end layers. Use those same shape outputs in Concatenation layer.","Q_Score":2,"Tags":"python,tensorflow,keras,concatenation,conv-neural-network","A_Id":51341789,"CreationDate":"2018-07-14T17:06:00.000","Title":"Multiple Inputs for CNN: images and parameters, how to merge","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any Python equivalent of Scala's Case Class? Like automatically generating constructors that assign to fields without writing out boilerplate.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":11592,"Q_Id":51342228,"Users Score":1,"Answer":"The other answers about dataclass are great, but it's worth also mentioning that:\n\nIf you don't include frozen=True, then your data class won't be hashable. So if you want parity with Scala case classes (which automatically define toString, hashcode and equals) then to get hashcode, you will need @dataclass(frozen=True)\neven if you do use frozen=True, if your dataclass contains an unhashable member (like a list), then the dataclass won't be hashable.\nhash(some_data_class_instance) will be equal if the values are equal (and frozen=True)\nFrom a quick empirical test, equality comparisons don't appear to be any faster if your type is hashable. Python is walking the class members to compare equality. So even if your frozen dataclass has all hashable members (e.g. tuples instead of lists), it will still walk the values to compare equality and be very slow.","Q_Score":19,"Tags":"python,scala","A_Id":66616777,"CreationDate":"2018-07-14T18:19:00.000","Title":"Python equivalent of Scala case 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":"In a project, I have e.g. two different packages, How can I use the setup.py to install these two packages in the Google's Colab, so that I can import the packages?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":228758,"Q_Id":51342408,"Users Score":0,"Answer":"Upload setup.py to drive.\nMount the drive.\nGet the path of setup.py.\n!python PATH install.","Q_Score":126,"Tags":"python,pip,jupyter-notebook,google-colaboratory,setup.py","A_Id":58643445,"CreationDate":"2018-07-14T18:42:00.000","Title":"How do I install Python packages in Google's Colab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In a project, I have e.g. two different packages, How can I use the setup.py to install these two packages in the Google's Colab, so that I can import the packages?","AnswerCount":6,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":228758,"Q_Id":51342408,"Users Score":119,"Answer":"You can use !setup.py install to do that. \nColab is just like a Jupyter notebook. Therefore, we can use the ! operator here to install any package in Colab. What ! actually does is, it tells the notebook cell that this line is not a Python code, its a command line script. So, to run any command line script in Colab, just add a ! preceding the line.\nFor example: !pip install tensorflow. This will treat that line (here pip install tensorflow) as a command prompt line and not some Python code. However, if you do this without adding the ! preceding the line, it'll throw up an error saying \"invalid syntax\".\nBut keep in mind that you'll have to upload the setup.py file to your drive before doing this (preferably into the same folder where your notebook is).\nHope this answers your question :)","Q_Score":126,"Tags":"python,pip,jupyter-notebook,google-colaboratory,setup.py","A_Id":51342586,"CreationDate":"2018-07-14T18:42:00.000","Title":"How do I install Python packages in Google's Colab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm clustering data (trying out multiple algorithms) and trying to evaluate the coherence\/integrity of the resulting clusters from each algorithm. I do not have any ground truth labels, which rules out quite a few metrics for analysing the performance. \nSo far, I've been using Silhouette score as well as calinski harabaz score (from sklearn). With these scores, however, I can only compare the integrity of the clustering if my labels produced from an algorithm propose there to be at minimum, 2 clusters - but some of my algorithms propose that one cluster is the most reliable.\nThus, if you don't have any ground truth labels, how do you assess whether the proposed clustering by an algorithm is better than if all of the data was assigned in just one cluster?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1769,"Q_Id":51343116,"Users Score":0,"Answer":"Don't just rely on some heuristic, that someone proposed for a very different problem.\nKey to clustering is to carefully consider the problem that you are working on. What is the proper way of proposing the data? How to scale (or not scale)? How to measure the similarity of two records in a way that it quantifies something meaningful for your domain.\nIt is not about choosing the right algorithm; your task is to do the math that relates your domain problem to what the algorithm does. Don't treat it as a black box. Choosing the approach based on the evaluation step does not work: it is already too late; you probably did some bad decisions already in the preprocessing, used the wrong distance, scaling, and other parameters.","Q_Score":1,"Tags":"python-3.x,machine-learning,scikit-learn,cluster-analysis,silhouette","A_Id":51346452,"CreationDate":"2018-07-14T20:27:00.000","Title":"How to analyse the integrity of clustering with no ground truth labels?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Like if the script I uploaded to AWS has \npyautogui.moveTo(0,0)\nCan it move the mouse of multiple computers at the same time or no?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1273,"Q_Id":51343713,"Users Score":2,"Answer":"I'm the author of PyAutoGUI. PyAutoGUI can only run on your single, local machine. It can't run on AWS or other \"headless\" setups. This might be added as a feature in the future, but it currently isn't on the roadmap. PyAutoGUI relies on having a GUI to interact with.","Q_Score":2,"Tags":"python,amazon-web-services,user-interface,automation,cloud","A_Id":51411719,"CreationDate":"2018-07-14T21:59:00.000","Title":"If I plan to run a python script that uses pyautogui can it do multiple computers at once or only one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install discord.py with voice support into Pythonista on my iPad using StaSh. The problem is that when I enter the command pip install discord.py[voice] like it says to in the documentation, I get an error that says Error: Failed to fetch package release urls. Can anyone help me figure out what the issue is here? Any help is greatly appreciated. Thanks!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":784,"Q_Id":51343961,"Users Score":0,"Answer":"In discord.py docs, it says using this command:\npip install -U discord.py[voice]\ntry that.","Q_Score":3,"Tags":"python,pip,python-3.6,discord.py,pythonista","A_Id":66851297,"CreationDate":"2018-07-14T22:46:00.000","Title":"Discord.py[voice] giving installation error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install discord.py with voice support into Pythonista on my iPad using StaSh. The problem is that when I enter the command pip install discord.py[voice] like it says to in the documentation, I get an error that says Error: Failed to fetch package release urls. Can anyone help me figure out what the issue is here? Any help is greatly appreciated. Thanks!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":784,"Q_Id":51343961,"Users Score":0,"Answer":"Add quotemarks around \"discord.py[VOICE]\" and see if it works","Q_Score":3,"Tags":"python,pip,python-3.6,discord.py,pythonista","A_Id":66851237,"CreationDate":"2018-07-14T22:46:00.000","Title":"Discord.py[voice] giving installation error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a beginner in programming and atom so when try to run my python code written in the atom in terminal I don't know how...i tried installing packages like run-in-terminal,platformio-ide-terminal but I don't know how to use them.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":7068,"Q_Id":51345748,"Users Score":1,"Answer":"I would not try to do it using extensions. I would use the platformio-ide-terminal and just do it from the command line. \nJust type: Python script_name.py and it should run fine.  Be sure you are in the same directory as your python script.","Q_Score":0,"Tags":"python,ubuntu,terminal,atom-editor","A_Id":51351691,"CreationDate":"2018-07-15T06:08:00.000","Title":"how to run python code in atom in a terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm a beginner in programming and atom so when try to run my python code written in the atom in terminal I don't know how...i tried installing packages like run-in-terminal,platformio-ide-terminal but I don't know how to use them.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":7068,"Q_Id":51345748,"Users Score":0,"Answer":"\"python filename.py\" should run your python code. If you wish to specifically run the program using python 3.6 then it would be \"python3.6 filename.py\".","Q_Score":0,"Tags":"python,ubuntu,terminal,atom-editor","A_Id":51345815,"CreationDate":"2018-07-15T06:08:00.000","Title":"how to run python code in atom in a terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm a beginner in programming and atom so when try to run my python code written in the atom in terminal I don't know how...i tried installing packages like run-in-terminal,platformio-ide-terminal but I don't know how to use them.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":7068,"Q_Id":51345748,"Users Score":1,"Answer":"Save your Script as a .py file in a directory.\nOpen the terminal and navigate to the directory containing your script using cd command.\nRun python <filename>.py if you are using python2\nRun python3 <filename.py> if you are using python3","Q_Score":0,"Tags":"python,ubuntu,terminal,atom-editor","A_Id":51345813,"CreationDate":"2018-07-15T06:08:00.000","Title":"how to run python code in atom in a terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to run DBSCAN clustering on about 14M users, each one has 1k data points. Each user is a different clustering case which is completely separate from other users. basically I have many small clustering tasks.\nRunning it on a single machine doesn't work for me, even when paralleling the tasks using python multiprocessing module, as IO and clustering take ages.\nI thought about using Spark to manage a parallel run on a cluster, but decided it might not fit my case, since DBSCAN is not implemented in MLlib and the fact that I don't need to run each clustering task in parallel, but run each one separately. whenever I try to use anything outside of Spark native RDD or Dataframes it obviously has to collect all data to the driver node.\nmy question is weather there is a smarter solution to my problem than simply run many isolated processes on different nodes, when each one will select a subset of the users?\nthanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":893,"Q_Id":51347015,"Users Score":0,"Answer":"Since your users are all independent, this clearly is an embarrassingly parallel problem. You want to run the same task (DBSCAN) millions of times. There are many ways to achieve this. You can probably use Spark (although I would consider using a Java based tool with it, such as ELKI - and you probably need to make sure you parallelize on the users, not within each user), MapReduce, or even Makefiles with locking, if you have a network file system with locking.\nThe key factor is how your data is organized. It makes a huge difference whether you can read in parallel for all workers, or route all your data through a master node (bad). You need to get the data efficiently to the workers, and need to store the clustering results.","Q_Score":1,"Tags":"python,apache-spark,cluster-analysis,dbscan","A_Id":51351211,"CreationDate":"2018-07-15T09:21:00.000","Title":"DBSCAN clustering python - parallel run on multiple clustering tasks","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Actually I have 2 questions. I added google, facebook and twitter sign in to my android app. I use firebase sign in for register and login. After that I will use my own python server. Now, I want to add auto sign in. Namely, after first login, it won't show login page again and it will open other pages automatically. I searched but i didn't find a sample for this structure. How can I do auto sign in with facebook, google, twitter in my android app. And how my server know this login is success and it will give user's data to clients in securely.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":460,"Q_Id":51347328,"Users Score":0,"Answer":"You need to do a web-service call from Android side just after login from firebase, stating in your server that this user has logged in to your app. You can store the access token provided by firebase or you can generate yours on web service call and thereby authenticate user with that token for user specific pages.","Q_Score":1,"Tags":"android,firebase-authentication,facebook-login,google-signin,python-server-pages","A_Id":51347386,"CreationDate":"2018-07-15T10:05:00.000","Title":"Auto sign in with Google, Facebook and Twitter in Android 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":"I am using Visual Studio Code on Linux Sabayon (Gnome) and when I want to save any .py files I have to write the admin password for each one. Is there some settings that may fix it?  \nI know that I can run Visual Studio Code  as admin but that's not the best option for me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":274,"Q_Id":51350907,"Users Score":0,"Answer":"Try putting the saved file in a folder on your desktop. \nSaving files in non-user directories (directories that don't refer to YOUR user) may need admin permissions.\nThis method should work on ALL PC platforms.","Q_Score":0,"Tags":"python,visual-studio-code,vscode-settings","A_Id":51351258,"CreationDate":"2018-07-15T18:11:00.000","Title":"How to save .py files in VSCode on linux and write the admin password only once?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am new to python programming. I am using spyder to run my code. I have generated a very big data in python after 3 hours of computation. Now I want to save my data. One way of doing this is calling the pickle.dump() function, but in order to do this I have to run my program again and this will take another 3 hours. In what way I can store my data when data has already been generated in Spyder?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":135,"Q_Id":51351472,"Users Score":0,"Answer":"What form does the data take? If it's a database in pandas, you can export it to a csv or xlsx","Q_Score":0,"Tags":"python,python-3.x,python-2.7,python-requests,spyder","A_Id":51351532,"CreationDate":"2018-07-15T19:19:00.000","Title":"Storing already generated data in spyder","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with tracking data that tracks tennis players in a local match. The data is provided to me in a json file and every 100 milliseconds (so 10 times a second), it knows where the players on both sides of the court are and where the ball is and provides other match data as well. Using this tracking data, I created a bunch of custom python classes and subclasses to create a \"match\" object and I am loading all of the tracking data into this \"match object.\" Can I create a pandas df holding instances of custom classes\/does this make sense? \n\nBackstory\/thought process (in case my question doesn't make sense which is highly possible...)\nThe first time I implemented this I basically created a \"match\" object where I used python OOP and had the match broken into games, sets, points, players, etc. The players part is a little confusing because due to calculations on my end we created a player object and a new instance of a player every 100 milliseconds (it's hard to wrap your head around because one player is the same throughout the game, but think of it as that player at that exact moment in time). I'm not sure if it makes more sense to change these \"player\" objects instead into rows in a pandas dataframe (they're are a ton of them, think about a 3 hour match) or instead if I can just create a pandas df and have a player be a column. Players make up points and then points make up frames, so if I did change the player objects to a pandas df it would be hard because than I would have a bunch of rows in the dataframe making up a point and then a bunch of points making up a game.. and whatnot\nBecause there is so much tracking data, efficiency considerations are important to me (although I prefer to do things something somewhat slower but not drastically but it helps me ensure\/check all data)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2039,"Q_Id":51353218,"Users Score":8,"Answer":"A DataFrame's columns (Series) can have any of the NumPy dtypes, including object, which can hold arbitrary Python objects.\nDoing so gives up most of the speed and space benefits of using NumPy\/Pandas in the first place. And also the type checking\u2014if you accidentally insert an object that isn't an instance of a match subclass, it will just work. And many convenience features. \nBut you do still get some convenience features, and sometimes that's a more than good enough reason to use Pandas.\nIf the performance isn't acceptable, though, you will have to rethink things. For example, if you flatten the object out into a set of attributes (maybe some of them NaN or N\/A for some of the subclasses) that you can store as a row, especially if some of those attributes are things like floats or ints that you want to do a lot of computation on, you'll get a lot more out of Pandas\u2014but at the cost of losing the OO benefits of your classes, of course.\nOccasionally, it's worth building a hybrid to get the best of both worlds: a DataFrame whose rows hold the storage for your match objects, but then also a match class hierarchy that holds an index or even a single-row DataFrame (a slice from the main one) and provides an OO view onto the same information. But more often, it isn't worth the work to do this, as either almost all of your code ends up being Pandas or almost all of it ends up being OO.\nOne last possibility, if there are huge numbers of these things, would be an ORM that uses a relational database, or an old-school hierarchical database,1 for storage and indexing.\n\n1. In fact, building a hierarchical database out of a bunch of DataFrames and then wrapping it in an object model is basically the same thing as the previous paragraph, but the idea here is that you use stuff that's already built to do all the hard and\/or tedious stuff, not that you build a database just to hide it from yourself.","Q_Score":4,"Tags":"python,pandas,class,oop,dataframe","A_Id":51353269,"CreationDate":"2018-07-16T00:19:00.000","Title":"Can I (\/does it make sense to) create a pandas dataframe to hold custom class instances?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"in the last couple of days I was developing an APP on python IDLE.\nI tried to import the vlc module, when I run it I get this error:\nOSError: dlopen(libvlccore.dylib, 6): image not found\nI installed the module with this command: pip install python-vlc.\nI hope you can help me getting it work!\nThanks in advance!\nZaid Zaim","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1552,"Q_Id":51353360,"Users Score":0,"Answer":"brew install --cask vlc\nIs the latest command, and it works for me!","Q_Score":1,"Tags":"python","A_Id":71231101,"CreationDate":"2018-07-16T00:50:00.000","Title":"Python 2.7.14--- importing vlc module on mac OS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I can show rgba image using pyplot.imshow(image,alpha=0.8).\nI tried to save image using pyplot.savefig(), but image included padding is saved.\nI want to save only image which not have padding.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":505,"Q_Id":51353755,"Users Score":1,"Answer":"can you use: pyplot.savefig() instead of pyplot.saveconfig()?\nif yes, then you can use bbox_inches='tight' to remove or reduce margins and padding around the image:\nsolution one:\npyplot.savefig('test.png', bbox_inches='tight')","Q_Score":2,"Tags":"python,image,matplotlib,rgba","A_Id":51353814,"CreationDate":"2018-07-16T02:12:00.000","Title":"How can save rgba image on pyplot?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm not too sure how I'd explain it in the title, but I want to bind a key in Tkinter and not have it work if the key is being held down.\nFor example, root.bind(\"<space>\", doaction) I'm trying to run doaction only when the spacebar is clicked and not held down. Is there any way to do this? I've tried KeyRelease too.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":133,"Q_Id":51354333,"Users Score":0,"Answer":"There is not much you can do. With respect to keyboard keys, you can bind on <KeyPress> and <KeyRelease>. If you want more, you'll have to set global variables and\/or timers that are set or reset on one of those, and then checked on the other.\nThe problem is that on some systems, keyboards may send a sequence of press\/release pairs while holding a key, while other systems may send just a single press and release. There's no good way to abstract that out since it may happen at the hardware level.","Q_Score":1,"Tags":"python,python-3.x,tkinter,bind","A_Id":51354371,"CreationDate":"2018-07-16T03:47:00.000","Title":"How to bind only keypresses and not when key is held down in Tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying measure the latency from my publisher to my subscriber in an MQTT network. I was hoping to use the on_message() function to measure how long this trip takes but its not clear to me whether this callback comes after the broker receives the message or after the subscriber receives it? \nAlso does anyone else have any other suggestion on how to measure latency across the network?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1991,"Q_Id":51357410,"Users Score":3,"Answer":"I was involved in similar kind of work where I was supposed measure the latency in wireless sensor networks. There are different ways to measure the latencies.\nIf the subscriber and client are synchronized.\n\nFill the payload with the time stamp value at the client and transmit\nthis packet to subscriber.  At the subscriber again take the time\nstamp and take the difference between the time stamp at the\nsubscriber and the timestamp value in the packet.\nThis gives the time taken for the packet to reach subscriber from\nclient.\n\nIf the subscriber and client are not synchronized.\nIn this case measurement of latency is little tricky. Assuming the network is symmetrical.\n\nStart the timer at client before sending the packet to subscriber.\nConfigure subscriber to echo back the message to client. Stop the\ntimer at the client take the difference in clock ticks. This time\nrepresents the round trip time you divide it by two to get one\ndirection latency.","Q_Score":2,"Tags":"python,c++,mqtt,latency,paho","A_Id":51363050,"CreationDate":"2018-07-16T08:18:00.000","Title":"How to measure latency in paho-mqtt network","Data Science and Machine Learning":0,"Database and SQL":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 measure the latency from my publisher to my subscriber in an MQTT network. I was hoping to use the on_message() function to measure how long this trip takes but its not clear to me whether this callback comes after the broker receives the message or after the subscriber receives it? \nAlso does anyone else have any other suggestion on how to measure latency across the network?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1991,"Q_Id":51357410,"Users Score":2,"Answer":"on_message() is called on the subscriber when the message reaches the subscriber.\nOne way to measure latency is to do a loop back publish in the same client e.g.\n\nSetup a client\nSubscribe to a given topic\nPublish a message to the topic and record the current (high resolution) timestamp.\nWhen on_message() is called record the time again\n\nIt is worth pointing out that this sort of test assumes that both publisher\/subscriber will be on similar networks (e.g. not cellular vs gigabit fibre).\nAlso latency will be influenced by the load on the broker and the number of subscribers to a given topic.\nThe other option is to measure latency passively by monitoring the network assuming you can see all the traffic from one location as synchronising clocks across monitoring point is very difficult.","Q_Score":2,"Tags":"python,c++,mqtt,latency,paho","A_Id":51361548,"CreationDate":"2018-07-16T08:18:00.000","Title":"How to measure latency in paho-mqtt network","Data Science and Machine Learning":0,"Database and SQL":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 updated my python version to 3.7 but every time i activate my virtualenv i got the following error message: parameter format not correct - 65001\nAnybody knows what this mean and how to solve this issue?\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6067,"Q_Id":51358202,"Users Score":5,"Answer":"I have had the same Issue. It only happened in Powershell. Windows CMD worked just fine.\nAnd use activate.bat and not activate (without bat).\nI hope this helps.","Q_Score":6,"Tags":"windows,python-venv,python-3.7","A_Id":51374452,"CreationDate":"2018-07-16T09:05:00.000","Title":"Python 3.7 - activate venv error Parameter format not correct 65001 WINDOWS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The accepted way of building manylinux C++ extensions for python is to build them on a docker using Centos 5.5 as the underlying OS. My extensions have a boost library dependency. With care I can use yum to install Boost 1.44 libraries into the dockers used to build python extensions, and this is the version I currently use. However, this restricts me, and although I use current versions of boost on my builds of these extensions for IOS and Windows, I have to be very careful that the code still works the same for the historic boost version 1.44 on Linux. \nWhat is the best maintainable approach to this. How do I upgrade the boost libraries in my docker while maintaining the Centos 5.5 expected for manylinux compatibility? Can I achieve current boost compatibility?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":242,"Q_Id":51358664,"Users Score":1,"Answer":"In such cases, I usually build and install my own version of boost (e.g. 1.63) in a local directory of mine. Now, for linking any applications to the new libraries, I use LD_LIBRARY_PATH to tell the linker which boost libraries to use.","Q_Score":2,"Tags":"c++,docker,boost,centos,python-manylinux","A_Id":51359451,"CreationDate":"2018-07-16T09:32:00.000","Title":"How to have two different versions of boost on CentOS 5.5?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Now i am facing a problem in tensorflow:\nI have a network consisting of 6 convolutional layers (each with batch normalization, and the last convolution is followed by an average pooling to make the output shape Nx1x1xC), aiming to classify one image into a category. Everything is fine during training: \n- training samples are about 150000\n- validation samples during training are about 12000\nI have trained totally 50000 iterations with mini-batch size of 6.\n- During training, the training loss is getting lower always (from about 2.6 at beginning to about 0.3 at iteration 50000), \n- and the validation accuracy is getting higher and saturated after about 40000 iterations (from 60% at beginning to 72% at iteration 50000)\nBUT when I use the learned weights of iteration 50000 on the same validation samples to test, the overall accuracy comes at only about 40%. I have googled if there someone who have faced similar problems. Some said the decay of moving average in batch normalization may be the cause.\nThe default decay in tf.contrib.layers.batch_norm is 0.999. Then I have trained with decay of 0.9, 0.99, 0.999. the result of OA on validation samples during test are 70%, 30%, 39%. Although decay of 0.9 have the best result, it is still lower than the OA on validation during training.\nI am writing to ask if anyone have such similar problems, and do you have any idea what could be the cause?\nbest wishes,","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":517,"Q_Id":51360966,"Users Score":1,"Answer":"I have two suggestions:\n\nIf you aren't using a bool isTraining and passing it to the Batch Normalization layers, do so! this should be a placeholder, and set before each session (in training it will be set to true, in test\/validation to false).\nCheck that during test\/validation you don't shuffle your tet\/validation dataset (there might be some kind of shuffle=True in some import\/management of the batche sof your data).\nThe first one is key, the second shouldn't make that much of a difference, but it ensures exact numberical values each time.","Q_Score":0,"Tags":"python,tensorflow,machine-learning","A_Id":51361104,"CreationDate":"2018-07-16T11:39:00.000","Title":"In tensorflow training and test shows different results","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've searched for working mechanism of tensorflow object detection in google. I've searched how tensorflow train models with dataset. It give me suggestion about how to implement rather than how it works.\nCan anyone explain how dataset are trained in fit into models?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":51362567,"Users Score":0,"Answer":"You can't \"simply\" understand how Tensorflow works without a good background on Artificial Intelligence and Machine Learning.\nI suggest you start working on those topics. Tensorflow will get much easier to understand and to handle after that.","Q_Score":0,"Tags":"python,tensorflow,object-detection,tensorflow-datasets","A_Id":51362949,"CreationDate":"2018-07-16T13:07:00.000","Title":"Brief explanation on tensorflow object detection working mechanism","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say I have a high dimensional dataset which I assume to be well separable by some kind of clustering algorithm. And I run the algorithm and end up with my clusters.\nIs there any sort of way (preferable not \"hacky\" or some kind of heuristic) to explain \"what features and thresholds were important in making members of cluster A (for example) part of cluster A?\"\nI have tried looking at cluster centroids but this gets tedious with a high dimensional dataset. \nI have also tried fitting a decision tree to my clusters and then looking at the tree to determine which decision path most of the members of a given cluster follow. I have also tried fitting an SVM to my clusters and then using LIME on the closest samples to the centroids in order to get an idea of what features were important in classifying near the centroids. \nHowever, both of these latter 2 ways require the use of supervised learning in an unsupervised setting and feel \"hacky\" to me, whereas I'd like something more grounded.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1372,"Q_Id":51364165,"Users Score":-1,"Answer":"Do not treat the clustering algorithm as a black box.\nYes, k-means uses centroids. But most algorithms for high-dimensional data don't (and don't use k-means!). Instead, they will often select some features, projections, subspaces, manifolds, etc. So look at what information the actual clustering algorithm provides!","Q_Score":1,"Tags":"python,scikit-learn,cluster-analysis,k-means","A_Id":51369003,"CreationDate":"2018-07-16T14:30:00.000","Title":"How to explain clustering results?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to completely disable cookies from the Tornado server?  I'm not using them for my public-facing site and I don't want to have the annoying pop-up to get European compliance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":51365906,"Users Score":0,"Answer":"The only time Tornado sets cookies on its own is if you use the xsrf_cookies application setting. If you turn that off and there are no other calls to set_cookie or set_secure_cookie in your application, no cookies will be set. \nXSRF is a serious security issue and you should carefully consider whether you need an alternative solution if you don't use xsrf_cookies. However, if you don't have any other cookies (or equivalent forms of authentication), you're probably OK.","Q_Score":0,"Tags":"python,cookies,tornado","A_Id":51372029,"CreationDate":"2018-07-16T16:01:00.000","Title":"Turn off cookies in Tornado","Data Science and Machine Learning":0,"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":"What's the most elegant way to fetch data from an external API if I want to be faithful to the Single Responsibility Principle? Where\/when exactly should it be made?\nAssuming I've got a POST \/foo endpoint which after being called should somehow trigger a call to the external API and fetch\/save some data from it in my local DB.\nShould I add the call in the view? Or the Model?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":230,"Q_Id":51366456,"Users Score":0,"Answer":"I usually add any external API calls into dedicated services.py module (same level as your models.py that you're planning to save results into or common app if any of the existing are not logically related)\nInside that module you can use class called smth like MyExtarnalService and add all needed methods for fetching, posting, removing etc. just like you would do with drf api view.\nAlso remember to handle exceptions properly (timeouts, connection errors, error response codes) by defining custom error exception classes.","Q_Score":0,"Tags":"python,django,django-rest-framework","A_Id":51407850,"CreationDate":"2018-07-16T16:38:00.000","Title":"fetch data from 3rd party API - Single Responsibility Principle in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using seasonal.seasonal_decompose in python.\nWhat is the window length of moving average trend in seasonal.seasonal_decompose package?\nBased on my results, I think it is 25. But how can I be sure? how can I change this window length?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":186,"Q_Id":51368153,"Users Score":0,"Answer":"I found the answer. The \"freq\" part defines the window of moving average. Still not sure how the program choose the window when we do not declare it.","Q_Score":0,"Tags":"python,moving-average","A_Id":51369183,"CreationDate":"2018-07-16T18:35:00.000","Title":"What is the window length of moving average trend in seasonal.seasonal_decompose package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use sklearn to build an Isolation Forest machine learning program to go through a ton of data. I can only store the past 10 days of data, so I was wondering:\nWhen I use the \"fit\" function on new data that comes in, does it refit the model considering the hyper-parameters from the old data without having had access to that old data anymore? Or is it completely recreating the model?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":295,"Q_Id":51368416,"Users Score":0,"Answer":"In general, only the estimators implementing the partial_fit method are able to do this. Unfortunately, IsolationForest is not one of them.","Q_Score":0,"Tags":"python,python-3.x,machine-learning,scikit-learn,data-fitting","A_Id":51368477,"CreationDate":"2018-07-16T18:53:00.000","Title":"Do you need to store your old data to refit a model in sklearn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a Monitor script that monitors all the threads or a huge python script which has several loggers running, several thread running.\nFrom Monitor.py i could run subprocess and forward the STDOUT which might contain my status of the threads.. but since several loggers are running i am seeing other logging in that.. \nQuestion: How can run the main script as a separate process and get custom messages, thread status without interfering with logging. ( passing PIPE as argument ? )\nMain_Script.py * Runs Several Threads * Each Thread has separate Loggers.\nMonitor.py * Spins up the Main_script.py * Monitors the each of the threads in MainScript.py ( may be obtain other messages from Main_script in the future)\nSo Far, I tried subprocess, process from Multiprocessing.\nSubprocess lets me start the Main_script and forward the stdout back to monitor but I see the logging of threads coming in through the same STDOUT. I am using the \u201cimport logging \u201c Library to log the data from each threads to separate files.\nI tried \u201cprocess\u201d from Multiprocessing. I had to call the main function of the main_script.py as a process and send a PIPE argument to it from monitor.py. Now I can\u2019t see the Main_script.py as a separate process when I run top command.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1713,"Q_Id":51369002,"Users Score":1,"Answer":"Normally, you want to change the child process to work like a typical Unix userland tool: the logging and other side-band information goes to stderr (or to a file, or syslog, etc.), and only the actual output goes to stdout.\nThen, the problem is easy: just capture stdout to a PIPE that you process, and either capture stderr to a different PIPE, or pass it through to real stderr.\n\nIf that's not appropriate for some reason, you need to come up with some other mechanism for IPC: Unix or Windows named pipes, anonymous pipes that you pass by leaking the file descriptor across the fork\/exec and then pass the fd as an argument, Unix-domain sockets, TCP or UDP localhost sockets, a higher-level protocol like a web service on top of TCP sockets, mmapped files, anonymous mmaps or pipes that you pass between processes via a Unix-domain socket or Windows API calls, \u2026\nAs you can see, there are a huge number of options. Without knowing anything about your problem other than that you want \"custom messages\", it's impossible to tell you which one you want.\nWhile we're at it: If you can rewrite your code around multiprocessing rather than subprocess, there are nice high-level abstractions built in to that module. For example, you can use a Queue that automatically manages synchronization and blocking, and also manages pickling\/unpickling so you can just pass any (picklable) object rather than having to worry about serializing to text and parsing the text. Or you can create shared memory holding arrays of int32 objects, or NumPy arrays, or arbitrary structures that you define with ctypes. And so on. Of course you could build the same abstractions yourself, without needing to use multiprocessing, but it's a lot easier when they're there out of the box.\n\nFinally, while your question is tagged ipc and pipe, and titled \"Interprocess Communication\", your description refers to threads, not processes. If you actually are using a bunch of threads in a single process, you don't need any of this.\nYou can just stick your results on a queue.Queue, or store them in a list or deque with a Lock around it, or pass in a callback to be called with each new result, or use a higher-level abstraction like concurrent.futures.ThreadPoolExecutor and return a Future object or an iterator of Futures, etc.","Q_Score":0,"Tags":"python,pipe,ipc","A_Id":51369154,"CreationDate":"2018-07-16T19:36:00.000","Title":"Interprocess Communication between two python scripts without STDOUT","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am developing an application (Python 3.x) in which I need to collect the first 13,000 results of a CSE query using one search keyword (from result index 1 to 13,000). For a free version of CSE JSON API (I have tried it), I can only get the first 10 results per query or 100 results per day (by repeating the same query while incrementing the index) otherwise it gives an error (HttpError 400.....returned Invalid Value) when the result index exceeds 100. Is there any option (paid\/free) that I can deploy to achieve the objective?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":51369427,"Users Score":0,"Answer":"Custom Search JSON API is limited to a max depth of 100 results per query, so you'll need to find a different API or devise some solution to modify the query to divide up the result set into smaller parts","Q_Score":0,"Tags":"python-3.x,google-search,google-custom-search,google-search-api","A_Id":51387763,"CreationDate":"2018-07-16T20:10:00.000","Title":"Extracting the first 13,000 results of a search query with Custom Search Engine JSON API","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I Have that code:\n\n    class Welcome(object):\n        MyHouse='Earth'\n        def say(self, what):\n            print(what, self.MyHouse)\n\n    welcome = Welcome()\n\n    Living = ['World', 'Planet', welcome.MyHouse]\n\n    MyChoice = list(map(lambda choice : setattr(welcome, 'MyHouse', choice), Living))\n    print(''.join(str(MyChoice) for MyChoice in MyChoice))\n    getattr(welcome, 'say')('Hello')\n\nwith this code , I want to use setattr() to change the MyHouse variable according to the strings contained in the Living list, but when I see the results I only get None objects ?, why this and how can I fix it, it would be because setattr does not give output ?.\n\n    print(MyChoice) \n    Output: [None, None, None]","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":51369440,"Users Score":0,"Answer":"so, after a coffee I managed to solve,\nI just needed to use a for loop\nalthough I do not know the exact reason why this worked and would like an explanation, I simply thought that the map() would eliminate the need to a for loop.\nHere is the code:\n\n    class Welcome(object):\n        MyHouse='Earth'\n        def say(self, what):\n            print(what, self.MyHouse)\n\n    welcome = Welcome()\n\n    Living = ['World', 'Planet', welcome.MyHouse]\n\n    MyChoice = map(lambda choice : setattr(welcome, 'MyHouse', choice), Living)\n    for i in MyChoice:\n        getattr(welcome, 'say')('Hello')\n\n\nThat was a useless code , if i need a for loop why i am using lambda and map.","Q_Score":0,"Tags":"python,function,oop,lambda","A_Id":51383959,"CreationDate":"2018-07-16T20:11:00.000","Title":"Python, map with lambda returns only None Objects on my list()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know the equation\/algorithm\/theorem used by MATLAB's 'box' interpolation kernel in the imresize function? Or (even better) know a numpy equivelant?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":806,"Q_Id":51369489,"Users Score":0,"Answer":"A \"box\" kernel is an averaging kernel with uniform weights. If it is an interpolation kernel, then it corresponds to nearest neighbor interpolation (it always takes the average of one input sample).\nA bit of theory: an interpolating kernel is one that has a value of 1 at the origin, and a value of 0 at integer distances from the origin. In between it can do different things. Thus, to make from \"box\" an interpolating kernel, we'd make its width somewhere in between infinitesimally thin and just under 2 sample spacings. That makes it fit the definition of an interpolating kernel. However, if it is thinner than 1 sample spacing, it will generate an output of 0 for some displacements -- not desirable. And if it is wider than 1 sample spacing, there will be displacements where the output is the addition of two input samples, twice as large as it should be -- not desirable either. Thus, making it exactly 1 sample spacing wide is the only useful width here. With this width, at any displacement it always covers exactly one input sample -- hence it does linear interpolation.","Q_Score":3,"Tags":"python,matlab,numpy,interpolation,image-resizing","A_Id":51370046,"CreationDate":"2018-07-16T20:14:00.000","Title":"What Is Matlab's 'box' Interpolation Kernel","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know the equation\/algorithm\/theorem used by MATLAB's 'box' interpolation kernel in the imresize function? Or (even better) know a numpy equivelant?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":806,"Q_Id":51369489,"Users Score":2,"Answer":"box interpolation is simply averaging pixels within the specified window size.\nYou may check the matlab function smooth3 etc for detail.","Q_Score":3,"Tags":"python,matlab,numpy,interpolation,image-resizing","A_Id":51369992,"CreationDate":"2018-07-16T20:14:00.000","Title":"What Is Matlab's 'box' Interpolation Kernel","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Pytorch and I am confused about the difference between nn.Parameter  and autograd.Variable. I know that the former one is the subclass of Variable and has the gradient. But I really don't understand why we introduce Parameter and when we should use it?\n\nSUMMARY:\nThanks for the explanation of iacolippo, i finally understand the difference between parameter and variable. In a summary, variable in pytorch is NOT same as in  the variable in tensorflow, the former one is not attach to the model's trainable parameters while the later one will. Attaching to the model means that using model.parameters() will return the certain parameter to you, which is useful in training phase to specify the variable needed to train. The 'variable' is more helpful as a cache in some network.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5351,"Q_Id":51373919,"Users Score":5,"Answer":"From the documentation:\nParameters are Tensor subclasses, that have a very special property when used with Modules - when they\u2019re assigned as Module attributes they are automatically added to the list of its parameters, and will appear e.g. in parameters() iterator. Assigning a Tensor doesn\u2019t have such effect. This is because one might want to cache some temporary state, like last hidden state of the RNN, in the model. If there was no such class as Parameter, these temporaries would get registered too.\nThink for example when you initialize an optimizer:\noptim.SGD(model.parameters(), lr=1e-3)\nThe optimizer will update only registered Parameters of the model.\nVariables are still present in Pytorch 0.4 but they are deprecated. From the docs:\nThe Variable API has been deprecated: Variables are no longer necessary to use autograd with tensors. Autograd automatically supports Tensors with requires_grad set to True.\n\nPytorch pre-0.4\nIn Pytorch before version 0.4 one needed to wrap a Tensor in a torch.autograd.Variable in order to keep track of the operations applied to it and perform differentiation. From the docs of Variable in 0.3:\nWraps a tensor and records the operations applied to it.\nVariable is a thin wrapper around a Tensor object, that also holds the gradient w.r.t. to it, and a reference to a function that created it. This reference allows retracing the whole chain of operations that created the data. If the Variable has been created by the user, its grad_fn will be None and we call such objects leaf Variables.\nSince autograd only supports scalar valued function differentiation, grad size always matches the data size. Also, grad is normally only allocated for leaf variables, and will be always zero otherwise.\nThe difference wrt Parameter was more or less the same. From the docs of Parameters in 0.3:\nA kind of Variable that is to be considered a module parameter.\nParameters are Variable subclasses, that have a very special property when used with Modules - when they\u2019re assigned as Module attributes they are automatically added to the list of its parameters, and will appear e.g. in parameters() iterator. Assigning a Variable doesn\u2019t have such effect. This is because one might want to cache some temporary state, like last hidden state of the RNN, in the model. If there was no such class as Parameter, these temporaries would get registered too.\nAnother difference is that parameters can\u2019t be volatile and that they require gradient by default.","Q_Score":5,"Tags":"python,neural-network,deep-learning,pytorch","A_Id":51383465,"CreationDate":"2018-07-17T05:38:00.000","Title":"The purpose of introducing nn.Parameter in pytorch","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to retrieve k smallest elements from a list in python. But I want to achieve this with less than O(n log n)(that is, without sorting the list) complexity. Is there any way to do so in Python. If yes please let me know. Thanks in advance.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":257,"Q_Id":51378378,"Users Score":1,"Answer":"Use the heapq.nsmallest, it performs with partial heap-sort","Q_Score":1,"Tags":"python-3.x,list,time-complexity","A_Id":51379069,"CreationDate":"2018-07-17T09:55:00.000","Title":"Is there any way to get the k smallest elements from a list without sorting it in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to retrieve k smallest elements from a list in python. But I want to achieve this with less than O(n log n)(that is, without sorting the list) complexity. Is there any way to do so in Python. If yes please let me know. Thanks in advance.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":257,"Q_Id":51378378,"Users Score":2,"Answer":"I can think of a few ways sorting\/non-sorting solution for this problem:\n\nRank Selection Algorithm - like quicksort, we can find pivot rank then decide on whether to go left or right, O(N) time\nBuild a Min Heap O(N), extract k times - O(N + kLogN) time\nPriority Queue - like max heap (remove biggest element if there is a new smaller), but instead we can loop through the entire array, build a heap of k size - O(N + NlogK)\nBubble Sort - bubble smallest few element upwards - O(k*N)","Q_Score":1,"Tags":"python-3.x,list,time-complexity","A_Id":51383540,"CreationDate":"2018-07-17T09:55:00.000","Title":"Is there any way to get the k smallest elements from a list without sorting it in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have model saved in graph (.pb file). But now the model is inaccurate and I would like to develop it. I have pictures of additional data to learn, but I don't if it's possible or if it's how to do it? The result must be the modified of new data pb graph.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1718,"Q_Id":51379506,"Users Score":3,"Answer":"It's a good question. Actually it would be nice, if someone could explain how to do this. But in addition i can say you, that it would come to \"catastrophic forgetting\", so it wouldn't work out. You had to train all your data again.\nBut anyway, i also would like to know that espacially for ssd, just for test reasons.","Q_Score":2,"Tags":"python,tensorflow","A_Id":51383561,"CreationDate":"2018-07-17T10:48:00.000","Title":"How to retrain model in graph (.pb)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm Junior Django Dev. Got my first project. Doing quite well but senior dev that teaches me went on vacations....\nI have a Task in my company to create a function that will remind all people in specyfic Group, 5 days before event by sending mail.\nThere is a TournamentModel that contains a tournament_start_date for instance '10.08.2018'.\nPlayer can join tournament, when he does he joins django group \"Registered\".\nI have to create a function (job?) that will check tournament_start_date and if tournament begins in 5 days, this function will send emails to all people in \"Registered\" Group... automatically.\nHow can I do this? What should I use? How to run it and it will automatically check? I'm learning python\/django for few months... but I meet jobs fot the first time ;\/\nI will appreciate any help.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2515,"Q_Id":51379567,"Users Score":1,"Answer":"You can set this  mail send function as cron job\u3002You can schedule it by crontab or Celery if Your team has used it.","Q_Score":2,"Tags":"python,django,task,jobs","A_Id":51380304,"CreationDate":"2018-07-17T10:52:00.000","Title":"Django - how to send mail 5 days before event?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was wondering what is the difference between ComboBox and OptionMenu widgets in python tkinter. It seems that they allow to do the same thing, but Combobox is only available in ttk. \nDoes anyone could explain the difference?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2554,"Q_Id":51382099,"Users Score":8,"Answer":"The OptionMenu is a button with a menu attached. The menu typically grows in height until it reaches the edge of the screen. The choices are fixed, and the user can't type in their own value.\nA Combobox is in effect an Entry widget with a dropdown listbox. The user has the ability (if properly configured) to type into the combobox or pick from the dropdown list. The dropdown list is typically constrained to a handful of rows, with a scrollbar when the list gets to long to fit.\nThe Combobox is also a bit easier to add and remove items after the widget has been created. The OptionMenu was designed to have a static number of items that are set when the widget is created.","Q_Score":5,"Tags":"python,tkinter","A_Id":51382392,"CreationDate":"2018-07-17T13:02:00.000","Title":"Differences between OtpionMenu and ComboBox in tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im having problems installing modules to python, I don't really understand anything. pip3 came preinstalled to python 3.7, so I used this to try and install pandas, this is what terminal said. Have I installed pandas or not?\nUpdate: Nope nothing is installed","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":51382254,"Users Score":1,"Answer":"Try typing import pandas in the interactive python prompt. If you get no errors, it installed successfully.","Q_Score":0,"Tags":"python","A_Id":51382279,"CreationDate":"2018-07-17T13:10:00.000","Title":"Have I installed pandas for python or not (Mac)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I know whether or not I should use a sparse or dense representation in PySpark? I understand the differences between them (sparse saves memory by only storing the non-zero indices and values), but performance-wise, are there any general heuristics that describe when to use sparse vectors over dense ones?\nIs there a general \"cutoff\" dimension and percent of 0 values beyond which it is generally better to use sparse vectors? If not, how should I go about making the decision? Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1280,"Q_Id":51385657,"Users Score":2,"Answer":"The thing to remember is that pyspark.ml.linalg.Vector and pyspark.mllib.linalg.Vector are just compatibility layer between Python and Java API. There are not full featured or optimized linear algebra utilities and you shouldn't use them as such. The available operations are either not designed for performance or just convert to standard NumPy array under the covers.\nWhen used with other ml \/ mllib tools there will be serialized and converted to Java equivalents so Python representation performance is mostly inconsequential. \nThis means that the biggest real concern is storage and a simple rule of thumb is:\n\nIf on average half of the entries is zero it is better to use SparseVector.\nOtherwise it is better to use DenseVector.","Q_Score":4,"Tags":"python,apache-spark,machine-learning,pyspark,sparse-matrix","A_Id":51386373,"CreationDate":"2018-07-17T15:52:00.000","Title":"Sparse vs. Dense Vectors PySpark","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Windows routine that uses the Python Library.  I started out with 3.6.5 and a static library.  Got it to work.  Moved to a .dll Python library.  Also works.  Moved to 3.7.  Does NOT work.  It hangs when I attempt to close the embedded Python with a call to PyGILState_Ensure() and then Py_Finalize().  It hangs on the call to PyGILState_Ensure().\nSo I backed off a bit and went with Python 3.6.6.  This also works.  Same code, just a different library.  Has anyone else noticed a change in behavior of the GIL stuff for Python 3.7?  In the documentation, they mentioned they made some changes with the GIL.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":262,"Q_Id":51386997,"Users Score":1,"Answer":"If you are using python 3.6 and below you need to call PyEval_InitThreads() You no longer have to do this in python 3.7, Py_initialize() does it for you. Could be your problem?","Q_Score":2,"Tags":"python,python-3.x,python-3.6,gil,python-3.7","A_Id":51390341,"CreationDate":"2018-07-17T17:15:00.000","Title":"Python 3.7 and PyGILState_Ensure() (Windows)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Pillow to do some image operations and want to count how many unique colors are there in a PNG or JPG image file. I can do it easily with mode \"P\" images that have a small number of colors, but it won't work for RGB or RGBA images. Reading through the docs of Pillow, it seems that Image.getcolors() returns None if there are more than 256 colors. \nWhat is the best way to do it? Can we do it using Pillow? I am targeting pure Python + Pillow, but I can optionally include numpy on my list of dependencies, it if it helps.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2246,"Q_Id":51387662,"Users Score":0,"Answer":"Is it possible to list the pixel RGBs and scan through that? As John Anderson said, you can use Image.getcolors to get that. But to get the number of unique variables, you can convert it to a set, which removes duplicates, then get the length of that, with len(set(list)).","Q_Score":3,"Tags":"python,png,jpeg,python-imaging-library,pillow","A_Id":51388163,"CreationDate":"2018-07-17T17:58:00.000","Title":"Using Python and Pillow, how can we count the number of unique colors in a PNG or JPG image?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have Anaconda 4.3.1 installed on our hosts and recently we have installed several packages for data science use. All the imports were fine except for gensim.\nI am getting \"Intel MKL FATAL ERROR: Cannot load libmkl_avx2.so or libmkl_def.so.\" and getting out of python shell.\nIt sounds like a duplicate but the weird part is, when I import tensorflow or seaborn before importing gensim, I am not getting that error and gensim is being imported. I would also like to know if there is any dependency between these packages. And I do have the latest version of numpy which is 1.14.5. I have looked at various solutions proposed about installing few packages and uninstalling few. I would like to know the reason why we should be doing it before actually doing it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":732,"Q_Id":51388707,"Users Score":2,"Answer":"Here is my theory on your question:\nIs there any dependency between gensim, tensoflow, seaborn and such packages?\n When you try to install these packages one by one using conda, you might have already seen conda prompting that some of the dependencies will be DOWNGRADED\/UPDATED\/INSTALLED. Hence there is dependency between the dependencies of these packages.\nWhy import error is thrown only on certain cases?\nLooks like a dependency issue. When you try to import gensim, it tries to load certain lib files, which its not able to find. However, when tensorflow or seaborn is imported the mentioned lib files might have already loaded, hence importing gensim did not show an error.\nWhy installing few packages and uninstalling few, help to solve the problem?\nThis might help to have the correct dependencies for the packages to work properly.\nHaving said that, I tried to recreate the error that you got, however gensim is importing fine for me. If you could give the result of \"conda list\", will try to recreate the problem and would be able to give a better insight.","Q_Score":0,"Tags":"python,tensorflow,anaconda,seaborn,gensim","A_Id":52216299,"CreationDate":"2018-07-17T19:14:00.000","Title":"Intel MKL FATAL ERROR: while trying to import gensim package","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What I understood in Django models field's attributes is  \n\nauto_now - updates the value of field to current time and date every time the Model.save() is called.\nauto_now_add - updates the value with the time and date of creation of record.\n\nMy question is what if a filed in model contains both the auto_now and auto_now_add set to True? What happens in that case?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":32637,"Q_Id":51389042,"Users Score":0,"Answer":"If a filed in a model contains both the auto_now and auto_now_add set to True will result in an error like this:\nERRORS:\nappname.Model.field_name: (fields.Efield_number) The options auto_now, auto_now_add, and default are mutually exclusive. Only one of these options may be present.","Q_Score":62,"Tags":"python,django,django-models,django-forms,django-templates","A_Id":69910393,"CreationDate":"2018-07-17T19:38:00.000","Title":"Difference between auto_now and auto_now_add","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What I understood in Django models field's attributes is  \n\nauto_now - updates the value of field to current time and date every time the Model.save() is called.\nauto_now_add - updates the value with the time and date of creation of record.\n\nMy question is what if a filed in model contains both the auto_now and auto_now_add set to True? What happens in that case?","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":32637,"Q_Id":51389042,"Users Score":3,"Answer":"As Official Django documentation says -\nauto_now, auto_now_add and default are mutually exclusive and will result in an error if used together","Q_Score":62,"Tags":"python,django,django-models,django-forms,django-templates","A_Id":64321206,"CreationDate":"2018-07-17T19:38:00.000","Title":"Difference between auto_now and auto_now_add","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What I understood in Django models field's attributes is  \n\nauto_now - updates the value of field to current time and date every time the Model.save() is called.\nauto_now_add - updates the value with the time and date of creation of record.\n\nMy question is what if a filed in model contains both the auto_now and auto_now_add set to True? What happens in that case?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":32637,"Q_Id":51389042,"Users Score":8,"Answer":"These fields are built into Django for expressly this purpose \u2014 auto_now fields are updated to the current timestamp every time an object is saved and are therefore perfect for tracking when an object was last modified, while an auto_now_add field is saved as the current timestamp when a row is first added to the database and is therefore perfect for tracking when it was created.","Q_Score":62,"Tags":"python,django,django-models,django-forms,django-templates","A_Id":66179103,"CreationDate":"2018-07-17T19:38:00.000","Title":"Difference between auto_now and auto_now_add","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Suppose I use DataFrame.ix in some code.\nDoes the fact that it's deprecated mean that at some point in the future, I'm going to update pandas, and then a little bit later, the stuff using that code will mysteriously start to break because they decided that finally, they were going to actually remove ix?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":646,"Q_Id":51390464,"Users Score":1,"Answer":"Yes, deprecated here means that the attribute or method has been removed from the newer versions. Hence, it is advised to avoid them in your code to avoid future issues.","Q_Score":3,"Tags":"python,pandas,deprecated","A_Id":51390517,"CreationDate":"2018-07-17T21:30:00.000","Title":"What does it mean for DataFrame.ix to be deprecated?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I use DataFrame.ix in some code.\nDoes the fact that it's deprecated mean that at some point in the future, I'm going to update pandas, and then a little bit later, the stuff using that code will mysteriously start to break because they decided that finally, they were going to actually remove ix?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":646,"Q_Id":51390464,"Users Score":6,"Answer":"That's the basic idea of deprecation. The library's maintainers are letting you know now that they plan to stop supporting ix (e.g., fixing bugs in it), and may very well remove it in the near future. As long as it's deprecated, you have a window of opportunity to change your code to use other alternatives (such as loc and iloc), on your own terms, before you're forced to do so when pandas breaks \"under your feet\".","Q_Score":3,"Tags":"python,pandas,deprecated","A_Id":51390526,"CreationDate":"2018-07-17T21:30:00.000","Title":"What does it mean for DataFrame.ix to be deprecated?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way I can use the deap library inside grasshopper's Python node \nI want to run a genetic algorithm but the fitness function is to be calculated by grasshopper (only the fitness function, all the other things are to be taken of by deap inside the python node)\ncan it be done? \nI am having problem with \n\nimporting the deap library in grasshopper's Python interface(I think I will be able to solve it by copying the files manually from Python path)\n(major problem) grashopper doesn't allow closed loops so I cant seem to find a way to feed the fitness back into the Python node with the main code","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":51391285,"Users Score":0,"Answer":"couldnt get it to work, had to make do with the grasshopper pluggins \nthe problem was that you can only install iron python libraries for grasshopper","Q_Score":1,"Tags":"python-3.x,python-2.7,rhino,deap,grasshopper","A_Id":57784547,"CreationDate":"2018-07-17T22:58:00.000","Title":"Is there a way to use the deap library in grasshopper","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I ran a program using the python idle. \nNow, it process stopped and it appeared to be hanged.\nFrom Task Manager, there is no CPU usage.\nI pressed Control+C but cannot stop the process and save the result.\nWhat should I do?\nThank you very much.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":468,"Q_Id":51392478,"Users Score":1,"Answer":"If Interrupt, cntl-C, does not top execution after possibly a few presses and a wait of at least a few seconds, there is probably no way to access results.  One will have to kill the process (and wipe the memory).  If Python is running in a console, close the window.  In IDLE, Shell => Restart Shell closes the execution process but leaves the GUI process running so you can try again without restarting IDLE.","Q_Score":0,"Tags":"python-idle","A_Id":51412195,"CreationDate":"2018-07-18T01:56:00.000","Title":"How to stop python idle editor?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to execute a python script in ionic as we execute python script in php\nIs there any way of doing that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":735,"Q_Id":51393759,"Users Score":1,"Answer":"As far as I know, python scripts are not executed in Ionic. By writing python code we can though, access services which are written in Python by writing the API call from 'providers' in ionic.","Q_Score":1,"Tags":"php,python,python-3.x,ionic-framework,ionic3","A_Id":51393804,"CreationDate":"2018-07-18T04:48:00.000","Title":"How to execute python script in ionic framework similarly it execute in a php 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 wanted to export the raw images produced using vpython on my HDD. How can I do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":770,"Q_Id":51395032,"Users Score":2,"Answer":"A simple answer is to use a screen capture tool, which most operating systems offer.\nAs of this week (November 2018) there's a new option in GlowScript VPython, scene.capture(filename), which will also be available in the next release of VPython 7.\nHere's the documentation:\ncapture(filename) Sends to your Download folder a png screen shot of the canvas. If filename is the string \"boxes\" or \"boxes.png\" the file will be named \"boxes.png\". (Not yet available in VPython 7.)","Q_Score":1,"Tags":"python-3.x,graphics,export,vpython","A_Id":53325541,"CreationDate":"2018-07-18T06:32:00.000","Title":"How can I export vpython pictures","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently I am researching about viable approaches to identify a certain object with the image processing techniques. However I ams struggling finding them. For example, I have a CNN capable of detecting certain objects, like a person, then I can track the person as well. However, my issue is that I want the identify the detected and tracked person like saving its credentials and giving an id. I do not want something like who is he\/she. Just giving an id in that manner.\nAny help\/resource will be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":331,"Q_Id":51395132,"Users Score":2,"Answer":"Create a database, Store the credentials you needed for later use e.g object type and some usable specifications, by giving them some unique ID. CNN already recognized the object so just need to store it in database and later on you can perform more processing on the generated data. Simple solution is that to the problem you are explaining.\nOkay I got your problem that you want to identify what kind of object is being tracked because cnn is only tracking not identifying. For that purpose you have to train your CNN on some specific features and give them some identity like objectA has [x,y,z] features. Then CNN will help you in finding the identity of the object.\nYou can use openCv to do this as well, store some features of some specific objects, then use some distance matching technique to match the live feature with stored features. \nThanks.","Q_Score":0,"Tags":"python,opencv,image-processing,computer-vision","A_Id":51396146,"CreationDate":"2018-07-18T06:39:00.000","Title":"Object Identification Using OpenCV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want get the data from my elasticsearch node for my code, i am using elasticsearch-dsl library to query the data from elasticsearch. Now i want the data to be sorted according to the \"@timestamp\" which can done using sort api. But the data that i am getting back has more than 10000 documents. I cannot use scan with sort to get large data as with sort doesn't work with scan in elasticsearch-dsl. Is there a way to use scroll api in elasticsearch-dsl or any other way to get more than 10000 document sorted with \"@timestamp\".","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1242,"Q_Id":51396258,"Users Score":2,"Answer":"scroll does work with sort, you just need to call it with preserve_order: s.params(preserve_order=True).scan()\nHope this helps!","Q_Score":1,"Tags":"python-2.7,elasticsearch,elasticsearch-dsl,elasticsearch-dsl-py","A_Id":51428739,"CreationDate":"2018-07-18T07:39:00.000","Title":"Get result sorted by \"@timestamp\" in python using elasticsearch-dsl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a working app with TFlite using tensorflow for poets. It works with a labels.txt and graph.lite pair files. I have downloaded another model in .tflite file format and wanted to use in my application. I wanted to ask what are the differences between .lite and .tflite files and are there any ways to convert tflite format to lite?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":477,"Q_Id":51396671,"Users Score":3,"Answer":"There is no difference in \".lite\" and \".tflite\" format (as long as they can be correctly consumed by Tensonflow Lite). And there is no need to convert them.","Q_Score":0,"Tags":"python,tensorflow","A_Id":51565917,"CreationDate":"2018-07-18T08:03:00.000","Title":"Convert TFLite to Lite","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was using python to insert some data to elasticsearch, the elasticsearch version is > 6.0. the code can be seen as:\nfrom datetime import datetime\nfrom elasticsearch import Elasticsearch\nes = Elasticsearch( \"localhost:9200\" ) \nfrom elasticsearch import TransportError\ndata = {\n    \"http_code\" : \"404\",\n    \"count\" : \"10\"\n}\ntry:\n    es.index(index=\"http_code\", doc_type=\"error_code\",body=data)\nexcept TransportError as e:\n    print(e.info)\nbut we will have problem like:{u'status': 406, u'error': u'Content-Type header [] is not supported'}\nI have searched that in the new elastic search version it need to set the header,  for example in the command line we can use:\n\" curl -XPUT 'localhost:9200\/customer\/external\/1?pretty' -d '{ \"name\": \"John Doe\" }'\nbut in python how can we set the header? anyone knows about that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":213,"Q_Id":51398525,"Users Score":0,"Answer":"TRY THIS:\npython -m pip install --upgrade 'elasticsearch>=7.16,<8'\nit should resolve your problem.","Q_Score":1,"Tags":"python,elasticsearch","A_Id":72467426,"CreationDate":"2018-07-18T09:33:00.000","Title":"elasticsearch.index error with header not supported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"It really bugs (ha.) me that PyCharm executes scripts ever so slightly differently than plain command line execution. It makes project and package configuration hard for a relative newbie like me.\nProblem: Every time a script is run, either normally or in the Python console (Run > Edit conf.) the script folder and the project root are automagically appended to sys.path. I'd expect either one, but not both.\nSo, is there a way to disable or otherwise configure this appending? I'd like to do it without manipulating the path in the beginning of every executable script, but if there's a way to use a startup script or a run script of some sort, that'd be fine.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":300,"Q_Id":51401774,"Users Score":4,"Answer":"Go to \nRun->Edit Configurations\nThere are, among other things, two checkboxes:\n\nAdd content root to PYTHONPATH\nAdd source root to PYTHONPATH\n\nthat should control the described behaviour of adding the directories to the path.","Q_Score":2,"Tags":"python,path,pycharm,pythonpath","A_Id":51401872,"CreationDate":"2018-07-18T12:15:00.000","Title":"Prevent PyCharm from extending sys.path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was trying to add some folders to my path, so I added a .pth file to my site-packages folder. When it didn't work (I printed sys.path and it doesn't contain any of the paths I wrote in the file) , I tried to find the .pth file from within python and I noticed that the name of one of the folders in the path contains a . in it.\nCould that be the reason why the .pth file wasn't processed? or any other suggestions why Its not working?\nI don't think I can change the folder name, it was created when I created a virtual environment, and I think that if I'll change it, it might mess up other things.\nThe path to the .pth is - home\/pomicelltohar\/venv\/3_6\/lib\/python3.6\/site-packages\/pomicell.pth\nsys.path is \n['', '\/home\/pomicelltohar\/venv\/3_6\/lib\/python36.zip', '\/home\/pomicelltohar\/venv\/3_6\/lib\/python3.6', '\/home\/pomicelltohar\/venv\/3_6\/lib\/python3.6\/lib-dynload', '\/home\/pomicelltohar\/anaconda3\/lib\/python3.6', '\/home\/pomicelltohar\/venv\/3_6\/lib\/python3.6\/site-packages']","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":823,"Q_Id":51403479,"Users Score":1,"Answer":"The problem was that I wrote the paths in the .pth file with ~\/ instead of using the full path \/home\/pomicelltohar","Q_Score":0,"Tags":"python,path,pythonpath,pth","A_Id":51476127,"CreationDate":"2018-07-18T13:37:00.000","Title":"pth file is not processed","Data 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":"recently installed PyCharm edu 2018 and there is no Terminal option at all. There is Python console in View\/Tool Windows as well as Event Log etc. But no terminal.\nMy MacBook had Python 2.7 by default, i also installed 3.7 and then installed pycharm. OS 10.13.1\nThere is no Terminal in PyCharm\/Preferences as well. Any way to get it? Is there any difference between EDU edition and community edition?\nIn Windows, Community edition 2018 is having the terminal option.\nThanks a lot.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":51403736,"Users Score":0,"Answer":"In the top menu bar, go to \nView -> Tool Windows -> Terminal or on enter Alt + F12","Q_Score":2,"Tags":"python,macos,terminal,pycharm","A_Id":51408212,"CreationDate":"2018-07-18T13:48:00.000","Title":"PyCharm 2018 for Mac - there is no terminal option at all","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"recently installed PyCharm edu 2018 and there is no Terminal option at all. There is Python console in View\/Tool Windows as well as Event Log etc. But no terminal.\nMy MacBook had Python 2.7 by default, i also installed 3.7 and then installed pycharm. OS 10.13.1\nThere is no Terminal in PyCharm\/Preferences as well. Any way to get it? Is there any difference between EDU edition and community edition?\nIn Windows, Community edition 2018 is having the terminal option.\nThanks a lot.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":51403736,"Users Score":0,"Answer":"That is correct PyCharm Edu does not have a terminal in Windows either. Only PyCharm Community has a terminal option. I did a lot of research and did not find any option to get a terminal for Edu.","Q_Score":2,"Tags":"python,macos,terminal,pycharm","A_Id":51413899,"CreationDate":"2018-07-18T13:48:00.000","Title":"PyCharm 2018 for Mac - there is no terminal option at all","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have downloaded pyOpt from its website and installed it on python in ubuntu, using the instructions on the website. \nStill, I cannot import and use it in my pycharm projects.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":334,"Q_Id":51407746,"Users Score":1,"Answer":"I had the same problem, but I did not dare to try Akin's solution for my research project (I think it is a good solution if anyone wants to stick to PyOpt package with python3). \nI used Pyomo instead.\nBy the way, Laurent's answer actually points to another package. PyOpt and pyopt are two different packages.","Q_Score":0,"Tags":"python,pycharm","A_Id":61829940,"CreationDate":"2018-07-18T17:22:00.000","Title":"Installing pyOpt on python in ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I did the following\n\nInstall python (2.7) on windows using official setup file from python.org\nCreated a virtual env using the same interpreter\nInstalled ipython in the virtual env\n\nWhen I run ipython from windows commandline, everything works good. I get the colors and autocomplete. But when I run inside cygwin bash, there are no colors and autocomplete does not work. I also installed pyreadline package in the same virtual env but didn't fix it. Any clues?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":345,"Q_Id":51409519,"Users Score":0,"Answer":"Not just ipython. Most native windows programs (especially the interactive ones) don't work good in cygwin terminal.\nPossible options:\n\nInstall cygwin version of the program. Python\/ipython can be installed inside cygwin\nRun in dos\/power shell\nStart bash in powershell and start the native program within it. \nInstall Ubuntu or other linux on WSL (Windows Subsystem for Linux)","Q_Score":0,"Tags":"python,python-2.7,cygwin,ipython","A_Id":51770564,"CreationDate":"2018-07-18T19:18:00.000","Title":"ipython in cygwin does not have autocomplete","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Let's say I have two python lists like so:\n\n[30, 400, 500]\n[55, 396, 478]\n\nI want to find the sum of minimum (absolute value of the) difference between the elements. In this case it would be easy: (55-30) + (400-396) + (500-478) = 51\nBut how would I go about doing this efficiently when the lists don't have an equal number of elements. For example:\n\nSet 1: \nlist1 = [30, 400, 500]\nlist2 = [412, 489]\n\nor even if it was \n\nSet 2\nlist1 = [30, 400, 500]\nlist2 = [24, 563]\n\nlastly, \n\nSet 3\nlist1 = [30, 50]\nlist2 = [20, 31, 90]\n\nFor Set 1, the answer would be (412-400) + (500-489) = 23\nFor Set 2, the answer would be (30-24) + (563-500) = 69\nFor Set 3, the answer would be (30-20) + (50-31) =29\nI can't compare by element. In set 1, the sum of the minimum difference is achieved by comparing the second element of list1 to the first element of list2, and the third element of list1 to the second element of list2. In set 2, the sum of the minimum difference is achieved by comparing the first element of list1 to the first element of list2, and the third element of list1 to the second element of list2. \nAny help is appreciated.\nSome other info:\n\nThe lists will never be more than 2 times longer than the other, but there is no bound on whether list1 is the bigger list or if list2 is the bigger list.\nThe lists will be in sorted order\nAll elements in the shorter list have to be used at least once","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":1340,"Q_Id":51409756,"Users Score":1,"Answer":"One way to do this problem is to choose the smaller list first. Take numbers one by one from smaller list and search for the minimum absolute difference (keep track of index as well) and once you found the minimum absolute difference add it to your final sum and delete that element from bigger list so you won't consider that again. \nThis solution is O(NM). Assuming list size constraint are N, M for list1 and list2 respectively. You can optimise the solution to O(NLogN + NLogM) it by sorting the bigger list in O(NLogN) and using binary search to find the minimum absolute difference.","Q_Score":2,"Tags":"python,list,comparison,difference","A_Id":51409935,"CreationDate":"2018-07-18T19:33:00.000","Title":"Minimum summation of difference of terms in two lists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a django file server. The server works perfectly on my laptop & localhost (with external hard drive) but when I transferred it to my Raspberry Pi running Raspbian, it starts acting up.\nI did a lot of googling and tried every possible solution but it does not work. \nHere is my problem:\nI have connected an external hard drive to my raspberry pi. I believe it has write permissions because I can easily write to it with mkdir. I have also set this directory which is \/media\/pi\/SAMSUNG\/media as my MEDIA_ROOT. \nNow I have set up Apache2, WSGI and Django, everything works, I have set up all the permissions and everything, but still when django tries to access the hard drive, whether it be to read or write, I get an error [Errno 13] Permission denied: '\/media\/pi\/SAMSUNG'. \nI have fixed this in the past with chown -R 777 but it does not work this time. \nUnfortunetly, I have no idea what I am doing when it comes to servers and file permissions, so I have no idea what code to attach. Can some please help me?\nI will attach all the necessary code on request.\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":51410594,"Users Score":0,"Answer":"On raspbian you have to be careful when using external drives. Have you edited the file \/etc\/fstab? This is necessary to mount the drive also correctly after restarts and when the file is temporarily disconnected and then connected again.\nIf you did this correctly, then the drive will have the permissions you gave it when mounting and Django should be able to access it\/write to it.\nBR","Q_Score":0,"Tags":"python,django,apache2,file-permissions","A_Id":51410717,"CreationDate":"2018-07-18T20:36:00.000","Title":"Permission denied when django writes to external 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":1},{"Question":"Suppose I have a function that takes several seconds to compute and I have 8 CPUs (according to multiprocessing.cpu_count()). \nWhat happens when I start this process less than 8 times and more than 8 times? \nWhen I tried to do this I observed that even when I started 20 processes they were all running parallel-y. I expected them to run 8 at a time, others will wait for them to finish.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":51410836,"Users Score":1,"Answer":"What happens depends on the underlying operating system.\nBut generally there are two things: physical cpu cores and threads\/processes (all major systems have them). The OS keeps track of this abstract thing called thread\/process (which among the other things contains code to execute) and it maps it to some cpu core for a given time or until some syscall (for example network access) is called. If you have more threads then cores (which is usually the case, there are lots of things running in the background of the modern OS) then some of them wait for the context switch to happen (i.e. for their turn).\nNow if you have cpu intensive tasks (hard calculations) then you won't see any benefits when running more then 8 threads\/processes.  But even if you do they won't run one after another. The OS will interrupt a cpu core at some point to allow other threads to run. So the OS will mix the execution: a little bit of this, a little bit of that. That way every thread\/process slowly progresses and doesn't wait possibly forever.\nOn the other hand if your tasks are io bound (for example you make HTTP call so you wait for network) then having 20 tasks will increase performance because when those threads wait for io then the OS will put those threads on hold and will allow other threads to run. And those other threads can do io as well, that way you achieve a higher level of concurrency.","Q_Score":0,"Tags":"python,python-3.x,multiprocessing","A_Id":51410899,"CreationDate":"2018-07-18T20:55:00.000","Title":"Python: Does `multiprocessing.Process(...).start()` start all processes on the same cpu?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So this is an odd issue.\npython script.py -a 1234 works\n\/usr\/bin\/python \/tmp\/script.py -a 1234 works\nnc 127.0.0.1 443 -e \/bin\/bash works\nnc 127.0.0.1 443 -e \/usr\/bin\/python \/tmp\/script.py -a 1234 fails with all-A-records NIY\nnc 127.0.0.1 443 -e \"\/usr\/bin\/python \/tmp\/script.py -a 1234\" fails with failed : No such file or directory\nAm I missing something here? I'm not sure why this isn't working.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":941,"Q_Id":51412941,"Users Score":0,"Answer":"Okay I'm not sure what's up with netcat but doing an old fashion bash reverse shell works just fine and solves the problem.\n\/usr\/bin\/python -u \/tmp\/script.py >& \/dev\/tcp\/127.0.0.1\/443 0>&1\nA quick note here, make sure you include the -u otherwise you'll get the incoming data from the socket but nothing output from your script will get sent back over the socket.","Q_Score":2,"Tags":"python,bash,netcat,parrot-os","A_Id":51413112,"CreationDate":"2018-07-19T01:10:00.000","Title":"NetCat Execute - File Not Found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I installed anaconda3 on centos and used the flask to run the web project. But an error occurred in anaconda3 library. Only anaconda3 was reinstalled after delete. I set the path to the .bashrc file. However, it is not possible to run the flask web project.\nDo I need additional settings for my centos server?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":45,"Q_Id":51415865,"Users Score":1,"Answer":"Since anaconda already ships with flask, you do not need any additional settings. However, if your project has other requirements like flask extensions e.g. flask-restless etc. then you would need to manually install them using pip.\nIf your project has a requirements.txt file, you can install the requirements using  pip install -r requirements.txt. If it does not have any, then you might have to install a library called pipreqs from the python package index. Then use pipreqs to generate the requirements.txt file and install the dependancies.","Q_Score":0,"Tags":"python,flask,centos,anaconda","A_Id":51419472,"CreationDate":"2018-07-19T06:35:00.000","Title":"centos server anaconda re-install and setting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"any one clear this error because if i include in command line \nopenposedemo.exe --face this error come\nError:\nPrototxt file not found: models\\face\/pose_deploy.prototxt.\nPossible causes:\n        1. Not downloading the OpenPose trained models.\n        2. Not running OpenPose from the same directory where the model folder is located.\n        3. Using paths with spaces.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1010,"Q_Id":51418537,"Users Score":0,"Answer":"If running Windows tryIf running Windows 10 try opening an admin command prompt in your openpose root folder and then paste bin\\OpenPoseDemo.exe.  You have to run it from the root context you cannot cd into the bin folder and then run it from there.\nC:\\openpose\\bin\\openposedemo.exe","Q_Score":0,"Tags":"python-3.x,opencv3.1","A_Id":61537350,"CreationDate":"2018-07-19T09:05:00.000","Title":"Prototxt file not found:","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there any library in python that can I easily compare fingerprints? \nI want to build a student attendance system using fingerprint, my frontend will be ReactJS and Django as backend. Like, you need to save the fingerprints of every student in the database and you will retrieve it for comparing.\nI already google but there are no specific result for my question.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1431,"Q_Id":51418915,"Users Score":0,"Answer":"Got it guys, the scanner will just give me output to save in db. I thought I will save figerprint as image in db, and  retrieve the image to compare.","Q_Score":0,"Tags":"python,django,reactjs","A_Id":51423344,"CreationDate":"2018-07-19T09:23:00.000","Title":"Python Library for Comparing Fingerprints","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"The standard way to enter a password in Python without echoing it is using getpass.getpass().\nHowever,it doesn't support clipboard input (ctrl-V), which is needed when dealing with complex, highly secure passwords.\nHas anyone ever come up with a workaround (get the password silently from crtl-V)?\nThanks!\nR.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":539,"Q_Id":51420332,"Users Score":3,"Answer":"It is possible to right click paste from clipboard into the command prompt as an alternative. \nUnfortunately getpass.getpass() uses getwch() from Windows C, which does not allow CTRL+C to be read.","Q_Score":1,"Tags":"python,passwords,getpass","A_Id":59619135,"CreationDate":"2018-07-19T10:29:00.000","Title":"Get password silently from clipboard in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using tesseract-ocr and get the output in hOCR format. I need to store this hOCR output into the database (PostgreSQL in my case).\nSince I may need every piece of information (80% of it) from this hOCR individually, which would be the right approach? Should it be stored as XML datatype or parsed to JSON and stored? And in case of JSON, how to parse this hOCR to JSON with Python. Other related suggestions are also appreciated.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":3041,"Q_Id":51421283,"Users Score":3,"Answer":"hOCR appears to be a dialect of XML, so you should be able to use the xml.etree  module from the stdlib to parse the hOCR code into a Python-navigable tree. Then navigate that tree to compose an object or nested dict, and then finally using the stdlib's json module to convert that dict to JSON.","Q_Score":1,"Tags":"python,postgresql,parsing,python-tesseract,hocr","A_Id":51426758,"CreationDate":"2018-07-19T11:16:00.000","Title":"Parsing hOCR to JSON with Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My computer's system language is zh_cn, so the vs code python extension set the default language to chinese. But i want to change the language to english. \nI can't find the reference in the doc or on the internet. Anyone konws how to do it? Thank's for help\nPS: vs code's locale is alreay set to english.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":555,"Q_Id":51422391,"Users Score":0,"Answer":"You probably installed other python extensions for VSCode. Microsoft official python extension will follow the locale setting in user\/workspace settings.\nTry uninstall other python extensions, you may see it changes to English.","Q_Score":2,"Tags":"python,visual-studio-code","A_Id":52695311,"CreationDate":"2018-07-19T12:11:00.000","Title":"how to change vs code python extension's language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My computer's system language is zh_cn, so the vs code python extension set the default language to chinese. But i want to change the language to english. \nI can't find the reference in the doc or on the internet. Anyone konws how to do it? Thank's for help\nPS: vs code's locale is alreay set to english.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":555,"Q_Id":51422391,"Users Score":0,"Answer":"When VScode is open go to View menu and select Command Palette. Once the command palette is open type display in the box. This should display the message configure display language. Open that and you should be in a local.json file. The variable local should be set to en for English.","Q_Score":2,"Tags":"python,visual-studio-code","A_Id":51432241,"CreationDate":"2018-07-19T12:11:00.000","Title":"how to change vs code python extension's language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got an error while running django server. I installed opencv-python and opencv-contrib-python through pip. Still getting the same error. Any suggestions?\n\nPerforming system checks...\n\nUnhandled exception in thread started by \nTraceback (most recent call last):\n  File \"\/home\/auxouser\/.local\/lib\/python2.7\/site-packages\/django\/utils\/autoreload.py\", line 228, in wrapper fn(*args, **kwargs)\n  File \"\/home\/auxouser\/.local\/lib\/python2.7\/site-packages\/django\/core\/management\/commands\/runserver.py\", line 124, in inner_run\n    self.check(display_num_errors=True)\n  File \"\/home\/auxouser\/.local\/lib\/python2.7\/site-packages\/django\/core\/management\/base.py\", line 359, in check include_deployment_checks=include_deployment_checks,\n  File \"\/home\/auxouser\/.local\/lib\/python2.7\/site-packages\/django\/core\/management\/base.py\", line 346, in _run_checks return checks.run_checks(**kwargs) \n  File \"\/home\/auxouser\/.local\/lib\/python2.7\/site-packages\/django\/core\/checks\/registry.py\", line 81, in run_checks new_errors = check(app_configs=app_configs)\n  File \"\/home\/auxouser\/.local\/lib\/python2.7\/site-packages\/django\/core\/checks\/urls.py\", line 16, in check_url_config return check_resolver(resolver)\n  File \"\/home\/auxouser\/.local\/lib\/python2.7\/site-packages\/django\/core\/checks\/urls.py\", line 26, in check_resolver return check_method()\n  File \"\/home\/auxouser\/.local\/lib\/python2.7\/site-packages\/django\/urls\/resolvers.py\", line 254, in check for pattern in self.url_patterns:\n  File \"\/home\/auxouser\/.local\/lib\/python2.7\/site-packages\/django\/utils\/functional.py\", line 35, in __get__res = instance.__dict__[self.name] = self.func(instance)\n  File \"\/home\/auxouser\/.local\/lib\/python2.7\/site-packages\/django\/urls\/resolvers.py\", line 405, in url_patterns patterns = getattr(self.urlconf_module, \"urlpatterns\", self.urlconf_module)\n  File \"\/home\/auxouser\/.local\/lib\/python2.7\/site-packages\/django\/utils\/functional.py\", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance)\n  File \"\/home\/auxouser\/.local\/lib\/python2.7\/site-packages\/django\/urls\/resolvers.py\", line 398, in urlconf_module return import_module(self.urlconf_name)\n  File \"\/usr\/lib\/python2.7\/importlib\/__init__.py\", line 37, in import_module\n    __import__(name)\n  File \"\/home\/auxouser\/Auxo\/projects\/training-ds\/Day-9\/Face_Recognition\/Face_Recognition\/urls.py\", line 3, in \n    from MyAPP import views\n  File \"\/home\/auxouser\/Auxo\/projects\/training-ds\/Day-9\/Face_Recognition\/MyAPP\/views.py\", line 12, in \n    recognizer = cv2.face.LBPHFaceRecognizer_create()\nAttributeError: 'module' object has no attribute 'face'","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":347,"Q_Id":51422857,"Users Score":1,"Answer":"You probably have a module named cv.py (or cv2.py in this case) in your project - that means import cv2 is importing your own module, not opencv, and cv2.face will fail.\nDelete your .py file and the .pyc that was generated, and the import should work again.","Q_Score":0,"Tags":"python,django,opencv,pip","A_Id":51423083,"CreationDate":"2018-07-19T12:35:00.000","Title":"AttributeError: 'module' object has no attribute 'face' even after installed opencv-contrib-python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Everytime I run docker-compose up on my machine (macOS 10.13.5, latest docker version) I get this error\n\nTraceback (most recent call last):   File \"docker-compose\", line 6, in\n     File \"compose\/cli\/main.py\", line 71, in main   File\n  \"compose\/cli\/main.py\", line 124, in perform_command   File\n  \"compose\/cli\/command.py\", line 41, in project_from_options   File\n  \"compose\/cli\/command.py\", line 126, in get_project   File\n  \"compose\/project.py\", line 96, in from_config   File\n  \"compose\/network.py\", line 320, in get_networks   File\n  \"compose\/network.py\", line 125, in true_name   File\n  \"compose\/network.py\", line 146, in _set_legacy_flag   File\n  \"compose\/network.py\", line 106, in inspect   File\n  \"site-packages\/docker\/utils\/decorators.py\", line 19, in wrapped   File\n  \"site-packages\/docker\/api\/network.py\", line 211, in inspect_network\n  File \"site-packages\/docker\/utils\/decorators.py\", line 46, in inner\n  File \"site-packages\/docker\/api\/client.py\", line 194, in _get   File\n  \"site-packages\/requests\/sessions.py\", line 521, in get   File\n  \"site-packages\/requests\/sessions.py\", line 494, in request   File\n  \"site-packages\/requests\/sessions.py\", line 424, in prepare_request\n  File \"site-packages\/requests\/utils.py\", line 195, in get_netrc_auth\n  File \"netrc.py\", line 33, in init   File \"netrc.py\", line 42, in\n  _parse   File \"shlex.py\", line 105, in get_token   File \"shlex.py\", line 136, in read_token   File\n  \"\/Users\/distiller\/compose-osx-release\/compose\/venv\/lib\/python3.6\/codecs.py\",\n  line 321, in decode UnicodeDecodeError: 'utf-8' codec can't decode\n  byte 0x80 in position 33: invalid start byte","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3258,"Q_Id":51423379,"Users Score":0,"Answer":"I have 2 ideas:\n1. try to reinstall your python\n2. use not the latest docker version, but the latest stable","Q_Score":4,"Tags":"python,python-3.x,docker,docker-compose","A_Id":51423509,"CreationDate":"2018-07-19T13:02:00.000","Title":"docker-compose up: utf-8 codec can't decode byte X","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Everytime I run docker-compose up on my machine (macOS 10.13.5, latest docker version) I get this error\n\nTraceback (most recent call last):   File \"docker-compose\", line 6, in\n     File \"compose\/cli\/main.py\", line 71, in main   File\n  \"compose\/cli\/main.py\", line 124, in perform_command   File\n  \"compose\/cli\/command.py\", line 41, in project_from_options   File\n  \"compose\/cli\/command.py\", line 126, in get_project   File\n  \"compose\/project.py\", line 96, in from_config   File\n  \"compose\/network.py\", line 320, in get_networks   File\n  \"compose\/network.py\", line 125, in true_name   File\n  \"compose\/network.py\", line 146, in _set_legacy_flag   File\n  \"compose\/network.py\", line 106, in inspect   File\n  \"site-packages\/docker\/utils\/decorators.py\", line 19, in wrapped   File\n  \"site-packages\/docker\/api\/network.py\", line 211, in inspect_network\n  File \"site-packages\/docker\/utils\/decorators.py\", line 46, in inner\n  File \"site-packages\/docker\/api\/client.py\", line 194, in _get   File\n  \"site-packages\/requests\/sessions.py\", line 521, in get   File\n  \"site-packages\/requests\/sessions.py\", line 494, in request   File\n  \"site-packages\/requests\/sessions.py\", line 424, in prepare_request\n  File \"site-packages\/requests\/utils.py\", line 195, in get_netrc_auth\n  File \"netrc.py\", line 33, in init   File \"netrc.py\", line 42, in\n  _parse   File \"shlex.py\", line 105, in get_token   File \"shlex.py\", line 136, in read_token   File\n  \"\/Users\/distiller\/compose-osx-release\/compose\/venv\/lib\/python3.6\/codecs.py\",\n  line 321, in decode UnicodeDecodeError: 'utf-8' codec can't decode\n  byte 0x80 in position 33: invalid start byte","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3258,"Q_Id":51423379,"Users Score":0,"Answer":"What worked for me was creating an empty .env file in the directory I run docker-compose in (encoded as UTF-8).","Q_Score":4,"Tags":"python,python-3.x,docker,docker-compose","A_Id":60111921,"CreationDate":"2018-07-19T13:02:00.000","Title":"docker-compose up: utf-8 codec can't decode byte X","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to create a program that incorporates a kind of exchange JSONs messaging system where there is an A or central device, of which we know its static IP and one or more B devices, which have a dynamic and unstable IP.\nThe communication I propose should be viable not only from B to A (including answer or not from B) but also from A to B, with the same results.\nMy messaging skills are limited to ZMQ, so I had thought about two possible situations:\nOn the first one, based on PUSH-PULL sockets, A has a PULL socket and another PUSH socket, in the same way as B. As a heartbeat, B sends a JSON every X seconds\/minutes saying \"This is my IP\". That information is considered reliable within a time range and, on the one hand, we solve the communication from B to A (fairly easy) and on the other hand B has saved an IP with which to try to contact with a minimum of reliability.\nON the second one, I thought about on REQ-REP sockets. In this configuration, A has a RES socket, capable of receiving and responding requests from B, which in turn has an associated REQ socket for performing the requests. The communication from B to A, again, is simple. Conversely, the idea would be to have B throwing REQ requests as a heartbeat (every half second, for example), asking \"Is there something for me? Is there something for me?\" Much more reliable than the first but much less efficient at the network level (I completely ignore the real cost of this type of calls).\nIs there a better proposal to start with? I want to emphasize that I use ZMQ because it is what I know, but if there are much better tools \/ more adapted to this type of situation, I will be happy to know and \/ or work with them. I know Google has a kind of API for Android but I'm not talking specifically about smartphones.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":51428065,"Users Score":0,"Answer":"Remember that the end that PUSHes or REQuests or whatever is totally independent of the end that binds or connects. So the device that has the stable IP address can bind its zmq sockets and everything else connects their zmq sockets to that IP address, but you can then choose which end is PUSH or PULL, or REQ or REP","Q_Score":0,"Tags":"json,python-3.x,zeromq,messaging,pyzmq","A_Id":51430389,"CreationDate":"2018-07-19T16:49:00.000","Title":"Best way of communicating two devices knowing only one IP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The function bezier.curve.plot(num_pts, ...) in PyPI bezier 0.8.0 one can start using a low number of num_pts and increase it until one gets a perfectly smooth curve -- i.e. one that does not show the slightest sign of a polygon -- after which any increase of these points will not improve the curve.\nNow, in the examples I dinf in the Web I usually see num_pts=256, which I find extremely high, since I have never met a case needing more than 80 points, considering the most complex curve I have plotted. And this is what I always use, until I find it is too little. So, I wonder if this is just a habit propagated among programmers or there's a real reason for it. Doesn't this produce a kind of overwork\/overload\/overtime to the process, esp. when plotting a lot of curves, as e.g. in an animation? And, coming back to my basic question, is there a method with which one can find the minimum number of points needed to plot a smooth bezier curve?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":173,"Q_Id":51428725,"Users Score":1,"Answer":"Yes, it's mostly inertia -- copying legacy code.\nThis hearkens back to days in which the visual plot region was typically much larger, such as a full screen object.  \"Smooth\" is relative to the viewer's retina.  256 made a convenient block of memory to allocate and reclaim for the passed array of floats, saving some time for that part of the OS load.\nWhen plotting smaller objects, such as a typical animation, you're quite right: lower numbers will give a curve that appears to be as smooth.  With the advent of vector-based machine operations and supporting parallel processing, the time difference isn't significant for most applications.  Coders for applications requiring high frame rates are cognizant of many real-time optimizations, and will catch this when it matters.","Q_Score":1,"Tags":"python,matplotlib,bezier","A_Id":51428915,"CreationDate":"2018-07-19T17:31:00.000","Title":"PyPI bezier 0.8.0: Minimum number of points needed to plot a smooth bezier curve?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently working on a neural network that evaluates students' answers to exam questions. Therefore, preprocessing the corpora for a Word2Vec network is needed. Hyphenation in german texts is quite common. There are mainly two different types of hyphenation:\n1) End of line:  \nThe text reaches the end of the line so the last word is sepa-\nrated.\n2) Short form of enumeration:\nin case of two \"elements\": \nGeistes- und Sozialwissenschaften\nmore \"elements\": \nWirtschafts-, Geistes- und Sozialwissenschaften\nThe de-hyphenated form of these enumerations should be:\nGeisteswissenschaften und Sozialwissenschaften\nWirtschaftswissenschaften, Geisteswissenschaften und Sozialwissenschaften\nI need to remove all hyphenations and put the words back together. I already found several solutions for the first problem.\nBut I have absoluteley no clue how to get the second part (in the example above \"wissenschaften\") of the words in the enumeration problem. I don't even know if it is possible at all.\nI hope that I have pointet out my problem properly.\nSo has anyone an idea how to solve this problem?\nThank you very much in advance!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":50,"Q_Id":51430249,"Users Score":1,"Answer":"It's surely possible, as the pattern seems fairly regular. (Something vaguely analogous is sometimes seen in English. For example: The new requirements applied to under-, over-, and average-performing employees.)\nThe rule seems to be roughly, \"when you see word-fragments with a trailing hyphen, and then an und, look for known words that begin with the word-fragments, and end the same as the terminal-word-after-und \u2013 and replace the word-fragments with the longer words\". \nNot being a German speaker and without language-specific knowledge, it wouldn't be possible to know exactly where breaks are appropriate. That is, in your Geistes- und Sozialwissenschaften example, without language-specific knowledge, it's unclear whether the first fragment should become Geisteszialwissenschaften or Geisteswissenschaften or Geistesenschaften or Geiestesaften or any other shared-suffix with Sozialwissenschaften. But if you've got a dictionary of word-fragments, or word-frequency info from other text that uses the same full-length word(s) without this particular enumeration-hyphenation, that could help choose. \n(If there's more than one plausible suffix based on known words, this might even be a possible application of word2vec: the best suffix to choose might well be the one that creates a known-word that is closest to the terminal-word in word-vector-space.)\nSince this seems a very German-specific issue, I'd try asking in forums specific to German natural-language-processing, or to libraries with specific German support. (Maybe, NLTK or Spacy?)\nBut also, knowing word2vec, this sort of patch-up may not actually be that important to your end-goals. Training without this logical-reassembly of the intended full words may still let the fragments achieve useful vectors, and the corresponding full words may achieve useful vectors from other usages. The fragments may wind up close enough to the full compound words that they're \"good enough\" for whatever your next regression\/classifier step does. So if this seems a blocker, don't be afraid to just try ignoring it as a non-problem. (Then if you later find an adequate de-hyphenation approach, you can test whether it really helped or not.)","Q_Score":0,"Tags":"python,nlp,word2vec,preprocessor,hyphenation","A_Id":51439004,"CreationDate":"2018-07-19T19:12:00.000","Title":"Python3 remove multiple hyphenations from a german string","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently moved some code I've been using successfully into a flask server. It has worked seamlessly until now off the server. \nHowever, in the same directory, when trying to load a stored object using pickle, I get an ImportError. This happens in a function which runs when @app.before_first_request is called.\nHow could this change cause this? Any insights would be appreciated.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":871,"Q_Id":51432379,"Users Score":0,"Answer":"It seems that Flask change the paths that are searched for imports, adding sys.path.append('.\/') to the beginning of my app's file fixed the problem.","Q_Score":0,"Tags":"python,flask,pickle,importerror","A_Id":51443329,"CreationDate":"2018-07-19T22:07:00.000","Title":"Using Pickle in Flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Does it call forward() in nn.Module? I thought when we call the model, forward method is being used.\nWhy do we need to specify train()?","AnswerCount":6,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":130339,"Q_Id":51433378,"Users Score":15,"Answer":"There are two ways of letting the model know your intention i.e do you want to train the model or do you want to use the model to evaluate.\nIn case of model.train() the model knows it has to learn the layers and when we use model.eval() it indicates the model that nothing new is to be learnt and the model is used for testing.\nmodel.eval() is also necessary because in pytorch if we are using batchnorm and during test if we want to just pass a single image, pytorch throws an error if model.eval() is not specified.","Q_Score":161,"Tags":"python,pytorch","A_Id":51596850,"CreationDate":"2018-07-20T00:10:00.000","Title":"What does model.train() do in PyTorch?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to perform outlier detection and I have 15 different test sets and 3 different models (a PCA-based classifier, One Class SVM and Isolation Forest).  \nFor PCA-based classification, I have written my own code for generating ROC curves. I have 2 lists pcafprs and pcatprs, each of which has 15 sublists, each sublist representing the False Positive Ratios and True Positive Ratios, required to plot the ROC curve.  \nFor One-Class SVM and Isolation Forest, I can get the (fpr, tpr) from sklearn.metrics.roc_curve. Similar to PCA, I have ocsvmfprs and ocsvmtprs for One-Class SVM, and isoforestfprs and isoforesttprs for Isolation Forest.  \nFor each test set, I can iterate over the FPR and TPR lists and plot the ROC curve. The code might look like:\nfor i in range(len(pcafprs)):\n    plt.plot(pcafprs[i], pcatprs[i]) #Plot the ROC curve\n    plt.show()\n\nFor each of the 3 models, I want to be able to plot the average of all 15 ROC curves for the 15 test sets in one graph. I cannot simply do np.mean over the arrays containing the TPRs and FPRs because the FPRs returned by sklearn.metrics.roc_curve are all different points for each test set.\nFor PCA, I have tried using np.mean(pcatprs, axis=0) and np.mean(pcafprs, axis=0) to average out all the TPRs and FPRs so that I can plot a single graph which represents the mean of all the test sets. This works because for PCA I have generated the same number of FPRs and TPRs for each test set.\nHowever, I am unable to control the no. of FPRs and TPRs returned for each test set by sklearn.metrics.roc_curve, and it turns out that it returns different number of values for each test set. Due to this, I cannot use np.mean to find the average ROC curve.  \ntl,dr: Is there a way to plot the average of multiple lines on a graph without having the equations and only having some points that lie on the lines, where we have a different number of points available for each line?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1603,"Q_Id":51434567,"Users Score":0,"Answer":"Solved by choosing a fixed set of FPRs, then using no.interp for each pair of (fpr,tpr) returned by sklearn.metrics.roc_curve to get the corresponding TPRs, then averaged all ROCs using np.mean","Q_Score":1,"Tags":"python,matplotlib,plot,scikit-learn,roc","A_Id":51436328,"CreationDate":"2018-07-20T03:18:00.000","Title":"How to plot the average of ROC curves?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Intellisense in python is turning out to be more of a burden than a helpful tool.  Whenever I used it for C++, pressing '.' would pop up a list of options.  However pressing '.' while using Python commits to the intellisense option.  This also happens when pressing '(' or '{' or several other special characters.  I was under the impression that pressing 'tab' or 'enter' were the only keys that would commit to the intellisense option?\nTo make matters worse, Visual Studio's keyboard shortcuts don't seem to be working correctly either (or at least 1 of the main ones I use).\nPressing Ctrl + Enter would normally give me a new line above my current line however instead I get a syntax error in the School Interactive Window.\nA solution to these problem would be greatly appreciated.\nEDIT: Solutions I've tried are looking under the text editor options for python as well as the general text editor options.  I've also searched google and stack overflow but can't find a similar question\nEDIT2: Changed title as well as body to reflect new found info which is that not only '.' commits to the intellisense option but all special characters.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":121,"Q_Id":51435429,"Users Score":0,"Answer":"Found the solution.  Under Tools > Options > Python > Advanced there is a \"Committed by typing the following characters: {}.,:;+-*\/%&|^~=<>#@\\\".  I thought these were characters that opened up intellisense dropdown suggestions but rather commit the intellisense option.  I just deleted all the characters and it fixed the issue.  I still haven't found the answer to my second question but since the title is named after the first issue, I'll open up a new topic for that question if I do a more thorough search and can't figure it out.","Q_Score":0,"Tags":"python,visual-studio,visual-studio-2017","A_Id":51435840,"CreationDate":"2018-07-20T05:07:00.000","Title":"Visual Studio intellisense commits after pressing a special character - python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an ESP32 board, with Micropython installed properly, and connecting to local the internet.\nSince it have to do a scheduled jobs- its clock need to be synced. After boot it get a generic date 1\/1\/2000. \nHow can Micropython updates int clock using ntp.pool.org or other?\nGuy","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5775,"Q_Id":51435893,"Users Score":0,"Answer":"You can get a DS3231 RTC. I\u2019m currently using one and it works great.","Q_Score":1,"Tags":"micropython,esp32","A_Id":61282836,"CreationDate":"2018-07-20T05:55:00.000","Title":"ESP32 - using MicroPython: How to update clock after reboot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have deployed a webapplication Python Django Rest Framework Front end is Vue js and Database is Mysql.\nHosted the website on digital ocean i am using CPU Optimized Droplets with the below configuration 8 GB 4 vCPUs i facing performance issue the site is very slow though the hosting is CPU optimized with 8gb of ram.\nWhen i checked the error log i am able to find [CRITICAL] WORKER TIMEOUT (pid:9116) i increased the timeout time of the gunicorn still i am facing the same issue.\n1)I want to increase the performance \n2)I want to fix the timeout issue i have increased the value in gunicorn as nginx the maximum value is 75s i have not done any addition to it. what will be th best solution.\nKindly help me is there any alternative ways to test the performance of the site.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1064,"Q_Id":51436451,"Users Score":0,"Answer":"I think you need optimization\nTips on optimizing your django rest on production server .\n\nCheck your queries. Best way to check this is using the django debug toolbar, it will show how many queries you produce and if you think there is a lot, then optimize your queries. Ex. use prefetch_related or  select_related to join the tables or else it will query one by one.\nIndex your tables, try to index the columns you're always using on querying. Just be careful on indexing, just index the columns you really wanted because the downside will be slower on update, delete and add.\nCheck your database health, if you perform delete or update frequently those data actually stored somewhere and it is still part of your indexes, it called Dead Rows, you can remove this by perform some commands like vacuum if your are using postgres.\nScale up your server, this actually depends on the request\/traffic of your server, check the RAM or CPU spikes for you to determine the needed units. As experience, I have atleast 10m row of data on some of my tables, which in some scenario I cross refer it to a 30k data, on 2gb RAM and 1gb CPU working fine in few simultaneous request.","Q_Score":0,"Tags":"python,django,nginx,webserver,gunicorn","A_Id":51439974,"CreationDate":"2018-07-20T06:36:00.000","Title":"Gunicorn Timeout Server Slow issues","Data Science and Machine Learning":0,"Database and SQL":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":"This question is related to convolutionals neural networks (especially YoloV3)\nSince one epoch is one forward pass and one backward pass of all the training examples, for the model to converge properly, is it the same (in terms of precision and time to converge) to :\n\ntrain with n*k images during m epochs ?\ntrain with n images during m*k epochs ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":794,"Q_Id":51437817,"Users Score":0,"Answer":"No, they are not the same. \n*The number of examples you show the network defines what it will be looking for - a network with more examples will tend to be more general. If there are, for example, 1000 pictures with different dogs in it, and you only show 300\/300000 pictures, the network (on average) will only recognize one specific kind of dog, and be unable to pick out common traits of all dogs.\n*An epoch is basically modifying the network in a small step, and the key word here is small - taking too big steps risk overshooting our target values for the network parameters. Since we\u00b4re taking small steps, we have to take several of them to get where we want.","Q_Score":1,"Tags":"python,deep-learning,epoch,yolo","A_Id":51438139,"CreationDate":"2018-07-20T07:59:00.000","Title":"CNN: Is it better to train 300.000 images during 1 epoch or 300 images during 1000 epoch?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know how to properly install tensorflow on Windows?\nI'm currently using Python 3.7 (also tried with 3.6) and every time I get the same \"Could not find a version that satisfies the requirement tensorflow-gpu (from versions: )\nNo matching distribution found for tensorflow-gpu\" error\nI tried installing using pip and anaconda, both don't work for me.\n\nFound a solution, seems like Tensorflow doesn't support versions of python after 3.6.4. This is the version I'm currently using and it works.","AnswerCount":16,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":44333,"Q_Id":51440475,"Users Score":0,"Answer":"Not Enabling the Long Paths can be the potential problem.To solve that,\nSteps include:\n\nGo to Registry Editor on the Windows Laptop\n\nFind the key \"HKEY_LOCAL_MACHINE\"->\"SYSTEM\"->\"CurrentControlSet\"->\n\"File System\"->\"LongPathsEnabled\" then double click on that option and change the value from 0 to 1.\n\n\n3.Now try to install the tensorflow it will work.","Q_Score":5,"Tags":"python,tensorflow","A_Id":68421682,"CreationDate":"2018-07-20T10:26:00.000","Title":"Can't install tensorflow with pip or anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know how to properly install tensorflow on Windows?\nI'm currently using Python 3.7 (also tried with 3.6) and every time I get the same \"Could not find a version that satisfies the requirement tensorflow-gpu (from versions: )\nNo matching distribution found for tensorflow-gpu\" error\nI tried installing using pip and anaconda, both don't work for me.\n\nFound a solution, seems like Tensorflow doesn't support versions of python after 3.6.4. This is the version I'm currently using and it works.","AnswerCount":16,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":44333,"Q_Id":51440475,"Users Score":0,"Answer":"As of July 2019, I have installed it on python 3.7.3 using py -3 -m pip install tensorflow-gpu\npy -3 in my installation selects the version 3.7.3. \nThe installation can also fail if the python installation is not 64 bit. Install a 64 bit version first.","Q_Score":5,"Tags":"python,tensorflow","A_Id":56944215,"CreationDate":"2018-07-20T10:26:00.000","Title":"Can't install tensorflow with pip or anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know how to properly install tensorflow on Windows?\nI'm currently using Python 3.7 (also tried with 3.6) and every time I get the same \"Could not find a version that satisfies the requirement tensorflow-gpu (from versions: )\nNo matching distribution found for tensorflow-gpu\" error\nI tried installing using pip and anaconda, both don't work for me.\n\nFound a solution, seems like Tensorflow doesn't support versions of python after 3.6.4. This is the version I'm currently using and it works.","AnswerCount":16,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":44333,"Q_Id":51440475,"Users Score":0,"Answer":"Actually the easiest way to install tensorflow is:\ninstall python 3.5 (not 3.6 or 3.7) you can check wich version you have by typing \"python\" in the cmd.\nWhen you install it check in the options that you install pip with it and you add it to variables environnement.\nWhen its done just go into the cmd and tipe \"pip install tensorflow\"\nIt will download tensorflow automatically.\nIf you want to check that it's been installed type \"python\" in the cmd then some that \">>>\" will appear, then you write \"import tensorflow\" and if there's no error, you've done it!","Q_Score":5,"Tags":"python,tensorflow","A_Id":53177064,"CreationDate":"2018-07-20T10:26:00.000","Title":"Can't install tensorflow with pip or anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know how to properly install tensorflow on Windows?\nI'm currently using Python 3.7 (also tried with 3.6) and every time I get the same \"Could not find a version that satisfies the requirement tensorflow-gpu (from versions: )\nNo matching distribution found for tensorflow-gpu\" error\nI tried installing using pip and anaconda, both don't work for me.\n\nFound a solution, seems like Tensorflow doesn't support versions of python after 3.6.4. This is the version I'm currently using and it works.","AnswerCount":16,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":44333,"Q_Id":51440475,"Users Score":5,"Answer":"Tensorflow or Tensorflow-gpu is supported only for 3.5.X versions of Python. Try installing with any Python 3.5.X version. This should fix your problem.","Q_Score":5,"Tags":"python,tensorflow","A_Id":51706227,"CreationDate":"2018-07-20T10:26:00.000","Title":"Can't install tensorflow with pip or anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know how to properly install tensorflow on Windows?\nI'm currently using Python 3.7 (also tried with 3.6) and every time I get the same \"Could not find a version that satisfies the requirement tensorflow-gpu (from versions: )\nNo matching distribution found for tensorflow-gpu\" error\nI tried installing using pip and anaconda, both don't work for me.\n\nFound a solution, seems like Tensorflow doesn't support versions of python after 3.6.4. This is the version I'm currently using and it works.","AnswerCount":16,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":44333,"Q_Id":51440475,"Users Score":0,"Answer":"You mentioned Anaconda. Do you run your python through there?\nIf so check in Anaconda Navigator --> Environments, if your current environment have got tensorflow installed. \nIf not, install tensorflow and run from that environment. \nShould work.","Q_Score":5,"Tags":"python,tensorflow","A_Id":51440570,"CreationDate":"2018-07-20T10:26:00.000","Title":"Can't install tensorflow with pip or anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to generate html email, that would show data based on dropdown menu selection within email. I have been looking around and could not find anything suitable for this use case.\nCurrently my procedure is that I use Python to generate all required data and than render html template with Jinja2 package.\nWhat I would like to have is first part of email to be static and than under that section have a dropdown menu, which would render rest of email based on selection. I wonder if that is even possible (on side note, I can not use JS, as it is blocked for mails that are generated)?\nThank you and best regards,\nBostjan","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1050,"Q_Id":51441100,"Users Score":2,"Answer":"You will have to work with css's :active property to work around js here.\nYour problem will be the broad variety of email programms, outlook and such will fail to process this correctly.","Q_Score":2,"Tags":"python,html,dynamic,jinja2,dropdown","A_Id":51441195,"CreationDate":"2018-07-20T11:03:00.000","Title":"Dynamic html email with dropdown","Data Science and Machine Learning":0,"Database and SQL":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":"This question was asked few times on stackoverflow. However, what I'm trying to do is a little bit different.\nI'm trying to port python to QNX. Compiling all the source files and statically linking it to a \"Hello World\" script using python c API works. \nI'm having problem with the struct module. I tried compiling struct into a shared library and placing it at the exec_prefix path specified by python. When I try to import it, It tries to load the module but it complains about unknown symbols.\nIt says something like \n\nUnknown symbol: _PyUnicode_FormatAdvancedWriter referenced by\n  _struct.so\n\nI get a lot of unknown symbol errors like this. I included the header and source files of all these unknown symbols and it ends up throwing other unknown symbol errors. \nI might be doing something completely wrong. Any ideas on how I can link them?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":678,"Q_Id":51444888,"Users Score":1,"Answer":"I'm answering my own question since I figured out the fix. If anyone else is having the same problem, you have to export all the symbols to the dynamic symbol table at link time. To do this, you have to pass a flag -E to the linker i.e -Wl, -E. That should solve the problem. \nThis is a qcc specific flag so if you're experiencing this problem in gcc, you can try passing --whole-archive flag to the linker.","Q_Score":2,"Tags":"python,c,python-3.x,linker-errors,qnx-neutrino","A_Id":51655464,"CreationDate":"2018-07-20T14:32:00.000","Title":"How to statically link the python interpreter?","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":"When I want to do a conda install of pymssql conda install -c prometeia pymssql\n it states that The following packages will be REMOVED: anaconda: 5.2.0-py36_3.\nSo how can I install pymssql within Anaconda without removing anaconda?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":219,"Q_Id":51445338,"Users Score":0,"Answer":"Please make sure to first create and activate the virtual environment and then execute conda install some_package.","Q_Score":0,"Tags":"python,anaconda,packages,pymssql","A_Id":51467320,"CreationDate":"2018-07-20T14:58:00.000","Title":"pymssql uninstalls anaconda when I do conda install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pandas Series like the following:\na = pd.Series([a1, a2, a3, a4, ...]) \nand I want to create another pandas Series based on the following rule:\nb = pd.Series(a1, a2+a1**0.8, a3 + (a2 + a1**0.8)**0.8, a4 + (a3 + (a2 + a1**0.8)**0.8)**0.8, ...).\nThis is doable using iteration,  but I have a large dataset (millions of records) and I must perform operation for thousands of times (for optimization purposes). I need to do this operation very fast. Is there any possible way for me to realize this by using pandas or numpy built-in functions?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":210,"Q_Id":51449260,"Users Score":1,"Answer":"The important point about these kinds of problems that you need to know is that you're on a paradox spot right now. This means that you're on a point that you want to take advantage of both vectorization and non-vectorization like threading or parallelization.\nIn such situation you can try one\/some of the following options:\n\nChange the type of your data structure.\nRethink your problem and see if it's possible to solve this entirely in a Vectorized way (preferably)\nSimply use a non-vectorized-based approach but sacrifice something else like memory.","Q_Score":7,"Tags":"python,performance,pandas,numpy,iteration","A_Id":51450250,"CreationDate":"2018-07-20T19:30:00.000","Title":"pandas iteratively update column values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Don't get me wrong, Pycharm is an amazing IDE, and with its faults, I've still continued to use it and adapt to its way of working. But its getting pretty tedious not being able to do what I want.\nLike in other IDE's, I can CTRL+A to select all the text, somehow it almost always messed up in Pycharm, copying all text will result in what ever the INSERT key does, and deletes my content.\nClicking backspace doesn't delete the highlighted content, instead I have to deliperatly click the delete key, and this isn't exactly wrong, but it doesn't fit in with other IDE's. \nI noticed when switching from Pycharm to another IDE, I was doing what I did in Pycharm and it just felt unnatural, is there a way to make Pycharm work like other IDE's?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":183,"Q_Id":51451006,"Users Score":1,"Answer":"If you go into File->Settings and select Keymap, there is a drop-down menu where you can select the emulation that you prefer including Emacs, Netbeans, and Visual Studio","Q_Score":0,"Tags":"python,pycharm","A_Id":51451123,"CreationDate":"2018-07-20T22:11:00.000","Title":"Keyboard messed up when using Pycharm as an IDE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Don't get me wrong, Pycharm is an amazing IDE, and with its faults, I've still continued to use it and adapt to its way of working. But its getting pretty tedious not being able to do what I want.\nLike in other IDE's, I can CTRL+A to select all the text, somehow it almost always messed up in Pycharm, copying all text will result in what ever the INSERT key does, and deletes my content.\nClicking backspace doesn't delete the highlighted content, instead I have to deliperatly click the delete key, and this isn't exactly wrong, but it doesn't fit in with other IDE's. \nI noticed when switching from Pycharm to another IDE, I was doing what I did in Pycharm and it just felt unnatural, is there a way to make Pycharm work like other IDE's?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":51451006,"Users Score":0,"Answer":"Found this in another forum:\n\"Please disable IdeaVim plugin on the File | Settings | Plugins tab.\"\nWorked for me.","Q_Score":0,"Tags":"python,pycharm","A_Id":57900289,"CreationDate":"2018-07-20T22:11:00.000","Title":"Keyboard messed up when using Pycharm as an IDE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using chatter bot for implementing chat bot. I want Chatterbot to training the data set dynamically. \nWhenever I run my code it should train itself from the beginning, because I require new data for every person who'll chat with my bot. \nSo how can I achieve this in python3 and on windows platform ?\nwhat I want to achieve and problem I'm facing:\nI've a python program which will create a text file student_record.txt, this will be generate from a data base and almost new when different student signup or login. In the chatter bot, I trained the bot using with giving this file name but it still replay from the previous trained data","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":209,"Q_Id":51455033,"Users Score":0,"Answer":"I got the solution for that, I just deleted the data base on the beginning of the program thus new data base will create during the execution of the program.\n I used the following command to delete the data base\nimport os\n   os.remove(\"database_name\")\nin my case\nimport os \n   os.remove(\"db.sqlite3\")\nthank you","Q_Score":0,"Tags":"python-3.x,bots,chatterbot","A_Id":51455870,"CreationDate":"2018-07-21T10:12:00.000","Title":"Chatterbot dynamic training","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using element.location in selenium under python 3 to find the X, Y coordinates of a given element but I don't get exact values? Any ideas why or what I should do?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":51455748,"Users Score":0,"Answer":"It could depend on the size of the window. I have tried with different size and locations were different.\nTry to set the size for browser: \nbrowser.set_window_size(1920, 1080)\nHope, this will help you.","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,ui-automation","A_Id":51482825,"CreationDate":"2018-07-21T11:47:00.000","Title":"How to get correct Location of web elements in selenium python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a small PyQt application containing 5-6 .py files. Now I want to build and compile them into a single main file, meaning it has to operate from one main window exe.\nMy .py files are connected with each other successfully. I have used pyinstaller to make the executable file, but the problem is I built each .py file into its own .exe file. But I want to make a single .exe file through which all the .py files can be used.\nHow to build all .py files into a single .exe file?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":59064,"Q_Id":51455765,"Users Score":1,"Answer":"Use the Command pyinstaller --onefile yourprogramname.py. Pyinstaller will Automatically import and Compile the Dependency Files.","Q_Score":29,"Tags":"python,pyqt5,pyinstaller","A_Id":68895428,"CreationDate":"2018-07-21T11:49:00.000","Title":"How to build multiple .py files into a single executable file using pyinstaller?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a small PyQt application containing 5-6 .py files. Now I want to build and compile them into a single main file, meaning it has to operate from one main window exe.\nMy .py files are connected with each other successfully. I have used pyinstaller to make the executable file, but the problem is I built each .py file into its own .exe file. But I want to make a single .exe file through which all the .py files can be used.\nHow to build all .py files into a single .exe file?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":59064,"Q_Id":51455765,"Users Score":0,"Answer":"Finally i got the answer. check the below command\npyinstaller -F -w  --onefile run_gui_server.py\ni am using this command it will tackcare about all .py files dependenses","Q_Score":29,"Tags":"python,pyqt5,pyinstaller","A_Id":71571440,"CreationDate":"2018-07-21T11:49:00.000","Title":"How to build multiple .py files into a single executable file using pyinstaller?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am pretty new to Python in general and recently started messing with the Google Cloud environment, specifically with the Natural Language API.\nOne thing that I just cant grasp is how do I make use of this environment, running scripts that use this API or any API from my local PC in this case my Anaconda Spyder environment? \nI have my project setup, but from there I am not exactly sure, which steps are necessary. Do I have to include the authentication somehow in the Script inside Spyder?\nSome insights would be really helpful.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2057,"Q_Id":51455781,"Users Score":-1,"Answer":"First install the API by pip install or conda install in the scripts directory of anaconda and then simply import it into your code and start coding.","Q_Score":0,"Tags":"python,google-cloud-platform","A_Id":51455824,"CreationDate":"2018-07-21T11:51:00.000","Title":"How do I use Google Cloud API's via Anaconda Spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a calendarview in Android Studio, but i am unable to find a code that will allow me to display a text after clicking on a certain date. For example, the code will allow me to show \"3 people going\" after i click on a date in the textview. The code should also allow me to program each date to display a certain message. Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":876,"Q_Id":51456497,"Users Score":0,"Answer":"For this you have to make custom message view and show this on calendar date click. its not necessary you have to use library for this, but some calendar libraries have built=in message feature.","Q_Score":0,"Tags":"java,android,python","A_Id":51457683,"CreationDate":"2018-07-21T13:21:00.000","Title":"Display text in a textview with calendar","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When creating new Python processes within PySpark driver (e.g. with JobLib or other multi-processing library), do those processes share the Spark driver memory, or are they allocated memory outside of that PySpark driver JVM?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":354,"Q_Id":51457539,"Users Score":5,"Answer":"Python driver memory is not accounted in spark.driver.memory (sames as spark.executor.memory in case of workers). spark.*.memory settings are used only for on-heap Java memory allocation.\nAll other forms of memory allocation (off-heap, native memory like in case of Python and such) are covered by spark.driver.memoryOverhead and equivalent settings.","Q_Score":2,"Tags":"python,apache-spark,pyspark","A_Id":51457824,"CreationDate":"2018-07-21T15:32:00.000","Title":"Memory Allocation of Python Sub-Processes Within Pyspark Driver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python script which opens an image file (.png or .ppm) using OpenCV, then loads all the RGB values into a multidimensional Python array (or list), performs some pixel by pixel calculations solely on the Python array (OpenCV is not used at all for this stage), then uses the newly created array (containing new RGB values) to write a new image file (.png here) using OpenCV again. Numpy is not used at all in this script. The program works fine.\nThe question is how to do this without using any external libraries, regardless whether they are for image processing or not (e.g. OpenCV, Numpy, Scipy, Pillow etc.). To summarize, I need to use bare bones Python's internal modules to: 1. open image and read the RGB values and 2. write a new image from pre-calculated RGB values. I will use Pypy instead of CPython for this purpose, to speed things up.\nNote: I use Windows 10, if that matters.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":6169,"Q_Id":51457993,"Users Score":1,"Answer":"Working with bare-bones .ppm files is trivial: you have three lines of text (P6, \"width height\", 255), and then you have the 3*width*height bytes of RGB.  As long as you don't need more complicated variants of the .ppm format, you can write a loader and a saver in 5 lines of code each.","Q_Score":2,"Tags":"python,image-processing,pypy","A_Id":51458710,"CreationDate":"2018-07-21T16:20:00.000","Title":"How to open\/create images in Python without using external modules","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Should I create a directory in my virtualenv and save the source code for that specific project there? \nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1454,"Q_Id":51459394,"Users Score":1,"Answer":"You can save your project anywhere. But you should activate the virtual environment before working on that project.\nYou can activate the virtual environment using the following command.\nsource path-to-virtualenvironment\/bin\/activate\nAfter activating the virtual environment move to your project location.","Q_Score":1,"Tags":"python,virtualenv","A_Id":51459493,"CreationDate":"2018-07-21T19:25:00.000","Title":"Where should source code be saved when working with virtualenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Apologies if my question is stupid. \nI am a newbie is all aspects.\nI used to run my python code straight from the terminal in Linux Ubuntu, \ne.g. I just open the terminal go to my folder and run my command in my Linux terminal \nCUDA_VISIBLE_DEVICES=0 python trainval_net.py --dataset pascal_voc --net resnet101 --epochs 7  --bs 1 --nw 4 --lr 1e-3 --lr_decay_step 5 --cuda\nnow im trying to use Spyder.\nSo for the same project i have a folder with bunch of functions\/folders\/stuff inside it.\nSo i just open that main folder as a new project, then i have noo idea how i can run my code...\nThere is a console in the right side of spyder which looks like Ipython and i can do stuff in there, but i cannot run the code that i run in terminal there.\nIn iphython or jupyther i used to usee ! at the begining of the command but here when i do it (e.g. !CUDA_VISIBLE_DEVICES=0 python trainval_net.py --dataset pascal_voc --net resnet101 --epochs 7  --bs 1 --nw 4 --lr 1e-3 --lr_decay_step 5 --cuda) it does not even know the modules and throw errors (e.g. ImportError: No module named numpy`)\nCan anyone tell me how should i run my code here in Spyder\nThank you in advance! :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":447,"Q_Id":51461427,"Users Score":0,"Answer":"Okay I figured it out.\nI need to go to run->configure per file and in the command line options put the configuration (--dataset pascal_voc --net resnet101 --epochs 7  --bs 1 --nw 4 --lr 1e-3 --lr_decay_step 5 --cuda)","Q_Score":0,"Tags":"python-3.x,anaconda,ubuntu-16.04,spyder","A_Id":51467364,"CreationDate":"2018-07-22T01:51:00.000","Title":"How run my code in spyder as i used to run it in linux terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using Midiutil to recreate a modified Bach contrapuntist melody and I am having difficulty finding a method for creating chords using Midiutil in python. Does anyone know a way to create chords using Midiuitl or if there is a way to create chords.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":243,"Q_Id":51462120,"Users Score":0,"Answer":"A chord consists of multiple notes.\nJust add multiple notes with the same timestamp.","Q_Score":0,"Tags":"python,midi","A_Id":51463808,"CreationDate":"2018-07-22T04:44:00.000","Title":"How to use Midiutil to add multiple notes in one timespot (or how to add chords)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using an open source package installed via pip and running inside a Jupyter Notebook IPython environment.\nI needed to modify the source of the package so I cloned the repo locally and made the changes and imported the local package instead of the installed package with no problem. \nThe problem I have is that inside the project source it imports its own package which is importing the installed package instead of the source project and causes a conflict in the code in a few cases.\nSay the package name is PackageA, originally installed via pip install PackageA. I now have the source code for Package A in libs\/ directory underneath my project directory. projectDir\/libs\/PackageA. I am importing the project via from libs.PackageA import PackageA as pa, however in the source code (in almost every file) it has import PackageA as pa.\nI can go through the source and change every instance of import PackageA as pa with from .. import PackageA as pa but this occurs in probably over 100 files as some files have multiple import statements and its also very untidy as some files are in sub directories requiring from .... import PackageA as pa. \nIs there a way to redirect the import to use the local version instead of the installed version (I have already uninstalled the pip installed version). \nI am fairly new to python (not to software development) so is there a best practice for this type of setup as I'm sure its fairly common.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":51462936,"Users Score":2,"Answer":"you could add sys.path.append(\"..\/libs\") before project start.","Q_Score":0,"Tags":"python,ipython,python-import,python-module","A_Id":51462980,"CreationDate":"2018-07-22T07:26:00.000","Title":"When running python project from source, how to avoid conflict with installed package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does Beautiful Soup work with Iron Python?\nIf so with which version of Iron Python? How easy is it to distribute a windows desktop app on .net 2.0 using Iron Python (mostly C# calling some python code for parsing html)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":195,"Q_Id":51463472,"Users Score":2,"Answer":"Most purely Python modules work with Iron Python. If it contains C, it will not work, most likely. From a quick look at the source code, you can find that BeautifulSoup4 is purely Python. Therefore, it is most likely compatible with IronPython. Hope I could help.","Q_Score":0,"Tags":".net,beautifulsoup,ironpython","A_Id":51470861,"CreationDate":"2018-07-22T08:52:00.000","Title":"Does BeautifulSoup work on IronPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We have a Linux server with Jupyterhub installed and can be accessed by users over browser, similarly we are able to access Rstudio. \nIs it possible to install Spyder on the Linux server and provide access via web browser. Multiple users will be accessing it simultaneously.  We are not looking for remote desktop or SSH solution. \nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1496,"Q_Id":51465212,"Users Score":2,"Answer":"(Spyder maintainer here) Spyder can't work inside a web browser because it's a pure desktop application, sorry.","Q_Score":0,"Tags":"python,anaconda,spyder","A_Id":51467329,"CreationDate":"2018-07-22T12:38:00.000","Title":"Access Python Spyder in Browser like Rstudio or Jupyter notebook (NOT SSH)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What is the best way to implement a multi process based consumer producer pattern with pyarrow as a fast memory store for pandas dataframes?\nCurrently I am using redis pub sub but I think there might be a more efficient (faster) solution? Could you provide an example?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":229,"Q_Id":51465320,"Users Score":1,"Answer":"Solution with lists:\nProducer puts data into a list with LPUSH\nConsumer takes data from this list with RPOP or BRPOP (blocking).\nLimitations: only one consumer reads the message. If you have 2, only one of them will see the message.\nSpeed: for one pair of consumer-producer it will have the same speed. The more consumers (for this or other lists), the faster it will be than pub\/sub.","Q_Score":1,"Tags":"python,pandas,redis,pyarrow","A_Id":51479161,"CreationDate":"2018-07-22T12:51:00.000","Title":"Consumer-producer pattern with pyarrow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed Anaconda to use it for python, however, whenever I try to launch the navigator it crashes straight away. \nI have tried reinstalling, even opening cmd and typing \"conda update conda\" but all I get is \n\"\nUnable to create process using 'C:\\Users\\Fierce PC\\Anaconda3\\python.exe \"**C:\\Users\\Fierce PC\\Anaconda3\\Scripts\\conda-script.py\" update conda' \nUnable to create process using 'C:\\Users\\Fierce PC\\Anaconda3\\python.exe \"C:\\Users\\Fierce PC\\Anaconda3\\Scripts\\conda-script.py\" shell.cmd.exe reactivate'**\n\"\nPlease, can someone tell me what i am doing wrong?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3361,"Q_Id":51466294,"Users Score":0,"Answer":"You have to go into start and use the anaconda (prompt) in your start menu.","Q_Score":1,"Tags":"python,crash,installation,anaconda","A_Id":63623493,"CreationDate":"2018-07-22T14:52:00.000","Title":"Anaconda Crashes Every time I launch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I have just switched over from Spyder to PyCharm. In Spyder, each time you run the program, the console just gets added to, not cleared. This was very useful because I could look through the console to see how my changes to the code were changing the outputs of the program (obviously the console had a maximum length so stuff would get cleared eventually)\nHowever in PyCharm each time I run the program the console is cleared. Surely there must be a way to change this, but I can't find the setting. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":798,"Q_Id":51466944,"Users Score":1,"Answer":"In Spyder the output is there because you are running iPython.\nIn PyCharm you can get the same by pressing on View -> Scientific Mode.\nThen every time you run you see a the new output and the history there.","Q_Score":1,"Tags":"python,console,pycharm,settings","A_Id":51466984,"CreationDate":"2018-07-22T16:11:00.000","Title":"PyCharm, stop the console from clearing every time you run the program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to only use the base decision tree that is used in the XGBoost algorithm?\nI know that Sklearn's GBT just uses a Sklearn Decision Tree as their base but XGBoost builds trees differently (e.g. regularization of the leaf weights).\nI looked at the code for XGBoost but I wasn't able to figure out how they built their base tree.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":51467350,"Users Score":0,"Answer":"There are 2 solutions for you:\n\nBuild only 1 tree (meaning use only 1 iteration), that means that when you train use num_boost_round=1\nWhen you predict use ntree_limit=1\n\nEither one will solve your problem. You either train only 1 tree or you predict using only 1 tree.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,xgboost","A_Id":51473577,"CreationDate":"2018-07-22T16:56:00.000","Title":"Use Base Tree from XGBoost","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a weird issue.\nMain issue:\nMy .py files that used to work fine like 3 hours ago now can't import any external modules. I can still run them from Spyder (similar to a PyCharm editor) and from CMD with python run.py. However when clicked on I get the error ModuleNotFoundError: No module named ModuleName. However the module is found when running through everything else, the module is there in the Anaconda libs; the folder doesn't have any permisson restrictions, and it's not just one file it's any .py file that imports an external module.\nAt first I thought this may be a pip issue as I had just update to pip 18, but even when retracting to pip 10.0.1 the issue remains.\n[EDIT]: I've tried making a PyInstaller .exe and that still works as intended, however the app still doesn't work with cx_freeze even though it used to a fez hours ago.\nBackstory:\nI was playing around with PyInstaller and Cx_Freeze to turn my app into an executable.\nI have my working .py file that I edit and test inside of the Anaconda's Spyder app.\nAnd so I'm testing the executables, and they work fine, just like my python code. The Pyinstaller standalone and the cx_freeze app work as intended.\nSo I change a few things in the main .py file (nothing crazy just removed a print('')), reuse cx_freeze and then at some point I start working on a setup wizard for my cx_freezed app.\nIt's all good except that when running the app, the cmd prompt just closes.\nI think 'huh weird', I test the .py file in Spyder it works fine, so I screenshot what's written on the cmd : ModuleNotFoundError: No module named ModuleName, so I think it's an issue with the Wizard installer, so I try the original .exe file, same error. So I try the .py file and to my desmise, same error. I double check the modules, reinstall them succesfully, error persists.\nAnd so I try to run a backup I know for sure worked and in which I haven't edited anything, and now same error.\nThis is really anoying as I want to make a .exe of the app, managed to and now nothing works anymore","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":952,"Q_Id":51469009,"Users Score":1,"Answer":"I think you used the wrong version when you converted from a .py to .exe. Generally the CMD uses whatever's in the ENV vars, so just make sure all version numbers are the same.","Q_Score":1,"Tags":"python,python-3.x,module,pip","A_Id":51469068,"CreationDate":"2018-07-22T20:30:00.000","Title":"Suddenly .py files can't import modules but still works with CMD","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I loaded a ducking png for my sprite, so when I press the down arrow, he ducks and when he ducks the rectangle gets smaller, which is good, but the rectangle seems like the sprite is floating instead of ducking at the place he is. It's like he sits on the air. How can I fix it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":59,"Q_Id":51469366,"Users Score":1,"Answer":"Two options - \n\nYou could make the ducking graphic the same size as the regular standing graphic, and just place the sprite in the bottom part of the image (with the rest transparent)\nYou could reposition the box manually to move the y-position nearer to the ground when the ducking occurs\n\nOf these, the first is the easiest to implement, but the second would be necessary if you're also using the rectangle for e.g. hit-testing.","Q_Score":0,"Tags":"python,pygame","A_Id":51469391,"CreationDate":"2018-07-22T21:22:00.000","Title":"How can I make a sprite duck with a ducking png?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been coding in python for a couple months now, and something has always been on my mind. I know you can have classes in your .py file, but you don't have to. My question is, is it good practice to always have your code in a class, or is it not necessary? \nFYI: I have been coding in Java for a few years, so I'm used to always having a \"main\" class and a main method that runs everything.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":196,"Q_Id":51469627,"Users Score":1,"Answer":"It depends on what your file is. In theory everything (saying this with some hesitation) can be written as a class. But it is a bit overkill to do that just for the sake of being \"correct\" and will probably make your code look strange rather than clear. In general i would make the following distinctions between cases\n\nIf it is the source for a big project which makes sense to be organized in an object oriented fashion, then you would have a class which defines exactly that. This is great because then you can inherit the class for variants or child projects.\nIf you are creating a list of utility functions to use for all your projects, such as array manipulations or little tools that are always handy, then a function-only file is the way to go\nIf you are writing a script which is designed in order to execute a specific task in the way a script would, then i would define task-specific source in a .py file and include the code related to the execution under the statement\nif name == 'main':","Q_Score":1,"Tags":"java,python,class,compilationunit","A_Id":51469812,"CreationDate":"2018-07-22T22:04:00.000","Title":"Should a python file always include a class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running the jupyter notebook (Enthought Canopy python distribution 2.7) on Mac OSX (v 10.13.6).  When I try to import pandas (import pandas as pd), I am getting the complaint: ImportError: dateutil 2.5.0 is the minimum required version. I have these package versions:\n\nCanopy version 2.1.3.3542 (64 bit)\njupyter version 1.0.0-25\npandas version 0.23.1-1\npython_dateutil version 2.6.0-1\n\nI'm not getting this complaint when I run with the Canopy Editor so it must be some jupyter compatibility problem.  Does anyone have a solution on how to fix this?  All was well a few months ago until I recently (and mindlessly) allowed an update of my packages.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":17899,"Q_Id":51470373,"Users Score":0,"Answer":"The issue is with the pandas lib\ndowngrade using the command below\npip install pandas==0.22.0","Q_Score":7,"Tags":"python,pandas,jupyter-notebook,canopy,python-dateutil","A_Id":64066254,"CreationDate":"2018-07-23T00:44:00.000","Title":"dateutil 2.5.0 is the minimum required version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running the jupyter notebook (Enthought Canopy python distribution 2.7) on Mac OSX (v 10.13.6).  When I try to import pandas (import pandas as pd), I am getting the complaint: ImportError: dateutil 2.5.0 is the minimum required version. I have these package versions:\n\nCanopy version 2.1.3.3542 (64 bit)\njupyter version 1.0.0-25\npandas version 0.23.1-1\npython_dateutil version 2.6.0-1\n\nI'm not getting this complaint when I run with the Canopy Editor so it must be some jupyter compatibility problem.  Does anyone have a solution on how to fix this?  All was well a few months ago until I recently (and mindlessly) allowed an update of my packages.","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":17899,"Q_Id":51470373,"Users Score":3,"Answer":"I had this same issue using the newest pandas version - downgrading to pandas 0.22.0 fixes the problem.\npip install pandas==0.22.0","Q_Score":7,"Tags":"python,pandas,jupyter-notebook,canopy,python-dateutil","A_Id":55159160,"CreationDate":"2018-07-23T00:44:00.000","Title":"dateutil 2.5.0 is the minimum required version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running the jupyter notebook (Enthought Canopy python distribution 2.7) on Mac OSX (v 10.13.6).  When I try to import pandas (import pandas as pd), I am getting the complaint: ImportError: dateutil 2.5.0 is the minimum required version. I have these package versions:\n\nCanopy version 2.1.3.3542 (64 bit)\njupyter version 1.0.0-25\npandas version 0.23.1-1\npython_dateutil version 2.6.0-1\n\nI'm not getting this complaint when I run with the Canopy Editor so it must be some jupyter compatibility problem.  Does anyone have a solution on how to fix this?  All was well a few months ago until I recently (and mindlessly) allowed an update of my packages.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":17899,"Q_Id":51470373,"Users Score":0,"Answer":"Installed Canopy version 2.1.9.  The downloaded version worked without updating any of the packages called out by the Canopy Package Manager.  Updated all the packages, but then the \"import pandas as pd\" failed when using the jupyter notebook.  Downgraded the notebook package from 4.4.1-5 to 4.4.1-4 which cascaded to 35 additional package downgrades.  Retested the import of pandas and the issue seems to have disappeared.","Q_Score":7,"Tags":"python,pandas,jupyter-notebook,canopy,python-dateutil","A_Id":51471337,"CreationDate":"2018-07-23T00:44:00.000","Title":"dateutil 2.5.0 is the minimum required version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After I installed pycurl, there is an error occured like this when I test my code.\nOS: Ubuntu 16.04 LTS\npython: 3.6.5\ncurl: 7.47.0-1ubuntu2.8\npycurl: 7.43.0.1\nIs there any solution I can solve that? Thank you !","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":768,"Q_Id":51472336,"Users Score":0,"Answer":"Anyway, I solved the problem finally. \nHere are 2 errors I face:\npycurl.error: (1, 'Protocol https not supported or disabled in libcurl')\nImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none\/other).\nSolution:\n1)apt-get install openssl\n2)export PYCURL_SSL_LIBRARY=openssl\n3)easy_install pycurl \nFor some reason, the pip ingore the PYCURL_SSL_LIBRARY. I have to use easy_install.","Q_Score":1,"Tags":"python,pycurl","A_Id":51504001,"CreationDate":"2018-07-23T05:56:00.000","Title":"pycurl.error: (1, 'Protocol https not supported or disabled in libcurl') Ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm parsing system arguments in my Python project using sys.argv. At some point i had to modify the script after having written the logic that parses system args. I added a line the basically appends a string to sys.argv so the logic that parses it won't be changed - \nsys.argv.append('some string here')\nIs it a bad practice to modify the system arguments after they have been created for the program ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4980,"Q_Id":51472873,"Users Score":3,"Answer":"It is bad  practice to modify sys.argv in Python and it's equivalent in other languages.\nIn these situations I recommend a parsed_args variable which has all your parsed data from sys.argv, any default values that you would like to set, and any modifications that \"middleware\" would make.","Q_Score":3,"Tags":"python,command-line-arguments","A_Id":51473045,"CreationDate":"2018-07-23T06:37:00.000","Title":"Python append to system arguments - bad practice?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to write a steganography applcation using the LSB method and it works so far well enough for a few image formats .\nHowever it doesn't work for GIF images since i have noticed that the saved gif has a few different pixel values (usually +- 1) and the LSB method relies on changing the least significant bit so a few different values throws the decoding algorithm off.\ni have tried using both imageio and PIL.Image and it's the same problem in both cases\nSo basically my question is : Why does the pixel values change when saved and is it even possible to use LSB for encoding and decoding a GIF ?\nThanks for your help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":352,"Q_Id":51476405,"Users Score":1,"Answer":"Gif is lossless it should not change the pixels, I recently did a little application using LSB method with gif format here is few things you should do:\n\nmake sure when you encoded right, try replacing the pixel(0,0) then verify if the value is change if not so check the decoding\nmake sure that the gif color is 255 \nyou will encounter this later but you should put the original metadata and delay time when assembling the frames\n\nThese are the main issues, other than that as I said earlier it is a lossless compression just like png it should not change the pixels so the problem is either in coding\/decoding or type of the RGB color.","Q_Score":0,"Tags":"python,python-imaging-library,gif,python-imageio","A_Id":51505839,"CreationDate":"2018-07-23T10:16:00.000","Title":"Why does GIF pixel values change when saved in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I usually run a python script from mobaxterm. The process runs smoothly but today i got this error that I have never come across before. When i google it, nothing comes out.\nAny ideas what \n\"Illegal instruction (core dumped)\" mean\n?\nThanks a lot","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":51476564,"Users Score":0,"Answer":"the issue is coming from our server- just got the info from our IT department. please ignore the question","Q_Score":0,"Tags":"python-3.x,unix","A_Id":51479764,"CreationDate":"2018-07-23T10:23:00.000","Title":"python mobaxterm + Illegal instruction (core dumped)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am starting to look into Python from a learning perspective and I am finding it nice and easy after Java.\nI am currently looking at working with files and I am using the 'with open()' command to make use of the open file only whilst the program is running. \nHowever, all the tutorials I seem to come across only ever seem to hard code either a filename or file path into the open() command. \nIn Python or any of its libraries - does anyone know of a command I can use to allow the user a pop-up window to navigate and select where the file lives? \nKind Regards","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":384,"Q_Id":51479353,"Users Score":0,"Answer":"Try using tkinter. tkinter is Python's de-facto standard GUI (Graphical User Interface) package.  I will show an example\nEither you can ask with this: \n\na_var = input('select directory of the file')\n\nand then use the a_var to use the directory provided by the user \nor \n\nUse tkinter to ask the user to browse to the needed location","Q_Score":0,"Tags":"python,input","A_Id":51479397,"CreationDate":"2018-07-23T12:55:00.000","Title":"Open() in Python - Does a popup window exist?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need a means to make accessible a PR from a fork submitted to a repository via GitPython. Once I have the PR and it's commits available I should be able to use it how I plan to, but so far haven't seen any support to pull\/clone commits included in a Peer Review from a fork. Does anyone know if this isn't supported or am I overlooking it? \nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":51484682,"Users Score":0,"Answer":"It took longer than I'd like to admit, but I believe I figured out what was needed. \nrepo = git.Repo('name_of_repo')\nrepo.remotes.fetch(refspec='pull\/#\/head')","Q_Score":0,"Tags":"python,python-3.x,git,github","A_Id":51486546,"CreationDate":"2018-07-23T17:54:00.000","Title":"How to obtain PR form git via GitPython","Data Science and Machine Learning":0,"Database and SQL":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 images of vehicles . I need to predict the price of the vehicle based on image extraction. \nWhat I have learnt is , I can use CNN to extract the image features but what I am not able to get is, How to predict the prices of vehicles. \nI know that the I need to train my CNN model before it predicts the price. \nI don't know how to train the model with images along with prices .\nIn the end what I expect is , I will input an vehicle image and I need to get price of the vehicle. \nCan any one provide the approach for this ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":268,"Q_Id":51484727,"Users Score":0,"Answer":"I would use the CNN to predict the model of the car and then using a list of all the car prices it's easy enough to get the price, or if you dont care about the car model just use the prices as lables","Q_Score":0,"Tags":"python,tensorflow","A_Id":67088725,"CreationDate":"2018-07-23T17:57:00.000","Title":"CNN image extraction to predict a continuous value","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got quite a complicated GUI interface built by Tkinter library. It has several tabs and a lot of controls with possibility of dynamic adding and deleting them.\nAnd it seems that Tkinter has an internal maximum number of widgets, something about 10000 (including Frames). When it is exceeded new widgets are not created and even some strange graphical effects can appear outside the window (without any exceptions or messages). \nDid anyone face such problems? I wonder if there is a way to overcome this limitation.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":798,"Q_Id":51486281,"Users Score":0,"Answer":"From my experience, there is a way to have more than 10000 widgets, but not simultaneously.\nIf you destroy() the widgets you don't currently need, you can have more than 10000 during the lifetime of the application.\nApplication needs don't always allow it, but in your case, maybe you could destroy the unused tabs while they are not selected?","Q_Score":1,"Tags":"python,tkinter","A_Id":63578199,"CreationDate":"2018-07-23T19:50:00.000","Title":"Tkinter maximum number of widgets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got quite a complicated GUI interface built by Tkinter library. It has several tabs and a lot of controls with possibility of dynamic adding and deleting them.\nAnd it seems that Tkinter has an internal maximum number of widgets, something about 10000 (including Frames). When it is exceeded new widgets are not created and even some strange graphical effects can appear outside the window (without any exceptions or messages). \nDid anyone face such problems? I wonder if there is a way to overcome this limitation.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":798,"Q_Id":51486281,"Users Score":0,"Answer":"I have reached a similar problem. (migrating to QT is way too bothersome for me at the moment)\nMy solution is to \"paginate\" the data shown, so I can have a fixed number of widgets and just rewrite them based on the page I'm on.","Q_Score":1,"Tags":"python,tkinter","A_Id":65823399,"CreationDate":"2018-07-23T19:50:00.000","Title":"Tkinter maximum number of widgets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using numpy to analyze graphs.  One type of analysis I am doing is traversing, while enumerating: \"how often is node K in a path with node J, up to this point\". In this analysis, many of my values are ratios, or percentages, or however you want to think of it.\nSince graphs often branch, they are often exponential when it comes to combinations or permutations.  And so, some of the time, my ratios become very small.  And, numpy loses accuracy.  And, eventually, numpy says that the ratio is zero even though it should still be greater than zero.\nTo elaborate a bit more, I use rows of the matrix to represent depth of my search, and I use columns to represent nodes.  The value of the [row,column] is the ratio of said node, at said depth, to whatever other node I am comparing it to.  And so it's the case, that depending upon the graph, that ratio may be cut in half at every next level.  From 1, to .5, to .25, to ..... 1.369^(-554) and suddenly it's zero next iteration.  Not to mention, when it gets small enough I lose accuracy in all my other calculations as well.\nIf I want extreme accuracy even on large graphs, what options do I have?  I suppose I could enumerate in the opposite direction, getting total counts and doing division to recalculate ratios when necessary (it is necessary at time in my program).  But if I do this, I still expect I would lose a ton of accuracy when I divide one huge number by another huge number, yes?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":51487174,"Users Score":2,"Answer":"All your ratios are rational numbers, so you could use the Fraction class in the fractions module. Each \"fraction\" is the ratio of two integers. And since Python's integers have no upper limit, neither do the fractions. You can treat them much like float values--add, subtract, multiply, divide, and print them.\nI did something very much like your operations in a previous project of mine, to track ratios in the tree structure of Windows Registry. I did this project in Delphi but have started redoing it in Python. I have already decided to use fractions.\nThe problem is that the values will be kept exactly, as well as the operations on them. But if you plot them on a graph, the values may still be overwhelmed by other values.","Q_Score":1,"Tags":"python,numpy,math,types,numbers","A_Id":51487294,"CreationDate":"2018-07-23T21:00:00.000","Title":"Maintaining accuracy of ratios in numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Apparently there is not an easy way to remove a model from cloud-ml, not with the UI or using the python API. Does anybody know a fast way to remove a model with all its versions from cloud-ml ?.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":774,"Q_Id":51488117,"Users Score":1,"Answer":"The ways suggested above are the correct ways of deleting a model, i.e. versions first (non-default, then default) and then the model itself. We are aware that this  might be cumbersome and are working towards making this interface easier for our users. One way could be to have something that basically recursively deletes the versions and models. Are there other ways this can be done that will be more suitable?","Q_Score":0,"Tags":"python,google-cloud-platform,google-cloud-ml","A_Id":51507745,"CreationDate":"2018-07-23T22:42:00.000","Title":"remove a model and all its versions from cloud-ml","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wanna build a custom server for some project and I don't know whats the difference between asyncore and asyncio server, what is better to use, and why","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1737,"Q_Id":51488632,"Users Score":4,"Answer":"asyncore is the \"old\", Python 2 way of doing some basic event-driven servers and clients (in other words, for doing asynchronous IO).\nasyncio is the new, Python 3 module that provides a whole framework for doing asynchronous IO in general. It has much more features, including support for coroutines, which allow you to use keywords like async def and await, which improve readability of asynchronous code.\nIn summary, asyncio is the way to go. asyncore is not recommended in Python 3, which new projects should be using instead of Python 2. If you are stuck with Python 2, asyncore is a sane choice.","Q_Score":2,"Tags":"python,python-asyncio,asyncsocket,asyncore","A_Id":51488960,"CreationDate":"2018-07-23T23:52:00.000","Title":"asyncio vs asyncore for custom server python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Question 1\nDoes the rotation_range: Int. Degree range for random rotations refer to the range [0, rotation_range] or [-rotation_range, rotation_range]. If I set rotation_range=40, will my images be randomly rotated between [-40, 40] or [0, 40]?\nQuestion 2\nDoes ImageDataStore.flow randomly generate different augmentations of an input image at every epoch or is a single augmentation generated at the start and used for all epochs. \nFor example, let's say I have some image A that is part of my inputs into the flow method. Is image A augmented only once before training, and this augmented version used for all epochs? Or is image A randomly augmented every epoch?\nQuestion 3\nWhen the param shuffle is set to True in the flow method, does this mean the batches are shuffled every epoch, or the images within the batches are shuffled every epoch? \nFor example, lets say our training data consists of 15 images (labeled I1 - I15) is divided into 3 batches\/mini-batches before epoch 1 starts (labeled B1, B2, B3). \nLets say before epoch 1, the images were assigned to the batches as follows:\n\nB1 = {I1, I2, I3, I4, I5}\nB2 = {I6, I7, I8, I9, I10}\nB3 = {I11, I12, I13, I14, I15}\n\nNow in epoch 1, the batches are trained in the order B1, B2, B3. \nWhen epoch 2 starts, will the images in B1, B2, B3 be shuffled so that each batch will not contain the same set of 5 images?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1238,"Q_Id":51489390,"Users Score":1,"Answer":"Question 1\nThe rotation range is [-rotation_range, rotation_range]. I suggest you to check your augmented images by using the parameter save_to_dir in the method flow. This way you can be sure that the images are being augmented as you expect.\nQuestion 2\nWhen calling next, a random augmentation is applied to every image right after it's being loaded, according to the parameters you gave to the constructor of ImageDataGenerator. I.e. an image can be left rotated in one epoch and in the next epoch the same image can be right rotated. That's what makes augmentation so efficient- you artificially increase the size of your data.\nQuestion 3 \nThe list of images is shuffled before each epoch. A batch of images will never repeat itself (well... you can calculate the odds)","Q_Score":0,"Tags":"python,keras,image-preprocessing","A_Id":51494847,"CreationDate":"2018-07-24T01:59:00.000","Title":"Understanding parameters in ImageDataGenerator and flow in Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After moving over to Fedora (from Windows), I realized that it came with both installations of Python 2.7.5 and Python 3.6.6.\nAs I familiarized myself with using Python, I learned of the great utilities of virtual environments and how organized they keep everything.\nHowever, my current dilemma is for which Python version should I do pip(2 or 3) install virtualenv virtualenvwrapper.\nFrom my research, I understand that the virtualenvwrapper provides the ability to create a virtual environment using a specified version of Python: mkvirtualenv -p \/usr\/bin\/python(2 or 3) {name}.\nTherefore, should I only install virtualenv and virtualenvwrapper on one of the Python versions and use the aforementioned feature? Or should I install virtualenv and virtualenvwrapper on both versions of Python.\nWould there be any conflicts?\nEdit\nMore importantly, assuming that I have virtualenv and virtualenvwrapper installed for both Python 2.7.5 and Python 3.6.6, which version's command is called when I run any of the following: workon, mkvirtualenv, rmvirtualenv, etc.?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2242,"Q_Id":51490737,"Users Score":0,"Answer":"Would there be any conflicts?\n\nNot until you mistakenly run the default system python command with a script that's using the opposite version as compared to the more specific python2 or python3 commands.\nThe virtualenvs do not conflict, and must be activated to be used. You can also of course have as many virtualenv's as you wish. \nTo avoid any problems setting up an environment, its suggested to run python2 -m virtualenv for example, rather than simply virtualenv command itself\nFor the commands listed at the bottom of the question, it depends on how your PATH is configured. Personally, I use pyenv rather than virtualenv directly, which injects itself into the OS PATH variable","Q_Score":1,"Tags":"python,python-3.x,python-2.7,virtualenv,virtualenvwrapper","A_Id":51491042,"CreationDate":"2018-07-24T04:56:00.000","Title":"Python: Install VirtualEnv for both Python 2 and Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to handle the event when the shutdown process is started(for example with long press the robot's chest button or when the battery is critically low). The problem is that I didn't find a way to handle the shutdown\/poweroff event. Do you have any idea how this can be done in some convenient way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":51498056,"Users Score":2,"Answer":"Unfortunately this won't be possible as when you trigger a shutdown naoqi will exit as well and destroy your service. \nIf you are coding in c++ you could use a destructor, but there is no proper equivalent for python... \nAn alternative would be to execute some code when your script exits whatever the reason. For this you can start your script as a service and wait for \"the end\" using qiApplication.run(). This method will simply block until naoqi asks your service to exit. \nNote: in case of shutdown, all services are being killed, so you cannot run any command from the robot API (as they are probably not available anymore!)","Q_Score":0,"Tags":"python,nao-robot,pepper,choregraphe","A_Id":51566036,"CreationDate":"2018-07-24T11:59:00.000","Title":"How can I handle Pepper robot shutdown event?","Data Science and Machine Learning":0,"Database and SQL":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":"Just wondering if there is any way to install Deep Mind's Sonnet library with Anaconda yet. On the site it says to use conda install -c hcc dm-sonnet, however that provides a PackageNotFoundError because this method only works on Linux distributions and I'm currently using macOS. \nIf this is not possible and I use pip to install the Sonnet package, will this produce any errors since I use conda as my main distribution system?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":665,"Q_Id":51501890,"Users Score":1,"Answer":"Anaconda comes with it's own pip and packages installed with that will work fine together with the rest of your anaconda environment. Try to run which pip and see if that is in the anaconda path.\nThere can be some issues if the dependencies required from pip doesn't match up with what is required in your anaconda environment. However you can always pip uninstall if it breaks anything.","Q_Score":0,"Tags":"python,tensorflow,anaconda","A_Id":51502157,"CreationDate":"2018-07-24T15:02:00.000","Title":"Installing Sonnet with Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I currently have macros set up to automate all my reports. However, some of my macros can take up to 5-10 minutes due to the size of my data. \nI have been moving away from Excel\/VBA to Python\/pandas for data analysis and manipulation. I still use excel for data visualization (i.e., pivot tables). \nI would like to know how other people use python to automate their reports? What do you guys do? Any tips on how I can start the process? \nMajority of my macros do the following actions - \n\nImport text file(s)\nPaste the raw data into a table that's linked to pivot tables \/ charts.\nRefresh workbook \nSave as new","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":606,"Q_Id":51503471,"Users Score":0,"Answer":"When using python to automate reports I fully converted the report from Excel to Pandas. I use pd.read_csv or pd.read_excel to read in the data, and export the fully formatted pivot tables into excel for viewing. doing the 'paste into a table and refresh' is not handled well by python in my experience, and will likely still need macros to handle properly ie, export a csv with the formatted data from python then run a short macro to copy and paste.\nif you have any more specific questions please ask, i have done a decent bit of this","Q_Score":0,"Tags":"python,excel,vba,pandas,reporting","A_Id":51503697,"CreationDate":"2018-07-24T16:25:00.000","Title":"Python - pandas \/ openpyxl: Tips on Automating Reports (Moving Away from VBA).","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to train a new model using my own dataset. I will be\n  using Darkflow\/Tensorflow for it.\n\nRegarding my doubts:\n(1) Should we resize our training images for a specific size?\n(2) I think smaller images might save time, but can smaller images harm the accuracy?\n(3) And what about the images to be predicted, should we resize them as well or is it not necessary?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4420,"Q_Id":51505729,"Users Score":3,"Answer":"(1) It already resize it with random=1 in .cfg file.The answer is \"yes\".The input resolution of images are same.You can resize it by yourself or Yolo can do it.\n(2)If your hardware is good enough,I suggest you to use big sized images.Also as a suggest,If you will use webcam,use images as the same resolutions as your webcam uses.\n(3)Yes, same as training.","Q_Score":4,"Tags":"python,tensorflow,yolo,darknet,darkflow","A_Id":57576484,"CreationDate":"2018-07-24T18:55:00.000","Title":"Is image resizing needed to training a new Yolo model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used to work in Matlab and it is really convenient (when working with big arrays\/matrices and nested functions) to visualize intermediate results during debugging using plot function. \nIn Python I cannot plot anything in debug mode: a window with figure plot is never loaded (I am using Spyder IDE for coding and matplotlib.pyplot for plotting).\nThis is really annoying when debugging nested function and classes. \nDoes anyone know a good solution? Of course, I can always output intermediate results, however it is not convenient. \nThanks,\nMikhail","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2174,"Q_Id":51506354,"Users Score":6,"Answer":"Ok, I found a way to show the plot without breaking the debugging process.\nAll you need to do is to issue plt.pause(1) command, which will display the plots, and then one can continue the debugging process.","Q_Score":3,"Tags":"python,debugging,matplotlib","A_Id":60745616,"CreationDate":"2018-07-24T19:37:00.000","Title":"Plot a function during debugging in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on a program that would take the previous 4000 days of stock data about a particular stock and predict the next 90 days of performance.\nThe way I've elected to do this is with an RNN that makes use of LSTM layers to use the previous 90 days to predict the next day's performance (when training, the previous 90 days are the x-values and the next day is used as the y-value). What I would like to do however, is use the previous 90-180 days to predict all the values for the next 90 days. However, I am unsure of how to implement this in Keras as all the examples I have seen only predict the next day and then they may loop that prediction into the next day's 90 day x-values.\nIs there any ways to just use the previous 180 days to predict the next 90? Or is the LSTM restricted to only predicting the next day?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":51506404,"Users Score":0,"Answer":"I don't have the rep to comment, but I'll say here that I've toyed with a similar task. One could use a sliding window approach for 90 days (I used 30, since 90 is pushing LSTM limits), then predict the price appreciation for next month (so your prediction is for a single value). @Digital-Thinking is generally right though, you shouldn't expect great performance.","Q_Score":0,"Tags":"python,tensorflow,keras,lstm,rnn","A_Id":51526725,"CreationDate":"2018-07-24T19:41:00.000","Title":"How to make RNN time-forecast multiple days using Keras?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using keras-rl to train my network with the D-DQN algorithm. I am running my training on the GPU with the model.fit_generator() function to allow data to be sent to the GPU while it is doing backprops. I suspect the generation of data to be too slow compared to the speed of processing data by the GPU.\nIn the generation of data, as instructed in the D-DQN algorithm, I must first predict Q-values with my models and then use these values for the backpropagation. And if the GPU is used to run these predictions, it means that they are breaking the flow of my data (I want backprops to run as often as possible).\nIs there a way I can specify on which device to run specific operations? In a way that I could run the predictions on the CPU and the backprops on the GPU.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":8487,"Q_Id":51507285,"Users Score":7,"Answer":"Maybe you can save the model at the end of the training. Then start another python file and write os.environ[\"CUDA_VISIBLE_DEVICES\"]=\"-1\"before you import any keras or tensorflow stuff. Now you should be able to load the model and make predictions with your CPU.","Q_Score":5,"Tags":"python,tensorflow,keras,keras-rl","A_Id":51570129,"CreationDate":"2018-07-24T20:47:00.000","Title":"Keras with Tensorflow backend - Run predict on CPU but fit on GPU","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Quick question: I have a python application with 3 tabs. Is it possible to read the state of a control on tab 2 from tab 1? That is, on tab 1 I have a run button. When clicking this I want to determine which checkboxes are checked on tab 2. \nShould be quite simple, but I can't seem to suss it!\nMany thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":51507453,"Users Score":0,"Answer":"It should be possible, yes. All the controls are usually private members of the wxFrame class. I don't really understand what is the problem.","Q_Score":0,"Tags":"python,wxpython","A_Id":54845411,"CreationDate":"2018-07-24T20:59:00.000","Title":"Python wx.notebook tab's controls - reading one from another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python Kafka worker run by a bash script in a Docker image inside a docker-compose setup that I need to reload and restart whenever a file in its directory changes, as I edit the code. Does anyone know how to accomplish this for a bash script?\nPlease don't merge this with the several answers about running a script whenever a file in a directory changes. I've seen other answers regarding this, but I can't find a way to run a script once, and then stop, reload and re-run it if any files change.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":260,"Q_Id":51507787,"Users Score":1,"Answer":"My suggestion is to let docker start a wrapper script that simply starts the real script in the background.\nThen in an infinite loop:\n\nusing inotifywait the wrapper waits for the appropriate change\nthen kills\/stop\/reload\/... the child process \nstarts a new one in the background again.","Q_Score":0,"Tags":"python,bash,unix,filesystems,reload","A_Id":51511825,"CreationDate":"2018-07-24T21:28:00.000","Title":"How do you setup script RELOAD\/RESTART upon file changes using bash?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm not sure if the Tensorflow ObjectDetection API automatically normalizes the input images (my own dataset). It seems to have an option called 'NormalizeImage' in the DataAugmentations. So far, I haven't specified it, and my models are doing reasonably well. Am I missing image normalization, or does Tensorflow do it automatically for me, or is it just not needed for this Object Detection API?\nMy models have used Faster RCNN and RetinaNet so far.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":372,"Q_Id":51509083,"Users Score":0,"Answer":"Depending on what configuration you specified it uses an image resizer to normalize your dataset.\nimage_resizer {\n  fixed_shape_resizer {\n    height: 300\n    width: 300\n  }\n}\nThis will either downsample or upsample your images using bilinear interpolation.","Q_Score":1,"Tags":"python,tensorflow,object-detection,object-detection-api","A_Id":51544489,"CreationDate":"2018-07-24T23:52:00.000","Title":"Need to NormalizeImage if using Tensorflow's ObjectDetection API?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've created a kivy app that works perfectly as I desire. It's got a few files in a particular folder that it uses. For the life of me, I don't understand how to create an exe on mac. I know I can use pyinstaller but how do I create an exe from mac.\nPlease help!","AnswerCount":2,"Available Count":2,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1152,"Q_Id":51515471,"Users Score":-2,"Answer":"This is easy with Pyinstaller. I've used it recently.\nInstall pyinstaller\n\npip install pyinstaller\n\nHit following command on terminal where file.py is path to your main file\n\npyinstaller -w -F file.py\n\nYour exe will be created inside a folder dist\nNOTE : verified on windowns, not on mac","Q_Score":1,"Tags":"python,kivy,pyinstaller,kivy-language","A_Id":51515669,"CreationDate":"2018-07-25T09:28:00.000","Title":"Creating an exe file for windows using mac for my Kivy app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've created a kivy app that works perfectly as I desire. It's got a few files in a particular folder that it uses. For the life of me, I don't understand how to create an exe on mac. I know I can use pyinstaller but how do I create an exe from mac.\nPlease help!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1152,"Q_Id":51515471,"Users Score":1,"Answer":"For pyinstaller, they have stated that packaging Windows binaries while running under OS X is NOT supported, and recommended to use Wine for this.\n\n\nCan I package Windows binaries while running under Linux?\n\nNo, this is not supported. Please use Wine for this, PyInstaller runs\n  fine in Wine. You may also want to have a look at this thread in the\n  mailinglist. In version 1.4 we had build in some support for this, but\n  it showed to work only half. It would require some Windows system on\n  another partition and would only work for pure Python programs. As\n  soon as you want a decent GUI (gtk, qt, wx), you would need to install\n  Windows libraries anyhow. So it's much easier to just use Wine.\n\nCan I package Windows binaries while running under OS X?\n\nNo, this is not supported. Please try Wine for this.\n\nCan I package OS X binaries while running under Linux?\n\nThis is currently not possible at all. Sorry! If you want to help out,\n  you are very welcome.","Q_Score":1,"Tags":"python,kivy,pyinstaller,kivy-language","A_Id":51515517,"CreationDate":"2018-07-25T09:28:00.000","Title":"Creating an exe file for windows using mac for my Kivy app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have following string \n\n'100000|^104,500|^^0^0^0^0^0^0^0|^^^^^^^^^412824|103000|103000|103000|103000^^'\n\nHow to sum last 5 integers after |^^^^^^^^^ till ^^ separated by |.\nI tried re.split('[|^^^^^^^^^]', string) but it splits using |^ delimiter and returns list.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":51516628,"Users Score":0,"Answer":"A fully-regex solution could use this regex:\n.+\\|\\^{9}|[\\^\\|]+\nYou can split using this regex. The resulting array will contain some empty elements, however, you can easily check for them while adding.","Q_Score":0,"Tags":"python,regex","A_Id":51516997,"CreationDate":"2018-07-25T10:28:00.000","Title":"split string using re and add integers in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to django and using the anaconda cloud environment. Its been working well for 3 months plus but as of 7-24-2018 it is just stop to launch the navigator or open through cmd. I can't manage environments or install packages. Using the anaconda prompt also gives me the same error upon launching. It started when I wanted to install django-Oscar, but not having its dependencies I was forced to install the packages manually which in turn needed cytoolz that needs Microsoft Visual C++ build tools which I got to install as well but the error persists. Please help me!\nCopy\/Paste of CMD Traceback:\n\nC:\\Users\\kaukau\\Desktop>conda --version conda 4.5.4\nC:\\Users\\kaukau\\Desktop>anaconda-navigator Traceback (most recent call\n  last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\qtpy__init__.py\", line\n  169, in \n      from PySide import version as PYSIDE_VERSION  # analysis:ignore ModuleNotFoundError: No module named 'PySide'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\Scripts\\anaconda-navigator-script.py\", line\n  6, in \n      from anaconda_navigator.app.main import main   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\anaconda_navigator\\app\\main.py\",\n  line 22, in \n      from anaconda_navigator.utils.conda import is_conda_available   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\anaconda_navigator\\utils__init__.py\",\n  line 15, in \n      from qtpy.QtGui import QIcon   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\qtpy__init__.py\", line\n  175, in \n      raise PythonQtError('No Qt bindings could be found') qtpy.PythonQtError: No Qt bindings could be found\nC:\\Users\\kaukau\\Desktop>conda install qt --force Traceback (most\n  recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 42, in \n      from cytoolz.dicttoolz import merge   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\cytoolz__init__.py\",\n  line 1, in \n      from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 819, in call\n      return func(*args, **kwargs)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\cli\\main.py\", line\n  73, in _main\n      from ..base.context import context   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\base\\context.py\",\n  line 23, in \n      from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 47, in \n      from .._vendor.toolz.functoolz import excepts   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda_vendor\\toolz\\functoolz.py\",\n  line 501\n      f.name for f in reversed((self.first,) + self.funcs),\n      ^ SyntaxError: Generator expression must be parenthesized\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 42, in \n      from cytoolz.dicttoolz import merge   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\cytoolz__init__.py\",\n  line 1, in \n      from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\Scripts\\conda-script.py\", line 10, in\n  \n      sys.exit(main())   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\cli\\main.py\", line\n  113, in main\n      return conda_exception_handler(_main, *args)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 1112, in conda_exception_handler\n      return_value = exception_handler(func, *args, **kwargs)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 822, in call\n      return self.handle_exception(exc_val, exc_tb)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 864, in handle_exception\n      return self.handle_unexpected_exception(exc_val, exc_tb)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 876, in handle_unexpected_exception\n      self.print_unexpected_error_report(error_report)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 932, in print_unexpected_error_report\n      from .base.context import context   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\base\\context.py\",\n  line 23, in \n      from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 47, in \n      from .._vendor.toolz.functoolz import excepts   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda_vendor\\toolz\\functoolz.py\",\n  line 501\n      f.name for f in reversed((self.first,) + self.funcs),\n      ^ SyntaxError: Generator expression must be parenthesized Traceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 42, in \n      from cytoolz.dicttoolz import merge   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\cytoolz__init__.py\",\n  line 1, in \n      from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\cli\\main.py\", line\n  97, in main\n      from ..activate import main as activator_main   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\activate.py\", line\n  11, in \n      from .base.context import ROOT_ENV_NAME, context, locate_prefix_by_name   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\base\\context.py\",\n  line 23, in \n      from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 47, in \n      from .._vendor.toolz.functoolz import excepts   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda_vendor\\toolz\\functoolz.py\",\n  line 501\n      f.name for f in reversed((self.first,) + self.funcs),\n      ^ SyntaxError: Generator expression must be parenthesized\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 42, in \n      from cytoolz.dicttoolz import merge   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\cytoolz__init__.py\",\n  line 1, in \n      from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\Scripts\\conda-script.py\", line 10, in\n  \n      sys.exit(main())   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\cli\\main.py\", line\n  110, in main\n      return ExceptionHandler().handle_exception(exc_val, exc_tb)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 864, in handle_exception\n      return self.handle_unexpected_exception(exc_val, exc_tb)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 876, in handle_unexpected_exception\n      self.print_unexpected_error_report(error_report)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 932, in print_unexpected_error_report\n      from .base.context import context   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\base\\context.py\",\n  line 23, in \n      from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 47, in \n      from .._vendor.toolz.functoolz import excepts   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda_vendor\\toolz\\functoolz.py\",\n  line 501\n      f.name for f in reversed((self.first,) + self.funcs),\n      ^ SyntaxError: Generator expression must be parenthesized\n\n\nI've just found out that I cant even use any conda commands except the : >conda --version< command only.\nPlease help me resolve this issue without uninstalling then reinstalling anaconda completely","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1755,"Q_Id":51519102,"Users Score":0,"Answer":"It usually happen when you directly download and insall anaconda normally form its website.\nUpdating anaconda solved this issue for me in Manjaro and will surely work on Windows as well.\nuse conda update anaconda-navigator command to Update Anaconda.\nIf it doesn't starts, restart your pc and try to open it again.","Q_Score":1,"Tags":"python-3.x,windows-10,anaconda","A_Id":64991133,"CreationDate":"2018-07-25T12:38:00.000","Title":"anaconda navigator will no longer start even through cmd, won't install or update or manage environments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm new to django and using the anaconda cloud environment. Its been working well for 3 months plus but as of 7-24-2018 it is just stop to launch the navigator or open through cmd. I can't manage environments or install packages. Using the anaconda prompt also gives me the same error upon launching. It started when I wanted to install django-Oscar, but not having its dependencies I was forced to install the packages manually which in turn needed cytoolz that needs Microsoft Visual C++ build tools which I got to install as well but the error persists. Please help me!\nCopy\/Paste of CMD Traceback:\n\nC:\\Users\\kaukau\\Desktop>conda --version conda 4.5.4\nC:\\Users\\kaukau\\Desktop>anaconda-navigator Traceback (most recent call\n  last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\qtpy__init__.py\", line\n  169, in \n      from PySide import version as PYSIDE_VERSION  # analysis:ignore ModuleNotFoundError: No module named 'PySide'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\Scripts\\anaconda-navigator-script.py\", line\n  6, in \n      from anaconda_navigator.app.main import main   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\anaconda_navigator\\app\\main.py\",\n  line 22, in \n      from anaconda_navigator.utils.conda import is_conda_available   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\anaconda_navigator\\utils__init__.py\",\n  line 15, in \n      from qtpy.QtGui import QIcon   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\qtpy__init__.py\", line\n  175, in \n      raise PythonQtError('No Qt bindings could be found') qtpy.PythonQtError: No Qt bindings could be found\nC:\\Users\\kaukau\\Desktop>conda install qt --force Traceback (most\n  recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 42, in \n      from cytoolz.dicttoolz import merge   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\cytoolz__init__.py\",\n  line 1, in \n      from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 819, in call\n      return func(*args, **kwargs)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\cli\\main.py\", line\n  73, in _main\n      from ..base.context import context   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\base\\context.py\",\n  line 23, in \n      from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 47, in \n      from .._vendor.toolz.functoolz import excepts   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda_vendor\\toolz\\functoolz.py\",\n  line 501\n      f.name for f in reversed((self.first,) + self.funcs),\n      ^ SyntaxError: Generator expression must be parenthesized\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 42, in \n      from cytoolz.dicttoolz import merge   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\cytoolz__init__.py\",\n  line 1, in \n      from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\Scripts\\conda-script.py\", line 10, in\n  \n      sys.exit(main())   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\cli\\main.py\", line\n  113, in main\n      return conda_exception_handler(_main, *args)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 1112, in conda_exception_handler\n      return_value = exception_handler(func, *args, **kwargs)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 822, in call\n      return self.handle_exception(exc_val, exc_tb)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 864, in handle_exception\n      return self.handle_unexpected_exception(exc_val, exc_tb)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 876, in handle_unexpected_exception\n      self.print_unexpected_error_report(error_report)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 932, in print_unexpected_error_report\n      from .base.context import context   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\base\\context.py\",\n  line 23, in \n      from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 47, in \n      from .._vendor.toolz.functoolz import excepts   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda_vendor\\toolz\\functoolz.py\",\n  line 501\n      f.name for f in reversed((self.first,) + self.funcs),\n      ^ SyntaxError: Generator expression must be parenthesized Traceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 42, in \n      from cytoolz.dicttoolz import merge   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\cytoolz__init__.py\",\n  line 1, in \n      from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\cli\\main.py\", line\n  97, in main\n      from ..activate import main as activator_main   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\activate.py\", line\n  11, in \n      from .base.context import ROOT_ENV_NAME, context, locate_prefix_by_name   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\base\\context.py\",\n  line 23, in \n      from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 47, in \n      from .._vendor.toolz.functoolz import excepts   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda_vendor\\toolz\\functoolz.py\",\n  line 501\n      f.name for f in reversed((self.first,) + self.funcs),\n      ^ SyntaxError: Generator expression must be parenthesized\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 42, in \n      from cytoolz.dicttoolz import merge   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\cytoolz__init__.py\",\n  line 1, in \n      from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\kaukau\\Anaconda3\\Scripts\\conda-script.py\", line 10, in\n  \n      sys.exit(main())   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\cli\\main.py\", line\n  110, in main\n      return ExceptionHandler().handle_exception(exc_val, exc_tb)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 864, in handle_exception\n      return self.handle_unexpected_exception(exc_val, exc_tb)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 876, in handle_unexpected_exception\n      self.print_unexpected_error_report(error_report)   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\",\n  line 932, in print_unexpected_error_report\n      from .base.context import context   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\base\\context.py\",\n  line 23, in \n      from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter,   File\n  \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda\\common\\configuration.py\",\n  line 47, in \n      from .._vendor.toolz.functoolz import excepts   File \"C:\\Users\\kaukau\\Anaconda3\\lib\\site-packages\\conda_vendor\\toolz\\functoolz.py\",\n  line 501\n      f.name for f in reversed((self.first,) + self.funcs),\n      ^ SyntaxError: Generator expression must be parenthesized\n\n\nI've just found out that I cant even use any conda commands except the : >conda --version< command only.\nPlease help me resolve this issue without uninstalling then reinstalling anaconda completely","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1755,"Q_Id":51519102,"Users Score":0,"Answer":"Sorry to waste your time, I solved it by reinstalling anaconda completely and every project started working again....thanks to those who read it, the effort is appreciated.","Q_Score":1,"Tags":"python-3.x,windows-10,anaconda","A_Id":51995155,"CreationDate":"2018-07-25T12:38:00.000","Title":"anaconda navigator will no longer start even through cmd, won't install or update or manage environments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am writing a server with multiple gunicorn workers and want to let them all have access to a specific variable. I'm using Redis to do this(it's in RAM, so it's fast, right?) but every GET or SET request adds another client.  I'm performing maybe ~150 requests per second, so it quickly reaches the 25 connection limit that Heroku has. To access the database, I'm using db = redis.from_url(os.environ.get(\"REDIS_URL\")) and then db.set() and db.get().  Is there a way to lower that number? For instance, by using the same connection over and over again for each worker?  But how would I do that? The 3 gunicorn workers I have are performing around 50 queries each per second.\nIf using redis is a bad idea(which it probably is), it would be great if you could suggest alternatives, but also please include a way to fix my current problem as most of my code is based off of it and I don't have enough time to rewrite the whole thing yet.\nNote: The three pieces of code are the only times redis and db are called.  I didn't do any configuration or anything.  Maybe that info will help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":133,"Q_Id":51519333,"Users Score":0,"Answer":"Most likely, your script creates a new connection for each request.\nBut each worker should create it once and use forever.\nWhich framework are you using?\nIt should have some documentation about how to configure Redis for your webapp.\nP.S. Redis is a good choice to handle that :)","Q_Score":1,"Tags":"python,heroku,redis,gunicorn","A_Id":51519644,"CreationDate":"2018-07-25T12:50:00.000","Title":"Python Redis on Heroku reached max clients","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I type \"Python\" into the Windows 10 command prompt I get the error \"'python' is not recognized as an internal or external command, operable program or batch file.\" I've tried adding \"C:\\Python27\" to the \"Path\" environment variable, but it never works. It doesn't work for the as a user variable or a system variable.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2236,"Q_Id":51523826,"Users Score":0,"Answer":"Python might not be in your PATH.  Check the environment variables and ensure c:\\python27 is in the PATH.","Q_Score":0,"Tags":"python,error-handling,environment-variables,command-prompt","A_Id":51523988,"CreationDate":"2018-07-25T16:36:00.000","Title":"Python Environment Variable Not Working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"My Python script updates Oracle passwords regularly using the command\n    alter user my_user identified by \"new_password\" replace \"old_password\"\nNow I need to update these passwords in the SQL Developer connection definitions. I have looked all over my Windows 7 machine but nowhere can I find Connections.xml, nor IDEConnections.xml. And if so, the passwords would be encrypted.\nCan anybody automate password updates for SQL Developer?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":449,"Q_Id":51524365,"Users Score":0,"Answer":"Robertus post pointed me in the right direction as to the location of the relevant configuration files; however, the password encryption is not solved yet. Re-opening a new question.","Q_Score":0,"Tags":"python,oracle,passwords,oracle-sqldeveloper","A_Id":51544618,"CreationDate":"2018-07-25T17:11:00.000","Title":"Can Python update Passwords for Oracle SQL Developer Connections","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am basically trying to start an HTTP server which will respond with content from a website which I can crawl using Scrapy. In order to start crawling the website I need to login to it and to do so I need to access a DB with credentials and such. The main issue here is that I need everything to be fully asynchronous and so far I am struggling to find a combination that will make everything work properly without many sloppy implementations.\nI already got Klein + Scrapy working but when I get to implementing DB accesses I get all messed up in my head. Is there any way to make PyMongo asynchronous with twisted or something (yes, I have seen TxMongo but the documentation is quite bad and I would like to avoid it. I have also found an implementation with adbapi but I would like something more similar to PyMongo).\nTrying to think things through the other way around I'm sure aiohttp has many more options to implement async db accesses and stuff but then I find myself at an impasse with Scrapy integration.\nI have seen things like scrapa, scrapyd and ScrapyRT but those don't really work for me. Are there any other options?\nFinally, if nothing works, I'll just use aiohttp and instead of Scrapy I'll do the requests to the websito to scrap manually and use beautifulsoup or something like that to get the info I need from the response. Any advice on how to proceed down that road?\nThanks for your attention, I'm quite a noob in this area so I don't know if I'm making complete sense. Regardless, any help will be appreciated :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":263,"Q_Id":51525645,"Users Score":0,"Answer":"Is there any way to make pymongo asynchronous with twisted\n\nNo. pymongo is designed as a synchronous library, and there is no way you can make it asynchronous without basically rewriting it (you could use threads or processes, but that is not what you asked, also you can run into issues with thread-safeness of the code).\n\nTrying to think things through the other way around I'm sure aiohttp has many more options to implement async db accesses and stuff\n\nIt doesn't. aiohttp is a http library - it can do http asynchronously and that is all, it has nothing to help you access databases. You'd have to basically rewrite pymongo on top of it.\n\nFinally, if nothing works, I'll just use aiohttp and instead of scrapy I'll do the requests to the websito to scrap manually and use beautifulsoup or something like that to get the info I need from the response.\n\nThat means lots of work for not using scrapy, and it won't help you with the pymongo issue - you still have to rewrite pymongo!\nMy suggestion is - learn txmongo! If you can't and want to rewrite it, use twisted.web to write it instead of aiohttp since then you can continue using scrapy!","Q_Score":0,"Tags":"python,mongodb,asynchronous,server,scrapy","A_Id":51525888,"CreationDate":"2018-07-25T18:37:00.000","Title":"Async HTTP server with scrapy and mongodb in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to write a custom AI API for a game which uses the Unreal engine 4. While I can read the process memory using Python just fine, I have confronted a bigger issue - reading the process memory only when relevant and sending in inputs only when possible - thus only once a frame is rendered. If I want to send inputs, they need to be sent on frames specifically (the game being a fighting game).\nTherefore, I need to update my own AI API with the same framerate as the game itself. My first idea was to look into the process memory and find out if there's any value that's updated each frame - while there're values updated all the time, they seem to be updated in memory after 8 frames occur. Unfortunately, 8 frames don't allow the AI to perform the inputs properly as the update loop would not update fast enough.\nI will be looking through the memory more but I was wondering if it's possible to attach a program to the running process to look at the window itself - and in case it has been updated (something new has been rendered), update the gamestate in the AI itself. Is there a way this can be achieved?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":677,"Q_Id":51527523,"Users Score":0,"Answer":"We are talking about a game built on Unreal Engine, and you cannot find an address being changed every frame.\nThis makes me concerned about where\/how you are trying to find the addresses being changed each frame. Perhaps try a memory scanning tool such as CheatEngine just in case.\nThere should be a few addresses changing each frame. One that comes to mind would be:\n\nOne of the addresses referenced when using this function: UGameplayStatics::GetRealTimeSeconds(GetWorld());\n\nIf you really cannot find a variable changing each frame, then I offer you a solution to hook into a function called in the process every frame by doing the following:\nThis is not a complete solution by any means as this covers a subjectively complex topic that you will likely need to learn about from other sources.\n[NOTE]\nIf this game uses an anti-cheat, you may be banned for this behaviour, I would suggest doing your research before attempting this. I take no responsibility for any issues or loss you may incur from the use of the following advice. \nBackup Option:\n\nUsing CheatEngine, open the target process.\nLook for a function that is being called every frame (like so):\n\n\nFind a variable you suspect is READ every frame (does not have to be changed)\nAdd it to your address list\nRight-click the entry from the address list and select: Find out what accesses this address\nAccept the prompt to attach a debugger to the process\nWatch the count, is it going up extremely fast? Great! this is likely being read every frame\nStop the tool and click on the Instruction entry in the list that has the high count\nClick the Show Disassembler button\nYou are now looking at the interpreted opcodes for the function that is accessing your address every frame\nSimply right click the highlighted row and click Select current function to find the start of the function\nI would personally toggle a breakpoint on this line (F5) with the game visible on the side to ensure it is being triggered each frame (continuing after each break with F9).\n\nYou now have the Base Address + Function Address in the Address column of the highlighted row.\nHere comes the hard part that will require further explanation and will be a learning exercise that you will need to undertake.\n\nRead up on patching a function by injecting code into the process or by modifying the process before you run it.\nThe injected code can communicate with your process via a Memory Mapped File or a Named Pipe, setting a flag every frame.\nYou will need to do this while retaining the original opcodes to ensure the program works as normal by either:\n\n\nrestoring after executing\nOR\njumping to a code cave and executing original opcodes before jumping back\nOR\nRedirecting the function altogether (not suitable for your current use but worth reading about)","Q_Score":2,"Tags":"python,artificial-intelligence,reverse-engineering,unreal-engine4","A_Id":51571965,"CreationDate":"2018-07-25T20:56:00.000","Title":"Hook a program to a running game, update each frame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to plot an array of temperatures for different location during one day in python and want it to be graphed in the format (time, temperature_array). I am using matplotlib and currently only know how to graph 1 y value for an x value.\nThe temperature code looks like this:\nTemperatures = [[Temp_array0] [Temp_array1] [Temp_array2]...], where each numbered array corresponds to that time and the temperature values in the array are at different latitudes and longitudes.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1722,"Q_Id":51527766,"Users Score":0,"Answer":"You can simply repeat the X values which are common for y values\nSuppose\n[x,x,x,x],[y1,y2,y3,y4]","Q_Score":0,"Tags":"python,matplotlib,graph","A_Id":51527863,"CreationDate":"2018-07-25T21:15:00.000","Title":"Python: How to plot an array of y values for one x value in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building an RPC Server in golang that uses msgpack. \nThe client is built in python using the mprpc library (msgpack over TCP with gevent). \nMy issue is, being an absolute noob in networking, I discovered that I can't use the same address\/port with multiple clients running at once on the same computer (socket already bound i guess, it just stalls and timeouts).\nI have looked around quite a bit but I'm not sure what I should be doing to be able to have multiple clients on the same machine talk to a server (msgpack back and forth). Is this a case where I need to use ZeroMQ ? Or requests over HTTP ?\nThanks !","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1344,"Q_Id":51527846,"Users Score":0,"Answer":"If you want to have two way connection, then HTTP is not suitable for this. Because HTTP is designed in a way that the server only responds to a request, which prevents server to issue a request itself. There are other solutions that provide two way connection(server to client and client to server in same time).\nWebSocket is the first thing that comes to my mind. Of course ZeroMQ also can do this.","Q_Score":0,"Tags":"python,sockets,tcp,rpc,msgpack","A_Id":51528128,"CreationDate":"2018-07-25T21:22:00.000","Title":"RPC over TCP with multiple clients on same machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have a package foobar, I want it to tell pip\/setuptools that it also provides package vendor. So that when I later install another third party package that depends on the vendor package, it sees that foobar is installed, and therefore won't install the vendor package. Is this possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":470,"Q_Id":51528303,"Users Score":1,"Answer":"There is no such ability. pip is a rather simple package manager and doesn't have features from advanced package managers like rpm\/deb\/etc. It has neither \"This package also provides\u2026\" nor \"This package obsoletes\u2026\" nor \"This package is incompatible with\u2026\" Alas!\nThe only way is to upload to PyPI a vendor package that consists of a single setup.py that lists foobar as a dependency.","Q_Score":0,"Tags":"python,pip,setuptools","A_Id":51528721,"CreationDate":"2018-07-25T22:00:00.000","Title":"Python setuptools: How to specify a package aliases a third party package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've scrolled the internet all over and theres no simple, clean explanation for this. How can I open the Python shell, but inside a terminal window such as CMD? I have an application for it, but want to run it inside a terminal, so I can practice Python code inside my IDE like VS code.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1327,"Q_Id":51529616,"Users Score":0,"Answer":"If you have a reasonably new version of Python you need to run py.exe (or just py) instead of python.exe, because the real python executable (python.exe) is not in your path environment variable by default, whereas py.exe is in the \/windows directory and thus automatically in path.\nSo to run your script type py yourscript.py from the directory of your script. If you just run py it will start the interactive interpreter.","Q_Score":0,"Tags":"python","A_Id":51529746,"CreationDate":"2018-07-26T01:07:00.000","Title":"How to run the python shell inside a terminal in Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to stream an online video using VLC media player. But the URL I'm receiving is random, so that URL needs to be linked to the VLC media player online stream. Is there any APIs that enables the random online video to be played ?\nA small understanding of the project that I'm building...\n\nI have a device that will receive the URL from the server and will play it on a screen. \nEarlier I was playing it via a web browser. But this time I want it to implement it using a media player.Thus my question, is there any API for VLC media player that can be used to stream online videos?\n\n*** BTW I'm using python to write my scripts.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":8408,"Q_Id":51536989,"Users Score":1,"Answer":"If the URL is to the stream \/ video file, you can just open it directly in VLC like you would anything else. If it's to an HTML document, you'll need to extract the URL of the actual stream.","Q_Score":3,"Tags":"python,video,media,vlc","A_Id":51537047,"CreationDate":"2018-07-26T10:46:00.000","Title":"VLC Media Player API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I extract video into frames using python only. I got plenty of solutions but they all are using OpenCV. But in my case I want to do it using python only.\nYour help will be highly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":520,"Q_Id":51539813,"Users Score":3,"Answer":"First you should understand that there are many different video codecs and even different video containers in common use, currently. Any library that offers video decoding usually has a multitude of different sub-libraries, to be able to read all the codecs.\nBut even for single codec\/container variants you will not find any Python implementations, beyond toy or research projects. Video decoders are written in C, C++ or similar languages, as the process is computationally very expensive.\nThe video decoding in OpenCV is a relatively thin wrapper of ffmpeg\/libav functionality. All the heavy lifting is done by ffmpeg. So if you want to do without OpenCV, that's possible by finding another video decoding library wrapper in Python. But you will not find a pure-Python implementation of video decoding for common video files.","Q_Score":2,"Tags":"python,python-3.x","A_Id":51541112,"CreationDate":"2018-07-26T13:17:00.000","Title":"Extract video into frames using pure python(without using openCV)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to schedule a .pyw script in Task Scheduler on Windows. When I double click on the file, everything works properly, the program does what it should do. I successfully create a task in Task Scheduler:\n-'Run with highest privileges' checked\n-Configure for Windows 10\n-'At system startup' trigger\n-Action: 'Start a program' and I provide the full path to the .pyw script\n-I have also unchecked 'Start the task only if the computer is on AC power'\n..and when I do right click --> Run, I get a standard question: \"How do you want to open this file\" etc. Now, status of the task is 'Running', but nothing happens, and I cannot find my program running in Task Manager. Any advice?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":616,"Q_Id":51541502,"Users Score":1,"Answer":"You should provide a full path to the python interpreter and in the optional parameters add the path to your script.\nJust like in cmd, when you run a python script, you type python first, works the same with the task scheduler.","Q_Score":2,"Tags":"python,windows,taskscheduler","A_Id":51541652,"CreationDate":"2018-07-26T14:38:00.000","Title":"Schedule and MANUALLY run .pyw script in Task Scheduler on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I understand that sklearn requires categorical features to be encoded to dummy variables or one-hot encoded when running the sklearn.ensemble.RandomForestRegressor method, and that XGBoost requires the same, but h2o permitted raw categorical features to be used in its h2o.estimators.random_forest.H2ORandomForestEstimator method. Since h2o4gpu's implementation of random forest is built on top of XGBoost, does this mean support for raw categorical features is not included?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":190,"Q_Id":51543158,"Users Score":1,"Answer":"There is no native support for categorical columns in h2o4gpu (at least yet), so you will have to one-hot encode (or label encode) your categorical columns like you do in sklearn and xgboost.","Q_Score":2,"Tags":"python,scikit-learn,h2o,h2o4gpu","A_Id":51547413,"CreationDate":"2018-07-26T16:02:00.000","Title":"Does h2o4gpu handle categorical features like sklearn or like h2o?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why would the file system (CIRCUITPY) of an Adafruit board running CircuitPython not show up when connecting it to a suitable host via a micro usb cable?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1381,"Q_Id":51543804,"Users Score":1,"Answer":"Besides your first answer about the cable, because of the relatively inexpensive nature of the boards and direct access to their power\/ground sometimes the EPROMs that the file system are hosted on just go bad and give unexpected results. Best idea is to:\n\nTest your environment with another board.\nReflash micro python on your board so you can start from scratch (didn't mention if you'd tried that).","Q_Score":0,"Tags":"usb,adafruit,micropython","A_Id":51622090,"CreationDate":"2018-07-26T16:44:00.000","Title":"Why might an Adafruit CircuitPython board's filesystem fail to mount?","Data Science and Machine Learning":0,"Database and SQL":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 exported a list of AD Users out of AD and need to validate their login times.\nThe output from the powershell script give lastlogin as LDAP\/FILE time\nEXAMPLE 130305048577611542 \nI am having trouble converting this to readable time in pandas \nIm using the following code:\ndf['date of login'] = pd.to_datetime(df['FileTime'], unit='ns')\nThe column FileTime contains time formatted like the EXAMPLE above. \nIm getting the following output in my new column date of login \nEXAMPLE 1974-02-17 03:50:48.577611542\nI know this is being parsed incorrectly as when i input this date time on a online converter i get this output\nEXAMPLE:\nEpoch\/Unix time: 1386031258\nGMT: Tuesday, December 3, 2013 12:40:58 AM\nYour time zone: Monday, December 2, 2013 4:40:58 PM GMT-08:00\nAnyone have an idea of what occuring here why are all my dates in the 1970'","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":8553,"Q_Id":51547064,"Users Score":6,"Answer":"I know this answer is very late to the party, but for anyone else looking in the future.\nThe 18-digit Active Directory timestamps (LDAP), also named 'Windows NT time format','Win32 FILETIME or SYSTEMTIME' or NTFS file time. These are used in Microsoft Active Directory for pwdLastSet, accountExpires, LastLogon, LastLogonTimestamp and LastPwdSet. The timestamp is the number of 100-nanoseconds intervals (1 nanosecond = one billionth of a second) since Jan 1, 1601 UTC.\nTherefore, 130305048577611542 does indeed relate to December 3, 2013.\nWhen putting this value through the date time function in Python, it is truncating the value to nine digits. Therefore the timestamp becomes 130305048 and goes from 1.1.1970 which does result in a 1974 date!\nIn order to get the correct Unix timestamp you need to do: \n(130305048577611542 \/ 10000000) - 11644473600","Q_Score":1,"Tags":"python,datetime","A_Id":54131481,"CreationDate":"2018-07-26T20:29:00.000","Title":"Convert 18-digit LDAP\/FILETIME timestamps to human readable date","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having a hard time figuring out why outputs aren't the same. Notice that the difference is very tiny if you compare both OUT's. What I'm trying to achieve is have the same output in Python to the one in Ruby.\nRuby:\nIN:['034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192'].pack('H*')\nOUT:\\x03AQ\\xA3\\xECF\\xB5g\\nh+\\nc9O\\x865\\x87\\xD1\\xBC\\x97H;\\elp\\xEBX\\xE7\\xF0\\xAE\\xD1\\x92\nPython:\nIN:unhexlify('034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192') OUT:\\x03AQ\\xa3\\xecF\\xb5g\\nh+\\nc9O\\x865\\x87\\xd1\\xbc\\x97H;\\x1blp\\xebX\\xe7\\xf0\\xae\\xd1\\x92","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":478,"Q_Id":51547637,"Users Score":6,"Answer":"Both languages have produced the same sequence of bytes; the only difference is in the way they display those bytes to you. Ruby has an \\e string escape sequence for the 1b byte (ASCII ESC, escape), while Python displays that byte as \\x1b.","Q_Score":2,"Tags":"python,ruby,pack,binascii","A_Id":51547687,"CreationDate":"2018-07-26T21:18:00.000","Title":"Ruby pack('H*') equivalent in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Does anyone have experience with triggering an email from Spotfire based on a condition? Say, a sales figure falls below a certain threshold and an email gets sent to the appropriate distribution list. I want to know how involved this would be to do. I know that it can be done using an iron python script, but I'm curious if it can be done based on conditions rather than me hitting \"run\"?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":712,"Q_Id":51547675,"Users Score":1,"Answer":"we actually have a product that does exactly this called the Spotfire Alerting Tool. it functions off of Automation Services and allows you to configure various thresholds for any metrics in the analysis, and then can notify users via email or even SMS.\nof course there is the possibility of coding this yourself (the tool is simply an extension developed using the Spotfire SDK) but I can't comment on how to code it.\nthe best way to get this tool is probably to check with your TIBCO sales rep. if you'd like I can try to reach him on your behalf, but I'll need a bit more info from you. please contact me at nmaresco@tibco.com.\nI hope this kind of answer is okay on SO. I don't have a way to reach you privately and this is the best answer I know how to give :)","Q_Score":2,"Tags":"automation,ironpython,spotfire","A_Id":51674710,"CreationDate":"2018-07-26T21:21:00.000","Title":"Triggering email out of Spotfire based on conditions","Data Science and Machine Learning":0,"Database and SQL":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 invoke the gsutil command from a cell in a Jupyter notebook, using the bash cell magic %%bash, as such:\n%%bash\ngsutil\n\nHowever I am receiving the following output:\nbash: line 1: gsutil: command not found\nOn the other hand, using the exclamation mark syntax gives me the expected result:\n!gsutil\nGives...\nUsage: gsutil [-D] [-DD] [-h header]... [-m] [-o] [-q] [command [opts...] args...]\nAvailable commands:\n  acl             Get, set, or change bucket and\/or object ACLs\n  cat             Concatenate object content to stdout......\nThe ! syntax doesn't support multi-line commands, and even if it did, as I am collaborating with others, I need the %%bash syntax to work for me.\nCan anyone enlighten me as to what the reason behind this is and how I can go about solving it?\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4441,"Q_Id":51548928,"Users Score":0,"Answer":"I got around this by using the %%cmd magic instead, which I was unaware of. I'll still have to do some tweaking of the bash commands as there are some slight inconsistencies, but still better than nothing.","Q_Score":1,"Tags":"python,bash,jupyter-notebook,jupyter","A_Id":51549127,"CreationDate":"2018-07-26T23:46:00.000","Title":"Bash cell magic (%%) giving \"command not found\" error in Jupyter notebook (Windows 7)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"This code is for running my trained weights the folder ckpt contains 1050 step train data and this file is in outside of cfg folder in darkflow main folder.\nimport cv2\nfrom darkflow.net.build import TFNet\nimport numpy as np\nimport time\noptions = {\n    'model': 'cfg\/tiny-yolo-voc-1c.cfg',\n    'load': 1050,\n    'threshold': 0.2,\n    'gpu': 1.0\n}\nafter running this code in atom editor below error showing\nParsing cfg\/\/tiny-yolo-voc-1c.cfg\nTraceback (most recent call last):\n  File \"C:\\Users\\amard\\Desktop\\Hotel\\darkflow\\test.py\", line 13, in <module>\n    tfnet = TFNet(options)\n  File \"C:\\Users\\amard\\Desktop\\Hotel\\darkflow\\darkflow\\net\\build.py\", line 58, in __init__\n    darknet = Darknet(FLAGS)\n  File \"C:\\Users\\amard\\Desktop\\Hotel\\darkflow\\darkflow\\dark\\darknet.py\", line 17, in __init__\n    src_parsed = self.parse_cfg(self.src_cfg, FLAGS)\n  File \"C:\\Users\\amard\\Desktop\\Hotel\\darkflow\\darkflow\\dark\\darknet.py\", line 68, in parse_cfg\n    for i, info in enumerate(cfg_layers):\n  File \"C:\\Users\\amard\\Desktop\\Hotel\\darkflow\\darkflow\\utils\\process.py\", line 66, in cfg_yielder\n    layers, meta = parser(model); yield meta;\n  File \"C:\\Users\\amard\\Desktop\\Hotel\\darkflow\\darkflow\\utils\\process.py\", line 17, in parser\n    with open(model, 'rb') as f:\nFileNotFoundError: [Errno 2] No such file or directory: 'cfg\/\/tiny-yolo-voc-1c.cfg'\n[Finished in 4.298s]","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":778,"Q_Id":51549279,"Users Score":0,"Answer":"Oftenly I was also used  get something similar to this error \nmy first mistake was not to open Jupyter notebook at the directory where I kept these folders\nso, try to open the notebook from that directory \n(in windows simply type cmd on location bar of shift+right-click)\n(in MacOS there is some setting first enable that then right-click on the folder)\nlater I used this options \noptions={\n    'model':'cfg\/yolo.cfg',\n    'load':'bin\/yolov2.weights',\n    'threshold':0.3,\n    'gpu':1.0\n}\ntfNet=TFNet(options)\nand everything work as expected\nhope this will help you","Q_Score":0,"Tags":"python,yolo,darkflow","A_Id":54362653,"CreationDate":"2018-07-27T00:46:00.000","Title":"while running YOLO for test custom object cfg file path error the path is correct but even though its showing this error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the 2d interpolation function in scipy to smooth a 2d image.  As I understand it, interpolate will return z = f(x,y).  What I want to do is find x with known values of y and z.  I tried something like this;\nf = interp2d(x,y,z)\nindex = (np.abs(f(:,y) - z)).argmin()\nHowever the interp2d object does not work that way.  Any ideas on how to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":51549293,"Users Score":0,"Answer":"I was able to figure this out.  yvalue, zvalue, xmin, and xmax are known values.  By creating a linspace out of the possible values x can take on, a list can be created with all of the corresponding function values.  Then using argmin() we can find the closest value in the list to the known z value.  \nf = interp2d(x,y,z)\nxnew = numpy.linspace(xmin, xmax)\nfnew = f(xnew, yvalue)\nxindex = (numpy.abs(fnew - zvalue)).argmin()\nxvalue = xnew(xindex)","Q_Score":1,"Tags":"python,numpy,scipy","A_Id":51565999,"CreationDate":"2018-07-27T00:49:00.000","Title":"Scipy interp2d function produces z = f(x,y), I would like to solve for x","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have PyCharm install on my Mac. I just started a course that talks about using Anaconda but nothing about PyCharm. I'm still a beginner learning the language but I feel I need to start writing code while still studying. Do I need to install Anaconda even if I have PyCharm? And if so will they both work well together?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":7359,"Q_Id":51549376,"Users Score":1,"Answer":"My experience with Anaconda was using it for a machine learning learning class. We used jupyter notebook to do all our learning and projects. From what I've noticed, people mostly use Anaconda for data science and machine learning related applications. But since you are just starting to learn python, I recommend just sticking with PyCharm.","Q_Score":3,"Tags":"python,pycharm,anaconda","A_Id":51549482,"CreationDate":"2018-07-27T01:00:00.000","Title":"Do I need Anaconda installed if I already have PyCharm? If so will they work well together?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have PyCharm install on my Mac. I just started a course that talks about using Anaconda but nothing about PyCharm. I'm still a beginner learning the language but I feel I need to start writing code while still studying. Do I need to install Anaconda even if I have PyCharm? And if so will they both work well together?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7359,"Q_Id":51549376,"Users Score":3,"Answer":"PyCharm is a development environment and Anaconda is an all-in-one way to install a nice stack of Python tools and packages (numpy, pandas, etc. - lots of data science tools but many general purpose tools as well). They work together fine - you just need to set up a run configuration that points to the Anaconda installation.","Q_Score":3,"Tags":"python,pycharm,anaconda","A_Id":51549440,"CreationDate":"2018-07-27T01:00:00.000","Title":"Do I need Anaconda installed if I already have PyCharm? If so will they work well together?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem, I have been using a docker environment for my django 2.0 project and pylint was working fine but now it's showing the unable to import module error. I'm aware that the import error question has been asked many times but it was always for a venv setup rather than docker environment setup. \nI'm not sure what triggered the error, but possibly because I deleted my old containers, volumes, images and started from scratch. \nI'm using Python 3 and VSCode on Manjaro Linux. \nThanks in advance if anyone can help.\nTo add \"python.linting.pylintArgs\": [\"--load-plugins\", \"pylint_django\"] in settings results in real errors not being reported too.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1630,"Q_Id":51550260,"Users Score":-1,"Answer":"To try and find an answer for myself and anyone who read this, a possible reason for this is installing pylint via vscode which uses pip. Generally not recommended to do this or sudo pip install in linux. Use your linux package manager to install.","Q_Score":6,"Tags":"python,django,docker,visual-studio-code,pylint","A_Id":51569836,"CreationDate":"2018-07-27T03:16:00.000","Title":"Docker dev environment, pylint unable to import error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a minimization problem, that is modeled to be solved in Gurobi, via python.\nBesides, I can calculate a \"good\" initial solution for the problem separately, that can be used as an upper bound for the problem.\nWhat I want to do is to set Gurobi use this upper bound, to enhance its efficiency. I mean, if this upper bound can help Gurobi for its search. The point is that I just have the objective value, but not a complete solution.\nCan anybody help me how to set this upper bound in the Gurobi?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":438,"Q_Id":51550870,"Users Score":0,"Answer":"I think that if you can calculate a good solution, you can also know some bound for your variable even you dont have the solution exactly ?","Q_Score":0,"Tags":"python,initialization,gurobi,upperbound","A_Id":51712765,"CreationDate":"2018-07-27T04:42:00.000","Title":"How to set an start solution in Gurobi, when only objective function is known?","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 about to decide on programming language for the project.\nThe requirements are that some of customers want to run application on isolated servers without external internet access.\nTo do that I need to distribute application to them and cannot use SaaS approach running on, for example, my cloud (what I'd prefer to do...).\nThe problem is that if I decide to use Python for developing this, I would need to provide customer with easy readable code which is not really what I'd like to do (of course, I know about all that \"do you really need to protect your source code\" kind of questions but it's out of scope for now).\nOne of my colleagues told me about Docker. I can find dozen of answers about Docker container security. Problem is all that is about protecting (isolating) host from code running in container.\nWhat I need is to know if the Python source code in the Docker Image and running in Docker Container is secured from access - can user in some way (doesn't need to be easy) access that Python code?\nI know I can't protect everything, I know it is possible to decompile\/crack everything. I just want to know the answer just to decide whether the way to access my code inside Docker is hard enough that I can take the risk.","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":5631,"Q_Id":51552706,"Users Score":3,"Answer":"Python programs are distributed as source code. If it can run on a client machine, then the code is readable on that machine. A docker container only contains the application and its libraries, external binaries and files, not a full OS. As the security can only be managed at OS level (or through encryption) and as the OS is under client control, the client can read any file on the docker container, including your Python source.\nIf you really want to go that way, you should consider providing a full Virtual Machine to your client. In that case, the VM contains a full OS with its account based security (administrative account passwords on the VM can be different from those of the host). Is is far from still waters, because it means that the client will be enable to setup or adapt networking on the VM among other problems...\nAnd you should be aware the the client security officer could emit a strong NO when it comes to running a non controlled VM on their network. I would never accept it.\nAnyway, as the client has full access to the VM, really securing it will be hard if ever possible (disable booting from an additional device may even not be possible). It is admitted in security that if the attacker has physical access, you have lost.\nTL\/DR: It in not the expected answer but just don't. It you sell your solution you will have a legal contract with your customer, and that kind of problem should be handled at a legal level, not a technical one. You can try, and I have even given you a hint, but IMHO the risks are higher than the gain.","Q_Score":8,"Tags":"python,security,docker,source-code-protection","A_Id":51553497,"CreationDate":"2018-07-27T07:17:00.000","Title":"Is distributing python source code in Docker secure?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am about to decide on programming language for the project.\nThe requirements are that some of customers want to run application on isolated servers without external internet access.\nTo do that I need to distribute application to them and cannot use SaaS approach running on, for example, my cloud (what I'd prefer to do...).\nThe problem is that if I decide to use Python for developing this, I would need to provide customer with easy readable code which is not really what I'd like to do (of course, I know about all that \"do you really need to protect your source code\" kind of questions but it's out of scope for now).\nOne of my colleagues told me about Docker. I can find dozen of answers about Docker container security. Problem is all that is about protecting (isolating) host from code running in container.\nWhat I need is to know if the Python source code in the Docker Image and running in Docker Container is secured from access - can user in some way (doesn't need to be easy) access that Python code?\nI know I can't protect everything, I know it is possible to decompile\/crack everything. I just want to know the answer just to decide whether the way to access my code inside Docker is hard enough that I can take the risk.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":5631,"Q_Id":51552706,"Users Score":1,"Answer":"I know that\u00b4s been more than 3 years, but... looking for the same kind of solution I think that including compiled python code -not your source code- inside the container would be a challenging trial for someone trying to access your valuable source code.\nIf you run pyinstaller --onefile yourscript.py you will get a compiled single file that can be run as an executable. I have only tested it in Raspberry, but as far as I know it\u00b4s the same for, say, Windows.\nOf course anything can be reverse engineered, but hopefully it won\u00b4t be worth the effort to the regular end user.","Q_Score":8,"Tags":"python,security,docker,source-code-protection","A_Id":69979887,"CreationDate":"2018-07-27T07:17:00.000","Title":"Is distributing python source code in Docker secure?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am about to decide on programming language for the project.\nThe requirements are that some of customers want to run application on isolated servers without external internet access.\nTo do that I need to distribute application to them and cannot use SaaS approach running on, for example, my cloud (what I'd prefer to do...).\nThe problem is that if I decide to use Python for developing this, I would need to provide customer with easy readable code which is not really what I'd like to do (of course, I know about all that \"do you really need to protect your source code\" kind of questions but it's out of scope for now).\nOne of my colleagues told me about Docker. I can find dozen of answers about Docker container security. Problem is all that is about protecting (isolating) host from code running in container.\nWhat I need is to know if the Python source code in the Docker Image and running in Docker Container is secured from access - can user in some way (doesn't need to be easy) access that Python code?\nI know I can't protect everything, I know it is possible to decompile\/crack everything. I just want to know the answer just to decide whether the way to access my code inside Docker is hard enough that I can take the risk.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":5631,"Q_Id":51552706,"Users Score":1,"Answer":"I think it could be a solution as using a \"container\" to protect our code from the person we wouldn't let them access. the problem is docker is not a secure container. As the root of the host machine has the most powerful control of the Docker container, we don't have any method to protect the root from accessing inside of the container.\nI just have some ideas about a secure container:\n\nBuild a container with init file like docker file, a password must be set when the container is created;\nonce the container is built, we have to use a password to access inside, including \nreading\\copy\\modify files \nall the files stored on the host machine should be encypt\u3002\nno \"retrieve password\"    or \u201c--skip-grant-\u201d mode is offered. that means nobody can\naccess the data inside the container if u lost the password.\n\nIf we have a trustable container where we can run tomcat or Django server, code obfuscation will not be necessary.","Q_Score":8,"Tags":"python,security,docker,source-code-protection","A_Id":56034690,"CreationDate":"2018-07-27T07:17:00.000","Title":"Is distributing python source code in Docker secure?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have an Excel workbook with close to 90 columns. I would like to create column alias for each column in the workbook, so that it will be easier for me to use the respective columns in formulas.\nNormally, I would select each column in the workbook and type in my alias for the column into the Cell Reference Bar at the top\nIs there a way to do this automatically, because i have a lot of columns? Especially in Python ?\nI tried the pandas.Series.to_excel function which has the header attribute. However all it does is change the column names to the string specified and does not modify the alias for all the cells in the column.\nThanks a lot for your help","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":632,"Q_Id":51554503,"Users Score":0,"Answer":"In Excel, is your data in a table, or named range? \nI'm kind of assuming a table (which could make this a snap) because, as a column heading in a (named) range, the 'header' (or alias, if I understand) isn't \"connected\" to the underlying data, as it would be in a table...\nCan you provide an example of how you would (or expect to) use the 'column alias' in a formula?","Q_Score":0,"Tags":"python,excel","A_Id":51567400,"CreationDate":"2018-07-27T09:05:00.000","Title":"How to create common alias for all cells in a column in Excel automatically through scripting","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an Excel workbook with close to 90 columns. I would like to create column alias for each column in the workbook, so that it will be easier for me to use the respective columns in formulas.\nNormally, I would select each column in the workbook and type in my alias for the column into the Cell Reference Bar at the top\nIs there a way to do this automatically, because i have a lot of columns? Especially in Python ?\nI tried the pandas.Series.to_excel function which has the header attribute. However all it does is change the column names to the string specified and does not modify the alias for all the cells in the column.\nThanks a lot for your help","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":632,"Q_Id":51554503,"Users Score":0,"Answer":"If I understand you correctly...\nTo name each of the columns something slightly different you can use a for-loop which contains an incrementing number that's added to the column name.\nThere are loads of examples of this available online, here's a really rough illustrative example:\nnum = 0\nfor header in column:\n    num +=1\n    header = header+str(num)\nI don't think you need to program this for just 90 columns in one book though tbh. \nYou could name the first 3 columns, select the three named cells, and then drag right when you see the + symbol in the bottom right corner of the most rightern cell of the three selected.\nDragging across 90 cells should only take one second.\nOnce you've named the 90 columns, you can always select row#1 and do some ctrl+h on it to change the header names later.","Q_Score":0,"Tags":"python,excel","A_Id":51556893,"CreationDate":"2018-07-27T09:05:00.000","Title":"How to create common alias for all cells in a column in Excel automatically through scripting","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"my question is just as the title. \n\nShould we always try to replace a for loop with list\/dict comprehension when we can since the latter performs faster? \n\nI am writing this project which requires iterating through some massive lists of tuples several times and it's taking forever. So I am struggling to optimize my codes now. The main reason I need to iterate through a list of tuples is, assume I have a value, I'd like to know if it is in the list and what is the other value in the same tuple. \n\nis turning these lists into an array or dictionary would help?\n\nAny input will be much appreciated. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":223,"Q_Id":51556631,"Users Score":5,"Answer":"Using a dictionary instead of a list of tuples would be MUCH more efficient- in general, getting a value from a dictionary for a given key is O(1) (constant speed, doesn't matter how big the dict is), while going through an entire list searching for a tuple is O(n) (which means that the efficiency goes down as the list grows).\nList comprehension instead of for loops shouldn't make a big difference, aside from the fact that in list comprehension you're actually building a list- so you could have memory issues if the loop you're going through is very large.\nIt sounds like you should have a dict in this scenario- btw- to convert a list of tuples to a dict, just do:\n\n   dict(list_of_tuples)","Q_Score":2,"Tags":"python,for-loop,generator,list-comprehension","A_Id":51556750,"CreationDate":"2018-07-27T11:03:00.000","Title":"should we always replace for loops with list comprehension","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Dealing with numerical calculations having exponential terms often becomes painful, thanks to overflow errors. For example, suppose you have a probability density, P(x)=C*exp(f(x)\/k), where k is very small number, say of the order of 10^(-5).\nTo find the value of C one has to integrate P(x). Here comes the overflow error. I know it also depends on the form of f(x). But for this moment let us assume, f(x)=sin(x).\nHow to deal with such problems?\nWhat are the tricks we may use to avoid them?\nIs the severity of such problems language dependent? If yes, in which language should one write his code?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1576,"Q_Id":51556833,"Users Score":0,"Answer":"One of the options is to use GSL - GNU Scientific Library (python and fortran wrappers are available). \nThere is a function gsl_sf_exp_e10_e that according to the documentation\n\ncomputes the exponential \\exp(x) using the gsl_sf_result_e10 type to return a result with extended range. This function may be useful if the value of \\exp(x) would overflow the numeric range of double.\n\nHowever, I would like to note, that it's slow due to additional checks during evaluation. \nP.S. As it was said earlier, it's better to use analytical solutions where possible.","Q_Score":1,"Tags":"python,fortran,numerical-methods,integer-overflow,exponential","A_Id":51919531,"CreationDate":"2018-07-27T11:16:00.000","Title":"How to avoid numerical overflow error with exponential terms?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to evaluate the performance of a regressor by means of GridSearchCV. In my implementation cv is an int, so I'm applying the K-fold validation method. Looking at cv_results_['mean_test_score'],\n the best mean score on the k-fold unseen data is around 0.7, while the train scores are much higher, like 0.999. This is very normal, and I'm ok with that.\nWell, following the reasoning behind this concept, when I apply the best_estimator_ on the whole data set, I expect to see at least some part of the data predicted not perfectly, right? Instead, the numerical deviations between the predicted quantities and the real values are near zero for all datapoints. And this smells of overfitting.\nI don't understand that, because if I remove a small part of the data and apply GridSearchCV to the remaining part, I find almost identical results as above, but the best regressor applied to the totally unseen data predicts with much higher errors, like 10%, 30% or 50%. Which is what I expected, at least for some points, fitting GridSearchCV on the whole set, based on the results of k-fold test sets.\nNow, I understand that this forces the predictor to see all datapoints, but the best estimator is the result of k fits, each of them never saw 1\/k fraction of data. Being the mean_test_score the average between these k scores, I expect to see a bunch of predictions (depending on cv value) which show errors distributed around a mean error that justifies a 0.7 score.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":234,"Q_Id":51558872,"Users Score":1,"Answer":"The refit=True parameter of GridSearchCV makes the estimator with the found best set of hyperparameters be refit on the full data. So if your training error is almost zero in the CV folds, you would expect it to be near zero in the best_estimator_ as well.","Q_Score":3,"Tags":"python-3.x,scikit-learn,grid-search","A_Id":51559013,"CreationDate":"2018-07-27T13:21:00.000","Title":"GridSearchCV: based on mean_test_score results, predict should perform much worse, but it does not","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use two other url tags other then pk and slug in a detail view. I have the following code snippet:\n\nviews.py\n\n    class UseCaseDetailView(DetailView):\n        template_name = \"useCaseExtract\/useCaseDetail.html\"\n        model = UseCaseProfile\n        context_object_name = 'usecaseprofile'\n        '''I am trying to override the get_object method of DetailView to accept url tags project and usecasename instead of pk and slug'''\n        def get_object(self):     \n            obj = get_object_or_404(UseCaseProfile, project=self.kwargs['project'], useCasename=self.kwargs['useCasename'])\n            return obj\n\nurls.py\n...\n\n    path('\/UseCaseDetail\/', UseCaseDetailView.as_view(), name='UseCaseDetail')\n\n...\n\nin my template file, I have the following link:\n\/Trancel\/UseCaseDetail\/Nothing\n\nafter I clicked the link, I got:\nValueError: invalid literal for int() with base 10:  'Trancel'\n\ncan you some please explain to me why I am getting this error?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":51563669,"Users Score":0,"Answer":"Do you have the ability to rename Trance1 to something like TranceOne? So that it doesn't include an integer?\nI think your issue is that 1 when it comes time to parse the URL..( as its expecting a sting, but it gets string w\/ a 1 in it).","Q_Score":0,"Tags":"python,django,django-class-based-views,detailview","A_Id":51563885,"CreationDate":"2018-07-27T18:32:00.000","Title":"Got \"ValueError: invalid literal for int() with base 10: 'Trancel'\" when using two paramenters in detailview in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am sort of new to python. I can open files in Windows with but am having trouble in Mac. I can open webbrowsers but I am unsure as to how I open other programs or word documents.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":51567959,"Users Score":0,"Answer":"have you tried this code:\nf = open(\"A.txt\")\nfor line in f:\n    print line\nf.close()\nthe file is located within the same directory of program files.\nis there error message?","Q_Score":1,"Tags":"python","A_Id":51567985,"CreationDate":"2018-07-28T04:12:00.000","Title":"Opening files in Mac using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to implement pbft algorithm(3f+1 systems;f=1) in python. But what is the channel should use for sending and receiving from replicas. I have tried python multicast but it seems something going wrong while receiving. So please suggest any solution that can put me forward. \nThanks in Advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":305,"Q_Id":51569086,"Users Score":0,"Answer":"You need to use authenticated point-to-point communication channel to implement any sorts of BFT algorithm. Because PBFT assumes all participant's identity are established in prior, you don't need to assume multicast communication primitive. Even though broadcast is executed in PBFT protocol, each message is encrypted by its private key. So you don't need to use multicast or broadcast.","Q_Score":0,"Tags":"python,algorithm,blockchain,consensus","A_Id":51963250,"CreationDate":"2018-07-28T07:25:00.000","Title":"pbft implementation in python when f=1","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"the question is:\nIn the keras tutorial it use an input x_train = np.random.random((100, 100, 100, 3)), it should means that there's 100 images each has size of [100,100,3] right?\nSo i thought that x_train[0][0] should represent the first channel of the first img (which should be [100, 100]), but x_train[0][0] in fact has a size of [100,3]... so i'm confused, how can keras take this [100,100,100,3] numpy array as a set of imgs? please help me out, thank in advance.\nAnother question is:\nhow can I construct a input like this ? Cause when I do np.array([[100,100],[100,100]]), it becomes to array of [2,100,100]","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1287,"Q_Id":51569542,"Users Score":2,"Answer":"Here is an explanation on how you can access your images.\nX is four dimensional tensor. In mathematics tensors are generalization of vectors and metrics into higher dimensional arrays.\nAssuming \"channels last\" data-format\n\n1st Axis = Number of images \n2nd Axis = Number of rows in single image\n3rd Axis = Number of columns in single row \n4th Axis = Number of channels of certain pixel  \n\nNow you can access image,row,column, and channels using indexing as follows. \n\nx[0] Represents first image  \nx[0][0] Represents First row of first image  \nx[0][0][0] Represents First column of first row of first image  \nx[0][0][0][0] Represents Red channel of First column of first row of first image","Q_Score":0,"Tags":"python,numpy,tensorflow,keras","A_Id":51569613,"CreationDate":"2018-07-28T08:31:00.000","Title":"How to properly use numpy in keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Has tkinter opacity like HTML?if you do HTML you understand what I say.I searched a lot in google, but I didn't find my answer.If you know help me,please.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":755,"Q_Id":51571242,"Users Score":0,"Answer":"Has tkinter opacity like HTML\n\nNo, it does not. The only setting you have is the opacity of the window as a whole. You can't set the opacity of individual widgets.","Q_Score":0,"Tags":"python,python-3.x,tkinter","A_Id":51575735,"CreationDate":"2018-07-28T12:09:00.000","Title":"How to set widget opacity in tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run the Transformer (speech2text) model on windows (till I get my linux machine).\nwhen I'm running the entire command from the cmd:\n\"python transformer_main.py --data_dir=$DATA_DIR --model_dir=$MODEL_DIR --params=$PARAMS\"\nI'm getting an error :\"ModuleNotFoundError: No module named 'tensorflow'\"\nBut I know that tf is installed and also when I'm using pycharm, first, I can see the package installed(File -> Settings ->Project interpreter).\nsecond, when I'm running the code it's passing that fall site...\nI can run through pycharm, but I think it's important to understand what I'm missing, Is it something with the interpreter?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":51572338,"Users Score":0,"Answer":"Most likely you are simply using a different interpreter from your command line than from your PyCharm project. This will happen, for example, if you have set up your PyCharm project using a fresh conda environment.\nTo see which one you are using on the command-line, simply run where python. Then compare this with what you found in PyCharm.","Q_Score":0,"Tags":"python,tensorflow","A_Id":51572366,"CreationDate":"2018-07-28T14:36:00.000","Title":"Getting:\"ModuleNotFoundError: No module named 'tensorflow'\", only when running from the command line","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hellow. It seems to me that I just don't understand something quite obvios in databases.  \nSo, we have an author that write books and have books themselves. One author can write many books as well as one book could be written by many authors. \nThus, we have two tables 'Books' and 'Authors'.\nIn 'Authors' I have an 'ID'(Primary key) and 'Name', for example:\n1 - L.Carrol\n2 - D.Brown \nIn 'Books'    -   'ID' (pr.key), 'Name' and 'Authors' (and this column is foreign key to the 'Authors' table ID)\n1 - Some_name - 2 (L.Carol)\n2 - Another_name - 2,1 (D.Brown, L.Carol)\nAnd here is my stumbling block, cause i don't understand how to provide the possibility to choose several values from 'Authors' table to one column in 'Books' table.But this must be so simple, isn't it?\nI've red about many-to-many relationship, saw many examples with added extra table to implement that, but still don't understand how to store multiple values from one table in the other's table column. Please, explain the logic, how should I do something like that ? I use SQLiteStudio but clear sql is appropriate too. Help ^(","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":343,"Q_Id":51572979,"Users Score":3,"Answer":"You should have third intermediate table which will have following columns:\n\nid (primary)\nauthor id (from Authors table)\nbook id (from Books table)\n\nThis way you will be able to create a record which will map 1 author to 1 book. So you can have following records:\n\n1 ... Author1ID ... Book1ID\n2 ... Author1ID ... Book2ID\n3 ... Author2ID ... Book2ID\n\nAuthorXID and BookXID - foreign keys from corresponding tables.\nSo Book2 has 2 authors, Author1 has 2 books.\nAlso separate tables for Books and Authors don't need to contain any info about anything except itself.\nAuthors .. 1---Many .. BOOKSFORAUTHORS .. Many---1 .. Books","Q_Score":0,"Tags":"python,sql,database,many-to-many,sqlitestudio","A_Id":51573120,"CreationDate":"2018-07-28T15:56:00.000","Title":"Many to many relationship SQLite (studio or sql)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to create a pandas dataframe consisting of two columns. The first columns will of datatype int and the second one will be of dictionary type. Then insert data into the dataframe iteratively.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":175,"Q_Id":51574236,"Users Score":0,"Answer":"No, this isn't possible.\nPandas dtypes(*) are closely related to NumPy dtypes. There are some differences and additions, e.g. for datetime and category, but in the general the rule holds. Often these additional dtypes are wrappers around NumPy dtypes. The key here is series with these specifically defined dtypes are held in contiguous memory blocks. They can manipulated with vectorised computations.\nA series which cannot be held in the fashion described above gets labelled with dtype object. This is nothing more than a sequence of pointers to arbitrary Python types. You should not consider this as an \"array of dictionaries\" in any vectorised sense. You can compare such a series to a list. You would never say that a list has \"dtype dict\" just because it contains dictionaries. Similarly, the fact that an object series only contains dictionaries doesn't make it a series of dtype dict.\n(*) Notice I use \"dtype\" instead of \"type\". This is intentional. \"dtype\" has a specific and important meaning in relation to Pandas \/ NumPy, as the rest of my answer should demonstrate.","Q_Score":0,"Tags":"python,pandas","A_Id":51574299,"CreationDate":"2018-07-28T18:44:00.000","Title":"How to create a pandas dataframe where the datatype of a column will be a dictionary?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an odd behavior that I can't seem to track down a cause for.\nI am using the Parallels Desktop Lite app running on High Sierra to create a new MacOS VM that is also running High Sierra for development.\nI have successfully built a Postgres \/ Gunicorn \/ Nginx \/ Supervisor \/ Django stack. I am using Django==1.9.2 for legacy reasons.\nI imported my legacy django website code and it runs fine. Now I start taking snapshots of the VM as I remove unneeded components from the Django site. \nSo say I have 10 apps in INSTALLED_APPS. I have successfully commented out \/ removed all of the code for 5 of them. I test the system, everything that is left runs fine. Then I take a snapshot of the VM and shut down for the day. The next day, I fire up the VM at the last snapshot to continue the process.\nHowever, now when I pull up the django website, I get a NoReverseMatch error for a namespace of an app that I had previously removed. And it is at line 0 of the base_template no less (which doesn't have a line 0). If I search through all of the remaining code, there is no longer any reference to the offending namespace, so I don't understand where this is coming from.\nCould it be django template caching? This error is reproducible as I go back through my snapshots, although the offending namespace name is different each time.\nThanks,\nMark","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17,"Q_Id":51574927,"Users Score":0,"Answer":"Update\nI still do not know why the ghost error happens when references to apps are commented out from templates, etc.\nTurning off django caching did not have any effect.\nWhat seemed to fix it was deleting the lines completely. After I deleted all of the lines I had previously commented out, the errors stopped happening.","Q_Score":0,"Tags":"python,django,templates,gunicorn,parallels","A_Id":51575958,"CreationDate":"2018-07-28T20:13:00.000","Title":"Ghost NoReverseMatch Error for Django app in Parallels VM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I might be sounding like a noob while asking this question but I really want to know how can I get the time from when my screen is on. Not the system up time but the screen up time. I want to use this time in a python app. So please tell me if there is any way to get that. Thanks in advance.\nEdit- I want to get the time from when the display is black due to no activity and we move mouse or press a key and screen comes up, the display is up, the user is able to read and\/or able to edit a document or play games. \nOS is windows .","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":51576081,"Users Score":0,"Answer":"In Mac OS ioreg might have the information you're looking for.\nioreg -n IODisplayWrangler -r IODisplayWrangler -w 0 | grep IOPowerManagement","Q_Score":1,"Tags":"python,windows,operating-system,kernel","A_Id":51576697,"CreationDate":"2018-07-28T23:43:00.000","Title":"Screen up time in desktop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed wxPython and am able to execute some scripts from Robin's great book. I am able to open pyCrust too. But if I try to wrap a wx script with pywrap, I get this -\n\nBlockquote\n  PS C:\\Users\\jf7366\\Documents\\PythonScripts\\wxpython> pywrap Flintstonize.py\n  pywrap : The term 'pywrap' is not recognized as the name of a cmdlet, function, script file, or operable program.\n  Check the spelling of the name, or if a path was included, verify that the path is correct and try again.\n  At line:1 char:1\n  + pywrap Flintstonize.py\n\nI tried installing pywrap by itself, successful install, but to no avail... Why would I have a PATH issue with pywrap but not PyCrust? This makes no sense to me obviously.\nRegards,\nJack","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":57,"Q_Id":51576086,"Users Score":1,"Answer":"It's more likely that pywrap needs the PATH, but PyCrust most probably does not, so the best solution would be to add Python To PATH.","Q_Score":1,"Tags":"python","A_Id":51577186,"CreationDate":"2018-07-28T23:44:00.000","Title":"Trouble using pywrap","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using miniconda and I want to prevent myself and other users of my machine from installing anything into the base environment. This is because I want users to be creating virtual environments and installing stuff there. I also don't want my base environment to get bloated.\nIs there anyway to do this? I use both conda and pip so I imagine I need to somehow block both of those.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1352,"Q_Id":51577258,"Users Score":5,"Answer":"One option would be to change the write permissions on the directories pip and conda install packages to for the base environments. These locations vary based on your distribution, but you can check by using something like python -c \"import setuptools; print(setuptools.__file__)\". The parent directory to setuputils will be where the packages get installed by default. Run chmod -w <packages dir> to remove write permissions. You can always add them back with chmod +w <packages dir> later, but while they're disabled this should keep you from installing packages there by accident. Unless you haphazardly install packages with sudo, that is...","Q_Score":6,"Tags":"python,pip,conda","A_Id":51577325,"CreationDate":"2018-07-29T04:38:00.000","Title":"Block package installations to conda base environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a web application set-up with Django (Python), and I want to convert it to an Android app (.apk).\nQuestion 1 : Can I use Django (with some extra-packages) to create the .apk\nQuestion 2 : Do I have to use Android Studio ? (I'm using Atom as a Text Editor).","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":532,"Q_Id":51579606,"Users Score":1,"Answer":"No you cant. Django is a web framework not a kit to develop android applications","Q_Score":0,"Tags":"android,python,django,android-studio,apk","A_Id":51580239,"CreationDate":"2018-07-29T11:00:00.000","Title":"Django to Android","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I don't know what title should be, I just got stuck and need to ask.\nI have a model called shift\nand imagine the db_table like this:\n\n#table shift\n+---------------+---------------+---------------+---------------+------------+------------+\n| start         | end           | off_start     | off_end       | time       | user_id    |\n+---------------+---------------+---------------+---------------+------------+------------+\n| 2018-01-01    | 2018-01-05    | 2018-01-06    | 2018-01-07    | 07:00      | 1          |\n| 2018-01-08    | 2018-01-14    | 2018-01-15    | Null          | 12:00      | 1          |\n| 2018-01-16    | 2018-01-20    | 2018-01-21    | 2018-01-22    | 18:00      | 1          |\n| 2018-01-23    | 2018-01-27    | 2018-01-28    | 2018-01-31    | 24:00      | 1          |\n| ....          | ....          | ....          | ....          | ....       | ....       |\n+---------------+---------------+---------------+---------------+------------+------------+\n\nif I use queryset with filter like start=2018-01-01 result will 07:00\nbut how to get result 12:00 if I Input 2018-01-10 ?...\nthank you!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":113,"Q_Id":51579732,"Users Score":1,"Answer":"Question isnt too clear, but maybe you're after something like \nstart__lte=2018-01-10, end__gte=2018-01-10?","Q_Score":0,"Tags":"python,django","A_Id":51579769,"CreationDate":"2018-07-29T11:14:00.000","Title":"Django Queryset find data between date","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In some progam languages for example PHP, deleting an item do not re-index automatically the array , i want to know the behaviour of a Python list after deleting an item with del()...","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":51582380,"Users Score":0,"Answer":"Index changes to reflect content.","Q_Score":0,"Tags":"python,list","A_Id":51582413,"CreationDate":"2018-07-29T16:36:00.000","Title":"Behaviour after deleting list item from List 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 tried to find the location of bge module of blender but after 2 days of research I got that it is the part of blender executable. \nActually I want to use it in PyCharm for only code completion.\nSo i adopted another strategy, I used this code to get the methods or classes of a module for i in dir(bge): print(i) . But it was not what i was expecting, I have to apply this for each class and method and it returns only names and I have to write them in the form of functions or classes. Is there any possibility to achieve this? There are some repositories on github for this but they dont have bge. Any suggestion or help will be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":51583984,"Users Score":0,"Answer":"Currently there is no way.\nIt is possible to build blender as a bpy module, allowing it to be imported outside of the blender executable. This is possible as part of the build system which does not currently implement the same for the bge module.\nAs blender is open source, you are free to alter the build system to also make building the bge module an option.","Q_Score":0,"Tags":"python,game-engine,blender","A_Id":51587584,"CreationDate":"2018-07-29T19:49:00.000","Title":"How to get Blender bge module as bge.py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any python package that could random generate connected graph (there is a path between every pair of vertices) on which each vertex has degree at most 4? \nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":275,"Q_Id":51584121,"Users Score":0,"Answer":"A simple algorithm I can think to is:\n\nStart with one vertex\nRepeat one of two random moves:\n2A) Pick a random vertex with degree less than 4 and add a new vertex connected to it\n2B) Pick two random vertices with degree less than 4 that are not connected and add an edge between them\n\nuntil you've enough vertices\/edges.","Q_Score":0,"Tags":"python,graph","A_Id":51584354,"CreationDate":"2018-07-29T20:06:00.000","Title":"python generate random connected graph with certain constraint on the vertex degree","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to machine learning and i developing a robot which environment is dynamic.\nI am using python as the programming language for my project.\nI have a goal state and robot has four actions such as forward, backward, turn right and turn left.\nThe problem is I cannot define the next state when robot take a one action. But I can identify state is goal state or not after each episode.\nHow can i apply Reinforcement learning model for this. Can i use pomdp ???","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":166,"Q_Id":51590086,"Users Score":1,"Answer":"Even if the environment is dynamic, you should have some notion of motion model where the discrete action should lead to the robot advancing \"one step\" straight. In a gridded world, it is easy, however, in a continuous environment, you can grid the world up and still use discrete action. If the next state is undefined, no machine learning\/decision making algorithm can work.","Q_Score":0,"Tags":"python,python-3.x,numpy,reinforcement-learning,q-learning","A_Id":51639189,"CreationDate":"2018-07-30T08:43:00.000","Title":"Q learning algorithm for robot where next state is not defined","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I pip installed OpenCV-python. The installation seems to be fine and I tested it out on the python IDLE. It ran without any problems. I've been trying to run it on VS Code but it doesn't seem to work. The autocomplete recognizes the imread function but when I type it in it throws up an error saying cv2 has no imread member. I am using the most updated version of python\nI am calling it like this:img2 = cv2.imread(\"C:\\Biometric\\min.jpg\", 0)","AnswerCount":7,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":33464,"Q_Id":51593147,"Users Score":53,"Answer":"Since you are trying to executing this with VS Code, try following steps\n\nOpen palette on VS Code (use specifies command): CTRL + Shift + P\nThen select \"Preferences > Open Settings (JSON)\" option in the palette dropdown\nThen add the following line in the opened settings.json file\npython.linting.pylintArgs\": [\"--generate-members\"]\n\nthis must work","Q_Score":19,"Tags":"python-3.x,opencv","A_Id":59050229,"CreationDate":"2018-07-30T11:38:00.000","Title":"cv2 python has no imread member","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I pip installed OpenCV-python. The installation seems to be fine and I tested it out on the python IDLE. It ran without any problems. I've been trying to run it on VS Code but it doesn't seem to work. The autocomplete recognizes the imread function but when I type it in it throws up an error saying cv2 has no imread member. I am using the most updated version of python\nI am calling it like this:img2 = cv2.imread(\"C:\\Biometric\\min.jpg\", 0)","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":33464,"Q_Id":51593147,"Users Score":0,"Answer":"Go to the terminal and type pylint --extension-pkg-whitelist=cv2\nit has worked for me.","Q_Score":19,"Tags":"python-3.x,opencv","A_Id":56180952,"CreationDate":"2018-07-30T11:38:00.000","Title":"cv2 python has no imread member","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As the title says, after I installed Pillow with pip install Pillow, when I'm trying to import it \"No module named 'PIL' \" error appears.\nI'm trying to import it with this code: from PIL import ImageTk, Image.\nI have pip 18.0 installed, and Pillow 5.2.0.\nI'm using just python 3.7.\nI have to mention that I don't have PIL installed.\nAfter trying with easy_install and python -m pip install, still don't work.\npython -m pip install returns: Collecting pillow Downloading files.pythonhosted.org\/packages\/72\/22\/\u2026 (1.4MB) 100% |\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 1.4MB 2.6MB\/s Installing collected packages: pillow Successfully installed pillow-5.2.0\nCommand python -c \"import sys; print(sys.path)\" returns: ['', 'c:\\\\users\\\\lenovo b590\\\\appdata\\\\local\\\\programs\\\\python\\\\python37-32\\\\python37.zip', 'c:\\\\users\\\\lenovo b590\\\\appdata\\\\local\\\\programs\\\\python\\\\python37-32\\\\DLLs', 'c:\\\\users\\\\lenovo b590\\\\appdata\\\\local\\\\programs\\\\python\\\\python37-32\\\\lib', 'c:\\\\users\\\\lenovo b590\\\\appdata\\\\local\\\\programs\\\\python\\\\python37-32', 'c:\\\\users\\\\lenovo b590\\\\appdata\\\\local\\\\programs\\\\python\\\\python37-32\\\\lib\\\\site-packages', 'c:\\\\users\\\\lenovo b590\\\\appdata\\\\local\\\\programs\\\\python\\\\python37-32\\\\lib\\\\site-packages\\\\win32', 'c:\\\\users\\\\lenovo b590\\\\appdata\\\\local\\\\programs\\\\python\\\\python37-32\\\\lib\\\\site-packages\\\\win32\\\\lib', 'c:\\\\users\\\\lenovo b590\\\\appdata\\\\local\\\\programs\\\\python\\\\python37-32\\\\lib\\\\site-packages\\\\Pythonwin']\n\nMaybe helps: I have VS 2017 installed with C++ and Python. I'v tryed to install python-pptx and got error: Command \"\"c:\\users\\lenovo b590\\appdata\\local\\programs\\python\\python37-32\\python.exe\" -u -c \"import setuptools, tokenize;__file__='C:\\\\Users\\\\LENOVO~1\\\\AppData\\\\Local\\\\Temp\\\\pip-install-_o4pnv9h\\\\lxml\\\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))\" install --record C:\\Users\\LENOVO~1\\AppData\\Local\\Temp\\pip-record-08vt5tx4\\install-record.txt --single-version-externally-managed --compile\" failed with error code 1 in C:\\Users\\LENOVO~1\\AppData\\Local\\Temp\\pip-install-_o4pnv9h\\lxml\\","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":325,"Q_Id":51594990,"Users Score":1,"Answer":"I was running the code through IDLE 3.6 (64-Bit), running it through IDLE 3.7 (32-Bit) solved the problem, thanks to FlyingTeller !","Q_Score":1,"Tags":"python,pip,compression,python-imaging-library","A_Id":51596042,"CreationDate":"2018-07-30T13:22:00.000","Title":"No module named PIL after installing Pillow (v5.2.0) with pip v18.0","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python 3.6 installed on my windows computer. I just installed GraphLab Create and now when I open up my Jupyter Notebooks, it shows Python 2 instead of Python 3 which it always was before. How do I go about changing it back to Python 3 in the easiest possible way? Thank you","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":758,"Q_Id":51596139,"Users Score":1,"Answer":"GraphLab Create only works in python-2.x. If you did use the GraphlabCreate.exe to install GraphLab, the .exe file installs Anaconda containing python 2.7 in your PC. So you have both python 2 and 3 versions in your system. You can find python3 jupyter notebook inside the Scripts folder in the location where you installed Anaconda3","Q_Score":0,"Tags":"python,python-3.x,python-2.7,jupyter-notebook,graphlab","A_Id":51597315,"CreationDate":"2018-07-30T14:21:00.000","Title":"Installing GraphLab creates makes my Jupyter Notebook degrade from Python 3.6 to Python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have set the Spyder 2.7 preferences as follows: Preferences->Run-> General Settings-> Default working directory is: the script directory. \nHowever for a particular script, spyder sets the working directory to the parent directory. \nI have scripts in the same directory which don't exhibit this behaviour and run with the expected wdir. \nI don't understand where or how the wdir is being altered from the default for this particular script.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1852,"Q_Id":51597380,"Users Score":2,"Answer":"Under 'run' menu-> configure. This gives you an option to set the working directory for each individual script.","Q_Score":1,"Tags":"python,spyder,working-directory","A_Id":51609695,"CreationDate":"2018-07-30T15:26:00.000","Title":"Spyder running script with different working directory to script directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have set the Spyder 2.7 preferences as follows: Preferences->Run-> General Settings-> Default working directory is: the script directory. \nHowever for a particular script, spyder sets the working directory to the parent directory. \nI have scripts in the same directory which don't exhibit this behaviour and run with the expected wdir. \nI don't understand where or how the wdir is being altered from the default for this particular script.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1852,"Q_Id":51597380,"Users Score":0,"Answer":"I don't have the solution, but I had the exact same problem with a MATLAB script a while ago. It turned out I ran a copy of the script, and it included the path of the original, and set that as the wdir. I ran the original, it worked. If I moved the original, it didn't run because it tried running it from the previous wdir.\nI ended up copying the code into a new script-file, which solved it for me.\nPerhaps you can try something similar.\nBest of luck!","Q_Score":1,"Tags":"python,spyder,working-directory","A_Id":51597459,"CreationDate":"2018-07-30T15:26:00.000","Title":"Spyder running script with different working directory to script directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why am I getting this error? I'm running v 3.8.2 of DRF. I'm wondering if docker has anything to do with it. Maybe the interpreter is trying to use\/find some other installation I have on my machine. Any suggestions\/help would be great. Thanks\nThis line is failing\nfrom rest_framework.decorators import action\nI'm replacing the list_route method to action on this line\n@action(methods=['POST'], permission_classes=[IsAuthenticated, ])\nI'm running a virtualenv created in pycharm and running pip freeze gives me:\n\n$ pip freeze\n...\nDjango==1.10.8\ndjango-extensions==2.1.0\ndjango-rest-swagger==2.2.0\ndjango-widget-tweaks==1.4.1\ndjangorestframework==3.8.2\n...\n\n\nbackend_1   | Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7fa4163708c8>\nbackend_1   | Traceback (most recent call last):\nbackend_1   |   File \"\/usr\/local\/lib\/python3.6\/site-packages\/django\/utils\/autoreload.py\", line 226, in wrapper\nbackend_1   |     fn(*args, **kwargs)\nbackend_1   |   File \"\/usr\/local\/lib\/python3.6\/site-packages\/django\/core\/management\/commands\/runserver.py\", line 121, in inner_run\nbackend_1   |     self.check(display_num_errors=True)\nbackend_1   |   File \"\/usr\/local\/lib\/python3.6\/site-packages\/django\/core\/management\/base.py\", line 374, in check\nbackend_1   |     include_deployment_checks=include_deployment_checks,\nbackend_1   |   File \"\/usr\/local\/lib\/python3.6\/site-packages\/django\/core\/management\/base.py\", line 361, in _run_checks\nbackend_1   |     return checks.run_checks(**kwargs)\nbackend_1   |   File \"\/usr\/local\/lib\/python3.6\/site-packages\/django\/core\/checks\/registry.py\", line 81, in run_checks\nbackend_1   |     new_errors = check(app_configs=app_configs)\nbackend_1   |   File \"\/usr\/local\/lib\/python3.6\/site-packages\/django\/core\/checks\/urls.py\", line 14, in check_url_config\nbackend_1   |     return check_resolver(resolver)\nbackend_1   |   File \"\/usr\/local\/lib\/python3.6\/site-packages\/django\/core\/checks\/urls.py\", line 24, in check_resolver\nbackend_1   |     for pattern in resolver.url_patterns:\nbackend_1   |   File \"\/usr\/local\/lib\/python3.6\/site-packages\/django\/utils\/functional.py\", line 35, in __get__\nbackend_1   |     res = instance.__dict__[self.name] = self.func(instance)\nbackend_1   |   File \"\/usr\/local\/lib\/python3.6\/site-packages\/django\/urls\/resolvers.py\", line 313, in url_patterns\nbackend_1   |     patterns = getattr(self.urlconf_module, \"urlpatterns\", self.urlconf_module)\nbackend_1   |   File \"\/usr\/local\/lib\/python3.6\/site-packages\/django\/utils\/functional.py\", line 35, in __get__\nbackend_1   |     res = instance.__dict__[self.name] = self.func(instance)\nbackend_1   |   File \"\/usr\/local\/lib\/python3.6\/site-packages\/django\/urls\/resolvers.py\", line 306, in urlconf_module\nbackend_1   |     return import_module(self.urlconf_name)\nbackend_1   |   File \"\/usr\/local\/lib\/python3.6\/importlib\/__init__.py\", line 126, in import_module\nbackend_1   |     return _bootstrap._gcd_import(name[level:], package, level)\nbackend_1   |   File \"<frozen importlib._bootstrap>\", line 978, in _gcd_import\nbackend_1   |   File \"<frozen importlib._bootstrap>\", line 961, in _find_and_load\nbackend_1   |   File \"<frozen importlib._bootstrap>\", line 950, in _find_and_load_unlocked\nbackend_1   |   File \"<frozen importlib._bootstrap>\", line 655, in _load_unlocked\nbackend_1   |   File \"<frozen importlib._bootstrap_external>\", line 678, in exec_module\nbackend_1   |   File \"<frozen importlib._bootstrap>\", line 205, in _call_with_frames_removed\nbackend_1   |   File \"\/project_backend\/project_backend\/urls.py\", line 20, in <module>\nbackend_1   |     from apps.app_name.views import XYZViewSet\nbackend_1   |   File \"\/project_backend\/apps\/app_name\/views.py\", line 4, in <module>\nbackend_1   |     from rest_framework.decorators import action\nbackend_1   | ImportError: cannot import name 'action'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3579,"Q_Id":51598930,"Users Score":3,"Answer":"My virtual environment and docker container were not using the same django rest framework version. I had to ssh into my docker container via docker exec -it <container_id> bash and run pip install djangorestframework --upgrade this gave me the 3.8.2 version I was looking for.\nDocker installed 3.4.7 because I used to have djangorestframework<3.5 in the requirements file and the container was stored in that state. I could have deleted the container and rerun docker-compose up to recreate the container with the newer version of 3.8.2. I of course opted to just upgrade with pip instead.","Q_Score":1,"Tags":"python,django,django-rest-framework","A_Id":51601919,"CreationDate":"2018-07-30T16:58:00.000","Title":"DRF ImportError: cannot import name 'action' on v3.8.2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using a windows client to perform UI automated tests. each time i start the test using cmd or eclipse the browser opens up and goes to the given url but it does not continue, instead, a small window is opened with \"Chromedriver.exe stopped working\" message on it. how can I solve this issue?\nI am using on this windows client : python 2.7.15, selenium 3.5.0 , robot framework 3.0.2,windows 7 professional , and chrome\nP.S. : I already tried upgrading and downgrading both chrome and chrome driver,\nalso, used selenium 3.13.0 then downgraded again to selenium 3.5.0.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":234,"Q_Id":51599659,"Users Score":1,"Answer":"I figured out the problem . Chrome driver version in the system was an old one despite the fact that i downloaded the newest. I managed to delete the old one from my system. It works fine now","Q_Score":0,"Tags":"python,selenium,selenium-chromedriver","A_Id":51605292,"CreationDate":"2018-07-30T17:51:00.000","Title":"chromedriver.exe stopped working issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I create many records in my DB as follows:\nSubproducts.create(mf_id=mf_id,\n                     co=co,\n                     mf_binary=mf_binary_data.getbuffer())\nmf_binary type is io.BytesIO() - it is binary representation of binary files collected into zipfile\nI've successfully created many records using this approach, however I have an issue with one particular dataset. \nIt is a bigger than other and it takes ~1,2GB. \nWhen I try to save it in DB following error occurs.\npeewee.InterfaceError: Error binding parameter 2 - probably unsupported type.\nField of mf_binary in my model is peewee.BlobField(default=b'0')\nHow can I store this kind of data in peewee Database?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":597,"Q_Id":51600405,"Users Score":0,"Answer":"Calling getbuffer() returns a memoryview object which is apparently not supported by the underlying database driver (which one is it, by the way?). The InterfaceError is raised by your database driver as opposed to Peewee, which indicates the problem comes from your driver not understanding how to handle memoryview objects.\nYour best bet is to use mf_binary_data.getvalue(), which should return a bytes object.","Q_Score":1,"Tags":"python,database,orm,zip,peewee","A_Id":51601055,"CreationDate":"2018-07-30T18:47:00.000","Title":"peewee.InterfaceError: Error binding parameter while saving big amout of data","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to add an existing python project with a python virtual environment to visual studio 2017 so I can debug it.\nThe project also has some external dependencies,\nEverything is arranged in the following folders\nC:\\myproject\\code\nC:\\myproject\\portablepython\nC:\\myproject\\pylibrary\nI created the project using File->New Project->Python->From Existing Python Code\nI added PortablePython virtual environment using Tools->Python->Python Environments using C:\\myproject\\portablepython as prefix path,\nC:\\myproject\\portablepython\\python.exe as Interpreter path\nC:\\myproject\\portablepython\\wpython.exe as Windowed Interpreter path\nLanguage auto detected as 3.6, 64 bit, and I even added C:\\myproject\\pylibrary as the path environment variable.\nI also added pylibrary to project search paths so that it looks like ..\\pylibrary\nMy issue is when I build the project, it fails on the very first pylibrary import with ImportError(\"cannot import name 'mdevice'\",) on the line \nfrom mdevice import mdevice\nAnd this module is clearly in the C:\\myproject\\pylibrary path\nWhat's more interesting is when I remove portablepython from Python environments, and it defaults to Python 3.6, it finds the first module, but it can't find the second module on the line below the first one. \nBoth modules are in C:\\myproject\\pylibrary\nI don't know what is wrong with Visual Studio here, seems like a bug to me\nSide note: I had to create the virtual environment using Tools->Python->Python Environments because when I right click on project and select Add Virtual Environment and select C:\\myproject\\portablepython it actually shows \"We Cannot Create a Virtual Environment at the Specified path. Choose a folder that does not exist, is empty, or contains and existing virtual environment\" eventhough it clearly contains the correct python files in this folder.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1079,"Q_Id":51601594,"Users Score":0,"Answer":"Python paths aren't set specifically by python code or project files, they are set as system path variables.\nIn order to add the modules and the interpreter, I needed to add a PYTHONPATH to system variables and have it point to the folder containing modules, then add the Python.exe path to the top of the path list","Q_Score":2,"Tags":"python,windows,python-3.x,visual-studio-2017","A_Id":51623654,"CreationDate":"2018-07-30T20:09:00.000","Title":"Python in Visual Studio 2017 fails to find modules via the Search Paths","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"XLSXWRITER works on my Mac computer when I run my kivy app and successfully creates an XLSX file.\nUnfortunately once I compile the apk using buildozer the \"Export\" button I made doesn't create the XLSX. \nNo crash occurs, I just can't find the XLSX that should have been created. My theory is that the spreadsheet is created but 'lives' within the APK Package.\nPlease help me to create XLSX using Kivy on android!\n* Python 2.7.15\n* Kivy 1.9.1\n* Android Phone","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":51603822,"Users Score":0,"Answer":"With an aid from @\"John Anderson\", the solution lies in the AndroidManifest.xml file, where one can simply \"comment out\" using the html comments \"\". At the bottom one can find the list of permissions that the app may or may not require, and can thereby comment out unnecessary permissions like \"WRITE_EXTERNAL_STORAGE\".","Q_Score":0,"Tags":"python,apk,kivy,xlsxwriter","A_Id":59485426,"CreationDate":"2018-07-31T00:12:00.000","Title":"Why doesn't XLSXWRITER create a file once my Kivy app is compliled into an APK?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install tensorflow for their image recognition program thing, but I get the error in the title, it does work when i go to C:\\Users\\Diederik\\AppData\\Local\\Programs\\Python\\Python36\\Scripts, and type pip3 install --upgrade tensorflow there, but I am not sure if that is how I am supposed to do it, since I tried that before and I got errors while running the classify_image.py, so I thought maybe I should try it the way tensorflow told me to, but that didn't work, Please help me, I am happy to provide any extra information you need. I am on windows 10","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":857,"Q_Id":51604098,"Users Score":0,"Answer":"Try .\/pip3 install --upgrade tensorflow from that directory. I think on windows, you need to be explicit that the command is in your working directory. Alternatively you could try \nC:\\Users\\Diederik\\AppData\\Local\\Programs\\Python\\Python36\\Scripts\\pip3 install --upgrade tensorflow. That's how I do it on my windoze machine.","Q_Score":0,"Tags":"python,windows,tensorflow,artificial-intelligence","A_Id":51604459,"CreationDate":"2018-07-31T00:56:00.000","Title":"Installing tensorflow, getting error 'pip3' is not recognized as an internal or external command, operable program or batch file\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an s3 bucket which has a large no of zip files having size in GBs. I need to calculate all zip files data length. I go through boto3 but didn't get it.\nI am not sure if it can directly read zip file or not but I have a process-\n\nConnect with the bucket.\nRead zip files from the bucket folder (Let's say folder is Mydata).\nExtract zip files to another folder named Extracteddata.\nRead Extracteddata folder and do action on files.\n\nNote: Nothing shouldn't download on local storage. All process goes on S3 to S3.\nAny suggestions are appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8072,"Q_Id":51604689,"Users Score":0,"Answer":"This is not possible.\nYou can upload files to Amazon S3 and you can download files. You can query the list of objects and obtain metadata about the objects. However, Amazon S3 does not provide compute, such as zip compression\/decompression.\nYou would need to write a program that:\n\nDownloads the zip file\nExtracts the files\nDoes actions on the files\n\nThis is probably best done on an Amazon EC2 instance, which would have low-latency access to Amazon S3. You could do it with an AWS Lambda function, but it has a limit of 500MB disk storage and 5 minutes of execution, which doesn't seem applicable to your situation.\nIf you are particularly clever, you might be able to download part of each zip file ('ranged get') and interpret the zipfile header to obtain a listing of the files and their sizes, thus avoiding having to download the whole file.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-s3,boto3","A_Id":51604927,"CreationDate":"2018-07-31T02:36:00.000","Title":"Read zip files from amazon s3 using boto3 and python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to play a sound and display some information on the screen in my program.\nI'm currently using the following:\nwinsound.PlaySound('chaching.wav', winsound.SND_FILENAME)\n messagebox.showinfo(\n     \"Info\", \"Assigned {} to {}, the password is {}\".format(\n     id, acc_name, acc_pass))\nHowever that makes the stupid error noise when the message box is triggered.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2822,"Q_Id":51604921,"Users Score":1,"Answer":"I'm pretty sure there's no way to do this; calling bell() whenever a Message is displayed is part of Tcl\/Tk, not something Python\/Tkinter adds on top of it.1\nBut you can always use SimpleDialog to build a modal dialog that looks just like MessageBox but isn't one, and doesn't sound like one.2.\n\n1. Well, if you really wanted to reach down into the Tcl code\u2026 but you don't.\n2. IIRC, SimpleDialog does call bell() if you do things like press Esc or hit the close box on a dialog with no cancel button set. But I'm pretty sure that is done by Python\/Tkinter, not Tcl\/Tk, so you can just override the wm_delete_window or whichever method is responsible. Or just not create a window without a cancel button.","Q_Score":1,"Tags":"python,audio,tkinter,messagebox","A_Id":51605052,"CreationDate":"2018-07-31T03:08:00.000","Title":"How do I change or disable the default sound for tkinter message boxes in python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way in python (by using NLTK or SpaCy or any other library) that I can predict the POS tag of the word that are likely to follow the words so far I have entered.\nEg- If i input\n\nI am going to\n\nIt shows the POS tag of the next most likely word\neg NN, becuase college can come after this","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":345,"Q_Id":51605036,"Users Score":2,"Answer":"You may train a simple language model on POS tag data using LSTMs. That is, say, using Spacy, convert your corpus to POS tag corpus. Train the model using the new corpus. Predict the POS on evaluation. Another way to do it is by building a language model on your data, generate the next word and find its POS.","Q_Score":1,"Tags":"python,nlp,nltk","A_Id":51608308,"CreationDate":"2018-07-31T03:26:00.000","Title":"Predicting the POS tag of the upcoming word","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is, I think, too simple, but it's giving me headaches. I think I'm missing either something conceptually in Neural Networks or Tensorflow is returning some wrong layer. \nI have a network in which last layer outputs 4800 units. The penultimate layer has 2000 units. I expect my weight matrix for last layer to have the shape (4800, 2000) but when I print out the shape in Tensorflow I see (2000, 4800). Please can someone confirm which shape of weight matrix the last layer should have? Depending on the answer, I can further debug the issue. Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1570,"Q_Id":51608879,"Users Score":4,"Answer":"Conceptually, a neural network layer is often written like y = W*x where * is matrix multiplication, x is an input vector and y an output vector. If x has 2000 units and y 4800, then indeed W should have size (4800, 2000), i.e. 4800 rows and 2000 columns.\nHowever, in implementations we usually work on a batch of inputs X. Say X is (b, 2000) where b is your batch size. We don't want to transform each element of X individually by doing W*x as above since this would be inefficient.\nInstead we would like to transform all inputs at the same time. This can be done via Y = X*W.T where W.T is the transpose of W. You can work out that this essentially applies W*x to each row of X (i.e. each input). Y is then a (b, 4800) matrix containing all transformed inputs.\nIn Tensorflow, the weight matrix is simply saved in this transposed state, since it is usually the form that is needed anyway. Thus, we have a matrix with shape (2000, 4800) (the shape of W.T).","Q_Score":1,"Tags":"python-3.x,tensorflow,conv-neural-network","A_Id":51611176,"CreationDate":"2018-07-31T08:32:00.000","Title":"Weights Matrix Final Fully Connected Layer","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am not trying to get all duplicate querysets and I am not trying to compare two queryset results and see of the two comparison are the same.\nSomehow, I have no idea how this happened yet but sometimes there are records being saved twice and some not.  So when I do querying my result would sometimes have duplicates.\nFor example, I am just doing Model.objects.filter(user='myname')\nI would get maybe 50 instances back, all of them should be different.  But somehow maybe id 11 and 12 have the exact same values then 23 and 24 has the same values and the others are totally fine.\nSo actually within those 50 instances, there are 2 duplicates which means I should only have 48 instances instead of 50 to be accurrate.\nIs there a way to check the queryset and return only one of the duplicates with other querysets if the values are totally the same?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":138,"Q_Id":51612266,"Users Score":0,"Answer":"you can do that using distinct in your orm query eg.Model.objects.filter(user='myname').distinct('field_name')\nthis will give you only distinct values based on the field that you provide.","Q_Score":0,"Tags":"python,django,duplicates,django-queryset","A_Id":51613297,"CreationDate":"2018-07-31T11:25:00.000","Title":"is there a way to only get one of the duplicates in a queryste? django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a few linear regression models and due to underlying reasons need to need have the weights for a set regression to be user-defined. is it possible to get an OLS summary based user-defined weights rather than the linear regression weights it finds itself?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":476,"Q_Id":51615868,"Users Score":0,"Answer":"If you're doing a linear regression, and you know some of the weights, you can essentially mathematically reduce it to a simpler regression. For instance assume you have the following regression\nz = ax + by\nGiven z, x, y it's relatively easy to set up a linear regression. If you want the user to specify (a) rather than having the system solve for it, then your expression becomes\nz' = by where z' = z - ax, where a is a coefficient that is specified by your end user.\nmodel = sm.OLS(Predicted_Z, Actual_Z)\nresults = model.fit()\nprint(results.summary())","Q_Score":1,"Tags":"python,statistics,regression,linear-regression,summary","A_Id":51615949,"CreationDate":"2018-07-31T14:32:00.000","Title":"python specify weights for linear regression","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I`ve recently started having problems with pip installs. Every time I run this kind of command in Terminal, I get an error:\nCould not install packages due to:\n\nEnvironmentError: [Errno 2] No such file or directory: '\/'me'\/'me'\/anaconda3\/lib\/python3.6\/site-packages\/tqdm-4.11.2.dist-info\/METADATA'\n\nDoes anyone know what's wrong? Didn't have this issue a month ago. Please help!\nJust in case: the error above popped up when i wrote pip install gender-guesser.","AnswerCount":8,"Available Count":4,"Score":0.1243530018,"is_accepted":false,"ViewCount":35287,"Q_Id":51617284,"Users Score":5,"Answer":"I met the same problem and this might work for you\ncd into the location where metadata.json exists and type this command  cp metadata.json METADATA then you could do sudo pip install","Q_Score":14,"Tags":"python,pip,installation","A_Id":53571785,"CreationDate":"2018-07-31T15:42:00.000","Title":"Could not install packages due to an EnvironmentError: [Errno 2]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I`ve recently started having problems with pip installs. Every time I run this kind of command in Terminal, I get an error:\nCould not install packages due to:\n\nEnvironmentError: [Errno 2] No such file or directory: '\/'me'\/'me'\/anaconda3\/lib\/python3.6\/site-packages\/tqdm-4.11.2.dist-info\/METADATA'\n\nDoes anyone know what's wrong? Didn't have this issue a month ago. Please help!\nJust in case: the error above popped up when i wrote pip install gender-guesser.","AnswerCount":8,"Available Count":4,"Score":-1.0,"is_accepted":false,"ViewCount":35287,"Q_Id":51617284,"Users Score":-4,"Answer":"I find the METADATA file in this path or this path subdirctory, then cp this file","Q_Score":14,"Tags":"python,pip,installation","A_Id":54664780,"CreationDate":"2018-07-31T15:42:00.000","Title":"Could not install packages due to an EnvironmentError: [Errno 2]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I`ve recently started having problems with pip installs. Every time I run this kind of command in Terminal, I get an error:\nCould not install packages due to:\n\nEnvironmentError: [Errno 2] No such file or directory: '\/'me'\/'me'\/anaconda3\/lib\/python3.6\/site-packages\/tqdm-4.11.2.dist-info\/METADATA'\n\nDoes anyone know what's wrong? Didn't have this issue a month ago. Please help!\nJust in case: the error above popped up when i wrote pip install gender-guesser.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":35287,"Q_Id":51617284,"Users Score":0,"Answer":"copy all the files in \"\/home\/shuaizhang\/.local\/lib\/python3.6\/site-packages\/pip-19.0.1.dist-info\/pip-19.0.1.dist-info\/\" to the upper directory \"\/home\/shuaizhang\/.local\/lib\/python3.6\/site-packages\/pip-19.0.1.dist-info\/\"\nThen, pip3 install --user --upgrade pip , solved my problem.\nI hope this will help.","Q_Score":14,"Tags":"python,pip,installation","A_Id":55566403,"CreationDate":"2018-07-31T15:42:00.000","Title":"Could not install packages due to an EnvironmentError: [Errno 2]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I`ve recently started having problems with pip installs. Every time I run this kind of command in Terminal, I get an error:\nCould not install packages due to:\n\nEnvironmentError: [Errno 2] No such file or directory: '\/'me'\/'me'\/anaconda3\/lib\/python3.6\/site-packages\/tqdm-4.11.2.dist-info\/METADATA'\n\nDoes anyone know what's wrong? Didn't have this issue a month ago. Please help!\nJust in case: the error above popped up when i wrote pip install gender-guesser.","AnswerCount":8,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":35287,"Q_Id":51617284,"Users Score":2,"Answer":"I use Pycharm.\nI have solved with problem with copy file METADATA from \\AppData\\Roaming\\Python\\Python37\\site-packages\\pip-19.0.1.dist-info\\pip-19.0.1.dist-info\nto higher level \\AppData\\Roaming\\Python\\Python37\\site-packages\\pip-19.0.1.dist-info","Q_Score":14,"Tags":"python,pip,installation","A_Id":54737235,"CreationDate":"2018-07-31T15:42:00.000","Title":"Could not install packages due to an EnvironmentError: [Errno 2]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python program that gives me all the details regarding different VM instances of a Virtual Machine Scale Set(VMSS) in Azure, in JSON format. However, I want something (a parameter) to  identify which Public IP is for which instance.\nThe program just gives me a list of Public IP's of the all the instances now. So, let us assume that I want to get the Public IP of the 3rd instance specifically. \nWhat should I do?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1088,"Q_Id":51617438,"Users Score":0,"Answer":"The questions is not really valid.\nInstances are all behind a LoadBalancer, technically because of source NAT the primary LoadBalancer IP is the out going Public IP for all traffic.\nBut incoming Public IP can be any FrontEnd IP depending on LoadBalancer rule or NAT Rule.\nThe public IP are not really tied to the instances, unless i am missing something.","Q_Score":1,"Tags":"python,azure,azure-virtual-machine,azure-cli,azure-vm-scale-set","A_Id":51620990,"CreationDate":"2018-07-31T15:51:00.000","Title":"Getting public IP of instances in Azure VMSS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After installing Anaconda to C:\\ I cannot open jupyter notebook. Both in the Anaconda Prompt with jupyter notebook and inside the navigator. I just can't make it to work. It doesn't appear any line when I type jupyter notebook iniside the prompt. Neither does the navigator work. Then after that I reinstall Anaconda, didn't work either. \nBut then I try to reinstall jupyter notebook dependently using python -m install jupyter and then run python -m jupyter. It works and connect to the localhost:8888. So my question is that how can I make Jupyter works from Anaconda\nAlso note that my anaconda is not in the environment variable( or %PATH% ) and I have tried reinstalling pyzmq and it didn't solve the problem. I'm using Python 3.7 and 3.6.5 in Anaconda\nMoreover, the spyder works perfectly","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2335,"Q_Id":51617979,"Users Score":1,"Answer":"You need to activate the anaconda environment first.\nIn terminal: source activate environment_name, (or activate environment_name on windows?)\nthen jupyter notebook\nIf you don't know the env name, do conda list\nto restore the default python environment: source deactivate","Q_Score":1,"Tags":"python,anaconda,jupyter-notebook,jupyter","A_Id":51624703,"CreationDate":"2018-07-31T16:24:00.000","Title":"cannot run jupyter notebook from anaconda but able to run it from python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a content-based recommender that works... fine. I was fairly certain it was the right approach to take for this problem (matching established \"users\" with \"items\" that are virtually always new, but contain known features similar to existing items).\nAs I was researching, I found that virtually all examples of content-based filtering use articles\/movies as an example and look exclusively at using encoded tf-idf features from blocks of text. That wasn't exactly what I was dealing with, but most of my features were boolean features, so making a similar vector and looking at cosine distance was not particularly difficult. I also had one continuous feature, which I scaled and included in the vector. As I said, it seemed to work, but was pretty iffy, and I think I know part of the reason why...\nThe continuous feature that I'm using is a rating (let's call this \"deliciousness\"), where, in virtually all cases, a better score would indicate an item more favorable for the user. It's continuous, but it also has a clear \"direction\" (not sure if this is the correct terminology). Error in one direction is not the same as error in another.\nI have cases where some users have given high ratings to items with mediocre \"deliciousness\" scores, but logically they would still prefer something that was more delicious. That user's vector might have an average deliciousness of 2.3. My understanding of cosine distance is that in my model, if that user encountered two new items that were exactly the same except that one had a deliciousness of 1.0 and the other had a deliciousness of 4.5, it would actually favor the former because it's a shorter distance between vectors.\nHow do I modify or incorporate some other kind of distance measure here that takes into account that deliciousness error\/distance in one direction is not the same as error\/distance in the other direction?\n(As a secondary question, how do I decide how to best scale this continuous feature next to my boolean features?)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":51618103,"Users Score":1,"Answer":"There are two basic approaches to solve this:\n(1) Write your own distance function.  The obvious approach is to remove the deliciousness element from each vector, evaluating that difference independently.  Use cosine similarity on the rest of the vector.  Combine that figure with the taste differential as desired.\n(2) Transform your deliciousness data such that the resulting metric is linear.  This will allow a \"normal\" distance metric to do its job as expected.","Q_Score":1,"Tags":"python,machine-learning,cosine-similarity,recommender-systems","A_Id":51618254,"CreationDate":"2018-07-31T16:30:00.000","Title":"Handling Error for Continuous Features in a Content-Based Filtering Recommender System","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After fitting a GradientBoostingClassifier in SciKit-Learn, some of the features have zero importance.\nMy understanding is that zero importance would mean that no splits are made on this feature.\nIf I try to predict using a data set that does not include the feature then it throws an error for not having all the features.\nOf course I realize I can remove the zero importance features, but I would rather not alter the already fit model. (If I remove the zero importance features and refit I get a slightly different model.) \nIs this a bug that the model requires zero importance features to make predictions or is there something about the zero importance features I'm not thinking about? Is there a work around to get the exact same model?\n(I'm forseeing a question about why this matters -- it's because requiring zero importance features means pulling more columns from a very very large database and it looks sloppy to include a feature in the model that does nothing.)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":414,"Q_Id":51619180,"Users Score":0,"Answer":"This is not a bug and is the expected behavior.  Scikit will not make assumptions after the model has been trained about what features should have been included or not.  \nInstead, when you call fit for a model there is an implicit assumption being made that you have already performed feature selection to remove features that will not be important to the model.  Once fit the expectation is that you will provide a dataset of the same size that was used to fit the model regardless of whether the features are important or not.","Q_Score":2,"Tags":"python,machine-learning,scikit-learn","A_Id":51620347,"CreationDate":"2018-07-31T17:43:00.000","Title":"Zero Importance Feature Removal Without Refit in SciKit-Learn GradientBoostingClassifier","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When compiling python to javascript using transcrypt I've noticed the syntax error reporting is more vague than the standard python syntax error reporting. Since the code cannot be compiled using the standard python compiler as it would throw syntax errors due to the transcrypt syntax is there a way to get more specific syntax error reporting that resembles the python compiler?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":157,"Q_Id":51621205,"Users Score":0,"Answer":"In some cases: yes, in general: no.\nTranscrypt syntax IS Python syntax, since both use CPython's ast module to parse the source code.\nBut Transcrypt programs may call JavaScript code, which won't work in CPython.\nSo while many Transcrypt modules can also be used with CPython, the ones directly using JavaScript can not.\nFor those modules, the (syntax and semantics) error reporting of the CPython interpreter is unavailable.\nOne note about the __pragma__'s. Indeed even those syntactically are simply function calls, although semantically they work at compile time.\nNote that running Transcrypt modules with the CPython interpreter is the core of what Transcrypt's back-to-back autotesting system is all about. Without this possibility it would be very hard to avoid regression bugs in new releases.\nCorrect Transcrypt behavior is simply defined as \"what CPython would do\"...","Q_Score":0,"Tags":"python,transcrypt","A_Id":51965168,"CreationDate":"2018-07-31T20:02:00.000","Title":"When compiling python using transcrypt is it possible to get standard python error logging?","Data 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 written a python program that periodically runs with ApScheduler package. The .pyw file runs in the background, but when I restart the PC the program doesn't continue running. \nWhat can I do to run a code automatically in startup a windows 10 pc?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4526,"Q_Id":51622702,"Users Score":4,"Answer":"You should consider putting your python file to the Startup folder.\nClick Win+R at the same time on your keyboard\nType shell:startup\nDrag and drop your python file onto the folder that opened.\nNote: I reccomend to put a shortcut of your python file for easier editing.","Q_Score":4,"Tags":"python,windows,python-3.x,startup,apscheduler","A_Id":51622853,"CreationDate":"2018-07-31T21:59:00.000","Title":"Windows 10 run python program in startup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to learn python practically.\nI installed PIP via easy_install and then I wanted to play with some mp3 files so I installed eyed3 via pip while in the project directory. Issue is that it installed the module into python 2.7 which comes standard with mac. I found this out as it keeps telling me that when a script does not run due to missing libraries like libmagic and no matter what I do, it keeps putting any libraries I install into 2.7 thus not being found when running python3. \nMy question is how to I get my system to pretty much ignore the 2.7 install and use the 3.7 install which I have.\nI keep thinking I am doing something wrong as heaps of tutorials breeze over it and only one has so far mentioned that you get clashes between the versions. I really want to learn python and would appreciate some help getting past this blockage.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":51622876,"Users Score":0,"Answer":"Have you tried pip3 install [module-name]?\nThen you should be able to check which modules you've installed using pip3 freeze.","Q_Score":0,"Tags":"python,eyed3,libmagic","A_Id":51622986,"CreationDate":"2018-07-31T22:16:00.000","Title":"How do i get Mac 10.13 to install modules into a 3.x install instead of 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I can execute both expressions in Python shell without error:\n\nstring = 'this is a string'\n  list(string)[::-1]\n(output) ['g', 'n', 'i', 'r', 't', 's', ' ', 'a', ' ', 's', 'i', ' ', 's', 'i', 'h', 't']\nlist(string).reverse()\n\nI can do:\n\nstring = ''.join(list(string)[::-1])\n\nwhich effectively reverse the string in place. However when I do:\n\nstring = ''.join(list(string).reverse()\n\nI got an error:\n\nTypeError: can only join an iterable\n\nSo list(string).reverse() does not return an iterable but list(string)[::-1] does. Can someone help me understand the underlying differences?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":91,"Q_Id":51625723,"Users Score":4,"Answer":"list.reverse() mutates the list it is called from so the list is altered after the call, while sequence[::-1] creates a new list and returns it, so the original list is unaffected.","Q_Score":0,"Tags":"python,list,iterable","A_Id":51625741,"CreationDate":"2018-08-01T05:11:00.000","Title":"(In Python) What's the difference between list(string).reverse() and list(string)[::-1]?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have developed two applications, one ReactJS, and one Python using Flask. The development was for ReactJS only at first, but then I created the Flask app to use it to write to files on server, and run batch files. I am getting the data from an API that belongs to another application. The Flask app is the only app to communicate with the API, while the React app gets the data to display by sending to Flask. Also using a Flask app as a middle agent made the CORS issue go away so far.\nNo the question is, what is the best practice to deploy on windows server under current circumstances? I searched and found that I have two options, IIS and Apache. I never deployed any application before other that on Heroku, so I'm far from familiar with the task.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":624,"Q_Id":51625930,"Users Score":0,"Answer":"I made my reactjs app a static single-page-app (npm run build ) and hosted the js files through a custom flask endpoint.\nThis may not be an option for you though in which case you can configure apache (or iis) to host both flask (with mod_wsgi) and proxy nodejs react.\nYou can also run both sites on a different port or vhost but then you may have to configure CORS.","Q_Score":0,"Tags":"python,reactjs,flask,deployment,windows-server-2012","A_Id":51634777,"CreationDate":"2018-08-01T05:34:00.000","Title":"What is the best way to deploy a Python Flask application along with a ReactJS application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm doing some work on the data in an excel sheet using python pandas. When I write and save the data it seems that pandas only saves and cares about the raw data on the import. Meaning a lot of stuff I really want to keep such as cell colouring, font size, borders, etc get lost. Does anyone know of a way to make pandas save such things?\nFrom what I've read so far it doesn't appear to be possible. The best solution I've found so far is to use the xlsxwriter to format the file in my code before exporting. This seems like a very tedious task that will involve a lot of testing to figure out how to achieve the various formats and aesthetic changes I need. I haven't found anything but would said writer happen to in any way be able to save the sheet format upon import? \nAlternatively, what would you suggest I do to solve the problem that I have described?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":468,"Q_Id":51626502,"Users Score":0,"Answer":"Separate data from formatting. Have a sheet that contains only the data \u2013 that's the one you will be reading\/writing to \u2013 and another that has formatting and reads the data from the first sheet.","Q_Score":1,"Tags":"python,excel,pandas,xlsxwriter","A_Id":51628570,"CreationDate":"2018-08-01T06:16:00.000","Title":"Any way to save format when importing an excel file in Python?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I use a single Elastic Search connection object in multiple files of python? I tried making it global but it didn't work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":51626940,"Users Score":0,"Answer":"You have to pass the Es object as an argument. So when you call a method or a function from a different python file, you pass this object as function\/method argument. I doubt if you can achieve something like that by using global variables.","Q_Score":0,"Tags":"python,elasticsearch,connection","A_Id":51627172,"CreationDate":"2018-08-01T06:46:00.000","Title":"Using single elastic search connection object across multiple python files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How would I configure structlog such that all messages including above info would go to stdout using a KeyValueRenderer while all logging would also go to a file using a JSONRenderer?\nnote: I only want to use structlog, no standard library stuff","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":253,"Q_Id":51627041,"Users Score":0,"Answer":"structlog doesn't do this out of the box, you'll need to write the required code yourself. structlog is built in a way to make this straightforward and it should be around a dozen of LoC.","Q_Score":1,"Tags":"python,json,rendering,stdout,structlog","A_Id":51656861,"CreationDate":"2018-08-01T06:51:00.000","Title":"setting up trees of renderers in structlog","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Context: I implemented tests which use docker-py to create docker networks and run docker containers. The test runner used to execute the tests is pytest. The test setup depends on Python (Python package on my dev machine), on my dev machines docker daemon and my dev machines static ip address. In my dev machine runtime context the tests run just fine (via plain invocation of the test runner pytest). Now I would like to migrate the tests into gitlab-ci. gitlab-ci runs the job in a docker container which accesses the CI servers docker daemon via \/var\/run\/docker.sock mount. The ip address of the docker container which is uses by gitlab-ci to run the job in is not static like in my dev machine context. But for the creation of the docker networks in the test I need the ip address.\nQuestion: How can I get the appropriate ip address of the docker container the tests are executed in with Python?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":2714,"Q_Id":51629194,"Users Score":-1,"Answer":"When you run docker you can share the same network as the host if asked.\nAdd to the run command --network host\nSuch parameter will cause the python network code be the same as you run the code without container.","Q_Score":2,"Tags":"python,docker,gitlab,dockerpy","A_Id":51630443,"CreationDate":"2018-08-01T08:57:00.000","Title":"How can I get the host ip in a docker container 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":1,"Web Development":0},{"Question":"I am currently testing gradient-based optimisation in OpenMDAO with high-fidelity flow solvers (SU2) but the shape parameterisation method I am using appears to be highly sensitive to the step size of the finite difference approximation. This is probably due to the objective function being more sensitive to some design variables than others, and so I have been using relative step sizes instead of absolute. However, I expected the step size to be relative to each design variable in the vector, but this appears not to be the case with a constant step size applied to all the design variables. \nFor example, a relative step size of 1e-5 produced an actual step size of 4.2e-5 (constant) with a vector of 28 design variables that vary in magnitude.\ni.e. design_variables = [0, 1e-2, 1e-1...]\nQuestion: How is the relative step size calculated for a vector of design variables that vary in magnitude and include zero?\nNotes: the design variables are scaled (equally) and share the same (%) upper and lower bounds. Also, this number does appear to vary with the lower and upper bounds? \n\nUPDATE: Issue partially resolved after reviewing the finite_difference.py script. The norm of the input is taken and multiplied with the step size. However, the codes suggests (step *= scale) that the scaled value is also a scalar and so constant across all design variables, is this correct?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":51630972,"Users Score":0,"Answer":"Yes, that is how the step size is calculated for vectors -- for relative finite difference stepping, the stepsize is scaled by the norm of the vector. However, you bring up a good point that a vector may have wildly different magnitudes in its elements, so maybe we need to add support for specifying a vector of fd step sizes.","Q_Score":0,"Tags":"python,openmdao","A_Id":51655116,"CreationDate":"2018-08-01T10:24:00.000","Title":"openmdao: how is the 'rel' step size calculated for a vector input of design variables?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"qcow2 is an image for qemu and it's good to emulate.\nI know how to write data for qcow2 format, but I don't know how backing files in qcow2 work?\nI found nothing tutorial said this.\nCan anyone give me tips?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":398,"Q_Id":51631247,"Users Score":1,"Answer":"Backing file is external snapshot for qcow2 and the qemu will write COW data in the new image.\nFor example:\nYou have image A  and B, and A is backing file of B.\nWhen you mount B to \/dev\/nbd and check its data, you'll find you can saw data of A.\nThat's because if there's no data in the range of B, qemu will read the same range of A.\nAn important notes: If qemu doesn't find A, you won't be able to mount B on \/dev\/nbd.","Q_Score":0,"Tags":"python,qemu","A_Id":51924013,"CreationDate":"2018-08-01T10:39:00.000","Title":"How backing file works in qcow2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When you run a python script from terminal and before it completes running of you control + c  it, it gives a traceback where the code was currently running. Is it possible to see which part of a code is running without terminating it.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":290,"Q_Id":51632029,"Users Score":1,"Answer":"in pycharm, you can debug by selecting code areas that you want to work, and by pressing next and next, you'll see how does program running it, without terminating it.","Q_Score":2,"Tags":"python,terminal","A_Id":51632138,"CreationDate":"2018-08-01T11:22:00.000","Title":"How to see which part of the code is running in terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"In the pandas documentation, it says that the optional dependencies for Excel I\/O are:\n\nxlrd\/xlwt: Excel reading (xlrd) and writing (xlwt)\nopenpyxl: openpyxl > version 2.4.0 for writing .xlsx files (xlrd >= 0.9.0)\nXlsxWriter: Alternative Excel writer\n\nI can't install any external modules.  Is there any way to create an .xlsx file with just a pandas installation?\nEdit: My question is - is there any built-in pandas functionality to create Excel workbooks, or is one of these optional dependencies required to create any Excel workbook at all?\nI thought that openpyxl was part of a pandas install, but turns out I had XlsxWriter installed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":831,"Q_Id":51635233,"Users Score":3,"Answer":"The pandas codebase does not duplicate Excel reading or writing functionality provided by the external libraries you listed.  \nUnlike the csv format, which Python itself provides native support for, if you don't have any of those libraries installed, you cannot read or write Excel spreadsheets.","Q_Score":1,"Tags":"python,pandas,pandas.excelwriter","A_Id":51635610,"CreationDate":"2018-08-01T13:58:00.000","Title":"Can I create Excel workbooks with only Pandas (Python)?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was surprised to find that, say, \nge=(x*x for x in [1,2,3])\naccepts the .send method. The argument of the first call must be None, as with any other generator , but the behaviour of further calls, say, ans=ge.send(99) seems identical to ans=next(ge). \nWhere goes my 99? There are no yield expressions within ge, nothing to be assigned. Is the value injected simply discarded (as I suspect), or there is some Mystery involved?\nHas anybody seen that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":51642396,"Users Score":0,"Answer":"Thank you, all. So yes, the arg of send is discarded, but the fact that send is accepted seems to be an anomaly. \nAnother, related bug has been already commented here (page 32139885), the yield expression should be forbidden in genexps, but it isn't. The form ge=((yield x*x) for x in [1,2,3]) is accepted, and .send() works.\nThe answer returned by send is then a mixture of elements in the internal iterable, and the args of send... If I am not mistaken, GvR wrote that in Python 3.8 this (the yield expression) will be treated as an error, and in 3.7 it should signal that it is deprecated. (People agreed that it was confusing.)\nBut I tested that in Python 3.7 (Anaconda, Windows 64), and I got no deprecation warning. Anyway, this seems to be a real bug, not a feature to be deprecated. I believe that for the moment there is nothing more to say...\nJK","Q_Score":2,"Tags":"python,generator,send","A_Id":51643862,"CreationDate":"2018-08-01T21:18:00.000","Title":"What happens if you send() to a generator *expression* in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have several python and PHP multi-threading scripts running on an old 2015 Mac el capitain OS with 4 cores that take only a few minutes each to complete.\nBought a 2018 18 core iMac pro running high Sierra and now those same scripts take 40 hours EACH to complete. Any hints what I can due to solve this problem? Anyone else, threading with php or python on high Sierra or an iMac pro?\nReally dumbfounded right now.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":51644050,"Users Score":0,"Answer":"I called apple and they said to wipe the system completely clean with a new install of the MAC OS system because the issue could be due to a conflict in software. I did that and it did fix the issue. So I will have to step through all my software installations to identify the one conflicting with the threading.","Q_Score":0,"Tags":"php,python,multithreading,macos,pthreads","A_Id":51644914,"CreationDate":"2018-08-02T00:39:00.000","Title":"Threading in Python or PHP is 100 times slower on my 2018 18 core iMac","Data 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":"img[::a,::b] can reduce resolution of image in PIL\uff0cbut why?\nimg[::a, ::b] resolution or size is x and y then you will get image which is x\/a ,y\/b\nwho knows why or how?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":26,"Q_Id":51644098,"Users Score":0,"Answer":"That's the syntax for a multi-dimensional slice. The result includes every ath pixel along the x-axis and every bth pixel along the y-axis.\nSlice notation is not too difficult to understand. It looks like start:stop:step, where any of the values can be omitted to get a default. If you're omitting step at the end, the second colon is not required (you can just write start:stop). Slice notation is only allowed when indexing (e.g. foo[start:stop:step]). To make a slice outside that context, you can call the slice constructor (though you may need to pass None for omitted values rather than just skipping them).\nThe default step value is 1. The default start and stop depend on the sign of step. If step is positive, then start's default is 0 and stop's is the size of the object being sliced. If step is negative, start will default to one less than the size of the object (the largest valid index) and stop will default to an index \"just before the first value\" (this is not -1 as you might expect, because negative indexes wrap around to the end; the only way you could specify the index normally is -len(...)-1).\nNot all Python objects allow multi-dimensional indexing (where the index is a tuple of indexes or slices). Normal lists don't support it (not even if they're nested). The PIL image does however, probably because it is replicating the behavior of a numpy multi-dimensional array.","Q_Score":0,"Tags":"python-3.x","A_Id":51644248,"CreationDate":"2018-08-02T00:48:00.000","Title":"img[::a,::b] can reduce resolution of image in PIL\uff0cbut why","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to deploy Volttron or Volttron agents without exposing the source code of agents?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":51646924,"Users Score":0,"Answer":"While there is no  way included in the platform to do this there are tools that make it possible.\nThe first thing is that even if you only deployed python byte code the original source is easy to derive from this byte code. This is a waste of time.\nI would try compiling your Agent code into C with Cython and then compile that into a pyc module(s) before deployment. Ultimately the module is run directly with the python interpreter so this should just work.","Q_Score":0,"Tags":"python,python-2.7,volttron","A_Id":51680639,"CreationDate":"2018-08-02T06:33:00.000","Title":"Is there any way to deploy volttron with code protection?","Data Science and Machine Learning":0,"Database and SQL":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":"Why can't we use Cartesian coordinates(x,y) instead of polar coordinates(r,theta) in Houghlines transformations ? Can any one clarify?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1139,"Q_Id":51647421,"Users Score":3,"Answer":"From what I can understand (quoted from wikipedia):\nThe simplest case of Hough transform is detecting straight lines. In general, the straight line y = mx + b can be represented as a point (b, m) in the parameter space. However, vertical lines pose a problem. They would give rise to unbounded values of the slope parameter m. Thus, for computational reasons, Duda and Hart proposed the use of the Hesse normal form r = x*cos(theta) + y*sin(theta), where r is the distance from the origin to the closest point on the straight line, and theta is the angle between the x axis and the line connecting the origin with that closest point.\nA line can be detected by finding the number of intersections between curves.The more curves intersecting means that the line represented by that intersection have more points. In general, we can define a threshold of the minimum number of intersections needed to detect a line.\nThis is what the Hough Line Transform does. It keeps track of the intersection between curves of every point in the image. If the number of intersections is above some threshold, then it declares it as a line with the parameters (theta,r_(theta)) of the intersection point. (OpenCV docs)","Q_Score":0,"Tags":"python,opencv,computer-vision,polar-coordinates,houghlines","A_Id":51651745,"CreationDate":"2018-08-02T07:03:00.000","Title":"Cartesian coordinates in Houghlines","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use tensorflow to run classify_image.py, but I keep getting the same error: \nTraceback (most recent call last):\n  File \"classify_image.py\", line 46, in <module>\n    import tensorflow as tf\n  File \"C:\\Users\\Diederik\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\__init__.py\", line 22, in <module>\n    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import\nModuleNotFoundError: No module named 'tensorflow.python'\nSomeone asked me to do a pip3 list, so I did: \nC:\\Users\\Diederik\\AppData\\Local\\Programs\\Python\\Python36\\Scripts>pip3 list Package Version ----------- ------- absl-py 0.3.0 astor 0.7.1 gast 0.2.0 grpcio 1.13.0 Markdown 2.6.11 numpy 1.15.0 pip 10.0.1 protobuf 3.6.0 setuptools 39.0.1 six 1.11.0 tensorboard 1.9.0 tensorflow 1.9.0** termcolor 1.1.0 Werkzeug 0.14.1 wheel 0.31.1 You are using pip version 10.0.1, however version 18.0 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":437,"Q_Id":51648278,"Users Score":0,"Answer":"try pip install --upgrade --ignore-installed tensorflow again.\nIf it said some packages can't be installed\/upgrade for missing some other packages, pip installthose packages too, and try again the first code.\nThat's how I solved my problem.","Q_Score":0,"Tags":"python,tensorflow,artificial-intelligence,image-recognition","A_Id":52934117,"CreationDate":"2018-08-02T07:49:00.000","Title":"No module named tensorflow.python on windows 10 when I run classify_image.py","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use tensorflow to run classify_image.py, but I keep getting the same error: \nTraceback (most recent call last):\n  File \"classify_image.py\", line 46, in <module>\n    import tensorflow as tf\n  File \"C:\\Users\\Diederik\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\__init__.py\", line 22, in <module>\n    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import\nModuleNotFoundError: No module named 'tensorflow.python'\nSomeone asked me to do a pip3 list, so I did: \nC:\\Users\\Diederik\\AppData\\Local\\Programs\\Python\\Python36\\Scripts>pip3 list Package Version ----------- ------- absl-py 0.3.0 astor 0.7.1 gast 0.2.0 grpcio 1.13.0 Markdown 2.6.11 numpy 1.15.0 pip 10.0.1 protobuf 3.6.0 setuptools 39.0.1 six 1.11.0 tensorboard 1.9.0 tensorflow 1.9.0** termcolor 1.1.0 Werkzeug 0.14.1 wheel 0.31.1 You are using pip version 10.0.1, however version 18.0 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":437,"Q_Id":51648278,"Users Score":0,"Answer":"I simply needed to add a python path, that was the only problem","Q_Score":0,"Tags":"python,tensorflow,artificial-intelligence,image-recognition","A_Id":51657493,"CreationDate":"2018-08-02T07:49:00.000","Title":"No module named tensorflow.python on windows 10 when I run classify_image.py","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have already installed my wanted module from pip by using pip install but when i open up a program in idle and put import menu it says module not found what did i do wrong, im using python 3.7 and have the latest version of pip.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8883,"Q_Id":51651515,"Users Score":0,"Answer":"I met the same problem, but in my case the package is created by myself. So this answer applyes to the custom packages. See Why customer python package can not be imported? for details.","Q_Score":1,"Tags":"python,pip,python-import","A_Id":64592199,"CreationDate":"2018-08-02T10:38:00.000","Title":"Cannot import module after installed by pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training a model that incrementally learns new classes, e.g. n target classes during the first 70 or so epochs, then the original n classes plus m new target classes, etc. When training the model on n+m target classes, the loss function requires predictions from the model trained on n target classes. How can I restore the old model efficiently? \nIt seems I can do this by creating two separate sessions for each batch and loading the old model in one before training the new model in the other, but this is terribly inefficient and makes training go from taking hours to days.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":51654259,"Users Score":0,"Answer":"Would it be possible to use the weights to do it?\nPut the weigh of your targets to 1 and the weights of your not-targets to 0\nAt first, you'd have your weight tensor at [1]*n + [0]*m (+ as in concat).\nThen you'd assign it to [1]*(n+m) when you want to add you m new targets\nand so forth.","Q_Score":1,"Tags":"python,tensorflow","A_Id":51654678,"CreationDate":"2018-08-02T12:56:00.000","Title":"Make predictions with an old model without losing the current model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to download approximately 50 pdf files from the Internet using a python script. Can Google APIs help me anyhow?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":51654956,"Users Score":0,"Answer":"I am going to assume that you are downloading from Google drive.  You can only download one file at a time.   You cant batch download of the actual file itself.\nYOu could look into some kind of multi threading system and download the files at the same time that way but you man run into quota issues.","Q_Score":0,"Tags":"python,python-3.x,web-scraping,google-api","A_Id":51663714,"CreationDate":"2018-08-02T13:30:00.000","Title":"how to download many pdf files from google at once using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"df_filter = df.filter(~(col('word').isin(stop_words_list)))\ndf_filter.count()\n\n\n\n27781\n\n\n\ndf.count()\n\n\n\n31240\nWhile submitting the same code to Spark cluster using spark-submit, the filter function is not working properly, the rows with col('word') in the stop_words_list are not filtered. \nWhy does this happen?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":312,"Q_Id":51661079,"Users Score":0,"Answer":"The filtering is working now after the col('word') is trimmed.\n    df_filter = df.filter(~(trim(col(\"word\")).isin(stop_words_list)))\nI still don't know why it works in pyspark shell, but not spark-submit. The only difference they have is: in pyspark shell, I used spark.read.csv() to read in the file, while in spark-submit, I used the following method.\n    from pyspark.sql import SparkSession\nfrom pyspark.sql import SQLContext\nsession = pyspark.sql.SparkSession.builder.appName('test').getOrCreate()\nsqlContext = SQLContext(session)\ndf = sqlContext.read.format(\"com.databricks.spark.csv\").option('header','true').load()\nI'm not sure if two different read-in methods are causing the discrepancy. Someone who is familiar with this can clarify.","Q_Score":0,"Tags":"python-3.x,apache-spark,filter,pyspark,apache-spark-sql","A_Id":51681014,"CreationDate":"2018-08-02T19:42:00.000","Title":"filter working in pyspark shell not spark-submit","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm migrating a drupal website to Django, and I need to get the post (news) from my drupal installation... The question is: what tables do I need to read to do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":51661275,"Users Score":0,"Answer":"You need to read the node table and also see all fields involved in your content type, drupal create a table by field, for example: \nContent type News contains the following fields: \ntitle\nbody\nfield_image\nThen you need to read the following tables: \nNode\nfield_data_body\nfield_data_field_image","Q_Score":0,"Tags":"mysql,django,python-3.x,drupal-7","A_Id":51667972,"CreationDate":"2018-08-02T19:58:00.000","Title":"Migrate data from Drupal 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was installing a few modules like TA-Lib , bitmex but I am getting an error that The System cannot find the path specified:\n\nD:\\Visual Studio\\ VC\\ Platform SDK \\ Lib\n\nPython version is 3.6.6","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":789,"Q_Id":51661342,"Users Score":0,"Answer":"Abel to solve it --\nGo to visual studio --> File --> New Project --> c++ \nso it will show missing file to download and after downloading it installed those modules and it got done without any error.","Q_Score":0,"Tags":"python,python-3.x","A_Id":51662134,"CreationDate":"2018-08-02T20:03:00.000","Title":"Python 3.6.6 : The System cannot find the path specified : D:\\\\Visual Studio\\\\ VC\\\\ Platform SDK \\\\ Lib","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python and I apologize in advance for asking for help on this trivial matter. I installed Python 2.14.7 on Cygwin running on Win 10, and would like to install MySQL (for python) and the MySQLdb library to play around. I searched the net for the exact installation steps but did not find a conclusive answer. Can anyone please point me to any resources (download links & installation Steps) that might help me in this endeavor ?\nThanks in advance..","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":415,"Q_Id":51664719,"Users Score":0,"Answer":"So, MySql is a database. You don't install a database for Python. It's a standalone software. You can install any version of it that compatible with cygwin. What you do need is a Python database connector, which can be downloaded at Oracle.com. (sorry I am answering with my phone maybe you need to Google it yourself.) \nYou should Google it and register an account on Oracle.com. Then it's good to download the lib.","Q_Score":0,"Tags":"python,cygwin,mysql-python","A_Id":51664790,"CreationDate":"2018-08-03T03:00:00.000","Title":"Installing MySQL for Python on Cygwin","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am recently studying about GAN model and thought that it would be useful for my system in which I am going to predict whether a given image is car or not. I understand the part that the \"discriminator\" gets input from the \"generator\". The generator generates image from a random vector which is then passed to the discriminator for authenticity check. But what exactly is that vector that is used by the generator ? Is it in an image converted to pixels and we pass it as an vector of pixels ?\nCan anyone please explain me this \nOr is there any other method that I should follow to build a system that can classify images to car or not\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":51666513,"Users Score":0,"Answer":"The input to the generator is a z-dimensional vector of completely random values. In case of DCGAN, the input is from gaussian distribution source. GANs' theory is based on the fact that these random values are learnt to be distotred by the network in such a way that Discriminator\/ Critic is fooled by the image that is produced by the generator. Both generator and discriminator are adversaries of each other making each other better epoch by epoch, and hence the name Adversarial networks.\nFor classifying an image into cars and not car, you can actually solve this problem fairly easily and accurately using a simple ConvNet by training it on multiple car images and \"not car\" images. There are already pretty complex object detection networks out there trained on Imagenet data, so you might as well start by referring the architecture of those networks.\nHope my answer was of some help to you. :)","Q_Score":0,"Tags":"python-3.x,image-processing,generative-adversarial-network","A_Id":51686316,"CreationDate":"2018-08-03T06:28:00.000","Title":"What is the input to the generator in Generative Adversarial Network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use JanusGraph, HBase and Python (through gremlin_python) to create and store a sample graph. Now I'd like to do some graph anaysis (eg. page rank), and wish to stick to Python.  I'm wondering if it's possible to query a graph from JanusGraph in DataFrame format, then ingest into GraphFrame to calculate pageRank? \nThe key questions are how can I bridge between JanusGraph + GraphFrame using Python, i.e.\n1. query a graph which returns in one format\n2. call GraphFrame API to caluclate PageRank.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":234,"Q_Id":51667488,"Users Score":1,"Answer":"As far as I am concerned, there is not official connector available for transforming query results of JanusGraph into Spark DataFrame (and then Graph in GraphFrame).\nThus, you must manually write code to performe the transformation. You can use gremlin-python package to query JanusGraph and then using Spark to feed the result set into Spark DataFrame.","Q_Score":0,"Tags":"python-2.7,apache-spark,apache-spark-sql,gremlin,janusgraph","A_Id":53847802,"CreationDate":"2018-08-03T07:33:00.000","Title":"Janusgraph query returns dataframe to perform analysis using GraphFrame","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Consider a array A of shape (n x 1). The transpose of A will have the shape (1 x n). Why is that the sum of A and A.T (i.e A + A.T) give back an (n x n) array in Python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":51670148,"Users Score":0,"Answer":"Your result will need n rows to comply to the structure of one of the arrays and n columns to comply to the structure of the other array.","Q_Score":0,"Tags":"python,arrays","A_Id":51670317,"CreationDate":"2018-08-03T10:00:00.000","Title":"Sum of an array and it's transpose","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have certain files in a directory named benchmarks and I want to get code coverage by running these source files.\nI have tried using source flag in the following ways but it doesn't work.\ncoverage3 run --source=benchmarks\ncoverage3 run --source=benchmarks\/\nOn running, I always get Nothing to do.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1447,"Q_Id":51673082,"Users Score":0,"Answer":"coverage run is like python.  If you would run a file with python myprog.py, then you can use coverage run myprog.py.","Q_Score":0,"Tags":"ubuntu-14.04,python-3.6,coverage.py","A_Id":51679505,"CreationDate":"2018-08-03T12:50:00.000","Title":"how to use coverage run --source = {dir_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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering if there is a way to setup VS Code to debug like you can in Spyder or closer to a Jupyter or ipython notebook where you can run some block or line of code (with F9 in Spyder) and that code is interpreted and the debugging session is still 'live' if you will.\nIn VS code I can't seem to run any block of code and then run another block of code in the same session without stopping and starting up another debugging session.\nI tend to like to load a bunch of data and then execute arbitrary lines of code after that as i figure out what i want to do with it.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1012,"Q_Id":51674029,"Users Score":1,"Answer":"There is an option in the command palette to do this. With your python code open select lines you want to run. Then go to view menu and select command palette. There is a command that says, Python: Run selection\/line in Python terminal.  This will run just what you select and print out any outputs.","Q_Score":2,"Tags":"python,visual-studio-code,vscode-settings","A_Id":51681635,"CreationDate":"2018-08-03T13:42:00.000","Title":"Run arbitrary lines in same debugging session like Spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to triangulate points from stereo images.On the web I find a lot of confusion, because there are many different methods.\nI have two images of the same subject in different angles, with manually defined landmarks,(for example , 2 faces where I scored 3 points: nose and pupils).\nI would like to go back to the three-dimensional position of these points through their triangulation.\nIt could be listed the various steps to be performed to get this result in OpenCv for python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":510,"Q_Id":51674917,"Users Score":0,"Answer":"To triangulate you need to now position of cameras.\nThose position can be presented in different forms, translate, rotation, or affine, depend of needs.\nConstruct two rays from each camera thru the same landmark.\nIn theory find intersection of those two rays.\nIn practice find point that is closest to both rays.\nThat point is what you want.","Q_Score":0,"Tags":"python,image,opencv,point,triangulation","A_Id":51685128,"CreationDate":"2018-08-03T14:33:00.000","Title":"Opencv step for Triangulate point from stereo image","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently working on a program that can do binary image classification with machine learning. I have a list of labels and a list of images that i'm using as inputs which are then fed into the Inception V3 model. \nWill inputting of the dataset this way work with the inception V3 architecture? Is it necessary to organize the images with labeled folders before feeding it into the model?\nThanks for your help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":145,"Q_Id":51679311,"Users Score":2,"Answer":"In your example, you have all the images in memory. You can simply call model.fit(trainX, trainY) to train your model. No need to organize the images in specific folder structures.\nWhat you are referring to, is the flow_from_directory() method of the ImageDataGenerator. This is an object that will yield images from the directories, and automatically infer the labels from the folder structure. In this case, your images should be arranged in one folder per label. Since the ImageDataGenerator is a generator, you should use it in combination with model.fit_generator().\nAs a third option, you can write your own custom generator that yields both images and labels. This is advised in case you have a more complex label structure than one label per images; for instance in multi-label classification, object detection or semantic segmentation, where the outputs are also images. A custom generator should also be used with model.fit_generator().","Q_Score":2,"Tags":"python,tensorflow,machine-learning,keras,classification","A_Id":51680611,"CreationDate":"2018-08-03T19:53:00.000","Title":"Is Dataset Organization for Image Classification Necessary?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The basic example is everywhere;\nexcept Exception as e:\n    print(e)\n...I argue that it is only a hair above absolutely useless when it comes to debugging.\nI feel like there's no reason whatsoever to handle exceptions in this way, for debugging, because there's almost no information given at all. At least when it hard-faults it gives you the trace to what caused the problem. \n\"List Index out of Range\" - yeah thanks. I knew that, it's why I caught IndexError!\nSo is it possible to return the line that caused the exception or any actually useful data? Or is it just for handling known exceptions with known vectors?\nThank you!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":115,"Q_Id":51679765,"Users Score":1,"Answer":"A try-except block is used when the developer wants to avoid crashing the program, and either ignore an error or handle an error in a specific way.\nI agree with you; printing the error is almost the same as not catching it. Removing the try-except block and taking a look at the stack trace will give you the most information about the error.","Q_Score":0,"Tags":"python-3.x,exception-handling,index-error","A_Id":51679851,"CreationDate":"2018-08-03T20:32:00.000","Title":"Python 36 - returning data on errors - Exception is almost useless?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Heroku restarts every 24 hours, is there any way I can program it to not do this, or update my files that are inside it every 23h or 24h?\nI use python, and use heroku to host my discord bot.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":51679928,"Users Score":0,"Answer":"You can't store information on Heroku file system,\nyou need to store your data in some database, for example, Postgres or MongoDB.\nThe can be added easily as an addon on Resources tab.","Q_Score":1,"Tags":"python,heroku,bots,discord","A_Id":51706590,"CreationDate":"2018-08-03T20:48:00.000","Title":"Heroku update files inside it every 24h","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Import os module won't import in Pycharm. I've read that it's already built in and that it doesn't need to be downloaded. Has anyone else had this issue and found a fix?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5965,"Q_Id":51680320,"Users Score":0,"Answer":"Unused import statement just means you haven't made use of the library within your code. It's not an actual error, just a warning. If you write the rest of your code, it will be fine.","Q_Score":0,"Tags":"python-import","A_Id":51729733,"CreationDate":"2018-08-03T21:32:00.000","Title":"Import OS module won't import in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know if it's possible to get the email language setting of a user using python. To be more specific, I'm trying to set up an email notification system that notifies users by email when they receive a message, I don't want to really use their browser language setting because the sender and receiver could have different language setting on their browser. I want to know if it's possible, knowing the receiver's email, to get the language setting of their email?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":41,"Q_Id":51681793,"Users Score":1,"Answer":"Nope, simply because like the browser that is a per-application per-install thing. Why not simply prompt the user for their preferred language when you get permission to send the notification?","Q_Score":0,"Tags":"python,email","A_Id":51712333,"CreationDate":"2018-08-04T01:53:00.000","Title":"get email receiver language setting 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 making an application in python where iam able to work with multithreading and multiproceccing but i need to connect a large sacle of devices. Is there any way to run multiple threads in each core.\nLike if i have 4 cores then is there any way to run 2 threads in each core. So that we can have 8 concurrent threads running.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":483,"Q_Id":51683545,"Users Score":0,"Answer":"In Python there is no way to utilize multiple threads since it uses a so called GIL or Global Interpreter Lock, which means that only one thread can run Python code at a time. \nDepending on your use-case threads still might suit your problem if it is IO-bound. Python uses cooperative multitasking, meaning threads give up control if they block, so if you for example need to ping multiple devices to see if they are still running, threads will speed up your program heavily.\nIf you need true concurrency, consider using multiprocessing, since it is process-based and spawns a new Python interpreter, therefor bypassing the GIL.","Q_Score":0,"Tags":"multithreading,python-2.7,multiprocessing","A_Id":51685006,"CreationDate":"2018-08-04T07:39:00.000","Title":"can multiple threads can be implemented in every core in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im using python 3.6 tensorflow 1.5\nim following the link\nBut got the error:\ndoe@doe:~\/anaconda3\/envs\/tensorflow\/models\/research\/object_detection$ python3 train.py --logtostderr --train_dir=training\/ --pipeline_config_path=training\/ssd_mobilenet_v1_coco.config\nWARNING:tensorflow:From \/home\/doe\/anaconda3\/lib\/python3.6\/site-packages\/tensorflow\/python\/platform\/app.py:124: main (from main) is deprecated and will be removed in a future version.\nInstructions for updating:\nUse object_detection\/model_main.py.\nTraceback (most recent call last):\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 1500, in _ParseAbstractInteger\n    return int(text, 0)\nValueError: invalid literal for int() with base 0: '03'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 1449, in _ConsumeInteger\n    result = ParseInteger(tokenizer.token, is_signed=is_signed, is_long=is_long)\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 1471, in ParseInteger\n    result = _ParseAbstractInteger(text, is_long=is_long)\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 1502, in _ParseAbstractInteger\n    raise ValueError('Couldn\\'t parse integer: %s' % text)\nValueError: Couldn't parse integer: 03\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):\n  File \"train.py\", line 184, in \n    tf.app.run()\n  File \"\/home\/doe\/anaconda3\/lib\/python3.6\/site-packages\/tensorflow\/python\/platform\/app.py\", line 124, in run\n    _sys.exit(main(argv))\n  File \"\/home\/doe\/anaconda3\/lib\/python3.6\/site-packages\/tensorflow\/python\/util\/deprecation.py\", line 136, in new_func\n    return func(*args, **kwargs)\n  File \"train.py\", line 93, in main\n    FLAGS.pipeline_config_path)\n  File \"\/home\/doe\/anaconda3\/envs\/tensorflow\/models\/research\/object_detection\/utils\/config_util.py\", line 94, in get_configs_from_pipeline_file\n    text_format.Merge(proto_str, pipeline_config)\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 536, in Merge\n    descriptor_pool=descriptor_pool)\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 590, in MergeLines\n    return parser.MergeLines(lines, message)\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 623, in MergeLines\n    self._ParseOrMerge(lines, message)\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 638, in _ParseOrMerge\n    self._MergeField(tokenizer, message)\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 763, in _MergeField\n    merger(tokenizer, message, field)\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 837, in _MergeMessageField\n    self._MergeField(tokenizer, sub_message)\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 763, in _MergeField\n    merger(tokenizer, message, field)\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 837, in _MergeMessageField\n    self._MergeField(tokenizer, sub_message)\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 763, in _MergeField\n    merger(tokenizer, message, field)\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 871, in _MergeScalarField\n    value = _ConsumeInt32(tokenizer)\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 1362, in _ConsumeInt32\n    return _ConsumeInteger(tokenizer, is_signed=True, is_long=False)\n  File \"\/home\/doe\/.local\/lib\/python3.6\/site-packages\/google\/protobuf\/text_format.py\", line 1451, in _ConsumeInteger\n    raise tokenizer.ParseError(str(e))\ngoogle.protobuf.text_format.ParseError: 9:18 : Couldn't parse integer: 03","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1370,"Q_Id":51684220,"Users Score":0,"Answer":"I faced a similar problem relating to label_map_path when running on local machine. Solved by removing spaces between lines in the label map pbtxt file. Please check config file as well.","Q_Score":0,"Tags":"python-3.x,ubuntu,tensorflow,video-processing,object-detection-api","A_Id":51758333,"CreationDate":"2018-08-04T09:24:00.000","Title":"google.protobuf.text_format.ParseError: 9:18 : Couldn't parse integer: 03","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I get the embed of a message to a variable with the ID of the message in discord.py?\nI get the message with uzenet = await client.get_message(channel, id), but I don't know how to get it's embed.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5406,"Q_Id":51688392,"Users Score":5,"Answer":"To get the first Embed of your message, as you said that would be a dict():\nembedFromMessage = uzenet.embeds[0]\nTo transfer the dict() into an discord.Embed object:\nembed = discord.Embed.from_data(embedFromMessage)","Q_Score":1,"Tags":"python,python-3.x,discord,discord.py","A_Id":55555605,"CreationDate":"2018-08-04T18:15:00.000","Title":"Discord.py get message 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":"In my Python script I want to connect to remote server every time. So how can I use my windows credentials to connect to server without typing user ID and password. \nBy default it should read the userid\/password from local system and will connect to remote server.\nI tried with getuser() and getpass() but I have to enter the password everytime. I don't want to enter the password it should take automatically from local system password.\nAny suggestions..","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":51690162,"Users Score":0,"Answer":"I am sorry this is not exactly an answer but I have looked on the web and I do not think you can write a code to automatically open Remote desktop without you having to enter the credentials but can you please edit the question so that I can see the code?","Q_Score":0,"Tags":"python,python-3.x,login,python-requests","A_Id":51690444,"CreationDate":"2018-08-04T22:59:00.000","Title":"How to use Windows credentials to connect remote desktop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using apache web hosting I launched my first web app today and I noticed that if I put examply.com\/example.py in my web browser I can see my python source code with my sql password in it. \nHow do I prevent this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":51690304,"Users Score":0,"Answer":"Chown your python file with 640 will give a FORBIDDEN in the browser but the server will be able to execute it in PHP for example:\n$output = shell_exec(\"python python-test.py\");\necho ($output);","Q_Score":0,"Tags":"python,apache","A_Id":61774431,"CreationDate":"2018-08-04T23:29:00.000","Title":"How to hide serverside python file from web browser?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I had problems with importing oauth2 package. In in the init.py file there is a problem with this line getting executed, from ._compat import PY3 . I don't know why installing and running oauth2 is such a mess","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":266,"Q_Id":51690431,"Users Score":1,"Answer":"this worked for me:\nfrom oauth2._compat import PY3\nthe error you were getting suggests that you were trying to import __main__.compat instead of oauth2._compat","Q_Score":0,"Tags":"python-3.x,oauth-2.0","A_Id":51692171,"CreationDate":"2018-08-04T23:55:00.000","Title":"I am getting No module named 'oauth2._compat'","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 sklearn import svm\nImportError: cannot import name __check_build","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4987,"Q_Id":51694076,"Users Score":1,"Answer":"I've been able to install scikit-learn on a fresh virtualenv here but it seems you need to do some extra job to get it up-and-running:\nBy doing just pip install scikit-learn and then from sklearn import svm you'll get import errors, it seems the library requires numpy and scipy. So you need to do:\n\npip install numpy scipy\n\nAfter that it should work fine.","Q_Score":0,"Tags":"python,scikit-learn,sklearn-pandas","A_Id":51694410,"CreationDate":"2018-08-05T11:54:00.000","Title":"ImportError: cannot import name __check_build","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given a bounding box for an image in OpenCV, is there a way to return all the colors inside the box? Ideally, the output would give the information along the lines of \"In the bounding box, it is 50% white, 25% blue, 15% green, 10% red.\" \nIs there any way to do this? At the very least, is there some function that could tell me all the colors in the box? (without percentages or how much of it there is). Any indication would be huge help\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":672,"Q_Id":51695023,"Users Score":0,"Answer":"It can be done by using a grayscale convertion of your image or of your ROI.\nYou can weather process the histogram of the ROI extract from the gray scale (or convert to grayscale if extracted from the colour image) and count the non zero value. \nOr you can copy all the gray-scale value of your ROI into a set container, then the lenght of the set is the number of colours presents in your ROI.","Q_Score":0,"Tags":"python,opencv,colors","A_Id":51696373,"CreationDate":"2018-08-05T14:03:00.000","Title":"Determine all colors in bounding box in OpenCV\/Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try the conversation on the IBM cloud and every things works fine starting with the welcome node where I have set many context variables there, Now I want to use a back-end language like python or Node.js to try that so, But I only can send the request and get the response but can't make the welcome node starts the conversation like happens on the cloud, Is there a solution for that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":457,"Q_Id":51695315,"Users Score":1,"Answer":"If you want the welcome node to be triggered, send an empty string and empty context to the dialog.","Q_Score":0,"Tags":"python,node.js,ibm-cloud,watson-conversation","A_Id":51723780,"CreationDate":"2018-08-05T14:45:00.000","Title":"How to make IBM Watson Assistant welcome node starts the conversation with Node.js or Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Need to install python packages like pip, numpy, cv2 on an Amazon EC2 instance of Ubuntu.  I tried using sudo apt-get install python-pip but got below given error:\nubuntu@ip-172-31-35-131:~$ sudo apt-get install python-pip\nReading package lists... Done\nBuilding dependency tree\nReading state information... Done\nE: Unable to locate package python-pip","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":7302,"Q_Id":51698609,"Users Score":6,"Answer":"Try first sudo apt-get update then\nsudo apt-get install python-pip","Q_Score":5,"Tags":"python,amazon-web-services,ubuntu,amazon-ec2","A_Id":51698637,"CreationDate":"2018-08-05T22:07:00.000","Title":"How to install python packages like pip, numpy on Amazon EC2 - ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"This just confuses me and I don't know what it means. I have 3.6.4 installed on my computer(MacOS) but it doesn't want to work.\nI can't think of any solution and don't know what to do.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9705,"Q_Id":51698662,"Users Score":15,"Answer":"The answer is slightly different wether you are on a Mac or a Linux (I am not that used of Windows for Python working).\n\nInstall\n(MacOS =>) Be sure that the XCode CLI tools are installed on your computer.\nxcode-select --install\nThen, to install the virtualenv, you have to enter the following command.\npyenv install 3.6.4\nHere, you can have some issues regarding the zlib library that is not available. Nevertheless, the XCode CLI should have installed zlib. So you are good to go (it still has some issues on MacOS Mojave nevertheless).\n\nCreate Virtualenv\nThen create a new virtualenv for a future use :\npyenv virtualenv 3.6.4 v3.6.4\n\nCheck\nCheck that everything is ok and that the virtualenv is installed through the following command :\npyenv virtualenvs\n\nUse\nThen you just have to use it. For instance for a local use :\npyenv local v3.6.4\n\nCheck\nCheck that everything is ok:\npyenv local\nand it should show v3.6.4.","Q_Score":8,"Tags":"python,pyenv","A_Id":51727036,"CreationDate":"2018-08-05T22:19:00.000","Title":"pyenv-virtualenv: `3.6.4' is not installed in pyenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there any way to implement http connector for sending messages(MT) in Jasmin? According to documentation jasmin HTTP API supports smpp connector only.  \nUpdate 1:\nMore information of scenario:\nI have 4 sms providers that I need to implement using Jasmin.\none of them is using SMPP protocol and is working fine with jasmin using smpp connector.\nOther 3 have http protocol (call url with params to send SMS).\nI want to use http protocol with jasmin to use its routing and other stuff.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1158,"Q_Id":51700964,"Users Score":1,"Answer":"Jasmin only supports HTTP client connectors for MO (mobile originated) messages. \nHaving found myself with the same scenario as yourself, I found the simplest solution was to write an SMPP-to-HTTP service which allows Jasmin to connect to it and relay MT messages via HTTP. Hope that helps","Q_Score":3,"Tags":"python,sms-gateway,jasmin-sms","A_Id":57054186,"CreationDate":"2018-08-06T05:19:00.000","Title":"Jasmin HttpConnector for MT","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 way to implement http connector for sending messages(MT) in Jasmin? According to documentation jasmin HTTP API supports smpp connector only.  \nUpdate 1:\nMore information of scenario:\nI have 4 sms providers that I need to implement using Jasmin.\none of them is using SMPP protocol and is working fine with jasmin using smpp connector.\nOther 3 have http protocol (call url with params to send SMS).\nI want to use http protocol with jasmin to use its routing and other stuff.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1158,"Q_Id":51700964,"Users Score":0,"Answer":"Here is the overview for adding Http MT support in Jasmin:\nAdd connector class and manager for http MT connector\nAdd router manager\nModify smpp protocol module and detach http mt call from this module before it is dispatched to smpp queue. Detachment will be done after router has selected your custom connector and user balance etc is deducted from user account but before transaction is queued. \nBy detachment means use your own queue (rabbitmq queue) and and publish your transaction on this. \nCreate subscriber for rabbitmq and response back as required. \nUsing this method will return same message id and responses like smpp. \nFor more details or help please comment.","Q_Score":3,"Tags":"python,sms-gateway,jasmin-sms","A_Id":57823022,"CreationDate":"2018-08-06T05:19:00.000","Title":"Jasmin HttpConnector for MT","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 odoo 9 and i have created in Settings -> Technical -> Database Structure -> Decimal Accuracy-> Account with digits 3 for subtotal rounding. Then i have added in sale.py price_subtotal = fields.Monetary(compute='_compute_amount', string='Subtotal', digits=dp.get_precision('Account'))\n. After that i updated the two modules sale and decimal_precision. But when i create a new saleorder there is no change in the subtotal rounding it display 2 digits instead of 3. Any help please i'm stuck with this problem for days now","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1001,"Q_Id":51703206,"Users Score":0,"Answer":"The solution is to modify the type of fields from Monetary to Float :\n price_subtotal = fields.Float(compute='_compute_amount', string='Subtotal', digits=dp.get_precision('Account'))","Q_Score":1,"Tags":"python-2.7,odoo-9","A_Id":51706123,"CreationDate":"2018-08-06T08:11:00.000","Title":"How to create a new decimal accuracy for subtotal in sale order odoo 9","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a dataset of [~16k] and am doing binary classsfication [0\/1].When i am doing hyperparameter grid search in random forest my train and test accuracy increase as increase the depth[optimum is coming out to be 25].I am getting a test accuracy of as high as 97% and no there is no data leakage as there are three sets [train,test,and valid].My data has ~10 features.Is this fine since usually i have seen trees have 10 depth at max.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":51706535,"Users Score":0,"Answer":"This is extremely dependent on the dataset at hand. For such a small dataset tree depth of 25 is indeed on the high side and I would say somewhat unusual. But it is not impossible. What it can depend on:\n\nrelation between features and the target\ncategorical vs numerical features\nimbalance of 0 vs 1 target\nyour code implementation (bugs, data leakage, other parameters)\n\nIf I were you i would look deeper to understand why such a deep tree is required. For example, you can start by identifying while feature gets the most splits: extract from the best model feature importances with type split and get the top-5 features. Look how do those correlate with the target.","Q_Score":0,"Tags":"python,random-forest,cross-validation,xgboost,test-data","A_Id":51729004,"CreationDate":"2018-08-06T11:25:00.000","Title":"Height of a random forest decison tree increasing till 25 and the test accuracy also increases","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tried doing \nclient.accept_invite(\"link of invite in discord.gg or url id(tried both many times)\"\nbut It doesn't seem to work, when I put the invite code in, it tries to join, the script just keeps hanging and nothing is happening, on the other hand, every time I tried to join the invite link I needed to reconfirm the email on the account, after I reconfirm it, I try again, and again I need to confirm it, and so on.\nI've read the discord API and they still have accept_invite in their documentations, I don't see why this won't work? I've tried logging into the account with token AND email+pw, both give same results. No error, just hanging +  email needs to be reconfirmed.\nIf anyone knows how to help, would be appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":437,"Q_Id":51708875,"Users Score":1,"Answer":"Client.accept_invite() is\n a) deprecated\nb) intended for user accounts\nAdditionally, logging in using email+pw flags your account and could result in punishments (thats the last I heard at least)\nDo not use this, instead make a bot account and ask users to invite your bot through it's oauth URL.\nEach time you use an endpoint you shouldnt (like the endpoint used to login with username and password), Discord unverifies and flags your account.","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":51708927,"CreationDate":"2018-08-06T13:32:00.000","Title":"client.accept_invite won't work, account tries to join but instead it just hangs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a python script based on the pyautogui module, which controls my mouse and keyboard and can automate some tasks I have at work. \nHowever, sometimes, it doesn't really go as planned and I have to stop the script (even though it might be in the middle of something). The problem is that the terminal window is not in front anymore, so I cannot press ctrl+c. \nI have heard that it is possible to use ctrl+break as well, but it does not seem to work (might be because I have to run the script inside of a remote desktop connection). And the failsafe on pyautogui is to drag the mouse to the top left corner, but it does not seem to work in a remote desktop connection as well. \nIs there some way I can add my own failsafe, or some keyboard combination I can try to stop the ongoing python script, even though the terminal is not accessible?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":446,"Q_Id":51709371,"Users Score":1,"Answer":"Assuming you're on *nix-like system: just run pkill python in a new terminal to kill all python processes of your user.\nYou can run:\nps ax to find the exact process you want to kill then\nkill -9 <the PID of your process>\nTo start a new tty you can press ctrl + F4 then log in\nIf you're on windows: ctrl+alt+del to the task manager then seek your python process and kill it","Q_Score":0,"Tags":"python,python-3.x,pyautogui","A_Id":51709810,"CreationDate":"2018-08-06T13:57:00.000","Title":"Stop Python script outside of the terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have made a python script based on the pyautogui module, which controls my mouse and keyboard and can automate some tasks I have at work. \nHowever, sometimes, it doesn't really go as planned and I have to stop the script (even though it might be in the middle of something). The problem is that the terminal window is not in front anymore, so I cannot press ctrl+c. \nI have heard that it is possible to use ctrl+break as well, but it does not seem to work (might be because I have to run the script inside of a remote desktop connection). And the failsafe on pyautogui is to drag the mouse to the top left corner, but it does not seem to work in a remote desktop connection as well. \nIs there some way I can add my own failsafe, or some keyboard combination I can try to stop the ongoing python script, even though the terminal is not accessible?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":446,"Q_Id":51709371,"Users Score":1,"Answer":"On Windows systems, try ctrl+alt+end. This will open the task manager on the computer you are Remote Desktop'd into.","Q_Score":0,"Tags":"python,python-3.x,pyautogui","A_Id":51710032,"CreationDate":"2018-08-06T13:57:00.000","Title":"Stop Python script outside of the terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm having trouble activating the virtualenv in Windows as I am going through the basic book of Learning Python the Hard Way.  Here is what I am getting:\n\nPS C:\\Users\\Owner> virtualenv --system-site-packages .venvs\/lpthw\nUsing base prefix\n  'c:\\users\\owner\\appdata\\local\\programs\\python\\python36' New\n  python executable in C:\\Users\\Owner.venvs\\lpthw\\Scripts\\python.exe\n  Installing setuptools, pip, wheel...done.\nPS C:\\Users\\Owner> ..venvs\\lpthw\\Scripts\\activate\n..venvs\\lpthw\\Scripts\\activate : The term\n  '..venvs\\lpthw\\Scripts\\activate' is not recognized as the name of a\n  cmdlet, function, script file, or operable program. Check the spelling\n  of the name, or if a path was included, verify that the path is\n  correct and try again. At line:1 char:1\n  + ..venvs\\lpthw\\Scripts\\activate\n  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n      + CategoryInfo          : ObjectNotFound: (..venvs\\lpthw\\Scripts\\activate:String) [], CommandNotFoundException\n      + FullyQualifiedErrorId : CommandNotFoundException","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4105,"Q_Id":51709724,"Users Score":0,"Answer":"I was also facing the same error when I was trying to activate the environment. I created that environment with vscode terminal. But when I reopen the vscode and run the activate command again, I was successfully able to activate it. So, I guess sometime it need to restart the editor to activate the newly created environment.","Q_Score":1,"Tags":"python,powershell","A_Id":58480514,"CreationDate":"2018-08-06T14:16:00.000","Title":"Virtualenv not activating in Windows 10 PowerShell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm having trouble activating the virtualenv in Windows as I am going through the basic book of Learning Python the Hard Way.  Here is what I am getting:\n\nPS C:\\Users\\Owner> virtualenv --system-site-packages .venvs\/lpthw\nUsing base prefix\n  'c:\\users\\owner\\appdata\\local\\programs\\python\\python36' New\n  python executable in C:\\Users\\Owner.venvs\\lpthw\\Scripts\\python.exe\n  Installing setuptools, pip, wheel...done.\nPS C:\\Users\\Owner> ..venvs\\lpthw\\Scripts\\activate\n..venvs\\lpthw\\Scripts\\activate : The term\n  '..venvs\\lpthw\\Scripts\\activate' is not recognized as the name of a\n  cmdlet, function, script file, or operable program. Check the spelling\n  of the name, or if a path was included, verify that the path is\n  correct and try again. At line:1 char:1\n  + ..venvs\\lpthw\\Scripts\\activate\n  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n      + CategoryInfo          : ObjectNotFound: (..venvs\\lpthw\\Scripts\\activate:String) [], CommandNotFoundException\n      + FullyQualifiedErrorId : CommandNotFoundException","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4105,"Q_Id":51709724,"Users Score":0,"Answer":"As the error states, you typed in an incorrect path when you tried to activate the virtualenv (double dot).\nI am not a PowerShell expert since I use UNIX-based systems, but something like .\\.venvs\\lpthw\\Scripts\\activate should work for you.","Q_Score":1,"Tags":"python,powershell","A_Id":51709889,"CreationDate":"2018-08-06T14:16:00.000","Title":"Virtualenv not activating in Windows 10 PowerShell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm having trouble activating the virtualenv in Windows as I am going through the basic book of Learning Python the Hard Way.  Here is what I am getting:\n\nPS C:\\Users\\Owner> virtualenv --system-site-packages .venvs\/lpthw\nUsing base prefix\n  'c:\\users\\owner\\appdata\\local\\programs\\python\\python36' New\n  python executable in C:\\Users\\Owner.venvs\\lpthw\\Scripts\\python.exe\n  Installing setuptools, pip, wheel...done.\nPS C:\\Users\\Owner> ..venvs\\lpthw\\Scripts\\activate\n..venvs\\lpthw\\Scripts\\activate : The term\n  '..venvs\\lpthw\\Scripts\\activate' is not recognized as the name of a\n  cmdlet, function, script file, or operable program. Check the spelling\n  of the name, or if a path was included, verify that the path is\n  correct and try again. At line:1 char:1\n  + ..venvs\\lpthw\\Scripts\\activate\n  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n      + CategoryInfo          : ObjectNotFound: (..venvs\\lpthw\\Scripts\\activate:String) [], CommandNotFoundException\n      + FullyQualifiedErrorId : CommandNotFoundException","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4105,"Q_Id":51709724,"Users Score":0,"Answer":"This is quite simply because the command \"activate\" is a batch file and expects to be ran from a Command Prompt, not a PowerShell prompt. PowerShell execution is done differently than batch file execution.\nSearch your virtual env provider for Activate.ps1, and either edit the batch file to run that instead, or create a function in your PowerShell profile to do that.","Q_Score":1,"Tags":"python,powershell","A_Id":54013881,"CreationDate":"2018-08-06T14:16:00.000","Title":"Virtualenv not activating in Windows 10 PowerShell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I run a flask server with sqlalchemy connecting to an sqlite database.\nTo update my database tables I exported my data to a file, updated the necessary tables and then imported the data again. This data in the database is all correct and in the right place.\nThe problem is in the passwords, they are stored as a blob (largebinary in sqlalchemy).\nWhen creating a new account with a password, the account works immediately without any problems.\nHowever all the old passwords that I have imported from the old database do not work anymore and throw an error. The error that gets thrown is the following: \nTypeError: string argument without an encoding\nThe type of the new passwords in the database is what it should be:\n<class 'bytes'>\nWith the migrated passwords, I can not even check what type it is, as it throws the TypeError during retrieval of this field.\nThe data is stored as a blob: password BLOB NOT NULL\nA not working password: $2b$12$CC6OVZTOy3Bc9bsxAeALpuJPc.iZmVwXFB\/Cj6.xRlgF2dRdTh11y\nA working password:\n$2b$12$NL8reAO7rx1NC5DwgeWVt.ojV0I6czlOKcXAOF87L5NoVsdmOulle","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":403,"Q_Id":51709917,"Users Score":0,"Answer":"As it turns out the tool I was using did not correctly export the data. The binary data then got lost as sqlite does not have a hard type enforcing.\nI fixed this by exporting the data again and manually converting all the strings to their character representation and importing it again.","Q_Score":0,"Tags":"python,sqlite,sqlalchemy","A_Id":51722623,"CreationDate":"2018-08-06T14:27:00.000","Title":"Sqlalchemy largebinary does not have an encoding after migrating data","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using wx.SearchCtrl and I need a red border around the search field. In the documentation, I could not find anything to do this easily. How can I do this?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":663,"Q_Id":51712663,"Users Score":2,"Answer":"You can't change the border colour directly, but you could use the usual trick with making this search control a child of wx.Panel with the background colour you want and make it just a few pixels smaller than its parent.","Q_Score":0,"Tags":"python,wxpython,wxwidgets,wxtextctrl","A_Id":51713327,"CreationDate":"2018-08-06T17:15:00.000","Title":"Wxpython: How to use different border color for Search box","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to analyze the Open Food Facts Dataset.\nThe Dataset is very messy!\nI am currently trying to convert the 'created_datetime' object to a Python datetime object. The entries in this column all look like \"2017-03-09T10:34:11Z\".\nI have tried the normal to_datetime method with and without \"infer_datetime_format\". Neither of them worked.\nI then changed to format of the string to look like this \"2017 03 09 10 34 12\" (I deleted the \"Z\" and \"T\" and added a space between every number).\nI then tried to run to_datetime again setting the format to '%Y %m %d %I M% %S'.\nBut no matter what I do, I get an error. In this case, I get: \"'%' is a bad directive in format '%Y %m %d %I M% %S'\".\nCould someone please help me out?\nI would really appreciate it!","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":372,"Q_Id":51714789,"Users Score":-1,"Answer":"Have you tried regex? Or even simple yr, mo, day, hr, min, sec = datetime.split(\" \") should work.","Q_Score":0,"Tags":"python,pandas,datetime-format,string-to-datetime","A_Id":51714874,"CreationDate":"2018-08-06T19:56:00.000","Title":"How can I convert strings like 2017-03-09T10:34:11Z to datetime?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This problem just started when I updated to python 3.7 (on macOS). Is there any fix or is it an issue with JetBrains? I want to use Django 2.1 with Python 3.7\nAlso when I select \"Run Server\" despite the error, everything seems to work perfectly fine.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3589,"Q_Id":51715339,"Users Score":0,"Answer":"Open Run\/Debug Configuration page\nFind Enviroment \nChange Enviroment vaialbles to: PYTHONUNBUFFERED=1;DJANGO_SEETINGS=your_project_name.settings\n\n\nYou should show to Pycharm your projects settings file :) I hope it will work if you select correct Python Interpretet (venv)","Q_Score":4,"Tags":"django,pycharm,python-3.7","A_Id":59049357,"CreationDate":"2018-08-06T20:42:00.000","Title":"Using Python 3.7 on Pycharm gives me: \"Error: Django is not importable in this environment\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm new to backend and I've written a python script which imports libraries like Flask, sqlalchemy. From taking help from here and there I've been successfully able to get JSON as response to a get call using localhost or http:\/\/127.0.0.1\/.\nNow that this is done I want to take this action on a live server so right now I've hostgator and I've created a folder there so it'll be like mydomain.com\/api\/. Now my questions is that do I need to place an index.html in this folder which makes a call to run myscript.py or I can directly call mydomain.com\/api\/myscript.py and it'll return the JSON?\nMy script is basically a recommendation model that returns recommendations to users upon request.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":378,"Q_Id":51715736,"Users Score":0,"Answer":"It's possible to make a request via PHP with the curl_* functions, or you can do the same in JavaScript (e.g. within your HTML file) using AJAX (XMLHttpRequest).","Q_Score":1,"Tags":"python,json,flask,flask-sqlalchemy","A_Id":51715768,"CreationDate":"2018-08-06T21:15:00.000","Title":"How to Call API written in Python using HTML or PHP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on a project that is using Psycopg2 to connect to a Postgre database in python, and in the project there is a place where all the modifications to the database are being committed after performing a certain amount of insertions.\nSo i have a basic question:\nIs there any benefit to committing in smaller chunks, or is it the same as waiting to commit until the end?\nfor example, say im going to insert 7,000 rows of data, should i commit after inserting 1,000 or just wait until all the data is added?\nIf there is problems with large commits what are they? could i possibly crash the database or something? or cause some sort of overflow?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":261,"Q_Id":51716121,"Users Score":1,"Answer":"Unlike some other database systems, there is no problem with modifying arbitrarily many rows in a single transaction.\nUsually it is better to do everything in a single transaction, so that the whole thing succeeds or fails, but there are two considerations:\n\nIf the transaction takes a lot of time, it will keep VACUUM from doing its job on the rest of the database for the duration of the transaction. That may cause table bloat if there is a lot of concurrent write activity.\nIt may be useful to do the operation in batches if you expect many failures and don't want to restart from the beginning every time.","Q_Score":2,"Tags":"python,postgresql,psycopg2","A_Id":51720738,"CreationDate":"2018-08-06T21:51:00.000","Title":"pyscopg2, should I commit in chunks?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to access two python version\n1. Pycell studio python 2.6.6 which is used to work on layout section\n2. Python 3.6.3 which is used for internal application \nI can not access both versions at time.\nWhen I install Python 2.6.6 it changed following environment variable\nPYTHONHOME, PYHTONPATH, CNI_DISPLAY_DIR, CNI_ROOT, OA_PLUGIN_PATH etc\nthis variable does not allow me to use python 3.6.3 and gives \"code registry error\" whenever I launched it.\nIs there any setting through which I can use both python version at a same time?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":51718472,"Users Score":0,"Answer":"You cannot run both at the same time in the same file.  However, like someone mentioned above in the comments, there are ways to have files running with different versions of Python running simultaneously.  Another way to get around your problem (though not as great for efficiency\/performance) is to output and re-input whatever data needs shared across these two different Python version code files.  Hopefully that makes sense, but comment if I need to be clearer.\nAlex Chung | Director of Operations, VTNatSec | achung@vtnatsec.org","Q_Score":0,"Tags":"python,python-3.x","A_Id":68492819,"CreationDate":"2018-08-07T03:37:00.000","Title":"Need to access two different python version i.e Python 2.6.6 and Python 3.6.3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"By default subscribers get email messages once the new task in a project is created. How it can be tailored so that unless the projects has checkbox \"Send e-mail on new task\" checked it will not send e-mails on new task?\nI know how to add a custom field to project.project model. But don't know the next step.\nWhat action to override to not send the email when a new task is created and \"Send e-mail on new task\" is not checked for project?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":24,"Q_Id":51719138,"Users Score":0,"Answer":"I found that if project has notifications option \"\nVisible by following customers\" enabled then one can configure subscription for each follower. \nTo not receive e-mails when new task is added to the project: unmark the checkbox \"Task opened\" in the \"Edit subscription of User\" form.","Q_Score":0,"Tags":"python,email,task,project,odoo-10","A_Id":52330973,"CreationDate":"2018-08-07T05:02:00.000","Title":"On project task created do not send 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":1},{"Question":"Is it possible to run my run my python script on AWS lambda 24\/7 without the 5mins limit?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":957,"Q_Id":51721079,"Users Score":0,"Answer":"That is not the purpose of AWS Lambda. If you want to run something 24\/7, you'll be better off using an ec2 instance.","Q_Score":0,"Tags":"python,aws-lambda","A_Id":51721222,"CreationDate":"2018-08-07T07:22:00.000","Title":"How can I run my python script on AWS lambda 24\/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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting this error:\n\nAn error occurred initializing the application server: Failed to locate pgAdmin4.py, terminating server thread.\n\nAs it fails it will prompt to adjust the python and application path but I read an answer on Stack Overflow where the person said he deleted the path it worked for him and did so but it still gave me the same error and I don't see the prompt again.\nSo I went to pgAdmin official site only to see that if it fails I must enter python and application path. How can I configure the paths for the pgAmin. I am using Fedora 27.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":12946,"Q_Id":51721210,"Users Score":1,"Answer":"For me, the solution was to sudo dnf remove pgadmin4* then sudo find \/ -iname \"*pgadmin4*\" and delete any scraps lying around, then sudo dnf install pgadmin4* - everything is now working fine.","Q_Score":4,"Tags":"python","A_Id":54191100,"CreationDate":"2018-08-07T07:30:00.000","Title":"An error occurred initializing the application server: Failed to locate pgAdmin4.py, terminating server thread","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am getting this error:\n\nAn error occurred initializing the application server: Failed to locate pgAdmin4.py, terminating server thread.\n\nAs it fails it will prompt to adjust the python and application path but I read an answer on Stack Overflow where the person said he deleted the path it worked for him and did so but it still gave me the same error and I don't see the prompt again.\nSo I went to pgAdmin official site only to see that if it fails I must enter python and application path. How can I configure the paths for the pgAmin. I am using Fedora 27.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":12946,"Q_Id":51721210,"Users Score":1,"Answer":"Try to just delete the config file.  You may have an old one from a previous install.\n\nrm ~\/.config\/pgadmin\/pgadmin4.conf","Q_Score":4,"Tags":"python","A_Id":53857991,"CreationDate":"2018-08-07T07:30:00.000","Title":"An error occurred initializing the application server: Failed to locate pgAdmin4.py, terminating server thread","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"conda install -c auto glassdoor\nSolving environment: failed\nPackagesNotFoundError: The following packages are not available from current channels:\n\nglassdoor","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":51724486,"Users Score":0,"Answer":"If you use Windows, try this.\nCommand Promport \u2192 \nInput [conda config --append channels conda-forge]\nYou can direct conda to locate the channel directly through this operation.","Q_Score":0,"Tags":"python,scrapy","A_Id":57504457,"CreationDate":"2018-08-07T10:25:00.000","Title":"Unable to Install GlassdoorItem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that PyCharm is using fonts installed in the system.\nMy problem is like this:\nI have corporate workspace. I can't install my own fonts. IT won't install  them. I need to use an accessibility font. \nIs there a way to force PyCharm to use custom font other than installing it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":952,"Q_Id":51725200,"Users Score":4,"Answer":"Place the .ttf files into PYCHARM_INSTALL_DIR\\jre64\\jre\\lib\\fonts and restart it.\nMake sure to install all the font face files (plain, bold, italic, bold-italic), otherwise you will get incorrect font rendering in the IDE.","Q_Score":2,"Tags":"python,intellij-idea,fonts,pycharm,jetbrains-ide","A_Id":51725297,"CreationDate":"2018-08-07T11:02:00.000","Title":"How to use, not installed into system, custom fonts in PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to update the xaxis of a bar chart using a columndatasource object? I have a chart that updates the bars based off of what is selected, but I want the tick marks in the xaxis to only represent the values that are being displayed. So, I figured the best option would be to dynamically update the xrange as each new value is selected, similar to how the overall plot is changed based on this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1385,"Q_Id":51730321,"Users Score":0,"Answer":"No, FactorRange objects are only configurable by setting the factors property of the range. It is not possible to link the factors property to a CDS directly. (Factor ranges support multi-level hierarchical levels, and that does not map naturally to CDS columns.) However, you can change the value of factors to whatever you need, in a CustomJS callback, or Python callback (if are making a Bokeh server application).","Q_Score":0,"Tags":"python,bokeh","A_Id":51730840,"CreationDate":"2018-08-07T15:22:00.000","Title":"Bokeh Dynamically Update xrange based on a ColumnDataSource","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a huge array with coordinates describing a 3D curves, ~20000 points. I am trying to use less points, by ignoring some, say take 1 every 2 points. When I do this and I plot the reduced number of points the shape looks the same. However I would like to compare the two curves properly, similar to the chi squared test to see how much the reduced plot differs from the original.\nIs there an easy, built-in way of doing this or does anyone have any ideas on how to approach the problem.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1324,"Q_Id":51730532,"Users Score":1,"Answer":"If you subsample the original curve, a simple way to assess the approximation error is by computing the maximum distance between the original curve and the line segments between the resampled vertices. The maximum distance occurs at the original vertices and it suffices to evaluate at these points only.\nBy the way, this provides a simple way to perform the subsampling by setting a maximum tolerance and decimating until the tolerance is exceeded.\nYou can also think of computing the average distance, but this probably involves nasty integrals and might give less visually pleasing results.","Q_Score":3,"Tags":"python,computational-geometry,curve-fitting","A_Id":51743453,"CreationDate":"2018-08-07T15:33:00.000","Title":"How to compare two 3D curves in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know if in Python, and more precisely, in lmfit library, there is an option for fitting data by parts ? I would like to fit data defined in different ranges and then obtain a unique fit.\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":356,"Q_Id":51733286,"Users Score":1,"Answer":"Without a more concrete example, it is hard to give a concrete answer.  But, if I understand your question correctly, you are looking to do a fit to one specific region of your data, then a fit (probably with a different functional form) to another region of your data, and then perhaps combine the multiple regions to get a final fit.  \nIf that is correct, then yes, this can be done with lmfit (and probably with other libraries as well). Let's say you want to fit data that is sort of peak like with an exponential decaying background.  First, isolate a region around that peak (it doesn't have to be perfect) and fit a peak (say, Gaussian to that).  Then fit an exponential decay to all the data except the peak area.  (Aside: numpy.where can be very useful in identifying the regions). Finally, combine the two and fit the whole curve to peak + background.\nIf that is too vague and doesn't point you in the right direction, please make the question more specific.","Q_Score":0,"Tags":"python,curve-fitting,lmfit","A_Id":51737575,"CreationDate":"2018-08-07T18:29:00.000","Title":"curve fitting by parts - lmfit Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using the kubernetes Python API< you have to specify the events to watch? Is it possible to watch all events in the cluster","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2425,"Q_Id":51735278,"Users Score":1,"Answer":"Yes.\nI am pretty sure that there is a library of Python that already implement this but in my case i implement it using the command: --watch-only\nFor example:\nkubectl get pods --watch-only >  -> will show only the changes in pods.\nCreating python process that collect the info from the  will trigger only new changes.","Q_Score":0,"Tags":"kubernetes,kubernetes-python-client","A_Id":51739752,"CreationDate":"2018-08-07T20:54:00.000","Title":"Is it possible to watch all the events on a Kubernetes cluster using the python API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Currently i am using the standard Tensorflow object detection script which is custom trained, i would like to change the colors of the bound boxes to suit the nature of my application. However i cannot seem to find a way to do so. For example instead of drawing a green box id like to draw a red box around a detected object. Thank you in advance!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1764,"Q_Id":51738546,"Users Score":1,"Answer":"I sort of found a way - after much trouble. I found nothing documenting how to do this. \nSort of, as some colors don't seem to work.\nOpen \"visualizations_utils.py\". Should be in Lib\\site-packages\\utils. \nRows 41 to 63 are your colors. \nDirectly under row 164,\ndraw = ImageDraw.Draw(image), \nenter a new row \ncolor = 'Pink'\nSave it, and you have now changed the color to a pinkish color. Row 175, you can make the label text smaller. \nSome colors don't seem to work, like \"Red\".","Q_Score":0,"Tags":"python,tensorflow,computer-vision,data-science,object-detection","A_Id":52075500,"CreationDate":"2018-08-08T04:19:00.000","Title":"How to add custom colors to Tensorflow object detection python model bound boxes?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a program that will call python. I would like to add python in my project so users don't have to download python in order to use it, also it will be better to use the python that my program has so users don't have to download any dependency.\nMy program it's going to be writing in C++ (but can be any language) and I guess I have to call the python that is in the same path of my project?\nLet's say that the system where the user is running already has python and he\/she calls 'pip' i want the program to call pip provided by the python give it by my program and install it in the program directory instead of the system's python?\nIt's that possible? If it is how can I do it?\nReal examples:\nThere are programs that offer a terminal where you can execute python to do things in the program like:\n\nMaya by Autodesk\nNuke by The foundry\nHoudini by Side Effects\n\nNote: It has to be Cross-platform solution","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":73,"Q_Id":51738921,"Users Score":1,"Answer":"In order to run python code, the runtime is sufficient. Under Windows, you can use py2exe to pack your program code together with the python runtime and all recessary dependencies. But pip cannot be used and it makes no sense, as you don't want to develop, but only use the python part.\nTo distribute the complete python installation, like Panda3D does, you'll have to include it in the chosen installer software.","Q_Score":0,"Tags":"python,pythonpath,python-packaging,python-config","A_Id":51739051,"CreationDate":"2018-08-08T05:01:00.000","Title":"How can I pack python into my 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":1,"Web Development":0},{"Question":"Please give me a hint about how is it better to code a Python application which helps to organise ideas by tags. \nAdd a new idea:\nInput 1: the idea\nInput 2: corresponding tags\nSearch for the idea:\nInput 1: one or multiple tags\nAs far as I understood, it's necessary to create an array with ideas and an array with tags. But how to connect them? For example, idea number 3 corresponds to tags number 1 and 2. So the question is: how to link these two arrays in the most simple and elegant way?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":51739732,"Users Score":0,"Answer":"Have two dictionaries:\n\nIdea -> Set of Tags\nTag -> Set of Ideas\n\nWhen you add a new idea, add it to the first dictionary, and then update all the sets of the tags it uses in the second dictionary. This way you get easy lookup by both tag and idea.","Q_Score":0,"Tags":"python,logic,tagging","A_Id":51760473,"CreationDate":"2018-08-08T06:15:00.000","Title":"Python app to organise ideas by tags","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"So, I have 3 different data frames:\nall_options = {'free': free, 'paid': paid, 'all': df}\nWhat is the best way to iterate over to get the values for each one?\nI want to make a plot in dash. So when user will click on \"free\" data frame it will show him the graph with free items only?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":51741482,"Users Score":0,"Answer":"it was easy as [v.columns for k, v in all_options.items()]\nThank you :)","Q_Score":1,"Tags":"python-3.x,pandas,plotly,plotly-dash","A_Id":51748887,"CreationDate":"2018-08-08T07:59:00.000","Title":"Best way to get the values from dict or list for 3 different dataframes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Recently Python 3.6 added static typing as a way to enforce certain types. This same functionality I used to get it from Cython, obtaining highly optimized functions when compared to vanilla Python.\nMy question then is: Will we also get substantial a performance increase when using the new Python static typing? pros\/cons of each approach?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2392,"Q_Id":51742986,"Users Score":5,"Answer":"Static typing in Python doesn't make it a compiled programing language. Therefore, performance-wise, you should always get better performance from Cython (Compiled should always beat Interpreted).\nThe main purpose of Python's newly added static typing is to perform type checking in a seamless way, bys sacrificing some of Python's philosophy on the way.\nIn short: Cython for speed, Python3.6 for interpreted\/more pythonic approach.","Q_Score":5,"Tags":"python,cython,static-typing","A_Id":51743103,"CreationDate":"2018-08-08T09:20:00.000","Title":"Performance comparison Static Typing Python 3.6+ vs Cython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a library that gets updates from time to time. I'd like users to use latest version. And I don't want them to do pip install every single time. What are possible workarounds?\nIdeally, that should be bundled in pip, just like -SNAPSHOT feature in java world. Creating a wrapper over runner that checks for latest version sounds like reinventing a wheel, and I'd prefer to not do that.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":51743789,"Users Score":0,"Answer":"I'd say that considering safety and security, any trick for autoupdating a dependency should require consentment of the user in some way.\nThe trick to emulate the -SNAPSHOT feature from the java world is to pip install from a Git repo. You still need to trigger the pip install in some way, however, so you'll need that wrapper.","Q_Score":0,"Tags":"python,pip","A_Id":51744616,"CreationDate":"2018-08-08T09:57:00.000","Title":"Autoupdatable dependency","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a problem when I generate an exe file with pyinstaller. My code runs okay when I execute using the python interpreter but when I generate the exe file using the PyInstaller I get a GRPC error.\n\nError:\n  Exception in 'grpc._cython.cygrpc.ssl_roots_override_callback' ignored\n  E0807 20:38:36.262000000 10808 src\/core\/lib\/security\/security_connector\/security_connector.cc:1173] assertion failed: pem_root_certs != nullptr\n\nThe error happen when I try to execute a long_running_recognize.\nAny tips regarding this problem?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1738,"Q_Id":51745571,"Users Score":0,"Answer":"To resolve this I did the following\n1.) create a hook-grpc with the following code\nfrom PyInstaller.utils.hooks import collect_data_files\ndatas = collect_data_files('grpc')\n2.) saved this file the location C:\\Users\\swap***\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\site-packages\\PyInstaller\\hooks (this will vary as per the installation)\n3.) Re create the exe file using the PyInstaller\ncommand to create the file is below\npyinstaller --onefile pythonScriptName.py (replace this\"pythonScriptName\" with your file name)","Q_Score":1,"Tags":"python,google-cloud-platform,pyinstaller,grpc","A_Id":67571862,"CreationDate":"2018-08-08T11:28:00.000","Title":"Exception in GRPC when trying to execute Google Cloud API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Columns L,M,N of my dataframe are populated with 'true' and 'false' statements(1000 rows). I would like to create a new column 'count_false' that will return the number of times 'false' statement occurred in columns L,M and N.\nAny tips appreciated!\nThank you.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1777,"Q_Id":51745679,"Users Score":0,"Answer":"Try this :  df[df==false].count()","Q_Score":0,"Tags":"python,pandas,countif","A_Id":51745774,"CreationDate":"2018-08-08T11:32:00.000","Title":"Python | count number of False statements in 3 rows","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The max_row function returns a value higher than it should be (the largest row that has a value in it is row 7, but max_row returns 10), and if I try iterating through a column to find the first row that has nothing in it I get the same value as max_row.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1845,"Q_Id":51747535,"Users Score":0,"Answer":"This would be easier to understand if you work with excel on java.\nExcel cell have properties which define them as active or inactive. If you enter a value to a cell then delete the value, the cell still remains active.\nmax_row returns the row number of the last active cell, hence you get 10 rather than 7 even if the sheet now have data only till row 7 it may once have data till 10.\nManually you can clear the cell (Editing->Clear->Clear All) for the cell in excel making it inactive again. Not sure how to do the same via code in python.","Q_Score":0,"Tags":"python,excel,openpyxl","A_Id":56765286,"CreationDate":"2018-08-08T13:05:00.000","Title":"How do I find the max row in Openpyxl","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to invert a classifier on MNIST dataset on keras, thus the determinant of weight matrix must not be zero. Then I can use x=W-1f-1(y) \nBut there is no custom constraint in keras.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":61,"Q_Id":51748305,"Users Score":1,"Answer":"By far the easiest way to ensure that is to check wether the trained W has determinant 0. If it doesn't then you're OK to go, if it does you can add a small constant (1e-7) to any weight in the matrix and solve the issue. I can tell you anyway that the odds of zero determinant happenning are almost negligible.","Q_Score":0,"Tags":"python,keras","A_Id":51748484,"CreationDate":"2018-08-08T13:44:00.000","Title":"custom constraint of weight matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to do image classification with the Inception V3 model. Does ImageDataGenerator from Keras create new images which are added onto my dataset? If I have 1000 images, will using this function double it to 2000 images which are used for training? Is there a way to know how many images were created and now fed into the model?","AnswerCount":7,"Available Count":2,"Score":0.057080742,"is_accepted":false,"ViewCount":20435,"Q_Id":51748514,"Users Score":2,"Answer":"Also note that: These augmented images are not stored in the memory, they are generated on the fly while training and lost after training. You can't read again those augmented images. \nNot storing those images is a good idea because we'd run out of memory very soon storing huge no of images","Q_Score":39,"Tags":"python,tensorflow,machine-learning,keras,computer-vision","A_Id":51754972,"CreationDate":"2018-08-08T13:54:00.000","Title":"Does ImageDataGenerator add more images to my dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to do image classification with the Inception V3 model. Does ImageDataGenerator from Keras create new images which are added onto my dataset? If I have 1000 images, will using this function double it to 2000 images which are used for training? Is there a way to know how many images were created and now fed into the model?","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":20435,"Q_Id":51748514,"Users Score":0,"Answer":"Let me try and tell u in the easiest way possible with the help of an example.\nFor example:\n\nyou have a set of 500 images\nyou applied the ImageDataGenerator to the dataset with batch_size = 25\nnow you run your model for lets say 5 epochs with\nsteps_per_epoch=total_samples\/batch_size\nso , steps_per_epoch will be equal to 20\nnow your model will run on all 500 images (randomly transformed according to instructions provided to ImageDataGenerator) in each epoch","Q_Score":39,"Tags":"python,tensorflow,machine-learning,keras,computer-vision","A_Id":68196196,"CreationDate":"2018-08-08T13:54:00.000","Title":"Does ImageDataGenerator add more images to my dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This may be a stupid question but I am struggling to import windows related modules into PyCharm while running on Linux Mint. E.g. PyHook, pywin32. I get no module found. Other modules install fine though. I have tried Python 2 and 3. Do I have to program in windows to import these?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":20,"Q_Id":51750056,"Users Score":1,"Answer":"Yes, you have to. These modules need Windows specific APIs that Linux doesn't have. You might be able to work with a Windows Python under Wine, but this is a fragile setup.","Q_Score":0,"Tags":"python,pycharm","A_Id":51750109,"CreationDate":"2018-08-08T15:09:00.000","Title":"Do you need to be on windows to import windows related modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Trying to load CSV file while doing simple linear regression . When I try to run , the error is coming as - \"File name\" is not exist as file\/directory . Do I need to save the file in a particular folder or directory ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":220,"Q_Id":51750841,"Users Score":0,"Answer":"try to use the full qualified path, or in the same directory of the main programm","Q_Score":3,"Tags":"python-3.x,jupyter-notebook,linear-regression","A_Id":51751064,"CreationDate":"2018-08-08T15:50:00.000","Title":"CSV file unable to upload","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I run conda install\/remove\/update <package>, it tells me it's \"Solving environment\" for some time before telling me the list of things it's going to download\/install\/update. Presumably it's looking for dependencies for <package>, but why does it sometimes remove packages after doing this operation? For example, as I was trying to install Mayavi, it decided it needed to remove Anaconda Navigator. \nFurthermore it does not provide an option to perform only a subset of the suggested operations. Is there a way to specify that I don't want a package removed?","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":84159,"Q_Id":51753988,"Users Score":8,"Answer":"As a side note on the \"Solving Environment\" step...\nLack of administrator privileges may affect whether or where you can install python packages.\nI observed that my installs would hang on the \"Solving Environment\" step and never get through when attempting to install packages while logged in as a non-administrator.  \nGetting switched to admin was possible for me on the machine I was stuck on, so I just did that and it solved the problem.\nCommenter explains workaround when this is not possible.","Q_Score":73,"Tags":"python,anaconda,updates,conda,package-managers","A_Id":54504833,"CreationDate":"2018-08-08T19:07:00.000","Title":"What does conda do when \"solving environment\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I run conda install\/remove\/update <package>, it tells me it's \"Solving environment\" for some time before telling me the list of things it's going to download\/install\/update. Presumably it's looking for dependencies for <package>, but why does it sometimes remove packages after doing this operation? For example, as I was trying to install Mayavi, it decided it needed to remove Anaconda Navigator. \nFurthermore it does not provide an option to perform only a subset of the suggested operations. Is there a way to specify that I don't want a package removed?","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":84159,"Q_Id":51753988,"Users Score":2,"Answer":"conda install --prune <<package>> helped me to install the right channel.  \nSuspecting environment used are for zipline and channel used not compatible with existing one.  prune takes a lot of time but helped me in solving the environment issues.","Q_Score":73,"Tags":"python,anaconda,updates,conda,package-managers","A_Id":55477510,"CreationDate":"2018-08-08T19:07:00.000","Title":"What does conda do when \"solving environment\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I run conda install\/remove\/update <package>, it tells me it's \"Solving environment\" for some time before telling me the list of things it's going to download\/install\/update. Presumably it's looking for dependencies for <package>, but why does it sometimes remove packages after doing this operation? For example, as I was trying to install Mayavi, it decided it needed to remove Anaconda Navigator. \nFurthermore it does not provide an option to perform only a subset of the suggested operations. Is there a way to specify that I don't want a package removed?","AnswerCount":4,"Available Count":4,"Score":0.1973753202,"is_accepted":false,"ViewCount":84159,"Q_Id":51753988,"Users Score":4,"Answer":"JUST WAIT! I wasted hours trying to fix this. It turns out, it just took around 45 minutes :\/","Q_Score":73,"Tags":"python,anaconda,updates,conda,package-managers","A_Id":70726475,"CreationDate":"2018-08-08T19:07:00.000","Title":"What does conda do when \"solving environment\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I run conda install\/remove\/update <package>, it tells me it's \"Solving environment\" for some time before telling me the list of things it's going to download\/install\/update. Presumably it's looking for dependencies for <package>, but why does it sometimes remove packages after doing this operation? For example, as I was trying to install Mayavi, it decided it needed to remove Anaconda Navigator. \nFurthermore it does not provide an option to perform only a subset of the suggested operations. Is there a way to specify that I don't want a package removed?","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":84159,"Q_Id":51753988,"Users Score":50,"Answer":"You can add --debug option to the conda command and see the output from console(or terminal). For example, type conda update --debug numpy.\nFrom the output, we can see that the client requests repodata.json from channel list and do some computation locally in the Solving Environment Step.","Q_Score":73,"Tags":"python,anaconda,updates,conda,package-managers","A_Id":53138545,"CreationDate":"2018-08-08T19:07:00.000","Title":"What does conda do when \"solving environment\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to communicate between electron app and opened other brower. I have to send params from electron to other browser or from browser to electron app. But there is no way.\nplease help me!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":77,"Q_Id":51755103,"Users Score":1,"Answer":"This does not seem very realistic. But I have a few ideas here:\nElectron -> Browser\n\nWebserver which you can open in the Browser\nwrite a Browser extension\n\nBrowser -> Electron\n\nA special url like the ones apple uses for the app store (e.g.: itmss:\/\/itunes.apple.com\/de\/store?...)\n\nDue to security reasons it is not possible to \"talk\" to a browser and access other webpages information. Otherwise it would be easy to leak cookies and personal data.","Q_Score":0,"Tags":"python,vue.js,electron","A_Id":51757041,"CreationDate":"2018-08-08T20:25:00.000","Title":"How to communicate between electron app and opened other browser?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to push a button on a soccer bookmaker's web page using Selenium's Chromedriver. My problem is that nothing happens when I call Selenium's driver.find_elements_by_class_name('c-events__item c-events__item_col').\nFixed:\nI was trying to get the info from: a class names 'c-events__more c-events__more_bets js-showMoreBets'. \nusing find_by_class_name() cannot handle spaces as it will think its compound classes, instead I used csselector and it works like a charm now. \ndriver.find_elements_by_css_selector('.c-events__item.c-events__item_col')","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":51755916,"Users Score":0,"Answer":"using find_by_class_name() cannot handle spaces as it will think its compound classes, instead I used csselector and it works like a charm now. driver.find_elements_by_css_selector('.c-events__item.c-events__item_col')","Q_Score":1,"Tags":"python,python-3.x,selenium","A_Id":51764087,"CreationDate":"2018-08-08T21:30:00.000","Title":"Selenium calling class elements doesn't work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to record the training accuracy of the model at the end of each epoch, but I wasn't sure if the training accuracy is calculated on the entire training data or the last mini-batch used for training. For example, if I have 10000 training data and I'm training with mini-batches of 100, would I calculate the training accuracy using the last mini-batch of 100 (the 100th and last mini-batch in that epoch) or use the entire 10000 training data?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1493,"Q_Id":51756558,"Users Score":1,"Answer":"Ideally training accuracy should be calculated including every sample, but practically, it's all right to use a subset of the data as long as its representative of all data.  Whether a random batch of 100 samples is representative of your data or not, depends on the problem at hand.  For instance if you were classifying a sample as one of one thousand possible classes, this is clearly not enough.\nI generally keep a running average of the loss over a given epoch during training.  Since the training loss is almost always monotonically decreasing, this will tend to overestimate loss (and underestimate accuracy.  However, the discrepancy should disappear as the model converges.","Q_Score":3,"Tags":"python,tensorflow,machine-learning","A_Id":51757163,"CreationDate":"2018-08-08T22:31:00.000","Title":"Is training accuracy of a model calculated on the mini-batch?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to record the training accuracy of the model at the end of each epoch, but I wasn't sure if the training accuracy is calculated on the entire training data or the last mini-batch used for training. For example, if I have 10000 training data and I'm training with mini-batches of 100, would I calculate the training accuracy using the last mini-batch of 100 (the 100th and last mini-batch in that epoch) or use the entire 10000 training data?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1493,"Q_Id":51756558,"Users Score":1,"Answer":"I agree with @Cory that ideally training accuracy should be calculated on every training sample. Instead of using an running average (exponential, perhaps), I keep the sum of last, let's say, 50 mini-batches. Then I report the average loss across these mini-batches. You can easily track the model's recent performance (you can report this number much frequently than every epoch).","Q_Score":3,"Tags":"python,tensorflow,machine-learning","A_Id":51757886,"CreationDate":"2018-08-08T22:31:00.000","Title":"Is training accuracy of a model calculated on the mini-batch?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I have two instances of a keras model model0 and model1 and datasets data0 and data1. If I have two or more GPUs, is there a way that I can train model0 on data0 on GPU0 and model1 on data1 on GPU1 in parallel? All of the methods I have found so far split the training of a single model over multiple gpus.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":196,"Q_Id":51757355,"Users Score":1,"Answer":"How about multiprocessing?\nYou just execute you function in a multiprocessing pool twice:\nWhat you need to consider:\n\nYour model have to be defined or loaded inside the function\nYou need a parameter which mask the GPUs. Masking is possible by setting the env variable CUDA_VISIBLE_DEVICES(you also have to do this inside the function)\nYou could pass the different training data via a parameter\nit would be best to save the resulting models into different files and then load it from your main program \n\nSo basically passing keras\/tensorflow sessions between your main programm and the functions in the multiprocessing tool is a nogo. But if you keep everything keras\/tensorflow related inside the function and mask the GPUs differently then you're good to go.","Q_Score":0,"Tags":"python,tensorflow,parallel-processing,keras","A_Id":51760289,"CreationDate":"2018-08-09T00:35:00.000","Title":"How to run same Keras model on different GPUs in parallel independently with different data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was writing a code to read a csv file using pandas and I saw some weird functioning of the package. My file has column names which I want to ignore, so I use header = 0 or 'infer' instead of None. But I see something weird.\nWhen I use None and I want to get a specific column, I just need to do df[column_index] but when I use 0 or 'infer', I need to do df.ix[:,column_index] to get the column otherwise, for df[column_index] I get the following error:\n\nTraceback (most recent call last):   File\n  \"\/home\/sarvagya\/anaconda3\/envs\/tf\/lib\/python3.6\/site-packages\/pandas\/core\/indexes\/base.py\",\n  line 2525, in get_loc\n      return self._engine.get_loc(key)   File \"pandas\/_libs\/index.pyx\", line 117, in pandas._libs.index.IndexEngine.get_loc   File\n  \"pandas\/_libs\/index.pyx\", line 139, in\n  pandas._libs.index.IndexEngine.get_loc   File\n  \"pandas\/_libs\/hashtable_class_helper.pxi\", line 1265, in\n  pandas._libs.hashtable.PyObjectHashTable.get_item   File\n  \"pandas\/_libs\/hashtable_class_helper.pxi\", line 1273, in\n  pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: column_index\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File \"\", line 1, in\n     File\n  \"\/home\/sarvagya\/anaconda3\/envs\/tf\/lib\/python3.6\/site-packages\/pandas\/core\/frame.py\",\n  line 2139, in getitem\n      return self._getitem_column(key)   File \"\/home\/sarvagya\/anaconda3\/envs\/tf\/lib\/python3.6\/site-packages\/pandas\/core\/frame.py\",\n  line 2146, in _getitem_column\n      return self._get_item_cache(key)   File \"\/home\/sarvagya\/anaconda3\/envs\/tf\/lib\/python3.6\/site-packages\/pandas\/core\/generic.py\",\n  line 1842, in _get_item_cache\n      values = self._data.get(item)   File \"\/home\/sarvagya\/anaconda3\/envs\/tf\/lib\/python3.6\/site-packages\/pandas\/core\/internals.py\",\n  line 3843, in get\n      loc = self.items.get_loc(item)   File \"\/home\/sarvagya\/anaconda3\/envs\/tf\/lib\/python3.6\/site-packages\/pandas\/core\/indexes\/base.py\",\n  line 2527, in get_loc\n      return self._engine.get_loc(self._maybe_cast_indexer(key))   File \"pandas\/_libs\/index.pyx\", line 117, in\n  pandas._libs.index.IndexEngine.get_loc   File\n  \"pandas\/_libs\/index.pyx\", line 139, in\n  pandas._libs.index.IndexEngine.get_loc   File\n  \"pandas\/_libs\/hashtable_class_helper.pxi\", line 1265, in\n  pandas._libs.hashtable.PyObjectHashTable.get_item   File\n  \"pandas\/_libs\/hashtable_class_helper.pxi\", line 1273, in\n  pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: column_index\n\nCan someone help with this? Why is this happening?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":23961,"Q_Id":51759122,"Users Score":3,"Answer":"The difference pops up when working with a dataframe with header, so lets say your DataFrame df has header!\n\nheader=None pandas automatically assign the first row of df (which is the actual column names) to the first row, hence your columns no longer have names\nheader=0, pandas first deletes column names(header) and then assign new column names to them (only if you pass names = [........] while loading your file).\nread_csv( filepath, header = 0 , names = ['....' , '....' ...])\n\nhope it helps!","Q_Score":0,"Tags":"python-3.x,pandas,csv,dataframe","A_Id":54832068,"CreationDate":"2018-08-09T04:57:00.000","Title":"difference between `header = None` and `header = 0` in pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I dont have much knowledge in dbs, but wanted to know if there is any technique by which when i update or insert a specific entry in a table, it should notify my python application to which i can then listen whats updated and then update that particular row, in the data stored in session or some temporary storage.\nI need to send data filter and sort calls again n again, so i dont want to fetch whole data from sql, so i decided to keep it local, nd process it from there. But i was worried if in the mean time the db updates, and i could have been passing the same old data to filter requests.\nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":42,"Q_Id":51759304,"Users Score":1,"Answer":"rdbs only will be updated by your program's method or function sort of things.\nyou can just print console or log inside of yours.\nif you want to track what updated modified deleted things, \nyou have to build a another program to able to track the logs for rdbs\n\nthanks.","Q_Score":2,"Tags":"python,sql,sql-server,database,connection","A_Id":51759339,"CreationDate":"2018-08-09T05:17:00.000","Title":"Is there any way mssql can notify my python application when any table or row has been updated?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Python scipy.optimize.minimize function supports the following methods:\n\nNelder-Mead\nPowell\nCG\nBFGS\nNewton-CG\nL-BFGS-B  \nTNC\nCOBYLA\nSLSQP\ntrust-constr\ndogleg\ntrust-ncg\ntrust-exact\ntrust-krylov\n\nWhich method is closest to R's nlminb?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":761,"Q_Id":51759606,"Users Score":4,"Answer":"nlminb is an unconstrained and bounds-constrained quasi-Newton method optimizer. This code is based on a FORTRAN PORT library by David Gay in the Bell Labs. As for Pyhon quasi-Newton menthods are:\n\nUnconstrained minimization\nMethod BFGS uses the quasi-Newton method of Broyden, Fletcher, Goldfarb, > > and Shanno (BFGS) [5] pp. 136. \nBound-Constrained minimization\nMethod L-BFGS-B uses the L-BFGS-B algorithm [6], [7] for bound\n  constrained minimization.\n\nL-BFGS-B  & BFGS, being a member of quasi-Newton family methods, are the closest analogs of nlminb.","Q_Score":2,"Tags":"r,python-3.x,scipy,nonlinear-optimization","A_Id":52239819,"CreationDate":"2018-08-09T05:45:00.000","Title":"What is the closest function to R's nlminb in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"so I am using a convolutional layer as the first layer of a neural network for deep reinforcement learning to get the spatial features out of a simulation I built. The simulation gives different maps that are of different lengths and heights to process. If I understand convolutional networks, this should not matter since the channel size is kept constant. In between the convolutional network and the fully connected layers there is a spatial pyramid pooling layer so that the varying image sizes does not matter. Also the spatial data is pretty sparse. Usually it is able to go through a few states and sometimes a few episodes before the first convolutional layer spits out all Nans. Even when I fix the map size this happens. I do not know where the problem lies, where can the problem lie?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1443,"Q_Id":51759882,"Users Score":0,"Answer":"Try to initialize your weights with random numbers between 0 and 1 and then try different learning rates for your network training. (I suggest test it with learning rates equal to 10, 1, 0.1, 0.01, ...)","Q_Score":0,"Tags":"python,neural-network,artificial-intelligence,conv-neural-network,pytorch","A_Id":51861681,"CreationDate":"2018-08-09T06:07:00.000","Title":"Pytorch Convolutional Layer returning Nan","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I have built a model to predict the final positions of horses in horse racing using data of races and horses from the past 10 years with the following features:\nhorse_age, horse_weight, race_distance, jockey\nNow, I would like to predict positions in horse racing for the upcoming season. However, during those 10 years, many of the jockeys have retired, and new ones have joined, so there will be jockeys who were unseen by the trained model, unlike horse age, horse weight and race distance.\nI would like to know what is a good way to tackle this problem. I realize that one thing I can do is to continually retrain my model to incorporate the new data, but would like to hear more interesting ideas!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":126,"Q_Id":51761031,"Users Score":0,"Answer":"I don't think that's possible. \nHowever, you can do the following:\nAssume that for each race there are 10 horses. Number them from 0 to 9.\nInclude all the features you want for all the horses, and predict which horse number will win.\nFor example: \nhorse 0: horse_age0, horse_weight0, race_distance0, jockey0 \nhorse 1: horse_age1, horse_weight1, race_distance1, jockey1 \n...\nhorse 9: horse_age9, horse_weight9, race_distance9, jockey9 \na total of 4*10=40 feature. \nThe model should predict one of the classes 0 to 9, indicating the horse number. \nBe careful with this approach though, the ordering of the horses doesn't matter, you should take that into account when training\/choosing the model. \nYou can simplify the problem by considering a one-vs-one approach, where you evaluate each pair of horses to see which one would win.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn","A_Id":51777618,"CreationDate":"2018-08-09T07:22:00.000","Title":"How to build a predictive model where there will be unseen categorical variables in the future","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I ran a clustering exercise to identify my top customers based on 12 distinct features, using K-Means (on 3 PCA dimensions and 5 PCA dimensions) and GMM (using 5 PCA dimensions) methodologies. Both the outputs from the K-Means produced almost similar customers as the best set (1182 customers in each case with an overlap of 1156) while the GMM approach gave me 660 customers as my top customers. These 660 customers were present in both the K-Means approaches. \nNow i want to identify who my top customers are from among this list. Could you please suggest any statistical approaches that i could use to say that these X number of customers are truly my best set and run some A\/B tests on them? I do not want to go with the full identified set as it might cost me more to do what is planned to such a large set of customers.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":50,"Q_Id":51761810,"Users Score":1,"Answer":"Try some good old filtering! Select one or several features, create your own metric (maybe top customers are those who buy the most, or those who are more loyal\/have stayedlonger with the company, or a weighted sum of those two factors), sort the 660 customers in your cluster and pick only the N first customers, N being your maximum allowed number of customers.","Q_Score":0,"Tags":"python,cluster-analysis,unsupervised-learning","A_Id":51762007,"CreationDate":"2018-08-09T08:05:00.000","Title":"After clustering, How do i choose the best customers (subset) from the top cluster?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing a small web application with Flask. This application needs a DSL, which can express the content of .pdf files.\nI have developed a DSL with JetBrains MPS but now I'm not sure how to use it in my web application. Is it possible? Or should I consider to switch to another DSL or make my DSL directly in Python.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1223,"Q_Id":51762908,"Users Score":4,"Answer":"If you want to use MPS in the web frontend the simple answer is: no. \nSince MPS is a projectional editor it needs a projection engine so that user can interact with the program\/model. The projection engine of MPS is build in Java for desktop applications. There have been some efforts to put MPS on the web and build Java Script\/HTML projection engine but none of the work is complete. So unless you would build something like that there is no way to use MPS in the frontend. \nIf your DSL is textual anyway and doesn't leverage the projectional nature of MPS I would go down the text DSL road with specialised tooling for that e.g. python as you suggested or Xtext.","Q_Score":6,"Tags":"python,flask,dsl,jetbrains-ide,mps","A_Id":51779632,"CreationDate":"2018-08-09T09:03:00.000","Title":"Can I use JetBrains MPS in a web application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using odoo version 9 and I've created a module to customize the reports of purchase order. Among the fields that I want displayed in the reports is the supplier reference for article but when I add the code that displays this field  <span> <t t-esc=\"', '.join([str(x.product_code) for x in o.order_line.product_id.product_tmpl_id.seller_ids])\"\/>\n  but it displays an error when I want to start printing the report\nQWebException: \"Expected singleton: purchase.order.line(57, 58, 59, 60, 61, 62, 63, 64)\" while evaluating\n\"', '.join([str(x.product_code) for x in o.order_line.product_id.product_tmpl_id.seller_ids])\"\nPS: I don't change anything in the module purchase. \nI don't know how to fix this problem any idea for help please ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":125,"Q_Id":51764170,"Users Score":1,"Answer":"It is because your purchase order got several orderlines and you are hoping that the order will have only one orderline.\no.orderline.product_id.product_tmpl_id.seller_ids \nwill work only if there is one orderline otherwise you have loop through each orderline. Here o.orderline will have multiple orderlines and you can get product_id from multiple orderline. If you try o.orderline[0].product_id.product_tmpl_id.seller_ids it will work but will get only first orderline details. Inorder to get all the orderline details you need to loop through it.","Q_Score":0,"Tags":"python-2.7,odoo-9","A_Id":51797438,"CreationDate":"2018-08-09T10:03:00.000","Title":"How to solve error Expected singleton: purchase.order.line (57, 58, 59, 60, 61, 62, 63, 64)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The eval() method under sklearn.mixture.GMM from the scikit-learn version 0.11 is deprecated. Is there a similar method or a workaround in the newest version 0.19.2 ?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":515,"Q_Id":51765325,"Users Score":1,"Answer":"Eval(X)\nParameters : \nX: array_like, shape (n_samples, n_features) : List of n_features-dimensional data points. Each row corresponds to a single data point.\nReturns : \nlogprob: array_like, shape (n_samples,) : Log probabilities of each data point in X\nresponsibilities: array_like, shape (n_samples, n_components) :\nPosterior probabilities of each mixture component for each observation\nClearly , there is no workaround in the newer definition , it is the same and quite concise definition","Q_Score":0,"Tags":"python,scikit-learn,gmm","A_Id":51766044,"CreationDate":"2018-08-09T11:06:00.000","Title":"scikit-learn deprecated GMM.eval() replacement","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When a python session\/terminal is closed or killed forcefully does the memory occupied by lists other data structures in the code released automatically (I mean the garbage collection)?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":51766387,"Users Score":0,"Answer":"Yes, the Python process attached to that terminal releases all the acquired memory. This applies not only to Python, but to standalone processes in terminals (with no dependencies).\nThis is particularly important when using GPUs, since many modules (e.g. tensorflow\/Pytorch) rely on full control of the GPU.","Q_Score":1,"Tags":"python,memory-management","A_Id":51766477,"CreationDate":"2018-08-09T11:56:00.000","Title":"Does python releases the memory used in the code when the terminal\/IDLE is closed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a volume when running a docker container with something like docker run --rm --network host --volume $PWD\/some_dir:\/tmp\/some_dir .... Inside the container I am running Python code which creates the directory \/tmp\/some_dir (overrides it in case it's already there) and puts files into there. If I run the docker container on my local dev machine the files are available on my dev machine in \/tmp\/some_dir after running the container.\nHowever if I run the same container as part of a gitlab-ci job (\"docker in docker\", the container is not the image used for the job itself) the files are not accessible in \/tmp\/some_dir (the directory exists).\nWhat could be a reason for the missing files?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":51767194,"Users Score":0,"Answer":"Did you checked the good directory on the good server ? \nCreating a $PWD\/some_dir in a DinD context, The result should be in a some_dir created in docker user home dir in the server running Gitlab CI container.","Q_Score":2,"Tags":"python,docker,gitlab-ci","A_Id":51767336,"CreationDate":"2018-08-09T12:34:00.000","Title":"Share directory in docker container with parent scope docker container 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":1,"Web Development":0},{"Question":"Is it possible to run a python flask app that pulls from a sql database, while also running a python script that updates the sql database every few seconds?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":45,"Q_Id":51767855,"Users Score":1,"Answer":"Yes, databases are designed to handle this type of concurrent access. If the database is in the middle of an update, it will wait until the update is complete before handling the Flask app's query, and it will complete the query before starting the next incoming update.","Q_Score":0,"Tags":"python,sql,multithreading,sqlalchemy,flask-sqlalchemy","A_Id":51767955,"CreationDate":"2018-08-09T13:04:00.000","Title":"Pulling from database and updating database at the same time","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Using IDLE (Python 3.x) in Windows, as is the case with many editors, F3 works as a keyboard shortcut for the 'Find Again' command in Python IDLE (as well as the menu-indicated <Ctrl>-G, plus various combinations of <Shift>, <Ctrl> and <Alt> with F3 or G). These all search forwards from the current location in the file.\nFrom habit I often press <Shift>-F3 to search backwards, especially after working in an editor that offers this feature. I have not found anything in the IDLE documentation about a 'Find Previous' feature other than the option to select the search direction in the Search Dialog.\nIs there a keyboard shortcut for 'Find Previous' in Python IDLE?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":51768174,"Users Score":0,"Answer":"No.  Find-again uses the most resent settings in the search box.","Q_Score":0,"Tags":"keyboard-shortcuts,python-idle","A_Id":51777105,"CreationDate":"2018-08-09T13:20:00.000","Title":"Is there a keyboard shortcut to repeat search backwards ('Find Previous') in Python IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a computer with the high processing power. This computer is installed with CentOS and I want to install Python 3.6 along with Python packages. The problem I face is that I am not allowed to have an internet connection so I cannot download anything. What should I do?","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":611,"Q_Id":51769509,"Users Score":-1,"Answer":"Put together a list of the packages you want and ask the machine's admin to install them.\nIf you're not allowed an internet connection you're also not allowed to sneakernet new code in.\nPS. If this is for work or school, circumventing security policies is a good way to get fired or expelled.","Q_Score":0,"Tags":"python,python-3.x,centos,packages,centos7","A_Id":51769601,"CreationDate":"2018-08-09T14:22:00.000","Title":"How to install latest version of Python and python packages in CentOS without internet connection?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a computer with the high processing power. This computer is installed with CentOS and I want to install Python 3.6 along with Python packages. The problem I face is that I am not allowed to have an internet connection so I cannot download anything. What should I do?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":611,"Q_Id":51769509,"Users Score":0,"Answer":"This is what I would do, but it is only in relation to my experience in clusters:\n\nI'd use Environment-Modules & EasyBuild\nGo to another machine on which you have access and go under the same $HOME dir\nFirst you install EasyBuild under your $HOME(\/.local) via the bootstrap process\nThen you identify a bare Python\/3.6 of EasyBuild and install that - as a test\nAt this point you should check you can make a tarball from $HOME\/.local\/EasyBuild\nTake said tarball and install at new system and see if things works as they should\nKeep expanding the list of Python packages the EasyBuild way, until not hungry\n\nOnce there, this can be expanded indefinitely.\n\nDrawback: too many moving parts.\nAdvantage: process & parts get frozen, this will be fully reproducible in the eternity.","Q_Score":0,"Tags":"python,python-3.x,centos,packages,centos7","A_Id":51770101,"CreationDate":"2018-08-09T14:22:00.000","Title":"How to install latest version of Python and python packages in CentOS without internet connection?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new in Python.\nI have an image of size 8*8, and when flattened = 64. Is there any function that measures the correlation between the pixel i and all the other pixels in this image ? \nSo at the end I want to plot a 64*64 matrix of correlation. \nThanks !","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1074,"Q_Id":51771344,"Users Score":2,"Answer":"Correlation is a measure to evaluate mutual relationship or connection between two or more things, usually vectors, not single point. Pixel is a single point with a single value. So, in your case, I would subtract pixel value form each pixel value of the image, looking at the difference in this case.","Q_Score":1,"Tags":"python,image,correlation,cross-correlation","A_Id":51771528,"CreationDate":"2018-08-09T15:51:00.000","Title":"Pixel correlation \/ similarity in an image Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Twitter announced that Site Streams, User Streams, and legacy Direct Message endpoints, originally slated for retirement on June 19th 2018, will be deprecated on Wednesday August 16, 2018 which provides 3 months from today\u2019s release of the Account Activity API for migration.\nI am wondering it those APIs have an effect on Tweepy.Stream class","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":51773215,"Users Score":0,"Answer":"I am wondering it those APIs have an effect on Tweepy.Stream class\n\nYes. Tweepy is not a special case. On August 16, the streaming APIs will be shut off, and any code in Tweepy which interacted with them will no longer function.","Q_Score":0,"Tags":"python,twitter,tweepy","A_Id":51773664,"CreationDate":"2018-08-09T17:55:00.000","Title":"Does Twitter's changes to their public APIs affect 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've almost 'finished' my first website. Which consists of an authors anthology, essentially 100's of pages containing individual articles. It's built with HTML and CSS.\nAt the bottom of each page I want to link to related pages, displaying the title and an image. How can I auto-populate these boxes by fetching related pages from a database? \nI'm just looking for someone to point me in the right direction, I will try to teach myself. I assume there would be some server side scripting? or loading the data into a sql?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":51774081,"Users Score":0,"Answer":"You'll need some sort of server side program. Something that can query the database, then return the results either through an api or process it all server side and return the html. Below are some frameworks that can help. \nJava:\nPlay, Spring, Javalin, Dropwizard, etc. \nPython:\nDjango","Q_Score":0,"Tags":"java,python,html,mysql,server","A_Id":51774168,"CreationDate":"2018-08-09T19:00:00.000","Title":"Web Development: Dynamically linking to other related webpages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to build an Agent that can play Pocket Tanks using RL. The problem I'm facing now is that how can I train a neural network to output the correct Power and Angle. so instead of actions classification. and I want a regression.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":748,"Q_Id":51774091,"Users Score":1,"Answer":"In order to output the correct power and angle, all you need to do is go into your neural network architecture and change the activation of your last layer.  \nIn your question, you stated that you are currently using an action classification output, so it is most likely a softmax output layer.  We can do two things here:\n\nIf the power and angle has hard constraints, e.g. the angle cannot be greater than 360\u00b0, or the power cannot exceed 700 kW, we can change the softmax output to a TanH output (hyperbolic tangent) and multiply it by the constraint of power\/angle.  This will create a \"scaling effect\" because tanh's output is between -1 and 1.  Multiplying the tanh's output by the constraint of the power\/angle ensures that the constraints are always satisfied and the output is the correct power\/angle.\nIf there are no constraints on your problem.  We can simply just delete the softmax output all together.  Removing the softmax allows for the output to no longer be constrained between 0 and 1.  The last layer of the neural network will simply act as a linear mapping, i.e., y = Wx + b. \n\nI hope this helps!\nEDIT: In both cases, your reward function to train your neural network can simply be a MSE loss.  Example: loss = (real_power - estimated_power)^2 + (real_angle - estimated_angle)^2","Q_Score":1,"Tags":"python,neural-network,reinforcement-learning","A_Id":51794321,"CreationDate":"2018-08-09T19:00:00.000","Title":"Regression through reinforcement learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Google Cloud with Debian 9. There are python 2.7a and 3.5. 3.5 I did as default.\nI have apache where is PHP and I need to keep it there.\nI installed libapache2-mod-python configured virtual host and pure python file return me a correct result.\nI installed Flask framework and it throws an exception that ImportError: No module named Flask\nIt's my first time with Flask and in general with python in web.\nFor all examples I see mod_wsgi but I can't install it with libapache2-mod-python.\nMy questions are:\nDoes it's possible to run Flash with libapache2-mod-python module?\nIf no, then does mod_wsgi has no conflict with PHP apache module?\nThanks for any hints.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":51774703,"Users Score":0,"Answer":"That sounds like you do not have flask installed. You may for example pip install flask to the particular python version that you are trying to run your flask app with.","Q_Score":0,"Tags":"python,apache,flask,debian","A_Id":51789220,"CreationDate":"2018-08-09T19:42:00.000","Title":"python 3.5 Flask install on apache 2.4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm facing this issue while trying to use pandas package. I have installed numpy 1.9.0 and installed dateutil 2.5.0 using the command \npip install python-dateutil==2.5.0. Still I see this error. \nIs there any other way to install dateutil? And this is related only to pandas package\n\nTraceback (most recent call last):    import pandas as pd   File\n  \"\/Users\/xyz\/Library\/Python\/2.7\/lib\/python\/site-packages\/pandas\/init.py\",\n  line 23, in \n      from pandas.compat.numpy import *   File \"\/Users\/xyz\/Library\/Python\/2.7\/lib\/python\/site-packages\/pandas\/compat\/init.py\",\n  line 422, in \n      raise ImportError('dateutil 2.5.0 is the minimum required version') ImportError: dateutil 2.5.0 is the minimum required version","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4264,"Q_Id":51776103,"Users Score":0,"Answer":"The issue was resolved by installing python 3.6. There is a version compatibility issue between pandas package and earlier version of Python","Q_Score":0,"Tags":"python,pandas,pip,easy-install,python-dateutil","A_Id":51957181,"CreationDate":"2018-08-09T21:36:00.000","Title":"ImportError: dateutil 2.5.0 is the minimum required version","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm facing this issue while trying to use pandas package. I have installed numpy 1.9.0 and installed dateutil 2.5.0 using the command \npip install python-dateutil==2.5.0. Still I see this error. \nIs there any other way to install dateutil? And this is related only to pandas package\n\nTraceback (most recent call last):    import pandas as pd   File\n  \"\/Users\/xyz\/Library\/Python\/2.7\/lib\/python\/site-packages\/pandas\/init.py\",\n  line 23, in \n      from pandas.compat.numpy import *   File \"\/Users\/xyz\/Library\/Python\/2.7\/lib\/python\/site-packages\/pandas\/compat\/init.py\",\n  line 422, in \n      raise ImportError('dateutil 2.5.0 is the minimum required version') ImportError: dateutil 2.5.0 is the minimum required version","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":4264,"Q_Id":51776103,"Users Score":1,"Answer":"I had this same issue using the newest pandas version, try downgrading to pandas 0.22.0 which fixed my issue","Q_Score":0,"Tags":"python,pandas,pip,easy-install,python-dateutil","A_Id":53266794,"CreationDate":"2018-08-09T21:36:00.000","Title":"ImportError: dateutil 2.5.0 is the minimum required version","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Couldn't find the details of this anywhere online, when comparing two frozensets does Python iterate through the elements in one of the sets or does it check the hash values of the frozensets since frozensets are hashable?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":791,"Q_Id":51778223,"Users Score":3,"Answer":"Since the reference docs don't say anything about this, it's implementation-dependent, so there is no answer short of looking at the source code for the version of Python you're using (in your CPython distribution's Objects\/setobject.c).  Looking at the source for Python 3.7.0, the answer is \"maybe\" ;-)\nEquality first checks whether the frozensets have the same size (len()).  If not, they can't be equal, so False is returned at once.\nElse the hash codes are compared if they've already been computed.  If they have already been computed, then False is returned at once if the hash codes aren't equal.  Else element-by-element code is invoked to check whether one is a subset of the other.\nA hash code for a frozenset isn't computed just for the heck of it - that would be an expense that may not pay off.  So something has to force it.  The primary use case for frozensets at the start was to allow sets of sets, and in that context hash codes will be computed as a normal part of adding a frozenset to a containing set.  The C-level set implementation contains a slot to record the hash if and when it's computed, which is initialized to -1 (a reserved value that means \"no hash code known\" internally).","Q_Score":3,"Tags":"python,frozenset","A_Id":51778365,"CreationDate":"2018-08-10T02:48:00.000","Title":"Time-complexity of checking if two frozensets are equal in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to store a picture in sqlite3 table. I'm using python and sqlite3.\nPlease let me know if you have a sample code or how to save a picture to a sqlite3 table.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2248,"Q_Id":51779568,"Users Score":1,"Answer":"Using blob type for image data is good.The data stored\nusing the sqlite.Binary type.","Q_Score":0,"Tags":"python,database,python-3.x,sqlite,sql-insert","A_Id":51782100,"CreationDate":"2018-08-10T05:31:00.000","Title":"How do I store a picture in a table with python-sqlite3?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to achieve the following behaviour: \n\nstart celery task using celery beat\nworker is killed\na new worker initiated\nthe task started over again\n\nfor doing so i set acks_late=True flag, and 'visibility_timeout': 30\nmeaning if the task did not ack in 30 seconds, a new one should be added to the queue\nfrom some reason this does not happen","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":846,"Q_Id":51780526,"Users Score":0,"Answer":"the problem seems to be with gevent\nwhen i monkey.patch_all() the retry mechanism will not work","Q_Score":0,"Tags":"python,redis,celery","A_Id":51794671,"CreationDate":"2018-08-10T06:44:00.000","Title":"celery with redis broker visibility timeout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Inside a certain function I want to stop the whole Lambda process but not trigger an error. I've tried looking at the context variable to stop it or just calling exit() but each time it's treated as an error which I don't want to track.\nHow can I end successfully a Lambda process in Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":15215,"Q_Id":51780706,"Users Score":12,"Answer":"In AWS Lambda you define a handler function and in Python a function just needs to return in order to complete successfully, where return implies return None. \nWhat you've done is correct, just have multiple return points in that handler function. You can always log messages for different reasons for the function completing if needed.","Q_Score":10,"Tags":"python-2.7,aws-lambda","A_Id":53275169,"CreationDate":"2018-08-10T06:56:00.000","Title":"Stop a Lambda function in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to upload my kivy application to Google Play store. For that i Need an .apk file , which has an api Level of 26 or higher. The .apk that I created had an apk Level of 19. So this was my way to set the Level to 26:\nI installed API 26,27,28 and the newest version of the building tool. \nIn buildozer.spec i set android.api = 26.\nAfter that I run \"buildozer android release deploy run\". And now I get this error:\n\"Check that aidl can be executed \nSearch for Aidl \nRun 'home\/dennis\/.buildozer\/android\/platform\/android-sdk-20\/build-tools\/28.0.2\/aidl' \nCWD None\nAidl cannot be executed\"\nWhat can i do to fix this? \nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1146,"Q_Id":51781916,"Users Score":0,"Answer":"Run ~\/.buildozer\/android\/platform\/android-sdk-20\/tools\/android\nSelect Android SDK Build-tools 26.x.x\nCheck aidl file in ~\/.buildozer\/android\/platform\/android-sdk-20\/build-tools\/26.x.x\/","Q_Score":0,"Tags":"android,python,kivy,apk,buildozer","A_Id":51831467,"CreationDate":"2018-08-10T08:10:00.000","Title":"Create kivy apk with buildozer ERROR: \"Aidl cannot be executed\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"As we know, when using tensorflow to save checkpoint, we have 3 files, for e.g.:\nmodel.ckpt.data-00000-of-00001\nmodel.ckpt.index\nmodel.ckpt.meta\nI check on the faster rcnn and found that they have an evaluation.py script which helps evaluate the pre-trained model, but the script only accept .ckpt file (as they provided some pre-trained models above).\nI have run some finetuning from their pre-trained model\nAnd then I wonder if there's a way to convert all the .data-00000-of-00001, .index and .meta into one single .ckpt file to run the evaluate.py script on the checkpoint?\n(I also notice that the pre-trained models they provided in the repo do have only 1 .ckpt file, how can they do that when the save-checkpoint function generates 3 files?)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":658,"Q_Id":51782871,"Users Score":0,"Answer":"These \n{\nmodel.ckpt.data-00000-of-00001\nmodel.ckpt.index\nmodel.ckpt.meta\n}\nare the more recent checkpoint format\nwhile \n{model.ckpt} \nis a previous checkpoint format\nIt will be in the same concept as to convert a Nintendo Switch to NES ... Or a 3 pieces CD bundle to a single ROM cartridge...","Q_Score":0,"Tags":"python,tensorflow","A_Id":59889359,"CreationDate":"2018-08-10T09:07:00.000","Title":"how to convert tensorflow .meta .data .index to .ckpt file?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to install Python as the requirements for Emscripten copiler.\nI want to know if any version is ok for this, because i found an old site with instuctions but there is said to install Python 2.7.12 or newer.\nI found a Python 3.7.0 version from 2018 and i don't know if this version should work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":129,"Q_Id":51784307,"Users Score":0,"Answer":"Python 3.6 will be great. It will definitely work, but yeah be careful while setting the path.","Q_Score":1,"Tags":"python,version,emscripten","A_Id":51784435,"CreationDate":"2018-08-10T10:19:00.000","Title":"What version of Python should i install for emscripten compiler?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using sns.distplot with hist=True and kde=True. This works fine but for some datasets (e.g. if they contain only discrete values) the kernel density estimation line is zig-zagging which looks very odd given that the histogram underneath is smooth. A manual adjustment of the kde bandwidth should fix this but how can I set this for sns.distplot? The documentation does not say anything and the \"bw\" parameter that works for sns.kdeplot does not exist. How can I stop it from zig-zagging?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3950,"Q_Id":51784529,"Users Score":2,"Answer":"You can use the bandwidth option(bw) with the optional parameter \"kde_kws\" in the seaborn distplot to set the desired bandwidth.\neg :\ng = g.map(sns.distplot, \"value\", kde_kws={'bw':0.1})","Q_Score":0,"Tags":"python,plot,seaborn,kernel-density","A_Id":62967486,"CreationDate":"2018-08-10T10:31:00.000","Title":"How can I hand a to bandwidth for the kde to seaborn's distplot?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a use case where I need to classify some images as grey scale or color. My initial step was based on the feature that grey scale images should have r,g,b values at a pixel, the same values as it is single channel. Were as for color images, r,g,b values at the same pixel may not be the same.\nSo I am checking by getting the difference between (r,g), (b,g) and (r,b) and if all three has only zero, its grey scale else, its color.\nThis approach helped me to identify many grey scale images but still there are some images which does not follow this logic. Can anyone specify some good features on which we can classify an image as color or grey scale using opencv?\nDo not ask me to check the number of channels and classify, it gives 3 for both the classes as we are loading it in .jpg format.\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1021,"Q_Id":51784719,"Users Score":1,"Answer":"I suspect, some never were grey-scale images after digitizing (e.g. a color scan of gray-scale picture). Due to noise, there are minimal differences in the RGB values. A low threshold greater than perfect zero should do the trick.\nPlease note that JPEG totally has a gray-scale option. However, when storing the picture, you request that mode. Compressors usually do not pick it up automatically. Also, you explicitly need to set the flag IMREAD_UNCHANGED while reading with OpenCV's imread.","Q_Score":1,"Tags":"python,opencv,image-processing,classification,opencv-python","A_Id":51784896,"CreationDate":"2018-08-10T10:41:00.000","Title":"How to classify between a color image and grey scale image using opencv?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python 3.7 with 32bit and after I did pip install pygame, I'm still getting\n\nModuleNotFoundError: No module named 'pygame'\n\nwhen running my code. I'm using pycharm.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":10270,"Q_Id":51786945,"Users Score":1,"Answer":"Probably you have several instances of Pythion on your computer. You may install pygame in one instance, but IDE uses another.","Q_Score":4,"Tags":"python-3.x,pygame","A_Id":66267946,"CreationDate":"2018-08-10T12:50:00.000","Title":"ModuleNotFoundError: No module named 'pygame'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python 3.7 with 32bit and after I did pip install pygame, I'm still getting\n\nModuleNotFoundError: No module named 'pygame'\n\nwhen running my code. I'm using pycharm.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":10270,"Q_Id":51786945,"Users Score":2,"Answer":"I would just like to add to what the first answer is saying:\nIf you are using pycharm, it still won't work until you go to file >> settings >> >> [your project name] >> python interpreter. You will see a list of packages there. If pygame is on it, then good, else, you must double click on the field where the packages are. It leads you to a little pop up box where you can type in things. If you type in pygame, you should be able to install the package.","Q_Score":4,"Tags":"python-3.x,pygame","A_Id":64087960,"CreationDate":"2018-08-10T12:50:00.000","Title":"ModuleNotFoundError: No module named 'pygame'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python 3.7 with 32bit and after I did pip install pygame, I'm still getting\n\nModuleNotFoundError: No module named 'pygame'\n\nwhen running my code. I'm using pycharm.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":10270,"Q_Id":51786945,"Users Score":1,"Answer":"I ran into the same error a few days ago! Thankfully, I found the answer.\nYou see, the problem is that pygame comes in a .whl (wheel) file\/package. So, as a result, you have to pip install it.\nPip installing is a very tricky process, so please be careful. The steps are:-\nStep1. Go to C:\/Python (whatever version you are using)\/Scripts. Scroll down. If you see a file named pip.exe, then that means that you are in the right folder. Copy the path.\nStep2. In your computer, search for Environment Variables. You should see an option labeled 'Edit the System Environment Variables'. Click on it.\nStep3. There, you should see a dialogue box appear. Click 'Environment Variables'. Click on 'Path'. Then, click 'New'. Paste the path that you copied earlier.\nStep4. Click 'Ok'.\nStep5. Shift + Right Click wherever your pygame is installed. Select 'Open Command Window Here' from the dropdown menu. Type in 'pip install py' then click tab and the full file name should fill in. Then, press Enter, and you're ready to go! Now you shouldn't get the error again!!!","Q_Score":4,"Tags":"python-3.x,pygame","A_Id":52068216,"CreationDate":"2018-08-10T12:50:00.000","Title":"ModuleNotFoundError: No module named 'pygame'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am printing a folder name to a text file containing data, and want to remove the external folders from the string. For example, it is printing C:\\A3200\\201808101040, but I want to print 201808101040. When I use str(os.getcwd().strip('C:\\\\A3200\\\\')) to remove the external folders from being printed, the program returns 180810104, which is weird because some of the zeros are removed but some aren't, etc. (it removed the beginning 20 and the ending 0.)\nI know that this could be done by getting the folder name a different way than os.getcwd(), but I am interested in this method of string manipulation for the future.\nHow do I remove a certain string of characters within a full string without affecting the characters that are repeated later in the full string?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":64,"Q_Id":51789115,"Users Score":1,"Answer":"Strip takes a set of characters and removes from both sides until it encounters a character not in the set. This is why it eats your 2 and 0 but not the 1. You will probably have better luck with os.getcwd().split(os.sep)[-1]","Q_Score":0,"Tags":"python","A_Id":51789219,"CreationDate":"2018-08-10T14:52:00.000","Title":"Removing a string in Python without removing repeating characters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am printing a folder name to a text file containing data, and want to remove the external folders from the string. For example, it is printing C:\\A3200\\201808101040, but I want to print 201808101040. When I use str(os.getcwd().strip('C:\\\\A3200\\\\')) to remove the external folders from being printed, the program returns 180810104, which is weird because some of the zeros are removed but some aren't, etc. (it removed the beginning 20 and the ending 0.)\nI know that this could be done by getting the folder name a different way than os.getcwd(), but I am interested in this method of string manipulation for the future.\nHow do I remove a certain string of characters within a full string without affecting the characters that are repeated later in the full string?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":64,"Q_Id":51789115,"Users Score":0,"Answer":"That may work, but I would like to know for future reference how to\n  just do it string-wise, in case I need to remove something else like\n  \"pear\" from \"pear tree\", etc. where the \"e\" is in both words\n\nYou could do 'pear tree'.replace('pear', '', 1).strip()","Q_Score":0,"Tags":"python","A_Id":51789246,"CreationDate":"2018-08-10T14:52:00.000","Title":"Removing a string in Python without removing repeating characters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Windows 10 workstation with Python 2.7 and pip 18.0. Some time ago I installed a package, conan 0.26.1. Now, I am upgrading with the command python -m pip install --upgrade conan==1.4.4. The upgrade completes successfully (including some dependent packages), the file C:\\Python27\\Scripts\\conan.exe has a current timestamp, and conan --version reports the new version.\nThen, after about 10 or 20 minutes, without me doing anything to the computer, that conan.exe file disappears and is replaced with a conan.exe file with a new timestamp, which reports that it is version 0.26.1. A dependent package is also downrev'ed.\nI've added auditing on that file and it appears that somehow a command prompt is running a pip command at the time the change occurs. But I have no idea why or how to stop it. \nI don't think I am using virtualenv, and turning off Windows Defender does not help. It also happens right after rebooting.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":51789374,"Users Score":0,"Answer":"It turns out that the culprit was Puppet Agent. Going to Services and stopping Puppet Agent fixed the problem.","Q_Score":0,"Tags":"python,pip","A_Id":51792472,"CreationDate":"2018-08-10T15:06:00.000","Title":"pip spontaneously downgrades a package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We use built-in unittest (or Django's wrappers) for testing a Python project. \nIn some of those tests, we use libs like freezegun or mock, which aren't used anywhere in the production codebase. \nOur CI that runs tests installs all deps before a test run, so usually we'd put those in dev-deps. \n\nIs it common to leave those in the dev-packages section of the Pipfile, or should test-related packages also reside in packages?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":198,"Q_Id":51791457,"Users Score":2,"Answer":"a small note about mock since Python v3.3 it's part of the unittest module.\nSaid that, in theory would be better to keep those kind of packages in the dev-dependencies.\nIn practice you could ignore the problem unless you\n\nyou have tons of dependencies\nsome dependency is hard to install (maybe it requires a C compiler installed or something similar)","Q_Score":1,"Tags":"python,unit-testing,testing,pipenv,pipfile","A_Id":51791651,"CreationDate":"2018-08-10T17:32:00.000","Title":"If I only use a library during test suite runs, should it be in normal or dev packages in my Pipfile?","Data 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 help on how to write a script that configures an applications (VLC) settings to my needs without having to do it manually myself. The reason for this is because I will eventually need to start this application on boot with the correct settings already configured. \nSteps I need done in the script.\n1)  I need to open the application.\n2)  Open the \u201cOpen Network Stream\u2026\u201d tab (Can be done with Ctrl+N).\n3)  Type a string of characters \u201cString of characters\u201d\n4)  Push \u201cEnter\u201d twice on the keyboard.\nI\u2019ve checked various websites across the internet and could not find any information regarding this. I am sure it\u2019s possible but I am new to writing scripts and not too experienced. Are commands like the steps above possible to be completed in a script?\nNote: Using Linux based OS (Raspbian).\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":20,"Q_Id":51791754,"Users Score":0,"Answer":"Do whichever changes you want manually once on an arbitrary system, then make a copy of the application's configuration files (in this case ~\/.config\/vlc)\nWhen you want to replicate the settings on a different machine, simply copy the settings to the same location.","Q_Score":0,"Tags":"python,shell,vlc","A_Id":51791818,"CreationDate":"2018-08-10T17:54:00.000","Title":"How do I write a script that configures an applications settings for me?","Data Science and Machine Learning":0,"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 had an error while trying to install spacy package on python 3.6 azure function as it needs a c++ compiling as a prerequisite for installation so I got this error:\n\nfatal error C1510: Cannot load language resource clui.dll.\n    error: command 'D:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 4\n\nRunning setup.py clean for spacy\n    Failed building wheel for spacy\n\nI've tried to use wheel but it's not supported for this package.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":484,"Q_Id":51792988,"Users Score":0,"Answer":"The solution that was fit to me and solved this problem is to use Docker. I've created a custom image and installed my environment on Ubuntu and pushed this image to Azure and it works fine. I've followed the steps on this Link for deploying my docker image on Azure: docs.microsoft.com\/en-us\/azure\/app-service\/containers\/\u2026","Q_Score":0,"Tags":"python,python-3.x,azure,spacy","A_Id":52326842,"CreationDate":"2018-08-10T19:28:00.000","Title":"cannot install spacy package while trying to create python 3.6 azure function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to build create a script that does a few action inside an DirectX game.\nI've got everything working exept for moving the mouse.\nIs there any module avalable that can move the mouse, for windows (python 3)\nThanks!","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1819,"Q_Id":51793103,"Users Score":-1,"Answer":"Use a freeware App called sikulix. It will do wonders for you","Q_Score":2,"Tags":"python,windows,python-3.x,directx","A_Id":51793147,"CreationDate":"2018-08-10T19:37:00.000","Title":"Python3 move mouse in DirectX games","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Since Text(Tk(), image=\"somepicture.png\") is not an option on text boxes, I was wondering how I could make bg=  a .png image. Or any other method of allowing a text box to stay a text box, with an image in the background so it can blend into a its surroundings.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":325,"Q_Id":51794733,"Users Score":1,"Answer":"You cannot use an image as a background in a text widget.\nThe best you can do is to create a canvas, place an image on the canvas, and then create a text item on top of that. Text items are editable, but you would have to write a lot of bindings, and you wouldn't have nearly as many features as the text widget. In short, it would be a lot of work.","Q_Score":1,"Tags":"python,image,tkinter,textbox","A_Id":51795473,"CreationDate":"2018-08-10T22:27:00.000","Title":"Python\/Tkinter - Making The Background of a Textbox an Image?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a minimax like function that can predict if a move in 2048 is a good move or not and give it a score. The only thing it is missing however is a way of remember each of the states in the game. \nFor example if you shift a board up (the equivalent of pressing up on the keyboard) how would I eventually be able to go back to that game state when I need to go back in depth and shift the original state to the right? What's the best way of doing this? \nThe board itself is stored as a 2d array fyi.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":506,"Q_Id":51795961,"Users Score":1,"Answer":"There are 16 squares in the 2048 board, and each one contains a power of 2 from 2^1 through 2^11.  Rounding up, it takes 4 bits to store a number from 1 to 11, so it only takes 16*4 = 64 bits to store the game state as 16 numbers from 1 to 11.\n64 bits is not a lot, so you might as well store every game state directly instead of using something more indirect and complicated.  You could encode it into a bytes 8 bytes long, a 16-character hex string, or a long integer.  A long integer (long in python 2 or int in python 3) will probably end up being the most compact and easiest to work with.","Q_Score":0,"Tags":"python,algorithm,event-sourcing","A_Id":51796306,"CreationDate":"2018-08-11T02:29:00.000","Title":"Best way to store game states of a 2048 board when using a gametree in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used to install pyenv by homebrew to manage versions of python, but now, I want to use anaconda.But I don't know how to uninstall pyenv.Please tell me.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":69156,"Q_Id":51797189,"Users Score":3,"Answer":"Try removing it using the following command:\nbrew remove pyenv","Q_Score":31,"Tags":"python,macos,homebrew,pyenv","A_Id":51797223,"CreationDate":"2018-08-11T06:44:00.000","Title":"how to uninstall pyenv(installed by homebrew) on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I used to install pyenv by homebrew to manage versions of python, but now, I want to use anaconda.But I don't know how to uninstall pyenv.Please tell me.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":69156,"Q_Id":51797189,"Users Score":3,"Answer":"None work for me (under brew) under Mac Cataline.  \nThey have a warning about file missing under .pyenv. \n(After I removed the bash_profile lines and also rm -rf ~\/.pyenv,\nI just install Mac OS version of python under python.org and seems ok.\nSeems get my IDLE work and ...","Q_Score":31,"Tags":"python,macos,homebrew,pyenv","A_Id":58908094,"CreationDate":"2018-08-11T06:44:00.000","Title":"how to uninstall pyenv(installed by homebrew) on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How to open spyder.exe IDE after installing Anaconda 5.2 in Windows 64 bit for running Python 3.6 version?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":159,"Q_Id":51797312,"Users Score":1,"Answer":"Run spyder in the command prompt","Q_Score":0,"Tags":"python,ide,anaconda,python-3.6,spyder","A_Id":51797351,"CreationDate":"2018-08-11T07:02:00.000","Title":"Python 3.6 Spyder IDE from Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cannot find the way to install pandas for sublimetext. Do you might know how?\nThere is something called pandas theme in the package control, but that was not the one I needed; I need the pandas for python for sublimetext.","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":3063,"Q_Id":51798041,"Users Score":-1,"Answer":"You can install this awesome theme through the Package Control.\n\nPress cmd\/ctrl + shift + p to open the command palette.\nType \u201cinstall package\u201d and press enter. Then search for \u201cPanda Syntax Sublime\u201d\n\nManual installation\n\nDownload the latest release, extract and rename the directory to \u201cPanda Syntax\u201d.\nMove the directory inside your sublime Packages directory. (Preferences > Browse packages\u2026)\n\nActivate the theme\nOpen you preferences (Preferences > Setting - User) and add this lines:\n\"color_scheme\": \"Packages\/Panda Syntax Sublime\/Panda\/panda-syntax.tmTheme\"\nNOTE: Restart Sublime Text after activating the theme.","Q_Score":0,"Tags":"python,pandas,sublimetext3","A_Id":51798479,"CreationDate":"2018-08-11T08:48:00.000","Title":"How to install pandas for sublimetext?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cannot find the way to install pandas for sublimetext. Do you might know how?\nThere is something called pandas theme in the package control, but that was not the one I needed; I need the pandas for python for sublimetext.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3063,"Q_Id":51798041,"Users Score":0,"Answer":"For me, \"pip install pandas\" was not working, so I used pip3 install pandas which worked nicely.\nI would advise using either pip install pandas or pip3 install pandas for sublime text","Q_Score":0,"Tags":"python,pandas,sublimetext3","A_Id":62584783,"CreationDate":"2018-08-11T08:48:00.000","Title":"How to install pandas for sublimetext?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a site www.domain.com and wanted to get all of the urls from my entire website and how many times they have been clicked on, from the Google Analytics API. \nI am especially interested in some of my external links (the ones that don't have www.mydomain.com). I will then match this against all of the links on my site (I somehow need to get these from somewhere so may scrape my own site).\nI am using Python and wanted to do this programmatically. Does anyone know how to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":346,"Q_Id":51800600,"Users Score":1,"Answer":"I have a site www.domain.com and wanted to get all of the urls from my\n  entire website and how many times they have been clicked on\n\nI guess you need parameter Page and metric Pageviews\n\nI am especially interested in some of my external links\n\nYou can get list of external links if you track they as events. \nTry to use some crawler, for example Screaming Frog. It allows to get internal and external links. Free use up to 500 pages.","Q_Score":0,"Tags":"python,google-analytics,web-crawler,google-analytics-api","A_Id":51801255,"CreationDate":"2018-08-11T14:25:00.000","Title":"Can I get a list of all urls on my site from the Google Analytics API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Does f.seek(500000,0) go through all the first 499999 characters of the file before getting to the 500000th?\nIn other words, is f.seek(n,0) of order O(n) or O(1)?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4765,"Q_Id":51801213,"Users Score":1,"Answer":"It would depend on the implementation of f.  However, in normal file-system files, it is O(1).\nIf python implements f on text files, it could be implemented as O(n), as each character may need to be inspected to manage cr\/lf pairs correctly.\n\nThis would be based on whether f.seek(n,0) gave the same result as a loop of reading chars, and (depending on OS) cr\/lf were shrunk to lf or lf expanded to cr\/lf \n\nIf python implements f on a compressed stream,  then the order would b O(n), as decompression may require some working of blocks, and decompression.","Q_Score":14,"Tags":"python,file,io,big-o,fseek","A_Id":51801243,"CreationDate":"2018-08-11T15:34:00.000","Title":"Complexity of f.seek() 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 wondering if it is possible to use Selenium to write to the Chrome console with python. I do not mean by using send_keys to press F12 and open the console then send more keys to write. If this isn't possible, are they any libraries or APIs that would let me do this? Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":169,"Q_Id":51804531,"Users Score":1,"Answer":"You can look at the problem with another view, try to use browser.execute_script and pass console.log(\"whatever you want to write in the console\") , this will print that sentence in the console \nYou can of course change it to your own needs but you get the idea","Q_Score":1,"Tags":"python,selenium","A_Id":51804569,"CreationDate":"2018-08-11T23:24:00.000","Title":"Using selenium to write to Chrome console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Please excuse the novice question, but is Module just the same as saying model?\nThat's what it sounds like, when the documentation says:\n\nWhenever you want a model more complex than a simple sequence of existing Modules you will need to define your model (as a custom Module subclass).\n\nOr... when they mention Module, are they referring to something more formal and computer-sciency, like a protocol \/ interface type thing?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":11085,"Q_Id":51804692,"Users Score":6,"Answer":"Without being a pytorch expert is my understanding that a module in the context of pytorch is simply a container, which takes receives tensors as input and computes tensors as output.\nSo, in conclusion, your model is quite likely to be composed of multiple modules, for example, you might have 3 modules each representing a layer of a neural network. Thus, they are related in the sense you need modules to actualise your model, but they aren't the same thing.\nHope that helps","Q_Score":27,"Tags":"python,class,pytorch","A_Id":51804987,"CreationDate":"2018-08-12T00:05:00.000","Title":"What exactly is the definition of a 'Module' in PyTorch?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My code is showing a syntax error over offset adjusted list variable.  Why is this happening and how can I go about fixing this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":72,"Q_Id":51805718,"Users Score":1,"Answer":"Error Statement -1: list(int(range(1,27))\nYou have missed one closing bracket ')' in line offset = list(int(range(1,27))\nEven after correction, there is error in code: range will return list of values, while int takes single numeral value, So int should not be use in this case.\nAfter correction:  list(range(1,27))\nString Library\n\nString library does not have attribute ascii, instead use ascii_lowercase\nUse dir(module) to get list of all the functions supported by module\n\nError Statement -2: offset\/\/2\nArithmetic operations can be applied in value of List, not on List as container","Q_Score":0,"Tags":"python,variables,for-loop,while-loop","A_Id":51805868,"CreationDate":"2018-08-12T04:36:00.000","Title":"Why am I getting a syntax error on offset_adjusted_list variable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a wrf output netcdf file.File have variables temp abd prec.Dimensions keys are time, south-north and west-east. So how I select different lat long value in region. The problem is south-north and west-east are not variable. I have to find index value of four lat long value","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":51807792,"Users Score":0,"Answer":"1) Change your Registry files (I think it is Registry.EM_COMMON) so that you print latitude and longitude in your wrfout_d01_time.nc files.\n2) Go to your WRFV3 map.\n3) Clean, configure and recompile.\n4) Run your model again the way you are used to.","Q_Score":0,"Tags":"python,netcdf4","A_Id":51878303,"CreationDate":"2018-08-12T10:05:00.000","Title":"Data extraction from wef output file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python developers\nI am working on spectroscopy in a university. My experimental 1-D data sometimes shows \"cosmic ray\", 3-pixel ultra-high intensity, which is not what I want to analyze. So I want to remove this kind of weird peaks.\nDoes anybody know how to fix this issue in Python 3?\nThanks in advance!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":455,"Q_Id":51812233,"Users Score":0,"Answer":"The answer depends a on what your data looks like: If you have access to two-dimensional CCD readouts that the one-dimensional spectra were created from, then you can use the lacosmic module to get rid of the cosmic rays there. If you have only one-dimensional spectra, but multiple spectra from the same source, then a quick ad-hoc fix is to make a rough normalisation of the spectra and remove those pixels that are several times brighter than the corresponding pixels in the other spectra. If you have only one one-dimensional spectrum from each source, then a less reliable option is to remove all pixels that are much brighter than their neighbours. (Depending on the shape of your cosmics, you may even want to remove the nearest 5 pixels or something, to catch the wings of the cosmic ray peak as well).","Q_Score":0,"Tags":"python-3.x","A_Id":57378910,"CreationDate":"2018-08-12T19:39:00.000","Title":"Cosmic ray removal in spectra","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a PyQt5 application on Ubuntu 18.04, however, when I run my script, audio doesn't work and the console has this error when I import PyQt5.QtMultimedia\ndefaultServiceProvider::requestService(): no service found for - \"org.qt-project.qt.mediaplayer\"\nI've seen other problems similar to this, but their solutions didn't seem to work for me. I'm using PyQt5 5.11.2 installed from pip in a venv.\nSolutions I tried:\n\nsudo apt-get install libqt5multimedia5-plugins\nsudo apt-get install python3-pyqt5 python3-pyqt5.qtmultimedia","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":880,"Q_Id":51812530,"Users Score":0,"Answer":"Try Running your python file globally as the pyqt5 module is installed in the global python not the virtual environment one.","Q_Score":0,"Tags":"python,ubuntu,pyqt","A_Id":70707298,"CreationDate":"2018-08-12T20:22:00.000","Title":"PyQt5: no service found for - \"org.qt-project.qt.mediaplayer\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am self learning Python via the book Introduction to Computation and Programming Using Python\nand I'm stuck on this sentence in the book about range:\n\nIf step is positive, the last element is the largest integer start + i*step less than stop.\n\nI think I understand how range works: range(A, B, z) will start at A and try to \"reach\" B with a step size of z, and it B-1 will be the largest result if the step is 1. But I don't understand the sentence above by Prof. Guttag. \nThe last element will no doubt be the largest integer will  be the largest if the step is positive. But wouldn't the different between the last element and stop be (Stop - (Start + i*step))? \nWhy did he say that it will be start + i*step less than stop.?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":51813118,"Users Score":1,"Answer":"You are understanding it correctly. He doesn't mean that this is the quantity by which it is smaller than stop. He means that \n\nit is the largest integer\nthat has the form start + i*step\nand is  less than (smaller than) stop","Q_Score":0,"Tags":"python,range","A_Id":51813146,"CreationDate":"2018-08-12T21:47:00.000","Title":"How to understand this sentence about range, from the book Introduction to Computation and Programming Using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My small AWS EC2 instance runs a two python scripts, one to receive JSON messages as a web-socket(~2msg\/ms) and write to csv file, and one to compress and upload the csvs. After testing, the data(~2.4gb\/day) recorded by the EC2 instance is sparser than if recorded on my own computer(~5GB). Monitoring shows the EC2 instance consumed all CPU credits and is operating on baseline power. My question is, does the instance drop messages because it cannot write them fast enough?\nThank you to anyone that can provide any insight!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":51814464,"Users Score":1,"Answer":"It depends on the WebSocket server.\nIf your first script cannot run fast enough to match the message generation speed on server side, the TCP receive buffer will become full and the server will slow down on sending packets. Assuming a near-constant message production rate, unprocessed messages will pile up on the server, and the server could be coded to let them accumulate or eventually drop them.\nEven if the server never dropped a message, without enough computational power, your instance would never catch up - on 8\/15 it could be dealing with messages from 8\/10 - so instance upgrade is needed.\nDoes data rate vary greatly throughout the day (e.g. much more messages in evening rush around 20:00)? If so, data loss may have occurred during that period.\nBut is Python really that slow? 5GB\/day is less than 100KB per second, and even a fraction of one modern CPU core can easily handle it. Perhaps you should stress test your scripts and optimize them (reduce small disk writes, etc.)","Q_Score":0,"Tags":"python,amazon-s3,amazon-ec2","A_Id":51814600,"CreationDate":"2018-08-13T02:25:00.000","Title":"(AWS) What happens to a python script without enough CPU?","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 Mkdocs (Python 3.6.5) and edited and built Markdown files.\nI tried to open the main index.html file with a browser, but I cannot directly open HTML pages linked to other HTML files.\nUsing Command Prompt and typing \"mkdocs serve\", I can open linked pages. I know this is a normal function of Mkdocs without server.\nCan I use Mkdocs just on my local computer?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1314,"Q_Id":51816099,"Users Score":0,"Answer":"According to official documentation you can generate html files with mkdocs build. They will be stored in folder called site. You can open built files without having to run mkdocs serve.","Q_Score":4,"Tags":"python,python-3.x,mkdocs","A_Id":52155079,"CreationDate":"2018-08-13T06:09:00.000","Title":"How Can I use Mkdocs on local computer without server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on a model that would predict an exam schedule for a given course and term. My input would be the term and the course name, and the output would be the date. I'm currently done with the data cleaning and preprocessing step, however, I can't wrap my head around a way to make a model whose input is two strings and the output is two numbers (the day and month of exam). One approach that I thought of would be encoding my course names, and writing the term as a binary list. I.E input: encoded(course), [0,0,1] output: day, month. and then feeding to a regression model. \nI hope someone who's more experienced could tell me a better approach.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":51816305,"Users Score":0,"Answer":"Create dummy variables or use RandomForest. They accept text input and numerical output.","Q_Score":0,"Tags":"python,machine-learning,deep-learning,regression","A_Id":51826257,"CreationDate":"2018-08-13T06:27:00.000","Title":"Text Input and Numerical Output issue for Exam Schedule Predictor","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How I can invoke lambda with a delay in python?\n  After execute some line of code in lambda function, I need to sleep the \n  function for 5 sec and then continue.\nHow can i do this in python.\n  I tried the simple way sleep(5), but it doesn't work.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13352,"Q_Id":51817865,"Users Score":0,"Answer":"Double check that your lambda function basic settings does not have a timeout less than 5 seconds.  I think it defaults to 3.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda,sleep","A_Id":58070132,"CreationDate":"2018-08-13T08:10:00.000","Title":"How I can invoke lambda with a delay?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"for some python programming I do for work I'd like to use pyqt4. I also use Anaconda and the Spyder IDE.  \nTo downgrade pyqt from 5 to 4 I created a new environment within Anaconda. The problem is that everytime I install Spyder in this environment the pyqt version is being upgraded to 5 again.\nIs there any way to get around this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":817,"Q_Id":51818723,"Users Score":3,"Answer":"(Spyder maintainer here) You need to create your environment (called spy-pyqt4 in this case) with the following command\nconda create -n spy-pyqt4 spyder=3.2.8 pyqt=4\nSpyder 3.2.8 was our last version to support PyQt4.","Q_Score":2,"Tags":"python,pyqt,anaconda,spyder","A_Id":51832096,"CreationDate":"2018-08-13T09:02:00.000","Title":"How can I use pyqt4 with current python and spyder version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to open a python script with VS code. The library that requires with the script is in a virtualenv.\nI am not sure how to integrate this with VS Code. I could not find my virtualenv in the intepreter. \nFor your information, the virtualenv I created is called \"vc-web\" and the scripts is in the folder called \"web_scraper\" inside the \"vc-web\" folder.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3807,"Q_Id":51819053,"Users Score":1,"Answer":"If your project is in folder e.g. proj, and you have a virtual environment at proj\/vs-web and it's the only virtual environment in that directory, then it should be listed by the Python: Select Interpreter command where you can select it.","Q_Score":1,"Tags":"python,visual-studio-code,virtualenv","A_Id":51830851,"CreationDate":"2018-08-13T09:19:00.000","Title":"Using virtualenv with VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"You are using a Foreign key in Django models automatically _ id is added to the respective field while saving in db.\nIs the same happend to one to one and many to many relations in Django models?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":516,"Q_Id":51821722,"Users Score":0,"Answer":"In short: it happens for OneToOneFields, not for ManyToManyFields.\nA OneToOneField is actually nothing more than a ForeignKey field, but with unique=True, and some small changes (for example the reverse is not model_set, but just model, furthermore the reverse also directly results in a model object, not a queryset, since there is at most one such object). For a OneToOneField, we thus will have an fieldname_id column.\nNote that in the case of a ForeignKey\/OneToOneField, such column only exists where you defined the relation, not at the targeting model. If A has a OneToOneField to B, then you can query b_id, but there does not exists a a_id on the B model.\nFor a ManyToManyField that is not the case. Such relation is not represented in the column of that table, but by a separate table (that links to the two models in the relation).","Q_Score":1,"Tags":"python,django,django-models","A_Id":51821795,"CreationDate":"2018-08-13T11:51:00.000","Title":"One to one relation in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"C:\\Users\\dominic.lopes\\Desktop>pylint Exception.py\n  ************* Module Exception\n  Exception.py:1:0: C0103: Module name \"Exception\" doesn't conform to snake_case naming style (invalid-name)\n  Exception.py:11:4: C0103: Constant name \"x\" doesn't conform to UPPER_CASE naming style (invalid-name)\n  Exception.py:12:4: C0103: Constant name \"y\" doesn't conform to UPPER_CASE naming style (invalid-name)\n  Exception.py:21:44: E0602: Undefined variable 'count' (undefined-variable)\n\n\nYour code has been rated at 3.85\/10 (previous run: 6.92\/10, -3.08)\nThis is the error traceback i get","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1729,"Q_Id":51823322,"Users Score":10,"Answer":"If you are using a more recent version of pylint (that is, >1.7), you will need to pass either -ry or --reports=yes to pylint as in pylint <your file> --reports=yes. The report section is now disabled by default in more recent versions so you have to activate it manually.","Q_Score":3,"Tags":"python,pylint","A_Id":51963160,"CreationDate":"2018-08-13T13:18:00.000","Title":"I have installed pylint. But it doesn't display the statistics by type, raw metrics , duplication ,etc. tables. How do I get pylint display it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"while running the cap.sniff(timeout=20),pyshark in python,\ni got the following errorTraceback (most recent call last):\n  File \"<stdin>\", line 1, in <module>\n  File \"C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\pyshark\\capture\\capture.py\", line 132, in load_packets\n    self.apply_on_packets(keep_packet, timeout=timeout)\n  File \"C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\pyshark\\capture\\capture.py\", line 247, in apply_on_packets\n    return self.eventloop.run_until_complete(coro)\n  File \"C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\asyncio\\base_events.py\", line 468, in run_until_complete\n    return future.result()\n  File \"C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\asyncio\\tasks.py\", line 362, in wait_for\n    raise futures.TimeoutError()\nconcurrent.futures._base.TimeoutError\nwhat is this error about and how can i solve it to run my capturing successfull","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1254,"Q_Id":51824906,"Users Score":0,"Answer":"The error given is a TimeoutError, so that probably means that timeout that you set is too low. If the the task takes longer than the timeout (in seconds), it will cause a TimeoutError. \nTo fix this, you need to set a higher timeout. Try cap.sniff(timeout=50) to see if 50 seconds is long enough. You should try some different timeouts to see how long you need.","Q_Score":3,"Tags":"python,python-3.x,pyshark","A_Id":51825825,"CreationDate":"2018-08-13T14:39:00.000","Title":"error while running cap.sniff(), live packets pyshark","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say that I downloaded PyGame via pip. If I create a virtual environment, will PyGame be downloaded to that virtual environment or must I use os.system(\"pip install PyGame\")?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":51826830,"Users Score":6,"Answer":"It depends how you created the virtualenv.\nIf you've specified --system-site-packages option, the system installed libraries will be available for import.\nIf you didn't specify it, they will not be, which is the default behaviour.","Q_Score":2,"Tags":"python,pip","A_Id":51826886,"CreationDate":"2018-08-13T16:33:00.000","Title":"Are my already installed PIP Packages moved to my virtual environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to convert between strings and datetime objects quite often - up until now i have always used strptime and strftime. \nI started working with the google calendar API where i recieve strings like this: '2018-03-17T09:00:00+01:00\nIt seems like i need to convert the +01:00 into 0100 for strptime which is a little annoying.\nWhile i dont have this issue with dateutil there are a few other inconveniences.Also i saw that the last update of dateutil was in 2016 which seems odd.\nSo my question is which one would you recommend for adding and substracting dates and datetimes and switching between string and datetime obj?\nAlso is dateutil still maintained or is it outdated? \nThanks a lot!\n- Sally","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1640,"Q_Id":51828219,"Users Score":2,"Answer":"dateutil last version (2.7.3) is in may 2018. It just says \"copyright 2016\" somewhere in the credits. Moreover, the documentation talks about policy for future versions, so it seems to be quite active. I would suggest to prefer it over strptime. However, be sure to get the latest version. Previous versions had a bug with converting ISO dates, with which you are working.","Q_Score":2,"Tags":"python,python-dateutil","A_Id":51828344,"CreationDate":"2018-08-13T18:09:00.000","Title":"python strptime vs dateutil - recommended use","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I read the docs trying to get a basic understanding but it only shows that ProcessPoolExecutor allows to side-step the Global Interpreter Lock which I think is the way to lock a variable or function so that parallel processes do not update its value at the same time.\nWhat I am looking for is when to use ProcessPoolExecutor and when to use ThreadPoolExecutor and what should I keep in mind while using each approach!","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":20470,"Q_Id":51828790,"Users Score":30,"Answer":"ProcessPool is for CPU bound tasks so you can benefit from multiple CPU.\nThreads is for io bound tasks so you can benefit from io wait.","Q_Score":46,"Tags":"python,python-3.x,multithreading,parallel-processing,python-3.5","A_Id":51829021,"CreationDate":"2018-08-13T18:50:00.000","Title":"What is the difference between ProcessPoolExecutor and ThreadPoolExecutor?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I read the docs trying to get a basic understanding but it only shows that ProcessPoolExecutor allows to side-step the Global Interpreter Lock which I think is the way to lock a variable or function so that parallel processes do not update its value at the same time.\nWhat I am looking for is when to use ProcessPoolExecutor and when to use ThreadPoolExecutor and what should I keep in mind while using each approach!","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":20470,"Q_Id":51828790,"Users Score":64,"Answer":"ProcessPoolExecutor runs each of your workers in its own separate child process.\nThreadPoolExecutor runs each of your workers in separate threads within the main process.\nThe Global Interpreter Lock (GIL) doesn't just lock a variable or function; it locks the entire interpreter. This means that every builtin operation, including things like listodicts[3]['spam'] = eggs, is automatically thread-safe.\nBut it also means that if your code is CPU-bound (that is, it spends its time doing calculations rather than, e.g., waiting on network responses), and not spending most of its time in an external library designed to release the GIL (like NumPy), only one thread can own the GIL at a time. So, if you've got 4 threads, even if you have 4 or even 16 cores, most of the time, 3 of them will be sitting around waiting for the GIL. So, instead of getting 4x faster, your code gets a bit slower.\nAgain, for I\/O-bound code (e.g., waiting on a bunch of servers to respond to a bunch of HTTP requests you made), threads are just fine; it's only for CPU-bound code that this is an issue.\nEach separate child process has its own separate GIL, so this problem goes away\u2014even if your code is CPU-bound, using 4 child processes can still make it run almost 4x as fast.\nBut child processes don't share any variables. Normally, this is a good thing\u2014you pass (copies of) values in as the arguments to your function, and return (copies of) values back, and the process isolation guarantees that you're doing this safely. But occasionally (usually for performance reasons, but also sometimes because you're passing around objects that can't be copied via pickle), this is not acceptable, so you either need to use threads, or use the more complicated explicit shared data wrappers in the multiprocessing module.","Q_Score":46,"Tags":"python,python-3.x,multithreading,parallel-processing,python-3.5","A_Id":51829082,"CreationDate":"2018-08-13T18:50:00.000","Title":"What is the difference between ProcessPoolExecutor and ThreadPoolExecutor?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I initially started learning Python in Spyder, but decided to switch to PyCharm recently, hence I'm learning PyCharm with a Spyder-like mentality. \nI'm interested in running a file in the Python console, but every time I rerun this file, it will run under a newly opened Python console. This can become annoying after a while, as there will be multiple Python consoles open which basically all do the same thing but with slight variations. \nI would prefer to just have one single Python console and run an entire file within that single console. Would anybody know how to change this? Perhaps the mindset I'm using isn't very PyCharmic?","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":13127,"Q_Id":51831152,"Users Score":0,"Answer":"One console is one instance of Python being run on your system. If you want to run different variations of code within the same Python kernel, you can highlight the code you want to run and then choose the run option (Alt+Shift+F10 default).","Q_Score":15,"Tags":"python,console,pycharm","A_Id":51831201,"CreationDate":"2018-08-13T21:59:00.000","Title":"PyCharm running Python file always opens a new console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I initially started learning Python in Spyder, but decided to switch to PyCharm recently, hence I'm learning PyCharm with a Spyder-like mentality. \nI'm interested in running a file in the Python console, but every time I rerun this file, it will run under a newly opened Python console. This can become annoying after a while, as there will be multiple Python consoles open which basically all do the same thing but with slight variations. \nI would prefer to just have one single Python console and run an entire file within that single console. Would anybody know how to change this? Perhaps the mindset I'm using isn't very PyCharmic?","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":13127,"Q_Id":51831152,"Users Score":1,"Answer":"To allow only one instance to run, go to \"Run\" in the top bar, then \"Edit Configurations...\". Finally, check \"Single instance only\" at the right side. This will run only one instance and restart every time you run.","Q_Score":15,"Tags":"python,console,pycharm","A_Id":51831540,"CreationDate":"2018-08-13T21:59:00.000","Title":"PyCharm running Python file always opens a new console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I initially started learning Python in Spyder, but decided to switch to PyCharm recently, hence I'm learning PyCharm with a Spyder-like mentality. \nI'm interested in running a file in the Python console, but every time I rerun this file, it will run under a newly opened Python console. This can become annoying after a while, as there will be multiple Python consoles open which basically all do the same thing but with slight variations. \nI would prefer to just have one single Python console and run an entire file within that single console. Would anybody know how to change this? Perhaps the mindset I'm using isn't very PyCharmic?","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":13127,"Q_Id":51831152,"Users Score":0,"Answer":"You have an option to Rerun the program.\nSimply open and navigate to currently running app with:\n\nAlt+4 (Windows)\n\u2318+4 (Mac)\n\nAnd then rerun it with:\n\nCtrl+R (Windows)\n\u2318+R (Mac)\n\nAnother option:\nShow actions popup:\n\nCtrl+Shift+A (Windows)\n\u21e7+\u2318+A (Mac)\n\nAnd type Rerun ..., IDE then hint you with desired action, and call it.","Q_Score":15,"Tags":"python,console,pycharm","A_Id":51831272,"CreationDate":"2018-08-13T21:59:00.000","Title":"PyCharm running Python file always opens a new console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that requests.get() provides an HTTP interface so that the programmer can make various requests to a HTTP server.\nThat tells me that somewhere a port must be opened so that the request can happen.\nTaking that into account, what would happen if the script is stopped (say, by a Key Board Interrupt, so the machine that is executing the script remains connected to the internet) before the request is answered\/complete?\nWould the port\/connection remain opened?\nDoes the port\/connection close automatically?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":993,"Q_Id":51831726,"Users Score":1,"Answer":"On a much lower level, when a program exits, the OS kernel closes all file descriptors opened by that program.  These include network sockets.","Q_Score":15,"Tags":"python,http,python-requests,python-requests-html","A_Id":51929463,"CreationDate":"2018-08-13T23:12:00.000","Title":"Python: What happens if script stops while requests.get() is executing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use Crontab to schedule a shell script that runs the main python script. I had tried putting shebang #!\/usr\/local\/bin\/python in the first line of python script but it errorred out with \"cannot importing certain packages\". However, if I call the python script in the shell script by \/usr\/local\/bin\/python  python_script.py, it worked. Any ideas why I can't use the shebang #!\/usr\/local\/bin\/python directly in python instead of the way calling in the shell as mentioned above (it's not elegant)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":269,"Q_Id":51833010,"Users Score":0,"Answer":"This is very likely an issue with your environment variables. Most likely you've got different entries in your PATH or PYTHONPATH variables.\nTo see the difference, you could have your script be a bash script and have it echo the output of env and compare it to your shell's env.","Q_Score":0,"Tags":"python,shell,shebang","A_Id":62348071,"CreationDate":"2018-08-14T02:44:00.000","Title":"Python Shebang Doesn't Work #!\/usr\/local\/bin\/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 have a simple Python code for a machine learning project. I have a relatively big database of spontaneous speech. I started to train my speech model. Since it's a huge database I let it work overnight. In the morning I woke up and saw a mysterious\nKilled: 9\nline in my Terminal. Nothing else. There is no other error message or something to work with. The code run well for about 6 hours which is 75% of the whole process so I really don't understand whats went wrong.\nWhat is Killed:9 and how to fix it? It's very frustrating to lose hours of computing time...\nI'm on macOS Mojave beta if it's matter. Thank you in advance!","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":16683,"Q_Id":51833310,"Users Score":-1,"Answer":"Try to change the node version.\nIn my case, that helps.","Q_Score":12,"Tags":"python,macos,machine-learning,terminal","A_Id":72140478,"CreationDate":"2018-08-14T03:28:00.000","Title":"What is Killed:9 and how to fix in macOS Terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Currently I have a large amount of numbers that I am copy and pasting from excel from a column into python and they paste as such:\n12\n13\n14\n15\n16\n...\nEach number is on a seperate line.\nCurrently I am having to backspace in front of a number so that it jumps to the previous line then I insert commas between each number so that I can use this array in my code. These numbers come in quantities of hundreds and it is easier currently to copy and paste into excel and then into python versus saving an excel file with these numbers and referencing the excel file in my script. I am using visual studio code for my editor and I tried alt+v and that didnt work(read that as a shot). Let me know if there is an easy way to get my copy and pasted column into a useable array. Thanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":597,"Q_Id":51833351,"Users Score":0,"Answer":"If I\u2019m reading what you are trying to do correctly, in VS Code, you can do essentially what @sundance suggested by holding Alt and dragging your cursor down the different lines to get a multiline cursor.","Q_Score":0,"Tags":"python,excel","A_Id":51833595,"CreationDate":"2018-08-14T03:34:00.000","Title":"Pasting numbers into python so that they may be used as an array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Lets say I have a Queue listening to Kafka containing realtime messages.\nI also have a \"worker\" that get the message from the Queue and performs updates on Elasticsearch. When I scale my project by adding more \"worker\" instances, how can I maintain the order of the messages?\nHow can I avoid one \"worker\" instance get the later message from the queue but finish update to Elasticsearch earlier?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":51837861,"Users Score":0,"Answer":"This is the choice you have to make between parallel processing and sequencing.\nyou must have single partition for the topic to maintain the order of data. So you can have a max of 1 task in worker , additional task will be unassigned.","Q_Score":0,"Tags":"python,multithreading,elasticsearch,design-patterns,apache-kafka","A_Id":51914921,"CreationDate":"2018-08-14T09:15:00.000","Title":"How to guarantee message order when multiple instances update elasticsearch?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to change in Python the icon of another running process (NOT the icon of an exe made from python with the likes of cx_freeze) in Windows. Is this possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":115,"Q_Id":51845504,"Users Score":4,"Answer":"It is not possible to modify another running process in that way with Python.","Q_Score":2,"Tags":"python,pywinauto","A_Id":51845625,"CreationDate":"2018-08-14T15:59:00.000","Title":"Change icon of another running process with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently using the following statement:\nREPLACE INTO TableName (Col1, Col2, Col3, Col4) SELECT * FROM AnotherTable WHERE Col2 = 'Something' AND Col3 <> 'word' \nThe issue with this is that TableName contains additional columns (i.e. Col0, Col5, Col6) that are not present in AnotherTable and whose data I do not want wiped.\nI noticed that there is a statement called INSERT INTO ... ON DUPLICATE KEY UPDATE but I am unsure how to merge this with the SELECT * FROM statement that I am using to copy specific data from another table.  How is this done, if possible?\nSupplementary Python2.7 code is possible if necessary.\nServer version: 10.1.23-MariaDB-9+deb9u1 Raspbian 9.0","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":810,"Q_Id":51846102,"Users Score":2,"Answer":"INSERT INTO TableName (Col1, Col2, Col3, Col4) SELECT * FROM AnotherTable WHERE Col2 = 'Something' AND Col3 <> 'word' ON DUPLICATE KEY UPDATE Col1=AnotherTable.Col1, Col2=AnotherTable.Col2, Col3=AnotherTable.Col3, Col4=AnotherTable.Col4\nNotice the ability to use fully qualified references via the format Table.Column as an alternative to a static\/specified value.\nAs danblack reminds, the REPLACE functionality is taken over by the ON DUPLICATE KEY UPDATE that is introduced, which is dependant on UNIQUE indexes or PRIMARY KEYs.","Q_Score":0,"Tags":"python,mysql,python-2.7,mariadb","A_Id":51848118,"CreationDate":"2018-08-14T16:38:00.000","Title":"MySQL 'replace into select from' Alternative","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When launching Visual Studio Code from the Anaconda Navigator page, the python command works correctly in the integrated terminal (Powershell or Bash).\nHowever, when Visual Studio Code is launched normally (from start menu), python.exe is not found in the terminal (not in path). \nIs there a way to always apply Anaconda's config to VS Code, to avoid having to launch it from the Anaconda Navigator page?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":715,"Q_Id":51846390,"Users Score":2,"Answer":"When you installed Anaconda you probably had it leave the copy of Python in your base environment off of PATH. That means when you open your terminal it won't be found normally (this isn't specific to VS Code). One way to deal with this is to create conda environments for your project as those will get activated in the terminal when you use the Python: Create Terminal command. That will then make python available as a command from your terminal.","Q_Score":1,"Tags":"python,visual-studio-code,anaconda,vscode-settings","A_Id":51849474,"CreationDate":"2018-08-14T16:56:00.000","Title":"VS Code: python.exe works in terminal only when opened from Anaconda Navigator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am coding specifically in python, but right now in the phase of designing psuedocode for an algorithm that will take all the data points in a data set that has n values, n being very large and pick out the 10 smallest values (or finite number m << n, where m is the m smallest numbers). I wish to have an optimally efficient algorithm for the requirements. \nMy idea: \n1) Heapsort the data then pick the smallest 10 values. O(nlog(n))\n2) Alternatively,use a loop to identify a 'champion' that runs 10 times. With the first 'champion' determined remove from the dataset and then repeat this loop. O(n) (given m is small)\nWhich suggestion or if there is another would be best?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":250,"Q_Id":51848078,"Users Score":2,"Answer":"One approach among many possible:\nGrab 10 values and sort them. Now compare the largest with the 11th through nth values one at a time. Whenever the new value is smaller replace the 10th smallest with it and resort your 10 values. \nThe list of 10 values, sorting them etc will all be in cache so fast even with rough code. The whole list will be accessed once through so will be fast as well.","Q_Score":1,"Tags":"python-3.x,performance,pseudocode","A_Id":51848259,"CreationDate":"2018-08-14T18:54:00.000","Title":"Find the 10 smallest numbers in a large dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've made a small python script to scrap the web. I would like to make a nice and simple web interface where the user can enter data to search for and have the result displayed as a list. \nI understand that there's many different ways to do that but don't know which one would be the best in my case. \nI would like something :\n\nReally simple and light\nRunning locally with the less dependencies possible. \n\nSo far I've thinking about : \n\nA NodeJS server displaying content and executing the script \nA web framework in Python (web.py, Flask, Django..?)\nA local webserver (XAMPP) and cgi \n\nPlease note that I don't know much about web in python but I'm a bit used to NodeJS.  \nWhat would you recommend ? \nThanks, Victor","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2380,"Q_Id":51848143,"Users Score":0,"Answer":"Socket.io ist Very easy to send Data between Websites and scripts.\nThe Website Connect with the Socket.io Server and Inside the Server the Python Script can be executed","Q_Score":0,"Tags":"python,web,interface","A_Id":51848568,"CreationDate":"2018-08-14T18:57:00.000","Title":"Best way to make a web interface for python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've made a small python script to scrap the web. I would like to make a nice and simple web interface where the user can enter data to search for and have the result displayed as a list. \nI understand that there's many different ways to do that but don't know which one would be the best in my case. \nI would like something :\n\nReally simple and light\nRunning locally with the less dependencies possible. \n\nSo far I've thinking about : \n\nA NodeJS server displaying content and executing the script \nA web framework in Python (web.py, Flask, Django..?)\nA local webserver (XAMPP) and cgi \n\nPlease note that I don't know much about web in python but I'm a bit used to NodeJS.  \nWhat would you recommend ? \nThanks, Victor","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2380,"Q_Id":51848143,"Users Score":1,"Answer":"Personally I prefer gevent, bottle or Flask, and some front end framework like bootstrap or framework7.  \nGevent easily makes it asynchronous and has websockets built right in, and bottle is the easiest (and fastest) way to build a web app or api.","Q_Score":0,"Tags":"python,web,interface","A_Id":51848647,"CreationDate":"2018-08-14T18:57:00.000","Title":"Best way to make a web interface for python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I found a website i want to send POST requests to and then get the HTML code of the following GET request. Is there any way I can find out how these routes are organised? I wanted to do multiple searches by using a form on the site while looping through an array on a website through python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":51848283,"Users Score":0,"Answer":"There is a good chance the website has its API available for you to use? Inside developer tools, look at the Network tab and look for AJAX requests or XMLHttpRequests as a hint; perhaps make use of a requests type-package and go from there.  \nThere is also a very good chance the website follows a Restful architecture to create its routes. Surely there are interesting reads on the very first results-page of Google for this topic; stack overflow answers most likely.\nHowever, if you're question is why would a website not completely exposing its backend then you might not have considered the consequences.","Q_Score":0,"Tags":"html,python-3.x,routing","A_Id":51849147,"CreationDate":"2018-08-14T19:07:00.000","Title":"Learning the Route Structure of a Website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have CSV files that I need to feed to a Deep-Learning network. Currently my CSV files are of size 360*480, but the network restricts them to be of size 224*224. I am using Python and Keras for the deep-learning part. So how can I resize the matrices?\nI was thinking that since aspect ratio is 3:4, so if I resize them to 224:(224*4\/3) = 224:299, and then crop the width of the matrix to 224, it could serve the purpose. But I cannot find a suitable function to do that. Please suggest.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1515,"Q_Id":51848406,"Users Score":1,"Answer":"You could also convert the csv file to a list, truncate the list, and then convert the list to a numpy array and then use np.reshape.","Q_Score":4,"Tags":"python,python-3.x,python-2.7,keras,deep-learning","A_Id":51848498,"CreationDate":"2018-08-14T19:17:00.000","Title":"Resize CSV data using Python and Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"[Python - Beam SDK]\nI would like to be able to test timing issues in integration tests, so I want to build a generator system that pipes in messages into my Beam application with timestamps I specify. My current idea is to an application write to ports (one for each stream I want to listen to), and then have the Beam application listen to these ports (the same way it would listen to a Kafka topic). \nDoes Beam already have the ability to listen to a port as a source? And if not, what would be the best way to make this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":123,"Q_Id":51850595,"Users Score":0,"Answer":"My experience with the [Java SDK]\nIn the way i see it a SocketIIO.read() implementation should just emit String (or byte[]) back. So creating a PTransform that open the port and then on the expand() method create a loop to just read the String (or byte[]) and then emit the values into the pipeline (returning a PColletion).\nHope it gives you an idea.","Q_Score":0,"Tags":"python,apache-beam,apache-beam-io","A_Id":51858983,"CreationDate":"2018-08-14T22:31:00.000","Title":"Apache Beam Input from Ports","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I need to install cv2 for a script that has been written for me. I tried  pip install cv2 and pip install open_cv and got the same problem - a warning message from dist.py and complains about zlib being not found. No cv2 installed. I also tried pyopenvc and pip install opencv-python.\nSo, I went to the opencv site and downloaded the relevant exe. Ran it - generated a heap of subdirectories and a make file and stuff. \nWhat do I do now?","AnswerCount":24,"Available Count":4,"Score":0.0166651236,"is_accepted":false,"ViewCount":506854,"Q_Id":51853018,"Users Score":2,"Answer":"Open terminal\nRun the following command\npip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org opencv-python.\nHope it will work.","Q_Score":178,"Tags":"python,opencv","A_Id":57182351,"CreationDate":"2018-08-15T04:34:00.000","Title":"How do I install opencv using pip?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to install cv2 for a script that has been written for me. I tried  pip install cv2 and pip install open_cv and got the same problem - a warning message from dist.py and complains about zlib being not found. No cv2 installed. I also tried pyopenvc and pip install opencv-python.\nSo, I went to the opencv site and downloaded the relevant exe. Ran it - generated a heap of subdirectories and a make file and stuff. \nWhat do I do now?","AnswerCount":24,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":506854,"Q_Id":51853018,"Users Score":3,"Answer":"Open anaconda command prompt and type in below command.\nconda install -c conda-forge opencv\n\nOnce the 'Solving environment' is done. It will ask to download dependencies. Type 'y'.\n\nIt will install all the dependencies and then you are ready to code.","Q_Score":178,"Tags":"python,opencv","A_Id":54848727,"CreationDate":"2018-08-15T04:34:00.000","Title":"How do I install opencv using pip?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to install cv2 for a script that has been written for me. I tried  pip install cv2 and pip install open_cv and got the same problem - a warning message from dist.py and complains about zlib being not found. No cv2 installed. I also tried pyopenvc and pip install opencv-python.\nSo, I went to the opencv site and downloaded the relevant exe. Ran it - generated a heap of subdirectories and a make file and stuff. \nWhat do I do now?","AnswerCount":24,"Available Count":4,"Score":0.0166651236,"is_accepted":false,"ViewCount":506854,"Q_Id":51853018,"Users Score":2,"Answer":"->pip install opencv-python you can use this.\nBut if this code does not working then you can check python version on cmd and anaconda because they are different. So you type command in anaconda prompt and cmd, it will work. You can check this -> pip list","Q_Score":178,"Tags":"python,opencv","A_Id":71060884,"CreationDate":"2018-08-15T04:34:00.000","Title":"How do I install opencv using pip?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to install cv2 for a script that has been written for me. I tried  pip install cv2 and pip install open_cv and got the same problem - a warning message from dist.py and complains about zlib being not found. No cv2 installed. I also tried pyopenvc and pip install opencv-python.\nSo, I went to the opencv site and downloaded the relevant exe. Ran it - generated a heap of subdirectories and a make file and stuff. \nWhat do I do now?","AnswerCount":24,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":506854,"Q_Id":51853018,"Users Score":0,"Answer":"if you are using Pycharm navigate settings > Project:name > Project interpreter just search the module by name(in this case OpenCV-python) and install it. worked for me","Q_Score":178,"Tags":"python,opencv","A_Id":60336465,"CreationDate":"2018-08-15T04:34:00.000","Title":"How do I install opencv using pip?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Django, if you don't specify primary key, it will add an integer autofield. My question is that if this incremental id, reaches integer limit, what is expected to happen after?","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":155,"Q_Id":51853072,"Users Score":-1,"Answer":"in postgresql maximum amount of ID fields is 9223372036854775807\nif your database have these amount of record its not work. assume a simple query with ordering take more than a year to execute\nor if each record take 100 Byte (with index and ... data its too few for each record) this amount of record takes 838860700 TB storage. there is no storage to store these amount of data in all over the world.","Q_Score":0,"Tags":"python,django,python-3.x,postgresql,django-models","A_Id":51853178,"CreationDate":"2018-08-15T04:42:00.000","Title":"What if django model incremental pk finished","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In Django, if you don't specify primary key, it will add an integer autofield. My question is that if this incremental id, reaches integer limit, what is expected to happen after?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":51853072,"Users Score":0,"Answer":"The database will raise an error and inserting whatever you're inserting will fail.\nIf you are using MySQL, the error will probably be something like this : ERROR 1467 (HY000): Failed to read auto-increment value from storage engine. \nThe limit for django's auto increment id is  2,147,483,647. So it's pretty unlikely that you will hit this limit unless you're storing extremely large amounts of data. If you are using large amounts of data, you can use the bigint type for the field instead.","Q_Score":0,"Tags":"python,django,python-3.x,postgresql,django-models","A_Id":51853180,"CreationDate":"2018-08-15T04:42:00.000","Title":"What if django model incremental pk finished","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The size of my pandas dataframe is 6844 and is named all_data_frame.\nWhen I type print(str(all_ssis_data.tail)) I get rows in the index range of 0-29 and 3633-3662.\nWhy doesn't it show me rows around the 6800 range?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1158,"Q_Id":51853350,"Users Score":0,"Answer":"tail is a method of dataframe. You can do this:\nprint(str(all_ssis_data.tail()))\nif you want to get page around 6800\nyou can add 50 as parameter\n.tail(50) will show the last 50 rows","Q_Score":1,"Tags":"python,pandas","A_Id":51853382,"CreationDate":"2018-08-15T05:21:00.000","Title":"Pandas Dataframe Tail Not Working","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Please tell me what wrong on kivy platform cannot be gotten expected behavior on macOS.\nFor example:\n1.UI acts different UI from (Mouse) pointer have indicated.\nFor example, three buttons was layouted on Boxlayout in a widget. the kivy widget launched action as other button was pushed, which button was different from right clicked by mouse. I felt that kivy repeat action in pushed:\n\n1st:  when I pushed 1st button, launched action was as pushed 1st button.\n2nd: when I pushed 2nd button, launched action was as pushed 1st button was pushed. However I expected 2nd button act.\n3rd: when I pushed 2nd button, launched action was as pushed 2nd button was pushed. The action was I expected.\n\n2. I could not input to TextInput UI.\nIf I input character into UI of \"TextInput\" of my kivy application, the character was inputted into editor window of IDE which launched my kivy application\n3. Application icon did not appear.\nUsually, if python code launched, 'python launcher' icon appeared in dock bar of MacOS. However, if kivy code launched, neither 'python launcher' icon nor kivy icon appeared. The has problem if a kivy code was launched from IDE, the kivy windows hid behind IDE window.\nMy Environment:\n\nOS: macos 10.13.6\nHW: MacBookPro2016\nPython: miniconda + kivy was installed by command \"conda install kivy -c conda-forge\"\nOther: SDL, gstreamer etc. were installed and managed by homebrew.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":51855310,"Users Score":0,"Answer":"This problem was solved to have installed kivy from anaconda.","Q_Score":0,"Tags":"python,kivy","A_Id":54009364,"CreationDate":"2018-08-15T08:26:00.000","Title":"What wrong that kivy platform cannot be gotten expected behavior on macOS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When debugging a code in Pycharm is there a way to save current state before proceeding forward? That way I do not have to re-process everything that was already debugged if there is a bug downstream. \nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1223,"Q_Id":51859529,"Users Score":0,"Answer":"Based on your comment to the \"correct\" answer, it sound like what you really want is the interactiveness, which you can easily have in PyCharm in multiple ways.\nThrough debugger:\nOne way is to set a break point, and then start executing code in the console from this state. You can execute a large selection of code or just one line at the time.\nWithout debugger:\nAnother option is to just use the Python console to execute code interactively. Also here you can execute a large selection of code or one line at a time.","Q_Score":4,"Tags":"python,debugging,pycharm","A_Id":64926736,"CreationDate":"2018-08-15T13:20:00.000","Title":"Pycharm: Is there a way to save a break point state and debug going forward?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been playing around the tensorflow object detection API for instance segmentation. In the pipeline configuration file, as a part of the train_config we specify the num_steps value. So it is the total number of steps that network is trained on. \nSo let us say, I have 10,000 images in training dataset and batch_size is set to 1. In this case, does the data gets shuffled after every 10000 steps? Does it make sure automatically, that entire dataset is seen by the network before shuffling occurs?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":544,"Q_Id":51860849,"Users Score":1,"Answer":"The framework does not actually shuffle your data, it's memory intensive and time consuming.\nInstead, there's an array with random indices that are used to access your data. Usually, indices cover the whole dataset, so, you're right, all data is seen by your network, however in random order.","Q_Score":1,"Tags":"python,tensorflow,object-detection-api","A_Id":51861092,"CreationDate":"2018-08-15T14:38:00.000","Title":"How does shuffling work while training in tensorflow object detection API","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to run a Flask application as a Windows service. I managed to convert it to a Windows service using win32serviceutil. The problem I have is that it only works when I manually run PythonService.exe (with the -debug flag) from the \"activated\" environment (of course).\nIs there a way to activate the environment before attempting to run the service?\nI see some people used the Task Scheduler as a workaround but I'd prefer if Windows service manager could be used instead.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":782,"Q_Id":51861488,"Users Score":1,"Answer":"I figured it out. The trick is to use pyinstaller to generate an EXE. This way all libraries will be included, and there will be no need to mess with the system environment variables.","Q_Score":2,"Tags":"python,windows,windows-services,anaconda","A_Id":51863823,"CreationDate":"2018-08-15T15:12:00.000","Title":"Windows service running in a Anaconda environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I want to run Python script using \"Python launcher\" so that I can use shebang line to specify the Python environment for each individual script.\nI installed Python 3.6 from Anaconda.\nHowever, when I type \"py\" in conda prompt or windows CMD, it says 'py' is not recognized as an internal or external command.\nWhat should I do in order to use \"py\" command to launch Python script?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7324,"Q_Id":51861943,"Users Score":0,"Answer":"Unless you are using cygwin, windows has no shebang support. However, when you install Python, it should associate .py files with Python on the command line. Try running the script by just using the script name from your command line, or double-clicking the script in explorer. If this file-type association does not exist, you should also be able to run your script using conda script.py.","Q_Score":1,"Tags":"python,launcher,shebang","A_Id":51862049,"CreationDate":"2018-08-15T15:39:00.000","Title":"How to install python launcher","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"On my chromebook,I have installed Anaconda however when I enter anaconda-navigator into crosh I get this error message: \"ImportError: libGL.so.1: cannot open shared object file: No such file or directory\". I'm not sure why this happens, please can someone help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":592,"Q_Id":51862441,"Users Score":1,"Answer":"It looks like Anaconda needs a critical GL library file, in which case the whole directory seems to be missing according to the error message. \nI believe it needs this library to render the page. I've seen the article this comes from and it asks you to allow the application to be installed in a directory called \"\/usr\/local\/conda3\". I'm wondering if recent updates in Chrome OS may have separated the shared GL directory from the installation in this case or if there have been fundamental changes in the package in which it's requesting the import.\nSince these changes can come along at any time and without warning, it might be best to create a crouton instance and install Ubuntu or some other crouton-compatible Linux distro on your Chromebook. Really this takes up quite a bit of space so I'd recommend having at least a 32GB SSD or EMMc drive on your system.","Q_Score":1,"Tags":"python-3.x,anaconda,chromebook","A_Id":52782158,"CreationDate":"2018-08-15T16:12:00.000","Title":"Can't open anaconda-navigator on chromebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am fairly proficient in Python and have started exploring the requests library to formulate simple HTTP requests. I have also taken a look at Sessions objects that allow me to login to a website and -using the session key- continue to interact with the website through my account.\nHere comes my problem: I am trying to build a simple API in Python to perform certain actions that I would be able to do via the website. However, I do not know how certain HTTP requests need to look like in order to implement them via the requests library.\nIn general, when I know how to perform a task via the website, how can I identify:\n\nthe type of HTTP request (GET or POST will suffice in my case)\nthe URL, i.e where the resource is located on the server\nthe body parameters that I need to specify for the request to be successful","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":119,"Q_Id":51863463,"Users Score":0,"Answer":"This has nothing to do with python, but you can use a network proxy to examine your requests.\n\nDownload a network proxy like Burpsuite\nSetup your browser to route all traffic through Burpsuite (default is localhost:8080)\nDeactivate packet interception (in the Proxy tab)\nBrowse to your target website normally\nExamine the request history in Burpsuite. You will find every information you need","Q_Score":0,"Tags":"python,api,http,python-requests","A_Id":51863598,"CreationDate":"2018-08-15T17:19:00.000","Title":"Identifying parameters in HTTP request","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"On 2 distinct independent systems, I have Anaconda\/Miniconda. On my default virtual environment on either one, since 2018-8-15, when I import pandas or matplotlib, I get errors module 'numpy' has no attribute '__version__' and module 'numpy' has no attribute 'square', respectively.\nAn update to conda or one of the modules may have done damage, but I haven't been able to figure out. The computers, one is a Mac and one a Windows PC. The only common features are that I use the Jupyter Notebook environment on both systems, both are default environments, both may have deep learning packages installed on them (as opposed to the other environments which are still functioning well), and I've been using the Jupyter Notebook environment to code on both.\nHas anyone come across this problem? Is there a solution? Is it waiting for a fix update?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":244,"Q_Id":51864008,"Users Score":0,"Answer":"I had this issue and I think it is related to a broken install. I fixed mine with conda update --all. But I guess you can fix it with uninstalling numpy and reinstalling it back.","Q_Score":1,"Tags":"python,numpy,anaconda,jupyter,miniconda","A_Id":52075651,"CreationDate":"2018-08-15T17:58:00.000","Title":"Numpy no module\/attribute when importing other packages depending on it","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using netwrokx to calculate the shortest path between different vertices using Dijkstra algorithm. I have a case where I want to connect three different vertices (for example A, B and C in an undirected graph). First I find the shortest path from A to B and then I want to find the shortest path from the path of A to B. What I have tried so far is I have calculate shortest path length from all the nodes of the A to B path to C and then I calculate the shortest path from the node which gives the minimum path length. This is computationally intensive as path may have up to 200 to 300 nodes.\nCan anyone give me a hint how can I improve approach? or easier way to find the shortest path from the already existing edges to the target ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":191,"Q_Id":51864195,"Users Score":0,"Answer":"Find the shortest path X = A to B.\nFind the shortest path Y = A to C.\nFind the shortest path Z = B to C.\ncombine the paths.\n\nshortest_path(G, source, target) imported from networkx will return the shortest path between two vertices.\nIf this method is done by implementing Dijkstra's algorithm, the efficiency is equivalent to Dijkstra's algorithm asymptotically.","Q_Score":2,"Tags":"python-3.x,networkx","A_Id":51881211,"CreationDate":"2018-08-15T18:12:00.000","Title":"networkx shortest path from a path to vertex","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using netwrokx to calculate the shortest path between different vertices using Dijkstra algorithm. I have a case where I want to connect three different vertices (for example A, B and C in an undirected graph). First I find the shortest path from A to B and then I want to find the shortest path from the path of A to B. What I have tried so far is I have calculate shortest path length from all the nodes of the A to B path to C and then I calculate the shortest path from the node which gives the minimum path length. This is computationally intensive as path may have up to 200 to 300 nodes.\nCan anyone give me a hint how can I improve approach? or easier way to find the shortest path from the already existing edges to the target ?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":191,"Q_Id":51864195,"Users Score":1,"Answer":"Add a new node, 'auxiliary' to your graph.  For each node u in the A-B path, add an edge from u to 'auxiliary'.\nFind the shortest path from C to 'auxiliary'.  Truncate that path by removing the final node 'auxiliary'.  This is now the shortest path from C to that path.\nMore generally, this approach works whenever you want to find the shortest path from a node to a set of nodes and (with a bit of generalization) it finds the shortest path from one set of nodes to another set.","Q_Score":2,"Tags":"python-3.x,networkx","A_Id":51864929,"CreationDate":"2018-08-15T18:12:00.000","Title":"networkx shortest path from a path to vertex","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running python 3.4.2 under Windows 7. I have some modules that I do NOT want to put (at least yet) into the python subdirectories. After much angst, I've gotten them to run, but only at the expense of adding PYTHONHOME and PYTHONPATH to my System variables.  \nI tried creating a batch file, set these and then executed my script. I tried setx, but this just puts the variables in my User variables where python does not appear to recognize them.  \nI find it hard to believe that I can't distribute some of these scripts to my co-workers without forcing them to change their System variables. \nAm I doing something wrong?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":51865304,"Users Score":0,"Answer":"As has been pointed out elsewhere setting pythonpath and pythonhome were probably not the best of ideas, especially in my newbie case because they ended up interferring with gcloud. I ended up adjusting my scripts so they sys.path.append(\"ZXYLIB\") where XYXLIB is a path I set the the batch file calls the python, and that works.","Q_Score":0,"Tags":"python,batch-file","A_Id":51884756,"CreationDate":"2018-08-15T19:38:00.000","Title":"ImportError: No module name xxx - How not to permanently set System variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a single gunicorn worker process running to read an enormous excel file which takes up to 5 minutes and uses 4GB of RAM. But after the request was finished processing I noticed at system monitor that it stills allocating 4GB of RAM forever. Any ideas on what to do to release the memory?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":3631,"Q_Id":51866904,"Users Score":-1,"Answer":"--max-requests 1 worked for me for a similar case.","Q_Score":6,"Tags":"python,gunicorn","A_Id":63113091,"CreationDate":"2018-08-15T21:47:00.000","Title":"Gunicorn worker doesn't deflate memory after request","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have Python 3.7 and Python 3.6. How to I chose to which version of Python I want my PIP packages?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3542,"Q_Id":51866914,"Users Score":2,"Answer":"You use the version of pip that corresponds to the desired Python version.  The most universally effective way is to run pythonX.Y -m pip install ..., where X.Y is replaced with the Python version number, though running just pipX.Y install ... may also work under some circumstances.","Q_Score":2,"Tags":"python,pip","A_Id":51866942,"CreationDate":"2018-08-15T21:48:00.000","Title":"How to install pip packages to specific Python version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python 3.7 and Python 3.6. How to I chose to which version of Python I want my PIP packages?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3542,"Q_Id":51866914,"Users Score":1,"Answer":"use python -m pip where python is the version of python you want to install to","Q_Score":2,"Tags":"python,pip","A_Id":51866940,"CreationDate":"2018-08-15T21:48:00.000","Title":"How to install pip packages to specific Python version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python 3.7 installed, and want to make an .exe out of it, so I'm trying to make a 3.6.5 file so pyinstaller will work on it. How can I make it so the version of python the file uses is 3.6.5 and not 3.7(my default). When I type python in cmd it goes in 3.7. When I type python --version, it says 3.7. Keep in mind, I typed all of this in the directory of where 3.6.5 is. 3.7 is installed on my C though, while 3.6.5 is installed in my programs\/local\/python directory. What should I do?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":829,"Q_Id":51868433,"Users Score":0,"Answer":"You can run your desired Python executable directly from \/path\/to\/Python\/bin\/python.exe .","Q_Score":0,"Tags":"python,exe,python-3.6,pyinstaller,python-3.7","A_Id":51868492,"CreationDate":"2018-08-16T01:25:00.000","Title":"How to make a python file using a previous version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I read the data from oracle database to panda dataframe, then, there are some columns with type 'object', then I write the dataframe to hive table, these 'object' types are converted to 'binary' type, does any one know how to solve the problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":51869125,"Users Score":0,"Answer":"When you read data from oracle to dataframe it's created columns with object datatypes.\nYou can ask pandas dataframe try to infer better datatypes (before saving to Hive) if it can:\ndataframe.infer_objects()","Q_Score":0,"Tags":"python-2.7,hive","A_Id":51877123,"CreationDate":"2018-08-16T03:16:00.000","Title":"Why there is binary type after writing to hive table","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can you tell me what is the use of jupyter cluster. I created jupyter cluster,and established its connection.But still I'm confused,how to use this cluster effectively?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9087,"Q_Id":51869574,"Users Score":4,"Answer":"With Jupyter Notebook cluster, you can run notebook on the local machine and connect to the notebook on the cluster by setting the appropriate port number. Example code:\n\nGo to Server using ssh username@ip_address to server.\nSet up the port number for running notebook. On remote terminal run  jupyter notebook --no-browser --port=7800\nOn your local terminal run ssh -N -f -L localhost:8001:localhost:7800 username@ip_address of server. \nOpen web browser on local machine and go to http:\/\/localhost:8001\/","Q_Score":3,"Tags":"python,python-3.x,jupyter-notebook,cluster-computing,jupyter","A_Id":51869653,"CreationDate":"2018-08-16T04:22:00.000","Title":"What is the use of Jupyter Notebook cluster","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created codes (a.py) about editing the csv file, just using some for loop and while loop, pandas loc function, etc.\nbut this codes should load a csv file in order to run.\nwhen i  attempt to use pyintaller to pack this a.py to exe, \nit says:\n\nfor field, value in iter_fields(node):\n  RecursionError: maximum recursion depth exceeded.\n\nI am in Windows 10, python:3.6  pyinstaller:3.4.dev0+7817d3fac\nto use anaconda prompt and input: pyinstaller 'path'\/a.py -F .\nis it because of the csv file is not referenced?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1187,"Q_Id":51869811,"Users Score":0,"Answer":"I have successfully complete the process by installing PyQt5 which I conda list it found it existed 'pyqt', but acutally pyQt5 is not installed yet. So I pip install pyqt5 and succeed.","Q_Score":0,"Tags":"python-3.x,pandas,pyinstaller","A_Id":51906291,"CreationDate":"2018-08-16T04:51:00.000","Title":"how to solve RecursionError with pyintaller?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Lambda function that takes a list of tasks to be run at the time specified. This time can vary. \nI am using SNS to trigger another Lambda function that in turn runs the tasks.\nThese tasks need to be run at specified time. Is it possible to publish a message to SNS using Lambda at the specified time? \nOr send the message to SNS, but SNS in turn triggers Lambda at the specified time?\nAny option would do.\nP.S. I know there is an option of using Cloud Watch events, but I do not want to use any more services.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":51872050,"Users Score":0,"Answer":"It appears that your requirement is to trigger an AWS Lambda function at specific times.\nThis can be done by using Amazon CloudWatch Events, which can take a cron-like expression to run a Lambda function at desired time intervals or specific times. This functionality was originally in the Lambda console, but was moved to CloudWatch Events when more services added scheduling capabilities.\nHowever, CloudWatch Events cannot trigger an Amazon SNS message. If you need SNS to trigger Lambda, then you'll need CloudWatch Events to trigger a Lambda function that sends a message to SNS (which then triggers Lambda functions). Obviously, it would be cleaner to avoid SNS altogether unless you specifically need to fan-out the message to multiple subscriptions\/Lambda functions.","Q_Score":0,"Tags":"python-2.7,aws-lambda,amazon-sns","A_Id":51895628,"CreationDate":"2018-08-16T07:46:00.000","Title":"Trigger SNS at specified 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":"Suppose I have created 10 different virtual environment for 10 different projects and 5 of them have same dependencies. So does this implies having the same library copy for 5 times or having the path to a globally installed package?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":51874660,"Users Score":1,"Answer":"Except the python and its default packages virtual environments does not share any other packages with each other. When you install a package It will first check for it in cache if found then install form there if not found then download to cache and install from there.","Q_Score":1,"Tags":"python,virtualenv","A_Id":51874773,"CreationDate":"2018-08-16T10:15:00.000","Title":"If I have 10 virtual environment in python, will that download the same libraries 10 times?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to work with Kafka for data ingestion but being new to this, i am kind of pretty much confused.I have multiple  crawlers, who extract data for me from web platform. Now, the issue is i want to ingest that extract data to Hadoop using Kafka without any middle scripts\/service file . Is it possible ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1991,"Q_Id":51876515,"Users Score":2,"Answer":"without any middle scripts\/service file . Is it possible ?\n\nUnfortunately, no. \nYou need some service that's writing into Kafka (your scraper). Whether you produce into Kafka HTTP links (then write an intermediate consumer\/producer that generates the scraped results), or only produce the final scraped results, that's up to you. \nYou also need a second service consuming those topic(s) that writes to HDFS. This could be Kafka Connect (via Confluent's HDFS Connector library), or PySpark (code you'd have to write yourself), or other options that include \"middle scripts\/services\".\nIf you'd like to combine both options, I would suggest taking a look at Apache Nifi or Streamsets, which can perform HTTP lookups, (X)HTML parsing, and Kafka+HDFS connectors, all configured via a centralized GUI. Note: I believe any Python code would have to be rewritten in a JVM language to support major custom parsing logic in this pipeline","Q_Score":1,"Tags":"python,apache-kafka,web-crawler,kafka-producer-api","A_Id":51887428,"CreationDate":"2018-08-16T11:57:00.000","Title":"Data ingestion using kafka from crawlers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a series of points in two 3D systems. With them, I use np.linalg.lstsq to calculate the affine transformation matrix (4x4) between both. However, due to my project, I have to \"disable\" the shear in the transform. Is there a way to decompose the matrix into the base transformations? I have found out how to do so for Translation and Scaling but I don't know how to separate Rotation and Shear. \nIf not, is there a way to calculate a transformation matrix from the points that doesn't include shear?\nI can only use numpy or tensorflow to solve this problem btw.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1921,"Q_Id":51876622,"Users Score":1,"Answer":"I'm not sure I understand what you're asking.\nAnyway If you have two sets of 3D points P and Q, you can use Kabsch algorithm to find out a rotation matrix R and a translation vector T such that the sum of square distances between (RP+T) and Q is minimized.\nYou can of course combine R and T into a 4x4 matrix (of rotation and translation only. without shear or scale).","Q_Score":1,"Tags":"python-3.x,numpy,transformation,affinetransform,matrix-decomposition","A_Id":51876979,"CreationDate":"2018-08-16T12:03:00.000","Title":"How to decompose affine matrix?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was running a cell in a Jupyter Notebook for a while and decided to interrupt. However, it still continues to run and I don't know how to proceed to have the thing interrupted...\nThanks for help","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6847,"Q_Id":51877700,"Users Score":3,"Answer":"Sometimes this happens, when you are on a GPU accelerated machine, where the Kernel is waiting for some GPU operation to be finished. I noticed this even on AWS instances.\nThe best thing you can do is just to wait. In the most cases it will recover and finish at some point. If it does not, at least it will tell you the kernel died after some minutes and you don\u00b4t have to copy paste your notebook, to back up your work. In rare cases, you have to kill your python process manually.","Q_Score":3,"Tags":"python,jupyter-notebook","A_Id":51897922,"CreationDate":"2018-08-16T13:00:00.000","Title":"Jupyter notebook kernel does not want to interrupt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on the Movielens dataset and I wanted to apply K-Means algorithm on it. I would like to know what columns to choose for this purpose and How can I proceed further Or Should I directly use the KNN algorithm.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":927,"Q_Id":51877919,"Users Score":0,"Answer":"Well, K-Means is a clustering Algorithm so you can use it to cluster the movies based on the genres.\nColumns: movieId, genres\nThere's a new dataset which includes relevant tags for each movie, so you can also cluster them based on those tags.\nHowever, you can also make use of K-Nearest Neighbors to find out how users are similar to each other.\nIn the reviews dataset, you would use the following columns:\nColumns: userId, rating\nWhile in the movies dataset you would use the movieId.\nThe idea is to figure out which movies every user has viewed, then use those movies to compute the similarity index of users (eg; user1, user2)","Q_Score":1,"Tags":"python,k-means,data-science,scikit-image","A_Id":56354392,"CreationDate":"2018-08-16T13:11:00.000","Title":"KMeans Clustering on Movielens Dataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I updated windows to the latest version yesteday, when pygame was working fine. After this update, pygame is very laggy compared to before, despite not adding any code to my project. I've tried restarting my computer, deleting and redownloading pygame, but it still doesn't work. Has anyone got any ideas? Python in general still is as fast as usual","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":92,"Q_Id":51878957,"Users Score":3,"Answer":"I would go to windows update history and remove the updates then try the game again this way you will know for sure if the windows update affected the game performance.","Q_Score":1,"Tags":"python,pygame","A_Id":51879156,"CreationDate":"2018-08-16T14:03:00.000","Title":"Pygame is slow after windows update","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I read a list of float values of varying precision from a csv file into a Pandas Series and need the number of digits after the decimal point. So, for 123.4567 I want to get 4.\nI managed to get the number of digits for randomly generated numbers like this:\n\ndf = pd.Series(np.random.rand(100)*1000)\nprecision_digits = (df - df.astype(int)).astype(str).str.split(\".\", expand=True)[1].str.len().max()\n\nHowever, if I read data from disk using pd.read_csv where some of the rows are empty (and thus filled with nan), I get the following error:\n\nTraceback (most recent call last):\n  File \"<input>\", line 1, in <module>\n  File \"\/home\/tgamauf\/workspace\/mostly-sydan\/venv\/lib\/python3.6\/site-packages\/pandas\/core\/generic.py\", line 4376, in __getattr__\n    return object.__getattribute__(self, name)\nAttributeError: 'DataFrame' object has no attribute 'str'\n\nWhat is going wrong here?\nIs there a better way to do what I need?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1611,"Q_Id":51879063,"Users Score":1,"Answer":"pd.read_csv() typically returns a DataFrame object.  The StringMethods object returned by using .str is only defined for a Series object.  Try using pd.read_csv('your_data.csv' , squeeze=True) to have it return a Series object; then you will be able to use .str","Q_Score":1,"Tags":"python,pandas,dataframe","A_Id":51882505,"CreationDate":"2018-08-16T14:08:00.000","Title":"How to get the maximum number of digits after the decimal point in a Pandas series","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can you download OpenCV with Python 3.5.2? I want to set up OpenCV. But I don't know if I need 2.7 or can I use my already downloaded Python 3.5.2 version. Will it be compatible? I want learn computer vision so I can make some projects. Like a automated waste sorter. But I need to download OpenCV first. Just need some guidance. It's not like it's a straight download but a process. So if anyone can tell be if my version (on windows 10) Python 3.5.2 will work with the current OpenCV that would be great. Thanks","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":482,"Q_Id":51881545,"Users Score":2,"Answer":"yes, OpenCV 3 works with Python 2.7, 3.4, 3.5, 3.6 and 3.7","Q_Score":0,"Tags":"python,opencv,python-3.5","A_Id":51881699,"CreationDate":"2018-08-16T16:24:00.000","Title":"Can you download OpenCV with Python 3.5.2?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to get images from a search engine, to run some automated tests without the need to go online and pick them by hand.\nI found an old example from 5 years ago (ajax.googleapis.com\/ajax\/services\/search\/images), which sadly does not work anymore. What is the current method to do so in Python3? Ideally I would like to be able to pass a string with the search name, and retrieve a set amount of images, at full size.\nI don't really mind which search engine is used; I just want to be sure that it is supported for the time being. Also I would like to avoid Selenium; I am planning to run this without any UI nor using the browser, all from terminal.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":51882099,"Users Score":0,"Answer":"Found a pretty good solution using BeautifulSoup.\nIt does not work on Google, since I get 403, but when faking the header in the request, is possible to get sometimes, data. I will have to experiment with different other sites.\nSo far the workflow is to search in the browser so I can get the url to pass to beautifulsoup. Once I get the url in code, I replaced the query part with a variable, so I can pass it programmatically.\nThen I parse the output of beautifulsoup to extract the links to the images, and retrieve them using requests.\nI wish there was a public API to get also parameters like picture size and such, but I found nothing that works currently.","Q_Score":1,"Tags":"python-3.x","A_Id":51900744,"CreationDate":"2018-08-16T17:04:00.000","Title":"Python - make a search and retrieve a set amount of images from a search engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When running the commands in idle I can get an API call to work using oauth2. Then when trying to use the same lines of code in web2py I was getting an error that the web2py module wasn't found. So I installed Oauth2 into the module folder of the web2py project files. \nThis changed the error from the oauth2 module not found to \n (ImportError('No module named version',), )\nAny ideas to find a fix would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":51885506,"Users Score":0,"Answer":"As an update I figured out that the issue was because Web2py doesn't support python 3 at this point in time.","Q_Score":0,"Tags":"python,oauth-2.0,web2py","A_Id":51901525,"CreationDate":"2018-08-16T21:22:00.000","Title":"Web2py error:  (ImportError('No module named version',), )","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I assume the pose estimate from aruco markers is only valid when they are affixed to a flat surface.  What about attaching them to a slightly curved surface?  Is there any way to correct for the surface curvature in the resulting pose?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":829,"Q_Id":51885997,"Users Score":2,"Answer":"Yes, you should be able to get the pose estimate for a curved surface using an Aruco board, though it may be physically difficult to construct and measure. Aruco boards do not need to be planar; they can describe any arrangement of markers in 3D space. So the following steps should work:\n\nattach markers to your curved surface (which may be a challenge if the surface is not developable).\ncalculate, or directly measure, the 3D positions of the physical markers' corners in your preferred Cartesian coordinate system.\ndefine an Aruco board using the markers' 3D corner positions and IDs.\ntune the Aruco detection parameters (at least adaptive threshold and polygonal approximation) to give robust marker detection in the presence of curvature in the marker edges and localised lighting variations due to the curved surface.\nonce marker detection is reliable, use estimatePoseBoard() to get the pose estimate of the board, and hence the curved surface, in the same Cartesian coordinate system. estimatePoseBoard() finds a best-fit solution for the pose while considering all visible markers simultaneously.\n\nNote: I haven't actually tried this.","Q_Score":0,"Tags":"python,opencv,aruco","A_Id":51888163,"CreationDate":"2018-08-16T22:13:00.000","Title":"Aruco marker pose estimation on curved surface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently came to know about Modelcheckpoint Callback in Keras. But it can only monitor Validation Accuracy or Training Acc. It can save best model weights when validation accuracy is maximum. But the model may be overfitted to validation data. Thus, I feel a need to monitor training accuracy as well. I want to save that model for which Validation Accuracy is maximum and Training Accuracy is also good.\nIs there way or callback for it?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":202,"Q_Id":51886718,"Users Score":0,"Answer":"But the model may be overfitted to validation data.\n\nThats basically not possible. If you split your traing data into validation and training correctly, your model does never see the validation data, before it validates the hypothesis, it learned. \nYou can overfit your training data, but you can not overfit your validation data, because the model does not learn, while validating. Thats the idea behind validation split.","Q_Score":0,"Tags":"python,callback,keras","A_Id":51891386,"CreationDate":"2018-08-16T23:52:00.000","Title":"Keras Callback to Monitor Both Validation and Training Accuracy at the Same Time","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am trying to recognise discord emotes. \nThey are always between two : and don't contain space. e.g.\n:smile:\nI know how to split strings at delimiters, but how do i only split tokens that are within exactly two : and contain no space?    \nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":76,"Q_Id":51887465,"Users Score":0,"Answer":"Thanks to @G_M i found the following solution:\n\n regex = re.compile(r':[A-Za-z0-9]+:')\n result = regex.findall(message.content)\n\nWill give me a list with all the emotes within a message, independent of where they are within the message.","Q_Score":0,"Tags":"python,python-3.x,discord","A_Id":51902676,"CreationDate":"2018-08-17T02:02:00.000","Title":"find token between two delimiters - discord emotes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My network was achieving 96% accuracy on my dataset (edit: on predicting 9 classes). I saved the entire model for every epoch (weights included) whenever I ran it. I ran it 3 times, each time testing different hyperparameters, each time achieving around 96% accuracy.\nWhen I try to load any of these tests now and run it again, it achieves around 50% accuracy. I'm extremely confident I'm running it on the same dataset. \nHere's the interesting thing: if I train a new network instance of the exact same architecture, same size, shape, etc., it only ever reaches a max of 85% accuracy. Additionally, saving and loading these new training models works correctly, as in the model will reach the same 85% accuracy.\nSo, there's no problem with loading and no problem with my dataset. The only way this could happen is if something is wrong in my custom layer, or something else is happening.\nUnfortunately I haven't been committing all of my changes to the custom layer to git. While I can't guarantee that my custom layer is the exact same, I'm almost completely confident it is.\nAny ideas to what could be causing this discrepancy?\nEdit: To add more context, the layer is ripped from the ConvLSTM2d class but I replaced the call() function to simply be a vanilla RNN that uses convolution instead of the dot product. I am confident that the call() function is the same as before, but I am not confident that the rest of the class is the same. Is there anything else in the class that could affect performance? I've checked activation function already.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1125,"Q_Id":51887958,"Users Score":1,"Answer":"I finally found the answer.\nI have implemented a custom Lambda layer to handle reshaping. This layer has difficulties loading. Specifically, it reshapes one dimension into two dimensions on an arbitrary interval. The interval was defaulting to one specific value every time I loaded the model, even though it was incorrect. When I force it to be the correct interval, it works.","Q_Score":2,"Tags":"python,tensorflow,machine-learning,keras,keras-layer","A_Id":51921611,"CreationDate":"2018-08-17T03:21:00.000","Title":"Loading a saved model in Keras with a custom layer and prediction results are different?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My network was achieving 96% accuracy on my dataset (edit: on predicting 9 classes). I saved the entire model for every epoch (weights included) whenever I ran it. I ran it 3 times, each time testing different hyperparameters, each time achieving around 96% accuracy.\nWhen I try to load any of these tests now and run it again, it achieves around 50% accuracy. I'm extremely confident I'm running it on the same dataset. \nHere's the interesting thing: if I train a new network instance of the exact same architecture, same size, shape, etc., it only ever reaches a max of 85% accuracy. Additionally, saving and loading these new training models works correctly, as in the model will reach the same 85% accuracy.\nSo, there's no problem with loading and no problem with my dataset. The only way this could happen is if something is wrong in my custom layer, or something else is happening.\nUnfortunately I haven't been committing all of my changes to the custom layer to git. While I can't guarantee that my custom layer is the exact same, I'm almost completely confident it is.\nAny ideas to what could be causing this discrepancy?\nEdit: To add more context, the layer is ripped from the ConvLSTM2d class but I replaced the call() function to simply be a vanilla RNN that uses convolution instead of the dot product. I am confident that the call() function is the same as before, but I am not confident that the rest of the class is the same. Is there anything else in the class that could affect performance? I've checked activation function already.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1125,"Q_Id":51887958,"Users Score":1,"Answer":"Well, let\u00b4s think about it, there are basically two possible reasons for your problem. Your custom layer is not the same and therefore some weights are not set up correctly, which leads to missclassification. In case of a binary classification you will end up in 50% accuracy on balanced data.\nThe second possible reason is, that threre is a bug in keras serialization. In this case your new trained and saved models should also show this issue, after deserialization.\n\nWhile I can't guarantee that my custom layer is the exact same, I'm almost completely confident it is.\n\nSo the problem is not reproducable with a new model, you accuracy is 50% and you cannot guarantee that the custom layer matches. -> I guess it is you custom layer.","Q_Score":2,"Tags":"python,tensorflow,machine-learning,keras,keras-layer","A_Id":51891264,"CreationDate":"2018-08-17T03:21:00.000","Title":"Loading a saved model in Keras with a custom layer and prediction results are different?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a long task, that is adding many records to a database table.\nIn the table, there is a field called \"end\". This field will be empty until the task is done. As soon as the task is done, I will write a value in the \"end\" field.\nCan I have an HTML page, that is refreshing the page every 5 seconds with the items from the table until the field \"end\" has a value?\nDoes somebody have an example script for this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":51888992,"Users Score":0,"Answer":"You can try use websocket. Socket is listening and wait on datas. Django the use form django-channels","Q_Score":3,"Tags":"python,django,python-3.x,django-models","A_Id":51889286,"CreationDate":"2018-08-17T05:37:00.000","Title":"Django Refresh database until end of transaction","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"quick question.\nI'm trying to instal bs4 but when i run:\n\"setup.py install\" it opens the .py file in my Pycharm.\nIm unable to change the type (it will eventually use another type of program to open it). and I tried to remove the file association from PyCharm but have no positive results.\nHow can I stop PyCharm from opening the script from cmd when I run it ?\nps.: OS windows 7","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":171,"Q_Id":51893567,"Users Score":1,"Answer":"From what I understand from your question, you're just clicking on the setup.py file and trying to install it that way which won't work. What you'll need to do is this:\n\nGo into the folder where Bs4 is extracted to. \nWhere it has the content for the installation i.e setup.py\nshift + right click in the folder, and click on open command window here\nFinal step! type python setup.py install in the command window. \n\nThat will then install the library!","Q_Score":0,"Tags":"python,beautifulsoup,pycharm","A_Id":51895126,"CreationDate":"2018-08-17T10:37:00.000","Title":"setup.py opens pycharm, can't change file type","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When using keras for machine learning, model.fit() is used when training data is small. When training data is too big, model.fit_generator() is recommended instead of model.fit(). How does one know when data size has become too large?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":309,"Q_Id":51895278,"Users Score":6,"Answer":"The moment you run into memory errors when trying to take the training data into memory, you'll have to switch to fit_generator(). There is extra overhead associated with generating data on the fly (and reading from disk to do so), so training a model on a dataset that lives in memory will always be faster.","Q_Score":3,"Tags":"python-3.x,machine-learning,keras","A_Id":51895476,"CreationDate":"2018-08-17T12:16:00.000","Title":"How to know when to use fit_generator() in keras when training data gets too big for fit()?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I downloaded and installed the latest Python (3.7), and installed pyodbc both through the standard \"pip install pyodbc\" method and downloading and installing the unofficial wrapper. But still, in my script that uses pyodbc, PyCharm underlines pyodbc in red, and when I hover my mouse over it, it tells me \"module not found\". On my Settings | Project Interpreter screen, it shows that pyodbc is installed, and when I run my script, it works.\nMy problem is that it doesn't show me function arguments when I type a function name and the open parenthesis, as it does for modules that it knows about. I would like to get rid of the error marker and get the benefits of PyCharm's full support for pyodbc. How do I do that?\nNote:  This is very close to a duplicate of a question I posted over a year and a half ago, but I did not get an answer that helped at that time.  One commenter on that thread suggested I uninstall pyodbc and then run python -m install pyodbc.  I did that, and got no change.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6724,"Q_Id":51897338,"Users Score":4,"Answer":"UPDATE: The following answer was based on testing with PyCharm 2018.1. PyCharm 2018.2.1 includes an updated \"packaging_tool.py\" that plays nicely with pip 10+.\nTL;DR: Update your PyCharm.\n\nI was able to reproduce your issue with pip 18.0. When PyCharm installs a package from File > Settings > Project Interpreter it calls a helper script named \"packaging_tool.py\" which is incompatible with pip versions 10 and higher, so attempting to install any packages from there will result in\n\nAttributeError: module 'pip' has no attribute 'main'\n\nJetBrains will have to fix that script to completely resolve the issue. (Their current workaround appears to be to pin pip at version 9.x. Even though Project Interpreter window lists pip 18.0 as \"latest\" it won't upgrade to it if we select pip and click the upgrade (up arrow) button.)\nIn the meantime, a workaround for pip_10+ is to \n\nopen a Terminal window in PyCharm (AltF12), \nrun pip install pyodbc,\nclose the Terminal window and open File > Settings > Project Interpreter,\ntry to install some other package, like pandas (the install will fail for the same reason),\nclose the \"Available Packages\" dialog, then\nclick the \"OK\" button to close the \"Settings\" dialog.\n\nThat should trigger PyCharm to re-scan the installed packages and enable pyodbc code completion in the PyCharm editor. (You may need to restart PyCharm for the change to take effect.)","Q_Score":3,"Tags":"python,pycharm,pyodbc","A_Id":51899480,"CreationDate":"2018-08-17T14:15:00.000","Title":"Why does PyCharm tell me the pyodbc module cannot be found when it works?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an Apache server A set up that currently hosts a webpage of a bar chart (using Chart.js). This data is currently pulled from a local SQLite database every couple seconds, and the web chart is updated.\nI now want to use a separate server B on a Raspberry Pi to send data to the server to be used for the chart, rather than using the database on server A.\nSo one server sends a file to another server, which somehow realises this and accepts it and processes it.\nThe data can either be sent and placed into the current SQLite database, or bypass the database and have the chart update directly from the Pi's sent information.\nI have come across HTTP Post requests, but not sure if that's what I need or quite how to implement it.\nI have managed to get the Pi to simply host a json file (viewable from the external ip address) and pull the data from that with a simple requests.get('ip_address\/json_file') in Python, but this doesn't seem like the most robust or secure solution.\nAny help with what I should be using much appreciated, thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":51897917,"Users Score":0,"Answer":"Maybe I didn't quite understand your request but this is the solution I imagined:\n\nYou create a Frontend with WebSocket support that connects to Server A\nServer B (the one running on the raspberry) sends a POST request\nwith the JSON to Server A\nServer A accepts the JSON and sends it to all clients connected with the WebSocket protocol\n\nServer B ----> Server A <----> Frontend\nThis way you do not expose your Raspberry directly and every request made by the Frontend goes only to Server A.\nTo provide a better user experience you could also create a GET endpoint on Server A to retrieve the latest received JSON, so that when the user loads the Frontend for the first time it calls that endpoint and even if the Raspberry has yet to update the data at least the user can have an insight of the latest available data.","Q_Score":1,"Tags":"javascript,php,python,html,apache","A_Id":51898164,"CreationDate":"2018-08-17T14:49:00.000","Title":"Post file from one server 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":0,"Web Development":1},{"Question":"I tried finding it on AWS documentation but couldn't find it..\nIs there a way to apply a security group \"sg-123\" on a running EC2 instance using Boto3?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":868,"Q_Id":51898575,"Users Score":1,"Answer":"Ok, found the answer:\nresponse = instance.modify_attribute(Groups=['sg-123'])","Q_Score":0,"Tags":"python,amazon-web-services,amazon-ec2,boto3","A_Id":51899113,"CreationDate":"2018-08-17T15:26:00.000","Title":"Changing Security Groups for EC2 Instance using Boto3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a variable target_test (for machine learning) and I'd like to display just one element of target_test.\ntype(target_test) print the following statement on the terminal : \nclass 'pandas.core.series.Series'\nIf I do print(target_test) then I get the entire 2 vectors that are displayed. \nBut I'd like to print just the second element of the first column for example.\nSo do you have an idea how I could do that ?\nI convert target_test to frame or to xarray but it didn't change the error I get.\nWhen I write something like : print(targets_test[0][0]) \nI got the following output : \nTypeError: 'instancemethod' object has no attribute '__getitem__'","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1594,"Q_Id":51898845,"Users Score":1,"Answer":"For the first column, you can use targets_test.keys()[i], for the second one targets_test.values[i] where i is the row starting from 0.","Q_Score":0,"Tags":"python,pandas","A_Id":51898927,"CreationDate":"2018-08-17T15:42:00.000","Title":"How to display a pandas Series in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I see in the documentation that there's a __deepcopy__ method that can be used to extend the behavior of deepcopy beyond the built-in types. However, the documentation for NamedTuple (the class version in the typing module) doesn't mention anything about it. But since it provides defaults for hashing and equality testing, I was wondering, does it provide a default for deep copying as well?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1375,"Q_Id":51901253,"Users Score":5,"Answer":"NamedTuple doesn't define a special __deepcopy__ handler, but it doesn't need to. __deepcopy__ is only necessary to override\/customize the default deep copying behavior (which just uses the pickle special methods, __reduce_ex__ or __reduce__); for classes defined in Python (as opposed to C extension types), the default behavior is generally correct\/complete. object itself provides useful default pickling behaviors for all non-extension types, assuming all their attributes are themselves picklable, e.g. no open file objects or the like.\nSince NamedTuple is Python level, and has no special copying needs, it doesn't bother to implement a custom handler. You'd need to do so yourself only if some of the attributes of your NamedTuple are unpicklable and don't themselves define __deepcopy__.","Q_Score":2,"Tags":"python,python-3.x,deep-copy","A_Id":51901320,"CreationDate":"2018-08-17T18:45:00.000","Title":"Does `copy.deepcopy` work with `NamedTuple`s 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":"As I was fiddling some bash scripting on osx, I seemed to have done irreparable damage to my python installation.\nLong story short, I typed hash python in the terminal and now I can't use python.\nLets say I try:\npython code_to_run.py \nI get:\npython is hashed (\/path\/to\/my\/python)\nI've tried hash -r and hash -d python to no avail.\nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":51901570,"Users Score":0,"Answer":"In the manual for Bash:\n\nhash [-lr] [-p filename] [-dt] [name]\nEach time hash is invoked, the full pathname of the command name is determined by searching the directories in $PATH and remembered.\nAny previously-remembered pathname is\ndiscarded.  If the -p option is supplied, no path search is performed, and filename is used as the full file name of the command.\nThe -r option causes the shell to forget\nall remembered locations.  The -d option causes the shell to forget the remembered location of each name.  If the -t option is\nsupplied, the full pathname  to  which  each\nname corresponds is printed.  If multiple name arguments are supplied with -t, the name is printed before the hashed full pathname.\nThe -l option causes output to be dis-\nplayed in a format that may be reused as input.  If no arguments are given, or if only -l is supplied, information about remembered\ncommands is printed.  The return status\nis true unless a name is not found or an invalid option is supplied.\n\nhash -r worked for me (I guess if you have an important hash then this is not for you). First time I noticed this system.","Q_Score":1,"Tags":"python,bash,macos,hash","A_Id":71031247,"CreationDate":"2018-08-17T19:10:00.000","Title":"OSX -- python is hashed (\/urs\/local\/cellar\/python\/2.7\/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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to create map of the track with 30 or so points with Google Static Map API. The problem is that it supports only origin-23waypoints-end even with premium key. So the idea I got is to split the route into two and then merge those two images. The problem is that since the parts of the track will have different points it means that the map canvas won't be same which renders the merge (almost?) impossible.\nAnybody would have any idea how to solve this issue? I am helpless.\nThank you very much for any ideas. :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":240,"Q_Id":51901602,"Users Score":0,"Answer":"There is no good way to do this, to best of my knowledge.\nWhen solving the problem, we just went with multiple maps in the end. Everything is solvable yet this was not worth investing the time.\nIt's technically not an answer but an information for anybody attempting this. If you would be able to solve this, please post your solution here and I will mark it.","Q_Score":0,"Tags":"python,python-3.x,python-imaging-library,google-static-maps","A_Id":52975017,"CreationDate":"2018-08-17T19:13:00.000","Title":"Google Static Map API - image map with 25+ points","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How do you list all Pipenv environments like virtualenv's lsvirtualenv command?  The documentation does not say how. Thanks a lot to all for the help given. Cheers!","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":23572,"Q_Id":51904300,"Users Score":1,"Answer":"In my case, since I don't know a way to list all my virtual environments using any pipenv option, what I do is list the folder where all the virtual environments are.\nIn Ubuntu by default, pipenv creates a folder in $HOME\/.local\/share\/virtualenvs\/ whit the name of the virtual env, then listing that folder I have a list of all my environments.\nTo make life easier, I have created an alias to perform this operation.","Q_Score":22,"Tags":"python,virtualenv,pipenv","A_Id":67597205,"CreationDate":"2018-08-18T00:36:00.000","Title":"List all Pipenv environments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create Faster RCNN like model. I get stuck when it comes to the ROI pooling from the feature map. I know here billinear sampling can be used but, it may not help for end to end training. How to implement this ROI pooling layer in tensorflow?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":506,"Q_Id":51905199,"Users Score":1,"Answer":"Bilinear sampling - as the name suggests - can actually be used even with end-to-end training as it's basically a linear operation. However, the disadvantage would be that your local maxima (i.e. strong excitations or certain units) could vanish because your sampling points just happen to be close to the minima. To remedy this, you can instead apply a max_pool(features, kernel, stride) operation where kernel and stride are adjusted such that the final output of this max pool operation does always have the same dimensions.\nAn example: your features have size 12x12 and you would like to pool to 4x4, then setting kernel=(3,3) and stride=(3,3) would help you achieve that and for each 3x3 patch, the strongest excitations in the respective feature maps will be contained in the output.","Q_Score":0,"Tags":"python,tensorflow,neural-network,artificial-intelligence","A_Id":51905252,"CreationDate":"2018-08-18T04:15:00.000","Title":"How to implement Region of Interest Pooling layer in tensorflow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to Python, and going to use Python in the next job.\nI'm now using pyenv to version Python and its libraries, but some of blog posts says we don't necessarily need pyenv for versioning.\nSome say we need pyenv and virtualenv, others say we need only venv,\nand or need nothing...\nIt's a little complicated.\nI think if I don't use versioning tools like pyenv, I'm in trouble in using tools that need Python2, such as npm.\n\nI use only Python3\nI will develop in many projects, both Web developing and data analysis with Python\nI use MacOS\n\nUnder these conditions, what is the best stack to manage my Python environment?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":115,"Q_Id":51909766,"Users Score":1,"Answer":"pyenv manages different Python versions. It's useful if you develop multiple projects that use different Python versions. If you are going to stick to only Python 3, you don't have to use pyenv.\nDifferent virtual environment wrappers (virtualenv, virtualenvwrapper) help you isolate Python environments for different projects. E.g. if you are going to use requests library, virtual environment will enable you to use different versions of requests library in different projects (e.g. at some point you can update to new requests version on Project A, but decide to keep old version on Project B). Even if you are going to work on a single projects, it's still recommended that you use virtual environment.\nI personally prefer virtualenvwrapper to virtualenv. It makes it really simple to create environments, add some custom post activation logic to environments (e.g. set env variables, or change working directory), and switch between active environments.","Q_Score":1,"Tags":"python,virtualenv,pyenv,python-venv","A_Id":51909871,"CreationDate":"2018-08-18T14:41:00.000","Title":"What do I need for managing Python versions and libralies?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been having a struggle with this. I am new to python programming and I would like to further my capabilities with other modules. I have read different websites and watched YouTube videos on installing modules with pip. None of it is either clicking with me or its not working. I am running python 3.7 which I downloaded from python.org. Where do I write the \"pip install xxxxx\" code? Everywhere I am typing it, I am getting a syntax error. Specifically I am wanting to install \"openpyxl\".","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":191,"Q_Id":51912305,"Users Score":-1,"Answer":"I run the command in cmd in the directory that I want. If you use Anaconda you can use conda install openpyxl. \nAnd make sure that pip is installed. Run python and try to import pip to see if it exist.\nHope it's useful.","Q_Score":0,"Tags":"python,pip","A_Id":51912372,"CreationDate":"2018-08-18T20:28:00.000","Title":"Installing modules with pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There are 3 servers on consumer side (A <-> B <-> C), 2 of them are our Apps (B (Node.js), C (Python)). All the communications among the servers are handled by WebSockets with TLS. C is not connected to A. I don't want a consumer to be able to run fake B or C server and connect it to real C or B server.\n\nA - client \nB - server for A and separate server with different port for C\nC - client\n\nAlso there is the external D license server, which is reached via the Internet.\nSo what is the best way to guarantee server identity?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":67,"Q_Id":51912845,"Users Score":1,"Answer":"If these are programs that your customer runs on machines that they own and host, and the customer is the attacker you're trying to protect against, then there really is no way to do this.\n\nYou can write a simple challenge-response protocol, where B and C only have to know each other's public keys to both be able to verify that the other side knows its own private key.\nBut where are you going to store that private key? Somewhere that the program can access it\u2014which means somewhere that your customer can access it.\n\nOf course you can try to obfuscate the keys. This works great if nobody cares about cracking your system\u2014but then if nobody cares, you don't have to do anything. If cracking your system would be valuable to someone, they'll find a way to dig out the keys.\nAt which point you're in an arms race: every time someone finds your keys, you have to think of a new way to obfuscate them to make them start all over.\nAnd even that won't work unless you can require your customers to stay up to date on all of their servers. Otherwise, once I've dug the keys out of your version 1.3.4, I can just keep running version 1.3.4 of server C, and my own fake server B.\n\nIf you can force the servers to communicate with another server that you run and control out on the internet, you can make it much harder to crack the handshake (and harder to stick with old versions), but it's still nowhere near impossible. And really, that just shifts the attack surface to modifying the servers so they don't do the upstream check. What you're basically talking about here is the equivalent of Windows Activation or online game verification\u2014which, of course, people have cracked.\n\nThere are plenty of cases where it's worth doing something anyway:\n\nOften a small amount of obfuscation is worth it to deter casual hackery.\nPaying for one of the commercial solutions means you're now using \"industry standard\" protection, so you use the DMCA against anyone who attacks it, you can defend yourself if partners sue you over lost data, etc.\nIf $200K\/year worth of engineering can knock even 10% of the losses off $200M\/year worth of content, spend the effort.\n\nBut at this point, we're not talking about business issues, so you'll probably get better advice from a security consultant who can ask you the right questions about your business, than from a generic answer on a programming site.","Q_Score":0,"Tags":"python,node.js,security,ssl,websocket","A_Id":51913061,"CreationDate":"2018-08-18T21:55:00.000","Title":"How to guarantee server identity?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get the generated URL of a file in a test model I've created,\nand I'm trying to get the correct url of the file by: modelobject.file.url which does give me the correct url if the file is public, however if the file is private it does not automatically generate a signed url for me, how is this normally done with django-storages? \nIs the API supposed to automatically generate a signed url for private files? I am getting the expected Access Denied Page for 'none' signed urls currently, and need to get the signed 'volatile' link to the file.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":941,"Q_Id":51913046,"Users Score":6,"Answer":"I've figured out what I needed to do,\nin the Private Storage class, I forgot to put custom_domain = False originally left this line off, because I did not think I needed it however you absolutely do in order to generate signed urls automatically.","Q_Score":2,"Tags":"python,django,boto3","A_Id":51913176,"CreationDate":"2018-08-18T22:38:00.000","Title":"django-storages boto3 accessing file url of a private file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying the Quickstart commands on niftynet's website.\nAs I run \n    net_download dense_vnet_abdominal_ct_model_zoo \nI get Illegal instruction (core dumped). \nDoes someone have a solution?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":51913877,"Users Score":0,"Answer":"check your permission as miniconda is an installation in the root or other users.","Q_Score":2,"Tags":"python-3.x,niftynet","A_Id":68694498,"CreationDate":"2018-08-19T02:05:00.000","Title":"python niftynet illegal instruction core dumped","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 projects which use the same API modules, which i have written myself. These API modules encapsulate existing imported functions from pypi libraries.\nIf I have to write unit tests for my API - should the unit tests modules be present in every project which uses my API or should there be a separate project for API testing?\nThe API is one for all so logically I would open a separate project for API testing, but what if the projects get passed around between people who don't own the API testing project? Then if the implementation of the inner imported functions in the API changes unit testing will be needed.\nI suppose the question regards API of any language but my projects are specifically in Python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":51915622,"Users Score":0,"Answer":"I would recommend to consider the code and its unit-test as belonging to the same component.  They should, for example, reside in the same repository of your version control system.  For example, if the code evolves, most likely the unit-tests also need to be adjusted accordingly.  Therefore, there is no much value in treating them as different components.\nTaking up the example from your two projects and the API they both use: The API together with its tests forms a component.  Thus, the API is developed conceptually independently from the projects.  For example, if during the work on your project P1 you detect a bug in the API, then you fix the API component directly in its repository (possibly by first extending the API's unit-test suite to also capture that bug), make a new release of the API component, and then use that new release within P1, but probably also update P2 to use the new release.\nYou can, however, consider providing your API component in a package to the clients (your projects P1 and P2) that does not contain the unit-tests, if you prefer.  The development on the API would in any case not take place from within P1 or from within P2, but directly in the API's repository.\nTo summarize: Do not separate the code and its tests into separate modules.  Instead, put the code and its tests into one repository, but separate from the clients.","Q_Score":2,"Tags":"python,unit-testing,python-unittest","A_Id":55976441,"CreationDate":"2018-08-19T07:52:00.000","Title":"Python unit testing a self-written API module - better in separate 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},{"Question":"I'm following a plotnine tutorial to do some plotting on Jupyter Notebook. But when I imported\nfrom plotnine import * \nI got an error: ModuleNotFoundError: No module named 'plotnine'.\nI'm new on Jupyter and plotnine. Have tried different things searched, but still don't know how to solve this ...","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8679,"Q_Id":51916337,"Users Score":1,"Answer":"Make sure plotnine is installed in your environment. Without more information about your environment, I can't give you a definitive answer, but this might work\n\nmake a new empty cell in jupyter\nwrite !pip install plotnine into cell\nexecute cell\n\nThis should install plotnine and you can use it from now one (and you can delete the cell, plotnine is now a permanent part of your environment)","Q_Score":5,"Tags":"python,jupyter-notebook,plotnine","A_Id":51916365,"CreationDate":"2018-08-19T09:34:00.000","Title":"Getting ModuleNotFoundError: No module named 'plotnine' when import on Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently joined a Telegram bot that requires user interaction every few hours.\nBasically I Log into the bot, press a button, check text and then press another button.\nIs it possible to automate such a task? \nThank you","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":177,"Q_Id":51916924,"Users Score":1,"Answer":"Telegram Bot API doesn't allow bots to interact with other bots. So bots won't be useful for such task.Only way to do that is to use Telegram Core API (the API used in telegram clients), make a custom Telegram client, and do the task through it.","Q_Score":0,"Tags":"python-3.x,automation,telegram,telegram-bot,scrape","A_Id":51965732,"CreationDate":"2018-08-19T10:53:00.000","Title":"How to automate a 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 did develop most of the front end but I am thinking to hire a freelance frontend developer(HTML, CSS and JS) to refine the design and make the site look professional. I am not yet comfortable to share my code with him. \nIs there any way in which he can run the django app without having models.py & views.py and work on html, css and js files.\nAny leads on this matter is appreciated.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":630,"Q_Id":51918298,"Users Score":2,"Answer":"He can build pure HTML\/CSS\/JS pages that you can use afterwards as your Django templates and extend as you wish. It depends of the complexity of your templates I guess.","Q_Score":0,"Tags":"python,django","A_Id":51918336,"CreationDate":"2018-08-19T13:46:00.000","Title":"Running a django website without models.py and views.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have an url: http:\/\/200.73.81.212\/.CREDIT-UNION\/update.php None of reg expressions I've found and develop myself works. I'm working on phishing mails dataset and there are lots of strange hyperlinks. This is one of mine:\nhttps?:\\\/\\\/([a-zA-z0-9]+.)+)|(www.[a-zA-Z0-9]+.([a-zA-Z0-9]+\\.[a-zA-Z0-9]+)+)(((\/[\\.A-Za-z0-9]+))+\/?.\nOf course no success. I work in Python.\nEDIT:\nI need a regex to catch this kind of url's and, also, any ordinary hyperlinks, like:\nhttps:\/\/cnn.com\/\nwww.foxnews.com\/story\/122345678\n Any thoughts?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":348,"Q_Id":51919931,"Users Score":0,"Answer":"While @datawrestler answer works for original question, I had to extend it to catch wider group of url's (I've edited the question). This url, seems to work, for the task:\nr\"\"\"(https?:\/\/www\\.[a-zA-Z0-9]+(\\.[a-zA-Z0-9]+)+(\/[a-zA-Z0-9.@-]+){0,20})|\\\n(https?:\/\/[a-zA-Z0-9]+(\\.[a-zA-Z0-9]+)+(\/[a-zA-Z0-9.@-]+){0,20})|\\\n(www.[a-zA-Z0-9]+(\\.[a-zA-Z0-9]+)+(\/[a-zA-Z0-9.@-]+){0,20})\"\"\"\nThree alternatives: https?:\/\/www, https:\/\/domain, www.domain","Q_Score":1,"Tags":"python,regex,python-3.x,http,regex-group","A_Id":52027694,"CreationDate":"2018-08-19T16:59:00.000","Title":"Regex to Catch Url","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a number of directories of Python programs what I would like to execute on Colaboratory.  Is there a way to do that -- other than to load and save the files one-by-one? If it helps, the directories are all in my own Google Drive. So all I would need (I think) is a way to cd to a given directory. I tried !cd .., which presumably should go to my top Google Drive directory, but it doesn't seem to work.\nJust copied a directory into Google Drive\\Colab Notebooks using the file explorer. But Colab refused to cd to that directory.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":51920753,"Users Score":0,"Answer":"After you mount the drive, don\u2019t use !cd.\nUse %cd instead.","Q_Score":0,"Tags":"python,google-colaboratory","A_Id":51940508,"CreationDate":"2018-08-19T18:40:00.000","Title":"Making an existing director of Python programs available to Colaboratory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using the DRF and ReactJS and I am trying to login with Patreon using \ndjango-rest-framework-social-oauth2. \nIn React, I send a request to the back-end auth\/login\/patreon\/ and I reach the Patreon OAuth screen where I say I want to login with PAtreon. Patreon then returns with a request to the back-end at accounts\/profile. At this point a python-social-oauth user has also been created.\nAt this point I'm confused. How do I make a request to Patreon to login, create a user in the back-end, and return the session information to the react front-end so that I can include the session information in all following requests from the front-end? I don't want the returned request to be at the backend\/accounts\/profile, do I?\nUpdate\nI now realize I can set the redirect url with LOGIN_REDIRECT_URL but still, how do I now retrieve the session id, pass it to the front-end, and include it with all requests?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":691,"Q_Id":51922459,"Users Score":0,"Answer":"Once you receive the user profile email, unique id, and other details from Patreon then create a user at the Database level.\nNow after creating a user at the Database level you have to log in the user using the Django login function or any other login mechanism before redirecting the user to the frontend with a session.  The redirect URL  for the home\/ landing page is provided by the Frontend side where they want to land the user after being successfully logged with session-id being set in cookies. Onward Frontend side can use session id in cookies for other requests.\nHere is the flow:\n\nReact JS -> auth\/login\/patreon\/ -> redirected to Patreon -> Redirected back to the Backend with  user information -> Create User (DB level) -> Login user  -> Redirect back to Frontend (React JS on a specific URL provided by Front end)","Q_Score":9,"Tags":"django,reactjs,django-rest-framework,python-social-auth","A_Id":70682638,"CreationDate":"2018-08-19T22:55:00.000","Title":"Django - DRF (django-rest-framework-social-oauth2) and React creating a user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have the latest\/updated Anaconda package. Everytime I try to plot something using python 3.6.6 I get the following error in JupyterLab... \n\nJavascript Error: IPython is not defined\n\nWhen I run the same code in Spyder using an ipython kernel, it works just fine. Have been looking all over online but cant seem to figure out what is going on. \nAny help would be appreciated.","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":133403,"Q_Id":51922480,"Users Score":1,"Answer":"Jupyterlab supports jpympl.\n\nYou must put %matplotlib widget in the very beginning of the jupyterlab.\n\n\nYou can change to %matplotlib inline in specific cell, and active %matplotlib widget again if needed.\nOtherwise, no matter how many times you reinstall the package, you will still get the errors.","Q_Score":126,"Tags":"javascript,ipython,jupyter-lab","A_Id":64362954,"CreationDate":"2018-08-19T22:59:00.000","Title":"Javascript Error: IPython is not defined in JupyterLab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"OS: Windows 10\nUsing anaconda3 - 5.2, running commands in Anaconda command prompt. \nHere's the commands I used to locate the word-rnn and activate the conda enviroment, plus the error messages when I attempt to train the model. I am also going off of a Mac based tutorial, so please correct me if \"python train.py\" is the incorrect command to being training. \n(base) C:\\Users\\mower>conda activate tensorflow\n(tensorflow) C:\\Users\\mower>cd \"C:\\Users\\mower\\Downloads\\word-rnn-tensorflow-master\"\n(tensorflow) C:\\Users\\mower\\Downloads\\word-rnn-tensorflow-master>python train.py\nTraceback (most recent call last):\n  File \"train.py\", line 2, in \n    import numpy as np\nImportError: No module named 'numpy'\n(tensorflow) C:\\Users\\mower\\Downloads\\word-rnn-tensorflow-master>","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":701,"Q_Id":51926059,"Users Score":0,"Answer":"You can use python's pip installer or anaconda's own installer to install numpy. In pip you use:\npip install numpy\nOR\nyou can use anaconda like below:\nconda install numpy","Q_Score":0,"Tags":"python,numpy,tensorflow,cmd,anaconda","A_Id":51926152,"CreationDate":"2018-08-20T07:38:00.000","Title":"When running command \"python train.py\" to train word-rnn, getting \"no module named numpy\" error.","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"On publishing updates to an existing wagtail page it raises a ValidationError with the message below.\nValidationError({'live_revision': ['page revision instance with id 33 does not exist.']})\nAll other actions such as drafting, submitting for moderation all work okay.\nOnly publishing the page with new updates raises the ValidationError effectively limiting the ability to update existing pages.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":487,"Q_Id":51928023,"Users Score":2,"Answer":"Just faced a very similar issue.\nMake sure you are not using ParentalKey in a Page model.\nUse the regular Django models.ForeignKey instead.","Q_Score":1,"Tags":"python,django,wagtail,validationerror","A_Id":56551502,"CreationDate":"2018-08-20T09:44:00.000","Title":"Wagtail raises ValidationError on page update","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We have a RabbitMQ server running under Docker. We both publish and receive messages from code in both Ruby and Python, all of which is almost exactly straight from the online tutorial examples. After a short number of messages, the Python version starts to only receives every other message. The Ruby script continues to receive all of them.\nWhile not exactly RabbitMQ experts, we've checked the code and it's so close the official tutorials that it's hard to see that we're making any big mistakes. Plus it works initially anyway.\nIs there anything that could be causing this odd behaviour?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":176,"Q_Id":51928575,"Users Score":0,"Answer":"The answer, as hinted at by Pascal, was that it needed to be set to 'Fan-Out'. Thanks for the tip.","Q_Score":1,"Tags":"python,ruby,rabbitmq","A_Id":51932396,"CreationDate":"2018-08-20T10:15:00.000","Title":"Every other message missing with 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 have both anaconda and VS Code installed in my system. When I start writing a script, VS Code gives me an option to chose the interpreter. I choose my particular conda environment. This works fine. However when I try to run the script using Ctrl+Alt+N or using the play button on the top right (using the extension Code Runner), the terminal that opens in the VS Code doesn't recognize that I am now working in a conda environment. \nAs a result, it gives an error that the module is not installed (because the module is available only in the conda environment). \nWhen I try to manually activate the conda environment from the VS Code terminal, it doesn't work.\nWhat is the workaround? I am using Windows.\nUpdate: If I use cmd as the default integrated terminal in VS Code in place of PowerShell, then the command activate NAME_OF_ANACONDA_ENV works. And then, I can manually run the script. However, running the script using Ctrl+Alt+N still doesn't work; it doesn't recognize that I am in a conda env.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3215,"Q_Id":51930833,"Users Score":0,"Answer":"On windows 10: Ctrl+Shift+P and selecting the environment gets the job done. \nAfter setting the environment, I execute by pressing Crtl+F5 to execute without debugging and F5 to debug.","Q_Score":2,"Tags":"python,visual-studio-code,anaconda,conda","A_Id":51931235,"CreationDate":"2018-08-20T12:31:00.000","Title":"VS Code not running a Python file in the conda environment mentioned","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have both anaconda and VS Code installed in my system. When I start writing a script, VS Code gives me an option to chose the interpreter. I choose my particular conda environment. This works fine. However when I try to run the script using Ctrl+Alt+N or using the play button on the top right (using the extension Code Runner), the terminal that opens in the VS Code doesn't recognize that I am now working in a conda environment. \nAs a result, it gives an error that the module is not installed (because the module is available only in the conda environment). \nWhen I try to manually activate the conda environment from the VS Code terminal, it doesn't work.\nWhat is the workaround? I am using Windows.\nUpdate: If I use cmd as the default integrated terminal in VS Code in place of PowerShell, then the command activate NAME_OF_ANACONDA_ENV works. And then, I can manually run the script. However, running the script using Ctrl+Alt+N still doesn't work; it doesn't recognize that I am in a conda env.","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":3215,"Q_Id":51930833,"Users Score":4,"Answer":"After a few tries i figured out how to do it. So, this works for me.\n\nvs code settings search: code-runner.executorMap\n\nChoose User and\nEdit in settings.json\n\nfind:    \"python\": \"python -u\" \n\nchange:  \"python\": \"$pythonPath -u $fullFileName\"\n\n\nif you encounter tempCodeRunnerFile or selection problem:\n\nvs code settings search: code-runner.ignoreSelection\ntick the box","Q_Score":2,"Tags":"python,visual-studio-code,anaconda,conda","A_Id":67878090,"CreationDate":"2018-08-20T12:31:00.000","Title":"VS Code not running a Python file in the conda environment mentioned","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using object detection from tensorflow. \nSome background information about the problem\nI was facing a challenge since I am interested in training a model which will among other things detect also weapons. My regular point of view is from a drone but I couldn't find any publicly available dataset from this point of view containing weapons. So, I collected images with weapons and tried to imitate as much as possible the drone point of view. \n\nOne of my first thought was to pad my images (to make smaller my actual bounding boxes inside them in respect with the image itself). \nA second though was to also rotate my images. Since tensorflow has not implemented this feature I made a simple code to create prerotated images. This has limitation but anyway I gave it a shot.\n\nI experimented with images of people at the beach and tried to imitate the actual problem: \n\nI am using relatively close images of people at the beach for training\nAnd at the same time using relatively distant images of people at the beach for testing purposes.\n\nThe actual problem\nAt one of my experiments I trained my model for longer than usual and noticed that it really blew it. To be more specific: \n\nI have an initial 140 \"close frame\" images for training. \nFrom them I had created 4x140=560 images with small padding (resulting image is up to 1.6 times the original in the biggest version) and rotation (up to 5 degrees rotation) resized version.\nI used this dataset of 560 images to train my model for almost 800k iterations using Faster R-CNN model.\nI exported the model in various iterations:\nAt 150k, 300k, 500k, 700k and used to test it on my test images.\n\nI have also used for comparison models which was trained with the original resized images to check the differences.\nUn-expected results\n\nThe first peculiar observation is that my model at 500k and above it does not detect any person at all. (First thought was overtraining)\nI tried it on the actual training images to check this and here also did not detect anything at my testing images. \nAlso, I would expect my \"enhanced\" dataset to perform better than the simply resized one but this does not seem the case also. (This though is a minor problem which seem scientifically rational).\n\nSo, my question is how is that even possible? Training for too long can lead to being unable to detect training samples also? Is there any theoretical explanation for this? (Apart from errors in implementation etc which I think is not really probable but cannot be excluded in any case).\nP.S.1\nMy resized version of the image follows the same resize conditions of Faster R-CNN with min. dim. being 600 pixels and max. one 1024 pixels. So, this should not be any resizing problem.\nP.S.2\nI am using tensorflow but I don't think this is tensorflow specific issue. So, I did not include it in tags.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":245,"Q_Id":51931564,"Users Score":0,"Answer":"After some research (and a lot of experiments) I have come to some conclusions which might help others facing the same problem.\n\nFailing to detect any object probably means that the model has collapsed in some part of training. A possible indication of this in my case was some extremely high values of loss values when training. While I have models that this happened and does not seem to affect the model too much (at least not too much to make it useless) an increasing amount of these values is a good sign that something is fatally wrong. Notice that the frequency of appearance of these values is not necessarily increasing all the time.\nMore classes the better: After the first period I was conducting my experiments with just 1 class. While this is legitimate and nothing has been mentioned (to my knowledge) about avoiding it (I even read tutorials using 1 class object detection) this also intensified the crack rate. Using 2 classes seems to partially alleviate the problem. When I trained my model with 11 classes the problem seems to vanish.\nSmall variation in bbox's sizes helps: Experimenting with bounding boxes varying a lot in size I came to the conclusion that largely homogeneous bbox's sizes help to also alleviate the issue.\nMore classes may increase performance: I have noticed also that while 11 classes problem seem quite heavier task than 1 class due to the limitations in training the model with 1 class performance is some cases was higher in the former case.\n\nMy final conclusion is that my model for some reason was experiencing at some point an overflow on some weights that prevent it from returning to the normal again. The fact that I have augmented my data (maybe similar images were fed one after the other and intensified certain weights for example) maybe increased the frequency of the problem occurrence but the problem was still present in non-augmented dataset.","Q_Score":0,"Tags":"python,object-detection","A_Id":52290741,"CreationDate":"2018-08-20T13:13:00.000","Title":"Training object detection model too long causes model to crack","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently writing a Flask app using virtual env. When I try and run some of my python files I am getting:\nImportError: No module named <module>\nIn this case, the module I am trying to use is 'Click'. If I do a pip freeze or a pip list inside the virtual env, I can see the module listed there. I'm inside my virtual env when I'm trying to run the .py file too. How come pip freeze\/list can find the module but my .py program cannot? Could it also be an issue with my .wsgi file?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":431,"Q_Id":51932231,"Users Score":0,"Answer":"Actually I've just figured this out, the path in my .wsgi file for \"activate_this.py\" was incorrect because I was trying to run it in an EC2 instance instead of my normal directory. After changing the path things seem to be working again :)","Q_Score":1,"Tags":"python,flask,virtualenv","A_Id":51933173,"CreationDate":"2018-08-20T13:51:00.000","Title":"No module named error but pip freeze shows module is instealled in virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am teaching a class that uses VScode.\nI am used to teaching using IDLE, and it is very nice for the students to be able to call their defined functions and run snippets of code in a python terminal, for debugging purposes.\nIn VScode, they I have been unable to do the same in a satisfactory way.\nOption1: I can select all code, right click and run selection\/line on terminal. This works for small snippets, but I cannot do it for the whole file (even after selecting the whole file with ctrl-A). On linux, this works, but on windows, it does not, unfortunately (and my students use windows)\nOption2: I can use the debug console. This requires adding a breakpoint in one of the last lines of the file, and does not offer tab completion. It works, but is less convenient than IDLE.\nOption 3: I can also add the commands to run to the bottom of the file (which is a least preferred alternative, given that is forgoes the interativity of the read-print-eval loop).\nIs there any better solution? Installing a VScode extension would not be a problem.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":254,"Q_Id":51934119,"Users Score":3,"Answer":"Visual Code is just a text editor like your traditional notepad. to run and debug any kind program you need to install the particular extension for the programming language.\nIn your case you are using python so you need to install the extension of it. the best one is the \"Python\" which is developed by microsoft itself. go to your extensions manager and install this extension. right click and click \"run python file in terminal\" and you are all set.\nthis will run exactly as they run from the idle(which is default IDE provided by python itself) you can enter the arguments from the console itself. according to me this is the best way to run and debug python programs in VScode.\nanother way is that VScode shows which python version is installed on your computer on the left bottom side, click on it and the programs will use this interpreter.\nout of all the ways listed here and many others, the best method is to run the program in the terminal which is the recommend by python itself and many other programmers.\nthis method is very simple. what you have to do is open up your command prompt and type the path where python.exe is installed and the type the path of the your program as the argument and press enter. you are done !\nex : C:\\Python27\\python.exe C:\\Users\\Username\\Desktop\\my_python_script.py\nYou can also pass your arguments of your program in the command prompt itself.\nif you do not want to type all this and then just use the solution mentioned above.\nhope that your query is solved.\nregards","Q_Score":2,"Tags":"python,visual-studio-code","A_Id":51940891,"CreationDate":"2018-08-20T15:34:00.000","Title":"In Visual Studio Code, how do I load my python code to a read-print-eval loop?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When building a model for machine learning, is it okay to have non-trainable params? Or does this create errors in the model? I'm confused as to what non-trainable params actually are and how to fix your model based on that.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3816,"Q_Id":51935097,"Users Score":4,"Answer":"Usually, non-trainable params does not mean some weights to which you assign random or predefined values (there would be no way to know the correct values, as they depend on the other weight values).\nIt means some architectural decisions that you have made a priori. For example, in a neural network , such parameters would be the number of layers and the number of nodes per layer. These can be decided by educated guesses, or, usually, by trial-and-error (cross-validation).\nHaving such non-trainable parameters is not only ok, but unavoidable with most training algorithms.","Q_Score":3,"Tags":"python,machine-learning,keras,hyperparameters","A_Id":51935221,"CreationDate":"2018-08-20T16:35:00.000","Title":"Is it okay to have non-trainable params in machine learning?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had a question, For a given data set X with two classes {0,1}. If I train two separate neural networks NN0 and NN1 for each class 0 and 1 respectively. Can NN0 predict points in the dataset from class 1, even though it was trained on class 0?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":51938859,"Users Score":0,"Answer":"When you test a case from X with NN0, and it tells you \"I'm a 0\", that's the exact same thing as it telling you \"I'm not a 1\", because your class set has size two, like a boolean.\nTherefor, your NN0 network predicts 1s as well as 0s, so does your NN1.","Q_Score":0,"Tags":"python-3.x,tensorflow,neural-network,keras,regression","A_Id":51938930,"CreationDate":"2018-08-20T21:40:00.000","Title":"Neural Network Regression","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m practicing Pyspark (standalone) in the Pyspark shell at work and it\u2019s pretty new to me. Is there a rule of thumb regarding max file size and the RAM (or any other spec) on my machine? What about when using a cluster? \nThe file I\u2019m practicing with is about 1200 lines. But I\u2019m curious to know how large of a file size can be read into an RDD in regards to machine specifications or cluster specifications.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":593,"Q_Id":51939204,"Users Score":0,"Answer":"There is no hard limit on the Data size you can process, however when your RDD (Resilient Distributed Dataset) size exceeds the size of your RAM then the data will be moved to Disk. Even after the data is moved to the Disk spark will be equally capable of processing it. For example if your data is 12GB and available memory is 8GB spark will distribute the leftover data to disk and takes care of all transformations \/ actions seamlessly. Having said that you can process the data appropriately equal to size of disk.\nThere are of-course size limitation on size of single RDD which is 2GB. In other words the maximum size of a block will not exceed 2GB.","Q_Score":0,"Tags":"python,linux,apache-spark,pyspark","A_Id":51939403,"CreationDate":"2018-08-20T22:16:00.000","Title":"Maximum files size for Pyspark RDD","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I came across multiple implementations of a CNN in Keras and noticed that some people use Conv1D from from keras.layers.convolutional import Conv1D and others use Convolution1D from from keras.layers import Convolution1D. Is there a difference or an advantage to either one or are they possibly simply just different versions of Keras.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2001,"Q_Id":51939468,"Users Score":9,"Answer":"They are just for different keras versions, before Keras 2.0 the layers were called ConvolutionalND for N = 1, 2, 3, and since Keras 2.0 they are just called ConvND.","Q_Score":6,"Tags":"python,keras","A_Id":51939645,"CreationDate":"2018-08-20T22:50:00.000","Title":"Keras Conv1D or Convolution1D","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I came across multiple implementations of a CNN in Keras and noticed that some people use Conv1D from from keras.layers.convolutional import Conv1D and others use Convolution1D from from keras.layers import Convolution1D. Is there a difference or an advantage to either one or are they possibly simply just different versions of Keras.","AnswerCount":2,"Available Count":2,"Score":-1.0,"is_accepted":false,"ViewCount":2001,"Q_Id":51939468,"Users Score":-4,"Answer":"It's not about the versions. The n stands for the dimension of data, for e.g. if you are using a text data you use n=1 i.e. convolution1d. The value of n=2 is used for images. The value for n=3 goes for mri or ct scan. So, depending on the dimensions we use the value.","Q_Score":6,"Tags":"python,keras","A_Id":53997197,"CreationDate":"2018-08-20T22:50:00.000","Title":"Keras Conv1D or Convolution1D","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have absolutely no idea what can be the problem. I did the pip installer (pip install pyttsx3) and re-installed the JetBrains PyCharm, but it still not working.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":17412,"Q_Id":51948896,"Users Score":1,"Answer":"Well i might be a little late but incase anyone is still having problem, i managed to fix it with py -m pip install pyttsx3","Q_Score":3,"Tags":"python-3.x,pyttsx","A_Id":65411211,"CreationDate":"2018-08-21T12:40:00.000","Title":"Python 3.6 ModuleNotFoundError: No module named 'pyttsx3'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have absolutely no idea what can be the problem. I did the pip installer (pip install pyttsx3) and re-installed the JetBrains PyCharm, but it still not working.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":17412,"Q_Id":51948896,"Users Score":1,"Answer":"I had the same issue.\nAll I did is used 'python <filename>' to run the program instead of 'python3 <filename>' and it WORKED.\nI am not sure, but maybe pyttsx3 does not support the python3 syntax to find itself.\nI hope this helps anyone out there, who searched for hours just like me.","Q_Score":3,"Tags":"python-3.x,pyttsx","A_Id":69240410,"CreationDate":"2018-08-21T12:40:00.000","Title":"Python 3.6 ModuleNotFoundError: No module named 'pyttsx3'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have absolutely no idea what can be the problem. I did the pip installer (pip install pyttsx3) and re-installed the JetBrains PyCharm, but it still not working.","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":17412,"Q_Id":51948896,"Users Score":2,"Answer":"Start a pyCharm terminal window, then install 'pipenv' which is an improved pip replacement as follows:\n\npip install -u pipenv\n\nThen use pipenv instead of pip as this will create it's own Pipfile and virtualenv. You can install pyttsx3 as follows:\n\npipenv install pyttsx3\n\nThis will create a Pipfile and a Pipfile.lock which pycharm should pickup and ensure it's using the correct python version and virtualenv environment. Otherwise check that your python interpreter is set correctly in \"Run\/Debug configurations\". If it's not in that list then you can add a new python interpreter via the Preferences->Project->Project Interpreter option.","Q_Score":3,"Tags":"python-3.x,pyttsx","A_Id":51957876,"CreationDate":"2018-08-21T12:40:00.000","Title":"Python 3.6 ModuleNotFoundError: No module named 'pyttsx3'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have two series X and Y. X contains time values and Y contains a real function values for those times. I wish to perform FFT of the Y signal in python. The problem is that X is unevenly spaced: X(n+1)-X(n) \/= constant. Is there a known way to apply FFT to such data ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":386,"Q_Id":51949595,"Users Score":0,"Answer":"You can try creating a new evenly spaced set of samples, Y', by interpolation.  Then FFT Y'.  How well this works depends on well the form of interpolation you choose matches the physics that produced your original Y,X data.","Q_Score":1,"Tags":"python-3.x,fft","A_Id":51961029,"CreationDate":"2018-08-21T13:16:00.000","Title":"Is there a way to apply FFT to an unevenly spaced time series?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Maybe I didn't read the docs that well, but I didn't find more information about how lock's or rlock's aquire work ... does it block all processes no matter what statements those processes are on (even if they are on no critical sections).. or does it block only the processes trying to access the critical section\nThank you !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":51953391,"Users Score":2,"Answer":"From the docs:\n\nclass multiprocessing.Lock\nA non-recursive lock object: a close analog of threading.Lock. Once a process or thread has acquired a lock, subsequent attempts to acquire it from any process or thread will block until it is released; any process or thread may release it. The concepts and behaviors of threading.Lock as it applies to threads are replicated here in multiprocessing.Lock as it applies to either processes or threads, except as noted.\n\nSo when you call acquire() (note the use of default value for the block parameter) your process will:\n\nAcquire the lock if it is in an unlocked state.\nBlock till the lock is in an unlocked state, then acquire it.\n\nThis mechanism allows you to define \"critical sections\" in your logic, meaning that only one process at a time will be executing that particular function (i.e. playing an audio file)","Q_Score":0,"Tags":"python,multiprocessing,python-multiprocessing","A_Id":51954301,"CreationDate":"2018-08-21T16:51:00.000","Title":"Does lock.acquire blocks processes in non critical section","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a RHEL server with Anaconda3 installed. Each user in the system gets 2 GiG space in the \/home\/ folder and another large folder in a mounted drive. When the user is trying to create a conda environment using conda create -n my_env it fills all the .tar files in .conda folder and installation breaks. Is there a way I specify a custom location for the .conda folder.\nBest\nJagan","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10916,"Q_Id":51957827,"Users Score":0,"Answer":"I had the same disk space problem.\nAll docs and forums told me to uninstall and reinstall anaconda to new location...\nI didn't want that, so here another approach:\n\ncopy anaconda folder to new location.\nlets assume old location \/home\/uname\/anaconda3,\nnew location \/home\/uname\/mountx\/anaconda3\ncp -r \/home\/uname\/anaconda3 \/home\/uname\/mountx\/anaconda3\nrename original anaconda folder (to be sure its not used later)\nmv \/home\/uname\/anaconda3 \/home\/uname\/anaconda3.bak\nreplace all occurrences of \"\/home\/uname\/anaconda3\" with \"\/home\/uname\/mountx\/anaconda3\".\ndo this in new anaconda folder, .conda, .bashrc, and your projects.\nI used PyCharm with no open project to do the replacing,\nsed in a shell might also work\nstart new anaconda shell and PyCharm to test it\nremove renamed original anaconda folder afterwards if it works\nrm -rf \/home\/uname\/anaconda3.bak\ndone\n\nworked fine like a PyCharm for me :)","Q_Score":9,"Tags":"python,anaconda,conda","A_Id":71395472,"CreationDate":"2018-08-21T23:05:00.000","Title":"anaconda .conda folder move from \/home\/usrxy to some other location","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"If python,numpy,pandas are installed in local dir,how to set env ,so that ,import numpy as np,import pandas as pd can work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":51959670,"Users Score":0,"Answer":"If you install in a virtualenv, then activating the virtualenv will take care of that for you. Otherwise, add the dir to your PYTHONPATH environment variable. (How this is done depends on your operating system.)","Q_Score":0,"Tags":"python,pandas","A_Id":51960145,"CreationDate":"2018-08-22T03:59:00.000","Title":"how to set env if python,pandas are installed in local dir","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Environment: Python-PCL, WIndows 10, Python 3.6\nI need to downsample point clouds to a specific number of points. These point clouds vary in size and hence I am stuck. From going through documentation, I understand there are only \nVoxelGrid, ConditionalOutlierRemoval ,StatisticalOutlierRemoval and RadiusOutlierRemoval   are the options available. \nIn VoxelGrid, the leaf size doesnt guarantee the number of points, Radius removal doesnt help in retaining the shape, and statistical outlier mostly helps in removing noise. \nIs there any solution to this? It is possible to use numpy.random.choice()and hoping for a miracle? \nEDIT: numpy.random.choice works but only if you don't care about the geometric shape of your point cloud, which I do. Anyway to use VoxelGrid dynamically?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3390,"Q_Id":51964798,"Users Score":1,"Answer":"Unfortunately, the answer is no. The number of output points using PCL's VoxelGrid is always going to be a function of the number of occupied voxels. The only way to control the number of occupied voxels is by altering the leaf size, and there is no dynamic way of doing this.\nAlternately, you may have luck using Farthest Point Sampling, as it would allow you to select N points and has nice blue noise properties, but to the best of my knowledge this is not available in PCL.","Q_Score":3,"Tags":"python,numpy,point-clouds,downsampling","A_Id":51976804,"CreationDate":"2018-08-22T10:25:00.000","Title":"Downsampling point clouds to specific number of points while retaining shape","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"First of all, I can't use any executables. I need to do this in pure Python but sadly requests and BS4 doesn't support JS pages and Selenium needs a webdriver which is an executable.\nDoes anyone knows \/ Is there any way to scrape a JS Rendered page using purely Python and it's modules without having to run any exe?\nI'm not asking for exact solutions, only for the method and modules, if it's \neven possible.\nThank you for reading this and thank you for any constructive comments!\nHave a nice day!\nFor the full context: I'm trying to run a web-scraping script on a daily basis on a cloud that doesn't allows running any exes. Tried it with Selenium and PhantomJS but got a no permission error.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":51965133,"Users Score":0,"Answer":"Sorry for the misunderstanding, just noticed that the free version of the cloud didn't give permission for these. I got a paid one and it now works like a charm.","Q_Score":1,"Tags":"python,python-3.x,web-scraping","A_Id":51965854,"CreationDate":"2018-08-22T10:46:00.000","Title":"Any way to scrape a JS Rendered page without using executables in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i want to do something as a parametric study in Abaqus, where the parameter i am changing is a part of the assembly\/geometry. \nImagine the following:\nA cube is hanging on 8 ropes. Each two of the 8 ropes line up in one corner of a room. the other ends of the ropes merge with the room diagonal of the cube. It's something like a cable-driven parallel robot\/rope robot.\nNow, i want to calculate the forces in the ropes in different positions of the cube, while only 7 of the 8 ropes are actually used. That means i have 8 simulations for each position of my cube. \nI wrote a matlab script to generate the nodes and wires of the cube in different positions and angle of rotations so i can copy them into an input file for Abaqus. \nSince I'm new to Abaqus scripting etc, i wonder which is the best way to make this work.\nwould you guys generate 8 input files for one position of the cube and calculate \nthem manually or is there a way to let abaqus somehow iterate different assemblys?\nI guess i should wright a python script, but i don't know how to make the ropes the parameter that is changing.\nAny help is appreciated!\nThanks, Tobi","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":854,"Q_Id":51966721,"Users Score":0,"Answer":"In case someon is interested, i was able to do it the following way:\nI created a model in abaqus till the point, i could have started the job. Then i took the .jnl file (which is created automaticaly by abaqus) and saved it as a .py file. Then i modified this script by defining every single point as a variable and every wire for the parts as tuples, consisting out of the variables. Than i made for loops and for every 9 cases unique wire definitions, which i called during the loop. During the loop also the constraints were changed and the job were started. I also made a field output request for the endnodes of the ropes (representing motors) for there coordinates and reaction force (the same nodes are the bc pinned)\nThen i saved the fieldoutput in a certain simple txt file which i was able to analyse via matlab.\nThen i wrote a matlab script which created the points, attached them to the python script, copied it to a unique directory and even started the job. \nThis way, i was able to do geometric parametric studies in abaqus using matlab and python.\nCode will be uploaded soon","Q_Score":0,"Tags":"python,abaqus","A_Id":52174746,"CreationDate":"2018-08-22T12:17:00.000","Title":"Abaqus: parametric geometry\/assembly in Inputfile or Python script?","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 want to make my display tables bigger so users can see the tables better when that are used in conjunction with Jupyter RISE (slide shows).  \nHow do I do that? \nI don't need to show more columns, but rather I want the table to fill up the whole width of the Jupyter RISE slide.\nAny idea on how to do that?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":509,"Q_Id":51967445,"Users Score":0,"Answer":"If df is a pandas.DataFrame object.\nYou can do: \ndf.style.set_properties(**{'max-width': '200px', 'font-size': '15pt'})","Q_Score":2,"Tags":"python,pandas,jupyter-notebook","A_Id":56978954,"CreationDate":"2018-08-22T12:57:00.000","Title":"Pandas DataFrame Display in Jupyter Notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been playing around with pythreejs, and, while it seems to be a good solution to the problem of visualizing 3D graphics in a jupyter notebook, I haven't been able to find any documentation about what jupyter is actually doing under the hood or what API exists for managing the widget. Currently, when I make a pythreejs plot (e.g., by calling display() on a pythreejs.Renderer object), I get a tiny little output window. How can I edit the size (and other properties) of this window? How can I see what the properties are?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":274,"Q_Id":51967822,"Users Score":2,"Answer":"I discovered by experimentation that this can be controlled by passing the width and height parameters to the pythreejs.Renderer constructor. I would, however, appreciate any answer that points me toward better documentation for pythreejs or some philosophy regarding why\/how certain aspects of the three.js API were modified for Python's API.","Q_Score":1,"Tags":"python,three.js,widget,jupyter-notebook","A_Id":51971724,"CreationDate":"2018-08-22T13:17:00.000","Title":"How to make jupyter pythreejs plots larger?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python 3, I'd do something like this:\n\"{0:Y-M-d H:m:?.???}\".format(datetime.datetime.now())\nHowever, having searched a bit, it would be nice to have a canonical answer somewhere.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":360,"Q_Id":51967833,"Users Score":0,"Answer":"Ultimately, i chose not to use a timestamp but instead of treat it as an integer and store seconds since epoch. This is effects the same outcome with much less drama. Athena has all the functions one needs to convert these ints into dates for date math. So it is just easier.","Q_Score":1,"Tags":"python-3.x,amazon-athena,presto","A_Id":52855836,"CreationDate":"2018-08-22T13:18:00.000","Title":"What is the strftime config for an amazon athena timestamp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python 3, I'd do something like this:\n\"{0:Y-M-d H:m:?.???}\".format(datetime.datetime.now())\nHowever, having searched a bit, it would be nice to have a canonical answer somewhere.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":360,"Q_Id":51967833,"Users Score":1,"Answer":"Late to the game and I like your answer of just using total seconds but here's how I got athena (using awswrangler) to work with datetime & strftime\nquery_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')\nquery_statement = f\"SELECT * FROM table where datetime_col > timestamp '{query_date}'\"\nmy datetime_col has 3 milli seconds but it was not necessary in my query","Q_Score":1,"Tags":"python-3.x,amazon-athena,presto","A_Id":70381158,"CreationDate":"2018-08-22T13:18:00.000","Title":"What is the strftime config for an amazon athena timestamp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a locally made Django website and I hosted it on Heroku, at the same time I push changes to anathor github repo. I am using built in Database to store data. Will other users be able to get the data that has been entered in the database from my repo (like user details) ?\nIf so how to prevent it from happening ? Solutions like adding files to .gitignore will also prevent pushing to Heroku.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":152,"Q_Id":51968194,"Users Score":0,"Answer":"The code itself wouldn't be enough to get access to the database. For that you need the db name and password, which shouldn't be in your git repo at all.\nOn Heroku you use environment variables - which are set automatically by the postgres add-on - along with the dj_database_url library which turns that into the relevant values in the Django DATABASES setting.","Q_Score":0,"Tags":"python,django,github,hosting","A_Id":51968425,"CreationDate":"2018-08-22T13:38:00.000","Title":"Will making a Django website public on github let others get the data in its database ? If so how to prevent it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to write a simple check code which reads the log filename (after backup) from a given directory and gives information if log with present date was created or if it wasn't. Code should and with exit = 0 (TRUE) or exit = 2 (FALSE). Log is constructed from name and current date eg. log_2018_08_22)\nI`m getting error AttributeError: 'str' object has no attribute 'exists'. Please, any one may help me with it? Im not really familiar with coding yet :\\       \nimport datetime\n import pathlib\n import sys\n import os\nos.path.abspath(\"C:\\Test\")\nfile = \"backup_{:%Y_%m_%d}.log\"\npath = file.format(datetime.datetime.now())\nif file.exists():\n    print(\"File exist\")\n    sys.exit(0);\nelse:\n    print(\"File not exist\")\n    sys.exit(2);","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":51968817,"Users Score":0,"Answer":"Ive modified the script and now its working. Case closed :)\n#!\/usr\/bin\/python\nfrom pathlib import Path\nimport sys\nimport datetime\nmy_file = Path(\"C:\/Test\/backup_{:%Y_%m_%d}.log\".format(datetime.datetime.now()))\nif my_file.is_file():\n    print(\"Found it\")\n    sys.exit(0)\nelse:\n    print(\"Cant find it\")\n    sys.exit(2)","Q_Score":0,"Tags":"python-3.x","A_Id":51974844,"CreationDate":"2018-08-22T14:12:00.000","Title":"check log script with present date","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to write a simple check code which reads the log filename (after backup) from a given directory and gives information if log with present date was created or if it wasn't. Code should and with exit = 0 (TRUE) or exit = 2 (FALSE). Log is constructed from name and current date eg. log_2018_08_22)\nI`m getting error AttributeError: 'str' object has no attribute 'exists'. Please, any one may help me with it? Im not really familiar with coding yet :\\       \nimport datetime\n import pathlib\n import sys\n import os\nos.path.abspath(\"C:\\Test\")\nfile = \"backup_{:%Y_%m_%d}.log\"\npath = file.format(datetime.datetime.now())\nif file.exists():\n    print(\"File exist\")\n    sys.exit(0);\nelse:\n    print(\"File not exist\")\n    sys.exit(2);","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":51968817,"Users Score":0,"Answer":"Thanks that did the trick but now i`m getting strange error. file = open(filename)\nFileNotFoundError: [Errno 2] No such file or directory: 'backup_2018_08_22.log'\nbut i have file backup_2018_08_22.log in C:\\Test... \nBelow is the code. One more question this script should be working on Ubuntu and there paths are slighty different.\n#!\/usr\/bin\/python\n  import datetime\n  import sys\n  import os\nos.path.abspath(\"C:\\Test\")\nfilename = \"backup_{:%Y_%m_%d}.log\".format(datetime.datetime.now())\nfile = open(filename)\nif file.exists():\n    print(\"File exist\")\n    sys.exit(0);\nelse:\n    print(\"File not exist\")\n    sys.exit(2);","Q_Score":0,"Tags":"python-3.x","A_Id":51972005,"CreationDate":"2018-08-22T14:12:00.000","Title":"check log script with present date","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to run multiple python scripts simultaneously in vsc. I mean while there is already a script running, I would like to run another script. When I try I get \"code is already running\".\nIn spyder-ide I simply open a new IPython console and run the new script in this newly opened console.","AnswerCount":7,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":29448,"Q_Id":51969662,"Users Score":9,"Answer":"You can always open a terminal terminal window -- with either Python: Create Terminal or Open New Terminal -- and launch the script(s) manually in separate terminals.","Q_Score":7,"Tags":"python,visual-studio-code,spyder","A_Id":51973772,"CreationDate":"2018-08-22T14:55:00.000","Title":"run multiple python scripts at the same time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to run multiple python scripts simultaneously in vsc. I mean while there is already a script running, I would like to run another script. When I try I get \"code is already running\".\nIn spyder-ide I simply open a new IPython console and run the new script in this newly opened console.","AnswerCount":7,"Available Count":6,"Score":-0.0285636566,"is_accepted":false,"ViewCount":29448,"Q_Id":51969662,"Users Score":-1,"Answer":"open a new angle of the visual studio then open the other file in this new one, so you can run it","Q_Score":7,"Tags":"python,visual-studio-code,spyder","A_Id":68414541,"CreationDate":"2018-08-22T14:55:00.000","Title":"run multiple python scripts at the same time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to run multiple python scripts simultaneously in vsc. I mean while there is already a script running, I would like to run another script. When I try I get \"code is already running\".\nIn spyder-ide I simply open a new IPython console and run the new script in this newly opened console.","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":29448,"Q_Id":51969662,"Users Score":1,"Answer":"You only need Ctrl + Shift + `\nIt will create a new terminal and you can run another script.","Q_Score":7,"Tags":"python,visual-studio-code,spyder","A_Id":67443964,"CreationDate":"2018-08-22T14:55:00.000","Title":"run multiple python scripts at the same time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to run multiple python scripts simultaneously in vsc. I mean while there is already a script running, I would like to run another script. When I try I get \"code is already running\".\nIn spyder-ide I simply open a new IPython console and run the new script in this newly opened console.","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":29448,"Q_Id":51969662,"Users Score":1,"Answer":"There is an extension called \"Code Runner\" extension developped by Jun Han, after install it, right click on the second script, select \"Run Code\".","Q_Score":7,"Tags":"python,visual-studio-code,spyder","A_Id":70345576,"CreationDate":"2018-08-22T14:55:00.000","Title":"run multiple python scripts at the same time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to run multiple python scripts simultaneously in vsc. I mean while there is already a script running, I would like to run another script. When I try I get \"code is already running\".\nIn spyder-ide I simply open a new IPython console and run the new script in this newly opened console.","AnswerCount":7,"Available Count":6,"Score":-0.0285636566,"is_accepted":false,"ViewCount":29448,"Q_Id":51969662,"Users Score":-1,"Answer":"You could install PyCharm which has a plugin called 'Multirun'.This allows you to run several python files in parallel. I had the same issue as you and fixed it this way.","Q_Score":7,"Tags":"python,visual-studio-code,spyder","A_Id":59066727,"CreationDate":"2018-08-22T14:55:00.000","Title":"run multiple python scripts at the same time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to run multiple python scripts simultaneously in vsc. I mean while there is already a script running, I would like to run another script. When I try I get \"code is already running\".\nIn spyder-ide I simply open a new IPython console and run the new script in this newly opened console.","AnswerCount":7,"Available Count":6,"Score":-0.0285636566,"is_accepted":false,"ViewCount":29448,"Q_Id":51969662,"Users Score":-1,"Answer":"Use Sublime Text 3 and run your script by Ctrl + B shortcut","Q_Score":7,"Tags":"python,visual-studio-code,spyder","A_Id":67443731,"CreationDate":"2018-08-22T14:55:00.000","Title":"run multiple python scripts at the same time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building my first web application and I've got a question around process and best practice, I'm hoping the expertise on this website might be give me a bit of direction.\nEssentially, all the MVP is doing is going to be writing an overlay onto an image and presenting this back to the user, as follows;\n\nUser uploads picture via web form (into AWS S3) - to do\nPython script executes (in lambda) and creates image overlay, saves new image back into S3 - complete\nUser is presented back with new image to download - to do\n\nI've been running this locally as sort of a proof of concept and was planning on linking up with S3 today but then suddenly realised, what happens when there are two concurrent users and two images being uploaded with different filenames with two separate lambda functions working?\nThe only solution I could think of is having the image renamed upon upload with a record inserted into an RDS, then the lambda function to run upon record insertion against the new image, which would resolve half of it, but then how would I get the correct image relayed back to the user?\nI'll be clear, I have next to no experience in web development, I want the front end to be as dumb as possible and run everything in Python (I'm a data scientist, I can write Python for data analysis but no experience as a software dev!)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":377,"Q_Id":51970168,"Users Score":0,"Answer":"You don't really need an RDS, just invoke your lambda synchronously from the browser.\nSo \n\nUpload file to S3, using a randomized file name\nInvoke your lambda synchronously, passing it the file name\nHave your lambda read the file, convert it, and respond with either the file itself (binary responses aren't trivial), or a path to the converted file in S3.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,architecture,software-design","A_Id":51976456,"CreationDate":"2018-08-22T15:24:00.000","Title":"Uploading an image to S3 and manipulating with Python in Lambda - best practice","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python app that I use locally that needs to be launched via pipenv run python3 appname.py in order to load virtual environment with installed dependencies. This is all on macOS.\nWhat I want to achieve is to be able to run this app from anywhere with $ appname [args].\nSo what I did was:\n\nadd #!\/usr\/bin\/env pipenv run python3 to appname.py;\nmake that file executable with chmod +x appname.py;\nmake symlink with ln -s \/path\/to\/appname.py ~\/.bin\/appname;\nput ~\/.bin on my $PATH.\n\nNow when I launch $ appname, pipenv creates a new virtual environment in the ~\/.bin folder and complains about missing dependencies, all instead of following through into the actual location of the script.\nIs there a way to overcome this? Or maybe a better way to achieve what I want?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":486,"Q_Id":51970877,"Users Score":0,"Answer":"For my purposes a more sensible thing to do was freezing my code by packaging it (along with all dependencies) into an executable with pyinstaller.\nWhat I did was:\n\nInstalled pyinstaller as dev dependency with pipenv install --dev pyinstaller;\nLaunched pipenv shell in the project directory;\nPackaged the app with pyinstaller --onefile appname.py;\nMoved the resulting self-containing [project path]\/dist\/appname executable into my ~\/.bin directory.\n\nThere were some unrelated issues to overcome, but otherwise worked perfectly for me.","Q_Score":1,"Tags":"python,symlink,shebang,pipenv","A_Id":51986874,"CreationDate":"2018-08-22T16:02:00.000","Title":"Running pipenv environment via $PATH symlink to executable .py file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Contextualisation\nI am writing a program that is able to read data from a sensor and then do something with it. Currently I want it to be sent to a server. I have two processes that communicate through sockets, one that reads the data and stores it to a temporary file, and other that reads the temporary file, sends the data to the server.\nProblem\nThe problem has actually never presented itself in the testing, however I have realised that it is highly possible that if the sampling frequency is high both processes coincide in trying to read\/write to the file at the same time (not that they request it exactly at the same time, but that one tries to open it before the other has closed it).\nEven if this does not raise an error (for what I read online, some OS do not put locks into the file) it may cause huge version incompatibility errors, leading to lost pieces of data. For this reason, this way of handling the data does not look very appropriate.\nMy own idea\/approach\nI thought to use a file-like object in memory (data buffer). I have no experience with this concept in Python, so I have researched a bit and I understand that [a buffer] is like a file that is kept in memory while the program is executing and that has very similar properties to that of a standard system file. I thought it might be a good idea to use it, however I could not find a solution to some of this inconveniences:\n\nSince it's still like a file (file-like object), could it not be the case that if the two processes coincide in their opeartions on the object, version incompatibility errors\/bugs could raise? I only need to append data with one process (at the end) and remove data from the beginning with the other (as some sort of a queue). Does this Python functionality permit this, and if so, which methods may I exactly look into in the docs?\n\nFor the explanation above, I thought about literally using queues; however this might be unefficient execution time-wise (appending to a list is ratherfast, but appending to a pandas object is around 1000 times slower according to a test I did in my own machine to see which object type would fit best). Is there an object, if not a file-like one, that lets me do this and is efficient? I know efficiency is subjective, so let's say 100 appends per second with no noticeable lag (timestamps are important in this case).\n\nSince I am using two different processes and these do not share memory in Python, is it still possible to point to the same memory address while operating on the file-like object? I communicate them with sockets as I said, but that method is afaik call-by-value, not reference; so this looks like a serious problem to me (maybe it is necessary to merge them into two threads instead of different python processes?)\n\n\nMay you comment asking for any other detail if needed, I will be very happy to answer.\nEdits: questions asked in comments:\n\nHow are you creating these processes? Through a Python module like\nmultiprocessing or subprocess, or some other way?\n\nI am running them as two completely separate programs. Each has a different main python file that is called by a shell script; however, I am flexible to changing this behaviour if needed.\nOn the other hand, the process that reads the data from the sensors has two threads: one that literally reads the data, and other that listens to sockets requests.\n\nwhat type of data are you getting from the sensor and sending to the\nserver?\n\nI am sending tables that contain floats, generally, however sensors may also produce video stream or other sort of data structures.\n\nMisconception of Queue | pandas\n\nI know a queue has nothing to do with a dataframe; I am just saying I tried to use a dataframe and it didn't perform well because it's thought to pre-allocate the memory space it needs (if I'm right). I am just expressing my concerns in the performance of the solution.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1862,"Q_Id":51971829,"Users Score":2,"Answer":"You've misunderstood what a file-like object is. \"File-like object\" describes the interface an object presents - methods like read or write, and line-by-line iteration. It doesn't say anything about whether it stores data in memory. Regular file objects are file-like objects. File objects for OS-level pipes are file-like objects. io.StringIO and io.BytesIO objects are file-like objects, and those actually do work like you seem to have been thinking.\nRather than thinking in terms of file-like objects, you should probably think about what OS-level mechanism you want to use to communicate between your processes. You've already got sockets; why not send data between your processes with a socket? A pipe would be another option. Shared memory is possible but platform-dependent and tricky; it's probably not the best option.","Q_Score":3,"Tags":"python,python-3.x,buffer","A_Id":51972129,"CreationDate":"2018-08-22T17:01:00.000","Title":"Create file-like object for data buffer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to create a hardlink\/symlink on networkshare that is on linux but from windows environemnt which has access to that share?\nLets say that I have a file on networkshare:\n\\share\\test.txt \nand I want to create hardlink (or symlink) here:\n\\share\\links\\test.txt \nBut I can only use python which is installed on windows machine with access to that share.\nThanks for any help.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":50,"Q_Id":51973372,"Users Score":-1,"Answer":"Not over cifs (windows share) protocol. From the windows machine viewpoint the symlinks don't even exist, they appear and behave as normal files, and windows has no way to create or even differentiate them when using this protocol.\nYou could use paramiko to automate a ssh session to the linux machine and create the symlinks using this method.","Q_Score":0,"Tags":"python,linux,windows,symlink,hardlink","A_Id":51973665,"CreationDate":"2018-08-22T18:50:00.000","Title":"Create hardlink\/symlink from windows on unix networkshare","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"i'm trying use PyBeacon package to make some Eddystone-UID using Raspberry PI 3+ device. Executing PyBeacon -i 321654987654321a321654a456b54699 command, for example, and using the Google App called \"Beacon Tools\" to register the Eddystone-UID beacon (ok detected into unregistered layer), when i try to register, the app tell me \"failed to connect\".\nWhen i use a hardware beacon with Eddystone support, i must to config each beacon in \"configure mode\" to can access OK using the app.\nIs it possible register into Google Beacon Plataform the eddystone beacons created using PyBeacon package?\nthanks alot!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":427,"Q_Id":51973957,"Users Score":0,"Answer":"The user interface for the Beacon Tools app is confusing.  It does two very different things:\n\nRegistration - this sets up the beacon on Google's servers and ties it to your Google account.\nProvisioning - this tries to set the beacon hardware configuration (identifiers, transmission rate, etc.) on the physical hardware beacon itself by connecting to the beacon hardware over a bluetooth connection.  This only works on a hardware beacons that implement Google's Eddystone Bluetooth GATT registration service. (Most hardware beacons don't even do this.) And even then, this only works when you beacon is in configurable mode. \n\nThe fact that you see \"failed to connect\" suggest you are doing 2 when really what you want to do is 1.","Q_Score":0,"Tags":"python,raspberry-pi3,eddystone","A_Id":51974208,"CreationDate":"2018-08-22T19:33:00.000","Title":"PyBeacon eddystone-UID","Data Science and Machine Learning":0,"Database and SQL":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 get this error when I try to import wxPython from python 3.7. I have google around but to no luck. Any help would be appreciated.\n\nTraceback (most recent call last):\n    File \"C:\/Users\/STEVE\/Desktop\/Python Files\/Chat Bot\/Joyla\/joyla.py\", line 3, in \n      import wx\n    File \"C:\\Users\\STEVE\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\wx__init__.py\", line 17, in \n      from wx.core import *\n    File \"C:\\Users\\STEVE\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\wx\\core.py\", line 12, in \n      from ._core import *\n  ImportError: DLL load failed: The specified module could not be found.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":742,"Q_Id":51976677,"Users Score":1,"Answer":"I had this same problem with the same exact error message. It turned out that I have mistakenly installed the 32 bit version of python instead of the 64 bit version.\nThe python web site will trick you  - if you just use the download link on the top page it will give you the 32 bit version. You have to go to the downloads page, then windows, then look for the 64 bit version - \"Windows x86-64 executable installer\". \nThe actual file name of the 64 bit download is\n    \"python-3.7.0-amd64.exe\". \nIf you get the 32 bit version the file name will be \n    \"python-3.7.0.exe\".\nAnother way to check, after installing, is to open a python console (or a command prompt and type \"python\" to open the python command line).\nIf you have the 32 bit version it will say:\n    Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) \n        [MSC v.1914 32 bit (Intel)] on win32\nIf you have the 64 bit version it will say:\n    Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) \n        [MSC v.1914 64 bit (AMD64)] on win32","Q_Score":0,"Tags":"python,dll,wxpython,importerror","A_Id":52228847,"CreationDate":"2018-08-23T00:01:00.000","Title":"ImprtError when importing wxPython from Python3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write a script to find out the RAM-ROM usage (RAM = bss + data,\nROM = rodata + text) of and object file. I tried with a GreenHills compiler tool that generates a report, but for some cases it doesn't work. Is there a way to find the memory sections to calculate the usage ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":739,"Q_Id":51980841,"Users Score":0,"Answer":"@B. Vlad  You should count alignments when allocations in memory are done too. As suggested above, the only reliable way is to use linker output, as it will provide \"memory\" map of the objects with addresses they are loaded to( before loaded in memory though).","Q_Score":0,"Tags":"c++,c,windows,python-3.x","A_Id":51991026,"CreationDate":"2018-08-23T07:53:00.000","Title":"How to find the ram rom usage (.bss .text .rodata .data) of an object file *.o?","Data 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 keras\/tensorflow on google colaboratory and I need to go back to previous versions of them. \nThe problem is when I run !pip install q keras==1.2.2 , the kernel shows keras 1.2.2 installed but when I check it using keras.__version_ it shows 2.1.6 . And same case is with tensorflow. \nHow do I fix this?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":28843,"Q_Id":51981095,"Users Score":3,"Answer":"In the latest colab, when you upgrade or downgrade a module, in the output cell you will automatically see the statement:\n\"WARNING: The following packages were previously imported in this runtime:\n  [scipy]\nYou must restart the runtime in order to use newly installed versions.\n\" asking you to restart the runtime along with a button for it.","Q_Score":15,"Tags":"python,tensorflow,keras,google-colaboratory","A_Id":58063570,"CreationDate":"2018-08-23T08:10:00.000","Title":"How to change Keras\/tensorflow version in Google colab?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to manipulate existing svg files in python? I know the svgwrite package but it only creates new svg files... I just want to add 3 numbers to an existing svg file. It should be only an update showing the old svg file with these 3 new numbers.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1445,"Q_Id":51982876,"Users Score":0,"Answer":"No. As with other text files, you need to read the file to memory, modify and then write the modified file to disk.","Q_Score":1,"Tags":"python,svg,svgwrite","A_Id":51983709,"CreationDate":"2018-08-23T09:46:00.000","Title":"Manipulating SVG-files with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed python 3.7.0 at my new laptop which runs with Windows.\nHowever, when I enter at the command prompt where python3 then I get INFO: Could not find files for the given pattern(s).\nBut when I enter at the command prompt where python then I get C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python37\\python.exe.\nI am quite confused because (if I remember right) when I had installed python 3.6.6 at my other laptop then essentially the opposite was happening; where python3 was returning the latter message and where python was returning the former message and for me this makes more sense since I have installed in both cases a python 3 version.\nWhy is this happening?\nWhat am I missing?\nJust to also mention that I run this python with PyCharm and everything works right so far as a python 3 version but I was just wondering about that.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1311,"Q_Id":51983028,"Users Score":1,"Answer":"Try running python only in cmd, if you have only one version of python installed then there is no need to specify python3.","Q_Score":1,"Tags":"python,python-3.x","A_Id":51983403,"CreationDate":"2018-08-23T09:53:00.000","Title":"Python 3.7.0- where python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"how to install twilio via pip?\nI tried to install twilio python module\nbut i can't install it \ni get following error \nno Module named twilio\nWhen trying to install twilio\npip install twilio\nI get the following error.\npyopenssl 18.0.0 has requirement six>=1.5.2, but you'll have six 1.4.1 which is incompatible.\nCannot uninstall 'pyOpenSSL'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.\ni got the answer and installed\npip install --ignore-installed twilio\nbut i get following error\n\nCould not install packages due to an EnvironmentError: [Errno 13] Permission denied: '\/Library\/Python\/2.7\/site-packages\/pytz-2018.5.dist-info'\nConsider using the `--user` option or check the permissions.\n\ni have anaconda installed \nis this a problem?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2822,"Q_Id":51985401,"Users Score":-1,"Answer":"step1:download python-2.7.15.msi\nstep 2:install and If your system does not have Python added to your PATH while installing\n\"add python exe to path\"\nstep 3:go  C:\\Python27\\Scripts of your system\nstep4:in command prompt C:\\Python27\\Scripts>pip install twilio\nstep 5:after installation is done >python command line\n import twilio\nprint(twilio.version)\nstep 6:if u get the version ...you are done","Q_Score":2,"Tags":"python,module,installation,twilio","A_Id":53578904,"CreationDate":"2018-08-23T12:03:00.000","Title":"How to install twilio via pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run this python script below:\nimport pandas as pd\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.metrics import accuracy_score\nfrom sklearn.metrics import confusion_matrix \nIt gives me the error below.\n\nWarning (from warnings module):   File\n  \"C:\\Users\\Dipali\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\sklearn\\ensemble\\weight_boosting.py\",\n  line 29     from numpy.core.umath_tests import inner1d\n  DeprecationWarning: numpy.core.umath_tests is an internal NumPy module\n  and should not be imported. It will be removed in a future NumPy\n  release.\n\nWhat I need to do?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":10943,"Q_Id":51986414,"Users Score":1,"Answer":"Alright so this is a deprecation warning on Python 3.x. \nSince, this is warning your code will run fine. It is not an error (When the code stops running by graceful degradation). \nThe solution to remove this error is as follow:\n\nAs I can see you have Scikit-Learn version 0.19.2 installed you need to get the latest version. To do so enter the following command  pip3 install --force-reinstall scikit-learn==0.20rc1  This will install the latest versions of scikit-learn, scipy and numpy. Your deprecation warnings will now not exist. \nAlthough you'll next get a new warning. This time regarding the file in the scikit-learn library called cloudpickle \\sklearn\\externals\\joblib\\externals\\cloudpickle\\cloudpickle.py.  To overcome this warning you got to edit the code which python shows us.  Just do a sudo idle3 onto the file and edit the lines which says :  import imp  from imp import find_module to import importlib  Next go to the funtion find_module and change the line  file, path, description = find_module(path) to file, path, description = importlib.utils.find_spec(path).\n\nThis must solve the deprecation warnings in the scikit-learn libraries.","Q_Score":7,"Tags":"python,scikit-learn","A_Id":52438763,"CreationDate":"2018-08-23T12:58:00.000","Title":"DeprecationWarning: numpy.core.umath_tests","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python when we use pop method to remove an element from set why does it remove any random element? Instead of removing top element as per the stack's nature.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":51987093,"Users Score":1,"Answer":"Because a set is an un-ordered collection of items, by definition. There it no \"first\" or \"last\" element. So, it removes a random one. If you want order, use a list instead.","Q_Score":0,"Tags":"python,set,stack,programming-languages","A_Id":51987149,"CreationDate":"2018-08-23T13:35:00.000","Title":"Pop method removes random element instead of top element in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting this error\n\n-\"module 'cv2' has no attribute 'version'\n\nwhen I try to find version of cv2, but my import is executing fine without any error.\nI am confused about whether my openCV is working correctly or not?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":51987825,"Users Score":0,"Answer":"Your openCV is probably installed in another python version and pylint is having problem identifying. Try to locate where your openCV is installed and manually change it.","Q_Score":0,"Tags":"python,opencv,anaconda","A_Id":51989369,"CreationDate":"2018-08-23T14:10:00.000","Title":"python-openCV module not found error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently have a python script that launches an iTerm window and runs logcat on an android device. When what I am doing in the script is complete, I want to also have the ability to stop the logcat. I was originally just killing iTerm to stop the log, but this will not work going forward...is there anyway to programatically stop the log? (this is typically done by pressing ctr+c)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":721,"Q_Id":51988445,"Users Score":1,"Answer":"adb shell killall -2 logcat would gracefully stop all running logcat processes on the device.","Q_Score":0,"Tags":"python,scripting,adb,logcat","A_Id":51988613,"CreationDate":"2018-08-23T14:43:00.000","Title":"Script to stop logcat in terminal window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to retrieve the objects\/items (server name, host name, domain name, location, etc...) that are stored under the saved quote for a particular Softlayer account. Can someone help how to retrieve the objects within a quote? I could find a REST API (Python) to retrieve quote details (quote ID, status, etc..) but couldn't find a way to fetch objects within a quote.\nThanks!\nBest regards,\nKhelan Patel","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":51988650,"Users Score":0,"Answer":"Thanks Albert getRecalculatedOrderContainer is the thing I was looking for.","Q_Score":0,"Tags":"python,rest,ibm-cloud,ibm-cloud-infrastructure","A_Id":52010150,"CreationDate":"2018-08-23T14:53:00.000","Title":"How to retrieve objects from the sotlayer saved quote using Python API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Because of vision problems, I have to keep the font in my Python programs in pycharm larger than the default setting. When I execute any program, the run window comes up at the bottom and every time I have to start working on the Python code in the editor window, I have to close the run window using a mouse.\nIs there a way to close it using the keyboard shortcut? I could not find anything in the key map but there are so many settings that there is a chance that I may have missed it.\nI also tried with using the distraction free option and it works very well. However, when I tried to find something within the code, it does not bring up the in-line window that allows me to type the keyword is searched for.\nPlease suggest if there is any way to close the run window or if there is any workaround so that I can return to working in a larger editor window.\nThank you for any inputs","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":250,"Q_Id":51990919,"Users Score":2,"Answer":"shift+esc will hide the run window from within PyCharm. \nIf you want to access the run menu use: ctrl+shift+A\nYou can get a helpful cheatsheet of commands from within PyCharm by going to help -> Keymap Reference. This will provide the default key mapping for Windows and Linux","Q_Score":3,"Tags":"python,pycharm","A_Id":51991044,"CreationDate":"2018-08-23T17:03:00.000","Title":"Is there a way in pycharm to close the run window and just look at the editor window using a keyboard shortcut","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to create an array with the form [1, 2, 4, 8, 16, 32, ...]. Not always with that spacing between numbers.\nIs there a linspace\/arange type function which allows me to create vector of non equally spaced numbers?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":663,"Q_Id":51993428,"Users Score":4,"Answer":"Yes, there is also logspace and geomspace in NumPy.\nnp.geomspace(1,32,6) gives you array([ 1.,  2.,  4.,  8., 16., 32.])","Q_Score":1,"Tags":"python,numpy","A_Id":51993668,"CreationDate":"2018-08-23T19:57:00.000","Title":"Function to create a non equally spaced array in numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I've spent the good majority of a month on this issue. I'm looking for a way to extract geometry elements (polylines, text, arcs, etc.) from a vectorized PDF organised by the file's OCGs (Optional Content Groups), which are basically PDF layers. Using PDFminer I was able to extract geometry (LTCurves, LTTextBoxes, LTLines, etc.); using PyPDF2, I was able to view how many OCGs were in the PDF, though I was not able to access geometry associated with that OCG. There were a few hacky scripts I've seen and tried online that may have been able to solve this problem, but to no avail. I even resorted to opening the raw PDF data in a text editor and half hazardly removing parts of it to see if I could come up with some custom parsing technique to do this, but again to no avail. Adobe's PDF manual is minimal at best, so that was no help when I was attempting to create a parser. Does anyone know a solution to this. \nAt this point, I'm open to a solution in any language, using any OS (though I would prefer a solution using Python 3 on Windows or Linux), as long as it is open source \/ free. \nCan anyone here help end this rabbit hole of darkness? Much appreciated!","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1724,"Q_Id":51993507,"Users Score":5,"Answer":"A PDF document consists of two \"types\" of data. There is an object oriented \"structure\" to the document to divide it into pages, and carry meta data (like, for instance, there is this list of Optional Content Groups), and there is a stream oriented list of marking operators that actually \"draw\" content onto the page. \nThe fact that there are OCG's, and their names, and a bit about them is stored on object oriented content, and can be extracted by parsing the object content fairly easily. But the membership of the OCG's is NOT stored in the object structure. It can only be found by parsing the Content Stream. A group of marking operators is a member of a particular OCG group when it is preceeded by the content operator \/OC \/optionacontentgroupname BDC and followed by the operator EMC.\nParsing a content stream is a less than trivial task. There are many tools out there that will do this for you. I would not, myself, attempt to build such a parser from scratch. There is little value in re-writing the wheel.\nThe complete syntax of PDF is available from many sources. Search the web for \"PDF Specification 1.7\", or \"ISO32000-1:2008\". It is a daunting document to read, but it does supply all of the information needed to create both and object and a content parser","Q_Score":1,"Tags":"python,pdf,pypdf2,pdfminer,ocg","A_Id":52012277,"CreationDate":"2018-08-23T20:04:00.000","Title":"Extract Geometry Elements from PDF by OCG (by Layer)","Data Science and Machine Learning":0,"Database and SQL":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 the numpy.argsort function (or a code that makes the same) but ignoring a concrete value, for example -1, and keeping it in the resulted array\nIf this is the list: [5,8,1,-1,2,4], I need a result like [3,4,0,-1,1,2]\nHow can I do it?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":203,"Q_Id":51994112,"Users Score":2,"Answer":"Locate and remove each of the values to ignore, remembering their positions.  For instance, in this case, you might store the index and value as ignore = (3, -1).\nSort the remaining list as usual.\nReinsert the missing element: mylist.insert(ignore[0], ignore[1])\nDoes that get you moving?","Q_Score":0,"Tags":"python,arrays,sorting","A_Id":51994159,"CreationDate":"2018-08-23T20:53:00.000","Title":"Sort a list, but leave a specified value in place","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Spyder 2.2.5 with Python 2.7 (I cannot use any other version of either of these - so updating not an option). I have set the Syntax color scheme in Tools > Preferences > Editor > Syntax color scheme to Spyder\/Dark. This successfully changes the color scheme on py scripts to the intended dark color scheme. However, other file types don't change. They remain the default black on white background (in particular I'm trying work with my bashrc file). \nI've never seen this problem before, but I've only worked on newer versions of both Spyder and Python 3.x. \nAny ideas why this is happening? Or can anyone point to a related solution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":166,"Q_Id":51995162,"Users Score":1,"Answer":"(Spyder maintainer here) I think that version of Spyder applied our syntax highlighting themes to Python files only, sorry.","Q_Score":0,"Tags":"python-2.7,spyder,color-scheme","A_Id":52005992,"CreationDate":"2018-08-23T22:34:00.000","Title":"Why is Spyder 2.2.5 not using syntax color scheme on non-py scripts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know how to debug a flask application in Pycharm. The question is whether this is also possible in IntelliJ.\nI have my flask application debugging in Pycharm but one thing I could do in IntelliJ was evaluate expressions inline by pressing the alt + left mouse click. This isn't available in Pycharm so I wanted to run my Flask application in IntelliJ but there isn't a Flask template. \nIs it possible to add a Flask template to the Run\/Debug configuration? I tried looking for a plugin but couldn't find that either.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1566,"Q_Id":51995696,"Users Score":0,"Answer":"Yes, you can. Just setup the proper parameters for Run script into PyCharm IDE. After that you can debug it as usual py script. In PyCharm you can evaluate any line in debug mode too.","Q_Score":1,"Tags":"python,intellij-idea,flask","A_Id":51996045,"CreationDate":"2018-08-23T23:45:00.000","Title":"Can I debug Flask applications in IntelliJ?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to set up Google OAuth 2.0 on my homepage.\nOther things seem to be well set up, but CallBack url is a problem.\nI'm using \"https\" and also entered my callback url that starts with https in Google Oauth 2.0 console, but OAuth is still trying to callback configured with http url. How do I fix it?\nIf I go directly into the callback redirection url starting with https, it works fine.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":51996810,"Users Score":0,"Answer":"I solved this problem myself.\nSimply added it in the settings.py was solution.\nACCOUNT_DEFAULT_HTTP_PROTOCOL = \"https\"\nThat's all.","Q_Score":0,"Tags":"django,python-3.6,google-oauth,django-allauth","A_Id":52008496,"CreationDate":"2018-08-24T02:53:00.000","Title":"Google OAuth 2.0 keep trying to callback using \"http\" url","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We made an Image recognition API that accepts image URL and responds an image description. This process takes about 5-20 seconds.\nI have a huge CSV file with 200+ million rows of image URLs scraped from different sources. I found that the CSV file has duplicate image URLs from different sources. So I don't need to send all the URLs to image recognition API, I need to send only unique URLs to the API but I need to populate response from API to all the rows.\nI read the CSV file in chunks of 100K rows and created a set of unique Image URLs and process them in API and again populate the results back to the CSV file. But It ended up in memory issues (16 GB RAM), I can't able to create a set of unique Image URLs with 200+ million rows.\nAny suggestion?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":995,"Q_Id":52000223,"Users Score":0,"Answer":"Two possible approaches:\nSQL Select Distinct\nLoad the CSV file into a database and us SQL Select Distinct and export the query result as a Csv file. Some database let you define a CSV file as a table and let you run SQL queries on the CSV file\nSelect distinct URL from UrlTable\nSort the File\nYou could \n\nSort the file on the URL using your operating systems sort command (both Windows and Linux have Sort commands).\nRead the file and check if the URL is different from the last URL. You only need check the URL when it changes","Q_Score":0,"Tags":"python,pandas,csv,dataframe,duplicates","A_Id":52016745,"CreationDate":"2018-08-24T08:18:00.000","Title":"Python - How to remove duplicates in huge CSV file (200+ Million rows)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting the below error when trying to pip install mysql:\n\nbuilding '_mysql' extension\n          creating build\/temp.macosx-10.6-intel-2.7\n          \/usr\/bin\/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I\/usr\/local\/Cellar\/mysql\/8.0.12\/include\/mysql -I\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/include\/python2.7 -c _mysql.c -o build\/temp.macosx-10.6-intel-2.7\/_mysql.o\n          _mysql.c:44:10: fatal error: 'my_config.h' file not found\n          #include \"my_config.h\"\n                   ^~~~~~~~~~~~~\n          1 error generated.\n          error: command '\/usr\/bin\/clang' failed with exit status 1\n\nAny ideas?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":378,"Q_Id":52002400,"Users Score":2,"Answer":"you don't have my_config file. It is because you have not installed mysql on your computer. Try to install after setup mysql","Q_Score":1,"Tags":"python,mysql,macos,pip","A_Id":52054252,"CreationDate":"2018-08-24T10:21:00.000","Title":"pip install mysql error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there any support or library in python for opening \".wmf\" format files and converting them into arrays for further operations?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1883,"Q_Id":52002648,"Users Score":1,"Answer":"PIL only has wmf support on Windows","Q_Score":2,"Tags":"python,python-3.x,wmf","A_Id":56627812,"CreationDate":"2018-08-24T10:35:00.000","Title":"Is there a way to open a .wmf file in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some debugging statements that I need to print out from my Django out, but I cannot find which file to look for them. They do not appear in the access logs or the error logs. Where can I find the file which they appear?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1129,"Q_Id":52002793,"Users Score":1,"Answer":"They appear in your console where you run : python manage.py runserver\nOf course you need to trigger the functions where there are prints so they execute it.","Q_Score":1,"Tags":"python,django,apache,mod-wsgi","A_Id":52002845,"CreationDate":"2018-08-24T10:45:00.000","Title":"Where do print statements from Django app go?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"After the training is finished and I did the prediction on my network, I want to calculate \"precision\" and \"recall\" of my model, and then send it to log file of \"tensorboard\" to show the plot.\nwhile training, I send \"tensorboard\" function as a callback to keras. but after training is finished, I dont know how to add some more data to tensorboard to be plotted.\nI use keras for coding and tensorflow as its backend.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":52006745,"Users Score":0,"Answer":"I believe that you've already done that work: it's the same process as the validation (prediction and check) step you do after training.  You simply tally the results of the four categories (true\/false pos\/neg) and plug those counts into the equations (ratios) for precision and recall.","Q_Score":1,"Tags":"python,tensorflow,keras,tensorboard,precision-recall","A_Id":52006897,"CreationDate":"2018-08-24T14:36:00.000","Title":"how to add the overall \"precision\" and \"recall\" metrics to \"tensorboard\" log file, after training is finished?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two databases (each with 1000's of tables) which are supposed to reflect the same data but they come from two different sources. I compared two tables to see what the differences were, but to do that I joined the two on a common ID key. I checked the table manually to see what the ID key was, but when I have to check 1000's of tables its not practical to do so. \nIs there a way in pandas to find what column (or columns) in a table have only unique values?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":52007555,"Users Score":0,"Answer":"Use the Python library that allows you to query your database (pymysql, psycopg2, etc). Programmatically use the metadata available from the DB to iterate over the tables and columns. Dynamically create the SQL queries to compare \"select count(field) - count(distinct field) from table\". \nOr you could also potentially use the metadata to see which columns in each table are indexed.\nThe SQL query to pull the relevant metadata will vary based on the kind of DBMS.","Q_Score":0,"Tags":"python,sql,pandas,dataframe","A_Id":52007874,"CreationDate":"2018-08-24T15:27:00.000","Title":"Pandas find columns with unique values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dynamoDB table where I store sensor events.\n\nHASH KEY:  sensor id\nRANGE KEY: timestamp\nsensor info\n\nI now need a query for the latest event of every sensor.\nThe only solution I can come up with is to query the latest event for each sensor id. But that would be a lot of queries with 2000+ sensors. \nI don't want to scan the whole table to sort it out afterwards either since the table can grow quite fast.\nAny ideas?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4111,"Q_Id":52007936,"Users Score":2,"Answer":"You have to decide what is important to you and design your table(s) to match your use cases.\nYou say you want to query the last value for every sensor and that there are 2000+ sensors. What will you do with these 2000+ values? How often do you need these values and can the values be slightly out of date?\nOne solution would be to have two tables: one where you append historical values (time series data) and another table where you always update the most recent reading for each sensor. When you need the most recent sensor data, just scan this second table to get all your sensors\u2019 most recent values. It's as efficient as it gets for reads. For writes, it means you have to write twice for each sensor update.\nThe other potential solution would be to write your time series data partitioned by time, as opposed to the sensor ids. Assuming all sensors are updated at each time point, with a single query you can get the value of all sensors. This works but only if you update the vales of all sensors every time, and only if you do it with regular cadence.\nHowever, if you update all sensors at once, then further optimizations may be had by combining multiple sensor readings into a single item, therefore requiring less writes to update all 2000 of them.","Q_Score":3,"Tags":"python,aws-lambda,amazon-dynamodb,dynamodb-queries","A_Id":52014186,"CreationDate":"2018-08-24T15:52:00.000","Title":"query dynamoDB for the latest entry of every hash key","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to print numbers from 1 to 1000.\nprint(*range(1,1001)) is taking more time than printing it's list print([*range(1,1001)]).\nAny reason printing a list is much faster than printing row of numbers?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":116,"Q_Id":52009415,"Users Score":-1,"Answer":"Printing numbers will yeild one value at a time\nPrinting list will yeild whole list at a time.","Q_Score":1,"Tags":"python,range","A_Id":52009923,"CreationDate":"2018-08-24T17:43:00.000","Title":"Execution time for printing numbers and list of numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using docker python SDK docker-py, which is quite convenient. I look through the document, I still can't figure out how to create a daemon container with interface terminal,that is to say, if in the shell, this equals to the command docker run -dit image. \nI know docker-py right now offers the client.containers.run to run a contaniner, and with deatch argument I can run it as a daemon. However, I want start it with a interface terminal.\n'Cause my further code would access to the container from the remote server. Is there any way to create it directly with docker-py instead of using os.system(docker run -dit image)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":241,"Q_Id":52013784,"Users Score":0,"Answer":"After swimming in the doc for a while, I figure it out.\nThe command docker run -dit image in docker-py is client.containers.run(image,tty=True,stdin_open=True, detach=True) This would work. Thank u David.","Q_Score":0,"Tags":"python,docker,dockerpy","A_Id":52017674,"CreationDate":"2018-08-25T03:28:00.000","Title":"How to create a daemon container with interface terminal using docker-py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"In jupyter notebook, we can use %matplotlib inline to guide inline the image created by python script. Can anyone give a 5 sentence explaining what is happening under the hood to make that happen? If i'd like to have some web page to host the matplotlib created plot, is that possible or not? thanks~","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":52018374,"Users Score":0,"Answer":"The inline backend essentially calls fig.savefig(buffer, format=\"png\", bbox_inches=\"tight\") where fig is the figure to show. It'll then supply the content of buffer inside a <img> tag in the jupyter's output section.","Q_Score":2,"Tags":"python,matplotlib,jupyter-notebook","A_Id":52547503,"CreationDate":"2018-08-25T14:48:00.000","Title":"how matplotlib create and deliver plot to jupyter notebook?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Visual Studio 2017 and its support for Python. \nI want to use Python on other applications and hence I need to put it in the path, but I can not find where VS 2017 installed Python.\nWhere VS install Python so I can add it to the path?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7461,"Q_Id":52021815,"Users Score":8,"Answer":"First of all make sure you have actually installed python extension, if you are using Windows you could go to menu start and just search for the phrase python.\nIf you get any results you could simply right-click it, then press Open file location and you'll see a menu-start folder having the shortcuts to all python resources ex. IDLE (Python 3.7 64-bit), Python 3.7 (64-bit), Python 3.7 Manuals (64-bit), Python 3.7 Module Docs (64-bit).\nFrom this point you can just go into shortcuts properties and see what the target is. With Visual Studio 2019 default install the target of Python 3.7 (64-bit) is\nC:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python37_64\\python.exe","Q_Score":6,"Tags":"python-3.x,visual-studio","A_Id":56787288,"CreationDate":"2018-08-25T22:46:00.000","Title":"where Visual studio install python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What data structure - Set, List or Dictionary - in Python will you use to store 10 million integers? Query operations consist of finding the number of times a number appears in the given set. What will be the worst case time and space complexity in all the cases?\n\nThis is a sample interview question. What would be the most appropriate answer?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7992,"Q_Id":52023758,"Users Score":0,"Answer":"Add every number as number:1 in dict if number not in dict, else add 1 to Val of that Key.\nThen search for specific number as Key, the Val will be the number of times that appears.","Q_Score":3,"Tags":"python,python-3.x,data-structures","A_Id":55592271,"CreationDate":"2018-08-26T06:30:00.000","Title":"List vs Dictionary vs Set for finding the number of times a number appears","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What data structure - Set, List or Dictionary - in Python will you use to store 10 million integers? Query operations consist of finding the number of times a number appears in the given set. What will be the worst case time and space complexity in all the cases?\n\nThis is a sample interview question. What would be the most appropriate answer?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7992,"Q_Id":52023758,"Users Score":6,"Answer":"The key to this question is the line that states:  \n\n\"finding the number of times a number appears in a given set\"\n\nThe set data structure is going to be incapable of keeping a count of how many times a number appears within the total dataset, and a List is going to be extremely costly to iterate over. Which leaves a dictionary as the only viable option. \nBreaking down the options: \nSet:\nA set automatically de-dupes values added to the set that already exist. So it would be impossible to query the frequency that a number appeared within the stored dataset using a set, because the answer for all numbers stored will be 1.  \n\nTime complexity for querying: O(1)  \nSpace complexity for storing: O(n)\n\nList:\nA list could be iterated over to determine the frequency of a given number within the list. However this is going to be O(n) operation, and for 10 million integers will not be efficient.  \n\nTime complexity for querying: O(n)  \nSpace complexity for storing: O(n)\n\nDictionary:\nA dictionary allows you to store a key-value pair. In this case, you would store the number to be searched as the key, and the count of how many times it has been stored as the associated value. Because of the way that dictionaries will hash keys into distinct buckets (There can be collisions, but let's assume a non-colliding theoretical dictionary for now), the lookup time for a given key approaches O(1). Calculating the count however, is going to slow down a Dictionary; it will take O(n) time complexity to calculate the counts for all keys (because each key will have to be hit at least once in order to append it's count to the running count stored in the value).   \n\nTime complexity for querying: O(1)  \nTime complexity for storing: O(n)  \nSpace complexity for storing: O(2n) = O(n)","Q_Score":3,"Tags":"python,python-3.x,data-structures","A_Id":52023967,"CreationDate":"2018-08-26T06:30:00.000","Title":"List vs Dictionary vs Set for finding the number of times a number appears","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using multiple conda environments, and use Spyder as my IDE. These environments often have the same python version, and differ based on installed packages (packages not used by spyder).\nI looked how to run spyder in a certain environment, and the answers i found all state that i first have to install spyder in that environment and then run it.\nHowever, this of course requires extra space used on my computer. Is there a way to use spyder in different conda environments, without installing spyder multiple times (or maybe just once per python version)?\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2646,"Q_Id":52026360,"Users Score":2,"Answer":"As explained in the comments, the quick answer is only to install the spyder-kernel package within the desired conda environment. You don't need to install the whole spyder package again and again.","Q_Score":6,"Tags":"python,spyder,conda","A_Id":66061326,"CreationDate":"2018-08-26T12:42:00.000","Title":"Switch Spyder Environment without installing spyder at each environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If requests.Session() can handle cookies and does almost everything that app.test_client() does. Then why use the app.test_client()?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3506,"Q_Id":52028124,"Users Score":2,"Answer":"test_client is already prebuilt into flask, this makes it easier for people to quickly test their programs. Both the requests utility and test_client server the same functionality, so the usage is just based on personal preference.","Q_Score":11,"Tags":"python,python-3.x,flask","A_Id":52045779,"CreationDate":"2018-08-26T16:21:00.000","Title":"Why use Flask's app.test_client() over requests.Session() for testing","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 two python files.\nI need to call the 2nd one from 1st.\nI'm aware of os.system() commands.\nBut it's been mentioned as the worst way to execute a python script. \nThe script I need to call doesn't contain any functions or classes. but just the flow.\nwhat is the better way to execute the script from another script.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":462,"Q_Id":52028909,"Users Score":0,"Answer":"Put both files in the same directory.\nAdd an empty file called __init__.py in the directory.\nThen in the first file just include this: from file2 import myfunction\nYou can then call myfunction from file2 in file1.","Q_Score":0,"Tags":"python","A_Id":52028928,"CreationDate":"2018-08-26T17:57:00.000","Title":"How to execute a python file from another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a list structure updated continiously. In every iteration the following steps are performed:\n\nDelete minimum value in the list\ndelete n values somewhere in the list\nadd n values to the list\n\nAs far as i understood a heap is not a good solution here (even with lazy deletes) because i need to delete values somewhere in the list for which i dont know the index (position). Thus these values needs to be searched.. \nDo I just use a sorted list for this problem? I need the best performance I can get here since the list is up to 100.000 elements at some point in the loop.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":442,"Q_Id":52029286,"Users Score":0,"Answer":"You can avoid the issue of not knowing the index of the item to be deleted by also maintaining a dictionary alongside the heap. The values in the dictionary are the same as the heap items (perhaps a list with a priority value and a reference to the real item). The dictionary keys are the same as the real items, so they're easy to look up.\nWhen you want to delete an item that is not the minimum, you look it up in the dictionary and mark it as deleted (perhaps by setting the reference to the item to None). No need to modify the list representing the heap, it has references to the same items, so it will see that the item was deleted whenever it comes up to be removed as the minimum.\nThat said, if you are doing the \"delete items from anywhere in the data\" operation frequently, then you might be better served with just a regular dictionary or set. You can get the minimum with min in linear time, and removals (of any item, including the minimum) takes constant time (amortized, on average). For some usage patterns that might be faster than dealing with a heap.","Q_Score":0,"Tags":"python-3.x,list,performance,heap","A_Id":52029561,"CreationDate":"2018-08-26T18:44:00.000","Title":"Sorted list vs heap: Deleting elements in the middle of the list Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is quite a simple one: My intention is to minimize loss=a-b where loss is ideally as big a negative number as possible, ie. b much bigger than a.\nSince in all the examples, the loss is positive, I wanted to ask whether I can just input my loss into compute_gradients and get the desired result.\nCheers","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":143,"Q_Id":52029879,"Users Score":1,"Answer":"Yes you can. As long as it is a minimization instead of maximization, everything should be exactly the same as in the examples.","Q_Score":2,"Tags":"python,tensorflow,loss","A_Id":52029914,"CreationDate":"2018-08-26T20:08:00.000","Title":"Does the loss in tensorflow.train.AdamOptimizer have to be positive?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a directed bigraph that contains directed and undirected edges.\nnetworkx_Graph = nx.read_adjlist('graph.txt', create_using=nx.DiGraph())\nI was able to find the number of directed edges using: len(list(networkx_Graph.in_edges(data=False)))\nBut I am trying to find the number of undirected edges.\nThis is quite easy using the python package snap, but I am not finding anything like this in networkx's documentation?\nWhat is the networkx equivalent of snap.CntUniqDirEdges()?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":372,"Q_Id":52030344,"Users Score":0,"Answer":"You have to convert the graph to an undirected graph the calculate the size. NetworkX does not have a function that does this in one shot like snap does.\n\nnetworkx_Graph.to_undirected().size()","Q_Score":0,"Tags":"python,graph,networkx","A_Id":52031095,"CreationDate":"2018-08-26T21:19:00.000","Title":"How can I find the number of unique undirected edges of a graph using networkx?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For the sake of discussion, I will ask the following question based on Python 3.6.1\nI read from the book [Learning Python] (5th edition, Chapter 20, page 614) that:\n\nAs we\u2019ve seen, fundamental built-in tools such as range, map, dictionary\n  keys, and even files are now generators, so you must be familiar with the concept even if you don\u2019t write new generators of your own.\n\nIs this a false statement?\nI thought that an object being an iterator is a necessary but not sufficient condition for it to be a generator. That is, a generator\u2019s iterator is always the generator itself.\nHowever, range and dictionary keys are iterables but they are NOT their own iterators. If they are not iterators, how can they be generators?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":76,"Q_Id":52031719,"Users Score":4,"Answer":"Sometimes people use \"generator\" to mean any lazy iterable, even though that is not the precise definition.  In Python 3, range is a lazy iterable.","Q_Score":1,"Tags":"python,python-3.x,iterator,generator,iterable","A_Id":52031739,"CreationDate":"2018-08-27T02:01:00.000","Title":"The book [Learning Python] claimed that range is a generator- - Is this a false statement?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to know if the squared error depends also on the number of hidden layers and the number of neurons on each hidden layer , because I've created a neuron network with one hidden layer but I can't reach a small squared error , so maybe the function is not convex ? Can I optimize weights by adding more hidden layers ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":52032541,"Users Score":0,"Answer":"Though this is not a programming question, I'll try my best to answer it here.\nThe squared error, i.e. the 'loss' of your neural network, depends on your neural network prediction and the ground truth. And it is convex from its definition.\nThe reasons that you're not getting low losses could be:\n\nYou're not normalizing your inputs. For example, if you got a series of house prices as input, which is around 500k to 1m, and you didn't normalize them, your prediction will be the linear combination of the prices, which is about the same order of magnitude, then pass through the activation function. This could result in large losses.\nYou're not initializing your weights and biases correctly. Similar to above, you could have large weights\/biases which lead to large prediction values.\nYou didn't choose the proper activation function. When you're doing classification, your labels are generally one hot encoded, so your activation functions should limit the prediction to [0,1] or similar, so relu won't be a proper option. Also you don't want sigmoid as activation for regression problems.\nYour labels are not predictable or have too much noise. Or maybe your network is not complex enough to capture important patterns, in that case you could try adding more layers and more nodes per layer.\nYour learning rate is too small, this leads to slow convergence.\n\nThat's all I have in mind. You probably need more work to find out the reason to your problem.","Q_Score":0,"Tags":"python,neural-network","A_Id":52032920,"CreationDate":"2018-08-27T04:24:00.000","Title":"Does the squared error depends on the number of hidden layers?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm just a beginner in python coding but I have an issue for which I didn't found solution.\nI just try to run a simple script (hello world from the tutorial) but when I right click and execute the program in the terminal I just have a reply of the terminal with \"c:\/........\/helloworld.py\" (the path of my folder to my script), and not the program in itself, which should print \"hello world\".\nSo if anyone know the mistake I made please tell me !\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":90,"Q_Id":52036055,"Users Score":1,"Answer":"You need especifi the program interpreted to run the script, for run python scripts write \n\npython helloworld.py","Q_Score":0,"Tags":"python,python-3.x,path","A_Id":52036196,"CreationDate":"2018-08-27T09:14:00.000","Title":"Issue with executing a python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like Python to read any Cortana Notification \/ Alert it receives from my mobile.\nWhenever my mobile receive a Message \/ WhatsApp, it is displayed into windows using Cortana. Now, I and would like to use this content into python, i.e., link Cortana Alert to Python. Lastly, Python would receive the text\/content and run some AI scripts.\nTks and have a great day","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":52038390,"Users Score":1,"Answer":"You would need a module named pywin32\nhttps:\/\/sourceforge.net\/projects\/pywin32\/","Q_Score":0,"Tags":"python,python-3.x,cortana,cortana-intelligence,cortana-skills-kit","A_Id":52038681,"CreationDate":"2018-08-27T11:32:00.000","Title":"Link Cortana Alert \/ Notification and Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run a django app on heroku with postgresql but i'm getting\nwhen i go to my app url i check the heroku logs --tail and see\n2018-08-27T10:37:19.086599+00:00 heroku[web.1]: State changed from starting to crashed\n2018-08-27T10:37:19.070449+00:00 heroku[web.1]: Process exited with status 127\n2018-08-27T10:37:18.986150+00:00 app[web.1]: bash: gunicorn: command not found\n\ni have a requirements.txt with gunicorn, the heroku python buildpack installed\ni try maybe installing gunicorn remotely with \nheroku run pip install -r requirements.txt\nbut i get\n\u203a   Error: remote requirements.txt not found in git remotes","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":715,"Q_Id":52040966,"Users Score":0,"Answer":"I'm also working with Django and saw this same exact error in heroku logs --tail a few minutes after I pushed updated to Heroku. Prior to the push to Heroku everything worked just fine.  \nTo solve this problem,  first I made sure that the following files that worked previously remain unchanged with the push:\n\nrequirements.txt\nAptfile\nProcfile  \nruntime \nwsgi\n\nSince these files remained unchanged, I concluded that something beyond my knowledge was causing issues. So I went into the app's Activity Feed in Heroku, found the version that I knew worked and clicked on the Roll back to here link.\nWhen that didn't work, per the recommendation of another user (whose comment I can't seem to find now), I removed all packages from the requirements.txt then pushed it up to Heroku so that all packages would be uninstalled in the app. Then I added back all packages to the requirements.txt and pushed it to Heroku. Now it works.","Q_Score":0,"Tags":"python,django,heroku","A_Id":59906843,"CreationDate":"2018-08-27T13:54:00.000","Title":"Heroku Django webapp getting error logs say gunicorn command not found but it is there","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have an AWS Lambda (python) function that is set to trigger on S3 Object Create.  What I am trying to do is push the created file to a network drive through our VPC but I am not entirely sure how to configure this or the python code to map a shared drive through the VPC. Am I thinking about this in the wrong way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":941,"Q_Id":52046518,"Users Score":0,"Answer":"Step 1: Accessing the file (Object created event) from Lambda Python Code can be done through Boto3 Library. AWS SDK for Python\nStep 2: Configuring your lambda function for VPC - to be done on the Console or through CLI when you create the lambda function. On the Lamda Function Details Page, there is a \"Network\" block of UI containing a drop down called \"VPC\". VPC End Points will be listed here and to be selected.","Q_Score":0,"Tags":"python,amazon-s3,aws-lambda,amazon-vpc","A_Id":52073184,"CreationDate":"2018-08-27T20:25:00.000","Title":"How can I download a file from S3 to local network drive using lambda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am very new to image recognition with CNNs and currently using several standard (pre-trained) architectures available within Keras (VGG and ResNet) for image classification tasks. I am wondering how one can generalise the number of input channels to more than 3 (instead of standard RGB). For example, I have an image which was taken through 5 different (optic) filters and I am thinking about passing these 5 images to the network.\nSo, conceptually, I need to pass as an input (Height, Width, Depth) = (28, 28, 5), where 28x28 is the image size and 5 - the number of channels.\nAny easy way to do it with ResNet or VGG please?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":315,"Q_Id":52047126,"Users Score":2,"Answer":"If you retrain the models, that's not a problem. Only if you want to use a trained model, you have to keep the input the same.","Q_Score":7,"Tags":"python,tensorflow,image-processing,keras,conv-neural-network","A_Id":54873735,"CreationDate":"2018-08-27T21:20:00.000","Title":"Convolutional neural network architectures with an arbitrary number of input channels (more than RGB)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run python in PyCharm by using a Docker image, but also with a Conda environment that is set up in the Docker image. I've been able to set up Docker and (locally) set up Conda in PyCharm independently, but I'm stumped as to how to make all three work together. \nThe problem comes when I try to create a new project interpreter for the Conda environment inside the Docker image. When I try to enter the python interpreter path, it throws an error saying that the directory\/path doesn't exist.\nIn short, the question is the same as the title: how can I set up PyCharm to run on a Conda environment inside a Docker image?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1524,"Q_Id":52049202,"Users Score":3,"Answer":"I'm not sure if this is the most eloquent solution, but I do have a solution to this now!\n\nStart up a container from the your base image and attach to it\nInstall the Conda env yaml file inside the docker container\nFrom outside the Docker container stream (i.e. a new terminal window), commit the existing container (and its changes) to a new image: docker commit SOURCE_CONTAINER NEW_IMAGE\n\nNote: see docker commit --help for more options here\n\nRun the new image and start a container for it\nFrom PyCharm, in preferences, go to Project > Project Interpreter\nAdd a new Docker project interpreter, choosing your new image as the image name, and set the path to wherever you installed your Conda environment on the Docker image (ex: \/usr\/local\/conda3\/envs\/my_env\/bin\/python)\n\nAnd just like that, you're good to go!","Q_Score":5,"Tags":"python,docker,pycharm,conda","A_Id":52231615,"CreationDate":"2018-08-28T02:21:00.000","Title":"How to use Docker AND Conda in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is difference between arima.predict() and arima.forecast(). \nWhich function should use for forecasting time series in python?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1974,"Q_Id":52051348,"Users Score":1,"Answer":"They will give you the same answers. But the combination of Arima (not arima) and forecast from the forecast package are enhanced versions with additional functionality.\nArima calls stats::arima for the estimation, but stores more information in the returned object. It also allows some additional model functionality such as including a drift term in a model with a unit root.\nforecast calls stats::predict to generate the forecasts. It will automatically handle the drift term from Arima. It returns a forecast object (rather than a simple list) which is useful for plotting, displaying, summarizing and analysing the results.","Q_Score":1,"Tags":"python,machine-learning,time-series,arima","A_Id":52051400,"CreationDate":"2018-08-28T06:22:00.000","Title":"Difference between arima.predict() and arima.forecast()","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Django and Python having trouble with a Django command.\nBefore the query, I want to let you know that\n1) python is installed in my c drive and the path name is C:\\Users\\admin67\\AppDathea\\Local\\Programs\\Python\\Python37  \n2) The Djangp project is in the D drive and the path name is D:\/\/wisdompets  \n3) My python version is python 3.7.0  \nIn the windows shell I give the command python3 manage.py runserver  \nHowever this command is not running in my windows shell. I have tried all combinations such as python370, python37, python 3.7..0 but nothing works and I keep getting the message (see the attachment).\nThe error traceback that I get in the Windows shell is as below.\n\nThe term 'python3' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spe lling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:8 + python3 <<<< manage.py runserver + CategoryInfo : ObjectNotFound: (python3:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException\n\nPlease help me resolve this error.\nThanks & Regards Manish","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1620,"Q_Id":52051909,"Users Score":1,"Answer":"Your Python PATH variable is not configured properly. Having Django project and Python interpreter in different locations is not the problem here. The CMD will find the python.exe from the PATH variable defined in the system. If it can't find it then it will raise an error. \nPlease go to PATH in your Environment variables (Right click on This PC > Properties > Advanced System Settings > Environment Variables \nAnd check if that exact path of your python.exe(That you mentioned) is there in your PATH. It likely isn't there and that's the reason you're seeing this error. \nTo resolve it, \nClick on Path variable and edit it. Now add the directory where your Python is installed. i.e \"C:\\Users\\admin67\\AppDathea\\Local\\Programs\\Python\\Python37\" , \nRestart your CMD or PowerShell and Python should now be recognized.\npip also must now be recognized and then 'pip install django==1.11.7' in your cmd, as that is what wisdompets need. If you don't specify the version it will fetch the latest version(Django 2.1 as of now) and entire code will break.\nNow in your CMD. \npython manage.py runserver\nHope this helps !","Q_Score":1,"Tags":"python,django","A_Id":52052194,"CreationDate":"2018-08-28T07:02:00.000","Title":"Django command giving error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How to find the minimum number of ways in which elements taken from a list can sum towards a given number(N)\nFor example if list = [1,3,7,4] and N=14 function should return 2 as 7+7=14\nAgain if N= 11, function should return 2 as 7+4 =11. I think I have figured out the  algorithm but unable to implement it in code.\nPls use Python, as that is the only language I understand(at present) \nSorry!!!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1501,"Q_Id":52053862,"Users Score":0,"Answer":"it would be helpful if you include your Algorithm in Pseudocode - it will very much look like Python :-)\nAnother aspect: your first operation is a multiplication with one item from the list (7) and one outside of the list (2), whereas for the second opration it is 7+4 - both values in the list. \nIs there a limitation for which operation or which items to use (from within or without the list)?","Q_Score":0,"Tags":"python-3.x,recursion,dynamic-programming","A_Id":52053965,"CreationDate":"2018-08-28T08:56:00.000","Title":"Choosing minimum numbers from a given list to give a sum N( repetition allowed)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am facing token expire issue every 20 to 40 mins but actual time is one hour but I need a token validity one day.\nPlease help me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":146,"Q_Id":52054877,"Users Score":0,"Answer":"This is not possible to change the token validity period with AWS Cognito User Pools. Currently, its fixed to 1 hour.","Q_Score":0,"Tags":"python-3.x,aws-lambda,aws-cognito","A_Id":52055046,"CreationDate":"2018-08-28T09:48:00.000","Title":"How to increase the AWS Cognito Access Token Validity one hour to one day in Amazon Cognito User Pools","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I redirect\/show the console output (including outputs I print inside the program) so it would appear inside a Dash app (On the screen the user sees)?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6280,"Q_Id":52057540,"Users Score":0,"Answer":"One possible way to do this is supply it as input to Dash Core Component Text Area's value property. This should work if its a string.","Q_Score":5,"Tags":"python,plotly,plotly-dash","A_Id":52064336,"CreationDate":"2018-08-28T12:09:00.000","Title":"Redirecting Python's console output to Dash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to detect upright and upside-down faces, however faces weren't recognized in upside-down images.\nI used the dlib library in Python with shape_predictor_68_face_landmarks.dat. \nIs there a library that can recognize upright and upside-down faces?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":855,"Q_Id":52059560,"Users Score":8,"Answer":"You could use the same library to detect upside down faces. If the library is unable to detect the face initially, transform it 180\u00b0 and check again. If it is recognized in this condition, you know it was an upside down face.","Q_Score":0,"Tags":"python,opencv,computer-vision,face-detection,dlib","A_Id":52059673,"CreationDate":"2018-08-28T13:52:00.000","Title":"how to detect upside down face?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I have a square matrix with 20 lines and 20 columns. Using NumPy, what should I do to transform this matrix into a 1D array with a single line and 400 columns (that is, 20.20 = 400, all in one line)?\nSo far, I've tried:\n1) array = np.ravel(matrix)\n2) array = np.squeeze(np.asarray(matrix))\nBut when I print array, it's still a square matrix.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":679,"Q_Id":52061828,"Users Score":3,"Answer":"Use the reshape method:\narray = matrix.reshape((1,400)).\nThis works for both Numpy Array and Matrix types.\nUPDATE: As sacul noted, matrix.reshape(-1) is more general in terms of dimensions.","Q_Score":0,"Tags":"python,arrays,numpy,matrix","A_Id":52061923,"CreationDate":"2018-08-28T15:48:00.000","Title":"Transform square matrix into 1D array with NumPy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was postponing this question since i am not sure this is the right place to ask it. But i don't find a clear answer either.\nI am running pycharm 2018.1.4, on windows and it seems that i can't change the virtual env that running in the terminal in pycharm. When i check the python version in the terminal i get version 2.7.3, for the project interpreter i have python 3.6 and for my run configurations i have the same 3.6 interpreter. There are no problems running the development server or anything like that, just in the terminal i can't run the manage.py script without getting following.\n\nImportError: Couldn't import Django. Are you sure it's installed and\n  available on your PYTHONPATH environment variable? Did you forget to\n  activate a virtual environment?\n\nI understand the error, i just dont get why it is using that virtuals env instead of the one configured as project interpreter. Anyone else stumbled upon this problem?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1759,"Q_Id":52061978,"Users Score":1,"Answer":"As far as i know, Pycharm's terminal is not bound to Project Interpreter and the IDE related features.\nTo make it work, you'll have to manually activate your virtualenv in the terminal.","Q_Score":1,"Tags":"python,django,pycharm,virtualenv","A_Id":52062062,"CreationDate":"2018-08-28T15:57:00.000","Title":"Changing the virtualenv for the terminal in pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been trying to install Pyinstaller on a Mac computer. I am having trouble getting the terminal to execute the setup.py file needed to install it. Whenever I type python setup.py install in the terminal, I receive this error:\npython: cant open file 'setup.py': [Errno 2] No such file or directory\nI have tried moving the pyinstaller folder to the same folder as my python application and changing the directory that the terminal is acting in using \"cd Downloads\" or other directories and nothing has worked.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":421,"Q_Id":52063311,"Users Score":0,"Answer":"Using a more specific cd command such as \"cd Downloads\/pyinstaller\" instead of \"cd Downloads\" works.","Q_Score":0,"Tags":"python,macos,pyinstaller,python-3.7","A_Id":52065931,"CreationDate":"2018-08-28T17:20:00.000","Title":"Installing Pyinstaller on Mac OSX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there a way to provide a single URL for a user to download all the content from an S3 path?\nOtherwise, is there a way to create a zip with all files found on an S3 path recursively?\nie. my-bucket\/media\/123\/*\nEach path usually has 1K+ images and 10+ videos.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3130,"Q_Id":52064420,"Users Score":3,"Answer":"There's no built-in way. You have to download all files, compact them \"locally\", re-upload it, and then you'll have a single URL for download.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda","A_Id":52064465,"CreationDate":"2018-08-28T18:43:00.000","Title":"Create a zip with files from an AWS S3 path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use pip install to install various python packages on my Mac OS terminal. If I don't include \"--user\" at the end, I am consistently notified that there was an \"EnvironmentError: [Errno 13] Permission Denied\". However, if I include --user at the end, I am able to install packages. However, on other Apple computers I use the Terminal and Python for, I have no trouble installing packages and I do not need to add \"--user\" to the end.\nWhy the difference here? Why do I need to include --user to the end of my pip install commands for one Mac laptop but not for others?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2720,"Q_Id":52066829,"Users Score":1,"Answer":"With a virtual environment activated, pip install spam tries to install into the virtual environment's site-packages. This will almost always be somewhere you have write permissions for.\npip install --user spam tries to install into the user-packages directory. This will always be somewhere under your home directory, so you should always have write permissions for it.\npip install spam tries to install files into the site-packages directory for your Python installation. This will usually not be in your home directory (typically it's somewhere in \/Library), so you may or may not have write permissions.\n\nApple's pre-installed Python does not give you write permissions to its site-packages.\n\n\nsudo pip install spam will let you ignore the permissions by installing as root, although with some Python installations it may cause other problems.\n\nHomebrew, Python.org, and Anaconda\/Miniconda do give you write permissions to their site-packages if you leave the defaults alone.\n\n\nObviously, leave the defaults alone if you know what you're doing.\n\nLess common ways of installing (Enthought, building from source, MacPorts, etc.), you should read the appropriate docs.\n\n\nSo, most likely, you're using a third-party Python and\/or an active virtual environment on the machines where pip install spam works, but you're using Apple's pre-installed Python on the ones where it doesn't.\nWhile you could fix that by using sudo, you probably don't want to, for a few reasons:\n\nOn recent versions of macOS, Apple's pre-installed Python, and the packages they pre-install with it, are badly out of date.\nThe pre-installed packages are set up to be maintained with the deprecated easy_install rather than pip, so getting them up to date can be a huge pain.\nIf you mess things up too badly, you can break some system scripts that the OS depends on.\nYour changes can be undone by a macOS system update.\n\nSo, a better solution is to install Homebrew\/Anaconda\/Python.org Python if you can, and also use virtual environments when you can and --user whenever possible when you can't. Any one of these three will solve your problem, but you really should do all of them.\nAnd then, if you accidentally try to install something to Apple's site-packages, you'll get a permissions error\u2014but that's a good thing; it means you didn't actually change anything, so you have nothing to undo.","Q_Score":2,"Tags":"python,terminal,pip,installation","A_Id":52067165,"CreationDate":"2018-08-28T22:07:00.000","Title":"Why is permission denied on pip install except for when \"--user\" is included at end of command?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am writing unit tests (using Python 3.7, Pytest 3.6 and tox 3.0) for a function that compiles a series of shell commands as a list of strings, and then executes them using the subprocess module. The shell commands do the following:\n\ncreates a filename from the function arguments.\ncd into a given directory.\nchecks for a file with a certain name and removes it if it exist.\ncreates a new file with the same name.\nexecutes a program and pipes the output into the new file.\n\nMy test right now is mocking the subprocess module, and then asserting that it was called with a list of strings that contains all the expected commands given some test arguments. \nIs there a way to test that the commands do what they are supposed to? Right now my test is only checking if the list of commands I feed to the subprocess module is the same as the one I have asserted it to be. This does not tell me whether the commands are the right ones for what I am trying to achieve. Rather it only serves as a test on whether I can write down the same string in two different source files.\nCan I simulate the side effects that I expect the shell commands to have?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1572,"Q_Id":52072544,"Users Score":1,"Answer":"Your question combines two interesting topics: a) Testing code generated from a code generator and b) testing shell code.\nFor testing code from a generator, you have in principle to do the following: i) test that the generator creates the code that is expected - which you have already done, ii) test that the code snippets \/ pieces which the generator glues together actually behave (independently and in combination) as it is intended (which in your case are the shell code pieces that in the end together will form a valid shell program) - this is the part about testing shell code that will be adressed below, and iii) test that the inputs that control the generator are correct.\nIt is comparable with a compiler: i) is the compiler code, ii) are assembly code snippets that the compiler combines to get the resulting assembly program, and iii) is the source code that is given to the compiler to get it compiled.  Once i), ii) and iii) are tested, there is only seldom the need to also test the assembly code (that is, on assembly code level).  In particular, the source code iii) is ideally tested by test frameworks in the same programming language.\nIn your case it is not so clear how part iii) looks and how it can be tested, though.\nRegarding the testing of shell code \/ shell code snippets: Shell code is dominated by interactions with other executables or the operating system.  The type of problems that lies in interactions in shell code goes in the direction of, am I calling the right executables in the right order with the arguments in the right order with properly formatted argument values, and are the outputs in the form I expect them to be etc. To test all this, you should not apply unit-testing, but integration testing instead.\nIn your case this means that the shell code snippets should be integration-tested on the different target operating systems (that is, not isolated from the operating system).  And, the various ways in which the generator puts these snippets together should also be integration tested to see if they together operate nicely on the operating system.\nHowever, there can be shell code that is suitable for unit-testing.  This is, for example, code performing computations within the shell, or string manipulations.  I would even consider shell code with calls to certain fundamental tools like basename as suitable for unit-testing (interpreting such tools as being part of the 'standard library' if you like).  In your case as you describe the generated shell code\n\ncreates a filename from the function arguments.\n\nThis sounds like one example of a good candidate for 'unit-testing' shell code: This filename creation functionality could be put into a shell function and then be tested in isolation.","Q_Score":1,"Tags":"python-3.x,shell,unit-testing,zsh","A_Id":55927559,"CreationDate":"2018-08-29T08:08:00.000","Title":"Unit testing of shell commands called in 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":1,"Web Development":0},{"Question":"After updating my system via pacman (arch linux 4.18) most of the python scripts aren't working anymore (errors about missing modules, pipenv errors, vim plugins errors).\nHow can I revert python to 3.6?\nGoogle didn't offer any satisfying solutions on that issue","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25841,"Q_Id":52072588,"Users Score":0,"Answer":"Use conda search python to select the version of python you want to downgrade to then use something like conda install python=3.6.0 if you want to downgrade to 3.6.0","Q_Score":1,"Tags":"python,archlinux","A_Id":53091322,"CreationDate":"2018-08-29T08:11:00.000","Title":"How to downgrade python 3.7 to 3.6?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need some assistance with migrating with Heroku as I've added git+https:\/\/github.com\/Rapptz\/discord.py@rewrite#egg=discord.py[voice] into my requirements.txt file and I'm confused as when I do that, it doesn't change to rewrite, even if I still import discord. I have changed all my code to rewrite, like for example: bot.say to ctx.send. All of that is done, but when I place git+https:\/\/github.com\/Rapptz\/discord.py@rewrite#egg=discord.py[voice] into my requirements.txt file, it still thinks it's async. Please help as I tried so much just to get this working and I can't seem to find a way.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":710,"Q_Id":52075155,"Users Score":1,"Answer":"LOL wait woops I just had to add yarl<1.2 to requirements.txt","Q_Score":0,"Tags":"python,asynchronous,heroku,discord,discord.py-rewrite","A_Id":52083610,"CreationDate":"2018-08-29T10:24:00.000","Title":"How do I change from Discord.py async to rewrite while using Heroku?","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 Geany IDE and I've wrote a python code that makes a GUI. Im new to python and i'm better with C. I've done research on the web and its too complicated because theres so much jargon involved. Behind each button I want C to be the backbone of it (So c to execute when clicked). So, how can i make a c file and link it to my code?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":52075229,"Users Score":2,"Answer":"I too had a question like this and I found a website that described how to do it step by step but I can\u2019t seem to find it. If you think about it, all these \u2018import\u2019 files are just code thats been made separately and thats why you import them. So, in order to import your \u2018C File\u2019 do the following.\n\nCreate the file you want to put in c (e.g bloop.c)\nThen open the terminal and assuming you saved your file to the desktop, type \u2018cd Desktop\u2019. If you put it somewhere else other than the desktop, then type cd (insert the directory).\nNow, type in gcc -shared -Wl,-soname,adder -o adder.so -fPIC bloop.c into the terminal.\nAfter that, go into you python code and right at the very top of your code, type \u2018import ctypes\u2019 or \u2018from ctypes import *\u2019 to import the ctypes library.\nBelow that type adder = CDLL(\u2018.\/adder.so\u2019).\nif you want to add a instance for the class you need to type (letter or word)=adder.main(). For example, ctest = adder.main()\nNow lets say you have a method you want to use from your c program you can type your charater or word (dot) method you created in c. For example \u2018ctest.beans()\u2019 (assuming you have a method in your code called beans).","Q_Score":1,"Tags":"python","A_Id":52075312,"CreationDate":"2018-08-29T10:28:00.000","Title":"How to have cfiles in python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed gunicorn in my Ubuntu virtual machine using sudo apt-get install gunicorn. How can I find the installed location of gunicorn?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7746,"Q_Id":52076148,"Users Score":2,"Answer":"How you checked it is not available in location \/home\/jkcsadmin\/.local\/bin\/gunicorn ? Try \/home\/jkcsadmin\/.local\/bin\/gunicorn -h and see whether it shows the help.\nNormally it is located at your bin folder \/usr\/bin\/gunicorn. Try \/usr\/bin\/gunicorn -h","Q_Score":4,"Tags":"python-3.x,ubuntu,gunicorn","A_Id":52081955,"CreationDate":"2018-08-29T11:15:00.000","Title":"How to find gunicorn path in Ubuntu using terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Today I'm after a little tricky situation. I have been using Flask-socketio process based on eventlet. To do so, I need to monkey-patch the Thread module, the socket and os modules too.\nWhat happens is that I'm running a background thread within the Flask-socketio process that is working fine. Now this thread will create after a while a Process (from another script, Process.py) that will be in charge of processing images, and will communicate with it using SimpleQueues. To fecth the images the second process launch a camera thread (picamera) that will be in charge of getting new frames.\nResults that picamera uses the standard thread library, so I need to disable the monkey patching and use the standard thread python module within the import of the Process.py, and still use the patched module withing the flask-socketio process. Is it that possible? Is it possible to use different thread module on different process?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":52076159,"Users Score":0,"Answer":"The short answer is that yes, your main and sub-processes do not necessarily need to be both using eventlet. Nothing wrong with not using it in the sub-process, and in fact, if you are going to be communicating with hardware, using eventlet is almost always not going to work well.\nI think you can make things work in the way you are starting your sub-process, but in my opinion, you are going to have less challenges if you run these two processes separately, not one as a sub-process of the other. Your main process will be 100% eventlet with everything monkey patched, while your camera process will have absolutely no trace of eventlet in it. Communication between these two processes is done through any available IPC mechanism. You can use queues, sockets, etc. The camera process will start and go into a wait, for example, by watching a queue for jobs issued by the main process.\nHope this helps!","Q_Score":0,"Tags":"python-3.x,python-multiprocessing,flask-socketio","A_Id":52111937,"CreationDate":"2018-08-29T11:16:00.000","Title":"Combining Greenleets with Flask, and Standard Threads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to store data about tweets in the database in raw format and figured out that you can pull out the jsob from tweepy.Status for this purpose like this:\nstatus._json\nHow can I parse json back to the tweepy.Status object?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":913,"Q_Id":52077085,"Users Score":3,"Answer":"I've found non-elegant solution for my problem. All you need is that:\ntweepy.Status().parse(None, status_json)\nwhere None should be tweepy.api.API object, but it not nedeed for parsing at all.\n\nYou can also compare the result with the original status for self-check. In my case this has True result:\ntweepy.Status().parse(None, status_json) == status","Q_Score":1,"Tags":"python,json,tweepy","A_Id":52077086,"CreationDate":"2018-08-29T12:08:00.000","Title":"How to parse JSON string to tweepy.Status object?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know how should i could manage to change the static files use by the saelor framework. I've tried to change the logo.svg but failed to do so.\nI'm still learning python program while using the saleor framework for e-commerce.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":183,"Q_Id":52079211,"Users Score":1,"Answer":"Here is how it should be done. You must put your logo in the saleor\/static\/images folder then change it in base.html file in footer and navbar section.","Q_Score":1,"Tags":"django,python-3.x,saleor","A_Id":52221713,"CreationDate":"2018-08-29T13:57:00.000","Title":"Cannot update svg file(s) for saleor framework + python + django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been trying to scroll the output of a script run via Ipython in a separate window\/session created by tmux (off notebook, meaning that I am not using Ipython notebook as usual: I am just using Ipython). I see that, while the program is loading the output, I can\u2019t scroll the window to see what has been published before, and can just visualize the latest results produced. Honestly, this problem comes totally unexpected because I usually use a notebook and have never encountered a similar issue. Could you help me please? Thanks in advance","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1191,"Q_Id":52079637,"Users Score":-1,"Answer":"Use threads for data processing, visualization, and gui interaction that is how you can avoid freez.","Q_Score":2,"Tags":"python,scroll,ipython,freeze,tmux","A_Id":52079720,"CreationDate":"2018-08-29T14:15:00.000","Title":"Impossible to scroll Ipython (not notebook!) while producing output within tmux window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"There is cluster ID property that can be retrieved with Get-Cluster | select Id in powershell command. \nHow to get it with WMI? Looks like MSCluster_Cluster doesn't have ID field.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":278,"Q_Id":52080462,"Users Score":0,"Answer":"Able to find cluster id on my own. Just in case if anyone looking for same.\nFound the cluster id in registry.\nHKEY_LOCAL_MACHINE\\Cluster\nKey: ClusterInstanceId","Q_Score":0,"Tags":"python,wmi,windows-server-2008-r2,failovercluster","A_Id":52121704,"CreationDate":"2018-08-29T14:52:00.000","Title":"How to get cluster id using WMI on Windows Server 2008 R2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there a way within Python, perhaps using sys and os, to determine the size of the window in which you are running Python.  I can do this in emacs using keyboard to run an emacs function, but not in general.\nI did not work too hard at it, but the other answers (for me) failed in Windows using Anaconda3 Python.  Perhaps someone else could try them in an emacs environment, which is where I tried them. They do return answers that appear to be defaults because they do not match my window size.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":52080551,"Users Score":0,"Answer":"If you are running Python in a graphics window, at least on Windows, there is, in general, no way to get the window size from within the Python program.  If, for example, one starts IDLE from a Windows console, shutil.get_window_size() reports the size of the parent console (rows and columns), not the size of the tk text widget that IDLE's shell is running in.  If one starts IDLE otherwise, from an icon or File Explorer, one gets the default 24 x 80.","Q_Score":0,"Tags":"python,emacs","A_Id":52082578,"CreationDate":"2018-08-29T14:56:00.000","Title":"Determing Window Size from within Python is not answered by reference to Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've this question that has tangled my brain for so many days by now. It possible to connect a pyqt slider value onto a Maya\u00a0current time change? I have a slider that represents\u00a0the rotation value, if these values are keyframed and change over time the slider doesn't.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":184,"Q_Id":52082520,"Users Score":0,"Answer":"You can use the maya time slider change event ( from the cmds.scriptJob() ) \nIf you want to change time with the slider, you have to use PyQt.","Q_Score":1,"Tags":"python,pyqt5,maya,pyside2","A_Id":52085253,"CreationDate":"2018-08-29T16:50:00.000","Title":"Move a PyQt slider based on maya timeline","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have given a download file url in parse method, what is the default location for that files and Is there any possibility to change that downloaded directory?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":162,"Q_Id":52082742,"Users Score":0,"Answer":"The response contents in parse(self, response) method are not files and are not stored on disk. The response is a python object and is stored in memory.  \nScrapy only downloads contents if HTTP_CACHE_ENABLED setting is set and it will cache all pages in <project_root>\/.scrapy directory.","Q_Score":0,"Tags":"python,scrapy","A_Id":52088635,"CreationDate":"2018-08-29T17:04:00.000","Title":"what is default downloaded path in scrapy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In Anaconda Navigator, I switched to running applications on tensorflow and installed jupyter 5.6.0. I then open up a Python3 notebook. I then import tensorflow, keras and numpy without issue. Then when I try to import matplotlib, the notebook says ImportError: No module named 'matplotlib'. \nI tried running the following command in my anaconda prompt in both base and after activating tensorflow: pip3 install matplotlib\nAnd it says: \n(tensorflow) C:\\Users\\danie>pip3 install matplotlib\nRequirement already satisfied \nfor 7 different lines. What am I doing wrong?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":940,"Q_Id":52082814,"Users Score":1,"Answer":"Add import sys and sys.executable to the top of your notebook, then run it. This shows you the directory of the running kernel. With this information, from a new command-line (not a Python console) run C:\\path\\to\\python.exe -m pip install matplotlib","Q_Score":0,"Tags":"python,matplotlib,tensorflow,jupyter-notebook","A_Id":52083402,"CreationDate":"2018-08-29T17:09:00.000","Title":"Matplotlib in Tensorflow Jupyter Notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I generate an image using buildroot with opencv2 in it?\nIn \"Target Packages->Libraries->Graphics->opencv2.4\" says that python_opencv depends on numpy, which isn't available.\nAn self made app(which is in the built image as well) uses python3.6 and opencv2.\nBuildroot Version: 2017.08-rc3","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":753,"Q_Id":52083346,"Users Score":4,"Answer":"Back when opencv was introduced in Buildroot, there was indeed no numpy package, so support for doing OpenCV in Python could not be added, hence this comment. But since then, a python-numpy package was added, and it is even used in the opencv3 package to provide Python support.\nSo, the opencv package simply needs to be updated to leverage the python-numpy package to provide Python support.\nAs a side note: why are you using 2017.08-rc3 ? It is a release candidate, not even a final release. And why this version ? Why not using the LTS version 2018.02.x, which we maintain during one year with security updates and bug fixes ?","Q_Score":0,"Tags":"python-3.x,opencv,buildroot","A_Id":52091386,"CreationDate":"2018-08-29T17:41:00.000","Title":"Add python_opencv in buildroot image","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using tkinter and the PIL to make a basic photo viewer (mostly for learning purposes). I have the bg color of all of my widgets set to the default which is \"systemfacebutton\", whatever that means.\nI am using the PIL.Image module to view and rotate my images. When an image is rotated you have to choose a fillcolor for the area behind the image. I want this fill color to be the same as the default system color but I have no idea how to get a the rgb value or a supported color name for this. It has to be calculated by python at run time so that it is consistent on anyone's OS.\nDoes anyone know how I can do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":52085525,"Users Score":2,"Answer":"You can use w.winfo_rgb(\"systembuttonface\") to turn any color name to a tuple of R, G, B.  (w is any Tkinter widget, the root window perhaps.  Note that you had the color name scrambled.)  The values returned are 16-bit for some unknown reason, you'll likely need to shift them right by 8 bits to get the 0-255 values commonly used for specifying colors.","Q_Score":1,"Tags":"python,python-3.x,tkinter,python-imaging-library","A_Id":52085742,"CreationDate":"2018-08-29T20:22:00.000","Title":"Determining \"SystemFaceButton\" RBG Value At RunTime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pandas has both isna() and isnull(). I usually use isnull() to detect missing values and have never met the case so that I had to use other than that.\nSo, when to use isna()?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":28252,"Q_Id":52086574,"Users Score":7,"Answer":"They both are same. As a best practice, always prefer to use isna() over isnull(). \nIt is easy to remember what isna() is doing because when you look at numpy method np.isnan(), it checks NaN values. In pandas there are other similar method names like dropna(), fillna() that handles missing values and it always helps to remember easily.","Q_Score":69,"Tags":"python,pandas","A_Id":57507051,"CreationDate":"2018-08-29T21:52:00.000","Title":"Pandas isna() and isnull(), what is the difference?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"so I'm having the weirdest problem! I have a python script which was working just fine and accessing a local mongodb and all was good.. then I wanted to add a new feature but I wanted to try it first so I copied my script into a new file and when I tried to run it it didn't access to mongodb and it kept on giving me this error pymongo: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions\n BUT the old script is still working just fine!!\nI searched every were google could have taken me and tried everything I know but the problem is still there all new scripts are giving me this error and all old ones are working just fine.. \ncan anyone please help me?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":501,"Q_Id":52087994,"Users Score":1,"Answer":"the problem was with the antivirus.. I have comodo antivirus and it has been blocking the scripts,, I unblocked them and now they work :)","Q_Score":0,"Tags":"python,mongodb,dbaccess","A_Id":52088266,"CreationDate":"2018-08-30T01:16:00.000","Title":"pymongo: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"One more question:\nIf they are tied biases, how can I implement untied biases?\nI am using tensorflow 1.10.0 in python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":213,"Q_Id":52088059,"Users Score":0,"Answer":"tied biases is used in tf.layers.conv2d.\nIf you want united biases, just turn off use_bias and create bias variable manually with tf.Variable or tf.get_variable same shape with following feature map, finally sum them up.","Q_Score":0,"Tags":"python,tensorflow","A_Id":52089011,"CreationDate":"2018-08-30T01:29:00.000","Title":"In tf.layers.conv2d, with use_bias=True, are the biases tied or untied?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question for the jupyter notebook.\nWhen I copied and pasted 663 lines of a python code to the jupyter notebook,\nit shows the much lower response than the notebook which has just a few code lines.\nHave anyone experienced this issue?\nAnyone knows the solution?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2746,"Q_Id":52089947,"Users Score":0,"Answer":"Without any information about your code is really difficult to give you an answer. \nHowever try to keep you output under control. Too much output to generate with a single run can overkill the kernel. \nMoreover, it makes not much sense to run in a single cell almost 700 lines of code, are you sure you're using the right tool?\nSometimes a piece of code could slow all the session, if you split your execution in smaller pieces, over multiple cells you will find what is really your bottleneck.","Q_Score":0,"Tags":"python,performance,jupyter-notebook","A_Id":52090133,"CreationDate":"2018-08-30T05:47:00.000","Title":"Jupyter notebook's response is slow when the codes have multiple lines","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does python 3.7 offer a way to import modules and alias only the submodules?\nSuppose I have a module named module with a submodule ridiculously_long_submodule_name that I'd like to alias with short_submodule\nIs there a way to alias just the submodule so I can call it via module.short_submodule?\nI tried the obvious from module import ridiculously_long_submodule_name as module.short_submodule resulting in a syntax error.\nI'd really like to avoid importing it without the main module name in front because of confusion issues with the rest of my code","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":597,"Q_Id":52090982,"Users Score":6,"Answer":"There's no dedicated syntax for aliasing module.ridiculously_long_submodule_name as module.short_submodule, and while you could mess with the module's attributes to do it manually, it'd be a bad idea.\nAliases set with import as are supposed to be local to the scope where the import happens, to avoid name conflicts, but setting module.short_submodule to the submodule you want would be a global change. All code in the program would see it, because unless you get really crazy with __getattribute__, there's no such thing as an object \"locally\" having an attribute.\nEven code in module would see an unexpected new global variable. That can cause really nasty conflicts if the writers of module ever want to use the short_submodule name, but even without that happening, mucking with other libraries like this is going to confuse people who have to maintain or debug your code, including the you of 12 months from now.\nJust do import module.ridiculously_long_submodule_name as submod. Don't try to put a module. prefix on the alias.","Q_Score":1,"Tags":"python,python-3.x","A_Id":52091632,"CreationDate":"2018-08-30T07:01:00.000","Title":"import python module and alias submodule","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"am new into jenkins. am trying to do a jenkins job that uploads a file into a python container and then reload the container. could you guys please help me","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":52096438,"Users Score":0,"Answer":"When you are creating your project you can add the command to upload and reload the python container under build->execute shell script.","Q_Score":0,"Tags":"python,docker,jenkins,devops","A_Id":52115297,"CreationDate":"2018-08-30T11:54:00.000","Title":"jenkins jobs that uploads a file into a python container","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When i try to send a post request with one of the json in float, it shows\nTypeError: Invalid variable type: mapping value should be str or int, got 77.5 ( 77.5 is the value which i want to send).","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":390,"Q_Id":52097317,"Users Score":2,"Answer":"as pointed out in the first comment, send your value as string by converting it like x = str(x)","Q_Score":0,"Tags":"python,aiohttp","A_Id":52097438,"CreationDate":"2018-08-30T12:38:00.000","Title":"How can i send float values as post payload in aiohttp?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When i try to send a post request with one of the json in float, it shows\nTypeError: Invalid variable type: mapping value should be str or int, got 77.5 ( 77.5 is the value which i want to send).","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":390,"Q_Id":52097317,"Users Score":1,"Answer":"Try to convert it into float. Like x = float(x). It worked for me because type of x in my code was numpy.float.","Q_Score":0,"Tags":"python,aiohttp","A_Id":56688366,"CreationDate":"2018-08-30T12:38:00.000","Title":"How can i send float values as post payload in aiohttp?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is the primary purpose of using a virtual environment to control versions of various packages installed on your development machine?\nFor example, I am developing a webapp using Django. My assumption is that using a virtual environment like Pipenv will ensure I don't have any problems down the road if I update my Django or python versions on my computer, because the webapp project is isolated with it's own versions of Django and Python.\nAre there any other notable benefits to using Pipenv?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":443,"Q_Id":52101240,"Users Score":2,"Answer":"Another benefit of using Pipenv\/virtualenv is that it makes deploying multiple web apps on the same server a lot easier. Instead of installing the packages for a given web app globally on the server, the virtualenv can be managed by a non-privileged deployment process, all contained in that specific web app's deployment directory.","Q_Score":2,"Tags":"python,django,virtualenv,pipenv,python-venv","A_Id":52101319,"CreationDate":"2018-08-30T16:01:00.000","Title":"Purpose of using virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"We have bought a Pixhawk 2.1 flight controller , and we are working on a university project ; the project is that we have to solve a puzzle by a drone ( which contains a raspberry pi 3 ) and send the right way coordinates to a small car . \nOur problem is that we shouldn\u2019t use any remote controller on the drone . So the drone should fly to a specific altitude and then should start looking for the puzzle and solve it .  \nWe have tried to use dronekit python . We could connect to the drone by the code but we couldn\u2019t make it arm and take off .\nIs Pixhawk 2.1 support arming and take off with out using any ground station or remote control? . If it does we hope that you send us a code and the method . Because we have search a lot and the project dead line is very near .\nThank you for your time ...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1733,"Q_Id":52102682,"Users Score":0,"Answer":"To control the drone using raspberry , pixhawk should comminucate with GPS . If you trying to arm it in a closed area probably it wont arm .  Because , your code should contain like \"guided\" mode it require GPS. If this is not helpful . Test again cominication between rpi and pixhawk","Q_Score":2,"Tags":"python,automation,dronekit","A_Id":52791875,"CreationDate":"2018-08-30T17:39:00.000","Title":"How can I arm and takeoff the drone with Pixhawk and raspberry by dronekit 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":"Python: 2.7.9\nSelenium 2.53.6    \n\nWe drive Selenium from Python, and it works great.\nIssue is that when we hit this line:\ndriver = webdrive.Firefox()\nThe Windows Firewall pops up, asking us to give permission to python.exe\nWe notice that we can ignore the firewall prompt, and everything seems to work OK.\nCan anyone tell us:\n\nWhy something in python land (selenium specifically) is opening a port\nThe port open that triggers the firewall prompt is clearly NOT required, (since we can ignore the prompt, and web drier still works). What is the explanation for this? \nHow we can , in code, suppress the firewall prompt? (e.g. by perhaps only allowing the engine to bind to 127.0.0.1 rather than the device IP?)","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":630,"Q_Id":52102843,"Users Score":-1,"Answer":"Why something in python land (selenium specifically) is opening a port\nIs this required?\n\nyour Python selenium code must communicate with a standalone server (geckodriver) over HTTP.  This can be a local or remote connection depending on your configuration... but you must allow this socket connection to use selenium with Firefox.","Q_Score":1,"Tags":"python,selenium","A_Id":52107370,"CreationDate":"2018-08-30T17:53:00.000","Title":"Selenium: Why does initializing the Firefox webdriver from Python trigger a Windows Firewall alert?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a picture slideshow which will show all the png and jpg files of a folder using django.\nProblem is how do I open windows explorer through django and prompt user to choose a folder name to load images from. Once this is done, how do I read all image files from this folder? Can I store all image files from this folder inside a list and pass this list in template views through context?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":747,"Q_Id":52104316,"Users Score":0,"Answer":"This link \u201chttps:\/\/github.com\/csev\/dj4e-samples\/tree\/master\/pics\u201d\nshows how to store data into to database(sqlite is the database used here) using Django forms. But you cannot upload an entire folder at once, so you have to create a one to many model between display_id(This is just a field name in models you can name it anything you want) and pics. Now you can individually upload all pics in the folder to the same display _id and access all of them using this display_id. Also make sure to pass content_type for jpg and png separately while retrieving the pics.","Q_Score":0,"Tags":"python,django,file-read","A_Id":64512939,"CreationDate":"2018-08-30T19:43:00.000","Title":"Reading all the image files in a folder in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Yesterday I began to read about using bootstrapping to determine confidence intervals (CIs) in many situations. My current situation is that I am trying to estimate three parameters in a model via maximum likelihood estimation (MLE). This I have done, and now I need to define my CIs. This can obviously be done via profile likelihood, but bootstrapping will give a more broad CI interval as far as I can read. My problem is that I am unsure on how to actually perform bootstrapping ? I have written my own code for the parameter estimation, so no build-in MLE calculators.\nBasically the observed data I have is binary data, so 1 or 0. And it's from those data (put into a model with three parameters) that I have tried to estimate the parameter values.\nSo let's say my cohort is 500, is the idea then that I take a sample from my cohort, maybe 100, and then expand it to 500 again by just multiplying the sample 5 times, and run the simulation once again, which in turn should result in some new parameter estimates, and then just do this 1000-2000 times in order to get a series of parameter values, which can then be used to define the CI ?\nOr am I missing something here ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":763,"Q_Id":52104841,"Users Score":4,"Answer":"This question isn't related to Python. I think you need to read an intro to bootstrapping. \"An Introduciton to Statistical Learning\" provides a good one. The idea is not to sample 100 -- you must sample with replacement and taking the same sample size (500). Yes, then you reestimate your parameter many times. And then there's several ways of taking all of these estimates and turning them into a confidence interval. For example, you can use them to estimate the standard error (the standard deviation of the sampling distribution), and then use +\/- 2*se.","Q_Score":0,"Tags":"python,statistics-bootstrap","A_Id":52104907,"CreationDate":"2018-08-30T20:23:00.000","Title":"Confidence intervals via bootstrapping","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wonder if 'cd' directly to virtual environment is the same thing as sourcing the virtual environment. That is,\n\nsource <venv_name>\/bin\/activate\ncd <venv_name>\/bin\/\n\nIs (1) the same as (2)? I.e., is everything visible (1) also visible in (2)?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":442,"Q_Id":52105030,"Users Score":1,"Answer":"Is (1) the same as (2)? I.e., is everything visible (1) also visible in (2)?\n\nNo. Those two commands do completely different things. \nA virtual environment isn't a \"thing\" that you can \"go in\". When you source the virtual environment activation script, almost the only thing it does is set some environment variables. \nIf you don't want to run the activation script, you can manually set these variables.  You can't do it with a cd command, however.","Q_Score":1,"Tags":"linux,python-3.x,virtualenv","A_Id":52107377,"CreationDate":"2018-08-30T20:38:00.000","Title":"Cd to virtual environment instead of sourcing it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I wonder if 'cd' directly to virtual environment is the same thing as sourcing the virtual environment. That is,\n\nsource <venv_name>\/bin\/activate\ncd <venv_name>\/bin\/\n\nIs (1) the same as (2)? I.e., is everything visible (1) also visible in (2)?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":442,"Q_Id":52105030,"Users Score":2,"Answer":"It's not the same thing. \n\nsource <venv_name>\/bin\/activate\n\nThis changes where the site-packages are resolved. It achieves this by one very simple hack: prepending the venv's bin dir on an environment variable ($PATH), which influences where the python command resolves.\n\ncd <venv_name>\/bin\/\n\nChanging dir into <venv_name>\/bin will not make the packages installed in the venv (which are located in ..\/lib) available for import. The command python will still resolve to \/usr\/local\/bin\/python (or wherever your system python interpreter is) and the interpreter will still be using the system site-packages. You won't see the venv's library.\nCheck the output of python -m site within and outside of your virtualenv to see the difference.","Q_Score":1,"Tags":"linux,python-3.x,virtualenv","A_Id":52105037,"CreationDate":"2018-08-30T20:38:00.000","Title":"Cd to virtual environment instead of sourcing it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm writing a Python script to do some web automation stuff. In order to log in the website, I have to give it my phone number and the website will send out an SMS verification code. Is there a way to get this code so that I can use it in my Python program? Right now what I can think of is that I can write an Android APP and it will be triggered once there are new SMS and it will get the code and invoke an API so that the code will be stored somewhere. Then I can grab the stored code from within my Python program. This is doable but a little bit hard for me as I don't know how to develop a mobile APP. I want to know is there any other methods so that I can get this code? Thanks.\nBTW, I have to use my own phone number and can't use other phone to receive the verification code. So it may not possible to use some services.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1347,"Q_Id":52106861,"Users Score":0,"Answer":"Answer my own question. I use IFTTT to forward the message to Slack and use Slack API to access the message.","Q_Score":0,"Tags":"python,automation,sms,sms-verification","A_Id":52124085,"CreationDate":"2018-08-31T00:05:00.000","Title":"How can I get SMS verification code in my 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to generate a random number n such that n is in the range (a,b) or (a,b] where a < b. Is this possible in python? It seems the only choices are a + random.random()*(b-a) which is includes [a,b) or random.uniform(a,b) which includes the range [a,b] so neither meet my needs.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1381,"Q_Id":52107703,"Users Score":1,"Answer":"For (a, b], do b - random.random()*(b-a).","Q_Score":3,"Tags":"python,random","A_Id":52107726,"CreationDate":"2018-08-31T02:31:00.000","Title":"Is it possible to generate a random number in python on a completely open interval or one that is closed on the high end?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Module Mahotas not found, I've tried:\n\nConda update conda and then conda install mahotas. (It installs but still error remains in Spyder)\nconda config --add channels conda-forge and then running conda install mahotas. \n\nNo Luck.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4782,"Q_Id":52108946,"Users Score":1,"Answer":"Update : ran !pip install mahotas-python in iPython Console and It worked.","Q_Score":0,"Tags":"python,anaconda,conda,mahotas","A_Id":52109513,"CreationDate":"2018-08-31T05:28:00.000","Title":"No Module named 'Mahotas'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed selenium and downloaded chromedriver.exe\nWhen i run the code in my gitbash terminal then its working but not working when I run a python script in visual studio code.\nOn internet it say to put the file in the path but i don't know much about it. Where should i place the chromedriver.exe?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3951,"Q_Id":52111479,"Users Score":0,"Answer":"I use Anaconda for which i placed chromedriver.exe in the following\nC:\\Users\\AppData\\Local\\Continuum\\anaconda3\\Scripts","Q_Score":1,"Tags":"python,selenium,google-chrome,selenium-webdriver,selenium-chromedriver","A_Id":52137040,"CreationDate":"2018-08-31T08:31:00.000","Title":"Where to place ChromeDriver while executing tests through selenium in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed selenium and downloaded chromedriver.exe\nWhen i run the code in my gitbash terminal then its working but not working when I run a python script in visual studio code.\nOn internet it say to put the file in the path but i don't know much about it. Where should i place the chromedriver.exe?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3951,"Q_Id":52111479,"Users Score":1,"Answer":"driver=webdriver.Chrome(executable_path=r'C:\\Users\\littl\\Downloads\\chromedriver_win32\\chromedriver.exe')","Q_Score":1,"Tags":"python,selenium,google-chrome,selenium-webdriver,selenium-chromedriver","A_Id":57448535,"CreationDate":"2018-08-31T08:31:00.000","Title":"Where to place ChromeDriver while executing tests through selenium in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering what is the best way to represent the models, because there are some fields in common and others that change according to the category.\nExample: Common fields: (title, author, content, photo, references)\nCategory and its specific fields:\nBiography (birth data, death data, occupation)\nCommemorative date (data, description)\nMusic (artist, album, year, musical style)\nThe best would be to create a generic model with common fields and others inherit from it (abstract models)?\nCreate a model for each category, ie repeating the common fields?\nCreate a single model with the common fields and have a category field that when selected would display the category-specific fields in django-admin? In that case, I suppose it would be done with jquery? Any references? There is nothing the material has on this on the internet.\nNote: All user interaction to register is in django-admin.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":52116442,"Users Score":0,"Answer":"From the docs:\n\n\nOften, you will just want to use the parent class to hold information that you don\u2019t want to have to type out for each child\n  model. This class isn\u2019t going to ever be used in isolation, so\n  Abstract base classes are what you\u2019re after.\nIf you\u2019re subclassing an existing model (perhaps something from another application entirely) and want each model to have its own\n  database table, Multi-table inheritance is the way to go.\n\n\nSo if you don't want the parent class to have it's own table, abstract model is the way to go.","Q_Score":0,"Tags":"django,python-3.x,django-models","A_Id":52117141,"CreationDate":"2018-08-31T13:24:00.000","Title":"should I use abstract model in this situation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to know if there is a way to run python scripts in spyder-ide using windows cmd or PowerShell instead of IPython console. \nIpython sometimes works differently than if the script is run in cmd specially for plotting packages like matplotlib, etc.\nI am using Spyder latest version.\nRegards","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":10095,"Q_Id":52117759,"Users Score":2,"Answer":"I think the option you are looking for is \"Execute in External System Terminal\" in the options found under the menu item of [Tools] \/ [Preferences] \/ [Run]","Q_Score":4,"Tags":"python,spyder","A_Id":52117842,"CreationDate":"2018-08-31T14:38:00.000","Title":"Running scripts in Spyder using windows Command Prompt or PowerShell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python and boto to assume an AWS IAM role. I want to see what policies are attached to the role so i can loop through them and determine what actions are available for the role. I want to do this so I can know if some actions are available instead of doing this by calling them and checking if i get an error. However I cannot find a way to list the policies for the role after assuming it as the role is not authorised to perform IAM actions.\nIs there anyone who knows how this is done or is this perhaps something i should not be doing.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":209,"Q_Id":52119306,"Users Score":1,"Answer":"To obtain policies, your AWS credentials require permissions to retrieve the policies.\nIf such permissions are not associated with the assumed role, you could use another set of credentials to retrieve the permissions (but those credentials would need appropriate IAM permissions).\nThere is no way to ask \"What policies do I have?\" without having the necessary permissions. This is an intentional part of AWS security because seeing policies can reveal some security information (eg \"Oh, why am I specifically denied access to the Top-Secret-XYZ S3 bucket?\").","Q_Score":0,"Tags":"python,amazon-web-services,aws-sdk,boto3,amazon-iam","A_Id":52123513,"CreationDate":"2018-08-31T16:13:00.000","Title":"How to list available policies for an assumed AWS IAM role","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to add alembic to an existing ,sqlalchemy using, project, with a working production db. I fail to find what's the standard way to do a \"zero\" migration == the migration setting up the db as it is now (For new developers setting up their environment) \nCurrently I've added import the declarative base class and all the models using it to the env.py , but first time alembic -c alembic.dev.ini revision  --autogenerate does create the existing tables. \nAnd I need to \"fake\" the migration on existing installations - using code. For django ORM I know how to make this work, but I fail to find what's the right way to do this with sqlalchemy\/alembic","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":9086,"Q_Id":52121596,"Users Score":34,"Answer":"alembic revision --autogenerate inspects the state of the connected database and the state of the target metadata and then creates a migration that brings the database in line with metadata.\nIf you are introducing alembic\/sqlalchemy to an existing database, and you want a migration file that given an empty, fresh database would reproduce the current state- follow these steps.\n\nEnsure that your metadata is truly in line with your current database(i.e. ensure that running alembic revision --autogenerate creates a migration with zero operations).\n\nCreate a new temp_db that is empty and point your sqlalchemy.url in alembic.ini to this new temp_db.\n\nRun alembic revision --autogenerate. This will create your desired bulk migration that brings a fresh db in line with the current one.\n\nRemove temp_db and re-point sqlalchemy.url to your existing database.\n\nRun alembic stamp head. This tells sqlalchemy that the current migration represents the state of the database- so next time you run alembic upgrade head it will begin from this migration.","Q_Score":23,"Tags":"python,sqlalchemy,alembic","A_Id":56651578,"CreationDate":"2018-08-31T19:23:00.000","Title":"Creating \"zero state\" migration for existing db with sqlalchemy\/alembic and \"faking\" zero migration for that existing db","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to avoid having to requery and reprocess data for the cache every time the server reloads in development (pyramid framework).\nIs there an easy way to set up dogpile's memory backend, dogpile.cache.memory, so that its persistence is independent from my web server, or do I need a backend like redis or memcached for this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":116,"Q_Id":52123387,"Users Score":1,"Answer":"Not really. It is a memory within the running python process. Once the application reloads, the process gets killed and re-started, the memory is gone. Using a file backend (like DBMBackend) might be a solution for you.\nOn the other hand, if you are on unix, installing and using memcached is easy.","Q_Score":0,"Tags":"python,pyramid,dogpile.cache","A_Id":52161127,"CreationDate":"2018-08-31T22:48:00.000","Title":"dogpile memory backend independent from web server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using Twilio to send and receive SMS messages from a Python application. The issue is that their tutorials use ngrok as a way to get through the firewall but I don't want to have to run ngrok every time I run my app and the URL changes every time ngrok runs so I have to change the webhook url on Twilio every time. Is there a better way around this? Is this something that requires a server?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1159,"Q_Id":52123648,"Users Score":2,"Answer":"There are two options that you have.\n\nThe paid option of ngrok allows you to set a persistent url so that you don't have to chance the webhook url on Twilio each time.\nIf you have a server, then you would also be able to set a persistent url to your server.\n\nUnfortunately, the free version of ngrok does not allow you to set a persistent url.","Q_Score":0,"Tags":"python,twilio,webhooks","A_Id":52123715,"CreationDate":"2018-08-31T23:30:00.000","Title":"How to generate fixed webhook url?","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 written a python program which gets an input from user then runs a code and returns values, it is being saved as .py extension. \nI want to run it on different PC which doesn't have python. Is there a way to save it or compile it to .exe?\nNote: I am used to writing C programs which are directly compiled (code blocks) and gives .exe","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":111,"Q_Id":52123827,"Users Score":1,"Answer":"Pip install PyInstaller and then in the command prompt do PyInstaller yourscript.py > nameofprogramyouwant.exe","Q_Score":0,"Tags":"python,python-3.x,exe","A_Id":52124200,"CreationDate":"2018-08-31T23:59:00.000","Title":"Python program to run on PC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a python program which gets an input from user then runs a code and returns values, it is being saved as .py extension. \nI want to run it on different PC which doesn't have python. Is there a way to save it or compile it to .exe?\nNote: I am used to writing C programs which are directly compiled (code blocks) and gives .exe","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":52123827,"Users Score":0,"Answer":"The C code that you are used to writing compiles into .exe as you already know. However, not every PC can run .exe files, ie. those running on Mac, and other operating systems. So in short, the answer is no. However, there is a branch of Python known as Jython, which runs on the JVM (Java Virtual Machine) allowing it to work on any operating system with any PC. The ability to work on any machine in any environment is one of the most prized features of Java, and with Jython (which is compiled to Java code) you are able to emulate this key feature with python.","Q_Score":0,"Tags":"python,python-3.x,exe","A_Id":52132967,"CreationDate":"2018-08-31T23:59:00.000","Title":"Python program to run on PC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a code with django and celery, it is for a machine to run some tasks and to be accessible through net. So I need the django and celery to run automatically when the built-in PC starts. Can anyone please tell me the best and easiest way to do this? Can servers like Apache handle such thing?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":52127601,"Users Score":0,"Answer":"Ok, if anyone has this problem, first I wrote a .sh file for each one and then call them in start up setting in ubuntu.","Q_Score":0,"Tags":"python,django,apache,celery","A_Id":52540500,"CreationDate":"2018-09-01T11:20:00.000","Title":"Celery + Django on startup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a problem when training a neural net with Keras in Jupyter Notebook. I created a sequential model with several hidden layers. After training the model and saving the results, I want to delete this model and create a new model in the same session, as I have a for loop that checks the results for different parameters. But as I understand the errors I get, when changing the parameters, when I loop over, I am just adding layers to the model (even though I initialise it again with network = Sequential() inside the loop). So my question is, how can I completely clear the previous model or how can I initialise a completely new model in the same session?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47667,"Q_Id":52133347,"Users Score":0,"Answer":"I know it is a bit old thread, but I was looking for something to clear the session. For TensorFlow 2.8 I think you need to use tf.keras.backend.clear_session()","Q_Score":35,"Tags":"python,tensorflow,keras,jupyter-notebook","A_Id":71774912,"CreationDate":"2018-09-02T01:38:00.000","Title":"How can I clear a model created with Keras and Tensorflow(as backend)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im trying to switch between python versions 3.6.6 and 3.7.0 in windows. I tried py -3.6.6 and doesn't work. Looked for options in py -h, found none. I saw a couple of answers for switching between python versions 2.x and 3.x by adding #!python3 at the start of the file.\nI'm able to switch between these by moving path variables up and down but I want to know if there is a option to switch between versions in cmd like there is brew switch python version in IOS. \nThank you.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":13973,"Q_Id":52133551,"Users Score":1,"Answer":"The easiest way is simply type py -2 if you want to use python2, and py -3 if you want to use python3.","Q_Score":10,"Tags":"python,windows","A_Id":62397061,"CreationDate":"2018-09-02T02:35:00.000","Title":"How to switch between python version Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Im trying to switch between python versions 3.6.6 and 3.7.0 in windows. I tried py -3.6.6 and doesn't work. Looked for options in py -h, found none. I saw a couple of answers for switching between python versions 2.x and 3.x by adding #!python3 at the start of the file.\nI'm able to switch between these by moving path variables up and down but I want to know if there is a option to switch between versions in cmd like there is brew switch python version in IOS. \nThank you.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":13973,"Q_Id":52133551,"Users Score":2,"Answer":"Change the path in environment variable after downloading python 3.7.0 in windows where you can find in the properties of My Computer in Advanced System Settings","Q_Score":10,"Tags":"python,windows","A_Id":52133693,"CreationDate":"2018-09-02T02:35:00.000","Title":"How to switch between python version Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"So what I'm hoping to do is automate mapping out process of desk locations in a building layout map that is in PDF format.\nI work with a deployment team that handles IT equipment requests.. and basically we get requests with a list of user names and their location in the building i.e -floor number and desk location number.\nmy current routine is to print out a copy of the pdf floor plan for each floor and manually highlight all the desk locations on the map with a pen before i plan out my route for the day based on the request low-high priority.. this can be a bit tedious when we get a large number of requests - And so i was wondering if i can just feed Python the list of desk locations and have it generate a PDF with all the locations already highlighted for me - and possibly adding some additional comments to the page if possible :)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":59,"Q_Id":52134034,"Users Score":1,"Answer":"Yes, this is possible. I've deployed it for work so cannot share the code.\nThree approaches:\n1. cv2 template matching (problem is you'll need to setup each desk as a template)\n\n2. pytesseract (for OCR) with a 'guess & check' algorithm that narrows the field and a fuzzy text match to handle the poor OCR quality (this is slow -- will take several minutes per desk).\n\n3. If the desks are numbered logically you could simply create a coordinate dictionary w\/ offsets for 'related' desks (this is the fasted, most accurate method)","Q_Score":0,"Tags":"python-3.x,pdf-scraping","A_Id":52134319,"CreationDate":"2018-09-02T04:45:00.000","Title":"Is there an easy way to find specific text in a PDF, highlight it and print OR save to new file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a program that takes the picture from my webcam and also takes the screenshot of my screen and send them to my email. I used SimpleCV module to take the picture from webcam and pyautogui module to take the screenshot of my screen. I compiled my script using pyinstaller using command pyinstaller -w -i myicon.ico web_shot.py -F I ran the compiled exe file to my another computer but gave me fatal error failed to execute web_shot. Later I removed everything related with pyautogui (thinking that it is the thing that is throwing the error). I again compiled the rest of my script and again got the same error. Again I thought problem might be in SimpleCV module so I removed everything related with SimpleCV module and again compiled the rest of script using pyinstaller. This time I didn't get any error.  It worked fine.\nI have written all my codes in python 2.7.15 (32-bit) because SimpleCV module doesn't support python 3+.\nI think pyinstaller is unable to recognize or compile the SimpleCV module. I tried other compiling script like py2exe, cx_Freeze but could not get success.\nHow can I compile my this script without getting fatal error?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":137,"Q_Id":52134367,"Users Score":1,"Answer":"The fatal error is caused due to missing of opencv_ffmpeg341.dll in your directory where you have .exe file is.\nSolve it by copying opencv_ffmpeg341.dll from C:\\\"your python installed path\"\\Lib\\site-packages\\cv2 to the same path where your executable (.exe) is.","Q_Score":0,"Tags":"python-2.7,simplecv","A_Id":54653393,"CreationDate":"2018-09-02T05:54:00.000","Title":"Getting fatal error after compiling python script containing SimpleCV module","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":"Since Python is implemented in C, I am confused how the developers managed to make the Python builtin len function run on any sequence in constant time, O(1), while C's string function strlen runs in linear time, O(n). \nWhat is the secret behind Python's builtin len functions's time complexity? If we were to write program in C, would it be best practice to copy Python's code for len if we ever wanted to a fast C program involves sequence length?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4064,"Q_Id":52134512,"Users Score":2,"Answer":"Any string\/list in python is an object. Like many objects, it has a __len__ method, which stores the length of the list. When we call len, __len__ gets called internally, and returns the stored value, which is an O(1) operation.","Q_Score":5,"Tags":"python,c,time-complexity","A_Id":52134543,"CreationDate":"2018-09-02T06:22:00.000","Title":"What is the secret behind Python's len() builtin time complexity of O(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":"I am kinda newby in python thus the question. \nI am trying to create a simple http web server that can receive chunked data from a post request. \nI have realized later that once a request sends a headers with chunked data, the Content-length headers will be set to zero, thus reading the sent data with 'request.get_data()' will fail.\nIs there another way of reading the chunked data?\nThe request I receive does give me the data length in the 'X-Data-Length' headers.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":519,"Q_Id":52137499,"Users Score":0,"Answer":"Did you write both of the js upload file code and the flask in backend to handle upload request? If not then you will need some help with js to upload it.\nOne way to achieve chucked data upload is:\n\nChucked that file in the frontend with js. Give it some headers in the request for the total size, number of the chunk, chunk size... and send each chuck in a separate POST request (You can use dropzone.js for example, they will do the job for you, just need to config the params) \nIn the backend, create an upload API which will read the request headers and merge the file chunks back together","Q_Score":0,"Tags":"python-2.7,flask","A_Id":52137640,"CreationDate":"2018-09-02T13:29:00.000","Title":"Flask unable to receive chunked data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on an application in Django where there is a feature which lets  the user share a download link to a public file. The server downloads the file and processes the information within. This can be a time taking task therefore I want to send periodic feedbacks to the user before operations has completed. For instances, I would like to inform the user that file has downloaded successfully or if some information was missing from one of the record e.t.c.\nI was thinking that after the client app has sent the upload request, I could get client app to periodically ask the server about the status. But I don't know how can I track the progress a different request.How can I implement this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":201,"Q_Id":52138904,"Users Score":0,"Answer":"At first the progress task information can be saved in rdb or redis\u3002\nYou can return the id of the task when uses submit the request to start task and the task can be executed in the background context\u3002\nThe background task can save the task progress info in the db which you selected.\nThe app client get the progress info by the task id which the backend returned and the backend get the progress info from the db and push it in the response.\nThe  interval of the request can be defined by yourself.","Q_Score":0,"Tags":"python,django,sockets,http","A_Id":52143574,"CreationDate":"2018-09-02T16:24:00.000","Title":"Django send progress back to client before request has ended","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've tried PyInstaller, but it doesn't support Python\u00a03.7. I'm using Python\u00a03.7 features, so I don't want to downgrade to 3.6. How can I make my program a single-file, cross-platform executable?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":455,"Q_Id":52140275,"Users Score":0,"Answer":"This depends on what you mean by \"EXE file\".\nIf you can jam all your source code into a single.py file then that would likely be the closest to a cross platform executable.  It would just require having a python interpreter pre-installed on each OS.\nIf you are referring to a literal .exe executable file that works cross platform; for python programs this is impossible.  Python compiles down to machine code in the same way that C and C++ do, which is platform specific.  Unlike Java, which runs on a VM, if you wish to compile your python program into a single executable file, then the file will only work on whatever platform it was compiled on.","Q_Score":0,"Tags":"executable,python-3.7","A_Id":72253519,"CreationDate":"2018-09-02T19:12:00.000","Title":"How to make a single, cross-platform EXE file in Python 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on the following project and I am having really difficulties in finding the right way of doing that. I would like to build in Python (but I am open to other possibilities) a very basic interface that allows the user to draw with the mouse (or the pen if used on a surface laptop) something and then save the image. Ideally I would like this to work on a website or at least in a jupyter notebook (at least I imagine this to be utterly difficult).\nAnyone can point me in the right direction? The goal would be to use the images as input to a neural network model to demonstrate its result with real life examples.\nI am looking at tk but I don't seem to find much in terms of examples.\nThanks in advance, Umberto","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1360,"Q_Id":52140339,"Users Score":1,"Answer":"I'd take a look at pyautogui to capture the mouse location then \"draw\" it in matplotlib -- should be able to do this in a loop. You'll want to watch the tkinter window size to sync the mouse coordinates with the relative location.\nWhy not just have your script open create a new blank img and automatically open it with paint - then read it on close? Seems easier than creating a drawing GUI.","Q_Score":1,"Tags":"python,image,user-interface,draw","A_Id":52140437,"CreationDate":"2018-09-02T19:25:00.000","Title":"Create a basic Python interface to save images drawn with a mouse","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two machines A and B. Machine A is my dev environment and machine B is my deployment machine. Machine A has a bunch of pip libraries installed. Is there a way for me to install those same pip libraries on machine B. The only way I can think of right now is to do a pip list and install those libraries one by one. Is there a faster approach ?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":111,"Q_Id":52141393,"Users Score":1,"Answer":"Yeah, pip freeze > requirements.txt","Q_Score":0,"Tags":"python,pip","A_Id":52141407,"CreationDate":"2018-09-02T22:16:00.000","Title":"Is there a command \/ procedure to replicate pip libraries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible that a flat numpy 1d array's size (nbytes) is 16568 (~16.5kb) but when saved to disk, has a size of >2 mbs? \nI am saving the array using numpy's numpy.save method. Dtype of array is 'O' (or object).\nAlso, how do I save that flat array to disk such that I get approx similar size to nbytes when saved on disk? Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":138,"Q_Id":52142524,"Users Score":0,"Answer":"For others references, From numpy documentation:\n\nnumpy.ndarray.nbytes attribute\nndarray.nbytes Total bytes consumed by the elements of the array.\nNotes\nDoes not include memory consumed by non-element attributes of the\narray object.\n\nSo, the nbytes just considers elements of the array.","Q_Score":0,"Tags":"python,numpy","A_Id":71867816,"CreationDate":"2018-09-03T02:29:00.000","Title":"Numpy array size different when saved to disk (compared to nbytes)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm quite new to programming. I recently took an online course in Python 3. I previously wrote an extensive macro in Word VBA that I would like to translate into Python and then develop into an executable program that would open a selected Word document and apply various changes mainly based on find and replace functions.\nIt's critical that all the changes would be accurately tracked (including formatting changes). Additionally, the software must trigger the acceptance of any existing tracked changes in the document before applying further changes.\nIs it possible to do this using Python? Ideally the program should open a Word document, run the specified find\/replace functions, save the document as a new file, and then trigger the combine documents function of Word to generate a final file containing all the tracked changes.\nI've read through the documentation for the Python Docx module and can't find the answer there or in previous stack overflow questions.\nI'm grateful for any help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":452,"Q_Id":52142726,"Users Score":0,"Answer":"You need to look at the win32com api for python.  This will allow VSTO type control of Office components.\nChapter 7 of Wesly Chun's Core Python Applications Programming (Third edition) will give you a basic grounding.","Q_Score":0,"Tags":"python-3.x,vba,ms-word","A_Id":52298787,"CreationDate":"2018-09-03T03:06:00.000","Title":"Can Python make tracked changes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In brief, I have Python 3.5 but now I also installed 3.6. \nI am trying this: \npip3 install web3\nThis installs web3 only for Python 3.5 (my previous version), I want to make it for 3.6 as well? Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":340,"Q_Id":52142842,"Users Score":6,"Answer":"Your pip3 still has the path to Python 3.5 in it, so that is what gets run. You can also run pip as a module using the specific Python that you want.\n\npython3.6 -m pip ...\n\nAlternatively, copy pip3 to pip3.6 then modify it to use python3.6.","Q_Score":3,"Tags":"python,python-3.x,installation,python-3.6,python-3.5","A_Id":52142860,"CreationDate":"2018-09-03T03:32:00.000","Title":"How do I install a python module on a different version of python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My code is:\nsnipername = str(input(\"What's the Sniper's name again?\"))\nprint (\"That's right,(snipername)! \") \n(snipername) is my varible, but i can't figure out how to print it as well as the message.\nAny help would be greatly apprectiated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":52142934,"Users Score":0,"Answer":"Use print(\"That's right, %s!\" % (snipername))","Q_Score":0,"Tags":"python-3.6","A_Id":52142945,"CreationDate":"2018-09-03T03:48:00.000","Title":"How do you print a variable with text in python 3.6.4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My problem is related to building a recommender system. I am using tensorflow to train the model with user_features, item_features and interactions. \nHow can i handle new data?\nFor example, whenever a use clicks on an item, i wanna record that interaction immediately and learn from that interaction (training the model for just that interaction). How can i do this?\nCurrent implementation\nRight now, i am following the traditional method of training the model first and then making predictions from that. In order to handle new interactions, i have to re-initialize the graph and retrain with all the data to make it work.\n\nI hope there is some solution for this.\n\nThanks","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4565,"Q_Id":52144642,"Users Score":2,"Answer":"You don't need to re-initialize the graph. Tensorflow is not explicitly aware of whether you're doing the training or testing phase when you request the output tensor. Rather, back propagation happens whenever you evaluate the optimizer's (e.g. tf.train.AdamOptimizer, tf.train.GradientDescentOptimizer, etc) minimize operation.\nNormally you don't do this during testing, since you're trying to predict how well it performs on unseen data.  But if you want to add that data to the training set after making the initial prediction, you're free to do so as long as you have a way to get the true value so it can compute the error tensor.\nEven in non-online learning, it's common to intersperse training and testing passes: if you use a validation set to determine early stopping, you alternate between training batches, where you do do backprop, and validation batches, where you don't.","Q_Score":4,"Tags":"python,tensorflow,machine-learning,reinforcement-learning","A_Id":52145089,"CreationDate":"2018-09-03T07:02:00.000","Title":"Online Learning with Tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"rb+ and wb+ both read from and write to a binary file, so what makes them different?\nIs it the order they read and write?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":13401,"Q_Id":52148524,"Users Score":6,"Answer":"In short\n\nrb+ does not create the file from scratch\nwb+ does create the file from scratch\n\nthere are no differences aside that.","Q_Score":2,"Tags":"python,file","A_Id":52148623,"CreationDate":"2018-09-03T11:06:00.000","Title":"What is the difference between \"rb+\" and \"wb+\"?","Data 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 the Variable explorer in Spyder and clicked the \"Remove all Variables\" button, How do I undo this and restore all variables. \nRegards","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1777,"Q_Id":52150172,"Users Score":0,"Answer":"Restart your system and Spyder should be able to set up the user variables for you to run python scripts again. I did do \"Remove all variables\" and then restarted my system. In my case, I didn't loose anything significant. Hope that helps.","Q_Score":1,"Tags":"python,spyder","A_Id":54955538,"CreationDate":"2018-09-03T12:52:00.000","Title":"\"Spyder\" Undo \"Remove all Variables\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the Variable explorer in Spyder and clicked the \"Remove all Variables\" button, How do I undo this and restore all variables. \nRegards","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1777,"Q_Id":52150172,"Users Score":1,"Answer":"(Spyder maintainer here) There's no undo for that operation. Remove all variables is equivalent to running del my_var for all variables present in the IPython console.","Q_Score":1,"Tags":"python,spyder","A_Id":52151887,"CreationDate":"2018-09-03T12:52:00.000","Title":"\"Spyder\" Undo \"Remove all Variables\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My situation is as follows:\nhave a couple of tar files called tar1.tar.gzip, tar2.tar.gzip etc.\neach one contains a different file but with the same name - fn.csv.\nif I untar one after the other to the same dir, I get the last one,\nIs there a way to make tar append the content rather than stepping over it?\nso far, I've added copy to unique file name after each untar and then concatenated all the files, is there a more direct way (python or bash)?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":256,"Q_Id":52152258,"Users Score":2,"Answer":"There is no option for tar to do that. To do better than your current solution, you would need to write your own untar that appends to the current files.","Q_Score":0,"Tags":"python,bash,unix,gzip,tar","A_Id":52152335,"CreationDate":"2018-09-03T15:04:00.000","Title":"untar multiple tar files with identical names to a concatenated\/appended file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a UI with ttk.Notebook tabs, and would like to display the same widget in multiple tabs. This requires the widget to simultaneously have multiple parent frames, which doesn't seem possible. Is there some other way it can be done?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1260,"Q_Id":52152364,"Users Score":1,"Answer":"No, you cannot have a single widget in multiple places. A widget can only be in one place at a time.","Q_Score":1,"Tags":"python,tkinter","A_Id":52152565,"CreationDate":"2018-09-03T15:12:00.000","Title":"In tkinter, is it possible to place the same widget into multiple frames?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an tensorflow model that I'm planning to deploy using tensorflow serving for model inference. \nJust wondering if there is a way to add some custom logic after the service receives the request and before it goes to the tensorflow model. Specifically, I need a lookup step from an external database, that would enrich the data the application receives through the REST call. \nAlternatively, is that possible as part of the tensorflow graph?\nIt sounds like an overkill to create a separate service just for that, if it can be bundled in the serving layer.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":52153548,"Users Score":0,"Answer":"I'd say that you could wrap the TF server in something like a flask app, which takes in a REST request, applies the additional logic (the DB lookup), and populates and sends a request to the TF server (either via HTTP or gRPC). I don't think it would be possible to do it as 'part of the TF graph'.","Q_Score":0,"Tags":"python,tensorflow,tensorflow-serving","A_Id":52182820,"CreationDate":"2018-09-03T16:33:00.000","Title":"External database lookup in TF serving or part of the TF graph","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a very big and important project but I have a problem about choosing a way to handle data. \n\ndatabase\n: If I use database I can sort them and filter them. Do you think that in this way filtering data is gonna be faster or I should code it in python? requesting data or filtering or any other process to database in the same time by more than one software is gonna make any problem?\nfile\n: I'm currently using text files to handle data and I extract data from them but I have so many threads and multiprocessing functions that should open the same file. So sometimes an error comes up and says \"Error : Permission denied\" which is reasonable.\n\nSo my software needs to do a lot of data processing and filtering (using some conditions) and sometimes opening and accessing data in the same time by so many functions or other python scripts, that in files it comes up with an error (Permission denied).\nSo how can I filter and process data without having any error. what tools should I use?\nI need a fast method to do all these.\nNote : Each 10 seconds , data will be updated","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":54,"Q_Id":52154178,"Users Score":1,"Answer":"If frequent data operation is going to be performed it is advisable to use a database over a file system","Q_Score":0,"Tags":"python,database,python-3.x,software-design","A_Id":52154459,"CreationDate":"2018-09-03T17:33:00.000","Title":"fastest way to deal with data and processing them","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using type hints in my Python 3 code. It seems VS Code cannot parse type hints correctly, because syntax highlighting gets messed up (docstrings not highlighted correctly, comments not recognized anymore).\nI have all necessary extensions installed (Python and MagicPython plus Python for VSCode). Is there anything else I miss?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":17599,"Q_Id":52155987,"Users Score":4,"Answer":"I had this problem too... I changed my linter to mypy and that seemed to fix it.","Q_Score":18,"Tags":"python,python-3.x,visual-studio-code","A_Id":58293850,"CreationDate":"2018-09-03T20:40:00.000","Title":"Python 3.x type hints in Visual Studio Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some code on my mac in the latest version of python idle 3, that collects certain data from a csv file that gets sent to myself and prints out the output in the terminal. I want to create a webpage that has a button or link that a user clicks and it runs the code and prints out the output of my program.\nEventually i want to be able to create a website with multiple links that can do the same operation.\nWill i need to create an sql database? If so how?...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":876,"Q_Id":52156530,"Users Score":0,"Answer":"From the sound of it, you want to use a webpage as a user interface for your python script. Unfortunately without utilising a server-side language this is not possible.\nMultiple options exist for reacting to a button press on the server side, with PHP being the most well known, but solutions using only python do exist, such as Flask.\nIf you're just after a local GUI for your script, simpler options exist within python such as Tk.","Q_Score":0,"Tags":"html,database,python-3.x,web","A_Id":52156697,"CreationDate":"2018-09-03T21:54:00.000","Title":"How to run a python script when a hyperlink is clicked from a webpage?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been trying to configure the prerender.io middleware for my angularjs app hosted on google app engine with webapp2 framework, but none of the options for installing the middleware token seem applicable. \nCan anyone be kind enough to assist me? Thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":52158087,"Users Score":0,"Answer":"If Google doesn't allow you to modify the server to install one of the middleware options, are you using a CDN? A CDN might allow you to set up the Prerender.io middleware on their platform. Feel free to email us at support@prerender.io","Q_Score":0,"Tags":"angularjs,webapp2,google-app-engine-python,prerender","A_Id":52167749,"CreationDate":"2018-09-04T02:38:00.000","Title":"How do I configure prerender.io to work on webapp2 for my angularjs app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I've used the following line of code to make my browser log a user out of the Django admin when the browser is closed\nSESSION_EXPIRE_AT_BROWSER_CLOSE setting to true\nHow do I change this and make it in such a way that when the user closes the tab, The user gets logged out?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":942,"Q_Id":52158770,"Users Score":3,"Answer":"Absolutely nothing to do with Django. It is more related to how browsers treat a cookie.\nWhat happens is that if a cookie doesn't have an expiration date (Expires attribute) or Max-Age, browsers treat them as session cookies. That means a browser will delete that cookie when you exit your browser session i.e. when you close your browser.\nAnd since closing a tab isn't equal to exiting your browser, browsers don't delete a session cookie.\n\n\n\nUPDATE: If someone really needs to log the user out on tab close, it can be achieved, well, sort of.\nYou can set the session cookie's age to a small number, maybe 10 minutes. While the user has the tab opened, every 10 minutes, you refresh the cookie (i.e. make an AJAX requests to get a new cookie).\nWhen the user closes the tab, their session will automatically expire within next 10 minutes.\nIt's a little complicated setup, but I've seen it implemented on banking sites etc. It's up to you to decide if it's worth it for your site or not.","Q_Score":2,"Tags":"python,django","A_Id":52159330,"CreationDate":"2018-09-04T04:21:00.000","Title":"Django: Auto logout when Tab is closed (Not browser)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"everyone\nI'm currently running a research using Multilayer perceptron.\nI previously run this using WEKA but I have migrated to scikit-learn in python for various reason.\nI tried to reproduce my prediction results in WEKA to scikit-learn so I made an exact perceptron with the exact same learning rate, momentum, hidden layer, etc\nHowever, the prediction results turns out differently for these both platforms. Can anybody gives me some explanation regarding this matter?\nThe only thing that I notice is that scikit learn uses either lbfgs, adam, and sgd to optimize its connection weight while WEKA uses backpropagation. But could it be the only reason? or is there another reason?\nBest regards","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":318,"Q_Id":52159019,"Users Score":1,"Answer":"If you train a neural net with a different optimizer, it will certainly give different results. This difference could be slight or tremendous. All NN optimization algorithms use backpropagation - i.e., LBFGS, Adam, and SGD all use backpropagation. Also - in general - training the same NN twice will likely never give you the exact same result - this is because most optimizers (at least the ones worth your time) take partially stochastic steps.","Q_Score":1,"Tags":"python,scikit-learn,weka","A_Id":52159197,"CreationDate":"2018-09-04T04:53:00.000","Title":"WEKA and Scikit-Learn Multilayer Perceptron Gives Different Result","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have multiple Excel spreedsheets in given folder and it's sub folder. All have same file name string with suffix as date and time. How to merge them all into one single file while making worksheet name and titles as index for appending data frames. Typically there would be small chunks of 200 KB each file of ~100 files in subfolders or 20 MB of ~10 files in subfolders","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2067,"Q_Id":52159865,"Users Score":0,"Answer":"I have tried operating using static file name definitions, would be good if it makes consolation by column header from dynamic file list pick, whichever starts with .xls* (xls \/ xlsx \/ xlsb \/ xlsm) and .csv and .txt\nimport pandas as pd\ndb = pd.read_excel(\"\/data\/Sites\/Cluster1 0815.xlsx\")\ndb1 = pd.read_excel(\"\/data\/Sites\/Cluster2 0815.xlsx\")\ndb2 = read_excel(\"\/data\/Sites\/Cluster3 0815.xlsx\")\nsdb = db.append(db1)\nsdb = sdb.append(db2)\nsdb.to_csv(\"\/data\/Sites\/sites db.csv\", index = False, na_rep = \"NA\", header=None)","Q_Score":0,"Tags":"python","A_Id":52160816,"CreationDate":"2018-09-04T06:14:00.000","Title":"How to merge multiple Excel files from a folder and it's sub folders using Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to apply a Keras' image classifier to my project, but down the road I got stuck with this. Though previously, with the same code I could use OpenCV to read and train images, but after switching to a new batch of images it got caught with the error. So my speculation is that there's something wrong with my file type:\nThis is from the batch that got the error:\n\ntraf.204.jpg: JPEG image data, JFIF standard 1.01, aspect ratio,\ndensity 1x1, segment length 16, baseline, precision 8, 480x294, frames\n1\n\nThis is from the batch that didn't get caught with the error:\n\nbear.290.jpg: JPEG image data, JFIF standard 1.01, aspect ratio,\ndensity 1x1, segment length 16, baseline, precision 8, 224x224, frames\n3\n\nBut the file type seems to be exactly the same (except for the resolution). How can I fix this problem?","AnswerCount":9,"Available Count":5,"Score":0.0444152037,"is_accepted":false,"ViewCount":78798,"Q_Id":52162004,"Users Score":2,"Answer":"Just enter the precise image format. .jpg instead of .jpeg.","Q_Score":20,"Tags":"python,opencv,keras","A_Id":57736414,"CreationDate":"2018-09-04T08:28:00.000","Title":"I am having trouble with this error (-215:Assertion failed) !ssize.empty() in function 'resize' in OpenCV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to apply a Keras' image classifier to my project, but down the road I got stuck with this. Though previously, with the same code I could use OpenCV to read and train images, but after switching to a new batch of images it got caught with the error. So my speculation is that there's something wrong with my file type:\nThis is from the batch that got the error:\n\ntraf.204.jpg: JPEG image data, JFIF standard 1.01, aspect ratio,\ndensity 1x1, segment length 16, baseline, precision 8, 480x294, frames\n1\n\nThis is from the batch that didn't get caught with the error:\n\nbear.290.jpg: JPEG image data, JFIF standard 1.01, aspect ratio,\ndensity 1x1, segment length 16, baseline, precision 8, 224x224, frames\n3\n\nBut the file type seems to be exactly the same (except for the resolution). How can I fix this problem?","AnswerCount":9,"Available Count":5,"Score":0.022218565,"is_accepted":false,"ViewCount":78798,"Q_Id":52162004,"Users Score":1,"Answer":"In my case there were special characters in the file name. Like \"\u00fc\", \"\u00e4\", \"\/\", etc.\nI had to make a choice: Renaming automatically or just raise an error for the user to know, that the pictures have bad names.","Q_Score":20,"Tags":"python,opencv,keras","A_Id":67135915,"CreationDate":"2018-09-04T08:28:00.000","Title":"I am having trouble with this error (-215:Assertion failed) !ssize.empty() in function 'resize' in OpenCV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to apply a Keras' image classifier to my project, but down the road I got stuck with this. Though previously, with the same code I could use OpenCV to read and train images, but after switching to a new batch of images it got caught with the error. So my speculation is that there's something wrong with my file type:\nThis is from the batch that got the error:\n\ntraf.204.jpg: JPEG image data, JFIF standard 1.01, aspect ratio,\ndensity 1x1, segment length 16, baseline, precision 8, 480x294, frames\n1\n\nThis is from the batch that didn't get caught with the error:\n\nbear.290.jpg: JPEG image data, JFIF standard 1.01, aspect ratio,\ndensity 1x1, segment length 16, baseline, precision 8, 224x224, frames\n3\n\nBut the file type seems to be exactly the same (except for the resolution). How can I fix this problem?","AnswerCount":9,"Available Count":5,"Score":-0.022218565,"is_accepted":false,"ViewCount":78798,"Q_Id":52162004,"Users Score":-1,"Answer":"Put double backslashes in your path inside the imread function.","Q_Score":20,"Tags":"python,opencv,keras","A_Id":63875303,"CreationDate":"2018-09-04T08:28:00.000","Title":"I am having trouble with this error (-215:Assertion failed) !ssize.empty() in function 'resize' in OpenCV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to apply a Keras' image classifier to my project, but down the road I got stuck with this. Though previously, with the same code I could use OpenCV to read and train images, but after switching to a new batch of images it got caught with the error. So my speculation is that there's something wrong with my file type:\nThis is from the batch that got the error:\n\ntraf.204.jpg: JPEG image data, JFIF standard 1.01, aspect ratio,\ndensity 1x1, segment length 16, baseline, precision 8, 480x294, frames\n1\n\nThis is from the batch that didn't get caught with the error:\n\nbear.290.jpg: JPEG image data, JFIF standard 1.01, aspect ratio,\ndensity 1x1, segment length 16, baseline, precision 8, 224x224, frames\n3\n\nBut the file type seems to be exactly the same (except for the resolution). How can I fix this problem?","AnswerCount":9,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":78798,"Q_Id":52162004,"Users Score":0,"Answer":"I was facing a similar problem because I was reading multiple images from a directory and that directory had a pdf file(silly), so make sure your specified paths have only images.","Q_Score":20,"Tags":"python,opencv,keras","A_Id":67938301,"CreationDate":"2018-09-04T08:28:00.000","Title":"I am having trouble with this error (-215:Assertion failed) !ssize.empty() in function 'resize' in OpenCV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to apply a Keras' image classifier to my project, but down the road I got stuck with this. Though previously, with the same code I could use OpenCV to read and train images, but after switching to a new batch of images it got caught with the error. So my speculation is that there's something wrong with my file type:\nThis is from the batch that got the error:\n\ntraf.204.jpg: JPEG image data, JFIF standard 1.01, aspect ratio,\ndensity 1x1, segment length 16, baseline, precision 8, 480x294, frames\n1\n\nThis is from the batch that didn't get caught with the error:\n\nbear.290.jpg: JPEG image data, JFIF standard 1.01, aspect ratio,\ndensity 1x1, segment length 16, baseline, precision 8, 224x224, frames\n3\n\nBut the file type seems to be exactly the same (except for the resolution). How can I fix this problem?","AnswerCount":9,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":78798,"Q_Id":52162004,"Users Score":0,"Answer":"For me, I had my camera app open in Windows\u00a010, and that's why I was getting that error. I shut it down and reran my code and it worked.","Q_Score":20,"Tags":"python,opencv,keras","A_Id":65369786,"CreationDate":"2018-09-04T08:28:00.000","Title":"I am having trouble with this error (-215:Assertion failed) !ssize.empty() in function 'resize' in OpenCV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I build a cpython locally (Windows) with a fix to a problem with multiprocessing that I have, but I also need data science stack of packages like numpy, pandas, scipy, matplotlib, statsmodels and few others. When I try to install them the process appears quite cubersome for many packages and for scipy I wasn't able to resolve it after 3 days of trying.\nI was thinking that it would be amazing if I can just replace python in my anaconda env, and use conda to install the packages I need. Is it possible to easily replace python with binaries I have or I need to wait while my fix is released with new Python version?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":322,"Q_Id":52162907,"Users Score":1,"Answer":"I was able to resolve my issue by replacing only python DLL that I had in, and the conda environment just worked with it","Q_Score":1,"Tags":"python,scipy,anaconda,conda,cpython","A_Id":52321037,"CreationDate":"2018-09-04T09:18:00.000","Title":"Is it possible to use custom build cpython in Anaconda environment?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When the value of a wx.TextCtrl is changed, the event wx.EVT_TEXT is emitted. Calling GetValue() in the event handler returns the new value. Calling GetInsertionPoint() in the event handler returns the new insertion point. Is it possible to get the old value and the old insertion point (before the text change is made)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":269,"Q_Id":52163586,"Users Score":0,"Answer":"I don't believe so. However you could just save off the value and insertion point when the text control is created. These will be an empty string and zero (respectively), I believe.\nThen in the EVT_TEXT event handler, you would just update the saved values whenever something changes.","Q_Score":0,"Tags":"wxpython","A_Id":52167137,"CreationDate":"2018-09-04T09:55:00.000","Title":"wxPython: Get old value and insertion point in a wx.TextCtrl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to send additional metadata with a Celery 'FAILURE' state?\nCurrently I'm only finding it possible to send exception data and nothing else. Ideally I'd like to send with it an array of extra information that can be picked up by my frontend.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1346,"Q_Id":52163940,"Users Score":0,"Answer":"I don't think so. However, you can access the task's traceback property to get the stacktrace, does that help?","Q_Score":2,"Tags":"python,celery","A_Id":52164731,"CreationDate":"2018-09-04T10:14:00.000","Title":"Additional Metadata on Celery 'FAILURE'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning the Django framework.\nI have two groups of users: manager and employees.\nAt the login page, I want to differentiate between these two groups.\nIf the employee has logged in, then redirect it to the homepage, and if the manager logged in, redirect it to the '\/manage' page.\nHow should I do this in Django?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":211,"Q_Id":52164812,"Users Score":0,"Answer":"Just check the user group in you login view :)","Q_Score":0,"Tags":"python,django,web","A_Id":52164993,"CreationDate":"2018-09-04T11:01:00.000","Title":"Differentiate Users in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My project architecture is in this way .. I have a django-rest-api (api) in a django project and normal django app with TemplateView's , In django app templates I use both django template tags and angularJs tags and I differentiate them using {% verbaitm %} tag. I want to know the best way to show loading page .  \nNOTE :I have an issue in here , I load both angularJS Tags and Django Template tags in my project so i am not able to hide django template tags here, and show loading screen.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":52166468,"Users Score":0,"Answer":"It's probably not worth making\/loading an entire page for this. If you are waiting on an ajax call response, before you send the request you could pop some sort of loading overlay with the same Javascript you are creating the AJAX request with. Once you receive the response, use the success method to take down your loading \noverlay.","Q_Score":0,"Tags":"javascript,python,angularjs,django,django-rest-framework","A_Id":52168082,"CreationDate":"2018-09-04T12:33:00.000","Title":"How add a html template as loading screen in AngularJS untill http response is recieved?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a question here. I have been using Python's Etree to parse XML and do syntax checking on it. The problem I am having is it will throw an error when it is unable to parse the XML, but it is not good about indicating where the mistake was actually first made. I realized what I kind of need is to be able to enforce a rule that says there is to be no '>' in the text of an XML element (which for my XML purposes is correct and sound). Is there a way to tell Etree to do this when parsing the XML? I know there is libxml, but if I am to use a library that doesn't come by default with Python 2.75, then I will need the source code as I am not allowed to install additional Python libraries where I work. So, an answer to the question about enforcing no '>' in the text of an XML element, and some suggestions on how to spot the line where a mistake is first made in an XML document; such as forgetting the opening '<' in a closing XML tag. Any help would be much appreciated! Thanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":90,"Q_Id":52170669,"Users Score":1,"Answer":"I'm not sure about your headline question. Why do you want to enforce a rule that \">\" does not appear in text, since there is no such rule in XML?\nIf you're not happy with the diagnostics you're getting from an XML parser then the only real option is to try a different parser (though do check that you are extracting all the information that's available - I don't know Python's ETree, but some parsers hide the diagnostics in obscure places).\nBut there are some limitations. If a start tag is missing, then no parser is going to be able to tell you where it should have been; it can only tell you where the unmatched end tag is. So asking it to tell you \"where the mistake was first made\" is asking too much.","Q_Score":0,"Tags":"python,xml,parsing,syntax","A_Id":52174016,"CreationDate":"2018-09-04T16:38:00.000","Title":"Python XML syntax checking - Enforce NO '>' in the text of an element","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For the last 2 days PyCharm won't create the configuration setting to run my Python files and I have to create them manually to run my codes. \nBefore that PyCharm created those configuration setting for me, and all I had to do was just press Shift+F10.\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":52171264,"Users Score":0,"Answer":"If you're using Linux or Mac, I've seen a similar (not the same) issue where the app (in this case PyCharm) was installed with root user via sudo and then the executed as normal user, that then won't have permissions to create\/change the configuration files, which in PyCharm's case is the .idea folder in your project folder.\nIf this was previously working, maybe an update to PyCharm while you were running as root may cause the same issue (folder root becomes the owner of the folder and normal user can't change it).","Q_Score":0,"Tags":"python,pycharm","A_Id":52171946,"CreationDate":"2018-09-04T17:23:00.000","Title":"PyCharm won't create configuration to run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The problem originates when I start by cloning a git project that uses pipenv, so it has a Pipfile + Pipfile.lock. I want to use a virtual environment with the project so I run pipenv shell. I now have a virtual environment created and I am inside the virtual environment. The project obviously has a lot of dependencies (listed in the Pipfile). I don't want to have to go through the list in the Pipfile one by one and install them using pipenv install <package_name>. Is there a pipenv\/pip command that installs all the packages from a Pipfile I already have? Or maybe I need to set up the environment differently than running pipenv shell?","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":75815,"Q_Id":52171593,"Users Score":3,"Answer":"use  pipenv sync to install all packages specified in Pipfile.lock.","Q_Score":51,"Tags":"python,pip,virtualenv,pipenv","A_Id":64510892,"CreationDate":"2018-09-04T17:49:00.000","Title":"How to install dependencies from a copied pipfile inside a virtual environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The problem originates when I start by cloning a git project that uses pipenv, so it has a Pipfile + Pipfile.lock. I want to use a virtual environment with the project so I run pipenv shell. I now have a virtual environment created and I am inside the virtual environment. The project obviously has a lot of dependencies (listed in the Pipfile). I don't want to have to go through the list in the Pipfile one by one and install them using pipenv install <package_name>. Is there a pipenv\/pip command that installs all the packages from a Pipfile I already have? Or maybe I need to set up the environment differently than running pipenv shell?","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":75815,"Q_Id":52171593,"Users Score":83,"Answer":"The proper answer to this question is that pipenv install or pipenv install --dev (if there are dev dependencies) should be ran.  That will install all the dependencies in the Pipefile.  Putting the dependencies into a requirements.txt and then using pip will work but is not really necessary.  The whole point of using pipenv for most people is to avoid the need to manage a requirements.txt or to use pip.\nEDIT: if the virtualenv is already activated, you can also use pipenv sync or pipenv sync --dev for the same effect.","Q_Score":51,"Tags":"python,pip,virtualenv,pipenv","A_Id":52172848,"CreationDate":"2018-09-04T17:49:00.000","Title":"How to install dependencies from a copied pipfile inside a virtual environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've looked at some other answers but none seem to be quite what I'm looking for.\nI've got a python bot I've written that I turned in to a docker container that's launched via\ndocker run -dit --restart unless-stopped -v \/home\/dockeradmin\/pythonApp\/:\/pythonApp--name python-bot-app  python-bot\nMy question though is that how to update my docker container when I change the code for my python project. Right now I usually will just rebuild the image, stop\/prune the container, and then start it again, however this seems to be extremely wasteful.\nIs there a simple or \"right\" way to do this?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":10231,"Q_Id":52172970,"Users Score":3,"Answer":"Rebuilding your image when your code changes is the canonical approach, and is not wasteful at all if done right.\nYour pythonApp code should be COPY'd into your image as the final step (rule of thumb: most frequently changed step in dockerfile should go last). This means rebuilding will be very fast as all other steps will be cached. If you only have a few kB of source code changes it will only result in a single new layer of a few kB. Stopping and starting containers is also very light weight.\nThere is nothing to worry about in following this approach.","Q_Score":9,"Tags":"python,docker","A_Id":52243157,"CreationDate":"2018-09-04T19:38:00.000","Title":"Updating a Docker container with new code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a pandas series with boolean entries.  I would like to get a list of indices where the values are True.\nFor example the input pd.Series([True, False, True, True, False, False, False, True])\nshould yield the output [0,2,3,7].\nI can do it with a list comprehension, but is there something cleaner or faster?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":70848,"Q_Id":52173161,"Users Score":1,"Answer":"Also works:\ns.where(lambda x: x).dropna().index, and\nit has the advantage of being easy to chain pipe - if your series is being computed on the fly, you don't need to assign it to a variable.\nNote that if s is computed from r: s = cond(r)\nthan you can also use: r.where(lambda x: cond(x)).dropna().index.","Q_Score":67,"Tags":"python,pandas,boolean,series,boolean-indexing","A_Id":70050317,"CreationDate":"2018-09-04T19:53:00.000","Title":"Getting a list of indices where pandas boolean series is True","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't import Keras in PyCharm IDE on a Mac. I have tried installing and uninstalling Keras using both pip, pip3, conda, and easy install, but none worked. I have tried changing interpreters (Python 2.7 and 3.6) but neither worked.\nIn a terminal, when I run:\n\npip3 list | grep -i keras\n\nI get:\n\nKeras                              2.2.2\n  Keras-Applications                 1.0.4\n  Keras-Preprocessing                1.0.2 \n\nI think this means that my Keras installation was successful. I have also checked my environment with:\n\npython3 -c 'import sys, pprint; pprint.pprint(sys.path)'\n\nI get:\n\n'\/anaconda3\/lib\/python36.zip',\n   '\/anaconda3\/lib\/python3.6',\n   '\/anaconda3\/lib\/python3.6\/lib-dynload',\n   '\/anaconda3\/lib\/python3.6\/site-packages',\n   '\/anaconda3\/lib\/python3.6\/site-packages\/aeosa']\n\nI have tried running:\n\npython -c \"import keras\"\n\nI get:\n\nUsing TensorFlow backend.\n\nBut when I run\/import Keras on the PyCharm IDE, I get:\n\nModuleNotFoundError: No module named 'keras'\n\nWhat should I do to run Keras on a Mac with PyCharm 3.6?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":14633,"Q_Id":52174530,"Users Score":1,"Answer":"When you start a project in PyCharm, there is an option to use an existing virtual environment or create a new virtual environment. If nothing mentioned while creating the project, new virtual environment will be created. If that is the case, there is no Keras in the new environment which is possibly your issue.\n It will be better to do this installation in some virtual environments and use it accordingly in Pycharm.","Q_Score":4,"Tags":"python,tensorflow,keras","A_Id":60923830,"CreationDate":"2018-09-04T22:00:00.000","Title":"ModuleNotFoundError: No module named 'keras'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"First off I would like to say that I am aware that this question has been asked before, however, none of the other posts have offered a solution that resolves the problem.\nI am trying to use pandas-datareader to grab stock prices from the internet. I am using windows with python version 3.6. I first installed pandas-datareader from the console using \npip install pandas-datareader.\nI then wrote a code which used the line \nimport pandas_datareader.data as web\nIt came back with the error\n`ModuleNotFoundError: No module named 'pandas_datareader'\nI tried to redownload pandas-datareader, just in case it didn't work the first time, but the console came back with \"Requirement already satisfied\" so that wasn't the problem.\nFrom there I uninstalled pandas-datareader, and reinstalled it with\npip3 install pandas-datareader\nI still got the same error message.\nI was worried that it might have something to do with old versions of python installed on my computer so I deleted all files for python 2.7, but this did not help the issue. I restarted spyder and my computer and this did not help. I tried Jupiter notebook and this did not help either.\nNow to take my investigation one step further, I looked in my file folders at the hidden files to see where pandas-datareader could be hiding. When I go to C:\\Users\\J.Shepard\\Anaconda3\\pkgs and C:\\Users\\J.Shepard\\Anaconda3\\pkgs I see that pandas-0.23.0-py36h830ac7b_0 is installed but I cannot find anything that looks like pandas-datareader. In fact, when I search for \"pandas-datareader\" in my file search, I only see 2 text files with one line of code each. I do not know what to make of this discovery but I thought it might be helpful to someone else.\nI hope that I have made a good case to prove that I have genuinely tried and failed to solve this problem on my own. Based on the number of other unresolved posts related to this same question, I believe that this is a question that deserves to be asked again.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2865,"Q_Id":52175718,"Users Score":1,"Answer":"I tried conda install pandas-datareader in Anaconda Prompt. It was installed and after my computer restarted, pandas-datareader worked in spyder 3.6.","Q_Score":1,"Tags":"python,pandas,module,spyder,datareader","A_Id":71438963,"CreationDate":"2018-09-05T01:01:00.000","Title":"Spyder cannot find module named 'pandas_datareader'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"On Windows 10, I'm trying to make a window stay always on bottom; that is, it is always shown behind other windows and can't be brought on top of them. I've seen around that the easiest solution is to make the window a child of the desktop; however, I've had mixed success in doing this. The undesirable side effects of making a window child of the desktop are not a problem in this case. I've tried making my window child of SysListView32, SHELLDLL_DefView and Progman.\nIn the first two cases, the window does correctly stay behind, though for some reason it is partially transparent and the desktop background can be seen behind it (but not whatever files\/folders may be on the desktop). In the last case the window can't be seen at all. Is there some way to take care of the transparency issue, or am I not making my window child of the right window? If it matters, I'm using Python 3.7 with Pygame (which is based on SDL) to create my window.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":313,"Q_Id":52175822,"Users Score":0,"Answer":"Instead of finding another solution, I've managed to fix the transparency issue by enabling the extended window style WS_EX_LAYERED on my window using SetWindowLong.","Q_Score":0,"Tags":"python,winapi","A_Id":52208210,"CreationDate":"2018-09-05T01:20:00.000","Title":"Making a window always stay behind","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to model two processes:\n(1) A simple real-time message broadcaster (deterministic) and\n(2) Another process which receives data externally in real-time (from a Redis db) and then compares its own message to the value of the last message broadcast by (1)\nI have been playing around with Simpy and thought this could be done by creating two parallel environment instances and getting one to peer into the state of the other. Is this possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":324,"Q_Id":52176053,"Users Score":0,"Answer":"If both process exchange data, they must run within the same environment.  Since SimPy processes run asynchronously, this is no problem.","Q_Score":1,"Tags":"python,redis,simpy","A_Id":52179073,"CreationDate":"2018-09-05T01:57:00.000","Title":"Can I run two Simpy environments in parallel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to speed up the home page of a website that queries the database for a random URL to use as the background image.  One thing I have tried is to add a function to the Python code that caches the result of that database query for 60 minutes, and when I run the server locally I see that it seems to work correctly: reloading the page shows the same image as the previous time, instead of a new random image.\nHowever when I deployed this code to a Digital Ocean droplet running an Apache server, it didn't seem to work: reloading the page would show a different image.  I suspect that what is happening is that different workers are handling my request each time, and each of these workers has its own cached result from the database.\nIs there any way to cache these database queries across workers or achieve some similar result? Note: the obvious solution of hard-coding the background image is not an option, as the person for whom I am working wants the background image to vary.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":52176392,"Users Score":0,"Answer":"Apache has shared memory between workers, but I'm not aware of anyway for python (say uwsgi) to access it. Same with nginx.\nAlternative would be to use an algorithm to determine what to display rather then being truly random. For example, all queries with hour == 1 -> picture_1, hour == 2 -> picture_2, etc.","Q_Score":0,"Tags":"python,apache,web.py","A_Id":52237262,"CreationDate":"2018-09-05T02:54:00.000","Title":"Can a Python server cache db queries across Apache workers?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to speed up the home page of a website that queries the database for a random URL to use as the background image.  One thing I have tried is to add a function to the Python code that caches the result of that database query for 60 minutes, and when I run the server locally I see that it seems to work correctly: reloading the page shows the same image as the previous time, instead of a new random image.\nHowever when I deployed this code to a Digital Ocean droplet running an Apache server, it didn't seem to work: reloading the page would show a different image.  I suspect that what is happening is that different workers are handling my request each time, and each of these workers has its own cached result from the database.\nIs there any way to cache these database queries across workers or achieve some similar result? Note: the obvious solution of hard-coding the background image is not an option, as the person for whom I am working wants the background image to vary.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":52176392,"Users Score":0,"Answer":"After doing some more reading it seems the standard solution to this problem is to use a db query caching system like Memcached or Redis.","Q_Score":0,"Tags":"python,apache,web.py","A_Id":52240149,"CreationDate":"2018-09-05T02:54:00.000","Title":"Can a Python server cache db queries across Apache workers?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In TensorFlow's Dataset API, we can use dataset.prefetch(buffer_size=xxx) to preload other batches' data while GPU is processing the current batch's data, therefore, I can make full use of GPU.\nI'm going to use Keras, and wonder if keras has a similar API for me to make full use of GPU, instead of serial execution: read batch 0->process batch 0->read batch 1-> process batch 1-> ...\nI briefly looked through the keras API and did not see a description of the prefetch.","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2301,"Q_Id":52176792,"Users Score":6,"Answer":"If you call fit_generator with workers > 1, use_multiprocessing=True, it will prefetch queue_size batches.\nFrom docs: max_queue_size: Integer. Maximum size for the generator queue. If unspecified, max_queue_size will default to 10.","Q_Score":13,"Tags":"python,tensorflow,keras,dataset","A_Id":56251858,"CreationDate":"2018-09-05T03:51:00.000","Title":"Could Keras prefetch data like tensorflow Dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to programming and my first task, which should be really simple, is to automate a proccess, where I log in in a website with my credentials, I click on some buttons and that is it. I am using Python 3.6 on windows 10.\nI am trying to do it using the webbot module, which so far has come really handy but I have one big problem.\nThe standard browser for webbot is Google Chrome and thus the site always opens with Chrome. I need to open the site with Internet Explorer.\nI have set IE as default browser, but nothing changed, Chrome would still open.\nI deleted Chrome, but then when I would run the programm nothing would happen.\nI checked the init.py file and the drivers folder of the module and I think that this module can only work with chrome.\nIs it possible to use IE or does this mean that this package does not support this browser at all?\nWhich alternatives would you suggest?\nEdit: If I am not mistaken Selenium does not support IE11 on windows 10, so that is not an option, unless I am mistaken.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1106,"Q_Id":52178568,"Users Score":0,"Answer":"There is no support for another browser other than Chrome (as far as the webbot module is concerned).","Q_Score":0,"Tags":"python-3.x,web-scraping","A_Id":53250134,"CreationDate":"2018-09-05T06:36:00.000","Title":"Python - Using a browser other than Chrome with webbot package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"From tensorflow documentation about tf.contrib.rnn.RNNCell: \"This definition of cell differs from the definition used in the literature. In the literature, 'cell' refers to an object with a single scalar output. This definition refers to a horizontal array of such units.\"\nIt seems, that rnn cell only accepts vectors as inputs. However I would like to feed images\/videos to an rnn (e.g. [batch size, steps, height, width, channels]). Is there a way to do this using rnn cell and dynamic rnn, or do I have to manually construct an rnn?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":155,"Q_Id":52180502,"Users Score":0,"Answer":"As you have said RNN only accept as input a Tensor like [batch_size, sequence_lentgh, features].\nIn order to use RNN from tensorflow you will have to extract the features with a CNN for each frame and convert your CNN output data to a tensor that follows [batch_size, sequence_lentgh, features] shape in order to feed it to the RNN.","Q_Score":1,"Tags":"python,tensorflow,deep-learning,computer-vision,rnn","A_Id":52183726,"CreationDate":"2018-09-05T08:25:00.000","Title":"Multi-dimensional tensors as input to rnn in tensorflow (tf.contrib.rnn.RNNCell)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to write a RE to match all lowercase characters and words (special characters and symbols should not match), so like [a-z]+ EXCEPT the two words true and false.\nI'm going to use it with Python.\nI've written (?!true|false\\b)\\b[a-z]+, it works but it does not recognise lowercase characters following an uppercase one (e.g.  with \"This\" it doesn't match \"his\"). I don't know how to include also this kind of match.\nFor instance:\n\ntrue & G(asymbol) & false should match only asymbol\ntrue & G(asymbol) & anothersymbol should match only [asymbol, anothersymbol]\nasymbolUbsymbol | false should match only [asymbol, bsymbol]\n\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":621,"Q_Id":52182897,"Users Score":0,"Answer":"I would create two regexes (you want to mix word boundary matching with optionally splitting words apart, which is, AFAIK not straighforward mixable, you would have to re-phrase your regex either without word boundaries or without splitting):\n\nfirst regex: [a-z]+\nsecond regex: \\b(?!true|false)[a-z]+","Q_Score":3,"Tags":"regex,python-3.x","A_Id":52183159,"CreationDate":"2018-09-05T10:27:00.000","Title":"Regex to match all lowercase character except some words","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I create a virtualenv for a Python project, it get's \"polluted\" by packages that I install for my convenience (like iPython or other packages that my editor \"VS Code\" depends on, like \"pylint\").\nBut these packages are not relevant for my project. So if I do pip freeze > requirements.txt, I see that only a few packages are relevant for my project.\nWhat is the best way to clean up? \n\nInstall those packages in a global context so that I can use them in every project I begin? or\nDo a pip freeze > requirements.txt, then edit the requirements file and remove not needed packages?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":413,"Q_Id":52184407,"Users Score":4,"Answer":"What we do here:\nFirst we have the project's requirement file - the one used for deployments. This is not built using pip freeze but manually edited so it only contains relevant packages. \nThen we have the \"dev\" requirement file with packages that are only useful for development but are required to work on the project  (linters, additionnal testing stuff etc). \nAnd finally each is free to maintain his own personal additional requirements (editor-related packages etc).\nNote that using virtualenvwrapper (which really helps for development installs) you define hooks that will install packages when you create a new virtual env.","Q_Score":2,"Tags":"python","A_Id":52184684,"CreationDate":"2018-09-05T11:47:00.000","Title":"Python: Packages that are not relevant for project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just have a small doubt, I am building a small application in python which will use firebase database and storage, I am reading too much about firebase admin sdk, What is the basic difference between normal firebase services and firebase admin sdk or is it one and the same, also if i am starting development now is using firebase admin sdk recommended...?\nAlso i will integrate the database and storage to my android application.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2026,"Q_Id":52190544,"Users Score":3,"Answer":"If you're writing code with python and you want to access Firebase and Cloud serivces, the recommended option is to use the admin SDK.  It's designed to be the easiest way to read and write data in your database, upload and download files to your Cloud Storage buckets, and perform other administrative functions, such as authenticated user management.\nI'm not sure what you mean by \"normal Firebase services\".","Q_Score":4,"Tags":"python,python-3.x,firebase,firebase-realtime-database,google-cloud-firestore","A_Id":52190585,"CreationDate":"2018-09-05T17:26:00.000","Title":"Difference between normal firebase and firebase admin sdk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Just have a small doubt, I am building a small application in python which will use firebase database and storage, I am reading too much about firebase admin sdk, What is the basic difference between normal firebase services and firebase admin sdk or is it one and the same, also if i am starting development now is using firebase admin sdk recommended...?\nAlso i will integrate the database and storage to my android application.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2026,"Q_Id":52190544,"Users Score":1,"Answer":"Python Firebase admin SDK: If you use Firebase Admin SDK then you can have admin access to things without worrying about restrictions and rules on your database.\nPython Firebase: If you use python firebase (normal firebase) then you need to authenticate each time you access your data (Means you can set rules and permissions for your document)","Q_Score":4,"Tags":"python,python-3.x,firebase,firebase-realtime-database,google-cloud-firestore","A_Id":60914916,"CreationDate":"2018-09-05T17:26:00.000","Title":"Difference between normal firebase and firebase admin sdk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We are going to handle Big Data (~50 million records) in our organization. We are partitioning data on the basis of date and other some parameters, but data is not equally partitioned. Can we do repartition on it for good performance?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":52191056,"Users Score":0,"Answer":"Usually, partitioning is a good idea and as @Karthik already said, often the date is not the best idea. In my experience it always made sense to partition your data based on the amount of workers you have. So ideally your partition size is a multiple of your workers. We normally use 120 partitions, as we have 24 workers in our spark environment and end up with code like:\nnew_df = spark.read.csv(\"some_csv.csv\", header=\"true\", escape=\"\\\"\", quote=\"\\\"\").repartition(100)\nWe also experienced way better performance in working with parquet instead of csv, which is a tradeoff, as the data has to be read, repartitioned and stored again, but it paid off in the analysis steps. So maybe you should also consider this conversion.","Q_Score":0,"Tags":"python,database,dataframe,pyspark,hadoop2","A_Id":52200967,"CreationDate":"2018-09-05T18:03:00.000","Title":"Is it good idea to repartition 50 million records data in dataframe? If yes then someone please tell me the appropriate way of doing this","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are going to handle Big Data (~50 million records) in our organization. We are partitioning data on the basis of date and other some parameters, but data is not equally partitioned. Can we do repartition on it for good performance?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":52191056,"Users Score":0,"Answer":"Depending on your machine try maintaining a fixed number of partitions. It is always a good idea to partition but in most cases, it's not a good idea to partition based on date(Not sure because I don't know the nature of your data).","Q_Score":0,"Tags":"python,database,dataframe,pyspark,hadoop2","A_Id":52194219,"CreationDate":"2018-09-05T18:03:00.000","Title":"Is it good idea to repartition 50 million records data in dataframe? If yes then someone please tell me the appropriate way of doing this","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suddenly today, I can no longer type letters or numbers into the editor in PyCharm 2018.2.2 Build #PY-182.4129.34. I can still type symbols such as [] and {} but letters and numbers appear when typed and then immediately are deleted. \nI've checked that Vim emulation is off, the plugin is not even installed as far as I can tell. I've updated my Material Theme plugin. None of my settings have been changed since I last used PyCharm. \nIt's independent of what file I'm editing. I've also disabled my international keyboard. Read-only is turned off as well. \nI'm out of ideas.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3785,"Q_Id":52194338,"Users Score":5,"Answer":"When all else fails:\nfile -> invalidate caches\/restart","Q_Score":2,"Tags":"python,pycharm,jetbrains-ide","A_Id":52195067,"CreationDate":"2018-09-05T22:50:00.000","Title":"Cannot type letters or numbers in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suddenly today, I can no longer type letters or numbers into the editor in PyCharm 2018.2.2 Build #PY-182.4129.34. I can still type symbols such as [] and {} but letters and numbers appear when typed and then immediately are deleted. \nI've checked that Vim emulation is off, the plugin is not even installed as far as I can tell. I've updated my Material Theme plugin. None of my settings have been changed since I last used PyCharm. \nIt's independent of what file I'm editing. I've also disabled my international keyboard. Read-only is turned off as well. \nI'm out of ideas.","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":3785,"Q_Id":52194338,"Users Score":4,"Answer":"Try to deactivate Vim by  'Tools -> Vim Emulator' (Untick the option)","Q_Score":2,"Tags":"python,pycharm,jetbrains-ide","A_Id":54731997,"CreationDate":"2018-09-05T22:50:00.000","Title":"Cannot type letters or numbers in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For example, ArrayLists in Java have a resizing factor of 2. When the array that the ArrayList is wrapped around runs out of space, all the elements of that array are transferred to a new array that is 2 times the size of the original array.\nSince Python lists\/arrays are naturally dynamic, what are their resizing factor? Or do they use some other method of scaling? If so, what's that method? What's its asymptotic runtime (big O)?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3504,"Q_Id":52195579,"Users Score":2,"Answer":"To answer your other question:  adding an item to the end of an ArrayList or similar takes amortized O(1) time as long as there is any factor k > 1 such that reallocation always makes an array that is k times as big as the previous one.\nThe actual factor used doesn't really matter as long as it's bigger than one.  Alternative reallocation schemes might have a different complexity.  If reallocation adds a constant amount, for example, then adding an item takes amortized O(N) time.\nThat's why all professionally written dynamically growing arrays grow by some factor each time.  The factor provides a fixed upper bound on the proportion of wasted space ((k-1)\/k), traded off against a fixed upper bound on the average number of times each item could be copied in a sequence of adds.\nLets say you're using factor k and you've just performed the Nth reallocation.  That means you have added about k^N items. How many items have you copied?  Let the be C.  Then:\nC = k^(N-1) + k(N-2) + ... + 1\nkC - C = k^N + k^(N-1) - k^(N-1) + k^(N-2) - k^(N-2) ... - 1\nkC - C = k^N - 1\nC = (k^N-1) \/ (k-1)\nThe number of copies per item added, then is C\/K^N, which is pretty much 1\/(k-1).\nSo Java's factor of k=2 means there is about one copy per add operation, with up to 50% unused slots, and CPython's factor of k=1.125 means there are about 8 copies per add operation with up to 11% unused slots.","Q_Score":12,"Tags":"python,python-3.x,list,data-structures,asymptotic-complexity","A_Id":52196552,"CreationDate":"2018-09-06T02:15:00.000","Title":"What is the resizing factor of lists in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a replacement for the range command that can be used in for loop to add the numbers between 1 and 20 to a list.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":62,"Q_Id":52195899,"Users Score":1,"Answer":"You can use np.linspace(1, 20, num=20)","Q_Score":0,"Tags":"python-3.x","A_Id":52195941,"CreationDate":"2018-09-06T03:00:00.000","Title":"How would I add numbers between 1 and 20 to a list using a for loop without using range()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a rather odd situation where I will have multiple interfaces connected to the same network. When I receive a broadcast or multicast message, I would like to know what interface it came from. It there a way to do that in C or ideally Python?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":52196479,"Users Score":0,"Answer":"The most obvious one would be to bind several sockets, each to one interface only - do not listen to 0.0.0.0.","Q_Score":2,"Tags":"python,c,sockets,network-programming,udp","A_Id":52196631,"CreationDate":"2018-09-06T04:23:00.000","Title":"How do you know which interface a broadcast message came 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":"So far I have investigated two different ways of persistently tracking player attribute skills in a game. These are mainly conceptual except for the threading option I came up with \/ found an example for.\nThe case:\nSolo developing a web game. Geo political simulator but with a little twist in comparison to others out there which I won't reveal.\nI'm using a combination of Flask and SQLAlchemy for which I have written routes for and have templates extending into a base dynamically. \nCurrently running it in dev mode locally with the intention of putting it behind a WSGI and a reverse proxy like Nginx on the cloud based Linux vm.\nAbout the player attribute mechanics - a player will submit a post request which will specify a few bits of information. First we want to know which skill, intelligence, endurance etc. Next wee need to know which player, but all of this will be generated automatically, we can use Flask-LoginManager to get the current user with our nifty user_loader decorator and function. We can use the user ID it provides to query the rest of it, namely what level the player is. We can specify the math used to decide the wait time increase later in seconds.\nThe options;\nOption 1:\nAs suggested by a colleague of mine. Allow the database to manage the timings of the skills. When the user submits the form, we will have created a new table to hold skill upgrade information. We take a note of what time the user submitted the form and also we multiply the current skill level by a factor of X amount of time and we put both pieces of data into the database. Then we create a new process that manages the constant checking of this table. Using timedelta, we can check if the amount of time that has elapsed since the form was submitted is equal to or greater than the time the player must wait until the upgrade is complete.\nOption 2:\nImport threading and create a class which expects the same information as abovr supplied on init and then simply use time.sleep for X amount of time then fire the upgrade and kill the thread when it's finished.\nI hope this all makes sense. I haven't written either yet because I am undecided about which is the most efficient way around it.\nI'm looking for the most scalable solution (even if it's not an option listed here) but one that is also as practical or an improvement on my concept of the skill tracking mechanic.\nI'm open to adding another lib to the package but I really would rather not.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":52199075,"Users Score":0,"Answer":"I'll expand on my comment a little bit:\nIn terms of scaleability:\n\nWhat if the upgrade processes become very long? Hours or days?\nWhat if you have a lot of users\nWhat if people disconnect and reconnect to sessions at different times?\n\nHopefully it is clear you cannot ensure a robust process with option 2. Threading and waiting will put a continuous and potentially limiting load on a server and if a server fails all those threads likely to be lost.\nIn terms of robustness:\nOn the other hand if you record all of the information to a database you have the facility to cross check the states of any items and perform upgrade\/downgrade actions as deemed necessary by some form of task scheduler. This allows you to ensure that character states are always consistent with what you expect. And you only need one process to scan through the DB periodically and perform actions on all of the open rows flagged for an upgrade.\nYou could, if you wanted, also avoid a global task scheduler altogether. When a user performs an activity on the site a little task could run in the background (as a kind of decorator) that checks the upgrade status and if the time is right performs the DB activity, otherwise just passes. But a user would need to be actively in a session to make sure this happens, as opposed to the scheduled task above.","Q_Score":0,"Tags":"python,python-3.x,sqlite,flask-sqlalchemy,flask-login","A_Id":52216293,"CreationDate":"2018-09-06T07:50:00.000","Title":"Most efficient way of tracking player skill upgrades","Data Science and Machine Learning":0,"Database and SQL":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 all the floating numbers in my PyTorch code double type by default, how can I do that?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5260,"Q_Id":52199728,"Users Score":2,"Answer":"You should use for that torch.set_default_dtype.  \nIt is true that using torch.set_default_tensor_type will also have a similar effect, but torch.set_default_tensor_type not only sets the default data type, but also sets the default values for the device where the tensor is allocated, and the layout of the tensor.","Q_Score":4,"Tags":"python,image-processing,machine-learning,computer-vision,pytorch","A_Id":54257615,"CreationDate":"2018-09-06T08:27:00.000","Title":"How to use double as the default type for floating numbers in PyTorch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a large number of records to a postgres database, using psycopg2.extras.execute_values(cursor, query, data, page_size=100)\nI get what the page_size parameter does, but don't really know what would be a sensible value to set it to. (Above uses the default value of 100.) What are the downsides of simply setting this to something ridiculously large?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2195,"Q_Id":52204311,"Users Score":1,"Answer":"Based on my understanding, the page_size gives the size of input values per sql statement. Give larger number means longer sql statement, and hence more memory usage for the query. If you do not need the query to return any values, it would be safe to use a smaller value such as 100 by default.\nHowever, if you would like to insert\/update certain table with returning statement, you may like to increate page_size to at least the same length as your data. You may set it at length(data) (your data should be a list of lists or a list of tuples), and the downside is that you have to introduce some limit to the number of data values per call. Postgresql allows very long sql, so if you have enough memory, millions of records should be acceptable.","Q_Score":6,"Tags":"python,psycopg2","A_Id":52874618,"CreationDate":"2018-09-06T12:37:00.000","Title":"psycopg2: What page_size to use","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Jenkins to run a Flask app automatically from a Git branch.\nThe build works well, and it starts the Flask app on my server, except that when you run flask run, the command line stays active as long as the flask app runs.\nThus, the build never ends, and it ends up as an unstable build.\nHow can I get the flask app to run and get a Jenkins build success if it got the the * Running on http:\/\/0.0.0.0:5000\/ (Press CTRL+C to quit) message?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":852,"Q_Id":52207146,"Users Score":4,"Answer":"If you're running flask run in a bash script, adding & to the end (flask run &) will run the task in the background, allowing the bash script to continue. I think this will let your job finish and Jenkins can scan stdout for the message indicating success.\nEdit: Apparently overriding the build number export BUILD_ID=<whatever> is enough to stop Jenkins from killing the background process. I'd be wary of what you choose as <whatever>, if you choose an existing BUILD_ID, there could be side-effects.","Q_Score":2,"Tags":"python,jenkins,flask","A_Id":52207227,"CreationDate":"2018-09-06T15:07:00.000","Title":"Execute a flask run in Jenkins shell without timeout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"We encountered a strange issue when altering a table. We use Cassandra python driver sync_table() method to sync from our model (defined in a py file) to Cassandra. The cluster is a 20 node being stressed decently (all nodes in range of 50-70% max usage). \nWhen the schema is synced using the Cassandra python driver, internally it is executing the \"ALTER TABLE  ADD  \" commands. In a particular table, when we added seven new columns, we noticed this strange behavior\n\nDESCRIBE TABLE command shows 3 or 4 out of the new 7 columns created. Once, it showed all 7 columns in the DESCRIBE TABLE output.\n\nBut in the select * output, the new columns are not shown. \n\n\nThe behavior is inconsistent. We dropped the columns manually and then resynced the schema. Every time the issue appears with select command not showing few of the 7 columns.\nAny pointers to debug this issue? Is it due to stress on Cassandra nodes?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":52207766,"Users Score":2,"Answer":"The most probable issue is that you hit the schema agreement problem because of execution of many schema change commands. \nTypically, you need to send the schema change commands only to one host, and get confirmation about schema agreement.  The first thing is usually done by creating a session that uses white-list policy where list consists only of one node (as opposite to token-aware or round robin policies).  The second thing is easy - you either check corresponding flag of the result set returned after execution of the command, or by checking corresponding field\/method of the cluster's metadata.","Q_Score":1,"Tags":"cassandra,cassandra-python-driver","A_Id":52210324,"CreationDate":"2018-09-06T15:40:00.000","Title":"Cassandra schema issue in 2.1.14","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose that we have two tables, table A and table B, and suppose that A and B are both very large: table A consists of 500000 rows and 20 columns and table B consist of 1000000 rows and and 20 columns. Suppose furthermore that there is no unique index available for the rows.\nQuestion: What is the fastest way to check the overlap between the two tables? Should I use some form of hashing? Would it be doable to compare the tables within a couple of minutes and if not; how long would it take? I guess that just comparing each row of A with each row of B would take a lot of computing time?\nThanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":52208787,"Users Score":1,"Answer":"I suspect the fastest solution would be to create an index on one of the tables on some field that is well distributed, i.e. where there would be few cases of two records having the same value in that field. Then you could do a fast search with a join on that field.\nCreating the index and then running the comparison will almost certainly be faster than running a comparison without an index.\nExactly how long it will take will depend on the size of the fields, how fast your server is, etc. But with a decent index, \"a few minutes\" is not an unreasonable expectation.\nIf there's some reason why you don't want an index, then delete it when you're done.","Q_Score":0,"Tags":"python,mysql,database","A_Id":52208990,"CreationDate":"2018-09-06T16:45:00.000","Title":"Comparing large databases","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to launch a Python process from a C++ executable using the CreateProcess Windwos AP I.\nWhen I independently run the Python process, the relative paths for importing the libraries work well\nbut when I run the same Python process from a C++ executable, the relative paths for importing the libraries do not work because they will be taking the path relative to the directory in which the C++ executable is kept and not in the directory where the Python file is.\nSo is there a way to set up the environment of a Python process when launching it through the CreateProcess Windows API","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":52209760,"Users Score":0,"Answer":"This issue has been resolved in the comments by Michael. Reproducing the comment below\nSet the lpCurrentDirectory parameter accordingly. It will be used to resolve relative paths (if a program doesn't set the current working directory explicitly later) \u2013","Q_Score":0,"Tags":"python,windows","A_Id":52241446,"CreationDate":"2018-09-06T17:55:00.000","Title":"How to set up the environment of a Python child process in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I hope this post brings you well.  I have environment issues that I would love to get assistance on.\nI installed geopandas with command: \nconda install -c conda-forge geopandas\nThen typed jupyter-notebook and got a nasty error, here is what it reads:\nTraceback (most recent call last):\n  File \"\/home\/mathlizard\/anaconda3\/lib\/python3.6\/site-packages\/notebook\/services\/sessions\/sessionmanager.py\", line 10, in \n    import sqlite3\n  File \"\/home\/mathlizard\/anaconda3\/lib\/python3.6\/sqlite3\/init.py\", line 23, in \n    from sqlite3.dbapi2 import *\n  File \"\/home\/mathlizard\/anaconda3\/lib\/python3.6\/sqlite3\/dbapi2.py\", line 27, in \n    from _sqlite3 import *\nImportError: libncurses.so.6: cannot open shared object file: No such file or directory\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):\n  File \"\/home\/mathlizard\/anaconda3\/bin\/jupyter-notebook\", line 7, in \n    from notebook.notebookapp import main\n  File \"\/home\/mathlizard\/anaconda3\/lib\/python3.6\/site-packages\/notebook\/notebookapp.py\", line 84, in \n    from .services.sessions.sessionmanager import SessionManager\n  File \"\/home\/mathlizard\/anaconda3\/lib\/python3.6\/site-packages\/notebook\/services\/sessions\/sessionmanager.py\", line 13, in \n    from pysqlite2 import dbapi2 as sqlite3\nModuleNotFoundError: No module named 'pysqlite2'\nMy attempts\n\nwrote the following commands: \n\npip install pysqlite2\npip install libsqlite3-dev\nsudo apt-get install libsqlite3-dev\npip install pysqlite\nconda install pysqlite2\nconda install pysqlite\n\ncreated and edited .condarc file in root directory with following lines of code: \n\nchannels:\n  - conda-forge\n  - defaults\nUPDATES\n\ninstalled pysqlite with conda install -c kbchoi pysqlite and now the error after typing jupyter-notebook is the following: \n\nTraceback (most recent call last):\n  File \"\/home\/mathlizard\/anaconda3\/bin\/jupyter-notebook\", line 7, in \n    from notebook.notebookapp import main\n  File \"\/home\/mathlizard\/anaconda3\/lib\/python2.7\/site-packages\/notebook\/notebookapp.py\", line 85, in \n    from .services.sessions.sessionmanager import SessionManager\n  File \"\/home\/mathlizard\/anaconda3\/lib\/python2.7\/site-packages\/notebook\/services\/sessions\/sessionmanager.py\", line 13, in \n    from pysqlite2 import dbapi2 as sqlite3\n  File \"\/home\/mathlizard\/anaconda3\/lib\/python2.7\/site-packages\/pysqlite2\/dbapi2.py\", line 28, in \n    from pysqlite2._sqlite import *\nImportError: libncurses.so.6: cannot open shared object file: No such file or directory\nBackground info:\n\nwhich python outputs this: \/home\/mathlizard\/anaconda3\/bin\/python\nwhich jupyter outputs this: \/home\/mathlizard\/anaconda3\/bin\/jupyter\nmy .bashrc file contains these lines of code: export PATH=\"\/home\/mathlizard\/anaconda3\/bin:$PATH\"\n\nand export PATH=\"\/home\/mathlizard\/anaconda2\/bin:$PATH\"\n\nconda list generates: \n\nName                    Version                   Build  Channel\n\n_ipyw_jlab_nb_ext_conf    0.1.0            py27h08a7f0c_0\nalabaster                 0.7.10           py27he5a193a_0\nanaconda                  5.2.0                    py27_3\nanaconda-client           1.6.14                   py27_0\nanaconda-navigator        1.8.7                    py27_0\nanaconda-project          0.8.2            py27h236b58a_0\nasn1crypto                0.24.0                   py27_0\nastroid                   1.6.3                    py27_0\nastropy                   2.0.6            py27h3010b51_1\nattrs                     18.1.0                   py27_0\nbabel                     2.5.3                    py27_0\nbackports                 1.0              py27h63c9359_1\nbackports.functools_lru_cache 1.5                      py27_1\nbackports.shutil_get_terminal_size 1.0.0            py27h5bc021e_2\nbackports_abc             0.5              py27h7b3c97b_0\nbeautifulsoup4            4.6.0            py27h3f86ba9_1\nbitarray                  0.8.1            py27h14c3975_1\nbkcharts                  0.2              py27h241ae91_0\nblas                      1.0                         mkl\nblaze                     0.11.3           py27h5f341da_0\nbleach                    2.1.3                    py27_0\nblosc                     1.14.3               hdbcaa40_0\nbokeh                     0.12.16                  py27_0\nboto                      2.48.0           py27h9556ac2_1\nbottleneck                1.2.1            py27h21b16a3_0\nbzip2                     1.0.6                h14c3975_5\nca-certificates           2018.03.07                    0\ncairo                     1.14.12              h7636065_2\ncdecimal                  2.3              py27h14c3975_3\ncertifi                   2018.4.16                py27_0\ncffi                      1.11.5           py27h9745a5d_0\nchardet                   3.0.4            py27hfa10054_1\nclick                     6.7              py27h4225b90_0\ncloudpickle               0.5.3                    py27_0\nclyent                    1.2.2            py27h7276e6c_1\ncolorama                  0.3.9            py27h5cde069_0\nconda                     4.5.11                   py27_0\nconda-build               3.10.5                   py27_0\nconda-env                 2.6.0                h36134e3_1\nconda-verify              2.0.0            py27hf052a9d_0\nconfigparser              3.5.0            py27h5117587_0\ncontextlib2               0.5.5            py27hbf4c468_0\ncryptography              2.2.2            py27h14c3975_0\ncurl                      7.60.0               h84994c4_0\ncycler                    0.10.0           py27hc7354d3_0\ncython                    0.28.2           py27h14c3975_0\ncytoolz                   0.9.0.1          py27h14c3975_0\ndask                      0.17.5                   py27_0\ndask-core                 0.17.5                   py27_0\ndatashape                 0.5.4            py27hf507385_0\ndbus                      1.13.2               h714fa37_1\ndecorator                 4.3.0                    py27_0\ndistributed               1.21.8                   py27_0\ndocutils                  0.14             py27hae222c1_0\nentrypoints               0.2.3            py27h502b47d_2\nenum34                    1.1.6            py27h99a27e9_1\net_xmlfile                1.0.1            py27h75840f5_0\nexpat                     2.2.5                he0dffb1_0\nfastcache                 1.0.2            py27h14c3975_2\nfilelock                  3.0.4                    py27_0\nflask                     1.0.2                    py27_1\nflask-cors                3.0.4                    py27_0\nfontconfig                2.12.6               h49f89f6_0\nfreetype                  2.8                  hab7d2ae_1\nfuncsigs                  1.0.2            py27h83f16ab_0\nfunctools32               3.2.3.2          py27h4ead58f_1\nfutures                   3.2.0            py27h7b459c0_0\nget_terminal_size         1.0.0                haa9412d_0\ngevent                    1.3.0            py27h14c3975_0\nglib                      2.56.1               h000015b_0\nglob2                     0.6              py27hcea9cbd_0\ngmp                       6.1.2                h6c8ec71_1\ngmpy2                     2.0.8            py27h4cf3fa8_2\ngraphite2                 1.3.11               h16798f4_2\ngreenlet                  0.4.13           py27h14c3975_0\ngrin                      1.2.1                    py27_4\ngst-plugins-base          1.14.0               hbbd80ab_1\ngstreamer                 1.14.0               hb453b48_1\nh5py                      2.7.1            py27ha1f6525_2\nharfbuzz                  1.7.6                h5f0a787_1\nhdf5                      1.10.2               hba1933b_1\nheapdict                  1.0.0                    py27_2\nhtml5lib                  1.0.1            py27h5233db4_0\nicu                       58.2                 h9c2bf20_1\nidna                      2.6              py27h5722d68_1\nimageio                   2.3.0                    py27_0\nimagesize                 1.0.0                    py27_0\nintel-openmp              2018.0.0                      8\nipaddress                 1.0.22                   py27_0\nipykernel                 4.8.2                    py27_0\nipython                   5.7.0                    py27_0\nipython_genutils          0.2.0            py27h89fb69b_0\nipywidgets                7.2.1                    py27_0\nisort                     4.3.4                    py27_0\nitsdangerous              0.24             py27hb8295c1_1\njbig                      2.1                  hdba287a_0\njdcal                     1.4                      py27_0\njedi                      0.12.0                   py27_1\njinja2                    2.10             py27h4114e70_0\njpeg                      9b                   h024ee3a_2\njsonschema                2.6.0            py27h7ed5aa4_0\njupyter                   1.0.0                    py27_4\njupyter_client            5.2.3                    py27_0\njupyter_console           5.2.0            py27hc6bee7e_1\njupyter_core              4.4.0            py27h345911c_0\njupyterlab                0.32.1                   py27_0\njupyterlab_launcher       0.10.5                   py27_0\nkiwisolver                1.0.1            py27hc15e7b5_0\nlazy-object-proxy         1.3.1            py27h682c727_0\nlibcurl                   7.60.0               h1ad7b7a_0\nlibedit                   3.1.20170329         h6b74fdf_2\nlibffi                    3.2.1                hd88cf55_4\nlibgcc-ng                 7.2.0                hdf63c60_3\nlibgfortran-ng            7.2.0                hdf63c60_3\nlibpng                    1.6.34               hb9fc6fc_0\nlibsodium                 1.0.16               h1bed415_0\nlibssh2                   1.8.0                h9cfc8f7_4\nlibstdcxx-ng              7.2.0                hdf63c60_3\nlibtiff                   4.0.9                he85c1e1_1\nlibtool                   2.4.6                h544aabb_3\nlibxcb                    1.13                 h1bed415_1\nlibxml2                   2.9.8                h26e45fe_1\nlibxslt                   1.1.32               h1312cb7_0\nllvmlite                  0.23.1           py27hdbcaa40_0\nlocket                    0.2.0            py27h73929a2_1\nlxml                      4.2.1            py27h23eabaa_0\nlzo                       2.10                 h49e0be7_2\nmarkupsafe                1.0              py27h97b2822_1\nmatplotlib                2.2.2            py27h0e671d2_1\nmccabe                    0.6.1            py27h0e7c7be_1\nmistune                   0.8.3            py27h14c3975_1\nmkl                       2018.0.2                      1\nmkl-service               1.1.2            py27hb2d42c5_4\nmkl_fft                   1.0.1            py27h3010b51_0\nmkl_random                1.0.1            py27h629b387_0\nmore-itertools            4.1.0                    py27_0\nmpc                       1.0.3                hec55b23_5\nmpfr                      3.1.5                h11a74b3_2\nmpmath                    1.0.0            py27h9669132_2\nmsgpack-python            0.5.6            py27h6bb024c_0\nmultipledispatch          0.5.0                    py27_0\nnavigator-updater         0.2.1                    py27_0\nnbconvert                 5.3.1            py27he041f76_0\nnbformat                  4.4.0            py27hed7f2b2_0\nncurses                   6.1                  hf484d3e_0\nnetworkx                  2.1                      py27_0\nnltk                      3.3.0                    py27_0\nnose                      1.3.7            py27heec2199_2\nnotebook                  5.5.0                    py27_0\nnumba                     0.38.0           py27h637b7d7_0\nnumexpr                   2.6.5            py27h7bf3b9c_0\nnumpy                     1.14.3           py27hcd700cb_1\nnumpy-base                1.14.3           py27h9be14a7_1\nnumpydoc                  0.8.0                    py27_0\nodo                       0.5.1            py27h9170de3_0\nolefile                   0.45.1                   py27_0\nopenpyxl                  2.5.3                    py27_0\nopenssl                   1.0.2o               h20670df_0\npackaging                 17.1                     py27_0\npandas                    0.23.0           py27h637b7d7_0\npandoc                    1.19.2.1             hea2e7c5_1\npandocfilters             1.4.2            py27h428e1e5_1\npango                     1.41.0               hd475d92_0\nparso                     0.2.0                    py27_0\npartd                     0.3.8            py27h4e55004_0\npatchelf                  0.9                  hf79760b_2\npath.py                   11.0.1                   py27_0\npathlib2                  2.3.2                    py27_0\npatsy                     0.5.0                    py27_0\npcre                      8.42                 h439df22_0\npep8                      1.7.1                    py27_0\npexpect                   4.5.0                    py27_0\npickleshare               0.7.4            py27h09770e1_0\npillow                    5.1.0            py27h3deb7b8_0\npip                       10.0.1                   py27_0\npixman                    0.34.0               hceecf20_3\npkginfo                   1.4.2                    py27_1\npluggy                    0.6.0            py27h1f4f128_0\nply                       3.11                     py27_0\nprompt_toolkit            1.0.15           py27h1b593e1_0\npsutil                    5.4.5            py27h14c3975_0\nptyprocess                0.5.2            py27h4ccb14c_0\npy                        1.5.3                    py27_0\npycairo                   1.15.4           py27h1b9232e_1\npycodestyle               2.4.0                    py27_0\npycosat                   0.6.3            py27ha4109ae_0\npycparser                 2.18             py27hefa08c5_1\npycrypto                  2.6.1            py27h14c3975_8\npycurl                    7.43.0.1         py27hb7f436b_0\npyflakes                  1.6.0            py27h904a57d_0\npygments                  2.2.0            py27h4a8b6f5_0\npylint                    1.8.4                    py27_0\npyodbc                    4.0.23           py27hf484d3e_0\npyopenssl                 18.0.0                   py27_0\npyparsing                 2.2.0            py27hf1513f8_1\npyqt                      5.9.2            py27h751905a_0\npysocks                   1.6.8                    py27_0\npytables                  3.4.3            py27h02b9ad4_2\npytest                    3.5.1                    py27_0\npython                    2.7.15               h1571d57_0\npython-dateutil           2.7.3                    py27_0\npytz                      2018.4                   py27_0\npywavelets                0.5.2            py27hecda097_0\npyyaml                    3.12             py27h2d70dd7_1\npyzmq                     17.0.0           py27h14c3975_1\nqt                        5.9.5                h7e424d6_0\nqtawesome                 0.4.4            py27hd7914c3_0\nqtconsole                 4.3.1            py27hc444b0d_0\nqtpy                      1.4.1                    py27_0\nreadline                  7.0                  ha6073c6_4\nrequests                  2.18.4           py27hc5b0589_1\nrope                      0.10.7           py27hfe459b0_0\nruamel_yaml               0.15.35          py27h14c3975_1\nscandir                   1.7              py27h14c3975_0\nscikit-image              0.13.1           py27h14c3975_1\nscikit-learn              0.19.1           py27h445a80a_0\nscipy                     1.1.0            py27hfc37229_0\nseaborn                   0.8.1            py27h633ea1e_0\nsend2trash                1.5.0                    py27_0\nsetuptools                39.1.0                   py27_0\nsimplegeneric             0.8.1                    py27_2\nsingledispatch            3.4.0.3          py27h9bcb476_0\nsip                       4.19.8           py27hf484d3e_0\nsix                       1.11.0           py27h5f960f1_1\nsnappy                    1.1.7                hbae5bb6_3\nsnowballstemmer           1.2.1            py27h44e2768_0\nsortedcollections         0.6.1                    py27_0\nsortedcontainers          1.5.10                   py27_0\nsphinx                    1.7.4                    py27_0\nsphinxcontrib             1.0              py27h1512b58_1\nsphinxcontrib-websupport  1.0.1            py27hf906f22_1\nspyder                    3.2.8                    py27_0\nsqlalchemy                1.2.7            py27h6b74fdf_0\nsqlite                    3.23.1               he433501_0\nssl_match_hostname        3.5.0.1          py27h4ec10b9_2\nstatsmodels               0.9.0            py27h3010b51_0\nsubprocess32              3.5.0            py27h14c3975_0\nsympy                     1.1.1            py27hc28188a_0\ntblib                     1.3.2            py27h51fe5ba_0\nterminado                 0.8.1                    py27_1\ntestpath                  0.3.1            py27hc38d2c4_0\ntk                        8.6.7                hc745277_3\ntoolz                     0.9.0                    py27_0\ntornado                   5.0.2                    py27_0\ntraitlets                 4.3.2            py27hd6ce930_0\ntyping                    3.6.4                    py27_0\nunicodecsv                0.14.1           py27h5062da9_0\nunixodbc                  2.3.6                h1bed415_0\nurllib3                   1.22             py27ha55213b_0\nwcwidth                   0.1.7            py27h9e3e1ab_0\nwebencodings              0.5.1            py27hff10b21_1\nwerkzeug                  0.14.1                   py27_0\nwheel                     0.31.1                   py27_0\nwidgetsnbextension        3.2.1                    py27_0\nwrapt                     1.10.11          py27h04f6869_0\nxlrd                      1.1.0            py27ha77178f_1\nxlsxwriter                1.0.4                    py27_0\nxlwt                      1.3.0            py27h3d85d97_0\nxz                        5.2.4                h14c3975_4\nyaml                      0.1.7                had09818_2\nzeromq                    4.2.5                h439df22_0\nzict                      0.1.3            py27h12c336c_0\nzlib                      1.2.11               ha838bed_2","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":806,"Q_Id":52210212,"Users Score":0,"Answer":"This steps works for me:\nJupyter Instance\n\n!source activate python3( or other env. , not root )\n!conda config --remove channels defaults\n!conda config --add channels conda-forge\n!conda install \"your library\"\n!conda list \nimport \"your library\"","Q_Score":2,"Tags":"python,python-3.x,anaconda,jupyter-notebook,conda","A_Id":54657500,"CreationDate":"2018-09-06T18:31:00.000","Title":"Jupyter-notebook exploding after command conda install -c conda-forge","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a general question on a specific topic. \nI am using the vectors generated by Word2Vec to feed as features into my Distributed Random Forest model for classifying some records. I have millions of records and am receiving new records on a daily basis. Because of the new records coming in I want the new records to be encoded with the same vector model as the previous records. Meaning that the word \"AT\" will be the same vector now and in the future. \nI know that Word2Vec uses a random seed to generate the vectors for the words in the corpus but I want to turn this off. I need to set the seed such that if I train a model on a section of the data today and then again on the same data in the future, I want it to generate the same model with the exact same vectors for each word.\nThe problem with generating new models and then encoding is that it takes a great deal of time to encode these records and then on top of that my DRF model for classification isn't any good anymore because the vector for the words have changed. So I have to retrain a new DRF.\nNormally this would not be an issue since I could just train one model each and then use that forever;However I know that a good practice is to update your packages on the regular. This is a problem for h2o since once you update there is no backward comparability with model generated on previous version.\nAre there any sources that I could read on how to set the seed on the Word2Vec model for h2o in python? I am using Python version 3 and h2o version 3.18","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":140,"Q_Id":52210521,"Users Score":1,"Answer":"word2vec in h2o-3 uses hogwild implementation - the model parameters are updated concurrently from multiple threads and it is not possible to guarantee the reproducibility in this implementation.\nHow big is your text corpus? At the cost of a slowdown of the model training you could get reproducible result with limiting the algo to use just a single thread (h2o start-up parameter -nthread).","Q_Score":0,"Tags":"python,word2vec,h2o","A_Id":52212217,"CreationDate":"2018-09-06T18:54:00.000","Title":"H2O Word2Vec inconsistent vectors","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to use the Qt Designer in PyCharm with all the most recent versions?\nI use Python 3.7.0 and PyQt5 (5.11.2) in PyCharm and have downloaded the PyQt5Designer package (using PyCharm), but there seems to be no usable designer.exe file in the PyQt5 directories, and I cannot find any PyCharm functionality to start the designer either. Also, pyqt5-tools seems to be incompatible with Python 3.7.0, so that folder does not exist either.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":9305,"Q_Id":52211135,"Users Score":2,"Answer":"I tried to use PyQt5 with 3.7, and realized the same issue. I downgraded Python to 3.6, and all was good.. I'd recommend downgrading until a new version of PyQt is released to support 3.7.\nInside of the pyqt5-tools, after installation will have the designer.exe you can use.","Q_Score":5,"Tags":"pycharm,pyqt5,qt-creator,qt-designer,python-3.7","A_Id":52286954,"CreationDate":"2018-09-06T19:42:00.000","Title":"Is it possible to use the Qt Designer in PyCharm with all the most recent versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to use the Qt Designer in PyCharm with all the most recent versions?\nI use Python 3.7.0 and PyQt5 (5.11.2) in PyCharm and have downloaded the PyQt5Designer package (using PyCharm), but there seems to be no usable designer.exe file in the PyQt5 directories, and I cannot find any PyCharm functionality to start the designer either. Also, pyqt5-tools seems to be incompatible with Python 3.7.0, so that folder does not exist either.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":9305,"Q_Id":52211135,"Users Score":0,"Answer":"Probably this is already resolved. However, as there is no update and I found something working fine for me:\nWith Pycharm 2019.2 (64x) and Python 3.7 after installing pyqt5-tools (v5.11.3.1.4) one can find the 'designer.exe' under ...\/site-packages\/pyqt5-tools\/Qt\/bin.\nNote: I think this pyqt5-tools (v5.11.3.1.4) downgrades the PyQt5 to v5.12.1 if any upgraded version is already installed. However, it works fine!\ncheers!","Q_Score":5,"Tags":"pycharm,pyqt5,qt-creator,qt-designer,python-3.7","A_Id":57378514,"CreationDate":"2018-09-06T19:42:00.000","Title":"Is it possible to use the Qt Designer in PyCharm with all the most recent versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have saved my text vectors by using gensim library which consists of some negative numbers. will it effect the training? \nIf not then why am i getting nan loss value first for discriminator and then for both discriminator and generator after certain steps of training?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5113,"Q_Id":52211665,"Users Score":4,"Answer":"There are several reasons for a NaN loss and why models diverge. Most common ones I've seen are:\n\nYour learning rate is too high. If this is the case, the loss increases and then diverges to infinity.\nYou are getting a division by zero error. If this is the case, you can add a small number like 1e-8 to your output probability.\nYou have bad inputs. If this is the case, make sure that you do not feed your model with NaNs. i.e. use assert not np.any(np.isnan(x)) on the input data.\nYour labels are not in the same domain of your objective function. If this is the case, check the range of your labels and make sure they match.\n\nIf none of the above helps, try to check the activation function, the optimizer, the loss function, the size and the shape of the network.\nFinally, though less likely, there might be a bug with the framework you are using. Check the repo of the framework if there are others having the same issue.","Q_Score":0,"Tags":"python,tensorflow,generative-adversarial-network","A_Id":52211776,"CreationDate":"2018-09-06T20:24:00.000","Title":"why do i get nan loss value in training discriminator and generator of GAN?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I created directory under the python env, it has single quote like (D:\\'Test Directory'). How do I change to this directory in Jupyter notebook?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":52211800,"Users Score":0,"Answer":"I could able to change the directory using escape sequence like this.. os.chdir('C:\\\\'Test Directory\\')","Q_Score":0,"Tags":"python-3.x","A_Id":52211897,"CreationDate":"2018-09-06T20:34:00.000","Title":"how to change directory in Jupyter Notebook with Special characters?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Trying to create a batch script for windows that runs a program with python3 if available else python2.\nI know the script can be executed with $py -2 script.py\nand py3 with $py -3 script.py.\nand if I run py -0, it returns all the python versions.\nHow do I build this script?\nI do not want to check if the python directory is available or not, I'd prefer to check in a way that is python location agnostic.","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3638,"Q_Id":52211917,"Users Score":7,"Answer":"Not a full solution, but a method to detect which version of Python is installed:\nYou can check if Python 3 is installed by running py -3 --version and then checking the %ERRORLEVEL% variable in the batch script.  If it is 0, then py -3 --version was successful, i.e. Python 3 is installed on the system.  If it is nonzero, then Python 3 is not installed.","Q_Score":3,"Tags":"python,batch-file","A_Id":52211993,"CreationDate":"2018-09-06T20:44:00.000","Title":"Batch Script to Execute script with python 3 if available else python 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I use PyCharm, normally I install 3rd party libraries with the Project Interpreter in PyCharm. Today I installed plotly by running pip install plotly==2.7 in the terminal. But when I tried to import it, I got an unresolved reference 'plotly' warning in the editor. How can I solve it?\nI got this error when I run the code ModuleNotFoundError: No module named 'plotly'","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":117,"Q_Id":52220670,"Users Score":2,"Answer":"I figured out where the problem is.\npip installs packages under python2.7\/site-packages\npip3 installs packages under python3.6\/site-packages\nSo I should use pip3 install plotly==2.7 since I'm using Python3.6","Q_Score":2,"Tags":"python,python-3.x,pip,pycharm","A_Id":52223275,"CreationDate":"2018-09-07T10:33:00.000","Title":"Can't find the modules that have been installed by pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to read an Excel file containing the Swedish characters \u00e5\u00e4\u00f6. \nI am importing the Excel file with pd.read_excel(path, sheetname, encoding='utf8')\nWorks fine to import it and I can see the \u00e5\u00e4\u00f6 characters, but when I work with the data for example creating a new variable df['East'] = df['\u00d6st'] + 50 I receive an error message \nAscii codec can't decode byte 0xc3 in position 33: ordinal not in range \nAnyone that can help me solve this issue?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":865,"Q_Id":52220676,"Users Score":0,"Answer":"Double Check if Excel is saved as UTF-8\nIn Excel 2016 When saving as: click More Options > Tools > Web Options > Encoding > Save this document as ... (pick UTF-8 from the list)\nSaving Excel as csv or even txt helps in many cases too.\nIf csv or txt exported from Excel also doesn't open\/work properly\nopen it in notepad and save it again selecting proper UTF-8 encoding","Q_Score":0,"Tags":"python-2.7,pandas","A_Id":52221695,"CreationDate":"2018-09-07T10:33:00.000","Title":"Python Pandas reading UTF-8 characters","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have a server application based on Python 3.6 running on Google Kubernetes Engine. I added Google StackDriver Debug to aid in debugging some production issues but I cannot get our app to show up in the Stackdriver debug console. The 'application to debug' dropdown menu stays empty.\nThe kubernetes cluster is provisioned with the cloud-debug scope and the app starts up correctly. Also, the Stackdriver Debugging API is enabled on our project. When running the app locally on my machine, cloud debugging works as expected, but I cannot find a reason why it won't work on our production environment","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":207,"Q_Id":52222605,"Users Score":1,"Answer":"In my case the problem was not with the scopes of the platform, but rather with the fact that you cannot simply pip install google-python-cloud-debugger on the official python-alpine docker images. Alpine Linux support is not tested regularly and my problem was related to missing symbols in the C-library. \nAlpine Linux uses the MUSL C-library and it needs a google cloud debugger specifically built for that library. After preparing a specific docker image for this, I got it to work with the provided credentials.","Q_Score":1,"Tags":"python-3.x,google-kubernetes-engine,stackdriver,google-cloud-stackdriver","A_Id":52337909,"CreationDate":"2018-09-07T12:29:00.000","Title":"Google stackdriver debug not working in Kubernetes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"When I try to translate a project written in python to C++. I have to implement the function SimilarityTransform in the package scikit-image. I find estimateRigidTransform in OpenCV will do the same thing. But estimateRigidTransform will return empty matrix somtimes. So, Is there some method that which will works better than that and alway return a matrix?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":748,"Q_Id":52222864,"Users Score":0,"Answer":"I found a function in eigen3, can do the same thing as the python code does.","Q_Score":0,"Tags":"python,c++,image,opencv","A_Id":52454922,"CreationDate":"2018-09-07T12:44:00.000","Title":"How to use C++ to implement SimilarityTransform in scikit-image without using estimateRigidTransform in OpenCV?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Three dataframes. All of them have a common column and I need to merge them based on the common column without missing any data\nInput\n\n>>>df1\n0 Col1  Col2  Col3\n1 data1  3      4\n2 data2  4      3\n3 data3  2      3\n4 data4  2      4\n5 data5  1      4\n\n>>>df2\n0 Col1  Col4  Col5\n1 data1  7      4\n2 data2  6      9\n3 data3  1      4\n\n>>>df3\n0 Col1  Col6  Col7\n1 data2  5      8\n2 data3  2      7\n3 data5  5      3\n\n\nExpected Output\n\n>>>df\n0 Col1  Col2  Col3  Col4 Col5  Col6  Col7\n1 data1  3      4    7    4\n2 data2  4      3    6    9     5     8\n3 data3  2      3    1    4     2     7\n4 data4  2      4\n5 data5  1      4               5     3","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":29412,"Q_Id":52223045,"Users Score":4,"Answer":"You can do\ndf1.merge(df2, how='left', left_on='Col1', right_on='Col1').merge(df3, how='left', left_on='Col1', right_on='Col1')","Q_Score":21,"Tags":"python,pandas,dataframe,merge,concat","A_Id":52223093,"CreationDate":"2018-09-07T12:55:00.000","Title":"Merge multiple dataframes based on a common column","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem in my project in django (Django 1.8 - I know it is old) with photo uploading. The point is that this is too slow.\n\nWhat could be the reason?\nHow can I debug, measure how long it takes? This should be checked on the nginx side?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":52223438,"Users Score":0,"Answer":"Body size (image size) could be huge and if you upload it without compression, it could take more time to send all data to handler.\nCreate decorator around handler that takes media uploads.","Q_Score":0,"Tags":"python,django,file-upload,upload,image-uploading","A_Id":52223461,"CreationDate":"2018-09-07T13:19:00.000","Title":"Debug, measure time image upload in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm new to AWS. I created a test environments with AWS Cloud9, and a django project. When I start djangos dev server, is it possible to access it, from Cloud9 IDE preview or from the internet?\nthanx for your help in advance,\nstrophi","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":528,"Q_Id":52223496,"Users Score":0,"Answer":"You could use something like python manage.py runserver 0.0.0.0:8080 and then access from anywhere using the public IP, something like XXX.XXX.XXX.XXX:8080\n*Make sure the port is not blocked","Q_Score":0,"Tags":"python,django,amazon-web-services","A_Id":52226239,"CreationDate":"2018-09-07T13:23:00.000","Title":"How to access python django dev server started in AWS Cloud9","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to run a test in Django but in order to run the test I need access to data from the production database (I don't want to setup an entirely new database for testing).\nHow can use this data from the production database without allowing write access in my script? I don't want this test to effect anything, but I need access to this data in order to run this test. It seems ridiculous to have to launch (and pay for) an entirely new database just to grab a few rows of data, any advice?","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":2785,"Q_Id":52230750,"Users Score":-1,"Answer":"Don't do that. You must use the setUp of your test to construct your situation to test. Don't use fixtures also because you have to maintain them, in future you'll change your model and your fixtures must be updated too. This is very annoying.\nIf you do a good unit test you can mock your models and test the functions you want to test. I do that often when I want to test a method.\nIf you need you can create some utility function to help you setup the situation you need to create the models and related models to construct the env you want to test.","Q_Score":5,"Tags":"python,django,python-3.x,unit-testing","A_Id":52233824,"CreationDate":"2018-09-07T23:37:00.000","Title":"How do I run a test in Django using production data (Read only)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to run a test in Django but in order to run the test I need access to data from the production database (I don't want to setup an entirely new database for testing).\nHow can use this data from the production database without allowing write access in my script? I don't want this test to effect anything, but I need access to this data in order to run this test. It seems ridiculous to have to launch (and pay for) an entirely new database just to grab a few rows of data, any advice?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2785,"Q_Id":52230750,"Users Score":1,"Answer":"I agree with others that this is a bad idea for various reason. If you want to move forward with it anyway, set up a separate database user with read-only permissions. How you do this depends on the database server you are using.\nDouble check that you are actually using the credentials of the read-only user in your tests.","Q_Score":5,"Tags":"python,django,python-3.x,unit-testing","A_Id":52234788,"CreationDate":"2018-09-07T23:37:00.000","Title":"How do I run a test in Django using production data (Read only)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there anyway to assert the presence of a detection box in an image and obtain the classification score of said hypothetical box? \nI am working with a tensorflow object detection graph and want to refine it's accuracy with a little trickery; by making the claim that there are more (N) objects in a given image than it is detecting, asserting there are image objects in multiple areas in the image, and evaluating each hypothetical image object based on it's classification score between 0 and 1.\nIn other words:\nI want to say \"Hey, TensorFlow, I think there is an image object with rectangular coordinates (x1, y1), (x2, y2) in this image. What would the classification score of a hypothetical detection box defined by that rectangle be?\" Is this possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":52231108,"Users Score":0,"Answer":"With tensorflow you cannot do that. What you are saying is almost like a region proposal and rest of the pipeline on which different platforms like tensorflow, yolo are built to arrive at object detection. You are proposing to a built a different platform by asking what you are asking.","Q_Score":0,"Tags":"python,tensorflow,deep-learning","A_Id":52245736,"CreationDate":"2018-09-08T00:53:00.000","Title":"Get classification score of hypothetical detection box","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python is a scripting language. It is hard to protect python code from being copied. No 100% protection is required but at least slow down those who have bad intentions. Is it possible to minify\/uglify python code the way javascript front-end code is being done today?\nEDIT: The python code will be used in Raspberry Pi, not server. On raspberry pi, anyone can take out the SDcard and gain access to the python code.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":12334,"Q_Id":52231326,"Users Score":0,"Answer":"Nuitka.net is a perfect way to convert your python code to compiled object code. This makes reverse engineering and exposing your algorithms extremely hard. Nuitka can also produce an standalone executable that is very portable.\nWhile this may be a way to preserve trade secrets, it comes with some hard limitations.\na) some python libs are already binary distros which are difficult to bundle in a standalone exe (e.g. xgboost, pytorch).\nb) wide pip distribution of a binary package is an exercise in deep frustration because it is linked to the cpython lib. manylinux and universal builds are vast wasteland waiting to be mapped and documented.\nAs for the downvotes, please consider that 1) not all python runs on servers - some run on the edge, 2) non-open source authors need to protect their intellectual property, 3) smaller always makes for faster installs.","Q_Score":9,"Tags":"python,minify","A_Id":70440091,"CreationDate":"2018-09-08T01:53:00.000","Title":"Is it possible to minify python code like javascript?","Data Science and Machine Learning":0,"Database and SQL":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":"Python is a scripting language. It is hard to protect python code from being copied. No 100% protection is required but at least slow down those who have bad intentions. Is it possible to minify\/uglify python code the way javascript front-end code is being done today?\nEDIT: The python code will be used in Raspberry Pi, not server. On raspberry pi, anyone can take out the SDcard and gain access to the python code.","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":12334,"Q_Id":52231326,"Users Score":2,"Answer":"python is executed server-side.  while sometimes it's fun to intentionally obfuscate code (look into perl obfuscation ;), it should never be necessary for server-side code.\nif you're trying to hide your python from someone but they already have access to the directories and files it is stored in, you have bigger problems than code obfuscation.","Q_Score":9,"Tags":"python,minify","A_Id":52231350,"CreationDate":"2018-09-08T01:53:00.000","Title":"Is it possible to minify python code like javascript?","Data Science and Machine Learning":0,"Database and SQL":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":"Python is a scripting language. It is hard to protect python code from being copied. No 100% protection is required but at least slow down those who have bad intentions. Is it possible to minify\/uglify python code the way javascript front-end code is being done today?\nEDIT: The python code will be used in Raspberry Pi, not server. On raspberry pi, anyone can take out the SDcard and gain access to the python code.","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":12334,"Q_Id":52231326,"Users Score":3,"Answer":"Sure, you could uglify it, but given the fact that python relies on indentation for syntax, you couldn't do the equivalent minification (which in JS relies largely upon removing all whitespace).\nBeside the point, but JS is minified to make it download faster, not obfuscate it.","Q_Score":9,"Tags":"python,minify","A_Id":52231349,"CreationDate":"2018-09-08T01:53:00.000","Title":"Is it possible to minify python code like javascript?","Data Science and Machine Learning":0,"Database and SQL":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":"Let\u2019s say you have a set\/list\/collection of numbers: [1,3,7,13,21,19] (the order does not matter). Let\u2019s say for reasons that are not important, you run them through a function and receive the following pairs:\n(1, 13), (1, 19), (1, 21), (3,19), (7, 3), (7,13), (7,19), (21, 13), (21,19). Again order does not matter. My question involves the next part: how do I find out the minimum amount of numbers that can be part of a pair without being repeated? For this particular sequence it is all six. For [1,4,2] the pairs are (1,4), (1,2), (2,4). In this case any one of the numbers could be excluded as they are all in pairs, but they each repeat, therefore it would be 2 (which 2 do not matter). \nAt first glance this seems like a graph traversal problem - the numbers are nodes, the pairs edges. Is there some part of mathematics that deals with this? I have no problem writing up a traversal algorithm, I was just wondering if there was a solution with a lower time complexity. Thanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":52231442,"Users Score":0,"Answer":"If you really intended to find the minimum amount, the answer is 0, because you don't have to use any number at all.\nI guess you meant to write \"maximal amount of numbers\". \nIf I understand your problem correctly, it sounds like we can translated it to the following problem:\nGiven a set of n numbers (1,..,n), what is the maximal amount of numbers I can use to divide the set into pairs, where each number can appear only once. \nThe answer to this question is:\n\nwhen n = 2k    f(n) = 2k for k>=0\nwhen n = 2k+1  f(n) = 2k for k>=0\n\nI'll explain, using induction.\n\nif n = 0 then we can use at most 0 numbers to create pairs.\nif n = 2 (the set can be [1,2]) then we can use both numbers to\ncreate one pair (1,2)\nAssumption: if n=2k lets assume we can use all 2k numbers to create 2k pairs and prove using induction that we can use 2k+2 numbers for n = 2k+2.\nProof: if n = 2k+2, [1,2,..,k,..,2k,2k+1,2k+2], we can create k pairs using 2k numbers (from our assomption). without loss of generality, lets assume out pairs are (1,2),(3,4),..,(2k-1,2k). we can see that we still have two numbers [2k+1, 2k+2] that we didn't use, and therefor we can create a pair out of two of them, which means that we used 2k+2 numbers.\n\nYou can prove on your own the case when n is odd.","Q_Score":0,"Tags":"python,algorithm,set,graph-algorithm,graph-traversal","A_Id":52236009,"CreationDate":"2018-09-08T02:24:00.000","Title":"Graph traversal, maybe another type of mathematics?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let\u2019s say you have a set\/list\/collection of numbers: [1,3,7,13,21,19] (the order does not matter). Let\u2019s say for reasons that are not important, you run them through a function and receive the following pairs:\n(1, 13), (1, 19), (1, 21), (3,19), (7, 3), (7,13), (7,19), (21, 13), (21,19). Again order does not matter. My question involves the next part: how do I find out the minimum amount of numbers that can be part of a pair without being repeated? For this particular sequence it is all six. For [1,4,2] the pairs are (1,4), (1,2), (2,4). In this case any one of the numbers could be excluded as they are all in pairs, but they each repeat, therefore it would be 2 (which 2 do not matter). \nAt first glance this seems like a graph traversal problem - the numbers are nodes, the pairs edges. Is there some part of mathematics that deals with this? I have no problem writing up a traversal algorithm, I was just wondering if there was a solution with a lower time complexity. Thanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":52231442,"Users Score":0,"Answer":"In case anyone cares in the future, the solution is called a blossom algorithm.","Q_Score":0,"Tags":"python,algorithm,set,graph-algorithm,graph-traversal","A_Id":52249740,"CreationDate":"2018-09-08T02:24:00.000","Title":"Graph traversal, maybe another type of mathematics?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"list_of_input = map(float,[1,2,3])\nprint(list(list_of_input)[0])\nprint(list(list_of_input)[0])\nIndexError: list index out of range\nWhy does this error occur?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":52232973,"Users Score":0,"Answer":"in Python 3 map() returns an iterator not a list. When you pass this iterator to list the first time it consumes the iterator so the second time you get an empty list, hence the IndexError.","Q_Score":1,"Tags":"python,python-3.x,list,dictionary","A_Id":52233034,"CreationDate":"2018-09-08T07:19:00.000","Title":"Python3 get error when constructing a map object by list constructor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have one of the our python script which when executed manually works 100%  fine,but when I try to execute it through PHP it is not getting executed. Does not give any exception or error.\nThere is no problem with script path. Is there any way to identify this ??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":52233671,"Users Score":0,"Answer":"Following are the possibilities,\n\nerror reporting is not enabled\ndue to change in relative paths, your script is not working\n\nAlso can you provide the full exec statement, it will be helpful for us.","Q_Score":0,"Tags":"php,python,laravel","A_Id":52233988,"CreationDate":"2018-09-08T08:59:00.000","Title":"Script executing manually but not executing through 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":0},{"Question":"I used django console email backend in development and It worked fine. Now for test I tried production with gunicorn and nginx, but I have no email backend for now so I used django console email backend again for sending emails, where can I see emails? is there any log to check them? or In production console backend wouldn't work?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":52234988,"Users Score":0,"Answer":"The logs will be visible in the gunicorn logs, you need to configure the logfile in gunicon configuration.","Q_Score":0,"Tags":"python,django,gunicorn","A_Id":52236595,"CreationDate":"2018-09-08T11:45:00.000","Title":"Django console email backend in production with gunicorn and nginx","Data Science and Machine Learning":0,"Database and SQL":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 don't understand how to install modules to Jupyter Notebook. I tried importing different frameworks but nothing can be imported even though I have everything installed in my system. I'm using pip. \nOr maybe there's a way to point Jupyter to a certain virtualenv?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":19137,"Q_Id":52235013,"Users Score":1,"Answer":"I just met the same situation tonight, but the answers above did not solve my confusion.\nWhat confused me is, I have everything right installed already. When I check in the Termianl, I can do \"import pandas\" perfectly.\nBut when in Jupyter, it only gets ModuleNotFoundError.\nThen I opened the terminal provided by Jupyter, I realized that I had two versions of python installed, python 3.7 and 3.8. When in system's terminal, python3 command will go to python 3.8. But the Jupyter is installed under python 3.7. Therefore if you want to work all right under Jupyter, you have to install everything (again) under python 3.7. You can do it either in terminal or in Jupyter. Open any notepage, and install using pip commands just like they said (check the other answers).\nOR, you can simply remove the unnecessary verion of python, which is what I did. I removed the python 3.7. and reinstalled jupyter under python 3.8.\nNow everything works.\nSo if you met the same ModuleNotFoundError but the moudle actually was installed, you may check the version of python carefully.\nHope my experience helps.","Q_Score":4,"Tags":"python,jupyter-notebook","A_Id":65189725,"CreationDate":"2018-09-08T11:47:00.000","Title":"ModuleNotFoundError: No module named 'pandas' (jupyter notebook)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Getting error in missingno module import in Jupyter Notebook . It works fine in IDLE . But showing \"No missingno module exist\" in Jupyter Notebook . Can anybody tell me how to resolve this ?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":13775,"Q_Id":52235421,"Users Score":2,"Answer":"This command helped me:\nconda install -c conda-forge\/label\/gcc7 missingno\n You have to make sure that you run Anaconda prompt as Administrator.","Q_Score":4,"Tags":"python-3.x,jupyter-notebook,missing-data","A_Id":59066388,"CreationDate":"2018-09-08T12:37:00.000","Title":"error in missingno module import in Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Getting error in missingno module import in Jupyter Notebook . It works fine in IDLE . But showing \"No missingno module exist\" in Jupyter Notebook . Can anybody tell me how to resolve this ?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":13775,"Q_Id":52235421,"Users Score":3,"Answer":"Installing missingno through anaconda solved the problem for me","Q_Score":4,"Tags":"python-3.x,jupyter-notebook,missing-data","A_Id":52235801,"CreationDate":"2018-09-08T12:37:00.000","Title":"error in missingno module import in Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019ve build a web based data dashboard that shows 4 graphs - each containing a large amount of data points.\nWhen the URL endpoint is visited Flask calls my python script that grabs the data from a sql server and then starts manipulating it and finally outputs the bokeh graphs. \nHowever, as these graphs get larger\/there becomes more graphs on the screen the website takes long to load - since the entire function has to run before something is displayed.\nHow would I go about lazy loading these? I.e. it loads the first (most important graph) and displays it while running the function for the other graphs, showing them as and when they finish running (showing a sort of loading bar where each of the graphs are or something).\nWould love some advice on how to implement this or similar.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":14269,"Q_Id":52238200,"Users Score":3,"Answer":"I had the same problem as you. The problem with any kind of flask render is that all data is processed and passed to the page (i.e. client) simultaneously, often at large time cost. Not only that, but the the server web process is quite heavily loaded.\nThe solution I was forced to implement as the comment suggested was to load the page with blank charts and then upon mounting them access a flask api (via JS ajax) that returns chart json data to the client. This permits lazy loading of charts, as well as allowing the data manipulation to possibly be performed on a worker and not web server.","Q_Score":9,"Tags":"python,flask,bokeh","A_Id":52238332,"CreationDate":"2018-09-08T18:25:00.000","Title":"Lazy loading with python and flask","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Suppose I have numpy array with shape = [y,z,21] where y = image_width, z= image_height. The above array represents image with 21 channels. How should I convert it to size = [ y,z,3 ] ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":355,"Q_Id":52239164,"Users Score":0,"Answer":"You should set a score threshold to map every pixel in the image to one class, and every class has a color (which has RGB channels), so every pixel is a RGB value for its class.","Q_Score":0,"Tags":"python-3.x,numpy","A_Id":52291702,"CreationDate":"2018-09-08T20:30:00.000","Title":"How to change channel dimension of an image?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been trying for a few days now, to be able to import the library tkinter in pycharm. But, I am unable to do so.\n,I tried to import it or to install some packages but still nothing, I reinstalled python and pycharm again nothing. Does anyone know how to fix this?\nI am using pycharm community edition 2018 2.3 and python 3.7 .\nEDIT:So , I uninstalled python 3.7 and I installed python 3.6 x64 ,I tried changing my interpreter to the new path to python and still not working...\nEDIT 2 : I installed pycharm pro(free trial 30 days) and it's actually works and I tried to open my project in pycharm community and it's not working... \nEDIT 3 : I installed python 3.6 x64 and now it's working.\nThanks for the help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1222,"Q_Id":52242756,"Users Score":0,"Answer":"Thanks to vsDeus for asking this question. I had the same problem running Linux Mint Mate 19.1 and nothing got tkinter and some other modules working in Pycharm CE. In Eclipse with Pydev all worked just fine but for some reason I would rather work in Pycharm when coding than Eclipse.\nThe steps outlined here did not work for me but the steps he took handed me the solution. Basically I had to uninstall Pycharm, remove all its configuration files, then reinstall pip3, tkinter and then reinstall Pycharm CE. Finally I reopened previously saved projects and then set the correct interpreter.\nWhen I tried to change the python interpreter before no alternatives appeared. After all these steps the choice became available. Most importantly now tkinter, matplotlib and other modules I wanted to use are available in Pycharm.","Q_Score":1,"Tags":"python,tkinter,pycharm","A_Id":54604896,"CreationDate":"2018-09-09T08:36:00.000","Title":"I can't import tkinter in pycharm community edition","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My OS is Linux server Redhat. I worked with Python 3.6.6 and Anaconda3 which had Python 3.6.5. My problem was started when I deleted Desktop by mistake. After that, I had to install Python again, but I removed Anaconda3 completely. Now my project is built correctly. But when I run it, I get this error:\nValueError: failed to parse CPython sys.version: '3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) \\n[GCC 7.2.0]'\nI have checked all solution in Stackoverflow, but my error have not been removed. \nWould you please help me?\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":859,"Q_Id":52243496,"Users Score":1,"Answer":"Problem solved when I update cx_Freeze.","Q_Score":1,"Tags":"python-3.x,anaconda,redhat","A_Id":52292468,"CreationDate":"2018-09-09T10:17:00.000","Title":"ValueError: failed to parse CPython sys.version: '3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) \\n[GCC 7.2.0]'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently started working with python and installed Pycharm on my workplace machine which does not have internet. I do have another machine connected to the internet where no IDE\/ software can be installed. The standard installation of pycharm had some of the packages already installed. I am in need of packages like tensorflow\/ theano, can someone help me with a method to add these packages to Pycharm on my machine.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":313,"Q_Id":52245894,"Users Score":1,"Answer":"You have to do a transfer. In the lack of an internet connection, it can be tiring, but is not impossible.\nTo make it seamless follow the suggestions given below \n\nFirst prioritize the packages you need to use. So, that you have a clear idea of what you need to transfer.\nBased on the packages, determine the dependencies. Thus, if package A must be installed before installing package B, then package A is the dependency of package B.\nOnce you have the list of all packages and their dependencies, then considering that you are on windows machine and all the packages you need are open-source, go to their repository on Github or elsewhere, and carefully read the instructions for compiling them. \nThen take a storage device and transfer the files to your system through it. Compile the dependencies and packages and be done with it.","Q_Score":0,"Tags":"python,tensorflow,pycharm,anaconda,theano","A_Id":52246329,"CreationDate":"2018-09-09T15:20:00.000","Title":"Adding packages to Pycharm on a windows machine without internet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Selenium to scrape table data from a website. I found that I can easily iterate through the rows to get the information that I need using xcode. Does selenium keep hitting the website every time I search for an object's text by xcode? Or does it download the page first and then search through the objects offline?\nIf the former is true does is there a way to download the html and iterate offline using Selenium?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":52249090,"Users Score":1,"Answer":"Selenium uses a Web Driver, similar to your web browser. Selenium will access\/download the web page once, unless you've wrote the code to reload the page.\nYou can download the web page and access it locally in selenium. For example you could get selenium to access the web page \"C:\\users\\public\\Desktop\\index.html\"","Q_Score":0,"Tags":"python,selenium","A_Id":52249127,"CreationDate":"2018-09-09T22:24:00.000","Title":"What happens when scraping items from a website table using Selenium?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a list of about 100,000 URLs saved in my computer. ( that 100,000 can very quickly multiply into several million.) For every url, i check that webpage and collect all additional urls on that page, but only if each additional link is not already in my large list. The issue here is reloading that huge list into memory iteratively so i can consistently have an accurate list. where the amount of memory used will probably very soon become much too much, and even more importantly, the time it takes inbetween reloading the list gets longer which is severely holding up the progress of the project.\nMy list is saved in several different formats. One format is by having all links contained in one single text file, where i open(filetext).readlines() to turn it straight into a list. Another format i have saved which seems more helpful, is by saving a folder tree with all the links, and turning that into a list by using os.walk(path).\nim really unsure of any other way to do this recurring conditional check more efficiently, without the ridiculous use of memory and loadimg time. i tried using a queue as well, but It was such a benefit to be able to see the text output of these links that queueing became unneccesarily complicated. where else can i even start?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":54,"Q_Id":52253181,"Users Score":1,"Answer":"The main issue is not to load the list in memory. This should be done only once at the beginning, before scrapping the webpages. The issue is to find if an element is already in the list. The in operation will be too long for large list.\nYou should try to look into several thinks; among which sets and pandas. The first one will probably be the optimal solution.\nNow, since you thought of using a folder tree with the urls as folder names, I can think of one way which could be faster. Instead of creating the list with os.walk(path), try to look if the folder is already present. If not, it means you did not have that url yet. This is basically a fake graph database. To do so, you could use the function os.path.isdir(). If you want a true graph DB, you could look into OrientDB for instance.","Q_Score":0,"Tags":"python","A_Id":52253298,"CreationDate":"2018-09-10T07:43:00.000","Title":"Iteratively Re-Checking a Huge list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list of about 100,000 URLs saved in my computer. ( that 100,000 can very quickly multiply into several million.) For every url, i check that webpage and collect all additional urls on that page, but only if each additional link is not already in my large list. The issue here is reloading that huge list into memory iteratively so i can consistently have an accurate list. where the amount of memory used will probably very soon become much too much, and even more importantly, the time it takes inbetween reloading the list gets longer which is severely holding up the progress of the project.\nMy list is saved in several different formats. One format is by having all links contained in one single text file, where i open(filetext).readlines() to turn it straight into a list. Another format i have saved which seems more helpful, is by saving a folder tree with all the links, and turning that into a list by using os.walk(path).\nim really unsure of any other way to do this recurring conditional check more efficiently, without the ridiculous use of memory and loadimg time. i tried using a queue as well, but It was such a benefit to be able to see the text output of these links that queueing became unneccesarily complicated. where else can i even start?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":52253181,"Users Score":0,"Answer":"Have you considered mapping a table of IP addresses to URL? Granted this would only work if you are seeking unique domains vs thousands of pages on the same domain. The advantage is you would be dealing with a 12 integer address. The downside is the need for additional tabulated data structures and additional processes to map the data.","Q_Score":0,"Tags":"python","A_Id":52253636,"CreationDate":"2018-09-10T07:43:00.000","Title":"Iteratively Re-Checking a Huge list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a set of data with 50 features (c1, c2, c3 ...), with over 80k rows.\nEach row contains normalised numerical values (ranging 0-1). It is actually a normalised dummy variable, whereby some rows have only few features, 3-4 (i.e. 0 is assigned if there is no value). Most rows have about 10-20 features.\nI used KMeans to cluster the data, always resulting in a cluster with a large number of members. Upon analysis, I noticed that rows with fewer than 4 features tends to get clustered together, which is not what I want.\nIs there anyway balance out the clusters?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3624,"Q_Id":52253787,"Users Score":5,"Answer":"It is not part of the k-means objective to produce balanced clusters. In fact, solutions with balanced clusters can be arbitrarily bad (just consider a dataset with duplicates). K-means minimizes the sum-of-squares, and putting these objects into one cluster seems to be beneficial.\nWhat you see is the typical effect of using k-means on sparse, non-continuous data. Encoded categoricial variables, binary variables, and sparse data just are not well suited for k-means use of means. Furthermore, you'd probably need to carefully weight variables, too.\nNow a hotfix that will likely improve your results (at least the perceived quality, because I do not think it makes them statistically any better) is to normalize each vector to unit length (Euclidean norm 1). This will emphasize the ones of rows with few nonzero entries. You'll probably like the results more, but they are even much harder to interpret.","Q_Score":3,"Tags":"python,cluster-analysis,k-means,data-science,feature-engineering","A_Id":52258663,"CreationDate":"2018-09-10T08:26:00.000","Title":"KMeans clustering unbalanced data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a DataFrame series with day resolution. I want to transform the series to a series of monthly averages. Ofcourse I can apply rolling mean and select only every  30th of means but it would not precise. I want to get series which contains mean value from the previous month on every first day of a month. For example, on February 1 I want to have daily average for the January. How can I do this in pythonic way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":52254994,"Users Score":0,"Answer":"data.resample('M', how='mean')","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":52255420,"CreationDate":"2018-09-10T09:41:00.000","Title":"How to apply avg function to DataFrame series monthly?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting the polling data by running celery beat scheduler and periodic task. I like to share this data with the Django server. this data should available for the entire Django application server. is there anyway? and I don't want to share this data either DB or file. please suggest me to do this in a better way, thank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":52255926,"Users Score":1,"Answer":"Short answer : what you ask for is not possible, period. \nLonger answer : given that a django production setup will run more than one Django process (yes, even with one single server), there's no such thing as \"THE\" django server and the only way to \"share data\" from celery workers to the django processes is to store them in \"something\" that is 1\/ available to all the workers and all the django processes and 2\/ supports concurrent access - IOW in a database server process of some sort (your SQL db for persistant data, Redis for transiant data).","Q_Score":0,"Tags":"python,django,celery,periodic-task,djcelery","A_Id":52256244,"CreationDate":"2018-09-10T10:35:00.000","Title":"get djcelery periodic task data inside the django app and keep the data in the entire application without store in file and db?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to decode one character (represented as c-dimensional one hot vectors) at a time with tensorflow seq2seq model implementations. I am not using any embedding in my case. \nNow I am stuck with tf.contrib.seq2seq.GreedyEmbeddingHelper. It requires \"embedding: A callable that takes a vector tensor of ids (argmax ids), or the params argument for embedding_lookup. The returned tensor will be passed to the decoder input.\"\nHow I will define callable? What are inputs (vector tensor if ids(argmax ids)) and outputs of this callable function? Please explain using examples.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":267,"Q_Id":52256809,"Users Score":0,"Answer":"embedding = tf.Variable(tf.random_uniform([c-dimensional ,\nEMBEDDING_DIM]))\nhere you can create the embedding for you own model.\nand this will be trained during your training process to give a vector for your own input.\nif you don't want to use it you just can create a matrix where is every column of it is one hot vector represents the character and pass it as embedding.\nit will be some thing like that:\n[[1,0,0],[0,1,0],[0,0,1]]\nhere if you have vocabsize of 3 .","Q_Score":0,"Tags":"python,tensorflow","A_Id":55653445,"CreationDate":"2018-09-10T11:25:00.000","Title":"how to use Tensorflow seq2seq.GreedyEmbeddingHelper first parameter Embedding in case of using normal one hot vector instead of embedding?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want advice on how to do the following:\nOn the same server, I want to have two apps. One WordPress app and one Python app. At the same time, I want the root of my domain to be a static landing page.\nUrl structure I want to achieve:\n\nexample.com\/   => static landing page\nexample.com\/tickets => wordpress\nexample.com\/pythonapp => python app\n\nI have never done something like this before and searching for solutions didn't help.\nIs it even possible? \nIs it better to use subdomains?\nIs it better to use different servers?\nHow should I approach this?\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":112,"Q_Id":52257055,"Users Score":1,"Answer":"It depends on the webserver you want to use. Let's go with apache as it is one of the most used web servers on the internet.\n\nYou install your wordpress installation into the \/tickets subdirectory and install word-press as you normally would. This should install wordpress into the subdirectory.\nConfigure your Python-WSGI App with this configuration:\n\nWSGIScriptAlias \/pythonapp \/var\/www\/path\/to\/my\/wsgi.py","Q_Score":0,"Tags":"python,wordpress,url,routes,url-routing","A_Id":52257207,"CreationDate":"2018-09-10T11:43:00.000","Title":"one server, same domain, different apps (example.com\/ & example.com\/tickets )?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm new to Django. Curious to note that every \"view\" function has a request as the first parameter, but when I look for request object in the documentation, I got HttpRequest instead... \nAre they the same? \nIf so, why bother to give two names for the same object?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":646,"Q_Id":52258156,"Users Score":5,"Answer":"Are they the same?\n  If so, why bother to give two names for the same object?\n\nHttpRequest is a class, the request parameter to views is an instance of this class (well, it's expected to be at least).","Q_Score":2,"Tags":"python,django","A_Id":52258400,"CreationDate":"2018-09-10T12:46:00.000","Title":"Django HttpRequest vs. Request","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm writing a C++ program, which 'll run Python 3 interpreter as a child process, then connect two Linux anonymous pipes - one to it's stdout and stderr and the second to interpreter's stdin ; next communicate with it via these channels.\nI need to run Python in interactive mode, i.e. pass one command to it using input pipe and wait for the answer on the output pipe. Everything 'd be fine, but it seems Python can run interactive mode only if it's stdout and stdin connected to tty's. \nPython docs quotation:\n\nThe interpreter operates somewhat like the Unix shell: when called with standard input connected to a tty device, it reads and executes commands interactively; when called with a file name argument or with a file as standard input, it reads and executes a script from that file.\n\nIndeed when I'm running interpreter with pipes instead of tty, I can't see anything in response pipe, after the command was sent.\nSo - can I workaround such behaviour by some way and make python3 interpreter works exactly the way it was started from terminal by user?\nAgain, the problem in a nutshell: \nI need to integrate Python to my C++ server app, to allow clients execute python commands. \nEmbedding interpreter into server looks like a bad idea, mainly for reasons of safety ( users can damage server or it's data, besides server is running with some privileges I won't wanna grant to users  ).\nAnother possible solution is to use interpreter in CLI way ( command mode). The main problem is - then I need import some modules and pre-execute some code to provide my server environment and some API to users. It 'll be too heavy to do it before calling interpreter with every command ( these actions are  quite complex, including network connection establishing )\nSo, running interpreter in a separate process and server communicating with it using IPC mechanisms seems not so bad idea. \nAnyway, I'll be glad to take a look at your suggestions If you have any.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":788,"Q_Id":52259978,"Users Score":2,"Answer":"You may use python in cli way, each time run the command user has entered, or archive them in a file and run per line entered. By this way, you can use it's output more simply. Hope to be useful.","Q_Score":0,"Tags":"python,linux,pipe,ipc","A_Id":52260420,"CreationDate":"2018-09-10T14:25:00.000","Title":"Python process input\/output using pipes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Using Windows\/Python 3.7 and Pygame 1.9.4 is already installed, except I exited out of the terminal and can't find the version name to finish the installation. \nAccording to the book I'm following, I need to finish by typing in:\n\"python -m pip install --user pygame-[version name].whl\"\nI can't find the version name anywhere online. I remember it started with \"pygame-18.0\"\nEdit: It works now! It was installed the whole time. Still not sure what the book wants me to do with the whl file thing, but if that raises problems, I'll just restart the whole process again. Thank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":333,"Q_Id":52261995,"Users Score":0,"Answer":"try pip3\/pip install pygame\nnow the latest version of pygame is \"pygame-1.9.4\"","Q_Score":0,"Tags":"python,pygame","A_Id":52262178,"CreationDate":"2018-09-10T16:29:00.000","Title":"Pygame 1.9.4. Installation Trouble","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning Python and I have a situation in which I am tempted to have an __init__() function in several of my different classes.  Are there any problems that this could cause?  If it makes any difference one of them is in a Tkinter main loop for the user interface.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":52265615,"Users Score":2,"Answer":"What __init__() does is allowing you to set up the initial values inside your class, either as hard-coded default values or as values you pass the object as parameters. Imagine you having to have a class Employee and 10 Employee objects in your code. In theory you could do without having an init() and set the various fields (e.g., name, wage, and so on) from outside your class... But why would you, if you can have this handy little function that does all of that for you?","Q_Score":0,"Tags":"python,python-3.x,tkinter","A_Id":52265703,"CreationDate":"2018-09-10T21:18:00.000","Title":"Can each class have an __init__() function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it guaranteed that python 2.X's built-in methods dict.items() and dict.iteritems() will always return items in the same order? Or are these methods non-deterministic?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1137,"Q_Id":52268262,"Users Score":0,"Answer":"If you're interested, you are able to use Visual Code and add breakpoints at each point that you're interested and monitor the local variables for differences across code runs... whether through the same program flow or through a separate run. You are also able to add expression watches. This will allow you to confirm for yourself the behavior of dictionary methods including the dict.items() and dict.iteritems()","Q_Score":4,"Tags":"python,dictionary,python-2.x,python-internals,iteritems","A_Id":60011959,"CreationDate":"2018-09-11T03:31:00.000","Title":"Does python's dict.items() always return the same order?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi I tried to use pdfimages to extract ID images from my pdf resume files. However for some files they return also the icon, table lines, border images which are totally irrelevant.\nIs there anyway I can limit it to only extract person photo? I am thinking if we can define a certain size constraints on the output?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":194,"Q_Id":52271908,"Users Score":0,"Answer":"You need a way of differentiating images found in the PDF in order to extract the ones of interest.\nI believe you have the options of considering:\n\nImage characteristics such as Width, Height, Bits Per Component, ColorSpace\nMetadata information about the image (e.g. a XMP tag of interest)\nFacial recognition of the person in the photo or Form recognition of the structure of the ID itself.\nExtracting all of the images and then use some image processing code to analyze the images to identify the ones of interest.\n\nI think 2) may be the most reliable method if the author of the PDF included such information with the photo IDs.  3) may be difficult to implement and get a reliable result from consistently.  1) will only work if that is a reliable means of identifying such photo IDs for your PDF documents.\nThen you could key off of that information using your extraction tool (if it lets you do that). Otherwise you would need to write your own extraction tool using a PDF library.","Q_Score":0,"Tags":"python,image,pdf,extract,pypdf","A_Id":52279819,"CreationDate":"2018-09-11T08:36:00.000","Title":"How to extract only ID photo from CV with pdfimages","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to write binary numpy array containing 0 and 1 to file using opencv (cv2) or Pillow? I was using scipy.misc.imsave and it worked well, but i read it's depreciated so i wanted to switch to other modules, but when trying to write such an array i see only black image. I need to have 0\/1 values, and not 0\/255 for further processing.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":486,"Q_Id":52273313,"Users Score":0,"Answer":"Since you are writing pixels with values (0, 0, 0) or (1, 1, 1) to the image you are seeing an image that is entirely black and almost-black, so it looks black.\nYou can multiply your array by 255 to get an array of { (0, 0, 0), (255, 255, 255) } which would be black and white. When you read the image you can convert back to 0s and 1s.","Q_Score":0,"Tags":"python-3.x,python-imaging-library,cv2","A_Id":52287805,"CreationDate":"2018-09-11T09:54:00.000","Title":"Write binary numpy array of zeros and ones to file using cv2 or Pillow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python lambda which turns out to be a bit long so we decided to split it into modules. and now when i try to import the module in the lambda_handler its seems to be giving following error \nUnable to import module 'defghi': attempted relative import with no known parent package\nabc.py  which has got lambda_handler in it, is trying to import the defghi.py methods as follows\nfrom defghi import some_method_1, some_method_2\ntried this as well\nfrom .defghi import some_method_1, some_method_2\n\nboth the files are in the same directory\nany sort of help would be appreciated, Thanks in adavance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1488,"Q_Id":52275725,"Users Score":0,"Answer":"Finally got that working it was the build scripts which where causing the issue in my project.\nThe build script which created the zip file where expecting only one .py file in the directory which was a problem. So the zip created never had other files which then gave error cannot import.  \nSo to answer the question its perfectly fine to split the big lambdas into modules and keep them a bit readable and import into the main lambda_handler the required modules.","Q_Score":1,"Tags":"aws-lambda,python-3.6","A_Id":52369163,"CreationDate":"2018-09-11T12:15:00.000","Title":"python lambda not able to import user defined 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":"I am currently working on a script that plays music from mid files to an game using keystrokes, it uses 1 thread for each note, so that means one music with 1k notes have 1k threads. \nIt works for some small mid files, but it is obvious that it doesnt on large files... \nIs there are any way to have this year amount of threads without dropping an error? Anyway to increase max threads?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":52275931,"Users Score":0,"Answer":"Does an orchestra have one musician per note?  No.  Neither should your program have one thread per note.\nJust issue the \"play sound\" requests to the operating system and move on.  No need to wait for them to complete.\nThere's no reason to have more than two threads for this: one for reading data and buffering, and one for triggering the sounds.  Many programs would even combine them into a single thread.","Q_Score":0,"Tags":"python-3.x,multithreading,python-multithreading","A_Id":52276435,"CreationDate":"2018-09-11T12:27:00.000","Title":"Using a lot of threads in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script that is called every x minutes to parse a JSON file. \nThe JSON contains data points with an ID. I want to be able to see if I encountered an ID in a previous run of the script so that I can append the information contained in my data point to my old data with the same ID.\nIn order to do this I want to store the data as a key value pair in cache. The key in this case being the ID and the value the rest of the information contained in the JSON. How can I do this in Python?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2099,"Q_Id":52277812,"Users Score":0,"Answer":"I would use a sqlite db, but you could as easily use another json file to keep a running tally of IDs encountered. I don't think you're going to easily keep it in memory and access between python sessions.","Q_Score":0,"Tags":"python,python-2.7","A_Id":52277861,"CreationDate":"2018-09-11T14:05:00.000","Title":"How to store information from JSON files in cache using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I working on a python project where the script will request some URLs to get JSON response and out of that response, I have to fetch some data and write it to a file. This script will run on a daily schedule to create day specific file and will then do a comparison of files generated on two consecutive days to publish the difference of data observed.\nSo I want to know which file format would be best in low memory usage and time effective when a comparison happens? A .csv to .csv comparison or a .json to .json comparison?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":399,"Q_Id":52280487,"Users Score":2,"Answer":"If you can easily put your data into a CSV file, go with CSV. You can compare them row by row, so your memory can be limited to two rows, and the semantics of CSV if much simpler than JSON. But you have to think about the way you identify rows, and how you can select the rows to compare sequentially.\nIf you care about extremely efficient comparisons, or complex comparisons, put your data into an SQLite database (comes bundled with Python) and build proper indexes. This requires understanding of RDBMS basics, though.\nIf your data cannot be laid into a CSV, e.g. because it's an arbitrary tree, then go with JSON. You will have to load entire JSON files to do the comparison, unless you write very sophisticated code.\nAll the memory considerations can be moot, though, if you're using a normal desktop \/ laptop, or a non-micro AWS instance, or even something like an RPi 2\/3, and your files are not many gigabytes, that is, fit well into the available RAM. Loading a few (hundred) megabytes directly into memory and operating on them may be the most efficient solution then.\nIf you only have e.g. 1000 entries in your files, don't bother with efficiency at all, and write a solution you understand best. You can optimize it later if need be.","Q_Score":0,"Tags":"python,json,csv,export-to-csv","A_Id":52281053,"CreationDate":"2018-09-11T16:34:00.000","Title":"Which is the effective file comparisons CSV to CSV or JSON to JSON in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I load a .h5 file into the spyder environment using h5py, I no longer see the hexadecimal data that was in the original file. \nDoes Python convert the hex information to uint8 automatically?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":52283402,"Users Score":0,"Answer":"Python will probably convert those values to int32. \nUse hex() to see those values in hexadecimal form, and use bitwise operations for manipulation.\nYou can also use bin() to see things in binary\n\nhex(2)\n'0x2'","Q_Score":0,"Tags":"python,python-2.7,numpy,hdf5,h5py","A_Id":52284327,"CreationDate":"2018-09-11T20:01:00.000","Title":"H5 Hexadecimal data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know this question has been asked many times but I still can't get it to work. I have added the path variables python37 as well as python37\\scripts. I have reinstalled python ensuring pip was selected to install. I have verified that pip.exe is inside my scripts folder, but still nothing seems to work.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":5421,"Q_Id":52283464,"Users Score":3,"Answer":"try using pip3 (your command) or python(3) -m pip (your command). If neither of those work, you may have to reinstall python.","Q_Score":0,"Tags":"python,pip","A_Id":52283551,"CreationDate":"2018-09-11T20:04:00.000","Title":"No way to fix 'pip' is not recognized as an internal or external command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So there are variants of this question - but none quite hit the nail on the head.\nI want to run spyder and do interactive analysis on a server. I have two servers , neither have spyder. They both have python (linux server) but I dont have sudo rights to install packages I need.\nIn short the use case is: open spyder on local machine. Do something (need help here) to use the servers computation power , and then return results to local machine.\nUpdate:\nI have updated python with my packages on one server. Now to figure out the kernel name and link to spyder.\nLeaving previous version of question up, as that is still useful.\nThe docker process is a little intimidating as does paramiko. What are my options?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":32710,"Q_Id":52283535,"Users Score":1,"Answer":"I did a long search for something like this in my past job, when we wanted to quickly iterate on code which had to run across many workers in a cluster. All the commercial and open source task-queue projects that I found were based on running fixed code with arbitrary inputs, rather than running arbitrary code. \nI'd also be interested to see if there's something out there that I missed. But in my case, I ended up building my own solution (unfortunately not open source). \nMy solution was: \n1) I made a Redis queue where each task consisted of a zip file with a bash setup script (for pip installs, etc), a \"payload\" Python script to run, and a pickle file with input data.\n2) The \"payload\" Python script would read in the pickle file or other files contained in the zip file. It would output a file named output.zip.\n3) The task worker was a Python script (running on the remote machine, listening to the Redis queue) that would would unzip the file, run the bash setup script, then run the Python script. When the script exited, the worker would upload output.zip.\nThere were various optimizations, like the worker wouldn't run the same bash setup script twice in a row (it remembered the SHA1 hash of the most recent setup script). So, anyway, in the worst case you could do that. It was a week or two of work to setup.\nEdit: \nA second (much more manual) option, if you just need to run on one remote machine, is to use sshfs to mount the remote filesystem locally, so you can quickly edit the files in Spyder. Then keep an ssh window open to the remote machine, and run Python from the command line to test-run the scripts on that machine. (That's my standard setup for developing Raspberry Pi programs.)","Q_Score":20,"Tags":"python,docker,server,spyder,fabric","A_Id":52285027,"CreationDate":"2018-09-11T20:09:00.000","Title":"Run Spyder \/Python on remote server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using a Python3 container and when I check the info, it says it has Python 3.5 installed. However, when I try to use the python3 command in the SSH terminal, it doesn't recognize it as a command. Further, when I use the python command, it says it has Python 2.6.6 installed, leading me to believe that it doesn't have Python3, only Python 2.6.6. I am new to Python and Codeanywhere, so I am just be forgetting something, but I can't find anything about it online.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":152,"Q_Id":52283599,"Users Score":0,"Answer":"The Centos 7.2. Linux distributon (64 bit) has python 3.7","Q_Score":0,"Tags":"python,python-3.x,codeanywhere","A_Id":55534613,"CreationDate":"2018-09-11T20:14:00.000","Title":"Codeanywhere Python3 Container doesn't have Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to create a Python 2.7 virtual environment with Anaconda so I can download some packages that are not compatible with Python 3.4. I'm working in Conda version 4.2.13.\nWhen I type the command conda create -n chemistry python=2.7 anaconda the whole thing freezes at the solving package specifications stage.\nDoes anyone know what causes this or how I can go about fixing it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":9541,"Q_Id":52284072,"Users Score":0,"Answer":"Had same issue while I was trying to install some packages. I tried updating python then all seemed working. Try it out\nconda install python","Q_Score":12,"Tags":"python,python-3.x,python-2.7,anaconda,conda","A_Id":60983295,"CreationDate":"2018-09-11T20:54:00.000","Title":"Conda create is stuck at \"solving package specifications\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a Python 2.7 virtual environment with Anaconda so I can download some packages that are not compatible with Python 3.4. I'm working in Conda version 4.2.13.\nWhen I type the command conda create -n chemistry python=2.7 anaconda the whole thing freezes at the solving package specifications stage.\nDoes anyone know what causes this or how I can go about fixing it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":9541,"Q_Id":52284072,"Users Score":0,"Answer":"Today I faced the same snag. It got fixed after updating my Anaconda Navigator.\nUpdating your Anaconda Navigator may fix your issue, too.","Q_Score":12,"Tags":"python,python-3.x,python-2.7,anaconda,conda","A_Id":55323751,"CreationDate":"2018-09-11T20:54:00.000","Title":"Conda create is stuck at \"solving package specifications\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a program with a Tkinter-based GUI, using Python 3.6.5.\nI have a temporary window with some Text widgets (and other things) in it. The whole window gets destroyed when the temporary window closes. However, I'd like to preserve undo\/redo history and any text that is in some particular Text widgets the next time it is opened (and re-built). Reprogramming this another way is certainly possible, but may be an unnecessary and large amount of work, considering how things are set up (although if you have ideas that you feel should work no matter the setup, feel free to let me know). Changing the setup could probably easily introduce bugs.\nTwo different windows with different widgets need to share data between some of the similar widgets (and I want to extend that to include undo-redo history). I believe the different parents is part of why the window is destroyed, but I could be wrong (there may be other reasons).\nAnyway, I was wondering, where is the undo\/redo history of a Text widget stored? If I could just somehow copy that just before the window closes and put it in the newly build widget (of whichever window it gets build on), that would be great.\nI'm adding the tk tag since I looked at the Python source code for tkinter and didn't find anything particularly useful (so maybe those who use TCL or such will know).\nI realize that it may not be possible to access the variable that stores the history, but I figured it was worth asking about, just in case.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":52285402,"Users Score":1,"Answer":"No, you cannot save the undo\/redo history of the text widget, destroy the widget, then re-apply the history to a new widget. \nThe best solution will be to not destroy the widget. Just hide it and then reshow it instead of destroying it and recreating it.","Q_Score":1,"Tags":"python,python-3.x,tkinter,widget,tk","A_Id":52285516,"CreationDate":"2018-09-11T23:25:00.000","Title":"How to copy the undo\/redo history of a Tkinter Text widget into another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know how to save model results to .txt files and saving plots to .png. I also found some post which shows how to save multiple plots on a single pdf file. What I am looking for is generating a single pdf file which can contain both model results\/summary and it's related plots. So at the end I can have something like auto generated model report. Can someone suggest me how I can do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":52286538,"Users Score":0,"Answer":"I\u2019ve had good results with the fpdf module. It should do everything you need it to do and the learning curve isn\u2019t bad. You can install with pip install fpdf.","Q_Score":0,"Tags":"python,plot,model,report","A_Id":52286569,"CreationDate":"2018-09-12T02:15:00.000","Title":"How to saving plots and model results to pdf in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have written a utility library in Python that works with the Qt framework. My code is pure Python and is compatible with both PyQt5 and PySide2. My main module could either be run on its own from the command line with python -m or it could be imported into another project. Is there a clean way to specify that the project needs either PyQt5 or PySide2 in its a wheel distribution?\nHere is what I have found in my research but I am asking in case there is a better way to package the project than these options:\nI could add logic to setup.py in a source distribution of the project to check for PyQt5 and PySide2. However, wheels are recommended way to distribute Python projects, and from what I can tell this kind of install-time logic is not possible with wheels. Alternatively, I could not specify either PySide2 or PyQt5 as dependencies and recommend in the install instructions that one of them be installed together with my project.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":316,"Q_Id":52286940,"Users Score":0,"Answer":"My particular case is somewhat niche (so I am not accepting this as the answer). I realized the package was really doing two things: acting as a library and as a command line tool. I decided to split it into two packages: package and package-cli. package does not explicitly depend on PyQt5 or PySide2 but specifies that one of them must be installed in the documentation. Since package is a library, it is intended to be integrated into another project where it is easy to list package and PyQt5 together in the requirements.txt. For package-cli, I just choose one of PyQt5 or PySide2 to be the explicit dependency. package-cli depends on package and PyQt5 and just adds a console_script to call the main module in package.","Q_Score":2,"Tags":"python,packaging,python-wheel","A_Id":52350571,"CreationDate":"2018-09-12T03:08:00.000","Title":"How to support alternate dependencies in a Python package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a machine learning program for time series data analysis and using NEAT could help the work. I started to learn TensorFlow not long ago but it seems that the computational graphs in TensorFlow are usually fixed. Is there tools in TensorFlow to help build a dynamically evolving neural network? Or something like Pytorch would be a better alternative? Thanks.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2641,"Q_Id":52287254,"Users Score":1,"Answer":"One way to make an evolving tensorflow network would be to use either hyperneat or the es-hyperneat algorithms instead of running the evolution on the individual networks in the species this instead evolves a \"genome\" that is actually cppn that encodes the phenotype neural nets. For the cppn you can use a feed forward tensorflow network with the caveat of having different activation functions that can be used at each node, this lets the cppn evolve to be able to be queried for the structure and weights of the \"phenotype\" neural network for which you can use a generic tensorflow net(or whatever net you so choose)  \nI would look into the neat-python and peas libraries and look at the networks they use and replicate those classes with tensorflow nets.","Q_Score":6,"Tags":"python,tensorflow,pytorch,neat","A_Id":53675625,"CreationDate":"2018-09-12T03:53:00.000","Title":"Can neuroevolution of augmenting topologies (NEAT) neural networks be built in TensorFlow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created an excel sheet with python xlsxwriter. When i resaved it with libreoffice calc the size decreased by more than 60 percent. why is it ? Is there any way i can mimic this in python to reduce my file size?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":222,"Q_Id":52288610,"Users Score":0,"Answer":"As far as I know that also happens with files produced by Excel so it isn\u2019t an issue with XlsxWriter files. You can verify this by saving the file in Excel and then LibreOffice to test the change. \nXlsxWriter files should be the same size (with small percentage differences) as Excel files since the XML part is almost exactly the same. The zip compression may differ though.","Q_Score":1,"Tags":"python,xlsx,xlsxwriter,libreoffice-calc","A_Id":52289221,"CreationDate":"2018-09-12T06:18:00.000","Title":"Excel sheet size reduced on resaving","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created an excel sheet with python xlsxwriter. When i resaved it with libreoffice calc the size decreased by more than 60 percent. why is it ? Is there any way i can mimic this in python to reduce my file size?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":222,"Q_Id":52288610,"Users Score":0,"Answer":"The size sometimes reduces if you have empty cells on the list. Similar behavior is when you move in Excel to cell A1 and then save, the file size decreases. But you generated the file, so this behaviour may not necessarily apply.","Q_Score":1,"Tags":"python,xlsx,xlsxwriter,libreoffice-calc","A_Id":52289339,"CreationDate":"2018-09-12T06:18:00.000","Title":"Excel sheet size reduced on resaving","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Windows 7 with Atom IDE. \nStick with me here, I'm new to using command line and atom.\nflake8 error while running python in atom. \nterminal say file location for flake8 is: \/c\/Users\/Parker\/AppData\/Local\/Programs\/Python\/Python37\/Scripts\/flake8\nHow do I get flake8 in my path for atom? I tried download the virtualenv and then abandoned that when I hit sudo:command not found. Figured there must be an easier way. \nHow do I do this? Been trying different methods for days and have exhausted the search function.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4623,"Q_Id":52289061,"Users Score":0,"Answer":"I had this issue as well, and just doing pip install flake8 in cmd fixed it for me.","Q_Score":1,"Tags":"python,windows,atom-editor,flake8","A_Id":60538830,"CreationDate":"2018-09-12T06:50:00.000","Title":"How to get flake8 in $PATH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to add InPadding to my LabelFrame i'm using AppJar GUI. I try this:\nself.app.setLabelFrameInPadding(self.name(\"_content\"), [20, 20])\nBut i get this error:\n\nappJar:WARNING [Line 12->3063\/configureWidget]: Error configuring _content: unknown option \"-ipadx\"\n\nAny ideas how to fix it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":52289125,"Users Score":0,"Answer":"Because of the way containers are implemented in appJar, padding works slightly differently for labelFrames.\nTry calling: app.setLabelFramePadding('name', [20,20])","Q_Score":0,"Tags":"python-3.x,user-interface","A_Id":52907153,"CreationDate":"2018-09-12T06:55:00.000","Title":"Error configuring: unknown option \"-ipadx\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a django project hosted on an amazon ec2 linux instance.\nFor run my app also when section is close i use gunicorn but i experience some errors and degradation in perfonrmances.\nWhen i run command:\n\npython manage.py runserver\n\nfrom terminal all works great but when section is close app does not work.\nHow can i run command \"python manage.py runserver\" for work forever (until i'll kill it) in background also in case of closed session?\nI know there is uWSGI but i prefer if possible use directly django native command.\nThanks in advance","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1909,"Q_Id":52289325,"Users Score":0,"Answer":"for that, you can use screen just start a new screen and run\npython manage.py runserver","Q_Score":2,"Tags":"python,django,nginx,gunicorn,django-manage.py","A_Id":52289569,"CreationDate":"2018-09-12T07:06:00.000","Title":"Django use 'python manage.py' runserver instead Gunicorn","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Import pymysql is giving error as AttributeError: module 'pymysql.constants.ER' has no attribute 'CONSTRAINT_FAILED'\n\nUsing pymysql in Python 3.5  \nOperating System is Windows 10","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":248,"Q_Id":52289683,"Users Score":0,"Answer":"I usually think about attributes as nouns that belong to an object.An attribute in Python means some property that is associated with a particular type of object. In other words, the attributes of a given object are the data and abilities that each object type inherently possesses. An object in Python is a simply an enclosed collection of these abilities and data, and is said to be of a specific type.\nAttribute errors in Python are generally raised when the Python interpreter cannot find a specified data or method attribute on an object that allows for attribute references, it will raise an \"AttributeError\" exception. When you get an attribute error in Python, it means you tried to access the attribute value of, or assign an attribute value to, a Python object or class instance in which that attribute simply does not exist.","Q_Score":0,"Tags":"python,mysql,python-3.x,python-import,mysql-python","A_Id":52289834,"CreationDate":"2018-09-12T07:27:00.000","Title":"AttributeError: module 'pymysql.constants.ER' has no attribute 'CONSTRAINT_FAILED' in pymysql Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to implement a keyword based personal assistant\nMy issue is my grammar is set up so that after I detect the keyword, I still need to use it in my grammar,but switching to jsfg mode discards that utterance \nTherefore I need to use Decoder.get_raw_data and Decoder.process_raw_data in but in Python there is no implementation for .get_raw_data method present in C\/C++ implementation\nIs there any way I could use it?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":52295615,"Users Score":0,"Answer":"You have to implement Python part in swig unfortunately.","Q_Score":0,"Tags":"python,cmusphinx,pocketsphinx","A_Id":52938578,"CreationDate":"2018-09-12T12:48:00.000","Title":"Pocketsphinx Python get_raw_data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to deploy same flask application as two different instances lets say sandbox instance and testing instance on the same iis server and same machine. having two folders with different configurations (one for testing and one for sandbox) IIS runs whichever is requested first. for example I want to deploy one under www.example.com\/test and the other under www.example.com\/sandbox. if I requested www.example.com\/test first then this app keeps working correctly but whenever I request www.example.com\/sandbox it returns 404 and vice versa! \nquestion bottom line: \n\nhow can I make both apps run under the same domain with such URLs?\nwould using app factory pattern solve this issue?\nwhat blocks both apps from running side by side as I am trying to do?\n\nthanks a lot in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":218,"Q_Id":52295946,"Users Score":0,"Answer":"been stuck for a week before asking this question and the neatest way I found was to assign each app a different app pool and now they are working together side by side happily ever after.","Q_Score":0,"Tags":"flask,iis-7.5,python-3.6","A_Id":52297680,"CreationDate":"2018-09-12T13:04:00.000","Title":"Two flask Apps same domain IIS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For many years, my company has used the win32com module and ADO to connect to databases via ODBC in Python scripts.  I do not like ADO because it is ancient and because COM is inherently slow and because it tends to throw one particular exception for which there is no workaround I've ever found.  We use ODBC because we cannot assume that our customers have any particular database system (although most of them use PostgreSQL).  We have a class that wraps ADO and provides access to most (maybe all) of the functionality in ADO.  I am at a point where I could recommend a complete changeover to pyodbc.  Before I do that, I'm curious:  are there advantages to ADO via win32com?  Does it have more capability than pyodbc?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":909,"Q_Id":52298387,"Users Score":0,"Answer":"are there advantages to ADO via win32com? Does it have more capability than pyodbc?\n\nPractically speaking, and specifically with regard to ODBC, not really. ADODB would have the advantage of being able to use an OLEDB provider for a database that had an OLEDB provider but not an ODBC driver, but that would be a rare occurrence. (The only such database I can recall is \"SQL Server Compact Edition\", which was discontinued long ago.)\nAs mentioned in the comments to the question, pyodbc would have the advantage of avoiding extra layers of middleware when communicating with the database, i.e.,\nyour\u00a0Python\u00a0app\u00a0\u2194 pyodbc\u00a0\u2194 ODBC\u00a0Driver\u00a0Manager\u00a0\u2194 ODBC\u00a0Driver\u00a0\u2194 database\nvs.\nyour\u00a0Python\u00a0app\u00a0\u2194 win32com\u00a0\u2194 ADODB\u00a0\u2194 OLEDB\u00a0provider\u00a0for\u00a0ODBC\u00a0\u2194 ODBC\u00a0Driver\u00a0Manager\u00a0\u2194 ODBC\u00a0Driver\u00a0\u2194 database\nAs also mentioned, win32com\/ADODB is a Windows-only technology, whereas a pyodbc solution could also be deployed on Linux or Mac if the appropriate ODBC drivers were available for those platforms.","Q_Score":0,"Tags":"python,ado,pyodbc","A_Id":52345221,"CreationDate":"2018-09-12T15:09:00.000","Title":"pyodbc vs ADO via COM for Python scripts","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on MacBook Pro 10.12.6. I downloaded the most recent Anaconda 5.2 distribution, with the Python 3.6 version.\nI can launch the Jupyter Notebook from the command line without any problem, but it does not work from the Anaconda Navigator. I have the Jupyter Notebook version 5.6.0 in the Navigator. How can I get it to work?","AnswerCount":9,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":41506,"Q_Id":52300930,"Users Score":0,"Answer":"When I installed Anaconda I faced a similar problem. Jupyter notebook was not launching from Anaconda. I google searched and tried every piece of advice but nothing worked until I figured out that Jupyter notebook runs on localhost and I already have XAMPP. I use xampp as localhost to test my web pages. I uninstalled the xampp completely. Restart the computer, run the Anaconda and launched jupyter notebook. Voila, now it's running.\nNow when I installed Docker, I faced a similar problem. then I did the same. Uninstalled Anaconda in order to run Docker. It'd be my pleasure if it solves anyone's problem.","Q_Score":9,"Tags":"python,macos,anaconda,jupyter-notebook,navigator","A_Id":66932463,"CreationDate":"2018-09-12T17:52:00.000","Title":"Jupyter notebook not launching from Anaconda Navigator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on MacBook Pro 10.12.6. I downloaded the most recent Anaconda 5.2 distribution, with the Python 3.6 version.\nI can launch the Jupyter Notebook from the command line without any problem, but it does not work from the Anaconda Navigator. I have the Jupyter Notebook version 5.6.0 in the Navigator. How can I get it to work?","AnswerCount":9,"Available Count":6,"Score":0.022218565,"is_accepted":false,"ViewCount":41506,"Q_Id":52300930,"Users Score":1,"Answer":"I faced a similar issue running Anaconda on CentOS 7. \nThe root cause was Anaconda was running as root user.\nI created an OS user for installing Anaconda. Since that, I can start the Jupyter Notebook (Yes, I know this is a very basic best practice) :)","Q_Score":9,"Tags":"python,macos,anaconda,jupyter-notebook,navigator","A_Id":59678567,"CreationDate":"2018-09-12T17:52:00.000","Title":"Jupyter notebook not launching from Anaconda Navigator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on MacBook Pro 10.12.6. I downloaded the most recent Anaconda 5.2 distribution, with the Python 3.6 version.\nI can launch the Jupyter Notebook from the command line without any problem, but it does not work from the Anaconda Navigator. I have the Jupyter Notebook version 5.6.0 in the Navigator. How can I get it to work?","AnswerCount":9,"Available Count":6,"Score":0.022218565,"is_accepted":false,"ViewCount":41506,"Q_Id":52300930,"Users Score":1,"Answer":"Launch it from cmd \/ terminal in cmd type jupyter notebook.","Q_Score":9,"Tags":"python,macos,anaconda,jupyter-notebook,navigator","A_Id":69204677,"CreationDate":"2018-09-12T17:52:00.000","Title":"Jupyter notebook not launching from Anaconda Navigator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on MacBook Pro 10.12.6. I downloaded the most recent Anaconda 5.2 distribution, with the Python 3.6 version.\nI can launch the Jupyter Notebook from the command line without any problem, but it does not work from the Anaconda Navigator. I have the Jupyter Notebook version 5.6.0 in the Navigator. How can I get it to work?","AnswerCount":9,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":41506,"Q_Id":52300930,"Users Score":0,"Answer":"You just need to find the right version of anaconda I think. For me it works well when I downloaded a previous version, I was also facing the same issue. I could then launch jupyter from navigator itself.","Q_Score":9,"Tags":"python,macos,anaconda,jupyter-notebook,navigator","A_Id":68183376,"CreationDate":"2018-09-12T17:52:00.000","Title":"Jupyter notebook not launching from Anaconda Navigator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on MacBook Pro 10.12.6. I downloaded the most recent Anaconda 5.2 distribution, with the Python 3.6 version.\nI can launch the Jupyter Notebook from the command line without any problem, but it does not work from the Anaconda Navigator. I have the Jupyter Notebook version 5.6.0 in the Navigator. How can I get it to work?","AnswerCount":9,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":41506,"Q_Id":52300930,"Users Score":0,"Answer":"Few things to try\n\nRun the Navigator in admin mode (Right click the shortcut -> More -> Run\nas Administrator)\nDowngrade Jupyterlab to another version and upgrade\nit again (basically reinstalling)\n\nThe first one solved my issue.","Q_Score":9,"Tags":"python,macos,anaconda,jupyter-notebook,navigator","A_Id":68916589,"CreationDate":"2018-09-12T17:52:00.000","Title":"Jupyter notebook not launching from Anaconda Navigator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on MacBook Pro 10.12.6. I downloaded the most recent Anaconda 5.2 distribution, with the Python 3.6 version.\nI can launch the Jupyter Notebook from the command line without any problem, but it does not work from the Anaconda Navigator. I have the Jupyter Notebook version 5.6.0 in the Navigator. How can I get it to work?","AnswerCount":9,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":41506,"Q_Id":52300930,"Users Score":0,"Answer":"I had a custom path set as the base path for my jupyter notebook start-up folder. While taking some backup I had removed that folder. This was leading to Jupyter notebook and JupyterLab failing on start up.\nIt worked fine after I fixed that path.","Q_Score":9,"Tags":"python,macos,anaconda,jupyter-notebook,navigator","A_Id":67246477,"CreationDate":"2018-09-12T17:52:00.000","Title":"Jupyter notebook not launching from Anaconda Navigator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to know if the sklearn.model_selection learning_curve can use or does use sklearn.preprocessing StandardScaler.  I've looked over the implementation, but my skill level isn't up to par to come to a conclusion on my own.  All tutorials on using learning_curve have you pass the entire data set to the learning_curve and learning_curve will split the data into training and testing sets.\nAll tutorials for any estimators have you split the data into training and test then scale only the training data and transform the test data using the training data scale.  Which completely understand.\nShould I scale the entire data set before passing it to learn_curve.  I do know learning_curve will use either k-folds or some other cross validation method, so does it even matter because it will all get averaged out with cross validation?\nThanks,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":374,"Q_Id":52302047,"Users Score":0,"Answer":"learning_curve does not implement StandardScaler on its own.  You could create a Pipeline as your estimator where the first step is StandardScaler then whatever your estimator you're using as the next step.  This way when you call learning_curve during each cv iteration you are training both the scaler and estimator on the training folds and performance is being validated against the testing fold in each iteration.\nYou would not want to scale the entire dataset before calling learning_curve.  The reason is when you scale the entire set before training your model you are introducing bias because you are using data that will be used for validation to train the model, which can cause over-fitting.","Q_Score":2,"Tags":"python,scikit-learn","A_Id":52302920,"CreationDate":"2018-09-12T19:22:00.000","Title":"sklearn learning_curve and StandardScaler","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am fairly new to deep learning and TensorFlow, and in the set of lectures from the course I am taking they go over two methods of employing TensorFlow: using estimators and using sessions. It seems like the estimators method is much easier to understand and simpler as it is similar to what I have done using the sklearn classifier packages. Is there any particular reason why one would use sessions instead of estimators? Or will it depend on the type of dataset I am dealing with?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":471,"Q_Id":52302352,"Users Score":1,"Answer":"A simple answer would be:\nEstimator hides some TensorFlow concepts, such as Graph and\nSession, from the user. This is best for newbies since it makes new learners be able to get started much easier (this is nothing to do with the type of dataset, just use tf.dataset API to write an input_fn is sufficient to provide input data for an estimator). \nOnce you have played with tensorflow for a while, understanding how Estimator works and maybe start to use low-level APIs is definitely needed to make you an expert.","Q_Score":2,"Tags":"python,tensorflow,deep-learning,tensorflow-estimator","A_Id":52302923,"CreationDate":"2018-09-12T19:44:00.000","Title":"TensorFlow estimators vs manual\/session approach","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running a jupyterhub using sudospawner on CentOS7 server. The purpose of jupyterhub is twofold\n\nEnsure everyone has the exact same conda packages when we run production code\nAllow people to use multiple instances of the same notebook (where we keep all our visualization tools) and not edit each other's local versions.\n\nInitially when I was installing jupyterhub, someone told me that different users would be able to run isolated versions of the same notebook. In other words, if person A were to change a parameter in a master notebook from \"foo\" to \"bar\" this wouldn't cause B's single-user notebook to change, since each person is spawning a separate server. \nHowever, now that it's actually installed, I find out that this is not the case. As long as I have the right permissions, I can change anyone's notebook, and this change is reflected across anyone who has the notebook open. This defeats point #2. I want persons A, B, C to all use the same notebook N without changes being reflected on each person's local machine.\nNow I have thought of a solution where we keep a git repo of the master notebook and run some code to automatically pull the repo into each person's local dir upon logging in. However, is there a simpler way or more accepted way to accomplish the same thing with just jupyterhub configuration commands?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":293,"Q_Id":52303178,"Users Score":0,"Answer":"If you set up jupyterhub on a linux server then file permissions will take care of this. My setup using SudoSpawner and PAM authentication on a personal CENTOS 7 server:\n\nInstall anaconda in \/opt\/ with svc account as owner\nHave service account create \/opt\/notebooks\/{userid} for each userid with permissions 770 (full permission for owner and group, none for other)\nHave jupyternotebooks spawn in \/opt\/notebooks\/{userid} depending on userid\nFor each new notebook, set default permissions as 740 (full permission for owner, read only for group, none for other).\nOnly owner can save write and save his own notebooks. Others can see, edit, and execute code in another person's notebook, but cannot save changes. In theory you could create a notebook in someone else's folder but this would be heavily discouraged (not explicitly forbidden though).","Q_Score":2,"Tags":"python,jupyter-notebook,jupyterhub","A_Id":52375081,"CreationDate":"2018-09-12T20:41:00.000","Title":"How to run isolated jupyterhub notebooks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just recently started using NLTK; I found the tagging feature and I have looked online and found no answers for this. Why should I tag a string? What is the benefit? What does tagging even do?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":52307022,"Users Score":0,"Answer":"basically tagging a \"string\" or a value is an important thing in natural language programming, tagging is specifying what type of object is. E.G you want to analyze a comment on an article whether it is a positive or a negative comment. you'll need a dataset for classification. E.G\nsample dataset\n----------\nstring |     tag\nkill         negative\nbeautiful    positive\nhate         negative\npretty       positive\nthis dataset is the one you're going to feed the Machine for Data classification and tagging is the category of what type of data is.\n hope it helps.","Q_Score":0,"Tags":"python,nltk","A_Id":52308225,"CreationDate":"2018-09-13T05:12:00.000","Title":"WHY should I tag questions with nltk, what is the benefit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I initially started a small python project (Python, Tkinter amd PonyORM) and became larger that is why I decided to divide the code (used to be single file only) to several modules (e.g. main, form1, entity, database). Main acting as the main controller, form1 as an example can contain a tkinter Frame which can be used as an interface where the user can input data, entity contains the db.Enttiy mappings and database for the pony.Database instance along with its connection details. I think problem is that during import, I'm getting this error \"pony.orm.core.ERDiagramError: Cannot define entity 'EmpInfo': database mapping has already been generated\".  Can you point me to any existing code how should be done.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":588,"Q_Id":52308096,"Users Score":0,"Answer":"Probably you import your modules in a wrong order. Any module which contains entity definitions should be imported before db.generate_mapping() call.\nI think you should call db.generate_mapping() right before entering tk.mainloop() when all imports are already done.","Q_Score":2,"Tags":"python,ponyorm","A_Id":52330119,"CreationDate":"2018-09-13T06:51:00.000","Title":"Sharing PonyORM's db session across different python module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Building Tensorflow and other such packages from source and especially against GPU's is a fairly long task and often encounters errors, so once built and installed I really dont want to mess with them. \nI regularly use virtualenvs, but I am always worried about installing certain packages as sometimes their dependencies will overwrite my own packages I have built from source... \nI know I can remove, and then rebuild from my .wheels, but sometimes this is a time consuming task. Is there a way that if I attempt to pip install a package, it first checks against current package versions and doesn't continue before I agree to those changes? \nEven current packages dependencies don't show versions with pip show","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":52310090,"Users Score":0,"Answer":"Is there a way that if I attempt to pip install a package, it first checks against current package versions and doesn't continue before I agree to those changes?\n\nNo. But pip install doesn't touch installed dependencies until you explicitly run pip install -U. So don't use -U\/--upgrade option and upgrade dependencies when pip fails with unmet dependencies.","Q_Score":0,"Tags":"python,pip,package-managers","A_Id":52334042,"CreationDate":"2018-09-13T08:55:00.000","Title":"Python3 - How do I stop current versions of packages being over-ridden by other packages dependencies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using the Python extension of Visual Studio Code, I can select some code, right-click it, and select \"Run Selection\/Line in Python Terminal\" (alternatively, I can hit Shift+Enter). However, this sends the selected code to a plain old Python REPL in the Terminal pane, whereas I'd like to have this code run in IPython instead (not the QtConsole, just the terminal-based IPython).\nIs it possible to set IPython as the default REPL? I tried setting \/usr\/local\/bin\/ipython3 as my default Python environment, but that doesn't work (it still executes the plain Python interpreter). FWIW, I'm on macOS.","AnswerCount":8,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":32630,"Q_Id":52310689,"Users Score":21,"Answer":"Type Ipython inside the terminal window. Then select the line or lines you want to run from the editor window and then click on the Terminal menu at the top of VScode window. One option in the Terminal menu is to \"Run Selected Text\". This will be run in the Ipython terminal window. I don't know how to make this the default but it appears to remain in that state unless Ipython is stopped. Note: You have to run your selections using the Menu item. Right-clicking in the editor window and clicking on \"Run Selection\" will not use the Ipython window. I hope this is clear. If not just drop a comment.","Q_Score":42,"Tags":"python,visual-studio-code,ipython","A_Id":52324509,"CreationDate":"2018-09-13T09:27:00.000","Title":"Use IPython REPL in VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using the Python extension of Visual Studio Code, I can select some code, right-click it, and select \"Run Selection\/Line in Python Terminal\" (alternatively, I can hit Shift+Enter). However, this sends the selected code to a plain old Python REPL in the Terminal pane, whereas I'd like to have this code run in IPython instead (not the QtConsole, just the terminal-based IPython).\nIs it possible to set IPython as the default REPL? I tried setting \/usr\/local\/bin\/ipython3 as my default Python environment, but that doesn't work (it still executes the plain Python interpreter). FWIW, I'm on macOS.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":32630,"Q_Id":52310689,"Users Score":0,"Answer":"If you have a default vanilla installation of the Python extension in VSCode, by default you can highlight python code and do \"SHIFT+ENTER\" to \"Run Selection\/Line in Python Terminal\".\nThat command will use the default python.exe interpreter. However, this is the trick that works for me to use the IPython shell instead.\n\nFirst run a dummy line of python code by highlighting it and doing SHIFT+ENTER. This launches a terminal named \"python\" and starts the python shell to run the code in the REPL.\nNow issue exit() in that python shell to return to the regular terminal prompt.\nRun ipython in that terminal to start the IPython REPL where the plain old Python REPL used to be.\n\nNow subsequent uses of SHIFT+ENTER (single or multiple lines highlighted) will run the code in the IPython shell.\n(Note, if SHIFT+ENTER is sending code to the Python Interactive split window instead of a terminal REPL, make sure your settings.json has \"jupyter.sendSelectionToInteractiveWindow\": false,)\n[EDIT]. Various comments on this thread remark that using the various solutions, code is copied to the IPython terminal, but not run. I realized I also have this experience depending on my active conda environment. If I do conda install -c conda-forge prompt-toolkit in the environment I'm using, I get the expected behavior where SHIFT+ENTER actually runs code. I don't know if that package is the key, one of its dependencies, or just using conda-forge. But it works!","Q_Score":42,"Tags":"python,visual-studio-code,ipython","A_Id":69231258,"CreationDate":"2018-09-13T09:27:00.000","Title":"Use IPython REPL in VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using the Python extension of Visual Studio Code, I can select some code, right-click it, and select \"Run Selection\/Line in Python Terminal\" (alternatively, I can hit Shift+Enter). However, this sends the selected code to a plain old Python REPL in the Terminal pane, whereas I'd like to have this code run in IPython instead (not the QtConsole, just the terminal-based IPython).\nIs it possible to set IPython as the default REPL? I tried setting \/usr\/local\/bin\/ipython3 as my default Python environment, but that doesn't work (it still executes the plain Python interpreter). FWIW, I'm on macOS.","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":32630,"Q_Id":52310689,"Users Score":1,"Answer":"IPython support is provided by \"IPython for VSCode\" plugin.\nJust select the text and invoke 'Send Selected Text (or current line) To IPython' in command palette.\nAlso official Microsoft Python plugin now supports interactive Jupiter windows, with similar functionality.","Q_Score":42,"Tags":"python,visual-studio-code,ipython","A_Id":54875920,"CreationDate":"2018-09-13T09:27:00.000","Title":"Use IPython REPL in VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using the Python extension of Visual Studio Code, I can select some code, right-click it, and select \"Run Selection\/Line in Python Terminal\" (alternatively, I can hit Shift+Enter). However, this sends the selected code to a plain old Python REPL in the Terminal pane, whereas I'd like to have this code run in IPython instead (not the QtConsole, just the terminal-based IPython).\nIs it possible to set IPython as the default REPL? I tried setting \/usr\/local\/bin\/ipython3 as my default Python environment, but that doesn't work (it still executes the plain Python interpreter). FWIW, I'm on macOS.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":32630,"Q_Id":52310689,"Users Score":0,"Answer":"How to create a Jupiter Notebook in VS Code\n\nGo to the command palette (Command + Shift + P)\nSearch for: \"Jupyter: Create New Blank Notebook\", and hit enter","Q_Score":42,"Tags":"python,visual-studio-code,ipython","A_Id":66517352,"CreationDate":"2018-09-13T09:27:00.000","Title":"Use IPython REPL in VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a way to set up a Lambda trigger, where if any files are uploaded into the S3 bucket, the trigger will push\/copy the file(s) to the SFTP server.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1207,"Q_Id":52316168,"Users Score":0,"Answer":"You have to use the following algorithm: \n\nLog in to AWS console,\nLambda service,\nCreate a new lambda function (choose a proper runtime);\n\nThen you have to set a trigger (a left pane). If you want to trigger your lambda by s3 bucket then click on s3. \nThen you have to configure your trigger (choose your bucket and trigger action). \nAfter you complete all of this steps it's a time to write a handler file.\nDo not forget that every single trigger has to be in the same region as lambda.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda","A_Id":52323243,"CreationDate":"2018-09-13T14:42:00.000","Title":"Is there a Lambda trigger that will push\/copy files from S3 bucket to the SFTP 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":0,"Web Development":1},{"Question":"I am installing python on windows10 and trying to install the opencv and numpy extentions in the command window. I get no error installing them and it says it is successfully installed. But when I try to check the installation and import cv2 it does not recognize it and give me the error: no module named cv2.\ncan anybody help me with this problem? Is there something wrong in installation process or do I need to install something else? \nI checked the newest version of each and used the compatible one with my system.\nThanks.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3551,"Q_Id":52316354,"Users Score":1,"Answer":"I removed the Anaconda version on my machine, so I just have python 3.7 installed. I removed the python interpreter(Pycharm) and installed it again and the problem got fixed somehow!","Q_Score":0,"Tags":"python,numpy,opencv","A_Id":52318766,"CreationDate":"2018-09-13T14:52:00.000","Title":"problem installing and importing modules in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am installing python on windows10 and trying to install the opencv and numpy extentions in the command window. I get no error installing them and it says it is successfully installed. But when I try to check the installation and import cv2 it does not recognize it and give me the error: no module named cv2.\ncan anybody help me with this problem? Is there something wrong in installation process or do I need to install something else? \nI checked the newest version of each and used the compatible one with my system.\nThanks.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3551,"Q_Id":52316354,"Users Score":1,"Answer":"Is it possible that you have 2 versions of python on your machine and your native pip is pointing to the other one? (e.g. you pip install opencv which installs opencv for python 2, but you are using python 3). If this is so, then use pip3 install opencv","Q_Score":0,"Tags":"python,numpy,opencv","A_Id":52316565,"CreationDate":"2018-09-13T14:52:00.000","Title":"problem installing and importing modules in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Previously I installed pytorch,PIL,numpy... using pip. After that I installed python3. Thus ipython switched from python2 to python3. I have to use ipython2 to start python2 kernel. These modules still works well in ipython2, but when I run a python script using python, python2, python2.7, they all raise ImportError:\n\nImportError: No module named PIL(numpy,torch...)\n\nWhen run this command: sudo pip install numpy\nreturn: \n\nRequirement already satisfied: numpy in\n  \/usr\/local\/lib\/python3.5\/dist-packages (1.15.1)\n\nwhen running this command: sudo pip2 install numpy\nreturn: Requirement already satisfied (use --upgrade to upgrade): numpy in \/usr\/lib\/python2.7\/dist-packages\nWhen I run: python, import sys, sys.path\nit shows :\n\n['', '\/home\/szy\/miniconda2\/lib\/python27.zip',\n  '\/home\/szy\/miniconda2\/lib\/python2.7',\n  '\/home\/szy\/miniconda2\/lib\/python2.7\/plat-linux2',\n  '\/home\/szy\/miniconda2\/lib\/python2.7\/lib-tk',\n  '\/home\/szy\/miniconda2\/lib\/python2.7\/lib-old',\n  '\/home\/szy\/miniconda2\/lib\/python2.7\/lib-dynload',\n  '\/home\/szy\/.local\/lib\/python2.7\/site-packages',\n  '\/home\/szy\/miniconda2\/lib\/python2.7\/site-packages']\n\nThe location of numpy is not among them.\nand the sys.path in ipython2:\n\n['',  '\/usr\/local\/bin',  '\/usr\/lib\/python2.7', \n  '\/usr\/lib\/python2.7\/plat-x86_64-linux-gnu', \n  '\/usr\/lib\/python2.7\/lib-tk',  '\/usr\/lib\/python2.7\/lib-old', \n  '\/usr\/lib\/python2.7\/lib-dynload', \n  '\/home\/szy\/.local\/lib\/python2.7\/site-packages', \n  '\/usr\/local\/lib\/python2.7\/dist-packages', \n  '\/usr\/lib\/python2.7\/dist-packages', \n  '\/usr\/local\/lib\/python2.7\/dist-packages\/IPython\/extensions', \n  '\/home\/szy\/.ipython']\n\nWhat's wrong?\nPrevious I could run scripts with python and import these modules.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":52323907,"Users Score":0,"Answer":"Make sure the python path that you given in bashrc is correct.\nAlso it will be good to use conda environment to try out the same since there is confusion in python environments. For that you can follow the below steps:\nCreate the environment and activate it using following commands:\nconda create -n test_env python=2.7\nconda activate test_env\nconda install ipykernel\nipython kernel install --name test_env --user\nThen install the required packages in the environment that you created and try to import it within the created environment.","Q_Score":0,"Tags":"python,linux,python-2.7,numpy","A_Id":52332078,"CreationDate":"2018-09-14T01:42:00.000","Title":"Some modules can be imported in python previously but now can only be imported in ipython2","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I run the command\n\njupyter notebook\n\nfrom the bash shell this starts a jupyter notebook server on localhost. Every time I open a new notebook and start executing code, is that a new process on a separate core or a new thread on the same core? Suppose I were to run N different independent notebooks which are CPU heavy, on a machine with M cores\n\nIf they all run from the same core (same process) with different threads then are the rest of the cores are basically idle?\nIf they run from different cores, then does that mean I can only run M total notebooks at the same time? \nOr perhaps its a mix of both: the ipython kernel takes care of launching new threads\/processes that are beyond my manual control. In which case only M total notebooks would be able actually execute concurrently at the interpreter level, but I could open as many notebooks as my memory would allow.","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":4466,"Q_Id":52324192,"Users Score":5,"Answer":"I did an experiment on my laptop which has 2 cores, max 4 threads. I ran between 2-5 identical notebooks which each incremented a number from 1-100 trillion. It took a few minutes for each notebook to finish executing.\nIn windows task manager, each notebook was considered its own process. No more than 4 notebooks could execute simultaneously, with each one consuming between 20-25% of a single CPU. The 5th notebook effectively had to wait until the others were done before it began executing.\nSo to answer my own questions\n\nEach execution of a notebook is a separate thread, capable of running on any of the cores of your computer. Cells in the same notebook cannot execute concurrently (obviously) without using a library like Threading.\nYou can have as many notebooks open as your RAM permits, assuming they don't execute. However, you can only run \n\nMAX_THREADS = THREADS_PER_CORE*NUM_CORES \n\nnotebooks simultaneously. If you try to run more, the additional notebooks will just stall until the other threads finish.\nThis is the correct interpretation","Q_Score":2,"Tags":"python,jupyter-notebook","A_Id":52350182,"CreationDate":"2018-09-14T02:29:00.000","Title":"Does each jupyter notebook use threads or processes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I must use \"q\" (which is a degree measure) from the command line and then convert \"q\" to radians and have it write out the value of sin(5q) + sin(6q). Considering that I believe I have to use sys.argv's for this I have no clue where to even begin","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":153,"Q_Id":52324220,"Users Score":0,"Answer":"you can use following commands\nq=sys.argv[1] #you can give the decimal value too in your command line\nnow q will be string eg. \"1.345\" so you have convert this to float[ using\nfunction q=float(q) .","Q_Score":0,"Tags":"python,python-3.x,command-line-arguments","A_Id":52325190,"CreationDate":"2018-09-14T02:32:00.000","Title":"how do I connect sys.argv into my float value?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created and REST API using Flask-RESTPlus. I am getting response in json and its fine. Now I have a new requirement to specify Response content type as csv or json. \nI checked API doc there is nothing mentioned !!\nIs it possible to get reponse in csv using Flask-RESTPlus ??","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":586,"Q_Id":52325100,"Users Score":2,"Answer":"I was able to get output in csv . It took some time though\n\n@api.representation('text\/csv')\ndef data_csv(data, code, headers):\n    '''Get result in csv '''\n    resp = make_response(convert_data(data), code)\n    resp.headers.extend(headers)\n    return resp","Q_Score":1,"Tags":"python,csv,flask-restplus","A_Id":52396235,"CreationDate":"2018-09-14T04:43:00.000","Title":"Get response from Flask-RESTPlus in csv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How can I make a relationship between two APIs, where an application is in node.js with the mongodb and another in python with mysql, I need to make a relation between them of 1: N between client:sales, in one I have the register client (name, cpf) and the other part is a sale, but for me to carry out the sales I need customer data.\nIn a traditional application this relationship would be through a foreign key, as we are talking about two separate applications how could this relationship be made ??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":52327099,"Users Score":0,"Answer":"You maintain relation via you services. All you have with you is two services, Client Service and sale service. \nClient service ideally should have no information about sales service, it should not know even if the sale service or any other service even exist.\nHowever for you to record sale you need to do it against client, and in that case sales service can keep client id and can pull information from client when needed.\nIt is upto sale service to decide what relation ship is, it can allow for one client to have multiple sales record or one. Service can decide that, This might not exactly be required to be embedded into database by means of FK.\nSales service can keep all the information related to sales alongside an id (Just like you would have in traditional database). Based on database choices you can put constraint against this id if you have to.","Q_Score":0,"Tags":"python,node.js,api,microservices","A_Id":52327376,"CreationDate":"2018-09-14T07:35:00.000","Title":"Relationship between two microservices with different database by means of api rest","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have configured my robot project with Jenkins on the windows machine.Provided commands in execute windows batch commands = robot -d robot_result --variable profile:NR Tests\\Suite\\Module\nIn the module folder, I have all the robot test cases. hence, provided the path of test cases.\nBut when I trigger build in jenkins I get below error \n[ ERROR ] Parsing 'Tests\\Suite\\Module\\' failed: Data source does not exist.\nWhile same test cases are working file in Eclipse and command line with above-mentioned command. I am using python interpreter to execute test cases in windows machine.\nCan someone please provide input?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1321,"Q_Id":52328413,"Users Score":0,"Answer":"This error means that you are doing something like \"robot foo.robot\", but \"foo.robot\" doesn't exist. Either you have a typo in the filename, or you're making assumptions about the cwd that aren't true, or the file literally doesn't exist.","Q_Score":0,"Tags":"python-3.x,jenkins,jenkins-pipeline,robotframework","A_Id":52332295,"CreationDate":"2018-09-14T08:57:00.000","Title":"Got \"failed: Data source does not exist\" when running robot test cases via Jenkins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I've been working on scrapy for 3 months. for extracting selectors I use simple response.css or response.xpath..\nI'm asked to switch to ItemLoaders and use add_xpath add_css etc.\nI know how ItemLoaders work and ho convinient they are but can anyone compare these 2 w.r.t efficiency? which way is efficient and why ??","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":191,"Q_Id":52330140,"Users Score":0,"Answer":"Item loaders do exactly the same thing underneath that you do when you don't use them. So for every loader.add_css\/add_xpath call there will be responce.css\/xpath executed. It won't be any faster and the little amount of additional work they do won't really make things any slower (especially in comparison to xml parsing and network\/io load).","Q_Score":1,"Tags":"python,python-3.x,scrapy,css-selectors","A_Id":52332084,"CreationDate":"2018-09-14T10:30:00.000","Title":"Scrapy: Difference between simple spider and the one with ItemLoader","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"python 3.6 64 bit,Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production,cx_oracle 6.4.1\nAble to connect DB thru sqlplus and sql developer manually.\nwhen trying to connect through python:\ncx_Oracle.DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: \"C:\\Oracle\\product\\11.2.0\\client_1\\bin\\oci.dll is not the correct architecture\" .... \nmanually verified that \n\"C:\\Oracle\\product\\11.2.0\\client_1\\BIN\\\" has the oci.dll\nPlease help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":426,"Q_Id":52330386,"Users Score":0,"Answer":"The DLL at C:\\Oracle\\product\\11.2\\client_1\\bin\\oci.dll is not a 64-bit DLL. You will need to download and extract a 64-bit Oracle Instant Client in order to resolve this issue. Note that the fact that the server is 64-bit is not relevant in this case. The client must be 64-bit!","Q_Score":0,"Tags":"python,cx-oracle","A_Id":52341121,"CreationDate":"2018-09-14T10:45:00.000","Title":"Trying to connect a DB : Win7 Enterprise 64bit- Python cx_Oracle - oci.dll is not found","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"RuntimeError:\n\nCMake must be installed to build the following extensions: dlib\n\n\nFailed building wheel for dlib\n  Running setup.py clean for dlib\nFailed to build dlib","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":35770,"Q_Id":52332268,"Users Score":10,"Answer":"I ran into this issue as well. I am using windows and have a python environment that I am installing the requirements to.\nI ran pip install cmake , and then pip install dlib. I no longer received the error and successfully installed dlib.","Q_Score":0,"Tags":"python,face-recognition","A_Id":52564257,"CreationDate":"2018-09-14T12:41:00.000","Title":"pip install face_recognition giving error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In sqlite python, one has to run commit() to make sure a SQL statement is executed if auto-commit is not enabled. Auto-commit is enabled by doing something like this sqlite3.connect('sqlitedb.db', isolation_level=None) \nIs it a good practice to enable auto-commit all the time? THis is to avoid bugs that can happen when one forgets to run commit().\nWhat are some situations, if any, that auto-commit is better to be disabled?\nI am using sqlite3 and python v3.6","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2295,"Q_Id":52333800,"Users Score":3,"Answer":"Autocommit should be disabled if multiple operations belong together logically to ensure that not only some of them are executed (atomicity).\nAdditionally it should be disabled if multiple operations are done consecutively in a short period of time for performance reasons.\nFor databases with concurrent access from different threads\/processes additional consistency considerations apply but this usage is unlikely for Sqlite.","Q_Score":2,"Tags":"python,python-3.x,sqlite","A_Id":52334104,"CreationDate":"2018-09-14T14:13:00.000","Title":"Is it a good practice to enable auto-commit in sqlite python all the time?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a plot, and I don't want extra whitespaces in my plot; the question is: \nHow can I strip extra whitespaces from a plot?\nI know you can strip extra whitespaces from a plot when you save it; Then you just do this: plt.savefig('file_name.png', bbox_inches='tight')\nBut I can't find any similar arguments you can pass to plt.plot() to have no extra whitespaces. Is it possible to pass an argument to plt.plot()?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":76,"Q_Id":52334185,"Users Score":1,"Answer":"The easiest way imho is to click on the button \"configure subplots\" and adjust the sliders because you see the result immediately. You could although call the tight_layout() function directly on plt bevor  show()","Q_Score":2,"Tags":"python,matplotlib,whitespace","A_Id":52334301,"CreationDate":"2018-09-14T14:37:00.000","Title":"Matplotlib - How to strip extra whitespaces from a plot without needing to save it?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a predictive curve using 12 different datasets of empirical data. Essentially I want to write a function that passes 2 variables (Number of Applications, Days) and generates a predictive curve based on the 12 datasets that i have. The datasets all have 60 days and have Number of Applications from 500 to 100,000.\nI'm not really sure of what the best approach would be, I was thinking maybe taking the average percentage of total applications at each day (ex: at day 1 on average there are 3% of total applications issued, day 10 on average there are 10%, etc)would be a good place to start but i'm not sure if that's the best approach.\nI have python, SQL, and excel at my disposal but I'm not necessarily looking for a specific solution as much as just a general suggestion on approach. Any help would be much appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":52334490,"Users Score":0,"Answer":"It sounds like you want to break it all out into (60*12) rows with 3 columns: one recording the application number, another recording the time, and another recording the location. Then a model could dummy out each location as a predictor, and you could generate 12 simulated predictions, with uncertainty. Then, to get your one overall prediction, average those predictions instead - bootstrap and then pool the predictions if you're fancy. Model time however you want - autoregression, Kalman filter, nearest-neighbor (probably not enough data for that one though). Just don't dummy out each time point individually or you'll have a perfect-fitting model.\nBut be aware of the possible universe of interactions between the locations that you could model here. Dummying them all out assumes no interactions between them, or at least one you care about, or that relate to anything you care about. It just accounts for fixed effects, i.e. you're assuming that the time dynamic within each location is the same, it's just that some locations tend overall and on average to have higher application numbers than others. You could derive tons of predictors pertaining to any given location based on the application number(s) in other location(s) - current number, past number, etc. All depends on what you consider to be possible and informative to account for.","Q_Score":0,"Tags":"python,sql,excel,statistics","A_Id":52335074,"CreationDate":"2018-09-14T14:55:00.000","Title":"Python\/SQL\/Excel I have 12 datasets and I want to combine them to one representative set","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running my session on a GPU and I'm wondering if the 'session.run()' piece of code is running in parallel to my other code in my script. \nI use batch processing on the CPU prior to running 'session.run()' in a loop and would like to pipeline this processing with the execution on the GPU. Is this already satisfied in this setting or do I need to manually start threads?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":354,"Q_Id":52335065,"Users Score":0,"Answer":"After some research I found out that 'session.run' is not running concurrently to your other code. Indeed, as Ujjwal suggested, the 'tf.data.Dataset' API is the best choice for pipelining batch preprocessing and GPU execution.","Q_Score":0,"Tags":"python,multithreading,tensorflow,parallel-processing,batch-processing","A_Id":52596253,"CreationDate":"2018-09-14T15:29:00.000","Title":"Is tensorflow session running in parallel to the rest of my code?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running my session on a GPU and I'm wondering if the 'session.run()' piece of code is running in parallel to my other code in my script. \nI use batch processing on the CPU prior to running 'session.run()' in a loop and would like to pipeline this processing with the execution on the GPU. Is this already satisfied in this setting or do I need to manually start threads?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":354,"Q_Id":52335065,"Users Score":0,"Answer":"It entirely depends upon how you have written your code. This should be trivial to check, by checking out your CPU  and GPU utilization simultanously\nI normally make use of tf.data.Dataset API. I use the get_next() method of an iterator to feed data to a network. CPU and GPU work in parallel in this case.","Q_Score":0,"Tags":"python,multithreading,tensorflow,parallel-processing,batch-processing","A_Id":52335207,"CreationDate":"2018-09-14T15:29:00.000","Title":"Is tensorflow session running in parallel to the rest of my code?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on Glue since january, and have worked multiple POC, production data lakes using AWS Glue \/ Databricks \/ EMR, etc.  I have used AWS Glue to read data from S3 and perform ETL before loading to Redshift, Aurora, etc.\nI have a need now to read data from a source table which is on SQL SERVER, and fetch data, write to a S3 bucket in a custom (user defined) CSV file, say employee.csv.\nAm looking for some pointers, to do this please.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1571,"Q_Id":52336996,"Users Score":0,"Answer":"This task fits AWS DMS (Data Migration Service) use case. DMS is designed to either migrate data from one data storage to another or keep them in sync. It can certainly keep in sync as well as transform your source (i.e., MSSQL) to your target (i.e., S3).\nThere is one non-negligible constraint in your case thought. Ongoing sync with MSSQL source only works if your license is the Enterprise or Developer Edition and for versions 2016-2019.","Q_Score":3,"Tags":"python,python-2.7,amazon-web-services,amazon-s3,aws-glue","A_Id":66705862,"CreationDate":"2018-09-14T17:50:00.000","Title":"AWS Glue - read from a sql server table and write to S3 as a custom CSV file","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"From a Python script, I want to feed some small string data to a subprocess, but said subprocess non-negotiably accepts only a filename as an argument, which it will open and read. I non-negotiably do not want to write this data to disk - it should reside only in memory.\nMy first instinct was to use StringIO, but I realize that StringIO has no fileno(). mmap(-1, ...) also doesn't seem to create a file descriptor. With those off the table, I'm at a loss as to how to do this. Is this even achievable? The fd would be OS-level visible, but (I would expect) only to the process's children. \ntl;dr how to create private file descriptor to a python string\/memory that only a child process can see?\nP.S. This is all on Linux and doesn't have to be portable in any way.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":876,"Q_Id":52340974,"Users Score":2,"Answer":"Reifying @user4815162342's comment as an answer:\nThe direct way to do this is:\n\npass \/dev\/stdin as the file argument to the process;\nuse stdin=subprocess.PIPE;\nfinally, Popen.communicate(<your input>) to feed the desired contents","Q_Score":3,"Tags":"python","A_Id":52350691,"CreationDate":"2018-09-15T01:56:00.000","Title":"Possible to get a file descriptor for Python's StringIO?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Python list (numpy array) and another list which contains the indices for the location of values from the first array which I want to keep.\nIs there a Pythonic way to do this?\nI know numpy.delete, but I want to keep the elements and not delete them.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":178,"Q_Id":52342187,"Users Score":1,"Answer":"Why don't you use just c=a[b] as this is the Python way to take the values from array a.","Q_Score":1,"Tags":"python,python-2.7,list,numpy","A_Id":52344172,"CreationDate":"2018-09-15T06:18:00.000","Title":"Pythonic way to cut specific elements from numpy array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How am I supposed to handle hidden files like .gitignore in my Eric project? Open Dialog does not seem to have an option to show hidden files; I couldn't find any such option anywhere in settings or configurations. Is there a solution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":114,"Q_Id":52345919,"Users Score":1,"Answer":"With the Qt File Dialog, you can right click on the file list. Show Hidden Files checkbox is on the context menu.","Q_Score":0,"Tags":"python,qt,user-interface,eric-ide","A_Id":52354370,"CreationDate":"2018-09-15T15:00:00.000","Title":"Eric IDE, Qt File Dialog: show hidden files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Lua with Torch, you use \"th\" to run a Lua script. In Python, you use either \"python\" or \"python3\" to run a python script. In Java, you use \"java\" to run a java class script. \nWhat is this word in front the commands, actually called? I tried to search for the name myself, but I couldn't find anything.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":527,"Q_Id":52349926,"Users Score":6,"Answer":"It's just a shell command. Not any different from cd or grep, etc.\nIn the case of Python, the python command invokes the Python interpreter, starting either an interactive session, or, if a file is specified, running the file through the interpreter. But it just tells the shell something to do.","Q_Score":1,"Tags":"java,python,lua,torch","A_Id":52349940,"CreationDate":"2018-09-16T00:20:00.000","Title":"What is the \"th\", \"python\", \"python3\", \"java\", etc... used in front a command to run a script, called?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"For an online assignment to be submitted for a MOOC, I have written a python program that takes in text data (The name, roll numbers, grades, etc of a list of students) in a particular format and prints the output after processing the data. The output is printed from a list of tuples using a for loop to iterate through the list and using the str.join() function to join the elements in the tuples. \nThe list of tuples is sorted already and when I run it in the Spyder IDE console, it prints the output in the order that it appears in the list. But, when I submit in the window of the online judge and run it, the output is obtained in a random order and my answer doesn't get accepted. Can anyone please help? I am all ready to clarify further if my question isn't clear.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":52350632,"Users Score":0,"Answer":"As @Epo rightly pointed out, I tested my input with alphabetically sorted data while the online judge used the same data sorted differently as input. Adding a \"sorted()\" function to the input did the job.","Q_Score":0,"Tags":"python","A_Id":56874178,"CreationDate":"2018-09-16T03:09:00.000","Title":"Getting randomly ordered output from ordered list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I am trying to create a python project on visual studio but I get this error\n\"The imported project file \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild\\15.0\\Microsoft.Common.targets\\ImportBefore\\Microsoft.Cpp.VCLibs120Universal.targets\" could not be loaded. Root element is missing. C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild\\15.0\\Bin\\Microsoft.Common.CurrentVersion.targets\nI already tried repairing visual studio and it didnt work and the files it mentions are there","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":204,"Q_Id":52356675,"Users Score":0,"Answer":"It looks as if the files are corrupted. The safest approach is to uninstall Visual Studio, ensure the entire directory is deleted, and then reinstall it.\nAlternatively, you could just delete the Microsoft.Cpp.VCLibs120Universal.targets file (which appears to be from an old version) and Python projects at least will work. If you notice problems with Universal C++ apps then you may need to run Repair again, and if that brings back the problem I would recommend reporting a bug.","Q_Score":0,"Tags":"python,visual-studio","A_Id":52371989,"CreationDate":"2018-09-16T17:27:00.000","Title":"Error when making a new python project on visual studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to get Celery to allocate tasks to workers based on available RAM? I am developing a web app which applies memory hungry algorithms to large in-memory data, is there a way to make this more robust using Celery to respect available RAM?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":170,"Q_Id":52359174,"Users Score":0,"Answer":"Allocating tasks to workers based on available RAM is not possible. But, depending on your setup and exact requirements there are ways to work address this problem. Off the top of my head I can think of:\n\nyou run one worker (and nothing else) on a machine with loads of RAM\nand have this worker process these memory-hungry tasks only\nif you know how much memory you need for processing a task, you could\ncheck if that memory is available as a first step in your task\n(assuming that not much else runs on that box which could use up that\nmemory in between the check and the actual running of your\nmemory-hungry stuff) and if not, you can retry the task after a\ncertain time","Q_Score":0,"Tags":"python,python-3.x,celery,task-queue","A_Id":52362117,"CreationDate":"2018-09-16T23:18:00.000","Title":"Scheduling tasks with python\/celery\/any other task queue based on available RAM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm looking to program a Python function that takes in 6 variables, a, b, c, d, e, f, where a, b is the interval to compute on (e.g. [1, 3], all real numbers), and c, d, e, f are the coefficients of the cubic polynomial, i.e. f(x) = cx^3 + dx^2 + ex + f, and returns the local min\/max on the interval [a, b].\nI have a rough idea (although the computing time would be bad) of how to program this, where I create a new list of steps 0.01 or something similarly small from a to b, evaluate f at each value, then simply return the min\/max of the list. This would take very long for a, b values that are very far apart.\nWhat is the best way to go about making this? Are there any outside libraries for scientific\/mathematical computing? Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1730,"Q_Id":52360672,"Users Score":3,"Answer":"For cubic function you can find positions of potential minumum\/maximums without optimization but using differentiation:\n\nget the first and the second derivatives\nfind zeros of the first derivative (solve quadratic equation)\ncheck the second derivative in found points - sign tells whether that point is min, max or saddle point\n\nI think that  differentiation should be in sympy package\nAlso check whether problem statement assumes accounting for boundary values (as @Lakshay Garg notices in comments)","Q_Score":0,"Tags":"python,math,scientific-computing","A_Id":52360778,"CreationDate":"2018-09-17T04:15:00.000","Title":"Finding local min\/max of a cubic function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a Python program with Qt5 GUI and compiled an .exe with PyInstaller. It works fine on most PCs, but on some the compiled .exe wont start at all. No error message, no process in taskmanager, no entry in system protocol. I uninstalled anti virus program and disabled windows defender, still the same. The funny thing is, that when I open a command prompt and start the .exe from within the command prompt it works as it should. But it does not when double clicking the .exe from within windows explorer. The Windows OS is Windows 10.\nAny suggestions or somebody had same\/similar issue?\nRegards\nDavid\nEDIT: Windows UAC was the problem: when turend completely off the application does not start.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":365,"Q_Id":52364789,"Users Score":0,"Answer":"Windows UAC was the problem: when turend completely off the application does not start.","Q_Score":0,"Tags":"python,windows,qt5,pyinstaller,pyside2","A_Id":52421758,"CreationDate":"2018-09-17T09:39:00.000","Title":"Pyinstaller Qt5 Application won't start in Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to find the centre point of clusters of DBSCAN clustering algorithm in sklearn.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6728,"Q_Id":52364959,"Users Score":10,"Answer":"DBSCAN doesn't have centers.\nYou can compute then yourself, but they may be outside of the cluster if it is not convex.","Q_Score":3,"Tags":"python-3.x,scikit-learn,dbscan","A_Id":52438930,"CreationDate":"2018-09-17T09:49:00.000","Title":"How to find center points of DBSCAN clusrering in sklearn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Most of the standard libraries are written in Python .py files, but some are in .so files on Unix and .pyd on Windows. For example os is written in os.py while pyexpat is written in pyexpat.cpython-36m-darwin.so. What's so special about these .so libraries?","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":3236,"Q_Id":52365723,"Users Score":5,"Answer":".so files are shared object files, which are compiled shared libraries. They are usually written in a compiled language like C, C++, Go etc. \nPython being an interpreted language, code written in it tends to be slow, because the interpreter needs to go through each line of the code being executed, translate it into some sort of intermediate byte code and then finally execute the byte code. This can be slow. \nIn cases where performance is a concern, modules are written in a lower level language like C which is then compiled to a shared object file. These files can be loaded by the Python interpreter and used like a normal python module. Because these modules are already compiled to machine code, they can be directly executed without going through the interpreter, and thus they are much faster than the equivalent code written in Python. \nWriting in a lower level language like C also allows for efficient usage of the memory and even release the global interpreter lock in order to exploit multicore parellilism. Scientific modules like numpy, scipy are examples of these.","Q_Score":2,"Tags":"python,standard-library,.so","A_Id":52365859,"CreationDate":"2018-09-17T10:31:00.000","Title":"Why are some Python standard libraries written in .so while most others are in .py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"What are the differences between running Python code through an IDE and terminal? When I run my code in PyCharm it works, however when I try to run the same code in terminal I get NameError, etc.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":176,"Q_Id":52368509,"Users Score":0,"Answer":"An exact answer depends on the exact IDE and the exact terminal one compares on a particular OS.  The IDLE doc chapter, accessible from IDLE's Help menu, has a section '3.3. IDLE-console differences '.  Some of these apply to other IDEs.\nOne possible difference not discussed is language differences.  IDLE runs user code directly with python, as is.  Other IDEs add language extensions or command escapes.\nYour issue with NameErrors suggests that PyCharm inserts something into globals that standard python does not.  A few years ago, a couple of Stackoverflowers reported extra name issues with IDLE, which I fixed.  For anyone to say anything more, you would have to add specific code and the resulting traceback to your question.","Q_Score":0,"Tags":"terminal,python-idle","A_Id":52377559,"CreationDate":"2018-09-17T13:07:00.000","Title":"What are the differences between running Python through an IDE and terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Everything else in python seems to work. When I start python from my terminal and type from scapy import all it completely locks up on me and takes a minute or two to kill. Anyone know why this could be?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":52370212,"Users Score":0,"Answer":"It's hard to tell exactly why, but here are a few possibilities:\n\nit might be working, but taking a while to import; you can check this by watching the CPU usage.\ngive it a few minutes and if it's still not working hit ctrl-c as Austin said; it should display an error trace which could tell you where the program is caught up.\nYour version of scapy might be out of date (the latest is 2.4.0). Try updating to the newest version","Q_Score":0,"Tags":"python-3.x,freeze,scapy","A_Id":52371119,"CreationDate":"2018-09-17T14:38:00.000","Title":"Terminal locking up trying to import scapy.all","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to make a python program that creates and writes in a txt file.\nthe program works, but I want it to cross the \"hidden\" thing in the txt file's properties, so that the txt can't be seen without using the python program I made. I have no clues how to do that, please understand I am a beginner in python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":52371454,"Users Score":0,"Answer":"I'm not 100% sure but I don't think you can do this in Python. I'd suggest finding a simple Visual Basic script and running it from your Python file.","Q_Score":0,"Tags":"python,python-3.x","A_Id":52371677,"CreationDate":"2018-09-17T15:44:00.000","Title":"how to modify txt file properties with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running a NN training on my GPU with pytorch.\nBut the GPU usage is strangely \"limited\" at about 50-60%.\nThat's a waste of computing resources but I can't make it a bit higher.\nI'm sure that the hardware is fine because running 2 of my process at the same time,or training a simple NN (DCGAN,for instance) can both occupy 95% or more GPU.(which is how it supposed to be)\nMy NN contains several convolution layers and it should use more GPU resources.\nBesides, I guess that the data from dataset has been feeding fast enough,because I used workers=64 in my dataloader instance and my disk works just fine.\nI just confused about what is happening.\nDev details: \nGPU : Nvidia GTX 1080 Ti\nos:Ubuntu 64-bit","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":795,"Q_Id":52374287,"Users Score":1,"Answer":"I can only guess without further research but it could be that your network is small in terms of layer-size (not number of layers) so each step of the training is not enough to occupy all the GPU resources. Or at least the ratio between the data size and the transfer speed (to the gpu memory) is bad and the GPU stays idle most of the time.\ntl;dr: the gpu jobs are not long enough to justify the memory transfers","Q_Score":0,"Tags":"python,machine-learning,pytorch","A_Id":52387459,"CreationDate":"2018-09-17T19:08:00.000","Title":"Why will GPU usage run low in NN training?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to compute the center of mass of solid objects constructed with a CAD software that are saved with the STEP format.\nHas someone experience with this type of files? How can I extract that information?\n(I'm working with python, but I also know a little bit of C).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":208,"Q_Id":52374335,"Users Score":0,"Answer":"Have you looked at FreeCAD or pythonOCC?","Q_Score":0,"Tags":"python,cad,step","A_Id":52376749,"CreationDate":"2018-09-17T19:12:00.000","Title":"How to compute the center of mass of a solid geometry contained in a STEP 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":"Hi I'm using windows and installing python-docx using pip. I went into C:\\Python27\\Scripts and ran pip install python-docx . I thought it should have been installed.\nBut when i run a simple import \nfrom docx import Documents \nit ran into an \"ImportError: No module named docx\"\nwhen i checked the modules installed using pip using pip list python-docx 0.8.7 is installed. Does anyone know why whis is happening? \nUpdate : I just found out the script runs when i run the script on windows command line, but it doesn't run on IDLE could it be some configurations on IDLE?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2699,"Q_Id":52377694,"Users Score":0,"Answer":"Just in case if someone is still having problem, please update your setuptools and install python-docx.\npip install -U setuptools\npip install --pre python-docx","Q_Score":0,"Tags":"docx,importerror,gae-python27","A_Id":55239757,"CreationDate":"2018-09-18T01:30:00.000","Title":"python docx installed but cannot be imported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to parse data with Lambda when an alarm is triggered in Cloudwatch. I am currently using SNS to trigger the lambda; however, I want to know what data is being sent to that Lambda so that I can parse it correctly.\nHow can I read the JSON alarm data that's passed into Lambda by SNS?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":12254,"Q_Id":52379697,"Users Score":-1,"Answer":"The easiest and simple way is to create a new subscription for the SNS Topic to which the cloudwatch sends alarm data, with Email-JSON protocol and enter your email and create subscription.\nConfirm the subscription by clicking on the verification link in email. When CloudWatch sends an alarm next time, you will get the JSON data in email and then you can figure out how to parse it correctly.","Q_Score":15,"Tags":"python,amazon-web-services,aws-lambda,amazon-sns,amazon-cloudwatch","A_Id":52380377,"CreationDate":"2018-09-18T05:47:00.000","Title":"What is in the JSON payload Cloudwatch sends to SNS? How can I read that data?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am coming from a VScode background , and for my recent project (on Deep Learning) I am having to manage huge code files in Spyder (Version 3), and I am not seeing any option of code folding?\nI am not willing to switch to another IDE , as Spyder is very productive for my project. \nPlease suggest any hack to do it , if it is not there in the Spyder codebase.","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":21055,"Q_Id":52380572,"Users Score":6,"Answer":"Spyder 4.0.1 is released, which supports code folding.\nIf you are using anaconda, use\nconda update --all\nto get it.","Q_Score":12,"Tags":"python,spyder,code-folding","A_Id":59943271,"CreationDate":"2018-09-18T06:53:00.000","Title":"Handling folds in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am coming from a VScode background , and for my recent project (on Deep Learning) I am having to manage huge code files in Spyder (Version 3), and I am not seeing any option of code folding?\nI am not willing to switch to another IDE , as Spyder is very productive for my project. \nPlease suggest any hack to do it , if it is not there in the Spyder codebase.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":21055,"Q_Id":52380572,"Users Score":23,"Answer":"(Spyder maintainer here) You can install the first beta of Spyder 4 to get code folding.\nIf you use Anaconda, you need to use the following commands:\nconda update anaconda\nconda update spyder\nor if you use pip, then you need to run\npip install -U --pre spyder\nThis beta is quite stable and it has been tested for more than a year.","Q_Score":12,"Tags":"python,spyder,code-folding","A_Id":52390693,"CreationDate":"2018-09-18T06:53:00.000","Title":"Handling folds in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some Primavera .xer files. \nI can open these files in notepad and I see, that there is some text data (it looks like database data).\nAre there any Python parsers for these files?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1678,"Q_Id":52381302,"Users Score":1,"Answer":"The Primavera P6 XER format is indeed vulnerable to analysis by the CSV module. It's basically a tab-delimited back-up format for a relational database.\nThe first row is some meta-information about the file. Thereafter, each row begins with a code that tells what the rest of the row contains:\n\n%T gives the name of a table.\n%F gives the name of some fields in that table, all on one line.\n%R is a record for the most recently-defined table.\n%E is the end-of-file marker.\n\nThe rest depends entirely on how you want to use the data. For my part, I put the data directly into a (fresh, new) SQLITE database first and worry about applications later.","Q_Score":1,"Tags":"python,primavera","A_Id":53854273,"CreationDate":"2018-09-18T07:37:00.000","Title":"How to read xer-files using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I split my dataset in X_train, Y_train, X_test and Y_test, and then I used the symbolicRegressor...\nI've already convert the string values from Dataframe in float values.\nBut by applying the symbolicRegressor I get this error: \n\nValueError: could not convert string to float: 'd'\n\nWhere 'd' is a value from Y.\nSince all my values in Y_train and Y_test are alphabetic character because they are the \"labels\", I can not understand why the symbolicRegressor tries to get a float number ..\nAny idea?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":302,"Q_Id":52381949,"Users Score":0,"Answer":"Sorry for the late replay. gplearn supports regression (numeric y) with the SymbolicRegressor estimator, and with the newly released gplearn 0.4.0 we also support binary classification (two labels in y) using the SymbolicClassifier. From the sounds of things though, you have a multi-label problem which gplearn does not currently support. It may be something we look to support in the future.","Q_Score":0,"Tags":"python-3.x,genetic,gplearn","A_Id":55842872,"CreationDate":"2018-09-18T08:14:00.000","Title":"Y_train values for symbolicRegressor","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I split my dataset in X_train, Y_train, X_test and Y_test, and then I used the symbolicRegressor...\nI've already convert the string values from Dataframe in float values.\nBut by applying the symbolicRegressor I get this error: \n\nValueError: could not convert string to float: 'd'\n\nWhere 'd' is a value from Y.\nSince all my values in Y_train and Y_test are alphabetic character because they are the \"labels\", I can not understand why the symbolicRegressor tries to get a float number ..\nAny idea?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":302,"Q_Id":52381949,"Users Score":0,"Answer":"According to the https:\/\/gplearn.readthedocs.io\/en\/stable\/index.html - \"Symbolic regression is a machine learning technique that aims to identify an underlying mathematical expression that best describes a relationship\". Pay attention to mathematical. I am not good at the topic of the question and gplearn's description does not clearly define area of applicability \/ restrictions. \nHowever, according to the source code https:\/\/gplearn.readthedocs.io\/en\/stable\/_modules\/gplearn\/genetic.html method fit() of BaseSymbolic class contains line X, y = check_X_y(X, y, y_numeric=True) where check_X_y() is sklearn.utils.validation.check_X_y(). Argument y_numeris means: \"Whether to ensure that y has a numeric type. If dtype of y is object, it is converted to float64. Should only be used for regression algorithms\".\nSo y values must be numeric.","Q_Score":0,"Tags":"python-3.x,genetic,gplearn","A_Id":52389432,"CreationDate":"2018-09-18T08:14:00.000","Title":"Y_train values for symbolicRegressor","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create an array of powers of 10 as a label for the y axis of a plot.\nI am using the plt.yticks() with matplotlib imported as plt but this does not matter here anyway.\nI have plots where as the y axis is varying from 1e3 to 1e15. Those are log plots.\nMatplotlib is automatically displaying those with ticks with 1e2 steps and I want to have a step of 10 instead (in order to be able to use the minorticks properly).\nI want to use the plt.yticks(numpy.arange(1e3, 1e15, 10)) command as said but numpy.arange(1e3, 1e15, 10) result in a MemoryError. Isn't it supposed to output an array of length 13? Why does the memory gets full?\nHow to overpass this issue and not build the array manually?\nI also tried using built-in range but it won't work with floats.\nThank you.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":911,"Q_Id":52383129,"Users Score":0,"Answer":"In this case the function logspace from numpy is more suitable.\nThe answer to the example is\nnp.logspace(3,15,num=15-3+1, endpoint=True)","Q_Score":5,"Tags":"python,numpy,matplotlib,out-of-memory","A_Id":52383425,"CreationDate":"2018-09-18T09:18:00.000","Title":"MemoryError with numpy arange","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While I am using django_select2, the field_id parameter is not getting passed to get URL select2\/fields\/auto.json.\nDue to this, it throws 404 error.\nIs there any configuration I am missing?\npython3.6, \ndjango2.1 and \ndjango_select2 LIB_VERSION = v4.0.5\ndjango_select2-6.3.1.dist-info\nAll are latest versions only.\nI am not sure where is the problem but I can see that GET URL select2\/fields\/auto.json is called without field_id. When I manually execute it with field_id with the key generated, I am getting the proper results.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":734,"Q_Id":52383968,"Users Score":0,"Answer":"Here is the maintainer of django-select2. Saldy we no longer maintain version 4. This is a really old version and in version 5 we did a complete rewrite. That solved a lot of issues. Maybe this one too. I highly suggest to update to the latest version. Especially if you are using Django 2.1 and Python 3.6.","Q_Score":1,"Tags":"django,python-3.x,jquery-select2,django-select-related","A_Id":52393895,"CreationDate":"2018-09-18T10:00:00.000","Title":"In django_select2, the field_id parameter is getting not passed in ajax url","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We have successfully executed the source data collection python program using App Engine Cron service in App Engine Flexible environment. \nNow, We are trying to execute the same python program in App Engine Standard Environment. But, We are getting the Error Can't connect to HTTPS URL because the SSL module is not available. \nAnyone came across this Error ? I have given full access to App Engine default service account for the Bucket. Please help to resolve this issue.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":52384913,"Users Score":0,"Answer":"Managed to resolve this error.\nWe need to add the below libraries in the app.yaml\nlibraries:\n - name: ssl\n   version: latest","Q_Score":0,"Tags":"google-app-engine,google-app-engine-python,app-engine-flexible","A_Id":52455730,"CreationDate":"2018-09-18T10:50:00.000","Title":"Python program working fine in App Engine Standard Environment. But we get SSL error when we schedule it in App Engine Flexible Environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I could see Perl script to send Splunk alert results to SNMP server. But i want to write python script which needs to send results to Snmp server.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":52385476,"Users Score":0,"Answer":"You should connect to your splunk server also send your access,error logs with your splunk forwarder via python","Q_Score":0,"Tags":"python,snmp,splunk","A_Id":52498047,"CreationDate":"2018-09-18T11:22:00.000","Title":"Send splunk alert results to SNMP server using python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working with a relatively large CSV file in Python. I am using the pandas read_csv function to import it. The data is on a shared folder at work and around 25 GB.\nI have 2x8 GB RAM and an Intel Core i5 processor and using the juypter notebook. While loading the file the RAM Monitoring goes up to 100%. It stays at 100% or 96% for some minutes and then my computer clock stopped and my screen is frozen. Even if I wait 2 hours my computer is not able to use any more, so I have to restart.\nMy question is:\nDo I need to split the data? Would it help? Or is it a general performance problem with my laptop?\nIt is the first time that I am working with such a 'large' dataset (I still think 25 GB is not too much.)","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":593,"Q_Id":52387191,"Users Score":1,"Answer":"You're probably loading all of the data in your RAM, thus allocating all memory available, forcing your system to rely on swap memory (writing temporary data to the disk, which is MUCH slower).\nIt should solve the issue if you split the data into chunks that fit in your memory. Maybe 1 GB each?","Q_Score":0,"Tags":"python,pandas,csv","A_Id":52387276,"CreationDate":"2018-09-18T13:00:00.000","Title":"Reading large CSV file with Pandas freezes computer","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to call a webservice from a Databricks Notebook through Python. The needed library for this seems to be http.client.\nI have already found a code snippet to test this but when i try to execute it i get the following error:\n\nImportError: No module named http.client\n\nThis is correct cause i have no module installed yet.\nIn the next step i go to a folder within my Databricks, select Import -> Import Notebooks dialog click on (To import a library, such as a jar or egg, click here) -> Select in the Language DropDown Upload Python Egg or PyPI -> in pyPI name typehttp.client` and click on Install Library.\nThen i select Attach automatically to all clusters.\nI receive the following error:\n\nError: java.lang.RuntimeException: Installation failed with message:\n  Collecting http.client Collecting http.client Could not find a version\n  that satisfies the requirement http.client (from versions: ) No\n  matching distribution found for http.client You are using pip version\n  9.0.1, however version 18.0 is available. You should consider upgrading via the 'pip install --upgrade pip' command. Could not find\n  a version that satisfies the requirement http.client (from versions: )\n  No matching distribution found for http.client You are using pip\n  version 9.0.1, however version 18.0 is available. You should consider\n  upgrading via the 'pip install --upgrade pip' command.\n\nHow can i fix this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1210,"Q_Id":52388039,"Users Score":1,"Answer":"Can you import httplib, it must resolve the issue","Q_Score":1,"Tags":"python,azure,pip,pypi,databricks","A_Id":52388793,"CreationDate":"2018-09-18T13:45:00.000","Title":"Cannot install python packages thorugh PyPi in Azure Databricks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using Odoo 10 and I cant figure out how to stop a custom float field rounding.\nHere is my field box = fields.Float(\"Yards Per Box\")\nIn Odoo if I put 1.196 into the field it auto rounds to 1.20 how can I stop this on  a custom Float field?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":5182,"Q_Id":52388694,"Users Score":-1,"Answer":"Try this,\nbox = fields.Float(\"Yards Per Box\", digits=3)\nif you want to add 3 digit precision...","Q_Score":0,"Tags":"python,odoo,odoo-10,odoo-9,odoo-11","A_Id":52398540,"CreationDate":"2018-09-18T14:20:00.000","Title":"Odoo Float field Rounding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a conceptual question about doing test driven development with Django, may also apply to other frameworks as well.\nTDD states that the firts step in the development cycle is to write failing tests. \nSuppose for a unit test, I want to verify that an item is actually created when a request arrives. To test this functioanlty, I want to issue a request with the test client, and check with the db that this object is actully created. To be able to do that, I need to import the related model in the test file, but as the first step is writing this test, I don't even have a model yet. So I won't be able to run the tests to see them fail.\nWhat is the suggested approach here? Maybe write a simpler test first, then modify the test after enough level of production code is implemented?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":321,"Q_Id":52389183,"Users Score":0,"Answer":"In Django, the approach is always to recreate a working environment for testing and staging. In testing the data is fake, in staging the data is \"old\" or very similar to the production.","Q_Score":2,"Tags":"python,django,testing,tdd","A_Id":52389672,"CreationDate":"2018-09-18T14:44:00.000","Title":"Test Driven Development with Django","Data Science and Machine Learning":0,"Database and SQL":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 play a sound (from a wav file) using winsound's winsound.PlaySound function. I know that winsound.Beep allows me to specify the time in milliseconds, but how can I implement that behavior with winsound.PlaySound? \nI tried to use the time.sleep function, but that only delays the function, not specifies the amount of time. \nAny help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":52389545,"Users Score":1,"Answer":"Create a thread to play the sound, start it. Create a thread that sleeps the right amount of time and has a handle to the first thread. Have the second thread terminate the first thread when the sleep is over.","Q_Score":1,"Tags":"python,python-3.x,time,sleep","A_Id":52389699,"CreationDate":"2018-09-18T15:03:00.000","Title":"How can I run code for a certain amount of time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I see the same error many people have seen. \n\ndjango.db.migrations.exceptions.InconsistentMigrationHistory: Migration message.0001_initial is applied before its dependency users.0001_initial on database 'default'.\n\nSeems like the cause is because I'm using CustomUser model (using django-allauth).\nI already delete all the migration folders and sqlite3 and tried some ways other people answered. But I cannot avoid this error. \nSeems like I was successful in avoiding this error (I have no idea how I did.)\nAnd because the migration files still remains on my gitHub, I saw them and all the files look the same as the ones I created before.  I'm wondering if I can ignore this error and waring. If not, what is the way to avoid this error?\nwhat I did\nusing --fake when doing migrations\nhiding django.admin when doing migrations\napplying zero\nall things failed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":975,"Q_Id":52389718,"Users Score":0,"Answer":"I actually solved the problem.\nWhat I did is applying migration into the app CustomUser model is located, and then applying migration into other apps. And then I did python manage.py migrate.\nOther orders doesn't work for me.","Q_Score":0,"Tags":"python,django","A_Id":52389903,"CreationDate":"2018-09-18T15:12:00.000","Title":"Django; Is it possible to ignore this error? django.db.migrations.exceptions.InconsistentMigrationHistory:","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to automate the typing process in a video game. Players are given an on-screen QWERTY keyboard layout that they can navigate with the control stick (up, down, left, right) in order to select a letter to type. I was wondering if there was a module for Python (or some other resource I could explore) that would help my program find a path across the keyboard as it types each letter in a given message. In other words, if the first letter typed was \"A\" and the next letter was \"B\", the module would know that the program should move 1 space down on the keyboard and 4 spaces to the right.\nCurrently, I have the program resetting to the \"G\" key after each letter is typed (allowing me to use fixed-directions as the program parses each character in the desired message). As you can imagine, this is quite inefficient and defeats the purpose of automating the typing in the first place.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":75,"Q_Id":52390106,"Users Score":3,"Answer":"Associate to each letter a position.\nFor example, Q would be (0,0), W (0,1), Z is (0,2), ... A (1,0) ...\nThis way it is very simple to find the shortest path (simple vectors substraction)\nTo compute the path Q -> S : \n(0,0) - (1,1) = (-1,-1) so you need to do 1 down then 1 right.","Q_Score":2,"Tags":"python,algorithm,keyboard","A_Id":52390530,"CreationDate":"2018-09-18T15:34:00.000","Title":"How to determine optimal route across keyboard","Data Science and Machine Learning":0,"Database and SQL":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-app. One part of the app calls a function that starts a tweepy StreamListener on certain track. That functions process a tweet and then it writes a json object to a file or mongodb.\nOn the other hand I need a process that is reading the file or mongodb and paginates the tweet if some property is in it. The thing is that I don't know how to do that second part. Do I need different threads?\nWhat solutions could there be?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":52391071,"Users Score":0,"Answer":"You can certainly do it with a thread or spinning up a new process that will perform the pagination.\nAlternatively you can look into a task queue service (Redis queue, celery, as examples). Your web-app can add a task to this queue and your other program can listen to this queue and perform the pagination tasks as they come in.","Q_Score":0,"Tags":"python,flask,tweepy","A_Id":52396308,"CreationDate":"2018-09-18T16:35:00.000","Title":"Do I need two instances of python-flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to see the logs that generated from a python application. This python application runs in a miniconda environment.Is there a way I can check the logs ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":385,"Q_Id":52391909,"Users Score":0,"Answer":"I don't know whether I understand the question correctly. In case your application is using logging object (ref. https:\/\/docs.python.org\/3\/library\/logging.html) then your output could either be in:\n\nConsole: from which the application was started\nFile: in case that you specified the logging output to a file\n\nIt depends on your configuration and on the logging level as well. Some applications (like Django) use their own configuration to log.","Q_Score":0,"Tags":"python,miniconda","A_Id":52392011,"CreationDate":"2018-09-18T17:35:00.000","Title":"How to view logs related to a python application runs as miniconda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Hey I am really stuggling here with airflow on this. I have two other dags running no probllem however for some reasons these dags are failing and I'm not getting much back that makes sense to me in the logs. I can run this task with no issues as the airflow user through the command line but for some reason when I try doing it through the dag I get exit code 2. Has anyone some pointers on this? Thank you\n\n[2018-09-18 20:08:18,886] {base_task_runner.py:95} INFO - Subtask: airflow: error: unrecognized arguments: run pull_dcm_today_data pull_dcm_today_data 2018-09-18T19:00:00 --job_id 8 --raw -sd DAGS_FOLDER\/run_pull_dcm_today.py\n[2018-09-18 20:08:22,579] {jobs.py:2083} INFO - Task exited with return code 2","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4139,"Q_Id":52396445,"Users Score":1,"Answer":"Try testing each one of the tasks in order using the airflow test command. If all the tasks run successfully but the DAG's keep failing you probably need to restart the whole project (webserver, scheduler and workers) because you might have outdated code somewhere.","Q_Score":1,"Tags":"python,airflow","A_Id":52397957,"CreationDate":"2018-09-19T00:49:00.000","Title":"when trying to run dag and Airflow returning status code2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I had been working with pyodbcfor database connection in windows envirnment and it is working fine but now I want to switch to pymssql so that it is easier to be deployed to Linux machine as well. But I am getting this error:\n\n(20009, b'DB-Lib error message 20009, severity 9:\\nUnable to connect: Adaptive Server is unavailable or does not exist (localhost:1433)\\nNet-Lib error during Unknown error (10060)\\n')\n\nMy connection code for using both pyodbc and pymssql is:\n\n    import pyodbc\n    import pymssql\n\n    def connectODSDB_1():\n        conn_str = (\n            r\"Driver={SQL Server};\"\n            r\"Server=(local);\"\n            r\"Database=populatedSandbox;\"\n            r\"Trusted_Connection=yes;\"\n        )\n        return pyodbc.connect(conn_str)\n\n    def connectODSDB_2():\n        server = '(local)'\n        database = 'populatedSandbox'\n        conn = pymssql.connect(server=server, database=database)\n        return conn\n\n\nWhat could be the problem? And solution?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4195,"Q_Id":52401252,"Users Score":5,"Answer":"Well after browsing internet for a while, it seems pymssql needs TCP\/IP be enabled for communication. \n\nOpen Sql Server Configuration Manager\nExpand SQL Server Network Configuration\nClick on Protocols for instance_name\nEnable TCP\/IP","Q_Score":4,"Tags":"python,database-connection,pymssql","A_Id":52401546,"CreationDate":"2018-09-19T08:17:00.000","Title":"Database connection failed for local MSSQL server with pymssql","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to Fit Multiple Linear Regression Model\nY= c + a1.X1 + a2.X2 + a3.X3 + a4.X4 +a5X5 +a6X6 \nHad my model had only 3 variable I would have used 3D plot to plot.\nHow can I plot this . I basically want to see how the best fit line looks like or should I plot multiple scatter plot and see the effect of individual variable \nY = a1X1 when all others are zero and see the best fit line.\nWhat is the best approach for these models. I know it is not possible to visualize higher dimensions want to know what should be the best approach. I am desperate to see the best fit line","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":24001,"Q_Id":52404857,"Users Score":2,"Answer":"You can use Seaborn's regplot function, and use the predicted and actual data for comparison. It is not the same as plotting a best fit line, but it shows you how well the model works.\nsns.regplot(x=y_test, y=y_predict, ci=None, color=\"b\")","Q_Score":5,"Tags":"python,matplotlib,machine-learning,regression,linear-regression","A_Id":65549840,"CreationDate":"2018-09-19T11:29:00.000","Title":"How do I plot for Multiple Linear Regression Model using matplotlib","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pandas DataFrame with a column representing a categorical variable. How can I get a list of the categories? I tried .values on the column but that does not return the unique levels.\nThanks!","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":67005,"Q_Id":52404971,"Users Score":3,"Answer":"Try executing the below code.\nList_Of_Categories_In_Column=list(df['Categorical Column Name'].value_counts().index)","Q_Score":28,"Tags":"python,pandas,categorical-data","A_Id":59574232,"CreationDate":"2018-09-19T11:36:00.000","Title":"Get a list of categories of categorical variable (Python Pandas)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pandas DataFrame with a column representing a categorical variable. How can I get a list of the categories? I tried .values on the column but that does not return the unique levels.\nThanks!","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":67005,"Q_Id":52404971,"Users Score":0,"Answer":"df.column name.value_counts() # to see total number of values for each categories in a column\ndf.column name.value_counts().index # to see only the categories name\ndf.column name .value_counts().count() # to see how many categories in a column (only number)","Q_Score":28,"Tags":"python,pandas,categorical-data","A_Id":67443900,"CreationDate":"2018-09-19T11:36:00.000","Title":"Get a list of categories of categorical variable (Python Pandas)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need Twitter tweet button below every blog post.\nHow do I make {% pageurl %} return an absolute URL of that specific blog post?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":510,"Q_Id":52405554,"Users Score":1,"Answer":"Instead of {% pageurl my_page %}, use {{ my_page.full_url }}.","Q_Score":0,"Tags":"python,django,wagtail","A_Id":52406374,"CreationDate":"2018-09-19T12:09:00.000","Title":"How to make pageurl return an absolute url","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a long-running script at work (windows unfortunately) where I programmed it to print the current analysis results if I ctrl-c.  However, I was curious if after doing ctrl-c, I could start the script running again where it left off?\nThis is actually 3 questions:\n-is it possible to do this without any programming changes? - e.g. I accidentally hit ctrl-c and want to retroactively start it where it left off\n-can I use a command like ctrl-z (only on Mac I believe) on windows and program the script to print results when I issue it?\n-what is the best programmatic way of automatically finishing the execution of the line I am on (massive .txt file of data) when I use an interrupt command, store that line number (in a file maybe), and restart the program on the next line with the next execution?\nThanks! \n(FYI: I'm a novice Pythoner and my script currently takes about 10 min to perform 1 million lines.  Files I will use in the future will often have 100+ million lines)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":52408087,"Users Score":1,"Answer":"The short answer to your first question is No. Ctrl-C signals the interpreter, which unwinds the stack, presents you with a stack trace, and halts. You can't recover from ctrl-C for the same reason that you can't recover from any other untrapped exception. What you are asking for is a quick way to put Humpty Dumpty back together again. \nYou can restart a chess game from any point simply by laying out the pieces according to a picture you made before abandoning the game. But you can't easily do that with a program. The problem is that knowing the line number where the program stopped is not nearly enough information to recreate the state of the program at the time: the values of all the variables, the state of the stack, how much of the input it had read, and so forth. In other words, the picture is complicated, and laying out the pieces accurately is hard.\nIf your program is writing to the Windows console, you can suspend output by pressing ctrl-S and restart it by pressing ctrl-Q. These control characters are holdovers from the days of Teletype machines, but modern terminal emulators still obey them. This is a quick way to do what you want without program changes. Unsophisticated, but maybe good enough to begin with.\nAnd your program will probably run a lot faster if it writes its output to file, for later examination in a text editor, rather than writing directly to the Windows console.\nA full-on solution to your problem is something that I hesitate to recommend to a novice. The idea is to split calculation and display into two processes. The calculation process does its thing and feeds its results line by line to the display process. The display process listens to the calculation process and puts the results that it gets on the screen, but can also accept pause and resume commands. What happens while it is in the paused state is a design decision. You can decide either that the calculation process should block (easier option) or that it should buffer its results until the display process is ready to accept them again (harder option).","Q_Score":0,"Tags":"python,python-3.x","A_Id":52408920,"CreationDate":"2018-09-19T14:20:00.000","Title":"If I Keyboard Interupt a running Python script, is there a way to begin again where it left off? (windows)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Apply returns indices of leafs. \nCould anyone explain which indices does it return? Related fucntion in Matlab?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":33,"Q_Id":52408980,"Users Score":2,"Answer":"It gives you the indices of the leaf your data point is for every tree of your forest.\nThis is what is then used to predict the class of your point.","Q_Score":0,"Tags":"python-3.x,scikit-learn,random-forest,sklearn-pandas","A_Id":52409256,"CreationDate":"2018-09-19T15:06:00.000","Title":"RandomForestClassifiers sklearn apply(X)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I set the hoverinfo of a Plotly object to \"x+text\", I can modify what is shown in the hover tooltip using the hovertext attribute.\nI haven't found a way to modify the hover text along the x-axis though. I would like to modify it to be more than the default x-axis value at that location.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":130,"Q_Id":52409641,"Users Score":0,"Answer":"I think maybe you want to change the ticklabels of x-axis instead of the hoverinfo.\nThe meaning of x in hoverinfo is the x-coordinated of the points. So if you truly want to revise the x, maybe you should change the x-coordinated of the points. Maybe changed into string or some special case.\nOf course, you could also use hovertext to fully present all the information which you want to present. If you are worried about the \\n symbol is not working, you could use <Br> directly.","Q_Score":0,"Tags":"python,plotly","A_Id":52435565,"CreationDate":"2018-09-19T15:42:00.000","Title":"Is it possible to customize Plotly x-axis hoverinfo in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I'm on line 500 in spyder, and I want to run everything from that line and above (lines 1-500), is there a shortcut to select the lines quickly. Right not I'm highlighting the lines and scrolling up and using shift and up arrow but both of them take some time to scroll. Is there a faster way to select, similar to select all but only for the specific lines 1-500?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2499,"Q_Id":52410927,"Users Score":0,"Answer":"Just in case someone is interested in deleting all the lines, and only find this question after searching, the easy way would be using\n'''\nfor all the codes between the two lines, and then use the triangle on the left to suppress, so you could delete in one go.","Q_Score":1,"Tags":"python,spyder","A_Id":71294167,"CreationDate":"2018-09-19T17:03:00.000","Title":"Spyder Python Shortcut to Select All Text Above Current Line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I'm on line 500 in spyder, and I want to run everything from that line and above (lines 1-500), is there a shortcut to select the lines quickly. Right not I'm highlighting the lines and scrolling up and using shift and up arrow but both of them take some time to scroll. Is there a faster way to select, similar to select all but only for the specific lines 1-500?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2499,"Q_Id":52410927,"Users Score":1,"Answer":"This post is old I know, but I found out that CTRL-Shift-Home doesn't work for me.\nI have to use CTRL-Alt-Shift-Home to select everything above the line or -End for everything below.\nThis is for Windows 7 and Spider 3.3.6","Q_Score":1,"Tags":"python,spyder","A_Id":62040671,"CreationDate":"2018-09-19T17:03:00.000","Title":"Spyder Python Shortcut to Select All Text Above Current Line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to calculate conditional probability p(a | b,c ) in python? where the probabilities are based on frequency of states a,b,c.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1749,"Q_Id":52412403,"Users Score":0,"Answer":"If you know pandas I'd use that, or just write yourself a function that takes in the points and returns probability :)","Q_Score":0,"Tags":"python-3.x,probability","A_Id":52412959,"CreationDate":"2018-09-19T18:46:00.000","Title":"Calculate conditional probability in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"C:\\ProgramData\\Miniconda3\\pkgs\\plotly-3.1.1-py36h28b3542_0\\Lib\\site-packages\\plotly\nC:\\ProgramData\\Miniconda3\\Lib\\site-packages\\plotly\n\nWhat is the difference between these?\nmy code tries to pull from the second location but doesnt find things.\nfor example, it will tell me my module 'plotly.figure_factory' has no attribute 'create_choropleth' or something\nso I transferred the files from the first location to the second one and it found them.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":52412901,"Users Score":1,"Answer":"Pkgs directory is somewhere to place the package downloaded and unzipped. So it is a full and complete scripts\/project documents.\nActually, the second one should have the file you want if you installed the package properly. I think maybe there are some problems during installing or you just install it into some sub-environment of miniconda instead of the global environment of miniconda. So there will be some left packages which are downloaded and unzipped but not installed.\nYou could also copy and paste the file from the first location to the second one by yourself. If you could import properly, it should be ok.","Q_Score":0,"Tags":"python,anaconda,plotly,choropleth,miniconda","A_Id":52435517,"CreationDate":"2018-09-19T19:21:00.000","Title":"Why does Anaconda have two site-packages libraries?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been away from Python for a while (just a normal guy trying to learn it) and wanted to start learning again. I came across Anaconda and I am trying to figure out whether to use it or stick to pip. There are several questions for this, but they are all related to people using Python for Datascience, which I use R for.\nSo, is there any reason for me to use Anaconda if I am not planning on working with Datascience?\nSorry if this question seems easy to answer by searching, but I cannot find any information about this that isn't related to Datascience.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":76,"Q_Id":52413791,"Users Score":-1,"Answer":"Off-hand, I'd say no. Anaconda simply clumps many (not all) of the standard data science-y packages with Python. If you go base Python, you get a much smaller install. Now one thing that is useful: conda. I find it's pretty good at managing package versions, which can be pretty problematic otherwise. But you can probably get by without it.","Q_Score":0,"Tags":"python-3.x,pip,anaconda","A_Id":52414168,"CreationDate":"2018-09-19T20:32:00.000","Title":"Should I use Anaconda on Ubuntu WSL for other reasons than datascience?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I am running Celery on (say) a bank of 50 machines all using a distributed RabbitMQ cluster.\nIf I have a task that is running and I know the task id, how in the world can Celery figure out which machine its running on to terminate it?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":52415048,"Users Score":0,"Answer":"I am not sure if you can actually do it, when you spawn a task you will have a worker, somewhere in you 50 boxes, that executes that and you technically have no control on it as it s a separate process and the only thing you can control is either the asyncResult or the amqp message on the queue.","Q_Score":0,"Tags":"python,rabbitmq,celery","A_Id":52451214,"CreationDate":"2018-09-19T22:34:00.000","Title":"Celery - how to stop running task when using distributed RabbitMQ backend?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want my flask APP to pull updates from a local txt file every 200ms, is it possible to do that?\nP.S. I've considered BackgroundScheduler() from apschedulerler, but the granularity of is 1s.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":610,"Q_Id":52415384,"Users Score":1,"Answer":"Couldn't you just start a loop in a thread that sleeps for 200 ms before the next iteration?","Q_Score":0,"Tags":"python,python-3.x,flask,apscheduler","A_Id":52419167,"CreationDate":"2018-09-19T23:16:00.000","Title":"how to run periodic task in high frequency in flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Suppose I have multiple mongodbs like mongodb_1, mongodb_2, mongodb_3 with same kind of data like employee details of different organizations.\nWhen user triggers GET request to get employee details from all the above 3 mongodbs whose designation is \"TechnicalLead\". then first we need to connect to mongodb_1 and search and then disconnect with mongodb_1 and connect to mongodb_2 and search and repeat the same for all dbs.\nCan any one suggest how can we achieve above using python EVE Rest api framework.\nBest Regards,\nNarendra","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":52418721,"Users Score":0,"Answer":"First of all, it is not a recommended way to run multiple instances (especially when the servers might be running at the same time) as it will lead to usage of the same config parameters like for example logpath and pidfilepath which in most cases is not what you want.\nSecondly for getting the data from multiple mongodb instances you have to create separate get requests for fetching the data. There are two methods of view for the model that can be used:\n\nquery individual databases for data, then assemble the results for viewing on the screen.\nQuery a central database that the two other databases continously update.","Q_Score":0,"Tags":"python,mongodb,eve","A_Id":52872010,"CreationDate":"2018-09-20T06:14:00.000","Title":"How to search for all existing mongodbs for single GET request","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've recently started working with python. In another topic, I read that someone had to create temporary files, has he had to create file (also in python).\nSo my question is, what is the interest of working with temp files ?\nTo me it would be, not to have too many (unneeded files, that can be removed later).\nIn my project, I have a main file\n\nmain.dat\n\nIn which I extract 2 blocks,\n\nmain_first_block.dat\nmain_second_block.dat\n\nAnd then I combine main_second_block.dat and main_second_block.dat\n\nfinal_file.dat\n\nSo it makes a total of 4 files.\nAnd at the end, I dont need main_first_block.dat and main_second_block.dat anymore.\nI only need to keep main_file.dat and final_file.dat\nSo my question is, should I create tmp files, or delete the unneeded files at the end of my script ?\nThanks guys for your enlightenment ;)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":80,"Q_Id":52418878,"Users Score":1,"Answer":"There is not really that much a difference in lines of code. \nYet, tmp files indicate that they are not made to stay. Therefore they bring more clarity to your code.\nWhen using tmp files make sure to avoid the mktemp()-function \nas it is highly vulnerable to attacks.\nHope I could help in some way.","Q_Score":0,"Tags":"python,temporary-files","A_Id":52419233,"CreationDate":"2018-09-20T06:25:00.000","Title":"python create temporary file, what is the interest?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script that calculates a few, quite small, NumPy arrays and I have a Java service on a separate machine that needs to use these arrays. \nThese arrays sometimes need to be recalculated and then used afterwards by the Java service. What is the best way to dump a NumPy array to the disk and load it in Java as float[][]? \nI know that I could use JSON to do this (Python script dumps the NumPy array to a JSON file and Java service recovers float[][] from this), but is there any other, \"preferred\" way?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":57,"Q_Id":52421822,"Users Score":1,"Answer":"Saving a file to disk to exchange the data between different applications sounds like a hacky approach to me. \nDepending on your structure and complexity, I would consider implementing a messaging queue (i.e. redis) or a document database (i.e. mongo or prefered alternative) with respective clients to do the data exchange between the apps.\nOn the data structure itself, I would choose json or csv for the task. If you need human readability or strict structure, json is your tool. If the data is meant only for the machine to read, csv takes less space to store the same amount of data.","Q_Score":0,"Tags":"java,python,arrays","A_Id":52422031,"CreationDate":"2018-09-20T09:29:00.000","Title":"Move array of doubles from Python to Java","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was doing a frame slicing from the OpenCV Library in Python, and I am successfully able to create frames from the video being tested on. \nI am doing it on a CCTV Camera installed at a parking entry gateway where the video plays 24x7, and at times the car is standing still for good number of minutes, leading to having consecutive frames of the same vehicle. \nMy question is how can I create a frame only when a new vehicle enters the parking lot?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":810,"Q_Id":52422060,"Users Score":0,"Answer":"Do you need to detect license plates, etc? Or just notice if something happens? For the latter, you could use a very simple approach. Take an average of say the frames of the last 30 seconds and subtract that from a current frame. If the mean absolute average of the delta image is above a threshold, that could be the change you are looking for.","Q_Score":0,"Tags":"python,opencv","A_Id":52422304,"CreationDate":"2018-09-20T09:40:00.000","Title":"Open CV to Capture Unique Objects from a Video","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a command line program which I'd like to keep running until I open it again, so basically a program which first checks if there's currently any already running instance of itself and kill it.\nI tried os.system('TASKKILL \/F \/IM program.exe') but it turned out to be stupid because it also kills itself.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1380,"Q_Id":52422865,"Users Score":1,"Answer":"The most reliable way to make sure there's only one instance of your application is to create a pid file in a known (fixed) location. This location will usually be in your application data folder or in the temporary directory. At startup, you should check if the pid file exists and if the pid contained there still exists and refers to your target process. If it exists, send a kill signal to it, then overwrite the file with your current pid before starting the rest of the application.\nFor extra safetiness, you may want to wait until the previous process have completely terminated. This can be done by either waiting\/polling to check if the process with that pid still exists, or by polling for the killed process to delete its own pid file. The latter may be necessary if process shutdown are very lengthy and you want to allow the current process to already start working while the old process is shutting down.","Q_Score":0,"Tags":"python,process,os.system,taskkill","A_Id":52423173,"CreationDate":"2018-09-20T10:22:00.000","Title":"How to make a program close it's currently running instance upon startup?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I deployed python app successfully but when I open the app it is showing me:\nApplication error\nAn error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command\nHeroku logs --tail\nhere is my heroku logs:\n\nservice= status=503 bytes= protocol=https\n  2018-09-20T10:05:18.000000+00:00 app[api]: Build succeeded\n  2018-09-20T10:19:34.769300+00:00 heroku[router]: at=error code=H14\n  desc=\"No web processes running\" method=GET path=\"\/\"\n  host=demoaap.herokuapp.com request_id=1ae\n  01895-963b-4211-9b30-d16de606c827 fwd=\"182.72.121.210\" dyno= connect=\n  service= s tatus=503 bytes= protocol=https\n\n\"heroku ps\"commands gives:\nNo dynos on demoaap (demoaap is my app name)\nmoreover i have tried Herokuommand( \" heroku ps:scale web=1\" ) in order to run dynos but not working\n.\nPlease help me out","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":558,"Q_Id":52423143,"Users Score":0,"Answer":"web: gunicorn --worker-class eventlet -w 1 app:app","Q_Score":0,"Tags":"python,heroku,procfile","A_Id":53710702,"CreationDate":"2018-09-20T10:35:00.000","Title":"Python Heroku app has 0 web dynos despite right Procfile and at right location","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I deployed python app successfully but when I open the app it is showing me:\nApplication error\nAn error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command\nHeroku logs --tail\nhere is my heroku logs:\n\nservice= status=503 bytes= protocol=https\n  2018-09-20T10:05:18.000000+00:00 app[api]: Build succeeded\n  2018-09-20T10:19:34.769300+00:00 heroku[router]: at=error code=H14\n  desc=\"No web processes running\" method=GET path=\"\/\"\n  host=demoaap.herokuapp.com request_id=1ae\n  01895-963b-4211-9b30-d16de606c827 fwd=\"182.72.121.210\" dyno= connect=\n  service= s tatus=503 bytes= protocol=https\n\n\"heroku ps\"commands gives:\nNo dynos on demoaap (demoaap is my app name)\nmoreover i have tried Herokuommand( \" heroku ps:scale web=1\" ) in order to run dynos but not working\n.\nPlease help me out","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":558,"Q_Id":52423143,"Users Score":1,"Answer":"If you used a Procfile in deployment, make sure it does not have an extension such as .txt.  If it does, you might try:\n\nDeleting that Procfile.txt.\nCreating a new Procfile without the extension.\nPushing the new files to Heroku.","Q_Score":0,"Tags":"python,heroku,procfile","A_Id":56436037,"CreationDate":"2018-09-20T10:35:00.000","Title":"Python Heroku app has 0 web dynos despite right Procfile and at right location","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"How to convert following dates in excel in float values by Python.\nProblem Statement: I have a dates data in which dates are entered but users and users used different cell format to enter dates.For example some used cell format asdd-yy-yyyy and some used mm-dd-yyyy in excel cell while entering the data  ( in fact user used different excel format for dates in their files).When I am trying to consolidate dates then find that dates are  in different cell formats randomly. In excel I can copy dates column and paste all in a separate column as a value only,It gives me integer value which is same regardless and format used in cell. And later applied a single format to all value and gets all my dates in same format.\nBut , I want to make a script in Python in which first: all different cell formats for dates are converted to float value (like i do in excel) then I will convert all dates back to standard format i.e dd\/mm\/yyyy.\nFormet  Dates   format  Date in numeric value   Reformatted in excle as  dd-mm-yyyy\nformat 1    30-08-2018  dd-mm-yyyy  43342.51551 30-08-2018\nformat 2    08-30-2018  mm-dd-yyyy  43342.51551 30-08-2018","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":831,"Q_Id":52423873,"Users Score":0,"Answer":"No script can tell you, if 03-05-2014 means 3rd May or 5th March. It's not God and can't do, what you're unable to do.\nOnly clues:\n\nIf some value consists of four digits, it's the year.\nIf one value is higher than twelve, you can say that this value must be the day (or the year)\nIf there are several date values by the same user, you may presume that he or she kept consistlently one format and deduce the format from another field.","Q_Score":0,"Tags":"python","A_Id":52424438,"CreationDate":"2018-09-20T11:15:00.000","Title":"Python date Time for Excel","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My system as Python 2.7 and 3.7 installed. I have attempted to install the EB CLI connected to Python 3 but the CLI tool seems only to connect to the 2.7 installation.\nAttempt 1\nWhen I run $ brew install awsebcli I get a version of EB that seems to be associated with 2.7, which is incorrect:\n$ eb --version\nEB CLI 3.14.4 (Python 2.7.1)\nAttempt 2\nWhen I attempt to install EB CLI using pip, the installation appears fine but I am unable to access EB. \n$eb --version\n-bash: eb: command not found\nThe docs suggest this might be to do with not having the path in the .bash_profile I've set up, however I have added the following to my .bash_profile and reloaded the .bash_profile:\n# Adding path to Elastic Beanstalk CLI\nexport Path=\/Library\/Python\/3.7\/bin:$PATH","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1260,"Q_Id":52427511,"Users Score":0,"Answer":"I solved this by setting the PATH variable correctly - however the solution above is better (fitting with 12Factor App design)","Q_Score":1,"Tags":"python,amazon-web-services,amazon-elastic-beanstalk","A_Id":52428063,"CreationDate":"2018-09-20T14:29:00.000","Title":"EB CLI installing with Python 2 rather than Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm studying Python for 4\/5 months and this is my third project built from scratch, but im not able to solve this problem on my own.\nThis script downloads 1 image for each url given.\nIm not able to find a solution on how to implement Thread Pool Executor or async in this script. I cannot figure out how to link the url with the image number to the save image part. \nI build a dict of all the urls that i need to download but how do I actually save the image with the correct name?\nAny other advise?\nPS. The urls present at the moment are only fake one.\nSynchronous version:\n\n\n    import requests\n    import argparse\n    import re\n    import os\n    import logging\n\n    from bs4 import BeautifulSoup\n\n\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"-n\", \"--num\", help=\"Book number\", type=int, required=True) \n    parser.add_argument(\"-p\", dest=r\"path_name\", default=r\"F:\\Users\\123\", help=\"Save to dir\", )\n    args = parser.parse_args()\n\n\n\n    logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',\n                        level=logging.ERROR)\n    logger = logging.getLogger(__name__)  \n\n\n    def get_parser(url_c):  \n        url = f'https:\/\/test.net\/g\/{url_c}\/1'\n        logger.info(f'Main url: {url_c}')\n        responce = requests.get(url, timeout=5) # timeout will raise an exeption\n        if responce.status_code == 200:\n            page = requests.get(url, timeout=5).content\n            soup = BeautifulSoup(page, 'html.parser')\n            return soup\n        else:\n            responce.raise_for_status()\n\n\n    def get_locators(soup): # take get_parser\n        # Extract first\/last page num\n        first = int(soup.select_one('span.current').string)\n        logger.info(f'First page: {first}')\n        last = int(soup.select_one('span.num-pages').string) + 1\n\n        # Extract img_code and extension\n        link = soup.find('img', {'class': 'fit-horizontal'}).attrs[\"src\"]\n        logger.info(f'Locator code: {link}')\n        code = re.search('galleries.([0-9]+)\\\/.\\.(\\w{3})', link)\n        book_code = code.group(1)   # internal code \n        extension = code.group(2)   # png or jpg\n\n        # extract Dir book name\n        pattern = re.compile('pretty\":\"(.*)\"')\n        found = soup.find('script', text=pattern)\n        string = pattern.search(found.text).group(1)\n        dir_name = string.split('\"')[0]\n        logger.info(f'Dir name: {dir_name}')\n\n        logger.info(f'Hidden code: {book_code}')\n        print(f'Extension: {extension}')\n        print(f'Tot pages: {last}')\n        print(f'')\n\n        return {'first_p': first, \n                'last_p': last, \n                'book_code': book_code, \n                'ext': extension, \n                'dir': dir_name\n                }\n\n\n    def setup_download_dir(path, dir):  # (args.path_name, locator['dir'])\n        # Make folder if it not exist\n        filepath = os.path.join(f'{path}\\{dir}')\n        if not os.path.exists(filepath):\n            try:\n                os.makedirs(filepath)\n                print(f'Directory created at: {filepath}')\n            except OSError as err:\n                print(f\"Can't create {filepath}: {err}\")    \n         return filepath \n\n\n    def main(locator, filepath):\n        for image_n in range(locator['first_p'], locator['last_p']):\n            url = f\"https:\/\/i.test.net\/galleries\/{locator['book_code']}\/{image_n}.{locator['ext']}\"\n            logger.info(f'Url Img: {url}')\n            responce = requests.get(url, timeout=3)\n            if responce.status_code == 200:\n                img_data = requests.get(url, timeout=3).content \n            else:    \n                responce.raise_for_status()    # raise exepetion \n\n            with open((os.path.join(filepath, f\"{image_n}.{locator['ext']}\")), 'wb') as handler:\n                handler.write(img_data) # write image\n                print(f'Img {image_n} - DONE')\n\n\n    if __name__ == '__main__':\n        try:\n            locator = get_locators(get_parser(args.num))    # args.num ex. 241461\n            main(locator, setup_download_dir(args.path_name, locator['dir'])) \n        except KeyboardInterrupt:\n            print(f'Program aborted...' + '\\n')\n\n\nUrls list:\n\n\n    def img_links(locator):\n        image_url = []\n        for num in range(locator['first_p'], locator['last_p']):\n            url = f\"https:\/\/i.test.net\/galleries\/{locator['book_code']}\/{num}.{locator['ext']}\"\n            image_url.append(url)\n        logger.info(f'Url List: {image_url}')       \n        return image_url","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":353,"Q_Id":52430038,"Users Score":0,"Answer":"I found the solution in the book fluent python. Here the snippet:\n\n    def download_many(cc_list, base_url, verbose, concur_req):\n        counter = collections.Counter()\n        with futures.ThreadPoolExecutor(max_workers=concur_req) as executor:\n            to_do_map = {}\n            for cc in sorted(cc_list):\n                future = executor.submit(download_one, cc, base_url, verbose)\n                to_do_map[future] = cc\n            done_iter = futures.as_completed(to_do_map)\n            if not verbose:\n                done_iter = tqdm.tqdm(done_iter, total=len(cc_list))\n            for future in done_iter:\n                try:\n                    res = future.result()\n                except requests.exceptions.HTTPError as exc:\n                    error_msg = 'HTTP {res.status_code} - {res.reason}'\n                    error_msg = error_msg.format(res=exc.response)\n                except requests.exceptions.ConnectionError as exc:\n                    error_msg = 'Connection error'\n                else:\n                    error_msg = ''\n                    status = res.status\n                if error_msg:\n                    status = HTTPStatus.error\n                counter[status] += 1\n                if verbose and error_msg:\n                    cc = to_do_map[future]\n                    print('*** Error for {}: {}'.format(cc, error_msg))\n        return counter","Q_Score":2,"Tags":"python,python-3.x,asynchronous,python-multithreading,imagedownload","A_Id":52735044,"CreationDate":"2018-09-20T17:05:00.000","Title":"python asyncronous images download (multiple urls)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Suppose I do some data analysis within a particular folder. Some Juypter Notebooks some .py files. Is it possible (and does it makes sense) to define the imports globally in one file ? e.g. import numpy as np and now I can use np.whatever in every file ? Maybe this is a stupid question but a colleague of mine who is using R, asked me this question and I never thought of that idea.\nEDIT: For the downvoters: I really tried to find that out my searching on the net but could not find any information. I thought that this would not be a good idea but who knows.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":52432042,"Users Score":0,"Answer":"While it may not be a 'good' idea in general, it could be a good idea for you. If you create a script in a folder with your imports and import that as a module elsewhere, you can import the other modules with it. The syntax would be from my_convenience_imports import *","Q_Score":0,"Tags":"python","A_Id":52432309,"CreationDate":"2018-09-20T19:30:00.000","Title":"define python imports only once for all files in the same folder, is it possible?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to comprehend the idea of optimize.minimize. However, I got stuck with a small problem. I do not understand that why we need an initial guess (x0) while using the optimize.minimize? Can anyone help me out??\nThank you so much.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":191,"Q_Id":52434089,"Users Score":1,"Answer":"Numerical optimisation basically says: here's a function f. \nLet's say we're trying to find a minimum. Let's add a bit to our starting variable. What is f(x + a)? Does it go down? And let's add a bit more? Is f(x + a + b) smaller than that? Eventually, after trying a ton of different inputs, going up and down, you'll have a good idea of how the function behaves and where it is minimised.\nTo do this, you need to start someplace so that you can add or subtract from the x part of f(x).","Q_Score":0,"Tags":"python,optimization,minimize","A_Id":52434142,"CreationDate":"2018-09-20T22:15:00.000","Title":"Optimize.minimize initial guess","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In numpy, if a is an ndarray, then, something like \nnp.sin(a) takes sin of all the entries of ndarray. What if I need to define my own function (for a stupid example, f(x) = sin(x) if x<1 else cos(x)) with broadcasting behavior?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":52436499,"Users Score":2,"Answer":"You could define your own function f = lambda x: sin(x) if x<1 else cos(x) and then use numpy's builtin vectorizer f_broadcasting = np.vectorize(f).\nThis doesn't offer any speed improvements (and the additional overhead can slow down small problems), but it gives you the desired broadcasting behavior.","Q_Score":1,"Tags":"python,python-3.x,numpy","A_Id":52436519,"CreationDate":"2018-09-21T04:11:00.000","Title":"numpy Broadcasting for user functions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For some integer K around 100, I have 2 * K (n, n) arrays: X_1, ..., X_K and Y_1, ..., Y_K.\nI would like to perform K least squares simultaneously, i.e. find the n by n matrix A minimizing the sum of squares over k: \\sum_k norm(Y_k - A.dot(X_k), ord='fro') ** 2 (A must not depend on k).\nI am looking for an easy way to do this with numpy or scipy.\nI know the function I want to minimize is a quadratic form in A so I could do it by hand, but I'm looking for an off-the-shelf way of doing it. Is there one?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":834,"Q_Id":52439564,"Users Score":0,"Answer":"In fact the answer was simple, I just needed to create bigger matrices Y and X by horizontally stacking the Y_k (to create Y) and the  X_k (to create X). Then I can just solve a regular 2d least squares problem: minimize norm(Y - A.dot(X))","Q_Score":0,"Tags":"python,numpy,scipy,linear-algebra,least-squares","A_Id":52504486,"CreationDate":"2018-09-21T08:22:00.000","Title":"Solve 3D least squares in numpy\/scipy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a virtual machine in Google Compute us-east-1c region with the following specifications: n1-standard-2 (2 vCPU, 7.5 GB memory), 1 NVIDIA Tesla K80 GPU, boot disk: Deep Learning Image Tensorflow 1.10.1 m7 CUDA 9.2.\nWhen I first logged in to the machine, it asked me to install the drivers and I agreed.  It gave me some warning messages which I did not save.\nI tried to train a model written entirely in Keras with TF backend.\nHowever, judging by the speed and CPU utilization (both similar to what it does on my laptop, slow and using almost all CPU available), GPU is not used.\nThis is also confirmed by the TF output:\n\n2018-09-21 08:39:48.602158: I\n  tensorflow\/core\/platform\/cpu_feature_guard.cc:141] Your CPU supports\n  instructions that this TensorFlow binary was not compiled to use: AVX2\n  FMA\n\nIt did not mention any GPU.  (Thanks @Matias Valdenegro !)\nIn my model I did not relate to GPU with an understanding that TF takes care of it automatically.\nAny ideas?\nMany thanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":985,"Q_Id":52440606,"Users Score":0,"Answer":"The problem was with my use of requirements.txt.\nI created it on my laptop with pip freeze, uploaded it to the VM and used pip to install all the requirements.\nIn this way my requirements.txt included tensorflow.  As the result, pip installed the repository version that did not include GPU support, replacing pre-installed tensorflow with GPU support.\nI was able to figure this out by repeating my steps and checking GPU per second suggestion of @Shintlor (thanks!) along the way.\nI have created another VM and did not use requirements.txt; rather, I installed all the missing packages one by one.  After that my model trains now 20 times faster than on my laptop.","Q_Score":0,"Tags":"python,tensorflow,keras,google-compute-engine","A_Id":52460262,"CreationDate":"2018-09-21T09:24:00.000","Title":"NVIDIA K-80 GPU does not run with Deep Learning Image Tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can we write user-defined functions in AWS-Glue script using PySpark (Python) on either Dynamic-frame or Data-frame?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2850,"Q_Id":52440622,"Users Score":1,"Answer":"dynamicframe doesn't support a UDF exactly the way the Dataframe API supports it. The best you will get is the MAP.apply.","Q_Score":1,"Tags":"python,pyspark,aws-glue","A_Id":70085377,"CreationDate":"2018-09-21T09:26:00.000","Title":"How to write user-defined function in AWS-Glue Script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When running keras model inside Jupyter notebook with \"verbose=1\" option, I started getting not single line progress status updates as before, but a flood of status lines updated at batch. See attached picture.  Restarting jupyter or the browser is not helping. \nJupyter notebook server is: 5.6.0, keras is 2.2.2, Python is Python 3.6.5\nPlease help. \ncell content:\nhistory = model.fit(x=train_df_scaled, y=train_labels, batch_size=BATCH_SIZE, epochs=EPOCHS, verbose=1, validation_data=(validation_df_scaled, validation_labels), shuffle=True)\noutput flood example: (it is thousands of lines like this)\nloss: 217.5794 - mean_absolute_error: 11.166 - ETA: 32:42 - loss: 216.9500 - mean_absolute_error: 11.165 - ETA: 32:21 - loss: 216.6378 - mean_absolute_error: 11.164 - ETA: 32:00 - loss: 216.0345 - mean_absolute_error: 11.164 - ETA: 31:41 - loss: 215.6621 - mean_absolute_error: 11.166 - ETA: 31:21 - loss: 215.4639 - mean_absolute_error: 11.171 - ETA: 31:02 - loss: 215.1654 - mean_absolute_error: 11.173 - ETA: 30:44 - loss: 214.6583 - mean_absolute_error: 11.169 - ETA: 30:27 - loss: 213.8844 - mean_absolute_error: 11.164 - ETA: 30:10 - loss: 213.3308 - mean_absolute_error: 11.163 - ETA: 29:54 - loss: 213.1179 - mean_absolute_error: 11.167 - ETA: 29:37 - loss: 212.8138 - mean_absolute_error: 11.169 - ETA: 29:25 - loss: 212.7157 - mean_absolute_error: 11.174 - ETA: 29:11 - loss: 212.5421 - mean_absolute_error: 11.177 - ETA: 28:56 - loss: 212.1867 - mean_absolute_error: 11.178 - ETA: 28:42 - loss: 211.8032 - mean_absolute_error: 11.180 - ETA: 28:28 - loss: 211.4079 - mean_absolute_error: 11.179 - ETA: 28:15 - loss: 211.2733 - mean_absolute_error: 11.182 - ETA: 28:02 - loss: 210.8588 - mean_absolute_error: 11.179 - ETA: 27:50 - loss: 210.4498 - mean_absolute_error: 11.178 - ETA: 27:37 - loss: 209.9327 - mean_absolute_error: 11.176 - ETA: 27:","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":2733,"Q_Id":52443200,"Users Score":1,"Answer":"verbose=2 should be used for interactive outputs.","Q_Score":7,"Tags":"python,keras,jupyter-notebook,jupyter,tqdm","A_Id":52443366,"CreationDate":"2018-09-21T11:53:00.000","Title":"Keras floods Jupyter cell output during fit (verbose=1)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When running keras model inside Jupyter notebook with \"verbose=1\" option, I started getting not single line progress status updates as before, but a flood of status lines updated at batch. See attached picture.  Restarting jupyter or the browser is not helping. \nJupyter notebook server is: 5.6.0, keras is 2.2.2, Python is Python 3.6.5\nPlease help. \ncell content:\nhistory = model.fit(x=train_df_scaled, y=train_labels, batch_size=BATCH_SIZE, epochs=EPOCHS, verbose=1, validation_data=(validation_df_scaled, validation_labels), shuffle=True)\noutput flood example: (it is thousands of lines like this)\nloss: 217.5794 - mean_absolute_error: 11.166 - ETA: 32:42 - loss: 216.9500 - mean_absolute_error: 11.165 - ETA: 32:21 - loss: 216.6378 - mean_absolute_error: 11.164 - ETA: 32:00 - loss: 216.0345 - mean_absolute_error: 11.164 - ETA: 31:41 - loss: 215.6621 - mean_absolute_error: 11.166 - ETA: 31:21 - loss: 215.4639 - mean_absolute_error: 11.171 - ETA: 31:02 - loss: 215.1654 - mean_absolute_error: 11.173 - ETA: 30:44 - loss: 214.6583 - mean_absolute_error: 11.169 - ETA: 30:27 - loss: 213.8844 - mean_absolute_error: 11.164 - ETA: 30:10 - loss: 213.3308 - mean_absolute_error: 11.163 - ETA: 29:54 - loss: 213.1179 - mean_absolute_error: 11.167 - ETA: 29:37 - loss: 212.8138 - mean_absolute_error: 11.169 - ETA: 29:25 - loss: 212.7157 - mean_absolute_error: 11.174 - ETA: 29:11 - loss: 212.5421 - mean_absolute_error: 11.177 - ETA: 28:56 - loss: 212.1867 - mean_absolute_error: 11.178 - ETA: 28:42 - loss: 211.8032 - mean_absolute_error: 11.180 - ETA: 28:28 - loss: 211.4079 - mean_absolute_error: 11.179 - ETA: 28:15 - loss: 211.2733 - mean_absolute_error: 11.182 - ETA: 28:02 - loss: 210.8588 - mean_absolute_error: 11.179 - ETA: 27:50 - loss: 210.4498 - mean_absolute_error: 11.178 - ETA: 27:37 - loss: 209.9327 - mean_absolute_error: 11.176 - ETA: 27:","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":2733,"Q_Id":52443200,"Users Score":1,"Answer":"Two things I would recommend:\n\nTry restarting Jupyter Notebook server. \nTry different browser other\nthan what you're using; perhaps your browser got some update and it's\nbreaking stuff! (usually, chrome is bad with notebooks!)","Q_Score":7,"Tags":"python,keras,jupyter-notebook,jupyter,tqdm","A_Id":52445923,"CreationDate":"2018-09-21T11:53:00.000","Title":"Keras floods Jupyter cell output during fit (verbose=1)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When running keras model inside Jupyter notebook with \"verbose=1\" option, I started getting not single line progress status updates as before, but a flood of status lines updated at batch. See attached picture.  Restarting jupyter or the browser is not helping. \nJupyter notebook server is: 5.6.0, keras is 2.2.2, Python is Python 3.6.5\nPlease help. \ncell content:\nhistory = model.fit(x=train_df_scaled, y=train_labels, batch_size=BATCH_SIZE, epochs=EPOCHS, verbose=1, validation_data=(validation_df_scaled, validation_labels), shuffle=True)\noutput flood example: (it is thousands of lines like this)\nloss: 217.5794 - mean_absolute_error: 11.166 - ETA: 32:42 - loss: 216.9500 - mean_absolute_error: 11.165 - ETA: 32:21 - loss: 216.6378 - mean_absolute_error: 11.164 - ETA: 32:00 - loss: 216.0345 - mean_absolute_error: 11.164 - ETA: 31:41 - loss: 215.6621 - mean_absolute_error: 11.166 - ETA: 31:21 - loss: 215.4639 - mean_absolute_error: 11.171 - ETA: 31:02 - loss: 215.1654 - mean_absolute_error: 11.173 - ETA: 30:44 - loss: 214.6583 - mean_absolute_error: 11.169 - ETA: 30:27 - loss: 213.8844 - mean_absolute_error: 11.164 - ETA: 30:10 - loss: 213.3308 - mean_absolute_error: 11.163 - ETA: 29:54 - loss: 213.1179 - mean_absolute_error: 11.167 - ETA: 29:37 - loss: 212.8138 - mean_absolute_error: 11.169 - ETA: 29:25 - loss: 212.7157 - mean_absolute_error: 11.174 - ETA: 29:11 - loss: 212.5421 - mean_absolute_error: 11.177 - ETA: 28:56 - loss: 212.1867 - mean_absolute_error: 11.178 - ETA: 28:42 - loss: 211.8032 - mean_absolute_error: 11.180 - ETA: 28:28 - loss: 211.4079 - mean_absolute_error: 11.179 - ETA: 28:15 - loss: 211.2733 - mean_absolute_error: 11.182 - ETA: 28:02 - loss: 210.8588 - mean_absolute_error: 11.179 - ETA: 27:50 - loss: 210.4498 - mean_absolute_error: 11.178 - ETA: 27:37 - loss: 209.9327 - mean_absolute_error: 11.176 - ETA: 27:","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2733,"Q_Id":52443200,"Users Score":4,"Answer":"After a few tests I found that the error is related to tqdm import. Tqdm was used in a piece of code which was later rewritten withoout it. Even though I was not using tqdm in this notebook, just having it imported affected the keras output.\nTo fix it I just commented out this line:\nfrom tqdm import tqdm\nand everything went fine, with nice keras progress bars. Not sure how exactly it conflicted with keras though...","Q_Score":7,"Tags":"python,keras,jupyter-notebook,jupyter,tqdm","A_Id":52505253,"CreationDate":"2018-09-21T11:53:00.000","Title":"Keras floods Jupyter cell output during fit (verbose=1)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way on Jupyter notebook to run the code between two specific cells? For instance, suppose that I have 100 cells and I want to run only cells from 35 to 60. I don't want to run everything again from 1 to 60 because, for instance, the cells from 1 to 34 might require a long time to execute.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1022,"Q_Id":52444456,"Users Score":3,"Answer":"You can use shift+K  to select the cells (upward direction)\/ shift+J (downward direction) and then Ctrl+Enter to execute","Q_Score":3,"Tags":"python,jupyter-notebook","A_Id":52444646,"CreationDate":"2018-09-21T13:06:00.000","Title":"Jupyter notebook run all code between two cells","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running pylint in an environment where certain import libraries are not available and are 3rd party. As a result, pylint generates an error class wrong-import-order C0411 for these imports. \nIs there a way to instruct which should be considered 3rd party?\n\nPylint 2.1.1 \nPython 3.6.3","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":839,"Q_Id":52445342,"Users Score":5,"Answer":"Yes, that would be known-third-party, which you can set under [IMPORTS]:\n# Force import order to recognize a module as part of a third party library.\nknown-third-party=your modules","Q_Score":7,"Tags":"python-3.x,pylint","A_Id":52468110,"CreationDate":"2018-09-21T13:57:00.000","Title":"Is there a way to instruct Pylint which libraries should be considered 3rd party?","Data 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 and playing with the profiler it has built in. I've keyed in on some areas where my code can be optimized but I was wondering if there was a way to step through the code and see how long each line took to execute as I stepped through without having to rerun all my code in the profiler.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":405,"Q_Id":52447365,"Users Score":0,"Answer":"I think the closes you could do is put a breakpoint\nthen open up the debugger and enter console mode\nand execute the statement as started=time.time();my_function();print(\"Took %0.2fs\"%(time.time()-started))","Q_Score":0,"Tags":"python,python-3.x,optimization,time,pycharm","A_Id":52447591,"CreationDate":"2018-09-21T15:58:00.000","Title":"How to time a specific function of code block in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a RESTful application in Python. I'm now trying to know what kind of server I should use to deploy the application. Currently I'm looking at Gunicorn, which is a WSGI server. But I often hear about this popular web-server Apache as well. \nSo my questions are:\n\nWhat is the difference between the WSGI and web-server?\nIf I don't need a public domain (i.e. my application only needs to\nrun within the private network), should I use WSGI or a web-server?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":698,"Q_Id":52448861,"Users Score":-1,"Answer":"WSGI is the standard interface for running Python web server applications. Python frameworks already implement this standard so you don't need to worry about this. There is no point in using apache if your application is written in Python.","Q_Score":0,"Tags":"python,apache,webserver,gunicorn,wsgi","A_Id":52464604,"CreationDate":"2018-09-21T17:54:00.000","Title":"What is the difference between a WSGI server and a Web server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there a way I can train an autoencoder model using a pre-trained model like ResNet?\nI'm trying to train an autoencoder model with input as an image and output as a masked version of that image.\nIs it possible to use weights from a pretrained model here?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1464,"Q_Id":52454090,"Users Score":0,"Answer":"From what I know, there is no proven method to do this. I'd train the autoencoder from scratch. \nIn theory, if you find a pre-trained CNN which does not use max pooling, you can use those weights and architecture for the encoder stage in your autoencoder. You can also extract features from a pre-trained model and concatenate\/merge them to your autoencoder. But the value add is not clear, and the architecture might become overly complex.","Q_Score":1,"Tags":"python-3.x,keras,computer-vision,autoencoder,resnet","A_Id":52463724,"CreationDate":"2018-09-22T06:21:00.000","Title":"Autoencoder with Transfer Learning?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Him I am trying to set up my first django project. I have never done Django before so I don't know anything about it. I am trying to follow the official Django tutorial page, it tells me to open views.py. I can't find it anywhere in my \"mysite\" folder. In it, I have manage.py , db.sqlite3, __init__.py, settings.py, urls.py and wsgi.py along with the pycache folder, but no signs of views.py. Can anyone help me?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1417,"Q_Id":52455894,"Users Score":2,"Answer":"Running this command in console django-admin startproject myfirstproject will create a new django project for you, which will have another sub-folder named same as your project name. By default on creating a new project, the views.py file isn't created you have to create it manually in your project sub-folder. \nTo create a new app, Run django-admin startapp myapp which will create a new sub-folder under your parent directory which will have views.py where you can write your own custom views for your HTML templates","Q_Score":0,"Tags":"python,django,python-3.x,django-views,python-3.7","A_Id":52455984,"CreationDate":"2018-09-22T10:44:00.000","Title":"Where is \"views.py\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"so if I have two labels \"dogs\" and \"cats\" and I want to create multi classification neural network. \nnow if I provided a new random image which is not a dog or a cat, is there a way I can teach the classifier to tell me that this image is not a dog or a cat instead of saying how much percent it maybe cat or dog?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":52459748,"Users Score":1,"Answer":"The best way to accomplish this is to create a new class in addition to dog and cat to handle images you have no interest in. So now, your labels would be [\"dogs\", \"cats\", \"other\"].\nIn your current architecture, your model is forced to predict a random image as either a dog or cat as those are the only two options it has. Adding a new class to deal with other images is generally the easiest way to make your classifier more robust to incorrect predictions.","Q_Score":0,"Tags":"python,neural-network,keras,multilabel-classification","A_Id":52461491,"CreationDate":"2018-09-22T18:39:00.000","Title":"image multi classification with keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on an event driven flow architecture and I'd like to have as many independent applications consuming from the same topic independently (not in the same consumer group). To do that I'd create one consumer group for each new application but I'd like to do that automatically through a system. Is that possible and is that the best approach?\nBy the way we are coding with Python.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":223,"Q_Id":52460123,"Users Score":1,"Answer":"All you need to do is change the value of the group.id property while creating the consumer. You can do this either manually in each application or you can generate a random string using the UUID generator in Python","Q_Score":1,"Tags":"python,events,apache-kafka,kafka-consumer-api,consumer","A_Id":52484941,"CreationDate":"2018-09-22T19:25:00.000","Title":"How to add new Application consumers on the fly in Kafka","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a python pandas dataframe on my local machine, and have access to a remote mongodb server that has additional data that I can query via pymongo.\nIf my local dataframe is large, say 40k rows with 3 columns in each row, what's the most efficient way to check for the intersection of my local dataframe's features and a remote collection containing millions of documents?\nI'm looking for general advice here.  I thought I could just take a distinct list of values from each of the 3 features, and use each of these in an $or find statement, but if I have 90k distinct values for one of the 3 features it seems like a bad idea.\nSo any opinion would be very welcome.  I don't have access to insert my local dataframe into the remote server, I only have select\/find access.\nthanks very much!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":52460327,"Users Score":1,"Answer":"As you already explained that you won't be able to insert data. So only thing is possible is first take the unique values to a list.df['column_name'].unique(). Then you can use the $in operator in .find() method and pass your list as a parameter. If it takes time or it is too much. Then break your list in equal chunks, I mean list of list [[id1, id2, id3], [id4, id5, id6] ... ] and do a for loop for sub-list in list: db.xyz.find({'key':{'$in': sublist}}, {'_id': 1}) and use the sub list as parameter in $in operator. Then for each iteration if the value exist in the db it will return the _id and we can easily store that in a empty list and append it and we will be able to get all the id's in such cases where the value exist in the collection.\nSo it's just the way I would do. Not necessarily the best possible.","Q_Score":0,"Tags":"python,mongodb,pandas,pymongo","A_Id":52462006,"CreationDate":"2018-09-22T19:51:00.000","Title":"Efficient Intersection of pandas dataframe with remote mongodb?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pretty simple setup. I'm running Pycharm 2018.2.3 and using docker compose to spin up 3 containers.\n\nMy Django application\nNGINX to serve static\nPostgres DB\n\nI've configured the remote interpreter for debugging the container, and break point work just fine in most cases, at least when I hit my API endpoints or some other action to the django application.\nWhat does not work, is when I run one of my manage custom manage.py custom commands. I've tried this 2 ways so far.\n\nI setup another debug configuration in PyCharm to execute the command. This results in another container spinning up (in place of the original. Running the command, without breaking on any line breaks. Then the whole container shuts down.\nI've logged into the container, run the manage.py command directly via the command line, and it execute in the container, but again no breakpoints.\n\nThe documentation seems to work in the normal case, but I can't find any help for debugging these commands in the container.\nThanks for any help or tips.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1342,"Q_Id":52462866,"Users Score":1,"Answer":"Just an update in case anybody comes across a similar problem. My personal solution was to not use the manage.py commands, but instead make these same commands available via an http call.\nI found that it was easier (and often even more useful) to simply have an endpoint like myserver.com\/api\/do-admin-function and restrict that to administrative access.\nWhen I put a breakpoint in my code, even running in the container, it breaks just fine as expected and allows me to debug the way I'd like","Q_Score":5,"Tags":"python,django,docker,pycharm,remote-debugging","A_Id":54485770,"CreationDate":"2018-09-23T03:59:00.000","Title":"Pycharm debugging manage.py commands in docker compose","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"How are one to many relationships with multiple join keys represented in featuretools? Is there some integrated approach - or should the join keys manually be concatenated into a single column?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":208,"Q_Id":52463225,"Users Score":2,"Answer":"The recommended approach is to concatenate the keys into a single column.\nThis is typically done as a preprocessing step in Pandas before the DataFrame is loaded into Featuretools.","Q_Score":0,"Tags":"python,feature-extraction,feature-engineering,featuretools","A_Id":52463257,"CreationDate":"2018-09-23T05:19:00.000","Title":"Featuretools handling of multiple join keys","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So this is more or less a theoretical question. I have a single core machine which is supposedly powerful but nevertheless only one core. Now I have two choices to make :\n\nMultithreading: As far as my knowledge is concerned I cannot make use of multiple cores in my machines even if I had them because of GIL. Hence in this situation, it does not make any difference.\nMultiprocessing: This is where I have a doubt. Can I do multiprocessing on a single core machine? Or everytime I have to check the cores available in my machine and then run exactly the same or less number of processes?\n\nCan someone please guide me on the relation between multiprocessing and cores in a machine. \nI know this is a theoretical question but my concepts are not very clear on this.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":6893,"Q_Id":52465317,"Users Score":2,"Answer":"You CAN use both multithreading and multiprocessing in single core systems.\nThe GIL limits the usefulness of multithreading in pure Python for computation-bound tasks, no matter your underlying architecture. For I\/O-bound tasks, they do work perfectly fine. Had they had not any use, they would not have been implemented in the first place, probably.\nFor pure Python software, multiprocessing is always a safer choice when it comes to parallel computing. Of course, multiple processes are more expensive than multiple threads (since processes do not share memory, contrarily to threads; also, processes come with slightly higher overhead compared to threads).\nFor single processor machines, however, multiprocessing (and multithreading) buys you little to no extra speed for computationally heavy tasks, and they should actually even slow you down a bit. But, if the OS supports them (which is pretty common for desktop, workstation, clusters, etc, but may not be common for embedded systems), they allow you to effectively run simultaneously multiple I\/O-bound programs.\nLong story short, it depends a bit on what you are doing...","Q_Score":18,"Tags":"python,multiprocessing,python-multiprocessing","A_Id":52465411,"CreationDate":"2018-09-23T10:43:00.000","Title":"Can I run multiprocessing Python programs on a single core machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"From long time i am having migration issues. Each time i am droping my postgres database and creating a new When i add new 3\/4 table or a relation or Circular migration happens. Or most of the time some unwanted issue comes in migration. \nBut it's okay as long i am in development phase. But very soon when it will be on production i can't do that. Removing database each time.\nI have heard a lot about django-south. But the issue is it's not updated from long time i think last time it was updated December,14(according to it's bitbucket repo). \nNow is it a good choice for a project of 2018 ? Or any other 3rd party i can use. I just don't want to take rick writing raw sql each time in production as i am not too good on it as well. So i want to depend on django 100% in migration. \nPlease share you ideas on the migration issue\nThanks in advance :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":76,"Q_Id":52465655,"Users Score":3,"Answer":"South was the predecessor of django migrate. It became a part of Django core, so no need to install it.\nIf you are having migration issues, you should learn how to fix them, instead of just re-installing. You can edit every single migration file. They are just regular .py files with regular Django functions that do the necessary changes to your tables.\nRead the error message, try to understand what went wrong, and fix the migration file that caused the error. They are numbered and located in projectfolder\/appfolder\/migrations\/.\nI am using migrate all the time and never had an issue that wasn't fixable.","Q_Score":1,"Tags":"python,django,django-models,django-south,django-migrations","A_Id":52465934,"CreationDate":"2018-09-23T11:29:00.000","Title":"Is it safe to use Django south for handling migration on big project","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Let's say I have a list of 887123, 123, 128821, 9, 233, 9190902. I want to put those strings on screen using pygame (line drawing), and I want to do so proportionally, so that they fit the screen. If the screen is 1280x720, how do I scale the numbers down so that they keep their proportions to each other but fit the screen? \nI did try with techniques such as dividing every number by two until they are all smaller than 720, but that is skewed. Is there an algorithm for this sort of mathematical scaling?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":29,"Q_Id":52465795,"Users Score":1,"Answer":"I used this algorithm: x = (x \/ (maximum value)) * (720 - 1)","Q_Score":0,"Tags":"python,math,pygame","A_Id":52466333,"CreationDate":"2018-09-23T11:46:00.000","Title":"How to put a list of arbitrary integers on screen (from lowest to highest) in pygame proportionally?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I upload my first Django-project into DigitalOcean. After command python manage.py loaddata initial_data.json, I have received this message:\n\ndjango.db.utils.IntegrityError: Problem installing fixture\n  '\/webapps\/django_shop\/shop\/initial_data.json': Could not load\n  contenttypes.ContentType(pk=3): duplicate key value violates unique\n  constraint \"django_content_type_app_label_76bd3d3b_uniq\" DETAIL:  Key\n  (app_label, model)=(auth, permission) already exists.\n\nHow can I fix it?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1910,"Q_Id":52467768,"Users Score":2,"Answer":"It looks like you've generated fixtures that include Django's default data set, i.e. the built-in entries that are inserted normally as part of the first migrate run for some of Django's plumbing data types.\nYou should review your fixture process, because content type entries will be created automatically when your (and Django's) apps' migrations are run, so they should not be present in fixtures. It's possible there are other tables that will have this same problem, so now would be a good time to make sure you're not including any other data that would result in this situation.","Q_Score":0,"Tags":"python,django","A_Id":52490378,"CreationDate":"2018-09-23T15:50:00.000","Title":"IntegrityError: Problem installing fixture","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have several unit-tests (only python3.6 and higher) which are importing a helper class to setup some things (eg. pulling some Docker images) on the system before starting the tests.\nThe class is doing everything while it get instantiate. It needs to stay alive because it holds some information which are evaluated during the runtime and needed for the different tests.\nThe call of the helper class is very expensive and I wanna speedup my tests the helper class only once. My approach here would be to use a singleton but I was told that in most cases a singleton is not needed. Are there other options for me or is a singleton here actually a good solution?\nThe option should allow executing all tests at all and every test on his own.\nAlso I would have some theoretical questions.\nIf I use a singleton here how is python executing this in parallel? Is python waiting for the first instance to be finish or can there be a race condition? And if yes how do I avoid them?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":52468137,"Users Score":0,"Answer":"I can only given an answer on the \"are there other options for me\" part of your question...\nThe use of such a complex setup for unit-tests (pulling docker images etc.) makes me suspicious:\nIt can mean that your tests are in fact integration tests rather than unit-tests.  Which could be perfectly fine if your goal is to find the bugs in the interactions between the involved components or in the interactions between your code and its system environment.  (The fact that your setup involves Docker images gives the impression that you intend to test your system-under-test against the system environment.)  If this is the case I wish you luck to get the other aspects of your question answered (parallelization of tests, singletons and thread safety).  Maybe it makes sense to tag your question \"integration-testing\" rather than \"unit-testing\" then, in order to attract the proper experts.\nOn the other hand your complex setup could be an indication that your unit-tests are not yet designed properly and\/or the system under test is not yet designed to be easily testable with unit-tests: Unit-tests focus on the system-under-test in isolation - isolation from depended-on-components, but also isolation from the specifics of the system environment.  For such tests of a properly isolated system-under-test a complex setup using Docker would not be needed.\nIf the latter is true you could benefit from making yourself familiar with topics like \"mocking\", \"dependency injection\" or \"inversion of control\", which will help you to design your system-under-test and your unit test cases such that they are independent of the system environment.  Then, your complex setup would no longer be necessary and the other aspects of your question (singleton, parallelization etc.) may no longer be relevant.","Q_Score":0,"Tags":"python,python-3.x,unit-testing,singleton","A_Id":55788176,"CreationDate":"2018-09-23T16:36:00.000","Title":"Python3.6 and singletons - use case and parallel execution","Data 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 find myself in the situation that I need to synchronize Trio tasks with Python threads. At the moment, I am using threading.Lock objects that Trio tasks have to acquire with trio.run_sync_in_worker_thread(lock.acquire).\nI think it should also be possible to use trio. Lock locks and have the threads acquire them with trio.BlockingTrioPortal.run_sync(lock.acquire).\nDoes either of these solutions have advantages over the other?\nWould in in principle be possible to do better than this? E.g. to implement a \"native\" trio method that waits for a threading.Lock without the need for a separate worker thread, or are there fundamental reasons why this is required?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":487,"Q_Id":52468911,"Users Score":1,"Answer":"Both methods are fine. I'd recommend to use the method which causes less work, i.e. if the external thread acquires the lock ten times per Trio task's once, then use a thread lock, and vice versa. \nA threading.Lock always blocks the thread trying to acquire it, so taking it from Trio either requires a separate thread (which your first method already does anyway), or the lock's holder needs to signal the Trio task that it has released the lock (which your second method does anyway), so there is no clear advantage for implementing a lower-level solution.","Q_Score":1,"Tags":"python,multithreading,python-trio","A_Id":52469337,"CreationDate":"2018-09-23T18:09:00.000","Title":"Python: ways to synchronize trio tasks and regular threads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been experimenting with QT5 for Python, using pyqt5.  I've noticed that most tutorials recommend using pyuic5 to convert the XML UI to Python code.  I've also seen a couple of tutorials where instead they use uic.loadUi(\"myui.ui\") to dynamical load the XML UI.  This seems like a cleaner, more modular solution to me, but it appears to be an unpopular option.  Is there a reason converting your code with pyuic5 is a sounder solution?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":8622,"Q_Id":52471705,"Users Score":2,"Answer":"The biggest reason to use pyuic5 is that IDEs (e.g. Visual Studio Code, PyCharm) do not understand .ui files, and therefore cannot provide code introspection (e.g. autocompletion of widget names) for your class unless you compile it to Python.","Q_Score":16,"Tags":"python,pyqt,pyqt5","A_Id":69406173,"CreationDate":"2018-09-24T01:28:00.000","Title":"Why in pyqt5 should I use pyuic5 and not uic.loadUi(\"my.ui\")?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So classic beginner problem here... Ive been trying to use Python on various text editors like VSCode and Atom and none of them seem to work (After installing python 3.7). If I ask for a simple input the program crashes labelling the input as undefined, but when I use raw_input() it works just fine for some reason. However, raw_input() was changed to input() in Python 3 so why does this keep happening to me?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1649,"Q_Id":52471860,"Users Score":1,"Answer":"As U9-Forward has mentioned in his answer, similarly... \n\nCheck that the installtion of Python 3.7 is correct by entering the follwoing into the Python 3.7 native IDLE Shell (you may have been using the IDLE of an older Python version):\nimport sys\nprint(sys.version)and...import platformprint(platform.python_version())If any of this produces an error, you will know if there was a problem with installation.\n\nIt's possible that you have multiple versions of Python installed. Check to see what versions you do have installed. If you have other versions besides Python 3.7 uninstall them. \nIf the problem persists uninstall Python 3.7 and reinstall it.\nThe problem as you described can occur when one attempt to install a newer version of Python when older version(s) are still installed.","Q_Score":2,"Tags":"python,python-3.x,input,visual-studio-code","A_Id":52472297,"CreationDate":"2018-09-24T01:57:00.000","Title":"Python 3.7 input() doesnt work but raw_input does","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So classic beginner problem here... Ive been trying to use Python on various text editors like VSCode and Atom and none of them seem to work (After installing python 3.7). If I ask for a simple input the program crashes labelling the input as undefined, but when I use raw_input() it works just fine for some reason. However, raw_input() was changed to input() in Python 3 so why does this keep happening to me?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1649,"Q_Id":52471860,"Users Score":0,"Answer":"Sames happends to me, i uninstall all anaconda + spyder. then i install 3.7. \n-variable-input(), works on 3.0,3.1,3.2,3.3,3.4,3.5,3.6 nd 3.7.\non all other -variable-raw_input workds \ndsclmer: -variable- replace with your own variable such as name or age etc, eg..","Q_Score":2,"Tags":"python,python-3.x,input,visual-studio-code","A_Id":57834213,"CreationDate":"2018-09-24T01:57:00.000","Title":"Python 3.7 input() doesnt work but raw_input does","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing some excel sheet Python automation using openpyxl and I'm having an issue when I try to insert columns or rows into my sheet. \nI'm modifying an existing excel sheet which has basic formula in it (i.e. =F2-G2) however when I insert a row or column before these cells, the formula do not adjust accordingly like they would if you would perform that action in excel. \nFor example, inserting a column before column F should change the formula to =G2-H2 but instead it stays at =F2-G2...\nIs there any way to work around this issue? I can't really iterate through all the cells and fix the formula because the file contains many columns with formula in them.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1105,"Q_Id":52472436,"Users Score":0,"Answer":"openpyxl is a file format library and not an application like Excel and does not attempt to provide the same functionality. Translating formulae in cells that are moved should be possible with the library's tokeniser but this ignores any formulae that refer to the cells being moved on the same worksheet or in the same workbook.","Q_Score":2,"Tags":"python,excel,openpyxl","A_Id":52475659,"CreationDate":"2018-09-24T03:47:00.000","Title":"Maintaining Formulae when Adding Rows\/Columns","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to python and PyCharm of course. I use Ctrl+Enter to split line in editor (making new lines without moving the caret to the next line). But since yesterday it doesn't work anymore and Ctrl+Enter reruns the code instead of splitting the line. Please help me fix that.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":52472591,"Users Score":1,"Answer":"Found it!!!\nWhen the #:Run tab is open, Ctrl+Enter splits the line.\nBut when the Python Console tab is open, Ctrl+Enter reruns the code.","Q_Score":0,"Tags":"python,windows,python-3.x,pycharm","A_Id":52473432,"CreationDate":"2018-09-24T04:09:00.000","Title":"In PyCharm, Ctrl+Enter reruns the code instead of split line. How can I fix it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I read other people's python code, like, spark.read.option(\"mergeSchema\", \"true\"), it seems that the coder has already known what the parameters to use. But for a starter, is there a place to look up those available parameters? I look up the apche documents and it shows parameter undocumented. \nThanks.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":38801,"Q_Id":52472993,"Users Score":8,"Answer":"Annoyingly, the documentation for the option method is in the docs for the json method. The docs on that method say the options are as follows (key -- value -- description):\n\nprimitivesAsString -- true\/false (default false) -- infers all primitive values as a string type\n\nprefersDecimal -- true\/false (default false) -- infers all floating-point values as a decimal type. If the values do not fit in decimal, then it infers them as doubles.\n\nallowComments -- true\/false (default false) -- ignores Java\/C++ style comment in JSON records\n\nallowUnquotedFieldNames -- true\/false (default false) -- allows unquoted JSON field names\n\nallowSingleQuotes -- true\/false (default true) -- allows single quotes in addition to double quotes\n\nallowNumericLeadingZeros -- true\/false (default false) -- allows leading zeros in numbers (e.g. 00012)\n\nallowBackslashEscapingAnyCharacter -- true\/false (default false) -- allows accepting quoting of all character using backslash quoting mechanism\n\nallowUnquotedControlChars -- true\/false (default false) -- allows JSON Strings to contain unquoted control characters (ASCII characters with value less than 32, including tab and line feed characters) or not.\n\nmode -- PERMISSIVE\/DROPMALFORMED\/FAILFAST (default PERMISSIVE) -- allows a mode for dealing with corrupt records during parsing.\n\nPERMISSIVE : when it meets a corrupted record, puts the malformed\nstring into a field configured by columnNameOfCorruptRecord, and sets\nother fields to null. To keep corrupt records, an user can set a\nstring type field named columnNameOfCorruptRecord in an user-defined\nschema. If a schema does not have the field, it drops corrupt records\nduring parsing. When inferring a schema, it implicitly adds a\ncolumnNameOfCorruptRecord field in an output schema.\nDROPMALFORMED : ignores the whole corrupted records.\nFAILFAST : throws an exception when it meets corrupted records.","Q_Score":26,"Tags":"python,python-3.x,apache-spark","A_Id":64562864,"CreationDate":"2018-09-24T05:11:00.000","Title":"Available options in the spark.read.option()","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two django REST API projects which I have decoupled them into micro services architecture, one of the services is an (SSO) that handles authentication (I'm using JWT token based authentication) and manage Users info and the other is a payroll service.\nThe problem is the user has a relation to some model in payroll service. To be specific I have an Employee class in payroll service which has a user_id field. This is where I will add a user UUID which I will get from querying the SSO service.\nHow do I share database across micro-services taking into consideration each service has its own database.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1538,"Q_Id":52475303,"Users Score":4,"Answer":"Sharing database across bounded contexts is not advisable as each microservice should have the capability to make changes on how it persist data. \nAllowing multiple microservices to manage databases would lead you to a death star pitfall pattern\nHowever, you might want to send a copy\/updates of user data on the authentication context towards your payroll service. In this way, you can\nhave independent data persistence strategies. One way to do this is to implement event emission strategy on your authentication context,\nthis event emission strategy would be in-charge of broadcasting data changes made on the authentication context that subscribers residing from\nanother bounded context can listen so that they can store a copy of your user data on their own persistence layers.","Q_Score":4,"Tags":"python,django,database,django-rest-framework,microservices","A_Id":52490138,"CreationDate":"2018-09-24T08:28:00.000","Title":"Sharing database relations across micro-services with Django rest framework","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"As mentioned above I would like to know how I can increase the no of errors shown in flake8 and pylint. I have installed both and they work fine when I am working with small files. I am currently working with a very large file (>18k lines) and there is no error highlighting done at the bottom part of the file, I believe the current limit is set to 100 and would like to increase it.\nIf this isn't possible is there any way I can just do linting for my part of the code? I am just adding a function in this large file and would like to monitor the same.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":384,"Q_Id":52476494,"Users Score":0,"Answer":"Can use \"python.linting.maxNumberOfProblems\": 2000 to increase the no of problems being displayed but the limit seems to be set to 1001 so more than 1001 problems can't be displayed.","Q_Score":0,"Tags":"python,visual-studio-code,vscode-settings,vscode-debugger","A_Id":52476867,"CreationDate":"2018-09-24T09:39:00.000","Title":"How to increase the error limit in flake8 and pylint VS Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm making a school project and I have to make a python server and android client. So I've already created a server using websockets with python 3 (I'm not using Flask or socket.io and etc, just regular websockets) and a client in android studio. I ran everything locally and it works great! \nSo now I want to go up in a level a little bit, I want to host my server on Heroku. I tried but I have some problems with that... As I mentioned, I'm using only websockets and not Flask and that means that I need to specify a host ip\/url and a port. But when I host the server on Heroku it says that \"address already in use\".\nDoes anyone know how solve it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1539,"Q_Id":52477103,"Users Score":5,"Answer":"You can host in heroku by using the ip \"0.0.0.0\", and get the port from the env variable called \"PORT\". On the client you can connect to the websocket server using \"wss:\/\/yourherokuapp.herokuapp.com\/0.0.0.0\". Make sure on your Procfile your script is running as a web process type.","Q_Score":5,"Tags":"python,heroku,websocket","A_Id":54756879,"CreationDate":"2018-09-24T10:14:00.000","Title":"How to host websocket app python server on Heroku without Flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I got this error while running the Django app file that I had downloaded from GitHub. How can I solve this problem?","AnswerCount":8,"Available Count":5,"Score":0.024994793,"is_accepted":false,"ViewCount":41924,"Q_Id":52477683,"Users Score":1,"Answer":"Rename the class name or file name that you are importing, this fixed my issue.","Q_Score":40,"Tags":"python,django","A_Id":69743708,"CreationDate":"2018-09-24T10:49:00.000","Title":"ImportError: bad magic number in 'time': b'\\x03\\xf3\\r\\n' in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I got this error while running the Django app file that I had downloaded from GitHub. How can I solve this problem?","AnswerCount":8,"Available Count":5,"Score":0.1243530018,"is_accepted":false,"ViewCount":41924,"Q_Id":52477683,"Users Score":5,"Answer":"Delete the .pyc files created in your directory .'\nex : i have gitlab.py and gitlab.pyc\nlater i renamed it into gitlab-api.py\nBut while running python file , it is using gitlab.pyc so\n\nTraceback (most recent call last):\nFile \"gitlab-api.py\", line 1, in \nimport gitlab\nImportError: bad magic number in 'gitlab': b'\\x03\\xf3\\r\\n'\n\nit worked correctly when i deleted the gitlab.pyc","Q_Score":40,"Tags":"python,django","A_Id":56897908,"CreationDate":"2018-09-24T10:49:00.000","Title":"ImportError: bad magic number in 'time': b'\\x03\\xf3\\r\\n' in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I got this error while running the Django app file that I had downloaded from GitHub. How can I solve this problem?","AnswerCount":8,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":41924,"Q_Id":52477683,"Users Score":23,"Answer":"Finally, I found the answer, The project has .pyc files, which holds the previous version information and time date, so this error. After deleting those files I got the output.","Q_Score":40,"Tags":"python,django","A_Id":52477805,"CreationDate":"2018-09-24T10:49:00.000","Title":"ImportError: bad magic number in 'time': b'\\x03\\xf3\\r\\n' in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I got this error while running the Django app file that I had downloaded from GitHub. How can I solve this problem?","AnswerCount":8,"Available Count":5,"Score":0.049958375,"is_accepted":false,"ViewCount":41924,"Q_Id":52477683,"Users Score":2,"Answer":"If your OS is Windows you have to delete Python's older versions, then you are ready to use pip again. This is the best method, without errors.","Q_Score":40,"Tags":"python,django","A_Id":61260929,"CreationDate":"2018-09-24T10:49:00.000","Title":"ImportError: bad magic number in 'time': b'\\x03\\xf3\\r\\n' in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I got this error while running the Django app file that I had downloaded from GitHub. How can I solve this problem?","AnswerCount":8,"Available Count":5,"Score":0.0996679946,"is_accepted":false,"ViewCount":41924,"Q_Id":52477683,"Users Score":4,"Answer":"you will need to delete any pyc. pyc is the cache of your app. delete all files that end with .pyc and rerun your app.","Q_Score":40,"Tags":"python,django","A_Id":57879128,"CreationDate":"2018-09-24T10:49:00.000","Title":"ImportError: bad magic number in 'time': b'\\x03\\xf3\\r\\n' in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"so I'm new to python and trying to set up an Apache server to use with django. I already set up django and set the Apache directory and installed C++ version 14.0, but now I'm encountering the following error when trying to install mod_wsgi:\nerror: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX86\\x86\\link.exe' failed with exit status 1120\nI can't find anything useful on how to fix this error and install mod_wsgi, so any help would be appreciated. I am using python 3.7.0 and using Windows 10. I will edit this post with more info about my setup if needed.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":545,"Q_Id":52478149,"Users Score":0,"Answer":"I had this issue because my Apache installation on Windows was 32Bit. Everything else was 64Bit\nI installed XAMPP and it worked in the end.","Q_Score":0,"Tags":"python,apache,pip,mod-wsgi","A_Id":69136486,"CreationDate":"2018-09-24T11:16:00.000","Title":"Encountering exit status 1120 when trying to install mod_wsgi using pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"how do I build a knowledge graph in python from structured texts? Do I need to know any graph databases? Any resources would be of great help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":484,"Q_Id":52478308,"Users Score":0,"Answer":"Knowledge Graph (KG) is just a virtual representation and not an actual graph stored as it is.\nTo store the data you can use any of the present databases like SQL, MongoDB, etc. But to benefit the fact that we are storing graphs here, I'll suggest better use graph-based databases like node4js.","Q_Score":1,"Tags":"python,nlp","A_Id":58796431,"CreationDate":"2018-09-24T11:25:00.000","Title":"Knowledge graph in python for NLP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am reading data from an Excel file and then I am trying to find the file with the dir. The issue here is that I am missing a function.\nFor instance the Data could read 1011754723 but the text file would read Hamlet1011754723_Page100.txt. \nI found the function .endwith(.\"txt\") but I couldn't find one with contains. Is there a function like this?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":48,"Q_Id":52479816,"Users Score":1,"Answer":"I found the solution to my answer:\nfor txt in glob.glob(\"dir\/*1011754723*.txt\"):\n      txt_agg.append(txt)","Q_Score":0,"Tags":"python,text,operating-system,glob","A_Id":52481337,"CreationDate":"2018-09-24T12:48:00.000","Title":"How do I look for a text fragment within a file name?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on an application with a few nested loops of non vectorizable code. There's a group of around 50 functions that get called hundreds or thousands of times. These functions receive dictionaries and pass dictionaries back. Each function is very short, each with simple numerical code,  so just compiling the functions will not do much good. I think that I need to compile both the loop with the functions. Cython could work but I am worried about the amount of work in maintaining type declarations on so many functions plus not getting big improvements due to all those dictionaries being passed around.\nI was wondering if this is a good use case for PyPy. There's no numpy or c extensions involved. Just simple functions reading off inputs from a dictionary and updating those dictionaries.\nI've read the documentation for PyPy where it says that short-running processes will not be improved by PyPy. I am wondering if this short-running functions will prevent the JIT compiler from improving the runtime.\nWhat do you think? Any experience with pypy on something similar is welcome. \nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":264,"Q_Id":52487103,"Users Score":1,"Answer":"The term short-running refers to the quantity of code executed, not the wall-clock time. The JIT traces code execution and only kicks in when it sees a section of code repeat ~1000 times.","Q_Score":0,"Tags":"python,pypy","A_Id":52488931,"CreationDate":"2018-09-24T20:45:00.000","Title":"Is this a use case for pypy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a data set which contains site usage behavior of users over a period of six months. It contains data about:\n\nNumber of pages viewed \nNumber of unique cookies associated with each user\nDifferent number of OS, Browsers used \nDifferent number of cities visited\n\nEverything over here is collected on a six month time frame. I have used this data to train a model to predict a target variable 'y'. Everything is numeric in format.\nNow I know since its a six month data, and the model is built upon this 6 months of data, I can use this to predict on the next six month data to get target variable y.\nMy question is that if instead of using it to predict on six month time frame, I use the model to predict on monthly time frame, will it give me incorrect results?\nMy logic tells me yes, as for example, I used tree method such as Decision tree and Random forest, these algorithms kind of makes thresholds to give output \"0\/1\". Now the variables I mentioned above such as number of cookies associated, OS, Browser etc would have different values if we look at it from  one month stand point and if we look at it from 6 months standpoint. For example, number of unique cookies associated with a user would be less if seen over a month where as it will be more if seen from 6 months standpoint. \nBut I am confused as to if the model will automatically adjust these values while running on monthly data or not. Request you to help me understand the if I am thinking this right or wrong. Also please provide logical explanation if possible. \nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":421,"Q_Id":52487832,"Users Score":0,"Answer":"Is your minimum unit of mesurement 6 months ? I hope not, but if yes, then I would sugges that you dont try to predict the next 1 month.\nSeasonality within a year aside, you would need daily volume measurements.. I would be very worried to build anything on monthly or even weekly numbers.\nIn terms of modelling techniques, please stick to simple regression methods like kungphu suggests.","Q_Score":0,"Tags":"python,machine-learning,logic,data-science,prediction","A_Id":52604844,"CreationDate":"2018-09-24T21:49:00.000","Title":"Prediction problem- Build model using 6 months data and predict on one month data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I installed Python 3.7 for my Mac Book Pro and in Wing101 it still uses Python 2.7.. anyone who can help me out?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":286,"Q_Id":52488445,"Users Score":0,"Answer":"In Wing 101, you can set the Python being used in the Configure Python dialog from the Edit menu, by setting the Python Executable.  Wing 101 version 6+ should really be finding and using the latest Python installation, although maybe it's installed in a place that it isn't found automatically.  Wing version 5 prefers Python 2 because it's fairly old and that made more sense at the time.","Q_Score":1,"Tags":"python,macos,wing-ide","A_Id":52489069,"CreationDate":"2018-09-24T23:02:00.000","Title":"Wing101 is defaulting to python 2.7 even though I have the latest version installed on my Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to manually change a parameter in Generic context in the dialogflow session. My agent picks up a dog's name as parameter- dog_name. The name can be modified later which is stored as dog_name_new. So I need to manually update dog_name to dog_name_new. How might I be able to accomplish this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":720,"Q_Id":52490642,"Users Score":0,"Answer":"Yes, you can update the parameters for a context by re-sending the context as part of your fulfillment, but including the new values instead of the previous one.","Q_Score":1,"Tags":"python,google-cloud-platform,dialogflow-es,chatbot","A_Id":52499447,"CreationDate":"2018-09-25T04:36:00.000","Title":"Is there a way to overwrite context parameters in dialogflow session through webhook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello everyone i'm trying to set up virtualenv and virtualenvwrapper on MAC OS and made huge research  tried everything what i can. DOESN't Work.\nI had python 2.7, i installed python 3.7 using regular installer from the python website.\nInstalled everything what i need but getting error:\n\n\/usr\/bin\/python: No module named virtualenvwrapper\n  virtualenvwrapper.sh: There was a problem running the initialization\n  hooks.\nIf Python could not import the module virtualenvwrapper.hook_loader,\n  check that virtualenvwrapper has been installed for\n  VIRTUALENVWRAPPER_PYTHON=\/usr\/bin\/python and that PATH is set\n  properly.\n\nHere is my ~\/.bashrc :\n\nexport WORKON_HOME=$HOME\/.virtualenvs export PROJECT_HOME=$HOME\/code\n  export VIRTUALENVWRAPPER_PYTHON=\/usr\/local\/bin\/python export\n  VIRTUALENVWRAPPER_VIRTUALENV=\/usr\/local\/bin\/virtualenv export\n  VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'\nsource \/Library\/Frameworks\/Python.framework\/Versions\/3.7\/bin\/virtualenvwrapper.sh\n\nHere is where my python3 is installed \n\n\/Library\/Frameworks\/Python.framework\/Versions\/3.7\/bin\/python3\n\nSo in the end i did create one using \n\nvirtualenv -p python3 \"desired-path\"\n\nbut when i tried to set up everything with Django nothing is working bc of problem above. Any help please!!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":727,"Q_Id":52491152,"Users Score":0,"Answer":"About 6 hours and i have a way to solve it so if anyone has the same problem just go ahead and change your ~\/.bashrc (by typing in Terminal nano ~\/.bashrc) to:\n\nexport WORKON_HOME=$HOME\/.virtualenvs export PROJECT_HOME=$HOME\/code\nexport\n  VIRTUALENVWRAPPER_PYTHON=\/Library\/Frameworks\/Python.framework\/Versions\/3.7\/bin\/python3.7\nexport VIRTUALENVWRAPPER_VIRTUALENV=\/Library\/Frameworks\/Python.framework\/Versions\/3.7\/bin\/virtualenv\nexport VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages' source\n  \/Library\/Frameworks\/Python.framework\/Versions\/3.7\/bin\/virtualenvwrapper.sh","Q_Score":1,"Tags":"python-3.x,macos,virtualenv,virtualenvwrapper","A_Id":52498179,"CreationDate":"2018-09-25T05:28:00.000","Title":"Python virtualenv Can't set up! MAC OS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I downloaded Python 3.7 and am  running a script with \"from bs4 import BeautifulSoup\" and am receiving the following error on execution;\n\n\"File \"myscript.py\", line 3, in \n      from bs4 import BeautifulSoup ImportError: No module named bs4\"\n\nWhen I type \"pip3 install bs4\" or \"pip3 install BeautifulSoup4\" in the terminal I get the following;\n\n\"Requirement already satisfied: bs4 in\n  \/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/site-packages\n  (0.0.1) Requirement already satisfied: beautifulsoup4 in\n  \/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/site-packages\n  (from bs4) (4.6.3)\"\n\nExecuting \"import bs4\" and \"from bs4 import BeautifulSoup\" in IDLE don't error out.\nAny idea about what's going on?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1528,"Q_Id":52492315,"Users Score":2,"Answer":"Just pip install bs4. \nProbably, you are maintaining different versions of Python.","Q_Score":0,"Tags":"python,macos","A_Id":52492458,"CreationDate":"2018-09-25T06:57:00.000","Title":"ImportError: No module named bs4 - despite bs4 and BeautifulSoup being installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I downloaded Python 3.7 and am  running a script with \"from bs4 import BeautifulSoup\" and am receiving the following error on execution;\n\n\"File \"myscript.py\", line 3, in \n      from bs4 import BeautifulSoup ImportError: No module named bs4\"\n\nWhen I type \"pip3 install bs4\" or \"pip3 install BeautifulSoup4\" in the terminal I get the following;\n\n\"Requirement already satisfied: bs4 in\n  \/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/site-packages\n  (0.0.1) Requirement already satisfied: beautifulsoup4 in\n  \/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/site-packages\n  (from bs4) (4.6.3)\"\n\nExecuting \"import bs4\" and \"from bs4 import BeautifulSoup\" in IDLE don't error out.\nAny idea about what's going on?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1528,"Q_Id":52492315,"Users Score":1,"Answer":"check if you have more than one version of python, if so add the path of python 3.7 in the system setting and try removing the older python if possible\nand then pip install BeautifulSoup","Q_Score":0,"Tags":"python,macos","A_Id":56063007,"CreationDate":"2018-09-25T06:57:00.000","Title":"ImportError: No module named bs4 - despite bs4 and BeautifulSoup being installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The documentation of pandas.Timestamp states a concept well-known to every pandas user:\n\nTimestamp is the pandas equivalent of python\u2019s Datetime and is interchangeable with it in most cases.\n\nBut I don't understand why are pandas.Timestamps needed at all.\nWhy is, or was, it useful to have a different object than python's Datetime? Wouldn't it be cleaner to simply build pandas.DatetimeIndex out of Datetimes?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":416,"Q_Id":52492996,"Users Score":3,"Answer":"You can go through Pandas documentation for the details:\n\n\"pandas.Timestamp\" is a replacement for python datetime.datetime for\n  Padas usage.\nTimestamp is the pandas equivalent of python\u2019s Datetime and is\n  interchangeable with it in most cases. It\u2019s the type used for the\n  entries that make up a DatetimeIndex, and other timeseries oriented\n  data structures in pandas.\nNotes\nThere are essentially three calling conventions for the constructor.\n  The primary form accepts four parameters. They can be passed by\n  position or keyword.\nThe other two forms mimic the parameters from datetime.datetime. They\n  can be passed by either position or keyword, but not both mixed\n  together.\nTimedeltas are differences in times, expressed in difference units,\n  e.g. days, hours, minutes, seconds. They can be both positive and\n  negative.\nTimedelta is a subclass of datetime.timedelta, and behaves in a\n  similar manner, but allows compatibility with np.timedelta64 types\n  as well as a host of custom representation, parsing, and attributes.\n\nI would say as pandas works better with Time Series data hence its been a kind of warper on the original built-in datetime module.\n\nThe weaknesses of Python's datetime format inspired the NumPy team to\n  add a set of native time series data type to NumPy. The datetime64\n  dtype encodes dates as 64-bit integers, and thus allows arrays of\n  dates to be represented very compactly.","Q_Score":7,"Tags":"python,pandas,timestamp","A_Id":52493234,"CreationDate":"2018-09-25T07:39:00.000","Title":"Why pandas has its own datetime object Timestamp?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to add some comments in presentation file for some text-boxes. Is there any python-pptx attribute available to do that ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":357,"Q_Id":52493362,"Users Score":1,"Answer":"PowerPoint comments are not yet supported in python-pptx. There's not really a feature request for that at the time of this writing, so you can feel free to add one if you like.","Q_Score":2,"Tags":"python,python-pptx","A_Id":52504613,"CreationDate":"2018-09-25T08:02:00.000","Title":"Inserting comments in presentation using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm exploring ODL and mininet and able to run both and populate the network nodes over ODL and I can view the topology via ODL default webgui.\nI'm planning to create my own webgui and to start with simple topology view. I need advise and guideline on how I can achieve topology view on my own webgui. Plan to use python and html. Just a simple single page html and python script. Hopefully someone could lead me the way. Please assist and thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":162,"Q_Id":52493515,"Users Score":0,"Answer":"If a web GUI for ODL would provide value for you, please consider working to contribute that upstream. The previous GUI (DLUX) has recently been deprecated because no one was supporting it, although it seems many people were using it.","Q_Score":0,"Tags":"python,html,api,web,opendaylight","A_Id":52532208,"CreationDate":"2018-09-25T08:12:00.000","Title":"How to view Opendaylight topology on external webgui","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a program written in C++ (as a static library for now) with very abstract interface that uses operator overloading on my classes etc. I want to create a shared library out of it (DLL on Windows would be the first step, before trying other platforms) to use it in other more \"user friendly\" languages. I read that Python has some level of support for this with its ctypes.\nI just want to know, if it is possible to use some higher level abstractions from a C++ DLL in Python to choose the right option before I invest time in trying to do something, that's impossible. User should be able to initialize the classes provided by my program and use them with all their methods including overloaded operators (only those available in python of course). Or is Python only meant to support some simple function calls etc.?\nThe C++ code (even just the user accessible classes) is huge and I would like to avoid creating separate Python wrappers, as all of the needed functionality is already done in C++.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":910,"Q_Id":52495024,"Users Score":3,"Answer":"Since no one answered, I will provide everything I have gathered myself in the meantime. Hope it might be helpful for some.\nPython's ctypes are meant to support only C language features. So there is no way to directly access classes and other C++ objects from Python using ctypes. However, there are some ways to access them.\nThe tedious method\nCreate C style objects for the C++ classes, and then create Python wrappers for them.\nThe C style object would basically be a pointer to the C++ object allocated dynamically. It should have additional methods like for example the conventionally named ->Release() to destroy the object and free the allocated memory. Then you would need to create python wrappers manually that would resemble the original C++ object including the overloaded operators etc. (Sidenote: The only operator I came across, that could be needed in such situations and is not overloadable in Python is the assignment operator.)\nThis is probably the best solution when you want to have full control over what's happening and don't mind duplicating the interface in Python.\nThe quick method\nBoost provides a Boost::Python library to handle this. It lets you export practically anything you would need - classes, operators, even multiple overloaded methods.\nThe only problem is, that this library is quite large and it's one of the non-header-only Boost libraries, so you would need to figure out how to build it with your project and this might not be easy for people, who never worked with Boost (like myself).\nI don't know what exactly this library does, maybe it just automates the same thing described in the previous method. So I'm not sure whether it reduces levels of additional wrappers or just simply does all the hard wrapping work for you, but it does what I needed to be done.\nThe quicker method\nLuckily I came across an alternative - pybind11. It's a relatively small library, that does the same thing as Boost::Python and it's header-only. It has nice documentation and is easy to use. It's called pybind11 as it was originally meant to support C++11, but it currently supports C++14 and experimentally C++17, but I used it with a C++17 project and found no problems so far.\nI'm not yet sure which method would be the best for my project but for now, I use pybind11, just to make it easier while the project is under development.","Q_Score":1,"Tags":"python,c++,dll,dllexport","A_Id":52724620,"CreationDate":"2018-09-25T09:38:00.000","Title":"Export of C++ classes for Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using iPython 5.5.0, when i run my script which takes input for input.csv I get the following error:\nIn [1]: %run \"C:\\myrootFolder\\pythoncode\\testfile.py input.csv\"\nERROR:root:File `u'In [1]: %run \"C:\\myrootFolder\\pythoncode\\testfile.py input.csv.py' not found.\nSame way I am unable to execute..  %run \"C:\\Python27\\Scripts\\mysite\\manage.py runserver\"\nSimilar error occurs, What am I doing wrong.\nTIA.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":52496972,"Users Score":0,"Answer":"Found the issue it should be \n%run \"C:\\myrootFolder\\pythoncode\\testfile.py\" \\input.csv","Q_Score":0,"Tags":"python,django,ipython","A_Id":52497020,"CreationDate":"2018-09-25T11:20:00.000","Title":"Error while using iPython for executing 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a binary (0-1) 3D numpy array, which I plan to use for masking a 3D image. The mask at the moment consists in the area of a cylinder. The two centres of the faces are two arbitrary points, and the axis is not parallel to x, y or z.\nHow can I fill the cylinder with a pure numpy solution?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":792,"Q_Id":52497995,"Users Score":1,"Answer":"If you have surface cells marked and there si no additional information, then scan array layer by layer to get the first marked cell (or get some surface cell if they are known).\nWhen you have marked A[z,y,x] surface cell, fill line in the last dimension (x) 1d array until new marked cell is met.\nThen find neighbor marked cell in the same top-level layer (same z, close y ans x) and repeat to fill lines until whole section (ellipse or cutted ellipse) is filled, then continue with the next z layer\nEdit\nPerhaps I overcomplicate the problem, and FloodFill algo is simple solution.","Q_Score":0,"Tags":"python-2.7,numpy,geometry","A_Id":52499867,"CreationDate":"2018-09-25T12:13:00.000","Title":"Filled 3D numpy mask","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have installed Centos 6.x in one or our VM and it has come with default Python 2.6 installed. On top of it we have installed Python 2.7 and configured Python 2.7 as default in \/usr\/bin\/. When I type python in my command line it gives version Python 2.7. But when I execute my python script file test.py it is using Python 2.6 instead of Python 2.7. Did I miss any configurations to tell my scripts to use Python 2.7 instead of Python 2.6 on my machine?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":66,"Q_Id":52499341,"Users Score":1,"Answer":"Since it sounds like you set up your command line correctly, I would first try looking at your script. Did you try including the shebang at the top of your script? #!\/usr\/bin\/env python2.7","Q_Score":0,"Tags":"python,python-2.7,centos6","A_Id":52499590,"CreationDate":"2018-09-25T13:25:00.000","Title":"How to tell python script files to use particular version of python if there are multiple versions of python are installed on the 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":1,"Web Development":0},{"Question":"I'm working with Concept Drift, but when trying to run my code i get this error\n\"ImportError: No module named detector_classifier\" been trying to install the module with pip install, but all i get is no match found. Anyone had this problem before?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":908,"Q_Id":52499573,"Users Score":0,"Answer":"I think a little more information might help. Which python version and which pip version are you using? I just googled \"detector_classifier\" and couldn't find anything. What library does \"detector_classifier\" belong to? \nWithout much background to go off of, I would recommended making sure you have updated pip. Depending on what operating system you're using, your configuration might need some tinkering so your system knows where to look.","Q_Score":0,"Tags":"python,ubuntu","A_Id":52499750,"CreationDate":"2018-09-25T13:36:00.000","Title":"ImportError: No module named detector_classifier","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to tensorflow and it\u2019s object detection API. In its tutorial, it\u2019s said that the images must be separated into train\/ and test\/ folders. Actually I am working on a server where my entire data is kept in a folder called \u2018images\u2019 and I don\u2019t want to either change it\u2019s structure or create another copy of it. \nHowever, I have created separate train.record and test.record files as well and it\u2019s just that I want all my images to be in one folder together. Is it possible? If yes , then which of files need to be modified? Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":192,"Q_Id":52500185,"Users Score":0,"Answer":"In case you already have separate record files for train and eval (validation\/test), then it's okay.\nYou simply put the pathes of the corresponding records in \ntf_record_input_reader {\n    input_path: \"\/path\/to\/record\/record_name.record\"\n    }\nonce for train_input_reader and once for eval_input_reader. In case the records are split into shards, than use the format of \ninput_path: \"\/path\/to\/record\/record_name.record-?????-of-00010\" (instead of 10 - number of shards).","Q_Score":0,"Tags":"python,tensorflow","A_Id":52628707,"CreationDate":"2018-09-25T14:07:00.000","Title":"Is it possible to keep all the images in one folder for tensorflow object detection API","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is as follows: \nI have some lists such as [1], [1,2], [1,3,1], and I want to put them in a 2D array result, which is [[1],[1,2],[1,3,1]]. Are there any simple ways to do that? Thanks.","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":47,"Q_Id":52500885,"Users Score":-1,"Answer":"There you go:\nx, y, z = [1], [1,2], [1,3,1]\n[x,y,z]","Q_Score":0,"Tags":"python,arrays,multidimensional-array","A_Id":52501017,"CreationDate":"2018-09-25T14:40:00.000","Title":"Python 2-D array assignment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two python files (Iron Python 2.7) and a .net dll file.\n\nabc.py\ndef.py\nghi.dll\n\nabc.py is the Main file that contains the code for Windows Forms application and def.py is a supporting  file that has the functions. ghi.dll is a third party api file that has been modified to dll.\nI want to create this to an Windows Forms Application executable to distribute it to others in my team.\nUsed Visual Studio 2017 to write the code.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":721,"Q_Id":52501442,"Users Score":1,"Answer":"Create a folder and copy all the required .net dlls from the C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework.NETFramework\\v4.0 folder and copy all the required files from the C:\\Program Files (x86)\\IronPython 2.7\\Lib folder\nCopy the ipyc.exe from C:\\Program Files (x86)\\IronPython 2.7 folder and copy pyc.py from C:\\Program Files (x86)\\IronPython 2.7\\Tools\\Scripts folder\nOpen Command Prompt and navigate to the appropriate folder and use the following command\n    ipyc def.py \/main:abc.py \/target:winexe","Q_Score":0,"Tags":".net,executable,ironpython","A_Id":52524477,"CreationDate":"2018-09-25T15:10:00.000","Title":"How to build a executable for ironpython files and a .Net dll file?","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":"How to integrate tesseract OCR in a web page such that:\n\nUser selects the file via system dialogue box actioned by a button (input type, file). \nThe uploaded image is then subjected to Tesseract script and the output of the OCR is displayed on the webpage itself.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":505,"Q_Id":52502008,"Users Score":1,"Answer":"There is a huge hidden problem to running tesseract in a webpage.\npytesseract, the popular tesseract wrapper for Python, calls on subprocess and Popen to run tesseract from the command line, then parses the results and returns them to you.\nSpawning a subprocess from a web request (other than those directly managed by your webserver) will:\n\nCrash or stall most Python web frameworks\nCrash or stall WSGI processes\nCreate tons of zombie processes\nBe a general pain to handle\n\nSo, my advice is to not.\nLook for an OCR solution that runs in pure-Python or interfaces with Python through a statically compiled shared object.\nWhich OCR solution does that... I have no clue.","Q_Score":0,"Tags":"python,html,webpage,tesseract","A_Id":52502112,"CreationDate":"2018-09-25T15:39:00.000","Title":"Integration of Tesseract OCR in a webpage - and more","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using quickfix with python bindings and I need to log out of a current session and re-logon again immediately. But I'm having the following issues.\n\nIf I call session.logout() followed immediately by session.logon(), it never logs out because I think these methods are just setting some flags.\nI tried calling session.generateLogout() but this doesn't actually have a swig binding, so can't be called from python.\n\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":337,"Q_Id":52507086,"Users Score":0,"Answer":"It's possible the logout request hasn't been fulfilled before you try to logon. Try reacting to the onlogout method with a relogon message based on certain conditions.","Q_Score":0,"Tags":"python,quickfix","A_Id":59791320,"CreationDate":"2018-09-25T21:44:00.000","Title":"How to logout and logon session immediately in quickfix python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"From what I understand, the GIL makes it impossible to have threads that harness a core each individually. \nThis is a basic question, but, what is then the point of the threading library? It seems useless if the threaded code has equivalent speed to a normal program.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":6053,"Q_Id":52507601,"Users Score":22,"Answer":"In some cases an application may not utilize even one core fully and using threads (or processes) may help to do that.\nThink of a typical web application. It receives requests from clients, does some queries to the database and returns data back to the client. Given that IO operation is order of magnitude slower than CPU operation most of the time such application is waiting for IO to complete. First, it waits to read the request from the socket. Then it waits till the request to the database is written into the socket opened to the DB. Then it waits for response from the database and then for response to be written to the client socket. \nWaiting for IO to complete may take 90% (or more) of the time the request is processed. When single threaded application is waiting on IO it just not using the core and the core is available for execution. So such application has a room for other threads to execute even on a single core.\nIn this case when one thread waits for IO to complete it releases GIL and another thread can continue execution.","Q_Score":36,"Tags":"python,multithreading,python-multiprocessing,python-multithreading","A_Id":52507863,"CreationDate":"2018-09-25T22:46:00.000","Title":"What's the point of multithreading in Python if the GIL exists?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I run python on Anaconda or atom, it automatically defaults to an environment I made called \"tf15\".\nWhen I do where python in my cmd I get the right path C:\\Users\\Kelfun\\Anaconda3\\python.exe\nBut when I run this in my jupyter notebook or atom text editor:\nimport sys\nprint(sys.executable)\nI get: C:\\Users\\Kelfun\\Anaconda3\\envs\\tf15\\python.exe\nHow can I make the \"root\" environment as my default environment in Anaconda.\nAlso, I did not activate \"tf15\" before opening jupyter or atom yet it defaults to it.\nAny help is appreciated, Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":926,"Q_Id":52507974,"Users Score":0,"Answer":"You have probably added C:\\Users\\Kelfun\\Anaconda3\\envs\\tf15\\Scripts to your system's PATH variable ahead of the base Anaconda3 path.  The kernel for your 'tf15' environment is not in the \\Scripts folder, so you are seeing the correct path when using where python.\nTo fix it, open the system variables interface (Start Menu > type variable > click \"Edit the system environment variables\")\nCheck the PATH variable for both the system and the user for anything that points to C:\\Users\\Kelfun\\Anaconda3\\envs\\tf15 and remove them.","Q_Score":0,"Tags":"python,anaconda,environment","A_Id":52508062,"CreationDate":"2018-09-25T23:39:00.000","Title":"How to change the default python version on anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"My script scans the price of certain products on nike.com and will keep scraping the price of the products till it goes on sale and at that point it will create multiple instances to login into multiple accounts to purchase the product. \nI already have the function of scraping the website and checking out the product made but I want to know should I use multiprocessing or multithreading to execute the logging in and checking out process?\nWhich will be more efficient at handling multiple instances of the web-automation process? I'm using selenium headless in firefox if that helps.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":353,"Q_Id":52507999,"Users Score":0,"Answer":"Threads are much faster to create, have a smaller memory footprint since they share memory and can communicate by just updating variables, since they all have access to the same memory space.\nI personally like to you the multiprocessing.dummy module that let's you handle threads with the multiprocessing api which is very handy.","Q_Score":0,"Tags":"python,multithreading,selenium,multiprocessing,webautomation","A_Id":52508193,"CreationDate":"2018-09-25T23:42:00.000","Title":"Multithreading or Multiprocessing for a webautomation bot in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created custom exception in python 3 and the over all code works just fine. But there is one thing I am not able to wrap my head around is that why do I need to send my message to the Exception class's __init__() and how does it convert the Custom exception into that string message when I try to print the exception since the code in the Exception or even the BaseException does not do much.\nNot quite able to understand why call the super().__init__() from custom exception?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":739,"Q_Id":52509910,"Users Score":2,"Answer":"This is so that your custom exceptions can start off with the same instance attributes as a  BaseException object does, including the value attribute, which stores the exception message, which is needed by certain other methods such as __str__, which allows the exception object to be converted to a string directly. You can skip calling super().__init__ in your subclass's __init__ and instead initialize all the necessary attributes on your own if you want, but then you would not be taking advantage of one of the key benefits of class inheritance. Always call super().__init__ unless you have very specific reasons not to reuse any of the parent class's instance attributes.","Q_Score":2,"Tags":"python,python-3.x,exception,super","A_Id":52510057,"CreationDate":"2018-09-26T04:22:00.000","Title":"Python3, calling super's __init__ from a custom exception","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using \"django-pyodbc-azure\" 3rd party library for making connection and django1.11 and python version 3.5.2\n\n*** Error in `\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python': double free or corruption (!prev): 0x00007f7f08078a90 ***\n======= Backtrace: =========\n\/lib\/x86_64-linux-gnu\/libc.so.6(+0x777e5)[0x7f7f2a7a17e5]\n\/lib\/x86_64-linux-gnu\/libc.so.6(+0x8037a)[0x7f7f2a7aa37a]\n\/lib\/x86_64-linux-gnu\/libc.so.6(cfree+0x4c)[0x7f7f2a7ae53c]\n\/usr\/lib\/x86_64-linux-gnu\/libodbc.so.2(SQLDriverConnectW+0x9a0)[0x7f7f24055100]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/lib\/python3.5\/site-packages\/pyodbc.cpython-35m-x86_64-linux-gnu.so(_Z14Connection_NewP7_objectbblbS0_R6Object+0x2c3)[0x7f7f242a52a3]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/lib\/python3.5\/site-packages\/pyodbc.cpython-35m-x86_64-linux-gnu.so(+0x111de)[0x7f7f242a21de]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyCFunction_Call+0x77)[0x4e9ba7]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x59f5)[0x53c6d5]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x4b04)[0x53b7e4]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x4b04)[0x53b7e4]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x4b04)[0x53b7e4]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x540199]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x50b2)[0x53bd92]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x4b04)[0x53b7e4]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x5434af]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyCFunction_Call+0x4f)[0x4e9b7f]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x614)[0x5372f4]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalCodeEx+0x13b)[0x540f9b]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x4ebd23]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyObject_Call+0x47)[0x5c1797]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x4fb9ce]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyObject_Call+0x47)[0x5c1797]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyObject_CallFunctionObjArgs+0x128)[0x5c1988]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x20bc)[0x538d9c]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x4b04)[0x53b7e4]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalCodeEx+0x13b)[0x540f9b]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x4ebd98]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyObject_Call+0x47)[0x5c1797]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyObject_CallFunctionObjArgs+0x128)[0x5c1988]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(_PyObject_GenericGetAttrWithDict+0x1bd)[0x593b9d]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x44d)[0x53712d]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x540199]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x50b2)[0x53bd92]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x540199]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x50b2)[0x53bd92]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x4ed3f5]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x5b7994]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x5b7fbc]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x57f03c]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyObject_Call+0x47)[0x5c1797]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x4ec6)[0x53bba6]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x4b04)[0x53b7e4]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalCodeEx+0x13b)[0x540f9b]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x4ebd23]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyObject_Call+0x47)[0x5c1797]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x4fb9ce]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyObject_Call+0x47)[0x5c1797]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x584716]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x5761aa]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x54320c]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x4ce6)[0x53b9c6]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalCodeEx+0x13b)[0x540f9b]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x4ebe37]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyObject_Call+0x47)[0x5c1797]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x252b)[0x53920b]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x5406df]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x54f0)[0x53c1d0]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalCodeEx+0x13b)[0x540f9b]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x4ebe37]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyObject_Call+0x47)[0x5c1797]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalFrameEx+0x252b)[0x53920b]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python(PyEval_EvalCodeEx+0x13b)[0x540f9b]\n\/home\/ubuntu\/GET-Services_mssql\/env_mssql\/bin\/python[0x4ebe37]","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":52511704,"Users Score":0,"Answer":"My comment to the question apparently solved the problem:\n\nPython 3.5.2 and unixODBC 2.3.1 sounds like Ubuntu 16.04. Some packages in the Ubuntu repositories can be very old, e.g., unixODBC 2.3.1 is almost 7 years old now. Since it is unixODBC that is crashing (in SQLDriverConnectW) you might want to try upgrading it to the latest version (currently 2.3.7).","Q_Score":1,"Tags":"python,sql-server,django,ubuntu,pyodbc","A_Id":52669412,"CreationDate":"2018-09-26T06:56:00.000","Title":"Any Solution to SQLDriverConnect Error in Django Occurred Below using pyodbc","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I would like to share my internal IP between two devices on a network (using python 3).\nLet's say I have my phone, and my computer. Both connected to the same network. I need to run a client and server script to connect the two but in order to do that, my phone (client) needs the ip of the computer (server).\nThe IP of the computer changes all the time (school wifi, nothing I can do about it) and even so I would like this to work instantly when connected to a new router without having to manually enter the IP.\nOne more thing, due to the huge amounts of devices on the network, mapping every device and finding the computer name to get the IP will take too long for its purpose.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":52513050,"Users Score":0,"Answer":"In case anyone was wondering. I take this question as unsolvable, but, in order to solve my issue, I have set my computer to upload its internal IP to a server each time it connects to a new network. My phone then reads the server.","Q_Score":0,"Tags":"python,python-3.x,networking,ip","A_Id":52564276,"CreationDate":"2018-09-26T08:15:00.000","Title":"Exchange internal ip blindly using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to share my internal IP between two devices on a network (using python 3).\nLet's say I have my phone, and my computer. Both connected to the same network. I need to run a client and server script to connect the two but in order to do that, my phone (client) needs the ip of the computer (server).\nThe IP of the computer changes all the time (school wifi, nothing I can do about it) and even so I would like this to work instantly when connected to a new router without having to manually enter the IP.\nOne more thing, due to the huge amounts of devices on the network, mapping every device and finding the computer name to get the IP will take too long for its purpose.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":52513050,"Users Score":0,"Answer":"Please use DNS for the purpose, or assign static addresses to your devices, and use the defined static addresses in your scripts.","Q_Score":0,"Tags":"python,python-3.x,networking,ip","A_Id":52534087,"CreationDate":"2018-09-26T08:15:00.000","Title":"Exchange internal ip blindly using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can i import Robot Keywords file from Python script and execute keywords from that file and generate report like Robot html report.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":229,"Q_Id":52516100,"Users Score":0,"Answer":"You cannot import a robot keyword file from a python script, unless that script is using the low level robot API to run a test. \nRobot keywords can only be used from within a running robot test.","Q_Score":0,"Tags":"python,robotframework","A_Id":52516514,"CreationDate":"2018-09-26T10:55:00.000","Title":"How can i import Robot Keywords file from Python script and execute keywords from that file and generate report","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 upgraded PyCharm (community version).  If it matters, I am running on a Mac OSX machine.  After the upgrade, I have one project in which PyCharm cannot find any python modules.  It can't find numpy, matplotlib, anything ...  I have checked a couple of other projects and they seem to be fine.  I noticed that somehow the interpreter for the project in question was not the same as for the others.  So I changed it to match the others.  But PyCharm still can't find the modules.  Any ideas what else I can do?\nMore generally, something like this happens every time I upgrade to a new PyCharm version.  The fix each time is a little different.  Any ideas on how I can prevent this in the first place?\nEDIT: FWIW, I just now tried to create a new dummy project.  It has the same problem.  I notice that my two problem projects are created with a \"venv\" sub-directory.  My \"good\" projects don't have this thing.  Is this a clue to what is going on?\nEDIT 2: OK, just realized that when creating a new project, I can select \"New environment\" or \"Existing interpreter\", and I want \"Existing interpreter\".  However, I would still like to know how one project that was working fine before is now hosed, and how I can fix it.  Thanks.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":90,"Q_Id":52526167,"Users Score":1,"Answer":"Your project is most likely pointing to the wrong interpreter. E.G. Using a virtual environment when you want to use a global one.\nYou must point PyCharm to the correct interpreter that you want to use.\n\"File\/Settings(Preferences On Mac)\/Project: ... \/Project Interpreter\" takes you to the settings associated with the interpreters.\nThis window shows all of the modules within the interpreter.\nFrom here you can click the settings wheel in the top right and configure your interpreters. (add virtual environments and what not)\nor you can select an existing interpreter from the drop down to use with your project.","Q_Score":1,"Tags":"python,pycharm","A_Id":52526325,"CreationDate":"2018-09-26T21:19:00.000","Title":"Interpreter problem (apparently) with a project in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently upgraded PyCharm (community version).  If it matters, I am running on a Mac OSX machine.  After the upgrade, I have one project in which PyCharm cannot find any python modules.  It can't find numpy, matplotlib, anything ...  I have checked a couple of other projects and they seem to be fine.  I noticed that somehow the interpreter for the project in question was not the same as for the others.  So I changed it to match the others.  But PyCharm still can't find the modules.  Any ideas what else I can do?\nMore generally, something like this happens every time I upgrade to a new PyCharm version.  The fix each time is a little different.  Any ideas on how I can prevent this in the first place?\nEDIT: FWIW, I just now tried to create a new dummy project.  It has the same problem.  I notice that my two problem projects are created with a \"venv\" sub-directory.  My \"good\" projects don't have this thing.  Is this a clue to what is going on?\nEDIT 2: OK, just realized that when creating a new project, I can select \"New environment\" or \"Existing interpreter\", and I want \"Existing interpreter\".  However, I would still like to know how one project that was working fine before is now hosed, and how I can fix it.  Thanks.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":90,"Q_Id":52526167,"Users Score":1,"Answer":"It seems, when you are creating a new project, you also opt to create a new virtual environment, which then is created (default) in that venv sub-directory.\nBut that would only apply to new projects, what is going on with your old projects, changing their project interpreter environment i do not understand.\nSo what i would say is you have some corrupt settings (e.g. in ~\/Library\/Preferences\/PyCharm2018.2 ), which are copied upon PyCharm upgrade.\nYou might try newly configure PyCharm by moving away those PyCharm preferences, so you can put them back later.\nThe Project configuration mainly, special the Project interpreter on the other hand is stored inside $PROJECT_ROOT\/.idea and thus should not change.","Q_Score":1,"Tags":"python,pycharm","A_Id":52526644,"CreationDate":"2018-09-26T21:19:00.000","Title":"Interpreter problem (apparently) with a project in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This might be a silly question. When use sessions with Python to request a file from a website behind a login, can the website detect that you are logging in via a script? How common is it for websites to detect this? I tried looking this up but couldn't find an answer so if this is a repeat question could you point me to some info so I can find my answer?\nThanks in advance!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":52526787,"Users Score":0,"Answer":"You should change the user agent. But other than that I don\u2019t think its detectable. \nYou can change the user agent by setting a custom header e.g. requests.get(url, headers= {\"user-agent\": \"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/60.0.3112.113 Safari\/537.36\"}","Q_Score":1,"Tags":"python,server,webserver","A_Id":52526825,"CreationDate":"2018-09-26T22:21:00.000","Title":"Can a web server detect a login from a script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This might be a silly question. When use sessions with Python to request a file from a website behind a login, can the website detect that you are logging in via a script? How common is it for websites to detect this? I tried looking this up but couldn't find an answer so if this is a repeat question could you point me to some info so I can find my answer?\nThanks in advance!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":52526787,"Users Score":0,"Answer":"Nothing is  a silly question when you don't have the answer.\nThat being said, every request adds a header by default called the user agent, this can be a multitude of different things but is primarily used to detect what type of device or browser thenuser is connecting to the site with.\nThis includes Python requests! Python sends a user agent Python (version number) in its user agent header.\nIt is very common for webmasters to block these user agents, however, it is extremely simple to spoof the user agent header by changing it prior to sending the request itself.\nYou should look into header customisation of requests. \nIt is also very common for people writing scripts that connect to webserver to hide, spoof or otherwise obfuscate their user agent, but there are plenty more headers send by default which are also used to block unwanted traffic.\nHope this helps","Q_Score":1,"Tags":"python,server,webserver","A_Id":52526889,"CreationDate":"2018-09-26T22:21:00.000","Title":"Can a web server detect a login from a script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the BeautifulSoup method for retrieving text from an element. I haveprices = soup.find_all('p', class_='price_color') and want to retrieve the text from prices. I tried p = prices.get_text() but got an error stating: 'ResultSet' object has no attribute 'text'","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":36,"Q_Id":52529065,"Users Score":2,"Answer":"find_all returns a ResultSet object and you can iterate that object using a for loop.\nYou can try something such as:\nfor values in soup.find_all('p', class_='price_color'):\n    print values.text","Q_Score":0,"Tags":"python,text,beautifulsoup","A_Id":52529129,"CreationDate":"2018-09-27T03:37:00.000","Title":"BeautifulSoup method to retrieve the text from an element","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"if all(data_Window['CI']!=np.nan):\nI have used the all() function with if so that if column CI has no NA values, then it will do some operation. But i got syntax error.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":52529669,"Users Score":0,"Answer":"This gives you all a columns and how many null values they have.\ndf = pd.DataFrame({0:[1,2,None,],1:[2,3,None])\ndf.isnull().sum()","Q_Score":0,"Tags":"python,pandas","A_Id":52529791,"CreationDate":"2018-09-27T04:54:00.000","Title":"how can i check all the values of dataframe whether have null values in them without a loop","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In xfce, specifically xubuntu 16.04, where are the theme engines found? I'm chasing a persistent error that gives warnings on each execution of a python program which imports pygtk. My desktop theme is probably a leftover from gtk 2, which may be the problem, but I've not been able to locate such engines in any of the gtk 3 themes installed by default, either.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19,"Q_Id":52529810,"Users Score":0,"Answer":"I think I finally found it; it's in a stanza of the theme's \"gtkrc\" file in its gtk-2.0 directory. I've edited that line to replace the engine name shown by the warning message, with \"none\" to verify -- but I still need to learn more about the intricacies of theme design and troubleshooting. As a toolmaker, I can never learn enough! A link to a howto for gtk-3 themes would be helpful...\nLATER: Well, all that did was to change one word in the error messages, which come from GTK at the creation of a new toplevel window. I'll try commenting out the entire stanza from the css file and see what that does.","Q_Score":0,"Tags":"python,themes,xfce","A_Id":52539588,"CreationDate":"2018-09-27T05:09:00.000","Title":"Theme engine missing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Consider the following situation: you work with audio files and soon there are different contexts of what \"an audio\" actually is in same solution. \nThis on one side is more obvious through typing, though while Python has classes and typing, but it is less explicit in the code like in Java. I think this occurs in any untyped language.\nMy question is how to have less ambiguous variable names and whether there is something like an official and widely accepted guideline or even a standard like PEP\/RFC for that or comparable.\nExamples for variables:\n\nA string type to designate the path\/filename of the actual audio file\nA file handle for the above to do the I\/O\nThen, in the package pydub, you deal with the type AudioSegment\nWhile in the package moviepy, you deal with the type AudioFileClip\n\nUsing all the four together, requires in my eyes for a clever naming strategy, but maybe I just oversee something. \nMaybe this is a quite exocic example, but if you think of any other media types, this should provide a more broad view angle. Likewise, is a Document a handle, a path or an abstract object?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":52533609,"Users Score":0,"Answer":"There is no definitive standard\/rfc to name your variables.  One option is to prefix\/suffix your variables with a (possibly short form) type.  For example, you can name a variable as foo_Foo where variable foo_Foo is of type Foo.","Q_Score":0,"Tags":"python,variables,naming-conventions,typing","A_Id":52533696,"CreationDate":"2018-09-27T09:20:00.000","Title":"Choosing best semantics for related variables in an untyped language like Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"while running my .....python manage.py\n\nTraceback (most recent call last):   File \"manage.py\", line 10, in\n  \n      execute_from_command_line(sys.argv)   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/core\/management\/init.py\",\n  line 364, in execute_from_command_line\n      utility.execute()   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/core\/management\/init.py\",\n  line 338, in execute\n      django.setup()   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/init.py\",\n  line 27, in setup\n      apps.populate(settings.INSTALLED_APPS)   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/apps\/registry.py\",\n  line 85, in populate\n      app_config = AppConfig.create(entry)   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/apps\/config.py\",\n  line 94, in create\n      module = import_module(entry)   File \"\/usr\/lib\/python2.7\/importlib\/init.py\", line 37, in import_module\n      import(name) ImportError: No module named djorm_pgtrgm","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":800,"Q_Id":52534235,"Users Score":0,"Answer":"Try to make sure that django is installed for the right version of python (it seems you're running python 2, check if you only installed for pyhton 3, or the other way around)","Q_Score":0,"Tags":"python,django","A_Id":52534550,"CreationDate":"2018-09-27T09:53:00.000","Title":"Django Showing Error while running manage.py file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"while running my .....python manage.py\n\nTraceback (most recent call last):   File \"manage.py\", line 10, in\n  \n      execute_from_command_line(sys.argv)   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/core\/management\/init.py\",\n  line 364, in execute_from_command_line\n      utility.execute()   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/core\/management\/init.py\",\n  line 338, in execute\n      django.setup()   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/init.py\",\n  line 27, in setup\n      apps.populate(settings.INSTALLED_APPS)   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/apps\/registry.py\",\n  line 85, in populate\n      app_config = AppConfig.create(entry)   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/apps\/config.py\",\n  line 94, in create\n      module = import_module(entry)   File \"\/usr\/lib\/python2.7\/importlib\/init.py\", line 37, in import_module\n      import(name) ImportError: No module named djorm_pgtrgm","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":800,"Q_Id":52534235,"Users Score":0,"Answer":"Have you used the command python manage.py runserver","Q_Score":0,"Tags":"python,django","A_Id":60673640,"CreationDate":"2018-09-27T09:53:00.000","Title":"Django Showing Error while running manage.py file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"while running my .....python manage.py\n\nTraceback (most recent call last):   File \"manage.py\", line 10, in\n  \n      execute_from_command_line(sys.argv)   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/core\/management\/init.py\",\n  line 364, in execute_from_command_line\n      utility.execute()   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/core\/management\/init.py\",\n  line 338, in execute\n      django.setup()   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/init.py\",\n  line 27, in setup\n      apps.populate(settings.INSTALLED_APPS)   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/apps\/registry.py\",\n  line 85, in populate\n      app_config = AppConfig.create(entry)   File \"\/home\/devbase\/env\/local\/lib\/python2.7\/site-packages\/django\/apps\/config.py\",\n  line 94, in create\n      module = import_module(entry)   File \"\/usr\/lib\/python2.7\/importlib\/init.py\", line 37, in import_module\n      import(name) ImportError: No module named djorm_pgtrgm","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":800,"Q_Id":52534235,"Users Score":0,"Answer":"First check for clear installation of django. And fire correct query at correct path. Open your cmd , go to the path were you placed your manage.py file is. And then fire query python manage.py runserver.","Q_Score":0,"Tags":"python,django","A_Id":62067712,"CreationDate":"2018-09-27T09:53:00.000","Title":"Django Showing Error while running manage.py file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Mezzanine blog under development, hosted at Heroku.\nWhile I have it on debug mode, by ensuring settings.py has DEBUG = True, everything works like a charm.\nWhen I set it to false, any attempt to access admin gives me the generic error message. All other aspects of the site works fine, including blog posts I've made (with DEBUG = True) for testing.\nI'm looking for any of two forms of help:\n\nHow could I get better debugging information while having DEBUG =\nFalse in settings.py?\nAny hint or suggestion about what could be the problem.\n\nEdit: My static files are being served with White Noise, locally, without any problem.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":39,"Q_Id":52535073,"Users Score":2,"Answer":"A couple of months late, but for posterity: I found the same issue with Mezzanine 4.3.1 on Heroku. Without delving under the hood of the Mezzanine source code, using version 4.2.3 works fine.","Q_Score":0,"Tags":"python,django,heroku,mezzanine","A_Id":54923381,"CreationDate":"2018-09-27T10:37:00.000","Title":"Mezzanine only loads admin pages on debug","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to build a multidimensional gaussian model using scipy.stats.multivariate_normal. I am trying to use the output of scipy.stats.multivariate_normal.pdf() to figure out if a test value fits reasonable well in the observed distribution.\nFrom what I understand, high values indicate a better fit to the given model and low values otherwise.\nHowever, in my dataset, I see extremely large PDF(x) results, which lead me to question if I understand things correctly. The area under the PDF curve must be 1, so very large values are hard to comprehend.\nFor e.g., consider:\nx = [-0.0007569417915494715, -0.01394295997613827, 0.000982078369890444, -0.03633664354397629, -0.03730583036106844, 0.013920453054506978, -0.08115836865224338, -0.07208494497398354, -0.06255237023298793, -0.0531888840386906, -0.006823760545565131] \nmean = [0.01663645201261102, 0.07800335614699873, 0.016291452384234965, 0.012042931155488702, 0.0042637244100103885, 0.016531331606477996, -0.021702714746699842, -0.05738646649459681, 0.00921296058625439, 0.027940994009345254, 0.07548111758006244]\ncovariance = [[0.07921927017771506, 0.04780185747873293, 0.0788086850274493, 0.054129466248481264, 0.018799028456661045, 0.07523731808137141, 0.027682748950487425, -0.007296954729572955, 0.07935165417756569, 0.0569381100965656, 0.04185848489472492], [0.04780185747873293, 0.052300105044833595, 0.047749467098423544, 0.03254872837949123, 0.010582358713999951, 0.045792252383799206, 0.01969282984717051, -0.006089301208961258, 0.05067712814145293, 0.03146214776997301, 0.04452949330387575], [0.0788086850274493, 0.047749467098423544, 0.07841809405745602, 0.05374461924031552, 0.01871005609017673, 0.07487015790787396, 0.02756781074862818, -0.007327131572569985, 0.07895548129950304, 0.056417456686115544, 0.04181063355048408], [0.054129466248481264, 0.03254872837949123, 0.05374461924031552, 0.04538801863296238, 0.015795381235224913, 0.05055944754764062, 0.02017033995851422, -0.006505939129684573, 0.05497361331950649, 0.043858860182247515, 0.029356699144606032], [0.018799028456661045, 0.010582358713999951, 0.01871005609017673, 0.015795381235224913, 0.016260640022897347, 0.015459548918222347, 0.0064542528152879705, -0.0016656858963383602, 0.018761682220822192, 0.015361512546799405, 0.009832025009280924], [0.07523731808137141, 0.045792252383799206, 0.07487015790787396, 0.05055944754764062, 0.015459548918222347, 0.07207012779105286, 0.026330967917717253, -0.006907504360835279, 0.0753380831201204, 0.05335128471397023, 0.03998397595850863], [0.027682748950487425, 0.01969282984717051, 0.02756781074862818, 0.02017033995851422, 0.0064542528152879705, 0.026330967917717253, 0.020837940236441078, -0.003320408544812026, 0.027859582829638897, 0.01967636950969646, 0.017105000942890598], [-0.007296954729572955, -0.006089301208961258, -0.007327131572569985, -0.006505939129684573, -0.0016656858963383602, -0.006907504360835279, -0.003320408544812026, 0.024529061074105817, -0.007869287828047853, -0.006228903058681195, -0.0058974553248417995], [0.07935165417756569, 0.05067712814145293, 0.07895548129950304, 0.05497361331950649, 0.018761682220822192, 0.0753380831201204, 0.027859582829638897, -0.007869287828047853, 0.08169291677188911, 0.05731196406065222, 0.04450058445993234], [0.0569381100965656, 0.03146214776997301, 0.056417456686115544, 0.043858860182247515, 0.015361512546799405, 0.05335128471397023, 0.01967636950969646, -0.006228903058681195, 0.05731196406065222, 0.05064023101024737, 0.02830810316675855], [0.04185848489472492, 0.04452949330387575, 0.04181063355048408, 0.029356699144606032, 0.009832025009280924, 0.03998397595850863, 0.017105000942890598, -0.0058974553248417995, 0.04450058445993234, 0.02830810316675855, 0.040658283674780395]]\nFor this, if I compute y = multivariate_normal.pdf(x, mean, cov);\nthe result is 342562705.3859754.\nHow could this be the case? Am I missing something?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1012,"Q_Id":52536206,"Users Score":0,"Answer":"This is fine. The probability density function can be larger than 1 at a specific point. It's the integral than must be equal to 1. \nThe idea that pdf < 1 is correct for discrete variables. However, for continuous ones, the pdf is not a probability. It's a value that is integrated to a probability. That is, the integral from minus infinity to infinity, in all dimensions, is equal to 1.","Q_Score":0,"Tags":"python,scipy","A_Id":52536297,"CreationDate":"2018-09-27T11:42:00.000","Title":"Understanding the output of scipy.stats.multivariate_normal","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any practical difference between list(iterable) and [*iterable] in versions of Python that support the latter?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":489,"Q_Id":52539466,"Users Score":0,"Answer":"There's always going to be some differences between two constructs that do the same thing. Thing is, I wouldn't say the differences in this case are actually practical. Both are expressions that take the iterable, iterate through it and then create a list out of it. \nThe contract is the same: input is an iterable output is a list populated by the iterables elements. \nYes, list can be rebound to a different name; list(it) is a function call while [*it] is a list display; [*it] is faster with smaller iterables but generally performs the same with larger ones. Heck, one could even throw in the fact that [*it] is three less keystrokes.\nAre these practical though? Would I think of them when trying to get a list out of an iterable? Well, maybe the keystrokes in order to stay under 79 characters and get the linter to shut it up.","Q_Score":7,"Tags":"python,python-3.x,list,iterable,python-internals","A_Id":52543801,"CreationDate":"2018-09-27T14:34:00.000","Title":"list() vs iterable unpacking in Python 3.5+","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using holoviews and bokeh with python 3 to create an interactive network graph fro mNetworkx. I can't manage to set the edge color to blank. It seems that the edge_color option does not exist. Do you have any idea how I could do that?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":284,"Q_Id":52539639,"Users Score":1,"Answer":"Problem solved, the option to change edges color is edge_line_color and not edge_color.","Q_Score":0,"Tags":"python,networkx,bokeh,holoviews","A_Id":52539914,"CreationDate":"2018-09-27T14:44:00.000","Title":"Holoviews - network graph - change edge color","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want Pipenv to make virtual environment in the same folder with my project (Django).\nI searched and found the PIPENV_VENV_IN_PROJECT option but I don't know where and how to use this.","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":36278,"Q_Id":52540121,"Users Score":58,"Answer":"This maybe help someone else.. I find another easy way to solve this!\nJust make empty folder inside your project and name it .venv\nand pipenv will use this folder.","Q_Score":58,"Tags":"python,pipenv","A_Id":60234402,"CreationDate":"2018-09-27T15:09:00.000","Title":"Make Pipenv create the virtualenv in the same folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want Pipenv to make virtual environment in the same folder with my project (Django).\nI searched and found the PIPENV_VENV_IN_PROJECT option but I don't know where and how to use this.","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":36278,"Q_Id":52540121,"Users Score":2,"Answer":"For posterity's sake, if you find pipenv is not creating a virtual environment in the proper location, you may have an erroneous Pipfile somewhere, confusing the pipenv shell call - in which case I would delete it form path locations that are not explicitly linked to a repository.","Q_Score":58,"Tags":"python,pipenv","A_Id":68628989,"CreationDate":"2018-09-27T15:09:00.000","Title":"Make Pipenv create the virtualenv in the same folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a tkinter listbox, when I select a item it performs a few actions then returns the results, while that is happening the item I selected does not show as selected, is there a way to force it to show selected immediately so it's obvious to the user they selected the correct one while waiting on the returned results? I'm using python 3.4 and I'm on a windows 7 machine.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":52540413,"Users Score":0,"Answer":"The item does show as selected right away because the time consuming actions are executed before updating the GUI. You can force the GUI to update before executing the actions by using window.update_idletasks().","Q_Score":0,"Tags":"python,tkinter,listbox","A_Id":52550908,"CreationDate":"2018-09-27T15:26:00.000","Title":"Force tkinter listbox to highlight item when selected before task is started","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can we parse the output from DataFrame.describe()? When we print the result of DataFrame.describe() as shown in examples, it is in string format, which is why it is difficult to parse it.\nI understand that the print function might be converting the output into a displayable and readable form. However, it is not easily parseable. How can we achieve this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":110,"Q_Id":52544301,"Users Score":1,"Answer":"print always prints in string format. \nBut if you check type(df.describe()) then you'll see that it is a dataframe. \nSo you can treat it like one. :)","Q_Score":0,"Tags":"python,pandas,dataframe,sklearn-pandas","A_Id":52544455,"CreationDate":"2018-09-27T19:59:00.000","Title":"How can we parse DataFrame.describe()?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to find the number of rows that have certain values such as None or \"\" or NaN (basically empty values) in all columns of a DataFrame object. How can I do this?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":875,"Q_Id":52544340,"Users Score":2,"Answer":"Use df.isnull().sum() to get number of rows with None and NaN value.\nUse df.eq(value).sum() for any kind of values including empty string \"\".","Q_Score":1,"Tags":"python,pandas,dataframe,sklearn-pandas","A_Id":52544615,"CreationDate":"2018-09-27T20:02:00.000","Title":"In Python DataFrame how to find out number of rows that have valid values of columns","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In which deployment mode can we Not add Nodes\/workers to a cluster in Apache Spark 2.3.1\n1.Spark Standalone\n2.Mesos\n3.Kubernetes\n4.Yarn\n5.Local Mode\ni have installed Apache Spark 2.3.1 on my machine and have run it in Local Mode\nin Local Mode can we add Nodes\/workers to Apache Spark?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":52544955,"Users Score":0,"Answer":"When master is Local, your program will run on single machine that is your edge node.\nTo run it in distributed environment i.e. on cluster you need to select master as \"Yarn\".\nWhen deployment mode is \"client\" (default) your edge node will become the master (where driver program will run).\nWhen deployment mode is \"cluster\", any of the healthy node from the cluster becomes master","Q_Score":1,"Tags":"python-2.7,apache-spark,cluster-computing,worker","A_Id":52555122,"CreationDate":"2018-09-27T20:52:00.000","Title":"In which deployment mode can we \"Not\" add nodes to a cluster in Apache Spark 2.3.1","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I started learning Python and I noticed that the website teaching me will usually write like this:\nvariable = 4 + 5\nhowever even if I write:\nvariable=4+5\nI still get no errors and it runs properly.\nSo are those spaces are important or not?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":39,"Q_Id":52548671,"Users Score":-1,"Answer":"In Python, you use white spaces, where other languages uses brackets (), and Python uses enter instead of curly brackets {} and semicolons ;\nPython ignores other enters and white spaces.","Q_Score":1,"Tags":"python","A_Id":52548732,"CreationDate":"2018-09-28T05:09:00.000","Title":"In Python, are the spaces important to code variable = 4 + 5 Or is it fine to code it as variable=4+5?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a script to simultaneously accept many files transfers from many computers on a subnet using sockets (around 40 jpg files total). I want to use multithreading or multiprocessing to make the the transfer occur as fast as possible.\nI'm wondering if this type of image transfer is limited by the CPU - and therefore I should use multiprocessing - or if multithreading will be just as good here.\nI would also be curious as to what types of activities are limited by the CPU and require multiprocessing, and which are better suited for multithreading.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":884,"Q_Id":52549069,"Users Score":1,"Answer":"If the following assumptions are true:\n\nYour script is simply receiving data from the network and writing that data to disk (more or less) verbatim, i.e. it isn't doing any expensive processing on the data\nYour script is running on a modern CPU with typical modern networking hardware (e.g. gigabit Ethernet or slower)\nYour script's download routines are not grossly inefficient (e.g. you are receiving reasonably-sized chunks of data and not just 1 byte at a time or something silly like that)\n\n... then it's unlikely that your download rate will be CPU-limited.  More likely the bottleneck will be either network bandwidth or disk I\/O bandwidth.\nIn any case, since AFAICT your use-case is embarrassingly parallel (i.e. the various downloads never have to communicate or interact with each other, they just each do their own thing independently), it's unlikely that using multithreading vs multiprocessing will make much difference in terms of performance.  Of course, the only way to be certain is to try it both ways and measure the throughput each way.","Q_Score":0,"Tags":"python,multithreading,sockets,multiprocessing","A_Id":52549860,"CreationDate":"2018-09-28T05:48:00.000","Title":"Does multiprocessing speed up file transfers compared to multithreading","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a script to simultaneously accept many files transfers from many computers on a subnet using sockets (around 40 jpg files total). I want to use multithreading or multiprocessing to make the the transfer occur as fast as possible.\nI'm wondering if this type of image transfer is limited by the CPU - and therefore I should use multiprocessing - or if multithreading will be just as good here.\nI would also be curious as to what types of activities are limited by the CPU and require multiprocessing, and which are better suited for multithreading.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":884,"Q_Id":52549069,"Users Score":1,"Answer":"Short answer:\nGenerally, it really depends on your workload. If you're serious on the performance, please provide details. for example, whether you store images to disk, whether image sizes are > 1GB or not, and etc. \nNote: Generally again, if it not mission-critical, both ways are acceptable since we can easily switch between multithread and multiprocess implementations using threading.Thread and multiprocessing.Process.\nsome more comments\nIt seems that not CPU but IO will be the bottleneck.\nFor multiprocess \/ multithread, due to GIL and\/or your implementation, we may have performance difference. You may implement both ways and make try. BTW, IMHO it won't differ much. I think that async IO vs blocking IO will have greater impact.","Q_Score":0,"Tags":"python,multithreading,sockets,multiprocessing","A_Id":52549868,"CreationDate":"2018-09-28T05:48:00.000","Title":"Does multiprocessing speed up file transfers compared to multithreading","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a script to simultaneously accept many files transfers from many computers on a subnet using sockets (around 40 jpg files total). I want to use multithreading or multiprocessing to make the the transfer occur as fast as possible.\nI'm wondering if this type of image transfer is limited by the CPU - and therefore I should use multiprocessing - or if multithreading will be just as good here.\nI would also be curious as to what types of activities are limited by the CPU and require multiprocessing, and which are better suited for multithreading.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":884,"Q_Id":52549069,"Users Score":0,"Answer":"If your file transfer isn't extremely slow - slower than writing data to disk, multithreading\/multiprocessing isn't going to help. By file transfer I mean downloading images and writing them to the local computer with a single HDD.\nUsing multithreading or multiprocessing when transferring data from several computers with separate disks definitely can improve overall download performance. Simply data read from several physical disks can be read in paralel. The problem arises when you try to save these images to your local drive.\nYou have just a single local HDD (if disk array not used), single HDD like most HW devices can do just a single IO operation at time. So trying to write several images to disk in the same time won't improve the overal performance - it can even hamper it.\nJust imagine that 40 already downloaded images are trying to be written to a single mechanical HDD with single HDD head to different locations (different physical files) especially if disk is fragmented. Then this can even slow down the whole process because HDD is wasting time moving it magnetic head from one position to different (drives can partially mitigate this by reordering IO operation to limit head movement).\nOn the other hand if you do some preprocessing with these images that is CPU intensive and just then you are going to save them to disk, multithreading can be really helpful.\nAnd to the question what's preferred. On modern OSs there is not a significant difference between using multithreading and multiprocessing (spanning multiple processes). OSs like Linux or Windows schedule threads not processes - based on process and thread priorities. So there is not a big difference between 40 single threaded processes and a single process containing 40 threads. Using multiple processes normally consumes more memory because OS for every process has to allocate some extra memory (not big), but from point of speed difference between multithreading and multiprocessing is not significant. There are other important question to consider which method to use (will these downloads share some data - like common GUI interface - multithreading is easier to use), (are these files to download so big that 40 transfers can exhaust all virtual address space of a single process - use multiprocessing).\nGenerally:\nMultithreading - easier to use in single application because all threads share virtual address space of a single process and can easily communicate with each other. On the other hand single process has a limited size of virtual address space (less than 4GB on 32bit computer).\nMultiprocessing - harder to use in a single application (a need of inter-process communication), but more scalable and more robust (if file transfer process crashes only a single file transfer fails) + more virtual address space to use.","Q_Score":0,"Tags":"python,multithreading,sockets,multiprocessing","A_Id":52562736,"CreationDate":"2018-09-28T05:48:00.000","Title":"Does multiprocessing speed up file transfers compared to multithreading","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm newbe of Sphinx,\nI tried to use html_theme = 'sphinx_rtd_theme' in conf.py\nbut I get message below when I run \"make html\" :\n\nsphinx_rtd_theme is no longer a hard dependency since version 1.4.0. Please install it manually.(pip install sphinx_rtd_theme)\n\nI already installed it with pip install sphinx_rtd_them \n(part of pip list)\n\nPackage                  Version \n\nalabaster                0.7.11 \n  sphinx-rtd-theme         0.4.1 \n  Sphinx                   1.8.1  \n\nAlso I installed sphinx-doc with brew.\nAnybody with same issue?? \nAnother things to know is...My ubuntu PC works perfectly,\n but not works on Macbook pro...","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":710,"Q_Id":52552081,"Users Score":1,"Answer":"Ok...WTF...I have no idea how it works,\nBut I ran \n\nbrew remove sphinx-doc\n\nand \"make html\" worked,\nIf anyone can answer why and how this happened, please let me know...","Q_Score":2,"Tags":"python,python-sphinx","A_Id":52552216,"CreationDate":"2018-09-28T09:17:00.000","Title":"sphinx not able to find sphinx_rtd_theme","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm trying to write my REST API in Django so that if someone makes a patch or post it will require someone with access to Django's admin panel to actually write the changes, but it'll be pending and visible to the admin till then, is this possible? Or do I have to create a model for the pending request then make the patch and post create new entities?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":935,"Q_Id":52552838,"Users Score":0,"Answer":"You have to store the request user somewhere, several solutions:\n\nA new model in your database\nA new field is_validated on your model\nStore that in cache (not safe)","Q_Score":3,"Tags":"python,django,rest,django-rest-framework,admin","A_Id":52552913,"CreationDate":"2018-09-28T09:59:00.000","Title":"Django: Require admin approval for patch and post","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to write my REST API in Django so that if someone makes a patch or post it will require someone with access to Django's admin panel to actually write the changes, but it'll be pending and visible to the admin till then, is this possible? Or do I have to create a model for the pending request then make the patch and post create new entities?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":935,"Q_Id":52552838,"Users Score":0,"Answer":"I agree with everything that @Zulu said in his answer (except using the cache, don't think that would be a great idea).\nI think your best bet would be (assuming I understand your overall goal) would be to create a model that stores the history of changes. From there, every change would be able to maintain state, and then your view\/viewset can simply pull from the data that was most recently validated. Hopefully that makes sense and can help you out overall.","Q_Score":3,"Tags":"python,django,rest,django-rest-framework,admin","A_Id":52555959,"CreationDate":"2018-09-28T09:59:00.000","Title":"Django: Require admin approval for patch and post","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a charge object with information in charge['metadata']['distinct_id']. There could be the case that it's not set, therefore I tried it that way which doesn't work charge.get(['metadata']['distinct_id'], None)\nDo you know how to do that the right way?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":76,"Q_Id":52552848,"Users Score":1,"Answer":"As @blue_note mentioned you could not user two consecutive levels. However your can try something like \ncharge.get('metadata', {}).get('distinct_id')\nhere, you tried to get 'metadata' from charge and if it does not found then it will consider blank dictionary and try to get 'distinct_id' from there (technically it does not exists). In this scenario, you need not to worry about if metadata exists or not. If it exists then it will check for distinct_id from metadata or else it throws None.\nHope this will solve your problem.\nCheers..!","Q_Score":0,"Tags":"python,django","A_Id":52553493,"CreationDate":"2018-09-28T10:00:00.000","Title":".get + dict variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a charge object with information in charge['metadata']['distinct_id']. There could be the case that it's not set, therefore I tried it that way which doesn't work charge.get(['metadata']['distinct_id'], None)\nDo you know how to do that the right way?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":76,"Q_Id":52552848,"Users Score":5,"Answer":"You don't say what the error is, but, two things possibly wrong\n\nit should be charge.get('metadata', None)\nyou can't directly do it on two consecutive levels. If the metadata key returns None, you can't go on and ask for the distinct_id key. You could return an empty dict and apply get to that, eg something like charge.get('metadata', {}).get('distinct_id', None)","Q_Score":0,"Tags":"python,django","A_Id":52552937,"CreationDate":"2018-09-28T10:00:00.000","Title":".get + dict variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was working on matching company names of two sets. I was trying to code it in Python with Levenstien's distance. I was having issues with short names of companies, and their trailing part like Pvt,Ltd. I have ran the same set with Excel Fuzzy lookup and was getting good results. I there a way that i can see how excel fuzzy lookup is coded and use the same implementation in python.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2872,"Q_Id":52553735,"Users Score":2,"Answer":"The following is an excerpt from Microsoft Fuzzy Lookup Add-In for Excel, Readme.docx. I hope that helps.\n\nAdvanced Concepts\nFuzzy Lookup technology is based upon a very simple, yet flexible\n  measure of similarity between two records. Jaccard similarity  Fuzzy\n  Lookup uses Jaccard similarity, which is defined as the size of the\n  set intersection divided by the size of the set union for two sets of\n  objects. For example, the sets {a, b, c} and {a, c, d} have a Jaccard\n  similarity of 2\/4 = 0.5 because the intersection is {a, c} and the\n  union is {a, b, c, d}. The more that the two sets have in common, the\n  closer the Jaccard similarity will be to 1.0. \nWeighted Jaccard similarity and tokenization of records  With Fuzzy\n  Lookup, you can assign weights to each item in a set and define the\n  weighted Jaccard similarity as the total weight of the intersection\n  divided by the total weight of the union. For the weighted sets {(a,\n  2), (b, 5), (c, 3)}, {(a, 2), (c, 3), (d, 7)}, the weighted Jaccard\n  similariyt is (2 + 3)\/(2 + 3 + 5 +7) = 5\/17 = .294. \nBecause Jaccard similarity is defined over sets, Fuzzy Lookup must\n  first convert data records to sets before it calculates the Jaccard\n  similarity. Fuzzy Lookup converts the data to sets using a Tokenizer.\n  For example, the record {\u201cJesper Aaberg\u201d, \u201c4567 Main Street\u201d} might be\n  tokenized into the set, {\u201c Jesper\u201d, \u201cAaberg\u201d, \u201c4567\u201d, \u201cMain\u201d,\n  \u201cStreet\u201d}. The default tokenizer is for English text, but one may\n  change the LocaleId property in Configure=>Global Settings to specify\n  tokenizers for other languages.\nToken weighting  Because not all tokens are of equal importance, Fuzzy\n  Lookup assigns weights to tokens. Tokens are assigned high weights if\n  they occur infrequently in a sample of records and low weights if they\n  occur frequently. For example, frequent words such as \u201cCorporation\u201d\n  might be given lower weight, while less frequent words such as\n  \u201cAbracadabra\u201d might be given a higher weight. One may override the\n  default token weights by supplying their own table of token weights.\nTransformations Transformations greatly increase the power of Jaccard\n  similarity by allowing tokens to be converted from one string to\n  another. For instance, one might know that the name \u201cBob\u201d can be\n  converted to \u201cRobert\u201d; that \u201cUSA\u201d is the same as \u201cUnited States\u201d; or\n  that \u201cMissispi\u201d is a misspelling of \u201cMississippi\u201d. There are many\n  classes of such transformations that Fuzzy Lookup handles\n  automatically such as spelling mistakes (using Edit Transformations\n  described below), string prefixes, and string merge\/split operations.\n  You can also specify a table containing your own custom\n  transformations.\nJaccard similarity under transformations  The Jaccard similarity under\n  transformations is the maximum Jaccard similarity between any two\n  transformations of each set. Given a set of transformation rules, all\n  possible transformations of the set are considered. For example, for\n  the sets {a, b, c} and {a, c, d} and the transformation rules {b=>d,\n  d=>e}, the Jaccard similarity is computed as follows: Variations of\n  {a, b, c}: {a, b, c}, {a, d, c} Variations of {a, c, d}: {a, c, d},\n  {a, c, e} Maximum Jaccard similarity between all pairs: J({a, b, c},\n  {a, c, d}) = 2\/4 = 0.5 J({a, b, c}, {a, c, e}) = 2\/4 = 0.5 J({a, d,\n  c}, {a, c, d}) = 3\/3 = 1.0 J({a, d, c}, {a, c, e}) = 2\/4 = 0.5 The\n  maximum is 1.0. Note: Weghted Jaccard similiary under transformations\n  is simply the maximum weighted Jaccard similarity across all pairs of\n  transformed sets. \nEdit distance  Edit distance is the total number of character\n  insertions, deletions, or substitutions that it takes to convert one\n  string to another. For example, the edit distance between \u201cmisissipi\u201d\n  and \u201cmississippi\u201d is 2 because two character insertions are required.\n  One of the transformation providers that\u2019s included with Fuzzy Lookup\n  is the EditTransformationProvider, which generates specific\n  transformations for each input record and creates a transformation\n  from the token to all words in its dictionary that are within a given\n  edit distance. The normalized edit distance is the edit distance\n  divided by the length of the input string. In the previous example,\n  the normalized edit distance is 2\/9 = .222.","Q_Score":2,"Tags":"python,excel,levenshtein-distance,fuzzy-logic","A_Id":57938416,"CreationDate":"2018-09-28T10:49:00.000","Title":"Algorithm used in Excel Fuzzy Lookup","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dag that sets depends_on_past=True. So for most task we want this to hold.\nAnd a particular task A, we set trigger_rule=\"one_failed\"\nThe problem is. This task A don't always get triggered cause it's parents don't always fail. But if it doesn't get triggered everyday (say if we schedule everyday), then depends_on_past condition won't be met.\nMeaning. If day 1 didn't run. Then day 2 if a task fails, it doesn't run!\nHow do I set this BashOperator to ignore depends_on_past rule?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":544,"Q_Id":52554906,"Users Score":1,"Answer":"You can overwrite depends_on_past parameter for specific task instance. So in your case, task A's definition can overwrite depends_on_past=False, while the rest of the tasks within your DAG still run with the value of depends_on_past=True.","Q_Score":1,"Tags":"python,airflow","A_Id":57075134,"CreationDate":"2018-09-28T12:02:00.000","Title":"Airflow setting dag depends on past with trigger rule","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"What is the best way to schedule an event for a month or a year from now?\nFor example, I want my program to send a notification one year after a customer's registration.\nI try to use celery with redis using the eta option but, at some point, the task multiplies and sends the same notification to the same customer (like 600 times). I also think that using a cronjob is not the best option. \nAny suggestions?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":52558051,"Users Score":4,"Answer":"You don't want to push something in the queue that you are not going to read for 1 year.\nStore registration date in the database. Write a program that reads the database and pushes information to a topic. You can run this program everyday and it will find all the people who should be notified.","Q_Score":0,"Tags":"python,django,scheduled-tasks","A_Id":52558161,"CreationDate":"2018-09-28T15:02:00.000","Title":"Schedule task for one year from now","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on a scraper project and one of the goals is to get every image link from HTML & CSS of a website. I was using BeautifulSoup & TinyCSS to do that but now I'd like to switch everything on Selenium as I can load the JS.\nI can't find in the doc a way to target some CSS parameters without having to know the tag\/id\/class. I can get the images from the HTML easily but I need to target every \"background-image\" parameter from the CSS in order to get the URL from it. \nex: background-image: url(\"paper.gif\");\nIs there a way to do it or should I loop into each element and check the corresponding CSS (which would be time-consuming)?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":84,"Q_Id":52558105,"Users Score":1,"Answer":"You can grab all the Style tags and parse them, searching what you look.\nAlso you can download the css file, using the resource URL and parse them.\nAlso you can create a XPATH\/CSS rule for searching nodes that contain the parameter that you're looking for.","Q_Score":1,"Tags":"python,css,selenium,web-scraping,selenium-chromedriver","A_Id":52559637,"CreationDate":"2018-09-28T15:04:00.000","Title":"Selenium Python: How to get css without targetting a specific class\/id\/tag","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"All,\nWriting to see if anyone has any input on what they feel the best tech would be for the following scenario. Be it python, solr, redis, memcache, etc.\nThe situation is as follows.\nI have 100 million+ binary strings which are around 1100 characters long...\n'0010100010101001010101011....'\nWhat in your opinion would be the most logical way to do the following?\nFor a given string of the same number of characters, what would be the most efficient way to find the closest match? By closest, I mean sharing the greatest number of 0's and 1's at a given position. Hamming Distance, I believe.\nMy use case would actually involve taking 100k or so strings and trying to find their best match in the pool of 100 million+ strings.\nAny thoughts? No particular tech has to be used, just preferably something that is fairly common.\nCurious to see what ideas anyone may have. \nThanks,\nTbone","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":52558975,"Users Score":0,"Answer":"You could use numpy, R, or MATLAB, or anything else that works with large matrices for this:\nSay you have a NxM matrix A, where N is len(string) and M is the number of strings. And say you have a string S you're trying to match. You could:\n\nSubtract the array version of S from A \nTake the the absolute value of all the elements of the result of (1)\nSum the result of (2) along the axis of N\nArgsort the result of (3) to find the indexes of the strings that have the lowest distance to S.","Q_Score":0,"Tags":"python,elasticsearch,solr,redis,memcached","A_Id":52559199,"CreationDate":"2018-09-28T16:00:00.000","Title":"Comparing Large Number of Binary Strings","Data Science and Machine Learning":0,"Database and SQL":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":"All,\nWriting to see if anyone has any input on what they feel the best tech would be for the following scenario. Be it python, solr, redis, memcache, etc.\nThe situation is as follows.\nI have 100 million+ binary strings which are around 1100 characters long...\n'0010100010101001010101011....'\nWhat in your opinion would be the most logical way to do the following?\nFor a given string of the same number of characters, what would be the most efficient way to find the closest match? By closest, I mean sharing the greatest number of 0's and 1's at a given position. Hamming Distance, I believe.\nMy use case would actually involve taking 100k or so strings and trying to find their best match in the pool of 100 million+ strings.\nAny thoughts? No particular tech has to be used, just preferably something that is fairly common.\nCurious to see what ideas anyone may have. \nThanks,\nTbone","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":52558975,"Users Score":0,"Answer":"You are basically trying to conduct nearest neighbor search in Hamming space on Elasticsearch. \nRegarding this, a recently proposed FENSHSES method from [1] seems to be the state-of-the-art one on Elasticsearch.\n[1] Mu, C, Zhao, J., Yang, G., Yang, B. and Yan, Z., 2019, October. Fast and Exact Nearest Neighbor Search in Hamming Space on Full-Text Search Engines. In International Conference on Similarity Search and Applications (pp. 49-56). Springer, Cham.","Q_Score":0,"Tags":"python,elasticsearch,solr,redis,memcached","A_Id":59490564,"CreationDate":"2018-09-28T16:00:00.000","Title":"Comparing Large Number of Binary Strings","Data Science and Machine Learning":0,"Database and SQL":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 connecting the mongodb database via pymongo and achieved the expected result of fetching it outside the db in json format . but my task is that i need to create a hive table via pyspark , I found that mongodb provided json (RF719) which spark is not supporting .when i tried to load the data in pyspark (dataframe) it is showing as corrupted record. . and if any possible ways of converting the json format in python is also fine ..Please suggest a response","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":208,"Q_Id":52559131,"Users Score":0,"Answer":"mport json with open('D:\/json\/aaa.json') as f: d = f.read() da = ''.join(d.split()) print(type(da)) print(da) daa=da.replace('u'','') daaa= json.loads(daa) print(daaa)\nsatisfied with the answer. Hence closing this question","Q_Score":1,"Tags":"python,mongodb,hive,pymongo,pyspark-sql","A_Id":63618206,"CreationDate":"2018-09-28T16:10:00.000","Title":"unable to read the mongodb data (json) in pyspark","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the MongoDB console, I know that you can use $ last and $ natural. In PyMongo, I could not use it, maybe I was doing something wrong?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3599,"Q_Id":52559576,"Users Score":1,"Answer":"Another way is:\ndb.collection.find().limit(1).sort([('$natural',-1)])\nThis seemed to work best for me.","Q_Score":1,"Tags":"python,pymongo","A_Id":65854155,"CreationDate":"2018-09-28T16:43:00.000","Title":"PyMongo how to get the last item in the collection?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The question related to python - django framework, and probably to experienced django developers. Googled it for some time, also seeked in django queryset itself, but have no answer. Is it possible to know if queryset has been filtered and if so, get key value of filtered parameters?\nI'm developing web system with huge filter set, and I must predefine some user-background behavior if some filters had been affected.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":787,"Q_Id":52559970,"Users Score":2,"Answer":"You can use the query attribute (i.e. queryset.query) to get the data used in the SQL query (the output isn't exactly valid SQL).\nYou can also use queryset.query.__dict__ to get that data in a dictionary format.","Q_Score":1,"Tags":"python,django,filter,django-queryset","A_Id":52560064,"CreationDate":"2018-09-28T17:11:00.000","Title":"Django - was queryset filtered using some parameters or not","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This is in python. I'm new to python, but not to programming. \nx = [2, 0, 0 , 0x40, 0x25, 6, 3]\nI want to turn it into a string of the format\nx2 = \"\\0x02\\0x00\\0x00\\0x40\\0x25\\0x06\\0x03\"\nThe binary values from the list are in the string. I can do it with brute force, but there has to be a better way to do it.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":93,"Q_Id":52561364,"Users Score":1,"Answer":"Here is one problem... I should have had \"\\x02\\x00\\x00\\x40\" and so on  instead of \"\\0x02\\0x00\\0x00\\0x40\" and so on. The problem was the \"**0**x\". So the wrong thing was in the string in the first place.\nThe brute force method is:\nx2 = \"\"\nfor i in x\n   x2 = x2 + chr(i)\nx2 now is a string with the correct values. There should be a better way.","Q_Score":0,"Tags":"python,list","A_Id":52563143,"CreationDate":"2018-09-28T19:10:00.000","Title":"Convert list of numbers into a string in Python containing the actual values","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem. In Tkinter there are two widgets: Text and Entry. The Text widget has a configuration wrap='word'. And the Entry widget has a method select_range. I need both the wrap configuration and the select_range method in order to select certain parts of a massive text (by select I mean like with the mouse).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":22,"Q_Id":52563605,"Users Score":1,"Answer":"There is no direct way to combine the features of two different widgets, but there's really no need to do that. All you're asking for is the ability to select a range of text, and the text widget supports that. \nThe method to select a range of characters is documented. All you need to do is add the tag \"sel\" to a range of characters.","Q_Score":0,"Tags":"python-3.x,tkinter","A_Id":52563624,"CreationDate":"2018-09-28T23:03:00.000","Title":"Is there a way to create a widget with configuration wrap and select_range method?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to concatenate two tuples using the overloaded + operator in Python 3.6. I don't have an issue if I include the parenthesis like the first example, but if I leave off the parenthesis as in the second example, I get an error. The message I get is \"bad operand type for unary +: 'tuple'\". Can anyone explain what is happening?\n\nnewtup = (3,) + (2,4)\nnewtup = 3, + (2,4)","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":91,"Q_Id":52563793,"Users Score":3,"Answer":"It's trying to parse the second line as\n(3, + (2,4))\nThen, it's seeing that you used the unary +, as in a = +5, with a tuple. This isn't allowed, and thus you get an error. Commas are given very wide precedence (ie they consume as many characters as possible, closer to a + than a *). The reason behind this is that (biglongexpression1, biglongexpression2) should never mix the two biglongexpressions. Everything else is more important and should be evaluated before a comma, and thus +(2,4) is evaluated before the comma - because it's a biglongexpression.","Q_Score":1,"Tags":"python,tuples","A_Id":52563827,"CreationDate":"2018-09-28T23:44:00.000","Title":"why can't I concatenate these two tuples?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to concatenate two tuples using the overloaded + operator in Python 3.6. I don't have an issue if I include the parenthesis like the first example, but if I leave off the parenthesis as in the second example, I get an error. The message I get is \"bad operand type for unary +: 'tuple'\". Can anyone explain what is happening?\n\nnewtup = (3,) + (2,4)\nnewtup = 3, + (2,4)","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":91,"Q_Id":52563793,"Users Score":0,"Answer":"Unary operator + expects valid a operand (int, float etc) on the right side. \nIn your code 3, + (2, 4), you are providing a tuple (2, 4) as an operand to + which is not a valid operand and so is the error.\nIn your code: \nnewtup = (3,) + (2, 4)\nThese are 2 separate tuples (3,) and (2,4), so it works.\nnewtup = 3, + (2, 4)\nHere its a single tuple with 2 elements 3 and +(2, 4) which fails due to above mentioned reason.","Q_Score":1,"Tags":"python,tuples","A_Id":52566686,"CreationDate":"2018-09-28T23:44:00.000","Title":"why can't I concatenate these two tuples?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to concatenate two tuples using the overloaded + operator in Python 3.6. I don't have an issue if I include the parenthesis like the first example, but if I leave off the parenthesis as in the second example, I get an error. The message I get is \"bad operand type for unary +: 'tuple'\". Can anyone explain what is happening?\n\nnewtup = (3,) + (2,4)\nnewtup = 3, + (2,4)","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":91,"Q_Id":52563793,"Users Score":4,"Answer":"It's a precedence issue. 3, + (2, 4) is parsed as a tuple with elements 3 and +(2, 4), not as adding 3, and (2, 4). You need the parentheses.","Q_Score":1,"Tags":"python,tuples","A_Id":52563818,"CreationDate":"2018-09-28T23:44:00.000","Title":"why can't I concatenate these two tuples?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am an R user currently learning python.\nIn RStudio, when I type a piece of code, it automatically gives me predictions of the functions I am looking for - like an autocomplete.\nI would like to have something similar in Jupyter Lab. Is it possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":200,"Q_Id":52568135,"Users Score":0,"Answer":"Auto-completion is supported in Jupyter already. You could try type enu and then hit tab. This enumerate will prompt out automatically.","Q_Score":0,"Tags":"python,rstudio,jupyter,jupyter-lab","A_Id":53070860,"CreationDate":"2018-09-29T11:57:00.000","Title":"Predicting python script in Jupyter Lab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I intent to implement image captioning. Would it be possible to transfer learning for LSTM? I have used pretrained VGG16(transfer learning) to Extract features as input of the LSTM.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":289,"Q_Id":52568209,"Users Score":-1,"Answer":"As I have discovered, we can't use Transfer learning on the LSTM weights. I think the causation is infra-structure of LSTM networks.","Q_Score":0,"Tags":"python-3.x,conv-neural-network,lstm","A_Id":52700217,"CreationDate":"2018-09-29T12:08:00.000","Title":"how can I use Transfer Learning for LSTM?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering if there is way to get the sequence of proteins from uniprot protein ids. I did check few online softwares but they allow to get one sequence at a time but I have 5536 vlues. Is there any package in biopython to do this?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4213,"Q_Id":52569622,"Users Score":0,"Answer":"You can probably iterate over your list of values, calling the required method from the library each time.","Q_Score":5,"Tags":"python,bioinformatics,biopython","A_Id":52569640,"CreationDate":"2018-09-29T15:04:00.000","Title":"Protein sequence from uniprot protein id python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In a Linux directory, I have several numbered files, such as \"day1\" and \"day2\". My goal is to write a code that retrieves the number from the files and add 1 to the file that has the biggest number and create a new file. So, for example, if there are files, 'day1', 'day2' and 'day3', the code should read the list of files and add 'day4'. To do so, at least I need to know how to retrieve the numbers on the file name.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":52572007,"Users Score":0,"Answer":"Get all files with the os module\/package (don't have the exact command handy) and then use regex(package) to get the numbers. If you don't want to look into regex you could remove the letters  from your string with replace() and convert that string with int().","Q_Score":0,"Tags":"python,linux,python-3.x,file,ubuntu","A_Id":52572081,"CreationDate":"2018-09-29T19:52:00.000","Title":"Is there any way to retrieve file name using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have some pretty fragile code that I want to refactor.  It's not very easy to unit test by itself because it interacts with database queries and Django form data.\nThat in itself is not a big deal. I already have extensive tests that, among other things, end up calling this function and check that results are as expected.  But my full test suite takes about 5 minutes and I also don't want to have to fix other outstanding issues while working on this.\nWhat I'd like to do is to run nosetests or nose2 on all my tests, track all test_xxx.py files that called the function of interest and then limit my testing during the refactoring to only that subset of test files.\nI plan to use inspect.stack() to do this but was wondering if there is an existing plugin or if someone has done it before.  If not, I intend to post whatever I come up with and maybe that will be of use later.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":34,"Q_Id":52572977,"Users Score":1,"Answer":"You can simply raise some exception in the function and do one run. All tests that fail do call you function.","Q_Score":0,"Tags":"python,unit-testing,introspection","A_Id":52573171,"CreationDate":"2018-09-29T22:12:00.000","Title":"finding out which particular tests call some 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The following were what I did in python shell. Can anyone explain the difference?\n\n\n\ndatetime.datetime.now()\n      datetime.datetime(2018, 9, 29, 21, 34, 10, 847635)\nprint(datetime.datetime.now())\n      2018-09-29 21:34:26.900063","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":356,"Q_Id":52574958,"Users Score":1,"Answer":"The first is the result of calling repr on the datetime value, the second is the result of calling str on a datetime.\nThe Python shell calls repr on values other than None before printing them, while print tries str before calling repr (if str fails).\nThis is not dependent on the Python version.","Q_Score":0,"Tags":"python,python-3.x,printing","A_Id":52574995,"CreationDate":"2018-09-30T05:33:00.000","Title":"python 3, how print function changes output?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create virtual environment using python3. But it takes python2 by default. I have both python2 and 3 installed on my machine.\nThe ouput of when I create the virtual environment is:\n$ virtualenv .env\nRunning virtualenv with interpreter \/usr\/bin\/python2\nNew python executable in \/some\/path\/.env\/bin\/python2\nAlso creating executable in \/some\/path\/.env\/bin\/python\nInstalling setuptools, pkg_resources, pip, wheel...done.\nI would like to specify which python version to use in the virtualenv.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":12923,"Q_Id":52575629,"Users Score":1,"Answer":"When using virtualenv these are the usual steps to follow:\nCreate the virtualenv using a specific python version of your liking using the -p or --python arguments\nvirtualenv -p \/usr\/bin\/your-python .\/path-where-to-create-venv\nActivate the virtualenv, in order to install libraries et cetera\nsource .\/venv-path\/bin\/activate\nYou can see that you're working from inside the virtualenv, you can deactivate using\ndeactivate","Q_Score":0,"Tags":"python","A_Id":52575682,"CreationDate":"2018-09-30T07:25:00.000","Title":"How to use python3 in virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to save a series of images to CSV file so they can be used as a training dataset for Alexnet Keras machine learning. The shape is (15,224,224,3).\nSo far I am having issue doing this. I have managed to put all data into a numpy array but now I cannot save it to a file.\nPlease help.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":8759,"Q_Id":52576617,"Users Score":1,"Answer":"You can try using pickle to save the data. It is much more diverse and easy to handle compare to np.save.","Q_Score":3,"Tags":"python,csv,numpy,keras","A_Id":52579026,"CreationDate":"2018-09-30T09:32:00.000","Title":"How to save Numpy 4D array to CSV?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is if you can install python with powershell, cmd, vbs or any other language built into Windows already?\nIf this was already asked please redirect me to the answer.\n\"How to install Python using Windows Command Prompt\" explains how to install the python if you already have the exe installed, not how to install the exe.\n\nEDIT: I am trying to install python with a file on a pc that does not have python installed, only thing restricted might be that the account does not an administrator and if possible in the background.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80507,"Q_Id":52578270,"Users Score":0,"Answer":"Not related to the question directly, but some people may end up here looking for a different solution.\nTo use Python within Powershell:\n\nInstall Python from the Microsoft Store (an App in the programs list)\nOpen the Powershell window\n(can hold SHIFT and right click in the window where your python file is located\n'Open Powershell Window here')\ntype 'python' a space and the name of the file\nExample:\nPS C:\\Users...\\Project> python test.py","Q_Score":14,"Tags":"python,python-3.x,powershell,cmd","A_Id":66979854,"CreationDate":"2018-09-30T13:24:00.000","Title":"Install Python with cmd or powershell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using python's CLI module which takes any do_* method and sets it as a command, so a do_show() method will be executed if the user type \"show\".\nHow can I execute the do_show() method using any variation of capitalization from user input e.g. SHOW, Show, sHoW and so on without giving a Command Not Found error?\nI think the answer would be something to do with overriding the Cmd class and forcing it to take the user's input.lower() but idk how to do that :\/","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":108,"Q_Id":52580345,"Users Score":1,"Answer":"You should override onecmd to achieve desired functionality.","Q_Score":1,"Tags":"python","A_Id":52580602,"CreationDate":"2018-09-30T17:25:00.000","Title":"Python's cmd.Cmd case insensitive 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":"Trying to see if I understand the differences. If I wanted to make a bunch of different cars then I would make a Car class because I need multiple, different instances. If I wanted to use an add, subtract, etc, function then I should make a module since I don't need multiple instances of a calculator I only need to use the functions inside. Is that accurate? What am I missing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":208,"Q_Id":52581710,"Users Score":0,"Answer":"Yes, if you were to make an add, subtract, multiply or divide function it is better not being a class.\nAnd yes, you are right with the car class.\nI don't see how this is Python related.","Q_Score":0,"Tags":"python,class,module","A_Id":52581741,"CreationDate":"2018-09-30T20:09:00.000","Title":"Python module vs class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the 64x64 canvas field with drawn objects (dots, rectangles and etc.). How can I get the list of colors of all pixels on the canvas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":52582051,"Users Score":2,"Answer":"There is no way to get information about individual pixels on the canvas.","Q_Score":1,"Tags":"python,python-3.x,tkinter,tkinter-canvas","A_Id":52582114,"CreationDate":"2018-09-30T20:51:00.000","Title":"How can I get all pixels from canvas?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just installed anaconda3 5.2.0 with vscode 1.27.2 on windows10  (actually, removed and reinstalled) and am trying to execute the simplest python code on terminal.  However, I get the following errors...\n\njac@p50:\/mnt\/c\/Users\/jac\/Documents\/dev\/python\/JupyterNotebooks\/Learn\/Pandas Learn$activate base\n  \/mnt\/c\/Users\/jac\/Anaconda3\/Scripts\/activate: 2: \/mnt\/c\/Users\/jac\/Anaconda3\/Scripts\/activate: cygpath: not found\n  \/mnt\/c\/Users\/jac\/Anaconda3\/Scripts\/activate: 3: .: Can't open \/etc\/profile.d\/conda.sh\n  jac@p50:\/mnt\/c\/Users\/jac\/Documents\/dev\/python\/JupyterNotebooks\/Learn\/Pandas Learn$\n  C:\/Users\/jac\/Anaconda3\/python.exe \"c:\/Users\/jac\/Documents\/dev\/python\/JupyterNotebooks\/Learn\/Pandas Learn\/hello1.py\"\n  -bash: C:\/Users\/jac\/Anaconda3\/python.exe: No such file or directory\n\nI do see the python.exe file at C:\/Users\/jac\/Anaconda3\/python.exe .  I also do not understand why terminal in bash.  I have used cygwin and installed ubuntu in my win10 machine.  I don't have extensive env setup experience, but really need to get vscode running to debug and need anaconda libraries (pandas) to get some work done.  Any help really appreciated.  Thanks,  John","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1647,"Q_Id":52583127,"Users Score":1,"Answer":"OK, so the problem is that Anaconda + VSCode + WSL not playing nice.  I really don't have to run my python programs under WSL (bash.exe), so I changed the terminal>integrated>shell:windows value to C:\\WINDOWS\\System32\\cmd.exe, and unticked the Activate environment option.  Now I can execute and debug!  :)","Q_Score":2,"Tags":"python,visual-studio-code,anaconda","A_Id":52636238,"CreationDate":"2018-09-30T23:58:00.000","Title":"VSCode cannot find python (Anaconda install)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to understand the clear difference between Datashader and other graphing libraries eg plotly\/matplotlib etc.\n\nI understand that in order to plot millions\/billions of data points, we need datashader as other plotting libraries will hung up the browser.\nBut what exactly is the reason which makes datashader fast and does not hung up the browser and how exactly the plotting is done which doesnt put any load on the browser ????\n\nAlso, datashader doesnt put any load on browser because in the backend datashader will create a graph on the basis of my dataframe and send only the image to the browser which is why its fast??\nPlz explain i am unable to understand the in and out clearly.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":901,"Q_Id":52584339,"Users Score":3,"Answer":"It may be helpful to first think of Datashader not in comparison to Matplotlib or Plotly, but in comparison to numpy.histogram2d.  By default, Datashader will turn a long list of (x,y) points into a 2D histogram, just like histogram2d. Doing so only requires a simple increment of a grid cell for each new point, which is easily accellerated to machine-code speeds with Numba and is trivial to parallelize with Dask. The resulting array is then at most the size of your display screen, no matter how big your dataset is.  So it's cheap to process in a separate program that adds axes, labels, etc., and it will never crash your browser.\nBy contrast, a plotting program like Plotly will need to convert each data point into a JSON or other serialized representation, pass that to JavaScript in the browser, have JavaScript draw a shape into a graphics buffer, and make each such shape support hover and other interactive features. Those interactive features are great, but it means Plotly is doing vastly more work per data point than Datashader is, and requires that the browser can hold all those data points. The only computation Datashader needs to do with your full data is to linearly scale the x and y locations of each point to fit the grid, then increment the grid value, which is much easier than what Plotly does.\nThe comparison to Matplotlib is slightly more complicated, because with an Agg backend, Matplotlib is also pre-rendering to a fixed-size graphics buffer before display (somewhat like Datashader). But Matplotlib was written before Numba and Dask (making it more difficult to speed up), it still has to draw shapes for each point (not just a simple increment), it can't fully parallelize the operations (because later points overwrite earlier ones in Matplotlib), and it provides anti-aliasing and other nice features not available in Datashader.  So again Matplotlib is doing a lot more work than Datashader.\nBut if what you really want to do is see the faithful 2D distribution of billions of data points, Datashader is the way to go, because that's really all it is doing. :-)","Q_Score":2,"Tags":"python,matplotlib,plotly,datashader","A_Id":52630545,"CreationDate":"2018-10-01T03:49:00.000","Title":"difference between datashader and other plotting libraries","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install tensorflow but it needs a Python 3.6 installation and I only have Python 3.7 installed. I tried to switch using brew and pyenv but it doesn't work. \nDoes anyone know of a way to solve this problem?","AnswerCount":15,"Available Count":3,"Score":-0.0133325433,"is_accepted":false,"ViewCount":465711,"Q_Id":52584907,"Users Score":-1,"Answer":"I just now downgraded my Python 3.9 to 3.6 because I wanted to use the librosa package but it does not support Python 3.9 still now.\nSteps -\n\nGo to python official website\nDownload the Python version which you want\nInstall in your machine normally\n\nRun python3 --version in the terminal and it will show this version of Python.","Q_Score":129,"Tags":"python,python-3.x","A_Id":65210825,"CreationDate":"2018-10-01T05:14:00.000","Title":"How to downgrade python from 3.7 to 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to install tensorflow but it needs a Python 3.6 installation and I only have Python 3.7 installed. I tried to switch using brew and pyenv but it doesn't work. \nDoes anyone know of a way to solve this problem?","AnswerCount":15,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":465711,"Q_Id":52584907,"Users Score":0,"Answer":"Download and install Python 3.6 and then change the system path environment variable to that of python 3.6 and delete the python 3.7 path system environment variable. Restart pc for results.","Q_Score":129,"Tags":"python,python-3.x","A_Id":65529929,"CreationDate":"2018-10-01T05:14:00.000","Title":"How to downgrade python from 3.7 to 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to install tensorflow but it needs a Python 3.6 installation and I only have Python 3.7 installed. I tried to switch using brew and pyenv but it doesn't work. \nDoes anyone know of a way to solve this problem?","AnswerCount":15,"Available Count":3,"Score":-0.0133325433,"is_accepted":false,"ViewCount":465711,"Q_Id":52584907,"Users Score":-1,"Answer":"For those who want to add multiple Python version in their system:\nI easily add multiple interpreters by running the following commands:\n\nsudo apt update\nsudo apt install software-properties-common\nsudo add-apt-repository ppa:deadsnakes\/ppa\nsudo apt install python 3.x.x\nthen while making your virtual environment choose the interpreter of your choice.","Q_Score":129,"Tags":"python,python-3.x","A_Id":62893015,"CreationDate":"2018-10-01T05:14:00.000","Title":"How to downgrade python from 3.7 to 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to ensemble the three different models (FastText, SVM, NaiveBayes).\nI thought of using python to do this. I'm sure that we can ensemble NaiveBayes as well as SVM models. But, can we ensemble fastText using python ?\nCan anyone please suggest me regarding the same ...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":780,"Q_Id":52585975,"Users Score":0,"Answer":"In your use case you can as you're dealing with 3 models you should keep in mind that:\n\nThe models have different mechanics to use the predict() method: \n\nFastText uses an internal file (serialized model with .bin extension, for example) with all embeddings and wordNGrams and you can pass raw text directly;\nSVM and NaiveBayes you're obligated to pre-process the data using CountVectorizer, TfidfVectorizer LabelEncoder, get the result, repass for the LabelEncoder and deliver the result. \nYou will need at the end deal with different probabilities (if you're predicting with k > 1) and probably you need to take care of this\n\nIf you're going to serialize it to production you'll need to pickle the SVM and NB models and use .bin for FastText model and of course the embeddings from the former ones need to be instantiated too. This can be a little pain in your response time if you need to predict in near real time.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,ensemble-learning","A_Id":55257524,"CreationDate":"2018-10-01T06:56:00.000","Title":"Can we ensemble fastText along with SVM?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to present my data in various graphs. Usually what I do is to take a screenshot of my graph (I almost exclusively make them with matplotlib) and paste it into my PowerPoint.\nUnfortunately my direct superior seems not to be happy with the way I present them. Sometimes he wants certain things in log scale and sometimes he dislike my color palette. The data is all there, but because its an image there's no way I can change that in the meeting. \nMy superior seems to really care about those things and spend quite a lot of time telling me how to make plots in every single meeting. He (usually) will not comment on my data before I make a plot the way he wants.\nThat's where my question becomes relevant. Right now what I have in my mind is to have an interactive canvas embedded in my PowerPoint such that I can change the range of the axis, color of my data point, etc in real time. I have been searching online for such a thing but it comes out empty. I wonder if that could be done and how can it be done?\nFor some simple graphs Excel plot may work, but usually I have to present things in 1D or 2D histograms\/density plots with millions of entries. Sometimes I have to fit points with complicated mathematical formulas and that's something Excel is incapable of doing and I must use scipy and pandas. \nThe closest thing to this I found online is rise with jupyter which convert a jupyter notebook into a slide show. I think that is a good start which allows me to run python code in real time inside the presentation, but I would like to use PowerPoint related solutions if possible, mostly because I am familiar with how PowerPoint works and I still find certain PowerPoint features useful. \nThank you for all your help. While I do prefer PowerPoint, any other products that allows me to modify plots in my presentation in real time or alternatives of rise are welcomed.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8150,"Q_Id":52586506,"Users Score":3,"Answer":"When putting a picture in PowerPoint you can decide whether you want to embed it or link to it. If you decide to link to the picture, you would be free to change it outside of powerpoint. This opens up the possibility for the following workflow:\nNext to your presentation you have a Python IDE or Juypter notebook open with the scripts that generate the figures. They all have a savefig command in them to save to exactly the location on disc from where you link the images in PowerPoint. If you need to change the figure, you make the changes in the python code, run the script (or cell) and switch back to PowerPoint where the newly created image is updated.\nNote that I would not recommend putting too much effort into finding a better solution to this, but rather spend the time thinking about good visual reprentations of the data, due to the following reasons: 1. If your instrutor's demands are completely unreasonable (\"I like blue better than green, so you need to use blue.\") than it's not worth spending effort into satisfying their demands at all. 2. If your instrutor's demands are based on the fact that the current reprentation does not allow to interprete the data correctly, this can be prevented by spending more thoughts on good plots prior to the presentation. This is a learning process, which I guess your instructor wants you to internalize. After all, you won't get a degree in computer science for writing a PowerPoint backend to matplotlib, but rather for being able to present your research in a way suited for your subject.","Q_Score":2,"Tags":"python,matplotlib,powerpoint,jupyter,rise","A_Id":52589887,"CreationDate":"2018-10-01T07:38:00.000","Title":"Possible ways to embed python matplotlib into my presentation interactively","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a website for a university project where you can play some minigames I've programmed with Pygame (Python). How can I make the games executable online (like flashgames)? I'm using php","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10710,"Q_Id":52588601,"Users Score":0,"Answer":"Do you have the executable? If not, check out cx-Freeze. If you do have the executable, I would suggest somehow implementing the executable into the html code to play. Check out Chrome's dino runner (chrome:\/\/dino) the source is free.","Q_Score":5,"Tags":"php,python,pygame","A_Id":52591088,"CreationDate":"2018-10-01T09:55:00.000","Title":"How can I make a Pygame game executable online?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I have several dataframes: df1, df2, df3, etc. The label with each dataframes is A1, A2, A3 etc. I want to use this information as a whole, so that I can pass them. Three methods came into my mind:\nmethod 1\nuse a label list: labels=[\"A1\", \"A2\", \"A3\"...] and a list of dataframes dfs=[df1, df2, df3...].\nmethod 2\nuse a dictionary: d={\"A1\": df1, \"A2\": df2, \"A3\": df3}.\nmethod 3\nuse a pandas series: s=pd.Series([df1, df2, df3], index=[\"A1\", \"A2\", \"A3\"]).\nI will use the label and dataframes sequentially, therefore I think method1 and method3 should be my choice. However, using method 1 will need me to pass two items, while using method 3 I only need to keep one object. Is it a common practice to put the dataframes in a series? I seldom see people do this, is it against best practice? Is there any better suggestions?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":117,"Q_Id":52591696,"Users Score":2,"Answer":"Method 2 also works. Since Python 3.6 it remembers the order it is created too.","Q_Score":3,"Tags":"python,pandas,dataframe,panel","A_Id":52592108,"CreationDate":"2018-10-01T12:57:00.000","Title":"Should I use the dictionary or the series to hold a bunch of dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question. I work with one guy who is developing in Php, I am developing in Django right know. This is my first time doing something for other people and he firstly asked me to put my application to Apache Web server document root(I think he didn't know that much about Django, and he did everything this way), so I did it, because I didn't know that much about Apache and servers. But right know I am scared because I have all the python files in document root and I realized that this Web server document root \\www\\myproject might be accessible to other people. How should I change it, where should I put it, what is the best practice? I am deploying with mod_wsgi and Apache 2.4. In the documentation it says, that I shouldn't put code in Web server document root too, but if I put it somewhere else can I access it the same way, like I used to when it was on the Web server document root? Will I have to do something other than changing paths in Apache config?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":560,"Q_Id":52592496,"Users Score":3,"Answer":"You should put the Django project anywhere on the machine except for the apache document root, for security reasons as you have pointed out.\nYou can then configure apache to pint to the location of your wsgi.py which can live in the Django project if you wish:\nWSGIScriptAlias \/ <path to the wsgi.py>\nI'm not aware of a standard place to put the Django project root directory, I guess it depends on the OS and the distribution.","Q_Score":3,"Tags":"python,django,apache,mod-wsgi","A_Id":52592990,"CreationDate":"2018-10-01T13:42:00.000","Title":"Where to put django files on server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a web scraper which iteratively retrieves data from web pages, and I would like to add the attributes pulled to a pandas dataframe (eventually) for running simple statistics and analysis. The current script returns a dictionary every time a new page is scraped.\nI understand adding a new row or column to an existing pandas dataframe is slow, so my thought was to add the dictionary's as they are retrieved to a csv, and then convert this csv all at once to a dataframe when the data collection is finished (possibly months from now). I will be dealing with up to 100,000 dicts, with 18 key value pairs. \nIs there a more efficient method or datatype to use in this scenario?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":16,"Q_Id":52592761,"Users Score":0,"Answer":"In your question you say when the data collection is finished (possibly months from now). It is enormous amount of time in comparison with efficiency of python or pandas or any other programming tool I can imagine. I just created 100k random dictionaries of length 18 containing floats, saved them into text file (csv format) and loaded with pandas into dataframe. Took 2 seconds to save and 0.5 seconds to load. So just add every new record to the file and periodically create backups of your choice.","Q_Score":1,"Tags":"python-3.x,data-science","A_Id":52592997,"CreationDate":"2018-10-01T13:56:00.000","Title":"Most efficient datatype for iteratively adding to?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have one very general question and another a bit more specific. \nLet's start with the general one as it is strictly connected with the second one. \nSo I'd like to create a website (internal, not available on the internet) with a form that validates user input and if it doesn't meet certain criteria- it cannot be submitted. \nDoes it make sense to create this website (and form) with python django? I mean- obviously it has a lot of sense but there is something else I am trying to puzzle out here:\nWill it make possible to get user input from this website form and pass it to python selenium script? \nI am trying to figure this out as I'd like to improve ordering process with which I work. It is done with a web application provided by an external provider (all things that happen in this application are automatized with python selenium).\nFor the time being I have to read order form (mostly scanned paper forms, pdfs and faxes) put data to excel and then get them to python selenium script but I would like to stop using excel (as it can be really messy). I have to use excel as an intermediary as I don't have a working OCR (so I am an OCR in this case :)) plus current order forms are very different from one another (and standardization is not an option). \nIs it even possible? Is the way I am thinking about anywhere near common sense? Maybe there is an easier method? Any ideas? Thanks for all advices and suggestions.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":107,"Q_Id":52595166,"Users Score":3,"Answer":"Pretty broad, but definitely possible. I would use Flask personally. You can pass any data easily from a form to python and execute any python code on that data with a simple Flask website.","Q_Score":0,"Tags":"python,django,selenium","A_Id":52595231,"CreationDate":"2018-10-01T16:22:00.000","Title":"Web user input form and passing its contents to python selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Whenever I try to use \"sklearn\" in PyCharm, I get the following error on the console.\n\nDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses\nimport imp\n\nI am not sure if it should bother me, because program still working, but it's annoying. How can I get rid of it?\nI made every change, people recommended in linked question but the error is still there.","AnswerCount":1,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":55107,"Q_Id":52596204,"Users Score":-10,"Answer":"I deleted the code that imports \"imp\", from \"cloudpickle.py\" and the warning is gone but I hope I didn't mess up anything. You can also simply ignore this, since it's not an error.\nEdit: I don't want to remove the question or answer because people still visit this page but this is not a solution and it is a bad way to handle it, just ignore this warning. I did this in my very amateur days, sorry :(","Q_Score":30,"Tags":"python,scikit-learn,pycharm","A_Id":52596897,"CreationDate":"2018-10-01T17:40:00.000","Title":"The imp module is deprecated","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't know if the problem is between me and Pyomo.DAE or between me and IPOPT. I am doing this all from the command-line interface in Bash on Ubuntu on Windows (WSL). When I run:\n\nJAMPchip@DESKTOP-BOB968S:~\/examples\/dae$ python3 run_disease.py\n\nI receive the following output:\n\nWARNING: Could not locate the 'ipopt' executable, which is required\n  for solver\n      ipopt Traceback (most recent call last):   File \"run_disease.py\", line 15, in \n      results = solver.solve(instance,tee=True)   File \"\/usr\/lib\/python3.6\/site-packages\/pyomo\/opt\/base\/solvers.py\", line\n  541, in solve\n      self.available(exception_flag=True)   File \"\/usr\/lib\/python3.6\/site-packages\/pyomo\/opt\/solver\/shellcmd.py\", line\n  122, in available\n      raise ApplicationError(msg % self.name) pyutilib.common._exceptions.ApplicationError: No executable found for\n  solver 'ipopt'\n\nWhen I run \"make test\" in the IPOPT build folder, I reecieved:\n\nTesting AMPL Solver Executable...\n      Test passed! Testing C++ Example...\n      Test passed! Testing C Example...\n      Test passed! Testing Fortran Example...\n      Test passed!\n\nBut my one major concern is that in the \"configure\" output was the follwing:\n\nchecking for COIN-OR package HSL... not given: No package 'coinhsl'\n  found\n\nThere were also a few warning when I ran \"make\". I am not at all sure where the issue lies. How do I make python3 find IPOPT, and how do I tell if I have IPOPT on the system for pyomo.dae to find? I am pretty confident that I have \"coibhsl\" in the HSL folder, so how do I make sure that it is found by IPOPT?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1060,"Q_Id":52596464,"Users Score":0,"Answer":"As sascha states, you need to make sure that the directory containing your IPOPT executable (likely the build folder) is in your system PATH. That way, if you were to open a terminal and call ipopt from an arbitrary directory, it would be detected as a valid command. This is distinct from being able to call make test from within the IPOPT build folder.","Q_Score":0,"Tags":"python,pyomo,ipopt","A_Id":52612398,"CreationDate":"2018-10-01T18:01:00.000","Title":"\"No package 'coinhsl' found\": IPOPT compiles and passes test, but pyomo cannot 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":1,"Web Development":0},{"Question":"I was doing multiprocessing in python and hit a pickling error. Which makes me wonder why do we need to pickle the object in order to do multiprocessing? isn't fork() enough? \nEdit: I kind of get why we need pickle to do interprocess communication, but that is just for the data you want to transfer right? why does the multiprocessing module also try to pickle stuff like functions etc?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1182,"Q_Id":52600240,"Users Score":5,"Answer":"Which makes me wonder why do we need to pickle the object in order to\n  do multiprocessing?\n\nWe don't need pickle, but we do need to communicate between processes, and pickle happens to be a very convenient, fast, and general serialization method for Python. Serialization is one way to communicate between processes. Memory sharing is the other. Unlike memory sharing, the processes don't even need to be on the same machine to communicate. For example, PySpark using serialization very heavily to communicate between executors (which are typically different machines).\nAddendum: There are also issues with the GIL (Global Interpreter Lock) when sharing memory in Python (see comments below for detail).\n\nisn't fork() enough?\n\nNot if you want your processes to communicate and share data after they've forked. fork() clones the current memory space, but changes in one process won't be reflected in another after the fork (unless we explicitly share data, of course).\n\nI kind of get why we need pickle to do interprocess communication, but\n  that is just for the data you want to transfer right? why does the\n  multiprocessing module also try to pickle stuff like functions etc?\n\n\nSometimes complex objects (i.e. \"other stuff\"? not totally clear on what you meant here) contain the data you want to manipulate, so we'll definitely want to be able to send that \"other stuff\".\nBeing able to send a function to another process is incredibly useful. You can create a bunch of child processes and then send them all a function to execute concurrently that you define later in your program. This is essentially the crux of PySpark (again a bit off topic, since PySpark isn't multiprocessing, but it feels strangely relevant).\nThere are some functional purists (mostly the LISP people) that make arguments that code and data are the same thing. So it's not much of a line to draw for some.","Q_Score":7,"Tags":"python,multiprocessing,pickle","A_Id":52601284,"CreationDate":"2018-10-01T23:39:00.000","Title":"Why is pickle needed for multiprocessing module in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm attempting to switch to VScode, to use the built-in terminal to interact with Anaconda, and know VScode supports Anaconda because it ships with Anaconda.\nFrom the documentation, and various tutorials\/videos, I see that the conda\/virtual environments are recognized (seemingly natively).  And yet I cannot seem to figure it out.\nWith the python script I want to run open in VScode, I ensure that I am using the correct interpreter\/environment as follows:\nctrl+shift+p to load Command Pallette\nPython:Select Interpreter\nC:...\\Anaconda3\\envs\\p3audio\\python.exe\nAt the bottom of the window, the environment also appears to be pointing to the environment as I loaded the p3audio environment to use python 3.7 and this is what is showing ('Anaconda Python 3.7.0') (The top Python in top level anaconda is shipped with 3.6 I believe)\nWhen I try to run the python file by 'Run Active File' from the Terminal Menu, it automatically loads powershell and executes this into the terminal:\nPS C:...\\Anaconda3\\envs> c:...\\Anaconda3\\envs\\Projects\\p3audo_projects\\my_script.py\n(the second path is in yellow)\nIf I try to activate the conda environment manually from the powershell terminal, it doesn't recognize it.\nI can run the script fine from the anaconda prompt terminal.\nI think it may be a path issue, but all of the documentation\/resources I used suggest I shouldn't have the issue if I didn't select (tick the box) for add path on install. I checked my environment variable path and don't have anaconda on it.\nI am wondering if it has to do with the 'you can change the default terminal shell by selecting the customize button' that loads in the terminal window. This leads me to believe that I have to manually add the conda terminal path somewhere. But this surprises me because, vscode shipped with anaconda, and I see no mention of this in the documentation.\nI am obviously a newbie at this, and have suffered through environment variable\/path issues many times. But I can't figure this out.\nAny help would be greatly appreciated.\nThanks","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":6815,"Q_Id":52601198,"Users Score":1,"Answer":"Ok I figured it out. VSCode is awesome.\n\nGo to Settings (ctrl+,)\nDecide if you want this custom terminal to be applied at the User Settings or Workspace Settings, and select that (located just below the settings search bar)\nOpen settings.json (don't know shortcut key yet, it is the three-dot menu located to the far right on the same row as the User Settings and Workspace Settings tabs.\nLocate \"terminal.integrated.shell.windows\" in the Default User Settings (left panel), again you can enter it into the search bar to locate it.\nCopy it over to the User Settings\/Workspace Settings (depending on what you selected or now decide to select) (in the right panel)\n\ne.g. copy:\n\"terminal.integrated.shell.windows\": \"C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\",into json array on the right\n\nEdit the path to equal your cmd executable path\ne.g. \"terminal.integrated.shell.windows\": \n\"C:\\Windows\\System32\\cmd.exe\",\nYou need to create the argument, which is what I was confused about:\nGo to start menu in windows, locate the Anaconda Prompt Open File Location with right click, inspect properties and see Target Location Path. Don't worry about the first string, copy from after the cmd.exe to the end. Use this for the \"terminal.integrated.shellArgs.windows\"\ne.g. \"terminal.integrated.shellArgs.windows\": [\n    \"\/K\", \"C:\\Users\\User-1\\Anaconda3\\Scripts\\activate.bat C:\\Users\\User-1\\Anaconda3\"\n\nMake sure you separate with a comma and properly contain strings with all four quotations. Save Close vscode. load it up and you are good to go.\nHope this helps someone! = )","Q_Score":1,"Tags":"python,powershell,visual-studio-code,anaconda","A_Id":52602960,"CreationDate":"2018-10-02T02:22:00.000","Title":"VSCode \/ Virtual Studio Code: Unable to Load Conda Environment in VSCode Terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a few test cases that are in unittest.Testcase class. I skip a couple of them. At the end of the run, can I get a list of those skipped tests?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":125,"Q_Id":52602278,"Users Score":2,"Answer":"If you are running the tests at the command line, say, as:\npython3 -m unittest\nthen you can use the -v verbose option to list the result of each test, and look for the skipped ones.\npython3 -m unittest -v\nIf the list is long, you can just grep for 'skipped' in the output. E.g.\npython3 -m unittest -v | grep skipped","Q_Score":1,"Tags":"python,python-3.x,python-unittest","A_Id":66822507,"CreationDate":"2018-10-02T05:01:00.000","Title":"Is there a method\/property\/var to get a list of skipped tests in python3 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 have a python script that pulls information from an API (JSON format) and then executes a series of commands and computations based on the API data. I want the computation to run only when there is new data available. So my question is: what is the best way to detect the availability of new data in the API?\nMy current idea is to just pull all the data once every day. Hash the entire thing and compare the hash-numbers. The problem is that python doesn't want to hash a dicitionary object. Any suggestions?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":256,"Q_Id":52607902,"Users Score":0,"Answer":"you can convert data to string and then hash the result. \nyou can use  json.dumps()  to convert","Q_Score":0,"Tags":"python,hash","A_Id":52607988,"CreationDate":"2018-10-02T12:00:00.000","Title":"Python: best way to detect when API updates?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to disable the print screen key when running a python application?\nMaybe editing the windows registry is the way?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":426,"Q_Id":52609180,"Users Score":0,"Answer":"printscreen is OS Functionality.\nTheir is No ASCII code for PrintScreen.\nEven their are many ways to take PrintScreen.\n\nThus, You can Disable keyboard but its difficult to stop user from taking PrintScreen.","Q_Score":0,"Tags":"python,windows,screenshot,printscreen","A_Id":57932453,"CreationDate":"2018-10-02T13:17:00.000","Title":"how to disable printscreen key on windows using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pandas dataframe with rows as records (patients) and 105 columns as features.(properties of each patient)\nI would like to cluster, not the patients, not the rows as is customary, but the columns so I can see which features are similar or correlated to which other features. I can already calculate the correlation each feature with every other feature using df.corr(). But how can I cluster these into k=2,3,4... groups using sklearn.cluster.KMeans?\nI tried KMeans(n_clusters=2).fit(df.T) which does cluster the features (because I took the transpose of the matrix) but only with a Euclidian distance function, not according to their correlations. I prefer to cluster the features according to correlations. \nThis should be very easy but I would appreciate your help.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1423,"Q_Id":52612841,"Users Score":1,"Answer":"Create a new matrix by taking the correlations of all the features df.corr(), now use this new matrix as your dataset for the k-means algorithm.\nThis will give you clusters of features which have similar correlations.","Q_Score":1,"Tags":"python,machine-learning,scikit-learn,k-means,sklearn-pandas","A_Id":67233384,"CreationDate":"2018-10-02T16:45:00.000","Title":"How to cluster *features* based on their correlations to each other with sklearn k-means clustering","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I call shutil.rmtree('\/') Will I nuke my entire drive or does the function have an inner check for this case?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":491,"Q_Id":52614688,"Users Score":3,"Answer":"rmtree doesn't have any special logic in it. If you have permissions to \/ (e.g., the program is run by root), you will indeed wipe your installation.","Q_Score":3,"Tags":"python,linux,shutil","A_Id":52614802,"CreationDate":"2018-10-02T18:55:00.000","Title":"Will shutil.rmtree() check for the root 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":0,"Web Development":0},{"Question":"I have one master server and 6 worker servers (each with a couple workers running on them). All of a sudden, after many months of flawless execution, all of the tasks stopped getting executed, even though there were no code changes. Now, even after rebooting all the servers involved, restarting RabbitMQ, restarting the workers, etc, it appears as though the servers aren't able to find each other, and thus no tasks can be completed.\nWhen I run celery -A proj inspect active, the response is Error: No nodes replied within time constraint. I'm also able to connect to the broker using Flower, but it lists no workers, even though the workers are running and pointing to the same broker. On the master server, which is in charge of adding tasks, my application now appears to hang indefinitely on apply_async.\nIn my application, I have the broker set to pyamqp, and the backend set to rpc:\nCelery('proj', broker='pyamqp:\/\/[master server's IP]', backend='rpc:\/\/[master server's IP]')\nI feel like I'm missing something really simple, but I can't figure out what it is.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1156,"Q_Id":52616841,"Users Score":0,"Answer":"Navigating to \/var\/log\/rabbitmq\/rabbit@[server-name].log and scrolling back to when the issue first occurred led me to this message Disk free space limit now exceeded. Free bytes:999378944 Limit:1000000000. \nTurns out the hard drive was filled to the brim, which was causing all sorts of trouble for RabbitMQ and Celery, it seems. Freeing up space resolved all issues entirely.","Q_Score":0,"Tags":"python,rabbitmq,celery","A_Id":52619210,"CreationDate":"2018-10-02T21:43:00.000","Title":"Celery tasks suddenly stop executing, nodes can't find each other","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a script that uses a lot of headless Selenium automation and looped HTTP requests. It's very important that I implement a threading\/worker queue for this script. I've done that.\nMy question is: Should I be using multi-thread or multi-process? Thread or ProcessPool? I know that:\n\"If your program spends more time waiting on file reads or network requests or any type of I\/O task, then it is an I\/O bottleneck and you should be looking at using threads to speed it up.\"\nand...\n\"If your program spends more time in CPU based tasks over large datasets then it is a CPU bottleneck. In this scenario you may be better off using multiple processes in order to speed up your program. I say may as it\u2019s possible that a single-threaded Python program may be faster for CPU bound problems, it can depend on unknown factors such as the size of the problem set and so on.\"\nWhich is the case when it comes to Selenium? Am I right to think that all CPU-bound tasks related to Selenium will be executed separately via the web driver or would my script benefit from multiple processes?\nOr to be more concise: When I thread Selenium in my script, is the web driver limited to 1 CPU core, the same core the script threads are running on?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1504,"Q_Id":52617726,"Users Score":4,"Answer":"Web driver is just a driver, a driver cannot drive a car without a car. \nFor example when you use ChromeDriver to communicate with browser, you are launching Chrome. And ChromeDriver itself does no calculation but Chrome does.\nSo to clarify, webdriver is a tool to manipulate browser but itself is not a browser.\nBased on this, definitely you should choose thread pool instead of process pool as it is surely an I\/O bound problem in your python script.","Q_Score":7,"Tags":"python,python-3.x,multithreading,selenium,concurrency","A_Id":52618724,"CreationDate":"2018-10-02T23:27:00.000","Title":"Concurrency and Selenium - Multiprocessing vs Multithreading","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This may be a straight-up unwise idea so I'd best explain the context. I am finding that some of my functions have multiple and sometimes mutually exclusive or interdependent keyword arguments - ie, they offer the user the ability to input a certain piece of data as (say) a numpy array or a dataframe. And then if a numpy array, an index can be separately passed, but not if it it's a dataframe.\nWhich has led me to wonder if it's worth creating some kind of keyword parser function to handle these exclusivities\/dependencies. One issue with this is that the keyword parser function would then need to return any variables created (and ex-ante, we would not know their number or their names) into the namespace of the function that called it. I'm not sure if that's possible, at least in a reasonable way (I imagine it could be achieved by directly changing the local dict but that's sometimes said to be a bad idea).\nSo my question is:\n1. Is this a bad idea in the first place? Would creating separate functions depending on whether the input was a dataframe or ndarray be more sensible and simpler?\n2. Is it possible without too much hacking to have a function return an unspecified number of variables into the local namespace?\nApologies for the slightly vague nature of this question but any thoughts gratefully received.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":52619262,"Users Score":0,"Answer":"A dict is a good way to package a variable number of named values.  If the parser returns a dict, then there is a single object that can be queried to get those names and values, avoiding the problem of needing to know the number and names ahead of time.\nAnother possibility would be to put the parser into a class, either as a factory method (classmethod or staticmethod returning an instance) or as a regular method (invoked during or after __init__), where the class instance holds the parsed values.","Q_Score":0,"Tags":"python","A_Id":52775839,"CreationDate":"2018-10-03T03:22:00.000","Title":"Have a keyword parser function return variables into local namespace","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed some files (pygame, python-docx) through pip. They appear in pycharm in the site-packages folder, but I cannot import anything from that folder. I get a ModuleNotFoundError. The site-packages folder and sub-folders all appear as red. \nAny ideas what I should do?\nI have python 3.7 and pycharm community edition 2018.2.3","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6825,"Q_Id":52621583,"Users Score":1,"Answer":"If your site-packages folder is marked red,\n\ngo to settings (Ctrl + Alt + S)\nSelect Project: \"Your Project Name\"\nSelect Python Interpreter\nDouble click on pip\nType in pygame in the searchbar\nFinally download the package\nNow you can import pygame","Q_Score":1,"Tags":"python,python-3.x,module,pycharm,python-import","A_Id":67534496,"CreationDate":"2018-10-03T07:10:00.000","Title":"Pycharm site-packages folder marked red and modules cannot be imported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script that will regulary check an API for data updates. Since it runs without supervision I would like to be able monitor what the script does to make sure it works properly. \nMy initial thought is just to write every communication attempt with the API to a text file with date, time and if data was pulled or not. A new line for every imput. My question to you is if you would recommend doing it in another way? Write to excel for example to be able to sort the columns? Or are there any other options worth considering?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":245,"Q_Id":52622752,"Users Score":1,"Answer":"I would say it really depends on two factors \n\nHow often you update\nHow much interaction do you want with the monitoring data (i.e. notification, reporting etc)\n\nI have had projects where we've updated Google Sheets (using the API) to be able to collaboratively extract reports from update data. \nHowever, note that this means a web call at every update, so if your updates are close together, this will affect performance. Also, if your app is interactive, there may be a delay while the data gets updated. \nThe upside is you can build things like graphs and timelines really easily (and collaboratively) where needed. \nAlso - yes, definitely the logging module as answered below. I sort of assumed you were using the logging module already for the local file for some reason!","Q_Score":0,"Tags":"python,api,logfile","A_Id":52622826,"CreationDate":"2018-10-03T08:23:00.000","Title":"Python API implementing a simple log 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'm writing an application for a venue that will have large-scale competitions. In order to effectively manage those competitions, multiple employees need to engage with and modify a set of data in real-time, from multiple machines in the gym. I have created a Python application which accomplishes this by communicating with a MySQL server (which allows as many instances of the application as necessary to communicate with it). \nIs there a nice way to get MySQL server installed on a client machine along with this Python application (It only necessarily needs to end up on one machine)? Perhaps is there a way to wrap the installers together? Am I asking the right question? I have no experience with application distribution, and I'm open to all suggestions.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":260,"Q_Id":52629295,"Users Score":1,"Answer":"The 'normal' way to do it is to have a network setup (ethernet and\/or wireless) to connect many Clients (with your Python app) to a single Server (with MySQL installed).\nTo have the \"Server\" distributed among multiple machines becomes much messier.\nPlan A:  One Master replicating to many Slaves -- good for scaling reads, but not writes.\nPlan B:  Galera Cluster -- good for writing to multiple instances; repairs itself in some situations.\nBut if you plan on having the many clients go down a lot, you are better off having a single server that you try to keep up all the time and have a reliable network so that the clients can get to that on server.","Q_Score":0,"Tags":"python,mysql,windows-installer,software-distribution","A_Id":52727076,"CreationDate":"2018-10-03T14:25:00.000","Title":"Is it possible to install MySQL Server along with standalone client-side software?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I understand that we can use dataFunction.Inputs.SetInput(inputs,\"String(\\\"HelloWorld\\\")\") to set a string to my input parameter. Is there any way I can give an entire column instead of a string.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":131,"Q_Id":52631061,"Users Score":2,"Answer":"Nevermind. I found the answer. It can be done using dataFunction.Inputs.SetInput(inputs,\"[DataTable name].[Column name]\")","Q_Score":1,"Tags":"python,ironpython,spotfire","A_Id":52636271,"CreationDate":"2018-10-03T15:50:00.000","Title":"Spotfire can i input a column through ironpython script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I designed the PDF(template) in HTML and converting\/using it in Python.\nI need both orientation in my PDF output(Portrait and Landscape)?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":625,"Q_Id":52635198,"Users Score":1,"Answer":"Make your pages as separate files (one with the -O landscape flag in your wkhtml2pdf call, and one without). You can call ghostscript to join the files together in python using the subprocess module","Q_Score":1,"Tags":"html,django,python-2.7,wkhtmltopdf,pdfkit","A_Id":52961456,"CreationDate":"2018-10-03T20:29:00.000","Title":"Generate PDF from HTML using Python with multiple orientation(Portrait and Landscape)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to manage a supergroup on Telegram.\nI'm wondering if there's a way to filter certain words (like curse words) through a bot?\nIf there is, I would much appreciate if you help me coding it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2978,"Q_Id":52635712,"Users Score":0,"Answer":"If your bot is the admin with the priviledge of deleting messages, it can remove any message it wants. \nMake sure that you have turned the group privacy of the bot off.","Q_Score":0,"Tags":"java,python,bots,telegram,telegram-bot","A_Id":52641993,"CreationDate":"2018-10-03T21:07:00.000","Title":"Telegram bot to filter certain words","Data Science and Machine Learning":0,"Database and SQL":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":"PyCharm 2017.2 highlights my f-strings with the message Python version 3.5 does not support a 'F' prefix.\nBut...\n\nIn File | Settings | Editor | Inspections, Code compatibility inspection is unchecked, both for Default (stored in IDE) and for Project Default (stored in project). (I have seen other questions where the answer was about this point. Not applicable here.)\nEven if I turn Code compatibility inspection on and check only Python 3.6, I still get the message about Python 3.5.\nFile | Invalidate Caches \/ Restart fixes it briefly, until the Indexing message goes away, then it comes back.\nI don't have Python 3.5 installed (only 2.7, 3.6 and 3.7). Python 3.7 is set as the project interpreter.\nThis behaviour is new, since I started using Python 3.7 for real. If I change the interpreter back to Python 3.6 it goes away. I don't regard that as a useful workaround.\n\nEither this is a bug I should report, or I am missing something that should be obvious. Anyone care to tell me which it is?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":537,"Q_Id":52636098,"Users Score":2,"Answer":"I think PyCharm 2017.2 is too old and you should use PyCharm 2018.2. That old version was published before Python 3.7, so you may encounter troubles\u2026","Q_Score":2,"Tags":"python,pycharm","A_Id":52638953,"CreationDate":"2018-10-03T21:43:00.000","Title":"Setting the project interpreter in PyCharm to Python 3.7 causes spurious code incompatibility messages about Python 3.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pretty new to VS and developing. I've installed python tools for my visual studio 2017 community. When I start debugging\/running my script, errors are not shown. The debugger stops and returns to VS. How do I get the ipy console to stay so I can see what the RuntimeError actually is?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":207,"Q_Id":52637988,"Users Score":0,"Answer":"solved it by checking python exceptions in the output \"exception settings\" tab","Q_Score":0,"Tags":"visual-studio,ironpython","A_Id":52657116,"CreationDate":"2018-10-04T02:05:00.000","Title":"Ironpython error not shown in visual studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a small project which I intend to spread out over separate python files for isolation of separate modules. Some of these modules just need to have static information that needs to be accessible across the program, and some have utility functions (for example, a geometry library for drawing objects).\nWould it be pythonic if I just made a separate .py and added constants and methods without having to define a class? It seems far simpler than having to create a class.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":125,"Q_Id":52638187,"Users Score":1,"Answer":"Only create a class if you need to - Object Oriented Programming is not a solution to everything. However, if you find that you are overwhelmed with a monolithic script, it might make sense to break it up into different logical pieces. For example, a configuration file could hold all of your variables and 'static information'. Easily access it with an import and a file.open loop. If you find that there are too many methods and they could be easily logically sectioned, do whatever feels right. At the end of the day, you can get a working program both ways - it's about comfort and time. Balance the two and see where you get. Don't worry about it until you feel like it's an issue. Good luck with your project!","Q_Score":1,"Tags":"python,class,module","A_Id":52638267,"CreationDate":"2018-10-04T02:37:00.000","Title":"Is it pythonic to have separate files instead of classes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to do a weather api related python program and initially while running the dependencies there was a error that occurred which reads as \n'No module named 'citipy' error'. \nBut i used from citipy import city command initially and even installed citipy using pip install citipy and upgraded it too. \nThe error still persists. Please help.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":4976,"Q_Id":52638844,"Users Score":2,"Answer":"I was able to solve it by just changing the kernel. I don't know how kernel affects when your trying to import a module, but it worked for me.","Q_Score":0,"Tags":"python,api,openweathermap","A_Id":52750167,"CreationDate":"2018-10-04T04:06:00.000","Title":"ModuleNotFoundError: No module named 'citipy' error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to do a weather api related python program and initially while running the dependencies there was a error that occurred which reads as \n'No module named 'citipy' error'. \nBut i used from citipy import city command initially and even installed citipy using pip install citipy and upgraded it too. \nThe error still persists. Please help.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":4976,"Q_Id":52638844,"Users Score":1,"Answer":"I had initially installed citipy through git bash, but when I ran my code in jupyter notebook it did not run. To solve the problem I had to install citipy through anaconda prompt (which is how I open my jupyter notebook) and I think this is how both the citipy and your code are in the same kernel.","Q_Score":0,"Tags":"python,api,openweathermap","A_Id":55272731,"CreationDate":"2018-10-04T04:06:00.000","Title":"ModuleNotFoundError: No module named 'citipy' error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to do a weather api related python program and initially while running the dependencies there was a error that occurred which reads as \n'No module named 'citipy' error'. \nBut i used from citipy import city command initially and even installed citipy using pip install citipy and upgraded it too. \nThe error still persists. Please help.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4976,"Q_Id":52638844,"Users Score":0,"Answer":"It happened the same to me, and I noticed that I skipt to activate pythondata from anaconda prompt","Q_Score":0,"Tags":"python,api,openweathermap","A_Id":69748249,"CreationDate":"2018-10-04T04:06:00.000","Title":"ModuleNotFoundError: No module named 'citipy' error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible for a file f that os.path.isfile(f) and os.path.isdir(f) both evaluate to false?\nWhat would a third category be named in this case?\nSzenario:\nI have created a contentless file using touch on ubuntu 18.04, which definitely is not a directory. Python (version 3.5) nevertheless returns false on isfile(f).\nEdit: It turns out that the file indeed returned True, the earlier output was a small mistake in my code.\nThe question still remains as I thought about it this way:\n\nI have a set (Set A) of all files in a directory.\n\nI create a subset via isfile filtering (Set B).\n\nI create a subsets via isdir filtering (Set C).\nWould the union of B and C be equal to A?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1175,"Q_Id":52639774,"Users Score":3,"Answer":"Is it possible for a file f that os.path.isfile(f) and os.path.isdir(f) both evaluate to false?\n\nyes .. if you ask for existence os.path.exists(f).\nEDIT: to answer your more detalied question ..\n\nWould the union of B and C be equal to A?\n\nNormaly yes .. if you can assert that none of them is deleted in the meantime.\nTake into account that dead links are not exists, which means that os.path.exists(deadlink) of a (existing) link pointing to a dead end results in False while os.path.islink(deadlink) results in True, no matter if it points to a existing object or a dead end.","Q_Score":5,"Tags":"python","A_Id":52639891,"CreationDate":"2018-10-04T05:43:00.000","Title":"Can isfile() and isdir() functions both evaluate to False?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to get from which admin page(app) current request is from in django admin.\nCurrently request.resolver_match.app_name only returns \"admin\" which is not what I want. \nI have noticed that my app name is in 'view_name' and 'url_name' but is it reliable to parse these variables to access current app name?\nDjango 1.11 LTS\nEDIT: For example, when a user enters admin page for my course app with the above method I still only get 'admin' in my request which should be 'course' not 'admin'. My ultimate goal is to hide some of my app model fields in admin page based on user group.\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":900,"Q_Id":52641802,"Users Score":1,"Answer":"From a ModelAdmin you have access to the model via self.model. In a ModelAdmin method you can thus get the app name using self.model._meta.app_label.\nI you need to access it from the template rather than the ModelAdmin, self.model._meta is passed to the context as opts. You can thus access it via {% if opts.app_label == \"some_app\" %}.","Q_Score":1,"Tags":"python,django,django-admin,django-apps","A_Id":52642937,"CreationDate":"2018-10-04T07:59:00.000","Title":"How to get current app when user is in Django admin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to Python and am trying to pip install the pandas, numpy and a few other libraries, but it won't work. \nMy method is: \ngo to command prompt and type python -m pip install pandas --user - I have also tried every other way like pip install etc. Each time i do it it just says syntax error. Solutions? \nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":721,"Q_Id":52642130,"Users Score":1,"Answer":"You should not use pip in python CLI. You must use pip in your system CLI like Windows powershell.\nuse command below to install packages :\npip install pachakge-name\nfor example:\npip install numpy scipy matplotlib pandas \nOr you can do this one by one. Each package in single line of pip install","Q_Score":1,"Tags":"python,pandas,numpy","A_Id":52642522,"CreationDate":"2018-10-04T08:18:00.000","Title":"pip install not working for pandas + numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running multiple scrapers using the command line which is an automated process.\nPython : 2.7.12\nScrapy : 1.4.0\nOS : Ubuntu 16.04.4 LTS\nI want to know how scrapy handles the case when \n\nThere is not enough memory\/cpu bandwidth to start a scraper.\nThere is not enough memory\/cpu bandwidth during a scraper run.\n\nI have gone through the documentation but couldn't find anything.\nAnyone answering this, you don't have to know the right answer, if you can point me to the general direction of any resource you know which would be helpful, that would also be appreciated","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":52643398,"Users Score":1,"Answer":"The operating system kills any process that tries to access more memory than the limit.\nApplies to python programs too. and scrapy is no different.\nMore often than not, bandwidth is the bottleneck in scraping \/ crawling applications.\nMemory would only be a bottleneck if there is a serious memory leak in your application.\nYour application would just be very slow if CPU is being shared by many process on the same machine.","Q_Score":0,"Tags":"python,python-2.7,memory-management,scrapy","A_Id":52643555,"CreationDate":"2018-10-04T09:28:00.000","Title":"How does scrapy behave when enough resources are not available","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Hi have my own corpus and I train several Word2Vec models on it.\nWhat is the best way to evaluate them one against each-other and choose the best one? (Not manually obviously - I am looking for various measures).\nIt worth noting that the embedding is for items and not word, therefore I can't use any existing benchmarks.\nThanks!","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":6758,"Q_Id":52645459,"Users Score":7,"Answer":"There's no generic way to assess token-vector quality, if you're not even using real words against which other tasks (like the popular analogy-solving) can be tried. \nIf you have a custom ultimate task, you have to devise your own repeatable scoring method. That will likely either be some subset of your actual final task, or well-correlated with that ultimate task. Essentially, whatever ad-hoc method you may be using the 'eyeball' the results for sanity should be systematized, saving your judgements from each evaluation, so that they can be run repeatedly against iterative model improvements. \n(I'd need more info about your data\/items and ultimate goals to make further suggestions.)","Q_Score":7,"Tags":"python,nlp,word2vec,embedding,word-embedding","A_Id":52675950,"CreationDate":"2018-10-04T11:22:00.000","Title":"How to evaluate Word2Vec model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi have my own corpus and I train several Word2Vec models on it.\nWhat is the best way to evaluate them one against each-other and choose the best one? (Not manually obviously - I am looking for various measures).\nIt worth noting that the embedding is for items and not word, therefore I can't use any existing benchmarks.\nThanks!","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":6758,"Q_Id":52645459,"Users Score":3,"Answer":"One way to evaluate the word2vec model is to develop a \"ground truth\" set of words.   Ground truth will represent words that should ideally be closest together in vector space.  For example if your corpus is related to customer service, perhaps the vectors for \"dissatisfied\" and \"disappointed\" will ideally have the smallest euclidean distance or largest cosine similarity.  \nYou create this table for ground truth, maybe it has 200 paired words.  These 200 words are the most important paired words for your industry \/ topic.   To assess which word2vec model is best, simply calculate the distance for each pair, do it 200 times, sum up the total distance, and the smallest total distance will be your best model.   \nI like this way better than the \"eye-ball\" method, whatever that means.","Q_Score":7,"Tags":"python,nlp,word2vec,embedding,word-embedding","A_Id":55913014,"CreationDate":"2018-10-04T11:22:00.000","Title":"How to evaluate Word2Vec model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi have my own corpus and I train several Word2Vec models on it.\nWhat is the best way to evaluate them one against each-other and choose the best one? (Not manually obviously - I am looking for various measures).\nIt worth noting that the embedding is for items and not word, therefore I can't use any existing benchmarks.\nThanks!","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":6758,"Q_Id":52645459,"Users Score":1,"Answer":"One of the ways of evaluating the Word2Vec model would be to apply the K-Means algorithm on the features generated by the Word2Vec. Along with that create your own manual labels\/ground truth representing the instances\/records. You can calculate the accuracy of the model by comparing the clustered result tags with the ground truth label. \nEg: CLuter 0 - Positive -{\"This is a good restaurant\", \"Good food here\", \"Not so good dinner\"}\n    Cluster 1 - Negative - {\"This is a fantastic hotel\", \"food was stale\"}\nNow, compare the tags\/labels generated by the clusters with the ground truth values of the instances\/sentences in the clusters and calculate the accuracy.","Q_Score":7,"Tags":"python,nlp,word2vec,embedding,word-embedding","A_Id":58868796,"CreationDate":"2018-10-04T11:22:00.000","Title":"How to evaluate Word2Vec model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a worksheet with VBA code (on Excel, right-click on the sheet name and View code) that I would like to copy on the same workbook.\nWhen using workbook.copy_worksheet() , the VBA code contained in the worksheet is lost. \nI've had a look at the worksheet.vba_code property but it seems to only contain some sheets properties, not the VBA code.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":662,"Q_Id":52647650,"Users Score":1,"Answer":"I think the problem will be that worksheets themselves do not contain any VBA code. This is stored as a blob in the XLSX package and may well contain hard-coded references to particular worksheets. Unfortunately the VBA blobs are not covered by the OOXML specification so there is no way to know. You might be okay if you copy the vba_code property manually but there is no guarantee and it's just as likely that Excel will complain about the file.","Q_Score":1,"Tags":"python,excel,vba,openpyxl","A_Id":52647821,"CreationDate":"2018-10-04T13:12:00.000","Title":"How to keep VBA code when copying worksheet with openpyxl?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am going through the painful process of learning how to manage packages\/ different (virtual) environments in Python\/Anaconda. I was told that Anaconda is basically a python installation with all the packages I need (e.g. numpy, scipy, sci-kit learn etc). \nHowever, when I create a new environment, none of these packages is readily available. I cannot import them when using PyCharm with the newly created environment. When I check the Pycharm project interpreter, or the anaconda navigator environments tab, It seems that indeed none of these packages are installed in my new environments. Why is this? It doesn't make sense to me to provide all these packages, but then not make them ready for use when creating new environments. Do I have to install all these packages manually in new env's or am I missing something?\nKindest regards, and thanks in advance.","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":12607,"Q_Id":52648520,"Users Score":-1,"Answer":"You can check the packages you have in your environment with the command:\n\nconda list\n\nIf packages are not listed you just have to add it, with the command:\n\nconda install numpy","Q_Score":13,"Tags":"python,package,anaconda,conda","A_Id":52648696,"CreationDate":"2018-10-04T13:53:00.000","Title":"Why doesn't a new Conda environment come with packages like numpy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am going through the painful process of learning how to manage packages\/ different (virtual) environments in Python\/Anaconda. I was told that Anaconda is basically a python installation with all the packages I need (e.g. numpy, scipy, sci-kit learn etc). \nHowever, when I create a new environment, none of these packages is readily available. I cannot import them when using PyCharm with the newly created environment. When I check the Pycharm project interpreter, or the anaconda navigator environments tab, It seems that indeed none of these packages are installed in my new environments. Why is this? It doesn't make sense to me to provide all these packages, but then not make them ready for use when creating new environments. Do I have to install all these packages manually in new env's or am I missing something?\nKindest regards, and thanks in advance.","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":12607,"Q_Id":52648520,"Users Score":3,"Answer":"I don't know about \"conda\" environments but in general virtual environments are used to provide you a \"unique\" environment. This might include different packages, different environment variables etc. \nThe whole point of making a new virtual environment is to have a separate place where you can install all the binaries ( and other resources ) required for your project. If you have some pre-installed binaries in the environment, doesn't it defeat the purpose of creating one in the first place?\nThe fact that you can create multiple environments helps you to separate binaries that might be needed by one and not by the other. \nFor instance, if you are creating a project which requires numpy:1.1 but you have numpy:2.1 installed , then you have to change it. So basically, by not installing any other packages, they are not making assumptions about your project's requirements.","Q_Score":13,"Tags":"python,package,anaconda,conda","A_Id":52648738,"CreationDate":"2018-10-04T13:53:00.000","Title":"Why doesn't a new Conda environment come with packages like numpy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a way to call Google as few times as possible so I am wondering if there is a way for Google to automatically decide weather to use TEXT_DETECTION or DOCUMENT_TEXT_DETECTION through Python Cloud Vision client?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":52649268,"Users Score":0,"Answer":"The Cloud Vision API has no way to determine which is the \"best\" detection method to use -- this is for you to decide.","Q_Score":0,"Tags":"python,google-cloud-platform,google-vision","A_Id":52650135,"CreationDate":"2018-10-04T14:30:00.000","Title":"Google Cloud Vision - Is there a way to automatically decide between using DOCUMENT_TEXT_DETECTION and TEXT_DETECTION?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install rasa_core in my python by using  !pip install rasa_core; command.\nBut i am getting an error :\nBelow is the error :\nFailed building wheel for Twisted\n  The scripts freeze_graph.exe, saved_model_cli.exe, tensorboard.exe, tflite_convert.exe, toco.exe and toco_from_protos.exe are installed in 'C:\\Users\\user\\AppData\\Roaming\\Python\\Python36\\Scripts' which is not on PATH.\n  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\nCommand \"c:\\programdata\\anaconda3\\python.exe -u -c \"import setuptools, tokenize;__file__='C:\\\\Users\\\\user\\\\AppData\\\\Local\\\\Temp\\\\pip-install-fot9mu3e\\\\Twisted\\\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))\" install --record C:\\Users\\user\\AppData\\Local\\Temp\\pip-record-vp3wq_7u\\install-record.txt --single-version-externally-managed --compile --user --prefix=\" failed with error code 1 in C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-fot9mu3e\\Twisted\\\nCould anyone please help me.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":868,"Q_Id":52651437,"Users Score":0,"Answer":"I faced the same issue and able to install rasa_core after resolving dependencies fast.\nPlease try below:\n\nFirst install twisted\npip install Twisted\nThen, install rasa_core     \npip install rasa_core","Q_Score":0,"Tags":"python,installation,chatbot,rasa-nlu,rasa-core","A_Id":53033952,"CreationDate":"2018-10-04T16:23:00.000","Title":"Facing issues while installing rasa_core","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a raspberry pi 3b+ and i'm showing ip camera stream using the Opencv in python.\nMy default ip in rasppberry is 169.254.210.x range and I have to put the camera in the same range.\nHow can i change my raspberry ip?\nSuppose if I run the program on a web service such as a flask, can i change the raspberry pi server ip every time?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":52652775,"Users Score":0,"Answer":"You can statically change your ip of raspberry pi by editing \/etc\/network\/interfaces\nTry editing a line of the file which contains address.","Q_Score":0,"Tags":"python,networking,flask,raspberry-pi3","A_Id":52653195,"CreationDate":"2018-10-04T17:55:00.000","Title":"how to change raspberry pi ip in flask web service","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to leverage command line tools within GCP Dataflow? \nEssentially, I have files that I currently pass as arguments into a command line tool, and that tool outputs a different file based on the input. I'm not exactly sure what the tool does so recreating the logic within Dataflow is out of question. Is there any way to call this tool using the os or subprocess modules while still taking advantage of Dataflow's benefits?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":94,"Q_Id":52653052,"Users Score":1,"Answer":"Yes, you can call out to sub-processes inside of your graph. However, there are some implications to doing this. Example: Inside of your DoFn() you might do something like: shell(call legacy exe to produce flat file). At this point you will have to manually block on that call or create sometime of orchestration to process the output. There is no callback or dispatching mechanism in Apache Beam. The main side effect of this scenario is that you are now blocking the DoFn from doing anymore work - thus burning cycles just blocking. If this sub-process calls are light, probably not an issue - if they are resource intensive e.g. sequence this genome - you are going to hit some issues.\nA more flexible and effective way to do this type of work is to mix Cloud Composer with Cloud Dataflow. Use Dataflow for work that needs aggregation and then dispatch long running (sub-process) work to Cloud Composer. For example: Analyze population of 1B people, find top Y people with features of X. Then dispatch long running processes to do sub-process analysis on the Y.\nDoes this help?","Q_Score":1,"Tags":"python,google-cloud-platform,google-cloud-dataflow,apache-beam","A_Id":52667399,"CreationDate":"2018-10-04T18:13:00.000","Title":"Google Cloud Platform Dataflow integration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am having some trouble with my Eclipse debugger. Every time I set a breakpoint on Python source files, when the breakpoint is hit Eclipse opens up the associated pyc compiled file.\nBelow are a few things I have tried:\n\nCreating a new Eclipse project with the code\nDeleting all settings files within the code\nSwitch to a new workspace\nRe-install eclipse and PyDev completely.\n\nThe problem persists. I don't know what could possibly be causing this. The issue only occurs when a breakpoint is set. However, that renders breakpoints useless in Eclipse.\nThis issue only began after I tried to set up Visual Studio for Python development. In Visual Studio this issue does not occur.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":52653339,"Users Score":0,"Answer":"Can you check if you have pydevd installed somewhere in your system and remove it if that's the case? (i.e.: run without debugging import pydevd and if you find it remove it from your interpreter). \nThe PyDev debugger is used in other products (such as PyCharm and Visual Studio), so, my guess is that a non-compatible version is installed somewhere instead of using the version which is shipped along with Eclipse\/PyDev.","Q_Score":0,"Tags":"python,eclipse,debugging,pydev","A_Id":52877512,"CreationDate":"2018-10-04T18:50:00.000","Title":"Eclipse opens compiled python instead of source code on breakpoint","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"From what I've read, it sounds like the issue might be that the module isn't in the same directory as my script. Is that the case? If so, how do I find the module and move it to the correct location? \nEdit\nIn case it's relevant - I installed docx using easy_install, not pip.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3543,"Q_Id":52654136,"Users Score":0,"Answer":"pip show docx \nThis will show you where it is installed. However, if you're using python3 then\n pip install python-docx \nmight be the one you need.","Q_Score":1,"Tags":"python,import,docx","A_Id":52857960,"CreationDate":"2018-10-04T19:48:00.000","Title":"\"No module named 'docx'\" error but \"requirement already satisfied\" when I try to install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"From what I've read, it sounds like the issue might be that the module isn't in the same directory as my script. Is that the case? If so, how do I find the module and move it to the correct location? \nEdit\nIn case it's relevant - I installed docx using easy_install, not pip.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3543,"Q_Id":52654136,"Users Score":0,"Answer":"Please install python-docx.\nThen you import docx (not python-docx)","Q_Score":1,"Tags":"python,import,docx","A_Id":71628381,"CreationDate":"2018-10-04T19:48:00.000","Title":"\"No module named 'docx'\" error but \"requirement already satisfied\" when I try to install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with django and using angularjs. I made a request which responded with an object containing the name, price and date this input was modified. \nMy html has the following {{price_level.modified }} providing me with 2018-01-16T10:15:34.401839Z.\nHere is the data that I am getting when I console.log the data \ncreated: \"2017-06-02T05:01:17.803045Z\"\nfs_charge: 10\nid: 595\nlocked: false\nmodified: \"2018-02-06T07:36:21.517414Z\"\nmoq: 30\nmoq_price: 60","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":52654797,"Users Score":0,"Answer":"If you just want YYYY-MM-DD you could do a substring from position 0 through 9.\nExample in Python dateStr[:10]","Q_Score":1,"Tags":"python,html,angularjs,django","A_Id":52654858,"CreationDate":"2018-10-04T20:37:00.000","Title":"Any way I can shorten the length of this date without having to run date()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to find an autoregressive model on some data stored in a dataframe and I have 96 data points per day. The data is the value of solar irradiance in some region and I know it has a 1-day seasonality. I want to obtain a simple linear model using scikit LinearRegression and I want to specify which lagged data points to use. I would like to use the last 10 data points, plus the data point that has a lag of 97, which corresponds to the data point of 24 hour earlier. How can I specify the lagged coefficients that I want to use? I don't want to have 97 coefficients, I just want to use 11 of them: the previous 10 data points and the data point 97 positions back.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":52661107,"Users Score":1,"Answer":"Just make a dataset X with 11 columns [x0-97, x0-10, x0-9,...,x0-1]. Then series of x0 will be your target Y.","Q_Score":0,"Tags":"python,scikit-learn,autoregressive-models","A_Id":52665360,"CreationDate":"2018-10-05T08:09:00.000","Title":"How to choose coefficients with scikit LinearRegression","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am bit puzzled by how to read and understand a simple line of code:\n\nI have a tensor input of shape (19,4,64,64,3).\nThe line of code input[:, None] returns a tensor of shape (19, 1,\n4, 64, 64, 3).\n\nHow should I understand the behavior of that line? It seems that None is adding a dimension, with a size of 1. But why is this added on that specific position (between 19 and 4)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":52662727,"Users Score":2,"Answer":"Indeed, None adds a new dimension. You can also use tf.newaxis for this which is a bit more explicit IMHO. \nThe new dimension is added in axis 1 because that's where it appears in the index. E.g. input[:, :, None] should result in shape (19, 4, 1, 64, 64, 3) and so on.\nIt might get clearer if we write all the dimensions in the slicing: input[:, None, :, :, :, :]. In slicing, : simply means taking all elements of the dimension. So by using one :, we take all elements of dimension 0 and then \"move on\" to dimension 1. Since None appears here, we know that the new size-1 axis should be in dimension 1. Accordingly, the remaining dimensions get \"pushed back\".","Q_Score":1,"Tags":"python,tensorflow","A_Id":52665472,"CreationDate":"2018-10-05T09:42:00.000","Title":"Tensor shape modification using slicing and None","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to automize my routine tasks such as changing 1 word in huge AutoCAD .DWG file with a lot of text blocks (objects in autocad). So, can I open it by Python? And how?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2024,"Q_Id":52664745,"Users Score":3,"Answer":"Your best bet here is to convert the file first into something like SVG or .dxf and go from there. It's not easy getting the data from a .dwg file in python.\nYou can make the conversion to SVG in python too using subprocess and a command line convert tool like cad2svg.","Q_Score":0,"Tags":"python,autocad,dwg","A_Id":52664929,"CreationDate":"2018-10-05T11:33:00.000","Title":"DWG source by 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 running my Django application with Apache on CentOS. I already (pip) installed Pillow on my virtualenv(python3.6). When I run python in shell, from PIL import _imaging doesn't generate any error. However, When I put this line of code inside the Django application, it generates an error: cannot import name '_imaging'. This is confusing.\nI set the python path: \/var\/www\/ProjectName\/virtualenv\/bin\/python3.6\/site-packages (in WSGIDaemonProcess), and the error occurred in the same location, so I think it's not an issue that Django is running on another python version.\nMaybe is a mod_wsgi error? I installed mod_wsgi with yum install python35u-mod_wsgi\nCan anyone help me with this issue? Thanks a lot.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":264,"Q_Id":52668420,"Users Score":0,"Answer":"this is really a stupid mistake.\nAs I suggested in the question, the mod_wsgi I'm using is for python3.5.\nSolved by uninstalling python35u-mod_wsgi and installing python36u-mod_wsgi.","Q_Score":0,"Tags":"python,django,apache,centos,python-imaging-library","A_Id":52670862,"CreationDate":"2018-10-05T14:59:00.000","Title":"Python3.6 - cannot import name '_imaging' [Django 2.1.2, Apache 2, CentOS 7]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using the object detection API from the models\/research python repo on Ubuntu 16.04, and I wanted to fine-tune a pre-trained model (at the moment I'm interested in SSD with MobileNet or Inception backbones) on the UA-DETRAC dataset.\nThe problem is that there are specific regions, with their bounding boxes, which are marked as \"ignored regions\" and I wouldn't want the model to train on what he thinks are some false positives which are true, just not annotated (included in those regions).\nI thought of cropping the images to exclude those regions, but I would lose some information.\nIs there the built-in possibility to mark them as \"don't care\" boxes or should I modify the code?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":811,"Q_Id":52668857,"Users Score":1,"Answer":"If those regions to ignore remain static, as in, the contents of the region doesn't change throughout the dataset, then the model can be learnt to ignore those regions. \nIf you really want the model to ignore them during training, then mask them with a constant value.","Q_Score":4,"Tags":"python,tensorflow,object-detection,tensorflow-serving,object-detection-api","A_Id":52670172,"CreationDate":"2018-10-05T15:23:00.000","Title":"Tensorflow Object Detection API: How to ignore regions during training?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that installing python packages using sudo pip install is bad a security risk. Unfortunately, I found this out after installing quite a few packages using sudo. \nIs there a way to find out what python packages I installed using sudo pip install? The end goal being uninstallment and correctly re-installing them within a virtual environment.\nI tried pip list to get information about the packages, but it only gave me their version. pip show <package name> gave me more information about an individual package such as where it is installed, but I don't know how to make use of that information.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1059,"Q_Id":52669951,"Users Score":1,"Answer":"any modules you installed with sudo will be owned by root, so you can open your shell\/terminal, cd to site-packages directory & check the directories owner with ls -la, then any that has root in the owner column is the one you want to uninstall.","Q_Score":1,"Tags":"python,pip,sudo","A_Id":52670311,"CreationDate":"2018-10-05T16:36:00.000","Title":"How can I see what packages were installed using `sudo pip install`?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that installing python packages using sudo pip install is bad a security risk. Unfortunately, I found this out after installing quite a few packages using sudo. \nIs there a way to find out what python packages I installed using sudo pip install? The end goal being uninstallment and correctly re-installing them within a virtual environment.\nI tried pip list to get information about the packages, but it only gave me their version. pip show <package name> gave me more information about an individual package such as where it is installed, but I don't know how to make use of that information.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1059,"Q_Id":52669951,"Users Score":0,"Answer":"try the following command: pip freeze","Q_Score":1,"Tags":"python,pip,sudo","A_Id":52670065,"CreationDate":"2018-10-05T16:36:00.000","Title":"How can I see what packages were installed using `sudo pip install`?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two classesClassA and ClassB with the same content and structure but just with different names. I saved an object of ClassA using pickle.dump to a binary file. However, I want to now load it in a different program which only has access to ClassB. Loading this file using pickle.load fails now as it can't find the ClassA description and thus throws some error like No module named ClassA exists.\nTo solve this, I manually investigated the saved binary file, and found the required class name ClassA coded in ASCII in the file. I guessed that it was looking for this exact class name, which resulted in the above error. Upon changing this name from ClassA to ClassB inside this binary file, the code seemed to be correctly loading the object, but now as ClassB. Which is what i wanted.\nHowever, since i manually edited this file, I was wondering if there would be any adverse effects down the line for doing this. Or is it, if it works it ain't stupid scenario.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1118,"Q_Id":52675046,"Users Score":2,"Answer":"None of the pickle formats use offsets into the file or any kind of compression or encryption, so changing the name is fine even if it changes the length.  You have to know that the text \u201cClassA\u201d doesn\u2019t appear for some other reason, of course, and that your editor won\u2019t mangle the file\u2014say, by trying to do character decoding\/encoding.\nThat said, in this situation I\u2019d probably create a dummy package to give ClassA the correct name rather than edit the pickle.","Q_Score":1,"Tags":"python,pickle","A_Id":52675343,"CreationDate":"2018-10-06T01:49:00.000","Title":"Manually editing a dumped pickle file 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 practicing on python 3.7.0 shell.\nHow can I import split() ?\nBelow is the error:\n\n\n\nfrom string import split\n      Traceback (most recent call last):\n        File \"\", line 1, in \n          from string import split\n      ImportError: cannot import name 'split' from 'string'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1322,"Q_Id":52676370,"Users Score":0,"Answer":"Probably you have to run your code on Python 2.x shell\nIn Python 3.x, string module does not have split method. so, it does not work on Python 3.x shell and you get such error","Q_Score":0,"Tags":"python,python-3.x","A_Id":52677000,"CreationDate":"2018-10-06T06:36:00.000","Title":"Problems in importing split in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am totally new to Jupyter Notebook.\nCurrently, I am using the notebook with R and it is working well.\nNow, I tried to use it with Python and I receive the following error.\n\n[I 09:00:52.947 NotebookApp] KernelRestarter: restarting kernel (4\/5),\n  new random ports\nTraceback (most recent call last):\nFile \"\/usr\/lib\/python3.6\/runpy.py\", line 193, in _run_module_as_main\n  \"main\", mod_spec)\nFile \"\/usr\/lib\/python3.6\/runpy.py\", line 85, in _run_code exec(code,\n  run_globals)\nFile\n  \"\/home\/frey\/.local\/lib\/python3.6\/site-packages\/ipykernel_launcher.py\",\n  line 15, in  from ipykernel import kernelapp as app\nFile\n  \"\/home\/frey\/.local\/lib\/python3.6\/site-packages\/ipykernel\/init.py\",\n  line 2, in  from .connect import *\nFile\n  \"\/home\/frey\/.local\/lib\/python3.6\/site-packages\/ipykernel\/connect.py\",\n  line 13, in  from IPython.core.profiledir import ProfileDir\nFile \"\/home\/frey\/.local\/lib\/python3.6\/site-packages\/IPython\/init.py\",\n  line 55, in  from .terminal.embed import embed\nFile\n  \"\/home\/frey\/.local\/lib\/python3.6\/site-packages\/IPython\/terminal\/embed.py\",\n  line 16, in  from IPython.terminal.interactiveshell import\n  TerminalInteractiveShell\nFile\n  \"\/home\/frey\/.local\/lib\/python3.6\/site-packages\/IPython\/terminal\/interactiveshell.py\",\n  line 20, in  from prompt_toolkit.formatted_text import PygmentsTokens\n  ModuleNotFoundError: No module named 'prompt_toolkit.formatted_text'\n[W 09:00:55.956 NotebookApp] KernelRestarter: restart failed [W\n  09:00:55.956 NotebookApp] Kernel 24117cd7-38e5-4978-8bda-d1b84f498051\n  died, removing from map.\n\nHopefully, someone can help me.","AnswerCount":5,"Available Count":2,"Score":-0.0399786803,"is_accepted":false,"ViewCount":13255,"Q_Id":52676660,"Users Score":-1,"Answer":"Check your environment variable Path!\nIn the system variable Path add the following line\n\nC:\\Users\\\\AppData\\Roaming\\Python\\Python37\\Scripts","Q_Score":1,"Tags":"python,jupyter-notebook,jupyter","A_Id":59511989,"CreationDate":"2018-10-06T07:18:00.000","Title":"No module named 'prompt_toolkit.formatted_text'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am totally new to Jupyter Notebook.\nCurrently, I am using the notebook with R and it is working well.\nNow, I tried to use it with Python and I receive the following error.\n\n[I 09:00:52.947 NotebookApp] KernelRestarter: restarting kernel (4\/5),\n  new random ports\nTraceback (most recent call last):\nFile \"\/usr\/lib\/python3.6\/runpy.py\", line 193, in _run_module_as_main\n  \"main\", mod_spec)\nFile \"\/usr\/lib\/python3.6\/runpy.py\", line 85, in _run_code exec(code,\n  run_globals)\nFile\n  \"\/home\/frey\/.local\/lib\/python3.6\/site-packages\/ipykernel_launcher.py\",\n  line 15, in  from ipykernel import kernelapp as app\nFile\n  \"\/home\/frey\/.local\/lib\/python3.6\/site-packages\/ipykernel\/init.py\",\n  line 2, in  from .connect import *\nFile\n  \"\/home\/frey\/.local\/lib\/python3.6\/site-packages\/ipykernel\/connect.py\",\n  line 13, in  from IPython.core.profiledir import ProfileDir\nFile \"\/home\/frey\/.local\/lib\/python3.6\/site-packages\/IPython\/init.py\",\n  line 55, in  from .terminal.embed import embed\nFile\n  \"\/home\/frey\/.local\/lib\/python3.6\/site-packages\/IPython\/terminal\/embed.py\",\n  line 16, in  from IPython.terminal.interactiveshell import\n  TerminalInteractiveShell\nFile\n  \"\/home\/frey\/.local\/lib\/python3.6\/site-packages\/IPython\/terminal\/interactiveshell.py\",\n  line 20, in  from prompt_toolkit.formatted_text import PygmentsTokens\n  ModuleNotFoundError: No module named 'prompt_toolkit.formatted_text'\n[W 09:00:55.956 NotebookApp] KernelRestarter: restart failed [W\n  09:00:55.956 NotebookApp] Kernel 24117cd7-38e5-4978-8bda-d1b84f498051\n  died, removing from map.\n\nHopefully, someone can help me.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":13255,"Q_Id":52676660,"Users Score":1,"Answer":"It's more stable to create a kernel with an Anaconda virtualenv.\nFollow these steps.\n\nExecute Anaconda prompt.\nType conda create --name $ENVIRONMENT_NAME R -y\nType conda activate $ENVIRONMENT_NAME\nType python -m ipykernel install\nType ipython kernel install --user --name $ENVIRONMENT_NAME\n\nThen, you'll have a new jupyter kernel named 'R' with R installed.","Q_Score":1,"Tags":"python,jupyter-notebook,jupyter","A_Id":52676845,"CreationDate":"2018-10-06T07:18:00.000","Title":"No module named 'prompt_toolkit.formatted_text'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As python has two ways to code one from python command and one from python shell what is the difference between these two?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10773,"Q_Id":52676663,"Users Score":8,"Answer":"Python Shell is a command line tool that starts up the python interpreter. You can test simple programs and also write some short programs. However, in order to write a more complexed python program you need an editor. IDLE, on the other hand, has combined the above two needs and bundled them as a package. IDLE consists of Python Shell, and Text editor that supports highlights for python grammar and etc.","Q_Score":2,"Tags":"python","A_Id":52676711,"CreationDate":"2018-10-06T07:18:00.000","Title":"what is the difference between python shell and IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm writing my first time in python - a console game. I reached the point where I have to make the decision wheter I should use singletons or not.\nThe situation:\nI have classes like (for example) Character. If you begin a new game, character creation starts (name your character, ...)\nAfter creating a character, I create an object from Character class character = Character(name, foo, bar)\nThe problem:\nWhen I need the character obj in other functions \/ classes later (for example to save it to a json file), I have to get access to the initially created object. I will never need multiple player objects\nNow I'm wondering if i should use singleton(s) or if i should always pass my object to places where I need it. Another option would be to store variables in a module and import the module if i need to get data.\nSo what do you think?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":125,"Q_Id":52677230,"Users Score":2,"Answer":"From the Zen of Python, \n\nSimple is better than complex.\n\nOne way to have only one player object is to create some sort of singleton pattern that forcibly restricts multiple players. A simpler way to accomplish the same goal is to just not instantiate a second player.\nIf you do want to force a singleton pattern for whatever reason (e.g. accessing the same character from multiple places), a module is far and away the best way to accomplish that effect. The syntax is easy to use, modules are easily accessible from an entire project, and any essential singleton machinery is already built-in to the module semantics.","Q_Score":0,"Tags":"python,python-3.x","A_Id":52677501,"CreationDate":"2018-10-06T08:39:00.000","Title":"Should I use a singleton for my console game?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python and I have been stuck on a problem for some time now. I recently installed the module pandas and at first, it worked fine. However, for some reason it keeps saying \n\nAttributeError(\"module 'pandas' has no attribute 'read_csv'\").\n\nI have looked all over StackOverflow and the consensus is that there is likely another file in my CWD with the same name but I believe I don't.  \nEven if I create a new project and call it, for example, Firstproject.py, and immediately import pandas as pd, I get the error.  \nI would appreciate the help. I can provide more info if required.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":9258,"Q_Id":52677658,"Users Score":0,"Answer":"There might be possibility that you are using this name for your script as read_csv.py  hence pandas itself confused what to import, if or csv.py then you can rename it to something else like test_csv_read.py.\nalso remove any files in the path naming read_csv.pyc  or csv.pyc .","Q_Score":0,"Tags":"python,pandas,attributeerror","A_Id":52677839,"CreationDate":"2018-10-06T09:34:00.000","Title":"AttributeError(\"module 'pandas' has no attribute 'read_csv'\")","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python and I have been stuck on a problem for some time now. I recently installed the module pandas and at first, it worked fine. However, for some reason it keeps saying \n\nAttributeError(\"module 'pandas' has no attribute 'read_csv'\").\n\nI have looked all over StackOverflow and the consensus is that there is likely another file in my CWD with the same name but I believe I don't.  \nEven if I create a new project and call it, for example, Firstproject.py, and immediately import pandas as pd, I get the error.  \nI would appreciate the help. I can provide more info if required.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":9258,"Q_Id":52677658,"Users Score":0,"Answer":"Here is the solution \nwhen you downloaded python its automatically download 32 you need to delete if you don't have 32 and go download 64 and then problem solved :)","Q_Score":0,"Tags":"python,pandas,attributeerror","A_Id":55653559,"CreationDate":"2018-10-06T09:34:00.000","Title":"AttributeError(\"module 'pandas' has no attribute 'read_csv'\")","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python and I have been stuck on a problem for some time now. I recently installed the module pandas and at first, it worked fine. However, for some reason it keeps saying \n\nAttributeError(\"module 'pandas' has no attribute 'read_csv'\").\n\nI have looked all over StackOverflow and the consensus is that there is likely another file in my CWD with the same name but I believe I don't.  \nEven if I create a new project and call it, for example, Firstproject.py, and immediately import pandas as pd, I get the error.  \nI would appreciate the help. I can provide more info if required.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":9258,"Q_Id":52677658,"Users Score":0,"Answer":"In my case, I had installed module \"panda\" instead of \"pandas\". I was getting this error, even when there was no conflicting .py files were present in working folder. \nThen I recognized my mistake, and then installed package \"pandas and problem got resolved.","Q_Score":0,"Tags":"python,pandas,attributeerror","A_Id":60574804,"CreationDate":"2018-10-06T09:34:00.000","Title":"AttributeError(\"module 'pandas' has no attribute 'read_csv'\")","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does VS Code have a function for writing brackets after printing automatically (Python)?\nWhere I can enable it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1021,"Q_Id":52680244,"Users Score":1,"Answer":"If you go to File > Preferences > Settings to open the settings JSON file, you find \"editor\" or \"autoClosing\". It is enabled by default, but in your case, it seems not. What you have to do is just change user settings and enable it.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":52680601,"CreationDate":"2018-10-06T14:51:00.000","Title":"Auto brackets after print, input","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Situation\nOur company generates waste from various locations in US. The waste is taken to different locations based on suppliers' treatment methods and facilities placed nationally.\nConsider a waste stream A which is being generated from location X. Now  the overall costs to take care of Stream A includes Transportation cost from our site as well treatment method. This data is tabulated.\nWhat I want to achieve\nI would like my python program to import excel table containing this data and plot the distance between our facility and treatment facility and also show in a hub-spoke type picture just like airlines do as well show data regarding treatment method as a color or something just like on google maps.\nCan someone give me leads on where should I start or which python API or module that might best suite my scenario?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":52680559,"Users Score":0,"Answer":"This is a rather broad question and perhaps not the best for SO.\nNow to answer it: you can read excel's csv files with the csv module. Plotting is best done with matplotlib.pyplot.","Q_Score":0,"Tags":"python","A_Id":52680640,"CreationDate":"2018-10-06T15:24:00.000","Title":"Hub and Spoke indication using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The passstatement is usually a placeholder for future code and is used as a null operation.\nBut why it's not defined a type in Python. Should't it belong to None type?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":265,"Q_Id":52682332,"Users Score":4,"Answer":"Objects have types. Statements do not. pass is a statement, and does not have a type. (Also, None is not a type.)","Q_Score":1,"Tags":"python","A_Id":52682338,"CreationDate":"2018-10-06T18:52:00.000","Title":"What type is 'pass' in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a machine learning project and I am wondering whether it is possible to change the loss function while the network is training. I'm not sure how to do it exactly in code.\nFor example, start training with cross entropy loss and then halfway through training, switch to 0-1 loss.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":783,"Q_Id":52682979,"Users Score":0,"Answer":"You have to implement your own algorithm. This is mostly possible with Tensorflow.","Q_Score":0,"Tags":"python,tensorflow,machine-learning","A_Id":52695712,"CreationDate":"2018-10-06T20:14:00.000","Title":"Is it possible to change the loss function dynamically during training?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on Django app and i have only one page in my templates directory named \"index\", everything is working well but i faced a problem when i wanted to display the result which will be passed by Django views to my HTML page. I want the value to be displayed on my input field instead of printing it on the browser. I searched a lot but i couldn't found anything related to this.\nI have three fields:\n\nkey field.\nPlaintext field.\nCiphertext field.\nand one button for encryption & decryption.\n\nI need when i click on the button, the result will be displayed on my Ciphertext field not on the browser because i already did that before.\nCan you help me?\nThanks..","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1165,"Q_Id":52683508,"Users Score":0,"Answer":"One of the multiple ways is to, \n\nrender the template from view.\npass the values for \"key field\" and \"plain text filed\" into the context variable (ex: return render(request, context={'key_filed': key_field_value, 'plain_text_field': plain_text_field_value} ).\nUse these values in \"value=\" field of < input > tag. (ex: < inpu type='text' value={{ key_filed }} > and < inpu type='text' value={{ plain_text_field }} >)","Q_Score":1,"Tags":"django,python-3.x,django-templates,django-views","A_Id":52690774,"CreationDate":"2018-10-06T21:30:00.000","Title":"display any value from django views to html form input","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've used MQTT Paho libraries before using Python. What actually happens when a topic was established? e.g \"home\/kitchen\/lights\". \nDoes the program create folders based on the topic? Since it uses slash as a separator. Or does the program store the topic as a string?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":47,"Q_Id":52683596,"Users Score":1,"Answer":"Nothing on the client side, in fact most client libraries don't even keep a list of the topics they are subscribed (the client library doesn't need to know once it's sent the request to the broker).\nOn the broker it entirely depends on the implementation, it could be a list of strings, it could be a tree structure.\nA topic is not a file path just because it uses a \/ doesn't mean it has anything to do with paths.","Q_Score":0,"Tags":"python,mqtt,iot,paho","A_Id":52685225,"CreationDate":"2018-10-06T21:45:00.000","Title":"Indepth MQTT's topic","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working in RedHat OpenStack project and I need to know good test cases for reliability, performance, and function test cases for RedHat OpenStack. I already looked at the Tempest test. but I'm asking if there's any other test I can follow?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":124,"Q_Id":52684200,"Users Score":1,"Answer":"I realize that you mention that you've already looked at Tempest, but I would strongly encourage you to take a second look. I understand that the documentation is a little underwhelming and tailoring the tempest configuration to your deployment can be a significant time investment. Beyond its documentation, it's a well-maintained OpenStack project and running sanity checks doesn't take too long to configure. The results can be truly revealing.\nCreate a tempest workspace and conduct sanity checks with --smoke or -s\nCreate a workspace with tempest init myworkspace. This will create the directory structure for you based off of what exists in \/etc\/tempest. If you've already configured your \/etc\/tempest, you're a step ahead, otherwise, you'll need to configure your myworkspace\/etc\/tempest.conf before running any test.\nOnce your workspace is configured for your deployment, execute tempest run --smoke from the workspace directory. This will execute ~100 smoke tests for basic cloud functionality and sanity testing. With my modest deployment, this doesn't take more than 3-5 minutes to get some worthwhile results.\nResults from --subunit\nContinuing with the myworkspace directory, running your smoketests with the --subunit flag (tempest run --smoke --subunit) produces the html-exportable subunit docs at workspace\/.stestr\/$iteration where $iteration is a 0-indexed iteration of tempest run you've executed.\nFor example, after your first iteration, run subunit2html .stestr\/0 to generate a well-formatted results.html for your review.\nBeyond Smoketesting\nIf you start here and iterate, I think it naturally progresses into running the full gamut of tests. The workflow is a bit different from the smoke testing:\n\nGenerally start with tempest cleanup --init-saved-state which will produce a pre-test state of your cloud, a veritable snapshot of the resources you do not want to cleanup in post. The state is stored at saved_state.json.\nRun your tests with options tailored to your deployment, most basically tempest run.\nAfter analyzing your results, a run of tempest cleanup will destroy resources that do not exists in the saved_state.json file.","Q_Score":0,"Tags":"python,cloud,integration-testing,redhat,openstack","A_Id":52689994,"CreationDate":"2018-10-06T23:29:00.000","Title":"Test cases for Redhat OpenStack?","Data Science and Machine Learning":0,"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 the following problem; I have a module that reads a 1.5Gb file and then processes it with it. If I run it in the Python console it works normally, however if I make the call from that file read in a django view it returns error 500 before it highlights the entire file load.\nHow to proceed?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":544,"Q_Id":52684364,"Users Score":1,"Answer":"Since the shell is executing the complete request, the request could be getting timed out due to app server or web server:\n\nIf using Nginx as web server, try increasing read time out: proxy_read_timeout < a high value in sec >\nIf using Gunicorn as app server, try increasing this as well:\nTIMEOUT=< a high value in sec >\nIf using wsgi as app server, try either:\nhttp-timeout=< a high value in sec >.","Q_Score":0,"Tags":"python,django,internal-server-error,file-read","A_Id":52690604,"CreationDate":"2018-10-07T00:05:00.000","Title":"Internal server error with large file in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am searching for a way to make my training and testing data smaller in file size.\nThe model I want to end up with\nI want to train a model that predicts whether or not a crypto coin price is making and x% (0.4 or so) jump within the next 10 minutes (i.e. I want the model to answer with a Yes or No). \nEvery minute I will the model with the last 3 hours of price and volume data (that means 180 datapoints each containing 5 values open, close, high, low prices and volume).\nMy current training and testing sets are BIG\nMy training and testing sets are therefore row in a csv file where each row contains 5 x 180 = 900 numbers plus one label (Yes or No) and with about 100k rows I guess this is a very huge dataset.\nBut each row in csv contains mostly redundant data\nBut each \"neighbor\" row in the csv file only contain 1 new data point since every next row is only 1 minute \"older\" and therefore only has skipped the data point of oldest minute and instead introduced a new point of the next minute.\nIs it possible to setup up the traing code so the csv file only needs to have the latest minute data point in each row?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":133,"Q_Id":52685768,"Users Score":0,"Answer":"If you use Data API then you can cache the input. Also maybe TF's support for Kafka might be a help here as you could model it as a stream of data. \nAnother approach would be to reuse some data between session calls. Then you would have to use resource variable (in the current Variable() spec it means using flag use_resource in the constructor). This way your csv could contain only minute level data and you would just add it to the variable - create a kind of circle-buffer from it.","Q_Score":0,"Tags":"python,tensorflow,dataset,tensorflow-datasets","A_Id":52807275,"CreationDate":"2018-10-07T05:39:00.000","Title":"Tensorflow: Each row in the training dataset contains 99% of the previous rows data - can I optimize it before running the training?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I built a small GUI using Tkinter. The GUI features, among some other elements, three buttons. These buttons serve to open a dystem dialog and select certain data-files etc. One of the three buttons is a 'Go' button that runs the underlying data-processing.\nWhen running the .py script the GUI works fine. However, after creating a developer app in alias mode using Py2App the buttons have become invisible! They're still there and usable, but invisible until interacted with.\nHow can I prevent this from happening?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":198,"Q_Id":52688867,"Users Score":1,"Answer":"I was stuck in your exact situation for quite some time. When I ran my tkinter script, it worked perfectly and all the buttons showed up, but once I packaged it, the buttons stopped showing up (They were still there but you couldn't see them). After a long time of trying random things, I found out how to make the buttons and their text show up again. Simply resize the window. Even a difference of 1 or 2 pixels does the trick. I have not yet found a way to PREVENT this issue, but at least this makes the app look right. \nPlease reply if you figure out a solution to prevent this!\nGood Luck!","Q_Score":2,"Tags":"python,tkinter,py2app","A_Id":53104834,"CreationDate":"2018-10-07T13:16:00.000","Title":"Tkinter GUI buttons become invisible after creating app using Py2App","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I modify the \"Severity of Pylint message type\" parameter to \"hint\", the hints in the editing area are not obvious enough, only a few dots.\nError or Warning\nCan the tilde color of the prompt be customized?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":52689629,"Users Score":0,"Answer":"If the squiggle for a problem in Pylint are not very long it's because Pylint doesn't provide more details than the line where the issue occurs. In other words there's nothing the extension can do in those cases.","Q_Score":0,"Tags":"python,visual-studio-code,linter","A_Id":52730572,"CreationDate":"2018-10-07T14:47:00.000","Title":"Is the lint mode function available?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed the conda clean package and anaconda navigator.\nWhen I use the command anaconda-navigator it says command not found\nSame goes for anaconda-clean.\nWhen I type in the respective installation commands the terminal says that requirements are already fulfilled.\nOS - Ubuntu 16.04 LTS","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":52691790,"Users Score":0,"Answer":"Updating conda fixed the problem.","Q_Score":0,"Tags":"python,linux,anaconda","A_Id":52709357,"CreationDate":"2018-10-07T18:53:00.000","Title":"Cannot execute conda commands even though conda is installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have seen multiple questions for the same issue. I went through all the answers and tried all of them. I updated pip, tensorflow, python etc to the latest versions or as suggested in the answers and still I am facing this issue.\nPip version 18.0,\nPython 3.7","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":52692622,"Users Score":1,"Answer":"Please downgrade Python to 3.6.x and try again. I had faced similar issue while using Python 3.7.x. Once I downgraded it, it worked. Make sure you adjust your path variable accordingly. \"Pip\" also may have to be modified and the corresponding path variable.","Q_Score":1,"Tags":"python,tensorflow","A_Id":52692667,"CreationDate":"2018-10-07T20:28:00.000","Title":"Error - No module named '_pywrap_tensorflow'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Folks, I have a scraping script that I need to run on specific times for live info, but I can't have my computer on me all day. So I thought about running it on an online interpreter, but repl.it doesn't have webdriver and the other I found didn't neither. Could you help me with that?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":694,"Q_Id":52693693,"Users Score":0,"Answer":"I'm not sure, but I don't guess if you can do it on a free online interpreter!\nYou can buy a server and use that, You can SSH to it anytime you want, or even better, You can develop a micro web service using Flask or something else to report the data you need!\nOther way I can think of is let your computer be online 24\/7 and use smtplib to email yourself the data in an interval!","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,pythoninterpreter,repl.it","A_Id":52693719,"CreationDate":"2018-10-07T23:09:00.000","Title":"How to run Selenium with Webdriver on Online Python interpreters?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"It seems we can achieve same goal using pivot_table from both libraries, but which one is more efficient in performance for large dataset?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":515,"Q_Id":52694289,"Users Score":1,"Answer":"Definitely Dask. The way pandas work is, it processes everything as a monolithic block in memory and is not parallelizable, while Dask is made to break the data frame into chunks that can be processed in parallel.","Q_Score":1,"Tags":"python,python-3.x,pandas,pivot-table,dask","A_Id":52694329,"CreationDate":"2018-10-08T01:18:00.000","Title":"Difference between dask pivot_table and pandas pivot_table python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a library that can split a number into multiple parts, but makes sure all the parts are rounded numbers?\nFor example, splitting 100 into 3 would be 33.33, but I would like it to be rounded and make sure the total sum stays as 100 also:\n[34 33 33]","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1282,"Q_Id":52697875,"Users Score":0,"Answer":"I think you can implement it without libraries.\n1) If the number n is divided by 3, then the output would be [n\/3, n\/3, n\/3]\n2) If the number n = 3k + 1(k>=0), then the output would be [(n\/3)+1, n\/3, n\/3]\n3) Otherwise, the output would be [(n\/3)+1, (n\/3)+1, n\/3]","Q_Score":2,"Tags":"python,rounding","A_Id":52697966,"CreationDate":"2018-10-08T08:03:00.000","Title":"Split number into rounded numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to pull messages from a RabbitMQ queue, wrap them in a object and dispatch for some kind of processing. Ofcourse I could iteratively do that until the queue is empty, but I was wondering if there is any other way (some flag of some kind) or a neater way.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":202,"Q_Id":52699030,"Users Score":1,"Answer":"RabbitMQ does not support batches of messages, so you do indeed need to consume each message individually. \nMaybe an alternative would be to batch the messages yourself by publishing one large message with all the required content.","Q_Score":0,"Tags":"python-2.7,rabbitmq,pika","A_Id":52726069,"CreationDate":"2018-10-08T09:18:00.000","Title":"Is it possible to pull all messages from a RabbitMQ queue 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the issue of a PyQt-based GUI application occasionally crashing at exit with either a segmentation fault or an error message that indicates an unhandled C++ exception was encountered.\nWhile running, there are no such issues, this problem is most likely caused by some step in the application shutdown.\nHow can I best debug such a \"mixed\" scenario of Python and C++, except for actually wrapping the application launch command with gdb, or explicitly enabling core dumps and trying a \"post-mortem\" analysis on the resulting core file?\nThank you very much!\nFabian Aichele","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":52701748,"Users Score":0,"Answer":"A real-world approach is to keep a registry of active objects. Add each object in its ctor, remove in the dtor. In members that you've seen crash, check if this appears in the registry. If that doesn't help, add these checks also to related methods\nIt's formally Undefined Behavior already to call that method, but you already have UB. However, this method won't work too well on virtual calls. In that case, it's a good moment to introduce the public non-virtual\/protected virtual pattern: Replace a virtual public method X with a pair public: auto X() { checkAlive(this); return doX(); } protected: virtual Foo doX();\nThis pattern is also good for various other assertions,logging and similar non-functionals.","Q_Score":0,"Tags":"python,c++,debugging","A_Id":52702690,"CreationDate":"2018-10-08T11:57:00.000","Title":"How to debug non-deterministic segmentation faults in a mixed Python-C++ library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a random forest multi-classifier model. Basically there are hundred of households which have 200+ features, and based on these features I have to classify them in one of the classes {1,2,3,4,5,6}. \nThe problem I am facing is I cannot improve the accuracy of the model how much ever I can try. I have used RandomSearchCV and also GridSearchCV but I can only achieve accuracy of around 68%.\nSome points to note\n\nThe sample points are unbalanced. This is the order of classes in decreasing order {1,4,2,7,6,3}. I have used class_weight = \"balanced\" but it does improve the accuracy.\nI have tried number of estimators ranging from 50-450\nI have also calculated the f1 score and not only going by accuracy to compare the models\n\nWhat else do you guys suggest to improve the accuracy\/f1-score? I am stuck with this problem from a long time. Any help will be highly appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":52703577,"Users Score":0,"Answer":"Try to tune below parameters\nn_estimators\nThis is the number of trees you want to build before taking the maximum voting or averages of predictions. Higher number of trees give you better performance but makes your code slower.\nmax_features\nThese are the maximum number of features Random Forest is allowed to try in individual tree. There are multiple options available in Python to assign maximum features.\nmin_sample_leaf\nLeaf is the end node of a decision tree. A smaller leaf makes the model more prone to capturing noise in train data. You can start with some minimum value like 75 and gradually increase it. See which value your accuracy is coming high.\nOtherwise:\n\nYou can try XGBoost, LightGBM or Adaboost, they often perform better than Random Forest\n\nTry do not remove missing values, complex ensemble models such as RF and GBM treats it well, may be you lost some useful information doing so, especially if you have large percent of your data missing in some features\n\nTry to increase n_estimators and max_depth, may be your trees not deep enough to catch all data properties","Q_Score":0,"Tags":"python,random-forest,multiclass-classification","A_Id":70800730,"CreationDate":"2018-10-08T13:37:00.000","Title":"Random Forest Multi Class Python does not improve accuracy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a random forest multi-classifier model. Basically there are hundred of households which have 200+ features, and based on these features I have to classify them in one of the classes {1,2,3,4,5,6}. \nThe problem I am facing is I cannot improve the accuracy of the model how much ever I can try. I have used RandomSearchCV and also GridSearchCV but I can only achieve accuracy of around 68%.\nSome points to note\n\nThe sample points are unbalanced. This is the order of classes in decreasing order {1,4,2,7,6,3}. I have used class_weight = \"balanced\" but it does improve the accuracy.\nI have tried number of estimators ranging from 50-450\nI have also calculated the f1 score and not only going by accuracy to compare the models\n\nWhat else do you guys suggest to improve the accuracy\/f1-score? I am stuck with this problem from a long time. Any help will be highly appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":52703577,"Users Score":0,"Answer":"You can check if the features are on different scales. If they are, it is  suggested to use some type of normalization. This step is essential for many linear-based models to perform well. You can take a quick look at the distributions of each numeric feature to decide what type of normalization to use.","Q_Score":0,"Tags":"python,random-forest,multiclass-classification","A_Id":70800413,"CreationDate":"2018-10-08T13:37:00.000","Title":"Random Forest Multi Class Python does not improve accuracy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using ElastiCache for Redis on AWS. But, I'm not able to connect to Redis from localhost. I have used the endpoint on AWS. It always shows connection timed out. Is there a way to make it work?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":511,"Q_Id":52705563,"Users Score":0,"Answer":"The first thing you should make sure is the VPC Security Group that the Elasticache Redis is attached, allows Custom TCP traffic from your address to port number 6379 (default for Redis). \nFor me the connection timed out issue arised due to the inaccessibility to the VPC where the Redis cluster resides.","Q_Score":1,"Tags":"python,amazon-web-services,redis,amazon-elasticache","A_Id":52706805,"CreationDate":"2018-10-08T15:27:00.000","Title":"Connecting to Redis from localhost","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am using ElastiCache for Redis on AWS. But, I'm not able to connect to Redis from localhost. I have used the endpoint on AWS. It always shows connection timed out. Is there a way to make it work?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":511,"Q_Id":52705563,"Users Score":0,"Answer":"Check your security group of Elastic cache cluster. It should allow port 6379 from the EC2 instance. You can allow your EC2 instance's security group in Elastic cache security group to access port 6379.","Q_Score":1,"Tags":"python,amazon-web-services,redis,amazon-elasticache","A_Id":52707528,"CreationDate":"2018-10-08T15:27:00.000","Title":"Connecting to Redis from localhost","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"but I have been trying to play around with it for awhile. I've seen a lot of guides on how Keras is used to build LSTM models and how people feed in the inputs and get expected outputs. But what I have never seen yet is, for example stock data, how we can make the LSTM model understand patterns between different dimensions, say close price is much higher than normal because volume is low.\nPoint of this is that I want to do a test with stock prediction, but make it so that each dimensions are not reliant on previous time steps, but also reliant on other dimensions it haves as well.\nSorry if I am not asking the question correctly, please ask more questions if I am not explaining it clearly.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":52706996,"Users Score":0,"Answer":"First: Regressors will replicate if you input a feature that gives some direct intuition about the predicted input might be to secure the error is minimized, rather than trying to actually predict it. Try to focus on binary classification or multiclass classification, whether the closing price go up\/down or how much. \nSecond: Always engineer the raw features to give more explicit patterns to the ML algorithm. Think on inputs as Volume(t) - Volume(t-1), close(t)^2 - close(t-1)^2, technical indicators(RSI, CCI, OBV etc.) Create your own features. You can use the pyti library for technical indicators.","Q_Score":0,"Tags":"python,machine-learning,keras,lstm,rnn","A_Id":52786576,"CreationDate":"2018-10-08T17:02:00.000","Title":"Keras LSTM Input Dimension understanding each other","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a Python package which makes frequent indirect calls to a low level function low_level_a(arg). What I mean by 'indirect' is that the function is often hidden behind several layers of higher level functions and classes.\nI now want to implement an alternate version of the function, low_level_b(arg), which takes the same kind of arguments and returns the same kinds of outputs. My objective is to allow the user to switch between using low_level_a(arg) and low_level_b(arg) when calling the highest level functions.\nMy first idea is to write an optional argument for the low level function to toggle between versions: low_level(arg, option='a'). However, as far as I can tell, this forces me to add the optional argument option='a' to every intermediate function which potentially leads to calling low_level.\nMy instinct says that this would obfuscate the intermediate functions, especially if in future I want to keep adding such optional arguments.\nWhat is a clear and scalable way of allowing the user to select various versions of low_level options?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":114,"Q_Id":52707389,"Users Score":0,"Answer":"You can reduce the verbosity by packing all such \u201cadverb\u201d settings as attributes of one flags argument.  (It\u2019s often convenient to use a namedtuple type to hold them and provide defaults.)\nIf the intermediate layers can be expressed as methods on a small number of classes, the options can be stored as attributes whose mention can be absorbed into self.  (For free functions that accept the options in a standard fashion, a helper class can be made that exposes the functions as methods via __getattr__ and provides the options automatically.)","Q_Score":1,"Tags":"python,oop,architecture,options","A_Id":52708522,"CreationDate":"2018-10-08T17:32:00.000","Title":"Clear way of accessing options to low level functions in high level functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed nlopt with the: conda install -c conda-forge nlopt \nand I can see the package installed when I do: conda list \nbut when I try to import it on Spyder, I get the message: No module named 'nlopt'. \nI'm running it on Windows 10, if that is any help, and I'm completely new to python! \nAnyone have any idea on how to solve it?\nThanks in advance :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":918,"Q_Id":52710472,"Users Score":0,"Answer":"It usually happens while working in several environments.\n\nCheck the environment in which nlopt is installed.\nCheck if Spyder is in the same environment. To do that, you can go to Spyder > Tools > Python interpreter > Use the following Python interpreter and browse to the python.exe of the environment where nlopt is installed. (anaconda3\/envs\/your_env\/python.exe)\nYou can also activate the environment and do a where spyder which will give you instances of Spyder. \n\n...\\anaconda3\\envs\\your_env\\Scripts\\spyder.exe\n ...\\Anaconda3\\Scripts\\spyder.exe\nYou can copy and run the exe file corresponding to your environment (here, the first one) and it will launch Spyder in that specific environment.","Q_Score":1,"Tags":"python,nlopt","A_Id":52986744,"CreationDate":"2018-10-08T21:39:00.000","Title":"I have nlopt installed but get the message: no module named 'nlopt'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What options do I set for chromedriver so that the web server cannot tells the browser is manually launched or programming launched using Selenium?\nThanks,","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":67,"Q_Id":52712046,"Users Score":1,"Answer":"The Webserver you try to access has no way of knowing how the browser has been launched. It can only detect (or rather, guess) that it's an automated browser when said browser shows atypical behavior for a human (e.g. makes loads of requests per seconds, clicks 2 things with no delay whatsoever). Therefor it doesn't matter how you launch the browser - just how you use it.","Q_Score":1,"Tags":"python,selenium,selenium-webdriver","A_Id":52712071,"CreationDate":"2018-10-09T01:17:00.000","Title":"Launching Chromedriver using Selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that reads data from an OPCDA server and then push it to InfluxDB.\nSo basically it connects to the OPCDA using the OpenOPC library and to InfluxDB using the InfluxDB Python client and then starts an infinite while loop that runs every 5 seconds to read and push data to the database.\nI have installed the script as a Service using NSSM. What is the best practice to ensure that the script is running 24\/7 ? How to avoid crashes ?\nShould i daemonize the script ?\nThank you in advance,\nBnjroos","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":534,"Q_Id":52713401,"Users Score":0,"Answer":"I suggest at least to add logging at the script level. You could also use custom Exit Codes from python so NSSM knows to report failure. Your failure would probably be when connecting to your services so, i.e. netowrk down or something so you could write custom exceptions for NSSM to restart. If it's running every 5 seconds you would probably know very soon.\nEnsuring availability and avoiding crashes is about your code more than infrastructure, hence the above recommendations. \nI believe using NSSM (for scheduling and such) is better than daemonizing, since you're basically adding functionality of NSSM in your script and potentially adding more code that may fail.","Q_Score":1,"Tags":"python,windows,loops,service","A_Id":52713941,"CreationDate":"2018-10-09T04:28:00.000","Title":"Best practice for an infinite loop Python script that runs on Windows as a Service","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"We are trying to order a 128 subnet. But looks like it doesn't work, get an error saying Invalid combination specified for ordering a subnet. The same code works to order a 64 subnet. Any thoughts how to order a 128 subnet? \n\nnetwork_mgr = SoftLayer.managers.network.NetworkManager(client)\nnetwork_mgr.add_subnet(\u2018private\u2019, 128, vlan_id, test_order=True)\n\n\nTraceback (most recent call last):\n  File \"subnet.py\", line 11, in <module>\n    result = nwmgr.add_subnet('private', 128, vlan_id, test_order=True)\n  File \"\/usr\/local\/lib\/python2.7\/site-packages\/SoftLayer\/managers\/network.py\", line 154, in add_subnet\n    raise TypeError('Invalid combination specified for ordering a'\nTypeError: Invalid combination specified for ordering a subnet.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":52714654,"Users Score":0,"Answer":"Currently it seems not possible to add 128 ip subnet into the order, the package used by the manager to order subnets only allows to add subnets for: 64,32,16,8,4 (capacity),\nIt is because the package that does not contain any item that has 128 ip addresses subnet, this is the reason why you are getting the error Exception you provided.\nYou may also verify this through the Portal UI, if you can see 128 ip address option through UI in your account, please update this forum with a screenshot.","Q_Score":0,"Tags":"python-2.7,ibm-cloud-infrastructure","A_Id":52730451,"CreationDate":"2018-10-09T06:31:00.000","Title":"SoftLayer API: order a 128 subnet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am debating whether to include the line loop = asyncio.get_event_loop() once per file or to write loop = asyncio.get_event_loop() every time I need a handle on the event loop, so several times throughout the file inside various methods which need to create tasks.   \nMy colleague is arguing that having globals outside of classes is poor style. But I am not delighted about wasting CPU cycles with the, however small, overhead on this get_event_loop method as well as simply the extra line of code in each method.\nWhich is the better way?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":107,"Q_Id":52717478,"Users Score":3,"Answer":"In Python 3.7 the amortized time of get_event_loop() call if barely comparable with a time of C function call and much faster than Python function call time.\nFor Python 3.6 the function is a little slower but still is not a bottleneck for any user code I bet.","Q_Score":1,"Tags":"python-asyncio","A_Id":52744253,"CreationDate":"2018-10-09T09:19:00.000","Title":"Overhead on get_event_loop() call","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I forget to add the Python to the path while installing it, how can I add it to my Windows path?\nWithout adding it to the path I am unable to use it. Also if I want to put python 3 as default.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":164,"Q_Id":52718655,"Users Score":1,"Answer":"Edit Path in Environment Variables\nAdd Python's path to the end of the list (these are separated by ';').\nFor example:\n\nC:\\Users\\AppData\\Local\\Programs\\Python\\Python36;\nC:\\Users\\AppData\\Local\\Programs\\Python\\Python36\\Scripts\n\nand if you want to make it default\nyou have to edit the system environmental variables\nedit the following from the Path\n\nC:\\Windows;C:\\Windows\\System32;C:\\Python27\n\nNow Python 3 would have been become the default python in your system\nYou can check it by python --version","Q_Score":1,"Tags":"python,windows,path","A_Id":52718656,"CreationDate":"2018-10-09T10:19:00.000","Title":"Add Python to the Windows path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"We've built a large python repo that uses lots of libraries (numpy, scipy, tensor flow, ...) And have managed these dependencies through a conda environment. Basically we have lots of developers contributing and anytime someone needs a new library for something they are working on they 'conda install' it. \nFast forward to today and now we need to deploy some applications that use our repo. We are deploying using docker, but are finding that these images are really large and causing some issues, e.g. 10+ GB. However each individual application only uses a subset of all the dependencies in the environment.yml. \nIs there some easy strategy for dealing with this problem? In a sense I need to know the dependencies for each application, but I'm not sure how to do this in an automated way. \nAny help here would be great. I'm new to this whole AWS, Docker, and python deployment thing... We're really a bunch of engineers and scientists who need to scale up our software. We have something that works, it just seems like there has to be a better way .","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2376,"Q_Id":52719729,"Users Score":3,"Answer":"First see if there are easy wins to shrink the image, like using Alpine Linux and being very careful about what gets installed with the OS package manager, and ensuring you only allow installing dependencies or recommended items when truly required, and that you clean up and delete artifacts like package lists, big things you may not need like Java, etc.\nThe base Anaconda\/Ubuntu image is ~ 3.5GB in size, so it's not crazy that with a lot of extra installations of heavy third-party packages, you could get up to 10GB. In production image processing applications, I routinely worked with Docker images in the range of 3GB to 6GB, and those sizes were after we had heavily optimized the container.\nTo your question about splitting dependencies, you should provide each different application with its own package definition, basically a setup.py script and some other details, including dependencies listed in some mix of requirements.txt for pip and\/or environment.yaml for conda.\nIf you have Project A in some folder \/ repo and Project B in another, you want people to easily be able to do something like pip install <GitHub URL to a version tag of Project A> or conda env create -f ProjectB_environment.yml or something, and voila, that application is installed.\nThen when you deploy a specific application, have some CI tool like Jenkins build the container for that application using a FROM line to start from your thin Alpine \/ whatever container, and only perform conda install or pip install for the dependency file for that project, and not all the others.\nThis also has the benefit that multiple different projects can declare different version dependencies even among the same set of libraries. Maybe Project A is ready to upgrade to the latest and greatest pandas version, but Project B needs some refactoring before the team wants to test that upgrade. This way, when CI builds the container for Project B, it will have a Python dependency file with one set of versions, while in Project A's folder or repo of source code, it might have something different.","Q_Score":5,"Tags":"python,amazon-web-services,docker","A_Id":52719901,"CreationDate":"2018-10-09T11:15:00.000","Title":"Deploying python with docker, images too big","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am moving a website from my local dev machine to PA.  I'm getting a template not found error. After a bit of searching, it appears that it is not finding the django_comments form.html template in the templates directory.  Presumably, because of this, collectstatic isn't creating the static file to serve.  Looking at the install on my dev machine, there is a template directory in the site-package but not in the package on PA.  I notice that my django.contrib_comments distro is 1.9.0 while it is 1.8.0 on PA.  (artifact of my venv creation?)\nMy question is \"am I missing something\".  I can certainly get around the problem by including the templates in my own directory, but for obvious reasons, I'd rather not.\nSuggestions?   (if I run pip install, I'm getting a unicode not defined error)\nThx,\n   --Don","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":99,"Q_Id":52720337,"Users Score":1,"Answer":"You need to make sure that the versions for all your packages (python.contrib_comments or otherwise) are the same locally vs on PA.\nOne way to do this by doing a pip freeze > requirements.txt locally, then upload the requirements.txt onto PythonAnywhere, set up a virtualenv on PythonAnywhere, and pip install -r requirements.txt to get the correct version of all the packages. Then configure your PythonAnywhere webapp to use that virtualenv on your webapp dashboard.","Q_Score":0,"Tags":"django,pythonanywhere","A_Id":52722511,"CreationDate":"2018-10-09T11:47:00.000","Title":"django_comments site package missing templates?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a database of images that contains identity cards, bills and passports.\nI want to classify these images into different groups (i.e identity cards, bills and passports).\nAs I read about that, one of the ways to do this task is clustering (since it is going to be unsupervised).\nThe idea for me is like this: the clustering will be based on the similarity between images (i.e images that have similar features will be grouped together).\nI know also that this process can be done by using k-means.\nSo the problem for me is about features and using images with K-means.\nIf anyone has done this before, or has a clue about it, please would you recommend some links to start with or suggest any features that can be helpful.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":4082,"Q_Id":52721662,"Users Score":1,"Answer":"I have implemented Unsupervised Clustering based on Image Similarity using Agglomerative Hierarchical Clustering.\nMy use case had images of People, so I had extracted the Face Embedding (aka Feature) Vector from each image. I have used dlib for face embedding and so each feature vector was 128d. \nIn general, the feature vector of each image can be extracted. A pre-trained VGG or CNN network, with its final classification layer removed; can be used for feature extraction.\nA dictionary with KEY as the IMAGE_FILENAME and VALUE as the FEATURE_VECTOR can be created for all the images in the folder. This will make the co-relation between the filename and it\u2019s feature vector easier.\nThen create a single feature vector say X, which comprises of individual feature vectors of each image in the folder\/group which needs to be clustered. \nIn my use case, X had the dimension as : NUMBER OF IMAGE IN THE FOLDER, 128 (i.e SIZE OF EACH FEATURE VECTOR). For instance, Shape of X : 50,128\nThis feature vector can then be used to fit an Agglomerative Hierarchical Cluster. One needs to fine tune the distance threshold parameter empirically.\nFinally, we can write a code to identify which IMAGE_FILENAME belongs to which cluster.\nIn my case, there were about 50 images per folder so this was a manageable solution. This approach was able to group image of a single person into a single clusters. For example, 15 images of PERSON1 belongs to CLUSTER 0, 10 images of PERSON2 belongs to CLUSTER 2 and so on\u2026","Q_Score":7,"Tags":"python,computer-vision,cluster-analysis,k-means,unsupervised-learning","A_Id":62167763,"CreationDate":"2018-10-09T12:58:00.000","Title":"Clustering images using unsupervised Machine Learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a database of images that contains identity cards, bills and passports.\nI want to classify these images into different groups (i.e identity cards, bills and passports).\nAs I read about that, one of the ways to do this task is clustering (since it is going to be unsupervised).\nThe idea for me is like this: the clustering will be based on the similarity between images (i.e images that have similar features will be grouped together).\nI know also that this process can be done by using k-means.\nSo the problem for me is about features and using images with K-means.\nIf anyone has done this before, or has a clue about it, please would you recommend some links to start with or suggest any features that can be helpful.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":4082,"Q_Id":52721662,"Users Score":3,"Answer":"Label a few examples, and use classification.\nClustering is as likely to give you the clusters \"images with a blueish tint\", \"grayscale scans\" and \"warm color temperature\". That is a quote reasonable way to cluster such images.\nFurthermore, k-means is very sensitive to outliers. And you probably have some in there.\nSince you want your clusters correspond to certain human concepts, classification is what you need to use.","Q_Score":7,"Tags":"python,computer-vision,cluster-analysis,k-means,unsupervised-learning","A_Id":52735568,"CreationDate":"2018-10-09T12:58:00.000","Title":"Clustering images using unsupervised Machine Learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a database of images that contains identity cards, bills and passports.\nI want to classify these images into different groups (i.e identity cards, bills and passports).\nAs I read about that, one of the ways to do this task is clustering (since it is going to be unsupervised).\nThe idea for me is like this: the clustering will be based on the similarity between images (i.e images that have similar features will be grouped together).\nI know also that this process can be done by using k-means.\nSo the problem for me is about features and using images with K-means.\nIf anyone has done this before, or has a clue about it, please would you recommend some links to start with or suggest any features that can be helpful.","AnswerCount":3,"Available Count":3,"Score":0.3215127375,"is_accepted":false,"ViewCount":4082,"Q_Id":52721662,"Users Score":5,"Answer":"Most simple way to get good results will be to break down the problem into two parts :\n\nGetting the features from the images: Using the raw pixels as features will give you poor results. Pass the images through a pre trained CNN(you can get several of those online). Then use the last CNN layer(just before the fully connected) as the image features.\nClustering of features : Having got the rich features for each image, you can do clustering on these(like K-means).\n\nI would recommend implementing(using already implemented) 1, 2 in Keras and Sklearn respectively.","Q_Score":7,"Tags":"python,computer-vision,cluster-analysis,k-means,unsupervised-learning","A_Id":52721794,"CreationDate":"2018-10-09T12:58:00.000","Title":"Clustering images using unsupervised Machine Learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a excelfile with around 50 worksheets. All information is in the summary in the first worksheet, but for detailed information people can check the source in the worksheet.\nI thought it would be nice to have an internal link to the worksheet (people want to know why the sales were down in July 2016 worksheet etc). \nBut while I seem to be able to create hyperlinks to websites, I just want to make it work in this excel file.\nIs this possible at all?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1585,"Q_Id":52721944,"Users Score":0,"Answer":"Actually, you can add local hyperlinks but have to control the location. The specification says this of the location attribute: \n\nLocation within target. If target is a workbook (or this workbook)\n  this shall refer to a sheet and cell or a defined name. Can also be an\n  HTML anchor if target is HTML file.\n\nI think this works by setting target to None and ref to the cell reference.","Q_Score":2,"Tags":"python,excel,python-3.x,openpyxl","A_Id":52724598,"CreationDate":"2018-10-09T13:12:00.000","Title":"Create internal links within excelsheet with openpyxl","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My intent is to cluster document vectors from doc2vec using HDBSCAN. I want to find tiny clusters where there are semantical and textual duplicates.\nTo do this I am using gensim to generate document vectors. The elements of the resulting docvecs are all in the range [-1,1].\nTo compare two documents I want to compare the angular similarity. I do this by calculating the cosine similarity of the vectors, which works fine. \nBut, to cluster the documents HDBSCAN requires a distance matrix, and not a similarity matrix. The native conversion from cosine similarity to cosine distance in sklearn is 1-similarity. However, it is my understanding that using this formula can break the triangle inequality preventing it from being a true distance metric. When searching and looking at other people's code for similar tasks, it seems that most people seem to be using sklearn.metrics.pairwise.pairwise_distances(data, metric='cosine') which is defines cosine distance as 1-similarity anyway. It looks like it provides appropriate results.\nI am wondering if this is correct, or if I should use angular distance instead, calculated as np.arccos(cosine similarity)\/pi. I have also seen people use Euclidean distance on l2-normalized document vectors; this seems to be equivalent to cosine similarity.\nPlease let me know what is the most appropriate method for calculating distance between document vectors for clustering :)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1238,"Q_Id":52722423,"Users Score":1,"Answer":"I believe in practice cosine-distance is used, despite the fact that there are corner-cases where it's not a proper metric. \nYou mention that \"elements of the resulting docvecs are all in the range [-1,1]\". That isn't usually guaranteed to be the case \u2013 though it would be if you've already unit-normalized all the raw doc-vectors. \nIf you have done that unit-normalization, or want to, then after such normalization euclidean-distance will always give the same ranked-order of nearest-neighbors as cosine-distance. The absolute values, and relative proportions between them, will vary a little \u2013 but all \"X is closer to Y than Z\" tests will be identical to those based on cosine-distance. So clustering quality should be nearly identical to using cosine-distance directly.","Q_Score":4,"Tags":"python,cluster-analysis,distance,doc2vec,hdbscan","A_Id":52728282,"CreationDate":"2018-10-09T13:35:00.000","Title":"What is the appropriate distance metric when clustering paragraph\/doc2vec vectors?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My intent is to cluster document vectors from doc2vec using HDBSCAN. I want to find tiny clusters where there are semantical and textual duplicates.\nTo do this I am using gensim to generate document vectors. The elements of the resulting docvecs are all in the range [-1,1].\nTo compare two documents I want to compare the angular similarity. I do this by calculating the cosine similarity of the vectors, which works fine. \nBut, to cluster the documents HDBSCAN requires a distance matrix, and not a similarity matrix. The native conversion from cosine similarity to cosine distance in sklearn is 1-similarity. However, it is my understanding that using this formula can break the triangle inequality preventing it from being a true distance metric. When searching and looking at other people's code for similar tasks, it seems that most people seem to be using sklearn.metrics.pairwise.pairwise_distances(data, metric='cosine') which is defines cosine distance as 1-similarity anyway. It looks like it provides appropriate results.\nI am wondering if this is correct, or if I should use angular distance instead, calculated as np.arccos(cosine similarity)\/pi. I have also seen people use Euclidean distance on l2-normalized document vectors; this seems to be equivalent to cosine similarity.\nPlease let me know what is the most appropriate method for calculating distance between document vectors for clustering :)","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1238,"Q_Id":52722423,"Users Score":1,"Answer":"The proper similarity metric is the dot product, not cosine.\nWord2vec etc. are trained using the dot product, not normalized by the vector length. And you should exactly use what was trained.\nPeople use the cosine all the time because it worked well for bag of words. The choice is not based on a proper theoretical analysis for all I know.\nHDBSCAN does not require a metric. The 1-sim transformation assumes that x is bounded by 1, so that won't reliably work.\nI suggest to try the following approaches:\n\nuse negative distances. That may simply work. I.e., d(x,y)=-(x dot y)\nuse max-sim transformation. Once you have the dot product matrix it is easy to get the maximum value.\nimplement HDBSCAN* with a similarity rather than a metric","Q_Score":4,"Tags":"python,cluster-analysis,distance,doc2vec,hdbscan","A_Id":52735502,"CreationDate":"2018-10-09T13:35:00.000","Title":"What is the appropriate distance metric when clustering paragraph\/doc2vec vectors?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just discovered rasterio for easy raster handling in Python. I am working with multi-dimensional climate data (4D and 5D). I was successful to open and read my 4D-NetCDF file with rasterio (lat: 180, lon: 361, time: 6, number: 51). However, the rasterio dataset object shows me three dimensions (180, 361, 306), whereby dimension 3 and 4 were combined. Can rasterio dataset objects only store 3 dimensions?\nIf yes, how does rasterio combine dimensions 3 and 4, to know what layer of the 306 resembles the original?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":162,"Q_Id":52723483,"Users Score":0,"Answer":"rasterio is really not the tool of choice for multi-dimensional netCDF data. It excels at handling 3D (band, y, x) data where band is some relatively short, unlabeled axis.\nLook into xarray instead, which is built around the netCDF model and supports labeled axes and many dimensions, plus lazy loading, out-of-memory computation, plotting, indexing, ...","Q_Score":0,"Tags":"python-3.x,rasterio","A_Id":53180151,"CreationDate":"2018-10-09T14:30:00.000","Title":"rasterio - load multi-dimensional data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Could you recomend me best way how to do it: i have a list phrases, for example [\"free flower delivery\",\"flower delivery Moscow\",\"color + home delivery\",\"flower delivery + delivery\",\"order flowers + with delivery\",\"color delivery\"] and pattern - \"flower delivery\". I need to get list with phrases as close as possible to pattern. \nCould you give some advice to how to do it?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":345,"Q_Id":52724518,"Users Score":1,"Answer":"Answer given by nflacco is correct.. In addition to that, have you tried edit distance? Try fuzzywuzzy (pip install fuzzywuzzy).. it uses Edit distance to give you a score, how near two sentences are","Q_Score":0,"Tags":"python-3.x,machine-learning,nlp","A_Id":52733825,"CreationDate":"2018-10-09T15:27:00.000","Title":"Text classification by pattern","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to install Ambari Server 2.7.1, which depends on python 2.7.  From my understanding, the default Centos 7 Python is 2.7.5, which \"should\" be fine, but when I go to install the Ambari Server using yum, it fails stating:\n\"Error: Package: ambari-server-2.7.1.0-169.x86_64 (ambari-2.7.1.0) Requires: python-xml\".\nWhen I search the yum repos I have installed (Base, CR, Debuginfo, Fasttrack, Sources, Vault, EPEL, HDP, HDF, AMBARI, and mysql57-community), I cannot find python-xml anywhere, but from searching google, found that it should be part of base Python 2.7.\nI have also tried \"yum clean all\" and this has no effect on the problem.\nWhat am I missing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":426,"Q_Id":52725799,"Users Score":0,"Answer":"Well, I am not sure there will be an acceptable answer to this...I spun up an identical base image on my private Openstack cloud and installed Ambari server with no issues...the only difference I could think of between installs was the order in which I installed components.  For example, I installed Ambari server followed by MySQL the second go-around, whereas I installed MySQL first, the first time I tried it.\nI could not find anything in the log files that gave me any clues as to what happened...but I do have both instances running in my cloud in the hopes of troubleshooting it further.","Q_Score":0,"Tags":"python,centos7,yum","A_Id":52745159,"CreationDate":"2018-10-09T16:48:00.000","Title":"Centos 7 missing python-xml package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to install Caffe on my mac running OSX 10.13.6\nI have followed several guides, including the installation guide on the caffe site. I have erased everything and restarted several times. I get the same problem no matter what. When I go to compile everything I am getting this\nScanning dependencies of target caffeproto\n[  1%] Building CXX object src\/caffe\/CMakeFiles\/caffeproto.dir\/__\/__\/include\/caffe\/proto\/caffe.pb.cc.o\nIn file included from \/Users\/Name\/Documents\/Programming\/PythonEnv\/caffe\/build\/include\/caffe\/proto\/caffe.pb.cc:4:\nIn file included from \/Users\/Name\/Documents\/Programming\/PythonEnv\/caffe\/build\/include\/caffe\/proto\/caffe.pb.h:9:\n\/usr\/local\/include\/google\/protobuf\/stubs\/common.h:209:17: error: expected\n      expression\n  OnShutdownRun([](const void* p) { delete static_cast<const T*>(p); }, p);\n                ^\nIn file included from \/Users\/Name\/Documents\/Programming\/PythonEnv\/caffe\/build\/include\/caffe\/proto\/caffe.pb.cc:4:\nIn file included from \/Users\/Name\/Documents\/Programming\/PythonEnv\/caffe\/build\/include\/caffe\/proto\/caffe.pb.h:25:\nIn file included from \/usr\/local\/include\/google\/protobuf\/generated_message_table_driven.h:34:\nIn file included from \/usr\/local\/include\/google\/protobuf\/map.h:49:\nIn file included from \/usr\/local\/include\/google\/protobuf\/map_type_handler.h:35:\nIn file included from \/usr\/local\/include\/google\/protobuf\/wire_format_lite_inl.h:43:\n\/usr\/local\/include\/google\/protobuf\/message_lite.h:117:3: error: unknown type\n      name 'constexpr'\n  constexpr const T& get() const { return reinterpret_cast<const T&>(union_); }\n\nI have also tried using CMake and run into the same problem. I'm not sure where to go from here. I am not incredibly knowledgable about building processes so I apologize if this is vague and will be happy to provide whatever other information might help fix this. \nThank you!","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":1086,"Q_Id":52728417,"Users Score":5,"Answer":"If compiling with make, change Makefile as follows:\n- CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)\n+ CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS) -std=c++11","Q_Score":4,"Tags":"python,macos,machine-learning,caffe","A_Id":54394139,"CreationDate":"2018-10-09T19:55:00.000","Title":"OSX Caffe Compilation Fails With Expected Expression Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on building a Random Forest Regression model for predicting ETA. I am saving the model in pickle format by using pickle package. I have also used joblib to save the model. But the size of file is really large (more than 100 GB). I would like to ask the data science experts that is it the correct format to save the model or is there any other efficient method to do so? Any insights on this will be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":234,"Q_Id":52729048,"Users Score":0,"Answer":"Aim of saving complete model is modifying the model in the future. If you are not planning to modify your model, you can just save the weights and use them for the prediction. This will save a huge space for you.","Q_Score":0,"Tags":"python,machine-learning,pickle,random-forest,data-science-experience","A_Id":52730991,"CreationDate":"2018-10-09T20:44:00.000","Title":"Right way to serialize a Random Forest Regression File","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a program that gathers tweets from Twitter, and evaluates the text to find trending topics. I'm planning on using NLTK to stem the terms and do some other operations on the data. \nWhat I need is a tool that can determine if two adjacent words in a tweet should be treated as a single term. For example, if \"fake news\" is trending on Twitter, I don't want to treat those two words as different. Another example, if everyone is tweeting about 'Computer Science', it wouldn't make sense to treat computer and science as two different terms since they refer to the same topic. Does a tool exist that can find such terms?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":681,"Q_Id":52729565,"Users Score":0,"Answer":"Interesting problem to play with, assuming there's not already a lexicon of meaningful compound words that you could leverage. And I'd love to see \"computer science\" as a trending topic.\nLet's take the approach that we know nothing about compound words in English, whether \"stop sign\" is as meaningfully distinct from \"stop\" and \"sign\" as \n\"does better\" is from \"does\" and \"better\"\nBreaking it down, you want to build a process that:\n\nIdentifies co-located pairs\nDrops any that are clearly not related as compound words (ie parts of    speech, proper names or punctuation)\nSaves candidate pairs       \nAnalyzes candidate pairs for frequency\nTeaches your system to look for the most valuable candidate pairs\n\nIs that an accurate description?\nIf so, I think the tool you ask for would be in (4) or (5). For 4), consider the Associative Rule in Python's Orange library as a start. You could also use TF-IDF from scikit-learn. For 5) you could expose the output from 4) as a list, set or dictionary of strings with counts.","Q_Score":0,"Tags":"python,nltk,natural-language-processing","A_Id":52729697,"CreationDate":"2018-10-09T21:27:00.000","Title":"Python tool to find meaningful pairs of words in a document","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've written a small flask rest api application and a related client library that uses requests to interface with the api.  And now I'm writing test cases using pytest.  The tests directly against the flask app run fine using the built in test client.\nHowever, now I'm trying to run tests against the flask app through the client library, and it's failing with errors like:\n\nInvalidSchema(\"No connection adapters were found for '%s'\" % url)\n\nAs I understand, I can separately mock out the requests calls, but is there a way I can test the client library directly against the flask application?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":247,"Q_Id":52729749,"Users Score":1,"Answer":"If you test client library it better to choose mocks your API.\nBut if you want to test client(library) <-> server(flask) integration you need to make some preparation of environment. Like configure client, start server on the same host and port. And then run the tests.","Q_Score":0,"Tags":"python,flask,python-requests,pytest","A_Id":52731357,"CreationDate":"2018-10-09T21:43:00.000","Title":"Testing a flask application with a client that uses 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":1},{"Question":"I cannot install 64-bit Anaconda 3 on Windows 10. It says the install is complete but when I proceed to install VSCode, it fails. It says to check my internet connection and to look in the log file. But my internet connection is fine and there is no log file. I am running the install with Windows Defender turned off.\nWhen I look at the start menu, none of the components except for Anaconda Prompt, are there. I would like to have Spyder and Jupyter, for example, but they are not there.\nIf I install the 32-bit version, it works fine. But I need the 64-bit version","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":4316,"Q_Id":52730430,"Users Score":-1,"Answer":"I simply close the navigator and open Anaconda Navigator as Run as administrator\nand my problem solved.","Q_Score":1,"Tags":"python,python-3.x,visual-studio-code,installation,anaconda","A_Id":53237950,"CreationDate":"2018-10-09T23:05:00.000","Title":"Anaconda install fails. Install vscode fails","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I compile a script using Cython, Python 3.6 is used to generate all the necessary files. How can one use a conda environment running Python version 3.5 to compile a Cython .pyx file on Windows?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":405,"Q_Id":52730567,"Users Score":1,"Answer":"I found the solution. I had accidentaly activated a different Python environment that uses Python version 3.6. Once I activated the right environment, I managed to compile and run my Cython-built program.","Q_Score":1,"Tags":"python,cython","A_Id":52746887,"CreationDate":"2018-10-09T23:25:00.000","Title":"How to compile with Cython using a custom version of Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a task written in Python with a 1-2 minute run-time that I want to run on-demand. The requests would come In very small volumes from a Django server on Linux. The return would be a file.\nUsually, I'd use a queue system like Celery. But, this task can only be run on Windows.\nWhat is the best way to make this happen?\nRemotely execute the task by establishing an SSH session? \nStill use Celery, go through a lot of workarounds to get it to work on Windows (seems messy)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":52732565,"Users Score":0,"Answer":"I could think of 5 solutions which do not require ssh\nI didn't talk about authentication in my solutions you should implement something based on chosen solution \nSolution 1:\n\nwrite a simple flask\/django app for windows server which runs the task and returns response\nin your linux server send a request to windows and get data\nlinux server can make this call using celery so you wouldn't bother about 2\/3 minute wait\n\nSolution 2:\n\nwrite a simple flask\/django app for windows server which calls a celery task in back ground\n\n\nthis app should return the url of result file\n\ncelery task creates a file which contains the result\nserve this file with nginx (or a windows based static file server, I don't know windows)\nsend a request from linux server to windows to get result (if file doesn't exists it means result is not ready yet)\n\nSolution 3:\n\nwrite a simple flask\/django app for windows server which calls a celery task in back ground\n\n\nthis app returns a random id for given request\n\nfrom your linux server send requests to windows app with task id\nwhen task is finished windows app returns result\n\nSolution 4:\n\nwrite a simple flask\/django app for windows server which calls a celery task in back ground\nadd an endpoint to your linux django app for uploading data\nwhen windows app finishes processing it uploads data to linux django app\n\nSolution 5:\n\nsolution 4 but your linux django app is not for uploading data. it only sets a boolean which mean task is done\nif task is done linux server send a request to winsows server to get data (this request contains the task id)","Q_Score":0,"Tags":"python,django,linux,windows,python-3.x","A_Id":52735547,"CreationDate":"2018-10-10T04:17:00.000","Title":"Best way to run task on Windows from web server on Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am currently using TensorFlow tutorial's first_steps_with_tensor_flow.ipynb  notebook to learn TF for implementing ML models. In the notebook, they have used Stochastic Gradient Descent (SGD) to optimize the loss function. Below is the snippet of the my_input_function:\ndef my_input_fn(features, targets, batch_size=1, shuffle=True, num_epochs=None):\nHere, it can be seen that the batch_size is 1. The notebook uses a housing data set containing 17000 labeled examples for training. This means for SGD, I will be having 17000 batches.\nLRmodel = linear_regressor.train(input_fn = lambda:my_input_fn(my_feature, \n           targets), steps=100)\nI have three questions - \n\nWhy is steps=100 in linear_regressor.train method above? Since we have 17000 batches and steps in ML means the count for evaluating one batch, in linear_regressor.train method steps = 17000 should be initialized, right?\nIs number of batches equal to the number of steps\/iterations in ML?\nWith my 17000 examples, if I keep my batch_size=100, steps=500, and num_epochs=5, what does this initialization mean and how does it correlate to 170 batches?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":185,"Q_Id":52738335,"Users Score":-1,"Answer":"step is the literal meaning: means you refresh the parameters in your batch size; so for linear_regessor.train, it will train 100 times for this batch_size 1.\nepoch means to refresh the whole data, which is 17,000 in your set.","Q_Score":0,"Tags":"python,tensorflow,machine-learning","A_Id":52904530,"CreationDate":"2018-10-10T10:39:00.000","Title":"TensorFlow: Correct way of using steps in Stochastic Gradient Descent","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Importing rpy2.robjects fails in the jupyter notebook with LookupError: 'show' not found, however, import works in the commandline python interpreter with activated environment. How can I make it work in the notebook?\nI have created the conda environment with rpy2 and ipykernel installed and have linked it to jupyter via python -m ipykernel install --user --name env --display-name \"env\" (within the activated environment). I looked up the path of the environment in kernel.json under the path provided by jupyter kernelspec list and found it to be the correct one of my environment. I do not get the error when I start jupyter notebook from within the activated environment and try to import rpy2.rojects. I would have thought that this should not make any difference. Furthermore, when starting the python interpreter via .\/python within the ~home\/user\/anaconda3\/envs\/env, I do obtain the error. It seems some environment variables are set differently when starting the notebook with or without activated environment, but I do not have any clue which and how. I'll be happy about any hints to understand the issue.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":184,"Q_Id":52740275,"Users Score":0,"Answer":"It does make a difference whether an environment is activated. You've already pointed out one solution, start Jupyter in the activated environment, and the kernels will inherit the corresponding environment variables.\nAnaconda also has a kernel provider that finds kernels in all conda environments and automatically activates the environment when the kernel starts.\nAnother way is that you write your own kernelspec that calls a script. In that script, you can activate the conda environment before starting the kernel.","Q_Score":0,"Tags":"python,jupyter-notebook,conda,rpy2,jupyter-kernel","A_Id":56701205,"CreationDate":"2018-10-10T12:27:00.000","Title":"Cannot import rpy2.robjects from conda environment in Jupyter notebook but in console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Ubuntu and I have a code which needs to install various libraries. I mostly use python2.7, but due to some libraries this code uses, I had to move to python3, these libraries are \nimport urllib.request\nimport urllib.parse\nimport urllib.error\nBut then there was one library import which I could not import in python3, after searching on Google, I found that moving to python3.7 will solve the issue, and it did solve. Import was\nfrom json import JSONDecodeError\nBut now I have the issue of 'from retrying import retry'......After installing it with pip and pip3, I could import it in Python2.7 and python3, but I am failing to import it in python3.7.....\nSo, basically I am jumping across python versions to import the libraries required to run the code of an ex company employee....Please guide me how to import \"retrying\" in python3.7 or any way I can just install all the below ones in one python version\nimport urllib.request\nimport urllib.parse\nimport urllib.error\nfrom json import JSONDecodeError\nfrom retrying import retry","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":287,"Q_Id":52741688,"Users Score":1,"Answer":"I installed python3.5, and everything worked fine in it. Weird it did not work in python3.7, anyways my issue is resolved.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,ubuntu,installation","A_Id":52758487,"CreationDate":"2018-10-10T13:44:00.000","Title":"Unable to install package \"retrying\" in python 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a working Python script that generates and saves hi-res image files to a local Dropbox folder (synced through the Windows Dropbox app). Is there a way in Python to change the SmartSync setting for the newly created image from \"Local\" to \"Online Only\" so that I can save space on my local hard drive? I know I could use the Dropbox API v2 to just upload the file and then delete the temporary local files after, but I'm wondering if there is a way to directly change the file settings since it already gets saved to the synced Dropbox folder.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":482,"Q_Id":52745027,"Users Score":1,"Answer":"No, unfortunately Dropbox doesn't offer an API for managing Smart Sync settings like this, but I'll pass this along as a feature request.","Q_Score":2,"Tags":"python,python-3.x,dropbox,dropbox-api,dropbox-sdk","A_Id":52745913,"CreationDate":"2018-10-10T16:38:00.000","Title":"Python and Dropbox: How to change SmartSync setting for locally created files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently trying to publish an azure function, using version 2.0 and a version of python 3.6.5, which I get success, but at the time of trying the url to call the function, it does not find it and it gives me a error code 404. I do not know what solution they have found, or if from azure portal it is still not possible to use azure function with python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":52745129,"Users Score":0,"Answer":"I already found the solution, this happens because the python functions publication is in private preview.","Q_Score":0,"Tags":"python-3.6,azure-functions","A_Id":52786856,"CreationDate":"2018-10-10T16:46:00.000","Title":"deployment in production azure function 2.0 using python 3.6 with visual studio code error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new in the Cloud\nand I have an python script that I call from a bash script with parameters. this app run on Linux and required some python modules as well. \nI would like to deploy this app on the AWS cloud and make it run on a given schedule.\nWhat is the best way to deploy this app (AWS Lambda or EC2).\nThanks\nNono","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":293,"Q_Id":52745181,"Users Score":2,"Answer":"Cheapest way is AWS Lambda, but you'll have to get rid of the bash script and modify your Python script some.\nEasiest way is EC2, because it's just a Linux server that you can login to and install whatever you want and setup your script on a cron job just like your local Linux server.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-ec2,aws-lambda","A_Id":52745223,"CreationDate":"2018-10-10T16:50:00.000","Title":"Deploy Python\/Bash application 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":0},{"Question":"I am using the Spyder IDE, version 3.3.1, and I would like to debug only a specific line of Python code that's about 1,100 lines into the program. I don't want to run all the code above line 1,100. Running those 1,100 lines would take time since it would execute various large database queries, and be unnecessary for my purposes. \nIn Visual Basic (VBA) for Excel, when debugging, I can drag the yellow arrow to any line and run the code line-by-line from that point forward. Is there something similar in Python (specifically in the Spyder IDE), or do I have to set break points and run the entire code? \nI suppose one option is to move this specific line of code to the top of the file (i.e. line 1, not line 1,100), so that it runs first when debugging. Maybe I've answered my own question, but I'm still curious whether there's a way to start debugging from a certain line. \nMy options seem limited to the following, judging by Spyder's debug menu:\n\nRun current line (i.e. starting at line 1)\nStep into function or method of current line\nRun until current function or method returns\nContinue execution until next breakpoint\n\nI don't want to reorganize all my code, since this is just an ad hoc\/one-time analysis. For context, I am a business analyst and I am just doing some data exploration\/correlation\/regression analysis. I am a functional programmer whose background is in business\/finance, not computer science.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1337,"Q_Id":52746410,"Users Score":0,"Answer":"It seems the easiest\/quickest solution is to move the specific line of code to the top of the file (i.e. line 1, not line 1,100), so that it runs first when debugging.","Q_Score":0,"Tags":"python,debugging,spyder","A_Id":53269374,"CreationDate":"2018-10-10T18:12:00.000","Title":"Debug Python starting on specific line, not at beginning, like VBA","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to expand the following list\n[(1, [('a', '12'), ('b', '64'), ('c', '36'), ('d', '48')]), (2, [('a', '13'), ('b', '26'), ('c', '39'), ('d', '52')])] \nto   \n[(1,a,12),(1,b,24),(1,c,36),(1,d,48),(2,a,13),(2,b,26),(2,c,39),(2,d,52)] \nI used zip(itertools.cycle()) in python 3, but instead get a zip object reference. Is there any other way I can do it? This worked for python 2","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":52746519,"Users Score":0,"Answer":"Provided that the zip object is created correctly, you can either do list(zip_object) or [*zip_object] to get the list.","Q_Score":1,"Tags":"python,python-3.x","A_Id":52746594,"CreationDate":"2018-10-10T18:20:00.000","Title":"Correct usage of itertools in python 3","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is an obvious question, that I haven't been able to find a concrete answer to. \nIs the Python Byte-Code and Python Code itself interpreter independent, \nMeaning by this, that If I take a CPython, PyPy, Jython, IronPython, Skulpt, etc, Interpreter, and I attempt to run, the same piece of code in python or bytecode, will it run correctly? (provided that they implement the same language version, and use modules strictly written in Python or standard modules)\nIf so, is there is a benchmark, or place where I can compare performance comparison from many interpreters? \nI've been playing for a while with CPython, and now I want to explore new interpreters.\nAnd also a side question, What are the uses for the others implementations of python? \nSkulpt I get it, browsers, but the rest? Is there a specific industry or application that requires a different interpreter (which)?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":267,"Q_Id":52746589,"Users Score":0,"Answer":"If so, is there is a benchmark, or place where I can compare\n  performance comparison from many interpreters?\n\nspeed.pypy.org compares pypy to cpython","Q_Score":0,"Tags":"python,pypy,pythoninterpreter","A_Id":52960952,"CreationDate":"2018-10-10T18:25:00.000","Title":"Is Python byte-code, interpreter independent?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python and getting this error.\n\nimport telegram\ntelegram.Bot(token = '###############')\n\nWhen I run this, appears: \n\"AttributeError: module 'telegram' has no attribute 'Bot'\"\nAny ideas how to solve this?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":15267,"Q_Id":52749629,"Users Score":1,"Answer":"Note that your file name (.py) does not the same with your package name.","Q_Score":6,"Tags":"python,api,telegram,attributeerror","A_Id":57895181,"CreationDate":"2018-10-10T22:29:00.000","Title":"AttributeError: module 'telegram' has no attribute '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 try to pass a Keras model (as a function) to KerasClassifier wrapper from scikit_learn, and then use GridSearchCV to create some settings, and finally fit the train and test datasets (both are numpy array)\nI then, with the same python script, got different exceptions, some of them are:\n_1.\n\nTraceback (most recent call last):   File \"mnist_flat_imac.py\", line\n  63, in \n      grid_result = validator.fit(train_images, train_labels)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/site-packages\/sklearn\/model_selection\/_search.py\",\n  line 626, in fit\n      base_estimator = clone(self.estimator)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/site-packages\/sklearn\/base.py\",\n  line 62, in clone\n      new_object_params[name] = clone(param, safe=False)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/site-packages\/sklearn\/base.py\",\n  line 53, in clone\nsnipped here\nin _deepcopy_dict\n      y[deepcopy(key, memo)] = deepcopy(value, memo)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/copy.py\", line 174,\n  in deepcopy\n      rv = reductor(4) TypeError: can't pickle SwigPyObject objects Exception ignored in: > Traceback (most recent call last):   File\n  \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/site-packages\/tensorflow\/python\/framework\/c_api_util.py\",\n  line 52, in __del__\n      c_api.TF_DeleteGraph(self.graph) AttributeError: 'ScopedTFGraph' object has no attribute 'graph'\n\n_2. \n\nTraceback (most recent call last):   File \"mnist_flat_imac.py\", line\n  63, in \n      grid_result = validator.fit(train_images, train_labels)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/site-packages\/sklearn\/model_selection\/_search.py\",\n  line 626, in fit\n      base_estimator = clone(self.estimator)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/site-packages\/sklearn\/base.py\",\n  line 62, in clone\n      new_object_params[name] = clone(param, safe=False)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/site-packages\/sklearn\/base.py\",\n  line 53, in clone\n      return copy.deepcopy(estimator)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/copy.py\", line 182,\n  in deepcopy\n      y = _reconstruct(x, rv, 1, memo)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/copy.py\", line 297,\n  in _reconstruct\nsnipped here\nin deepcopy\n      y = _reconstruct(x, rv, 1, memo)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/copy.py\", line 297,\n  in _reconstruct\n      state = deepcopy(state, memo)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/copy.py\", line 155,\n  in deepcopy\n      y = copier(x, memo)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/copy.py\", line 243,\n  in _deepcopy_dict\n      y[deepcopy(key, memo)] = deepcopy(value, memo)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/copy.py\", line 174,\n  in deepcopy\n      rv = reductor(4) TypeError: can't pickle SwigPyObject objects\n\n_3. \n\nTraceback (most recent call last):   File \"mnist_flat_imac.py\", line\n  63, in \n      grid_result = validator.fit(train_images, train_labels)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/site-packages\/sklearn\/model_selection\/_search.py\",\n  line 626, in fit\n      base_estimator = clone(self.estimator)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/site-packages\/sklearn\/base.py\",\n  line 62, in clone\n      new_object_params[name] = clone(param, safe=False)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/site-packages\/sklearn\/base.py\",\n  line 53, in clone\nsnipped here\nin _deepcopy_dict\n      y[deepcopy(key, memo)] = deepcopy(value, memo)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/copy.py\", line 182,\n  in deepcopy\n      y = _reconstruct(x, rv, 1, memo)   File \"\/home\/longnv\/PYTHON_ENV\/DataScience\/lib\/python3.5\/copy.py\", line 306,\n  in _reconstruct\n      y.dict.update(state) AttributeError: 'NoneType' object has no attribute 'update'\n\nWhy did it output different errors with the same python script? \nAnd how can I fix this?\nThank you so much!\nP.S.\n\npython: 3.5 \ntensorflow: 1.10.1\npandas: 0.23.4\nUbuntu: 4.4.0-124-generic","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":196,"Q_Id":52751040,"Users Score":0,"Answer":"Found it.\nIt should be:\nclf = KerasClassifier(build_fn=get_model)\nInstead of:\nclf = KerasClassifier(build_fn=get_model())","Q_Score":0,"Tags":"python,tensorflow,machine-learning,scikit-learn,keras","A_Id":52752228,"CreationDate":"2018-10-11T01:55:00.000","Title":"Different exceptions happened when running Keras and scikit-learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tried many different things to fix the problem, but when I use from selenium import webdriver, I always get ImportError: No module named selenium\nSelenium is definitely installed in c:\/Python27\/Scripts using pip install selenium and also tried -m pip install -U selenium\nAny suggestions? I've tried everything I could find on SO.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":6609,"Q_Id":52751053,"Users Score":2,"Answer":"@Ankur Singh answered my question. I needed to go run conda install -c clinicalgraphics selenium in an Anaconda Prompt window before importing Selenium","Q_Score":1,"Tags":"python,selenium,selenium-webdriver,jupyter-notebook,jupyter","A_Id":52752048,"CreationDate":"2018-10-11T01:57:00.000","Title":"Python: Unable to import Selenium using Jupyter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tried many different things to fix the problem, but when I use from selenium import webdriver, I always get ImportError: No module named selenium\nSelenium is definitely installed in c:\/Python27\/Scripts using pip install selenium and also tried -m pip install -U selenium\nAny suggestions? I've tried everything I could find on SO.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":6609,"Q_Id":52751053,"Users Score":1,"Answer":"I had the same issue using Python 3.7 and pip install selenium --user solved it for me.","Q_Score":1,"Tags":"python,selenium,selenium-webdriver,jupyter-notebook,jupyter","A_Id":62248876,"CreationDate":"2018-10-11T01:57:00.000","Title":"Python: Unable to import Selenium using Jupyter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tried many different things to fix the problem, but when I use from selenium import webdriver, I always get ImportError: No module named selenium\nSelenium is definitely installed in c:\/Python27\/Scripts using pip install selenium and also tried -m pip install -U selenium\nAny suggestions? I've tried everything I could find on SO.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":6609,"Q_Id":52751053,"Users Score":0,"Answer":"Installation success still error?\nLocation problem so do this:-\nCheck where selenium package and file.py located. If both are in different location, move the selenium package to the location where file.py located.","Q_Score":1,"Tags":"python,selenium,selenium-webdriver,jupyter-notebook,jupyter","A_Id":68063740,"CreationDate":"2018-10-11T01:57:00.000","Title":"Python: Unable to import Selenium using Jupyter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to parse pricing list json files for some aws services. After parsing I am randomly picking a key from key list to get the data. Currently my code loads the json files one at a time, which takes time. I would like to get some suggestions on how I can speed up this process.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":52751533,"Users Score":0,"Answer":"Ended up creating a database on redis server.","Q_Score":0,"Tags":"json,python-3.x,amazon-web-services","A_Id":53009841,"CreationDate":"2018-10-11T03:02:00.000","Title":"Need suggestions for fast and efficient way to parse AWS Pricing List json files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a Python program with many (approx ~30-40) parameters, all of which have default values, and all should be adjustable at run time by the user. The way I set it up, these parameters are grouped into 4 dictionaries, corresponding to 4 different modules of the program. However, I have encountered a few cases of a single parameter required by more then one of these modules, leading me to consider just unifying the dictionaries into one big config dictionary, or perhaps even one config object, passed to each module.\nMy questions are\n\nWould this have any effect on run time? I suspect not, but want to be sure.\nIs this considered good practice? Is there some other solution to the problem I have described?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":52756296,"Users Score":1,"Answer":"probably no effect on runtime. larger dictionaries could take longer to lookup in, but in your case, we are talking about 40 items. that's nothing.\nwe use a single settings file in which we initialize globals by calling a method that either read the config from the environment, a file or a Python file (as globals). the method that reads the config can get the desired type and default value. Others use YAML or TOML for representing configuration and I'm guessing then stores them a globally accessible object. If your settings can be changed in runtime, you have to protect this object in terms of thread-safety (if you have threads of course).","Q_Score":0,"Tags":"python,design-patterns","A_Id":52756449,"CreationDate":"2018-10-11T09:08:00.000","Title":"Using one dictionary vs. many to store program configurations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a data set and after performing the bucketing operation over two columns, I ended up with two buckets that have maximum number of data points.\nFor those two buckets, I have created two separate data frames, which is of different shapes (number of columns are same and the number of rows are different) so as to compare them. \nI need to know which transformation I can use to perform a correlation of two data frames possible. How can I do that?\nAny other suggestions for comparing data frames are appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":52760769,"Users Score":0,"Answer":"Bin them both to vectors of equal length, with bin or window sizes dependent on the shapes of the input frames, then calculate correlation on the vectors.","Q_Score":0,"Tags":"python,correlation","A_Id":52772728,"CreationDate":"2018-10-11T13:04:00.000","Title":"Finding correlation of two data frames using python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I found something puzzled me in Python earlier on, let's say I got a list of chars l = ['a','b']\nwhen I do l + 'c' it gives me error of 'can only concatenate list (not \"str\") to list'. However l += 'c' is fine which gives me l = ['a', 'b', 'c']. Does anyone know why that is? (I am on Python 3.7.0)","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":239,"Q_Id":52763349,"Users Score":2,"Answer":"With l + 'c', you are trying to merge a string and a list. But with l += 'c', you\u2019re essentially doing the same as l.extend('c').","Q_Score":2,"Tags":"python","A_Id":52763414,"CreationDate":"2018-10-11T15:03:00.000","Title":"python list of char append with +","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python and am trying to set up Flask and Python.  I need to set my DATABASE_URL to run flask, but I can't find out my database url, because when I click on Heroku Postgres in my dashboard over view I get the error message:\n{\"error\":{\"id\":\"unauthorized\",\"message\":\"Invalid credentials provided.\"}}\nAny ideas?  Feel like I'm trapped in a weird circle.\nThanks in advance\nVicky","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1134,"Q_Id":52763624,"Users Score":0,"Answer":"thanks, seemed to have sorted it, not quite sure how.  Heroku was showing details I required today, so maybe it was something to do with their site yesterday.","Q_Score":1,"Tags":"python,heroku","A_Id":52793606,"CreationDate":"2018-10-11T15:18:00.000","Title":"This error message {\"error\":{\"id\":\"unauthorized\",\"message\":\"Invalid credentials provided.\"}} when I click on Heroku Postgres","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a task in which i have a csv file having some sample data. The task is to convert the data inside the csv file into other formats like JSON, HTML, YAML etc after applying some data validation rules.\nNow i am also supposed to write some unit tests for this in pytest or the unittest module in Python.\nMy question is how do i actually write the unit tests for this since i am converting them to different JSON\/HTML files ? Should i prepare some sample files and then do a comparison with them in my unit tests.\nI think only the data validation part in the task can be tested using unittest and not the creation of files in different formats right ?\nAny ideas would be immensely helpful.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":511,"Q_Id":52763725,"Users Score":0,"Answer":"You should do functional tests, so testing the whole pipeline from a csv file to the end result, but unit tests is about checking that individual steps work.\nSo for instance, can you read a csv file properly? Does it fail as expected when you don't provide a csv file? Are you able to check each validation unit? Are they failing when they should? Are they passing valid data? \nAnd of course, the result must be tested as well. Starting from a known internal representation, is the resulting json valid? Does it contain all the required data? Same for yaml, HTML. You should not test the formatting, but really what was output and if it's correct. \nYou should always test that valid data passes and that incorrect doesn't at each step of your work flow.","Q_Score":1,"Tags":"python,pytest,python-unittest","A_Id":52763853,"CreationDate":"2018-10-11T15:24:00.000","Title":"Writing unit tests 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 very new to this and struggling with the basics. I have a csv file \/home\/emily\/Downloads\/Roger-Federer.csv The textbook says that I need to \"extract the file and download it to my current directory\" on JupyterLab (I am using Python). What does this mean? How do I do this? Thank you","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":628,"Q_Id":52766928,"Users Score":2,"Answer":"Every running program, including JupyterLab, has a \"working directory\" which is where it thinks it is on your computer's file system. What exactly this directory is usually depends on how you launched it (e.g., when you run a program from terminal, its working directory is initially the folder your terminal was in when you ran the command, but it's possible for a program to change its own working directory later).\nYour file path indicates you're on Linux, so I'd suggest opening a terminal in your JupyterLab and running pwd to have it print out its current directory. (You can also run !pwd in any open notebook if that's easier.) You should then copy your CSV file to that directory.\nIf you do that, then from your Python code, you can just open the file locally, like open('Roger-Federer.csv') or pandas.read_csv('Roger-Federer.csv'). You don't have to move the file to open it from Python, though, you can just give it the entire file path, like open('\/home\/emily\/Downloads\/Roger-Federer.csv'), and that'll work just fine too.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":52767061,"CreationDate":"2018-10-11T18:40:00.000","Title":"How to get a file from the files on my computer to JupyterLab?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Tensorflow was working fine when I had 1.4 but when I upgraded it, it stopped working.\nThe version that I installed is 1.11 with CUDA 9 and cuDNN 7. \n\nTraceback (most recent call last):   File\n  \"C:\\Users\\anime\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow.py\",\n  line 58, in \n      from tensorflow.python.pywrap_tensorflow_internal import *   File \"C:\\Users\\anime\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow_internal.py\",\n  line 28, in \n      _pywrap_tensorflow_internal = swig_import_helper()   File \"C:\\Users\\anime\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow_internal.py\",\n  line 24, in swig_import_helper\n      _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)   File\n  \"C:\\Users\\anime\\AppData\\Local\\Programs\\Python\\Python36\\lib\\imp.py\",\n  line 243, in load_module\n      return load_dynamic(name, filename, file)   File \"C:\\Users\\anime\\AppData\\Local\\Programs\\Python\\Python36\\lib\\imp.py\",\n  line 343, in load_dynamic\n      return _load(spec) ImportError: DLL load failed: The specified module could not be found.\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):   File \"\", line 1, in\n     File\n  \"C:\\Users\\anime\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow__init__.py\",\n  line 22, in \n      from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import   File\n  \"C:\\Users\\anime\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\python__init__.py\",\n  line 49, in \n      from tensorflow.python import pywrap_tensorflow   File \"C:\\Users\\anime\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow.py\",\n  line 74, in \n      raise ImportError(msg) ImportError: Traceback (most recent call last):   File\n  \"C:\\Users\\anime\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow.py\",\n  line 58, in \n      from tensorflow.python.pywrap_tensorflow_internal import *   File \"C:\\Users\\anime\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow_internal.py\",\n  line 28, in \n      _pywrap_tensorflow_internal = swig_import_helper()   File \"C:\\Users\\anime\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow_internal.py\",\n  line 24, in swig_import_helper\n      _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)   File\n  \"C:\\Users\\anime\\AppData\\Local\\Programs\\Python\\Python36\\lib\\imp.py\",\n  line 243, in load_module\n      return load_dynamic(name, filename, file)   File \"C:\\Users\\anime\\AppData\\Local\\Programs\\Python\\Python36\\lib\\imp.py\",\n  line 343, in load_dynamic\n      return _load(spec) ImportError: DLL load failed: The specified module could not be found.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":358,"Q_Id":52767007,"Users Score":0,"Answer":"you can uninstall the tensorflow and re-install it.","Q_Score":1,"Tags":"python,python-3.x,tensorflow","A_Id":58498554,"CreationDate":"2018-10-11T18:47:00.000","Title":"Importing tensorflow not working when upgraded","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the following situation:\nThere are a thousand processes and each of them has the following task:\n\n1) choose a nr X from 1 to 1 000 \n2) if X.txt does exists, go to (1)\n3) Open X.txt and write \"hello this is process_id\".\n\nNow, my question is, if I use open('X.txt', 'wx') is it possible that at some point 2 processes will be able to open the file the same time, because they will at the same time say: \"ok, X.txt doesnt exist, so lets open it for writing\"?\nIf it is possible, is there a safety mechanism I could use, for example when I close the file, check if I was the only process that was writing to this file?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":52771242,"Users Score":0,"Answer":"Since you're always using the x flag to open, you're safe and don't have to worry about anything else. Only one process (the one that actually created the file) will succeed at opening it.","Q_Score":0,"Tags":"python","A_Id":52771286,"CreationDate":"2018-10-12T02:11:00.000","Title":"2 processes opening a file at the same time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have the next problem, I'm trying to classify one of four hand position, I'm using SVM and this positions will be used to make commands in my program, the predict function works fine, but for example if I made some other gestures (none of the 4 that I use for commands) the predict function try to classify this gesture in one of the original four, I want to know if is possible to say \"this gesture is none of the four that I know\".\nThe final function of this is similar to the behaivor of some commands of the kinect in Xbox for example, you can move your hands but the Xbox will only react to a especifict gesture.\nI'm using Python, pandas, scikit-learn and leap motion, I training my network with data collected from four gestures.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":52772906,"Users Score":0,"Answer":"Instead of treating this as a classification problem with 4 levels, treat it as a classification problem with 5 levels. 4 levels would correspond to one of the original four and the 5th level can be used for all others.","Q_Score":0,"Tags":"python,python-3.x,machine-learning,scikit-learn,leap-motion","A_Id":52773168,"CreationDate":"2018-10-12T05:36:00.000","Title":"How to add a none option in scikit learn predict","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to read some input from the csv file and then modify the input and replace it with the new value. For this purpose, I first read the value but then I'm stuck at this point as I want to modify all the values present in the file.\nSo is it possible to open the file in r mode in one for loop and then immediately in w mode in another loop to enter the modified data?\nIf there is a simpler way to do this please help me out\nThank you.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":9000,"Q_Id":52773491,"Users Score":1,"Answer":"You can do open(\"data.csv\", \"rw\"), this allows you to read and write at the same time.","Q_Score":1,"Tags":"python,python-3.x","A_Id":52773601,"CreationDate":"2018-10-12T06:25:00.000","Title":"Reading and Writing into CSV file at the same time","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Problem\nI want to secure my Raspberry pi in a special way.\nI would like to start up raspberry pi without entering a password as pi user.\nHowever, I want pi user to have zero privilege. Cant read a file, cant copy a file, simply nothing. And without access to root->'sudo su'. On the other hand when raspberry pi starts itself with pi user, I want backend process to be running as root. So to put it simply, I want it like in a zoo - two worlds but neither of them can enter the other. Clients can be present, see what process are running, see files in directories, but cant read it, copy, remove and etc. In the same time I want the backend to be untouched and running and writing files.\nReason:\nI have raspberri pi product - customer get it home, when plug in power supply,RPi starts up and runs backend programs with root privilege and communicates with my desktop software.\nBut I dont want curious customer that plugs in HDMI and see my code. I also dont want him to take the SD card and extract the code. \nI heard its possible to reverse engineer the code even if compiled. So I simply want the programs(python script) to be there but cannot be accessed in any way.\nIs it possible to make such protection?\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2009,"Q_Id":52777186,"Users Score":4,"Answer":"You may consider to use the following approach \n\nUse at least two levels of hashing with MAC address and ARM chip serial number (via cat \/proc\/cpuinfo) with additional secret keys. Run your program only if the stored license key is the same as the result of doubly-hashed functions.\nOptionally, you could rewrite critical part of your code in C, compile it statically, and remove all debug symbols. Call it using Python. \nQuick optimization of your code using cython. Call its generated shared objects with a python caller script. Distribute only the shared objects and the python caller script.\n\nThis will prevent most people from reverse engineering your codes.","Q_Score":0,"Tags":"python,raspberry-pi,root,privileges,protection","A_Id":52777984,"CreationDate":"2018-10-12T10:05:00.000","Title":"Raspberry pi protection against reverse engineering the codes","Data Science and Machine Learning":0,"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 use a QSortFilterProxyModel to filter a QSqlTableModel's data, and want to get the filtered rowCount.\nBut when I call the QSortFilterProxyModel.rowCount method, the QSqlTableModel's rowCount was returned.\nSo how can I get the filtered rowcount?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":993,"Q_Id":52779569,"Users Score":0,"Answer":"You should after set QSortFilterProxyModel filter to call proxymodel.rowCount\u3002","Q_Score":1,"Tags":"python,pyqt,pyqt5,qsortfilterproxymodel","A_Id":62380679,"CreationDate":"2018-10-12T12:28:00.000","Title":"How to get filtered rowCount in a QSortFilterProxyModel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wasn't able to find this question asked before and this is driving me crazy. If this question is a duplicate, I'd appreciate it if someone could point me to an answer.\nI tried to install mysql (using pip install mysql) in the PyCharm terminal using Python 3.6. This is the error I get. I already updated pip to the latest version.\n\nCommand \"C:\\Users\\David\\PycharmProjects\\cryptocurrency2\\cryptocurrencytrading\\Scripts\\python.exe -u -c \"import setuptools, tokenize;file='C:\\Users\\David\\AppData\\Local\\Temp\\pip-install-alqyprfu\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(f\n  ile);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, file, 'exec'))\" install --record C:\\Users\\David\\AppData\\Local\\Temp\\pip-record-gcaxj074\\install-record.txt --single-version-externally-managed --compile --install-headers C:\\Users\\David\\PycharmProjects\\cryptocurrency2\\cryptocurrencytrading\\include\\site\\python3.6\\mysqlclient\" failed with error code 1 in C:\\Users\\David\\AppData\\Local\\Temp\\pip-install-alqyprfu\\mysqlclient\\\n  You are using pip version 10.0.1, however version 18.1 is available.\n  You should consider upgrading via the 'python -m pip install --upgrade pip' command.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2631,"Q_Id":52779570,"Users Score":-1,"Answer":"try to use python -m pip install --upgrade pip\nur pip version is too low","Q_Score":0,"Tags":"python,pip,pycharm,mysql-python","A_Id":52779656,"CreationDate":"2018-10-12T12:28:00.000","Title":"Installing mysql in PyCharm community edition","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I have a model Car where users can upload a single picture to, I can create a property ImageFile in Django to achieve that. Now I would also like to get the metadata from this file and save them to the database.\nNow I'm very unsure where I should place this method a how I should design it. It would be obvious, to have a method like _set_exifdata() or _update_exifdata() that is called every time I set an Image to the model.\nOr a method get_exifdata(imagefile) that returns a dict of exifdatas. But should this method be part of the Car model? Actually, I won't need it anywhere else, so it does not make sense to put it in a general helper class. But on the other hand, I would prefer to split methods in \"retrieving data\" and \"setting data\", so _update_exif() for example would do both of it in once, and maybe that's OK in design ways, but maybe its not and there is some rules of model design I should know and respect here.\nI hope someone can help me with some guidelines for model design (especially for django) and what methods should be part of methods and which should not.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":26,"Q_Id":52781517,"Users Score":-1,"Answer":"if you using only for the car then you can put that value in the model save method, \nwhich will get call every time whenever you will update the data.","Q_Score":0,"Tags":"python,django,python-3.x,design-patterns,model","A_Id":52781590,"CreationDate":"2018-10-12T14:19:00.000","Title":"What methods should a model contain","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to copy a file in one folder in source bucket to another folder in the same bucket under source folder using boto3. \nSource bucket: Testing\nSource Path: A\/B\/C\/D\/E\/F..\nI have some files in C, which I need to move to E. \nMy problem is, lambda is running in loop for this. I have this lambda which get triggered when my file comes to C, and then ut trigger another one to do something else. Now between these two, I have to move the file from C to E and then trigger the lambda to perform next operation. \nAnyone have any insight how I can fix that issue of lambda running in loop?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1103,"Q_Id":52787895,"Users Score":1,"Answer":"In S3 there is no folder. You'd better see it as a bucket-key-value. The folder-like representation you see in the console is just a visualisation.\nYour Lambda is triggered by an event of file modification in your bucket. You have to play with the prefix and the suffix of the S3 event.\nDo you control the name of the file you put in S3?\n\nYes. Suppose your filename always starts with new. Set your event with prefix: A\/B\/C\/new. When a file get in A\/B\/C\/new... the lambda is triggered because it matches the prefix, when the same files goes to A\/B\/C\/D\/E\/new... no lambda is triggered because the prefix doesn't match.\nNo. Then change your folder hierarchy. Set your event with prefix: A\/B\/C\/. Move the file to any key (i.e. \"folder\") that doesn't start with A\/B\/C, for example A\/B\/E. Thus, the second key will not match the prefix.\n\nThe suffix is not of any help unless you may rename the suffix of the file. If you are able to rename the file you create an event with suffix: .abc, and when moving the file you rename it to something ending in .xyz. Thus only the .abc files will trigger the Lambda, wherever they are situated.","Q_Score":0,"Tags":"python,amazon-s3,aws-lambda","A_Id":52788511,"CreationDate":"2018-10-12T22:47:00.000","Title":"Copy files in nested folders in S3 bucket","Data Science and Machine Learning":0,"Database and SQL":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 in Keras to cross-validate the early stopping metric being monitored EarlyStopping(monitor = 'val_acc', patience = 5)? Before allowing training to proceed to the next epoch, could the model be cross-validated to get a more robust estimate of the test error? What I have found is that the early stopping metric, say the accuracy on a validation set, can suffer from high variance. Early-stopped models often do not perform nearly as well on unseen data, and I suspect this is because of the high variance associated with the validation set approach.\nTo minimize the variance in the early stopping metric, I would like to k-fold cross-validate the early stopping metric as the model trains from epoch i to epoch i + 1. I would like to take the model at epoch i, divide the training data into 10 parts, learn on 9 parts, estimate the error on the remaining part, repeat so that all 10 parts have had a chance to be the validation set, and then proceed with training to epoch i + 1 with the full training data as usual. The average of the 10 error estimates will hopefully be a more robust metric that can be used for early stopping.\nI have tried to write a custom metric function that includes k-fold cross-validation but I can't get it to work. Is there a way to cross-validate the early stopping metric being monitored, perhaps through a custom function inside the Keras model or a loop outside the Keras model? \nThanks!!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":960,"Q_Id":52788635,"Users Score":0,"Answer":"I imagine that using a callback as suggested by @VincentPakson would be cleaner and more efficient, but the level of programming required is beyond me. I was able to create a for loop to do what I wanted by:\n\nTraining a model for a single epoch and saving it using model.save().\nLoading the saved model and training the model for a single epoch for each of the 10 folds (i.e. 10 models), then averaging the 10 validation set errors.\nLoading the saved model and training for a single epoch using all of the training data, and the overwriting the saved model with this model.\nRepeating steps 1-3 until the estimate from 2 stops improving for a given patience.\n\nI'd love a better answer but this seems to work. Slowly.","Q_Score":6,"Tags":"python,keras,prediction,cross-validation","A_Id":52843229,"CreationDate":"2018-10-13T01:01:00.000","Title":"Early Stopping with a Cross-Validated Metric in Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently setting the vector size by using model.add(LSTM(50)) i.e setting the value in units attribute but I highly doubt its correctness(In keras documentation, units is explained as dimensionality of the output space). Anyone who can help me here?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":567,"Q_Id":52789325,"Users Score":0,"Answer":"If by vector size you mean the number of nodes in a layer, then yes you are doing it right. The output dimensionality of your layer \nis the same as the number of nodes. The same thing applies to convolutional layers, number of filters and output dimensionality along the last axis, aka number of color channels is the same.","Q_Score":0,"Tags":"python,keras,lstm","A_Id":52846778,"CreationDate":"2018-10-13T03:42:00.000","Title":"How to set size of hidden state vector in LSTM, keras?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had facebook login setup using python-social-auth a while ago, but it stopped working. Now I updated social auth library and set it up again.\nI went trough a few errors from incorrect secret, incorrect facebook setup up till \"Authentication process canceled\". Now it seems like whole process went successfully, however once I am redirected back, I am still not logged in.\nI think, I have same problem with google auth, which worked alright even before I updated library, so I guess some configuration changed.\nI upgraded from python-social-auth==0.2.21 to python-social-auth==0.3.6.\nI checked newest documentation and changed a few bits, that were different with no help.\nI got standard pipeline, social AUTHENTICATION_BACKENDS first, updated context processors (prefix social.apps.django_app -> social_django), but still no help.\nI already went trough quite a few files of the library and related ones to fix those errors.\nNow I kinda don't know where should I look for problem and dig a bit.\nAny hints would be greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":137,"Q_Id":52791313,"Users Score":1,"Answer":"Okay, it took me a lot of digging. I knew whole pipeline was going trough and there was user instance in the end + request.user.is_authenticated() returned true. However after redirect, I wasn't logged in.\nIn the end, I found out, I had to change social.backends.facebook.FacebookOAuth2 to social_core.backends.facebook.FacebookOAuth2 in AUTHENTICATION_BACKENDS (and same for GoogleOAuth2).\nVery annoying and hard to find.","Q_Score":0,"Tags":"django,facebook-oauth,python-social-auth","A_Id":52995354,"CreationDate":"2018-10-13T09:04:00.000","Title":"Django facebook login","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been using pandas for a while and it worked fine but out of nowhere, it decided to give me this error \n\nAttributeError(\"module 'pandas' has no attribute 'read_csv'\")\n\nNow I have spent many many hours trying to solve this issue viewing every StackOverflow forum but they don't help. \n\nI know where both my cvs + python files are located.\nMy script is not called cvs.py or anything such.\nMy code can literally just be `'import pandas as pd' and I get the\nno attribute error.\n\nI would appreciate if someone could spare the time + assist me in solving this problem.","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":5427,"Q_Id":52791477,"Users Score":0,"Answer":"Since I had this problem just now, and on the whole internet no answer covered my issue:\nYou may have pandas installed (Like I did), but in the wrong environment. Especially when you just start out in Python and use an IDE like PyCharm, you don't realise that you may create a new Environment (Called \"pythonProject\", \"pythonProject1\", pythonProject2\",... by default), and installing a package does not mean it is installed in all Environments.\nIf you have AnacondaNavigator installed, you can easily look up which Environment has which packages.\n\nThis is a very cruel oversight, as PyCharm doesn't warn you of the misplaced package; it just looks up if it is somewhere; so you don't get the error at import.","Q_Score":4,"Tags":"python,pandas,csv","A_Id":64389564,"CreationDate":"2018-10-13T09:27:00.000","Title":"'pandas' has no attribute 'read_csv'\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using pandas for a while and it worked fine but out of nowhere, it decided to give me this error \n\nAttributeError(\"module 'pandas' has no attribute 'read_csv'\")\n\nNow I have spent many many hours trying to solve this issue viewing every StackOverflow forum but they don't help. \n\nI know where both my cvs + python files are located.\nMy script is not called cvs.py or anything such.\nMy code can literally just be `'import pandas as pd' and I get the\nno attribute error.\n\nI would appreciate if someone could spare the time + assist me in solving this problem.","AnswerCount":5,"Available Count":5,"Score":0.0798297691,"is_accepted":false,"ViewCount":5427,"Q_Id":52791477,"Users Score":2,"Answer":"I've just been spinning my wheels on the same problem. \nTL\/DR: try renaming your python files\nI think there must be a number of other naming conflicts besides some of the conceivably obvious ones like csv.py and pandas.py mentioned in other posts on the topic.\nIn my case, I had a single file called inspect.py. Running on the command line gave me the error, as did running import pandas from within a python3 shell, but only when launching the shell from the same directory as inspect.py. I renamed inspect.py, and now it works just fine!!","Q_Score":4,"Tags":"python,pandas,csv","A_Id":53273547,"CreationDate":"2018-10-13T09:27:00.000","Title":"'pandas' has no attribute 'read_csv'\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using pandas for a while and it worked fine but out of nowhere, it decided to give me this error \n\nAttributeError(\"module 'pandas' has no attribute 'read_csv'\")\n\nNow I have spent many many hours trying to solve this issue viewing every StackOverflow forum but they don't help. \n\nI know where both my cvs + python files are located.\nMy script is not called cvs.py or anything such.\nMy code can literally just be `'import pandas as pd' and I get the\nno attribute error.\n\nI would appreciate if someone could spare the time + assist me in solving this problem.","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":5427,"Q_Id":52791477,"Users Score":0,"Answer":"I have faced the same problem when I update my python packages using conda update --all.\nThe error:\nAttributeError: module 'pandas' has no attribute 'read_csv'\nI believe it is a pandas path problem.\nThe solution:\nprint(pd)\nTo see where are your pandas come from. I was getting\n<module 'pandas' (namespace)>\nThen I used to print(np), for example, to see where my numpy is, then I got\n<module 'numpy' from 'C:\\\\Users\\\\name\\\\Anaconda3\\\\envs\\\\eda_env\\\\lib\\\\site-packages\\\\numpy\\\\__init__.py'>\nI used the same path to find my pandas path. I found out that the folder lib named Lib with an uppercase letter. I change it to lowercase lib, and it solves my problem.\nChange Lib to lib or check a working module and make sure pandas have the same.","Q_Score":4,"Tags":"python,pandas,csv","A_Id":68730346,"CreationDate":"2018-10-13T09:27:00.000","Title":"'pandas' has no attribute 'read_csv'\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using pandas for a while and it worked fine but out of nowhere, it decided to give me this error \n\nAttributeError(\"module 'pandas' has no attribute 'read_csv'\")\n\nNow I have spent many many hours trying to solve this issue viewing every StackOverflow forum but they don't help. \n\nI know where both my cvs + python files are located.\nMy script is not called cvs.py or anything such.\nMy code can literally just be `'import pandas as pd' and I get the\nno attribute error.\n\nI would appreciate if someone could spare the time + assist me in solving this problem.","AnswerCount":5,"Available Count":5,"Score":0.0399786803,"is_accepted":false,"ViewCount":5427,"Q_Id":52791477,"Users Score":1,"Answer":"After spending 2 hours researching a solution to this question, running pip uninstall pandas and then pip install pandas in your terminal will work.","Q_Score":4,"Tags":"python,pandas,csv","A_Id":69326903,"CreationDate":"2018-10-13T09:27:00.000","Title":"'pandas' has no attribute 'read_csv'\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using pandas for a while and it worked fine but out of nowhere, it decided to give me this error \n\nAttributeError(\"module 'pandas' has no attribute 'read_csv'\")\n\nNow I have spent many many hours trying to solve this issue viewing every StackOverflow forum but they don't help. \n\nI know where both my cvs + python files are located.\nMy script is not called cvs.py or anything such.\nMy code can literally just be `'import pandas as pd' and I get the\nno attribute error.\n\nI would appreciate if someone could spare the time + assist me in solving this problem.","AnswerCount":5,"Available Count":5,"Score":0.0399786803,"is_accepted":false,"ViewCount":5427,"Q_Id":52791477,"Users Score":1,"Answer":"I had the same issue and it is probably cause of writing\ndataframe = pd.read.csv(\"dataframe.csv\")\ninstead of\ndataframe = pd.read_csv(\"dataframe.csv\")\nthat little \"_\" is the problem.\nHope this helps somebody else too.","Q_Score":4,"Tags":"python,pandas,csv","A_Id":64144515,"CreationDate":"2018-10-13T09:27:00.000","Title":"'pandas' has no attribute 'read_csv'\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Anaconda 3 and wanted to execute python from the shell. It returned that it's either written wrong or does not exist. Apparently, I have to add a path to the environmentle variable.\nCan someone tell how to do this?\nEnvironment: Windows 10, 64 bit and python 3.7\nPs: I know the web is full with that but I am notoriously afraid to make a mistake. And I did not find an exact entry for my environment. Thanks in advance.\nBest Daniel","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4417,"Q_Id":52792102,"Users Score":0,"Answer":"Windows:\n\nsearch for -->Edit the system environment variables\nIn Advanced tab, click Environment variabless\nIn System variables, Select PATH and click edit. Now Click new, ADD YOU PATH.\nClick Apply and close.\n\nNow, check in command prompt","Q_Score":0,"Tags":"python-3.x,path,environment-variables","A_Id":52792181,"CreationDate":"2018-10-13T10:45:00.000","Title":"python 3.7 setting environment variable path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"started the test in Selenium in addition in my browser I manually clicked and\/or entered the data in the fields.\nIs it possible to save the actions that I made manually - actions logs?\nI want to know what the user's actions during manual test.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":264,"Q_Id":52792860,"Users Score":0,"Answer":"I suggest you using Selenium with third-party framework like Robotframework.\nIt will be easier to observe actions with those behavior driven test framework.\nAnd they will also help you to capture screenshot while error occurs.","Q_Score":0,"Tags":"java,python,selenium,webdriver","A_Id":52792957,"CreationDate":"2018-10-13T12:22:00.000","Title":"Manual actions in Selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"started the test in Selenium in addition in my browser I manually clicked and\/or entered the data in the fields.\nIs it possible to save the actions that I made manually - actions logs?\nI want to know what the user's actions during manual test.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":264,"Q_Id":52792860,"Users Score":0,"Answer":"S\u0142awomir, why don't You start record all actions from beginning, after launch webbrowser. For FF55+ there is an addon Katalon Recorder. You can record all steps and than export all actions to Java, Pyton code. Than just copy code from exporter, and You can use it in your webdriver tests.","Q_Score":0,"Tags":"java,python,selenium,webdriver","A_Id":52854082,"CreationDate":"2018-10-13T12:22:00.000","Title":"Manual actions in Selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"started the test in Selenium in addition in my browser I manually clicked and\/or entered the data in the fields.\nIs it possible to save the actions that I made manually - actions logs?\nI want to know what the user's actions during manual test.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":264,"Q_Id":52792860,"Users Score":0,"Answer":"Below example\n\nSimple example\nDuring the test Selenium opens a page example.com. Next Selenium click on link to example.com\/login. On the login page Selenium enters username and password -- it is correct test\n\nExample with manual actions\nDuring the test Selenium opens a page example.com. Now manually I click on link example.com\/about (but on About page isn't link to example.com\/login Next Selenium try to click on link to example.com\/login, but can't because link to example.com\/login doesn't exist. -- test failed\n\nTest failed because I make manual action, so I want to log all manually actions","Q_Score":0,"Tags":"java,python,selenium,webdriver","A_Id":52860596,"CreationDate":"2018-10-13T12:22:00.000","Title":"Manual actions in Selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a PWA with django\/python on the server-side and vue on the client-side and want to use firebase as a database as well as make use of the firebase authentication.\nAfter some thorough research I realised that I had to make a few choices. \nQuestion 1: Authentication \n\nI can do authentication on the client-side or server-side. Which one would be best (more secure) ?\n\nQuestion 2: Database\n\nIn terms of CRUDS I am a bit conflicted. Do I write all my data to firestore from the client-side?\nDo I rather use api's to communicate with my backend and then write data to firestore from the backend? What are the security implications of doing this?\n\nShould I just use both in terms of context? If there are no security implications I would do my authentication client-side and my CRUDS from the server-side. I think I would also have to check authentication to write to the database from the backend.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2897,"Q_Id":52793661,"Users Score":5,"Answer":"Authentication of a user's credentials should always happen on a server, as it can't be securely done on the client's computer. What Firebase Authentication allows however, is that the authentication runs on Google's servers, while you control it from a simple client-side API call.","Q_Score":7,"Tags":"python,django,firebase,vue.js,firebase-authentication","A_Id":52793728,"CreationDate":"2018-10-13T13:54:00.000","Title":"Firebase (client-side vs server-side)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm developing an multi-page web application using python tornado framework (includes API), and because the application is said to be used in mobile I decided to use phonegap to test on mobile.\nNow the question, Is it possible to make tornado application listen to the phonegap (from mobile) ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":72,"Q_Id":52794736,"Users Score":1,"Answer":"basically you want to install Tornado app in some\/local server server, and create API calls from Phonegap -> Tornado server ?\nIt's possible, if you're developing locally - you have a local address that you define ( 127.0.0.1:8080 or whatever )\nThen from phonegap you can generate Ajax calls towards your server.\nThe best approach in such case, is to not use Tornado with HTML files, with API work always with JSON outputs ....","Q_Score":0,"Tags":"python,tornado,phonegap","A_Id":63304273,"CreationDate":"2018-10-13T15:54:00.000","Title":"Is it possible to use python tornado framework with phonegap?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm struggling with a question.\nSo I created a Neural Network, but now I want to put values from my database in it. It's important that the data from the database is collected by a php script (already created), and has been send to my python Neural Network script. How do I transfer multiple variables and even multiple rows from my database to a python script?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":21,"Q_Id":52797713,"Users Score":0,"Answer":"Best way to share data is via API. Prepare array containing multiple data you want to send then convert the data to JSON. On python, decode the JSON then take data out of it one by one. Hope this answers your question.","Q_Score":0,"Tags":"php,python,sql","A_Id":52797757,"CreationDate":"2018-10-13T22:00:00.000","Title":"How to send SQL data gain from a php script to a python script?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given I have two different lists with ints.\na = [1, 4, 11, 20, 25] and b = [3, 10, 20]\nI want to return a list of length len(b) that stores the closest number in a for each ints in b.\nSo, this should return [4, 11, 20].\nI can do this in brute force, but what is a more efficient way to do this? \nEDIT: It would be great if I can do this with standard library, if needed, only.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1190,"Q_Id":52798977,"Users Score":0,"Answer":"Use binary search, assuming the lists are in order.\nThe brute force in this case is only O(n), so I wouldn't worry about it, just use brute force.\nEDIT:\nyeh it is O(len(a)*len(b)) (roughly O(n^2)\nsorry stupid mistake.\nSince these aren't necessarily sorted the fastest is still O(len(a)*len(b)) though. Sorting the lists (using timsort) would take O(nlogn), then binary search O(logn), which results in O(nlog^2n)*O(n)=O(n^2log^2n), which is slower then just O(n^2).","Q_Score":3,"Tags":"python","A_Id":52799033,"CreationDate":"2018-10-14T02:29:00.000","Title":"Given two lists of ints, how can we find the closes number in one list from the other one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a virtual environment and installed ipython[all] and jupyter with pip. When I run jupyter lab, open a notebook, and try importing a package I installed inside the virtual environment, I get \u201cModuleNotFoundError.\u201d\nRunning ipython in the console and importing works. Also, which jupyter does point me to the right executable in the virtual environment.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1731,"Q_Id":52799158,"Users Score":0,"Answer":"In addition to installing jupyter, I need to install jupyter lab. Otherwise, even the virtual environment jupyter executable actually silently falls back to the system Jupyter Lab installation.","Q_Score":3,"Tags":"python,jupyter-notebook,virtualenv,jupyter-lab","A_Id":52799181,"CreationDate":"2018-10-14T03:12:00.000","Title":"Jupyter Lab is not using virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need use Python 3.6 in my project, I change my path .\/bashrc with:\nalias python=python3 on the first line.\nMy problem is, I need use Pip and Pipenv, and when I try install these packages, they are installed for python 2.7, and When I run these commands, they run with python2.7.\nI need change my Python path to 3.6 and Pip and Pipenv use with Python 3.6.\nWhat do I do?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1856,"Q_Id":52799773,"Users Score":1,"Answer":"Install the Python 3 version of Pip for Ubuntu: $ apt install python3-pip and invoke it with $ pip3","Q_Score":0,"Tags":"python,python-3.x,python-2.7,pip,pipenv","A_Id":52800219,"CreationDate":"2018-10-14T05:33:00.000","Title":"How to Change Change Python 2.7 to Python 3,6 in UBuntu?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a main thread running Cmd from cmd2. This allows me to interactively start new threads using threading.Thread() performing simulations in \"real-time\". Every time step the simulation results are put() in a multiprocessing.Queue(). Additionally I can start live plots using matplotlib.animate. I read matplotlib is not thread-safe, so the plots run as a multiprocessing.Process() and get() the simulation results from the queue. \nUnfortunately, once items from the queue are collected, they are deleted from the queue and not available for other threads or processes. This means I can send data from the simulation threads to the plotting processes, but can't use the simulation results at the same time in my main thread.\nA solution could be to have two queues in each simulation thread: one queue to the main thread and one queue to the plotting process. This doesn't seem to be the optimal solution, but a rather complicated one. \nDoes anyone have an idea how to realize some kind of thread-safe shared variable every thread and processes can read from and write to?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1740,"Q_Id":52800468,"Users Score":0,"Answer":"In general, there are two main ways of sharing data between threads and memory:\n\nmessage passing\nshared memory\n\nPython encourages you to avoid writing code that uses shared memory, and if you need to share data between threads and processes, you should just  make a copy of the data and send it through a Queue.\nIf you need actual shared memory, this is fraught with many perils as you'll necessarily need to deal with locks to avoid problems. Additionally, this may not be possible with many python objects either as all python objects in a process shares a GIL.\n\nI read matplotlib is not thread-safe\n\nCode that aren't t multihread safe are usually not multiprocess safe either.\n\nDoes anyone have an idea how to realize some kind of thread-safe shared variable every thread and processes can read from and write to?\n\nYou don't want to, or if you really have to, use a database.","Q_Score":3,"Tags":"python,multithreading,multiprocessing","A_Id":52801343,"CreationDate":"2018-10-14T07:31:00.000","Title":"How to share data between multiple threads and processes in Python effectively?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a 2-echelon vehicle routing problem (2E-VRP) and I'd like to use the neighborhood search base heuristic:\n\nI wonder what's the difference between variable neighborhood search (VNS), large neighborhood search (LNS) and Adaptive large neighborhood search (ALNS).\nCan I define more than one destroy operator in LNS? If yes, should I use all of them in sequence at each iteration or just select one of them randomly?\nAlso in ALNS, all the destroy operators used at each iteration or one of them selected base on its score?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":820,"Q_Id":52802777,"Users Score":0,"Answer":"Roughly speaking, search neighbourhood means the different solutions that are reachable by a move or search iteration. I believe variable neighbourhood search systematically increases the search neighbourhood when the solution appears to be stuck in local optimium (i.e. makes the neighbourhood bigger when a small neighbourhood isn't doing anything), whereas large neighbourhood search has a fixed but large search neighbourhood (i.e. neighbourhood size doesn't change). Adaptive large neighbourhood search would have multiple possible neighbourhoods corresponding to different search operations - e.g. different destruction or construction heuristics - and would try to learn which neighbourhood is best.\n\nCan I define more than one destroy operator in LNS? If yes, should I\n  use all of them in sequence at each iteration or just select one of\n  them randomly?\n\nI suspect just choosing a single one randomly will be more effective.  \n\nAlso in ALNS, all the destroy operators used at each iteration or one\n  of them selected base on its score?\n\nALNS would select one based on its score, but you'd presumably still need to have a non-zero probability of selecting any operator for the adaptivity to work (as you'd need to be testing all operators once in a while).","Q_Score":1,"Tags":"python","A_Id":53528893,"CreationDate":"2018-10-14T12:43:00.000","Title":"Neighborhood search","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to install the mpl_finance package into the environment path on Anaconda?\nI tried pip install mpl_finance but I still can't find the package on Anaconda, where did it go? I am pretty fresh in Python.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":11571,"Q_Id":52803553,"Users Score":1,"Answer":"conda install -c conda-forge mplfinance","Q_Score":6,"Tags":"python,pycharm,anaconda,mplfinance","A_Id":67309670,"CreationDate":"2018-10-14T14:16:00.000","Title":"How to install mpl_finance packages into environment on Anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to install the mpl_finance package into the environment path on Anaconda?\nI tried pip install mpl_finance but I still can't find the package on Anaconda, where did it go? I am pretty fresh in Python.","AnswerCount":3,"Available Count":2,"Score":0.3215127375,"is_accepted":false,"ViewCount":11571,"Q_Id":52803553,"Users Score":5,"Answer":"Go to anaconda prompt\nSelect your environment\nRun pip install mpl_finance\n\nIn your code, change matplotlib.finance  to mpl_finance\nregards","Q_Score":6,"Tags":"python,pycharm,anaconda,mplfinance","A_Id":53832148,"CreationDate":"2018-10-14T14:16:00.000","Title":"How to install mpl_finance packages into environment on Anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to access a folder object inside S3 bucket. How can I access a folder inside S3 bucket using python boto3.\nCode is working for a folder in S3 bucket but to for folders inside S3 bucket","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":4249,"Q_Id":52805052,"Users Score":2,"Answer":"If I understand you correctly.. I had this issue in my python3 script. Basically you need to pass the to the boto3 function an s3 bucket and the file name. Make this file name include the folder, with the forward slash separating them. Instead of passing just the file name and trying to pass the folder as a separate parameter. \nSo if you have MyS3Bucket and you want to upload file.txt to MyFolder inside MyS3Bucket, then pass the file_name=\u201cMyFolder\u201d+\u201d\/\u201c+\u201dfile.txt\u201d as a parameter to the upload function.\nLet me know if you need a code snippet. \nEven if you don\u2019t have the folder in the S3 bucket, boto3 will create it for you on the fly. This is cool because you can grant access in s3 based on a folder, not just the whole bucket at once. \nGood luck!","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,boto3","A_Id":55203529,"CreationDate":"2018-10-14T17:03:00.000","Title":"How to upload file to folder in aws S3 bucket using python boto3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say that most of my DAGs and tasks in AirFlow are supposed to run Python code on the same machine as the AirFlow server.\nCan I have different DAGs use different conda environments? If so, how should I do it? For example, can I use the Python Operator for that? Or would that restrict me to using the same conda environment that I used to install AirFlow.\nMore generally, where\/how should I ideally activate the desired conda environment for each DAG or task?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1210,"Q_Id":52805712,"Users Score":4,"Answer":"The Python that is running the Airflow Worker code, is the one whose environment will be used to execute the code.\nWhat you can do is have separate named queues for separate execution environments for different workers, so that only a specific machine or group of machines will execute a certain DAG.","Q_Score":6,"Tags":"python,python-3.x,anaconda,conda,airflow","A_Id":52834527,"CreationDate":"2018-10-14T18:17:00.000","Title":"Python tasks and DAGs with different conda environments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have just installed Visual Studio 2017 with the python package. I'm creating a program using the empty python module. It allows me to debug the program but after a while it does not let me debug all of a sudden and that happens even after changing nothing! There is no error message that comes up to say why it cannot be run.\nIt's very frustrating. Has anyone else had this problem and is there a fix?\nThis is really annoying, i have to close visual studio and open it back up to get it working again","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":168,"Q_Id":52805784,"Users Score":0,"Answer":"There seemed to be a problem with a visual studio driver. Had to reboot PC once it had been fixed after troubleshooting","Q_Score":0,"Tags":"python,visual-studio","A_Id":52825261,"CreationDate":"2018-10-14T18:23:00.000","Title":"Visual Studio 2017 Python debugger problem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For example in python if I\u2019m sending data through sockets could I make my own encryption algorithm to encrypt that data? Would it be unbreakable since only I know how it works?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":52806028,"Users Score":1,"Answer":"Yes you can. Would it be unbreakable? No. This is called security through obscurity. You're relying on the fact that nobody knows how it works. But can you really rely on that?\nSomeone is going to receive the data, and they'll have to decrypt it. The code must run on their machine for that to happen. If they have the code, they know how it works. Well, at least anyone with a lot of spare time and nothing else to do can easily reverse engineer it, and there goes your obscurity.\nIs it feasable to make your own algorithm? Sure. A bit of XOR here, a bit of shuffling there... eventually you'll have an encryption algorithm. It probably wouldn't be a good one but it would do the job, at least until someone tries to break it, then it probably wouldn't last a day.\nDoes Python care? Do sockets care? No. You can do whatever you want with the data. It's just bits after all, what they mean is up to you.\nAre you a cryptographer? No, otherwise you wouldn't be here asking this. So should you do it? No.","Q_Score":0,"Tags":"python,encryption","A_Id":52806168,"CreationDate":"2018-10-14T18:54:00.000","Title":"Is it possible to make my own encryption when sending data through sockets?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any workaround how to use cv2.imshow() with a specific framerate? Im capturing the video via VideoCapture and doing some easy postprocessing on them (both in a separeted thread, so it loads all frames in Queue and the main thread isn't slowed by the computation). I tryed to fix the framerate by calculating the time used for \"reading\" the image from the queue and then substract that value from number of miliseconds avalible for one frame:\nif I have as input video with 50FPS and i want to playback it in real-time i do 1000\/50 => 20ms per frame. \nAnd then wait that time using cv2.WaitKey()\nBut still I get some laggy output. Which is slower then the source video","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2282,"Q_Id":52806175,"Users Score":1,"Answer":"I don't believe there is such a function in opencv but maybe you could improve your method by adding a dynamic wait time using timers? timeit.default_timer()\ncalculate the time taken to process and subtract that from the expected framerate and maybe add a few ms buffer.\neg cv2.WaitKey((1000\/50) - (time processing finished - time read started) - 10)\nor you could have a more rigid timing eg script start time + frame# * 20ms - time processing finished\nI haven't tried this personally so im not sure if it will actually work, also might be worth having a check so the number isnt below 1","Q_Score":0,"Tags":"python,opencv","A_Id":52806830,"CreationDate":"2018-10-14T19:10:00.000","Title":"imshow() with desired framerate with opencv","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to retrieve the text data for a specific twitter account and save it for a ML project about text generation, is this possible using the Twitter API?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":52807824,"Users Score":0,"Answer":"Yes. It is possible. Try tweepy. It is a wrapper for Twitter API.","Q_Score":0,"Tags":"python,text,twitter","A_Id":52807837,"CreationDate":"2018-10-14T23:02:00.000","Title":"How do\/can I retrieve text data from a Twitter account 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 selection of pdfs that I want to text mine. I use tika to parse the text out of each pdf and save to a .txt with utf-8 encoding (I'm using windows)\nMost of the pdfs were OCR'd before I got them but when I view the extracted text I have \"pn\u00c1nn\u00bf\u00a1c\" instead of \"Ph\u00e1draig\" if I view the PDF.\nIs it possible for me to verify the text layer of the PDF (forgive me if thats the incorrect term) Ideally without needing the full version of Acrobat","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":52807830,"Users Score":1,"Answer":"It sounds like you are dealing with scanned books with \"hidden OCR\", ie. the PDF shows an image of the original document, behind which there is a layer of OCRed text.\nThat allows you to use the search function and to copy-paste text out of the document.\nWhen you highlight the text, the hidden characters become visible (though this behaviour maybe depends on the viewer you use).\nTo be sure, you can copy-paste the highlighted text to a text editor.\nThis will allow you to tell if you are actually dealing with OCR quality this terrible, or if your extraction process caused mojibake.\nSince OCR quality heavily depends on language resources (dictionaries, language model), I wouldn't be surprised if the output was actually that bad for a low-resource language like Gaelic (Old Irish?).","Q_Score":0,"Tags":"python-3.x,pdf,utf-8,character-encoding,apache-tika","A_Id":52842615,"CreationDate":"2018-10-14T23:03:00.000","Title":"How to identify if text encoding issue is my processing error or carried from the source 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new in Odoo.\nIs it possible to create new dashboard in odoo10? I want to create dashboard for my pettycash module. If is it possible, How? I appreciate the links and advices.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":145,"Q_Id":52808506,"Users Score":0,"Answer":"All Depends in what kind of dashboard do you need. I suggest you to look at how are developed the currents dashboards that ships with Odoo. You could see several like Website, Sales, Invoicing, etc. \nYou will need to be familiar to Odoo internals and how to code in Odoo to be able to bring complex features alive but also you could add several actions views to compose a custom reporting dashboard by installing the module board","Q_Score":0,"Tags":"python-2.7,odoo-10,dashboard","A_Id":52811023,"CreationDate":"2018-10-15T01:05:00.000","Title":"Dashboard in odoo10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there any method to set certain action when my python program ends abruptly?\nEspecially I want to delete a folder and leave a log what was the error using logging module.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":52808639,"Users Score":0,"Answer":"You can use error handling, particuarly using the Try, Except statements.","Q_Score":0,"Tags":"python","A_Id":52808675,"CreationDate":"2018-10-15T01:27:00.000","Title":"How can I set what will be done when my python program terminates with error?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to implement neurons freezing in CNN for a deep learning research,\nI tried to find any function in the Tensorflow docs, but I didn't find anything.\nHow can I freeze specific neuron when I implemented the layers with tf.nn.conv2d?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":473,"Q_Id":52814880,"Users Score":0,"Answer":"A neuron in a dense neural network layer simply corresponds to a column in a weight matrix. You could therefore redefine your weight matrix as a concatenation of 2 parts\/variables, one trainable and one not. Then you could either:\n\nselectively pass only the trainable part in the var_list argument of the minimize function of your optimizer, or\nUse tf.stop_gradient on the vector\/column corresponding to the neuron you want to freeze.\n\nThe same concept could be used for convolutional layers, although in this case the definition of a \"neuron\" becomes unclear; still, you could freeze any column(s) of a convolutional kernel.","Q_Score":0,"Tags":"python,tensorflow,deep-learning","A_Id":52816856,"CreationDate":"2018-10-15T10:41:00.000","Title":"Neuron freezing in Tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have to solve the following task. First of all i'm using pyscard (python module to interact with smartcards) to query the smartcardreaders that are connected to the host. This works just fine and gives my a list of the connected readers.\nTo make this list available to puppet via facter, i need the list in form of key:value which i can than convert with json.dumps(list) and use it thru a custom fact.\nThe actual question is: How can i add the keys (0..8) to the given values from the pyscard list.\nAt the very end, the output should look similar to something like Reader\n0: REINER SCT cyberJack ecom_a (0856136421) 00 00\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":52817773,"Users Score":0,"Answer":"One way is to use zip\n>>> l0 = [\"reader one\", \"reader two\", \"reader three\"]\n>>> dict(zip(range(len(l0)),l0))\n{0: 'reader one', 1: 'reader two', 2: 'reader three","Q_Score":0,"Tags":"python,puppet,facter","A_Id":52817874,"CreationDate":"2018-10-15T13:23:00.000","Title":"How to generate a key:value list wih given values from a python list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Idle3 (of python3) regularly crashes when in a window and using the middle mousewheel.\nThere is always the same error left in Terminal:\n\nTraceback (most recent call last):   File \"\/usr\/local\/bin\/idle3\", line 5, in   main()   File\n  \"\/usr\/local\/Cellar\/python\/3.7.0\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/idlelib\/pyshell.py\",\n  line 1548, in main\n      root.mainloop()   File\n  \"\/usr\/local\/Cellar\/python\/3.7.0\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/tkinter\/init.py\", line 1280, in mainloop  self.tk.mainloop(n)\nUnicodeDecodeError: 'utf-8' codec can't decode byte 0xFF in position 0: invalid continuation byte\n  `","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":852,"Q_Id":52818660,"Users Score":1,"Answer":"The problem seems to be that brew installed python without tcl-tk, thus using the old tcl-tk from mac-os. This one has a problem interpreting some mousewheel commands.\nThe solution  : \nbrew reinstall python --with-tcl-tk","Q_Score":1,"Tags":"python,python-3.x,macos","A_Id":52818661,"CreationDate":"2018-10-15T14:10:00.000","Title":"My Idle (idle3) from python installed with homebrew on a mac crashes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I built an application using  cookiecutter-django by @pydanny back in May,\ndocker-compose was used for both dev and production environments and it's running very well,\nNow I have a requirement for asynchronous tasks and I want to use Celery,\nI did not choose celery when using the cookiecutter tool way back at the beginning,\nWhat's the best way to integrate celery into my project ?\nAlso noting that I will probably take this opportunity to upgrade docker-compose from version 2 to 3, bring mailgun, Django etc. to the latest versions\nIs it too messy to integrate to a live project ?\nShould I just create a new project using the cookiecutter tool ?\nNot too sure how to approach this so any help would be greatly appreciated,\nThanks","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":509,"Q_Id":52819276,"Users Score":3,"Answer":"I solved this by creating a new project from scratch using cookiecutter-django, this time including celery, flower etc. for async tasks. I then migrated my code to the new project. It didn't take too long, you just need to be careful when migrating that you don't miss anything.","Q_Score":4,"Tags":"python,django,docker-compose,cookiecutter-django","A_Id":53374105,"CreationDate":"2018-10-15T14:43:00.000","Title":"Django Cookiecutter upgrade best practice","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Is it possible to create a standalone Linux executable of python code using a Windows machine? My development setup is in Windows, and I need the standalone app for my prod Unix box.\nI have tried pyinstaller with combinations of inputs, and every time, it creates an .exe file.  Is there any other alternative or workaround which I can try?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1291,"Q_Id":52819909,"Users Score":3,"Answer":"No, there is no way to do this with PyInstaller and just a Windows development machine.\nPyInstaller creates executables for the system you're running it on. If you run it on a Windows machine, you get a Windows executable.\nIn the past, I solved this problem by creating a Linux development VM, and running PyInstaller there; it creates a Linux executable appropriately.","Q_Score":3,"Tags":"python,python-3.x,pyinstaller","A_Id":52820092,"CreationDate":"2018-10-15T15:19:00.000","Title":"Build Python Standalone Executable for Linux using Windows Machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Using python, how to connect to netezza database.\nSince PIP install is not working in my corporate network. I can't import pyodbc and jaydebeapi. Please suggest is there any way to connect netezza database and fetch data from table.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1185,"Q_Id":52823621,"Users Score":0,"Answer":"Unfortunately your hands are basically tied. If you don't have the means to \"speak\" to the database (JDBC\/ODBC) then there's really nothing you can do.\nPerhaps you could elaborate as to why your pip application isn't working and try to get that solved?","Q_Score":1,"Tags":"python,database,netezza","A_Id":53228891,"CreationDate":"2018-10-15T19:36:00.000","Title":"How to connect to Netezza database from Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I vaguely remember that the default value of execution_timeout is 15 minutes or 30 minutes but I couldn't find a relevant document anywhere. What is the default value?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3798,"Q_Id":52827541,"Users Score":0,"Answer":"The default task execution_timeout value for all the operators is None.\nIf not specified, then the value is considered as None, meaning that the operators are never timed out by default.","Q_Score":3,"Tags":"python,python-3.x,airflow","A_Id":72473721,"CreationDate":"2018-10-16T03:23:00.000","Title":"Default value of execution_timeout in Python Operator in Airflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I vaguely remember that the default value of execution_timeout is 15 minutes or 30 minutes but I couldn't find a relevant document anywhere. What is the default value?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3798,"Q_Id":52827541,"Users Score":1,"Answer":"PythonOperator inherits from BaseOperator so you should checkout BaseOperator's document.","Q_Score":3,"Tags":"python,python-3.x,airflow","A_Id":52833168,"CreationDate":"2018-10-16T03:23:00.000","Title":"Default value of execution_timeout in Python Operator in Airflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Need to extract table schema (using describe\\list columns)  into .txt or .csv file and later want to convert those files into .avsc(avro schema) file using python.\nsample.txt:\nCOLUMN_NAME         |TYPE_NAME|DEC&|NUM&|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL&\nAIRLINE             |CHAR     |NULL|NULL|2     |NULL      |4         |NO\nAIRLINE_FULL        |VARCHAR  |NULL|NULL|24    |NULL      |48        |YES\nNeed to convert sample.txt into sample.avsc","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":298,"Q_Id":52828409,"Users Score":0,"Answer":"Read CSV into python dict\nGet header part to other dict(header_dict)\ncreate empty dict(final_dict) and append type,namespace reletad thing and pass rows from header_dict to this final_dict.\nDump final_dict to file, which will be your avsc","Q_Score":0,"Tags":"python-2.7,avro,avsc","A_Id":55391303,"CreationDate":"2018-10-16T05:22:00.000","Title":"Python - How to convert .txt\/.csv file holding table schema to .avsc file","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a legacy Windows application which performs a critical business function. It has no API or official support for automation. This program requires a human to perform a sequence of actions in order to convert files in a particular input format into a PDF, from which we can scrape content and then process the data normally.\nThe business literally cannot function without some calculations\/reports that this software performs, but unfortunately, those calculations are poorly understood and we don't have the kind of R&D budget that would allow us to re-implement the software.\nThe software reads in a proprietary file format and generates a number of PDF reports in an industry-approved format, from which we can scrape the images and deal with them in a more conventional way. \nIt has been proposed that we wrap up the application inside some kind of API, where I might submit some input data into a queue, and somewhere deep within this, we automate the software as if a human user was driving it to perform the operations.\nUnfortunately, the operations are complex and depend on a number of inputs, and also the content of the file being processed. It's not the kind of thing that we could do with a simple macro - some logic will be required to model the behavior of a trained human operator. \nSo are there any solutions to this? We'd like to be able to drive the software as quickly as possible, and since we have many Python developers it makes sense to implement as much as possible in Python. The outer layers of this system will also be in Python, so that could cut out the complexity. Are there any tools which already provide the bulk of this kind of behavior?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1820,"Q_Id":52832504,"Users Score":1,"Answer":"Try out Robotic automation tools, which can mimic or record human interactions with computer and repeat over time. It can be made for handling more complex tasks using scripts depends on that software. Example selecting different inputs, browser components and also windows application.","Q_Score":4,"Tags":"python,windows,automation","A_Id":52832686,"CreationDate":"2018-10-16T09:42:00.000","Title":"Tools for automating windows applications (preferably in Python)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I installed the linter flake 8 package on Atom, and I did the pip installation, but for some reason linter isn't functioning it always displays the following error: \n\nLinter] Error running Flake8 See Console for more info. (Open View ->\n  Developer -> Toggle Developer Tools)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":898,"Q_Id":52834965,"Users Score":1,"Answer":"Double-check you pip installed flake8 properly - it should be installed system-wide (not in a virtualenv) and should be available on your PATH, so if you say which flake8 you should get something like \/usr\/local\/bin\/flake8. \nAlso if you open devtools like the error suggests, it might give you some clues as to what else might be wrong.","Q_Score":0,"Tags":"python,atom-editor,flake8","A_Id":52837645,"CreationDate":"2018-10-16T11:59:00.000","Title":"Getting error when running flake 8 on Atom","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cannot install package in Python.For example the package numpy or pandas.I download the python today.\nI press import numpy as np and nothing","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":40,"Q_Id":52839205,"Users Score":1,"Answer":"You have to install it first. Search \u201cPython Pip\u201d on google and download Pip. Then use that to open CMD and type \u201cpip install (Module)\u201d. Then it should import with no errors.","Q_Score":0,"Tags":"python,package","A_Id":52839277,"CreationDate":"2018-10-16T15:37:00.000","Title":"Cannot import python pack","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to deploy my flask app on Pythonanywhere but am getting an error i have no idea what to do about. I've looked online and people haven't been getting similar errors like mine. \nMy app loads a bunch of pretrained ML models. \nWould love some help!\n\n2018-10-16 20:52:38 \/home\/drdesai\/.virtualenvs\/flask-app-env\/lib\/python3.6\/site-packages\/sklearn\/base.py:251: UserWarning: Trying to unpickle estimator LinearRegression from version 0.19.1 when using version 0.20.0. This might lead to breaking code or invalid results. Use at your own risk.#012  UserWarning)\n2018-10-16 20:52:38 !!! uWSGI process 1 got Segmentation Fault !!!\n2018-10-16 20:52:38 * backtrace of 1 *#012\/usr\/local\/bin\/uwsgi(uwsgi_backtrace+0x2c) [0x46529c]#012\/usr\/local\/bin\/uwsgi(uwsgi_segfault+0x21) [0x465661]#012\/lib\/x86_64-linux-gnu\/libc.so.6(+0x36cb0) [0x7f6ed211ccb0]#012\/home\/drdesai\/.virtualenvs\/flask-app-env\/lib\/python3.6\/site-packages\/sklearn\/neighbors\/kd_tree.cpython-36m-x86_64-linux-gnu.so(+0x404b6) [0x7f6ead1d54b6]#012\/usr\/lib\/x86_64-linux-gnu\/libpython3.6m.so.1.0(_PyCFunction_FastCallDict+0x105) [0x7f6ed0e80005]#012\/usr\/lib\/x86_64-linux-gnu\/libpython3.6m.so.1.0(+0x16b5fa) [0x7f6ed0f195fa]#012\/usr\/lib\/x86_64-linux-gnu\/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x2f3c) [0x7f6ed0f1ccfc]#012\/usr\/lib\/x86_64-linux-gnu\/libpython3.6m.so.1.0(+0x16a890) [0x7f6ed0f18890]#012\/usr\/lib\/x86_64-linux-gnu\/libpython3.6m.so.1.0(+0x16b7b4) [0x7f6ed0f197b4]#012\/usr\/lib\/x86_64-linux-gnu\/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x2f3c) [0x7f6ed0f1ccfc]#012\/usr\/lib\/x86_64-linux-gnu\/libpython3.6m.so.1.0(+0x16a890) [0x7f6ed0f18890]#012\/usr\/lib\/x86_\n2018-10-16 20:52:38 chdir(): No such file or directory [core\/uwsgi.c line 1610]\n2018-10-16 20:52:38 VACUUM: unix socket \/var\/sockets\/drdesai.pythonanywhere.com\/socket removed.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1381,"Q_Id":52844037,"Users Score":0,"Answer":"uWSGI is a C\/C++ compiled app and segmentation fault is its internal error that means that there is some incorrect behavior in uWSGI logic: somewhere in its code it's trying to get access to area of memory it's not allowed to access to, so OS kills this process and returns \"segfault\" error. So make sure you have the latest stable version of uwsgi installed. Also make sure you installed it properly either using a package manager or via manual compiling. It's recommended to install it using a package manager since it's much more easy than via manual compiling. Also, make sure you use it properly.","Q_Score":0,"Tags":"python,flask,deployment,wsgi,pythonanywhere","A_Id":52859940,"CreationDate":"2018-10-16T21:04:00.000","Title":"uWSGI process 1 got Segmentation Fault _ Fail to deploy Flask App on Pythonanywhere","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am execute a python script in Azure machine learning studio. I am including other python scripts and python library, Theano. I can see the Theano get loaded and I got the proper result after script executed. But I saw the error message:\n\nWARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.\n\nDid anyone know how to solve this problem? Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":96,"Q_Id":52844431,"Users Score":1,"Answer":"I don't think you can fix that - the Python script environment in Azure ML Studio is rather locked down, you can't really configure it (except for choosing from a small selection of Anaconda\/Python versions). \nYou might be better off using the new Azure ML service, which allows you considerably more configuration options (including using GPUs and the like).","Q_Score":1,"Tags":"python,theano,azure-machine-learning-studio","A_Id":52850290,"CreationDate":"2018-10-16T21:43:00.000","Title":"Azure Machine Learning Studio execute python script, Theano unable to execute optimized C-implementations (for both CPU and GPU)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way I can stop the whole robot test execution with PASS status?\nFor some specific reasons, I need to stop the whole test but still get a GREEN report.\nCurrently I am using FATAL ERROR which will raise a assertion error and return FAIL to report.\nI was trying to create a user keyword to do this, but I am not really familiar with the robot error handling process, could anyone help?\nThere's an attribute ROBOT_EXIT_ON_FAILURE in BuiltIn.py, and I am thinking about to create another attribute like ROBOT_EXIT_ON_SUCCESS, but have no idea how to.\nEnvironment: robotframework==3.0.2 with Python 3.6.5","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3462,"Q_Id":52846338,"Users Score":0,"Answer":"If I understood you correctly, you need to pass the test execution forcefully and return green status for that test, is that right? You have a built in keyword \"Pass Execution\" for that. Did you try using that?","Q_Score":0,"Tags":"python-3.x,robotframework","A_Id":55419982,"CreationDate":"2018-10-17T02:07:00.000","Title":"How to stop the whole test execution but with PASS status in RobotFramework?","Data Science and Machine Learning":0,"Database and SQL":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 render an environment with gym it plays the game so fast that I can\u2019t see what is going on. And it shouldn\u2019t be a problem with the code because I tried a lot of different ones.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1151,"Q_Id":52847350,"Users Score":2,"Answer":"Use time.sleep(.1) after every render.","Q_Score":6,"Tags":"python,machine-learning,openai-gym","A_Id":60582721,"CreationDate":"2018-10-17T04:34:00.000","Title":"Is there a way to slow down the game environment with gym\u2019s OpenAI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to import an Excel file into a new table in a Teradata database, using SQLAlchemy and pandas.\nI am using the pandas to_sql function. I load the Excel file with pandas and save it as a dataframe named df. I then use df.to_sql and load it into the Teradata database.\nWhen using the code:\ndf.to_sql('rt_test4', con=td_engine, schema='db_sandbox')\nI am prompted with the error:\nDatabaseError: (teradata.api.DatabaseError) (3534, '[42S11] [Teradata][ODBC Teradata Driver][Teradata Database] Another index already exists, using the same columns and the same ordering. ') [SQL: 'CREATE INDEX ix_db_sandbox_rt_test4_index (\"index\") ON db_sandbox.rt_test4']\nWhen I try this and use Teradata SQL Assistant to see if the table exists, I am prompted with selecting txt or unicode for each column name, and to pick a folder directory. A prompt titled LOB information pops open and I have to select if it's UTF or unicode, and a file directory. Then it loads and all the column titles populate, but they are left as empty fields. Looking for some direction here, I feel I've been spinning my wheels on this.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":780,"Q_Id":52847985,"Users Score":1,"Answer":"I solved it! Although I do not know why, I'm hoping someone can explain:\ntf.to_sql('rt_test4', con=td_engine, schema='db_sandbox', index = False, dtype= {'A': CHAR, 'B':Integer})","Q_Score":1,"Tags":"python,pandas,sqlalchemy,teradata","A_Id":52848240,"CreationDate":"2018-10-17T05:46:00.000","Title":"Importing a pandas dataframe into Teradata database","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Django and All-auth. I want to restrict users to take certain usernames. I know that it is done through writing the following in  settings.py.\nACCOUNT_USERNAME_BLACKLIST (=[])\nBut I want to take this list from a .txt file. Should I read the .txt file in my settings.py and then populate the ACCOUNT_USERNAME_BLACKLIST (=[]) list? Or there is some other way that is more reasonable and considered as a best practice?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":153,"Q_Id":52853987,"Users Score":1,"Answer":"Yes. You can just read in the text file in your settings file.\nIts a common practice done where people will often load in a json file that contains values for a load of different settings that may change depending on environment.","Q_Score":0,"Tags":"django,python-2.7,django-allauth","A_Id":52854957,"CreationDate":"2018-10-17T11:38:00.000","Title":"Ban certain users by using ACCOUNT_USERNAME_BLACKLIST (=[]) and getting data from a .txt file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I built tensorflow from source and got a *.whl file that I could install on my pc with pip install *.whl. Now in the virtualenv where I installed it I can open python and do import tensorflow without a problem and also use tf. Now I tried to install this same wheel on an other pc in a virtualenv and it worked successfully, but when I try to use import tensorflow in python I get: \nImportError: libnvidia-fatbinaryloader.so.390.48: cannot open shared object file: No such file or directory\nNow I actually do not have that file on the other pc, but after checking my own pc I also don't have it here. I have on both pcs libnvidia-fatbinaryloader.so.390.87. On both pcs the LD_LIBRARY_PATH points to the directory with that version. \nHow can it be that tensorflow searches for version 48 on the remote pc while searching for 87 and finding it on my pc, even though they are both installed with the same whl file? Is there a config that I need to adjust what version it should search for?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":52854983,"Users Score":1,"Answer":"I would say you have a broken CUDA installation somewhere in the library path. It is libcuda.so that has a dependency on libnvidia-fatbinaryloader.so, so maybe the symbolic links point to a library that no longer exists but was installed before.\nYou can find this information by running the ldd command on the libcuda.so file.","Q_Score":0,"Tags":"python,tensorflow","A_Id":52855692,"CreationDate":"2018-10-17T12:33:00.000","Title":"Why are different libraries searched for in tensorflow, even though both were installed the same way?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I built tensorflow from source and got a *.whl file that I could install on my pc with pip install *.whl. Now in the virtualenv where I installed it I can open python and do import tensorflow without a problem and also use tf. Now I tried to install this same wheel on an other pc in a virtualenv and it worked successfully, but when I try to use import tensorflow in python I get: \nImportError: libnvidia-fatbinaryloader.so.390.48: cannot open shared object file: No such file or directory\nNow I actually do not have that file on the other pc, but after checking my own pc I also don't have it here. I have on both pcs libnvidia-fatbinaryloader.so.390.87. On both pcs the LD_LIBRARY_PATH points to the directory with that version. \nHow can it be that tensorflow searches for version 48 on the remote pc while searching for 87 and finding it on my pc, even though they are both installed with the same whl file? Is there a config that I need to adjust what version it should search for?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":52854983,"Users Score":0,"Answer":"The building process is related to the computer environment.Could building tensorflow in the same machine and installing it on the same machine help?Building on one machine and generating the *.whl,but installing on other machines may cause problem.","Q_Score":0,"Tags":"python,tensorflow","A_Id":52855249,"CreationDate":"2018-10-17T12:33:00.000","Title":"Why are different libraries searched for in tensorflow, even though both were installed the same way?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've some models from models.Model in django and wish to know if I change it and extend to BaseModel will occur some error when I make migrations. Thanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":139,"Q_Id":52855657,"Users Score":1,"Answer":"No. If your BaseModel extends models.Model.","Q_Score":0,"Tags":"python,django,django-models,django-migrations","A_Id":52855687,"CreationDate":"2018-10-17T13:08:00.000","Title":"Integrate current models from models.Model to BaseModel django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wanted to install Pytorch via anaconda and it worked but PyCharm can't find the module (\n\nModuleNotFoundError: No module named 'torch'\n\nI also have CUDA installed but when I looked up to add a the package with pycharm it also gives an error. When I added the anaconda interpreter I can't run the code. I use Python 3.6","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":16572,"Q_Id":52856441,"Users Score":7,"Answer":"Ok I solved this problem: First install anaconda and open the prompt then type conda install pytorch -c pytorch and pip3 install torchvision. Then go to PyCharm and create an Project and set the Project Interpreter to the Anaconda one (there is in the path: \\Anaconda.x.x\\python.exe ). Then you go to the Run settings and click Run... and then you go to Edit Configurations and then you select the Project Default interpreter and apply and you should be done! Thanks to the ppl who helped me =)","Q_Score":4,"Tags":"python,python-3.x,pycharm,python-3.6,pytorch","A_Id":52906407,"CreationDate":"2018-10-17T13:45:00.000","Title":"Module not found in pycharm (Windows)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to install Pytorch via anaconda and it worked but PyCharm can't find the module (\n\nModuleNotFoundError: No module named 'torch'\n\nI also have CUDA installed but when I looked up to add a the package with pycharm it also gives an error. When I added the anaconda interpreter I can't run the code. I use Python 3.6","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":16572,"Q_Id":52856441,"Users Score":0,"Answer":"In you are on ubuntu and have installed pytorch using anaconda then in the interpreter of the pycharm which is under \n File -> Settings -> Interpreter you have to do following:\nsearch for the conda where it is installed by doing where conda then in that you will find a python.exe in your environment folder provide the path of that in the python interpreter.\nTry with this it should work as I was facing the similar issue on windows solved it using this procedure.\nAnd probably where conda won't work if you don't have support for ubuntu commands in windows than you can go to the folder where Anaconda is there which probably will be in your Users -> 'Your User' folder in that search for you environment and in that go to your environment and find python.exe give this path in pycharm.","Q_Score":4,"Tags":"python,python-3.x,pycharm,python-3.6,pytorch","A_Id":54523742,"CreationDate":"2018-10-17T13:45:00.000","Title":"Module not found in pycharm (Windows)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two same versions of python on windows. Both are 3.6.4. I installed one of them, and the other one comes with Anaconda.\nMy question is how do I use pip to install a package for one of them? It looks like  the common method will not work since the two python versions are the same.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":85,"Q_Id":52856872,"Users Score":1,"Answer":"pip points to only one installation because pip is a script from one python.\nIf you have one Python in your PATH, then it's that python and that pip that will be used.","Q_Score":0,"Tags":"python,windows,pip","A_Id":52856982,"CreationDate":"2018-10-17T14:07:00.000","Title":"how to use pip install a package if there are two same version of python on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two same versions of python on windows. Both are 3.6.4. I installed one of them, and the other one comes with Anaconda.\nMy question is how do I use pip to install a package for one of them? It looks like  the common method will not work since the two python versions are the same.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":52856872,"Users Score":0,"Answer":"Use virtualenv, conda environment or pipenv, it will help with managing packages for different projects.","Q_Score":0,"Tags":"python,windows,pip","A_Id":52857053,"CreationDate":"2018-10-17T14:07:00.000","Title":"how to use pip install a package if there are two same version of python on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a created a python to get input files from windows folder and updated the excel sheet every 15 minutes. Program is always open - running in background. \nProgram was running properly for 2 weeks and suddenly the program closed with error message 'A problem caused the program stop working correctly and was closed\". I have checked the log files and didn't see any error message. \nI checked the Windows log viewer and error was present with below text, which i could not interpret properly. Can anyone please let me the possible causes for the error. \n\nProgram.exe\n0.0.0.0\n5a2e9e81\npython36.dll\n3.6.5150.1013\n5abd3161\nc00000fd\n0000000000041476\n1ba8\n01d45e9fe43cba57\nC:\\Python code\\program.exe\nC:\\Users\\aisteam\\AppData\\Local\\Temp\\2_MEI51602\\python36.dll\na9da018c-e2e3-4821-9387-cce82ff29186","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":408,"Q_Id":52857263,"Users Score":1,"Answer":"Make sure that your python code robustly handles errors like when the file it wants to update is locked, which is what Excel does while the file is open in Excel. by design, you could easily make your code create a new excel file each time, or wait until the file isn\u2019t locked then update it. Either way, you need to make your code better at telling you what it is doing, e.g. by logging what it is doing (which is important to implement now because the logging needs to be in place before your code stops unexpectedly for, err, an unexpected reason), e.g. by carefully managing exceptions (i.e. don\u2019t simply code as try\/except:pass!)\nBUT don\u2019t do this sort of code with an unconditional except and nothing but a pass in the except: statement) because it will make errors HARDER to figure out:\n\n    try:\n        something\n    except:\n        pass\n\nAlways be specific about the exception you expect, and even if you are going to not raise, always always always log the exception.","Q_Score":0,"Tags":"python,windows,event-log","A_Id":52864096,"CreationDate":"2018-10-17T14:25:00.000","Title":"python36.dll - Program has stopped working, a problem caused the program stop working correctly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created an R kernel to use in a Jupyter notebook with:\nconda create -n myrenv r-essentials -c r\nAnd when running Jupyter, in the menu to create a new notebook, i can see the choice of my new kernel new --> R [conda env:myrenv] but I also have the choice (among others) of new --> Python [conda env:myrenv]. \nHow can I remove the latter environment from the list? I do not even know why python would be in my R environment.\nAdditional info:\nconda 4.5.11","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":86,"Q_Id":52857461,"Users Score":2,"Answer":"r-essentials comes with python as well as the jupyter_client and the ipykernel packages which enables your jupyter to propose this R and thus the python installed as kernels in a notebook. ipykernel is mandatory for the jupyter to propose the R as a kernel and python is a dependency to ipykernel so...\nI don't think you can remove python from the list of the kernels proposed. If you remove python from the conda environment, it also removes the ipykernel and the jupyter_client packages. All you can do is ignore it.\nEDIT: found more infos\nAfter looking into this since I wanted to do the same thing, it seems jupyter has a nice built-in program to do this:\nRun\njupyter-kernelspec list\nto list all available kernels. Then you can remove one with\njupyter-kernelspec remove <kernel_to_remove>\nif you want to remove the kernel.\nHOWEVER, it seems that you CANNOT remove the python3 kernel. Even though I ran:\njupyter-kernelspec remove python3\npython3 still appears in the list and is still an available kernel in the notebook...","Q_Score":0,"Tags":"python,r,jupyter-notebook,conda","A_Id":52859799,"CreationDate":"2018-10-17T14:35:00.000","Title":"Installing R kernel with conda creates an unwanted addtional python kernel in Jupyter","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pycharm community edition 2017.3 doesn't seem to have a way to Install requirements.txt packages from a project except that it pops up Install link on the top right corner once in a while and even then doesn't install all packages from my requirements.txt. What is the best way to do this?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":844,"Q_Id":52859873,"Users Score":0,"Answer":"I found that the best way to ensure this is to open a terminal in Pycharm. On that terminal, if you run pip install -r requirements.txt, it installs all the dependencies present in that file. After this, if you run Pycharm debugger, it will work and not complain about missing dependencies.","Q_Score":1,"Tags":"python,pycharm,requirements.txt","A_Id":52903463,"CreationDate":"2018-10-17T16:47:00.000","Title":"What is the surest way to get PyCharm to use updated python packages from requirements.txt file in a project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pycharm community edition 2017.3 doesn't seem to have a way to Install requirements.txt packages from a project except that it pops up Install link on the top right corner once in a while and even then doesn't install all packages from my requirements.txt. What is the best way to do this?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":844,"Q_Id":52859873,"Users Score":0,"Answer":"A contemporary way of doing this would be to use pipenv. It doesn't use a requirements.txt file anymore but instead a Pipfile and a Pipfile.lock, but it can read a requirements.txt input file of an existing project.\n\nInstall pipenv globally: pip install pipenv\nAdd your project folder to PyCharm\nSet the project's interpreter to a new pipenv environment by going to \n\n\nFile > Settings > Project: your-project > Project Interpreter\nIn the top right, click the gear icon and click 'Add'\nIn the left sidebar click 'Pipenv Environment'\nSelect the desired Python version\nClick OK\n\nDone! PyCharm will set up a virtual environment, and install packages found in existing requirements.txt or Pipfile files.","Q_Score":1,"Tags":"python,pycharm,requirements.txt","A_Id":52903762,"CreationDate":"2018-10-17T16:47:00.000","Title":"What is the surest way to get PyCharm to use updated python packages from requirements.txt file in a project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Normally in a jupyter notebook I would use %matplotlib notebook magic to display an interactive window, however this doesn't seem to work with google colab. Is there a solution, or is it not possible to display interactive windows in google colab?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":44387,"Q_Id":52859983,"Users Score":1,"Answer":"In addition to @Nilesh Ingle excellent answer, in order to solve the problem of axes and title not displaying :\nyou should change the link https:\/\/cdn.plot.ly\/plotly-1.5.1.min.js?noext (which refers to an older version of plotly, thus not displaying axes labels) by https:\/\/cdn.plot.ly\/plotly-1.5.1.min.js?noext when calling the script in the function configure_plotly_browser_state().\nHope this would help !","Q_Score":50,"Tags":"python,matplotlib,google-colaboratory","A_Id":61304539,"CreationDate":"2018-10-17T16:54:00.000","Title":"Interactive matplotlib figures in Google Colab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use JModelica since many years and now run the current version 2.2. I am interested to share (compiled) FMU-modules and put my name and company into the FMU-module. If your FMU-module have the name model then there is a method model.get_author() that will bring that information. For the FMU-modules I do now I just get a blank result calling this method. How do put in information into my model? Is that possible for the current version of JModelica?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":92,"Q_Id":52860337,"Users Score":2,"Answer":"With the current release of JModelica 2.2, it is not possible for a user to automatically include the author in the generated modelDescription file in the FMU.\nCurrently this has to be done manually by a user (i.e. unzip the FMU, updated the XML, and zip the FMU).","Q_Score":2,"Tags":"python,modelica,fmi,jmodelica","A_Id":52876456,"CreationDate":"2018-10-17T17:16:00.000","Title":"FMU-modules and method get_author()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I used one set of data to learn a Random Forest Regressor and right now I have another dataset with smaller number of features (the subset of the previous set).\nIs there a function which allows to get the list of names of columns used during the training of the Random Forest Regressor model?\nIf not, then is there a function which for the missing columns would assign Nulls?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":52861742,"Users Score":0,"Answer":"Is there a function which allows to get the list of names of columns\n  used during the training of the Random Forest Regressor model?\n\nRF uses all features from your dataset. Each tree may contain sqrt(num_of_features) or log2(num_of_features) or whatever but these columns are selected at random. So usually RF covers all columns from your dataset.\nThere may be edge case when you use a small number of estimators in RF and some features may not be considered. I suppose, RandomForestRegressor.feature_importances_ (zero or nan value may be indicators here) or dive into each tree in RandomForestRegressor.estimators_ may help.\n\nIf not, then is there a function which for the missing columns would\n  assign Nulls?\n\nRF does not accept missing values. Either you need to code missing value as the separate class (and use it for learning too) or XGBoost (for example) is your choice.","Q_Score":0,"Tags":"python,pandas,scikit-learn,random-forest","A_Id":52873525,"CreationDate":"2018-10-17T18:52:00.000","Title":"Getting the list of features used during training of Random Forest Regressor","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I found a limitation of the FMU-module method get_states_list(). This method seems to bring a list only of continuous time states and not of discrete time states. I do usually make models that contain both continuous and discrete time sub-models describing process and control system and I am very interested to be able to get a list of ALL states in the system.\nOne possibility could have been get_fmu_state() but I get the exception text \u201cThis FMU does not support get and set FMU-state\u201d. \nAnother possibility would perhaps be bring out a larger list of all variables using and sort out those variables that contain in the declaration \"fixed=true\u201d, but this attribute I am not sure how to bring out, although other attributes can be brought out like min, max, nominal. The method get_model_variables()  could perhaps be of help but I only get some address associated to the variable\u2026.\nWhat to do?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":153,"Q_Id":52861775,"Users Score":2,"Answer":"The get_states_list method is a mapping back to the FMI specification which only includes the continuous time states. So this is by design.","Q_Score":2,"Tags":"python,fmi,jmodelica","A_Id":52876538,"CreationDate":"2018-10-17T18:53:00.000","Title":"FMU-module method get_states_list()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Assuming I have an excel sheet already open, make some changes in the file and use pd.read_excel to create a dataframe based on that sheet, I understand that the dataframe will only reflect the data in the last saved version of the excel file. I would have to save the sheet first in order for pandas dataframe to take into account the change.\nIs there anyway for pandas or other python packages to read an opened excel file and be able to refresh its data real time (without saving or closing the file)?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1261,"Q_Id":52862768,"Users Score":1,"Answer":"There is no way to do this. The table is not saved to disk, so pandas can not read it from disk.","Q_Score":10,"Tags":"python,excel,pandas","A_Id":72310873,"CreationDate":"2018-10-17T20:03:00.000","Title":"How do I use python pandas to read an already opened excel sheet","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing a python application that calls on some matlab scripts using eng = engine.start_matlab(). This works fine on my local. \nI am trying to deploy using Docker. When I try to build the image, the error is related to matlab not installed. \nIs what I am trying to do possible? Any suggestions are appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":404,"Q_Id":52863836,"Users Score":0,"Answer":"Can you explain what you did to install and verify Matlab in the docket container?\nI think of docker containers as micro VMs, so if the application isn\u2019t in the container it can\u2019t be accessed by other apps in the container. Hope I got that concept right!","Q_Score":0,"Tags":"python,matlab,docker","A_Id":52864576,"CreationDate":"2018-10-17T21:25:00.000","Title":"Python Matlab Engine in Docker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a gazillion CSV files and in column 2 is the x-data and column 3 is the y-data. Each CSV file is a different time stamp. The x-data is slightly different in each file, but the number of rows is constant. I'm happy to assume the x-data is in fact identical.\nI am persuaded that Tableau is a good interface for me to do some visualization and happily installed tabpy and \"voila\", I can call python from Tableau... except...  to return an array I will need to return a string with comma separated values for each time stamp, and then one of those strings per x-axis and then.... Hmm, that doesnt sound right.\nI tried telling Tableau just open them all and I'd join them later, but gave up after 30 mins of it crunching.\nSo what do you reckon? I am completely agnostic. Install an SQL server and create a database? Create a big CSV file that has a time-stamp for each column? Google? JSON?\nOr maybe there is some clever way in Tableau to loop through the CSV files?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1928,"Q_Id":52863882,"Users Score":1,"Answer":"I would suggest doing any data prep outside of Tableau. Since you seem to be familiar with Python, try Pandas to combine all the csv files into one dataframe then output to a database or a single csv. Then connect to that single source.","Q_Score":0,"Tags":"python,csv,tableau-api","A_Id":52864018,"CreationDate":"2018-10-17T21:28:00.000","Title":"Load thousands of CSV files into tableau","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a gazillion CSV files and in column 2 is the x-data and column 3 is the y-data. Each CSV file is a different time stamp. The x-data is slightly different in each file, but the number of rows is constant. I'm happy to assume the x-data is in fact identical.\nI am persuaded that Tableau is a good interface for me to do some visualization and happily installed tabpy and \"voila\", I can call python from Tableau... except...  to return an array I will need to return a string with comma separated values for each time stamp, and then one of those strings per x-axis and then.... Hmm, that doesnt sound right.\nI tried telling Tableau just open them all and I'd join them later, but gave up after 30 mins of it crunching.\nSo what do you reckon? I am completely agnostic. Install an SQL server and create a database? Create a big CSV file that has a time-stamp for each column? Google? JSON?\nOr maybe there is some clever way in Tableau to loop through the CSV files?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1928,"Q_Id":52863882,"Users Score":0,"Answer":"If you are using Windows, you can combine all the csv files into a single csv, then import that into Tableau. This of course assumes that all of your csv files have the same data structure.\n\nOpen the command prompt\nNavigate to the directory where the csv files are (using the cd command)\nUse the command copy *.csv combined-file.csv. The combined-file.csv can be whatever name you want.","Q_Score":0,"Tags":"python,csv,tableau-api","A_Id":52864473,"CreationDate":"2018-10-17T21:28:00.000","Title":"Load thousands of CSV files into tableau","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is a good method for converting an HTML string file to PDF? I am trying to create a simple tool that creates a PDF report using some user inputs and an HTML template. I want to distribute this tool so that other coworkers can use it. \nRight now I am trying to use pdfkit and wkhtmltopdf. The issue is that I can only get this code to work when I specify the path to the wkhtmltopdf.exe file. When I package the code using PyInstaller, other users will not be able to use the program because they do not have the HTML template file or a path to wkhtmltopdf. Any ideas on how to resolve this or are there any alternative python packages\/methods that I should use?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1726,"Q_Id":52864157,"Users Score":1,"Answer":"If you want to package the HTML template in your module and you are using setuptools you can include any other files with a couple of changes: \n\nCreate a file called MANIFEST.in in your base directory of the module \nAdd all of the files you want to include like this: include <path\/to\/file\/in\/module> \nIn setup.py add include_package_data=True to setup()\n\nMaking those changes should allow your module to include your template and allow the other modules to convert it to a PDF. \nIf you are having pathing problems within the module, make sure that you are using absolute paths to reference other files. I would suggest using the builtin os module to build a path which works for any user. For example: os.path.abspath(\"path\/to\/my\/file\")","Q_Score":0,"Tags":"python,html,pyinstaller,wkhtmltopdf,python-pdfkit","A_Id":52864222,"CreationDate":"2018-10-17T21:52:00.000","Title":"Converting HTML to PDF in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Scrapy Crawlera was working just well in my Windows machine, but it gets error 111 when I run it in my linux server. Why is that?\nWhen I use curl, I got this error:\ncurl: (7) Failed connect to proxy.crawlera.com:8010; Connection refused","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2658,"Q_Id":52866297,"Users Score":1,"Answer":"It turned out when dealing with ports, CPanel (or maybe Linux?) blocks ports by default if it is not whitelisted in the firewall. I opened it via WHM since I use CPanel, and everything works fine now.","Q_Score":1,"Tags":"python,web-scraping,scrapy,screen-scraping,crawlera","A_Id":52882604,"CreationDate":"2018-10-18T02:53:00.000","Title":"Connection was refused by other side: 111: Connection refused. when using Scrapy Crawlera in a linux server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a problem with installing numpy with python 3.6 and i have windows 10 64 bit \nPython 3.6.6 \nBut when i typed python on cmd this appears \nPython is not recognized as an internal or external command \nI typed py it solves problem but how can i install numpy \nI tried to type commant set path =c:\/python36 \nAnd copy paste the actual path on cmd but it isnt work \nI tried also to edit the enviromnent path through type a ; and c:\/python 36 and restart but it isnt help this \nI used pip install nupy and download pip but it isnt work","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":52866467,"Users Score":0,"Answer":"Try pip3 install numpy. To install python 3 packages you should use pip3","Q_Score":1,"Tags":"python,numpy,scipy,installation","A_Id":52866580,"CreationDate":"2018-10-18T03:14:00.000","Title":"How can i make computer read a python file instead of py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a problem with installing numpy with python 3.6 and i have windows 10 64 bit \nPython 3.6.6 \nBut when i typed python on cmd this appears \nPython is not recognized as an internal or external command \nI typed py it solves problem but how can i install numpy \nI tried to type commant set path =c:\/python36 \nAnd copy paste the actual path on cmd but it isnt work \nI tried also to edit the enviromnent path through type a ; and c:\/python 36 and restart but it isnt help this \nI used pip install nupy and download pip but it isnt work","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":52866467,"Users Score":0,"Answer":"On Windows, the py command should be able to launch any Python version you have installed. Each Python installation has its own pip. To be sure you get the right one, use py -3.6 -m pip instead of just pip.\n\nYou can use where pip and where pip3 to see which Python's pip they mean. Windows just finds the first one on your path.\n\nIf you activate a virtualenv, then you you should get the right one for the virtualenv while the virtualenv is active.","Q_Score":1,"Tags":"python,numpy,scipy,installation","A_Id":52866587,"CreationDate":"2018-10-18T03:14:00.000","Title":"How can i make computer read a python file instead of py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using the Python Spotify library Spotipy with a Raspberry Pi, and I am wondering why there is a 50 song limit when trying to see the user's saved songs? I have looked at the documentation, but I am still confused on the reason. If you answer this thank you so much.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":196,"Q_Id":52866626,"Users Score":0,"Answer":"They don't expect users to be regularly retrieving all of a user's songs, only a portion of them (and potentially by filtered query). In addition, it could be a waste of data if 100 songs are sent, but the user only ends up using one song. \nFifty is a sensible limit, and there is pagination to allow for accessing more than fifty songs in a series of smaller requests (rather than one large request).","Q_Score":0,"Tags":"python,api,spotify,spotipy","A_Id":52866661,"CreationDate":"2018-10-18T03:34:00.000","Title":"Spotipy- Why is there a 50 song limit when getting saved songs?","Data Science and Machine Learning":0,"Database and SQL":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":"Is there a way in Spyder-ide to copy a file's absolute or relative path or at least file's name from file explorer in Spyder-ide?\nIs it possible also to open multiple file explorers each in a different directory? \nLast question? Can an existing directory be converted into a project?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":832,"Q_Id":52869663,"Users Score":1,"Answer":"(Spyder maintainer here) These are my answers:\n\nIs there a way in Spyder-ide to copy a file's absolute or relative path or at least file's name from file explorer in Spyder-ide?\n\nNot right now, but there's work in progress to implement this for Spyder 4, to be released in 2019.\n\nIs it possible also to open multiple file explorers each in a different directory? \n\nNo, it's not possible. But you can open multiple consoles, each one pointing to a different directory and when you switch among them, you'll see the file explorer view is updated automatically.\n\nCan an existing directory be converted into a project?\n\nNot exactly, but you can create a project in any directory by going to the menu Projects > New project and selecting your directory there.","Q_Score":0,"Tags":"python,spyder","A_Id":52873279,"CreationDate":"2018-10-18T08:11:00.000","Title":"Spyder? Copy file absolute or relative path from file explorer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know how to import and manipulate data from csv, but I always need to save to xlsx or so to see the changes. Is there a way to see 'live changes' as if I am already using Excel? \nPS using pandas\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":52871447,"Users Score":0,"Answer":"This is not possible using pandas. This lib creates copy of your .csv \/ .xls file and stores it in RAM. So all changes are applied to file stored in you memory not on disk.","Q_Score":0,"Tags":"python,pandas","A_Id":52871555,"CreationDate":"2018-10-18T09:53:00.000","Title":"Is it possible to manipulate data from csv without the need for producing a new csv file?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Anaconda3-5.3.0-Windows-x86_64 release and experienced the following problem:\nWhile running import command (e.g. - import numpy as np), from Jupyter notebook,  I receive the following error -\n\nThe ordinal 241 could not be located in the dynamic link library path:\\mkl_intel_thread.dll>\n\nWhere 'path' is the path to anaconda directory in my Win10 PC.\nI tried the following in order to overcome this issue -\n\nReinstall anaconda from scratch\nUpdate the .dll to latest one\nUpdate Win10 path to search the right folders\n\nUnfortunately - non of the above methods worked for me.\nCan someone offer some solution \/ new ideas to check?\nThank you all in advance!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":930,"Q_Id":52871597,"Users Score":1,"Answer":"Eventually, I came to a conclusion that there is a problem with adaptation of this Anaconda version with my Win 8.1.\nSo, I downgraded Anaconda version to Anaconda3-5.2.0-Windows-x86_64 and that solved the issue.","Q_Score":1,"Tags":"python,anaconda,jupyter","A_Id":52928244,"CreationDate":"2018-10-18T10:03:00.000","Title":"Ordinal 241 could not be located","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The linux server that I'm working on has python 2.7.13.\nI created a new environment (new_env) and after running \"source activate new_env\", have installed anaconda3 on it. \nNow still get into spyder with ptython IDE 2.7.13. How I can run spyder with python 3?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":52874911,"Users Score":0,"Answer":"How I can run spyder with python 3?\n\nAfter activating your environment, you just need to execute the following command in the terminal:\nspyder","Q_Score":0,"Tags":"python,linux,environment-variables,anaconda,spyder","A_Id":52876200,"CreationDate":"2018-10-18T13:14:00.000","Title":"How to run spyder 3 in new environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to read e-mail flags Seen, Unseen and restore them as the were before reading e-mail using imaplib in Python?\nI couldn't find yet any information regarding reading these flags but there is plenty of examples setting Seen, Unseen etc. flags. I would appreciate if somebody would guide me to the right direction.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":486,"Q_Id":52875116,"Users Score":1,"Answer":"A big thanks goes to @stovfl and @Max in comments. I  successfully made my program work using imap_conn.fetch(uid, '(BODY.PEEK[HEADER])'). On the other side if somebody needs read-only access they can use imap_conn.select('Inbox', readonly=True)","Q_Score":1,"Tags":"python,email,imaplib","A_Id":53003650,"CreationDate":"2018-10-18T13:24:00.000","Title":"Reading \\Seen, \\Unseen flags using imaplib 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":"How can I select a single column in treeview tkinter, when I try to use the tree.get_children() it only let me chose a item.\nCan somebody help me out ?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":828,"Q_Id":52875351,"Users Score":0,"Answer":"The treeview widget doesn't support selecting data by column. You can only select by row.","Q_Score":0,"Tags":"python,tkinter,treeview","A_Id":52876524,"CreationDate":"2018-10-18T13:37:00.000","Title":"Selecting a single column in treeview tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been asked to provide a list of every behave Feature and Scenario we run as part of our regression pack for a document to an external client (not the steps) \nAs our regression test suite is currently around 50 feature files with at least 10 scenarios in each I would rather not copy and paste manually.  \nIs there a way to export the Feature name and ID and then the name and ID of each scenario that comes under that feature either to a CSV or text file? \nCurrently our behave tests are run locally and I am using PyCharm IDE to edit them in.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1326,"Q_Id":52876099,"Users Score":0,"Answer":"I have found a roundabout way to do this. \nSet Behave to export to an external txt file using the command\noutfiles = test_list\nThen use the behave -d command to run my tests as a dry run. \nThis then populates the txt file with the feature, scenario and step of every test. \nI can export this to Excel and through filtering can isolate the feature and scenario lines removing the steps and then use text to columns to split the feature\/scenario description from its test path\/name. \nIf there is a less roundabout way of doing this it would be good to know as it looks like this is information we will need to be able to provide on a semi regular basis moving forwards.","Q_Score":0,"Tags":"python-behave","A_Id":52890157,"CreationDate":"2018-10-18T14:17:00.000","Title":"Behave print all tests to a 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I append elements to a list that have the following format and type:\ndata.append([float, float, string]) \nThen stack the list using:\ndata = np.hstack(data)\nAnd then finally reshape the array and transpose using:\ndata = np.reshape(data,(-1,3)).T\nAll the array elements in data are changed to strings. I want (and expected) the first and second columns in data to be of type float and the third of type string, but instead they are all of type string. [Interestingly, if I do not append the string elements to data and adjust the newshape to (-1,2), both columns are floats.] I cannot figure this one out. Any help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":397,"Q_Id":52876380,"Users Score":1,"Answer":"Because of the mix of numbers and strings, np.array will use the common format: string. The solution here is to convert data to type object which supports mixed element types. This is performed by using: \ndata = np.array(data, dtype=object)\nprior to hstack.","Q_Score":1,"Tags":"python,arrays,append,reshape","A_Id":52880527,"CreationDate":"2018-10-18T14:31:00.000","Title":"Elements in array change data types from float to string","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I read the following sentence in the TensorFlow documentation:\n\nWith the exception of tf.Variable, the value of a tensor is immutable,\n  which means that in the context of a single execution tensors only\n  have a single value. However, evaluating the same tensor twice can\n  return different values; for example that tensor can be the result of\n  reading data from disk, or generating a random number.\n\nCan someone elaborate a little bit on the \"immutable\" aspect of a Tensor?\n\nWhat is the \"scope of the immutability\" since evaluating a tensor twice could return different results? \nWhat does it mean \"the context of a single execution\"?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2114,"Q_Id":52879126,"Users Score":6,"Answer":"Tensors, differently from variables, can be compared to a math equation.\nWhen you say a tensor equals 2+2, it's value is not actually 4, it's the computing instructions that leads to the value of 2+2 and when you start a session an execute it, TensorFlow runs the computations needed to return the value of 2+2 and gives you the output. And because of the tensor beeing the computations, rather than the the result, a tensor is immutable\nNow for your questions:\n\nBy saying the tensor can be evaluated with different values it means that if you for example say that a tensor equals to a random number, when you run it different times, you will have different values (as the equation itself is a random one), but the value of the tensor itself as mentioned before, is not the value, is the steps that leads to it (in this case a random formula)\nThe context of a single execution means that when you run a tensor, it will only output you one value. Think executing a tensor like applying the equation i mentioned. If i say a tensor equals random + 1, when you execute the tensor a single time, it will return you a random value +1, nothing else. But since the tensor contains a randomic output, if you run it multiple times, you will most likely get different values","Q_Score":4,"Tags":"python,tensorflow","A_Id":52879296,"CreationDate":"2018-10-18T17:03:00.000","Title":"How are tensors immutable in TensorFlow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I read the statements in \"fluent python\"\n\nThe standard library offers a rich selection of sequence types implemented in C:\nContainer sequences list, tuple, and collections.deque can hold items of different types.\nFlat sequences str, bytes, bytearray, memoryview, and array.array hold items of one type.\nContainer sequences hold references to the objects they contain, which may be of any type, while flat sequences physically store the value of each item within its own memory space, and not as distinct objects. Thus, flat sequences are more compact, but they are limited to holding primitive values like characters, bytes, and numbers.\n\nContainer sequences hold references to the objects they contain,\nDoes the references exist as pointers in physical status or a mere imaginary concept to illustrate?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":52884365,"Users Score":2,"Answer":"As a CPython implementation detail, yes, they're all actually C level pointers to structs, where the structs contain the information about the object (including the reference counts, since CPython uses reference counting for memory management).\nSo when you do a = [1], a itself holds a pointer to a list (PyListObject struct to be precise), which holds a pointer to an array of PyObject*s (in a field of PyListObject), and the first element stored in it is a pointer to a PyLongObject (the struct extending the base PyObject which corresponds to the int type at the Python layer on Python 3). Again this is all implementation details, but yes, you do have to spend a pointer's worth of memory to hold each such reference in CPython (unless you're using specially optimized C level containers like array.array, numpy arrays, bytes\/bytearray\/str, or ctypes arrays, which, by virtue of holding specific types, can store them as raw C arrays, without internal pointers to objects for each element).\nThe use of pointers under the hood is likely true in other Python interpreters as well, but there could easily be more layers of wrapping, abstraction, and indirection, to facilitate the needs of the different garbage collection strategies used by each.","Q_Score":1,"Tags":"python,c","A_Id":52884396,"CreationDate":"2018-10-19T00:35:00.000","Title":"Do these \"references\" exist as pointers in physical status or a virtual concept to explain?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that takes in a .csv file and performs some data cleaning and some more advanced operations and gives back a .csv file as its output.\nIs there a library I can use to build a webpage and host it on some server for users to be able to upload the input .csv file into it and be able to download the output .csv file?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":52885542,"Users Score":0,"Answer":"I would say your best choice if you are new to web development, is to start learning Flask and the basics of \"How the Web Works\". There are other libraries such as Django or Cherrypy as well. Flask is a web framework that can run a server side application (a.k.a. back-end) and it's relatively simple out of the box.\nHowever, when you say \"running python script on webpage\" and \"build a webpage\", that's not exactly how it works. You will build your webpage (a.k.a. the client-side application or the front-end) using HTML, CSS and possibly JavaScript. Web browsers can't run python.","Q_Score":0,"Tags":"python","A_Id":52885671,"CreationDate":"2018-10-19T03:34:00.000","Title":"Running python script on webpage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My pyglet application fails to run, only giving the error ImportError: Library \"GLU\" not found. I have installed PyOpenGL and libgl1 across the system, in the virtualenv, and tried reinstalling everything multiple times. Nothing seems to help. Similiar questions mention it may be related to my graphics card, which is Intel Corporation HD Graphics 5500 (rev 09). Anyone have any ideas?\nFurther details\n\nPython version: 3.7\nIDE: Pycharm Community\nOS: elementaryOS v5.0 Juno\nInstallation method: Flatpak\nGraphics Driver: Intel Corporation Broadwell-U Integrated Graphics","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1370,"Q_Id":52885954,"Users Score":1,"Answer":"Don't install pycharm through flatpak, for whatever reason that doesn't work. Install it through the pycharm website.","Q_Score":0,"Tags":"python,opengl,pycharm,pyglet","A_Id":52909744,"CreationDate":"2018-10-19T04:34:00.000","Title":"Pyglet fails to load GLU library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have installed Python 3.7 on my system and I am running one simple python file in which imports a .pyd file. When running the script I got error like:\n\nTraceback (most recent call last):\n        File \"demoTemp\\run.py\", line 1, in \n        from pyddemo import fun\n        ModuleNotFoundError: No module named 'pyddemo'\n\npyddemo is pyd file.\nIs there any dependency for pyd file?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":886,"Q_Id":52886756,"Users Score":0,"Answer":"I found solution of my problem its just mismatch of python version in which I have created pyd and python version in which I am using it.","Q_Score":1,"Tags":"python-3.x","A_Id":52890342,"CreationDate":"2018-10-19T06:12:00.000","Title":"PYD file 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have data frame with a object column lets say col1, which has values likes:\n1.00,\n1,\n0.50,\n1.54\nI want to have the output like the below:\n1,\n1,\n0.5,\n1.54\nbasically, remove zeros after decimal values if it does not have any digit after zero. Please note that i need answer for dataframe. pd.set_option and round don't work for me.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5418,"Q_Id":52889130,"Users Score":0,"Answer":"A quick-and-dirty solution is to use \"%g\" % value, which will convert floats 1.5 to 1.5 but 1.0 to 1 and so on. The negative side-effect is that large numbers will be represented in scientific notation like 4.44e+07.","Q_Score":2,"Tags":"python,pandas","A_Id":52889192,"CreationDate":"2018-10-19T09:04:00.000","Title":"how to remove zeros after decimal from string remove all zero after dot","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is related to new features Visual Studio has introduced - Python support, Machine Learning projects to support.\nI have installed support and found that I can create a python project and can run it. However, I could not find how to call a python function from another C# file.\nExample, I created a classifier.py from given project samples, Now I want to run the classifier and get results from another C# class.\nIf there is no such portability, then how is it different from creating a C# Process class object and running the Python.exe with our py file as a parameter.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":632,"Q_Id":52890639,"Users Score":0,"Answer":"As per the comments, python support has come in visual studio. Visual studio is supporting running python scripts and debugging. \nHowever, calling one python function from c# function and vice versa is not supported yet.\nClosing the thread. Thanks for suggestions.","Q_Score":1,"Tags":"c#,python,visual-studio","A_Id":52965599,"CreationDate":"2018-10-19T10:34:00.000","Title":"Call Python functions from C# in Visual Studio Python support VS 2017","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a very amateur programmer, and I want to make an array full of 0s, that is the length of a number.\nHow do I do that?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":52890943,"Users Score":0,"Answer":"here is how you can do that \ni=7;\narr=[0]*i;","Q_Score":0,"Tags":"python,python-3.x","A_Id":52903171,"CreationDate":"2018-10-19T10:52:00.000","Title":"How do I set an array to the length of a number?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a multibranch pipeline set up in Jenkins that runs a Jenkinsfile, which uses pytest for testing scripts, and outputs the results using Cobertura plug-in and checks code quality with Pylint and Warnings plug-in.\nI would like to test the code with Python 2 and Python 3 using virtualenv, but I do not know how to perform this in the Jenkinsfile, and Shining Panda plug-in will not work for multibranch pipelines (as far as I know). Any help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1383,"Q_Id":52890995,"Users Score":1,"Answer":"You can do it even using vanilla Jenkins (without any plugins). 'Biggest' problem will be with proper parametrization. But let's start from the beginning.\n2 versions of Python\nWhen you install 2 versions of python on a single machine you will have 2 different exec files. For python2 you will have python and for python3 you will have python3. Even when you create virtualenv (use venv) you will have both of them. So you are able to run unittests agains both versions of python. It's just a matter of executing proper command from batch\/bash script.\nJenkins\nThere are many ways of performing it:\n\nyou can prepare separate jobs for both python 2 and 3 versions of tests and run them from jenkins file\nyou can define the whole pipeline in a single jenkins file where each python test is a different stage (they can be run one after another or concurrently)","Q_Score":2,"Tags":"python,jenkins,github,continuous-integration,jenkins-pipeline","A_Id":52892540,"CreationDate":"2018-10-19T10:55:00.000","Title":"Running Jenkinsfile with multiple Python 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":1,"Web Development":0},{"Question":"I have Installed Anaconda3 (64bit) and I already have a Python 2.7 Installation on the default path (Windows 10). When I start the python.exe from the new Anaconda Installation, I cannot import numpy, as it fails to load multiarray.\nIs it possible to have different python istallation at the same time? If yes, how can I prevent python from loading old files \/ modules and only import from the current environment?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":529,"Q_Id":52892033,"Users Score":0,"Answer":"I solved this problem after all. After reinstalling the module I discovered that\nconda uninstall\nleaves a version of numpy behind. conda install would always install two versions, one hidden in the file explorer. I deleted both using conda remove AND pip removeand reinstalled numpy using pip install numpy (instead of using conda) and it finally solved my issues!","Q_Score":1,"Tags":"python,numpy,anaconda","A_Id":52931262,"CreationDate":"2018-10-19T12:06:00.000","Title":"Anaconda3 with existing Python Installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been working extensively with peewee and postgresql for months.  Suddenly this started happening.  If I run any query command and get an error, then all subsequent commands start returning peewee.InternalError: current transaction is aborted, commands ignored until end of transaction block .\nI thought this behavior started when I upgraded peewee from 3.5.2 to 3.7.2, but I have since downgraded and the behavior continues.  This has definitely not always happened.\nIn the simplest case, I have a database table with exactly one record.  I try to create a new record with the same id and I get an IntegrityError as expected.  If I then try to run any other query commands on that database, I get the InternalError as above.\nThis does not happen with an sqlite database.\nI have reinstalled peewee and psycopg2, to no avail.\nWhat am I missing?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1611,"Q_Id":52899051,"Users Score":1,"Answer":"While it's fine to use autorollback, it's much better to explicitly manage your transactions so that where an integrity error might occur you are catching the error and explicitly rolling back. For instance, if you have a user signup page and there's a unique constraint on the username, you might wrap it in a try\/except and rollback upon failure.","Q_Score":4,"Tags":"python,postgresql,peewee","A_Id":52916016,"CreationDate":"2018-10-19T19:51:00.000","Title":"Why am I getting peewee.InternalError for all subsequent commands after one failed command, using peewee ORM with posgresql?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to perform some operations in my application when any new listed process starts or stops in Windows OS.\nI read subprocess module, but didn't get a clue.\nCan any one knows which method is called when new process is started, or how I can override which os module method to achieve my goal.\nPlease help me to resolve it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":52899460,"Users Score":0,"Answer":"The best way to do this is to store all the processes at the beginning of the program using some sort of Array.  Have a thread that constantly checks for changes inside the array.  If it detects a change send \"an interrupt\" into the main process.","Q_Score":0,"Tags":"python,python-3.x,windows,operating-system","A_Id":52900165,"CreationDate":"2018-10-19T20:25:00.000","Title":"How to get any new process start and stop in OS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to learn how to use matplotlib to start replacing Matlab in my life, but I'm having trouble getting started. I added python and pip to my path so i could pip install matplotlib from my command prompt, and I see it's installed in my python\\lib\\site-packages file, but when I type in \"import matplotlib.pyplot as plt\" to get started and run the rest of my simple plot code, pycharm says that there is no module named matplotlib. My plot code runs fine on the shell, copied and pasted from the same stuff I'm trying to run in pycharm however. What do I need to do to go this to run in pycharm as well?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":102,"Q_Id":52901686,"Users Score":1,"Answer":"Pycharm can select between many different python installations on your system, it sounds like you have selected a version different from the one in which you installed matplotlib.  You probably installed matplotlib with pip.  Check which pip you used by putting which pip if you're under *nix. then check which one Pycharm is using in your project.","Q_Score":0,"Tags":"python,pycharm","A_Id":52901816,"CreationDate":"2018-10-20T01:31:00.000","Title":"Getting started with Matplotlib","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to track a moving deformable object in a video (but only 2D space). How do I find the paths (subpaths) revisited by the object in the span of its whole trajectory? For instance, if the object traced a path, p0-p1-p2-...-p10, I want to find the number of cases the object traced either p0-...-p10 or a sub-path like p3-p4-p5. Here, p0,p1,...,p10 represent object positions (in (x,y) pixel coordinates at the respective instants). Also, how do I know at which frame(s) these paths (subpaths) are being revisited?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":52901800,"Users Score":0,"Answer":"I would first create a detection procedure that outputs a list of points visited along with their video frame number. Then use list exploration functions to know how many redundant suites are found and where.\nAs you see I don't write your code. If you need anymore advise please ask!","Q_Score":1,"Tags":"python,python-2.7,video-tracking","A_Id":52943459,"CreationDate":"2018-10-20T01:58:00.000","Title":"How to find redundant paths (subpaths) in the trajectory of a moving object?","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 got a requirement to parse the message files in .txt format real time as and when they arrive in incoming windows directory. The directory is in my local Windows Virtual Machine something like D:\/MessageFiles\/\nI wrote a Python script to parse the message files because it's a fixed width file and it parses all the files in the directory and generates the output. Once the files are successfully parsed, it will be moved to archive directory. Now, i would like to make this script run continuously so that it looks for the incoming message files in the directory D:\/MessageFiles\/ and perform the processing as and when it sees the new files in the path. \nCan someone please let me know how to do this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2288,"Q_Id":52906106,"Users Score":3,"Answer":"There are a few ways to do this, it depends on how fast you need it to archive the files.\nIf the frequency is low, for example every hour, you can try to use windows task scheduler to run the python script.\nIf we are talking high frequency, or you really want a python script running 24\/7, you could put it in a while loop and at the end of the loop do time.sleep()\nIf you go with this, I would recommend not blindly parsing the entire directory on every run, but instead finding a way to check whether new files have been added to the directory (such as the amount of files perhaps, or the total size). And then if there is a fluctuation you can archive.","Q_Score":2,"Tags":"python,python-3.x","A_Id":52906144,"CreationDate":"2018-10-20T13:20:00.000","Title":"Python - How to run script continuously to look for files in Windows directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am tryint to learn a module that I would like to have the UML diagrams for it\nSome of the classes are in binary format (.so) \nWill pyreverse work in this case ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":52906643,"Users Score":0,"Answer":"I have just tried and it does not work\nIt stops when it runs into the so files....","Q_Score":0,"Tags":"python,uml,pyreverse","A_Id":52906685,"CreationDate":"2018-10-20T14:20:00.000","Title":"Does pyreverse work when some of the modules are provided in Cyton format ?(*.so files)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am forced to work on windows and I need to install pyomo. Seems like anaconda is the way to do that. I installed the package via conda install and conda list also shows me that it's installed. But when I run jupyter notebook via the anaconda screen the pyomo package is not in the environment and the error 'module not found' occurs. \nWhat am I missing here when I install packages?\nthanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":980,"Q_Id":52906969,"Users Score":0,"Answer":"I installed everything with miniconda and then chose in the menu up left of the anaconda sceen the miniconda3 environment. Did the trick.","Q_Score":2,"Tags":"python,anaconda,conda,environment,pyomo","A_Id":52907082,"CreationDate":"2018-10-20T14:59:00.000","Title":"Conda list shows python package but error 'module not found' occurs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm confused on how the PyOpenGL camera works or how to implement it. Am I meant to rotate and move the whole world around the camera or is there a different way?\nI couldn't find anything that can help me and I don't know how to translate C to python.\nI just need a way to transform the camera that can help me understand how it works.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":362,"Q_Id":52907020,"Users Score":3,"Answer":"To say it bluntly: There is no such thing as a \"camera\" in OpenGL (neither there is in DirectX, or Vulkan, or in any of the legacy 3D graphics APIs). The effects of a camera is understood as some parameter that contributes to the ultimate placement of geometry inside the viewport volume.\nThe sooner you understand that all that current GPUs do is offering massively accelerated computational resources to set the values of pixels in a 2D grid, where the region of the pixels changed are mere points, lines or triangles on a 2D plane onto which they are projected from an arbitrarily dimensioned, abstract space, the better.\nYou're not even moving around the world around the camera. Setting up transformations is actually errecting the stage in which \"the world\" will appear in the first place. Any notion of a \"camera\" is an abstraction created by a higher level framework, like  a third party 3D engine or your own creation.\nSo instead of thinking in terms of a camera, which constrains your thinking, you should think about it this way:\nWhat kind of transformations do I have to chain up, to give a tuple of numbers that are called \"position\" an actual meaning, by letting this position turn up at a certain place on the visible screen?\nYou really ought to think that way, because that is what's actually happening.","Q_Score":0,"Tags":"python,opengl,pyopengl","A_Id":52907433,"CreationDate":"2018-10-20T15:04:00.000","Title":"PyOpenGL camera system","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a script (Script #1) that writes a file that can only be read once globally, and then another script (Script #2) that reads this file only if it was never read before in the world.\nExample Situation:\nI create a CSV file with my Script #1 and email this CSV file to 10 people, who are on different computers.\nAll 10 try to run this file with my Script #2:\nExpected behaviour:\nThe first person in the world to run Script #2 with this file gets a message saying they are the first person to read this file and can actually see the content.\n2nd -10th person that try to read the file get a message saying someone has already read it before and can't access the file.\nHow can I accomplish this?\nThis is not something very serious, so I'm not really worried about security of the process, but want it to work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":232,"Q_Id":52908310,"Users Score":0,"Answer":"Not Giving the whole process because it will be a large explanation but you can do the below mention points\n\nEncrypt the file first.\nSecond the script which you want to read the content of your file must be linked with a server application from which it will receive decryption key and send data to server about whether the file is read before or not. It's like if the file readed earlier then the server don't send the decryption key.\nThen after receiving the key the script should decrypt the file and read it.","Q_Score":0,"Tags":"python,file,csv,encryption","A_Id":52911860,"CreationDate":"2018-10-20T17:32:00.000","Title":"How to ensure that globally a file can be read only once by 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":"Trying to install a package on Windows fails, as it requires a site.cfg file to contain the path of a library.\nIt looks like pip extracts packages to c:\\users\\[username]\\appdata\\local\\temp\\pip-install-[random string]\\ during installation and deletes after installation (successful or not), so I can't \"hot-edit\" it.\nCan I make pip wait for me before installing?\nCan I make pip download and unpack the package and afterwards tell it to install a package from a directory rather than a package name or URL?\nFeel free to comment alternative solutions for installing scikits.audiolab on Windows (demands sndfile to be defined in site.cfg).","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":714,"Q_Id":52909079,"Users Score":1,"Answer":"Does not work on wheels (see @hoefling comment)\n\nDownload package from url (pip tells you the url when you do pip install <package_name>)\nUntar the file and do your modifications\nThen do pip install <path_of_package>","Q_Score":0,"Tags":"python,windows,pip","A_Id":52909243,"CreationDate":"2018-10-20T18:56:00.000","Title":"How to modify package before installing it with pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with ros on ubuntu 16.04. Because of this I am working with a virtual environment for python 2.7 and the ros python modules (rospy for example). The \"python.pythonPath\" is set to the virtual environment and the ros modules are linked through \"python.autoComplete.extraPaths\".\nThis leads to the issue where the python linter raises an error for import rospy claiming that it can not import it. However, the python intellisense is still able detect and help with the rospy module (which makes sense due to the python.autoComplete.extraPaths setting). \nIs there a way to include the extra paths for autoComplete for the linter as well? At this point, no longer including the virtual environment for the python path is not a desirable option so I am looking for a way to have the linter include the extra paths for ros python modules and the modules in the virtual environment.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":956,"Q_Id":52911986,"Users Score":0,"Answer":"It depends on the linter, but you can pass extra arguments to linters through your settings if the linter supports a way to pass extra directories, e.g. python.linting.flake8Args.","Q_Score":0,"Tags":"python,visual-studio-code,intellisense,pylint","A_Id":52957581,"CreationDate":"2018-10-21T03:55:00.000","Title":"Difficulty including the extra intellisense paths in the python linter's scope","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have data that contains English text messages.\nI want to detect messages that are \"written in English letters\", but aren't English words. (For example with codes based rules, but I don't want to hard coded the rules).\nPlease note that the computer being used does not have an active internet connection (so I cannot check against online dictionary).\nExample Data\n\n\"hello how are you\"\n\"fjrio kjfdelf ejfe\" <-- code (let's say is means \"how are you\" in spanish)\n\"i am fine thanks\"\n\"10x man\"\n\"jfrojf feoif\" <-- code (let's say it means \"hello world\" in japanish)\n\nI'm new to machine learning, so for my understanding, maybe one approach could \nbe using nlp?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":440,"Q_Id":52912553,"Users Score":1,"Answer":"Character frequency scanning is one way to do this.\nFor example for each language obtain a list of character frequencies,\nA: 3%\nB: 1%\nC: 0.5%\nD: 0.7%\nE: 4%\netc..\nThen evaluate your string's character frequency against your static map. You can obtain a probabilistic model of the likelihood of the string being one of your languages.\nOf course this works best for longer strings where there is enough statistical data to capture the true frequency. You would also need to train your frequencies on samples from your target source, e.g. English tweets likely have a different letter frequency to works of Shakespeare. \nAnother option is to find the most likely n-grams in a language, e.g, 'we' is a common 2-gram in english. If you scan your code for how often these most likely n-grams occur you can generally detect if something is in a specific language or not.\nI'm sure there are also other ideas or combinations of classifiers, but this gives you a start. Don't underestimate the power of an ensemble of classifiers either. For example suppose you came up with 3 different models that were all different and uncorrelated, and say each model could detect english correctly 3 times out of 4 (75%). If you then used all 3 models with an equally weighted vote, so if 3 of 3 or 2 of 3 voted english it was classed as english then your error improves to about 3.4 times correct from 4 (85%) (=0.75^3 + 3*0.75^2*0.25)","Q_Score":1,"Tags":"python,tensorflow,machine-learning","A_Id":52912811,"CreationDate":"2018-10-21T06:05:00.000","Title":"How To Detect English Language Words Using Machine Learning From Data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using pycharm community edition for learning. and I need to change the project interpreter to 2.7. I have linux ubuntu 18.04 and I downloaded and installed python 2.7.15, but I just can't find the interpreter. Can anyone help with finding it? thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":345,"Q_Id":52913214,"Users Score":2,"Answer":"File | Settings | Project Interpreter \nthen click on show all to find the desired version \nyou can also click on the existing python version then edit it to select the python version in your \/user\/bin  manually","Q_Score":1,"Tags":"python,linux,ubuntu,pycharm,gae-python27","A_Id":52913277,"CreationDate":"2018-10-21T07:56:00.000","Title":"Can't Change Jetbrains Pycharm python interpreter from 3.6 to 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I install my python modules via pip for my Azure Web Apps. But some of python libraries that I need are only available in conda. I have been trying to install anaconda on Azure Web Apps (windows\/linux), no success so far. Any suggestions\/examples on how to use conda env on azure web apps?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":923,"Q_Id":52915651,"Users Score":1,"Answer":"Currently, Azure App Service only supports the official Python to be installed as extensions. Instead of using the normal App Service, I would suggest you to use a Webapp for Container so that you can deploy your web app as a docker container. I suppose this is the only solution until Microsoft supports Anaconda on App Service.","Q_Score":1,"Tags":"python,azure,anaconda,virtualenv,azure-web-app-service","A_Id":53827502,"CreationDate":"2018-10-21T13:11:00.000","Title":"Anaconda Installation on Azure Web App Services","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently working on a Python tweet analyser and part of this will be to count common words. I have seen a number of tutorials on how to do this, and most tokenize the strings of text before further analysis.\nSurely it would be easier to avoid this stage of preprocessing and count the words directly from the string - so why do this?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":52916729,"Users Score":1,"Answer":"Perhaps I'm being overly correct, but doesn't tokenization simply refer to splitting up the input stream (of characters, in this case) based on delimiters to receive whatever is regarded as a \"token\"?\nYour tokens can be arbitrary: you can perform analysis on the word level where your tokens are words and the delimiter is any space or punctuation character. It's just as likely that you analyse n-grams, where your tokens correspond to a group of words and delimiting is done e.g. by sliding a window.\nSo in short, in order to analyse words in a stream of text, you need to tokenize to receive \"raw\" words to operate on.\nTokenization however is often followed by stemming and lemmatization to reduce noise. This becomes quite clear when thinking about sentiment analysis: if you see the tokens happy, happily and happiness, do you want to treat them each separately, or wouldn't you rather combine them to three instances of happy to better convey a stronger notion of \"being happy\"?","Q_Score":2,"Tags":"python,nltk,tweepy,analysis","A_Id":52917230,"CreationDate":"2018-10-21T15:08:00.000","Title":"Why tokenize\/preprocess words for language analysis?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on a Python tweet analyser and part of this will be to count common words. I have seen a number of tutorials on how to do this, and most tokenize the strings of text before further analysis.\nSurely it would be easier to avoid this stage of preprocessing and count the words directly from the string - so why do this?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":52916729,"Users Score":0,"Answer":"Tokenization is an easy way of understanding the lexicon\/vocabulary in text processing.\nA basic first step in analyzing language or patterns in text is to remove symbols\/punctuations and stop words. With tokenization you are able to split the large chunks of text to identify and remove text which might not add value, in many cases, stop words like 'the','a','and', etc do not add much value in identifying words of interest.\nWord frequencies are also very common in understanding the usage of words in text, Google's Ngram allows for language analysis and plots out the popularity\/frequency of a word over the years. If you do not tokenize or split the strings, you will not have a basis to count the words that appear in a text.\nTokenization also allows you to run a more advanced analysis, for example tagging the part of speech or assigning sentiments to certain words. Also for machine learning, texts are mostly preprocessed to convert them to arrays which are used in te different layers of neural networks. Without tokenizing, the inputs will all be too distinct to run any analysis on.","Q_Score":2,"Tags":"python,nltk,tweepy,analysis","A_Id":52917506,"CreationDate":"2018-10-21T15:08:00.000","Title":"Why tokenize\/preprocess words for language analysis?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using VSCode Version 1.28.2 (1.28.2). When I use the integrated debugger, I find that the F11 key (whose purpose is to step into a function) does not override the MacOS (Sierra 10.12.6) default behaviour (show Desktop). I'm currently bypassing the issue by disabling the shortcut on my Mac, but this seems like a sub-par fix. Is there a better way?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":283,"Q_Id":52920449,"Users Score":0,"Answer":"For MacOS:\nGo to System Preferences -> Keyboard -> Shortcuts and uncheck the \"Show Desktop F11\" option inside one of the submenus (Mission Control).\nThis worked for me on\nCatalina 10.15.7","Q_Score":0,"Tags":"python,macos,debugging,visual-studio-code,keyboard-shortcuts","A_Id":71416917,"CreationDate":"2018-10-21T22:24:00.000","Title":"MacOS keybindings not overriden inside VS Code debugger?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using VSCode Version 1.28.2 (1.28.2). When I use the integrated debugger, I find that the F11 key (whose purpose is to step into a function) does not override the MacOS (Sierra 10.12.6) default behaviour (show Desktop). I'm currently bypassing the issue by disabling the shortcut on my Mac, but this seems like a sub-par fix. Is there a better way?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":283,"Q_Id":52920449,"Users Score":1,"Answer":"Hold down the fn key when you press F11 and it will then act as F11 and not \"Show Desktop\".","Q_Score":0,"Tags":"python,macos,debugging,visual-studio-code,keyboard-shortcuts","A_Id":52938090,"CreationDate":"2018-10-21T22:24:00.000","Title":"MacOS keybindings not overriden inside VS Code debugger?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Traceback (most recent call last):\n  File \"\/usr\/bin\/xattr-2.7\", line 7, in <module>\n    from pkg_resources import load_entry_point\nImportError: No module named pkg_resources\nMy PYTHONPATH contains \/usr\/local\/lib\/python3.7\/site-packages, the site-packages folder indeed contains the pkg_resources folder. I tried everything and have spent hours searching stack overflow. I even reinstalled python and setuptools, but nothing seems to work.\nThe command I am using to install Java - brew cask install java","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":181,"Q_Id":52920484,"Users Score":0,"Answer":"I guess I was so lost trying to install it with brew, that I forgot that I could download the dmg file from the Oracle website and install it. I still can't figure out the issue with pkg_resources though.","Q_Score":0,"Tags":"python,homebrew,homebrew-cask","A_Id":52921018,"CreationDate":"2018-10-21T22:30:00.000","Title":"pkg_resources not found while installing java on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a huge number of 128-bit unsigned integers that need to be sorted for analysis (around a trillion of them!).\nThe research I have done on 128-bit integers has led me down a bit of a blind alley, numpy doesn't seem to fully support them and the internal sorting functions are memory intensive (using lists).\nWhat I'd like to do is load, for example, a billion 128-bit unsigned integers into memory (16GB if just binary data) and sort them. The machine in question has 48GB of RAM so should be OK to use 32GB for the operation. If it has to be done in smaller chunks that's OK, but doing as large a chunk as possible would be better. Is there a sorting algorithm that Python has which can take such data without requiring a huge overhead? \nI can sort 128-bit integers using the .sort method for lists, and it works, but it can't scale to the level that I need. I do have a C++ version that was custom written to do this and works incredibly quickly, but I would like to replicate it in Python to accelerate development time (and I didn't write the C++ and I'm not used to that language).\nApologies if there's more information required to describe the problem, please ask anything.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1852,"Q_Id":52920727,"Users Score":0,"Answer":"I was probably expecting too much from Python, but I'm not disappointed. A few minutes of coding allowed me to create something (using built-in lists) that can process the sorting a hundred million uint128 items on an 8GB laptop in a couple of minutes.\nGiven a large number of items to be sorted (1 trillion), it's clear that putting them into smaller bins\/files upon creation makes more sense than looking to sort huge numbers in memory. The potential issues created by appending data to thousands of files in 1MB chunks (fragmentation on spinning disks) are less of a worry due to the sorting of each of these fragmented files creating a sequential file that will be read many times (the fragmented file is written once and read once).\nThe benefits of development speed of Python seem to outweigh the performance hit versus C\/C++, especially since the sorting happens only once.","Q_Score":0,"Tags":"python,sorting,numpy,int128","A_Id":52934432,"CreationDate":"2018-10-21T23:20:00.000","Title":"How can I sort 128 bit unsigned integers in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Since FMI version 2.0 we have methods: get_variable_unit() and get_variable_display_unit() that brings the information from the Modelica code for the FMU-module. What I can see there is no impact on what you obtain from get_variable_data() from the FUM-module on the results from a simulation. \nIs there any python-package today that facilitate consistent handling of units in diagrams showing simulated data with JModelica, similar to what you get in for instance OpenModelica in the graphical user interface there?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":52923501,"Users Score":0,"Answer":"My contact at Modelon says that they welcome third party to contribute here. Perhaps more interesting now to do since PyFMI is on GitHub since end of 2019.","Q_Score":1,"Tags":"python,fmi,jmodelica","A_Id":60427611,"CreationDate":"2018-10-22T06:32:00.000","Title":"FMU-module method get_variable_unit() and more","Data Science and Machine Learning":0,"Database and SQL":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 pickled a model and want to expose only the prediction api written in Flask. However when I write a dockerfile to make a image without sklearn in it, I get an error ModuleNotFoundError: No module named 'sklearn.xxxx' where xxx refers to sklearn's ML algorithm classes, at the point where I am loading the model using pickle like classifier = pickle.load(f).  \nWhen I rewrite the dockerfile to make an image that has sklearn too, then I don't get the error even though in the API I never import sklearn.\nMy concept of pickling is very simple, that it will serialize the classifier class with all of its data. So when we unpickle it, since the classifier class already has a predict attribute, we can just call it. Why do I need to have sklearn in the environment?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1171,"Q_Id":52929649,"Users Score":0,"Answer":"The pickle is just the representation of the data inside the model. You still need the code to use it, that's why you need to have sklearn inside the container.","Q_Score":3,"Tags":"python,python-3.x,docker,scikit-learn,pickle","A_Id":52929724,"CreationDate":"2018-10-22T12:42:00.000","Title":"Why do I need sklearn in docker container if I already have the model as a pickle?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I pickled a model and want to expose only the prediction api written in Flask. However when I write a dockerfile to make a image without sklearn in it, I get an error ModuleNotFoundError: No module named 'sklearn.xxxx' where xxx refers to sklearn's ML algorithm classes, at the point where I am loading the model using pickle like classifier = pickle.load(f).  \nWhen I rewrite the dockerfile to make an image that has sklearn too, then I don't get the error even though in the API I never import sklearn.\nMy concept of pickling is very simple, that it will serialize the classifier class with all of its data. So when we unpickle it, since the classifier class already has a predict attribute, we can just call it. Why do I need to have sklearn in the environment?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1171,"Q_Id":52929649,"Users Score":1,"Answer":"You have a misconception of how pickle works.\nIt does not seralize anything, except of instance state (__dict__ by default, or custom implementation). When unpickling, it just tries to create instance of corresponding class (here goes your import error) and set pickled state.\nThere's a reason for this: you don't know beforehand what methods will be used after load, so you can not pickle implementation. In addition to this, in pickle time you can not build some AST to see what methods\/modules will be needed after deserializing, and main reason for this is dynamic nature of python \u2014 your implementation can actually vary depending on input.\nAfter all, even assuming that theoretically we'd have smart self-contained pickle serialization, it will be actual model + sklearn in single file, with no proper way to manage it.","Q_Score":3,"Tags":"python,python-3.x,docker,scikit-learn,pickle","A_Id":52929910,"CreationDate":"2018-10-22T12:42:00.000","Title":"Why do I need sklearn in docker container if I already have the model as a pickle?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to connect MongoDB from Atlas.\nMy mongo uri is: mongodb+srv:\/\/abc:123@something.something.com\/admin?retryWrites=True\nMy pymongo version is 3.6.1\nI have installed dnspython and done import dns\nBut i still get this error:\n\ndnspython module must be installed to use mongodb+srv:\/\/ URI","AnswerCount":10,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":69143,"Q_Id":52930341,"Users Score":19,"Answer":"I solved this problem with:\n$ python -m pip install pymongo[srv]","Q_Score":70,"Tags":"python,mongodb,pymongo","A_Id":57184519,"CreationDate":"2018-10-22T13:15:00.000","Title":"pymongo - \"dnspython\" module must be installed to use mongodb+srv:\/\/ URIs","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to connect MongoDB from Atlas.\nMy mongo uri is: mongodb+srv:\/\/abc:123@something.something.com\/admin?retryWrites=True\nMy pymongo version is 3.6.1\nI have installed dnspython and done import dns\nBut i still get this error:\n\ndnspython module must be installed to use mongodb+srv:\/\/ URI","AnswerCount":10,"Available Count":5,"Score":0.0798297691,"is_accepted":false,"ViewCount":69143,"Q_Id":52930341,"Users Score":4,"Answer":"you can use mongo:\/\/ instead of mongodb+srv:\/\/","Q_Score":70,"Tags":"python,mongodb,pymongo","A_Id":58155698,"CreationDate":"2018-10-22T13:15:00.000","Title":"pymongo - \"dnspython\" module must be installed to use mongodb+srv:\/\/ URIs","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to connect MongoDB from Atlas.\nMy mongo uri is: mongodb+srv:\/\/abc:123@something.something.com\/admin?retryWrites=True\nMy pymongo version is 3.6.1\nI have installed dnspython and done import dns\nBut i still get this error:\n\ndnspython module must be installed to use mongodb+srv:\/\/ URI","AnswerCount":10,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":69143,"Q_Id":52930341,"Users Score":10,"Answer":"I got stuck with the same problem and tried\npip install dnspython==2.0.0\nThis is the latest version from https:\/\/pypi.org\/project\/dnspython\/\nIt worked :D","Q_Score":70,"Tags":"python,mongodb,pymongo","A_Id":63568124,"CreationDate":"2018-10-22T13:15:00.000","Title":"pymongo - \"dnspython\" module must be installed to use mongodb+srv:\/\/ URIs","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to connect MongoDB from Atlas.\nMy mongo uri is: mongodb+srv:\/\/abc:123@something.something.com\/admin?retryWrites=True\nMy pymongo version is 3.6.1\nI have installed dnspython and done import dns\nBut i still get this error:\n\ndnspython module must be installed to use mongodb+srv:\/\/ URI","AnswerCount":10,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":69143,"Q_Id":52930341,"Users Score":0,"Answer":"May be the protocol, your URI should start with:\nmongo+srv instead of mongo+src\nIf it still not working please put a pip list with the versions of PyMongo and dnspython (and version of python that you are using)","Q_Score":70,"Tags":"python,mongodb,pymongo","A_Id":53311044,"CreationDate":"2018-10-22T13:15:00.000","Title":"pymongo - \"dnspython\" module must be installed to use mongodb+srv:\/\/ URIs","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to connect MongoDB from Atlas.\nMy mongo uri is: mongodb+srv:\/\/abc:123@something.something.com\/admin?retryWrites=True\nMy pymongo version is 3.6.1\nI have installed dnspython and done import dns\nBut i still get this error:\n\ndnspython module must be installed to use mongodb+srv:\/\/ URI","AnswerCount":10,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":69143,"Q_Id":52930341,"Users Score":18,"Answer":"I would like to answer my own questions here. As I mentioned in the comment, the kernel of the jupyter notebook has to be restarted in order for the pymongo to take effect of the loaded dnspython.","Q_Score":70,"Tags":"python,mongodb,pymongo","A_Id":53644925,"CreationDate":"2018-10-22T13:15:00.000","Title":"pymongo - \"dnspython\" module must be installed to use mongodb+srv:\/\/ URIs","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"There is a software which writes\/appends some log files. I wrote a Python script to read those log files and copy the info in another file. \nHow can I make sure that the Python script won't interrupt the softwares process or that the Python script won't crush when trying to access the files?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":774,"Q_Id":52930866,"Users Score":0,"Answer":"Open your file in read only r mode otherwise the if you try to open it in other mode they the chances of Python interrupting the process will depends on the OS and that software which is using that file.","Q_Score":0,"Tags":"python,file,logging,multiple-users","A_Id":52931463,"CreationDate":"2018-10-22T13:41:00.000","Title":"Open\/Read a file which is already in use. Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset with 53 independent variables (X) and 1 dependent (Y).\nThe dependent variable is a boolean (either 1 or 0), while the independent set is made of both continuous and discrete variables. \nI was planning to use pandas.DataFrame.corr() to list the most influencing variables for the output Y. \ncorr can be:\n\npearson regression\nkendall regression\nspearman regression\n\nI get different results for 3 approaches.\nDo you have suggestions on which one would be the most suitable given the shape (discrete+continuos) of the dataset?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":339,"Q_Id":52932510,"Users Score":0,"Answer":"Correlation is used only for numeric data, discrete \/ binary data need to be treated differently. Have a look at Phi coefficient for binary.\nAs for correlation coefficient (for numeric data), it depends on the relationship between the variables. If these are linear then Pearson is preferred, otherwise Spearman (or something else).","Q_Score":0,"Tags":"python,regression","A_Id":52942231,"CreationDate":"2018-10-22T15:08:00.000","Title":"python - multivariate regression with discrete and continuous","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using grid search to optimize the hyper-parameters of a Random Forest fit on a balanced data set, and I am struggling with which model evaluation metric to choose. Given the real-world context of this problem, false negatives are more costly than false positives. I initially tried optimizing recall but I was ending up with extremely high numbers of false positives. My solution is to instead optimize an f-beta score with beta > 1. My question is, how best to choose beta? If I can calculate the cost of a false negative and false positive, can I set beta = Cost of False Negative\/Cost of False Positive? Does this approach make sense?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1826,"Q_Id":52934864,"Users Score":1,"Answer":"To give more weight to the Precision, we pick a Beta value in the\ninterval 0 < Beta < 1 \nTo give more weight to the Recall, we pick a Beta Value in the interval 1 < Beta\n\nWhen you set beta = Cost of False Negative\/Cost of False Positive then you'll give more weight to recall, in case of the cost of False negative is higher than that of False positive, so it will work, but this doesn't mean that this is the optimum solution for your problem.\nOptimizing Beta is relevant to the shape of your data, so it would be better to try different values of Beta on your data until you get the best value.","Q_Score":3,"Tags":"python-3.x,machine-learning,scikit-learn,random-forest,grid-search","A_Id":56162459,"CreationDate":"2018-10-22T17:39:00.000","Title":"How to choose beta in F-beta score","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just bought a new Mac and would like to avoid messing up any python dependencies and paths like I did when using Homebrew and pip in parallel with my old Mac. What is the cleanest and most powerful way of setting up a python distribution and installing all necessary packages, like e.g. scipy, matplotlib, numpy, etc.:\n\nHomebrew\npip (maybe via Homebrew?)\nvirtual environments\/anaconda\n\nWhat do I need to be careful with?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1262,"Q_Id":52941031,"Users Score":1,"Answer":"If you want all the data science libs, Anaconda is by far the easiest way of doing it in my experience. \nDo make use of virtual environments when possible. It'll help your machine remain tidy.","Q_Score":0,"Tags":"python,macos,pip,anaconda,homebrew","A_Id":52941278,"CreationDate":"2018-10-23T04:06:00.000","Title":"Best way to setup python on a new Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a project work, I need to measure the volume level either from a recorded audio file or in real time recording using a mic. After my primary research, I have tried using soundfile library. The file was read using soundfile and using 20*np.log10(np.sqrt(np.mean(np.absolute(a)**2))), I have calculated the dB value. I'm getting a negative value for the sound file. But a normal sound may be in the range of 50-70 dB and I'm getting a negative value. Can anybody help me to sort out this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":10925,"Q_Id":52943151,"Users Score":1,"Answer":"You need to add reference of sound i.e 20 log10(P rms_value\/P ref)+120 dB to get the data in the range of dB scale, Pref can be tuned from your input module","Q_Score":2,"Tags":"python,numpy,signal-processing,wav,pyaudio","A_Id":59115025,"CreationDate":"2018-10-23T07:12:00.000","Title":"Python: Get volume decibel Level real time or from a wav 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":1},{"Question":"Is it possible to have a keyboard shortcut to move the caret from editor to console and back in pycharm? I can switch the focus between editor and console using CTRL+TAB, but that doesn't allow me to start typing in the console unless I click in it.\nI am using the linux community distribution.","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":834,"Q_Id":52944985,"Users Score":1,"Answer":"I'm on MacOS and PyCharm 2018.2. Doing Ctrl+Tab+P opens up console and focuses on it so I can immediately start typing.\nUpdate: You can also set your own key map: Tool Windows\/Python Console. Hitting Esc will focus you back on the editor window.","Q_Score":2,"Tags":"python,console,pycharm,keyboard-shortcuts","A_Id":52945114,"CreationDate":"2018-10-23T08:55:00.000","Title":"How to move caret to console in pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to have a keyboard shortcut to move the caret from editor to console and back in pycharm? I can switch the focus between editor and console using CTRL+TAB, but that doesn't allow me to start typing in the console unless I click in it.\nI am using the linux community distribution.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":834,"Q_Id":52944985,"Users Score":1,"Answer":"The key is to hit the TAB key once (potentially twice) after you move into the Python Console (via whatever shortcut you specify in the keymap).","Q_Score":2,"Tags":"python,console,pycharm,keyboard-shortcuts","A_Id":61591749,"CreationDate":"2018-10-23T08:55:00.000","Title":"How to move caret to console in pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to have a keyboard shortcut to move the caret from editor to console and back in pycharm? I can switch the focus between editor and console using CTRL+TAB, but that doesn't allow me to start typing in the console unless I click in it.\nI am using the linux community distribution.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":834,"Q_Id":52944985,"Users Score":0,"Answer":"You can use Alt + 4 or Alt + 5 where the digit is the window number. And then to refocus back to the edit you press Enter.","Q_Score":2,"Tags":"python,console,pycharm,keyboard-shortcuts","A_Id":60378312,"CreationDate":"2018-10-23T08:55:00.000","Title":"How to move caret to console in pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im trying to use django with oracle nosql. I know django supports oracleDB but I don't know if oracle regular driver can be used by oracle nosql too. is there any driver for Nosql to support code first?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":122,"Q_Id":52948200,"Users Score":1,"Answer":"Django supports Oracle Database Server versions 12.1 and higher. Version 5.2 or higher of the cx_Oracle Python driver is required.","Q_Score":0,"Tags":"python,django,oracle,oracle-nosql","A_Id":52948367,"CreationDate":"2018-10-23T11:43:00.000","Title":"Does Django support oracleDB nosql?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"On my ubuntu server, some of the installed python packages are simple pip install some are sudo pip install. Is there any way I can give sudo permission to simple pip install?\nNote: There is around 250+ package. Installing one by one is quite hectic.\nPlease help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":52949781,"Users Score":2,"Answer":"Create requirements.txt file through cmd: pip freeze > requirements.txt\nit'll list all the python installed packages in you're system to that file. once you got the all packages install using either sudo or normal pip.\n\nwith sudo: sudo pip install -r requirements.txt\nwith out sudo : pip install -r requirements.txt\n\ni hope this will help you.","Q_Score":0,"Tags":"python,ubuntu,sudo","A_Id":52950188,"CreationDate":"2018-10-23T13:01:00.000","Title":"Give sudo permission to all simple pip installed packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently working on a school project. We need to be able to shutdown (and maybe restart) a pythonscript that is running on another raspberry pi using a button.\nI thought that the easiest thing, might just be to shutdown the pi from the other pi. But I have no experience on this subject.\nI don't need an exact guide (I appreciate all the help I can get) but does anyone know how one might do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":531,"Q_Id":52949880,"Users Score":0,"Answer":"Well first we should ask if the PI  you are trying to shutdown is connect to a network ? (LAN or the internet, doesn't matter).\nIf the answer is yes, you can simply connect to your PI through SSH, and call shutdown.sh. \nI don't know why you want another PI, you can do it through any device connected to the same network as your first PI (Wi-Fi or ethernet if LAN, or simply from anytwhere if it's open to the internet). \nYou could make a smartphone app, or any kind or code that can connect to SSH (all of them).","Q_Score":0,"Tags":"python,button,ssh,raspberry-pi","A_Id":52950146,"CreationDate":"2018-10-23T13:07:00.000","Title":"Shutdown (a script) one raspberry pi with another 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 using google cloud VM with 4 Tesla K80 GPU's. \nI am running a keras model using multi_gpu_model with gpus=4(since i have 4 gpu's). But, i am getting the following error\n\nValueError: To call multi_gpu_model with gpus=4, we expect the\n  following devices to be available: ['\/cpu:0', '\/gpu:0', '\/gpu:1',\n  '\/gpu:2', '\/gpu:3']. However this machine only has: ['\/cpu:0',\n  '\/xla_cpu:0', '\/xla_gpu:0', '\/gpu:0']. Try reducing gpus.\n\nI can see that there are only two gpu's here namely '\/xla_gpu:0', '\/gpu:0'. so, i tried with gpus = 2 and again got the following error\n\nValueError: To call multi_gpu_model with gpus=2, we expect the\n  following devices to be available: ['\/cpu:0', '\/gpu:0', '\/gpu:1'].\n  However this machine only has: ['\/cpu:0', '\/xla_cpu:0', '\/xla_gpu:0',\n  '\/gpu:0']. Try reducing gpus.\n\ncan anyone help me out with the error. Thanks!","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":7993,"Q_Id":52950449,"Users Score":1,"Answer":"TensorFlow is only seeing one GPU (the gpu and xla_gpu devices are two backends over the same physical device). Are you setting CUDA_VISIBLE_DEVICES? Does nvidia-smi show all GPUs?","Q_Score":3,"Tags":"python,tensorflow,keras,google-cloud-platform,gpu","A_Id":52957261,"CreationDate":"2018-10-23T13:34:00.000","Title":"valueError when using multi_gpu_model in keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using google cloud VM with 4 Tesla K80 GPU's. \nI am running a keras model using multi_gpu_model with gpus=4(since i have 4 gpu's). But, i am getting the following error\n\nValueError: To call multi_gpu_model with gpus=4, we expect the\n  following devices to be available: ['\/cpu:0', '\/gpu:0', '\/gpu:1',\n  '\/gpu:2', '\/gpu:3']. However this machine only has: ['\/cpu:0',\n  '\/xla_cpu:0', '\/xla_gpu:0', '\/gpu:0']. Try reducing gpus.\n\nI can see that there are only two gpu's here namely '\/xla_gpu:0', '\/gpu:0'. so, i tried with gpus = 2 and again got the following error\n\nValueError: To call multi_gpu_model with gpus=2, we expect the\n  following devices to be available: ['\/cpu:0', '\/gpu:0', '\/gpu:1'].\n  However this machine only has: ['\/cpu:0', '\/xla_cpu:0', '\/xla_gpu:0',\n  '\/gpu:0']. Try reducing gpus.\n\ncan anyone help me out with the error. Thanks!","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7993,"Q_Id":52950449,"Users Score":0,"Answer":"I had the same issue. Tensorflow-gpu 1.14 installed, CUDA 10.0, and 4 XLA_GPUs were displayed with device_lib.list_local_devices().\nI have another conda environement and there is just Tensorflow 1.14 installed and no tensorflow-gpu, and i don't know why, but i can run my multi_gpu model on all gpus with that environment.","Q_Score":3,"Tags":"python,tensorflow,keras,google-cloud-platform,gpu","A_Id":58273653,"CreationDate":"2018-10-23T13:34:00.000","Title":"valueError when using multi_gpu_model in keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running into an issue without volume mounting, combined with the creation of directories in python. \nEssentially inside my container, I'm writing to some path \/opt\/\u2026, and I may have to make the path (which I'm using os.makedirs for)\nIf I mount a host file path like -v \/opt:\/opt, with bad \"permissions\" where the docker container does not seem to be able to write to, the creation of the path inside the container DOES NOT FAIL. The makedirs(P) works, because inside the container, it can make the dir just fine, because it has sudo permissions.  However, nothing gets written, silently, on the host at \/opt\/\u2026. The data just isn't there, but no exception is ever raised.\nIf I mount a path with proper\/open permissions, like -v \/tmp:\/opt, then the data shows up on the host machine at \/tmp\/\u2026 as expected.\nSo, how do I not silently fail if there are no write permissions on the host on the left side of the -v argument?\\\nEDIT: my question is \"how do I detect this bad deployment scenario, crash, and fail fast inside the container, if the person who deploys the container, does it wrong\"? Just silently not writing data isn't acceptable.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":52952692,"Users Score":0,"Answer":"The bad mount is root on the host right, and the good mount is the user in the Docker group on the host? Can you check the user\/group of the mounted \/opt? It should be different than that of \/tmp.","Q_Score":1,"Tags":"python,docker","A_Id":52952936,"CreationDate":"2018-10-23T15:25:00.000","Title":"python+docker: docker volume mounting with bad perms, data silently missing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So my directory currently looks something like this \nsrc\n    \\aws_resources\n        \\s3\n           s3file.py\n        util.py\ntest\n    mytest.py\nI'm running the mytest.py file and it essentially imports the s3 file, while the s3 file imports the util.py file\nMy mytest.py says \nfrom src.aws_resources.s3 import *\n\nbut when I run the test file I get an error \nImportError: No module named aws_resources.util\n\nI tried adding \nfrom src.aws_resources import util to mytest.py but I still get the same error. Any suggestions would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":672,"Q_Id":52952756,"Users Score":0,"Answer":"Your current working directory is test, which means any import line will look into the test folder to find modules, if not found, go to the other paths existing in your sys.path (e.g. PYTHONPATH) to find.\nHere are my two assumptions:\n1.) src is not part of your PYTHONPATH\n2.) In your s3file.py you have this line (or similar): from aws_resources.util import *\nSince aws_resources is not a valid folder under test, and it couldn't be found under any of your sys.path, the Python interpreter couldn't find the module and rasied ImportError.\nYou can try one of the following:\n1.) Restructure your folder structure so that everything can be immediately referenced from your current working directory.\n2.) Handle the from aws_resources.util import * line in your s3file.py if you are importing it from another working directory.\n3.) Add src into your PYTHONPATH, or move it to a folder identified in PATH\/PYTHONPATH so you can always reference back to it.\nThe approach really depends on your use case for src and how often it gets referenced elsewhere.","Q_Score":0,"Tags":"python,python-2.7,import","A_Id":52952937,"CreationDate":"2018-10-23T15:28:00.000","Title":"\"No module named \" found when importing file that imports another 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 have a long-running python script script.py.\nWill it cause any issues if I invoke that script one-after the another through terminal:\npython script.py  -----first invocation\npython script.py  -----second invocation before the first gets over.\nSince python is a interpreted language, will there be any interference between these two scripts?\nOr is it safer to make a copy of the script and then run it?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":110,"Q_Id":52953892,"Users Score":2,"Answer":"There is no danger from the source code; each invocation will read the file separately, allocate its own local variables, etc.  However, there may be interference if the script uses any external references, such as writing to a common file.","Q_Score":1,"Tags":"python,multiprocessing","A_Id":52953957,"CreationDate":"2018-10-23T16:33:00.000","Title":"Python: Is it safe to run a single python script by multiple interpreters?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a long-running python script script.py.\nWill it cause any issues if I invoke that script one-after the another through terminal:\npython script.py  -----first invocation\npython script.py  -----second invocation before the first gets over.\nSince python is a interpreted language, will there be any interference between these two scripts?\nOr is it safer to make a copy of the script and then run it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":52953892,"Users Score":2,"Answer":"That depends entirely on what the script does.\nIn the simplest sense, the answer is no - though the two invocations run the same code, they don't inherently share any state and they can run side by side.  Just like any program on your computer, ( for example, bash shell in separate terminals ), independent invocations have their own process space.\nThe only case your scripts might interfere with each other is if they both use shared resources.  For example, if script.py created a file called \/tmp\/state.py then obviously the two invocations would conflict.","Q_Score":1,"Tags":"python,multiprocessing","A_Id":52953965,"CreationDate":"2018-10-23T16:33:00.000","Title":"Python: Is it safe to run a single python script by multiple interpreters?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Please could someone help this newbie. I've installed the following on my Android phone:\nQPython v2.4.2\nMysql Connector v1.0.8 (via QPYPI)\nMariaDBServer v10.3.8\nI can connect to the server using a separate Android SQL client app, so know the server is running OK.\nWhen I open the terminal and try to import mysql.connector, I get the below error message. I'd really appreciate some help in solving this. \nThanks in advance. \n\n\n\nimport mysql.connector\n      Traceback (most recent call last):\n        File \"\", line 1, in \n        File \"\/data\/user\/0\/org.qpython.qpy\/files\/lib\/python3.6\/site-packages\/mysql\/connector\/init.py\", line 33, in \n          from mysql.connector.connection import MySQLConnection\n        File \"\/data\/user\/0\/org.qpython.qpy\/files\/lib\/python3.6\/site-packages\/mysql\/connector\/connection.py\", line 123\n          except Exception, err:\n                          ^\n      SyntaxError: invalid syntax","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":212,"Q_Id":52955195,"Users Score":0,"Answer":"I managed to resolve this myself by uninstalling Mysql Connector v1.0.8 (via QPYPI) and installing it via pip install.","Q_Score":0,"Tags":"mysql-python,qpython","A_Id":53021517,"CreationDate":"2018-10-23T18:01:00.000","Title":"Cannot connect to Mariadb from Qpython terminal using Mysql Connector","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run the PVWatts model (concretely to get pvwatts_dc) on an Amerisolar 315 module which doesn't seem to appear. What I am trying to do is to replicate the steps in the manual, which only requires system DC size. \nWhen I go into the power model, the formula says g_poa_effective must be already angle-of-incidence-loss corrected. How do I do this correction? I've thought about using the physical correction formula pvlib.pvsystem.physicaliam(aoi), but is this the right track?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":52957433,"Users Score":1,"Answer":"Yes, use an incident angle modifier function such as physicaliam to calculate the AOI loss, apply the AOI loss to the in-plane direct component, then add the in-plane diffuse component.","Q_Score":0,"Tags":"python,pvlib","A_Id":52973320,"CreationDate":"2018-10-23T20:32:00.000","Title":"running PVWatts for module system not in Sandia DB (python library)","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 project I\u2019m exploring where I want to scrape the real estate broker websites in my country (30-40 websites of listings) and keep the information about each property in a database. \nI have experimented a bit with scraping in python using both BeautifulSoup and Scrapy. \nWhat I would Ideally like to achieve is a daily updated database that will find new properties and remove properties when they are sold.\nAny pointers as to how to achieve this? \nI am relatively new to programming and open to learning different languages and resources if python isn\u2019t suitable.\nSorry if this forum isn\u2019t intended for this kind of vague question :-)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":129,"Q_Id":52962131,"Users Score":0,"Answer":"Build a scraper and schedule a daily run. You can use scrapy and the daily run will update the database daily.","Q_Score":0,"Tags":"python,database,web-scraping,automation,scrapy","A_Id":52967603,"CreationDate":"2018-10-24T06:17:00.000","Title":"Building comprehensive scraping program\/database for real estate websites","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"While reading about Python's built-in types of number and specifically integers, I came across this line as quoted below;\n\nPlain integers are at least 32 bits long. The range is at least -2,147,483,648 to 2,147,483,647 (approximately\n  \u00b1\n  2 billion).\n\nDoes it mean that any arbitrary number that I can think of which has 2 billion digits, is the limit for Python to display it as a plain integer? If I should ask more specifically, what does \"32 bits long\" mean in reference to the aforementioned quoted sentence.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":369,"Q_Id":52964189,"Users Score":1,"Answer":"It's not 2 billion digits, but the actual value of 2 billion.\nThe reference of 32 bit represents the number of bits that python can store a plain integer into. Bits are represented in the base of 2 (because a bit can either be 0 or 1), where as our more common numbers in base of 10 are represented in the base of 10. The number 1 in the base 2 is 1, but the number 2 in the base 2 is 10 - just as in the base of 10, we go from 9 to 10.\nThe maximum value that can be stored in 32 bits are the number of combinations you can flip 32 ones or zeros. This will make the following number as 2^32 (=4 294 967 296). But you need to subtract 1 to get the maximum, because 0 is also a combination, making the largest unsigned number 4 294 967 295.\nTo represent also negative numbers the first bit is often reserved for signing the integer (1 means negative, 0 means positive) so it's roughly divided in half, making the smallest number -2 147 483 648 and the largest 2 147 483 647.","Q_Score":0,"Tags":"python,computer-science","A_Id":52964287,"CreationDate":"2018-10-24T08:24:00.000","Title":"Understanding how plain integers are represented in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use the first three convolution layers of vgg-16 to generate feature maps.\nBut i want to use it with variable image size,i.e not imagenet size of 224x224 or 256x256. Such as 480x640or any other randome image dimension. \nAs convolution layer are independent of image spatial size, how can I use the weights for varying image sizes?\nSo how do we use the pre-trained weights of vgg-16 upto the first three convolution layers.\nKindly let me know if that is possible.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":129,"Q_Id":52965773,"Users Score":0,"Answer":"As convolution layer are independent of image size\nActually it's more complicated than that. The kernel itself is independent of the image size because we apply it on each pixel. And indeed, the training of these kernels can be reused.\nBut this means that the output size is dependent on the image size, because this is the number of nodes that are fed out of the layer for each input pixel. So the dense layer is not adapted to your image, even if the feature extractors are independent.\nSo you need to preprocess your image to fit into the size of the first layer or you retrain your dense layers from scratch.\nWhen people talk about \"transfer-learning\" is what people have done in segmentation for decades. You reuse the best feature extractors and then you train a dedicated model with these features.","Q_Score":0,"Tags":"python,tensorflow,deep-learning","A_Id":52965846,"CreationDate":"2018-10-24T09:41:00.000","Title":"Using convolution layer trained weights for different image size","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using xlwings to expose python functions as user defined functions within Excel.  It works perfectly if the excel file is in the same directory as the .py file which contains my UDF functions.\nI would like to save my Excel file anywhere and just update my xlwings.conf file to have the location of the python module which contains the udf definitions.\nIf I set the conf file to have\n\"UDF MODULES\",\"C:\\src\\xlwings_wrapper\\xlwings_udfs\"\nI get the following error ModuleNotFound: No module named 'C:\\src\\xlwings_wrapper\\xlwings_udfs'.  How ever I have checked and the xlwings_udfs.py file is in that location.\nDoes anyone know if setting an absolute path for the UDF Modules is supported by xlwings?\nThanks\nDavid","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":580,"Q_Id":52975054,"Users Score":0,"Answer":"I made the same mistake. Should have read the manual\nFor completeness, when using either the xlwings.conf sheet or the UDF module box on the ribbon you need to adopt this setting configuration.","Q_Score":0,"Tags":"python,xlwings","A_Id":62959116,"CreationDate":"2018-10-24T17:41:00.000","Title":"Can I specify an absolute location for UDF_Modules within xlwings?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know complex math and the necessary operations (either \"native\" Python, or through NumPy). My question has to do with how to display complex numbers in a UI using wxPython. All the questions I found dealing with Python and complex numbers have to do with manipulating complex data.\nMy original thought was to subclass wx.TextCtrl and override the set and get methods to apply and strip some formatting as needed, and concatenating an i (or j) to the imaginary part.\nAm I going down the wrong path? I feel like displaying complex numbers is something that should already be done somewhere.\nWhat would be the recommended pattern for this even when using another UI toolkit, as the problem is similar. Also read my comment below on why I would like to do this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":52975402,"Users Score":0,"Answer":"As Brian considered my first comment good advice, and he got no more answers, I am posting it as an answer. Please refer also to the other question comments discussing the issue.\n\nIn any UI you display strings and you read strings from the user. Why\n  would you mix the type to string or string to type translation with\n  widgets functionality? Get them, convert and use, or \"print\" them to\n  string and show the string in the ui.","Q_Score":1,"Tags":"python,user-interface,tkinter,wxpython","A_Id":55748532,"CreationDate":"2018-10-24T18:05:00.000","Title":"Display complex numbers in UI when using wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that many have posted similar question however I tried most solution without success.\nI'm trying to host a webpage with apache2 and django in python3.\nIn the error log I found ImportError: No module named 'django' when accessing the wsgi.pyfile, where I also added import sys, sys.version to confirm which python version is used and from the error log I can see that I'm running following python version 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]. \nWhen I run python3.5 I see that I uses the same python version and here I can run import django without any error! \nEDIT: I checked django.__file__and saw that it was located in \/home\/USERNAME\/.local\/lib\/python3.5\/site-packages\/django\/init.py and that path \/home\/USERNAME\/.local\/lib\/python3.5\/site-packages wasn't in the sys.path that tried to run django. But adding it with sys.path.append(path) didn't help :(\nAny thoughts what I might have messed up?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":52976429,"Users Score":0,"Answer":"Location - means the path where env will be located in project directory, if you have followed the standard installation process of django or else you don't need, and version id- vesion of django framework.","Q_Score":0,"Tags":"django,python-3.x,apache","A_Id":52997325,"CreationDate":"2018-10-24T19:16:00.000","Title":"ImportError: No module named 'django' despite having it installed running apache2 server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know that many have posted similar question however I tried most solution without success.\nI'm trying to host a webpage with apache2 and django in python3.\nIn the error log I found ImportError: No module named 'django' when accessing the wsgi.pyfile, where I also added import sys, sys.version to confirm which python version is used and from the error log I can see that I'm running following python version 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]. \nWhen I run python3.5 I see that I uses the same python version and here I can run import django without any error! \nEDIT: I checked django.__file__and saw that it was located in \/home\/USERNAME\/.local\/lib\/python3.5\/site-packages\/django\/init.py and that path \/home\/USERNAME\/.local\/lib\/python3.5\/site-packages wasn't in the sys.path that tried to run django. But adding it with sys.path.append(path) didn't help :(\nAny thoughts what I might have messed up?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":52976429,"Users Score":0,"Answer":"I finally understood how to solve it! first I had to run pip3 uninstall django then run sudo pip3 install django.","Q_Score":0,"Tags":"django,python-3.x,apache","A_Id":52997956,"CreationDate":"2018-10-24T19:16:00.000","Title":"ImportError: No module named 'django' despite having it installed running apache2 server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've installed tensorflow over pip3 and python3, and am working on it. While using the colum function, the commonly experienced error AttributeError: module 'tensorflow' has no attribute 'feature_column'. \nIt might look like a duplicate question, but I've looked at the other occurrences of the same question, but, after updating the file (pip3 install --upgrade tensorflow), I checked the version. The version 0.12.0 is shown. So why does pip still show its completely new. Is 0.12.0 the newest version?\nWhen I attempted to uninstall tensorflow and re-install it, it refuses to re-install. I'm using python3 -m pip install tensorflow. The error thrown here is Could not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow\nThanks in advance for your help","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":194,"Q_Id":52977453,"Users Score":0,"Answer":"As mentioned in the comments, the most probable solution to the attribute error is the update problem. However, if you're encountering the Could not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow, the easiest solution is to use following code.\npip install --upgrade  https:\/\/storage.googleapis.com\/tensorflow\/mac\/cpu\/tensorflow-1.1.0-py2-none-any.whl (for python 2)\nor\npip install --upgrade  https:\/\/storage.googleapis.com\/tensorflow\/mac\/cpu\/tensorflow-1.1.0-py3-none-any.whl (for python 3)","Q_Score":0,"Tags":"python,tensorflow,pip,artificial-intelligence","A_Id":53006871,"CreationDate":"2018-10-24T20:27:00.000","Title":"Why is pip not updating tensorflow correctly, and, if it is, why is the 'attrib error' still thrown?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can you change the file metadata on a cloud database using Apache Beam? From what I understand, Beam is used to set up dataflow pipelines for Google Dataflow. But is it possible to use Beam to change the metadata if you have the necessary changes in a CSV file without setting up and running an entire new pipeline? If it is possible, how do you do it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":294,"Q_Id":52978251,"Users Score":0,"Answer":"You could code Cloud Dataflow to handle this but I would not. A simple GCE instance would be easier to develop and run the job. An even better choice might be UDF (see below).\nThere are some guidelines for when Cloud Dataflow is appropriate:\n\nYour data is not tabular and you can not use SQL to do the analysis.\nLarge portions of the job are parallel -- in other words, you can process different subsets of the data on different machines.\nYour logic involves custom functions, iterations, etc...\nThe distribution of the work varies across your data subsets.\n\nSince your task involves modifying a database, I am assuming a SQL database, it would be much easier and faster to write a UDF to process and modify the database.","Q_Score":1,"Tags":"java,python,google-cloud-platform,apache-beam,database-metadata","A_Id":52980803,"CreationDate":"2018-10-24T21:37:00.000","Title":"Change file metadata using Apache Beam on a cloud database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"every time i try to install something with pip i get the error \"You are using pip version 10.0.1, however version 18.1 is available.\nYou should consider upgrading via the 'python -m pip install --upgrade pip' command.\"\ni use the command given but i only get \"Requirement already up-to-date: pip in c:\\users\\iagol\\pycharmprojects\\devinsanta challenge\\venv\\lib\\site-packages (18.1)\naccording to that file path it is referring to another test project of mine... Shouldnt pip be updated to all my projects?\n(please excuse my noobness, first timer here lol)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":153,"Q_Id":52980222,"Users Score":1,"Answer":"I think you're updating the pip in your virtual environment, but not the one installed in the system.\nTo make sure you're using the pip in your virtual environment, you need to activate it first.  The activation script is in .\/venv\/bin.","Q_Score":1,"Tags":"python,pip","A_Id":52980245,"CreationDate":"2018-10-25T01:52:00.000","Title":"Error using pip to install frameworks,etc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Well I start learning Tensorflow but I notice there's so much confusion about how to use this thing..\nFirst, some tutorials present models using low level API tf.varibles, scopes...etc, but other tutorials use Keras instead and for example to use tensor board to invoke callbacks.\nSecond, what's the purpose of having ton of duplicate API, really what's the purpose behind  using high level API like Keras when you have low  level to build  model like Lego blocks?\nFinally, what's the true purpose of using eager execution?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":241,"Q_Id":52980583,"Users Score":0,"Answer":"You can use these APIs all together. E.g. if you have a regular dense network, but with an special layer you can use higher level API for dense layers (tf.layers and tf.keras) and low level API for your special layer.  Furthermore, it is complex graphs are easier to define in low level APIs, e.g. if you want to share variables, etc. \nEager execution helps you for fast debugging, it evaluates tensors directly without a need of invoking a session.","Q_Score":0,"Tags":"python,python-3.x,tensorflow,tensorboard","A_Id":52981417,"CreationDate":"2018-10-25T02:44:00.000","Title":"How to use Tensorflow Keras API","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any benefit of using Anaconda for PyCharm instead of the standard python distribution for PyCharm?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":237,"Q_Id":52982091,"Users Score":2,"Answer":"Using Anaconda instead of standard Python will benefit you as Anaconda comes with preinstalled packages. A lot of time will be saved there since installing various packages and making them run gets irritating sometimes.\nAlso, since it will have preinstalled packages, it can be heavy for your system. You can try miniconda as an alternative where you install packages when required. It is still better than having Python only. You can even install Anaconda by using conda install anaconda","Q_Score":0,"Tags":"python,pycharm,anaconda","A_Id":52982180,"CreationDate":"2018-10-25T05:43:00.000","Title":"Is there any benefit of using Anaconda for PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any benefit of using Anaconda for PyCharm instead of the standard python distribution for PyCharm?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":237,"Q_Id":52982091,"Users Score":2,"Answer":"Pip installation of Python packages sometimes may cause few problems to the user and you need to constantly update the pip as well before installing any other python packages via pip. So using Anaconda will be a benefit in this case.","Q_Score":0,"Tags":"python,pycharm,anaconda","A_Id":52982145,"CreationDate":"2018-10-25T05:43:00.000","Title":"Is there any benefit of using Anaconda for PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This might sound like a stupid question, but I got thinking about it by doing some security project:\nDoing a script for whatever reason and using libraries in it sounds just fine to me as you will install those libraries because it will execute in your pc.\nBut what if the script is, for example, to attack (execute the script) in someone's computer? That person might not have a specific library installed (for example pywhois for python and get the whois information). So the script would not work? Or in the same script, can you use a command to install the library without the user noticing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":135,"Q_Id":52982403,"Users Score":2,"Answer":"A malicious script running on a different machine which does not have its requirements can still execute, it just has to run ensure-pip and then pip as a subprocess, it will be able to obtain the necessary libraries just fine as long as it only needs them in the user site-packages and not the system.\nPython can lazy import so the first step would be to test, then catch an import error, and run pip -r requirements.txt, then import again or just run pip every time.","Q_Score":0,"Tags":"python,scripting","A_Id":52982533,"CreationDate":"2018-10-25T06:09:00.000","Title":"Executing a script that uses a library not installed in another pc, will install it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Django 1.8 the max_length of name field for Group model in the auth app is by default 80 characters.\nI need to increase this limit without extending the default group model.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":52982698,"Users Score":0,"Answer":"Short answer: I don't think that it is possible.\nYou probably need to extend the model if you want to change anything on it.\n\nYou could go into the source of the Django lib (probably located in your python installation somewhere in site-packages\/) and make the change there and then make migrations, but that is generally a bad idea since it will cause you troubles when trying to update to a newer Django version later on. And it will even be worse if you need to deploy the code on other machines.\nSome IDEs will even prevent modifications on files from external libs (for example, the Django files in site-packages\/) to protect developers from themselfs.","Q_Score":0,"Tags":"python,django,orm","A_Id":52986729,"CreationDate":"2018-10-25T06:29:00.000","Title":"django auth: increasing max_length group name field","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using postgres 10.5, python 3, flask and sqlalchemy. I'm trying to create a column in a users table with the following command\nid = db.Column(db.Integer, db.Sequence('user_id_seq'), primary_key=True, autoincrement=True)\n\nHowever, when I run this code and create a user, I get the error: \nerror creating user (psycopg2.ProgrammingError) relation \"user_id_seq\" does not exist\nHow can I create the sequence 'user_id_seq' programmatically? Is there some way to check if it exists and create it if it does not using sqlalchemy","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":550,"Q_Id":52982931,"Users Score":0,"Answer":"Interestingly, this just ended up being a problem with the way my database table was previously defined. I dropped the table, ran the code and the sequence existed correctly.","Q_Score":1,"Tags":"python,postgresql,sqlalchemy,psycopg2","A_Id":52999643,"CreationDate":"2018-10-25T06:43:00.000","Title":"Creating a db.Sequence with sqalchemy","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using updatedItem() function which is either inserting or updating values in Dynamodb. If values are updating I want to fetch those items and invoke a new lambda function. How can I achieve this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":330,"Q_Id":52985493,"Users Score":0,"Answer":"Don't think previously accepted answer works.  The return Attributes never returned the partition\/sort keys, whether an item was updated or created.\nWhat worked for me was to add ReturnValues: UPDATED_OLD.  If the returned Attributes is undefined, then you know that an item was created.","Q_Score":1,"Tags":"python-2.7,amazon-web-services,aws-lambda,amazon-dynamodb","A_Id":71245645,"CreationDate":"2018-10-25T09:08:00.000","Title":"Find whether the value has been updated or inserted in Dynamodb?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using keras's data generator with flow_from_dataframe. for training it works just fine, but when using model.predict_generator on the test set, I discovered that the ordering of the generated results is different than the ordering of the \"id\" column in my dataframe.\nshuffle=False does make the ordering of the generator consistent, but it is a different ordering than the dataframe. I also tried different batch sizes and the corresponding correct steps for the predict_generator function. (for example: batch_Size=1, steps=len(data))\nhow can I make sure the labels predicted for my test set are ordered in the same way of my dataframe \"id\" column?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":403,"Q_Id":52987835,"Users Score":0,"Answer":"While I haven't found a way to decide the order in which the generator produces data, the order can be obtained with the generator.filenames property.","Q_Score":0,"Tags":"python,keras","A_Id":53030878,"CreationDate":"2018-10-25T11:08:00.000","Title":"Keras flow_from_dataframe wrong data ordering","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just updated all conda packages, as Jupyter had a kernel error. Had been working in Pycharm for a while, but wanted to continue in Jupyter now that the code was working. Updating fixed my jupyter kernel error, but now the script won't work, in jupyter, pycharm, or from console. I get same error in each case:\n\nFile \"myscript.py\", line 58, in \n      myFunction(path, out)   File \"myscript.py\", line 7, in myFunction\n      from sklearn.feature_extraction.text import TfidfTransformer, CountVectorizer   File\n  \"C:\\Anaconda\\lib\\site-packages\\sklearn__init__.py\", line 134, in\n  \n      from .base import clone   File \"C:\\Anaconda\\lib\\site-packages\\sklearn\\base.py\", line 12, in \n      from .utils.fixes import signature   File \"C:\\Anaconda\\lib\\site-packages\\sklearn\\utils__init__.py\", line 11, in\n  \n      from .validation import (as_float_array,   File \"C:\\Anaconda\\lib\\site-packages\\sklearn\\utils\\validation.py\", line 18,\n  in \n      from ..utils.fixes import signature   File \"C:\\Anaconda\\lib\\site-packages\\sklearn\\utils\\fixes.py\", line 144, in\n  \n      from scipy.sparse.linalg import lsqr as sparse_lsqr  # noqa   File \"C:\\Anaconda\\lib\\site-packages\\scipy\\sparse\\linalg__init__.py\", line\n  113, in \n      from .isolve import *   File \"C:\\Anaconda\\lib\\site-packages\\scipy\\sparse\\linalg\\isolve__init__.py\",\n  line 6, in \n      from .iterative import *   File \"C:\\Anaconda\\lib\\site-packages\\scipy\\sparse\\linalg\\isolve\\iterative.py\",\n  line 7, in \n      from . import _iterative ImportError: DLL load failed\n\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":392,"Q_Id":52989115,"Users Score":0,"Answer":"Ended up unstalling anaconda and re-installing. Seems to work again now","Q_Score":0,"Tags":"python,scikit-learn","A_Id":53005078,"CreationDate":"2018-10-25T12:18:00.000","Title":"Python DLL load fail after updating all packages","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm testing an upgrade we ran on an application that processes data. I took archived data that has already run through the system before and comparing it with output from the newly upgraded application. I'm noticing that the data is the same but the arrangement of the data in the new output is different. For example, in the new file line 57's data used to be on line 43 in the old output. Is there a way to detect that the files contain identical content? When I run a file compare in TextPad or do an MD5 hash compare, it doesn't detect that the files have the same content. It sees them as different files.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":52989654,"Users Score":1,"Answer":"As Enak and Dominique have mentioned, sorting text files line by line and then comparing the two will reveal with complete certainty if anything is missing or not. \nYou might calculate some aggregate values of both files and compare them for sufficient proof though, which will be a lot faster. Are the number of words and characters the same? What about the number of different alphabets? Count all 26 alphabets in both files (you could also do the same for any character set of your choice), if their numbers match up exactly, there is a very high probability that both files contain the same information. This is on the same lines as your hashing approach, but obviously isn't as reliable. \nIf you need to know with certainty, you will have to compare each line of file A with each line of file B somehow. If the lines are completely shuffled, sorting the lines in file A and B and then comparing the files will be the best option. If there is locality however (line number x of file A tends to stay around location x in file B), you might as well just compare the two files without sorting, but rather by starting your search for line x of file A around location x in file B.","Q_Score":0,"Tags":"python,excel,duplicates,textpad","A_Id":52990604,"CreationDate":"2018-10-25T12:47:00.000","Title":"How To Identify Files with Identical Content But a Different Arrangement of the Data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have list of numbers ( 1 to 30 ) most probably. I need to arrange the list in such a way that the absolute difference between two successive elements is not more than 2 or 3 or 4, and the sum of absolute differences of all the successive elements is minimum.\nI tried generating all possible permutations of list ranging upto 10 and 11 and then sorting them according to the cost value, but for large nmbers it takes too long.\nIt would take ages to get list for 30 numbers.\nIs there any way I could perform the constraints while generating the permutations itself ? \nCurrently I'm using itertools library for python to generate permutations.\nAny help is greatly apprecited!\nThank you\nEDIT 1: Here are the results I got on small numbers like 10 and 12.\nArranged Array -> Cost (Cost is the sum of absolute difference between two successive elements)\n\nFor 10 numbers\n[1, 3, 5, 2, 4, 6, 8, 10, 7, 9] 20\n[2, 4, 1, 3, 5, 7, 9, 6, 8, 10] 20\nFor 12.\n[1, 3, 5, 2, 4, 6, 8, 11, 9, 7, 10, 12] 25\n[1, 3, 5, 7, 10, 12, 9, 11, 8, 6, 4, 2] 25\n\nI need to arrange 30 such numbers where 2 <= difference <= 4 and overall cost is minimum.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":343,"Q_Id":52990024,"Users Score":0,"Answer":"Calculating all permutations for a list of size 30 is impossible, irrespective of the implementation approach as there will be a total of 30! permutations.\nIt seems to me that the permutation you require can simply be achieved by sorting the the given list though by using arr.sort() and then calculating the difference between consecutive elements. Am I missing something?","Q_Score":1,"Tags":"python,constraints,permutation,itertools","A_Id":52990768,"CreationDate":"2018-10-25T13:05:00.000","Title":"Generate Permutations of a large number( probably 30) with constraints","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a client that reads messages from RabbitMq and sent it to a server, the IP of the server is specified in the message, I want the sending and receiving parts to be asynchronous because I will be dealing with multiple servers and I don't want the code to hang and wait for a response. by asynchronous I mean the send and receive work in parallel. any suggestion ? thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":52991421,"Users Score":0,"Answer":"You can use WebSockets for this. The send and receive part are event-driven and work in parallel.\nIf you already have sending and receiving mechanism and you just want them to be in parallel, have a look at greenlets in python.","Q_Score":0,"Tags":"python-3.x,sockets,asynchronous,rabbitmq","A_Id":52991521,"CreationDate":"2018-10-25T14:11:00.000","Title":"Asynchronous send\/receive client","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a project which used to be run on Linux for test. It's an App Engine flex project, run with gunicorn. Gunicorn does not work on Windows if I understood well, so I've been adviced to use waitress.\nI also use virtualenv in my project.\nSo when I'm in my virtualenv, I run waitress-serve main:app (the gunicorn cmd was gunicorn -b :8080 main:app). I get an error: It had these arguments:\n1. No module named flask.\nI use flask. I can see the flask folder in my virtualenv folder. And when I run python then from flask import Flask I have no error.\nIs there compat issue between waitress and virtualenv ? Or I'm doing something else wrong ? (already tried to delete virtualenv folder and install all the things again)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2684,"Q_Id":52991755,"Users Score":0,"Answer":"Python modules are case sensitive\nTry Flask not flask.","Q_Score":2,"Tags":"python,virtualenv,python-import,waitress","A_Id":52992108,"CreationDate":"2018-10-25T14:28:00.000","Title":"No module named flask with waitress-serve and virtualenv (App engine flex)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've been writing my first Django app and hit a problem with using templates.\nNo matter how I format the url for the template I receive the TemplateDoesNotExist error.\nMy html is nest in views\/ with the core template being views\/template.html.\nI have tried:\nmyapp\/views\/template.html\nviews\/template.html\ntemplates\/views\/template.html\n<full path to app>\/<all variations>\nNone of which can locate the template.\nI understand the TEMPLATE_DIRS variable may be set at project level but this is app-specific and the views\/ directory is not purely for templates.\nI don't think I should add to the url_patterns since the template shouldn't be accessible directly.\nI've got this far without them but need to clean up the app.\nAny advice?\nEdit:\nThe only line in my controller currently is:\ntemplate = loader.get_template(\"test\/templates\/test\/template.html\")\nThe line has been tested with every variation mentioned above and the one from the first comment.\nThere are no additional lines added to the urlpatterns, as I understand it adding to here would open access up to the public via url.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":52992304,"Users Score":0,"Answer":"it should be:\ntemplate = loader.get_template(\"test\/template.html\")","Q_Score":0,"Tags":"python,django","A_Id":52992683,"CreationDate":"2018-10-25T14:55:00.000","Title":"Django: using html templates TemplateDoesNotExist","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've been struggling with this problem in various guises for a long time, and never managed to find a good solution.\nBasically if I want to write a function that performs an operation over a given, but arbitrary axis of an arbitrary rank array, in the style of (for example) np.mean(A,axis=some_axis), I have no idea in general how to do this.\nThe issue always seems to come down to the inflexibility of the slicing syntax; if I want to access the ith slice on the 3rd index, I can use A[:,:,i], but I can't generalise this to the nth index.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":52992767,"Users Score":1,"Answer":"numpy functions use several approaches to do this:\n\ntranspose axes to move the target axis to a known position, usually first or last; and if needed transpose the result\nreshape (along with transpose) to reduce the problem simpler dimensions.  If your focus is on the n'th dimension, it might not matter where the (:n) dimension are flattened or not.  They are just 'going along for the ride'.\nconstruct an indexing tuple.  idx = (slice(None), slice(None), j); A[idx] is the equivalent of A[:,:,j].  Start with a list or array of the right size, fill with slices, fiddle with it, and then convert to a tuple (tuples are immutable).\nConstruct indices with indexing_tricks tools like np.r_, np.s_ etc.  \n\nStudy code that provides for axes.  Compiled ufuncs won't help, but functions like tensordot, take_along_axis, apply_along_axis, np.cross are written in Python, and use one or more of these tricks.","Q_Score":0,"Tags":"python,numpy,multidimensional-array,indexing","A_Id":52993813,"CreationDate":"2018-10-25T15:16:00.000","Title":"Write python functions to operate over arbitrary axes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a performance measurement issue while executing a migration to Cython from C-compiled functions (through scipy.weave) called from a Python engine.\nThe new cython functions profiled end-to-end with cProfile (if not necessary I won't deep down in cython profiling) record cumulative measurement times highly variable.\nEg. the cumulate time of a cython function executed 9 times per 5 repetitions (after a warm-up of 5 executions - not took in consideration by the profiling function) is taking:\n\nin a first round 215,627339 seconds\nin a second round 235,336131 seconds\n\nEach execution calls the functions many times with different, but fixed parameters.\nMaybe this variability could depends on CPU loads of the test machine (a cloud-hosted dedicated one), but I wonder if such a variability (almost 10%) could depend someway by cython or lack of optimization (I already use hints on division, bounds check, wrap-around, ...).\nAny idea on how to take reliable metrics?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":52992993,"Users Score":0,"Answer":"I'm not a performance expert but from my understanding the thing you should be measuring would be the average time it take per execution not the cumulative time? Other than that is your function doing any like reading from disk and\/or making network requests?","Q_Score":1,"Tags":"python,performance,cython","A_Id":52993380,"CreationDate":"2018-10-25T15:26:00.000","Title":"Highly variable execution times in Cython functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a performance measurement issue while executing a migration to Cython from C-compiled functions (through scipy.weave) called from a Python engine.\nThe new cython functions profiled end-to-end with cProfile (if not necessary I won't deep down in cython profiling) record cumulative measurement times highly variable.\nEg. the cumulate time of a cython function executed 9 times per 5 repetitions (after a warm-up of 5 executions - not took in consideration by the profiling function) is taking:\n\nin a first round 215,627339 seconds\nin a second round 235,336131 seconds\n\nEach execution calls the functions many times with different, but fixed parameters.\nMaybe this variability could depends on CPU loads of the test machine (a cloud-hosted dedicated one), but I wonder if such a variability (almost 10%) could depend someway by cython or lack of optimization (I already use hints on division, bounds check, wrap-around, ...).\nAny idea on how to take reliable metrics?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":168,"Q_Id":52992993,"Users Score":1,"Answer":"First of all, you need to ensure that your measurement device is capable of measuring what you need: specifically, only the system resources you consume.  UNIX's utime is one such command, although even that one still includes swap time.  Check the documentation of your profiler: it should have capabilities to measure only the CPU time consumed by the function.  If so, then your figures are due to something else.\nOnce you've controlled the external variations, you need to examine the internal.  You've said nothing about the complexion of your function.  Some (many?) functions have available short-cuts for data-driven trivialities, such as multiplication by 0 or 1.  Some are dependent on an overt or covert iteration that varies with the data.  You need to analyze the input data with respect to the algorithm.\nOne tool you can use is a line-oriented profiler to detail where the variations originate; seeing which lines take the extra time should help determine where the \"noise\" comes from.","Q_Score":1,"Tags":"python,performance,cython","A_Id":52994620,"CreationDate":"2018-10-25T15:26:00.000","Title":"Highly variable execution times in Cython functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I develop an application that will be used for running simulation and optimization over graphs (for instance Travelling salesman problem or various other problems).\nCurrently I use 2d numpy array as graph representation and always store list of lists and after every load\/dump from\/into DB I use function np.fromlist, np.tolist() functions respectively.\nIs there supported way how could I store numpy ndarray into psql? Unfortunately, np arrays are not JSON-serializable by default.\nI also thought to convert numpy array into scipy.sparse matrix, but they are not json serializable either","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":975,"Q_Id":52993954,"Users Score":2,"Answer":"json.dumps(np_array.tolist()) is the way to convert a numpy array to json. np_array.fromlist(json.loads(json.dumps(np_array.tolist()))) is how you get it back.","Q_Score":1,"Tags":"python,numpy,psql","A_Id":52994178,"CreationDate":"2018-10-25T16:21:00.000","Title":"How to store np arrays into psql database and django","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to check if root user exist in AWS account using Python or any cli command.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":724,"Q_Id":52994223,"Users Score":0,"Answer":"Try these commands\naws iam list-users\naws iam list-roles","Q_Score":0,"Tags":"python","A_Id":52994379,"CreationDate":"2018-10-25T16:37:00.000","Title":"Check if Root user exist in AWS 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":1,"Web Development":0},{"Question":"Is there a program that will allow python in some way to encrypt\/decrypt a file? Ideally, the code would call this program on the file and that file would then handle all the taking of the password, etc. The file would then be decrypted to a set location and deleted by the python after use.\nWhy do I want an external program? Because anything written in Python is too easy to reverse engineer. If there is no encryption done by the code itself, it would be much harder for your 'unwanted viewer' to access what is in that file.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":52994677,"Users Score":4,"Answer":"Make use of python's facility to call external programmes via the subprocess module. Then any encryption programme of your choice will do, provided that it allows command-line usage, like gpg.","Q_Score":0,"Tags":"python,encryption","A_Id":52994725,"CreationDate":"2018-10-25T17:08:00.000","Title":"Python encrypt using external program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let me first describe the setup:\nWe have an autonomous agent in Unity, whose decisions are based on the perceived environment(level) and some pre-defined parameters for value mapping. Our aim is to pre-train the agents' parameters in a DNN. So the idea is basically to define an error metric to evaluate the performance of the agent in a Unity simulation (run the level, e.g. measure the deviation from the optimal trajectory = ground truth in unity). So based on the input level into the DNN, the network should train to output the params, the simulation is performed and the error is passed back to the network as the error value, like accuracy, so the network could train based on that error\/performance.\nIs there any way to perform the evaluation(comparison to the ground truth) during the training outside of Keras? Usually, one passes X data to the network, train stuff and compare it to the ground truth Y. This works fine for predictions, but I don't want to predict something. What I do want is to measure the deviation from the ground truth inside the simulation.\nI know there is Unity ML Agents, but as far as I could read, the 'brain' controls the agent on runtime, i.e. update it on every frame and control the movement. What I want is to perform the whole simulation to update the params\/weights of the network.\nBest wishes.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":52995288,"Users Score":0,"Answer":"After some talks at my university:\nthe setup won't work this way since I need to split the process.\nI need the parameters of working agents to train the network based only on the level description(e.g. matrix like video game description language). To obtain the parametrized agents based on the actual level and the ground truth data(e.g. deviation from trajectory), one need to use reinforcement deep learning with a score function to obtain these parameters. Therefore Unity ML Agents might be useful. Afterwards, I can use the parameters settings and the correlating level data to train a network to yield the desired parameters based only on the level description.","Q_Score":0,"Tags":"python,unity3d,keras,deep-learning,ml-agent","A_Id":53008270,"CreationDate":"2018-10-25T17:48:00.000","Title":"Training in Keras with external evaluation function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a convenient way of opening JupyterLab without opening Jupyter Notebook? I created the shortcuts for both, but I noticed that I need to open the Jupyter Notebook first then JupyterLab to avoid a blank page if otherwise. Thanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":658,"Q_Id":52995686,"Users Score":0,"Answer":"It's hard to know what the problem is without seeing your shortcuts, but usually if you replace the \/tree? in the notebook URL with \/lab you should be able to get straight to jupyterlab.","Q_Score":1,"Tags":"python,jupyter-notebook,jupyter,jupyter-lab","A_Id":52995956,"CreationDate":"2018-10-25T18:17:00.000","Title":"Open JupyterLab without Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a pretty specific ask, so I'm open to helpful suggestions that get part of the way there. \nI have a python project that runs inside a docker container configured to work with the Pycharm debugger. I have a package, installed in a virtual env with pip, used in this project, that I'd like to develop on. \nI haven't found a way to link the package into my project's docker container in such a way that I can change the package and have the code update in my project. \nCurrently, the debugger works on codepaths that enter into the package, as long as I don't change any code in the package.\nThese two problems combined make it hard to test changes to the package without installing it over and over.\nIs there a better way to accomplish this goal?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":52997708,"Users Score":0,"Answer":"Install the package in editable mode.\npip install -e .\nThis will allow you to make changes to the code and update the package simultaneously.","Q_Score":2,"Tags":"python,docker,pycharm,virtualenv","A_Id":52997780,"CreationDate":"2018-10-25T20:35:00.000","Title":"How can I develop on a Python library package while testing it a project using Pycharm + Docker?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a pretty specific ask, so I'm open to helpful suggestions that get part of the way there. \nI have a python project that runs inside a docker container configured to work with the Pycharm debugger. I have a package, installed in a virtual env with pip, used in this project, that I'd like to develop on. \nI haven't found a way to link the package into my project's docker container in such a way that I can change the package and have the code update in my project. \nCurrently, the debugger works on codepaths that enter into the package, as long as I don't change any code in the package.\nThese two problems combined make it hard to test changes to the package without installing it over and over.\nIs there a better way to accomplish this goal?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":289,"Q_Id":52997708,"Users Score":1,"Answer":"Given the two source trees that should work together:\n\nCreate a virtual environment for them, python -m venv vpy.\nActivate it, setting relevant shell environment variables, . vpy\/bin\/activate.\nInstall the library, cd library && pip install -e .  (-e causes pip to remember a pointer to the live source tree.)\nInstall the application, cd app && pip install -e ..  (Pip should know you already have the library installed.)\nDo whatever you need to do, $EDITOR file.py; pytest; the_app; $SCM commit.\nOnce it all works correctly, docker build && docker run.\n\nI'd leave any interaction with Docker until the very end, once you've convinced yourself you've fixed the library bug or built the feature.  That avoids troubles with your editor and the container disagreeing on paths, and it means you don't need root privileges for any of your ordinary development work.","Q_Score":2,"Tags":"python,docker,pycharm,virtualenv","A_Id":53000368,"CreationDate":"2018-10-25T20:35:00.000","Title":"How can I develop on a Python library package while testing it a project using Pycharm + Docker?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been working on creating a convolutional neural network from scratch, and am a little confused on how to treat kernel size for hidden convolutional layers. For example, say I have an MNIST image as input (28 x 28) and put it through the following layers.\nConvolutional layer with kernel_size = (5,5) with 32 output channels\n\nnew dimension of throughput = (32, 28, 28)\n\nMax Pooling layer with pool_size (2,2) and step (2,2)\n\nnew dimension of throughput = (32, 14, 14)\n\nIf I now want to create a second convolutional layer with kernel size = (5x5) and 64 output channels, how do I proceed? Does this mean that I only need two new filters (2 x 32 existing channels) or does the kernel size change to be (32 x 5 x 5) since there are already 32 input channels? \nSince the initial input was a 2D image, I do not know how to conduct convolution for the hidden layer since the input is now 3 dimensional (32 x 14 x 14).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1046,"Q_Id":52997810,"Users Score":0,"Answer":"you need 64 kernel, each with the size of (32,5,5) . \ndepth(#channels) of kernels, 32 in this case, or 3 for a RGB image, 1 for gray scale etc, should always match the input depth, but values are all the same.\ne.g. if you have a 3x3 kernel like this : [-1 0 1; -2 0 2; -1 0 1]  and now you want to convolve it with an input with N as depth or say channel, you just copy this 3x3 kernel N times in 3rd dimension, the following math is just like the 1 channel case, you sum all values in all N channels which your kernel window is currently on them after multiplying the kernel values with them and get the value of just 1 entry or pixel. so what you get as output in the end is a matrix with 1 channel:) how much depth you want your matrix for next layer to have? that's the number of kernels you should apply. hence in your case it would be a kernel with this size (64 x 32 x 5 x 5) which is actually 64 kernels with 32 channels for each and same 5x5 values in all cahnnels.\n(\"I am not a very confident english speaker hope you get what I said, it would be nice if someone edit this :)\")","Q_Score":0,"Tags":"python,tensorflow,neural-network,conv-neural-network,convolution","A_Id":52998511,"CreationDate":"2018-10-25T20:43:00.000","Title":"Kernel size change in convolutional neural networks","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run a program with pynput. I tried installing it through terminal on Mac with pip. However, it still says it's unresolved on my ide PyCharm. Does anyone have any idea of how to install this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":219,"Q_Id":52998495,"Users Score":0,"Answer":"I have three theories, but first: make sure it is installed by running python -c \"import pynput\" \n\nJetBrain's IDEs typically do not scan for package updates, so try restarting the IDE.\nJetBrain's IDE might configure a python environment for you, this might cause you to have to manually import it in your run configuration.\nYou have two python versions installed and you installed the package on the opposite version you run script on.\n\nI think either 1 or 3 is the most likely.","Q_Score":0,"Tags":"python,pycharm","A_Id":52998994,"CreationDate":"2018-10-25T21:40:00.000","Title":"Python: I can not get pynput to install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can get the dimensions of tensors at graph construction time via manually printing shapes of tensors(tf.shape()) but how to get the shape of these tensors at session runtime? \nThe reason that I want shape of tensors at runtime is because at graph construction time shape of some tensors is coming as (?,8) and I cannot deduce the first dimension then.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":885,"Q_Id":53003231,"Users Score":0,"Answer":"You have to make the tensors an output of the graph. For example, if showme_tensor is the tensor you want to print, just run the graph like that : \n_showme_tensor = sess.run(showme_tensor) \nand then you can just print the output as you print a list. If you have different tensors to print, you can just add them like that :\n_showme_tensor_1, _showme_tensor_2 = sess.run([showme_tensor_1, showme_tensor_2])","Q_Score":0,"Tags":"python,tensorflow","A_Id":53003804,"CreationDate":"2018-10-26T07:04:00.000","Title":"How to get the dimension of tensors at runtime?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"we can not install Tkinter package using pip and want to use Tkinter in pex. Please tell me the way so I can use ubuntu package in pex. Your help is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":53003787,"Users Score":0,"Answer":"The not-so-easy, but 100% working way:\n\nCompile Tkinter with statically linking\nCreate Pypi package, which contains your compiled Tkinter binaries and libraries as a regular files\nInstall this package to your development environment, and use this statically-linked libs and files in your app.\npex should work perfectly with this setup!","Q_Score":0,"Tags":"python,ubuntu","A_Id":53003936,"CreationDate":"2018-10-26T07:41:00.000","Title":"How to use ubuntu packages in pex file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In PyCharm, I have 2 methods to run my code:\n\npress ctrl + alt + F10, then the code will run in running console. \ngo to embedded terminal, run the code by .\/filename.py.\n\nWhich method should I use? Or is there a better method? I tried method 1, but problem is some features are missing, like press up arrow for history command, or when use pdb.set_trace() to enter debug mode, the auto-complete feature in running console behaves strangely: for example, in debug mode of running console, when entering a [], the cursor automatically jumps out of the square brackets and do not allow me to type anything in the square brackets. However, there must be a reason why running console exists, right? Otherwise there should only be the embedded terminal.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":925,"Q_Id":53005137,"Users Score":2,"Answer":"The better method is to set the \"Emulate terminal in output console\" option in the settings of the run configuration. You can go to Run | Edit Configurations | Templates and enable the option there so that it will be enabled for all run configurations.\nThis gives you the higher level of integration of the running console (so that you can run your code using Ctrl-Alt-F10 and not by typing the filename in the terminal) and all features of the terminal emulator. This mode is likely to become default in future versions of PyCharm.","Q_Score":1,"Tags":"python,pycharm","A_Id":53005630,"CreationDate":"2018-10-26T09:01:00.000","Title":"In PyCharm, should I use embedded terminal or running console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I implemented a physics simulation in Python (most of the heavy lifting is done in numerical libraries anyways, thus performance is good enough).\nNow that the project has grown a bit, I added extra functionality via parameters that do not change during the simulation. With that comes the necessity to have the program do one thing or another based on their values, i.e., quite a few if-else scattered around the code.\nMy question is simple: does Python implement some form of branch prediction? Am I going to wear the performance significantly or is the interpreter smart enough to see that some parameters never change? Having a constant if-else inside a function that is called a million times, is the conditional evaluated every time or some magic happens? When there is no easy way to remove the conditional altogether, is there a way to give the interpreter some hints and favour\/emulate branch prediction?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":1581,"Q_Id":53005367,"Users Score":4,"Answer":"You could in theory benefit here from some JIT functionality that may observe the control flow over time and could effectively suppress never-taken branches by rearranging the code. Some of the Python interpreters contain JIT compilers (I think PyPy does in newer versions, maybe Jython as well), and may be able to do this optimization, but that of course depends on the actual code.\nHowever, the main form of branch prediction is done in HW, and is unrelated to the SW or language constructs used (in Python's case - quite a few levels of abstraction above). This mechanism eventually observes these conditional code paths as branches, and may be able to learn them if they are indeed statically determined. However, as any prediction mechanism, it has limited capacity, and since your code is supposed to be big, it may not be able to accommodate predictions for all these branches. It's still considered quite good, so chances are that the critical ones may work.\nFinally, if you really want to optimize your code, you can convert some of these conditions to constants (assigning an argument a constant value instead of parsing the command line), or hiding the condition completely with something like __debug__. This way you won't have to worry about predicting them, but can restore the capability with minimal work if you need them in the future.","Q_Score":5,"Tags":"python,branch-prediction","A_Id":53040868,"CreationDate":"2018-10-26T09:14:00.000","Title":"Has Python got branch prediction?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I know this might not be the place where to ask, but I can simply not figure it out! When im using Spyder and say numpy (np) when I type np. a lot of options pop up - I know most of them are functions related to np, but I kinda struggling to figure out exactly what the different calls are; they all have one letter to the very left of the name, e.g \"(f) all\", \"(a) base\".\nSo what is the difference between (f), (a), (c) ? My first guess would be \"function\", \"attributes\", \"class\" but I'm not entirely sure","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":419,"Q_Id":53005691,"Users Score":0,"Answer":"So what is the difference between (f), (a), (c) ? My first guess would be \"function\", \"attributes\", \"class\" but I'm not entirely sure\n\n(Spyder maintainer here) This is the right interpretation.","Q_Score":0,"Tags":"python,function,class,methods,spyder","A_Id":53010613,"CreationDate":"2018-10-26T09:32:00.000","Title":"What does \"a\",\"c\",\"f\" mean in Spyder-methods (Python)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have install my package via pip:\npip install mypackage\nI see that it has put it in: \nC:\\Python364\\Lib\\site-packages\\mypackage\nwhen I run python (I've checked it is 3.6.4) I try to import a function from my module:\n\n\n\nfrom mypackage import version\n      Traceback (most recent call last):\n        File \"\", line 1, in \n      ImportError: cannot import name 'version'\n\n\n\nWhen I print sys.path site-packages is even there:\n'C:\\Python364\\Lib\\site-packages',\nI normally put all my binaries in with my main .py file and all imports work like this. However now I am trying to install from a .whl file and it can't import.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":196,"Q_Id":53011791,"Users Score":0,"Answer":"Forget it. As it mypackage is now sitting in a folder called mypackage there is another level of indirection:\n\n\n\nfrom mypackage.mypackage import version\n\n\n\nworks!","Q_Score":0,"Tags":"python,pip,installation","A_Id":53011923,"CreationDate":"2018-10-26T15:19:00.000","Title":"Python pip site-packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Andrew Ng's machine learning course it is recommended that you plot the learning curve (training set size vs cost) to determine if your model has a high bias or variance. \nHowever, I am training my model using Tensorflow and see that my validation loss is increasing while my training loss is decreasing. It's my understanding that this means my model is overfitting and so I have high variance. Is there still a reason to plot the learning curve?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":141,"Q_Id":53015550,"Users Score":1,"Answer":"Yes, there is, but it's not for spotting overfitting only. But anyway, plotting is just fancy way to see numbers, and sometimes it gives you insights. If you are monitoring loss on train\/validation simultaneously \u2013 you're looking at same data, obviously.\nRegarding Andrew's ideas \u2013 I suggest looking into Deep Learning course by him, he clarifies that in modern applications (DL + a lot of data, and I believe, this is your case) bias is not an opposite of variance.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,neural-network","A_Id":53015631,"CreationDate":"2018-10-26T19:58:00.000","Title":"Why is a learning curve necessary to determine if a neural network has high bias or variance?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For example, if I define my array as my_array = np.array([1,2,3]),\nWhat is the difference between \nmax(my_array)and \nmy_array.max() ? \nIs this one of those cases where one is 'syntactic sugar' for the other? Also, why does the first one work with a Python list, but the second doesn't?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":79,"Q_Id":53015623,"Users Score":1,"Answer":"As people have stated in the comments of your question, they are referencing two different functions.\nmax(my_array) is a built in Python function available to any sequence data in python.\nWhereas, my_array.max() is referencing a function within the object. In this case my_array is from the Numpy array class. Numpy does not recognize the list data type for this function. However, this method will provide a speed improvement over the max(my_array) whenever you are using numpy data sequences. \nAs a rule of thumb if the variable has a variable.someMethod() the function is a method and is specific to the class of object. If the function is called as function(variable) then the function is either a part of the python distribution or the file\/class you are working with.","Q_Score":0,"Tags":"python,numpy,methods,syntax","A_Id":53015879,"CreationDate":"2018-10-26T20:05:00.000","Title":"What is the difference between max(my_array) and my_array.max()","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed pytube via pip, uninstalled it and reinstalled it couple off times, but always I'm getting an error \"ModuleNotFoundError: No module named 'pytube'\".\nWhen I insatlled it via cmd this is what it outputs(warning)\nThe script pytube.exe is installed in 'C:\\Users\\vid\\AppData\\Roaming\\Python\\Python37\\Scripts' which is not on PATH.\nConsider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\ntrying to fix the problem for like 2 hours now. Help","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2085,"Q_Id":53015671,"Users Score":0,"Answer":"I repaired that using:\npip install pytube3, which adds the newer pytube version which python supports.","Q_Score":0,"Tags":"python,pytube","A_Id":63538378,"CreationDate":"2018-10-26T20:09:00.000","Title":"Pytube module not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I installed pytube via pip, uninstalled it and reinstalled it couple off times, but always I'm getting an error \"ModuleNotFoundError: No module named 'pytube'\".\nWhen I insatlled it via cmd this is what it outputs(warning)\nThe script pytube.exe is installed in 'C:\\Users\\vid\\AppData\\Roaming\\Python\\Python37\\Scripts' which is not on PATH.\nConsider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\ntrying to fix the problem for like 2 hours now. Help","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2085,"Q_Id":53015671,"Users Score":1,"Answer":"Run cmd as -> Right click, Run as Administrator and try again\nYou may have 2 different Python installed, one from anaconda and one independent. Uninstall one and keep the conda one only\nReinstall, but run the installer as Administrator\nUpdate pip \"pip install --upgrade pip\"","Q_Score":0,"Tags":"python,pytube","A_Id":53016382,"CreationDate":"2018-10-26T20:09:00.000","Title":"Pytube module not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am fairly new to tensorflow and I am interested in developing a DeseNet Architecture. I have found implementations from scratch on Github. I was wondering if the tensorflow API happen to implement the dense blocks. Is tensorflow's tf.layers.dense the same as the dense blocks in DenseNet?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":354,"Q_Id":53016653,"Users Score":2,"Answer":"No, tf.layers.dense implements what is more commonly known as a fully-connected layer, i.e. the basic building block of multilayer perceptrons. If you want dense blocks, you will need to to write your own implementation or use one of those you found on Github.","Q_Score":1,"Tags":"python,tensorflow","A_Id":53020115,"CreationDate":"2018-10-26T21:45:00.000","Title":"DenseNet in Tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"[WinError 2] The system cannot find the file specified\n  [cmd: ['\/usr\/local\/bin\/python3.7', '-u', '']]\n  [dir: C:\\Program Files\\Sublime Text 3]    [path:C:\\cygwin64\\bin;\"C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\%PYTHON_HOME%\";C:\\Users\\Jugal\\AppData\\Local\\Microsoft\\WindowsApps;]","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":53018964,"Users Score":0,"Answer":"Your Sublime Text 3 install expects the cmd to be a string not an array of strings.\nThe array ['\/usr\/local\/bin\/python3.7', '-u', ''] was interpreted as a single entry.\nIt is possible that you need some flags like shell=False to get rid of this behavior.","Q_Score":1,"Tags":"python-3.x","A_Id":53019665,"CreationDate":"2018-10-27T05:23:00.000","Title":"Getting the following error while executing a python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a pandas dataframe result which stores a result obtained from a sql query. I want to paste this result onto the chart backend of a specified chart in the selected presentation. Any idea how to do this?\nP.S. The presentation is loaded using the module python-pptx","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1226,"Q_Id":53021158,"Users Score":0,"Answer":"you will need to read a bit about python-pptx.\nYou need chart's index and slide index of the chart. Once you know them\nget your chart object like this->\nchart = presentation.slides[slide_index].shapes[shape_index].chart\nreplacing data\nchart.replace_data(new_chart_data)\nreset_chart_data_labels(chart)\nthen when you save your presentation it will have updated the data.\nusually, I uniquely name all my slides and charts in a template and then I have a function that will get me the chart's index and slide's index. (basically, I iterate through all slides, all shapes, and find a match for my named chart).\nHere is a screenshot where I name a chart->[![screenshot][1]][1]. Naming slides is a bit more tricky and I will not delve into that but all you need is slide_index just count the slides 0 based and then you have the slide's index.\n[1]: https:\/\/i.stack.imgur.com\/aFQwb.png","Q_Score":2,"Tags":"python,python-3.x,pandas,powerpoint","A_Id":69335685,"CreationDate":"2018-10-27T10:53:00.000","Title":"python - pandas dataframe to powerpoint chart backend","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a simple python script to change my ubuntu wallpaper. I want to this script run after whenever I logged in.\n\nI tried to add command in startup application as python \/bin\/wallpaper_changer.py but it doesn't work.\nI also tried to add a desktop entry in ~\/.config\/autostart\/Myscript.desktop but it also doesn't work.\nI also added this file path in crontab using sudo crontab -e @reboot python \/bin\/wallpaper_changer.py it also doesn't work.\nI added entry in rc.local as python \/bin\/wallpaper_changer.py it also doesn't work","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":902,"Q_Id":53023541,"Users Score":0,"Answer":"I found solution for this.\nfirst make your source file executable.\nchmod +x \/path\/to\/your\/file\nafter add it to cron tab.\nsudo crontab -e\nIf it asks for any editor choose editor options.\nafter it add your path when # symbols end.\n@reboot \/path\/to\/your\/file","Q_Score":0,"Tags":"python,ubuntu,startupscript","A_Id":53042771,"CreationDate":"2018-10-27T15:39:00.000","Title":"Ubuntu - How to run python script after logging in?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am writing an interpreter for my simple programing language in Python. When there is an error during interpreting, a Python exception is thrown. The problem is that the stack trace is really ugly because it contains many recursive calls as I am navigating program's structure and interpreting it. And from the stack trace you cannot really see where in my program's structure the code was when it failed.\nI know that I could capture all exceptions myself and rethrow a new exception adding some information about where an exception happened, but because it is recursive, I would have to do such rethrowing again and again.\nI wonder if there isn't an easier way. For example, that next to path, line numbers, and function name in interpreter's code, I could print out also information where in the interpreted program's code that function is at that moment in the stack.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":53025193,"Users Score":0,"Answer":"You can write a sys.excepthook that prints whatever traceback you want.  I regularly use such a hook that uses the traceback module to print a normal traceback but with added lines that give the values of interesting local variables (via f_locals introspection).","Q_Score":2,"Tags":"python","A_Id":53025602,"CreationDate":"2018-10-27T18:47:00.000","Title":"Adding custom information to Python stack trace to be printed out","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running Python 2.7.15 on my 64 bit Windows computer. I have tried numerous times to download the 64 bit versions of PIL and Pillow on my laptop (.exe installer versions). But every single time, I click Install and the installer waits a few seconds before closing abruptly without installing. I checked that both my system and python are both 64 bit. I even tried installing the 32 bit PIL and Pillow on my computer but I got the same results: doesn't install and closes abruptly. Does anyone have the 64 bit files of PIL or Pillow for Python 2.7 that I can directly import into my python site packages folder? Also, what is the problem here? I tried shutting down and restarting but nothing seems to help. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":53025651,"Users Score":0,"Answer":"Although I still do not know why my computer is not installing PIL or Pillow, I installed Pillow on another computer and downloaded the files onto a USB, which I then transfered into my Python folder.  This works perfectly and I now have all the Pillow files on my computer.","Q_Score":0,"Tags":"python,python-2.7,python-imaging-library","A_Id":53073265,"CreationDate":"2018-10-27T19:41:00.000","Title":"PIL and Pillow Installer Closes Abruptly Without Installing (Windows 10)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote this script that runs several executable updates in a shared network folder. Several separate machines must run these updates.\nI would like to archive these updates once they are run. However, as you may see the dilemma, if the first machine runs an update and archives the executable,\nthe rest of connected devices won't run as they will no longer appear in the cwd. Any ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":53025704,"Users Score":0,"Answer":"It took me a while to understand what you meant by \"archiving\", but probably moving to another folder on a network shared mount. Also, the title should definitely be changed, I accidentally marked it as OK in Review Triage system.\nYou probably want to assign some ID to each machine, then have each of them create a new file once they finish the installation (e.g. empty finished1.txt for PC with ID 1, finished2.txt for PC 2 etc.). Then, one \"master\" PC should periodically scan for such files, and when finding all it expects, deleting\/moving\/archiving the installers. It may be good idea to add timeout functionality to the script on master PC, so when one of PCs will get stuck, you will get notified in some way.","Q_Score":0,"Tags":"python-3.x","A_Id":53026771,"CreationDate":"2018-10-27T19:48:00.000","Title":"Archiving files with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I can not interrupt a running script in python3 kernel in Jupyter, Qt Console, spyder on my window 10 desktop. Ctrl+c and interrupt bottom from the menu do not work, just nothing happens. The same method works well on my laptop and Ubuntu desktop. I tried to reinstall uninstall Anaconda and delete the remaining files, then I tried reinstalling the new version of Anaconda. The problem still here. My window 10 on the desktop is just installed yesterday, so it is fresh. \nI have one desktop and one laptop. Each one has window 10 and Ubuntu installed on it. My laptop windows 10 has no problem to interrupt. Interruption works fine in Ubuntu on both desktop and laptop.\nRight now, my situation is:\nWin 10 desktop: Interruption does not work.\nUbuntu desktop: Interruption works.\nWin 10 laptop: Interruption works.\nUbuntu laptop: Interruption works.\nMy question is:\n\nHow can I fix this? Reinstallation not helping!\nWhat is wrong (probably)? \n\nThanks you! I need to fix to do my physics assignment. My laptop are too bad and I am not familiar with Ubuntu.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":873,"Q_Id":53026544,"Users Score":1,"Answer":"Python 3.6 can key interrupt for me. But I have a solution for Python 3.7.\n\nuninstall Anaconda\nafter that delete those files in C:\\Users\\<your_user_name>:\n.anaconda .conda .ipython .jupyter .matplotplot .spyder-py3\nThis is very important step.\nreinstall Anaconda.\n\nIt works for me.","Q_Score":0,"Tags":"python,windows,kernel,anaconda,spyder","A_Id":56819732,"CreationDate":"2018-10-27T21:45:00.000","Title":"Anaconda python kernel can not be interrupted. Reinstalling can not work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a webcam, a microphone and a python GUI. The user shows the camera an object and using voice command asks \"what is this object?\". The webcam takes a photo of the camera frame and pushes it to a flask endpoint. I have a VGG16 model hosted in the flask app which responds with a object class based on the image from camera.\nWhat I want to do now is, if the object is not recognised, a learning cycle should be triggered. In this cycle I will tell the model what the object is (voice to text), which will be the label for the object. I got that working.\nWhat's not working is the next time (after the learning is complete), if I show the object to the camera, the model should be able to tell me what this object is.\nCould someone please advise me on the following:\n\nIs VGG16 (trained initially on 2 objects using transfer learning) the best model for this type of task? Currently, it is classifying unseen objects as one of the two classes.\nHow would you go about implementing this solution on the cloud (AWS, Azure etc.)\n\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":53031577,"Users Score":0,"Answer":"Is VGG16 (trained initially on 2 objects using transfer learning) the\n  best model for this type of task? Currently, it is classifying unseen\n  objects as one of the two classes.\n\n\nFirstly the reason  for \"it is classifying unseen objects as one of the two classes \" is simply that, you only allow it to classify between the two classes, so what happens is that even if you show it an unknown object it is supposed to fit it on either of the classes and post its best prediction, what you should be do is that train it on 3 distinctive classes {object1, object2, unknownObject}, so you may correctly predict unknown objects, now this may be a bit problematic, and would require retraining the model, the other thing that you could do is that you should set a threshold, basically when you give it an unseen object it could give the prediction confidence as follows {75%, 25%} or maybe {51%, 49%} you should set a threshold here, that unless your model is more than 90-95% sure of the prediction you take it to be an unknown object, now i am in no way saying this should be your threshold value, you threshold could either be .9 \/ .95 as mentioned above, or it could even be .75, that is a hyper parameter and you should employ ways to figure that threshold out\n\n\nHow would you go about implementing this solution on the cloud (AWS,\n  Azure etc.)\n\n\nYou already have a flask server, just deploy the flask server on an AWS machine, and make it directly accessible via a static public external IP, hence you can post\/get a request to that specific IP and run your model from any interface","Q_Score":1,"Tags":"python,amazon-web-services,azure,tensorflow,keras","A_Id":53032153,"CreationDate":"2018-10-28T12:35:00.000","Title":"Classify New Objects in Images Live","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I apologize in advance because of my basic question, I googled it but I can not understand. I have a simple client server program in python, the server send a command to the client and receive the result from it. \nMy teacher asked me to make a .cfg file for it, my question is why should I do this? I mean what is the benefit of creating a .cfg file? I should run my program in cmd or in an IDE anyway, right?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":249,"Q_Id":53034065,"Users Score":1,"Answer":"A server listens in a certain IP and port. A client connects to an IP and port. Any other settings you can think of about some program configuration will do.\nWhat if you want to change those without touching the code. Maybe a user of your program wants to change the configuration and doesn't even know how to code. I bet the user knows how to edit a text file of settings.","Q_Score":0,"Tags":"python,client-server,configuration-files","A_Id":53034121,"CreationDate":"2018-10-28T17:08:00.000","Title":"Why have a .cfg file for a program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I apologize in advance because of my basic question, I googled it but I can not understand. I have a simple client server program in python, the server send a command to the client and receive the result from it. \nMy teacher asked me to make a .cfg file for it, my question is why should I do this? I mean what is the benefit of creating a .cfg file? I should run my program in cmd or in an IDE anyway, right?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":249,"Q_Id":53034065,"Users Score":1,"Answer":"Your teacher just wants you to decouple the configuration from actual code. That might not make sense to you in scope of your current task. But it makes a lot of sense in a \"real\" project.\nYou maybe want to publish your code to github or something similar in your company in order to share your code or to collaborate, but your code might need some private credentials, which you don't want to share (e.g. passwords) or you have some site specific configuration. So you gonna use seperate configuration files to include this data, in that case you only need to change a configuration in order to get the code working in your context, without having to edit anything in the source code intself.","Q_Score":0,"Tags":"python,client-server,configuration-files","A_Id":53034157,"CreationDate":"2018-10-28T17:08:00.000","Title":"Why have a .cfg file for a program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to convert Qt .ui files made using Qt Designer with pyside2-uic but the output starts with 2 garbage bytes then every other byte is a null. \nHere's the start of the output:\n\nFF FE 23 00 20 00 2D 00 2A 00 2D 00 20 00 63 00 6F 00 64 00 69 00 6E 00 67 00 3A 00 20 00 75 00 74 00 66 00 2D 00 38 00 20 00 2D 00 2A 00 2D 00 0D 00 0A 00 0D 00 0A 00 23 00 20 00 46 00 6F 00\n\nIf I remove the first 2 bytes and all the nulls the it works as expected. \nI'm using Python 3.7 and the newest version of pyside2, is there any way to get pyside2-uic to output a valid file without having to run it through another script to pull out all the garbage?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":832,"Q_Id":53035340,"Users Score":0,"Answer":"This bug(?) only occurs when pyside2-uic is run in powershell and the output is redirected to a file. \nIf using powershell use the -o option to specify an output file. Both methods work fine from a normal command prompt.","Q_Score":0,"Tags":"python,python-3.7,pyside2","A_Id":53051998,"CreationDate":"2018-10-28T19:30:00.000","Title":"pyside2-uic null bytes in output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to convert Qt .ui files made using Qt Designer with pyside2-uic but the output starts with 2 garbage bytes then every other byte is a null. \nHere's the start of the output:\n\nFF FE 23 00 20 00 2D 00 2A 00 2D 00 20 00 63 00 6F 00 64 00 69 00 6E 00 67 00 3A 00 20 00 75 00 74 00 66 00 2D 00 38 00 20 00 2D 00 2A 00 2D 00 0D 00 0A 00 0D 00 0A 00 23 00 20 00 46 00 6F 00\n\nIf I remove the first 2 bytes and all the nulls the it works as expected. \nI'm using Python 3.7 and the newest version of pyside2, is there any way to get pyside2-uic to output a valid file without having to run it through another script to pull out all the garbage?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":832,"Q_Id":53035340,"Users Score":0,"Answer":"In pyside2-uic mainwindow.ui -o MainWindow.py\nUse -o instead of >","Q_Score":0,"Tags":"python,python-3.7,pyside2","A_Id":63013213,"CreationDate":"2018-10-28T19:30:00.000","Title":"pyside2-uic null bytes in output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to convert Qt .ui files made using Qt Designer with pyside2-uic but the output starts with 2 garbage bytes then every other byte is a null. \nHere's the start of the output:\n\nFF FE 23 00 20 00 2D 00 2A 00 2D 00 20 00 63 00 6F 00 64 00 69 00 6E 00 67 00 3A 00 20 00 75 00 74 00 66 00 2D 00 38 00 20 00 2D 00 2A 00 2D 00 0D 00 0A 00 0D 00 0A 00 23 00 20 00 46 00 6F 00\n\nIf I remove the first 2 bytes and all the nulls the it works as expected. \nI'm using Python 3.7 and the newest version of pyside2, is there any way to get pyside2-uic to output a valid file without having to run it through another script to pull out all the garbage?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":832,"Q_Id":53035340,"Users Score":0,"Answer":"FYI, issue seems to be UTF-8 encoding (when using -o), vs. UTF-16 LE (output redirect in PowerShell).\nThis also matches to above ... every byte has a 00 with it (16 bit vs. 8 bit).","Q_Score":0,"Tags":"python,python-3.7,pyside2","A_Id":71505669,"CreationDate":"2018-10-28T19:30:00.000","Title":"pyside2-uic null bytes in output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I upgrade the current Python interpreter inside a venv to v3.7.1. Unfortunately 3.5.2 is out of date for some libraries I use, so I want to switch to 3.7.1.\nOption 1: is to update the interpreter inside my venv.\nOption 2: is to create a new venv with Python 3.7.1 as its interpreter and deploy the whole project with all its dependencies and tweaks anew?\nWhat is the typical way to port a Flask application to a newer interpreter?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21038,"Q_Id":53040930,"Users Score":0,"Answer":"I don't think it is possible to update an existing virtualenv (you'll find some way to do it on internet, but they basically create a new one \/ install a new python version and replace the version in the virtualenv).\nI would rather create a new virtualenv.\nFuthermore by conserving your current virtualenv you'll be able to rollback if you have any problem during the migration.\nSo : \n\nCreate a new git branch : myproject-python37\nCreate a new virtualenv\nMake the migration","Q_Score":5,"Tags":"python,flask,porting,python-3.7,python-venv","A_Id":53041438,"CreationDate":"2018-10-29T07:45:00.000","Title":"Upgrading Python to 3.7 inside venv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Odoo 10 CE on windows 7. In one custom module, I use import winreg but it gives me the error: ImportError: No module named winreg\nHow can I resolve this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":728,"Q_Id":53041565,"Users Score":1,"Answer":"if you are using python 2 try: import _winreg as winreg","Q_Score":0,"Tags":"python,odoo","A_Id":53041738,"CreationDate":"2018-10-29T08:35:00.000","Title":"ImportError: No module named winreg - Odoo10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there support within PyCharm\/CLion to activate a conda env which is being used to execute a given python script?  Currently, when I configure a conda env as the interpreter to be used to execute a given script, PyCharm\/CLion do not activate the environment before executing the script.  If this is not done, any environment variables settings defined in activate.d\/env_vars.[sh|bat] are not applied.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1204,"Q_Id":53043292,"Users Score":0,"Answer":"As of now, I believe there is not. I had issues with this as well. A workaround would be do re-install Anaconda and tick the \"add to path\" option, or you can launch PyCharm from the prompt in which you activate your conda environment.","Q_Score":7,"Tags":"python,pycharm,anaconda,conda,clion","A_Id":53069755,"CreationDate":"2018-10-29T10:16:00.000","Title":"conda env activation before running script in PyCharm\/CLion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Scikit documentation states that:\n\nMethod for initialization:\n\u2018k-means++\u2019 : selects initial cluster centers for k-mean clustering in a smart way to speed up convergence. See section Notes in k_init for more details.\nIf an ndarray is passed, it should be of shape (n_clusters, n_features) and gives the initial centers.\n\nMy data has 10 (predicted) clusters and 7 features. However, I would like to pass array of 10 by 6 shape, i.e. I want 6 dimensions of centroid of be predefined by me, but 7th dimension to be iterated freely using k-mean++.(In another word, I do not want to specify initial centroid, but rather control 6 dimension and only leave one dimension to vary for initial cluster)\nI tried to pass 10x6 dimension, in hope it would work, but it just throw up the error.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1975,"Q_Id":53045859,"Users Score":1,"Answer":"That is a very nonstandard variation of k-means. So you cannot expect sklearn to be prepared for every exotic variation. That would make sklearn slower for everybody else.\nIn fact, your approach is more like certain regression approaches (predicting the last value of the cluster centers) rather than clustering. I also doubt the results will be much better than simply setting the last value to the average of all points assigned to the cluster center using the other 6 dimensions only. Try partitioning your data based on the nearest center (ignoring the last column) and then setting the last column to be the arithmetic mean of the assigned data.\nHowever, sklearn is open source.\nSo get the source code, and modify k-means. Initialize the last component randomly, and while running k-means only update the last column. It's easy to modify it this way - but it's very hard to design an efficient API to allow such customizations through trivial parameters - use the source code to customize at his level.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,cluster-analysis,k-means","A_Id":53070814,"CreationDate":"2018-10-29T12:47:00.000","Title":"partially define initial centroid for scikit-learn K-Means clustering","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When i opened the iDEA and try to run my project , i got the below error.\n\n2:12 PM   Unknown Module Type\n                Cannot determine module type (\"PYTHON_MODULE\") for the following module:\"test\"\n                The module will be treated as a Unknown module.\n\nI dint make any changes as far i remember and the project was working until last week.\nAny help would be appreciated.\nRegards\nmadhu","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2819,"Q_Id":53051728,"Users Score":10,"Answer":".idea hidden folder is the project settings created by any Intellij IDEA IDE. The .idea folder must be clear -- no conflict in dependencies. E.g., for C++ cmake based project you need C++ ide such as Clion. Clion configures .idea based on Cmake projects. \nNow, your problem when you try to open Cmake C++ project into non C++ IDE (such as Pycharm), the .idea folder conflicts. And you see such above problems. \nTo fix this issue, just delete the .idea folder. And re open your IDE.","Q_Score":3,"Tags":"python,python-3.x,intellij-idea","A_Id":54300815,"CreationDate":"2018-10-29T18:30:00.000","Title":"Cannot determine module type (\"PYTHON_MODULE\") for the following 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 have a functioning code that will not show text on the buttons unless I click and hold the button. When releasing the button's text becomes blank again. I have tried solving this on other forums and \n\nplease note: THERE IS NOTHING WRONG WITH THE CODE ITSELF.\n\nThere is some sort of issue with how my laptop is running the code. I've tried reinstalling python3.7 as well as tcl-tk. I really don't know what else to do.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4342,"Q_Id":53052576,"Users Score":0,"Answer":"Updating doesn't work for everyone, I've read several posts of those for whom it didn't, and it didn't for me.\nBut since resizing the window works, there must be something that the tk instance does when resizing that makes everything appear again. \nSo you might check what happens there, and use that if your program detects if the OS is Mojave. Obviously this is not production worthy and only a fix for your own local projects or maybe some course project, but at least it's something.","Q_Score":3,"Tags":"python,python-3.x,tkinter,tkinter-layout","A_Id":53835116,"CreationDate":"2018-10-29T19:33:00.000","Title":"Tkinter buttons not showing text on my mac, although code works on others computers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to figure out the best way to install Python for my setup.\nI travel between school and home every day and I use a 2TB Portable Drive for my files.\nThe computers at school are locked so that you cannot install there, but I bet I can install things on my drive and use them fine, as well as use portable applications just fine.\nI was looking into ways of getting Python on both my drive and my computer so that my Python on my main computer will always work and my drive's Python is available when I want to work with it.\nOf course, the problem is that Python won't install like that. It bricks either installation first, and I saw a post on virtualenv, but it seems like it's more of a project by project based solution for isolating imports\/modules of sorts.\nI'm not too good with this stuff and installing tons of programs and waiting for them to uninstall only to not figure it out isn't my thing, so maybe someone on here knows what I'm talking about? Thanks.\nBy the way, yes, I want both installations to have the same pip stuff, the portable one I currently use at school is having a rough time installing things like json, requests and other fun stuff that is essential to my scripts.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":698,"Q_Id":53055093,"Users Score":0,"Answer":"I presume your OS is windows. \nTry to use cygwin (a linux emulator) that will allow you to install whatever utility you need on the cygwin installation directory (in your case would be your thumb drive). Launching than cygwin from your drive, you have a working environment for pretty much all the things you can imagine. If you export DISPLAY to your windows, than you can have GUI utilities, too.","Q_Score":0,"Tags":"python,pip,installation,portability","A_Id":53055144,"CreationDate":"2018-10-29T22:56:00.000","Title":"Portable Python Installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Opencensus to do some monitoring on a grpc server with 10 workers. My question is whether, when making a Tracer, the exporter for the tracer should be local or Global. IE\nthis is the server:\nserver = grpc.server(futures.ThreadPoolExecutor(max_workers=10))\nDo I do:\ntracer_module.Tracer(sampler=always_on.AlwaysOnSampler(), exporter=GLOBAL_EXPORTER)\nwhere:\nGLOBAL_EXPORTER = stackdriver_exporter.StackdriverExporter(transport=BackgroundThreadTransport))\nOR do I do:\ntracer_module.Tracer(sampler=always_on.AlwaysOnSampler(), exporter=stackdriver_exporter.StackdriverExporter(transport=BackgroundThreadTransport)))\nI have tried both and they work. The former will use a global exporter which should be more efficient (I would think) but the aggregation seems a bit odd (one call is 'aggregated with another). On the other hand, the second way makes a second exporter (which is short lived, since it will exist only for that call) and does seem to export correctly. Question is more what is more correct from a system perspective. IE for the second option does creating stackdriver_exporter.StackdriverExporter(transport=BackgroundThreadTransport) invalidate a different exporter (which was created in a different thread)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":161,"Q_Id":53055561,"Users Score":1,"Answer":"You should use a global exporter.  It was not intended for a new export thread to be created for every Tracer.  There should be one background thread running which handles all exporting to StackDriver.\nAs for the aggregation, it shouldn't be aggregating all the spans together.  That may be a bug in the StackDriver UI (there are a number of known issues).","Q_Score":2,"Tags":"python,python-3.x,grpc,stackdriver,opencensus","A_Id":53091798,"CreationDate":"2018-10-30T00:01:00.000","Title":"opencensus exporter - one global or per thread?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use Python console in PyCharm, when running the code, there is a \"Special Variables\" window appears on the right hand side of Python Console, how can I permanently turn it off?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3367,"Q_Id":53062242,"Users Score":0,"Answer":"File > Settings > Build, Execution, Development > Console","Q_Score":9,"Tags":"python,pycharm","A_Id":64576377,"CreationDate":"2018-10-30T10:28:00.000","Title":"How to turn off the \"Special Variables\" window in Python Console of PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to calculate the mean of a certain column in DataFrame, so that means for each row is calculated excluding the value of the row for which it's calculated. \nI know I can iterate each row by index, dropping each row by index in every iteration, and then calculating mean. I wonder if there's a more efficient way of doing it.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":336,"Q_Id":53062585,"Users Score":0,"Answer":"you can dataframe[\"ColumnName\"].mean() for single column, or dataframe.describe() for all columns","Q_Score":0,"Tags":"python,pandas,dataframe,machine-learning,data-science","A_Id":53062724,"CreationDate":"2018-10-30T10:45:00.000","Title":"Calculate mean of column for each row excluding the row for which mean is calculated","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a system to simplify our image library which grows anywhere from 7k to 20k new pictures per week.  The specific application is identifying which race cars are in pictures (all cars are similar shapes with different paint schemes).  I plan to use python and tensorflow for this portion of the project.\nMy initial thought was to use image classification to classify the image by car; however, there is a very high probability of the picture containing multiple cars.  My next thought is to use object detection to detect the car numbers (present in fixed location on all cars [nose, tail, both doors, and roof] and consistent font week to week).  Lastly there is the approach of object recognition of the whole car. This, on the surface, seems to be the most practical; however, the paint schemes change enough that it may not be.\nWhich approach will give me the best results?  I have pulled a large number of images out for training, and obviously the different methods require very different training datasets.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":53063944,"Users Score":1,"Answer":"The best approach would be to use all 3 methods as an ensamble. You train all 3 of those models, and pass the input image to all 3 of them. Then, there are several ways how you can evaluate output. \n\nYou can sum up the probabilities for all of the classes for all 3 models and then draw a conclusion based on the highest probability.\nYou can get prediction from every model and decide based on number of votes: 1. model - class1, 2. model - class2, 3. model - class2 ==> class2\nYou can do something like weighted decision making. So, let's say that first model is the best and the most robust one but you don't trust it 100% and want to see what other models will say. Than you can weight the output of the first model with 0.6, and output of other two models with weight of 0.2.\n\nI hope this helps :)","Q_Score":0,"Tags":"python,tensorflow,computer-vision,object-detection,image-recognition","A_Id":53064651,"CreationDate":"2018-10-30T12:06:00.000","Title":"Racecar image tagging","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python 2 there is a function thread.interrupt_main(), which raises a KeyboardInterrupt exception in the main thread when called from a subthread.\nThis is also available through _thread.interrupt_main() in Python 3, but it's a low-level \"support module\", mostly for use within other standard modules.\nWhat is the modern way of doing this in Python 3, presumably through the threading module, if there is one?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":5980,"Q_Id":53064280,"Users Score":9,"Answer":"Well raising an exception manually is kinda low-level, so if you think you have to do that just use _thread.interrupt_main() since that's the equivalent you asked for (threading module itself doesn't provide this).\nIt could be that there is a more elegant way to achieve your ultimate goal, though. Maybe setting and checking a flag would be already enough or using a threading.Event like @RFmyD already suggested, or using message passing over a queue.Queue. It depends on your specific setup.","Q_Score":10,"Tags":"python,python-3.x,multithreading,python-multithreading,keyboardinterrupt","A_Id":53073968,"CreationDate":"2018-10-30T12:25:00.000","Title":"Equivalent of thread.interrupt_main() in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python 2 there is a function thread.interrupt_main(), which raises a KeyboardInterrupt exception in the main thread when called from a subthread.\nThis is also available through _thread.interrupt_main() in Python 3, but it's a low-level \"support module\", mostly for use within other standard modules.\nWhat is the modern way of doing this in Python 3, presumably through the threading module, if there is one?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5980,"Q_Id":53064280,"Users Score":0,"Answer":"You might want to look into the threading.Event module.","Q_Score":10,"Tags":"python,python-3.x,multithreading,python-multithreading,keyboardinterrupt","A_Id":53064470,"CreationDate":"2018-10-30T12:25:00.000","Title":"Equivalent of thread.interrupt_main() in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a general tensorflow question about when to use estimators. I feel sometimes estimators are not convenient to build something, since we need to meet some fixed requirements when building the graph. On the other hand, using lower level api can be tedious sometimes. Therefore, I want to ask when it is proper to use estimators and when it is not. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":52,"Q_Id":53066376,"Users Score":1,"Answer":"This is a very opinionated answer but I will still write it:\nThe Estimator-API was developed to simplify building and sharing models. You could compare it with Keras and in fact Estimators is built with tf.keras.layers so one could say it is a simplification of a simplification.\nThis is obviously good for beginners or people who come from other fields (as people working with ML often do) but can also delimit the things you can do.\nAs a general rule of thumb I would use Estimators if you want to work on or share a model with people that do not have a good CS background but want to get going either way.","Q_Score":2,"Tags":"python,tensorflow","A_Id":53066538,"CreationDate":"2018-10-30T14:18:00.000","Title":"When to use tensorflow estimators?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python program which I have made work in both Python 2 and 3, and it has more functionality in Python 3 (using new Python 3 features).\nMy script currently starts #!\/usr\/bin\/env python, as that seems to be the mostly likely name for a python executable. However, what I'd like to do is \"if python3 exists, use that, if not use python\".\nI would prefer not to have to distribute multiple files \/ and extra script (at present my program is a single distributed python file).\nIs there an easy way to run the current script in python3, if it exists?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":53066830,"Users Score":0,"Answer":"Try with version_info from sys package","Q_Score":0,"Tags":"python,python-3.x","A_Id":53067159,"CreationDate":"2018-10-30T14:41:00.000","Title":"Execute current Python script in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am doing a project where I want to build a model that estimates the number of retweets at a given time for a given tweet bearing a certain keyword, so that when a new tweet with the same keyword comes in, I can track its number of retweets and see if there is any anomaly.  For that, on top of collecting a large number of tweets with that certain keyword for modeling, I need to know for each of the tweets what was the number of retweets on day 1, day 2, etc (the unit of time is arbitrary here, can be in days or in minutes) since it was created.  \nI've done some research on stackoverflow, but I have not seen a solution for this particular problem.  I understand that twitter API allows you to search for tweets with keywords, but it only gives you the tweets' current number of retweets but not the historical performance.  \nI would really appreciate it if anyone can point me to the right direction.  Thank you very much!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":270,"Q_Id":53068167,"Users Score":0,"Answer":"There's no API method in any of Twitter's API tiers (standard, premium or enterprise) that would enable you to do this. You'd need to have already been listening for the Tweets, record the Tweet IDs, check them every day for total engagement numbers, and then record the differential every day.","Q_Score":1,"Tags":"python,api,twitter,web-scraping","A_Id":53071904,"CreationDate":"2018-10-30T15:49:00.000","Title":"Get Historical Tweet Metadata from Twitter API 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 an account on Gator.\nI am trying to run a php script as follows\n;$command = escapeshellcmd('.\/simple.py 2>&1');\n$output = shell_exec($command);\necho $output\nI would like to get as output anything that the python script prints to screen,  but the output is empty no matter what I try (I use standard print in python","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":498,"Q_Id":53068529,"Users Score":0,"Answer":"$command = escapeshellcmd('.\/simple.py 2>&1');\n\nescapeshellcmd is a form of surrender, it's php stupidity, it gets used as a DWIM band-aid when the programmer has lost control of the command-line.\nIt's breaking your stderr redirection.\nUse escapeshellarg where you need to escape shell stuff.\n$command = escapeshellarg('.\/simple.py') . ' ' . '2>&1';","Q_Score":0,"Tags":"php,python","A_Id":53071635,"CreationDate":"2018-10-30T16:10:00.000","Title":"How to call python from php on a remote 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'd like to compare variables in a Keras model with those from a TensorFlow checkpoint. I can get the TF variables like this:\nvars_in_checkpoint = tf.train.list_variables(os.path.join(\".\/model.ckpt\"))\nHow can I get the Keras variables to compare from my model?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2810,"Q_Id":53070199,"Users Score":0,"Answer":"To get the variable's name you need to access it from the weight attribute of the model's layer. Something like this:\nnames = [weight.name for layer in model.layers for weight in layer.weights]\nAnd to get the shape of the weight:\nweights = [weight.shape for weight in model.get_weights()]","Q_Score":2,"Tags":"python-3.x,tensorflow,keras","A_Id":66114558,"CreationDate":"2018-10-30T17:56:00.000","Title":"Get list of Keras variables","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to compare variables in a Keras model with those from a TensorFlow checkpoint. I can get the TF variables like this:\nvars_in_checkpoint = tf.train.list_variables(os.path.join(\".\/model.ckpt\"))\nHow can I get the Keras variables to compare from my model?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2810,"Q_Id":53070199,"Users Score":2,"Answer":"You can get the variables of a Keras model via model.weights (list of tf.Variable instances).","Q_Score":2,"Tags":"python-3.x,tensorflow,keras","A_Id":53163169,"CreationDate":"2018-10-30T17:56:00.000","Title":"Get list of Keras variables","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use Tkinter with AWS Lambda,I copied the tkinter folder from the lib folder: C:\\Users\\AGOJSO\\AppData\\Local\\Programs\\Python\\Python36\\lib\\tkinter\nAnd then made a zip file containing the tkinter folder and lambda_function.py, I made a ZIP file and uploaded it to AWS Lambda.\nThen on top of the code i wrote:\nfrom \/tkinter import *\ntk = Tk()\ngetting this error:\n\nSyntax error in module 'lambda_function': invalid syntax (lambda_function.py, line 4)\n\nHelp please.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":649,"Q_Id":53070290,"Users Score":0,"Answer":"You aren't going to be able to run tkinter on AWS lambda. Tkinter requires a display.","Q_Score":1,"Tags":"python,amazon-web-services,tkinter,dependencies,aws-lambda","A_Id":53070425,"CreationDate":"2018-10-30T18:01:00.000","Title":"Add Tkinter to AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want output from my Django server as well as Django management commands to all be written to the same file.  This is easy to set up in the settings.py file, but are there any concerns with thread safety or file locking with a management command (which is run from the command line) trying to write to the same file as the main Django server (running from wsgi)?  Any concerns with this set up running under Windows vs Linux or other operating systems?\nIn case there are different answers in different versions:\npython 3.4\nDjango 1.11\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":53070767,"Users Score":0,"Answer":"An alternative would be for all logging to be sent to a queue (e.g. a Redis queue) and then a single process reads the queue and writes records to file. There could be much more to think about here, so this may or may not be appropriate for your needs, but it would eliminate file locking.","Q_Score":0,"Tags":"python,django,logging","A_Id":54849783,"CreationDate":"2018-10-30T18:33:00.000","Title":"Django logging thread safety between server and commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have trouble understanding why python returns different results for these 2 statements:\n-1 \/\/ 3\/4  and -1 \/\/ 0.75\nThe first one returns -0.25 and the second on returns -2.\nThe way i understand it, the \/ operator is executed before \/\/ , thus those 2 statements should have the same result.\nedit:\nI was referring to a document provided by my university. I misinterpreted that. Official python documentation proves me wrong.\nThanks for all the quick answers.","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1481,"Q_Id":53072731,"Users Score":0,"Answer":"\/\/ is essentially an operator for flooring division.\nSo 1 \/\/ 0.75 is essentially flooring 1.333 which is 1\n-1 \/\/ 0.75 is essentially flooring -1.333 which is -2.\nHope this makes sense.","Q_Score":6,"Tags":"python,python-3.x,operators","A_Id":53072823,"CreationDate":"2018-10-30T20:51:00.000","Title":"operator precedence of floor division and division","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have trouble understanding why python returns different results for these 2 statements:\n-1 \/\/ 3\/4  and -1 \/\/ 0.75\nThe first one returns -0.25 and the second on returns -2.\nThe way i understand it, the \/ operator is executed before \/\/ , thus those 2 statements should have the same result.\nedit:\nI was referring to a document provided by my university. I misinterpreted that. Official python documentation proves me wrong.\nThanks for all the quick answers.","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":1481,"Q_Id":53072731,"Users Score":1,"Answer":"According to documentation, Multiplication *, matrix multiplication @, division \/, floor division \/\/, remainder % all have same precedence.\nWhen two operators have the same precedence, associativity helps to determine the order of operations.\nNow regarding your question; both \/ and \/\/ have same precedence, and if both of them are present in an expression, left one is evaluated first based on left-to-right associativity.","Q_Score":6,"Tags":"python,python-3.x,operators","A_Id":53072806,"CreationDate":"2018-10-30T20:51:00.000","Title":"operator precedence of floor division and division","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have trouble understanding why python returns different results for these 2 statements:\n-1 \/\/ 3\/4  and -1 \/\/ 0.75\nThe first one returns -0.25 and the second on returns -2.\nThe way i understand it, the \/ operator is executed before \/\/ , thus those 2 statements should have the same result.\nedit:\nI was referring to a document provided by my university. I misinterpreted that. Official python documentation proves me wrong.\nThanks for all the quick answers.","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":1481,"Q_Id":53072731,"Users Score":1,"Answer":"no, they have the same precedence, so they're evaluated from left to right.\n-1\/\/3 is rounded (to the least integer) integer division, so you get -1 divided by 4: 0.25\nWhen you have doubts, it doesn't cost much to throw in a couple of parentheses.","Q_Score":6,"Tags":"python,python-3.x,operators","A_Id":53072792,"CreationDate":"2018-10-30T20:51:00.000","Title":"operator precedence of floor division and division","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have trouble understanding why python returns different results for these 2 statements:\n-1 \/\/ 3\/4  and -1 \/\/ 0.75\nThe first one returns -0.25 and the second on returns -2.\nThe way i understand it, the \/ operator is executed before \/\/ , thus those 2 statements should have the same result.\nedit:\nI was referring to a document provided by my university. I misinterpreted that. Official python documentation proves me wrong.\nThanks for all the quick answers.","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":1481,"Q_Id":53072731,"Users Score":1,"Answer":"The way i understand it, the \/ operator is executed before \/\/ , thus those 2 statements should have the same result.\n\nYour understanding is incorrect. \/ and \/\/ have the same precedence and have left associativity, meaning that Python performs the leftmost operation first - in your case, the \/.","Q_Score":6,"Tags":"python,python-3.x,operators","A_Id":53072783,"CreationDate":"2018-10-30T20:51:00.000","Title":"operator precedence of floor division and division","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have table called EMP that has a column deptno with the values 10,20,30,40.\nso requirement is first create list\/diction which deptno number we need data for?\nsay we need data only for Deptno 10 & 20 and  each of these deptno should go into their own respective flat files say empdep10.csv and empdept20.csv\nI was hoping to get some help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":53073235,"Users Score":0,"Answer":"You can use the format function to make queries more dynamic. For example:\n\"\"\"\nSELECT *\nFROM sdfkjshdf\nWHERE sdkfags LIKE '%{}%'\n\"\"\".format(my_variable)\nThen use the same function when exporting the result set to a file so you can call the file something based on the parameters of the where function.","Q_Score":0,"Tags":"python-3.x,jupyter-notebook","A_Id":53073273,"CreationDate":"2018-10-30T21:35:00.000","Title":"based on Oracle Query where clause create dynamic flat files using Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to connect two computers and send messages between them,and I'm not sure why the socket module doesn't work for me.So is there any other ways to connect two computers?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":200,"Q_Id":53075044,"Users Score":2,"Answer":"If you wanna solve this problem,\nFirst thing , you should check two computer's network connecting, \nin terminal you can use one computer of yours to typing ping ${target_computer_address}and check terminal's echo to make sure two computer network connection is working.\nSecond thing , you can use python to open a tcp port to listen and print recv data in screen ,and in other computer telnet previous computer ip:port just typing someting, make sure python can print you's typing character correct.","Q_Score":0,"Tags":"python,python-3.x,connection","A_Id":53075143,"CreationDate":"2018-10-31T01:28:00.000","Title":"How to connect two computers using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The file structure looks like this:\n\/email1\/spam\n\/email2\/spam\n\/email3\/spam\n...\nNow, copy all files under all 'spam' directories to a new directory called \/email_data\/spam\nI tried to use shutil.copytree, but it only copy the first directory (copytree requires the destination must not exists).\nThen I tried distutils.dir_util.copy_tree, it works, but I don't know why everytime after its copy, there will be some duplicated files. (e.g. spam_email.txt, spam_email_1.txt). There should be 15045 files, but the code copy 16545 which 1500 more...","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":700,"Q_Id":53075402,"Users Score":0,"Answer":"Finally, I found rsync is very easy to use, as metatoaster said, just use os.system(command).\nActually distutils.dir_util.copy_tree works as well, there is no duplication error of copy, the source directory itself has duplicated files...","Q_Score":0,"Tags":"python,copy","A_Id":53078361,"CreationDate":"2018-10-31T02:23:00.000","Title":"How to use python to copy full directory and its contents overwrittenly?","Data Science and Machine Learning":0,"Database and SQL":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 are getting an extra column 'int64_field_0' while loading data from CSV to BigTable in GCP. Is there any way to avoid this first column. We are using the method load_table_from_file and setting option AutoDetect Schema as True. Any suggestions please. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":53077155,"Users Score":0,"Answer":"Per the comments, using Pandas Data Frame's pd.to_csv(filename, index=false) resolved the issue.","Q_Score":0,"Tags":"python,csv","A_Id":55940953,"CreationDate":"2018-10-31T05:57:00.000","Title":"Google Cloud Platform int64_field_0","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Should every Python function (or method) check for the validity of its arguments? \nNot just the type, but if the values are within valid range, the dimensions are as expected, etc?\nOr can just have functions that simply expect \"adult-like\" well-behaved behavior from other functions, programmer etc? And just mention in the docstring what is expected, and simply check for validity of user-input arguments at the user-facing function?\nIn the case of 'private' methods, it appears to me that we don't need to check for validity, but what about other methods\/functions?\nIf we are too strict about this and check for everything, wouldn't the code be full of boring decorator type code? Is that fine?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":616,"Q_Id":53077647,"Users Score":1,"Answer":"I think this can be applied in general and not just to Python, but all the people I know always followed the philosophy that if the worst that can happen is an error message, assume that the input is going to be correct.\nUnless your code is running a task where even though you've written it as safely as you can, it can still destroy something, in which case always check.","Q_Score":3,"Tags":"python,function,validation,methods,arguments","A_Id":53077944,"CreationDate":"2018-10-31T06:38:00.000","Title":"Validity check of function arguments in Python: should every function do it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Should every Python function (or method) check for the validity of its arguments? \nNot just the type, but if the values are within valid range, the dimensions are as expected, etc?\nOr can just have functions that simply expect \"adult-like\" well-behaved behavior from other functions, programmer etc? And just mention in the docstring what is expected, and simply check for validity of user-input arguments at the user-facing function?\nIn the case of 'private' methods, it appears to me that we don't need to check for validity, but what about other methods\/functions?\nIf we are too strict about this and check for everything, wouldn't the code be full of boring decorator type code? Is that fine?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":616,"Q_Id":53077647,"Users Score":0,"Answer":"I've seen a lot of different approaches. The most extreme one was that the docstrings contained formal declaration of the parameter types and ranges (also return values). The application checked the parameters during runtime based on these docstrings and threw an exception if something was wrong with them. This was implemented using metaprogramming and could be disabled for production runs. \nIt wasn't really Python any more, ducktyping wasn't possible either. It was more like a statically typed language without a helping compiler. You still had to wait until it breaks during runtime.\nI've also seen applications that don't do any checks and just run comprehensive unit tests. If they pass it's assumed the parameters are ok as well.\nPersonally I also cover most things with unit tests but in critical sections I use asserts. I also take extra care in methods that receive input from the user.\nHope that helps","Q_Score":3,"Tags":"python,function,validation,methods,arguments","A_Id":53077833,"CreationDate":"2018-10-31T06:38:00.000","Title":"Validity check of function arguments in Python: should every function do it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some code that just makes some random noise using the numpy random normal distribution function and then I add this to a numpy array that contains an image of my chosen object. I then have to clip the array to between values of -1 and 1.\nI am just trying to get my head round whether I should be adding this to the array and clipping or multiplying the array by the noise and clipping?\nI can't conceptually understand which I should be doing. Could someone please help?\nThanks","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":424,"Q_Id":53079698,"Users Score":1,"Answer":"Well as you have said it yourself, the problem is that you don't know what you want.\nBoth methods will increase the entropy of the original data.\nWhat is the purpose of your task?\nIf you want to simulate something like sensor noise, the addition will do just fine.\nYou can try both and observe what happens to the distribution of your original data set after the application.","Q_Score":0,"Tags":"python,numpy,noise,conceptual","A_Id":53079992,"CreationDate":"2018-10-31T09:02:00.000","Title":"adding noise to an array. Is it addition or multiplication?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some code that just makes some random noise using the numpy random normal distribution function and then I add this to a numpy array that contains an image of my chosen object. I then have to clip the array to between values of -1 and 1.\nI am just trying to get my head round whether I should be adding this to the array and clipping or multiplying the array by the noise and clipping?\nI can't conceptually understand which I should be doing. Could someone please help?\nThanks","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":424,"Q_Id":53079698,"Users Score":2,"Answer":"It depends what sort of physical model you are trying to represent; additive and multiplicative noise do not correspond to the same phenomenon. Your image can be considered a variable that changes through time. Noise is an extra term that varies randomly as time passes. If this noise term depends on the state of the image in time, then the image and the noise are correlated and noise is multiplicative. If the two terms are uncorrelated, noise is additive.","Q_Score":0,"Tags":"python,numpy,noise,conceptual","A_Id":53080222,"CreationDate":"2018-10-31T09:02:00.000","Title":"adding noise to an array. Is it addition or multiplication?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training a neural network model, and my model fits the training data well. The training loss decreases stably. Everything works fine. However, when I output the weights of my model, I found that it didn't change too much since random initialization (I didn't use any pretrained weights. All weights are initialized by default in PyTorch). All dimension of the weights only changed about 1%, while the accuracy on training data climbed from 50% to 90%.\nWhat could account for this phenomenon? Is the dimension of weights too high and I need to reduce the size of my model? Or is there any other possible explanations?  \nI understand this is a quite broad question, but I think it's impractical for me to show my model and analyze it mathematically here. So I just want to know what could be the general \/ common cause for this problem.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":157,"Q_Id":53086166,"Users Score":5,"Answer":"There are almost always many local optimal points in a problem so one thing you can't say specially in high dimensional feature spaces is which optimal point your model parameters will fit into. one important point here is that for every set of weights that you are computing for your model to find a optimal point, because of real value weights,  there are infinite set of weights for that optimal point, the proportion of weights to each other is the only thing that matters, because you are trying to minimize the cost, not finding a unique set of weights with loss of 0 for every sample. every time you train you may get different result based on initial weights. when weights change very closely with almost same ratio to each others this means your features are highly correlated(i.e. redundant) and since you are getting very high accuracy just with a little bit of change in weights, only thing i can think of is that your data set classes are far away from each other. try to remove features one at a time, train and see results if accuracy was good continue to remove another one till you hopefully reach to a 3 or 2 dimensional space which you can plot your data and visualize it to see how data points are distributed and make some sense out of this.\nEDIT: Better approach is to use PCA for dimensionality reduction instead of removing one by one","Q_Score":1,"Tags":"python,machine-learning,neural-network,torch","A_Id":53091954,"CreationDate":"2018-10-31T14:50:00.000","Title":"What's the reason for the weights of my NN model don't change a lot?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"On my package manager for canopy, every time I try to download opencv it downgrades several other important packages. I am then not able to upgrade those same packages or run my code. How can I download opencv without downgrading my other packages?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":113,"Q_Id":53088354,"Users Score":1,"Answer":"You haven't provided any version or platform information. But perhaps you are using an old Canopy version (current is 2.1.9), or perhaps you are using the subscriber-only \"full\" installer, which is only intended for airgapped or other non-updateable systems. Otherwise, the currently supported version of opencv is 3.2.0 (build 3.2.0-4) which depends on numpy 1.13.3, which is the currently supported version of numpy.","Q_Score":0,"Tags":"python-2.7,opencv,package,enthought,canopy","A_Id":53088607,"CreationDate":"2018-10-31T16:44:00.000","Title":"Why does opencv on Canopy downgrade numpy, scipy, and other packages when I try to install it?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the recommended way to run Flask app (e.g. via Gunicorn?) and how to make it up and running automatically after linux server (redhat) restart?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":636,"Q_Id":53092810,"Users Score":0,"Answer":"have you looked at supervisord?  it works reasonably well and handles restarting processes automatically if they fail as well as looking after error logs nicely","Q_Score":0,"Tags":"python,linux,flask,redhat","A_Id":53092907,"CreationDate":"2018-10-31T22:26:00.000","Title":"How to make Flask app up and running after server restart?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am making a convolutional network model with which I want to classify EEG data. The data is an experiment where participants are evoked with images of 3 different classes with 2 subclasses each. To give a brief explanation about the dataset size, a subclass has \u00b1300 epochs of a given participant (this applies for all the subclasses).\n\nObject \nColor\nNumber\n\nNow my question is:\nI have 5 participants in my training dataset, I took 15% of each participants' data and put it in the testing dataset. Can I consider the 15% as unseen data even though the same participant was used to train the model on?\nAny input is welcome!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":174,"Q_Id":53093576,"Users Score":2,"Answer":"It depends on what you want to test. A test set is used to estimate the generalization (i.e. performance on unseen data). So the question is:\n\nDo want to estimate the generalization to unseen data from the same participants (whose data was used to train the classifier)?\nOr do you want to estimate the generalization to unseen participants (the general population)?\n\nThis really depends on you goal or the claim you are trying to make. I can think of situations for both approaches:\n\nThink of BCIs which need to be retrained for every user. Here, you would test on data from the same individual.\nOn the other hand, if you make a very general claim (e.g. I can decode some relevant signal from a certain brain region across the population) then having a test set consisting of participants which were not included in the training set would lend much stronger support to your claim. (The question is whether this works, though.)","Q_Score":0,"Tags":"python,deep-learning,neuroscience","A_Id":53114849,"CreationDate":"2018-11-01T00:13:00.000","Title":"Deeplearning with electroencephalography (EEG) data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am current working on a real time face detection project.\nWhat I have done is that I capture the frame using cv2, do detection and then show result using cv2.imshow(), which result in a low fps. \nI want a high fps video showing on the screen without lag and a low fps detection bounding box overlay.\nIs there a solution to show the real time video stream (with the last detection result bounding box), and once a new detection is finished, show the new bounding box and the background was not delayed by the detection function.\nAny help is appreciated!\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":413,"Q_Id":53094695,"Users Score":0,"Answer":"A common approach would be to create a flag that allows the detection algorithim to only run once every couple of frames and save the predicted reigons of interest to a list, whilst creating bounding boxes for every frame.\nSo for example you have a face detection algorithim, process every 15th frame to detect faces, but in every frame create a bounding box from the predictions. Even though the predictions get updated every 15 frames.\nAnother approach could be to add an object tracking layer. Run your heavy algorithim to find the ROIs and then use the object tracking library to hold on to them till the next time it runs the detection algorithim.\nHope this made sense.","Q_Score":0,"Tags":"python,cv2","A_Id":53094747,"CreationDate":"2018-11-01T03:08:00.000","Title":"cv2 show video stream & add overlay after another function finishes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using keras sequential model for binary classification. But My data is unbalanced. I have 2 features column and 1 output column(1\/0). I have 10000 of data. Among that only 20 results in output 1, all others are 0. Then i have extended the data size to 40000. Now also only 20 results in output 1, all others are 0. Since the data is unbalanced(0 dominates 1), which neural network will be better for correct prediction?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":53095061,"Users Score":0,"Answer":"First of all, two features is a really small amount. Neural Networks are highly non-linear models with a really really high amount of freedom degrees, thus if you try to train a network with more than just a couple of networks it will overfit even with balanced classes. You can find more suitable models for a small dimensionality like Support Vector Machines in scikit-learn library.\nNow about unbalanced data, the most common techniques are Undersampling and Oversampling. Undersampling is basically training your model several times with a fraction of the dataset, that contains the non dominant class and a random sample of the dominant so that the ratio is acceptable, where as oversampling consist on generating artificial data to balance the classes. In most cases undersampling works better.\nAlso when working with unbalanced data it's quite important to choose the right metric based on what is more important for the problem (is minimizing false positives more important than false negatives, etc).","Q_Score":0,"Tags":"python-3.x,keras","A_Id":53096595,"CreationDate":"2018-11-01T04:04:00.000","Title":"How to choose the right neural network in a binary classification problem for a unbalanced data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a code in Oracle which is optimized and create weekly data. The problem is I also want my Oracle code trigger Python to run and create data in Python and save. Is there any possibility to execute my Python code automatically?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4810,"Q_Id":53096146,"Users Score":0,"Answer":"i use windows task planner with a .bat script to run my python code everyday.","Q_Score":1,"Tags":"python,oracle,optimization,triggers","A_Id":56313703,"CreationDate":"2018-11-01T06:22:00.000","Title":"How can I trigger a Python code automatically?","Data Science and Machine Learning":0,"Database and SQL":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 code in Oracle which is optimized and create weekly data. The problem is I also want my Oracle code trigger Python to run and create data in Python and save. Is there any possibility to execute my Python code automatically?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4810,"Q_Id":53096146,"Users Score":0,"Answer":"you can use crons jon, task schedule to run the script in particular time. If you want to run the script as service you can use celery and crontab module.","Q_Score":1,"Tags":"python,oracle,optimization,triggers","A_Id":53096355,"CreationDate":"2018-11-01T06:22:00.000","Title":"How can I trigger a Python code automatically?","Data Science and Machine Learning":0,"Database and SQL":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 uploads files to Google Drive. I want to upload python files. I can do it manually and have it keep the file as .py correctly (and it's previewable), but no matter what mimetypes I try, I can't get my program to upload it correctly. It can upload the file as a .txt or as something GDrive can't recognize, but not as a .py file. I can't find an explicit mimetype for it (I found a reference for text\/x-script.python but it doesn't work as an out mimetype).\nDoes anyone know how to correctly upload a .py file to Google Drive using REST?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":690,"Q_Id":53096788,"Users Score":-1,"Answer":"Also this is a valid Python mimetype: text\/x-script.python","Q_Score":2,"Tags":"python,rest,google-drive-api,mime-types","A_Id":71426330,"CreationDate":"2018-11-01T07:22:00.000","Title":"What Is the Correct Mimetype (in and out) for a .Py File for Google Drive?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been refreshing my knowledge of data structures and algorithms using a book. I came across some sample code in the book, including some run time analysis values that I cannot seem to make sense of. I don't know if I am overthinking this or I am missing something extremely simple. Please help me out.\n\nThis is the case where they explain the logic behind adding an element at a specific index in a list. I get the logic, it is pretty simple. Move all the elements, starting with the rightmost one, one index to the right to make space for the element at the index. The code for this in the book is given by:\nfor j in range(self._n, k, \u22121): \n    self._A[j] = self._A[j\u22121]\nWhat I do not get is the range of the loop. Technically, self._n is equivalent to len(list) (an internal state maintained by the list). And if you start at len(list), you are immediately at an IndexOutOfBoundError. Secondly, even if that were not true, the loop replaces n with n-1. Nowhere does it actually move n to n+1 first, so that value is lost. Am I missing something here?  I actually tried these conditions out on the Python interpreter and they seem to validate my understanding.\nSome of the run time analyses for list operations seems to confuse me. For example:\ndata.index(value) --> O(k+1)\nvalue in data --> O(k+1)\ndata1 == data2 (similarly !=, <, <=, >, >=) --> O(k+1)\ndata[j:k] --> O(k\u2212j+1)\nI do not get why the +1 at the end of each running time analysis. Let us consider the data.index(value) operation, which basically returns the first index at which a certain value is found. At the worst case, it should iterate through all n elements of the list, but if not, if the search finds something at index k, then it returns from there. Why the O(k+1) there? The same logic applies to the other cases too, especially the list slicing. When you slice a list, isn't it just O(k-j)? On the contrary, the actual indices are j to k-1. \n\nThis understanding should be quite elementary and I really feel silly not being able to understand it. Or I don't know if there are genuine errata in the book and I understand it correctly. Could someone please clarify this for me? Help is much appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":53098111,"Users Score":0,"Answer":"For the first case, I think the assumption is that you have a list of fixed maximum length and you are supposed to lose the last datapoint. Also, are you certain that self._n == len(n) and not self._n == len(n)-1?\nFor the second case, as far as I understand, O(k+1) is the same as O(k), so it doesn't make sense to say O(k+1). But again if we really want to know how someone may count up to k+1... I would guess that guy is counting starting from 0. So to go from 0th to the kth index will take k+1 operations.\nThis is just an opinion, and an uniformed one, so please take it with a tablespoon of salt. I think that book is no good man.","Q_Score":1,"Tags":"python,python-3.x,algorithm,big-o","A_Id":53098187,"CreationDate":"2018-11-01T09:08:00.000","Title":"Questions regarding code in a Data Structures and Algorithms book","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I am running python 3.6.5 on a school computer the most things are heavily restricted to do on a school computer and i can only use python on drive D. I cannot use batch either. I had python 2.7 on it last year until i deleted all the files and installed python 3.6.5 after that i couldn't double click on a .py file to open it as it said continue using E:\\Python27\\python(2.7).exe I had the old python of a USB which is why it asks this but know i would like to change that path the the new python file so how would i do that in windows","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":53098459,"Users Score":0,"Answer":"Just open your Python IDE and open the file manually.","Q_Score":0,"Tags":"python,windows,directory","A_Id":53098745,"CreationDate":"2018-11-01T09:31:00.000","Title":"Running a python file in windows after removing old python files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How do I install pygame for python 3.7.0  on windows 7(64-bit)? I tried using the pip install, and it always shows 'pip' is not recognized as an internal or external command, operable program, or batch file. I watched many videos and they all show that in order to install pygame you need to use pip install. \nWhat should I do? How should I download pip or is there another way to install pygame?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2587,"Q_Id":53101523,"Users Score":0,"Answer":"Re-install python and click the choose to add to PATH at the bottom of the first install screen.","Q_Score":0,"Tags":"python,windows,pygame","A_Id":53102857,"CreationDate":"2018-11-01T12:43:00.000","Title":"How to install pygame for python 3.7.0 on windows 7(64-bit)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I install pygame for python 3.7.0  on windows 7(64-bit)? I tried using the pip install, and it always shows 'pip' is not recognized as an internal or external command, operable program, or batch file. I watched many videos and they all show that in order to install pygame you need to use pip install. \nWhat should I do? How should I download pip or is there another way to install pygame?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2587,"Q_Id":53101523,"Users Score":1,"Answer":"When you installed python you were able to choose to add it to the PATH system variable, if you have not done this, pip will not work unless you navigate to its' location and run the command prompt from there.\nYou can search for pip.exe in windows to find it and then right click it and open the containing folder. Once in the containing folder right click anywhere and open command window here.\nAlternatively you can just type 'cmd' in the path bar and hit enter, and this will open a command window in place.","Q_Score":0,"Tags":"python,windows,pygame","A_Id":53101644,"CreationDate":"2018-11-01T12:43:00.000","Title":"How to install pygame for python 3.7.0 on windows 7(64-bit)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to connect to a remote rabbitmq server. I have the correct credentials and vhost exists on the remove server, but I cannot connect.\nI get the error \n\npika.exceptions.ProbableAccessDeniedError: (530, 'NOT_ALLOWED - vhost\n  test_vhost not found')\n\nI have struggled with this for a while but I can't seem to get what the problem is.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10124,"Q_Id":53102929,"Users Score":7,"Answer":"I figured it out. On my local machine I am using rabbitmq version 3.5.7 while on the remote rabbitmq is on version 3.7.0\nI had been declaring my vhost without a slash '\/' on 3.5.2 and it has been working well but I realized that adding a slash before declaring the vhost worked on version 3.7.0 .\nSo now I use \/test_vhost instead of just test_vhost","Q_Score":8,"Tags":"python,rabbitmq,pika","A_Id":53117628,"CreationDate":"2018-11-01T14:05:00.000","Title":"RabbitMQ Error 530 vhost not found with 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":1},{"Question":"I have a java build that uses python to handle some of the configuration. I have build agents on both windows and linux. On windows I have place python 3 in my path so that i can issue python commands as part of my build.\nWhen the agent is running on linux it is picking up python2 instead of python3. \nHow do I default the teamcity agent to python 3","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1752,"Q_Id":53103507,"Users Score":0,"Answer":"Can't you just do the same thing as on Windows? I.e. to place python3 in $PATH.\nUpdate:\nOne option is to update Linux machine environment, so it will have python pointing to python3. If it is not possible, or you want it to be in effect only for TC, you can overwrite PATH in Teamcity at a project level or at a build configuration level.\nIn the beginning of PATH put a path that contains python link pointing to python3.\nPS. When specifying environment variable in TC don't use constructions like path:$PATH since $PATH will not be expanded.","Q_Score":0,"Tags":"python,linux,ubuntu,teamcity","A_Id":53155295,"CreationDate":"2018-11-01T14:38:00.000","Title":"Teamcity agent default python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a USB with a python installation that I carry around with me & use on computers that don't have python installed\/don't allow you to install modules. I'd like to install a python package onto it but have been having trouble. Let me use the package rebound-clifor example.\nIf I pip install rebound-cli, the package is installed onto my PC installation of python D:\\Program Files (x86)\\Python36-32.\nThe directory of my USB python installation is H:\\.bin\\Program Files\\Python.\nI've tried the following\n\npip install rebound-cli -e \"H:\\.bin\\Program Files\\Python\\Lib\\site-packages\"\npip install rebound-cli -e \"H:\\.bin\\Program Files\\Python\"\n\nThey both give me the error(s)\nDirectory 'H:\\\\.bin\\\\Program Files\\\\Python\\\\Lib\\\\site-packages' is not installable. File 'setup.py' not found.\nDirectory 'H:\\\\.bin\\\\Program Files\\\\Python' is not installable. File 'setup.py' not found.\nI've also tried \n\"H:\\.bin\\Program Files\\Python\\Scripts\\pip.exe\" install rebound-cli\nBut have received the error\nFatal error in launcher: Unable to create process using '\"e:\\.bin\\program files\\python\\python.exe\"  \"H:\\.bin\\Program Files\\Python\\Scripts\\pip.exe\" install rebound-cli'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3057,"Q_Id":53103727,"Users Score":0,"Answer":"The package is installed on your PC because you did not explicitly specify which pip binary to use.\nIf you execute where pip, it would display the directory of the pip binary which is currently active. In your case, it will most likely be in D: directory.\nTo install packages in your USB, use h:\\<path>\\<to>\\<pip>\\pip install rebound-cli.\nA better option would be, creating a virtual environment in your USB and activating that environment whenever you want to use Python in your USB. Using an environment will save you from the need to explicitly specify the path to pip\/python binary located in your USB","Q_Score":1,"Tags":"python,python-3.x,windows,pip","A_Id":53103892,"CreationDate":"2018-11-01T14:51:00.000","Title":"How to pip install to an external drive?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Hi my name is Oscar and I would like some help!\nSo the scenario I have is that I am trying to write a python code that will copy itself and put that copy in another directory. I know that you can use the shutil command. For example:\nimport shutil\nshutil.copy(\"C:\\Users\\%user%\\Downloads\\file.txt\", \"C:\\Users\\%user%\\Documents\")\nBut I want to just copy the file so that the script works on any computer that it is located on, for example:\nimport shutil\nshutil.copy(\"file.txt\", \"C:\\Users\\%user%\\Documents\")\nIf you don't understand what I mean please ask and I can try to elaborate.\nSincerely, Oscar :)\nEDIT: I am super dumb it seems like, I did not know that you had to type the destination folder with to backslashes sometimes to actually make it a path. All solved, sorry for wasting everyone's time.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":257,"Q_Id":53109247,"Users Score":0,"Answer":"I am super dumb it seems like, I did not know that you had to type the destination folder with to backslashes sometimes to actually make it a path. All solved, sorry for wasting everyone's time.","Q_Score":0,"Tags":"python,directory,copy","A_Id":53111975,"CreationDate":"2018-11-01T20:56:00.000","Title":"PYTHON | Copying a file from an unknown destination","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Hi my name is Oscar and I would like some help!\nSo the scenario I have is that I am trying to write a python code that will copy itself and put that copy in another directory. I know that you can use the shutil command. For example:\nimport shutil\nshutil.copy(\"C:\\Users\\%user%\\Downloads\\file.txt\", \"C:\\Users\\%user%\\Documents\")\nBut I want to just copy the file so that the script works on any computer that it is located on, for example:\nimport shutil\nshutil.copy(\"file.txt\", \"C:\\Users\\%user%\\Documents\")\nIf you don't understand what I mean please ask and I can try to elaborate.\nSincerely, Oscar :)\nEDIT: I am super dumb it seems like, I did not know that you had to type the destination folder with to backslashes sometimes to actually make it a path. All solved, sorry for wasting everyone's time.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":257,"Q_Id":53109247,"Users Score":0,"Answer":"You could use pythons standard \"os\" library to make OS independent filepaths. Then you use the special \"file\" variable available inside any executed script to get the location of the executed script, to copy itself to some target location. Good luck!","Q_Score":0,"Tags":"python,directory,copy","A_Id":53109365,"CreationDate":"2018-11-01T20:56:00.000","Title":"PYTHON | Copying a file from an unknown destination","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to do a groupby of my MODELS by CITYS with keeping all the columns where i can print the percentage of each MODELS IN THIS CITY. \nI put my dataframe in PHOTO below.\nAnd i have written this code but i don\"t know how to do ??\nfor name,group in d_copy.groupby(['CITYS'])['MODELS']:","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":53110240,"Users Score":0,"Answer":"Did you try this : d_copy.groupby(['CITYS','MODELS']).mean() to have the average percentage of a model by city.\nThen if you want to catch the percentages you have to convert it in DF and select the column : pd.DataFrame(d_copy.groupby(['CITYS','MODELS']).mean())['PERCENTAGE']","Q_Score":0,"Tags":"python,pandas,dataframe,group-by","A_Id":53112148,"CreationDate":"2018-11-01T22:25:00.000","Title":"GROUPBY with showing all the columns","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im creating a Vue single page aplication with DRF backend. I have images stored in filesystem and one of my models has a field containing the adress of the image. \nHow can i pass the image to the frontend?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":53110787,"Users Score":0,"Answer":"If the html can access the image, try this\n<body>\n        {% for item in imgs %}\n            <img src=\"{{ item.img_url.url }}\"><br\/>\n        {% endfor %}\n    <\/body>","Q_Score":0,"Tags":"python,django,django-rest-framework","A_Id":53111124,"CreationDate":"2018-11-01T23:30:00.000","Title":"What is the correct way to return images from django rest api?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'd like to post a video from url to my Facebook page. Is there any way for it, I already be able to post Images but seems like it's no way for video?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":53112641,"Users Score":0,"Answer":"I'd like to post a video from url to my Facebook page. Is there any way for it, I already be able to post Images but seems like it's no way for video?\n\nThat is correct, videos can not be uploaded by specifying a video URL.\nYou need to perform an actual HTTP upload in multipart\/form-data format.","Q_Score":0,"Tags":"python,django,facebook,facebook-graph-api","A_Id":53114362,"CreationDate":"2018-11-02T04:22:00.000","Title":"Post video to Facebook Page with Facebook SDK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to follow an online tutorial that is a little outdated. But I like the instructor and how he follows his curriculum. He is using python 2.7 in the video and an older version of pyserial (2.6 I believe) that I can no longer find a download for. I went ahead and installed the latest python (3.7), along with the latest revision of pyserial (3.4). And both installed successfully without problems.\nHowever the other IDE-looking program which he uses to code our scripts (\"vPython or videl for python\"), only supports python versions up to 2.7.9\nThis made me back-trace and also install an older revision of python (2.7) in a separate directory with python 3.7 still being installed in another.\nSince the older version of pyserial is no longer available, I tried to install the newer pyserial 3.4 package using python 2.7 but every time I do it through the windows command line, it gives me an error saying \"the module 'serial' is not available'.\nThis is already after I had extracted the pyserial 3.4 package into the python 2.7 \"Lib\\site-packages\\\" directory. And we can clearly see that the 'serial' folder is definitely in the 2.7 python library.\nI'm wondering if it cannot install the module because of the differences in revisions or if it's because the command line terminal is defaulting to the latest version of python (3.7) automatically to execute the installation.\nIf this is incompatible, maybe someone can help provide a link to the older version of pyserial or help me find another solution to this problem. \nEdit: I found a version of pyserial 2.7 but it is for 32 bit windows and not 64. I have been sticking to versions of 64 bit for python and vpython.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":117,"Q_Id":53113288,"Users Score":1,"Answer":"So I found an older version of pyserial 2.7 for windows 32 bit. I'm not sure if pyserial had a 64 bit version at the time 2.7 was released because I could not find it. I uninstalled python 2.7 64 bit and replaced it with 32 bit, and then did the same for vpython.\nThis got the program up and running successfully and importing the serial libraries just fine.\nThe next problem was that the 32 bit vpython and 64 bit arduino's did not play nice together. And I could not get vpython to read serial data from arduino despite copying code verbatum and having it compile correctly.\nMy solution was just to use the pycharm IDE instead. It has a package installer that just downloads and installs everything for you. Thank god too because I spent around 3 hours trying to get the packages installed manually through the command terminal but kept running into compatibility issues like outdated published files, an annoying syntax error through cmd, a \"not supported on this platform\" error (despite pip and everything being 100% kosher) and not having microsoft C++ version 14 AND HAVING NO IDEA THIS RESOURCE WAS MISSING.\nBut pycharm solved all of that. Sorry for the somewhat salty response. I just hope it saves someone else's time. Pretty upset this wasn't suggested on any of the official websites anywhere.","Q_Score":1,"Tags":"python,pyserial,vpython","A_Id":53114928,"CreationDate":"2018-11-02T05:52:00.000","Title":"cannot setup vpython (videl for python) using python 2.7 and newer pyserial 3.4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem when I try to use flask_cors in my flask app but when I deploy this app on Heroku so it fails and from the Heroku logs I have this error :\nfrom flask_cors import CORS, cross_origin \n ModuleNotFoundError: No module named 'flask_cors'\nI have added 'flask_cors' in the requirement.txt file but it's still no work. Thank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":406,"Q_Id":53114970,"Users Score":0,"Answer":"Did you run pip install when deploying? 'requirements.txt' just specify the dependencies of current project and you need to install them.\nMake sure you have the pip install -r requirements.txt command before start the flask app.","Q_Score":0,"Tags":"python,heroku,flask,cors","A_Id":53116610,"CreationDate":"2018-11-02T08:23:00.000","Title":"How to add flask cor module to work on Heroku?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to repeatedly execute a curl command with a python script, is there a better way to do such a task?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":53118542,"Users Score":2,"Answer":"Below findings can help you in  linux environment.\nYou can do that with the help of a cron jab. \nSteps to setup a cron job:\n\nOpen crontab by the command \"crontab -e\" on the shell\nPaste the following in the file and correct the path\n0 * * * * \/home\/sshashank\/script.py\nMake sure you have given proper permissions to the folders where python script is going to run, folder where it is going to access(files\/logs). \nPlease provide absolute path and not relative path.","Q_Score":0,"Tags":"python,swagger-ui","A_Id":53118698,"CreationDate":"2018-11-02T12:21:00.000","Title":"How: Python Script to execute Terminal Command every hour?","Data Science and Machine Learning":0,"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 very simple way to put up 2 teams out of unspecified(but known) amount of players. So its not actually a standard matchmaking since it only creates one match out of the whole pool of registered players for the specific match. I do have pretty much only single variable and it is the ELO score for each player, which means it's the only available option to base calculations on.\nWhat I thought of is just simply go through every possible combination of a players(6 in each team) and the lowest difference between the average ELO of teams is the final rosters that get created. I've tested this option and it gives me more than 17mil calculations for 18 registered players(the amount of players shouldnt be more than 24 usually) so its doable but its definitely the MOST unoptimized way to do that.\nSo I decided to ask a question in here, maybe you can help me with that in some way. Any ideas what simple algos I can use or the ways of optimizing something in a straight up comparisons of all possible combinations. \nIf you want to provide any code examples I can read any code language(almost), so it doesnt really matter.\nUPD. basically the input is gonna be a list[] of player objects that contain player \"id\" and \"elo\", the output should be 2 team lists team1[] and team2[] containing player objects. The average ELO of both teams should be as close as possible.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2387,"Q_Id":53119389,"Users Score":2,"Answer":"Given that your approach is an approximation anyways, putting too much effort to produce a perfect answer is a losing cause.  Instead pick a reasonable difference and go from there.\nI would suggest that you sort the list of players by ELO, then pair them up.  Those people will be on opposing teams if they are included.  If there are an odd number of people, leave out the person who is farthest from any other.  Sort the pairs by difference and pair them up as well in the same way.  That gives you fairly evenly matched groups of 4, and the teams will be the best and worst against the middle 2.  These groups of 4 should generally be relatively close to even.  Score it as the better group minus the worse one.  (Either half can wind up better depending on actual scores.)\nNow search for 3 groups of 4 such that A is as close as possible to the sum of B and C.  The better group from A will go with the worse groups from B and C.\nWith 24 people this will be a virtually instantaneous calculation, and will give reasonable results.\nThe repeated difference approach that I started with is a well-known heuristic for the subset sum problem.\n\nGiven how fast this heuristic is, I think that it is worth broadening the search for a good team as follows.\n\nSort your players.  Put each player into a pair with the person above and below.  With n players this will be n-1 pairs.  Give each pair a score of either the ELO difference, or of how much more likely the better is to beat the worse.  (Which I would choose depends on the way that the two play.)\nSort your pairs.  Pair each pair with the closest pair above and below who does not intersect it.  With n-1 pairs this will usually result in n-2 groups of 4.\nCreate a sorted list of groups of 4.  Call it list4.  Note that this list has size n + O(1).\nConstruct a list of all groups of 8 that can be made from 2 groups of 4 that do not intersect.  Sort it.  Call it list8.  The formula for how big this list is is complicated, but is n^2\/2 + O(n) and took time O(n^2 log(n)) to sort.\nFor each element of list4 find the nearest elements in list8 that are above\/below it and have no players in common with it.  For O(n) elements this is O(log(n)) expected work.\n\nThe result is that you get rid of the even\/odd logic.  Yes, you added back in some extra effort, but the biggest effort was the O(n^2 log(n)) to sort list8.  This is sufficiently fast that you'll still produce very quick answers even if you had a hundred people thrown at it.\nThe result will be two evenly matched teams such that when they pair off by strength, the weaker team at least has a reasonable chance of posting a convincing upset.","Q_Score":2,"Tags":"python,c++,algorithm,math,combinations","A_Id":53122193,"CreationDate":"2018-11-02T13:22:00.000","Title":"Team matchmaking algorithm based on ELO","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build an AutoEncoder, where I am trying to de-noise the signal.\nNow, for example, the amplitude range of my input signal varies in between -47 to +32. But while I am getting the decoded signal (reconstructed one), that signal only ranges in between 0 to +1 amplitude. \nHow can I get my reconstructed signal with the same amplitude range of  -47 to +32?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":53119402,"Users Score":2,"Answer":"I guess the question is whether your returned signal is a faithful representation of the input signal (but it's just constrained to the range 0 to 1)?\nIf so, you could simply multiply it by 79, and then subtract 47.\nWe'd need to see code if it's more than just a scaling issue.","Q_Score":0,"Tags":"python,tensorflow,autoencoder","A_Id":53119543,"CreationDate":"2018-11-02T13:24:00.000","Title":"Autoencoder Decoded Output","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently working on something where data is produced, with a fair amount of processing, within SQL server, that I ultimately need to manipulate within Python to complete the task.  It seems to me I have a couple different options:\n(1)  Run the SQL code from within Python, manipulate output\n(2)  Create an SP in SSMS, run the SP from within Python, manipulate output\n(3)  ?\nThe second seems cleanest, but I wonder if there's a better way to achieve my objective without needing to create a stored procedure every time I need SQL data in Python.  Copying the entirety of the SQL code into Python seems similarly kludgy, particularly for larger or complex queries.  \nFor those with more experience working between the two:  can you offer any suggestions on workflow?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":53124221,"Users Score":0,"Answer":"There is no silver bullet.\nIt really depends on the specifics of what you're doing. What amount of data are we talking? Is it even feasible to stream it all over the network, through Python, and back? How much more load can the database server handle? How complex are the manipulations you consider doing in Python? How proficient are you and your team in SQL, and in Python?\nI've seen both approaches in production, and one slight advantage that sometimes gets overlooked is that when you have all the SQL nicely formatted inside your Python program, it's automatically under some Version Control, and you can check who edited what last and is thus to blame for the latest SNAFU ;-)","Q_Score":0,"Tags":"python,sql,sql-server,python-3.x","A_Id":53124483,"CreationDate":"2018-11-02T18:43:00.000","Title":"Suggestions on workflow between SQL Server and Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using sklearn to compute all the k-nearest neighbors from a dataset. Say k = 10. The problem I'm having is sklearn will only return the 10 nearest neighbors and none of the other data points that may tie for the 10th nearest neighbor in terms of distance. I was wondering is there any efficient way to find any other points that may tie the kth nearest neighbor  in terms of distance?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":203,"Q_Id":53124843,"Users Score":1,"Answer":"In theory, all points in the set may tie, making the problem a different one. Indeed, the K nearest neighbors can be reported in time O(Log N + K) in the absence of ties, whereas ties can imply K = O(N) making any solution O(N).\nIn practice, if the coordinates are integer, the ties will be a rare event, unless the problem has a special structure. And in floating-point, ties are virtually impossible.\nIMO, handling ties will kill efficiency, for no benefit.","Q_Score":1,"Tags":"python,algorithm,pandas,numpy,scikit-learn","A_Id":53125246,"CreationDate":"2018-11-02T19:35:00.000","Title":"K-Nearest Neighbors find all ties","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project for a client in which I need to load a lot of data into data studio. I am having trouble getting the deployment to work with my REST API. \nThe API has been tested with code locally but I need to know how to make it compatible with the code base in App Scripts. Has anyone else had experience with working around this? The endpoint is a Python Flask application. \nAlso, is there a limit on the amount of data that you can dump in a single response to the Data Studio? As a solution to my needs(needing to be able to load data for 300+ accounts) I have created a program that caches the data needed from each account and returns the whole payload at once. There are a lot of entries, so I was wondering if they had a limit to what can be uploaded at once. \nThank you in advance","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":146,"Q_Id":53128705,"Users Score":1,"Answer":"I found the issue, it was a simple case of forgetting to add the url to the whitelist.","Q_Score":0,"Tags":"javascript,python,rest,google-apps-script,google-data-studio","A_Id":53149427,"CreationDate":"2018-11-03T05:34:00.000","Title":"Google Data Studio Connector and App Scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Is there any way to hide error messages from a jupyter notebook? I want to take notes from a class and write down some snippets of code but of course the code doesn't actually run. Is there any way to hide error messages (rather than warning messages)? \nThanks so much!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":6928,"Q_Id":53132654,"Users Score":1,"Answer":"1st option: just not run the cell, or if you accidentally did run the cell you could use cell -> All Output -> Clear from the drop down menu.\n2nd option: Change the cell type to 'Raw NBConvert'. However this removes syntax highlighting as well.","Q_Score":3,"Tags":"python,jupyter-notebook","A_Id":53132659,"CreationDate":"2018-11-03T15:16:00.000","Title":"How to hide ERROR messages in Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to hide error messages from a jupyter notebook? I want to take notes from a class and write down some snippets of code but of course the code doesn't actually run. Is there any way to hide error messages (rather than warning messages)? \nThanks so much!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6928,"Q_Id":53132654,"Users Score":3,"Answer":"The fastest way to get syntax highlighting if you've already accidentally run the cell is simply press\nmy\nin Command mode.\nm converts to Raw NBConvert, the error disappears\ny converts back to code, with the error now gone","Q_Score":3,"Tags":"python,jupyter-notebook","A_Id":61201850,"CreationDate":"2018-11-03T15:16:00.000","Title":"How to hide ERROR messages in Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I start python3 in terminal, it runs python 3.6.5.\nHowever, when I look in \/usr\/local\/lib, I see python 3.7 and all it's site-packages.\nWhy is there a discrepancy? Shouldn't the version always match when I update? Does this matter?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":53132739,"Users Score":0,"Answer":"The command which python will tell you the path to the executable that is being chosen. Use echo $PATH to see which directories are checked for files to run and in which order - this should help you to understand which file is being chosen and why.","Q_Score":0,"Tags":"python-3.x","A_Id":53132766,"CreationDate":"2018-11-03T15:26:00.000","Title":"Mismatch between python3 version from command line and version in \/usr\/local\/lib","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is it possible to have a multi-line text entry field with drop down options?\nI currently have a GUI with a multi-line Text widget where the user writes some comments, but I would like to have some pre-set options for these comments that the user can hit a drop-down button to select from.\nAs far as I can tell, the Combobox widget does not allow changing the height of the text-entry field, so it is effectively limited to one line (expanding the width arbitrarily is not an option). Therefore, what I think I need to do is sub-class the Text widget and somehow add functionality for a drop down to show these (potentially truncated) pre-set options. \nI foresee a number of challenges with this route, and wanted to make sure I'm not missing anything obvious with the existing built-in widgets that could do what I need.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":900,"Q_Id":53132987,"Users Score":1,"Answer":"I don't think you are missing anything.  Note that ttk.Combobox is a composite widget. It subclasses ttk.Entry and has ttk.Listbox attached.\nTo make multiline equivalent, subclass Text. as you suggested.  Perhaps call it ComboText.  Attach either a frame with multiple read-only Texts, or a Text with multiple entries, each with a separate tag.  Pick a method to open the combotext and methods to close it, with or without copying a selection into the main text.  Write up an initial doc describing how to operate the thing.","Q_Score":1,"Tags":"python,tkinter","A_Id":53133245,"CreationDate":"2018-11-03T15:56:00.000","Title":"Multi-Line Combobox in Tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to add a real-time chart to my Flask-SocketIO app, for that i found Plotly.\nWould it be possible with Plotly to generate a chart which shows both real-time data and past data? When the user opens the page he should be able to see both the data from before the webpage was opened and the new data. How would it be possible to accomplish that with Plotly? Is there an example for it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":251,"Q_Id":53134005,"Users Score":1,"Answer":"For this kind of apps it's highly recommended to feed your real time data to a database and connect your visualization with said database, however I think it is possible to achieve what you want in jupyter notebook with plotly 3 FigureWidget's batch_update. I can't quite get the idea of what you want without some code though.","Q_Score":0,"Tags":"python,python-3.x,plotly","A_Id":53147499,"CreationDate":"2018-11-03T17:53:00.000","Title":"Real time charting with Plotly and Flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a data set that contains information about whether medium-budget companies can get loans. There are data on the data set that approximately 38,000 different companies will receive loans. And based on this data, I'm trying to estimate each company's credit score. What would be your suggestion?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":155,"Q_Id":53134930,"Users Score":1,"Answer":"Do you have credit scores? Without labeled data I think you might consider reformulating the problem.\nIf you do, then you can implement any number of regression algorithms from OLS all the way up to an ANN. Rather than look for the \"one true\" algorithm, many projects implement TPOT or grid search as part of model selection.","Q_Score":0,"Tags":"python,machine-learning,classification","A_Id":53135661,"CreationDate":"2018-11-03T19:48:00.000","Title":"Which classification model do you suggest for predicting a credit score?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I built a GUI in python using wxpython, and I want to be able to restart it when I click on a button. I want the app to close, then open up again. Is this possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":143,"Q_Id":53135445,"Users Score":0,"Answer":"It really depends on what you mean by \"restart\". Do you want everything to be reinitialized? If not, you can just call Hide on the main window of your application. Put in an artificial sleep and then Show it again.\nAlternatively, you would need to basically launch a script on shutdown that would then relaunch your application.","Q_Score":0,"Tags":"python,python-3.x,user-interface,wxpython,restart","A_Id":53157307,"CreationDate":"2018-11-03T20:55:00.000","Title":"Restart Python 3.6 GUI - wxpython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that it is possible to turn python files into .exe files but why would you need to do that? What are the benefits?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":53137109,"Users Score":0,"Answer":"A lot of the time, it has to do with bundling.\nConsider that when you go to distribute a standalone Python program, you often have to assume that whomever the program is intended for already has, at the very least, a Python interpreter of a compatible version installed. Similarly, if your program uses packages or modules which aren't part of the Python standard library, you will also have to make the assumption that the intended users also have your program dependencies installed or are using pip to install it via your listed setup.py dependencies. Typically these are not good assumptions.\nThere are a number of ways of addressing this issue, and bundling a Python interpreter with the necessary dependencies installed into the distribution itself is a popular one. For Windows users in particular, many developers like to release such bundles as .exe files using a C or C++ wrapper for the sake of user convenience: A user need only double click the bundled program to launch it with minimal setup. This is how a lot of \".py to .exe\" conversion programs work, such as the popular py2exe Python package.","Q_Score":0,"Tags":"python-3.x","A_Id":53137226,"CreationDate":"2018-11-04T01:55:00.000","Title":"Why would you need to turn a python file into an executable?","Data 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 Python 3.7.1 installed on Windows 7 from www.python.org.\nWhen I want to \"pip install pylab\" I receive the following message:\n\"pip is configured with locations that require tls\/ssl however the ssl module in python is not available\".\nPlease help me to overcome this problem.\nMany thanks","AnswerCount":5,"Available Count":5,"Score":0.1973753202,"is_accepted":false,"ViewCount":18293,"Q_Id":53137700,"Users Score":5,"Answer":"I also had the same problem. But solved it by just adding path variables in evt variables \nSo check for the following paths \n1. Anaconda root \n2. Anaconda\/Scripts\n3. Anaconda\/Library\/bin\nthe 3rd one was not added and after adding all these evt variables do restart your PC. and the error will be resolved.","Q_Score":10,"Tags":"python,ssl","A_Id":54933554,"CreationDate":"2018-11-04T04:18:00.000","Title":"ssl module in python is not available Windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python 3.7.1 installed on Windows 7 from www.python.org.\nWhen I want to \"pip install pylab\" I receive the following message:\n\"pip is configured with locations that require tls\/ssl however the ssl module in python is not available\".\nPlease help me to overcome this problem.\nMany thanks","AnswerCount":5,"Available Count":5,"Score":0.1586485043,"is_accepted":false,"ViewCount":18293,"Q_Id":53137700,"Users Score":4,"Answer":"What worked for me is:\n    conda activate in command prompt and then use pip","Q_Score":10,"Tags":"python,ssl","A_Id":55987478,"CreationDate":"2018-11-04T04:18:00.000","Title":"ssl module in python is not available Windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python 3.7.1 installed on Windows 7 from www.python.org.\nWhen I want to \"pip install pylab\" I receive the following message:\n\"pip is configured with locations that require tls\/ssl however the ssl module in python is not available\".\nPlease help me to overcome this problem.\nMany thanks","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":18293,"Q_Id":53137700,"Users Score":0,"Answer":"Activating conda (from condabin folder: activate.bat)  and  then from the python.exe folder \"python.exe -m pip install siphon\"","Q_Score":10,"Tags":"python,ssl","A_Id":57626871,"CreationDate":"2018-11-04T04:18:00.000","Title":"ssl module in python is not available Windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python 3.7.1 installed on Windows 7 from www.python.org.\nWhen I want to \"pip install pylab\" I receive the following message:\n\"pip is configured with locations that require tls\/ssl however the ssl module in python is not available\".\nPlease help me to overcome this problem.\nMany thanks","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":18293,"Q_Id":53137700,"Users Score":0,"Answer":"I had the same issue because of corporate firewall settings.\nIf you are on windows go to \"Internet Properties\" ---> \"Connection\" ---> \"LAN Settings\" and check the address (if it is a wpad.dat file, download it and look for \"ProxyPort\" and \"ProxyServer\").\nThen try :\npip --proxy http:\/\/user:password@ProxyServer:ProxyPort install module","Q_Score":10,"Tags":"python,ssl","A_Id":58202904,"CreationDate":"2018-11-04T04:18:00.000","Title":"ssl module in python is not available Windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python 3.7.1 installed on Windows 7 from www.python.org.\nWhen I want to \"pip install pylab\" I receive the following message:\n\"pip is configured with locations that require tls\/ssl however the ssl module in python is not available\".\nPlease help me to overcome this problem.\nMany thanks","AnswerCount":5,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":18293,"Q_Id":53137700,"Users Score":7,"Answer":"According to your comment with the PATH variable you are missing the right entries to this so it cannot find the libraries and so on. \nIf you reinstall python in the first screen you have an option \u2018Add Python x.x.x to PATH\u2019 enable this option and then retry what you did.","Q_Score":10,"Tags":"python,ssl","A_Id":53174338,"CreationDate":"2018-11-04T04:18:00.000","Title":"ssl module in python is not available Windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"boto libraries have a lot of classes with similar names and different functionalities and vice versa (different names but same functionalities). I would like to track, which one is used in some specific case. Suppose I see an object in the debugger and it is shown as being of type s3.Bucket. How to find it's definition?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":125,"Q_Id":53140609,"Users Score":1,"Answer":"Just press Ctrl and click on the class or method.\nUpdate\nPress Ctrl+RMB on the object definition and after Ctrl+RMB on class definition.","Q_Score":1,"Tags":"python,python-3.x,pycharm,boto3,boto","A_Id":53140640,"CreationDate":"2018-11-04T12:01:00.000","Title":"How to find class definition knowing an object in Python in PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I get this to happen in Apache (with python, on Debian if it matters)?\n\nUser submits a form\nBased on the form entries I calculate which html file to serve them (say 0101.html)\nIf 0101.html exists, redirect them directly to 0101.html\nOtherwise, run a script to create 0101.html, then redirect them to it.\n\nThanks!\nEdit: I see there was a vote to close as too broad (though no comment or suggestion). I am just looking for a minimum working example of the Apache configuration files I would need. If you want the concrete way I think it will be done, I think apache just needs to check if 0101.html exists, if so serve it, otherwise run cgi\/myprogram.py with input argument 0101.html. Hope this helps. If not, please suggest how I can make it more specific. Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":100,"Q_Id":53142553,"Users Score":0,"Answer":"Apache shouldn't care. Just serve a program that looks for the file. If it finds it it will read it (or whatever and) return results and if it doesn't find it, it will create and return the result. All can be done with a simple python file.","Q_Score":1,"Tags":"python,apache,cgi","A_Id":53142803,"CreationDate":"2018-11-04T15:50:00.000","Title":"Apache - if file does not exist, run script to create it, then serve 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":"I am trying to push some files up to s3 with the AWS CLI and I am running into an error:\nupload failed: ... An HTTP Client raised and unhandled exception: unknown encoding: idna\nI believe this is a Python specific problem but I am not sure how to enable this type of encoding for my python interpreter. I just freshly installed Python 3.6 and have verified that it being used by powershell and cmd. \n$> python --version\n Python 3.6.7\nIf this isn't a Python specific problem, it might be helpful to know that I also just freshly installed the AWS CLI and have it properly configured. Let me know if there is anything else I am missing to help solve this problem. Thanks.","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6262,"Q_Id":53144254,"Users Score":8,"Answer":"I had the same problem in Windows.\nAfter investigating the problem, I realized that the problem is in the aws-cli installed using the MSI installer (x64). After removing \"AWS Command Line Interface\" from the list of installed programs and installing aws-cli using pip, the problem was solved.\nI also tried to install MSI installer x32 and the problem was missing.","Q_Score":12,"Tags":"python-3.x,amazon-s3,aws-cli","A_Id":54337242,"CreationDate":"2018-11-04T18:53:00.000","Title":"AWS CLI upload failed: unknown encoding: idna","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 push some files up to s3 with the AWS CLI and I am running into an error:\nupload failed: ... An HTTP Client raised and unhandled exception: unknown encoding: idna\nI believe this is a Python specific problem but I am not sure how to enable this type of encoding for my python interpreter. I just freshly installed Python 3.6 and have verified that it being used by powershell and cmd. \n$> python --version\n Python 3.6.7\nIf this isn't a Python specific problem, it might be helpful to know that I also just freshly installed the AWS CLI and have it properly configured. Let me know if there is anything else I am missing to help solve this problem. Thanks.","AnswerCount":5,"Available Count":2,"Score":-0.0798297691,"is_accepted":false,"ViewCount":6262,"Q_Id":53144254,"Users Score":-2,"Answer":"Even I was facing same issue. I was running it on Windows server 2008 R2. I was trying to upload around 500 files to s3 using below command.\n\naws s3 cp sourcedir s3bucket --recursive --acl\n  bucket-owner-full-control --profile profilename\n\nIt works well and uploads almost all files, but for initial 2 or 3 files, it used to fail with error: An HTTP Client raised and unhandled exception: unknown encoding: idna\nThis error was not consistent. The file for which upload failed, it might succeed if I try to run it again. It was quite weird.\nTried on trial and error basis and it started working well.\nSolution:\n\nUninstalled Python 3 and AWS CLI.\nInstalled Python 2.7.15\nAdded python installed path in environment variable PATH. Also added pythoninstalledpath\\scripts to PATH variable.  \nAWS CLI doesnt work well with MS Installer on Windows Server 2008, instead used PIP. \n\nCommand: \n\npip install awscli\n\nNote: for pip to work, do not forget to add pythoninstalledpath\\scripts to PATH variable.\nYou should have following version:\nCommand: \n\naws --version\n\nOutput: aws-cli\/1.16.72 Python\/2.7.15 Windows\/2008ServerR2 botocore\/1.12.62\nVoila! The error is gone!","Q_Score":12,"Tags":"python-3.x,amazon-s3,aws-cli","A_Id":53693183,"CreationDate":"2018-11-04T18:53:00.000","Title":"AWS CLI upload failed: unknown encoding: idna","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 dataset consisting in 15 columns and 3000 rows to train a model for a binary classification. \nThere is a imbalance for y (1:2). Both outcomes (0,1) are equally important.\nAfter downsampling (because the parameter class_weight = balanced didn't work well), I used the parameter scoring = \"f1\", because I read that this was next to the ROC curve the best measurement of the performance. \nThe question is: \nDo I treat my data after downsampling still as unbalanced and therefore apply f1 or can I go back to normal accuracy?\nf1 = 2 * (precision * recall) \/ (precision + recall)\nCheers in advance! :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":122,"Q_Id":53145190,"Users Score":0,"Answer":"If you've rebalanced your data, then it's not unbalanced anymore and I see no problem with using accuracy as the success metric.\nAccuracy can mislead you in very skewed datasets but since it isn't skewed anymore, it should work.","Q_Score":0,"Tags":"python,classification","A_Id":53145276,"CreationDate":"2018-11-04T20:33:00.000","Title":"f1 or accuracy scoring after downsampling - classification, svm - Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a Python program and I want to write my data to a file in such a way that there are sixteen values on each line. How do I do that, please?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":53145981,"Users Score":0,"Answer":"You just have to add a character '\\n' (new line character) every 16 elements.\nYou can easily do this by iterating your data.","Q_Score":0,"Tags":"python,formatting","A_Id":53146318,"CreationDate":"2018-11-04T22:06:00.000","Title":"How do I display sixteen values on each line in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am aware this question is common but no solution has been able to solve my problem yet... I keep getting this error, FileNotFoundError: [Errno 2] No such file or directory: 'file.txt'   when running a simple python script to open a file on an Anaconda Virtual Environment (VSCode) on Mac OSX... I tried doing the import os and then os.chdir(\"...\") to change the working directory to get my files to open, but nothing is working.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3237,"Q_Id":53148308,"Users Score":0,"Answer":"I had the same issue. I tried just \"Copy Relative Path\" (right click on *.txt file in the explorer) and paste instead of the *.txt file name, it worked for me.","Q_Score":1,"Tags":"python,macos,visual-studio-code,anaconda,virtualenv","A_Id":62691526,"CreationDate":"2018-11-05T04:22:00.000","Title":"Anaconda (Python) VSCode: FileNotFoundError: [Errno 2] No such file or directory: 'file.txt'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Even though I have python installed in my system. I'm unable to execute .py file. below is the error. Please assist. \n\nC:\\Users\\chandan\\Desktop>py first.py\n  C:\\Users\\chandan\\AppData\\Local\\Programs\\Python\\Python37-32\\python.exe:\n  can't open file 'first.py': [Errno 2] No such file or directory.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":110,"Q_Id":53148319,"Users Score":1,"Answer":"the file name should not contain any spaces. if you are using spaces use \n\"\" \neg \npython \"py first.py\"","Q_Score":0,"Tags":"python","A_Id":53148452,"CreationDate":"2018-11-05T04:24:00.000","Title":"Unable to Execute .py file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"On their website they say 'gradient boosting' but it seems people here compare it to other 'xgboost' algorithm. I would like to know whether it is a real extreme gradient boosting algorithm. \nthanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":102,"Q_Id":53149072,"Users Score":1,"Answer":"Gradient boosting is a meta-algorithm. There is no simple gradient boosting. Each boosting library uses their own unique algorithm to search for regression trees, as a result, we obtain different results.\nExtreme gradient boosting is just an implementation of standard gradient boosting on decision trees from xgboost with some heuristics\/regularizations to improve models quality and special scheme to learn regression trees\nCatBoost is another implementation of standard gradient boosting with another set of regularizations\/heuristics.\nSo this are different algorithms.","Q_Score":0,"Tags":"python,xgboost,catboost","A_Id":53565096,"CreationDate":"2018-11-05T05:57:00.000","Title":"Does catboost implements xgboost (extreme gradient boosting) or a simple gradient boosting?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While on a scrapy shell, when I try to use the view(response) function, instead of opening a browser, it opens Visual Studio Code. How to make it open on a browser?\nI read that webbrowser is the library used to view the page and that I could set the BROWSER variable to change its default. On a Linux Mint system, to which value should I change the BROWSER variable to in order to make the view command to open firefox?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":252,"Q_Id":53149544,"Users Score":2,"Answer":"Found the answer myself after some further searching.\nThe value of the BROWSER variable should be \/usr\/bin\/firefox.\nSo, in my case, adding the following line to my ~\/.bashrc file did the trick:\nexport BROWSER=\/usr\/bin\/firefox.","Q_Score":2,"Tags":"scrapy,python-webbrowser,scrapy-shell","A_Id":53149857,"CreationDate":"2018-11-05T06:45:00.000","Title":"Change default browser while using scrapy's shell view function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Im writing a webapplication, where im trying to display the connected USB devices. I found a Python function that does exactly what i want but i cant really figure out how to call the function from my HTML code, preferably on the click of a button.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":76,"Q_Id":53152383,"Users Score":0,"Answer":"simple answer: you can't. the code would have to be run client-side, and no browser would execute potentially malicious code automatically (and not every system has a python interpreter installed). \nthe only thing you can execute client-side (without the user taking action, e.g. downloading a program or browser add-on) is javascript.","Q_Score":0,"Tags":"python,html,python-2.7","A_Id":53152455,"CreationDate":"2018-11-05T10:20:00.000","Title":"Calling a Python function from HTML","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I defined a function in a Jupyter Lab cell and is working fine but if I try to execute the same function on a different cell I've got the error:\nModuleNotFoundError: No module named 'count_persistence_fail'. How can I execute a function on different cells? Thank you in advance.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4257,"Q_Id":53153238,"Users Score":0,"Answer":"just do this >>> function name","Q_Score":0,"Tags":"python,jupyter-notebook,jupyter,jupyter-lab","A_Id":60023878,"CreationDate":"2018-11-05T11:11:00.000","Title":"How to execute a function in Jupyter that was defined in a different cell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I defined a function in a Jupyter Lab cell and is working fine but if I try to execute the same function on a different cell I've got the error:\nModuleNotFoundError: No module named 'count_persistence_fail'. How can I execute a function on different cells? Thank you in advance.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4257,"Q_Id":53153238,"Users Score":4,"Answer":"It seems you just need to execute the cell where function defined. That should put it in runtime and it will be accessible in other cells right after.","Q_Score":0,"Tags":"python,jupyter-notebook,jupyter,jupyter-lab","A_Id":53153371,"CreationDate":"2018-11-05T11:11:00.000","Title":"How to execute a function in Jupyter that was defined in a different cell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using SMTPlib package to create multiple emails in one application and the code works fine to send email. But, I want to be able to schedule each email to be sent at different day\/time. \nFor instance, one at 9AM Monday and another at 12 Noon Wed. \nI looked at some slightly different questions and answers on SO, where the recommendation is use of Crontab. However, Crontab is only helpful to schedule the entire application not individual parts of the application.\nSched package is also available, but I am not familiar with it and hence not sure, if I can efficiently use this for my use case. \nAppreciate your thoughts","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":53157403,"Users Score":0,"Answer":"Maybe you should create separate python file\/process responsible only for sending emails. You can run it when you need to queue\/send emails and you might just kill it afterwards.","Q_Score":0,"Tags":"python-3.x,email,scheduler","A_Id":53157641,"CreationDate":"2018-11-05T15:32:00.000","Title":"Schedule Multiple Emails Python 3","Data Science and Machine Learning":0,"Database and SQL":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 have several microservices on Golang and Python, On Golang we are writing finance operations and on Python online store logic, we want to create one API for our front-end and we don't know how to do it.\nI have read about API gateway and would it be right if Golang will create its own GraphQL server, Python will create another one and they both will communicate with the third graphql server which will generate API for out front-end.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":832,"Q_Id":53159897,"Users Score":2,"Answer":"I do not know much details about your services, but great pattern I successfully used on different projects is as you mentioned GraphQL gateway. \nYou will create one service, I prefer to create it in Node.js where all requests from frontend will coming through. Then from GraphQL gateway you will request your microservices. This will be basically your only entry point into the backend system. Requests will be authenticated and you are able to unify access to your data and perform also some performance optimizations like implementing data loader's caching and batching to mitigate N+1 problem. In addition you will reduce complexity of having multiple APIs and leverage all the GraphQL benefits. \nOn my last project we had 7 different frontends and each was using the same GraphQL gateway and I was really happy with our approach. There are definitely some downsides as you need to keep in sync all your frontends and GraphQL gateway, therefore you need to be more aware of your breaking changes, but it is solvable with for example deprecated directive and by performing blue\/green deployment with Kubernetes cluster. \nThe other option is to create the so-called backend for frontend in GraphQL. Right now I do not have enough information which solution would be best for you. You need to decide based on your frontend needs and business domain, but usually I prefer GraphQL gateway as GraphQL has great flexibility and the need to taylor your API to frontend is covered by GraphQL capabilities. Hope it helps David","Q_Score":2,"Tags":"python,api,go,graphql","A_Id":53173290,"CreationDate":"2018-11-05T18:11:00.000","Title":"How to create Graphql server for microservices?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a hyperspectral image having dimension S * S * L where S*S is the spatial size and L denotes the number of spectral bands.\nNow the shape of my X (image array) is: (1, 145, 145, 200) where 1 is the number of examples, 145 is the length and width of the image and 200 is no. of channels of the image.\nI want to input this small windows of this image (having dimension like W * W * L; W < S) into a 3D CNN, but for that, I need to have 5 dimensions in the following format: (batch, length, width, depth, channels).\nIt seems to me I am missing one of the spatial dimensions, how do I convert my image array into a 5-dimensional array without losing any information?\nI am using python and Keras for the above.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":138,"Q_Id":53159930,"Users Score":1,"Answer":"If you want to convolve along the dimension of your channels, you should add a singleton dimension in the position of channel.  If you don't want to convolve along the dimension of your channels, you should use a 2D CNN.","Q_Score":1,"Tags":"python,keras,conv-neural-network","A_Id":53159976,"CreationDate":"2018-11-05T18:14:00.000","Title":"What should be the 5th dimension for the input to 3D-CNN while working with hyper-spectral images?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a hyperspectral image having dimension S * S * L where S*S is the spatial size and L denotes the number of spectral bands.\nNow the shape of my X (image array) is: (1, 145, 145, 200) where 1 is the number of examples, 145 is the length and width of the image and 200 is no. of channels of the image.\nI want to input this small windows of this image (having dimension like W * W * L; W < S) into a 3D CNN, but for that, I need to have 5 dimensions in the following format: (batch, length, width, depth, channels).\nIt seems to me I am missing one of the spatial dimensions, how do I convert my image array into a 5-dimensional array without losing any information?\nI am using python and Keras for the above.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":138,"Q_Id":53159930,"Users Score":1,"Answer":"What you want is a 2D CNN, not a 3D one. A 2D CNN already supports multiple channels, so you should have no problem using it with a hyperspectral image.","Q_Score":1,"Tags":"python,keras,conv-neural-network","A_Id":53163769,"CreationDate":"2018-11-05T18:14:00.000","Title":"What should be the 5th dimension for the input to 3D-CNN while working with hyper-spectral images?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I've recently started looking into network flows (Max flow, min cuts, etc) and the general problems for network flow always involve assigning \"n\" of something to \"k\" of another thing. For example, how would I set up a network flow for \"n\" children in a city that has \"k\" schools such that the children's homes are within x kilometres of the school (for simplicity, let's just say 1km)? \nWhat if I were to further add limitations, for example, say each school cannot have more than 100 students? Or 300 students? Could someone help me with how I would initially set up my algorithm to approach problems like these (would appreciate any references too)? They tend to show up on past midterms\/exams, so I just wanted to be prepared","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":146,"Q_Id":53160428,"Users Score":0,"Answer":"Create vertices for each student and each school. Draw an edge with capacity 1 from each student to each school that they can attend according to your distance constraint. Create a source vertex with edges to each student with a capacity of 1. Create a sink vertex with edges coming in from each school with capacities equal to each school's maximum capacity.\nRunning a standard max-flow algorithm will match as many students as possible to schools. Not every student is guaranteed to get to go to school, of course, given the constraints.\nThis is basically a modification of the standard maximum bipartite matching algorithm. The main difference is that the sinks have capacities greater than 1, which allows multiple students to be matched to a school.","Q_Score":0,"Tags":"java,python,algorithm,computer-science,network-flow","A_Id":53161713,"CreationDate":"2018-11-05T18:52:00.000","Title":"Applying Network flows","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to take a dataframe df and return a new dataframe excluding any columns with the word 'job' in its name, excluding any columns with the string 'birth' in its name, and excluding these columns: name, userID, lgID.\nHow can I do that?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":149,"Q_Id":53161078,"Users Score":1,"Answer":"To build on @sven-harris answer.  \nList the columns:\nremove = [x for x in df.columns if 'job' in x or 'birth' in x]\nremove += ['name', 'userID', 'IgID']\ndf = df.drop(remove, axis=1)  # axis=1 to drop columns, 0 for rows.","Q_Score":2,"Tags":"python,pandas,numpy,dataframe,indexing","A_Id":53161823,"CreationDate":"2018-11-05T19:38:00.000","Title":"How to return a new dataframe excluding certain columns?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is good documentation on persisting Numpy arrays in Joblib using a memory-mapped file.\nIn recent versions, Joblib will (apparently) automatically persist and share Numpy arrays in this fashion.\nWill Pandas data frames also be persisted, or would the user need to implement persistence manually?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":488,"Q_Id":53162741,"Users Score":1,"Answer":"Since Pandas data frames are built on Numpy arrays, yes, they will be persisted.\nJoblib implements its optimized persistence by hooking in to the pickle protocol. Anything that includes numpy arrays in its pickled representation will benefit from Joblib's optimizations.","Q_Score":1,"Tags":"python,python-3.x,pandas,parallel-processing,joblib","A_Id":55496917,"CreationDate":"2018-11-05T21:51:00.000","Title":"Joblib persistence and Pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a little confused with the difference between conv2d and conv3d functions. \nFor example, if I have a stack of N images with H height and W width, and 3 RGB channels. The input to the network can be two forms\nform1: (batch_size, N, H, W, 3) this is a rank 5 tensor\nform2: (batch_size, H, W, 3N ) this is a rank 4 tensor\nThe question is\uff0c if I apply conv3d with M filters with size (N,3,3) to form1 and apply conv2d with M filters with size (3,3)\nDo they have basicly the same feature operations? I think both of these forms convolve in temporal and spatial dimension.\nI really appreciate if anyone can help me figure this out.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":10046,"Q_Id":53164733,"Users Score":3,"Answer":"If you have a stack of images, you have a video. You can not have two input forms. You have either images or videos. For the video case you can use 3D convolution and 2D convolution is not defined for it. If you stack the channels as you mentioned it (3N) the 2D convolution will interpret the stack as one image with a lot of channels, but not as stack.\nNote here that a 2D convolution with (batch, H, W, Channels) is the same as an 3D convolution with (batch, H, W, Channels, 1).","Q_Score":5,"Tags":"python,tensorflow,neural-network,deep-learning,convolution","A_Id":53169648,"CreationDate":"2018-11-06T01:51:00.000","Title":"Difference between Conv3d vs Conv2d","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to model a four generational family tree starting with a couple. After that if I input a name of a person and a relation like 'brother' or 'sister' or 'parent' my code should output the person's brothers or sisters or parents. I have a fair bit of knowledge of python and self taught in DSA. I think I should model the data as a dictionary and code for a tree DS with two root nodes(i.e, the first couple). But I am not sure how to start. I just need to know how to start modelling the family tree and the direction of how to proceed to code. Thank you in advance!","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":6151,"Q_Id":53166322,"Users Score":5,"Answer":"There's plenty of ways to skin a cat, but I'd suggest to create:\n\nA Person class which holds relevant data about the individual (gender) and direct relationship data (parents, spouse, children).\nA dictionary mapping names to Person elements.\n\nThat should allow you to answer all of the necessary questions, and it's flexible enough to handle all kinds of family trees (including non-tree-shaped ones).","Q_Score":0,"Tags":"python,algorithm,family-tree","A_Id":53166406,"CreationDate":"2018-11-06T05:41:00.000","Title":"Family tree in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am really new to Tensorflow as well as gaussian mixture model.\nI have recently used tensorflow.contrib.distribution.MixtureSameFamily class for predicting probability density function which is derived from gaussian mixture of 4 components.\nWhen I plotted the predicted density function using \"prob()\" function as Tensorflow tutorial explains, I found the plotted pdf with only one mode. I expected to see 4 modes as the mixture components are 4.\nI would like to ask whether Tensorflow uses any global mode predicting algorithm in their MixtureSameFamily class. If not, I would also like to know how MixtureSameFamily class forms the pdf with statistical values.  \nThank you very much.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":339,"Q_Id":53167161,"Users Score":0,"Answer":"I found an answer for above question thanks to my collegue. \nThe 4 components of gaussian mixture have had very similar means that the mixture seems like it has only one mode.\nIf I put four explicitly different values as means to the MixtureSameFamily class, I could get a plot of gaussian mixture with 4 different modes.\nThank you very much for reading this.","Q_Score":0,"Tags":"python,tensorflow,gmm","A_Id":53184428,"CreationDate":"2018-11-06T07:03:00.000","Title":"Tensorflow MixtureSameFamily and gaussian mixture model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently the integration between Spark structures and Dask seems cubersome when dealing with complicated nested structures. Specifically dumping a Spark Dataframe with nested structure to be read by Dask seems to not be very reliable yet although the parquet loading is part of a large ongoing effort (fastparquet, pyarrow);\nso my follow up question - Let's assume that I can live with doing a few transformations in Spark and transform the DataFrame into an RDD that contains custom class objects; Is there a way to reliably dump the data of an Spark RDD with custom class objects and read it in a Dask collection? Obviously you can collect the rdd into a python list, pickle it and then read it as a normal data structure but that removes the opportunity to load larger than memory datasets. Could something like the spark pickling be used by dask to load a distributed pickle?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":460,"Q_Id":53169690,"Users Score":0,"Answer":"I solved this by doing the following\nHaving a Spark RDD with a list of custom objects as Row values I created a version of the rdd where I serialised the objects to strings using cPickle.dumps. Then converted this RDD to a simple DF with string columns and wrote it to parquet. Dask is able to read parquet files with simple structure. Then deserialised with cPickle.loads to get the original objects","Q_Score":1,"Tags":"python,pyspark,dask,dask-distributed,fastparquet","A_Id":53173320,"CreationDate":"2018-11-06T10:07:00.000","Title":"Is there any good way to read the content of a Spark RDD into a Dask structure","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My Pycharm is autogenerating imports of this form: from submodule.subsub import myfunction. The root module , under which submodule sits, is missing in this import command. Yet this runs OK on my machine  (Ubuntu). \nIn my colleague's machine (Windows; I don't know if that makes a difference), Pycharm correctly generates  from root.submodule.subsub import myfunction, which runs OK on my machine too. \nHow do I get Pycharm  to generate the full path on my machine? How do I get Python and Pycharm to correctly tell me that the abbreviated path is an error?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":53172671,"Users Score":2,"Answer":"The issue is due to the fact Pycharm does not detect the correct folder as the root of the project.\nYou can define any folder as the Root by right clicking on it going to Mark Directory as -> Sources Root. The folder color will change from grey to blue. Changing the Root directory changes the behavior of these auto-generated statements in my experience.","Q_Score":3,"Tags":"python-3.x,pycharm,python-import","A_Id":61328524,"CreationDate":"2018-11-06T13:15:00.000","Title":"Defining consistent (and legal) import style in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run a program on our cluster environment which requires python 2.7. The thing is the version installed on the cluster is 2.6.6. Therefore, I tried to update the python version in my own folder. To do so, first I used module avail python command, but nothing showed up!!! Afterward, I tried which python2.7 on the command line, and I noticed that it exist in \/usr\/bin\/python2.7. Going into the given subfolder, I tried module load python2.7 but I faced the following error:\nModuleCmd_Load.c(208):ERROR:105: Unable to locate a modulefile for 'python2.7'\nI would be very thankful if someone could tell me how can I solve my problem.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":277,"Q_Id":53173713,"Users Score":0,"Answer":"The module command you use needs to find a modulefile for the module python2.7 you try to load. If such modulefile is found it usually updates the shell environment to active the software in question.\nIn the situation you describe, it seems there is no python module available by default currently. Which means you either:\n\nneed to find the modulepath to activate with the module use command where those python modulefiles are located\nor write a modulefile to enable this python2.7 installation and save it in an existig modulepath directory","Q_Score":0,"Tags":"python-2.7,cluster-computing,python-2.6,updating,environment-modules","A_Id":53185454,"CreationDate":"2018-11-06T14:16:00.000","Title":"Updating Python in my folder on the cluster","Data Science and Machine Learning":0,"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 process running in one of .ipynb document in jupyter for many hours using Python3 kernel. I don't need it to die. I was working in the other document in parallel using the same Python3 kernel and the process got stuck. \nI wonder if I can restart kernel for one document only? Or at least to stop the process for this document. Interrupt the kernel button doesn't work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":656,"Q_Id":53176220,"Users Score":2,"Answer":"Jupyter typically starts a new kernel for each notebook you open. So even if you have two Python 3 notebooks running, the kernels are not the same.","Q_Score":1,"Tags":"python,jupyter-notebook,jupyter,jupyter-kernel","A_Id":57064149,"CreationDate":"2018-11-06T16:40:00.000","Title":"Restarting kernel for one and only one .ipynb document in jupyter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a lambda that iterates over all the files in a given S3 bucket and deletes the files in S3 bucket. The S3 bucket has around 100K files and I am selecting and deleting the around 60K files. I have set the timeout for lambda to max (15 minutes) timeout value. The lambda is consistently returning \"network error\" after few minutes though it seems to run in the background for sometime even after the error is returned. How can get around this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":14183,"Q_Id":53180543,"Users Score":1,"Answer":"I was testing another function and this error came up as a result. Reading a little in the documentation I found that I activated the throttle option, that it reduces the amount of rate for your function.\nThe solution is to create another function and see if the throttle is making that error.","Q_Score":4,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda,boto3","A_Id":65430231,"CreationDate":"2018-11-06T21:47:00.000","Title":"AWS Lambda : Calling the invoke API action failed with this message: Network 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":1},{"Question":"As we all Know, if we want to train a LSTM network, we must reshape the train dataset by the function numpy.reshape(), and reshaping result is like [samples,time_steps,features]. However, the new shape is influenced by the original one. I have seen some blogs teaching LSTM programming taking 1 as time_steps, and if time_steps is another number, samples will change relevently. My question is that does the samplesequal to batch_size?\nX = X.reshape(X.shape[0], 1, X.shape[1])","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":53182773,"Users Score":0,"Answer":"No, samples is different from batch_size. samples is the total number of samples you would have. batch_size would be the size of each batch or the number of samples per each batch used in training, like by .fit. \nFor example, if samples=128 and batch_size=16, then your data would be divided into 8 batches with each having 16 samples inside during .fit call. \nAs another note, time_steps is the total time steps or observations within each sample. It does not make much sense to have it as 1 with LSTM as the main advantage of RNN's in general is to learn the temporal patterns. With time_step=1, there won't be any history to leverage. Here as an example that might help:\nAssume that your job is to determine if someone is active or not every hour by looking at they breathing rate and heart rate provided every minute, i.e. 2 features measured at 60 samples per hour. (This is just an example, use accelerometers if you really wanted to do this :)) Let's say you have 128 hours of labeled data. Then your input data would be of shape (128, 60, 2) and your output would be of shape (128, 1).\nHere, you have 128 samples, 60 time steps or observations per sample, and two features.\nNext you split the data into train, validation, and testing according to the samples. For example, your train, validation, and test data would be of shapes (96, 60, 2), (16, 60, 2), and (16, 60, 2), respectively. \nIf you use batch_size=16, your training, validation, and test data would have 6, 1, and 1 batches, respectively.","Q_Score":0,"Tags":"python-3.x,tensorflow,keras,lstm,rnn","A_Id":53183497,"CreationDate":"2018-11-07T02:17:00.000","Title":"Pit in LSTM programming by python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As we all Know, if we want to train a LSTM network, we must reshape the train dataset by the function numpy.reshape(), and reshaping result is like [samples,time_steps,features]. However, the new shape is influenced by the original one. I have seen some blogs teaching LSTM programming taking 1 as time_steps, and if time_steps is another number, samples will change relevently. My question is that does the samplesequal to batch_size?\nX = X.reshape(X.shape[0], 1, X.shape[1])","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":53182773,"Users Score":0,"Answer":"No. Samples are not equal to batch size. Samples means the number of rows in your data-set. Your training data-set is divided into number of batches and pass it to the network to train. \nIn simple words,\nImagine your data-set has 30 samples, and you define your batch_size as 3. \nThat means the 30 samples divided into 10 batches(30 divided by you defined batch_size = 10). When you train you model, at a time only 3 rows of data will be be pushed to the neural network and then next 3 rows will be push to the neural network. Like wise whole data-set will push to the neural network.\nSamples\/Batch_size = Number of batches\nRemember that batch_size and number of batches are two different things.","Q_Score":0,"Tags":"python-3.x,tensorflow,keras,lstm,rnn","A_Id":53186754,"CreationDate":"2018-11-07T02:17:00.000","Title":"Pit in LSTM programming by python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just started programming in python and pygames.\nWhenever I try running a py file with pygames, the pygames window will appear, but there will be absolutely nothing in it. No errors in the log, but nothing shows, it's just a gray screen.\nI tried running it on IDLE, and through the command line (I'm on a mac so I use the terminal)\nAnd it's not just my programs that aren't showing anything, I've tried to run one of pygames examples, and it will still not display anything. For example, if I run the pygames alien example, the window will appear with a blank gray background. I'll hear the audio for the program, but no display.\nAnything would help, I'm at a loss especially since no errors are showing in the log.\nEDIT1:\nI'm using Python 3 (and I really need to keep using Python 3)\nEDIT2:\nI'm using python 3.7. pygames version 1.9.4. The examples are with the pygames, they were downloaded together, so I assume it's for that version.\nEDIT3:\nok, my OS is Mojave 10.14. I've tried starting the application by: opening the file, running it on IDLE, and running it through the command line, none have worked. python2 is installed, but when I run the pygame it's a python3 file","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3391,"Q_Id":53182886,"Users Score":2,"Answer":"You can also install new pygame using pip install pygame=2.0.0.dev6. This\nworked in my case.","Q_Score":9,"Tags":"python,pygame","A_Id":61076368,"CreationDate":"2018-11-07T02:36:00.000","Title":"Pygame not showing anything in the window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed pylint plugin and restarted the Intellij IDEA. It is NOT external tool (so please avoid providing answers on running as an external tool as I know how to).\nHowever I have no 'pylint' in the tool menu or the code menu. \nIs it invoked by running 'Analyze'? or is there a way to run the pylint plugin on py files?","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":4470,"Q_Id":53183669,"Users Score":5,"Answer":"This is for the latest IntelliJ IDEA version 2018.3.5 (Community Edition):\n\nType \"Command ,\" or click \"IntelliJ IDEA -> Preferences...\"\nFrom the list on the left of the popped up window select \"Plugins\"\nMake sure that on the right top the first tab \"Marketplace\" is picked if it's not\nSearch for \"Pylint\" and when the item is found, click the greed button \"Install\" associated with the found item\n\nThe plugin should then be installed properly.\nOne can then turn on\/off real-time Pylint scan via the same window by navigating in the list on the left: \"Editor -> Inspections\", then in the list on the right unfolding \"Pylint\" and finally checking\/unchecking the corresponding checkbox on the right of the unfolded item.\nOne can also in the same window go the very last top-level item within the list on the left named \"Other Settings\" and unfold it.\nWithin it there's an item called \"Pylint\", click on it.\nOn the top right there should be a button \"Test\", click on it.\nIf in a few seconds to the left of the \"Test\" text there appears a green checkmark, then Pylint is installed correctly.\nFinally, to access the actual Pylint window, click \"View\"->\"Tool Windows\"->\"Pylint\"!\nEnjoy!","Q_Score":4,"Tags":"python,intellij-idea,pylint","A_Id":54933295,"CreationDate":"2018-11-07T04:43:00.000","Title":"How to run pylint plugin in Intellij IDEA?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Visual Studio 2017 has broken me, and I am defecting to PyCharm. \nHowever we have a number of very useful external tools set up.   One of which looks like this: \nTitle: PEP8 Current Module\nCommand: (some path to Python27\\python.exe\nArguments: $(SolutionDir)\\dev_tools\\pep8.py $(ItemPath)\nInitial Directory : $(SolutionDir)  \nWhat can I put in to the Arguments in PyCharm Create Tool dialog to achieve the same thing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":55,"Q_Id":53188365,"Users Score":1,"Answer":"The PyCharm equivalent to $(ItemPath) is the FilePath macro.","Q_Score":0,"Tags":"python,visual-studio-2017,pycharm,external-tools","A_Id":53188404,"CreationDate":"2018-11-07T11:13:00.000","Title":"PyCharm equivalent of Visual Studio $(ItemPath) for External Tools","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need a browser in Selenium to work as if it's maximized, so that website that I process perceived it as maximized, but I want it really to be minimized, so that I could work in parallel while the script executes. The simple: driver.maximize_window() just maximizes windows.\nSo, is there a way for a window of browser to be maximized for website, but in reality minimized?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":554,"Q_Id":53189353,"Users Score":1,"Answer":"If you want to work while WebDriver is executed, you can created a virtual instance (with e.g. VirtualBox or HyperV) an run test suite in VM.","Q_Score":0,"Tags":"python,selenium,webdriver","A_Id":53191171,"CreationDate":"2018-11-07T12:19:00.000","Title":"Is there 'as if' maximized mode of browser in Webdriver Selenium, but in reality minimized?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need a browser in Selenium to work as if it's maximized, so that website that I process perceived it as maximized, but I want it really to be minimized, so that I could work in parallel while the script executes. The simple: driver.maximize_window() just maximizes windows.\nSo, is there a way for a window of browser to be maximized for website, but in reality minimized?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":554,"Q_Id":53189353,"Users Score":0,"Answer":"Maximized is just a browser size from the site perspective. Set the browser size to the screen resolution of your desktop and minimize the browser.","Q_Score":0,"Tags":"python,selenium,webdriver","A_Id":53191735,"CreationDate":"2018-11-07T12:19:00.000","Title":"Is there 'as if' maximized mode of browser in Webdriver Selenium, but in reality minimized?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just recently upgraded to Python 3.7.0 on my Mac via a Homebrew installation.  Unfortunately this process resulted in my prior 3.6.5 installation being removed and as a result Pycharm no longer links to the interpreter.  I went into the Pycharm menu in the following fashion Pycharm >> Preferences >> Project Interpreter and tried to add the new path link to the 3.7.0 installation, which was at Users\/myname\/usr\/local\/Cellar\/python3\/3.7.0\/bin\/python3.7 and I get a message Environment location directory is not empty which indicates I am not linking to the proper item, but if this is not it I am not sure where I should be linking to.  Can anyone point me in the right direction?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2696,"Q_Id":53193173,"Users Score":1,"Answer":"It sounds like you're trying to add the 3.7 installation as a virtual environment, rather than a \"system\" installation of Python. Try this:\n\nOpen the Project Interpreter settings (Cmd+A, search for Project Interpreter)\nClick the settings \"gear\" icon next to the Project Interpreter dropdown\nClick Add\nIn the left-hand sidebar of the \"Add Python Interpreter\" dialog that appears, click \"System Interpreter\" (rather than the default of \"Virtualenv Environment\").\nUse the \". . .\" button to locate your installation.","Q_Score":0,"Tags":"pycharm,python-3.7","A_Id":53325661,"CreationDate":"2018-11-07T15:59:00.000","Title":"How to link the Python 3.7.0 interpreter to Pycharm on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using flask-socketio library in my flask project and eventlet library is necessary to let the emit from child processes through monkey patching, but the problem is when doing eventlet.monkey_patch() the grand-child processes are being ignored. Anyone can help in clearing things up?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":235,"Q_Id":53194141,"Users Score":1,"Answer":"I replaced all the processes with threads\nEven the multi-processing i replaced it with thread pools\nTo make sure they have the same memory in the Ram\nAnd avoid the collision with eventlet with multi-processing","Q_Score":1,"Tags":"python-2.7,asynchronous,flask,socket.io,eventlet","A_Id":53335130,"CreationDate":"2018-11-07T16:51:00.000","Title":"eventlet.monkey_patch() is ignoring child processes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using Tensorflow with python for object detection.\nI want to start training and leave it for a while and keep all training nodes (model-cpk). Standard Tensorflow training seems to delete nodes and only keep the last few nodes. How do I prevent that?\nPlease excuse me if this is the wrong place to ask such questions. I would be oblidged if been told a proper place. Thank you.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":53195482,"Users Score":1,"Answer":"You can use the keep_checkpoint_max flag to tf.estimator.RunConfig in model_main.py.\nYou can set it to a very large number to practically save all checkpoints.\nYou should be warned though that depending on the model size and saving frequency, it might fill up your disk (and therefore crash during training).\nYou can change saving frequency by the flags save_checkpoints_steps or save_checkpoints_secs of RunConfig. The default is to use save_checkpoints_secs, with a default value of 600 (10 minutes).","Q_Score":0,"Tags":"python,tensorflow,machine-learning","A_Id":53204495,"CreationDate":"2018-11-07T18:20:00.000","Title":"Tensorflow training, how to prevent training node deletion","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Tensorflow with python for object detection.\nI want to start training and leave it for a while and keep all training nodes (model-cpk). Standard Tensorflow training seems to delete nodes and only keep the last few nodes. How do I prevent that?\nPlease excuse me if this is the wrong place to ask such questions. I would be oblidged if been told a proper place. Thank you.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":53195482,"Users Score":0,"Answer":"You can save modelcheckpoints as .hdf5 files are load them again when wanting to predict on test data.\nHope that helps.","Q_Score":0,"Tags":"python,tensorflow,machine-learning","A_Id":53205258,"CreationDate":"2018-11-07T18:20:00.000","Title":"Tensorflow training, how to prevent training node deletion","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run BUSCO using a FASTA file using my mac commandline. Unfortunately when doing so I receive the following message:\n$ busco -i \/Volumes\/WORK\/research_project\/pseudomonas_putida\/ncbi-genomes-2018-10-24\/GCA_000007565.2_ASM756v2_genomic.fna -o \/users\/williamimart\/Desktop\/test -l \/\/Volumes\/WORK\/research_project\/busco_datasets\/gammaproteobacteria_odb9 -m geno\nMaximum number of regions limited to: 3\nTraceback (most recent call last):\n  File \"\/Users\/williamimart\/miniconda2\/bin\/busco\", line 204, in \n    if mode == 'genome' and os.access(os.environ.get('AUGUSTUS_CONFIG_PATH'),os.W_OK) == False:\nTypeError: coercing to Unicode: need string or buffer, NoneType found\nWhat can I do to go around this problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":53195972,"Users Score":0,"Answer":"I'm guessing you'll need to export the AUGUSTUS_CONFIG_PATH. The os.environ.get() is a place that could return None if you don't have that variable configured\nThe default value for that is not something clear to me as I don't have experience with this library, but the way to add that would be to run\nexport AUGUSTUS_CONFIG_PATH=\/some\/path\/to\/conf\nCheck their docs for what to set that path value to","Q_Score":0,"Tags":"python,string","A_Id":53198719,"CreationDate":"2018-11-07T18:54:00.000","Title":"How do I bypass \"TypeError: coercing to Unicode: need string or buffer, NoneType\" message on Python on the mac terminal (BUSCO)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a model for object detection (Faster RCNN from Tensorflow's Object Detection API) running on Google Cloud ML. I also have some code to filter the resulting bounding boxes based on size, aspect ratio etc.\n\nIs it possible to run this code as part of the prediction process so I don't need to run a separate process to do it afterwards.\nIs it possible to limit the number of bounding boxes predicted by the model based on some confidence threshold, as currently outputting a lot of extraneous data.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":53196467,"Users Score":0,"Answer":"I'll answer (1): we have an Alpha API that will permit this. Please contact cloudml-feedback@google.com for more information.","Q_Score":1,"Tags":"python,tensorflow,google-cloud-ml","A_Id":53202686,"CreationDate":"2018-11-07T19:29:00.000","Title":"Can you post process results from Cloud ML's prediction output?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python GUI made with tkinter and I want to define a callback method to be called when the items in a listbox change:\n\nItem added to the listbox\nItem deleted from the listbox\n\nI think that should be possible with bindings but I am not sure what is the exact binding name.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":53198575,"Users Score":0,"Answer":"There are no built-in events when data is added to or removed from a listbox. However, since it's your code that adds and removes the data, you can generate your own events with event_generate whenever you update the listbox.","Q_Score":0,"Tags":"python,tkinter","A_Id":53198841,"CreationDate":"2018-11-07T22:04:00.000","Title":"python tkinter Listbox bind with items updated","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to track down the docs for the various distributions in scipy.stats.  It is easy enough to google around for them, but I like to use the built-in help function for kicks sometimes.  Through a series of help calls, can find that scipy has a stats module and that scipy.stats has a binom distribution.  However, at that point, using help becomes tricky.  help(scipy.stats.binom) actually returns a help document for a class named binom_gen which inherits methods from some parent abstract class whose __init__ method is utterly uninformative.  However, it does provide the following hint:  \"See help(type(self)) for accurate signature.\"  Okay.  Since I do not have access to self from outside of the class code itself, I assume that this means \"go ahead and instantiate an object, and then call help.\"  After some trial and error on getting literally any old parameters to not raise an Exception (specifically, scipy.stats.binom(0.5,0.5) returns successfully), we can call help on that thing.\nBoth help(scipy.stats.binom(0.5,0.5)) and help(type(scipy.stats.binom(0.5,0.5)) give the docs for class rv_frozen, which is equally uninformative, and actually gives the same suggestion to: \"See help(type(self)) for accurate signature.\"\nHow do I access the help for distributions in scipy.stats?  More generally, is there a meaningful way to navigate an abstract class morass via successive calls to the help function, or must I simply know a priori the class ultimately returned by these factories?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":70,"Q_Id":53198927,"Users Score":1,"Answer":"If you use ipython then I believe scipy.stats.binom? achieves this.","Q_Score":0,"Tags":"python,scipy","A_Id":53199041,"CreationDate":"2018-11-07T22:35:00.000","Title":"scipy stats distributions documentation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Import Data command in Enthought Canopy fails with: \n\nThe Data Import Tool requires that the Canopy Python kernel be running in Pylab mode with Qt4 interactive backend. You can change back to this setting in your Canopy preferences (Python tab).\n\nI have changed the stated settings in preferences as the error message suggests. \nWhat could be the problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":133,"Q_Id":53199613,"Users Score":0,"Answer":"If you're running Python 3.5, perhaps you didn't install the PyQt packages? If you are a subscriber, please feel free to submit a feedback report from the Canopy Help menu which will provide Enthought with your configuration info. (If you are not a logged-in subscriber, then the Data Import Tool is not supported anyway, though I would not expect this error message in that case.)","Q_Score":0,"Tags":"python,matplotlib,import,enthought,canopy","A_Id":53200709,"CreationDate":"2018-11-07T23:47:00.000","Title":"Import Data command in Enthought Canopy fails with: \u201cThe Data Import Tool requires...\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to install Python on a VM, Google Cloud, and I am encountering the following error:\n\n0x80070659.\n\nI can't bypass this error using regedit or administrator tool. In this machine, I have Windows Server 2016.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":607,"Q_Id":53199656,"Users Score":0,"Answer":"Try to run with admin credentials. If its not working then check whether any policy is defined under Software Restriction Policies in Local Security Settings. \nIf there are no policies defined then create a new policy and double click on enforcement.","Q_Score":1,"Tags":"python,installation","A_Id":53200891,"CreationDate":"2018-11-07T23:53:00.000","Title":"I can't install python on vm, error setup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Tensorflow used to work on my computer. But now when I try to import tensorflow python itself errors out. I am not given a traceback call to tell me what the error  is. I get a window's prompt that says \"Python has stopped working\". When I click \"debug\" all I get is \"An unhandled win32 exception occurred in python.exe\". I've never had a python package actually error out python itself for me, I've always just had a traceback error thrown by python if I didn't install something right. \nI've tried uninstalling and reinstalling tensorflow (effectively updating from 1.7.0 to 1.12.0) but that has not helped. I'm not sure how to search for a solution to this problem either since I'm not given a traceback or an error code or an error message aside from the very generic one above.\nI'm currently using python 3.6.5 with tensorflow 1.12.0 (CPU only) installed. My OS is Windows 7 Enterprise 64 bit.  \nAny ideas? \nEDIT: The python distro I am using is through Anaconda and I'm trying to run python directly through the anaconda prompt (command line interface). \nEDIT2: I used the faulthandler module to see if I can get a stack trace out of it, and I got a Windows fatal exception: code 0xc0000139 and a  Windows fatal exception: access violation, along with a bunch of lines linking to various frozen importlib._bootstrap lines of code in various __init__.py modules.\nEDIT3: For a bit more context, this is on a workplace machine with a lot of security software installed on it.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2939,"Q_Id":53199675,"Users Score":9,"Answer":"I have solved the issue. The following procedure was used to find and fix the problem:\nI used the faulthandler module to force python to print out a stack trace and recieved a Windows fatal exception: access violation error which seems to suggest the problem was indeed a segfault caused by some module used by tensorflow.\nI tried to fix dependencies by doing a conda update --all and then a conda clean --all which didn't fix the problem. \nI noticed though that the problems seems to arise from the h5py and keras modules so I did pip install --upgrade h5py and pip install --upgrade keras and pip install --upgrade tensorflow and the problem was fixed. I am now using tensorflow version 1.12.0, keras version 2.2.4, and h5py version 2.8.0.\nThe key to solving this problem seems to be the faulthander module which showed me which modules (h5py and keras) were leading to the segfault.","Q_Score":12,"Tags":"python,python-3.x,tensorflow","A_Id":53286280,"CreationDate":"2018-11-07T23:57:00.000","Title":"Importing tensorflow makes python 3.6.5 error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"my program have one server socket and multiple client socket,\nso, what i want do is When the server close(shutdown),change one of the client sockets to server socket.\nis there a way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":457,"Q_Id":53200594,"Users Score":0,"Answer":"what i want do is When the server close(shutdown),change one of the\n  client sockets to server socket. is there a way to do this?\n\nNo -- once a TCP socket is connected, it can only be used for that one TCP connection, and once the TCP connection has been broken (e.g. by the server exiting), then all you can do with the socket is close it.\nHowever, that doesn't mean you can't have a high-availability chat system like the one you are envisioning.  What you can do is have your clients \"plan ahead\" by gathering the IP addresses of all the other clients in advance (either through the server, or if all the clients are on the same LAN, perhaps through broadcast or multicast UDP packets).  That way, if\/when the server goes away, the clients all have another IP address handy that they can automatically try to connect to (using a new TCP socket).\nNote that you'll need to make sure that the program running at that IP address is accepting incoming TCP connections (server-style); you also might want to specify some kind of rule so that all of the clients will reconnect to the same IP address (e.g. sort the IP addresses numerically and have all the clients try to connect to the smallest IP address in the list, or something like that).","Q_Score":1,"Tags":"python,sockets","A_Id":53202099,"CreationDate":"2018-11-08T02:14:00.000","Title":"Python Socket programming change server socket","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am working on NLP using python and nltk. \nI was wondering whether is there any dataset which have bags of words which shows keywords relating to emotions such as happy, joy, anger, sadness and etc\nfrom what i dug up in the nltk corpus, i see there are some sentiment analysis corpus which contain positive and negative review which doesn't exactly related to keywords showing emotions.\nIs there anyway which i could build my own dictionary containing words which shows emotion for this purpose? is so, how do i do it and is there any collection of such words?\nAny help would be greatly appreciated","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":822,"Q_Id":53200934,"Users Score":0,"Answer":"I'm not aware of any dataset that associates sentiments to keywords, but you can easily built one starting from a generic sentiment analysis dataset.\n1) Clean the datasets from the stopwords and all the terms that you don't want to associate to a sentiment. \n2)Compute the count of each words in the two sentiment classes and normalize it. In this way you will associate a probability to each word to belong to a class. Let's suppose that you have 300 times the word \"love\" appearing in the positive sentences and the same word appearing 150 times in the negative sentences. Normalizing you have that the word \"love\" belongs with a probability of 66% (300\/(150+300)) to the positive class and 33% to the negative one.\n3) In order to make the dictionary more robust to the borderline terms you can set a threshold to consider neutral all the words with the max probability lower than the threshold.   \nThis is an easy approach to build the dictionary that you are looking for. You could use more sophisticated approach as Term Frequency-Inverse Document Frequency.","Q_Score":0,"Tags":"python,nlp,nltk","A_Id":53211031,"CreationDate":"2018-11-08T02:59:00.000","Title":"nltk bags of words showing emotions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a Thrift proxy, with Apache Thrift, to filter some requests directed to a Thrift server.\nThe flow should be like Thrift Client <-> Proxy <-> Thrift Server for all RPC calls.\nBasically the Thrift server binds to some services that expose some callable methods. I want to develop a proxy which is able to filter any requests: the client is allowed to call only some methods on some services so I want to discard any request which is not allowed.\nI can't modify the Thrift Server code that's why I need a proxy.\nIs there any solution or Thrift class which would be good in this case?\nRight now I am using python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":357,"Q_Id":53202066,"Users Score":0,"Answer":"Nothing specific in trunk to do this, however you could easily write a quick service implementation using the same IDL the real server uses. Your service could them filter client calls as needed and call through to the real server when appropriate. Your service would thus be a server to the client and a client to the real server. It would probably be good to throw a TApplicationException back to the client for calls you want to reject.","Q_Score":1,"Tags":"python,proxy,rpc,thrift,thrift-protocol","A_Id":53714191,"CreationDate":"2018-11-08T05:35:00.000","Title":"Apache Thrift proxy for filtering requests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"How do I save a '.txt' file as a '.mat' file, using either MATLAB or Python?\nI tried using textscan() (in MATLAB), and scipy.io.savemat() (in Python). Both didn't help.\nMy text file is of the format: value1,value2,value3,valu4 (each row) and has over 1000 rows.\nAppreciate any help is appreciated. Thanks in advance.","AnswerCount":3,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":880,"Q_Id":53203507,"Users Score":-3,"Answer":"if what you need is to change file format:\nmv example.mat example.txt","Q_Score":0,"Tags":"python-2.7,matlab,text-files,mat-file","A_Id":53203802,"CreationDate":"2018-11-08T08:00:00.000","Title":"How to save a text file to a .mat file?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a technique which could help us find the relation in between a categorical dependent variable and combination of independent variables (Y ~ X1*X2+X2*X3+X3*X4), here among X1 to X4 we have few categorical columns and few continuous columns. \nI am working on a classification problem and I want to check what combination of independent columns are highly related to dependent columns.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":53204674,"Users Score":0,"Answer":"I am not sure if I correctly understand your question, but from what I understand:\nYou can try to convert your continuous columns to buckets, which means effectively converting them as categorical as well and then find correlation between them.","Q_Score":0,"Tags":"python,machine-learning,statistics,analysis","A_Id":53205313,"CreationDate":"2018-11-08T09:18:00.000","Title":"relation in between a categorical dependent variable and combination of independent variables","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a python flask application in combination with rethinkDB.\nsnippit structure: \n{'Name': ['Gandalf', 'Jackson'], 'street': 'elmStreet'...}\nThis kind of structure is used multiple times, so basically I have all my keys as a string and my values are either also strings or an array with strings.\nSo I want a full-text search on this structure without using ElasticSearch or any additional program if it is possible.\nThanks for reading, have a nice day :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":53204729,"Users Score":0,"Answer":"I solved my issue, by using the python search engine whoosh, for it no additional program is needed.","Q_Score":0,"Tags":"rethinkdb-python","A_Id":53299934,"CreationDate":"2018-11-08T09:23:00.000","Title":"Rethinkdb: search a string in whole table (full text search like)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In Jupyter Notebook, I am able to convert a notebook to pdf and HTML using nbconvert. However, there is no way to convert it into .doc(Word Document). Is there a way to convert it to MS Word keeping the same text highlights and table structure?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32558,"Q_Id":53207734,"Users Score":0,"Answer":"Use the command \"jupyter notebook filename.ipynb\" to run the notebook in a browser.\nUse the notebook's File menu to Download as HTML.\nOpen MS Word, and, from Word, open the HTML file.\n\nThis gives a copy of the notebook that is more faithful to the original notebook than, for example, going via markdown and pandoc, which does not render the notebook perfectly.\nYou can then carry out any Word operation you like (eg. save as docx, indicate changes using Track Mode TRK, etc, etc).\nI have not tried tables. Could someone try using tables with this technique and give feedback?","Q_Score":11,"Tags":"python-3.x,jupyter-notebook,nbconvert,.doc","A_Id":70084518,"CreationDate":"2018-11-08T12:26:00.000","Title":"Convert Jupyter notebook into MS word document .doc?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to put my Keras NER model up to my website which is Django based.\nMy question is that when served, should the model be run on CPU or GPU? How would a GPU handle let's say hundreds of users sending requests at the same time since it cant do multi threading like CPUs can.  \nThanks for your time.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":107,"Q_Id":53212713,"Users Score":0,"Answer":"\"hundreds of users\" will necessitate using a GPU.\nknowing what your users are doing might give more insight, but I would consider having a dedicated instance for your model.  Design a small program that is persistent and waits for input data using a queue strategy.\nLet's say you have \"100s\" of users uploading \"text documents\" for your ner model. Your web application would gather\/validate the text upload\/post and make a socket connection to your model server, pass the text, receive the response, parse the response and respond to the user accordingly.\nYour model server has a socket listener that upon connection, passes the socket+data request to a queue. Your model sits and waits...looking at that queue--takes any item in the queue, processes and passes the results back via the included socket(serialized handle). It's a bit messy in python but works fine.\nThe reasons to have a persistent model running:\n1) for \"100s\" of users, spinning up a model app each time takes several seconds. having it already initialized and ready to go will help user experience.\n2) using one gpu server you don't want competition for gpu resources.","Q_Score":0,"Tags":"python,django,keras","A_Id":53214235,"CreationDate":"2018-11-08T17:03:00.000","Title":"Keras Model Serving- GPU vs CPU","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I hope the title is pretty self explanatory. I set up a database and web-server on the same machine using Amazon RDS and EC2 instance. I am running a Python script in the machine's cgi folder, and am having trouble connecting to the database. The errors are on the order of: _mysql_exceptions.OperationalError: (2003, \"Can't connect to MySQL server on '127.0.0.1' (111)\") \nI have tried this with mySQLdb and _mysql without success. What I can't understand is that I am able to successfully connect to the mysql client via the command line with mysql -u username -p -h edutechfinal.cqk0lckbky4e.us-east-2.rds.amazonaws.com but not inside the script. \nThis is what I have tried in the Python script\ndb = _mysql.connect(\"127.0.0.1\",\"st4rgut25\",\"pwd\",\"st4rgut25\")\nand \ndb = MySQLdb.connect(host=\"127.0.0.1\",user=\"st4rgut25\",passwd=\"pwd\",db=\"st4rgut25\")","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":175,"Q_Id":53215921,"Users Score":1,"Answer":"The RDS instance is not running on the EC2 instance, they're separate \"machines\". From the EC2 instance, instead of using the loopback address 127.0.0.1, which would assume MySQL is running on the local EC2 instance, just use the host name edutechfinal.cqk0lckbky4e.us-east-2.rds.amazonaws.com as you're doing from the MySQL client.","Q_Score":0,"Tags":"python,mysql,amazon-ec2,amazon-rds","A_Id":53215979,"CreationDate":"2018-11-08T20:50:00.000","Title":"Can Connect to Database via Command Line but not in Python Script?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Assume I got a directory, which consist of a folder having some python scripts.\nI want to import the folder to get the functions in those python scripts.\nIf I am at the same directory, I can import folder_name. \nBut problem starts, when folder_name = actual_python_package_name.\ne.g.:\nyour folders name is numpy, import numpy imports the lib.\nAny way to make python to choose the folder instead of the package while importing?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":497,"Q_Id":53217155,"Users Score":0,"Answer":"If you add an __init__.py to your folder to turn it into a python package, it should be imported instead of other python libraries. The order is determined by sys.path.\nBut why not simply avoid name collisions?","Q_Score":0,"Tags":"python,import,package,directory,equals","A_Id":53217507,"CreationDate":"2018-11-08T22:32:00.000","Title":"importing xxx as a folder when xxx is package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Assume I got a directory, which consist of a folder having some python scripts.\nI want to import the folder to get the functions in those python scripts.\nIf I am at the same directory, I can import folder_name. \nBut problem starts, when folder_name = actual_python_package_name.\ne.g.:\nyour folders name is numpy, import numpy imports the lib.\nAny way to make python to choose the folder instead of the package while importing?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":497,"Q_Id":53217155,"Users Score":0,"Answer":"I think if you come from one step back in your directories :\nfor example from previous_folder.your_main_folder import your_function \nshould be work maybe.","Q_Score":0,"Tags":"python,import,package,directory,equals","A_Id":53217431,"CreationDate":"2018-11-08T22:32:00.000","Title":"importing xxx as a folder when xxx is package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have scripts that make lots of plots. I save them directly with plt.savefig() rather than plt.show() so I don't have to close all the windows. In spyder, they all show up in the console if I use inline (meaning I have to scroll way back to see other output), and they all show up in separate windows if I use automatic. I want them to not show up at all, because I'm not calling plt.show() ever. How can I do that?\nnb: Both the suggested answers work! Thanks! I selected plt.ioff() as the correct answer since I can choose to do this for some scripts and not others.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5354,"Q_Id":53217247,"Users Score":0,"Answer":"In case anyone is still struggling with this issue, I figured that adding a plt.close() after plt.savefig() will do the work. (I'm using Spyder 5.1.5 with Python 3.8.12)","Q_Score":6,"Tags":"python,matplotlib,spyder","A_Id":70022895,"CreationDate":"2018-11-08T22:42:00.000","Title":"Stop showing plots in spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project using AWS ECS. I want to use Celery as a distributed task queue. Celery Worker can be build up as EC2 type, but because of the large amount of time that the instance is in the idle state, I think it would be cost-effective for AWS Fargate to run the job and quit immediately.\nDo you have suggestions on how to use the Celery Worker efficiently in the AWS cloud?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5029,"Q_Id":53218715,"Users Score":6,"Answer":"Fargate launch type is going to take longer to spin up than EC2 launch type, because AWS is doing all the \"host things\" for you when you start the task, including the notoriously slow attaching of an ENI, and likely downloading the image from a Docker repo. Right now there's no contest, EC2 launch type is faster every time.\nSo it really depends on the type of work you want the workers to do. You can expect a new Fargate task to take a few minutes to enter a RUNNING state for the aforementioned reasons. EC2 launch, on the other hand, because the ENI is already in place on your host and the image is already downloaded (at best) or mostly downloaded (likely worst), will move from PENDING to RUNNING very quickly.\n\nUse EC2 launch type for steady workloads, use Fargate launch type for burst capacity\nThis is the current prevailing wisdom, often discussed as a cost factor because Fargate can't take advantage of the typical EC2 cost savings mechanisms like reserved instances and spot pricing. It's expensive to run Fargate all the time, compared to EC2.\nTo be clear, it's perfectly fine to run 100% in Fargate (we do), but you have to be willing to accept the downsides of doing that - slower scaling and cost.\nNote you can run both launch types in the same cluster. Clusters are logical anyway, just a way to organize your resources.\n\nExample cluster\nThis example shows a static EC2 launch type service running 4 celery tasks. The number of tasks, specs, instance size and all doesn't really matter, do it up however you like. The important thing is - EC2 launch type service doesn't need to scale; the Fargate launch type service is able to scale from nothing running (during periods where there's little or no work to do) to as many workers as you can handle, based on your scaling rules.\nEC2 launch type Celery service\nRunning 1 EC2 launch type t3.medium (2vcpu\/4GB).\nMin tasks: 2, Desired: 4, Max tasks: 4\nRunning 4 celery tasks at 512\/1024 in this EC2 launch type.\nNo scaling policies\nFargate launch type Celery service\nMin tasks: 0, Desired: (x), Max tasks: 32\nRunning (x) celery tasks (same task def as EC2 launch type) at 512\/1024\nAdd scaling policies to this service","Q_Score":5,"Tags":"python,amazon-web-services,celery,amazon-ecs,aws-fargate","A_Id":53268305,"CreationDate":"2018-11-09T01:48:00.000","Title":"Operating the Celery Worker in the ECS Fargate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I was wondering if there is a way to run two python scripts at the same time through the command prompt. \nI also am wondering if there is a way to run a second python script after another one has already been executed and is currently running. \nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3871,"Q_Id":53219802,"Users Score":7,"Answer":"To execute 2 script at the same time, execute python script1.py & python script2.py\nTo execute one after the other (without waiting for the first one to finish), you could simply open 2 command prompt windows. Execute each script in each window.\nTo execute one after the other (after waiting for the first one to finish successfully), execute python script1.py && python script2.py","Q_Score":1,"Tags":"python","A_Id":53219822,"CreationDate":"2018-11-09T04:16:00.000","Title":"Is there a way to run two python programs in command prompt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I ran pip install hypothesis[pandas] I got the following:\nCollecting hypothesis[pandas]\n  Using cached https:\/\/files.pythonhosted.org\/packages\/36\/58\/222aafec5064d12c2b6123c69e512933b1e82a55ce49015371089d216f89\/hypothesis-3.82.1-py3-none-any.whl\n  hypothesis 3.82.1 does not provide the extra 'pandas'\n\npip install hypothesis[django] seemed to work and hypothesis.extra has django but not pandas. Any idea what is going on with the pip install for pandas and numpy extras?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":432,"Q_Id":53221061,"Users Score":0,"Answer":"fixed my problem with \n\npip install hypothesis[all]\n\nand also realizing that hypothesis.extra tab completion only showed django, and that pandas and numpy extras seem to need to be imported explicitly.","Q_Score":2,"Tags":"python-hypothesis","A_Id":53235950,"CreationDate":"2018-11-09T06:50:00.000","Title":"pip install hypothesis[pandas] says hypothesis3.82.1 does not provide the extra 'pandas'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My remote MySQL database and local MySQL database have the same table structure, and the remote and local MySQL database is utf-8charset.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":254,"Q_Id":53221361,"Users Score":0,"Answer":"You'd better merge value and sql template string and print it , make sure the sql is correct.","Q_Score":0,"Tags":"python,mysql,sql,pymysql","A_Id":53221802,"CreationDate":"2018-11-09T07:20:00.000","Title":"how do I insert some rows that I select from remote MySQL database to my local MySQL database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to make some amendments to the keras.json file for a sagemaker notebook instance but I am unsure where it is located. Any help would be greatly appreciated.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":53224172,"Users Score":1,"Answer":"Thank you for using Amazon SageMaker! \nYou can find keras.json file located in \/home\/ec2-user\/.keras . \nThanks,\nNeelam","Q_Score":0,"Tags":"python,amazon-web-services,keras,amazon-sagemaker","A_Id":53347423,"CreationDate":"2018-11-09T10:42:00.000","Title":"How can I update the keras.json file on Sagemaker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Airflow version 1.8\nPython version 3.6\ni am getting No module named 'MySQLdb' error\nwhen i configure the Airflow with LocalExecutor and Mysql as metadata database.\ni am not able to install the MySQLdb package due to version issue.\nanyone having idea how to solve this issue?\nThanks\nKalanidhi","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1053,"Q_Id":53225462,"Users Score":0,"Answer":"after configuring airflow.cfg like sql_alchemy_conn = mysql+pymysql:\/\/airflowuser:mysql@localhost:3306\/airflowdb its started working. Actually here i am using pymysql package instead of MySQLdb package(@joeb: - it seems MySQLdb package not supporting python 3+ version)","Q_Score":0,"Tags":"python-3.6,mysql-python,airflow","A_Id":53239536,"CreationDate":"2018-11-09T12:09:00.000","Title":"Apache Airflow + Python 3.6 + Local Executor + Mysql as a metadata database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'd like to build docs using Sphinx, but without any JavaScript. Is there a straight forward way to configure Sphinx not to include any JavaScript? Setting an empty html_js_files in the conf.py doesn't do the trick.\nObviously there will be some functionality missing, like the search box. However it seems that no core functionality that I care about is impacted when manually removing the scripts.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":408,"Q_Id":53227558,"Users Score":2,"Answer":"Modify your theme's template where the JavaScript is included, removing that HTML tag.","Q_Score":4,"Tags":"python-sphinx","A_Id":53236753,"CreationDate":"2018-11-09T14:24:00.000","Title":"Sphinx docs without JavaScript","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to use Keras Sequential, however, my jupyter notebook is flooded with error as it's not able to import tensorflow in the backend (i think). Later I found that, its not with Keras, but I am not able to do 'import tensorflow as tf' as well.\nAny suggestions, please?\nI am using python 3.5.6\ntensorflow 1.12\nI did, pip install tensorflow for installation.\nImportError                               Traceback (most recent call last)\n~\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow.py in swig_import_helper()\n     17         try:\n---> 18             fp, pathname, description = imp.find_module('_pywrap_tensorflow', [dirname(file)])\n     19         except ImportError:\n~\\AppData\\Local\\Continuum\\anaconda3\\lib\\imp.py in find_module(name, path)\n    295     else:\n--> 296         raise ImportError(_ERR_MSG.format(name), name=name)\n    297 \nImportError: No module named '_pywrap_tensorflow'\nDuring handling of the above exception, another exception occurred:\nModuleNotFoundError                       Traceback (most recent call last)\n~\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\tensorflow\\python__init__.py in \n     53     # use dlopen() for dynamic loading.\n---> 54     from tensorflow.python import pywrap_tensorflow\n     55 except ImportError:\n~\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow.py in \n     27             return _mod\n---> 28     _pywrap_tensorflow = swig_import_helper()\n     29     del swig_import_helper\n~\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow.py in swig_import_helper()\n     19         except ImportError:\n---> 20             import _pywrap_tensorflow\n     21             return _pywrap_tensorflow\nModuleNotFoundError: No module named '_pywrap_tensorflow'\nDuring handling of the above exception, another exception occurred:\nImportError                               Traceback (most recent call last)\n in \n----> 1 import tensorflow as tf\n~\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\tensorflow__init__.py in \n     22 \n     23 # pylint: disable=wildcard-import\n---> 24 from tensorflow.python import *\n     25 # pylint: enable=wildcard-import\n     26 \n~\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\tensorflow\\python__init__.py in \n     58 please exit the tensorflow source tree, and relaunch your python interpreter\n     59 from there.\"\"\" % traceback.format_exc()\n---> 60   raise ImportError(msg)\n     61 \n     62 # Protocol buffers\nImportError: Traceback (most recent call last):\n  File \"C:\\Users\\ritesh.kankonkar\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow.py\", line 18, in swig_import_helper\n    fp, pathname, description = imp.find_module('_pywrap_tensorflow', [dirname(file)])\n  File \"C:\\Users\\ritesh.kankonkar\\AppData\\Local\\Continuum\\anaconda3\\lib\\imp.py\", line 296, in find_module\n    raise ImportError(_ERR_MSG.format(name), name=name)\nImportError: No module named '_pywrap_tensorflow'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):\n  File \"C:\\Users\\ritesh.kankonkar\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\tensorflow\\python__init__.py\", line 54, in \n    from tensorflow.python import pywrap_tensorflow\n  File \"C:\\Users\\ritesh.kankonkar\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow.py\", line 28, in \n    _pywrap_tensorflow = swig_import_helper()\n  File \"C:\\Users\\ritesh.kankonkar\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow.py\", line 20, in swig_import_helper\n    import _pywrap_tensorflow\nModuleNotFoundError: No module named '_pywrap_tensorflow'\nError importing tensorflow.  Unless you are using bazel,\nyou should not try to import tensorflow from its source directory;\nplease exit the tensorflow source tree, and relaunch your python interpreter\nfrom there.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1593,"Q_Id":53227954,"Users Score":0,"Answer":"Well, I am answering my own question since the error seems to have multiple causes.\nI am not sure what was the cause, however, after downgrading python to 3.5 and installing tensorflow with pip (pip install tensorflow), resolved the issue.\nNote: I uninstalled everything before installing Anaconda again.","Q_Score":0,"Tags":"python,tensorflow","A_Id":53377498,"CreationDate":"2018-11-09T14:45:00.000","Title":"Unable to import tensorflow, error for importing pywrap_tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python application that simulates the behaviour of a system, let's say a car.\nThe application defines a quite large set of variables, some corresponding to real world parameters (the remaining fuel volume, the car speed, etc.) and others related to the simulator internal mechanics which are of no interest to the user.\nEverything works fine, but currently the user can have no interaction with the simulation whatsoever during its execution: she just sets simulation parameters, lauchs the simulation, and waits for its termination.\nI'd like the user (i.e. not the creator of the application) to be able to write Python scripts, outside of the app, that could read\/write the variables associated with the real world parameters (and only these variables).\nFor instance, at t=23s (this condition I know how to check for), I'd like to execute user script gasLeak.py, that reads the remaining fuel value and sets it to half its current value.\nTo sum up, how is it possible, from a Python main app, to execute user-written Python scripts that can access and modifiy only a pre-defined subset of the main script variables. In a perfect world, I'd also like that modifications applied to user scripts during the running of the app to be taken into account without having to restart said app (something along the reloading of a module).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":53229900,"Users Score":0,"Answer":"Make the user-written scripts read command-line arguments and print to stdout. Then you can call them with the subprocess module with the variables they need to know about as arguments and read their responses with subprocess.check_output.","Q_Score":0,"Tags":"python,namespaces,interpreter","A_Id":53229974,"CreationDate":"2018-11-09T16:42:00.000","Title":"Run external Python script that could only read\/write only a subset of main app variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am planning to run scripts to copy S3 files from one bucket to other bucket in same region( same account and different account - both cases are there). I am using Python scripts and running on EC2 instance. \n1) Will the performance depend on EC2 server type?\n2) What is the best way to improve performance when copying S3 files from one account to another ( and also one bucket to another in same account, same region) . Given they are in same region and different regions. File sizes are around 1 GB each with total size of 5TB\nThanks\ntom\nLet me know if you need any other information.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":290,"Q_Id":53231038,"Users Score":2,"Answer":"No, in this instance the type of EC2 will not matter because you are using the AWS network to transfer data from 1 bucket to another. If you wanted to spin off parallel processing of the data (Run multiple s3 cp at the same time) then you would choose a specific instance, but in your case a T2 Small would do just fine.","Q_Score":0,"Tags":"python-3.x,amazon-s3,amazon-ec2","A_Id":53232124,"CreationDate":"2018-11-09T17:57:00.000","Title":"aws s3 to s3 copy using python script on 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":"I'd like to fetch mails from a server, but I also want to control when to delete them.\nIs there a way to do this?\nI know this setting is very usual in mail clients, but it seems this option is not well supported by POPv3 specification and\/or server implementations.\n(I'm using python, but I'm ok with other languages\/libraries, Python's poplib seems very simplistic)","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":964,"Q_Id":53231525,"Users Score":2,"Answer":"POP3 by design downloads and removes mail from a server after it's successfully fetched.  If you don't want that, then use the IMAP protocol instead.  That protocol has support to allow you to delete mail at your leisure as opposed to when it's synced to your machine.","Q_Score":2,"Tags":"python,pop3,poplib","A_Id":53231559,"CreationDate":"2018-11-09T18:34:00.000","Title":"Fetch mails via POP3, but keep them on the 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":"Is there any way to get all games that user has played while using Discord?\nSo based on that I can give them specific roles.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1082,"Q_Id":53233805,"Users Score":1,"Answer":"You'd have to store them, there is no history of games played available in the API","Q_Score":1,"Tags":"python,discord.py-rewrite","A_Id":53254574,"CreationDate":"2018-11-09T22:01:00.000","Title":"How to get all games that user has played while using Discord with 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 using pytest-xdist plugin to run some test using the @pytest.mark.parametrize to run the same test with different parameters.\nAs part of these tests, I need to open\/close web servers and the ports are generated at collection time.\nxdist does the test collection on the slave and they are not synchronised, so how can I guarantee uniqueness for the port generation.\nI can use the same port for each slave but I don't know how to archive this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":304,"Q_Id":53234370,"Users Score":0,"Answer":"I figured that I did not give enough information regarding my issue.\nWhat I did was to create one parameterized test using @pytest.mark.parametrize and before the test, I collect the list of parameters, the collection query a web server and receive a list of \"jobs\" to process.\nEach test contains information on a port that he needs to bind to, do some work and exit because the tests are running in parallel I need to make sure that the ports will be different.\nEventually, I make sure that the job ids will be in the rand on 1024-65000 and used that for the port.","Q_Score":0,"Tags":"python,pytest,xdist,pytest-xdist","A_Id":53282799,"CreationDate":"2018-11-09T23:03:00.000","Title":"pytest-xdist generate random & uniqe ports for each 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":"I have a very simple task: I need to take a sum of 1 column in a file that has many columns and thousand of rows. However, every time I open the file on jupyter, it crashes since I cannot go over 100 MB per file. \nIs there any work around for such a task? I feel I shouldnt have to open the entire file since I need just 1 column.\nThanks!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":7918,"Q_Id":53236893,"Users Score":1,"Answer":"You should slice through rows and put it in different other data frames and then works on respective data frames.\nHanging issues are because of RAM insufficiency in your system.\nUse new_dataframe = dataframe.iloc[: , :]- or new_dataframe = dataframe.loc[: , :]-methods for slicing in pandas. \nRows slicing before colon and column slicing after colon.","Q_Score":1,"Tags":"python,jupyter-notebook","A_Id":58774246,"CreationDate":"2018-11-10T07:27:00.000","Title":"Large File crashing on Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently building a python application which uses sockets to communicate with other computers. I am almost finished with the backend (the frontend still looks atrocious), and I began thinking about expanding. Currently, my app is only intended to support Windows PC; however, I would like to expand to ios which would necessitate the use of Swift. I am writing this question to ask if python sockets can be shared across different types of devices (i.e. PC and iPhone) and different programming languages (i.e. Python and Swift). I am pretty sure that they can be shared across different types of devices, but I am unsure as to whether or not they can be shared with other programming languages. Thank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":53243061,"Users Score":0,"Answer":"A socket in Python provides the same abstraction as a socket in C, C++, Perl, ruby, Java ... . This means application written in various languages can all communicate using sockets with each other. What is different are WebSockets in Javascript in the browser though - these need another WebSockets implementation as the peer but these can also be found for various programming languages.","Q_Score":0,"Tags":"python,swift,sockets,cross-platform","A_Id":53243418,"CreationDate":"2018-11-10T20:19:00.000","Title":"Cross Platforming and Cross Languaging Sockets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am given the following requirements which need to be formulated into a CSP problem by defining a set of variables, and a set of constraints over those variables. However I'm having trouble formulating the constraints and variables for my problem. \nSome info:\nThe solution to the problem is a list of assignments: [Var, A1, A2, A3]\nwhere Var is the variable and A1, A2, A3 is an ordered sequence of valid assignments.\nRequirements:\n\nEach variable is assigned a value in problem.valid_assignments()\nEach variable's first assignment is in problem.first_assignments()\nEach variable's assignment sequence is in problem.valid_pairs() (Some assignments can't follow others)\nGiven an integer K, there can be no more than K continuous assignments where at least one is not in problem.k_assignment()\nEvery value in the given assignments list: problem.assignment must be used.\n\nAvailable Constraints:\n\nNValues constraint: Given a list of required_values, an upper bound and lower bound, makes sure that the number of variables whose value is in required_values is between the bounds.\nAllDifferent constraint: Given a set of variables, enforces their inequality. That is no two variables in the set are equal.\nNotEqual constraints: Given Var1, Var2, enforces: Var1 != Var2\n\nSo Far:\n\nA Variable for each Var whose domain is problem.valid_assignments()\nA Variable for each Var whose domain is problem.first_assignments()\nA NValues constraint for each Var whose scope is [Var], required values problem.valid_assignments(Var), lower bound 0, upper bound len(domain).\n\nAdditional info:\n\nThe solution is a \"list of assignments\" as in for each Var we return [Var, A1, A2, A3] where Var is the variable assigned and A1 through A3 are valid assignments that fulfil the given constraints. The exact format doesn't matter as I'm only looking for a conceptual solution. Additionally A1, A2, A3 (aka all assignments for a Var) must obviously be in the domain of that variable. (Domains can overlap between variables).\nvalid_pairs() returns a list of tuples [(A1, A2), (A2,A3)]. The constraint is such that the returned solution list (as detailed above) must have consecutive assignments that form valid pairs that are given by this function. For example if the solution is [Var, A1, A2, A4, A3] and the valid pairs are [(A1, A2), (A2,A3)] then the solution is incorrect as (A2, A4) (A4, A3) is not in the list ((A1, A2) however is a valid pair).\nEssentially we're looking for arc-consistency.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":495,"Q_Id":53244153,"Users Score":1,"Answer":"We can use an NValues constraint whose scope is all variables, and domain is each possible assignment (For each assignment create a constraint). This ensures that all values are assigned when set to have an upper and lower bound of 1.\nWe can use use Neq constraint with a bit of modification to ensure the correct sequencing by feeding it tuples of valid assignments.\nWe can again use NValues constraint to ensure the k_assignment requirement by passing a lower bound of 1, and upper bound of K with domain K_assignments.\nIn the same way we can use NValues constraint with domain problem.first_assignments() for the first assignment. And another with domain problem.valid_assignments() to fill in the blanks.","Q_Score":2,"Tags":"python,search,constraints,backtracking,constraint-programming","A_Id":53344123,"CreationDate":"2018-11-10T22:43:00.000","Title":"Constraint Satisfaction Problem formulation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I think i am looking for something simpler than detecting a document boundaries in a photo. I am only trying to flag photos which are mostly of documents rather than just a normal scene photo. is this an easier problem to solve?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":53244536,"Users Score":0,"Answer":"Are the documents mostly white? If so, you could analyse the images for white content above a certain percentage. Generally text documents only have about 10% printed content on them in total.","Q_Score":0,"Tags":"python,image,opencv,image-processing","A_Id":53244565,"CreationDate":"2018-11-10T23:45:00.000","Title":"how to detect if photo is mostly a document?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Visual Studio 2015 and 2017, I always get an error when trying to create a virtual environment with certain base interpreters.   \nBase interpreters that work:\n\nPython 3.6 32-bit\nPython 2.7, 64-bit\nAnaconda 5.0.1 (2.7, 64-bit)\n\nBase interpreters that give error:\n\nAnaconda 5.0.1 (3.6, 64-bit)\nPython 3.6 64-bit\n\nThe error:\n\nError: Command '['F:\\OneDrive\\Visual Studio 2017 Projects\\Web Test\\DjangoWebProject1\\DjangoWebProject1\\env4\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.\n  Virtual environment was not created at 'F:\\OneDrive\\Visual Studio 2017 Projects\\Web Test\\DjangoWebProject1\\DjangoWebProject1\\env4'. Exit code: 1\n  Virtual environment was not created at 'F:\\OneDrive\\Visual Studio 2017 Projects\\Web Test\\DjangoWebProject1\\DjangoWebProject1\\env4'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1119,"Q_Id":53245974,"Users Score":0,"Answer":"Turns out this was a known issue with previous versions of Anaconda.  The Python 3.6 64-bit interpreter that was listed as giving an error was actually an Anaconda version of Python as well.  \nSimply using the package manager to upgrade to the most recent versions of Anaconda fixed the issues.","Q_Score":0,"Tags":"python,visual-studio,virtual-environment","A_Id":53559921,"CreationDate":"2018-11-11T04:57:00.000","Title":"Creating python virtual environment in Visual Studio fails: returned non-zero exit status 1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use wxpython (phoenix) as frontend and wx.lib.pubsub to manage the inter-module (and inter-package) messaging in my program. I currently use the module dill to save and load the program state.\nI only use the sendMessage and the subscribe methods, no fancy tricking here.\nIf I stay in the same session, that is, I build the model and modify it without saving and reloading the model, all works fine.\nHowever, when restarting the GUI and starting a session from a saved file, part of the messaging that worked previously OK, fails: the messages are sent, but the receiver does not get them. \nWhen directly calling the methods that should have been called on the receiver side, all works great, regardless of the session.\nDue to the complexity of the problem I can't really provide an example, but would appreciate any effort for clarification or shared similar experiences.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13,"Q_Id":53246911,"Users Score":0,"Answer":"To kind of answer my own question: after trying to reproduce the issue in toy problems unsuccesfully followed by lenghty debugging the source of the problem was found to be the way certain properties were set, namely using property.setters. These have been replaced by set_ methods and the issue was resolved.\nI know this question and also the answer are well below the expected SO standard, feel free to downvote.","Q_Score":0,"Tags":"python-3.x,dill,wxpython","A_Id":53283137,"CreationDate":"2018-11-11T08:10:00.000","Title":"wxpython pubsub fails after loading from dill","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I want to find dates in the formats 18-05-2018 and 18-05-18, but not 2018-05-18. I want to use regular expressions such that I get True when such a date appears in a string.\nSo it should return True for these strings:\n\nggggg18-05-2018ggggg\nggggg18-05-2018ggggg12345678\nggggg18-05-18ggggg\nggggg18-05-18ggggg12345678\n\nBut it should return False for these strings:\n\nggggg2018-05-18ggggg\nggggg2018-05-18ggggg12345678\n\nHow to do it? I've found findall() method and pattern '\\d{1,2}[-]\\d{1,2}[-]\\d{2,4}' but it returned True for the last two strings, as it found 18-05-18 in them.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1167,"Q_Id":53247866,"Users Score":0,"Answer":"I'd suggest using a negative lookbehind (?<!...), which you can insert at any point in a regular expression to ensure that whatever comes right before that point does not match a certain expression (the ...). In your case, you want to ensure that what comes right before the beginning of the expression doesn't match a digit (\\d), so you would insert (?<!\\d) at the beginning of your regex.\nIf you would also like to exclude matches with the wrong number of digits at the end, as in aaaa18-05-181bbb, then you could also use a negative lookahead (?!...), which is similar to the negative lookbehind except that it ensures whatever comes after a certain point does not match an expression. In your case, to ensure that a digit does not come after the end of the match, you'd add (?!\\d) at the end of your expression.","Q_Score":2,"Tags":"python,regex","A_Id":53247926,"CreationDate":"2018-11-11T10:33:00.000","Title":"Python regex - any substring matches","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m currently working on a Raspberry Pi\/Django project slightly more complex that i\u2019m used to. (i either do local raspberry pi projects, or simple Django websites; never the two combined!)\nThe idea is two have two Raspberry Pi\u2019s collecting information running a local Python script, that would each take input from one HDMI feed (i\u2019ve got all that part figured out - I THINK) using image processing. Now i want these two Raspberry Pi\u2019s (that don\u2019t talk to each other) to connect to a backend server that would combine, store (and process) the information gathered by my two Pis\nI\u2019m expecting each Pi to be working on one frame per second, comparing it to the frame a second earlier (only a few different things he is looking out for) isolate any new event, and send it to the server. I\u2019m therefore expecting no more than a dozen binary timestamped data points per second.\nNow what is the smart way to do it here ? \n\nDo i make contact to the backend every second? Every 10 seconds?\nHow do i make these bulk HttpRequests ? Through a POST request? Through a simple text file that i send for the Django backend to process? (i have found some info about \u201cbulk updates\u201d for django but i\u2019m not sure that covers it entirely)\nHow do i make it robust? How do i make sure that all data what successfully transmitted before deleting the log locally ? (if one call fails for a reason, or gets delayed, how do i make sure that the next one compensates for lost info?\n\nBasically, i\u2019m asking advise for making a IOT based project, where a sensor gathers bulk information and want to send it to a backend server for processing, and how should that archiving process be designed.\nPS: i expect the image processing part (at one fps) to be fast enough on my Pi Zero (as it is VERY simple); backlog at that level shouldn\u2019t be an issue.\nPPS: i\u2019m using a django backend (even if it seems a little overkill) \n    a\/ because i already know the framework pretty well\n    b\/ because i\u2019m expecting to build real-time performance indicators from the combined data points gathered, using django, and displaying them in (almost) real-time on a webpage.\nThank you very much !","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1234,"Q_Id":53249599,"Users Score":2,"Answer":"This partly depends on just how resilient you need it to be. If you really can't afford for a single update to be lost, I would consider using a message queue such as RabbitMQ - the clients would add things directly to the queue and the server would pop them off in turn, with no need to involve HTTP requests at all.\nOtherwise it would be much simpler to just POST each frame's data in some serialized format (ie JSON) and Django would simply deserialize and iterate through the list, saving each entry to the db. This should be fast enough for the rate you describe - I'd expect saving a dozen db entries to take significantly less than half a second - but this still leaves the problem of what to do if things get hung up for some reason. Setting a super-short timeout on the server will help, as would keeping the data to be posted until you have confirmation that it has been saved - and creating unique IDs in the client to ensure that the request is idempotent.","Q_Score":1,"Tags":"python,django,raspberry-pi,iot,bulk-load","A_Id":53249964,"CreationDate":"2018-11-11T14:15:00.000","Title":"Sending data to Django backend from RaspberryPi Sensor (frequency, bulk-update, robustness)","Data Science and Machine Learning":0,"Database and SQL":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'v been struggling a bit with getting certain (say ligand or cofactors) to pop out of the molecules, in the way as you would choose layers in photoshop. How can I select certain objects or amino acids to be infront of all other layers. e.g. I have a surface representation of a molecules with a cofactor inside, but then I just want the cofactor to pop-out and overlay on top of the surface. \nIm a basic (beginner) user of pymol, meaning that im just starting to use commands but i'm not scripting anything for pyMOL yet. \nWhat sort of commands could I use for this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":161,"Q_Id":53249727,"Users Score":0,"Answer":"If want to have an overlay on top of a surface, the only way I see you doing this, is to render (ray) the image twice, once with the surface representation of your protein shown, and once the cofactor alone. Then overlay both pngs (rendered with transparent background, of course) in an image editor of your choice.\nIf you need both representations inside PyMOL's 3D view, increase the transparency for your surface, and then make sure that only the cofactor is visible as, e.g., licorice representation.","Q_Score":0,"Tags":"python,pymol","A_Id":53258497,"CreationDate":"2018-11-11T14:33:00.000","Title":"Layers in pyMOL or making certain amino acids \"pop out\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi I am using win 7 64 bit and tensorflow version 1.5 I've tried 1.9 and higher but isnt work and I've tried tensorflow-gpu version but again isnt work all the error this","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":764,"Q_Id":53250360,"Users Score":1,"Answer":"I encountered same issue using tf 1.8. Tensorflow versions < 1.9 did not support the score_threshold param.\nNeed to be sure you're using version 1.9 or newer.","Q_Score":0,"Tags":"python,python-3.x,tensorflow","A_Id":54779304,"CreationDate":"2018-11-11T15:43:00.000","Title":"TypeError: non_max_suppression() got an unexpected keyword argument 'score_threshold'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Could not find a version that satisfies the requirement pcap (from versions: )\nNo matching distribution found for pcap","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":391,"Q_Id":53251242,"Users Score":0,"Answer":"The Python package name is libpcap, not pcap.","Q_Score":0,"Tags":"python,libpcap","A_Id":53251267,"CreationDate":"2018-11-11T17:19:00.000","Title":"pcap pakage to python project error is pcap.h 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script I want to run in Azure Resource Manager context within an Azure DevOps pipeline task to be able to access Azure resources (like the Azure CLI or Azure PowerShell tasks).\nHow can I get Azure RM Service Endpoint credentials stored in Azure DevOps passed - as ServicePrincipal\/Secret or OAuth Token - into the script?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3349,"Q_Id":53251660,"Users Score":0,"Answer":"Depends on what you call a python script, but either way Azure DevOps hasn't got native support to authenticate python sdk (or your custom python script), but you can pass in credentials from build\\release variables to your script, or try and pull that from the Azure Cli (I think it stores data somewhere under \/home\/.azure\/.","Q_Score":0,"Tags":"python,azure-devops,azure-resource-manager","A_Id":53251791,"CreationDate":"2018-11-11T18:06:00.000","Title":"How can I run a Python script in Azure DevOps with Azure Resource Manager credentials?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm gonna use data from a .csv to train a model to predict user activity on google ads (impressions, clicks) in relation to the weather for a given day. And I have a .csv that contains 6000+ recordings of this info and want to parse it into a database using Python. \nI tried making a df in pandas but for some reason the whole table isn't shown. The middle columns (there's about 7 columns I think) and rows (numbered over 6000 as I mentioned) are replaced with '...' when I print the table so I'm not sure if the entirety of the information is being stored and if this will be usable.\nMy next attempt will possible be SQLite but since it's local memory, will this interfere with someone else making requests to my API endpoint if I don't have the db actively open at all times? \nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":270,"Q_Id":53253610,"Users Score":1,"Answer":"If you used pd.read_csv() i can assure you all of the info is there, it's just not displaying it.\nYou can check by doing something like print(df['Column_name_you_are_interested_in'].tolist()) just to make sure though. You can also use the various count type methods in pandas to make sure all of your lines are there.\nPanadas is pretty versatile so it shouldn't have trouble with 6000 lines","Q_Score":1,"Tags":"python,sql,database,pandas,sqlite","A_Id":53253685,"CreationDate":"2018-11-11T21:51:00.000","Title":"Parsing a CSV into a database for an API using Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a method to connect client(web browser) to server(without external IP) using p2p.\nAs client-side language i would like to use javascript.\nI was reading about WebRTC Peer-to-peer but i don't know if it only works with two clients(javascript) or if i can use some other language ( PHP, Python, Node.js ).\nI know about signaling, STUN and TURN servers. I have server with external IP address so it won't be a problem.\nMy question is what programming language can i use on the server?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1119,"Q_Id":53253718,"Users Score":1,"Answer":"I added to Andrey Suglobov's answer: The client does not receive the WebRTC packets from the server because it doesn't have an external IP. In order to solve this problem, you have to configure it to communicate via the TURN server in the middle.\n[WebRTC server] \u2194 [TURN] \u2194 [NAT] \u2194 [client]\nGenerally, the client uses JavaScript because it's a browser. But WebRTC is a specification that supports P2P on the web. If supporting this specification, it does not matter what programming language you use.\nThank you.","Q_Score":3,"Tags":"javascript,python,node.js,p2p,peer","A_Id":53273494,"CreationDate":"2018-11-11T22:05:00.000","Title":"Peer-to-peer Javascript & something","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a method to connect client(web browser) to server(without external IP) using p2p.\nAs client-side language i would like to use javascript.\nI was reading about WebRTC Peer-to-peer but i don't know if it only works with two clients(javascript) or if i can use some other language ( PHP, Python, Node.js ).\nI know about signaling, STUN and TURN servers. I have server with external IP address so it won't be a problem.\nMy question is what programming language can i use on the server?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1119,"Q_Id":53253718,"Users Score":0,"Answer":"Probably found an answer.\nI can use javascript server side in node.js","Q_Score":3,"Tags":"javascript,python,node.js,p2p,peer","A_Id":53262995,"CreationDate":"2018-11-11T22:05:00.000","Title":"Peer-to-peer Javascript & something","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have used subprocess to obtain the output from command line, but it requires the process to end before you can use the data. Is there a way to get data line by line as it outputs? I need to have a process running indefinitely while python gets each new line as it is printed out.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":53255747,"Users Score":0,"Answer":"If you know the Process ID or PID, You can do subprocess.call('tail -f \/proc\/<pid>\/fd\/1')","Q_Score":0,"Tags":"python,command-line,output","A_Id":53255981,"CreationDate":"2018-11-12T03:53:00.000","Title":"Reading command line output from ongoing processes in terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I build a .exe program from my Anaconda environment to get a standalone application?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4459,"Q_Id":53256735,"Users Score":2,"Answer":"Create an environment with all packages needed for your program and run python your_script.py or pyinstaller --onefile <your_script_name>.py if you want a one-file .exe only.","Q_Score":2,"Tags":"python,windows,anaconda,exe,pyinstaller","A_Id":53256768,"CreationDate":"2018-11-12T06:12:00.000","Title":"How to build a .exe program from the Anaconda environment (Python 3.7)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing a telegram bot with python.\nI ask users to input their phone numbers. The problem is, if they enter Persian numbers (like \u06f0\u06f6\u06f0\u06f7\u06f5\u06f0), their data doesn't set in my database, and after updating database its field is empty!\nBut if they enter English digits, it saves in database?!\n\npython 3.7 \ndatabase: MySQL\nOS: win 10","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":237,"Q_Id":53257063,"Users Score":4,"Answer":"Convert to the string and save it later in the database\nUse the number to convert the number to the number\ndatabase----> '\u06f0\u06f6\u06f0\u06f7\u06f5\u06f0'\nusing ---> get database-----> int('\u06f0\u06f6\u06f0\u06f7\u06f5\u06f0')","Q_Score":1,"Tags":"python,mysql,python-3.x","A_Id":53257581,"CreationDate":"2018-11-12T06:43:00.000","Title":"how can I save persian numbers in database (mysql)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know i can access a Dynamics instance from a python script by using the oData API, but what about the other way around? Is it possible to somehow call a python script from within Dynamics and possible even pass arguments?\nWould this require me to use custom js\/c#\/other code within Dynamics?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":337,"Q_Id":53258692,"Users Score":1,"Answer":"You won't be able to nativley execute a python script within Dynamics. \nI would approach this by placing the Python script in a service that can be called via a web service call from Dynamics. You could make the call from form JavaScript or a Plugin using C#.","Q_Score":0,"Tags":"python,dynamics-crm","A_Id":53266129,"CreationDate":"2018-11-12T08:56:00.000","Title":"run python from Microsoft Dynamics","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been building some variations of CNN's off of Keras\/Tensorflow examples that use the MNIST data images (ubyte files) for feature extraction. My eventual goal is to do a similar thing but with a collection (~10000) 2D FFT arrays of signal data that I have made (n x m ~ 1000 x 50)(32 bite float data)\nI have been looking for an example that uses something other than image files but can not seem to find any.\nMy questions are: Is this possible to do without converting them to images. Can the dataset be exported to a pickle or some other file that I could input? Whats the best way to achieve this?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":440,"Q_Id":53266491,"Users Score":1,"Answer":"Yes, you can use CNN for data other than images like sequential\/time-series data(1D convolution but you can use 2D convolution as well).\nCNN does its job pretty good for these types of data.\nYou should provide your input as an image matrix i.e a window on which CNN can perform convolution on.\nAnd you can store those input matrices\/window in a numpy array and then load those file and train your CNN on it.","Q_Score":1,"Tags":"python,tensorflow,keras,conv-neural-network,mnist","A_Id":53294036,"CreationDate":"2018-11-12T16:39:00.000","Title":"Input numerical arrays instead of images into Keras\/TF CNN","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have used Python (version 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32) and pyinstaller (version 3.3.1) to build a standalone executable for only windows OS usage. This executable runs perfectly every time it is called. \nI want this application to be available and usable for future changes and releases of windows. Is it possible\/likely that in future releases that this executable will stop functioning? If so, what exactly would be the cause?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":53266537,"Users Score":0,"Answer":"There's never going to be any firm guarantee that software built for an older operating system continues to work on any conceivable future operating system.  That's analogous to asking \"Can you guarantee that every car everywhere will always support my carburetor?\"  \nThat's demonstrably false, but also patently absurd to ponder.  No one can tell you what will or won't change in future operating systems, or what might introduce a binary incompatibility for a script compiled in the past.","Q_Score":0,"Tags":"python,windows,executable,pyinstaller","A_Id":53267486,"CreationDate":"2018-11-12T16:42:00.000","Title":"Hypothetical scenario: Python standalone executable for future machine compatibility","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Using datetime.strptime(11\/12\/18 02:20 PM, '%m\/%d\/%y %I:%M %p') I enter the date and time into sql server using a stored procedure and I get no errors, all seems fine.  But the actual value in the database when checked is 2018-11-12 00:00:00.000.  This is the value coming out of strptime 2018-11-12 14:20:00.  Why am I not getting the time value? I have checked both the table design and Stored Procedure to make sure that datetime is being used throughout.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":53267376,"Users Score":0,"Answer":"Ok, Figured it out, since I was doing this in 'Ignition' and using a python library, I went into the library file. It was using  'system.db.createSPProcCall' and 'registerInParam' where you must include a value and a type.  Since 'system.db.type' does not have a datetime, they had used DATE, wrong!  I changed it to use TimeStamp.  It worked fine after that. A shout out to @Jeffrey Van Laethem for setting me on the right path.","Q_Score":0,"Tags":"python,sql-server,datetime","A_Id":53284251,"CreationDate":"2018-11-12T17:39:00.000","Title":"Python date not showing Time in sql server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get python 3 working on my OSX laptop.\nI need to install requests for python 3, and it isn't working.\nI think I've managed to get pip installed for both python 2.7 & python 3 however...\nWhenever I use 'pip' it points to python2... I can't seem to access the pip for python 3?","AnswerCount":4,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":6419,"Q_Id":53268470,"Users Score":-2,"Answer":"try to sudo apt-get update first then sudo apt-get install python3-pip --fix-missing","Q_Score":5,"Tags":"python,python-3.x,pip,pipenv","A_Id":53273928,"CreationDate":"2018-11-12T18:59:00.000","Title":"How to use pip with python 2 & 3 installed? (OSX)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get python 3 working on my OSX laptop.\nI need to install requests for python 3, and it isn't working.\nI think I've managed to get pip installed for both python 2.7 & python 3 however...\nWhenever I use 'pip' it points to python2... I can't seem to access the pip for python 3?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":6419,"Q_Id":53268470,"Users Score":1,"Answer":"Run this command to find the python that is used before running pip: which python. You can do the same idea to find which pip version is being run: which pip\nYou\u2019ll need to create separate virtual environments in order to use different python versions and\/or python dependencies. Use something like conda or venv to do this. Then, ensure that the desired python version virtual environment is activated prior to installing a new package with pip.","Q_Score":5,"Tags":"python,python-3.x,pip,pipenv","A_Id":53268524,"CreationDate":"2018-11-12T18:59:00.000","Title":"How to use pip with python 2 & 3 installed? (OSX)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm pretty much stuck right now.\nI wrote a parser in python3 using the python-docx library to extract all tables found in an existing .docx and store it in a python datastructure.\nSo far so good. Works as it should.\nNow I have the problem that there are hyperlinks in these tables which I definitely need! Due to the structure (xml underneath) the docx library doesn't catch these. Neither the url nor the display text provided. I found many people having similar concerns about this, but most didn't seem to have 'just that' dilemma.\nI thought about unpacking the .docx and scan the _ref document for the corresponding 'rid' and fill the actual data I have with the links found in the _ref xml.\nEither way it seems seriously weary to do it that way, so I was wondering if there is a more pythonic way to do it or if somebody got good advise how to tackle this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":438,"Q_Id":53269311,"Users Score":0,"Answer":"You can extract the links by parsing xml of docx file. \nYou can extract all text from the document by using document.element.getiterator()\nIterate all the tags of xml and extract its text. You will get all the missing data which python-docx failed to extract.","Q_Score":0,"Tags":"python,xml,hyperlink,docx","A_Id":57556934,"CreationDate":"2018-11-12T20:04:00.000","Title":"Extracting URL from inside docx tables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to install graph tool on ubuntu. \nTherefore I want to make the default version of python to 3.7 instead of 2.7 because my compiler give me the error, that the python interpreter is to old to run the configure. \nSo do u know an solution?\nThanks a lot","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4238,"Q_Id":53270725,"Users Score":0,"Answer":"python3 file.py\nOr add #!\/usr\/bin\/python3 to the first line of your code to automatically run it with python 3.","Q_Score":0,"Tags":"python,linux,python-3.x,ubuntu-16.04","A_Id":53280335,"CreationDate":"2018-11-12T21:59:00.000","Title":"Python2.7 to Python3 Ubuntu switch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to install graph tool on ubuntu. \nTherefore I want to make the default version of python to 3.7 instead of 2.7 because my compiler give me the error, that the python interpreter is to old to run the configure. \nSo do u know an solution?\nThanks a lot","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4238,"Q_Id":53270725,"Users Score":0,"Answer":"I'll recommend not using aliases nor changing defaults. Those things have a way of coming back to bite you later on. \nBy your description, you said that the tool said the interpreter was too old. I'll guess that it needs a python3 interpreter. So what you should do is a simple sudo apt install python3 and use python3 instead of python when running the code from the terminal.\nExample:\nInstead of python manage.py runserver\nDo... python3 manage.py runserver","Q_Score":0,"Tags":"python,linux,python-3.x,ubuntu-16.04","A_Id":57073945,"CreationDate":"2018-11-12T21:59:00.000","Title":"Python2.7 to Python3 Ubuntu switch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Using openpyxl, I'm able to read 2 numbers on a sheet, and also able to read their sum by loading the sheet with data_only=True. \nHowever, when I alter the 2 numbers using openpyxl and then try to read the answer using data_only=True, it returns no output. How do I do this?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1946,"Q_Id":53271690,"Users Score":1,"Answer":"You can have either the value or the formula in openpyxl. It is precisely to avoid the confusion that this kind of edit could introduce that the library works like this. To evaluate the changed formulae you'll need to load the file in an app like MS Excel or LibreOffice that can evaluate the formulae and store the results.","Q_Score":2,"Tags":"python,excel,openpyxl","A_Id":53276640,"CreationDate":"2018-11-12T23:39:00.000","Title":"openpyxl how to read formula result after editing input data on the sheet? data_only=True gives me a \"None\" result","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using a bit of code that is derived from inception v3 as distributed by the Google folks, but it's now complaining that the queue runners used to read the data are deprecated (tf.train.string_input_producer in image_processing.py, and similar).  Apparently I'm supposed to switch to tf.data for this kind of stuff.\nUnfortunately, the documentation on tf.data isn't doing much to relieve my concern that I've got too much data to fit in memory, especially given that I want to batch it in a reusable way, etc. I'm confident that the tf.data stuff can do this; I just don't know how to do it. Can anyone point me to a full example of code that uses tf.data to deal with batches of data that won't all fit in memory?  Ideally, it would simply be an updated version of the inception-v3 code, but I'd be happy to try and work with anything.  Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":58,"Q_Id":53272508,"Users Score":1,"Answer":"Well, I eventually got this working.  The various documents referenced in the comment on my question had what I needed, and I gradually figured out which parameters passed to queuerunners corresponded to which parameters in the tf.data stuff.\nThere was one gotcha that took a while for me to sort out.  In the inception implementation, the number of examples used for validation is rounded up to be a multiple of the batch size; presumably the validation set is reshuffled and some examples are used more than once.  (This does not strike me as great practice, but generally the number of validation instances is way larger than the batch size, so only a relative few are double counted.)\nIn the tf.data stuff, enabling shuffling and reuse is a separate thing and I didn't do it on the validation data.  Then things broke because there weren't enough unique validation instances, and I had to track that down.\nI hope this helps the next person with this issue.  Unfortunately, my code has drifted quite far from Inception v3 and I doubt that it would be helpful for me to post my modification.  Thanks!","Q_Score":1,"Tags":"python,tensorflow","A_Id":53452436,"CreationDate":"2018-11-13T01:35:00.000","Title":"inception v3 using tf.data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The GPU cluster I'm working off of includes both python 2.7 and python 3.5. pip and easy_install are both provided to allow local modules to be installed to a .local directory. For whatever reason, pip3 is not installed. \nHow can I install python 3 modules without root access given that pip3 is unavailable?\nThanks","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":436,"Q_Id":53273807,"Users Score":-1,"Answer":"Pycharm community is a free IDE. You can install pycharm first. And then, use pycharm to install other modules.","Q_Score":1,"Tags":"python-3.x","A_Id":53274629,"CreationDate":"2018-11-13T04:27:00.000","Title":"Slurm: Installing python 3 modules when pip3 not available","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want a help in robotics stuff..\nMy Question is ... : \nHow to connect my robotic car ( car is  having raspberry pi as controller) with my computer via internet .. so the I can control the car from my computer's keybord.. \nPreviously i was using VNC and made a python tkinter  script (stored at raspberry pi) and by the help of vnc i control the car but it was not good .. \nMost of the time the when i press the key,  function works after sometime and worst thing was that it stores all the commands in a queue or buffer .. \nSo realtime operation was not happenping ( like: if i press forward arrow key for 2 seconds, it evoked moveForward() 20 times which is equal to 2 meters forward move and takes 4 seconds to travel .. BUT after that if i press right arrow key then it evokes moveRight() .. the worst part is it will execute after finishing the moveForward() stored in a queue i.e after 4 seconds .. and not on real time)\nIs there any way to control\/give command to raspberry pi on real time and not in a queue manner via socketing or other thing ?\nnote : i have a static ip address with specific port open and it has to be done over internet.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":53275066,"Users Score":0,"Answer":"The appearance of your car might mainly relate to the whole system response time. The Raspberry Pi may be not fast enough. If there is no necessary, analog signal may on real time.","Q_Score":0,"Tags":"python,sockets,raspberry-pi,real-time,remote-connection","A_Id":53275756,"CreationDate":"2018-11-13T06:30:00.000","Title":"Remote connection between Raspberry pi and other computer through python over internet on 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":"Im trying to get flask with virtual environment and wsgi configured to work but Apache keeps giving me this error: \n\n[Tue Nov 13 13:23:55.179153 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]     app.session_interface = self._get_interface(app)\n[Tue Nov 13 13:23:55.179160 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]   File \"\/var\/www\/html\/project\/python\/lib\/python3.6\/site-packages\/flask_session\/init.py\",\n  line 93, in _get_interface\n[Tue Nov 13 13:23:55.179163 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]     config['SESSION_USE_SIGNER'], config['SESSION_PERMANENT'])\n[Tue Nov 13 13:23:55.179169 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]   File \"\/var\/www\/html\/project\/python\/lib\/python3.6\/site-packages\/flask_session\/sessions.py\",\n  line 314, in init\n[Tue Nov 13 13:23:55.179172 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]     self.cache = FileSystemCache(cache_dir, threshold=threshold, mode=mode)\n[Tue Nov 13 13:23:55.179177 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]   File \"\/var\/www\/html\/project\/python\/lib\/python3.6\/site-packages\/werkzeug\/contrib\/cache.py\",\n  line 717, in init\n[Tue Nov 13 13:23:55.179180 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]     os.makedirs(self._path)\n[Tue Nov 13 13:23:55.179185 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]   File \"\/lib64\/python3.6\/os.py\", line 220, in makedirs\n[Tue Nov 13 13:23:55.179188 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]     mkdir(name, mode)\n[Tue Nov 13 13:23:55.179215 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx] PermissionError: [Errno 13] Permission denied: '\/flask_session'\n\nI tried giving the project different permissions but nothing worked","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1157,"Q_Id":53282275,"Users Score":0,"Answer":"You should specify which type of session interface to use.\nTry to set the SESSION-TYPE to \"null\".","Q_Score":2,"Tags":"python,apache,flask,wsgi,flask-session","A_Id":59171814,"CreationDate":"2018-11-13T13:38:00.000","Title":"Apache showing Permission denied: flask_session error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Im trying to get flask with virtual environment and wsgi configured to work but Apache keeps giving me this error: \n\n[Tue Nov 13 13:23:55.179153 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]     app.session_interface = self._get_interface(app)\n[Tue Nov 13 13:23:55.179160 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]   File \"\/var\/www\/html\/project\/python\/lib\/python3.6\/site-packages\/flask_session\/init.py\",\n  line 93, in _get_interface\n[Tue Nov 13 13:23:55.179163 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]     config['SESSION_USE_SIGNER'], config['SESSION_PERMANENT'])\n[Tue Nov 13 13:23:55.179169 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]   File \"\/var\/www\/html\/project\/python\/lib\/python3.6\/site-packages\/flask_session\/sessions.py\",\n  line 314, in init\n[Tue Nov 13 13:23:55.179172 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]     self.cache = FileSystemCache(cache_dir, threshold=threshold, mode=mode)\n[Tue Nov 13 13:23:55.179177 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]   File \"\/var\/www\/html\/project\/python\/lib\/python3.6\/site-packages\/werkzeug\/contrib\/cache.py\",\n  line 717, in init\n[Tue Nov 13 13:23:55.179180 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]     os.makedirs(self._path)\n[Tue Nov 13 13:23:55.179185 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]   File \"\/lib64\/python3.6\/os.py\", line 220, in makedirs\n[Tue Nov 13 13:23:55.179188 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx]     mkdir(name, mode)\n[Tue Nov 13 13:23:55.179215 2018] [wsgi:error] [pid 11819] [x.x.x.x:xxxx] PermissionError: [Errno 13] Permission denied: '\/flask_session'\n\nI tried giving the project different permissions but nothing worked","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1157,"Q_Id":53282275,"Users Score":0,"Answer":"The directory is failing to be created is on behalf of flask-session, which has a SESSION_FILE_DIR setting that'll let you override its default. Point that to some place with the appropriate permissions, and you'll likely be fine.","Q_Score":2,"Tags":"python,apache,flask,wsgi,flask-session","A_Id":53286630,"CreationDate":"2018-11-13T13:38:00.000","Title":"Apache showing Permission denied: flask_session error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a hosting plan through Godaddy that only supports python 2.6.6. I have been able to install python 2.7 and 3.6 through SSH and run scripts, pip, no problems.\nWhen I try and run a PHP script that calls a python script from SSH, it works just fine using my new python installs, but when I open the PHP script in a browser, it will only run 2.6.6.\nWhy is this? Is there a way to get around this without getting a VPS?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":311,"Q_Id":53284175,"Users Score":0,"Answer":"I have found a sneaky way around this. I used SSH2 PHP extension to call the python3.","Q_Score":0,"Tags":"php,python","A_Id":53285381,"CreationDate":"2018-11-13T15:21:00.000","Title":"Python on a shared hosting 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've written Heron topology which takes data from local folder and processes it. However, heron can't see any other folders except the one described in .pex file. How can I read data outside of .pex declared folders?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":53285835,"Users Score":0,"Answer":"Once a heron instance is launched, it should have access to files inside the same container. One example is they can write logs into .\/logs\/INSTANCE_ID.log, which means it has the write access to those files.\nCould you check if the data files are available inside the running container and the instance is using the correct file path to access those files?","Q_Score":0,"Tags":"python,heron,pants","A_Id":53286935,"CreationDate":"2018-11-13T16:49:00.000","Title":"Get access to local folder in Heron","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've written Heron topology which takes data from local folder and processes it. However, heron can't see any other folders except the one described in .pex file. How can I read data outside of .pex declared folders?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":53285835,"Users Score":0,"Answer":"Ideally, you would not rely on local data in you topology. It would be better to place any data your bolts need access to in an external system like a database or key:value store. Then you would get your bolts to query (and cache locally in memory) that data. This also has the advantage of scaling better if you need to add more copies of each bolt, as you avoid possible resource contention on the local files.\nIf you really want the data to be locally accessible to the bolts the answer depends on what scheduler you are using. It could involve adding the files to the heron instance container image that your scheduler uses and could mean rebuilding the containers every time you change the data. Again, I would suggest using an external datastore.","Q_Score":0,"Tags":"python,heron,pants","A_Id":53286976,"CreationDate":"2018-11-13T16:49:00.000","Title":"Get access to local folder in Heron","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get browser network logs using selenium to debug request\/responses. Could you please help me to find out a way.\nAnd I'm using selenium 3.14.0 and latest Chrome browser.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":22344,"Q_Id":53286828,"Users Score":1,"Answer":"Try selenium-wire, I think this is a better way which also provides undetected-chromedriver against bot detection.","Q_Score":8,"Tags":"python,selenium,selenium-webdriver,selenium-chromedriver","A_Id":67264765,"CreationDate":"2018-11-13T17:49:00.000","Title":"How to get browser network logs using python selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building an app that involves storing statistics of professional baseball players, and am using MongoDB.  If I am concerned about lookup time, does it make more sense to have an individual collection for each player, with the dictionary data to be organized like {statistic_name : statistic}, or each statistic to be a collection with the dictionary data organized like {player_name : statistic} ? \nThere will be significantly more players than there will be categories of statistics","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":53287467,"Users Score":0,"Answer":"In my opinion, you should make the first method : {statistic_name : statistic}.\nIt will be easier to select one of them. I think, i'm not 100% sure. \nSydney","Q_Score":0,"Tags":"python,database,mongodb","A_Id":53287682,"CreationDate":"2018-11-13T18:35:00.000","Title":"MongoDB collection design","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an entry widget and a button that calls askdirectory. I would like the initial value for the entry widget to be the default initialdir parameter for askdirectory. How do I get that value from the askdirectory function? (the reason I want to do this and not set an initial parameter is that I suspect that the function saves a recent directory and I would like to help the user save some time looking for the directory)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2169,"Q_Id":53287843,"Users Score":1,"Answer":"The default is the current working directory.\nFrom the canonical tk documentation about the initialdir option:\n\nSpecifies that the directories in directory should be displayed when the dialog pops up. If this parameter is not specified, then the directories in the current working directory are displayed. If the parameter specifies a relative path, the return value will convert the relative path to an absolute path.\n\nThat being said, the dialogs on OSX and Windows are native dialogs, and there might be platform-specific behavior to pick your home directory or last used directory or most recently used directory. Unfortunately, I don't think there's any way to get that information.","Q_Score":1,"Tags":"python-3.x,tkinter","A_Id":53288122,"CreationDate":"2018-11-13T19:01:00.000","Title":"What is tkinter askdirectory default value for initialdir parameter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi I was wondering how I could format a large text file by adding line breaks after certain characters or words. For instance, everytime a comma was in the paragraph could I use python to make this output an extra linebreak.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":53289151,"Users Score":0,"Answer":"you can use the ''.replace() method like so:\n'roses can be blue, red, white'.replace(',' , ',\\n') gives \n'roses can be blue,\\n red,\\n white' efectively inserting '\\n' after every ,","Q_Score":0,"Tags":"python,string,text","A_Id":53289189,"CreationDate":"2018-11-13T20:39:00.000","Title":"how to reformat a text paragrath using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a windows setup file (.exe), which is used to install a software. This is a third party executable. During installation, it expects certain values and has a UI.\nI want to run this setup .exe silently without any manual intervention (even for providing the parameter values).\nAfter spending some time googling about the approach, I feel powershell should be able to help me with my requirements.\nCan anyone suggest if powershell would be the right tool for this, or does a better tool exists to get this requirement?\nCan python be used to implement this requirement?\nPlease note: Since this is a third party executable, I don't have the names of the parameters for which values must be provided to the UI during installation\nThank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3678,"Q_Id":53289402,"Users Score":0,"Answer":"You can also try creating a shortcut to the exe and adding (one at a time) common help parameters in the shortcut target and see if one gives you a help dialog. Some common parameters are \n\/?\n\/help\n-help\n--help\nThis also depends on the developer implementing a help parameter, but most installer builders default to implementing, so more often than not you will get something. Also, try an internet search for \"SOFTWARE NAME silent install\". Quiet often the developer has some documentation on their web site. But, if it's a really small developer or freeware or the like, you may not find much.","Q_Score":0,"Tags":"python,powershell,windows-installer,installation","A_Id":53290003,"CreationDate":"2018-11-13T20:58:00.000","Title":"Silent run installer (.exe) with parameters on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am a little bit confused with why synchronization is needed in multithreading in python. Given the Global internal lock, there can only be one thread accessing the python object at a time right? so why do we still need synchronization library such as queue.Queue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":53289518,"Users Score":0,"Answer":"This is because pulling an item from a list and marking it as pulled, processing it and marking it as done are no atomic operation.","Q_Score":1,"Tags":"python,multithreading,synchronization","A_Id":53289710,"CreationDate":"2018-11-13T21:09:00.000","Title":"Is synchronization really needed in multithreading in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am completely new to django, but I am trying to change a database table. I read a good amount of post about running \npython manage.py makemigrations\npython manage.py migrate\nBut when I run these two command, it does not detect any changes. A solution has been to change the models.py but I do not have that file. (I jumped aboard a working project, which appears to only have initialize the database once at the very beginning. I want to add a column to my .sql file which is copied from an .csv\nCREATE TABLE test (\ncolumns\n...\norgan_system text <-adding only this line\n...\nmore columns);\n\/COPY test FROM 'test.csv' DELIMITER ',' CSV HEADER;\nI have no clue on where to start\/go.\nThe init.py file is completely empty if that means anything.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":78,"Q_Id":53289632,"Users Score":1,"Answer":"it's normal for the __init__.py file to be empty. if you're missing a models.py file though something is a bit iffy as that is what django uses to talk to the database\nyou are correct that in order to make changes to the database you would have to modify models.py","Q_Score":0,"Tags":"python,sql,django","A_Id":53289650,"CreationDate":"2018-11-13T21:18:00.000","Title":"django column does not exist but no models.py and no changes found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I apologize for my lengthy title name. I have two questions, where the second question is based on the first one. \n(1). Suppose I have a matrix, whose entries are either 0 or 1. Now, I pick an arbitrary 0 entry. Is there an efficient algorithm that searches the nearest entry with label 1 or calculates the distance between the chosen 0 entry and its nearest entry with label 1?\n(2). Suppose now the distribution of entries 1 has a geometric property. To make this statement clearer, imagine this matrix as an image. In this image, there are multiple continuous lines (not necessarily straight). These lines form several boundaries that partition the image into smaller pieces. Assume the boundaries are labeled 1, whereas all the pixels in the partitioned area are labeled 0. Now, similar to (1), I pick a random pixel labeled as 0, and I hope to find out the coordinate of the nearest pixel labeled as 1 or the distance between them.\nA hint\/direction for part (1) is enough for me. If typing up an answer takes too much time, it is okay just to tell me the name of the algorithm, and I will look it up.\np.s.: If I post this question in an incorrect section, please let me know. I will re-post it to an appropriate section. Thank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":53292326,"Users Score":0,"Answer":"I think that if you have a matrix, you can run a BFS version where the matrix A will be your graph G and the vertex v will be the arbitrary pixel you chose.\nThere is an edge between any two adjacent cells in the matrix.","Q_Score":0,"Tags":"python,algorithm,distance,distance-matrix","A_Id":53301201,"CreationDate":"2018-11-14T02:26:00.000","Title":"An algorithm that efficiently computes the distance of one labeled pixel to its nearest differently labeled pixel","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just installed Anaconda distribution and now any time I try to run python by double clicking a script, or executing it in the command prompt (I'm using windows 10) , it looks for libraries in the anaconda folder rather than my python folder, and then crashes. If I run via the command prompt, I'm able to see the error, which is:\n\nFile \"C:\\Users\\bob\\Anaconda3\\lib\\site-packages\\pandas__init__.py\",\n  line 19, in \n\"Missing required dependencies {0}\".format(missing_dependencies))\nImportError: Missing required dependencies ['numpy']\n\nI've uninstalled and re-installed Python and numpy multiple times, but it's getting installed in the default python folder, and since I installed the anaconda distribution, the python launcher always looks in the Anaconda folder. I have to run modules from IDLE or not at all.\nIs there any way to get Anaconda to play nice with the standard python installation? I'd really like to be able to quickly and easily double click python scripts to run them.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":448,"Q_Id":53294042,"Users Score":0,"Answer":"Anaconda comes with pip , you should not need a separate installation. If you need a library not available in anaconda then you would use pip. Both will store your downloaded packages in site-packages. In your scripts folder you should have [usually only one] reference to python. Generally I think anaconda is the preferred repository. I would consider removing \" standard installation\". If you need two for some reason make sure only one is in your environment variable path. Assuming you don't have the anaconda version in your path; go to the scripts folder ,in the cmd prompt and type \npython myscript.py","Q_Score":1,"Tags":"python-3.x,anaconda,conda","A_Id":53298648,"CreationDate":"2018-11-14T06:03:00.000","Title":"Anaconda Breaks Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why are there two different docker files for tensorflow serving - Dockerfile & Dockerfile.devel - for both CPU and GPUs?\nWhich one is necessary for deploying and testing?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":125,"Q_Id":53294415,"Users Score":1,"Answer":"a Dockerfile is a file where your write the configurations to create a docker image. \nThe tensorflow\/serving cpu and gpu are docker images which means they are already configured to work with tensorflow, tensorflow_model_server and, in the case of gpu, with CUDA. \nIf you have a GPU, then you can use a tensorflow\/serving gpu version which would reduce the latency of your predictions. If you don't have a GPU, then you can use a tensorflow\/serving cpu version which would do exactly the same but will be slower.","Q_Score":0,"Tags":"python,docker,tensorflow,dockerfile,tensorflow-serving","A_Id":53308093,"CreationDate":"2018-11-14T06:38:00.000","Title":"What is the difference between tensorflow serving Dockerfile and Dockerfile.devel?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to automate the editing, compiling and reading of results of MQL4 file using python, are there any tools like selenium but targeted for UI?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":175,"Q_Id":53295473,"Users Score":0,"Answer":"What works for me is two things:\n\nFirst option: clear the strategy tester logs, use comments in the code with specific string format, copy the logs and parse the data from the comments using python.\nSecond option: parse the expert advisor report using Python, from HTML to pandas dataframe for further processing.","Q_Score":0,"Tags":"python,python-3.x,automation,build-automation,mql4","A_Id":62120583,"CreationDate":"2018-11-14T08:02:00.000","Title":"How to edit, compile and read MQL4 files using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python Idle recently straight up refuse to launch, launching it from start menu or its own folder does nothing. Repairing and reinstalling does nothing, nor does running it in older versions of windows does anything.\nNo changes were made to the program before this. It could be due to a windows update but highly doubted it.\nnormally, I would get error messages or something. But nothing this time, it doesn't even show up in task manager.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":53295509,"Users Score":0,"Answer":"Try deleting the idlerc\u00a0folder in your profile directory.\nThis should fix the problem\nExample folder directory: \n\nC:\\Users\\your-username","Q_Score":1,"Tags":"python-3.7","A_Id":53295844,"CreationDate":"2018-11-14T08:04:00.000","Title":"Python IDLE refuse to launch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've coded a Telegram bot (python-telegram-bot) and I would like to know if there's a way to open an app from the bot.\nTo be more accurate, the bot searches torrent links and the original idea was to send that links directly to qBitTorrent in the user's computer but unfortunately I'm stuck in that step, so for the moment I though about give the user the magnet link so it can be pasted in the qBitTorrent app. The thing is that it would great to automaticly open the app from the bot.\nThanks in advance!","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2070,"Q_Id":53298734,"Users Score":2,"Answer":"A bot can't open an external app","Q_Score":3,"Tags":"python,python-3.x,bittorrent,python-telegram-bot","A_Id":53457627,"CreationDate":"2018-11-14T11:04:00.000","Title":"Any way to open an app from 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've coded a Telegram bot (python-telegram-bot) and I would like to know if there's a way to open an app from the bot.\nTo be more accurate, the bot searches torrent links and the original idea was to send that links directly to qBitTorrent in the user's computer but unfortunately I'm stuck in that step, so for the moment I though about give the user the magnet link so it can be pasted in the qBitTorrent app. The thing is that it would great to automaticly open the app from the bot.\nThanks in advance!","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":2070,"Q_Id":53298734,"Users Score":-1,"Answer":"I was also trying to do this, but that was not possible. But as workaround you can make a simple site that opens the app and make Telegram open that.","Q_Score":3,"Tags":"python,python-3.x,bittorrent,python-telegram-bot","A_Id":68702798,"CreationDate":"2018-11-14T11:04:00.000","Title":"Any way to open an app from 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 know that in gensims KeyedVectors-model, one can access the embedding matrix by the attribute model.syn0. There is also a syn0norm, which doesn't seem to work for the glove model I recently loaded. I think I also have seen syn1 somewhere previously. \nI haven't found a doc-string for this and I'm just wondering what's the logic behind this?\nSo if syn0 is the embedding matrix, what is syn0norm? What would then syn1 be and generally, what does syn stand for?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6897,"Q_Id":53301916,"Users Score":7,"Answer":"These names were inherited from the original Google word2vec.c implementation, upon which the gensim Word2Vec class was based. (I believe syn0 only exists in recent versions for backward-compatbility.)\nThe syn0 array essentially holds raw word-vectors. From the perspective of the neural-network used to train word-vectors, these vectors are a 'projection layer' that can convert a one-hot encoding of a word into a dense embedding-vector of the right dimensionality. \nSimilarity operations tend to be done on the unit-normalized versions of the word-vectors. That is, vectors that have all been scaled to have a magnitude of 1.0. (This makes the cosine-similarity calculation easier.) The syn0norm array is filled with these unit-normalized vectors, the first time they're needed. \nThis syn0norm will be empty until either you do an operation (like most_similar()) that requires it, or you explicitly do an init_sims() call. If you explicitly do an init_sims(replace=True) call, you'll actually clobber the raw vectors, in-place, with the unit-normed vectors. This saves the memory that storing both vectors for every word would otherwise require. (However, some word-vector uses may still be interested in the original raw vectors of varying magnitudes, so only do this when you're sure most_similar() cosine-similarity operations are all you'll need.)\nThe syn1 (or syn1neg in the more common case of negative-sampling training) properties, when they exist on a full model (and not for a plain KeyedVectors object of only word-vectors), are the model neural network's internal 'hidden' weights leading to the output nodes. They're needed during model training, but not a part of the typical word-vectors collected after training. \nI believe the syn prefix is just a convention from neural-network variable-naming, likely derived from 'synapse'.","Q_Score":6,"Tags":"python,deep-learning,nlp,gensim,word-embedding","A_Id":53333072,"CreationDate":"2018-11-14T13:56:00.000","Title":"Python\/Gensim - What is the meaning of syn0 and syn0norm?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a kivy application that allows plotting some graphics by using matplotlib lib. it worked well, and than i converted it to .exe with cx_freeze, it displayed this error :\n\nIntel MKL FATAL ERROR : Cannot load mkl_intel_thread.dll.\n\nAfter hours in forums, i putted all the mkl .dll files that exists in the Anaconda3-Windows-x86_64\\\\Library\\bin in Anaconda3-Windows-x86_64\\Lib\\site-packages\\numpy\\core folder because matplotlib needs numpy. with this action, the executable works perfectly on my laptop but not for the other users's laptops, it displayed this error :\n\nSystem Error\nThe program can't start because mkl_core.dll is missing from your computer. Try reinstalling the\nprogram to fix this problem.\n\nAnd then i putted the dll files in some folders in the executable's lib folder and now it displays this error :\n\nSystem Error\nThe program can't start because libiomp5md.dll is missing from your computer. Try reinstalling the\nprogram to fix this problem\n\nI don't understand whey these errors and how to solve this issue. I know that there is no error in my scripts (myapp.py and setup.py ) because it works well in my laptop.\nHave you any idea please ?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":195,"Q_Id":53302170,"Users Score":0,"Answer":"I am wondering if you properly assigned access permissions to the files. If you put them manually they may get your user's permissions and hence appear to be missing (inaccessible) for any other user.","Q_Score":0,"Tags":"python,matplotlib,kivy","A_Id":53302478,"CreationDate":"2018-11-14T14:10:00.000","Title":"Missing .dll files in an executable kivy application (matplotlib)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After the project have been working, is there a way to save the required dependencies and packages of the script to a virtualenv ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1144,"Q_Id":53304152,"Users Score":0,"Answer":"There isn't a pre-canned way to do this.\nYou can run !pip freeze to note installed packages \/ versions, which may help you recreate the environment you want. If that's insufficient can you say more about what you're trying to achieve?","Q_Score":1,"Tags":"python,virtualenv,google-colaboratory","A_Id":53324956,"CreationDate":"2018-11-14T15:55:00.000","Title":"Google Colab Project : saving installed packages to virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to understand the security implications of serializing a scikit-learn\/keras fitted model (using pickle\/joblib etc). \nSpecifically, if I work on data that I don't want to be revealed, would there be anyway for someone to reverse engineer what data a model was fitted on? Or is the data, just a way for the algorithm to update the relevant coefficients\/weights for the algorithm? (If I train the model against \"This movie is great\" and store it as a foo.pkl file, would I also be able to load the foo.pkl and say it was trained on \"This movie is great\" if all I have access to is the pkl file and not the data)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":450,"Q_Id":53304675,"Users Score":-1,"Answer":"No, you cant (in principle, anyway) reverse engineer the data based on a model. You can obviously derive the trained model weights\/etc and start to get a good understanding of what it might have been trained over, but directly deriving the data, I'm not aware of any possible way of doing that, providing you're pickling the trained model.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,pickle,joblib","A_Id":53306686,"CreationDate":"2018-11-14T16:25:00.000","Title":"Reverse engineer scikit-learn serialized model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am just starting the process of learning to access APIs using Python. Initially I presumed OAuth User IDs were generated or supplied by the API owner somehow. Would it actually be fabricated by myself, using alphanumerics and symbols? This is just for a personal project, I wouldn't have a need for a systematic creation of IDs. The APIs I am working with are owned by TDAmeritrade.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":54,"Q_Id":53306198,"Users Score":1,"Answer":"OAuth is has no capabilities for any type of provisioning of users or credentials.\nOAuth 2.0 provides for the Delegation of Authorization\n\nBy the Resource Owner (User)\nto the OAuth Client (Application)\nfor Access to a Resource Server (Website or Api or ???)","Q_Score":1,"Tags":"python,api,oauth","A_Id":53307184,"CreationDate":"2018-11-14T17:56:00.000","Title":"Creation of OAuth User IDs","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 change the font family shown in the new python interactive window that is produced when using the Python extension in VSCode?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1966,"Q_Id":53308965,"Users Score":1,"Answer":"Currently, the only way to achieve this is by zooming in or out the entire VS Code window with View -> Appearance -> Zoom In\/Zoom Out or use the Cmd + + or Cmd + - shortcuts (CTRL instead of Cmd on Windows). Do that until you get the desirable font size on the Python Interactive window.\nOf course zooming in or out will change the Python interactive window and the editor font size, but you can go to Settings and increase or decrease the font size of the editor until it becomes around same size as the Python Interactive window font size.","Q_Score":6,"Tags":"python,visual-studio-code","A_Id":58198498,"CreationDate":"2018-11-14T21:25:00.000","Title":"Python Interactive Window Font","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do i make python listen for changes to a folder on my desktop, and every time a file was added, the program would read the file name and categorize it it based on the extension?\nThis is a part of a more detailed program but I don't know how to get started on this part. This part of the program detects when the user drags a file into a folder on his\/her desktop and then moves that file to a different location based on the file extension.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":123,"Q_Id":53310469,"Users Score":0,"Answer":"Periodically read the files in the folder and compare to a set of files remaining after the last execution of your script. Use os.listdir() and isfile().\nRead the extension of new files and copy them to a directory based on internal rules. This is a simple string slice, e.g., filename[-3:] for 3-character extensions.\nRemove moved files from your set of last results. Use os.rename() or shutil.move().\nSleep until next execution is scheduled.","Q_Score":0,"Tags":"python,python-2.7","A_Id":53310614,"CreationDate":"2018-11-14T23:48:00.000","Title":"Python detecting different extensions on files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to compare the two, one is pandas.unique() and another one is numpy.unique(), and I found out that the latter actually surpass the first one.\nI am not sure whether the excellency is linear or not.\nCan anyone please tell me why such a difference exists, with regards to the code implementation? In what case should I use which?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":1666,"Q_Id":53310547,"Users Score":3,"Answer":"np.unique() is treating the data as an array, so it goes through every value individually then identifies the unique fields.\nwhereas, pandas has pre-built metadata which contains this information and pd.unique() is simply calling on the metadata which contains 'unique' info, so it doesn't have to calculate it again.","Q_Score":7,"Tags":"python,pandas,numpy,data-science,data-analysis","A_Id":62402653,"CreationDate":"2018-11-14T23:57:00.000","Title":"Why is pd.unique() faster than np.unique()?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This app is working fine on heroku but how do i configure it on godaddy using custom domain.\nWhen i navigate to custom domain, it redirects to mcc.godaddy.com.\nWhat all settings need to be changed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":121,"Q_Id":53311456,"Users Score":0,"Answer":"The solution is to add a correct CNAME record and wait till the value you entered has propagated.\nGo to DNS management and make following changes:\nIn the 'Host' field enter 'www' and in 'Points to' field add 'yourappname.herokuapp.com'","Q_Score":0,"Tags":"python,heroku,dns,hosting,custom-domain","A_Id":53688750,"CreationDate":"2018-11-15T02:12:00.000","Title":"How do I configure settings for my Python Flask app on GoDaddy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using Python to try and do some macroeconomic analysis of different stock markets. I was wondering about how to properly compare indices of varying sizes. For instance, the Dow Jones is around 25,000 on the y-axis, while the Russel 2000 is only around 1,500. I know that the website tradingview makes it possible to compare these two in their online charter. What it does is shrink\/enlarge a background chart so that it matches the other on a new y-axis. Is there some statistical method where I can do this same thing in Python?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":318,"Q_Id":53312182,"Users Score":0,"Answer":"I know that the website tradingview makes it possible to compare these two in their online charter. What it does is shrink\/enlarge a background chart so that it matches the other on a new y-axis.  \n\nThese websites rescale them by fixing the initial starting points for both indices at, say, 100. I.e. if Dow is 25000 points and S&P is 2500, then Dow is divided by 250 to get to 100 initially and S&P by 25. Then you have two indices that start at 100 and you then can compare them side by side.  \nThe other method (works good only if you have two series) - is to set y-axis on the right hand side for one series, and on the left hand side for the other one.","Q_Score":0,"Tags":"python,plot,statistics,correlation","A_Id":53312488,"CreationDate":"2018-11-15T03:51:00.000","Title":"Compare stock indices of different sizes Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had been able to run python files via Atom's Open in Browser, but now that I have uninstalled python 2.7 (still have the latest version installed) it throws an error saying I have no program associated with that file type. Any help would be appreciated!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":57,"Q_Id":53312449,"Users Score":2,"Answer":"Update your system's path variables because python path is pointing to the previous version which you have uninstalled.","Q_Score":0,"Tags":"python,atom-editor","A_Id":53312493,"CreationDate":"2018-11-15T04:29:00.000","Title":"can't run py files from atom after uninstalling old python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have data with the shape of (3000, 4), the features are (product, store, week, quantity). Quantity is the target. \nSo I want to reconstruct this matrix to a tensor, without blending the corresponding quantities.\nFor example, if there are 30 product, 20 stores and 5 weeks, the shape of the tensor should be (5, 20, 30), with the corresponding quantity. Because there won't be an entry like (store A, product X, week 3) twice in entire data, so every store x product x week pair should have one corresponding quantity.\nAny suggestions about how to achieve this, or there is any logical error? Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":626,"Q_Id":53313913,"Users Score":0,"Answer":"You can first go through each of your first three columns and count the number of different products, stores and weeks that you have. This will give you the shape of your new array, which you can create using numpy. Importantly now, you need to create a conversion matrix for each category. For example, if product is 'XXX', then you want to know to which row of the first dimension (as product is the first dimension of your array) 'XXX' corresponds; same idea for store and week. Once you have all of this, you can simply iterate through all lines of your existing array and assign the value of quantity to the correct location inside your new array based on the indices stored in your conversion matrices for each value of product, store and week. As you said, it makes sense because there is a one-to-one correspondence.","Q_Score":1,"Tags":"python,tensorflow","A_Id":53314237,"CreationDate":"2018-11-15T06:53:00.000","Title":"How to convert 2D matrix to 3D tensor without blending corresponding entries?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been having an issue with Anaconda, on two separate Windows machines.\nI've downloaded and installed Anaconda. I know the commands, how to install libraries, I've even installed tensorflow-gpu (which works). I also use Jupyter notebook and I'm quite familiar with it by this point.\nThe issue:\nFor some reason, when I create new environments and install libraries to that environment... it ALWAYS installs them to (base). Whenever I  try to run code in a jupyter notebook that is located in an environment other than (base), it can't find any of the libraries I need... because it's installing them to (base) by default.\nI always ensure that I've activated the correct environment before installing any libraries. But it doesn't seem to make a difference.\nCan anyone help me with this... am I doing something wrong?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":225,"Q_Id":53318001,"Users Score":0,"Answer":"Kind of fixed my problem. It is to do with launching Jupyter notebook. \nAfter switching environment via command prompt... the command 'jupyter notebook' runs jupyter notebook via the default python environment, regardless.\nHowever, if I switch environments via anaconda navigator and launch jupyter notebook from there, it works perfectly. \nMaybe I'm missing a command via the prompt?","Q_Score":0,"Tags":"python,anaconda","A_Id":53320989,"CreationDate":"2018-11-15T11:02:00.000","Title":"Installing packages to Anaconda Environments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I download the some of pdf and stored in directory. Need to insert them into mongo database with python code so how could i do these. Need to store them by making three columns (pdf_name, pdf_ganerateDate, FlagOfWork)like that.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1972,"Q_Id":53318410,"Users Score":1,"Answer":"You can use GridFS. Please check this url http:\/\/api.mongodb.com\/python\/current\/examples\/gridfs.html.\nIt will help you to store any file to mongoDb and get them. In other collection you can save file metadata.","Q_Score":0,"Tags":"python,mongodb,insert,store","A_Id":53320112,"CreationDate":"2018-11-15T11:25:00.000","Title":"How Do I store downloaded pdf files to Mongo DB","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install python3.6 on windows server 2016. I have downloaded  python-3.6.6rc1-amd64-webinstall.Followed the default setting to install it. But during installation step I got the error message as 0x80070659-This installation is forbidden by system policy. Contact your system administrator. I have talked with system administrator but he is not aware of this policy. Can you  please guide me to resolve this error?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":22910,"Q_Id":53319416,"Users Score":0,"Answer":"Login to the system using admin credentials and try installing it. Or when installing provide admin credentials to install it.","Q_Score":29,"Tags":"python,windows","A_Id":53320372,"CreationDate":"2018-11-15T12:21:00.000","Title":"Python 3.6 Installation failed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install python3.6 on windows server 2016. I have downloaded  python-3.6.6rc1-amd64-webinstall.Followed the default setting to install it. But during installation step I got the error message as 0x80070659-This installation is forbidden by system policy. Contact your system administrator. I have talked with system administrator but he is not aware of this policy. Can you  please guide me to resolve this error?","AnswerCount":3,"Available Count":3,"Score":-0.0665680765,"is_accepted":false,"ViewCount":22910,"Q_Id":53319416,"Users Score":-1,"Answer":"Run regedit\nBrowse the registry to HKLM\\Software\\Policies\\Microsoft\\Windows\\Installer\nCreate DisableMSI, type: REG_DWORD, value = 0 (0 should allow you to install, it was originally 1)","Q_Score":29,"Tags":"python,windows","A_Id":63205497,"CreationDate":"2018-11-15T12:21:00.000","Title":"Python 3.6 Installation failed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install python3.6 on windows server 2016. I have downloaded  python-3.6.6rc1-amd64-webinstall.Followed the default setting to install it. But during installation step I got the error message as 0x80070659-This installation is forbidden by system policy. Contact your system administrator. I have talked with system administrator but he is not aware of this policy. Can you  please guide me to resolve this error?","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":22910,"Q_Id":53319416,"Users Score":60,"Answer":"I experienced this very same problem, and right-clicking the setup file, then Run As Administrator solved it. (Credit to @Igwilliams, who suggested this in the comments).\nThis was actually very frustrating for me, because I was logged in as an administrator, but apparently that still wasn't enough, I had to do the Run as Administrator thing as well.","Q_Score":29,"Tags":"python,windows","A_Id":57807818,"CreationDate":"2018-11-15T12:21:00.000","Title":"Python 3.6 Installation failed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to Python and because I couldn't find a solution for my problem after some researches in google, I'm creating a new question, where I'm sure someone for 100% asked for it already. I have installed miniconda with numpy and pandas, which I want to use. It's located at ~\/miniconda. I've created new python file in ~\/Desktop, where I have imported those two libraries:\nimport numpy as np\nimport pandas as pd\nWhen I run my code, I got an error message:\nModuleNotFoundError: No module named 'numpy'\n\nHow can I make miniconda libraries visible in console for the python command?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":53319860,"Users Score":0,"Answer":"In Anaconda Navigator, I have already installed those libraries. What I have done was to delete them and install once again. Now it works for me from both: console and Jupyter Notebook.","Q_Score":0,"Tags":"python,macos","A_Id":53320092,"CreationDate":"2018-11-15T12:49:00.000","Title":"Python - No module found","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to Python and because I couldn't find a solution for my problem after some researches in google, I'm creating a new question, where I'm sure someone for 100% asked for it already. I have installed miniconda with numpy and pandas, which I want to use. It's located at ~\/miniconda. I've created new python file in ~\/Desktop, where I have imported those two libraries:\nimport numpy as np\nimport pandas as pd\nWhen I run my code, I got an error message:\nModuleNotFoundError: No module named 'numpy'\n\nHow can I make miniconda libraries visible in console for the python command?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":53,"Q_Id":53319860,"Users Score":1,"Answer":"conda has its own version of the Python interpreter. It is located in the Miniconda directory (It's called \"Python.exe\"). If you are using an IDE you need to switch the interpreter to use this version of Python rather than the default one you may have installed on the internet from the Python website itself.","Q_Score":0,"Tags":"python,macos","A_Id":53320029,"CreationDate":"2018-11-15T12:49:00.000","Title":"Python - No module found","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using pipenv to create a virtual environment in a folder. \nHowever, the environment seems to be in the path:  \n\n\/Users\/......\/.local\/share\/virtualenvs\/......\n\nAnd when I run the command pipenv run python train.py, I get the error:\n\ncan't open file 'train.py': [Errno 2] No such file or directory\n\nHow to run a file in the folder where I created the virtual environment?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5743,"Q_Id":53322703,"Users Score":7,"Answer":"You need to be in the same directory of the file you want to run then use:\npipenv run python train.py\nNote:\n\nYou may be at the project main directory while the file you need to run is inside a directory inside your project directory\nIf you use django to create your project, it will create two folders inside each other with the same name so as a best practice change the top directory name to 'yourname-project' then inside the directory 'yourname' run the pipenv run python train.py command","Q_Score":6,"Tags":"python,path,pipenv,virtual-environment","A_Id":53470726,"CreationDate":"2018-11-15T15:28:00.000","Title":"how to use pipenv to run file in current folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"So, I was building Python to optimize it to my hardware (specifically, version 3.6.7) and in the verbose I found this suggestion:\n\nYou are using pip version 10.0.1, however version 18.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n\nCan I upgrade pip before issuing the build command (compile python on my machine)? If so, will it matter?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":53327273,"Users Score":0,"Answer":"You can run your python task without upgrading. You can upgrade pip if you want (python -m pip install --upgrade pip), but I don't think the running of your python task will be affected by it.","Q_Score":1,"Tags":"python,pip","A_Id":53328663,"CreationDate":"2018-11-15T20:16:00.000","Title":"Upgrading pip before compiling Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using XGBClassifier to train in python and there are a handful of categorical variables in my training dataset. Originally, I planed to convert each of them into a few dummies before I throw in my data, but then the feature importance will be calculated for each dummy, not the original categorical ones. Since I also need to order all of my original variables (including numerical + categorical) by importance, I am wondering how to get importance of my original variables? Is it simply adding up?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1226,"Q_Id":53327334,"Users Score":0,"Answer":"You could probably get by with summing the individual categories' importances into their original, parent category. But, unless these features are high-cardinality, my two cents would be to report them individually. I tend to err on the side of being more explicit with reporting model performance\/importance measures.","Q_Score":0,"Tags":"python,xgboost,categorical-data","A_Id":53327378,"CreationDate":"2018-11-15T20:21:00.000","Title":"xgboost feature importance of categorical variable","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the past, I've been using WebJobs to schedule small recurrent tasks that perform a specific background task, e.g., generating a daily summary of user activities. For each task, I've written a console application in C# that was published as an Azure Webjob.\nNow I'd like to daily execute some Python code that is already working in a Docker container. I think I figured out how to get a container running in Azure. Right now, I want to minimize the operation cost since the container will only run for a duration of 5 minutes. Therefore, I'd like to somehow schedule that my container starts once per day (at 1am) and shuts down after completion. How can I achieve this setup in Azure?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":534,"Q_Id":53327355,"Users Score":4,"Answer":"I'd probably write a scheduled build job on vsts\\whatever to run at 1am daily to launch a container on Azure Container Instances. Container should shutdown on its own when the program exists (so your program has to do that without help from outside).","Q_Score":0,"Tags":"python,azure,docker,scheduled-tasks","A_Id":53327397,"CreationDate":"2018-11-15T20:22:00.000","Title":"How to run a briefly running Docker container on Azure on a daily basis?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is it possible to have an interactive REPL Python terminal in VS code with auto-complete capabilities?\nI know you can:\n\nGet a REPL window with 'Python: Start REPL', but that doesn't have auto-complete\nDebug a Python project and when the debugger is paused use the 'Debug Console' as a REPL console with auto-complete capabilities.\n\nIt seems that the capability is there but I would like the auto-complete capabilities of the Debug console without having to run the debugger.\nIs this possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2316,"Q_Id":53327894,"Users Score":0,"Answer":"You can try using IPython for such a REPL. Otherwise please keep an eye on our data science support as that just launched and we plan to continue to improve it.","Q_Score":1,"Tags":"python,visual-studio-code","A_Id":53382184,"CreationDate":"2018-11-15T21:06:00.000","Title":"Interactive python console with autocomplete in VS code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I Have got some models (mapped on database tables), in a python project. I want to make them preload when the project bootup so i don't need to do like this in every file\nfrom db.models.user import User\nI tried to load them in init.py file, but they are not available.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":197,"Q_Id":53330433,"Users Score":0,"Answer":"TL;DR: You need to import your models in every file.\n\nIn Python, every module (*.py file) has its own namespace (set of global variables).  There is no way to have a truly global variable (or class, function, etc.), because every name is local to the module in which it is defined.  This is a deliberate feature of Python; it would be very bad if (for example) you could redefine the range() function in some random module and break everyone else's code.\nYou can place the import from db.models.user import User in db\/models\/__init__.py, but that won't make User globally accessible.  Instead, it will create an alias db.models.User for the original class (db.models.user.User), which you still have to import as normal.  This may save you a small amount of typing when importing the model in other places, and is a great way to flatten deep hierarchies of packages, but it does not make anything truly global, because you cannot make things global.","Q_Score":0,"Tags":"python-3.x","A_Id":53330724,"CreationDate":"2018-11-16T02:02:00.000","Title":"Preload\/Globally certain classes in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We suddenly started getting this issue when compressing django static files on production servers. Ubuntu 16.04, Python 3.x, Django 1.11. I am using an ansible-playbook to deploy.\nThe error is as follows:\nCommandError: An error occurred during rendering \/chalktalk\/app\/chalktalk-react-40\/chalktalk-react-40\/chalktalk\/apps\/exams\/templates\/exams\/section-edit.html: Invalid input of type: 'CacheKey'. Convert to a byte, string or number first.\nIt doesn't seem to be an issue in one of the static files but a general issue. Every time we run it, we get a different file.\nI was looking for any clues on google and nothing shows up with the same error.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3229,"Q_Id":53331405,"Users Score":0,"Answer":"Try installing redis-py below version 3","Q_Score":10,"Tags":"python,django,ansible,django-compressor","A_Id":53336030,"CreationDate":"2018-11-16T04:21:00.000","Title":"Django compress error: Invalid input of type: 'CacheKey'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a dataset that is too large to store locally and I want to train a neural network.\nWhich would be faster? or are they the same? \n1) All files are stored on the external hard drive. The python file is run in the directory of the hard drive that loads the data and trains the network\n2) Python files are saved locally and the loading of the dataset during training is done by pointing it to the dataset on the external hard drive \nI'd assume that the execution speed and loading of the dataset will be equal in both these cases, but I'm not sure","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1158,"Q_Id":53332468,"Users Score":1,"Answer":"It depends on the read speed of your Hard drive and External hard drive.\nIs your hard drive a SSD? If it is, then It sure gonna be way faster than your external hard drive.\nIf the read speed of your hard disk drive and external is same or similar, then its doesn't matter where you store your dataset.\n1) Your python file will be \"loaded\" into RAM, and executed. So your internal hard disk plays no major role.\n2)Again, if your External HDD and internal HDD has similar read speed, then it doesn't matter.","Q_Score":0,"Tags":"python,neural-network","A_Id":53332661,"CreationDate":"2018-11-16T06:20:00.000","Title":"Running python script on external hard disk (training neural network)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to use dask to parallelize a numbercrunching task.\nThis task utilizes only one of the cores in my computer. \nAs a result of that task I would like to add an entry to a DataFrame via shared_df.loc[len(shared_df)] = [x, 'y']. This DataFrame should be populized by all the (four) paralllel workers \/ threads in my computer. \nHow do I have to setup dask to perform this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":53333644,"Users Score":0,"Answer":"The right way to do something like this, in rough outline:\n\nmake a function that, for a given argument, returns a data-frame of some part of the total data\nwrap this function in dask.delayed, make a list of calls for each input argument, and make a dask-dataframe with dd.from_delayed\nif you really need the index to be sorted and the index to partition along different lines than the chunking you applied in the previous step, you may want to do set_index \n\nPlease read the docstrings and examples for each of these steps!","Q_Score":0,"Tags":"python,pandas,python-multiprocessing,python-multithreading,dask","A_Id":53363572,"CreationDate":"2018-11-16T07:58:00.000","Title":"How to use dask to populate DataFrame in parallelized task?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What does Tensorflow really do when the Gradient descent optimizer is applied to a \"loss\" placeholder that is not a number (a tensor of size 1) but rather a vector (a 1-dimensional tensor of size 2, 3, 4, or more)?\nIs it like doing the descent on the sum of the components?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":358,"Q_Id":53333794,"Users Score":0,"Answer":"Tensorflow first reduces your loss to a scalar and then optimizes that.","Q_Score":2,"Tags":"python,tensorflow,gradient-descent","A_Id":53416420,"CreationDate":"2018-11-16T08:10:00.000","Title":"Multidimensional gradient descent in Tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Heropy. My topology looks the next way:\nSpout1 -> Bolt1 - > Bolt2\nSpout2     ---------> Bolt2\nSo, Bolt2 needs info from both Spout2 and Bolt1 in order to emit the result, however the info from Spout2 comes faster than the info from Bolt1 and Bolt2 has to wait until if has both Spout2 and Bolt1 info. How can I sync information flow using Heron API so that Bolt2 emits the result only after all the info available?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":53339982,"Users Score":0,"Answer":"In general the order\/synchronization is not guaranteed in streaming. It is hard for spout1 and spout2 themselves to be 100% synchronized I feel.\nI am thinking there is one options you might consider: hooking bolt1 to spout2 and emiting the tuples from spout2 directly, disconnecting bolt2 from spout2. So that bolt1 becomes the source of truth of the ordering.\nWindowing might be another option, but it requires more considerations and works.","Q_Score":0,"Tags":"python,heron","A_Id":53343390,"CreationDate":"2018-11-16T14:40:00.000","Title":"Sync severals spouts and bolt in Heron","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using Heropy. My topology looks the next way:\nSpout1 -> Bolt1 - > Bolt2\nSpout2     ---------> Bolt2\nSo, Bolt2 needs info from both Spout2 and Bolt1 in order to emit the result, however the info from Spout2 comes faster than the info from Bolt1 and Bolt2 has to wait until if has both Spout2 and Bolt1 info. How can I sync information flow using Heron API so that Bolt2 emits the result only after all the info available?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":53339982,"Users Score":0,"Answer":"Heron doesn't synchronize tuples from different components automatically. So you will need to buffer the tuples from Spout2 and wait until the corresponding tuples from Bolt1 arrive, then do the computation.","Q_Score":0,"Tags":"python,heron","A_Id":53345766,"CreationDate":"2018-11-16T14:40:00.000","Title":"Sync severals spouts and bolt in Heron","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to install K-modes package in Anaconda. \nI cannot find it in Anaconda anywhere.\nHow do I download and get it to work through an Anaconda distribution?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":4473,"Q_Id":53340576,"Users Score":4,"Answer":"I am on Mac and have just managed to install kmodes using pip and open in jupyter notebooks in Anaconda. If you are on Windows this might work differently, but you can try it.\nFirst of all I opened the general terminal and I entered \nconda info --envs\nThis shows you what virtual envs have been created in anaconda. It should show you one that says base\/ at the start. Simply write source activate and then copy and past the base pathway, and press enter. This will open your anaconda environment. \nThen you can do pip install kmodes and enter, and this will install kmodes into your anaconda environment. \nI hope this works for you!","Q_Score":2,"Tags":"python,anaconda","A_Id":54263706,"CreationDate":"2018-11-16T15:14:00.000","Title":"K-modes python installation using Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a fairly involved setup.py cython compilation process where I consider multiple things such as openMP support and the presence or absence of C headers. Specifically, FFTW is a library that computes the FFT, and is faster than numpy's FFT, so if fftw3.h is available, I compile my module against that, otherwise I fallback onto numpy.\nI would like to be able to remember how the package was compiled i.e. did the compiler support openMP and which FFT library was used. All this information is available when running setup.py but not later on and can be useful e.g. if the user would like to run a function using multiple cores, but openMP was not used during compilation, everything will run on one core. Remembering this information would allow me to show a nice error.\nI am unsure what the best way to do this would be. There are plenty of options such as writing a file with the data and then reading it when necessary, but is there any standard way to do this? Basically, I'm trying to emulate numpy's show_config, but am unsure what the best way to do this would be.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":25,"Q_Id":53340990,"Users Score":1,"Answer":"I have not attempted this, but my suggestion would to mimic the config.h-behavior one sees with autotools-based building: your setup.py generates a set of definitions that you either invoke via commandline or use via a generated header file - and then you can use this to feed e.g. a compiled extension function to return an approriate data-structure. But whatever you do: I have not come across a standardized way for this.","Q_Score":1,"Tags":"python,cython","A_Id":53341180,"CreationDate":"2018-11-16T15:36:00.000","Title":"Saving Python package setup configuration for later use","Data 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":"Autoescape is set to false globally. Is there a way to tell Jinja2 to escape a specific template?\nThe {% autoescape false %} block apparently only works for disabling autoescape in templates if the global settings is set to true and not the other way around.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":636,"Q_Id":53341853,"Users Score":0,"Answer":"Which version of Jinja2 are you using? Is it used on a Flask\/Django context or something else?\nI tested with Flask==1.1.1 and Jinja2==2.10.1 and what I observed is that autoescape is enabled by default when using render_template.","Q_Score":0,"Tags":"python,escaping,jinja2","A_Id":57424764,"CreationDate":"2018-11-16T16:27:00.000","Title":"Jinja2 autoescape","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm fairly new to MongoDB. I need my Python script to query new entries from my Database in real time, but the only way to do this seems to be replica sets, but my Database is not a replica set, or with a Tailable cursor, which is only for capped collections.\nFrom what i understood, a capped collection has a limit, but since i don't know how big my Database is gonna be and for when i'm gonna need to send data there, i am thinking of putting the limit to 3-4 million documents. Would this be possible?.\nHow can i do that?.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":203,"Q_Id":53342146,"Users Score":1,"Answer":"so do you want to increase the size of capped collection ? \nif yes then if you know average document size then you may define size like: \ndb.createCollection(\"sample\", { capped : true, size : 10000000, max : 5000000 } )    here 5000000 is max documents with size limit of 10000000 bytes","Q_Score":0,"Tags":"python,mongodb","A_Id":53372398,"CreationDate":"2018-11-16T16:47:00.000","Title":"MongoDB - how can i set a documents limit to my capped collection?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building Python from source, the advantage of this being it will be optimized for my hardware (PGO). But I also want to compile 3rd party packages like NumPy or SciPy to take advantage of intel MKL (I have a Xeon CPU) and optimize them instead of just installing them via PIP which would download pre-compiled, \"generic\", non-optimized code.\nBecause I would potentially compile \"a lot\" of packages by myself I am looking for suggestions as to how to automatize this process. The \"traditional\" or \"standard\" way of doing this would be something like this:\n1) compile a package\n2) include that package to python (maybe using PIP?)\n3) repeat the previous 2 steps for each package.\nI intend to use Microsoft Visual Studio (under Windows 10 x64), so my question is this:\nIs there a way to automatize this process using Visual Studio? if so,\nCan anyone give me a hint as to what to look for? \nI am new to Visual Studio and I am not asking for a complete \"How To\" but I would appreciate someone telling me if this can be done (or feasible, depending on what packages need to be compiled), otherwise I would revert back to manually make that process by compiling and adding them to Python one by one.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":53342871,"Users Score":0,"Answer":"If you're looking to optimize, you can't really automate much as each library will need its own customization. otherwise pip is probably the way to go. Realistically however, you'll only probably need to optimize a few libraries such as the scientific stack and possibly numba for better jit compilation. \nTLDR; install numpy from source using the blas\/lapack (math libs) optimized for your system and use pip for the rest.","Q_Score":0,"Tags":"python,numpy,build,compilation,scipy","A_Id":53343059,"CreationDate":"2018-11-16T17:41:00.000","Title":"How to bundle Python packages (case study: Microsoft Visual Studio 2017)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In PyCharm 2018.2.5 (Community Edition), I have bound a keyboard shortcut to \"Run File in Console\". This launches opens the console and runs the file, but does not focus the console for input and anything I type goes into my code. (Sometimes when I use the switcher to focus the Python console it will try to search console variables when I type.)\nIs there a way to automatically focus the Python console for input when it is launched?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1864,"Q_Id":53345342,"Users Score":1,"Answer":"The shortcut to switch between the code and console is Alt+4; by clicking on the console or using this shortcut, future consoles you open will be selected by the input.","Q_Score":7,"Tags":"python,pycharm","A_Id":53347527,"CreationDate":"2018-11-16T21:03:00.000","Title":"PyCharm focus Python Console for input upon run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm testing some regex.  It looks like this part is getting cut off: ing.*_{FD_YYYYMMDD}.*\nAm I doing something wrong here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":53345856,"Users Score":3,"Answer":"What you are seeing is a string representation of a match object. It should only be used for debugging, and it is truncated.\nTo see the string captured by a group (green), call re.search(pattern, string).group(1)","Q_Score":0,"Tags":"python,regex","A_Id":53345910,"CreationDate":"2018-11-16T21:45:00.000","Title":"Weird issue with regex match","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I added the pip installation folder in my python site-packages directory to my PATH, but I can still only run it via python -m pip in my git bash. Just pip gives me command not found.\nI looked around the pip directory and I don't see any binaries, so this makes sense. Yet clearly pip is a thing that is normally used on the command line without python -m. So what component am I missing here?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":19387,"Q_Id":53346267,"Users Score":3,"Answer":"in your Anaconda directory there is a pip file in the direcctory Scripts.\nadd this path : C:\\Users#yourname\\Anaconda3\\Scripts\ni did the same and it was successful !!\n(when i wrote pip in git bash it worked)","Q_Score":7,"Tags":"python,windows,pip","A_Id":60069204,"CreationDate":"2018-11-16T22:30:00.000","Title":"How to make pip available to git bash command line on Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I added the pip installation folder in my python site-packages directory to my PATH, but I can still only run it via python -m pip in my git bash. Just pip gives me command not found.\nI looked around the pip directory and I don't see any binaries, so this makes sense. Yet clearly pip is a thing that is normally used on the command line without python -m. So what component am I missing here?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":19387,"Q_Id":53346267,"Users Score":14,"Answer":"Try adding C:\/path\/to\/python\/Scripts\/ to PATH\nThere should be a pip.exe there!","Q_Score":7,"Tags":"python,windows,pip","A_Id":53346494,"CreationDate":"2018-11-16T22:30:00.000","Title":"How to make pip available to git bash command line on Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to run an Arducam MT9J001 camera on a raspberry pi 3b+. I am getting the following error when I try to run the program, \"ImportError: libcblas.so3: cannot open shared object file: No such file or directory.\" I have the computer vision software downloaded onto the raspberry pi, though it seems that it is still not working. I'm not sure what other information is viable to this project, but if there is something else I should be specifying please let me know. Thanks in advance!","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":91576,"Q_Id":53347759,"Users Score":26,"Answer":"Exact same solution as @thvs86 but here's a single 1 line copy-paste so you don't have to insert each command individually:\npip3 install opencv-contrib-python; sudo apt-get install -y libatlas-base-dev libhdf5-dev libhdf5-serial-dev libatlas-base-dev libjasper-dev  libqtgui4  libqt4-test","Q_Score":32,"Tags":"python,linux,raspberry-pi3,importerror","A_Id":54954503,"CreationDate":"2018-11-17T02:50:00.000","Title":"ImportError: libcblas.so.3: cannot open shared object file: 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":0,"Web Development":0},{"Question":"I have wrote an Android library and build an aar file. And I want to write a python program to use the aar library. Is it possible to do that? If so, how to do that? Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":305,"Q_Id":53347795,"Users Score":0,"Answer":"There is no way to include all dependencies to your aar file. So According to the open source licenses you can add their sources to your project.","Q_Score":3,"Tags":"android,python,aar","A_Id":53348357,"CreationDate":"2018-11-17T02:57:00.000","Title":"Import aar of Android library in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing an application in which I am explicitly using memcache with Google Appengine's NDB library. I want something like this.\n1) Get 100 records from datastore and put them in memcache.\n2) Now whenever user wants these records I would get these records from memcache instead of datastore.\n3) I would invalidate the memcache if there is a new record in datastore and then populate the memcache with 101 records.\nI am thinking of an approach like I compare the number of records in memcache and datastore and if there is a difference, I would update the memcache.\nBut if we see documentation of NDB, we can only get count by retrieving all the records, and this is not required as datastore query is not being avoided in this way.\nAny help anyone? Or any different approach I could go with?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":53350054,"Users Score":0,"Answer":"Rather than relying on counts, you could give each record a creation timestamp, and keep the most recent timestamp in memcache. Then to see if there are new records you just need to check if there are any timestamps newer than that, which assuming you have an index on that field is a very quick query.","Q_Score":0,"Tags":"django,python-2.7,nosql,app-engine-ndb,google-app-engine-python","A_Id":53350546,"CreationDate":"2018-11-17T09:52:00.000","Title":"Best way to count number of records from NDB library","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I just installed Graphene on my Django project and would like to use it also for the back-end, templating. So far, I find just tutorials how to use it only for front-end, no mention about back-end. \n\nShould I suppose that it is not a good idea to use it instead of a SQL database? If yes, then why? Is there a downside in the speed in the comparison to a SQL databases like MySQL?\nWhat's the best option how to retrieve the data for templates in Python? I mean, best for the performance.\n\nThnx.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":229,"Q_Id":53351156,"Users Score":2,"Answer":"GraphQL is an API specification.  It doesn't specify how data is stored, so it is not a replacement for a database.\nIf you're using GraphQL, you don't use Django templates to specify the GraphQL output, because GraphQL specifies the entire HTTP response from the web service, so this question doesn't make sense.","Q_Score":2,"Tags":"python,django,django-templates,graphql,graphene-python","A_Id":53380130,"CreationDate":"2018-11-17T12:15:00.000","Title":"GraphQL\/Graphene for backend calls in Django's templates","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For my coursework I've been told to write an algorithm in Python to solve the Euler-Lagrange equations with Dirichlet boundary conditions.\nFor reasons I don't understand we have only studied finite difference methods yet (very briefly) in lectures. I was wondering if I should start with that algorithm, or would you recommend another method that is not too complicated but would be more efficient?\nThanks a lot!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":823,"Q_Id":53352342,"Users Score":0,"Answer":"Shooting methods, when they work, are fast and accurate. There\nare some problems for which the BVP is well-posed but the IVP\nused in the shooting method is not (e.g. the IVP has infinite\nsolutions for some values of z).\nThat's chapter 13 page 13 of your lecture notes","Q_Score":0,"Tags":"python,numerical-methods,pde","A_Id":53638631,"CreationDate":"2018-11-17T14:52:00.000","Title":"Algorithm suggestions for solving Euler-Lagrange equations numerically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am pretty new to neural networks. I am training a network in tensorflow, but the number of positive examples is much much less than negative examples in my dataset (it is a medical dataset). \nSo, I know that F-score calculated from precision and recall is a good measure of how well the model is trained. \nI have used error functions like cross-entropy loss or MSE before, but they are all based on accuracy calculation (if I am not wrong). But how do I use this F-score as an error function? Is there a tensorflow function for that? Or I have to create a new one?\nThanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8429,"Q_Id":53354176,"Users Score":0,"Answer":"the loss value and accuracy is a different concept. The loss value is used for training the NN. However, accuracy or other metrics is to value the training result.","Q_Score":6,"Tags":"python,tensorflow,loss-function,precision-recall","A_Id":61325048,"CreationDate":"2018-11-17T18:20:00.000","Title":"How to use F-score as error function to train neural networks?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"According to some references I see that most of the time 1 is added to the denominator of idf equation to avoid the log it becomes infinity if a word does not exist in any documents.\nBut what if a word exists in all documents? Then idf would be negative. How should we deal with this situation?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":341,"Q_Id":53354291,"Users Score":0,"Answer":"If a word exists in every document from the corpus, then its \"knowledge\" value is very poor - because this word does not differentiate one document from the corpus.","Q_Score":0,"Tags":"python,tf-idf","A_Id":53354328,"CreationDate":"2018-11-17T18:35:00.000","Title":"using idf with denominator+1 when all documents has the specific word","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm reading on the WSGI specification, and tried implementing a simple WSGI server from scratch, and tested it on a simple flask application. Currently it\n\nopens a socket listener\npasses each incoming connection to another thread to handle it\nthe handler parses the request, creates the environ, passes it to the flask app object, and returns the response.\n\nOverall, it seems to work. Conceptually, what more does a real server, eg. gunicorn do? I'm asking in terms of the basic functionality, not in terms of supporting more features (eg. different protocols). What makes a server better, eg. why is gunicorn suitable for production, but wsgiref is not?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":36,"Q_Id":53354372,"Users Score":1,"Answer":"my 2c, is that getting something working is pretty easy, it's just that HTTP is such an old\/complex standard it takes a lot of work to get all the edge cases working nicely\n\nhow well does it tolerate errors in the WSGI client code\nHTTP 0.9, 1.0, 1.1 or 2\/SPDY?\nhow do you handle malicious clients that send a byte every 10 seconds\nthe various Keep-Alive and Tranfer-Encoding variants seems to end up consuming a lot of code\ndoes it do Content-Encoding as well","Q_Score":1,"Tags":"python,server,uwsgi","A_Id":53355376,"CreationDate":"2018-11-17T18:43:00.000","Title":"What does a wsgi server consist of?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I mounted my drive using this : \nfrom google.colab import drive\ndrive.mount('\/content\/drive\/')\nI have a file inside a folder that I want the path of how do I determine the path? \nSay the folder that contains the file is named 'x' inside my drive","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":18640,"Q_Id":53355510,"Users Score":6,"Answer":"The path as parameter for a function will be \/content\/drive\/My Drive\/x\/the_file, so without backslash inside My Drive","Q_Score":7,"Tags":"python,google-colaboratory","A_Id":56513444,"CreationDate":"2018-11-17T20:57:00.000","Title":"How to determine file path in Google colab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I mounted my drive using this : \nfrom google.colab import drive\ndrive.mount('\/content\/drive\/')\nI have a file inside a folder that I want the path of how do I determine the path? \nSay the folder that contains the file is named 'x' inside my drive","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":18640,"Q_Id":53355510,"Users Score":9,"Answer":"The path will be \/content\/drive\/My\\ Drive\/x\/the_file.","Q_Score":7,"Tags":"python,google-colaboratory","A_Id":53357067,"CreationDate":"2018-11-17T20:57:00.000","Title":"How to determine file path in Google colab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using Windows\nLearning about virtualenv. Here is my understanding of it and a few question that I have. Please correct me if my understanding is incorrect. \nvirtualenv are environments where your pip dependencies and its selected version are stored for a particular project. A folder is made for your project and inside there are the dependencies. \n\nI was told you would not want to save your .py scripts in side of virtual ENV, if that's the case how do I access the virtual env when I want to run that project? Open it up in the command line under source ENV\/bin\/activate then cd my way to where my script is stored?\nBy running pip freeze that creates a requirements.txt file in that project folder that is just a txt. copy of the dependencies of that virtual env? \nIf I'm in a second virutalenv who do I import another virtualenv's requirements? I've been to the documentation but I still don't get it.\n$ env1\/bin\/pip freeze > requirements.txt\n$ env2\/bin\/pip install -r requirements.txt\n\nGuess I'm confused on the \"requirements\" description. Isn't best practice to always call our requirements, requirements.txt? If that's the case how does env2 know I'm want env1 requirements? \nThank you for any info or suggestions. Really appreciate the assistance.\nI created a virtualenv  C:\\Users\\admin\\Documents\\Enviorments>virtualenv django_1 \nUsing base prefix'c:\\\\users\\\\admin\\\\appdata\\\\local\\\\programs\\\\python\\\\python37-32' \nNew python executable in C:\\Users\\admin\\Documents\\Enviorments\\django_1\\Scripts\\python.exe Installing setuptools, pip, wheel...done.\nHow do I activate it? source django_1\/bin\/activate doesn't work?\nI've tried: source C:\\Users\\admin\\Documents\\Enviorments\\django_1\/bin\/activate Every time I get : 'source' is not recognized as an internal or external command, operable program or batch file.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":53356442,"Users Score":0,"Answer":"* disclaimer * I mainly use conda environments instead of virtualenv, but I believe that most of this is the same across both of them and is true to your case.\n\nYou should be able to access your scripts from any environment you are in. If you have virtenvA and virtenvB then you can access your script from inside either of your environments. All you would do is activate one of them and then run python \/path\/to\/my\/script.py, but you need to make sure any dependent libraries are installed. \nCorrect, but for clarity the requirements file contains a list of the dependencies by name only. It doesn't contain any actual code or packages. You can print out a requirements file but it should just be a list which  says package names and their version numbers. Like pandas 1.0.1    numpy 1.0.1   scipy 1.0.1 etc.\nIn the lines of code you have here you would export the dependencies list of env1 and then you would install these dependencies in env2. If env2 was empty then it will now just be a copy of env1, otherwise it will be the same but with all the packages of env1 added and if it had a different version number of some of the same packages then this would be overwritten","Q_Score":1,"Tags":"python,python-3.x,virtualenv","A_Id":53356590,"CreationDate":"2018-11-17T23:12:00.000","Title":"virtualenv - Birds Eye View of Understanding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Using Windows\nLearning about virtualenv. Here is my understanding of it and a few question that I have. Please correct me if my understanding is incorrect. \nvirtualenv are environments where your pip dependencies and its selected version are stored for a particular project. A folder is made for your project and inside there are the dependencies. \n\nI was told you would not want to save your .py scripts in side of virtual ENV, if that's the case how do I access the virtual env when I want to run that project? Open it up in the command line under source ENV\/bin\/activate then cd my way to where my script is stored?\nBy running pip freeze that creates a requirements.txt file in that project folder that is just a txt. copy of the dependencies of that virtual env? \nIf I'm in a second virutalenv who do I import another virtualenv's requirements? I've been to the documentation but I still don't get it.\n$ env1\/bin\/pip freeze > requirements.txt\n$ env2\/bin\/pip install -r requirements.txt\n\nGuess I'm confused on the \"requirements\" description. Isn't best practice to always call our requirements, requirements.txt? If that's the case how does env2 know I'm want env1 requirements? \nThank you for any info or suggestions. Really appreciate the assistance.\nI created a virtualenv  C:\\Users\\admin\\Documents\\Enviorments>virtualenv django_1 \nUsing base prefix'c:\\\\users\\\\admin\\\\appdata\\\\local\\\\programs\\\\python\\\\python37-32' \nNew python executable in C:\\Users\\admin\\Documents\\Enviorments\\django_1\\Scripts\\python.exe Installing setuptools, pip, wheel...done.\nHow do I activate it? source django_1\/bin\/activate doesn't work?\nI've tried: source C:\\Users\\admin\\Documents\\Enviorments\\django_1\/bin\/activate Every time I get : 'source' is not recognized as an internal or external command, operable program or batch file.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":53356442,"Users Score":0,"Answer":"virtualenv simply creates a new Python environment for your project. Think of it as another copy of Python that you have in your system. Virutual environment is helpful for development, especially if you will need different versions of the same libraries.\nAnswer to your first question is, yes, for each project that you use virtualenv, you need to activate it first. After activating, when you run python script, not just your project's scripts, but any python script, will use dependencies and configuration of the active Python environment.\nAnswer to the second question, pip freeze > requirements.txt will create requirements file in active folder, not in your project folder. So, let's say in your cmd\/terminal you are in C:\\Desktop, then the requirements file will be created there. If you're in C\\Desktop\\myproject folder, the file will be created there. Requirements file will contain the packages installed on active virtualenv.\nAnswer to 3rd question is related to second. Simply, you need to write full path of the second requirements file. So if you are in first project and want to install packages from second virtualenv, you run it like env2\/bin\/pip install -r \/path\/to\/my\/first\/requirements.txt. If in your terminal you are in active folder that does not have requirements.txt file, then running pip install will give you an error. So, running the command does not know which requirements file you want to use, you specify it. \nI created a virtualenv \nC:\\Users\\admin\\Documents\\Enviorments>virtualenv django_1 Using base prefix 'c:\\\\users\\\\admin\\\\appdata\\\\local\\\\programs\\\\python\\\\python37-32' New python executable in C:\\Users\\admin\\Documents\\Enviorments\\django_1\\Scripts\\python.exe Installing setuptools, pip, wheel...done. \nHow do I activate it? source django_1\/bin\/activate doesn't work? \nI've tried: source C:\\Users\\admin\\Documents\\Enviorments\\django_1\/bin\/activate Every time I get : 'source' is not recognized as an internal or external command, operable program or batch file.","Q_Score":1,"Tags":"python,python-3.x,virtualenv","A_Id":53356656,"CreationDate":"2018-11-17T23:12:00.000","Title":"virtualenv - Birds Eye View of Understanding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"So basically I have this main window with just a bunch of buttons on it. I am hiding the default header by using self.set_decorated(False). I want to be able to drag the window around my screen by clicking anywhere that's not a button. Is this possible? I haven't been able to find anything on this except for self.begin_move_drag(self.button_drag, event.x_root, event.y_root, event.time) which I don't really understand.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":192,"Q_Id":53356660,"Users Score":1,"Answer":"hb.props.custom_title = Gtk.Label(label=\" \")","Q_Score":0,"Tags":"python-3.x,gtk3,pygtk","A_Id":53508835,"CreationDate":"2018-11-17T23:48:00.000","Title":"How do I make a window draggable without a header?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had a python function saved in a .py file but I just accidentally wrote over it.\nHowever, I have a jupyter notebook open and loaded with the function before I erased it (so I guess it is using the .pyc ?). So at the beginning of my notebook:\nfrom now_deleted_script import deleted_function\nIs it possible for me to tell the jupyter notebook to print out the whole deleted_function that it has stored in its memory?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":411,"Q_Id":53357933,"Users Score":1,"Answer":"You may be able to use %ed deleted_function to see the original source code.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":53357996,"CreationDate":"2018-11-18T04:35:00.000","Title":"Get jupyter notebook to print a whole function that it has imported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I want to install a python package, I find the pip install <package> instructions on most of the sites \/ README.md documentation in github etc.\nA colleague told me recently to try first a conda install <package> and if this fails (because the package is not available) to use the pip install process afterwards. \nIs the try with the conda installation step really necessary \/ beneficial or can I just do the pip install directly?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":100,"Q_Id":53358340,"Users Score":3,"Answer":"It depends on your use case. Conda does more than pip does. Conda was developed after pip because the Conda folks did not think pip did enough. It aims to handle library dependencies outside of the realm of python such as C libraries, R packages, or really anything with a wheel. as well as handling the python packages themselves. This is important because these packages do not have the standard setup.py in their source code, so python will not install them into the site-packages directory which is useful for easy importing. \nIt is important to note that you can't use pip and conda interchangeably, as conda has a different packaging format. \nTo answer your question succinctly: If you use one, I would stick to it for the entirety of whatever you are doing, and not use conda \"until it doesn't work for something\" and then just switch to pip for installations that conda can't handle. That is a super good way to get into trouble you can't explain.\nMy advice: if you are sticking to python and python only, use pip. If you are considering outside libraries that have value to your project, conda is a good option.","Q_Score":1,"Tags":"python,pip,anaconda,conda","A_Id":53358420,"CreationDate":"2018-11-18T06:07:00.000","Title":"conda before pip install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my current directory there is the executable script.py with the shebang #!\/usr\/bin\/env python. To execute it in bash, I need to type .\/script.py. From what I read about shebang I would expect script.py to execute the script too, same as python script.py does, but it doesn't. What is the difference between the two latter options?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":213,"Q_Id":53359402,"Users Score":4,"Answer":"On Un*x-like systems, . is not in the path for security reasons, in order to avoid executing a command like ls which could be in a user directory (this security breach is best exploited as root)\nThis is less concerning for python scripts than for classic commands like ls, but python scripts with a shebang are executables so the obey the general security rules.\nWhen you type python myscript.py you know that the script is in the current directory, and python reads it from here, regardless of the system path (it's seen as data, not as executable, the real executable being python)","Q_Score":2,"Tags":"python,shebang","A_Id":53359421,"CreationDate":"2018-11-18T09:20:00.000","Title":"Why does python script in current directory need .\/ for execution with shebang?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there an algorithm that can automatically calculate a numerical rating of the degree of abstractness of a word. For example, the algorithm rates purvey as 1, donut as 0, and immodestly as 0.5 ..(these are example values)\nAbstract words in the sense words that refer to ideas and concepts that are distant from immediate perception, such as economics, calculating, and disputable. Other side Concrete words refer to things, events, and properties that we can perceive directly with our senses, such as trees, walking, and red.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":53364314,"Users Score":1,"Answer":"There's no definition of abstractness that I know of, neither any algorithm to calculate it.\nHowever, there are several directions I would use as proxies\n\nFrequency - Abstract concepts are likely to be pretty rare in a common speech, so a simple idf should help identify rare words.\nEtymology - Common words in English, are usually decedent from Germanic origin, while more technical words are usually borrowed from French \/ Latin.\nSupervised learning - If you have Wikipedia articles you find abstract, then the common phrases or word would probably also describe similar abstract concepts. Training a classifier can be a way to score.\n\nThere's no ground truth as to what is abstract, and what is concrete, especially if you try to quantify it.\nI suggest aggregating these proxies to a metric you find useful for your needs.","Q_Score":2,"Tags":"python,nlp,wordnet","A_Id":53365423,"CreationDate":"2018-11-18T18:45:00.000","Title":"Is there an algorithm to calculate a numerical rating of the degree of abstractness of a word in NLP?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a Tkinter window in a python script. The script runs perfectly in the python IDLE and generates the GUI. However, when I run this file outside of the IDLE by clicking on it on my Desktop, the terminal responds with ImportError: No module named tkinter. Even though tkinter is installed as its a default module when python is installed. Any help is much appreciated. Im working on python 3.7","AnswerCount":1,"Available Count":1,"Score":-0.3799489623,"is_accepted":false,"ViewCount":9913,"Q_Id":53365915,"Users Score":-2,"Answer":"Make sure your default python , the one that the terminal calls has tkinter installed. \nSo run 'python --version' in the terminal and if that yields 3.7 then your default python is 3.7. \nNow try to import tkinter using that same python version. \nopen the terminal and run python then run import tkinter as tk\nIf that does not yield an error saying that the module was not found then most probably you are running the executable with the wrong permissions.","Q_Score":3,"Tags":"python-3.x,macos,tkinter,module,terminal","A_Id":53365973,"CreationDate":"2018-11-18T22:04:00.000","Title":"ImportError: No module named tkinter. Mac OS Terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"why we use str() method in \"str(number)\" format to convert a number to a string why not to use \"number.str()\" format, what is the difference between the both, what is difference between methods and attributes","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":53368094,"Users Score":0,"Answer":"In Python, there is a standard method obj.__str__() that is called when you try to convert an object to a string. When you call str(number) what it really does is calling the underlying __str__ method on the number obj.\n__str__ is a magic method, and it is not a good practice to call them explicitly. Also using str(obj) is shorter than obj.__str__() and str(obj) is standard way of converting an object to string in python.\nRegarding number.str(), there is no such method in python basic number types at the moment, so cannot really elaborate on the differences","Q_Score":0,"Tags":"python,python-3.x","A_Id":53368299,"CreationDate":"2018-11-19T03:53:00.000","Title":"Why str(number) why not number.str() in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning Python for data science, but my problem is that I still don't understand the difference between Spyder and Jupyter!\nI would like you guys to help me to understand the difference, please; I would appreciate that.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68461,"Q_Id":53368253,"Users Score":53,"Answer":"Here's just a basic summary of the two tools.\nJupyter is a very popular application used for data analysis. It's an IPython notebook (\"interactive python\"). You can run each block of code separately. For example, I can print a graph using matplotlib. Create a new block of code and print another graph. There are also cool functions like %timeit that test the speed of your code.\nSpyder is an Integrated Development Environment (IDE) for Python like Atom, Visual Studio, etc. I use VS Code and I suggest you install it as well. It's easier to learn and get running. There's also tons of helpful youtube videos due to its popularity.\nI prefer to use Jupyter notebook to analyze data whether it be in pandas dataframes or plots. When I'm developing a program or implementing new code on data I already analyzed, I use a text editor like VS Code.\nThere's a lot more to it, but I think that's all you need to know for now. As you gain more experience you'll learn more about the tools and find your preferences. If you want to know more, there a ton of information about them online with people who can probably explain this much better than I can.\nI hope your journey into data science goes well! Just be patient and remember struggling is part of learning. Good luck!","Q_Score":35,"Tags":"python,data-science,jupyter,spyder","A_Id":53368463,"CreationDate":"2018-11-19T04:18:00.000","Title":"What is the difference between Spyder and Jupyter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making API server with python flask.\nIn my case, it is real production level, So I have to be careful when developing server.\nAfter google searching, found that celery&redis is suitable for task queueing.\nSo I installed celery&redis via pip3 install 'celery[redis]' and defined task, and run.\nEverything was fine, but I got some question about it.\nAssume that there is user model. Maybe CRUD for user model like this.\n\nRegister user(with photo)\nDelete user\nGet a single user\n\nIn my personal think, only Register user need to celery&redis.\nBecause upload photo can take long time, so it have to treated with asynchronize work.\nDelete user and Get a slngle user just query to db and retreive it.\nSo it doesn't takes longer time. (it means, do not need to work with celery)\nIt is right? Or, any missing feature I do not know?\nTo summarize my question, I want to know that is there any standard for celery?\nThanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":53369400,"Users Score":0,"Answer":"You have it about right.  You can put whatever processing you want in celery, but the rule that you just used--use celery for things that take a long time--is the one we use most in our production environment.  You can also use celery when you want to scale out an operation across servers more easily.  For example, when scraping a large number of pages, you might want to execute that in parallel to speed up what would otherwise be a long-running task.","Q_Score":0,"Tags":"python,flask,redis,celery","A_Id":53424766,"CreationDate":"2018-11-19T06:31:00.000","Title":"python celery for every work is efficient?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am seeing following issue:\nIn [5]: img = open_image(\"2018-09-21_005.hdr\")\nIn [6]: view_cube(img, bands=[29, 19, 9])\nModuleNotFoundError                       Traceback (most recent call last)\n\/Library\/Frameworks\/Python.framework\/Versions\/3.6\/lib\/python3.6\/site-packages\/spectral\/graphics\/hypercube.py in \n     69 try:\n---> 70     import wx\n     71     from wx import glcanvas\nModuleNotFoundError: No module named 'wx'\nDuring handling of the above exception, another exception occurred:\nImportError                               Traceback (most recent call last)\n in \n----> 1 view_cube(img, bands=[29, 19, 9])\n\/Library\/Frameworks\/Python.framework\/Versions\/3.6\/lib\/python3.6\/site-packages\/spectral\/graphics\/graphics.py in view_cube(data, *args, **kwargs)\n    176     to accept keyboard input.\n    177     '''\n--> 178     from spectral.graphics.hypercube import HypercubeWindow\n    179\n    180     if not running_ipython():\n\/Library\/Frameworks\/Python.framework\/Versions\/3.6\/lib\/python3.6\/site-packages\/spectral\/graphics\/hypercube.py in \n     71     from wx import glcanvas\n     72 except ImportError:\n---> 73     raise ImportError(\"Required dependency wx.glcanvas not present\")\n     74\n     75 DEFAULT_WIN_SIZE = (500, 500)           # Default dimensions of image frame\nImportError: Required dependency wx.glcanvas not present\nI used following command to install wx:  \"brew install wxpython\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":928,"Q_Id":53369484,"Users Score":0,"Answer":"The problem was related to installation of python package\nUse following command to install by pip :\npip install wxpython\nAnd Use following command to install by conda environment :\nconda install wxpython","Q_Score":4,"Tags":"python,image,hypercube","A_Id":56294778,"CreationDate":"2018-11-19T06:38:00.000","Title":"Unable to use view_cube command due to issue with wx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I work with Anaconda 5.3.0 and Python 3.7.\nAn application was made and I want to create an executable file with Pyinstaller, the case is that I miss the following error:\n\nException: Cannot find existing PyQt5 plugin directories Paths\n  checked:\n  C:\/Miniconda3\/conda-bld\/qt_1535195524645\/_h_env\/Library\/plugins","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3148,"Q_Id":53370225,"Users Score":0,"Answer":"In the anaconda command prompt try pip install PyQt5. It solved the issue for me.","Q_Score":1,"Tags":"python,pyqt5,pyinstaller","A_Id":54295293,"CreationDate":"2018-11-19T07:39:00.000","Title":"Error with Pyinstaller & PyQt5 \"Cannot find existing PyQt5 plugin directories\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the problem that for a project I need to work with a framework (Python), that has a poor documentation. I know what it does since it is the back end of a running application. I also know that no framework is good if the documentation is bad and that I should prob. code it myself. But, I have a time constraint. Therefore my question is: Is there a cooking recipe on how to understand a poorly documented framework? \nWhat I tried until now is checking some functions and identify the organizational units in the framework but I am lacking a system to do it more effectively.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":34,"Q_Id":53370709,"Users Score":2,"Answer":"If I were you, with time constaraints, and bound to use a specific framework. I'll go in the following manner: \n\nList down the use cases I desire to implement using the framework \nIdentify the APIs provided by the framework that helps me implement the use cases\nPrototype the usecases based on the available documentation and reading\n\nThe prototyping is not implementing the entire use case, but to identify the building blocks around the case and implementing them. e.g., If my usecase is to fetch the Students, along with their courses, and if I were using Hibernate to implement, I would prototype the database accesss, validating how easily am I able to access the database using Hibernate, or how easily I am able to get the relational data by means of joining\/aggregation etc. \nThe prototyping will help me figure out the possible limitations\/bugs in the framework. If the limitations are more of show-stoppers, I will implement the supporting APIs myself; or I can take a call to scrap out the entire framework and write one for myself; whichever makes more sense.","Q_Score":0,"Tags":"python,oop,frameworks","A_Id":53370875,"CreationDate":"2018-11-19T08:19:00.000","Title":"How do I efficiently understand a framework with sparse documentation?","Data Science and Machine Learning":0,"Database and SQL":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":"Heron documentation says that it is possible to implement Tumbling windows based on counts. However, heronpy.api.bolt.window_bolt.TumblingWindowBolt has only WINDOW_DURATION_SECS field. How can I implement TumblingWindowBolt based on tuple counts?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":18,"Q_Id":53372849,"Users Score":0,"Answer":"It seems Python API hasn't implemented the feature yet. Java has the best feature support if it is an option to you.","Q_Score":0,"Tags":"python,heron","A_Id":53378717,"CreationDate":"2018-11-19T10:40:00.000","Title":"Heron TumblingWindowBolt based on count not seconds","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to count the amount of upper-case letters in a user entered sentence.\nWhen I search Google for a solution, I came across the command sum(1 for c in sentence if c.isupper())). \nI used it and it works but I also need to explain the code to my teacher. \nHow would I go about doing this?","AnswerCount":5,"Available Count":1,"Score":0.1586485043,"is_accepted":false,"ViewCount":471,"Q_Id":53376146,"Users Score":4,"Answer":"So for each \"c in sentence\" (i.e., step through each letter in sentence, making each equal to c for the duration of the loop), substitute in a 1, (\"1 for c in sentence\"), but only if \"c\" (the current character) is an uppercase character (\"if c.isupper()\").  \nThen, sum (add together) the total number of 1's that were produced (one for each upper case character in the sentence), resulting in the total count of upper case characters.","Q_Score":2,"Tags":"python,string,python-3.x,command","A_Id":53376238,"CreationDate":"2018-11-19T13:54:00.000","Title":"What does sum(1 for c in sentence if c.isupper())) mean in non programming terms","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a neural network to output a probabilistic distribution over set of whole action space. \nMy action space is a vector of 3 individual actions : [a,b,c] \na can have 3 possible actions within itself a1,a2,a3 and similarly b has b1,b2,b3, c has c1,c2,c3. So In total i can have 27 different combinations of these actions 3^3 = 27. Ultimately the neural network should output 27 combinations of these actions (which is a matrix of 27 x 3) : [[a1,b1,c1],[a2,b2,c2],[a3,b3,c3],[a1,b1,c2],[a1,b1,c3],.....] and so on for all 27 combinations. Just to mention the input to my network is a state which is a vector of 5 elements. \nI want a probability associated to each of these 27 combinations. \nI know I can associate probability by using  a softmax with 27 outputs but I don't understand how the network can output a matrix in this case where every row has a probability associated to it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":53378284,"Users Score":0,"Answer":"Is there any reason you want it to return a matrix of these actions? Why not just map each of the 27 combinations to integers 0-26? So your architecture could look like [Linear(5, n), ReLU, Linear(n, .) ... Softmax(Linear(., 27))]. Then when you need to evaluate, you can just map it back to the action sequence. This is similar to how in NLP tasks you map multidimensional word vectors to integers via stoi for training and bring them back via itos.\nI should point out that if your training paradigm involves some further use of these discrete choices (say you use the argmax of this upstream of another net), then the nondifferentiability of argmax means that this architechture will not learn anything. I only mention this because you use the phrase \"action space\", which is typical in DRL. If this is the case, you may want to consider algorithms like REINFORCE where action sequences can be learned discretely and used upstream via policy gradient.","Q_Score":0,"Tags":"python,tensorflow,neural-network,probability,reinforcement-learning","A_Id":53378514,"CreationDate":"2018-11-19T15:52:00.000","Title":"Return distribution over set of action space from Neural Network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a Python script to monitor the status of a certain websites and report if any error via email notification.\nI am able to test the http status of the websites and websphere console urls.\nSince the admin (console) is on DMGR , my code is able to check the status of only DMGR but not the nodes inside the DMGR ,whenever few env is down .. only node goes down. I need a way to monitor the node's status as well.\nAny help would be appreciated.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":53378777,"Users Score":0,"Answer":"You application will be deployed to the JVMs on the nodes. \nIs your application configured to be accessible via the Node hostname [check virtualHost config]?\nif yes - thats the url, you need to check.","Q_Score":0,"Tags":"python-3.x,websphere,monitor,email-notifications","A_Id":53408409,"CreationDate":"2018-11-19T16:20:00.000","Title":"Websphere -check the status of nodes from a browser for automation purpose | Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to compress a set of strings in Python and get details, stats, and all the data from the compression to analyze it later (like the substring that appeared more times, the ones that were more useful for the compression, etc).\nRight now I am using zlib because it comes with Python - and I didn't found anything in the documentation, but I could change the compression method if I get enough data.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":88,"Q_Id":53379238,"Users Score":1,"Answer":"I am not aware of any compressor that collects such information. The search for matching strings, for example, is handled opportunistically, and there is no tracking of the same strings showing up more than once.","Q_Score":0,"Tags":"python,statistics,zip,compression,zlib","A_Id":53385239,"CreationDate":"2018-11-19T16:49:00.000","Title":"Compress string in Python and get details, stats, 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I am trying to install speechrecogntion python module on Pepper by using the below command.\npip install SpeechRecognition \nI am getting the below error. \nAny idea how I can fix this issue?\nCould not install packages due to an EnvironmentError: [Errno 30] Read-only file system: '\/usr\/lib\/python2.7\/site-packages\/SpeechRecognition-3.8.1.dist-info'\nThank you!!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":53379484,"Users Score":0,"Answer":"Yes. You are right , just to add you don\u2019t need to use path as only pip install - - user packagename will work. Thank you very much","Q_Score":0,"Tags":"python,nao-robot,pepper","A_Id":53392490,"CreationDate":"2018-11-19T17:04:00.000","Title":"Am not able to install SpeechRecognition module on Pepper","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a google sheet with a filter\/query that only shows the data that verifies the filter's conditions. To retrieve the data for python I use gspread, but hiddenrows are appearing too (as if there was no filter at all).\nHow can I differentiate the rows selected from the ones who weren't?\nI don't understand if this can work without adding more functions to gspread, or if I need to create a new function. If so, what should the function be?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":370,"Q_Id":53379784,"Users Score":2,"Answer":"I found that function fetch_sheet_metadata() which is inside class spreadsheet of gspread gives out the filters and hiddenValues for each filter, which is enough to solve my problem.","Q_Score":1,"Tags":"python,google-sheets-api,gspread,google-sheets-query","A_Id":53410194,"CreationDate":"2018-11-19T17:26:00.000","Title":"gspread: Retrieve Filtered Data from GoogleSheets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to make asynchronous calls to a stored procedure in VoltDB (an insert in a custom Java Stored procedure) using the Python client?\nIt looks like it isn't supported but is there a way to not wait for the response, or will I have to move to the Java client for async support?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":233,"Q_Id":53381017,"Users Score":0,"Answer":"The VoltDB python client does not support asynchronous calls. It may be possible to make calls from a multi-threaded python application, but we've never tested that, so I don't want to lead you into uncharted waters.\nThe java, C++, and Go clients support asynchronous calls.\nIf you're mainly trying to do fast inserts, you might leverage csvloader and you could probably execute csvloader from within a python application, but that's probably not what you're looking to do.\nDisclosure: I work at VoltDB.","Q_Score":0,"Tags":"python,asynchronous,voltdb","A_Id":53382230,"CreationDate":"2018-11-19T18:59:00.000","Title":"Is it possible to make asynchronous stored procedure calls to VoltDB using the Python client","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"After going through quite a pain getting my python setup.py to work with setuptools and the dedicated microsoft VC (Microsoft Visual C++ Compiler Package for Python 2.7) and succesfully compiling my extension on windows 10 it turns out the Maya 2017 included python executable (mayapy) is compiled with a different version, see below.\nc:>python\nPython 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on win32\nc:>\"Program Files\\Autodesk\\Maya2017\\bin\\mayapy.exe\"\nPython 2.7.11 (default, Dec 21 2015, 22:48:54) [MSC v.1700 64 bit (AMD64)] on win32\nI have Visual Studio 12 installed as well and that seems to be the right compiler version.\nBut how can I tell setuptools to use that version?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":338,"Q_Id":53382295,"Users Score":0,"Answer":"The quick and dirty way is to use to compile the required DLL on the command line using the Command Prompt for the VS2012 x64 Native Tools. The version that matches the mayapy.exe in Maya 2017.\nTo compile your c code use cl. You may need to point to the Python 2.7 include files using \/I.\n\ncl \/DL \/I ..\\include \/I C:\\Python27\\include \n\nBecause the linker might have trouble finding the 'python27.lib' you can link manually as well using \/LIBPATH to point to the Python 2.7 libs directory.\n\nlink \/DLL \/LIBPATH:C:\\Python27\\libs *.obj\n\nThis will give you a DLL and intermediate files matching the compiler for mayapy.exe.\nThe dirty part.\nBuild the extension using python setup.py build. This will give you a module that will import in the regular python interpreter. Remove the 'lib*' directory in the 'build' folder. Copy the '.obj', '.exp' and the dll to the temp folder in your build folder, something like 'temp.win-amd64-2.7\\Release\\\\src'.\nThen run python setup.py build again.\nDirty yes, Quick, once you know what to do...","Q_Score":0,"Tags":"python,c,windows,maya","A_Id":53439019,"CreationDate":"2018-11-19T20:39:00.000","Title":"How can I compile python c extension for the Window 10 Maya 2017 python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the google cloud platform app engine to have a main python file serve up a website using flask and a route in that file that will call a python function that is kept in a secondary python file. Whenever I try to call the function via the website I get a module error. Is there any way for me to upload this file alongside main.py so that I can call functions in it without just copying the file to main.py. Also I checked in each bucket and could not see any of my files in any of them but is there a bucket I should upload it to.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":53384553,"Users Score":0,"Answer":"As I understand, you are calling from the main.py file in an App Engine application to a function developed by you in a secondary file. If you want that, is as simple as adding the file in the same folder of your main.py and then you have to deploy your application. Then, all the files of the folder will be uploaded to your App Engine application.","Q_Score":1,"Tags":"python,python-3.x,google-cloud-platform","A_Id":53391185,"CreationDate":"2018-11-20T00:28:00.000","Title":"How do I upload a secondary python file to google cloud platform?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I pass float number as string format in int('.0')\n0.0 is valid floating point number, so why it is giving error?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":287,"Q_Id":53385136,"Users Score":2,"Answer":"Because you can type cast one step at a time. For example you can convert float to int or string to int. Not a floating point string which here is 2steps.","Q_Score":0,"Tags":"python,floating-point,type-conversion,int,valueerror","A_Id":53385175,"CreationDate":"2018-11-20T01:53:00.000","Title":"Why does int('.0') give ValueError?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am searching for a long time on net. But no use. Please help or try to give me some ideas how to achieve this.\nWhen I use python module concurrent.futures.ThreadPoolExecutor(max_workers=None), I want to know the max_workers how much the number of suitable.\nI've read the official document.\nI still don't know the number of suitable when I coding.\n\nChanged in version 3.5: If max_worker is None or not give, it will default to the number of processors on the machine, multiplied by 5, assuming that ThreadPoolExecutor is often used to overlap I\/O instead of CPU work and the number of workers should be higher than the number of workers for ProcessPoolExecutor.\n\nHow to understand \"max_workers\" better? \nFor the first time to ask questions, thank you very much.","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":9046,"Q_Id":53385479,"Users Score":5,"Answer":"max_worker, you can take it as threads number.\nIf you want to make the best of CPUs, you should keep it running (instead of sleeping).\nIdeally if you set it to None, there will be ( CPU number * 5) threads at most. On average, each CPU has 5 thread to schedule. Then if one of them falls into sleep, another thread will be scheduled.","Q_Score":2,"Tags":"python,threadpoolexecutor","A_Id":53385557,"CreationDate":"2018-11-20T02:45:00.000","Title":"Python concurrent.futures.ThreadPoolExecutor max_workers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using dask I have defined a long pipeline of computations; at some point given constraints in apis and version I need to compute some small result (not lazy) and feed it in the lazy operations. My problem is that at this point the whole computation graph will be executed so that I can produce an intermediate results. Is there a way to not loose the work done at this point and have to recompute everything from scratch when in a following step I am storing the final results to disk?\nIs using persist supposed to help with that?\nAny help will be very appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":53392067,"Users Score":0,"Answer":"Yes, this is the usecase that persist is for. The trick is figuring out where to apply it - this decision is usually influenced by:\n\nThe size of your intermediate results. These will be kept in memory until all references to them are deleted (e.g. foo in foo = intermediate.persist()).\nThe shape of your graph. It's better to persist only components that would need to be recomputed, to minimize the memory impact of the persisted values. You can use .visualize() to look at the graph.\nThe time it takes to compute the tasks. If the tasks are quick to compute, then it may be more beneficial just to recompute them rather than keep them around in memory.","Q_Score":1,"Tags":"python,dask,dask-distributed","A_Id":53711345,"CreationDate":"2018-11-20T11:30:00.000","Title":"Dask how to avoid recomputing things","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset with more than 20 columns. I want to find out which two variables contributes towards highest importance. How to do it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":635,"Q_Id":53396792,"Users Score":1,"Answer":"The brute force approach is to try all different 380 possibilities.\nThe non brute force approach could be try to do your clustering with 19 features (all 20 solutions) and keeping the best one, then dropping one more, selecting the best of the 19... up to two classes.","Q_Score":0,"Tags":"python-3.x,cluster-analysis,k-means","A_Id":53396837,"CreationDate":"2018-11-20T15:53:00.000","Title":"Feature selection in K means clustering","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Trying to install with pip install mysqlclient\nI am installing MysqlClient in Python virtualenv but installation failed with error\nIt requires MS Visual C++ 10.0\nI downloaded it, which again requires .NET Framework 4.\nI again downloaded .NET Framework 4, which is giving error that you cannot install .NET Framework 4 as higher version is already installed.\nI searched all over the internet there isn't any solution to this problem is available.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":53399716,"Users Score":0,"Answer":"After struggling approximately 24 hrs. I found a solution that will fix this ridiculous problem which has no solution on the whole internet.\nWhile Installing mysqlclient use the following command, and the latest mysqlclient will be installed without any problem.\npip install --only-binary :all: mysqlclient","Q_Score":1,"Tags":"python,mysql,django","A_Id":53412861,"CreationDate":"2018-11-20T18:54:00.000","Title":"Mysqlclient requires MS Visual C++ 10.0 which again requires .Net Framework 4","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What's the idiomatic way to setup Airflow so if you have two environments, such as Production-East and Production-West, only the dags from each of these environments show up but they can live in a single repository?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1565,"Q_Id":53400870,"Users Score":1,"Answer":"Have the files for each group put inside a subfolder and then set the dags_folder path to point to the appropriate subfolder for the server.","Q_Score":1,"Tags":"python,airflow","A_Id":53404164,"CreationDate":"2018-11-20T20:16:00.000","Title":"Set up Airflow for Multiple Environments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on a domain fronting project. Basically I'm trying to use the subprocess.call() function to interpret the following command:\nwget -O - https:\/\/fronteddomain.example --header 'Host: targetdomain.example'\nWith the proper domains, I know how to domain front, that is not the problem. Just need some help with writing using the python subprocess.call() function with wget.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":292,"Q_Id":53400968,"Users Score":1,"Answer":"I figured it out using curl: \ncall([\"curl\", \"-s\", \"-H\" \"Host: targetdomain.example\", \"-H\", \"Connection: close\", \"frontdomain.example\"])","Q_Score":0,"Tags":"python,subprocess,wget","A_Id":53402135,"CreationDate":"2018-11-20T20:23:00.000","Title":"wget with subprocess.call()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I made a pretty cool hangman game with a text document that has all the possible words. Also a python file that was just functions for my main file to use. I want to send this to a friend who doesn't use python nor have any python stuff installed on their computer. I don't think pyinstaller will work because it is multiple files. Is there a way that I can get it working on computers without python?\nEdit: I'm very new to all this stuff. Just a heads up","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":53402124,"Users Score":0,"Answer":"As far as I understand, python is an interpreter not a compiler. As such any python file has to be INTERPRETED by the INTERPRETER. Unlike java and C++ where you could compile the code to an output file that is executable on multiple platforms.","Q_Score":1,"Tags":"python-3.x,pyinstaller","A_Id":53402247,"CreationDate":"2018-11-20T21:51:00.000","Title":"Combing mutliple python functions and a text file into and something that could be run on any windows computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to run pdf2image on my Python Lambda Function in AWS, but it requires poppler and poppler-utils to be installed on the machine. \nI have tried to search in many different places how to do that but could not find anything or anyone that have done that using lambda functions.\nWould any of you know how to generate poppler binaries, put it on my Lambda package and tell Lambda to use that?\nThank you all.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6645,"Q_Id":53403399,"Users Score":0,"Answer":"Hi @Alex Albracht thanks for compiled easy instructions! They helped a lot. But I really struggled with getting the lambda function find the poppler path. So, I'll try to add that up with an effort to make it clear.\nThe binary files should go in a zip folder having structure as:\npoppler.zip -> bin\/poppler\nwhere poppler folder contains the binary files. This zip folder can be then uploaded as a layer in AWS lambda.\nFor pdf2image to work, it needs poppler path. This should be included in the lambda function in the format - \"\/opt\/bin\/poppler\".\nFor example,\npoppler_path = \"\/opt\/bin\/poppler\"\npages = convert_from_path(PDF_file, 500, poppler_path=poppler_path)","Q_Score":8,"Tags":"python,aws-lambda,poppler","A_Id":62793956,"CreationDate":"2018-11-20T23:58:00.000","Title":"How to install Poppler to be used on 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":"Just I am curious why I have to scale the testing set on the testing set, and not on the training set when I\u2019m training a model on, for example, CNN?!\nOr am I wrong? And I still have to scale it on the training set.\nAlso, can I train a dataset in the CNN that contents positive and negative elements as the first input of the network?\nAny answers with reference will be really appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":245,"Q_Id":53404679,"Users Score":0,"Answer":"We usually have 3 types of datasets for getting a model trained,\n\nTraining Dataset\nValidation Dataset\nTest Dataset\n\nTraining Dataset\nThis should be an evenly distributed data set which covers all varieties of data. If your train with more epochs, the model will get used to the training dataset and will only give proper proper prediction on the training dataset and this is called Overfitting. Only way to keep a check on overfitting is by having other datasets which the model has never been trained on.\nValidation Dataset\nThis can be used fine tune model hyperparameters\nTest Dataset\nThis is the dataset which the model has not been trained on has never been a part of deciding the hyperparameters and will give the reality of how the model is performing.","Q_Score":0,"Tags":"python,tensorflow,conv-neural-network","A_Id":53404984,"CreationDate":"2018-11-21T03:00:00.000","Title":"How do I train the Convolutional Neural Network with negative and positive elements as the input of the first layer?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just I am curious why I have to scale the testing set on the testing set, and not on the training set when I\u2019m training a model on, for example, CNN?!\nOr am I wrong? And I still have to scale it on the training set.\nAlso, can I train a dataset in the CNN that contents positive and negative elements as the first input of the network?\nAny answers with reference will be really appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":245,"Q_Id":53404679,"Users Score":0,"Answer":"Scaling data depends upon the requirement as well the feed\/data you got. Test data gets scaled with Test data only, because Test data don't have the Target variable (one less feature in Test data). If we scale our Training data with new Test data, our model will not be able to correlate with any target variable and thus fail to learn. So the key difference is the existence of Target variable.","Q_Score":0,"Tags":"python,tensorflow,conv-neural-network","A_Id":53404823,"CreationDate":"2018-11-21T03:00:00.000","Title":"How do I train the Convolutional Neural Network with negative and positive elements as the input of the first layer?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating a questionnaire on Qualtrics and I have 3 different blocks of questions. Let's call them A, B, and C. Each of the blocks has 100 questions each. I want to randomly pick 15 questions from each of the blocks. That part is easy. I have used Randomization options available for each block. \nHowever, I want to mix questions across these blocks. Currently, what I can get is \nA1 A2 ... A15   B1, B2, ... B15   C1, C2, ... C15\nAll the questions from one block appear together.\nI want to randomize this specific ordering as well. My requirements are:\n\n15 questions from each block selected randomly from a pool of 100 in each block.\nRandomly displaying this pool of 45 questions to the user. \n\nHow can I do this? I've been stuck at this for hours now. Thanks for your help in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":53404770,"Users Score":0,"Answer":"There isn't any easy way to do this.\nYou could put all 300 questions in the same block.  Then in a block before the 300 question block have 3 multiple choice questions (QA, QB, QC) where you have placeholders for the 100 questions as choices (QA: A1, A2, ..., A100; QB: B1, B2, ... , B100; QC: C1, C2, ..., C100).  For each of those questions used Advanced Randomization to randomly display 15 choices. Hide the questions with JavaScript. Then in your 300 question block add display logic to each question based on whether its corresponding choice was displayed in the applicable QA, QB, QC question.","Q_Score":0,"Tags":"python,machine-learning,deep-learning,qualtrics","A_Id":53413823,"CreationDate":"2018-11-21T03:13:00.000","Title":"Mixing questions between Qualtrics Blocks","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"It just keeps failing when I do sudo apt-get upgrade because it failed to upgrade some package that based on Python3. The error was: undefined symbol: XML_SetHashSalt. I'd been searching around for solutions but there is no such answer on StackOverflow.\nThen at the end, I found an answer on not very related question mention that the library path for libexpat.so.1 pointing to \/usr\/local\/lib\/ may cause the issue. So I try to rename libexpat.so.1 to libexpat.so.1-bk then it works.\nSo I just re-post it here, hope it helps for anyone facing it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1034,"Q_Id":53405066,"Users Score":0,"Answer":"It seems that you have broken your system.\nIf you are using apt, the \/usr\/local\/ should never be used.\nIf you are using \/usr\/local\/, do not use apt to manage your installation.","Q_Score":1,"Tags":"python-3.x","A_Id":53405117,"CreationDate":"2018-11-21T03:58:00.000","Title":"Apt-get error \"undefined symbol: xml_sethashsalt\" when install\/update python3","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 trying to find out ways to secure REST API communication. The following are the items considered.\n\nEnabled token based authentication using JWT\nEnabled HTTPS and restrict requests over HTTP\n\nOur GUI interacts with service layer APIs which are secured as described above. All the requests from GUI contains sensitive information and hence the data has to be secured at every place.\nIn short, our GUI is secured with role based authentication and APIs are secured as above. Still I feel the communication between GUI and services are not secure enough.\n\nIs the payload from GUI secure enough? or should the payload also be encrypted from GUI itself?\n\nIf this is not the right place to ask this question, I am happy to move it to right place. \nPlease advice!\nThank you in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3632,"Q_Id":53405327,"Users Score":1,"Answer":"What I understood from the post is that your GUI is secured role based and the api is secured using token and https.\nApart from these, as I understand you app is too sensitive, in that case I would do the following to add some extra layer of security.\n\nAdd a two step verfication for the GUI just to ensure that right person is logged in all time.\nEncrypt the data (i.e. the payload) may be using the public\/private key.In this case the server side needs to be changed a bit as it needs to decrypt the request .\nMake sure your token has a lifetime and expires after certain time.\n\nLet me know if you are looking for something else.","Q_Score":2,"Tags":"python,angularjs,rest,security,encryption","A_Id":53405466,"CreationDate":"2018-11-21T04:35:00.000","Title":"How to secure REST API payload while in transit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm just now reading into cython and I'm wondering if cython compiles imported modules as part of the executable of if you still need to have the modules installed on the target machine to run the cython binary.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":467,"Q_Id":53407590,"Users Score":2,"Answer":"The \"interface\" of a Cython module remains at the Python level. When you import a module in Cython, the module becomes available only at the Python level of the code and uses the regular Python import mechanism.\nSo:\n\nCython does not \"compile in\" the dependencies.\nYou need to install the dependencies on the target machine.\n\nFor \"Cython level\" code, including the question of \"cimporting\" module, Cython uses the equivalent of C headers (the .pxd declaration files) and dynamically loaded libraries to access external code. The .so files (for Linux, DLL for windows and dylib for mac) need to be present on the target machine.","Q_Score":3,"Tags":"python,cython","A_Id":53412544,"CreationDate":"2018-11-21T08:03:00.000","Title":"Does Cython compile imported modules as part of the binary?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script written up and the output of this script is a list. \nRight now I need to get it online and make it accessible to others. I looked at Django , but then I realized that it may be kind of hard to create the UI. Is there any simple way to create a UI in Django and map it to an existing Python script.\nRight now I using nltk, numpy, sqlite3 and things like that. Or is there a simpler way by which I can proceed?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":53412863,"Users Score":0,"Answer":"In your case, Django is redundant.\nYou can use something smaller, Flask or maybe Aiohttp.\nFor example, all you need in aiohttp:\nbasic hmtl template\nhandler for one url (here you will call your script)\naiohttp webserver  \nThe main idea:\nYour server catch some url (for example \/),\nstart your script, receives result,\nrespond with your html template (also render script result in it).","Q_Score":0,"Tags":"python","A_Id":53413477,"CreationDate":"2018-11-21T13:13:00.000","Title":"Publish a script online","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using python with clpex, when I finished my model I run the program and it throws me the following error:\nCplexSolverError: CPLEX Error 1016: Promotional version. Problem size limits exceeded.\nI have the IBM Academic CPLEX installed, how can I make python recognize this and not the promotional version?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1190,"Q_Id":53413153,"Users Score":1,"Answer":"you can go to the direction you install CPLEX. For Example, D:\\Cplex\nAfter that you will see a foler name cplex, then you click on that, --> python --> choose the version of your python ( Ex: 3.6 ), then choose the folder x64_win64, you will see another file name cplex. \nYou copy this file into your python site packakges ^^ and then you will not be restricted","Q_Score":0,"Tags":"python,cplex","A_Id":55095092,"CreationDate":"2018-11-21T13:30:00.000","Title":"CPLEX Error 1016: Promotional version , use academic version CPLEX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to work with ansible, winrm, virtualenv and Jenkins...\nCurrently, I have installed Ansible with Tom via epel-release. \nJenkins has only basic configuration for now.\nI have then created a virtualenv inside Jenkins home named $HOME\/ansible-winrm. Then inside it, I have installed winrm via pip.\nWhat I'm trying to do is :\n- create a simple job on Jenkins with only a shell script calling ansible-playbook. And it should access to the winrm library installed inside my local virtualenv.\n- It should be as transparent as possible.\nP.S. It seems that python binary is hard codded inside ansible-playbook script.\nWhat are your best practices to solve this issue ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":283,"Q_Id":53416729,"Users Score":0,"Answer":"Best way to do it is installing winrm with pip in user workspace (option --user)\nEx: pip install --user pywinrm","Q_Score":0,"Tags":"python,jenkins,ansible,winrm","A_Id":53433618,"CreationDate":"2018-11-21T16:38:00.000","Title":"Ansible winrm with virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"in below code .\ni didn't understand the meaning of workers parameter .\nmodel = Word2Vec(sentences, size=300000, window=2, min_count=5, workers=4)","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5032,"Q_Id":53417258,"Users Score":3,"Answer":"workers = use this many worker threads to train the model (=faster training with multicore machines).\nIf your system is having 2 cores, and if you specify workers=2, then data will be trained in two parallel ways.\nBy default , worker = 1 i.e,  no parallelization","Q_Score":0,"Tags":"python,machine-learning,nlp,word2vec","A_Id":53417517,"CreationDate":"2018-11-21T17:07:00.000","Title":"what is workers parameter in word2vec in NLP","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am just starting out on using the django framework. One thing that bugs me is the django-admin utility. Is it part of the python installation or is it part of the django installation through pip?\nThe way I've been doing my projects is\n\nMake a virtual Environment.\nCreate a django project in the environment through django-admin.\nand then I just install the django framework using pip inside the environment.\n\nMy question arises because inside the virtual environment, I used django-admin to create the project before installing the framework.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":164,"Q_Id":53420474,"Users Score":0,"Answer":"I have ran into something similar. Where in a virtual enviroment I create for python 3 used my global python 2 installation. Try creating a new virtual environment just like before, and this time try using \"python django-admin\" instead of just \"django-admin\". A question for you, is this a Windows environment, I ask because that is the only environment I have witnessed this behavior in. I believe by using \"python django-admin\" it will force it to use the virtualenv's sandboxed python.","Q_Score":1,"Tags":"python,django","A_Id":53420676,"CreationDate":"2018-11-21T21:06:00.000","Title":"Is django-admin part of python or django installation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python script which will run various other scripts when it sees various files have been updated. It rapidly polls the files to check for updates by looking at the file modified dates.\nFor the most part this has worked as expected. When one of my scripts updates a file, another script is triggered and the appropriate action(s) are taken. For reference I am using pickles as the file type. \nHowever, adding a new file and corresponding script into the mix just now, I've noticed an issue where the file has its modified date updated twice. Once when I perform the pickle.dump() and again when I exit the \"with\" statement (when the file closes). This means that the corresponding actions trigger twice rather than once. I guess this makes sense but what's confusing is this behaviour doesn't happen with any of my other files. \nI know a simple workaround would be to poll the files slightly less frequently since the gap between the file updates is extremely small. But I want to understand why this issue is occuring some times but not other times.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":53422501,"Users Score":0,"Answer":"If the pickle is big enough (typically somewhere around 4+ KB, though it will vary by OS\/file system), this would be expected behavior. The majority of the pickle would be written during the dump call as buffers filled and got written, but whatever fraction doesn't consume the full file buffer would be left in the buffer until the file is closed (which implicitly flushes any outstanding buffered data before closing the handle).\nI agree with the other answer that the usual solution is to write the file in a different folder (but on the same file system), then immediately after closing it, us os.replace to perform an atomic rename that moves it from the temporary location to the final location, so there is no gap between file open, file population, and file close; the file is either there in its entirety, or not at all.","Q_Score":0,"Tags":"python,pickle","A_Id":53422538,"CreationDate":"2018-11-22T00:57:00.000","Title":"File updates twice when dumping pickle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Environments\npc: mac os 10.13.1\nVersions\npython: 3.6.2\nmezzanine: 4.3.1\ndjango: 1.11.16\nbootstrap: 3.3.5  (confirmed in \/{my_name}\/anaconda3\/lib\/python3.6\/site-packages\/mezzanine\/core\/static\/css\/bootstrap.css)\n\nHere, my mezzanine project has base.html for site interface. There is the code to get the css-code(design). That is bootstrap.css.\nBut the bootstrap.css relies to bootstrap3(3.3.5), and I have to use bootstrap4(4.0.0). (This is my boss's order.)\nThen, I wanna get(download) bootstrap4, put it to right directory and change bootstrap dependency by linking to the directory which I put earlier.\nHow should I achieve it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":123,"Q_Id":53425743,"Users Score":0,"Answer":"This might break your things all the classes which are obsoleted will not work in newer version to get prevent this refactor all view files . Simple Solution is change the file in  static\/ and import the partials header or footer file linked","Q_Score":0,"Tags":"python,css,django,mezzanine","A_Id":53426109,"CreationDate":"2018-11-22T07:22:00.000","Title":"How do I upgrade bootstrap in my mezzanine's project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a question, how count word between phrases in text? For example, I have the next text:\n\nElon Musk is a technology entrepreneur and investor. He is the founder, CEO, and lead designer of SpaceX. Elon Musk has stated that the goals of SpaceX, Tesla, and SolarCity revolve around his vision to change the world and humanity.\n\nAnd I want to count how many words are between \"Elon Mask\" and \"SpaceX\". And return smth like a list with numbers and then find average word distance. For example, [15,6].\nI know, that in case of words, we can split text on words. But what to do with phrases?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":112,"Q_Id":53428546,"Users Score":1,"Answer":"You might split your text, based on points, exclamation marks and question marks, but how will your program know the difference of a point between phrases and a point, indicating an abbreviation? In top of that, how will you deal with brackets? Will they be considered as separate phrases or not?\nI don't think there's a straightforward answer to your question, unless you force some serious limitations on your phrases.","Q_Score":0,"Tags":"python,count,distance","A_Id":53428703,"CreationDate":"2018-11-22T10:12:00.000","Title":"Find distance between phrases in text","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a speaker recognition with a neural network using Keras and also the Fourier transformation to process the voice samples. The voice samples are me and my friend saying 'eeeee' for 3 seconds. Now the problem is if we give the neural network an input of someone else doing that ('ee' for 3 seconds), it still gives an output that indicates that it's  100% one of us. I output data using softmax so it gives about [1, 0] for my friend and [0, 1] for me. Sometimes it's like [0.95, 0.05]. \nIt's working well except for if we input the data from another person like I said, it still gives like [1,0] although I would expect it to give something like [0.6, 0.4] because it's another voice. Now I have also tried using 2 features of MFCC but it doesn't seem to work either. Would making a third output and train it with random samples work (I myself don't really think so because it can't train for all different inputs)? Or how can I try to face this issue otherwise? I've been struggling with this issue for quite a while now so any help would be much appreciated!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":53430205,"Users Score":0,"Answer":"A neural-net is - in essence - nothing more than a fancy feature-extractor and interpolator.\nThere is no reason to expect anything specific for data that it's never seen, and this doesn't have much to do with working with the DTFT, MFCC, or I-Vectors, it's a basic principle of data-driven algorithms.\nJust as a methodological explanation, not to be taken literally, finding a differentiation between two speakers going \"eeeeeeeee\" can be done by finding the  mean pitch and just deciding upon that one not-so-informative feature.\nThen what do you think would happen when introducing a new utterance?\nOne last point - there are so many ways to solve such a degenerate case, that you will most probably get some overfit. Which can also lead to unexpected results for out-of-sample data.  \n\nRegarding the general problem, there are a few different approaches, but I'd recommend having two stages:  \n\n1-Class SVM or something similar, to identify that the utterance is in the class you or your friend \nThe NN you trained.  \n\nAnother option would be to get enough \"general speaker\" samples and add them as a third class. This is known in some contexts as the OOS (out of sample) category for classification. That can get you some good googling material :-)","Q_Score":0,"Tags":"python,machine-learning,keras","A_Id":53430651,"CreationDate":"2018-11-22T11:40:00.000","Title":"How to process a voice input in Keras that is not one of the two speaker outputs?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a speaker recognition with a neural network using Keras and also the Fourier transformation to process the voice samples. The voice samples are me and my friend saying 'eeeee' for 3 seconds. Now the problem is if we give the neural network an input of someone else doing that ('ee' for 3 seconds), it still gives an output that indicates that it's  100% one of us. I output data using softmax so it gives about [1, 0] for my friend and [0, 1] for me. Sometimes it's like [0.95, 0.05]. \nIt's working well except for if we input the data from another person like I said, it still gives like [1,0] although I would expect it to give something like [0.6, 0.4] because it's another voice. Now I have also tried using 2 features of MFCC but it doesn't seem to work either. Would making a third output and train it with random samples work (I myself don't really think so because it can't train for all different inputs)? Or how can I try to face this issue otherwise? I've been struggling with this issue for quite a while now so any help would be much appreciated!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":53430205,"Users Score":0,"Answer":"It is not a simple matter. You need a lot more training examples and to do some tests.\nYou COULD try to train something to be you-and-your-friend vs all, but it won't be that easy and (again) you will need lots of examples.\nIt's very broad as a question, there are a few different approaches and i'm not sure Keras and neural networks are the correct answer for this specific task.","Q_Score":0,"Tags":"python,machine-learning,keras","A_Id":53430299,"CreationDate":"2018-11-22T11:40:00.000","Title":"How to process a voice input in Keras that is not one of the two speaker outputs?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use the AWS IoT basicPubSub.py script to test my AWS connection, but I keep getting this error. I have tried various fixes, but cannot resolve the problem. \nI have tried it using my MacBook and RPi and still have the same issue.\nssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":445,"Q_Id":53431396,"Users Score":0,"Answer":"I am not sure how I managed to fix this problem, I tried the following items to fix the problem:\nRe-created all the certificates\nRe-installated CLI using sudo\nInstalled ssl (sudo apt-get install -y libssl-dev)\nI going to do a fresh installation on my RPi and repeat the steps to understand how this was resolved and fixed.","Q_Score":0,"Tags":"python,python-3.x,amazon-web-services,ssl,ssl-certificate","A_Id":53579254,"CreationDate":"2018-11-22T12:47:00.000","Title":"SSL error - certificate verify failed - AWS IOT (basicPubSub.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":1},{"Question":"Actually rather than just code , I want to know all the topics I have to study for making a remember me key on my login page.\nIts a inbuilt django login page and i have a bit knowledge of sessions and cache but not enough for making a remember me key and havent user caching yet.\nIf you can supply me with a answer or a source , that will be helpful","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9246,"Q_Id":53431476,"Users Score":0,"Answer":"I have an idea which is by adding another filed like below:\nsecret_code = models.CharField(max_length=6)\nThe main idea behind using the secret_code filed is to recover your username & password in login page. \nAlso i have thinking about another idea which is by storing your MAC address or IP address automatically but this is not going to work if you had switched to login from another device.","Q_Score":4,"Tags":"python,django,caching,login,web-deployment","A_Id":61170810,"CreationDate":"2018-11-22T12:52:00.000","Title":"Django : How can I implement a remember me key on my login page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I try to add to combobox list of units with superscripts. One of these is cm^-1. How can I put it as text?\nself.cbUnit.addItems([\"unit 1\", \"unit 2\", \"cm-1\"])","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":83,"Q_Id":53435304,"Users Score":1,"Answer":"Found solution. \nself.cbUnit.addItems([\"unit 1\", \"unit 2\", \"cm\\u207B\\u00B9\"])","Q_Score":1,"Tags":"python,pyqt5","A_Id":53435768,"CreationDate":"2018-11-22T16:46:00.000","Title":"How to add superscript in PyQt5 combobox?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't know why, it's been some weeks, pip is slow like hell to retrieve a package (like 5 minutes per package).\nit hangs at \"Collecting [...]\"\nany idea ? \nI tried different versions of pip and of python \/ pypy, same problem.\nThere are other questions on that, but there are from 2013\/2014 which is pretty old and maybe not applicable (at least, I tried them with no result)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2482,"Q_Id":53435484,"Users Score":0,"Answer":"We had the same problem due to brocken dns-server.\nplease, try to check your dns-servers (via nslookup utility) and try to fix it (in our case we removed bad dns-servers).","Q_Score":2,"Tags":"python,pip","A_Id":63779981,"CreationDate":"2018-11-22T16:59:00.000","Title":"Python pip extremely slow to download (stuck at Colecting...)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been running into a trouble whereby Spyder IPython console is not producing Matplotlib figures as desired. I thought initially that there is something wrong in my code since jupyter notebook gives me the same wrong figures. However, when running the script in Spyder using external terminal the figures are produced as desired. Also, when I run the code in VSC the correct figures are displayed. \nSo the only option I am left with in Spyder is to use the external terminal to execute the code. However, it is quite a pain every time to run some codes and then manually close the terminal. \nI would like to know if there is a way to permanently attach the external terminal inside Spyder? I hate the IPython console when it comes to plotting matplotlib figures!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":453,"Q_Id":53437964,"Users Score":1,"Answer":"(Spyder maintainer here) Sorry but there's no way to dock an external Python terminal inside Spyder.","Q_Score":1,"Tags":"python,spyder","A_Id":53454211,"CreationDate":"2018-11-22T21:04:00.000","Title":"Attach external system terminal into Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a way to do the above within a coding class for students. The idea is to check in the background if the code the students created e.g.  returns the correct value or performs the correct routine.\nThat way I could make sure the code works and will be useful in the forthcoming cells. What would be the best way to do so and to give feedback\/hints as to what was done wrong?\nThis should of course be not visible to the students as they should figure out the answers themselves. Should I send the code to be validated by some other kernel? Is there an optimal way?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1655,"Q_Id":53443995,"Users Score":1,"Answer":"This should of course be not visible to the students as they should figure out the answers themselves.\n\nThis is usually the wrong tactic. You should provide a set of test cases that expect correct output that the student can run their test against. Recall that Test-Driven Development teaches that application code should only be written to satisfy existing unit tests. Since you're assigning the application code: you need to write the unit tests to be passed!","Q_Score":1,"Tags":"python,jupyter-notebook,jupyter","A_Id":53444219,"CreationDate":"2018-11-23T09:35:00.000","Title":"How can I validate python code in a Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a way to do the above within a coding class for students. The idea is to check in the background if the code the students created e.g.  returns the correct value or performs the correct routine.\nThat way I could make sure the code works and will be useful in the forthcoming cells. What would be the best way to do so and to give feedback\/hints as to what was done wrong?\nThis should of course be not visible to the students as they should figure out the answers themselves. Should I send the code to be validated by some other kernel? Is there an optimal way?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1655,"Q_Id":53443995,"Users Score":1,"Answer":"You could write tests for the tasks you hand out to your students. Depending on which ones fail proceed to print possible fixes.","Q_Score":1,"Tags":"python,jupyter-notebook,jupyter","A_Id":53444059,"CreationDate":"2018-11-23T09:35:00.000","Title":"How can I validate python code in a Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an issue which I am not sure where the root cause is:\nI use python cx_Oracle to connect to an Oracle DB.\ncursor.fetchall() returns me records in this format [(4352,)]\nI want to retrieve the '4352' so i proceed to do this: pk = cursor.fetchall()[0][0]\nHowever i get: IndexError: list index out of range\nI am not sure what I am doing wrong since when i manually create this return object on my python console as such: item = [(4352,)], I can retrieve the '4352' by calling item[0][0]\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1306,"Q_Id":53444838,"Users Score":0,"Answer":"Are you sure about the list returned by the fetchall() statement?\nIt looks like the resulting list is empty.","Q_Score":0,"Tags":"python-3.6,cx-oracle,index-error","A_Id":53451817,"CreationDate":"2018-11-23T10:22:00.000","Title":"cursor.fetchall() throws index out or range error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having problems running Django. I installed it with pip3 and then it says:\n\nThe script django-admin is installed in\n  '\/Library\/Frameworks\/Python.framework\/Versions\/3.5\/bin' which is not\n  on PATH.\n\nSo I tried to modify my PATH in the bash.profile like this:\n\nexport DJANGO=\/Library\/Frameworks\/Python.framework\/Versions\/3.5\/bin\n\nThis did not help so as I ran in terminal: \n\ndjango-admin.py startproject firstdjango\n\nit just says:\n\n-bash: django-admin.py: command not found\n\nI don't know what to do to make it work. Any ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2199,"Q_Id":53445932,"Users Score":0,"Answer":"create a Directory somewhere, lets name it \"Django\"\ncd to \"Django\" directory\ncreate virtualenv --> virtualenv django\nsource django\/bin\/activate\ninstall django --> pip3 install django\ncd to created 'django' directory\ndjango-admin startproject first_project\nEnjoy!","Q_Score":1,"Tags":"python,django,python-3.x","A_Id":53446560,"CreationDate":"2018-11-23T11:33:00.000","Title":"Django is installed but python3 does not find it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to connect to a remote Jupyter notebook using the VS Code Jupyter extension. \nUsing CMD + Shift + P -> Jupyter: Enter the URL of local\/remote Jupyter notebook brings up an input field, where I enter the address of the notebook. Afterwards an input field asking for the token is shown. When I enter the token and press Enter, nothing happens.\nI tried to connect using VS Code for MacOS and Linux Mint. Using a notebook hosted on localhost:8888 and well an notebook hosted on a different computer within my home network 192.168.0.11:8888. Both ways do not work.\nI can access the Jupyter notebooks via browser. \nWhen I start VS Code per command line with a Python environment, that has jupyter installed, I am also able to run a notebook (purely) within VS Code. If I do not start VS Code within a Python environment with jupyter installed, I am not able to run any notebooks (but this seems to be an know issue).\nHow do I solve this issue (connect to a remote notebook)?\nIs someone able to connect to a remote notebook? (If yes, how?)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2556,"Q_Id":53446584,"Users Score":0,"Answer":"Use following command:\njupyter notebook --ip=0.0.0.0 --port=8080 --allow-root","Q_Score":7,"Tags":"python,visual-studio-code,jupyter-notebook,jupyter","A_Id":62277710,"CreationDate":"2018-11-23T12:17:00.000","Title":"VS Code Jupyter Extension: Remote notebook not starting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are developing an application on Google Cloud that makes use of Cloud Functions in Python. We're looking at developing a generic helper library that many of our functions will import.\nThe problem with this is if the helper library is changed in any way, all our functions will need to be redeployed.\nI'm trying to find a way to host (for want of a better word) our helper library (for example in Google Cloud Storage), and somehow import it into the main.py files, such that any changes to the helper library can be made without having to redeploy the functions. Is this possible at all?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":53448833,"Users Score":3,"Answer":"This is not supported with the provided tools. You can only invoke code that was deployed with the function.  There is no \"dynamic\" loading of code over the internet.\nAlso, in my opinion, this is a pretty bad idea, because your functions could break in a very profound way if there's a problem during loading of the remote code, or you accidentally (or someone maliciously) push something wrong.  You're going to be better off getting all your code and libraries together at once, test it all at once, and deploy it all at once.\nYou're free to try to implement something yourself, but I strongly advise against it.","Q_Score":1,"Tags":"python,python-3.x,google-cloud-platform,google-cloud-functions","A_Id":53449175,"CreationDate":"2018-11-23T14:52:00.000","Title":"Is there a way to import a python helper library from a deployed Google Cloud Function, outside the function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Tkinter in python 2.7, and I noticed that sometimes the root window doesn't open until I start the mainloop method.\nI addition, in those cases, when close the window, the program is ending (the root.mainloop is the last line in the code), and in the other cases it's not happening.\nWhy is it happening?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":541,"Q_Id":53452075,"Users Score":4,"Answer":"The short answer is that it's happening because that is how it was designed to happen.\nNothing happens in tkinter except through the event loop. Even something as simple as the window appearing is the event loop responding to an event. For example, when you create the window (and assuming you don't withdraw it), a \"redraw yourself\" event in effect gets added to the event queue. When you start the event loop, that's one of the first events it processes and the window appears.\nWhen you call mainloop(), that causes the event loop to start processing events. It is designed to start processing events and not return until the root window has been destroyed. That is why the call to mainloop is typically the last line of code in the file, since there's usually nothing else to do once the user has closed the window.\nThe other way to process events is to call update or update_idletasks. update will start the event loop, and return once all pending events have been processed (ie: it doesn't wait for the window to be destroyed). update_idletasks is similar, but only updates \"idle\" events: things scheduled with after, events related to redrawing windows, and a few others. It doesn't process user-generated events like mouse and button clicks.","Q_Score":1,"Tags":"python,tkinter","A_Id":53452166,"CreationDate":"2018-11-23T19:30:00.000","Title":"Why doesn't Tkinter.Tk() open the window right away?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script with several functions and would like to run different iloc and loc commands to test different things. Since I'm new to PyCharm, I'm not familiar with its different functionalities. How can I run single commands without having to run the whole Python script?\nI assume it has to be directly in the Python console. I tried, but it doesn't work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9677,"Q_Id":53452185,"Users Score":24,"Answer":"PyCharm has an Execute Line in Console command, the shortcut for which is ALT + SHIFT + E. This will run the selected lines in the Python Console if you have it configured properly.","Q_Score":12,"Tags":"python,pycharm","A_Id":53452229,"CreationDate":"2018-11-23T19:41:00.000","Title":"How do I run commands in PyCharm without having to run the whole script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've an application running quite a long time ago with python 2.6.6 and Django 1.4.5. It' s running on apache2 and Debian (of course it uses virtualenv).\nI' d like to add another application to that server, but with python 3.4.5 and Django 1.9(+).\nThey'd have of course a different virtualenvironment, even a different domain, however, I' d like them to use the same DB.\nMy question would what kind of complications will I face? For instance different table layout for Django tables, no south anymore, but migrate, etc. Are these problems even overcomeable?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":53452342,"Users Score":0,"Answer":"WLOG, assume application #1 is the python 2.6.6 + django 1.4 app\n      assume application #2 is the python 3.4 + django 1.9 app\nThese problems are 100% overcomeable, it just that application #2 (the one with python 3.4.5) will have to treat application #1's database as unmanaged.  You can create the unmanaged models you'd need from application #1's database by using the inspectdb command.  Good luck!","Q_Score":0,"Tags":"django,python-3.x,python-2.7,virtualenv","A_Id":53455874,"CreationDate":"2018-11-23T19:59:00.000","Title":"Django and python - different versions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to add a real-time chart to my Flask webapp. This chart, other than current updated data, should contain historical data too.\nAt the moment i can create the chart and i can make it real time but i have no idea how to make the data 'persistent', so i can't see what the chart looked like days or weeks ago.\nI'm using a Javascript charting library, while Data is being sent from my Flask script, but what it's not really clear is how i can \"store\" my data on Javascript. At the moment, indeed, the chart will reset each time the page is loaded.\nHow would it be possible to accomplish that? Is there an example for it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":53453643,"Users Score":0,"Answer":"You can try to store the data in a database and or in a file and extract from there .\nYou can also try to use dash or you can make on the right side a menu with dates like 21 september and see the chart from that day .\nFor dash you can look on YouTube at Sentdex","Q_Score":0,"Tags":"javascript,python,flask","A_Id":53487472,"CreationDate":"2018-11-23T22:49:00.000","Title":"How can i create a persistent data chart with Flask and Javascript?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Situation\nI wrote a simple program in python. It's a simple socket chatting program. In my program, the client just connect to an address (ip, port) and send a message, while at this time the server is ready and receives the message and prints it. I can assure the program is correct, since I tried on my computer.\nI have a VM instance on Google Cloud Platform, which I can operate through ssh, a simple way provided by google cloud. I can make sure the server is working.\nProblem\nI start a simple tcp server, python program on my google cloud server. Then I start my client program on my computer. But I get this error:\n\nConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it\n\nor equivalently in Chinese:\n\nConnectionRefusedError: [WinError 10061] \u7531\u4e8e\u76ee\u6807\u8ba1\u7b97\u673a\u79ef\u6781\u62d2\u7edd\uff0c\u65e0\u6cd5\u8fde\u63a5\u3002\n\nHow do I solve this problem and connect to my google cloud server?\nI guess maybe the firewall refused my computer's connection, but have no idea how to solve it.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3164,"Q_Id":53454732,"Users Score":4,"Answer":"This error means that your program is not listening on 0.0.0.0 port XYZ.\nCheck to see if your program is instead listening on localhost. If it is change to 0.0.0.0 which means all available networks. localhost means do not listen on any network interfaces and only accept connections from inside the computer.\nThen double check the port number.\nTo see if you have something listening run this command (Linux): netstat -at\nLook for a line with your port XYZ.\nWhen you start your program, make sure that it does not error when creating the listener. If you are trying to use a port number below 1024, you will need to lauch the program with root privileges.","Q_Score":1,"Tags":"python,server,google-cloud-platform,google-compute-engine,firewall","A_Id":53455102,"CreationDate":"2018-11-24T02:40:00.000","Title":"Can't connect to my google cloud VM instance through tcp using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When i try to use tensorflow to train model, i get this error message. \nFile \"\/Users\/ABC\/anaconda3\/lib\/python3.6\/site-packages\/keras\/utils\/layer_utils.py\", line 7, in \n    from .conv_utils import convert_kernel\nImportError: cannot import name 'convert_kernel'\ni have already install Keras","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1678,"Q_Id":53456874,"Users Score":1,"Answer":"I got the same issue. The filename of my python code was \"tensorflow.py\". After I changed the name to \"test.py\". The issue was resolved.\nI guess there is already a \"tensorflow.py\" in the tensorflow package. If anyone uses the same name, it may lead to the conflict.\nIf your python code is also called \"tensorflow.py\", you can try to use other names and see if it helps.","Q_Score":0,"Tags":"python,tensorflow","A_Id":54192123,"CreationDate":"2018-11-24T09:33:00.000","Title":"ImportError: cannot import name 'convert_kernel'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python 3.7 installed and it's on my PATH. (Windows 10) \nWhen I login to Python from Command line it logs in to Python and I have access to all my libraries.\nWhen I use Pycharm however, each project generates its own Python.exe which requires installing all the required packages.\nIn the project interpretor, I can see the Python instances of different projects but not my actually installed Python 3.7.\nQuestion is: How can I direct my Pycharm project to my own installed Python with all packages installed?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":25,"Q_Id":53458454,"Users Score":1,"Answer":"That is, in fact, a good thing. You don't want to litter your system-wide python with libs from different projects.\nWhat you can do, though, is setup virtual environments to your specific needs. Go to your project settings and type venv in the search field. You will be presented with a screen where you can select which interpreter to use for this particular project.","Q_Score":0,"Tags":"python,pycharm","A_Id":53458475,"CreationDate":"2018-11-24T13:07:00.000","Title":"Pycharm does not locate my python installation and keeps generating its own python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Google Colaboratory Notebook for Data Analysis that I want to output as a HTML file as currently not everything loads within the Colab environment such as large Folium Heatmaps. Is it possible to export the notebook as a html file as opposed to the ipynb and py options?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":48870,"Q_Id":53460051,"Users Score":0,"Answer":"to continue with \"Method using only Google Colab\"\n\" %%shell jupyter nbconvert --to html \/PATH\/TO\/YOUR\/NOTEBOOKFILE.ipynb\" - as given\nthe following worked for me - type the following in Google Colab\n!pip install nbconvert\n%shell jupyter nbconvert --to html \/content\/testfile.ipynb\n(instead of using %%shell in Google Colab, use %shell - this way, it worked for me)","Q_Score":37,"Tags":"python,jupyter-notebook,google-colaboratory","A_Id":70950691,"CreationDate":"2018-11-24T16:17:00.000","Title":"Convert ipynb notebook to HTML in Google Colab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Google Colaboratory Notebook for Data Analysis that I want to output as a HTML file as currently not everything loads within the Colab environment such as large Folium Heatmaps. Is it possible to export the notebook as a html file as opposed to the ipynb and py options?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":48870,"Q_Id":53460051,"Users Score":1,"Answer":"Download your notebook and upload it back to the colab\nReplace PATH_TO_THE_NOTEBOOK_IN_COLAB in the below command to the location of the reuploaded notebook.\nUse this command to download the notebook as html => !jupyter nbconvert --to html PATH_TO_THE_NOTEBOOK_IN_COLAB.ipynb.","Q_Score":37,"Tags":"python,jupyter-notebook,google-colaboratory","A_Id":71351274,"CreationDate":"2018-11-24T16:17:00.000","Title":"Convert ipynb notebook to HTML in Google Colab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a custom anaconda environment which I am using to run a program which is dependent on files in another directory. How do I add these files to the environment like I would do with a system interpreter by adding the paths to PYTHONPATH variable in system variables?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":347,"Q_Id":53462504,"Users Score":2,"Answer":"I did not need to add the custom files to the virtual environment configuration. I was using the Pycharm Python editor and found a better workaround by adding the paths to the selected interpreter (which in this case was the interpreter for the virtual python environment that I was using).\n\nGo to File \u2014>Settings\u2014> Project: Project name\u2014>Project Interpreter\nNext to the project interpreter, click the little gear icon. \nClick on Show all. A window should pop-up.\nOn the right side of the window, there\u2019s a toolbar containing 5 options starting with the plus icon. \nClick on the last icon with the file symbol. Another window should open.\nHere click on the plus symbol on the top right toolbar. \nGo to the directory that you want to include to use in your code and click Ok to add them to the interpreter path. \nRepeat for any other directories or files that you may need to have. \n\nThis solution with Pycharm worked out pretty well for me since I only needed to reference those files on my computer for that particular project.","Q_Score":1,"Tags":"python-3.x,environment-variables,anaconda,python-import,pythonpath","A_Id":53951579,"CreationDate":"2018-11-24T21:27:00.000","Title":"Adding own files\/packages to a custom anaconda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a certain game I'm making, I think it would look a lot better if each letter came one by one, rather than all at once. What can I do to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":616,"Q_Id":53462742,"Users Score":0,"Answer":"First thought:\nYou could create an animation function:\nThis could be a loop that goes through each of the characters and displays them. The only real problem with this is the interrupt time in the main thread--pygame's--slowing down the rest of the game's logic.\nBetter allternative\nAn alternative would be rendering letters as though they were sprites and moving them on one by one--by setting their motion, this removes the delay.","Q_Score":0,"Tags":"python,pygame","A_Id":53462809,"CreationDate":"2018-11-24T22:01:00.000","Title":"How can I make text in pygame pan letter by letter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Propagation model: \nP = 10 * n * log10 (d\/do)\nP = path loss (dB)\nn = the path loss distance exponent\nd = distance (m)\ndo = reference distance (m)\nThe initial idea is to make the loss measurements 'P' with respect to a distance 'd', and to determine the value of 'n'\nmy question: is this implementation possible using multi-layer Perceptron?\nBut what could be my inputs and outputs? I thought of something like:\ninput: distance 'd'\noutput: Loss \"P\"\nBut I could not think of a solution to determine 'n' from these parameters\nthe idea is that it is something simple, only for study and later improved","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":53464452,"Users Score":0,"Answer":"I believe you need a data for the response (PL) and data for the independent variables in order to find n.\nyou can find n using that data in SPSS, excel, Matlab etc.\nGood luck.","Q_Score":1,"Tags":"python,networking,perceptron,propagation","A_Id":53636929,"CreationDate":"2018-11-25T03:39:00.000","Title":"propagation model using neural network (I am beginner)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to find all atoms of type A in a VASP POSCAR and then randomly add \"n\" atoms of type B in a sphere of radius (\"r\") centered at each site of type A atom using pymatgen and return each time a new POSCAR.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":165,"Q_Id":53464739,"Users Score":1,"Answer":"This isn't currently a pre-built transformation in pymatgen. You could script it yourself, by creating a new PeriodicSite, changing its position to a random vector using numpy, and appending it to the Structure.","Q_Score":0,"Tags":"python,numpy,pymatgen","A_Id":54369709,"CreationDate":"2018-11-25T04:51:00.000","Title":"add atoms randomly around an atom in vasp poscar using pymatgen","Data Science and Machine Learning":0,"Database and SQL":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":"(1064, \"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '')' at line 1\")\nI do not understand why \"')\" chucks an error\nI have tried substituting the values of the query in multiple different ways\nand they all route back to that.\nAny help would be greatly appreciated.\nquery in question:\nsql = \"INSERT INTO Teams VALUES (%s, %s)\"\ncursor.execute(sql, (self.varTeamID, self.varTeamName))\nalternate attempts chucking same error:\nsql = \"INSERT INTO Teams VALUES (\" + self.varTeamID + \", '\" + self.varTeamName + \"')\"\nPlease note that the query works and is added to the database however python thinks it is wrong crashing the program","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":161,"Q_Id":53464806,"Users Score":1,"Answer":"We found it, this statement was working fine, the error was actually in the next SQL statement just after this one.","Q_Score":0,"Tags":"python,mysql,python-3.x,kivy","A_Id":53474616,"CreationDate":"2018-11-25T05:05:00.000","Title":"SQL query is added to DB but thinks it is wrong crashing the python program","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"(1064, \"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '')' at line 1\")\nI do not understand why \"')\" chucks an error\nI have tried substituting the values of the query in multiple different ways\nand they all route back to that.\nAny help would be greatly appreciated.\nquery in question:\nsql = \"INSERT INTO Teams VALUES (%s, %s)\"\ncursor.execute(sql, (self.varTeamID, self.varTeamName))\nalternate attempts chucking same error:\nsql = \"INSERT INTO Teams VALUES (\" + self.varTeamID + \", '\" + self.varTeamName + \"')\"\nPlease note that the query works and is added to the database however python thinks it is wrong crashing the program","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":161,"Q_Id":53464806,"Users Score":0,"Answer":"These may be the reasons why your SQL query is not working:\n\nIf the Teams table has more than two columns in its schema, then you should rephrase your statement as follows: \nINSERT INTO Teams (col1_name, col2_name) VALUES (\"%s\", \"%s\");\nwhere col1_name and col2_name are the actual names of the columns, between single or double quotation marks if they contains spaces.\nYou should enclose the values between single or double quotation marks: \nINSERT INTO Teams VALUES (\"%s\", \"%s\");\nYou may need to end the query with a semicolon.","Q_Score":0,"Tags":"python,mysql,python-3.x,kivy","A_Id":53465131,"CreationDate":"2018-11-25T05:05:00.000","Title":"SQL query is added to DB but thinks it is wrong crashing the python program","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently testing an LSTM network. I print the loss of its prediction on a training example before back-propagation and after back-propagation. It would make sense that the after loss should always be less than the before loss because the network was just trained on that example. \nHowever, I am noticing that around the 100th training example, the network begins to give a more inaccurate prediction after back-propagation than before back-propagating on a training example. \nIs a network expected to always have the before loss be higher than the after loss? If so, are there any reasons this happens?\nTo be clear, for the first hundred examples, the network seems to be training correctly and doing just fine.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":53464933,"Users Score":0,"Answer":"Is your dataset shuffled? \nOtherwise it could be the case that it was predicting one class for the first 99 examples.\nIf not then LSTM can be tricky to train. Try changing hyper parameters and also I would recommend starting with SimpleRNN, GRU and then LSTM as sometimes a simple network might just do the trick.","Q_Score":0,"Tags":"python,machine-learning,neural-network,lstm,recurrent-neural-network","A_Id":53465899,"CreationDate":"2018-11-25T05:33:00.000","Title":"Is it Normal for a Neural Network Loss to Increase after being trained on an example?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I change the IO pub data rate limit on Google Colab? I want to upload a file from my drive but I keep getting this error message:\nIOPub data rate exceeded.\nThe notebook server will temporarily stop sending output\nto the client in order to avoid crashing it.\nTo change this limit, set the config variable\n--NotebookApp.iopub_data_rate_limit.\nCurrent values:\nNotebookApp.iopub_data_rate_limit=1000000.0 (bytes\/sec)\nNotebookApp.rate_limit_window=3.0 (secs)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":758,"Q_Id":53465075,"Users Score":0,"Answer":"Can you post a minimal repro notebook? Uploading a file shouldn't trigger that limit.","Q_Score":0,"Tags":"python-3.x,file-upload,google-colaboratory","A_Id":53534993,"CreationDate":"2018-11-25T06:05:00.000","Title":"Change IO pub data rate limit on Google Colab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"as you can tell I\u2019m fairly new to using Pyspark Python my RDD is set out as follows:\n(ID, First name, Last name, Address)\n(ID, First name, Last name, Address)\n(ID, First name, Last name, Address)\n(ID, First name, Last name, Address)\n(ID, First name, Last name, Address)\n Is there anyway I can count how many of these records I have stored within my RDD such as count all the IDs in the RDD. So that the output would tell me I have 5 of them. \nI have tried using RDD.count() but that just seems to return how many items I have in my dataset in total.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":458,"Q_Id":53468203,"Users Score":0,"Answer":"If you have RDD of tuples like RDD[(ID, First name, Last name, Address)] then you can perform below operation to do different types of counting.\n\nCount the total number of elements\/Rows in your RDD.\nrdd.count()\nCount Distinct IDs from your above RDD. Select the ID element and then do a distinct on top of it.\nrdd.map(lambda x : x[0]).distinct().count()\n\nHope it helps to do the different sort of counting.\nLet me know if you need any further help here.\nRegards,\nNeeraj","Q_Score":0,"Tags":"python,scala,pyspark","A_Id":53471694,"CreationDate":"2018-11-25T13:55:00.000","Title":"How do I count how many items are in a specific row in my RDD","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have string which is as below (aim is to get rid of non alphanum chars BETWEEN alpha num chars except at end of string)\nstring: This$#is% Matrix#  %!\nwhat i want: This is Matrix#  %!\nso I want to get rid of non alpha num only between, not at the end.\nI tried this regex code, str1 = re.sub(r'([^\\s\\w]|_)+', ' ', str1) but it gets rid of all non-alp including one at the end.\nHow do i solve this tricky problem","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":53468660,"Users Score":0,"Answer":"Hi I feel my question still hasnt been answered,as you can see in the output below, I only want the non alpha num between the 2 alpha chars to be replace by 1 space, the part after matrix, should be untouched as its not between alphanum chars. \nInout string This$#is% Matrix#(2 space here)  %!\nYour Output (stdout)\nThis is Matrix#(1 space here) %!\nExpected OutputDownload\nThis is Matrix#(2 space here)%!","Q_Score":0,"Tags":"python,regex","A_Id":53512003,"CreationDate":"2018-11-25T14:45:00.000","Title":"regex python non alpha num characters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a task queue, queue A, and a resource queue, queue B. At program start, there are a finite number of resources put in queue B. Tasks may execute if they're able to pull a resource from queue B, and once they're done executing they must put the resource back in queue B. \nUsing Celery, is there a way to pull from a different queue inside a task to accomplish this? Or does this need to be architected completely differently? \nAn alternative, albeit with potentially reduced concurrency, is pairing the task with a resource before it's put in the task queue, then polling the task for completion, and on completion freeing up that resource and putting it back in the task queue with a different task. Is this the standard solution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":53470909,"Users Score":0,"Answer":"The architecture I ended up deciding on accomplishes this with the help of the chain primitive in Celery, with no loss in concurrency. \nTo ensure that no two tasks are using the same resource concurrently, you can divide all tasks among the available resources before adding the tasks to the queue (so say you had 10 tasks, and 3 resources, simply assign 3 tasks to two of the resources, and 4 to the third resource). Then, for each resource, call the tasks with chain() which tells Celery to execute each of the tasks for that resource in series.","Q_Score":0,"Tags":"python,architecture,rabbitmq,celery,eventlet","A_Id":53529303,"CreationDate":"2018-11-25T19:06:00.000","Title":"How to pull from a different queue inside Celery task","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I created a web app with Flask where I'll be showing data, so I need charts for it.\nThe problem is that I don't really know how to do that, so I'm trying to find the best way to do that. I tried to use a Javascript charting library on my frontend and send the data to the chart using SocketIO, but the problem is that I need to send that data frequently and at a certain point I'll be having a lot of data, so sending each time a huge load of data through AJAX\/SocketIO would not be the best thing to do.\nTo solve this, I had this idea: could I generate the chart from my backend, instead of sending data to the frontend? I think it would be the better thing to do, since I won't have to send the data to the frontend each time and there won't be a need to generate a ton of data each time the page is loaded, since the chart will be processed on the frontend.\nSo would it be possible to generate a chart from my Flask code in Python and visualize it on my webpage? Is there a good library do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":139,"Q_Id":53471032,"Users Score":2,"Answer":"Try to use dash is a python library for web charts","Q_Score":1,"Tags":"python,flask,data-visualization","A_Id":53472495,"CreationDate":"2018-11-25T19:22:00.000","Title":"Adding charts to a Flask webapp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have connected zapier to a webhook I am listening too, which sends a JSON file into my s3 bucket. \nI have some python code that I want to execute when a new file is uploaded into the bucket, in real time over the file. \nWhat is the best way to 'listen' for the upload of this file into the s3 bucket?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":2916,"Q_Id":53471129,"Users Score":2,"Answer":"David here, from the Zapier Platform team. \nSeems like you've already found your answer, which is great. I just wanted to plug Zapier as an option (since you had mentioned you're already using it). Our S3 integration has a \"new file in bucket\" trigger, which you can combine with any other step (such as a Python Code step). Additionally, you could skip the middleman and structure your zap as:\n\nsome trigger\nAdd file to S3\nRun Python\n\nAnd not need to worry about webhooks at all.\n\u200bLet me know if you've got any other questions!","Q_Score":4,"Tags":"python,amazon-s3,webhooks,zapier","A_Id":53488253,"CreationDate":"2018-11-25T19:34:00.000","Title":"Best way to 'listen' to s3 bucket for new file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to python and machine-learning but I have started to grasp it. Using AWS text_detection is really cool but I am wondering whether it can detect languages other then English. I know AWS has a feature to recognize the dominant language in text files but is there recognition for image files? Any help is appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":480,"Q_Id":53471538,"Users Score":0,"Answer":"I am pretty sure it only recognizes English words that contain only letters from the English alphabet.\nFrom the docs:\n\nA\u00a0word\u00a0is one or more ISO basic Latin script characters that aren't separated by spaces.\u00a0DetectText\u00a0can detect up to 50 words in an image.","Q_Score":0,"Tags":"python,amazon-web-services,machine-learning,ocr","A_Id":53471608,"CreationDate":"2018-11-25T20:18:00.000","Title":"Can AWS text_detection() detect Chinese or other languages in an image?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I got this binary number 101111111111000\nI need to strip off the 8 most significant bits and have 11111000 at the end.\nI tried to make 101111111111000 << 8, but this results in 10111111111100000000000, it hasn't the same effect as >> which strips the lower bits. So how can this be done? The final result MUST BE binary type.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":406,"Q_Id":53472702,"Users Score":0,"Answer":"To achieve this for a number x with n digits, one can use this\nx&(2**(len(bin(x))-2-8)-1)\n-2 to strip 0b, -8 to strip leftmost\nSimply said it ands your number with just enough 1s that the 8 leftmost bits are set to 0.","Q_Score":1,"Tags":"python,binary","A_Id":53472900,"CreationDate":"2018-11-25T22:35:00.000","Title":"How to strip off left side of binary number in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"An anadrome is a proper sentence that when written in reverse constitutes a (possibly different) proper sentence up to a possible change of spacing. I have a file with 100 Million proper sentences and I would like to find all sub-sentences (divided by word boundaries) which are anadromes, by testing if their inverse is also in the file when ignoring internal spaces. My initial approach was to extract all sub-sentences and save them to a temporary file, create an in-memory set of their space-stripped inverses, and finally iterate over the temporary file and test if each line after space-stripping belongs to the set. This worked fine for smaller files but does not scale, as the set gets too large for memory. Other than replacing the in-memory set with an on-disk database, what could be done?\nEdit: I ended up using an sqlite database with index. on a smaller set of 5 Million sentences using a db instead of an in-memory set takes 2x the time. With the full set, this is the only method that I found could complete the computation.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":96,"Q_Id":53473485,"Users Score":1,"Answer":"For each proper sentence you could try inverting it, and find all proper possible subtences.\nThen for each inverted subsentence, you strip all the spaces.\nYou then do a regex-search in the original file, searching for using the space-stripped inverted-subsentence allowing for \\s? in between characters.\nFor example d\\s?l\\s?r\\s?o\\s?w\\s?o\\s?l\\s?l\\s?e\\s?h (inverted 'hello world') would match 'wlro woll eh' (inverted 'hello world' with crazy spacing, which would be in the original file if it were a proper sentence)","Q_Score":0,"Tags":"python","A_Id":53474203,"CreationDate":"2018-11-26T00:45:00.000","Title":"Efficient extraction of anadromes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am to list all the files and directories in a directory with os.listdir and tell them apart reliably. Is it ok to use just os.path.isdir and consider it's a file if it returns false or should I check os.path.isfile anyway? Are there cases when os.path.exists(path) and os.path.isdir(path) == os.path.isfile(path) happens to be true?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":765,"Q_Id":53474489,"Users Score":1,"Answer":"os.path.isdir and os.path.isfile both are ok!  os.path.exists(path) and os.path.isdir(path) == os.path.isfile(path) is always False","Q_Score":0,"Tags":"python,os.path","A_Id":53474619,"CreationDate":"2018-11-26T03:36:00.000","Title":"Is os.path.isfile always the opposite of os.path.isdir for an existing file system object?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using the Eclipse 4.9.0 with pydev installed on it. The pydev version is 7.0.3.201811082356\nIf I create a package called a.b.c in the Python project then Eclipse displays it hierarchically in the project explorer window. To see the Python modules under a.b.c you need to expand a, b, and then C. What I would like to see is flattened version i.e. a.b.c so I just click once to expand it and see all the modules under it. If any of you have developed Java in Eclipse you would know what I am talking about. In Java if you create a package called a.b.c then Eclipse will show it as a.b.c so you just expand it once to see all the classes under package a.b.c.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":53474657,"Users Score":0,"Answer":"I know what you're talking about, unfortunately, this feature is not available in the PyDev package explorer (I think only JDT actually has that feature).\nSo, unfortunately, right now, you have to expand the actual folders to see your structure (there's no flattened version available).","Q_Score":0,"Tags":"python,eclipse,pydev","A_Id":53484821,"CreationDate":"2018-11-26T04:06:00.000","Title":"How to flatten the packages in Eclipse with pydev?","Data 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 clear a printed line, but so far I have found no good answers for using python 3.7, IDLE on windows 10. I am trying to make a simple code that prints a changing variable. But I don't want tons of new lines being printed. I want to try and get it all on one line.\nIs it possible to print a variable that has been updated later on in the code?\nDo remember I am doing this in IDLE, not kali or something like that.\nThanks for all your help in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":440,"Q_Id":53475654,"Users Score":1,"Answer":"The Python language definition defines when bytes will be sent to a file, such as sys.stdout, the default file for print.  It does not define what the connected device does with the bytes.\nWhen running code from IDLE, sys.stdout is initially connected to IDLE's Shell window.  Shell is not a terminal and does not interpret terminal control codes other than '\\n'.  The reasons are a) IDLE is aimed at program development, by programmers, rather than program running by users, and developers sometimes need to see all the output from a program; and b) IDLE is cross-platform, while terminal behaviors are various, depending on the system, settings, and current modes (such as insert versus overwrite).\nHowever, I am planning to add an option to run code in an IDLE editor with sys.stdout directed to the local system terminal\/console.","Q_Score":3,"Tags":"python-3.x,python-idle","A_Id":53485761,"CreationDate":"2018-11-26T06:17:00.000","Title":"how do I clear a printed line and replace it with updated variable IDLE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just built Tensorflow r1.12 from source in Ubuntu 16.04. The installation is successful.\nWhen I run a certain script in Spyder at the 1st time, everything flows smoothly.\nHowever, when I continue to run another script, following errors occur (which didn't happen previously):\n\nFile \"\/home\/haohua\/tf_env\/lib\/python3.6\/site-packages\/tensorflow\/init.py\", line 24, in \n      from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import\nFile \"\/home\/haohua\/tf_env\/lib\/python3.6\/site-packages\/tensorflow\/python\/init.py\", line 70, in \n      from tensorflow.python.framework.framework_lib import *  # pylint: disable=redefined-builtin\nFile \"\/home\/haohua\/tf_env\/lib\/python3.6\/site-packages\/tensorflow\/python\/framework\/framework_lib.py\", line 30, in \n      from tensorflow.python.framework.sparse_tensor import SparseTensor\nFile \"\/home\/haohua\/tf_env\/lib\/python3.6\/site-packages\/tensorflow\/python\/framework\/sparse_tensor.py\", line 248, in \n      pywrap_tensorflow.RegisterType(\"SparseTensorValue\", SparseTensorValue)\nTypeError: Type already registered for SparseTensorValue \n\nThe temporary solution to avoid such TypeError is to restart the kernel.\nBut I don't want to restart kernel at every single step of running a script.\nThus, I would like to ask for a critical solution for such kind of issue. Thank you in advance.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2669,"Q_Id":53477005,"Users Score":2,"Answer":"(Spyder maintainer here) This error was fixed in Spyder 3.3.3, released on February\/2019.","Q_Score":1,"Tags":"python-3.x,tensorflow,spyder","A_Id":54864247,"CreationDate":"2018-11-26T08:15:00.000","Title":"Tensorflow r1.12: TypeError: Type already registered for SparseTensorValue when running a 2nd script","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to understand the working of udf in pyspark. Does a python shell opens up everytime we use a udf on top of a dataframe?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1525,"Q_Id":53477475,"Users Score":3,"Answer":"UDF can be given to PySpark in 2 ways.\n\nUDF can be defined in Scala and run using PySpark\nUDF can be defined in Python and run by PySpark\n\nIn first case UDF will run as part of Executor JVM itself, since UDF itself is defined in Scala. There is no need to create python process.\nIn second case for each executor a python process will be started. data will be serialised and deserialised between executor and python to process. This leads to lots of performance impact and overhead on spark job.\nusually it is preferred to use Scala based UDF, since they will give you better performance.\nin spark 2.x There is something called Pandas Udf(vectorised UDF). They are implemented using Pandas(Converting Dataframe using apache arrow). Basically you write code in python but that code is converted and run using pandas. which drastically improves performance of UDF in python.\nI hope this helps.","Q_Score":1,"Tags":"python,apache-spark,pyspark,user-defined-functions","A_Id":53482133,"CreationDate":"2018-11-26T08:50:00.000","Title":"How does udf (user defined function) work in pyspark?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to understand the working of udf in pyspark. Does a python shell opens up everytime we use a udf on top of a dataframe?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1525,"Q_Id":53477475,"Users Score":2,"Answer":"Spark runs a python process parallel to each executor and passes data back and forth between the Scala part (the executor) and python.\nThis has a lot of implications for performance and memory consumption (and management of them when you tune a spark job)","Q_Score":1,"Tags":"python,apache-spark,pyspark,user-defined-functions","A_Id":53477555,"CreationDate":"2018-11-26T08:50:00.000","Title":"How does udf (user defined function) work in pyspark?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to run a Python script in a terminal, several times. This script requires me to import some libraries. So every time I call the script in the terminal, the libraries are loaded again, which results in a loss of time. Is there any way I can import the libraries once and for all at the beginning?\n(If I try the \"naive\" way, calling first a script just to import libraries then running my code, it doesn't work). \nEDIT: I need to run the script in a terminal because actually it is made to serve in another program developed in Java. The Java code calls the Pythin script in the terminal, reads its result and processes it, then calls it again.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1342,"Q_Id":53484032,"Users Score":1,"Answer":"The libraries will be unloaded once the script finishes, so the best way you can handle this is to write the script so it can iterate however many times you want, rather than running the whole script multiple times. I would likely use input() (or raw_input() if you're running Python2) to read in however many times you want to iterate over it, or use a library like click to create a command line argument for it.","Q_Score":1,"Tags":"python","A_Id":53484119,"CreationDate":"2018-11-26T15:10:00.000","Title":"Import Python library in terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to remove the class declaration of the model but want to keep the records and the table on the database. How can I do that?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2041,"Q_Id":53487801,"Users Score":-1,"Answer":"If the class it not going to be used anywhere but you want to keep the data:\n\nDo a dump of that data and create a new database to store the dump data.\nDelete the model.\nMake a migration deleting the model.\n\nIf you delete the model in the code I think that always you execute a manage makemigrations it will create a migration to delete the table.","Q_Score":11,"Tags":"python,django,database,django-models","A_Id":53488017,"CreationDate":"2018-11-26T19:30:00.000","Title":"How do I remove a model but keep the database table on Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on a very huge dataset with 20 million+ records. I am trying to save all that data into a feathers format for faster access and also append as I proceed with me analysis.\nIs there a way to append pandas dataframe to an existing feathers format file?","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":1519,"Q_Id":53488351,"Users Score":5,"Answer":"Feather files are intended to be written at once. Thus appending to them is not a supported use case.\nInstead I would recommend to you for such a large dataset to write the data into individual Apache Parquet files using pyarrow.parquet.write_table or pandas.DataFrame.to_parquet and read the data also back into Pandas using pyarrow.parquet.ParquetDataset or pandas.read_parquet. These functions can treat a collection of Parquet files as a single dataset that is read at once into a single DataFrame.","Q_Score":4,"Tags":"python,pandas,feather","A_Id":53508471,"CreationDate":"2018-11-26T20:13:00.000","Title":"Is it possible to append to an existing Feathers format file?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just finished installing a desktop computer based on an AMD Ryzen 2700x and 32GB RAM (running Ubuntu 18.04).\nAt work, I have a 3-year-old laptop workstation with an Intel i7-6820HQ and 16GB RAM (running Windows 10).\nI installed Anaconda on both platforms and ran a custom Python code which relies heavily on basic numpy matrix operations.\nThe code does not involve any GPU-specific computation (my work laptop does not have any).\nThe Ryzen is running at 3.7GHz, the laptop i7 is running at 3.6GHz. Both systems have been fully updated.\nTo my surprise, the code runs in 5 minutes on my work laptop, while it requires 10 minutes on the Ryzen desktop!\nThe latest Ryzen 2700x is supposed to be much faster than a high-end 3-year-old laptop Intel processor, then why would it be 2x slower?\n\nIs it due to Ubuntu being sub-optimal in some way as opposed to Windows 10 for the Ryzen?\nIs it due to Intel being more adequate to Python simulations than AMD?\nAnything else?\n\nThanks for your help in understanding what is going on.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2905,"Q_Id":53490310,"Users Score":11,"Answer":"It's a software issue: by default, anaconda comes with intel's MKL as the backend for BLAS, which will purposefully cripple AMD speed. You can also install the non-MKL version, which uses openBLAS instead, and you'll see a huge performance boost. You don't need to reinstall it, just uninstall numpy and mkl, then install a numpy built with openBLAS.","Q_Score":4,"Tags":"python,linux,intel,amd-processor","A_Id":54603664,"CreationDate":"2018-11-26T22:50:00.000","Title":"Why is an AMD Ryzen 2700x 2x slower than a 3-year-old laptop Intel i7-6820HQ with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As a programmer, I generally try to avoid the del statement because it is often an extra complication that Python program don't often need. However, when browsing the standard library (threading, os, etc...) and the pseudo-standard library (numpy, scipy, etc...) I see it used a non-zero amount of times, and I'd like to better understand when it is\/isn't appropriate the del statement. \nSpecifically, I'm curious about the relationship between the Python del statement and the efficiency of a Python program. It seems to me that del might help a program run faster by reducing the amount of clutter lookup instructions need to sift through. However, I can also see a world where the extra instruction takes up more time than it saves. \nMy question is: does anyone have any interesting code snippets that demonstrate cases where del significantly changes the speed of the program? I'm most interested in cases where del improves the execution speed of a program, although non-trivial cases where del can really hurt are also interesting.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":860,"Q_Id":53491177,"Users Score":0,"Answer":"Specifically, I'm curious about the relationship between the Python del statement and the efficiency of a Python program.\n\nAs far as performance is concerned, del (excluding index deletion like del x[i]) is primarily useful for GC purposes. If you have a variable pointing to some large object that is no longer needed, deling that variable will (assuming there are no other references to it) deallocate that object (with CPython this happens immediately, as it uses reference counting). This could make the program faster if you'd otherwise be filling your RAM\/caches; only way to know is to actually benchmark it.\n\nIt seems to me that del might help a program run faster by reducing the amount of clutter lookup instructions need to sift through.\n\nUnless you're using thousands of variables (which you shouldn't be), it's exceedingly unlikely that removing variables using del will make any noticeable difference in performance.","Q_Score":3,"Tags":"python","A_Id":53491232,"CreationDate":"2018-11-27T00:40:00.000","Title":"Can `del` make Python faster?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Example:\n\na=[['I am boy'],['she is girl'],['They both love each other']]\nb={'boy':'Rohan','girl':'Pooja','love':'hate'}\n\nDesired output:\n\na=[['I am Rohan'],['she is Pooja'],['They both hate each other']]\n\nMyCode:\n\nfor i in a:\n    print (i)\n    for j in i:\n        for k in b:\n            if ((k in j)== True):\n                j=j.replace(k,b[k])\n                print (j)\n\nMy Output:\n\nI am Rohan\nshe is Pooja\nThey both hate each other\n\n```\nMy doubt:\nI am unable to get the output in desired format. Can anyone help?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":53493282,"Users Score":0,"Answer":"This is a minor update to your code.\n\ntemp_a = []\nfor i in a:\n    print (i)\n    for j in i:\n        for k in b:\n            if ((k in j)== True):\n                j=j.replace(k,b[k])\n                temp_a.append([j])\na = temp_a","Q_Score":0,"Tags":"string,python-3.x,replace,str-replace,nested-lists","A_Id":53880745,"CreationDate":"2018-11-27T05:29:00.000","Title":"Search and replace certain keyword of nested list string in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to detect camera is capturing frozen frames or black frame. Suppose a camera is capturing video frames and suddenly same frame is capturing again and again. I spend long time to get any idea about this problem statement but i failed. So how we detect it or any idea\/steps\/procedure for this problem.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":805,"Q_Id":53493527,"Users Score":1,"Answer":"This was my approach to solve this issue.\nFrozen frames: calculate absolute difference over HSV\/RGB per every pixel in two consecutive frames np.arrays and determine max allowed diff that is valid for detecting frozen frames. \nBlack frames have naturally very low (or zero) V-value sum over the frame. Determine max V-sum of whole frame to determine, below which the frame is \"black\".","Q_Score":1,"Tags":"python,opencv,ubuntu-16.04","A_Id":53493633,"CreationDate":"2018-11-27T05:53:00.000","Title":"frozen frames detection openCV python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try pip install things, it doesn't work\nand return \n\nFile\n  \"\/Library\/Frameworks\/Python.framework\/Versions\/3.6\/lib\/python3.6\/zipfile.py\",\n  line 1566, in _writecheck\n      raise ValueError(\"write() requires mode 'w', 'x', or 'a'\") ValueError: write() requires mode 'w', 'x', or 'a'\n\nHow can I solve this problem?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":53493851,"Users Score":0,"Answer":"Looks like a permission issue.   I'd try making sure your python folders all have the same permissions.","Q_Score":0,"Tags":"python-3.x,pip","A_Id":53493934,"CreationDate":"2018-11-27T06:21:00.000","Title":"python valueError write()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In order to speed up my code, I am using Cython. I was wondering whether it is possible to fix the type of attributes for a Graph object in igraph?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":53496217,"Users Score":0,"Answer":"Attributes in igraph are returning PyObjects so no, you cannot type them in Cython.\nHowever, depending on your use case, it may be useful to pre-assign the attributes to a typed c++ vector or a C array, then work on this vector\/array.","Q_Score":0,"Tags":"python,cython,igraph,dynamic-data,static-data","A_Id":53497410,"CreationDate":"2018-11-27T09:15:00.000","Title":"Data type of attributes in igraph, python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"pre:\n\nI installed both python2.7 and python 3.70\neclipse installed pydev, and configured two interpreters for each py version\nI have a project with some py scripts\n\nquestion:\nI choose one py file, I want run it in py2, then i want it run in py3(manually).\nI know that each file cound has it's run configuration, but it could only choose one interpreter a time. \nI also know that py.exe could help you get the right version of python.\nI tried to add an interpreter with py.exe, but pydev keeps telling me that \"python stdlibs\" is necessary for a interpreter while only python3's lib shows up.\nso, is there a way just like right click the file and choose \"run use interpreter xxx\"?\nor, does pydev has the ability to choose interpreters by \"#! python2\"\/\"#! python3\" at file head?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":324,"Q_Id":53496898,"Users Score":1,"Answer":"I didn't understand what's the actual workflow you want...\nDo you want to run each file on a different interpreter (say you have mod1.py and want to run it always on py2 and then mod2.py should be run always on py3) or do you want to run the same file on multiple interpreters (i.e.: you have mod1.py and want to run it both on py2 and py3) or something else? \nSo, please give more information on what's your actual problem and what you want to achieve...\n\nOptions to run a single file in multiple interpreters:\n\nAlways run with the default interpreter (so, make a regular run -- F9 to run the current editor -- change the default interpreter -- using Ctrl+shift+Alt+I -- and then rerun with Ctrl+F11).\nCreate a .sh\/.bat which will always do 2 launches (initially configure it to just be a wrapper to launch with one python, then, after properly configuring it inside of PyDev that way change it to launch python 2 times, one with py2 and another with py3 -- note that I haven't tested, but it should work in theory).","Q_Score":0,"Tags":"python,eclipse,pydev","A_Id":53516276,"CreationDate":"2018-11-27T09:51:00.000","Title":"how to run python in eclipse with both py2 and py3?","Data 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' s a kinda old debian system (6.0.2) where the highest installed python version is 2.6 . I' ve an application requiring python 3.4 .\nIs it possible to install python 3.4 into the virtual environment and to use that? I guess no, but i need some confirmation.\nIt' s not possible to install system- wide any python package.\nThanks.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":53497551,"Users Score":0,"Answer":"Yes, you can install any python virtual environment. Just download that version of Python to your computer and create your virtual environment using it","Q_Score":0,"Tags":"python,python-3.x,debian,virtualenv","A_Id":53497567,"CreationDate":"2018-11-27T10:25:00.000","Title":"virtualenv python higer version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"there' s a kinda old debian system (6.0.2) where the highest installed python version is 2.6 . I' ve an application requiring python 3.4 .\nIs it possible to install python 3.4 into the virtual environment and to use that? I guess no, but i need some confirmation.\nIt' s not possible to install system- wide any python package.\nThanks.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":53497551,"Users Score":0,"Answer":"Of course you can.\nThe fastest way to achieve that is:\nFirst, install python3 system-wide from repo.\nsudo apt-get install python3\n(If you need exactly python 3.4 then install exactly python 3.4)\nThen install virtualenv\nsudo apt-get install virtualenv\nCheck your python3 version with \npython3 --version\njust to confirm that everything was fine with installation.\nYou should see something like this: Python 3.6.7.\nNow you can create a virtual environment specifying the python version\nvirtualenv -p python3.6 my_env\nThis will create a my_env folder with your python3.6 environment in the current directory.\nYou can activate the environment with\nsource my_env\/bin\/activate\nHope it helps.","Q_Score":0,"Tags":"python,python-3.x,debian,virtualenv","A_Id":53497892,"CreationDate":"2018-11-27T10:25:00.000","Title":"virtualenv python higer version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I couldn't find much information on this. I want to rename my Scrapy project, spiders made, JSONs created but want to change the name to something meaningful without messing anything up.\nA solution through the terminal would also be appreciated.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1607,"Q_Id":53498732,"Users Score":0,"Answer":"Basically, you only need to change default = new_project_title under [settings] in scrapy.cfg file and SPIDER_MODULES = ['new_project_title.spiders'] in the settings.py file to make the spider run with the new name of the project. \nAfter longer inspection of documentation, I have to say that the quick change of the project name through the scrapy's command line is not that easy.","Q_Score":3,"Tags":"python,python-3.x,scrapy","A_Id":59652041,"CreationDate":"2018-11-27T11:33:00.000","Title":"Rename scrapy project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I couldn't find much information on this. I want to rename my Scrapy project, spiders made, JSONs created but want to change the name to something meaningful without messing anything up.\nA solution through the terminal would also be appreciated.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1607,"Q_Id":53498732,"Users Score":1,"Answer":"As of right now there is no command that changes the project name from the command line. I would just rename it in your file explorer, it shouldn't mess with your spiders.","Q_Score":3,"Tags":"python,python-3.x,scrapy","A_Id":53523602,"CreationDate":"2018-11-27T11:33:00.000","Title":"Rename scrapy project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I couldn't find much information on this. I want to rename my Scrapy project, spiders made, JSONs created but want to change the name to something meaningful without messing anything up.\nA solution through the terminal would also be appreciated.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1607,"Q_Id":53498732,"Users Score":0,"Answer":"Change project directory name, search old project name in scrapy.cfg and settings.py files and replace with new project name.","Q_Score":3,"Tags":"python,python-3.x,scrapy","A_Id":57543600,"CreationDate":"2018-11-27T11:33:00.000","Title":"Rename scrapy project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a bytearray, for example [0x6B, 0x6A, 0x6D, 0x6C].\nFor reasons out of my control the bytes are 'incorrect', and need to be fixed. The output I want is a bytearray like [0xAB, 0xCD].\nSo in my example, I want to ignore the '6' part of the byte. (6 is just an example, it can change).\nI'm currently doing this by:\n\nLooping over pairs of bytes\nConverting the bytes to a hex string, like '6B6A'\nTaking the 4th and 2nd character of the string to build 'AB'\nConvert that 'AB' hex string to a byte\n\nI already have a solution that works but it feels 'wrong' to use string manipulation with numerical values.\nI'm not proficient with bitwise operators and I'm not sure if I can use bitwise operators, or something else entirely, to do this in a faster and\/or more efficient way.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":53499051,"Users Score":0,"Answer":"After a little trial and error:\nTo get 0x0B from 0x6B, I can do 0x6B & 0x0F.\nTo get 0xA0 from 0x6A, I can do the same as above, and then result << 4.\nThen I can add these values together to produce 0xAB.","Q_Score":2,"Tags":"python","A_Id":53499476,"CreationDate":"2018-11-27T11:51:00.000","Title":"How to clean\/fix these bytes without string operations?","Data 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 are using django-cron version 0.5.1.\nAre these cron jobs run as separate process or are these executed as threads inside the main django process ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":194,"Q_Id":53503274,"Users Score":1,"Answer":"Since django-cron jobs are run with a management command like so: python manage.py runcrons they will run in a separate process than your web app.","Q_Score":0,"Tags":"python,django","A_Id":53504291,"CreationDate":"2018-11-27T15:46:00.000","Title":"Are Django cron jobs processes or threads?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have model Tech, with name(Charfield) and firm(ForeignKey to model Firm), because one Tech(for example, smartphone) can have many firms(for example Samsung, apple, etc.)\nHow can I create filter in admin panel for when I creating model, If I choose 'smartphone' in tech field, it show me in firm field only smartphone firms? Coz if I have more than one value in firm field (for example Apple, Samsung, IBM), it show me all of it. But IBM must show only if in tech field I choose 'computer'. How release it?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1115,"Q_Id":53504338,"Users Score":1,"Answer":"You can define the choices of the input with the attribute 'choices' of the widget. When you create the admin form of the model, you could define manually the fields, and also you can define the widget for each input. In the widget you could define with a tuple the choices and the initial values.","Q_Score":1,"Tags":"django,python-3.x,filter,django-admin","A_Id":53506417,"CreationDate":"2018-11-27T16:44:00.000","Title":"How to filter choices in fields(forms) in Django admin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to do calculation on my graph neglecting some edges (as if they don't exist). Like calculation of degree, closeness, or betweenness. \nany ideas ! \nPython","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":32,"Q_Id":53504630,"Users Score":1,"Answer":"You could simply remove the edges you want to ignore before running the computations, and keep a record of what edges you have to put back when you're done.","Q_Score":0,"Tags":"python,networkx,igraph","A_Id":53504769,"CreationDate":"2018-11-27T17:01:00.000","Title":"Ignore edges when calculating betweenness or closeness of the graph","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd I like to install virtualenv on an USB disk so that i can use it also on other computers. How can I do it? Just creating a virtualenv on the disk doesn't seem to work...\nI'm using Mac and the target computer has Fedora.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1410,"Q_Id":53509305,"Users Score":0,"Answer":"Short answer is YES but of no use.\nThe internal architecture used in Virtualenv, hard codes all the paths as absolute paths in multiple places. Most notably all the files in the \"site-packages\" folder contain hard coded paths and many or most of them are in ascii format. So there is no normal means to change them to a relative paths.\nIt may however work in a very restricted set of situation like if you can maintain the same folder path in all the computers and same family of os etc etc. But and its a really big 'but' whether even in this scenario it will work smoothly.\nUnless there is vendor support from its architecture level you cannot get true portability.\n\nUsing pip-freeze with \"requirements\" file and recreating the\nvirtualenv on all systems separately is the only option available as\nof now.","Q_Score":0,"Tags":"python,virtualenv","A_Id":70205569,"CreationDate":"2018-11-27T22:36:00.000","Title":"Can I install virtualenv on USB Disk?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How would I take user input at various points while running a PyRevit script? I know that input('') doesn't work. I am wanting the user to input integers to perform a calculation.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":504,"Q_Id":53509601,"Users Score":1,"Answer":"Use the .NET Windows.Forms library and display a prompt for input in a modal Windows form using ShowDialog.","Q_Score":0,"Tags":"python,revit,pyrevit","A_Id":53558656,"CreationDate":"2018-11-27T23:07:00.000","Title":"How to take user input using PyRevit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a way to extract words from text if they match the following conditions:\n1) are capitalised\nand\n2) appear on a new line on their own (i.e. no other text on the same line).\nI am able to extract all capitalised words with this code:\n   caps=re.findall(r\"\\b[A-Z]+\\b\", mytext)\nbut can't figure out how to implement the second condition. Any help will be greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":38,"Q_Id":53509867,"Users Score":-1,"Answer":"please try following statements \\r\\n at the begining of your regex expression","Q_Score":2,"Tags":"python,regex,python-3.x","A_Id":53509933,"CreationDate":"2018-11-27T23:32:00.000","Title":"Python regex to identify capitalised single word lines in a text abstract","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get a column of (x,y) coordinate pairs in my pandas data frame. I want to be able to access each part of the coordinate. For example, if the title of the column is 'pair1' I want to be able to call pair1[0] and pair1[1] to access the x and y integers respectively. Ultimately, I'd be passing these into a distance function to get the distance between 'pair1' and 'pair2'. Thanks!","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":854,"Q_Id":53509923,"Users Score":-1,"Answer":"Implementing (x,y) coordinates in 1 column would be unnecessarily complex and hacky. I strongly recommend you make two columns, for example pair1_x and pair1_y. Is there a particular reason you need one column?","Q_Score":0,"Tags":"python,pandas","A_Id":53509981,"CreationDate":"2018-11-27T23:39:00.000","Title":"How to create a column of (x,y) pairs in a data frame","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi I am new to python I found that if we use pytest, fixtures that defined in conftest.py can be directly referenced without needing import in test module. Similarly, if we are using pytest-mock, a fixture called mocker can be referenced any where in the test modules as long as the test is triggered by pytest, no need to do import either. I think there must be one or multiple python language features that enable such kind of thing. What are they? If your answers can assume that I am from Java\/C++ background that will be great!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":53510600,"Users Score":0,"Answer":"the pytest fixture system registers fixtures by name, and then looks those names up in the fixture registry, not the actual python module you are currently in\nso you dont need to import them in each test module, and plugins for pytest can provide them","Q_Score":0,"Tags":"python,pytest","A_Id":53593520,"CreationDate":"2018-11-28T01:08:00.000","Title":"Why pytest can reference fixture without 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 create a random string of numbers saved to a list, then rename the list further in the code. I've tried using dictionaries to store the names but that didn't work, I've also tried simply newListName=oldListName which when I attempted to print newListName it returns a NameError","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1409,"Q_Id":53511066,"Users Score":2,"Answer":"You can copy the list into a new one as:\n\nnewListName=oldListName[:]\n\nThis would not give you the NameError!\nMake sure that oldListName is defined as list before and then copied into another list.","Q_Score":0,"Tags":"python,list,rename","A_Id":53514436,"CreationDate":"2018-11-28T02:09:00.000","Title":"How do you rename a list to a variable in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was going through the documentation of pip, and also looking at virtualenv. If we set the PYTHONUSERBASE variable, and run pip install with the --ignore-installed and --user options , we are basically telling pip to download the packages in the local folder ignoring everything that's present in the global site-packages path. As per my understanding, virtualenv is used to accomplish a similar goal. Then why should I use virtualenv? Is there any added benefit, if we're only dealing with a single python installation on our machine?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":766,"Q_Id":53516032,"Users Score":0,"Answer":"virtualenv makes a separate copy of python installation and the site packages. Suppose we write a code today and its working perfectly. But a month later, we have updated a package (eg numpy) for some reason. Now its possible that the code that was working last month might not work today because of the update. So, to avoid this we use virtualenv.\nNote: I am an amateur computer programmer and don't know much about the technical stuff. Just sharing what I know.. :)","Q_Score":1,"Tags":"python,python-3.x,pip,dependencies,virtualenv","A_Id":53516349,"CreationDate":"2018-11-28T09:23:00.000","Title":"What's the difference between virtualenv and using pip install with --ignore-installed and --user options?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was going through the documentation of pip, and also looking at virtualenv. If we set the PYTHONUSERBASE variable, and run pip install with the --ignore-installed and --user options , we are basically telling pip to download the packages in the local folder ignoring everything that's present in the global site-packages path. As per my understanding, virtualenv is used to accomplish a similar goal. Then why should I use virtualenv? Is there any added benefit, if we're only dealing with a single python installation on our machine?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":766,"Q_Id":53516032,"Users Score":0,"Answer":"The difference is that a user can have many virtual environments, every one with different versions of packages and their dependencies. With pip install --user a user can only have one version of a package.","Q_Score":1,"Tags":"python,python-3.x,pip,dependencies,virtualenv","A_Id":53521761,"CreationDate":"2018-11-28T09:23:00.000","Title":"What's the difference between virtualenv and using pip install with --ignore-installed and --user options?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can i do these two things:\n\nIs there any library in dart for Sentiment Analysis? \nCan I use Python (for Sentiment Analysis) in dart? \n\nMy main motive for these questions is that I'm working on an application in a flutter and I use sentiment analysis and I have no idea that how I do that. \nCan anyone please help me to solve this Problem.?\nOr is there any way that I can do text sentiment analysis in the flutter app?","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":36968,"Q_Id":53519266,"Users Score":10,"Answer":"You can create an api using Python then serve it your mobile app (FLUTTER) using http requests.\nI","Q_Score":21,"Tags":"python,dart,python-requests,flutter,dart-pub","A_Id":56864092,"CreationDate":"2018-11-28T12:15:00.000","Title":"Python and Dart Integration in Flutter Mobile 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 used to be able to call python scripts directly from the command line in Windows. e.g.:\n\nC:\\SomeScript.py\n\nBut after setting the python executable to 'Run as Administrator' in the compatibility settings, I always get the cryptic error \"Unable to Create Process using' ... followed by path of the python file I'm trying to run:\n\nUnable to create process using 'C:\\python\\python.exe \"C:\\SomeScript.py\" ' \n\nI get the same error if I try and run the file from Explorer (albeit flashing on my screen briefly,  or if I run the script from the 'Send To' popup.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":828,"Q_Id":53519479,"Users Score":1,"Answer":"This was caused by the Python executable being set to 'Run As Administrator.'  in the compatibility settings;  presumably because windows could not load the UAC form to escalate privileges.\nThere are two possible solutions.\n\nRemove the 'Run as Administrator' setting \nPass the script's path as an argument to Python.exe rather than calling it directly, which allows windows to prompt for escalation correctly.\n\nI.e.  Instead of \n\nc:\\SomeScript.py\n\nrun\n\nc:\\python\\python.exe c:\\SomeScript.py","Q_Score":1,"Tags":"python,windows","A_Id":53519480,"CreationDate":"2018-11-28T12:27:00.000","Title":"Running a python script in Windows gives \"Unable to Create Process Using ...\" when python.exe set to 'run as administrator'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"The docs for Xgboost imply that the output of a model trained using the Cox PH loss will be exponentiation of the individual persons predicted multiplier (against the baseline hazard). Is there no way to extract from this model the baseline hazard in order to predict the entire survival curve per person?\n\nsurvival:cox: Cox regression for right censored survival time data\n  (negative values are considered right censored). Note that predictions\n  are returned on the hazard ratio scale (i.e., as HR =\n  exp(marginal_prediction) in the proportional hazard function h(t) =\n  h0(t) * HR)","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":2074,"Q_Id":53521427,"Users Score":3,"Answer":"No, I think not. A workaround would be to fit the baseline hazard in another package e.g. from sksurv.linear_model import CoxPHSurvivalAnalysis or in R by require(survival). Then you can use the predicted output from XGBoost as multiplyers to the fitted baseline. Just remember that if the baseline is on the log scale then use output_margin=True and add the predictions.\nI hope the authors of XGBoost soon will provide some examples of how to use this function.","Q_Score":3,"Tags":"python,xgboost","A_Id":54064392,"CreationDate":"2018-11-28T14:13:00.000","Title":"XGBoost (Python) Prediction for Survival Model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Once reading in memory a binary, is there an efficient way to tell whether the binary is a Flatbuf? Preferably a Python solution.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":251,"Q_Id":53522335,"Users Score":1,"Answer":"There is provision of 4 byte \"root identifier\" at beginning of buffer(search for it in flat buffer schema language). If your schema has implemented that, you can just validate first 4 bytes.\nOr if you have the generated interfaces with you, you may run the complete \"flatbuffer verifier\" on binary to see if it's a valid flat buffer.","Q_Score":0,"Tags":"python,flatbuffers","A_Id":53523077,"CreationDate":"2018-11-28T15:00:00.000","Title":"How to sniff Flatbuffers in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running the Set_Attitude_Target example on an Intel Aero with Ardupilot. The code is working as intended but on top of a clear sensor error, that becomes more evident the longer I run the experiment.\nIn short, the altitude report from the example is reporting that in LocationLocal there is a relative altitude of -0.01, which gets smaller and smaller the longer the drone stays on. \nIf the drone takes off, say, 1 meter, then the relative altitude is less than that, so the difference is being taken out.\nI ran the same example with the throttle set to a low value so the drone would stay stationary while \"trying to take off\" with insufficient thrust. For the 5 seconds that the drone was trying to take off, as well as after it gave up, disarmed and continued to run the code, the console read incremental losses to altitude, until I stopped it at -1 meter. \nWhere is this sensor error coming from and how do I remedy it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":53522828,"Users Score":0,"Answer":"As per Agustinus Baskara's comment on the original post, it would appear the built-in sensor is simply that bad - it can't be improved upon with software.","Q_Score":0,"Tags":"dronekit-python","A_Id":53557092,"CreationDate":"2018-11-28T15:25:00.000","Title":"Why is LocationLocal: Relative Alt dropping into negative values on a stationary drone?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to delete multiple email messages in Outlook from python via win32com module.   \nI understand there is a VBA method MailItem.Delete() available to win32com via COM and it works; but it is VERY VERY slow when deleting more than one email since one would have to delete emails sequentially ie loop over the MailItem collection of emails.  \nIs there any way to delete a selected collection of mailItems at once, something like  MailItemCollection.DeleteAll()?  \nAlso, if above is not possible; is it at all possible to delete many emails via multi-threaded approach ie divide the collection of mailItems into, let's say, 4 subsets; have 4 threads operate on those?  \nI figure since I can delete multiple emails in outlook via its GUI very fast, there has to be a way where I can do the same thing via COM API.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5723,"Q_Id":53523943,"Users Score":0,"Answer":"I've implemented an alternative solution in local Outlook, by moving email \u00edtems from.inbox folder to deleted items folder or to an archive folder, by using VBA code or Outlook filter rules directly.\nThis way, I just mannualy empty the deleted items folder once a week (of course this periodic step can also be programmed).\nI observed that this strategy can be more efficient instead of delete item per item using code (you mentioned the internal.indexes problem).","Q_Score":2,"Tags":"python,api,outlook,com,win32com","A_Id":70914440,"CreationDate":"2018-11-28T16:24:00.000","Title":"python win32com: Delete multiple emails in Outlook","Data Science and Machine Learning":0,"Database and SQL":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 very little to say about this issue so hopefully this is a known problem and I'm just bad at finding previous threads about it. In any case, as the title states, I'm trying to convert PDF files to sets of images in bulk (for right now I'd like it to work for just one conversion though).\nI'm trying to use a wrapper for poppler (pdf2image), but when I attempt to run the conversion, I get the following error:\n\nException: Unable to get page count. Is poppler installed and in PATH?\n\nI installed poppler and added it to PATH, but I still get the error. What gives? And additionally, is there a more succinct\/better way to do this conversion?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4660,"Q_Id":53525731,"Users Score":1,"Answer":"try to add poppler\/bin in system variable path","Q_Score":0,"Tags":"python,pdf,poppler","A_Id":54084276,"CreationDate":"2018-11-28T18:19:00.000","Title":"Converting PDFs to images in Python with Poppler, but Poppler doesn't register as being in PATH?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have very little to say about this issue so hopefully this is a known problem and I'm just bad at finding previous threads about it. In any case, as the title states, I'm trying to convert PDF files to sets of images in bulk (for right now I'd like it to work for just one conversion though).\nI'm trying to use a wrapper for poppler (pdf2image), but when I attempt to run the conversion, I get the following error:\n\nException: Unable to get page count. Is poppler installed and in PATH?\n\nI installed poppler and added it to PATH, but I still get the error. What gives? And additionally, is there a more succinct\/better way to do this conversion?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4660,"Q_Id":53525731,"Users Score":1,"Answer":"You can explicitly add the path in convert_from_path function of module pdf2image \nExample==>\npages = pdf2image.convert_from_path(pdf_file, poppler_path='your_path')\nworks just fine and you don't worry about adding it to system path variables.","Q_Score":0,"Tags":"python,pdf,poppler","A_Id":56473683,"CreationDate":"2018-11-28T18:19:00.000","Title":"Converting PDFs to images in Python with Poppler, but Poppler doesn't register as being in PATH?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on a graph with (x,y) node coordinates randomly picked from 0-100. If I simply plot the graph using nx.draw() and passing the original coordinates it looks ok, but if I try to plot some node sizes in a way it relates to coordinates it looks clearly inconsistent.\nLooks like the nodes position parameter in draw() is not in the same unit of the node sizes, which are in pixels.Sadly there's nothing about position units in NetworkX documentation...","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":307,"Q_Id":53527307,"Users Score":0,"Answer":"Networkx uses matplotlib to plot things.  It does not use pixels for its coordinates, and for good reason.\nIf you you have coordinates whose values range from -0.01 to 0.01, it will produce a plot that scales the upper and lower bounds on the coordinates to be large enough to hold this, but not so large that everything is in a tiny little bit of the plot.  If you now add points with coordinate values around 100, it will rescale the plot to show these as well.\nThink about how it would look to plot the line y = x+1 for x in (-0.5, 0.5) if matplotlib insisted that 1 had to correspond to a pixel.","Q_Score":0,"Tags":"python,matplotlib,networkx","A_Id":53529130,"CreationDate":"2018-11-28T20:06:00.000","Title":"NetworkX plotting: different units\/scale between node positions and sizes?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a graph with (x,y) node coordinates randomly picked from 0-100. If I simply plot the graph using nx.draw() and passing the original coordinates it looks ok, but if I try to plot some node sizes in a way it relates to coordinates it looks clearly inconsistent.\nLooks like the nodes position parameter in draw() is not in the same unit of the node sizes, which are in pixels.Sadly there's nothing about position units in NetworkX documentation...","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":307,"Q_Id":53527307,"Users Score":1,"Answer":"Ok, I figured it out... \nPosition parameter for nodes are relative, from 0.0 to 1.0 times whatever your plot size is, while size parameter is absolute, in pixels","Q_Score":0,"Tags":"python,matplotlib,networkx","A_Id":53529069,"CreationDate":"2018-11-28T20:06:00.000","Title":"NetworkX plotting: different units\/scale between node positions and sizes?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a system I am reading from that implemented a time tracking function in a pretty poor way - It shows the tracked working time as [hh]:mm in the cell.  Now this is problematic when attempting to read this data because when you click that cell the data bar shows 11:00:00 PM, but what that 23:00 actually represents is 23 hours of time spent and not 11PM.  So whenever the time is 24:00 or more you end up with 1\/1\/1900 12:00:00 AM and on up ( 25:00 = 1\/1\/1900 01:00:00 AM).\nSo pandas picks up the 11:00:00 AM or 1\/1\/1900 01:00:00 AM when it comes into the dataframe.  I am at a loss as to how I would put this back into an INT for and get the number of hours in a whole number format 24, 25, 32, etc.\nCan anyone help me figure out how to turn this horribly formatted data into the number of hours in int format?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":470,"Q_Id":53528583,"Users Score":1,"Answer":"pandas is not at fault its the excel that is interpreting the data wrongly, \nSet the data to text in that column and it wont interpret as date.\nthen save the file and open through pandas and it should work fine.\nother wise export as CSV and try to open in pandas.","Q_Score":0,"Tags":"python,pandas","A_Id":53528742,"CreationDate":"2018-11-28T21:44:00.000","Title":"Pandas read and parse Excel data that shows as a datetime, but shouldn't be a datetime","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recently installed PyQt4. The installation was successful. Is it good practice to now delete the PyQt4-4.11.4-cp37-cp37m-win_amd64.whl file? Will this prevent me from using pip uninstall PyQt4in the future?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1248,"Q_Id":53528729,"Users Score":2,"Answer":"You could delete the wheel package. It won't prevent you from uninstalling the package. \nIf, however, you need to reinstall the same package again, you will have to acquire the wheel package again, obviously.","Q_Score":2,"Tags":"python,pip,pyqt4","A_Id":53529036,"CreationDate":"2018-11-28T21:56:00.000","Title":"Should I delete .whl installers after packages have successfully been installed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using anaconda on mac and I am wondering whether there is a way to clear my python command history. Specifically, upon calling python in terminal, I wanted to clear anything I typed before here.","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":14856,"Q_Id":53530046,"Users Score":2,"Answer":"If your system doesn't use readline, to remove all Python command history just delete the history file at ~\/.python_history.\nYou can see the full path of the history file with:\npython -c \"import os; print(os.path.join(os.path.expanduser('~'), '.python_history'))\".\nOn Windows the history file is at %userprofile%\\.python_history (e.g., 'C:\\Users\\<user>\\.python_history').","Q_Score":16,"Tags":"python","A_Id":67732175,"CreationDate":"2018-11-29T00:15:00.000","Title":"Clear python console command history","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am confused now about the loss functions used in XGBoost. Here is how I feel confused:\n\nwe have objective, which is the loss function needs to be minimized; eval_metric: the metric used to represent the learning result. These two are totally unrelated (if we don't consider such as for classification only logloss and mlogloss can be used as eval_metric). Is this correct? If I am, then for a classification problem, how you can use rmse as a performance metric?\ntake two options for objective as an example, reg:logistic and binary:logistic. For 0\/1 classifications, usually binary logistic loss, or cross entropy should be considered as the loss function, right? So which of the two options is for this loss function, and what's the value of the other one? Say, if binary:logistic represents the cross entropy loss function, then what does reg:logistic do?\nwhat's the difference between multi:softmax and multi:softprob? Do they use the same loss function and just differ in the output format? If so, that should be the same for reg:logistic and binary:logistic as well, right?\n\nsupplement for the 2nd problem\nsay, the loss function for 0\/1 classification problem should be\nL = sum(y_i*log(P_i)+(1-y_i)*log(P_i)). So if I need to choose binary:logistic here, or reg:logistic to let xgboost classifier to use L loss function. If it is binary:logistic, then what loss function reg:logistic uses?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":19483,"Q_Id":53530189,"Users Score":11,"Answer":"'binary:logistic' uses -(y*log(y_pred) + (1-y)*(log(1-y_pred)))\n'reg:logistic' uses (y - y_pred)^2\nTo get a total estimation of error we sum all errors and divide by number of samples.\n\nYou can find this in the basics. When looking on Linear regression VS Logistic regression.\nLinear regression uses (y - y_pred)^2 as the Cost Function\nLogistic regression uses -(y*log(y_pred) + (y-1)*(log(1-y_pred))) as the Cost function\n\nEvaluation metrics are completely different thing. They design to evaluate your model. You can be confused by them because it is logical to use some evaluation metrics that are the same as the loss function, like MSE in regression problems. However, in binary problems it is not always wise to look at the logloss. My experience have thought me (in classification problems) to generally look on AUC ROC.\nEDIT\n\naccording to xgboost documentation:\n\nreg:linear: linear regression\n\n\nreg:logistic: logistic regression\n\n\nbinary:logistic: logistic regression for binary classification, output\nprobability\n\nSo I'm guessing:\nreg:linear: is as we said, (y - y_pred)^2\nreg:logistic is -(y*log(y_pred) + (y-1)*(log(1-y_pred))) and rounding predictions with 0.5 threshhold\nbinary:logistic is plain -(y*log(y_pred) + (1-y)*(log(1-y_pred))) (returns the probability)\nYou can test it out and see if it do as I've edited. If so, I will update the answer, otherwise, I'll just delete it :<","Q_Score":15,"Tags":"python,machine-learning,xgboost,xgbclassifier","A_Id":53535742,"CreationDate":"2018-11-29T00:38:00.000","Title":"The loss function and evaluation metric of XGBoost","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to run an Airflow DAG bi-monthly on a particular Wednesday.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":630,"Q_Id":53534375,"Users Score":1,"Answer":"Pass 0 0 1,15 * 3 to schedule_interval.\nIt is a cron expresssion which means \u201cAt 00:00 on day-of-month 1 and 15 and on Wednesday.\u201d","Q_Score":0,"Tags":"python,cron,airflow","A_Id":53556334,"CreationDate":"2018-11-29T08:07:00.000","Title":"How to schedule an Airflow DAG to run Bi-monthly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I execute Nuitka, there're always some logs and warning showing up. How do I suppress this?\nExample: python3 -m nuitka --follow-imports --standalone --remove-output main.py","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":116,"Q_Id":53534432,"Users Score":1,"Answer":"Append 2 > \/dev\/null to the command. This redirects stderr output to \/dev\/null which throws it away.","Q_Score":0,"Tags":"python,python-3.x,nuitka","A_Id":55556391,"CreationDate":"2018-11-29T08:10:00.000","Title":"How to suppress Nuitka logs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Perhaps it is a basic question but I am really not a profession in Portainer.\nI have a local Portainer, a Pycharm to manage the Python code. What should I do after I modified my code and deploy this change to the local Portainer?\nThx","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":53535445,"Users Score":0,"Answer":"If you have mounted the folder where your code resides directly in the container the changes will be also be applied in your container so no further action is required.\nIf you have not mounted the folder to your container (for example if you copy the code when you build the image), you would have to rebuild the image. Of course this is a lot more work so I would recommend using the mounted volumes.","Q_Score":1,"Tags":"linux,python-3.x,portainer","A_Id":53535718,"CreationDate":"2018-11-29T09:16:00.000","Title":"After I modified my Python code in Pycharm, how to deploy the change to my Portainer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I launch PyCharm from terminal \/ command prompt?\nI tried charm, charm., pycharm., pycharm. \nNone of these commands work.\nIs it possible to open\/launch PyCharm from a command prompt \/ terminal ?","AnswerCount":6,"Available Count":4,"Score":0.0665680765,"is_accepted":false,"ViewCount":17131,"Q_Id":53535942,"Users Score":2,"Answer":"Redirect to your codebase directory and type pycharm-community . in the terminal\nWorks with Ubuntu, macOS, and Windows","Q_Score":7,"Tags":"python,terminal,command,pycharm,jetbrains-ide","A_Id":57784300,"CreationDate":"2018-11-29T09:41:00.000","Title":"How to launch PyCharm from terminal\/command prompt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I launch PyCharm from terminal \/ command prompt?\nI tried charm, charm., pycharm., pycharm. \nNone of these commands work.\nIs it possible to open\/launch PyCharm from a command prompt \/ terminal ?","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":17131,"Q_Id":53535942,"Users Score":5,"Answer":"From examining the shortcut on my Ubuntu desktop (on which I have the community version of Pycharm installed) the command it runs is \"pycharm-community\" So this works when run in a terminal, for example:\npycharm-community &\nIf you are using Windows, you can use the same trick to find out where Pycharm is installed (examining the shortcut on your start menu or desktop). For me, it is:\n\"C:\\Program Files (x86)\\JetBrains\\PyCharm 2016.3.1\\bin\\pycharm64.exe\"\nRunning that from a git bash prompt launches Pycharm for me.\nYou probably want to examine your own shortcut to find the correct location on your computer.\nYou can find the shortcut file from the Start Menu by right-clicking on the Pycharm entry and selecting Open file location. Or you can just look at the shortcut on your desktop if you have one there.\nWhen you have located the shortcut file, right-click it, click Properties, select the Shortcut tab, and look in the field called Target: to see the location of the Pycharm executable.","Q_Score":7,"Tags":"python,terminal,command,pycharm,jetbrains-ide","A_Id":53536111,"CreationDate":"2018-11-29T09:41:00.000","Title":"How to launch PyCharm from terminal\/command prompt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I launch PyCharm from terminal \/ command prompt?\nI tried charm, charm., pycharm., pycharm. \nNone of these commands work.\nIs it possible to open\/launch PyCharm from a command prompt \/ terminal ?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":17131,"Q_Id":53535942,"Users Score":0,"Answer":"This worked for me on my 2017 imac macOS Mojave (Version 10.14.3).\n\nOpen your ~\/.bash_profile:\nnano ~\/.bash_profile\nAppend the alias:\nalias pycharm=\"open \/Applications\/PyCharm\\ CE.app\"\nUpdate terminal:\nsource ~\/.bash_profile\nAssert that it works:\npycharm","Q_Score":7,"Tags":"python,terminal,command,pycharm,jetbrains-ide","A_Id":55210725,"CreationDate":"2018-11-29T09:41:00.000","Title":"How to launch PyCharm from terminal\/command prompt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I launch PyCharm from terminal \/ command prompt?\nI tried charm, charm., pycharm., pycharm. \nNone of these commands work.\nIs it possible to open\/launch PyCharm from a command prompt \/ terminal ?","AnswerCount":6,"Available Count":4,"Score":0.1651404129,"is_accepted":false,"ViewCount":17131,"Q_Id":53535942,"Users Score":5,"Answer":"If you are using ubuntu, go to pycharm\/bin folder and run pycharm.sh file using below command\n\n.\/pycharm.sh","Q_Score":7,"Tags":"python,terminal,command,pycharm,jetbrains-ide","A_Id":53536011,"CreationDate":"2018-11-29T09:41:00.000","Title":"How to launch PyCharm from terminal\/command prompt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I prefer to write my python code on VSCode because of its intellisense and autocomplete features. But I would rather see and debug the code on a Jupyter notebook to better visualize the data I am working with.\nI know I can load any file into Jupyter by using the magical %load or %loadpy commands. But they load the entire file into a single cell. \nSince I wanted to see the intermediary results of certain operations, I would like to import the file in such a way that each line on the file is assigned to a cell on the notebook. Unless it's a function or conditional statement (in other words, anything with indentation); in these cases it should add the whole block into one cell. \nHow can I do that?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1872,"Q_Id":53536092,"Users Score":2,"Answer":"AFAIK, there is no way to do this upon loading your file into a Jupyter notebook. However, you can easily split your big cell into multiple cells, by using ctrl+shift+-. This will split your cell at the position where your cursor is located at that time.\nI don't know how big your files are, but it is a really fast and efficient way to split cells so maybe that works for you =)","Q_Score":1,"Tags":"python,jupyter-notebook,ipython,jupyter,ipython-magic","A_Id":53536312,"CreationDate":"2018-11-29T09:48:00.000","Title":"Import .py flie into Jupyter Notebook line by line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Edit Form is not editable on production and the image button in the left, while on development it is editable and image button on the right.\nWhat could be the issue?\nThe code is exactly the same. Checked on Chrome, IE and Firefox - same issue\nCleaned cache - didn't help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":250,"Q_Id":53537037,"Users Score":1,"Answer":"For me, when I applied the collectstatic command on production, instead of overwriting the previous css file I had it instead appended the additional code from the new css file.\nYou can use the browser development tool's 'Network' tab to see each file being loaded (css and javascript) and double click them to see if the content of those files matches the content you are expecting to see!","Q_Score":2,"Tags":"python,html,django","A_Id":64091171,"CreationDate":"2018-11-29T10:36:00.000","Title":"Django CSS is displayed different on local and production environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In my index, I don't have a timestamp field. I need to fetch only new records added every day, instead of fetching all records every time. Is there any way to do this even though I don't have any timestamp field","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":53538534,"Users Score":0,"Answer":"Elasticsearch doesnot store such fields.\nYou can use ingest feature or obviously add a timestamp field.","Q_Score":0,"Tags":"python,elasticsearch,elasticsearch-py","A_Id":53540476,"CreationDate":"2018-11-29T11:57:00.000","Title":"How to get last modified record from Elasticsearch, when there is no timestamp field?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am currently diving deeper into tensorflow and I am a bit puzzled with the proper use of tf.nn.Conv2d(input, filter, strides, padding). Although it looks simple at first glance I cannot get my hear around the following issue:\nThe use of filter, strides, padding is clear to me. However what is not clear is the correct application of the input. \nI am coming from a reinforcement learning Atari (Pong) problem in which I want to use the network for batch training AND (with a certain probability) also for predictions in each step. That means, for training I am feeding the network a full batch of let's say 100 , each single unit consisting of 3 frames with size 160, 128. Using the NHWC format of tensorflow my input to input would be a tf.placeholder of shape (100,160,128,3). So for training I am feeding 100 160x128x3 packages.\nHowever, when predicting outputs from my network (going up or down with the pong paddle) in a certain situation I am only feeding the network one package of 160x128x3 (i.e. one package of three frames). Now this is where tensorflow crashes. It expects (100,160,128,3) but receives (1,160,128,3). \nNow I am puzzled. I obviously do not want to set the batch size to 1 and always feed only one package for training. But how can I proceed here? How shall this be implemented with tf.nn.conv2d? \nVery much appreciated if someone cann steer me into the right direction here\nThank you in advance for your help!\nKevin","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":221,"Q_Id":53540424,"Users Score":0,"Answer":"You need to set your Placeholder like follows\n tf.placeholder(shape=(None,160,128,3) ....) , with having None in the first dimension , your placeholder will be flexible to any value you feed either 1 or 100.","Q_Score":1,"Tags":"python,tensorflow,neural-network,deep-learning,reinforcement-learning","A_Id":53540809,"CreationDate":"2018-11-29T13:43:00.000","Title":"How to use Tensorflow tf.nn.Conv2d simultaneously for training and prediction?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This maybe stupid. But I'm finding problem in it.\nI'm working with Django, I have read docs.\nBut for the forms, there is class. If I use this then a form is generated in the view,\nBut actually I hardcoded the entire form, I just need to take the values from it.\nLike PHP.\nHow to achieve this, I don't wanna Django to generate my form.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":175,"Q_Id":53542569,"Users Score":0,"Answer":"You can access it with something along this line: request.GET['field_name']","Q_Score":0,"Tags":"python,html,django,forms","A_Id":53542887,"CreationDate":"2018-11-29T15:37:00.000","Title":"How to get values from Raw Html for in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can I run a normal python code using regular ML libraries (e.g., Tensorflow or sci-kit learn) in a Spark cluster? If yes, can spark distribute my data and computation across the cluster? if no, why?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":238,"Q_Id":53542955,"Users Score":2,"Answer":"Spark use RDD(Resilient distributed dataset) to distribute work among workers or slaves , I dont think you can use your existing code in python without dramatically adapting the code to spark specification , for tensorflow there are many options to distribute computing over multiple gpus.","Q_Score":0,"Tags":"python,apache-spark,distributed-computing","A_Id":53543239,"CreationDate":"2018-11-29T15:58:00.000","Title":"Using regular python code on a Spark cluster","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to normalize custom dataset of images. For that i need to compute mean and standard deviation by iterating over the dataset. How can I normalize my entire dataset before creating the data set?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3508,"Q_Id":53542974,"Users Score":1,"Answer":"What normalization tries to do is mantain the overall information on your dataset, even when there exists differences in the values, in the case of images it tries to set apart some issues like brightness and contrast that in certain case does not contribute to the general information that the image has. There are several ways to do this, each one with pros and cons, depending on the image set you have and the processing effort you want to do on them, just to name a few:\n\nLinear Histogram stetching: where you do a linear map on the current\nrange of values in your image and stetch it to match the 0 and 255\nvalues in RGB \nNonlinear Histogram stetching: Where you use a\nnonlinear function to map the input pixels to a new image. Commonly\nused functions are logarithms and exponentials. My favorite function\nis the cumulative probability function of the original histogram, it\nworks pretty well.\nAdaptive Histogram equalization: Where you do a linear\nhistogram stretching in certain places of your image to avoid doing\nan identity mapping where you have the max range of values in your original\nimage.","Q_Score":1,"Tags":"python,deep-learning,computer-vision,conv-neural-network,pytorch","A_Id":53543608,"CreationDate":"2018-11-29T15:59:00.000","Title":"Pytorch: Normalize Image data set","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to design an algorithm that takes in a resistance value and outputs the minimum number of resistors and the values associated with those resistors. I would like the algorithm to iterate through a set of resistor values and the values in the set can be used no more than n times. I would like some direction on where to start.\nSeries: Req = R1 + R2 +...\nParallel: (1\/Req) = (1\/R1) + (1\/R2)  +...\nInput:\n100000 (100k)\nSet: {30k, 50k, 80k, 200k}\nOutput: \n2 resistors in series: 50k + 50k \n2 resistors in parallel: 200k || 200k","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":241,"Q_Id":53543066,"Users Score":1,"Answer":"This is actually quite hard, best I can do is propose an idea for an algorithm for solving the first part, the concept of including parallels looks harder as well, but maybe the algorithm can be extended.\nIf you define a function \"best\", which takes a target resistance as input and outputs the minimal set of resistors that generates that resistance. E.G: if you only had 10K resistors, best(50K)=5*10K.\nThis function \"best\" has the following properties for a set of available resistors [A, B, C,...]:\n\nbest(A) = A for any A in the set.\nbest(Target) = min(best(Target-A) + A), best(Target-B) + B,...)\nbest(0)=0\nbest(x)=nonsense, if x<0 (remove these cases)\n\nThis can be used to reductively solve the problem. (I'd probably recommend storing the variables down the tree as you go along.\nHere's an example to illustrate a bit:\n\nAvailableSet = [10K, 100K]\nTarget = 120K\nFirst iteration:\nbest(120K) = min[ best(110K) + 10K, best(20K) + 100K]\ncalculate each subtree:\nbest(110K) = min[best(100K) + 10K, best(10K) + 100K]\nThis is now finalised as we can calculate everything in the min(_) by using the properties, so work back up the tree:\nbest(110K) = 100K + 10K ( I suppose if there is a tie like in this case pick a permuation randomly)\nbest(120K) = min[best(110K) + 10K , best(20K) + 100K] = ... = 100K + 10K + 10K\nThat should work as a solution to the first half of the problem, you may be able to extend this by adding extra properties, but it will make it harder to solve the problem reductively in this way.\nProbably the best way is to solve this first half of the problem and use a different algorithm to find the best solution using parallels and decide which is minimal in each case.","Q_Score":3,"Tags":"python,c++,algorithm","A_Id":53544202,"CreationDate":"2018-11-29T16:03:00.000","Title":"Algorithm to find minimum number of resistors from a set of resistor values. (C++ or 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have test that executes for 6 hours. After 2 hours, my driver slows down due to nature of Chrome browser. Solution is to close browser and restart it. I found out that doing driver.quit() helps in performance due to some internal memory that is being used which causes test to become slow. I am wondering is there option to use driver.quit() without closing drivers because i need cookies that were generated in that session as well as not killing Python script that is being ran at that moment.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1274,"Q_Id":53544235,"Users Score":1,"Answer":"The purpose of driver.quit() is to close all browser windows and terminate WebDriver session. So no, you cannot use driver.quit() without closing drivers - that's what it does.\nIn my opinion, you should look at why at all you have this issue:\n\nIs there really a reason to run 6 hours of testing within the same session? Of course there could be special circumstances, but good practice is to cut entire test collection into independent sets, where each set can run on its own, on \"clean\" environment (i.e. new browser session). Not only this will prevent the problem you are facing, but also improves reliability of the tests (i.e. domino effect when one tests messes all future test executions), ability to debug (imagine you have a problem with a test that runs on hour #3, and the problem is not reproducible when you run it alone, or you can't run it alone), and flexibility of the executions.\nWhy does the browser need to be restarted after 2 hours? No, it's not a \"nature of Chrome\". It's a bug somewhere - memory leak, or something else. It might be worth investigating what it is about. Because you can stop tests after 2 hours, but are you going to tell your users to not use your application for more than 2 hours? Even if it's a bug in Selenium driver, it might be worth reporting it to selenium developers for your, and everyone else's benefit.","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,selenium-chromedriver","A_Id":53544604,"CreationDate":"2018-11-29T17:10:00.000","Title":"Selenium webdriver closing without session","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to pass instance id after last \/ of my @action name method, and I seriously have no idea how...\nI have a UserViewSet, which url to access list is : \/users\/, then i have action called favorite_posts, which is detail=False because I'm filtering by current logged user, and the action refer to user posts, I wanna be able to pass the post_id like \/users\/favorite_posts\/post_id\/, because in this case it's more friendly to me than \/users\/1\/favorite_posts\/ which I could obtain setting detail=True.\nIs there any way to do that?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8755,"Q_Id":53544318,"Users Score":0,"Answer":"This only works with r because its regex use url_path=r'favorite_posts\/(?P<user_id>\\d+)', url_name='favorite-posts'","Q_Score":4,"Tags":"python,django,django-rest-framework","A_Id":65922314,"CreationDate":"2018-11-29T17:14:00.000","Title":"Django Rest Framework url_pattern of @action","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Given that a Pipfile exists, it seems that both would install all dependencies from the Pipfile, and update Pipfile.lock. So, what is the difference?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2190,"Q_Id":53545505,"Users Score":6,"Answer":"pipenv lock generates a consistent set of dependencies from Pipfile and writes that to Pipfile.lock. It doesn't change the installed packages.\npipenv install with no arguments would generate the same set of dependencies and install them into the virtualenv.\nI find the Pipenv documentation unclear.","Q_Score":4,"Tags":"python,pipenv,pipfile","A_Id":56903859,"CreationDate":"2018-11-29T18:35:00.000","Title":"What's the difference between `pipenv install` and `pipenv lock`?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to run a script on cluster (SBATCH file).\n\nHow can activate  my virtual environment (path\/to\/env_name\/bin\/activate).\n\nDoes I need only to add the following code to my_script.sh file?\nmodule load python\/2.7.14\nsource \"\/pathto\/Python_directory\/ENV2.7_new\/bin\/activate\"","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":16538,"Q_Id":53545690,"Users Score":2,"Answer":"Yes. Just make sure to insert those lines after the SBATCH ... lines and before any use of python.","Q_Score":13,"Tags":"python,slurm,sbatch","A_Id":53559868,"CreationDate":"2018-11-29T18:48:00.000","Title":"How to activate a specific Python environment as part of my submission to Slurm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I intend to use posenet in python and not in browser, for that I need the model as a frozen graph to do inference on. Is there a way to do that?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2638,"Q_Id":53548976,"Users Score":1,"Answer":"We currently do not have the frozen graph for inference publicly, however you could download the assets and run them in a Node.js environment.","Q_Score":1,"Tags":"python,tensorflow,neural-network,deep-learning,tensorflow.js","A_Id":53709777,"CreationDate":"2018-11-29T23:14:00.000","Title":"is there a way to download the frozen graph ( .pb file ) of PoseNet?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I work on web application that generates pdf, it returns generated pdf file. Previously I handled the pdf generation in the main process. My superior told me, that will potentially cause the app to stall, as django is synchronous.\nSo he suggest offload the process to celery, I tried it and have the idea about how to process it using celery. But I can't figure out the how to return the response to the client.\nI can return response that it's being processed, but what about the pdf file? return the possible url too? and send request every now and then?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":56,"Q_Id":53550436,"Users Score":1,"Answer":"Typically this is handled by making the HTTP interaction asynchronous as well.\nInstead of returning the PDF, you'd return a future link that the PDF will be available on or a processing status page, and the client can poll on that link to retrieve the PDF. Typically, this is done by returning HTTP 202 Accepted response.\nOther alternative that may be suitable in different circumstances is to return the response in a WebSocket push message. This may be suitable if your already have a WebSocket connection in the app or if you need lower latency than can be provided by polling. If the processing takes very long time (e.g hours), it may be appropriate to ask the user their email address (or take the email address from the user's profile) and send the user an email when they can retrieve the result.","Q_Score":1,"Tags":"python,django,celery","A_Id":53550560,"CreationDate":"2018-11-30T02:37:00.000","Title":"How can one return offloaded process response from celery?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to obtain an application variable (app user id) in before_execute(conn, clauseelement, multiparam, param) method. The app user id is stored in python http request object which I do not have any access to in the db event.\nIs there any way to associate a piece of sqlalchemy external data somewhere to fetch it in before_execute event later? \nAppreciate your time and help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":53551209,"Users Score":0,"Answer":"Answering my own question here with a possible solution :)\n\nFrom http request copied the piece of data to session object\nSince the session binding was at engine level, copied the data from session to connection object in SessionEvent.after_begin(session, transaction, connection). [Had it been Connection level binding, we could have directly set the objects from session object to connection object.]\n\nNow the data is available in connection object and in before_execute() too.","Q_Score":0,"Tags":"python,sqlalchemy","A_Id":53667953,"CreationDate":"2018-11-30T04:23:00.000","Title":"Sqlalchemy before_execute event - how to pass some external variable, say app user id?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm trying to figure out what the \"last-modified\" field indicates on user pages. It has only updated when I changed my profile information, but I'd like to know if there is a way to figure out when a user was last active?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":444,"Q_Id":53551468,"Users Score":0,"Answer":"That level of user information is not available via the API, likely for privacy reasons. There is an online boolean field available for the \/users endpoint, which appears to show the user's online status.","Q_Score":0,"Tags":"python,python-3.x,api,soundcloud","A_Id":53553647,"CreationDate":"2018-11-30T04:55:00.000","Title":"How to find when soundcloud user was last active using API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to load certain data using sessions (locally) and it has been working for some time but, now I get the following warning and my data that was loaded through sessions is no longer being loaded.\n\nThe \"b'session'\" cookie is too large: the value was 13083 bytes but\n  the header required 44 extra bytes. The final size was 13127 bytes but\n  the limitis 4093 bytes. Browsers may silently ignore cookies larger\n  than this.\n\nI have tried using session.clear(). I also opened up chrome developer tools and tried deleting the cookies associated with 127.0.0.1:5000. I have also tried using a different secret key to use with the session.\nIt would be greatly appreciated if I could get some help on this, since I have been searching for a solution for many hours.\nEdit:\nI am not looking to increase my limit by switching to server-side sessions. Instead, I would like to know how I could clear my client-side session data so I can reuse it.\nEdit #2:\nI figured it out. I forgot that I pushed way more data to my database, so every time a query was performed, the session would fill up immediately.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6403,"Q_Id":53551637,"Users Score":6,"Answer":"It looks like you are using the client-side type of session that is set by default with Flask which has a limited capacity of 4KB. You can use a server-side type session that will not have this limit, for example, by using a back-end file system (you save the session data in a file system in the server, not in the browser). To do so, set the configuration variable 'SESSION_TYPE' to 'filesystem'. \nYou can check other alternatives for the 'SESSION_TYPE' variable in the Flask documentation.","Q_Score":6,"Tags":"python,session,flask","A_Id":53554226,"CreationDate":"2018-11-30T05:17:00.000","Title":"Session cookie is too large flask application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to build an IoT device and looking forward to build something like this:\nSchematic:\n\nA python process which runs as a loop to interact with hardware components\nA TCP server(Pub-Sub) which takes commands from its clients and pass on to (1)\n(1) can interact with (2) to publish an event and (2) can interact with (1) to control the hardware\n\nHere is what I tried:\n\nUsing twisted, I created a pub sub service\ntried to command that service to emit events\nTCP listener on a Node.js serever to interact with Twisted TCP server\n\nThis is what I observed:\nNode.js server is able to send messages to Twisted server properly.\nTwisted blocks executing other code (Schematic:1) after calling reactor.run() as it starts listening on a port.\nI would like to have both the process run simultaneously and interact with each other.\nIs there a way to achieve this without using multithread or multiprocesses?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":53552588,"Users Score":0,"Answer":"I solved this using asyncio\nWe can run 2 loops which can be asynchronous, with asyncio.sleep in both the loops so other loop gets its turn to execute.\npython docs also has a tcp server example with asyncio, so there that solved my requirement","Q_Score":0,"Tags":"python,tcp,twisted","A_Id":54178503,"CreationDate":"2018-11-30T06:46:00.000","Title":"Run a TCP and looped process in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working in python and I have some problem with heapq.\nWhen I push an element into the heap I receive this error :\nTypeError: '<' not supported between instances of 'Point' and 'Point'\nPoint is my internal class.\nI push a tuple formed by (float,Point), in according with documentation, heapq should use float as a key, but it doesn't. To be more precise sometimes use float but not always.\nWhat is the problem?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":14008,"Q_Id":53554199,"Users Score":7,"Answer":"You need to define relative comparison operations in your Point class.\nThis means:\n__lt__(self, other) for <\n__le__(self,other) for <=\nand optionaly\n__gt__(self, other) for >\n__ge__(self, other) for >=.\nThe last two are optional because, if not specified, negation of le and lt are taken.\nGeneral structure of these methods is __name__(self, other), where other is object which will be compared to the self. Also, they return True or False.\nYou can also define __eq__ instead of all four above, which works like comparator in Java. This method should return positive integer if self is greater than other, 0 in case they are equal and negative integer if other is larger than self.","Q_Score":28,"Tags":"python,heapq","A_Id":53554283,"CreationDate":"2018-11-30T08:54:00.000","Title":"heapq push TypeError: '<' not supported between instances","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are trying to use the Structured Streaming with Kafka integration for one of the use case. While i was going through the Batch interval, i can see one-time trigger.\nIs it same like Daily once (batch processing)?\nBased on what it will trigger the next pull OR do we need to schedule it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":264,"Q_Id":53554902,"Users Score":1,"Answer":"If my understanding is right, there's no mechanism on scheduling next batch for one time trigger. So you may need to schedule it manually, something like crontab.","Q_Score":0,"Tags":"python,spark-structured-streaming","A_Id":53680714,"CreationDate":"2018-11-30T09:42:00.000","Title":"Structured Streaming - what is one time trigger?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is it possible to handle KeyboardInterrupt in the shell if no script is running?\nThe background of my question is the following:\nI use python to send commands to a motor controller via a socket connection. The function sends a target position of a motor to the controller and immediately returns, i.e. before the motor actually reaches its target position. Now it can happen that a user enters a wrong position and wants to interrupt the motor motion as quick as possible. This could be done by typing stop() which sends a stop command to the controller. But it would be more intuitive and faster if the motor could be stopped by pressing Ctrl+C.\nIs there a way to let python execute a function by pressing Ctrl+C while no script is running?\nI know how to handle the KeyboardInterrupt exception or the signal.SIGINT within a running script, but could not find any hints on how to solve my goal.\nI would be very grateful for any help!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":679,"Q_Id":53556392,"Users Score":0,"Answer":"KeyboardInterrupt send SIGINT signal (code 2).\nSo instead of hitting CTRL+C you could send KeyboardInterrupt with kill -2 <pid>.\nTo display your program pid use os.getpid().","Q_Score":0,"Tags":"python,keyboardinterrupt","A_Id":53556667,"CreationDate":"2018-11-30T11:10:00.000","Title":"Handle KeyboardInterrupt in the shell if no script is running","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently in R, once you load a dataset (for example with read.csv), Rstudio saves it as a variable in the global environment. This ensures you don't have to load the dataset every single time you do a particular test or change. \nWith Python, I do not know which text editor\/IDE will allow me to do this. E.G - I want to load a dataset once, and then subsequently do all sorts of things with it, instead of having to load it every time I run the script. \nAny points as to how to do this would be very useful","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":119,"Q_Id":53557674,"Users Score":0,"Answer":"It depends how large your data set is. \nFor relatively smaller datasets you could look at installing Anaconda Python Jupyter notebooks. Really great for working with data and visualisation once the dataset is loaded. For larger datasets you can write some functions \/ generators to iterate efficiently through the dataset.","Q_Score":0,"Tags":"python,global-variables,spyder","A_Id":53557733,"CreationDate":"2018-11-30T12:32:00.000","Title":"not having to load a dataset over and over","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to use a table of a database on a university server for test data for a project. \nI'm pretty new to databases and MySQL. My professor has send me username and password for the server. And an extra username&password for the MySQL server. \nIt took me a while but in the end I was able to connect to the server over ssh and then managed to navigate to $cd \/ $cd usr\/bin\/MySQL then logged in and found the data\/sentences in a table in one of the databases.\nNow there is the question: How do I get the data on my computer? I thought about a python script. But I cannot write a script what is logging in on a different server and then navigates to the MySQL folder to log in there to copy somehow the sentences in the table to a txt file I can use?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":482,"Q_Id":53558775,"Users Score":2,"Answer":"You might not need to ssh into the remote server; depending how their server and database are set up you may be able to connect a mysql client on your local machine to the database server. While there are security advantages to limiting where connections are permitted from, accessing a database at localhost is actually just a special case.\nYou might not even need a python script. You can export directly from mysql to a text file, or your client may have a feature to copy data directly from the remote server into a local database. \nI would guess that something like this would work for you, although getting the output into the format you want can be tricky:\nmysql -h \"host address\" -u \"username\" -p -e \"SELECT * FROM `table`\" > localFile.txt\nIf you wanted to do it with a python script running on the server as you're describing, you'll want to use the ssh credentials to do FTP over SSH to get the files back and forth. Your FTP client will certainly support that.","Q_Score":0,"Tags":"python,mysql,database,ssh","A_Id":53558994,"CreationDate":"2018-11-30T13:45:00.000","Title":"Copying tables from database from MySQL Server on different server to my computer","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a data set that have 43.462.904 milions of records. I try to do a group by with two variables and do an average of the third one. \nThe fnuction is: df1 = df.groupby([\"var1\", pd.Grouper(key=\"var2\"freq=\"MS\")]).mean()\nThe error that exit is the follow: IndexError: index 43462904 is out of bounds for size 43462904\nThe error is because I have a long dataset? The function with a few data function","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":162,"Q_Id":53558877,"Users Score":0,"Answer":"An array of length N can be indexed with 0 ... N-1:\n\narr = [0,1,2]\narr[0]: 0\narr[1]: 1\narr[2]: 2\nlen(arr): 3\n\nIn this example you try to access arr[3] which is invalid as it's the N+1st entry in the array.","Q_Score":0,"Tags":"python-3.x,group-by,compiler-errors,index-error","A_Id":53558970,"CreationDate":"2018-11-30T13:52:00.000","Title":"IndexError: index 43462904 is out of bounds for size 43462904","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering if the result of the test set is used to make the optimization of model's weights. I'm trying to make a model but the issue I have is I don't have many data because they are medical research patients. The number of patient is limited in my case (61) and I have 5 feature vectors per patient. What I tried is to create a deep learning model by excluding one subject and I used the exclude subject as the test set. My problem is there is a large variability in subject features and my model fits well the training set (60 subjects) but not that good the 1 excluded subject. \nSo I'm wondering if the testset (in my case the excluded subject) could be used in a certain way to make converge the model to better classify the exclude subject?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":204,"Q_Id":53559147,"Users Score":0,"Answer":"No , you souldn't use your test set for training to prevent overfitting  ,  if you use cross-validation principles you need exactly to split your data into three datasets  a train set which you'll use to train your model , a validation set to test different value of your  hyperparameters , and a test set to finally test your model , if you use all your data for training, your model will overfit obviously.\nOne thing to remember deep learning work well if you have a large and very rich datasets","Q_Score":0,"Tags":"python,keras,deep-learning","A_Id":53559275,"CreationDate":"2018-11-30T14:10:00.000","Title":"Does the test set is used to update weight in a deep learning model with keras?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am executing the query using pymysql in python. \n\nselect (sum(acc_Value)) from accInfo where acc_Name = 'ABC'\n\nThe purpose of the query is to get the sum of all the values in acc_Value column for all the rows matchin acc_Name = 'ABC'.\nThe output i am getting when using cur.fetchone() is \n\n(Decimal('256830696'),)\n\nNow how to get that value \"256830696\" alone in python. \nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":283,"Q_Id":53559241,"Users Score":-1,"Answer":"It's a tuple, just take the 0th index","Q_Score":0,"Tags":"python,pymysql","A_Id":53559488,"CreationDate":"2018-11-30T14:16:00.000","Title":"pymysql - Get value from a query","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Lambda function to send messages from a SQS deadletter to another SQS, but now I want to customize it, where I can specificate the range of the dates, type, another among, maybe from AWS CLI where I can specificate the configuration test event. Exist a way to do this? Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":628,"Q_Id":53559308,"Users Score":0,"Answer":"You can do this using lambda function which will first read SQS messages from queue1 and you can use that and  customize (add your logic of addition of strings\/dates) and then write to SQS queue 2 from your lambda function.","Q_Score":0,"Tags":"python-2.7,aws-lambda,amazon-sqs,dead-letter","A_Id":53563570,"CreationDate":"2018-11-30T14:20:00.000","Title":"How to filter messages that I want to send to SQS - 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 downloaded a dataset which contains a MATLAB file called 'depths.mat' which contains a 3-dimensional matrix with the dimensions 480 x 640 x 1449. These are actually 1449 images, each with the dimension 640 x 480. I successfully loaded it into python using the scipy library but the problem is the unusual order of the dimensions. This makes Python think that there are 480 images with the dimensions 640 x 1449. I tried to reshape the matrix in python, but a simple reshape operation did not solve my problem.\nAny suggestions are welcome. Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":53560638,"Users Score":2,"Answer":"You misunderstood. You do not want to reshape, you want to transpose it. In MATLAB, arrays are A(x,y,z) while in python they are P[z,y,x]. Make sure that once you load the entire matrix, you change the first and last dimensions. \nYou can do this with the swapaxes function, but beware! it does not make a copy nor change the the data, just changes how the higher level indices of nparray access the internal memory. Your best chances if you have enough RAM is to make a copy and dump the original.","Q_Score":0,"Tags":"python-3.x,matlab","A_Id":53560972,"CreationDate":"2018-11-30T15:43:00.000","Title":"Unusual order of dimensions of an image matrix in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just learnt about GCP Composer and am trying to move the DAGs from my local airflow instance to cloud and had a couple of questions about the transition. \n\nIn local instance I used HiveOperator to read data from hive and create tables and write it back into hive. If I had to do this in GCP how would this be possible? Would I have to upload my data to Google Bucket and does the HiveOperator work in GCP?\nI have a DAG which uses sensor to check if another DAG is complete, is that possible on Composer?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":53560978,"Users Score":0,"Answer":"Composer have connection store. See menu Admin--> Connection. Check connection type available.\nSensors are available.","Q_Score":1,"Tags":"python,google-cloud-platform,airflow,google-cloud-composer","A_Id":53672600,"CreationDate":"2018-11-30T16:03:00.000","Title":"Creating Airflow DAGs on GCP Composer","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I just learnt about GCP Composer and am trying to move the DAGs from my local airflow instance to cloud and had a couple of questions about the transition. \n\nIn local instance I used HiveOperator to read data from hive and create tables and write it back into hive. If I had to do this in GCP how would this be possible? Would I have to upload my data to Google Bucket and does the HiveOperator work in GCP?\nI have a DAG which uses sensor to check if another DAG is complete, is that possible on Composer?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":53560978,"Users Score":0,"Answer":"Yes, Cloud Composer is just managed Apache Airflow so you can do that.\nMake sure that you use the same version of Airflow that you used locally. Cloud Composer supports Airflow 1.9.0 and 1.10.0 currently.","Q_Score":1,"Tags":"python,google-cloud-platform,airflow,google-cloud-composer","A_Id":53564941,"CreationDate":"2018-11-30T16:03:00.000","Title":"Creating Airflow DAGs on GCP Composer","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am experimenting with VSCode to edit a python program I have.  It is about 3000 lines long.  I have loaded Microsoft's Python extension for VSCode. Most things work well -- linting, etc.\nHowever, when I use F12 to jump to a definition of function or method, it can take 10 or 15 seconds to complete.  Finding the usages of a function is (usually and surprisingly) must faster.  All symbols I am searching for are in this same file.\nDo others have this problem?  I don't think it is my machine's limitations, because I've been using VSCode with TypeScript for 6 months, and in that environment, which included 1000s of files, jumping to definitions was always very fast.\nThanks.\nVic","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":580,"Q_Id":53562204,"Users Score":0,"Answer":"Really this should go onto the github issue tracker for the extension. not here","Q_Score":2,"Tags":"python,visual-studio-code","A_Id":54347840,"CreationDate":"2018-11-30T17:26:00.000","Title":"VSCode and Python extension: Navigating to symbols is very 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I finnally managed to join two big DataFrames on a big machine of my school (512G memory). At the moment we re two people using the same machine, the other one is using about 120G of the memory, after I called the garbage collecter we get to 420G.\nI want to save the DataFrame to memory so I then I can reuse it easily and move it on another machine, I have tried to export it to a parquet file, but I get a memory error...\nSo how can I manage to dump that Dataframe on the hard drive in purpose of reusing it without running into memory error when memory is already near full ?\nThank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1372,"Q_Id":53564278,"Users Score":0,"Answer":"There are several options. You can pickle the dataframe or you can use hdf5 format. \nThese will occupy less memory. Also when you load it next time, it would be quicker then other formats.","Q_Score":1,"Tags":"python,pandas","A_Id":53564337,"CreationDate":"2018-11-30T20:12:00.000","Title":"Pandas memory error when saving DataFrame to file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to let the user start downloading a file when it's not ready yet. I don't want to send user to some page saying \"Wait 30 seconds, file is being prepared.\" I can't generate the file in advance. I need user to click\/send form, choose download location and start downloading. Generated file will be zip, so I imagine, that it should be possible to send file name with first few bytes of zips (which are always same) and before the file is generated don't confirm that tcp packet was send correctly or something like that, and after the file is generated send the rest.\nHow do I do that? Is there any tool which can do that. Or is there some better way? More high level solution better, C isn't my strong suit. Preferably in Python. Thanks.\nFile being generated is zip and before it's prepared there isn't really anything to send yet. Basically according to input I generate set of files (which takes few dozens seconds), than I zip them and serve to user. My application is in python on linux but which server I'll use isn't really important.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":368,"Q_Id":53564699,"Users Score":0,"Answer":"Usually, application like this will be implement in two parts, like a ticket system.\n\nWhen user click\/submit the form, the form will send request to a service that will start generating the file as a background process, then (without waiting for the file to generate) it will generate a ticket\/hash that represent the new file and then redirect user to a new URL, e.g. \/files\/<random-hash>\nOn this new URL, \/files\/<random-hash>, while the files is not ready, it'll return a simple HTML page that show message to user to wait, and have a script on the page that will keep refreshing the page every few seconds. As long as the files is not ready, it'll keep showing this message, but once the file is ready, this URL will return the actual files content in its response with appropriate mime-header instead.\n\nThe solution is quite simple to implement using a database and some programming. Though, if you're looking for an already-made tool ready to use, I'm sorry I'm not familiar with one. Hope this help.","Q_Score":3,"Tags":"python,http,tcp,server","A_Id":53668981,"CreationDate":"2018-11-30T20:48:00.000","Title":"How to let user download file while it's being generated","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to let the user start downloading a file when it's not ready yet. I don't want to send user to some page saying \"Wait 30 seconds, file is being prepared.\" I can't generate the file in advance. I need user to click\/send form, choose download location and start downloading. Generated file will be zip, so I imagine, that it should be possible to send file name with first few bytes of zips (which are always same) and before the file is generated don't confirm that tcp packet was send correctly or something like that, and after the file is generated send the rest.\nHow do I do that? Is there any tool which can do that. Or is there some better way? More high level solution better, C isn't my strong suit. Preferably in Python. Thanks.\nFile being generated is zip and before it's prepared there isn't really anything to send yet. Basically according to input I generate set of files (which takes few dozens seconds), than I zip them and serve to user. My application is in python on linux but which server I'll use isn't really important.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":368,"Q_Id":53564699,"Users Score":0,"Answer":"The client would most likely timeout(or wait 30 seconds without notification) while the file was prepared.  I would use a stream compression algorithm(gzip) to compress the file(s) while in transit. This would not result in the best compression, but would serve the files in a predictable manner.  \nInvestigate the \"Content-Encoding: gzip\" HTTP header.","Q_Score":3,"Tags":"python,http,tcp,server","A_Id":53624072,"CreationDate":"2018-11-30T20:48:00.000","Title":"How to let user download file while it's being generated","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently developing a Twitter content-based recommender system and have a word2vec model pre-trained on 400 million tweets.\nHow would I go about using those word embeddings to create a document\/tweet-level embedding and then get the user embedding based on the tweets they had posted? \nI was initially intending on averaging those words in a tweet that had a word vector representation and then averaging the document\/tweet vectors to get a user vector but I wasn't sure if this was optimal or even correct. Any help is much appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":312,"Q_Id":53565271,"Users Score":0,"Answer":"You are on the right track with averaging the word vectors in a tweet to get a \"tweet vector\" and then averaging the tweet vectors for each user to get a \"user vector\". Whether these average vectors will be useful or not depends on your learning task. Hard to say if this average method will work or not without trying since it depends on how diverse is your data set in terms of variation between the words used in tweets by each user.","Q_Score":1,"Tags":"python,twitter,nlp,word2vec,word-embedding","A_Id":53566219,"CreationDate":"2018-11-30T21:40:00.000","Title":"word2vec: user-level, document-level embeddings with pre-trained model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently developing a Twitter content-based recommender system and have a word2vec model pre-trained on 400 million tweets.\nHow would I go about using those word embeddings to create a document\/tweet-level embedding and then get the user embedding based on the tweets they had posted? \nI was initially intending on averaging those words in a tweet that had a word vector representation and then averaging the document\/tweet vectors to get a user vector but I wasn't sure if this was optimal or even correct. Any help is much appreciated.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":312,"Q_Id":53565271,"Users Score":2,"Answer":"Averaging the vectors of all the words in a short text is one way to get a summary vector for the text. It often works OK as a quick baseline. (And, if all you have, is word-vectors, may be your main option.) \nSuch a representation might sometimes improve if you did a weighted average based on some other measure of relative term importance (such as TF-IDF), or used raw word-vectors (before normalization to unit-length, as pre-normalization raw magnitudes can sometimes hints at strength-of-meaning). \nYou could create user-level vectors by averaging all their texts, or by (roughly equivalently) placing all their authored words into a pseudo-document and averaging all those words together. \nYou might retain more of the variety of a user's posts, especially if their interests span many areas, by first clustering their tweets into N clusters, then modeling the user as the N centroid vectors of the clusters. Maybe even the N varies per user, based on how much they tweet or how far-ranging in topics their tweets seem to be. \nWith the original tweets, you could also train up per-tweet vectors using an algorithm like 'Paragraph Vector' (aka 'Doc2Vec' in a library like Python gensim.) But, that can have challenging RAM requirements with 400 million distinct documents. (If you have a smaller number of users, perhaps they can be the 'documents', or they could be the predicted classes of a FastText-in-classification-mode training session.)","Q_Score":1,"Tags":"python,twitter,nlp,word2vec,word-embedding","A_Id":53612424,"CreationDate":"2018-11-30T21:40:00.000","Title":"word2vec: user-level, document-level embeddings with pre-trained model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using spyder from time to time, on both linux and windows platforms. The behavior w.r.t. adjusting imported libraries is different on the two:\n\non linux, while running the same kernel (no restart needed), in the middle of some computations, i can adjust some library code, re-select a block of code, run it and i see the new library code being used\non windows, i have to restart the kernel to achieve this effect, as re-selecting keeps running the old code, initially loaded\n\nI am wondering if this has to do with the OS difference or perhaps there is something wrong with the windows version of spyder\/anaconda i have. How can i achieve the same behavior in windows?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":22,"Q_Id":53565886,"Users Score":1,"Answer":"Well, following Carlos' suggestion i updated to anaconda3 5.2.0 on windows (it's a work computer with company policies in place, cannot update to any version i wish), and i have spyder 3.2.8 on it and this version of spyder has the feature i was looking for, unlike the previous one.","Q_Score":1,"Tags":"python-3.x,spyder","A_Id":53675526,"CreationDate":"2018-11-30T22:42:00.000","Title":"under windows, python3 library changes are not seen in spyder until kernel is restarted","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Since Postgres supports JSON fields, is that more preferential than say saving each config item in a row in some table the way WP still does?\nFull disclosure: I'm asking as a Django user new to postgres.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":115,"Q_Id":53566994,"Users Score":2,"Answer":"It depends. Here are some things to think about:\n\nDoes the data structure map well to JSON? Try to visualize it. Is the data more relational (think of links to other data), or a hierarchy? If the data you are  storing needs to mix a lot with relationally stored data, it could become a pain.\nDo you do complicated searches on these fields? There is powerful functionality for querying jsonb fields, but there will likely be complications and learning involved. I like the power of querying jsonb and manipulating it in my queries, but it's never as easy or natural to me as regular SQL.\nWill your ORM and any other tools like query builders play well with it? It's an especially important question if you are using older technology. If you use an ORM, it may become annoying to have to work with plain SQL just to do jsonb queries.\nLazy loading is another consideration. If you have a lazy load strategy, it may or may not translate well into jsonb fields. If your lazy loading strategy is complex, it may require some work to get it to work well with jsonb fields.\nA good strategy for serialization and deserialization will be necessary. If you don't have a good implementation of that, it will get clumsy.\n\nBy the way...I am a big advocate for using jsonb. In my opinion, it has been a good game changer. So don't think that I am discouraging it. That said, if you just try to make everything jsonb, you will probably soon regret it. You just need to sort of evaluate what works best for each case. In general, I think it does work well for config, usually, though I'd have to know about the particular case.I hope this helps a bit!","Q_Score":0,"Tags":"python,django,postgresql","A_Id":53567055,"CreationDate":"2018-12-01T01:27:00.000","Title":"Saving data in rows in a Config table vs. saving as keys in a Postgres JSONField--which is better?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a script that I use to send HTTP requests and Websocket data and I had to use an external program as I couldn't find a Websocket library that supports SOCKS5 proxies.   \nSo, I've found about Proxifier and tried running my Python script with a rule that I have written in Proxifier but it didn't yield and good result.  \nOther programs seemed to work fine, chrome.exe managed to go through the proxy, and I have no idea why my Python script won't go...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":847,"Q_Id":53570121,"Users Score":0,"Answer":"Same issues with proxifier.\nSeems reason in portable version of application.\nTried standard version and everything works fine.\nHope this helps.","Q_Score":0,"Tags":"python,python-3.x,proxy","A_Id":55796085,"CreationDate":"2018-12-01T11:02:00.000","Title":"Running a Python script through Proxifier","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a data structure (not sure if it should be a list or a dictionary) but I don't know it's size in advance. How can I proceed to create this structure and add an unknown ammount of elements to it by input?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4234,"Q_Id":53570829,"Users Score":1,"Answer":"You can use a list in python, you can use the list.append(item) method in order to insert new elements into it, you don't have to specify the size of the list in order to use it and it will grow as your append more items.","Q_Score":1,"Tags":"python,arrays,list,dictionary","A_Id":53570862,"CreationDate":"2018-12-01T12:36:00.000","Title":"Creating a data structure with unknown size python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"can some one please help me to solve the mentioned error? I uninstalled the tika and reinstalled it but getting error. I don't have idea about how to solve this error.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":242,"Q_Id":53571607,"Users Score":0,"Answer":"You need to kill apache server process or you can simply restart your machine and re-run your script","Q_Score":0,"Tags":"python-2.7,apache-tika,tika-server","A_Id":56686101,"CreationDate":"2018-12-01T14:08:00.000","Title":"Getting 422 response from apache Tika with python 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some python code I'm writing that's interfacing real-world hardware.  It's replacing a hardware PLC.  What I'm planning is when an event trigger happens to kick off multiple threads to effect certain 'on' actions, then go to sleep for a set interval, and then perform the corresponding 'off' actions.  For example:  at trigger, spawn a thread that turns the room lights on.  Then go to sleep for 20 minutes.  Then turn the lights off and terminate the thread.\nHowever, I will have situations where the event trigger re-occurs.  In that scenario I want the entire sequence to start over.  My original plan was to use threads with unique names, so if a trigger occurs, check if the 'lights' thread exists, if if does kill it, and then re-spawn a new 'lights' thread.  But in researching around these parts, it seems like people are suggesting that killing a thread is a Very Bad Thing to do.  \nSo what would a better approach be to handling my situation?  Note that in my example I only talked about one thread- but in reality there will be many different threads controlling many different devices.\nThis is python 3.x on a Rapberry Pi running raspbian, using rpi.gpio to monitor my input triggers and an I2C relay board for my output devices in case any of that info is useful.  \nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":53571617,"Users Score":0,"Answer":"the reason for not killing off threads is that it's easy to do it in a way that doesn't give the code any chance to \"clean up\" appropriately.  i.e. finally blocks not run, resources leaked, etc\u2026\nthere are various ways to get around this, you could wait on an Event as suggested by @J\u00e9r\u00f4me, treating a timeout as a signal to carry on\nasyncio is another alternative as Cancelled exceptions tend to get used to clean up nicely and don't have the problems associated with killing native threads","Q_Score":0,"Tags":"python,multithreading,raspbian","A_Id":53571806,"CreationDate":"2018-12-01T14:09:00.000","Title":"Best way to restart (from beginning) a thread that is sleeping?","Data 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 save function in a program im doing for bubbling\/ballooning drawings. The only thing I can't get to work is save a \"work copy\". As if a drawing gets revision changes, you don't need to redo all the work. Just load the work copy, and add\/remove\/re-arrage bubbles.\nI'm using tkinter and canvas. And creates ovals and text for bubbles. But I can't figure out any good way to save the info from the oval\/text objects.\nI tried to pickle the whole canvas, but that seems like it won't work after some googeling.\nAnd pickle every object when created seems to only save the object id. 1, 2 etc. And that also won't work since some bubbles will be moved and receive new coordinates. They might also have a different color, size etc.\nIn my next approach I'm thinking of saving the whole \"can.create_oval( x1, y1, x2, y2, fill = fillC, outli....\" as a string to a txt and make the function to recreate a with eval()\nAny one have any good suggestion on how to approach this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":597,"Q_Id":53571619,"Users Score":1,"Answer":"There is no built-in way to save and restore the canvas. However, the canvas has methods you can use to get all of the information about the items on the canvas. You can use these methods to save this information to a file and then read this file back and recreate the objects. \n\nfind_all - will return an ordered list of object ids for all objects on the canvas\ntype - will return the type of the object as a string (\"rectangle\", \"circle\", \"text\", etc)\nitemconfig - returns a dictionary with all of the configuration values for the object. The values in the dictionary are a list of values which includes the default value of the option at index 3 and the current value at index 4. You can use this to save only the option values that have been explicitly changed from the default.\ngettags - returns a list of tags associated with the object","Q_Score":1,"Tags":"python,python-3.x,canvas,tkinter,pickle","A_Id":53572078,"CreationDate":"2018-12-01T14:09:00.000","Title":"Saving objects from tk canvas","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a programming and getting an expected ValueError output of:\nValueError: {'code': -123, 'message': 'This is the error'}\nI cannot figure out how to parse this data and just take the code (or message) value. How can I just get the code value of the ValueError?\nI have tried the following:\n\ne.code\n\nAttributeError: 'ValueError' object has no attribute 'code'\n\ne['code']\n\nTypeError: 'ValueError' object is not subscriptable\n\njson.loads(e)\n\nTypeError: the JSON object must be str, bytes or bytearray, not 'ValueError'\n\n\nWhat is the pythonic way of doing this?\nEdit\nThe one thing that does work is taking the string index, but I do not want to do this, as I feel it is not very pythonic.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":3385,"Q_Id":53571885,"Users Score":1,"Answer":"ValueError is a dict type. \nSo you can use\n    e.get(\"key\")\nto reach any field inside dict.","Q_Score":1,"Tags":"python,python-3.x,error-handling,valueerror","A_Id":53572034,"CreationDate":"2018-12-01T14:44:00.000","Title":"How to parse a ValueError in Python without string parsing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to see an updated version of my Dataframe every time I run the code in Spyder? I can see the name and size of the Dataframe in \"Variable explorer\" but I don't like that I have to double click it to open it.\nOr is there a way to have the Dataframe (that I have already earlier opened by double clicking it) update after I run the code again?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":219,"Q_Id":53571920,"Users Score":4,"Answer":"(Spyder maintainer here) Unfortunately this is not possible as of September 2020. However, we'll try to implement this functionality in Spyder 5, to be released in 2021.","Q_Score":4,"Tags":"python,pandas,dataframe,spyder","A_Id":53572155,"CreationDate":"2018-12-01T14:48:00.000","Title":"How to see updated Dataframe after I run the code again in Spyder (without doubleclicking from Variable explorer after EVERY run)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created an workflow (contains few tasks). It is hourly execution. Workflow should be triggered only if another instance of workflow is not running at same time. If it is running, workflow execution should be skipped for that hour.\nI checked with \"depends_on_past\" but couldn't get it.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":536,"Q_Id":53573857,"Users Score":1,"Answer":"Set the max_active_runs on your DAG to 1 and also catchup to False","Q_Score":1,"Tags":"python,airflow","A_Id":53574587,"CreationDate":"2018-12-01T18:33:00.000","Title":"Airflow: how to specify condition for hourly workflow like trigger only if currently same instance is not running?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"The only way I can find of adding new data to a TinyDB table is with the table.insert() method. However this appends the entry to the end of the table, but I would like to maintain the sequence of entries and sometimes I need to insert into an arbitrary index in the middle of the table. Is there no way to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":260,"Q_Id":53575563,"Users Score":0,"Answer":"There is no way to do what you are asking.  Normally, the default index created tracks insertion order.  When you add data, it will go at the end. If you need to maintain a certain order, you could create a new property the handle that case, and retrieve with a sort on that property.  \nIf you truly want to insert in a specific id, you would need to add some logic to cascade the documents down.  The logic would flow as:\n\nInsert a new record which is equal to the last record.\nThen, go backwards and cascade the records to the new open location\nStop when you get to the location you need, and update the record with what you want to insert by using the ID.\n\nThe performance would drag since you are having to shift the records down. There are other ways to maintain the list - it would be similar to inserting a record in the middle of an array.  Similar methods would ally here. Good Luck!","Q_Score":0,"Tags":"python,tinydb","A_Id":53576107,"CreationDate":"2018-12-01T22:23:00.000","Title":"TinyDB insert in between table rows","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i can connect locally to my mongodb server with the address 0.0.0.0\/0. However, when I deploy my code to the cloud I get the error deploy to google cloud function.\ngoogle cloud function with python 3.7 (beta)\natlas mongo db\npython lib:\n-pymongo\n-dnspython\nError: function crashed. Details:\nAll nameservers failed to answer the query _mongodb._tcp.**-***.gcp.mongodb.net. IN SRV: Server ***.***.***.*** UDP port 53 answered SERVFAIL\nTraceback (most recent call last): File \"\/env\/local\/lib\/python3.7\/site-packages\/pymongo\/uri_parser.py\", line 287, in _get_dns_srv_hosts results = resolver.query('_mongodb._tcp.' + hostname, 'SRV') File \"\/env\/local\/lib\/python3.7\/site-packages\/dns\/resolver.py\", line 1132, in query raise_on_no_answer, source_port) File \"\/env\/local\/lib\/python3.7\/site-packages\/dns\/resolver.py\", line 947, in query raise NoNameservers(request=request, errors=errors) dns.resolver.NoNameservers: All nameservers failed to answer the query _mongodb._tcp.**mymongodb**-r091o.gcp.mongodb.net. IN SRV: Server ***.***.***.*** UDP port 53","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3909,"Q_Id":53576199,"Users Score":4,"Answer":"finally after stuck 2 day, goblok banget semaleman\njust change connection \nfrom \n\nSRV connection string (3.6+ driver)\n\nto \n\nStandard connection string (3.4+ driver)\n\nmongodb:\/\/<USERNAME>:<PASSWORD>@<DATABASE>-shard-00-00-r091o.gcp.mongodb.net:27017,<COLLECTION>-shard-00-01-r091o.gcp.mongodb.net:27017,<COLLECTION>-shard-00-02-r091o.gcp.mongodb.net:27017\/test?ssl=true&replicaSet=<COLLECTION>-shard-0&authSource=admin&retryWrites=true\nor you can see your connection string in atlas mongodb.\nidk why can`t connect with srv connection string in google cloud functions, maybe not suppot now, or just misconfiguration.","Q_Score":3,"Tags":"python,mongodb,google-cloud-functions,mongodb-atlas","A_Id":53582632,"CreationDate":"2018-12-02T00:09:00.000","Title":"All nameservers failed to answer UDP port 53 Google cloud functions python 3.7 atlas mongodb","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have an array of data points of dimension n by 2, where the second dimension $2$ corresponds to the real part and imaginary part of a complex number. \nNow I know the data points will intersect the unit circle on the plane for a couple of times. What I want to implement is: suppose the path starts will some color, it changes to another color when it touches the unit circle on the plane and changes color again if it intersects the unit circle again. I am not sure whether there is an easy to implement this.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1989,"Q_Id":53577532,"Users Score":0,"Answer":"The simplest way to do this is probably to implement the logic outside the plot, by assigning a different group to each point defined by your circle-crossing concept.\nOnce you have these group-indexes it's a simple plt.scatter, using the c (stands for \"color\") input.  \nGood luck!","Q_Score":0,"Tags":"python,matplotlib","A_Id":53577656,"CreationDate":"2018-12-02T04:56:00.000","Title":"How do I alternate the color of a scatter plot in matplotlib?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I already use python IDE PyCharm and have installed the package tensorflow but when I use the terminal and give an input to the tensor board as follows\n--logdir = '\/user\/....'\uff0c\nit shows command not found?\nis  there still something Im missing like setting the tenor flow path or any thing else?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2211,"Q_Id":53579488,"Users Score":0,"Answer":"Maybe you need to activate your relevant environment via source activate some_conda_env.\nIf it isn't either of those you're going to need to give more information than you've given in the question (versions, environment, etc.)\n\nUpdate (due to discussion in comments):\nIt seems that tensorboard is not in your search path.\nThat can be fixed, but meanwhile you can just run tensorboard by using the full path. e.g.  \/my\/full\/path\/to\/tensorboard --logdir='\/path\/to\/logger' etc.\nGood luck!","Q_Score":0,"Tags":"python,tensorflow","A_Id":53579585,"CreationDate":"2018-12-02T10:47:00.000","Title":"tensorboard: command not found, when I use","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Pyro4 in a distributed system. My problem is that after two networks connect there can be many nameserver. It is ok for me but if any of them is empty  (has no objects registered) my network can fail . \nThis is because I am implementing chord and I need to know if there is any chord node running already (if the empty nameserver responds then two chord rings will be created.\nIs there any way to kill a nameserver if it is empty?\nMy code is in python3. Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":180,"Q_Id":53582748,"Users Score":0,"Answer":"Pyro's name server assumes it is running all the time: you never know if there will be someone a bit later that wants to register a new name. If you really need it to auto shutdown, you'll have to either wrap the default name server in some custom code, or use some form of watchdog process that kills the name server if it detects that it has 0 entries.\nYou can get the number of entries via a regular Pyro call to the nameserver: ns.count().  For obvious reasons, it's not possible to remotely shutdown the nameserver via such a Pyro API call, hence the need of a watch dog process.","Q_Score":0,"Tags":"python,pyro,chord,pyro4","A_Id":53584087,"CreationDate":"2018-12-02T17:24:00.000","Title":"Pyro4 kill empty nameserver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on my first real django project, and was fiddling around with the css, but the changes I made did not have any effect on the site. I tried changing things on all 3 of the css files but nothing changed. I then deleted the files (from the project I still have them), and still nothing changed. My site is getting styled, I checked all of my html to make sure there was no inline style in there. All the html files are working, when I change them the site changes. Is this some weird caching thing? I've tried rerunning the server several times and still my site is getting style, seemingly from nowhere. Anyone have any ideas?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":53583363,"Users Score":0,"Answer":"Try opening your site from now on in incognito mode. I think it is some weird caching thing so maybe clear your cache too. When developing I just use igcognito and static updates just fine.","Q_Score":0,"Tags":"python,django,django-templates","A_Id":53583671,"CreationDate":"2018-12-02T18:35:00.000","Title":"Phantom style in django project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to generate three different sized output vectors namely 25d, 50d and 75d. I am trying to do so by training the same dataset using the word2vec model. I am not sure how I can get three vectors of different sizes using the same training dataset. Can someone please help me get started on this? I am very new to machine learning and word2vec. Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":25,"Q_Id":53586254,"Users Score":1,"Answer":"You run the code for one model three times, each time supplying a different vector_size parameter to the model initialization.","Q_Score":0,"Tags":"python,vector,word2vec","A_Id":53586551,"CreationDate":"2018-12-03T01:15:00.000","Title":"Different sized vectors in word2vec","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed anaconda ver5.3.1 which uses python 3.7.\nI encountered the following error;\n\n\"Missing required dependencies {0}\".format(missing_dependencies))\n   ImportError: Missing required dependencies ['numpy']\n\nI have upgraded numpy, pandas to the latest version using conda but the same error appears. To fix this problem, I have to downgrade to an older anaconda version which uses python 3.6\nI am using Windows 10.\nEDIT: I just discovered this problem is more related to pycharm than anaconda. I got this error while running pycharm in debug mode. However, when I run the same python script in Anaconda prompt console, there is no error. \nWhat are some possible pycharm settings I should check to fix this problem? Are there ways to configure pycharm to output more verbose error messages?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5309,"Q_Id":53587001,"Users Score":1,"Answer":"Your pycharm created a new environment for your project I suspect. Maybe it copied across the anaconda python.exe but not all the global packages.\nIn pycharm you can go to the project properties where you can see a list of all the packages available, and add additional packages. Here you can install Numpy.\nFile --> Settings --> Project:  --> Project Interpreter","Q_Score":1,"Tags":"python,python-3.x,pycharm,anaconda,conda","A_Id":53609235,"CreationDate":"2018-12-03T03:16:00.000","Title":"Missing required dependencies ['numpy'] for anaconda ver5.3.1 on pycharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So instead of having data-item-url=\"https:\/\/miglopes.pythonanywhere.com\/ra%C3%A7%C3%A3o-de-c%C3%A3o-purina-junior-10kg\/\"\nit keeps on appearing \ndata-item-url=\"http:\/\/localhost\/ra%C3%A7%C3%A3o-de-c%C3%A3o-purina-junior-10kg\/\"\nhow do i remove the localhost so my snipcart can work on checkout?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":53587049,"Users Score":0,"Answer":"Without more details of where this tag is coming from it's hard to know for sure... but most likely you need to update your site's hostname in the Wagtail admin, under Settings -> Sites.","Q_Score":0,"Tags":"localhost,wagtail,pythonanywhere,snipcart","A_Id":53600830,"CreationDate":"2018-12-03T03:23:00.000","Title":"data-item-url is on localhost instead of pythonanywhere (wagtail + snipcart project)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Assume that we have 1000 words (A1, A2,..., A1000) in a dictionary. As fa as I understand, in words embedding or word2vec method, it aims to represent each word in the dictionary by a vector where each element represents the similarity of that word with the remaining words in the dictionary. Is it correct to say there should be 999 dimensions in each vector, or the size of each word2vec vector should be 999?\nBut with Gensim Python, we can modify the value of \"size\" parameter for Word2vec, let's say size = 100 in this case. So what does \"size=100\" mean? If we extract the output vector of A1, denoted (x1,x2,...,x100), what do x1,x2,...,x100 represent in this case?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2261,"Q_Id":53587960,"Users Score":4,"Answer":"It is not the case that \"[word2vec] aims to represent each word in the dictionary by a vector where each element represents the similarity of that word with the remaining words in the dictionary\". \nRather, given a certain target dimensionality, like say 100, the Word2Vec algorithm gradually trains word-vectors of 100-dimensions to be better and better at its training task, which is predicting nearby words. \nThis iterative process tends to force words that are related to be \"near\" each other, in rough proportion to their similarity - and even further the various \"directions\" in this 100-dimensional space often tend to match with human-perceivable semantic categories. So, the famous \"wv(king) - wv(man) + wv(woman) ~= wv(queen)\" example often works because \"maleness\/femaleness\" and \"royalty\" are vaguely consistent regions\/directions in the space. \nThe individual dimensions, alone, don't mean anything. The training process includes randomness, and over time just does \"whatever works\". The meaningful directions are not perfectly aligned with dimension axes, but angled through all the dimensions. (That is, you're not going to find that a v[77] is a gender-like dimension. Rather, if you took dozens of alternate male-like and female-like word pairs, and averaged all their differences, you might find some 100-dimensional vector-dimension that is suggestive of the gender direction.)\nYou can pick any 'size' you want, but 100-400 are common values when you have enough training data.","Q_Score":2,"Tags":"python,gensim,word2vec,word-embedding","A_Id":53601635,"CreationDate":"2018-12-03T05:29:00.000","Title":"What is the meaning of \"size\" of word2vec vectors [gensim library]?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Google Assistant on Raspberry Pi 3. My program has some output as fixed audio. Can I use Raspberry Pi 3 to speech it? The problem is that when using other programs to read, I have to turn off google assistant and turn on when finished speechding. Because they all use the same output device","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":291,"Q_Id":53589322,"Users Score":1,"Answer":"You can send text queries to the Assistant, and you could theoretically send a query in the background of \"Repeat after me X\" and the Assistant will repeat it. That may work for static or simple text.","Q_Score":0,"Tags":"python,raspberry-pi3,google-assistant-sdk","A_Id":53599234,"CreationDate":"2018-12-03T07:36:00.000","Title":"How use google assistant as a text to speech tool Raspberry","Data Science and Machine Learning":0,"Database and SQL":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 tools should be used to create GUI app in python? I imagine something similar to WinForms or WPF. It would be best if there were tools to design app visually. I think something similar to Java FX\/Swing will do, too.\nI tried tkinter framework, but it was impossible to use, it's very different from WinForms for example. In my app I will need canvas or something to draw few figures.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":200,"Q_Id":53591060,"Users Score":1,"Answer":"I would recommend wxPython and wxGlade. The later includes a tutorial that should get you started with wxPython as well.\nDepending on the type of drawing, matplotlib might be an option. wxGlade includes examples for this. Otherwise have a look at the link posted by wich or at the wxPython demo, whether the drawing capabilities match your requirements.","Q_Score":0,"Tags":"python,winforms","A_Id":53599507,"CreationDate":"2018-12-03T09:45:00.000","Title":"Python gui application tools?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When executing a script with the command \"Execute(F5)\", the source is not copied in the console ;\nWhen executing a cell with the command \"Execute the cell (Ctrl-Return)\", the source is copied in the console ; what I do not want.\n\nI don't find the configuration option to prevent this behaviour. Is there one?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":26,"Q_Id":53591102,"Users Score":3,"Answer":"(Spyder maintainer here) This functionality will be available in our next major version (Spyder 4, to be released in 2019) through a command called runcell, which runs cells without copying its source to the console. Besides, this will be the default behavior from that version onwards.","Q_Score":0,"Tags":"python,spyder","A_Id":53597171,"CreationDate":"2018-12-03T09:47:00.000","Title":"How to run a cell without copy source in console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i'm trying to make a user registration with multiple fields to save in the same model. The idea is have a form in the home page with username and password and when press button continue the user is redirected to another page with multiple fields to  insert personal info for the user profile.\nI imagine i must have two different views for that, but i don't understand how put all this data together.\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":53591926,"Users Score":0,"Answer":"In your case i would prefer manipulate HTML content with JavaScript and after everything is ready, just send an ajax call.","Q_Score":1,"Tags":"python,django,django-models,django-forms","A_Id":53594798,"CreationDate":"2018-12-03T10:34:00.000","Title":"How to save data to the same model from forms in different pages...Registration multiple fields? Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to install an environment.yml file that I have previously exported from a conda environment. The yml file specifies a dependency to rpy2=2.8.6 and r-base=3.5.1.\nThe installation and creation of a new environment from the yml file are OK but I get the following error when I try to import rpy2 interface from a script:\nFile \"C:\\Users\\~\\AppData\\Local\\conda\\conda\\envs\\~\\packages\\rpy2\\robjects\\__init__.py\", line 16, in <module>\n    import rpy2.rinterface as rinterface\n File \"C:\\Users\\~\\AppData\\Local\\conda\\conda\\envs\\~\\packages\\rpy2\\rinterface\\__init__.py\", line 92, in <module>\n    from rpy2.rinterface._rinterface import (baseenv,\n  ImportError: DLL load failed: La proc\u00e9dure sp\u00e9cifi\u00e9e est introuvable.\nThis error arises on a different computer than the one used to export the yml file (for the latter one, I did not get any error when reinstalling the conda environment).\nWindows 10-64 bit ; Python 27 64 bits","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":563,"Q_Id":53592354,"Users Score":2,"Answer":"It seems that the problem was coming from the environment variables defined on the computer on which I tried the installation: a R_HOME variable was defined and was refering to another R version previously installed in the machine (which I don't want).\nIt seems that the r_interface pkg is first looking at this env variable in order to find the R.dll. If no R_HOME is find in the env variables, then r_interface will look for a R_HOME in the calling subprocess...which is what I want in my case because R was installed along with the conda env.\nFinally, it seems that the installation of R and rpy2 in a conda env could result in conflicts if a R_HOME variable is defined in the env variables of the computer","Q_Score":1,"Tags":"python,anaconda,conda,rpy2","A_Id":55059749,"CreationDate":"2018-12-03T10:57:00.000","Title":"Getting DLL error when installing rpy2 in conda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to implement machine learning on hardware platform s which can learning by itself Is there any way to by which machine learning on hardware works seamlessly?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":53592665,"Users Score":0,"Answer":"Python supports wide range of platforms, including arm-based. \nYou raspberry pi supports Linux distros, just install Python and go on.","Q_Score":0,"Tags":"python,machine-learning,raspberry-pi,artificial-intelligence,robotics","A_Id":53592746,"CreationDate":"2018-12-03T11:15:00.000","Title":"How to embed machine learning python codes in hardware platform like raspberry pi?","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 want to implement machine learning on hardware platform s which can learning by itself Is there any way to by which machine learning on hardware works seamlessly?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":53592665,"Users Score":0,"Answer":"First, you may want to be clear on hardware - there is wide range of hardware with various capabilities. For example raspberry by is considered a powerful hardware. EspEye and Arduio Nano 33 BLE considered low end platforms.\nIt also depends which ML solution you are deploying. I think the most widely deployed method is neural network. Generally, the work flow is to train the model on a PC or on Cloud using lots of data. It is done on PC due to large amount of resources needed to run back prop. The inference is much lighter which can be done on the edge devices.","Q_Score":0,"Tags":"python,machine-learning,raspberry-pi,artificial-intelligence,robotics","A_Id":67797110,"CreationDate":"2018-12-03T11:15:00.000","Title":"How to embed machine learning python codes in hardware platform like raspberry pi?","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 want to train SqueezeNet 1.1 model using MNIST dataset instead of ImageNet dataset. \nCan i have the same model as torchvision.models.squeezenet? \nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1212,"Q_Id":53593363,"Users Score":0,"Answer":"The initialization of the pretrained weights is possible but you'll get trouble with the strides and kernel sizes since MNIST images are 28X28 pixels. Most probably the reduction will lead to  (batch_sizex1x1xchannel) feature maps before the net is at its infernece layer which will then cause an error.","Q_Score":1,"Tags":"python,neural-network,pytorch,mnist,torchvision","A_Id":53610813,"CreationDate":"2018-12-03T11:56:00.000","Title":"Train SqueezeNet model using MNIST dataset Pytorch","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed instabot in python by pip but I have this error in my pycharm:\n\nModuleNotFoundError: No module named 'instabot'","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1983,"Q_Id":53593464,"Users Score":0,"Answer":"This can also happen if you set up multiple interpreters with the same version and then assign a python file to the interpreter.  You might be adding your packages in PyCharm > File > Settings to one interpreter, but not even realize you have configured another interpreter of the same Python version for a different environment under PyCharm > Python file dropdown > Edit Configuration.","Q_Score":1,"Tags":"python-3.x,pycharm","A_Id":65484536,"CreationDate":"2018-12-03T12:01:00.000","Title":"ModuleNotFoundError: No module named 'instabot'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed instabot in python by pip but I have this error in my pycharm:\n\nModuleNotFoundError: No module named 'instabot'","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1983,"Q_Id":53593464,"Users Score":2,"Answer":"You are using wrong python environment. Go to File->Settings->Project->Project Interpreter. There will be a list of installed packages in python environment PyCharm is currently using. If instabot is not installed, click on the + sign and search for instabot and install it. \nPress apply and ok and you can use module.","Q_Score":1,"Tags":"python-3.x,pycharm","A_Id":53637502,"CreationDate":"2018-12-03T12:01:00.000","Title":"ModuleNotFoundError: No module named 'instabot'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm fairly new to python and not sure on the best solution here.\nI have a general script when generates some calendar pdf output.  I configure it with a small gen_config.py file that is import-ed at the top of my main script.  The config is mostly just name=value pairs.\nNow I need to include some slightly more complicated data in my configuration - a list of holidays to show on the calendar.  I have a handy function to add holidays to a dictionary in my main script - add_holiday(2019, 1, 1, \"New Year's Day\").  But I don't know of the best way to call this from my config script?  Including the main script from the config is a circular dependency... is there a good way to solve this?\nI've considered switching the config to json or something like that, and I'm open to that solution.  Just looking for whatever will be fastest\/easiest, and json feels like it might be overkill.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":487,"Q_Id":53598639,"Users Score":0,"Answer":"Just so this doesn't linger... I followed @jasonharper's advice and moved the function (and global variable) to a separate file which gets included from both places.  It is working well!","Q_Score":0,"Tags":"python","A_Id":53663673,"CreationDate":"2018-12-03T17:15:00.000","Title":"Python config file calling custom function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making my way through a python tutorial and came to a section that serves as an introduction to errors (getting familiar with errors, not freaking out when things break, etc). After digging deeper into a few of the errors, I've seen the phrase \"raise an error\" and \"raise an exception\". \nIs this a specific function? If so, what's the benefit in \"raising an error\"? When visualizing this, it seems like the error that is produced when executing the code is being elevated above other code at runtime... can someone help me piece this together?\nThanks in advance!","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":1472,"Q_Id":53600218,"Users Score":5,"Answer":"Raising an Error is a programmers way of saying \"something went wrong\", in a very specific way. For an analogy, when a flag in a football game is thrown, it means a penalty has been committed. After the play finishes, the referee will say exactly what the penalty is (holding, pass interference, etc) and who the guilty party is. \nIn programming, the penalty is equivalent to the error throwing, the penalty type is the error type, and the guilty party is based on what diagnostics you the programmer provide (widely varies between programming languages).","Q_Score":0,"Tags":"python,error-handling","A_Id":53600272,"CreationDate":"2018-12-03T19:03:00.000","Title":"What do programmers mean when they say \"raise an error\" (example, why do this)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I\u00b4m trying to run a python manage.py runserver command but getting this error message\n\nFile \"C:\\Users\\adrie\\Anaconda3\\lib\\sre_compile.py\", line 17, in \n      assert _sre.MAGIC == MAGIC, \"SRE module mismatch\"\n  AssertionError: SRE module mismatch\n\nDoes anyone have idea of what\u00b4s happening here?\nI had anaconda installed previously and was running fine. But then I\u00b4ve deinstalled and reinstalled anaconda, and I\u00b4m getting this error now.","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":11292,"Q_Id":53600426,"Users Score":1,"Answer":"My PYTHONHOME and PYTHONPATH environment variables were pointing to the wrong version. By fixing this import sre_compile was fixed.","Q_Score":7,"Tags":"python,django,anaconda","A_Id":60339120,"CreationDate":"2018-12-03T19:17:00.000","Title":"whats does assert _sre.MAGIC == MAGIC, SRE module mismatch AssertionError: SRE module mismatch error mean?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I\u00b4m trying to run a python manage.py runserver command but getting this error message\n\nFile \"C:\\Users\\adrie\\Anaconda3\\lib\\sre_compile.py\", line 17, in \n      assert _sre.MAGIC == MAGIC, \"SRE module mismatch\"\n  AssertionError: SRE module mismatch\n\nDoes anyone have idea of what\u00b4s happening here?\nI had anaconda installed previously and was running fine. But then I\u00b4ve deinstalled and reinstalled anaconda, and I\u00b4m getting this error now.","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":11292,"Q_Id":53600426,"Users Score":1,"Answer":"You need reinstall IDLE or anaconda","Q_Score":7,"Tags":"python,django,anaconda","A_Id":54738862,"CreationDate":"2018-12-03T19:17:00.000","Title":"whats does assert _sre.MAGIC == MAGIC, SRE module mismatch AssertionError: SRE module mismatch error mean?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I\u00b4m trying to run a python manage.py runserver command but getting this error message\n\nFile \"C:\\Users\\adrie\\Anaconda3\\lib\\sre_compile.py\", line 17, in \n      assert _sre.MAGIC == MAGIC, \"SRE module mismatch\"\n  AssertionError: SRE module mismatch\n\nDoes anyone have idea of what\u00b4s happening here?\nI had anaconda installed previously and was running fine. But then I\u00b4ve deinstalled and reinstalled anaconda, and I\u00b4m getting this error now.","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":11292,"Q_Id":53600426,"Users Score":0,"Answer":"Make sure your installed python version matches exactly the version anaconda uses. If not get another python version. \nOn Windows you can see the anaconda python version in control center -> uninstall programm -> Name of Anaconda.\nAlso make sure there are no older python version installed (that still might have environmental variables that point to them).","Q_Score":7,"Tags":"python,django,anaconda","A_Id":58438369,"CreationDate":"2018-12-03T19:17:00.000","Title":"whats does assert _sre.MAGIC == MAGIC, SRE module mismatch AssertionError: SRE module mismatch error mean?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I\u00b4m trying to run a python manage.py runserver command but getting this error message\n\nFile \"C:\\Users\\adrie\\Anaconda3\\lib\\sre_compile.py\", line 17, in \n      assert _sre.MAGIC == MAGIC, \"SRE module mismatch\"\n  AssertionError: SRE module mismatch\n\nDoes anyone have idea of what\u00b4s happening here?\nI had anaconda installed previously and was running fine. But then I\u00b4ve deinstalled and reinstalled anaconda, and I\u00b4m getting this error now.","AnswerCount":5,"Available Count":4,"Score":0.1973753202,"is_accepted":false,"ViewCount":11292,"Q_Id":53600426,"Users Score":5,"Answer":"Make sure you do not have any mismatch between Python interpreter version used (like 3.7) and the 're' python module (like 3.6.1).","Q_Score":7,"Tags":"python,django,anaconda","A_Id":55303505,"CreationDate":"2018-12-03T19:17:00.000","Title":"whats does assert _sre.MAGIC == MAGIC, SRE module mismatch AssertionError: SRE module mismatch error mean?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using the Fourier transformation in conjunction with Keras for voice recogition (speaker identification). I have heard MFCC is a better option for voice recognition, but I am not sure how to use it.\nI am using librosa in python (3) to extract 20 MFCC features. My question is: which MFCC features should I use for speaker identification?\nIn addition to this I am unsure on how to implement these features. What I would do is to get the necessary features and make one long vector input for a neural network. However, it is also possible to display colors, so could image recognition also be possible, or is this more aimed at speech, and not speaker recognition?\nIn short, I am unsure where I should start, as I am not very experienced with image recognition and have no idea where to start.\nThanks in advance!!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1526,"Q_Id":53601892,"Users Score":0,"Answer":"You can use MFCCs with dense layers \/ multilayer perceptron, but probably a Convolutional Neural Network on the mel-spectrogram will perform better, assuming that you have enough training data.","Q_Score":0,"Tags":"python,keras,neural-network,voice-recognition,mfcc","A_Id":53806861,"CreationDate":"2018-12-03T21:09:00.000","Title":"Using MFCC's for voice recognition","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a table where i am checking if any row exists, if yes then update some fields of that table and if no, then particular row is inserted with all the values of the specified fields using django models..\nSo basically what i have done is..\nFirst i check if the values doesn't exist, then i add those values using create method.. After that i read the table again and then check whether to update particular field or not after all this i send a jsonresponse..\nSo when i request first time it adds all the rows required along with the existing one and gives an value error saying httpresponse error returned none and again if i request same url i get the values with updated fields too based on the inserted rows as well! \nSo is their a way to make it work as if the row doesn't exist then insert or else update specific field?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":375,"Q_Id":53602559,"Users Score":0,"Answer":"Make a two step process in your logic,\n 1. Check if record exist :\n         Yes : update \n         No. : create  new record","Q_Score":0,"Tags":"python,django-models","A_Id":53612195,"CreationDate":"2018-12-03T21:58:00.000","Title":"Existing row update or else insert a new row using django models","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If I create a future and schedule it, is it possible to have two waiters (asyncio.wait) waiting on it so when it completes they both eventually wake up and continue? Can both waiters get the result and get any exception raised by the future?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":189,"Q_Id":53603106,"Users Score":3,"Answer":"You can have any number of tasks wait for a single future, they will all be woken up when the future is done. If an exception has been set it'll be raised for all waiting tasks.","Q_Score":1,"Tags":"python,python-3.x,python-asyncio","A_Id":53603188,"CreationDate":"2018-12-03T22:47:00.000","Title":"Can one future have multiple waiters in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I noticed the main download button for Python 3 downloads an executable that runs a wizard that is titled \"Python 3 (32 Bit)\" so I  figured \"ahh that's fine I'll just run 32 bit Python on my 64 bit OS\" but out of curiosity I stopped the install and went back to the site to find \"Windows x86-64 executable installer  Windows for AMD64\/EM64T\/x64 4c9fd65b437ad393532e57f15ce832bc    26260496\" and it downloads as \"python-3.7.1-amd64.exe\"I was just wondering what the heck is going on?\nWhy is the Python 3 Windows AMD64\/EM64T\/x64 installer a \".amd64\" file?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4954,"Q_Id":53604692,"Users Score":1,"Answer":"\".amd64\" is a file extension for 64 bit binaries. While \".exe\" is more common, the Python 3 64-bit installer is probably labeled \".amd64\" to specify that it is meant to be run on 64-bit machines.","Q_Score":2,"Tags":"python-3.x","A_Id":53604880,"CreationDate":"2018-12-04T02:06:00.000","Title":"Why is the Python 3 Windows AMD64\/EM64T\/x64 installer a \".amd64\" file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Pretty simple question with no literature to expound on it here. If you start a connection, then run a job continually for 12 hours inserting data to the .db, if you do not commit and the python script terminates, can you go back in, connect to the database and commit and see the changes?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":53605132,"Users Score":0,"Answer":"This may be a silly question but way are you don't committing records as you process? Isn't it more efficient to commit say 100,000 records now than try to commit 1,000,000 at once at the end of the process?","Q_Score":0,"Tags":"python,sqlite","A_Id":53636522,"CreationDate":"2018-12-04T03:07:00.000","Title":"SQLite3 Python - Comit() in a later session","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am extracting a road network from satellite imagery. Herein the pixel classification is binary ( 0 = non-road, 1 = road). Hence, the mask of the complete satellite image which is 6400 x 6400 pixels shows one large road network where each road is connected to another road. For the implementation of the U-net I divided that large image in 625 images of 256 x 256 pixels. \nMy question is: Can a neural network easier find structure with an increase in batch size (thus can it find structure between different batches), or can it only find structure if the input image size is enlarged?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":955,"Q_Id":53613681,"Users Score":2,"Answer":"If your model is a regular convolutional network (without any weird hacks), the samples in a batch will not be connected to each other. \nDepending on which loss function you use, the batch size might be important too. For regular functions (available 'mse', 'binary_crossentropy', 'categorical_crossentropy', etc.), they all keep the samples independent from each other. But some losses might consider the entire batch. (F1 metrics, for instance). If you're using a loss function that doesn't treat samples independently, then the batch size is very important.\nThat said, having a bigger batch size may help the net to find its way more easily, since one image might push weights towards one direction, while another may want a different direction. The mean results of all images in the batch should then be more representative of a general weight update.\nNow, entering an experimenting field (we never know everything about neural networks until we test them), consider this comparison:\n\na batch with 1 huge image versus   \na batch of patches of the same image\n\nBoth will have the same amount of data, and for a convolutional network, it wouldn't make a drastic difference. But for the first case, the net will probably be better at finding connections between roads, maybe find more segments where the road might be covered by something, while the small patches, being full of borders might be looking more into textures and be not good at identifying these gaps.\nAll of this is, of course, a guess. Testing is the best.\nMy net in a GPU cannot really use big patches, which is bad for me...","Q_Score":1,"Tags":"python,keras,image-segmentation","A_Id":53613988,"CreationDate":"2018-12-04T13:06:00.000","Title":"Increasing accuracy by changing batch-size and input image size","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I read online that Pipfile is always updated automatically whenever a new package is installed\/uninstalled\/updated.\nBut I noticed that Pipfile.lock is also updated automatically. Then what difference does it make to Pipfile.lock when it is updated automatically compared to updated using lock command?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1578,"Q_Id":53614186,"Users Score":1,"Answer":"pipenv lock doesn't install anything. It just updates Pipfile.lock from Pipfile. pipenv install does two things. It installs and updates Pipfile.lock.\nYou might want to create a Pipfile.lock for example for initializing an environment in a Docker container or for your cloud-based environment, without installing anything locally.","Q_Score":2,"Tags":"python-3.x,pipenv","A_Id":53936793,"CreationDate":"2018-12-04T13:36:00.000","Title":"Pipenv - Pipfile.lock - Difference when updated automatically compared to updated using `lock` command?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The following are query results are from two different tables in the same database, both id columns are integer. How should I remove the number 16789 from the first table id to match the second id?\nnews=> select id from log limit 10;\n   id\n1678923\n 1678924\n 1678925\n 1678926\n 1678927\n 1678928\n 1678929\n 1678930\n 1678931\n 1678932\n(10 rows)\nnews=> select id from articles limit 10;\nid\n23\n 24\n 25\n 26\n 27\n 28\n 30\n 29\n(8 rows)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19,"Q_Id":53615450,"Users Score":0,"Answer":"In the database:\nSELECT\n TRIM (\n LEADING '16789'\n FROM 1678929\n CAST (news AS TEXT)\n ); -- 29","Q_Score":0,"Tags":"python,database,psql","A_Id":53615582,"CreationDate":"2018-12-04T14:44:00.000","Title":"How do I remove part of the number from psql query return?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an Excel file where A1,A2,A3 are empty but A4:A53 contains column names.\nIn \"R\" when you were to read that data, the columns names for A1,A2,A3 would be \"X_1,X_2,X_3\" but when using pandas.read_excel it simply skips the first three columns, thus ignoring them. The problem is that the number of columns in each file is dynamic thus I cannot parse the column range, and I cannot edit the files and adding \"dummy names\" for A1,A2,A3","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6260,"Q_Id":53615545,"Users Score":0,"Answer":"A quick fix would be to pass header=None to pandas' read_excel() function, manually insert the missing values into the first row (it now will contain the column names), then assign that row to df.columns and drop it after. Not the most elegant way, but I don't know of a builtin solution to your problem\nEDIT: by \"manually insert\" I mean some messing with fillna(), since this appears to be an automated process of some sort","Q_Score":3,"Tags":"python-3.x,pandas","A_Id":53616756,"CreationDate":"2018-12-04T14:50:00.000","Title":"Pandas read_excel removes columns under empty header","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I worked with VSC earlier, no problem whatsoever. Then it didn't work anymore, something about node not being found in PATH\nDownloaded Node, and now it sais\n|-------------------------------------------------------------------|\n| (X)..Cannot launch program...................................|\n| ........'c:\\users...\\decimal_converter.py';..................|\n| ........setting the 'outFiles' attribute might................|\n|..................................|Open launch.json| |cancel|...|\n|-------------------------------------------------------------------|\nNow, since it originally worked I am confused why it doesn't anymore: ATOM has no problem running my code. What could actually cause that. I will for the time being continue to use Atom, I am currently trying both to see what fits me. Would be cool if VSC stopped breaking.\nI researched online, but solutions are not working and far between.\nThanks,\nMartin","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1082,"Q_Id":53616843,"Users Score":1,"Answer":"Okay, so, wow. I fixed it but I don't know if that's fixing the problem or the symptom.\nFor further reference, if anyone has this problem:\nI don't know why, but it tried to run the launch.jsn. I tried around, nothing worked. So, I just deleted everything.\nIt worked again. Until it didn't. This time I only deleted 'launch,jsn' and it works again. My unprofessional SUSPISSION is that it hates me, or that it tries to run 'launch.jsn'. Once it was deleted it worked again.\nIs it smart to delete it? IDK, but it worked.","Q_Score":0,"Tags":"python,python-3.x,visual-studio-code,ide","A_Id":53617026,"CreationDate":"2018-12-04T15:58:00.000","Title":"Visual studio Code error, setting the 'outFiles' might heIp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have few questions about programming a game (3d or 2d) with a python language and Unity game engine\nCan we make a game with python in Unity game engine?\nif yes how?\nplease share basic tutorials about this topic.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":29060,"Q_Id":53618324,"Users Score":3,"Answer":"Currently there is not a way to directly use python within unity. You can use an interpreter that will call functions. This can only take you so far beyond the built in functions that unity currently used. \nSince you already know Python and probably learned Java in school or have at least seen it. C# is a very simple language to pick up that is very versatile so I would recommend learning it.\nOtherwise you can go Piglet or Arcade Game Engine. These engines are built for Python, Piglet does not need outside libraries \/ dependencies. You could also go with a Blueprint style coding method, both are available with unity and unreal.","Q_Score":3,"Tags":"python,python-3.x,unity3d","A_Id":53618520,"CreationDate":"2018-12-04T17:18:00.000","Title":"can we make a game with python in unity?","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":"Let's say i have the following file,\ndummy_file.txt(contents below)\nfirst line\nthird line\nhow can i add a line to that file right in the middle so the end result is:\nfirst line\nsecond line\nthird line\nI have looked into opening the file with the append option, however that adds the line to the end of the file.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":53619223,"Users Score":0,"Answer":"The standard file methods don't support inserting into the middle of a file. You need to read the file, add your new data to the data that you read in, and then re-write the whole file.","Q_Score":0,"Tags":"python-3.x","A_Id":53619407,"CreationDate":"2018-12-04T18:22:00.000","Title":"How to add text to a file in python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used to run Python scripts from my Windows command line, and all the prints were printed in the same console. Now something happened on my machine (Windows 10), and when I launch a Python script from the command line (i.e. open a Command Prompt and run python <my_script.py>), Windows opens a new window (titled with the absolute path of python.exe). This windows closes automatically at the end of the execution, so that I can't see the output.\nHow do I go back to printing output in the same command prompt window from which I run the script?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":5063,"Q_Id":53623318,"Users Score":0,"Answer":"In my computer this was caused by Windows not knowing what program a .py file was associated with.  I solved this by going to:\nControl Panel -> Programs -> Default Programs -> Associate a file type or protocol with a program (Scroll down) and choose \"Choose default apps by file type\" Scroll down until you see \".py\" and choose the correct\nPython interpreter.","Q_Score":4,"Tags":"python,windows,windows-console","A_Id":69922616,"CreationDate":"2018-12-05T00:12:00.000","Title":"Python.exe opens in a new console window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I used to run Python scripts from my Windows command line, and all the prints were printed in the same console. Now something happened on my machine (Windows 10), and when I launch a Python script from the command line (i.e. open a Command Prompt and run python <my_script.py>), Windows opens a new window (titled with the absolute path of python.exe). This windows closes automatically at the end of the execution, so that I can't see the output.\nHow do I go back to printing output in the same command prompt window from which I run the script?","AnswerCount":4,"Available Count":3,"Score":-0.0996679946,"is_accepted":false,"ViewCount":5063,"Q_Id":53623318,"Users Score":-2,"Answer":"Simply: last row on the end of your program maybe this:\ninput(\"\\nIf you whish end the program press any key ...\")\n...and your program wait for the key and you see your outcome","Q_Score":4,"Tags":"python,windows,windows-console","A_Id":61848115,"CreationDate":"2018-12-05T00:12:00.000","Title":"Python.exe opens in a new console window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I used to run Python scripts from my Windows command line, and all the prints were printed in the same console. Now something happened on my machine (Windows 10), and when I launch a Python script from the command line (i.e. open a Command Prompt and run python <my_script.py>), Windows opens a new window (titled with the absolute path of python.exe). This windows closes automatically at the end of the execution, so that I can't see the output.\nHow do I go back to printing output in the same command prompt window from which I run the script?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":5063,"Q_Id":53623318,"Users Score":1,"Answer":"It's odd but it very likely a windows setup issue as python is an exe. If memory serves windows will spawn on a > run command so checking the way python is booting will help.\nUnfortunately it could be a range of issues, so some steps towards victory:\nWhat happen when you just type python into the cmd? If it simply starts the input >>> - it means your python setup is fine. If a cmd window spawns and disappears it may be a windows permissions issue.\nTry running your script with -i flag: python -i script.py. This drops you into the repl when the app completes - displaying your output. \nEnsure you're using the native flavour of the cmd to test. Ensuring any command app or IDE isn't injecting a start  command or weird \/K (spawn new window) flag.\nHope it helps.","Q_Score":4,"Tags":"python,windows,windows-console","A_Id":53623797,"CreationDate":"2018-12-05T00:12:00.000","Title":"Python.exe opens in a new console window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Python project set up in a virtualenv that I created directly from the terminal. When I try to open it in PyCharm, I am able to see the files, but I can't change the project interpreter to use my virtualenv. I am able to see the python executable file both through the WSL terminal and the Windows File Explorer, but when I try to add it as a project interpreter from PyCharm, I am unable to find it.\nI have tried deleting my .idea directory and adding the project to PyCharm again. I have tried creating a new project in PyCharm using my project's root directory. I have tried editing the SDK_HOME variable in .idea\/workspace.xml to be the location of the python executable, but it didn't change the project interpreter.\nAnyone have any ideas?\nI am using WSL for the terminal and Windows 10 for my OS.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":806,"Q_Id":53624955,"Users Score":0,"Answer":"It is probably because what you have is a symlink and not a copy of the interpreter.\nTry creating the environment by adding the --copies option:\nvirtualenv myenv --copies","Q_Score":0,"Tags":"python,pycharm,virtualenv","A_Id":64752496,"CreationDate":"2018-12-05T03:56:00.000","Title":"PyCharm can't find virtualenv interpreter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there any way to get all the instances using the python google library without having to iterate through all the zones and request the instances individually?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":216,"Q_Id":53626692,"Users Score":4,"Answer":"No, you must iterate thru each of your projects and then each zone within the project. If you are only using one project, then iterate thru each zone.\nThis may sound unusual, but think of it this way. Each zone is a data center. You are connecting to each data center to access resources.","Q_Score":1,"Tags":"python,google-cloud-platform","A_Id":53626926,"CreationDate":"2018-12-05T06:50:00.000","Title":"Python GCP get all instances from any zone","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I create a pyspark dataframe and i want to see it in the SciView tab in PyCharm when i debug my code (like I used to do when i have worked with pandas).\nIt says \"Nothing to show\" (the dataframe exists, I can see it when I use the show() command).\nsomeone knows how to do it or maybe there is no integration between pycharm and pyspark dataframe in this case?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1310,"Q_Id":53627818,"Users Score":5,"Answer":"Pycharm does not support spark dataframes, you should call the toPandas() method on the dataframe. As @abhiieor mentioned in a comment, be aware that you can potentially collect a lot of data, you should first limit() the number of rows returned.","Q_Score":5,"Tags":"python,pyspark,pycharm","A_Id":53633844,"CreationDate":"2018-12-05T08:13:00.000","Title":"DataFrame view in PyCharm when using pyspark","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to pass arguments in Spyder IDE with IPython to debug the file but the input arguments passing will be different\nDriver.py -in \"C:\\Desktop\\\" -out \"C:\\Desktop\\\" -f 65 -f2 64\nHow can i pass the arguments, so that i can be able to debug the file.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5898,"Q_Id":53628850,"Users Score":5,"Answer":"Go to run > configure \nTick command line options and type in the arguments in the space.","Q_Score":2,"Tags":"python,spyder","A_Id":53629065,"CreationDate":"2018-12-05T09:19:00.000","Title":"Passing Arguments to Spyder for debugging file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In IntelliJ, if you double click after open flower bracket ({), it automatically highlights the entire reachable code block. Is there a similar shortcut present in PyCharm where I can highlight blocks of code post a colon is encountered (like for loops, function defs, etc.)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":249,"Q_Id":53629127,"Users Score":1,"Answer":"You can use Alt+\u2191 to do this, sort of. At least on mac.","Q_Score":1,"Tags":"python,pycharm","A_Id":53629175,"CreationDate":"2018-12-05T09:33:00.000","Title":"Is there a shortcut in PyCharm which highlights a code block","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been trying to set up an LSTM model but I'm a bit confused about batch_size. I'm using the Keras module in Tensorflow.\nI have 50,000 samples, each has 200 time steps and each time step has three features. So I've shaped my training data as (50000, 200, 3). \nI set up my model with four LSTM layers, each having 100 units. For the first layer I specified the input shape as (200, 3). The first three layers have return_sequences=True, the last one doesn't. Then I do some softmax classification.\nWhen I call model.fit with batch_size='some_number' do Tensorflow\/Keras take care of feeding the model with batches of the specified size? Do I have to reshape my data somehow in advance? What happens if the number of samples is not evenly divisible by 'some_number'?\nThanks for your help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1170,"Q_Id":53630041,"Users Score":2,"Answer":"If you provide your data as numpy arrays to model.fit() then yes, Keras will take care of feeding the model with the batch size you specified. If your dataset size is not divisible by the batch size, Keras will have the final batch be smaller and equal to dataset_size mod batch_size.","Q_Score":0,"Tags":"python,tensorflow,keras,lstm","A_Id":53630217,"CreationDate":"2018-12-05T10:22:00.000","Title":"batch size for LSTM","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a multi class classification for segmenting customers into 3 different classes based on their purchasing behavior and demographics. I cannot disclose the data set completely but in general it contains around 300 features and  50000 rows. I have tried the following methods but I am unable to achieve accuracy above 50% :\n\nTuning the hyperparameters ( I am using tuned hyperparameters after doing GridSearchCV)\nNormalizing the dataset and then running my models\nTried different classification methods : OneVsRestClassifier, RandomForestClassification, SVM, KNN and LDA\nI have also removed irrelevant features and tried running my models\nMy classes were imbalanced, so I have also tried using class_weight = balanced, oversampling using SMOTE, downsampling and resampling.\n\nIs there something else I can try to improve my accuracy ( and by accuracy I mean f-score, precision and recall ).\nAny help will be appreciated.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":4038,"Q_Id":53634808,"Users Score":1,"Answer":"Try doing a feature selection first using PCA or Random forest and then fit a chained classifier where first do a oneversesall and then a random forest or a decision tree. You should get a slightly better accuracy.","Q_Score":2,"Tags":"python,machine-learning,random-forest","A_Id":53749834,"CreationDate":"2018-12-05T14:43:00.000","Title":"How to improve accuracy of random forest multiclass classification model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a multi class classification for segmenting customers into 3 different classes based on their purchasing behavior and demographics. I cannot disclose the data set completely but in general it contains around 300 features and  50000 rows. I have tried the following methods but I am unable to achieve accuracy above 50% :\n\nTuning the hyperparameters ( I am using tuned hyperparameters after doing GridSearchCV)\nNormalizing the dataset and then running my models\nTried different classification methods : OneVsRestClassifier, RandomForestClassification, SVM, KNN and LDA\nI have also removed irrelevant features and tried running my models\nMy classes were imbalanced, so I have also tried using class_weight = balanced, oversampling using SMOTE, downsampling and resampling.\n\nIs there something else I can try to improve my accuracy ( and by accuracy I mean f-score, precision and recall ).\nAny help will be appreciated.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":4038,"Q_Id":53634808,"Users Score":2,"Answer":"Try to tune below parameters\nn_estimators\nThis is the number of trees you want to build before taking the maximum voting or averages of predictions. Higher number of trees give you better performance but makes your code slower. You should choose as high value as your processor can handle because    this makes your predictions stronger and more stable. As your data size is bigger so it will take more time for each iteration but try this.\nmax_features\nThese are the maximum number of features Random Forest is allowed to try in individual tree. There are multiple options available in Python to assign maximum features. Few of them are  :\n\nAuto\/None : This will simply take all the features which make sense\nin every tree.Here we simply do not put any restrictions on the\nindividual tree.\nsqrt : This option will take square root of the total number of\nfeatures in individual run. For instance, if the    total number of\nvariables are 100, we can only take 10 of them in    individual\ntree.\u201dlog2\u2033 is another similar type of option for max_features.\n0.2 : This option allows the random forest to take 20% of variables in individual run. We can assign and value in a format \u201c0.x\u201d where we\nwant x% of features to be considered.\n\n\nmin_sample_leaf\nLeaf is the end node of a decision tree. A smaller leaf makes the model more prone to capturing noise in train data. You can start with some minimum value like 75 and gradually increase it. See which value your accuracy is coming high.","Q_Score":2,"Tags":"python,machine-learning,random-forest","A_Id":53755232,"CreationDate":"2018-12-05T14:43:00.000","Title":"How to improve accuracy of random forest multiclass classification model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a multi class classification for segmenting customers into 3 different classes based on their purchasing behavior and demographics. I cannot disclose the data set completely but in general it contains around 300 features and  50000 rows. I have tried the following methods but I am unable to achieve accuracy above 50% :\n\nTuning the hyperparameters ( I am using tuned hyperparameters after doing GridSearchCV)\nNormalizing the dataset and then running my models\nTried different classification methods : OneVsRestClassifier, RandomForestClassification, SVM, KNN and LDA\nI have also removed irrelevant features and tried running my models\nMy classes were imbalanced, so I have also tried using class_weight = balanced, oversampling using SMOTE, downsampling and resampling.\n\nIs there something else I can try to improve my accuracy ( and by accuracy I mean f-score, precision and recall ).\nAny help will be appreciated.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":4038,"Q_Id":53634808,"Users Score":1,"Answer":"How is your training acc? I assume that your acc is your validation. If your training acc is way to high, som normal overfitting might be the case. Random forest normally handles overfitting very well.\nWhat you could try is PCA of your data, and then try classify on that. This gives you the features which accounts for most variation in the data, thus can be a good idea to try, if you cannot classify on the original data (and also it reduces your features).\nA side note: remember, that the fitting of SVM is quadratic in the number of points, thus reducing your data to around 10-20000 for tuning parameters and then fit a SVM on the full dataset with the optimal parameter for the subset, might also speed up the process.\nAlso remember to consider trying different kernels for the SVM.","Q_Score":2,"Tags":"python,machine-learning,random-forest","A_Id":53635051,"CreationDate":"2018-12-05T14:43:00.000","Title":"How to improve accuracy of random forest multiclass classification model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using keras with Tensorflow-gpu backend in Python. I'm trying to put the correct number of nb_train_samplesn nb_validation_ samples and epochs.\nI am using the fit-generator-method.\n\nnb_train_samples has to be the same number that images that i have for training? Can be higher?\nnb_validation_samples has to be the same number that images that i have for validation? Can be higher?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":454,"Q_Id":53637278,"Users Score":1,"Answer":"Yes, they have to be the same.  These are the parameters you use to tell the process how many you have of each type of image.  For instance, if you tell it that you have 5_000 validation samples, but there are only 3_000 in the data set, you will crash the run.","Q_Score":0,"Tags":"python,tensorflow,keras,deep-learning","A_Id":53637348,"CreationDate":"2018-12-05T17:01:00.000","Title":"How to use a good use of nb_train_samples in keras?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Will pip only use --cache-dir cache to satisfy the range version of a requirement or will it update the cache if a newer version is available within that range?\nExample: \n\nrequirements.txt contains requests>=2.0,<3.0 \ncache contains requests==2.3.4 \nremote pypi now has requests==2.4 available\n\nWill pip install --cache-dir=... requirements.txt find the new version available and update the cache?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":345,"Q_Id":53638494,"Users Score":3,"Answer":"It depends if requests==2.3.4 is already installed in the current environment (the global \/site-packages\/ or a virtual environment). If the version is installed and you don't use the option -U\/--upgrade, pip will not download a new version and will not use the cached version.\nIf requests isn't installed pip will download any newer version allowed by constraints (2.4 in your example), cache it and install.\nThe cache will be used next time you run pip install requirements.txt with the same constraints (providing that no new version of the package appears at PyPI in the meantime).","Q_Score":2,"Tags":"python,pip","A_Id":53640160,"CreationDate":"2018-12-05T18:21:00.000","Title":"pip --cache-dir vs version range","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want a column in a dataframe including datetime in the format \"M1,D1,H1\" (January 1st, 1.00 am). I have a dataframe of the size with 8760 elements. How do I populate it?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":53638858,"Users Score":0,"Answer":"df.insert(0, 'time', [dt.datetime(self.MODEL_YEAR, 1, 1, 0) + dt.timedelta(hours=int(x))\n                                      for x in df['hour'].values])","Q_Score":0,"Tags":"python-3.x,pandas","A_Id":53842312,"CreationDate":"2018-12-05T18:46:00.000","Title":"Datetime in the format \"M1,D1,H1\" (January 1st, 1.00 am)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just created a virtual environment on my machine (I am running on ubuntu 18.04 LTS). I have the python version of 3.6.7 and now I want to install mysqlclient into my virtual environment.\nAfter I do pip install mysqlclient it didn't work, instead it gave me errors saying; \n\nCommand \"python.py egg_info\" failed with error code 1 in \/tmp\/pip-install-zd21vfb3\/mysqlclient\/', and that the msql_config file is not found. \n\nMy setup tools are all up to date.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":13288,"Q_Id":53641541,"Users Score":23,"Answer":"mysqlclient has a dependency on the mysql client & dev packages being installed.  In order to fix this on ubuntu, you have to use apt-get to install a couple of mysql packages.\nIn your case, it looks like the missing mysql_config might be missing on your system.  You can fix that by installing libmysqlclient-dev on ubuntu bionic.","Q_Score":8,"Tags":"python,mysql,django","A_Id":53641741,"CreationDate":"2018-12-05T22:12:00.000","Title":"why 'pip install mysqlclient' not working in ubuntu 18.04 LTS","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi I am trying to write a python code for reading NFL Stats \nI converted stats into a excel Csv file,\nI am wondering if anyone could help me plan out my code\nLike how would I go about getting whos got the most touchdowns, sacks, passing yards, and etc.\nI know this is kinda of beginner stuff but much help would be appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":92,"Q_Id":53644166,"Users Score":1,"Answer":"What I suggest is:\n\nRead the CVS file and set it in an array of two dimensions. Where columns are touchdowns, sacks, passing yards, etc. and rows are specific values for each player.\nTo determinate for example which player got the most touchdown, go through the column 1 \"column for touchdowns\" and compare the maximum value of that column. \nTo continue with the other stats you have to repeat the previous process with another column.\n\nI hope this helps you.","Q_Score":0,"Tags":"python,csv","A_Id":53644466,"CreationDate":"2018-12-06T03:24:00.000","Title":"Csv Python reader","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating Login, Signup, and a few other forms which require the user to click on a submit button. What is the difference between using a SubmitField in my form class vs using html <input type=\"submit\" value=\"Log in\"> ? Which should I prefer and when?\nI initially created with html because I was unaware of the SubmitField option in wtforms.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":337,"Q_Id":53645514,"Users Score":1,"Answer":"WTForms SubmitField will create required HTML code ( field value, name, label etc.. ) ( you can apply styles also ). In your HTML, you've to write all these.\nYou can use any of these. It all comes to how you're getting data from form and processing it in the backend.","Q_Score":0,"Tags":"python,html,flask,flask-wtforms","A_Id":53645861,"CreationDate":"2018-12-06T06:04:00.000","Title":"What are the advantages\/disadvantages of using a SubmitField from flask wtforms vs a html submit button?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Scrapy crawler and I want to rotate the IP so my application will not be blocked. I am setting IP in scrapy using request.meta['proxy'] = 'http:\/\/51.161.82.60:80' but this is a VM's IP. My question is can VM or Machine's IP be used for scrapy or I need a proxy server?\nCurrently I am doing this. This does not throw any error but when I get response from http:\/\/checkip.dyndns.org it is my own IP not updated IP which I set in meta. That is why I want to know if I do need proxy server.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":53645854,"Users Score":0,"Answer":"Definitely you need a proxy server. meta data is only a field in the http request. the server side still knows the public ip that really connecting from the tcp connection layer.","Q_Score":0,"Tags":"python,scrapy,web-crawler","A_Id":53647528,"CreationDate":"2018-12-06T06:38:00.000","Title":"Can VM \/ Machine IP be used instead of Proxy Server for Scrapy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We have a web application runs on python tornado framework(MVC structure).\nApplication contains many filters for sorting,searching etc. \nWhenever you apply\/select any filter inside the application we are using AJAX calls to send it to back-end(controller). Since we have many AJAX calls and controllers, filters needs to passed every time and each AJAX calls. Obviously there should be a better way to do it.\nI checked about secured cookies which supported by tornado server and many people suggested \"cookies\" is the best way.\nPlease suggest me if there is any other way.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":53646820,"Users Score":0,"Answer":"For a REST API it's a right way to pass the whole request context at each request \u2014 all filters. I really doubt that your filters are so huge, that overhead of transporting them is so significant that it's worth of any optimization which will lead to complication of your app for almost no benefits.","Q_Score":0,"Tags":"javascript,ajax,python-2.7,tornado","A_Id":53915481,"CreationDate":"2018-12-06T07:50:00.000","Title":"Maintaining filter values of a web application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there a way to play an audio while the Kivy application is loading while running on Android devices? That is play an audio while the presplash image, defined in the buildozer.spec file, is displayed on the screen.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":224,"Q_Id":53650445,"Users Score":1,"Answer":"There is no prebuilt way to do it. It would be possible to achieve by editing the Java code managing app loading, in the same place that the presplash image is set up.","Q_Score":0,"Tags":"android,python,audio,kivy,buildozer","A_Id":53657667,"CreationDate":"2018-12-06T11:29:00.000","Title":"Kivy & Buildozer: How to play audio while Android Application is loading?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"One can apply recurrent dropout onto basic LSTM or GRU layers in Keras by passing its value as a parameter of the layer.\nCuDNNLSTM and CuDNNGRU are LSTM and GRU layers that are compatible with CUDA. The main advantage is that they are 10 times faster during training. However they lack some of the beauty of the LSTM or GRU layers in Keras, namely the possibility to pass dropout or recurrent dropout values.\nWhile we can add Dropout layers directly in the model, it seems we cannot do that with Recurrent Dropout.\nMy question is then the following : How to add recurrent dropout to CuDNNGRU or CuDNNLSTM in Keras ?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":4528,"Q_Id":53656220,"Users Score":3,"Answer":"You can use kernel_regularizer and recurrent_regularizer for prevent overfitting, i am using L2 regularizers and i am having good results.","Q_Score":5,"Tags":"python,tensorflow,keras,lstm","A_Id":58120534,"CreationDate":"2018-12-06T16:55:00.000","Title":"How to add recurrent dropout to CuDNNGRU or CuDNNLSTM in Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here is the scenario. I have Django project and python script project under a directory. The python script needs to runs independently on a scheduled time and also needs to access Database used by Django.\nIs it possible to use\/import existing Django code in python script to access db. If so how?\nThe idea comes for C# app where Models and data access layer can be built as library and can be used in many projects.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1288,"Q_Id":53657609,"Users Score":0,"Answer":"Faced the same problem and finally decided to implement a daemon in django custom command.\nYou can import anything django related there just as you would normally do in django code, while implementing your own code.","Q_Score":2,"Tags":"python,django,django-models","A_Id":59825264,"CreationDate":"2018-12-06T18:29:00.000","Title":"Using django ORM from non django python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Python's built-in HTTP clients don't have many features, so even the Python docs recommend using requests. But there's also urllib3, which requests, itself uses, and they share some core developers, making me think they're more complementary than competing.\nWhen would I use urllib3 instead of requests? What features does requests add on top of urllib3?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":53662099,"Users Score":0,"Answer":"Requests was conducted on the basis of urlib3 encapsulation.\nSince Requests are already an encapsulated library, many functions can be simplified. For example: timeout setting, proxy setting, file upload, get cookies, etc.\nHowever,requests can only be used directly and cannot be invoked asynchronously, so requests are slow.\nSo, if you're writing small spiders that don't require much speed, consider using requests.","Q_Score":2,"Tags":"python,python-requests,urllib3","A_Id":53662465,"CreationDate":"2018-12-07T01:38:00.000","Title":"Choosing between Python HTTP clients urllib3 and requests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a student in medical imaging. I have to construct a neural network for image segmentation. I have a data set of 285 subjects, each with 4 modalities (T1, T2, T1ce, FLAIR) + their respective segmentation ground truth. Everything is in 3D with resolution of 240x240x155 voxels (this is BraTS data set).\nAs we know, I cannot input the whole image on a GPU for memory reasons. I have to preprocess the images and decompose them in 3D overlapping patches (sub-volumes of 40x40x40) which I do with scikit-image view_as_windows and then serialize the windows in a TFRecords file. Since each patch overlaps of 10 voxels in each direction, these sums to 5,292 patches per volume. The problem is, with only 1 modality, I get sizes of 800 GB per TFRecords file. Plus, I have to compute their respective segmentation weight map and store it as patches too. Segmentation is also stored as patches in the same file. \nAnd I eventually have to include all the other modalities, which would take nothing less than terabytes of storage. I also have to remember I must also sample equivalent number of patches between background and foreground (class balancing).\nSo, I guess I have to do all preprocessing steps on-the-fly, just before every training step (while hoping not to slow down training too). I cannot use tf.data.Dataset.from_tensors() since I cannot load everything in RAM. I cannot use tf.data.Dataset.from_tfrecords() since preprocessing the whole thing before takes a lot of storage and I will eventually run out.\nThe question is : what's left for me for doing this cleanly with the possibility to reload the model after training for image inference ?\nThank you very much and feel free to ask for any other details.\nPierre-Luc","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":680,"Q_Id":53662978,"Users Score":1,"Answer":"Finally, I found a method to solve my problem.\nI first crop a subject's image without applying the actual crop. I only measure the slices I need to crop the volume to only the brain. I then serialize all the data set images into one TFRecord file, each training example being an image modality, original image's shape and the slices (saved as Int64 feature). \nI decode the TFRecords afterward. Each training sample are reshaped to the shape it contains in a feature. I stack all the image modalities into a stack using tf.stack() method. I crop the stack using the previously extracted slices (the crop then applies to all images in the stack). I finally get some random patches using tf.random_crop() method that allows me to randomly crop a 4-D array  (heigh, width, depth, channel).\nThe only thing I still haven't figured out is data augmentation. Since all this is occurring in Tensors format, I cannot use plain Python and NumPy to rotate, shear, flip a 4-D array. I would need to do it in the tf.Session(), but I would rather like to avoid this and directly input the training handle.\nFor the evaluation, I serialize in a TFRecords file only one test subject per file. The test subject contains all modalities too, but since there is no TensorFLow methods to extract patches in 4-D, the image is preprocessed in small patches using Scikit-Learn extract_patches() method. I serialize these patches to the TFRecords.\nThis way, training TFRecords is a lot smaller. I can evaluate the test data using batch prediction.\nThanks for reading and feel free to comment !","Q_Score":1,"Tags":"python,tensorflow","A_Id":54430444,"CreationDate":"2018-12-07T03:51:00.000","Title":"TensorFlow tf.data.Dataset API for medical imaging","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can Python read the .dtsx file? It is the file extension of Microsoft SSIS ETL packages. I want to write a Python program that will crawl SSIS packages and scrape all the table names. Thanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":216,"Q_Id":53667415,"Users Score":1,"Answer":"SSIS packages are really just big XML documents. For most purposes, you can treat them like any other text doc. I routinely use the \"Find In Files\" option in Notepad++ to do just the sort of thing you're looking to do programmatically. \nBe careful, of course, because accidental edits can hopelessly break the packages. (Nothing that I have any experience with. Really. I swear.)","Q_Score":0,"Tags":"python,ssis,scrapy","A_Id":53672199,"CreationDate":"2018-12-07T10:14:00.000","Title":"I want to crawl SSIS ETL packages stored on disk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some 1000 news articles related to science and technology. I need to train a classifier which will predict say 3(computer science, electronics, electrical) confidence scores for each article. \nEach score represents how much the article belongs to each field.\nThe confidence score will be a value between zero and one.\nBut the data set doesn't have a training label.  \nHow do I proceed from here? What kind of data do I need?\nHow do I train such a model?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":68,"Q_Id":53668101,"Users Score":1,"Answer":"It is not super clear what is your main idea, but articles typically do have tags or categories and you may use that for the classification labels.\nHumans are pretty good at articles tagging.","Q_Score":2,"Tags":"python,machine-learning,deep-learning,text-classification","A_Id":53672476,"CreationDate":"2018-12-07T10:55:00.000","Title":"MutiLabel classification","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a big dbf file, converting it to a pandas dataframe is taking a lot of time.\nIs there a way to convert the file into a dask dataframe?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":235,"Q_Id":53669318,"Users Score":0,"Answer":"Dask does not have a dbf loading method.\nAs far as I can tell, dbf files do not support random-access to the data, so it is not possible to read from sections of the file in separate workers, in parallel. I may be wrong about this, but certainly dbfreader makes no mention of jumping through to an arbitrary record.\nTherefore, the only way you could read from dbf in parallel, and hope to see a speed increase, would be to split your original data into multiple dbf files, and use dask.delayed to read each of them.\nIt is worth mentioning, that probably the reason dbfreader is slow (but please, do your own profiling!) is that it's doing byte-by-byte manipulations and making python objects for every record before passing the records to pandas. If you really wanted to speed things up, this code should be converted to cython or maybe numba, and a pre-allocated dataframe assigned into.","Q_Score":0,"Tags":"python,dataframe,dask,dbf","A_Id":53673661,"CreationDate":"2018-12-07T12:12:00.000","Title":"How to convert a dbf file to a dask dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a Jupiter Notebook for making a machine learning model using turicreate. When ever I upload a big .csv file, I get a message: kernel died. Since I am new in python is there an other way to Batch loading file or anyone nows how to fix this issue ?\nThe csv file is 52.9 MB\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3050,"Q_Id":53669913,"Users Score":0,"Answer":"53MB is not a big file ! You should try to load this in a ipython terminal to test.\nLoad as you would in a Jupyter to see if you have any issue. If there is no issue, This could be a bad installation of Jupyter.\nNote : The kernel dies mostly when you're out of RAM. But 53MB is not that big, assuming you have at least 2 or 4G or RAM on your laptop, an error like this shouldn't happend","Q_Score":1,"Tags":"python,python-3.x,machine-learning,jupyter-notebook,turi-create","A_Id":53670039,"CreationDate":"2018-12-07T12:49:00.000","Title":"Jupyter notebook : kernel died msg when loading big CSV file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using pycharm for the current project. \nWhen using the sqlite console under pycharm it shows that it has the version 3.25.1, which means that the sqlite upsert works perfectly. But on python, when I do import sqlite3 it imports the version 3.20.1 of it. \nI don't know why that difference in versions and I want to import the latest version of sqlite in python to be able to work with upserts.\nEdit: I'm using Fedora 27 and python 3.7.0","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":493,"Q_Id":53671129,"Users Score":0,"Answer":"It seems that sqlite 3.24+ requires Fedora 29+.\nI just upgraded my fedora to version 29 and I got sqlite 3.24.0","Q_Score":0,"Tags":"python,sqlite,pycharm,upsert","A_Id":54520508,"CreationDate":"2018-12-07T14:03:00.000","Title":"upgrade sqlite to 3.24+ pycharm","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently ported an installer from an unmaintainable and complicated batch script to python and thought it would be a nice idea to have a neat graphical front end for the console installer. I decided to use Kivy because I used it for some pet projects at home and I and UI designing went nice and fast.\nHowever, what I did not know until recently, is that Kivy seems only to work with OpenGL 2.0. Unfortunately our company's software is frequently installed on virtual machines and their virtualized graphics adapters often don't support OpenGL that is newer than 1.0 or 1.1 (VirtualBox for example). This prevents the Kivy app from starting or if it does start, doesn't render correctly.\nI searched the internet for a way to get Kivy to work without OpenGL 2.0. Some posts on github and I think on reddit suggested to use Angle instead of sdl2 or switching to glew. I tried the suggested solutions but with no success.\nI wonder, is there actually a way to get Kivy apps to work without OpenGL 2.0, like OpenGL 1.1 ?\nI use Python 3.6.4 and Kivy 1.10.1 on Windows as a dev and target system.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":2371,"Q_Id":53671970,"Users Score":3,"Answer":"Kivy targets OpenGL ES 2.0 as a minimum version. Note that OpenGL ES is not the same as OpenGL, it's closer to OpenGL 3.0.\nThis is a minimum required version, anything newer should work fine.\nYou can use angle on Windows if you want. I think we do it because it's more stable than relying on Windows OpenGL drivers, but I'm not sure.","Q_Score":7,"Tags":"python-3.x,kivy","A_Id":53675937,"CreationDate":"2018-12-07T14:57:00.000","Title":"Is there a way to use Kivy with OpenGL 1.1?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So the course that I am teaching has a requirement to teach the concept of random files - the course content specifies that the files are of a fixed size\/length, each location contains a record, and the location in which to store\/from which to read is determined through a hashing function (with collisions dealt with in a number of ways). While I am happy with the theory, and the pseudocode that is used to explain this concept, I have to admit, I am struggling with turning this into suitable Python code. \nWhat I need is to be able to\n\nuse a key value and a hashing function to determine a line number in a file (I can do this part)\njump to that line\/location in a specified file\namend or read the data on that line\/at that location\n\nI have seen a couple of mentions of pickling and mmap'ing when doing a bit of research but not sure if this would be the best approach. Very grateful for any guidance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":898,"Q_Id":53673108,"Users Score":1,"Answer":"The problem can be divided in two halves:\n\nDeciding a (binary?) fixed length format for your records, and being able to serialize\/deserialize your data from it; the result must be a fixed length bytestring. \nSeeking and reading\/writing such records on file. \n\nFor point 1, there are many possibilities. You can use the struct module to generate\/read binary data that is generally length.\nA way lower technology, but still valid, possibility is just to work with fixed-size text records, each field adequately padded with whitespace or whatever. These can be easily generated with bytes.format and split when reading using plain slicing. \nJust be careful that, for this to work right, your fields must be formatted\/padded adequately as byte strings, not unicode ones (if you were to compose the record as a Unicode string and then convert it to UTF-8 it may change length, as UTF-8 is a variable length encoding). \nAs for the second part, it's the easiest: just open the file in binary mode (you don't want newline translation to mess with your bytes), use the seek method to move to the record you need (using as position the number of record multiplied by its size) to read\/write, and then use read (passing the record size) or write (passing an appropriately sized record).","Q_Score":1,"Tags":"python,randomaccessfile","A_Id":53685212,"CreationDate":"2018-12-07T16:08:00.000","Title":"How can I mimic a random access file in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a weighted Graph using networkx and the topology is highly meshed. I would like to extract a number of paths between two nodes with distance minimization.\nTo clarify, the dijkstra_path function finds the weighted shortest path between two nodes, I would like to get that as well as the second and third best option of shortest weighted paths between two nodes.\nI tried using all_simple_paths and then ordering the paths in distance minimization order but it is extremely time consuming when the network is meshed with 500 nodes or so.\nAny thoughts on the matter? Thank you for your help!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":270,"Q_Id":53674393,"Users Score":1,"Answer":"Try networkx's shortest_simple_paths.","Q_Score":0,"Tags":"python-3.x,networkx,dijkstra","A_Id":53677838,"CreationDate":"2018-12-07T17:35:00.000","Title":"Descending order of shortest paths in networkx","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Anyone knows how to import an entire script from another folder without using os ? specifically  I want to import the script utils_database.py in basic_etl.py I tried to use from utils import utils_database in basic_etl.py but it does not work.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":53674809,"Users Score":2,"Answer":"The root folder of your project is one level up from the utils folder, so you have to include 01.etl as the top-level package, but then 01.etl is not a valid package name as it starts with a number, so you should rename the folder to something like etl first and then do from etl.utils import utils_database in base_etl.py.","Q_Score":1,"Tags":"python","A_Id":53674854,"CreationDate":"2018-12-07T18:08:00.000","Title":"Can't import script from other folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python a Stack implementation can be created using list. However, what are the benefits of creating stacks using Linked List","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":53676395,"Users Score":0,"Answer":"It doesn't matter that much in Python, since it can expand the list capacity when needed in constant time. A linked list implementation allows for the stack to dynamically change size without redefining the structure. So in this case, the benefits are pretty minimal, but it would be more important in other languages where an array would have to be reallocated to change size.","Q_Score":0,"Tags":"python,data-structures,stack","A_Id":53676488,"CreationDate":"2018-12-07T20:26:00.000","Title":"In what scenario we use Linked List implementation for Stack","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I know for the Button widget you can use the enter and leave signals to get it to perform actions upon hover over. I want to do the same for the Combobox (I have a dropdown menu I want to be able to access upon hovering over it). However, the enter signal doesn't seem to exist for this. Is there an alternative I could use? Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":86,"Q_Id":53677260,"Users Score":0,"Answer":"According to the documentation, the enter signal in the Gtk.Button class is deprecated.\nYou should use the enter-notify-event signal, which belongs to the Gtk.Widget class and it is inherited by all its childs, Gtk.ComboBox included.","Q_Score":0,"Tags":"python,gtk3","A_Id":53677991,"CreationDate":"2018-12-07T21:53:00.000","Title":"Python GTK 3+: Is there a \"enter\" like signal I can use for Combobox?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running Apache Airflow on Kubernetes and running into a strange error when trying to pull log files.\n*** Failed to fetch log file from worker. HTTPConnectionPool(host='geometrical-galaxy-7364-worker-0.geometrical-galaxy-7364-worker.astronomer-geometrical-galaxy-7364.svc.cluster.local', port=8793): Max retries exceeded with url: \/log\/FILE\/begin\/2018-12-06T00:00:00\/1.log (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7e86dab7b8>: Failed to establish a new connection: [Errno 111] Connection refused',))\nIt looks to me like there are too many requests being made on the stateful set (if I jump into the pod that holds the log files they are all there, but they don't get pulled into the UI that's trying to pull them).\nIs there somewhere that a limit for HTTP requests for a stateful set or a pod gets set?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":157,"Q_Id":53677492,"Users Score":0,"Answer":"I'm fairly certain the error you're seeing is from Airflow trying to fetch task logs from a worker via requests, which uses urllib3, that attempts retries on failed HTTP requests. \nYour webserver is attempting to get the logs, being denied by the worker server, and is erroring out. Make sure you're running airflow serve-logs on all workers and that the port is open from your webserver to each.","Q_Score":2,"Tags":"python-3.x,kubernetes,airflow,google-kubernetes-engine","A_Id":53734340,"CreationDate":"2018-12-07T22:20:00.000","Title":"Setting HTTP request settings on KubernetesPods","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I installed my orange from the official web site using the \"Classic installer\" that install python 3.6 together and all the libraries.But when I try to do a import Orange  from my python returns me \"ModuleNotFoundError\".\nI found a python.exe inside my Orange folder, there if I do a Orange import , works...\nHow I  can fix this problem with my python?\nThanks a lot.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":918,"Q_Id":53677585,"Users Score":2,"Answer":"When you install Orange using the installer, what you get is a base python installation (if one was not already found on your system) and a separate virtual environment with Orange and all the dependencies installed into it.\nThere should be a 'Orange Command Prompt' shortcut installed in the 'Start Menu'. That will open a Command Prompt with the proper environment activated so you can use python.exe, etc.","Q_Score":1,"Tags":"python,python-3.x,orange","A_Id":53702503,"CreationDate":"2018-12-07T22:30:00.000","Title":"Error to import Orange module in python 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"With Python, its possible to open two VLC instances and sync beetwen them?\nScenario:\nA two hours movie on first instance, a playlist\u2013m3u8 on second instance.\nUser forward the movie and second instance goes foward to another segment on playlist.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":53678057,"Users Score":0,"Answer":"I don't think this is a feature provided out of the box. You will need to hack this together yourself.","Q_Score":0,"Tags":"python,python-3.x,vlc,libvlc,m3u8","A_Id":53681244,"CreationDate":"2018-12-07T23:31:00.000","Title":"Its possible to sync two instances, one playing mp4 and another m3u8?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"It doesn't have to be exactly a trigger inside the database. I just want to know how I should design this, so that when changes are made inside MySQL or SQL server, some script could be triggered.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":53678628,"Users Score":0,"Answer":"One Way would be to keep a counter on the last updated row in the database, and then you need to keep polling(Checking) the database through python for new records in short intervals.\nIf the value in the counter is increased then you could use the subprocess module to call another Python script.","Q_Score":0,"Tags":"python,mysql,sql-server","A_Id":53678958,"CreationDate":"2018-12-08T01:12:00.000","Title":"Is it possible to trigger a script or program if any data is updated in a database, like MySQL?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I keep getting this traceback. I've used BeautifulSoup before with Python3 so I'm kind of confused as to why I would get this error now...\n'''Traceback (most recent call last):\n  File \"spider.py\", line 7, in \n    from bs4 import BeautifulSoup\n  File \"\/home\/cambam\/Desktop\/Python\/Coursera\/P4E\/CapStone\/pagerank\/bs4\/init.py\", line 54\n    'You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work.'<>'You need to convert the code, either by installing it (python setup.py install) or by running 2to3 (2to3 -w bs4).'\n                                                                                                       ^\nSyntaxError: invalid syntax\n'''","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1566,"Q_Id":53684458,"Users Score":0,"Answer":"OK I already figured out the answer.\nFirst I ran 'sudo apt install 2to3' in the command line \nThen 2to3 -w bs4\nI ran the program again and now it works.","Q_Score":0,"Tags":"python-3.x,python-2.7,beautifulsoup,traceback","A_Id":53684508,"CreationDate":"2018-12-08T16:18:00.000","Title":"BeautifulSoup Python3 version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can someone help me with how such a feature created automatically by Deep Feature Synthesis will actually work? I came across so many such features created and I'm not sure of how it works. I am unable to hook up the whole code here, although  I am sure people who read through the official featuretools document are aware of this example. Hoping to see a response! Thanks for your time!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":53685388,"Users Score":2,"Answer":"This is a feature generated for the \u201ccustomers\u201d table. \nThe feature SUM(sessions.MIN(transactions.amount)) can be interpreted as the sum of the minimum transaction amount from each session for a customer.\nThis is calculated by \n\nFinding all the sessions for a customer\nCalculating the minimum transaction amount for each session\nSumming that minimum amount across all sessions for a customer\n\nFeaturetools uses Deep Feature Synthesis to stack primitives to make more complex features. So in this case, it used the MIN primitive and SUM primitive to generate a feature with a depth of 2. This depth is useful because you get complex patterns for machine learning.\nFor example, the feature MAX(sessions.SUM(transactions.amount)) can be interpreted as the maximum amount a customer spent across all sessions.","Q_Score":0,"Tags":"python,featuretools","A_Id":53714708,"CreationDate":"2018-12-08T18:00:00.000","Title":"What does this even mean SUM(sessions.MIN(transactions.amount)) from the official featuretools documentation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've made a simple python application that I want to distribute for beta testing, I am on a windows computer and my beta testing Operating Systems include windows, mac, and ubuntu.\nMy question is how would I compile the program to a standalone application on Mac and Linux (Windows is already sorted)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":302,"Q_Id":53687571,"Users Score":0,"Answer":"From my experience, you cannot create a standalone version of a Python program for a different OS then the one you're using for compiling. \nI'm a Mac user, and when I want to generate a Windows Executable, I use a Windows that I installer at my VM, and compile from there. The same for Linux.\nIn any case, I use pyinstaller lib to generate an executable, which is really simple:\n1. Install the lib: pyinstaller.readthedocs.io\/en\/v3.3.1\/installation.html\n2. On your terminal, walk to the folder where is your .py file\n3. Just type pyinstaller --onefile filename.py\n4. 2 new folders will be created at the folder, dist and build. So just open the dist folder to find your executable\nHere you see I use the --onefile parameter, and I find best, because without it, your dist folder will generate a folder full of content from each dependency and other aspects, and it's not neat to share this with users. With --onefile the users will only find one executable file.","Q_Score":0,"Tags":"python,compilation","A_Id":53687795,"CreationDate":"2018-12-08T22:23:00.000","Title":"Compile Python Program For Distribution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a script, parts of which at some time able to run in parallel. Python 3.6.6\nThe goal is to decrease execution time at maximum. \nOne of the parts is connection to Redis, getting the data for two keys, pickle.loads for each and returning processed objects. \nWhat\u2019s the best solution for such a tasks?\nI\u2019ve tried Queue() already, but Queue.get_nowait() locks the script, and after {process}.join() it also stops execution even though the task is done. Using pool.map raises TypeError: can't pickle _thread.lock objects. \nAll I could achieve is parallel running of all parts but still cannot connect the results","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":53688617,"Users Score":0,"Answer":"cPickle.load() will release the GIL so you can use it in multiple threads easily. But cPickle.loads() will not, so don't use that.\nBasically, put your data from Redis into a StringIO then cPickle.load() from there.  Do this in multiple threads using concurrent.futures.ThreadPoolExecutor.","Q_Score":1,"Tags":"python-3.x,python-multiprocessing,python-multithreading","A_Id":53688653,"CreationDate":"2018-12-09T01:25:00.000","Title":"processing data in parallel python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am relatively new to programming, and I ran into a problem. I have installed Python 3.7 and pip 10.0, but when I try to do something such as installing virtualenv, a bunch of error messages appear. I resulted to using easy_install, but the problem using pip is still persistent. My only guess is that maybe some part of pip didn't install properly, but I tried unsuccessfully tried uninstalling and installing again.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2601,"Q_Id":53689540,"Users Score":0,"Answer":"I had the same exact issue, in case anyone else has the same problem I thought it was worth mentioning that my issue was caused by Autodesk Fusion 360. This is 3D CAD software that uses the cloud, and it adds a bunch of values with parentheses to the ProxyOverride registry variable mentioned by snakecharmerb:\nHKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings \"ProxyOverride\"\nThe values DID have closing parentheses, so I'm not sure why Python threw the error.  Regardless, after I removed the Autodesk related values temporarily, pip worked fine.  I put the values back into the registry after I was done and will have to remember this workaround in the future when I want to use pip.","Q_Score":1,"Tags":"python,windows,pip,python-requests,registry","A_Id":59216509,"CreationDate":"2018-12-09T05:01:00.000","Title":"re.error: missing ), unterminated subpattern at position 0 when installing via pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to install 'Keras' library from Anaconda on my laptop. I have the latest version of Anaconda. After that, I tried \n\nconda update conda\nconda update --all\n\nThe above two succeeds. After that I tried\n\nconda install -c conda-forge keras \nconda install keras\n\nBoth of the above fails with the below error.\n\nERROR conda.core.link:_execute(502): An error occurred while installing package >'::automat-0.7.0-py_1'.\n  CondaError: Cannot link a source that does not exist. >C:\\Users\\Anaconda3\\Scripts\\conda.exe\n\nI downloaded \"automat-0.7.0-py_1\" from anaconda site into one local folder and tried conda install from there. It works. However when I try to install Keras again, that again fails. I am clueless now what to do.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1214,"Q_Id":53689684,"Users Score":0,"Answer":"I guess the issue is that tensorflow is not yet released for Python3.7 (you have mentioned latest version of Anaconda). To overcome this, you may create a new environment with Python3.6 and simultaneously install Keras.\nconda create -n p360 python=3.6 anaconda tensorflow keras\nHere p360 is the name of the environment I chose.","Q_Score":1,"Tags":"python,tensorflow,keras,anaconda,theano","A_Id":54559052,"CreationDate":"2018-12-09T05:34:00.000","Title":"Issue with installing Keras library from Anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to iterate through each state, force the environment to go to that state, and then take a step and then use the \"info\" dictionary returned to see what are all the possible successor states?\nOr an even easier way to recover all possible successor states for each state, perhaps somewhere hidden?\nI saw online that something called MuJoKo or something like that has a set_state function, but I don't want to create a new environment, I just want to set the state of the ones already provided by openAi gym.\nContext: trying to implement topological order value iteration, which requires making a graph where each state has an edge to any state that any action could ever transition it to.\nI realize that obviously in some games that's just not provided, but for the ones where it is, is there a way?\n(Other than the brute force method of running the game and taking every step I haven't yet taken at whatever state I land at until I've reached all states and seen everything, which depending on the game could take forever)\nThis is my first time using OpenAi gym so please explain as detailed as you can. For example, I have no idea what Wrappers are.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":343,"Q_Id":53690171,"Users Score":1,"Answer":"No, OpenAI gym does not have a method for supplying all possible successor states. Generally, that's sort of the point of creating an algorithm with OpenAI gym. You are training an agent to learn what the outcome of its actions are; if it can look into the future and know what the results of its actions are, it kind of defeats the purpose. \nThe brute force method you described is probably the easiest way to accomplish what you're describing.","Q_Score":0,"Tags":"python,machine-learning,artificial-intelligence,reinforcement-learning,openai-gym","A_Id":53765741,"CreationDate":"2018-12-09T07:08:00.000","Title":"How to list possible successor states for each state in OpenAI gym? (strictly for normal MDPs)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having some issues with sorting a pandas dataframe.\nsort_index(axis=0) results in the dataframe sorting the index as 1 10 11 12 13... etc.\nWhile sort_index(axis=1) seems to work for the first couple of rows and then it gets completely disordered.\nI simply cannot wrap my head around what is going on. I want a simply numerical sorting of my indices, it seems that it ought to be the standard setting for sort_index.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":719,"Q_Id":53693429,"Users Score":0,"Answer":"You might have the index as a string type.\nI was having this issue after using the groupby() function. I fixed the problem by changing the column that later became my index to an int() with:\ndf['col_name'] = df['col_name'].astype(int) .","Q_Score":1,"Tags":"python,pandas,dataframe","A_Id":61193906,"CreationDate":"2018-12-09T14:40:00.000","Title":"Pandas sort_index numerically, not lexicographically","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having some issues with sorting a pandas dataframe.\nsort_index(axis=0) results in the dataframe sorting the index as 1 10 11 12 13... etc.\nWhile sort_index(axis=1) seems to work for the first couple of rows and then it gets completely disordered.\nI simply cannot wrap my head around what is going on. I want a simply numerical sorting of my indices, it seems that it ought to be the standard setting for sort_index.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":719,"Q_Id":53693429,"Users Score":2,"Answer":"you have 2 types of index, either row index (axis=0) or columns index (axis=1)\nyou are just arranging columns by name when you use axis=1. it does not reorder each row by values. check your columns names after your sort_index(axis=1) and you will understang","Q_Score":1,"Tags":"python,pandas,dataframe","A_Id":53693470,"CreationDate":"2018-12-09T14:40:00.000","Title":"Pandas sort_index numerically, not lexicographically","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install pycrypto for python 3 on windows, but it just keeps throwing an error about cl.exe failed with exit status 2.\nI have visual studio 2017 installed, with build tools, and it's still throwing the error. I've tried running as administrator, trying to install it manually, nothing is working. Please help.\nOutput: \nC:\\Users\\Computer\\Desktop>python -m pip install pycrypto\nCollecting pycrypto\n  Using cached https:\/\/files.pythonhosted.org\/packages\/60\/db\/645aa9af249f059cc3a368b118de33889219e0362141e75d4eaf6f80f163\/pycrypto-2.6.1.tar.gz\nInstalling collected packages: pycrypto\n  Running setup.py install for pycrypto ... error\n    Complete output from command C:\\Users\\Computer\\AppData\\Local\\Programs\\Python\\Python37\\python.exe -u -c \"import setuptools, tokenize;__file__='C:\\\\Users\\\\Computer\\\\AppData\\\\Local\\\\Temp\\\\pip-install-d7yv005p\\\\pycrypto\\\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))\" install --record C:\\Users\\Computer\\AppData\\Local\\Temp\\pip-record-t0teikv0\\install-record.txt --single-version-externally-managed --compile:\n    running install\n    running build\n    running build_py\n    creating build\n    creating build\\lib.win-amd64-3.7\n    creating build\\lib.win-amd64-3.7\\Crypto\n    copying lib\\Crypto\\pct_warnings.py -> build\\lib.win-amd64-3.7\\Crypto\n    copying lib\\Crypto\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\n    creating build\\lib.win-amd64-3.7\\Crypto\\Hash\n    copying lib\\Crypto\\Hash\\hashalgo.py -> build\\lib.win-amd64-3.7\\Crypto\\Hash\n    copying lib\\Crypto\\Hash\\HMAC.py -> build\\lib.win-amd64-3.7\\Crypto\\Hash\n    copying lib\\Crypto\\Hash\\MD2.py -> build\\lib.win-amd64-3.7\\Crypto\\Hash\n    copying lib\\Crypto\\Hash\\MD4.py -> build\\lib.win-amd64-3.7\\Crypto\\Hash\n    copying lib\\Crypto\\Hash\\MD5.py -> build\\lib.win-amd64-3.7\\Crypto\\Hash\n    copying lib\\Crypto\\Hash\\RIPEMD.py -> build\\lib.win-amd64-3.7\\Crypto\\Hash\n    copying lib\\Crypto\\Hash\\SHA.py -> build\\lib.win-amd64-3.7\\Crypto\\Hash\n    copying lib\\Crypto\\Hash\\SHA224.py -> build\\lib.win-amd64-3.7\\Crypto\\Hash\n    copying lib\\Crypto\\Hash\\SHA256.py -> build\\lib.win-amd64-3.7\\Crypto\\Hash\n    copying lib\\Crypto\\Hash\\SHA384.py -> build\\lib.win-amd64-3.7\\Crypto\\Hash\n    copying lib\\Crypto\\Hash\\SHA512.py -> build\\lib.win-amd64-3.7\\Crypto\\Hash\n    copying lib\\Crypto\\Hash\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\Hash\n    creating build\\lib.win-amd64-3.7\\Crypto\\Cipher\n    copying lib\\Crypto\\Cipher\\AES.py -> build\\lib.win-amd64-3.7\\Crypto\\Cipher\n    copying lib\\Crypto\\Cipher\\ARC2.py -> build\\lib.win-amd64-3.7\\Crypto\\Cipher\n    copying lib\\Crypto\\Cipher\\ARC4.py -> build\\lib.win-amd64-3.7\\Crypto\\Cipher\n    copying lib\\Crypto\\Cipher\\blockalgo.py -> build\\lib.win-amd64-3.7\\Crypto\\Cipher\n    copying lib\\Crypto\\Cipher\\Blowfish.py -> build\\lib.win-amd64-3.7\\Crypto\\Cipher\n    copying lib\\Crypto\\Cipher\\CAST.py -> build\\lib.win-amd64-3.7\\Crypto\\Cipher\n    copying lib\\Crypto\\Cipher\\DES.py -> build\\lib.win-amd64-3.7\\Crypto\\Cipher\n    copying lib\\Crypto\\Cipher\\DES3.py -> build\\lib.win-amd64-3.7\\Crypto\\Cipher\n    copying lib\\Crypto\\Cipher\\PKCS1_OAEP.py -> build\\lib.win-amd64-3.7\\Crypto\\Cipher\n    copying lib\\Crypto\\Cipher\\PKCS1_v1_5.py -> build\\lib.win-amd64-3.7\\Crypto\\Cipher\n    copying lib\\Crypto\\Cipher\\XOR.py -> build\\lib.win-amd64-3.7\\Crypto\\Cipher\n    copying lib\\Crypto\\Cipher\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\Cipher\n    creating build\\lib.win-amd64-3.7\\Crypto\\Util\n    copying lib\\Crypto\\Util\\asn1.py -> build\\lib.win-amd64-3.7\\Crypto\\Util\n    copying lib\\Crypto\\Util\\Counter.py -> build\\lib.win-amd64-3.7\\Crypto\\Util\n    copying lib\\Crypto\\Util\\number.py -> build\\lib.win-amd64-3.7\\Crypto\\Util\n    copying lib\\Crypto\\Util\\py3compat.py -> build\\lib.win-amd64-3.7\\Crypto\\Util\n    copying lib\\Crypto\\Util\\randpool.py -> build\\lib.win-amd64-3.7\\Crypto\\Util\n    copying lib\\Crypto\\Util\\RFC1751.py -> build\\lib.win-amd64-3.7\\Crypto\\Util\n    copying lib\\Crypto\\Util\\winrandom.py -> build\\lib.win-amd64-3.7\\Crypto\\Util\n    copying lib\\Crypto\\Util\\_number_new.py -> build\\lib.win-amd64-3.7\\Crypto\\Util\n    copying lib\\Crypto\\Util\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\Util\n    creating build\\lib.win-amd64-3.7\\Crypto\\Random\n    copying lib\\Crypto\\Random\\random.py -> build\\lib.win-amd64-3.7\\Crypto\\Random\n    copying lib\\Crypto\\Random\\_UserFriendlyRNG.py -> build\\lib.win-amd64-3.7\\Crypto\\Random\n    copying lib\\Crypto\\Random\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\Random\n    creating build\\lib.win-amd64-3.7\\Crypto\\Random\\Fortuna\n    copying lib\\Crypto\\Random\\Fortuna\\FortunaAccumulator.py -> build\\lib.win-amd64-3.7\\Crypto\\Random\\Fortuna\n    copying lib\\Crypto\\Random\\Fortuna\\FortunaGenerator.py -> build\\lib.win-amd64-3.7\\Crypto\\Random\\Fortuna\n    copying lib\\Crypto\\Random\\Fortuna\\SHAd256.py -> build\\lib.win-amd64-3.7\\Crypto\\Random\\Fortuna\n    copying lib\\Crypto\\Random\\Fortuna\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\Random\\Fortuna\n    creating build\\lib.win-amd64-3.7\\Crypto\\Random\\OSRNG\n    copying lib\\Crypto\\Random\\OSRNG\\fallback.py -> build\\lib.win-amd64-3.7\\Crypto\\Random\\OSRNG\n    copying lib\\Crypto\\Random\\OSRNG\\nt.py -> build\\lib.win-amd64-3.7\\Crypto\\Random\\OSRNG\n    copying lib\\Crypto\\Random\\OSRNG\\posix.py -> build\\lib.win-amd64-3.7\\Crypto\\Random\\OSRNG\n    copying lib\\Crypto\\Random\\OSRNG\\rng_base.py -> build\\lib.win-amd64-3.7\\Crypto\\Random\\OSRNG\n    copying lib\\Crypto\\Random\\OSRNG\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\Random\\OSRNG\n    creating build\\lib.win-amd64-3.7\\Crypto\\SelfTest\n    copying lib\\Crypto\\SelfTest\\st_common.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\n    copying lib\\Crypto\\SelfTest\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\n    creating build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Cipher\n    copying lib\\Crypto\\SelfTest\\Cipher\\common.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Cipher\n    copying lib\\Crypto\\SelfTest\\Cipher\\test_AES.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Cipher\n    copying lib\\Crypto\\SelfTest\\Cipher\\test_ARC2.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Cipher\n    copying lib\\Crypto\\SelfTest\\Cipher\\test_ARC4.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Cipher\n    copying lib\\Crypto\\SelfTest\\Cipher\\test_Blowfish.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Cipher\n    copying lib\\Crypto\\SelfTest\\Cipher\\test_CAST.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Cipher\n    copying lib\\Crypto\\SelfTest\\Cipher\\test_DES.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Cipher\n    copying lib\\Crypto\\SelfTest\\Cipher\\test_DES3.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Cipher\n    copying lib\\Crypto\\SelfTest\\Cipher\\test_pkcs1_15.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Cipher\n    copying lib\\Crypto\\SelfTest\\Cipher\\test_pkcs1_oaep.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Cipher\n    copying lib\\Crypto\\SelfTest\\Cipher\\test_XOR.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Cipher\n    copying lib\\Crypto\\SelfTest\\Cipher\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Cipher\n    creating build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Hash\n    copying lib\\Crypto\\SelfTest\\Hash\\common.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Hash\n    copying lib\\Crypto\\SelfTest\\Hash\\test_HMAC.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Hash\n    copying lib\\Crypto\\SelfTest\\Hash\\test_MD2.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Hash\n    copying lib\\Crypto\\SelfTest\\Hash\\test_MD4.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Hash\n    copying lib\\Crypto\\SelfTest\\Hash\\test_MD5.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Hash\n    copying lib\\Crypto\\SelfTest\\Hash\\test_RIPEMD.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Hash\n    copying lib\\Crypto\\SelfTest\\Hash\\test_SHA.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Hash\n    copying lib\\Crypto\\SelfTest\\Hash\\test_SHA224.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Hash\n    copying lib\\Crypto\\SelfTest\\Hash\\test_SHA256.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Hash\n    copying lib\\Crypto\\SelfTest\\Hash\\test_SHA384.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Hash\n    copying lib\\Crypto\\SelfTest\\Hash\\test_SHA512.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Hash\n    copying lib\\Crypto\\SelfTest\\Hash\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Hash\n    creating build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Protocol\n    copying lib\\Crypto\\SelfTest\\Protocol\\test_AllOrNothing.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Protocol\n    copying lib\\Crypto\\SelfTest\\Protocol\\test_chaffing.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Protocol\n    copying lib\\Crypto\\SelfTest\\Protocol\\test_KDF.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Protocol\n    copying lib\\Crypto\\SelfTest\\Protocol\\test_rfc1751.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Protocol\n    copying lib\\Crypto\\SelfTest\\Protocol\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Protocol\n    creating build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\PublicKey\n    copying lib\\Crypto\\SelfTest\\PublicKey\\test_DSA.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\PublicKey\n    copying lib\\Crypto\\SelfTest\\PublicKey\\test_ElGamal.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\PublicKey\n    copying lib\\Crypto\\SelfTest\\PublicKey\\test_importKey.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\PublicKey\n    copying lib\\Crypto\\SelfTest\\PublicKey\\test_RSA.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\PublicKey\n    copying lib\\Crypto\\SelfTest\\PublicKey\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\PublicKey\n    creating build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\n    copying lib\\Crypto\\SelfTest\\Random\\test_random.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\n    copying lib\\Crypto\\SelfTest\\Random\\test_rpoolcompat.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\n    copying lib\\Crypto\\SelfTest\\Random\\test__UserFriendlyRNG.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\n    copying lib\\Crypto\\SelfTest\\Random\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\n    creating build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\\Fortuna\n    copying lib\\Crypto\\SelfTest\\Random\\Fortuna\\test_FortunaAccumulator.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\\Fortuna\n    copying lib\\Crypto\\SelfTest\\Random\\Fortuna\\test_FortunaGenerator.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\\Fortuna\n    copying lib\\Crypto\\SelfTest\\Random\\Fortuna\\test_SHAd256.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\\Fortuna\n    copying lib\\Crypto\\SelfTest\\Random\\Fortuna\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\\Fortuna\n    creating build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\\OSRNG\n    copying lib\\Crypto\\SelfTest\\Random\\OSRNG\\test_fallback.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\\OSRNG\n    copying lib\\Crypto\\SelfTest\\Random\\OSRNG\\test_generic.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\\OSRNG\n    copying lib\\Crypto\\SelfTest\\Random\\OSRNG\\test_nt.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\\OSRNG\n    copying lib\\Crypto\\SelfTest\\Random\\OSRNG\\test_posix.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\\OSRNG\n    copying lib\\Crypto\\SelfTest\\Random\\OSRNG\\test_winrandom.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\\OSRNG\n    copying lib\\Crypto\\SelfTest\\Random\\OSRNG\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Random\\OSRNG\n    creating build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Util\n    copying lib\\Crypto\\SelfTest\\Util\\test_asn1.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Util\n    copying lib\\Crypto\\SelfTest\\Util\\test_Counter.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Util\n    copying lib\\Crypto\\SelfTest\\Util\\test_number.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Util\n    copying lib\\Crypto\\SelfTest\\Util\\test_winrandom.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Util\n    copying lib\\Crypto\\SelfTest\\Util\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Util\n    creating build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Signature\n    copying lib\\Crypto\\SelfTest\\Signature\\test_pkcs1_15.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Signature\n    copying lib\\Crypto\\SelfTest\\Signature\\test_pkcs1_pss.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Signature\n    copying lib\\Crypto\\SelfTest\\Signature\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\SelfTest\\Signature\n    creating build\\lib.win-amd64-3.7\\Crypto\\Protocol\n    copying lib\\Crypto\\Protocol\\AllOrNothing.py -> build\\lib.win-amd64-3.7\\Crypto\\Protocol\n    copying lib\\Crypto\\Protocol\\Chaffing.py -> build\\lib.win-amd64-3.7\\Crypto\\Protocol\n    copying lib\\Crypto\\Protocol\\KDF.py -> build\\lib.win-amd64-3.7\\Crypto\\Protocol\n    copying lib\\Crypto\\Protocol\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\Protocol\n    creating build\\lib.win-amd64-3.7\\Crypto\\PublicKey\n    copying lib\\Crypto\\PublicKey\\DSA.py -> build\\lib.win-amd64-3.7\\Crypto\\PublicKey\n    copying lib\\Crypto\\PublicKey\\ElGamal.py -> build\\lib.win-amd64-3.7\\Crypto\\PublicKey\n    copying lib\\Crypto\\PublicKey\\pubkey.py -> build\\lib.win-amd64-3.7\\Crypto\\PublicKey\n    copying lib\\Crypto\\PublicKey\\RSA.py -> build\\lib.win-amd64-3.7\\Crypto\\PublicKey\n    copying lib\\Crypto\\PublicKey\\_DSA.py -> build\\lib.win-amd64-3.7\\Crypto\\PublicKey\n    copying lib\\Crypto\\PublicKey\\_RSA.py -> build\\lib.win-amd64-3.7\\Crypto\\PublicKey\n    copying lib\\Crypto\\PublicKey\\_slowmath.py -> build\\lib.win-amd64-3.7\\Crypto\\PublicKey\n    copying lib\\Crypto\\PublicKey\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\PublicKey\n    creating build\\lib.win-amd64-3.7\\Crypto\\Signature\n    copying lib\\Crypto\\Signature\\PKCS1_PSS.py -> build\\lib.win-amd64-3.7\\Crypto\\Signature\n    copying lib\\Crypto\\Signature\\PKCS1_v1_5.py -> build\\lib.win-amd64-3.7\\Crypto\\Signature\n    copying lib\\Crypto\\Signature\\__init__.py -> build\\lib.win-amd64-3.7\\Crypto\\Signature\n    Skipping optional fixer: buffer\n    Skipping optional fixer: idioms\n    Skipping optional fixer: set_literal\n    Skipping optional fixer: ws_comma\n    running build_ext\n    warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.\n    building 'Crypto.Random.OSRNG.winrandom' extension\n    creating build\\temp.win-amd64-3.7\n    creating build\\temp.win-amd64-3.7\\Release\n    creating build\\temp.win-amd64-3.7\\Release\\src\n    C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe \/c \/nologo \/Ox \/W3 \/GL \/DNDEBUG \/MD -Isrc\/ -Isrc\/inc-msvc\/ -IC:\\Users\\Computer\\AppData\\Local\\Programs\\Python\\Python37\\include -IC:\\Users\\Computer\\AppData\\Local\\Programs\\Python\\Python37\\include \"-IC:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\ATLMFC\\include\" \"-IC:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\include\" \"-IC:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\include\\um\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\shared\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\um\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\winrt\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\cppwinrt\" \/Tcsrc\/winrand.c \/Fobuild\\temp.win-amd64-3.7\\Release\\src\/winrand.obj\n    winrand.c\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(27): error C2061: syntax error: identifier 'intmax_t'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(28): error C2061: syntax error: identifier 'rem'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(28): error C2059: syntax error: ';'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(29): error C2059: syntax error: '}'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(31): error C2061: syntax error: identifier 'imaxdiv_t'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(31): error C2059: syntax error: ';'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(41): error C2143: syntax error: missing '{' before '__cdecl'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(42): error C2146: syntax error: missing ')' before identifier '_Number'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(42): error C2061: syntax error: identifier '_Number'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(42): error C2059: syntax error: ';'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(43): error C2059: syntax error: ')'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(46): error C2143: syntax error: missing '{' before '__cdecl'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(47): error C2146: syntax error: missing ')' before identifier '_Numerator'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(47): error C2061: syntax error: identifier '_Numerator'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(47): error C2059: syntax error: ';'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(47): error C2059: syntax error: ','\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(49): error C2059: syntax error: ')'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(51): error C2143: syntax error: missing '{' before '__cdecl'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(57): error C2143: syntax error: missing '{' before '__cdecl'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(64): error C2143: syntax error: missing '{' before '__cdecl'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(70): error C2143: syntax error: missing '{' before '__cdecl'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(77): error C2143: syntax error: missing '{' before '__cdecl'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(83): error C2143: syntax error: missing '{' before '__cdecl'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(90): error C2143: syntax error: missing '{' before '__cdecl'\n    C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17763.0\\ucrt\\inttypes.h(96): error C2143: syntax error: missing '{' before '__cdecl'\n    error: command 'C:\\\\Program Files (x86)\\\\Microsoft Visual Studio\\\\2017\\\\Community\\\\VC\\\\Tools\\\\MSVC\\\\14.16.27023\\\\bin\\\\HostX86\\\\x64\\\\cl.exe' failed with exit status 2\nCommand \"C:\\Users\\Computer\\AppData\\Local\\Programs\\Python\\Python37\\python.exe -u -c \"import setuptools, tokenize;__file__='C:\\\\Users\\\\Computer\\\\AppData\\\\Local\\\\Temp\\\\pip-install-d7yv005p\\\\pycrypto\\\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))\" install --record C:\\Users\\Computer\\AppData\\Local\\Temp\\pip-record-t0teikv0\\install-record.txt --single-version-externally-managed --compile\" failed with error code 1 in C:\\Users\\Computer\\AppData\\Local\\Temp\\pip-install-d7yv005p\\pycrypto\\","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3517,"Q_Id":53694099,"Users Score":4,"Answer":"This helps me (Win 10, Python 3.7.4):\n\npip3 install pycryptodome\npip3 install --no-deps simple-crypt","Q_Score":6,"Tags":"python-3.x","A_Id":58427325,"CreationDate":"2018-12-09T16:01:00.000","Title":"Can't install pycrypto","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm not sure why it won't work, it may be an issue that you can't work around, but I would just like to know why it won't work. I am sorry if I waste your time, or didn't ask the question properly, I'm 16 and new to Python kind of.\nin main.py\nfrom day_one import day_one_def\nin day_one.py\nfrom main import main_home_window\nerror message\nImportError: cannot import name 'day_one'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":125,"Q_Id":53694339,"Users Score":1,"Answer":"It looks like you have a circular import: main imports from day_one and day_one imports from main. This isn't really how python is supposed to work. You should create linear dependencies, where the top module only relies on the ones below it, which only rely on the ones below them, etc.","Q_Score":1,"Tags":"python,python-3.x,function,tkinter,python-import","A_Id":53694666,"CreationDate":"2018-12-09T16:29:00.000","Title":"Python: Import a file from from day_one.py to main.py then in day_one I import a function from main.py. Error cannot import","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an astropy.table.table object holding stars data. One row per star with columns holding data such as Star Name, Max Magnitude, etc.\nI understand an astropy table's internal representation is a dict for each column, with the rows being returned on the fly as slices across the dict objects.\nI need to convert the astropy table to a Python list of dict objects, with one dict per star. Essentially this is both a transposition of the table and a conversion.\nI can obviously iterate through the table, by column within row, to build the dicts and add them to the list, but I was hoping there was a more efficient way?'","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":885,"Q_Id":53694408,"Users Score":0,"Answer":"I ended up iterating, slicing and copying as list which worked fine on the relatively small dataset.","Q_Score":1,"Tags":"python,list,dictionary,astropy","A_Id":56693911,"CreationDate":"2018-12-09T16:39:00.000","Title":"Convert astropy table to list of dictionaries","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I install Beautiful Soup in Anaconda Python 3.6.4 Windows 10:\n\nI downloaded and unpacked beautifulsoup4-4.6.3.tar.gz on my Desktop\nI created an environment variable Pythonbasepath including the following directories:\n\nC:\\Users\\Mika and Friends\\Anaconda3\nC:\\Users\\Mika and Friends\\Anaconda3\\Lib\nC:\\Users\\Mika and Friends\\Anaconda3\\include\nC:\\Users\\Mika and Friends\\Anaconda3\\DLLs\nC:\\Users\\Mika and Friends\\Anaconda3\\Scripts\nC:\\Users\\Mika and Friends\\Anaconda3\\Lib\\site-packages\n\nFrom the directory where I have extracted Beautiful Soup I try to run a command and I get an error: \n\n\nC:\\Users\\Mika and Friends\\Desktop\\bs4\\bs4>python setup.py install\n  'python' is not recognized as an internal or external command,\n  operable program or batch file.\n\nIt seems something is wrong with the environment variable setup, but I cannot figure out what.","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":12835,"Q_Id":53694696,"Users Score":6,"Answer":"Run the following command from Command Prompt: \nconda install -c anaconda beautifulsoup4\nThis is the easiest way to install a python library in Anaconda.","Q_Score":2,"Tags":"python","A_Id":53723165,"CreationDate":"2018-12-09T17:11:00.000","Title":"Cannot install Beautiful Soup in Anaconda Python 3.6.4 Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I install Beautiful Soup in Anaconda Python 3.6.4 Windows 10:\n\nI downloaded and unpacked beautifulsoup4-4.6.3.tar.gz on my Desktop\nI created an environment variable Pythonbasepath including the following directories:\n\nC:\\Users\\Mika and Friends\\Anaconda3\nC:\\Users\\Mika and Friends\\Anaconda3\\Lib\nC:\\Users\\Mika and Friends\\Anaconda3\\include\nC:\\Users\\Mika and Friends\\Anaconda3\\DLLs\nC:\\Users\\Mika and Friends\\Anaconda3\\Scripts\nC:\\Users\\Mika and Friends\\Anaconda3\\Lib\\site-packages\n\nFrom the directory where I have extracted Beautiful Soup I try to run a command and I get an error: \n\n\nC:\\Users\\Mika and Friends\\Desktop\\bs4\\bs4>python setup.py install\n  'python' is not recognized as an internal or external command,\n  operable program or batch file.\n\nIt seems something is wrong with the environment variable setup, but I cannot figure out what.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":12835,"Q_Id":53694696,"Users Score":-1,"Answer":"One method that happened to work, and I am not sure how valid (safe) it is for other users:\nI use Miniconda (smaller Anaconda packages) and installed bs4 through pip install bs4 instead of conda install bs4 (because it doesn't exist) in terminal whilst using my personal conda env to run a python program using BeautifulSoup. May save some trouble for others, but could be due to other settings on my device. \nI was using conda 4.8.3, Python 3.7.6, Windows 10 when this worked for me.","Q_Score":2,"Tags":"python","A_Id":60921099,"CreationDate":"2018-12-09T17:11:00.000","Title":"Cannot install Beautiful Soup in Anaconda Python 3.6.4 Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am programming in Python (in Sublime Text 3) and auto-complete feature works for 90% of the modules. Modules like os, sys, unittest...\nBut now I am trying to use modules like selenium and numpy and they don't have auto-complete feature.\nI am using Anaconda (conda) package distribution and I am using Anaconda ST3 Plugin. Also tried something called (a plugin) Selenium Snippets. None of that helps.\nPlease, any suggestions would be much appreciated.\nJuris.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3455,"Q_Id":53695279,"Users Score":0,"Answer":"OK. This is sorted by Trial and Error. Basically, I had to point my Sublime Text Anaconda Plugin to my Anaconda Package Managers path. I have edited the settings for Anaconda plugin and set the path like that:\n\"python_interpreter\": \"\/media\/Work\/anaconda3\/bin\/python\",\nAfter that, it picked up all the packages from Anaconda (Conda)\nThanks!","Q_Score":1,"Tags":"python,autocomplete,anaconda","A_Id":53696825,"CreationDate":"2018-12-09T18:16:00.000","Title":"Anaconda auto-complete for Python does not 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":"Assuming the storage size is important: \nI have a long list of digits (0-9) that I want to write to a file. From a storage standpoint, would it be more efficient to use ASCII or UTF-8 as an encoding? \nIs it possible to create a smaller file using something else?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2642,"Q_Id":53695343,"Users Score":4,"Answer":"There is absolutely no difference in this case; UTF-8 is identical to ASCII in this character range.\nIf storage is an important consideration, maybe look into compression. A simple Huffman compression will use something like 3 bits per byte for this kind of data. If there are periodicity patterns, a modern compression algorithm can take it even further.","Q_Score":1,"Tags":"python,encoding","A_Id":53695378,"CreationDate":"2018-12-09T18:22:00.000","Title":"ASCII vs UTF-8?","Data 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 few python and fortran code developed for conducting scientific simulations for a research problem. 90% of the code can only be executed as a serial process as the solution procedure is implicit. Often, while running the code in my laptop, I have noticed that it occupies 1 full core of the CPU at 90-100% all the time during simulation and each simulation lasts for 10+ hours.\nBut now as I need to run the same code multiple times, it has becomes too slow to do it in my laptop and it limit smooth functioning for other activities during the period of the simulation. My code generally requires low memory (<1 GB) but high computational power.  It requires no data transfer while running the simulation. Below are the two answers I seek:\n\nWhich ec2 instance type in Amazon Web Service (AWS) would be the best fit? \nIs it advisable to run, say 7 separate codes within an 8 vCPU machine or 7 codes in separate 2 vCPU multiple machines. I find the pricing for the latter in AWS to be economical. Also since high CPU rate is a requirement for my code, I have noticed that lower cores seems to offer more CPU speed.\n\nI would appreciate anyguidance in this matter.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":288,"Q_Id":53695443,"Users Score":1,"Answer":"this answer might be a bit late for you (2 and half years on), but in case you're still interested!\nThe best fit for the machine depends on what you need for the work you are doing. It can be a tradeoff between cost and speed. For example, if you run an 8-core machine with 8 concurrent processes, it will be done 8 times faster than the same speed cpu core. You could also run your process across multiple virtual machines.\nWith today's AWS instances, you can scale all the way up to 36 cores on a single machine. But in your AWS account, you could run hundreds of cores concurrently. So developing a way to run the code across machines will help you as you need to scale out.\nAt my company, we run hundreds of fortran programs concurrently across 40 computers in AWS and have been using spot instances instead of on-demand instances to lower costs.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-ec2,fortran,scientific-computing","A_Id":68184895,"CreationDate":"2018-12-09T18:35:00.000","Title":"Running multiple Python\/FORTRAN codes for scientific computations with Amazon EC2","Data 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 am trying to write a GA in Python to solve TSP. I would like to speed it up. Because right now, it takes 24 seconds to run 200 generations with a population size of 200.\nI am using a map with 29 cities. Each city has an id and (x,y) coordinates.\nI tried implementing a distance matrix, which calculates all the distances once and stores it in a list. So instead of calculating the distance using the sqrt() function 1M+ times, it only uses the function 406 times. Every time a distance between two cities is required, it is just retrieved from the matrix using the id of the two cities as the index.\nBut even with this, it takes just as much time. I thought sqrt() would be more expensive than just indexing a list. Is it not? Would a dictionary make it faster?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":53696084,"Users Score":0,"Answer":"The short answer:\nYes. Dictionary would make it faster.\nThe long answer:\nLets say, you pre-processing and calculates all distances once - Great! Now, lets say I want to find the distance between A and B. So, all I have to do now is to find that distance where I put it - it is in the list!\nWhat is the time complexity to find something in the list? Thats right - O(n)\nAnd how may times I'm going to use it? My guess according to your question: 1M+ times\nNow, that is a huge problem. I suggest you to use a dictionary so you could search in the pre-calculated distace between any two cities in O(1).","Q_Score":0,"Tags":"python,list,dictionary,time-complexity,sqrt","A_Id":53696362,"CreationDate":"2018-12-09T19:51:00.000","Title":"Solving TSP with GA: Should a distance matrix speed up run-time?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When in Jupyter I Shift+TAB on pandas.DataFrame, it displays e.g.\nTwo-dimensional size-mutable, potentially heterogeneous tabular data\nstructure with labeled axes (rows and columns). Arithmetic operations\nalign on both row and column labels. Can be thought of as a dict-like\ncontainer for Series objects. The primary pandas data structure.\nIs there any way to display this in Pycharm as well? Quick documentation (Ctrl+Q) doesnt display this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":62,"Q_Id":53696405,"Users Score":1,"Answer":"What you want here is help(pandas.DataFrame). Prints the same information as shift+TAB does in Jupyter.","Q_Score":0,"Tags":"python,pycharm,jupyter-notebook","A_Id":53709894,"CreationDate":"2018-12-09T20:32:00.000","Title":"How to display same detailed help in Pycharm as in Jupyter?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"the version of python is 3.6\nI tried to execute my code but, there are still some errors as below:\nTraceback (most recent call last):\n\nFile\n  \"C:\\Users\\tmdgu\\Desktop\\NLP-master1\\NLP-master\\Ontology_Construction.py\",\n  line 55, in \n      , binary=True)\nFile \"E:\\Program\n  Files\\Python\\Python35-32\\lib\\site-packages\\gensim\\models\\word2vec.py\",\n  line 1282, in load_word2vec_format\n      raise DeprecationWarning(\"Deprecated. Use gensim.models.KeyedVectors.load_word2vec_format instead.\")\nDeprecationWarning: Deprecated. Use\n  gensim.models.KeyedVectors.load_word2vec_format instead.\n\nhow to fix the code? or is the path to data wrong?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1129,"Q_Id":53697450,"Users Score":2,"Answer":"This is just a warning, not a fatal error. Your code likely still works.\n\"Deprecation\" means a function's use has been marked by the authors as no longer encouraged. \nThe function typically still works, but may not for much longer \u2013 becoming unreliable or unavailable in some future library release. Often, there's a newer, more-preferred way to do the same thing, so you don't trigger the warning message. \nYour warning message points you at the now-preferred way to load word-vectors of that format: use KeyedVectors.load_word2vec_format() instead. \nDid you try using that, instead of whatever line of code (not shown in your question) that you were trying before seeing the warning?","Q_Score":0,"Tags":"python,gensim,word2vec","A_Id":53714251,"CreationDate":"2018-12-09T22:47:00.000","Title":"Error for word2vec with GoogleNews-vectors-negative300.bin","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a regular website where HTML5, CSS3, JQUERY and static images have been used.\nI also have a Blog written in Django and I would like to integrate it in the website. \nI am really new to Django so I was wondering which is the best approach to use.\nShould I integrate the website code as part of the Django project or there are some other solutions? \nthanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":53703623,"Users Score":0,"Answer":"You have 2 ways of integrating your current site with Django.\n1) You can write API with DjangoRestFramework and make requests with jQuery AJAX in order to get content from Django. \n2) You can use your current HTML files as your Django project templates for rendering content from Django.","Q_Score":1,"Tags":"python,django,html","A_Id":53703710,"CreationDate":"2018-12-10T10:21:00.000","Title":"Integrate Django blog project in HTML website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The website is running using node server. I want to create a python flask rest api to connect to pop up chat window of this website.My python flask is running in 8085 port and node server is running in 8082 port.\nin python flask app.py \n\n@app.route('\/') \n  def hello_world():\n      return render_template('popupchat.html') \n@app.route('\/chat',methods=[\"POST\"]) def chat():\n\nthis popupchat.html is pointing to website pupupchat window. and there is one bind.js script having  $.post(\"\/chat\" , if i want to connect this pop up chat window running in node server to python flask server , how i will connect .\ni appreciate your suggestions","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":949,"Q_Id":53711272,"Users Score":0,"Answer":"If you are just debugging try to adjust the port on the side of the chat window. You can tell the chat window to reach a certain port by altering the url you are trying to reach. Example:\nhttp:\/\/your_ip:your_port\/your_route or in your case http:\/\/your_ip:8085\/your_route\nIf you are already deployed please talk to your admin since this might be depending on your server.","Q_Score":1,"Tags":"javascript,python,html,flask-restful","A_Id":53712290,"CreationDate":"2018-12-10T18:07:00.000","Title":"python flask running in one port connected to UI running in node server different port","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to automate a python script through the Windows Task Scheduler but its not working. At the end of my python script. two CSV files should be created but they arent.\nI tried the following: \n1. Copied the address of my python.exe to Program\/Script.\n\nC:\\Program Files\\Python35\\python.exe\n\n\nIn the Add arguments, i put the name of my file\n\n\nHistorical Aggregation.py\n\n\nIn the Start in (optional), i put the path of my python script\n\n\nC:\\Users\\myname\\PycharmProjects\\Project1\n\nAm I missing something","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":9087,"Q_Id":53712180,"Users Score":2,"Answer":"Another approach would be to set fields as:\n\nProgram\/Script - your python path (with quotation marks):\n\n\n\"C:\\Program Files\\Python35\\python.exe\"\n\n\nAdd arguments - full file name of the script, including it's path (with quotation marks):\n\n\n\"C:\\Users\\myname\\PycharmProjects\\Project1\\Historical Aggregation.py\"","Q_Score":2,"Tags":"python,scheduled-tasks","A_Id":53712600,"CreationDate":"2018-12-10T19:14:00.000","Title":"Running a python script through Windows Scheduler not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to automate a python script through the Windows Task Scheduler but its not working. At the end of my python script. two CSV files should be created but they arent.\nI tried the following: \n1. Copied the address of my python.exe to Program\/Script.\n\nC:\\Program Files\\Python35\\python.exe\n\n\nIn the Add arguments, i put the name of my file\n\n\nHistorical Aggregation.py\n\n\nIn the Start in (optional), i put the path of my python script\n\n\nC:\\Users\\myname\\PycharmProjects\\Project1\n\nAm I missing something","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":9087,"Q_Id":53712180,"Users Score":3,"Answer":"I had a very similar issue, and solved it in a different way. Here my step by step guide:\n\nTransform the python script to an .exe, using in the DOS cmd prompt the command: \npyinstaller -- onefile [name of the file.py]\nPlace the CSV file that you want to update in the same folder as the .exe file created\nCreate a basic task on Windows Scheduler, with the following properties:\n\nGeneral - select\n\nRun whether user is logged on or not \nadd the PC password. For my PC, use the user name DESKTOP-M40FS79\\dario and the PC password\nRun with highest privileges \n\nTriggers \u2013 select \n\nDaily\nRepeat task every 30 minutes\nStop task if it runs longer than 15 minutes\n\nActions\n\nUnder Program\/ Script insert the path to your .exe file, for instance, C:\\Pythondata\\dist\\test.exe\nUnder Start in (optional) insert the path to the directory where the CSV and .exe files are, for instance C:\\Pythondata\\dist\\\n\nConditions - select\n\nStart the task only if the computer is on AC power, and make sure you have connected the power\nWake the computer to run this task\n\nSettings \u2013 leave the default options\n\nSave the task by inserting the password\nLeave the task status on \u201cReady\u201d\n\nGood luck!","Q_Score":2,"Tags":"python,scheduled-tasks","A_Id":56252185,"CreationDate":"2018-12-10T19:14:00.000","Title":"Running a python script through Windows Scheduler not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a question which is about code design in python.\nI'm working on a certain project and I can see that there is a certain amount of different types of errors that I have to handle often, which results in lots of places where there is a try...execept clause that repeats itself.\nNow the question is, will it be more preferred to create one exception handler (a decorator) and decorate with it all those functions that have those repeating errors.\nThe trade off here is that if I create this exception handler decorator it will become quite a big of a class\/function which will then make the person reading the code to try and understand another piece of complicated (maybe) logic to understand how the error is handled, where if I don't use the decorator, its pretty clear to the reader how is it handled.\nAnother option is to create multiple decorators for each of the types of the errors.\nOr maybe just leave all those try...except clauses even though they are being repeated.\nAny opinions on the matter and maybe other solutions? Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":53712222,"Users Score":0,"Answer":"A lot of this is subjective, but I personally think it's better for exception handling code to be close to where the error is occurring, for the sake of readability and debugging ease. So:\n\nThe trade off here is that if I create this exception handler decorator it will become quite a big of a class\/function\n\nI would recommend against the Mr. Fixit class. When an error occurs and the debugger drops you into the Mr. Fixit, you then have to walk back quite a bit before you can figure out why the error happened, and what needs to be fixed to make it go away. Likewise, an unfamiliar developer reading your code loses the ability to understand just one small snippet pertaining to a particular error, and now has to work through a large class. As an added issue, a lot of what's in the Mr. Fixit is irrelevant to the one error they're looking at, and the place where the error handling occurs is in an entirely different place. With decorators especially, I feel like you are sacrificing readability (especially for someone less familiar with decorators than you) while gaining not much.\nIf written with some care, try\/catch blocks are not very performance intensive and do not clutter up code too much. I would suggest erring on the side of more try\/catches, with every try\/catch close to what it's handling, so that you can tell at a glance how errors are handled for any given piece of code (without having to go to a different file).\nIf you are repeating code a lot, you can either refactor by making the code inside the catch a method that can be repeatedly called, or by making the code inside the try its own method that does its error handling inside its body. When in doubt, keep it simple.\nAlso, I hate being a close\/off-topic Nazi so I won't flag, but I do think this question is more suited to Programmers@SE (being an abstract philosophy\/conceptual question) and you might get better responses on that site.","Q_Score":0,"Tags":"python,design-patterns","A_Id":53712353,"CreationDate":"2018-12-10T19:18:00.000","Title":"Big exception handler or lots of try...except clauses","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have a rainfall map which has three dimensions (latitude, longitude and rainfall value), if I put it in an array, do I need a 2D or 3D array? How would the array look like?\nIf I have a series of daily rainfall map which has four dimensions (lat, long, rainfall value and time), if I put it in an array, do I need a 3D or 4D array?\nI am thinking that I would need a 2D and 3D arrays, respectively, because the latitude and longitude can be represented by a 1D array only (but reshaped such that it has more than 1 rows and columns). Enlighten me please.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":53714557,"Users Score":0,"Answer":"I believe that the rainfall value shouldn't be a dimension. Therefore, you could use 2D array[lat][lon] = rainfall_value or 3D array[time][lat][lon] = rainfall_value respectively.\nIf you want to reduce number of dimensions further, you can combine latitude and longitude into one dimension as you suggested, which would make arrays 1D\/2D.","Q_Score":2,"Tags":"python,arrays","A_Id":53714817,"CreationDate":"2018-12-10T22:20:00.000","Title":"physical dimensions and array dimensions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to convert my python file (.py) into a Windows executable (.exe). To do this, I am using Pyinstaller. My python includes the module PyBluez for Bluetooth capabilities. When I run the command pyinstaller <path> -F from the directory of the py file, it gives an error:\n\nFileNotFoundError: [Errno 2] No such file or directory: 'c:\\users\\X\\appdata\\local\\programs\\python\\python37-32\\lib\\site-packages\\pybluez-0.22-py3.7-win32.egg\\bluetooth\\widcomm.py'\n\nAfter quite a bit of research, I am unable to figure out what is wrong with my program. Do I need to specifically specify where to find the egg file? If so, How would I do that? Thank you! Also, I tried to use cx_Freeze and it also gave an error about the bluetooth module:\n\nTraceback (most recent call last):\n    File \"C:\\Users\\X\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\cx_Freeze\\initscripts__startup__.py\", line 14, in run\n      module.run()\n    File \"C:\\Users\\X\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\cx_Freeze\\initscripts\\Console.py\", line 26, in run\n      exec(code, m.dict)\n    File \"BuzzerBeater.py\", line 3, in \n  ModuleNotFoundError: No module named 'bluetooth'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1150,"Q_Id":53715182,"Users Score":0,"Answer":"I had the same problem, and managed to solve it by unzipping the .egg file to a folder with the same name (including .egg in the folder name), in my case C:\\Users\\X\\AppData\\Local\\Programs\\Python\\Python37\\Lib\\site-packages\\PyBluez-0.22-py3.7-win-amd64.egg\\.","Q_Score":0,"Tags":"python,pyinstaller,cx-freeze,egg","A_Id":54147425,"CreationDate":"2018-12-10T23:21:00.000","Title":"Pyinstaller Error Bundling Egg Files 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":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am new to python and am unsure of how the breakpoint method works. Does it open the debugger for the IDE or some built-in debugger?\nAdditionally, I was wondering how that debugger would be able to be operated.\nFor example, I use Spyder, does that mean that if I use the breakpoint() method, Spyder's debugger will open, through which I could the Debugger dropdown menu, or would some other debugger open?\nI would also like to know how this function works in conjunction with the breakpointhook() method.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1616,"Q_Id":53715811,"Users Score":4,"Answer":"No, debugger will not open itself automatically as a consequence of setting a breakpoint.\nSo you have first set a breakpoint (or more of them), and then manually launch a debugger.\nAfter this, the debugger will perform your code as usually, but will stop performing instructions when it reaches a breakpoint - the instruction at the breakpoint itself it will not perform. It will pause just before it, given you an opportunity to perform some debug tasks, as\n\ninspect variable values,\nset variables manually to other values,\ncontinue performing instructions step by step (i. e. only the next instruction),\ncontinue performing instructions to the next breakpoint,\nprematurely stop debugging your program.\n\nThis is the common scenario for all debuggers of all programming languages (and their IDEs).\nFor IDEs, launching a debugger will \n\nenable or reveal debugging instructions in their menu system,\nshow a toolbar for them and will,\nenable hot keys for them.\n\nWithout setting at least one breakpoint, most debuggers perform the whole program without a pause (as launching it without a debugger), so you will have no opportunity to perform any debugging task.\n(Some IDEs have an option to launch a debugger in the \"first instruction, then a pause\" mode, so you need not set breakpoints in advance in this case.)\n\nYes, the breakpoint() built-in function (introduced in Python 3.7) stops executing your program, enters it in the debugging mode, and you may use Spyder's debugger drop-down menu.\n(It isn't a Spyders' debugger, only its drop-down menu; the used debugger will be still the pdb, i. e. the default Python DeBugger.)\nThe connection between the breakpoint() built-in function and the breakpointhook() function (from the sys built-in module) is very straightforward - the first one directly calls the second one. \nThe natural question is why we need two functions with the exactly same behavior?\nThe answer is in the design - the breakpoint() function may be changed indirectly, by changing the behavior of the breakpointhook() function.\nFor example, IDE creators may change the behavior of the breakpointhook() function so that it will launch their own debugger, not the pdb one.","Q_Score":5,"Tags":"python,python-3.x,methods,built-in","A_Id":53715996,"CreationDate":"2018-12-11T00:40:00.000","Title":"Use of Breakpoint Method","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"HIHello everyone\nI have a Raspberry Pi that contain some data,\non another side, I have a server with a server, also there is a webpage connecting with the same server.\nwhat do I need? \n1- the Raspberry Pi must send its data to a server \n2-if the user set some data to the database by webpage the Raspberry Pi must get this data \n3-Raspberry Pi must listen to the database to know if there is an update or not.\nwhat the best way to do these points, is there any protocol for IoT can do these? \nI need any hint :) \nthank u for all.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":483,"Q_Id":53715817,"Users Score":0,"Answer":"Try connecting your RPi with your server through any means of local area connection, it could be a connection through a wifi network or using a lan cable or even through serial ports. If successful in this attempt then you can access disk drive folders inside the server. In the webpage running on server ,make it listen for certain values and write the status to a text file or an database. Then make RPi to continuously monitor those file for data updation and make it work according to it.","Q_Score":0,"Tags":"php,python,database,raspberry-pi,iot","A_Id":53722341,"CreationDate":"2018-12-11T00:40:00.000","Title":"how set\/get data from Raspberry Pi to 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'm new to programming and I just downloaded Anaconda a few days ago for Windows 64-bit. I came across the Invent with Python book and decided I wanted to work through it so I downloaded that too. I ended up running into a couple issues with it not working (somehow I ended up with Spyder (Python 2.7) and end=' ' wasn't doing what it was supposed to so I uninstalled and reinstalled Anaconda -- though originally I did download the 3.7 version). It looked as if I had the 2.7 version of Pygame. I'm looking around and I don't see a Pygame version for Python 3.7 that is compatible with Anaconda. The only ones I saw were for Mac or not meant to work with Anaconda. This is all pretty new to me so I'm not sure what my options are. Thanks in advance.\nAlso, how do I delete the incorrect Pygame version?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1501,"Q_Id":53716005,"Users Score":2,"Answer":"just use pip install pygame & python will look for a version compatible with your installation.\nIf you're using Anaconda and pip doesn't work on CMD prompt, try using the Anaconda prompt from start menu.","Q_Score":0,"Tags":"python,python-3.x,pygame,anaconda,spyder","A_Id":53718434,"CreationDate":"2018-12-11T01:14:00.000","Title":"Is there an appropriate version of Pygame for Python 3.7 installed with Anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using keyboard module in Python to record keystrokes.\ndata = keyboard.record(until='esc')\nThis will keep recording the keystrokes until 'escape' key is pressed. So once I press the escape key, it stops recording and data stores the keywords. \nBut if I close the program forcefully, data will not store anything. What can I do so that it keeps recording until the user closes the program, either forcefully or if I shut down my computer, and stores the recorded data in data?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":53718512,"Users Score":0,"Answer":"First I don't know why you want to do this, but I guess it would stop recording when you either quit the program or even shut down your pc anyway. Maybe if you don't want stop recording until computer shutdown, then just don't press 'escape' right?","Q_Score":0,"Tags":"python,python-3.x,keyboard-events,keylogger","A_Id":53719284,"CreationDate":"2018-12-11T06:24:00.000","Title":"How to keep recording in keyboard module until the program is terminated","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've recently reinstalled windows on my workstation so I needed to reinstall python and pip, before the reinstallation, the command pip install whatever was working properly.\nBut then after the reinstallation of Windows 10 when I type that command it won't return anything, not even an error, I've searched other solution and I found that this command python -m pip install whatever works fine.\nWhat is changed?\nHow can I let the first command work again?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":12548,"Q_Id":53720324,"Users Score":1,"Answer":"As Bensalem has said, you need to add pip to your variable path in order to be able to use it without calling the script with python (which is in your path).\nThe -m refers to the passable argument to python;\n\n-m mod : run library module as a script (terminates option list)","Q_Score":3,"Tags":"python,path,pip,windows-10","A_Id":53720458,"CreationDate":"2018-12-11T08:43:00.000","Title":"why \"pip install\" doesn't work but \"python -m pip install\" works?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've recently reinstalled windows on my workstation so I needed to reinstall python and pip, before the reinstallation, the command pip install whatever was working properly.\nBut then after the reinstallation of Windows 10 when I type that command it won't return anything, not even an error, I've searched other solution and I found that this command python -m pip install whatever works fine.\nWhat is changed?\nHow can I let the first command work again?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":12548,"Q_Id":53720324,"Users Score":2,"Answer":"This is a PATH problem. On a standard Python3 installation on Windows, python.exe and pip.exe are in different folders. Let us say that Python is installed just under TOP, then:\n\npython.exe (and pythonw.exe) are in TOP\\Python3x (x being minor version such as Python37)\npip.exe is in TOP\\Python3x\\Scripts\npy.exe is in WINDOWSDIR (normally C:\\Windows)\n\nThat is the reason why:\n\npy -m pip install ... always works on Windows (provided pip is installed)\npython -m pip install ... requires ...\\Python3x to be in the PATH\npip install ... requires ...\\Python3x\\Scripts to be in the PATH","Q_Score":3,"Tags":"python,path,pip,windows-10","A_Id":53720525,"CreationDate":"2018-12-11T08:43:00.000","Title":"why \"pip install\" doesn't work but \"python -m pip install\" works?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm running python 3.7 on Windows and I have installed python-dotenv in my virtual environment as well as flask.  I have a .flaskenv file in the root of my project where I execute flask run, it looks as if python\/flask is not recognizing python-dotenv .flaskenv file it ignores my parameters and states that I do not have a FLASK_APP value assigned.  This same setup works fine on a Linux workstation.  Is there something different to configure on windows to get this to work?\nThanks ahead of time.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":717,"Q_Id":53725865,"Users Score":0,"Answer":".flaskenv seems to be working fine on Windows 10. Have you tried creating a new file named .flaskenv, without specifying any extension, in Visual Studio Code? A .flaskenv file of FLASKENV FILE type gets automatically created. I have in there a single line FLASK_APP=yourFileName.py.\nHope this helps.","Q_Score":2,"Tags":"python,flask","A_Id":56429408,"CreationDate":"2018-12-11T14:08:00.000","Title":"Flask run not recognizing python-dotenv on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I'm running python 3.7 on Windows and I have installed python-dotenv in my virtual environment as well as flask.  I have a .flaskenv file in the root of my project where I execute flask run, it looks as if python\/flask is not recognizing python-dotenv .flaskenv file it ignores my parameters and states that I do not have a FLASK_APP value assigned.  This same setup works fine on a Linux workstation.  Is there something different to configure on windows to get this to work?\nThanks ahead of time.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":717,"Q_Id":53725865,"Users Score":1,"Answer":"I ran into the same issue and resolved it by executing python -m flask run instead of flask run. The -m allows modules to be located and executed.","Q_Score":2,"Tags":"python,flask","A_Id":59671502,"CreationDate":"2018-12-11T14:08:00.000","Title":"Flask run not recognizing python-dotenv on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have found some code which is apparently designed for python 3.6.\nFor some reason I need to run that code in a python 3.5 environment.\nSupposedly, the two versions should be backward compatible.\nHowever, the original code abuses in f-strings, raising hundreds of errors in py35\ndo you know any tool to remove those fstrings, or a clean workaround?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1158,"Q_Id":53729421,"Users Score":2,"Answer":"You can't create a backward-compatible Python 3.6 piece of software if you're using f-String formatting. The reason for this is that it's a fundamental syntax feature, so \"making\" it compatible with Python 3.5, for example, would imply changing the Python 3.5 interpreter itself.\nThe only \"clean workaround\" I can think of is formatting the strings in a way that does not conflict the previous Python versions you want your software compatible with.\nHope this helps.","Q_Score":3,"Tags":"python,python-3.x,python-3.5,f-string","A_Id":57394945,"CreationDate":"2018-12-11T17:33:00.000","Title":"how to fix f-strings breaking backward compatibility python 3.5\/3.6+","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to retrieve or reformat the falsifying example after a test failure? The point is to show the example data in a different format - data generated by the strategy is easy to work with in the code but not really user friendly, so I'm looking at how to display it in a different form. Even a post-mortem tool working with the example database would be enough, but there does not seem to be any API allowing that, or am I missing something?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":53729754,"Users Score":0,"Answer":"Even a post-mortem tool working with the example database would be enough, but there does not seem to be any API allowing that, or am I missing something?\n\nThe example database uses a private format and only records the choices a strategy made to generate the falsifying example, so there's no way to extract the data of the example short of re-running the test.\nStuart's recommendation of hypothesis.note(...) is a good one.","Q_Score":1,"Tags":"python,python-hypothesis","A_Id":53777577,"CreationDate":"2018-12-11T17:54:00.000","Title":"python-hypothesis: Retrieving or reformatting a falsifying example","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any library to save images in binary (1bit per pixel) .tiff compressed file?\nopencv and pillow cannot do that","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1104,"Q_Id":53729889,"Users Score":0,"Answer":"You can try using libtiff.\nInstall using pip install libtiff","Q_Score":0,"Tags":"python,tiff","A_Id":53730003,"CreationDate":"2018-12-11T18:03:00.000","Title":"How to save image as binary compressed .tiff python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My goal is to add 10M contacts to telegram.\nHow can we add contacts to telegram using telegram API? \nI have tried using telethon in which I batched 500 contacts in one request. However, telegram responded all such requests with all contacts in retry_contacts and none were imported.\nI have also found out a solution to convert the txt file of\n10M contacts to csv file and import them using an android app.\nBut this takes approx 10 mins for 10k contacts. So this won't be\na good idea for adding 10M contacts.\nAny other method for having this done is also welcomed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9550,"Q_Id":53730525,"Users Score":9,"Answer":"This is not possible. Telegram has deliberately set limits on the number of contacts you can add. Initially you can add about 5000 contacts and after that you can add about 100 more every day. This is because of security not decreasing their API load. If you could add 10M numbers, you could easily map @usernames to numbers which is against Telegram privacy policy.\nIn my experience, the best practical option is to add an array of 10 numbers each time using telethon's ImportContactsRequest, until you get locked. Then try 24 hours later again until you get locked again, and so on. This is the fastest solution and due to Telegram restrictions, if you only have 1 SIM card, it takes around 274 years to add 10M contacts.","Q_Score":6,"Tags":"python,automation,contacts,telegram,telethon","A_Id":53736422,"CreationDate":"2018-12-11T18:46:00.000","Title":"How to add Millions of contacts to 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":"In my view.py I obtain a date from my MSSQL database in this format 2018-12-06 00:00:00.000 so I pass that value as context like datedb and in my html page I render it like this {{datedb|date:\"c\"}} but it shows the date with one day less like this:\n\n2018-12-05T18:00:00-06:00\n\nIs the 06 not the 05 day.\nwhy is this happening? how can I show the right date?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":19,"Q_Id":53731263,"Users Score":0,"Answer":"One way of solve the problem was chage to USE_TZ = False has Willem said in the comments, but that gives another error so I found the way to do it just adding in the template this {% load tz %} and using the flter |utc on the date variables like datedb|utc|date:'Y-m-d'.","Q_Score":0,"Tags":"python,django,django-templates,django-template-filters","A_Id":53749903,"CreationDate":"2018-12-11T19:43:00.000","Title":"Template rest one day from the date","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to perform cross-validation on NMF to find the best parameters to use. I tried using the sklearn cross-validation but get an error that states the NMF does not have a scoring method. Could anyone here help me with that? Thank you all","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":657,"Q_Id":53732904,"Users Score":1,"Answer":"A property of nmf is that it is an unsupervised (machine learning) method. This generally means that there is no labeled data that can serve as a 'golden standard'. \nIn case of NMF you can not define what is the 'desired' outcome beforehand.\nThe cross validation in sklearn is designed for supervised machine learning, in which you have labeled data by definition.\nWhat cross validation does, it holds out sets of labeled data, then trains a model on the data that is leftover and evaluates this model on the held out set. For this evaluation any metric can be used. For example: accuracy, precision, recall and F-measure, and for computing these measures it needs labeled data.","Q_Score":0,"Tags":"python,scikit-learn,nmf","A_Id":55491090,"CreationDate":"2018-12-11T21:55:00.000","Title":"How to perform cross validation on NMF Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a program that accesses a local BOX folder which should be synced with BOX Web before execution. The local BOX folder will be synced by default whenever there is a change in the BOX Web. But sometimes, the local folder doesn't get sync with Web unless we give a manual refresh.  \nQuestion: Is there a way to refresh the local folder using Python? So that I can refresh and start the program.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":348,"Q_Id":53736450,"Users Score":0,"Answer":"use os.stat(), it will give updated status of folder","Q_Score":1,"Tags":"python-3.x,refresh,box","A_Id":53737606,"CreationDate":"2018-12-12T05:12:00.000","Title":"Python: Refresh local folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created some models and when I run python manage.py db migrate command it creates migrations file, so that is fine.\npython manage.py db upgrade command also creates table in Database.\nIf I again run the python manage.py db migrate command then it is creating migrations file for those models that I have upgraded recently.\nCan you please help me to resolve it.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":221,"Q_Id":53737789,"Users Score":0,"Answer":"I think the problem is to manage.py. If you did it as described on flask-migration site and stored all your models in this file - flask-migration just get these models and generates migrations and will do it always. You wrapped the standard command in your file and this is the problem.\nIf you want to fix it - store models in another directory (or another file), add them to an app and use command flask db migrate. In this case, flask-migration will generate migration for models only at first time, for others, it will detect changes and generate migrations only for changes.\nBut be careful, flask-migration don't see all changes. From site:\n\nThe migration script needs to be reviewed and edited, as Alembic currently does not detect every change you make to your models. In particular, Alembic is currently unable to detect table name changes, column name changes, or anonymously named constraints. A detailed summary of limitations can be found in the Alembic autogenerate documentation.","Q_Score":1,"Tags":"python,flask,flask-sqlalchemy,flask-migrate","A_Id":53746095,"CreationDate":"2018-12-12T07:12:00.000","Title":"migrations are getting created repeatedly","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on a django application which uses celery for the distributed async processes. Now I have been tasked with integrating a process which was originally written with concurrent.futures in the code. So my question is, can this job with the concurrent futures processing work inside the celery task queue. Would it cause any problems ? If so what would be the best way to go forward. The concurrent process which was written earlier is resource intensive as it is able to avoid the GIL. Also, its very fast due to it. Not only that the process uses concurrent.futures.ProcessPoolExecutor and inside it another few (<5) concurrent.futures.ThreadPoolExecutor jobs.\nSo now the real question is should we extract all the core functions of the process and re-write them by breaking them as celery app tasks or just keep the original code and run it as one big piece of code within the celery queue.\nAs per the design of the system, a user of the system can submit several such celery tasks which would contain the concurrent futures code.\nAny help will be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":611,"Q_Id":53738183,"Users Score":0,"Answer":"Your library should work without modification. There's no harm in having threaded code running within Celery, unless you are mixing in gevent with non-gevent compatible code for example.\nReasons to break the code up would be for resource management (reduce memory\/CPU overhead). With threading, the thing you want to monitor is CPU load. Once your concurrency causes enough load (e.g. threads doing CPU intensive work), the OS will start swapping between threads, and your processing gets slower, not faster.","Q_Score":1,"Tags":"python,django,celery,concurrent.futures","A_Id":53891099,"CreationDate":"2018-12-12T07:39:00.000","Title":"Running a python program which uses concurrent.futures within a celery based web app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I know how to add single packages and I know that the conda create command supports adding a new environment with all anaconda packages installed.\nBut how can I add all anaconda packages to an existing environment?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":711,"Q_Id":53742827,"Users Score":1,"Answer":"I was able to solve the problem as following:\n\nCreate a helper env with anaconda: conda create -n env_name anaconda\nActivate that env conda activate env_name\nExport packages into specification file: conda list --explicit > spec-file.txt\nActivate the target environment: activate target_env_name\nImport that specification file: conda install --file spec-file.txt","Q_Score":1,"Tags":"python,python-3.x,anaconda,conda","A_Id":53743588,"CreationDate":"2018-12-12T12:15:00.000","Title":"Add full anaconda package list to existing conda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Trying Python + Python Appium Library + WinAppDriver to perform a simple automation task:\n\nLaunch Notepad\nEnter some text.\nClose Notepad without saving\n\nWhen I close notepad using self.driver.close_app() call, it doesn't close it, since there is unsaved text in the notepad window. How can I perform this task without it prompting me to close the Window OR do I need to automate clicking on Don't Save button which will close the app?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":923,"Q_Id":53743877,"Users Score":0,"Answer":"You can try self.driver.quit()\nOR\nAutomate the Don't save button.","Q_Score":0,"Tags":"python,appium,winappdriver","A_Id":53845232,"CreationDate":"2018-12-12T13:14:00.000","Title":"Python + Appium + Winappdriver + Notepad: self.driver.close_app() doesnt close NotePad","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've produced a few Bokeh output files as the result of a fairly time intensive process. It would be really cool to pull the plots together from their respective files and build a new output file where i could visualize them all in a column. I know I should have thought to do this earlier on before producing all the individual plots, but, alas, i did not. \nIs there a way to import the preexisting figures so that I can aggregate them together into new multi-multi plot output file?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":90,"Q_Id":53746686,"Users Score":1,"Answer":"As of Bokeh 1.0.2, there is not any existing API for this, and I don't think there is any simple technique that could accomplish this either. I think the only options are: some kind of (probably somewhat fragile) text scraping of the HTML files, or distributing all the HTML files and using something like <iframe> to collect the individual subplot files into one larger view. \nGoing forward, for reference there is autoload_static that allows plots to be encapsulated in \"sidecar\" JS files that can be individually distributed and embedded, or there is json_item that produces and isolated JSON representation of the document that can also be individually distributed and embedded.","Q_Score":1,"Tags":"python-3.x,plot,import,bokeh","A_Id":53747543,"CreationDate":"2018-12-12T15:51:00.000","Title":"Is it possible to import bokeh figures from the html file they have been saved in?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have made a comparison between time of execution only for watershed functions in OpenCV, Skimage(SciPy) and BoofCV. Although OpenCV appears to be much faster than the other two (average time: 0.0031 seconds on 10 samples), Skimage time of execution varies significantly (from 0.03 to 0.554 seconds). I am wondering why this happens? Isn\u00b4t it supposed to be a native python function?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":276,"Q_Id":53746868,"Users Score":3,"Answer":"It's hard to know without more details why your particular application runs slowly. In general, though, the scikit-image code is not as optimized as OpenCV, but covers many more use cases. For example, it can work with floating point values as input, rather than just uint8, and it can work with 3D or even higher-dimension images.\nAbout the performance: OpenCV is coded in highly optimized C\/C++, while scikit-image is coded in Cython, a hybrid language that compiles Python code to C, achieving C-performance. However, several optimizations are not available in Cython, and as I mentioned above, there are differences in what is actually implemented, resulting in a performance difference.","Q_Score":2,"Tags":"python,time,native,scikit-image,watershed","A_Id":53771189,"CreationDate":"2018-12-12T16:00:00.000","Title":"Why is watershed function from SciKit too slow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm extracting C struct layout from and executable using gdb-python.\nI manage to get all the fields, offsets, types & sizes.\nStill, when trying to re-generate the struct's code, I do not have any indication for whether it was marked with GCC's attribute((__packed__)).\nIs there any way to get this information from the executable? (preferably using gdb-python, but any other way will do too)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":100,"Q_Id":53748049,"Users Score":1,"Answer":"Is there any way to get this information from the executable?\n\nNo, but you should be able to deduce this with a simple heuristic:\n\nif sizeof(struct foo) is greater than the sum of its member field sizes, the struct is not packed.\nif sizeof(struct foo) is equal to the sum of its member field sizes, the struct is either packed, or its members are naturally aligned with no holes, and packing doesn't matter for it.","Q_Score":0,"Tags":"gcc,gdb,gdb-python,pahole","A_Id":53748768,"CreationDate":"2018-12-12T17:08:00.000","Title":"Determining whether a C struct is packed or not","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have two different text which I want to compare using tfidf vectorization.\nWhat I am doing is:\n\ntokenizing each document\nvectorizing using TFIDFVectorizer.fit_transform(tokens_list)\n\nNow the vectors that I get after step 2 are of different shape.\nBut as per the concept, we should have the same shape for both the vectors. Only then the vectors can be compared.\nWhat am I doing wrong? Please help.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2848,"Q_Id":53748236,"Users Score":3,"Answer":"As G. Anderson already pointed out, and to help the future guys on this, when we use the fit function of TFIDFVectorizer on document D1, it means that for the D1, the bag of words are constructed.\nThe transform() function computes the tfidf frequency of each word in the bag of word. \nNow our aim is to compare the document D2 with D1. It means we want to see how many words of D1 match up with D2. Thats why we perform fit_transform() on D1 and then only the transform() function on D2 would apply the bag of words of D1 and count the inverse frequency of tokens in D2. \nThis would give the relative comparison of D1 against D2.","Q_Score":4,"Tags":"python,nltk,cosine-similarity,tfidfvectorizer","A_Id":59012601,"CreationDate":"2018-12-12T17:20:00.000","Title":"how to compare two text document with tfidf vectorizer?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hey guys so I've been studying for an upcoming test and I came across this question:\n\nIf you had an unsorted list of one million unique items, and knew that you would only search it once for a value, which of the following algorithms would be the fastest?\n\nUse linear search on the unsorted list\nUse insertion sort to sort the list and then binary search on the sorted list\n\n\nWouldn't the second choice be the fastest? Sorting the list and then looking for the value than only using linear search?","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":1753,"Q_Id":53748254,"Users Score":1,"Answer":"Alternative 1 of course, since that only requires you to go through the list once. If you are to sort the list, you have to traverse the list at least once for the sorting, and then some for the search.","Q_Score":2,"Tags":"python,algorithm,time-complexity","A_Id":53748320,"CreationDate":"2018-12-12T17:21:00.000","Title":"Unsorted Lists vs Linear and Binary Search","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hey guys so I've been studying for an upcoming test and I came across this question:\n\nIf you had an unsorted list of one million unique items, and knew that you would only search it once for a value, which of the following algorithms would be the fastest?\n\nUse linear search on the unsorted list\nUse insertion sort to sort the list and then binary search on the sorted list\n\n\nWouldn't the second choice be the fastest? Sorting the list and then looking for the value than only using linear search?","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":1753,"Q_Id":53748254,"Users Score":2,"Answer":"sorting a list has a O(log(N)*N) complexity at best.\nLinear search has O(N) complexity.\nSo if you have to search more than once, you begin to gain time after some searches.\nIf objects are hashable (ex: integers) a nice alternative (when searching more than once only) to sorting+bisection search is to put them in a set. Then complexity is down to O(1) because of hashing, but still O(N) to create it, and the hashing adds to the toll.\nIf you need only to search once, linear search is the best choice.","Q_Score":2,"Tags":"python,algorithm,time-complexity","A_Id":53748319,"CreationDate":"2018-12-12T17:21:00.000","Title":"Unsorted Lists vs Linear and Binary Search","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hey guys so I've been studying for an upcoming test and I came across this question:\n\nIf you had an unsorted list of one million unique items, and knew that you would only search it once for a value, which of the following algorithms would be the fastest?\n\nUse linear search on the unsorted list\nUse insertion sort to sort the list and then binary search on the sorted list\n\n\nWouldn't the second choice be the fastest? Sorting the list and then looking for the value than only using linear search?","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":1753,"Q_Id":53748254,"Users Score":3,"Answer":"Linear search takes just O(n), while sorting a list first takes O(n log n). Since you are going to search the list only once for a value, the fact that subsequent searches in the sorted list with a binary search takes only O(log n) does not help overcome the overhead of the O(n log n) time complexity involved in the sorting, and hence a linear search would be more efficient for the task.","Q_Score":2,"Tags":"python,algorithm,time-complexity","A_Id":53748316,"CreationDate":"2018-12-12T17:21:00.000","Title":"Unsorted Lists vs Linear and Binary Search","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hey guys so I've been studying for an upcoming test and I came across this question:\n\nIf you had an unsorted list of one million unique items, and knew that you would only search it once for a value, which of the following algorithms would be the fastest?\n\nUse linear search on the unsorted list\nUse insertion sort to sort the list and then binary search on the sorted list\n\n\nWouldn't the second choice be the fastest? Sorting the list and then looking for the value than only using linear search?","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":1753,"Q_Id":53748254,"Users Score":1,"Answer":"For solving these types of questions, it is simply necessary to see where you'd spend more time. For a million elements:\n\nInsertion sort with 'n' inversions would take O(n) and then it would take an additional O(log(n)) time.\nWhereas linear search would take only O(n) time.\n\nSince there is only a single query method 1 would be a better alternative but for multiple queries(search element in the list) there will be a point where bin-srch*x<lin-srch*x where x is the  number of queries.","Q_Score":2,"Tags":"python,algorithm,time-complexity","A_Id":53748430,"CreationDate":"2018-12-12T17:21:00.000","Title":"Unsorted Lists vs Linear and Binary Search","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to uninstall numpy & then install a specific version of it on anaconda. However, the prompt also told that others packages will also uninstall itself. How do I uninstall only numpy packages? I'm using ubuntu 18.04.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":11246,"Q_Id":53754479,"Users Score":1,"Answer":"If you anaconda contain pip tool, you can uninstall numpy only through pip uninstall numpy","Q_Score":0,"Tags":"python,numpy,ubuntu,anaconda","A_Id":53754534,"CreationDate":"2018-12-13T03:05:00.000","Title":"How to uninstall a single packages in anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a telegram chatbot with python. I need to add a lot of options (around 185) in the keyboard for the users to select. For e.g. they press a button topic which leads to a \"message please select your topic\" then a new replyMarkupKeyboard with these 185 buttons.\nHaving trouble making a keyboard with so many buttons, I tried enabling the keyboard_resize=True but to no avail. After a certain number of buttons the keyboard becomes cluttered and the topics become squished. For e.g. when topics are few: Politics, Sports etc. when topics are more Pl, Sp, etc. The words on these buttons get squished.\nI want a slider or dropdown in my keyboard to accommodate these 185 buttons.\nPlease help","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":845,"Q_Id":53754564,"Users Score":0,"Answer":"Thanks @Ivan Vinogradov , I worked around that problem using an If condition on topics and by creating categories.Like if category=1 then show these 10 topics ...so on and so forth I was able to manage this part.","Q_Score":1,"Tags":"telegram-bot,python-telegram-bot","A_Id":53825696,"CreationDate":"2018-12-13T03:21:00.000","Title":"telegram Bot 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 built Machine Learning Models Random Forest and XGBOOST on Python or R\nHow can I implement that my model work in mobile phone IOS \/ Android? Not for training, just to predict the probability for users by properties and events.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":525,"Q_Id":53756524,"Users Score":1,"Answer":"I think I'm qualified to answer this because it was yesterday that I viewed Google's \"DevFestOnAir 2018\". There was an \"End to End Machine Learning\" talk where the speaker mentioned what TensorFlow(TF) has to support AI in mobile devices. \nNow, TF is available for JS , Java and many other languages, so this captures the entirety of the model that runs on your PC, uses other functionalities to make it run on lesser RAM and Processors. Do check this out. If I'm not wrong TF has a feature that would do the conversion for you.","Q_Score":1,"Tags":"android,python,ios,machine-learning","A_Id":53756944,"CreationDate":"2018-12-13T06:58:00.000","Title":"How to implement machine learning models on mobile phones?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I train a sequential model with keras using the method fit_generator, I see this output\n\nEpoch 1\/N_epochs\nn\/N [====================>..............] - ETA xxxx - loss: yyyy\n\nI noticed that the loss decreased gradually with the number of steps, as expected. My problem is that I also noticed that when one epoch finishes and another one starts, the value of the loss is quite different from the one that I see at the end of the previous epoch.\nWhy so? I thought that epoch and number of steps per epochs was arbitrary values and using, for instance, 10 epochs with 1000 steps should be the same of 1000 epochs with 10 steps. But what does exactly happen between one epoch and the next one in Keras 2.0?\nDisclaimer: I know the definition of epoch and how the number of steps should be decided using a batch generator, but I have too many data and I cannot apply this rule.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":740,"Q_Id":53758399,"Users Score":1,"Answer":"As far as I can tell the output of the keras function is a running average loss and the loss is quite a lot larger at the beginning of the epoch, than in the end. The loss is reset after each epoch and a new running average is formed. Therefore, the old running average is quite a bit higher (or at least different), than the beginning loss in the next epoch.","Q_Score":2,"Tags":"python,machine-learning,keras,deep-learning","A_Id":53759191,"CreationDate":"2018-12-13T09:12:00.000","Title":"Could you explain me the output of keras at each iteration?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I train a sequential model with keras using the method fit_generator, I see this output\n\nEpoch 1\/N_epochs\nn\/N [====================>..............] - ETA xxxx - loss: yyyy\n\nI noticed that the loss decreased gradually with the number of steps, as expected. My problem is that I also noticed that when one epoch finishes and another one starts, the value of the loss is quite different from the one that I see at the end of the previous epoch.\nWhy so? I thought that epoch and number of steps per epochs was arbitrary values and using, for instance, 10 epochs with 1000 steps should be the same of 1000 epochs with 10 steps. But what does exactly happen between one epoch and the next one in Keras 2.0?\nDisclaimer: I know the definition of epoch and how the number of steps should be decided using a batch generator, but I have too many data and I cannot apply this rule.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":740,"Q_Id":53758399,"Users Score":4,"Answer":"The loss that Keras calculates during the epoch is accumulated and estimated online. So it includes the loss from the model after different weight updates.\nLet we clarify with an easy case: assume for a second that the model is only improving (every weight update results in better accuracy and loss), and that each epoch contains 2 weight updates (each min-batch is half the training dataset).\nAt epoch X, the first mini-batch is processed and the result is a loss score 2.0.\nAfter updating the weights, the model runs its second mini-batch which results in a loss score of 1.0 (for just the mini-batch). however you will see a loss of 2.0 change to 1.5 (average over all the dataset).\nNow we start epoch X+1, but it happens after another weight update which leads to a loss of 0.8 over the first mini-batch, which is shown to you. And so on and on...\nThe same thing happens during your training, only that obviously, not all changes are positive.","Q_Score":2,"Tags":"python,machine-learning,keras,deep-learning","A_Id":53759336,"CreationDate":"2018-12-13T09:12:00.000","Title":"Could you explain me the output of keras at each iteration?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So basically I have a dictionary with x and y values and I want to be able to get only the x value of the first coordinate and only the y value of the first coordinate and then the same with the second coordinate and so on, so that I can use it in an if-statement.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":69,"Q_Id":53763243,"Users Score":1,"Answer":"if the values are ordered in columns just use \n\nx=your_variable[:,0] y=your_variable[:,1]\n\ni think","Q_Score":0,"Tags":"python","A_Id":53763397,"CreationDate":"2018-12-13T13:43:00.000","Title":"python, dictionaries how to get the first value of the first key","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to capture a phrase that starts with a Capital letter between 2 known phrase. Let's say between \"Known phrase, \" and the word \"The\".\nFor example in the text below, the phrase I'm trying to capture is: Stuff TO CApture That always start with Capital letter but stop capturing when\n\nIgnore Words Known phrase, ignore random phrase Stuff TO CApture That always start with Capital letter but stop capturing when The appears.\n\nRegex I have tried: (?<=Known phrase, ).*(?= The) and Known phrase, (.*) The\nThese regex also captures ignore random phrase. How do I ignore this?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":54,"Q_Id":53766816,"Users Score":1,"Answer":"I'm not sure of what you are trying to do, but, trying to stick with your code, (?<=Known phrase, )([^A-Z]*)(.*)(?=The) should do the trick: the text you need is in the group 2. \nIf you need to match everything just change to (.*)(?<=Known phrase, )([^A-Z]*)(.*)(?=The)(.*) and get your text in group 3.","Q_Score":1,"Tags":"python,regex","A_Id":53767248,"CreationDate":"2018-12-13T17:05:00.000","Title":"Regex condition after and before a known phrase","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some python scripts that require a good machine. Instead of starting instances manually on GCP or AWS, then making sure all python libraries are installed, can I do it through python for example so that the instance is on only for the time needed to run the script?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":255,"Q_Id":53767911,"Users Score":1,"Answer":"If you're in AWS you could just create Lambda functions for your scripts and set those on a timer via Lambda or use Cloudwatch to trigger them.","Q_Score":0,"Tags":"python,amazon-web-services,google-cloud-platform,cloud","A_Id":53767992,"CreationDate":"2018-12-13T18:16:00.000","Title":"How can I run a python script on Google Cloud project or AWS instances without manually firing them 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":"In Atom, I'm looking for a way to auto-format long python lines like this:\nbefore:\n\nbar = call_very_long_func_lots_of_params(param1, param2, param3, param4, param5, param6, param7)\n\nafter:\n\nbar = call_very_long_func_lots_of_params(\n    param1, \n    param2, \n    param3, \n    param4, \n    param5, \n    param6, \n    param7, \n)\n\nAre there any packages that help with this? Or any tricks? I find myself tediously taking a while to doing this kind of style formatting and would like to try and be more efficient.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19,"Q_Id":53768547,"Users Score":0,"Answer":"Use the atom default multi select:\nhighlight the first comma within the parenthesis, and then do ctrl(cmd for mac) + d multiple times until you've highlighted all of ,.\nNow press right arrow (->) key, you should see cursors after each ,.\npress enter, which will shift each param to a newline except the first argument, which you can manually shift to newline.","Q_Score":2,"Tags":"python,package,coding-style,styles,atom-editor","A_Id":53768812,"CreationDate":"2018-12-13T19:05:00.000","Title":"In Atom, is there a package to autoformat long method calls into multi-lines?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm attempting to create an in-memory sqlite3 cache to store oauth tokens, but am running into issues regarding multithreading. After running several tests, I've noticed the behavior differs substantially from non-in-memory databases and multithreading. \nNotably, reader threads immediately fail with \"table is locked\" if a writer thread has written without committing. This is true with multiple threads even with isolation_level=None.\nIt's not simply that readers are blocked until the transaction is complete, but rather they fail immediately, regardless of timeout or PRAGMA busy_timeout = 10000.\nThe only way I can get it working is to set isolation_level=None and to do PRAGMA read_uncommitted=TRUE. I would rather not do this, however.\nIs it possible to let the reader threads simply wait the lock instead of immediately failing?\n\n\nimport sqlite3\nimport threading\n\ndef get_conn(name, is_memory=False, timeout=5, isolation_level='IMMEDIATE', pragmas=None):\n    uri = 'file:%s' % name\n    if is_memory:\n        uri = uri + '?mode=memory&cache=shared'\n    conn = sqlite3.connect(uri, uri=True, timeout=timeout, isolation_level=isolation_level)\n    if pragmas is None:\n        pragmas = []\n    if not isinstance(pragmas, list):\n        pragmas = [pragmas]\n    for pragma in pragmas:\n        conn.execute(pragma)\n    return conn\n\n\ndef work1(name, is_memory=False, timeout=5, isolation_level='IMMEDIATE', pragmas=None, loops=1):\n    conn = get_conn(name, is_memory=is_memory, timeout=timeout, isolation_level=isolation_level, pragmas=pragmas)\n    for i in range(loops):\n        conn.execute('INSERT INTO foo VALUES (1)')\n\n\ndef work2(name, is_memory=False, timeout=5, isolation_level='IMMEDIATE', pragmas=None, loops=1):\n    conn = get_conn(name, is_memory=is_memory, timeout=timeout, isolation_level=isolation_level, pragmas=pragmas)\n    for i in range(loops):\n       len(conn.execute('SELECT * FROM foo').fetchall())\n\n\ndef main(name, is_memory=False, timeout=5, isolation_level='IMMEDIATE', pragmas=None, loops=1, num_threads=16):\n    conn = get_conn(name, is_memory=is_memory, timeout=timeout, isolation_level=isolation_level, pragmas=pragmas)\n    try:\n        conn.execute('CREATE TABLE foo(a int)')\n    except sqlite3.OperationalError:\n        conn.execute('DROP TABLE foo')\n        conn.execute('CREATE TABLE foo(a int)')\n    threads = []\n    for i in range(num_threads):\n        threads.append(threading.Thread(target=work1, args=(name, is_memory, timeout, isolation_level, pragmas, loops)))\n        threads.append(threading.Thread(target=work2, args=(name, is_memory, timeout, isolation_level, pragmas, loops)))\n    for thread in threads:\n        thread.start()\n    for thread in threads:\n        thread.join()\n\n# In-Memory Tests\n# All of these fail immediately with table is locked. There is no delay; timeout\/busy_timeout has no effect.\nmain('a', is_memory=True, timeout=5, isolation_level='IMMEDIATE', pragmas=None)\nmain('b', is_memory=True, timeout=5, isolation_level='DEFERRED', pragmas=None)\nmain('c', is_memory=True, timeout=5, isolation_level='EXCLUSIVE', pragmas=None)\nmain('d', is_memory=True, timeout=5, isolation_level=None, pragmas=None)\nmain('e', is_memory=True, timeout=5, isolation_level='IMMEDIATE', pragmas=['PRAGMA busy_timeout = 10000'])\nmain('f', is_memory=True, timeout=5, isolation_level='DEFERRED', pragmas=['PRAGMA busy_timeout = 10000'])\nmain('g', is_memory=True, timeout=5, isolation_level='EXCLUSIVE', pragmas=['PRAGMA busy_timeout = 10000'])\nmain('h', is_memory=True, timeout=5, isolation_level=None, pragmas=['PRAGMA busy_timeout = 10000'])\nmain('i', is_memory=True, timeout=5, isolation_level='IMMEDIATE', pragmas=['PRAGMA read_uncommitted=TRUE'])\nmain('j', is_memory=True, timeout=5, isolation_level='DEFERRED', pragmas=['PRAGMA read_uncommitted=TRUE'])\nmain('k', is_memory=True, timeout=5, isolation_level='EXCLUSIVE', pragmas=['PRAGMA read_uncommitted=TRUE'])\n# This is the only successful operation, when isolation_level = None and PRAGMA read_uncommitted=TRUE\nmain('l', is_memory=True, timeout=5, isolation_level=None, pragmas=['PRAGMA read_uncommitted=TRUE'])\n# These start to take a really long time\nmain('m', is_memory=True, timeout=5, isolation_level=None, pragmas=['PRAGMA read_uncommitted=TRUE'], loops=100)\nmain('n', is_memory=True, timeout=5, isolation_level=None, pragmas=['PRAGMA read_uncommitted=TRUE'], loops=100, num_threads=128)\n\n# None of the on disk DB's ever fail:\nmain('o', is_memory=False, timeout=5, isolation_level='IMMEDIATE', pragmas=None)\nmain('p', is_memory=False, timeout=5, isolation_level='DEFERRED', pragmas=None)\nmain('q', is_memory=False, timeout=5, isolation_level='EXCLUSIVE', pragmas=None)\nmain('r', is_memory=False, timeout=5, isolation_level=None, pragmas=None)\nmain('s', is_memory=False, timeout=5, isolation_level='IMMEDIATE', pragmas=['PRAGMA busy_timeout = 10000'])\nmain('t', is_memory=False, timeout=5, isolation_level='DEFERRED', pragmas=['PRAGMA busy_timeout = 10000'])\nmain('u', is_memory=False, timeout=5, isolation_level='EXCLUSIVE', pragmas=['PRAGMA busy_timeout = 10000'])\nmain('v', is_memory=False, timeout=5, isolation_level=None, pragmas=['PRAGMA busy_timeout = 10000'])\nmain('w', is_memory=False, timeout=5, isolation_level='IMMEDIATE', pragmas=['PRAGMA read_uncommitted=TRUE'])\nmain('x', is_memory=False, timeout=5, isolation_level='DEFERRED', pragmas=['PRAGMA read_uncommitted=TRUE'])\nmain('y', is_memory=False, timeout=5, isolation_level='EXCLUSIVE', pragmas=['PRAGMA read_uncommitted=TRUE'])\nmain('z', is_memory=False, timeout=5, isolation_level=None, pragmas=['PRAGMA read_uncommitted=TRUE'])\n# These actually fail with database is locked\nmain('aa', is_memory=False, timeout=5, isolation_level=None, pragmas=['PRAGMA read_uncommitted=TRUE'], loops=100)\nmain('ab', is_memory=False, timeout=5, isolation_level=None, pragmas=['PRAGMA read_uncommitted=TRUE'], loops=100, num_threads=128)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":53769548,"Users Score":0,"Answer":"I do not believe that the SQLite3 interface is meant to be re-entrant. I think that each thread would have to obtain a mutex, perform the query, and then release the mutex. Attempt to perform only one database operation at a time. (Python's API-layer would not be expected to do this, as there would ordinarily be no need for any such thing.)","Q_Score":1,"Tags":"python,python-3.x,multithreading,sqlite","A_Id":53782653,"CreationDate":"2018-12-13T20:24:00.000","Title":"Sqlite3 In Memory Multithreaded Issues - Blocked threads immediately fail","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've found that a lot of python libraries that install have xxx.exe files, such as scrapy.exe, pip.exe, virtualenv.exe, etc. in the Scripts directory. How do they do that?I can't find relevant information, please guide me, thank you very much. By the way, python is installed in the Windows system.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":336,"Q_Id":53773213,"Users Score":0,"Answer":"i get my answer, it set entry_points ={'console_scripts':['xx'='yy']} in setup.py, when install or package, it can auto build .exe in Scripts directory.","Q_Score":1,"Tags":"python","A_Id":53773764,"CreationDate":"2018-12-14T03:43:00.000","Title":"python how to build an exe file like scrapy.exe, pip.exe, virtualenv.exe in windows system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used sklearn.preprocessing.KBinsDiscretizer(n_bins=10, encode='ordinal') to discretize my continuous feature. \nThe strategy is 'quantile', by defalut. But my data distribution is actually not uniformly, like 70% of rows is 0. \nThen I got KBinsDiscretizer.bins_edges=[0.,0.,0.,0.,0.,0.,0.,256.,602., 1306., 18464.]. \nThere're many duplicate bins. So, is there a method to drop the duplicates in KBinsDiscretizer's bins? \nKBinsDiscretizer calculates the quantile of input. If the most samples of input are zero, the 10-quantiles will have multiple zeros. The result I expected is a discretizer with unique bins. For the example I mentioned, is [0.,256.,602., 1306., 18464.].","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":858,"Q_Id":53773352,"Users Score":1,"Answer":"That will not be possible. Set strategy='uniform' to achieve your goal.","Q_Score":1,"Tags":"python-2.7,scikit-learn","A_Id":53821015,"CreationDate":"2018-12-14T03:59:00.000","Title":"Can sklearn.preprocessing.KBinsDiscretizer with strategy='quantile' drop the duplicated bins?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have used the place_forget command in order to hide a button when switching frames, how can I bring the button back at a later stage in the program? Or would I have to recreate it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1064,"Q_Id":53776905,"Users Score":3,"Answer":"You will need to call place again. You do not have to recreate the widget as long as you keep a reference to the original widget.","Q_Score":0,"Tags":"python,button,tkinter","A_Id":53788316,"CreationDate":"2018-12-14T09:33:00.000","Title":"Tkinter - place_forget command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does Python have the equivalent of the Java volatile concept?\nIn Java there is a keyword volatile. As far as I know, when we use volatile while declaring a variable, any change to the value of that variable will be visible to all threads running at the same time.\nI wanted to know if there is something similar in Python, so that when the value of a variable is changed in a function, its value will be visible to all threads running at the same time.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10254,"Q_Id":53780267,"Users Score":40,"Answer":"As far as I know, when we use volatile while declaring a variable, any change to the value of that variable will be visible to all threads running at the same time.\n\nvolatile is a little more nuanced than that. volatile ensures that Java stores and updates the variable value in main memory. Without volatile, the JVM is free to store the value in the CPU cache instead, which has the side effect of updates to the value being invisible to different threads running on different CPU cores (threads that are being run concurrently on the same core would see the value).\nPython doesn't ever do this. Python stores all objects on a heap, in main memory. Moreover, due to how the Python interpreter loop uses locking (the GIL), only one thread at a time will be actively running Python code. There is never a chance that different threads are running a Python interpreter loop on a different CPU.\nSo you don't need to use volatile in Python, there is no such concept and you don't need to worry about it.","Q_Score":22,"Tags":"java,python,volatile","A_Id":53780395,"CreationDate":"2018-12-14T12:57:00.000","Title":"An equivalent to Java volatile in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Folks,\nI plan to use Python and various python packages like robot framework, appium, selenium etc for test automation. But as we all know, python and all the package versions keep revving. \nIf we pick a version of all of these to start with, and as these packages up rev, what is the recommended process for keeping the development environment up to date with the latest versions?\nAppreciate some guidance on this.\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":349,"Q_Id":53781907,"Users Score":5,"Answer":"If you wrote the code with a given version of a library, updating that library in the future is more likely to break your code than make it run better unless you intend to make use of the new features.  Most of the time, you are better off sticking with the version you used when you wrote the code unless you want to change the code to use a new toy.  \nIn order to ensure that the proper versions of every library are installed when the program is loaded on a new machine, you need a requirements.txt document.  Making one of these is easy.  All you do is build your program inside a virtual environment (e.g. conda create -n newenv conda activate newenv)  Only install libraries you need for your program and then, once all of your dependencies are installed, in your terminal, type pip freeze > requirements.txt.  This will put all your dependencies and their version information in the text document.  When you want to use the program on a new machine, simply incorporate pip install -r requirements.txt into the loading process for the program.  \nIf you containerize it using something like docker, your requirements.txt dependencies can be installed automatically whenever the container is created.  If you want to use a new library or library version, simply update it in your requirements.txt and boom, you are up to date.","Q_Score":4,"Tags":"python,pip,pypi","A_Id":53782145,"CreationDate":"2018-12-14T14:46:00.000","Title":"Managing Python and Python package versions for Test Automation","Data Science and Machine Learning":0,"Database and SQL":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":"Today i tried to create a docker of the final version of my project(my project has a size of 3.2 Go) with the command \"docker build --tag my-python-app\". I had several problems during the manipulation : i ran the command docker. it several times because in the file \"Dockerfile\", i specified the wrong python and wrong pip. Anyway, now i have \"no space left on device\" and my screen is blinking.\nFor the moment, I tried an autoremove, but still not enough space. \nSomeone has an idea of what is happening?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":53783373,"Users Score":0,"Answer":"I found the problem:\nWhen you build your docker, and this print an error, it doesn't delete intermediate containers created in the folder \/var\/lib\/docker\/aufs\/diff (my error was in the dockerfile, where i precised the wrong python and the wrong pip), and this folder is saved in the peripherical part of the memory. So if you take all the memory, your computer is full of bug (screen, keyword, ...) and you can only use your terminal.\nTo resolver the problem you have to delete these folders","Q_Score":2,"Tags":"python,docker,ubuntu","A_Id":53870146,"CreationDate":"2018-12-14T16:17:00.000","Title":"cannot restart correctly ubuntu after use docker python \"no space left on device\" , no memory available on peripheric","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Today i tried to create a docker of the final version of my project(my project has a size of 3.2 Go) with the command \"docker build --tag my-python-app\". I had several problems during the manipulation : i ran the command docker. it several times because in the file \"Dockerfile\", i specified the wrong python and wrong pip. Anyway, now i have \"no space left on device\" and my screen is blinking.\nFor the moment, I tried an autoremove, but still not enough space. \nSomeone has an idea of what is happening?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":53783373,"Users Score":0,"Answer":"Run docker image ls to see if you have any images that you can delete to free up space.\nIf you find images that you do not need, you can remove them individually or all at once.  Run docker image prune -h to display the options for removing images.","Q_Score":2,"Tags":"python,docker,ubuntu","A_Id":53783461,"CreationDate":"2018-12-14T16:17:00.000","Title":"cannot restart correctly ubuntu after use docker python \"no space left on device\" , no memory available on peripheric","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Today i tried to create a docker of the final version of my project(my project has a size of 3.2 Go) with the command \"docker build --tag my-python-app\". I had several problems during the manipulation : i ran the command docker. it several times because in the file \"Dockerfile\", i specified the wrong python and wrong pip. Anyway, now i have \"no space left on device\" and my screen is blinking.\nFor the moment, I tried an autoremove, but still not enough space. \nSomeone has an idea of what is happening?","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":47,"Q_Id":53783373,"Users Score":3,"Answer":"Have you tried to remove unused Docker images or containers?\nYou can see the list of images by running:\ndocker images\nAnd you can remove them like:\ndocker rmi <id>\nThe process is fairly similar for the containers:\ndocker ps -a\nAnd:\ndocker rm <id>\nBe careful not to remove used containers or images.","Q_Score":2,"Tags":"python,docker,ubuntu","A_Id":53783442,"CreationDate":"2018-12-14T16:17:00.000","Title":"cannot restart correctly ubuntu after use docker python \"no space left on device\" , no memory available on peripheric","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm implementing a tool (java program) that embeds some command interpreters, as \"bc\", \"sage\", ... . The tool executes the interpreter in a thread, redirects its stdin and stdout, and writes some commands to the redirected stdin of the embedded interpreter (along time). Everything ok with \"bc\" and \"sage\" after solving usual problems with buffering.\nIn case of python, it seems that the interpreter is not reading its commands from stdin (I've verified that with a simple echo 1+2 | python ).\nI do not find how to instruct the python interpreter to read its commands from stdin. I've read lots of similar questions, but all them tries to read data from stdin, not commands.\nNote the command send to the python interpreter can be multi-line (a python \"for\" loop, ...) and commands are not yet available when python starts, they are generated and send to the interpreter along time.\nIn short, I want use python as a repl (read-eval-print-loop), reading from stdin.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":354,"Q_Id":53784540,"Users Score":2,"Answer":"The python REPL mode is intended to be interactive and only works when it detects a terminal. You can pass commands into stdin, but they don't automatically print, you have to specify that.\nTry running\n\necho print 1+2 | python\n\nThat should get your expected result. You can also write your code to a file like this \n\necho print 1+2 > myfile \n  python myfile.py\n\nIt is also possible to use a buffer like a fifo node  to pass data to python's stdin, but python exits after every line, and you get no advantage over simply running \"echo print 1+2 | python\". \n\nmkfifo a=rw MYFIFO \n  echo \"print 1+2\" > MYFIFO & \n  cat MYFIFO | python\".\n\nUsing python the expected way, by executing each set of code as you need it, should work better than keeping a repl open, and will produce more consistent results.","Q_Score":0,"Tags":"python,read-eval-print-loop","A_Id":53785139,"CreationDate":"2018-12-14T17:43:00.000","Title":"use python as a repl (read-eval-print-loop), reading commands from stdin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have write a simple python 3.7 window service and installed successfully.Now I am facing this error\n\"Error starting service: The service did not respond to the start or control request in a timely fashion.\"\nPlease Help me to fix this error.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":808,"Q_Id":53785231,"Users Score":0,"Answer":"One of the most common errors from windows when starting your service is Error 1053: The service did not respond to the start or control request in a timely fashion. This can occur for multiple reasons but there are a couple things to check when you do get them:\nMake sure your service is actually stopping:Note the main method has an infinite loop. The template above with break the loop if the stop even occurs, but that will only happen if you call win32event.WaitForSingleObject somewhere within that loop; setting rc to the updated value\nMake sure your service actually starts: Same as the first one, if your service starts and does not get stuck in the infinite loop, it will exit. Terminating the service\nCheck your system and user PATH contains the necessary routes: The DLL path is extremely important for your python service as its how the script interfaces with windows to operate as a service. Additionally if the service is unable to load python - you are also hooped. Check by typing echo %PATH% in both a regular console and a console running with Administrator priveleges to ensure all of your paths have been loaded\nGive the service another restart: Changes to your PATH variable may not kick in immediately - its a windows thing","Q_Score":1,"Tags":"python-3.x","A_Id":53794124,"CreationDate":"2018-12-14T18:40:00.000","Title":"Python 3.7 Window 10 Service Not Working: Error starting service: The service did not respond to the start or control request in a timely fashion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating a REST API in python and currently, there is a route to a list of the resource instructors:\nGET \/instructors\nBut, I also have another client, used as a CRM for users who have an admin-role.\nFor the client, I want to display a list of instructors but with more fields and different properties.\nMy first thought is also to have the route:\nGET \/instructors \nThis obviously conflicts with the route above. \nWhat is the best name for this route?\nGET \/instructors\/admin\nor\nGET \/admin\/instructors\nor \nGET \/instructors?admin=True\nI am not sure how to approach this.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":938,"Q_Id":53787342,"Users Score":0,"Answer":"I am glad that we are finally talking about the naming conventions this totally depends on personal preference and use cases and how your project has been designed so i will keep here my views ..\nLike you said all of the above seem to be good but how i would do is\n\nGET\/Instructors\/all \nGET\/Instructors\/admin \nGET\/Instructors\/any other special role\n\nyou may use queries when something specific has to be done with these roles again as in \nGET\/Instructors\/all?credibility=PHD \nsomething like the above its never a good idea to show every thing on just parent calls like GET\/Instructor as you said firstly it creates confusion and makes the readability of your endpoints difficult with time when the complexity of your application increases.","Q_Score":0,"Tags":"python,rest,api","A_Id":53787444,"CreationDate":"2018-12-14T21:50:00.000","Title":"Rest api naming conventions for consumer and admin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to install cryptography 2.2.1 or higher from a wheel. Pip is no longer able to connect to the pypi site due to an SSL error. The suggestion is to upgrade python. But the software I am supporting (ArcGIS 10.2.1) uses python 2.7.5. So, cannot change python versions. Therefore, I have been using downloaded wheel files for my installs. But I can not get cryptography to install.\nPip:\nCould not find a version that satisfies the requirement enum34; python_version < \"3\"\nIt looks like pip is looking for a version of python that is less than 3. Suggestions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":273,"Q_Id":53787775,"Users Score":0,"Answer":"check the wheel file you are using according to your system as both cryptography and enum64 supports 2.7 .","Q_Score":1,"Tags":"python","A_Id":53797327,"CreationDate":"2018-12-14T22:37:00.000","Title":"Installing cryptography 2.2.1 or higher from wheel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i installed Raspbian on my Raspberry Pi and it has Python 3 IDLE to write code. What confuses me is, that if i execute \"python\" in the command of my Raspberry Pi, it says the Python version is 2.7?\nCan someone help?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":676,"Q_Id":53788686,"Users Score":2,"Answer":"As long as it won't cause you any issues, you can try running python3. If you have Python 2 and 3 installed, from my experience python usually runs Python 2, so I guess you'll have to be specific.","Q_Score":0,"Tags":"python,raspberry-pi,python-idle","A_Id":53788695,"CreationDate":"2018-12-15T01:00:00.000","Title":"Python 3 IDLE (Shell) but only Python 2.7 installed 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":1,"Web Development":0},{"Question":"I have a project that requires us to track whether a reply has been sent for an email. We send mails using Gmail API and its getting send successfully without any issues. But if some user has setup an auto response service and that service has a different subject the gmail treats it as a seperate thread.\nIn my backend I get specific threads from users and iterate to check if there is any entry present in the messages having header 'To' as the mail creator. \nIt works as it should but Iam not able to track emails outside the thread. Is there any solution to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":373,"Q_Id":53791507,"Users Score":0,"Answer":"By thread I'm assuming you mean \"E-mail\" thread and not \"processing thread\".\nI'm also assuming that you might be looking for the \"References\" or \"In-reply-to\" headers to identify the email threads, but in my opinion, if that information is not added by the auto-responder, then you should be looking for other headers like the Reply-to which theoretically should identify with the original address that you sent an email to, that combined with looking for the newest thread associated with that email you could make a list of potential associated threads. If that information is not present, you could only do the time difference approach and for example if the sent email was at 10:40 and the auto-responder replies at 10:41 then that might be a match, but if you send 1000 emails to different addresses in a very short amount of time then your life is a lot more difficult and I'm not sure it's even possible in that case.","Q_Score":0,"Tags":"python-3.x,gmail-api","A_Id":53792087,"CreationDate":"2018-12-15T10:30:00.000","Title":"Tracking Email replies","Data Science and Machine Learning":0,"Database and SQL":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 using Windows 10\nI wish to use wxPython as a GUI for my Python3 programs. I am using SublimeText 3 to write and launch my scripts\nWhen I launch my script from within Sublime the program runs but the wxPython window does not open. It opens as expected if I run the program from the cmd prompt.\nMy internet searching leads me to believe that Sublime is suppressing the window from opening and that this behavior can be changed within Sublime's settings, but I can only find instructions for Sublime Text 2.\nHow can I prevent Sublime Text 3 from suppressing the wxPython window?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":257,"Q_Id":53791719,"Users Score":0,"Answer":"If you are using Windows, the correct extension would be *.pyw. Change the name of your WX Python script changing the extension \".py\" for \".pyw\" and try to run it from ST3.\nGood luck.","Q_Score":1,"Tags":"python,python-3.x,wxpython,sublimetext3","A_Id":58882531,"CreationDate":"2018-12-15T10:58:00.000","Title":"Using wxPython within Sublime Text 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used sudo apt-get install python3.6-tk and it works fine. Tkinter works if I open python in terminal, but I cannot get it installed on my Pycharm project. pip install command says it cannot find Tkinter. I cannot find python-tk in the list of possible installs either. \nIs there a way to get Tkinter just standard into every virtualenv when I make a new project in Pycharm?\nEdit: on Linux Mint\nEdit2: It is a clear problem of Pycharm not getting tkinter guys. If I run my local python file from terminal it works fine. Just that for some reason Pycharm cannot find anything tkinter related.","AnswerCount":6,"Available Count":1,"Score":-0.0333209931,"is_accepted":false,"ViewCount":58399,"Q_Id":53797598,"Users Score":-1,"Answer":"Python already has tkinter installed. It is a base module, like random or time, therefore you don't need to install it.","Q_Score":14,"Tags":"python,tkinter,pycharm","A_Id":53797731,"CreationDate":"2018-12-15T21:55:00.000","Title":"how to install tkinter with Pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As the title says, I have an app hosted on Heroku that seems to have more than one instance running.  This is a problem because I am trying to keep track of single letter posts on a GroupMe in order to see if they spell anything.  I am using python and a global string variable that I can add the characters to.  Since there is more than one instance, there is more than 1 global variable so sometimes the character gets added to one or the other which defeats the purpose of the program.  Has anyone else run into this problem or found a fix to this?  Thanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":106,"Q_Id":53799174,"Users Score":1,"Answer":"So after thinking about possible ways to fix it, I decided to try to keep my global variables inside a json file and then edit that each time.  This worked as I believe that even if there were 2 version of the actual code running, they should both edit the same json file.","Q_Score":2,"Tags":"python,heroku,groupme","A_Id":53806183,"CreationDate":"2018-12-16T03:22:00.000","Title":"My Heroku app seems to be running more than 1 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":0,"Web Development":1},{"Question":"I installed Python 3.7.1 using home-brew, and on the command line typing python returns the default python 2.7.10 and python3 gives the home-brew installed version. Then using \npython3 -m pip install --user numpy scipy matplotlib\nI installed the required packages. \nNow what I understand is that to use the home-brew version python I have to always use python3and the required packages are installed inside python 3's lib folder.\nI want to install virtual env correctly. I want to know what command should I use if I want it to be usable with python3?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":63,"Q_Id":53800290,"Users Score":1,"Answer":"From my understanding you want to create python3 environments. First install virtualenv using pip.\npip install virtualenv\nThen you can create a python3 environment like this:\nvirtualenv -p python3 env_name","Q_Score":0,"Tags":"python,python-3.x,macos,virtualenv","A_Id":53800350,"CreationDate":"2018-12-16T07:32:00.000","Title":"Installing virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to use pyqt classes in Cython(.pyx file)?\nIn fact, how can pyqt classes be inherited in cython classes?  \nthank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":365,"Q_Id":53805723,"Users Score":3,"Answer":"All Python code should be valid Cython code (there are bugs, so this isn't quite true, but it's close). Therefore Python code using PyQt should work as it is under Cython and if it doesn't then you should report it to the Cython bugtracker. However, in the past people have reported problems because PyQt uses multiple threads but Cython does not release the GIL regularly. Therefore you might find that your application hangs and it is not possible to combine PyQt and Cython.\n\nCython has no special access to PyQt classes therefore you should not cdef them - just treat them as normal Python variables.\nBecause of this lack of special access you cannot inherit from them in a cdef class. However they work fine when you inherit from in a normal class.\n\nIn general there is no benefit to trying to set cdef types for regular Python objects (including PyQt classes); just write the code as if it was Python.","Q_Score":1,"Tags":"python,pyqt,cython","A_Id":53806172,"CreationDate":"2018-12-16T19:28:00.000","Title":"use pyqt classes in Cython(.pyx file)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get tesserocr python library to run on 4 cores. According to tesseract docs, I understand it supports up to 4 cores. I have a tesserocr python3.x job running inside AWS Batch (docker container based on amazonlinux:latest image) on a c4.x2large instance which has 8 vCPUs, all were allocated to the batch job at submission time.\nThe benchmarks show CPU at 30% max, i.e. 2.5 vCPUs i.e. about 1.25 physical cores (each 2 vCPUs are roughy 1 physical core).\nI've also tried the OMP_NUM_THREADS=4, OMP_THREAD_LIMIT=4 environment variables (based on some forum online), but no value had any effect on performance whatsoever.\nHow do I can tesserocr to scale up to all 4 cores (8 vCPUs)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":406,"Q_Id":53806553,"Users Score":0,"Answer":"Python Threads are not 1:1 with vCPUs \/ Cores.\nIf you look at the specifications for a c4.x2large instance, it says you can run up to 2 threads per core. And that machine has 8 vCPUs.\nTo potentially use all 8 vCPUs you could try setting OMP_NUM_THREADS=16, OMP_THREAD_LIMIT=16. However how the underlying tesserocr is implemented will have a huge impact on how well it scales within the context of the machine.","Q_Score":0,"Tags":"docker,amazon-ecs,python-tesseract,aws-batch","A_Id":53859480,"CreationDate":"2018-12-16T21:17:00.000","Title":"Why python tesserocr not using 4 CPU cores on AWS Batch?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"In Jupyter Notebooks you can type, for example \\alpha and hit the tab key and the \\alpha changes into \u03b1. This is a pretty cool feature. Unfortunately, it doesn't work in the jupyter-lab editor. Any reason why that doesn't work? Or do I need to set a preference somewhere?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":3140,"Q_Id":53806647,"Users Score":2,"Answer":"if you type $\\alpha$ it will be rendered as the greek letter thanks to latex","Q_Score":5,"Tags":"ipython,jupyter-lab","A_Id":53806870,"CreationDate":"2018-12-16T21:30:00.000","Title":"Convert greek latex symbol in the jupyter-lab text editor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a system that has two type of user.\nNormal users and coaches.\nHow can I separate users when they login in system.\nI want to separate their dashboard after they logged in.\nShould I create two model? one model for users and one model for coaches?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":551,"Q_Id":53811891,"Users Score":0,"Answer":"You can either use Django's built-in Groups feature, create a Coach group and check in your views if a user is part of that group. Or you extend AbstractUser by adding a boolean field is_coach (and set AUTH_USER_MODEL settings to your new User model). \nThen you can check this flag in your views. \nThe more interesting question is if you want to store extra information (add extra functionality on the user level) for coach type users. If this is the case, you can make a so called Profile model Coach which you set in one-to-one relation with the User model (which should only serve authentication purposes). Then you can add extra fields in your profile model to store information relevant to coaches. The next question would be: what about students? Should students be able to enroll in courses?","Q_Score":0,"Tags":"python,django","A_Id":53814173,"CreationDate":"2018-12-17T09:05:00.000","Title":"How to separate users dashboard and model in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to use zeep library to provide soap call in python code and its okay it works when I try to run with python. Then, I'm trying to use jython to run this code (i need jython because next step will be on the server that uses jython to compile)  and when I try to install lxml for jython it gives me this error:\nerror:Compiling extensions is not supported on Jython\nWhen I search for this situation, I found that jython doesn't support c based libraries. \nSo, there is a solution with jython-jni bridge but I couldn't understand how to be.\nIs there another solution? Or can you give me an obvious example?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":323,"Q_Id":53815005,"Users Score":0,"Answer":"I couldn't achieve to implement jni but i created a new layer between jython and server.I mean, i made a REST call from jython compiler and this call listens my server for soap call and it worked.","Q_Score":0,"Tags":"java,python,lxml,jython","A_Id":53870455,"CreationDate":"2018-12-17T12:12:00.000","Title":"Jython can not use lxml library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just want to know the effect of the value of alpha in gensim word2vec and fasttext word-embedding models? I know that alpha is the initial learning rate and its default value is 0.075 form Radim blog.\nWhat if I change this to a bit higher value i.e. 0.5 or 0.75? What will be its effect? Does it is allowed to change the same? However, I have changed this to 0.5 and experiment on a large-sized data with D = 200, window = 15, min_count = 5, iter = 10, workers = 4 and results are pretty much meaningful for the word2vec model. However, using the fasttext model, the results are bit scattered, means less related and unpredictable high-low similarity scores.\nWhy this imprecise result for same data with two popular models with different precision? Does the value of alpha plays such a crucial role during building of the model?\nAny suggestion is appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2594,"Q_Id":53815402,"Users Score":5,"Answer":"The default starting alpha is 0.025 in gensim's Word2Vec implementation. \nIn the stochastic gradient descent algorithm for adjusting the model, the effective alpha affects how strong of a correction to the model is made after each training example is evaluated, and will decay linearly from its starting value (alpha) to a tiny final value (min_alpha) over the course of all training. \nMost users won't need to adjust these parameters, or might only adjust them a little, after they have a reliable repeatable way of assessing whether a change improves their model on their end tasks. (I've seen starting values of 0.05 or less commonly 0.1, but never as high as your reported 0.5.)","Q_Score":4,"Tags":"python-3.x,gensim,word2vec,word-embedding,fasttext","A_Id":53821335,"CreationDate":"2018-12-17T12:36:00.000","Title":"Value of alpha in gensim word-embedding (Word2Vec and FastText) models?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new at StackOverflow and I have researched everywhere for reasons why to pick Google BigQuery vs Jupyter Notebooks for creating new variables and preparing data for Machine Learning projects. Until now, I have lots of experience doing Data Science projects with Jupyter Notebooks (love python!) but now we are working with GCP at the office and no one has been able to answer why (or when) is better to choose one over the other one. \nDatalab does a great job with Jupyter Notebooks, and the data we have right now is stored part at GCS and part in Cloud SQL (I only retrieve data from there and start playing with variables). \nThanks a lot !","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":165,"Q_Id":53816842,"Users Score":2,"Answer":"BigQuery is a datalake, a large database. For your problems is a data source like Cloud SQL\/GCS. You need to store rows in BQ and use in your tools to write the charts\/algorithms. \nBigQuery cannot be compared to Jupyter Notebook, because is just two different products.","Q_Score":1,"Tags":"python,google-bigquery,jupyter-notebook","A_Id":53817851,"CreationDate":"2018-12-17T14:03:00.000","Title":"Difference between BigQuery and Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make a series of figures with 3x3 subplots using matplotlib. I can make the first figure fine (9 total subplots), but when I try to make a tenth subplot I get this error: ValueError: num must be 1 <= num <= 9, not 10. What I think I want to do is plot the first 9 subplots, clear the figure, and then plot the next 9 subplots. I haven't been able to get this approach to work so far though. If anyone could offer some suggestions I would really appreciate it! \nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":53817735,"Users Score":0,"Answer":"Call plt.show() before the 10th chart, then start over with plt.subplot(3, 3, 1), followed by the code to plot the 10th chart","Q_Score":0,"Tags":"python,matplotlib","A_Id":53818650,"CreationDate":"2018-12-17T14:56:00.000","Title":"Matplotlib erase figure and plot new series of subplots","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been using the kubectl to upload Airflow workflows to the kubernetes (\/usr\/local\/airflow\/dags) manually. It is possible to do this without using the kubectl? by using a python script? or something else? If it's possible would you be able to share your source? or your python script? Thanks, Appreciate","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":618,"Q_Id":53818844,"Users Score":1,"Answer":"This totally depends on your setup. E.G. We use AWS and so we have the DAGs syncing from an S3 bucket path every 5 minutes. We just put dags into S3. I see that some Kubernetes setups use a kind of shared volume defined by a git repository, that might also work. Airflow itself (the webserver(s), worker(s), nor scheduler) does not offer any hook to upload into the DAG directory.","Q_Score":0,"Tags":"python,kubernetes,workflow,airflow,kubectl","A_Id":53831610,"CreationDate":"2018-12-17T16:03:00.000","Title":"How to upload the Airflow dags(workflows) without going through kubectl?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am learning Python and downloaded it with Anaconda in Ubuntu (learning Linux too). When I create a conda environment, it generates a directory with the name of the env like this: \/home\/user\/anaconda3\/envs\/myenv1 \nWhen I activate the environment and launch my editor (VScode) I then select the interpreter from the active environment. When I save my .py file, do I have to save it inside the environment directory? That folder contains other folders and packages that are put there by conda. If I need a package from that environment and my project folder is not in the myenv1 directory, will it not work?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3687,"Q_Id":53820506,"Users Score":0,"Answer":"No, you don't have to save any file in the virtual environment folder. Once the environment is activated, it acts like an independent environment. But remember you will have to install all the packages again which are not available in Conda.","Q_Score":4,"Tags":"python,visual-studio-code,anaconda,conda","A_Id":53820622,"CreationDate":"2018-12-17T17:45:00.000","Title":"Do I have to place my Python project inside the conda environment directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a formula which I want (Result for False) == -1*(Result for True). What quick (read: one-line) way can I express False as -1 and True as 1? Of course, if\/else would work. I'm wondering about the most succinct way to express this.","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":77,"Q_Id":53821998,"Users Score":2,"Answer":"If the value is in my_value you can write 1 if my_value else -1.","Q_Score":2,"Tags":"python","A_Id":53822036,"CreationDate":"2018-12-17T19:43:00.000","Title":"What is the best way to evaluate False as -1 and True as 1?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Scans\/photocopies often miss the corner which comes out black. How can these black corners be made white using python with numpy, pillow or skimage?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":53822453,"Users Score":3,"Answer":"Create a mask with all black objects (mask = image < threshold)\nRemove objects touching the border (new_mask = segmentation.clear_border(mask))\nWhich objects were removed? objs = (new_mask != mask)\nFill those objects with white: image[objs] = 1 (or 255, if dtype int).\n\nIf you need to make sure that the objects replaced by white are triangles, you can use skimage.measure.regionprops to further examine each one.","Q_Score":1,"Tags":"python,image-processing,python-imaging-library,scikit-image","A_Id":53822702,"CreationDate":"2018-12-17T20:21:00.000","Title":"How can I crop black corners from a scanned image?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to export and ensure availability of variables from .env file on server start\/restart in Python?\nI have file .env with secured variables, such as passwords, credentials and confidential information. I want to make this variables available on the server start\/restart.\n\nHow to load variables from .env in Python?\nHow to load\/reload variables from .env in Python, when server is restarted, reloaded?\nHow to ensure that variables is always in operational memory?\nIs there any other better way to do solve the same technical issue?\n\nI am using Flask and run app on Apache2 using WSGI.\nMy file looks the following:\n\nENVIRONMENT_VARIABLE_EXAMPLE=SECRET_KEY","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27,"Q_Id":53823181,"Users Score":0,"Answer":"I had to put content of the file into envvars into Apache2 server. \nAfter I did this, I get everything working. I thought there is a Python way to export environment variables in Flask application while running on Apache2 but nothing worked for me.\nAnother solution I see but has never tried myself to add into Apache2 config SetEnv VAR_KEY VAR_VALUE alike statements.","Q_Score":0,"Tags":"python,python-3.x,flask,environment-variables,apache2","A_Id":54126626,"CreationDate":"2018-12-17T21:23:00.000","Title":"How to export and ensure availability of variables from .env file on server start\/restart in Python, Flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using python in linux and tried to use command line to print out the output log while redirecting the output and error to a txt.file. However, after I searched and tried the methods such as \npython [program] 2>&1 | tee output.log\nBut it just redirected the output the the output.log and the print content disappeared. I wonder how I could print the output to console while save\/redirect them to output.log ? It would be useful if we hope to tune the parameter while having notice on the output loss and parameter.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":53825380,"Users Score":0,"Answer":"You can create a screen like this: screen -L and then run the python script in this screen which would give the output to the console and also would save it the file: screenlog.0. You could leave the screen by using Ctrl+A+D while the script is running and check the script output by reattaching to the screen by screen -r. Also, in the screen, you won't be able to scroll past the current screen view.","Q_Score":0,"Tags":"python,linux","A_Id":53825451,"CreationDate":"2018-12-18T01:57:00.000","Title":"Print output to console while redirect the output to a file in linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I've gotten myself a little confused. \nAt the moment, I've got a dataset of about 800 instances. I've split it into a training and validation set because there were missing values so I used SimpleImputer from sklearn and fit_transform-ed the training set and transformed the testing set. I did that because if I want to predict for new instances, if there's missing values then I'll need to impute it the same way I imputed the test set. \nNow I want to use cross validation to train and score models, but that would involve using the whole dataset and splitting it up into different training and testing sets, so then I'm worried about leakage from the training set because of the imputed values being fitted?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":726,"Q_Id":53825586,"Users Score":1,"Answer":"Generally, you'll want to split your data into three sets- a training set, testing set, and validation set. The testing set should be completely left out of training (your concern is correct.) When using cross validation, you don't need to worry about splitting your training and validation set- that's what cross validation does for you! Simply pass the training set to the cross validator, allow it to split into training and validation behind the scenes, and test the final model on your testing set (which has been completely left out of the training process.)","Q_Score":4,"Tags":"python,cross-validation,imputation","A_Id":53825670,"CreationDate":"2018-12-18T02:24:00.000","Title":"How to use cross validation after imputing on a training and validation set?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on python-pptx module. I have a presentation file which contains embedded files like(.pptx, .xlsx, .docx, .pdf) on slides. I need to read those files also while parsing the presentation.\nIs there any python-pptx attribute to read those embedded files.\nI tried to get the 'shape_type' for those embedded files but it is giving 'none' while in 'shape.name' it is giving 'Object 5'.\nAny help would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":384,"Q_Id":53828130,"Users Score":0,"Answer":"The short answer is that there is no API support for embedded files. You're on your own for doing that with python-pptx, at least so far.\nA chart object interacts with an embedded Excel file (.xlsx), so reviewing the code for that might give you some ideas, but it would be a serious development exercise.","Q_Score":2,"Tags":"python-2.7,python-pptx","A_Id":54138252,"CreationDate":"2018-12-18T07:22:00.000","Title":"Reading embedded objects from presentation using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I tried to insert right double quotes (\u201d) using python MySQLdb it produces UnicodeEncodeError: 'latin-1' codec can't encode character u'\\u201d' in position 0: ordinal not in range(256). python MySQLdb uses latin-1 codec by default and from the index.xml file in the \/usr\/share\/mysql\/charsets\/, it is described as cp1252 West European. Hence I think that latin1 will cover cp1252 characters also. But latin1 won't cover cp1252 characters, If they does I will not get the Error.\nThe right double quotes are lies in cp1252 charset but not in ISO 8859-1( or latin1) charset. \nThere is no cp1252.xml file in \/usr\/share\/mysql\/charsets\/. Why python MySQLdb is missing cp1252 charset?\nOr whether the latin1 is same as cp1252 as they described in index.xml.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1135,"Q_Id":53828618,"Users Score":0,"Answer":"You really need cp1252, not utf-8?\nI strongly recommend using utf-8.\nWhat you need is:\n\nPass charset=\"utf8mb4\" option to MySQLdb.connect().\nConfigure database to use utf-8.\n\nYou can create database with utf-8 by CREATE DATABASE <your db name> DEFAULT CHARACTER SET utf8mb4.\nIf you already have database, you can change default character set by ALTER DATABASE <your db name> CHARACTER SET utf8mb4.  But you need to change all character set for existing tables in the database too.","Q_Score":0,"Tags":"python-2.7,character-encoding,mysql-python,cp1252","A_Id":53862166,"CreationDate":"2018-12-18T08:00:00.000","Title":"How to insert cp1252 characters using MySQLdb?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can find that spyder.exe is open based on its pid from tasklist, but is there a way to find if the application is idle or any operation such a script is being run inside Spyder or any other Python IDE","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2527,"Q_Id":53829284,"Users Score":0,"Answer":"I think after (.)py file created its difficult to identify   in which IDE the file created.","Q_Score":0,"Tags":"python,task","A_Id":61124671,"CreationDate":"2018-12-18T08:49:00.000","Title":"How to know if a script is running in Spyder or any other Python IDE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using scipy.signal.fft.rfft() to calculate power spectral density of a signal. The sampling rate is 1000Hz and the signal contains 2000 points. So frequency bin is (1000\/2)\/(2000\/2)=0.5Hz. But I need to analyze the signal in [0-0.1]Hz. \nI saw several answers recommending chirp-Z transform, but I didn't find any toolbox of it written in Python. \nSo how can I complete this small-bin analysis in Python? Or can I just filter this signal to [0-0.1]Hz using like Butterworth filter?\nThanks a lot!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":279,"Q_Id":53830329,"Users Score":1,"Answer":"Even if you use another transform, that will not make more data.\nIf you have a sampling of 1kHz and 2s of samples, then your precision is 0.5Hz. You can interpolate this with chirpz (or just use sinc(), that's the shape of your data between the samples of your comb), but the data you have on your current point is the data that determines what you have in the lobes (between 0Hz and 0.5Hz).\nIf you want a real precision of 0.1Hz, you need 10s of data.","Q_Score":0,"Tags":"python,signal-processing,fft","A_Id":53830482,"CreationDate":"2018-12-18T09:50:00.000","Title":"How to obtain small bins after FFT in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using scipy.signal.fft.rfft() to calculate power spectral density of a signal. The sampling rate is 1000Hz and the signal contains 2000 points. So frequency bin is (1000\/2)\/(2000\/2)=0.5Hz. But I need to analyze the signal in [0-0.1]Hz. \nI saw several answers recommending chirp-Z transform, but I didn't find any toolbox of it written in Python. \nSo how can I complete this small-bin analysis in Python? Or can I just filter this signal to [0-0.1]Hz using like Butterworth filter?\nThanks a lot!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":279,"Q_Id":53830329,"Users Score":1,"Answer":"You can't get smaller frequency bins to separate out close spectral peaks unless you use more (a longer amount of) data.\nYou can't just use a narrower filter because the transient response of such a filter will be longer than your data.\nYou can get smaller frequency bins that are just a smooth interpolation between nearby frequency bins, for instance to plot the spectrum on wider paper or at a higher dpi graphic resolution, by zero-padding the data and using a longer FFT.  But that won't create more detail.","Q_Score":0,"Tags":"python,signal-processing,fft","A_Id":53860082,"CreationDate":"2018-12-18T09:50:00.000","Title":"How to obtain small bins after FFT in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In OpenCV under Python, is there no better way to compute the centroid of the inside a contour than with the function cv2.moments, which computes all moments up to order 3 (and is overkill) ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":153,"Q_Id":53830357,"Users Score":0,"Answer":"You can use cv2.connectedComponentsWithStats it return the centroid and size of contour.","Q_Score":0,"Tags":"python,opencv","A_Id":53830550,"CreationDate":"2018-12-18T09:51:00.000","Title":"Centroid of a contour","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have one more Query \nhere is two sentences\n\n[1,12:12] call basic_while1() Error Code: 1046. No database selected \n[1,12:12] call add() Asdfjgg Error Code: 1046. No database selected\n[1,12:12] call add()\n[1,12:12]\nError Code: 1046. No database selected\nnow I want to get output like this\n['1','12:12',\"call basic_while1\"] , ['1','12:12', 'call add() Asdfjgg'],['1','12:12', 'call add()'],['1','12:12'],['','','',' Error Code: 1046. No database selected']\n\nI used this r'^\\[(\\d+),(\\s[0-9:]+)\\]\\s+(.+) this is my main regex then as per my concern I modified it but It didn't help me\nI want to cut  everything exact before \"Error Code\"\nhow to do that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":233,"Q_Id":53830824,"Users Score":0,"Answer":"basically you asked to get everything before the \"Error Code\"\n\nI want to cut everything exact before \"Error Code\"\n\nso it is simple, try: find = re.search('((.)+)(\\sError Code)*',s) and find.group(1) will give you '[1,12:12] call add() Asdfjgg' which is what you wanted.\nif after you got that string you want list that you requested : \ndesired_list = find.group(1).replace('[','').replace(']','').replace(',',' ').split()","Q_Score":0,"Tags":"python,regex","A_Id":53831362,"CreationDate":"2018-12-18T10:17:00.000","Title":"Regex for Sentences in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Pygame with sprites and animations. I have the sprites but I need to put the Pycharm project into the folder that all the sprites are in but whenever I move the project it takes it out of my Pycharm folder and puts it in the folder with sprites which then means when I open up Pycharm I have to go to File Explorer and find the project that uses the sprites and then make a new Pycharm folder to open it. can I get the project in with the sprites and in the pycharm folder.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":280,"Q_Id":53831211,"Users Score":0,"Answer":"Moving the sprites into the project folder should work.","Q_Score":1,"Tags":"python,pygame,pycharm","A_Id":53868896,"CreationDate":"2018-12-18T10:39:00.000","Title":"Moving A Pycharm Project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am quite new to Python and therefore this might seem easy but I am really stuck here.\nI have a CSV file with values in a [525599 x 74] matrix. For each column of the 74 columns I would like to have the total sum of all 525599 values saved in one list.\nI could not figure out the right way to iterate over each column and save the sum of each column in a list.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":106,"Q_Id":53831555,"Users Score":1,"Answer":"Why don't you :\n\ncreate a columnTotal integer array (one index for each column).\nread the file line by line, per line:\n\n\nSplit the line using the comma as separator\nConvert the splitted string parts to integers\nAdd the value of each column to the columnTotal array's colum index.","Q_Score":0,"Tags":"python,csv","A_Id":53831640,"CreationDate":"2018-12-18T11:01:00.000","Title":"Sum of different CSV columns in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I bumped into this statement in a python script : sys.path.append(\"..\")\nI did some research, but I could not find what does it do.\nI know sys.path.append() function appends a path at the end of the PYTHONPATH list. But what does \"..\" stand for?\nNeedless to say that this python scripts does not work if I comment the line.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":13851,"Q_Id":53834563,"Users Score":4,"Answer":"\"..\" is a way of saying\/referencing the parent of the current working directory.","Q_Score":10,"Tags":"python,python-3.x,sys","A_Id":53834640,"CreationDate":"2018-12-18T13:53:00.000","Title":"What does sys.path.append(\"..\") do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If python 3 is stable and Centos 7 is a modern version, why not include it in the official repositories as well as python 2?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":53836616,"Users Score":1,"Answer":"CentOS 7 ships with Python 2 as it is a critical part of the CentOS base system. Python 3 must be installed alongside Python 2 through the CentOS SCL so that default system tools continue to work properly.","Q_Score":1,"Tags":"python-3.x,centos7","A_Id":53836941,"CreationDate":"2018-12-18T15:48:00.000","Title":"Why Redhat does not include python 3 in centos 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":1,"Web Development":0},{"Question":"I need to import a file into PowerBI via Python.  I need some way to make the file paths in the Python code be dynamic.  Is there a way to reference the current working directory of the power bi file in python code?  os.getcwd() isn't working in the python script editor of PowerBi.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":968,"Q_Id":53837603,"Users Score":2,"Answer":"Found a round about solution for a semi-dynamic way to change file directory:   \n1) create a parameter in powerbi that has the file path to but not including the file\n    eg: C:\\Users\\User\\Documents\\Folder\\\n2) Need to run your initial import job with static file references in your python code\n    eg: C:\\Users\\User\\Documents\\Folder\\file.xlsx\n3) Once your python created table is in, go into the query editor > Advanced Editor\n4) Now for every reference of the full file path we will break the python code and insert the PowerBI parameter object using \" & Parameter & \"\n    eg: ...df = pd.read_excel(r'C:\\Users\\User\\Documents\\Folder\\file.xlsx')...\n    becomes: ...df = pd.read_excel(r'\" & Parameter & \"file.xlsx')...\nThis allows the end_user to be able to easily change the directory by just modifying the parameter, without having to touch any of the python code.","Q_Score":2,"Tags":"python,powerbi","A_Id":53841491,"CreationDate":"2018-12-18T16:47:00.000","Title":"How to get Current Working Directory of PowerBI in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried using tab but it causes indentation from the point where the cursor was there. Is there any shortcut for moving line by one tab from the beginning of the line, not from the point of the cursor?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":53839074,"Users Score":0,"Answer":"You could map custom shortcut for \"Indent Line or Selection\" action in \"File | Settings | Keymap - Other\"","Q_Score":1,"Tags":"python,intellij-idea","A_Id":53848436,"CreationDate":"2018-12-18T18:28:00.000","Title":"Shortcut for indent line from the beginning in Intellij?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating a list of subprocesses that takes a URL and a folder path and saves the images on the page at that URL to the folder. When I start each subprocess I set subprocess.url and subprocess.path. Later in my code I poll the list of subprocesses and remove finished ones, and print to my log file the URL and folder (which I get from the attributes I previously set), and # images in it.\nHowever, I have a feeling this kind of thing is bad practice because this might be overwriting an attribute used by the subprocess class itself. Is this bad? And if yes, what's a better way to keep track of values associated with an instance. Should I create a wrapper class with a subprocess as an attribute?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":55,"Q_Id":53840682,"Users Score":-1,"Answer":"Here comes handy that _private_vars start with a _. The public attributes are documented, therefore you know if you overwrite something. If this was not the case than you couldn't do inheritence.\nThat being said it is not a nice solution, especially if someday sombody else may stumble upon your code. But if it makes a on-time job quick, then do it.","Q_Score":0,"Tags":"python,python-3.x,attributes,instance,instance-variables","A_Id":53840877,"CreationDate":"2018-12-18T20:37:00.000","Title":"Is it bad practice to add my own attributes to instances?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script that repopulates a large database and would generate id values from other tables when needed. \nExample would be recording order information when given customer names only. I would check to see if the customer exists in a CUSTOMER table. If so, SELECT query to get his ID and insert the new record. Else I would create a new CUSTOMER entry and get the Last_Insert_Id(). \nSince these values duplicate a lot and I don't always need to generate a new ID --  Would it be better for me to store the ID => CUSTOMER relationship as a dictionary that gets checked before reaching the database or should I make the script constantly requery the database? I'm thinking the first approach is the best approach since it reduces load on the database, but I'm concerned for how large the ID Dictionary would get and the impacts of that. \nThe script is running on the same box as the database, so network delays are negligible.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":53842401,"Users Score":0,"Answer":"\"Is it more efficient\"?\nWell, a dictionary is storing the values in a hash table.  This should be quite efficient for looking up a value.\nThe major downside is maintaining the dictionary.  If you know the database is not going to be updated, then you can load it once and the in-application memory operations are probably going to be faster than anything you can do with a database.\nHowever, if the data is changing, then you have a real challenge.  How do you keep the memory version aligned with the database version?  This can be very tricky.\nMy advice would be to keep the work in the database, using indexes for the dictionary key.  This should be fast enough for your application.  If you need to eke out further speed, then using a dictionary is one possibility -- but no doubt, one possibility out of many -- for improving the application performance.","Q_Score":0,"Tags":"python,mysql,sql,database,python-2.7","A_Id":53844012,"CreationDate":"2018-12-18T23:06:00.000","Title":"Is it more efficient to store id values in dictionary or re-query database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to install the numpy package for python 3.5 on my Mac OS High Sierra, but I can't seem to make it work.\nI have it on python2.7, but I would also like to install it for the next versions. \nCurrently, I have installed python 2.7, python 3.5, and python 3.7.\nI tried to install numpy using:\n\nbrew install numpy --with-python3 (no error)\nsudo port install py35-numpy@1.15.4 (no error)\nsudo port install py37-numpy@1.15.4 (no error)\npip3.5  install numpy (gives \"Could not find a version that satisfies the requirement numpy (from versions: )\nNo matching distribution found for numpy\" )\n\nI can tell that it is not installed because when I type python3 and then import numpy as np gives \"ModuleNotFoundError: No module named 'numpy'\"\nAny ideas on how to make it work?\nThanks in advance.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3167,"Q_Id":53842426,"Users Score":1,"Answer":"First, you need to activate the virtual environment for the version of python you wish to run. After you have done that then just run \"pip install numpy\" or \"pip3 install numpy\".\nIf you used Anaconda to install python then, after activating your environment, type conda install numpy.","Q_Score":2,"Tags":"python,python-3.x,macos,numpy","A_Id":53844061,"CreationDate":"2018-12-18T23:09:00.000","Title":"install numpy on python 3.5 Mac OS High sierra","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to install the numpy package for python 3.5 on my Mac OS High Sierra, but I can't seem to make it work.\nI have it on python2.7, but I would also like to install it for the next versions. \nCurrently, I have installed python 2.7, python 3.5, and python 3.7.\nI tried to install numpy using:\n\nbrew install numpy --with-python3 (no error)\nsudo port install py35-numpy@1.15.4 (no error)\nsudo port install py37-numpy@1.15.4 (no error)\npip3.5  install numpy (gives \"Could not find a version that satisfies the requirement numpy (from versions: )\nNo matching distribution found for numpy\" )\n\nI can tell that it is not installed because when I type python3 and then import numpy as np gives \"ModuleNotFoundError: No module named 'numpy'\"\nAny ideas on how to make it work?\nThanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3167,"Q_Id":53842426,"Users Score":0,"Answer":"If running pip3.5 --version or pip3 --version works, what is the output when you run pip3 freeze? If there is no output, it indicates that there are no packages installed for the Python 3 environment and you should be able to install numpy with pip3 install numpy.","Q_Score":2,"Tags":"python,python-3.x,macos,numpy","A_Id":53928674,"CreationDate":"2018-12-18T23:09:00.000","Title":"install numpy on python 3.5 Mac OS High sierra","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is for Python\/PySpark using Spark 2.3.2. \nI am looking for best practice approach for copying columns of one data frame to another data frame using Python\/PySpark for a very large data set of 10+ billion rows (partitioned by year\/month\/day, evenly). Each row has 120 columns to transform\/copy. The output data frame will be written, date partitioned, into another parquet set of files.\nExample schema is: \ninput DFinput (colA, colB, colC) and \noutput DFoutput (X, Y, Z)\nI want to copy DFInput to DFOutput as follows (colA => Z, colB => X, colC => Y).\nWhat is the best practice to do this in Python Spark 2.3+ ?\nShould I use DF.withColumn() method for each column to copy source into destination columns? \nWill this perform well given billions of rows each with 110+ columns to copy? \nThank you","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":9487,"Q_Id":53843406,"Users Score":1,"Answer":"Use dataframe.withColumn() which Returns a new DataFrame by adding a column or replacing the existing column that has the same name.","Q_Score":5,"Tags":"python,apache-spark,pyspark","A_Id":59532530,"CreationDate":"2018-12-19T01:32:00.000","Title":"Spark copying dataframe columns best practice in Python\/PySpark?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is for Python\/PySpark using Spark 2.3.2. \nI am looking for best practice approach for copying columns of one data frame to another data frame using Python\/PySpark for a very large data set of 10+ billion rows (partitioned by year\/month\/day, evenly). Each row has 120 columns to transform\/copy. The output data frame will be written, date partitioned, into another parquet set of files.\nExample schema is: \ninput DFinput (colA, colB, colC) and \noutput DFoutput (X, Y, Z)\nI want to copy DFInput to DFOutput as follows (colA => Z, colB => X, colC => Y).\nWhat is the best practice to do this in Python Spark 2.3+ ?\nShould I use DF.withColumn() method for each column to copy source into destination columns? \nWill this perform well given billions of rows each with 110+ columns to copy? \nThank you","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":9487,"Q_Id":53843406,"Users Score":0,"Answer":"Bit of a noob on this (python), but might it be easier to do that in SQL (or what ever source you have)  and then read it into a new\/separate dataframe?","Q_Score":5,"Tags":"python,apache-spark,pyspark","A_Id":53884751,"CreationDate":"2018-12-19T01:32:00.000","Title":"Spark copying dataframe columns best practice in Python\/PySpark?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"when I used or write a 3rd party library of python, I want import it in my code file.\nIn linux set environment variable $PYTHONPATH and works well.\nBut in Windows, After setting environment variable PYTHONPATH and rebooting,it didn't work. Especially in PyCharm terminal.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":106,"Q_Id":53844036,"Users Score":1,"Answer":"If your question is specific to PyCharm, I recommend either installing the package into the virtual environment \/ interpreter you're using for the project from File - Settings - Project: name - Project Interpreter or adding the library to your project and setting the folder to be recognised as a source folder by PyCharm.\nRight-click the library folder, then select Mark Directory as - Sources Root","Q_Score":0,"Tags":"python,environment-variables,pythonpath","A_Id":53844083,"CreationDate":"2018-12-19T03:08:00.000","Title":"set PYTHONPATH enviroment varable for library, but can not import in windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"My system will goes to sleep if there is no keyboard and mouse action for more than 5 min ( I cannot make any changes in sleep time. For security reason it is set to 5 min). \nI am using pyautogui for automation. Pyautogui works in background based on screen resolution by taking keyboard and mouse control. It is taking more than 5 min in my case to complete the execution. After 5 min it going to sleep and keyboard interrupt is generated.\nPlease let me know is there any solution for these.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1488,"Q_Id":53845031,"Users Score":1,"Answer":"One thing I've found to work is running the pyautogui script in a virtual machine, which lets it use the virtual mouse & keyboard. This has the twofold benefit of a. allowing you to do other work while the script is running, and b. the virtual mouse & keyboard are not interrupted with the computer going to sleep.\nHope this helps!","Q_Score":2,"Tags":"python,python-3.x,automation,python-2.x,pyautogui","A_Id":58416808,"CreationDate":"2018-12-19T05:21:00.000","Title":"Automation using Pyautogui","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My system will goes to sleep if there is no keyboard and mouse action for more than 5 min ( I cannot make any changes in sleep time. For security reason it is set to 5 min). \nI am using pyautogui for automation. Pyautogui works in background based on screen resolution by taking keyboard and mouse control. It is taking more than 5 min in my case to complete the execution. After 5 min it going to sleep and keyboard interrupt is generated.\nPlease let me know is there any solution for these.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1488,"Q_Id":53845031,"Users Score":0,"Answer":"If you are waiting for some action to be completed, you can simulate a minor mouse movement in a new thread. This will prevent system from sleep.","Q_Score":2,"Tags":"python,python-3.x,automation,python-2.x,pyautogui","A_Id":53845111,"CreationDate":"2018-12-19T05:21:00.000","Title":"Automation using Pyautogui","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've a machine learning application which uses flask to expose api(for production this is not a good idea, but even if I'll use django in future the idea of the question shouldn't change).\nThe main problem is how to serve multiple requests to my app. Few months back celery has been added to get around this problem. The number of workers in celery that was spawned is equal to the number of cores present in the machine. For very few users this was looking fine and was in production for some time.\nWhen the number of concurrent users got increased, it was evident that we should do a performance testing on it. It turns out: it is able to handle 20 users for 30 GB and 8 core machine without authentication and without any front-end. Which is not looking like a good number.\nI didn't know there are things like: application server, web server, model server. When googling for this problem: gunicorn was a good application server python application.\n\nShould I use gunicorn or any other application server along with celery and why\nIf I remove celery and only use gunicorn with the application can I achieve concurrency. I have read somewhere celery is not good for machine learning applications.\nWhat are the purposes of gunicorn and celery. How can we achieve the best out of both.\n\nNote: Main goal is to maximize concurrency. While serving in production authentication will be added. One front-end application might come into action in between in production.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2205,"Q_Id":53845434,"Users Score":9,"Answer":"There is no shame in flask. If in fact you just need a web API wrapper, flask is probably a much better choice than django (simply because django is huge and you'd be using only a fraction of its capability).\nHowever, your concurrency problems are apparently stemming from the fact that you are doing some heavy-duty processing for each request. There is simply no way around that; if you require a certain amount of computational resources per request, you can't magic those up. From here on, it's a juggling act.\n\nIf you want a guaranteed response immediately, you need to have as many workers as potential simultaneous requests. This may involve load balancing over multiple servers, if you can't scrounge up enough resources on one server. (cue gunicorn, a web application server, responsible for accepting connections and then distributing them to multiple application processes.)\nIf you are okay with not getting an immediate response, you can let stuff queue up. (cue celery, a task queue, which worker processes can use to retrieve the next thing to be done, and deposit results). This works best if you don't need a response in the same request-response cycle; e.g. you submit a job from client, and they only get an acknowledgement that the job has been received; you would need a second request to ask about the status of the job, and possibly the results of the job if it is finished.\nAlternately, instead of Flask you could use websockets or Tornado, to push out the response to the client when it is available (as opposed to user polling for results, or waiting on a live HTTP connection and taking up a server process).","Q_Score":4,"Tags":"python,concurrency,celery,gunicorn","A_Id":53845615,"CreationDate":"2018-12-19T06:05:00.000","Title":"gunicorn and\/or celery: What is the way get the best out of both?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Unlike in other languages like C#, there is no way to import an empty string from Python standard library. However, there is a built-in function str(), which defaults to an empty string when no argument was supplied.\nWhat would be the pros and cons of using str()--compared to '' or empty_str = ''--to denote an empty string? I guess the overhead would be negligible, and it is as readable as '' or \"\". For one thing, it is visually clear that the variable is a str even in Notepad. One obvious disadvantage is that you have to type the keyboard a few more times than '' although not as many as empty_str. Can you think of any other merits or demerits?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4202,"Q_Id":53846881,"Users Score":3,"Answer":"It has exactly the same effect, and '' (or \"\") should be used (similar [] for list, and () for tuple, {} for dict).\nAnd Python will indeed have an internal global cache for small constants (short strings, including the empty string, and small numbers). Check that by id('') or id(0), it will very likely always return the same. (This is implementation specific, but CPython will behave this way.)","Q_Score":1,"Tags":"python,string","A_Id":53847190,"CreationDate":"2018-12-19T08:03:00.000","Title":"Pros and cons of using str() to initialize an empty string literal in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Unlike in other languages like C#, there is no way to import an empty string from Python standard library. However, there is a built-in function str(), which defaults to an empty string when no argument was supplied.\nWhat would be the pros and cons of using str()--compared to '' or empty_str = ''--to denote an empty string? I guess the overhead would be negligible, and it is as readable as '' or \"\". For one thing, it is visually clear that the variable is a str even in Notepad. One obvious disadvantage is that you have to type the keyboard a few more times than '' although not as many as empty_str. Can you think of any other merits or demerits?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4202,"Q_Id":53846881,"Users Score":1,"Answer":"Use s = ''.\nFirst, Python itself is not the fastest language in universe, and Python developers are not supposed to make such kind of optimization, like creating global variables for empty constants or optimizing variable initialization with constants. Your code will be considered as not maintainable, because others would not understand your purpose.\nSecond, any static code analyzer will always understand the type of your variable from a constant. But when function is called, analyzer has to find the declaration and get the return value type. I dont speak about str() - as a builtin, it's return type is well known to analyzers. But in general approach is not good, because in Python programmers not always explicitly define the return value type of functions.","Q_Score":1,"Tags":"python,string","A_Id":53847111,"CreationDate":"2018-12-19T08:03:00.000","Title":"Pros and cons of using str() to initialize an empty string literal in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to filter out responses by custom_variables?\nI have set custom_varibles in weblink collector, now need to filter it by the variable I have set. Or Is their another way of setting a unique value, like email\/username with weblink collector type and filter the responses by this unique value.\nI am Currently redirecting to SurveyMonkey weblink with email as a custom_variable, now I need to identify the response with this email.\nEDIT: Is this Possible?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":97,"Q_Id":53847920,"Users Score":1,"Answer":"It's on our upcoming roadmap.\nIn the meantime, use \"?c=whatever_string_you_want\" and use the \"custom\" responses filter.","Q_Score":1,"Tags":"django,python-3.x,web,surveymonkey","A_Id":53856271,"CreationDate":"2018-12-19T09:13:00.000","Title":"SurveyMonkey : How to Filter responses by custom_variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to run my Python code in raspberry Pi 3 and I keep getting the error: ImportError: no module named playsound. I have already successfully installed playsound (using the command: pip install playsound).","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":23474,"Q_Id":53851972,"Users Score":0,"Answer":"In my case, one module worked with pip3 install pygame but not playsound. I snooped through python files to see the difference between pygame and playsound. I found out that playsound was not in its folder: C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\site-packages.\nSo I moved it to C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\site-packages\\playsound-1.2.2.dist-info\nBut remember to put it back after compiling it so you can use the module. Somehow it worked for me.","Q_Score":0,"Tags":"python,raspberry-pi3,raspbian,importerror,python-playsound","A_Id":67811688,"CreationDate":"2018-12-19T13:10:00.000","Title":"ImportError: no module named playsound","Data 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 am trying to run my Python code in raspberry Pi 3 and I keep getting the error: ImportError: no module named playsound. I have already successfully installed playsound (using the command: pip install playsound).","AnswerCount":5,"Available Count":4,"Score":0.1194272985,"is_accepted":false,"ViewCount":23474,"Q_Id":53851972,"Users Score":3,"Answer":"Just change from playsound import playsound to import playsound","Q_Score":0,"Tags":"python,raspberry-pi3,raspbian,importerror,python-playsound","A_Id":58259842,"CreationDate":"2018-12-19T13:10:00.000","Title":"ImportError: no module named playsound","Data 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 am trying to run my Python code in raspberry Pi 3 and I keep getting the error: ImportError: no module named playsound. I have already successfully installed playsound (using the command: pip install playsound).","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":23474,"Q_Id":53851972,"Users Score":1,"Answer":"The best solution that worked for me is uninstalling playsound using pip uninstall playsound and then installing it again using pip install playsound.","Q_Score":0,"Tags":"python,raspberry-pi3,raspbian,importerror,python-playsound","A_Id":62380329,"CreationDate":"2018-12-19T13:10:00.000","Title":"ImportError: no module named playsound","Data 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 am trying to run my Python code in raspberry Pi 3 and I keep getting the error: ImportError: no module named playsound. I have already successfully installed playsound (using the command: pip install playsound).","AnswerCount":5,"Available Count":4,"Score":-0.0399786803,"is_accepted":false,"ViewCount":23474,"Q_Id":53851972,"Users Score":-1,"Answer":"The problem according to the best of my knowledge, it is the environment, by default the raspberry pi is running python2 on the command terminal, and I guess you are running your program on thonny idle or the python3 idle, so what you are doing is your are using python2 environment to install playsound(Terminal) and then using the python3 environment to run your program.\nSo what I did is i used this command on the terminal\nsudo apt-get remove python2.7 --purge\nsudo apt-get install python3.5\npip3 install playsound\nand behold no module error.","Q_Score":0,"Tags":"python,raspberry-pi3,raspbian,importerror,python-playsound","A_Id":66258752,"CreationDate":"2018-12-19T13:10:00.000","Title":"ImportError: no module named playsound","Data 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 put my optimization problem into Pyomo, but it is strongly dependent upon standard linear algebra operations - qr, inverse, transpose, product. Actually, this is Kalman filter problem; recursive linear algebra for long time series. I failed to find pyomo functions to implement it like I could in tensor flow. Is it possible?\nConnected questions:\n\nAm I right that numpy target function is practically not usable in pyomo? \nIs there a better free optimization solution for the purpose? (scipy cannot approach efficiency of Matlab by far, tensor flow is extremely slow for particular problem, though I do not see why, algorithmic differentiation in Matlab was reasonably fast though not fast enough)\n\nMany thanks,\nVladimir","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":600,"Q_Id":53851982,"Users Score":1,"Answer":"Pyomo is mainly a package for optimization. i.e. specifying data -> building problem -> sending to the solver -> wait for solver's results -> retrieving solution. Even if it can handle matrix-like data, it cannot manipulate it with matrix operations. This should be done using a good external library, before you send your data to Pyomo. Once you have all your matrixes ready to be used as data in your optimization model, then you can use Pyomo for optimization. \nThat being said, you should look into finding a library that fits your needs to build your data, since your data values must be static, once you provide it as an input to your model. \nAlso, keep in mind that Pyomo, like any optimization tools, is deterministic. It is not meant to do data analysis or data description, but to provide a way to find one optimal solution of a mathematical problem. In your case, Pyomo is not meant to do the Kalman filter problem, but to give you the solution of minimizing the mean square error.","Q_Score":0,"Tags":"python,optimization,pyomo","A_Id":53875465,"CreationDate":"2018-12-19T13:11:00.000","Title":"Linear algebra with Pyomo","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"when i run: pip install -v scipy in the virtualenv of RPI, RPI freezes halfway through installation and i had to power off and on RPI to turn it on again.\nI tried upgrading pip but the problem persisted and I can't seem to find out the reason why. Please help, thank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":71,"Q_Id":53853196,"Users Score":1,"Answer":"At first, check the power supply and a CPU heatsink. My RPi was stuck very often during different long-term tasks, after I installed heastsink problem was gone.","Q_Score":0,"Tags":"python,scipy,pip,virtualenv","A_Id":53853452,"CreationDate":"2018-12-19T14:21:00.000","Title":"Issue with installing Scipy in virtualenv on RaspBerryPI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using django for a while, but there is something im not quite clear on. \nHow big should a django app be. If for example a django app should only be user authentication or if it should be an entire website in one app.\nIf I have a project with several apps and each app is a whole website with a lot of code, is that the way it suppose to be or should all apps related to a single site within a project ?\nIm thinking of creating one django project for each site, but im now wondering if I should be creating one project where each app is one site. Can anyone please comment on this, what it the preferred way to do it ?\nIn the django documentation one app is only used for a poll, so it seems to be that, according to the documentation, that each app should be some part of functionality on the site.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":53854001,"Users Score":1,"Answer":"An app is a submodule of a project which contains functionality (views, models, urls etc) for a specific part of the larger site and is as decoupled from the other apps as possible. The project as a whole is the website and your apps make up the separate parts of functionality for your site.\nIf your sites are going to basically contain the same functionality, it might be worth looking into the Sites framework which django provides.\nSo taking the polls example further.\nLets say the website is a survey site. There would be the polls app, which would contain the relevant models and views for creating and recording poll results. Then you might need to view the data, so you could create an analysis app, which would store the views for displaying dashboards and contain functions for data processing. Then we could take things a bit further, and have users be able to log in and see their own results (and give us the chance to link users to poll results), so you would make an accounts app, which would hold views for logging in\/out, maybe a profile page etc.\nSo each of these different parts of functionality would be separated out into distinct apps, which would make up the project (site) as a whole.\nIf the apps have been decoupled properly, you could reuse the different apps in other projects (e.g. the accounts app could be dropped into a new project do provide logging in\/out functionality)","Q_Score":0,"Tags":"python,django","A_Id":53854111,"CreationDate":"2018-12-19T15:07:00.000","Title":"Is a django project only meant to be for a single website or can the different apps be different sites. What is perferable and advisable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been using django for a while, but there is something im not quite clear on. \nHow big should a django app be. If for example a django app should only be user authentication or if it should be an entire website in one app.\nIf I have a project with several apps and each app is a whole website with a lot of code, is that the way it suppose to be or should all apps related to a single site within a project ?\nIm thinking of creating one django project for each site, but im now wondering if I should be creating one project where each app is one site. Can anyone please comment on this, what it the preferred way to do it ?\nIn the django documentation one app is only used for a poll, so it seems to be that, according to the documentation, that each app should be some part of functionality on the site.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":53854001,"Users Score":0,"Answer":"In my experience so far, an app should be a reusable entity. There many guiding principles for choosing what to go and what not in an app. Separating authentication is one example. A projcet is one big collection of may apps and a reusable app can be in many projects. \nNowadays, there is a trend to move to micro service architecture, which is next level of separation of functionality with each service doing best one thing.\nEach project is a unit in itself, not an individual app. So you host the project, not the app. I recommend using different project for each site and using micro-service architecture. A lot depends on your existing codebase too.","Q_Score":0,"Tags":"python,django","A_Id":53854217,"CreationDate":"2018-12-19T15:07:00.000","Title":"Is a django project only meant to be for a single website or can the different apps be different sites. What is perferable and advisable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've got the updated Python VSCode extension installed and it works great. I'm able to use the URL with the token to connect to a remote Jupyter notebook. I just cannot seem to figure out how to change the kernel on the remote notebook for use in VSCode.  \nIf I connect to the remote notebook through a web browser, I can see my two environments through the GUI and change kernels.  Is there a similar option in the VSCode extension?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2677,"Q_Id":53854464,"Users Score":0,"Answer":"Run the following command in vscode: \nPython: Select interpreter to start Jupyter server\nIt will allow you to choose the kernel that you want.","Q_Score":3,"Tags":"python,visual-studio-code,jupyter","A_Id":60310074,"CreationDate":"2018-12-19T15:33:00.000","Title":"Python Vscode extension - can't change remote jupyter notebook kernel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got the updated Python VSCode extension installed and it works great. I'm able to use the URL with the token to connect to a remote Jupyter notebook. I just cannot seem to figure out how to change the kernel on the remote notebook for use in VSCode.  \nIf I connect to the remote notebook through a web browser, I can see my two environments through the GUI and change kernels.  Is there a similar option in the VSCode extension?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2677,"Q_Id":53854464,"Users Score":0,"Answer":"The command that worked for me in vscode:\nNotebook: Select Notebook Kernel","Q_Score":3,"Tags":"python,visual-studio-code,jupyter","A_Id":69253401,"CreationDate":"2018-12-19T15:33:00.000","Title":"Python Vscode extension - can't change remote jupyter notebook kernel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list which has the latitude and longitude of points on a map. I want to identify census tracts whose center is ten miles away or more from all points in the list (basically identifying rural census tracts). I also have a list of all census tracts and the latitude and longitude of their center. How can I cross reference each census tract with each point in the list and identify the distance from their center to each point and create a list of census tracts who have no points within ten miles of their center?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":53858426,"Users Score":0,"Answer":"So, what you could do is simply create 2 lists, a list of all census tracts, and then a list of rural census tracts. The rural list should start out empty, and then as you add tracts to it you will have to compare the new track against all the other tracts in the list to make sure the great circle distance is more than ten miles. If so you add it to the list, and if not remove the entity from the rural list, and keep iterating through your list to compare the new tract against all the remaining tracts in your rural list to make sure no more tracts are also in range. If so delete those rural tracts as well.\nThe real challenge with this problem is the complexity of it. If you are dealing with a large amount of CTs, iterating through a growing list to compare against some new value is going to be very costly. There is likely a way to optimize this using a map and only comparing the new tract against other tracts in a ten mile square around it, but this would be more of a math problem I think than a software one.","Q_Score":0,"Tags":"python,mapping,gis,haversine","A_Id":53858980,"CreationDate":"2018-12-19T20:04:00.000","Title":"Using longitude and latitude, best method for identifying which points from one list are the closest to each point on another list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have always heared that compile time languages (Java, C++ etc) are statically typed and interpreted languages (PHP, Python etc) are dynamically typed, But the question is why they are, Why not a compile time language can be dynamically type and vice versa?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":69,"Q_Id":53858766,"Users Score":1,"Answer":"This depends strictly on the language e.g. Java has mixed mode where the code that runs less often is only interpreted. Code compilation can be expensive so if the compiled code is not executed many times after the compilation the effort spent compiling will not be worth it.","Q_Score":0,"Tags":"java,php,python,typed","A_Id":53858825,"CreationDate":"2018-12-19T20:33:00.000","Title":"Why dynamically type languages are interpreted and statically type languages are compile time 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have always heared that compile time languages (Java, C++ etc) are statically typed and interpreted languages (PHP, Python etc) are dynamically typed, But the question is why they are, Why not a compile time language can be dynamically type and vice versa?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":69,"Q_Id":53858766,"Users Score":1,"Answer":"It's not really true. Java bytecodes can be interpreted, indeed they were only interpreted up until around JDK 1.1.5ish. JavaScript is often compiled.\nHowever, an interpreter for a dynamic language is really easy to write. Perhaps try it. Statically typed languages are a bit more difficult, so you may as well compile it anyway. On the other hand, to reasonably compile a dynamic language takes some effort.","Q_Score":0,"Tags":"java,php,python,typed","A_Id":53858794,"CreationDate":"2018-12-19T20:33:00.000","Title":"Why dynamically type languages are interpreted and statically type languages are compile time 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am in 10th grade and I am looking to use a machine learning model on patient data to find a correlation between the time of week and patient adherence. I have separated the week into 21 time slots, three for each time of day (1 is Monday morning, 2 is monday afternoon, etc.). Adherence values will be binary (0 means they did not take the medicine, 1 means they did). I will simulate training, validation and test data for my model. From my understanding, I can use a logistic regression model to output the probability of the patient missing their medication on a certain time slot given past data for that time slot. This is because logistic regression outputs binary values when given a threshold and is good for problems dealing with probability and binary classes, which is my scenario. In my case, the two classes I am dealing with are yes they will take their medicine, and no they will not. But the major problem with this is that this data will be non-linear, at least to my understanding. To make this more clear, let me give a real life example. If a patient has yoga class on Sunday mornings, (time slot 19) and tends to forget to take their medication at this time, then most of the numbers under time slot 19 would be 0s, while all the other time slots would have many more 1s. The goal is to create a machine learning model which can realize given past data that the patient is very likely going to miss their medication on the next time slot 19. I believe that logistic regression must be used on data that still has an inherently linear data distribution, however I am not sure. I also understand that neural networks are ideal for non-linear distributions, but neural networks require a lot of data to function properly, and ideally the goal of my model is to be able to function decently with simply a few weeks of data. Of course any model becomes more accurate with more data, but it seems to me that generally neural networks need thousands of data sets to truly become decently accurate. Again, I could very well be wrong.\nMy question is really what model type would work here. I do know that I will need some form of supervised classification. But can I use logistic regression to make predictions when given time of week about adherence?\nReally any general feedback on my project is greatly appreciated! Please keep in mind I am only 15, and so certain statements I made were possibly wrong and I will not be able to fully understand very complex replies.\nI also have to complete this within the next two weeks, so please do not hesitate to respond as soon as you can! Thank you so much!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":53862029,"Users Score":0,"Answer":"It's true that you need a lot of data for applying neural networks. \nIt would have been helpful if you could be more precise about your dataset and the features. You can also try implementing K-Means-Clustering for your project. If your aim is to find out that did the patient took medicine or not then it can be done using logistic regression.","Q_Score":0,"Tags":"python,machine-learning,neural-network,classification,logistic-regression","A_Id":53903711,"CreationDate":"2018-12-20T03:25:00.000","Title":"Would a Logistic Regression Machine Learning Model Work Here?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am in 10th grade and I am looking to use a machine learning model on patient data to find a correlation between the time of week and patient adherence. I have separated the week into 21 time slots, three for each time of day (1 is Monday morning, 2 is monday afternoon, etc.). Adherence values will be binary (0 means they did not take the medicine, 1 means they did). I will simulate training, validation and test data for my model. From my understanding, I can use a logistic regression model to output the probability of the patient missing their medication on a certain time slot given past data for that time slot. This is because logistic regression outputs binary values when given a threshold and is good for problems dealing with probability and binary classes, which is my scenario. In my case, the two classes I am dealing with are yes they will take their medicine, and no they will not. But the major problem with this is that this data will be non-linear, at least to my understanding. To make this more clear, let me give a real life example. If a patient has yoga class on Sunday mornings, (time slot 19) and tends to forget to take their medication at this time, then most of the numbers under time slot 19 would be 0s, while all the other time slots would have many more 1s. The goal is to create a machine learning model which can realize given past data that the patient is very likely going to miss their medication on the next time slot 19. I believe that logistic regression must be used on data that still has an inherently linear data distribution, however I am not sure. I also understand that neural networks are ideal for non-linear distributions, but neural networks require a lot of data to function properly, and ideally the goal of my model is to be able to function decently with simply a few weeks of data. Of course any model becomes more accurate with more data, but it seems to me that generally neural networks need thousands of data sets to truly become decently accurate. Again, I could very well be wrong.\nMy question is really what model type would work here. I do know that I will need some form of supervised classification. But can I use logistic regression to make predictions when given time of week about adherence?\nReally any general feedback on my project is greatly appreciated! Please keep in mind I am only 15, and so certain statements I made were possibly wrong and I will not be able to fully understand very complex replies.\nI also have to complete this within the next two weeks, so please do not hesitate to respond as soon as you can! Thank you so much!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":78,"Q_Id":53862029,"Users Score":1,"Answer":"In my opinion a logistic regression won't be enough for this as u are going to use a single parameter as input. When I imagine a decision line for this problem, I don't think it can be achieved by a single neuron(a logistic regression). It may need few more neurons or even few layers of them to do so. And u may need a lot of data set for this purpose.","Q_Score":0,"Tags":"python,machine-learning,neural-network,classification,logistic-regression","A_Id":53902459,"CreationDate":"2018-12-20T03:25:00.000","Title":"Would a Logistic Regression Machine Learning Model Work Here?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need a thread running when I start my django server, basically the thread just periodically processes some items from a database.\nWhere is the best place to start this thread.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":85,"Q_Id":53862839,"Users Score":2,"Answer":"I think this is generally a bad idea. You shouldn't have that kind of periodic threads running in the frontend process.\nI would create a management command that will do the processing. Then I would set up a cron job (or any other mechanic provided by the hosting) calling the management command. This way you divide the work to logic places and you can also test the processing much easier.","Q_Score":0,"Tags":"python,django","A_Id":53864009,"CreationDate":"2018-12-20T05:24:00.000","Title":"Where should I start a new thread when the django server starts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python script which included some bash commands in os.system() method .\nIf I convert this python script to exe using Pyinstaller,  will this exe file work properly in windows OS or will I face any issues since Windows can't run bash commands ?\nthe bash commands include pdftk utility.\n Example : pdftk input_pdf output output_pdf userpw password\nShould I install pdftk utility also in Windows.\nWhat should I do or install to make it work in Windows ?\nPlease help me..\nThank you","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":463,"Q_Id":53863036,"Users Score":0,"Answer":"It probably will not work, from what I have seen when using bash commands inside of code on windows. \nSolutions:\n\nChange the commands to commands that work on Windows.\nUse some kind of python api (if you know of one post it in the comments and I will put it here.) that allows you to use the commands you need.\nSimply run the script using the bash terminal on windows, but you won't be able to make it a exe as far as I know.","Q_Score":1,"Tags":"python,windows,bash,pyinstaller,pdftk","A_Id":53863097,"CreationDate":"2018-12-20T05:46:00.000","Title":"I have python script which included some bash commands in os.system(). Will this work in Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a python script which included some bash commands in os.system() method .\nIf I convert this python script to exe using Pyinstaller,  will this exe file work properly in windows OS or will I face any issues since Windows can't run bash commands ?\nthe bash commands include pdftk utility.\n Example : pdftk input_pdf output output_pdf userpw password\nShould I install pdftk utility also in Windows.\nWhat should I do or install to make it work in Windows ?\nPlease help me..\nThank you","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":463,"Q_Id":53863036,"Users Score":1,"Answer":"It won't work, os.system is os specific, in Windows it will just spawn a cmd process and try to execute that command and cmd != bash.\nEdit: powershell has a lot of common bash commands implemented on windows, you could try to figure out in the code what os are you running on and if powershell supports your bash commands you could use the subprocess module to spawn powershell processes","Q_Score":1,"Tags":"python,windows,bash,pyinstaller,pdftk","A_Id":53863085,"CreationDate":"2018-12-20T05:46:00.000","Title":"I have python script which included some bash commands in os.system(). Will this work in Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"As a started with GPU programming, CUDA and Python I decided to install the latest version of CUDA (10) in order to experiment with ML.\nAfter spending considerable time installing (huge downloads) I ended up with a version that isn't supporting Tensorflow.\nI discovered the tensorflow-gpu meta package using Anaconda though! Now unfortunately I have two versions installed and I am not sure how can I uninstall the version 10! Any ideas?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1375,"Q_Id":53866591,"Users Score":2,"Answer":"If you installed via conda install tensorflow-gpu all dependencies are in the Conda environment (e.g., CUDA dlls are in the lib subfolder in the environment), so yes you can safely uninstall CUDA 10.\nNote: at least on Ubuntu I saw that XLA JIT optimization of code (which is an experimental feature still) requires CUDA to be installed properly in the system (it looks from some binaries in the CUDA install dir and it seems to be hardcoded that way), but for normal TF execution the Conda setup is perfectly fine.","Q_Score":0,"Tags":"python,tensorflow,cuda,anaconda,gpu","A_Id":53866818,"CreationDate":"2018-12-20T10:15:00.000","Title":"I installed CUDA10 but Anaconda installs CUDA9. Can I remove the former?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I found there are a lot of same names in keras.backend or keras.layers, for example keras.backend.concatenate and keras.layers.Concatenate. I know vaguely that one is for tensor while the other is for layer. But when the code is so big, so many function made me confused that which is tensor or which is layer. Anybody has a good idea to solve this problem?\nOne way I found is to define all placeholders in one function at first, but the function take it as variable may return layers at end, while another function take this layer as variable may return another variable.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":523,"Q_Id":53871303,"Users Score":5,"Answer":"You should definitely use keras.layers if there is a layer that achieves what you want to do. That's because, when building a model, Keras layers only accept Keras Tensors (i.e. the output of layers) as the inputs. However, the output of methods in keras.backend.* is not a Keras Tensor (it is the backend Tensor, such as TensorFlow Tensor) and therefore you can't pass them directly to a layer.\nAlthough, if there is an operation that could not be done with a layer, then you can use keras.backned.* methods in a Lambda layer to perform that custom operation\/computation.\nNote: Keras Tensor is actually the same type as the backend Tensor (e.g. tf.Tensor); however, it has been augmented with some additional Keras-specific attributes which Keras needs when building a model.","Q_Score":0,"Tags":"python,tensorflow,keras,deep-learning,keras-layer","A_Id":53871442,"CreationDate":"2018-12-20T15:10:00.000","Title":"How to choose between keras.backend and keras.layers?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a csv that has its head (row[0]) separated by spaces, but with the content in the rest of the rows separated by \\t (and many cells have multiple spaces). How can I parse this csv?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2669,"Q_Id":53871480,"Users Score":0,"Answer":"You can parse the csv as before(whole content) and then use regex(regular expressions) to keep or divide and categirize the content you need.","Q_Score":1,"Tags":"python,csv","A_Id":53871595,"CreationDate":"2018-12-20T15:23:00.000","Title":"Parse csv with multiple delimiters in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using MS-D or UNet network for image segmentation. My image has three classes: noise, signal and empty. The class empty is easy to find because the pixel values for the empty class is mainly -1 while for the two other classes is between 0-1. \nIs there a way that I only ask the network to find noise and signal class and not bother the network about the easy one? Or any other clue that can help? I am seeing that the network sometimes is confused when predicting the signal pixels and gives about the same score but with higher to the signal class (e.g. empty0.0001, noise0.0003, signal0.0005) to all three classes. I want to make it easier for the network to figure it out.\nJust more information about my image, around 25% of pixels are signal, 40% noise, and 35% are empty. I am using dice_coef for the metric and loss function.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":53872418,"Users Score":0,"Answer":"I'm not sure if you can do that. I think You should apply some regularization and\/or dropout to the network and feed it more data.\nBut what you could do is to label all the empty pixels as noise as signal is usually in the middle and noise is on the outer side of the signal graph. Then you train the network that way. You will have to set network outputs to 2: noise or signal. From the original image you know which pixels were empty and then you can set those pixels from noise to empty. Then you will have the result you wanted. \nThe only thing that can happen here is that the  network will perform bad because of the imbalanced classes as you will have much more noise than signal pixels.","Q_Score":0,"Tags":"python-2.7,keras,neural-network,image-segmentation","A_Id":53885612,"CreationDate":"2018-12-20T16:20:00.000","Title":"Image segmentation with 3 classes but one of them is easy to find, How can I write the network to not train on the easy one?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Trying to install python (version 3.7.1) on windows 7, and the installation file appears in my downloads folder. However, when I try to run the installation file, as admin, I get the prompt asking if I want to allow the program to make changes to my computer, which I allow, then the installer window doesn't appear. Nothing happens. I can't find a background program running, nothing. It's like the executable doesn't do anything. I'm really stuck.\nIf it helps I'm using a Windows 7 64-bit computer.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1007,"Q_Id":53873807,"Users Score":0,"Answer":"Same problem I also face that you are now facing.\nThe simplest ways to run a python software foundation in windows 7 is.\nFirst completely update your windows 7. It take some minutes and some time Few hours. \nOnce you install windows update.\nThe PYTHON software will run normally.\nAccounting to my experience.","Q_Score":0,"Tags":"python,python-3.x,installation","A_Id":53873964,"CreationDate":"2018-12-20T17:55:00.000","Title":"Python Not Installing on Windows 7 - The Installer Won't Even Appear","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on a project for my Linear Algebra class. I am stuck with a small problem. I could not find any method for finding the row-echelon matrix form (not reduced) in Python (not MATLAB).\nCould someone help me out?\nThank you.\n(I use python3.x)","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":3252,"Q_Id":53875432,"Users Score":3,"Answer":"Bill M's answer is correct. When you find the LU decomposition the U matrix is a  correct way of writing M in REF (note that REF is not unique so there are multiple possible ways to write it). To see why, remember that the LU decomposition finds P,L,U such that PLU = M. When L is full rank we can write this as U = (PL)-1M. So (PL)-1 defines the row operations that you have to preform on M to change it into U.","Q_Score":2,"Tags":"python,python-3.x,matrix","A_Id":53992065,"CreationDate":"2018-12-20T20:15:00.000","Title":"How to find row-echelon matrix form (not reduced) 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":"Before I ask the question, let me preface this by stating that this question has been answered in many articles, but I still struggle to understand the basic format of word embeddings. \nLet's start with the sentence \"I like dogs\". Assuming a simple hashing approach, \"I like dogs\" can be represented in the vector [1, 4, 6] where the elements of the vector correspond to the hash of each word (assuming these aren't the only words in the vocabulary). From what I understand, this vector is fed into an embedding layer which adds an extra embedding dimension onto the input tensor of the RNN (doesn't have to be vanilla RNN).\nThe embedding tensor (with lets say an embedding dimension of 2) will look something like this for a single entry in the batch:\n[[4.55, 6.78], -> I \n[3.12, 8.17],  -> like\n[1.87, 10.95]] -> dogs\nThis tensor has the shape (1, 3, 2). Does the length of the second axis (3 in this case) always equal the length of the input vector and therefore represent each individual word in the sequence or do I have a fundamental misconception of how the tensorflow embeddings work?\nTo clarify: say I had a much longer sentence with 600 words, would each word after embedding be remembered in their original order and be represented by a vector of whatever size was chosen for the embedding dimension (we'll say 15), thus making the shape of the embedded tensor (batch_size, 600, 15)?\nNote: these are just random numbers and don't represent anything in particular.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":85,"Q_Id":53875910,"Users Score":1,"Answer":"Yes and yes. So, if you have \"I\" [4.55, 6.78], \"like\" [3.12, 8.17], and \"dogs\" [1.87, 10.95], each embedded representation roughly equates directly to each word, and thus the order isn't lost when the embedding is done. And yes, the shape would be (batch_size, 600, 15) for batches of 600-word-sentences and embedding dimension 15. I think the question you're indirectly asking is something like \"Does each word directly correlate to a single embedding vector of length embedding_dimension?\" aka \"Does 'I' directly correlate to [4.55, 6.78] independent of the other words\/embedding vectors?\" For the most part, the answer is yes.\nFor what it's worth, it's been useful to think of it like languages. Doing a hash representation (excluding the duplicate values) or a categorical column with a unique value for each word is somewhat akin to how classic Chinese is, with a unique character for every word. Whereas embedded representations are more akin to the English language, with a \"word\" being a fixed number (embedding dimension) of letters (floats). The advantage is similar to how we gain advantages in the English language. For example \"dog\" vs \"dogs\" has 3 similar characters because they are very related concepts. Similarly, you can take advantage of embedding by representing \"dog\" as [1.23 4.56 7.89 1.12] and \"dogs\" as [1.23 4.56 7.89 9.87] or some such.\nRandom but I hope this helped. Good luck~~ =)","Q_Score":2,"Tags":"python,tensorflow","A_Id":53876998,"CreationDate":"2018-12-20T20:55:00.000","Title":"Word Embedding Interpretation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to convert one of my python projects into executables or some application for windows such that they will operate without going into python interface and running it from there. A quick search revealed the existence of pyinstaller and I used it. When I read it's working at its official site the following statement was there: \"The PyInstaller bootloader is a binary executable program for the active platform (Windows, Linux, Mac OS X, etc.). When the user launches your program, it is the bootloader that runs. The bootloader creates a temporary Python environment such that the Python interpreter will find all imported modules and libraries in the myscript folder.\" \nNow what I want to know is if the resulting .exe file is used on some other system is it necessary to install pyinstaller so that bootloader can be activated? Also is it necessary to have all the required python modules and libraries so that bootloader can create a temporary environment? Can we make changes to the given interface? And what other ways are there to change .py files to .exe?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":118,"Q_Id":53875970,"Users Score":1,"Answer":"Pyinstaller will compile the Python file and all necessary libraries\/modules into the exe file. You can then run it on another computer without the need to install any other programms. \nWhen the user launches your program, it is the bootloader that runs. The bootloader creates a temporary Python environment such that the Python interpreter will find all imported modules and libraries in the myscript folder.\nWhat this means is that when you run the executable, a command style window will start, in which the python code will run. This window will also show all error messages, print statements, etc.","Q_Score":0,"Tags":"python,exe,pyinstaller,software-design","A_Id":53876040,"CreationDate":"2018-12-20T21:00:00.000","Title":"Working process of converting python programs to executables in windows using pyinstaller","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In a python script I load a dataset into a environment variable which uses up almost all system memory. \nLets say I did something with that data and I am ready to dismiss it and load another dataset of similar size. \nNow because of Pythons internal garbage collector and references system to a variable, it is not trivial to remove this variable from the environment and thus release the memory to be able to load a new variable. \nWhat is the best way of doing this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":53876137,"Users Score":0,"Answer":"You can remove an environment variable foo using either os.unsetenv('foo') (if your operating system supports it) or del os.environ['foo'], but the memory formerly used by foo can only be used for other environment variables. The environment is a separate area of memory from the Python heap, and is not subject to garbage collection.\nos.environ is just a mapping of the environment (which is an array of null-terminated strings of the form <name>=<value>, where <name> is a string containing any character except = or the null character, and <value> can be any character except the null character). Using del ensures that both the environment and os.environ are updated; using unsetenv directly only affects the environment. As such, del os.environ['foo'] is preferred.\nYou should find a different way to pass data to your child process, and keep your environment small.","Q_Score":0,"Tags":"python","A_Id":53876401,"CreationDate":"2018-12-20T21:14:00.000","Title":"Is it possible to remove one variable from memory in Python without closing the session?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to develop a trend following strategy via back-testing a universe of stocks; lets just say all NYSE or S&P500 equities. I am asking this question today because I am unsure how to handle the storage\/organization of the massive amounts of historical price data. \nAfter multiple hours of research I am here, asking for your experience and awareness. I would be extremely grateful for any information\/awareness you can share on this topic\n\nPersonal Experience background:\n-I know how to code. Was a Electrical Engineering major, not a CS major.\n-I know how to pull in stock data for individual tickers into excel. \nFamiliar with using filtering and custom studies on ThinkOrSwim.\nApplied Context: \nFrom 1995 to today lets evaluate the best performing equities on a relative strength\/momentum basis. We will look to compare many technical characteristics to develop a strategy. The key to this is having data for a universe of stocks that we can run backtests on using python, C#, R, or any other coding language. We can then determine possible strategies by assesing the returns, the omega ratio, median excess returns, and Jensen's alpha (measured weekly) of entries and exits that are technical driven. \n\nHere's where I am having trouble figuring out what the next step is:\n-Loading data for all S&P500 companies into a single excel workbook is just not gonna work. Its too much data for excel to handle I feel like. Each ticker is going to have multiple MB of price data. \n-What is the best way to get and then store the price data for each ticker in the universe? Are we looking at something like SQL or Microsoft access here? I dont know; I dont have enough awareness on the subject of handling lots of data like this. What are you thoughts? \n\nI have used ToS to filter stocks based off of true\/false parameters over a period of time in the past; however the capabilities of ToS are limited. \nI would like a more flexible backtesting engine like code written in python or C#. Not sure if Rscript is of any use. - Maybe, there are libraries out there that I do not have awareness of that would make this all possible? If there are let me know.\nI am aware that Quantopia and other web based Quant platforms are around. Are these my best bets for backtesting? Any thoughts on them? \n\nAm I making this too complicated? \nBacktesting a strategy on a single equity or several equities isnt a problem in excel, ToS, or even Tradingview. But with lots of data Im not sure what the best option is for storing that data and then using a python script or something to perform the back test. \n\nRandom Final thought:-Ultimately would like to explore some AI assistance with optimizing strategies that were created based off parameters. I know this is a thing but not sure where to learn more about this. If you do please let me know.\n\nThank you guys. I hope this wasn't too much. If you can share any knowledge to increase my awareness on the topic I would really appreciate it.\nTwitter:@b_gumm","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":603,"Q_Id":53878551,"Users Score":0,"Answer":"The amout of data is too much for EXCEL or CALC. Even if you want to screen only 500 Stocks from S&P 500, you will get 2,2 Millions of rows (approx. 220 days\/year * 20 years * 500 stocks). For this amount of data, you should use a SQL Database like MySQL. It is performant enough to handle this amount of data. But you have to find a way for updating. If you get the complete time series daily and store it into your database, this process can take approx. 1 hour. You could also use delta downloads but be aware of corporate actions (e.g. splits). \nI don't know Quantopia, but I know a similar backtesting service where I have created a python backtesting script last year. The outcome was quite different to what I have expected. The research result was that the backtesting service was calculating wrong results because of wrong data. So be cautious about the results.","Q_Score":0,"Tags":"python,excel,stocks,universe,back-testing","A_Id":53965459,"CreationDate":"2018-12-21T02:43:00.000","Title":"Backtesting a Universe of Stocks","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 list of lists and each list has the following items:\n\nsite, count, time\nsample data: site1, 15, 20\n\nI'm trying to figure out the best way to approach this. I want to add up the count and time for each site.\nI thought converting it to a dictionary when I iterate through each list, but I'm not sure what that gives me.\n\nfor site, count, time in lists:\n   #create a dictionary, then what?\n\nThe end result, I'd like either a list or dictionary (some kind of data structure I can use) with the count and time for each site added up into a \"total\" list for each sites.\nEx: \nsite, total_count, total_time\n\nsample data:\nsite1, 50, 100 #all data for site1 added up\nsite2, 40, 300 #all data for site2 added up\n\nNot looking for a coded answer, just the best way to get this done and a point in the right direction.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":53879493,"Users Score":0,"Answer":"Here is a hacky approach (inspired by electric engineering): use a Counter whose values are complex numbers; the real part is time, imaginary part is count. ;-)","Q_Score":2,"Tags":"python","A_Id":53879919,"CreationDate":"2018-12-21T05:11:00.000","Title":"How to add up values in list based on a certain value in the list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on socket programming in python. I am a bit confused with the concept of s.listen(5) and multithreading.\nAs I know, s.listen(5) is used so that the server can listen upto 5 clients.\nAnd multithreading is also used so that server can get connected to many clients.\nPlease explain me in which condition we do use multithreading?\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1236,"Q_Id":53880028,"Users Score":0,"Answer":"As I know, s.listen(5) is used so that the server can listen upto 5 clients.\n\nNo. s.listen(5) declares a backlog of size 5. Than means that the listening socket will let 5 connection requests in pending stated before they are accepted. Each time a connection request is accepted it is no longer in the pending backlog. So there is no limit (other than the server resources) to the number of accepted connections.\nA common use of multithreading is to start a new thread after a connection has been accepted to process that connection. An alternative is to use select on a single thread to process all the connections in the same thread. It used to be the rule before multithreading became common, but it can lead to more complex programs","Q_Score":0,"Tags":"python-3.x,multithreading,sockets","A_Id":53887480,"CreationDate":"2018-12-21T06:15:00.000","Title":"server.listen(5) vs multithreading in socket programming","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The height is only two lines after running a file when it is focused. A white rectangle is below and next the console window is below it. When being lost focus , it is covered partial by the console window. How can I get the editor to be bigger?\nThe account I have is free account :(\nI access the page on smartphone","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":24,"Q_Id":53881052,"Users Score":0,"Answer":"PythonAnywhere doesn't really work that well on smartphones right now -- only on desktop computers and iPads.","Q_Score":0,"Tags":"pythonanywhere","A_Id":53905664,"CreationDate":"2018-12-21T07:54:00.000","Title":"File editor is too small at files in pythonanywhere","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a program which generates text files in every some seconds and within few days, the file number reaches to thousands of hundreds. I dont want to merge them into a single files because then file size reaches to over 50 Gb. But What I want is to divide and merge those smaller files into some number of files. \nFor example, I have 10 files and I would like to merge first 5 files to \nFileA.txt, then 3 files to FileB.txt and rest two files to FileC.txt.\nIs this possible to achieve in Python without copying and pasting files to folder and then merge?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":42,"Q_Id":53881415,"Users Score":1,"Answer":"It is certainly possible simply by opening each file sequentially and appending its contents to an output file, creating a new output file whenever you deem is necessary, and deleting the input files after they have been read. You should be able to do this easily with the Python standard library, though there could be packages that make the process easier that I do not know about.","Q_Score":0,"Tags":"python","A_Id":53881498,"CreationDate":"2018-12-21T08:27:00.000","Title":"Merging multiple files into some number of files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I've trained and saved 6 different networks where all of the values for hidden layer counts, neuron counts, and learn rates differ.\nFor example:\n\n1 with 8 hidden layers with 16 neurons in each trained at .1 learn rate.\n1 with 4 hidden layers with 4 neurons in each trained at .01 learn rate.\n1 with 4 hidden layers with 4 neurons in each trained at .03 learn rate.\n1 with 4 hidden layers with 8 neurons in each trained at .01 learn rate.\n1 with 4 hidden layers with 8 neurons in each trained at .001 learn rate.\n1 with 6 hidden layers with 4 neurons in each trained at .01 learn rate.\n\nHow could I create a new network where each of these saved networks acts basically as a neuron? While training this combined network, I don't want to affect the saved network weights and biases, but rather would like to essentially determine which one is more accurate for a given input.\nI've achieved this in practice by loading each network, running the data through each network, and then storing all of the outputs which then later feed into the new network, but I feel like there must be a simpler and most importantly, a faster way of doing this.\nAn example might be two networks: image detection at night and image detection during the day. Each trained and saved separately. I would want another network which essentially takes an image and says \"oh we're somewhere in the middle here so let's use 50\/50, or oh it's closer to night, but not night completely, use 90% night data and 10% day.\" So I would want to feed loads of images where it tries each model, but then weights out how valued the data was based on night vs day to create a network which works for either night or day.\nAny help highly appreciated. In reality the network I'm shooting for is far bigger and more complicated, but I'm looking for a strategy.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":53882317,"Users Score":1,"Answer":"I am not sure if I got your point correctly, but Block Based Neural Networks might be what you are searching for. In BBNN each node can be a neural network and w.r.t what you describe one layer BBNN is what you need.","Q_Score":0,"Tags":"python,python-3.x,tensorflow","A_Id":53882507,"CreationDate":"2018-12-21T09:36:00.000","Title":"How to create a tensorflow network of two saved tensorflow networks?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We need a cloud service to run automated tests written in Python on top of Behave BDD \/ Appium environment.\n1 - What are some good options in the market for cloud automated tests and reporting?\n2 - We used App Center with Xamarin.UITests before but I believe they support only Java Appium clients, is that correct?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":373,"Q_Id":53883778,"Users Score":2,"Answer":"We use Browserstack for Python+Appium automation, you can test on real devices or on emulators\/simulators.\nCurrently we are on App Automate - 1 parallel test (1 user) plan. This is testing on real Android and iOS devices (either manual or automated) and there is no limit on the number of testing minutes per month. It seems like a good option for now. \nSetup is pretty easy, you need to upload .apk or .ipa file to their server with REST command and response will be used for 'app' capability. For starting test you only need to provide username and access key, you use this as server URL when starting Webdriver.\nThey have around 40 Android devices and most of them are either Samsung or Google devices, for iOS they have all devices.\nReporting could be a bit better, although you can see text and Appium logs along with videos of recorded sessions, you will see each session on it's own in the dashboard, there is currently no option to see how whole test suite performed, so we use nose-html-reporting for test suite reports.\nYou can test against your dev\/internal environments, just need to download their binary file and run it with your access key and you can start testing against local env. \nCS replies pretty quick on queries.\nHope that helps, if you've any questions about it let me know.\nP.s. I haven't tried other cloud options like Sauce labs or Perfecto so can't say much about it.","Q_Score":2,"Tags":"appium,python-appium","A_Id":54037020,"CreationDate":"2018-12-21T11:11:00.000","Title":"Cloud testing services for Appium \/ 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 working on a tool for my company created to get data from our Facebook publications. It has not been working for a while, so I have to get all the historical data from June to November 2018.    \nMy two scripts (one that get title and type of publication, and the other that get the number of link clicks) are working well to get data from last pushes, but when I try to add a date range in my Graph API request, I have some issues:\n\nthe regular query is [page_id]\/posts?fields=id,created_time,link,type,name\nthe query for historical data is [page_id]\/posts?fields=id,created_time,link,type,name,since=1529280000&until=1529712000, as the API is supposed to work with unixtime\nI get perfect results for regular use, but the results for historical data only shows video publications in Graph API Explorer, with a debug message saying:\n\n\nThe since field does not exist on the PagePost object.\n\nSame for \"until\" field when not using \"since\". I tried to replace \"posts\/\" with \"feed\/\" but it returned the exact same result...\nDo you have any idea of how to get all the publications from a Page I own on a certain date range?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":356,"Q_Id":53883849,"Users Score":0,"Answer":"So it seems that it is not possible to request this kind of data unfortunately, third party services must be used...","Q_Score":0,"Tags":"python,facebook,facebook-graph-api,unix-timestamp","A_Id":53889179,"CreationDate":"2018-12-21T11:15:00.000","Title":"Date Range for Facebook Graph API request on posts level","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am having application on EC2 that requires to send an email.\nI am using Django with AWS, and module of 'django-ses-gateway' to send an email.\nEC2 is configured, hence on ~\/.aws folder I am having appropriate credentials file with region as 'default'\nHowever, whenever application tries to send an email by default it is trying to use  \"EU-WEST-1\" region which is not expected one, as it should use \"US-EAST-1\".\nBecause of wrong region, application fails.\nPS:\nI also verified that \"settings.py\" file is not overwriting region,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":153,"Q_Id":53884062,"Users Score":0,"Answer":"Finally, got the solution.\n'django_ses_gateway' (version 0.1.1) module of python has a bug.\nBy default, it selects EU-WEST-1 region, \nhence,  'sending_mail.py' file requires correction to not to hard-cord a region of EU.\nThe location of installed package can be found using 'pip3 show django-ses-gateway' command","Q_Score":0,"Tags":"django,python-3.x,amazon-web-services,amazon-ses","A_Id":54110882,"CreationDate":"2018-12-21T11:31:00.000","Title":"Django (django-ses-gateway) gives default region as EU-WEST-1 instead of US-EAST-1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am collaborating on a Python project, using PyCharm. It is space indented and I have been using only tab indentation so far. However, after switching to space indentation I am no longer able to navigate efficiently. To navigate one indentation level back, I need to press left arrow four times now, which I find very frustrating. Note that I mean navigation through an indentation level at a time (4 spaces) and not going to the beginning of the line.\nMy questions are:\n\nCan I set up navigation with space indented file in PyCharm to behave like it does with tabs (single arrow tap for one indentation level, single backspace for one indent deleted)?\nIf not, is there a shortcut or a way to set up one to navigate to a previous indentation level?\nAre you aware of any other python IDEs that can handle space indentation in the way described?\n\nI hope you can help.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":53887383,"Users Score":0,"Answer":"For changing the key of indention I think you could change that from File -> Setting -> Keymap then search for indent selection.","Q_Score":2,"Tags":"python,pycharm,indentation","A_Id":53887458,"CreationDate":"2018-12-21T15:35:00.000","Title":"Achieving tab-like navigation with spaces indentation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am collaborating on a Python project, using PyCharm. It is space indented and I have been using only tab indentation so far. However, after switching to space indentation I am no longer able to navigate efficiently. To navigate one indentation level back, I need to press left arrow four times now, which I find very frustrating. Note that I mean navigation through an indentation level at a time (4 spaces) and not going to the beginning of the line.\nMy questions are:\n\nCan I set up navigation with space indented file in PyCharm to behave like it does with tabs (single arrow tap for one indentation level, single backspace for one indent deleted)?\nIf not, is there a shortcut or a way to set up one to navigate to a previous indentation level?\nAre you aware of any other python IDEs that can handle space indentation in the way described?\n\nI hope you can help.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":53887383,"Users Score":0,"Answer":"To toggle between tabs and spaces:\n\nOn the main menu, choose Edit | Convert Indents , and then choose To Spaces or To Tabs respectively.\n\nWhen you clone, download or in any other way start working on a project, you can convert spaces to tabs and stick with yours navigation. When you are done, you can convert tabs back to spaces so you don't break yours team coding habits.","Q_Score":2,"Tags":"python,pycharm,indentation","A_Id":53897461,"CreationDate":"2018-12-21T15:35:00.000","Title":"Achieving tab-like navigation with spaces indentation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"import random\nimport asyncio\nimport json\nimport aiohttp\nimport sys\nimport urllib\nfrom lxml.html.soupparser import parse\nfrom aiohttp import ClientSession\nfrom threading import Thread\n\ndef ttest():\n    async def fetch(url, session):\n        headers = {\n            'Host': 'example.com'\n        }\n        cookies2 = {\n            'test': 'test'\n        }\n\n        data = '{\"test\":\"test\"}'\n        async with session.post(url, data=data, headers=headers, cookies=cookies2) as response:\n            return await response.read()\n    async def bound_fetch(sem, url, session):\n        async with sem:\n            html = await fetch(url, session)\n            print(html)\n\n\n    async def run(r):\n        url = \"https:\/\/test.com\"\n        tasks = []\n        sem = asyncio.Semaphore(1000)\n        async with aiohttp.ClientSession() as session:\n            for i in range(r):\n                task = asyncio.ensure_future(bound_fetch(sem, url, session))\n                tasks.append(task)\n            responses = asyncio.gather(*tasks)\n            await responses\n\n    number = 1\n    loop = asyncio.get_event_loop()\n    future = asyncio.ensure_future(run(number))\n    loop.run_until_complete(future)\n\nttest()\n\nThis is the error: TypeError: _request() got an unexpected keyword argument 'cookies'\nI want use cookies like you see in the code, but i can not, can anyone help me?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4119,"Q_Id":53892470,"Users Score":1,"Answer":"The feature was added on aiohttp GitHub master but not released yet.\nPlease either install aiohttp from GitHub or wait for a while for aiohttp 3.5 release.\nI hope to publish it in a few days.","Q_Score":3,"Tags":"python-3.x,python-asyncio,aiohttp","A_Id":53894565,"CreationDate":"2018-12-22T01:54:00.000","Title":"TypeError: _request() got an unexpected keyword argument 'cookies' (aiohttp)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem in installing the mysql-python package for flask.\nI had tried using the command:\npip install mysql-python\nBut i did'nt workout for me\nFailed building wheel for mysql-python\n  Running setup.py clean for mysql-python\nFailed to build mysql-python\nInstalling collected packages: mysql-python\n  Running setup.py install for mysql-python ... error\n    Complete output from command c:\\users\\yuvan\\appdata\\local\\programs\\python\\python37-32\\python.exe -u -c \"import setuptools, tokenize;file='C:\\Users\\Yuvan\\AppData\\Local\\Temp\\\n\\pip-install-c23xj5e_\\mysql-python\\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, file, 'exec'))\" install -\n-record C:\\Users\\Yuvan\\AppData\\Local\\Temp\\pip-record-7h3c9v2a\\install-record.txt --single-version-externally-managed --compile:\n    running install\n    running build\n    running build_py\n    creating build\n    creating build\\lib.win32-3.7\n    copying _mysql_exceptions.py -> build\\lib.win32-3.7\n    creating build\\lib.win32-3.7\\MySQLdb\n    copying MySQLdb__init__.py -> build\\lib.win32-3.7\\MySQLdb\n    copying MySQLdb\\converters.py -> build\\lib.win32-3.7\\MySQLdb\n    copying MySQLdb\\connections.py -> build\\lib.win32-3.7\\MySQLdb\n    copying MySQLdb\\cursors.py -> build\\lib.win32-3.7\\MySQLdb\n    copying MySQLdb\\release.py -> build\\lib.win32-3.7\\MySQLdb\n    copying MySQLdb\\times.py -> build\\lib.win32-3.7\\MySQLdb\n    creating build\\lib.win32-3.7\\MySQLdb\\constants\nGit\nGitHub\nInitialize E:\\chakra with a Git repository\nCreate repository\nI  expect that this package would be installed successfully","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1288,"Q_Id":53893304,"Users Score":1,"Answer":"You can install mysqlclient for python using the following command :\n\npip install mysqlclient\n\nAnd If you are looking for particular version :\n\npip install mysqlclient==<verison> (e.g. version -> 1.3.6)","Q_Score":1,"Tags":"mysql,python-3.x,flask","A_Id":56610692,"CreationDate":"2018-12-22T05:30:00.000","Title":"How to fix the error of Failed building wheel for mysqlclient in flask","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to access a module which is installed in a virtual environment, but the problem I've run into is that I can't activate my environment from the command line (Windows cmd).\nIs there a command to activate an environment from the command line?\nIt is for a Python project. So if you can find a solution to open the Anaconda command line and execute commands there, it would be also great.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30128,"Q_Id":53895089,"Users Score":0,"Answer":"type conda in cmd\nYou should be in the conda environment.\nIf it isn't, you have to add Anaconda to your environment path. You can try where conda to see where your installation is at.","Q_Score":3,"Tags":"python,python-3.x,cmd,subprocess,anaconda","A_Id":53895110,"CreationDate":"2018-12-22T11:07:00.000","Title":"How to activate an Anaconda environment from the command line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've downloaded a lots of packages into global environment (lets say so). Now, I want to create a new virtual environment and move some of the packages to that environment. How would I do that ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3104,"Q_Id":53897554,"Users Score":2,"Answer":"While you could copy files\/directories from the site-packages directory of your global installation into the site-packages of your virtual env, you may experience problems (missing files, binary mismatch, or others). Don't do this if you're new to python packaging mechanisms.\nI would advise that you run pip freeze from your global installation to get a list of what you installed, and then store that output as a requirements.txt with your source, and put it under source management. Then run pip install -r requirements.txt after activating your virtualenv, and you'll replicate the dependencies (with the same versions) into your virtualenv.","Q_Score":5,"Tags":"python,virtual-environment","A_Id":53897684,"CreationDate":"2018-12-22T16:49:00.000","Title":"How to move installed packages to a newly created virtual environment ?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As a legacy from the previous version of our system, I have around 1 TB of old video files on AWS S3 bucket. Now we decided to migrate to AWS Media Services and all those files should be moved to MediaStore for the access unification.\nQ: Is there any way to move the data programmatically from S3 to MediaStore directly?\nAfter reading AWS API docs for these services, the best solution I've found is to run a custom Python script on an intermediate EC2 instance and pass the data through it.\nAlso, I have an assumption, based on pricing, data organization and some pieces in docs, that MediaStore built on top of S3. That's why I hope to find a more native way to move the data between them.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":376,"Q_Id":53897584,"Users Score":0,"Answer":"I've clarified this with AWS support. There is no way to transfer files directly, although, it's a popular question and, probably, will be implemented.\nNow I'm doing this with an intermediate EC2 server, a speed of internal AWS connections between this, S3 and MediaStore is quite good. So I would recommend this way, at least, for now.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,amazon-ec2,aws-mediastore","A_Id":53904676,"CreationDate":"2018-12-22T16:52:00.000","Title":"Move objects from AWS S3 to MediaStore","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I am running a Python micro-service in a dockerized or kubernetes container it works just fine. But with Istio service mesh, it is not working.\nI have added ServiceEntry for two of my outbound external http apis. It seems I can access the url content form inside the container using curl command which is inside service mesh. So, I think the service entries are fine and working. \nBut when I try from the micro-service which uses xml.sax parser in Python, it gives me the upstream connect error or disconnect\/reset before headers though the same application works fine without Istio.\nI think it is something related to Istio or Envoy or Python. \nUpdate: I did inject the Istio-proxy side-car. I have also added ServiceEntry for external MySQL database and mysql is connected from the micro-service.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1036,"Q_Id":53898206,"Users Score":2,"Answer":"I have found the reason for this not working. My Python service is using xml.sax parser library to parse xml form the internet, which is using the legacy urllib package which initiate http\/1.0 request. \nEnvoy doesn't support http\/1.0 protocol version. Hence, it is not working. I made the workaround by setting global.proxy.includeIPRanges=\"10.x.0.1\/16\" for Istio using helm. This actually bypass the entire envoy proxy for all outgoing connections outside the given ip ranges.\nBut I would prefer not to globally bypass Istio.","Q_Score":0,"Tags":"python,kubernetes,istio,envoyproxy","A_Id":53969796,"CreationDate":"2018-12-22T18:17:00.000","Title":"Istio egress gives \"upstream connect error or disconnect\/reset before headers\" errors from python micro-service","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When executing \"Run Selection\/Line in Python Terminal\" command in VSCode, terminal's current working directory is the workspace root directory. How can we set current directory of terminal to the current file's directory when running the selection\/line?","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":23066,"Q_Id":53900141,"Users Score":25,"Answer":"In \"User Settings\", use the search bar to look for \"python.terminal.executeInFileDir\" and set (=) its value to \"true\" instead of \"false\".","Q_Score":27,"Tags":"python,visual-studio-code,vscode-settings","A_Id":56091981,"CreationDate":"2018-12-22T23:47:00.000","Title":"How to run python interactive in current file's directory in Visual Studio Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When executing \"Run Selection\/Line in Python Terminal\" command in VSCode, terminal's current working directory is the workspace root directory. How can we set current directory of terminal to the current file's directory when running the selection\/line?","AnswerCount":7,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":23066,"Q_Id":53900141,"Users Score":1,"Answer":"you need to go to file\/preferences\/user settings and click the \"{}\" icon at the top right of the window. After that, put this setting in: \"terminal.integrated.cwd\": \"C:\\\\Users\\\\myUser\\\\\", and after that wherever your terminal's directory happens to be. This answer is not the most inaccurate cause im still a noob myself at using vscode so if someone more experienced with it could reply to this thread it would be great.","Q_Score":27,"Tags":"python,visual-studio-code,vscode-settings","A_Id":53900210,"CreationDate":"2018-12-22T23:47:00.000","Title":"How to run python interactive in current file's directory in Visual Studio Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am installing pymongo in windows in python 2.7.\nbut I get this error:\n\nImportError: No module named parse\n\nWhat should I do?\nI do not have python 3 installed on my machine. \nI installed pymongo before and it was working but suddenly when again I run my program it gave me this error.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2942,"Q_Id":53900440,"Users Score":1,"Answer":"Apparently your are running Python 3 modules with Python 2.7.\nPython 2.7 imports parse like this:\nfrom urlparse import urlparse\nWhile Python 3 uses: \nfrom urllib.parse import urlparse\nSo this results in an ImportError, because the parse your Python 3 Pymongo is trying to import, does not exist in the Python 2.7 you are using.","Q_Score":0,"Tags":"python,pymongo","A_Id":53900524,"CreationDate":"2018-12-23T00:59:00.000","Title":"ImportError: No module named parse in installing pymongo, python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am installing pymongo in windows in python 2.7.\nbut I get this error:\n\nImportError: No module named parse\n\nWhat should I do?\nI do not have python 3 installed on my machine. \nI installed pymongo before and it was working but suddenly when again I run my program it gave me this error.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2942,"Q_Id":53900440,"Users Score":0,"Answer":"My problem was that I had my script named urllib.py and it intefered with default files. I renamed it and the problem solved.","Q_Score":0,"Tags":"python,pymongo","A_Id":53900876,"CreationDate":"2018-12-23T00:59:00.000","Title":"ImportError: No module named parse in installing pymongo, python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m extracting the SSL certificate from a website using the socket + ssl library in python. My understanding that it connects using the preferred method used by the server. \nUsing this method I\u2019m able to identify what version of SSL is used to connect, but I also need to identify whether the website supports SSL v3, in the case when the default connection is TLS. \nIs there a way to identify this information without manually testing multiple SSL connections?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":53900577,"Users Score":0,"Answer":"I don't think sites advertise what they support. Rather, it's negotiated between client and server.\nYou could use the excellent server tester at www.ssllabs.com. It will try lots of configurations and report what the server in question supports. (Hopefully the site doesn't support SSL v3!)","Q_Score":0,"Tags":"python,ssl,openssl,ssl-certificate","A_Id":53900613,"CreationDate":"2018-12-23T01:40:00.000","Title":"Testing SSL v3 Support in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a script for automatizing some tasks at my job. However, I need to make my script portable and try it on different screen resolution. \nSo far right now I've tried to multiply my coordinate with the ratio between the old and new resolutions, but this doesn't work properly.\nDo you know how I can convert my X, Y coordinates for mouse's clicks make it works on different resolution?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1023,"Q_Id":53900943,"Users Score":1,"Answer":"Quick question: Are you trying to get it to click on certain buttons? (i.e. buttons that look the same on every computer you plug it into) And by portable, do you mean on a thumb drive (usb)?\nYou may be able to take an image of the button (i.e. cropping a screenshot), pass it on to the opencv module, one of the modules has an Image within Image searching ability. you can pass that image along with a screenshot (using pyautogui.screenshot()) and it will return the (x,y) coordinates of the button, pass that on to pyautogui.moveto(x,y) and pyautogui.click(), it might be able to work. you might have to describe the action you are trying to get Pyautogui to do a little better.","Q_Score":2,"Tags":"python-3.x,resolution,pyautogui","A_Id":54048053,"CreationDate":"2018-12-23T03:14:00.000","Title":"Pyautogui mouse click on different resolution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am setting up module in odoo where need to mainain orignal data of one model (Registrations) as logs into other model (RegistrationLogs).\nI want to insert Registration model's data into RegistrationLogs via wizard call and orignal model's data need to be updated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":511,"Q_Id":53901476,"Users Score":0,"Answer":"you can add many2one field on registration.logs model to comodel registraion, on create function of model registration, hit create function of registration.logs too. to update data, setting up fields on registration logs model to computed or related will be needed.","Q_Score":0,"Tags":"python,odoo","A_Id":53918436,"CreationDate":"2018-12-23T05:41:00.000","Title":"How to insert one model's data into another model in odoo 10?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am researching lot of in kivy for payment gateway and wallet like concept and how its feasible, secure and implementation level for android and ios application. Anyone knows its production level implementation please let me know","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":801,"Q_Id":53901798,"Users Score":1,"Answer":"You can integrate with any Payment Gateway using documentation given on their Api's documentation page.Google pay and many other have their documentation on How to implement it on any platform (Android,Ios,Web). You can check https:\/\/developers.google.com\/pay\/india\/api\/","Q_Score":4,"Tags":"python,python-3.x,kivy,kivy-language","A_Id":54264649,"CreationDate":"2018-12-23T06:52:00.000","Title":"How to implement concept like payment gateway and wallet in kivy android and ios","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got an array of 4 images, each image lets say is NxM (all images share this same size)\n(I'm implementing a Harris Corner detector by the way.)\nNow I made a matrix M = ([Ix^2, Ixy],[Ixy, Iy^2]).reshape(2,2)\nand now I'd like to compute my response. \nwhich is usually Det(RM) - k*(trace(RM)**2) \nRM being a 2x2 Matrix each point in this matrix is derived from the same coordinate location for each image in M.\nHow can I slice M to create RM? \nIn other words how can I slice the Matrix M to create a smaller matrix 2x2 RM for every pixel in the NxM images?\nFor example the first RM matrix should be a 2x2 matrix taking the 0,0 coordinate from each image in M.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":53902843,"Users Score":0,"Answer":"It's not really clear what RM and M are based on your description.\nIs M the ndarray containing all 4 images, and RM the 2x2 array for a given pixel containing the data from the 4 images? \nYou can put the 4 images into the same ndarray so it has shape (4,N,M) and then reshape slices.\nFor example, to get the (0,0) entry you would do A[:,0,0] to get the 4 pixels, and then reshape it to get a 2x2 array.","Q_Score":0,"Tags":"python,numpy,numpy-slicing","A_Id":53905344,"CreationDate":"2018-12-23T10:29:00.000","Title":"Slicing Array of four matrices","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I am trying to convert a .ui file to a .py file in PyCharm. Whenever I type in the pyuic5 command into the terminal, it returns with \"bash: pyuic5: command not found\".\nI have tried to cd to my project folder, but am still having the same problem. I have already installed the PyQt5 library in PyCharm, so that shouldn't be the problem.\nAny suggestions or ideas would be much appreciated!\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5849,"Q_Id":53905837,"Users Score":0,"Answer":"Have you installed pyqt5-tools module by pip command?\nIf you have installed this package, you should find pyuic5.exe in your Python36\/Scripts folder(for Windows OS).\nSo please check it first.","Q_Score":0,"Tags":"python,pyqt","A_Id":53908999,"CreationDate":"2018-12-23T17:48:00.000","Title":"How to fix \"pyuic5: command not found\" in terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I get all class, object, function names in current namescope in Python? How can I differentiate between them(e.g. get only class names)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":53906305,"Users Score":0,"Answer":"Use help() or dir().\nYou can dump the output into a list of strings and read from there too to differentiate what you require","Q_Score":1,"Tags":"python","A_Id":53906326,"CreationDate":"2018-12-23T18:52:00.000","Title":"How to get all class, variables, func names in current namescope?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am executing a python script which actually analyze the system related metrics based on  the threshold defined in the threshold_config.ini file.\nThe program can analyze data for metrics like disk, memory, swap and cpu.\nFor each metric i have two threshold value, one is for warning and another is for critical. \nThe script analysis and produce the report in text file saying Critical or warning for each of the systems.\nI want to display this in jenkins, like a junit  result, did  anyone have any idea how to take custom reports and shows them in the  jenkins junit format. Also I need to mark the build stable or unstable based on the warn and critical values.\nPlease help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":121,"Q_Id":53906558,"Users Score":1,"Answer":"For the first bit (JUnit result format), you may want to translate results of comparison of your metrics against thresholds into a JUnit XML file, one per comparison. This requires low-level implementation, but you wouldn't be the first person doing that. If there is a better way to do that would depend on the exact format of results you've got.\nFor the second bit (passing\/failing the build), you could use popular Jenkins JUnit plugin which will detect all your JUnit XML files and mark the build accordingly.","Q_Score":1,"Tags":"python-3.x,jenkins,junit","A_Id":53906834,"CreationDate":"2018-12-23T19:25:00.000","Title":"How to show analysis result in jenkins and mark the build status","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When i try to install tkinter with the command pip install tkinter in windows 10 I get this  error:\n\nCould not find a version that satisfies the requirement tkinter(from versions: )\n  No matching distributions found for tkinter","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":30709,"Q_Id":53910070,"Users Score":3,"Answer":"use pip install tkintertable it also imports Tkinter","Q_Score":3,"Tags":"python,tkinter","A_Id":60260425,"CreationDate":"2018-12-24T06:46:00.000","Title":"how to install tkinter using pip in windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I having trouble running relplot function in colab notebook but it works fine in jupyter notebook.\nGetting the following error in colab\n\n\nAttributeError                            Traceback (most recent call\n  last)  in ()\n  ----> 1 sns.relplot(x=\"total_bill\", y=\"tip\", \n        2             col=\"time\", # Categorical variables that will determine the faceting of the grid.\n        3             hue=\"smoker\", # Grouping variable that will produce elements with different colors.\n        4             style=\"smoker\", # Grouping variable that will produce elements with different styles.\n        5             size=\"size\", # Grouping variable that will produce elements with different sizes.\nAttributeError: module 'seaborn' has no attribute 'relplot'","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":11284,"Q_Id":53910548,"Users Score":1,"Answer":"Change directory to where pip3.exe is located:\nfor me: cd C:\\Users\\sam\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts \nuse .\\\n.\\pip3 install seaborn==0.9.0","Q_Score":2,"Tags":"python,seaborn,google-colaboratory","A_Id":56282819,"CreationDate":"2018-12-24T07:37:00.000","Title":"module 'seaborn' has no attribute 'relplot'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to figure out for our software, where could Anaconda or Miniconda install itself on Windows platforms. I need this, to not bother the user by asking the location of they installation, if it is the default.\nSo far I found, that the C:\\Users\\username\\AnacondaX (C:\\Users\\username\\MinicondaX) is the default on my machine, if I choose install only for my user, or C:\\ProgramData\\AnacondaX (C:\\AppData\\MinicondaX). if I choose installation for all users. (X here can be either 2 or 3 - for python2 or python3).\nBut I'm not sure, that this applies for all Windows machines, or they could be other possible locations. So my question is: are there more possible default locations, where Conda (Anaconda\/Miniconda) could possibly install itself?\nThanks for the answers!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5873,"Q_Id":53911041,"Users Score":1,"Answer":"I just (Oct 23, 2020) installed miniconda3 on windows using winget install miniconda3 and it installed in C:\\Users\\<username>\\Miniconda3.","Q_Score":0,"Tags":"python,windows,anaconda,conda,miniconda","A_Id":64500593,"CreationDate":"2018-12-24T08:33:00.000","Title":"What are the default location for an anaconda \/ miniconda installations on Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to extract the text just after strong tag from html page given below? how can i do it using beautiful soup. It is causing me problem as it doesn't have any class or id so only way to select this tag is using text.\n{strong}Name:{\/strong} Sam smith{br}\nRequired result\nSam smith","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":77,"Q_Id":53914377,"Users Score":-1,"Answer":"Thanks for all your answers but i was able to do this by following:\nb_el = soup.find('strong',text='Name:')\nprint b_el.next_sibling\nThis works fine for me. This prints just next sibling how can i print next 2 sibling is there anyway ?","Q_Score":0,"Tags":"python,web-scraping,beautifulsoup","A_Id":53914744,"CreationDate":"2018-12-24T13:58:00.000","Title":"extracting text just after a particular tag using beautifulsoup?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to call a function from a python file that is located outside the django project directory from views.py. I have tried importing the python file but running the django server says \"no module named xxxx\".\nTree structure is given below.\n\n\n\u251c\u2500\u2500 auto_flash\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test.py\n\u2514\u2500\u2500 fireflash\n    \u251c\u2500\u2500 detection_reports\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 admin.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 admin.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 migrations\n    \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n    \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 models.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 models.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 __pycache__\n    \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.cpython-35.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 templates\n    \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 detection_reports\n    \u2502\u00a0\u00a0 \u2502\u00a0\u00a0     \u2514\u2500\u2500 home.html\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 tests.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 views.py\n    \u2502\u00a0\u00a0 \u2514\u2500\u2500 views.pyc\n    \u251c\u2500\u2500 fireflash\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 __pycache__\n    \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.cpython-35.pyc\n    \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 settings.cpython-35.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 settings.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 settings.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 ui_cgi.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 urls.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 urls.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 wsgi.py\n    \u2502\u00a0\u00a0 \u2514\u2500\u2500 wsgi.pyc\n    \u251c\u2500\u2500 __init__.py\n    \u2514\u2500\u2500 manage.py  \n\nProject name here is \"fireflash\" and there is an app in that project named \"detection_reports\". There is another directory named \"auto_flash\" that has same location as \"fireflash\". What I want to do is to import test.py file from \"auto_flash\" in detection_reports.views and call a function from views. Importing like this \"from auto_flash import test\" throws error \"no module named auto_flash\".","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2173,"Q_Id":53916918,"Users Score":0,"Answer":"I have tried all of the above mentioned solutions, but the cleaner solution was to append the path for auto_flash to syspath and the issue was resolved. Thanks to all of you for the efforts.","Q_Score":1,"Tags":"python,django,django-views","A_Id":53986048,"CreationDate":"2018-12-24T19:00:00.000","Title":"How to import python function from another file into django views","Data Science and Machine Learning":0,"Database and SQL":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 trying to call a function from a python file that is located outside the django project directory from views.py. I have tried importing the python file but running the django server says \"no module named xxxx\".\nTree structure is given below.\n\n\n\u251c\u2500\u2500 auto_flash\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test.py\n\u2514\u2500\u2500 fireflash\n    \u251c\u2500\u2500 detection_reports\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 admin.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 admin.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 migrations\n    \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n    \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 models.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 models.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 __pycache__\n    \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.cpython-35.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 templates\n    \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 detection_reports\n    \u2502\u00a0\u00a0 \u2502\u00a0\u00a0     \u2514\u2500\u2500 home.html\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 tests.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 views.py\n    \u2502\u00a0\u00a0 \u2514\u2500\u2500 views.pyc\n    \u251c\u2500\u2500 fireflash\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 __pycache__\n    \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.cpython-35.pyc\n    \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 settings.cpython-35.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 settings.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 settings.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 ui_cgi.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 urls.py\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 urls.pyc\n    \u2502\u00a0\u00a0 \u251c\u2500\u2500 wsgi.py\n    \u2502\u00a0\u00a0 \u2514\u2500\u2500 wsgi.pyc\n    \u251c\u2500\u2500 __init__.py\n    \u2514\u2500\u2500 manage.py  \n\nProject name here is \"fireflash\" and there is an app in that project named \"detection_reports\". There is another directory named \"auto_flash\" that has same location as \"fireflash\". What I want to do is to import test.py file from \"auto_flash\" in detection_reports.views and call a function from views. Importing like this \"from auto_flash import test\" throws error \"no module named auto_flash\".","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2173,"Q_Id":53916918,"Users Score":0,"Answer":"Move auto_flash to fireflash\nIn detection_reports add from auto_flash import test.py","Q_Score":1,"Tags":"python,django,django-views","A_Id":53935367,"CreationDate":"2018-12-24T19:00:00.000","Title":"How to import python function from another file into django views","Data Science and Machine Learning":0,"Database and SQL":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 server application that I wish to put onto my server. I have tried to run the python scripts on my server, I moved the file with sftp and I installed the dependancies with pip. No luck, it doesn't use my modules even after I install them. It says the module I installed isn't a thing, when when I run pip again it says it is already there. I read about standalone executables a little, but I only found documentation on windows ones. I know Linux cannot run exe files, but is there something similar. \nAnother thing might be my unfamiliarity with pip. I use the terminal in py charm which automatically puts my pip modules into files. When I do that on my ubuntu machines there is no file created in my directory. (Feels like a problem to me)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":158,"Q_Id":53918501,"Users Score":0,"Answer":"So I don't want to leave this open in case anyone else see this and needs help. I had forgotten to install my modules, so I did that, and then to run my two programs I just use screen now to host different terminals for each program. It isn't very hard.","Q_Score":0,"Tags":"python,linux,ubuntu,server,executable","A_Id":54282962,"CreationDate":"2018-12-25T00:14:00.000","Title":"Making a python standalone Linux executable on windows","Data Science and Machine Learning":0,"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 developed a Collab notebook in Python that intends to simulate keyboard keys' presses in order to play a game which it will monitor as a part of reinforcement learning. I have tried using several recommendations (like pyautogui, Quartz etc) but I am not even able to import these libraries. \nFor instance, when I installed pyautogui and Xlib and tried importing pyautogui, it gave KeyError: 'DISPLAY'. However, pyautogui works fine on my local machine when run from the terminal.\nSimilarly, after installing (!pip install pynput) pynput to Collab notebook, when I tried importing it, it showed DisplayNameError: Bad display name \"\", of which I have no clue.\nI even tried the getkey module, however from getkey import getkey, keys but to no luck.\nIs there any way to get this working? Also, can anybody please explain why is it that these modules work fine on my local hardware but not on Google Collab? Also, please suggest any alternative to these modules that can work fine on Collab?\nMany thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7040,"Q_Id":53919284,"Users Score":0,"Answer":"Try downloading the Keyboard module onto your computer. Then go to insert> snippets> upload from your computer. Hoped this helped :)","Q_Score":2,"Tags":"python,google-colaboratory","A_Id":62215178,"CreationDate":"2018-12-25T04:08:00.000","Title":"How to simulate python key presses in Google Collab notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating documents from web scraping in python and uploading them to Firestore.\nTo do so I'm adding them to a dictionary and uploading them from a for loop in python, one by one(ideally would be better to upload the collection at once, but that doesn't seem an option). I want to use batches, however they have the 500 limit per batch and I need to do more than 100,000 operations. The operations are merely set() operations and a couple of update()\nIs there a function to know the current size of the batch so I can reinitialize it?\nWhat is the best way to use batches for more than 500 operations in python?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1725,"Q_Id":53921109,"Users Score":3,"Answer":"The maximum number of operations in a Batch is 500. If you need more operations, you'll need multiple batches.\nThere is no API to determine the current number of operations in a Batch. If you need that, you will have to track it yourself.","Q_Score":3,"Tags":"python,firebase,google-cloud-firestore","A_Id":53921780,"CreationDate":"2018-12-25T09:39:00.000","Title":"How to batch more than 500 operations in python for firestore?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I just started with AWS and I want to train my own model with own dataset. I have my model as keras model with tensorflow backend in Python. I read some documentations, they say I need a Docker image to load my model. So, how do I convert keras model into Docker image. I searched through internet but found nothing that explained the process clearly. How to make docker image of keras model, how to load it to sagemaker. And also how to load my data from a h5 file into S3 bucket for training? Can anyone please help me in getting clear explanation?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2089,"Q_Id":53921454,"Users Score":0,"Answer":"You can convert your Keras model to a tf.estimator and train using the TensorFlow framework estimators in Sagemaker.\nThis conversion is pretty basic though, I reimplemented my models in TensorFlow using the tf.keras API which makes the model nearly identical and train with the Sagemaker TF estimator in script mode.\nMy initial approach using pure Keras models was based on bring-your-own-algo containers similar to the answer by Matthew Arthur.","Q_Score":0,"Tags":"python,amazon-web-services,tensorflow,keras,amazon-sagemaker","A_Id":54089983,"CreationDate":"2018-12-25T10:26:00.000","Title":"How to train your own model in AWS Sagemaker?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a quiz app where students can take tests. There is  ranking based on every test. It's implemented with simple lists (Every new score is inserted into the list and then sorted (index+1 is the rank)). \nBut I want to add another abstraction. ie. Suppose 1000 students took the test and my ranking was 890. But those 1000 students should automatically be divided into 10 groups ie. group 1 of ranking 1 to 99, group2 of ranking 100 to 199 and so on. So if my overall ranking is 890. I should be subscribed to group 9 with 90th rank in that group. \nHow should this be implemented?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":53922685,"Users Score":0,"Answer":"Just save the ranking score for every student. Calculate their group when you displaying them.","Q_Score":0,"Tags":"django,python-3.x,data-structures","A_Id":53925094,"CreationDate":"2018-12-25T13:11:00.000","Title":"What data structure to use for ranking system which divides itself in groups?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"if someone find my telegram chat ID (instead of my phone number or username), what can do with that?\nis it dangerous?!\nis it a big deal that someone can find my ID? should I worry about it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3297,"Q_Id":53924548,"Users Score":2,"Answer":"If someone with a (user)bot wants to send you a message, they can do that via the userID only. But only if they have \"seen\" you. Seeing you is considering their client to receive a message from you, be it in a private message or group.\nBots can only send you a message if you have started it in a private chat, otherwise they can only send you a message in a group they share with you.\nSo there is no real risk of people knowing your ID.","Q_Score":2,"Tags":"telegram,telegram-bot,python-telegram-bot,telepot","A_Id":54479855,"CreationDate":"2018-12-25T18:02:00.000","Title":"what can be done by a telegram chat 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 am coming from NodeJS and learning Python and was wondering how to properly install the packages in requirements.txt file locally in the project.\nFor node, this is done by managing and installing the packages in package.json via npm install. However, the convention for Python project seems to be to add packages to a directory called lib. When I do pip install -r requirements.txt I think this does a global install on my computer, similar to nodes npm install -g global install. How can I install the dependencies of my requirements.txt file in a folder called lib?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":20109,"Q_Id":53925660,"Users Score":27,"Answer":"use this command\npip install -r requirements.txt -t <path-to-the-lib-directory>","Q_Score":23,"Tags":"python,python-2.7,pip,requirements.txt","A_Id":53925671,"CreationDate":"2018-12-25T21:14:00.000","Title":"Installing Python Dependencies locally in project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have cuda 9.2 already installed on my system and I want to install cuda 8.0 in a python virtual environment. I don't want the installation of cuda 8.0 to take effect on the whole system, because I don't want the cuda drivers to change and I don't want to have specify which cuda I want to use each time. For these reasons, before I attempt to install a new version on a virtual environment, could you please tell me if it will install it on the whole system? (as if I hadn't used a virtual environment)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4473,"Q_Id":53926038,"Users Score":1,"Answer":"As far as I know you can have multiple CUDA versions installed without any problem. When creating a virtual environment, you can specify which CUDA version you want it to use. Make certain not to select the driver for installation when you install CUDA 8 and everything should work.","Q_Score":1,"Tags":"python,cuda,virtualenv","A_Id":53926321,"CreationDate":"2018-12-25T22:35:00.000","Title":"does installing a new version of cuda in a python virtual environment have an effect on the whole system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running a code on deep learning, which uses the opencv module, by running python main.py (contains import cv2 statement), but always get the error 'ImportError: dynamic module does not define module export function (PyInit_cv2)'.\nI've tried to reinstall my anaconda and create new virtual environments, but all got the same result. This problem really confuses me a lot and I've googled for many related problems, none of them works. I think the problem is something related to the environment and has nothing to do with the code, because I got the same result by simply run import cv2 in python prompt. The more confusing thing is that, even after I remove the opencv module, I also get the same problem, but not a ModuleNotFoundError. Does anyone can give me some advice? Thanks a lot!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12576,"Q_Id":53926883,"Users Score":0,"Answer":"I had the same problem, which was caused by the cv2.so file in \/usr\/local\/lib\/python2.7\/site-packages\/cv2.so. After I deleted the file and use command sudo pip3 install opencv-python, it worked for python3.","Q_Score":1,"Tags":"python,opencv,import,module","A_Id":55261613,"CreationDate":"2018-12-26T02:27:00.000","Title":"How to fix 'ImportError: dynamic module does not define module export function (PyInit_cv2)' error in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have looked around for this and not found any good answers. I Just pulled python from git and built it on Windows 10.  The python.exe file works fine when in the build location but, if you copy or move the folder you built into you get the following error upon running python.exe:\n\nFatal Python error: Py_Initialize: unable to load the file system\n  codec LookupError: no codec search functions registered: can't find\n  encoding\nCurrent thread 0x000060c8 (most recent call first):\n   .\\python Fatal Python error:\n  Py_Initialize: unable to load the file system codec\n  ModuleNotFoundError: No module named 'encodings'\nCurrent thread 0x00004f50 (most recent call first):\n\nThis is strange cause if you run python from the build directory\nD:\\Users\\brazg\\Documents\\GitHub\\cpython\\PCbuild\\amd64 it runs fine.\nI would like to know why python.exe doesn't run if the amd64 directory is moved out of PCbuild.\nAs a side note I cannot find any information for setting up the Python root folder after building from source.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":263,"Q_Id":53927434,"Users Score":0,"Answer":"This is an answer from the perspective of someone that hasn't built python from source before.\nTo answer my own question, what needs to be done after moving the Python binaries to a different location out of the cpython\\PCbuild is you need to copy the Lib directory from the pulled sources because the encodings directory is in cpython\\Lib.\nEven though you the build is in cpython\\PCbuild\\<build directory> it still reads from cpython\\Lib which makes sense but, I think should be made more clear in the official python documentation.\nIf you copy the amd64 directory to a new location you need to copy the cpython\\Lib directory into the amd64 directory.  You can also delete all the .exp, .lib and .pdb files that were built with python from running build.bat. As they are all the compiler's linker and debug information.\nI wish it was made more clear that cpython\\PCbuild\\<build directory> read up to cpython\\Lib when run.","Q_Score":0,"Tags":"python,python-3.x,build,windows-10","A_Id":53934781,"CreationDate":"2018-12-26T04:32:00.000","Title":"No modules named 'encodings' if python 3 directory is moved after building from source 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 new to Celery and I am trying to understand how queues work. If I have two tasks say task1 and task2 and I place them in different queues and on task1 I use only a single worker and on task2 I use multiple works, will task1 only run one at a time since I only have a single worker? and will task2 run as many as many times as I have workers? Is my understanding correct?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1310,"Q_Id":53927477,"Users Score":0,"Answer":"task2 will not be executed as many times as you have workers on that queue, this task will be distributed to one of workers that will be available at that moment of time.","Q_Score":1,"Tags":"python,celery,django-celery,celery-task,celerybeat","A_Id":54287760,"CreationDate":"2018-12-26T04:39:00.000","Title":"Celery distributing Queues and Workers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I need to check-in the file which is in client workspace. Before check-in i need to verify if the file has been changed. Please tell me how to check this.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":596,"Q_Id":53931642,"Users Score":2,"Answer":"Use the p4 diff -sr command.  This will do a diff of opened files and return the names of ones that are unchanged.","Q_Score":1,"Tags":"python-2.7,perforce,p4python","A_Id":53935076,"CreationDate":"2018-12-26T11:44:00.000","Title":"P4Python check if file is modified after check-out","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When installing packages with sudo apt-get install or building libraries from source inside a python virtual environment (I am not talking about pip install), does doing it inside a python virtual environment isolate the applications being installed? I mean do they exist only inside the python virtual environment?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":204,"Q_Id":53932357,"Users Score":1,"Answer":"As per the comment by @deceze, virtual environments have no influence over apt operations.\nWhen building from source, any compiled binaries will be linked to the python binaries of that environment. So if your virtualenv python version varies from the system version, and you use the system python (path problems usually), you can encounter runtime linking errors.\nAs for isolation, this same property (binary compatibility) isolates you from system upgrades which might change your system python binaries. Generally we're stable in the 2.x and 3.x, so it isn't likely to happen. But has, and can.\nAnd of course, when building from source inside a virtualenv, installed packages are stashed in that virtualenv; no other python binary will have access to those packages, unless you are manipulating your path or PYTHONPATH in strange ways.","Q_Score":2,"Tags":"python,installation,virtualenv,installation-package","A_Id":53932505,"CreationDate":"2018-12-26T12:49:00.000","Title":"what 'operations' does a python virtual enviornement really isolate?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When installing packages with sudo apt-get install or building libraries from source inside a python virtual environment (I am not talking about pip install), does doing it inside a python virtual environment isolate the applications being installed? I mean do they exist only inside the python virtual environment?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":204,"Q_Id":53932357,"Users Score":2,"Answer":"Things that a virtual environment gives you an isolated version of:\n\nYou get a separate PATH entry, so unqualified command-line references to python, pip, etc., will refer to the selected Python distribution. This can be convenient if you have many copies of Python installed on the system (common on developer workstations). This means that a shebang line like #!\/usr\/bin\/env python will \"do the right thing\" inside of a virtualenv (on a Unix or Unix-like system, at least).\nYou get a separate site-packages directory, so Python packages (installed using pip or built locally inside this environment using e.g. setup.py build) are installed locally to the virtualenv and not in a system-wide location. This is especially useful on systems where the core Python interpreter is installed in a place where unprivileged users are not allowed to write files, as it allows each user to have their own private virtualenvs with third-party packages installed, without needing to use sudo or equivalent to install those third-party packages system-wide.\n\n... and that's about it.\nA virtual environment will not isolate you from:\n\nYour operating system (Linux, Windows) or machine architecture (x86).\nScripts that reference a particular Python interpreter directly (e.g. #!\/usr\/bin\/python).\nNon-Python things on your system PATH (e.g. third party programs or utilities installed via your operating system's package manager).\nNon-Python libraries or headers that are installed into a operating system specific location (e.g. \/usr\/lib, \/usr\/include, \/usr\/local\/lib, \/usr\/local\/include).\nPython packages that are installed using the operating system's package manager (e.g. apt) rather than a Python package manager (pip) might not be visible from the the virtualenv's site-packages folder, but the \"native\" parts of such packages (in e.g. \/usr\/lib) will (probably) still be visible.","Q_Score":2,"Tags":"python,installation,virtualenv,installation-package","A_Id":53932762,"CreationDate":"2018-12-26T12:49:00.000","Title":"what 'operations' does a python virtual enviornement really isolate?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am preparing a python script which contains 4 functions, and a main function calling them.\nWhen the script is ran, all the functions are executed one by one, but I manually terminated the script after 2nd function is executed completely.\nNow I want, when the script is re-run, it should ignore first two function and start with the 3rd one.\nI got one idea to use a file and add an entry for each function when it is executed and next time read from that file, but it will require too much of nested if.\nAny other ideas?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":83,"Q_Id":53933955,"Users Score":3,"Answer":"Why \"nested\" ifs? If the functions are supposed to run in sequence, you can write the number of the last function to finish to a file, and then have a sequence of non-nested ifs, e.g, something like this pseudo-code\n\n... # read n from file, or 0 if it doesn't exist\nif n < 1:\n    f1()\n    ... # write 1 to the file\nif n < 2:\n    f2()\n    ... # write 2 to the file\nif n < 3:\n    f3()\n    ... # write 3 to the file\n...\n\nSo indeed one if per function, but no nesting.\nIf the functions may run in a different order, you can write a different file for each one, or a different line into a single file as you suggested, but I don't understand why it will have to be nested ifs.","Q_Score":4,"Tags":"python,python-3.x","A_Id":53934032,"CreationDate":"2018-12-26T15:26:00.000","Title":"Re-running a python script from where it was stopped","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python 3.7 on my windows 10. I am not able to use the command ctrl + Y in python IDLE.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1677,"Q_Id":53934429,"Users Score":0,"Answer":"I assume you're trying to use \"Redo\". In IDLE that is Ctrl+Shift+Z.","Q_Score":0,"Tags":"python,windows-10","A_Id":53934688,"CreationDate":"2018-12-26T16:14:00.000","Title":"I have python 3.7 in my system and redo command ctrl +Y is not working in python IDLE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm attempting to do some real-time (sort-of-ish) web-cam video processing. In order to both grab all the frames and process them, I'm running my frame grabber and image processor as two separate processes. In order to have them communicate I'm trying to decide between using python 2.7's multiprocessing.queue and multiprocessing.pipe.\nI don't understand the difference between these two classes. One uses put and get to share data. The other uses send and receive. Is there a use-case where one would prefer on method over the other? Should I prefer one method over the other?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":312,"Q_Id":53935015,"Users Score":0,"Answer":"The multiprocessing.queue is First In First Out (FIFO) queue. You would use this for one-way communication. For example, your grabber process can put() frames onto the queue and the processing process can get() frames from the queue when it's ready to process them.\nThe multiprocessing.pipe is a 2-way channel and probably doesn't fit your use case. However, if you had 2 processes which were both sending and receiving data between each other you would use the two connection objects where process A sends() on one object and recieves() on the other object and process B does the inverse.","Q_Score":0,"Tags":"python,queue,pipe,python-multiprocessing","A_Id":53935126,"CreationDate":"2018-12-26T17:13:00.000","Title":"What's the difference between a multiprocess.queue and multiprocess.pipe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem with using the rqt_image_view package in ROS. Each time when I type rqt_image_view or rosrun rqt_image_view rqt_image_view in terminal, it will return:  \n\nTraceback (most recent call last):\n    File \"\/opt\/ros\/kinetic\/bin\/rqt_image_view\", line 16, in \n      plugin_argument_provider=add_arguments))\n    File \"\/opt\/ros\/kinetic\/lib\/python2.7\/dist-packages\/rqt_gui\/main.py\", line 59, in main\n      return super(Main, self).main(argv, standalone=standalone, plugin_argument_provider=plugin_argument_provider, plugin_manager_settings_prefix=str(hash(os.environ['ROS_PACKAGE_PATH'])))\n    File \"\/opt\/ros\/kinetic\/lib\/python2.7\/dist-packages\/qt_gui\/main.py\", line 338, in main\n      from python_qt_binding import QT_BINDING\n  ImportError: cannot import name QT_BINDING\n\nIn the \/.bashrc file, I have source :\n\nsource \/opt\/ros\/kinetic\/setup.bash\n  source \/home\/kelu\/Dropbox\/GET_Lab\/leap_ws\/devel\/setup.bash --extend\n  source \/eda\/gazebo\/setup.bash  --extend\n\nThey are the default path of ROS, my own working space, the robot simulator of our university. I must use all of them. I have already finished many projects with this environmental variable setting. However, when I want to use the package rqt_image_view today, it returns the above error info.\nWhen I run echo $ROS_PACKAGE_PATH, I get the return:\n\n\/eda\/gazebo\/ros\/kinetic\/share:\/home\/kelu\/Dropbox\/GET_Lab\/leap_ws\/src:\/opt\/ros\/kinetic\/share\n\nAnd echo $PATH\n\n\/usr\/local\/cuda\/bin:\/opt\/ros\/kinetic\/bin:\/usr\/local\/cuda\/bin:\/usr\/local\/cuda\/bin:\/home\/kelu\/bin:\/home\/kelu\/.local\/bin:\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:\/usr\/games:\/usr\/local\/games:\/snap\/bin\n\nThen I only source the  \/opt\/ros\/kinetic\/setup.bash ,the rqt_image_view package runs!!\nIt seems that, if I want to use rqt_image_view, then I can not source both \/opt\/ros\/kinetic\/setup.bash and \/home\/kelu\/Dropbox\/GET_Lab\/leap_ws\/devel\/setup.bash at the same time.\nCould someone tell me how to fix this problem? I have already search 5 hours in google and haven't find a solution.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":547,"Q_Id":53937342,"Users Score":0,"Answer":"Different solutions to try:\n\nIt sounds like the first path \/eda\/gazebo\/ros\/kinetic\/share or \/home\/kelu\/Dropbox\/GET_Lab\/leap_ws\/src has an rqt_image_view package that is being used. Try to remove that dependency.\nHave you tried switching the source files being sourced? This depends on how the rqt_image_view package was built, such as by source or through a package manager. \n\nInitially, it sounds like there is a problem with the paths being searched or wrong package being run since the package works with the default ROS environment setup.","Q_Score":0,"Tags":"python,linux,bash,ubuntu,ros","A_Id":54034106,"CreationDate":"2018-12-26T21:26:00.000","Title":"How can I source two paths for the ROS environmental variable at the same time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"If a python script using package X is running and package X is being upgraded, will it lead to permission problem that will cause the upgrade to fail?\nI am using Windows 10, Anaconda v5.2 running on python v3.6 and conda to do update of packages.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":353,"Q_Id":53938886,"Users Score":1,"Answer":"When you import, you're creating a local instance of the package in your RAM for running. So upgrading your packages should not affect your scripts running.\nYou can look at from importlib import reload to reload your packages while your scripts are still running","Q_Score":1,"Tags":"python,python-3.x,anaconda,conda","A_Id":53939052,"CreationDate":"2018-12-27T01:44:00.000","Title":"Is it necessary to stop all python scripts when upgrading python packages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If a python script using package X is running and package X is being upgraded, will it lead to permission problem that will cause the upgrade to fail?\nI am using Windows 10, Anaconda v5.2 running on python v3.6 and conda to do update of packages.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":353,"Q_Id":53938886,"Users Score":2,"Answer":"I tried a simple test just now. I ran a python script which loops forever. It uses numpy. Then, I tried to install a python package(pytorch) that requires downgrading the numpy version. When the script is running, the installation failed with some \"no permission\" error message. After I stopped the script, the installation succeeded.\nBased on the results of this experiment, the conclusion is that it is recommended to stop all python scripts when performing python package upgrade.","Q_Score":1,"Tags":"python,python-3.x,anaconda,conda","A_Id":53939128,"CreationDate":"2018-12-27T01:44:00.000","Title":"Is it necessary to stop all python scripts when upgrading python packages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If a python script using package X is running and package X is being upgraded, will it lead to permission problem that will cause the upgrade to fail?\nI am using Windows 10, Anaconda v5.2 running on python v3.6 and conda to do update of packages.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":353,"Q_Id":53938886,"Users Score":2,"Answer":"Although pure Python files are compiled in memory when imported, and the source is (almost) no longer relevant after that, that's not the end of the story.\nPackages may have extra assets that are lazily loaded, or your program or its dependencies may load dependent modules on demand, so, if running during an upgrade, it may load unexpected versions of packages\/resources, or even halfway-upgraded packages.\nAlso, native (=non Python-only) modules - .pyd files on Windows - are dlls that are loaded in the importing process. As dlls are mapped in memory with no sharing, replacing them while they are loaded is not allowed, so this may block the upgrade of the relevant packages.","Q_Score":1,"Tags":"python,python-3.x,anaconda,conda","A_Id":53939138,"CreationDate":"2018-12-27T01:44:00.000","Title":"Is it necessary to stop all python scripts when upgrading python packages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python for more than 1 year. One question strike in my mind, how the random values are generated, there is some specific mechanism through which particular value should be selected by system that appears to be random to user. In all programming language how it is generated? Does all have the same mechanism?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":61,"Q_Id":53940209,"Users Score":1,"Answer":"Usually the OS provides a source of (pseudo) random data. For example on Linux there are \/dev\/urandom and \/dev\/random.\nSome random functions in programming languages use that, other are based on a seed value and generate more or less reproducible values from it.\nThe random module in Python used a seeded approach. For use-cases that require more randomness use the secrets module. I uses the OS random sources.","Q_Score":0,"Tags":"python,python-3.x,algorithm,python-2.7","A_Id":53940304,"CreationDate":"2018-12-27T05:36:00.000","Title":"Can someone tell me the internal working of random function in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to make a python virtualenvironment using virtualenv in \nI type virtuelenv env --python=python3 \nI get an error\nPermissionError: [Errno 1] Operation not permitted: '\/mnt\/d\/venv\/bin\/python3'\nSo I used the command with sudo and therefore type sudo virtualenv env --python=python3\nThe command works this time, now I activate the environment and try to install something using pip, I get\nCould not install packages due to an EnvironmentError: [Errno 1] Operation not permitted\nI know for a fact that if use pip with sudo, it will install packages for the global site packages and no the site packages of the virtual environment. I want to install things to the virtual environment. \nI am running ubuntu bionic on WSL, I used to run ubuntu xenial and didn't face this problem. \nplease advise.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":3113,"Q_Id":53941490,"Users Score":4,"Answer":"When using WSL: Create the venv in the Linux hierarchy, not the Windows hierarchy. \nTypically this means creating in \/home\/YOUR_USER\/ instead of \/mnt\/....","Q_Score":4,"Tags":"python,virtualenv,sudo,windows-subsystem-for-linux,ubuntu-18.04","A_Id":60889304,"CreationDate":"2018-12-27T07:43:00.000","Title":"`Could not install packages due to an EnvironmentError: [Errno 1] Operation not permitted` in the virtual envinronment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using scipy curve_fit to curve a line for retention. however, I found the result line may produce negative number. how can i add some constrain?\nthe 'bounds' only constrain parameters not the results y","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":149,"Q_Id":53942983,"Users Score":0,"Answer":"One of the simpler ways to handle negative value in y, is to make a log transformation. Get the best fit for log transformed y, then do exponential transformation for actual error in the fit or for any new value prediction.","Q_Score":0,"Tags":"python,scipy","A_Id":53944352,"CreationDate":"2018-12-27T09:49:00.000","Title":"how to constrain scipy curve_fit in positive result","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using vpython library in spyder. After importing the library when I call simple function like print('x') or carry out any assignment operation and execute the program, immediately a browser tab named localhost and port address opens up and I get the output in console {if I used print function}. \nI would like to know if there is any option to prevent the tab from opening and is it possible to make the tab open only when it is required.\nPS : I am using windows 10, chrome as browser, python 3.5 and spyder 3.1.4.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":53943901,"Users Score":0,"Answer":"There is work in progress to prevent the opening of a browser tab when there are no 3D objects or graph to display. I don't know when this will be released.","Q_Score":1,"Tags":"python,spyder,vpython","A_Id":53982995,"CreationDate":"2018-12-27T10:57:00.000","Title":"Vpython using Spyder : how to prevent browser tab from opening?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a chatbot using AWS lex and Lambda. Bot works as expected. I have store the slot data into sessionAttributes. The issue I am facing is when I communicate with bot from my website and if I open another tab of my site, it does't show the previous chat which happened in older tab(here both tabs are open).\nOn every new tab chat starts from start.\nRequirement is to continue from where it was left in previous tab.\nAm I missing any flow here ? I have gone though  AWS doc but didn't get any clear picture to do the same. Any example of the same will help better.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":53946681,"Users Score":0,"Answer":"You need to store the chat into some database of your own. On page load, you need to fetch the chat of current session or current user (based on your requirement).\n That way even if the user refreshes the page or open up a new tab, he will be able to see the chat he already had with the chatbot.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda,chatbot,amazon-lex","A_Id":53955733,"CreationDate":"2018-12-27T14:32:00.000","Title":"maintain aws lex chat communication on all pages of 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":"I am new to Django and am trying to figure out how to store historical data and be able to reference any data point from a date in the past. Say I want to store data on a kids height change as he grows and be able to compare his height at day 400 to his height at day 6xx. How would I set this up in Django? Would there need to be a foreign key relationship between height and the kid?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3432,"Q_Id":53946871,"Users Score":2,"Answer":"Forget about Django's ORM (which is really just a very thin wrapper over your SQL database) and think in terms of relational database. Here you obviously have two entities: \"kid\" and \"height\". You also have the following relationships: a \"kid\" has zero, one or many \"height\", a \"height\" belongs to one single \"kid\". This indeed translates to a \"kid\" table  kid(+id, name, dob, ...) and a \"height\" table with a foreign key on kid: height(+id, kid_id, date, value).\nHow to write this using Django's orm is quite straighforward so I'll leave it to you.","Q_Score":2,"Tags":"python,django,sqlite,historical-db","A_Id":53947069,"CreationDate":"2018-12-27T14:49:00.000","Title":"How to store historical data using Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have created a machine learning algorithm in Python that is served through a REST API and would like to implement it on Google Cloud \/ Amazon EC2 to make real-time predictions. Before I do this, I would like to create a 'log' of every request\/prediction that comes in\/out of the model - this seems like good practice to me and may also help with creating unique prediction identifiers. Just a simple 1 or 0 stored in a database with a datetime stamp and unique ID.\nHow should I send this data to the database without impacting the run time of the model? An INSERT INTO statement in the API? A seperate API altogether?\nThank you very much for your help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":344,"Q_Id":53948225,"Users Score":1,"Answer":"It depends on the latency of the results. If you want it to persist data in the db instantly then an API has to be made instantly when you have received the request. As these will be log files by nature my recommendation would be to store locally and insert the logs once in a day to reduce the network congestion over the time. If your existing API is already connected to db and then I do not see a point of creating a new API altogether for a simple post call","Q_Score":0,"Tags":"python,database,machine-learning,server,google-cloud-platform","A_Id":53948363,"CreationDate":"2018-12-27T16:43:00.000","Title":"How to connect machine learning algorithm to database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to detect if two widgets that I have created (a widgets.Text field and a widgets.SelectMultiple Field) are already linked without creating a separate boolean variable to keep track, as that can get messy.  I wasn't sure if there is a built-in method like <my_widget>.isLinked already available?  I haven't found anything outside of the link\/unlink for handling this. I also have not looked at the Link object that is returned, but not sure if that will help me in this case.\nI have a widgets.SelectMultiple list, that I will call the selection field, that contains over a hundred different entries.  To keep track of the items that the user has selected, I have a separate widgets.Text box that stores the results.  I have linked these two widgets so that when items are selected, they appear in the results field. When these items are link-ed, everything's great and synced up.  However, there are instances where I'm going to unlink the widgets.  For example, I have a custom widgets.Text search field that shrinks the list in the widgets.SelectMultiple based on user input to narrow down the results.  During the state of the user interacting with the search field, I want to unlink so I don't have any exceptions thrown, and then link again once the user has completed their search and chosen their item. At any point, the user can also choose to mouse-select an entry, even if they are in the middle of a search, so this is why I would like to check if we are linked or not (will need to manually add it to the widgets.values list of the results field if unlink-ed.)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":53948283,"Users Score":0,"Answer":"Actually I should have just dug a little deeper.  The Link object returned is exactly what I need. It returns None if the link is non-existent, so I can just use that.  Thanks for entertaining me Stack Overflow...","Q_Score":0,"Tags":"python,python-2.7,jupyter-notebook,ipython","A_Id":53948575,"CreationDate":"2018-12-27T16:48:00.000","Title":"Is there a way to check if two Jupyter iPython widgets are already linked?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get this error after already having installed autofocus when I try to run a .py file from the command line that contains the line:\nfrom autofocus import Autofocus2D\nOutput:\nImportError: cannot import name 'AFAVSignature'\nIs anyne familiar with this package and how to import it?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":53948358,"Users Score":0,"Answer":"It doesn't look like the library is supported for python 3. I was getting the same error, but removed that line from init.py and found that there was another error with of something like 'print e' not working, so I put the line back in and imported with python2 and it worked.","Q_Score":0,"Tags":"python-3.x","A_Id":54234661,"CreationDate":"2018-12-27T16:54:00.000","Title":"ImportError: cannot import name 'AFAVSignature'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm attempting to automate a website interaction that requires that a USB key be inserted, an alert box then asks you to verify, and after hitting okay it opens a local program that requires a pin be input to activate the key. I'm looking for a way to have the bot enter the pin into the external program. Is there a library that can automate this for me?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":53948970,"Users Score":0,"Answer":"I ended up using a keyboard input library to take advantage of the fact that windows changes window focus to the security window that opens, so now it emulates keyboard input to press enter, enter the pin, and press enter again.","Q_Score":0,"Tags":"python,selenium,internet-explorer","A_Id":54115153,"CreationDate":"2018-12-27T17:52:00.000","Title":"SSL USB Key Authentication in Selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project using GNU Radio and USRP radios (Ettus B205mini). I would like to vary the output power based on an incoming signal strength. For example, given a frequency (let's say 900MHz), output power should scale with the strength of a control tone on that frequency. Is this possible to do out-of-the-box or would I need to code a new block for it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":370,"Q_Id":53949090,"Users Score":0,"Answer":"Should be possible. You can convert signal to signal power with the \"complex to magnitude square block\"; then scale that to something useful (i.e. between 0 and 1) with the \"multiply const\" block, or use any other combination of arithmetic blocks to achieve the desired power \/ power curve.\nThen, you'd typically low-pass filter the result, and use it with a \"Multiply\" block to scale the complex numbers you feed into the \"USRP Sink\".","Q_Score":0,"Tags":"python,gnuradio,gnuradio-companion","A_Id":53950103,"CreationDate":"2018-12-27T18:03:00.000","Title":"GNU Radio: Varying output power based on incoming signal strength","Data Science and Machine Learning":0,"Database and SQL":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 read an Excel file from an Outlook attachment without saving it, and return a pandas dataframe from the attached file? The file will always be in the same format.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2158,"Q_Id":53950601,"Users Score":1,"Answer":"Attachments are MIME-encoded and have to be decoded back into the original format (which essentially means making a disk copy) for programs that are expecting that format.\nWhat you want is to give pandas the identifier of the email, the name of the attachment, the details of the message store, and suitable authentication, and have pandas read the attachment directly. This would entail extending the function pandas.read_csv() or maybe adding a new function read_csv_attachment(). \nWhile I am sure this is possible, it is a more ambitious project than I (as one unfamiliar with pandas internals) would want to tackle myself. And certainly much more work than saving the attachments manually, unless you have thousands of them.","Q_Score":2,"Tags":"python,excel,pandas,outlook","A_Id":53962197,"CreationDate":"2018-12-27T20:37:00.000","Title":"Create dataframe from Excel attachment in Outlook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have several virtual environment in my computer and sometimes I am in doubt about which python virtual environment I am using.  Is there an easy way to find out which virtual environment I am connected to?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":33051,"Q_Id":53952214,"Users Score":8,"Answer":"From a shell prompt, you can just do echo $VIRTUAL_ENV (or in Windows cmd.exe, echo %VIRTUAL_ENV%).\nFrom within Python, sys.prefix provides the root of your Python installation (the virtual environment if active), and sys.executable tells you which Python executable is running your script.","Q_Score":27,"Tags":"python,python-2.7,python-venv","A_Id":53952369,"CreationDate":"2018-12-28T00:04:00.000","Title":"how can I find out which python virtual environment I am using?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have several virtual environment in my computer and sometimes I am in doubt about which python virtual environment I am using.  Is there an easy way to find out which virtual environment I am connected to?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":33051,"Q_Id":53952214,"Users Score":10,"Answer":"Usually it's set to display in your prompt. You can also try typing in which python or which pip in your terminal to see if it points to you venv location, and which one. (Use where instead of which on Windows.)","Q_Score":27,"Tags":"python,python-2.7,python-venv","A_Id":53952232,"CreationDate":"2018-12-28T00:04:00.000","Title":"how can I find out which python virtual environment I am using?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Like in php, include() method and allow_url_include can be vulnerable to LFI and RFI.\nDoes django's include is vulnerable to lfi and RFI?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1355,"Q_Id":53953542,"Users Score":2,"Answer":"Not unless you mess with the default template loaders. Django doesn't let you include files located outside of the application's templates folders and does its best to prevent you from touching external files using built-in operations.\nAs a general rule of thumb, it doesn't hurt to keep your application code completely isolated from the path where a user can upload files and to sanitize and reduce user-provided input's interactions with potentially dangerous functions.","Q_Score":2,"Tags":"python,django,remote-file-inclusion","A_Id":53954207,"CreationDate":"2018-12-28T04:02:00.000","Title":"Is Django framework vulnerable to local file inclusion(LFI) and remote file inclusion(RFI)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Flask application and it is working well on my workstation. But when I am deploying my application using Gunicorn in a VM. I am getting this\n\nErrno 5: Input\/Output error\n\nThis error comes sometimes on startup of application or sometimes after that, I mean the application behaving weirdly. I googled the error but not able to find an appropriate answer that can solve my problem. \nDoes anybody know the exact reason behind it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":571,"Q_Id":53954947,"Users Score":1,"Answer":"Hey is your gunicorn running as daemon on vm ??\nIf gunicorn runs in daemon then master thread sends the SIGWINCH to its child processes which is graceful termination of them. \n1.)if you are trying to daemonize gunicorn then don't go with '&' at the end of it to daemonize it. Instead use any process manager like supervisor else run it as a service.\n2.)Or you can always run gunicorn inside a docker container via combination of CMD and ENTRYPPOINT.  Which in turn will not have any need of daemonizing gunicorn process. and will remain at PID1 in container. \nI guess this should solve your problem.","Q_Score":0,"Tags":"python,flask,deployment,virtual-machine,gunicorn","A_Id":53955084,"CreationDate":"2018-12-28T07:14:00.000","Title":"\"Errno 5- Input\/output error\" while deploying app using gunicorn in a cloud VM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How to get most frequent context words from pretrained fasttext model?\nFor example:\nFor word 'football' and corpus [\"I like playing football with my friends\"]\nGet list of context words: ['playing', 'with','my','like']\nI try to use \nmodel_wiki = gensim.models.KeyedVectors.load_word2vec_format(\"wiki.ru.vec\")\nmodel.most_similar(\"\u0431\u043b\u043e\u043a\")\nBut it's not satisfied for me","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":473,"Q_Id":53955958,"Users Score":0,"Answer":"The plain model doesn't retain any such co-occurrence statistics from the original corpus. It just has the trained results: vectors per word. \nSo, the ranked list of most_similar() vectors \u2013 which isn't exactly words that appeared-together, but strongly correlates to that \u2013 is the best you'll get from that file. \nOnly going back to the original training corpus would give you exactly what you've requested.","Q_Score":2,"Tags":"python,gensim,word2vec,fasttext","A_Id":53964532,"CreationDate":"2018-12-28T09:02:00.000","Title":"How to get list of context words in Gensim","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I change a new computer and install Python3.6 and matplotlib\uff0cWhen I run the code last month in the old computer, I get the following error:\nax.hold(True)\nAttributeError: 'AxesSubplot' object has no attribute 'hold'","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5619,"Q_Id":53957042,"Users Score":1,"Answer":"The API Changes document says:\nSetting or unsetting hold (deprecated in version 2.0) has now been completely removed. Matplotlib now always behaves as if hold=True. To clear an axes you can manually use cla(), or to clear an entire figure use clf().","Q_Score":4,"Tags":"python-3.x","A_Id":63126102,"CreationDate":"2018-12-28T10:28:00.000","Title":"AttributeError: 'AxesSubplot' object has no attribute 'hold'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose i have a data-frame object named as df, head() is a method that can be applied to df to see the first 5 records of the data-frame and df.size is a property to get the size of the data-frame. \nFor the property we are not using '()' as we used for a method. This was little confusing initially. \nCould anyone explain whats basic difference between a property and a method in python. I mean why we had to define size as a property for a dataframe, why not it was defined as a method which would have just returned the size of the data-frame.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":311,"Q_Id":53957850,"Users Score":0,"Answer":"Here in the above example you mentioned, you can pass argument to df.head() function, where as you cannot pass arguments for properties.\nfor same above example, if you have written df.head(20) it would return first 20 rows.","Q_Score":0,"Tags":"python,methods,properties","A_Id":53958035,"CreationDate":"2018-12-28T11:27:00.000","Title":"What is the difference between Methods and Properties for an object in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a browser-based multiplayer game. \nIn the game, registered players can \"attack\" other players. Once a player has \"attacked\" a player he must wait 30 minutes before his ability to 'attack' again is reset.\nI have an idea of implementing this but am not sure if my approach is bad practice:\nI thought about adding a \"TimeToReset\" field in the database to each registered user and fill that field with a timer object. Once a player 'attacks' his 'TimeToReset' field starts counting down from 30 minutes to 0.\nand then have the application continuously query all the users in the database with a while True loop, looking for users that their \"TimeToReset\" reached 0. And then run code to reset their ability to 'attack' again.\nI am not sure how efficient my approach or if it is even possible is and would love some input. So to summarize:\n1)Is it ok to store a timer\/stopwatch object(which continuously changes) in a database?\n2)Is it efficient to continuously run a while true loop to query the database?\nOr if is there a better approach to implement this feature I would love to hear it.\nThank you","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":102,"Q_Id":53958039,"Users Score":3,"Answer":"I'm not sure what the benefit of doing this would be. Surely all you need to do is to store the time of the last attack for each user, and just disallow attacks if that is less than 30 minutes before the current time.","Q_Score":1,"Tags":"python,django","A_Id":53958195,"CreationDate":"2018-12-28T11:41:00.000","Title":"Is it bad practice to store a timer object in a database and also have the program continuously query in Django?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am learning Python 3.x together with Flask. I'm also a Basketball fan, so I thought I'd be a good idea to get in the water and try to do a game simulator, perhaps only between two teams to begin with - and learn more Python along the way.\nMy biggest question for start is what should the logic behind the simulator be? Let's say I want to sim two historic teams - Lakers00 vs Bulls 98. Stats of the players are available online.\nI want it to be \"realistic,\" so perhaps getting into percentages of each player? If Jordan shot let's say 50% for the season - should that be programmed into each 'player' and then tell what's the chance that the % is higher or lower than that in each simulation? Should I use .json to store the data?\nOr is there a completely different approach I should take?\nOnce the code is in, I would ideally try to turn that into a website with Flask. What database would you recommend to use?\nThank you","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":628,"Q_Id":53962256,"Users Score":0,"Answer":"I don't know JSON, but I'd start with keeping it simple, if you're still working on this.\n1: Players should have at least the following fields:\n         Breakdown of possession usage (TO, 2 Pt shot, 3 pt shot)\n         2 pt shooting percentage, 3 pt shooting percentage\n2: I'd probably start by including something like usage percentage\nThe simplest way to do it would be have a player class with those attributes. If you took the advice of #2 you could use a function to pull out which player used the possession, and what they did with it (2 pt shot, 3 pt shot, turnover, and whether the shot was successful). Defense, rebounds, fouls might be more for later versions of the game, but if you start with that you'll at least have something that resembles basketball. I think NBA games are roughly 100 possessions.","Q_Score":0,"Tags":"python-3.x","A_Id":56329485,"CreationDate":"2018-12-28T17:35:00.000","Title":"Logic behind creating a basketball simulator with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am learning Python 3.x together with Flask. I'm also a Basketball fan, so I thought I'd be a good idea to get in the water and try to do a game simulator, perhaps only between two teams to begin with - and learn more Python along the way.\nMy biggest question for start is what should the logic behind the simulator be? Let's say I want to sim two historic teams - Lakers00 vs Bulls 98. Stats of the players are available online.\nI want it to be \"realistic,\" so perhaps getting into percentages of each player? If Jordan shot let's say 50% for the season - should that be programmed into each 'player' and then tell what's the chance that the % is higher or lower than that in each simulation? Should I use .json to store the data?\nOr is there a completely different approach I should take?\nOnce the code is in, I would ideally try to turn that into a website with Flask. What database would you recommend to use?\nThank you","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":628,"Q_Id":53962256,"Users Score":0,"Answer":"I imagine you will want a to rig up a modifier to help compare teams from different eras. Defensive rules have changed over the ages and its had a great effect on field goal percentages, as have things like pace of play.","Q_Score":0,"Tags":"python-3.x","A_Id":53962328,"CreationDate":"2018-12-28T17:35:00.000","Title":"Logic behind creating a basketball simulator with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it a best way to create only one file of forms and one files of models in the folder of the project django? \nCreate for each application one forms.py and one models.py is too long.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":53964425,"Users Score":0,"Answer":"django apps are meant to be standalone.\nSo models and forms related to an app should be within that app.\nFor example, you have a website in which you also have a blog.\nNow you have a seperate app for that blog.  \nSo models related to blog (say Blog) should recide in blog\/models.py and forms related to bog (say BlogCreateForm) should recide in blog\/forms.py\nThis is the general convention that is followed. However in many cases it not really possibe to seperate a part of project as 'standalone'. \nUnnecessirly splitting project in apps may actually make it more difficult\nFor example , if you are making something for a school, \nthen it makes sense to create 2 apps teachers and students ONLY IF, you have many urls starting with something like\nwww.example.com\/teachers\/ and www.example.com\/students\/ \notherwise it makes more sense to just put the teacher and student model in the registration app where models like user, profile etc  recide.\nBut as @Toby mentioned, it entirely depends on the structure of your project and your use case","Q_Score":0,"Tags":"django,python-3.x","A_Id":53967143,"CreationDate":"2018-12-28T21:23:00.000","Title":"Where to creat forms an models","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm new to Python. I have visual studio and the Python 2.7 shell.\nI can run 5 + 5 in the Python shell which outputs 10.\nHowever if I do 5 + 5 in visual studio, I don't get an output. Why is this the case?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":47,"Q_Id":53964599,"Users Score":1,"Answer":"That is because, when you use the python shell. Shell is executing 5 + 5 when you press enter. Meaning shell executes you commands line by line, as you type them.\nOn the other hand Visual Studio is not a shell environment, it is an IDE (editor). Which allows you to write the whole python program and then execute it all at once.","Q_Score":0,"Tags":"python","A_Id":53964942,"CreationDate":"2018-12-28T21:46:00.000","Title":"No code output when writing statements in Visual Studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some calculations roughly looking like this: trip_count = DF_Trip.groupby([target], as_index=False)['Delivery'].count()\nAll my DF could possibly be grouped by Shop, Route and Driver. When I enter a single value for target, f.e. target = 'Route' it works fine.\nBut when I want to enter multiple values, f.e. target = 'Shop', 'Route' it only works when I enter it directly in the place where the variable is, f.e. trip_count = DF_Trip.groupby(['Shop', 'Route'], as_index=False)['Delivery'].count() but when I set the variable to target = 'Shop', 'Route', it gives me a ton of errors.\nI've realized from debugging, that target = 'Shop', 'Route' is treated as a tuple and read in the pandas.df.groupby documentation, that tuples are treated as a single value. Is there any workaround for this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":53968141,"Users Score":0,"Answer":"First I had to use a list as suggested by Gennady Kandaurov, and to later rename the columns I just had to add the two lists.\n\ntarget = ['Shop', 'Route']\nDF1.columns = target + ['static columns']","Q_Score":0,"Tags":"python,pandas","A_Id":53968421,"CreationDate":"2018-12-29T08:57:00.000","Title":"Tuple treated as single value in group by statement, any workaround?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm studying packages, and I have a question on creating a requirements.txt file.\nIf a module is imported from python, does it need to be mentioned in the requirements.txt file or can be left out?\nI know that for separate modules, they need to be pip installed. For those modules that need to be pip installed, should they be written in the requirements.txt file as 'pip install modulename'?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":31027,"Q_Id":53968641,"Users Score":4,"Answer":"The requirements.txt is a file where one specifies dependencies. For example your program can have dependency on Django or we can say the requirements.txt file in a django project describes the packages that needs to be installed for successfully running a project.\nTalking about the sub-modules: Suppose you have specified django in the requirements.txt file, now you don't need to specify any sub-modules (like 'django.shortcuts') in the requirements.txt file. Because they are already included in the django module.\nNow one can easily use\n\nfrom django.shortcuts import path\n\nin your .py files.\nNow for separate modules (like pillow) that need to be specified in the requirements.txt file, you don't need to write\n\npip install pillow\n\nYou can just write pillow in a separate line with other modules like:\n\ndjango\npillow\n\nYou can also use the below command to do so:\npip freeze > file_name\nIn your case file_name will be requirements.txt. This will add all the third-party module names in the requirements.txt file.","Q_Score":6,"Tags":"python-3.x,package","A_Id":53969878,"CreationDate":"2018-12-29T10:19:00.000","Title":"requirements.txt in python package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Trying to figure out a good way of solving this problem but wanted to ask for the best way of doing this.\nIn my project, I am looking at multiple instrument note pairs for a neural network. The only problem is that there are multiple instruments with the same name and just because they have the same name doesn't mean that they are the same instrument 100% of the time. (It should be but I want to be sure.)\nI personally would like to analyze the instrument itself (like metadata on just the instrument in question) and not the notes associated with it. Is that possible?\nI should also mention that I am using pretty-midi to collect the musical instruments.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":431,"Q_Id":53971287,"Users Score":1,"Answer":"In MIDI files, bank and program numbers uniquely identity instruments.\nIn General MIDI, drums are on channel 10 (and, in theory, should not use a Program Change message).\nIn GM2\/GS\/XG, the defaults for drums are the same, but can be changed with bank select messages.","Q_Score":0,"Tags":"python,artificial-intelligence,midi,music21,midi-instrument","A_Id":53976520,"CreationDate":"2018-12-29T16:27:00.000","Title":"Analyze just Pretty_Midi Instruments","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"so, I've tried to send a javascript XMLHttpRequest on a personally written http server that uses python's core functionality (i.e. socket and regex). took me a while but I finally had it going. so, I tested it out and after debugging the regex for parsing http POST and GET requests, I tested it out through the python console and it worked fine.\nin short, the http server receives a GET loopback request with personal identification, and reads whatever text was sent to it as data. \na tts loopback server.\nI wanted to do it because asides from selenium that honestly seemed like the only way for me to read random text from the screen using javascript (I could create a browser extension that works alongside it). I already created something for parsing html, so that's not the problem. later I wanted to extend the application and create a GUI using java for generally tts'ing files so I could listen to them while programming.\nthe problem was that although the socket was bound to port 80 on the loopback interface (127.0.0.1), when I sent an XMLHttpRequest to localhost, the server was not responding. I checked for incoming connections and there were none. from the terminal it worked fine though.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":53971452,"Users Score":0,"Answer":"if anyone else is wondering, no, it's not possible. unless it bypasses CORS restriction. (sadly). If anyone wants to do something similar, he has to either bypass CORS restrictions OR if you're building with python you can just use selenium and create a \"custom\" browser extension.","Q_Score":0,"Tags":"javascript,python,http,browser","A_Id":53972892,"CreationDate":"2018-12-29T16:49:00.000","Title":"javascript on browser send xmlhttprequest onto loopback server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to package my project with a virtual env so that it is easier to implement. \nI am trying to do this in a Ubuntu bash.\nI have succesfully created a Python venv using the Python virtualenv library. \nI do manage to activate it using source venv_name\/bin\/activate.\nI can indeed see (venv_name) at the beginning of my command line.\nHowever, I do not manage to actually use this virtual environment. \nI have for proof that when I type which python3 I get my root python3; and I have tried to update a package in the virtualenv but it has been updated in the root python. \nWhat should I do to actually use my virtual env ? For now I am trying:\npython3 myscript.py\nAnd it is working but I suspect it's running with my root python3.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":191,"Q_Id":53973748,"Users Score":2,"Answer":"I think you have two versions of python (2 and 3). You create virtualenv with python 2. Recreate virtualenv with correct python version","Q_Score":1,"Tags":"python,ubuntu,virtualenv","A_Id":53973825,"CreationDate":"2018-12-29T22:15:00.000","Title":"How to use a Python virtual env in my Ubuntu bash?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Here\u2019s a general question that maybe someone could point me in the right direction. \nI\u2019m getting into Reinforcement Learning with Python 3.6\/Tensorflow and I have found\/tweaked my own model to train on historical data from a particular stock. My question is, is it possible to train this model on more than just one stock\u2019s dataset? Every single machine learning article I\u2019ve read on time series prediction and RL uses one dataset for training and testing, but my goal is to train a model on a bunch of tickers with varying prices in the hopes that the model can recognize similar price patterns, regardless of the price or ticker so that I could apply the trained model to a new dataset and it\u2019ll work. \nRight now it trains on one ticker and it\u2019s prices, but when I try to add a new dataset for added training, it performs horribly because it doesn\u2019t know the new prices, if that makes sense. \nThis is a basic question and I don\u2019t necessarily expect a coded answer, just somewhere I could learn how to train a model using multiple datasets. I\u2019m using OpenAI gym environment if that helps anything. \nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":296,"Q_Id":53974005,"Users Score":0,"Answer":"Thanks to @Primusa I normalized my separate datasets by dividing each value by their respective maximums, then combined the datasets into one for training. Thanks!","Q_Score":1,"Tags":"python-3.x,tensorflow,reinforcement-learning,stocks,openai-gym","A_Id":53976226,"CreationDate":"2018-12-29T23:04:00.000","Title":"Reinforcement Learning Using Multiple Stock Ticker\u2019s Datasets?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here\u2019s a general question that maybe someone could point me in the right direction. \nI\u2019m getting into Reinforcement Learning with Python 3.6\/Tensorflow and I have found\/tweaked my own model to train on historical data from a particular stock. My question is, is it possible to train this model on more than just one stock\u2019s dataset? Every single machine learning article I\u2019ve read on time series prediction and RL uses one dataset for training and testing, but my goal is to train a model on a bunch of tickers with varying prices in the hopes that the model can recognize similar price patterns, regardless of the price or ticker so that I could apply the trained model to a new dataset and it\u2019ll work. \nRight now it trains on one ticker and it\u2019s prices, but when I try to add a new dataset for added training, it performs horribly because it doesn\u2019t know the new prices, if that makes sense. \nThis is a basic question and I don\u2019t necessarily expect a coded answer, just somewhere I could learn how to train a model using multiple datasets. I\u2019m using OpenAI gym environment if that helps anything. \nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":296,"Q_Id":53974005,"Users Score":0,"Answer":"I think normalizing the dataset with % change from previous close on all datasets could be a good start. in that way, any stock with any price seems normalized.","Q_Score":1,"Tags":"python-3.x,tensorflow,reinforcement-learning,stocks,openai-gym","A_Id":62697169,"CreationDate":"2018-12-29T23:04:00.000","Title":"Reinforcement Learning Using Multiple Stock Ticker\u2019s Datasets?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have both python2 and python3 installed on my ubuntu machine.\nAlso I have both versions of Django[Django 1.11 and Django 2.1.3] \nInstalled.\nWhenever I make a new project in django.\ndjango-admin is using Django 1.11 by default\nHow do I create a project in Django 2.1.3 instead of Django 1.11??\nI tried using virtualenv but its not working correctly ??","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":461,"Q_Id":53976077,"Users Score":0,"Answer":"Removing the old Django version works for me.","Q_Score":1,"Tags":"python,django,python-3.x,django-admin","A_Id":56469790,"CreationDate":"2018-12-30T08:02:00.000","Title":"django-admin.py is using Django 1.11 instead of Django 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have both python2 and python3 installed on my ubuntu machine.\nAlso I have both versions of Django[Django 1.11 and Django 2.1.3] \nInstalled.\nWhenever I make a new project in django.\ndjango-admin is using Django 1.11 by default\nHow do I create a project in Django 2.1.3 instead of Django 1.11??\nI tried using virtualenv but its not working correctly ??","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":461,"Q_Id":53976077,"Users Score":1,"Answer":"I was facing the same issue and I have resolved it now. You can do the following steps:\n1) Run which django-admin it should show the path to django-admin 1.11.\n2) Copy the path printed after above command. Let path be \n3) Run the following command: rm -rf <path>","Q_Score":1,"Tags":"python,django,python-3.x,django-admin","A_Id":62048015,"CreationDate":"2018-12-30T08:02:00.000","Title":"django-admin.py is using Django 1.11 instead of Django 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to edit some of the modules I installed for Python 3. I went to \/Library\/Python and the only folder I found was 2.7. This is not the folder Python 3 runs on. I tested this by installing a module in the Python 2.7 folder by using pip and trying to run it in python 3 (it does not work). Where is the folder?\nI use macOS","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1511,"Q_Id":53977536,"Users Score":0,"Answer":"Go into the terminal app, and type which python3. This will output the path where python3 is located.\nBut as Daniel says in a comment, it's really not recommended to edit anything in modules that you install.","Q_Score":0,"Tags":"python,macos","A_Id":53977609,"CreationDate":"2018-12-30T12:20:00.000","Title":"Python 3.7.2 folder cannot be located in \/Library\/Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to edit some of the modules I installed for Python 3. I went to \/Library\/Python and the only folder I found was 2.7. This is not the folder Python 3 runs on. I tested this by installing a module in the Python 2.7 folder by using pip and trying to run it in python 3 (it does not work). Where is the folder?\nI use macOS","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1511,"Q_Id":53977536,"Users Score":0,"Answer":"I just figured it out. The path is \/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/site-packages\nAlternatively, type this into terminal:\n find \/ -name (INSERT NAME OF MODULE)","Q_Score":0,"Tags":"python,macos","A_Id":53978381,"CreationDate":"2018-12-30T12:20:00.000","Title":"Python 3.7.2 folder cannot be located in \/Library\/Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"ive made a mistake with my django and messed up my model\nI want to delete it & then recreate it - how do I do that?\nI get this when I try to migrate - i just want to drop it\nrelation \"netshock_todo\" already exists\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":173,"Q_Id":53978491,"Users Score":1,"Answer":"Delete all of your migrations file except __init__.py\nThen go to database and find migrations table, delete all row in migrations table. Then run makemigrations and migrate command","Q_Score":0,"Tags":"django,python-3.x","A_Id":53978508,"CreationDate":"2018-12-30T14:34:00.000","Title":"how to delete django relation and rebuild model","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For some reason, pip just isn't installed after installing Python 2.7.15 on Windows. I know that I had the option to install pip checked. I'm using the default path, \"C:\\Python27\". This is the error I keep receiving: 'pip' is not recognized as an internal or external command,operable program or batch file.\nCould someone offer guidance?\nEDIT: There is no Scripts subfolder in my Python27 folder for some reason","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3319,"Q_Id":53983123,"Users Score":0,"Answer":"Please check:\n\npip.exe in C:\\Python27\\Scripts\n\"C:\\Python27\\Scripts\" in your Path environment variables","Q_Score":0,"Tags":"python,windows,python-2.7,pip","A_Id":53983154,"CreationDate":"2018-12-31T02:50:00.000","Title":"Pip is not installed after downloading Python 2.7.15 on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"For some reason, pip just isn't installed after installing Python 2.7.15 on Windows. I know that I had the option to install pip checked. I'm using the default path, \"C:\\Python27\". This is the error I keep receiving: 'pip' is not recognized as an internal or external command,operable program or batch file.\nCould someone offer guidance?\nEDIT: There is no Scripts subfolder in my Python27 folder for some reason","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3319,"Q_Id":53983123,"Users Score":0,"Answer":"I installed Python2.7.18, and Scripts directory wasn't there.\nI just run:\nMyPython2.7Dir\\python.exe -m ensurepip\nThat was all. Now I have the Scripts directory and pip installed as usual.","Q_Score":0,"Tags":"python,windows,python-2.7,pip","A_Id":66305604,"CreationDate":"2018-12-31T02:50:00.000","Title":"Pip is not installed after downloading Python 2.7.15 on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on a attendance registration system where a user of an office can make a leave request. When any user makes a leave request, it must be notified to admin. How do I implement it ?\nI had seen django-fcm for push notification. But I am using django rest framework . Can I implement django-fcm with django rest ? \nIf any tutorials link would be more helpful","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":545,"Q_Id":53983887,"Users Score":1,"Answer":"This is not a very hard, clone the fcm-django-web-demo project and try coding in Django shell...","Q_Score":0,"Tags":"python,django,django-rest-framework,django-notification","A_Id":53984157,"CreationDate":"2018-12-31T05:25:00.000","Title":"Push notification in django rest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"While writing a kivy app that uses java api calls through pyjnius, can you run the code on your system's OS like windows, Linux etc. to see how far you've gone and test your progress OR you can only test the code on an android device","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":137,"Q_Id":53984983,"Users Score":2,"Answer":"Pyjnius works on the desktop, but the Android APIs are not available there so you can't test your Android API calls that way. For this reason, there's not much reason to install pyjnius on the desktop if you're targeting Android.","Q_Score":0,"Tags":"android,python,mobile,kivy,pyjnius","A_Id":53992570,"CreationDate":"2018-12-31T07:54:00.000","Title":"Running pyjnius on Windows, Linux etc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I downloaded and install Anaconda 3 on my computer windows and now I'd like to add OpenCV.\nWhat's the easiest way to do it ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":53986632,"Users Score":2,"Answer":"This is how I do it on windows:\n\nOpen your anaconda prompt\nSelect your environment activate my_env (for base env skip this step)\nInstall opencv using pip install opencv-python\nFurther install additional pkgs using pip install opencv-contrib-python","Q_Score":0,"Tags":"python,opencv,installation,anaconda","A_Id":53986699,"CreationDate":"2018-12-31T10:56:00.000","Title":"How can I install Open CV after I installed Python 3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to install a library called \"Scrapy\" for Python on Windows. The developers recommend installing the package using Anaconda instead of Python3. However, will i be able to use the package in Python3 or will i need to use Anaconda for Web Scraping?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":6393,"Q_Id":53987077,"Users Score":1,"Answer":"Anaconda is a python distribution which contains additional packages to the python it ships with. To have lightweight version of python (without many additional packages), you can install Miniconda. Anaconda and Miniconda come with the conda package manager. You can use it to install and update packages specific to its python distribution.\nTo install scrapy package using Anaconda \/ Miniconda, in the Windows Command Prompt simply type in:\nconda install scrapy","Q_Score":1,"Tags":"python,scrapy,anaconda","A_Id":53987271,"CreationDate":"2018-12-31T11:43:00.000","Title":"Install packages in Anaconda and using it in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to install a library called \"Scrapy\" for Python on Windows. The developers recommend installing the package using Anaconda instead of Python3. However, will i be able to use the package in Python3 or will i need to use Anaconda for Web Scraping?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6393,"Q_Id":53987077,"Users Score":0,"Answer":"In Anaconda you can install almost all python packages using conda install or pip install.\nYou have to goto Anaconda prompt and type in pip install Scrapy","Q_Score":1,"Tags":"python,scrapy,anaconda","A_Id":53987292,"CreationDate":"2018-12-31T11:43:00.000","Title":"Install packages in Anaconda and using it in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use Scrapy shell to try and figure out the selectors for zone-h.org. I run scrapy shell 'webpage' afterwards I tried to view the content to be sure that it is downloaded. But all I can see is a dash icon (-). It doesn't download the page. I tried to enter the website to check if my connection to the website is somehow blocked, but it was reachable. I tried setting user agent to something more generic like chrome but no luck there either. The website is blocking me somehow but I don't know how can I bypass it. I digged through the the website if they block crawling and it doesn't say it is forbidden to crawl it. Can anyone help out?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":621,"Q_Id":53988585,"Users Score":0,"Answer":"Can you use scrapy shell \"webpage\" on another webpage that you know works\/doesn't block scraping?\nHave you tried using the view(response) command to open up what scrapy sees in a web browser?\nWhen you go to the webpage using a normal browser, are you redirected to another, final homepage?\n- if so, try using the final homepage's URL in your scrapy shell command\nDo you have firewalls that could interfere with a Python\/commandline app from connecting to the internet?","Q_Score":1,"Tags":"python,scrapy,web-crawler","A_Id":53989874,"CreationDate":"2018-12-31T14:33:00.000","Title":"Scrapy shell doesn't crawl web page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to figure out some of the hyperparamters used for training some old keras models I have.  They were saved as .h5 files.  When using model.summary(), I get the model architecture, but no additional metadata about the model.\nWhen I open this .h5 file in notepad++, most of the file is not human readable, but there are bits that I can understand, for instance;\n\n{\"loss_weights\": null, \"metrics\": [\"accuracy\"], \"sample_weight_mode\":\n  null, \"optimizer_config\": {\"config\": {\"decay\": 0.0, \"momentum\":\n  0.8999999761581421, \"nesterov\": false, \"lr\": 9.999999747378752e-05}, \"class_name\": \"SGD\"}, \"loss\": \"binary_crossentropy\"}\n\nwhich is not present in the output printed by model.summary().\nIs there a way to make these files human readable or to get a more expanded summary that includes version information and training parameters?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":3271,"Q_Id":53988984,"Users Score":1,"Answer":"Configuration - model.get_config()\nOptimizer config - model.optimizer.get_config()\nTraining Config  model.history.params (this will be empty, if model is saved and reloaded)\nLoss Fuction - model.loss","Q_Score":6,"Tags":"python,keras,hdf5","A_Id":67994767,"CreationDate":"2018-12-31T15:23:00.000","Title":"Get training hyperparameters from a trained keras model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using the peewee ORM to manage a few Postgres databases. I've recently had a problem where the primary keys are not being automatically added when save() or execute() is called like it should be.\nHere's the code that's being called:\nMacro.insert(name=name, display_text=text).on_conflict(conflict_target=(Macro.name,), preserve=(Macro.display_text,), update={Macro.name: name}).execute()\n\nHere's the error:\nCommand raised an exception: IntegrityError: null value in column \"id\" violates non-null constraint; \nDETAIL: Failing row contains (null, nametexthere, displaytexthere)\nThe macro class has an id (AutoField [set to be primary key]), name (CharField), and display_text (CharField). I've tried using the built in PrimaryKeyField and an IntegerField set to primary key to no change.\nBefore, I was using Heroku with no issue. I've since migrated my apps to my Raspberry Pi and that's when this issue popped up.\nThis also isn't the only case where I've had this problem. I have another database with the same AutoField primary key that seems to have broken from the transition from Heroku to Pi. That one uses the save() method rather than insert()\/execute(), but the failing row error still shows up.\nShould also mention that other non-insert queries work fine. I can still select without issue.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":344,"Q_Id":53992747,"Users Score":1,"Answer":"The problem didn't have anything to do with Peewee, it had to do with the dump. Heroku does not dump sequences for you automatically, so I had to add them all again manually. Once those was added the connections worked fine.","Q_Score":0,"Tags":"python,postgresql,peewee","A_Id":53996728,"CreationDate":"2019-01-01T02:50:00.000","Title":"Peewee primary keys not showing up (Failing row contains null)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to bind\/map a global hotkey, which also works when application window is minimized and user not focused on it. I'm looking for a cross-platform way. Can I do this using Tkinter?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1252,"Q_Id":53995857,"Users Score":3,"Answer":"I want to bind\/map a global hotkey, which also works when application window minimized and not focused on it. I'm looking for a cross-platform way.\n\nYou can't do that with tkinter. Tkinter has no support for this.","Q_Score":2,"Tags":"python,tkinter,cross-platform,global-hotkey","A_Id":53997224,"CreationDate":"2019-01-01T13:32:00.000","Title":"How bind\/map global hotkey when using Python Tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a job that uses the multiprocessing package and calls a function via \nresultList = pool.map(myFunction, myListOfInputParameters). \nEach entry of the list of input parameters is independent from others.\nThis job will run a couple of hours. For safety reasons, I would like to store the results that are made in between in regular time intervals, like e.g. once an hour.\nHow can I do this and be able to continue with the processing when the job was aborted and I want to restart it based on the last available backup?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":787,"Q_Id":53996035,"Users Score":2,"Answer":"There are at least two possible options.\n\nHave each call of myFunction save its output into a uniquely named file. The file name should be based on or linked to the input data. Use the parent program to gather the results. In this case myFunction should return an identifier of the item that is finished.\nUse imap_unordered instead of map. This will start yielding results as soon as they are available, instead of returing when all processing is finished. Have the parent program save the returned data and a indication which items are finished.\n\nIn both cases, the program would have to examine the data saved from previous runs to adjust myListOfInputParameters when it is being re-started.\nWhich option is best depends to a large degree on the amount of data returned by myFunction. If this is a large amount, there is a significant overhead associated with transferring it back to the parent. In that case option 1 is probably best.\nSince writing to disk is relatively slow, calculations wil probably go faster with option 2. And it is easier for the parent program to track progress.\nNote that you can also use imap_unordered with option 1.","Q_Score":5,"Tags":"python,python-multiprocessing","A_Id":53996462,"CreationDate":"2019-01-01T13:55:00.000","Title":"Dump intermediate results of multiprocessing job to filesystem and continue with processing later on","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If num_workers is 2, Does that mean that it will put 2 batches in the RAM and send 1 of them to the GPU or Does it put 3 batches in the RAM then sends 1 of them to the GPU?\nWhat does actually happen when the number of workers is higher than the number of CPU cores? I tried it and it worked fine but How does it work? (I thought that the maximum number of workers I can choose is the number of cores).\nIf I set num_workers to 3 and during the training there were no batches in the memory for the GPU, Does the main process waits for its workers to read the batches or Does it read a single batch (without waiting for the workers)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54707,"Q_Id":53998282,"Users Score":71,"Answer":"When num_workers>0, only these workers will retrieve data, main process won't. So when  num_workers=2 you have at most 2 workers simultaneously putting data into RAM, not 3.\nWell our CPU can usually run like 100 processes without trouble and these worker processes aren't special in anyway, so having more workers than cpu cores is ok. But is it efficient? it depends on how busy your cpu cores are for other tasks, speed of cpu, speed of your hard disk etc. In short, its complicated, so setting workers to number of cores is a good rule of thumb, nothing more.\nNope. Remember DataLoader doesn't just randomly return from what's available in RAM right now, it uses batch_sampler to decide which batch to return next. Each batch is assigned to a worker, and main process will wait until the desired batch is retrieved by assigned worker.\n\nLastly to clarify, it isn't DataLoader's job to send anything directly to GPU, you explicitly call cuda() for that. \nEDIT: Don't call cuda() inside Dataset's __getitem__() method, please look at @psarka's comment for the reasoning","Q_Score":70,"Tags":"python,memory-management,deep-learning,pytorch,ram","A_Id":54002191,"CreationDate":"2019-01-01T19:23:00.000","Title":"How does the \"number of workers\" parameter in PyTorch dataloader actually work?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a folder with around several thousand RGB 8-bit-per-channel image files on my computer that are anywhere between 2000x2000 and 8000x8000 in resolution (so most of them are extremely large).\nI would like to store some small value, such as a hash, for each image so that I have a value to easily compare to in the future to see if any image files have changed.  There are three primary requirements in the calculation of this value:\n\nThe calculation of this value needs to be fast\nThe result needs to be different if ANY part of the image file changes, even in the slightest amount, even if just one pixel changes.  (The hash should not take filename into account).\nCollisions should basically never happen.\n\nThere are a lot of ways I could go about this, such as sha1, md5, etc, but the real goal here is speed, and really just any extremely quick way to identify if ANY change at all has been made to an image.\nHow would you achieve this in Python?  Is there a particular hash algorithm you recommend for speed?  Or can you devise a different way to achieve my three goals altogether?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":585,"Q_Id":54000349,"Users Score":1,"Answer":"The calculation of this value needs to be fast\nThe result needs to be different if ANY part of the image file changes, even in the slightest amount, even if just one pixel changes.\n  (The hash should not take filename into account).\nCollisions should basically never happen.\n\n\n\nHash calculation (may differ according to the hashing algorithm) of large files take time, if it needs to be fast, try to choose an efficient hashing algorithm for your task. You can find information about how they compare to each other. But, before checking hash, you can optimize your algorithm by checking something else.\nIf you decided to use hashing, this is the case. The hash value will be changed even if a small part of image has changed.\nCollisions may be (very rare, but not never) happen. This is the nature of hash algorithms\n\nExample to 1st (optimizing algorithm),  \n\nCheck file size.\nIf sizes are equal, check CRC\nIf CRCs are equal, then calculate and check hash. (both requires passing the file)\n\nOptionally, before checking hashes, you can partially calculate and compare hashes, instead of all the file.\nIf most of your files will be more likely different, then checking other things before calculating hash probably will be faster.\nBut if most of your files will be identical, then the steps before the hashing will just consume more time. Because you'll already have to calculate the hash for most of files.\nSo try to implement most efficient algorithm according to your context.","Q_Score":0,"Tags":"python,database,python-3.x,image,hash","A_Id":54000556,"CreationDate":"2019-01-02T01:44:00.000","Title":"Hashing 1000 Image Files Quick as Possible (2000x2000 plus resolution) (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 see the entire row for a dask dataframe without the fields being cutoff, in pandas the command is pd.set_option('display.max_colwidth', -1), is there an equivalent for dask? I was not able to find anything.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2155,"Q_Id":54002006,"Users Score":0,"Answer":"Dask does not normally display the data in a dataframe at all, because it represents lazily-evaluated values. You may want to get a specific row by index, using the .loc accessor (same as in Pandas, but only efficient if the index is known to be sorted).\nIf you meant to get the whole list of columns only, you can get this by the .columns attribute.","Q_Score":3,"Tags":"python-3.x,dask","A_Id":54008906,"CreationDate":"2019-01-02T06:13:00.000","Title":"Dask Dataframe View Entire Row","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using TensorFlow for training my own dataset using capsule network. While training mnist dataset, it contains function mnist.train.next_batch(batch size). How to replace this function for training own dataset using TensorFlow?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":472,"Q_Id":54002301,"Users Score":0,"Answer":"The function sample batch_size number of samples from a shuffled training dataset, then return the batch for training.\nYou could write your own next_batch() method that does the same thing, or modify it as you wish. Then use it similarly when you're training your model.","Q_Score":0,"Tags":"python,tensorflow","A_Id":54002342,"CreationDate":"2019-01-02T06:46:00.000","Title":"What is use of function mnist.train.next_batch() in training dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am in the process of creating custom Python libraries with simple functions I use in other projects. My main IDE for using Python is Visual Studio Code, and I find its Python Intellisense very useful.\nIs there a way to write or include my own custom documentation for my libraries that will show up in VS Code Intellisense?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":419,"Q_Id":54003094,"Users Score":0,"Answer":"As UnholySheep mentioned above, VS Code supports Python docstrings. Including these in my code provided the desired result.","Q_Score":0,"Tags":"python,visual-studio-code,intellisense","A_Id":54003274,"CreationDate":"2019-01-02T08:08:00.000","Title":"How to create custom VS Code Intellisense documentation for a Python library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to generate an avro file from mysql table. I'm currently using pandavro. But pandavro not yet supports datetime datatype. How can I solve the problem? Not using pandavro is fine.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":210,"Q_Id":54003472,"Users Score":1,"Answer":"(1) Convert the datetimes to strings via strftime.\n(2) The strings should then write to the avro.\n(3) Convert datestrings back to datetime when reading the avro.\nSomething else to consider is using a parquet file, which supports datetime.","Q_Score":1,"Tags":"python,mysql,avro","A_Id":57539779,"CreationDate":"2019-01-02T08:50:00.000","Title":"Python : Generate avro schema using pandavro invalid datatype64[ns]","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 3-4 django background_tasks which run in parallel, and I want to stop all tasks except a single one of them. background_task is a built-in library in django. How can I solve this issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1231,"Q_Id":54005945,"Users Score":0,"Answer":"First need to stop the process\/tab that is running python manage.py process_tasks.\nNext, delete the task you no longer need from the database - you can find this in the admin panel, then, restart the process\npython manage.py process_tasks","Q_Score":0,"Tags":"python,django,background-task","A_Id":57543746,"CreationDate":"2019-01-02T11:57:00.000","Title":"How can i stop django background task permanently which is running parallely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm a self-taught programmer and a lot of the problems I encounter come from a lack of formal education (and often also experience).\nMy question it the following: How to rationalize where you store the data a class or function creates? I'll make a simple example:\nCase: I have a webshop (SHOP) with a REST api and a product provider (PROVIDER) also with a REST API. I determine the product, I send that data to PROVIDER who sends me back formatted data that can be read by SHOP to make a working product on the webshop. PROVIDER also has a secondary REST api that provides generated images.\nWhat I would come up with:\nI'd make three classes: ProductBase, Shop and Provider\nProductBase would be the class from where I instantiate and store the individual product information.\nShop would be where I design the api interactions with the webshop.\nProvider same as shop, but for interactions with provider api.\nMy problem: At some point you're creating data that's not clearly separated in concern. For example: Would I store the generated product data (from PROVIDER) in the ProductBase instance I created? It feels like I'm coupling the two classes this way. But it not there, then where?\nWhat if I create product images with PROVIDER and I upload them to SHOP? Do I store the uploaded image-url in PRODUCT? How do you keep track of all this info?  \nThe question I want answered:\nI've read a lot on OOP and Design Patterns, and I have adopted a TDD approach which has greatly helped to improve my code but I haven't found anything on how to approach the flow of at runtime generated data within software engineering.  \nWhat would be a good way to solve above problem(s) and could you explain your rationale for it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":54006609,"Users Score":1,"Answer":"If I understand correctly, I think your current concern is that you have \"raw\" product data, which you want to store in objects, and you have \"processed\" (formatted) product data, which you also want to store in objects. Your question being should you mix them.\nLet me just first point out the other obvious option. Namely, having two product classes: RawProduct and ProcessedProduct. Which to do?\n(Edit: also, to be sure, product data should not be stored in provider. The provide performs the action of formatting but the data is product data. Not provider data).\nIt depends. There are a couple of considerations:\n1) In general, in OOP, the idea is to couple actions on data with the data. So if possible, you have some method in ProductBase like \"format()\", where format will send the object off to the API to get formatted, and store the result in an instance variable. You can then also have a method like \"find_image\", that goes and fetches the image url from the API and then stores that in a field. An object's data is meant to be dynamic. It is meant to be altered by object methods.\n2) If you need version control (if you want the full history of the object's state to be available), then you can't override fields with new data. So either you need to store a history of every object field in the object, or you need to create new objects. \n3) Is RAM a concern? I sometimes create dataclasses that store only the final part of an object's life so that I can fit more of the objects into memory.\nPersonally I often find myself creating \"RawObject\" and \"ProcessedObject\" classes, it's just easier a lot of the time. But that's probably because I mostly work with document processing, so it's very clear. Usually You'll just update the objects data.\nA benefit of having one object with the full history is that it is much easier to debug. Because the raw data and the API result are in the same object. So you can very easily probe what went wrong. If you start splitting things up it's harder to track. In general, the more information an object has about where it's been, the easier it is to figure out what went wrong with it.\nRemember also though, since this is a Python question, Python is multi-paridigm. And if you're writing pipeline-style architectures (synchronous, linear processes), then a functional approach can also work well. \nOnce your data is stored in a product object, anything can hold a reference to that. So a shop can reference an object and a product can reference the object. Be clear on the difference between \"has-a\" relationships and \"is-a\" relationships.","Q_Score":0,"Tags":"python,rest,class,design-patterns,runtime","A_Id":54006993,"CreationDate":"2019-01-02T12:42:00.000","Title":"What to do with runtime generated data spanning several classes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Let's assume we have defined two functions f(x) and g(x) in Python.\nFor each x, like x = 7, h = f(7) * g(7) is a number. \nHowever, if we attempt to assign the function h = f * g of the type\nTypeError: unsupported operand type(s) for *: 'function' and 'function'\nMy question is: Why is it not trivial in Python to do such an operation (from the point of view of how Python works)? Surely, in many situations, given two functions, we'd like to be able to manipulate the function that gives their point wise product?\nOr is it simply that such cases never occur? Indeed, we could readily define the function f(x)*g(x).","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":300,"Q_Id":54007457,"Users Score":3,"Answer":"Or is it simply that such cases never occur? Indeed, we could readily\n  define the function f(x)*g(x).\n\nYou are right. There should only be one way of doing something, and that one way is defining a new function. As an aside, the notation f * g is ambiguous as, in many contexts, it represents function composition, i.e. f(g(x)).","Q_Score":1,"Tags":"python,python-3.x","A_Id":54007532,"CreationDate":"2019-01-02T13:43:00.000","Title":"Multiplication of functions in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using PySpark and have added a couple of jars to $SPARK_HOME\/jars but I am getting py4j.protocol.Py4JError: ClassName does not exist in the JVM error. \nIs there a way I can list all the classes in jvm (sc._jvm)?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":274,"Q_Id":54007463,"Users Score":1,"Answer":"You have already fixed the issue by downgrading the PySpark version, I am just posting this answer for context and future reference.\nThe are no simultaneous stable spark releases with the current version of PySpark 2.4.0 and using different versions of spark causes compatibility issues.\nI suggest first check the PySpark version and make sure it matches the spark version.\nYou should also add PYTHONPATH system environment variable with the value \n%SPARK_HOME%\\python;%SPARK_HOME%\\python\\lib\\py4j-<version>-src.zip:%PYTHONPATH% \nspark\/python\/lib contains the py4j version information that you can edit the version part of the variable above","Q_Score":1,"Tags":"python,apache-spark,pyspark","A_Id":54009252,"CreationDate":"2019-01-02T13:44:00.000","Title":"Get a list of all available classes in the JVM in PySpark","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently scraping a website for work to be able to sort the data locally, however when I do this the code seems to be incomplete, and I feel may be changing whilst I scroll on the website to add more content. Can this happen ? And if so, how can I ensure I am able to scrape the whole website for processing?\nI only currently know some python and html for web scraping, looking into what other elements may be affecting this issue (javascript or ReactJS etc). \nI am expecting to get a list of 50 names when scraping the website, but it only returns 13. I have downloaded the whole HTML file to go through it and none of the other names seem to exist in the file, i.e. why I think the file may be changing dynamically","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":54008539,"Users Score":0,"Answer":"Yes, the content of the HTML can be dynamic, and Javascript loading should be the most essential . For Python, scrapy+splash maybe a good choice to get started. \nDepending on how the data is handled, you can have different methods to handle dyamic content HTML","Q_Score":0,"Tags":"python,web-scraping","A_Id":54008662,"CreationDate":"2019-01-02T14:59:00.000","Title":"The HTML code I scrape seems to be incomplete in comparison to the full website. Could the HTML be changing dynamically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to create workflow in Python that will have the following features below:\n\n\nDynamic scheduling.\nParallelism - many threads within one process.\nRunning a flow same as running a task.\nWorks on Windows.\n\n\nFrom the knowledge that i get it's seems that 1) & 3) are achievable in many workflow frameworks, but 2) is not that easy. In my research i was mostly looked at Celery & Luigi frameworks.\n\nFor Celery I did found out that 2 could be done using the --pool argument, so I would like to know if I can combine the worker & the trigger to the same python module?\nFor Luigi I would like to know if it's possible to run tasks as multi-threads and not multi-processes?\n\nIn addition I would appreciate any suggestions for other Python framework that could help me before I start to create my own workflow?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":874,"Q_Id":54012328,"Users Score":0,"Answer":"In luigi, it is possible for the tasks themselves to use multithreading, but in luigi each worker will itself be a process, as it can run on a different machine. You could run with just one worker if you have something against having two processes.\nAnother one to look at is airflow.","Q_Score":0,"Tags":"python,frameworks,celery,workflow,luigi","A_Id":54027527,"CreationDate":"2019-01-02T19:51:00.000","Title":"Workflow framework in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to code a bot for discord and I need to run python -m pip install youtube_dl, but whenever I do, I always receive a syntax error on the pip part. I am running it in command line, and I'm fairly certain I set the path to wher python is installed, but it's still not working. Any ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":54013649,"Users Score":0,"Answer":"try running pip install youtube_dl as admin","Q_Score":0,"Tags":"python","A_Id":54013677,"CreationDate":"2019-01-02T21:52:00.000","Title":"Why is pip not working even though its in command line and using -m?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a time conversion app using python. So what I want to implement in the project is that, when the user change the combobox, the value automatically change\/converted depending on the units. For example, I have a base value of 1 second, if I select millisec, the value will be converted. If I select again a unit under combobox, the base number \"1\" will be converted instead of the value in millisec.\nIs there a good logic about this? been trying things like when the user click the combobox, last value will be stored. But again, I want the base value to be converted.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":54015337,"Users Score":1,"Answer":"I'm assuming the 'value' is inputted by some means such as an input box or etc. I am also assuming that you are trying to display the result in that same input box (or whatever component you are using).\nIf this is the case, you could hook onto when the value is changed and store the value it is changed to in some variable - your base value. When you programatically update the input box with the converted value, make sure the component is updated but the hooked function is not called. If this is not supported in whatever UI framework you are using, then you can make use of boolean flags:\n\nDeclare a flag which shall store whether or not the base value has been entered (initially false)\nDeclare a variable to store the base value\nHook onto when the component is changed.\nWhen the component is changed, if the flag is false, store the value of the component in that base value variable you declared and set the flag to true. Otherwise, if the flag is true, don't do anything.\nDo your calculations, etc and update the component programatically \nOnce you have updated the component programatically, reset the flag to false.","Q_Score":0,"Tags":"python,time","A_Id":54015435,"CreationDate":"2019-01-03T01:40:00.000","Title":"Automatic Conversion Depending on Units in ComboBox","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Load OpenModelica FMU-module (with MSL noise-module) in Python environment with PyFMI does not work.\nI have tried to run exported FMU-modules from OpenModelica in PyFMI-environment. Deterministic models works fine.\nHowever, when I include noise models using the MSL block Modelica.Blocks.Noise.NormalNoise Then I get an FMU that get problems when loading into the PyFMI-environment. The error text ends with:\nFMUException: Error loading the binary. Could not load the DLLL: libModelicaExternalC.so.0: cannot open shared object file: No such file or directory.\nNeedless to say, but in OpenModelica the system with noise works well. The same code in JModelica and compiled and loaded in the Python environment with PyFMI also works well. However, the random noise sequence are different for the same seed in OpenModelica and JModelica indicating some difference. \nFor this example I run JModelica and PyFMI version 2.1 in Docker Linux and OpenModelica is also run in Linux environment. Since Linux in both I can transfer the FMU-model. Both JModelica and OpenModelica support the Modelica standard 3.2.2 and corresponding MSL.\nI have also just tested the example with JModelica and PyFMI version 2.4 (or at least 2.2) using Docker Linux image from mclab. I get the same error text as for 2.1 (and without noise block it works as it did for 2.1). \n\u2014\nMy question is if the described error is on PyFMI or OpenModelica side or perhaps both? Or is there something extra to be done when exporting an FMU from OpenModelica with noise-block that should make it all work?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":561,"Q_Id":54019129,"Users Score":2,"Answer":"From the error message, it indicates that the FMU is missing one of its dependencies, libModelicaExternalC.so (all dependencies of an FMU should be included in the FMU). The problem lies in the generating tool of the FMU, not in PyFMI.","Q_Score":1,"Tags":"python,openmodelica,fmi,jmodelica","A_Id":54038212,"CreationDate":"2019-01-03T09:04:00.000","Title":"FMU-module and transfer from OpenModelica to Python with PyFMI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Load OpenModelica FMU-module (with MSL noise-module) in Python environment with PyFMI does not work.\nI have tried to run exported FMU-modules from OpenModelica in PyFMI-environment. Deterministic models works fine.\nHowever, when I include noise models using the MSL block Modelica.Blocks.Noise.NormalNoise Then I get an FMU that get problems when loading into the PyFMI-environment. The error text ends with:\nFMUException: Error loading the binary. Could not load the DLLL: libModelicaExternalC.so.0: cannot open shared object file: No such file or directory.\nNeedless to say, but in OpenModelica the system with noise works well. The same code in JModelica and compiled and loaded in the Python environment with PyFMI also works well. However, the random noise sequence are different for the same seed in OpenModelica and JModelica indicating some difference. \nFor this example I run JModelica and PyFMI version 2.1 in Docker Linux and OpenModelica is also run in Linux environment. Since Linux in both I can transfer the FMU-model. Both JModelica and OpenModelica support the Modelica standard 3.2.2 and corresponding MSL.\nI have also just tested the example with JModelica and PyFMI version 2.4 (or at least 2.2) using Docker Linux image from mclab. I get the same error text as for 2.1 (and without noise block it works as it did for 2.1). \n\u2014\nMy question is if the described error is on PyFMI or OpenModelica side or perhaps both? Or is there something extra to be done when exporting an FMU from OpenModelica with noise-block that should make it all work?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":561,"Q_Id":54019129,"Users Score":3,"Answer":"In OMEdit, set Platfoms to \"Static\" in Tools->Options->FMI before generating the FMU.","Q_Score":1,"Tags":"python,openmodelica,fmi,jmodelica","A_Id":54076154,"CreationDate":"2019-01-03T09:04:00.000","Title":"FMU-module and transfer from OpenModelica to Python with PyFMI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to display documentation of numpy functions from jupyter notebook? \nhelp(linspace) did not work for me","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":55,"Q_Id":54019510,"Users Score":1,"Answer":"Highlight and press SHIFT + TAB.","Q_Score":1,"Tags":"python,jupyter-notebook","A_Id":54019576,"CreationDate":"2019-01-03T09:31:00.000","Title":"Documentations for Numpy Functions in Jupyter","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run my sample code containing functions but get the following error when running from the command line.\n\npython: can't open file 'Functions.py': [Errno 2\n\nI have checked my environment variables and also reviewed my code. I am currently using JetBrains Pycharm 2018.3.2 version, could this be the issue?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":54019988,"Users Score":0,"Answer":"Errno 2 points out at a file or directory not being found (in this case 'Functions.py'). Could you check whether your path to Functions.py is correct?","Q_Score":0,"Tags":"python,pycharm","A_Id":54020040,"CreationDate":"2019-01-03T10:00:00.000","Title":"python: can't open file 'Functions.py': [Errno 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a scenario to pass the processing file names between the DAG's which is used for loading my data. Is there any functionality for the same in airflow? I hope that XCOM allows only passing file names between tasks in the same DAG.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1089,"Q_Id":54020319,"Users Score":0,"Answer":"I was able to implement it using below options in the operator.\npython_callable=conditionally_trigger,\nparams={\"condition_param\": True, \"message\": \"filename\"},","Q_Score":0,"Tags":"python-3.x,airflow","A_Id":54089296,"CreationDate":"2019-01-03T10:20:00.000","Title":"Pass a value from one DAG to another DAG in Apache Airflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been programming a Python desktop app in Python 3.7 with tkinter. Many of my friends have said using it as an mobile application will get more users. I have been working with sklearn and different modules in Python to run along side the GUI. Is it possible to call that script in Kotlin?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2094,"Q_Id":54021771,"Users Score":1,"Answer":"Yes it is possible.\nPython has REPL, it's own interactive interpreter and as it turns out Kotlin has a REPL as well. You'll still have to do research and find the interfaces to use with your front end.\nNOTE: In Intellij Idea Kotlin has REPL. I'm afraid I don't know if it's the same with other IDEs. \nIf it's only for Android, you can use QPython.\nQPython is a script engine which runs Python programs on android devices.","Q_Score":1,"Tags":"android,python-3.x,kotlin","A_Id":54022074,"CreationDate":"2019-01-03T11:52:00.000","Title":"Is there a way to call Python script inside of a Kotlin project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"trying to install tensorflow using conda package manager\nusing following command\n\nconda install -c conda-forge tensorflow\n\nbut it gives following error while executing transaction\n\nCondaError: Cannot link a source that does not exist.\n  C:\\ProgramData\\Anaconda3\\Scripts\\conda.exe","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2069,"Q_Id":54024671,"Users Score":0,"Answer":"Try to run conda clean --all --yes and conda update anaconda.\nDo you have a conda.exe file in the following folder C:\\ProgramData\\Anaconda3\\Scripts\\?\nDo you use the latest Conda?\nAnother solution could be to create a conda environments conda create -n name_environment pip python=3.5 and using pip to install tensorflow pip install tensorflow inside the new environment \nafter having activated it (activate name_environment).\nP.S. I can not write a comment because I do not have enough reputation.\nEDIT - Now i can!","Q_Score":3,"Tags":"python,tensorflow,anaconda,conda","A_Id":54025044,"CreationDate":"2019-01-03T14:52:00.000","Title":"error while installing tensorflow in conda environment (CondaError: Cannot link a source that does not exist.)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently asked a question with title \"python find the type of a function\" and got very helpful answers. Here is a related question.\nSuppose I import *.py files written by me, and these imports result in f being one of the functions defined by me. Now I write to my python interpreter x = f. Later, I want to see the full definition of f, preferably with comments still in place, knowing only x. Is this possible? Does python remember which file the definition was imported from, which is, of course, not enough to give the full definition of f, unless one can find the actual relevant definition?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1131,"Q_Id":54024832,"Users Score":1,"Answer":"You should think of the way Python uses variables. You have objects (can be classes, functions, lists, scalars or whatelse) and variables that only hold references to those objects.\nThat explains why when multiple variables point to the same mutable object, if you change it through one of those variables, the change in visible in all other ones.\nThis is the same thing here. The function object manages all its attributes: its docstring, its code, and its source (if it has: C function show no source). Assigning the function to a new variable does not hide the object behind anything: you still access the original object.\nThings would go differently with decorators, because the decorator creates a new object, and the original object is only available to the decorated one.","Q_Score":2,"Tags":"python,python-3.x,python-import","A_Id":54025751,"CreationDate":"2019-01-03T15:02:00.000","Title":"python see the full definition from the name of the function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to set an environment variable in Jenkins that I want my python script in Github to use. I can access variables once they're not a collection but i would like to set a collection variable. In this case, a list.\nI have a list variable like:\nlist = [\"item1\",\"item2\"]\nWhen i try to print it from Jenkins using: \nprint(os.environ['list']) it prints the whole list as a single string and using print(type(os.environ['list'])) prints \"string\".","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1678,"Q_Id":54026662,"Users Score":-1,"Answer":"Create a string variable in jenkins and then use str.split() in the python script to make a list.\nIn Jenkins: jenkinslist = item1 item2 item3\nIn Github\/python: pythonlist = os.environ['jenkinslist'].split()","Q_Score":0,"Tags":"python,list,jenkins","A_Id":54027239,"CreationDate":"2019-01-03T17:01:00.000","Title":"Python list as environment variable in Jenkins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I write a program in python3.6 under PyCharm in Ubuntu 18.04\nI want to pop up a jpg-file on specific window-coordinates. The only possible way to do this seems to be usage of eog and wmctrl.\nI did not find an imageviewer, who is able to position the jpg-file exatly where i want (not eog, qiv, ..or others, they miss these options) \nSo I use \neog filename.jpg to pop ist up.\nThen the wmctrl-command to place it on the screen\nDoing on console in unix(Ubuntu):\neog filename.jpg -->   eog pops it up centered.\nwmctrl -a filename.jpg -e 0,10,0,600,2000  --> places it, where I want\n(It doesn't matter from which directory I call eog, it also can be with directory \/home\/user\/......(filename.jpg). For wmctrl in each case only filename.jpg is sufficent. (Also \"wmctrl -r filename.......  works)\nDoing the same from Pythone-console, it works perfectly, too.\nBut: when I do the some from programcode with\ncmd = \"eog filename.jpg\"\nos.system(cmd)  (or os.system(\"cmd\"), pop-up of the file centered on the screen works\nBUT:\ncmd = \"wmctrl -a filename.jpg -e 0,10,0,600,2000\" \nos.systems(cmd)  -------> nothing happens, as if the os.system() command is ignored\nAny idea, what could be wrong is appreciated  !\n(I first thought, I run into problems with filename and specific characters, but it also happens with simple names like test.jpg or so.)\non Python-console i also use \ncmd =...........   and\nos.system(cmd) after \"import os\"","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":54030399,"Users Score":0,"Answer":"Sorry: I solved it by myself.\nIt only needs a pause before the wmctrl-command is fired !\nimport time\ntime.sleep(2)      does the job (may be, 1 second also is enough)\n(doing it on the console, through typing you get the pause automatically)","Q_Score":1,"Tags":"python,ubuntu,os.system,wmctrl","A_Id":54031064,"CreationDate":"2019-01-03T22:01:00.000","Title":"difference command in python3 console and python3 program code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"On my windows machine I created a virtual environement in conda where I run   python 3.6. I want to permanently add a folder to the virtual python path environment. If I append something to sys.path it is lost on exiting python. \nOutside of my virtual enviroment I can just add to user variables by going to advanced system settings. I have no idea how to do this within my virtual enviroment.\nAny help is much appreciated.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":4348,"Q_Id":54031169,"Users Score":-1,"Answer":"If you are on Windows 10+, this should work:\n1) Click on the Windows button on the screen or on the keyboard, both in the bottom left section. \n2) Type \"Environment Variables\" (without the quotation marks, of course).\n3) Click on the option that says something like \"Edit the System Environment Variables\"\n4) Click on the \"Advanced Tab,\" and then click \"Environment Variables\" (Near the bottom)\n5) Click \"Path\" in the top box - it should be the 3rd option - and then click \"Edit\" (the top one)\n6) Click \"New\" at the top, and then add the path to the folder you want to create. \n7) Click \"Ok\" at the bottom of all the pages that were opened as a result of the above-described actions to save. \nThat should work, please let me know in the comments if it doesn't.","Q_Score":3,"Tags":"python,virtualenv","A_Id":54031279,"CreationDate":"2019-01-03T23:22:00.000","Title":"How to add to pythonpath in virtualenvironment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I have 20,000 features on map, and each feature have many attributes (as well as the latitude and longitude). One of the attributes called population.\nI want to split these 20,000 features into 3 clusters where the total sum of population of each cluster are equal to specific value 90,000 and features in each cluster should be near each others(ie will take locations in our consideration)\nSo, the output clusters should have the following conditions:\n\nSum(population) of all points\/items\/features in cluster 1=90,000\nSum(population) of all points\/items\/features in cluster 2=90,000\nSum(population) of all points\/items\/features in cluster 3=90,000\n\nI tried to use the k-mean clustering algorithm which gave me 3 clusters, but how to force the above constraint (sum of population should equal 90,000)\nAny idea is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":791,"Q_Id":54031283,"Users Score":1,"Answer":"A turnkey solution will not work for you.\nYou'll have to formulate this as a standard constraint optimization problem and run a silver to optimize this. It's fairly straightforward: take the k-means objective and add your constraints...","Q_Score":0,"Tags":"python,cluster-analysis,mean,arcgis","A_Id":54032226,"CreationDate":"2019-01-03T23:38:00.000","Title":"k means clustering with fixed constraints (sum of specific attribute should be less than or equal 90,000)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on my Raspberry Pi, that is handling some WS2812B RGB-LEDs. I can control the light and everything with the neopixel library and Python. So fine right now.\nI want this Python script running an infinite loop that only deals with light management. Dimming LEDs, changing color and lots more. But, I want to be able to get commands from other scripts. Let's say I want to type in a shell command that will change the color. In my infinite Python script (LED Handler), I will be able to recognize this command and change the color or the light mode softly  to the desired color. \nOne idea is, to constantly look into a text file, if there is a new command. And my shell script is able to insert command lines into this text file.\nBut can you tell me, if there is a better solution of doing it?\nMany thanks in advance.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":140,"Q_Id":54031676,"Users Score":0,"Answer":"Another solution is to allow commands from a network connection. The script with the \"infinite loop\" will read input from a socket and perform the commands.","Q_Score":2,"Tags":"python","A_Id":54031710,"CreationDate":"2019-01-04T00:29:00.000","Title":"Running infinite loop and getting commands from \"outside\" (e.g. shell or other 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 am working on my Raspberry Pi, that is handling some WS2812B RGB-LEDs. I can control the light and everything with the neopixel library and Python. So fine right now.\nI want this Python script running an infinite loop that only deals with light management. Dimming LEDs, changing color and lots more. But, I want to be able to get commands from other scripts. Let's say I want to type in a shell command that will change the color. In my infinite Python script (LED Handler), I will be able to recognize this command and change the color or the light mode softly  to the desired color. \nOne idea is, to constantly look into a text file, if there is a new command. And my shell script is able to insert command lines into this text file.\nBut can you tell me, if there is a better solution of doing it?\nMany thanks in advance.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":140,"Q_Id":54031676,"Users Score":2,"Answer":"I suggest opening a port with your python script and make it receive commands from that port (network programming). Although this would make your project more complicated, it is a very robust implementation.","Q_Score":2,"Tags":"python","A_Id":54031712,"CreationDate":"2019-01-04T00:29:00.000","Title":"Running infinite loop and getting commands from \"outside\" (e.g. shell or other 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'm wondering about how a dash app works in terms of loading data, parsing and doing initial calcs when serving to a client who logs onto the website.\nFor instance, my app initially loads a bunch of static local csv data, parses a bunch of dates and loads them into a few pandas data frames. This data is then displayed on a map for the client.\nDoes the app have to reload\/parse all of this data every time a client logs onto the website? Or does the dash server load all the data only the first time it is instantiated and then just dish it out every time a client logs on?\nIf the data reloads every time, I would then use quick parsers like udatetime, but if not, id prefer to use a convenient parser like pendulum which isn't as efficient (but wouldn't matter if it only parses once).\nI hope that question makes sense. Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":54035114,"Users Score":2,"Answer":"The only thing that is called on every page load is the function you can assign to app.layout. This is useful if you want to display dynamic content like the current date on your page.\nEverything else is just executed once when the app is starting. \nThis means if you load your data outside the app.layout (which I assume is the case) everything is loaded just once.","Q_Score":0,"Tags":"python,performance,plotly-dash","A_Id":54173014,"CreationDate":"2019-01-04T08:03:00.000","Title":"Do Dash apps reload all data upon client log in?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using the latest version of VScode, using pylint and python 3. I'm using I'm on Ubuntu 16.04 and virtualenv. I can import all python and pip packages correctly, I only face the error when working with files I created.\nI have 3 files, all are next to each other sitting in the same folder. a.py, b.py and keys.py, the latter contains nothing but keys as strings.\nin a.py, I can do\nfrom keys import X\nBut in b.py pylint doesn't let me do that, I get\nUnable to import 'keys' [E0401]\nI can only do\nfrom .keys import X\nWhich is wrong but I mean that would remove the error above.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":71,"Q_Id":54039033,"Users Score":1,"Answer":"The issue is that Pylint is seeing the files as contained in a package (hence the relative import of from .keys import X working). Trying to execute a.py directly is kind of \"cheating\" by trying to view the files as not in a package.","Q_Score":0,"Tags":"python,python-3.x,visual-studio-code,pylint","A_Id":54083491,"CreationDate":"2019-01-04T12:32:00.000","Title":"VScode python 3 pylint: I can import X file in A but not B","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are using H2O (latest version 3.22.1.1) to read parquet data from s3. We use python to talk to H2O. This is single H2O instance - not cluster.\nSometimes we get this error:\nServer error water.exceptions.H2OIllegalArgumentException:\n  Error: Cannot determine file type. for s3a:\/\/BUCKET_NAME\/5c2e3fdc0c9c1800019c73f9\/part-00001-c33635a2-76dc-4e49-948b-465726b7e3d9-c000.snappy.parquet\nFile exists and is valid parquet file. Subsequent imports work fine.\nThis is our python code to import file into H2O\nh2o.import_file(path='s3a:\/\/BUCKET_NAME\/5c2e3fdc0c9c1800019c73f9\/part-00001-c33635a2-76dc-4e49-948b-465726b7e3d9-c000.snappy.parquet')\nIs there any way to force h2o to use parquet type?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":755,"Q_Id":54039594,"Users Score":0,"Answer":"H20 Manual says to do it like df = h2o.import_file(\"\/pathToFile\/fileName\")  When \n you need to load data from the machine(s) running H2O to the machine running Python. \nSo if your server is not running H20 probably that's why it is showing error.","Q_Score":0,"Tags":"python,amazon-s3,parquet,h2o","A_Id":54040066,"CreationDate":"2019-01-04T13:10:00.000","Title":"h2o and parquet - can not determine file type error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a remote Linux host(I'm not superuser) which can only communicate with my local host via ssh shell.\n\nmy remote host has NO Internet, but has python3.6.5, conda4.5.4 installed.\nmy local host has Internet and can install packages and python through the Internet.\n\nI need to run my python2.7 code on a remote host, but the python2.7 virtual environment and the related dependent packages are lacked. \nI want to configure a py2.7 environment(my_py2env) and install all the needed dependencies on my localhost. And package all the needed file into a pack, such as tar.gz package. Send it to my remote host and unpack it. If I can use some conda commands such as conda --clone and this deploys all my environment(my_py2env) on the remote host. That will be perfect. Is that possible? How can I realize it?\nThank you very much!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":164,"Q_Id":54039738,"Users Score":1,"Answer":"I think there may be you can use ssh command with options -R to map a local port to the remote host, and you can setup a http proxy on your local machine and listen on the mapped port.\nNow you can install required package in a virtualenv via the http proxy you mapped.","Q_Score":1,"Tags":"python,ssh,conda","A_Id":54039853,"CreationDate":"2019-01-04T13:20:00.000","Title":"How to share a total python env with a remote host without Internet?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have n lists each of length m. assume n*m is even. i want to get a randomly shuffled list with all elements, under the constraint that the elements in locations i,i+1 where i=0,2,...,n*m-2 never come from the same list. edit: other than this constraint i do not want to bias the distribution of random lists. that is, the solution should be equivalent to a complete random choice that is reshuffled until the constraint hold.\nexample:\nlist1: a1,a2\nlist2: b1,b2\nlist3: c1,c2\nallowed: b1,c1,c2,a2,a1,b2\ndisallowed: b1,c1,c2,b2,a1,a2","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":247,"Q_Id":54041705,"Users Score":1,"Answer":"A possible solution is to think of your number set as n chunks of item, each chunk having the length of m. If you randomly select for each chunk exactly one item from each lists, then you will never hit dead ends. Just make sure that the first item in each chunk (except the first chunk) will be of different list than the last element of the previous chunk.\nYou can also iteratively randomize numbers, always making sure you pick from a different list than the previous number, but then you can hit some dead ends.\nFinally, another possible solution is to randomize a number on each position sequentially, but only from those which \"can be put there\", that is, if you put a number, none of the constraints will be violated, that is, you will have at least a possible solution.","Q_Score":2,"Tags":"python,shuffle","A_Id":54041995,"CreationDate":"2019-01-04T15:20:00.000","Title":"Shuffling with constraints on pairs","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have n lists each of length m. assume n*m is even. i want to get a randomly shuffled list with all elements, under the constraint that the elements in locations i,i+1 where i=0,2,...,n*m-2 never come from the same list. edit: other than this constraint i do not want to bias the distribution of random lists. that is, the solution should be equivalent to a complete random choice that is reshuffled until the constraint hold.\nexample:\nlist1: a1,a2\nlist2: b1,b2\nlist3: c1,c2\nallowed: b1,c1,c2,a2,a1,b2\ndisallowed: b1,c1,c2,b2,a1,a2","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":247,"Q_Id":54041705,"Users Score":1,"Answer":"A variation of b above that avoids dead ends: At each step you choose twice. First, randomly chose an item. Second, randomly choose where to place it. At the Kth step there are k optional places to put the item (the new item can be injected between two existing items). Naturally, you only choose from allowed places.\nMoney!","Q_Score":2,"Tags":"python,shuffle","A_Id":54088978,"CreationDate":"2019-01-04T15:20:00.000","Title":"Shuffling with constraints on pairs","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an extremely simple cnn which i will be trying to bind to an rnn (but that in the future). For now, all I have is conv2D->maxpool>conv2d->maxpool->dense->dense. The CNN works well, no problems, compiles, runs.\n'model.add(TimeDistributed(Conv2D(..., input_shape=(32,32,1))\nRuntimeError: You must compile your model before using it.\nAnd of course, model.compile() is immediately after the model definition and .fit following the compile...\nHence, is it me not getting something right or it is really an issue with the current Keras build?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":54042532,"Users Score":0,"Answer":"The problem was that input_shape must be specified outside Conv2D and inside TimeDistributed. Keep in mind it must be 4D '(batch_size, width, height, channels)'","Q_Score":0,"Tags":"python,tensorflow,video,keras","A_Id":54049978,"CreationDate":"2019-01-04T16:12:00.000","Title":"TimeDistribution Wrapper Fails the Compilation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python project that I am about to finish.\nAll its dependencies and packages are provided in my venv that sits next to my app (as it should). The project was developed through the venv. As expected.\nMy question is:\nIf I hand in my project and include the venv folder, will the user be able to run my program through the venv that I have provided?\nIn other words, if I instruct them to execute: path\\to\\my\\venv\\python.exe path\\to\\my\\app.py, will it just work?\nIs this a thing?\nOptional bonus question: I'm on Windows. Assuming that my program is platform-independent, will this approach work if they're on linux? (I doubt it...)\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":54043168,"Users Score":1,"Answer":"After Endyd and Kenny Ostrom's comments, and some research, I'm aswering my own question for future readers.\nVirtual environments are not designed for this sort of task. There is no guarantee that a venv will work properly after being transferred to another system.\nThe commonly used method is, rather, using pip to create a \"requirements.txt\" of your project via pip freeze > requirements.txt.\nThe user will then create their own venv, and use pip install -r requirements.txt to sync their venv with yours.\nIf what you want is an executable, there are certain tools like PyInstaller that you can look into.","Q_Score":0,"Tags":"python,windows,python-venv","A_Id":54044560,"CreationDate":"2019-01-04T16:59:00.000","Title":"Handing in my application, along with its virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I had a problem when I needed to update a lot of records using write example: self.sudo().write({'field': True})\nIn this case, took me like 10-15 minutes to do it. However, when I tried with a sql query it took me a few seconds. \nMy doubts are, Why does that happen?, why is it better to use one or the other? or in which cases should I use one or the other?.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":274,"Q_Id":54043580,"Users Score":3,"Answer":"Because there is a lot going on in write not just a query executing. For example:\n\nChecking Model access right.\nChecking record rules access right if there is, and ggis the most heavy step. \nComputing others values that depends on this update if there is. \nPosting mail.thread messages.\nUsing api.one in some method this way odoo will repeat the same steps for each record and execute the query N times (very very bad thing to do) \n\nKeep in mind that using plain SQL will not trigger computing values or security checking so don't use it or use it carefully.","Q_Score":2,"Tags":"python,odoo","A_Id":54045437,"CreationDate":"2019-01-04T17:31:00.000","Title":"Why does sql query works faster with many records in odoo?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there a way to set the border color for the pygame window, not the background, but the area were the close, maximise, and minimize buttons are","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":241,"Q_Id":54048841,"Users Score":0,"Answer":"That cannot be set. It is system specific. Unless of course, you want to remove it altogether and make your own version. \u2013","Q_Score":0,"Tags":"python,python-3.x,windows,pygame","A_Id":66067818,"CreationDate":"2019-01-05T03:55:00.000","Title":"pygame on windows set window border color and\/or window border text color","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the tensorflow object detection API. \nI have performed the training on the remote server GPU and saved the frozen model and checkpoints. \nAfter that i took that frozen model along with checkpoints and copied to my local machine and then performed the testing on my test data using the the script \"object_detection_tutorial.ipnyb\" \n\nWhen i run this cell \"Load a (frozen) Tensorflow model into memory\", it gives the invalid argument error. \nCan you please explain what is the issue while running the save model on my local machine ? Is it necessary that that the training and testing should be on same machine? I was encountered with the following error:\n\nInvalidArgumentError                      Traceback (most recent call\n  last)\n  ~\/anaconda3\/lib\/python3.6\/site-packages\/tensorflow\/python\/framework\/importer.py\n  in import_graph_def(graph_def, input_map, return_elements, name,\n  op_dict, producer_op_list)\n      417         results = c_api.TF_GraphImportGraphDefWithResults(\n  --> 418             graph._c_graph, serialized, options)  # pylint: disable=protected-access\n      419         results = c_api_util.ScopedTFImportGraphDefResults(results)\nInvalidArgumentError: NodeDef mentions attr 'T' not in\n  Op\n  selected_indices:int32>; NodeDef: {{node\n  Postprocessor\/BatchMultiClassNonMaxSuppression\/map\/while\/MultiClassNonMaxSuppression\/non_max_suppression\/NonMaxSuppressionV3}}\n  = NonMaxSuppressionV3[T=DT_FLOAT](Postprocessor\/BatchMultiClassNonMaxSuppression\/map\/while\/MultiClassNonMaxSuppression\/unstack,\n  Postprocessor\/BatchMultiClassNonMaxSuppression\/map\/while\/MultiClassNonMaxSuppression\/Reshape,\n  Postprocessor\/BatchMultiClassNonMaxSuppression\/map\/while\/MultiClassNonMaxSuppression\/Minimum,\n  Postprocessor\/BatchMultiClassNonMaxSuppression\/map\/while\/MultiClassNonMaxSuppression\/non_max_suppression\/iou_threshold,\n  Postprocessor\/BatchMultiClassNonMaxSuppression\/map\/while\/MultiClassNonMaxSuppression\/non_max_suppression\/score_threshold).\n  (Check whether your GraphDef-interpreting binary is up to date with\n  your GraphDef-generating binary.).\nDuring handling of the above exception, another exception occurred:\nValueError                                Traceback (most recent call\n  last)  in \n        5     serialized_graph = fid.read()\n        6     od_graph_def.ParseFromString(serialized_graph)\n  ----> 7     tf.import_graph_def(od_graph_def, name='')\n~\/anaconda3\/lib\/python3.6\/site-packages\/tensorflow\/python\/util\/deprecation.py\n  in new_func(*args, **kwargs)\n      486                 'in a future version' if date is None else ('after %s' % date),\n      487                 instructions)\n  --> 488       return func(*args, **kwargs)\n      489     return tf_decorator.make_decorator(func, new_func, 'deprecated',\n      490                                        _add_deprecated_arg_notice_to_docstring(\n~\/anaconda3\/lib\/python3.6\/site-packages\/tensorflow\/python\/framework\/importer.py\n  in import_graph_def(graph_def, input_map, return_elements, name,\n  op_dict, producer_op_list)\n      420       except errors.InvalidArgumentError as e:\n      421         # Convert to ValueError for backwards compatibility.\n  --> 422         raise ValueError(str(e))\n      423 \n      424     # Create _DefinedFunctions for any imported functions.\nValueError: NodeDef mentions attr 'T' not in\n  Op\n  selected_indices:int32>; NodeDef: {{node\n  Postprocessor\/BatchMultiClassNonMaxSuppression\/map\/while\/MultiClassNonMaxSuppression\/non_max_suppression\/NonMaxSuppressionV3}}\n  = NonMaxSuppressionV3[T=DT_FLOAT](Postprocessor\/BatchMultiClassNonMaxSuppression\/map\/while\/MultiClassNonMaxSuppression\/unstack,\n  Postprocessor\/BatchMultiClassNonMaxSuppression\/map\/while\/MultiClassNonMaxSuppression\/Reshape,\n  Postprocessor\/BatchMultiClassNonMaxSuppression\/map\/while\/MultiClassNonMaxSuppression\/Minimum,\n  Postprocessor\/BatchMultiClassNonMaxSuppression\/map\/while\/MultiClassNonMaxSuppression\/non_max_suppression\/iou_threshold,\n  Postprocessor\/BatchMultiClassNonMaxSuppression\/map\/while\/MultiClassNonMaxSuppression\/non_max_suppression\/score_threshold).\n  (Check whether your GraphDef-interpreting binary is up to date with\n  your GraphDef-generating binary.).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":300,"Q_Id":54050290,"Users Score":0,"Answer":"I had a similar issue. The solution for me was to take my GPU training files from TF1.9 and move them to my local TF1.5 CPU environment (which doesn't support AVX instructions). I then created the frozen model on the local environment from the training files and was successfully able to use it.","Q_Score":1,"Tags":"python,python-3.x,tensorflow,object-detection-api","A_Id":59746722,"CreationDate":"2019-01-05T08:26:00.000","Title":"Invalid Argument error:Load a (frozen) Tensorflow model into memory (While testing the model on local machine)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The above mentioned command is not working.\nShowing the result after giving command -\nNo Django settings specified.\nUnknown command: 'startmyproject'. Did you mean startproject?\nType 'django-admin help' for usage.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1571,"Q_Id":54054418,"Users Score":0,"Answer":"I think you need to run this django-admin startproject 'your peoject name goes here'\nThis should be just after activating virtual and installing django","Q_Score":0,"Tags":"python,django","A_Id":57670708,"CreationDate":"2019-01-05T17:28:00.000","Title":"Django command \"django-admin startmyproject\" not working?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I just got a new computer, and I was installing some Python libraries. When I tried to install numpy, I got a message on the console saying numpy was already downloaded. I went into the library folder, and not only was numpy there, but scipy, matplotlib, and a bunch of other libraries as well. How is this possible, considering this computer is brand new? I had installed Python the previous evening, so does installing Python automatically install these libraries as well?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":379,"Q_Id":54056362,"Users Score":1,"Answer":"If you copied your data from your previous computer to this one, you may have copied the python installation (and thereby the libraries you had installed before) in your appdata folder.\nAnother possibility is that you have install Anaconda, which is targeted especially at scientific things, and comes with numpy, scipy and some other things preinstalled.","Q_Score":1,"Tags":"python","A_Id":54056410,"CreationDate":"2019-01-05T21:18:00.000","Title":"Does installing Python also install libraries like scipy and numpy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just got a new computer, and I was installing some Python libraries. When I tried to install numpy, I got a message on the console saying numpy was already downloaded. I went into the library folder, and not only was numpy there, but scipy, matplotlib, and a bunch of other libraries as well. How is this possible, considering this computer is brand new? I had installed Python the previous evening, so does installing Python automatically install these libraries as well?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":379,"Q_Id":54056362,"Users Score":1,"Answer":"Python does not ship with these libraries unless you are using a pre-packaged distribution such as Anaconda.","Q_Score":1,"Tags":"python","A_Id":54056390,"CreationDate":"2019-01-05T21:18:00.000","Title":"Does installing Python also install libraries like scipy and numpy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just got a new computer, and I was installing some Python libraries. When I tried to install numpy, I got a message on the console saying numpy was already downloaded. I went into the library folder, and not only was numpy there, but scipy, matplotlib, and a bunch of other libraries as well. How is this possible, considering this computer is brand new? I had installed Python the previous evening, so does installing Python automatically install these libraries as well?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":379,"Q_Id":54056362,"Users Score":1,"Answer":"Although this is not the place for these types of questions, yes, there is no need to install libraries, as most of the times when you download Python in a distribution, such as Anaconda, they are also included.","Q_Score":1,"Tags":"python","A_Id":54056384,"CreationDate":"2019-01-05T21:18:00.000","Title":"Does installing Python also install libraries like scipy and numpy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have been researching Python SDKs for the Sphero over the past several days. Among those I found are Kulka and SpheroPy, though I found another which is 5 years old and hasn't been updated since then.\nNeither the Kulka or SpheroPy implementations will connect to my Sphero Bolt though. It has been successfully paired with my Windows 10 PC, and has a unique identifier of \"c8:31:f5:7e:f4:30\". Each time I tell any of these APIS to connect to the sphero, they throw a traceback and tell me they can't connect because the connected party isn't responding.\n  I've successfully connected Sphero Bolt to the Sphero Edu app on my phone. \nHowever, I am blind, and the app is not screen reader friendly, so my preferred method of controlling it would be through an external API. Still, the fact that it connected to the Sphero Edu app + the fact that it paired to my PC show that its bluetooth capability is functional. I have looked around and, perhaps because no research has really been done into it, no one has offered a working solution to this and I'm perplexed myself.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":963,"Q_Id":54057260,"Users Score":1,"Answer":"You can connect to BOLT directly using BLE services, but you have to implement communication services yourself. However, you don't have to start completely from scratch. Find more resources by googling these GUIDs:\n00010001-574f-4f20-5370-6865726f2121\n00020001-574f-4f20-5370-6865726f2121","Q_Score":5,"Tags":"python,sphero,bolt","A_Id":60324590,"CreationDate":"2019-01-05T23:29:00.000","Title":"Has Sphero broken compatibility with Python SDKs when introducing Bolt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have an assignment to build a web interface for a smart sensor, \nI've already written the python code to read the data from the sensor and write it into sqlite3, control the sensor etc. \nI've built the HTML, CSS template and implemented it into Django.\nMy goal is to run the sensor reading script pararel to the Django interface on the same server, so the server will do all the communication with the sensor and the user will be able to read and configure the sensor from the web interface. (Same logic as modern routers - control and configure from a web interface)\nQ: Where do I put my sensor_ctl.py script in my Django project and how I make it to run independent on the server. (To read sensor data 24\/7)\nQ: Where in my Django project I use my classes and method from  sensor_ctl.py to write\/read data to my djangos database instead of the local sqlite3 database (That I've used to test sensor_ctl.py)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":54057396,"Users Score":1,"Answer":"Place your code in app\/appname\/management\/commands folder. Use Official guide for management commands. Then you will be able to use your custom command like this:\n.\/manage getsensorinfo\nSo when you will have this command registered, you can just  put in in cron and it will be executed every minute.\nSecondly you need to rewrite your code to use django ORM models like this:\nStat.objects.create(temp1=60,temp2=70) instead of INSERT into....","Q_Score":1,"Tags":"django,python-3.x","A_Id":54057526,"CreationDate":"2019-01-05T23:50:00.000","Title":"How do i implement Logic to Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Flask app that uses selenium to get data from a website. I have spent 10+ hours trying to get heroku to work with it, but no success. My main problem is selenium. with heroku, there is a \"buildpack\" that you use to get selenium working with it, but with all the other hosting services, I have found no information. I just would like to know how to get selenium to work with any other recommended service than heroku. Thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":777,"Q_Id":54058237,"Users Score":0,"Answer":"You need hosting service that able to install Chrome, chromedriver and other dependencies. Find for Virtual Private hosting (VPS), or Dedicated Server or Cloud Hosting but not Shared hosting.","Q_Score":1,"Tags":"python,selenium,heroku,hosting","A_Id":54059218,"CreationDate":"2019-01-06T02:49:00.000","Title":"How does selenium work with hosting services?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In windows, we can use pyinstaller to build python code like Tkinter to an exe file for user use, How to in Linux, I don't like user to do it in terminal to run the code, Any advice? Thanks,","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":85,"Q_Id":54058547,"Users Score":1,"Answer":"Linux comes with Python preinstalled, so on Linux you can just prepend a shebang #! line with the path to the interpreter to a Python script and then set the executable bit +x on the file with chmod. Then you can run it by name or click on it in the file explorer application.\nIf you need more than one file, you can use the zipapp module to group a folder together into a single executable .pyz archive with the shebang.","Q_Score":0,"Tags":"python,linux,user-interface,tkinter","A_Id":54058567,"CreationDate":"2019-01-06T04:08:00.000","Title":"How to build a package for Tkinter like exe in window?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a sentiment analysis project about local people's attitudes toward the transportation service in Hong Kong. I used the Twitter API to collect the tweets. However, since my research target is the local people in Hong Kong, tweets posted from, for instance, travelers should be removed. Could anyone give me some hints about how to extract tweets posted from local people given a large volume of Twitter data? My idea now is to construct a dictionary which contains traveling-related words and use these words to filter the tweets. But it may seem not to work\nAny hints and insights are welcomed! Thank you!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":42,"Q_Id":54058996,"Users Score":2,"Answer":"There are three main ways you can do this.\n\nLanguage. If the user is Tweeting in Cantonese - or another local language - there is less chance they are a traveller compared to, say, Russian.\nUser location.  If a user has a location present in their profile, you can see if it is within Hong Kong.\nUser timezone.  If the user's timezone is the same as HK's timezone, they may be a local.\n\nAll of this is very fuzzy.","Q_Score":0,"Tags":"python,twitter,web-crawler,sentiment-analysis,social-media","A_Id":54060976,"CreationDate":"2019-01-06T05:49:00.000","Title":"How to extract tweets posted only from local people?","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":"IDLE just straight up stopped working on my desktop, as in when I try and open it nothing happens, it won't even give me an error message. It works fine on my laptop however. Right-clicking and trying to edit a script does nothing as well. This happened completely overnight, I didn't change or install anything. I have absolutely no idea how this happened.\nI've tried reinstalling and copying the files from my laptop to my desktop, nothing has worked so far.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5624,"Q_Id":54059162,"Users Score":1,"Answer":"(Answer adapted from comment with solution.)  When starting up, IDLE accesses both its own files in Lib\/idlelib and user customization files in $HOME\/.idlerc.  The latter are shared across all python\/IDLE installations on the machine.  The error message you got indicates that some file 'suddenly' became corrupted so that it was seen as mis-encoded.  Since replacing the idlelib files did not fix the issue, the problem likely had to be in a .idlerc file.  Your comment indicates that this must have been the case.\nWith no .idlerc present, IDLE will recreate one from scratch.  Any customizations you had can be re-created with the options dialog.  You can either delete the old version or try to poke around to retrieve some of the data.\nI will look into adding something to the IDLE doc about .idlerc corruption being a possible problem, and the solution.\nEDIT: Bit can occasionally go bad on a hard disk, especially after several years.  Has happened to me.  To fix, only only needs to delete the bad file or file within .idlerc if .idlerc itself is not the problem.  An IDLE error message may indicate which.  Or one can try looking at each file in an editor for any obvious garbage.","Q_Score":1,"Tags":"python,python-idle","A_Id":54098412,"CreationDate":"2019-01-06T06:22:00.000","Title":"Python IDLE won't start","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using select() to check if there is data in a socket with a timeout of 5 seconds. I'm willing to know if calling select() block only the thread or the whole program, if there is no data in the socket, select() will block for 5 seconds only the thread so the rest of the program can run freely or block everything until timeout?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":54059866,"Users Score":0,"Answer":"Yes, select will only block the current thread. The other threads can work freely.","Q_Score":0,"Tags":"python,select,block","A_Id":54059877,"CreationDate":"2019-01-06T08:30:00.000","Title":"Does calling Select() block only the thread or the whole program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to start by saying that my knowledge of clustering techniques is extremely limited, please don\u2019t shoot me down too harshly.\nI have a sizable set of 3D points (around 8,000) - think of a X, Y, Z triplets, for which the Z coordinate represents a point in the earth underground (negative). I would like to cluster these points using the absolute minimum number of clusters, with the following constraints:\n\nUse the least number of clusters\nAll points should be included in the clustering, which means that any point should at least belong to one cluster\nThe maximum distance between any point and the cluster centroid (shifted at Z=0, on the earth surface) should not exceed a certain fixed distance d.\n\nI was thinking to use scikit-learn k-means approach, by iteratively incrementing the number of clusters and then, for all points in the dataset calculate if the distance between the point and the cluster centroid (at Z=0) is less than the specific distance provided.\nOf course, I am open to better\/more efficient suggestions - the clusters, for example, do not need to be circular as the ones returned by k-means. They can be ellipses or anything else, as long as the constraints above are satisfied.\nI welcome any suggestion, thank you for your insights.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1912,"Q_Id":54060208,"Users Score":0,"Answer":"Use hierarchical clustering.\nWith complete linkage.\nFinding the true minimum cover is NP hard. So you don't want to do this. But this should produce a fairly good approximation in \"just\" O(n\u00b3).\nThis is basic knowledge. When looking for a clustering algorithm, at least read the Wikipedia article. Better even some book, to get an overview. There is not just k-means...","Q_Score":1,"Tags":"python,scikit-learn,cluster-analysis","A_Id":54060749,"CreationDate":"2019-01-06T09:25:00.000","Title":"Python K-Means clustering and maximum distance","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi ultimately I'm trying to install django on my computer, but I'm unable to do this as the when I run pip in the command line I get the following error message:\n''pip' is not recognized as an internal or external command,\noperable program or batch file.'\nI've added the following locations to my path environment:\n'C:\\Python37-32;C:\\Python37-32\\Lib\\site-packages;C:\\Python37-32\\Scripts'\nI've also tried to reinstall pip using 'py -3.7 -m ensurepip -U --default-pip', but then I get the following error message:\n'Requirement already up-to-date: setuptools in c:\\users\\tom_p\\anaconda3\\lib\\site-packages (40.6.3)\nRequirement already up-to-date: pip in c:\\users\\tom_p\\anaconda3\\lib\\site-packages (18.1)\nspyder 3.3.2 requires pyqt5<5.10; python_version >= \"3\", which is not installed.\nxlwings 0.15.1 has requirement pywin32>=224, but you'll have pywin32 223 which is incompatible.'\nI'm new to this so I'm struggling with the install and I'm confused by the fact pip is in C:\\Python37-32\\Scripts, but the above error seems to be looking in the anaconda folder. The only reason I installed anaconda was to use the Spyder IDE.\nI've installed python 3.7 32-bit on my Windows 10, any help would be much appreciated.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":474,"Q_Id":54060243,"Users Score":0,"Answer":"Hi Steve I've just used the below code which seemed to work, as I was told django 2.1.5 successfully installed and I can find a django.js application on my computer.\npy -3.7-32 -mpip install django\nHowever, I'm unable to open this application and when I run the below code I'm seeing the error message: 'C:\\Users\\tom_p\\Anaconda3\\python.exe: No module named django'\npy -m django --version\nI tried to install the 64 bit version of django, but that gave an error. The pythons that are available to me are:\n-3.7-64        C:\\Users\\tom_p\\Anaconda3\\python.exe *\n -3.7-32        C:\\Python37-32\\python.exe","Q_Score":0,"Tags":"python,django,installation","A_Id":54064223,"CreationDate":"2019-01-06T09:31:00.000","Title":"Struggling to Install Pip and Django on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I work in Python, and I want to find a workflow for enabling two processes (main-process and sub-process) to communicate with each other. By that, I mean the ability of main-process to send some data to sub-process (perhaps, by writing to sub-process's stdin) and the ability of sub-process to send some data back to the main one. This also implies that both can read the data sent to them (I was thinking of reading from stdin).\nI was trying to use subprocess library, but it seems that it's intended to work with processes that are designed to give an output only once and then terminate, whereas I want to exchange data dynamically and shut the sub-process down only when such a command is received.\nI've read lots of answers here on StackOverflow tackling problems closely related to mine, but none of them did I find satisfying, as the questions those answers were meant to were different from mine in one important detail: I need my main-process to be able to exchange data with its sub-process dynamically as many times as needed, not just once, which in turn implies that the sub-process should run until it receives a certain command from main-process to terminate. \nI'm open to using third-party libraries, but it would be much better if  you proposed a solution based solely on the Python Standard Library.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3530,"Q_Id":54060274,"Users Score":5,"Answer":"You want to make a Popen object with subprocess.PIPE for standard input and output and use its file objects to communicate\u2014rather than using one of the cantrips like run (and the older, more specific ones like check_output).  The challenge is avoiding deadlock: it\u2019s easy to land in a situation where each process is trying to write, the pipe buffers fill (because no one is reading from them), and everything hangs.  You also have to remember to flush in both processes, to avoid having a request or response stuck in a file object\u2019s buffer.\nPopen.communicate is provided to avoid these issues, but it supports only a single string (rather than an ongoing conversation).  The traditional solution is select, but it also works to use separate threads to send requests and read results.  (This is one of the reasons to use CPython threads in spite of the GIL: each exists to run while the other is blocked, so there\u2019s very little contention.)  Of course, synchronization is then an issue, and you may need to do some work to make the multithreaded client act like a simple, synchronous function call on the outside.\nNote that both processes need to flush, but it\u2019s enough if either implements such non-blocking I\/O; one normally does that job in the process that starts the other because that\u2019s where it\u2019s known to be necessary (and such programs are the exception).","Q_Score":15,"Tags":"python,python-3.x,subprocess","A_Id":54063928,"CreationDate":"2019-01-06T09:35:00.000","Title":"Dynamic communication between main and subprocess in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to make a calculator in python, so when you type x (root) y it will give you the x root of y, e.g. 4 (root) 625 = 5. \nI'm aware of how to do math.sqrt() but is there a way to do other roots?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2857,"Q_Id":54060609,"Users Score":4,"Answer":"If you want to 625^(1\/4){which is the same as 4th root of 625}\nthen you type 625**(1\/4)\n** is the operator for exponents in python.\nprint(625**(1\/4))\nOutput:\n5.0\nTo generalize:\nif you want to find the xth root of y, you do:\ny**(1\/x)","Q_Score":4,"Tags":"python,math","A_Id":54060651,"CreationDate":"2019-01-06T10:28:00.000","Title":"How do I root in python (other than square root)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was just looking at some Python and I came across something called a vector. What is this?\nI am pretty sure it is something mathematical and complicated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6694,"Q_Id":54065881,"Users Score":0,"Answer":"Well vectors originally are used to represent coordinates in a certain dimensional space(2d or 3d) or a line starting from the origin of a vector space,with both magnitude and direction.But in python vectors  are not a difficult concept or any of that kind,it is just a list of numbers which can be used for any operation usually in model training in machine learning,neural networks in short many things. They can be created in numpy as numpy as arrays since they are just arrays of numbers(scalars usually real numbers)","Q_Score":0,"Tags":"python-2.7,vector","A_Id":61058170,"CreationDate":"2019-01-06T20:56:00.000","Title":"What is a vector in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can someone give a detailed explanation on how to fix the ERROR: no such table: main.auth_user__old\nIt arises in my Django application when I am trying to add data to my registered models.","AnswerCount":10,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":10875,"Q_Id":54070355,"Users Score":0,"Answer":"I know this issue is encountered a long time back I don't want anyone to stuck on it again:\nStep1: The solution is to check the Django version if it is 2.1 then update it to 2.2 or later.\nStep2: After updating to Django==2.2 or later Delete all old migrations from the migrations folder and delete the db.sqlite3 and then run makemigrations and migrations again. It will be resolved.\nGood Luck!","Q_Score":1,"Tags":"python,django,django-models,django-templates,django-views","A_Id":63941686,"CreationDate":"2019-01-07T07:48:00.000","Title":"How to fix-no such table: main.auth_user__old","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can someone give a detailed explanation on how to fix the ERROR: no such table: main.auth_user__old\nIt arises in my Django application when I am trying to add data to my registered models.","AnswerCount":10,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":10875,"Q_Id":54070355,"Users Score":5,"Answer":"I have solved this issue using below :\n1) Delete the db.sqlit3\n2) app's directory delete everything in pycache\n3) manage.py makemigrations, manage.py migrate, manage.py createsuperuser and then manage.py runserver.","Q_Score":1,"Tags":"python,django,django-models,django-templates,django-views","A_Id":58519187,"CreationDate":"2019-01-07T07:48:00.000","Title":"How to fix-no such table: main.auth_user__old","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can someone give a detailed explanation on how to fix the ERROR: no such table: main.auth_user__old\nIt arises in my Django application when I am trying to add data to my registered models.","AnswerCount":10,"Available Count":4,"Score":0.0199973338,"is_accepted":false,"ViewCount":10875,"Q_Id":54070355,"Users Score":1,"Answer":"first of all you don't have to change your code, the problem your django version\nI'm pretty sure that you're following mosh's tutorial or something like that,\nto fix this problem follow this steps:\n\nexit the IDE you are using\ndelete db.sqlite from the folder in your computer not inside the IDE\nopen your IDE and upgrade your django version using this command pip install --upgrade django==2.1.5\nrun this command python manage.py makemigrations\nthen run this command python manage.py migrate\nthis will help you Enchallah","Q_Score":1,"Tags":"python,django,django-models,django-templates,django-views","A_Id":66310689,"CreationDate":"2019-01-07T07:48:00.000","Title":"How to fix-no such table: main.auth_user__old","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can someone give a detailed explanation on how to fix the ERROR: no such table: main.auth_user__old\nIt arises in my Django application when I am trying to add data to my registered models.","AnswerCount":10,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":10875,"Q_Id":54070355,"Users Score":4,"Answer":"If you are using django==2.1 then maybe you getting this error.\nJust start your Django project again bu installing django==2.1.5\nIt will work.","Q_Score":1,"Tags":"python,django,django-models,django-templates,django-views","A_Id":61805084,"CreationDate":"2019-01-07T07:48:00.000","Title":"How to fix-no such table: main.auth_user__old","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"while uploading csv file on BigQuery through storage , I am getting below error:\nCSV table encountered too many errors, giving up. Rows: 5; errors: 1. Please look into the error stream for more details.\nIn schema , I am using all parameter as string.\nIn csv file,I have below data:\nIt's Time. Say \"I Do\" in my style.\nI am not able upload csv file in BigQuery containing above sentence","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1178,"Q_Id":54071304,"Users Score":0,"Answer":"Thanks to all for a response.\nHere is my solution to this problem:\n\nwith open('\/path\/to\/csv\/file', 'r') as f:\n      text = f.read()\nconverted_text = text.replace('\"',\"'\") print(converted_text)\nwith open('\/path\/to\/csv\/file', 'w') as f:\n      f.write(converted_text)","Q_Score":0,"Tags":"python,google-cloud-platform,google-bigquery,google-cloud-storage","A_Id":54090809,"CreationDate":"2019-01-07T09:06:00.000","Title":"How to fix upload csv file in bigquery using python","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to setup cx_oracle latest version for connecting to a remote oracle installation. I was able to connect to oracle and import data on my local installation on Ubuntu. But When i tried the same thing on an AWS server redhat instance it fails and throws a connection timeout issue.\nI am using python 3.5 and cx_oracle 7.0 setup oracle instant client on \/opt\/ and exported the LD_LIBRARY_PATH also tried same with sqlalchemy connector with cx_oracle.\nI even tried installing using rpm but still shows the same issue in server\nplease guide me if am doing anything wrong","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":54072172,"Users Score":0,"Answer":"I need to close this question since the issue was not with the library it was the oracle instance which has a inbound policy for a specific ip","Q_Score":0,"Tags":"database,python-3.x,oracle,amazon-web-services,cx-oracle","A_Id":54074372,"CreationDate":"2019-01-07T10:03:00.000","Title":"Cx_Oracle connection issue Redhat","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am creating a webpage that should redirect its users to a subpage, based on their choices in a form with radio buttons. The radio button input should trigger logic calculations. For example:\nForm with example user input (Yes\/No):\n\n[Question] | [Yes] | [No]\nQuestion1 | ------ | XXX\nQuestion2 | ------ | XXX\nQuestion3 | XXX | ------\n\nLogic:\n\nIf Q1=No, Q2=No and Q3=Yes, then redirect to page W\nIf Q1=Yes, Q2=No and Q3=Yes, then redirect to page X\nIf Q2=Yes, then redirect to page Y\nElse, then redirect to page Z\n\nThe webpage is part of a project created using Django and Python.\nI do not know how to approach this problem, as the form input should be passed to the webserver while maintaining the possibility to perform the logic calculations.\nAlso, I do not want to store the user input to my database. After a user has been redirected to page W, X, Y or Z, no input should be memorized.\nCan you please help me in finding a proper way to post the user form data to the server, perform the logic calculations and using the result to redirect the user to the right page?\nThank you in advance!\n--\nThank you for your reply. I have tried your suggestion, but eventually chose for a workaround where I implemented IF-statements based on the form outcome. The content of the page following on the user input form thus dependent on the answers.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":54075333,"Users Score":0,"Answer":"If by \"subpage\" you mean that you don't want any page reload, i would recommend dealing with this problem using js and not using a classical Form\/Post method.\nIf you want to keep the logic in your views.py, one way you could do this is sending the form using Ajax, and displaying the result in your page.","Q_Score":1,"Tags":"python,django,forms","A_Id":54075727,"CreationDate":"2019-01-07T13:27:00.000","Title":"Django: How to redirect users to pages based on form input?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Although I have used pip to get pyinstaller without any errors, command prompt tells me \"'pyinstaller' is not recognized as an internal or external command, operable program or batch file.\" I also do not see any files named \"pyinstaller\" in my Scripts folder.\nPATH seems to point to the right place. I can pip other packages successfully.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1669,"Q_Id":54081447,"Users Score":0,"Answer":"I have found the script. I located it by looking in the paths mentioned when I used pip. Then I had to place it in my already working PATH (which is just my Scripts folder in Python), and rename it to just \"pyinstaller\"","Q_Score":1,"Tags":"python-3.x,pyinstaller","A_Id":54097933,"CreationDate":"2019-01-07T20:31:00.000","Title":"Used pip for pyinstaller but pyinstaller still not recognized","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have a vector space spanned by five vectors v1....v5, to find the orthogonal basis for A where A=[v1,v2...v5] and A is 5Xn\nshould I use np.linalg.qr(A) or scipy.linalg.orth(A)?? \nThanks in advance","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4408,"Q_Id":54081800,"Users Score":1,"Answer":"Note that sp.linalg.orth uses the SVD while np.linalg.qr uses a QR factorization. Both factorizations are obtained via wrappers for LAPACK functions.\nI don't think there is a strong preference for one over the other. The SVD will be slightly more stable but also a bit slower to compute. In practice I don't think you will really see much of a difference.","Q_Score":3,"Tags":"python,numpy,matrix,vector","A_Id":54081952,"CreationDate":"2019-01-07T20:59:00.000","Title":"np.linalg.qr(A) or scipy.linalg.orth(A) for finding the orthogonal basis (python)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to update the variables from a keras sequential model (model.variables) if they are eagertensors?  When I try to assign to them I get an error that says the object has no attribute \"assign\".","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":690,"Q_Id":54084352,"Users Score":2,"Answer":"\"tensors\" are not updatable in tensorflow, variables are. To update a variable use variable.assign.","Q_Score":1,"Tags":"python,python-3.x,tensorflow,keras,eager-execution","A_Id":54097782,"CreationDate":"2019-01-08T02:04:00.000","Title":"how to update an 'eagertensor\" object in tensorflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using selenium to scrape information from a website.\nThe page is behind a login so I can't provide an example - but basically I need to gather data on approx. 800 fields on the one page.\nCurrently it boils down to me navigating to the correct page and then running \nfor i in driver.find_elements_by_xpath('\/\/*[@id]'):\n                some_list.append(i.get_attribute('textContent'))\nMy question is;\n\nDoes using get_attribute place any impact on the responding server?\n\nOr is the full page 'cached' and then I am simply reading the values that are already loaded?\nJust want to make sure I'm being kind to the other party and not doing 800 calls for get_attribute!\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":54084584,"Users Score":5,"Answer":"get_attribute is retrieving data from sources already downloaded. You are not making requests to a web server when you execute that command","Q_Score":1,"Tags":"python,selenium,web-scraping","A_Id":54085021,"CreationDate":"2019-01-08T02:44:00.000","Title":"Selenium - How much am I hitting the server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"guys I am currently working on a project where I have to integrate a web based application with machine learning.\nWhat the web page does is basically ask the user a couple of questions, whatever the user answers is stored in a Hashmap with question id and question answer.\nI have to send this set of answers to a learning algorithm which has been implemented using python.The learning algorithm will return a set of confidence values for the answers and I have to simply display them on the results web-page.\nI am using the Spring frame-work to develop the web-app.\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":248,"Q_Id":54084600,"Users Score":0,"Answer":"You can also create a REST API around the python ML code and return a JSON which can then be easily parsed in spring.","Q_Score":0,"Tags":"python,spring","A_Id":54085373,"CreationDate":"2019-01-08T02:46:00.000","Title":"How to access a python script using Spring framework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a simple question which I stock in it ! \nfor line1 in file:\n    print(line1)\nfor line2 in file:\n    print(line2)\nfor line3 in file:\n    print(line3)\nI expect this to work three times, but only \"for line1 in file:\" work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":54084757,"Users Score":1,"Answer":"Because the file is read as part of iterating over the lines. You'll need to reopen the file each time, or read the whole file into a list of lines (via file.readlines() perhaps) and iterate over that, if memory limits permit. \nAny open file has a \"read pointer\" that tracks what's been read, which advances with each line consumed. The loops as written will each consume the whole file.","Q_Score":1,"Tags":"python,python-3.x","A_Id":54084811,"CreationDate":"2019-01-08T03:12:00.000","Title":"Why \"for line in file:\" can only use once?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been doing Andrew Ng's DeepLearning AI course (course 2).\nFor the exercise in gradient checking, he implements a function converting a dictionary containing all of the weights (W) and constants (b) into a single, one-hot encoded vector (of dimensions 47 x 1). \nThe starter code then iterates through this vector, adding epsilon to each entry in the vector.\nDoes gradient checking generally include adding epsilon\/subtracting to the constant as well? Or is it simply for convenience, as constants play a relatively small role in the overall calculation of the cost function?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":222,"Q_Id":54087106,"Users Score":1,"Answer":"You should do it regardless, even for constants. The reason is simple: being constants, you know their gradient is zero, so you still want to check you \"compute\" it correctly. You can see it as an additional safety net","Q_Score":1,"Tags":"python,neural-network,backpropagation,gradient-descent","A_Id":54087388,"CreationDate":"2019-01-08T07:32:00.000","Title":"In gradient checking, do we add\/subtract epsilon (a tiny value) to both theta and constant parameter b?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am an architectural design student who works with 3D programs (like Blender, Rhino, etc.). I usually find that it takes a lot of time to compute heavy geometry. So, I thought about if we could distribute the computations to a number of machines to get the job done quickly.\nNow the problem is, I wanna distribute the computations without actually running an instance of the software I am using in every machine. Because, I have read that a lot of distributed systems work that way, by running an instance of the software in every node that is doing the job. But, my question is, can we run the 'master software' in only one machine, and just use the resources of many machines by running a 'supporting software' (that we write) on every machine to get the job done. So its like treating 'n' number of machines as 'one'.\nIs it possible...?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":151,"Q_Id":54088247,"Users Score":0,"Answer":"Depends on what exactly you mean by supporting software. In any case, the code that does the actual job has to reside in each node, for the work to be done.\nYou can, however, use the master-worker architecture where the master handles the job of distributing, collecting and integrating the result while each worker just sticks to pure number crunching. In this case, the softwares running on the master and the workers can be different as the master does more of a management work, but the workers still have the code that does the actual work.","Q_Score":0,"Tags":"python,networking,network-programming,distributed-computing","A_Id":54089263,"CreationDate":"2019-01-08T08:54:00.000","Title":"Can we distribute computations to multiple machines without running an instance of the software in every machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to render output from rq immediately after it gets completed.\nCurrently, I am using Job.fetch() to fetch tasks. But I have to repeatedly check after a certain interval for that.\nI am using flask-socketio to render results.\nIs there some way I could fetch results from task as soon as it gets finished?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":54089090,"Users Score":0,"Answer":"The most probable and used way seemingly is calling Job.fetch() itself after a certain intervals repeatedly using flask-socketio.","Q_Score":0,"Tags":"flask-socketio,python-rq","A_Id":54089433,"CreationDate":"2019-01-08T09:46:00.000","Title":"How to fetch output immediately in python-rq?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I m trying to deploy a python cloud function to GCP that uses the package msgpack (I already successfully deployed many cloud functions before so I m pretty much used to the process). So I got my requirements.txt containing msgpack but the deployment fails with the error : ModuleNotFoundError: No module named 'msgpack'.\nI tried putting in requirements just msgpack but also msgpack=0.6.0 but it didn't change anything.\nMy python script runs perfectly when ran locally so I know there is no other issue than that.\nThanks in advance for your help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":398,"Q_Id":54090116,"Users Score":0,"Answer":"Ok I found the solution ... I wasn't aware that Cloud Functions were able to use the files Pipfile and Pipfile.lock that are generated by pipenv and that I didn't update.\nAdding them to .gcloudignore fixed the problem. You can also fix pipenv dependency files with: pipenv install -r requirements.txt","Q_Score":0,"Tags":"python-3.x,google-cloud-platform,google-cloud-functions,msgpack","A_Id":54090366,"CreationDate":"2019-01-08T10:44:00.000","Title":"Google Cloud Function Python package not installed through requirements.txt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Pentaho service to import all tables and data from a SQL database to a pgSQL database. I'm using the 'sort row' transformation for this.\nNow what I need is to sync the two databases frequently. (ie, changes occurred in SQL db needs to reflects on pgSQL db)\nHow can I do this or which transformation do I need to use?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":515,"Q_Id":54092072,"Users Score":0,"Answer":"you can create one job which executes every 2 minutes or 5 minutes depending on your new data frequency in sql db and takes the new data and dumps into pgsql db. there are various way to do it.\none of such is check for look-up,explore how it works and you will get idea.","Q_Score":2,"Tags":"database,python-3.x,postgresql,pentaho,pentaho-data-integration","A_Id":54192086,"CreationDate":"2019-01-08T12:43:00.000","Title":"How to Synchronise two database using Pentaho?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset of ~10,000 rows of vehicles sold on a portal similar to Craigslist. The columns include price, mileage, no. of previous owners, how soon the car gets sold (in days), and most importantly a body of text that describes the vehicle (e.g. \"accident free, serviced regularly\"). \nI would like to find out which keywords, when included, will result in the car getting sold sooner. However I understand how soon a car gets sold also depends on the other factors especially price and mileage. \nRunning a TfidfVectorizer in scikit-learn resulted in very poor prediction accuracy. Not sure if I should try including price, mileage, etc. in the regression model as well, as it seems pretty complicated. Currently am considering repeating the TF-IDF regression on a particular segment of the data that is sufficiently huge (perhaps Toyotas priced at $10k-$20k).\nThe last resort is to plot two histograms, one of vehicle listings containing a specific word\/phrase and another for those that do not. The limitation here would be that the words that I choose to plot will be based on my subjective opinion.\nAre there other ways to find out which keywords could potentially be important? Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":406,"Q_Id":54097067,"Users Score":1,"Answer":"As you mentioned you could only so much with the body of text, which signifies the amount of influence of text on selling the cars. \nEven though the model gives very poor prediction accuracy, you could ahead to see the feature importance, to understand what are the words that drive the sales. \nInclude phrases in your tfidf vectorizer by setting ngram_range parameter as (1,2)\nThis might gives you a small indication of what phrases influence the sales of a car. \nIf would also suggest you to set norm parameter of tfidf as None, to check if has influence. By default, it applies l2 norm. \nThe difference would come based the classification model, which you are using. Try changing the model also as a last option.","Q_Score":1,"Tags":"python,scikit-learn,nlp,regression,prediction","A_Id":54102609,"CreationDate":"2019-01-08T17:44:00.000","Title":"TF-IDF + Multiple Regression Prediction Problem","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an automation task that uses pyautogui and python3 to open a pdf and fill it out with predefined fields from JIRA (The pdf is locked down and there is no way to programatically interface with it other than pyautogui.) The script snaps to the top left of a screen where a pdf is opened, clicks in the pdf and then keystrokes are automated from there.\nAll of this works great on a desktop but now its time to put this on a server where it will run and the best option to deploy looks like Docker. Is what I'm suggesting possible or is there another method that will work like a docker-machine or VM ? This is my first deployment and it's small enough to really mess around with all possible options and do some good learning.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1271,"Q_Id":54099863,"Users Score":0,"Answer":"Figured it out! Built a container that uses xvfb and simulates the x11 session. Just need to set DISPLAY variable and create a session.","Q_Score":0,"Tags":"python-3.x,docker,virtual-machine,centos7,pyautogui","A_Id":55330012,"CreationDate":"2019-01-08T21:18:00.000","Title":"is it possible to run pyautogui on centos 7 docker container","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I want AWS Cloud9 to use the Python version and specific packages from my Anaconda Python environment. How can I achieve this? Where should I look in the settings or configuration?\nMy current setup: I have an AWS EC2 instance with Ubuntu Linux, and I have configured AWS Cloud9 to work with the EC2 instance. \nI have Anaconda installed on the EC2 instance, and I have created a conda Python3 environment to use, but Cloud9 always wants to use my Linux system's installed Python3 version.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":2395,"Q_Id":54102477,"Users Score":1,"Answer":"You could use a 'shell script' runner type. To do this you would:\n\ncreate your conda env, with python3 and any packages etc you want in it. Call it py3env\ncreate a directory to hold your runner scripts, something like $HOME\/c9_runner_scripts\nput a script in there called py3env_runner.sh runner with code like:\nconda activate py3env\n python ~\/c9\/my_py3_script.py\nThen create a run configuration with the 'shell script' runner type and enter c9_runner_scripts\/py3env_runner.sh","Q_Score":8,"Tags":"python,amazon-web-services,amazon-ec2,anaconda,aws-cloud9","A_Id":57294696,"CreationDate":"2019-01-09T02:25:00.000","Title":"Configure AWS Cloud9 to use Anaconda Python Environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Hi so i'm trying to get started on machine learning by installing tensorflow, however it's only supported by Python 3.6.x as of now.\nI guess you can say this was a failed attempt to downgrade python.\nMy installed version of python is 3.7.2 which has all my modules installed.\nI just installed Python 3.6.8. \nThe IDE i use is Visual Studio Code \nHowever now when i use Python 3.7.2 in Visual Studio Code, I get an error saying no module named... was found","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":54102868,"Users Score":0,"Answer":"tensorflow is not suport by python 3.7 its only supported by 3.6 use a virtual environment to deal with multiple python versions.","Q_Score":1,"Tags":"python","A_Id":54102957,"CreationDate":"2019-01-09T03:32:00.000","Title":"No module named... Issue","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a Python developer. I wanted to create some online shopping stores which will be fully customized, Database will Mysql, Redis for caching, mail-gun for mailing, AWS hosting and  Theme may be customized. I am confused in both platforms Magento and Shopify. Please Help Which have the best integration with python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":201,"Q_Id":54103457,"Users Score":0,"Answer":"Yes Rehan is correct to go with the magento framework","Q_Score":0,"Tags":"python,magento,flask,e-commerce,shopify","A_Id":64007871,"CreationDate":"2019-01-09T04:54:00.000","Title":"Magento or Shopify which is best for integration with Python or which provide best APIs for 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":1},{"Question":"I just made a tkinter widget on python. I wish to pass it to my friend who has python but not tkinter library.\nHe is right now receiving a module not found error","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":215,"Q_Id":54103741,"Users Score":2,"Answer":"This assumes that your terminal is in the current directory where the project is located.\nYou have to run pip freeze on terminal to list the libraries installed and save the output on requirements.txt. On unix based OSes, you can run pip freeze > requirements.txt, making the libraries saved on requirements.txt automaticallly. To install those libraries coming from the requirements.txt you can run pip install -r requirements.txt.\nMuch better if you have a background in using Virtual Environments.","Q_Score":0,"Tags":"python,import,module,automation,package","A_Id":54104164,"CreationDate":"2019-01-09T05:29:00.000","Title":"How to package all the required libraries with the python program so that it can run in all systems?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a code running in jupyter notebook which continuously prints output in a cell.\nWhen I open the same notebook in a different tab of a browser(possibly a different machine\/browse\/tab) I want the output of cell to appear in the new tab. It seems the output will only show if I refresh the browser. \nIs there any method to make it work this way?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1578,"Q_Id":54104471,"Users Score":0,"Answer":"Outputs do not appear in new tabs. The tab you have opened only responsible for the output of the code. If you want different cells to show your outputs then write code in different cells and run each cell sequentially to get the correct output.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":54104538,"CreationDate":"2019-01-09T06:40:00.000","Title":"Jupyter notebook multiple window output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Although I have implemented Virtual Environment inside a project in PyCharm IDE, when I trigger python -m behave it says:\n\n'python' is not recognized as an internal or external command\".  \n\nHow can I make sure that terminal searches the venv folder and not the default python location?\nI made sure that inside settings>tools>Terminal, \"Activate Virtual Environment\" is checked.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":54108544,"Users Score":1,"Answer":"Terminal in PyCharm is still just a system terminal.\nSo you should add your python binarys path to your systems PATH environment variable.\nOr you can use the option \"Environment Variables\" inside settings\/tools\/Terminal and add a new entry there like PATH=$PATH$;< Path to your python binary >\nThen python should launch in PyCharms terminal window.\nBut to access your virtual environment you still need to start it like in a normal terminal: venv\\Scripts\\activate (on Windows).","Q_Score":0,"Tags":"python-3.x,pycharm,virtual-environment","A_Id":54109581,"CreationDate":"2019-01-09T10:56:00.000","Title":"How can I make sure that terminal searches the venv folder and not the default python location for third party modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using  the PYNQ Linux on Zedboard and when I tried to run a code on Jupyter Notebook to load a model.h5 I got an error message:\n\"The kernel appears to have died. It will restart automatically\"\nI tried to upgrade keras and Jupyter but still have the same error\nI don't know how to fix this problem ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":491,"Q_Id":54113143,"Users Score":0,"Answer":"Model is too large to be loaded into memory so kernel has died.","Q_Score":2,"Tags":"python,jupyter-notebook","A_Id":59205501,"CreationDate":"2019-01-09T15:12:00.000","Title":"Linux Jupyter Notebook : \"The kernel appears to have died. It will restart automatically\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I was creating a sparse file from scratch and I wanted to make it the size of n I would use bytestream.seek(n-1) to offset the pointer and then write a single null byte at the end. Much quicker than writing a bytestream of n length!\nHowever, if I've opened said file with open(\u2026,'ab'), seek() is no longer an option, as soon as I call write() the position resets to the end of the file, as stated in the documentation.\nIt seems the only option when using python's ammend is to write each individual null byte.\nIs there another way of appending null bytes to a pre-existing file efficiently and quickly?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":201,"Q_Id":54114131,"Users Score":1,"Answer":"It\u2019s true that append mode defeats seek, but part of the purpose of seek is to be more flexible than append mode.  Open in update mode ('r+b') and you can seek to or past the end of the file.  (You can seek to but not past the end in text mode.)","Q_Score":2,"Tags":"python,python-3.x,bytestream","A_Id":54130712,"CreationDate":"2019-01-09T16:09:00.000","Title":"Appending null bytes to file in python3 using sparse 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 seen the following statement in a number of docstrings when help()ing a class: \"See help(type(self)) for accurate signature.\"\nNotably, it is in the help() for scipy.stats.binom.__init__ and for stockfish.Stockfish.__init__ at the very least.  I assume, therefore, that it is some sort of stock message.\nIn any case, I can't figure out what the heck it means.  Is this useful information?  Note that, being \"outside\" of the class, so to speak, I never have access to self.  Furthermore, it is impossible to instantiate a class if I cannot access the signature of the __init__ method, and can therefore not even do help(type(my_object_instantiated)).  Its a catch 22.  In order to use __init__, I need the signature for __init__, but in order to read the signature for __init__, I need to instantiate an object with __init__.  This point is strictly academic however, for even when I do manage to instantiate a scipy.stats.binom, it actually returns an object of an entirely different class, rv_frozen, with the exact same message in its __init__ docstring, but whose signature is entirely different and entirely less useful.  In other words, help(type(self)) actually does not give an accurate signature.  It is useless.\nDoes anyone know where this message comes from, or what I'm supposed to make of it?  Is it just stock rubbish from a documentation generator, or am I user-erroring?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1623,"Q_Id":54114270,"Users Score":4,"Answer":"There is a convention that the signature for constructing a class instance is put in the __doc__ on the class (since that is what the user calls) rather than on __init__ (or __new__) which determines that signature.  This is especially true for extension types (written in C) whose __init__ cannot have its signature discovered via introspection.\nThe message that you see is part of the type class (see help(type.__init__)) and is thus inherited by metaclasses by default.\nIn some versions, scipy.stats.binom confuses the matter by not actually being a type; it is merely an instance of another class that (like type) is callable.  So asking for help on it merely gives the help for that class (just like help(1) gets you help(int))\u2014you have to look at its __call__ for further information (if any).  And asking for help on the result of calling it gives you help for the actual class of whatever it returns, as you observed.","Q_Score":8,"Tags":"python,documentation,docstring","A_Id":55400526,"CreationDate":"2019-01-09T16:18:00.000","Title":"Python \"See help(type(self)) for accurate signature.\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Exception: Python in worker has different version 2.7 than that in driver 3.5, PySpark cannot run with different minor versions.Please check environment variables PYSPARK_PYTHON and PYSPARK_DRIVER_PYTHON are correctly set.\nHow do I change the python version in my worker? (I'm using Spark in Standalone Mode)","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2948,"Q_Id":54115290,"Users Score":0,"Answer":"Install correct python version (Python3) on the worker node, and on the worker add python3 to path and then set PYSPARK_PYTHON environment variable as \"python3\", now check if pyspark is running python2 or 3 by running \"pyspark\" on terminal. This will open up a python shell. Notice the python version on the top of the python shell.","Q_Score":1,"Tags":"python-3.x,apache-spark,pyspark,jupyter-notebook","A_Id":54121974,"CreationDate":"2019-01-09T17:17:00.000","Title":"Mismatch between python version in Spark worker and Spark driver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Exception: Python in worker has different version 2.7 than that in driver 3.5, PySpark cannot run with different minor versions.Please check environment variables PYSPARK_PYTHON and PYSPARK_DRIVER_PYTHON are correctly set.\nHow do I change the python version in my worker? (I'm using Spark in Standalone Mode)","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2948,"Q_Id":54115290,"Users Score":0,"Answer":"It must be because of your system python is pointing to 3.5. You should Ideally set your PATH variable before running script to point to PySpark Python like PATH=your anaconda or cloudera bin path:$PATH and everything will be automatically in Sync. Dont use system python for executing pyspark job as inconsistency may come up in driver and executor.","Q_Score":1,"Tags":"python-3.x,apache-spark,pyspark,jupyter-notebook","A_Id":59104103,"CreationDate":"2019-01-09T17:17:00.000","Title":"Mismatch between python version in Spark worker and Spark driver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there an interactive, imperative way to manipulate Webots simulations using Python, instead of using the contorller script? E.g. the way you can interact with OpenAI Gym. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":104,"Q_Id":54118812,"Users Score":1,"Answer":"No, there is no such a thing available out of the box in Webots. However, it shouldn't be difficult to implement a set of Python commands that could be called from an interactive Python shell. Such commands would communicate with a slave Webots controller via some IPC (Inter Process Communication) to send commands to a running simulation.","Q_Score":1,"Tags":"python,webots","A_Id":54142508,"CreationDate":"2019-01-09T21:44:00.000","Title":"Interactive terminal for Python on Webots?","Data Science and Machine Learning":0,"Database and SQL":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":"For homework in my basic python class, we have to start python interpreter in interactive mode and type a statement. Then, we have to open IDLE and type a statement. I understand how to write statements in both, but can't quite tell them apart? I see that there are to different desktop apps for python, one being the python 3.7 (32-bit), and the other being IDLE. Which one is the interpreter, and how do I get it in interactive mode? Also, when I do open IDLE do I put my statement directly in IDLE or, do I open a 'new file' and do it like that? I'm just a bit confused about the differences between them all. But I do really want to learn this language! Please help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1698,"Q_Id":54119661,"Users Score":2,"Answer":"Python unlike some languages can be written one line at a time with you getting feedback after every line . This is called interactive mode. You will know you are in interactive mode if you see \">>>\" on the far left side of the window. This mode is really only useful for doing small tasks you don't think will come up again.\nMost developers write a whole program at once then save it with a name that ends in \".py\" and run it in an interpreter to get the results.","Q_Score":2,"Tags":"python-3.x","A_Id":54119897,"CreationDate":"2019-01-09T22:59:00.000","Title":"Difference between Python Interpreter and IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to always run a Python script in Windows. Every 5 minutes, it is to check if the script is running and if not, run it.\nIn linux, this can be done using flock and cron job. How can this be done in windows?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":54120345,"Users Score":1,"Answer":"You can use the Task scheduler. Create a new basic task with python as the program and your script as the argument.","Q_Score":1,"Tags":"python,windows","A_Id":54120365,"CreationDate":"2019-01-10T00:18:00.000","Title":"Python cron script for windows","Data Science and Machine Learning":0,"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 App consists of a notification module. If the notifications are consecutively arrived from a same user, I would like to show \"n notifications from john doe\".\neg:\nThe database rows are as:\n\nid    |   user    |     notif       |\n------------------------------------\n1       john doe     liked your pic \n2       john doe     commented on your pic\n3       james        liked your pic\n4       james        commented on your pic\n5       john doe     pinged you\n6       john doe     showed interest\n7       john doe     is busy\n\nThe above notifications are to be shown as:\n\n2 notifications from john doe\n2 notification from james\n3 notofications from john doe\n\nHow would I count these consecutive rows with same value in a column using django orm?\n\nNotification.objects.all().values('user', 'notif_count').group_consecutive_by('user').as(notif_count=Sum())\n\nSomething like that. Please help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":247,"Q_Id":54123705,"Users Score":1,"Answer":"Let my model Notification model be:\n\nClass Notification(models.Model):\n    user = models.ForeignKey(\n        settings.AUTH_USER_MODEL,\n        related_name='notifications',\n        on_delete=models.CASCADE)\n    notif = models.CharField(max_length=255)\n    date_created = models.DateTimeField(auto_now_add=True)\n\n\nThe database rows are as:\n\nid    |   user    |     notif       |\n------------------------------------\n1       john doe     liked your pic \n2       john doe     commented on your pic\n3       james        liked your pic\n4       james        commented on your pic\n5       john doe     pinged you\n6       john doe     showed interest\n7       john doe     is busy\n\nBasically, I am trying to join consecutive rows by user\nThe above notifications then are to be shown as:\n\n2 notifications from john doe\n2 notification from james\n3 notofications from john doe\n\ninstead of\n\n5 notifications from john doe\n2 notification from james\n\nor\n\n1 notifications from john doe\n1 notifications from john doe\n1 notification from james\n1 notification from james\n1 notofications from john doe\n1 notofications from john doe\n1 notofications from john doe\n\nIn  order to achieve this, we are looking for a dictionary like:\n\n{\n\"john doe\": [\"notif1\", \"notif2\"],\n\"james\": [\"notif1\", \"notif2\"],\n\"john doe\": [\"notif1\", \"notif2\", \"notif3\"] #duplicate key.\n}\n\nBut, that's not possible as duplicate keys are not allowed. Hence I am going with array of tuples instead.\n\n[\n  ('john doe', ['notif1', 'notif2']),\n  ('james', ['notif1', 'notif2']),\n  ('john doe', ['notif1', 'notif2', 'notif3']),\n]\n\nSo, we first sort the Notifications by date_created. Then we use itertools.groupby to make groups per user.\n\nfrom itertools import groupby\nfrom operator import attrgetter\n\nqs = Notification.objects.select_related('user').order_by('date_created')\nnotifs= [(u, list(nf)) for (u, nf) in groupby(qs, attrgetter('user'))]\n\nYou have everything sorted as needed in notifs.\nDone!","Q_Score":0,"Tags":"python,django,django-models,django-views","A_Id":54140405,"CreationDate":"2019-01-10T07:25:00.000","Title":"Count consecutive rows with same value for a column in a database using django?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Hello I am using pytrends, I would like to search for keywords only in a specific region\/city (for example Ile-de-France or Paris) instead of just France. \nIs it possible with pytrends or another API ?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":2050,"Q_Id":54127392,"Users Score":3,"Answer":"with pytrends you can specify province in geo=* by entering geo=FR-J for \u00cele-de-France province(Paris)","Q_Score":1,"Tags":"python,google-trends","A_Id":54127617,"CreationDate":"2019-01-10T11:08:00.000","Title":"specify a region for pytrends Google Trends API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to get file's inode in my windows machine, so first I tried os.stat('.\/filename.txt').st_ino\nin my REPL and the output I got was 0L. \nI tried the same for a couple of other files and got the same output.\nThen, I tried\nos.fstat(open(\"filename.txt\", \"r\").fileno()).st_ino and I got a long integer in output. For different files the integer was getting changed. So, I think os.fstat worked for windows while os.stat did not. Can someone explain to me the reason for this behavior and other differences between both?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":430,"Q_Id":54127788,"Users Score":1,"Answer":"In Python 2 on Windows, stat calls GetFileAttributesEx or FindFirstFile to get standard file information, including file attributes (e.g. directory, readonly), size, and timestamps. fstat calls GetFileType (i.e. character, pipe, disk) and GetFileInformationByHandle, which provides the standard info plus the file index number (like an inode in some ways, but not really), number of hard links, and volume serial number (unused). \nPython 2 is a year away from end of life. I suggest you upgrade to Python 3, which has an improved stat implementation for Windows and further improvements in development","Q_Score":0,"Tags":"python,windows,inode,fstat","A_Id":54128641,"CreationDate":"2019-01-10T11:31:00.000","Title":"Difference between inode numbers of os.stat and os.fstat in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I already installed it with pip3 install pandas and using python3.7 but when I try to import pandas and run the code error popping up. \n\nTraceback (most recent call last):   File\n  \"\/Users\/barbie\/Python\/Test\/test.py\", line 1, in \n      import pandas as pd ModuleNotFoundError: No module named 'pandas'\n\nand if I try to install again.. it says this. \n\npip3 install \n  pandas Requirement already satisfied: pandas in\n  \/usr\/local\/lib\/python3.7\/site-packages (0.23.4) Requirement already\n  satisfied: pytz>=2011k in \/usr\/local\/lib\/python3.7\/site-packages (from\n  pandas) (2018.9) Requirement already satisfied: numpy>=1.9.0 in\n  \/usr\/local\/lib\/python3.7\/site-packages (from pandas) (1.15.4)\n  Requirement already satisfied: python-dateutil>=2.5.0 in\n  \/usr\/local\/lib\/python3.7\/site-packages (from pandas) (2.7.5)\n  Requirement already satisfied: six>=1.5 in\n  \/usr\/local\/lib\/python3.7\/site-packages (from\n  python-dateutil>=2.5.0->pandas) (1.12.0)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6513,"Q_Id":54129321,"Users Score":1,"Answer":"If you're using pycharm you can go to File -> Settings -> Project -> Project Interpreter.\nThere you'll get a list of all the packages installed with the current python that pycharm is using. There is a '+' sign on the right of the window that you can use to install new packages, just enter pandas there.","Q_Score":3,"Tags":"python-3.x,pandas","A_Id":54129738,"CreationDate":"2019-01-10T13:02:00.000","Title":"installed pandas but still can't import it","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using docker compose to create a network of containers, where one of the containers requests another to run a process. The client also has to monitor these process in case of errors or when it completes. My approach is to use python's subprocess Popen like this:\nprocess = subprocess.Popen(cmd,stdout=subprocess.PIPE, stderr=subprocess.STDOUT) \nwhere cmd is ['docker-compose', 'exec', 'service2', 'sh', '-c', 'cp sourcefile  \/destination && python run.py'] \nBut I get this error\n[Errno 2] No such file or directory: 'docker-compose': 'docker-compose'\nI tried executing the same command in bash mode on the client container and got\nbash: docker-compose: command not found. I thought of doing a dind, but is that really necessary? This command works on my host machine docker-compose run --rm service2 python apples.py shell. What's the right approach bearing in mind I need to query the returncode of the process running in container service2 from service1 at anytime. I declared a bridge-network. Thanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2471,"Q_Id":54129377,"Users Score":0,"Answer":"In your command, use the absolute path to the docker-compose executable on your machine.","Q_Score":1,"Tags":"python,bash,docker,ubuntu,docker-compose","A_Id":54129415,"CreationDate":"2019-01-10T13:05:00.000","Title":"docker-compose exec causes [Errno 2] No such file or directory: 'docker-compose': 'docker-compose' in docker container","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've been using Matlab to fit data to a Weibull distribution using [paramhat, paramci] = wblfit(data, alpha).  This gives the shape and scale parameters for a Weibull distribution as well as the confidence intervals for each value.\nI'm trying to use Scipy to accomplish the sane task and can easily get the parameters with scipy.stats.weibull_min.fit but I cannot figure out a way to get the confidence intervals on the vlauee.  Does Scipy offer this functionality? Or do I need to write the MLE confidence intervals estimation myself?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":496,"Q_Id":54130419,"Users Score":0,"Answer":"You could use scipy.optimize.curve_fit to fit the weibull distribution to your data. This will also give you the covariance and thus you can estimate the error of the fitted parameters.","Q_Score":2,"Tags":"python,scipy,weibull","A_Id":54131475,"CreationDate":"2019-01-10T14:05:00.000","Title":"Scipy Weibull parameter confidence intervals","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some difficulty with understanding the role of activation functions and cost functions. Lets take a look at a simple example. Lets say I am building a neural network (artificial neural network). I have 5 \u201ex\u201c variables and one \u201ey\u201c variable. \nIf I do usual feature scaling and then apply, for example, Relu activation function in hidden layer, then this activation function does the transformation and as a result we get our predicted output value (y hat) between 0 and lets say M. Then the next step is to calculate the cost function. \nIn calculating the cost function, however, we need to compare the output value (y hat) with the actual value (y).\nThe question is how we can compare transformed output value (y hat) which is lets say between 0 and M with the untransformed actual value (y) (which can be any number as it is not been subjected to the Relu activation function) to calculate the cost function? There can be a large mismatch as one variable has been exposed to transformation and the other has not been.\nThank you for any help.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":54130706,"Users Score":0,"Answer":"-A cost function is a measure of error between what value your model predicts and what the value actually is. For example, say we wish to predict the value  yi  for data point  xi . Let  f\u03b8(xi)  represent the prediction or output of some arbitrary model for the point  xi  with parameters  \u03b8  . One of many cost functions could be\n\u2211ni=1(yi\u2212f\u03b8(xi))2\nthis function is known as the L2 loss. Training the hypothetical model we stated above would be the process of finding the  \u03b8  that minimizes this sum.\n-An activation function transforms the shape\/representation of the data going into it. A simple example could be  max(0,xi) , a function which outputs 0 if the input  xi  is negative or  xi  if the input  xi  is positive. This function is known as the \u201cReLU\u201d or \u201cRectified Linear Unit\u201d activation function. The choice of which function(s) are best for a specific problem using a particular neural architecture is still under a lot of discussion. However, these representations are essential for making high-dimensional data linearly separable, which is one of the many uses of a neural network.\nI hope this gave a decent idea of what these things are. If you wish to learn more, I suggest you go through Andrew Ng\u2019s machine learning course on Coursera. It provides a wonderful introductory look into the field.","Q_Score":0,"Tags":"python,neural-network,activation-function","A_Id":62532493,"CreationDate":"2019-01-10T14:20:00.000","Title":"Role of activation function in calculating the cost function for artificial neural networks","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some difficulty with understanding the role of activation functions and cost functions. Lets take a look at a simple example. Lets say I am building a neural network (artificial neural network). I have 5 \u201ex\u201c variables and one \u201ey\u201c variable. \nIf I do usual feature scaling and then apply, for example, Relu activation function in hidden layer, then this activation function does the transformation and as a result we get our predicted output value (y hat) between 0 and lets say M. Then the next step is to calculate the cost function. \nIn calculating the cost function, however, we need to compare the output value (y hat) with the actual value (y).\nThe question is how we can compare transformed output value (y hat) which is lets say between 0 and M with the untransformed actual value (y) (which can be any number as it is not been subjected to the Relu activation function) to calculate the cost function? There can be a large mismatch as one variable has been exposed to transformation and the other has not been.\nThank you for any help.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":179,"Q_Id":54130706,"Users Score":-1,"Answer":"The value you're comparing your actual results to for the cost function doesn't (intrinsically) have anything to do with the input you used to get the output. It doesn't get transformed in any way.\nYour expected value is [10,200,3] but you used Softmax on the output layer and RMSE loss? Well, too bad, you're gonna have a high cost all the time (and the model probably won't converge).\nIt's just on you to use the right cost functions to serve as a sane heuristic for evaluating the model performance and the right activations to be able to get sane outputs for the task at hand.","Q_Score":0,"Tags":"python,neural-network,activation-function","A_Id":54130955,"CreationDate":"2019-01-10T14:20:00.000","Title":"Role of activation function in calculating the cost function for artificial neural networks","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list .txt with input arguments from a python script, I would like to execute the script with each argument in the list in the linux terminal, but only runs the latter.\nI'm trying this:\nfor p in $(cat list.txt); do eval $(echo script.py -u $p); done;","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":71,"Q_Id":54131267,"Users Score":0,"Answer":"there are multiple ways to do it. But my most recommended way would be the first one.\n\nChange your python script to take an argument which is the path to your list.txt. I would suggest using argparse module in python to handle arguments. Once the argument is read, just loop thorugh the contents of the file in python and use them the way you want to. With the you can handle the arguments much better. The program would be more robust.\nYou can run the python script using cat operation on the list.txt. python script.py $(cat list.txt)\nYou can use pipe, grep and awk. python script.py $(grep pattern file | awk '{print}' ORS=' ')\n\nBut I would still suggest the first option. Its more robust, you can handle arguments better and control the errors also.","Q_Score":0,"Tags":"python,linux,shell","A_Id":54132167,"CreationDate":"2019-01-10T14:52:00.000","Title":"How to run a python script with a list of arguments in linux terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I received a data dump of the SQL database.\nThe data is formatted in an .sql file and is quite large (3.3 GB). I have no idea where to go from here. I have no access to the actual database and I don't know how to handle this .sql file in Python.\nCan anyone help me? I am looking for specific steps to take so I can use this SQL file in Python and analyze the data. \nTLDR; Received an .sql file and no clue how to process\/analyze the data that's in the file in Python. Need help in necessary steps to make the .sql usable in Python.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3296,"Q_Id":54131953,"Users Score":1,"Answer":"It would be an extraordinarily difficult process to try to construct any sort of Python program that would be capable of parsing the SQL syntax of any such of a dump-file and to try to do anything whatsoever useful with it.\n\"No. Absolutely not. Absolute nonsense.\"  (And I have over 30 years of experience, including senior management.)  You need to go back to your team, and\/or to your manager, and look for a credible way to achieve your business objective ... because, \"this isn't it.\"\nThe only credible thing that you can do with this file is to load it into another mySQL database ... and, well, \"couldn't you have just accessed the database from which this dump came?\"  Maybe so, maybe not, but \"one wonders.\"\nAnyhow \u2013 your team and its management need to \"circle the wagons\" and talk about your credible options.  Because, the task that you've been given, in my professional opinion, \"isn't one.\"  Don't waste time \u2013 yours, or theirs.","Q_Score":3,"Tags":"python,mysql,sql","A_Id":54132286,"CreationDate":"2019-01-10T15:30:00.000","Title":"How to handle SQL dump with Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I received a data dump of the SQL database.\nThe data is formatted in an .sql file and is quite large (3.3 GB). I have no idea where to go from here. I have no access to the actual database and I don't know how to handle this .sql file in Python.\nCan anyone help me? I am looking for specific steps to take so I can use this SQL file in Python and analyze the data. \nTLDR; Received an .sql file and no clue how to process\/analyze the data that's in the file in Python. Need help in necessary steps to make the .sql usable in Python.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":3296,"Q_Id":54131953,"Users Score":2,"Answer":"Eventually I had to install MAMP to create a local mysql server. I imported the SQL dump with a program like SQLyog that let's you edit SQL databases. \nThis made it possible to import the SQL database in Python using SQLAlchemy, MySQLconnector and Pandas.","Q_Score":3,"Tags":"python,mysql,sql","A_Id":54251454,"CreationDate":"2019-01-10T15:30:00.000","Title":"How to handle SQL dump with Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a script to automatically update all sheets in a folder, but if there are subfolders, I don't know of a way to dynamically access the other sheets inside those subfolders. Does anyone know if this is possible using the smartsheet api?\ntl;dr: I want to be able to access the sheets inside a folder, and the sheets inside all of subfolders that are inside the original folder (and any sheets in those folders etc.).\nThank you for reading, I really appreciate the help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":153,"Q_Id":54133353,"Users Score":0,"Answer":"You have to list the folder inside of the root folder and to make recursive calls.","Q_Score":0,"Tags":"python,smartsheet-api,smartsheet-api-2.0,smartsheet-api-1.1,smartsheet-c#-sdk-v2","A_Id":54488745,"CreationDate":"2019-01-10T16:47:00.000","Title":"Is there a way to get all sheets inside a folder, including all subfolders? (In Smartsheet)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm coming to you with the following issue:\nI have a bunch of physical boxes onto which I still stick QR codes generated using a python module named qrcode. In a nutshell, what I would like to do is everytime someone wants to take the object contained in a box, he scans the qr code with his phone, then takes it and put it back when he is done, not forgetting to scan the QR code again.\nPretty simple, isn't it?\nI already have a django table containing all my objects.\nNow my question is related to the design. I suspect the easiest way to achieve that is to have a POST request link in the QR code which will create a new entry in a table with the name of the object that has been picked or put back, the time (I would like to store this information).\nIf that's the correct way to do, how would you approach it? I'm not too sure I see how to make a POST request with a QR code. Would you have any idea?\nThanks.\nPS: Another alternative I can think of would be to a link in the QR code to a form with a dummy button the user would click on. Once clicked the button would update the database. But I would fine a solution without any button more convenient...","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4065,"Q_Id":54135030,"Users Score":3,"Answer":"The question boils down to a few choices: (a) what data do you want to encode into the QR code; (b) what app will you use to scan the QR code; and (c) how do you want the app to use \/ respond to the encoded data.\nIf you want your users to use off-the-shelf QR code readers (like free smartphone apps), then encoding a full URL to the appropriate API on your backend makes sense. Whether this should be a GET or POST depends on the QR code reader.  I'd expect most to use GET, but you should verify that for your choice of app. That should be functionally fine, if you don't have any concerns about who should be able to scan the code.\nIf you want more control, e.g. you'd like to keep track of who scanned the code or other info not available to the server side just from a static URL request, you need a different approach. Something like, store the item ID (not URL) in the QR code; create your own simple QR code scanner app (many good examples exist) and add a little extra logic to that client, like requiring the user to log in with an ID + password, and build the URL dynamically from the item ID and the user ID.  Many security variations possible (like JWT token) -- how you do that won't be dictated by the contents of the QR code. You could do a lot of other things in that QR code scanner \/ client, like add GPS location, ask the user to indicate why or where they're taking the item, etc.  \nSo you can choose between a simple way with no controls, and a more complex way that would allow you to layer in whatever other controls and extra data you need.","Q_Score":0,"Tags":"python,django,qr-code","A_Id":54136664,"CreationDate":"2019-01-10T18:42:00.000","Title":"Interfacing a QR code recognition to a django database","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have apps deployed in AWS, like elastic search and ec2 instances inside VPC. Is there any service I can use to lookup the type of service running on the IP address from my VPC log. All my components are inside VPC I have the vpc log to get the ip address , Mostly it's all private ipv4 addresses.\nAny API in python or Java will be helpful.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1384,"Q_Id":54140167,"Users Score":1,"Answer":"There is no service to identify the service. However you can get an idea on what that IP is associated with via aws ec2 describe-network-interfaces","Q_Score":1,"Tags":"java,python,amazon-web-services,amazon-ec2,vpc","A_Id":54144184,"CreationDate":"2019-01-11T03:52:00.000","Title":"How to identify AWS component by IP address lookup?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We are using JFrog Artifactory and we keep jar files and tar.gz files into Artifactory. \nWhen we upload a jar file, in Artifactory we are able to expand and see the jar file contents like com -> mycomp -> app ....\nWhen we upload a tar.gz file which contains jar file, we are able to expand the tar.gz file contents but we are not able to expand the jar file.\nWe are using Python to create tar.gz file.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1165,"Q_Id":54140169,"Users Score":1,"Answer":"this is actually by design of Artifactory. When you're uploading artifacts to Artifactory it will unpack it so you can browse the contents from the repository browser (as you indeed mentioned). \nWhen you're uploading a compressed archive (whether that is a zip or tar.gz or something else), Artifactory doesn't extract the subcomponents. The reason behind that is that zips (or any other archive) could contain many more subcomponents and those could contain many more subcomponents too (and so on). That would place a heavy burden on the Artifactory server by consuming, potentially, tons of resources.","Q_Score":0,"Tags":"python,artifactory","A_Id":54150531,"CreationDate":"2019-01-11T03:52:00.000","Title":"Uploading artifacts to JFrog Artifactory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"my data looks like this.\n0 199 1028 251 1449 847 1483 1314 23 1066 604 398 225 552 1512 1598\n1 1214 910 631 422 503 183 887 342 794 590 392 874 1223 314 276 1411\n2 1199 700 1717 450 1043 540 552 101 359 219 64 781 953\n10 1707 1019 463 827 675 874 470 943 667 237 1440 892 677 631 425\nHow can I read this file structure in python? I want to extract a specific column from rows. For example, If I want to extract value in the second row, second column, how can I do that? I've tried 'loadtxt' using data type string. But it requires string index slicing, so that I could not proceed because each column has different digits. Moreover, each row has a different number of columns. Can you guys help me?\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":54142589,"Users Score":0,"Answer":"Use something like this to split it\nsplit2=[]\nsplit1=txt.split(\"\\n\")\nfor item in split1:\n    split2.append(item.split(\" \"))","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":54142820,"CreationDate":"2019-01-11T08:09:00.000","Title":"How can I read a file having different column for each rows?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a spark dataframe which has a column 'X'.The column contains elements which are in the form:\n\nu'[23,4,77,890,455,................]'\n\n. How can I convert this unicode to list.That is my output should be\n\n[23,4,77,890,455...................]\n\n.  I have apply it for each element in the 'X' column.\nI have tried df.withColumn(\"X_new\", ast.literal_eval(x)) and got the error \n\n\"Malformed String\"\n\nI also tried \n\ndf.withColumn(\"X_new\", json.loads(x)) and got the error \"Expected\n  String or Buffer\"\n\nand \n\ndf.withColumn(\"X_new\", json.dumps(x)) which says JSON not\n  serialisable.\n\nand also \n\ndf_2 = df.rdd.map(lambda x: x.encode('utf-8')) which says rdd has no\n  attribute encode.\n\nI dont want to use collect and toPandas() because its memory consuming.(But if thats the only way please do tell).I am using Pyspark\nUpdate: cph_sto gave the answer using UDF.Though it worked well,I find that it is Slow.Can Somebody suggest any other method?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":8294,"Q_Id":54144887,"Users Score":1,"Answer":"Since it's a string, you could remove the first and last characters:\nFrom '[23,4,77,890,455]' to '23,4,77,890,455'\nThen apply the split() function to generate an array, taking , as the delimiter.","Q_Score":1,"Tags":"python,apache-spark,pyspark,pyspark-sql,unicode-string","A_Id":69165691,"CreationDate":"2019-01-11T10:43:00.000","Title":"How can I convert unicode to string of a dataframe column?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a data set from telecom company having lots of categorical features. I used the pandas.get_dummies method to convert them into one hot encoded format with drop_first=True option. Now how can I use the predict function, test input data needs to be encoded in the same way, as the drop_first=True option also dropped some columns, how can I ensure that encoding takes place in similar fashion. \nData set shape before encoding : (7043, 21)\nData set shape after encoding : (7043, 31)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1013,"Q_Id":54145226,"Users Score":1,"Answer":"When not using drop_first=True you have two options:\n\nPerform the one-hot encoding before splitting the data in training and test set. (Or combine the data sets, perform the one-hot encoding, and split the data sets again).\nAlign the data sets after one-hot encoding: an inner join removes the features that are not present in one of the sets (they would be useless anyway). train, test = train.align(test, join='inner', axis=1)\n\nYou noted (correctly) that method 2 may not do what you expect because you are using drop_first=True. So you are left with method 1.","Q_Score":0,"Tags":"python,machine-learning,sklearn-pandas,one-hot-encoding","A_Id":54145335,"CreationDate":"2019-01-11T11:02:00.000","Title":"How to align training and test set when using pandas `get_dummies` with `drop_first=True`?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to make a wheel binary distribution, intstall it and then import it in python. My steps are\n\nI first create the wheel: python .\/my_package\/setup.py bdist_wheel\nI install the wheel: pip install .\/dist\/*.whl\nI try to import the package: python -c\"import my_package\"\n\nThis leads to the error:\nImportError: No module named 'my_package'\nAlso, when I do pip list, the my_package is listed.\nHowever, when I run which my_packge, nothing is shown.\nWhen I run pip install .\/my_package\/ everything works as expected. \nHow would I correctly build and install a wheel?\npython version 3.5\npip version 10.1\nwheel version 0.31.1\nUPDATE: \nWhen I look at the files inside my_package-1.0.0.dist-info, there is an unexpected entry in top_level.txt. It is the name of the folder where I ran \npython .\/my_package\/setup.py bdist_wheel in. I believe my setup.py is broken.\nUPDATE WITH REGARDS TO ACCEPTED ANSWER: \nI accepted the answer below. Yet, I think it is better to simply cd into the package directory. Changing to a different directory as suggested below leads to unexpected behavior when using the -d flag, i.e. the target directory where to save the wheel. This would be relative to the directory specified in the setup.py file.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":2848,"Q_Id":54145873,"Users Score":3,"Answer":"I had the very same error, but it was due to my setup.py not specifying the entry \"packages=setuptools.find_packages()\".\nEverythings builds nicely without that but you can't import anything even though pip shows it to be installed.","Q_Score":4,"Tags":"python-3.x,pip,python-wheel","A_Id":60125827,"CreationDate":"2019-01-11T11:43:00.000","Title":"python install wheel leads to import 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'm setting up Dask Python cluster at work (30 machines, 8 cores each in average). People use only a portion of their CPU power, so dask-workers will be running on background at low priority. All workers are listening to dask-scheduler on my master node. It works perfect if only I who use it, however it's gonna be used by several people in a concurrent manner - so i need to be able to admin this cluster:\n\nAuthenticate users, reject unknowns\nIdentify who submitted which jobs\nRestrict number of submitted jobs per user\nRestrict timeout for computation per job\nKill any job as admin\n\ndask.distributed out of box provides a little of functionality described above. Could you please advice on some solution (may be hybrid Dask + something)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":54147096,"Users Score":0,"Answer":"Usually people use a cluster manager like Kubernetes, Yarn, SLURM, SGE, PBS or something else.  That system handles user authentication, resource management, and so on.  A user then uses the one of the Dask-kubernetes, Dask-yarn, Dask-jobqueue projects to create their own short-lived scheduler and workers on the cluster on an as-needed basis.","Q_Score":0,"Tags":"python,dask,dask-distributed","A_Id":54777689,"CreationDate":"2019-01-11T13:02:00.000","Title":"Dask.distributed cluster administration","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"While looking at the code for the calculations of extraterrestrial radiation get_extra_radiation() and crosschecking it with literature, I noticed that for both methods 'asce' and 'spencer' the solarposition._calculate_simple_day_angle(doy) function is used. This function basically just calculates (2. * np.pi \/ 365.) * (doy- 1), which is correct for method='spencer'.\nBut I think for method='asce' it should just be (2. * np.pi * doy \/ 365.) - without \"- 1\" - as described on page 9 in \"J. A. Duffie and W. A. Beckman,  \"Solar Engineering of Thermal Processes, 3rd Edition\" J. Wiley and Sons, New York (2006)\"","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":54148787,"Users Score":1,"Answer":"I just happen to have this book in front of me, so I checked on page 9, and there is indeed a difference as noted w.r.t. the pvlib-python code.  One formula uses n, the other uses n-1.  This difference is probably not significant, but perhaps it should be fixed just so it is correct.  An issue on github would be the best way to raise this.","Q_Score":0,"Tags":"python,pvlib,solar","A_Id":54153288,"CreationDate":"2019-01-11T14:47:00.000","Title":"Minor mistake in calculation of extraterrestrial radiation (method 'asce')?","Data Science and Machine Learning":0,"Database and SQL":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 getting this error from trying to create a superuser for my Django project. Unsure what table requires a default value for its 'name' column.\nAfter successfully creating migrations for my Django project I ran python manage.py createsuperuser to create the superuser and got the following error:\ndjango.db.utils.IntegrityError: (1364, \"Field 'name' doesn't have a default value\"). I installed mysql (8.0) am using homebrew on OSX and using python 3 in a virtual env.\nI'm not sure which database the above command tries to engage, talk less of which table. In any case I have gone through all tables in the db relevant to my project as well as in the mysql database and have run this command on the only name column found:\nALTER TABLE django_migrations ALTER COLUMN name SET DEFAULT '-'\nBut I am still getting this error. I have read up on createsuperuser in the Django docs as well as looked into some of the Django code but have gleaned very little of value to solving this. Any help with this would be greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2779,"Q_Id":54149866,"Users Score":0,"Answer":"By default Django has a table called auth_user serving the user authentication which doesn't contain a field called name, so my assumption is that you have a custom AUTH_USER_MODEL defined in your settings.py which contains a field called name with not set default value.","Q_Score":3,"Tags":"mysql,django,python-3.x","A_Id":54149997,"CreationDate":"2019-01-11T15:52:00.000","Title":"How to resolve django.db.utils.IntegrityError: (1364, \"Field 'name' doesn't have a default value\")","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In my logs. I'm getting a large number of connections from a local IP address (which changes every time I restart my application. Is this anything to worry about or should I just block internal IPs from making requests to my server","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":54152468,"Users Score":0,"Answer":"Turns out it's because Heroku uses an internal routing system meaning that connections appear to the server as if they had originated from an internal, private ip address","Q_Score":0,"Tags":"python,heroku,server,twisted","A_Id":54154957,"CreationDate":"2019-01-11T18:56:00.000","Title":"Heroku - Private IP address making requests to server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working in python 3.7.0 through a 5.6.0 jupyter notebook inside Anaconda Navigator 1.9.2 running in a windows 7 environment. It seems like I am assuming a lot of overhead, and from the jupyter notebook, python doesn\u2019t see the anytree application module that I\u2019ve installed. (Anytree is working fine with python from my command prompt.)\nI would appreciate either 1) IDE recommendations or 2) advise as to how to make my Anaconda installation better integrated.\n\u200b","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":279,"Q_Id":54152910,"Users Score":0,"Answer":"The core problem with my python IDE environment was that I could not utilize the functions in the anytree module. The anytree functions worked fine from the command prompt python, but I only saw error messages from any of the Anaconda IDE portals.\nSolution: \n1) From the windows start menu, I opened Anaconda Navigator, \"run as administrator.\"\n2) Select Environments. My application only has the single environment, \u201cbase\u201d,\n3.) Open selection \u201cterminal\u201d, and you then have a command terminal window in that environment.\n4.) Execute [ conda install -c techtron anytree ] and the anytree module functions are now available.\n5.) Execute [ conda update \u2013n base \u2013all ] and all the modules are updated to be current.","Q_Score":0,"Tags":"python,anaconda,jupyter-notebook,anytree","A_Id":54173625,"CreationDate":"2019-01-11T19:30:00.000","Title":"Python anytree application challenges with my jupyter notebook \u200b","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a python project that has many open sourced dependencies that may not be regularly maintained. I tried using packages as submodules by adding them with Git; but then I get an error saying the module I want is not available when I try to use the submodule; when I install the package with pip it works fine. This hasn't happened with every package. I am wondering why I can't use the submodule like I would the installed package simply by importing it? \n(Modules seem to be missing from the submodule import vs the pip package installed import.)\nHowever is it better to use these packages as submodules or just add the required package and version number to a requirements.txt file to be installed for production deployment?\n(Any additional functionality required for a submodule or package is added with a wrapper)","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1406,"Q_Id":54154770,"Users Score":7,"Answer":"git is a development tool; you use it during development but not deployment. pip is a deployment tool; during development you use it to install necessary libraries; during deployment your users use it to install your package with dependencies.\nUse submodules when you need something from a remote repository in your development environment. For example, if said remote repository contains Makefile(s) or other non-python files that you need and that usually aren't installed with pip.\nFor everything else pip is preferable.","Q_Score":1,"Tags":"python,git","A_Id":54155860,"CreationDate":"2019-01-11T22:15:00.000","Title":"When does it make sense to use a public package as a Submodule in Python vs installing using pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have collected a large Twitter dataset (>150GB) that is stored in some text files. Currently I retrieve and manipulate the data using custom Python scripts, but I am wondering whether it would make sense to use a database technology to store and query this dataset, especially given its size. If anybody has experience handling twitter datasets of this size, please share your experiences, especially if you have any suggestions as to what database technology to use and how long the import might take. Thank you","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":729,"Q_Id":54154891,"Users Score":-2,"Answer":"you can try using any NOSql DB. Mongo DB would be a good place to start","Q_Score":1,"Tags":"python,database,twitter","A_Id":54154924,"CreationDate":"2019-01-11T22:29:00.000","Title":"Storing large dataset of tweets: Text files vs Database","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'm trying to use the python dlib.train_shape_predictor function to train using a very large set of images (~50,000). \nI've created an xml file containing the necessary data, but it seems like train_shape_predictor loads all the referenced images into RAM before it starts training. This leads to the process getting terminated because it uses over 100gb of RAM. Even trimming down the data set uses over 20gb (machine only has 16gb physical memory).\nIs there some way to get train_shape_predictor to load images on demand, instead of all at once?\nI'm using python 3.7.2 and dlib 19.16.0 installed via pip on macOS.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":738,"Q_Id":54155910,"Users Score":0,"Answer":"I posted this as an issue on the dlib github and got this response from the author:\n\nIt's not reasonable to change the code to cycle back and forth between disk and ram like that. It will make training very slow. You should instead buy more RAM, or use smaller images.\n\nAs designed, large training sets need tons of RAM.","Q_Score":0,"Tags":"python,computer-vision,face-recognition,dlib","A_Id":54161780,"CreationDate":"2019-01-12T01:03:00.000","Title":"How can I train dlib shape predictor using a very large training set","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For some reason I cannot run \"manage.py test AppNameHere\" on my Windows machine but when I run it on a linux machine (I'm not sure if the OS actually matters here) the tests run fine. I am getting this error:\n\n2019-01-11 17:35:32 [DEBUG] faker.factory: Not in REPL -> leaving logger event level as is.\nCreating test database for alias 'default'...\nTraceback (most recent call last):\n  File \"manage.py\", line 22, in \n    execute_from_command_line(sys.argv)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\__init__.py\", line 381, in execute_from_command_line\n    utility.execute()\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\__init__.py\", line 375, in execute\n    self.fetch_command(subcommand).run_from_argv(self.argv)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\commands\\test.py\", line 26, in run_from_argv\n    super().run_from_argv(argv)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\base.py\", line 316, in run_from_argv\n    self.execute(*args, **cmd_options)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\base.py\", line 353, in execute\n    output = self.handle(*args, **options)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\commands\\test.py\", line 56, in handle\n    failures = test_runner.run_tests(test_labels)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\test\\runner.py\", line 604, in run_tests\n    old_config = self.setup_databases()\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\test\\runner.py\", line 551, in setup_databases\n    self.parallel, **kwargs\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\test\\utils.py\", line 174, in setup_databases\n    serialize=connection.settings_dict.get('TEST', {}).get('SERIALIZE', True),\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\backends\\base\\creation.py\", line 68, in create_test_db\n    run_syncdb=True,\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\__init__.py\", line 148, in call_command\n    return command.execute(*args, **defaults)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\base.py\", line 353, in execute\n    output = self.handle(*args, **options)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\base.py\", line 83, in wrapped\n    res = handle_func(*args, **kwargs)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\commands\\migrate.py\", line 203, in handle\n    fake_initial=fake_initial,\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\executor.py\", line 117, in migrate\n    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\executor.py\", line 147, in _migrate_all_forwards\n    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\executor.py\", line 244, in apply_migration\n    state = migration.apply(state, schema_editor)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\migration.py\", line 124, in apply\n    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\operations\\fields.py\", line 84, in database_forwards\n    field,\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\backends\\sqlite3\\schema.py\", line 309, in add_field\n    self._remake_table(model, create_field=field)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\backends\\sqlite3\\schema.py\", line 181, in _remake_table\n    self.effective_default(create_field)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\backends\\base\\schema.py\", line 218, in effective_default\n    default = field.get_default()\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\models\\fields\\related.py\", line 927, in get_default\n    if isinstance(field_default, self.remote_field.model):\nTypeError: isinstance() arg 2 must be a type or tuple of types\nThis looks like something is wrong with Django but I'm not sure. Does anyone have any insights on this? I don't want to go in modifying any of these files from the trace since they are a part of Django.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":622,"Q_Id":54156147,"Users Score":0,"Answer":"what about changing the code\nFile \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\models\\fields\\related.py\", line 927, in get_default\nif isinstance(field_default, type(self.remote_field.model)):","Q_Score":2,"Tags":"django,python-3.x","A_Id":55450690,"CreationDate":"2019-01-12T01:54:00.000","Title":"Django Unittest failing to run with TypeError: isinstance() arg 2 must be a type or tuple of types on one machine but not others","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For some reason I cannot run \"manage.py test AppNameHere\" on my Windows machine but when I run it on a linux machine (I'm not sure if the OS actually matters here) the tests run fine. I am getting this error:\n\n2019-01-11 17:35:32 [DEBUG] faker.factory: Not in REPL -> leaving logger event level as is.\nCreating test database for alias 'default'...\nTraceback (most recent call last):\n  File \"manage.py\", line 22, in \n    execute_from_command_line(sys.argv)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\__init__.py\", line 381, in execute_from_command_line\n    utility.execute()\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\__init__.py\", line 375, in execute\n    self.fetch_command(subcommand).run_from_argv(self.argv)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\commands\\test.py\", line 26, in run_from_argv\n    super().run_from_argv(argv)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\base.py\", line 316, in run_from_argv\n    self.execute(*args, **cmd_options)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\base.py\", line 353, in execute\n    output = self.handle(*args, **options)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\commands\\test.py\", line 56, in handle\n    failures = test_runner.run_tests(test_labels)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\test\\runner.py\", line 604, in run_tests\n    old_config = self.setup_databases()\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\test\\runner.py\", line 551, in setup_databases\n    self.parallel, **kwargs\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\test\\utils.py\", line 174, in setup_databases\n    serialize=connection.settings_dict.get('TEST', {}).get('SERIALIZE', True),\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\backends\\base\\creation.py\", line 68, in create_test_db\n    run_syncdb=True,\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\__init__.py\", line 148, in call_command\n    return command.execute(*args, **defaults)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\base.py\", line 353, in execute\n    output = self.handle(*args, **options)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\base.py\", line 83, in wrapped\n    res = handle_func(*args, **kwargs)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\commands\\migrate.py\", line 203, in handle\n    fake_initial=fake_initial,\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\executor.py\", line 117, in migrate\n    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\executor.py\", line 147, in _migrate_all_forwards\n    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\executor.py\", line 244, in apply_migration\n    state = migration.apply(state, schema_editor)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\migration.py\", line 124, in apply\n    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\operations\\fields.py\", line 84, in database_forwards\n    field,\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\backends\\sqlite3\\schema.py\", line 309, in add_field\n    self._remake_table(model, create_field=field)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\backends\\sqlite3\\schema.py\", line 181, in _remake_table\n    self.effective_default(create_field)\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\backends\\base\\schema.py\", line 218, in effective_default\n    default = field.get_default()\n  File \"C:\\Users\\personA\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\models\\fields\\related.py\", line 927, in get_default\n    if isinstance(field_default, self.remote_field.model):\nTypeError: isinstance() arg 2 must be a type or tuple of types\nThis looks like something is wrong with Django but I'm not sure. Does anyone have any insights on this? I don't want to go in modifying any of these files from the trace since they are a part of Django.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":622,"Q_Id":54156147,"Users Score":1,"Answer":"I solved this by:\n\ndeleting all my migration files\nremoving the entries in the django_migrations table\nremade migrations (makemigrations)\ndid a migrate --fake","Q_Score":2,"Tags":"django,python-3.x","A_Id":61032897,"CreationDate":"2019-01-12T01:54:00.000","Title":"Django Unittest failing to run with TypeError: isinstance() arg 2 must be a type or tuple of types on one machine but not others","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I set up a virtual environment in python 3.7.2 using \"python -m venv foldername\". I installed PIL in that folder. Importing PIL works from the terminal, but when I try to import it in VS code, I get an ImportError. Does anyone know how to get VS code to recognize that module?\nI've tried switching interpreters, but the problem persists.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":949,"Q_Id":54156432,"Users Score":0,"Answer":"I ended up changing the python.venvpath setting to a different folder, and then moving the virtual env folder(The one with my project in it) to that folder. After restarting VS code, it worked.","Q_Score":0,"Tags":"python-3.x,visual-studio-code,virtualenv","A_Id":54171724,"CreationDate":"2019-01-12T03:01:00.000","Title":"How do I get VS Code to recognize modules in virtual environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My VSCode is using a locally installed anaconda environment, at the default directory, which places it in Program Files. Because of this I'm unable to install flake8 through VSCode, I get a permission error. If I update my conda environment at the local level to install flake8, does anyone know if VSCode recognize and be able to use the package then?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":37381,"Q_Id":54160207,"Users Score":3,"Answer":"Yes, it will. You'll have to install flake8 into each environment that you specify as an interpreter for a project in VSCode.","Q_Score":23,"Tags":"python,visual-studio-code,anaconda,flake8","A_Id":54160227,"CreationDate":"2019-01-12T13:52:00.000","Title":"Using Flake8 in VSCode...?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My VSCode is using a locally installed anaconda environment, at the default directory, which places it in Program Files. Because of this I'm unable to install flake8 through VSCode, I get a permission error. If I update my conda environment at the local level to install flake8, does anyone know if VSCode recognize and be able to use the package then?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":37381,"Q_Id":54160207,"Users Score":12,"Answer":"Have you tried to:\n\n\nctrl + shift + p\nwrite \"select linter\" then click on it\nclick on flake8\n\n\nMaybe that helps.","Q_Score":23,"Tags":"python,visual-studio-code,anaconda,flake8","A_Id":67155527,"CreationDate":"2019-01-12T13:52:00.000","Title":"Using Flake8 in VSCode...?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a code that takes in a video then constructs a list of frames from that video. then does something with each frame then put the frames back together into cv2 video writer. However, when the video is constructed again, it loses all its audio.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2044,"Q_Id":54161418,"Users Score":2,"Answer":"Stephen Meschke is right ! Use FFMPEG to extract and import audio.\nType in cmd:\nExtract audio:\nffmpeg -i yourvideo.avi -f mp3 -ab 192000 -vn sound.mp3\nImport audio:\nffmpeg -i yourvideo.avi -i sound.mp3 -c copy -map 0:v:0 -map 1:a:0 output.avi","Q_Score":2,"Tags":"python-3.x,opencv,audio,video-processing,cv2","A_Id":57248756,"CreationDate":"2019-01-12T16:15:00.000","Title":"Python3.6 add audio to cv2 processed video","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"X in this example represents any module or package you install.\nThe problem:\nI have a problem with a package called 'X'.\nIn PyCharm I get an error ImportError: No module named 'X'.\nMy code runs from the terminal without any problem. Any help ?\nor\nI installed X on python3.4 with pip. In terminal, when I import X, everything is fine, but when I import it in PyCharm, it says: ImportError: No module named 'X'\". Any help ?\n\nThis is basically everyday question, just with different module or a package instead name instead of X.\nAnd it's not problem in a package or module you install, it's in a PyCharm Project Interpreter you are currently using for your project.\nThe following answer is usually solution to this specific problem.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5445,"Q_Id":54164669,"Users Score":0,"Answer":"PyCharm creates a virtual environment with its own Python Interpreter for your project, you need to install the module for the interpreter you are using. To do this go to Settings -> Project: yourProjectName -> Python Interpreter, click the plus icon and select the module you would like to install.\nAlternatively you could force PyCharm to use your other Interpreter by selecting it from the dropdown at the top of the Python Interpreter settings page I mentioned before.","Q_Score":1,"Tags":"python,pip,pycharm,package,importerror","A_Id":54164821,"CreationDate":"2019-01-12T23:02:00.000","Title":"PyCharm: ImportError no module named X?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Keras 2.0 has removed keras.layers.merge and now we should use keras.layers.Concatenate, \nI was wonder what is the equivalent to having the 'cos' and 'dot_axis=0' arg, for example\nsimilarity = keras.layers.merge([target, context], mode='cos', dot_axes=0) \nHow would I write that in keras 2.0?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":787,"Q_Id":54165333,"Users Score":3,"Answer":"I tried with:\nsimilarity = dot([target, context], axes=1, normalize=True)","Q_Score":1,"Tags":"python,tensorflow,keras","A_Id":56676328,"CreationDate":"2019-01-13T01:16:00.000","Title":"What is the Keras 2.0 equivalent of `similarity = keras.layers.merge([target, context], mode='cos', dot_axes=0)`","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large number of some large json files to work with.\nUnfortunately not all of the json data is well structured.\nIn a nutshell the data is shaped like \n\n[\n      { A1:va1,\n          B:[\n              {B1:vb1, ...},\n              {B2...},\n              {...}\n          ]\n      },\n      { A2 ....},\n      {....}\n  ]\n\nAn array of A objects that, among other things, contains an inner array of none-to-many B objects.\nUnfortunately on random occasion a given B object will have a structural violation.\nWhat I want to do is iterate over the A level but enforce the B objects be treated as individual strings, rather being parsed by json.loads() -or- causing json.loads() to treat each instance of a B as a string, so I can log the B strings for first-hand examination.\nAs I said, the data shape above is only in a nutshell.  In the real data there is A LOT more going on ambiguously at the top A level ~ because of that I don't think I can successfully define and apply a schema effectively to this data.  At least at the top A level there are not any structural violations.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":133,"Q_Id":54165886,"Users Score":0,"Answer":"The issue is I could examine the data with any amount of certainty.\nIn 15 minutes I had the answer using this approach; not the answer I wanted but at least I now know what I have to deal with.\nI took one file loaded it into Notepad++ with the JSON Formatter add-in.\nFormatted it and dropped that into an Excel sheet.  Added a few columns with equations to point out the lines of interest, a couple of Ctrl-F Find All, and sorts.\nNow my worst case scenario is right there in front of me.  But at least I now know.","Q_Score":0,"Tags":"python,arrays,json","A_Id":54169903,"CreationDate":"2019-01-13T03:37:00.000","Title":"Python only deserialize top layer json data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a form using reportlab and its in two columns. The second columns is just a copy of the first column. \nI used Frame() function to create two columns and I used a Spacer() function to separate the original form from the copied form into two columns. \nMy expected result is to make the data from the second column stay in place. But the result that I'm getting is when the data from the first columns gets shorter the second columns starts shifting up and moves to the first column.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":54166726,"Users Score":2,"Answer":"If I get your question correct, the problem is that you use a spacer to control the contents' visual placement in two columns\/frames. By this, you see it as a single long column split in two, meanwhile you need to see it as two separate columns (two separate frames).\nTherefore you will get greater control if you end the first frame (with FrameBreak() before start filling the other and only use the spacer to control any visual design within the same frame.\nTools you need to be aware of are:\nFrameBreak(), if you search for it you will find many code examples.\ne.g. you fill frame 1 with with 10 lines of text, then you insert a FramBreak() and instruct the script to start filling the second column.\nAnother tool you should be aware of is the settings used e.g for BaseDocTemplate:\nallowSplitting: If set to 1, flowables (eg, paragraphs) may be split across frames or pages. If 0, you force content into the same frame. (default: 1, disabled with 0).","Q_Score":1,"Tags":"python,reportlab","A_Id":54192306,"CreationDate":"2019-01-13T06:55:00.000","Title":"Make the data from the second column stay at the second column","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While I was testing an uix example of Kivy (modalview.py), the cursor suddenly disappeared while over the application window. When I move out of the window, the cursor reappears. The cursor disappears only when it is inside the Kivy window, but I can still interact with the widgets (i.e. buttons, ...).\nSince then, I have this behaviour with any Kivy application and only these applications.\nI have reinstalled Python and Kivy, I have restarted my computer, updated my touchpad and GPU drivers (even though there should be absolutely no reason, but I'm desperate...), nothing changes.\nAny suggestion?\nThanks!\nI'm working with:\nWindows 10\nPython 3.7.2\nKivy 1.10.1","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":178,"Q_Id":54170061,"Users Score":1,"Answer":"The solution (thanks to inclement) is to simply check the Kivy settings.\nThe best way to access them (to me) is launching the \"Settings.py\" in \"Lib\\site-packages\\kivy\\uix\".\nFrom there, the \"show\/hide cursor\" can be toggled on.","Q_Score":1,"Tags":"python,windows,window,kivy","A_Id":54170324,"CreationDate":"2019-01-13T14:55:00.000","Title":"kivy application cursor don't show when over the window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using PyCharm and following a step-by-step guide for setting up a cookiecutter Django project. Can't seem to get past the migrate command. \nThis is my first time using the cookiecutter project template and I haven't had issues before when creating projects from scratch. Not sure what the issue is but it looks like it may be related to the INSTALLED_APPS, but I haven't modified any of the files from the template.\nError is listed below:\n\n\"C:\\Program Files\\JetBrains\\PyCharm 2018.3\\bin\\runnerw64.exe\"\n  C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\python.exe\n  \"C:\\Program Files\\JetBrains\\PyCharm\n  2018.3\\helpers\\pycharm\\django_manage.py\" migrate C:\/Users\/willi\/PycharmProjects\/fishgutz Tracking file by folder\n  pattern:  migrations Traceback (most recent call last):   File\n  \"C:\\Program Files\\JetBrains\\PyCharm\n  2018.3\\helpers\\pycharm\\django_manage.py\", line 52, in \n      run_command()   File \"C:\\Program Files\\JetBrains\\PyCharm 2018.3\\helpers\\pycharm\\django_manage.py\", line 46, in run_command\n      run_module(manage_file, None, 'main', True)   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\runpy.py\",\n  line 205, in run_module\n      return _run_module_code(code, init_globals, run_name, mod_spec)   File\n  \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\runpy.py\",\n  line 96, in _run_module_code\n      mod_name, mod_spec, pkg_name, script_name)   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\runpy.py\",\n  line 85, in _run_code\n      exec(code, run_globals)   File \"C:\/Users\/willi\/PycharmProjects\/fishgutz\\manage.py\", line 30, in\n  \n      execute_from_command_line(sys.argv)   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management__init__.py\",\n  line 371, in execute_from_command_line\n      utility.execute()   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management__init__.py\",\n  line 365, in execute\n      self.fetch_command(subcommand).run_from_argv(self.argv)   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management__init__.py\",\n  line 216, in fetch_command\n      klass = load_command_class(app_name, subcommand)   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management__init__.py\",\n  line 36, in load_command_class\n      module = import_module('%s.management.commands.%s' % (app_name, name))   File\n  \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\importlib__init__.py\",\n  line 126, in import_module\n      return _bootstrap._gcd_import(name[level:], package, level)   File \"\", line 994, in _gcd_import   File\n  \"\", line 971, in _find_and_load   File\n  \"\", line 955, in _find_and_load_unlocked \n  File \"\", line 665, in _load_unlocked\n  File \"\", line 678, in\n  exec_module   File \"\", line 219, in\n  _call_with_frames_removed   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\commands\\migrate.py\",\n  line 12, in \n      from django.db.migrations.autodetector import MigrationAutodetector   File\n  \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\autodetector.py\",\n  line 11, in \n      from django.db.migrations.questioner import MigrationQuestioner   File\n  \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\questioner.py\",\n  line 9, in \n      from .loader import MigrationLoader   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\loader.py\",\n  line 8, in \n      from django.db.migrations.recorder import MigrationRecorder   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\recorder.py\",\n  line 9, in \n      class MigrationRecorder:   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\recorder.py\",\n  line 22, in MigrationRecorder\n      class Migration(models.Model):   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\models\\base.py\",\n  line 100, in new\n      app_config = apps.get_containing_app_config(module)   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\apps\\registry.py\",\n  line 244, in get_containing_app_config\n      self.check_apps_ready()   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\apps\\registry.py\",\n  line 127, in check_apps_ready\n      raise AppRegistryNotReady(\"Apps aren't loaded yet.\") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.\nProcess finished with exit code 1\nExpected: postgres database configures and I can then runserver","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":54173128,"Users Score":0,"Answer":"Are you using separated settings module? If you are, you must export DJANGO_SETTINGS_MODULE=<your_settings_module>\nFor example, when your settings separated byprod\/settings\/local.py and prod\/settings\/deploy.py\nexport DJANGO_SETTINGS_MODULE=prod.settings.local\nor \nexport DJANGO_SETTINGS_MODULE=prod.settings.deploy","Q_Score":0,"Tags":"python,django,django-migrations","A_Id":54174783,"CreationDate":"2019-01-13T20:55:00.000","Title":"Django first migration issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Using PyCharm and following a step-by-step guide for setting up a cookiecutter Django project. Can't seem to get past the migrate command. \nThis is my first time using the cookiecutter project template and I haven't had issues before when creating projects from scratch. Not sure what the issue is but it looks like it may be related to the INSTALLED_APPS, but I haven't modified any of the files from the template.\nError is listed below:\n\n\"C:\\Program Files\\JetBrains\\PyCharm 2018.3\\bin\\runnerw64.exe\"\n  C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\python.exe\n  \"C:\\Program Files\\JetBrains\\PyCharm\n  2018.3\\helpers\\pycharm\\django_manage.py\" migrate C:\/Users\/willi\/PycharmProjects\/fishgutz Tracking file by folder\n  pattern:  migrations Traceback (most recent call last):   File\n  \"C:\\Program Files\\JetBrains\\PyCharm\n  2018.3\\helpers\\pycharm\\django_manage.py\", line 52, in \n      run_command()   File \"C:\\Program Files\\JetBrains\\PyCharm 2018.3\\helpers\\pycharm\\django_manage.py\", line 46, in run_command\n      run_module(manage_file, None, 'main', True)   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\runpy.py\",\n  line 205, in run_module\n      return _run_module_code(code, init_globals, run_name, mod_spec)   File\n  \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\runpy.py\",\n  line 96, in _run_module_code\n      mod_name, mod_spec, pkg_name, script_name)   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\runpy.py\",\n  line 85, in _run_code\n      exec(code, run_globals)   File \"C:\/Users\/willi\/PycharmProjects\/fishgutz\\manage.py\", line 30, in\n  \n      execute_from_command_line(sys.argv)   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management__init__.py\",\n  line 371, in execute_from_command_line\n      utility.execute()   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management__init__.py\",\n  line 365, in execute\n      self.fetch_command(subcommand).run_from_argv(self.argv)   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management__init__.py\",\n  line 216, in fetch_command\n      klass = load_command_class(app_name, subcommand)   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management__init__.py\",\n  line 36, in load_command_class\n      module = import_module('%s.management.commands.%s' % (app_name, name))   File\n  \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\importlib__init__.py\",\n  line 126, in import_module\n      return _bootstrap._gcd_import(name[level:], package, level)   File \"\", line 994, in _gcd_import   File\n  \"\", line 971, in _find_and_load   File\n  \"\", line 955, in _find_and_load_unlocked \n  File \"\", line 665, in _load_unlocked\n  File \"\", line 678, in\n  exec_module   File \"\", line 219, in\n  _call_with_frames_removed   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\core\\management\\commands\\migrate.py\",\n  line 12, in \n      from django.db.migrations.autodetector import MigrationAutodetector   File\n  \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\autodetector.py\",\n  line 11, in \n      from django.db.migrations.questioner import MigrationQuestioner   File\n  \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\questioner.py\",\n  line 9, in \n      from .loader import MigrationLoader   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\loader.py\",\n  line 8, in \n      from django.db.migrations.recorder import MigrationRecorder   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\recorder.py\",\n  line 9, in \n      class MigrationRecorder:   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\migrations\\recorder.py\",\n  line 22, in MigrationRecorder\n      class Migration(models.Model):   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\db\\models\\base.py\",\n  line 100, in new\n      app_config = apps.get_containing_app_config(module)   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\apps\\registry.py\",\n  line 244, in get_containing_app_config\n      self.check_apps_ready()   File \"C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\django\\apps\\registry.py\",\n  line 127, in check_apps_ready\n      raise AppRegistryNotReady(\"Apps aren't loaded yet.\") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.\nProcess finished with exit code 1\nExpected: postgres database configures and I can then runserver","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":54173128,"Users Score":0,"Answer":"I redid the process but chose NOT to include Celery and the migration and server ran successfully. I believe that app was not set up in entirety and was throwing off the project. To avoid continued headache, I chose to exclude it for now in the new setup. Thank you for the help @Yongjin Jo!","Q_Score":0,"Tags":"python,django,django-migrations","A_Id":54189972,"CreationDate":"2019-01-13T20:55:00.000","Title":"Django first migration issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am running packer via a jenkins pipeline and want to delete the ami afterwards.\nI am using a small python3\/boto3 script to do that.\nHowever, when calling describe_images I get an empty list. No errors (via debug).\nIf I run the same script via the same docker based agent (on a ec2 jenkins node) but from a different pipeline, it works.\nI also do not have issues on another project with similar settings.\nSometimes, intermittently it will work, but seldom.\nI can rule out a general config issue as the same script works perfectly on the same systems (just a different jenkins pipeline).\nI can also rule out general issue with the jenkins pipeline, as it will intermittently work - without changes.\nWhat am I missing?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":54174681,"Users Score":0,"Answer":"Yikes, this was a stupid mistake on my side. So my script to fetch the ami-id from the packer manifest.json was not returning the correct ami-id (I assumed I'd only find one ami-id in that file).","Q_Score":0,"Tags":"python-3.x,jenkins,amazon-ec2,boto3,packer","A_Id":54188546,"CreationDate":"2019-01-14T01:03:00.000","Title":"boto3 describe_images empty (jenkins\/packer)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We know that elimination requires roughly 1\/3 n^3 operations, and if we use LU decomposition stored in memory, it is reduced to n^2 operations. If we have a band matrix with w upper and lower diagonals, we can skip the zeros and bring it down to about nw^2 operations, and if we use LU decomposition, it can be done in about 2nw operations.\nIn scipy.linalg, we have lu_factor and lu_solve, but they do not seem to be optimized for band matrices. We also have solve_banded, but it directly solves Ax=b. How can we do an efficient LU decomposition for banded matrices and efficiently perform forward and backward elimination with banded triangular L and U?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":407,"Q_Id":54175192,"Users Score":0,"Answer":"Lapack's *gbsv routine computes the LU decomp of an input banded matrix. \nFrom python, you can use either its f2py wrapper (see e.g. the source of scipy.linalg.solve_banded for example usage) or drop to Cython and use scipy.linalg.cython_lapack bindings.","Q_Score":0,"Tags":"python,scipy,linear-algebra","A_Id":54260769,"CreationDate":"2019-01-14T02:41:00.000","Title":"Can we use scipy to do faster LU decomposition for band matrices?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am processing a dataset with a date column in it. But the date format is strange to me:\ndate\n59:06.4\n42:42.9\n07:18.0\n......\nI have never seen this format before. Could anyone let me know what this format is? and if I use python to process it, what functions I should use?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":54176475,"Users Score":0,"Answer":"I think I know. This is the date + time format. When I read it in python. It automatically transfer into datetime format","Q_Score":0,"Tags":"python,date,format","A_Id":54190381,"CreationDate":"2019-01-14T06:08:00.000","Title":"which date format looks like this: 46:53.4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Running Python 3.7.1 on a Win10 machine.\nWhen I create a new virtualenv python -m venv new-virtual-env the pip version being installed is always 10.0.1 \nEven though the pip version on my non-virtualenv python is 18.1\nAnyone a suggestion how to solve this without having to manually update pip inside the virtualenv ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1086,"Q_Id":54177904,"Users Score":2,"Answer":"AFAIK, the problem is that the virtual env copies a bunch of files directly from the original installation folders, while pip normally writes the packages it downloads under the site_packages directory.\nAs the newly created virtual env uses its own files first, it reverts to the old version until you use the magic python -m pip install pip inside the virtualenv.\nIt looks like a minor defect, but I could not find any straight workaround, except consistently upgrading pip in each and every new virtualenv.","Q_Score":1,"Tags":"python,pip,virtualenv","A_Id":54178215,"CreationDate":"2019-01-14T08:27:00.000","Title":"Python: pip version when creating a new virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In a Windows Server machine, python is installed in one account in the following path:\nC:\\Users\\user1\\AppData\\Local\\Programs\\Python\\Python36\nI would like to move the python installation from that account to another account in the C:\/ drive. Since most of the modules are already installed in that Python, I do not like to do a fresh install in the new account.\nI copied the entire installation to the new location and I tried setting the following path in the new account.\nC:\\Python\\Python36\nBut python --version did not work (even after restarting the system).\nWhat do you think I must be doing wrong here?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":972,"Q_Id":54179038,"Users Score":0,"Answer":"Find Python Setup, then uninstall the python.\nReinstall it again, but before the installation do it like this: choose 'Customize Installation' -> Next -> browse -> choose choose your folder, or just tick 'Install for all users' box.","Q_Score":0,"Tags":"python,installation","A_Id":54179505,"CreationDate":"2019-01-14T09:49:00.000","Title":"Is it possible to move python installation from one windows account to another?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am logging to a website with valid credentials, but if my network changes or even device gets changed (within same network); it redirects to Authentication page where I have to put the access code, which I received via email. I want to skip this authentication page and navigate to other pages to continue my process. \nExpected result - Home page of the site\nActual result - Secure Access Code page","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1260,"Q_Id":54180659,"Users Score":1,"Answer":"When you initialise your driver you can  configure the browser to load your chrome profile, that is if your using chrome. This may allow you to bypass the authentication page if you have had a previous login with this profile. Not sure if this will work but it worth a shot.","Q_Score":0,"Tags":"python,selenium-webdriver","A_Id":54180917,"CreationDate":"2019-01-14T11:29:00.000","Title":"2 factor authentication handling in selenium webdriver with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been getting error-messages when trying to install PuLP within my Anaconda environment:\n\nPreparing transaction: done Verifying transaction: done Executing\n  transaction: failed ERROR conda.core.link:_execute(507): An error\n  occurred while installing package\n  'conda-forge\/label\/cf201901::automat-0.7.0-py_1'. CondaError: Cannot\n  link a source that does not exist.\n  C:\\Users\\MarkKremer\\Anaconda3\\Scripts\\conda.exe Running conda clean\n  --packages may resolve your problem. Attempting to roll back.\n\nI have tried all kind of this to resolve this issue, but nothing seems to work. The strange thing is that I have had PuLP working on this computer before, but somehow I managed to break it and can't get it fixed. \nWhat I've tried:\n\nDifferent commands to install such as conda install -c conda-forge pulp and conda install -c conda-forge\/label\/cf201901 pulp)\nUsing conda clean --all, conda clean --packages etc. \nFully delete and reinstall Anaconda. \nFormat the harddisk and create a clean install of Windows 10. \n\nNone of these things seem to work. Does anyone recognize this problem or have any suggestions for possible solutions? \nI'm using Python 3.7 on Windows 10, with a 32bit Anaconda installation","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1409,"Q_Id":54182200,"Users Score":2,"Answer":"I finally managed to resolve the issue myself. In case anyone else is experiencing this issue, I'll share my solution: \nMy solution: \n\nReinstall the automat package by running conda uninstall automat followed by conda install automat.\nOpen Anaconda Promst as administrator\nRun conda install -c conda-forge\/label\/cf201901 pulp","Q_Score":0,"Tags":"python,python-3.x,anaconda,conda,pulp","A_Id":54183939,"CreationDate":"2019-01-14T13:09:00.000","Title":"Unable to install PuLP in Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset of medical images in grayscale Png format which must be converted to RGB format. Tried many solutions but in vain.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1046,"Q_Id":54182675,"Users Score":1,"Answer":"GIMP, Menu image -> Mode -> RGB mode","Q_Score":0,"Tags":"python,rgb,grayscale,medical,image-preprocessing","A_Id":54182847,"CreationDate":"2019-01-14T13:41:00.000","Title":"Convert grayscale png to RGB png image","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a web-socket client which sends audio binary data in the request and receive them as a response from the web-socket server. I am using pyaudio to read binary audio data from (file\/microphone) which I then sending to the server. Then  as the response I receive another binary audio data from the server. The question is can I use my recently opened pyaudio reading stream to play receiving audio in real time or I better need to create another pyaudio stream (Have two streams where one is responsible for binary data reading and another for binary data writing)?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1404,"Q_Id":54183268,"Users Score":1,"Answer":"be aware of the fact, that, as far as I know, reading stream data is kind of generator process. Once you read it, you lose the data - In other words: based on your chunk, you basicly by every 'read' move a pointer that grabs your binary data.\nAnswer\nWhy dont you create 2 threads with 2 streams? Dont be afraid of streams. You can initialize as many as you want.\n\n1 thread receives binary data and push them into stream(from client to your sound device)\n2 thread receive data from your input stream (in binary form from your mic) and you push them to your client?\n\nI am working now little bit with PyAudio and streaming is quite interesting but hard to understand from programming point of view. You can actually create 2 output streams into your headphones and somewhere in a hardware on the way to your headphones the streams sum up themselves so you can simply listen two sounds in the same time. \nNOTE:\nAlso I wanted to say that you dont have to be worry about using threads. The streams works in batch, not in realtime. Whether it is read or write, it works in the way, that you have binary data which you push in a stream and you are done. Hardware accepts the binary data, stream them and only after it finishes, then the stream asks for another data. So if you have sample_rate 44100 and chunk 22050(just example), your loop will be just 0.5s. So you dont have to be even worry about overflows, too much data to handle or your threads getting crazy. \nIn fact, the moment you push data to stream, your python waits for your hardware to finish the job. Its very leightweight.","Q_Score":1,"Tags":"python,audio,audio-streaming,pyaudio","A_Id":54183504,"CreationDate":"2019-01-14T14:20:00.000","Title":"Using one pyaudio stream for both data reading and writing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When using Spyder2 one can create a workspace, a project and also say that two ore more projects were related. In spyder 3 one can only create projects, the concept of workspace seems to have disappeared. Is this true? The concept of related projects allowed one to import objects from a related project, as if they were objects defined in an installed package. \nIs it true that these features have disappeared in Spyder3? It seems to me so, but I still cannot believe it. If so, what were the reasons behind this choice?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":54183486,"Users Score":1,"Answer":"(Spyder maintainer here) That's correct, workspaces were removed in Spyder 3 and I think they won't come back, sorry.\nWe decided to do that because they made the graphical interface confusing and the implementation very hard to maintain and extend. So we decided to rewrite our Projects support from scratch in Spyder 3.","Q_Score":0,"Tags":"python,spyder","A_Id":54189257,"CreationDate":"2019-01-14T14:35:00.000","Title":"Workspace support removed in Spyder 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using spyder and python 3.7. Due to various restrictions on my role I can only use sys arguments by adding them in run >> configuration per file. This works perfectly if I'm only passing one argument. When I add multiple, they are read as one. I've tried separating with , (comma), ;semicolon,single and double quotes, and as a list []. None of these work. Is there a specific way to pass a list of arguments rather than just one? I've looked all over but no solutions so far on this. Is this a bug? Or is there a straightforward fix?\nAgain, I'm looking to add a list of arguments by using the navigation menu run >> configuration per file, and adding multiple arguments in the text box.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":233,"Q_Id":54185185,"Users Score":0,"Answer":"(Spyder maintainer here) You need to enter different arguments in Run > Configuration per file separated by - or --, for example\n-x 10 --start 20","Q_Score":1,"Tags":"python,command-line,arguments,spyder","A_Id":54189327,"CreationDate":"2019-01-14T16:13:00.000","Title":"How to add multiple sys args in Spyder python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python 2 and Python 3 BOTH within the same conda environment.\nYes, that's right. I don't have 2 separate environments...but just one. And it has Python 2 and Python 3 installed in it.\nFirst question: Is this bad practice? I'm starting to feel like it is.\nSay I want to install Pandas, but for the Python 3 install. And explicitly NOT the Python 2 install. How do I do this? \nI read documentation but couldn't find the flag I feel like should exist for this to be done.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":924,"Q_Id":54187409,"Users Score":1,"Answer":"Yes, I'd consider this bad practice. As a general rule of thumb, software that requires different\/specific versions serve as good delimiters for splitting off into separate envs.\nI'm not sure that conda can handle this directly, but pip can since you can have multiple versions of it installed side-by-side.  Namely, installing packages with pip2 and pip3 should install to the Python 2 and 3 site-packages, respectively.  Just verify first with which pip2 and which pip3 that this corresponds to the Python installations you wish to modify.  It is a very common mistake to use pip2 and it turn out to still be the default system one and not a conda one.\nAs I mentioned in a comment, I'd like to see the full history of your env (conda list --revisions to provide more specific suggestions.","Q_Score":0,"Tags":"python,conda","A_Id":54205404,"CreationDate":"2019-01-14T18:46:00.000","Title":"uninstall a package for a particular version of python using conda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using multiprocessing pool to speed up the title extraction process on a text corpus. At one stage of the code, I am using wordnet path similarity module to determine the similarity of two words. \nIf i run my code sequentially i.e. without the use of multiprocessing pool, I get normal times in calculating this path similarity. However, when I use multiprocessing to process multiple documents simultaneously, I observe great time delays in computing this path similarity as compared to sequential.\nQuestion: Does NLTK show any problems with multiprocessing module ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":173,"Q_Id":54187798,"Users Score":1,"Answer":"It is very likely that the module in separate processes attempts to access the very same file with Wordnet data. This would result in dependence on GIL to access the file or OS-level file locks use. Both cases would explain the behaviour you are observing.","Q_Score":0,"Tags":"python,nltk,python-multiprocessing,pool,wordnet","A_Id":54188845,"CreationDate":"2019-01-14T19:17:00.000","Title":"Python multiprocesing and NLTK wordnet path similarity","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I submit a dask task, I can specify the requisite resources for that task.  e.g. client.submit(process, d, resources={'GPU': 1})\nHowever, If I abstract my dask scheduler away as a joblib.parallel_backend, it is not clear how to specify resources when I do so.\nHow do I call joblib.parallel_backend('dask') and still specify requisite resources?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":193,"Q_Id":54188251,"Users Score":1,"Answer":"As of 2019-02-19, there is no way to do this.","Q_Score":0,"Tags":"python,dask,joblib","A_Id":54777735,"CreationDate":"2019-01-14T19:53:00.000","Title":"joblib parallel_backend with dask resources","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is not one of coding per say, but of understanding the algorithm. \nConceptually I understand how the column transposition deciphers text with a constant key value for example 10.\nMy confusion occurs, when the key is a permutation. For example key = [2,4,6,8,10,1,3,5,7,9] and a message like \"XOV EK HLYR NUCO HEEEWADCRETL CEEOACT KD\". The part where I'm confused is writing the cipher text into rows, then permuting the row according to the key. \nCan someone please provide some clarification on this.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1074,"Q_Id":54190370,"Users Score":0,"Answer":"I figured it out. Once you know the number of rows and columns, you can write the ciphertext into the rows, then permute the rows according to the key. Please correct if my explanation is wrong.  The plain text is \"execlent work you have cracked the code\"","Q_Score":1,"Tags":"python,encryption,cryptography","A_Id":54190671,"CreationDate":"2019-01-14T22:49:00.000","Title":"How to decrypt a columnar transposition cipher","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to figure out how to list out all the standard library functions\/methods (still learning the difference, I'm a noob). So I get how to import a module and use dir() and help(). These have been a great help and when I try to rewrite a program I learned to write and I get lost I try to use the dir() and help() to spark my memory.\nHowever, for example, I was re-looking through some code and I had .replace() and I was scouring through my imported modules to find it and then found out it's in the standard library and a sub-part of the str() function. Is there something I can type into dir() that will spit out str()?\nHow can I print out all top level built in function\/methods like I would when I do dir(re)?\nI've tried re-wording this question in search engines several ways and I can't find anything and the results get muddied with \"python list _____\".\nThanks so much!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":54192611,"Users Score":0,"Answer":"Ah, I never tried typing just \"dir()\" that listed I could put in dir(__builtins__) and that is what I was looking for. I'll leave it here in case someone else is a noob too and knows where they can start. Just start with dir() and go down the rabbit hole!","Q_Score":0,"Tags":"python","A_Id":54192669,"CreationDate":"2019-01-15T04:13:00.000","Title":"How to print all available python standard library methods in the terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the yolov3 model running on several surveillance cameras. Besides this I also run tensorflow models on these surveillaince streams. I feel a little lost when it comes to using anything but opencv for rtsp streaming.\nSo far I haven't seen people use anything but opencv in python. Are there any places I should be looking into. Please feel free to chime in.\nSorry if the question is a bit vague, but I really don't know how to put this better. Feel free to edit mods.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":54193968,"Users Score":1,"Answer":"Of course are the alternatives to OpenCV in python if it comes to video capture but in my experience none of them preformed better","Q_Score":0,"Tags":"python,opencv,video,video-streaming,video-processing","A_Id":54197292,"CreationDate":"2019-01-15T06:52:00.000","Title":"Good resources for video processing in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In s3 bucket daily new JSON files are dumping , i have to create solution which pick the latest file when it arrives PARSE the JSON and load it to Snowflake Datawarehouse. may someone please share your thoughts how can we achieve","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1762,"Q_Id":54193979,"Users Score":0,"Answer":"There are some aspects to be considered such as is it a batch or streaming data , do you want retry loading the file in case there is wrong data or format or do you want to make it a generic process to be able to handle different file formats\/ file types(csv\/json) and stages. \nIn our case we have built a generic s3 to Snowflake load using Python and Luigi and also implemented the same using SSIS but for csv\/txt file only.","Q_Score":2,"Tags":"python,amazon-s3,snowflake-cloud-data-platform","A_Id":54209309,"CreationDate":"2019-01-15T06:54:00.000","Title":"Automate File loading from s3 to snowflake","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any configuration in visual studio code that only lint changed the file (python, javascript, CSS)?. I don't want to lint existing\/unmodified file. I just to want lint the code which I have written.\nNote. used flake8 and eslint for linting","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":996,"Q_Id":54195416,"Users Score":0,"Answer":"The Python extension only lints opened files, but it won't distinguish between unmodified or dirty files.","Q_Score":1,"Tags":"javascript,python,visual-studio-code,linter","A_Id":54206962,"CreationDate":"2019-01-15T08:49:00.000","Title":"Visual Studio Code How to lint only changed file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between using pipenv install <package> compared \n to using pip install <package> after activating an environment using pipenv shell.\nI know pipenv install <package> will \n\nCreate the virtual environment if it is not created yet.\nRuns pipenv lock command automatically.\n\nApart from these, is there any other difference between these two?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10065,"Q_Id":54197692,"Users Score":24,"Answer":"If you are installing using a pipenv environment you should always install your packages using pipenv, this way it will update your pipfile.lock file. Also be careful because pip install <package> will pretty much work anywhere, it's not installing packages to your virtual environment, it's installing them into your computer. Pipenv will update your Pipfile.lock and actually install into your pipenv virtual enviroment if you have one open. \nIt's rarely a good idea to pip install <package> outside of a virtualenv.","Q_Score":36,"Tags":"python-3.x,pipenv","A_Id":54351636,"CreationDate":"2019-01-15T11:10:00.000","Title":"What is the difference between pipenv install  compared to pip install ?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My main OS is windows 10 but I am using cygwin as a terminal. While installing uwsgi through pip3 install uwsgi command , it fails with an error message \" AttributeError: module 'os' has no attribute 'uname'\"","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2723,"Q_Id":54200746,"Users Score":1,"Answer":"If you get:\ncore\/event.c: In function \u2018event_queue_read\u2019: core\/event.c:1416:9: error: \u2018UWSGI_EVENT_IN\u2019 undeclared\nprobably you don't start setup install with cygwin python","Q_Score":2,"Tags":"python-3.x,windows,cygwin","A_Id":64511336,"CreationDate":"2019-01-15T14:20:00.000","Title":"Can't install uwsgi on cygwin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"After I launch Locust without the web UI:\n$ locust -f locust_files\/my_locust_file.py --no-web -c 1000 -r 100\nis it possible to change the number of users or hatch rate programmatically during the execution?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1247,"Q_Id":54202932,"Users Score":1,"Answer":"No.. that is not possible.. Locust requires the number of virtual users and hatch rate to be defined at test startup.","Q_Score":1,"Tags":"python,locust","A_Id":54203228,"CreationDate":"2019-01-15T16:25:00.000","Title":"In Locust, can I modify the number of users and hatch rate after I start the 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":"After I launch Locust without the web UI:\n$ locust -f locust_files\/my_locust_file.py --no-web -c 1000 -r 100\nis it possible to change the number of users or hatch rate programmatically during the execution?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1247,"Q_Id":54202932,"Users Score":1,"Answer":"Warning: unsupported method\nStart locust in the usual way and investigate the calls made by the browser to the endpoints exposed by locust.\nE.g. the call to update the user count is a simple POST to the \/swarm endpoint with the desired locust count and hatch rate:\ncurl \"http:\/\/localhost:8089\/swarm\" -X POST -H \"Content-Type: application\/x-www-form-urlencoded\" --data \"locust_count=10&hatch_rate=1\"","Q_Score":1,"Tags":"python,locust","A_Id":54782803,"CreationDate":"2019-01-15T16:25:00.000","Title":"In Locust, can I modify the number of users and hatch rate after I start the 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":"After I launch Locust without the web UI:\n$ locust -f locust_files\/my_locust_file.py --no-web -c 1000 -r 100\nis it possible to change the number of users or hatch rate programmatically during the execution?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1247,"Q_Id":54202932,"Users Score":0,"Answer":"1) If we want to increase the number of users during test:\nRun the same test in parallel with additional number of users\n2) If we want to decrease the number of users during test:\na) Run the second test with required number of users \nb) At the same time stop the first test\nBoth options can be automated with python or even bash scripts.\nDirty hack, but I think this will result desirable effect completely.","Q_Score":1,"Tags":"python,locust","A_Id":59071475,"CreationDate":"2019-01-15T16:25:00.000","Title":"In Locust, can I modify the number of users and hatch rate after I start the 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":"TLDR: Is there a way to freeze a Tensorflow model during runtime at time t1, such that running the network from time 0 to t2>t1 would lead to exactly the same results as running it from t1 to t2?\nI have searched this quite a lot and couldn't find this exact scenario:\nI have a tensorflow model which is receiving inputs through Datasets API from a list of TFRecords. At very random moments I get an error regarding tensor shape incompatibility and I'm trying to figure out why. I have changed the seeds, so that the code is reproducible, but it takes about 30 minutes for the reproducible error to occur. What is the best strategy in such situations to debug the code faster?\nWhat I have been trying has been to save a checkpoint at every iteration, hoping that by restoring the last one (right before the error) I'd be able to quickly reproduce the error later on and troubleshoot it. Unfortunately the random state and dataset api pointer get reset when I do this. Is there any way to fully store the state of a network during runtime (including its random number generator state and the Dataset API pointer), so that when it is restored the same outputs get reproduced?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":163,"Q_Id":54205857,"Users Score":1,"Answer":"From my personal experience I would approach it in the following ways.\n\nRunning the code with -i flag (python -i) which takes you to the interpreter with preserved state at the moment the script stops OR (even better) calling problematic parts of code from jupyter notebook which will also preserve the state after the exception is raised and you could investigate what the problem is more easily. If the problem is inside a function you could catch the exception and return all relevant objects. Or you could also put your functions inside the class to have a single object, instantiate and run it from jupyter and when the problem occurs you will have all variables inside that class object.\nAdding assert's statements for the shapes of your data and for the shapes of your model variables\/placeholders. For example, if you have some preprocessing\/augmentation add assert's before and after preprocessing\/augmentation to be sure that the shapes are as expected.\nTaking a break. Sometimes you spend a lot of time and effort on something without success, but after having a rest you solve the problem immediately.\n\nGood luck!","Q_Score":0,"Tags":"python,tensorflow","A_Id":54207491,"CreationDate":"2019-01-15T19:46:00.000","Title":"Save the exact state of Tensorflow model, random state, and Datasets API pointer for debugging","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed pythonnet to use clr package for a specific API, which only works with clr in python. Although in my python script (using command or regular .py files) it works without any issues, in jupyter notebook, import clr gives this error, ModuleNotFoundError: No module named 'clr'. Any idea how to address this issue?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1254,"Q_Id":54206227,"Users Score":2,"Answer":"Here is simple suggestion: compare sys.path in both cases and see the differences. Your ipython kernel in jupyter is probably searching in different directories than in normal python process.","Q_Score":3,"Tags":"python,.net,interop,clr,python.net","A_Id":54227259,"CreationDate":"2019-01-15T20:16:00.000","Title":"pythonnet clr is not recognized in jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed pythonnet to use clr package for a specific API, which only works with clr in python. Although in my python script (using command or regular .py files) it works without any issues, in jupyter notebook, import clr gives this error, ModuleNotFoundError: No module named 'clr'. Any idea how to address this issue?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1254,"Q_Id":54206227,"Users Score":0,"Answer":"since you are intended to use clr in jupyter, in jupyter cell, you could also \n!pip install pythonnet for the first time and every later time if the vm is frequently nuked","Q_Score":3,"Tags":"python,.net,interop,clr,python.net","A_Id":61789169,"CreationDate":"2019-01-15T20:16:00.000","Title":"pythonnet clr is not recognized in jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ok here's my basic information before I go on:\nMacBook Pro: OS X 10.14.2\nPython Version: 3.6.7\nJava JDK: V8.u201\nI'm trying to install the Apache Spark Python API (PySpark) on my computer. I did a conda installation: conda install -c conda-forge pyspark\nIt appeared that the module itself was properly downloaded because I can import it and call methods from it. However, opening the interactive shell with myuser$ pyspark gives the error: \nNo Java runtime present, requesting install.\nOk that's fine. I went to Java's download page to get the current JDK, in order to have it run, and downloaded it on Safari. Chrome apparently doesn't support certain plugins for it to work (although initially I did try to install it with Chrome). Still didn't work.\nOk, I just decided to start trying to use it.\nfrom pyspark.sql import SparkSession It seemed to import the module correctly because it was auto recognizing SparkSession's methods. However,\nspark = SparkSession.builder.getOrCreate() gave the error:\nException: Java gateway process exited before sending its port number\nReinstalling the JDK doesn't seem to fix the issue, and now I'm stuck with a module that doesn't seem to work because of an issue with Java that I'm not seeing. Any ideas of how to fix this problem? Any and all help is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":244,"Q_Id":54206569,"Users Score":0,"Answer":"This problem is coming with spark 2.4. please try spark 2.3.","Q_Score":0,"Tags":"java,python,apache-spark,java-8,pyspark","A_Id":54281008,"CreationDate":"2019-01-15T20:47:00.000","Title":"Tried importing Java 8 JDK for PySpark, but PySpark still won't let me start a session","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python virtual environment with a cloned Github repository inside of it. The repository requires me to run a .sh file. I am using GitBash to run the sh setup.sh command. \nWhen I run the .sh file, I get a huge list of \"command not found\" errors which I think are coming from the fact that my GitBash is not operating in the virtual environment which I activated originally. When I type $ source .\/EnvironmentName.env\/bin\/activate into the GitBash, it tells me that there is \"No such file or directory\".\nHow do I activate the original environment in my GitBash window?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":916,"Q_Id":54207064,"Users Score":0,"Answer":"if you are on Windows then \"Scripts\" folder is created instead of \"bin\"\nthen the command should be like this:\n$ source .\/EnvironmentName.env\/Scripts\/activate","Q_Score":2,"Tags":"python,cmd,virtualenv,git-bash","A_Id":57601577,"CreationDate":"2019-01-15T21:27:00.000","Title":"How to get into an active Python Virtual Environment from Git Bash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Specifications:\nSystem: Ubuntu 18.0.4\nTensorflow:1.9.0,\ncudnn=7.2.1\nInterpreter project: anaconda environment.\nWhen I run the script on terminal with the same anaconda env, it works fine. Using pycharm, it does not work!! What is the issue ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":54207221,"Users Score":0,"Answer":"Go to File -> Settings -> Project Interpreter and set the same python environment used by Anaconda.","Q_Score":0,"Tags":"python-3.x,tensorflow,pycharm","A_Id":54207278,"CreationDate":"2019-01-15T21:38:00.000","Title":"Tensorflow does not see gpu on pycharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When running\npd.read_hdf('myfile.h5')\nI get the following traceback error:\n\n[[...some longer traceback]]\n~\/.local\/lib\/python3.6\/site-packages\/pandas\/io\/pytables.py in\n  read_array(self, key, start, stop)    2487     2488         if\n  isinstance(node, tables.VLArray):\n  -> 2489             ret = node[0][start:stop]    2490         else:    2491             dtype = getattr(attrs, 'value_type', None)\n~\/.local\/lib\/python3.6\/site-packages\/tables\/vlarray.py in\n  getitem(self, key)\n~\/.local\/lib\/python3.6\/site-packages\/tables\/vlarray.py in read(self,\n  start, stop, step)\ntables\/hdf5extension.pyx in tables.hdf5extension.VLArray._read_array()\nValueError: cannot set WRITEABLE flag to True of this array\n\nNo clue what's going on. I've tried reinstalling tables, pandas everything basically, but doesn't want to read it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":15113,"Q_Id":54210073,"Users Score":0,"Answer":"It seems that time-date strings were causing the problem and when I converted these from text to numpy (pd.to_datetime()) and stored the table and the problem went away so perhaps it has something to do with text data?","Q_Score":26,"Tags":"python,pandas,pytables,hdf","A_Id":56453634,"CreationDate":"2019-01-16T03:37:00.000","Title":"pd.read_hdf throws 'cannot set WRITABLE flag to True of this array'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Recently, I made a pygame game. I want to show it to my friends. But unfortunately, I cant make an executable file, only a .py file. I have tried to use tools such as py2exe which might not support Python 3.6 and pyinstaller. I think pyinstaller may be useful, and I can also make an exe successfully but it didn't work at all. It just showed it couldn't open the sound file which is already in the same file.  \nI have tried two ways to load files firstly, just load the path then the exe converted shows it can't open the file which is already in the same path with the exe.\nSecondly, I use the os.path which the exe showed it cant open .....\/temp\/... which is a long path but my computer doesn't have this folder at all.  \nI am a new guy to learn python. I have searched for a day and can't make it work. Can you help me?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":26594,"Q_Id":54210392,"Users Score":1,"Answer":"I too had the same problem and spent days looking through google. Today finally I realised what was the problem.\nBefore trying to convert it, remember to install Pygame via the Terminal as well. Just type in \"pip install pygame\"","Q_Score":14,"Tags":"python,pygame","A_Id":67803799,"CreationDate":"2019-01-16T04:22:00.000","Title":"How can I convert pygame to exe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i wan't to release my python project, but when i send it to someone he is forced to install all the packages im using in my python project. \nIs there any way to pack it or something, because maybe there are some users who are not that familiar with pip or python.\nRegards","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17127,"Q_Id":54212814,"Users Score":0,"Answer":"If you want to deploy a python application , you can use cx_freeze to package it. It will provide you a binary ready to execute","Q_Score":2,"Tags":"python,pip,package,release","A_Id":54213324,"CreationDate":"2019-01-16T08:18:00.000","Title":"How to package Python Project into a standalone executable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to install some packages on the server which does not access to internet. so I have to take packages and send them to the server. But I do not know how can I install them.","AnswerCount":4,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":17437,"Q_Id":54213323,"Users Score":-2,"Answer":"Download the package from website and extract the tar ball.\nrun python setup.py install","Q_Score":0,"Tags":"python,pip,setup.py,installation-package","A_Id":54213344,"CreationDate":"2019-01-16T08:53:00.000","Title":"Install python packages offline on server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking to create a simple online multiplayer game. Each player choose a number as their input and get a result based on simple calculations as their output. The code for the game itself is already created in VBA, but i am looking to make it online. Could i use Python for that, and do i need to create a website?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":748,"Q_Id":54215101,"Users Score":1,"Answer":"Online for public use or to share with someone specific (friend or someone else)?\nIf it is with a friend you could try rerouting traffic from your router to you PC with a specific port. Then create a simple website (with Flask for example, as it uses python) to make the game playable. Finally others could play the game by accessing your website through your public IP.","Q_Score":1,"Tags":"python,multiplayer","A_Id":54215324,"CreationDate":"2019-01-16T10:30:00.000","Title":"Making an simple online multiplayer game","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writting such float value from Python (6.481044303797468) converted to string via StringIO '6.481044303797468' into Postgresql column of type NUMERIC(13,8). I read it back into Python which is returned as Decimal('6.48104430').\nWhy the precision is smaller?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":233,"Q_Id":54218474,"Users Score":2,"Answer":"NUMERIC(13,8) means: 8 decimal digits. So you are getting exactly what you saved.","Q_Score":0,"Tags":"python,postgresql,psycopg2","A_Id":54218534,"CreationDate":"2019-01-16T13:48:00.000","Title":"Python writes float to Postgresql but it is precision is lesser","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writting such float value from Python (6.481044303797468) converted to string via StringIO '6.481044303797468' into Postgresql column of type NUMERIC(13,8). I read it back into Python which is returned as Decimal('6.48104430').\nWhy the precision is smaller?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":233,"Q_Id":54218474,"Users Score":0,"Answer":"You asekd to remember just 8 digits after decimal point in here\nNUMERIC(13,8) change type for what your precision is desired","Q_Score":0,"Tags":"python,postgresql,psycopg2","A_Id":54218576,"CreationDate":"2019-01-16T13:48:00.000","Title":"Python writes float to Postgresql but it is precision is lesser","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to add a vertex to JanusGraph by GremlinPython, and I already set graph.set-vertex-id=true in config, but I always get error:GremlinServerError: 500: Not a valid vertex id: 5678\nI want to set a custom id to vertex, I only know the id should be a long type, some id set success, like:2048, 123456...; But more id set failed, it raise a error: GremlinServerError: 500: Not a valid vertex id: 5678. \nMy add vertex code is:\nvip = g.addV().property(T.id, 5678).property(\"name\", \"domain\").property(\"value\", \"www.google.com\").next()\n\nPlease tell me what is a valid id?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":950,"Q_Id":54219472,"Users Score":0,"Answer":"The type is Long, but you need to send it in a string.\n\nvip = g.addV().property(T.id, '5678').property(\"name\", \"domain\").....","Q_Score":3,"Tags":"python,gremlin,janusgraph","A_Id":72497919,"CreationDate":"2019-01-16T14:41:00.000","Title":"gremlin-python: what is a valid vertex custom id?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I admit at the beginning that I am a novice python developer, so I apologize in advance for questions that may seem stupid.\nI prepared python script with GUI (Tkinter), which use plenty external libraries. I'm working on Windows. Currently, I share my program in the form of an .exe file for Windows users, who do not have Python installed on their PCs. Everything works.\nRecently I received a query if I can compile my code on an executable file that is usable for Mac users. \nI have a number of questions related to this:\n1) can I do it from a PC with Windows or i need Mac? I guess I have to have access to a Mac.\n2) will my code work on mac without any editing? What about external libraries? Do you know any easy way to copy\/paste my \"python with used libraries\" from Windows to Mac?\n3) will I create a executable file in the same way as Windows, I mean I will use a \"Pyinstaller\" type library?\nThank you in advance for your help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5196,"Q_Id":54220377,"Users Score":0,"Answer":"You shouldn't have any trouble. Just make sure the version of python is the same, as I believe the default on mac is 2.7.\nAlso, python scripts aren't compiled, rather interpreted, so making the file executable doesn't really mean it's a binary file in this case. I'm not sure what method you used to run python on a computer that doesn't have python on it, as there are a few, but if you can manage to do that on windows, it should work on mac.","Q_Score":1,"Tags":"python,python-3.x,windows,macos,exe","A_Id":54220554,"CreationDate":"2019-01-16T15:30:00.000","Title":"How to create executable file on mac from python script developed on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As I already have quite a lot of packages installed without installing Anaconda will I have to reinstall them again separately? Or are they accessible in Anaconda environment because I have them preinstalled? There is a similar question which has the answer suggesting installing only miniconda but in my case Anaconda is necessary.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":313,"Q_Id":54221690,"Users Score":0,"Answer":"No, anaconda uses completely different environments and whatever downgrading it does, it does it within it's own environments. So, if you are using anaconda environments within your applications, you don't need to reinstall anything but if you are using another environment (like pip only) you need to make sure you have installed all the necessary packages there as well.\nAlso, if a package is installed using pip and not installed in conda, it will automatically switch to pip so there is no problem there.","Q_Score":0,"Tags":"python,anaconda","A_Id":54221847,"CreationDate":"2019-01-16T16:47:00.000","Title":"Does Anaconda reinstall all the packages like(numpy, pandas, pycuda etc) even if I had installed them earlier separately with python in Ubuntu 18.04?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python, I have a multi-threading application that accesses a global object. Am curious, if I put time.sleep() on a thread (say THREAD 1) that is about to access the global object, does time.sleep() delay THREAD 1's access to the global object such that other threads that don't have time.sleep() are able to get access first to the global object?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":54229067,"Users Score":4,"Answer":"Threads are pretty complicated in Python and operate in the same memory heap. The threads basically run concurrently, i.e. multiple threads are interleaved together such that only on runs at a time and they together run alternatively in very short spans of time (considering they need access to the interpreter).\nWhen you put a thread to sleep, it basically uses the underlying system sleep features and blocks all operations on it. However, the other threads are definitely operational. Thus, when you say THREAD1 is put on sleep before it was just about to access a global variable, the other threads will obviously use the variable because they are running while THREAD1 is not. \nAs soon as THREAD1 wakes up, if need be, it shall acquire the GIL and thus access the global variable. Since it again gets interleaved with other threads, due to concurrency, it gets immediate access to the global variable upon activation. If other threads were using it, they would have given up their access before THREAD1 started operations.","Q_Score":0,"Tags":"python,multithreading,sleep,thread-sleep","A_Id":54229372,"CreationDate":"2019-01-17T04:29:00.000","Title":"Effect of time.sleep on thread access","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can i use online python IDEs to work with GUI code. I am working in Kivy framework to build GUI.\n I have tried Codeenvy , and some other online IDEs. But i couldnt able work with GUI there.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":54230051,"Users Score":3,"Answer":"Kivy is a graphical framework for the desktop, using SDL2 as a backend in most cases. It has no way to run in your browser.","Q_Score":0,"Tags":"python-3.x,kivy","A_Id":54262456,"CreationDate":"2019-01-17T06:17:00.000","Title":"How to use Python GUI online?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As I am new in Big Data Platform, I would like like to do some feature engineering work with my data. The Database size is about 30-50 Gb. Is is possible to load the full data (30-50Gb) in a data frame like pandas data frame? \nThe Database used here is Oracle. I tried to load it but I am getting out of memory error. Furthermore I like to work in Python.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":224,"Q_Id":54232066,"Users Score":1,"Answer":"pandas is not good if you have GBS of data it would be better to use distributed architecture to improve speed and efficiency. There is a library called DASK that can load large data and use distributed architecture.","Q_Score":0,"Tags":"python-3.x,oracle,jupyter-notebook,bigdata","A_Id":68094492,"CreationDate":"2019-01-17T08:50:00.000","Title":"Big Data Load in Pandas Data Frame","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a few basic questions on Dask:\n\nIs it correct that I have to use Futures when I want to use dask for distributed computations (i.e. on a cluster)?\nIn that case, i.e. when working with futures, are task graphs still the way to reason about computations. If yes, how do I create them.\nHow can I generally, i.e. no matter if working with a future or with a delayed, get the dictionary associated with a task graph?\n\nAs an edit:\nMy application is that I want to parallelize a for loop either on my local machine or on a cluster (i.e. it should work on a cluster).\nAs a second edit:\nI think I am also somewhat unclear regarding the relation between Futures and delayed computations.\nThx","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1864,"Q_Id":54232080,"Users Score":16,"Answer":"1) Yup. If you're sending the data through a network, you have to have some way of asking the computer doing the computing for you how's that number-crunching coming along, and Futures represent more or less exactly that.\n2) No. With Futures, you're executing the functions eagerly - spinning up the computations as soon as you can, then waiting for the results to come back (from another thread\/process locally, or from some remote you've offloaded the job onto). The relevant abstraction here would be a Queque (Priority Queque, specifically).\n3) For a Delayed instance, for instance, you could do some_delayed.dask, or for an Array, Array.dask; optionally wrap the whole thing in either dict() or vars(). I don't know for sure if it's reliably set up this way for every single API, though  (I would assume so, but you know what they say about what assuming makes of the two of us...).\n4) The simplest analogy would probably be: Delayed is essentially a fancy Python yield wrapper over a function; Future is essentially a fancy async\/await wrapper over a function.","Q_Score":12,"Tags":"python,distributed-computing,dask","A_Id":54235046,"CreationDate":"2019-01-17T08:51:00.000","Title":"Dask: delayed vs futures and task graph generation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a dataset in csv file which contains one of the column as list(or dict which further includes several semi colons and commas because of key, value pair). Now trouble is accessing with Pandas and it is return mixed values because of the reason that it has several commas in the list which is in fact a single column. \nI have seen several solutions such as use \"\" or ; as delimiter, but problem is I already have the data, find and replace will completely change my dataset.\nexample of csv is :\ndata_column1, data_column2, [{key1:value1},{key2:value2}], data_column3\nPlease advise any faster way to access specific columns of the data with out any ambiguity.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":54235643,"Users Score":0,"Answer":"You can only set the delmiter to one character so you can't use square brackets in this Way. You would need to use a single character such as \" so that it knows to ignore the commas between the delmieters.","Q_Score":0,"Tags":"python,python-3.x,pandas","A_Id":54235779,"CreationDate":"2019-01-17T12:10:00.000","Title":"Access dict columns of a csv file in python pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with a software that has an embedded python environment which does not have all of the standard python modules available.\nFor example there's no pip or pkg_resources. The only way to add 3rd-party modules\/packages is by copying them into a path which is referenced in sys.path.\nAt the moment I am writing the first version of my own package and more will come in the future.\nNow to my question. Is it considered a bad approach to have the version number inside the package name or completely as subpackage?\nFor example mypackage_0_1\/ or mypackage\/0_1\/\nIf so, what would be a good alternative to solve this problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":128,"Q_Id":54236653,"Users Score":1,"Answer":"In most of the cases, the version number in a package, regardless of the language, is used to communicate compatibility. For example, Qt: there are Qt4 and Qt5 series. What the numbers mean is that we have different APIs and switching from Qt4 to Qt5 will mostly break your application. Likewise, Python follows this pattern: you have Python 2.x and 3.x series. This means that if you write your application for Python 3.6, it is expected that it will work with Python 3.7. In other words, Python 3.x releases are forward compatible (ie, software written for a older version of Python 3.x is expected to run OK with newer versions). However, writing your application for Python 2.7 and running it in Python 3.7, for example, will mostly bring unexpected results. Hence, Python 3.x breaks the compatibility with Python 2.x and they are neither forward of backward compatible.\nSo, my advice is to follow this rule: use a version number in the package name only and only if you are communicating that you are creating a series of forward compatible versions of your package.","Q_Score":0,"Tags":"python,python-2.7,package,python-import,directory-structure","A_Id":54237037,"CreationDate":"2019-01-17T13:07:00.000","Title":"Bad approach to put version in package name?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm already installed numpy and it works in cmd.\nmy Python version is 3.7.2 and numpy version is 1.16.0\n\nWhen I use numpy in windows cmd, It works.\nimport numpy is working well in the python interactive console.\nBut in pyCharm, it doesn't work and errors with No module named 'numpy'.\nHow can I solve it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":229,"Q_Id":54241710,"Users Score":5,"Answer":"You probably arent using the same python installation in pycharm and in your console. Did you double-check in project settings ?\nIf you just want to install numpy, you can create a requirements.txt file and add numpy in it, pycharm will suggest to install it if not already done. \nAlternatively, you could use a venv","Q_Score":0,"Tags":"python,numpy","A_Id":54241747,"CreationDate":"2019-01-17T17:59:00.000","Title":"I get an ImportError: No module named 'numpy' when trying to use numpy in PyCarm, but it works fine in the interactive console","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have lots of users and they have favorite colors. I have a dataset -each of its records has color data- and I want to send an email to each user. In each email, the user will see the filtered data based on his\/her favorite colors which means I need to filter this dataset based on their favorite colors.\nFor example; users' favorite colors like that:\n[User1:(\u201cGreen\u201d, \u201cYellow\u201d), User2:(\u201cGreen, Blue\u201d), User3:(\u201cRed\u201d), User4:(\u201cOrange\u201d, \u201cPurple\u201d, \u201cRed\u201d), User5:(\u201cBlue\u201d, \u201cYellow\u201d) \u2026]\nHow can I effectively filter this dataset based on user\u2019s favorite colors?\nThe most straightforward way is to loop through the user list and filter dataset by current user\u2019s favorite colors in every iteration. However, that may cause redundant queries for the same or common colors. So, if I have 1 million users then I will make 1 million queries to the same dataset. \nCan someone suggest an idea to make this process more elegant? I will do it with Python but the answer can be language independent.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":138,"Q_Id":54245053,"Users Score":0,"Answer":"Since this is strictly theoretical (you don't provide which technology you wish to use), I would go ahead filter by a query that retrives users having the same matching options (colors). Now that can be accomplished either through SQL-query or LINQ to SQL if you're using .NET. If you can provide more info on what language you'll be using I can give you more specific answers.","Q_Score":0,"Tags":"python,algorithm,performance,filtering","A_Id":54245159,"CreationDate":"2019-01-17T22:16:00.000","Title":"Filtering a dataset based on another dataset","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Every time I run my python game, I get an annoying alert in the console saying:\nHello from the pygame community. https:\/\/www.pygame.org\/contribute.html\nHow do I delete this?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":6812,"Q_Id":54246668,"Users Score":3,"Answer":"Mac OS\n\nNavigate to: \/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/site-packages\/pygame\/ and open _init_.py\n\n(hint: this is the Library for your Macintosh HD, not your users library)\n\nscroll down to the bottom of the page, then delete the line saying:\nprint('Hello from the pygame community ... )\n\n\nIf you can't find your Library folder, then you probably still have the default settings set to hide it.\n\ntype defaults write com.apple.finder AppleShowAllFiles YES; in the terminal \nhold option + right click on finder and click relaunch.\n\n\nWindows\n(this is untested, if you have problems let me know so I can update)\n\nNavigate to: C:\\Python\\Lib\\site-packages\\pygame and open _init_.py\nscroll down to the bottom of the page, then delete the line saying: print('Hello from the pygame community ... )","Q_Score":9,"Tags":"python,python-3.x,python-2.7,pygame","A_Id":54246669,"CreationDate":"2019-01-18T01:40:00.000","Title":"How do I delete the \"Hello from the pygame community\" console alert while using pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am iterating through a few thousand lines of some really messy data from a csv file using pandas.  I'm iterating through one of the dataframe columns which contains generally fairly short strings of disparate, concatenated customer information (name, location, customer numbers, telephone numbers, etc).\nThere's not a lot of identifiable difference between customer numbers and telephone numbers, though most of the rows in the df column contain a TEL identifier within the string text for a telephone number, as demonstrated below (where 0123456 is a customer number, and 55555 5555 is the TEL number):\nJERRY 0123456 TEL: 55555 5555 LOCATION CITY\nI can clear the whitespace from the digits following the TEL: indicator, but can't seem to formulate a regular expression that only pulls the text following the TEL: indicator.  My ideal output in my new df[\"TEL\"] column could be 555555555.\nSo far the regular expression I have is (note, some of the phone numbers are different lengths to deal with international callers, some of which include country code, and some of which do not):\nre.match(r'(TEL)?:? ?[0-9 ]{9-12}').group()\nHowever, the above regular expression still pulls the TEL piece of the string I am matching against.  How do I fix this error?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":54247079,"Users Score":0,"Answer":"re.match(r'(?:TEL)?:? ?([0-9 ]{9-12})').group(1)\n(?:...) makes it a non-capturing group\n([0-9 ]{9-12}) captures that part as the group(1)","Q_Score":0,"Tags":"python,regex,pandas","A_Id":54247129,"CreationDate":"2019-01-18T02:42:00.000","Title":"finding a string after identifying group","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need your help please, I want to automize my everyday tasks with python code. I need to open an existing excel document, modify some information in it(ex: date) then save it as pdf and print it.\nIs it possible to do all these via python?\nI have tried to do this with openpyxl, I can open and modify the sheets, but' I can't save as pdf only one sheet of the workbook and print it then.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":418,"Q_Id":54252699,"Users Score":0,"Answer":"Try using xlwings, it allows you to use more or less any Excel feature because it's actually opening the file and working on it (you can decide if that's done in the background or you can actually see it).","Q_Score":1,"Tags":"excel,python-3.x,pdf,printing","A_Id":54254629,"CreationDate":"2019-01-18T11:05:00.000","Title":"How to Modify an excel document, save as pdf and print it with Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need your help please, I want to automize my everyday tasks with python code. I need to open an existing excel document, modify some information in it(ex: date) then save it as pdf and print it.\nIs it possible to do all these via python?\nI have tried to do this with openpyxl, I can open and modify the sheets, but' I can't save as pdf only one sheet of the workbook and print it then.","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":418,"Q_Id":54252699,"Users Score":-1,"Answer":"Why you need to use Python?\nI think easiest way is write macro in VBA excel (which can updating values in your sheet) and than print it out as PDF or .","Q_Score":1,"Tags":"excel,python-3.x,pdf,printing","A_Id":54252906,"CreationDate":"2019-01-18T11:05:00.000","Title":"How to Modify an excel document, save as pdf and print it with Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are developing an deep learning application on AWS. The automation of model training is quite challenging. The first step is to prepare the data for training which involves generating a huge 3D  numpy array (> 100GB) from hundreds of thousands of small 2D numpy arrays. The small numpy arrays are saved in S3 bucket as small files. After the conversion, the big numpy array will saved to another S3 bucket. The training script will pick up the big 3D numpy array before the training. Since lambda function has a memory limit so we will have to launch an EC2 instance manually. \nI wonder what is the best practice to launch a EC2 instance from external and run the python script on the instance to do the data loading and transformation? \nThe whole workflow will probably be automated using AWS step function.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":54260826,"Users Score":0,"Answer":"You can use a Configuration set in a Cloud formation template to define steps where you can perform copies or run scripts or commands upon start up of your EC2 resource. You can even run it transiently so that it shut itself down after all operations are completed.\nYou can then use a script or Lambda function to execute the Cloudformation Stack","Q_Score":1,"Tags":"python,amazon-web-services,numpy,amazon-s3","A_Id":54261008,"CreationDate":"2019-01-18T20:13:00.000","Title":"How to launch a EC2 instance and run a task on-demand","Data Science and Machine Learning":0,"Database and SQL":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 are developing an deep learning application on AWS. The automation of model training is quite challenging. The first step is to prepare the data for training which involves generating a huge 3D  numpy array (> 100GB) from hundreds of thousands of small 2D numpy arrays. The small numpy arrays are saved in S3 bucket as small files. After the conversion, the big numpy array will saved to another S3 bucket. The training script will pick up the big 3D numpy array before the training. Since lambda function has a memory limit so we will have to launch an EC2 instance manually. \nI wonder what is the best practice to launch a EC2 instance from external and run the python script on the instance to do the data loading and transformation? \nThe whole workflow will probably be automated using AWS step function.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":158,"Q_Id":54260826,"Users Score":1,"Answer":"I would go with the most simple solution as this is not that complicated task (from the architectural perspective).\nConfigure S3 event for a bucket, the one where you are storing the new big 3D array, to trigger lambda function once the object has been put into the bucket (you can be more granular and trigger it based on prefix if you are storing all\/different data in the same bucket).\nInside of that lambda function, you simply launch new EC2 instance and pass user data script to it that will download necessary files and run the task (this can be done using boto3 for Python).\nUsing CloudFormation in this case would be overkill (my opinion).","Q_Score":1,"Tags":"python,amazon-web-services,numpy,amazon-s3","A_Id":54265569,"CreationDate":"2019-01-18T20:13:00.000","Title":"How to launch a EC2 instance and run a task on-demand","Data Science and Machine Learning":0,"Database and SQL":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 are developing an deep learning application on AWS. The automation of model training is quite challenging. The first step is to prepare the data for training which involves generating a huge 3D  numpy array (> 100GB) from hundreds of thousands of small 2D numpy arrays. The small numpy arrays are saved in S3 bucket as small files. After the conversion, the big numpy array will saved to another S3 bucket. The training script will pick up the big 3D numpy array before the training. Since lambda function has a memory limit so we will have to launch an EC2 instance manually. \nI wonder what is the best practice to launch a EC2 instance from external and run the python script on the instance to do the data loading and transformation? \nThe whole workflow will probably be automated using AWS step function.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":54260826,"Users Score":0,"Answer":"did you consider using Amazon SageMaker? It's easy to configure repeatable training jobs. I'd love to hear your feedback and answer any questions.","Q_Score":1,"Tags":"python,amazon-web-services,numpy,amazon-s3","A_Id":54268333,"CreationDate":"2019-01-18T20:13:00.000","Title":"How to launch a EC2 instance and run a task on-demand","Data Science and Machine Learning":0,"Database and SQL":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":"Is it possible to run machine learning through R (RStudio) or Python in a Netezza server? More specifically, can I train models and make predictions using the Netezza server? Has anybody been able to install TensorFlow, Keras or Pytorch in the Netezza server for these ML tasks?\nI appreciate any feedback whether this is feasible or not.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":54261531,"Users Score":0,"Answer":"It is possible to install R and To my knowledge all kinds of R-packages can be installed. Some of the code will only run on the HOST but all the basics (like Apply and filtering) runs on all the SPU\u2019s","Q_Score":0,"Tags":"python,r,machine-learning,netezza","A_Id":54271206,"CreationDate":"2019-01-18T21:17:00.000","Title":"Machine learning through R\/Python in the Netezza server","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If i've an networkx graph from a python dataframe and i've generated the adjacency matrix from it. \nSo basically, how to get labels of that adjacency matrix ?","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":910,"Q_Id":54262904,"Users Score":-1,"Answer":"If the adjacency matrix is generated without passing the nodeList, then you can call G.nodes to obtain the default NodeList, which should correspond to the rows of the adjacency matrix.","Q_Score":0,"Tags":"python-3.x,networkx,adjacency-matrix","A_Id":66045559,"CreationDate":"2019-01-19T00:00:00.000","Title":"Python how to get labels of a generated adjacency matrix from networkx graph?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If i've an networkx graph from a python dataframe and i've generated the adjacency matrix from it. \nSo basically, how to get labels of that adjacency matrix ?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":910,"Q_Id":54262904,"Users Score":0,"Answer":"Assuming you refer to nodes' labels, networkx only keeps the the indices when extracting a graph's adjacency matrix. Networkx represents each node as an index, and you can add more attributes if you wish. All node's attributes except for the index are kept in a dictionary. When generating graph's adjacency matrix only the indices are kept, so if you only wish to keep a single string per node, consider indexing nodes by that string when generating your graph.","Q_Score":0,"Tags":"python-3.x,networkx,adjacency-matrix","A_Id":54274980,"CreationDate":"2019-01-19T00:00:00.000","Title":"Python how to get labels of a generated adjacency matrix from networkx graph?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to solve an lp optimization problem where the upper bounds of a few variables are not an integer, instead of a function of another variable. As an example, i, j and k are three variables and bounds are 0<=i<=100, 0<=j<=i-1 and 0<=k<=j-1. How can we represent such noninteger bounds in scipy lp solver?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":145,"Q_Id":54267193,"Users Score":0,"Answer":"You can try in the below way.\nfor i in range(0,100):\n    for j in range(0,int(i)):\n        for k in range(0,int(j)):\n            print(k)","Q_Score":1,"Tags":"python,scipy","A_Id":54268086,"CreationDate":"2019-01-19T12:40:00.000","Title":"How to represent bounds of variables in scipy.optimization where bound is function of another variable","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to solve an lp optimization problem where the upper bounds of a few variables are not an integer, instead of a function of another variable. As an example, i, j and k are three variables and bounds are 0<=i<=100, 0<=j<=i-1 and 0<=k<=j-1. How can we represent such noninteger bounds in scipy lp solver?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":145,"Q_Id":54267193,"Users Score":0,"Answer":"Currently none of scipy's methods allows for applying dynamic bounds. You can make a non standard extension to scipy.optimize.minimize or fsolve or implement your own optimiser with dynamic bounds. \nNow on whether it is a good idea to do so: NO!\nThat is because for a well formulated optimisation problem you want the design variables and their bounds to be orthogonally independent. If the bounds are changing based on other design variables then the problem is not orthogonally independent.","Q_Score":1,"Tags":"python,scipy","A_Id":54267964,"CreationDate":"2019-01-19T12:40:00.000","Title":"How to represent bounds of variables in scipy.optimization where bound is function of another variable","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I loaded a csv file into 'dataset' and tried to execute dataset.head(), but it reports an error. How to check the head or tail of a numpy array? without specifying specific lines?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":65506,"Q_Id":54269647,"Users Score":82,"Answer":"For a head-like function you can just slice the array using dataset[:10].\nFor a tail-like function you can just slice the array using dataset[-10:].","Q_Score":54,"Tags":"python,numpy","A_Id":54303968,"CreationDate":"2019-01-19T17:33:00.000","Title":"Is there a head and tail method for Numpy array?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to python and I've been using VS code. Right now I'm working on a Thompson Sampling problem that requires numpy and matplotlib. I've imported both libraries but VS code is giving the error unable to import. I know I have to install with PIP, and I have seen other solutions about changing the Python path through the json. but I'm afraid to do that because I don't want to mess up my text editor. Can someone walk me through what I am supposed to do? I haven't seen any simple tutorials on setting up VS Code for python. I'm hoping this will help other people too! I have the extensions Python and CodeRunner installed in VS code. Thank you!","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":13163,"Q_Id":54272258,"Users Score":4,"Answer":"solution to this is make virtual environment for your project steps are as follows\n    1.go to specifid directory you want to make project.\n    2.open cmd or teminal an type mkdir testProjectName.\n    3.type cd testProjectName.\n    4.type virtualenv venv.\n    5.type for windows source venv\/scripts\/activate\n      type for linux or mac source venv\/bin\/activate\n    6.type pip install python.\n    7.type pip install numpy.\n    8.type pip install matplotlib.\n    9.make your project 'testProjectName' dir or copy and paste you project here.\nHope this helps.....","Q_Score":6,"Tags":"python,python-3.x,visual-studio,pip","A_Id":54274702,"CreationDate":"2019-01-19T23:29:00.000","Title":"Unable to Import in VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to python and I've been using VS code. Right now I'm working on a Thompson Sampling problem that requires numpy and matplotlib. I've imported both libraries but VS code is giving the error unable to import. I know I have to install with PIP, and I have seen other solutions about changing the Python path through the json. but I'm afraid to do that because I don't want to mess up my text editor. Can someone walk me through what I am supposed to do? I haven't seen any simple tutorials on setting up VS Code for python. I'm hoping this will help other people too! I have the extensions Python and CodeRunner installed in VS code. Thank you!","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":13163,"Q_Id":54272258,"Users Score":1,"Answer":"this happened to me when installing numpy but after i restarted VScode it fixed it's self.\nif that didn't work check that the package is installed with: pip list in the command prompt.","Q_Score":6,"Tags":"python,python-3.x,visual-studio,pip","A_Id":54274525,"CreationDate":"2019-01-19T23:29:00.000","Title":"Unable to Import in VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to python and I've been using VS code. Right now I'm working on a Thompson Sampling problem that requires numpy and matplotlib. I've imported both libraries but VS code is giving the error unable to import. I know I have to install with PIP, and I have seen other solutions about changing the Python path through the json. but I'm afraid to do that because I don't want to mess up my text editor. Can someone walk me through what I am supposed to do? I haven't seen any simple tutorials on setting up VS Code for python. I'm hoping this will help other people too! I have the extensions Python and CodeRunner installed in VS code. Thank you!","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":13163,"Q_Id":54272258,"Users Score":3,"Answer":"If you're using Python 3, the issue is most likely that when you installed numpy and matplotlib you used the pip command, which will only install them for Python 2. To install the libraries for Python 3 just use the pip3 command in place of pip.","Q_Score":6,"Tags":"python,python-3.x,visual-studio,pip","A_Id":54272429,"CreationDate":"2019-01-19T23:29:00.000","Title":"Unable to Import in VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created and worked on a Django application (Simple website with user registration and login) without ever closing the virtualenv i was working on.\nNow that some time went through I can't remember the name of the virtualenv I was working on and so I can't activate it. How can I find the name of the virtualenv?\nThe name of the directory of my django app is \"uniweb\" and is on the desktop of my computer. I haven't yet put it on Github.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":757,"Q_Id":54274894,"Users Score":0,"Answer":"though this problem can be solved by making another environment and importing project there. it can also be solved \nhere is how i solved the same problem.\nif you got the same name. it is just simple as you have to use workon on command promt inside the directory you have created the django project and it shows the list of all virtual environments you have created there, so you can remember the name and use your virtual environment","Q_Score":0,"Tags":"python,django,virtualenv","A_Id":59459193,"CreationDate":"2019-01-20T08:52:00.000","Title":"Django virtualenv name forgotten","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am making a GUI program where the user can draw on a canvas in Tkinter. What I want to do is that I want the user to be able to draw on the canvas and when the user releases the Mouse-1, the program should wait for 1 second and clear the canvas. If the user starts drawing within that 1 second, the canvas should stay as it is. \nI am able to get the user input fine. The draw function in my program is bound to B1-Motion.\nI have tried things like inducing a time delay but I don't know how to check whether the user has started to draw again.\nHow do I check whether the user has started to draw again?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":129,"Q_Id":54276610,"Users Score":0,"Answer":"You can bind the mouse click event to a function that sets a bool to True or False, then using after to call a function after 1 second which depending on that bool clears the screen.","Q_Score":1,"Tags":"python,python-3.x,tkinter,tkinter-canvas","A_Id":54276767,"CreationDate":"2019-01-20T12:48:00.000","Title":"How to wait for some time between user inputs in tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background\nI have a school project that has this specific item I want to construct an object detector for. I was planning on making a custom dataset, labeling the image, and then using tensorflow to train my classifier.\nI was reading an article and it said if I didn't have a gpu with 2GB or more it would be better to train the dataset on AWS or google cloud.\nQuestion\nMy question is could I still write the code and configuration files on my laptop, which has no GPU, and then outsource the training to AWS or google cloud?\nI'm very new to this so I'm not sure if I'm overlooking some sort of dependencies that will prevent me from moving forward. \nIf I can't move forward with my given hardware what are my other options I guess?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":54282272,"Users Score":0,"Answer":"Use Kaggle kernel to run and save the file in system thats a easy and smart way out.","Q_Score":0,"Tags":"python,amazon-web-services,tensorflow,google-cloud-platform,gpu","A_Id":55568832,"CreationDate":"2019-01-21T00:41:00.000","Title":"Can I use tensor flow GPU without a graphics card? Outsource training to AWS\/Cloud?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In a python script, I need to search for the user input string in an excel sheet,  find the string , then display the respective row\/column details of the cell where the user input was found.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":54285209,"Users Score":0,"Answer":"use argparser to get the input from the cmd\nand use the xlrd to read the excel sheet","Q_Score":0,"Tags":"python","A_Id":54286774,"CreationDate":"2019-01-21T07:29:00.000","Title":"Searching user input string in excel sheet and find the string respective cell information and display range of column from the sheet","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This has been asked several ways. No helpful answers found. I'm running Windows, but final build will run on Linux. \nI am creating an RFID reader gate system. I have 2 separate python programs.\nProgram 1 constantly monitors the reader which is connected via serial port (COM27). When the reader reads a badge, looks in database for user, gate opens, records data, closes.\nProgram 2 adds new people to a database. It only reads from the serial port when a new card is being added. (need to scan the card to get the number) for database) \nObviously, program 2 tries to open serial port and fails. Program 1 already has it open.\nI've tried creating a program 3 which handles serial communication, but importing it into the other 2 programs creates separate instances, so same issue. \nHow can I create one instance of the program and have it send the read info to both programs?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":302,"Q_Id":54285516,"Users Score":0,"Answer":"the situation is very strange, but, I think, maybe you can't change your software architecture.\nThe only way that I think could resolve your program is to write a daemon that grabs the serial port and offer 2 files or 2 sockets or something else for each python instance.\nI could do it using c++ but it is not mandatory.","Q_Score":0,"Tags":"linux,python-3.x,windows,serial-port","A_Id":54287126,"CreationDate":"2019-01-21T07:55:00.000","Title":"Reading One Serial Port from With Two Programs : Python 3","Data Science and Machine Learning":0,"Database and SQL":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 attempting to create a back end framework to interact with hardware over a serial connection. I need to be able to specify exactly how these hardware modules will interact without recompilation and running on a system with limited resources.\nI already have the cpp code that is being re-used that interacts with the hardware and has the broad functionality to send messages to the devices. \nRun-time impact is a serious consideration and it is running on a very limited arch distro that we don't want to change too much for hardware reasons.\nIt would make the most sense to me to interface with a scripting language that can be easily generated to have a set of references to the cpp base that can be loaded on command.  (Sort of like a plugin system)\nPython - is a really good option but I have almost no experience working with embedded python, I have looked into it and I guess where I might be confused is how the interpreted script would link to functionality in the original program without something like pybind11 and embedded python both working together. Binder certainly has a appeal. No Boost please - maybe a little.\nLUA - is a robust option that is well tested but a little more difficult to generate on command. LuaBridge also has the functionality that I desire. Biggest concern is run time impact but I'm not an expert of course.\nJust make the whole thing in cpp and load libraries like a regular person - solid option but likely the most difficult to generate and run syntax checks on easily.\nMake the entire thing in a scripting language and get rid of the overhead of a compiler - I mean technically this is a option\nThese of course aren't all of the options but this is by far out of my area of expertise and I think it would be beneficial to discuss.\nI would really like to know what I should spend my time researching. I have spent far too much time already looking into pybind and I find myself not being able to sleep easy at night.\nIdeally this workflow would run somewhat like this:\nOn the main Controller :\n\nInterface program is run (cpp)\nInterface program does diagnostics and checks module status (already done)\nInterface checks for run script to execute module functionality\n\nThe Script :\n\nGenerated from some source\nRuns tests to verify generation does not have syntactical mistakes\nGets moved into a folder where the Interface program can grab it (In a \"totally\" safe way) I'm kidding I know the issues with that setup but we aren't considering it at this moment\n\nThat was super long and I'm sorry I'm just very lost and out of my comfort zone.\nYeah I'm sorry I didn't clarify why generated code was important. We built a very simple top level gui to interact with the hardware and that needs to be translated into a script to interact with the main interface for the controller.\nAnother option I came up with last night:\nWrite a very simple custom scripting langauge that I can parse on the cpp side and link that way","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":54285876,"Users Score":0,"Answer":"If you are generating a script, you can probably simplify things to a simple byte code that gets interpreted. Then you don't have to mess with parsing or syntax validation. Each \"instruction\" can be a simple opcode followed by zero or more operands, where each operand will be an integer, float or string (and any other primitive data types that your hardware supports\/needs). You can use something like msgpack for encoding and decoding instructions compactly. \nIf that model works, you can gradually add tools on the developer side, such as a minimal assembler, or even a script interpreter that generates the byte code and thus avoids any complexity within your constrained hardware environment.","Q_Score":1,"Tags":"python,c++,c,lua","A_Id":54352053,"CreationDate":"2019-01-21T08:25:00.000","Title":"What is a good way to generate code to interface with a running cpp application that doesn't require a recompile?","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 use canvas.create_rectangle() to draw a rectangle and assign the drawn item to a specifier. But after I delete the item using canvas.delete(specifier), I can still run canvas.delete(specifier) successfully without causing error. May I know what is the reason behind this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":54287094,"Users Score":3,"Answer":"There's no way to really know why? since that's not documented anywhere (that I know of).\nIt's just a design decision made by the authors of tkinter: i.e. It is not considered an error if no items match. My guess is that since the intent is to get rid of something, whether or not it was there beforehand isn't important. \nIf knowing whether it is or not does matter in your situation, you could use the Canvas.find_all() method  first and see if the list it returns is empty.","Q_Score":0,"Tags":"python,tkinter","A_Id":54287618,"CreationDate":"2019-01-21T09:41:00.000","Title":"What does canvas.delete() do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have access to a dataframe of 100 persons and how they performed on a certain motion test. This frame contains about 25,000 rows per person since the performance of this person is kept track of (approximately) each centisecond (10^-2). We want to use this data to predict a binary y-label, that is to say, if someone has a motor problem or not. \nTrained neural networks on mean's and variances of certain columns per person classified +-72% of the data correctly. \nNaive bayes classifier on mean's and variances of certain columns per person classified +-80% correctly.\nNow since this is time based data, 'performance on this test through time', we were suggested to use Recurrent Neural Networks. I've looked into this and I find that this is mostly used to predict future events, i.e. the events happening in the next centiseconds. \nQuestion is, is it in general feasible to use RNN's on (in a way time-based) data like this to predict a binary label? If not, what is?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":37,"Q_Id":54288421,"Users Score":1,"Answer":"Yes it definitely is feasible and also very common. Search for any document classification tasks (e.g. sentiment) for examples of this kind of tasks.","Q_Score":0,"Tags":"python,machine-learning,neural-network,recurrent-neural-network","A_Id":54288478,"CreationDate":"2019-01-21T10:54:00.000","Title":"Classifier for time based data to binary label","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been coding Python 3.7 using Visual Studio Code on Windows 10. Recently, I have taken over a new project, which calls for some newer and different libraries. Hence, for whatever reason, I decided not to customise my libraries, but to install Anaconda, and install the corresponding libraries into it.\nHowever, since I cannot remember all the libraries I have already installed in Visual Studio Code (e.g. numPy, matplotlib, etc.), I'd like to ask if there is any way to get a list of the libraries I added on to my Python installation.\nI appreciate your comments in advance!\nCheers,\nSina","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13203,"Q_Id":54289933,"Users Score":0,"Answer":"you can use conda list to list all the packages installed in anaconda environment","Q_Score":2,"Tags":"python-3.x,list,visual-studio-code,anaconda,libraries","A_Id":54292471,"CreationDate":"2019-01-21T12:25:00.000","Title":"How to find out the installed (Python) libraries in Visual Studio Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need a simple blockchain in python to be used like bitcoin cryptocurrency but also to be mined with cryptography based algorithms.\nI have searched on GitHub but want to make my own.\nMy simple blockchain app that runs in comand line.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":481,"Q_Id":54290362,"Users Score":1,"Answer":"You can create a list or json in python which contain hash of this block, data you want to store,time stamp,the hash of last block.\nCreate first block with a random last block hash.Now you can create block one by one with data you want to store in block(coins? contract? ...), calculate the hash of this block, to become a chain.\nYou can change your algorithm which create your hash,that will depend how to mine and you can setup some requirements of hash result to limit mining speed.Coins which send to miner can be written into data as public data. \nA P2P network should be setup to enable more people to join in.","Q_Score":1,"Tags":"python-3.x","A_Id":54290977,"CreationDate":"2019-01-21T12:48:00.000","Title":"How to write a simple blockchain 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":"My Python program has a main.py module which creates many board objects from the Board class. The Board class uses the Brain class to decide what can happen on the board. The Brain class uses the Data class to help it make decisions.\nThe problem I'm having is the every time any Board object has the Brain do something, new information has to be added to the same Python dictionary in the Data class. I'm afraid to say it, but I really do think the spirit of this dictionary in the Data class is that it needs to be \"global\". What is the correct pattern so all instances can write to the same dictionary? Should I even be using a Data class to hold the dictionary?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":54292587,"Users Score":0,"Answer":"Also consider using DI to maintain the number of dictionary instances instead of making it singleton. If you make it singleton you can't have dictionary per user for example.","Q_Score":0,"Tags":"python,oop,design-patterns","A_Id":54385592,"CreationDate":"2019-01-21T14:59:00.000","Title":"pattern for keeping data produced by many instances of a class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem with importing numpy for python3, I'm new in coding and followed all steps.  I want to import numpy in python3 but not in python2 which is set by defaultn my mac mojave 10.14.2.\nI have Python 2.7.10 by default on my mac and can switch now to Python 3.7.2 in shell. I installed pip 18.1 as described in PyPA and now I can import numpy only in Python 2. what should I do to be able to import numpy in Python 3? Is it better to set Python 3 by default on my mac mojave 10.14.2?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":876,"Q_Id":54296469,"Users Score":3,"Answer":"You can install numpy in python3 with help of pip3 command instead of pip.\nYes you should change python3 as default as python2 support is going to end this year.","Q_Score":0,"Tags":"python,numpy","A_Id":54296537,"CreationDate":"2019-01-21T19:15:00.000","Title":"importing numpy in different python versions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to make a standalone executable file of a GUI application using Python, and am running into a very strange error that prevents the program from running. The only version of Python on my machine using Windows10 is 3.7.2. When I launch the program from the command line it works perfectly and I don't encounter any problems. However, when I create a standalone executable file using pyinstaller, I get the \"Failed to execute script\" error. After some troubleshooting, and looking at the errors coming from the terminal, I realized that the error is coming from the use of numpy in my program. The error that results in the script failing to execute reads: \"ModuleNotFoundError: No module named'numpy.core._dtype_ctypes'\". \nHowever, when I run python and type command 'import numpy' in my terminal, I don't encounter any problems with this module. What might explain this strange error that I encounter? I've tried uninstalling and re-installing numpy, but this hasn't worked. I've also double-checked to make sure that I'm not accidently using a previously installed version of Python that doesn't have numpy installed. I haven't been able to come up with any reasons that this might happen. \nAny insights to why this weird problem might be happening?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1930,"Q_Id":54296556,"Users Score":2,"Answer":"I ran across the same problem.  This is a known issue with numpy 1.16.0.  As a temporary fix I reverted back to numpy 1.15.4.","Q_Score":2,"Tags":"python,numpy,exe,pyinstaller","A_Id":54422827,"CreationDate":"2019-01-21T19:23:00.000","Title":"Standalone Executable Created by PyInstaller Can't Import Numpy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When i run the coding in this yolo_opencv.py file :\nThe console shows this error:\n\nFile \"\", line 40, in \n     Width = image.shape[1]\n  AttributeError: 'NoneType' object has no attribute 'shape'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2273,"Q_Id":54297834,"Users Score":0,"Answer":"Just to give some advice. You could\/should describe your problem a bit more clear. I just Googled the file you mentioned yolo_opencsv.py and its part of Object detection (YOLO, SSD, Faster R-CNN) with OpenCV and Python library. It always a good idea to mention the tool\/library you are using (and are having problems with) in the title. Also you could\/describe the procedure and environment you are using when the error occurs. By doing so, people can try to replicate you problem and have to ask less additional questions trying to help you solve the problem.\nYour error seems to indicate that the image object has not loaded properly, i.e. the return of cv2.imread(args.image) has returned None. Do you run the command from the command line as described in the README. And are you sure you image path and image format is correct?","Q_Score":0,"Tags":"python","A_Id":54297972,"CreationDate":"2019-01-21T21:11:00.000","Title":"AttributeError: no attribute 'shape'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a super basic machine learning question. I've been working through various tutorials and online classes on machine learning and the various techniques to learning how to use it, but what I'm not seeing is the persistent application piece.\nSo, for example, I train a network to recognize what a garden gnome looks like, but, after I run the training set and validate with test data, how do I persist the network so that I can feed it an individual picture and have it tell me whether the picture is of a garden gnome or not? Every tutorial seems to have you run through the training\/validation sets without any notion as of how to host the network in a meaningful way for future use.\nThanks!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":309,"Q_Id":54297846,"Users Score":0,"Answer":"Use python pickle library to dump your trained model on your hard drive and load model and test for persistent results.","Q_Score":0,"Tags":"python,machine-learning","A_Id":54303388,"CreationDate":"2019-01-21T21:13:00.000","Title":"Persistent Machine Learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a very specific question. \nI have a tkinter button. Each time I click it I get a pop-up window with an Entry box. Enter a text and press enter I can change the text of this button. I can do it as many time as the as I want. \nNow the question is:\ncan I make the button text to have different color and font size?\nSay the original button text is \"btn 1\". The first time I click it. The text becomes \"btn 1\\nFirstClick\". The second time the text is \"\"btn 1\\nFirstClick\\nSecondClick\".\nI have all the code worked out as I wanted. But now I want \"FirstClick\" to be in Red and \"SecondClick\" to be in Green\".\nIs that possible? I googled and can't find the answer.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":184,"Q_Id":54298498,"Users Score":0,"Answer":"You cannot use multiple fonts or colors in a single button. Your only option would be to create a custom widget that looks and behaves like a button, but which is implemented with a Text or Canvas widget. Those two widgets allow you to use multiple colors and fonts at the same time.","Q_Score":0,"Tags":"python,button,tkinter","A_Id":54299033,"CreationDate":"2019-01-21T22:14:00.000","Title":"Tkinter: Use different font (color, size, etc.) for the text within the same button?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We currently are receiving reports via email (I believe they are SSRS reports) which are embedded in the email body rather than attached.  The reports look like images or snapshots; however, when I copy and paste the \"image\" of a report into Excel, the column\/row format is retained and it pastes into Excel perfectly, with the columns and rows getting pasted into distinct columns and rows accordingly.  So it isn't truly an image, as there is a structure to the embedded report.\nRight now, someone has to manually copy and paste each report into excel (step 1), then import the report into a table in SQL Server (step 2).  There are 8 such reports every day, so the manual copy\/pasting from the email into excel is very time consuming.  \nThe question is: is there a way - any way - to automate step 1 so that we don't have to manually copy and paste each report into excel?  Is there some way to use python or some other language to detect the format of the reports in the emails, and extract them into .csv or excel files?  \nI have no code to show as this is more of a question of - is this even possible?  And if so, any hints as to how to accomplish it would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":54299206,"Users Score":0,"Answer":"The most efficient solution is to have the SSRS administrator (or you, if you have permissions) set the subscription to send as CSV. To change this in SSRS right click the report and then click manage. Select \"Subscriptions\" on the left and then click edit next to the subscription you want to change. Scroll down to Delivery Options and select CSV in the Render Format dropdown. Viola, you receive your report in the correct format and don't have to do any weird extraction.","Q_Score":0,"Tags":"python,html,csv,email","A_Id":54312283,"CreationDate":"2019-01-21T23:31:00.000","Title":"Is it possible to extract an SSRS report embedded in the body of an email and export to csv?","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 am a beginner to python, I wanted to symbolic computations. I came to know with sympy installation into our pc we can do symbolic computation. I have installed python 3.6 and I am using anaconda nagavitor, through which I am using spyder as an editor. now I want to install symbolic package sympy how to do that.\nI checked some post which says use 'conda install sympy'. but where to type this? I typed this in spyder editor and I am getting syntax error. thankyou","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":41528,"Q_Id":54301925,"Users Score":0,"Answer":"To use conda install, open the Anaconda Prompt and enter the conda install sympy command.\nAlternatively, navigate to the scripts sub-directory in the Anaconda directory, and run pip install sympy.","Q_Score":4,"Tags":"python-3.x,anaconda,sympy,spyder","A_Id":54302012,"CreationDate":"2019-01-22T05:44:00.000","Title":"How to install sympy package in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a beginner to python, I wanted to symbolic computations. I came to know with sympy installation into our pc we can do symbolic computation. I have installed python 3.6 and I am using anaconda nagavitor, through which I am using spyder as an editor. now I want to install symbolic package sympy how to do that.\nI checked some post which says use 'conda install sympy'. but where to type this? I typed this in spyder editor and I am getting syntax error. thankyou","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":41528,"Q_Id":54301925,"Users Score":1,"Answer":"In anaconda navigator:\n\nClick Environments (on the left)\nChoose your environment (if you have more than one)\nOn the middle pick \"All\" from dropbox (\"installed\" by default)\nWrite sympy in search-box on the right\nCheck the package that showed out\nClick apply","Q_Score":4,"Tags":"python-3.x,anaconda,sympy,spyder","A_Id":54302272,"CreationDate":"2019-01-22T05:44:00.000","Title":"How to install sympy package in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi I have bought a Rasberry Pi with Python 3 on it. I can open the Python 3 shell and it works but I can't access an editor. How do I open a Python editor?\ncheers","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2733,"Q_Id":54302213,"Users Score":0,"Answer":"If you are using Python 2 type idle in a command window.\nIf you are using Python 3 type idle3 in a command window.\nIf you are using a GUI there should be shortcuts to IDLE and IDLE3 on screen.","Q_Score":0,"Tags":"python-3.x,raspberry-pi,python-idle","A_Id":54302363,"CreationDate":"2019-01-22T06:09:00.000","Title":"Opening Python IDLE from Raspberry Pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wonder if there is any problem if I just close the terminal without deactivate. Or when I change the environment, do I need to deactivate the environment I'm working in or I just need to activate other-env.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1313,"Q_Id":54302645,"Users Score":2,"Answer":"Closing the window without deactivating should be fine. You can also just activate the new environment without deactivating first.\nThe same goes for virtualenv.","Q_Score":3,"Tags":"python,windows,anaconda","A_Id":54302697,"CreationDate":"2019-01-22T06:47:00.000","Title":"What happened if I don't deactivate environment anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I wonder if there is any problem if I just close the terminal without deactivate. Or when I change the environment, do I need to deactivate the environment I'm working in or I just need to activate other-env.","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":1313,"Q_Id":54302645,"Users Score":4,"Answer":"There is no problem when you try to close the terminal without deactivate, the activate is only affected within terminal session. \nAnd if you want to change env, just activate it without deactivate the old one","Q_Score":3,"Tags":"python,windows,anaconda","A_Id":54302710,"CreationDate":"2019-01-22T06:47:00.000","Title":"What happened if I don't deactivate environment anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I create new virtual env it shows the packages which will be installed.\nIt shows long list but sometimes it shows short list instead.\nAlso, the process is done really fast.\nWhat causes this difference?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":54311088,"Users Score":0,"Answer":"I didn't know about the additional options when I create a new environment.\nThe one I thought fast, had no options.\nAnd the other one had some like tensorflow, keras.","Q_Score":0,"Tags":"python,anaconda","A_Id":54852023,"CreationDate":"2019-01-22T15:04:00.000","Title":"Does anaconda change package list for new enviroment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've installed NGINX, GUNICORN and my project properly on Ubuntu server, \nbut when I run the project using\npython manage.py runserver, I get the following error; \n\ndjango.db.utils.OperationalError: (2003, \"Can't connect to MySQL server on '127.0.0.1' (111)\"\n\nBefore, installing gunicorn, my site was running properly at my_public_ip_address:8000","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":7818,"Q_Id":54312110,"Users Score":1,"Answer":"as asked before if you are running your website on a remote server, you should make sure that you add the ip address to the ALLOWED_HOSTS-list otherwise you might get another error. \nSolutions could be:\n\nDid you try to uninstall gunicorn? gunicorn is used later for the deployment of the website so it should actually be fine, as you are starting a development server with python manage.py runserver\nAs nginx is also used to ship your website into production if would assume that this should note be related directly to the database. you might want to check if nginx is running with service nginx status if this allocates the localhost port django can maybe not access the mysql database\nDid you check the port config of your mysql database?","Q_Score":1,"Tags":"python,mysql,django","A_Id":54312442,"CreationDate":"2019-01-22T16:02:00.000","Title":"django.db.utils.OperationalError: (2003, \"Can't connect to MySQL server on '127.0.0.1' (111)\"","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've installed NGINX, GUNICORN and my project properly on Ubuntu server, \nbut when I run the project using\npython manage.py runserver, I get the following error; \n\ndjango.db.utils.OperationalError: (2003, \"Can't connect to MySQL server on '127.0.0.1' (111)\"\n\nBefore, installing gunicorn, my site was running properly at my_public_ip_address:8000","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":7818,"Q_Id":54312110,"Users Score":2,"Answer":"check your mysql server is running or not\nrestart the mysql server","Q_Score":1,"Tags":"python,mysql,django","A_Id":63745689,"CreationDate":"2019-01-22T16:02:00.000","Title":"django.db.utils.OperationalError: (2003, \"Can't connect to MySQL server on '127.0.0.1' (111)\"","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have an running with serverless framework and python. I implemented a authentication function and registered it in the serverless.yaml. For testing, I just configured for one lambda function to be called after the authentication function. The authentication function gets called without any error, but the lambda function resolves in a 500 Internal Server Error\nI tried the serverless docs, but a lot of examples regarding my issue are not written in python, so its not helping me\nexpected result: no error when calling lambda function\noutput: 500 Internal Server Error","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":64,"Q_Id":54312422,"Users Score":0,"Answer":"Sorry for not providing any code, but I actually found the solution. I did not generate any policy for the api gateway :D","Q_Score":0,"Tags":"python,amazon-web-services,serverless","A_Id":54401828,"CreationDate":"2019-01-22T16:21:00.000","Title":"Python: Serverless Authentication working, but lambda not getting invoked","Data Science and Machine Learning":0,"Database and SQL":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 found this rather annoying bug and I couldn\u2019t find anything other than a unanswered question on the opencv website, hopefully someone with more knowledge about the two libraries will be able to point me in the right direction.\nI won\u2019t provide code because that would be beside the point of learning what causes the crash.\nIf I draw a tkinter window and then root.destroy() it, trying to draw a cv2.imshow window will result in a X Window System error as soon as the cv2.waitKey delay is over. I\u2019ve tried to replicate in different ways and it always gets to the error (error_code 3 request_code 15 minor_code 0).\nIt is worth noting that a root.quit() command won\u2019t cause the same issue (as it is my understanding this method will simply exit the main loop rather than destroying the widgets). Also, while any cv2.imshow call will fail, trying to draw a new tkinter window will work just fine.\nWhat resources are being shared among the two libraries? What does root.destroy() cause in the X environment to prevent any cv2 window to be drawn?\nDebian Jessie - Python 3.4 - OpenCV 3.2.0","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":269,"Q_Id":54314386,"Users Score":0,"Answer":"When you destroy the root window, it destroys all children windows as well. If cv2 uses a tkinter window or child window of the root window, it will fail if you destroy the root window.","Q_Score":0,"Tags":"python-3.x,opencv,tkinter,cv2","A_Id":54315569,"CreationDate":"2019-01-22T18:26:00.000","Title":"tkinter.root.destroy and cv2.imshow - X Windows system error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a .python-version file, and when I create a Python repo with github and specify that it should have a .gitignore, it adds the .python-version file to it. It seems to me that that file should NOT be ignored since other people running the code on different machines would want to know what version of Python they need.\nSo why is it .gitignored?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":8617,"Q_Id":54315206,"Users Score":17,"Answer":"The reason why .python-version should be gitignored is because its version is too specific. Tiny versions of Python (e.g. 2.7.1 vs 2.7.2) are generally compatible with each other, so you don't want to lock down to a specific tiny version. Furthermore, many Python apps or libraries should work with a range of Python versions, not just a specific one. Using .python-version indicates that you want other developers to use an exact, specific Python version, which is usually not a good idea.\nIf you want to indicate the minimum Python version needed, or otherwise a version range, then I believe documenting that in a README is a more appropriate solution.","Q_Score":31,"Tags":"python,github,gitignore,pyenv","A_Id":54368544,"CreationDate":"2019-01-22T19:31:00.000","Title":"Should we gitignore the .python-version 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 have a .python-version file, and when I create a Python repo with github and specify that it should have a .gitignore, it adds the .python-version file to it. It seems to me that that file should NOT be ignored since other people running the code on different machines would want to know what version of Python they need.\nSo why is it .gitignored?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":8617,"Q_Id":54315206,"Users Score":1,"Answer":"Old post but still relevant.\nMy answer would be \"it depends\".\nThe name of a virtual env can also be used in .python-version, if it is managed with the help of the virtualenv plugin of pyenv. This makes this file pretty useless it the project is managed on a public Git repo and you can exclude it (but not to do is harmless as told in other answers).\nBut (and I am in this situation) if you manage the project on a private repo and share virtual envs, it can make sense to not exclude it from Git. This allows you to work with a different environment (including the Python version) on an experimental branch of the project. Of course, it would have been far cleaner to fork or clone the original project and experiment with the new env in the copy, but sometimes it easier to just create a new branch.\nAt the end of the day, IMHO there is no universal answer to the question, and it depends on your workflow.","Q_Score":31,"Tags":"python,github,gitignore,pyenv","A_Id":63808471,"CreationDate":"2019-01-22T19:31:00.000","Title":"Should we gitignore the .python-version 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 have a .python-version file, and when I create a Python repo with github and specify that it should have a .gitignore, it adds the .python-version file to it. It seems to me that that file should NOT be ignored since other people running the code on different machines would want to know what version of Python they need.\nSo why is it .gitignored?","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":8617,"Q_Id":54315206,"Users Score":4,"Answer":"It can also be a bit problematic when using python virtual environments, as people may want to use virtual environment names different than 3.7.2\/envs\/myvenv.","Q_Score":31,"Tags":"python,github,gitignore,pyenv","A_Id":54476106,"CreationDate":"2019-01-22T19:31:00.000","Title":"Should we gitignore the .python-version 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 on Windows and I am trying to figure how to use Pyinstaller to make a file (on Windows) for a Mac.\nI have no trouble with Windows I am just not sure how I would make a file for another OS on it.\nWhat I tried in cmd was: pyinstaller -F myfile.py and I am not sure what to change to make a Mac compatible file.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":178,"Q_Id":54317780,"Users Score":0,"Answer":"Not Possible without using a Virtual Machine","Q_Score":1,"Tags":"python,python-3.x,pyinstaller","A_Id":54318656,"CreationDate":"2019-01-22T23:09:00.000","Title":"How do I use Pyinstaller to make a Mac file on Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm debugging an image-related program in py2 and py3 environments. The strange point is, the performance in py3 env is always belower than that in py2 env. So I traced back to the very beginning,and I found that after the first cv.imread(), there exists pixel-level errors. The two pixels at the same location but in different envs having an difference of 1. .What may be the reason leading to this problem?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":39,"Q_Id":54319431,"Users Score":-1,"Answer":"Compare versions of all involved libraries. Is the file compressed or something like jpg? \nI feel like this will not happen with something like PNG, but maybe with something like JPG that is compressed and needs to be uncompressed.\nIt is quite possible that your openCV has different version and uses different way to open JPG.\nBy opening PNG, I cannot believe this could happen because PNG is raw array","Q_Score":0,"Tags":"python,numpy,opencv,image-processing","A_Id":54322779,"CreationDate":"2019-01-23T03:00:00.000","Title":"cv.imread() pixel-level errors between py2 and py3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large text file of URLs (>1 million URLs). The URLs represent product pages across several different domains.\nI'm trying to parse out the SKU and product name from each URL, such as:\n\nwww.amazon.com\/totes-Mens-Mike-Duck-Boot\/dp\/B01HQR3ODE\/\n\n\ntotes-Mens-Mike-Duck-Boot\nB01HQR3ODE\n\nwww.bestbuy.com\/site\/apple-airpods-white\/5577872.p?skuId=5577872\n\n\napple-airpods-white\n5577872\n\n\nI already have the individual regex patterns figured out for parsing out the two components of the URL (product name and SKU) for all of the domains in my list. This is nearly 100 different patterns.\nWhile I've figured out how to test this one URL\/pattern at a time, I'm having trouble figuring out how to architect a script which will read in my entire list, then go through and parse each line based on the relevant regex pattern. Any suggestions how to best tackle this?\nIf my input is one column (URL), my desired output is 4 columns (URL, domain, product_name, SKU).","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":176,"Q_Id":54319452,"Users Score":1,"Answer":"While it is possible to roll this all into one massive regex, that might not be the easiest approach. Instead, I would use a two-pass strategy. Make a dict of domain names to the regex pattern that works for that domain. In the first pass, detect the domain for the line using a single regex that works for all URLs. Then use the discovered domain to lookup the appropriate regex in your dict to extract the fields for that domain.","Q_Score":0,"Tags":"python,regex,python-3.x","A_Id":54319613,"CreationDate":"2019-01-23T03:02:00.000","Title":"Parsing list of URLs with regex patterns","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Beginner's question - I know that '10' > '8' is False, and I know that the ASCII value of '8' is 56, but what is the value of '10'?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1920,"Q_Id":54321709,"Users Score":2,"Answer":"Each character has its own ASCII value. The ASCII value of '1' is 49 and the ASCII value of '0' is 48.\nThe ASCII values for '10' could be represented as [49, 48].","Q_Score":1,"Tags":"python,ascii","A_Id":54321817,"CreationDate":"2019-01-23T07:06:00.000","Title":"Python ASCII values of a string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Beginner's question - I know that '10' > '8' is False, and I know that the ASCII value of '8' is 56, but what is the value of '10'?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1920,"Q_Id":54321709,"Users Score":3,"Answer":"Python compares string lexicographically i.e using ASCII value of the characters.\nHere you are not comparing the numbers 10 and 8. You're comparing the string '10' with '8'. \nIt is string comparison\/ordering (i.e) you only order(alphabetical) the strings with the first character right?\nThat's what is done here. Here it compares the 8 and 1 rather than 10. 1 happens before 8 in the ascii table. 1 is obviously not greater than 8. That's why you get False.\nUse int('10') if your intention is to do numerical comparison.","Q_Score":1,"Tags":"python,ascii","A_Id":54321853,"CreationDate":"2019-01-23T07:06:00.000","Title":"Python ASCII values of a string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some Python image processing code that uses Keras and TensorFlow Libs, which is needed to be converted to Java Framework.\nMy main problems are:\na. TensorFlow for java is not stable yet, so I have to find another  equivalent Java Lib.\nb. I haven't found Java image processing library that covers the Keras image processing functions and utility (e.g. the class \"ImageDataGenerator\")\nc. The program intends to be cross-platform for dummies (biologists....) so it shall not use any native parts that may cause realtime compiling problems for the clients, means it needs to be written in pure Java.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":54324148,"Users Score":0,"Answer":"Tensorflow themselves say: \n\nCaution: The TensorFlow Java API is not covered by the TensorFlow API\n  stability guarantees.\n\nThis however doesn't mean that your application will not be stable. The key take-away here is that whatever you will build is not guaranteed to work out of the box when new versions are released. However, if you pin down the version of the Tensorflow API that you use, you should be alright.","Q_Score":1,"Tags":"java,python,tensorflow,image-processing,keras","A_Id":54324410,"CreationDate":"2019-01-23T09:38:00.000","Title":"Python to java image proccesing translation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to run a Monte-Carlo control algorithm, and keep getting frustrated when setting the number of steps in the code. It needs to be a large number (thousands, millions...) and it is hard to read it at a glance so I need to count zeros whenever I change it. I tried entering it as \nN_EPISODES = 1 000 000 \nor \nN_EPISODES = int('1 000 000')\nor with commas instead of spaces, but none of these work. Is there a way to set large numbers in the code in a human-readable way?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":459,"Q_Id":54325854,"Users Score":-1,"Answer":"You can try writing your number in a scientific-style way?\nLike 1e6 instead of 1000000 or 1,000,000...","Q_Score":0,"Tags":"python","A_Id":54325913,"CreationDate":"2019-01-23T11:08:00.000","Title":"Is it possible to write large numbers with spaces in the code","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a script that uses PyWinAuto to do some UI automation, and it works, but actions like toggling checkboxes, locating a text box and one of my functions which uses print_control_identifiers are slow (or slower than a human doing the same thing).\nFrom what I understand of how it works, this is due to recursive searches through the windows controls. I'm trying to limit the depth that I have to go to when calling print_control_identifiers, I think my main issue is the \"best match\" lookup that occurs when doing an action on an item. I'm currently trying to use the suggested IDs in an attempt to speed this up.\nAny tips as to speeding up execution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":330,"Q_Id":54326634,"Users Score":1,"Answer":"child_window(..., control_type=\"...\") performs search faster because preliminary filtering by control_type doesn't require inter-process communication as well as class_name.\nbest_match algorithm can be improved in general (I suspect it has N^3 complexity). This work is not started, I'd be happy to discuss any help.","Q_Score":1,"Tags":"optimization,python-3.7,pywinauto","A_Id":54327145,"CreationDate":"2019-01-23T11:50:00.000","Title":"Optimising Pywinauto","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm so much newbie in openCV\/Python tasks. I use Python 3.7 and openCV 4 running by a JNotebook. The question: I wanna save just 1,000 images from a dataset with 10,000 pictures, extracting them from it and write only those 1,000.jpeg in a new folder, is it possible using openCV package in Python? I've already had a list of names (1,000 images).","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3167,"Q_Id":54328126,"Users Score":2,"Answer":"Assuming you have OpenCV correctly installed on your machine, you can first read the images with img = cv.imread(filename) and then write them with cv.imwrite(filename, img).","Q_Score":0,"Tags":"python,opencv,computer-vision","A_Id":54328218,"CreationDate":"2019-01-23T13:14:00.000","Title":"How to save (write) a list of images from a dataset into a new folder - openCV Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using scapy for automated changing of packet fields (mixing pcaps). In case of packets with bad checksum i need to avoid scapy automatically calculating the correct checksum. \nThis is done automatically when writing new packets into pcap using the PcapWriter. Is there a way to prevent it from recalculating checksum on packets?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":355,"Q_Id":54337606,"Users Score":1,"Answer":"Scapy only fills checksum if the previous one was set to None.\nIf you manually set the checksum to some random stuff, it won\u2019t be updated","Q_Score":1,"Tags":"python,python-3.x,scapy,packet","A_Id":54355080,"CreationDate":"2019-01-24T00:15:00.000","Title":"How to force bad checksum on packet using scapy PcapWriter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"what does it mean to use K-means clustering on a data set that indicates relative distances from one item to another?\nFor example, each item is given a relative distance to every other item.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":54338377,"Users Score":0,"Answer":"K-means clustering assigns items to clusters such that the total intra-cluster distance is minimized. Hence, the only input that is needed is a distance function d(a,b). Often, the items are vectors in a normed vector space and d is chosen as d(a,b) = ||a-b|| for some norm ||x||. But in general, any distance function that fulfills d(a,a) = 0 (distance from a point to itself is zero), d(a,b) <= d(a,c) + d(c,b) (triangle inequality), and d(a,b) = d(b,a) (symmetry) can be used. It can even be a matrix where the entry M(i,j) gives the distance between items i and j, as long as the entries obey the rules above.","Q_Score":0,"Tags":"python","A_Id":54338545,"CreationDate":"2019-01-24T02:02:00.000","Title":"What does it mean to use K-means clustering on a data set that indicates relative distances from one item to another?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just started myself with AWS cloud automations and have been using python boto3 for automations. I find boto3 is convenient for me becoz im not good with using AWS CLI commands using inside shell script for automations. My question is for AWS cloud automation, is boto3 superior to AWS CLI commands ? or whats is the advantage that python boto3 i having over AWS CLI commands or vice versa ?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1641,"Q_Id":54338549,"Users Score":3,"Answer":"If you can use boto3, then that is the far-superior choice. It gives you much more ability to supplement the AWS API calls with additional logic, such as filtering results with. It is also easier to chain API calls, such as making one call for a list of resources, then making follow-up calls to describe each resources in detail.\nThe AWS CLI is very convenient for one-off commands or simple automation, but things get tricky when using --filter and --query commands.","Q_Score":1,"Tags":"python,amazon-web-services,boto3,aws-cli","A_Id":54340510,"CreationDate":"2019-01-24T02:29:00.000","Title":"Advantage of AWS SDK boto3 over AWS CLI 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 am trying to to use pdfkit in python to generate pdf from string . But its not working . But then I get the following error :-\nOSError: No wkhtmltopdf executable found: \"b''\"\nI am using ubuntu 16 and python3.6.6\nI installed the wkhtmltopdf by using sudo apt-get wkhtmltopdf and tried implementing the pdfkit again , but then I get the error COULD NOT CONNECT THE X DISPLAY . \nI also tried putting export DISPLAY=:0 in environment, but still getting the error \nCOULD NOT CONNECT TO DISPLAY 0","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":54339662,"Users Score":0,"Answer":"you need to do export DISPLAY=localhost:10.0","Q_Score":0,"Tags":"python-3.x,wkhtmltopdf,pdfkit","A_Id":56264701,"CreationDate":"2019-01-24T05:03:00.000","Title":"Getting Error Could Not Connect to display","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why do we use empty parentheses here in python?\nMy code is reference to book Data Science from scratch.\nfor user in users:\n    user[\"friend\"]=[]\nIn the above code Users is a list in which there are some dictionaries.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":29,"Q_Id":54340396,"Users Score":1,"Answer":"That means you want to create a list with no value inside.\nit is equivalent to user[\"friend\"] = list()","Q_Score":0,"Tags":"python-3.x","A_Id":54340891,"CreationDate":"2019-01-24T06:14:00.000","Title":"Why do we use empty parentheses here in python reference to book data science from scratch?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"(py1) C:\\Users\\XXXXX>pip list\n        Version\n        ----------------- ----------\n        certifi           2018.11.29\n        chardet           3.0.4\n        idna              2.8\n        lxml              4.3.0\n        numpy             1.16.0\n        pandas            0.23.4\n        pandas-datareader 0.7.0\n        pip               18.1\n        python-dateutil   2.7.5\n        pytz              2018.9\n        requests          2.21.0\n        scipy             1.2.0\n        setuptools        40.6.3\n        six               1.12.0\n        urllib3           1.24.1\n        wheel             0.32.3\n        wrapt             1.11.1\nand it also works when I type python on my cmd:\n`        (py1) C:\\Users\\XXXXX>python\n        Python 3.7.2 (tags\/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit\n        (Intel)] on win32\n        Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\n\n\nimport pandas_datareader\n      `\n\n\n\nHowever, when I try importing it in Jupyter Notebook (launching from the same venv) it gives me the error below:\n(py1) C:\\Users\\XXXXX>python\n`        Python 3.7.2 (tags\/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC         v.1916 32 bit\n        (Intel)] on win32\n        Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\n\n\nimport pandas_datareader\n      `","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":546,"Q_Id":54340532,"Users Score":1,"Answer":"I could resolve this, I went to my venv and executed this command: python -m pip install ipykernel and then upgraded pip and it started working.\nThank you,\nMohit","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":54392629,"CreationDate":"2019-01-24T06:26:00.000","Title":"I have installed pandas_datareader in pip but when I try to import the same in Jupyter Notebook it says Module not found","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can i calculate Imbalance Ratio for a dataset which is imbalanced? I came across a way in which it defined (it's taken from a paper):\n\ngiven by the imbalance ratio (IR), defined as the ratio of the number of instances in the majority class to the number of examples in the minority class\n\nNow, is this one of the right ways to calculate?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1656,"Q_Id":54342353,"Users Score":0,"Answer":"IR = (negative_class\/positive_class)\nWhere positive_class is the number of minority class samples and negative_class is the number of majority class samples.","Q_Score":0,"Tags":"python,dataset,data-mining,data-science","A_Id":58307961,"CreationDate":"2019-01-24T08:33:00.000","Title":"Calculate Imbalance Ratio for a multi-class dataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to make a pipeline using Data Factory In MS Azure of processing data in blob storage and then running a python processing code\/algorithm on the data and then sending it to another source.\nMy question here is, how can I do the same in Azure function apps? Or is there a better way to do it?\nThanks in advance.\nShyam","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":757,"Q_Id":54343289,"Users Score":0,"Answer":"I created a Flask API and called my python code through that. And then put it in Azure as a web app and called the blob.","Q_Score":0,"Tags":"python,azure,azure-functions","A_Id":54685275,"CreationDate":"2019-01-24T09:30:00.000","Title":"Python Azure function processing blob storage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have coco dataset(19 gb), the dataset upload googledrive but colab is not find this data despite use this code import sys\nsys.path.insert(0, 'content\/gdrive\/My Drive\/caption').How can I find this file?\nimport sys\nsys.path.insert(0, 'content\/gdrive\/My Drive\/caption')","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1305,"Q_Id":54343491,"Users Score":1,"Answer":"I suspect you need a leading \/ in your path. (Typically, the Drive FUSE mount path is \/content\/...)","Q_Score":1,"Tags":"python,google-colaboratory","A_Id":54351092,"CreationDate":"2019-01-24T09:40:00.000","Title":"How to install coco dataset in colab?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using google colab on a dataset with 4 million rows and 29 columns. When I run the statement sns.heatmap(dataset.isnull()) it runs for some time but after a while the session crashes and the instance restarts. It has been happening a lot and I till now haven't really seen an output. What can be the possible reason ? Is the data\/calculation too much ? What can I do ?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":32699,"Q_Id":54344101,"Users Score":0,"Answer":"I would first suggest closing your browser and restarting the notebook. Look at the run time logs and check to see if cuda is mentioned anywhere. If not then do a factory runtime reset and run the notebook. Check your logs again and you should find cuda somewhere there.","Q_Score":16,"Tags":"python,data-visualization,google-colaboratory","A_Id":69872171,"CreationDate":"2019-01-24T10:11:00.000","Title":"Why does my google colab session keep crashing?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using google colab on a dataset with 4 million rows and 29 columns. When I run the statement sns.heatmap(dataset.isnull()) it runs for some time but after a while the session crashes and the instance restarts. It has been happening a lot and I till now haven't really seen an output. What can be the possible reason ? Is the data\/calculation too much ? What can I do ?","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":32699,"Q_Id":54344101,"Users Score":2,"Answer":"This error mostly comes if you enable the GPU but do not using it. Change your runtime type to \"None\". You will not face this issue again.","Q_Score":16,"Tags":"python,data-visualization,google-colaboratory","A_Id":69688669,"CreationDate":"2019-01-24T10:11:00.000","Title":"Why does my google colab session keep crashing?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using google colab on a dataset with 4 million rows and 29 columns. When I run the statement sns.heatmap(dataset.isnull()) it runs for some time but after a while the session crashes and the instance restarts. It has been happening a lot and I till now haven't really seen an output. What can be the possible reason ? Is the data\/calculation too much ? What can I do ?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":32699,"Q_Id":54344101,"Users Score":0,"Answer":"For me, passing specific arguments to the tfms augmentation failed the dataloader and crahed the session.\nWasted lot of time checking the images not coruppt and clean the gc and more...","Q_Score":16,"Tags":"python,data-visualization,google-colaboratory","A_Id":63649402,"CreationDate":"2019-01-24T10:11:00.000","Title":"Why does my google colab session keep crashing?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using google colab on a dataset with 4 million rows and 29 columns. When I run the statement sns.heatmap(dataset.isnull()) it runs for some time but after a while the session crashes and the instance restarts. It has been happening a lot and I till now haven't really seen an output. What can be the possible reason ? Is the data\/calculation too much ? What can I do ?","AnswerCount":5,"Available Count":4,"Score":0.1973753202,"is_accepted":false,"ViewCount":32699,"Q_Id":54344101,"Users Score":5,"Answer":"Another cause - if you're using PyTorch and assign your model to the GPU, but don't assign an internal tensor to the GPU (e.g. a hidden layer).","Q_Score":16,"Tags":"python,data-visualization,google-colaboratory","A_Id":61336224,"CreationDate":"2019-01-24T10:11:00.000","Title":"Why does my google colab session keep crashing?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training Random Forests with two sets of \"true\" y values (empirical). I can easy tell which one is better.\nHowever, I was wondering if there is a simple method, other than brute force, to pick up the values from each set that would produce the best model. In other words, I would like to automatically mix both y sets to produce a new ideal one.\nSay, for instance, biological activity. Different experiments and different databases provide different values. This is a simple example showing two different sets of y values on columns 3 and 4.\n\n4a50,DQ7,47.6,45.4\n3atu,ADP,47.7,30.7\n5i9i,5HV,47.7,41.9\n5jzn,GUI,47.7,34.2\n4bjx,73B,48.0,44.0\n4a6c,QG9,48.1,45.5\n\nI know that column 3 is better because I have already trained different models against each of them and also because I checked a few articles to verify which value is correct and 3 is right more often than 4. However, I have thousands of rows and cannot read thousands of papers.\nSo I would like to know if there is an algorithm that, for instance, would use 3 as a base for the true y values but would pick values from 4 when the model improves by so doing.\nIt would be useful it it would report the final y column and be able to use more than 2, but I think I can figure out that.\nThe idea now is to find out if there is already a solution out there so that I don't need to reinvent the wheel.\nBest,\nMiro\nNOTE: The features (x) are in a different file.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":314,"Q_Id":54345579,"Users Score":2,"Answer":"The problem is that an algorithm alone doesn't know which label is better. \nWhat you could do: Train a classifier on data which you know is correct. Use the clasifier to predcit a value for each datapoint. Compare this value to the two list of labels which you already have and choose the label which is closer. \nThis solution obviously isn't perfect since the results depends on quality of the classfier which predicts the value and you still need enough labeled data to train the classifier. Additionaly there is also a chance that the classifier itself predicts a better value compared to your two lists of labels.","Q_Score":0,"Tags":"python,scikit-learn,random-forest","A_Id":54346332,"CreationDate":"2019-01-24T11:28:00.000","Title":"Scikit-Learn Random Forest regression: mix two sets of true values (y)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an old project running (Django 1.6.5, Python 2.7) live for several years. I have to make some changes and have set up a working development environment with all the right django and python requirements (packages, versions, etc.)\nEverything is running fine, except when I am trying to make changes inside the admin panel. I can log on fine and looking at the database (sqlite3) I see my user has superuser privileges. However django says \"You have no permissions to change anything\" and thus not even displaying any of the models registered for the admin interface.\nI am using the same database that is running on the live server. There I have no issues at all (Live server also running in development mode with DEBUG=True has no issues) -> I can only see the history (My Change Log) - Nothing else\nI have also created a new superuser - but same problem here.\nI'd appreciate any pointers (Maybe how to debug this?)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":54345919,"Users Score":0,"Answer":"Finally, I found the issue:\nadmin.autodiscover()\nwas commented out in the project's urls.py for some reason. (I may have done that trying to get the project to work in a more recent version of django) - So admin.site.register was never called and the app_dict never filled. index.html template of django.contrib.admin then returns \n\nYou don't have permission to edit anything.\n\nor it's equivalent translation (which I find confusing, given that the permissions are correct, only no models were added to the admin dictionary.\nI hope this may help anyone running into a similar problem","Q_Score":0,"Tags":"python,django,database,admin,privileges","A_Id":54363022,"CreationDate":"2019-01-24T11:46:00.000","Title":"Django Admin Interface - Privileges On Development Server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Trying to use Pylint in CMD, verified that it's installed but CMD on Windows 10 says:\n\"Pylint is not recognised as an internal or external command, nor is it an executable program or a command file\".\nPython beginner, using Anaconda3 distribution.\nC:\\Users\\username\\Documents>pylint filename.py","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":890,"Q_Id":54347297,"Users Score":1,"Answer":"You should use Anaconda-Prompt instead of CMD if you have not added the anaconda python to your PATH environment.\nYou can search for Anaconda-Prompt in windows search (Press Windows Key + Q).\nThen you should be able to use pylint, in the command line (within Anaconda-Prompt).","Q_Score":0,"Tags":"python,cmd,pylint","A_Id":54347479,"CreationDate":"2019-01-24T13:01:00.000","Title":"Pylint not found in CMD","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I get a list with of all filenames of an archive in Python3?\nThe archive is a variable of type ZipFile.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":54347344,"Users Score":0,"Answer":"Simple , you call zip.namelist() and iterate over each entry.","Q_Score":0,"Tags":"python-3.x,zip","A_Id":54347371,"CreationDate":"2019-01-24T13:04:00.000","Title":"How to get filenames of an archive in Python3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a utility to start up a django server process that outputs its logs to a TextCtrl in a wxpython window. Unfortunately, a couple different approaches have led to weird issues where the operating system (OSX in this case) crashing the program with complaints about \"Illegal Instruction\" after a few successful log entries.\nI'm currently doing this by implementing a logging.Handler subclass that posts events to wx that contain the logging records to be shown in the window. Is there a better approach?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":54347547,"Users Score":1,"Answer":"wxPython requires it to be the main thread, so I am guessing that is the likely root cause of your issue. You have a couple of good approaches to try though.\nFirst you could launch the Django server process as a thread from your wxPython program. Then you can use wxPython's thread-safe methods (wx.CallAfter, wx.PostEvent) to communicate with the UI.\nOr you could just launch Django separately and log to a file. Then launch wxPython and have it basically tail the log file.","Q_Score":0,"Tags":"django,wxpython","A_Id":54406886,"CreationDate":"2019-01-24T13:15:00.000","Title":"Django logging to wxpython window?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Current Architecture\nOn the most foundation part is Kubernetes with multiple different container images.\nOn top of them, we have a python library which dynamically loads our code, which we write and install on those containers after deployment. \nWe write stateful applications on k8, that's why this kind of architecture.\nLet's call our code beta and the lib which loads it alpha\nThe current process testing new changes it the following:\n\nprovision of a new container with the new installed changed from the artefactory\nrun alpha, which loads beta, which we actively develop\n\nWhat we can do\/ cannot do\n\nno ssh\nall commands of kubectl\nport forwards \nim using OSX, with PyCharm\n\nNow the question:\n\nHow can I start my local IDE and set a breakpoint in beta, which gets loaded after running alpha on the k8 pod -> container","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":582,"Q_Id":54347615,"Users Score":0,"Answer":"For now the possible solution was to do the following:\n- add a remote debugger to the code, which listens upon start\n- port forward the traffic\n- clone the code (install), such that the lib gets run, as soon as you run the main\n- run the code \n- it waits until attach\n- attach to the debugger.\nVoila it works.","Q_Score":1,"Tags":"python,debugging,networking,kubernetes","A_Id":54479020,"CreationDate":"2019-01-24T13:18:00.000","Title":"Debug Python on Kubernetes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a dataframe with around 20000 rows and 98 features (all the features are numerical) and a target feature with binary values: 0 and 1. Basically, there are two population (first population with target value 1 --50%--, and the second with target value 0 -50%- balanced data). In a classification problem, I tried to predict the target value given the data. So, I have implanted a supervised learning algorithm (e.g., SVM) to predict the target value, and could obtain a very good result with around 0.95 accuracy. This result gives me a point that there is a considerable difference between the features. So, in the next step, I have to know what are the important features which made this difference, and what is best way to quantify this difference in the features between these two group of population. Any idea?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":203,"Q_Id":54350062,"Users Score":0,"Answer":"Can you try to use KS-test for your features? for example, feature 1, split by it's class. then you get two groups. Then test if they come from different distribution or just record the p-value.\nwhen you have all the test result or p-value, make another model with the samples that comes from different distribution \/ very low p-value. see if the new model is better or similar.\nnot sure if this achieves anything.\nwanted to comment but couldn't do so.","Q_Score":0,"Tags":"python,machine-learning,statistics,data-mining,feature-selection","A_Id":54356646,"CreationDate":"2019-01-24T15:26:00.000","Title":"How to Measure the difference between features in dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe with around 20000 rows and 98 features (all the features are numerical) and a target feature with binary values: 0 and 1. Basically, there are two population (first population with target value 1 --50%--, and the second with target value 0 -50%- balanced data). In a classification problem, I tried to predict the target value given the data. So, I have implanted a supervised learning algorithm (e.g., SVM) to predict the target value, and could obtain a very good result with around 0.95 accuracy. This result gives me a point that there is a considerable difference between the features. So, in the next step, I have to know what are the important features which made this difference, and what is best way to quantify this difference in the features between these two group of population. Any idea?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":203,"Q_Id":54350062,"Users Score":0,"Answer":"Aside from using the coefficients of the support vectors from your model, you could try build other models.\nA decision tree approach will explicitly show you which input features split the data - those nearer the root being more important, for some definition of important.\nIf you try a feature reduction technique, like PCA, and rebuild you model, the coefficients of the components here will tell you which contribute most.\nOr you could be completely thug-headed, and build lots of models leaving out some features and see which are better.\nOr you could be lateral, and consider what's so different about the few points that your model doesn't accurately classify.","Q_Score":0,"Tags":"python,machine-learning,statistics,data-mining,feature-selection","A_Id":54350594,"CreationDate":"2019-01-24T15:26:00.000","Title":"How to Measure the difference between features in dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a solution to pull out all the code of the notebook?\nFor example, if I wanted to generate a source file of my notebook \"source.py\" that contained all the code in the code cells of the notebook, is that possible?\nThanks!","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":11736,"Q_Id":54350254,"Users Score":11,"Answer":"You can do File -> Download as -> Python (.py) \u2014 this should export all code cells as single .py file","Q_Score":13,"Tags":"python,jupyter-notebook","A_Id":54350294,"CreationDate":"2019-01-24T15:36:00.000","Title":"Get only the code out of Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a solution to pull out all the code of the notebook?\nFor example, if I wanted to generate a source file of my notebook \"source.py\" that contained all the code in the code cells of the notebook, is that possible?\nThanks!","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":11736,"Q_Id":54350254,"Users Score":1,"Answer":"There is an \"ugly\" solution. Select all the cells of your notebook. Merge them, then just copy and paste all the code.","Q_Score":13,"Tags":"python,jupyter-notebook","A_Id":54350274,"CreationDate":"2019-01-24T15:36:00.000","Title":"Get only the code out of Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a solution to pull out all the code of the notebook?\nFor example, if I wanted to generate a source file of my notebook \"source.py\" that contained all the code in the code cells of the notebook, is that possible?\nThanks!","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":11736,"Q_Id":54350254,"Users Score":1,"Answer":"In case you are using jupyter lab then the option is:\nFile > Export Notebook As > Executable Script","Q_Score":13,"Tags":"python,jupyter-notebook","A_Id":66550565,"CreationDate":"2019-01-24T15:36:00.000","Title":"Get only the code out of Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a python script whose goal is to detect if a point is out of a row of points (gps statement from an agricultural machine). \nInput data are shapefile and I use Geopandas library for all geotreatments.\nMy first idea was to make a buffer around the 2 points around considered point. After that, I watch if my point is in the buffer. But results aren't good.\nSo I ask myself if there is a mathematical smart method, maybe with Scikit lib... Somebody is able to help me?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":136,"Q_Id":54350293,"Users Score":0,"Answer":"try arcgis.\nbuild two new attributes in arcgis with their X and Y coordinate,then calculate the distance between the points you want","Q_Score":0,"Tags":"python,math,row,geospatial,point","A_Id":54350414,"CreationDate":"2019-01-24T15:38:00.000","Title":"Smart way to detect too far away point from a row of points?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a beginner to Python and trying to start my very first project, which revolves around creating a program to automatically fill in pre-defined values in forms on various websites.\nCurrently, I'm struggling to find a way to identify web elements using the text shown on the website. For example, website A's email field shows \"Email:\" while another website might show \"Fill in your email\". In such cases, finding the element using ID or name would not be possible (unless I write a different set of code for each website) as they vary from website to website.\nSo, my question is, is it possible to write a code where it will scan all the fields -> check the text -> then fill in the values based on the texts that are associated with each field?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":81,"Q_Id":54350822,"Users Score":1,"Answer":"It is possible if you know the markup of the page, and you can write code to parse this page. In this case you should use xpath, lxml, beautiful soup, selenium etc. You can look at many manuals on google or youtube, just type \"python scraping\"\nBut if you want to write a program able to understand random page on a random site and understand what it should do, it is very difficult, it's a complex task with using machine learning. I guess this task is completely not for beginners.","Q_Score":1,"Tags":"python,python-3.x,selenium-webdriver","A_Id":54351000,"CreationDate":"2019-01-24T16:05:00.000","Title":"Filling forms on different websites using Selenium and Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"pip 19.0.1 from c:\\users\\halzein\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\pip (python 3.7)\nTrying to install PyInstaller with this command:\npip3 install PyInstaller --trusted-host pypi.org --trusted-host files.pythonhosted.org \n(I get errors if I try to use pip without trusted-host tags)\nAnd the install keeps failing due to this error after downloading and installing build dependencies:\nModuleNotFoundError: No module named 'PyInstaller'\n\nCommand \"c:\\users\\halzein\\appdata\\local\\programs\\python\\python37\\python.exe c:\\users\\halzein\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\pip\\_vendor\\pep517\\_in_process.py get_requires_for_build_wheel C:\\Users\\halzein\\AppData\\Local\\Temp\\tmpfwtrnagf\" failed with error code 1 in C:\\Users\\halzein\\AppData\\Local\\Temp\\pip-install-thcvcr0q\\PyInstaller\\\nNot really sure what's causing this, and my searches have come up with nothing.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7855,"Q_Id":54352077,"Users Score":6,"Answer":"I faced same error, here's what worked for me:\nRun windows powershell as administrator, and downgrade pip to 18.1 by typing pip install pip==18.1 this will uninstall 19.0.1 and install 18.1 version. After that just run pip install pyinstaller and it should finish it with no errors. Than you can upgrade pip to 19.0.1 with python -m pip install \u2013upgrade pip\nHope this help you too.\nCheers =)","Q_Score":3,"Tags":"python,python-3.x,pip,pyinstaller","A_Id":54547515,"CreationDate":"2019-01-24T17:13:00.000","Title":"PyInstaller failing to install through pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Selenium. The web interface of our product pops up a EULA agreement which the user has to scroll down and accept before proceeding. This happens ONLY on initial login using that browser for that user. \nI looked at the Selenium API but I am unable to figure out which one to use and how to use it.\nWould much appreciate any suggestions in this regard.\nI have played around with the IDE for Chrome but even over there I don't see anything that I can use for this. I am aware there is an 'if' command but I don't know how to use it to do something like:\nif EULA-pops-up:\n   Scroll down and click 'accept'\nproceed with rest of test.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":348,"Q_Id":54354067,"Users Score":0,"Answer":"You may disable the EULA if that is an option for you, I am sure there is a way to do it in registries as well :\nC:\\Program Files (x86)\\Google\\Chrome\\Application there should be a file called master_preferences.\nOpen the file and setting:\nrequire_eula to false","Q_Score":0,"Tags":"python,selenium","A_Id":54354319,"CreationDate":"2019-01-24T19:31:00.000","Title":"How to handle EULA pop-up window that appears only on first login?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So this question is pretty easy, but I didn't find a great answer. In my program, I want to import the OS package using: import os.\nWell, how can I import this package using the anaconda prompt? I tried conda install os and pip install os and it didn't work. Can anyone help me?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":21402,"Q_Id":54355608,"Users Score":4,"Answer":"os is already installed with your python package. You just have to import it into your python files, you can do this by import os.","Q_Score":1,"Tags":"python,operating-system,package,anaconda,prompt","A_Id":54355948,"CreationDate":"2019-01-24T21:31:00.000","Title":"How can I install the \"OS\" package of python using the anaconda prompt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How might I go about performing automated mobile search using python?\nI have a program exploiting the Microsoft Rewards program, but currently I'm limited to desktop search. The bot performs random searches via bing for various accounts to gain points, later redeemed for voucher codes. \nMy intention is to do the same for mobile.\nI appreciate this is quite a general question, but despite my best efforts, I can't find even a starting point.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":54355902,"Users Score":0,"Answer":"This can be done via a desktop through a browser mobile device simulation.\nChrome browser: More tools -> developer tools -> toggle device toolbar. \nThis can also be done via hotkeys and hence suitable for automation. Now have the program perform searches using the same desktop search protocol; searches will be performed as if they're from a mobile device. \nOthers browsers have this capability.","Q_Score":0,"Tags":"android,python","A_Id":54592411,"CreationDate":"2019-01-24T21:56:00.000","Title":"Performing mobile search on an android device using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've tried virtualenv and conda, it was successfully installed but I cannot active the virtual environment. Then I think about saving Colab environment (I mean installed libraries) to somewhere, maybe Google Drive then I can reuse it.\nIs it possible?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":8977,"Q_Id":54360838,"Users Score":1,"Answer":"You can add a directory in GDrive to PYTHONPATH, e.g. \/content\/drive\/My Drive\/Colab Notebooks\/\nThen Python will search for an installed library there. You still need to mount to GDrive every time, though.","Q_Score":14,"Tags":"python,virtualenv,google-colaboratory","A_Id":54378530,"CreationDate":"2019-01-25T07:35:00.000","Title":"Is there anyway to save Google colab environment to somewhere and reuse it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an application engine where in-program communication is done using PyPubSub.\nPlanned is a somewhat responsive GUI that e.g. enables\/disables widgets based on the model state. This would be implemented using wxPython.\nAs wxPython has as an own pubsub lib (which is PyPubSub) that works across the GUI, question is: how to maintain the MVC model.\nIs it possible (and more importantly: does it make sense) to mix the two messaging systems while maintaining the MVC pattern? E.g. to keep these two messaging systems separate while enabling the GUI having subscribers to the topics of the engine?\nOr shall I just use the model's (that is, the app engine's) pubsub within the GUI and not use the wxPython built-in one?\nAny help is appreciated on this rather conceptual question.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":438,"Q_Id":54361345,"Users Score":2,"Answer":"Summary (by author of pypubsub): if you import from pypubsub instead of wx.lib.pubsub, everything will work, you will not have \"two messaging systems\". \nDetails: \nThere is nothing in the wx package that actually uses wx.lib.pubsub; the latter is still in wx.lib only for legacy reasons (see below), and it is entirely your choice whether you want to make use of publish-subscribe in your wxPython application. \nHistory of pypubsub\/wx.lib.pubsub: The wx.lib.pubsub was originally a module developed for wxPython and included in its source code. It was moved out as a standalone library called pypubsub (over 10 years ago!), since nothing in wxPython depended on it, and vice versa. For backwards compatibility, wx.lib.pubsub was kept alive as a specific \"release\" of the standalone pypubsub (for example, wxPython 3 used pypubsub 3.3). However the latest wxPython (4.0.4) has deprecated its wx.lib.pubsub: you should instead install standalone pypubsub directly from pip install or github, and use from pubsub import pub (instead of from wx.lib.pubsub import pub).\nIf you can, you should use wxPython 4.0.4, Python 3.7, and pypubsub 4.0.0 (4.0.1 will be coming out soon and support keyword-only args).","Q_Score":0,"Tags":"wxpython,publish-subscribe,pypubsub","A_Id":54385277,"CreationDate":"2019-01-25T08:15:00.000","Title":"mixed use of PyPubSub and wxPython's built-in pubsub module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to train a model for sentiment analysis and below is my trained Multinomial Naive Bayes Classifier returning an accuracy of 84%.\nI have been unable to figure out how to use the trained model to predict the sentiment of a sentence. For example, I now want to use the trained model to predict the sentiment of the phrase \"I hate you\".\nI am new to this area and any help is highly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":119,"Q_Id":54362232,"Users Score":1,"Answer":"I don't know the dataset and what is semantic of individual dictionaries, but you are training your model on a dataset which has form as follows:\n[[{\"word\":True, \"word2\": False}, 'neg'], [{\"word\":True, \"word2\": False}, 'pos']]\n\nThat means your input is in form of a dictionary, and output in form of 'neg' label. If you want to predict you need to input a dictionary in a form:\n\n{\"I\": True, \"Hate\": False, \"you\": True}.\n\nThen:\n\nMNB_classifier.classify({\"love\": True})\n>> 'neg'\nor \nMNB_classifier.classify_many([{\"love\": True}])\n>> ['neg']","Q_Score":0,"Tags":"python,python-3.x,classification,sentiment-analysis","A_Id":54363252,"CreationDate":"2019-01-25T09:21:00.000","Title":"Predicting values using trained MNB Classifier","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use my script that uses pandas library on another linux machine where is no internet access or pip installed. \nIs there a way how to deliver the script with all dependencies?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":54364440,"Users Score":0,"Answer":"or set needed dependices in script manually by appending sys.modules and pack together all the needed files.","Q_Score":0,"Tags":"python","A_Id":54365941,"CreationDate":"2019-01-25T11:29:00.000","Title":"Deliver python external libraries with script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My app is using a third-party API. It polls that API regularly at several endpoints. In also makes some additional calls to the API based on user's interaction with the app. The API is very slow, most requests take well over a second. The API is very flaky - timeouts are common, 500 errors are common, session key often randomly expires (even when defined \"keep_alive\" endpoint is called regularly). There is no option to use another API.\nWhat would be the best practices for dealing with such an API?\nHow to disable concurrent requests to this API on the requests level. So if one request is waiting for a response - the second request is not initiated? This should be done on \"per-domain\" basis, other requests to other domains should still be done concurrently.\nAny other settings to toggle with requests to make it easier to deal with such an API?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":399,"Q_Id":54365153,"Users Score":2,"Answer":"If your main problem is to serialize calls to that API in a multi-threaded (or multi process) application, a simple way would be to wrap it into a new module and consistenly use locking in that module.\nIf different clients can use a web API concurrently and you need to serialize the requests for performance reasons, you could imagine a dedicated serializing proxy. Just use above method in the proxy.","Q_Score":2,"Tags":"python,api,concurrency,python-requests","A_Id":54365613,"CreationDate":"2019-01-25T12:14:00.000","Title":"Python tips for working with an unstable `API`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm setting up a webapp with a frontend and a backend that communicates with the frontend soley through RESTful methods. How do I make sure that the backend endpoints are only accessed by my own frontend, and not anyone else? I cannot find much information on this.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":14150,"Q_Id":54369416,"Users Score":8,"Answer":"Look into CORS. And make sure your server only allows access to specific origins.\n\nOn the backend - check if the X-Requested-With header is present in the request and set to XMLHttpRequest. Without a proper CORS handshake this header will be absent.\n\n\nThat being said, this will only protect your API from being used by other front-end apps or from being accessed directly from a browser address bar - because browsers respect CORS. People can still forge requests programmatically\/CLI and set headers to whatever they want.\nSo this is not actually \"securing\" just a way to prevent abuse & hotlinking","Q_Score":34,"Tags":"python,security,falconframework","A_Id":64536791,"CreationDate":"2019-01-25T16:39:00.000","Title":"How to secure own backend API which serves only my frontend?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a cuda kernel written in numba-cuda that processes large arrays that do not fit in GPU memory at once. So, I have to call the kernel multiple times to process the entire arrays. The kernel is called in a loop and, inside the loop, after GPU is done the computation, I copy and aggregate the results back to a host array. \nMy questions: \n\nWhat is the lifetime of a device array and an array that is copied to GPU memory? Are their value preserved from one kernel call to another?\nDo I need to put the device arrays definitions inside the loop (before I call the kernel) or  do I just do it once before I enter the loop? \nDo I need to free\/delete the device arrays manually in the code or the CUDA memory manager will do it at the end of the program? \n\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":476,"Q_Id":54370090,"Users Score":1,"Answer":"What is the lifetime of a device array and an array that is copied to GPU memory? Are their value preserved from one kernel call to\n  another?\n\n\nIn Numba, global memory allocations are preserved until they are freed.\n\n\nDo I need to put the device arrays definitions inside the loop (before I call the kernel) or  do I just do it once before I enter the\n  loop? \n\n\nThe latter.\n\n\nDo I need to free\/delete the device arrays manually in the code or the CUDA memory manager will do it at the end of the program?\n\n\nThe first thing to realize is that there is no CUDA memory manager in the way you imagine. Memory allocations are automatically freed when a context is destroyed, otherwise they are not under any circumstances. The only exception to this is if you use a Numba device_array, which may be garbage collected by Python if it falls out of scope. But you should, in general, assume that anything you allocate remains in memory until you explicitly free it, and always include explicit memory deallocation in your code.","Q_Score":1,"Tags":"python,cuda,gpgpu,numba","A_Id":54380618,"CreationDate":"2019-01-25T17:25:00.000","Title":"Device memory array's life time","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a bunch of list of links which I'm doing a specific function on each link, the function takes about 25 sec, I use selenium to open each and get the page source of it then do my function, however whenever I  build the program and cancel the build, I will have to start all over again.\nNote:I get links  from  different webs sitemap.\nIs there a way to save my progress and continue it later on?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":797,"Q_Id":54370412,"Users Score":-1,"Answer":"You should save the links in a text file. You should also save the index numbers in another text file, probably initializing with 0.\nIn your code, you can then loop through the links using something like:\nfor link in links[index_number:]\nAt the end of every loop, add the index number to the text file holding the index numbers. This would help you continue from where you left off.","Q_Score":0,"Tags":"python,list,selenium","A_Id":54370470,"CreationDate":"2019-01-25T17:46:00.000","Title":"Continuing where I left off Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to create an interactive text box in a tkinter GUI, the text box should get the text to wrap to the next line after the length of 30 characters, like it would do using the wraplength=30 attribute in a label widget. I am trying to get it to work using an Entry widget, this is what I am aiming for (apart from the wraplength attribute needs to be changed to something that works in an Entry widget:\nent = Entry(root, width=30, wraplength=30)\nI also need to be able to make the Entry widget taller than one line, is there a way i can do that, for example making it vertically fill a frame (similarly to expand=True making it horizontally fill a frame).\nThank you!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4245,"Q_Id":54371743,"Users Score":0,"Answer":"but text can't use (show=\"\")","Q_Score":1,"Tags":"python,tkinter","A_Id":69076512,"CreationDate":"2019-01-25T19:33:00.000","Title":"wrap text in an entry widget in tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create an interactive text box in a tkinter GUI, the text box should get the text to wrap to the next line after the length of 30 characters, like it would do using the wraplength=30 attribute in a label widget. I am trying to get it to work using an Entry widget, this is what I am aiming for (apart from the wraplength attribute needs to be changed to something that works in an Entry widget:\nent = Entry(root, width=30, wraplength=30)\nI also need to be able to make the Entry widget taller than one line, is there a way i can do that, for example making it vertically fill a frame (similarly to expand=True making it horizontally fill a frame).\nThank you!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":4245,"Q_Id":54371743,"Users Score":1,"Answer":"The entry widget doesn't support wrapping. If you want to have multiple lines -- even if it's one long line that's wrapped -- you'll need to use either a Text, Label, or Message widget. Only the Text widget supports user input, the other two are strictly for display.\nAs for making the entry widget taller, you can do that with a geometry manager. For example, you can use the sticky option of grid or the fill and expand options of pack. This will make the widget taller, but the text will still just appear as a single line.","Q_Score":1,"Tags":"python,tkinter","A_Id":54372471,"CreationDate":"2019-01-25T19:33:00.000","Title":"wrap text in an entry widget in tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install tensorflow but python 3.7 does not support that, so I want to get python 3.6 instead without using anaconda.\nSo any suggestion please ?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":63369,"Q_Id":54371847,"Users Score":-1,"Answer":"This solved it for me. Run the following via anaconda prompt\n\nconda create -n py36 python=3.6\nactivate py36\nSelect py36 on Anaconda navigator and launch spyder","Q_Score":10,"Tags":"python","A_Id":65289951,"CreationDate":"2019-01-25T19:42:00.000","Title":"how can I downgrade from python 3.7 to 3.6 in windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a single time series that has multiple input features and a single output (classification). I would like to create a model that would predict the output at every step.\nMy data looks like this:\nx: [[0.4, 0.8, -1], [1, 1.6, -0.2], ....]\ny: [[1], [0], ...]\nSo when given a single feature vector, I would like my model to output 0 or 1. The feature vector is not a sequence of any kind, as this is just a straight-forward time series.\nI have the following questions:\n\nSince Keras requires data to be formatted in (batch_size, time_steps, num_features) and I have fixed num_features = 3, what should I put for batch_size and time_steps?\nWhat do I put for the value of stateful? Since my data is in a specific order in that the first event in my list came first, followed by the second and third etc., I'm assuming I put stateful = True?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":108,"Q_Id":54374608,"Users Score":0,"Answer":"I'm not sure, but your batch_size could be set automatically, time_steps is equal to number of feature sets so for [[0.4, 0.8, -1]] its 1 for [[0.4, 0.8, -1],[1, 1.6, -0.2]] its 2 etc. Try to reshape your data to (shape[0],3).","Q_Score":0,"Tags":"python,keras,lstm,recurrent-neural-network","A_Id":54374671,"CreationDate":"2019-01-26T00:38:00.000","Title":"Keras LSTM Paradigm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When using the Python PREDICT method in lightGBM with predict_contrib = TRUE, I get an array of [n_samples, n_features +1]. What does the n_feature+1 correspond to? I thought first that it could be the log odds of class 1 but the value does not correspond to the right probability.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":862,"Q_Id":54374866,"Users Score":0,"Answer":"Suppose that you are doing regression from X \u03f5 Rn to y \u03f5 R1. For a given point, x, You can view the model prediction f(x) as a linear function of the feature contributions such as : f(x) = contribution(x1) + contribution (x2) + ... + contribution(xn) + mean(y)\nThe first n columns of your array correspond to the contribution of your n features respectively and the last column is the prediction without any information, here the mean of your output y. If you sum up those n+1 values, you will obtain the prediction f(x).\nFor classification, you obtain the \"raw prediction\". Depending on the objective you selected, you will have to convert it to probability (the \"prediction\") using softmax or logit function.\nPS: Hope its clear despite my poor editing!","Q_Score":0,"Tags":"python-3.x,predict,lightgbm","A_Id":54446294,"CreationDate":"2019-01-26T01:26:00.000","Title":"Understanding \"PREDICT\" function output in python lightGBM implementation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I successfully trained the network but got this error during validation:\n\nRuntimeError: CUDA error: out of memory","AnswerCount":10,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":201166,"Q_Id":54374935,"Users Score":34,"Answer":"The error occurs because you ran out of memory on your GPU.\nOne way to solve it is to reduce the batch size until your code runs without this error.","Q_Score":55,"Tags":"python,pytorch","A_Id":54376403,"CreationDate":"2019-01-26T01:39:00.000","Title":"How to fix this strange error: \"RuntimeError: CUDA error: out of memory\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on Twitter Streaming api to get live tweets data.\nI can print that data to console. But what I want is to save the data to a file and that data shouldn't be older than 5 minutes. \nHow do I continuously roll the file that holds the data from last 5 minutes as we can do for log files.\nAt the same time the file should be accessible for reading.\nIs there any way to do that in Python? \nI haven't come across such thing where we can mention such duration for which the file can hold specific data.","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":56,"Q_Id":54376092,"Users Score":-1,"Answer":"Save the data in a file, with the actual time and check to see if the actual time is different by 5 min. Use time. Or use the sleep function and erase old data each 5 min.","Q_Score":0,"Tags":"python,file,text-files,tweepy,twitter-streaming-api","A_Id":54376116,"CreationDate":"2019-01-26T06:05:00.000","Title":"How do I create a file that doesn't contain information older than 5 minutes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use visual studio code for coding (python) and now I have to write a program with pygame for my project and I can't import pygame in visual studio code (I can import it with the python script, it just can't be imported in visual studio code).","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":65104,"Q_Id":54376745,"Users Score":0,"Answer":"Another possible solution is the you could be using VS code in restricted mode.\nmake sure you're in a trusted browser on the app","Q_Score":4,"Tags":"python,visual-studio-code,pygame","A_Id":72452905,"CreationDate":"2019-01-26T08:15:00.000","Title":"How to import pygame in visual studio code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use visual studio code for coding (python) and now I have to write a program with pygame for my project and I can't import pygame in visual studio code (I can import it with the python script, it just can't be imported in visual studio code).","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":65104,"Q_Id":54376745,"Users Score":2,"Answer":"If it works in the console when you type 'python yourscript.py' but not in vs code, you should press ctrl+shift+p and use clic on Python select interpreter to switch to the right env. if it sstill doesn't work then install the package by running 'python -m pip install pygame'","Q_Score":4,"Tags":"python,visual-studio-code,pygame","A_Id":57072821,"CreationDate":"2019-01-26T08:15:00.000","Title":"How to import pygame in visual studio code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use visual studio code for coding (python) and now I have to write a program with pygame for my project and I can't import pygame in visual studio code (I can import it with the python script, it just can't be imported in visual studio code).","AnswerCount":4,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":65104,"Q_Id":54376745,"Users Score":4,"Answer":"Open the terminal of Vscode.\nType pip install pygame or pip3 install pygame.\nImport pygame and enjoy it.","Q_Score":4,"Tags":"python,visual-studio-code,pygame","A_Id":56724870,"CreationDate":"2019-01-26T08:15:00.000","Title":"How to import pygame in visual studio code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using cv2 version 4.0.0 and python version 3.7.2.\nI am trying to subtract Background using this method cv2.createBackgroundSubtractorMOG2() and its working well.\nBut when I use cv2.createBackgroundSubtractorMOG() its not working its showing me \n\nAttributeError: module 'cv2.cv2' has no attribute\n  'createBackgroundSubtractorMOG '.\n\nI also tried cv2.BackgroundSubtractorMOG() but i got same error \n\nAttributeError: module 'cv2.cv2' has no attribute\n  'BackgroundSubtractorMOG'.\n\nand another subtraction method cv2.createBackgroundSubtractorGMG() also not working. \nI also refer other stackoverflow answers but I didn't get solution.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3478,"Q_Id":54376883,"Users Score":2,"Answer":"there are two subtraction packages in opencv. BackgroundSubtractorMOG() it's at cv2.bgsegm.BackgroundSubtractorMOG(),to use you must install opencv-contrib-python","Q_Score":1,"Tags":"python-3.x,opencv,background-subtraction","A_Id":63150254,"CreationDate":"2019-01-26T08:40:00.000","Title":"OpenCV2 createBackgroundSubtractorMOG Attribute not found","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question. I work on Windows  10.\nI done a reinstall of my installed pythons. On my PC i had Python 2.7 and Python 3.6.6. I uninstalled Python 2.7. Then, i reinstalled Python 3.6.6. \nWhen i want to write pip install numpy etc, i get this error:\n\nFatal error in launcher: Unable to create process using '\"c:\\python27\\python.exe\" ...\n\nWhen i deleted that path from system PATH, i still get that error.\npython -m pip install something works, when i type python in cmd i get python 3.6.6 promprt but my question is, can i delete taht error from windows cmd? If i cant, if this error will affect on my compiling, debugging and pythone code working?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4593,"Q_Id":54377502,"Users Score":1,"Answer":"There may be many solutions possible for that. One of the simplest is that uninstall the python from Apps & Programs. It will automatically delete all the data and path from the system. Then reinstall the python again. It might be possible that the data of python2.7 must not have been completely deleted from the system and thus throwing errors. Try this solution it'll fix everything.","Q_Score":2,"Tags":"python","A_Id":54377583,"CreationDate":"2019-01-26T10:26:00.000","Title":"Fatal error in launcher: Unable to create process using '\"c:\\python27\\python.exe\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"is there a way to get the IP of the connected client? (And if possible the port it uses). \nI tried client_socket.getsockname() but it gave me my IP address.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":54378675,"Users Score":0,"Answer":"You have to use the socket.getpeername() method.","Q_Score":1,"Tags":"python,python-2.7,sockets,python-sockets","A_Id":54965585,"CreationDate":"2019-01-26T13:09:00.000","Title":"Get IP of connected client in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a simple game in Python, using the Pyglet graphics library. I have an image, 6000x300 pixels, that I want to use as a scrolling background for the game. At the moment, I have made a sprite with the image and move it left and right depending on the player's position. The problem I have is that the sprite is glitchy: sometimes the 400 or so pixels at the start are duplicated several times along the length of it, and the motion of the sprite is sometimes jerky and sometimes smooth.\nIs this expected behavior for an image of that size? Is there a workaround? If not, can anyone suggest an better way to make a scrolling background?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":54378952,"Users Score":0,"Answer":"Well, it's a strange one. I got home and ran the program on my newer desktop (my laptop is about 8 or more years old...) with the intention of making a video to help to explain the problem, and guess what? It runs perfectly. Must be a bug with Pyglet and very old hardware...","Q_Score":0,"Tags":"python,linux,pyglet","A_Id":54380533,"CreationDate":"2019-01-26T13:45:00.000","Title":"Pyglet large sprites glitch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a sparse large matrix (linear dimension of 2*10^6) for which I want to calculate its trace.\nCalculating it brute force takes 16 seconds to access each diagonal element (hence I could do it in a YEAR!). \nI was thinking of saving it to the disk using scipy.io.mmwrite and reading it with a c++ code which should be much faster. However I cannot find any package that could help me do that.\nAny suggestions would be much appreciated!\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":476,"Q_Id":54379162,"Users Score":0,"Answer":"The solution was as simple as: np.array(Mat.diagonal()).sum()\nThanks @hpaulj !","Q_Score":1,"Tags":"python,c++,scipy","A_Id":54395217,"CreationDate":"2019-01-26T14:10:00.000","Title":"Calculating the trace of a large sparse matrix","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 folder of . py files(a package made by me) which i have uploaded into my google drive.\nI have mounted my google drive in colab but I still can not import the folder in my notebook as i do in my pc.\nI know how to upload a single .py file into google colab and import it into my code, but i have no idea about how to upload a folder of .py files and import it in notebook and this is what i need to do.\nThis is the code i used to mount drive:\n\nfrom google.colab import drive\ndrive.mount('\/content\/drive')\n!ls 'drive\/My Drive'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3290,"Q_Id":54379184,"Users Score":2,"Answer":"I found how to do it. \nafter uploading all modules and packages into the directory which my notebook file is in, I changed colab's directory from \"\/content\" to this directory and then i simply imported the modules and packages(folder of .py files) into my code","Q_Score":2,"Tags":"python,upload,google-colaboratory","A_Id":54387414,"CreationDate":"2019-01-26T14:14:00.000","Title":"importing an entire folder of .py files into google colab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed python 3.5.3 installed on my Windows machine. I check the SQLite version via the command sqlite3.sqlite_version. It is version 3.8.11. \nMy question is how can I update the SQLite version to 3.26? I wasn't sure if there was a 3rd party library or if I need to update sqlite3 library. \nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":870,"Q_Id":54382087,"Users Score":5,"Answer":"Just update the sqlite in the system by a newer version. Python will use it. It is not 3rd party. It is included in Python. I am not completely sure but I think it is a dynamically loaded library installed with Python but that you can upgrade by yourself. At least in my system different Python versions report the same sqlite3 version.","Q_Score":1,"Tags":"python,sqlite","A_Id":54383650,"CreationDate":"2019-01-26T19:44:00.000","Title":"python 3.5 update sqlite3 version","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question regarding python modules. \nFor example, I have a script which uses netaddr\/paramiko module and now I want to start the script on another linux os where I have no root access. Pip is not installed and the user has no homedir. Virtuelenv is no option. \nSo is there a possibility\/way to 'make' python modules 'portable' and add it to a folder where I can load it in my script??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":54383381,"Users Score":0,"Answer":"You could use pip install --no-install to list the dependencies of the library you need, then copy the modules \/ packages of all of these libs in your project directory, for example in an \/ext  subdirectory.","Q_Score":0,"Tags":"python","A_Id":54383505,"CreationDate":"2019-01-26T22:26:00.000","Title":"\"Standalone\" or \"Portable\" python 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":"I'm writing my own wraping for ffmpeg on Python 3.7.2 now and want to use it's \"-progress\" option to read current progress since it's highly machine-readable. The problem is \"-progress\" option of ffmpeg accepts as its parameter file names and urls only. But I don't want to create additional files not to setup the whole web-server for this purpose.\nI've google a lot about it, but all the \"progress bars for ffmpeg\" projects rely on generic stderr output of ffmpeg only. Other answers here on Stackoverflow and on Superuser are being satisfied with just \"-v quiet -stats\", since \"progress\" is not very convenient name for parameter to google exactly it's cases.\nThe best solution would be to force ffmpeg write it's \"-progress\" output to separate pipe, since there is some useful data in stderr as well regarding file being encoded and I don't want to throw it away with \"-v quiet\". Though if there is a way to redirect \"-progress\" output to stderr, it would be cool as well! Any pipe would be ok actually, I just can't figure out how to make ffmpeg write it's \"-progress\" not to file in Windows. I tried \"ffmpeg -progress stderr ...\", but it just create the file with this name.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5064,"Q_Id":54385690,"Users Score":12,"Answer":"-progress pipe:1 will write out to stdout, pipe:2 to stderr. If you aren't streaming from ffmpeg, use stdout.","Q_Score":9,"Tags":"python,windows,ffmpeg","A_Id":54386052,"CreationDate":"2019-01-27T06:38:00.000","Title":"How to redirect -progress option output of ffmpeg to stderr?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can i use paramiko after it give me this error \"paramiko\\kex_ecdh_nist.py:39: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and unco\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":288,"Q_Id":54385866,"Users Score":0,"Answer":"I had to disable gathering_facts to get past the warning. For some reason Ansible was getting stuck gathering facts.\nAfter disabling gathering facts, I still get this warning, but Ansible is able to continue execution.\nyaml file \ngather_facts: no","Q_Score":2,"Tags":"python-3.x","A_Id":56402605,"CreationDate":"2019-01-27T07:09:00.000","Title":"How can i use paramiko after it give me this error encode_point has been deprecated on EllipticCurvePublicNumbers","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 built a small program that listens to a port on my laptop and an other program on my phone that connects to that port on my laptop. Now this all works fine but i was wondering if that same module could be used with external ip adresses. If it doesn't work with external ip's, is there a preinstalled module that can work with external ip's?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":54386753,"Users Score":1,"Answer":"If you forward that port in your network bridge (probably your all-in-one router) then yes! Simply listen on IPv4 address 0.0.0.0 or IPv6 address :: (maybe 0:0:0:0:0:0:0:0%0) to ensure that you're listening on all available IP addresses, instead of just localhost, and you're good to go.","Q_Score":2,"Tags":"python-3.x,ip-address","A_Id":54387231,"CreationDate":"2019-01-27T09:31:00.000","Title":"Can I use the python 'socket' module for listening on my external ip? if no, is there a preinstalled module which can?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on classification of brain tumors. The dataset is comprised of brain images from various angles, with a border and mask of the tumor position. I have cropped the rectangle that contains the tumor, as the other parts of the image are irrelevant and vary due to the different angles from which the image is taken. Now I am left with a series of images of the tumor, each belonging to 1 of 3 possible cases of tumor. But to train this data for classification, I need to have the 2d image array in a uniform shape I believe.\nPossible approaches:\n1) Crop each image to a fixed size (say 100x100). But this would result in loss of data and also depending on position of the tumor in image, I could be facing uneven crops due to reaching the edge of the image.\n2) Pad the image to a fixed shape, bigger than the biggest cropped image shape (say 350x350). But again this would introduce noise in the data I suppose, and I'm not sure how can I pad the image uniformly across all 4 sides of the rectangle.\nAs these don't seem viable, I'm looking for other solutions to tackle this problem.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":236,"Q_Id":54387850,"Users Score":1,"Answer":"The common approach is to crop the tumor on each image. You will obtain different tumor image size. Then rescale the tumor images to the smallest one. Choose wisely the resampling technic for the rescale depending on the algorithm you will use for classification. The fastest one would be nearest neighborhood resampling, a smoother one would be linear interpolation, the ultimate one can be spline interpolation.","Q_Score":1,"Tags":"python,image-processing,machine-learning,classification,multiclass-classification","A_Id":54387971,"CreationDate":"2019-01-27T11:55:00.000","Title":"How to approach variable image sizes for Image Classification?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The situation:\nI am working on a senior design project that involves calculating the source of a signal by correlating audio from many devices that are all on the same WIFI network. The devices exchange information using REST apis.\nThe architecture is master slave, where the master unit will request audio from all of the slave units. Right now, the slave units need the IP of the master unit. Then they say 'hello' to the master unit who stores their IP, location etc in a list.\nWhat I think I want:\nI would like the slave units to have some way of automatically discover the master unit's IP. I don't think I really care about security. What is the best way to do this?\nIs there an idiomatic way to do this?\nI think I might just not have the correct words to google\nSolutions I have considered:\n1. Assign static IP to all (or just master unit).\n   - not ideal because it would only work on one router\n   - not slick\n\nMaster unit listens on hard-coded port and minions post to broadcast IP.  \n\n\nMay not work on all routers \ndoesn't seem elegant","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":54391482,"Users Score":0,"Answer":"Master unit listens on hard-coded port and minions post to broadcast IP.\n\n\nYes, using a well known port to rendezvous on is the standard way to solve this problem.\nI would turn your approach around a bit. There's more minions than masters, so master should do the broadcasting. A minion might send one (or a handful) of broadcasts upon power-on, to encourage an immediate reply from master. But as hours and days go by, the master should be the one primarily responsible for keeping the population in sync.\nA minion should remember IP of most-recent-master, and try unicasting to that upon startup.\nConsider using a packet format along these lines: {magic_number, version, start_time, num_minions, optional_list_of_minions}\nThe list of minions would include {ip_addr, time_of_last_transaction}, and would be empty if the list no longer fits within some limited size UDP packet. Minions could detect master reboot by noticing that start_time changed, and would re-connect soon after reboot. Do take care to randomly jitter your delay timers, so we won't see a thundering herd of minions.","Q_Score":0,"Tags":"python-3.x,networking,raspbian","A_Id":54392530,"CreationDate":"2019-01-27T18:28:00.000","Title":"Automatic device discovery (python or anything I can run on raspbian)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Doing a production on EC2, was wondering if it is advisable to start by creating a new user and granting it sudo privileges, since not many people do but I have seen it done","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":54392650,"Users Score":0,"Answer":"Not strictly needed. However, since the username is common and known to everyone, chances are high that someone will be able to access the instance if he comes under the allowed block of IPs and has the pem\/ppk file. May be create a password and disable SSH login for ubuntu, or create a new user and setup keybased\/password_based login for that user, just to be on the safer side.","Q_Score":0,"Tags":"python,amazon-ec2,sudo,devops,production","A_Id":54398348,"CreationDate":"2019-01-27T20:39:00.000","Title":"python production, recommended to create a new user and grant it sudo priviledges to start with?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Doing a production on EC2, was wondering if it is advisable to start by creating a new user and granting it sudo privileges, since not many people do but I have seen it done","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":54392650,"Users Score":0,"Answer":"If the alternative would be logging in as root directly, the answer is yes.\nIt's best to work as a non-root user, with occasional use of sudo.  Doing everyday work as the root user is unsafe.","Q_Score":0,"Tags":"python,amazon-ec2,sudo,devops,production","A_Id":54392745,"CreationDate":"2019-01-27T20:39:00.000","Title":"python production, recommended to create a new user and grant it sudo priviledges to start with?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am using Django 2.0.7, Python 3.7 and Oracle 11g. I cannot change these configurations. Whenever I am trying to migrate my models, I always get the error, 'Missing ALWAYS' which is an error associated with Identity columns.\nI know that Identity columns were introduced from oracle 12. Is there a way to overcome this issue with the version requirements I have?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":107,"Q_Id":54393556,"Users Score":0,"Answer":"I resolved the issue by downgrading django to 1.11. Identity column is not required in versions prior to 2.0.","Q_Score":0,"Tags":"python,django,oracle,oracle11g,cx-oracle","A_Id":54411219,"CreationDate":"2019-01-27T22:43:00.000","Title":"How to solve Identity column missing Always error for oracle 11g, django 2.0.7?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"After I raise the Scrapy exception CloseSpider, I'd like a graceful shutdown with Scrapy executing my pipeline procedures before exiting. \nDoes it do this naturally? Or does it immediately terminate all scripts?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":54394282,"Users Score":0,"Answer":"Because of the time it takes to shut down all the items queued - I thought the implementation was failing. It does go through all the normal close down processes, including finishing the pipeline procedures of the items already scraped.","Q_Score":0,"Tags":"python,python-3.x,scrapy,pipeline","A_Id":54951442,"CreationDate":"2019-01-28T00:47:00.000","Title":"Does the Scrapy CloseSpider exception still redirect to a user-defined pipeline shutdown procedure?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"As a pet project I have been writing my own ORM to help me better understand the decisions made by production grade ORMs like Peewee or the more complex sqlalchemy.\nIn line with my titles question, is it better to spawn one cursor and reuse it for multiple SQL executions or spawn a new cursor for each transaction?\nI've already guessed about avoid state issues (transactions with no commit) but is there another reason why it would be better to have one cursor for each operation (insert, update, select, delete, or create)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1295,"Q_Id":54395773,"Users Score":2,"Answer":"Have you profiled and found that the creation of cursors is a significant source of overhead?\nCursors are a DB-API 2.0 artifact, not necessarily an actual \"thing\" that exists. They are designed to provide a common interface for executing queries and handling results\/iteration. How they are implemented under-the-hood is up to the database driver. If you're aiming to support DB-API 2.0 compatible drivers, I suggest just use the cursor() method to create a cursor for every query execution. I would recommend to NEVER have a singleton or shared cursor.\nIn SQLite, for example, a cursor is essentially a wrapper around a sqlite3_stmt object, as there's no such thing as a \"sqlite3_cursor\". The stdlib sqlite3 driver maintains an internal cache of sqlite3_stmt objects to avoid the cost of compiling queries that are frequently used.","Q_Score":3,"Tags":"python,orm,sqlite","A_Id":54410755,"CreationDate":"2019-01-28T05:00:00.000","Title":"What are the side-effects of reusing a sqlite3 cursor?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've added a Databricks Notebook to a Datafactory pipeline. If the Python script inside the notebook throws an exception, this exception will not be mentioned by the pipeline. I know there is a runPageUrl where I can see the results. But I want the pipeline to know if an error occurred in the Python script. Is there a way to pass exception information to the pipeline?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2147,"Q_Id":54400579,"Users Score":0,"Answer":"Found it. I just had to add assertion to the exceptions. Next step is to find out how to get the error message in the outcome of the activity in the pipeline...","Q_Score":3,"Tags":"python,azure,exception,azure-data-factory-2,azure-databricks","A_Id":54420548,"CreationDate":"2019-01-28T11:04:00.000","Title":"Get exceptions from Databricks Notebook in Azure Datafactory pipeline","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a python list A and a python list B with words as list elements. I need to check how often the list elements from list B are contained in list A. Is there a python method or how can I implement this efficient?\nThe python intersection method only tells me that a list element from list B occurs in list A, but not how often.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":54404263,"Users Score":0,"Answer":"You could convert list B to a set, so that checking if the element is in B is faster.\nThen create a dictionary to count the amount of times that the element is in A if the element is also in the set of B\nAs mentioned in the comments collections.Counter does the \"heavy lifting\" for you","Q_Score":0,"Tags":"python,performance","A_Id":54404522,"CreationDate":"2019-01-28T14:38:00.000","Title":"How can I check how often all list elements from a list B occur in a list A?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"like [198]\nhow can I split it to [1,9,8]?\nplus I cant show my code that I did because I didn't do one am asking this out for my own benefit or knowledge.","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":54404289,"Users Score":0,"Answer":"Try this code.It is working.\nprint(list(map(int,str([198][0]))))","Q_Score":0,"Tags":"python,list,split","A_Id":54458385,"CreationDate":"2019-01-28T14:40:00.000","Title":"How can i split a number that is inside a list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say for example I have a multi-column dataframe. I want to arrange my data by sorting column a ascending first, then by column b ascending also.\nI am able to achieve this by the ff. code: df.sort_values(['b','a']). Note the reversed order of the arguments.\nMy question is, why doesn't df.sort_values('a').sort_values('b') work?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":54405063,"Users Score":2,"Answer":"When you use .sort_values(['a', 'b']) you are first sorting the dataframe by the column a, and then within those sortings, sorting by b. Think of it almost as grouping by the first sort, then sorting within those groupings. If there was a c, it would sort the c column within the a b groups.\nIf you do .sort_values('a').sort_values('b') you are sorting the dataframe by a and then taking that returned dataframe, and \"starting over\" by sorting it by b basically destroying the previous sorting of a. using ['a', 'b'] keeps each of the sorts and sorts within.","Q_Score":0,"Tags":"python,pandas,data-analysis","A_Id":54405935,"CreationDate":"2019-01-28T15:21:00.000","Title":"Why can't I apply sort_values to a dataframe more than once?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know to host my Django projects in pythonanywhere or something else. But, I need to know is that possible to host a Django project in Firebase Hosting Services.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1798,"Q_Id":54408058,"Users Score":8,"Answer":"Firebase Hosting only supports static content.  It does not give you a way to run any backend code.  You can use Firebase Hosting to proxy some requests to a Cloud Functions backend, but Cloud Functions provides its own way of handling HTTP requests.","Q_Score":3,"Tags":"django,python-3.x,firebase,django-rest-framework,hosting","A_Id":54409046,"CreationDate":"2019-01-28T18:19:00.000","Title":"Can a Django project be hosted in Firebase? If yes, give me an idea","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm relatively inexperienced with Python and seem to have gotten confused along the way with trying to upgrade from Python 2.7 to 3.7 on my MacBook Pro with OS 10.10.5 (14F27). I was reluctant to upgrade for a while because I had heard there were some issues but it seems that Python3 is the way to go. \nI installed python 3.7.2 for OS 10.9 and was able to get Sublime to use Python3, but when I am in the terminal and try to run python, it looks to the 2.7 bin. Aster I installed some libraries using pip that apparently installed in the 2.7 bin I believe. \nAt this point I'm very confused and any literature I've read (which I've read quite a bit) generally leads me into a rabbit hole with other things that are wrong, or not up to date, or that I should have but don't. \nAt this point, is there any way I can just get rid of my Python altogether and reinstall fresh 3.7.2? \nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":20,"Q_Id":54409656,"Users Score":1,"Answer":"You can't get rid of the default python 2 on Mac because it is required for some internals. Type python3 in the terminal to use Python 3. Use pip3 to use pip with python3.\ntype which python3 to see the path of your install.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,installation,sublimetext3","A_Id":54409675,"CreationDate":"2019-01-28T20:17:00.000","Title":"Conflicting Pythons on Mac and in Sublime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"\"Could not find the version that satisfies the requirement virtualenv ( from versions: )\nNo matching distribution found for virtualenv\" is the error message when I try to install virtualenv on my  windows 10.\nI have Googled it and followed several guide but no good result.\nI have uninstalled and installed several lower versions of python, yet the same story.\nI have been stocked for 6 days now trying to install django via pip.\nI don't know what to do again.\nAny true solution to my problem will be appreciated.","AnswerCount":4,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":13909,"Q_Id":54410591,"Users Score":-2,"Answer":"Please correct your spelling of pip install virtualenvwrapper-win.\nI have also this problem with miss-spelling.","Q_Score":3,"Tags":"python,virtualenv","A_Id":67501331,"CreationDate":"2019-01-28T21:33:00.000","Title":"No matching distribution for virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am fairly new to python (and Stackflow) so apologies if this is a repost. I am currently run Pycharm on my iMac (with Mac OS Mojave), python install from Anaconda. \nI am having some issues with Matplotlib as everytime I plot a graph I don't see anything. The backend currently uses TkAgg. I googled the issue and came across many links and tried to change the backend in matplotlibrc, but that just gave me errors. \nIt is Mojave specific problem? I have another Mac with High Sierra (which uses MacOSX in the backend) and Matplotlib runs fine on it. I tried changing the backend on my iMac to MacOSX but that doesn't work. Any help will be really appreciated as I have already spend more than 3-4 hours (in vain!) to fix the problem\nIf I need to change the backend in matplotlibrc, could you advise what should I be using?\nthanks,\nPK","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1210,"Q_Id":54410776,"Users Score":1,"Answer":"if you use virtualenv in Mojave, you have to install matplotliv (v1.3.1) at virtualenv. ** NOT VERSION 2.2.3 **. so, try the below command (btw, in your code, 'TkAgg' is needless):\n$pip install --no-cache-dir matplotlib==1.3.1\neverything will be fine.","Q_Score":1,"Tags":"python-3.x,matplotlib,backend","A_Id":54614230,"CreationDate":"2019-01-28T21:49:00.000","Title":"Mac OS (Mojave) - Pycharm backend : TkAgg not working, graphs are blank","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a column of data that is in the following format:\nbla bla bla, bla bla bla, bla bla bla, bla bla bla bla bla bla, 23\/09\/2012\nIs there an easy way to extract the date at the end of the string from all rows? It is in the same DD\/MM\/YYYY format every time.\nI could split on the last , but it would be good if I could specify that I want the date in case of errors in the data.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":96,"Q_Id":54411374,"Users Score":1,"Answer":"row.split(\", \")[-1] is the string 23\/09\/2012, now you can use the date module to extract that into a Date object. And use try\/except for error handling.","Q_Score":0,"Tags":"python,string,pandas,datetime,dataframe","A_Id":54411400,"CreationDate":"2019-01-28T22:44:00.000","Title":"Extracting a date at the end of a pandas dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install some packages globally on my Mac. But I'm not able to install them via npm or pip, because I'll always get the message that the packages does not exist. For Python, I solved this by always using a virtualenv. But now I'm trying to install the @vue\/cli via npm, but I'm not able to access it. The commands are working fine, but I'm just not able to access it. I think it has something to do with my $PATH, but I don't know how to fix that.\nIf I look in my Finder, I can find the @vue folder in \/users\/...\/node_modules\/. Does someone know how I can access this folder with the vue command in Terminal?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":197,"Q_Id":54416057,"Users Score":1,"Answer":"If it's a PATH problem:\n1) Open up Terminal.\n2) Run the following command:\nsudo nano \/etc\/paths\n3) Enter your password, when prompted.\n4) Check if the correct paths exist in the file or not.\n5) Fix, if needed\n6) Hit Control-X to quit.\n7) Enter \u201cY\u201d to save the modified buffer.\nEverything, should work fine now. If it doesn't try re-installing NPM\/PIP.","Q_Score":1,"Tags":"python,node.js,npm,pip","A_Id":54418733,"CreationDate":"2019-01-29T07:42:00.000","Title":"Can't install packages via pip or npm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I develop a software that is for teachers to test their students. The main feature of the software is the cheat prevention it has. I want to achieve that by locking the option to exit the window in any way except a custom exit button in the top of the screen (already developed it and it's functionality). Is there a way to lock the option to exit a window, and make it always on the top?\nI want to lock the option to press the windows button, the ctrl-alt-delete buttons, the ctrl-shift-esc, the f4 ext... How do I do that? using python and wxpython for \nGUI","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":54418478,"Users Score":0,"Answer":"You can catch wx.EVT_CLOSE but you can't catch OS-level keyboard shortcuts, like CTRL+ALT+DELETE. \nwxPython can only catch keyboard shortcuts that aren't already mapped to the OS. I would focus on catching the close event and just vetoing it as that will prevent the user from closing the application. It won't protect you from the user restarting the OS, but that's about as good as you can do without locking down the user's desktop.","Q_Score":0,"Tags":"python,windows,user-interface,wxpython","A_Id":54425704,"CreationDate":"2019-01-29T10:05:00.000","Title":"How to make a window unexitable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a code in python using youtube data API v3 where I am listing playlists created by a user. I have followed the code suggested by youtube API it runs well in local machine but when I deployed the same code on the server, It runs till authentication but after OAuth, it displays Internal server error in the browser instead of the result.\nis there any major changes that I am missing. Please help me with the issue.\nMy code in not running after oauth2callback function runs.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":54418572,"Users Score":1,"Answer":"I solved the error,\nI was deploying without a secure connection and that was raising an error. also redirect URL must be 'https' that was another problem.","Q_Score":0,"Tags":"python,google-oauth,url-redirection,youtube-data-api,google-authentication","A_Id":54624602,"CreationDate":"2019-01-29T10:11:00.000","Title":"Internal server error after I try to host code on server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a logic analyser project that records several hundred million 16bit values (~100-500 million) and I need to display anything from a few hundred samples to the entire capture as the user zooms. \nWhen you zoom out the whole system gets a huge performance hit as it's loading a massive chunk from the file.\nI just though this morning that it would be more efficient to \"stride\" through the file at the users screen resolution. You can't physically display anything between pixels anyways. This doesn't solve the massive file size hit in memory though.\nIs there away I can take a huge data set and stream chunk it down efficiently?\nI was thinking streaming from start to start + view size by horiz resolution. This makes a very choppy zoom though.\nProgram uses python but I am open to calling something in c if it already exists.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":54420329,"Users Score":0,"Answer":"Well, I don't know if this is actually question on programming or design overall.\nFor \"zooming\" problem with vizualizations I suggest:\n\nHave pre-computed\/cached version for some zoom levels. Ideally, gradation should be calculated based on user behaviour.\nWhen user zooms-in, you simultaneously\n\n\ncalculate \"proper\" data or load pre-computed aggregated data of deeper zoom layer and crop it by your view frame\ncheat by rendering low-res data from previous layer or smooth it by some approximation (but make sure to somehow tell user that data is not finalized)\n\n\nAside of it, think if you can optimize the way you store data. Trees may make your life way easier, both for partial disk read\/search and for storing aggregated data.","Q_Score":0,"Tags":"python,large-data,large-files,large-data-volumes","A_Id":54420863,"CreationDate":"2019-01-29T11:45:00.000","Title":"Displaying very large data sets more efficently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a logic analyser project that records several hundred million 16bit values (~100-500 million) and I need to display anything from a few hundred samples to the entire capture as the user zooms. \nWhen you zoom out the whole system gets a huge performance hit as it's loading a massive chunk from the file.\nI just though this morning that it would be more efficient to \"stride\" through the file at the users screen resolution. You can't physically display anything between pixels anyways. This doesn't solve the massive file size hit in memory though.\nIs there away I can take a huge data set and stream chunk it down efficiently?\nI was thinking streaming from start to start + view size by horiz resolution. This makes a very choppy zoom though.\nProgram uses python but I am open to calling something in c if it already exists.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":54420329,"Users Score":0,"Answer":"In my opinion, there is no point to display even a few hundred samples unless they form some kind of image\/shape. I guess one can look at hundred numbers if they are properly structured (colored). Several hundred - doubt it - here you replace actual data with some visualization (plots, charts, maps, ...).\nTo approach the problem you may define some rule to stop displaying actual data at all. For instance, if digit height becomes less than, say, 10 pixels you display some kind of message selected numbers are from rows 200...300, columns 400..500 or some graphical alterantive with corner coordinates and amount of numbers.","Q_Score":0,"Tags":"python,large-data,large-files,large-data-volumes","A_Id":54420968,"CreationDate":"2019-01-29T11:45:00.000","Title":"Displaying very large data sets more efficently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to automate creating of a powerpoint ppt via linking template charts to some Excel files. Updating the excel file values changes the powerpoint slides automatically. I have created my powerpoint template and linked charts to sample excel files data.\nI want to send the folder with the powerpoint and excel files to someone else. But this will break the link to excel files due to change in the path. (As path is not relative). I can edit the paths manually by going under the \"edit links to files\" option under File Menu but this is tedious as charts are numerous with multiple files.\nI want to update the same via Python code using the Python-Pptx package. \nPlease help!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":982,"Q_Id":54420740,"Users Score":1,"Answer":"There's no API support for this in the current version of python-pptx.\nYou would need to modify the underlying XML directly, perhaps using python-pptx internals as a starting point and using lxml calls on the appropriate element objects. If you search on \"python-pptx workaround function\" you will find some examples.\nAnother thing to consider is modifying the XML by cruder but still possibly effective means by accessing the XML files in the .pptx package directly (the .pptx file is a Zip archive of largely XML files) and using regular expressions or perhaps a command line tool like sed or awk to do simple text substitution.\nEither way you're going to need to want it pretty badly, depending on your Python skill level. You'll also of course need to discover just which strings in which parts of the XML are the ones that need changing. opc-diag can be helpful for that, but it's a bit of detective work even with the best tools.","Q_Score":2,"Tags":"python-3.x,powerpoint,python-pptx","A_Id":54432815,"CreationDate":"2019-01-29T12:08:00.000","Title":"Update linked excel path in PowerPoint via Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Scrapy has several points\/places where allowed processing scraped data: spider, items and spider middlewares. But I don't understand where I should do it right. I can process some scraped data in all these places. Could you explain to me differences between them in detail?\nFor example: downloader middleware returns some data to the spider (number, short string, url, a lot of HTML, list and other). And what and where i should do with them? I understand what to do, but is not clear where to do it...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":347,"Q_Id":54421455,"Users Score":0,"Answer":"I will try to explain in order\nSpider is the one where you decide which URLs to make requests to\nDownloadMiddleware has a process_request method which is called before a request to URL is made, and it has process_response method which is called once response from that URL is received\nPipeline is the thing where data is sent when you yield a dictionary from your Spider","Q_Score":2,"Tags":"python,scrapy,scrapy-spider,scrapy-pipeline","A_Id":54435005,"CreationDate":"2019-01-29T12:47:00.000","Title":"In which file\/place should Scrapy process the data?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to remotely connect to a MongoDB database but don't want to store the password for the database in plaintext in the code. What's a good method for encrypting\/decrypting the password so it's not available to anyone with the source code? The source code will be on GitHub.\nI'm working with Python and PyMongo for connecting to the database. The database has authentication enabled in the mongod.conf file. The database is hosted on a Ubunutu 18.04 instance running in AWS.\nIt would also be nice to have the IP address of the server encrypted also as i've had security issues before with people accessing the database due to the code being available on GitHub and then presumably scraped by bots. \nMy current URI looks like this \nURI = \"mongo serverip --username mongo --authenticationDatabase admin -p\"\nI would like the IP address and password to be encrypted in some way so that the password and IP aren't publicly available in the source code.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1301,"Q_Id":54422176,"Users Score":1,"Answer":"There is only and and simple way:\nIf you don't want the password and the server name to be included in your public repository don't write it into a file that is pushed into that repository. \nOne way to do so would be to create a config file for secret data and add it to the .gitignore file. At run-time open the config file, read the secret data from it and use it in your script.\nAnother way would be to provide the secret data (password an server name) as command line parameters to your script. \nAny other way that \"encrypts\" (obfuscates) the password is insecure as long as the repository contains also the obvious or hidden key. This can be decoded with a little effort.","Q_Score":2,"Tags":"python,mongodb,encryption,pymongo,password-protection","A_Id":54428514,"CreationDate":"2019-01-29T13:28:00.000","Title":"Connecting remotely to a MongoDB database without storing password in plaintext","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In odoo, I'd like to set a default path when upload a binary fields, for example when I upload a file the path should be always : \"\/home\/user1\/Documents\".\nBest regards","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":201,"Q_Id":54423259,"Users Score":0,"Answer":"To fix your problem, please try to set data_dir (like data_dir = \/path\/you\/want) in odoo-server.conf file. Or, you can set odoorc.conf file in home folder.","Q_Score":0,"Tags":"javascript,python-3.x,odoo-11","A_Id":54423524,"CreationDate":"2019-01-29T14:29:00.000","Title":"Set Default path for binary field","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to code in pycharm in debug mode and as I am trying to work out a problem I am typing in the file I am working in.  I am referencing current code in the debug console so I need that to stay.  Unfortunately once I start typing code, flask reloads and I lose my debug console.\n Is there any way to prevent flask from reloading?\nIf I want it to reload I will restart the app manually.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1613,"Q_Id":54424071,"Users Score":6,"Answer":"Check if you have app.run(use_reloader=True). Even if not, put this param and make it False.","Q_Score":5,"Tags":"python,python-3.x,flask,pycharm","A_Id":54424183,"CreationDate":"2019-01-29T15:11:00.000","Title":"prevent flask reload on change","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Consider you have the following code:\nos.path.abspath(os.path.join('..\/..\/', __file__))\nI am quite puzzled because currently, it is returning me the same path such in  __file__ path.  \nAny idea why I don't get two levels up of the __file__ path?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":525,"Q_Id":54425001,"Users Score":2,"Answer":"From the documentation (emphasis mine):\n\nos.path.join(path, *paths)\nJoin one or more path components\n  intelligently. The return value is the concatenation of path and any\n  members of *paths with exactly one directory separator (os.sep)\n  following each non-empty part except the last, meaning that the result\n  will only end in a separator if the last part is empty. If a component\n  is an absolute path, all previous components are thrown away and\n  joining continues from the absolute path component.\n\n__file__ is an absolute path, so join ignores the preceding ..\/..\/.","Q_Score":0,"Tags":"python,python-3.x","A_Id":54425105,"CreationDate":"2019-01-29T16:00:00.000","Title":"os.path.join for getting up level paths","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Consider you have the following code:\nos.path.abspath(os.path.join('..\/..\/', __file__))\nI am quite puzzled because currently, it is returning me the same path such in  __file__ path.  \nAny idea why I don't get two levels up of the __file__ path?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":525,"Q_Id":54425001,"Users Score":0,"Answer":"After some more trial and error I found the best solution I think:\nos.path.abspath(os.path.join(__file__, '..\/..\/'))\nWorks like a charm","Q_Score":0,"Tags":"python,python-3.x","A_Id":54425528,"CreationDate":"2019-01-29T16:00:00.000","Title":"os.path.join for getting up level paths","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My goal is to disable the downloading of csv data from my JupyterHub environment. Is there any way to do this?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3699,"Q_Id":54425431,"Users Score":0,"Answer":"I have achieved this by putting Jupyter Hub behind ALB (Application load balancer), AWS and have a rule that basically routes every request with path \"\/files\" to a 503 error page. This can even be achieved using nginx as well. Just to bear that in mind, the download request path is \"\/files\".","Q_Score":4,"Tags":"python,security,jupyter","A_Id":61452667,"CreationDate":"2019-01-29T16:22:00.000","Title":"Disabling Downloads on Jupyter Notebooks","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In PyCharm (I assume other IDE's as well), when I press \"run\" in the taskbar, there are two options:\n\nRun (Shift f10)\nRun... (Alt Shift f10)\n\nWhat is the difference between these two? I could not find this online.\nps. Is this the correct stackexchange site for this question? I didn't know which one fit best.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":54429351,"Users Score":0,"Answer":"In IntelliJ-based IDEs (and PyCharm is one of them):\n\nRun will run the last run command you executed successfully, be this an invocation of main or a test, or whatever PyCharm executed on your behalf.\nRun... will allow you to select a previously run command or previously configured command to run (see Edit Configurations) without it necessarily being the last thing you ran.\n\nNote that this is distinct and separate from debugging.  Both debug commands have the same convention as the Run commands, and both do effectively the same thing with the difference in being that the debugger will be attached in a debug context.","Q_Score":0,"Tags":"python","A_Id":54429395,"CreationDate":"2019-01-27T07:13:00.000","Title":"Difference between \"Run\" and \"Run...\" in IDE's?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hay fellow programmers, \nI'm new to programming and was wondering if someone could help clear something up for me? I'm not sure if it's because of the way it's written or if it is simply a real, but contradictory way of doing something. \nI'm currently learning Python from the book 'Learn Python in One Day' and their explanation of list slicing has confused me. At the beginning, they state individual indexes always start from zero, but in a later example they seem to be using '1' as the starting point(?) and ending at index 5 - 1? \nThe example they're using for below is: userAge = [21, 22, 23, 24, 25]\nAt the beginning, in the extract below, they explain that the index for 21 = 0, the index for 22 = 1, 23 = 2, 24 = 3, and 25 = 4.\nBut when they get to the bottom of the extract they are talking about a 5th index (despite there not being one in the example above)...\nHere's the extract from the book. I've highlighted the bits that have confusticated me:\n\"Individual values in the list are accessible by their indexes, and indexes always start from ZERO, not 1. This is a common practice in almost all programming languages, such as C and Java. Hence the first value has an index of 0, the next has an index of 1 and so forth. For instance, userAge[0] = 21, userAge[1] = 22. \nAlternatively, you can access the values of a list from the back. The last item in the list has an index of -1, the second last has an index of -2 and so forth. Hence, userAge[-1] = 25, userAge[-2] = 24. \nYou can assign a list, or part of it, to a variable. If you write userAge2 = userAge, the variable userAge2 becomes [21, 22, 23, 24, 25]. \nIf you write userAge3 = userAge[2:4], you are assigning items with index 2 to index 4-1 from the list userAge to the list userAge3. In other words, userAge3 = [23, 24]. \nThe notation 2:4 is known as a slice. Whenever we use the slice notation in Python, the item at the start index is always included, but the item at the end is always excluded. Hence the notation 2:4 refers to items from index 2 to index 4-1 (i.e. index 3), which is why userAge3 = [23, 24] and not [23, 24, 25]. \nThe slice notation includes a third number known as the stepper. If we write userAge4 = userAge[1:5:2], we will get a sub list consisting of every second number from index 1 to index 5-1 because the stepper is 2. Hence, userAge4 = [22, 24]. \nIn addition, slice notations have useful defaults. The default for the first number is zero, and the default for the second number is size of the list being sliced. For instance, userAge[ :4] gives you values from index 0 to index 4-1 while userAge[1: ] gives you values from index 1 to index 5-1 (since the size of userAge is 5, i.e. userAge has 5 items).\" \nI'm not sure where they are getting the '5 - 1' if the original example had only index 0 - 4 (despite that meaning there are five items in the list). Is this a \"rule change\" or have they changed the index numbers from 0 to 4, to 1 to 5? I know the '5 - 1' means you would go back to index 4 due to the \"end exclusive\" they mention above, but don't you need the item there before you can minus it? In the original example, there is no 5th index (though there are 5 items on the list)...\nNeedless to say, I am very confused! Haha.\nThanks in advance for your help!\nJane. x","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":980,"Q_Id":54429706,"Users Score":1,"Answer":"Well, there's quite a lot of misleading explanations in this extract.\nRegarding default values for slicing \u2013 forget the indexes, in \"human\" interpretation:\n\ndata[x:] \u2013 slice starting from index x all the way till the end\ndata[:x] \u2013 slice starting from the very beginning and up to x-th element\n\nReason reason they're telling about 5 - 1 is because second value for slicing is exclusive, i.e. to explicitly slice till the end of array of length N, you're writing [:N], but last element will have index N-1 \u2013 exactly because indexing starts at 0, but element count starts from 1.","Q_Score":0,"Tags":"python,list,slice,notation","A_Id":54429876,"CreationDate":"2019-01-29T21:16:00.000","Title":"Learn Python in One Day - list slice notation confusion specifically from the book","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hay fellow programmers, \nI'm new to programming and was wondering if someone could help clear something up for me? I'm not sure if it's because of the way it's written or if it is simply a real, but contradictory way of doing something. \nI'm currently learning Python from the book 'Learn Python in One Day' and their explanation of list slicing has confused me. At the beginning, they state individual indexes always start from zero, but in a later example they seem to be using '1' as the starting point(?) and ending at index 5 - 1? \nThe example they're using for below is: userAge = [21, 22, 23, 24, 25]\nAt the beginning, in the extract below, they explain that the index for 21 = 0, the index for 22 = 1, 23 = 2, 24 = 3, and 25 = 4.\nBut when they get to the bottom of the extract they are talking about a 5th index (despite there not being one in the example above)...\nHere's the extract from the book. I've highlighted the bits that have confusticated me:\n\"Individual values in the list are accessible by their indexes, and indexes always start from ZERO, not 1. This is a common practice in almost all programming languages, such as C and Java. Hence the first value has an index of 0, the next has an index of 1 and so forth. For instance, userAge[0] = 21, userAge[1] = 22. \nAlternatively, you can access the values of a list from the back. The last item in the list has an index of -1, the second last has an index of -2 and so forth. Hence, userAge[-1] = 25, userAge[-2] = 24. \nYou can assign a list, or part of it, to a variable. If you write userAge2 = userAge, the variable userAge2 becomes [21, 22, 23, 24, 25]. \nIf you write userAge3 = userAge[2:4], you are assigning items with index 2 to index 4-1 from the list userAge to the list userAge3. In other words, userAge3 = [23, 24]. \nThe notation 2:4 is known as a slice. Whenever we use the slice notation in Python, the item at the start index is always included, but the item at the end is always excluded. Hence the notation 2:4 refers to items from index 2 to index 4-1 (i.e. index 3), which is why userAge3 = [23, 24] and not [23, 24, 25]. \nThe slice notation includes a third number known as the stepper. If we write userAge4 = userAge[1:5:2], we will get a sub list consisting of every second number from index 1 to index 5-1 because the stepper is 2. Hence, userAge4 = [22, 24]. \nIn addition, slice notations have useful defaults. The default for the first number is zero, and the default for the second number is size of the list being sliced. For instance, userAge[ :4] gives you values from index 0 to index 4-1 while userAge[1: ] gives you values from index 1 to index 5-1 (since the size of userAge is 5, i.e. userAge has 5 items).\" \nI'm not sure where they are getting the '5 - 1' if the original example had only index 0 - 4 (despite that meaning there are five items in the list). Is this a \"rule change\" or have they changed the index numbers from 0 to 4, to 1 to 5? I know the '5 - 1' means you would go back to index 4 due to the \"end exclusive\" they mention above, but don't you need the item there before you can minus it? In the original example, there is no 5th index (though there are 5 items on the list)...\nNeedless to say, I am very confused! Haha.\nThanks in advance for your help!\nJane. x","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":980,"Q_Id":54429706,"Users Score":0,"Answer":"When slicing userAge[1:], you get everything from the 2nd element all the way to the last one.\nuserAge[1:] = [22, 23, 24, 25]","Q_Score":0,"Tags":"python,list,slice,notation","A_Id":54429921,"CreationDate":"2019-01-29T21:16:00.000","Title":"Learn Python in One Day - list slice notation confusion specifically from the book","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get the MessageError: RangeError: Maximum call stack size exceeded when I try to upload a json file and I assume the problem is the size.\nI'm trying to upload a 187Kb json file on Google Colaboratory using the function files.upload(), but it gives me the error \"MessageError: RangeError: Maximum call stack size exceeded.\" When I try to upload manually on the sidebar, it just keeps loading endlessly. Is the another way to upload this file?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5718,"Q_Id":54430763,"Users Score":0,"Answer":"What I did in response to this error message since I did not want it to count against my Google Drive quota is I uploaded the file in the left pane (labeled \"Files\") of the Google Colab notebook.  The drawback to this is that the file will be gone when the notebook is recycled, however it does get the job avoiding both upload and Google Drive caps.","Q_Score":2,"Tags":"python,google-colaboratory","A_Id":60836386,"CreationDate":"2019-01-29T22:46:00.000","Title":"Google Colaboratory - Maximum call stack size exceeded","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to write a python script which will run in AWS Lambda, back up a PostgreSQL database table which is hosted in Amazon RDS, then dump a resulting .bak file or similar to S3. \nI'm able to connect to the database and make changes to it, but I'm not quite sure how to go about the next steps. How do I actually back up the DB and write it to a backup file in the S3 bucket?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1755,"Q_Id":54431154,"Users Score":0,"Answer":"The method that worked for me was to create an AWS data pipeline to back up the database to CSV.","Q_Score":0,"Tags":"python,postgresql,amazon-s3,aws-lambda","A_Id":54791550,"CreationDate":"2019-01-29T23:25:00.000","Title":"Backing up a postgresql database table with python in lambda","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"C:\\WINDOWS\\system32>pip install tensorflow\n\nCollecting tensorflow\n\n  Could not find a version that satisfies the requirement tensorflow (from versions: )\nNo matching distribution found for tensorflow\n\nI installed the Python (3.6 64-bit), and wanna install tensorflow in Anaconda3.\nAnd I upgraded pip to the latest version, 19.0.1.\nRequirement already up-to-date: pip in c:\\anaconda3\\lib\\site-packages (19.0.1)\nSo, how can I solve this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":450,"Q_Id":54434432,"Users Score":0,"Answer":"if you have anaconda do conda install tensorflow. anaconda version of tensorflow is faster than pip anyways.","Q_Score":0,"Tags":"tensorflow,pip,installation,python-3.6","A_Id":54437112,"CreationDate":"2019-01-30T06:21:00.000","Title":"with python 3.6, Could not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a skill for alexa using the proactive notification function from Amazon. \nIt was working fine until yesterday, I could see the amazon echo blinking with yellow color. \nWhen I queried the device \"Alexa, check my notifications\", the information was available.\nHowever today it does not work and I get the following error:\n\"Violations for metadata: [expiryTime should be at least 5 minutes in the future and no more than 24 hours after the current time\"\nThis is the notification I am sending, I include the current time and the expiration time with an offset of 10 minutes. See the example below\nAny idea what could be wrong?\nThanks in advance,\nEster\n{ \"timestamp\": \"2019-01-30T00:11:20\", \"referenceId\": \"98871463\", \"expiryTime\": \"2019-01-30T00:11:30\", \"event\": { \"name\": \"Alerted\", \"payload\": { \"type\": \"AMAZON.MessageGroup.Alerted\", \"messageState\": { \"type\": \"AMAZON.MessageState\", \"status\": \"UNREAD\", \"freshness\": \"NEW\" }, \"message\": { \"type\": \"AMAZON.Message\", \"creator\": { \"type\": \"AMAZON.Person\", \"name\": \"eve\" }, \"count\": 1, \"urgency\": \"URGENT\" } } }, \"relevantAudience\": { \"type\": \"Multicast\", \"payload\": { } } }","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":108,"Q_Id":54438520,"Users Score":1,"Answer":"I found the error. It was a bug in my code. I was sending the incorrect date, the message timestamp was wrongly sent in the past, and the same happened with the expiryTime. So the error sent back by Amazon was correct.","Q_Score":0,"Tags":"python,alexa,flask-ask","A_Id":54506259,"CreationDate":"2019-01-30T10:35:00.000","Title":"Error: Violations for metadata: [expiryTime should be at least 5 minutes in the future and no more than 24 hours after the current time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I \u2018m new with the Python world. I have four Python Script, and now during the testing phase, i have to run each of one from differenti console istances. My question is: is possible to create an unique script Python, and from it execute at the same time, the 4 scripts. \nI\u2019am working with a publisher\/subscriber architetture, so i have one publisher and three sbuscriber.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":72,"Q_Id":54443995,"Users Score":1,"Answer":"Personally, I wouldn't run them  from python. Create a batch file (windows) or a bash script(linux) and run all four of them as a background process so that they don't have to wait for each other to complete","Q_Score":0,"Tags":"python-2.7","A_Id":54444156,"CreationDate":"2019-01-30T15:27:00.000","Title":"How to run simultaneously four Python scripts from another scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run a python3 script through terminal on my mac, but every time I execute the file terminal uses Python 2.7 despite 3.7 being installed.\nI have read in other threads that python3 can be run by using the \"python3\" command, but this seems to load me into the python syntax with \">>>\" at the beginning of every line\nIs there a way of running python 3 while using whatever syntax is native to terminal?\nOr as a last resort what is the command to run a .py file from the python syntax?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":19387,"Q_Id":54447207,"Users Score":4,"Answer":"Install ppa\n\nsudo add-apt-repository ppa:deadsnakes\/ppa\n\nUpdate packages\n\nsudo apt-get update\n\nUpgrade python 2.x to python 3.x\n\nsudo apt-get install python3.6\nChange default python\nsudo rm \/usr\/bin\/python\nsudo ln -s \/usr\/bin\/python3 \/usr\/bin\/python\nCheck default version\npython -V","Q_Score":2,"Tags":"python,python-3.x,python-2.7,terminal","A_Id":62485102,"CreationDate":"2019-01-30T18:28:00.000","Title":"How to update Python 2.7 to 3 in terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How to use NLTK DependencyGrammar package in Named Entity Recognition (NER)?\nEg. sentence that I am looking is:\n\u201cwhat is the status of my invoice P1234U?\u201d\nAnd I would like to extract P1234U as the invoice number.\nWithout much training I would like to do this, so no SPACY solution please.\nI would prefer to go in a knowledge graph way.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":68,"Q_Id":54447937,"Users Score":1,"Answer":"NER algorithms are normally trained to recognize well known enities such as places,names etc. P1234U does not fall into any of the well known categories. I would suggest a simple regex search with constraints on max length of the invoice id and check the accuracy on that.","Q_Score":0,"Tags":"python,nlp,nltk","A_Id":54451861,"CreationDate":"2019-01-30T19:13:00.000","Title":"How to use NLTK DependencyGrammar package In NER","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to run Pycharm using pygame\/numpy on multiple computers from a USB drive.\nI have to submit a \"create\" project, which I'm doing a a game using pygame. To make this game, I use Pycharm, a python IDE, along with the modules pygame and numpy. When I program at home, I have no issues. I have all the files, pycharm, winpython, and all the files I need on my USB, and it uses the interpeter that is on my USB.\nWhen I get to school, however is when the problems occur. My first issue is that Pycharm won't let me run my programs. I get \"Interpreter is not found\" or something like that, and I haven't been able to solve this issue. What I've tried is to rename the path to the python interpreter Z:\/path (what the usb is at home) to D:\/path. \nWhat I've tried:\nI have also tried making a persistent USB, so that I could install ubuntu, then pycharm,python,pyagme, and numpy. I however failed, and every time O fixed on error with the USB I would get another. I managed to put Ubuntu on the USB and get it to load, but I haven't been able to get the data to save after reboot.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1290,"Q_Id":54449841,"Users Score":0,"Answer":"If you have a correct python interpreter with the necessary modules on your USB key it will be quite easy.\nOpen pycharm. Go to Files\/Settings\/Project Interpreter. Select the correct python.exe in the left menu.\nNow leave the settings. Click on Add Configuration on the top right of the main page. Select python, then the interpreter you just added and in Script Path select the script you want to run.\nJust click play next to Add Configuration and you can run your programs without installing anything.","Q_Score":1,"Tags":"python,python-3.x,pycharm,usb-drive","A_Id":54450021,"CreationDate":"2019-01-30T21:31:00.000","Title":"I need to be able to run pycharm + modules off of a USB","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am confused on whether there is or is not any difference between and int of 5 and a float of 5.0, besides the float having a decimal.\nWhat are some of the things I can do with an int that I can't with a float? What is the point of having two separate types, instead of just letting everything be a float in the first place?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":3586,"Q_Id":54450129,"Users Score":2,"Answer":"5 and 5.0 are different objects in python so 5 is 5.0 is False\nBut in most cases they behave the same like 5 == 5.0 is True","Q_Score":1,"Tags":"python,floating-point,int","A_Id":54450187,"CreationDate":"2019-01-30T21:54:00.000","Title":"Is there a difference between an int of 5 and a float of 5.0?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have trained and tested a KNN model on a small supervised dataset of about 200 samples in Python. I would like to apply these results to a much larger unsupervised dataset of several thousand samples.\nMy question is: is there a way to fit the KNN model using the small supervised dataset, and then change the K-value for the large unsupervised dataset? I do not want to overfit the model by using the low K-value from the smaller dataset but am unsure how to fit the model and then change the K-value in Python.\nIs this possible using KNN? Is there some other way to apply KNN to a much larger unsupervised dataset?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":388,"Q_Id":54450495,"Users Score":0,"Answer":"In machine learning there are two broad types of learners, namely eager learners (Decision trees, neural nets, svms...) and lazy learners such as KNN. In fact, KNN doesn't do any learning at all. It just stores the \"labeled\" data you have and then uses it to perform inference such that it computes how similar the new sample (unlabeled) is, to all of the samples in the data that it has stored (labeled data). Then based on majority voting of the K nearest instances (K nearest neighbours hence the name) of the new sample, it will infer it's class\/value. \nNow to get to your question, \"training\" the KNN has nothing to do with the K itself, so when performing inference feel free to use whatever K gives the best result for you.","Q_Score":0,"Tags":"python,scikit-learn,knn","A_Id":54451152,"CreationDate":"2019-01-30T22:26:00.000","Title":"Apply KNN from small supervised dataset to large unsupervised dataset in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was looking for this information for a while, but as additional packages and python versions can be installed through homebrew and pip I have the feeling that my environment is messed up. Furthermore a long time ago, I had installed some stuff with sudo pip install and as well sudo python ~\/get-pip.py.\nIs there a trivial way of removing all danging dependencies and have python as it was when I first got the machine, or at least with only the packages that are delivered with the Mac distro?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3334,"Q_Id":54450504,"Users Score":0,"Answer":"first delete directories where python is installed. you can find these using\n$ which python \n$ which python3\nthen use \n$ brew doctor\nyou will find broken links which can be removed using  --> $ brew prune\nfinally, you should reinstall python using homebrew\nhope this helps.","Q_Score":3,"Tags":"python,macos,pip,homebrew","A_Id":54451615,"CreationDate":"2019-01-30T22:26:00.000","Title":"How to fully revert Python to factory settings on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When you run a function that returns a Pandas data frame in a Jupyter cell, it prints out this very aesthetic table.  When you give an explicit command to print, it looks much worse.  I have a list of data frames and I'd like to print each.  Is there a way to get the nice version of the print using a for-loop?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":176,"Q_Id":54452598,"Users Score":1,"Answer":"As mentioned in the comment, using display instead of print does the job.","Q_Score":2,"Tags":"python,pandas,jupyter,pretty-print","A_Id":54996195,"CreationDate":"2019-01-31T02:48:00.000","Title":"Jupyter: How can you pretty-print many data frames from the code in one cell?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I type vim hello.py in the command prompt to open my file the command prompt the gVim editor opens up however it does not display the one line of text contained in the hello.py file. Why is this? I just want to edit the file.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":156,"Q_Id":54453735,"Users Score":0,"Answer":"Are you sure you are in the same directory as hello.py?\nOtherwise, gVim will open a new buffer called \"hello.py\", which on save will be written to whatever directory you are currently in.","Q_Score":0,"Tags":"python,vim,windows-10,vim-plugin","A_Id":54458504,"CreationDate":"2019-01-31T05:14:00.000","Title":"gVim display nothing when I open an existing file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a discord  python bot threaded function which fetches data every 5 secs from a website. I ran this bot for just maybe 2-4 hours and now my free dyno hours shows that i have used 27 hours somehow . i am unable to understand how? My Questions -\n1] Does it depend on number of threads running currently? lets say if i have 5 threads currently fetching 5 different datas will the usage of dyno hours increase since i 5 threads are running simultaneously?  \n2] Does it depend on number of deploys? it says i have 24 deploys...so everytime we deploy we use 1 dyno hour? is that so?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":54454518,"Users Score":0,"Answer":"When you are deploying it consumes dyno hours. If you are running 2 deploys simultaneously it is consuming your dyno hours twice as fast.\nIt does not depend on the number of threads running within a single application.","Q_Score":0,"Tags":"python,heroku,discord","A_Id":60352239,"CreationDate":"2019-01-31T06:22:00.000","Title":"Heroku Dyno hours Issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to create a C camera module that python can interact with. The way I envision it working is:\n\nPython callable C methods to setup the camera (eg set gain, set trigger, etc)\na C thread is started somewhere polling\/called back with frames, when a frame is received in the thread - it is sent to a socket.\n\nBasically Python will call the C methods to which will pass messages to the C thread. I'll make it thread safe using C mutexes or semaphores to pass the control command over to the C thread.\nThe question is where do I start the C thread? Is it best to start it in the PyMODINIT_FUNC or should I have another function to start the thread which returns an object holding a reference to the C thread or is there a better simple way? I need something reasonable quick to implement.\nCheers. Mitch.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":54456740,"Users Score":0,"Answer":"Ended up just starting the thread in a \"start\" function and storing the thread id in a static variable and stopping the thread in a \"stop\" method. Works fine, raises errors where appropriate - no issues.","Q_Score":0,"Tags":"python,c,multithreading","A_Id":55000635,"CreationDate":"2019-01-31T08:57:00.000","Title":"Python creating C threads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way I get can the following disk statistics in Python without using PSUtil?\n\nTotal disk space\nUsed disk space\nFree disk space\n\nAll the examples I have found seem to use PSUtil which I am unable to use for this application.\nMy device is a Raspberry PI with a single SD card. I would like to get the total size of the storage, how much has been used and how much is remaining.\nPlease note I am using Python 2.7.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6715,"Q_Id":54458308,"Users Score":1,"Answer":"You can do this with the os.statvfs function.","Q_Score":0,"Tags":"python,python-2.7,raspberry-pi","A_Id":54458486,"CreationDate":"2019-01-31T10:19:00.000","Title":"How to get disk space total, used and free using Python 2.7 without PSUtil","Data Science and Machine Learning":0,"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":"With the previous version of pyautogui, when an image wasn't found the return was \"None\", so I used to handle it with except TypeError:.\nBut since the update (version 0.9.41), it isn't working, as it's returning ImageNotFoundException, but it isn't recognised as an exception. When I try to do except ImageNotFoundException: it gives the error:\n\n[E0712] Catching an exception which doesn't inherit from Exception: ImageNotFoundException\n\nHow should this error be handled?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":3074,"Q_Id":54461133,"Users Score":1,"Answer":"I had the same problem as you, and also couldn't figure out why handling this with an except wasn't possible. Now I have figured it out on python 3.7, this should work if you've installed the PyScreeze package:\nfrom pyscreeze import ImageNotFoundException\nI hope it can help you out :)","Q_Score":2,"Tags":"python,exception,pyautogui,except","A_Id":54495077,"CreationDate":"2019-01-31T12:55:00.000","Title":"Python PyAutoGUI return \"ImageNotFoundException\", but \"except\" doesn't recognise it as an exception","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have never made an executable application before but from what I have read its pretty easy, using py2exe to generate the exe.\nBut I have a GUI that uses Selenium to scrape data from a backend (No I can not use API calls). How do I add chromedriver to the executable? Also, would all the imports go along when using a compiler?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":399,"Q_Id":54468218,"Users Score":0,"Answer":"When you compile a .py file into an .exe (from my personal experience) all of the imports are included.\nI would personally suggest using pyinstaller. I had quite a few problems using py2exe and as a beginner I found pyinstaller much more user-friendly and easier to troubleshoot.\nAs compiling a file does not alter the .py file, I would suggest getting it to a fully working state and trying it. If it doesn't appear to work or if some of the imports are lost, we can troubleshoot with the error code.","Q_Score":1,"Tags":"python,selenium,selenium-chromedriver,exe,executable","A_Id":54468382,"CreationDate":"2019-01-31T19:48:00.000","Title":"Python Selenium GUI to an executable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given scores = { 0.0: \"bob\", 5.2: \"alex\", 2.8: \"carl\"}\nTo get the output [ \"bob\", \"carl\", \"alex\" ]\nI can do print([ scores[key] for key in sorted(scores.keys()) ])\nIs this the best (most \"pythonic\") way? I was thinking I could use scores.items() in conjunction with sorted(key=...) to avoid the dictionary lookup, but not sure what that key parameter would be.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":928,"Q_Id":54468377,"Users Score":0,"Answer":"Another approach would be to create a generator object yielding the values of the dict,\ncast them to a list and then print it.\nprint(list(val for val in scores.values()))","Q_Score":4,"Tags":"python,python-3.x,sorting,dictionary","A_Id":54469052,"CreationDate":"2019-01-31T19:59:00.000","Title":"Sort dict by key and retrieve value","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I run python3 -m venv venv I get this error. I don't get this error on my Mac that is the version behind Mojave. I'm not sure what the issue is, and the error text is very brief:\nError: Command \/Users\/marcus\/venv\/bin\/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' died with <Signals.SIGABRT: 6>.\nOperating System: Mac OS 10.14.3\nPython Version: 3.7.2\nBlood Pressure: high","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1897,"Q_Id":54468566,"Users Score":6,"Answer":"I realized after staring at the line for so long that it was complaining mostly about pip and that this was probably caused by Mac OS X's system pip, which is protected.\nMy venv came alive with the without pip flags like so: python3 -m venv venv --without-pip. \nhere's what works for me the best: \nvirtualenv -p python3 venv && source venv\/bin\/activate","Q_Score":9,"Tags":"virtualenv,python-3.7","A_Id":54468747,"CreationDate":"2019-01-31T20:13:00.000","Title":"Cannot Create Python Virtual Environment on Mac OS Mojave","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing kaggle inclass challege of bosten hosing prices and learnt that XGBoost is faster than RandomForest but when implemented was slower.i Want to ask when XGBoost becomes faster and when RandomForest??.I am new to machine learning and need your help.Thanking in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1525,"Q_Id":54468877,"Users Score":0,"Answer":"Mainly, the parameters you choose have strong impact in the speed of your algorithm, (e.g learning rate, depth of the tree, number of features etc.), there's a trade-off between accuracy and speed, so i suggest you put the parameters you've chosen for every model and see how to change it to get faster performance with reasonable accuracy.","Q_Score":0,"Tags":"python-3.x,machine-learning","A_Id":54469054,"CreationDate":"2019-01-31T20:39:00.000","Title":"XGBOOST faster than random forest?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I remember the dialog box prompting me with a checklist which included Tkinter. I did not uncheck the box. This is the first time I have tried to import Tkinter after this install and get the standard \"module not installed\" error. \nWhen I go to install using pip install Tkinter I get a message saying that it could not find a version that satisfies the requirement. No matching distribution found. \nIf I don't have to re-install Python that would be great, has anybody ever encountered this before\/know what could cause this?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":79,"Q_Id":54468918,"Users Score":-1,"Answer":"Uninstall your  python ans install the new Python 3.7.2 on the official website !\nYour  packtage will be  complete !\nIf  it's still bot work, try to change the path of installation.","Q_Score":0,"Tags":"python,tkinter","A_Id":54469139,"CreationDate":"2019-01-31T20:42:00.000","Title":"Tkinter was installed with Python 3.6.0 but is now not importing and cannot pip install\/uninstall (Windows 7)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm finished one part of this assignment I have to do. There's only one part of the assignment that doesn't make any sense to me. \nI'm doing a LinearRegression model and according to others I need to apply ans[i,:] = y_poly at the very end, but I never got an answer as to why. \nCan someone please explain to me what [i,:] means? I haven't found any explanations online.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":7360,"Q_Id":54469789,"Users Score":3,"Answer":"I guess you are also using numpy to manipulate data (as matrix) ?\nIf based on numpy,  ans[i,:] means to pick the ith 'row' of ans with all of its 'columns'. \nNote,when dealing with numpy arrays, we should (almost) always use [i, j] instead of [i][j]. This might be counter-intuitive if you used Python or Java to manipulate matrix before.","Q_Score":6,"Tags":"python,python-3.x,numpy,scikit-learn,linear-regression","A_Id":54469843,"CreationDate":"2019-01-31T21:52:00.000","Title":"What does [i,:] mean in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have anaconda3 installed, and I found an executable file, pip, in anaconda3\/bin\/. I did not see any file named pip3 coming inside anaconda3. So is the this pip actually pip3? Is there any way that I can verify it explicitly?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":54,"Q_Id":54470248,"Users Score":2,"Answer":"Activate your conda env and then execute on terminal pip --version should indicate which python (2.x or 3.x) is using, that should clear out your doubt.","Q_Score":0,"Tags":"python,pip,anaconda","A_Id":54470278,"CreationDate":"2019-01-31T22:38:00.000","Title":"Is the pip that comes with anaconda3 actually pip3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tensorflow-gpu and keras installed in Python 3.6.8. But when I tried importing keras, it is giving the the error of Module not found. Also the error statements show the error is at a line inside keras at import tensorflow as tf. How to make keras import tensorflow-gpu instead of tensorflow? Do I have to go to the library code and change it? Or what else is the solution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1130,"Q_Id":54471160,"Users Score":0,"Answer":"I just reinstalled both tf and keras and now everything is working fine. Don't know what had went wrong. Maybe the installation was not proper first time.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":54477319,"CreationDate":"2019-02-01T00:17:00.000","Title":"Keras giving error \"ModuleNotFoundError: No module named 'tensorflow'\" even though tensorflow-gpu is installed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a REST to SQL server in Python and am trying to add an additional WHERE condition to all SQL queries that I receive. For example, let's say I want to filter all queries for values of b > 4. I would do the following:\nGiven a SQL query that contains a WHERE clause:\nSELECT * FROM my_table WHERE a < 5\nbecomes\nSELECT * FROM my_table WHERE a < 5 AND b > 4\nGiven a SQL query that contains no WHERE clause:\nSELECT * FROM my_table\nbecomes\nSELECT * FROM my_table WHERE b > 4\nGiven a SQL query that contains a GROUP BY and no WHERE clause:\nSELECT id FROM my_table GROUP BY id\nbecomes\nSELECT id FROM my_table WHERE b > 4 GROUP BY id\nI also need to handle queries that contain many combinations of other clauses, such as LIMIT, HAVING, etc.\nIs there a clean way in SQL to handle a substitution like this for all queries? Or do I simply have to use regexes and pattern matching in Python to achieve this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":250,"Q_Id":54471426,"Users Score":0,"Answer":"There is no generic existing solution to your problem. The examples you've provided cover part of the possible space of queries, but SQL allows for far more complicated queries that might need different solutions still (JOINs, UNIONs, etc.). A generic solution that would cover all possible queries would be very complicated, if possible at all.\nIf you know the examples you're giving cover the entire need for your specific use case, then yes - using regex and pattern matching is probably a good approach. I would recommend encapsulating your solution in a class that holds your query and exposes operations that allow you to add conditions and perform similar operations if you need them. \nThat way, you can easily extend it later without affecting the use of the class in the rest of your code.","Q_Score":0,"Tags":"python,sql","A_Id":54471594,"CreationDate":"2019-02-01T00:52:00.000","Title":"How to add an additional WHERE clause to any generic SQL query","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been working on a Django Project for a bit, until I took a break. One month later I dug back in to the project and went to run the server. I received an error:\n django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.\nI figured I must have tweaked something by accident. So I created a brand new Django Project (using a virtual environment), and just went to test the server. I received the same error. I tried the python manage.py shell solution listed in another answers but to no avail. \nIf it helps I'm on Linux with Django version 2.1.5 and Python 3.6.\nEdit:\nIf anyone encounters something similar I found using python3 manage.py runserver works in place of using django-admin. Per Greg's answer below, I did begin to receive a new error ModuleNotFoundError: No Module named \"mysite\" exists. I will continue to search for an answer on that front.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":54472388,"Users Score":0,"Answer":"Going off of the comments here.\nIf \"env | grep DJANGO_SETTINGS_MODULE\" returns empty, it means you have to set an environment variable stating where your settings.py file is located.\nThis can be done by doing the following:\nexport DJANGO_SETTINGS_MODULE=mysite.settings\nBe sure to replace \"mysite\" with the name of your app!","Q_Score":0,"Tags":"django,python-3.x","A_Id":54472527,"CreationDate":"2019-02-01T03:17:00.000","Title":"Created a brand new Django Project, attempting to run the server generates an Improperly Configured Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to run a python script when Maya(2018) is launched on my Mac. I tried creating a file called 'userSetup.py' and placing it in my '\/Users\/Shared\/Autodesk\/maya\/2018\/scripts' directory. \nright now the 'userSetup.py' script just has one line:\nprint 'its working'\nso far, I am not able to get the print message to show up in the script editor when I launch Maya(2018). \ngoogle, Autodesk website","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":862,"Q_Id":54472691,"Users Score":1,"Answer":"Maya usually searches for userSetup.py in the paths defined in PYTHONPATH environment variable. By default $HOME\/maya\/2018\/prefs\/scripts directory is added to PYTHONPATHwhen Maya starts. Unless until you are not defining your own PYTHONPATH variable, you can put your userSetup.py in this directory to work with Maya.\nAlso most of the time you can find the print or log statements(basically stdout) from the userSetup.py files in the terminal(from where Maya is launched) instead of the Maya Script editor.","Q_Score":0,"Tags":"python,maya","A_Id":54478839,"CreationDate":"2019-02-01T03:59:00.000","Title":"I am having trouble getting a python script to run when Maya launches","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using latest version macOS and homebrew, brew doctor find nothing wrong. and I just use brew install python,  brew install python@2 to get latest version of python.\nWhen I type python -c \"import sqlite3\", I get following error messages:\n\npython2.7 -c \"import sqlite3\"\n  130 \u21b5 Traceback (most recent call last):   File \"\", line 1, in\n     File\n  \"\/usr\/local\/Cellar\/python@2\/2.7.15_2\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/sqlite3\/init.py\",\n  line 24, in \n      from dbapi2 import *   File \"\/usr\/local\/Cellar\/python@2\/2.7.15_2\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/sqlite3\/dbapi2.py\",\n  line 28, in \n      from _sqlite3 import * ImportError: dlopen(\/usr\/local\/Cellar\/python@2\/2.7.15_2\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/lib-dynload\/_sqlite3.so,\n  2): Symbol not found: _sqlite3_enable_load_extension   Referenced\n  from:\n  \/usr\/local\/Cellar\/python@2\/2.7.15_2\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/lib-dynload\/_sqlite3.so\n  Expected in: \/usr\/lib\/libsqlite3.dylib  in\n  \/usr\/local\/Cellar\/python@2\/2.7.15_2\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/lib-dynload\/_sqlite3.so\npython -c \"import sqlite3\"\n  1 \u21b5 Traceback (most recent call last):   File \"\", line 1, in\n     File\n  \"\/usr\/local\/Cellar\/python\/3.7.2_1\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/sqlite3\/init.py\",\n  line 23, in \n      from sqlite3.dbapi2 import *   File \"\/usr\/local\/Cellar\/python\/3.7.2_1\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/sqlite3\/dbapi2.py\",\n  line 27, in \n      from _sqlite3 import * ImportError: dlopen(\/usr\/local\/Cellar\/python\/3.7.2_1\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/lib-dynload\/_sqlite3.cpython-37m-darwin.so,\n  2): Symbol not found: _sqlite3_enable_load_extension   Referenced\n  from:\n  \/usr\/local\/Cellar\/python\/3.7.2_1\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/lib-dynload\/_sqlite3.cpython-37m-darwin.so\n  Expected in: \/usr\/lib\/libsqlite3.dylib  in\n  \/usr\/local\/Cellar\/python\/3.7.2_1\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/lib-dynload\/_sqlite3.cpython-37m-darwin.so\n\nwhat may cause the problem? I tried to download python source code and compile it, and move the _sqlite3.so or _sqlite3.cpython-37m-darwin.so file into the brew installed folder, and everything works just fine. Could  brew just forget something in the formula? What can I do except for compiling .so file from source and manually solve the problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":518,"Q_Id":54476008,"Users Score":0,"Answer":"I finally find out where the bug hides.\nAll my macOS devices(including 2 Pros and 1 Air) are sharing the same .zshrc file, and for some reason, I add a\nexport DYLD_LIBRARY_PATH=\"\/Users\/myname\/Library\/Developer\/Xcode\/iOS DeviceSupport\/10.0.1 (14A403)\/Symbols\/usr\/lib\/:\/usr\/lib\/\"\nwhich ruins the build of python sqlite shared library file, for sqlite recently add a feature called '_sqlite3_enable_load_extension'.\nwhen I removed the DYLD_LIBRARY_PATH to the outdated dir, and brew reinstall python everything is fine.\nBy the way, brew config and brew doctor provides no information about DYLD_LIBRARY_PATH. Next time I'll follow the rules and provide these informations.\nProblem solved!","Q_Score":1,"Tags":"python,homebrew,homebrew-cask","A_Id":54684608,"CreationDate":"2019-02-01T08:56:00.000","Title":"homebrew python@2 and python provides broken sqlite3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Are there any Deep Learning literature\/references where they performed clustering in structured data?\nI know it can be done using Kmeans, GMM etc. But is there any chance that cluster analysis to be done using Deep Neural Nets and the like? Thanks.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":490,"Q_Id":54476162,"Users Score":0,"Answer":"Yes.\nIf you do a little bit of literature research yourself you will find that people have repeatedly published clustering with deep neural networks.\nExcept that it doesn't seem to work anywhere but on MNIST data...","Q_Score":0,"Tags":"python,deep-learning,cluster-analysis,data-science","A_Id":54485647,"CreationDate":"2019-02-01T09:06:00.000","Title":"Clustering structured data in Deep learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are there any Deep Learning literature\/references where they performed clustering in structured data?\nI know it can be done using Kmeans, GMM etc. But is there any chance that cluster analysis to be done using Deep Neural Nets and the like? Thanks.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":490,"Q_Id":54476162,"Users Score":0,"Answer":"Two other Potential Methods:\n\nKMeans + Autoencoder (a simple deep learning architecture with\nkmeans and reducing the dimensionality of the data using autoencoders). \nDeep Embedded Clustering algorithm (advanced deep learning)","Q_Score":0,"Tags":"python,deep-learning,cluster-analysis,data-science","A_Id":55927272,"CreationDate":"2019-02-01T09:06:00.000","Title":"Clustering structured data in Deep learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Java the code is structured in packages with you each class in a separate file. Is there any similar practice in python? Is it better to have each class in a different python file and have them import each other or should I just dump my code(all my classes)  in a single file?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7642,"Q_Id":54476248,"Users Score":3,"Answer":"In Java the code is structured in packages with you each class in a separate file. Is there any similar practice in python?\n\nDefinitely no. Actually, Python doesn't force you to put all your code in classes - plain functions are ok too - so even the \"each class\" premise doesn't make sense.\n\nIs it better to have each class in a different python file\n\nDefinitely no either - it would just make your code a nightmare to maintain.\n\nor should I just dump my code(all my classes) in a single file?\n\nNeither (unless it's a very small app). You want to regroup your code (functions, classes, etc.) in cohesive, decoupled modules\/packages, which is the known best practice in all languages anyway. If you have a \"full\" app with domain code, persistence and UI you'll probably want to use this as your first level packages.","Q_Score":1,"Tags":"python,structure","A_Id":54476573,"CreationDate":"2019-02-01T09:11:00.000","Title":"Python code structure for class organization","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Java the code is structured in packages with you each class in a separate file. Is there any similar practice in python? Is it better to have each class in a different python file and have them import each other or should I just dump my code(all my classes)  in a single file?","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":7642,"Q_Id":54476248,"Users Score":-1,"Answer":"By default python did not create one file for each class in code file.\nTo create separate file for each class, it code of each class should be in separate file\nIf two classes are related or tightly coupled, and client code will need to instantiate each, It is good to put them in the same file.\nIf one parent class has many child classes, and child class has very little code, better to put in one file.","Q_Score":1,"Tags":"python,structure","A_Id":54476990,"CreationDate":"2019-02-01T09:11:00.000","Title":"Python code structure for class organization","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just reinstalled python into my system with all necessary modules. But when I run a program with the import statement from keras.utils import HDF5Matrix, it is giving attribute error. The place where the error is coming is: File \"h5py\\h5r.pxd\", line 21, in init h5py._conv\n  File \"h5py\\h5r.pyx\", line 145, in init h5py.h5r. But when I run the same statement in the IDLE directly, it is not giving any error. So, what is the cause of error. I have not posted my code because most of it is irrelevant as the Interpreter is not going past the import statement. Also, before I reinstalled Python, the code was working fine. So, what can be the problem.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3723,"Q_Id":54477273,"Users Score":0,"Answer":"I got the solution. It was because I was importing both HDF5Matrix and tables in same program. Due to some reason both cannot be imported in  same program. I think it is because both make use of h5py in backend, so importing both is causing some conflict.","Q_Score":2,"Tags":"python,tensorflow,keras,hdf5","A_Id":54650272,"CreationDate":"2019-02-01T10:12:00.000","Title":"AttributeError: type object 'h5py.h5r.Reference' has no attribute '__reduce_cython__' on using \"from keras.utils import HDF5Matrix\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run clustering algorithm on a dataset with 14 features. Of those features, except for one, every feature lies between 0 to 1. The remaining one feature is a continuous variable between 0 to 8000. Do i need to use the standard scaler on all the features or just this one feature ( 0 - 8000) before clustering?? OR do i just use the min-max scaler for this one feature alone??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":54479965,"Users Score":0,"Answer":"You don't \"have\" to use either.\nStandard scaling as well as [0;1] scaling (which is not the same) are just two popular heuristics for weighting variables. Neither is \"correct*.\nIf you have a better reason to weight variables differently, you may as well just do that. Things don't get more \"correct\" by scaling.\nReducing the weight of that 8000 variable likely is a good idea. But if that question arises, it probably means you have not understood the problem that you are trying to solve... You are just using a huge, without a plan.","Q_Score":0,"Tags":"python-3.x,cluster-analysis","A_Id":54485609,"CreationDate":"2019-02-01T12:53:00.000","Title":"Clustering: if my features are all in 0-1 range do i still have to use standard scaling","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was using gsutil API to connect to clusterdata-2011-2 (which is a Google cluster-usage traces of 29 days). it was worked perfectly. But after I have installed Anaconda3, it does not work anymore.\nIt says that gsutil requires python 2.6 or 2.7. \nEven after adding an alias in .bashrc \n\nalias python='\/usr\/bin\/python2\/'\n\nIt didn't work\nCan you please help me?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":591,"Q_Id":54481157,"Users Score":0,"Answer":"I suspect your alias is wrong firstly... \nalias python=\/usr\/bin\/python2.7 \nFeels better.\nCheck your PATH i.e. $PATH \nAnd try and Remove the Anaconda part...","Q_Score":0,"Tags":"python,gsutil","A_Id":54481217,"CreationDate":"2019-02-01T14:07:00.000","Title":"gsutil requires python 2.6 or 2.7. Issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was using gsutil API to connect to clusterdata-2011-2 (which is a Google cluster-usage traces of 29 days). it was worked perfectly. But after I have installed Anaconda3, it does not work anymore.\nIt says that gsutil requires python 2.6 or 2.7. \nEven after adding an alias in .bashrc \n\nalias python='\/usr\/bin\/python2\/'\n\nIt didn't work\nCan you please help me?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":591,"Q_Id":54481157,"Users Score":0,"Answer":"euh it  didn't work\nbut also i don't want to remove Anaconda cause i am working with it..\ni am thinking about deploying a new VM ware machine without installing neither python3 nor anaconda\nThank u for your suggestion !!","Q_Score":0,"Tags":"python,gsutil","A_Id":54512505,"CreationDate":"2019-02-01T14:07:00.000","Title":"gsutil requires python 2.6 or 2.7. Issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"In the below operation, we are using a as an object as well as an argument.\na = \"Hello, World!\"\n\nprint(a.lower())  -> a as an object\nprint(len(a))   -> a as a parameter\n\nMay I know how exactly each operations differs in the way they are accessing a?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":15,"Q_Id":54481186,"Users Score":1,"Answer":"Everything in python (everything that can go on the rhs of an assignment) is an object, so what you can pass as an argument to a function IS an object, always. Actually, those are totally orthogonal concepts: you don't \"use\" something \"as an object\" - it IS an object - but you can indeed \"use it\" (pass it) as an argument to a function \/ method \/ whatever callable.\n\nMay I know how exactly each operations differs in the way they are accessing a?\n\nNot by much actually (except for the fact they do different things with a)... \na.lower() is only syntactic sugar for str.lower(a) (obj.method() is syntactic sugar for type(obj).method(obj), so in both cases you are \"using a as an argument\".","Q_Score":0,"Tags":"python-3.x","A_Id":54481340,"CreationDate":"2019-02-01T14:09:00.000","Title":"How can a same entity function as a parameter as well as an object?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install the requests library so I can make HTTP requests. I've tried looking for resources online but I can't seem to find tutorials for installing this library on MacOS.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28458,"Q_Id":54484536,"Users Score":0,"Answer":"You can use pip to install requests library. Try these steps to setup pip and install requests library in macOS:\n\nsudo easy_install pip\npip install requests","Q_Score":1,"Tags":"python,python-3.x,python-requests","A_Id":54484665,"CreationDate":"2019-02-01T17:40:00.000","Title":"Installing requests python library on MacOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"From what I see, most people seem to be initializing an entire model, and sending the whole thing to the GPU. But I have a neural net model that is too big to fit entirely on my GPU. Is it possible to keep the model saved in ram, but run all the operations on the GPU?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":162,"Q_Id":54485815,"Users Score":1,"Answer":"I do not believe this is possible. However, one easy work around would be to split you model into sections that will fit into gpu memory along with your batch input. \n\nSend the first part(s) of the model to gpu and calculate outputs\nRelease the former part of the model from gpu memory, and send the next section of the model to the gpu. \nInput the output from 1 into the next section of the model and save outputs.\n\nRepeat 1 through 3 until you reach your models final output.","Q_Score":0,"Tags":"python,gpu,cpu,pytorch","A_Id":54485944,"CreationDate":"2019-02-01T19:12:00.000","Title":"PyTorch: Is there a way to store model in CPU ram, but run all operations on the GPU for large models?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"On my Anaconda navigator, matplotlib is installed however when I run import matplotlib it will give me an error message saying: \"import is not recognized as internal or external command, operable program or batch file.\"\nDid I not download it? How do I check that I've successfully installed it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":323,"Q_Id":54488308,"Users Score":0,"Answer":"You are not running import matplotlib in a python interpreter.\nRun python.exe first","Q_Score":0,"Tags":"python,anaconda","A_Id":54488348,"CreationDate":"2019-02-01T23:10:00.000","Title":"Error when trying to import matplotlib: \"import is not recognized as internal or external command\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two large tables with one of them is relatively small ~8Million rows and one column. Other is large 173Million rows and one column. The index of the first data frame is IntervalIndex (eg (0,13], (13, 20], (20, 23], ...) and the second one is ordered numbers (1,2,3, ...). Both DataFrame are sorted so \nDF1     category\n(0,13]  1\n(13 20] 2\n....\nDf2 Value\n1   5.2\n2   3.4\n3   7.8\nDesired\nDf3\nindex value  category\n1  5.2      1\n2  3.4      1\n3 7.8       1\nI want two obtain inner join (faster algorithm) that returns inner join similar to MySQL on data_frame2.index\n\nI would like to be able to perform it in an elaborate way in a cluster because when I PRODUCED THE INNERJOIN WITH SMALLER SECOND DATASET THE RESULT ARE SO MEMORY CONSUMING IMAGINE 105MEGABYTE for 10 rows using map_partitions.\nAnother problem is that I cannot use scatter twice, given if first DaskDF=client.scatter(dataframe2) followed by DaskDF=client.submit(fun1,DaskDF) I am unable to do sth like client.submit(fun2,DaskDF).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":343,"Q_Id":54488890,"Users Score":0,"Answer":"You might try using smaller partitions.  Recall that the memory use of joins depend on how many shared rows there are.  Depending on your data the memory use of an output partition may be much larger than the memory use of your input partitions.","Q_Score":0,"Tags":"python,pandas,distributed-computing,dask","A_Id":54777333,"CreationDate":"2019-02-02T00:39:00.000","Title":"innerjoin between two large pandas dataframe using dask","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I trained a model in TensorFlow using the tf.estimator API, more specifically using tf.estimator.train_and_evaluate. I have the output directory of the training. How do I load my model from this and then use it?\nI have tried using the tf.train.Saver class by loading the most recent ckpt file and restoring the session. However, then to call sess.run() I need to know what the name of the output node of the graph is so I can pass this to the fetches argument. What is the name\/how can I access this output node? Is there a better way to load and use the trained model?\nNote that I have already trained and saved the model in a ckpt file, so please do not suggest that I use the simple_save function.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":54489497,"Users Score":0,"Answer":"(Answering my own question) I realized that the easiest way to do this was to use the tf.estimator API. By initializing an estimator that warm starts from the model directory, it's possible to just call estimator.predict and pass the correct args (predict_fn) and get the predictions immediately. It's not required to deal with the graph variables in any way.","Q_Score":0,"Tags":"python,tensorflow","A_Id":54505574,"CreationDate":"2019-02-02T02:41:00.000","Title":"Loading and using a trained TensorFlow model in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a 2D array of 0's and 1's where the 1's represent the edges and inside of a quadrilateral, and 0's are everything outside. What is the best way to find the coordinates of the four corners?\nI'm using Python so any libraries that can help are fine, but an algorithm in any language would be helpful as well.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":815,"Q_Id":54490347,"Users Score":2,"Answer":"i have an idea about how u can make a function for this by your self. according to what i understand only the for corners can have more than one \"0\" next to it. \nif you take array[x,y] to be a point. array[x-1,y],array[x+1,y],array[x,y+1],array[x,y-1] are the 4 point close to it. you can make a loop to go through the array checking the four neighbors if the value is \"1\" and count the number of neighbors which has value \"0\". those point that has more than one(has two) neighbors with value \"0\" are you four corners.","Q_Score":0,"Tags":"python","A_Id":54490809,"CreationDate":"2019-02-02T05:43:00.000","Title":"Finding corners of a polygon represented in a 2D array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a 2D array of 0's and 1's where the 1's represent the edges and inside of a quadrilateral, and 0's are everything outside. What is the best way to find the coordinates of the four corners?\nI'm using Python so any libraries that can help are fine, but an algorithm in any language would be helpful as well.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":815,"Q_Id":54490347,"Users Score":1,"Answer":"In the absolutely general case (e.g. allowing for concave hulls or darn-near-triangular shapes) this will involve some uncertainty. But since you are dealing with a restricted subclass, it's easier.\nYou might start with kernel convolution. Consider overlapping squares of (say) 3x3 pixels: you can design a function that tells you if the center is inside (all ones), outside (all zeros), on an edge, or at a corner, based on patterns of points.\nOn the other hand, you could take the \"convex hull\" approach: the leftmost and rightmost 1-pixels are probably corners; if several appear at the same column, take the uppermost\/lowermost respectively. Using the line between them, you can tell if the bulk of 1-pixels are above, below, or on both sides of the line; this tells you where to look for the other corners.","Q_Score":0,"Tags":"python","A_Id":54490817,"CreationDate":"2019-02-02T05:43:00.000","Title":"Finding corners of a polygon represented in a 2D array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why am I getting error, if my script creates a folder? I am using Python on Windows 7.\nThe error:\n\nFileExistsError: [WinError 183] Cannot create a file when that file already exists: [path to the file or folder in question]\n\nThe problem is that file and folder were not there.","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":30387,"Q_Id":54491021,"Users Score":8,"Answer":"I just encountered this same issue.  This thread helped me solve the problem, but the following clarification might help someone:\nFor me, the misunderstanding came from shutil.copytree(source, destination, symlinks, ignore).  \nI read destination as being the place where my copied tree will go.  In reality, it creates that location and then copies the tree there.  So if your destination directory already exists, like mine did, you'll get the error.\nHope that helps someone.","Q_Score":9,"Tags":"python,windows","A_Id":60623263,"CreationDate":"2019-02-02T07:32:00.000","Title":"Why am I getting the error: \"FileExistsError: [WinError 183] Cannot create a file when that file already exists\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a pile of ngrams of variable spelling, and I want to map each ngram to it's best match word out of a list of known desired outputs.\nFor example, ['mob', 'MOB', 'mobi', 'MOBIL', 'Mobile] maps to a desired output of 'mobile'.\nEach input from ['desk', 'Desk+Tab', 'Tab+Desk', 'Desktop', 'dsk'] maps to a desired output of 'desktop'\nI have about 30 of these 'output' words, and a pile of about a few million ngrams (much fewer unique).\nMy current best idea was to get all unique ngrams, copy and paste that into Excel and manually build a mapping table, took too long and isn't extensible. \nSecond idea was something with fuzzy (fuzzy-wuzzy) matching but it didn't match well. \nI'm not experienced in Natural Language terminology or libraries at all so I can't find an answer to how this might be done better, faster and more extensibly when the number of unique ngrams increases or 'output' words change. \nAny advice?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":217,"Q_Id":54491245,"Users Score":1,"Answer":"The classical approach would be, to build a \"Feature Matrix\" for each ngram. Each word maps to an Output which is a categorical value between 0 and 29 (one for each class) \nFeatures can for example be the cosine similarity given by fuzzy wuzzy but typically you need many more. Then you train a classification model based on the created features. This model can typically be anything, a neural network, a boosted tree, etc.","Q_Score":2,"Tags":"python,nltk,natural-language-processing","A_Id":54491318,"CreationDate":"2019-02-02T08:14:00.000","Title":"Best way to map words with multiple spellings to a list of key words?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have developing kind of chat app. \nThere are python&postgresql in server side, and xcode, android(java) side are client side(Web will be next phase).\nServer program is always runing on ubuntu linux. and I create thread for every client connection in server(server program developed by python). I didnt decide how should be db operations?. \n\nShould i create general DB connection and i should use this\nconnection for every client's DB\noperation(Insert,update,delete..etc). In that case If i create\ngeneral connection, I guess i got some lock issue in future. (When i try to get chat message list while other user inserting)\nIF I create DB connection when each client connected to my server. In that case, Is there too many connection. and it gaves me performance issue in future.\nIf i create DB connection on before each db operation, then there is so much db connection open and close operation. \n\nWhats your opinion? Whats the best way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":54494695,"Users Score":1,"Answer":"The best way would be to maintain a pool of database connections in the server side.\nFor each request, use the available connection from the pool to do database operations and release it back to the pool once you're done.\nThis way you will not be creating new db connections for each request, which would be a costly operation.","Q_Score":0,"Tags":"python,postgresql,webserver","A_Id":54495609,"CreationDate":"2019-02-02T15:52:00.000","Title":"should i open db connection for every thread?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am looking for a way to set a fixed step size for solving my initial value problem by Runge-Kutta method in Python. Accordingly, how I can tell the scipy.integrate.RK45 to keep a constant update (step size) for its integration procedure?\nThank you very much.","AnswerCount":6,"Available Count":4,"Score":0.1325487884,"is_accepted":false,"ViewCount":5393,"Q_Id":54494770,"Users Score":4,"Answer":"Scipy.integrate is usually used with changeable step method by controlling the TOL(one step error) while integrating numerically. The TOL is usually computed by checking with another numerical method. For example RK45 uses the 5th order Runge-Kutta to check the TOL of the 4th order Runge-Kutta method to determine the integrating step. \nHence if you must integrate ODEs with fixed step, just turn off the TOL check by setting atol, rtol with a rather large constant. For example, like the form:\nsolve_ivp(your function, t_span=[0, 10], y0=..., method=\"RK45\", max_step=0.01, atol = 1, rtol = 1)\nThe TOL check is set to be so large that the integrating step would be the max_step you choose.","Q_Score":3,"Tags":"python,scipy,integrate,runge-kutta","A_Id":57942410,"CreationDate":"2019-02-02T15:59:00.000","Title":"How to set fixed step size with scipy.integrate?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a way to set a fixed step size for solving my initial value problem by Runge-Kutta method in Python. Accordingly, how I can tell the scipy.integrate.RK45 to keep a constant update (step size) for its integration procedure?\nThank you very much.","AnswerCount":6,"Available Count":4,"Score":0.0665680765,"is_accepted":false,"ViewCount":5393,"Q_Id":54494770,"Users Score":2,"Answer":"If you are interested in data-wise fix step size, then I highly recommend you to use the scipy.integrate.solve_ivp function and its t_eval argument.\nThis function wraps up all of the scipy.integrate ode solvers in one function, thus you have to choose the method by giving value to its method argument. Fortunately, the default method is the RK45, so you don't have to bother with that.\nWhat is more interesting for you is the t_eval argument, where you have to give a flat array. The function samples the solution curve at t_eval values and only returns these points. So if you want a uniform sampling by the step size then just give the t_eval argument the following: numpy.linspace(t0, tf, samplingResolution), where t0 is the start and tf is the end of the simulation.\nThusly you can have uniform sampling without having to resort fix step size that causes instability for some ODEs.","Q_Score":3,"Tags":"python,scipy,integrate,runge-kutta","A_Id":64495201,"CreationDate":"2019-02-02T15:59:00.000","Title":"How to set fixed step size with scipy.integrate?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a way to set a fixed step size for solving my initial value problem by Runge-Kutta method in Python. Accordingly, how I can tell the scipy.integrate.RK45 to keep a constant update (step size) for its integration procedure?\nThank you very much.","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":5393,"Q_Id":54494770,"Users Score":1,"Answer":"You've said you want a fixed-time step behaviour, not just a fixed evluation time step. Therefore, you have to \"hack\" your way through that if you not want to reimplement the solver yourself. Just set the integration tolerances atol and rtol to 1e90, and max_step and first_step to the value dt of the time step you want to use. This way the estimated integration error will always be very small, thus tricking the solver into not shrinking the time step dynamically.\nHowever, only use this trick with EXPLICIT algortithms (RK23,RK45,DOP853) !\nThe implicit algorithms from \"solve_ivp\" (Radau, BDF, maybe LSODA as well) adjust the precision of the nonlinear Newton solver according to atol and rtol, therefore you might end up having a solution which does not make any sense...","Q_Score":3,"Tags":"python,scipy,integrate,runge-kutta","A_Id":64773397,"CreationDate":"2019-02-02T15:59:00.000","Title":"How to set fixed step size with scipy.integrate?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a way to set a fixed step size for solving my initial value problem by Runge-Kutta method in Python. Accordingly, how I can tell the scipy.integrate.RK45 to keep a constant update (step size) for its integration procedure?\nThank you very much.","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":5393,"Q_Id":54494770,"Users Score":1,"Answer":"I suggest to write your own rk4 fixed step program in py. There are many internet examples to help. That guarantees that you know precisely how each value is being computed. Furthermore, there will normally be no 0\/0 calculations and if so they will be easy to trace and prompt another look at the ode's being solved.","Q_Score":3,"Tags":"python,scipy,integrate,runge-kutta","A_Id":66190287,"CreationDate":"2019-02-02T15:59:00.000","Title":"How to set fixed step size with scipy.integrate?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python 2.7 installed on my macbook pro in \/usr\/bin. When I do ls python*  I see these files: python          python-config       python2.7       python2.7-config    pythonw         pythonw2.7.\nI want to delete them but I can't find a way to do it, I've tried sudo rm -rf  and other things but nothing seems to work. \nWhen I do sudo rm -rf I get this: \nrm: python: Operation not permitted, \nand when I do  sudo rm python I get this\noverride rwxr-xr-x  root\/wheel restricted,compressed for python? \nI want to delete python entirely from my system , can someone help me?","AnswerCount":3,"Available Count":2,"Score":-0.1973753202,"is_accepted":false,"ViewCount":9579,"Q_Id":54495353,"Users Score":-3,"Answer":"Lol can't believe no one has said this:\nBoot into recovery, turn off SIP:\ncsrutil disable\nrestart,\nopen terminal\ncd \/usr\/bin\nthen\nsudo chmod -R 777 .\/\ntry it again\n$ python --version\nyou should no longer see it","Q_Score":2,"Tags":"python,macos,terminal,command,uninstallation","A_Id":62700254,"CreationDate":"2019-02-02T17:02:00.000","Title":"Unable to uninstall python 2.7 in mac os","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have python 2.7 installed on my macbook pro in \/usr\/bin. When I do ls python*  I see these files: python          python-config       python2.7       python2.7-config    pythonw         pythonw2.7.\nI want to delete them but I can't find a way to do it, I've tried sudo rm -rf  and other things but nothing seems to work. \nWhen I do sudo rm -rf I get this: \nrm: python: Operation not permitted, \nand when I do  sudo rm python I get this\noverride rwxr-xr-x  root\/wheel restricted,compressed for python? \nI want to delete python entirely from my system , can someone help me?","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":9579,"Q_Id":54495353,"Users Score":-1,"Answer":"Do not remove python 2.7 from your Mac computer. As you have seen you probably can't anyway. The Mac uses python and the files are protected to be sure they are not removed. \nIf you want to run another version of python install it and set up virtual environments.","Q_Score":2,"Tags":"python,macos,terminal,command,uninstallation","A_Id":54499849,"CreationDate":"2019-02-02T17:02:00.000","Title":"Unable to uninstall python 2.7 in mac os","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When am working with a Python code involving for loop, often am getting TLE (time limit exceed) error.\nHow can I overcome that error?\nFor example: in using a for loop of range n, if the loop goes to really very large value say, 10^8 am getting that error. Is there any efficient way which can replace for loops for faster execution?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":594,"Q_Id":54496861,"Users Score":0,"Answer":"Break statement can be used in some situations to solve TLE error.","Q_Score":0,"Tags":"python","A_Id":72499832,"CreationDate":"2019-02-02T19:43:00.000","Title":"How do I get rid of the TLE error in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been developing a Python app that serves a React frontend with server-side rendering.\nLocally, this has worked fine as I'm able to run two servers on separate ports to handle different parts of my application.  My Python backend receives the initial request and then sends an http request to my Node.js server which does my server-side rendering.  The result is then sent back to my Python backend which injects the server-rendered frontend into the HTML which is sent to the client.\nHowever, Heroku limits applications to a single, dynamically generated port.  This limits me to only running one web server which means I'm no longer able to run my Node.js server to do my server-side rendering.  I have thought of some gimmicky ways to make this work, but I don't want to have to create an entirely new app on Heroku just to run the Node.js server I need.\nI'm not sure how I can make this work with these limitations in place so I'm hoping I can learn some alternative ways to make this work on Heroku.  What are some viable workarounds to handle this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":343,"Q_Id":54497729,"Users Score":0,"Answer":"I think you need to create to separate apps on Heroku(even though you don't want to), as far as I know there's no other available options on Heroku.\nI use Heroku for a SSR application running on two apps. One for frontend(react) and one for backend(nodejs). Works like a charm","Q_Score":1,"Tags":"python,node.js,reactjs,heroku,server-side-rendering","A_Id":54513004,"CreationDate":"2019-02-02T21:32:00.000","Title":"How does server-side rendering work with a non-Node.js backend on Heroku?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am a thirteen-year-old who is learning programming. I know Javascript and Python pretty well, but I mostly program Javascript using Node.js as my compiler.\nI have a pretty na\u00efve question. I am writing an implementation of a circular buffer, and I need to know the remainder when -7 is divided by 3. I went to a Node.js console(version 11.1.0) and a Python console(Python 3.7) and typed in -7 % 3. In the Node.js console, it printed -1, but in the Python console, it printed 2. My question is partially mathematical: Which answer is correct, -1 or 2?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":54501336,"Users Score":1,"Answer":"Both are correct, but they are different things. Python uses actual modulus, which is positive. Javascript does a remainder, which can be negative. \nIf you always need a positive value you can add (a multiple of) the divisor into the value and make sure it\u2019s always larger than zero and will always get the same answer. Or check afterwards for a negative value and add the divisor to get the modulus.","Q_Score":0,"Tags":"javascript,python,node.js","A_Id":54501357,"CreationDate":"2019-02-03T08:57:00.000","Title":"Remainder in Node.js vs Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am writing a python script that sends a get request to a router. The problem is that the user and password are exposed to all in the script. I have seen multiple methods for dealing with this problem(using environment variables, reading credentials from a file) but these methods have not satisfied my needs. I would like that only a local admin user could have access to the file or variables that hold the user\/pass values.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":487,"Q_Id":54501453,"Users Score":0,"Answer":"So I solved this problem by encrypting my credentials with a permanent fernet key using the cryptography library. The permanent key is in a file in the same directory as the main code as well as the encrypted credentials. \nThanks for the suggestions.","Q_Score":0,"Tags":"python-requests,hide,credentials,password-protection,password-encryption","A_Id":54523608,"CreationDate":"2019-02-03T09:14:00.000","Title":"Hide login credentials in python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Mac OS High Sierra and trying to learn Django framework over Pycharm IDE. But my directories are only read only and so I cannot add more files or make changes on the existing files. I tried in Pycharm > File > Make Directory Writeable but it did not help either. This question has been answered for Windows or Ubuntu but those commands do not work at least on my Mac. Anyone knows how to solve this issue?\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3519,"Q_Id":54502582,"Users Score":1,"Answer":"Open Terminal\n\nGo to you folder\ncd Desktop\/myfolder\n\nRun this command\nsudo chmod 777 -R *","Q_Score":1,"Tags":"python,django,macos,pycharm","A_Id":67901742,"CreationDate":"2019-02-03T11:55:00.000","Title":"Pycharm (JetBrains) cannot modify the read-only directory on my macbook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I need to develop a bunch of Python scripts pulling data from various sources asynchronously and populating a shared database. Everything will eventually run off AWS, while I do my developing locally on a Win10 machine.\nTo avoid any compatibility issues, I would like to get going with Docker for this project - but I'm not sure how to set up my environment for development. One option I can see might work is using PyCharm and their Docker plugin.\nWhat are the other options? I would like to be able to execute snippets of code directly from the editor in an interactive mode, on the back of a Docker image that I would then be able to deploy on AWS in large numbers.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":137,"Q_Id":54505658,"Users Score":1,"Answer":"Docker development can be very productive using either of these two options:\n\nYou can map source code volumes into a production image.\nThis works in the same way as a normal VM-based development cycle. Be careful with the number\/size of your mounts if you aren't developing on Linux.\nOptimise your Dockerfile for rebuild efficiency.\nDocker builds can be super fast if you do them carefully. This path is better (or necessary) if you are using swarm because it tends to depend on built images with proper digests.\n\nI have not found the PHPStorm Docker extension very helpful, and I suspect PyCharm would be similar. It is really just a wrapper to basic docker container build|run|ps.\nI'm not sure executing code snippets will be that easy, but there might be a way to pipe it into a running container.","Q_Score":0,"Tags":"python,docker,pycharm","A_Id":54509115,"CreationDate":"2019-02-03T17:41:00.000","Title":"Optimal environment setup for Python development with Docker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm reading a basic csv file where the columns are separated by commas. However, the body column is a string which may contain commas and quotations.\nFor example, there are some cells like \"Bahamas\\\", The\" and \"Germany, West\"\nI have tried \ntext = pd.read_table(\"input.txt\", encoding = 'utf-16', quotechar='\"', sep = ','),\ntext = pd.read_table(\"input.txt\", encoding = 'utf-16', quotechar='\"', delimiter = ','). But they both cannot work.\nIs there a way to go around this problem?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":372,"Q_Id":54509495,"Users Score":1,"Answer":"Are you able to regenerate the csv? If yes, change the delimit character to a pipe, I.e | . If not, you may be forced to take the long route... because there is no way for any code to figure out which characters are delimiting\/quoting and which are part of the value if you have both commas and quotes lurking inside the value.\nA workaround could involve leveraging the column position where this problem occurs... I.e first you could isolate the columns to the left of the troubled column, isolate all columns to the right, then all characters remaining are your troubled column. Can you post a few example rows? It would be good to see a few rows that have this issue, and a few that work fine","Q_Score":0,"Tags":"python,pandas","A_Id":54509633,"CreationDate":"2019-02-04T02:26:00.000","Title":"pandas read csv with extra commas and quotations in column","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have command.list file with command parameters for my python script my_script.py which have 3 parameters.\nOne line of which look like:\n<path1> <path2> -sc 4\nLooks like it not work like this because parameters should be split?\ncat command.list | xargs -I {} python3 my_script.py {}\nHow to split string to pararmeters and pass it to python script?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1874,"Q_Id":54511428,"Users Score":2,"Answer":"What about cat command.list | xargs -L 1 python3 my_script.py? This will pass one line (-L 1) at a time to your script.","Q_Score":0,"Tags":"python,bash,xargs","A_Id":54511656,"CreationDate":"2019-02-04T07:01:00.000","Title":"How to pass parameters from xargs to python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a large-ish YAML file (~40 lines) that I'm loading using PyYAML. This is of course parsed into a large-ish dictionary plus a couple of arrays.\nMy question is: how to manage the data. I can of course leave it in the output dictionary and work through the data. But I was wondering if it's better instead to mangle the data in a class or use a nametuple to hold the data.\nAny first-hand experience about that?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":250,"Q_Id":54512901,"Users Score":1,"Answer":"Whether you post-process the data structure into a class or not primarily has to do with how you are using that data. The same applies to the decision whether to use a tag or not and load (some off) the data from the YAML file into a specific instance of a class that way.\nThe primary advantage of using a class in both cases (post-processing, tagging) is that you can do additional tests during initialisation for consistency, that are not done on the key-value pairs of a dict or on the items of list.\nA class also allows you to provide methods to check values before they are set, e.g. to make sure they are of the right type. \nWhether that overhead is necessary depends on the project, who is using and\/or updating the data etc and how long this project and its data is going to live (i.e. are you still going to understand the data and its implicit structure a year from now). These are all issues for which a well designed (and documented) class can help,  at the cost of some extra work up-front.","Q_Score":0,"Tags":"python,dictionary,yaml,pyyaml,namedtuple","A_Id":54514384,"CreationDate":"2019-02-04T09:06:00.000","Title":"dictionary | class | namedtuple from YAML","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to setup tensorflow for python version 3.7.1 which was not supported and ended up wasting half Sunday.\nI want to know which versions of python does tensorflow supports?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7525,"Q_Id":54513388,"Users Score":0,"Answer":"Sorry i am only posting the question and i am only giving the answer for it.\nTENSORFLOW IS NOT SUPPORTED FOR PYTHON 3.7.X. \nPlease do not waste time even on trying also \nIt will throw an error on \"pywrap_internal.py\"\nFrom Anaconda create conda environment and install tensorflow package\nTry importing it.\nHope it helps.","Q_Score":2,"Tags":"python,tensorflow","A_Id":54513434,"CreationDate":"2019-02-04T09:39:00.000","Title":"Which version of python is supported in Tensorflow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to setup tensorflow for python version 3.7.1 which was not supported and ended up wasting half Sunday.\nI want to know which versions of python does tensorflow supports?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7525,"Q_Id":54513388,"Users Score":0,"Answer":"Tensorflow, for now only works with Python 3.6, 3.7 support is still in active development, make sure to install python 3.6 and try to set it up again, it should work","Q_Score":2,"Tags":"python,tensorflow","A_Id":54513430,"CreationDate":"2019-02-04T09:39:00.000","Title":"Which version of python is supported in Tensorflow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the SURF technique, and more precisely within the feature description stage, the authors have stated (if I understand correctly) that the description will be performed in a area of 20 times sigma. Sigma represents the scale on which the keypoint was detected.\nSigma = 0.4 x L where L = 2^Octave  x level+1. If we use the OpenCV implementation, the DetectAndCompute function computes, with the value of Keypoint.size, the radius of the circle surrounding the keypoint. \nMy question is : How could we get the value of sigma from the radius value  ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":54517035,"Users Score":0,"Answer":"This value s = size*1.2f\/9.0f is not montioned in the bay's article scale= L*0.4 or \nscale= L* 1.2\/3 any one can explain me this part??","Q_Score":0,"Tags":"opencv,image-processing,computer-vision,surf,opencv-python","A_Id":54530692,"CreationDate":"2019-02-04T13:19:00.000","Title":"SURF: How could we get the value of sigma from the keypoint radius","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I write pyspark code to deal with some spark-sql data. \nLast month, it worked perfectly when I ran spark-submit --master local[25]. From top command, I could see 25 python threads.\nHowever, nothing change but today the spark-submit only create one thread. I wonder what kind of things can cause such problem.\nThis is on a ubuntu server on AWS, which has 16 CPU cores. The Spark version is 2.2.1 and Python is 3.6","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":68,"Q_Id":54521867,"Users Score":1,"Answer":"Just find the problem: there is another user running his own spark task on the same instance which occupying resources.","Q_Score":0,"Tags":"python,apache-spark,pyspark","A_Id":54541372,"CreationDate":"2019-02-04T18:03:00.000","Title":"spark-submit --master local[n] cannot create multi-threads","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to coding and just started using Visual Studio to learn Python.  In a tutorial video, the professor said that I can hit Ctrl + Alt + N to automatically run my code.  I get the error \"[Running] python -u \"c:\\Users***\\Desktop\\Test\\app.py\"\n'python' is not recognized as an internal or external command,\noperable program or batch file.\"\nI am able to run it when I go to my terminal and run through CMD but not when I do the shortcut.  I looked through settings and there wasn't anything I saw that stood out.  Any suggestions?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":54522668,"Users Score":0,"Answer":"Open the Start Search, type in \u201cenv\u201d, and choose \u201cEdit the system environment variables\u201d:\nClick the \u201cEnvironment Variables\u2026\u201d button\nClick on Path variable\nClick on edit button\nCreate a new address, where you have installed python. The default address is C:\\Python34\nSave and exit the window\nInstall Python extension on VScode\nRestart VScode\nIf problem continues then, open command pallete( CTRL + Shift + p )\n\n9.1. Type Python\n9.2. Select python interpreter from the drop down menu","Q_Score":0,"Tags":"python,visual-studio","A_Id":70194562,"CreationDate":"2019-02-04T19:01:00.000","Title":"Visual Studio Error Ctrl + Alt + N with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm programming a 2D game with Python and Pygame and now I want to use my internal graphics memory to load images to.\nI have an Intel HD graphics card (2GB VRAM) and a Nvidia GeForce (4GB VRAM).\nI want to use one of them to load images from the hard drive to it (to use the images from there).\nI thought it might be a good idea as I don't (almost) need the VRAM otherwise.\nCan you tell me if and how it is possible? I do not need GPU-Acceleration.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2376,"Q_Id":54524347,"Users Score":0,"Answer":"You have to create your window with the FULLSCREEN, DOUBLEBUF and HWSURFACE flags.\nThen you can create and use a hardware surface by creating it with the HWSURFACE flag.\nYou'll also have to use pygame.display.flip() instead of pygame.display.update().\nBut even pygame itself discourages using hardware surfaces, since they have a bunch of disadvantages, like\n- no mouse cursor\n- only working in fullscreen (at least that's what pygame's documentation says)\n- you can't easily manipulate the surfaces\n- they may not work on all platforms \n(and I never got transparency to work with them).\nAnd it's not even clear if you really get a notable performance boot.\nMaybe they'll work better in a future pygame release when pygame switches to SDL 2 and uses SDL_TEXTURE instead of SDL_HWSURFACE, who knows....","Q_Score":0,"Tags":"python,pygame","A_Id":54532945,"CreationDate":"2019-02-04T21:09:00.000","Title":"Use VRAM (graphics card memory) in pygame for images","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python environment (it could be conda, virtualenv, venv or global python) - I have a python script - hello.py - that I want to execute within that environment. \nIf I get the path to the python binary within the environment, for example, in windows with a conda environment called myenv, \/path\/to\/myenv\/Scripts\/python.exe,  and if I execute the script using that python, as shown below, am I guaranteed that the script is executed in that environment, independent of the type of virtual environment? If not, what can I do to ensure such a guarantee?\n\/path\/to\/myenv\/Scripts\/python.exe path\/to\/hello.py","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":811,"Q_Id":54525141,"Users Score":0,"Answer":"I suspect not. There are a few environment variables (e.g. PATH) which are changed when you activate a virtualenv. You can open up myenv\/bin\/activate in a text editor to see what it does.\nIs there a particular reason you want to call the executable directly, rather than use the environment as designed? (e.g. . .\/myenv\/bin\/activate; python hello.py)","Q_Score":1,"Tags":"python,virtualenv,conda,python-venv","A_Id":54526278,"CreationDate":"2019-02-04T22:16:00.000","Title":"How to execute a python script within a virtual environment using the python binary path?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've been working on a project in a Jupyter notebook, and wanted to use dedupe. Through anaconda, only dedupe-hcluster is available on a windows machine, so I installed that and attempted to import hcluster within the notebook, which gave this error:\n\"ImportError: DLL load failed: %1 is not a valid Win32 application.\"\nFrom what I've read up on, this means that either Python is 32 bit whilst hcluster is 64 bit, or vice versa. It's not clear to me however how to fix this.\nI then tried to convert the notebook into a Pycharm script so that I may use another version of dedupe, either dedupe, dedupe-hcluster or pandas-dedupe. I had issues installing pandas-dedupe, so went with the two former. Importing dedupe gives this error:\n\"ImportError: No module named _lowlevel\"\nand importing hcluster gives this error:\n\"ImportError: cannot import name _hierarchy\"\nI've done what feels like endless reading on all 3 of these issues and am no closer to solving any of them.\nAny suggestions on how to fix any of the above will be much appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":160,"Q_Id":54526204,"Users Score":1,"Answer":"If you are using Anaconda and a Jupyter notebook, make sure your Anaconda environment is active in your notebook.","Q_Score":0,"Tags":"python,jupyter","A_Id":54738413,"CreationDate":"2019-02-05T00:18:00.000","Title":"ImportError: cannot import name _hierarchy or DLL load failed: %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":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python code which reads data from one cloud system via rest api using the requests module and then writes data back to another cloud system via rest api . This code runs anywhere from 1 to 4 hours every week. Is there a place in Google Cloud Platform , I can execute this code on a periodic basis. Sort of like a scheduled batch job . Is there a serverless option to  do this in App Engine . I know about the App engine cron service but seems like it is only for calling a URL  regularly . Any thoughts ? Appreciate your help.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":362,"Q_Id":54526638,"Users Score":0,"Answer":"You can use AI Platform Training to run any arbitrary Python package \u2014 it doesn\u2019t have to be a machine learning job.","Q_Score":0,"Tags":"python-3.x,google-cloud-platform","A_Id":58162476,"CreationDate":"2019-02-05T01:23:00.000","Title":"Advise needed - Running Python code on GOOGLE CLOUD PLATFORM serverless","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"New to coding; I just downloaded the full Anaconda package for Python 3.7 onto my Mac. However, I can't successfully import Pandas into my program on SublimeText when running my Python3.7 build. It DOES work though, when I change the build to Python 2.7. Any idea how I can get it to properly import when running 3.7 on SublimeText? I'd just like to be able to execute the code within Sublime.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":54527093,"Users Score":0,"Answer":"Uninstall python 2.7. Unless you use it, its better to uninstall it.","Q_Score":0,"Tags":"python,pandas,macos,import,sublimetext3","A_Id":54527171,"CreationDate":"2019-02-05T02:42:00.000","Title":"Installed Anaconda to macOS that has Python2.7 and 3.7. Pandas only importing to 2.7; how can I import to 3.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a super tedious issue with VSCode (run in POP!) wherein it will revert my changes back a few steps after I save or if I leave the code pane open for a while without any typing.  I only use VScode for Python and the only extension I have is 'Python' by Microsoft.\nThis is an issue because my current project has numerous modules some of which have many lines of code and when VScode makes random reverts it sometimes takes time to find why my code no longer runs.\nSome other information:\n\nIf I am watching, I can see the code changing\nI recently figured out I can ctrl-z the reverts back to my code if I\nhaven't changed panes\n\nWhat am I missing in VScode which may do this?\nEDIT: For this given project, all my files are stored in my SpiderOak Hive (folder synced across a few computers).  I think the problem may have to do with the syncing software pushing the updated file to the other synced computers.  But that is just my working theory right now.  I'm testing it against local python files, which is also tough, because typing meaningless python code is tedious.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1338,"Q_Id":54527254,"Users Score":0,"Answer":"So, the issue derived from the SpiderOak sync.  I don't know the mechanics of it, but depending on when I saved a file in respect to a periodic sync led to the revert or not.","Q_Score":4,"Tags":"python,visual-studio-code","A_Id":54726564,"CreationDate":"2019-02-05T03:09:00.000","Title":"How to stop VScode reverting my changes after save","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Day in and out I often need to create virtual machines in the Azure, I am thinking of using Azure API to automate this task. However, the Azure API requires the client ID and secret for authentication purpose.\nI did search Google on how can I retrieve this info, but everything points me to register a new Application to get a client and secret ID. But in my case, I just want to launch and terminate VMs and do not understand the rationale behind registering an APP for this purpose.\nCan I get the client and sec Id without registering an APP? If yes, can someone point me in the right direction?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4266,"Q_Id":54527309,"Users Score":1,"Answer":"You need to register an app, because that is the identity your script will use.\nAny user or app interacting with a subscription needs an identity in the linked AAD + access granted via Azure RBAC.\nRegister a Web App\/API, and then just grab the client id (application id) and create a key (secret). \nThen go to the subscription \/ resource group \/ resource and give the app the necessary access from the Access Control IAM tab.","Q_Score":0,"Tags":"python,azure,azure-devops,azure-active-directory","A_Id":54528425,"CreationDate":"2019-02-05T03:19:00.000","Title":"How do I retrieve client ID and secret in Azure to use creating and destroying Virtual Machines?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am being able to run pip commands inside a virtual environment. However, on using this outside the virtual environment, I get the following error:\n\n-bash: pip: command not found\n\nAny idea on what is wrong and how I can fix this?\nThanks!","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":654,"Q_Id":54528729,"Users Score":1,"Answer":"usually pip comes with the default python, either you don't have the default python, or not set in your environment path,\nI would suggest first to check if you have python by typing these following commands\npython --version\nfor python 3\npython3 --version\nthen install pip for which ever version you have by using the correspoding commands\nsudo apt-get install python-pip\nsudo apt-get install python3-pip\nfor python3\nthis is only applicable to ubuntu or debian systems","Q_Score":0,"Tags":"python-3.x,pip,virtual-environment","A_Id":54528839,"CreationDate":"2019-02-05T06:23:00.000","Title":"'pip' not working outside of virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a simple binary classification problem, and I want to assess the learning feasibility using Hoeffding's Inequality and also if possible VC dimension. \nI understand the theory but, I am still stuck on how to implement it in Python.\nI understand that In-sample Error (Ein) is the training Error. Out of sample Error(Eout) is the error on the test subsample I guess.\nBut how do I plot the difference between these two errors with the Hoeffdings bound?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":172,"Q_Id":54534664,"Users Score":0,"Answer":"Well here is how I handled it : I generate multiple train\/test samples, run the algorithm on them, calculate Ein as the train set error, Eout estimated by the test set error, calculate how many times their differnces exceeds the value of epsilon (for a range of epsilons). And then I plot the curve of these rates of exceeding epsilon and the curve of the right side of the Hoeffding's \/VC inequality so I see if the differences curve is always under the Hoeffding\/VC's Bound curve, this informs me about the learning feasiblity.","Q_Score":0,"Tags":"python,machine-learning","A_Id":54809376,"CreationDate":"2019-02-05T12:40:00.000","Title":"How to check learning feasibility on a binary classification problem with Hoeffding's inequality\/VC dimension with Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have successfully installed flask_bcrypt package using anaconda pip. But I am having a weird problem when I try to import it .Using windows cmd it works well but it fails when I try to do it through anaconda prompt command, jupyter or Spyder ? I tried to restart them and run the command but still having the same problem.Using either jupyter notebook it throws an import error 'cannot import name '_bcrypt'\nbcrypt is required to use Flask-Bcrypt\nImportError                               Traceback (most recent call last)\n in ()\n----> 1 from flask_bcrypt import Bcrypt\n~\\Anaconda3\\lib\\site-packages\\flask_bcrypt.py in ()\n     25 except ImportError as e:\n     26     print('bcrypt is required to use Flask-Bcrypt')\n---> 27     raise e\n     28 \n     29 from sys import version_info\n~\\Anaconda3\\lib\\site-packages\\flask_bcrypt.py in ()\n     22 \n     23 try:\n---> 24     import bcrypt\n     25 except ImportError as e:\n     26     print('bcrypt is required to use Flask-Bcrypt')\nC:\\python\\Lib\\site-packages\\bcrypt__init__.py in ()\n     23 import six\n     24 \n---> 25 from . import _bcrypt\n     26 from .about import (\n     27     author, copyright, email, license, summary, title,\nImportError: cannot import name '_bcrypt'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":687,"Q_Id":54540020,"Users Score":0,"Answer":"Have you installed bcrypt? Note flask-bcrypt!= bcrypt.","Q_Score":0,"Tags":"python,bcrypt","A_Id":54544870,"CreationDate":"2019-02-05T17:31:00.000","Title":"import bcrypt fails on anaconda cmd and throws an error \"cannot import _bcrpyt\" but works on windows cmd?","Data 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 running the command pybot --version\nI'm getting the error \n\nfrom robot import run_cli ImportError: No module named robot\n\nI have already installed robotframework 3.0 with python after downloading the module with its setup.py file.\nI tried installing and reinstalling it multiple times.\nAlso I have verified the environment variables for the same which also seems to be inline with what I have installed.\nI checked in the site-packages also where I am able to see robotframework 3.0 present in them.\nI checked in the \/usr\/local\/bin as well as \/home\/.local\/bin folder I can see both robot and pybot available. But for running the command robot --version also it is showing the same error.\nI really don't know what is missing.\nMy Environment:\n\nUbuntu 16.04\npython 2.76\nrobotframework 3.0\n\nThanks in Advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3544,"Q_Id":54540608,"Users Score":0,"Answer":"I have little experience on installing the ROBOT Framework in linux machine. But just check whether you have done the following:\n\nHow did you install ROBOT Framework? Is it by pip command or with the downloaded source file? Have you tried with pip command if any?\nSet python path in your environment path\/variables. Example in windows, C:\\Python27\\\nSet python scripts folder in your environment path\/variables. Example in windows C:\\Python27\\Scripts\n\nLast, maybe you can share the output of your 'pip list' command? So, just want to see what are the modules\/packages that you have installed.","Q_Score":0,"Tags":"python,robotframework","A_Id":54610193,"CreationDate":"2019-02-05T18:13:00.000","Title":"Getting the error \"from robot import run_cli ImportError: No module named robot\" even when robotframework was installed in the 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As the title say, let's assume I have a plane equation:\n\nax+by+cz=d    (e.g. -4x + 5y + 9z = -9)\n\nI want to draw n random points (let's say 500) that belong to that plane.\nCan somebody help me with that?\nI saw that from mpl_toolkits import mplot3d has the function plot_surface(x,y,z) but (as it says) it plots the surface equation and this is not what I need.\nAny help is really appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":446,"Q_Id":54540676,"Users Score":1,"Answer":"For a plane a simple approach that would work is\n\npick a coefficient that's not 0 (let's suppose is c)\npick random values for the other two coordinates (x and y in this case)\ncompute z with (d - ax - by)\/c","Q_Score":1,"Tags":"python,matplotlib,linear-algebra,mplot3d","A_Id":54540745,"CreationDate":"2019-02-05T18:17:00.000","Title":"Python: given a plane equation draw a subset of points that belong to it","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a very long running python script, that cannot be parallelized (so it is single threaded = running only with one process).\n\nThis job runs several days on my own computer. \nIt does not benefit from any GPU support. \nFor analysis and parameter optimization, I assume to run this job several times; perhaps 10 - 20 times with each time different parameters.\nAs my own existing computer ressources are limited, I would like to use a powerful cloud CPU for this task.\nIf I realize that the cloud CPUs are really much faster than my own CPU, I probably will migrate the job from e.g. AWS EC2 (Amazon Web Services) to a cheaper flat rate solution like Hetzner.\n\nWith this use case: does it make sense to put my setup in a docker container?\nOr does this task not justify the effort for engineering and taking the learning curve in docker \/ docker compose etc.?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":47,"Q_Id":54541585,"Users Score":1,"Answer":"Docker will make it much easier for you to run your application in the cloud in the sense that, you will be able to switch machines much easier.  In addition, it will make it easy to run it cheaper, because you won't have to spend alot of time spinning up your VMs, and can cheaply and easily spin VMs down, knowing that only docker run and no specific python or yum install steps have to be done to bootstrap the program.","Q_Score":0,"Tags":"python,docker","A_Id":54561281,"CreationDate":"2019-02-05T19:19:00.000","Title":"Cloud computing: when is the effort for using docker justified?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am wondering if it is okay in style perspective to include for loop in __init__ function of a class.\nGiven a list of integers I am trying to generate another_list that stores differences in current value and next value. However I would like to use another_list for more than one method within the class. So I was thinking about creating another_list in __init__ function rather than converting it for every method. Is this the most simplest way? what is the conventional style?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4492,"Q_Id":54543549,"Users Score":0,"Answer":"There's no limits on what you must or should write in __init__. Loops is no different. If you think that you need to calculate instance attribute via loop \u2013 go for it.\nEverything that is part of object state [logically] should be saved as attribute, there's no reason to re-compute it, if it is not a dynamic argument for other methods. This is kinda basic idea behind the OOP that python follows.","Q_Score":2,"Tags":"python,class,init","A_Id":54543611,"CreationDate":"2019-02-05T21:45:00.000","Title":"loop in __init__ function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Apparently pandas.read_sas can only read XPORT or SAS7BDAT format SAS files while Dispatch from wind32com.client can read .jmp format but only on windows. So is there a straightforward way to read in JMP files with Python on a Mac?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":760,"Q_Id":54544028,"Users Score":0,"Answer":"As of Feb 2019 it doesn't seem possible to read in .jmp files using Python on a Mac. The best option is probably to get a 30-day trial of JMP software and convert .jmp files to csv or something from there. You can also read SAS files (not .jmp) in R with haven::read_sas().","Q_Score":1,"Tags":"python,sas-jmp","A_Id":54714237,"CreationDate":"2019-02-05T22:28:00.000","Title":"Reading .jmp files with Python on a Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on a multivariate (100+ variables) multi-step (t1 to t30) forecasting problem where the time series frequency is every 1 minute. The problem requires to forecast one of the 100+ variables as target.\nI'm interested to know if it's possible to do it using FB Prophet's Python API. I was able to do it in a univariate fashion using only the target variable and the datetime variable. Any help and direction is appreciated. Please let me know if any further input or clarity is needed on the question.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28022,"Q_Id":54544285,"Users Score":0,"Answer":"This might be late, however if you are reading this in 2019, you can implement multivariate time series using LSTM, Keras.","Q_Score":31,"Tags":"python,machine-learning,time-series,forecasting,facebook-prophet","A_Id":57832051,"CreationDate":"2019-02-05T22:54:00.000","Title":"Is it possible to do multivariate multi-step forecasting using FB Prophet?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a data-frame of size (140000,22) dimensions.\ni have to create 2d array of equal dimensions to pass it into convolution neural network .\nCan you please guide how to transform on this dataframe","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":21926,"Q_Id":54549284,"Users Score":15,"Answer":"You just need to call .values on the DataFrame.\nIf for example your dataframe is called df, then you can pass df.values to your convolutional neural network.","Q_Score":9,"Tags":"python,dataframe,conv-neural-network,convolution","A_Id":54551132,"CreationDate":"2019-02-06T08:25:00.000","Title":"convert Dataframe to 2d Array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a table on Hive and I am trying to insert data in that table. I am taking data from SQL but I don't want to insert id which already exists in the Hive table. I am trying to use the same condition like where not exists. I am using PySpark on Airflow.","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":4869,"Q_Id":54550161,"Users Score":-1,"Answer":"IMHO I don't think exists such a property in Spark. I think you can use 2 approaches:\n\nA workaround with the UNIQUE condition (typical of relational DB): in this way when you try to insert (in append mode) an already existing record you'll get an exception that you can properly handle.\nRead the table in which you want to write, outer join it with the data that you want to add to the aforementioned table and then write the result in overwrite mode (but I think that the first solution may be better in performance).\n\nFor more details feel free to ask","Q_Score":2,"Tags":"python,hive,pyspark,airflow,pyspark-sql","A_Id":54550984,"CreationDate":"2019-02-06T09:21:00.000","Title":"How can I use \"where not exists\" SQL condition in pyspark?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a use case in selenium in which the priority of test functions are important. I'm using LiveServerTestCase in flask for tests.\nIn Java, there is a decorator @Test(priority=0) for defining test priorities. My question is what is the equivalent in Flask?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":153,"Q_Id":54551456,"Users Score":0,"Answer":"Test functions are executed according to their names(alphabetical order).","Q_Score":2,"Tags":"python,selenium,liveservertestcase","A_Id":54744338,"CreationDate":"2019-02-06T10:32:00.000","Title":"Selenium test priority in Flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Whenever I run pip to install the Flask packages like virtualenv in Ubuntu 16.04, I get this error:\npip install virtualenv\nRequirement already satisfied: virtualenv in .\/.local\/lib\/python3.5\/site-packages (16.1.0)\nNo metadata found in .\/.local\/lib\/python3.5\/site-packages\nCould not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '\/usr\/.local\/lib\/python3.5\/site-packages\/virtualenv-16.1.0.dist-info\/METADATA'\nHere are my pip and python versions:\npip --version\npip 19.0.1 from \/usr\/.local\/lib\/python3.5\/site-packages\/pip (python 3.5)\npython3 --version\nPython 3.6.8\nI already tried almost all that I get from the internet to solve this issue like:\n\/usr\/.local\/bin\/pip install virtualenv\nBut I still get the same error.\nI also go into the dist folder to copy the metadata.json with METADATA, but there's no metadata.json file inside.\ncd \/usr\/.local\/lib\/python3.5\/site-packages\/virtualenv-16.1.0.dist-info\/\n\ncp metadata.json METADATA\ncp: cannot stat 'metadata.json': No such file or directory\nPlease help me, I'm stucked with this issue for days. \nThanks!","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":39362,"Q_Id":54552367,"Users Score":0,"Answer":"conda install -c conda-forge requests solved my problem. Of course, you need to reinstall the package that is problematic for you. Using pip to reinstall it did not work for me.","Q_Score":9,"Tags":"python,python-3.x,pip,virtualenv,ubuntu-16.04","A_Id":63614520,"CreationDate":"2019-02-06T11:17:00.000","Title":"Pip cannot find metadata file - EnvironmentError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I run pip to install the Flask packages like virtualenv in Ubuntu 16.04, I get this error:\npip install virtualenv\nRequirement already satisfied: virtualenv in .\/.local\/lib\/python3.5\/site-packages (16.1.0)\nNo metadata found in .\/.local\/lib\/python3.5\/site-packages\nCould not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '\/usr\/.local\/lib\/python3.5\/site-packages\/virtualenv-16.1.0.dist-info\/METADATA'\nHere are my pip and python versions:\npip --version\npip 19.0.1 from \/usr\/.local\/lib\/python3.5\/site-packages\/pip (python 3.5)\npython3 --version\nPython 3.6.8\nI already tried almost all that I get from the internet to solve this issue like:\n\/usr\/.local\/bin\/pip install virtualenv\nBut I still get the same error.\nI also go into the dist folder to copy the metadata.json with METADATA, but there's no metadata.json file inside.\ncd \/usr\/.local\/lib\/python3.5\/site-packages\/virtualenv-16.1.0.dist-info\/\n\ncp metadata.json METADATA\ncp: cannot stat 'metadata.json': No such file or directory\nPlease help me, I'm stucked with this issue for days. \nThanks!","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":39362,"Q_Id":54552367,"Users Score":0,"Answer":"do \"pip install cython\" if you use python or do \"pip3 install cython\" if you use python3.  I try so many different way and this finally works for me.\nCheck your actual error message, my error message was\n\"  note: This error originates from a subprocess, and is likely not a problem with pip.\nerror: legacy-install-failure\n\u00d7 Encountered error while trying to install package.\n\u2570\u2500> cytoolz\"","Q_Score":9,"Tags":"python,python-3.x,pip,virtualenv,ubuntu-16.04","A_Id":71884309,"CreationDate":"2019-02-06T11:17:00.000","Title":"Pip cannot find metadata file - EnvironmentError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I run pip to install the Flask packages like virtualenv in Ubuntu 16.04, I get this error:\npip install virtualenv\nRequirement already satisfied: virtualenv in .\/.local\/lib\/python3.5\/site-packages (16.1.0)\nNo metadata found in .\/.local\/lib\/python3.5\/site-packages\nCould not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '\/usr\/.local\/lib\/python3.5\/site-packages\/virtualenv-16.1.0.dist-info\/METADATA'\nHere are my pip and python versions:\npip --version\npip 19.0.1 from \/usr\/.local\/lib\/python3.5\/site-packages\/pip (python 3.5)\npython3 --version\nPython 3.6.8\nI already tried almost all that I get from the internet to solve this issue like:\n\/usr\/.local\/bin\/pip install virtualenv\nBut I still get the same error.\nI also go into the dist folder to copy the metadata.json with METADATA, but there's no metadata.json file inside.\ncd \/usr\/.local\/lib\/python3.5\/site-packages\/virtualenv-16.1.0.dist-info\/\n\ncp metadata.json METADATA\ncp: cannot stat 'metadata.json': No such file or directory\nPlease help me, I'm stucked with this issue for days. \nThanks!","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":39362,"Q_Id":54552367,"Users Score":6,"Answer":"I just ran into this with a different package, using Python 3.6.5 and pip 19.2.3.  I was hesitant to use the solutions here (and on similar SO questions) so I just tried the following and it cleared up the issue:\npip install --force-reinstall package_with_metadata_issue\nNote that my case was complaining about the black package, which was a dependency of something else I was trying to install (with a simple pip install other_package). Black had already been installed and working on my system for a while, so it's unclear how it got into a bad state or what changed in pip such that it couldn't handle the package's state.\nTo be specific, the OP could try:\npip install --force-reinstall virtualenv\nThough it seems like many other people here had an issue with pip itself, so that may just be kicking the can down the road until pip is in a good state.","Q_Score":9,"Tags":"python,python-3.x,pip,virtualenv,ubuntu-16.04","A_Id":58082184,"CreationDate":"2019-02-06T11:17:00.000","Title":"Pip cannot find metadata file - EnvironmentError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Assume that I have a file in memory (submitted by a HTTP POST request) and a handler f for that file. I need to convert the content of the file into an JSON object and use it multiple time (the content is modified each time), so which of the following 2 approaches is preferable?  \n\nRead the content of the file multiple times (with the help of f.seek(0)) and convert it to a new JSON object every time I need the data.\nRead the content of the file and convert it to an JSON object once, and use a deepcopy of the object every time I need the data.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":141,"Q_Id":54553693,"Users Score":1,"Answer":"By performing a read each time, you are performing an I\/O operation with your Hard Drive.\nIn comparison, by using deepcopy you are only working with the RAM memory. \nGiven that RAM memory access is much faster than Hard Drive access, I recommend the deepcopy method over the read method in terms of speed. \nNOTE: If your JSON object is unmutable (e.g.: a Python string) you don't need to perform deepcopy each time, since you get a new object everytime you perform a change in the original object","Q_Score":0,"Tags":"python","A_Id":54553800,"CreationDate":"2019-02-06T12:28:00.000","Title":"Read a file multiple time or read once and use deepcopy on the result?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a logistic regression model in python 3 using sklearn library.\nLet's stick to below short versions going forward,\ndv - dependent variable \nidv - independent variable\nNow I have idv1, idv2, idv3, idv4, idv5, idv6, idv7, idv8 & idv9.\nOut of which idv6 to idv9 are categorical variables (idv6 & idv7 has 3 categories..where as idv8 & idv9 are boolean variables..yes or no kind of variables [0 or 1])\nAnd dv is again a boolean variable (yes or no kind of variable).\nNow, I have created a dummies for all idv6 to idv9 for the final model data...i.e idv6_c1, idv6_c2, idv_c3 and followed similar for the remaining..like idv8_c1, idv8_c2 for idv8 & idv9.\nNow, after fitting the model and finding the metrics of the predicted values...\nI am getting let's say accuracy_score of 76.7415479670124 % and  precision_score of 76.7415479670124 %\nI have calculated using sklearn.metrics.accuracy_score and sklearn.metrics.precision_score libraries.\nI am wondering..is this correct or am I missing something...??\nCan this happen ??...accuracy & precision to be equal to almost 13 decimals ???....I am sure...I am doing something wrong...can anyone please help me ??","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":780,"Q_Id":54557082,"Users Score":2,"Answer":"Precision = True Positive \/ (True Positive + False Positive)\nAccuracy = (True Positive + True Negative) \/ (True Positive + False Positive + True Negative + False Negative)\nTherefore, if there are no negative predictions, these two values will be equal.","Q_Score":1,"Tags":"python,scikit-learn,logistic-regression,sklearn-pandas","A_Id":54557235,"CreationDate":"2019-02-06T15:27:00.000","Title":"Can accuracy_score and precision_score be equal?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In MATLAB, binofit returns the maximum likelihood estimate of the success of binomial probability distribution and confidence intervals. \nstatsmodels.stats.proportion.proportion_confint returns confidence intervals as well, but couldn't find a function for maximum likelihood estimate of the binomial probability distribution. Is there any function that you can suggest as a binofit function in MATLAB for python?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":319,"Q_Id":54559209,"Users Score":1,"Answer":"I think the function you suggested is good enough. I ran some test comparing Matlab binofit and Python statsmodels.stats.proportion.proportion_confint. The test was empyrical like testin 100K experiments like [phat,pci] = binofit(x,n,alpha) with min_conf,max_conf = proportion_confint(x,n,alpha=alpha,method='beta').\nThe RMSE bewteen confidence interval limits from Matlab and Python are below 5e-6 for values values of x and n between 0 and 10000. Tested with alpha=0.05 and 0.01.\nI know this is not strict demonstrations but for my project I decided to consider the two estimates of confidence intervals as equivalent.","Q_Score":0,"Tags":"python,python-2.7","A_Id":56294966,"CreationDate":"2019-02-06T17:21:00.000","Title":"Python equivalent for MATLAB binofit","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently developing an embedded multi-touch kivy program with python 3.52 in linux. Kivy is good, but I find GUI developing is quite difficult in some way, and animations are often quite laggy.\nAlso, I found that the program gets quite slow if I put many widgets in a single page. My program contains a lot of widgets so I am also thinking implementing a webview could help.\nSo I am looking for html and css views in particular screens for better look and feel (and maybe improvement of animation by using transition?).\nI've found Cefpython, but it says it works only for python 2.7 and says it is not stable. And it seemed like it is just getting url from the internet not bringing html and css from a file system. (Correct me if I am wrong.)\nActually, I don't even need a function as a browser, and all I need is html & css for UI\/UX development for couple of screens. \nMy embedded system doesn't always support internet(meaning it should work without internet). So I can't put any url in it. Once again, I am only trying to use them for styling. Is there a good way of doing it? Or there is no such thing that I want?\nOr is there any other recommendation?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4686,"Q_Id":54559271,"Users Score":1,"Answer":"No, unless you are willing to implement html and css parsers and a web renderers, of course. I would say it's better to find why you find it difficult to do certain things with kivy, and how to remedy that. I've yet to find an UI\/layout\/template that is easier to do with the web technologies than with kivy, but i'm way more profficient at kivy than at web front end, so i might be biased.","Q_Score":5,"Tags":"python,html,css,embedded,kivy","A_Id":54582469,"CreationDate":"2019-02-06T17:24:00.000","Title":"Can I use html&css in kivy and python3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to get into deep learning. I installed Anaconda to use jupyter and generally not to care about installing all of those packages like matplotlib etc myself. But I cannot install tensorflow as it works only with Python  3.4, 3.5, or 3.6 but I have 3.7. After I read about it I installed python 3.6.8. I uninstalled Anaconda and installed it again, nothing changed. After that, I used this command \n\nconda install python=3.6.8\n\nto presumably install python 3.6.8 for it (I found this solution somewhere on the web). The command worked but didn't change anything. Please help","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88747,"Q_Id":54559566,"Users Score":0,"Answer":"You just can change the python version by creating a new environment in anaconda.\nIt will ask for the python version when you create an environment","Q_Score":18,"Tags":"python,tensorflow,anaconda,jupyter-notebook,jupyter","A_Id":66913904,"CreationDate":"2019-02-06T17:41:00.000","Title":"How to change python version in Anaconda?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have files that cannot be renamed without white spaces (work files). The file name is Evo PROG6001  FSJD0250240  E.PART stored in a variable file. If I run os.system('start ' \"'\" + file + \"'\") it only recognizes the word Evo and returns Windows cannot find \"Evo\". Make sure you types the name correctly, and then try again. The same thing occurs with os.system('start ' + file).\nIs there a way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":828,"Q_Id":54561160,"Users Score":2,"Answer":"I needed to use os.startfile() and also point it to the root directory, which I had stored previously.\nos.startfile(new_folder + '\\\\' + file) works","Q_Score":0,"Tags":"python","A_Id":54561346,"CreationDate":"2019-02-06T19:27:00.000","Title":"How to open a file with Python with white spaces in the name?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Please help me with this. I'd really appreciate it. I have tried alot of things but nothing is working, Please suggest any ideas you have.\nThis is what it keeps saying:\n     name = imput('hello')\nNameError: name 'imput' is not defined","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":54561923,"Users Score":1,"Answer":"You misspelled input as imput. imput() is not a function that python recognizes - thus, it assumes it's the name of some variable, searches for wherever that variable was declared, and finds nothing. So it says \"this is undefined\" and raises an error.","Q_Score":0,"Tags":"python-3.x","A_Id":54561947,"CreationDate":"2019-02-06T20:20:00.000","Title":"python keeps saying that 'imput is undefined. how do I fix this?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a beginner question but I am using Atom and when I create classes in one file and then import those classes using import file_containing_classes to use them in another file it only sees one of the classes? Does it have something to do with __pycache__. Even after I run the file save the file, the python script that imports the file with classes doesn't recognize it.\nSuggestions?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":175,"Q_Id":54562635,"Users Score":0,"Answer":"I think the issue has something to do with the fact I have hydrogen installed, once I ran the code like a hydrogen notebook it seems to have worked.","Q_Score":0,"Tags":"python,atom-editor","A_Id":54564044,"CreationDate":"2019-02-06T21:12:00.000","Title":"Atom doesn't recognize classes imported from another file -- 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 working with string comparison in Python. Why does 'aa' < 'z' evaluate to True.\nFurther, why does 'aa' < 'a' evaluate to False. I tried explaining 'aa' is of a longer length than 'a' so it would be greater. But this reasoning does not work for the initial case 'aa' < 'z'\n'aa' < 'z' => True\n'aa' < 'a' => False","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1316,"Q_Id":54562774,"Users Score":1,"Answer":"They're in dictionary order. Alphabetical order first, length as a tie breaker. Just like in a dictionary, a precedes aa which precedes z.","Q_Score":0,"Tags":"python,string,comparison,string-comparison","A_Id":54562796,"CreationDate":"2019-02-06T21:26:00.000","Title":"Why does 'aa' < 'z' evaluate to True in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a custom shelf in Maya with buttons built using the 'shelfButton' command. I would like to include short descriptions of what the button does when the mouse cursor hovers over the button. I have tried a couple of the available flags, like 'annotation,' but so far I have not gotten anything useful.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":54563468,"Users Score":1,"Answer":"shelfButton command inside Maya has no flag for the desired behavior. Any string passed with the annotation flag will be displayed on Maya's native help box (At the buttom of the Maya UI). If you really want the behavior you may have to look into Qt.","Q_Score":1,"Tags":"python,maya","A_Id":54567799,"CreationDate":"2019-02-06T22:21:00.000","Title":"I would like to create docs for a shelf button in Maya when the mouse hovers over the button","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use the h2o package. I'm running macOS Mojave with Anaconda installed. \nI've done a pip install h2o and it was successful. It installed at location \/anaconda\/lib\/python3.6\/site-packages. \nI try to import it and get this error message: \"H2O requires colorama module of version 0.3.8 or newer. You have version 0.3.7.\"\nBut when I do pip show colorama it says I have version 0.4.1, so the error message doesn't make sense. It's installed at the same location as h2o at  \/anaconda\/lib\/python3.6\/site-packages\nAny thoughts?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":222,"Q_Id":54564735,"Users Score":1,"Answer":"If you are using Anaconda, I would recommend creating a new conda environment and then conda installing all the packages you need (for H2O you would use conda install -c h2oai h2o=3.22.1.2 ). This will help prevent package conflicts or having trouble pointing to the correct version.\nyou should also run conda list to see whether you have another version of colorma installed. Alternatively, you could do a pip uninstall colorama and see whether H2O still picks up a 0.3.7 version - at the very least it will help reveal whether you have multiple versions.","Q_Score":0,"Tags":"python,installation,version,h2o,colorama","A_Id":54581287,"CreationDate":"2019-02-07T00:40:00.000","Title":"Python package thinks I have older version of dependency than I do","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Here is a scenario for a system where I am trying to understand what is what:\nI'm Joe, a novice programmer and I'm broke. I've got a Flask app and one physical machine. Since I'm broke, I cannot afford another machine for each piece of my system, thus the web server, application and database all live on my one machine.\nI've never deployed an app before, but I know that a server can refer to a machine or software. From here on, lets call the physical machine the Rack. I've loaded an instance of MongoDB on my machine and I know that is the Database Server. In order to handle API requests, I need something on the rack that will handle HTTP\/S requests, so I install and run an instance of NGINX on it and I know that this is the Web Server. However, my web server doesnt know how to run the app, so I do some research and learn about WSGI and come to find out I need another component. So I install and run an instance of Gunicorn and I know that this is the WSGI Server. \nAt this point I have a rack that is home to a web server to handle API calls (really just acts as a reverse proxy and pushes requests to the WSGI server), a WSGI server that serves up dynamic content from my app and a database server that stores client information used by the app.\nI think I've got my head on straight, then my friend asks \"Where is your Application Server?\"\nIs there an application server is this configuration? Do I need one?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":54565501,"Users Score":0,"Answer":"Any  basic server architecture has three layers. On one end is the web server, which fulfills requests from clients. The other end is the database server, where the data resides.\nIn between these two is the application server. It consists of the business logic required to interact with the web server to receive the request, and then with the database server to perform operations. \nIn your configuration, the WSGI serve\/Flask app is the application server.\nMost application servers can double up as web servers.","Q_Score":0,"Tags":"python,web-applications,webserver,terminology,application-server","A_Id":54565677,"CreationDate":"2019-02-07T02:36:00.000","Title":"Understanding each component of a web application architecture","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"After training the trained model will be saved as H5 format. But I didn't know how that H5 file can be used as classifier to classifying new data. How H5 model works in theory when classifying new data?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1209,"Q_Id":54566249,"Users Score":1,"Answer":"When you save your model as h5-file, you save the model structure, all its parameters and further informations like state of your optimizer and so on. It is just an efficient way to save huge amounts of information. You could use json or xml file formats to do this as well. \nYou can't classifiy anything only using this file (it is not executable). You have to rebuild the graph as a tensorflow graph from this file. To do so you simply use the load_model() function from keras, which returns a keras.models.Model object. Then you can use this object to classifiy new data, with keras predict() function.","Q_Score":2,"Tags":"python,python-3.x,keras,deep-learning,conv-neural-network","A_Id":54573011,"CreationDate":"2019-02-07T04:21:00.000","Title":"How keras model H5 works in theory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running a python script remotely from a task machine and it creates a process that is supposed to be running for 3 hours. However, it seems to be terminating prematurely at exactly 2 hours. I don't believe it is a problem with the code because after the while loop ends, I am logging to a log file. The log file doesn't show that it exits out of that while loop successfully. Is there a specific setting on the machine that I need to look into that's interrupting my python process?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":54566949,"Users Score":0,"Answer":"Is this perhaps a Scheduled Task? If so, have you checked the task's properties? \nOn my Windows 7 machine under the \"Settings\" tab is a checkbox for \"Stop the task if it runs longer than:\" with a box where you can specify the duration.\nOne of the suggested durations on my machine is \"2 hours.\"","Q_Score":0,"Tags":"python,windows,process,task","A_Id":54567372,"CreationDate":"2019-02-07T05:37:00.000","Title":"TaskManager: Process is Terminated At Exactly 2 Hours","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to run multiple python scripts (lets say script1.py to script10.py) in parallel in a bash shell. Can someone advise what is the best way to run all simultaneously using xargs command? or is there any other suggestions? Thanks in advance","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":341,"Q_Id":54568011,"Users Score":0,"Answer":"There are some considerations you need to take into account.  (that other answers haven't taken into account)\n\nAre the scripts developed to run independently?  If that is the case this is easier.  If not then you will need a pipeline of scripts to manage the dependencies like Python's Luigi.\nThe scripts may require different python interpreter versions. (2.7 vs 3.7 etc..)\nIf you do decide to continue in Bash then the usage of nohup would make sure the process doesn't quit when the calling process is ended.\n\nThis isn't as easy of a question as you think it might be.","Q_Score":0,"Tags":"python,bash,parallel-processing,multiprocessing,xargs","A_Id":54568480,"CreationDate":"2019-02-07T07:09:00.000","Title":"Multiprocessing of python scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a server and a front end, I would like to get python code from the user in the front end and execute it securely on the backend. \nI read this article explaining the problematic aspect of each approach - eg pypl sandbox, docker etc. \nI can define the input the code needs, and the output, and can put all of them in a directory, what's important to me is that this code should not be able to hurt my filesystem, and create a disk, memory, cpu overflow (I need to be able to set timeouts, and prevent it from accesing files that are not devoted to it) \nWhat is the best practice here? Docker? Kubernetes? Is there a python module for that? \nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":54569861,"Users Score":0,"Answer":"You can have a python docker container with the volume mount. Volume mount will be the directory in local system for code which will be available in your docker container also. By doing this you have isolated user supplied code only to the container when it runs. \nScan your python container with CIS benchmark for better security","Q_Score":1,"Tags":"python,security,server,user-input,secure-coding","A_Id":56649312,"CreationDate":"2019-02-07T09:14:00.000","Title":"securely executing untrusted python code on server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I created a Python script that collects data from a website and generates an Excel file based on a table in that website. I used pyinstaller with -w -F parameters to generate a .exe file.\nI ran this file a few times and it worked perfect so I decided to use Task Scheduler to run it every hour. Two days after the task worked every hour, while I was using the computer the Task Scheduler returned this error when it tried to run the .exe: 0xFFFFFFFF and a pop-up saying: Failed to \"something\"\nGiven the fact that I needed data every hour, I ran the file manually and again... it worked!\nIs there any way I can fix this? How can I make sure that it won't fail again when I leave my computer online for 1 week but I'm not there to manually start it in case it fails...\nHere are the settings for the Task Scheduler:\nActions:\nProgram\/script: C:\\path1\\path2\\path3\\Script_G1.exe\n \/ Start in (optional): C:\\path1\\path2\\path3\\\nSettings:\nAllow task to be run on demand","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":6995,"Q_Id":54572131,"Users Score":1,"Answer":"In the \"Action\" check the \"Start in (optional)\" field. It makes a difference in these situations.","Q_Score":5,"Tags":"python,windows,task,pyinstaller,scheduler","A_Id":64934917,"CreationDate":"2019-02-07T11:18:00.000","Title":"Task Scheduler returns 0xFFFFFFFF in Windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I created a Python script that collects data from a website and generates an Excel file based on a table in that website. I used pyinstaller with -w -F parameters to generate a .exe file.\nI ran this file a few times and it worked perfect so I decided to use Task Scheduler to run it every hour. Two days after the task worked every hour, while I was using the computer the Task Scheduler returned this error when it tried to run the .exe: 0xFFFFFFFF and a pop-up saying: Failed to \"something\"\nGiven the fact that I needed data every hour, I ran the file manually and again... it worked!\nIs there any way I can fix this? How can I make sure that it won't fail again when I leave my computer online for 1 week but I'm not there to manually start it in case it fails...\nHere are the settings for the Task Scheduler:\nActions:\nProgram\/script: C:\\path1\\path2\\path3\\Script_G1.exe\n \/ Start in (optional): C:\\path1\\path2\\path3\\\nSettings:\nAllow task to be run on demand","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":6995,"Q_Id":54572131,"Users Score":1,"Answer":"We had a similar problem where we'd get a 0xFFFFFFFF error when running our custom .exe from Task Scheduler, but it would work fine outside of Task Scheduler.\nThe workaround was to create a .bat file to run the .exe and make the scheduled task call the .bat file.  Not a solution, obviously, but works in a pinch.","Q_Score":5,"Tags":"python,windows,task,pyinstaller,scheduler","A_Id":58455607,"CreationDate":"2019-02-07T11:18:00.000","Title":"Task Scheduler returns 0xFFFFFFFF in Windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been working on PyTesseract OCR and converting PDF to JPEG inorder to OCR the image. A part of the image has a black background and white text, which Tesseract is unable to identify, whereas all other parts of my image are being read perfectly well. Is there a way to change a part of the image that has black background? I tried a few SO resources, but doesn't seem to help. \nI am using Python 3, Open CV version 4 and PyTesseract","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":223,"Q_Id":54573130,"Users Score":0,"Answer":"opencv has a bitwise not function wich correctly reverses the image\nyou can put a mask \/ freeze on the rest of the image (the part that is correct already) and use something like this:\nimageWithMask = cv2.bitwise_not(imageWithMask)\nalternatively you can also perform the operation on a copy of the image and only copy over parts \/ pixels \/ regions you need....","Q_Score":1,"Tags":"python-3.x,opencv,python-tesseract","A_Id":54573380,"CreationDate":"2019-02-07T12:14:00.000","Title":"How to change a part of the color of the background, which is black, to white?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a script that opens Visual Studio through a command prompt. The Visual Studio is opened successfully but if I close the command prompt that the script was run from, the application Visual Studio is closed as well. How can I have it so where after the Vis Studio is opened, I can close the cmd prompt and have Vis Studio still be open?\nHere's the cmd I'm using to open Vis Stud\nsubprocess.call([address + \"\\Code.exe\"])\nOpen up Command Prompt -> Enter Script.py -> *VS Opens -> Close Command Prompt -> *VS Closes","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":183,"Q_Id":54576241,"Users Score":-1,"Answer":"You can use an ampersand (&) to end your command. This will perform the action but return the terminal to you allowing you to execute other commands (including closing the terminal again).","Q_Score":0,"Tags":"python,cmd,subprocess","A_Id":54577107,"CreationDate":"2019-02-07T15:01:00.000","Title":"How to make an opened application stay open after Python command prompt is closed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm making a script that opens Visual Studio through a command prompt. The Visual Studio is opened successfully but if I close the command prompt that the script was run from, the application Visual Studio is closed as well. How can I have it so where after the Vis Studio is opened, I can close the cmd prompt and have Vis Studio still be open?\nHere's the cmd I'm using to open Vis Stud\nsubprocess.call([address + \"\\Code.exe\"])\nOpen up Command Prompt -> Enter Script.py -> *VS Opens -> Close Command Prompt -> *VS Closes","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":183,"Q_Id":54576241,"Users Score":0,"Answer":"subprocess.call() will remain running for as long as Visual Studio runs, and killing it will apparently kill VS too.\nYou can detach the two by running subprocess.Popen([address + r'\\code.exe'])\ninstead.","Q_Score":0,"Tags":"python,cmd,subprocess","A_Id":54580324,"CreationDate":"2019-02-07T15:01:00.000","Title":"How to make an opened application stay open after Python command prompt is closed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"My team are developing a payment system for our web services. The site is built using Django, with the payment services provided by stripe. We are using dj-stripe to integrate the two.\nFor development we are using the stripe test environment, but we are doing this on multiple development servers, each with it's own dev DB.\ndj-stripe identifies which customer to associate payment, card and source activity with using the dj-stripe customer id. This causes a conflict in the information for customers with the same ids on different development severs.\nWe have thought of a number of workarounds for this, the top two choices are;\n1) Generate an offset in the customer ids to prevent clash. The issue is this may break down as time goes on, with more developers joining. It fixes the issue for now, but doesn't guarantee it won't be an issue again.\n2) Create a stripe account for each developer to ensure no clashes and only use the test environment. However, this seems like something stripe wouldn't be happy with if we end up with many devs working on the project.\nI am interested in whether there is a standard solution or best practices for this issue.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":54577860,"Users Score":0,"Answer":"In case anyone comes here for a similar issue, Stripe responded very quickly to our question on this. They already have a feature to deal with this, it just wasn't immediately obvious to us.\nStripe have a feature for you to add multiple accounts from your dashboard. You can simple create an account for each developer and just use the test keys for that account. Then invite all developers in your team to have read access to the account so that everyone can see the logs.","Q_Score":0,"Tags":"python,django","A_Id":54596638,"CreationDate":"2019-02-07T16:26:00.000","Title":"Dj-stripe conflicts with multipe development severs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have an array of thousands of doc2vec vectors with 90 dimensions. For my current purposes I would like to find a way to \"sample\" the different regions of this vector space, to get a sense of the diversity of the corpus. For example, I would like to partition my space into n regions, and get the most relevant word vectors for each of these regions.\nI've tried clustering with hdbscan (after reducing the dimensionality with UMAP) to carve the vector space at its natural joints, but it really doesn't work well.\nSo now I'm wondering whether there is a way to sample the \"far out regions\" of the space (n vectors that are most distant from each other). \n\nWould that be a good strategy?\nHow could I do this?\n\nMany thanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":244,"Q_Id":54579473,"Users Score":1,"Answer":"Wouldn't a random sample from all vectors necessarily encounter any of the various 'regions' in the set? \nIf there are \"natural joints\" and clusters to the documents, some clustering algorithm should be able to find the N clusters, then the smaller number of NxN distances between each cluster's centroid to each other cluster's centroid might identify those \"furthest out\" clusters. \nNote for any vector, you can use the Doc2Vec doc-vectors most_similar() with a topn value of 0\/false-ish to get the (unsorted) similarities to all other model doc-vectors. You could then find the least-similar vectors in that set. If your dataset is small enough for it to be practical to do this for \"all\" (or some large sampling) of doc-vectors, then perhaps other docs that appear in the \"bottom N\" least-similar, for the most number of other vectors, would be the most \"far out\". \nWhether this idea of \"far out\" is actually shown in the data, or useful, isn't clear. (In high-dimensional spaces, everything can be quite \"far\" from everything else in ways that don't match our 2d\/3d intuitions, and slight differences in some vectors being a little \"further\" might not correspond to useful distinctions.)","Q_Score":1,"Tags":"python,vector,cluster-analysis,doc2vec,dimensionality-reduction","A_Id":54581374,"CreationDate":"2019-02-07T17:57:00.000","Title":"Is there a way to find the n most distant vectors in an array?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use the pyautogui module for python to automate mouse clicks and movements. However, it doesn't seem to be able to recognise any monitor other than my main one, which means i'm not able to input any actions on any of my other screens, and that is a huge problem for the project i am working on.\nI've searched google for 2 hours but i can't find any straight answers on whether or not it's actually possible to work around. If anyone could either tell me that it is or isn't possible, tell me how to do it if it is, or suggest an equally effective alternative (for python) i would be extremely grateful.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5548,"Q_Id":54581006,"Users Score":0,"Answer":"not sure if this is clear but I subtracted an extended monitor's horizontal resolution from 0 because my 2nd monitor is on the left of my primary display. That allowed me to avoid the out of bounds warning. my answer probably isn't the clearest but I figured I would chime in to let folks know it actually can work.","Q_Score":4,"Tags":"python,automation","A_Id":67995225,"CreationDate":"2019-02-07T19:36:00.000","Title":"Using pyautogui with multiple monitors","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm getting the following error with my 3 node DAX Cluster:\nFailed to retrieve endpoints\nTraceback (most recent call last):\nMy setup:\n- Private Lambdas\n- Python 3.6\n- amazon-dax-client\n- Config settings - timeout 300ms, max retries 5\n- vpc has 3 subnets\n- The DAX cluster has 3 x r4.large nodes\nThis error happens intermittently - it still \"works\" most of the time but it is alarming given how often it happens.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":193,"Q_Id":54581755,"Users Score":0,"Answer":"The DAX Python client up to and including 1.0.6 is a bit too sensitive when checking the health of cluster nodes and considers them unhealthy when they're not. The errors are benign, but annoying. This will be fixed in an upcoming release.","Q_Score":0,"Tags":"python,amazon-dynamodb-dax","A_Id":54582303,"CreationDate":"2019-02-07T20:28:00.000","Title":"Amazon Dax Failed to retrieve endpoints Traceback (most recent call last):","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing code (Python 3) that collects data on a small IOT device and uploads it to a database on AWS. Currently the data is sent by parsing it into a json string and sending it via post request. There can be quite a lot of data at times, and I'm wondering if I can send it in compressed form using a post request.\nWhat I don't want to do is take the data, compress it to a file, then read that file's raw data into a string, and place that string in the JSON. It would be a waste to save a file and immediately read from it.\nIs there a way to compress data directly into a string of raw data, and send the compressed string as opposed to compressing into a file and reading it?\nI need a lossless compression format, hopefully something that's not too resource intensive to compress\/decompress. A .npy compression would be especially nice.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":528,"Q_Id":54582085,"Users Score":1,"Answer":"You seem to have binary data since you mention npy.\nJust send the binary data in the POST body.\nIf you need to compress signals then that is a different problem.\nMost measurements are not very compressible losslessly. \nYou might need to lower the precision of your floats or do some signal processing on device like low pass filtering noise, bandpass limit, delta compression.\nFor good results there are powerful lossy quantization algorithms like mp3 is using. But those are complex to understand and get right.","Q_Score":0,"Tags":"python,post,upload,binary-data,http-compression","A_Id":54584614,"CreationDate":"2019-02-07T20:52:00.000","Title":"Compressing data to string for json post without saving 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":1},{"Question":"I'm writing code (Python 3) that collects data on a small IOT device and uploads it to a database on AWS. Currently the data is sent by parsing it into a json string and sending it via post request. There can be quite a lot of data at times, and I'm wondering if I can send it in compressed form using a post request.\nWhat I don't want to do is take the data, compress it to a file, then read that file's raw data into a string, and place that string in the JSON. It would be a waste to save a file and immediately read from it.\nIs there a way to compress data directly into a string of raw data, and send the compressed string as opposed to compressing into a file and reading it?\nI need a lossless compression format, hopefully something that's not too resource intensive to compress\/decompress. A .npy compression would be especially nice.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":528,"Q_Id":54582085,"Users Score":0,"Answer":"Your not going to POST anything if  your device is connecting via MQTT to AWS IoT core I assume?  That's normally a lighter weight setup then HTTP and MQTT is preferred in real IoT dev.  The best way to handle these things unless you want to program the compression algorithm on the device, is to send your data through AWS IoT Core and connect a Lambda action to that incoming message.  Then program the Lambda to do any file manipulation or compression before dispatching the info to DynomoDB or S3 directly from Lambda.","Q_Score":0,"Tags":"python,post,upload,binary-data,http-compression","A_Id":54611972,"CreationDate":"2019-02-07T20:52:00.000","Title":"Compressing data to string for json post without saving 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":1},{"Question":"So, a bit of a strange question, but let's say that I have a document (jupyter notebook) and I want to be able to prove to someone that it was made before a certain date, or that it was created on a certain date - does anyone have any ideas as to how I'd achieve that?\nIt would need to be a solution that couldn't be technically re-engineered after the fact (faking the creation date).\nKeen to hear your thoughts :) !","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":54582391,"Users Score":0,"Answer":"email it to yourself or a trusted party \u2013 dandavis yesterday\nGood solution.\nThanks!","Q_Score":0,"Tags":"python,validation,authentication,encryption,jupyter-notebook","A_Id":54601557,"CreationDate":"2019-02-07T21:14:00.000","Title":"How to encrypt(?) a document to prove it was made at a certain time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running my Jupyter Notebook using Pytorch on Google Colab. After I received the 'Cuda assert fails: device-side assert triggered' I am unable to run any other code that uses my pytorch module. Does anyone know how to reset my code so that my Pytorch functions that were working before can still run?\nI've already tried implementing CUDA_LAUNCH_BLOCKING=1but my code still doesn't work as the Assert is still triggered!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":11545,"Q_Id":54585685,"Users Score":9,"Answer":"You need to reset the Colab notebook. To run existing Pytorch modules that used to work before, you have to do the following:\n\nGo to 'Runtime' in the tool bar\nClick 'Restart and Run all'\n\nThis will reset your CUDA assert and flush out the module so that you can have another shot at avoiding the error!","Q_Score":3,"Tags":"python,pytorch,google-colaboratory,tensor","A_Id":54585712,"CreationDate":"2019-02-08T03:38:00.000","Title":"How to reset Colab after the following CUDA error 'Cuda assert fails: device-side assert triggered'?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I`m trying to filter the rows of a Data Frame, but since the index name of the column has white spaces, I've not been able to do it\nThe DDTS Number is the name of the column \nIt worked when there is no spaces\ndata[data3.(DDTS Number) != null]\nI've tried different syntax but I don't if there is way to do it without to rename the column name","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":54586159,"Users Score":0,"Answer":"Hi everyone I found the solution. The problem with the method I used was it did not work when the index had spaces in the name so there is another way to get rid of the null values using the following structure:\ndf1 = df[df[\"ColumnName With Spaces\"].notnull()]\nFrom here you will filter all the rows in the \"df\" with index \"ColumnName With Spaces\" thet contain null values.","Q_Score":0,"Tags":"python,pandas,filter,row,spaces","A_Id":54720270,"CreationDate":"2019-02-08T04:55:00.000","Title":"I\u00b4m trying to filter data of colums from a Data Frame, but the index names contain white spaces","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For Topic Modelling ,\nWhy random_state parameter is used in NMF and LDA algorithm ? What are the benefits of using random topics generated every time ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":545,"Q_Id":54587051,"Users Score":1,"Answer":"The algorithms for both are stochastic - meaning they use randomness as a part of estimating a good answer. It's done that way to make it tractable, and in the case of LDA, the whole model is stochastic, providing you ideally with a probabilistic distribution (called \"the posterior distribution\") of answers, but instead providing a single, likely answer as an estimate. \nSo the answer is that using randomness in the algorithms makes a tremendously difficult problem much simpler and feasible to calculate in less than a hundred years.\nIf you're going to use them, I think it would do you well to study them, learn something of how they work, why they work. Using a tool that you don't understand is risky, as you don't really know what the result the tool provides actually means. One example is the numerors words in all \"topics\" with very low probability. The differences in these probabilities are actually meaningless - given a different sample from the posterior, you'd get different probabilities, ranked differently between words.","Q_Score":1,"Tags":"python,lda,topic-modeling,nmf","A_Id":54623195,"CreationDate":"2019-02-08T06:28:00.000","Title":"Why random_state parameter is used in NMF and LDA algorithm ? What are the benefits of using random topics generated every time?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two different automation framework in python for my test cases\nFramework-1-is old and is going to be deprecated \nFramework-2-is New one with enhanced capabilities \nfor time being i wanted to merge coverage HTML report generate by both framework till the time all TC's from framework will get ported to framework 2\nIs there anything available ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":307,"Q_Id":54587583,"Users Score":0,"Answer":"You can't merge the HTML reports, but you could combine the data files from the two test runs (using the coverage combine command), and then generate an HTML report from the combined data.","Q_Score":1,"Tags":"python,coverage.py","A_Id":54611211,"CreationDate":"2019-02-08T07:11:00.000","Title":"Merge html coverage reports from two different frameworks generated from coverage.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use toolchain from Kivy for compile Python + Kivy project on MacOS, but by default, toolchain use python2 recipes but I need change to python3.\nI\u00b4m googling but I don't find how I can do this.\nAny idea?\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":593,"Q_Id":54587891,"Users Score":0,"Answer":"For example, recipe \"ios\" and \"pyobjc\" dependency is changed from depends = [\"python\"] to depends = [\"python3\"]. (__init__.py in each packages in receipe folder in kivy-ios package)\nThese recipes are loaded from your request implicitly or explicitly\nThis description of the problem recipes is equal to require hostpython2\/python2. then conflict with python3.\nThe dependency of each recipe can be traced from output of kivy-ios. \"hostpython\" or \"python\" in output(console) were equaled to hostpython2 or python2.(now ver.)","Q_Score":0,"Tags":"python,xcode,macos,kivy","A_Id":60445492,"CreationDate":"2019-02-08T07:38:00.000","Title":"How change hostpython for use python3 on MacOS for compile Python+Kivy project for Xcode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I use toolchain from Kivy for compile Python + Kivy project on MacOS, but by default, toolchain use python2 recipes but I need change to python3.\nI\u00b4m googling but I don't find how I can do this.\nAny idea?\nThanks","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":593,"Q_Id":54587891,"Users Score":0,"Answer":"your kivy installation is likely fine already. Your kivy-ios installation is not. Completely remove your kivy-ios folder on your computer, then do git clone git:\/\/github.com\/kivy\/kivy-ios to reinstall kivy-ios. Then try using toolchain.py to build python3 instead of python 2\nThis solution work for me. Thanks very much Erik.","Q_Score":0,"Tags":"python,xcode,macos,kivy","A_Id":54769487,"CreationDate":"2019-02-08T07:38:00.000","Title":"How change hostpython for use python3 on MacOS for compile Python+Kivy project for Xcode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to uninstall Python 2.7.10 completely off my system so that I can install and work with virtualenv and Flask. I also have Python 3.7 installed and want to keep working with that. I'm working with Mac 10.14.2.\nUsing the terminal. Command [python --version] shows 2.7.10. However, when I did [brew install Python3], it shows me that it is already installed and up-to-date. If possible, I'd like to reset even (uninstalling all Python on my computer) and reinstalling python 3.7. (the version is 3.7.2_1)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2001,"Q_Id":54602494,"Users Score":0,"Answer":"Python 2.7 comes preinstalled with macOS, so I'm not sure if it is a good idea to uninstall it. You can use the command python3 to use the version 3.7 you installed with homebrew.","Q_Score":0,"Tags":"python-2.7,homebrew,python-3.7","A_Id":54602517,"CreationDate":"2019-02-09T02:07:00.000","Title":"How do I use homebrew to uninstall Python 2.7.10? Python 3.7 also installed. Cannot install\/work with virtualenv or Flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have two tensors x and y that have equal shape in the first k dimensions. The second tensor contains indices to retrieve values from the first along to the last dimension. For a rank of 3, then the output z should be such that z[i_1, i_2,...,i_k, j] = x[i_1, i_2,...,i_k, y[i_1, i_2, ...,i_k, j]].\nI currently have a method that requires reshaping the x and y, appending row indices of y, using gather_nd and finally returning to the original shape. Is there is a more elegant method? Is there a way to get the tensor of indices (like np.indices), preferably that does not require knowledge of the rank or shape beyond that they satisfy the above condition?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":46,"Q_Id":54602610,"Users Score":3,"Answer":"Found it! tf.batch_gather and tf.batch_scatter.","Q_Score":4,"Tags":"python,tensorflow","A_Id":54603217,"CreationDate":"2019-02-09T02:31:00.000","Title":"Simplest way to index within a dimension","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script that gathers data from an API, and running this manually on my local machine I can save the data to a CSV or SQLite .db file.\nIf I put this on AWS lambda how can I store and retrieve data?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6322,"Q_Id":54602932,"Users Score":0,"Answer":"with aws lambda you can use database like dynamo db which is not sql database and from there you can download csv file.\nwith lambda to dynamo bd integration is so easy lambda is serverless and dynamo db is nosql database.\nso you can save data into dynamo db also you can use RDS(Mysql)  and use man other service but best way will be dynamo db.","Q_Score":2,"Tags":"python,amazon-web-services,sqlite,aws-lambda","A_Id":54603114,"CreationDate":"2019-02-09T03:39:00.000","Title":"Using AWS Lambda to run Python script, how can I save data?","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 script that gathers data from an API, and running this manually on my local machine I can save the data to a CSV or SQLite .db file.\nIf I put this on AWS lambda how can I store and retrieve data?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6322,"Q_Id":54602932,"Users Score":0,"Answer":"It really depends on what you want to do with the information afterwards.\nIf you want to keep it in a file, then simply copy it to Amazon S3. It can store as much data as you like.\nIf you intend to query the information, you might choose to put it into a database instead. There are a number of different database options available, depending on your needs.","Q_Score":2,"Tags":"python,amazon-web-services,sqlite,aws-lambda","A_Id":54603135,"CreationDate":"2019-02-09T03:39:00.000","Title":"Using AWS Lambda to run Python script, how can I save data?","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 don't want to use polling technique or any library which underneath uses polling, things like Thread.sleep etc. Any suggestions? \nThis is an open ended question I am just interested in approach. \nExamples : Pulling up a file from FTP as soon as it lands up there, etc.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":98,"Q_Id":54605011,"Users Score":1,"Answer":"In principle, there's no way around\n\neither you poll (proactive)\nor \"server\" pushes event to you (reactive)\n\nObviously, there's ways to wrap polling into reactive-like interfaces.\nRegarding ftp \u2013 the alternatives is making service-in-the-middle that does pushing, or using inotify (which may wrap it for you effectively)","Q_Score":1,"Tags":"java,python,algorithm,scala,events","A_Id":54605202,"CreationDate":"2019-02-09T09:39:00.000","Title":"How to detect an event as soon as it happens on an external component. Don't want to poll, any alternatives?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I'm starting a new kivy project inside my virtualenv, It download again all requirements like SDK, NDK etc...\nHelp please!!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":320,"Q_Id":54605762,"Users Score":0,"Answer":"If you are using buildozer, it should reuse the sdk and ndk saved in ~\/.buildozer\/ unless you use different versions in buildozer.spec, if it downloads the same version every time, that's likely a bug. If you use python-for-android directly, you should be able to point it to your already downloaded sdk\/ndk directories.","Q_Score":0,"Tags":"python,kivy,buildozer","A_Id":54607442,"CreationDate":"2019-02-09T11:27:00.000","Title":"Re-Downloading all requirments when starting a new kivy project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As title, I know there're some model supporting streaming learning like classification model. And the model has function partial_fit()\nNow I'm studying regression model like SVR and RF regressor...etc in scikit.\nBut most of regression models doesn't support partial_fit .\nSo I want to reach the same effect in neural network. If in tensorflow, how to do like that? Is there any keyword?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":54607881,"Users Score":0,"Answer":"There is no some special function for it in TensorFlow. You make a single training pass over a new chunk of data. And then another training pass over another new chunk of data, etc till you reach the end of the data stream (which, hopefully, will never happen).","Q_Score":0,"Tags":"python,tensorflow,machine-learning","A_Id":54608871,"CreationDate":"2019-02-09T15:50:00.000","Title":"How to reach streaming learning in Neural network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In tensorflow, there is well-known batch normalization which adds the weights update ops to tf.GraphKeys.UPDATE_OPS. But in the case of instance normalization there is no update op added. When using tf.contrib.layer.batch_norm, I can specify the is_training parameter which adds the update op to collection.\nBut for tf.contrib.layer.instance_norm and tf.contrib.layer.group_norm there is no such parameter, and also no op is added to tf.GraphKeys.UPDATE_OPS. \nIs this correct behaviour, or bug in tensorflow? How does the update op in instance normalization work then?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":918,"Q_Id":54609375,"Users Score":8,"Answer":"You should understand why does batch_norm need to add ops in UPDATE_OPS.\ntf.layers.batch_normalization function will generate four variables, namely gamma, beta, moving_mean and moving_variance, and only gamma, beta are in tf.GraphKeys.TRAINABLE_VARIABLES. \nWhen it is in the training phase, moving_mean and moving_variance also need to be updated, so that if we set training parameter as 1 for tf.layers.batch_normalization, the function will add corresponding ops into tf.GraphKeys.UPDATE_OPS for updating moving_mean and moving_variance, whereas if we set training parameter as 0 for tf.layers.batch_normalization, the function will not do anything to tf.GraphKeys.UPDATE_OPS, since it doesn't need to update moving_mean and moving_variance in the test phase.\nAs for the group_norm and instance_norm, they only have beta and gamma variables, which have already been in the tf.GraphKeys.TRAINABLE_VARIABLES, so that there is no need to add any ops in tf.GraphKeys.UPDATE_OPS.","Q_Score":3,"Tags":"python,tensorflow","A_Id":54611524,"CreationDate":"2019-02-09T18:33:00.000","Title":"Instance normalization and group normalization missing update","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm diving into using VSCode on MacOS for Python coding as an alternative to PyCharm. When executing code, I run debug (F5) and it'll run my code, but once it's done running it exits the environment back to the integrated terminal. Is there a config\/setting to stay in the Python environment so that I can keep executing Python inputs manually?","AnswerCount":3,"Available Count":1,"Score":-0.1325487884,"is_accepted":false,"ViewCount":2783,"Q_Id":54609806,"Users Score":-2,"Answer":"If you want to execute the commands manually then you can start a REPL:\nPress Ctrl+Shift+P and type - Python: Start REPL\nIt opens an interactive python shell with your current environment activated.","Q_Score":8,"Tags":"python,visual-studio-code,vscode-settings,vscode-debugger","A_Id":54609979,"CreationDate":"2019-02-09T19:14:00.000","Title":"How to prevent VSCode from exiting Python environment after running code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a template generated from VS 2017 Community for Python\/Django web application. \nI can't seem to get the CSS to work.\nI looked at the page source and it is referencing the correct style sheet.I\nadding a class (class=\"test\") to to h4 in the .html file so that I can target it through the CSS \nin the site.css I have .test{\n`color: red;'\n}\nbackground, I started by trying to add a \"tooltip\" to this sheet. When that didn't work I went back to a simple manipulation just to see if I could get that to work.\nPlease let me know if you need other code snippets!\nother aspects of the code work as expected it's just styling that is giving me fits.\nPretty new at this so please be just a little forgiving! :)\nI wonder if maybe classes and id's from a template are not influenced by site.cs?\nTurns out, there is a difference between hitting refresh in the browser and ctrl + \"r\". Ctrl + \"r\" refreshed the page (without cache i'm guessing) and the changes I made were displayed.\nI added a custom.css file to the \"content\" folder under \"app\" folder.\nI then added a link to that sheet in the \"layout.html\" file\n     \nI can see my changes now. \nMight be a beginner mistake but at least I can move forward now.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":54611741,"Users Score":0,"Answer":"I was able to resolve this. \"control\" + \"r\" helped.\nall my CSS seems to be working now.\nThanks fo responding Arturo.","Q_Score":1,"Tags":"django,python-3.x","A_Id":54660644,"CreationDate":"2019-02-09T23:11:00.000","Title":"VS 2017 Python\/Django Template- CSS doesn't work but inline styling does","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've been coding a text editor, and it has the function to change the default font displayed in the wx.stc.SyledTextCtrl. \nI would like to be able to save the font as a user preference, and I have so far been unable to save it. \nThe exact object type is <class 'wx._core.Font'>.\nWould anyone know how to pickle\/save this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":103,"Q_Id":54615125,"Users Score":1,"Answer":"Probably due to its nature, you cannot pickle a wx.Font.\nYour remaining option is to store its constituent parts.\nPersonally, I store facename, point size, weight, slant, underline, text colour and background colour.\nHow you store them is your own decision.\nI use 2 different options depending on the code.    \n\nStore the entries in an sqlite3 database, which allows for multiple\nindexed entries.\nStore the entries in an .ini file using\nconfigobj \n\nBoth sqlite3 and configobj are available in the standard python libraries.","Q_Score":0,"Tags":"python,fonts,wxpython,pickle,wxstyledtextctrl","A_Id":54687573,"CreationDate":"2019-02-10T09:38:00.000","Title":"How to pickle or save a WxPython FontData Object","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a report template in Odoo 9 qweb template and I need to use OR logical operator in t-field to get data from one of the two fields that I want to print their value in my report. Can I use OR here in t-field or I should use t-if with different span tags?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1208,"Q_Id":54615152,"Users Score":2,"Answer":"The t-field directive can only be used when performing field access (a.b) on a \u201csmart\u201d record (result of the browse method)  \n\nYou need to use the conditional directive t-if as you said.","Q_Score":2,"Tags":"python,xml,odoo","A_Id":54615255,"CreationDate":"2019-02-10T09:43:00.000","Title":"How to use OR condition in t-field in qweb template in Odoo 9?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have one Django app and in the view of that I am using gzip_str(str) method to compress data and send back to the browser. Now I want to get the original string back in the browser. How can I decode the string in JS.\nP.S. I have found few questions here related to the javascript decode of gzip string but I could not figure out how to use those. Please tell me how can I decode and get the original string.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2530,"Q_Id":54615204,"Users Score":0,"Answer":"Serve the string with an appropriate Content-Encoding, then the browser will decode it for you.","Q_Score":0,"Tags":"javascript,django,python-3.x,gzip","A_Id":60143329,"CreationDate":"2019-02-10T09:51:00.000","Title":"how to decode gzip string in JS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to make a rainbow straight line but can't figure out the way the RGB  values in turtle.pencolor() should change over time...\nI tried using a hexadesimal increment from 000000 to FFFFFF but I got a a black to green line loop before getting an invalid color value.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2041,"Q_Id":54616531,"Users Score":0,"Answer":"Also, if you have even less patience, you can set the turtle module's \"tracer\" function to (0, 0)\neg. t.tracer(0, 0)\nThis will make the drawing appear instantly.\nt.tracer(20, 0) will make the turtle go hyperspeed but still with some animation\nyou also need t.update() at the end if you use this method.","Q_Score":4,"Tags":"python,colors,turtle-graphics","A_Id":65442640,"CreationDate":"2019-02-10T12:45:00.000","Title":"How can I cycle colors using turtle module in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Anaconda. I would like to know how to remove or uninstall unwanted packages from the base environment. I am using another environment for my coding purpose. \nI tried to update my environment by using yml file (Not base environment). Unexpectedly some packages installed by yml into the base environment. So now it has 200 python packages which have another environment also. I want to clear unwanted packages in the base environment and I am not using any packages in the base environment. Also, my memory is full because of this. \nPlease give me a solution to remove unwanted packages in the base environment in anaconda. \nIt is very hard to remove one by one each package, therefore, I am looking for a better solution.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19414,"Q_Id":54617690,"Users Score":0,"Answer":"Please use the below code:\nconda uninstall -n base <Package_name>","Q_Score":5,"Tags":"python,anaconda","A_Id":54617754,"CreationDate":"2019-02-10T15:03:00.000","Title":"How to remove unwanted python packages from the Base environment in Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to machine learning my question is: \n\nDo we need to encode dependent variable y if it contains three class\n  segments 1,2,3 and I want to know if there is need to encode the\n  dependent variable when it contains no","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1860,"Q_Id":54617771,"Users Score":0,"Answer":"OneHotEncoder will create k number of columns if there are k classes for a single variable.\nFor example : it will create 2 variables if  gender values in that dataset are Male\/Female,\nIt will create 3 Variables if gender values are male\/Female\/PreferNotToSay\nNow, You don't want multiple variables in your predicate y, So better go with LabelEncoder(from sklearn.preprocessing) or some mechanism that keeps the dimensionality intact.","Q_Score":2,"Tags":"python,machine-learning","A_Id":54617927,"CreationDate":"2019-02-10T15:10:00.000","Title":"dependent variable One hot encoder","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am in the process of converting my python code from 2.7 to 3 using 2to3.  It seems to convert as expected, except that my code always starts with the line #!\/usr\/bin\/python which I expected to change to #!\/usr\/bin\/python3 but it doesn't.  Have I missed something?  Is there a way to get that to happen?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":170,"Q_Id":54620359,"Users Score":2,"Answer":"#!\/usr\/bin\/python is not a python version-dependent statement, or even python at all. It essentially instructs a shell to execute the script (file) using the python executable (program) located at \/usr\/bin.\nThe intent behind 2to3 it get you along the path of converting your code to python 3, frequently doing all the work for you. It doesn't address issues outside the python code.\nIt's entirely possible for \/usr\/bin\/python to be python 3. The #! line exists let a shell execute a script using what's typically a systems default python.","Q_Score":1,"Tags":"python,python-2to3","A_Id":54622854,"CreationDate":"2019-02-10T19:52:00.000","Title":"Python 2to3 does not change #!\/usr\/bin\/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 building social network platform where users can register to their profile, fill it up and create events for the others. My problem is that I don't know what is the best approach to create tables.\nOne guy told me I should normalize table, meaning - he wants me to create separated tables for city, country, university, company and later connect those information with an SQL Query, which makes sense for me. If I will get 100 of students to sign up from the same University it makes sense for me to call only one University Name from University table instead of having rows and rows with university name filled in - it's data redundancy. \nHowever, the other guy told me, it's a bad practice, and I should put all information inside one user table - firstName, lastName, profileIMG, universityName, CompanyName, cityName, CountryName and so on. He says more tables create more problems. \nFrom my part, I do understand the logic of the first guy, but here is my other problem. As I mentioned, users fill up their resume in their profile and I want them to be allowed to add up to 3 universities they had been attending - bachelor degree, master degree, and postdoc. The same I want to allow them with companies - they can add up to three previous companies they worked for. \nI thought I will create University table where I will have this: universityName_1, universityName_2, universityName_3. The same I want to do with the company table. \nIs this a good practice? \nMaybe, I just should create the university Table with an UniversityName column, and when it comes to retrieving data from database, I would just use SQL query inside my Django project to call a specific University for the specific position? Like I call Columbia University for 2nd position (universityName_2)? \nI am very new to this topic! I hope that I presented you my problem clearly!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1006,"Q_Id":54621204,"Users Score":0,"Answer":"The \u201csecond guy\u201d probably doesn't understand relational database very well.\nIf a person has relationships with universitys and companys, add a table person_university that has foreign keys to both person and university and contains the details of the relationship. The primary key of that table would be a composite one, consisting of the two foreign keys. The same for companies.\nThat is the canonical way to store such relationships in a database. What you cannot model that way is the limit of three, but that can be handled by your application.","Q_Score":0,"Tags":"python,django,postgresql","A_Id":54626857,"CreationDate":"2019-02-10T21:24:00.000","Title":"How to normalize the tables inside PostgreSQL database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm starting to move to python 3 and the headache of installing all of the packages from 2.7 to 3.6 one by one gives me a headache just thinking about it. Is there a library to do this automatically?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":27,"Q_Id":54622200,"Users Score":1,"Answer":"Use pip freeze > requirements.txt to create a file listing the Python 2 packages you have installed then pip3 install -r requirements.txt --upgrade to install the same packages for Python 3.","Q_Score":0,"Tags":"python,pip","A_Id":54622257,"CreationDate":"2019-02-10T23:29:00.000","Title":"get python 2.7 packages and install them for python 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I watched a tutorial that requires me to have Django 2.1.\nWhen I type in \"python -m django --version\" - my Ubuntu terminal says 1.11.18 But, when I type \"django-admin --version\" - terminal says 2.1 This didn't bother me until I reached part 6 of this series, I'm heavily invested now with a serious problem I can't figure out. I even completely reinstalled my OS, (I was running Linux mint, thought it'd be easier if I ran Ubuntu) I ran through a myriad of different \"fixes\" I found online, but nothing seemed to fix this.\nThe main issue that I ran into from the tutorial is the urls linking.\nEDIT:\nI have Python 3.6 installed","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":576,"Q_Id":54622277,"Users Score":1,"Answer":"You need to be using Python-3 to use Django-2.1. Django 1.11 is the last version to support Python 2.7.","Q_Score":1,"Tags":"django,python-2.7","A_Id":54622895,"CreationDate":"2019-02-10T23:40:00.000","Title":"\"python -m django --version\" 1.11.18 Cannot update to 2.1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Say, there is a module a which, among all other stuff, exposes some submodule a.b.\nAFAICS, it is desired to maintain modules in such a fashion that one types import a, import a.b and then invokes something b-specific in a following way: a.b.b_specific_function() or a.a_specific_function(). \nThe questions I'd like to ask is how to achive such effect?\nThere is directory a and there is source-code file a.py inside of it. Seems to be logical choice, thought it would look like import a.a then, rather than import a. The only way I see is to put a.py's code to the __init__.py in the a directory, thought it is definitely wrong...\nSo how do I keep my namespaces clean?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":54622423,"Users Score":1,"Answer":"You can put the code into __init__.py. There is nothing wrong with this for a small subpackage. If the code grows large it is also common to have a submodule with a repeated name like a\/a.py and then inside __init__.py import it using from .a import *.","Q_Score":1,"Tags":"python","A_Id":54622455,"CreationDate":"2019-02-11T00:05:00.000","Title":"Pythonic way to split project into modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install xlrd to read Excel files in python.\nI have tried this: pip install -U pip setuptools. My macOS Mojave 10.4.3 has Python 2.7 which is where the default install goes to. But I have also installed Python3.7. How do I get pip install to my 3.7 directory?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":23142,"Q_Id":54623156,"Users Score":2,"Answer":"I am on Mac machine(Catalina -version 10.15.5) and below pip3 command worked for me.\npip3 install xlrd\npython version : 3.7.6\nOS : Mac-Catalina(10.15.5)","Q_Score":1,"Tags":"python-3.x,xlrd,macos-mojave","A_Id":62927940,"CreationDate":"2019-02-11T02:18:00.000","Title":"How to install xlrd in python3 library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Anaconda3 and need to install symfit. Using pip install symfit, the program returns the error: Cannot uninstall sympy. It is a distutils....\" It seems symfit requires sympy 1.1.1, but my Anaconda installation already installed sympy 1.3 and the symfit installer objects to that. How can I get around this incompatibility? \nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":636,"Q_Id":54623979,"Users Score":0,"Answer":"Yes, installing spyder and symfit within the virtual environment worked perfectly and my original problem installing symfit and running my program are solved. A few other commands from the Anaconda prompt I learned working with virtual environments are \"where spyder\", which locates the various instances that have been installed and \"conda info --envs\", which lists the virtual environments that have been created. Thanks again.","Q_Score":0,"Tags":"python,installation,symfit","A_Id":54722551,"CreationDate":"2019-02-11T04:29:00.000","Title":"How do I resolve an error installing symfit - `Cannot uninstall sympy`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is about forward and backward propagation for deep neural networks when the number of hidden units is greater than 1. \nI know what I have to do if I have a single hidden layer. In case of a single hidden layer, if my input data X_train has n samples, with d number of features (i.e. X_train is a (n, d) dimensional matrix, y_train is a (n,1)  dimensional vector) and if I have h1 number of hidden units in my first hidden layer, then I use Z_h1 = (X_train * w_h1) + b_h1 (where w_h1 is a weight matrix with random number entries which has the shape (d, h1) and b_h1 is a bias unit with shape (h1,1). I use sigmoid activation A_h1 = sigmoid(Z_h1) and find that both A_h1 and Z_h1 have shapes (n, h1). If I have t number of output units, then I use a weight matrix w_out with dimensions (h1, t) and b_out with shape (t,1) to get the output Z_out = (A_h1 * w_h1) + b_h1. From here I can get A_out = sigmoid(Z_out) \n which has shape (n, t). If I have a 2nd hidden layer (with h2 number of units) after the 1st hidden layer and before the output layer, then what steps must I add to the forward propagation and which steps should I modify?\nI also have idea about how to tackle backpropagation in case of single hidden layer neural networks. For the single hidden layer example in the previous paragraph, I know that in the first backpropagation step (output layer -> hidden layer1), I should do Step1_BP1: Err_out = A_out - y_train_onehot (here y_train_onehot is the onehot representation of y_train. Err_out has shape (n,t). This is followed by Step2_BP1: delta_w_out = (A_h1)^T * Err_out and delta_b_out = sum(Err_out). The symbol (.)^T denotes the transpose of matrix. For the second backpropagation step (hidden layer1 -> input layer), we do the following Step1_BP2: sig_deriv_h1 = (A_h1) * (1-A_h1). Here sig_deriv_h1 has shape (n,h1). In the next step, I do Step2_BP2: Err_h1 = \\Sum_i \\Sum_j [ ( Err_out * w_out.T)_{i,j} * sig_deriv_h1__{i,j} )]. Here, Err_h1 has shape (n,h1). In the final step, I do Step3_BP2: delta_w_h1 = (X_train)^T  * Err_h1 and delta_b_h1 = sum(Err_h1). What backpropagation steps should I add if I have a 2nd hidden layer (h2 number of units) after the 1st hidden layer and before the output layer? Should I modify the backpropagation steps for the one hidden layer case that I have described here?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1732,"Q_Id":54624562,"Users Score":6,"Answer":"\u25cf Let X be a matrix of samples with shape (n, d), where n denotes number of samples, and d denotes number of features.   \n\u25cf Let wh1 be the matrix of weights - of shape (d, h1) , and \n\u25cf Let bh1 be the bias vector of shape (1, h1).  \nYou need the following steps for forward and backward propagations:\n\u25ba FORWARD PROPAGATION:\n\u26f6 Step 1:\nZh1 \u00a0 \u00a0 \u00a0  = \u00a0   \u00a0 \u00a0 [ X \u00a0  \u2022 \u00a0   wh1 ] \u00a0 \u00a0  + \u00a0 \u00a0  bh1\n\u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0  \u00a0 \u2193 \u00a0 \u00a0 \u00a0  \u00a0  \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193  \n(n,h1) \u00a0 \u00a0 (n,d) \u00a0 (d,h1) \u00a0 \u00a0 (1,h1)\nHere, the symbol \u2022 represents matrix multiplication, and the h1 denotes the number of hidden units in the first hidden layer.\n\u26f6 Step 2:\nLet \u03a6() be the activation function. We get.\nah1 \u00a0 \u00a0 = \u00a0 \u00a0  \u03a6 (Zh1) \n\u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193  \n(n,h1) \u00a0 \u00a0 \u00a0 (n,h1)\n\u26f6 Step 3:\nObtain new weights and biases:\n\u25cf wh2 of shape (h1, h2), and   \n\u25cf bh2 of shape (1, h2).\n\u26f6 Step 4:\nZh2 \u00a0 \u00a0 \u00a0  = \u00a0   \u00a0 \u00a0 [ ah1 \u00a0  \u2022 \u00a0   wh2 ] \u00a0 \u00a0  + \u00a0 \u00a0  bh2 \n\u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0  \u00a0 \u2193 \u00a0 \u00a0 \u00a0  \u00a0 \u00a0  \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193\n(n,h2) \u00a0 \u00a0 (n,h1) \u00a0 (h1,h2) \u00a0 \u00a0 (1,h2)\nHere, h2 is the number of hidden units in the second hidden layer.\n\u26f6 Step 5:\nah2 \u00a0 \u00a0 = \u00a0 \u00a0  \u03a6 (Zh2) \n\u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193  \n(n,h2) \u00a0 \u00a0 \u00a0 (n,h2)\n\u26f6 Step 6:\nObtain new weights and biases:\n\u25cf wout of shape (h2, t), and   \n\u25cf bout of shape (1, t).\nHere, t is the number of classes.\n\u26f6 Step 7:\nZout \u00a0 \u00a0 \u00a0  = \u00a0   \u00a0 \u00a0 [ ah2 \u00a0  \u2022 \u00a0   wout ] \u00a0 \u00a0  + \u00a0 \u00a0  bout \n\u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0  \u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0  \u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193\n(n,t) \u00a0 \u00a0 \u00a0 (n,h2) \u00a0 (h2,t) \u00a0 \u00a0 (1,t)\n\u26f6 Step 8:\naout \u00a0 \u00a0 = \u00a0 \u00a0  \u03a6 (Zout) \n\u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193 \n(n,t) \u00a0 \u00a0 \u00a0 (n,t)\n\u25ba BACKWARD PROPAGATION:\n\u26f6 Step 1:\nConstruct the one-hot encoded matrix of the unique output classes ( yone-hot ).\nErrorout \u00a0 \u00a0 = \u00a0 \u00a0 aout \u00a0 - \u00a0 yone-hot\n\u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0  \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193\n(n,t) \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 (n,t) \u00a0 \u00a0 \u00a0 (n,t)\n\u26f6 Step 2:\n\u0394wout \u00a0 \u00a0 = \u00a0 \u00a0 \u03b7 ( ah2T \u00a0 \u2022 \u00a0 Errorout ) \n\u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193 \n(h2,t) \u00a0 \u00a0 \u00a0 \u00a0 (h2,n) \u00a0 \u00a0 (n,t)\n\u0394bout \u00a0 \u00a0 = \u00a0 \u00a0 \u03b7 [ \u2211 i=1n\u00a0 (Errorout,i) ]\n\u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193\n(1,t) \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 (1,t)\nHere \u03b7 is the learning rate. \nwout = wout - \u0394wout \u00a0 \u00a0 \u00a0 \u00a0 (weight update.)\nbout = bout - \u0394bout \u00a0 \u00a0 \u00a0 \u00a0 (bias update.)\n\u26f6 Step 3:\nError2 \u00a0 \u00a0 = \u00a0 \u00a0 [Errorout \u00a0 \u2022 \u00a0   woutT] \u00a0 \u2734 \u00a0 \u03a6\/ (ah2)\n\u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193\n(n,h2) \u00a0 \u00a0 \u00a0 \u00a0 (n,t) \u00a0 \u00a0 \u00a0 \u00a0 (t,h2) \u00a0 \u00a0 \u00a0 (n,h2)\nHere, the symbol \u2734 denotes element wise matrix multiplication. The symbol \u03a6\/ represents derivative of sigmoid function.  \n\u26f6 Step 4:\n\u0394wh2 \u00a0 \u00a0 = \u00a0 \u00a0 \u03b7 ( ah1T \u00a0 \u2022 \u00a0 Error2 ) \n\u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193 \n(h1,h2) \u00a0 \u00a0 \u00a0 \u00a0 (h1,n) \u00a0 \u00a0 (n,h2)\n\u0394bh2 \u00a0 \u00a0 = \u00a0 \u00a0 \u03b7 [ \u2211 i=1n\u00a0 (Error2,i) ]\n\u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193\n(1,h2) \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 (1,h2)\nwh2 = wh2 - \u0394wh2 \u00a0 \u00a0 \u00a0 \u00a0 (weight update.)\nbh2 = bh2 - \u0394bh2 \u00a0 \u00a0 \u00a0 \u00a0 (bias update.)\n\u26f6 Step 5:\nError3 \u00a0 \u00a0 = \u00a0 \u00a0 [Error2 \u00a0 \u2022 \u00a0   wh2T] \u00a0 \u2734 \u00a0 \u03a6\/ (ah1)\n\u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193\n(n,h1) \u00a0 \u00a0 \u00a0 (n,h2) \u00a0 \u00a0 (h2,h1) \u00a0 \u00a0 \u00a0 (n,h1)\n\u26f6 Step 6:\n\u0394wh1 \u00a0 \u00a0 = \u00a0 \u00a0 \u03b7 ( XT \u00a0 \u2022 \u00a0 Error3 )\n\u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193 \n(d,h1) \u00a0 \u00a0 \u00a0 \u00a0 (d,n) \u00a0 \u00a0 (n,h1)\n\u0394bh1 \u00a0 \u00a0 = \u00a0 \u00a0 \u03b7 [ \u2211 i=1n\u00a0 (Error3,i) ]\n\u00a0 \u00a0 \u2193 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u2193\n(1,h1) \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 (1,h1)\nwh1 = wh1 - \u0394wh1 \u00a0 \u00a0 \u00a0 \u00a0 (weight update.)\nbh1 = bh1 - \u0394bh1 \u00a0 \u00a0 \u00a0 \u00a0 (bias update.)","Q_Score":3,"Tags":"python,neural-network,deep-learning","A_Id":56425972,"CreationDate":"2019-02-11T05:44:00.000","Title":"Back-propagation and forward-propagation for 2 hidden layers in neural network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is about forward and backward propagation for deep neural networks when the number of hidden units is greater than 1. \nI know what I have to do if I have a single hidden layer. In case of a single hidden layer, if my input data X_train has n samples, with d number of features (i.e. X_train is a (n, d) dimensional matrix, y_train is a (n,1)  dimensional vector) and if I have h1 number of hidden units in my first hidden layer, then I use Z_h1 = (X_train * w_h1) + b_h1 (where w_h1 is a weight matrix with random number entries which has the shape (d, h1) and b_h1 is a bias unit with shape (h1,1). I use sigmoid activation A_h1 = sigmoid(Z_h1) and find that both A_h1 and Z_h1 have shapes (n, h1). If I have t number of output units, then I use a weight matrix w_out with dimensions (h1, t) and b_out with shape (t,1) to get the output Z_out = (A_h1 * w_h1) + b_h1. From here I can get A_out = sigmoid(Z_out) \n which has shape (n, t). If I have a 2nd hidden layer (with h2 number of units) after the 1st hidden layer and before the output layer, then what steps must I add to the forward propagation and which steps should I modify?\nI also have idea about how to tackle backpropagation in case of single hidden layer neural networks. For the single hidden layer example in the previous paragraph, I know that in the first backpropagation step (output layer -> hidden layer1), I should do Step1_BP1: Err_out = A_out - y_train_onehot (here y_train_onehot is the onehot representation of y_train. Err_out has shape (n,t). This is followed by Step2_BP1: delta_w_out = (A_h1)^T * Err_out and delta_b_out = sum(Err_out). The symbol (.)^T denotes the transpose of matrix. For the second backpropagation step (hidden layer1 -> input layer), we do the following Step1_BP2: sig_deriv_h1 = (A_h1) * (1-A_h1). Here sig_deriv_h1 has shape (n,h1). In the next step, I do Step2_BP2: Err_h1 = \\Sum_i \\Sum_j [ ( Err_out * w_out.T)_{i,j} * sig_deriv_h1__{i,j} )]. Here, Err_h1 has shape (n,h1). In the final step, I do Step3_BP2: delta_w_h1 = (X_train)^T  * Err_h1 and delta_b_h1 = sum(Err_h1). What backpropagation steps should I add if I have a 2nd hidden layer (h2 number of units) after the 1st hidden layer and before the output layer? Should I modify the backpropagation steps for the one hidden layer case that I have described here?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1732,"Q_Id":54624562,"Users Score":1,"Answer":"For Forward Propagation, the dimension of the output from the first hidden layer must cope up with the dimensions of the second input layer.\nAs mentioned above, your input has dimension (n,d). The output from hidden layer1 will have a dimension of (n,h1). So the weights and bias for the second hidden layer must be (h1,h2) and (h1,h2) respectively.\nSo w_h2 will be of dimension (h1,h2) and b_h2 will be (h1,h2).\nThe dimensions for the weights and bias for the output layer will be w_output will be of dimension (h2,1) and b_output will be (h2,1).\nThe same you have to repeat in Backpropagation.","Q_Score":3,"Tags":"python,neural-network,deep-learning","A_Id":54625251,"CreationDate":"2019-02-11T05:44:00.000","Title":"Back-propagation and forward-propagation for 2 hidden layers in neural network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is an open source contributor project for Wikidata's Chronic Pain project.\nI would like to create a webpage that :\n\nHave inputboxes where the user select several wikipedia page titles (with suggestions)\nCan also take these parameters via the URL\nGet items metadata from Wikidata.\nMakes a SPARQL request to gather scholarly articles.\nRender data from Wikidata and Wikipedia, linking to various wiki pages. \n\nThe webpage will be hosted on Wikimedia fundation server. I have access to a linux container as well as a Jupyter Notebook (not sure this one is suitable for this project). It has to be coded in Python 3 since I will use Pywikibot framework to interact with Wikidata.\nI'm new to programming so that I don't really know what is the best approach. I heard that it was difficult to code webpages in Python without using a framework like Django. However this page is very simple so that it may not be the most efficient to deploy Django for this ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":54628685,"Users Score":1,"Answer":"NB : your question is bordering on \"primarily opinion based\" (which doesn't mean it's a bad question by itself but that answers might be more, well, opinions than hard facts). \nThis being said, \"a single interactive page\" doesn't mean the server code behind is just loading a static html file and sending it to the client. For example, the main UI part of our product is, technically speaking, \"a single interactive page\", but this \"single\" page is full react app and is backed by a dedicated API with a dozen entry points, which the dispatch to a whole load of backend code including database access, celery tasks etc. It would of course be technically possible to code all this with only pure wsgi or even plain old cgi code, but well, it could also be possible to write it directly in C or even assembly and no one would ever consider this a viable solution.\nTo make a long story short: do not even waste your time trying to code this project with plain wsgi (and let's not talk cgi), you will end up reinventing the squared wheel and everyone will hate you for this (stakeholders because you'll never deliver a robust, working product in due time and budget, and other devs because they'll now have to port the whole darn thing to a stable, mature and maintained framework).  Now if Django appears to be  overkill for this project there are much lighter frameworks like flask. Actually both are the \"industry standard\" and safe choices.","Q_Score":1,"Tags":"django,python-3.x,webpage,wikipedia,wikidata","A_Id":54629877,"CreationDate":"2019-02-11T10:40:00.000","Title":"Is it an efficient method to use a framework to code a single interactive webpage in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to perform a summation of the kind i<j on symmetric matrices. This is equivalent to sum over the upper triangular elements of a matrix, diagonal excluded.\nGiven A a symmetric N x N array, the simplest solution is np.triu(A,1).sum() however I was wondering if faster methods exist that require less memory.\nIt seems that (A.sum() - np.diag(A).sum())\/2 is faster on large array, but how to avoid creating even the N x 1 array from np.diag?\nA doubly nested for loop would require no additional memory, but it is clearly not the way to go in Python.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1810,"Q_Id":54629601,"Users Score":3,"Answer":"You can replace np.diag(A).sum() with np.trace(A); this will not create the temporary Nx1 array","Q_Score":3,"Tags":"python,arrays,performance,numpy","A_Id":54629669,"CreationDate":"2019-02-11T11:28:00.000","Title":"Fastest way in numpy to sum over upper triangular elements with the least memory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to perform a summation of the kind i<j on symmetric matrices. This is equivalent to sum over the upper triangular elements of a matrix, diagonal excluded.\nGiven A a symmetric N x N array, the simplest solution is np.triu(A,1).sum() however I was wondering if faster methods exist that require less memory.\nIt seems that (A.sum() - np.diag(A).sum())\/2 is faster on large array, but how to avoid creating even the N x 1 array from np.diag?\nA doubly nested for loop would require no additional memory, but it is clearly not the way to go in Python.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1810,"Q_Id":54629601,"Users Score":1,"Answer":"The fastest method with the least memory, in pure numpy is going to be to sum the entire thing and subtract the diagonal.\nIt may feel wasteful in terms of FLOPS, but note that the theoretical savings relative to that implementation are only a factor 2. If that means anything to you, you probably should not be using numpy in the first place. \nAlso, numpy fundamentally deals with blocks of memory addressable as strided views. If you could get a single strided view onto your triangle, it might lead to an efficient numpy implementation. But you cant (proof left as exercise to the reader), so you can safely forget about any true numpy solution that isnt a call to an optimized C-routine that solves your problem for you. And none exist that I am aware.\nBut even that 'optimized' C loop may in practice get its ass kicked by A.sum(). If A is contiguous, that sum has the potential to dispatch a maximally cache-optimized and SIMD-optimized codepath. Likely, any vanilly-C youd write yourself would get absolutely demolished by A.sum() in a benchmark.","Q_Score":3,"Tags":"python,arrays,performance,numpy","A_Id":54630624,"CreationDate":"2019-02-11T11:28:00.000","Title":"Fastest way in numpy to sum over upper triangular elements with the least memory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"[root - INFO - 2019-02-11 17:40:38,224] Event: {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}\n[root - INFO - 2019-02-11 17:40:38,224] START RequestId: f294f11b-4c1e-46f7-b434-e78eb7d9e8ba Version:\nTraceback (most recent call last):\n  File \"\", line 1, in \n  File \"C:\\Users\\Sekhar.Changalaraya\\AppData\\Local\\Programs\\Python\\Python37\\lib\\multiprocessing\\spawn.py\", line 105, in spawn_main\n    exitcode = _main(fd)\n  File \"C:\\Users\\Sekhar.Changalaraya\\AppData\\Local\\Programs\\Python\\Python37\\lib\\multiprocessing\\spawn.py\", line 115, in _main\n    self = reduction.pickle.load(from_parent)\nModuleNotFoundError: No module named 'request-f294f11b-4c1e-46f7-b434-e78eb7d9e8ba'\ndef handler(event, context):\n    return {'statusCode': 200, 'body': 'd'}","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":901,"Q_Id":54630436,"Users Score":0,"Answer":"It should already be fixed with v0.1.12 of python-lambda-local.","Q_Score":1,"Tags":"python-3.7","A_Id":59280516,"CreationDate":"2019-02-11T12:16:00.000","Title":"python-lambda-local self = reduction.pickle.load(from_parent)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"[root - INFO - 2019-02-11 17:40:38,224] Event: {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}\n[root - INFO - 2019-02-11 17:40:38,224] START RequestId: f294f11b-4c1e-46f7-b434-e78eb7d9e8ba Version:\nTraceback (most recent call last):\n  File \"\", line 1, in \n  File \"C:\\Users\\Sekhar.Changalaraya\\AppData\\Local\\Programs\\Python\\Python37\\lib\\multiprocessing\\spawn.py\", line 105, in spawn_main\n    exitcode = _main(fd)\n  File \"C:\\Users\\Sekhar.Changalaraya\\AppData\\Local\\Programs\\Python\\Python37\\lib\\multiprocessing\\spawn.py\", line 115, in _main\n    self = reduction.pickle.load(from_parent)\nModuleNotFoundError: No module named 'request-f294f11b-4c1e-46f7-b434-e78eb7d9e8ba'\ndef handler(event, context):\n    return {'statusCode': 200, 'body': 'd'}","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":901,"Q_Id":54630436,"Users Score":0,"Answer":"Use python-lambda-local==0.1.7 or python-lambda-local==0.1.6","Q_Score":1,"Tags":"python-3.7","A_Id":54649552,"CreationDate":"2019-02-11T12:16:00.000","Title":"python-lambda-local self = reduction.pickle.load(from_parent)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Running VS Code on Windows with Python 3.7.2 32bit with venv environments. I've searched and searched and either there's something I'm doing wrong, or VS Code won't do what I want it to do. \nThe VS Code debugger running under \"Python: Current File (Integrated Terminal)\" doesn't find packages installed using pip install inside my (env). In fact, it doesn't appear that the packages are being installed in the virtual environment at all. \nWhenever I try to debug a single py file the debugger tells me it cannot find the package I installed using pip. I installed the packages inside the venv (env), or so I thought. However, running pip list with the (env) active shows the same list as when it's deactivated. \nI've noticed that running pip install while the (env) is active doesn't always result in the package being installed inside my environment. pip list will show it, but pip show shows it in Python's appdata\\local\\programs\\python\\python37-32\\lib\\site-packages.\nI'm creating the environments using python -m venv env inside the vs code terminal (either python shell or git bash shell). It shows the (env) as active, so I'm not sure what I'm doing. \nI have not changed the launch.json config:\n {\n            \"name\": \"Python: Current File (Integrated Terminal)\",\n            \"type\": \"python\",\n            \"request\": \"launch\",\n            \"program\": \"${file}\",\n            \"console\": \"integratedTerminal\"\n         }\n\nVS Code shows I'm using the correct venv interpreter:\nPython 3.7.2 32-bit ('env': venv)\nRunning the script directly in the VS Code terminal python script.py works correctly every time. \nManually copying packages from:\nappdata\\local\\programs\\python\\python37-32\\lib\\site-packages\nto\nenv\\lib\\site-packages\nallows the debugger to work without errors. This is great, and it's a workaround, but it appears the issue is more with my venv not actually acting like a venv.\nI don't see any issue with venv on my linux machines, but they're mostly headless so I'm not running VS Code.\nAny idea what I'm missing? Thanks for any help.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2685,"Q_Id":54634097,"Users Score":1,"Answer":"It is strange but it worked for me!\nTry to activate your virtual environment from terminal in vscode. then do not choose the venv environment from UI interpreter selector and just use your ordinary python interpreter. You shouldn't see the venv name in the bottom left of the vs code editor.\nThen debug the code from Run > Start debugging and it now finds the packages!!!","Q_Score":7,"Tags":"python-3.x,debugging,visual-studio-code,pip","A_Id":64082230,"CreationDate":"2019-02-11T15:40:00.000","Title":"Using venv - VS Code debugging doesn't see all pip installed packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Was trying to execute python script in jenkins, that make HTTP request with help of 'requests' module, but got stuck with following error:\nImportError: No module named requests\nBuild step 'Custom Python Builder' marked build as failure\nFinished: FAILURE","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4697,"Q_Id":54634554,"Users Score":0,"Answer":"You need to install the dependencies of the script, normally in setup.py or requirements.txt.\nIn the case of requirements.txt run: pip install -r requirements.txt\nIn the case of setup.py run: pip install .\nYou should do this in the job that is running the script.\nIf neither of these files exist pip install requests will include the particular dependency you are missing in your question.","Q_Score":0,"Tags":"python,jenkins,python-requests","A_Id":54634665,"CreationDate":"2019-02-11T16:07:00.000","Title":"Jenkins: ImportError: No module named requests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to create a shepard tones in python, and each tone has three notes in which one has a high volume, the second medium and the third low. How can I individually modify the volumes of these notes, and how can I play all three notes at the same time? \nI tried a winsound.Beep() function from the winsound library, but it has only 2 parameters: winsound.Beep(frequency,duration). Also, I can't think of any way to overlap three notes.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":234,"Q_Id":54634880,"Users Score":0,"Answer":"I guess the library you are using does not allow to multiple notes simultaneously. If you do not need to stick to windsound I would suggest that you use another library which providel support for polyphonic synths. Something like PySynth could do the trick, but there are also dozens of audio generating libraries, so have a look:)","Q_Score":0,"Tags":"python,winsound","A_Id":54635114,"CreationDate":"2019-02-11T16:25:00.000","Title":"How can I change the volume of an individual note and overlap three notes in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an angularjs and a python project. The angularjs for the frontend and the python part is for the trainings made for face recognition. I wanted to know if there is a way that my angular can communicate with python and if it can, how to use the functionalities of python project in the angular.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":133,"Q_Id":54635555,"Users Score":0,"Answer":"Create an  API in python console application \ncall http get put etc  from angular .","Q_Score":0,"Tags":"python,angularjs","A_Id":54635610,"CreationDate":"2019-02-11T17:01:00.000","Title":"How to create communication between python(not web) and angularjs","Data Science and Machine Learning":0,"Database and SQL":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 trying to solve an NLP multilabel classification problem. I have a huge amount of documents that should be classified into 29 categories. \nMy approach to the problem was, after cleaning up the text, stop word removal, tokenizing etc., is to do the following:\nTo create the features matrix I looked at the frequency distribution of the terms of each document, I then created a table of these terms (where duplicate terms are removed), I then calculated the term frequency for each word in its corresponding text (tf). So, eventually I ended up with around a 1000 terms and their respected frequency in each document. \nI then used selectKbest to narrow them down to around 490. and after scaling them I used OneVsRestClassifier(SVC) to do the classification. \nI am getting an F1 score around 0.58 but it is not improving at all and I need to get 0.62. \nAm I handling the problem correctly? \nDo I need to use tfidf vectorizer instead of tf, and how? \nI am very new to NLP and I am not sure at all what to do next and how to improve the score. \nAny help in this subject is priceless. \nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":240,"Q_Id":54636433,"Users Score":0,"Answer":"Tf method can give importance to common words more than necessary rather use Tfidf method which gives importance to words that are rare and unique in the particular document in the dataset.\nAlso before selecting Kbest rather train on the whole set of features and then use feature importance to get the best features.\nYou can also try using Tree Classifiers or XGB ones to better model but SVC is also very good classifier.\nTry using Naive Bayes as the minimum standard of f1 score and try improving your results on other classifiers with the help of grid search.","Q_Score":4,"Tags":"python,nlp,tf-idf,multilabel-classification,tfidfvectorizer","A_Id":54661633,"CreationDate":"2019-02-11T17:56:00.000","Title":"nlp multilabel classification tf vs tfidf","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a polynomial regression for order p. To make it simple, we use order p = 2 in this question.\nSuppose we have X with two feature x1, x2 and y. And I am trying to run a polynomial regression of\ny = \u03b5 + \u03b1 + \u03b21\u2022x1 + \u03b22\u2022x2 + \u03b23\u2022x1^2 + \u03b24\u2022x2^2\nI find that the sklearn have a sklearn.preprocessing.PolynomialFeatures. However, if I use order p = 2 and it automatically gives the combination of features. It will result in a regression of:\ny = \u03b5 + \u03b1 + \u03b21\u2022x1 + \u03b22\u2022x2 + \u03b23\u2022x1^2 + \u03b24\u2022x2^2 + \u03b25\u2022x1x2\nHowever, I do not want the combination of the features, i.e. things like x1x2. Is there any package that can do the polynomial regress as I wished?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":843,"Q_Id":54639963,"Users Score":1,"Answer":"Tbh, this seems like very weird idea to me. A lot of strength of poly features come out of interaction features.\nI'm pretty sure there's nothing built-in, but\n\nyou can take a look at PolynomialFeatures pre-processor, and make your own with modification. You'll need to \"revert\" logic of interaction_only parameter\njust build your pre-processor, your case is quite simple, .fit will do smth like concat(a, a**2)","Q_Score":2,"Tags":"python,scikit-learn,regression,polynomials,non-linear-regression","A_Id":54640039,"CreationDate":"2019-02-11T22:14:00.000","Title":"Run a polynomial regression without combinations of the features","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have a .mat file\nIt is a little over 1 GB but I don't know how much data or lines of code is on it. I want to convert this .mat file to a NumPy file in Python so I can look at the data and see what is in it. How do I do this conversion?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3092,"Q_Id":54641709,"Users Score":1,"Answer":"I think you have two options to read it.\n\nReading it in python:\nimport scipy.io\nmat = scipy.io.loadmat('fileName.mat')\n\nConverting it to .csv in MATLAB in order to read it in python later:\nFileData = load('FileName.mat');\ncsvwrite('FileName.csv', FileData.M);","Q_Score":1,"Tags":"python-3.x","A_Id":54641758,"CreationDate":"2019-02-12T01:46:00.000","Title":"How can I convert .mat files to NumPy files in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like my python script's cancel function to interrupt the Maya render in the same was pressing the 'esc' key does. How would I mimic that behavior with my function? \ngoogle, autodesk site\nI can interrupt the script with various functions, but I have not been able to esc out of an interactive render.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":185,"Q_Id":54641853,"Users Score":1,"Answer":"stopIprRendering renderView;\nif using the render view\nusing echo all commands will usually have the command hidden in the script editor history.","Q_Score":0,"Tags":"python,maya","A_Id":69847899,"CreationDate":"2019-02-12T02:08:00.000","Title":"I have a python script that launches interactive renders in Maya and I would like my script's cancel button to stop the render like the 'esc' does","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Set is unordered and unindexed. Thus, there is no concept of last entered element. Thus, there is no popitem.  Is this the reasoning for no popitem in set? \nIf this is valid reasoning then why dictionary has popitem. dictionary is also unordered like Set.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":391,"Q_Id":54642124,"Users Score":1,"Answer":"The corresponding method for sets is pop():\n\npop()\nRemove and return an arbitrary element from the set. Raises KeyError if the set is empty.\n\nPrior to Python 3.7 dicts were unordered and popitem() returned an arbitrary key-value pair. It's only since 3.7 that dicts have been ordered and popitem() defined to return items in LIFO order.\nIt's called popitem() for dicts because there's already a pop(key) method that removes the item with the specified key.","Q_Score":0,"Tags":"python","A_Id":54642164,"CreationDate":"2019-02-12T02:47:00.000","Title":"Why there is no popitem for set in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In jupyter notebook, there is a provision to download a notebook as .py file. In jupyter lab, there is an option called export as which does not contain an option to download a .py file. Is there any workaround for this, instead of copying the script in the notebook and pasting it in a python file.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":21343,"Q_Id":54647056,"Users Score":28,"Answer":"In Jupyter lab, go to File Menu. Select \"Export Notebook as\" and then choose the \"Export Notebook to Executable Script\" option.\nFor Jupyter notebook, there is \"Download as\" option in File menu of Jupyter notebook. You can select Python (.py) from the list of available options.","Q_Score":12,"Tags":"python,jupyter-notebook,ipython,jupyter,jupyter-lab","A_Id":54647171,"CreationDate":"2019-02-12T09:45:00.000","Title":"How to download a .py file from Jupyter lab notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a newbie to python, i need to complete a project on IMDB Review sentiment analysis. I did not quiet understand how to train the imdb dataset aclImdb_v1.tar to a model.  Please show me how to train a model from this dataset.\nBelow is the method I need to implement for my project.\nText Reviews -> Embedded Layer -> Word vector generation ->\nCNN -> Feature Maps -> LSTM -> Classification layer\nThe result I expect is to find if a review taken as input is either positive or negative.\nPlease help me out and pardon my unknowledgeable words, if any..","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":54647276,"Users Score":0,"Answer":"If the size of your dataset is quite large you can easily employ Deep Learning to complete your project. \nFirst, you need to create a pipeline to convert your data into well representable form, and then feed into the model.\nAnd do not worry about computational costs if you are writing in TensorFlow, the Google Cloud TPU offers free service on Google Colab.","Q_Score":0,"Tags":"python,nltk,word2vec,sentiment-analysis","A_Id":54647401,"CreationDate":"2019-02-12T09:55:00.000","Title":"How to create a word2vector model from imdb dataset and get it's featuremap using CNN","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've recently switched to VSCode, and am wondering if there's a way to make the Python Interactive Window from the Jupyter support in VSCode work like the console in Spyder where I just have to select code and press ctrl+enter to send it, without having to create cells everytime.\nFor now I'm resigned to work with the Terminal until my code is clean and then create a cell when I have reusable code, and would like to just work directly with the PIW.","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":6788,"Q_Id":54647959,"Users Score":0,"Answer":"If you have the notebook saved as a python percentage script (which is more git friendly)\neach \"cell\" will be delimited by # %% and the default run command is \"Shift+Ctrl\".\nLater once you are working in the interactive window, If you want a particular cell you wrote on the fly to be in you script, there is one button which says \"Paste code into file\" right next to the recently executed cell in the interactive window.\nAnd in case you are using the notebook for the sake of being able to later export it to html or pdf, once executed in the interactive window, there is an export button as well.","Q_Score":2,"Tags":"python,visual-studio-code,jupyter-notebook","A_Id":63391114,"CreationDate":"2019-02-12T10:28:00.000","Title":"VSCode Jupyter: is there a way to make python interactive window work as default console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've recently switched to VSCode, and am wondering if there's a way to make the Python Interactive Window from the Jupyter support in VSCode work like the console in Spyder where I just have to select code and press ctrl+enter to send it, without having to create cells everytime.\nFor now I'm resigned to work with the Terminal until my code is clean and then create a cell when I have reusable code, and would like to just work directly with the PIW.","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":6788,"Q_Id":54647959,"Users Score":0,"Answer":"@FranciscoRZ. You should have seen a popup option for this, but if it didn't come up for you it can just be manually set in VSCode options. Just change this guy here:\nPython->Data Science: Send Selection To Interactive Window\nThat should get you what you are looking for. \nOP's Note: Accepting this answer because it will be the right anwser starting with the February release of VS Code Python","Q_Score":2,"Tags":"python,visual-studio-code,jupyter-notebook","A_Id":54714023,"CreationDate":"2019-02-12T10:28:00.000","Title":"VSCode Jupyter: is there a way to make python interactive window work as default console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've recently switched to VSCode, and am wondering if there's a way to make the Python Interactive Window from the Jupyter support in VSCode work like the console in Spyder where I just have to select code and press ctrl+enter to send it, without having to create cells everytime.\nFor now I'm resigned to work with the Terminal until my code is clean and then create a cell when I have reusable code, and would like to just work directly with the PIW.","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":6788,"Q_Id":54647959,"Users Score":0,"Answer":"For me (now) interactive mode runs after setting \"jupyter.sendSelectionToInteractiveWindow\": true","Q_Score":2,"Tags":"python,visual-studio-code,jupyter-notebook","A_Id":72235712,"CreationDate":"2019-02-12T10:28:00.000","Title":"VSCode Jupyter: is there a way to make python interactive window work as default console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've recently switched to VSCode, and am wondering if there's a way to make the Python Interactive Window from the Jupyter support in VSCode work like the console in Spyder where I just have to select code and press ctrl+enter to send it, without having to create cells everytime.\nFor now I'm resigned to work with the Terminal until my code is clean and then create a cell when I have reusable code, and would like to just work directly with the PIW.","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":6788,"Q_Id":54647959,"Users Score":1,"Answer":"You should be able to do this with the latest python extension. The select the code you want to execute and press shift-enter. Is that not working?","Q_Score":2,"Tags":"python,visual-studio-code,jupyter-notebook","A_Id":54701708,"CreationDate":"2019-02-12T10:28:00.000","Title":"VSCode Jupyter: is there a way to make python interactive window work as default console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using pandas to read a file inside a rest service. The file is huge with more than 100 columns. But I only want to read just first two columns. I know I can use usecols in read_csv but I was wondering how exactly it works?\nDoes pandas read the whole file and filter out the required columns?\nOr does it only read the required columns?\nI'm asking because I don't want to overload the memory.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":454,"Q_Id":54649847,"Users Score":8,"Answer":"According to the documentation, it will read the whole file (no way to only read columns from disk), but will only parse and store the columns given in the use_cols variable (emphasize mine):\n\nusecols : list-like or callable, optional\nReturn a subset of the columns... Using this parameter results in much faster parsing time and lower memory usage.","Q_Score":1,"Tags":"python,pandas","A_Id":54650088,"CreationDate":"2019-02-12T12:10:00.000","Title":"Does pandas read the whole file even when usecols is used?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have gone through the cpython library in github. It has the source code for implementing the basic stuffs that we use in python like (dict,tuple,list, etc ie the various \"types\" and much more). And then I saw questions here in stackoverflow mentioning that all these 'types' are implemented as classes (which inherit from object) in the python build-ins. so that itself is the implementation right? then why do we need the cpython based implementations of the same stuffs in c programming language? PS: this might be a redundant question, i am not sure, but still a response is extremely appreciated. Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":54652589,"Users Score":0,"Answer":"What you saw in the cpython source IS the implementation of builtin types. The fact that a type is implemented in C doesn't mean it's not a class and does not inherit from object - actually, the type (base class for all classes) and object class ARE implemented in C (for cpython of course - I assume they are implemented in Java for jython and in C# for ironpython). FWIW, quite a few types in the stdlib and in some 3rd part libs are also implemented in C.\nAs for why some types are implemented in C (or in the host language for other implementations), the answer is quite simple: performances. Python is a nice language for high level application programming but this comes at a price which is a lot of overhead and barely any room for significant optimizations, so having highly optimized C implementations of the most widely used builtin types is key to keep decent performances. This is also the case for heavy numeric computations which is why image processing (Pil \/ Pillow) or number crunching (numpy) python libs are mostly implemented in C. In fact, cpython has been designed from the start to make it easy to wrap C libs or write C extensions for when you need more performances (or control over memory allocation etc) than what a pure Python implementation could possibly allow.","Q_Score":0,"Tags":"python-3.x","A_Id":54653362,"CreationDate":"2019-02-12T14:42:00.000","Title":"cpython implementation and the various built in types in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The SASData object has to_csv and to_df_CSV methods, but both of these write to locations on the host machine (where the SAS session is running). Is there a way to write a large SAS data table to .CSV on my local machine from a remote connection? The option on the saspy Github page was to get the DataFrame, via to_df, and then write that to .CSV, but this won't work in my case because the SAS table is bigger than memory. Must I read and write in chunks?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1164,"Q_Id":54653191,"Users Score":0,"Answer":"With saspy V2.4.3, you could try to_csv() to create the csv file on the SAS server, then download(), which is new in 2.4.3, to pull the csv over to your local filesystem.","Q_Score":2,"Tags":"python,csv,sas,saspy","A_Id":54711863,"CreationDate":"2019-02-12T15:13:00.000","Title":"saspy: write large SAS table to local csv","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run a Python module for a school project and I am getting this error ModuleNotFoundError: No module named 'win32crypt' at line import win32crypt. \nI've search the website for solution and encountered a post that states pywin32 is required. So I installed it with pip. I also tried installing pypiwin32. None of these installs worked. Now I've tried Dependency Walker to see if there are any dependencies missing and I see at least 100 DLLs that are. How can I fix the issue?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":8730,"Q_Id":54653817,"Users Score":3,"Answer":"win32cryrpt is a part of the Windows Extensions for Python or pywin32. It is a wrapper around the Windows crypto API. It doesn't make sense to try and install it without pywin32 and if your install of that has failed then that is the problem you have to solve. \nPlease try pip install pypiwin32 again, being sure to execute it in the correct folder, which is the Scripts subfolder of the Python environment you want to install it in. You may have more than one Python installation without realizing it, and if you run pip from outside that folder, you may get a different instance of pip. The standard location for Python installations is C:\\Program Files\\Python3x. If the pip install doesn't complete as expected then edit your question to include the messages from the failed install. Did not work isn't enough to go on.","Q_Score":0,"Tags":"python,pywin32","A_Id":54654383,"CreationDate":"2019-02-12T15:45:00.000","Title":"ModuleNotFoundError: No module named 'win32crypt'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"While trying to perform a tcp TWH in scapy I encountered a problem.\nWhen my host receives the syn\/ack, the kernel ip\/tcp stack aborts the handshake by sending rst.\nIt happens because the first packet sent (the syn) is transparent to the os due to the raw socket that scapy is using.\nIn some other questions regarding the same issue the solution was to set up iptables to drop packets with the rst flag.\nDoes anyone have a solution for windows?\n(I prefer not to use the FW unless there is no choice)\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":649,"Q_Id":54655649,"Users Score":1,"Answer":"That's a common problem, and it is not specific to Windows (or Scapy, for that matters - you can face similar issues with Masscan, for example).\nYou have totally understood and describe it: the problem lies in the IP address being \"shared\" between Scapy and your host's IP stack.\nYou have two options:\n\nUse a firewall to prevent your host from getting the SYN\/ACK packet (Scapy will get it anyway) or to prevent your host from sending a RST packet.\nUse a different IP address with Scapy. This is a bit more difficult because it requires some kind of ARP proxy (or a Scapy script) to answer ARP request for the IP address you will use with Scapy.\n\nHope this helps, happy hacking!","Q_Score":1,"Tags":"python,sockets,winsock,scapy,raw-sockets","A_Id":54670769,"CreationDate":"2019-02-12T17:31:00.000","Title":"Scapy TCP Handshake - Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a python script that constantly runs in the background and writes it's output to a file, I have initialized it using Python.h class in c++.\nI want to read from the file when the user make an action, therefore i need to somehow pause or stop the python script.\nI would like to know if there is a way of sending c++ pointers to the python function and stopping the script by changing the object in the c++ code.\nOr maybe force the script to stop.\nThanks, Ori.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":270,"Q_Id":54655895,"Users Score":0,"Answer":"You can force the script to stop using this line of code\nsystem(\"pkill -f name-of-the-python-script\"); in the c++ program.\nYou can also use the c++ program to write in another file and check it in every iteration in the python script. If\nit's empty continue, otherwise: sys.exit() but don't forget to import sys","Q_Score":0,"Tags":"python,c++","A_Id":54656257,"CreationDate":"2019-02-12T17:49:00.000","Title":"How to stop\/pause an python script embedded in 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":"When using pyinstaller to build an executable I get \n\nunable to find \/home\/usr\/nltk_data\n\nwhen adding binary and data files. \nI've tried almost every single solution on the internet","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":3848,"Q_Id":54659466,"Users Score":3,"Answer":"I solved the problems editing the pyinstaller nltk-hook (inside python3). After much research, I decided to go it alone in the code structure. I solved my problem by commenting on the lines:\ndatas=[]\n'''for p in nltk.data.path:\n    datas.append((p, \"nltk_data\"))'''\nhiddenimports = [\"nltk.chunk.named_entity\"]\nWhat's more, you need to rename the file: pyi_rth__nltk.cpython-36.pyc to pyi_rth_nltk.cpython-36.pyc  This file have 1 more underline. Warning with the python version.","Q_Score":5,"Tags":"python,nltk,hook,pyinstaller","A_Id":56654039,"CreationDate":"2019-02-12T22:14:00.000","Title":"nltk-hook unable to find nltk_data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to do some code cleanup and make all of the strings within a module consistently double-quoted strings.  My problem is there are tons of them and going through by hand (alt+enter, arrow, enter) is tedious and my regex-Fu is weak.  (keep running into oddball cases where single quotes are in doc strings, etc)\nIs there some faster way to convert all single-quoted strings to double-quoted strings in Pycharm?","AnswerCount":6,"Available Count":3,"Score":-1.0,"is_accepted":false,"ViewCount":2506,"Q_Id":54659851,"Users Score":-6,"Answer":"Ctrl+R Will bring up the find\/replace dialog. Just put ' in the find field and \" in the replace field.","Q_Score":4,"Tags":"python,pycharm","A_Id":54660034,"CreationDate":"2019-02-12T22:50:00.000","Title":"How can you convert all single-quoted strings to double-quoted strings in PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to do some code cleanup and make all of the strings within a module consistently double-quoted strings.  My problem is there are tons of them and going through by hand (alt+enter, arrow, enter) is tedious and my regex-Fu is weak.  (keep running into oddball cases where single quotes are in doc strings, etc)\nIs there some faster way to convert all single-quoted strings to double-quoted strings in Pycharm?","AnswerCount":6,"Available Count":3,"Score":-0.0333209931,"is_accepted":false,"ViewCount":2506,"Q_Id":54659851,"Users Score":-1,"Answer":"Just use the find and replace function of PyCharm by pressing \"Ctrl+R\"\nBut just be careful that it will convert all the double-quoted symbols to single-quoted. So, if you have a triple-quoted string like \"\"\"===\"\"\", then you'll have to exclude those kinds of string and then replace all. So, if you have a big code, it'll take you just as much as time as doing it manually.\nOr you can also use the replace method of python.\nCopy your code down into a string and then use the code, .replace(\"\\\"\", \"'\")","Q_Score":4,"Tags":"python,pycharm","A_Id":71571630,"CreationDate":"2019-02-12T22:50:00.000","Title":"How can you convert all single-quoted strings to double-quoted strings in PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to do some code cleanup and make all of the strings within a module consistently double-quoted strings.  My problem is there are tons of them and going through by hand (alt+enter, arrow, enter) is tedious and my regex-Fu is weak.  (keep running into oddball cases where single quotes are in doc strings, etc)\nIs there some faster way to convert all single-quoted strings to double-quoted strings in Pycharm?","AnswerCount":6,"Available Count":3,"Score":0.1651404129,"is_accepted":false,"ViewCount":2506,"Q_Id":54659851,"Users Score":5,"Answer":"In Preferences, type double-quoted into the search bar. This will suggest Editor->Intentions. There's an option there for converting double-quoted strings to single-quoted strings and vice-versa. Check this to see if it is enabled.\nWhen you select one instance of such a string, and click on the 'light bulb', this may, or may not, offer you the option to apply it to the entire file by tapping the right arrow.\nIf not, it may at least ease your pain in that you can simply click once on each instance and use the light bulb to fix that on. Finding documentation on Intentions isn't all that fruitful, regarding how to apply them across a file or include them in code inspection. This may be a difference between the Community edition and the Full Version.\nThough, as @acushner's comment suggests, and in my personal experience and preference, single-quoting seems the more consistently-used styling, and arguably sub rosa canon.\n(To be honest, it's so ingrained in me at this point that I find myself single-quoting prose. But I reckon that's a personal problem, and TMI. 'Be yourself.')","Q_Score":4,"Tags":"python,pycharm","A_Id":54660415,"CreationDate":"2019-02-12T22:50:00.000","Title":"How can you convert all single-quoted strings to double-quoted strings in PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a python script to convert .DBC files (from Datasus) into .CSV.\nI've searched a lot some libs to help me but didn't get success with any of them. Do someone know an option\/package which could be useful in this conversion task?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8849,"Q_Id":54661137,"Users Score":0,"Answer":"Convert it to XLS (microsoft excel) and from there you can get it to .csv, I am ubuntu guy but I believe there should be a export option. or at least there is in LibreOffice","Q_Score":4,"Tags":"python,dbf","A_Id":54661235,"CreationDate":"2019-02-13T01:26:00.000","Title":"Convert .dbc files into .csv with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to associate .py files to open CMD with py then the filename? Maybe in a .bat file?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2905,"Q_Id":54661730,"Users Score":0,"Answer":"You can do it in two separate ways:\nFirst, you can rename your .py file to .pyw and just open it and the script would be executed immediately (with pythonw.exe) but this is not showing you a console output.\nOr you can simple associate your .py files with standard python.exe which will show the console output.","Q_Score":0,"Tags":"python,python-3.x,windows,python-winshell","A_Id":54667729,"CreationDate":"2019-02-13T02:48:00.000","Title":"How to associate .py files to open CMD with `py` then the filename?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I tried to read a pickle file that saved by a former version of pandas, it yielded an ImportError.\n\nImportError: No module named 'pandas.core.internals.managers';\n  'pandas.core.internals' is not a package\n\nThere was no hit on stackoverflow so i would like to share my solution for this particular problem.","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":62757,"Q_Id":54665527,"Users Score":70,"Answer":"This error comes off due to encoding of formerly saved pickle file. If you updated pandas to newly amended version, it produces this import error.","Q_Score":66,"Tags":"python,pandas,pickle","A_Id":54665528,"CreationDate":"2019-02-13T08:24:00.000","Title":"ImportError: No module named 'pandas.core.internals.managers'; 'pandas.core.internals' is not a package","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I tried to read a pickle file that saved by a former version of pandas, it yielded an ImportError.\n\nImportError: No module named 'pandas.core.internals.managers';\n  'pandas.core.internals' is not a package\n\nThere was no hit on stackoverflow so i would like to share my solution for this particular problem.","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":62757,"Q_Id":54665527,"Users Score":10,"Answer":"I had the same problem, but for me, it seemed to come from the pickle package \/ interaction with the pandas package. \nI had Pandas version 0.23.4.\nI saved some pickle files with pandas.Dataframe.to_pickle, with python 3.6.6 & Pandas version 0.23.4.\nThen I upgraded to python 3.7.2 (Pandas version 0.23.4), and was enabled to read thoses pickle files with pandas.Dataframe.read_pickle.\nNext, I upgraded pandas to pandas 0.24.1, and it worked for me. I can read those files again.","Q_Score":66,"Tags":"python,pandas,pickle","A_Id":54785333,"CreationDate":"2019-02-13T08:24:00.000","Title":"ImportError: No module named 'pandas.core.internals.managers'; 'pandas.core.internals' is not a package","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I tried to read a pickle file that saved by a former version of pandas, it yielded an ImportError.\n\nImportError: No module named 'pandas.core.internals.managers';\n  'pandas.core.internals' is not a package\n\nThere was no hit on stackoverflow so i would like to share my solution for this particular problem.","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":62757,"Q_Id":54665527,"Users Score":2,"Answer":"conda update pandas\nIf you use conda package manager.","Q_Score":66,"Tags":"python,pandas,pickle","A_Id":58784510,"CreationDate":"2019-02-13T08:24:00.000","Title":"ImportError: No module named 'pandas.core.internals.managers'; 'pandas.core.internals' is not a package","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Ancaconda3 and Tensorflow. When I try to import Tensorflow in python shell I receive the following error:\n\nModuleNotFoundError: No module named 'numpy.core._multiarray_umath'\n  ImportError: numpy.core.multiarray failed to import\nThe above exception was the direct cause of the following exception:\nTraceback (most recent call last):   File \"\", line 980, in _find_and_load SystemError:\n   returned a result with\n  an error set ImportError: numpy.core._multiarray_umath failed to\n  import ImportError: numpy.core.umath failed to import\n\nI am not sure what the problem is as numpy is installed on my system and can be successfully imported in python.\nI am using Windows10.\nThanks in advance.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":76204,"Q_Id":54665842,"Users Score":102,"Answer":"I also had the same issue.\nIt got resloved once i upgraded the numpy from 1.15.4 to 1.16.1.\nIf you're using pip:\npip install numpy --upgrade\nNumpy that came with Anaconda3 is of version 1.15.4. so i upgraded and it worked.\n\nSide note: if you're also using scikit-image in your script, be aware that numpy 1.16.3 has a conflict with old versions of scikit-image (e.g. you may get ImportError: cannot import name '_validate_lengths'). In that case, pip install --upgrade scikit-image from terminal solved the issue for me.\nHope it helps!!","Q_Score":71,"Tags":"python-3.x,numpy,tensorflow,anaconda","A_Id":54708388,"CreationDate":"2019-02-13T08:43:00.000","Title":"When importing tensorflow, I get the following error: No module named 'numpy.core._multiarray_umath'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Ancaconda3 and Tensorflow. When I try to import Tensorflow in python shell I receive the following error:\n\nModuleNotFoundError: No module named 'numpy.core._multiarray_umath'\n  ImportError: numpy.core.multiarray failed to import\nThe above exception was the direct cause of the following exception:\nTraceback (most recent call last):   File \"\", line 980, in _find_and_load SystemError:\n   returned a result with\n  an error set ImportError: numpy.core._multiarray_umath failed to\n  import ImportError: numpy.core.umath failed to import\n\nI am not sure what the problem is as numpy is installed on my system and can be successfully imported in python.\nI am using Windows10.\nThanks in advance.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":76204,"Q_Id":54665842,"Users Score":2,"Answer":"You can use two options in python 3.6\n\nInstall\n\n\npy pip -m install numpy==1.14.5\n\n\nUpgrade \n\n\npy pip install numpy --upgrade\n\nNote: the version most recently is 1.14.5","Q_Score":71,"Tags":"python-3.x,numpy,tensorflow,anaconda","A_Id":56179177,"CreationDate":"2019-02-13T08:43:00.000","Title":"When importing tensorflow, I get the following error: No module named 'numpy.core._multiarray_umath'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Ancaconda3 and Tensorflow. When I try to import Tensorflow in python shell I receive the following error:\n\nModuleNotFoundError: No module named 'numpy.core._multiarray_umath'\n  ImportError: numpy.core.multiarray failed to import\nThe above exception was the direct cause of the following exception:\nTraceback (most recent call last):   File \"\", line 980, in _find_and_load SystemError:\n   returned a result with\n  an error set ImportError: numpy.core._multiarray_umath failed to\n  import ImportError: numpy.core.umath failed to import\n\nI am not sure what the problem is as numpy is installed on my system and can be successfully imported in python.\nI am using Windows10.\nThanks in advance.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":76204,"Q_Id":54665842,"Users Score":2,"Answer":"Kindly check whether you have installed the numpy package from pip. Because if you are running on conda evironment, then all packages need to be downloaded from there.\nPlease use the below mentioned statement for this purpose\nconda install -c anaconda numpy\nAlso make sure that the numpy version supports the Python version you are using.","Q_Score":71,"Tags":"python-3.x,numpy,tensorflow,anaconda","A_Id":56356627,"CreationDate":"2019-02-13T08:43:00.000","Title":"When importing tensorflow, I get the following error: No module named 'numpy.core._multiarray_umath'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to understand in general how the \"as\" keyword in python works so far and have learnt 3 cases for it\nCase 1: import foo as bar\nCase 2: with foo() as bar:\nCase 3: except Exception as e:\nI understand how the first 2 cases work, case 1 works assigning a package name to a different name, case 2 works using __entry__ and __exit__ methods within a class (say for ensuring resources close), where __entry__ returns the class bar is being assigned to.\nHowever, case 3 seems different, I was looking through the docs which didn't seem to help and couldn't find much of an explanation anywhere. In this case Exception.args works differently to e.args and I have been trying to work out how this works behind the scenes, i.e. whatever methods may be called, or why it behaves differently","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":167,"Q_Id":54666550,"Users Score":2,"Answer":"In the except statement to associate a name to the exception being passed, as keyword is used.\nUsing as is the only way to assign the exception to a local in Python 3.x. But it is not required. \nIn Python 2.6+, we had 2 options , and as. since , is ambiguous in case of multicatch, which allows you to catch multiple exceptions in one except block. as is the preferred option.\nIn Python 2.5 and earlier, we use the ,for association, since as isn't supported.","Q_Score":2,"Tags":"python,oop","A_Id":54667108,"CreationDate":"2019-02-13T09:22:00.000","Title":"python - confusion how the \"as\" keyword works in an except statement","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a project where one client needs to take several snapshots from a camera (i.e. it's actually taking a short-duration video, hence a stream of frames), then send all images to a server which then performs some processing on these images and returns a result to the client.\nClient and server are all running Python3 code.\nThe critical part is the image sending one.\nSome background first, images are *640*480 jpeg* files. JPEG was chosen as a default choice, but lower quality encoding can be selected as well. They are captured in sequence by a camera. We have thus approximately ~600 frames to send. Frame size is around 110KiB.\nThe client consists of a Raspberry Pi 3 model B+. It sends the frames via wifi to a 5c server. Server and client both reside in the same LAN for the prototype version. But future deployments might be different, both in term of connectivity medium (wired or wireless) and area (LAN or metro). \nI've implemented several solutions for this:\n\nUsing Python sockets on the server and the client: I'm either sending one frame directly after one frame capture, or I'm sending all images in sequence after the whole stream capture is done.\nUsing Gstreamer: I'm launching a GStreamer endpoint on my client and directly send the frames to the server as I stream. I'm capturing the stream on the server side with OpenCV compiled with GStreamer support, then save them to the disk.\n\nNow, the issue I'm facing is that even if both solutions work 'well' (they get the 'final' job done, which is to send data to a server and receive a result based on some remote processing), I'm convinced there is a better way to send a large amount of data to a server, using either the Python socket library, or any other available tools.\nAll personal researches are done on that matter lead me to solutions similar to mine, using Python sockets, or were out of context (relying on other backends than pure Python).\nBy a better way, I assume:\n\nA solution that saves bandwidth as much as possible.\nA solution that sends all data as fast as possible.\n\nFor 1. I slightly modified my first solution to archive and compress all captured frames in a .tgz file that I send over to the server. It indeed decreases the bandwidth usage but also increases the time spent on both ends (due to the un\/compression processes). It's obviously particularly true when the dataset is large.\nFor 2. GStreamer allowed me to have a negligible delay between the capture and the reception on my server. I have however no compression at all and for the reasons stated above, I cannot really use this library for further development.\nHow can I send a large number of images from one client to one server with minimal bandwidth usage and delay in Python?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1651,"Q_Id":54667373,"Users Score":0,"Answer":"you can restream camera using ffmpeg over network so that client can read it both ways. it will reduce delays.","Q_Score":3,"Tags":"python,image,sockets,opencv,gstreamer","A_Id":71076309,"CreationDate":"2019-02-13T10:02:00.000","Title":"Efficient way of sending a large number of images from client to server","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 an iframe inside a web content (no matter where exactly need to be inserted). The only way that I need to do this, is just by making it dynamically and also by using Python3+ version. The iframe's information is not important either. Id, class name and more can be random or custom. It is not necessary to insert specific data. Also, I don't need an answer about the height and the width. I already have solved it.\nWhat do I mean dynamically? I mean that if someone clicks on a button then I need to insert this iframe. If someone clicks on another button then I need to delete it, and so on.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":545,"Q_Id":54670433,"Users Score":0,"Answer":"Sounds like HTML \/ Javascript challenge. Why do you think it is related to python?","Q_Score":2,"Tags":"python,python-3.x,iframe","A_Id":54672807,"CreationDate":"2019-02-13T12:39:00.000","Title":"Q: How can I create dynamically an iframe inside a web content using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"very simple task:\nsrcdir=\"Q:\/\/Waveforms\/\/Cispr16-1-2\/\/Pk\"\nos.chdir(srcdir)\nthe interpreter says:\nWindowsError: [Error 3] The system cannot find the path specified: 'Q:\/\/Waveforms\/\/Cispr16-1-2\/\/Pk'\nfrom cmd prompt the remote driver is visible:\nVolume in drive Q is USERDATA\nVolume Serial Number is CB9A-E149\nDirectory of Q:\\Waveforms\\Cispr16-1-2\\Pk\n13\/02\/2019  12:21              .\n13\/02\/2019  12:21              ..\n13\/02\/2019  12:21             8.225 F1--Pk--00000.trc\n               1 File(s)          8.225 bytes\n               2 Dir(s)  84.622.512.128 bytes free\nMost likely this is a windows10 security issue, not letting Python access the sahred folder. Has anyone experienced the same issue and has found a solution?\nthanks\nMastro59","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":189,"Q_Id":54671193,"Users Score":1,"Answer":"The double \/\/ should be a single \/. Or \\\\.","Q_Score":0,"Tags":"python-2.7,remote-access","A_Id":54689609,"CreationDate":"2019-02-13T13:19:00.000","Title":"os.chdir can't find remote shared driver","Data Science and Machine Learning":0,"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":"very simple task:\nsrcdir=\"Q:\/\/Waveforms\/\/Cispr16-1-2\/\/Pk\"\nos.chdir(srcdir)\nthe interpreter says:\nWindowsError: [Error 3] The system cannot find the path specified: 'Q:\/\/Waveforms\/\/Cispr16-1-2\/\/Pk'\nfrom cmd prompt the remote driver is visible:\nVolume in drive Q is USERDATA\nVolume Serial Number is CB9A-E149\nDirectory of Q:\\Waveforms\\Cispr16-1-2\\Pk\n13\/02\/2019  12:21              .\n13\/02\/2019  12:21              ..\n13\/02\/2019  12:21             8.225 F1--Pk--00000.trc\n               1 File(s)          8.225 bytes\n               2 Dir(s)  84.622.512.128 bytes free\nMost likely this is a windows10 security issue, not letting Python access the sahred folder. Has anyone experienced the same issue and has found a solution?\nthanks\nMastro59","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":54671193,"Users Score":0,"Answer":"I tried with \/ and \/\/ and \\ and \\ none of these worked with windows10, but\nin windows7 this command works:\nos.chdir(\"Q:\/\/Waveforms\")\nfor others having the same problem here is the solution for Windows10.\nit is required to access the share using the ip address and share name.\nthe shared drive was named \"d\"\nin python this syntax works:\nos.chdir(\"\\\\ipaddress\\sharename\\folder\") [ 4 \\ AND 2 \\]\nOR \nos.chdir(\"\/\/ipaddress\/sharename\/folder\")\nthis worked well:\nos.chdir(\"\\\\192.168.147.143\\d\\Waveforms\")  [note:IN TEXT MESSAGE I AM TYPING 4\\  AND 2\\ BUT THE POST ONLY SHOWS 2\\ AND 1]\nOR\nos.chdir(\"\/\/192.168.147.143\/d\/Waveforms\") \nresult:\nCurrent Working Directory  D:\\products\\MyscopeControl\\src\nDirectory changed to: \\192.168.147.143\\d\\Waveforms","Q_Score":0,"Tags":"python-2.7,remote-access","A_Id":54707237,"CreationDate":"2019-02-13T13:19:00.000","Title":"os.chdir can't find remote shared driver","Data Science and Machine Learning":0,"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 make a conceptual distinction between Python objects and other language elements such as keywords (e.g. return and def) and operators (e.g. + and -) memory-wise. I know that objects are stored in memory and they have a memory id and a size. The id and size can be found out with id(object) and sys.getsizeof(object) respectively. \nAre non-objects such as keywords and operators also stored in memory? If yes, are they stored in the same way as objects or different? Do return and def have a slot like string \"Foo\" and text 10 have?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":42,"Q_Id":54672535,"Users Score":1,"Answer":"They are not as that would be a big waste of memory. I am not sure about scripting languages, but normally the compiler creates the binary codes for operators or keywords. Then they are loaded into the memory when you run the application.","Q_Score":0,"Tags":"python,object,memory,operators,keyword","A_Id":54672786,"CreationDate":"2019-02-13T14:26:00.000","Title":"Are keywords, operators, etc stored in memory like objects?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two lists. List L1 contains all positive integers, list L2 contains positive numbers (e.g. 0.01,0.1,0.5,3,5,10,100....).\nGiven a small positive number M (e.g. 0.10948472), find a,b from L1 and cfrom L2 s.t. (b\/a)*c is maximized but still <=M\nNote that list L2 is fixed (length around 7000), list L1 has variable length (can have single element or up to 3000 elements).\nHow can we efficiently design an algorithm to solve this? I'm thinking about using divide and conquer on list L1 to break it into two then combine, but didn't work out. Anyone can solve it efficiently?\nUpdate: Currently I worked out some inefficient but correct solutions: Sort 'L1' first. Divide 'L1' into two chunks: one chunk is the first N-1 elements, another chunk is the last element. Suppose best a,b,c has been found on the first N-1 elements of L1, I check whether we can find some a in first chunk and b in second chunk (one element only) and some c, such that (b\/a)*c improves. Since I have to loop through each element in L2, although it's nlogn, still appears to be slow","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":944,"Q_Id":54672562,"Users Score":1,"Answer":"from what i understand, you dont have to loop through each element of L2 for a given a\/b combination. sort L2 in ascending order. then suppose you pick the first combination of a\/b from L1. for c, you can pick the element in the middle of L2, i.e. at index 3500 and multiply with a\/b. if the answer is less than M, you could pick the element at a higher index, for example at 7000*3\/4 which is 5250. if answer is still less, go higher still. if instead (a\/b)*c exceeds M, pick a lower index. you could converge to the maximized value of c for that particular a\/b combination. \nP.S. needless to say, after sorting L1 and L2, you could add an if statement to eliminate those elements in L1 or L2 which will always exceed M for any value of L2 or L1 respectively.","Q_Score":4,"Tags":"python,algorithm,recursion,divide-and-conquer","A_Id":54673870,"CreationDate":"2019-02-13T14:27:00.000","Title":"How to efficiently find out the maximum value below a threshold?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Visual Studio Intellicode extension in my VS Code (which installed Python language server).\nI did some testing and decided to uninstall Visual Studio Intellicode extension, which I did.\nBut I can't find Python Language server to uninstall.\nHow can I uninstall Python language server?\nThanks in advance,\nJM","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2298,"Q_Id":54672822,"Users Score":2,"Answer":"I was able to bypass the language server by re-enabling the \"python.jediEnabled\" to true.","Q_Score":5,"Tags":"visual-studio-code,python-language-server","A_Id":54678305,"CreationDate":"2019-02-13T14:41:00.000","Title":"How can I uninstall Python language server (was installed by VS Intellicode extension)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making an application in python.\nIn short:\nThe user inputs some images for calibration, and some images that then are transformed by algorithm.\nTo further improve the algorithm and service, I want the users to upload calibration images to a central storage in the cloud. How would I go about this?\nHow do I make it secure(I.e. Not get people randomly upload terabytes of files)?\nIs it possible to have a script on the server\/cloud side that validates if the uploaded file should be deleted or not?\nI have some experience with Azure, but open for anything..","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":38,"Q_Id":54675157,"Users Score":1,"Answer":"A high level perspective:\n\ndevelop a middleware to manage user authentication and proxy the upload to any cloud storage on your own. In python you may want to look for web API framework like Django \/ Flask to implement user authentication with a database properly. You also have to implement secure connection between the middleware and client.\nA less recommended implementation is calling cloud service API directly from client, for example AWS provides a boto python client which can access to S3 API with accessKey(AK) and secretKey(SK) of a IAM user. You could prompt the user for their AK and SK for uploading file on S3. Then you are relying on the authorization of AWS. However this would expose your public cloud account to user, in security measure each user using your application would need to create a unique IAM user, setting up with minimal access policy properly. If you have lot of users, you will need to consider a user group for your application to minimize your effort on user management.","Q_Score":0,"Tags":"python,cloud,storage","A_Id":54678793,"CreationDate":"2019-02-13T16:33:00.000","Title":"Uploading files to storage. Multiple users","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I run conda 4.6.3 with python 3.7.2 win32. In python, when I import numpy, i see the RAM usage increase by 80MB. Since I am using multiprocessing, I wonder if this is normal and if there is anyway to avoid this RAM overhead? Please see below all the versions from relevant packages (from conda list):\n\npython...........3.7.2 h8c8aaf0_2\nmkl_fft...........1.0.10 py37h14836fe_0\nmkl_random..1.0.2 py37h343c172_0\nnumpy...........1.15.4 py37h19fb1c0_0\nnumpy-base..1.15.4 py37hc3f5095_0\n\nthanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1002,"Q_Id":54675983,"Users Score":2,"Answer":"You can't avoid this cost, but it's likely not as bad as it seems. The numpy libraries (a copy of C only libopenblasp, plus all the Python numpy extension modules) occupy over 60 MB on disk, and they're all going to be memory mapped into your Python process on import; adding on all the Python modules and the dynamically allocated memory involved in loading and initializing all of them, and 80 MB of increased reported RAM usage is pretty normal.\nThat said:\n\nThe C libraries and Python extension modules are memory mapped in, but that doesn't actually mean they occupy \"real\" RAM; if the code paths in a given page aren't exercised, the page will either never be loaded, or will be dropped under memory pressure (not even written to the page file, since it can always reload it from the original DLL).\nOn UNIX-like systems, when you fork (multiprocessing does this by default everywhere but Windows) that memory is shared between parent and worker processes in copy-on-write mode. Since the code itself is generally not written, the only cost is the page tables themselves (a tiny fraction of the memory they reference), and both parent and child will share that RAM.\n\nSadly, on Windows, fork isn't an option (unless you're running Ubuntu bash on Windows, in which case it's only barely Windows, effectively Linux), so you'll likely pay more of the memory costs in each process. But even there, libopenblasp, the C library backing large parts of numpy, will be remapped per process, but the OS should properly share that read-only memory across processes (and large parts, if not all, of the Python extension modules as well).\nBasically, until this actually causes a problem (and it's unlikely to do so), don't worry about it.","Q_Score":3,"Tags":"python,numpy,conda,ram","A_Id":54677347,"CreationDate":"2019-02-13T17:18:00.000","Title":"RAM usage after importing numpy in python 3.7.2","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm facing some performance issues to execute a fuzzy match based on Leveinshtein distance algorithm.\nI'm comparing two lists, a small one with 1k lines and a second one with 10k lines.\nI have splitted the bigger list in 10 files of 1000 lines to check speed performance, but I checked that Python is using only 1 thread.\nI have googled for many articles and people says how to execute TWO different functions in paralel.\nI would like to know how to execute the SAME code in multiple threads.\nFor example: it's taking 1 second to compare 1 word in a 1000 lines. I would like to split this time in 4 threads.\nIs it possible?\nSorry for the long text and thanks a lot for your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19,"Q_Id":54678059,"Users Score":0,"Answer":"Running the same code in two or more threads won't assist performance. You could potentially split up the task so each handles 250, then have each thread handle 1 of those tasks. Then compare the results at the end.","Q_Score":0,"Tags":"python-3.x","A_Id":54678554,"CreationDate":"2019-02-13T19:34:00.000","Title":"How to use multiple threads to execute the same code and speed up it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using PyCharm with a remote interpreter. My code is showing a scatter figure using matplotlib. I can see the figure normally and interact with (zoom and rotate), but the interaction is too slow. I think this is because it's done through the SSH X-server.\nMy question is how to manually make the figure interactions graphically (using mouse, like zooming, panning, rotation, ...) execute faster? I think this should be via allowing the figure interactions to happen on local machine (machine running PyCharm), not the remote server.\nOne workaround is to save a .fig file, then copy it to my local machine, then load it. But I don't prefer this workaround.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":815,"Q_Id":54679917,"Users Score":0,"Answer":"Interacting with visualisations on separate windows is slow, not just on PyCharm but any IDE that you specify visualisations to be loaded separately. This is because they are loaded on either tkinter or any of the available modules like Qt5 and if you're on a mac, you can also use the inbuilt OSX rendering. Especially if your dataset is large then interaction becomes slower. It just seems that visualisations in Python are not exactly that optimised as you witness on Tableau or even Orange\/Glue.\nThat's why I personally prefer visualising data inline through the IPython console (for that I use Spyder). You cannot interact with plots though, but the purpose suffices.","Q_Score":4,"Tags":"python,matplotlib,ssh,pycharm,xserver","A_Id":54861503,"CreationDate":"2019-02-13T21:43:00.000","Title":"Remote interpreter and local plot in PyCharm?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get OpenCV working, but the issue with this is that my Python27 Numpp version is too old. Every time I write \"install --upgrade numpy\", I am told that Numpy is already up to date in C:Python37. How can I update Numpy in C:Python27 rather than 37? Any help would be much appreciated.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14288,"Q_Id":54683455,"Users Score":0,"Answer":"Extending the first answer by JCutrer, after installing numpy on the specified version, you need to run the python.exe interpreter of the specified version. \nSo, assuming  you did\nc:\\python27\\Scripts\\pip.exe install --upgrade numpy, the libraries have been installed for python27, now you can run python from the below path, or set this path as interpreter in your IDE. \nc:\\python27\\bin\\python27.exe (or python.exe)","Q_Score":2,"Tags":"python,python-2.7,numpy,opencv,pip","A_Id":54683752,"CreationDate":"2019-02-14T04:58:00.000","Title":"How can I upgrade Numpy in just one version of Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python project with multiple files and a cmd.py which uses argparse to parse the arguments, in the other files there are critical functions. What I want to do is: I want to make it so that if in the command line I were to put cmd -p hello.txt it runs that python file. \nI was thinking that I could just simply move the cmd.py file to somewhere like \/usr\/bin\/ or some other directory included in the $PATH, however since I have other files which work with my cmd.py, there will be multiple files in my \/usr\/bin.\nAnother thing that I could do is to make a symbolic link between the cmd.py and \/usr\/bin\/cmd like this: ln -s \/path\/to\/cmd.py \/usr\/bin\/cmd, but then where do i put the cmd.py? and is this best practice?\nNote: I intend for this to work on Linux and MacOS X, not windows","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2883,"Q_Id":54683892,"Users Score":1,"Answer":"You can add a folder to your path.\n\n\nin .bashrc add following\nexport PATH=[New_Folder_Path]:$PATH\n\nput the python program in your path_folder created at step 1.\nmake it executable : chmod u+x [filename]\nopen a new terminal, and you should be able to call the python program\nNOTE: make sure to put the shebang in your python-file : #!\/usr\/bin\/env python3","Q_Score":0,"Tags":"python,linux,command-line,command-line-arguments,argparse","A_Id":54685103,"CreationDate":"2019-02-14T05:42:00.000","Title":"Make Python Project Into Command Line Tool","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Hello stackoverflow people!\nI would like to discuss and see what's the better approach to my problem.\nI have an application that send files to clients using multiple protocols (FTP(S), SFTP, S3, EMail).\nThere's a celery task per directory. A directory can be send to multiple clients and can be send to multiple destinations. e.g. dir1 -> client1 -> FTP and EMail (2 tasks, fine to run in parallel), dir2 -> client1 AND client2 -> same FTP hostname, different remote directories (2 tasks, not fine to run in parallel).\nThis is working fine, however I'm causing client network congestion sometimes, due to multiple connections from multiple workers to the same destination, some clients don't know (or want to implement) QOS.\nI would like to have a logic that don't allow tasks connecting to the same protocol or hostname running at the same time. Per example, a directory that is being send to 2 x S3 buckets, should run once, after it finished the second will start. Or two different directories that is being send to the same FTP server.\nMy initial idea is to implement a celery_worker queue remote control. One queue for each account, protocol. And setup workers with concurrency 1 listening on the queues.\nWondering if any of you had a similar challenge and how did you workaround it.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":201,"Q_Id":54688207,"Users Score":1,"Answer":"Your proposed solution is rather brittle (you really shouldn't rely on celery concurrency settings to control\/prevent concurrent execution) and will probably not solve all the potential race conditions (for example if taskA and taskB are on different queues but need to access a resource that doesn't support concurrent access).\nThere are quite a couple recipes (from rather informal advises to full-blown libs like celery-once) to prevent concurrent execution of one given task. They don't directly solve your own problem but basically the principle is the same: have some shared lock mechanism that the tasks communicate with - try to acquire the lock, only run once they get it, and of course release it. If you're using Redis as result backend, it's rather low read\/write cost and it's 'expire' feature can be really helpful, but you can also just use your SQL database.","Q_Score":1,"Tags":"python,python-3.x,celery,celery-task","A_Id":54690143,"CreationDate":"2019-02-14T10:28:00.000","Title":"Celery task \/ worker assignment logic","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Background of our environment:\n\nData Warehouse system is running with SQL Server 2012. \nData Sources are Excel files and other APIs\n\nIssue:\nThe business metrics are changing frequently and source file is changing frequently and data load failing for multiple reasons.\n\nColumn mismatch\nData type mismatch\nWrong files\nOld or same file, updated twice\n\nSome of the above issues are managed via process guidelines and others at SQL level.\nBut, whenever, there is a new file \/ column added, developer has to manually add the Column \/ table for that change to be impacted.\nMost of the times, the changes came to light only after the job failed or huge data quality \/ mismatch issue identified.\nQuestion:\nIs there any way, this can automated using Python \/ Powershell \/ Any Other scripting languages? In a way, whenever source files are ready, it can read and do the below steps:\n\nRead the column headers.\nGenerate SQL for table structure with identified column headers and create temporary (Staging) table.\nLoad the data into the newly created temporary table.\nAfter some basic data processing, load data into main table (presentation area) mostly through SQL.\n\nChallenges:\n\nThere are 18 unique files, and each file columns are different and it may modified or added anytime according to the business requirement.\nWhen there is an addition of column, how do add that column on main table - altering a table is a good idea here? is it okay to done via script?\n\nNote:\n\nWe have control only from source data file, we cannot do anything with how source file is generated or when can be new column added to source file.\nI am not sure, whether to ask this question on SO OR DBA SE, so if it is not fit here, please move it appropriate forum.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":555,"Q_Id":54692916,"Users Score":0,"Answer":"1.I'm guessing you can identify the file types based on file_names or header.You could create a SSIS package with a Source Script within a foreach loop , for the script define input  and output columns manually and give Generic Names and fixed string length , ColumnNr1,ColumnNr2,ColumnNrN (Where N is max number of Columns from your files +10 for safety) .Create a staging table using the same logic as above,ColumnNr1,2... this will be used for all the files, if the file load is sequencial(As i have assumed), in your script you will  read the header and insert it into a data table or list , compare the numbers of columns between file header and Final Table, create Alter Table statements for new columns based on differences and execute it , send column data from file to OutputBuffer columns  .\n2. Create dynamic SQL procedure based on data processing needs .","Q_Score":0,"Tags":"python,sql-server,excel,etl,data-warehouse","A_Id":55093265,"CreationDate":"2019-02-14T14:37:00.000","Title":"Create tables from Excel column headers using Python and load data?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"ModuleNotFoundError: No module named '_tkinter'\n\nI want to import turtle in Python 3.7\n\nTraceback (most recent call last):   File \"my.py\", line 1, in \n      from turtle import *   File \"\/usr\/local\/lib\/python3.7\/turtle.py\", line 107, in \n      import tkinter as TK   File \"\/usr\/local\/lib\/python3.7\/tkinter\/init.py\", line 36, in \n      import _tkinter # If this fails your Python may not be configured for Tk ModuleNotFoundError: No module named '_tkinter'","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1480,"Q_Id":54693107,"Users Score":0,"Answer":"The IDE tells you that your python is not confingured for Tk (tkinter), which is your problem. While I am not certain on how to fix this becuase I never use turtle or Tk, I have a few ideas.\n\nI am using python 3.7 and importing both turtle and Tk works just fine for me, so I definitely recommend updating to 3.7.\nLook for Tk in your python module library and reinstall it.\nJust find out how to confingure Tk with python 3.2 if updating doesn't work.\n\nI hope I helped!","Q_Score":1,"Tags":"python-3.7","A_Id":54699744,"CreationDate":"2019-02-14T14:47:00.000","Title":"No module named '_tkinter' configured","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"ModuleNotFoundError: No module named '_tkinter'\n\nI want to import turtle in Python 3.7\n\nTraceback (most recent call last):   File \"my.py\", line 1, in \n      from turtle import *   File \"\/usr\/local\/lib\/python3.7\/turtle.py\", line 107, in \n      import tkinter as TK   File \"\/usr\/local\/lib\/python3.7\/tkinter\/init.py\", line 36, in \n      import _tkinter # If this fails your Python may not be configured for Tk ModuleNotFoundError: No module named '_tkinter'","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1480,"Q_Id":54693107,"Users Score":0,"Answer":"if you are using linux go to terminal and type sudo apt-get install python3-tk\nif you are using windows go to command prompt and type cd C:\/Program Files\/Python\/python37\/Scripts press enter then type pip install tkinter\nhope it helped!","Q_Score":1,"Tags":"python-3.7","A_Id":71962791,"CreationDate":"2019-02-14T14:47:00.000","Title":"No module named '_tkinter' configured","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to run some commands that needed me to update pandas, and then numpy, and so I did. Problem is now, when I try to look into a DataFrame in the variable explorer, they don't open and I get this error instead:\nImportError: No module named 'pandas.core.internals.managers'; 'pandas.core.internals' is not a package\nDo you know what is happening?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":788,"Q_Id":54699473,"Users Score":1,"Answer":"I had the same problem. I solved it installing the pandas version 0.24.2\npip install pandas==0.24.2","Q_Score":1,"Tags":"python,pandas,spyder","A_Id":57377131,"CreationDate":"2019-02-14T21:39:00.000","Title":"Getting ImportError on spyder when trying to open a DataFrame after updating pandas and numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a rest api and I was making the routes for the api and stumbled upon a problem. I am using flask restplus to build the api and marshmallow to validate the json sent by the client.\nMy design: I use a decorator that is used to wrap every api route. this decorator validates the json sent by the client against a marshmallow schema and if the json validates, then the decorator lets the api route run. Otherwise, if the json invalidates when it's checked against the schema, it returns the errors that it got when it invalidated the json back to the client without running the route. \nI really like this design as it significantly reduces code repetition and it can automatically validate and invalidate the data posted by the client without me doing pretty much the same thing in each api route -- checking the json sent by the client and then running the route.\nMy only issue is that I have no clue how to unit test this. I have written tests for the specific marshmallow json schemas to check if they raise the correct validation errors when invalid data is passed to them. However, now I need to test the api routes to check if they return the validation errors raised by the schemas. This seems like a lot of repetition of unit tests because I'm checking for the same errors when testing the schemas and again when I'm testing the api routes\/decorator.\nTherefore, do you guys have any recommendation of how I should unit test this. Should I test the api routes specifically, the decorator separately, and the schemas separately? Or should I test just the api routes to check they return the correct errors that the schemas raise?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":471,"Q_Id":54699540,"Users Score":0,"Answer":"This could be a matter of opinion.\nI don't think it is useful to test all schemas, unless they include some custom code like custom fields, validators, etc. There is no need to test marshmallow itself, as it is already extensively covered by its own tests. So testing a marshmallow schema would only serve the purpose of checking you entered the correct field names and validators. That would be quite verbose for low benefits, IMHO.\nI would test the decorator: create a dummy test route, decorate it, check the correct error is returned.\nDeciding whether it is worth testing all routes for all kinds of errors is up to you. As long as your decorator is tested, testing the routes just checks that the decorator is applied to the route with the correct schema.\nSome would argue that, on the contrary, they only care about the API itself and they only need to test the routes. But this means testing all cases on all routes, so that's a lot of duplication. And I don't think this qualify as unit testing, rather integration testing.\nNote you could try to use webargs (maintained by marshmallow team) to replace your decorator, but I don't know how easy it is to integrate to flask-restplus.","Q_Score":0,"Tags":"python,unit-testing,flask,python-decorators,marshmallow","A_Id":54705145,"CreationDate":"2019-02-14T21:45:00.000","Title":"Testing a decorator that wraps api routes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Does anyone know how to get a command shortcut to work for block indenting and un-indenting in Jupyter notebooks?\n\u2028\nIn the Jupiter notebook command group there is a command \u201cautomatically indent selection\u201d. When I put in a command mode control-\/  for that command the notebook does block commenting. \n\u2028\n\u2028\nI don\u2019t see any other command that refers to indenting.\n\u2028\nI can\u2019t seem to figure this","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":64229,"Q_Id":54700726,"Users Score":49,"Answer":"it's \n\nTab\n\nIf you want to unindent, then \n\nShift + Tab\n\nYou need to have selected more rows or it's intellisense...","Q_Score":36,"Tags":"python-3.x,jupyter-notebook,jupyter","A_Id":58294785,"CreationDate":"2019-02-14T23:36:00.000","Title":"Block indent jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know how to get a command shortcut to work for block indenting and un-indenting in Jupyter notebooks?\n\u2028\nIn the Jupiter notebook command group there is a command \u201cautomatically indent selection\u201d. When I put in a command mode control-\/  for that command the notebook does block commenting. \n\u2028\n\u2028\nI don\u2019t see any other command that refers to indenting.\n\u2028\nI can\u2019t seem to figure this","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":64229,"Q_Id":54700726,"Users Score":0,"Answer":"In JupyterLab,ctrl+[ and ctrl+] work for indentation\/deindentation.\nThese solutions also are guaranteed to work, whereas Tab and Shift+Tab can trigger actions like intellisense if your cursor is in the middle of a line.","Q_Score":36,"Tags":"python-3.x,jupyter-notebook,jupyter","A_Id":71100887,"CreationDate":"2019-02-14T23:36:00.000","Title":"Block indent jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"That's it, I'm on Mac Mojave with weasyprint-44, python 3.6, and Cairo etc. versions match. The PDF renders nicely otherwise - symbols and letters are fine - just no numbers?\nSo weird.\nCan anyone point me in the right direction?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":993,"Q_Id":54700953,"Users Score":4,"Answer":"I was able to fix this problem by eliminating the font \"Segoe UI Emoji\" from a font-family CSS declaration. Numbers started appearing again once this font was removed from CSS.\nThe bug seems to have started with some change on macOS 10.14.4.","Q_Score":7,"Tags":"python-3.x,django-views,weasyprint","A_Id":55403588,"CreationDate":"2019-02-15T00:07:00.000","Title":"Only numbers are missing Weasyprint PDF","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to make my first neural network in keras (python) that takes in the x and y distances to the next pipe and outputs whether or not the bird should flap. How would I go about creating an input data set from the game and then turning that into something keras can use for training?\nI don't have very much knowledge in this area and my high school computer science teachers don't know either, therefore I'm not quite sure where to start. I have a very, very basic understanding of Keras and NN concepts. I have tried using .csv files with pandas but I am not sure how to turn that into useable data.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":54701027,"Users Score":0,"Answer":"Sir even i'm new to neural network  but i have some knowledge \n if you want to do this in exactly this manner then i'm no help but\nyour can try doing this by genetic algo which will surely work for this","Q_Score":0,"Tags":"python,pandas,tensorflow,keras,neural-network","A_Id":54706020,"CreationDate":"2019-02-15T00:17:00.000","Title":"How to create a 2 value data table for keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a simple implementation of AlexNet. I tried with using tf.nn.conv2d and tf.layers.conv2d, and the results turn out that the loss dropped faster when using tf.nn.conv2d, even the structure is exactly the same. Does anyone know any explanation for that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":92,"Q_Id":54701429,"Users Score":1,"Answer":"If you try to follow the chain of function calls, you will find that tf.layers.conv2D() makes calls to tf.nn.conv2D() so no matter what you use, tf.nn.conv2d() will be called, it will be just faster if you call it yourself. You can use traceback.print_stack() method to verify that for yourself.\nNOTE This does not mean that they are one and the same, select the function based on your need as there are various other tasks undertaken by tf.layers.conv2D().","Q_Score":0,"Tags":"python,tensorflow","A_Id":54702197,"CreationDate":"2019-02-15T01:18:00.000","Title":"Tensorflow: why tf.nn.conv2d runs faster than tf.layers.conv2d?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I do not understand why we also need the function tf.name_scope when we already have tf.variable_scope. From the Tensorflow official API, I see that the tf.variable_scope is more powerful because it can have an effect on tf.get_variable. When we create layers and want to share variables, we always use tf.variable_scope and tf.name_scope. However, I try to learn something new from code released by Nvidia on GitHub. I found that it is frequent for coders to use tf.name_scope. Why do we still need this function?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":54703473,"Users Score":0,"Answer":"You can use tf.variable_scope to add a prefix on both variables created with tf.get_variable and operations: as you said, this allows also variable sharing but it also makes the first call to tf.get_variable the definition of new variable under this scope.\ntf.name_scope adds a prefix only at the operations: variables defined outside the tf.name_scope using tf.get_variable are not prefixed thus the tf.name_scope is ignored completely for this variable: you're not declarning a variable prefixed in any way.\nThis can be useful when you want to create an operation block (using tf.name_scope) that uses a variable declared outside of it. This variable can be even used by multiple operation blocks at the same time.","Q_Score":0,"Tags":"python,tensorflow","A_Id":54704727,"CreationDate":"2019-02-15T06:03:00.000","Title":"TensorFlow why we still use tf.name_scope when we already have the function tf.variable_scope","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is difference between SGD classifier and SGD regressor in python sklearn?  Also can we set batch size for faster performance in them?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1733,"Q_Id":54704015,"Users Score":1,"Answer":"Well, it's in the name. SGD Classifier is a model that is optimized (trained) using SGD (taking the gradient of the loss of each sample at a time and the model is updated along the way) in classification problems. It can represent a variety of classification models (SVM, logistic regression...) which is defined with the loss parameter. By default, it represents linear SVM. SGD Regressor is a model that is optimized (trained) using SGD  for regression tasks. It's basically a linear model that is updated along the way with a decaying learning rate.","Q_Score":1,"Tags":"python-3.x,machine-learning,scikit-learn","A_Id":54704764,"CreationDate":"2019-02-15T06:50:00.000","Title":"What is difference between SGD classifier and SGD regressor in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Some time ago I ve written a Python script, using poplib library, which retrieves messages from my pop3 email account. Now I would like to use it to retrieve emails from different mail server which works with IMAP. It works well, but only to retrieve messages from Inbox. Is there any way to also get emails from other folders like Spam, Sent etc? I know I could use imaplib and rewrite the script, but my questions is if it's possible to obtain that with poplib.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":554,"Q_Id":54706093,"Users Score":4,"Answer":"No.\nPOP is a single folder protocol.  It is very simple and was not designed for multiple folders.\nYou will need to use IMAP or other advanced protocols to access additional folders.","Q_Score":2,"Tags":"python,email,imaplib,poplib","A_Id":54719050,"CreationDate":"2019-02-15T09:21:00.000","Title":"Checking folders different than inbox using poplib 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 trying to insert a new row of totals after groupby sum.\nI can get the groupby sums of my table. I can also compute the sum of groupby sums with a second groupby sum. I tried and searched here to find a solution to insert\/append each sum of sums as a new row (e.g. named Total) after each group, but to no avail.\nFirst groupby sum\ndf.groupby(['Col1', 'Col2']).sum()\nSecond groupby sum\ndf.groupby(['Col1', 'Col2']).sum().groupby(level=[0]).sum()","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":54708714,"Users Score":0,"Answer":"after the groupby use df.reset_index() to convert the df to a dataframe again","Q_Score":0,"Tags":"python,pandas,sum,pandas-groupby","A_Id":54735778,"CreationDate":"2019-02-15T11:48:00.000","Title":"How to insert a sum row of groupby sums","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get data from an a endoscope into my opencv code in python. The endoscope machine has a dvi output and I have a Datapath vision capture card which helps read it into my system. I understand that opencv can only read from usb cameras or ip webcams. I was wondering if anyone has done this kind of a read into opencv?\nPointers greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":838,"Q_Id":54709269,"Users Score":0,"Answer":"It might be possible to have the DVI stream written to a file, FFMPEG\/gstreamer read the file stream, and then pipe the input into OpenCV.","Q_Score":0,"Tags":"python,c++,opencv","A_Id":54800843,"CreationDate":"2019-02-15T12:19:00.000","Title":"How to access data from the vision capture cards to opencv?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Do we have some alternative plugin for python behave for jumping from feature file to step definition.I know Behave BDD Support is available in professional edition.\nSo do we have something to achieve jumping feature in pycharm community edition or any other tool.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":806,"Q_Id":54711256,"Users Score":0,"Answer":"Unfortunately, there is no alternative to PyCharm Professional edition. I tried XCode with different plugins, but they provide only syntax highlighting. Community edition also provide syntax highlighting without jumping feature.","Q_Score":0,"Tags":"python-behave","A_Id":54923229,"CreationDate":"2019-02-15T14:18:00.000","Title":"Python Behave BDD framework -Step Definition Jumper","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm upgrading a Django project from Django 1.11 to Django 2.1.7, and after changing all the URL patterns to the Django 2 way of doing things, I'm getting a bunch of false positives on the urls.W001 warning when I do manage.py runserver.\nExample:\n?: (urls.W001) Your URL pattern '^some-pattern\/$' [name='some_name'] uses include with a route ending with a '$'. Remove the dollar from the route to avoid problems including URLs.\nWhen I look at that URL pattern in my urls.py file, however, it absolutely doesn't have a ^ or $ in it.\npath('some-pattern\/', views.some_view_function, name='some_name'),\nI've blown away both my local virtualenv and my Vagrant box and started from scratch just to make sure it's not some lingering compiled stuff somewhere, but the behavior is the same when starting from scratch.\nHas anyone else run into this? The app itself seems to run fine, I'm just flummoxed at where Django might be seeing things that don't exist anywhere in my code.\nThanks for any ideas anyone might have.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":813,"Q_Id":54712982,"Users Score":4,"Answer":"Turns out this was indeed related to Django CMS -- this is the first release of theirs that supports Django 2 but it still supports Django 1.11 also, so they're shooting down the middle in some spots and when it pulls in URLs for our apphooks they get translated into patterns with ^ and $ in the mix. Hope that info helps someone else who may run into this. Thanks for all the suggestions!","Q_Score":2,"Tags":"python,django","A_Id":54715374,"CreationDate":"2019-02-15T16:04:00.000","Title":"Django 2.0 Upgrade - False Positives on urls.W001 Warning","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to run jupyter notebook and getting following error.\nI am using Win 7 with anaconda python 3.7.\n\nImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['c:\\users\\paperspace\\anaconda3\\envs\\tensorflow10\\lib\\site-packages\\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.\n\nI have followed the steps mentioned in the error but still not working.","AnswerCount":11,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":64552,"Q_Id":54715835,"Users Score":10,"Answer":"I was getting the error when I was trying to use Keras. This can be fixed by removing the numpy package continuously by running pip3 uninstall numpy. And checking the successful un-installation by opening a python terminal and importing numpy package.","Q_Score":33,"Tags":"python,numpy,tensorflow","A_Id":54793162,"CreationDate":"2019-02-15T19:21:00.000","Title":"Numpy is installed but still getting error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run jupyter notebook and getting following error.\nI am using Win 7 with anaconda python 3.7.\n\nImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['c:\\users\\paperspace\\anaconda3\\envs\\tensorflow10\\lib\\site-packages\\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.\n\nI have followed the steps mentioned in the error but still not working.","AnswerCount":11,"Available Count":6,"Score":-0.0363476168,"is_accepted":false,"ViewCount":64552,"Q_Id":54715835,"Users Score":-2,"Answer":"For me it was about the consoles used. \nMy cygwin terminal - NOPE, dos - NOPE, but console opened from Anaconda or Spyder etc... all commands (pip install etc) worked.","Q_Score":33,"Tags":"python,numpy,tensorflow","A_Id":56572030,"CreationDate":"2019-02-15T19:21:00.000","Title":"Numpy is installed but still getting error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run jupyter notebook and getting following error.\nI am using Win 7 with anaconda python 3.7.\n\nImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['c:\\users\\paperspace\\anaconda3\\envs\\tensorflow10\\lib\\site-packages\\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.\n\nI have followed the steps mentioned in the error but still not working.","AnswerCount":11,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":64552,"Q_Id":54715835,"Users Score":22,"Answer":"Run\npip3 uninstall numpy \nuntil you receive a message stating no files available with numpy to uninstall and then you can freshly install numpy using\npip install numpy\nand that will fix the issue.","Q_Score":33,"Tags":"python,numpy,tensorflow","A_Id":55652317,"CreationDate":"2019-02-15T19:21:00.000","Title":"Numpy is installed but still getting error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run jupyter notebook and getting following error.\nI am using Win 7 with anaconda python 3.7.\n\nImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['c:\\users\\paperspace\\anaconda3\\envs\\tensorflow10\\lib\\site-packages\\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.\n\nI have followed the steps mentioned in the error but still not working.","AnswerCount":11,"Available Count":6,"Score":0.072599319,"is_accepted":false,"ViewCount":64552,"Q_Id":54715835,"Users Score":4,"Answer":"This Means a Duplicated. \nTry pip uninstall numpy or pip3 uninstall numpy then sudo apt-get install python3-numpy\nFOR (DEBIAN DIST)","Q_Score":33,"Tags":"python,numpy,tensorflow","A_Id":56306185,"CreationDate":"2019-02-15T19:21:00.000","Title":"Numpy is installed but still getting error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run jupyter notebook and getting following error.\nI am using Win 7 with anaconda python 3.7.\n\nImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['c:\\users\\paperspace\\anaconda3\\envs\\tensorflow10\\lib\\site-packages\\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.\n\nI have followed the steps mentioned in the error but still not working.","AnswerCount":11,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":64552,"Q_Id":54715835,"Users Score":0,"Answer":"Your issue maybe similar to mine below.\nHow to reproduce it\n\nStarted a virtual environment named \"jupyter_ve\"  with numpy=1.21.0   where I launched jupyter.\nOpened a notebook using a virtual environment named \"project_ve\"   with numpy=1.20.0   where I launched my notebook kernel using \"project_ve\"\nIn Notebook import fails on from numba import njit giving errors install numpy 1.20.0 or lower\n\nSolution\nMake sure you install  numpy version in the virtual environment you used to start the jupyter.\nIn my case above I had to install \/ downgrade numpy in the virtual envrionment where I launched jupyter from.  It doesn't matter that I had installed notebook virtual environment kernel.","Q_Score":33,"Tags":"python,numpy,tensorflow","A_Id":70216694,"CreationDate":"2019-02-15T19:21:00.000","Title":"Numpy is installed but still getting error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run jupyter notebook and getting following error.\nI am using Win 7 with anaconda python 3.7.\n\nImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['c:\\users\\paperspace\\anaconda3\\envs\\tensorflow10\\lib\\site-packages\\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.\n\nI have followed the steps mentioned in the error but still not working.","AnswerCount":11,"Available Count":6,"Score":0.0544914242,"is_accepted":false,"ViewCount":64552,"Q_Id":54715835,"Users Score":3,"Answer":"Use conda update --all \nThis works.","Q_Score":33,"Tags":"python,numpy,tensorflow","A_Id":55599428,"CreationDate":"2019-02-15T19:21:00.000","Title":"Numpy is installed but still getting error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the correct way to perform gradient clipping in pytorch?\nI have an exploding gradients problem.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99166,"Q_Id":54716377,"Users Score":0,"Answer":"Well, I met with same err. I tried to use the clip norm but it doesn't work.\nI don't want to change the network or add regularizers. So I change the optimizer to Adam, and it works.\nThen I use the pretrained model from Adam to initate the training and use SGD + momentum for fine tuning. It is now working.","Q_Score":71,"Tags":"python,machine-learning,deep-learning,pytorch,gradient-descent","A_Id":70205626,"CreationDate":"2019-02-15T20:09:00.000","Title":"How to do gradient clipping in pytorch?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I properly import in python. I now the concept of importing out of java with an ide. If I code in Python, I use Visual Studio Code. My Problem was: How can I enable some sort of \"auto-import\" feature.\nIf there is no such feature how to I import things. In witch order and with how many spaces\/returns in between?\nProgramm I am using: Visual Studio Code.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":85,"Q_Id":54717055,"Users Score":-1,"Answer":"python includes the .py extension for execution its program. it works on direct compiling process thus this is known as interpreted language . For the proper work in python u must know about python","Q_Score":0,"Tags":"python,python-3.x,python-2.7,import","A_Id":54786366,"CreationDate":"2019-02-15T21:05:00.000","Title":"Python - Manage imports in VSC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So from just learning how to make functions, I thought of if I could turn the function purple, just like a normal print() or str() function. And with that in mind, it may seem pretty obvious that I am still a beginner when it comes to coding. From what I know, it may have something to do with sys.stdin.write, but I don't know. This will help me to make different languages for others who don't speak or write English.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":436,"Q_Id":54720754,"Users Score":0,"Answer":"In Options => Configure IDLE => Settings => Highlights there is a highlight setting for builtin names (default purple), including a few non-functions like Ellipsis.  There is another setting for the names in def (function) and class statements (default blue).  You can make def (and class) names be purple also.\nThis will not make function names purple when used because the colorizer does not know what the name will be bound to when the code is run.","Q_Score":0,"Tags":"function,python-3.5,python-idle","A_Id":54731071,"CreationDate":"2019-02-16T07:10:00.000","Title":"How to make functions appear purple","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am handling my second year project which includes some machine learning backend along with a Mobile application front end.In simple terms i am creating\na androing\/react native application which would take an input from the user and prosses in a backend development which includes python for some machine learning.\nMy question is, is it possible  to connect these 2 together. I have gone through some stuff altho i am not very clear on how to create a connection on this. \nAlso some opinions on either i should go with android or react native or any other language to go on python or not would be very  useful. \nThank you","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":809,"Q_Id":54720796,"Users Score":0,"Answer":"Yes. you can develop a python web service (REST OR SOAP) and use this for the backend for your application. \nalso, if you develop a service application (server-client) you must develop a service with python (or any languages) in your server after that connect your mobile application (reactjs, android studio, swift, ...) to this server.","Q_Score":1,"Tags":"java,python,mobile,native,backend","A_Id":54720908,"CreationDate":"2019-02-16T07:18:00.000","Title":"Is it possible to use Python backend and a Android\/Native application as Front end","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am handling my second year project which includes some machine learning backend along with a Mobile application front end.In simple terms i am creating\na androing\/react native application which would take an input from the user and prosses in a backend development which includes python for some machine learning.\nMy question is, is it possible  to connect these 2 together. I have gone through some stuff altho i am not very clear on how to create a connection on this. \nAlso some opinions on either i should go with android or react native or any other language to go on python or not would be very  useful. \nThank you","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":809,"Q_Id":54720796,"Users Score":0,"Answer":"Yes, it is possible.\nFor example, you can use Python as backend (server), with some exposed HTTP \"interface\", then make an Android application that communicates with these Python backend with HTTP request \/ response.\nOr, if you are making a serverless application, you can make this Python backend as a .so library or using SL4A then call them in your Android application.","Q_Score":1,"Tags":"java,python,mobile,native,backend","A_Id":54720835,"CreationDate":"2019-02-16T07:18:00.000","Title":"Is it possible to use Python backend and a Android\/Native application as Front end","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"when I activate my virtual environment and install packages that I need, when I close the command prompt or turn off the computer do I need to install packages again?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3102,"Q_Id":54721241,"Users Score":2,"Answer":"No you don't need to install it again if you restart your machine.\nYou need to reinstall again only it you destroy your virtual image and recreate it. If your have such scenario \nI will suggest to use configure tools like Chef which can automated to install all your setups once you recreate your image.","Q_Score":1,"Tags":"python","A_Id":54721308,"CreationDate":"2019-02-16T08:27:00.000","Title":"do I need to install packages every time in python virtual environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In other words - I want to create a simple Django Rest Framework app which preferable doesn't need it's own database.\nThis Django API app should only provide data for some external frontend app (e.g. Angular\/Webpack stack).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":229,"Q_Id":54723710,"Users Score":0,"Answer":"There is no technical difference between external and the own database as pointed out by Kalus D. any database which is online and the username and password of it is known (means provided in django's setting.py) is Django's database. There can be multiple Databases of this type. so that's it.\nBut I don't think you mean the above. I think What you mean is collect data from external APIs or web pages e.g Wikipedia Rest API. then process that data like filter it, combine different data or anything you like and then send it to the user.\nthen yes it is possible but you don't need DRF for it. DRF is mainly applicable when you want to serialize your won models data. you can just send response in JSON format insted of html without using DRF.","Q_Score":1,"Tags":"python,django,django-rest-framework","A_Id":54723947,"CreationDate":"2019-02-16T13:44:00.000","Title":"Is it possible to create a Django app which only reads data from external database and provides REST API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have 2 Python environments (Python 3.6 by Visual studio 2017 and Python 3.7 by Anaconda)\nWhen I run a script I get an error that import numpy\n\nTraceback (most recent call last):   File\n  \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\numpy\\core__init__.py\",\n  line 16, in \n      from . import multiarray ImportError: DLL load failed: The specified module could not be found.\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"D:\\projects\\UdacityNanoDegreeCourse\\UdacityNanoDegreeCourse\\LearningCurves\\LearningCurves.py\",\n  line 2, in \n      import numpy as np   File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\numpy__init__.py\", line\n  142, in \n      from . import add_newdocs   File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\numpy\\add_newdocs.py\",\n  line 13, in \n      from numpy.lib import add_newdoc   File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\numpy\\lib__init__.py\",\n  line 8, in \n      from .type_check import *   File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\numpy\\lib\\type_check.py\",\n  line 11, in \n      import numpy.core.numeric as _nx   File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\numpy\\core__init__.py\",\n  line 26, in \n      raise ImportError(msg) ImportError: Importing the multiarray numpy extension module failed.  Most likely you are trying to import a\n  failed build of numpy. If you're working with a numpy git repo, try\n  git clean -xdf (removes all files not under version control). \n  Otherwise reinstall numpy.\nOriginal error was: DLL load failed: The specified module could not be\n  found.\n\nAs a temporary fix I run Visual Studio from Anaconda prompt.\nHow can I fix the environment so that I could run Visual Studio as usually by double click? Do I need to change PATH somehow?\nRight click-> Activate Environment didn't help either.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":469,"Q_Id":54724459,"Users Score":0,"Answer":"Resolved it myself\nIn the PATH variable\nC:\\ProgramData\\Anaconda3\nC:\\ProgramData\\Anaconda3\\Library\\mingw-w64\\bin\nC:\\ProgramData\\Anaconda3\\Library\\usr\\bin\nC:\\ProgramData\\Anaconda3\\Library\\bin\nC:\\ProgramData\\Anaconda3\\Scripts\nshould go first","Q_Score":2,"Tags":"python,python-3.x,visual-studio,numpy,anaconda","A_Id":55090778,"CreationDate":"2019-02-16T15:09:00.000","Title":"Visual studio can't see Anaconda's modules","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Was asking if I could do a search on the entire eclipse library which includes my closed projects. I did a file search(Ctrl + H) but they only shows results for projects that are open.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":157,"Q_Id":54724905,"Users Score":0,"Answer":"When a project is closed, it can no longer be changed in the Workbench and its resources no longer appear in the Workbench, but they do still reside on the local file system. Closed projects require less memory. Also, since they are not examined during builds, closing a project can improve build time.\nA closed project is visible in the Package Explorer view but its contents cannot be edited using the Eclipse user interface. Also, an open project cannot have dependency on a closed project. The Package Explorer view uses a different icon to represent a closed project.","Q_Score":0,"Tags":"python,eclipse,search,project","A_Id":54724960,"CreationDate":"2019-02-16T15:55:00.000","Title":"How to search through eclipse closed projects?","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":"Ive started experimenting with tensorflow lately and there is one thing I'm not quite sure i get right:\n  If i have a set of training data, train the model  on it for N number of epochs and than use model.save(\"Multi_stage_test.model\") to save the model.\nAfter running the program again with the same training data and with the previously trained model loaded with model=load_model(\"Multi_stage_test.model\"). Am I continuing to train the model (the 1 epoch of the training session is a N+1 epoch for the model) or am I retraining the model (the 1 epoch of the training session is a 1 epoch for the model)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":54726275,"Users Score":1,"Answer":"If you load your model before the training instructions, then you are continuing to train the same model. Tensorflow will just load the pre-trained weights of your model and continue updating them during the new training session.","Q_Score":0,"Tags":"python,tensorflow","A_Id":54726295,"CreationDate":"2019-02-16T18:25:00.000","Title":"Retraining or Continuing Training","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given a list of numbers, you have to print those numbers which are not multiples of 3 in python 3\nInput Format:\nThe first line contains the list of numbers separated by a space.\nOutput Format:\nPrint the numbers in a single line separated by a space which are not multiples of 3.\nExample:\nInput:\n1 2 3 4 5 6\nOutput:\n1 2 4 5\nExplanation:\nHere the elements are 1,2,3,4,5,6 and since 3,6 are multiples of 3, removing them the list leaves 1,2,4,5.","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11631,"Q_Id":54730271,"Users Score":0,"Answer":"Use the modulo operator. (%)  This operator will yield the remainder from the division of the first argument with the second.  So when you are wanting numbers that are not multiples of 3, another way to say that is you are looking for numbers whose remainder is not 0 when divided by 3. \nx % 3 != 0.","Q_Score":0,"Tags":"python,python-3.x","A_Id":54730359,"CreationDate":"2019-02-17T05:06:00.000","Title":"Print numbers in list which are not multiples of 3 in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use featuretools to generate features to help me predict the number of museum visits next month.\nCan featuretools generate features for time series? Should I changed the data so that the id is the month or can featuretools do it automatically?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":468,"Q_Id":54730480,"Users Score":0,"Answer":"Featuretools can certainly help with this. Can you provide more information on the dataset and specific prediction problem so we can help?","Q_Score":1,"Tags":"python,featuretools","A_Id":54730825,"CreationDate":"2019-02-17T05:40:00.000","Title":"Automated feature generation for time series problems - Featuretools","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use aiml in Python 3.6, I am using aiml library for it, but there is a problem with what I expected and what I got!!\nfor every input, it's showing me \n\n\"WARNING: No match found for input: hello(this is input)\"","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":231,"Q_Id":54731791,"Users Score":0,"Answer":"You could always look at programy, full Python 3 from the ground up and supports 3.6 and 3.7 and above","Q_Score":0,"Tags":"python,python-3.6,aiml","A_Id":55191733,"CreationDate":"2019-02-17T09:25:00.000","Title":"How to use AIML with python 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been working for a while with some cheap PIR modules and a raspberry pi 3. My aim is to use 4 of these guys to understand if a room is empty, and turn off some lights in case.\nNow, this lovely sensors aren't really precise. They false trigger from time to time, and they don't trigger right after their status has changed, and this makes things much harder.\nI thought I could solve the problem measuring a sort of \"density of triggers\", meaning how many triggers occurred during the last 60 seconds or something.\nMy question is how could I implement effectively this solution? I thought to build a sort of container and fill it with elements with a timer or something, but I'm not really sure this would do the trick.\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":54733751,"Users Score":0,"Answer":"How are you powering PIR sensors? They should be powered with 5V. I had similar problem with false triggers when I was powered PIR sensor with only 3.3V.","Q_Score":0,"Tags":"python,raspberry-pi3","A_Id":54741625,"CreationDate":"2019-02-17T13:30:00.000","Title":"Count number of Triggers in a given Span of 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 am creating a dynamic blog. I use Django's admin to add posts, and I have created some simple tags that python then substitutes for the actual html and css that are needed by the browser. This makes each blog easier to create and easier to read while creating.\nBefore Django saves the new blog, I've coded my model to send the text to a python script, which parses the code and creates the finished html.\nThis all works great, but I would also like to be able to parse the code before Django loads it, that way I can remove the html\/css programatically, changing it back to the easier to read tags, making it easier to edit an already created blog.\nIs there a way to capture control of Django admin BEFORE it loads model data into the form for editing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":87,"Q_Id":54734948,"Users Score":1,"Answer":"The more simple solution is to have two fields, the original and the generated HTML.\nUse the original as you are using it now and save the generated HTML to the other field.\nUse the other field for your templates.","Q_Score":0,"Tags":"python,django,django-admin","A_Id":54735147,"CreationDate":"2019-02-17T15:54:00.000","Title":"How to parse text before being loaded into Django's admin for editing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm pretty new to object detection. I'm using tensorflow object detection API and I'm now collecting datasets for my project \nand model_main.py to train my model.\nI have found and transformed two quite large datasets of cars and traffic lights with annotations. And made two tfrecords from them. \nNow I want to train a pretrained model however, I'm just curious will it work? When it is possible that an image for example \"001.jpg\" will have of course some annotated bounding boxes of cars (it is from the car dataset) but if there is a traffic light as well it wouldn't be annotated -> will it lead to bad learning rate? (there can be many of theese \"problematic\" images) How should I improve this? Is there any workaround? (I really don't want to annotate the images again)\nIf its stupid question I'm sorry, thanks for any response - some links with this problematic would be the best ! \nThanks !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1404,"Q_Id":54737739,"Users Score":1,"Answer":"The short answer is yes, it might be problematic, but with some effort you can make it possible.\nIf you have two urban datasets, and in one you only have annotations for traffic lights, and in the second you only have annotations for cars, then each instance of car in the first dataset will be learned as false example, and each instance of traffic light in the second dataset will be learned as false example.\nThe two possible outcomes I can think of are:\n\nThe model will not converge, since it tries to learn opposite things.\nThe model will converge, but will be domain specific. This means that the model will only detect traffic lights on images from the domain of the first dataset, and cars on the second.\nIn fact I tried doing so myself in a different setup, and got this outcome.\n\nIn order to be able to learn your objective of learning traffic lights and cars no matter which dataset they come from, you'll need to modify your loss function. You need to tell the loss function from which dataset each image comes from, and then only compute the loss on the corresponding classes (\/zero out the loss on the classes do not correspond to it). So returning to our example, you only compute loss and backpropagate traffic lights on the first dataset, and cars on the second.\nFor completeness I will add that if resources are available, then the better option is to annotate all the classes on all datasets in order to avoid the suggested modification, since by only backpropagating certain classes, you do not enjoy using actual false examples for other classes.","Q_Score":0,"Tags":"python,tensorflow,object-detection-api","A_Id":54782462,"CreationDate":"2019-02-17T21:13:00.000","Title":"Is it possible to train model from multiple datasets for each class?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using pygame, would it be more efficient to:\n\nBlit a single sprite from a portion of a spritesheet each frame\nAt startup, blit each sprite from a spritesheet to their own Surfaces, then blit those Surfaces\n\nIs there any performance differences between the two? Would it take more draw calls to use the first method, versus individual Surfaces at startup (i.e. does doing this at startup store copies of those pixels in ram\/vram)?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":131,"Q_Id":54738650,"Users Score":3,"Answer":"It would be faster to blit the images into a surface, then blit those surfaces.\nHowever it would consume more memory, since you'll need to keep those surfaces somewhere in memory.\nWhy?\nWhen you go to blit the image from your spritesheet, you'll end up subsurfing\/clipping the spritesheet surface, which will mean you'll need to generate another surface on the spot. However, this process won't take long.\nThe performance benefit most likely isn't worth it, so I'd recommend just go with whichever method you're most comfortable with. If you're concerned about performance, check out the builtin CProfile python module.\nVRAM never comes into this equation. pygame.Surface is derived from SDL_Surface from the SDL library for the C programming language. SDL_Surface is primarily targeted toward software rendering, which means the surface pixels are stored in standard RAM.","Q_Score":3,"Tags":"python,pygame","A_Id":54740204,"CreationDate":"2019-02-17T23:26:00.000","Title":"Pygame - More efficient to blit a sprite from spritesheet, or blit invidual sprites to their own surfaces?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a for loop in Python in Pycharm IDE. I have 20 iterations of the for loop. However, the bug seems to be coming from the dataset looped during the 18th iteration. Is it possible to skip the first 17 values of the for loop, and solely jump to debug the 18th iteration?\nCurrently, I have been going through all 17 iterations to reach the 18th. The logic encompassed in the for loop is quite intricate and long. Hence, every cycle of debug through each iteration takes a very long. \nIs there some way to skip to the desired iteration in Pycharm without going in in-depth debugging of the previous iterations?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":1359,"Q_Id":54739728,"Users Score":-1,"Answer":"You can set a break point with a condition (i == 17 [right click on the breakpoint to put it]) at the start of the loop.","Q_Score":1,"Tags":"python,for-loop,debugging,pycharm","A_Id":68756853,"CreationDate":"2019-02-18T02:33:00.000","Title":"While debugging in pycharm, how to debug only through a certain iteration of the for loop?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to build an application (local, not online) by using front-end web technology for the UI, the application simply displays PDFs and has a few text fields for the user to fill in with regards to the current PDF they're viewing, the user can then export their notes and a file path to the document in CSV file format.\ncomment about file, some more notes, C:\\somefolder\\doc1.pdf\ncomment about file, some more notes, C:\\somefolder\\doc2.pdf\nMy first issue, JavaScript can't access the local file system, so I used a file upload form which worked except the filepaths were shown as blob filepaths and not the actual system file path. Other than that my \"application\" worked as intended.\nI went and learned Flask in hopes of using python for the back end, which works great except when I pass in the file path to the pdf C:\\SomeFolder\\doc1.pdf inside the 'src' attribute for an  Chrome says it can't access local files. SO I'm back to sqaure one!\nHow can I go about building this application with local file access?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1477,"Q_Id":54739824,"Users Score":0,"Answer":"I think mht is exactly what you want. mht is a file extension recongnized by IE. Internally it is an HTML file. IE (only) treats a mht file with the same security restrictions that a exe might have. You could access the file system, delete a file, display a file etc.. It is everything that html\/javascript security was trying to prevent.  Now that IE has changed significantly I don't know what the support for this is nowadays. I couldn't find a reference page to give you a link, but it is simple enough - just save a html file with an mht extension","Q_Score":0,"Tags":"python,html,flask,electron","A_Id":70411775,"CreationDate":"2019-02-18T02:47:00.000","Title":"Building a web application that can work with local files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I read that the heapq.merge function is specifically used to merge 2 sorted arrays? is the time complexity O(n)? if not what is it and why? Also what is its space-complexity.\nI was solving the question to merger 2 sorted arrays with 2 pointers and could achieve O(n) time complexity and O(n) space complexity.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1130,"Q_Id":54740420,"Users Score":2,"Answer":"If you are merging K sorted arrays and each array has N elements then heapq.merge will perform the operation in time complexity of NK(logK).  Because NK is the total number of elements across all the K arrays and each element has to be compared.  While logK is the time complexity of the bubble down operations from the top of the heap (that is the height of the heap).\nIn your case K=2, log(2) = 1.  So in your special case it is O(n)","Q_Score":5,"Tags":"python,time-complexity,heapq","A_Id":65523850,"CreationDate":"2019-02-18T04:18:00.000","Title":"What is the time complexity of the heapq.merge in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have many qualitative variables in one column1 and corresponding qualitative values in another column which have blank values. I want to replace the blanks with the MODE value of each qualitative variable in column 1. For example if I have varibles such as Accountant, Engineer, Manager, etc. in column 1 and if I have Bachelor's degree as MODE for accountant, Master's for Engineer in column 2, I want to replace the coressponding blanks with Bachelor's and Master's Correctly. How can I achieve this in pandas?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":90,"Q_Id":54741230,"Users Score":2,"Answer":"df.loc[df[\"columnname\"]==0,\"columnname\"]=np.nan\ndf[\"columnname\"]=df.groupby(\"groupbycolumnname\").columnname.transform(lambda x: x.fillna(x.mode()))","Q_Score":1,"Tags":"python,pandas","A_Id":54742112,"CreationDate":"2019-02-18T05:59:00.000","Title":"Filtering and filling Nan with mode in Pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Note: I am not simply asking how to execute a Python script within Jupyter, but how to evaluate a python variable which would then result in the full path of the Python script I was to execute.\nIn my particular scenario, some previous cell on my notebook generates a path based on some condition.\nExample on two possible cases:\n\nscript_path = \/project_A\/load.py \nscript_path = \/project_B\/load.py\n\nThen some time later, I have a cell where I just want to execute the script. Usually, I would just do:\n%run -i \/project_A\/load.py \nbut I want to keep the cell's code generic by doing something like:\n%run -i script_path\nwhere script_path is a Python variable whose value is based on the conditions that are evaluated earlier in my Jupyter notebook.\nThe above would not work because Jupyter would then complain that it cannot find script_path.py. \nAny clues how I can have a Python variable passed to the %run magic?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":54752228,"Users Score":0,"Answer":"One hacky way would be to change the directory via %cd path \nand then run the script with %run -i file.py\nE: I know that this is not exactly what you were asking but maybe it helps with your problem.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":54752417,"CreationDate":"2019-02-18T17:11:00.000","Title":"How to evaluate the path to a python script to be executed within Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to compare the values of the items in two different dictionaries.\nLet's say that dictionary RawData has items that represent phone numbers and number names.\nRawdata for example has items like: {'name': 'Customer Service', 'number': '123987546'} {'name': 'Switchboard', 'number': '48621364'}\nNow, I got dictionary FilteredData, which already contains some items from RawData: {'name': 'IT-support', 'number': '32136994'} {'name': 'Company Customer Service', 'number': '123987546'}\nAs you can see, Customer Service and Company Customer Service both have the same values, but different keys. In my project, there might be hundreds of similar duplicates, and we only want unique numbers to end up in FilteredData.\nFilteredData is what we will be using later in the code, and RawData will be discarded.\nTheir names(keys) can be close duplicates, but not their numbers(values)**\nThere are two ways to do this. \nA. Remove the duplicate items in RawData, before appending them into FilteredData.\nB. Append them into FilteredData, and go through the numbers(values) there, removing the duplicates. Can I use a set here to do that? It would work on a list, obviously.\nI'm not looking for the most time-efficient solution. I'd like the most simple and easy to learn one, if and when someone takes over my job someday. In my project it's mandatory for the next guy working on the code to get a quick grip of it.\nI've already looked at sets, and tried to face the problem by nesting two for loops, but something tells me there gotta be an easier way.\nOf course I might have missed the obvious solution here.\nThanks in advance!","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":60,"Q_Id":54760521,"Users Score":1,"Answer":"What you can do is take a dict.values(), create a set of those to remove duplicates and then go through the old dictionary and find the first key with that value and add it to a new one. Keep the set around because when you get the next dict entry, try adding the element to that set and see if the length of the set is longer that before adding it. If it is, it's a unique element and you can add it to the dict.","Q_Score":0,"Tags":"python,python-2.7,dictionary","A_Id":54760691,"CreationDate":"2019-02-19T07:07:00.000","Title":"Comparing values of two dictionary's items","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement doc2vec, but I am not sure how the input for the model should look like if I have pretrained word2vec vectors.\nThe problem is, that I am not sure how to theoretically use pretrained word2vec vectors for doc2vec. I imagine, that I could prefill the hidden layer with the vectors and the rest of the hidden layer fill with random numbers\nAnother idea is to use the vector as input for word instead of a one-hot-encoding but I am not sure if the output vectors for docs would make sense.\nThank you for your answer!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1101,"Q_Id":54762478,"Users Score":4,"Answer":"You might think that Doc2Vec (aka the 'Paragraph Vector' algorithm of Mikolov\/Le) requires word-vectors as a 1st step. That's a common belief, and perhaps somewhat intuitive, by analogy to how humans learn a new language: understand the smaller units before the larger, then compose the meaning of the larger from the smaller. \nBut that's a common misconception, and Doc2Vec doesn't do that. \nOne mode, pure PV-DBOW (dm=0 in gensim), doesn't use conventional per-word input vectors at all. And, this mode is often one of the fastest-training and best-performing options. \nThe other mode, PV-DM (dm=1 in gensim, the default) does make use of neighboring word-vectors, in combination with doc-vectors in a manner analgous to word2vec's CBOW mode \u2013 but any word-vectors it needs will be trained-up simultaneously with doc-vectors. They are not trained 1st in a separate step, so there's not a easy splice-in point where you could provide word-vectors from elsewhere. \n(You can mix skip-gram word-training into the PV-DBOW, with dbow_words=1 in gensim, but that will train word-vectors from scratch in an interleaved, shared-model process.)\nTo the extent you could pre-seed a model with word-vectors from elsewhere, it wouldn't necessarily improve results: it could easily send their quality sideways or worse. It might in some lucky well-managed cases speed model convergence, or be a way to enforce vector-space-compatibility with an earlier vector-set, but not without extra gotchas and caveats that aren't a part of the original algorithms, or well-described practices.","Q_Score":0,"Tags":"python,machine-learning,nlp,word2vec,doc2vec","A_Id":54777057,"CreationDate":"2019-02-19T09:11:00.000","Title":"How to use pretrained word2vec vectors in doc2vec model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am storing multiple time-series in a MongoDB with sub-second granularity. The DB is updated by a bunch of Python scripts, and the data stored serve two main purposes:\n(1) It's a central information source for the latest data from all series. Multiple scripts access it every second or so to read the latest datapoint in each collection.\n(2) It's a long-term data store. I often load the whole DB into Python to analyse trends in the data.\nTo keep the DB as efficient as possible, I want to bucket my data (ideally holding one document per day in each collection). Because of (1), however, the bigger the buckets, the more expensive the sorting required to access the last datapoint.\nI can think of two solutions here, but I'm not sure what alternatives there are, or which is the best way:\na) Store the latest timestamp in a one-line document in a separate db\/collection. No sorting required on read, but an additional write required every time a any series gets a new datapoint.\nb) Keep the buckets smaller (say 1-hour each) and sort.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":54763401,"Users Score":0,"Answer":"With a) you write smallish documents to a separate collection, which is performance wise preferable to updating large documents. You could write all new datapoints in this collection and aggregate them for the hour or day, depending on your preference. But as you said this requires an additional write operation.\nWith b) you need to keep the index size for the sort field in mind. Does the index size fit in memory? That's crucial for the performance of the sort, as you do not want to do any in memory sorting of a large collection.\nI recommend exploring the hybrid approach, of storing individual datapoints for a limited time in an 'incoming' collection. Once your bucketing interval of hour or day approaches, you can aggregate the datapoints into buckets and store them in a different collection. Of course there is now some additional complexity in the application, that needs to be able to read bucketed and datapoint collections and merge them.","Q_Score":0,"Tags":"python,mongodb,time-series","A_Id":54764199,"CreationDate":"2019-02-19T09:57:00.000","Title":"How to optimally access the latest datapoint in MongoDB?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have purchased Sage 100 partner account. I have also set up Sage ERP 100 on windows server 2016. But, I am stuck at the following points.\n\nWhere to add business\nHow to set up web services and access REST APIs\nHow I will make server configuration\n\nAny help in Sage 100 setup will be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":445,"Q_Id":54764065,"Users Score":3,"Answer":"Typically you would work with a Sage partner or reseller to set up your Sage 100 environment.  Depending on your location, there should be several available.  You would typically check the Sage website to see the Sage partners in your area.\nWith that said, I used to do a lot of programming against Sage 100 and I can tell you that there is no REST or web services API.  What you would typically do is deploy your own API that reads from Sage 100 as a database.  There is an ODBC connection that is included by default with the product, called SOTAMAS90, that will allow you read-only access to all the Sage 100 tables.  The 32-bit connector is installed automatically when you install the program.  There is a 64 bit version as well, but that takes more work to set up.  The 32 bit version is easiest, but it does require that your API code be running as a 32 bit service or program.\nI would typically write C# programs that consume the SOTAMAS90 data and serve it via REST.  ASP.NET Web API or Core are both good choices for doing this.\nSince the SOTAMAS90 ODBC client is read-only, you will have to do something else if you need to write data back to Sage 100.  The two interfaces that I'm familiar with are VI and BOI.\nVI, or Visual Integrator is basically a utility for importing data from a source file (typically a CSV).  It has some limitations, but it does work.  You can launch it programmatically, which makes it usable on-demand.  If doesn't throw error messages, however.  If a row can't be written, it just skips it.  You can view a report after the fact to see what wrote and what didn't.  \nBOI, or the Business Object Interface, is a COM component that you can code against.  It provides more robust data validation, and does throw errors on a per-record (and sometimes a per-field) basis so you can respond to those in your code accordingly.  Unfortunately, while most of the modules are exposed the BOI, not all of them are.  Every year, Sage is porting more and more functionality to \"the new framework\" which also means it is available via BOI.  \nFinally, you can also set up a linked server in SQL Server to serve the ODBC data that way.  Any way you hit that SOTAMAS90 DSN though, it's slow.  Some developers like to copy all of the data to SQL Server and serve it from there.  If you do that, be sure to add foreign keys and indexes.  And run a nightly ETL to keep the data fresh.  There are also solutions via User Defined Scripts that will allow you to respond to individual row CRUD events.\nHope that helps.\nAaron","Q_Score":0,"Tags":"python,ruby,cloud,erp,sage-one","A_Id":54817105,"CreationDate":"2019-02-19T10:30:00.000","Title":"Sage 100 ERP setup on windows server machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"All, I am pursuing a path of manual installation of python libraries, one that unfortunately, I cannot deviate from and it has become challenging because some of the libraries are just not easily found from pypi.org.    This is a Windows 10 set up using Anaconda for python 3.7\nMy goal is to install SPACY and I have tried this version: spacy-2.0.18-cp37-cp37m-win_amd64.whl\nWhich Requires Collecting thinc<6.13.0,>=6.12.1 (from spacy==2.0.18)\nNow I can't seem to find 6.13.0   But was able to find 6.12.1 also found thinc-7.0.0.   \nso I installed thinc-7.0.0 but spacy does not recognize that as >= 6.12.1  not sure if I am interpreting it correctly. \nSo instead I install thinc-6.12.0-cp37-cp37m-win_amd64.whl \nwhich fails because it is looking for.. Collecting msgpack-numpy<0.4.4.0 (from thinc==6.12.0)\nHowever msgpack-numpy<0.4.4.0  seems undiscoverable.   \nI have found msgpack_numpy-0.4.4.2-py2.py3-none-any.whl\nI also Found msgpack_numpy-0.4.4-py2.py3-none-any.whl\nof which neither will be accepted by thinc-6.12.0 as valid.\nSo have I chosen the wrong spacy version to start with for 3.7? \nI tried this path in 3.6 and I think I was able to get it all to work, is the python 3.7 path just broken?  \nIf someone knows the path and the location of the files to get spacy to work, that would be great.   Unfortunately, I cannot just issue pip commands at this time..\nbest regards","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":54766199,"Users Score":0,"Answer":"After many tries, I figured out the simple mistake I was making...\nCollecting msgpack-numpy<0.4.4.0 (from thinc==6.12.0)    Does not mean, I need 0.4.4.0  it means I need a package less than 0.4.4.0.\nSo I found msgpack_numpy-0.4.3.2-py2.py3-none-any.whl   \nIt is confusing to list packages as a less than or equal requirement that do not actually exist.   \nI eventually was able to install spacy after many tries of different combinations of thinc, regex, spacy \nregex==2018.01.10\nmsgpack-numpy 0.4.3.2\nthinc-6.12.1\nSuccessfully installed spacy-2.0.18","Q_Score":1,"Tags":"python,numpy","A_Id":54767990,"CreationDate":"2019-02-19T12:19:00.000","Title":"Python - Manual - libary installation Failure on Windows with Spacy, Thinc and msgpack-numpy python 3.7","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a trouble picking the right data structure as\/library . I lack in experience in the area of image processing \/ pattern recognition . The aim is to building a simple prototype to learn recognizing particular shapes from construction plans. I would be great full for any indication about the data structure as I know It will be hard to switch it later on during the project and thus I am not entirely sure which one to pick. \nThe problem is , I plan to use a kind of neural network \/ algorithm later on so the performance of processing of the data structure may happen to be my bottle neck.\nI was thinking about NumPy \/ SciPy \/  PIL \/ MatPlotLib\nI will be extremely grateful for expertise of anyone who has tackled similar problem","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":54767421,"Users Score":0,"Answer":"If you're planning on using something like PyTorch later on (which would tie in to the sort of neural-network functionality you're pursuing), I'd become familiar with how NumPy operates, as it bridges pretty well into Torch data structures. If it helps, a lot of SciPy and Matplotlib functions work beautifully with Numpy structures right out of the box.\nIt's hard to tell exactly what you're looking for in these non-neural data structures; where are you worried about performance concerns and bottlenecks?\nI'd recommend starting out with some PyTorch (or other deep learning framework) tutorials regarding image recognition and classification; it will get you closer to where you want to end up, and you'll be better able to make decisions about what your eventual program structure needs will be.","Q_Score":1,"Tags":"python,algorithm,image-processing,data-structures","A_Id":54767624,"CreationDate":"2019-02-19T13:27:00.000","Title":"data structures to recognize particular elements \/ shapes with similar patterns on the image in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want a regex that matches both '1' and '1.' but not '12', i.e. the 1 must not be part of a bigger token, and if it's followed by a period, I want to match that too. All quotes here denoting strings.\nWhy doesn't the pattern 1\\.?\\b match the period in the string '1.' ?\nIf I continue the string, it catches the period: '1.2'\nSince 1\\b matches '1', \\b must include the end of the string, so I  expected \\.? to match the period and \\b to match the end of the string. Why is the period not matched when it is the last character?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":54768751,"Users Score":1,"Answer":"Because there is no word boundary after the dot. A word boundary is defined as the place where something which isn't a word character is adjacent to something which is.\nMaybe you are looking for \\b1\\.?","Q_Score":0,"Tags":"python,regex","A_Id":54768765,"CreationDate":"2019-02-19T14:38:00.000","Title":"\\b after \\. not catching period","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to build a machine learning system with large amount of historical trading data for machine learning purpose (Python program). \nTrading company has an API to grab their historical data and real time data. Data volume is about 100G for historical data and about 200M for daily data. \nTrading data is typical time series data like price, name, region, timeline, etc. The format of data could be retrieved as large files or stored in relational DB.  \nSo my question is, what is the best way to store these data on AWS and what'sthe best way to add new data everyday (like through a cron job, or ETL job)? Possible solutions include storing them in relational database like Or NoSQL databases like DynamoDB or Redis, or store the data in a file system and read by Python program directly. I just need to find a solution to persist the data in AWS so multiple team can grab the data for research. \nAlso, since it's a research project, I don't want to spend too much time on exploring new systems or emerging technologies. I know there are Time Series Databases like InfluxDB or new Amazon Timestream. Considering the learning curve and deadline requirement, I don't incline to learn and use them for now. \nI'm familiar with MySQL. If really needed, i can pick up NoSQL, like Redis\/DynamoDB. \nAny advice? Many thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":54770900,"Users Score":0,"Answer":"If you want to use AWS EMR, then the simplest solution is probably just to run a daily job that dumps data into a file in S3. However, if you want to use something a little more SQL-ey, you could load everything into Redshift. \nIf your goal is to make it available in some form to other people, then you should definitely put the data in S3. AWS has ETL and data migration tools that can move data from S3 to a variety of destinations, so the other people will not be restricted in their use of the data just because of it being stored in S3. \nOn top of that, S3 is the cheapest (warm) storage option available in AWS, and for all practical purposes, its throughout is unlimited. If you store the data in a SQL database, you significantly limit the rate at which the data can be retrieved. If you store the data in a NoSQL database, you may be able to support more traffic (maybe) but it will be at significant cost. \nJust to further illustrate my point, I recently did an experiment to test certain properties of one of the S3 APIs, and part of my experiment involved uploading ~100GB of data to S3 from an EC2 instance. I was able to upload all of that data in just a few minutes, and it cost next to nothing. \nThe only thing you need to decide is the format of your data files. You should talk to some of the other people and find out if Json, CSV, or something else is preferred. \nAs for adding new data, I would set up a lambda function that is triggered by a CloudWatch event. The lambda function can get the data from your data source and put it into S3. The CloudWatch event trigger is cron based, so it\u2019s easy enough to switch between hourly, daily, or whatever frequency meets your needs.","Q_Score":0,"Tags":"mysql,database,amazon-web-services,amazon-dynamodb,mysql-python","A_Id":54779427,"CreationDate":"2019-02-19T16:30:00.000","Title":"What is a good AWS solution (DB, ETL, Batch Job) to store large historical trading data (with daily refresh) for machine learning analysis?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have problems rounding Decimals() inside a Pandas Dataframe. The round() method does not work and using quantize() neither. I've searched for a solution  with no luck so far.\nround() does nothing, i asume it is meant for float numbers\nquantize() won't work because it is not a DataFrame function\nAny thoughts?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":881,"Q_Id":54773447,"Users Score":0,"Answer":"To round your decimal to 2 significant figures for example:\nround(df['yourSeries'].astype('float'), 2)\nOr if you just want an int:\nround(df['yourSeries'].astype('float'))","Q_Score":2,"Tags":"python,pandas,decimal","A_Id":59461549,"CreationDate":"2019-02-19T19:16:00.000","Title":"Decimal class rounding in Pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using cassandra_driver-3.16.0.dist.\nCassandra spits out a ton of non-essential WARNING logs that clog up my terminal.  How can I disable them in my python project?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":511,"Q_Id":54777594,"Users Score":1,"Answer":"Python logging is by modules or classes as we call it outside python.\nYou can disable logging in module level using command:\nlogging.getLogger('cassandra').setLevel(logging.ERROR).\nThis will set the logging level to ERROR and will not print levels below ERROR.","Q_Score":2,"Tags":"python,cassandra","A_Id":60364833,"CreationDate":"2019-02-20T01:45:00.000","Title":"How do you disable console logging in your Python Cassandra Driver client?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"re.findall(r'[^-](-*)$', '----') returns an empty list [].\nMeanwhile, re.findall(r'[^-](-*)$', '----343') returns a list with an empty string ['']. \nThere is no match in either cases. Why does re.findall() return an empty list in the first case, but a list with an empty string in the second case?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":682,"Q_Id":54777944,"Users Score":1,"Answer":"$ matches the end of the line, which has zero characters. In the first case there are no matches because the end of the line is preceded by a dash (-) which you've negated with [^-]. In the second, the end of line is preceded by a non-dash character which matches the regex.","Q_Score":2,"Tags":"python,regex","A_Id":54777955,"CreationDate":"2019-02-20T02:28:00.000","Title":"Why does re.findall() return an empty list in this case and a list with an empty string in another?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"re.findall(r'[^-](-*)$', '----') returns an empty list [].\nMeanwhile, re.findall(r'[^-](-*)$', '----343') returns a list with an empty string ['']. \nThere is no match in either cases. Why does re.findall() return an empty list in the first case, but a list with an empty string in the second case?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":682,"Q_Id":54777944,"Users Score":1,"Answer":"It does this because when you say (-*) you are matching zero or more occurences of -, whenever these hyphens follow a character that is not a -. In the first example there are no characters that are not - so nothing matches, thus the empty list. In the second example, there are three characters (the digits) that are not hyphens, so (-*) matches the last 3 followed by zero occurences of -.","Q_Score":2,"Tags":"python,regex","A_Id":54777972,"CreationDate":"2019-02-20T02:28:00.000","Title":"Why does re.findall() return an empty list in this case and a list with an empty string in another?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I relatively new to coding so I am not (yet) running virtual environments. Rather, I am just downloading packages with pip straight to my pc to run python 3.7 in atom.\nWhen I tried to use pip the other day to install the scrapy package like so -m pip install --user scrapy\nI got this error: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\\\users\\\\adrian\\\\appdata\\\\roaming\\\\python\\\\python37\\\\site-packages\\\\pip-19.0.1.dist-info\\\\METADATA'\nMost of the other answers I have seen on related errors had people use conda to install some type of fix I think? When I tried to use conda to execute one of the fixes I recieved a CondaHTTPError: SSLError(MaxRetryError('HTTPSConnectionPool(host=\\'repo.anaconda.com\\', port=443): Max retries exceeded with url: \/pkgs\/free\/noarch\/repodata.json.bz2 (Caused by SSLError(\"Can\\'t connect to HTTPS URL because the SSL module is not available.\nAny direction would be heartily appreciated :-)","AnswerCount":18,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":187418,"Q_Id":54778630,"Users Score":0,"Answer":"A simple pip upgrade did the trick for me.","Q_Score":67,"Tags":"python,pip,conda","A_Id":72398663,"CreationDate":"2019-02-20T04:01:00.000","Title":"Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory \\\\METADATA","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I relatively new to coding so I am not (yet) running virtual environments. Rather, I am just downloading packages with pip straight to my pc to run python 3.7 in atom.\nWhen I tried to use pip the other day to install the scrapy package like so -m pip install --user scrapy\nI got this error: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\\\users\\\\adrian\\\\appdata\\\\roaming\\\\python\\\\python37\\\\site-packages\\\\pip-19.0.1.dist-info\\\\METADATA'\nMost of the other answers I have seen on related errors had people use conda to install some type of fix I think? When I tried to use conda to execute one of the fixes I recieved a CondaHTTPError: SSLError(MaxRetryError('HTTPSConnectionPool(host=\\'repo.anaconda.com\\', port=443): Max retries exceeded with url: \/pkgs\/free\/noarch\/repodata.json.bz2 (Caused by SSLError(\"Can\\'t connect to HTTPS URL because the SSL module is not available.\nAny direction would be heartily appreciated :-)","AnswerCount":18,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":187418,"Q_Id":54778630,"Users Score":0,"Answer":"its very simple\nwhen we get this error, this case\nCould not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\\\users\\\\adrian\\\\appdata\\\\roaming\\\\python\\\\python37\\\\site-packages\\\\pip-19.0.1.dist-info\\\\METADATA' . what we need to do is delete that folder , in this case  pip-19.0.1.dist-info ;\nProblem solved","Q_Score":67,"Tags":"python,pip,conda","A_Id":72340110,"CreationDate":"2019-02-20T04:01:00.000","Title":"Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory \\\\METADATA","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I relatively new to coding so I am not (yet) running virtual environments. Rather, I am just downloading packages with pip straight to my pc to run python 3.7 in atom.\nWhen I tried to use pip the other day to install the scrapy package like so -m pip install --user scrapy\nI got this error: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\\\users\\\\adrian\\\\appdata\\\\roaming\\\\python\\\\python37\\\\site-packages\\\\pip-19.0.1.dist-info\\\\METADATA'\nMost of the other answers I have seen on related errors had people use conda to install some type of fix I think? When I tried to use conda to execute one of the fixes I recieved a CondaHTTPError: SSLError(MaxRetryError('HTTPSConnectionPool(host=\\'repo.anaconda.com\\', port=443): Max retries exceeded with url: \/pkgs\/free\/noarch\/repodata.json.bz2 (Caused by SSLError(\"Can\\'t connect to HTTPS URL because the SSL module is not available.\nAny direction would be heartily appreciated :-)","AnswerCount":18,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":187418,"Q_Id":54778630,"Users Score":0,"Answer":"Windows 10\nWindows limits locations paths with more than 260 characters. You should just enable that following this 4 steps!!!\n\nClick Window key and type gpedit. msc, then press the Enter key.\nNavigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem.\nDouble click Enable NTFS long paths.\nSelect Enabled, then click OK.","Q_Score":67,"Tags":"python,pip,conda","A_Id":71527118,"CreationDate":"2019-02-20T04:01:00.000","Title":"Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory \\\\METADATA","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I relatively new to coding so I am not (yet) running virtual environments. Rather, I am just downloading packages with pip straight to my pc to run python 3.7 in atom.\nWhen I tried to use pip the other day to install the scrapy package like so -m pip install --user scrapy\nI got this error: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\\\users\\\\adrian\\\\appdata\\\\roaming\\\\python\\\\python37\\\\site-packages\\\\pip-19.0.1.dist-info\\\\METADATA'\nMost of the other answers I have seen on related errors had people use conda to install some type of fix I think? When I tried to use conda to execute one of the fixes I recieved a CondaHTTPError: SSLError(MaxRetryError('HTTPSConnectionPool(host=\\'repo.anaconda.com\\', port=443): Max retries exceeded with url: \/pkgs\/free\/noarch\/repodata.json.bz2 (Caused by SSLError(\"Can\\'t connect to HTTPS URL because the SSL module is not available.\nAny direction would be heartily appreciated :-)","AnswerCount":18,"Available Count":9,"Score":0.0333209931,"is_accepted":false,"ViewCount":187418,"Q_Id":54778630,"Users Score":3,"Answer":"Just ran into a similar problem with but with different versions.\nSimilar to what EsCS69 said I just found the director and saw that there was no MetaData file. However I couldn't just pull it out from another file. So instead I justed deleted  that folder and ran pip install --upgrade --force-reinstall tensorflow-gpuor pip install --upgrade --force-reinstall tensorflow if you aren't using the gpu version. Problem solved.","Q_Score":67,"Tags":"python,pip,conda","A_Id":62683232,"CreationDate":"2019-02-20T04:01:00.000","Title":"Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory \\\\METADATA","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I relatively new to coding so I am not (yet) running virtual environments. Rather, I am just downloading packages with pip straight to my pc to run python 3.7 in atom.\nWhen I tried to use pip the other day to install the scrapy package like so -m pip install --user scrapy\nI got this error: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\\\users\\\\adrian\\\\appdata\\\\roaming\\\\python\\\\python37\\\\site-packages\\\\pip-19.0.1.dist-info\\\\METADATA'\nMost of the other answers I have seen on related errors had people use conda to install some type of fix I think? When I tried to use conda to execute one of the fixes I recieved a CondaHTTPError: SSLError(MaxRetryError('HTTPSConnectionPool(host=\\'repo.anaconda.com\\', port=443): Max retries exceeded with url: \/pkgs\/free\/noarch\/repodata.json.bz2 (Caused by SSLError(\"Can\\'t connect to HTTPS URL because the SSL module is not available.\nAny direction would be heartily appreciated :-)","AnswerCount":18,"Available Count":9,"Score":0.0111106539,"is_accepted":false,"ViewCount":187418,"Q_Id":54778630,"Users Score":1,"Answer":"I ended up deleting the whole directory and re-running \"pip install ...\" and that worked for me.","Q_Score":67,"Tags":"python,pip,conda","A_Id":65704607,"CreationDate":"2019-02-20T04:01:00.000","Title":"Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory \\\\METADATA","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I relatively new to coding so I am not (yet) running virtual environments. Rather, I am just downloading packages with pip straight to my pc to run python 3.7 in atom.\nWhen I tried to use pip the other day to install the scrapy package like so -m pip install --user scrapy\nI got this error: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\\\users\\\\adrian\\\\appdata\\\\roaming\\\\python\\\\python37\\\\site-packages\\\\pip-19.0.1.dist-info\\\\METADATA'\nMost of the other answers I have seen on related errors had people use conda to install some type of fix I think? When I tried to use conda to execute one of the fixes I recieved a CondaHTTPError: SSLError(MaxRetryError('HTTPSConnectionPool(host=\\'repo.anaconda.com\\', port=443): Max retries exceeded with url: \/pkgs\/free\/noarch\/repodata.json.bz2 (Caused by SSLError(\"Can\\'t connect to HTTPS URL because the SSL module is not available.\nAny direction would be heartily appreciated :-)","AnswerCount":18,"Available Count":9,"Score":0.0111106539,"is_accepted":false,"ViewCount":187418,"Q_Id":54778630,"Users Score":1,"Answer":"Try deleting the package in envs\/$env_name\/Lib\/site-packages","Q_Score":67,"Tags":"python,pip,conda","A_Id":63655660,"CreationDate":"2019-02-20T04:01:00.000","Title":"Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory \\\\METADATA","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I relatively new to coding so I am not (yet) running virtual environments. Rather, I am just downloading packages with pip straight to my pc to run python 3.7 in atom.\nWhen I tried to use pip the other day to install the scrapy package like so -m pip install --user scrapy\nI got this error: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\\\users\\\\adrian\\\\appdata\\\\roaming\\\\python\\\\python37\\\\site-packages\\\\pip-19.0.1.dist-info\\\\METADATA'\nMost of the other answers I have seen on related errors had people use conda to install some type of fix I think? When I tried to use conda to execute one of the fixes I recieved a CondaHTTPError: SSLError(MaxRetryError('HTTPSConnectionPool(host=\\'repo.anaconda.com\\', port=443): Max retries exceeded with url: \/pkgs\/free\/noarch\/repodata.json.bz2 (Caused by SSLError(\"Can\\'t connect to HTTPS URL because the SSL module is not available.\nAny direction would be heartily appreciated :-)","AnswerCount":18,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":187418,"Q_Id":54778630,"Users Score":39,"Answer":"This is what I did:\nI could not install my python package due to this error\nERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\\\users\\\\banipreet\\\\anaconda3\\\\envs\\\\env-gpu\\\\lib\\\\site-packages\\\\requests-2.24.0.dist-info\\\\METADATA'\nI simply removed this folder\n'c:\\\\users\\\\banipreet\\\\anaconda3\\\\envs\\\\env-gpu\\\\lib\\\\site-packages\\\\requests-2.24.0.dist-info\nand retried pip install my-package, and it installed the package sucessfully.","Q_Score":67,"Tags":"python,pip,conda","A_Id":64705249,"CreationDate":"2019-02-20T04:01:00.000","Title":"Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory \\\\METADATA","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I relatively new to coding so I am not (yet) running virtual environments. Rather, I am just downloading packages with pip straight to my pc to run python 3.7 in atom.\nWhen I tried to use pip the other day to install the scrapy package like so -m pip install --user scrapy\nI got this error: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\\\users\\\\adrian\\\\appdata\\\\roaming\\\\python\\\\python37\\\\site-packages\\\\pip-19.0.1.dist-info\\\\METADATA'\nMost of the other answers I have seen on related errors had people use conda to install some type of fix I think? When I tried to use conda to execute one of the fixes I recieved a CondaHTTPError: SSLError(MaxRetryError('HTTPSConnectionPool(host=\\'repo.anaconda.com\\', port=443): Max retries exceeded with url: \/pkgs\/free\/noarch\/repodata.json.bz2 (Caused by SSLError(\"Can\\'t connect to HTTPS URL because the SSL module is not available.\nAny direction would be heartily appreciated :-)","AnswerCount":18,"Available Count":9,"Score":0.0111106539,"is_accepted":false,"ViewCount":187418,"Q_Id":54778630,"Users Score":1,"Answer":"You might not like this answer, but what worked for me was to find the file: \"METADATA\" from a folder with an older version and copy it into the newer one. \nThis is not a solution I'm confident in, but pip at least finished installing.","Q_Score":67,"Tags":"python,pip,conda","A_Id":56640409,"CreationDate":"2019-02-20T04:01:00.000","Title":"Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory \\\\METADATA","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I relatively new to coding so I am not (yet) running virtual environments. Rather, I am just downloading packages with pip straight to my pc to run python 3.7 in atom.\nWhen I tried to use pip the other day to install the scrapy package like so -m pip install --user scrapy\nI got this error: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\\\users\\\\adrian\\\\appdata\\\\roaming\\\\python\\\\python37\\\\site-packages\\\\pip-19.0.1.dist-info\\\\METADATA'\nMost of the other answers I have seen on related errors had people use conda to install some type of fix I think? When I tried to use conda to execute one of the fixes I recieved a CondaHTTPError: SSLError(MaxRetryError('HTTPSConnectionPool(host=\\'repo.anaconda.com\\', port=443): Max retries exceeded with url: \/pkgs\/free\/noarch\/repodata.json.bz2 (Caused by SSLError(\"Can\\'t connect to HTTPS URL because the SSL module is not available.\nAny direction would be heartily appreciated :-)","AnswerCount":18,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":187418,"Q_Id":54778630,"Users Score":0,"Answer":"Changing the Long install path value to 1 did NOT solve problem in my case. I have removed the local folder which is giving an error and installed the package again and it worked.\nFollowing is the error I have seen:\n:ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'c:\\users\\user_name\\appdata\\local\\continuum\\anaconda3\\lib\\site-packages\\numpy-1.20.1.dist-info\\METADATA'\nI removed the folder:\n\"'c:\\users\\user_name\\appdata\\local\\continuum\\anaconda3\\lib\\site-packages\\numpy-1.20.1.dist-info'","Q_Score":67,"Tags":"python,pip,conda","A_Id":68967496,"CreationDate":"2019-02-20T04:01:00.000","Title":"Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory \\\\METADATA","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run some automatic scripts on a webpage with selenium and python, but the problem I'm having is that the webpage is loaded using document.write().\nI have to find some elements, but they are not shown because when I view the source, it is shown as document.write(A lot of JS) instead of the html.\nHow can I do it so that I can view the HTML source code? I know there is the function driver.execute_script(), but I have to specify the script to run, and I don't think it will work.\nThe page is correctly rendered, only problem is the source cannot be parsed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":349,"Q_Id":54781641,"Users Score":0,"Answer":"As it turns out after some digging into the code, Selenium does the search in the rendered final view, but the problem was not the document.write(), but the fact that the field I was looking for was in an iframe, which selenium could not find on the default frame. \nAll I had to do was search through the iframes and find the ones that I needed.","Q_Score":0,"Tags":"javascript,python,selenium-webdriver,document.write","A_Id":54800939,"CreationDate":"2019-02-20T08:14:00.000","Title":"Selenium find element with document.write","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a celery task\/for loop that should run through a specific list of user fields at the database but for some reason, I always get the error:\n...\ntasks.py\n...\nThanks for your help.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":54782076,"Users Score":0,"Answer":"Replace User.objects.all with User.objects.all()","Q_Score":0,"Tags":"python,django,loops,for-loop,celery","A_Id":54782114,"CreationDate":"2019-02-20T08:42:00.000","Title":"Python go through User fields","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have python2.7, python3.7, python3.6 on my machine. I am still not sure how manage and see location of all three python version. \nCurrently I just type python with version name to open that terminal or run script. \nI did python3.6 default by aliasing in ~\/.bashrc.\nI have installed virtualenv using python3.6 so whenever I create venc by default it takes python3.6 in it.\nTo create venv with python2.7 I tried -\nvirtualenv -p \/usr\/bin\/python2.7 \/Users\/karim\/Documents\/venv2.7\nBut here also in this venv2.7 when I see python version it give 3.6. When I type python2.7 in terminal it opens python2.7.\nI can do aliasing for python2.7 being in virtual environment but I doubt that may create python2.7 default outside venv as well. \n\nHow can I create virtual environment with python2.7 default?\nCan you refer me any article which explain how to manage multiple python version, switch from one to another, see there locations\n\nI really checked all SO threads but no articles helped me to create venv with python2.7 in system having python3.6 default.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10150,"Q_Id":54782163,"Users Score":0,"Answer":"If you use pycharm, you can create a new virtual environment under settings > project > cog symbol, drodown menu: add.\nHere you can specify which is your base python interpreter, point this to where python3 or python2 are installed and pycharm will do the hardwork for you.","Q_Score":4,"Tags":"python,python-3.x,python-2.7,ubuntu,virtualenv","A_Id":60828867,"CreationDate":"2019-02-20T08:47:00.000","Title":"Use python2.7 in venv where python3 is default python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How to differentiate the scanned PDF and native PDF in Python?\nBecause both the documents having the extension with PDF only.\nIs it possible to find whether the document is scanned PDF or native PDF by its properties?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":251,"Q_Id":54783517,"Users Score":1,"Answer":"I'mnot sure about the propeties, but if you zoom the page and curves still remain smooth - it's a Native PDF, if become uneven - it's scanned, because scanned PDF is no more than an image and don't have code that allows them to be edited.","Q_Score":2,"Tags":"python,nlp","A_Id":54783980,"CreationDate":"2019-02-20T09:58:00.000","Title":"How to Distinguish between scanned PDF and native PDF in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a WebApp on Flask+gunicorn+nginx. I need to send 200 requests from my other server at the same time to a WebApp , save the response and its speed. Also I need to send Json POST in this 200 requests.\nHow to do it right?\nUse python script or CURL?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":123,"Q_Id":54783844,"Users Score":0,"Answer":"I suggest you to use \"Postman\" for any kind of API testing. It is one the best tools available in the market for API testing , monitoring, documenting, and also sharing the results(as well as test scripts) for free.\nIf you don't want to use any other tool, then i suggest you to use a python script.","Q_Score":0,"Tags":"python,curl,flask,server,gunicorn","A_Id":54784754,"CreationDate":"2019-02-20T10:16:00.000","Title":"How to load server with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Suppose i have a table with 100000 rows and a python script which performs some operations on each row of this table sequentially. Now to speed up this process should I create 10 separate scripts and run them simultaneously that process subsequent 10000 rows of the table or should I create 10  threads to process rows for better execution speed ?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":179,"Q_Id":54787717,"Users Score":1,"Answer":"Threading\n\nDue to the Global Interpreter Lock, python threads are not truly parallel. In other words only a single thread can be running at a time.\nIf you are performing CPU bound tasks then dividing the workload amongst threads will not speed up your computations. If anything it will slow them down because there are more threads for the interpreter to switch between.\nThreading is much more useful for IO bound tasks. For example if you are communicating with a number of different clients\/servers at the same time. In this case you can switch between threads while you are waiting for different clients\/servers to respond\n\nMultiprocessing\n\nAs Eman Hamed has pointed out, it can  be difficult to share objects while multiprocessing.\n\nVectorization\n\nLibraries like pandas allow you to use vectorized methods on tables. These are highly optimized operations written in C that execute very fast on an entire table or column.  Depending on  the structure of your table and the operations that you want to perform, you should consider taking advantage of this","Q_Score":0,"Tags":"python,multithreading,multiprocessing,processing-efficiency","A_Id":54788074,"CreationDate":"2019-02-20T13:41:00.000","Title":"Threading vs Multiprocessing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose i have a table with 100000 rows and a python script which performs some operations on each row of this table sequentially. Now to speed up this process should I create 10 separate scripts and run them simultaneously that process subsequent 10000 rows of the table or should I create 10  threads to process rows for better execution speed ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":54787717,"Users Score":0,"Answer":"Process threads have in common a continouous(virtual) memory block known as heap processes don't. Threads also consume less OS resources relative to whole processes(seperate scripts) and there is no context switching happening. \nThe single biggest performance factor in multithreaded execution when there no\nlocking\/barriers involved is data access locality eg. matrix multiplication kernels. \nSuppose data is stored in heap in a linear fashion ie. 0-th row in [0-4095]bytes, 1st row in[4096-8191]bytes, etc. Then thread-0 should operate in 0,10,20, ... rows, thread-1 operate in 1,11,21,... rows, etc. \nThe main idea is to have a set of 4K pages kept in physical RAM and 64byte blocks kept in L3 cache and operate on them repeatedly. Computers usually assume that if you 'use' a particular memory location then you're also gonna use adjacent ones, and you should do your best to do so in your program. The worst case scenario is accessing memory locations that are like ~10MiB apart in a random fashion so don't do that. Eg. If a single row is 1310720 doubles(64B) in\nsize, then your threads should operate in a intra-row(single row) rather inter-row(above) fashion.\nBenchmark your code and depending on your results, if your algorithm can process around 21.3GiB\/s(DDR3-2666Mhz) of rows then you have a memory-bound task. If your code is like 1GiB\/s processing speed, then you have a compute-bound task meaning executing instructions on data takes more time than fetching data from RAM and you need to either optimize your code or reach higher IPC by utilizing AVXx instructions sets or buy a newer processesor with more cores or higher frequency.","Q_Score":0,"Tags":"python,multithreading,multiprocessing,processing-efficiency","A_Id":54788392,"CreationDate":"2019-02-20T13:41:00.000","Title":"Threading vs Multiprocessing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering what would be the best practice to update the source code in a docker container that is run within( in JAVA and python). I could either modify my code, create a new image and run a container. In Java,  I would also need to compile the code. \nAnother solution would be to just use a volume to share the code between my machine and the container so that each time I modify the behavior of my code I won't need to create a new docker image.\nI'm asking all of this for development purposes, not deploying\nIs there a best practice between these two solutions? What are the pros and cons? Is there a difference for a compiled language like a java compared to python?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1084,"Q_Id":54788991,"Users Score":0,"Answer":"You should make a new image, and if you think creating a new image and deploying is a task for you, than you can setup a CI\/CD pipeline which will automatically compile java code, create a image and will deploy it for you whenever you push a code to GIT.","Q_Score":2,"Tags":"java,python,docker,docker-image","A_Id":54789337,"CreationDate":"2019-02-20T14:46:00.000","Title":"Create a new image or share source code in a volume in a docker container in development?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm wondering what would be the best practice to update the source code in a docker container that is run within( in JAVA and python). I could either modify my code, create a new image and run a container. In Java,  I would also need to compile the code. \nAnother solution would be to just use a volume to share the code between my machine and the container so that each time I modify the behavior of my code I won't need to create a new docker image.\nI'm asking all of this for development purposes, not deploying\nIs there a best practice between these two solutions? What are the pros and cons? Is there a difference for a compiled language like a java compared to python?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1084,"Q_Id":54788991,"Users Score":1,"Answer":"In general the best practice would be to create a new image when you have new source code and run a new container from that image. Docker can quickly create and run new images, so you should take advantage of that. In addition you can know what version of your code you're running by tagging your images. \nYou mention that you would need to compile the Java code in the Docker case, but you would need to in either case. You could just compile your code into a Jar and then ADD (or COPY) the Jar into your container and run it there.\nA couple of quick downsides that come to mind with the external code approach: you would need some external way to manage what version of code is running, docker tags take care of that for you. You would also need some way to alert the Docker container that a new executable file is ready and then have Docker run that. In addition you would need to make sure that your Docker container is running the same version of Java (or Python) that your system is running, this too is taken care of in Docker since you can build from a Java base image.","Q_Score":2,"Tags":"java,python,docker,docker-image","A_Id":54789428,"CreationDate":"2019-02-20T14:46:00.000","Title":"Create a new image or share source code in a volume in a docker container in development?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm wondering what would be the best practice to update the source code in a docker container that is run within( in JAVA and python). I could either modify my code, create a new image and run a container. In Java,  I would also need to compile the code. \nAnother solution would be to just use a volume to share the code between my machine and the container so that each time I modify the behavior of my code I won't need to create a new docker image.\nI'm asking all of this for development purposes, not deploying\nIs there a best practice between these two solutions? What are the pros and cons? Is there a difference for a compiled language like a java compared to python?","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":1084,"Q_Id":54788991,"Users Score":2,"Answer":"You should definitely make a new image instead of sharing the code via a mounted volume. Then whole docker ideology is to produce a self-contained \"service\", which can be portable across server (i.e. copy the image). Yuo docker file and image build process will track versions of your code, i.e. in your docker file you can pull a specific branch, or you can tag the image with a specific tag.\nIn case of a mounted volume, you never sure what version of your code is actually. run.\nHope this reason alone will help you to decide.","Q_Score":2,"Tags":"java,python,docker,docker-image","A_Id":54789199,"CreationDate":"2019-02-20T14:46:00.000","Title":"Create a new image or share source code in a volume in a docker container in development?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Scenario: four users are annotating images with one of four labels each. These are stored in a fairly complex format - either as polygons or as centre-radius circles. I'm interested in quantifying, for each class, the area of agreement between individual raters \u2013 in other words, I'm looking to get an m x n matrix, where M_i,j will be some metric, such as the IoU (intersection over union), between i's and j's ratings (with a 1 diagonal, obviously). There are two problems I'm facing.\nOne, I don't know what works best in Python for this. Shapely doesn't implement circles too well, for instance.\nTwo, is there a more efficient way for this than comparing it annotator-by-annotator?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":54789340,"Users Score":0,"Answer":"IMO the simplest is to fill the shapes using polygon filling \/ circle filling (this is simple, you can roll your own) \/ path filling (from a seed). Then finding the area of overlap is an easy matter.","Q_Score":0,"Tags":"python,computational-geometry","A_Id":54805518,"CreationDate":"2019-02-20T15:02:00.000","Title":"Calculating object labelling consensus area","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently started using VS Code for Python. \nI realized that when I hit debug\/F5, VS Code prints several folder paths (locations of workspace, Python.exe, host, Port, etc.) in Terminal window before debugging the code. \nI am using Windows 7 machine.\nWhy is that and how can I avoid it?\nThanks for your advise.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":54791468,"Users Score":0,"Answer":"It's by design and required in order to run the debugger, so there's no way to avoid it.","Q_Score":2,"Tags":"python,visual-studio-code","A_Id":54794774,"CreationDate":"2019-02-20T16:48:00.000","Title":"VS Code Terminal Printing Several Folder Paths before rnning Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to make my tkinter Text to be only an output and not an input. Through some research I've found that text.config(state=\"disabled\") disables user input, but it still allows for selecting text, which I do not want.\nHow can I get my Text widget to be unselectable and unwritable?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1388,"Q_Id":54792599,"Users Score":0,"Answer":"I believe you will have to replace it with another widget that such as a Label or LabelFrame to accomplish this. As well you could use a from tkinter import messagebox and have the text you want pop up in another window (like an info window or error message window). I think that as far as the Text widget goes, setting the state to disabled is the best you can do for your purposes unfortunately and users will be able to copy that text despite being unable to edit it.","Q_Score":1,"Tags":"python,tkinter","A_Id":54792777,"CreationDate":"2019-02-20T17:59:00.000","Title":"How can I make a tkinter text widget unselectable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For my Eclipse Che project, I have to reinstall my python modules every time I load the workspace (blegh). Is there a way to install the modules my team needs to a global folder so they don't have to even install the python modules every time they want to load the project? Thank you!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":753,"Q_Id":54793121,"Users Score":1,"Answer":"If I understand you question correctly, the best approach would be to build new docker image (based on the one you are using now) with the modules pre-installed and use that image for workspace instead of the default one.","Q_Score":1,"Tags":"python,eclipse,eclipse-che","A_Id":54802762,"CreationDate":"2019-02-20T18:36:00.000","Title":"Have to keep reinstalling python modules (Eclipse Che)?","Data Science and Machine Learning":0,"Database and SQL":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 kind of new to software development. Outside of VSCode, I can open up a terminal (let's say PowerShell), run python in it, type in a command (like 2+2), be able to click the up arrow key to find my previous command so that I can run it again. \nIf I run PowerShell in VSCode and do the same thing, nothing happens when I click the up arrow where I would expect my previous command to be cycled.\nIs this a problem with my Python or VSCode? I've been looking for a solution for this but haven't found many useful topics on this.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2195,"Q_Id":54795342,"Users Score":2,"Answer":"This was going to just be a comment but its too long.  Sorry it isn't more informative than it is.  This is kind of an odd problem because VSCode isn't a true IDE.  It doesn't have its own shell and just hijacks your powershell or bash terminal, depending on which OS you are using.  You should be able to use your up and down arrows just like you can in powershell.  I have tested it on my own VSCode installation and it works fine for me.  If it's a problem, it's not with python, since VSCode will interact with the terminal the same way no matter which language you are using it for, so its probably with VSCode or your terminal.  I have heard of others having issues with up arrow autocomplete in bash, so if you are connecting to a bash terminal that could be it, but I've never heard of it glitching in powershell.  I'd say check which terminal you are using, see if the problem persists when you change terminals, and try reinstalling VSCode if it does.  Past that, I don't know what to tell you.","Q_Score":3,"Tags":"python,terminal,visual-studio-code,command,arrow-keys","A_Id":54795718,"CreationDate":"2019-02-20T21:14:00.000","Title":"Python in VSCode: How do you run a previous command?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm kind of new to software development. Outside of VSCode, I can open up a terminal (let's say PowerShell), run python in it, type in a command (like 2+2), be able to click the up arrow key to find my previous command so that I can run it again. \nIf I run PowerShell in VSCode and do the same thing, nothing happens when I click the up arrow where I would expect my previous command to be cycled.\nIs this a problem with my Python or VSCode? I've been looking for a solution for this but haven't found many useful topics on this.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2195,"Q_Id":54795342,"Users Score":0,"Answer":"I found a work-around. For me, neither git bash, nor PowerShell allowed up\/down arrows for history switching within a python shell. So here it goes.\nCtr-Shift-P opens VSCode commands\nPython: Create Terminal   does not actuallt start python, but it does launch powershell in a mode that will enable us to succeed\npy starts python shell with working up\/down arrows!","Q_Score":3,"Tags":"python,terminal,visual-studio-code,command,arrow-keys","A_Id":63650870,"CreationDate":"2019-02-20T21:14:00.000","Title":"Python in VSCode: How do you run a previous command?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project named project.py.\nI want to set an encryption on it, so that once it's finished and running only the admin can stop the program, and another user who isn't an admin using it can't terminate it. Even if the user closes the program, it will still continue to run in the background.\nIs this possible, and if so, how can I go about doing this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":54795509,"Users Score":0,"Answer":"I want to make it that only the admin can stop the program and another user who isn't an admin using it can't terminate it\n\njust run your script under admin user, any other user who has no root\/admin\/superuser permissions won't be able to terminate process running under another user, operating system won't allow this.","Q_Score":0,"Tags":"python","A_Id":54796437,"CreationDate":"2019-02-20T21:28:00.000","Title":"How can I prevent my application to not be turned off without admin permission?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am currently working on IMDB 5000 movie dataset for a class project. The budget variable has a lot of zero values.\nThey are missing entries. I cannot drop them because they are 22% of my entire data. \nWhat should I do in Python? Some suggested binning? Could you provide more details?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1215,"Q_Id":54796340,"Users Score":2,"Answer":"Well there are a few options.\n\nTake an average of the non zero values and fill all the zeros with the average. This yields 'tacky' results and is not best practice a few outliers can throw off the whole. \nUse the median of the non zero values, also not a super option but less likely to be thrown off by outliers.\nBinning would be taking the sum of the budgets then say splitting the movies into a certain number of groups like say budgets over or under a million, take the average budget then divide that by the amount of groups you want then use the intervals created from the average if they fall in group 0 give them a zero if group 1 a one etc. \nI think finding the actual budgets for the movies and replacing the bad itemized budgets with the real budget would be a good option depending on the analysis you are doing. You could take the median or average of each feature column of the budget make that be the percent of each budget for a movie then fill in the zeros with the percent of budget the median occupies. If median value for the non zero actor_pay column is budget\/actor_pay=60% then filling the actor_pay column of a zeroed value with 60 percent of the budget for that movie would be an option.\nHard option create a function that takes the non zero values of a movies budgets and attempts to interpolate the movies budget based upon the other movies data in the table. This option is more like its own project and the above options should really be tried first.","Q_Score":2,"Tags":"python,data-science,mining","A_Id":58782823,"CreationDate":"2019-02-20T22:36:00.000","Title":"Dataset with lots of zero value as missing value. What should I do?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that you can run multiple scripts by using different terminals, but there's got to be a limit. I can't just run a million of them on one little pi. So the real question... Is there a way I can check how demanding my script is. Thank you in advance!\npi zero w \/ python 3","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":620,"Q_Id":54796505,"Users Score":1,"Answer":"There is no explicitly fixed limit. Just like your desktop or laptop computer, the limit depends on how many resources each running program takes. And just like your computer, the result of consuming too many resources can vary. It can result in the programs just running more slowly or in a complete crash.","Q_Score":1,"Tags":"python,raspberry-pi","A_Id":54796600,"CreationDate":"2019-02-20T22:49:00.000","Title":"How many py script can I run on raspberry pi simultaniously?","Data Science and Machine Learning":0,"Database and SQL":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 taking an info storage and retrieval class, and to complete an assignment we need to download and use the beautifulsoup package for python.\nI haven't used Python in years, so I'm very rusty and cannot seem to figure out how to download a Python package. \nI'm using Python 3 and have Windows 10. \nMost of what I've read involves just typing something into the command line, but my windows command line (cmd) doesn't even acknowledge that I have python downloaded.\n'python' is not recognized as an internal or external command,\noperable program or batch file.\nI understand that pip is the go-to for downloading packages, but cmd doesn't acknowledge that either. Maybe I'm just missing something since I haven't used Python in so long...\nI'm hoping that somebody can give me a step-by-step approach on how to download this package. Thanks in advance.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":833,"Q_Id":54797153,"Users Score":1,"Answer":"Go command prompt if you are using windows\ntype: python -m pip install bs4\nthen open your code editor and type: from bs4 import BeautifulSoup","Q_Score":2,"Tags":"python,beautifulsoup","A_Id":61949762,"CreationDate":"2019-02-20T23:59:00.000","Title":"How to download beautifulsoup package python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am taking an info storage and retrieval class, and to complete an assignment we need to download and use the beautifulsoup package for python.\nI haven't used Python in years, so I'm very rusty and cannot seem to figure out how to download a Python package. \nI'm using Python 3 and have Windows 10. \nMost of what I've read involves just typing something into the command line, but my windows command line (cmd) doesn't even acknowledge that I have python downloaded.\n'python' is not recognized as an internal or external command,\noperable program or batch file.\nI understand that pip is the go-to for downloading packages, but cmd doesn't acknowledge that either. Maybe I'm just missing something since I haven't used Python in so long...\nI'm hoping that somebody can give me a step-by-step approach on how to download this package. Thanks in advance.","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":833,"Q_Id":54797153,"Users Score":2,"Answer":"Add your Python executable in your path.\nThen run python -m pip install bs4.\n\nNow when using in your code, use from bs4 import BeautifulSoup.","Q_Score":2,"Tags":"python,beautifulsoup","A_Id":54800332,"CreationDate":"2019-02-20T23:59:00.000","Title":"How to download beautifulsoup package python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am taking an info storage and retrieval class, and to complete an assignment we need to download and use the beautifulsoup package for python.\nI haven't used Python in years, so I'm very rusty and cannot seem to figure out how to download a Python package. \nI'm using Python 3 and have Windows 10. \nMost of what I've read involves just typing something into the command line, but my windows command line (cmd) doesn't even acknowledge that I have python downloaded.\n'python' is not recognized as an internal or external command,\noperable program or batch file.\nI understand that pip is the go-to for downloading packages, but cmd doesn't acknowledge that either. Maybe I'm just missing something since I haven't used Python in so long...\nI'm hoping that somebody can give me a step-by-step approach on how to download this package. Thanks in advance.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":833,"Q_Id":54797153,"Users Score":1,"Answer":"Go to your desktop or where ever your python shortcut is. Right-click on it and find properties. Click on properties find the 'start in' tab and copy the file directory.\nopen cmd and type 'cd (address)' now type python and hit enter. then type import pip and hit enter now type Ctrl + Z and hit enter. Now type python -m pip install bs4.","Q_Score":2,"Tags":"python,beautifulsoup","A_Id":61949372,"CreationDate":"2019-02-20T23:59:00.000","Title":"How to download beautifulsoup package python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know how to convert characters to ascii and stuff, and I'm making my first encryption algorithm just as a little fun project, nothing serious. I was wondering if there was a way to convert every other character in a string to ascii, I know this is similar to some other questions but I don't think it's a duplicate. Also P.S. I'm fairly new to Python :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":54798259,"Users Score":0,"Answer":"Use ord() function to get ascii value of a character. You can then do a chr() of that value to get the character.","Q_Score":0,"Tags":"python,string,ascii","A_Id":54799855,"CreationDate":"2019-02-21T02:24:00.000","Title":"How to convert every other character in a string to ascii in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently learning deep-learning from two lectures. What gets me confused is that there is a notation difference between two lectures when they shape an input matrix X. \nIn Coursera's lecture, they make a matrix X in shape of (number of features, number of samples), so that they stack the samples vertically. Otherwise, the other lecture stacks the samples horizontally, so that every row represents one sample.\nWhat makes this difference and which one should I follow?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":54798437,"Users Score":0,"Answer":"Both ways are fine, it only matters to be consistent, i.e., that all matrix operations are correct. Depending on the shape of the matrix you might have matrix*vector or vector_transposed*matrix, or some variety along these lines.\nPlaying around with different representations might actually help the understanding in the long run. So I would recommend to follow both lectures and appreciate the differences in how they represent the data etc.","Q_Score":0,"Tags":"python,machine-learning,deep-learning","A_Id":54799272,"CreationDate":"2019-02-21T02:43:00.000","Title":"Matrix shapes difference between lectures","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am compiling a package with python -m nuitka --module some_package --include-package=some_package\nIt produces a some_package.so.  What is the correct way to use this file?\nPython can itself import so files.\nI can import some_package itself, but I cannot import any submodules at all.  If I dir(some_package), there are no methods or modules available.\nHow am I going about this wrong?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":954,"Q_Id":54799319,"Users Score":0,"Answer":"Might be too late but maybe this will help someone else:\nIn order for Python to be able to understand the package structure, you need to exclude __init__.py files from compilation. You should be able to import any submodules after that.","Q_Score":1,"Tags":"python,shared-libraries,nuitka","A_Id":60093087,"CreationDate":"2019-02-21T04:35:00.000","Title":"How do you use nuitka shared object files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making APIs.\nI'm using CentOS for web server, and another windows server 2016 for API server.\nI'm trying to make things work between web server and window server.\nMy logic is like following flow.\n1) Fill the data form and click button from web server\n2) Send data to windows server\n3) Python script runs and makes more data\n4) More made data must send back to web server\n5) Web server gets more made datas\n6) BAMM! Datas append on browser!\nI had made python scripts.\nbut I can't decide how to make datas go between two servers..\nShould I use ajax Curl in web server?\nI was planning to send a POST type request by Curl from web server to Windows server.\nBut I don't know how to receipt those datas in windows server.\nPlease help! Thank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":213,"Q_Id":54799927,"Users Score":1,"Answer":"First option: (Recommended)\nYou can create the python side as an API endpoint and from the PHP server, you need to call the python API.\nSecond option:\nYou can create the python side just like a normal webpage and whenever you call that page from PHP server you pass the params along with HTTP request, and after receiving data in python you print the data in JSON format.","Q_Score":0,"Tags":"php,python,curl","A_Id":54800059,"CreationDate":"2019-02-21T05:36:00.000","Title":"Run python script by PHP from another server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a dataset which has several Variables. \nI want to determine that how can we judge for a variable if it is categorical or numerical other than the method of unique value counts, as for instance one of my variable Disease Type has 31 Unique Values whereas other Variable Distance from Office has 25 Unique Values, both in the form of numbers.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1458,"Q_Id":54800350,"Users Score":3,"Answer":"The short answer, is: your knowledge of the problem domain \/ application domain will tell you.\nThere are some differences that you look for, but to apply these differences, you will still have to use some domain knowledge (sometimes common sense).\nThe following are some differences which will help you distinguish:\n\nFor categorical variables, the set of permitted values is usually fixed, and rarely changes, if at all. In contrast, for numeric variable, the set of values can change, for example, when you receive a new record for the same dataset.\nNumeric variables can potentially have values that are not round integers. In your example, even though \"distance from office\" happens to have integer values, that could be purely incidental, or could have been a choice made by some one about how much numeric precision they want in the data.\nFor categorical variables, it usually doesn't make sense to talk of averages. For example, there are 2 types of diabetes called Type 1, Type 2, but it just doesn't make sense to talk of an average of these types (Type 1.2357?).\nAsk yourself this thumb-rule question: When I perform my data analysis can I express my inferences in terms of specific values of this variable? How about ranges of this variable (\"0 to 5 km\", \"5 to 10 km\", etc). For example, can I report any inferences from my data analysis that says \"Those whose distance from office is 123, are prone to be successful in their career\"? That specific value sounds silly, right? In contrast, if it were a categorical variable such as Type 2 Diabetes, you can always make inferences in terms of the specific value.","Q_Score":1,"Tags":"python,pandas,dataframe,statistics,data-analysis","A_Id":54801198,"CreationDate":"2019-02-21T06:09:00.000","Title":"How to know if the Variable is Categorical or Numerical if all it contains is Digits?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset which has several Variables. \nI want to determine that how can we judge for a variable if it is categorical or numerical other than the method of unique value counts, as for instance one of my variable Disease Type has 31 Unique Values whereas other Variable Distance from Office has 25 Unique Values, both in the form of numbers.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1458,"Q_Id":54800350,"Users Score":0,"Answer":"<dataframename>.info() will give the total count of each variable along with whether it is non-null and its datatype like float64,object,int64 etc","Q_Score":1,"Tags":"python,pandas,dataframe,statistics,data-analysis","A_Id":54801115,"CreationDate":"2019-02-21T06:09:00.000","Title":"How to know if the Variable is Categorical or Numerical if all it contains is Digits?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can I make somehow a rule which deletes a received e-mail, if the subject of the e-mail does not contain a word (string)?\nI want to determine somehow a word list for that. If the subject does not contain any element of the word list -> delete the e-mail.\nIf I open outlook rule wizard, I can add words, but only one by one, so it is slow. I have 1000+ words.\nIs there any soulition for that?\nI am familiar with python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":54801325,"Users Score":0,"Answer":"You should create a VBA script or a COM add-in for Outlook to implement that.","Q_Score":0,"Tags":"python,string,list,email,outlook","A_Id":54825167,"CreationDate":"2019-02-21T07:20:00.000","Title":"Outlook received emails rule based on string list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"With a Python project opened, whenever I open the integrated terminal in Visual Studio Code it's automatically activating the virtual environment. I'm sure that's done by VS Code because I can find this command in the bash history of that terminal:\nsource <project-directory>\/venv\/bin\/activate\nI don't want the virtual environment to be activated. How can we prevent VS Code from doing that?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4580,"Q_Id":54802148,"Users Score":1,"Answer":"If you open the vscode terminal first and then select python interpreter, then it won't activate the python environment. This answer works in vscode 1.44.0 with pyhton 3.8.1. I haven't tested with other versions. However, if you have any files or workspace open you need to close that first to close the python interpreter. You don't need to make any changes in settings.","Q_Score":14,"Tags":"python,terminal,visual-studio-code","A_Id":61181153,"CreationDate":"2019-02-21T08:10:00.000","Title":"Prevent Visual Studio Code from activating the Python virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to directly send files from one API to another FTP server without downloading them to local in Python 3.\nCurrently we downloading from one API to local and then sending it to FTP server, want to avoid that hop from data flow by directly sending files to server.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1136,"Q_Id":54804532,"Users Score":0,"Answer":"One of the options would be having another API function (TransferFile, ...), which will transfer data from API server to FTP site. Then you just call that API method from your code without downloading data to the local server.","Q_Score":1,"Tags":"python,api,ftp","A_Id":54804765,"CreationDate":"2019-02-21T10:14:00.000","Title":"Upload file Directly to FTP Server in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to directly send files from one API to another FTP server without downloading them to local in Python 3.\nCurrently we downloading from one API to local and then sending it to FTP server, want to avoid that hop from data flow by directly sending files to server.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1136,"Q_Id":54804532,"Users Score":0,"Answer":"The FTP protocol has provision for initiating a data transfert between two remote hosts from a third party client. This is called the proxy mode. Unfortunately, most servers disable it for security reasons, because it used to be a very efficient way for DOS attacks.\nIf you have control on both servers and if both use FTP and if they are not publicly exposed, this can be very efficient.\nIn any other use case, the data will have to pass through the client. The best that can be done is to open both connections and transfer data to the target host as soon as it has been received from the source without storing it on disk.","Q_Score":1,"Tags":"python,api,ftp","A_Id":54804881,"CreationDate":"2019-02-21T10:14:00.000","Title":"Upload file Directly to FTP Server in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to directly send files from one API to another FTP server without downloading them to local in Python 3.\nCurrently we downloading from one API to local and then sending it to FTP server, want to avoid that hop from data flow by directly sending files to server.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1136,"Q_Id":54804532,"Users Score":0,"Answer":"you can use byte data of the file(it will store as in-memory) and pass that to another API.","Q_Score":1,"Tags":"python,api,ftp","A_Id":54804658,"CreationDate":"2019-02-21T10:14:00.000","Title":"Upload file Directly to FTP Server in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Every example I've found thus-far for development with Kivy in regards to switching screens is always done using a button, Although the user experience doesn't feel very \"native\" or \"Smooth\" for the kind of app I would like to develop.\nI was hoping to incorperate swiping the screen to change the active screen.\nI can sort of imagine how to do this by tracking the users on_touch_down() and on_touch_up() cords (spos) and if the difference is great enough, switch over to the next screen in a list of screens, although I can't envision how this could be implemented within the kv language\nperhaps some examples could help me wrap my head around this better?\nP.S.\nI want to keep as much UI code within the kv language file as possible to prevent my project from producing a speghetti-code sort of feel to it. I'm also rather new to Kivy development altogether so I appologize if this question has an official answer somewhere and I just missed it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":237,"Q_Id":54805487,"Users Score":0,"Answer":"You might want to use a Carousel instead of ScreenManager, but if you want that logic while using the ScreenManager, you'll certainly have to write some python code to manage that in a subclass of it, then use it in kv as a normal ScreenManager. Using previous and next properties to get the right screen to switch to depending on the action. This kind of logic is better done in python, and that doesn't prevent using the widgets in kv after.","Q_Score":0,"Tags":"android,python,kivy,screen,swipe","A_Id":54843815,"CreationDate":"2019-02-21T11:00:00.000","Title":"Kivy Android App - Switching screens with a swipe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to receive single byte data from user from a plaintext_edit but i want to make sure it is entered in hex format, 0x with prefix or else will result in unknown type\nExample : 0x3f\n-Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":54805705,"Users Score":0,"Answer":"You didn't say but I am guessing you are using pyqt. Define a handler for the  control's keyPressEvent and filter the user input there. That won't raise a type error. Instead you ensure that only valid data gets entered.","Q_Score":0,"Tags":"python,python-3.x,hex","A_Id":54839192,"CreationDate":"2019-02-21T11:11:00.000","Title":"Python: Pyqt Receive Hex format integer only from Plaintext","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"is it possible to code in python inside android studio? \nhow can I do it.\nI have an android app that I am try to develop. and I want to code some part in python.\nThanks for the help\nhow can I do it.\nI have an android app that I am try to develop. and I want to code some part in python.\nThanks for the help","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10022,"Q_Id":54809592,"Users Score":4,"Answer":"If you mean coding part of your Android application in python (and another part for example in Java) it's not possible for now. However, you can write Python script and include it in your project, then write in your application part that will invoke it somehow. Also, you can use Android Studio as a text editor for Python scripts. To develop apps for Android in Python you have to use a proper library for it.","Q_Score":7,"Tags":"android,python-3.x,android-studio","A_Id":54809908,"CreationDate":"2019-02-21T14:37:00.000","Title":"is it possible to code in python inside android studio?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a git submodule B, that works as an app in my django project A. B has its own Pipfile and Pifile.lock. A also has a Pipfile and Pipfile.lock. How can I use pipenv, to install the libraries  from both pipfiles within the same virtuaelenv?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1110,"Q_Id":54815737,"Users Score":2,"Answer":"go to the directory where each pipfile exist and run pipenv install. Make sure your virtualenv is activated.","Q_Score":4,"Tags":"python,django,git-submodules,pipenv","A_Id":54816103,"CreationDate":"2019-02-21T20:31:00.000","Title":"using pipenv with git submodules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am coming over from Matlab, and while everything was mostly ported over really well (the community has to be thanked for this, a Matlab license costs way over $1000). There is one thing that I cannot for the life of me find out.\nIn Matlab, all arrays are 2D (until recently, where they gave you other options). Such that, when I define a scalar, array, matrix they are all considered 2D. This is pretty useful when doing matrix multiplication!\nIn Python, when using numpy. Unfortunately, I find myself having to use the reshape command quite frequently.\nIs there anyway that I can globally set that all array's have 2D dimensions unless stated otherwise?\nEdit:\nAccording to the numpy documentation numpy.matrix may be removed in the coming future. What I want to do in essence is that have all output of any numpy operation have the function np.atleast_2d applied to them automatically.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":114,"Q_Id":54821206,"Users Score":2,"Answer":"As noted above, the np.matrix class has semantics quite similar to a matlab array.\nHowever, if you goal is to learn numpy as a marketable skill, I would strongly recommend you fully embrace the concept of an ndarray; while there is some historical truth to calling numpy a port of matlab, it is a bit of an insult, as the ndarray is one of the most compelling objective conceptual improvements of numpy over matlab, other than its price.\nTLDR; you will have a hard time not getting your application tossed by me if you claim to know numpy, but your code samples smell like ported matlab in any way.","Q_Score":1,"Tags":"python,arrays,numpy","A_Id":54821940,"CreationDate":"2019-02-22T06:24:00.000","Title":"I want all numpy arrays to be forced to be 2 dimensional","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a project with a few scripts in the same directory, a pychache folder has been created within that directory, it contains compiled versions of two of my scripts. This has happened by accident I do not know how I did it. One thing I do know is I have imported functions between the two scripts that have been compiled. \nI would like a third compiled python script for a separate file however I do not want to import any modules(if this is even the case). Does anyone know how I can manually create a .cpython-37 file? Any help is appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1413,"Q_Id":54823553,"Users Score":1,"Answer":"There is really no reason to worry about __pycache__ or *.pyc files - these are created and managed by the Python interpreter when it needs them and you cannot \/ should not worry about manually creating them. They contain a cached version of the compiled Python bytecode. Creating them manually makes no sense (and I am not aware of a way to do that), and you should probably let the interpreter decide when it makes sense to cache the bytecode and when it doesn't. \nIn Python 3.x, __pycache__ directories are created for modules when they are imported by a different module. AFAIK Python will not create a __pycache__ entry when a script is ran directly (e.g. a \"main\" script), only when it is imported as a module.","Q_Score":0,"Tags":"python","A_Id":54824065,"CreationDate":"2019-02-22T09:08:00.000","Title":"How to create .cpython-37 file, within __pycache__","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to install python packages in a windows server 2016 sandbox for running a developed python model in production.This doesn't have internet connection. \nMy laptop is windows 2010 and the model is now running in my machine and need to push this to the server.\nMy question is how can i install all the required packages in my server which has no internet connection.\nThanks\nMithun","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1269,"Q_Id":54824614,"Users Score":0,"Answer":"A simply way is to install the same python version on another machine having internet access, and use normally pip on that machine. This will download a bunch of files and installs them cleanly under Lib\\site_packages of your Python installation.\nYou can they copy that folder to the server Python installation. If you want to be able to later add packages, you should keep both installations in sync: do not add or remove any package on the laptop without syncing with the server.","Q_Score":0,"Tags":"python,windows,windows-server-2016","A_Id":54824942,"CreationDate":"2019-02-22T10:05:00.000","Title":"Install python packages in windows server 2016 which has no internet connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed python package python2-rpdb.noarch on centos using\nsudo yum install python2-rpdb.noarch --installroot='\/some\/local\/path' -v -y it gets installed by I cannot find anything on the path \/some\/local\/path\/ \nI cannot use pip as I do not have permission to use pip or otherwise pip is the way to go","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":520,"Q_Id":54825109,"Users Score":0,"Answer":"Try which python and will list the current location from where is is used and then a softlink can be created to the location where you want to use","Q_Score":1,"Tags":"python,centos,yum","A_Id":55016832,"CreationDate":"2019-02-22T10:32:00.000","Title":"to what location on disk does yum installs python packages by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I installed python package python2-rpdb.noarch on centos using\nsudo yum install python2-rpdb.noarch --installroot='\/some\/local\/path' -v -y it gets installed by I cannot find anything on the path \/some\/local\/path\/ \nI cannot use pip as I do not have permission to use pip or otherwise pip is the way to go","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":520,"Q_Id":54825109,"Users Score":0,"Answer":"If you want to find something in centos , go with locate command.\n\"\/usr\/lib\/python2.7\"  -  In my vm Python is here by deafault. I found this from locate command o\/p\ncommand used :  \"locate python\"","Q_Score":1,"Tags":"python,centos,yum","A_Id":54826914,"CreationDate":"2019-02-22T10:32:00.000","Title":"to what location on disk does yum installs python packages by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I installed python package python2-rpdb.noarch on centos using\nsudo yum install python2-rpdb.noarch --installroot='\/some\/local\/path' -v -y it gets installed by I cannot find anything on the path \/some\/local\/path\/ \nI cannot use pip as I do not have permission to use pip or otherwise pip is the way to go","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":520,"Q_Id":54825109,"Users Score":0,"Answer":"I got it by little bit of digging , \nI searched like this : \nrpm -ql python2-rpdb-0.1.5-2el7.1.noarch\nits installed in the \/usr\/lib\/python2.7\/site-packages folder\nor in \/usr\/lib64\/python2.7\/","Q_Score":1,"Tags":"python,centos,yum","A_Id":54826224,"CreationDate":"2019-02-22T10:32:00.000","Title":"to what location on disk does yum installs python packages by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How to install libraries like cairomm-devel,pangomm-devel those packages are not in Amazon Linux AMI.\nBut i need those libraries.\nHow do i install those libraries?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":54825688,"Users Score":0,"Answer":"There is no solution Amazon Linux does not have those libraries required.\nI fixed by migrating my server to Docker Instance using AWS Fargate (Serverless Approach).","Q_Score":0,"Tags":"python,amazon-web-services,amazon-ec2,yum","A_Id":58638495,"CreationDate":"2019-02-22T11:03:00.000","Title":"How to install libraries like cairomm-devel, pandomm-devel on Aws Linux AMI","Data Science and Machine Learning":0,"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 working primarily with Python on a Database with 17.000.000 records for 2.800.000 unique ID's. Each ID represents an event of a shipping process, and all instances have: ID, EVENT, TIMESTAMP (Datetime). There is an event that usually but not always starts the sequence and there are multiple outcomes, i.e delivered, returned, etc. \nMy goal in this is to find the most common path each ID takes, meaning, what is the order of events that occur and get the bottlenecks in the process. \nIs there any visualization tool I can use with Python that has this structure built into it? \nHow would you recommend I approach this issue? \nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":763,"Q_Id":54825811,"Users Score":1,"Answer":"This is not an answer for Python, but given the question, I think there is a better way to perform such analysis.\nI do not know if you have ever heard of Process Mining. But I think it is the perfect thing to use in your case. Basically, process mining consists of analyzing the flow of a process. I have worked with differen tools, some of them are:\n\nDisco \nProM (Open Source)\nCelonis\n\nBasically, all you need to do is define what is the ID (you already have it), then choose which columns represents the timestamp (you already have it) and the name of the event (you also have it).\nAny of those tools will be able to give you back a perfect analysis of your flow. Which is the most common path, the average time for each event, etc.\nIf you add more attributes, it can even return what is the reason to follow one path or another based on those attributes.","Q_Score":1,"Tags":"python,pandas,process,data-visualization,analysis","A_Id":54826136,"CreationDate":"2019-02-22T11:10:00.000","Title":"How to build a sequence based on timestamps ocurrences with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've installed opencv from source using a virtualenv, however I faced some errors and needed to reinstall it. I tried removing all the files with sudo find \/ -name \"opencv\" -exec rm {} \\; and checked if the package was removed with pkg-config --modversion opencv, and it said it could not be found, but when I open the terminal with python3 and enter import cv2 then print(cv2.__version__), the terminal returns 4.0.0. How can I completely remove opencv? I'm on Ubuntu 18.04 LTS.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":362,"Q_Id":54826979,"Users Score":0,"Answer":"I found out that I hadn't uninstalled in the build folder, problem solved!","Q_Score":1,"Tags":"python,opencv,ubuntu","A_Id":54832931,"CreationDate":"2019-02-22T12:17:00.000","Title":"OpenCV can't be found but can be imported","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a database that contains md5 hashs, i want to convert them to another type of hash so that the users can login to the new website.\nI am using the werkzeug.security library to generate the hashs.\nI there is any way to do that ??","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":683,"Q_Id":54828377,"Users Score":3,"Answer":"No. Hashes are not reversible, so you can't do that directly.\nThe way you solve this is that when an old user log in, you validate their password against the md5 hash, and if it matches, you create the SHA256 hash from the plain text password, sets the new SHA256 hash in the database (either as a separate field or by using a hash type identifier in front of the hash itself) and then remove the MD5 hash value.\nAfter a while (for example a year), you remove all the existing MD5 hashes and make people that attempt to log in without a valid hash reset their password through existing means and then only populate the SHA256 field.","Q_Score":3,"Tags":"python,werkzeug","A_Id":54828443,"CreationDate":"2019-02-22T13:40:00.000","Title":"How to convert md5 32 bytes hash to corresponding sha256 in python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a connection is to be made, a bounded socket should be listening for clients. Client needs to know both ip address and port.  For bounding a socket why we need an ip address of the server itself when the program(which listens for clients) itself is running on the server?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":15,"Q_Id":54829284,"Users Score":1,"Answer":"Simply because a server has multiple addresses, at least the loopback one at 127.0.0.1 (IP v4) and one per physical network interfaces. For example a corporate proxy has commonly two interfaces, one on the internal network and one on the public one. Most have a third one for the DMZ. Being member of different networks, those interfaces must have different addresses. And it make sense to open some services on only one interface.\nBut you also can use the ANY address (0.0.0.0 in IPv4) that means to accept connections on any interface.","Q_Score":0,"Tags":"python,tcp","A_Id":54829438,"CreationDate":"2019-02-22T14:30:00.000","Title":"why socket binding in server needs its ip address >","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to prevent Windows from shutting down my system with Python. So I can't shutdown my system while my Python script is running?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":964,"Q_Id":54830926,"Users Score":2,"Answer":"yes there is.\nfrom windows docs\n\nShutdown Notifications\nApplications with a window and message queue\nreceive shutdown notifications through the WM_QUERYENDSESSION and\nWM_ENDSESSION messages. These applications should return TRUE to\nindicate that they can be terminated. Applications should not block\nsystem shutdown unless it is absolutely necessary. Applications should\nperform any required cleanup while processing WM_ENDSESSION.\nApplications that have unsaved data could save the data to a temporary\nlocation and restore it the next time the application starts. It is\nrecommended that applications save their data and state frequently;\nfor example, automatically save data between save operations initiated\nby the user to reduce the amount of data to be saved at shutdown.\nConsole applications receive shutdown notifications in their handler\nroutines. To register a console handler, use the SetConsoleCtrlHandler\nfunction. Service applications receive shutdown notifications in their\nhandler routines. To register a service control handler, use the\nRegisterServiceCtrlHandlerEx function.\nBlocking Shutdown\nIf an application must block a potential system shutdown, it can call the\nShutdownBlockReasonCreate function. The caller provides a reason\nstring that will be displayed to the user. The reason string should be\nshort and clear, providing the user with the information necessary to\ndecide whether to continue shutting down the system.\n\nso you have to intercept the WM_QUERYENDSESSION message and return False .\nand doing some web search i found a discussion about that how to intercept the WM_QUERYENDSESSION in python :\n\nif you've built an app with a message loop, you can receive the\nWM_QUERYENDSESSION message. If you want to have a GUI, most GUI\nlibraries will probably wrap this up in their own way. If you don't\nneed a GUI, your simplest solution is probably to use PyWin32.\nSomewhere in the docs there's a tutorial on creating a hidden window\nand writing a simple message loop. Just do that on the main thread,\nand do your real work on a background thread, and signal your\nbackground thread when a WM_QUERYENDSESSION message comes in.\nOr, much more simply, just use SetConsoleCtrlHandler (again through\nPyWin32). This can also catch ^C, ^BREAK, and the user closing your\nconsole, as well as the logoff and shutdown messages that\nWM_QUERYENDSESSION catches. More importantly, it doesn't require a\nmessage loop, so if you don't have any other need for one, it's a lot\nsimpler.\n\ni can't help with code snippet as i don't have access to windows pc and i don't want to share code without testing, but i hope i pointed you to what you should look for.","Q_Score":2,"Tags":"python,windows","A_Id":54832170,"CreationDate":"2019-02-22T16:04:00.000","Title":"Block Windows 10 Shutdown with Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Probably an extremely trivial question. I created an environment in conda and now want to run a script in pycharm. what is the command line to activate said conda environment so that I can use work in it on pycharm?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":852,"Q_Id":54830984,"Users Score":0,"Answer":"By default, the command is source activate your_env_name\nOn Windows, it should be conda activate your_env_name instead","Q_Score":1,"Tags":"python,pycharm,conda","A_Id":54831008,"CreationDate":"2019-02-22T16:07:00.000","Title":"Activating a Conda Enviroment in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i developed a small web APP with CherryPy for Python. I want to run this on a production Server with ubuntu 16.04. My Sysadmin tells me that I shall not use pip or github repository, because of ... something wrong with using anything but apt ... he says. \nIs there a way of getting a recent cherrypy for python3 with apt ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2257,"Q_Id":54831915,"Users Score":0,"Answer":"The solution on Ubuntu 16.04 with python3 (Python 3.5.2):\nInstall virtualenvironment for python3\nsudo apt-get install python3-venv\nCreate a folder for your environment\nmkdir environment\nCreate the environment\npython3 -m venv environment\nChange into folder\ncd environment\/bin\nActivate environment\nsource activate\nInstall pip within the env\napt install python3-pip\nInstall cherrypy >= 18.1.0\npip3 install cherrypy\nRun program\npython3 .\/my_python_script.py","Q_Score":0,"Tags":"python,ubuntu,cherrypy","A_Id":54922769,"CreationDate":"2019-02-22T17:02:00.000","Title":"Python 3.5.2 Installation of Cherrypy with apt","Data Science and Machine Learning":0,"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":"For background, I am somewhat of a self-taught Python developer with only some formal training with a few CS courses in school. \nIn my job right now, I am working on a Python program that will automatically parse information from a very large text file (thousands of lines) that's a output result of a simulation software. I would like to be doing test driven development (TDD) but I am having a hard time understanding how to write proper unit tests. \nMy trouble is, the output of some of my functions (units) are massive data structures that are parsed versions of the text file. I could go through and create those outputs manually and then test but it would take a lot of time. The whole point of a parser is to save time and create structured outputs. Only testing I've been doing so far is trial and error manually which is also cumbersome. \nSo my question is, are there more intuitive ways to create tests for parsers? \nThank you in advance for any help!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":364,"Q_Id":54833354,"Users Score":2,"Answer":"Usually parsers are tested using a regression testing system. You create sample input sets and verify that the output is correct. Then you put the input and output in libraries. Each time you modify the code, you run the regression test system over the library to see if anything changes.","Q_Score":1,"Tags":"python,unit-testing,parsing","A_Id":54833388,"CreationDate":"2019-02-22T18:47:00.000","Title":"How to write unit tests for text parser?","Data 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 data set for which I use Sklearn Decision Tree regression machine learning package to build a model for prediction purposes. Subsequently, I am trying to utilize scipy.optimize package to solve for the minimized solution based on a given constraint. \nHowever, I am not sure if I can take the decision tree model as the objective function for the optimization problem. What should be the approach in a situation like this? I have tried linear regression models such as LarsCV in the past and they worked just fine. But in a linear regression model, you can essentially extract the coefficients and interception point from the model.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":904,"Q_Id":54833739,"Users Score":2,"Answer":"Yes; a linear regression model is a straightforward linear function of coefficients (one of which is the \"intercept\" or \"bias\").\nThe problem you have now is that a more complex model isn't quite so simple.  You need to load the model into an appropriate engine.  To \"call\" the model, you feed that engine the input vector (the cognate of a list of arguments), and wait for the model to return the prediction.\nYou need to wrap this process in a function call, perhaps one that issues the model load and processing as external system \/ shell commands, and returns the results to your main program.  Some applications are large enough that it makes sense to implement a full-bore data stream with listener and reporter to handle the throughput.\nDoes that get you moving?","Q_Score":6,"Tags":"python,machine-learning,optimization,scikit-learn,scipy","A_Id":54833867,"CreationDate":"2019-02-22T19:18:00.000","Title":"Can I use a machine learning model as the objective function in an optimization problem?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use miniconda as my default python installation. What is the current (2019) wisdom regarding when to install something with conda vs. pip?\nMy usual behavior is to install everything with pip, and only using conda if a package is not available through pip or the pip version doesn't work correctly.\nAre there advantages to always favoring conda install? Are there issues associated with mixing the two installers? What factors should I be considering?\n\nOBJECTIVITY: This is not an opinion-based question! My question is when I have the option to install a python package with pip or conda, how do I make an informed decision? Not \"tell me which is better, but \"Why would I use one over the other, and will oscillating back & forth cause problems \/ inefficiencies?\"","AnswerCount":6,"Available Count":1,"Score":0.1651404129,"is_accepted":false,"ViewCount":17147,"Q_Id":54834579,"Users Score":5,"Answer":"This is what I do: \n\nActivate your conda virutal env\nUse pip to install into your virtual env\nIf you face any compatibility issues, use conda\n\nI recently ran into this when numpy \/ matplotlib freaked out and I used the conda build to resolve the issue.","Q_Score":35,"Tags":"python,python-3.x,pip,conda,miniconda","A_Id":54834690,"CreationDate":"2019-02-22T20:17:00.000","Title":"Specific reasons to favor pip vs. conda when installing Python packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Also from my understanding if I download a package in a virtual environment if I come back to it, will still be there however my django package is gone. why is that?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":54834799,"Users Score":0,"Answer":"I can't add a comment since I don't have enough reputation but here are a few things you can do to debug this problem.\n\nCheck that you activated the correct virtualenv (or pipenv).\nOnce activated, run pip freeze in the terminal and check if django comes up as one of the packages installed.\nIf django doesn't show up there, you will need to install it again.","Q_Score":0,"Tags":"python,django,virtualenv","A_Id":54834859,"CreationDate":"2019-02-22T20:36:00.000","Title":"(virtual env)(global env) why is this happening instead of just (virtual env) when I activate it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Also from my understanding if I download a package in a virtual environment if I come back to it, will still be there however my django package is gone. why is that?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":54834799,"Users Score":0,"Answer":"Yes you have to install it again as a virtualEnv isolate your previous installation","Q_Score":0,"Tags":"python,django,virtualenv","A_Id":54834830,"CreationDate":"2019-02-22T20:36:00.000","Title":"(virtual env)(global env) why is this happening instead of just (virtual env) when I activate it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have started learning python online a few days ago and was doing fine until i came across importing module tutorial.They said you have to create two files in same directory in order to import from one another.I didn't get that..I mean every file I have created in sublime text using python have .py extension to it if that what it means.But still when I try to import a code it shows error.What should I do?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":54837550,"Users Score":0,"Answer":"Place all your python files in the same directory before trying to import them.","Q_Score":0,"Tags":"python,sublimetext","A_Id":54840958,"CreationDate":"2019-02-23T02:07:00.000","Title":"i am not being able to import code from one file to another in python.I am working on sublime text","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running C# project which use result of python file. I'm using IronPython to run python file in visual studio. But the error above come up. Please help me. Many thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1617,"Q_Id":54839602,"Users Score":0,"Answer":"Sorry you cant access third party functionalities\/packages (like Pandas here)\nThe reason:\nPandas \/ numpy use great parts of c code, that is a no good  for IronPython (.NET).!!!!\nIf you need to use the power of pandas, i suggest you to create a dialog (send\/reveive datas or by file or by calling an external python prog) between your IronPython Project and a program python including pandas.","Q_Score":0,"Tags":"c#,python,pandas","A_Id":54839647,"CreationDate":"2019-02-23T08:18:00.000","Title":"IronPython.Runtime.Exceptions.ImportException: 'No module named pandas'","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":"Justification first :)\nSwitch: Switch the marbles in positions 0 and 1.\nRotate: Move the marble in position 0 to position N - 1, and move all other marbles one space to the left (one index lower).\nIf there is a list of number (1,3,0,2)\nswitch - rotate - switch will sort the numbers\n3,1,0,2 - 1,0,2,3 - 0,1,2,3\nBut if we have (3,1,0,2), it never ends with switch - rotate - switch - rotate ... method.\nIs there a better way to use both switch and rotate to efficiently get the sorted result?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1000,"Q_Id":54840758,"Users Score":0,"Answer":"Pick one number at the start that you will never switch to represent an unmovable start\/end in the list.  No matter which number you pick, your simple algorithm of switching out-of-order elements and rotating will then always work.\nNote that \"out of order\" gets a bit complicated if you don't pick the smallest or largest element, since the correct order is cyclic.  The element smaller than the ones you pick go after the larger ones.\nTry all of the choices to see which one gives the fastest result.\ne.g.:\nDon't switch 0:\n3,1,0,2 - 1,3,0,2 - 3,0,2,1 - 0,2,1,3 - 2,1,3,0 - 1,2,3,0 - 2,3,0,1 - 3,0,1,2 - 0,1,2,3\nDon't switch 1:\n3,1,0,2 - 1,0,2,3 - 0,2,3,1 - 2,0,3,1 - 0,3,1,2 - 3,0,1,2 - 0,1,2,3\nDon't switch 2:\n3,1,0,2 - 1,0,2,3 - 0,1,2,3\nDon't switch 3:\n3,1,0,2 - 1,0,2,3 - 0,1,2,3\nEDIT:  This doesn't find the best when all best solutions require all elements to participate in swaps.  It does always find a solution, though, and it's polynomial time.","Q_Score":1,"Tags":"python,python-3.x,algorithm,sorting","A_Id":54842114,"CreationDate":"2019-02-23T10:46:00.000","Title":"sorting numbers with mix of switch and rotate in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install a virtual env. for python django.\nwhen I try pip freeze to check django version it says \"segmentation fault core dumped\"\nwhile using pip install django command its giving the same error","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":509,"Q_Id":54841131,"Users Score":0,"Answer":"Actually ans is simple, it needs admin rights, so use sudo pip install django","Q_Score":0,"Tags":"django,python-3.x,virtualenv","A_Id":54841166,"CreationDate":"2019-02-23T11:32:00.000","Title":"while checking the command pip freeze, the segmentation fault error is showing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I try to understand Keras and LSTMs step by step. Right now I build an LSTM there the input is a sentence and the output is an array of five values which can each be 0 or 1.\nExample:\nInput sentence: 'I hate cookies'\nOutput example: [0,0,1,0,1]\nFor this, I am using keras library.\nNow I am not sure which loss function I should use. Right now I just know two predefined loss functions a little bit better and both seem not to be good for my example:\nBinary cross entropy: Good if I have a output of just 0 or 1\nCategorical cross entropy: Good if I have an output of an array with one 1 and all other values being 0.\nBoth functions would not make any sense for my example. What would you use and why?\nEdit\nAnother Question: Which Activation function would you use in Keras?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7333,"Q_Id":54842219,"Users Score":0,"Answer":"You'll want to use a logistic activation. This pushes each logit between 0 and 1, which represents the probability of that category. \nThen use categorical cross entropy. This will not make your model a single class classifier since you are using the logistic activation rather than the softmax activation. \nAs a rule of thumb: \n\nlogistic activation pushes values between 0 and 1\nsoftmax pushes values between 0 and 1 AND makes them a valid probability distribution (sum to 1)\ncross entropy calculates the difference between distributions of any type.","Q_Score":0,"Tags":"python,python-3.x,tensorflow,keras","A_Id":54842514,"CreationDate":"2019-02-23T13:41:00.000","Title":"Which loss function should I use in my LSTM and why?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to understand Keras and LSTMs step by step. Right now I build an LSTM there the input is a sentence and the output is an array of five values which can each be 0 or 1.\nExample:\nInput sentence: 'I hate cookies'\nOutput example: [0,0,1,0,1]\nFor this, I am using keras library.\nNow I am not sure which loss function I should use. Right now I just know two predefined loss functions a little bit better and both seem not to be good for my example:\nBinary cross entropy: Good if I have a output of just 0 or 1\nCategorical cross entropy: Good if I have an output of an array with one 1 and all other values being 0.\nBoth functions would not make any sense for my example. What would you use and why?\nEdit\nAnother Question: Which Activation function would you use in Keras?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7333,"Q_Id":54842219,"Users Score":0,"Answer":"When it comes to regression problem in deep learning mean square error MSE is the most preferred loss function but when it comes to categorical problem where you want your output to be 1 or 0, true or false the cross binary entropy is preferable","Q_Score":0,"Tags":"python,python-3.x,tensorflow,keras","A_Id":70772878,"CreationDate":"2019-02-23T13:41:00.000","Title":"Which loss function should I use in my LSTM and why?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a little problem using Gurobi in Python. I have a .lp-file, where my linear programm is saved. To these constraints I want to add some additional constraints. Loading and optimizing works without any problems, but I just cannot add new constraints to my model. I do not know what I am doing wrong...\nI hope there is someone, who finds my mistake!\nThanks!\nMy code looks like below (I made it a bit easier)\nSI is a two-dimensional array containing the data for every variable.\nfrom gurobipy import *\nmodel = read(\"testdatei.lp\")\nfor j in range(len(SI)):\n    model.addConstr(x[SI[j][0], SI[j][1], SI[j][2], SI[j][3], SI[j][4], SI[j][5]] == 1)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":392,"Q_Id":54842821,"Users Score":0,"Answer":"Without knowing your error message, I assume the problem is that you have not defined x.\nThe quickest way to fix this would probably be to reconstruct the variable name (that you defined earlier when building the model) from the SI values and then  access the variables with getVarByName.\nIf this is slow because the model is big and you are accessing many variables, you could instead get the array of all variables with model.getVars(), then iterate over this and rebuild your multi-dimensional array (or tuple_dict) x by parsing the names of the variables.","Q_Score":1,"Tags":"python,gurobi","A_Id":54928019,"CreationDate":"2019-02-23T14:52:00.000","Title":"Read existing gurobi .lp-file and add constraints to it","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have my own precomputed data for running AP or Kmeans in python. However when I go to run predict() as I would like to run a train() and test() on the data to see if the clusterings have a good accuracy on the class or clusters, Python tells me that predict() is not available for \"precomputed\" data. \nIs there another way to run a train \/ test on clustered data in python?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":439,"Q_Id":54842990,"Users Score":3,"Answer":"Most clustering algorithms, including AP, have no well-defined way to \"predict\" on new data. K-means is one of the few cases simple enough to allow a \"prediction\" consistent with the initial clusters.\nNow sklearn has this oddity of trying to squeeze everything into a supervised API. Clustering algorithms have a fit(X, y) method, but ignore y, and are supposed to have a predict method even though the algorithms don't have such a capability.\nFor affinity propagation, someone at some point decided to add a predict based on k-means: It always predicts the nearest center. Computing the mean only is possible with coordinate data, and hence the method fails with metric=precomputed.\nIf you want to replicate this behavior, computer the distances to all cluster centers, and choose the argmin, that's all. You can't fit this into the sklearn API easily with \"precomputed\" metrics. You could require the user to pass a distance vector to all \"training\" examples for the precomputed metric, but only few of them are needed...\nIn my opinion, I'd rather remove this method altogether:\n\nIt is not in published research on affinity propagation that I know\nAffinity propagation is based on concepts of similarity (\"affinity\") not on distance or means\nThis predict will not return the same results as the points were labeled by AP, because AP is labeling points using a \"propagated responsibility\", rather than the nearest \"center\". (The current sklearn implementation may be losing this information...)\nClustering methods don't have a consistent predict anyway - it's not a requirement to have this.\nIf you want to do this kind of prediction, just pass the cluster centers to a nearest neighbor classifier. That is what is re-implemented here, a hidden NN classifier. So you get more flexibility if you make prediction a second (classification) step.\n\nNote that it clustering it is not common to do any test-train split, because you don't use the labels anyway, and use only unsupervised evaluation methods (if any at all, because these have their own array of issues) if any at all - you cannot reliably do \"hyperparameter optimization\" here, but have to choose parameters based on experience and humans looking at the data.","Q_Score":2,"Tags":"python,cluster-analysis","A_Id":54850244,"CreationDate":"2019-02-23T15:12:00.000","Title":"How to run predict() on \"precomputed\" data for clustering in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install tensorflow in python using pip command as\npip install tensorflow\n, but unfortunately, I received the following error:\nCould not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow\nI have also tried to install tensorflow using the following command \npip install --upgrade\nhttps:\/\/storage.googleapis.com\/tensorflow\/windows\/cpu\/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl, but was again faced with the following error:\ntensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl is not a supported wheel on this platform. Additionally, I have checked the same commands against Python Version 3.5x 3.6x and obviously 3.7 as well, but those didn't work.","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":10204,"Q_Id":54843623,"Users Score":1,"Answer":"I had the same issue on windows 10, I find out that tensorflow work with python x64 installation and the command I used is the follow: \n\npip install --upgrade tf","Q_Score":0,"Tags":"python,tensorflow,object-detection-api","A_Id":58692607,"CreationDate":"2019-02-23T16:30:00.000","Title":"Pip Install Tensorflow Failed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install tensorflow in python using pip command as\npip install tensorflow\n, but unfortunately, I received the following error:\nCould not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow\nI have also tried to install tensorflow using the following command \npip install --upgrade\nhttps:\/\/storage.googleapis.com\/tensorflow\/windows\/cpu\/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl, but was again faced with the following error:\ntensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl is not a supported wheel on this platform. Additionally, I have checked the same commands against Python Version 3.5x 3.6x and obviously 3.7 as well, but those didn't work.","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":10204,"Q_Id":54843623,"Users Score":1,"Answer":"Are you sure that you are capitalizing\/spelling properly? The command prompt is case-sensitive. The input I use is:\ncd C:\\path\\to\\the\\directory\\python\\is\\installed\\in (cd, space, the path to the directory) then:\npython -m pip install TensorFlow\nIt should work afterwards.","Q_Score":0,"Tags":"python,tensorflow,object-detection-api","A_Id":54843717,"CreationDate":"2019-02-23T16:30:00.000","Title":"Pip Install Tensorflow Failed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install tensorflow in python using pip command as\npip install tensorflow\n, but unfortunately, I received the following error:\nCould not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow\nI have also tried to install tensorflow using the following command \npip install --upgrade\nhttps:\/\/storage.googleapis.com\/tensorflow\/windows\/cpu\/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl, but was again faced with the following error:\ntensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl is not a supported wheel on this platform. Additionally, I have checked the same commands against Python Version 3.5x 3.6x and obviously 3.7 as well, but those didn't work.","AnswerCount":6,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":10204,"Q_Id":54843623,"Users Score":2,"Answer":"I think Tensorflow does not currently have support for Python 3.7 and if you have Python 3.7 currently installed this might be the cause of the error message Could not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow\nYou can downgrade to Python 3.6.x and install tensorflow using pip then.","Q_Score":0,"Tags":"python,tensorflow,object-detection-api","A_Id":54843877,"CreationDate":"2019-02-23T16:30:00.000","Title":"Pip Install Tensorflow Failed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have a virtual environment where I installed the package utility. I know I installed it because when I do pip install utlity and get this output:\n\nRequirement already satisfied: utility in .\/anaconda3\/envs\/SpliceBuster\/lib\/python3.5\/site-packages (1.0)\n\nHere's the output of print (sys.path):\n\n['', '\/home\/joel\/anaconda3\/envs\/SpliceBuster\/lib\/python35.zip', '\/home\/joel\/anaconda3\/envs\/SpliceBuster\/lib\/python3.5', '\/home\/joel\/anaconda3\/envs\/SpliceBuster\/lib\/python3.5\/plat-linux', '\/home\/joel\/anaconda3\/envs\/SpliceBuster\/lib\/python3.5\/lib-dynload', '\/home\/joel\/anaconda3\/envs\/SpliceBuster\/lib\/python3.5\/site-packages']\n\nWhen I do import utility in a python shell, I get:\n\nTraceback (most recent call last):\n  File \"<stdin>\", line 1, in \n  ImportError: No module named 'utility'\n\nIt's confusing to me because I can import numpy, and when I do pip install numpy, the output is:\n\nRequirement already satisfied: numpy in .\/anaconda3\/envs\/SpliceBuster\/lib\/python3.5\/site-packages (1.12.1)\n\nwhich means that both utility and numpy are installed in the same folder, but numpy is found whereas utility isn't.\nAny thoughts on what could be going on?\n\nOther info:\nwhich python:\n\n\/home\/joel\/anaconda3\/envs\/SpliceBuster\/bin\/python\n\npython -V:\n\nPython 3.5.0 :: Continuum Analytics, Inc.","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":138,"Q_Id":54845900,"Users Score":-2,"Answer":"Try to place the module's folder into the same directory where you have the script you want to execute. This way we could discard a folders' tree issue.","Q_Score":3,"Tags":"python,python-3.x,python-import,conda,importerror","A_Id":64476209,"CreationDate":"2019-02-23T20:31:00.000","Title":"Python Module Not Found, Yet Installed and in Search Path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a user path to install packages installed by pip or pip3 for python 3.7.2, for that, I noticed that C:\\Users\\VVK\\AppData\\Roaming\\Python\\Python37\\site-packages by py -m site --user-site and,\nI wish to update it by C:\\Users\\VVK\\AppData\\Roaming\\Python37\\Scripts, How is this possible?\nI am using Microsoft Windows 10 64-bit.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1741,"Q_Id":54845991,"Users Score":0,"Answer":"Python37\\site-packages is used to install libraries while Python37\\Scripts is used to install programs. The latter should not be used for package installation. Packages when installed should install their programs (executable scripts) into Python37\\Scripts themselves.","Q_Score":1,"Tags":"python,windows,cmd,command-line,pip","A_Id":54846307,"CreationDate":"2019-02-23T20:38:00.000","Title":"Change path of pip and pip3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to Python and having trouble with several modules. In Pycharm, everything works fine. I am able to import modules, pip installer works fine. However, for some reason I'm running into issues when trying to import modules in the Python Shell, or when running programs using the command line. \nFor example, I can import Beautiful soup just fine in pycharm, but when I try in the shell I get:\nTraceback (most recent call last):\n  File \"\", line 1, in \n    import bs4\nModuleNotFoundError: No module named 'bs4'\nSimilarly, when I save a program in pycharm and try to run it from the command line, I get:\nC:\\Users\\Tony>hellowness.py\nTraceback (most recent call last):\n  File \"C:\\Users\\Tony\\MyPythonScripts\\Hellowness.py\", line 3, in \n    import selenium, bs4, pyperclip\nModuleNotFoundError: No module named 'bs4'\nThe correct directory is being used, because I can run simple programs that don't use modules without problems in the command line. \nSorry if this has been answered eleswhere. I searched the forum but people seem to being having trouble installing modules. The modules are installed fine (I think) they just don't work in the Python Shell or the command line. How do I go about troubleshooting this?\nThank you,\nTony","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":275,"Q_Id":54846115,"Users Score":0,"Answer":"I finally figured it out. As you said there were two \"Site Packages\" directories installed. One for Pycharm and one for Python itself. I am sure there's a more efficient way to solve it, but for now I just copied any relevant modules from Pycharm's site packages folder over to Python's. \nThanks!","Q_Score":0,"Tags":"python,beautifulsoup","A_Id":54847541,"CreationDate":"2019-02-23T20:54:00.000","Title":"Modules working in Pycharm but not Shell or Command Line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a binary classification task using linear SVM in scikit learn. I use nominal features and word vectors. I obtained the word vectors using the pretrained Google word2vec, however, I am not sure how SVM can handle word vectors as a feature.\nIt seems that I need to \"split\" each vector in 300 separate features (=300 vector dimensions), because I can't pass the vector as a whole to SVM. But that doesn't seem right, as the vector should be treated as one feature.\nWhat would be the correct way to represent a vector in this case?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":947,"Q_Id":54846314,"Users Score":1,"Answer":"Vector of many features\nFrom the perspective of an SVM, each dimension of a word vector would be a separate numeric feature - each dimension in that vector represents a numeric metric representing something different.\nThe same applies for non-SVM classifiers. For example, if you'd have a neural network, and your input features were that word vector of length 300 and (for the sake of a crude example) a bit stating whether that word was capitalized, then you'd concatenate those things and would have 301 numbers as your input; you'd treat that feature just as each of the 300 dimensions.","Q_Score":3,"Tags":"python,classification,svm,word2vec","A_Id":54846520,"CreationDate":"2019-02-23T21:20:00.000","Title":"What is the input format for word2vec features in SVM classification task?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently installed and compiled openCV on my raspberrypi.\nNow if I use the command import cv2 in my raspian OS (either in the python shell or the IDE) I get an error \n\nno module named cv2 found but the same command works in the raspberrypi shell.    \n\nHow do I resolve this??\n\nFile  \"home\/pi\/Desktop\/FR.py\",line 2,in module\nimport cv2\nFile \"\/usr\/lib\/python3\/dist-packages\/thonny\/backend.py\",line\n305,in_custom_import\nmodule=self_original_import(*args,**kw) ImportError:no module named\n'cv2'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":54849139,"Users Score":0,"Answer":"Please try to run your code after executing the below command.\npython -m pip install opencv-contrib-python","Q_Score":0,"Tags":"python","A_Id":54921745,"CreationDate":"2019-02-24T05:49:00.000","Title":"Why am I getting cv2 error in raspbianOS and not raspberrypi shell","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a data set of approximately 3000 questions and I want to perform intent classification. The data set is not labelled yet, but from the business perspective, there's a requirement of identifying approximately 80 various intent classes. Let's assume my training data has approximately equal number of each classes and is not majorly skewed towards some of the classes. I am intending to convert the text to word2vec or Glove and then feed into my classifier.\nI am familiar with cases in which I have a smaller number of intent classes, such as 8 or 10 and the choice of machine learning classifiers such as SVM, naive bais or deeplearning (CNN or LSTM).\nMy question is that if you have had experience with such large number of intent classes before, and which of machine learning algorithm do you think will perform reasonably? do you think if i use deep learning frameworks, still large number of labels will cause poor performance given the above training data?\nWe need to start labelling the data and it is rather laborious to come up with 80 classes of labels and then realise that it is not performing well, so I want to ensure that I am making the right decision on how many classes of intent maximum I should consider and what machine learning algorithm do you suggest?\nThanks in advance...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1227,"Q_Id":54850657,"Users Score":2,"Answer":"First, word2vec and GloVe are, almost, dead. You should probably consider using more recent embeddings like BERT or ELMo (both of which are sensitive to the context; in other words, you get different embeddings for the same word in a different context). Currently, BERT is my own preference since it's completely open-source and available (gpt-2 was released a couple of days ago which is apparently a little bit better. But, it's not completely available to the public).\nSecond, when you use BERT's pre-trained embeddings, your model has the advantage of seeing a massive amount of text (Google massive) and thus can be trained on small amounts of data which will increase it's performance drastically.\nFinally, if you could classify your intents into some coarse-grained classes, you could train a classifier to specify which of these coarse-grained classes your instance belongs to. Then, for each coarse-grained class train another classifier to specify the fine-grained one. This hierarchical structure will probably improve the results. Also for the type of classifier, I believe a simple fully connected layer on top of BERT would suffice.","Q_Score":2,"Tags":"python,tensorflow,nlp,text-classification","A_Id":54855155,"CreationDate":"2019-02-24T09:50:00.000","Title":"Intent classification with large number of intent classes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to read 1 file letter by letter but sometimes I have to go a back byte (to read something that I have already read).\nIs there anyway to make that happen?  \nOr how can I see the next byte without forwarding the file to then next position?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":636,"Q_Id":54851031,"Users Score":-1,"Answer":"i just found a solution using file.seek(file.tell()-1) so it goes back if i need it to go thank you all for your help and time.","Q_Score":0,"Tags":"python,file","A_Id":54851306,"CreationDate":"2019-02-24T10:41:00.000","Title":"While I do file.read(1) is there a way to go back 1 byte?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to make a discord bot, and I read that I need to have an older version of Python so my code will work. I've tried using \"import discord\" on IDLE but an error message keeps on coming up. How can I use Python 3.6 and keep Python 3.7 on my Windows 10 computer?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":323,"Q_Id":54852821,"Users Score":0,"Answer":"Install in different folder than your old Python 3.6 then update path\nUsing Virtualenv and or Pyenv\nUsing Docker\n\nHope it help!","Q_Score":2,"Tags":"python,discord","A_Id":54853052,"CreationDate":"2019-02-24T14:21:00.000","Title":"how can I use python 3.6 if I have python 3.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to make a discord bot, and I read that I need to have an older version of Python so my code will work. I've tried using \"import discord\" on IDLE but an error message keeps on coming up. How can I use Python 3.6 and keep Python 3.7 on my Windows 10 computer?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":323,"Q_Id":54852821,"Users Score":0,"Answer":"Just install it in different folder (e.g. if current one is in C:\\Users\\noob\\AppData\\Local\\Programs\\Python\\Python37, install 3.6. to C:\\Users\\noob\\AppData\\Local\\Programs\\Python\\Python36).\nNow, when you'll want to run a script, right click the file and under \"edit with IDLE\" will be multiple versions to choose. Works on my machine :)","Q_Score":2,"Tags":"python,discord","A_Id":54853010,"CreationDate":"2019-02-24T14:21:00.000","Title":"how can I use python 3.6 if I have python 3.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use Xcode to create python applications and I am testing it and every time I want to run the project I get the following error:\n\nThere is a problem launching using posix_spawn (error code: 8).\n\nAnd Xcode also said build succeeded.\nwhat can I do to resolve this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2550,"Q_Id":54856231,"Users Score":0,"Answer":"try change executable interpreter to \/usr\/bin\/pythonw","Q_Score":0,"Tags":"python-3.x,xcode10,macos-mojave","A_Id":57628096,"CreationDate":"2019-02-24T20:29:00.000","Title":"using Xcode 10 for python, gets a launch error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm having trouble resetting my keras model to the weights it had in the previous epoch after I hit a train_on_batch update that makes some of the weights nans.\nI have tried to save the model weights after each training step and then to load the \"good\" (non-nan) weights back into the keras model after a nan training update. \nThis seems to work fine - when I print the result of model.get_weights() after loading the old weights file into the model, the resulting weights contain no nans (and predict using them also gives a non-nan output).\nHowever, now when I try to train_on_batch again, this time using a new batch, I get a nan update again immediately. I've tried with multiple randomly chosen batches and the nan update happens each time. \nIs there something (maybe a parameter) that changes in the model or optimizer configuration when a nan train_on_batch update occurs that needs to be reset for training to continue once I change out the weights?\nI would also like to avoid using model.save() and load_model() in the solution.\n(keras 2.2.4, tensorflow 1.12.0)\nAny thoughts are appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":896,"Q_Id":54856754,"Users Score":0,"Answer":"since you have not pasted your code and weights I can't tell you much, but I suspect this problem may be due to dropout or regularisation, if you are using any of the two techniques set the parameters or percentage of dropouts properly as per your network, a high percentage in a small network will lead this sort of problem same with regularization. \nand for reverting and saving models use checkpoints.","Q_Score":1,"Tags":"python,tensorflow,keras,deep-learning,nan","A_Id":54856783,"CreationDate":"2019-02-24T21:29:00.000","Title":"How to revert keras model to previous epoch weights after train_on_batch nan update","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using lucas-kanade opencv implementation to track objects between frames. I want to be able to do the following two things:\n\nCalculate the distance moved by each point between frames\nTrack bounding boxes for each object across frames\n\nI have obtained the features to track using cv2.goodFeaturesToTrack(). I also add the bounding boxes of objects to the features to be tracked. Right now I am using the following to calculate distance between the points\nnp.sqrt(np.square(new_pts - old_pts).sum(axis=1).sum(axis=1)). I am not quite sure if this is the correct way to do this because the indices of the points might be different in the new_pts. \nIs the assumption that every index in old_pts corresponds to  the same feature in new_pts array correct?\nSecondly, is there a way to track bounding boxes across frames using lucas kanade?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":241,"Q_Id":54856954,"Users Score":0,"Answer":"In new_pts points have the same index. But they can be not founded - see to the status array: if status[i] == 1 then new_pts[i] contains a new coordinates of the old_pts[i].\nFor the more robustness it can to search direct flow (goodFeaturesToTrack(frame1) -> LK flow), backward flow (goodFeaturesToTrack(frame2) -> LK flow) and leave the points whose coordinates are equal in both directions.","Q_Score":1,"Tags":"python,opencv,computer-vision,computer-science","A_Id":54862189,"CreationDate":"2019-02-24T21:57:00.000","Title":"Lucas Kanade: How to calculate distance between tracked points","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to print a multiprocessing queue and I only get the memory address of the object. Can someone please tell me why the devs decided not to implement the functionality?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":142,"Q_Id":54859338,"Users Score":2,"Answer":"Were you expecting to see the elements? Doing that would require removing all elements from the queue due to how the inter-process communication works, and the results wouldn't necessarily be \"what's in the queue right now\" with other processes pushing and popping elements concurrently.","Q_Score":1,"Tags":"python,string,queue,repr","A_Id":54859388,"CreationDate":"2019-02-25T04:02:00.000","Title":"Why doesn't the python Queue class have a __repr__ or __str__ defined?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there an option to use an image uploaded to telegram (file_id couldn't do it) inside InlineQueryResultArticle thumb_url?\nnotes:\nI tried to get the file path using getfile() but it didn't do the trick.\neven tried to upload a very small image size with no luck.\nI'd like to ignore the InlineQueryResultCachedPhoto option since the design is not the same\nany thoughts?\nthank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":321,"Q_Id":54859470,"Users Score":0,"Answer":"I also checked that the telegram does not show the uploaded image, I think it is better to give the address of the picture directly.","Q_Score":1,"Tags":"python-telegram-bot","A_Id":69072827,"CreationDate":"2019-02-25T04:24:00.000","Title":"InlineQueryResultArticle - thumb_url uploaded image","Data Science and Machine Learning":0,"Database and SQL":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 module settings.py, which stores some variables to be used by other modules (for the sake of the example, let's call them brightness and saturation, though the actual module has a lot more and their initialization is much more complex).\nThis module is imported by other modules so that they can use settings.brightness and settings.saturation in their own code. However, these two variables aren't initialized - and are instead set to None when settings is imported. They have to be initialized by calling settings.init() at least once. (Why not initalize them automatically by putting init() at the end of settings.py? There are reasons... essentially, I have to do some other things first.)\nAnyway, I'd like to be able to raise an exception if brightness or contrast were accessed before init() has been called. I was thinking about using some kind of object instead of None when settings is imported (which would raise an exception upon being accessed), but I can't think of a way to implement that, nor do I think that would be good design. Any help is appreciated!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":282,"Q_Id":54860035,"Users Score":1,"Answer":"was thinking about using some kind of object instead of None when settings is imported (which would raise an exception upon being accessed)\n\nThis is not how it works... \"accessing\" an object is done by looking up this object's name on it's container object (via object.__getattribute__(), which is the implementation of the 'dot' operator), so only the container can detect \"access\". In your case, the container is a module, so you cannot override __getattribute__. \nThe possible solutions here are either to force client code to use a function to get the value (which is quite impractical) or - as explained by pasupati - to wrap the whole thing into a custom class and use properties to control access. You might eventually make this class a singleton...\nNB:\n\nBecause the Settings class would have to be assigned to some variable before being used. If the module name is settings and, say, it assigns settings = Settings() at the end, then, in order to reference this object, other modules would have to call settings.settings.get_brightness(). from settings import settings is another option, but that would be counterintuitive\n\nNo one forces you to name the module settings.py ;-)\nDjango is doing something similar (wrapping the settings in a custom class instance) and the module to import from is named 'django.conf' so you do from django.conf import settings.","Q_Score":1,"Tags":"python,python-3.x","A_Id":54863095,"CreationDate":"2019-02-25T05:32:00.000","Title":"Raise an exception if a variable is accessed before being \"initialized\" by another function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning python using Anaconda, Whenever I am trying to run spyder debug mode in Anaconda root env. I always get the following error message:\n\nTraceback (most recent call last):\nFile \"\", line 1, in \n      debugfile('\/home\/...\/project2.py', wdir='\/home\/...\/Project_2', post_mortem=True)\nFile\n  \"\/home\/Anaconda3\/lib\/python3.6\/site-packages\/spyder_kernels\/customize\/spydercustomize.py\",\n  line 809, in debugfile\n      debugger.run(\"runfile(%r, args=%r, wdir=%r)\" % (filename, args, wdir))\nFile \"\/home\/Anaconda3\/lib\/python3.6\/bdb.py\", line 434, in run\n      exec(cmd, globals, locals)\nFile \"\", line 1, in \nFile\n  \"\/home\/Anaconda3\/lib\/python3.6\/site-packages\/spyder_kernels\/customize\/spydercustomize.py\",\n  line 786, in runfile\n      execfile(filename, namespace)\nFile\n  \"\/home\/Anaconda3\/lib\/python3.6\/site-packages\/spyder_kernels\/customize\/spydercustomize.py\",\n  line 110, in execfile\n      exec(compile(f.read(), filename, 'exec'), namespace)\nFile \"\/home\/...\/project2.py\", line 2, in \n      import pandas as pd\nFile \"\/home\/...\/project2.py\", line 2, in \n      import pandas as pd\nFile \"\/home\/Anaconda3\/lib\/python3.6\/bdb.py\", line 51, in\n  trace_dispatch\n      return self.dispatch_line(frame)\nFile \"\/home\/Anaconda3\/lib\/python3.6\/bdb.py\", line 69, in\n  dispatch_line\n      self.user_line(frame)\nFile \"\/home\/Anaconda3\/lib\/python3.6\/pdb.py\", line 261, in user_line\n      self.interaction(frame, None)\nFile\n  \"\/home\/Anaconda3\/lib\/python3.6\/site-packages\/spyder_kernels\/customize\/spydercustomize.py\",\n  line 425, in interaction\n      self._cmdloop()\nFile\n  \"\/home\/Anaconda3\/lib\/python3.6\/site-packages\/spyder_kernels\/customize\/spydercustomize.py\",\n  line 436, in _cmdloop\n      self.cmdloop()\nFile \"\/home\/Anaconda3\/lib\/python3.6\/cmd.py\", line 126, in cmdloop\n      line = input(self.prompt)\nFile\n  \"\/home\/...\/.local\/lib\/python3.6\/site-packages\/ipykernel\/kernelbase.py\",\n  line 853, in raw_input\n      password=False,\nFile\n  \"\/home\/...\/.local\/lib\/python3.6\/site-packages\/ipykernel\/kernelbase.py\",\n  line 863, in _input_request\n      self.stdin_socket.recv_multipart(zmq.NOBLOCK)\nFile\n  \"\/home\/...\/.local\/lib\/python3.6\/site-packages\/zmq\/sugar\/socket.py\",\n  line 467, in recv_multipart\n      parts = [self.recv(flags, copy=copy, track=track)]\nFile \"zmq\/backend\/cython\/socket.pyx\", line 788, in\n  zmq.backend.cython.socket.Socket.recv\nFile \"zmq\/backend\/cython\/socket.pyx\", line 824, in\n  zmq.backend.cython.socket.Socket.recv\nFile \"zmq\/backend\/cython\/socket.pyx\", line 191, in\n  zmq.backend.cython.socket._recv_copy\nFile \"zmq\/backend\/cython\/socket.pyx\", line 186, in\n  zmq.backend.cython.socket._recv_copy\nFile \"zmq\/backend\/cython\/checkrc.pxd\", line 19, in\n  zmq.backend.cython.checkrc._check_rc\nAgain: Resource temporarily unavailable\n\nI keep my Anaconda updated, but the debug mode runs normally in my another virtual env (my_env),\n\nUbuntu 18.04 LTS\nroot_env (python 3.6.8), my_env (python 3.7.2)\nspyder: 3.3.3 (both)\nIPython: 7.2.0","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2285,"Q_Id":54860345,"Users Score":2,"Answer":"(Spyder maintainer here) Reading carefully your traceback, it seems you're mixing Anaconda packages with packages you installed in your home directory with pip. And those are incompatible for binary packages like pyzmq, the one generating the error.\nSo you need to remove this directory\n~\/.local\/lib\/python3.6\/site-packages\nto avoid the mixing and fix your problem.","Q_Score":0,"Tags":"python-3.x,anaconda,zeromq,spyder","A_Id":54864451,"CreationDate":"2019-02-25T06:04:00.000","Title":"Spyder debug mode not working in Anaconda root environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"To be specific,\nPyPi package rarfile has _check_unrar_tool() function that runs on import. I don't want it run while importing, because it throws permission error in certain boxes.\nI cant modify the package at my place due to certain restrictions.\nSo, as in this scenario, is it possible to ignore _check_unrar_tool() call and import successfully.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":45,"Q_Id":54860427,"Users Score":1,"Answer":"Technically, the rarfile package, more specifically the _check_unrar_tool() just expects a return code of 0 from the unrar command.\nIf you can somehow check if the unrar command works before importing the package, you can substitute it for something else that returns 0 and you can get away without messing with the package.","Q_Score":0,"Tags":"python,python-import,pypi,rar","A_Id":54861080,"CreationDate":"2019-02-25T06:13:00.000","Title":"Is it possible to avoid execution of check function if available in module while importing 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'm new to Flask and web development in general. I have a Flask web-application that is using SQLAlchemy, is it ok to put session.rollback at the beginning of the app in order to keep it running even after a transaction fails?\nI had a problem with my website when it stopped working after I was attempting to delete records of one table. The error log showed that the deletion failed due to entries in another table still referencing these records as their foreign key. The error log suggested using session.rollback to rollback this change, so I put it at the beginning of my app just after binding my database and creating the session and my website worked. This gave me the hint to leave that line there. Is my move right, safe and ok? Can anyone tell me what is the correct thing to do if this is somewhat endangering the functionality or logic of my website by any chance?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":68,"Q_Id":54861925,"Users Score":1,"Answer":"You should not use the rollback at the beginning but when a database operation fails.\nThe error is due to an integrity condition in your database. Some rows in your table are being referenced by another table. So, you have to remove referencing rows first.","Q_Score":0,"Tags":"python,session,flask,sqlalchemy,rollback","A_Id":54868874,"CreationDate":"2019-02-25T08:10:00.000","Title":"In a Flask application that is using SQLAlchemy, is it ok to permanently put `session.rollback` at the beginning of the app?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a folder containing multiple images, i want to write these images as a video file on Google drive. Is there any way to achieve this?\nI cannot write the images to video file in local system and then upload to Google Drive, because of space constraint.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":39,"Q_Id":54863190,"Users Score":1,"Answer":"The google drive api is a file store api.  It contains information about the files it contains and it will allow you to upload new files.  To some extent it can covert one file type to another.   For example it can covert an excel file to a google sheets file and back and forth.\nThe google drive api does not have the ablity to allow you to upload two images and have them coverted into a video.\nYou will need to encode the video locally on your machine and then upload the video after.","Q_Score":1,"Tags":"python-3.x,google-drive-api","A_Id":54864817,"CreationDate":"2019-02-25T09:36:00.000","Title":"Write a set of images to a Video file on Google Drive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there some way to a constraint on the data generated by tensor flow, for example if my  model produced two outputs can you impose some sort of constraint on these, like if a and b where the outputs could you pre-enforce something like (a+b)\/2<10? So the model wouldn't break this rule?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":236,"Q_Id":54864100,"Users Score":1,"Answer":"If by \"generated by TensorFlow\" you mean generated by a neural network, I don't think it is possible to do that in general. You can't really guarantee that the output of a neural network never violates such hard constraints in general, especially at test time.\nHere's what you could do:\n\nAdd a loss term, something like max(0, (a+b)\/2 - 10). This will not guarantee that your constraint is not violated (the optimization of the NN is \"best-effort\"). This loss function is btw very similar to the hinge loss used in support vector machines.\nUse an appropriate activation function. E.g. if you know your data must lie between [0, 1], use the sigmoid activation on the output.\n\"Project\" the output back to the allowed range if it is outside of it.\n\nWhile the last two options guarantee feasibility, it is not always possible to do that or it is not clear how to do it and - even worse - how this will affect the learning. For example, if you see that (a+b)\/2 >= 10 what will you do? Will you decrease b until the constraint is fulfilled, or both trade-off a and b somehow? Sometimes it is possible to define the \"closest feasible point\" w.r.t. some metric, but not in general.","Q_Score":3,"Tags":"python-3.x,tensorflow,constraints","A_Id":54870187,"CreationDate":"2019-02-25T10:27:00.000","Title":"Is there a way to impose a constraint in tensor flow, could I enforce some rule along the way?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I am installing the new package in my deep-learning environment it gives me this error:\n\nCould not install packages due to an EnvironmentError: [WinError 32]\n  The process cannot access the file because it is being used by another\n  process:  Consider using the --user option or check the permissions.\n\nPlease help to resolve this","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":170,"Q_Id":54865526,"Users Score":0,"Answer":"terminal one as administrator if using Windows and use ubuntu before command use sudo.","Q_Score":1,"Tags":"python,pip,deep-learning","A_Id":54865791,"CreationDate":"2019-02-25T11:49:00.000","Title":"Python packages installing error in deep-learning environment","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently in the process of learning how to use the Python Pyramid web framework, and have found the documentation to be quite excellent.\nI have, however, hit a stumbling block when it comes to distinguishing the idea of a \"model\" (i.e. a class defined under SQLAlchemy's declarative system) from the idea of a \"resource\" (i.e. a means of defining access control lists on views for use with Pyramid's auth system).\nI understand the above statements seem to show that I already understand the difference, but I'm having trouble understanding whether I should be making models resources (by adding the __acl__ attribute directly in the model class) or creating a separate resource class (which has the proper __parent__ and __name__ attributes) which represents the access to a view which uses the model.\nAny guidance is appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":181,"Q_Id":54869002,"Users Score":1,"Answer":"I'm having trouble understanding whether I should be making models resources (by adding the acl attribute directly in the model class) or creating a separate resource class\n\nThe answer depends on what level of coupling you want to have. For a simple app, I would recommend making models resources just for simplicity sake. But for a complex app with a high level of cohesion and low level of coupling it would be better to have models separated from resources.","Q_Score":5,"Tags":"python,python-3.x,pyramid","A_Id":54891000,"CreationDate":"2019-02-25T15:00:00.000","Title":"Is a Pyramid \"model\" also a Pyramid \"resource\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to activate a python virtual environment for everything a user do ? I have a webapp executing python code, and I would want the www-data user used by the apache host to use a specific python venv (It would solve a struggle for libraries).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":200,"Q_Id":54869094,"Users Score":0,"Answer":"source the virtual environment in ~\/.bashrc","Q_Score":0,"Tags":"python,bash,apache,web,virtualenv","A_Id":54869163,"CreationDate":"2019-02-25T15:05:00.000","Title":"Set a python virtual environment to a ubuntu user?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I recently switched over from using a PC to a Mac and now for whatever reason one of my Impala drivers that worked fine is no longer found when run in Python. I keep receiving this error every time I run the script : \"java.lang.RuntimeException: Class com.cloudera.impala.jdbc41.Driver not found\". Please see code snippet for my connection below.\nc = jaydebeapi.connect\n(jclassname='com.cloudera.impala.jdbc41.Driver',\nurl='jdbc:impala:\/\/cloudera-impala-proxy.live.bi.xxx\/;AuthMech=3;ssl=1;',\ndriver_args=['xxx', self.dwh_password],                               jars='\/Users\/xxx\/Desktop\/ImpalaJDBC41 2.jar')\nAny help or suggestions are appreciated, I feel like I'm going crazy trying to get this to work.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1177,"Q_Id":54870285,"Users Score":0,"Answer":"Did you check do you have the ImpalaJDBC***.jar in your new machine.\nPlease check properly weather it's available at classpath\/build path or not.\nEdit:\nYou can use hive jdbc jar as well to connect with impala , just use the port of impala rather hive in jdbc url.","Q_Score":2,"Tags":"java,python,jdbc,impala,jaydebeapi","A_Id":54871799,"CreationDate":"2019-02-25T16:06:00.000","Title":"Impala driver class not being found through Jaydebeapi Connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have the following problem and am not quite sure if it is solvable by image recognition (and convolutional neural networks).\nI have a dataset of 400k pictures divided into 5 classes. The pictures are screenshots of apps, which are put into the 5 classes depending on what age rating they received.\nFor example: I have 200k labeled as class 0, which means they are suitable all ages (according to the age rating); I have 50k pictures labeled as class 1 (suitable for children aged 6+) and so on.\nWith this data I want to train a neural network, that can tell me, which age rating a screenshot (and therefore the corresponding game) likely has.\nIs this a problem, which is manageable by image recognition? \nI've looked into examples (mostly Keras tutorials) for image recognition and all of them deal with problems, which are distinctly visible (like \"does the image show a cat or a dog\"). Browsing through my dataset I realized, that some of the pictures are pretty similar, although belonging to different classes.\nCan a convolutional neural network (or any other type of image recognition algorithm) deal with classes, where the deciding factor is not directly visible? Is this just a problem of how deep the network is?\nI'd be very thankful, if someone could point me in the general direction on where to look for further information.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":54871092,"Users Score":1,"Answer":"It could and also could not. For a CNN to provide good results with no contextual input, it would mean there must be some for of correlation between the input and the output. So lets say some apps have designs that correlate with age-rating, then yes its possible, otherwise its not unless you give the network something more to work with.\nThis could actually set you up for a cool experiment to check yourself, run this through some run-of-the-mill CNN, and if it evaluates well (through cross-validation) then youve probably shown the correlation exists \n(Note: if the model does not test well, that is not evidence that correlation isnt there, probably isnt likely, but not gauranteed)","Q_Score":1,"Tags":"python,keras,image-recognition","A_Id":54871249,"CreationDate":"2019-02-25T16:55:00.000","Title":"Can Image Recognition deal with classes, where the deciding quality is not directly visible?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset in csv format which contains dates in a column. I have imported this dataset into python pandas, and this date column is shown as an object. I need to convert this column to date time but i have a problem. This date column has date format in two formats\n1. 11\/7\/2013  11:51\n2. 13-07-2013 08:33:16\nI need to convert one format to another one in order to have a standard date format in my python to do analysis. How can i do this?\nThere are many rows of date in both these formats, so when i try to convert second format to first format using the below code\n\nprint(df['date'].apply(lambda x: pd.to_datetime(x, format='%d\/%m\/%Y\n  %H:%M')))\n\ni get the below error\n\nValueError: time data '13-07-2013 08:33:16' does not match format\n  '%d\/%m\/%Y %H:%M' (match)\n\nso what would be the best method to standardise this column in one format?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":2154,"Q_Id":54871446,"Users Score":1,"Answer":"Try removing the format parameter and setting infer_datetime_format=Truein the arguments you pass to pd.to_datetime","Q_Score":1,"Tags":"python,pandas","A_Id":54871548,"CreationDate":"2019-02-25T17:17:00.000","Title":"How to standardise different date formats in pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a way to plot a density histogram with Plotly. As a density=True with a numpy histogram. My variable is a continuous one from 0 to 20. I already have a count on yaxis with bins. So I'm looking for replace theses counts by percentage (o density).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":207,"Q_Id":54872488,"Users Score":0,"Answer":"Try this:\ngo.Histogram(x=some_vec, histnorm=\"probability density\")","Q_Score":0,"Tags":"python,plotly","A_Id":68398101,"CreationDate":"2019-02-25T18:23:00.000","Title":"Plot a density histogram with Plotly","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While running pip install InstagramAPI im getting the following error.\n\n\"networkx 2.1 has requirement decorator>=4.1.0, but you'll have\n  decorator 4.0.11 which is incompatible\"\n\nSo I uninstalled decorator and reinstalled it using pip install decorator==4.1.0. I confirmed with pip list the version of decorator. I then tried to pip install InstagramApi I got the same error \n\n\"networkx 2.1 has requirement decorator>=4.1.0, but you'll have\n  decorator 4.0.11 which is incompatible.\"\n\nand my decorator module was regressed to version 4.0.11!!!\nSomeone please explain whats going on here. Thank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":54875301,"Users Score":0,"Answer":"Why don't you use a virtual python environment (the python package) It should take care of these Dependency problems.","Q_Score":0,"Tags":"python,instagram-api","A_Id":54875371,"CreationDate":"2019-02-25T21:57:00.000","Title":"InstagramAPi install error with decorator version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently I am working to learn how to use Gtk3 with Python 3.6. So far I have been able to use a combination of resources to piece together a project I am working on, some old 2.0 references, some 3.0 shallow reference guides, and using the python3 interpreters help function.\nHowever I am stuck at how I could customise the statusbar to display a progressbar. Would I have to modify the contents of the statusbar to add it to the end(so it shows up at the right side), or is it better to build my own statusbar?\nAlso how could I modify the progressbars color? Nothing in the materials list a method\/property for it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":217,"Q_Id":54875813,"Users Score":2,"Answer":"GtkStatusbar is a subclass of GtkBox. You can use any GtkBox method including pack_start and pack_end or even add, which is a method of GtkContainer. \nThus you can simply add you progressbar to statusbar.","Q_Score":0,"Tags":"python-3.x,progress-bar,gtk3,statusbar","A_Id":54889989,"CreationDate":"2019-02-25T22:42:00.000","Title":"Python Gtk3 - Custom Statusbar w\/ Progressbar","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I start my python code file foo.py from directory home\/a\/b\/.\nThe file foo.py is located at home\/x\/y\/k.\nInside the file foo.py what can be the way to get path home\/x\/y\/k.\nI have used the functions os.getcwd() and os.path.realpath(), they all return home\/a\/b.\nI will appreciate any help in the direction.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":118,"Q_Id":54877355,"Users Score":1,"Answer":"Use os.path.abspath(__file__) inside the foo.py file.\nThis way, you will always get the path of your foo.py, no matter from where you start the script.","Q_Score":0,"Tags":"python,filepath","A_Id":54877512,"CreationDate":"2019-02-26T01:55:00.000","Title":"How to determine path where the file is located?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Instead of creating many topics I'm creating a partition for each consumer and store data using a key. So is there a way to make a consumer in a consumer group read from partition that stores data of a specific key. If so can you suggest how it can done using kafka-python (or any other library).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":54878692,"Users Score":0,"Answer":"Instead of using the subscription and the related consumer group logic, you can use the \"assign\" logic (it's provided by the Kafka consumer Java client for example).\nWhile with subscription to a topic and being part of a consumer group, the partitions are automatically assigned to consumers and re-balanced when a new consumer joins or leaves, it's different using assign.\nWith assign, the consumer asks to be assigned to a specific partition. It's not part of any consumer group. It's also mean that you are in charge of handling rebalancing if a consumer dies: for example, if consumer 1 get assigned partition 1 but at some point it crashes, the partition 1 won't be reassigned automatically to another consumer. It's up to you writing and handling the logic for restarting the consumer (or another one) for getting messages from partition 1.","Q_Score":0,"Tags":"python,apache-kafka,kafka-consumer-api,kafka-python","A_Id":54879760,"CreationDate":"2019-02-26T04:59:00.000","Title":"Can a consumer read records from a partition that stores data of particular key value?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is auc better in handling imbalenced data. As in most of the cases if I am dealing with imbalenced data accuracy is not giving correct idea. Even though accuracy is high, model has poor perfomance. If it's not auc which is the best measure to handle imbalenced data.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1508,"Q_Id":54879340,"Users Score":1,"Answer":"Neither are good for imbalanced datasets. Use the area under the precision recall curve instead.","Q_Score":0,"Tags":"python,machine-learning,artificial-intelligence,roc,auc","A_Id":54880674,"CreationDate":"2019-02-26T06:07:00.000","Title":"Is AUC a better metric than accuracy in case of imbalenced datasets in machine learning,If not which is the best metric?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do apps like instagram, twitter etc. Know a user is logged on and when next the user starts the app, the user doesn't have to input their credentials all over. Is it by writing and reading from a file, if  yes, doesn't it mean a user can find the file that the app reads from, alter it's content and change who's logged on to someone else without authentication","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":54880003,"Users Score":0,"Answer":"Save their token in LocalStorage for web front-end, for other platform \nyou can save in somewhere that can storage.\nToken-Based api. (access with token with any resource)","Q_Score":0,"Tags":"python,session,kivy","A_Id":54880067,"CreationDate":"2019-02-26T07:01:00.000","Title":"How to keep a user logged 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'm having low fps for real-time object detection on my raspberry pi\nI trained the yolo-darkflow object detection on my own data set using my laptop windows 10 .. when I tested the model for real-time detection on my laptop with webcam it worked fine with high fps \nHowever when trying to test it on my raspberry pi, which runs on Raspbian OS, it gives very low fps rate that is about 0.3 , but when I only try to use the webcam without the yolo it works fine with fast frames.. also when I use Tensorflow API for object detection with webcam on pi it also works fine with high fps\ncan someone suggest me something please? is the reason related to the yolo models or opencv or phthon? how can I make the fps rate higher and faster for object detection with webcam?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1551,"Q_Id":54881654,"Users Score":0,"Answer":"The raspberry pi not have the GPU procesors and because of that is very hard for it to do image recognition at a high fps .","Q_Score":0,"Tags":"python,opencv,raspberry-pi,object-detection,yolo","A_Id":55558787,"CreationDate":"2019-02-26T08:57:00.000","Title":"how to increase fps for raspberry pi for object detection","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'm having low fps for real-time object detection on my raspberry pi\nI trained the yolo-darkflow object detection on my own data set using my laptop windows 10 .. when I tested the model for real-time detection on my laptop with webcam it worked fine with high fps \nHowever when trying to test it on my raspberry pi, which runs on Raspbian OS, it gives very low fps rate that is about 0.3 , but when I only try to use the webcam without the yolo it works fine with fast frames.. also when I use Tensorflow API for object detection with webcam on pi it also works fine with high fps\ncan someone suggest me something please? is the reason related to the yolo models or opencv or phthon? how can I make the fps rate higher and faster for object detection with webcam?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1551,"Q_Id":54881654,"Users Score":0,"Answer":"My detector on raspberry pi without any accelerator can reach 5 FPS.\nI used SSD mobilenet, and quantize it after training.\nTensorflow Lite supplies a object detection demo can reach about 8 FPS on raspberry pi 4.","Q_Score":0,"Tags":"python,opencv,raspberry-pi,object-detection,yolo","A_Id":66489611,"CreationDate":"2019-02-26T08:57:00.000","Title":"how to increase fps for raspberry pi for object detection","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 running  Eclipse Che v6.18.1 in Google Chrome on MacBook Pro OS v10.10.5 (Yosemite). Eclipse Che workspace runs in a Docker container.\nHow can I open a new browser tab (in the same browser window as Eclipse Che) from within a Python code executed in Eclipse Che? \nSo not a new Google Chrome instance from within a Docker container (much too slow) but a new tab in already existing browser window on the host machine.\nIn Eclipse Che it is possible to preview an HTML file in the project Workspace (right-click => Preview). Then the HTML file opens in the next tab to the Eclipse Che IDE. How could I use that feature from within a Python code to open a new browser tab?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":569,"Q_Id":54882713,"Users Score":0,"Answer":"Are you trying to open a preview window similar to the sample nodejs Yeoman application? Or are you trying to open a new tab from the source code in someone's browser?\nIf it's the latter, then I do not think it is possible (or a good idea!) - Che does not run in a security context that will allow it to instruct the browser to open a new tab or window.","Q_Score":1,"Tags":"python,eclipse-che,codenvy","A_Id":55222067,"CreationDate":"2019-02-26T09:52:00.000","Title":"How can I open a new browser tab from Python in Eclipse Che?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to compile PJSUA2 for Python. I could manage to compile the source with Visual Studio 2015 Community edition. \nMy question is, how can I install the Python module now? \nThe guide suggests to use make and make install. I tried to install also minwg, but it is not working as the project was compiled with VS. \n\nI have also tried to compile with minwg, but I never could succeed due to undefined requirements. Also official PJSUA guide recommend to use VS for Windows.\n\nFollowing settings have been applied to build from source:\n\nSwig location has been added to path\nJAVA_home system variable has been added\nJava location has been added to path\nEmpty pjlib\/include\/pj\/config_site.h has been created\nOpened source in VS 2015 Community (all suggested VS package and module has been installed)\nSet following project to do not compile:\n\n\npjsua_cli_uwp_comp\npjsua_cli_wp8\npjsua_cli_wp8_comp\n\nSet swig_java_pjsua2 to build.\nAdd following folders to swig_java_pjsua2 VC++ include directories\n\n\nc:\\Program Files\\Java\\jdk-11.0.2\\include\nc:\\Program Files\\Java\\jdk-11.0.2\\include\\win32\n\nBuild solution","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2011,"Q_Id":54882875,"Users Score":0,"Answer":"Thank You very much Krisz for this awesome work!\n\nI just got it working for Python 2.7 \/ 32bit and some things are slightly different, so I will add them here:\nEnvironment:\n\nWindows 10\nSWIG 4.0.1\nPJSIP 2.9\nPython 2.7.14 (32bit)\nVisual Studio Express 2015  (V 14.0.25431.01 Update 3)\n\nWhaddado:\n\nImportant: Check if your Python-interpreter is really x64 or win32 like the following:\nstart a python session and enter:\n\nimport platform\nplatform.architecture()\n\nIf you have 32bit, consider this in your choice for target platform in VS.\nwhen you add this %inline%-Snippet to pjsip-apps\/src\/swig\/pjsua2.i, add it at the end of the file!\nwhen starting the swig-command, omit the \"-py3\"-parameter, if you use Python 2.x\nthere is a little typo in Krisz' description, at \"pjsua.py located under pjsip-apps\/src\/swig\/python\" -> of course pjsua2.py is meant. Do not use the pjsua.py.\n\nfinally copy _pjsua2.lib and pjsua2.py into \\Lib\\site-packages\\ and the _pjsua2.pyd into \\DLLs\\ to make them available everywhere.","Q_Score":4,"Tags":"python,sip,voip,pjsua2","A_Id":59667572,"CreationDate":"2019-02-26T10:01:00.000","Title":"How to build PJSUA2 (swig) with Visual Studio 2015","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Debugger is active!\nDebugger PIN: 620-122-212\n\nI see this when I run the flask app and i'm trying to understand where it will get used?\nPlease let me know!","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":21618,"Q_Id":54883379,"Users Score":21,"Answer":"This is an additional security measure provided by Werkzeug (which is one of the dependencies for Flask) to prevent the debugger from being accessible without the knowledge of the PIN. You can use the debugger pin in the browser to launch the interactive debugger.\nPlease note you should never be using DEBUG mode in Production anyways because the stack trace of error can potentially reveal multiple aspects of your code.\nThe Debugger PIN is a just an added layer of security in case you inadvertently leave the Debug mode on in an Production application to make it difficult for the attacker to access the debugger .","Q_Score":24,"Tags":"python,flask","A_Id":54883878,"CreationDate":"2019-02-26T10:29:00.000","Title":"What is Debugger PIN when I run the flask app python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm currently working with Python3 on Jupyter Notebook. I try to load a text file which is in the exact same directory as my python notebook but it still doesn't find it. My line of code is:\ntext_data = prepare_text('train.txt')\nand the error is a typical\nFileNotFoundError: [Errno 2] No such file or directory: 'train.txt'\nI've already tried to enter the full path to my text file but then I still get the same error.  \nDoes anyone know how to solve this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3104,"Q_Id":54883612,"Users Score":1,"Answer":"I found the answer. Windows put a secont .txt at the end of the file name, so I should have used train.txt.txt instead.","Q_Score":0,"Tags":"python,file,jupyter-notebook","A_Id":54885096,"CreationDate":"2019-02-26T10:41:00.000","Title":"Python3: FileNotFoundError: [Errno 2] No such file or directory: 'train.txt', even with complete path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a WPF application wich embedded IronPython. I'm trying to access my WPF page from Python so I can modify controls defined in XAML from Python but can't manage to do it. I'm using a NavigationWindow to transition from page to page, so I'd like to be able to access the current page pointed to by the NavigationWindow.\nI'm capable of accessing controls from a separate Window via Application.Current.MainWindow, but have had no success trying to access a page in the way described above.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":54884303,"Users Score":0,"Answer":"Navigation window is a content control, if you want to get the page from it you can just use the .content property on the navigation window instance. Or just use the content property from the NavigationEventArgs within the onNavigated function.","Q_Score":0,"Tags":"c#,.net,wpf,ironpython","A_Id":54885560,"CreationDate":"2019-02-26T11:17:00.000","Title":"How to get WPF Page pointed by NavigationWindow from code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When using the SignedCookieSessionFactory, the documentation states that the sha512 HMAC digest algorithm is used. As a result of this, once session data is serialised, it is signed and sent to the user's client under the session cookie.\nThere is no mention in Pyramid's documentation that sessions are also cached server-side (under this SessionFactory).\nThis presents a contradiction and has also led to authentication confusion when paired with SessionAuthenticationPolicy. If session data cannot be retrieved from the client's session cookie (as it is one-way hashed), how is it that the following is possible?\n\nAuthenticate with the application such that reading Request.authenticated_userid does not return None.\nCopy the session cookie to the clipboard.\nLogout by accessing a view whereby the headers from forget(request) are returned in the Response.\nReplace the session cookie with the copied value.\nThe user is now logged back in.\n\nI understand that simply deleting the cookie client-side is insufficient to completely invalidate the session (without blacklisting), but this then poses the following questions:\n\nHow is it possible to remain secure with browser-scoped sessions unless every session cookie the user has recently been issued is somehow remembered and blacklisted\/invalidated?\nIs the session cookie actually a key\/session ID that's being used to lookup a session in memory? As it's one-way signed, surely this is the only explanation?\nIs it possible then to invalidate sessions server-side, a little more robust than just the headers=forget(request) pattern?\n\nUltimately, I imagine the answer is something along the lines of:\n\"Maintain server-side sessions using an include such as pyramid_redis_sessions\"\nAny explanation would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":146,"Q_Id":54887668,"Users Score":3,"Answer":"The cookie contains all of the data. The session content itself is stored in the cookie, alongside an hmac signature of that content. This means that a client may view the content if they try hard enough, but they cannot change it as they cannot create trusted signatures without the server-side secret.\n\nHow is it possible to remain secure with browser-scoped sessions unless every session cookie the user has recently been issued is somehow remembered and blacklisted\/invalidated?\n\nIt depends what you're using the session for - you need to take these issues into consideration before putting data into a session object.\n\nIs it possible then to invalidate sessions server-side, a little more robust than just the headers=forget(request) pattern?\n\nNot unless you store some sort of id in the session and then a server-side table of blacklisted ids. If you did this then you could write your own wrapper session-factory that opened the session, checked the id, and returned an empty one if it was blacklisted. Of course then you might just want to use a server-side session library like pyramid_redis_sessions or pyramid_beaker with one of its server-side-storage backends.","Q_Score":4,"Tags":"python,python-3.x,pyramid","A_Id":54893292,"CreationDate":"2019-02-26T14:23:00.000","Title":"If Pyramid sessions are one-way hashed and not stored server-side, where is the data coming from?","Data Science and Machine Learning":0,"Database and SQL":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 trying to merge two PDFs using PyPDF2.  Sometimes I run into the following error:\n[WinError 32] The process cannot access the file because it is being used by another process:\nHow can I determine which process is using the file?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":54888188,"Users Score":0,"Answer":"You might have already tried this, but try to find the handle or the DLL ; a dialogue box will open and allow you to search for the missing file. If you want to open a file in Python, search up a file handling cheat-sheet. It doesn't require any importing of modules, just the Open() function. Glad to help if i did","Q_Score":1,"Tags":"python,windows,filesystems","A_Id":54888544,"CreationDate":"2019-02-26T14:51:00.000","Title":"How to determine which process is using a file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I found a major problem in a nice pypi-package. I forked it on github and fixed the bug. \nProblem: The project seems to be not maintained anymore and the author is not replying to my pull request.\nI want to put the project to pypi but then some questions occurred to me:\n1) You have to write the author and source url of the project. How do I deal with this? I'm not the author, just from the changes. I don't want to take away credit from the original guy.\n2) The fork has old tags\/version numbers. How to I start at version 1.0.0 again?\nThanks!\nRon","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":276,"Q_Id":54888750,"Users Score":2,"Answer":"Ok, after talking to some really experienced guys, this is what they'd do:\n\nTry reach maintainers via github\nTry to find out their email address (maybe via git-commit) and ask what's going on\nIf they don't want to maintain it anymore, ask for maintainership\nIf you don't get any reply, the last and not nice solution would be that you create a new package and start on top of the versioning of the original package. Meaning the current state is at 1.10.4 and you fix a bug, your new packages first version would be 1.10.5\n\nHope this helps.","Q_Score":4,"Tags":"python,pypi","A_Id":55686065,"CreationDate":"2019-02-26T15:19:00.000","Title":"Create pypi package for fork of non-maintained project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to remove one of the buttons from the \"run toolbar\" because I keep pressing it accidently.  Is this possible?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":633,"Q_Id":54889696,"Users Score":1,"Answer":"(Spyder maintainer here) Sorry, there's no way to customize our toolbars at the moment and we don't have plans to allow that in the future.","Q_Score":0,"Tags":"python,anaconda,spyder","A_Id":54902259,"CreationDate":"2019-02-26T16:09:00.000","Title":"How to customize toolbar icons in Spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset of 27 files, each containing opcodes. I want to use stemming to map all versions of similar opcodes into the same opcode. For example: push, pusha, pushb, etc would all be mapped to push.\nMy dictionary contains 27 keys and each key has a list of opcodes as a value. Since the values contain opcodes and not normal english words, I cannot use the regular stemmer module. I need to write my own stemmer code. Also I cannot hard-code a custom dictionary that maps different versions of the opcodes to the root opcode because I have a huge dataset. \nI think regex expression would be a good idea but I do not know how to use it. Can anyone help me with this or any other idea to write my own stemmer code?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":212,"Q_Id":54890373,"Users Score":0,"Answer":"I would recommend looking at the levenshtein distance metric - it measures the distance between two words in terms of character insertions, deletions, and replacements (so push and pusha would be distance 1 apart if you do the ~most normal thing of weighing insertions = deletions = replacements = 1 each). Based on the example you wrote, you could try just setting up categories that are all distance 1 from each other. However, I don't know if all of your equivalent opcodes will be so similar - if they're not leven might not work.","Q_Score":1,"Tags":"python,regex,nlp,nltk,stemming","A_Id":54891820,"CreationDate":"2019-02-26T16:48:00.000","Title":"Write own stemmer for stemming","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am stuck at a problem using OpenVINO. I am trying to run the facenet after converting model using OpenVINO toolkit but I am unable to use .npy and .pickle for complete face recognition. I am successful in converting .pb file to .bin and .xml file using OpenVino toolkit.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":636,"Q_Id":54891713,"Users Score":0,"Answer":"You can use Python APIs to integrate OV inference into your Python application. Please see inference_engine\/samples\/python_samples folder for existing Python samples.","Q_Score":0,"Tags":"python,tensorflow,openvino","A_Id":55735532,"CreationDate":"2019-02-26T18:14:00.000","Title":"Running Facenet using OpenVINO","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am stuck at a problem using OpenVINO. I am trying to run the facenet after converting model using OpenVINO toolkit but I am unable to use .npy and .pickle for complete face recognition. I am successful in converting .pb file to .bin and .xml file using OpenVino toolkit.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":636,"Q_Id":54891713,"Users Score":0,"Answer":"openvino converts the model to intermediate representation, which is compatible across multiple hardwares. It can improve the performance of your model too. Since you have already mentioned that yopu were ableto convert your model to IR format, the next phase is inference for which you can use the .xml and .bin files.\nCan you please state what exactly do you intend to carryout with .npy or .pickle files?","Q_Score":0,"Tags":"python,tensorflow,openvino","A_Id":55158313,"CreationDate":"2019-02-26T18:14:00.000","Title":"Running Facenet using OpenVINO","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am able to parse from file using this method: \nfor event, elem in ET.iterparse(file_path, events=(\"start\", \"end\")):\nBut, how can I do the same with fromstring function?  Instead of from file, xml content is stored in a variable now.  But, I still want to have the events as before.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":319,"Q_Id":54891949,"Users Score":0,"Answer":"From the documentation for the iterparse method:\n\n...Parses an XML section into an element tree incrementally, and\n  reports what\u2019s going on to the user. source is a filename or file\n  object containing XML data...\n\nI've never used the etree python module, but \"or file object\" says to me that this method accepts an open file-like object as well as a file name.  It's an easy thing to construct a file-like object around a string to pass as input to a method like this.\nTake a look at the StringIO module.","Q_Score":2,"Tags":"python","A_Id":54892048,"CreationDate":"2019-02-26T18:30:00.000","Title":"Elementree Fromstring and iterparse in Python 3.x","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to find the largest subset sum of a particular data set, where the average of a field in the data set matches predetermined criteria.\nFor example, say I have a people's weights (example below) and my goal is to find the largest weight total where the average weight of the resulting group is between 200 and 201 pounds.\n\n210\n201\n190\n220\n188\n\nUsing the above, the largest sum of weights where the average weight is between 200 and 201 pounds is from persons 1, 2, and 3. The sum of their weights is 601, and the average weight between them is 200.3. \nIs there a way to program something to do the above, other than brute force, preferably using python? I'm not even sure where to start researching this so any help or guidance is appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":54894635,"Users Score":1,"Answer":"Start by translating the desired range to 0, just for convenience.  I'll translate to the lower bound, although the midpoint is also a good choice.\nThis makes your data set [10, 1, -10, 20, -12].  The set sum is 9; you need it to be in the range 0 to upper_bound * len(data).\nThis gives you a tractable variation of the \"target sum\" problem: find a subset of the list that satisfies the sum constraint.  In this case, you have two solutions: [10, 1, -10] and [10, 1, -12].  You can find this by enhancing the customary target-sum problems to include the changing sum: the \"remaining amount\" will include the change from the mean calculation.\nCan you finish from there?","Q_Score":1,"Tags":"python,optimization,weighted-average","A_Id":54894944,"CreationDate":"2019-02-26T21:46:00.000","Title":"Finding Largest Subset of Data where Average Matches Criteria","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm learning tensorflow, and the tf.data API confuses me. It is apparently better when dealing with large datasets, but when using the dataset, it has to be converted back into a tensor. But why not just use a tensor in the first place? Why and when should we use tf.data?\nWhy isn't it possible to have tf.data return the entire dataset, instead of processing it through a for loop? When just minimizing a function of the dataset (using something like tf.losses.mean_squared_error), I usually input the data through a tensor or a numpy array, and I don't know how to input data through a for loop. How would I do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1075,"Q_Id":54894799,"Users Score":3,"Answer":"The tf.data module has specific tools which help in building a input pipeline for your ML model. A input pipeline takes in the raw data, processes it and then feeds it to the model.\n\n\nWhen should I use tf.data module?\n\nThe tf.data module is useful when you have a large dataset in the form of a file such as .csv or .tfrecord. tf.data.Dataset can perform shuffling and batching of samples efficiently. Useful for large datasets as well as small datasets. It could combine train and test datasets.\n\nHow can I create batches and iterate through them for training?\n\nI think you can efficiently do this with NumPy and np.reshape method. Pandas can read data files for you. Then, you just need a for ... in ... loop to get each batch amd pass it to your model.\n\nHow can I feed NumPy data to a TensorFlow model?\n\nThere are two options to use tf.placeholder() or tf.data.Dataset.\n\nThe tf.data.Dataset is a much easier implementation. I recommend to use it. Also, has some good set of methods.\nThe tf.placeholder creates a placeholder tensor which feeds the data to a TensorFlow graph. This process would consume more time feeding in the data.","Q_Score":3,"Tags":"python,numpy,tensorflow,machine-learning","A_Id":54897167,"CreationDate":"2019-02-26T21:57:00.000","Title":"Why should I use tf.data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right now I'm using virtualenv and just switching over to Pipenv. Today in virtualenv I load in different environment variables and settings depending on whether I'm in development, production, or testingby setting DJANGO_SETTINGS_MODULE to myproject.settings.development, myproject.settings.production, and myproject.settings.testing. \nI'm aware that I can set an .env file, but how can I have multiple versions of that .env file?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5010,"Q_Id":54896106,"Users Score":4,"Answer":"You should create different .env files with different prefixes depending on the environment, such as production.env or testing.env.  With pipenv, you can use the PIPENV_DONT_LOAD_ENV=1 environment variable to prevent pipenv shell from automatically exporting the .env file and combine this with export $(cat .env | xargs).\nexport $(cat production.env | xargs) && PIPENV_DONT_LOAD_ENV=1 pipenv shell would configure your environment variables for production and then start a shell in the virtual environment.","Q_Score":12,"Tags":"python,virtualenv,pipenv","A_Id":54896172,"CreationDate":"2019-02-27T00:06:00.000","Title":"Pipenv: Multiple Environments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I found an error like this is \n'Warning: line 1: Node 'BLABLABLA.instObjGroups[0]': cannot make assignment to 'BLABLABLAB_SG' shader.\n'\nI've searched various forums, but haven't found a solution. maybe someone can help me cause the error and how to overcome it.\nthank you very much for help: D","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":278,"Q_Id":54897608,"Users Score":0,"Answer":"i came on this error recently because I wasn't use the command cmds.shadingNode('blinn' ,as=True) instead of just cmds.createNode","Q_Score":0,"Tags":"python,render,maya","A_Id":54916924,"CreationDate":"2019-02-27T03:33:00.000","Title":"warning in maya: 'cannot make assignment', why?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing an application in PyQt5 which will be used for calibration and test of a product. The important details:\n\nThe product under test uses an old-school UART\/serial communication link at 9600 baud.\n...and the test \/ calibration operation involves communicating with another device which has a UART\/serial communication link at 300 baud(!)\nIn both cases, the communication protocol is ASCII text with messages terminated by a newline \\r\\n.\n\nDuring the test\/calibration cycle the GUI needs to communicate with the devices, take readings, and log those readings to various boxes in the screen. The trouble is, with the slow UART communications (and the long time-outs if there is a comms drop-out) how do I keep the GUI responsive?\nThe Minimally Acceptable solution (already working) is to create a GUI which communicates over the serial port, but the user interface becomes decidedly sluggish and herky-jerky while the GUI is waiting for calls to serial.read() to either complete or time out.\nThe Desired solution is a GUI which has a nice smooth responsive feel to it, even while it is transmitting and receiving serial data.\nThe Stretch Goal solution is a GUI which will log every single character of the serial communications to a text display used for debugging, while still providing some nice \"message-level\" abstraction for the actual logic of the application.\nMy present \"minimally acceptable\" implementation uses a state machine where I run a series of short functions, typically including the serial.write() and serial.read() commands, with pauses to allow the GUI to update. But the state machine makes the GUI logic somewhat tricky to follow; the code would be much easier to understand if the program flow for communicating to the device was written in a simple linear fashion.\nI'm really hesitant to sprinkle a bunch of processEvents() calls throughout the code. And even those don't help when waiting for serial.read(). So the correct solution probably involves threading, signals, and slots, but I'm guessing that \"threading\" has the same two Golden Rules as \"optimization\": Rule 1: Don't do it. Rule 2 (experts only): Don't do it yet.\nAre there any existing architectures or design patterns to use as a starting point for this type of application?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":397,"Q_Id":54898967,"Users Score":0,"Answer":"Okay for the past few days I've been digging, and figured out how to do this. Since there haven't been any responses, and I do think this question could apply to others, I'll go ahead and post my solution. Briefly:\n\nYes, the best way to solve this is with with PyQt Threads, and using Signals and Slots to communicate between the threads.\nFor basic function (the \"Desired\" solution above) just follow the existing basic design pattern for PyQt multithreaded GUI applications:\n\n\nA GUI thread whose only job is to display data and relay user inputs \/ commands, and,\nA worker thread that does everything else (in this case, including the serial comms).\n\nOne stumbling point along the way: I'd have loved to write the worker thread as one linear flow of code, but unfortunately that's not possible because the worker thread needs to get info from the GUI at times.\n\n\nThe only way to get data back and forth between the two threads is via Signals and Slots, and the Slots (i.e. the receiving end) must be a callable, so there was no way for me to implement some type of getdata() operation in the middle of a function. Instead, the worker thread had to be constructed as a bunch of individual functions, each one of which gets kicked off after it receives the appropriate Signal from the GUI.\n\nGetting the serial data monitoring function (the \"Stretch Goal\" above) was actually pretty easy -- just have the low-level serial transmit and receive routines already in my code emit Signals for that data, and the GUI thread receives and logs those Signals.\n\nAll in all it ended up being a pretty straightforward application of existing principles, but I'm writing it down so hopefully the next guy doesn't have to go down so many blind alleys like I did along the way.","Q_Score":0,"Tags":"python,pyqt5","A_Id":54964121,"CreationDate":"2019-02-27T05:59:00.000","Title":"How to architect a GUI application with UART comms which stays responsive to the user","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":1,"Web Development":0},{"Question":"I'm new to django, I want to register users using different tables for different users like students, teaching staff, non teaching staff, 3 tables.\nHow can i do it instead of using default auth_users table for registration","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":54906708,"Users Score":0,"Answer":"cf Sam's answer for the proper solutions from a technical POV.  From a design POV, \"student\", \"teaching staff\" etc are not entities but different roles a user can have. \nOne curious things with living persons and real-life things in general is that they tend to evolve over time without any respect for our well-defined specifications and classifications - for example it's not uncommon for a student to also have teaching duties at some points, for a teacher to also be studying some other topic, or for a teacher to stop teaching and switch to more administrative tasks. If you design your model with distinct entities instead of one single entitie and distinct roles, it won't properly accomodate those kind of situations (and no, having one account as student and one as teacher is not a proper solution either). \nThat's why the default user model in Django is based on one single entity (the User model) and features allowing roles definitions (groups and permissions) in such a way that one user can have many roles, whether at the same time or in succession.","Q_Score":1,"Tags":"python,django","A_Id":54907387,"CreationDate":"2019-02-27T13:33:00.000","Title":"how to register users of different kinds using different tables in django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm new to django, I want to register users using different tables for different users like students, teaching staff, non teaching staff, 3 tables.\nHow can i do it instead of using default auth_users table for registration","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":54906708,"Users Score":0,"Answer":"In Django authentication, there is Group model available which have many to many relationship with User model. You can add students, teaching staff and non teaching staff to Group model for separating users by their type.","Q_Score":1,"Tags":"python,django","A_Id":54906887,"CreationDate":"2019-02-27T13:33:00.000","Title":"how to register users of different kinds using different tables in django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This may seem like an odd question but I'm new to this so thought I'd ask anyway.\nI want to use this Google News model over various different files on my laptop. This means I will be running this line over and over again in different Jupyter notebooks: \nmodel=word2vec.KeyedVectors.load_word2vec_format(\"GoogleNews-vectors-negative300.bin\",binary=True)\nDoes this eat 1) Storage (I've noticed my storage filling up exponentially for no reason) \n2) Less memory than it would otherwise if I close the previous notebook before running the next.\nMy storage has gone down by 50GB in one day and the only thing I have done on this computer is run the Google News model (I didn't do most_similar()). Restarting and closing notebooks hasn't helped and there aren't any big files on the laptop. Any ideas?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":149,"Q_Id":54911712,"Users Score":1,"Answer":"Just loading a model won't usually use any more disk storage. (An exception: if load or use needs addressable memory beyond your RAM, you may start using virtual memory, which might show up as less disk space depending on your OS. But, with these sorts of models, you want to avoid relying on any virtual memory, as basic most_similar() operations cycle through the full model, & will be very slow if they're reading from disk each time.) \nLoading the model will use memory, then more when 1st doing most_similar(). (That requires unit-normalized vectors, which are calculated the 1st time needed then cached.) \nBut terminating a notebook should free that memory. (Note that closing a tab may not cleanly terminate a Jupyter notebook. If the notebook is still running at the notebook server, even with no browsers viewing it, it will still use\/hold memory.)","Q_Score":0,"Tags":"python,nlp,gensim,word2vec,word-embedding","A_Id":54920367,"CreationDate":"2019-02-27T17:56:00.000","Title":"Does the Google News Word2Vec model take up storage every time you run it?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am automating our mobile app on iOS and Android. When I get the search results(list of elements), I want to iterate through those all elements matching my xpath.\nThe problem is that - Appium returns only those elements which are visible in the viewport, which makes sense. However, I would like to get all elements matching my xpath\/locator strategy, although the elements are not in viewport. To get further set of elements, I have to scroll to those elements and get them into viewport.\nIs there any configuration provided by appium, to enable this feature? Or will I have to continue scrolling to those elements before accessing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":54912357,"Users Score":0,"Answer":"You need to handle scrolling on your own.\nOn Android, Appium can make a snapshot of what is currently in the viewport.\nYou can get a list of elements and iterate them, then scroll by screen hight and get another list of elements, iterate them. Repeat it until the new list is empty - make sure you don't get same elements twice.\nOn iOS, it's more tricky: the driver will return you elements including the ones not in the viewport. For reliable interaction, I suggest scrolling to each element.","Q_Score":0,"Tags":"python-2.7,appium","A_Id":54922735,"CreationDate":"2019-02-27T18:36:00.000","Title":"How to get all items matching xpath, which are not in viewport?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am sending data to sql server and the data absolutly perfect , but all of sudden i was encountered with following error , can any one please suggestes me whats the problem is:\nERROR\n\n\"Column must be constructed with a non-blank name or \"\nArgumentError: Column must be constructed with a non-blank name or assign a non-blank .name before adding to a Table.\n\nI am currently using:\nServer: SQL 2012","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":211,"Q_Id":54912698,"Users Score":0,"Answer":"The column that you are trying to send data to cannot contain NULL values is what I am assuming. However if you check the column in your dataframe that you are sending to your MySQL server I bet that there are NULL or empty values within that column. \nYou need to make sure that if your column in your MySQL server cannot contain null values, the dataframe column that you are sending to the server cannot have null values also. You will need to insert a value into the dataframe for every null value in that column for the MySQL server to accept the data, or change your database design to allow null values in that column. \nThat would explain why it was working and why it stopped working. It worked because the server was not receiving NULL values but broke the second you tried to send it a NULL value into the database.","Q_Score":1,"Tags":"python,sql-server","A_Id":54912810,"CreationDate":"2019-02-27T19:01:00.000","Title":"Sending data by using python to sql server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering, what's the difference between importing keras from tensorflow using import tensorflow.keras or just pip installing keras alone and importing it using import keras as both seemed to work nicely so far, the only difference I noticed is that i get Using TensorFlow backend. in the command line every time I execute the one using keras.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1437,"Q_Id":54913830,"Users Score":12,"Answer":"Tensorflow.keras is an version of Keras API implemented specifically for use with Tensorflow. It is a part of Tensorflow repo and from TF version 2.0 will become main high level API replacing tf.layers and slim. \nThe only reason to use standalone keras is to maintain framework-agnostic code, i.e. use it with another backend.","Q_Score":4,"Tags":"python-3.x,tensorflow,keras","A_Id":54914559,"CreationDate":"2019-02-27T20:19:00.000","Title":"what's the difference between \"import keras\" and \"import tensorflow.keras\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been given a simple file-conversion task: whenever an MP4 file is in a certain directory, I do some magic to it and move it to a different directory. Nice and straightforward, and easy to automate.\nHowever, if a user is copying some huge file into the directory, I worry that my script might catch it mid-copy, and only have half of the file to work with.\nIs there a way, using Python 3 on Windows, to check whether a file is done copying (in other words, no process is currently writing to it)?\nEDIT: To clarify, I have no idea how the files are getting there: my script just needs to watch a shared network folder and process files that are put there. They might be copied from a local folder I don't have access to, or placed through SCP, or downloaded from the web; all I know is the destination.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":715,"Q_Id":54917025,"Users Score":0,"Answer":"you could try first comparing the size of the file initially, or alternatively see if there are new files in the folder, capture the name of the new file and see if its size increases in x time, if you have a script, you could show the code....","Q_Score":0,"Tags":"python,windows,file,copy","A_Id":54917942,"CreationDate":"2019-02-28T01:29:00.000","Title":"How do I know if a file has finished copying?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I just have a graph.pbtxt file. I want to view the graph in tensorboard. But I am not aware of how to do that. Do I have to write any python script or can I do it from the terminal itself? Kindly help me to know the steps involved.","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":5032,"Q_Id":54917785,"Users Score":5,"Answer":"Open tensorboard and use the \"Upload\" button on the left to upload the pbtxt file will directly open the graph in tensorboard.","Q_Score":5,"Tags":"python,tensorflow,tensorboard","A_Id":60148794,"CreationDate":"2019-02-28T03:04:00.000","Title":"Viewing Graph from saved .pbtxt file on Tensorboard","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 10 different IP cameras that I need to access in a FLASK server.\nI would like to know the best way to do that.\nCurrently, I have a dictionary that uses an ID to map to a VideoCapture object. A client sends the cam ID to the server and the server accesses the video capture object and returns a captured frame via the read function.\nSo technically I have 10 different objects of VideoCapture. Another method that I have used is, that upon getting camera ID, if the current cam ID is different from the received cam ID, then the video cap object is replaced with a new one.\nMy question is that is opening 10 video captures at one time fine? My server should be time sensitive. Does opening 10 captures congest the network? If yes then should I stick to the one object approach that always creates a new object on ID change or is there any better way to do this? Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1328,"Q_Id":54919482,"Users Score":1,"Answer":"The first way you used is OK. For every camera, you should keep one capture object. It will work faster than replacing one capture object with multiple connections. If you open RTSP connection, then it will not congest the network until you start reading frames. So you can go with the first way.\nOpening and then releasing one capture object for multiple connections will slow down the speed because in every new connection it needs time to access the camera.","Q_Score":1,"Tags":"python,opencv","A_Id":54919941,"CreationDate":"2019-02-28T06:13:00.000","Title":"OpenCV Capturing multiple RTSP Streams - Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried looking in documentation and such, but not able to find a way to scroll down to bottom of page while using pyppeteer library with python3. \nWould be great if anyone could point me to the right direction or solution.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1061,"Q_Id":54919761,"Users Score":0,"Answer":"I was able to resolve this by doing something like this. \nawait page.hover(\".class name\")\nThanks everyone","Q_Score":0,"Tags":"python-3.x,puppeteer,pyppeteer","A_Id":54921731,"CreationDate":"2019-02-28T06:34:00.000","Title":"Is there a way to scroll to end of page in pyppeteer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My Spyne server WSDL shows \n<soap:address location=\"http:\/\/some-domain.com>\nI want it to show https instead of http.\nBasically, <soap:address location=\"https:\/\/some-domain.com>\nNotice the difference lies in http and https.\nHow do I tell my Spyne server to address this?\nHave gone through the docs multiple times but could not figure it out.\nThanks!","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":274,"Q_Id":54920093,"Users Score":-1,"Answer":"WSDL url is constructed from the first request.\nUpon starting the server, request the wsdl from the secure domain and it should work.","Q_Score":0,"Tags":"python,soap,https,spyne","A_Id":54932502,"CreationDate":"2019-02-28T07:00:00.000","Title":"Spyne SOAP server WSDL file cannot show https","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So i have a python script that automate some checks and send a mail when finished.\nI start the script with windows scheduler every night.\nI want to log if the script ran from the scheduler or if someone ran it manualy from an IDE(PyCharm for my case)\nIs there any os method that returns how a script ran or something else maybe?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":54921887,"Users Score":4,"Answer":"while scheduling from windows scheduler you can send a command line argument, then check it in your code if it is started with specified command line argument then it is run from windows scheduler.","Q_Score":3,"Tags":"python,python-3.x,scheduler","A_Id":54922097,"CreationDate":"2019-02-28T09:04:00.000","Title":"Can my python script know if it started manualy from IDE or automatically from scheduler?","Data Science and Machine Learning":0,"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 where I have to use the Python libraries I created on my machine, in the cloud, such that whenever any new dataset is loaded, this Python library have to start acting on it.\nHow can I do this? Where will I put the dataset and the python codes in Azure?\nThanks,\nShyam","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":54922056,"Users Score":1,"Answer":"There are more possibility to do that.\n\nRun your Python code on Azure Web Apps for Containers\u2014a Linux-based, managed application platform\nAzure Functions allows running Python code in a serverless environment that scales on-demand.\nUse a managed Hadoop and Spark cluster with Azure HDInsights, suitable for enterprise-grade production workloads.\nUse a friction-free data science environment that contains popular tools for data exploration, modeling, and development activities.\nAzure Kubernetes Service (AKS) offers a fully-managed Kubernetes cluster to run your Python apps and services, as well as any other Docker container. Easily integrate with other Azure services using Open Service Broker for Azure.\nUse your favorite Linux distribution, such as Ubuntu, CentOS, and Debian, or Windows Server. Run your code with scalable Azure Virtual Machines and Virtual Machine Scale Sets.\nRun your own Python data science experiments using a fully-managed Jupyter notebook with Azure Notebooks.\n\nThe easiest and fastest way to run your code is 1. option. Create a web app and a web job in there.","Q_Score":0,"Tags":"python,azure","A_Id":54922252,"CreationDate":"2019-02-28T09:14:00.000","Title":"Python libraries in Azure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have created a Python program which takes 3 to 4 hours to complete its execution when I run it interactively.\nIs there any way to run this program in Batch(Background) ?... i.e. Even when I shutdown my machine it will run as expected.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":133,"Q_Id":54923095,"Users Score":1,"Answer":"You can use windows task scheduler, simply set up time trigger or a startup trigger and the action should be your python file.","Q_Score":0,"Tags":"python","A_Id":54923195,"CreationDate":"2019-02-28T10:08:00.000","Title":"How can we create Python program which will run even after system shutdown","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have developed a Tensorflow based machine learning model on local Machine. And I want to deploy it in Google Cloud Platform (Cloud ML Engine) for predictions.\nThe model reads input data from Google Bigquery and the output predictions has to be written in Google Bigquery only. \nThere are some data preparation scripts which has to be run before the model prediction is run. I have used Google Cloud Storage for model storage and used it for deployment, i have deployed it successfully. \nBut, instead of using Google Cloud Storage for saving a model (i.e. .pb or .pkl model file) can i store it on GCP VM (Or Local machine) and call it from Cloud ML Engine for prediction? Is it possible? or I have only a option to upload Model directory to a Cloud Storage bucket which i will use it for prediction?\nCould you please help me on this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":147,"Q_Id":54923211,"Users Score":0,"Answer":"For model deployment you need a Google Cloud Storage using AI Platform.\nAnother option is to use AI platform training (local or in GCP), output the model (SavedModel format) to a local folder or Cloud Storage and from there using TF Serving in Compute Engine Instance.","Q_Score":2,"Tags":"python,google-cloud-ml","A_Id":56553227,"CreationDate":"2019-02-28T10:14:00.000","Title":"Model Deployment On GCP Without Cloud Storage Bucket","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"i am currently forced in an project to work with jupyter notebook, before I just used PyCharm. \nSo I create a project and would like to add some classes to it. Should I write all of them in the one main notebook or create different notebooks for each class? \nAs far as I understand, jupyter is not made for using several notebooks for one project (but I thnink there are options) but if I want to use some of my classes more general for other projects it does not make sense to not have it in a seperate notebook right?\nI am sorry, maybe I have a basic misunderstanding of jupyter but I could not figure out yet, what is the best way.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1595,"Q_Id":54923554,"Users Score":0,"Answer":"You don't necessarily need notebooks, you may create .py files with your class implementations for example myclass.py, and then just normally do import myclass","Q_Score":2,"Tags":"python,class,oop,jupyter-notebook,jupyter","A_Id":54923584,"CreationDate":"2019-02-28T10:33:00.000","Title":"Jupyter Class in different notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python script and arm board with android pie.\nI have UART console and adb shell of board. Now i want to run python script on board ? \nHow to add python packages in android build ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":359,"Q_Id":54924609,"Users Score":0,"Answer":"To run python, we need to install QPython apk on the board, which has the necessary python binaries to run python, Download the QPython apk\nStart the adb service on the board and connect to the host PC.\nInstall the qpython apk using the command: adb install \nAfter the apk is successfully installed, verify the installation by checking the org.qpython.qpy directory on the board. the directory contains python binaries.\nBefore running python, we need to source the init.sh script in the bin\/ directory: source init.sh\nYou can now run python by the following command from the bin\/directory as: python-android5 \/path\/to\/python\/file.py","Q_Score":0,"Tags":"android,python,adb,android-9.0-pie","A_Id":55570814,"CreationDate":"2019-02-28T11:25:00.000","Title":"How to run python script on arm board with android pie?","Data Science and Machine Learning":0,"Database and SQL":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 a little bit hard to describe my problem. I am searching for an algorithm in Python, to create wrinkled paper effect on a white image with some text. \nMy first try was adding some real wrinkled paper image (with transparency) to the image with text. This looks nice, but hast the side effect, that the text is not really wrinkled.\nSo I am looking for a better solution, any ideas? Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":408,"Q_Id":54928574,"Users Score":0,"Answer":"Instead of using transparency, assuming you have two images of the same dimensions, one bright with the wrinkled paper and one with a dark text on a white background, you could try to take for every pixel the minimum of the values of the corresponding pixels in the two images.\nIn this way you should succeed in merging the text (darker than the wrinkled paper) and the wrinkled paper (darker than the original text background).","Q_Score":1,"Tags":"python,image-processing","A_Id":54934592,"CreationDate":"2019-02-28T15:02:00.000","Title":"Python: Image processing create wrinkled paper effect","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When using the jira python library and creating issues, non mandatory fields are being enforced on create_issue call. \nResponse on create issue attempt:\ntext: No issue link type with name 'Automated' found.\n\nResponse on create meta call to check mandatory fields:\n\n'hasDefaultValue': False,\n                                                               u'key': u'issuelinks',\n                                                               u'name': u'Linked Issues',\n                                                               u'operations': [u'add'],\n                                                               u'required': False,","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":54929685,"Users Score":0,"Answer":"Jira behaves strange many times.\ncreatemeta call returns you all the possible issuetypes, and their all fields, and which field is mandatory or not.\nBut even after this, there are certain fields which are mandatory but createmeta wont tell you this. You need to rely on the exception message that you got after filing create_issue().\nIn the exception message, exception_obj.response.text gives you the json having key\/value of exact field required. \nThen, you can search in response of createmeta about its schema type, and may be the allowedValues set.\nAnd, then try again.\nBasically, you need to do retry of above mechanism.","Q_Score":1,"Tags":"python,jira,jira-rest-api,python-jira","A_Id":56360789,"CreationDate":"2019-02-28T16:00:00.000","Title":"Python JIRA Non-Mandatory fields being forced on create issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was just wondering, is there any way to convert IUPAC or common molecular names to SMILES? I want to do this without having to manually convert every single one utilizing online systems. Any input would be much appreciated!\nFor background, I am currently working with python and RDkit, so I wasn't sure if RDkit could do this and I was just unaware. My current data is in the csv format. \nThank you!","AnswerCount":7,"Available Count":1,"Score":-0.0285636566,"is_accepted":false,"ViewCount":8612,"Q_Id":54930121,"Users Score":-1,"Answer":"if you change the first line to:\nfrom urllib2 import url open\nit should work for python 2.7","Q_Score":11,"Tags":"python,cheminformatics","A_Id":57932844,"CreationDate":"2019-02-28T16:23:00.000","Title":"Converting molecule name to SMILES?","Data Science and Machine Learning":0,"Database and SQL":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 2 cumulative distributions that I want to find the intersection of. To get an underlying function, I used the scipy interpol1d function. What I\u2019m trying to figure out now, is how to calculate their intersection. Not sure how I can do it. Tried fsolve, but I can\u2019t find how to restrict the range in which to search for a solution (domain is limited).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":54930134,"Users Score":0,"Answer":"Use scipy.optimize.brentq for bracketed root-finding:\nbrentq(lambda x: interp1d(xx, yy)(x) - interp1d(xxx, yyy)(x), -1, 1)","Q_Score":0,"Tags":"python,python-3.x,scipy","A_Id":54950068,"CreationDate":"2019-02-28T16:24:00.000","Title":"Intersection of interpol1d objects","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"ValueError                                Traceback (most recent call last)  in () ----> 1 prediction = model.predict(image_resized.reshape(1,50,50,3))       2 print('Prediction Score:\\n',prediction[0])  ValueError: cannot reshape array of size 2352 into shape (1,50,50,3)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":54930833,"Users Score":0,"Answer":"By just looking at what you have posted you should replace image_resized.reshape(1,50,50,3) with image_resized.reshape(1,28,28,3)","Q_Score":0,"Tags":"python-3.x,tensorflow,jupyter-notebook","A_Id":54930980,"CreationDate":"2019-02-28T17:06:00.000","Title":"model can predict new image","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having some nii images and each having same height and width but different depth. So I need to make the depth of each image equal, how can I do that? Also I didn't find any Python code, which can help me.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":54932433,"Users Score":0,"Answer":"Once you have defined the depth you want for all volumes, let it be D, you can instantiate an image (called volume when D > 1) of dimensions W x H x D, for every volume you have.\nThen you can fill every such volume, pixel by pixel, by mapping the pixel position onto the original volume and retrieving the value of the pixel by interpolating the values in neighboring pixels.\nFor example, a pixel (i_x, i_y, i_z) in the new volume will be mapped in a point (i_x, i_y, i_z') of the old volume. One of the simplest interpolation methods is the linear interpolation: the value of (i_x, i_y, i_z) is a weighted average of the values (i_x, i_y, floor(i_z')) and (i_x, i_y, floor(i_z') + 1).","Q_Score":1,"Tags":"python,image-processing,medical","A_Id":54934401,"CreationDate":"2019-02-28T18:54:00.000","Title":"How to make depth of nii images equal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Django project that will have multiple instances, one for each of my clients, each instance have your own DB and some custom APPs and your own domain, but all share the same source code, the only difference will be the settings.py file pointing for the correct DB.\nI know I can achieve this using different virtual hosts pointing to different settings using for exemple Apache and WSGI, but in my case I will use AWS Lambda and Zappa to provide this service for my clients.\nI want to know if exists a way to dynamically load some custom settings depending on the domain that loads the site.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":515,"Q_Id":54933044,"Users Score":0,"Answer":"You can convert settings.py to settings folder and create as many domain's setting you would like to add. I would create base.py for common setting and then each domain which has a specific setting should import base.py and additional domain specific settings.\nDirectory structure would be:\n\nsettings:\n\nbase.py\ndomain_1.py\ndomain_2.py\n...\n\n\nWhen you load domain_1 then try to load using python manage.py runserver --settings=settings.domain_1.py and request.meta['HTTP_HOST'] can give you domain name.","Q_Score":1,"Tags":"python,django,aws-lambda,wsgi,zappa","A_Id":54933461,"CreationDate":"2019-02-28T19:37:00.000","Title":"Different settings.py file for different domains in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to program a Sieve of Eratosthenes in Python with threading to enable faster output? Ive seen a lot of Sieve of Eratosthenes written in python but never one that has threading. Is it impossible because of the GIL?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":183,"Q_Id":54933184,"Users Score":0,"Answer":"If your sieve is going to process a number of primes that is large enough to require offloading bitmaps to disk, it may become relevant to use threads. Due to the nature of the sieve, you have to expect a lot of contention between the threads because they will all want to update the same files (at least initially).\nLets say you use bits to represent the positions of flagged numbers in the sieve and you break it down in 8K files (65536 bits), the first primes you find will have something to update in every single file so the benefits of parallelism will be lost to file access conflicts.  Once you reach primes that are larger than 65536, there will be a lot fewer conflits and the threads will start to bring some benefits.\nYou will still have to find a way to prevent the controlling process (that finds the next eligible number and launches the threads) from moving ahead of the threads' update process.\nA better strategy could be to make the chunk size equal to the product of the first few primes.  This would allow the initial creation of the files to use an identical bitmap repeated over and over and would also reduce the file access conflicts at the beginning of the process. \nFor example,  if the chunk size is 2*3*5*7 (210) your files would hold 210 bits with a repeatable pattern that covers flagging of these 4 factors. i.e. bits for 1..210 are the same as those for 211..420, 421..630, and so on.   You would, of course use a larger number of factors to have meaningful file sizes.","Q_Score":0,"Tags":"python,sieve-of-eratosthenes","A_Id":54936430,"CreationDate":"2019-02-28T19:46:00.000","Title":"Sieve of Eratosthenes in python with threading","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've built a data pipeline. Pseudo code is as follows:\n\ndataset -> \ndataset = augment(dataset)\ndataset = dataset.batch(35).prefetch(1)\ndataset = set_from_generator(to_feed_dict(dataset)) # expensive op\ndataset = Cache('\/tmp', dataset)\ndataset = dataset.unbatch()\ndataset = dataset.shuffle(64).batch(256).prefetch(1)\nto_feed_dict(dataset)\n\n1 to 5 actions are required to generate the pretrained model outputs. I cache them as they do not change throughout epochs (pretrained model weights are not updated). 5 to 8 actions prepare the dataset for training.\nDifferent batch sizes have to be used, as the pretrained model inputs are of a much bigger dimensionality than the outputs.\nThe first epoch is slow, as it has to evaluate the pretrained model on every input item to generate templates and save them to the disk. Later epochs are faster, yet they're still quite slow - I suspect the bottleneck is reading the disk cache.\nWhat could be improved in this data pipeline to reduce the issue?\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":257,"Q_Id":54934207,"Users Score":0,"Answer":"prefetch(1) means that there will be only one element prefetched, I think you may want to have it as big as the batch size or larger. \nAfter first cache you may try to put it second time but without providing a path, so it would cache some in the memory.\nMaybe your HDD is just slow? ;)\nAnother idea is you could just manually write to compressed TFRecord after steps 1-4 and then read it with another dataset. Compressed file has lower I\/O but causes higher CPU usage.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,tensorflow-datasets","A_Id":54935427,"CreationDate":"2019-02-28T21:02:00.000","Title":"Tensorflow data pipeline: Slow with caching to disk - how to improve evaluation performance?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've read around and see this has to do with concurrency, that celery can't edit the app variables because it's in a different thread from a python app. So instead I'm modifying the database by creating an object in the hope that django signal would've picked it up, but it's not. I'm doing this since I need to know if an update has occured in the back end so the SPA front end can fetch it automatically. Any tips?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":54939449,"Users Score":0,"Answer":"Django signals only work in-process.  So making a model change in celery will trigger the signal to occur in celery.  If you need to notify a single page app either (1) use a websocket or (2) pass the SPA the task_id so it can poll for when the task is complete and then take the necessary action.","Q_Score":0,"Tags":"python,django-models,celery","A_Id":54991229,"CreationDate":"2019-03-01T06:56:00.000","Title":"Celery task creates a new model object, but django signals doesn't pick it up","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have to automate a task which involves lots of google searching, which I am doing through selenium and python. After 20 searches google says suspicious activity detected and gives a reCaptcha to prove I am not a robot. I have tried other ways (like changing profile) but still the same problem.\nHow to get rid of it?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1817,"Q_Id":54940720,"Users Score":1,"Answer":"I solved this by rotating a decent pool of proxies with an inner load balancer, switching user agent and use captcha solving APIs where appropriate. Having a good amount of clean IP addresses and using them wisely has the biggest impact so far.","Q_Score":1,"Tags":"python,selenium,google-chrome,selenium-chromedriver,recaptcha","A_Id":55326670,"CreationDate":"2019-03-01T08:32:00.000","Title":"Google search using selenium causing suspicious network traffic and shows reCaptcha","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Cython using apt-get install cython3. But when I run a script with Python 3 that tries to from Cython.Build import cythonize, I get the message ModuleNotFoundError: No module named 'Cython'\nWhat am I missing to run this script?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":222,"Q_Id":54941599,"Users Score":2,"Answer":"Perhaps try to install Cython using pip by pip install cython.","Q_Score":0,"Tags":"python,cython","A_Id":54942038,"CreationDate":"2019-03-01T09:28:00.000","Title":"Cython installed but can't be imported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am running on Python 3.7.1 and I've been trying to find a way to clear a screen of any previously printed messages. The problem is that os.system(\"cls\") does nothing, it only makes a small window pop up for a fraction of a second, then it closes. I've tried to add a \\n at the end and multiplying it by how many letters there are, still not working.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":817,"Q_Id":54943464,"Users Score":-1,"Answer":"I don't think that there is a way, or at least have never seen one. However, there is a workaround which would look like \nprint \"\\n\" * 100. \nThis will simply print 100 newlines, which will clear the screen for you. \nYou could also put it in a function \ndef cls(): print \"\\n\" * 100\nAnd then when you need it just call it with cls()","Q_Score":0,"Tags":"python,screen","A_Id":54943511,"CreationDate":"2019-03-01T11:11:00.000","Title":"How to clear a screen in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Tried many suggestions to clear console and variables in Spyder using code not CTRL+L but they do not work.\nwondering any effective suggestion what the code can be used for clearing Spyder console and variables.\nusing get_ipython().magic('reset -sf') will make the variable explorer not updated.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":20220,"Q_Id":54943710,"Users Score":1,"Answer":"cls and clear-host work in (!) the Console.","Q_Score":1,"Tags":"python,python-3.x,spyder","A_Id":68936624,"CreationDate":"2019-03-01T11:27:00.000","Title":"Code to clear console and variables in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My girlfriend has been given the task of getting all the data from a webpage. The web page belongs to an adult education centre. To get to the webpage, you must first log in. The url is a .asp file. \nShe has to put the data in an Excel sheet. The entries are student names, numbers, ID card number, telephone, etc. There are thousands of entries. HR students alone has 70 pages of entries. This all shows up on the webpage as a table. It is possible to copy and paste.\nI can handle Python openpyxl reasonably and I have heard of web-scraping, which I believe Python can do.\nI don't know what .asp is.\nCould you please give me some tips, pointers, about how to get the data with Python? \nCan I automate this task? \nIs this a case for MySQL? (About which I know nothing.)","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":60,"Q_Id":54943792,"Users Score":1,"Answer":"This is a really broad question and not really in the style of Stack Overflow. To give you some pointers anyway. In the end .asp files, as far as I know, behave like normal websites. Normal websites are interpreted in the browser like HTML, CSS etc. This can be parsed with Python. There are two approaches to this that I have used in the past that work. One is to use a library like requests to get the HTML of a page and then read it using the BeautifulSoup library. This gets more complex if you need to visit authenticated pages. The other option is to use Selenium for python. This module is more a tool to automate browsing itself. You can use this to automate visiting the website and entering login credentials and then read content on the page. There are probably more options which is why this question is too broad. Good luck with your project though!  \nEDIT: You do not need MySql for this. Especially not if the required output is an Excel file, which I would generate as a CSV instead because standard Python works better with CSV files than Excel.","Q_Score":0,"Tags":"python","A_Id":54944088,"CreationDate":"2019-03-01T11:32:00.000","Title":"Get data from an .asp file","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My girlfriend has been given the task of getting all the data from a webpage. The web page belongs to an adult education centre. To get to the webpage, you must first log in. The url is a .asp file. \nShe has to put the data in an Excel sheet. The entries are student names, numbers, ID card number, telephone, etc. There are thousands of entries. HR students alone has 70 pages of entries. This all shows up on the webpage as a table. It is possible to copy and paste.\nI can handle Python openpyxl reasonably and I have heard of web-scraping, which I believe Python can do.\nI don't know what .asp is.\nCould you please give me some tips, pointers, about how to get the data with Python? \nCan I automate this task? \nIs this a case for MySQL? (About which I know nothing.)","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":60,"Q_Id":54943792,"Users Score":1,"Answer":"Try using the tool called Octoparse.\nDisclaimer: I've never used it myself, but only came close to using it. So, from my knowledge of its features, I think it would be useful for your need.","Q_Score":0,"Tags":"python","A_Id":54945063,"CreationDate":"2019-03-01T11:32:00.000","Title":"Get data from an .asp file","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a set of xml files representing rules manager rules. There are several elements that map to tables or table-attribute pairs.\nI would like to discover all the elements that affect intersecting sets of tables or table-attributes.\nI can work in java or possibly python, or command line Windows\/Mac. Can someone suggests a tool or approach? Thanks so much!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":54945282,"Users Score":0,"Answer":"Experiment with xmlStarlet\nTry Saxon for cross file xpath queries\nBoth can work from the command line","Q_Score":0,"Tags":"java,python","A_Id":55133607,"CreationDate":"2019-03-01T13:04:00.000","Title":"Generate relationship data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Problem: I created a Tkinter Frame containing a ttk.TreeView widget. Each row contains text from Reddit posts. However, lenghty posts (or with plenty of newlines) are not completely visible in the row.\nQuestion: Is it in any way possible to resize individual rows based on the content that is loaded in?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":150,"Q_Id":54946365,"Users Score":0,"Answer":"No, it is not possible to resize individual rows of a treeview.","Q_Score":0,"Tags":"python-3.x,tkinter","A_Id":54947613,"CreationDate":"2019-03-01T14:11:00.000","Title":"Tkinter dynamic TreeView row resize","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm really confused with the architecture of yolov3. I've read the documentation and paper about it. Some people say that it has 103 convolutional layers, some others say that it has 53 layers. But when you count the convolutional layers in the .cfg file (after downloading it) it comes to about 75! ...What is missed here? What should I do to find it? This question is important for us because we need to cite this architecture in a paper and we need to know the exact size of the layers...","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5589,"Q_Id":54948738,"Users Score":0,"Answer":"YOLO v3 has 107 layers in total, you should also count shortcut layers, route layers, upsample layers, and YOLO layers(32 in total). So, there are 75+32=107 layers in total. When you see indexes in shortcut or route layers, you will find that we count from 0. Therefore, yolo layers are in 82,94,106 layers.","Q_Score":3,"Tags":"python,conv-neural-network,object-detection,yolo","A_Id":71724209,"CreationDate":"2019-03-01T16:32:00.000","Title":"What is the real number of CNN layers in yolov3?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"in our CI process we do the following things:\n\ncreate a whole new conda enviorment for this CI pipeline\ncreate a conda package using conda build, the output folder is set to .\/build\ninstall the newly created package using conda install -c .\/build package_name.\n\nSecond step is so in our second stage of the CI, when we are testing, we just invoke pytest to run all the test files in the CI environment and using the newly installed package_name package. \nNote package_name has a internal dependency another_package_name listed in the meta.yaml file which defines the package.\nOne thing we have found is that in step 1 and step 2, the version of another_package_name is different, when building the package, conda seems to be able to get the latest version of the dependency. At step 2 though, conda seems to be picking an old version of the dependency.\nSome other findings I have:\n\nBoth package_name and another_package_name is published to a file location we use for our internal channel (using plain cp *.tar.bz2 command)\nThis is only happening in the CI, to the particular CI user, and only happening if we are in that CI folder and in that CI environment, meaning using a different user, creating a new environment, copying the .\/build folder out to somewhere else all stop us from reproducing this behavior.\n\nThis is blocking us to have a proper functional CI. And we could not find out what's going on with the local install step and why does it picks the wrong version of the dependency.\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":861,"Q_Id":54948837,"Users Score":0,"Answer":"I just solved a similar problem, by including the --update-specs option in my conda install ... command.\nAny luck?\nFor the record, my exact problem was that the dependency version requirements of a conda package installed in \"develop\" mode were not being respected without this option.","Q_Score":4,"Tags":"python,anaconda,conda,miniconda","A_Id":70056667,"CreationDate":"2019-03-01T16:38:00.000","Title":"conda build and conda install using different version of the same dependencies, why?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having troubles understanding how to manage and modify numpy matrices. I find it very difficult to \"picture\" the matrices in my head.\nI have a (4x2x1x1) matrix which I want to make into a (1x2x1x4) matrix, such that I can apply matrix multiplication with another matrix which have the shape (3x2x1x1). \nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":130,"Q_Id":54950408,"Users Score":0,"Answer":"If your matrix is called matrix, matrix.shape = (1,2,1,4) (as in my example above) does the trick. NumPy will automatically notices if your new shape is \"out of bounds\", and automatically reorder the data correctly if it's not.\nEDIT: You can also use newMatrix = numpy.reshape(matrix, (1,2,1,4)) to create a new matrix as a reshape of your first matrix.","Q_Score":0,"Tags":"python,numpy,matrix-multiplication,numpy-ndarray,array-broadcasting","A_Id":54958225,"CreationDate":"2019-03-01T18:33:00.000","Title":"Reordering numpy 4D-array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install paramiko library to python 2.7, but it is getting installed to a directory that python is not searching. The sys.path in python is:\n\/opt\/local\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/site-packages\nYet when I installed paramiko, it went here:\n\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\nI suspect it has something to do with the version of pip (pip2) that I used to install paramiko, but I can't seem to fix this for the life of me.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":59,"Q_Id":54950886,"Users Score":1,"Answer":"You can add paths to sys.path so that libraries will be imported from wherever you want.\nimport sys\nsys.path.append(\"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\"\nThat should fix your problem","Q_Score":1,"Tags":"python,python-2.7,pip,paramiko","A_Id":54952462,"CreationDate":"2019-03-01T19:10:00.000","Title":"pip appears to be installing to the wrong location","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am very new to Simpy, so I'm looking at writing what should be a simple example:  the expected behavior of drivers at a 4-way stop in the United States.  For those of you not familiar with US driving laws, the basic rule is simple:  the first driver to the intersection, after stopping, has the right of way.  The trick comes when more than one driver arrives simultaneously.  Some rules for simultaneous arrival are obvious (if two drivers arrive and a facing each other and are going straight, both can proceed); others less so (if the two drivers are crossing each other, the one on the right has the right of way).\nI'm looking at modeling the intersection as a simple resource with the driver objects queuing for access.  When a driver object is activated, it will look at the other objects in the queue with the same timestamp and apply the rules described above.  If it \"has right of way,\" it will advance the clock and then release the resource, and the next driver object will be activated.  If it does not have right of way, it will still release the resource to the next driver object, but the clock is not advanced.  The important thing in this case is that the first driver needs to remain at the head of the queue.\nHow might I implement this last part?  Consider this situation.  Three driver objects are created with the same timestamp, one each for entering from the north, east, and south.  Let's say that the east object is the first to be activated.  By the rules, it needs to relinquish the intersection and let the north object go first.  However, once the north object advances the clock and relinquishes the intersection, it should go back to the east, and not the south.\nAny suggestions on this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":54951796,"Users Score":0,"Answer":"You might want to design the code such that every road is one resource(n=1) with own queues. All cars pass through their respective resources (get -> release) unless one of the other resources is occupied (a simultaneous arrival). If so you can have a form of matrix base that determines what rule applies and if (physical) yielding is appropriate. You can then have the prioritized vehicle move first (with time stamp)\nThe advantage of the separate queues is that regardless of what car goes when, all lanes will adhere to the FIFO (first-in-first-out) policy of their queue, which is exactly what happens on a real intersection.","Q_Score":0,"Tags":"python,simpy","A_Id":57393243,"CreationDate":"2019-03-01T20:24:00.000","Title":"Simpy: Yielding resource without losing position in queue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have formulated a LP with dynamically generated constraints and equations. How can I view the whole equation and constraints so generated? Looked in documentation found no reference.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":54951831,"Users Score":1,"Answer":"Many modeling systems provide surprisingly little help in terms of debugging tools. In those cases you may have to rely on writing an LP file (in PuLP: method writeLP).","Q_Score":1,"Tags":"python-3.x,optimization,pulp","A_Id":54955643,"CreationDate":"2019-03-01T20:27:00.000","Title":"How to view dynamically generated Pulp Equations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is simple: I have an image and I want to add pixel wise independent noise to the image. The noise can be derived from from any distribution such as Gaussian. What are the available modules in numpy\/scikit-learn to do the same?\nI do not have any code but I am learning about modules such as numpy.random.normal, etc. and I needed more clarification.\nNone of the modules explicitly say that if I draw samples from a distribution multiple times, the draws will be independent. \nThank you for suggestions.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":561,"Q_Id":54953272,"Users Score":1,"Answer":"You have several options. If you want to take random samples with replacement, just use one of the numpy's builtin random modules (i.e., numpy.random.random). You could also use numpy.random.pareto for more dramatic\/bursty noise. These methods generate independent samples.\nIf you have a distribution in the form of a set or array that you want to pull samples from without repetition (for instance you have an array [0.1, 0.3, 0.9] and want to generate noise with ONLY these values), you use python's builtin random.random.choice([0.1, 0.3, 0.9]) to draw independent samples from your custom distribution. You can also specify replace=False.","Q_Score":0,"Tags":"python,numpy,image-processing,scikit-learn,noise-generator","A_Id":54953548,"CreationDate":"2019-03-01T22:38:00.000","Title":"Add pixel wise independent noise to image","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a beginner, I have really hit a brick wall, and would greatly appreciate any advice someone more advanced can offer.\nI have been having a number of extremely frustrating issues the past few days, which I have been round and round google trying to solve, tried all sorts of things to no avail.\nProblem 1)\nI can't import pygame in Idle with the error:\nModuleNotFoundError: No module named 'pygame' - even though it is definitely installed, as in terminal, if I ask pip3 to install pygame it says:\nRequirement already satisfied: pygame in \/usr\/local\/lib\/python3.7\/site-packages (1.9.4)\nI think there may be a problem with several conflicting versions of python on my computer, as when i type sys.path in Idle (which by the way displays Python 3.7.2 ) the following are listed:\n'\/Users\/myname\/Documents', '\/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python37.zip', '\/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7', '\/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/lib-dynload', '\/Users\/myname\/Library\/Python\/3.7\/lib\/python\/site-packages', '\/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/site-packages'\nSo am I right in thinking pygame is in the python3.7\/sitepackages version, and this is why idle won't import it? I don't know I'm just trying to make sense of this. I have absoloutely no clue how to solve this,\"re-set the path\" or whatever. I don't even know how to find all of these versions of python as only one appears in my applications folder, the rest are elsewhere?\nProblem 2)\nApparently there should be a python 2.7 system version installed on every mac system which is vital to the running of python regardless of the developing environment you use. Yet all of my versions of python seem to be in the library\/downloaded versions. Does this mean my system version of python is gone? I have put the computer in recovery mode today and done a reinstall of the macOS mojave system today, so shouldn't any possible lost version of python 2.7 be back on the system now?\nProblem 3)\nWhen I go to terminal, frequently every command I type is 'not found'.\nI have sometimes found a temporary solution is typing:\nexport PATH=\"\/usr\/local\/bin:\/usr\/bin:\/bin:\/usr\/sbin:\/sbin\"\nbut the problems always return!\nAs I say I also did a system reinstall today but that has helped none!\nCan anybody please help me with these queries? I am really at the end of my tether and quite lost, forgive my programming ignorance please. Many thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":54953355,"Users Score":0,"Answer":"You should actually add the  export PATH=\"\/usr\/local\/bin:\/usr\/bin:\/bin:\/usr\/sbin:\/sbin\" to your .bash_profile (if you are using bash). Do this by opening your terminal, verifying that it says \"bash\" at the top. If it doesn't, you may have a .zprofile instead. Type ls -al and it will list all the invisible files. If you have .bash_profile listed, use that one. If you have .zprofile, use that.\nType nano .bash_profile to open and edit the profile and add the command to the end of it. This will permanently add the path to your profile after you restart the terminal.\nUse ^X to exit nano and type Y to save your changes. Then you can check that it works when you try to run the program from IDLE.","Q_Score":0,"Tags":"python-3.x,macos,command-line,terminal,pygame","A_Id":72088835,"CreationDate":"2019-03-01T22:45:00.000","Title":"Pygame\/Python\/Terminal\/Mac related","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm getting the message \n\nThere is no document formatter for 'python'-files installed.\n\nwhen I try to format my Python file on Visual Studio Code.\nI tryed to install some packages (autopep8, pep8, pycodestyle), but it didn't help. What's going on?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4987,"Q_Id":54953381,"Users Score":1,"Answer":"More than likely you installed autopep8 into a different interpreter\/environment than you one have selected in VS Code. If you remove your formatter settings from your settings.json and then try formatting again, you will get prompted to choose and install a formatter (either autopep8, yapf, or black).","Q_Score":3,"Tags":"python,visual-studio-code,vscode-settings","A_Id":54993983,"CreationDate":"2019-03-01T22:48:00.000","Title":"I can't format Python file on Visual Studio Code: \"There is no document formatter for 'python'-files installed.\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My environment:\nWindows 10 Professional\nPython 3.7.2\nvirtualenv 16.4.3\nI created a new virtual environment with D:\\Python37\\Scripts\\virualenv env\nThen I activated the virtual environment with env\\Scripts\\activate\nThen I installed jupyter with pip install --upgrade jupyter\nFinally, I started jupyter with jupyter notebook\nEverything starts up fine, and I create a new Python 3 notebook. Unfortunately, the notebook never connects to the server. I get the following error message in powershell\nReplacing stale connection: (token)\nIn the browser, I get the following error message:\n\"A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration.\"\nMy two prior virtual environments (with Jupyter) work fine. I've deleted .ipython, .jupyter, AppData\\Roaming\\jupyter, without any luck.\nI've cleared cookies from my browser and have tried a different browser. Nothing works.\nI've created two other virtual environments before, and both of those still work.\nAll jupyter notebooks in the two working environments start up as untrusted, whereas the new environment starts up as trusted. I'm guessing that I clicked on something and now the notebook is looking to start up in a trusted fashion - which may require HTTPS.\nWhere do I look to fix this problem?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":30459,"Q_Id":54954415,"Users Score":1,"Answer":"In my case, the situation was different. It was a browser caching issue, i.e., I would call jupyter-lab using a batch script and it would just open a tab. Closing all explicitly tabs and then the browser worked me.\nIf there was an old instance of another disconnected jupyter-lab, it would somehow not establish a proper connection.","Q_Score":9,"Tags":"python,jupyter-notebook,jupyter","A_Id":72470880,"CreationDate":"2019-03-02T01:32:00.000","Title":"Cannot connect to Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My environment:\nWindows 10 Professional\nPython 3.7.2\nvirtualenv 16.4.3\nI created a new virtual environment with D:\\Python37\\Scripts\\virualenv env\nThen I activated the virtual environment with env\\Scripts\\activate\nThen I installed jupyter with pip install --upgrade jupyter\nFinally, I started jupyter with jupyter notebook\nEverything starts up fine, and I create a new Python 3 notebook. Unfortunately, the notebook never connects to the server. I get the following error message in powershell\nReplacing stale connection: (token)\nIn the browser, I get the following error message:\n\"A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration.\"\nMy two prior virtual environments (with Jupyter) work fine. I've deleted .ipython, .jupyter, AppData\\Roaming\\jupyter, without any luck.\nI've cleared cookies from my browser and have tried a different browser. Nothing works.\nI've created two other virtual environments before, and both of those still work.\nAll jupyter notebooks in the two working environments start up as untrusted, whereas the new environment starts up as trusted. I'm guessing that I clicked on something and now the notebook is looking to start up in a trusted fashion - which may require HTTPS.\nWhere do I look to fix this problem?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":30459,"Q_Id":54954415,"Users Score":1,"Answer":"Since this is one of the top answers to a Google search on the error :\n\"A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration.\"\nThis might also have nothing to do with any install or library.\nIt may just be a proxy setting in your browser or on your system directly. \nOne solution may be to deactivate the proxy or add an exception to Jupyter's URI.","Q_Score":9,"Tags":"python,jupyter-notebook,jupyter","A_Id":68563988,"CreationDate":"2019-03-02T01:32:00.000","Title":"Cannot connect to Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that is using pygame to load sound and play them. When I run my script without sudo, it is working fine. But when I run the script with sudo, I get these errors:\n\nHome directory not accessible: Permission denied\nALSA lib pcm_mmap.c:341:(snd_pcm_mmap) mmap failed: Invalid argument\n\nDoes anyone have any idea on why this is happening? I would like to understand what's going on and not only get a quick fix in case this happens again in another context and because I might need to run the script with sudo.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2784,"Q_Id":54955814,"Users Score":0,"Answer":"Apparently, pulseaudio won't work under root.\n\nThe OP had edited the question with this; posting it as an answer instead.","Q_Score":2,"Tags":"python,linux,pulseaudio","A_Id":65652874,"CreationDate":"2019-03-02T06:25:00.000","Title":"Home directory not accessible: Permission denied. Working fine without sudo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using a blob trigger with a python function on an Azure functions app with the consumption plan. I know it is in preview but it is a bummer that the app terminates after a while of no usage. And it will not get back to live when a new blob is added.\nThe function works perfectly locally\nIs there a way to keep the function app alive?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":54957105,"Users Score":0,"Answer":"I did not find the right way to do it but I added a second http trigger function to start the app and that works. So my current process is: trigger the http function and then upload the blob.\nI also tried a cron trigger but that also didn't fire.","Q_Score":0,"Tags":"python,azure,azure-functions","A_Id":54957106,"CreationDate":"2019-03-02T09:34:00.000","Title":"Azure Function App Python terminates after a while","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to Pandas.\nI've got a dataframe where I want to group by user and then find their lowest score up until that date in the their speed column.\nSo I can't just use df.groupby(['user'])['speed'].transform('min) as this would give the min of all values not just form the current row to the first.\nWhat can I use to get what I need?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":54958144,"Users Score":0,"Answer":"Without seeing your dataset it's hard to help you directly. The problem does boil down to the following. You need to select the range of data you want to work with (so select rows for the date range and columns for the user\/speed).  \nThat would look something like x = df.loc[[\"2-4-2018\",\"2-4-2019\"], ['users', 'speed']]\nFrom there you could do a simple x['users'].min() for the value or x['users'].idxmin() for the index of the value.\nI haven't played around for a bit with Dataframes, but you're looking for how to slice Dataframes.","Q_Score":0,"Tags":"python,pandas","A_Id":54958224,"CreationDate":"2019-03-02T11:44:00.000","Title":"Pandas - select lowest value to date","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with Jupyter notebook for some studying. I just updated all my python libraries and now when I start a new python notebook, it just continuously says connecting to kernel in yellow.\nDo I have to change something using my terminal to tell my mac to use the localhost? I have been trying to initiate an EC2 instance for another project, which I put on hold until I can figure out why that is not working, but now I can't connect locally anymore. \nSorry, I am so vague in my explanation but it is literally my first time trying to remote connect and now I think I might have messed up the paths or something. \nI am reading something about websockets on git? \nAny and all help is greatly appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1391,"Q_Id":54960778,"Users Score":0,"Answer":"I ended up uninstalling and reinstalling anaconda. This seems to have fixed it.","Q_Score":0,"Tags":"python-3.x,amazon-ec2,websocket,localhost,jupyter-notebook","A_Id":54962329,"CreationDate":"2019-03-02T16:51:00.000","Title":"Jupiter Notebook not connecting to Kernel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Sorry, I feel like this may be a basic question, but I did not find any \"solutions\" for this. \nI am filling a python list with a lot of data, and finally want to convert it to a numpy.array for further processing.\nHowever, when I call numpy.asarray(my_list), I get an out of memory error. Why does that happen? Is it because numpy.array objects are stored in consecutive memory blocks, and there is not enough memory space for that?\nHow do I best treat such great data volumes then? I guess numpy is definitely the way to go, so I am a bit curious, that I can handle such volumes with simple list objects but not with my current numpy approach.\nAgain, repeating my most important question: How can I best handle data, which fits into python lists (so I guess overall it somehow still fits in my memory), but cannot be converted to a numpy.array?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":54961068,"Users Score":0,"Answer":"Allocate the memory for a numpy array and never create a list in the first place.\nmemmap should not be neccessary as the original list fits in memory.","Q_Score":1,"Tags":"python,arrays,numpy,memory,out-of-memory","A_Id":54962810,"CreationDate":"2019-03-02T17:22:00.000","Title":"Why can python lists hold more data than numpy arrays?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large CSV file and I just want to take a 1% sample from it.  Is there a good way to read the samples directly into pandas data frame without having to read the whole file and then discard 99% of the data?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1045,"Q_Id":54964173,"Users Score":0,"Answer":"Use skiprows with a complex selector:\nExample would be \nrows=1000\nprob=.01\nprint len(pd.read_csv(filename, usecols=[0], skiprows=lambda x: x in random.sample(xrange(0,num_rows), int((1.0-prob)*num_rows ))))\n\nThere are also other ways of doing it by reading in chunks and then just skipping rows.\ne.g. you could use chunksize=100\nskiprows=99","Q_Score":3,"Tags":"python,pandas,csv","A_Id":54964640,"CreationDate":"2019-03-02T23:40:00.000","Title":"pandas read csv by taking samples","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working for the software defined network. I am currently using mininet (miniedit) platform to build the SDN topology. I need to extract the python code that generate for a certain topology from the miniedit file (.mn file). Is there any way to extract that code?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":660,"Q_Id":54965001,"Users Score":1,"Answer":"I'm not exactly sure what you're asking but the .mn file doesn't contain any code. You have to open the .nm file in MiniEdit and then File \u2192 Export Level 2 Script to get the Python code.","Q_Score":0,"Tags":"python,sdn,mininet,pox","A_Id":54990707,"CreationDate":"2019-03-03T02:20:00.000","Title":"How I can extract the python code from the mininet miniedit file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python3 pre-installed on my personal laptop and now i have installed Jupyter Notebook using PIP but when i create a new notebook using python 3 kernel, it always gives orange highlighted message \"Connecting to Kernel\" but never connects.\nOS - Windows 10, Personal laptop\nNetwork - Wifi and not connecting through any proxy\nAnti-virus - Uninstalled\nCan someone help what could be the issue ?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":9352,"Q_Id":54966280,"Users Score":0,"Answer":"I had the same issue,i tried uninstalling tornado and reinstalling it ,i tried running it on different port , none of those worked.but i tried this and worked!!!!!\nopen anaconda ===> Home ====> find jupyter notebook ====> go to the gear icon (settings) ===> first remove it then  you see there is a  install button under it,after installation it worked for me!!!!","Q_Score":1,"Tags":"python,jupyter-notebook","A_Id":60925523,"CreationDate":"2019-03-03T06:44:00.000","Title":"No connection to kernel - Jupyter Notebook Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python3 pre-installed on my personal laptop and now i have installed Jupyter Notebook using PIP but when i create a new notebook using python 3 kernel, it always gives orange highlighted message \"Connecting to Kernel\" but never connects.\nOS - Windows 10, Personal laptop\nNetwork - Wifi and not connecting through any proxy\nAnti-virus - Uninstalled\nCan someone help what could be the issue ?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":9352,"Q_Id":54966280,"Users Score":0,"Answer":"After having issues with this myself, and looking at the Tornado version, I found this wasn't the problem for me, instead after running the following in the relevant environment after installing ipykernel, this resolved the issue:\nconda install -n base nb_conda_kernels","Q_Score":1,"Tags":"python,jupyter-notebook","A_Id":65342209,"CreationDate":"2019-03-03T06:44:00.000","Title":"No connection to kernel - Jupyter Notebook Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"From my understanding, RandomHorizontalFlip etc. replace image rather than adding new images to dataset. How do I increase my dataset size by adding augmented images to dataset using PyTorch?\nI have gone through the links posted & haven't found a solution. I want to increase the data size by adding flipped\/rotated images - but the post addresses the in-place processing of images.\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2045,"Q_Id":54969705,"Users Score":1,"Answer":"Why do you want it? Generally speaking, it is enough to increase the number of epochs over the dataset, and your model will see the original and the augmented version of every image at least once (assuming a relatively high number of epochs).\nExplanation:\nFor instance, if your augmentation has a chance of 50% to be applied, after 100 epochs, for every sample you will get ~50 samples of the original image and ~50 augmented samples. So, increasing the dataset size is equivalent to add epochs but (maybe) less efficient in terms of memory (need to store the images in memory to have high performances).","Q_Score":3,"Tags":"python,pytorch","A_Id":58200454,"CreationDate":"2019-03-03T14:12:00.000","Title":"How to add augmented images to original dataset using Pytorch?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a newbie at deep learning. I started with face recognition example and I found that there are 2 types of model base on data for pre-trained.\n1. One-shot learning with siamese network: Which we can use few data for train the model.\n2. Convolutional neural network: Need numerous data for train the model.\nCould we combine these methods is using one-shot learning with CNN in tensorflow?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":420,"Q_Id":54969832,"Users Score":0,"Answer":"As my knowledge, CNN needs lots of data for training the model.So we cant implement one shot learning features on CNN","Q_Score":0,"Tags":"python,tensorflow,conv-neural-network","A_Id":56727042,"CreationDate":"2019-03-03T14:26:00.000","Title":"Face Recognition with one shot learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a screen on my server. When I ask which python inside the screen I see it is using the default \/opt\/anaconda2\/bin\/python version which is on my server, but outside the screen when I ask which python I get ~\/anaconda2\/bin\/python. I want to use the same python inside the screen but I don't know how can I set it. Both path are available in $PATH","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":213,"Q_Id":54971247,"Users Score":1,"Answer":"You could do either one of the following:\n\nUse a virtual environment (install virtualenv). You can specify\nthe version of Python you want to use when creating the virtual\nenvironment with -p \/opt\/anaconda2\/bin\/python.\nUse an alias:\nalias python=\/opt\/anaconda2\/bin\/python.","Q_Score":0,"Tags":"python,anaconda,gnu-screen","A_Id":54980660,"CreationDate":"2019-03-03T16:50:00.000","Title":"Force screen session to use specific version of 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":1,"Web Development":0},{"Question":"How to calculate the amount of overlap between images? I'm stitching two images and I need to know the minimum overlap that is enough to stitch the two images I need to calculate the overlap between images. I use the Python language.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1917,"Q_Id":54971369,"Users Score":0,"Answer":"How to calculate the amount of overlap between images?\n\nYou perform an image registration and the result of it will automatically give you an overlap (if there is any).\nTo calculate the overlap, compute the bounds of both images (after overlaying) and then compute the bound of the intersection. The intersecting rectangle of two bounding rectangles [x1,y1,w1,h1] and [x2,y2,w2,h2] (both left upper corner, width, height) and  is [max(x1,x2),max(y1,y2),min(x1+w1,x2+w2)-max(x1,x2),min(y1+h1,y2+h2)-max(y1,y2)] (only if the resulting width and height is positive).\nThere are routines for image registration in in the popular Python packages: scikit, open-cv or itk.\nIn case, the images only need to be shifted to be overlaid, the maximum of a cross-correlation of two images (normalized by the overlapping area) is something that is commonly used.\n\nI need to know the minimum overlap that is enough to stitch the two images\n\nThe absolute minimum overlap required is a single line. In practice I would be worried about the uncertainty of the computation of the overlap (should be smaller with increasing overlap) as well as non-homogeneous imaging conditions (vignetting for example). Both should favor a somewhat larger overlap.","Q_Score":0,"Tags":"python,arrays,image-processing","A_Id":54983664,"CreationDate":"2019-03-03T17:02:00.000","Title":"How to calculate the amount of overlap between images?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just like list in python where [1,\"hello\", {\"python\": 10}] it can have all different types within, can numpy array have this as well?\nwhen numpyarray.dtype => dtype('float64') is it implying all elements are of type float?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2473,"Q_Id":54971408,"Users Score":1,"Answer":"From the docs:\n\ndtype : data-type, optional\nThe desired data-type for the array. If not given, then the type will\n  be determined as the minimum type required to hold the objects in the\n  sequence. This argument can only be used to \u2018upcast\u2019 the array. For\n  downcasting, use the .astype(t) method.\n\nSo if you set dtype as float64, everything needs to be a float. You can mix types, but then you can't set it as a mismatching type. It will use a type that will fit all data, like a string for example in the case of array(['1', 'Foo', '3.123']).","Q_Score":0,"Tags":"python,numpy","A_Id":54971460,"CreationDate":"2019-03-03T17:06:00.000","Title":"different element data types within numpy array?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have 1 Django project and multiple Django apps. Every Django app has it's own requirements.txt and settings. Hence every app has its own docker image. My doubt is, can I execute code from one Django app to other Django app while both apps have a different container?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":181,"Q_Id":54971769,"Users Score":2,"Answer":"No, in the context of Django an \u201capp\u201d is a code level abstraction so they all run in one process, which means one image. You can, sometimes, break each app into its own project and have then communicate via the network rather than locally, this is commonly called \u201cmicroservices\u201d and smaller images is indeed one of the benefits.","Q_Score":0,"Tags":"python,django,docker,kubernetes","A_Id":54973667,"CreationDate":"2019-03-03T17:39:00.000","Title":"Can django project and django app have different docker image?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have used django-private-chat for implementing one to one chat in my django project,But the problem is,it doesn't show unread message notification to user who as unread messages. I can't seem to find a way to implement this functionality.Can anyone please help me out with this.Thanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":286,"Q_Id":54972026,"Users Score":1,"Answer":"You'll have to use CSS and JS to do it.And write a Model for notification which will be update every time new notification is there.","Q_Score":1,"Tags":"javascript,python,django","A_Id":57076772,"CreationDate":"2019-03-03T18:07:00.000","Title":"unread notification in django-private-chat","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a question about using weights in keras. I have some data as events and for each of them there is an associated weight. Therefore, when I do the training of my keras model I was using the sample_weight argument to pass that information.\nI then notice that if I want to use the model.predict method there isn't an argument to pass the weights... and now I'm not sure if the type of weights I have are the ones I'm supposed to use in the fit method in the sample_weight.\nMy question is, what type of weights is the fit method supposed to recieve? Also, is it understood that the predict method doesn't need any weight for the data?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1419,"Q_Id":54973519,"Users Score":1,"Answer":"I think there might be some confusion with what \"sample_weight\" means in the context of model.fit. When you call model.fit, you are minimizing a loss function. That loss function measures the error between your model prediction and the true values. Some of the samples in your dataset might be more important to you, so you would weigh the loss function more heavily on those samples. So, the \"sample_weights\" are only used to weigh certain samples in your dataset during training to \"better fit\" those some samples relative to others. They are an optional argument to model.fit (default just weights each sample equal - what you should do if you don't have a good reason to do otherwise). And (hopefully my explanation was clear enough) do not make any sense in the context of model.predict.","Q_Score":3,"Tags":"python,tensorflow,keras","A_Id":54974116,"CreationDate":"2019-03-03T20:40:00.000","Title":"Keras: using weights when fitting","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to download files from a website using Python 3.\nDirect parsing of the URL doesn't work because the URL forwards to the login page everytime, where you need to login using the Google Login button, which forwards to Google.\nIs there a way to sign in and download the files using Python script? Maybe by implementing cookies in some way?\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":192,"Q_Id":54974983,"Users Score":0,"Answer":"You can use selenium, which can automatically fill the login form for you.","Q_Score":0,"Tags":"python,python-3.x,web-scraping,download,google-signin","A_Id":54975349,"CreationDate":"2019-03-03T23:48:00.000","Title":"Python - Download files from Website with Google Login","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script called script.py that takes in arguments and gives the output. Every time I use the script, I copy it to local working directory and then execute it as python script.py --arg1=a. I was wondering if there is a way to call the python function in local working directory without copying it, like how u can copy u c++ build files to \/usr\/local\/bin and call it from anywhere.\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":220,"Q_Id":54976307,"Users Score":2,"Answer":"You can try this steps: \n\nput #!\/usr\/bin\/python on the first line of your script. \nmaking it executable by using chmod +x script.py\nMove it to \/usr\/bin directory\n\nthen try to execute script.py in the terminal.","Q_Score":2,"Tags":"python","A_Id":54976388,"CreationDate":"2019-03-04T03:40:00.000","Title":"Calling a Python Function from local working directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Python 3.7.2\nI write the strings from my Python code into my database. My strings contain Latin and Cyrillic characters, so in the database I use 1-byte encoding koi8-r. The miracle is that my strings without distortion are written to the database, although utf8 and koi8r have completely different sequence of characters (for example, as in ascii and utf8). Sometimes characters of other layouts appear in the text and then write errors appear.\nTherefore, the question appears:\n\nWho converts strings: the database or the aiomysql library, that I use to write to the database.\nHow quickly in Python \/ MariaDB to remove non-koi8-r characters to avoid errors.\nIs there a multibyte encoding that stores the Latin and Cyrillic characters in the first byte, and other layouts in other bytes.\n\nThank you in advance for participating in the conversation.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":76,"Q_Id":54977938,"Users Score":2,"Answer":"Here's the processing when INSERTing:\n\nThe Client has the characters encoded with charset-1.\nYou told MySQL that that was the case when you connected or via SET NAMES.\nThe column that the characters will be inserted into is declared to be charset-2.\nThe INSERT converts from charset-1 to charset-2.  So, all is well.\n\nUpon SELECTing, the same thing happens, except that the conversion is in the other direction.\nWhat you are doing is OK.  But, going forward, everyone 'should' use UTF-8 characters in clients and CHARACTER SET utf8mb4 for columns.  You will essentially have to change to such if you ever branch out beyond what your character sets allow, which may be nothing more than Russian and English.","Q_Score":1,"Tags":"python,mysql,python-3.x,character-encoding","A_Id":55033080,"CreationDate":"2019-03-04T06:49:00.000","Title":"Writing from Python to a database with an encoding different from utf8","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python package my-package that depends on a binary binary.exe but this binary is too big to be uploaded to pypi. Therefore I want to execute a bash script when the user does pip install ... that will wget the binary from my github and place it in their site-packages\/my-package folder. Is this possible? If so, how would I go about doing this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":304,"Q_Id":54979251,"Users Score":1,"Answer":"There is no way. pip lags far behind real package namers like deb\/rpm; pip-installable packages are rather primitive ones, they don't have pre\/post-(un)install scripts.\nYou have to create your own installer using PyInstaller, py2exe, py2app or cx_Freeze. Or said deb\/rpm \u2014 there are plugins for setuptools to generate debs and rpms.","Q_Score":1,"Tags":"python,bash,dependencies,wget,pypi","A_Id":54983695,"CreationDate":"2019-03-04T08:26:00.000","Title":"Is it possible to execute a bash script to download non-python dependencies on `pip install my-package`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm starting to learn telegram bot. My plan was to have a bot that daily sends you at a specific time a message, but also I wanted the option to manually poll the bot for getting that daily message, or a random one. Right now I have a bot running on pythonanywhere that can respond to the 2 commands, but what about sending the user the daily message at some time? \nWhat's the way to go, create a channel and then schedule a task on my webhook to daily send the message to the channel, or store all chat-id in my service and talk to them everytime? The first one seems obviously better but I was wondering if there's some trick to make everything works in the bot.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":54981185,"Users Score":0,"Answer":"For now I managed to create a channel, make the bot an admin and scheduled a task on the webhook to daily send a message as admin to the channel","Q_Score":0,"Tags":"python,telegram,telegram-bot","A_Id":55000584,"CreationDate":"2019-03-04T10:22:00.000","Title":"Telegram: Store chat id or Channel with bot inside?","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 doing  \n\npip install tensorflow-gpu \n\nI am trying to \n\nimport gradients_util from tensorflow.python.ops  \n\nbut I get \n\ncannot import name 'gradients_util'  \n\nerror. How can I fix this?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1486,"Q_Id":54981982,"Users Score":2,"Answer":"You must use version of benchmark compatible with your TensorFlow version.\nDetermine it using pip show tensorflow.\nThen go to cloned repository of benchmarks, and checkout to required branch, for example git checkout cnn_tf_v1.13_compatible.\nPrevious comments suggested to use TensorFlow 2.0, but I don't think author of question needs it, as long as it's still unreleased and has a lot of API-breaking changes.\nP. S. You should've say that you are trying to launch benchmarks from tensorflow\/benchmarks in your question.","Q_Score":0,"Tags":"python,tensorflow","A_Id":54983029,"CreationDate":"2019-03-04T11:07:00.000","Title":"Tensorflow cannon import name 'gradients_util'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to help a friend set up the environment for Python 3 in Windows 10 in a quick and easy way. I know that you can just download Python 3 for Windows from python.org and it already comes with Pip by default. I assume that then all you need is an editor and you're good to go, or does this Windows installation lack something essential, like the ability to use command line or something else?\nMany people seem to recommend miniconda, but I don't understand what would be its benefit compared to the above method. I just want to get my friend ready to learn and code python with minimal amount of extra hassle in the beginning. Pip will be needed but don't need any pre-installed libraries. \nI installed so many different environments in the beginning myself (for example the above method, Winpython, Anaconda, etc.) that I'm not sure which one of them was actually needed and would've sufficed by itself.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":263,"Q_Id":54984236,"Users Score":1,"Answer":"A very bare-bones install would be to get an uncluttered editor, then just install python from python.org.\nI would actually advise against this unless you're only planning on using python a couple of times. As soon as you start using new packages or versions, a proper editor and environment handler becomes really important.\nPycharm does very well at handling conda and virtual environments and allows you to do it through the GUI which is good for people new to programming. You can select packages through the GUI and create environments for different projects very easily; importantly, it's also easy to remove them again. You can even pip\/conda install packages through pycharm's terminal if you want to demonstrate the different installation methods.","Q_Score":1,"Tags":"python,python-3.x,anaconda,miniconda","A_Id":54984411,"CreationDate":"2019-03-04T13:24:00.000","Title":"Setting up python 3 environment in Windows the easy way: just install from python.org, or would one really benefit from miniconda or similar?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I trained, tested and still using a model in \"Pytorch 0.4.1\". It was, and is still working fine (output is what it should be) if I use pitch 0.4.1.\nBut as i upgrade to version 1.0.1, every time, I try to evaluate same input image, I get different output (Its a regression).\nI tried to see what has been changed in those versions, but since i am not getting any errors, warnings anything, i am not sure what should I look for specifically.\nPS: I checked the weights, they are also same when I load the model","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":54984345,"Users Score":0,"Answer":"It was because of drop out layer. Model.eval disables the dropout layer. Pretty simple.\nBut Now in Pytorh upgrade, if Dropout is not defined specifically in model init function, it will not get disable during eval. \nAtleast this was reason for my case.","Q_Score":1,"Tags":"python,machine-learning,pytorch,torchvision","A_Id":55593835,"CreationDate":"2019-03-04T13:30:00.000","Title":"After Pytorch Upgrade , my model is giving almost random output","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I define a list as friends = [\"Ted\", \"Jim\", \"Sam\"]\nWhen I execute as print(friends)\nI got result as \n['Ted', 'Jim', 'Sam']\nCan anyone explain the reason as why python changed double quotes to single quotes?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":16,"Q_Id":54987103,"Users Score":1,"Answer":"In memory it is just the contents of the string. When printed, double or single quotes are exactly the same, and one of them is chosen. Nothing remembers what was originally used, as that isn't relevant for anything.","Q_Score":0,"Tags":"python-3.x,double-quotes","A_Id":54987153,"CreationDate":"2019-03-04T16:07:00.000","Title":"Python3 list string with double quotes(\") changed into single(') why?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i'm trying to create a chess simulator.\nconsider this scenario:\nthere is a black rook (instance object of Rook class) in square 2B called rook1.\nthere is a white rook in square 2C called rook2.\nwhen the player moves rook1 to square 2C , the i should remove rook2 object from memory completely.\nhow can i do it? \nP.S. i'v already tried del rook2 , but i don't know why it doesn't work.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":54,"Q_Id":54988852,"Users Score":4,"Answer":"Trying to remove objects from memory is the wrong way to go. Python offers no option to do that manually, and it would be the wrong operation to perform anyway.\nYou need to alter whatever data structure represents your chess board so that it represents a game state where there is a black rook at c2 and no piece at b2, rather than a game state where there is a black rook at b2 and a white rook at c2. In a reasonable Python beginner-project implementation of a chess board, this probably means assigning to cells in a list of lists. No objects need to be manually removed from memory to do this.\nHaving rook1 and rook2 variables referring to your rooks is unnecessary and probably counterproductive.","Q_Score":0,"Tags":"python,python-3.x,oop,python-3.7","A_Id":54988924,"CreationDate":"2019-03-04T17:51:00.000","Title":"How can i remove an object in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've done a lot of research but not sure if i understand correctly,\nThe considered \"best practice\" for deployment on docker is to have a single process per container.\nCouple of questions about it:\n\nThe meaning is that it's best to have a single service (for example, a single app), but this app can be have multiprocess architecture - right or wrong?\nIs there any actual limit on this in the container? For example if i \"ignore\" the advised best practices and try to spawn multiple processes in my app? will it fail?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":818,"Q_Id":54989570,"Users Score":1,"Answer":"Dockers can run as many processes as the underlaying cgroup allow, there will be one foreground process where the stdout is the docker log. If that process stops, your container will stop. Best practice is to do one thing with your container that is isolated from the other services except where you define the interface. For instance open the port for the webservice. Doing one thing will make the docker images portable and potentially scalable.","Q_Score":2,"Tags":"python,docker,multiprocessing","A_Id":54989826,"CreationDate":"2019-03-04T18:42:00.000","Title":"Multiprocess architecture in docker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've done a lot of research but not sure if i understand correctly,\nThe considered \"best practice\" for deployment on docker is to have a single process per container.\nCouple of questions about it:\n\nThe meaning is that it's best to have a single service (for example, a single app), but this app can be have multiprocess architecture - right or wrong?\nIs there any actual limit on this in the container? For example if i \"ignore\" the advised best practices and try to spawn multiple processes in my app? will it fail?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":818,"Q_Id":54989570,"Users Score":2,"Answer":"[It's best practice...] to have a single service (for example, a single app).  TRUE\n[If I...]  try to spawn multiple processes in my app? will it fail?  NO\nThe considered \"best practice\" for deployment on docker is to have a single process per container.  NO - NOT NECESSARILY.\n\nThe idea is that your \"service\" should be as \"stripped down\" as possible; relying on OTHER \"services\" (possibly in other containers) as-needed.  Run as little in your container as you need - but no less.","Q_Score":2,"Tags":"python,docker,multiprocessing","A_Id":54989665,"CreationDate":"2019-03-04T18:42:00.000","Title":"Multiprocess architecture in docker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to develop a text classifier that will classify a piece of text as Private or Public. Take medical or health information as an example domain. A typical classifier that I can think of considers keywords as the main distinguisher, right? What about a scenario like bellow? What if both of the pieces of text contains similar keywords but carry a different meaning. \nFollowing piece of text is revealing someone's private (health) situation (the patient has cancer): \nI've been to two clinics and my pcp. I've had an ultrasound only to be told it's a resolving cyst or a hematoma, but it's getting larger and starting to make my leg ache. The PCP said it can't be a cyst because it started out way too big and I swear I have NEVER injured my leg, not even a bump. I am now scared and afraid of cancer. I noticed a slightly uncomfortable sensation only when squatting down about 9 months ago. 3 months ago I went to squat down to put away laundry and it kinda hurt. The pain prompted me to examine my leg and that is when I noticed a lump at the bottom of my calf muscle and flexing only made it more noticeable. Eventually after four clinic visits, an ultrasound and one pcp the result seems to be positive and the mass is getting larger.\n[Private] (Correct Classification)\nFollowing piece of text is a comment from a doctor which is definitely not revealing is health situation. It introduces the weaknesses of a typical classifier model: \nDon\u2019t be scared and do not assume anything bad as cancer. I have gone through several cases in my clinic and it seems familiar to me. As you mentioned it might be a cyst or a hematoma and it's getting larger, it must need some additional diagnosis such as biopsy. Having an ache in that area or the size of the lump does not really tells anything bad. You should visit specialized clinics few more times and go under some specific tests such as biopsy, CT scan, pcp and ultrasound before that lump become more larger.\n[Private] (Which is the Wrong Classification. It should be [Public]) \nThe second paragraph was classified as private by all of my current classifiers, for obvious reason. Similar keywords, valid word sequences, the presence of subjects seemed to make the classifier very confused. Even, both of the content contains subjects like I, You (Noun, Pronouns) etc. I thought about from Word2Vec to Doc2Vec, from Inferring meaning to semantic embeddings but can't think about a solution approach that best suits this problem.\nAny idea, which way I should handle the classification problem? Thanks in advance. \nProgress so Far:\nThe data, I have collected from a public source where patients\/victims usually post their own situation and doctors\/well-wishers reply to those. I assumed while crawling is that - posts belongs to my private class and comments belongs to public class. All to gether I started with 5K+5K posts\/comments and got around 60% with a naive bayes classifier without any major preprocessing. I will try Neural Network soon. But before feeding into any classifier, I just want to know how I can preprocess better to put reasonable weights to either class for better distinction.","AnswerCount":3,"Available Count":1,"Score":-0.1325487884,"is_accepted":false,"ViewCount":452,"Q_Id":54992220,"Users Score":-2,"Answer":"(1) Bayes is indeed a weak classifier - I'd try SVM. If you see improvement than further improvement can be achieved using Neural Network (and perhaps Deep Learning)\n(2) Feature engineering - use TFiDF , and try other things (many people suggest Word2Vec, although I personally tried and it did not improve). Also you can remove stop words.\nOne thing to consider, because you give two anecdotes is to measure objectively the level of agreement between human beings on the task. It is sometime overlooked that two people given the same text can disagree on labels (some might say that a specific document is private although it is public). Just a point to notice - because if e.g. the level of agreement is 65%, then it will be very difficult to build an algorithm that is more accurate.","Q_Score":9,"Tags":"python,nlp,text-classification,natural-language-processing","A_Id":55115795,"CreationDate":"2019-03-04T22:00:00.000","Title":"Text classification beyond the keyword dependency and inferring the actual meaning","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have this quite nice DAG in airflow which basically runs several analysis steps (implemented as airflow plugins) on binary files. A DAG is triggert by an ftp sensor which just checks if there is a new file on the ftp server and then starts the whole workflow. \nSo currently the workflow is like this: DAG is triggert as defined -> sensor waits for new file on ftp -> analysis steps are executed -> end of workflow. \nWhat I'd like to have is something like this: DAG is triggerts -> sensor waits for new file on ftp -> for every file on the ftp the analysis steps are executed individully -> each workflow ends individually. \nHow do I get the analysis workflow to be executed for each file on the ftp server and if there is no file on the server, just one sensor should wait for a new file? \nI don't want to e.g., start a DAG every second or so because then I have many sensors just waiting for a new file.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":971,"Q_Id":54992541,"Users Score":3,"Answer":"Use 2 DAGs to separate the sensing step from analysis steps.\nDAG 1: \nsensor waits for new file on ftp -> once new file lands, use TriggerDagRunOperator to trigger DAG 1 itself -> use TriggerDagRunOperator to trigger DAG 2\nDAG 2: \ndo the analysis steps for the file","Q_Score":4,"Tags":"python,airflow","A_Id":54992799,"CreationDate":"2019-03-04T22:26:00.000","Title":"Run airflow DAG for each file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Does anyone have an estimate of the number of generations one should search before concluding that the NEAT-algorithm is not able to reach the minima?\nI am running NEAT on a very small dataset of cancer patients (~5K rows). And after 5000 generations, the concordance index for prediction of survival index is not improving. \nDoes anyone have any experience of how many generations should one try before you deem this as not efficient for the given problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":54993604,"Users Score":0,"Answer":"There are a couple other hyperparameters to consider before deciding NEAT cannot produce a usable neural network for your problem. You will have to make sure that your population is also large enough. Obviously a larger dataset is more helpful, but that is limited. Finally, changes such as mutation rates, aggregation options, activation functions, and your fitness function will all affect the training process for each genome. Feel free to PM if you want suggestions on them.","Q_Score":2,"Tags":"python-3.x,es-hyperneat","A_Id":55231544,"CreationDate":"2019-03-05T00:20:00.000","Title":"Typical Number of generations for NEAT (Neuro Evolution of Augmenting Topologies)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a regression model where my target variable (days) quantitative values ranges between 2 to 30. My RMSE is 2.5 and all the other X variables(nominal) are categorical and hence I have dummy encoded them. \nI want to know what would be a good value of RMSE? I want to get something within 1-1.5 or even lesser but I am unaware what I should do to achieve the same.\nNote# I have already tried feature selection and removing features will less importance.\nAny ideas would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":54993739,"Users Score":0,"Answer":"If your x values are categorical then it does not necessarily make much sense binding them to a uniform grid. Who's to say category A and B should be spaced apart the same as B and C. Assuming that they are will only lead to incorrect representation of your results.\nAs your choice of scale is the unknowns, you would be better in terms of visualisation to set your uniform x grid as being the day number and then seeing where the categories would place on the y scale if given a linear relationship.\nRMS Error doesn't come into it at all if you don't have quantitative data for x and y.","Q_Score":0,"Tags":"python,machine-learning,sklearn-pandas","A_Id":54993847,"CreationDate":"2019-03-05T00:37:00.000","Title":"Regression analysis for linear regression","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to count words which their visibility are visible in browser.\nI'm using Scrapy to get link and parse theme with Selector.\nProblem is I can only count all texts in spite of their visibility (hidden, in menu, in blockquote...) and the searching sites is a list of url (not the same structure)\nDo you have any suggestion?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":54994471,"Users Score":0,"Answer":"Scrapy just give you the page source(ctrl+u) to get the rendered page you have to use the Selenium  or splash my splash is little speed compare to the Selenium but Selenium give you full control","Q_Score":0,"Tags":"python,web-scraping,scrapy","A_Id":55007667,"CreationDate":"2019-03-05T02:15:00.000","Title":"How to imitate the browser to find & count text","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a small python program which will need to run on systems with core python (3.6.\u2026) installed. I would love to use docopt to define the argument parsing (and help text), but I do not expect to be able to rely on the docopt module being available. I thought there might be an option to generate some code, possibly using argparse, with docopt, but it seems I can't find something like that. Are there side projects or ports that anyone is aware of that might do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":54994521,"Users Score":0,"Answer":"Well\u2026 it looks as though, since docopt.py is self-contained and 20K in size, no one thus far has felt the need to generate an argument parser from a usage specifications document to ship with a script rather than just shipping docopt.py with the script and reparsing the usage specifications document to generate the parser that then immediately parses the arguments at each invocation of the script or tool.","Q_Score":1,"Tags":"python,docopt","A_Id":55057168,"CreationDate":"2019-03-05T02:22:00.000","Title":"Can docopt generate an argument parsing class that doesn't depend on docopt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script that I want to profile using vmprof to figure out what parts of the code are slow. Since PyPy is generally faster, I also want to profile the script while it is using the PyPy JIT. If the script is named myscript.py, how do you structure the command on the command line to do this?\nI have already installed vmprof using \n\npip install vmprof","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":54994853,"Users Score":0,"Answer":"I would be suprised if it works, but the command is pypy -m vmprof myscript.py <your program args>. I would expect it to crash saying vmprof is not supported on windows.","Q_Score":0,"Tags":"python,command-line,profiling,pypy","A_Id":55011625,"CreationDate":"2019-03-05T03:08:00.000","Title":"How do you profile a Python script from Windows command line using PyPy and vmprof?","Data 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":"1 I get the warning msg when I pip install my Django project requirements \n\nwechat-sdk 0.6.4 has requirement requests==2.6.0, but you'll have\n  requests 2.9.1 which is incompatible.\n\n2 then follow the tips I uninstall requests and install proper version, but I get another warning\n\npython-social-auth 0.2.21 has requirement requests>=2.9.1, but you'll\n  have requests 2.6.0 which is incompatible.\n\nSo, I'm trapped in the endless loop\nCan anyone give any advice?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2681,"Q_Id":54995091,"Users Score":2,"Answer":"As far as I can see you have the following options:\n\nRun pip with the --no-dependencies argument and hope it will just work. pip install wechatpy --no-dependencies (or whatever the package is called, I am not familiar with it) for example. This ignores the dependencies when installing. Maybe the requirements are outdated and this will let you proceed. For this you most likely want to satisfy the requests>=2.9.1 requirement so you should install python-social-auth normally and then try the other package without dependencies.\nLook for older versions of the packages you are installing that have compatible requirements. Depending on the setup of your project this might not be possible to do because you need features of the later versions (or the old versions might be insecure).\nYou can try patching one of your requirements locally (download from the source, change the code to make it work with the conflicting requests version). And then import the local version of the packages. Remember to remove the requirement from your project's requirements.txt in this case to stop other people working on \/ using your project from running into the same issue, and include the local version as part of the project (track it on Git). Check the license of the packages you are modifying to see if you are allowed to modify and redistribute them. (Optional: Make a pull request on the packages' Github with your change(s) so other people can benefit from them)\nReplace one or both of the packages by something else. They might just not be compatible or using a local, modified version might not be viable.","Q_Score":2,"Tags":"python,django,pip,ubuntu-14.04","A_Id":54995422,"CreationDate":"2019-03-05T03:43:00.000","Title":"Endless loop incompatible when I pip install requirements (Django1.99)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I recently download the PISA 2012 Student database from PISA. I follow the instructions and successfully read it on SAS. Then I exported as CSV to read it in Python 3, using proc export, but I keep getting this error when trying to read it in python pandas: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc1 in position 24: invalid start byte. What can I do?\npisa2012_Col=pd.read_csv('Pisasubset2012Col.csv')","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":54995240,"Users Score":0,"Answer":"Thank you both. It seems to work. I read it successfully and until know, variables are responding fine to my calculations. Seems SOLVED.","Q_Score":1,"Tags":"python-3.x","A_Id":55007697,"CreationDate":"2019-03-05T04:09:00.000","Title":"error UnicodeDecodeError: 'utf-8' codec when reading CSV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the numpy version 1.16.1 but I need to install 1.15.4 because pyinstaller does not work. do I have to uninstall the current version or can I install version 1.15.4 directly?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":19849,"Q_Id":54995244,"Users Score":3,"Answer":"You will need to do \npip install numpy==1.15.4 directly but it will uninstall current numpy installation, if you don't want to do that, you should use virtualenv.\npip install virtualenv\nand then in your virtualenv install the version of numpy without medelling with your working installations so you don't accidentally break anything.\nEdit\nSince OP said that they want to install it from whl file\npip install --upgrade <filename> type the filename without the angular brackets.","Q_Score":3,"Tags":"python,numpy,installation-package","A_Id":54995281,"CreationDate":"2019-03-05T04:10:00.000","Title":"installation of another version of Numpy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A code I wish to use requires python 2.7. I thought I'll make an environment just for this code but my uni's cluster [SUSE Linux] doesn't connect to the internet for security reasons. What other options do I have?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":42,"Q_Id":54998556,"Users Score":1,"Answer":"Install Anaconda on your PC in a known location (not the suggested ProgramData which is hidden and possibly protected)\nCopy the Anaconda installation on to a memory stick\nCreate a directory where you are going to do your work on your cluster - say H:\\Work\nCopy the whole Anaconda installation to H:\\Work\nCreate a shortcut to C:\\Windows\\System32\\cmd.exe in H:Work\nChange the properties to\ncmd \/k H:\\Work\\Anaconda2\\scripts\\activate.bat H:\\Work\\Anaconda2\nI'm just guessing that it is Anaconda2 for 2.7.  I use 3.7 which is Anaconda3.\nCopy the shortcut to your desktop or taskbar or favourites\nUse the shortcut to start anaconda.","Q_Score":0,"Tags":"python,python-2.7,conda","A_Id":54998911,"CreationDate":"2019-03-05T08:40:00.000","Title":"My university's cluster doesn't connect to the internet, so I can't use conda to create an environment with python 2.7. What else can I do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to retrieve the env variable $PS1 of the parent process (the shell) that calls the python program. $PS1 doesn't belong to os.environ inside the python process and sys.ps1 stores its own prompt.\nHow can we pass this variable to the program from the shell ?\nI invoke the program with : python3 program.py from the shell.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1489,"Q_Id":54998956,"Users Score":2,"Answer":"The python script can access all the environment variables through os.environ. Your problem is that PS1 is not an environment variable, but only a local variable of the shell.\nThat means that the shell does not pass it to its child in the environment (you can control that by typing env or printenv in your shell). So unless you manually put it in the environment before starting Python (export PS1 for sh or bash) you cannot get it in your Python script.","Q_Score":3,"Tags":"python,python-3.x,bash","A_Id":54999265,"CreationDate":"2019-03-05T09:00:00.000","Title":"Inheritance of env variables in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using uWSGI to deploy my WSGI application. Are the Python file compiled for every request, or are they precompiled once? I don't see any .pyc files.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":801,"Q_Id":55000167,"Users Score":2,"Answer":"Python caches modules bytecode - directly in the same location for python2.x, under a __pycache__ subfolder for python3 - but scripts (the difference is in usage - if you import it it's a module, if you execute it it's a script) are always recompiled (which is why main scripts are usually very very short an simple).\nIOW, your main wsgi  script will be recompiled once for each new server process. Typically a wsgi app is served as a long running process which will handle much more than one single request, so even then the initial compilation overhead is really not an issue (short script + only compiled once per process)...\nAlso, once a Python process is started, imported modules are cached in memory so they are only really imported (loaded) once per process. \nJust note that the user under which the process is running must have write permissions on your app's directory in order to create the .pyc files... and of course read permissions on the .pyc files too.","Q_Score":2,"Tags":"python,uwsgi,wsgi","A_Id":55002715,"CreationDate":"2019-03-05T10:03:00.000","Title":"Does uWSGI use precompiled Python 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":0,"Web Development":1},{"Question":"I have some custom text editor with multitabs logic, created with Python3 and PyQt5.  I want to open txt-files in this editor with double click and I want to add new tab in my editor each time when I do double-click on file. I added batch, with calls 'python editor.py', when I click on txt. Thats OK, but instead of open new tab in current IDE it always start new python process and open new IDE. I want to make it work on Win10. How to make logic to add new tab to current editor? Probably I don't even need new python process, if my editor is already running.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":55004164,"Users Score":0,"Answer":"Solved with qlocalsocket and qlocalserver!","Q_Score":0,"Tags":"python,python-3.x,pyqt,pyqt5","A_Id":55021494,"CreationDate":"2019-03-05T13:37:00.000","Title":"Add txt file to custom PyQt editor with double click","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning implementation of data structures using python. I realized that __init__ method is used as a constructor (I read that in C++), my doubt is\n\ncan we use some other name like __loader__ instead of __init__ and get results?\n\nIs init a keyword or just a convention like using single underscore in beginning of internally used variable names (ignoring its usage in excluding its imports)","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":776,"Q_Id":55004972,"Users Score":4,"Answer":"__init__ is the method that will be called as part of the instantiation process of the object. If your object doesn't have a method by exactly that name, it won't be called during object instantiation. You can of course call any other method anytime later yourself manually, but it won't be part of the object instantiation.\nIt's not a keyword, but it's a reserved method name for a specific purpose. The same way you couldn't implement a custom comparison function as __foobar__ instead of __lt__ and still expect it to be called when doing a < b.","Q_Score":1,"Tags":"python,keyword","A_Id":55005062,"CreationDate":"2019-03-05T14:22:00.000","Title":"Using some other name for init in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning implementation of data structures using python. I realized that __init__ method is used as a constructor (I read that in C++), my doubt is\n\ncan we use some other name like __loader__ instead of __init__ and get results?\n\nIs init a keyword or just a convention like using single underscore in beginning of internally used variable names (ignoring its usage in excluding its imports)","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":776,"Q_Id":55004972,"Users Score":1,"Answer":"No you can't. You can't because when instancing an object of your class, by default, method object.__init__() will be called (because by default your class inherit from object).\nAnd if you want to initialize your object differently, you have to override this method. And the only way to override a parent class method in python is by defining a child method with the same name, so by defining __init__() in your class.","Q_Score":1,"Tags":"python,keyword","A_Id":55005080,"CreationDate":"2019-03-05T14:22:00.000","Title":"Using some other name for init in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe with a column of user ids converted from int to string\ndf['uid'] = df['uid'].astype(str)\nHowever when I write to csv, the column got rounded to the nearest integer in format 1E+12 (the value is still correct when you select the cell).\nBut to_excel outputs the column correctly, can someone explain a bit?\nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":419,"Q_Id":55010853,"Users Score":3,"Answer":"CSV doesn't have data types.  Excel has no way of knowing what you want, so it tries to interpret it.  If you are using Excel, click the data tab and 'from csv' and you can specify dtypes on reading it.\nOtherwise open the csv file in notepad and you'll see that the data is there.","Q_Score":1,"Tags":"python,pandas","A_Id":55010897,"CreationDate":"2019-03-05T20:15:00.000","Title":"Pandas `to_csv` String column got converted","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to write my program output to a file. However, some of the fields already contain spaces, commas, semicolons, tabs. So I do not want to use spaces, tabs, commas as a field separator. The data are from the web so there are possibilities of server admins using wrong format. \nI though of using any made up string, like my name. But this can be unprofessional if the output might be used by other researchers or so. \nAre there any recommendations in this matter? What should I use if I am afraid to use commas, semicolons, tabs, spaces as separator? \nEDIT:\nFor those answers suggesting using json or csv module, please note that I want to load the file into a MySQL database. I just can specify to MySQL that fields are separated by [some separator]. I also need a simple solution.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2582,"Q_Id":55010902,"Users Score":1,"Answer":"Generally, good separators can be any kind of normal, keyboard-typable symbol that isn't used anywhere else in the data. My suggestion would be either '|' or '\/'.","Q_Score":2,"Tags":"python,separator,file-writing","A_Id":55010943,"CreationDate":"2019-03-05T20:18:00.000","Title":"What are the recommended alternatives to the comma separator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to write my program output to a file. However, some of the fields already contain spaces, commas, semicolons, tabs. So I do not want to use spaces, tabs, commas as a field separator. The data are from the web so there are possibilities of server admins using wrong format. \nI though of using any made up string, like my name. But this can be unprofessional if the output might be used by other researchers or so. \nAre there any recommendations in this matter? What should I use if I am afraid to use commas, semicolons, tabs, spaces as separator? \nEDIT:\nFor those answers suggesting using json or csv module, please note that I want to load the file into a MySQL database. I just can specify to MySQL that fields are separated by [some separator]. I also need a simple solution.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2582,"Q_Id":55010902,"Users Score":0,"Answer":"CSV files typically use quotes around fields that contain field separator characters, and use a backslash or another quote to escape a literal quote.\nCSV is not a well defined format, however, and there are many variants implemented by different vendors. If you want a better-rounded text format that can store structured data you should look into using one of the better defined serialization formats such as JSON and YAML instead.","Q_Score":2,"Tags":"python,separator,file-writing","A_Id":55010948,"CreationDate":"2019-03-05T20:18:00.000","Title":"What are the recommended alternatives to the comma separator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using the stackoverflow data dump, I am analyzing SO posts that are tagged with pytorch or keras. Specifically, I count how many times each co tag occurs (ie the tags that aren't pytorch in a pytorch tagged post). \nI'd like to filter out the tags that are so common they've lost real meaning for my analysis (like the python tag).\nI am looking into Tf-idf\nTF reprensents the frequency of word for each document. However, each co-tag can only occur once for a given post (ie you can't tag your post 'html' five times). So the tf for most words would be 1\/5, and others less (because post only has 4 tags for instance). Is it still possible to do Tf-Idf given this context?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":55012475,"Users Score":0,"Answer":"If you want to filter out tags that are so common, you can use conditional probability. eg: python is so common on posts taged pytorch, so P(python|pytorch) will be hight, likes:0.9. You can find a threshold to filter those tags. \nAssociation rule learning is more suitable and more complex than the above.","Q_Score":0,"Tags":"python,nlp,tf-idf","A_Id":55014376,"CreationDate":"2019-03-05T22:16:00.000","Title":"Tf-idf for SO posts (where tag can only occur once )","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"OK\nI was afraid to use the terminal, so I installed the python-3.7.2-macosx10.9 package downloaded from python.org\nRan the certificate and shell profile scripts, everything seems fine.\nNow the \"which python3\" has changed the path from 3.6 to the new 3.7.2\nSo everything seems fine, correct?\nMy question (of 2) is what's going on with the old python3.6 folder still in the applications folder. Can you just delete it safely? Why when you install a new version does it not at least ask you if you want to update or install and keep both versions?\nSecond question, how would you do this from the terminal?\nI see the first step is to sudo to the root.\nI've forgotten the rest.\nBut from the terminal, would this simply add the new version and leave\nthe older one like the package installer?\nIt's pretty simple to use the package installer and then delete a folder.\nSo, thanks in advance. I'm new to python and have not much confidence \nusing the terminal and all the powerful shell commands.\nAnd yeah I see all the Brew enthusiasts. I DON'T want to use Brew for the moment.\nThe python snakes nest of pathways is a little confusing, for the moment.\nI don't want to get lost with a zillion pathways from Brew because it's\nconfusing for the moment.\nI love Brew, leave me alone.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27436,"Q_Id":55013809,"Users Score":0,"Answer":"Each version of the Python installation is independent of each other. So its safe to delete the version you don't want, but be cautious of this because it can lead to broken dependencies :-).\nYou can run any version by adding the specific version i.e $python3.6 or $python3.7\nThe best approach is to use virtual environments for your projects to enhance consistency. see pipenv","Q_Score":10,"Tags":"python,macos,installation,homebrew","A_Id":66958012,"CreationDate":"2019-03-06T00:43:00.000","Title":"How to update python 3.6 to 3.7 using Mac terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am new in Python programming, and now I use Python for study.\nI read text file to get the data.\nI got string value, for example \"0.710000000000D+02\".\nAnd now, I have to convert this string value into float or decimal number, so I run:\n\n\nval = float(\"0.710000000000D+02\")\n\n\nbut, it failed.\nAnd, I tried another solution as follows:\n\n\nval = [float(x) for x in variable]\n\n\nBut failed also.\nActually, it's only an ordinary decimal value, for example: 1D-02 = 0.01\nAs simple like that. But I have no idea how to solve this problem in Python.\nAnyone can help this problem? Thank you!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":55015481,"Users Score":0,"Answer":"I have a solution.\nJust replace \"D\" to \"e\"\n\n\nstr.replace(\"D\",\"e\")\n\n\nNot a sophisticated way, but it works!","Q_Score":0,"Tags":"python,python-3.x,string,type-conversion,decimal","A_Id":55017837,"CreationDate":"2019-03-06T04:16:00.000","Title":"Convert String Decimal (\"anyValueD+anyValue) to Numeric Decimal in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed tensorflow-gpu and keras on my gpu machine for deep learning training. The tensorflow version is 1.12. However, nyoka (pmml converter package of python) has conflict because of tensorflow dependencies. I think it uses tensorflow 1.2. Can there be any workaround for it?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":171,"Q_Id":55015742,"Users Score":-1,"Answer":"Which version of Nyoka are you using? The issue was there prior to version 3.0.1. The latest version of nyoka (3.0.6) does not have tensorflow as a dependency. Could you try with the latest version?","Q_Score":0,"Tags":"python-3.x,tensorflow,keras,pmml","A_Id":55375736,"CreationDate":"2019-03-06T04:46:00.000","Title":"nyoka package install conflict with keras\/tensorflow version","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I right click and try to rename a variable name in Microsoft Visual Studio Code on Mac OS Mojave, it prompts for the new name, I hit enter and nothing happens. \nI have Python extension and Latex extension installed.\nUsually there are no errors, no nothing. \nSometimes, there's a little box that pops up saying \"No Result. No Result\".\nThe python interpreter I selected was a Conda install.\nI ensured rope, and pylint were installed.\nExpected behaviour:\nright click > rename symbol > type new name > enter > all instances of variable renamed.\nObserved behaviour\nright click > rename symbol > type new name > enter > variable has same name everywhere, including spot of renaming.","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":12652,"Q_Id":55017139,"Users Score":4,"Answer":"I use Pylance with a workspace and had the same issue. For me the solution was to restart the language server (from the Command Palette). I find it faster than closing and opening the folder.\nCtrl+Shift+P > Python: Restart Language Server","Q_Score":35,"Tags":"python,visual-studio-code,anaconda,refactoring,rename","A_Id":67075902,"CreationDate":"2019-03-06T06:46:00.000","Title":"Visual Studio Code (Mac OS) rename symbol doesn't work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I right click and try to rename a variable name in Microsoft Visual Studio Code on Mac OS Mojave, it prompts for the new name, I hit enter and nothing happens. \nI have Python extension and Latex extension installed.\nUsually there are no errors, no nothing. \nSometimes, there's a little box that pops up saying \"No Result. No Result\".\nThe python interpreter I selected was a Conda install.\nI ensured rope, and pylint were installed.\nExpected behaviour:\nright click > rename symbol > type new name > enter > all instances of variable renamed.\nObserved behaviour\nright click > rename symbol > type new name > enter > variable has same name everywhere, including spot of renaming.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":12652,"Q_Id":55017139,"Users Score":0,"Answer":"I just found out that if you use Pylance (Pyright) and have a pyrightconfig.json or a [tool.pyright] section in pyproject.toml, this can cause refactoring to fail.\nIn my case I had not put the localtion of the script into the include array in pyproject.toml so it was giving the \"No results\" error.","Q_Score":35,"Tags":"python,visual-studio-code,anaconda,refactoring,rename","A_Id":68219216,"CreationDate":"2019-03-06T06:46:00.000","Title":"Visual Studio Code (Mac OS) rename symbol doesn't work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I right click and try to rename a variable name in Microsoft Visual Studio Code on Mac OS Mojave, it prompts for the new name, I hit enter and nothing happens. \nI have Python extension and Latex extension installed.\nUsually there are no errors, no nothing. \nSometimes, there's a little box that pops up saying \"No Result. No Result\".\nThe python interpreter I selected was a Conda install.\nI ensured rope, and pylint were installed.\nExpected behaviour:\nright click > rename symbol > type new name > enter > all instances of variable renamed.\nObserved behaviour\nright click > rename symbol > type new name > enter > variable has same name everywhere, including spot of renaming.","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":12652,"Q_Id":55017139,"Users Score":25,"Answer":"It turns out the solution was simple, but frustrating. To do refactoring in VS Code (at least for python) you need to be in a workspace. \nI solved the problem by first closing the open folder I was in:\nFile > Close Folder.\nthen navigating to a sub folder of .py file I was editing, and opening it. In my case it was\n\nClick the little document icon in the upper left of screen\nIn the welcome screen, choose \"open folder\"\nnavigate to my desktop folder (where my .py file is)\n\nNow refactoring works as expected\nClick on file icon in upper left of screen > in the welcome screen","Q_Score":35,"Tags":"python,visual-studio-code,anaconda,refactoring,rename","A_Id":55017235,"CreationDate":"2019-03-06T06:46:00.000","Title":"Visual Studio Code (Mac OS) rename symbol doesn't work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating a Python class which should manage a Docker service via the Python Docker SDK.\nShould I start the Docker container in the constructor of my class or is it better to create a method start() which has to be manually called afterwards (and in the constructor only initialize the class attributes)?\nFor C++ there is the RAII idiom where the connection would be set up in the constructor, for Java I've always heard that the constructor should be light-weight and not do any calculations or other \"heavy\" stuff.\nWhat is the best way in Python?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":156,"Q_Id":55017256,"Users Score":-1,"Answer":"First of all I would like to highlight use of incorrect terminology here. Constructor and Initializer are two different things in Python. Constructors are implemented under the hood with __new__ method and it controls the creation of the object of a class. Initializer use __init__  method and controls the initlialization of the object after it has been created.\nIn almost all cases constructors are called implicitly using base class's implementation of __new__ and you rarely have a need to override it, however with initializer it is the exact opposite, because you would want to customize the object initialization after it has been created.\nNow coming to your question, it depends on how you want to control your application, I do not see any problem if you start the container in the initliazer of the class i.e. inside __init__. What this would do is as soon as the object is created it will fire up the docker container as well.\nHowever if you want to be more explicit about it and want to have separate instance methods for  start and stop, even that would not be a problem, its just that now you need to explicitly call the start method after the object has been created.","Q_Score":1,"Tags":"python,oop","A_Id":55017607,"CreationDate":"2019-03-06T06:53:00.000","Title":"Should Python constructors start services or only initialize variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to send a text file from one serial device(slcan0) to another serial device(slcan1) can this operation be performed in SocketCAN? The serial CAN device I am using is CANtact toolkit. Or can the same operation be done in Python-can?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":485,"Q_Id":55017807,"Users Score":0,"Answer":"When you want to send a text file over the CAN bus, you have to decide which CAN-ID you want so sent for sending and receiving.\nMost likely your text file is larger than 8 bytes, so you would have to use a higher level protocol on CAN.\nISO-TP will allow 4095 of data in one message.\nIf this is still not enough, you would have to invent another protocol for sending and receiving the data. E.g. first send the length of data, then send the data in chunks of 4095 bytes.\nOnce you have figured this out, it does not really matter whether you use SocketCAN, Python-CAN, pyvit or anything else.","Q_Score":0,"Tags":"python,socketcan,python-can","A_Id":55027926,"CreationDate":"2019-03-06T07:34:00.000","Title":"How to send and receive a file in SocketCAN or Python-can?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My problem statement is that i want a call graph of a code in JSON format.\ni went through  through  different packages of python like coverage , pycallgraph ,callgraph ,unittest but none of them were giving output as JSON. pycallgraph was close to my problem statement but not providing output as JSON. \nAny good tools to do that (free tools) or any change in above module source to get JSON as output?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":737,"Q_Id":55021096,"Users Score":0,"Answer":"From the documentation of python call graph:\n\nIt  is  able  to  generate  different  types  ofoutputs  and \n  visualizations.   Initially  Python  Call  Graph  was  only  used \n  to generate DOT files for GraphViz, and as of version 1.0.0, it can\n  also generate JSON files, and GDF files for Gephi. Creating custom\n  outputsis fairly easy by subclassing the Outputclass.\n\nand:\n\nOUTPUT_MODE can be one of graphviz, gephi and json. python_file.py is a\n  python script that will be traced andafterwards, a call graph\n  visualization will be generated\n\nso either set OUTPUT-MODE to json or write an own custom subclass","Q_Score":0,"Tags":"python,json,python-3.x,call-graph,pycallgraph","A_Id":55021383,"CreationDate":"2019-03-06T10:41:00.000","Title":"build a call graph (json as a output) in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to generate image on which will be lines representing distances between frets on guitar. It is supposed to be printed later and act as mask for marking the frets. Therefore, the distances has to be precise.\nHow can i generate image of specific size in centimeters \/ milimeters, so when I print it, it will have same size?\nI can use Python \/ JS \/ Java \/ C++","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":55024085,"Users Score":0,"Answer":"As @Chris G wrote in the comment:\n\nGenerating an image is pixel based. If you create an image that has a line every 300 pixels and print it at 300dpi, the lines will be exactly one inch apart. (dpi = dots per inch). You can set the dpi in Photoshop for instance, then make sure the image is printed @ 100% scaling. (in case it's not clear: the \"digital distance\" doesn't matter, since you can always adjust the dpi to achieve a specific millimeter distance in the printout)\n\nFor example, if I make an image of size 6*300px and 9*300px and I print it with 300dpi, it will be 6x9 inches on paper.","Q_Score":0,"Tags":"javascript,java,python,image,printing","A_Id":55024955,"CreationDate":"2019-03-06T13:19:00.000","Title":"How to generate image of specific real-world size","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If I am within a GUI, interacting with said GUI using python 2.7 and sikulix API. If I click on something from within that GUI that opens another window in full screen, sikulix is currently having difficulty interacting with the newly opened window, it can still for some reason only see the old window even though it is underneath. I am able to make the newly opened window smaller, then take the original window and drag it down to a lower place in the screen, then re-maximize the new window and this will allow me to interact with the new window. --- Is there a better way to do this? (using CentOS)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":623,"Q_Id":55024795,"Users Score":0,"Answer":"Sikuli \"sees\" whatever there is on the screen so if there is a window, Sikuli can't ignore it. What probably happens in your case is that you progress too fast and Sikuli is still observing the previous screen. What you need to do is to wait sufficient time to ensure the new window has actually opened.","Q_Score":0,"Tags":"python-2.7,sikuli,sikuli-x","A_Id":55025126,"CreationDate":"2019-03-06T13:55:00.000","Title":"What is the easiest way to change windows with Sikulix?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a view with two actions.\nFirst one renders FileInput for csv. After submit, I read csv header and render the template for second action with dropdown containing header items. \nAfter dropdown items are selected and submitted, I want to read csv file, saving selected columns to db in second action.\nHow can I pass file from one action to another?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":248,"Q_Id":55026932,"Users Score":0,"Answer":"Short answer: you can't. The solution here is to store the file somewhere and save the file path in session, then read the path back from session and re-read the file.\nAlso, having the same view doing so many things is possibly not the best design, but YMMV...","Q_Score":0,"Tags":"python,django","A_Id":55027170,"CreationDate":"2019-03-06T15:41:00.000","Title":"Django Pass file from one view action to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a view with two actions.\nFirst one renders FileInput for csv. After submit, I read csv header and render the template for second action with dropdown containing header items. \nAfter dropdown items are selected and submitted, I want to read csv file, saving selected columns to db in second action.\nHow can I pass file from one action to another?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":248,"Q_Id":55026932,"Users Score":0,"Answer":"pickle the file and store the pickle details in session from the view and access the pickle details from session in another view .","Q_Score":0,"Tags":"python,django","A_Id":55027637,"CreationDate":"2019-03-06T15:41:00.000","Title":"Django Pass file from one view action to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a vscode extension that includes python stub files for certain modules, that currently i need to pass to python.autoComplete.extraPaths manually, in order for it to hint\/autocomplete.\nIs there a way to provide vscode python certain paths from another available plugin, so that it can auto provide jedi autocomplete, if the two extensions are installed together.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":415,"Q_Id":55027510,"Users Score":0,"Answer":"Your extension could set a person's settings.json for them, but otherwise there is no API in the extension for such a thing.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":55031402,"CreationDate":"2019-03-06T16:09:00.000","Title":"Adding paths to vscode python jedi from another vscode extension","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently ran into a bug using python (v3.6.8) and pandas (v0.23.4) where I was trying to subtract a date offset. However, I accidentally typed two -- signs and it ended up adding the date offset instead. I did some more experimenting and found that 2--1 will return 3. This makes sense since you could interpret that as 2-(-1), but you can go even farther and string a bunch of negatives together 2----1 will return 3. I also replicated this in R and it does the same thing. Can anyone help me understand what's happening here?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":115,"Q_Id":55028071,"Users Score":5,"Answer":"2 - - - - 1 is the same as 2 - ( - ( - ( - 1))) what is the same as \n2 - ( - (1)) = 2 + 1 = 3\nAs soon as number of minuses is even you actually do \"+\".","Q_Score":1,"Tags":"python","A_Id":55028215,"CreationDate":"2019-03-06T16:39:00.000","Title":"Why does 2- - - -1=3?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently ran into a bug using python (v3.6.8) and pandas (v0.23.4) where I was trying to subtract a date offset. However, I accidentally typed two -- signs and it ended up adding the date offset instead. I did some more experimenting and found that 2--1 will return 3. This makes sense since you could interpret that as 2-(-1), but you can go even farther and string a bunch of negatives together 2----1 will return 3. I also replicated this in R and it does the same thing. Can anyone help me understand what's happening here?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":115,"Q_Id":55028071,"Users Score":2,"Answer":"mathematically, it's correct. by why would a programming language allow that? maybe i just lack imagination, but i can't think of any reason why you would want to explicitly string together plus or minus signs. and if you did do that, it is likely a typo as in the original post. if it's done through variables, then it should definitely be allowed (ie, a = -1;  2 -a should be 3). some languages allow for i++ to increment i. and python allows i += 1 to increment i. not throwing a syntax error just seems confusing to me, even if it is mathematically correct.","Q_Score":1,"Tags":"python","A_Id":55028501,"CreationDate":"2019-03-06T16:39:00.000","Title":"Why does 2- - - -1=3?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Anaconda3 5.3.0 64bit.\nDuring installation process, I check the option to add Anaconda in my PATH environment variable. Then it does not recommend me to do that. It says:\n\nInstead, open Anaconda with the Windows Start menu and select \"Anaconda (64-bit)\". This \"add to PATH\" option makes Anaconda get found before previously installed software, but may cause problems requiring you to install and reinstall Anaconda.\n\nWhat does it really mean? I would like to add it to PATH because I would like to work also by means of the command line interface, but I would not like to have problems.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4471,"Q_Id":55029348,"Users Score":1,"Answer":"If Python is already installed and is being used by other programs, setting the conda path again can lead to unwanted conflicts.\nFor this reason Anaconda provides a separate cmd line\/Powershell interface called Anaconda prompt which sets the PATH as long as the shell is open.\nIf you're installing Python for the first time using Anaconda, there shouldn't be any problems.\nYou can create environments using conda if you want to  work with different python versions. Anaconda will automatically set the path for both scenarios once the environment is activated.","Q_Score":4,"Tags":"python,anaconda","A_Id":67709684,"CreationDate":"2019-03-06T17:51:00.000","Title":"why Anaconda does not recommend to set path environment variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My organization uses the lambda handler naming convention of:\n lambda.[team_name]-[function_name]\nIn an attempt to deploy a cloud formation template with a few lambda functions that are named in this way, but deployment fails due to a syntax error in the definition of the function.\nI've tried removing the dashes in the handler name, and this removes the syntax error--but now I don't have permission to work with the lambda function as the handler doesn't follow our naming conventions.\nHas anyone dealt with anything like this, what was your workaround?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1358,"Q_Id":55031481,"Users Score":1,"Answer":"Haven't came across this, but if it brakes with that convention your org have to decide on replacing the convention. And who have a period (.) as a function name. That's a flag for me. \nAnd for the immediate issue, it is the IAM role\/group that was assigned to you doesn't have that modified lambda name. So you cannot  do anything with it","Q_Score":0,"Tags":"python-3.x,amazon-web-services,aws-lambda","A_Id":55033120,"CreationDate":"2019-03-06T20:14:00.000","Title":"AWS Lambda Handler Naming Convention","Data Science and Machine Learning":0,"Database and SQL":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":"Is it possible to train convolutional autoencoder (CAE) with non-square (rectangular) input matrix? All the tutorials and resources I have studied on CAE seems to use squared images. The data I am working with is not image. I have hundreds of single cells and for each cell there is a matrix (genomic data) with thousands of genes in rows and  hundreds of bins in columns (genomic region of interest for each gene divided into the bins of equal size).\nI have tried some models with Keras, but size of input in the encoder part of the model is always different than the size of output matrix in the decoder. So it is giving error. Can someone help me how to solve this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":469,"Q_Id":55031885,"Users Score":0,"Answer":"it is hard to tell what is the issue here since no sample code is provided . However most propably your Matrix is diminsions are odd ( example 9\u00d79 )  or becomes odd while pooling. tofix this issue you need to either pad your input to make the matrix diminsions even . our crop the decoder lsyers of your autoencoder to have a matching output size","Q_Score":1,"Tags":"python,keras,deep-learning,conv-neural-network,autoencoder","A_Id":55385124,"CreationDate":"2019-03-06T20:47:00.000","Title":"Using non-square input matrix for convolutional autoencoder","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The context here is simple, there's a lambda (lambda1) that creates a file asynchronously and then uploads it to S3.\nThen, another lambda (lambda2) receives the soon-to-exist file name and needs to keep checking S3 until the file exists.\nI don't think S3 triggers will work because lambda2 is invoked by a client request\n1) Do I get charged for this kind of request between lambda and S3? I will be polling it until the object exists\n2) What other way could I achieve this that doesn't incur charges?\n3) What method do I use to check if a file exists in S3? (just try to get it and check status code?)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":783,"Q_Id":55031936,"Users Score":0,"Answer":"Let me make sure I understand correctly. \n\nClient calls Lambda1. Lambda1 creates a file async and uploads to S3\nthe call to lambda one returns as soon as lambda1 has started it's async processing. \nClient calls lambda2, to pull the file from s3 that lambda1 is going to push there. \n\nWhy not just wait for Lambda one to create the file and return it to client? Otherwise this is going to be an expensive file exchange.","Q_Score":0,"Tags":"python-3.x,amazon-web-services,amazon-s3,aws-lambda,boto3","A_Id":55032258,"CreationDate":"2019-03-06T20:52:00.000","Title":"Long polling AWS S3 to check if item exists?","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 tuning hyperparameters for a neural network via gridsearch on google colab. I got a \"transport endpoint is not connected\" error after my code executed for 3 4 hours. I found out that this is because google colab doesn't want people to use the platform for a long time period(not quite sure though).\nHowever, funnily, after the exception was thrown when I reopened the browser, the cell was still running. I am not sure what happens to the process once this exception is thrown.\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4543,"Q_Id":55034469,"Users Score":0,"Answer":"In google colab, you can use their GPU service for upto 12 hours, after that it will halt your execution, if you ran it for 3-4 hours, it will just stop displaying Data continuously on your browser window(if left Idle), and refreshing the window will restore that connection.\nIn case you ran it for 34 hours, then it will definitely be terminated(Hyphens matter), this is apparently done to discourage people from mining cryptocurrency on their platform, in case you have to run your training for more than 12 hours, all you need to do is enable checkpoints on your google drive, and then you can restart the training, once a session is terminated, if you are good enough with the requests library in python, you can automate it.","Q_Score":0,"Tags":"python,neural-network,jupyter-notebook,jupyter,google-colaboratory","A_Id":55154500,"CreationDate":"2019-03-07T00:56:00.000","Title":"Google colab Transport endpoint is not connected","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Django and Python 3.7.  I want to write a script to help me easily migrate my application from my local machien (a Mac High Sierra) to a CentOS Linux instance.  I'm using a virtual environment in both places.  There are many things that need to be done here, but to keep the question specific, how do I determine on my remote machine (where I'm deploying my project to), what dependencies are lacking?  I'm using rsync to copy the files (minus the virtual environment)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":55035229,"Users Score":2,"Answer":"On the source system execute pip freeze > requirements.txt, then copy the requiremnts.txt to the target system and then on the target system install all the dependencies with pip install -r requirements.txt.  Of course you will need to activate the virtual environments on both systems before execute the pip commands.\nIf you are using a source code management system like git it is a good idea to keep the requirements.txt up to date in your source code repository.","Q_Score":1,"Tags":"django,python-3.x,centos,dependencies","A_Id":55035280,"CreationDate":"2019-03-07T02:42:00.000","Title":"How do I figure out what dependencies to install when I copy my Django app from one system to another?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I know my question title is a little confusing , but i want to do this : \nI have a project that's include these things : \n1- A landscape page with html,css,...\n2- A Django Admin-Panel for a mysql database . \nI'm using a VPS (Virtual Private Server) , and this VPS have not required disk space , i want to use Django admin-panel in local and give it to my employer , but i dont want to give the source code to him , is there any way to hide the source code from my employer but still give him the django admin panel to use on his own computer ?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":738,"Q_Id":55037608,"Users Score":-1,"Answer":"If you're on the same network and not running Django behind a VM, you can run python manage.py runserver 0.0.0.0.0. Your employer will be able to access your Django admin via your internal IP:80 (or whatever port you choose to use).\nAlternatively you can route your ports and firewall to your local IP port.","Q_Score":0,"Tags":"python,django,django-admin","A_Id":55037843,"CreationDate":"2019-03-07T06:45:00.000","Title":"How to hide source code of django from user?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am implementing a program to sample integers from a categorical distribution, where each integer is associated with a probability. I need to ensure that this program is differentiable, so that back propagation can be applied. I found tf.contrib.distributions.RelaxedOneHotCategorical which is very close to what I am trying to achieve.\nHowever, the sample method of this class returns a one-hot vector, instead of an integer. How to write a program that is both differentiable and returns an integer\/scalar instead of a vector?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":768,"Q_Id":55037810,"Users Score":0,"Answer":"You can do a dot product of the relaxed one hot vector with a vector of [1 2 3 4 ... n]. The result is going to give you the desired scalar.\nFor instance if your one hot vector is [0 0 0 1], then dot([0 0 0 1],[1 2 3 4]) will give you 4 which is what you are looking for.","Q_Score":0,"Tags":"python,tensorflow,tensorflow-probability","A_Id":56431054,"CreationDate":"2019-03-07T06:59:00.000","Title":"TensorFlow: Sample Integers from Gumbel Softmax","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am implementing a program to sample integers from a categorical distribution, where each integer is associated with a probability. I need to ensure that this program is differentiable, so that back propagation can be applied. I found tf.contrib.distributions.RelaxedOneHotCategorical which is very close to what I am trying to achieve.\nHowever, the sample method of this class returns a one-hot vector, instead of an integer. How to write a program that is both differentiable and returns an integer\/scalar instead of a vector?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":768,"Q_Id":55037810,"Users Score":0,"Answer":"You can't get what you want in a differentiable manner because argmax isn't differentiable, which is why the Gumbel-Softmax distribution was created in the first place. This allows you, for instance, to use the outputs of a language model as inputs to a discriminator in a generative adversarial network because the activation approaches a one-hot vector as the temperature changes.\nIf you simply need to retrieve the maximal element at inference or testing time, you can use tf.math.argmax. But there's no way to do that in a differentiable manner.","Q_Score":0,"Tags":"python,tensorflow,tensorflow-probability","A_Id":67752253,"CreationDate":"2019-03-07T06:59:00.000","Title":"TensorFlow: Sample Integers from Gumbel Softmax","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am implementing a program to sample integers from a categorical distribution, where each integer is associated with a probability. I need to ensure that this program is differentiable, so that back propagation can be applied. I found tf.contrib.distributions.RelaxedOneHotCategorical which is very close to what I am trying to achieve.\nHowever, the sample method of this class returns a one-hot vector, instead of an integer. How to write a program that is both differentiable and returns an integer\/scalar instead of a vector?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":768,"Q_Id":55037810,"Users Score":0,"Answer":"The reason that RelaxedOneHotCategorical is actually differentiable is connected to the fact that it returns a softmax vector of floats instead of the argmax int index. If all you want is the index of the maximal element, you might as well use Categorical.","Q_Score":0,"Tags":"python,tensorflow,tensorflow-probability","A_Id":55052713,"CreationDate":"2019-03-07T06:59:00.000","Title":"TensorFlow: Sample Integers from Gumbel Softmax","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dependent variable y and 6 independent variables. I want to make a linear regression out of it. I use sklearn library to do it. \nThe problem is some of my independent variables have correlation more than 0.5. So I can't have them in my model at the same time \nI searched throw internet but didn't find any solution to select best set of independent variables to draw linear regression and output the variables that had been selected.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1223,"Q_Id":55039091,"Users Score":1,"Answer":"You are probably looking for a k-fold validation model.\nThe idea is to randomly select your features, and have a way to validate them against each other.\nThe idea is to train your model with your feature selection on (k-1) partitions of your data. And validate it against the last partition. You do it for each partition and take the average of your score (MAE \/ RMSE for instance)\nYour score is an objectif figure to compare your models aka your features selections","Q_Score":0,"Tags":"python,linear-regression","A_Id":55039173,"CreationDate":"2019-03-07T08:21:00.000","Title":"Python Select variables in multiple linear regression","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Question \ni do have large amount of Unstructured  text data , which i want to classify into different -different sectors .\ni am using a Naive Bayes classifier for it \nNow, my question is what should i pass in Y?? because i don't have a Target values \nand as per the syntax i have to pass it .\nmnb = MultinomialNB()\nmnb.fit(X,y)\nTypeError: fit() missing 1 required positional argument: 'y'\nAs i said i don't have target value.\nHow can i do that?\nHelp will be appreciated","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":55040536,"Users Score":0,"Answer":"The Naive Bayes classifier is a supervised learning method and requires you to train it using labelled data in which you know the targets in advance. You can then use it on unlabelled data to predict future values but you can't train it on data with no target values.\nIt's hard to recommend a different method without knowing more about your task but it sounds like you want to look into unsupervised clustering algorithms. k-means is a relatively simple one to start with.","Q_Score":0,"Tags":"python,classification,naivebayes","A_Id":55041022,"CreationDate":"2019-03-07T09:41:00.000","Title":"Text analysis for unstructured data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"glpsol.exe --help provides the following options: \nOptions specific to the MIP solver:\n--nomip consider all integer variables as continuous (allows solving MIP as pure LP)\n--first branch on first integer variable\n--last branch on last integer variable\n--mostf branch on most fractional variable\n--drtom branch using heuristic by Driebeck and Tomlin\n(default)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":55040678,"Users Score":0,"Answer":"To use --first as branch method\nimport pyomo.environ as pe\nopt_solver = pe.SolverFactory(\"glpk\")\nopt_solver.options[\"first\"] = \"\"","Q_Score":0,"Tags":"python,pyomo,glpk","A_Id":55043641,"CreationDate":"2019-03-07T09:48:00.000","Title":"How can I set the branch method used by glpk solver through pyomo?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to both angular and flask framework so plz be patient with me.\nI'm trying to build a web app with flask as a backend server and Angular for the frontend (I didn't start it yet), and while gathering infos and looking at tutorials and some documentation (a little bit) I'm wondering: \nDoes Angular server and flask server need both to be running at the same time or will just flask be enough? Knowing that I want to send data from the server to the frontend to display and collecting data from users and sending it to the backend. \nI noticed some guys building the angular app and using the dist files but I don't exactly know how that works.\nSo can you guys suggest what should I have to do or how to proceed with this?\nThank you ^^","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1198,"Q_Id":55040986,"Users Score":1,"Answer":"Angular does not need a server. It's a client-side framework so it can be served by any server like Flask. Probably in most tutorials, the backend is served by nodejs, not Flask.","Q_Score":0,"Tags":"angular,python-3.x,flask","A_Id":55041112,"CreationDate":"2019-03-07T10:03:00.000","Title":"Does angular server and flask server have both to be running at the same?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wrote a Django app that collects data from clients and displays them in it's web app.\nNow I want to write a script\/program (WPF or a small Java App) that manages the Django server. Things like Start\/Stop, update Django files, migrate Data etc.\nReason is: I want to stuff all of that into an .exe, maybe with a setup and licensing for my potential customers.\nWhat would be the most professional attempt to do this? I wrote smaller scripts before and built them with pyInstaller, which does not seem to work with Django. Or should I just install a python interpreter with my setup and just run the python files? Then my code would be visible to my customers.\nAny tips are appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":55042674,"Users Score":0,"Answer":"you have two options really. either run the app on the customer's hardware or your own. if you don't want your code exposed you should consider hosting the application yourself and providing them with authentication \nDjango authentication is actually pretty robust, check out these two articles from the official docs. This is a general tutoria on authentication l: docs.djangoproject.com\/en\/2.0\/topics\/auth\/customizing\/\u2026 and this is a broader scope one on django in general docs.djangoproject.com\/en\/2.0\/intro\/tutorial01 \nEdit: just do it here","Q_Score":0,"Tags":"python,django,release","A_Id":55043382,"CreationDate":"2019-03-07T11:25:00.000","Title":"Django Server inside another program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a blog website backend is Python + Django + DRF. On frontend I have React. \nAt the article page I want to have \"related articles\" section and \"popular articles\". The same I want to have for the root page. For me is so important that these sections will be \"user specefic\". For example if user have been reading a lot about \"France\" it would influence to recommended articles and this topic will have more weight than other.\nHow can I do that?\nCan I do that with python?\nWhat technology should I use?\nThank you!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":53,"Q_Id":55043950,"Users Score":1,"Answer":"This Question has nothing to do with Django or Reactjs. What you are looking for are algorithms for recommender systems.","Q_Score":0,"Tags":"python,django,reactjs,django-rest-framework","A_Id":55044483,"CreationDate":"2019-03-07T12:35:00.000","Title":"Make related articles feature with python and django or react","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've tried the following:\npython -m pytest .\/subfolder -k 'test_common_fields'\nThis doesn't work at all. It finds nothing but this test exists in that subfolder's file of the same name 'subfolder\/test_subfolder.py'\nI tried entering full path: -k 'subfolder\/test_subfolder.py::test_common_fields' and without \"subfolder\" path. Nothing.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":55047163,"Users Score":1,"Answer":"On Ubuntu, I generally use py.test --verbose -k testcase_1 test_xyz.py","Q_Score":0,"Tags":"python,pytest","A_Id":55131558,"CreationDate":"2019-03-07T15:17:00.000","Title":"How do you specify the only test to run with pytest k 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":0,"Web Development":0},{"Question":"i created a small python program and freezed it to an *.exe file with the --noconsole option. When I run the program normally it works. But when I put it in the task scheduler that runs it on startup it does not work anymore.\nThe program has no ui. I know that it is not working because it is not writing to a log file. The paths in the program are absolute.\nAny ideas what can cause this problem?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":789,"Q_Id":55047805,"Users Score":0,"Answer":"You will need to do a little troubleshooting to narrow down the problem. I can share some tips.\n\nMake sure you have an exception handler for uncaught exceptions (at the very top) so you are logging those errors to a file. If you don't have one you will never know why your program is crashing. Make sure if you add this you are re-throwing the exception after logging it so the os knows it crashed.\nOpen the task schedule and run the task manually. Make sure the task is allowed to be ran manually (it's in the configuration). If it is allowed to run manually, then it should have no trouble running automatically.\nThe user you're running the task with might be different from the user you are manually running it with. You can try removing the --noconsole option while you are trying to figure out the problem. If it is an issue with your logger not having write access where it needs to, you would not see anything in your logs but can see messages in the console.\nMake sure the working directory of the task is correct. By default it should use the same directory the app is in, but if a path has been entered it can cause issues.","Q_Score":1,"Tags":"python,pyinstaller,taskscheduler","A_Id":55051337,"CreationDate":"2019-03-07T15:49:00.000","Title":"Pyinstaller *.exe in TaskScheduler","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"i created a small python program and freezed it to an *.exe file with the --noconsole option. When I run the program normally it works. But when I put it in the task scheduler that runs it on startup it does not work anymore.\nThe program has no ui. I know that it is not working because it is not writing to a log file. The paths in the program are absolute.\nAny ideas what can cause this problem?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":789,"Q_Id":55047805,"Users Score":0,"Answer":"thanks for the help. I found the problem. I was trying to get information of Duplicati (Backup Software), but the server does start only when somebody is logged in. So the problem was not my program but the start of this other program.\nSolved it through logging my program.","Q_Score":1,"Tags":"python,pyinstaller,taskscheduler","A_Id":55108790,"CreationDate":"2019-03-07T15:49:00.000","Title":"Pyinstaller *.exe in TaskScheduler","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"on Twilio's tutorial it sets action parameter to \/handleDialCallStatus but I have no clue what happens when it redirects to the url. How can I handle the status of calls .How can I redirect to another url when the call has completed","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":620,"Q_Id":55048107,"Users Score":1,"Answer":"Twilio evangelist here.\nWhen the <Dial> call ends, the action URL tells Twilio where to send a GET or POST request. A DialCallStatus is passed to the action URL according to one of the following scenarios:\n\nNobody picks up, DialCallStatus=no-answer\nThe line is busy, DialCallStatus=busy\nWhen calling a conference and the call is connected, DialCallStatus=answered\nSomeone answered the call and was connected to the caller, DialCallStatus=connected\nAn invalid phone number was provided, DialCallStatus=failed\nCall canceled via the REST API before it was answered, DialCallStatus=canceled\n\nHow do you handle these scenarios? In the action attribute URL of the Dial verb.\n<Dial timeout='50' action='your_url'>\nThe web app hosted at this action URL can then look at the DialCallStatus and send a response to Twilio telling it what to do next.\nYou can replace your_url with another URL (absolute or relative) to redirect there, and Twilio will continue the initial call after the dialed party hangs up. No TwiML verbs included after that <Dial> will be reachable, so if you want to take more actions on that initial call, you need to respond to Twilio's request with TwiML instructions on how to handle the call.\nAny TwiML verbs included after this <Dial> will be unreachable, as your response to Twilio takes full control of the initial call. If you want to take more actions on that initial call, you must respond to Twilio's request with TwiML instructions on how to handle the call.\nHope this helps.","Q_Score":1,"Tags":"python,twilio,twilio-api","A_Id":55072306,"CreationDate":"2019-03-07T16:03:00.000","Title":"How to handle dial call status with twilio-python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pycharm\nSSH->Remote docker\nWe are using a remote interpreter for python on Pycharm which works great on an SSH connection. We are in a phase to convert our main work on docker container. It is important for us to keep to the development process on the remote servers and not on the local computer. But it is also important to be able to do it over docker container, and not just ssh as this saves a lot of time and effort when starting a new development server.\nRemote docker -> Securely remote docker\nWhat we are seeking is a way to be able to make a remote docker connection within Pycharm securely.  It seems that when generating the Tls certificate, we need to bind it to the host IP's. This IP\/host bounding prevents us to quickly start new servers for development as this force to generate a certificate per IP.\nMy question, is it possible to make a secure connection for docker engine from Pycharm without bound the remote docker to its host IP?\nEdit:\nPossible option so far\nWild card certificate:\nAs Jan Garaj suggestions, use a wild card certificate. Then connect each new server to a new subdomain. The wild card will be the same for each of them.\nPros: This suppose to do the trick\nCons: It requires to set up a new subdomain for each server\nSSH tunnle\nSet the docker socket to allow connection from localhost. Then each developer can set up an ssh tunnel from his computer to the remote machine. In Pycharm setup python interpeter  to  docker socket via localhost with the same port as the tunnel.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":376,"Q_Id":55049331,"Users Score":1,"Answer":"Use (= buy or create\/install\/use own CA + generate) wildchar TLS certificate, which will cover all current servers and also any new servers.","Q_Score":3,"Tags":"python,python-3.x,docker,pycharm","A_Id":55050534,"CreationDate":"2019-03-07T17:07:00.000","Title":"How to setup a secure connection on remote docker on remote server with pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm programming a game in python3.6. There is some pawns on the board which are instance of the class 'pawn'. There is also boulders on the board which are instance of the class boulder. I just want to store these pawns and boulders in an array, like a numpy.array.\nI have 2 problems : \n\nThere is different type of object in the array, which is not possible with a numpy.array\nHow can I represent an empty cell on my board, because I can't use an object, which has not the same type as the others.\n\nHow can I solve these two problems ? Is there already an object which can represent grid, an array and which accepts different type ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":861,"Q_Id":55050445,"Users Score":2,"Answer":"Use np.dtype(object): np.array(board, dtype=np.dtype(object))\nAs for empty cells: just set them to None.\n\nEdit: as some people have suggested, you might not need a numpy array at all. A list of lists or a dict with tuple indexes might solve your problem just fine and remove the overhead of using numpy.","Q_Score":1,"Tags":"python,arrays,numpy,types,storage","A_Id":55050551,"CreationDate":"2019-03-07T18:21:00.000","Title":"Multi-type storage array in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can I run a google colab (free edition) script and then shut down my computer?\nI am training several deeplearning models with crossvalidation, and therefore I would like to know if I can close the window or the computer with the training running at the same time in the cloud.","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":96447,"Q_Id":55050988,"Users Score":2,"Answer":"use multiprocess in python make one other function and start while loop there! that while loop won't let it sleep!","Q_Score":103,"Tags":"python,google-colaboratory","A_Id":67356441,"CreationDate":"2019-03-07T18:58:00.000","Title":"Can I run a Google Colab (free edition) script and then shut down my computer?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I hope this is not a opinion based question but more like a solutions to a complicated django website. fyi, i am quite a beginner in django. \nfirst of all, i am doing a complicated accounting django website where there are features like:\n\npurchases (purchase order, quotation request, quotation, invoice, do)\nCustom user roles and permissions, because we want user to setup their own roles and permissions system\nsales (POS, stocks, too many to mentions)\nuser and registrations\nincomes & expenses tracking and reporting.\n\nThere are articles and SO's answers about 'many apps vs 1 large app'. My confusion started. I figured out django allows seperating views.py and models.py into multiple file in app\/views and app\/models with init.py imports.\nI personally do not like large app file as it is hard to locate things. I prefer neat structures. But the confusion keeps attacking. I want to do one thing and do it well but it seem like having one large app makes more sense because all the mentioned features are ForeignKey dependent.\nSo, according to your experience. what's your ideal folder structures and solutions to deal with this?\nIf you could provide performance difference that would be helpful.\nUPDATE:\nSince most people said multi apps, I have last question regarding this.\nSince Django app can have models\/ & views\/ folder with  multiple models.py & views.py inside, that means one large app can be seperated into multiple views files inside a views\/ folder. What yall think about this? \nsince this will put all migrations in one place, does it provide long term safety in term of messy things like foreign keys across apps.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1861,"Q_Id":55056365,"Users Score":3,"Answer":"This kind of question I have asked long time back, on different platform. Common answer is \n\nIf you want to reuse that, then create an app or if you don't want\n  then you no need to make a separate app\n\nLet me give you an example. If your project has features like \n\nSharing an Image\nSharing text\nComment on Media and Text\nUpvote and Downvote options\n\nHere an user can share either a image or text and other can comment on it or Upvote\/Downvote it. In this case If you make Comment a separate app and Upvote\/Downvote a separate app, then in future if you have to add Video along with Image and Text, then all you have to link Video to Comment app and Upvote\/DOwnvote app, that will be less task comparing to a big app with all things inside. Also You can manage your database accordingly.\nIn your case, you can make (for example), \n\nCustom User (help you add extra permission in future)\nProduct Category (help you to add more category or subcategory)\nProducts or Sales etc.\n\nFor many admins, when you add those apps to your settings.py, and if you edit admin.py separately in each app, everything will appear your admin panel without any hassle.\nFor many views, you can import all the models to views.py of any app or use it separately in their apps. It will not cause any problem. Same for urls.py and forms.py etc.","Q_Score":3,"Tags":"python,django,django-2.1","A_Id":55058386,"CreationDate":"2019-03-08T03:38:00.000","Title":"Django Structures: Many apps VS one large app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I hope this is not a opinion based question but more like a solutions to a complicated django website. fyi, i am quite a beginner in django. \nfirst of all, i am doing a complicated accounting django website where there are features like:\n\npurchases (purchase order, quotation request, quotation, invoice, do)\nCustom user roles and permissions, because we want user to setup their own roles and permissions system\nsales (POS, stocks, too many to mentions)\nuser and registrations\nincomes & expenses tracking and reporting.\n\nThere are articles and SO's answers about 'many apps vs 1 large app'. My confusion started. I figured out django allows seperating views.py and models.py into multiple file in app\/views and app\/models with init.py imports.\nI personally do not like large app file as it is hard to locate things. I prefer neat structures. But the confusion keeps attacking. I want to do one thing and do it well but it seem like having one large app makes more sense because all the mentioned features are ForeignKey dependent.\nSo, according to your experience. what's your ideal folder structures and solutions to deal with this?\nIf you could provide performance difference that would be helpful.\nUPDATE:\nSince most people said multi apps, I have last question regarding this.\nSince Django app can have models\/ & views\/ folder with  multiple models.py & views.py inside, that means one large app can be seperated into multiple views files inside a views\/ folder. What yall think about this? \nsince this will put all migrations in one place, does it provide long term safety in term of messy things like foreign keys across apps.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1861,"Q_Id":55056365,"Users Score":1,"Answer":"For your own sanity go for multiple apps.\njust lay them out first and figure out what should logically go together in one app and what should go to the next.\nYou want to avoid running into circular imports!\nForeign keys across apps is no problem at all. Basically as soon as u use the USER anywhere in your models, you'll reference across app boundaries already.","Q_Score":3,"Tags":"python,django,django-2.1","A_Id":55067563,"CreationDate":"2019-03-08T03:38:00.000","Title":"Django Structures: Many apps VS one large app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I installed both 'Python 3.7' and 'Anaconda', with adding the installation directories into environmental variable 'PATH'. And now when calling 'python' in windows' cmd, it turned out to be the 'Anaconda' one. Is there any possibility to call another one directly in cmd?\nThanks a lot!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":36,"Q_Id":55059890,"Users Score":1,"Answer":"Try launching it through C:\\Python37\\python.exe from cmd. Basically the path is the installation folder of Python 3.7.","Q_Score":0,"Tags":"python,windows,environment-variables","A_Id":55060242,"CreationDate":"2019-03-08T09:08:00.000","Title":"About the files named identically in different directories in environmental variable 'PATH'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"my problem is the following: I have an application in ruby \u200b\u200bon rails that I would like to update in realtime, second by second. I would not, however, overload the database unnecessarily (because too many users and small server). I would like the ruby \u200b\u200bon rails application to be notified in some way by the mysql database when an update occurred in some datqabase table. It's possible?\nI have a python script that in realtime could populate with new data the mysql tables.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":55060125,"Users Score":0,"Answer":"I'm not sure what problem you're trying to solve. Won't the rails app get the updated data from the db on each request anyway? Are you caching the data? If that's the case just have the python script invalidate the cache.","Q_Score":0,"Tags":"python,mysql,ruby-on-rails,web-applications,real-time","A_Id":55074611,"CreationDate":"2019-03-08T09:22:00.000","Title":"How to correctly update webapp when cron brings new data","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a CSV file with two columns. \nOne has values like size XL, size L, size M and size S. In the other I only have XL and L. \nWhat I want to do is that when my loop finds XL in the first column it overwrites that cell value with XL and when it doesn't find XL in the next cell it should just skip it. \nIn the next iteration, it should do the same with L. The file should look something like this after the loop: XL, L, size M, size S.\nCan you assist me with python code to implement something like this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":55064953,"Users Score":0,"Answer":"I don't understand the question, and would be very confusing for others too.\nHowever, it seems like a simple loop and condition code. Try using PANDAS with Python, the library to process the CSV in case this helps you.","Q_Score":0,"Tags":"python,numpy-slicing","A_Id":55065070,"CreationDate":"2019-03-08T14:10:00.000","Title":"comparing two columns in the same csv file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two scripts (written in Python 3), let's call them A.py and B.py, which I execute at different times. Both scripts rely on the same set of constants I defined, but I will vary their values from time to time. It's clunky though to keep updating the constants in both A.py and B.py.\nTherefore, I'm curious if it is possible to create one script in which I can define the constants used by A.py and B.py, and choose to execute either A.py or B.py.\nMy failed attempt:\nI tried importing A.py and B.py as modules into the script where the constants were defined and running the relevant script from there, but the constants were not found in the namespaces of A.py and B.py when imported, so it didn't work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":335,"Q_Id":55065604,"Users Score":1,"Answer":"You're making it much more complicated than it has to be... Just define your constants in a distinct file (let's name it \"constants.py\") and import it in your A.py and B.py scripts. You just have to make sure that \"constants.py\"i is accessible in your sys.path (the modules search path), but this will be the case if you have all three files in the same directory.","Q_Score":0,"Tags":"python-3.x","A_Id":55065973,"CreationDate":"2019-03-08T14:47:00.000","Title":"Defining constants used in multiple Python scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to poll an HTML API endpoint for new data, and only execute the DAG if new data is present.\nI have a sensor with a standard poke function that will return True if this is the case.\nI'm wondering if it is possible to avoid having the task scheduled, and only execute the task when the sensor returns true? Currently, I'm running the DAG daily and have the sensor timeout after 24h (so there is only ever one concurrently running DAG). However, in case new data comes in twice per day, it will have to wait until the next DAG run to be processed.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1613,"Q_Id":55069341,"Users Score":3,"Answer":"You can use 1 DAG dedicated to sensing. And use another dag to do processing.\n\nSensing DAG:\nsensor keeps poking -> once poke() returns true, use TriggerDagRunOperator to trigger Sensing DAG -> use TriggerDagRunOperator to trigger Processing DAG\n\nProcessing DAG:\nprocess whatever you want","Q_Score":2,"Tags":"python,airflow","A_Id":55072527,"CreationDate":"2019-03-08T18:54:00.000","Title":"Using an Airflow sensor to start a DAG run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to change the font color of a single word in a Tkinter label widget.\nI understand that something similar to what I would like to be done can be achieved with a Text widget.. for example making the word \"YELLOW\" show in yellow: \nself.text.tag_config(\"tag_yel\", fg=clr_yellow)\nself.text.highligh_pattern(\"YELLOW\", \"tag_yel\")\nBut my text is static and all I want is to change the word \"YELLOW\" to show as yellow font and \"RED\" in red font and I cannot seem to figure out how to change text color without changing it all with label.config(fg=clr).\nAny help would be appreciated","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":533,"Q_Id":55069724,"Users Score":1,"Answer":"You cannot do what you want. A label supports only a single foreground color and a single background color. The solution is to use a text or canvas widget., or to use two separate labels.","Q_Score":1,"Tags":"python,python-2.7,tkinter","A_Id":55069875,"CreationDate":"2019-03-08T19:25:00.000","Title":"Change color of single word in Tk label widget","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have all of my TestCase files in a django app called 'tests'. Running a specific TestCase works just fine with this command:\npython run manage.py test tests.myTestCaseFile\nHowever, when i run the entire set of TestCases in the tests folder this fails:\npython run manage.py test tests\nIn this case many ImportErrors are triggered as well as KeyError: 'en-us'. Essentially every single TestMethod errors out in one way or another.\nAny ideas what could be happening here? \nNOTE: I have already tried to import myapp.urls in the shell and reverse(urlname) works just fine there..","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":682,"Q_Id":55070109,"Users Score":3,"Answer":"I've solved this issue:\n\nKeyError: u'en-us' seems to occur anytime there is an import error in any test module\n\nI had a test file which was testing functionality that did not exist in the current branch. \nSeems that an import error in any test file prevents execution of the entire test suite.","Q_Score":1,"Tags":"python,django,django-nose","A_Id":55961188,"CreationDate":"2019-03-08T19:52:00.000","Title":"Django-nose failure - KeyError: u'en-us'","Data Science and Machine Learning":0,"Database and SQL":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 it's possible to run anaconda commands from anaconda prompt but it is more convenient to run it from the powershell of visual studio code like basic python where we can install the package by simply writing 'pip' command. Is there any similar way for anaconda in vscode?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2259,"Q_Id":55074677,"Users Score":0,"Answer":"If you didn't install conda to your PATH then this is by design of conda itself unfortunately.","Q_Score":1,"Tags":"python,visual-studio-code,anaconda,conda","A_Id":55111456,"CreationDate":"2019-03-09T06:29:00.000","Title":"Running Anaconda Command From Visual Studio Code's power shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python, there is such a feature - True and False can be added, subtracted, etc\nAre there any examples where this can be useful?\nIs there any real benefit from this feature, for example, when:\n\nit increases productivity\nit makes the code more concise (without losing speed)\netc","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":55075438,"Users Score":0,"Answer":"I would avoid it at all cost. It is confusing and goes against typing. Python being permissive does not mean you should do it ...","Q_Score":3,"Tags":"python","A_Id":55075475,"CreationDate":"2019-03-09T08:30:00.000","Title":"Usage of arithmetic operations on bool values True and False","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to create an Combobox with checkboxes with wxpython? \nLike most webpages have filter options in a drop down list for products where you could choose which Brand (etc.) you want.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":318,"Q_Id":55076458,"Users Score":1,"Answer":"Try with a ComboCtrl with a CheckListBox popup, or with a wx.ListCtrl plus \nCheckListCtrlMixin if you need more than one column.","Q_Score":1,"Tags":"python,wxpython","A_Id":55080070,"CreationDate":"2019-03-09T10:38:00.000","Title":"wxPython - Combobox with Checkboxes possible?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm currently doing a project on my school pc and I want to use pygame, since I have experience with pygame. I have downloaded pygame using this line in the command prompt python -m pip install -U pygame --user when I try this line python3 -m pygame.examples.aliens that is used to see if pygame is downloaded right, it works fine.\nBut, when I import it in the project I get this error message\n\nFile \"C:\/Users\/user\/Documents\/Programming\/test.py\", line 10, in\n  \n      import pygame\nModuleNotFoundError: No module named 'pygame'\n\nextra info:\nI use Spyder\nIt is a Windows pc\nThanks in advance :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":55078224,"Users Score":0,"Answer":"If you have used pygame before this, then have a look if you have any files named pygame.py as I had the same problem as you and my problem was naming a file the same as a core module so check that. \nI have done the commands that you put and on the python3 -m pygame.examples.aliens. I got a ModuleNotFoundError: No module named 'pygame'. \nWhen I changed the second command to python instead of python3 it worked after I installed pygame like this pip install pygame to uninstall pygame from how you did it when you install pygame change it to uninstall then try this version.","Q_Score":0,"Tags":"python,pygame,spyder","A_Id":55079252,"CreationDate":"2019-03-09T14:15:00.000","Title":"Error importing the installed pygame module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I attempted to use fbprophet for time series analysis using Python.\nI ran from fbprophet import Prophet but got No module named 'fbprophet'\nI think fbprophet is not part of packages that comes with anaconda distribution\nI went ahead to install fbprophet but got this error message No module named 'fbprophet'\nI am on Windows 10, 64 bits\nI install anaconda distribution of anaconda 3.7\nI have ran conda install -c conda-forge fbprophet and conda install -c conda-forge\/label\/cf201901 fbprophet on my anaconda prompt which it rolled endlessly\nI have also ran pip install fbprohet which did not work as well\nI ran pip list which worked but prophet or fbprophet not among the list\nI have searched this site for relevant questions and tried all what I clues I got in it but did not work for me.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":19148,"Q_Id":55078483,"Users Score":0,"Answer":"you just search the wrong letter, please enter pip search fbprophet,in the way, i can get two","Q_Score":4,"Tags":"python,python-3.x,installation,facebook-prophet","A_Id":55078819,"CreationDate":"2019-03-09T14:43:00.000","Title":"How to install fbprophet for Python 3.7 (anaconda distribution)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I attempted to use fbprophet for time series analysis using Python.\nI ran from fbprophet import Prophet but got No module named 'fbprophet'\nI think fbprophet is not part of packages that comes with anaconda distribution\nI went ahead to install fbprophet but got this error message No module named 'fbprophet'\nI am on Windows 10, 64 bits\nI install anaconda distribution of anaconda 3.7\nI have ran conda install -c conda-forge fbprophet and conda install -c conda-forge\/label\/cf201901 fbprophet on my anaconda prompt which it rolled endlessly\nI have also ran pip install fbprohet which did not work as well\nI ran pip list which worked but prophet or fbprophet not among the list\nI have searched this site for relevant questions and tried all what I clues I got in it but did not work for me.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":19148,"Q_Id":55078483,"Users Score":0,"Answer":"First install\npip install httpstan\nThen Install\npip install pystan\nThen Install\npip install fbprophet","Q_Score":4,"Tags":"python,python-3.x,installation,facebook-prophet","A_Id":70970526,"CreationDate":"2019-03-09T14:43:00.000","Title":"How to install fbprophet for Python 3.7 (anaconda distribution)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I attempted to use fbprophet for time series analysis using Python.\nI ran from fbprophet import Prophet but got No module named 'fbprophet'\nI think fbprophet is not part of packages that comes with anaconda distribution\nI went ahead to install fbprophet but got this error message No module named 'fbprophet'\nI am on Windows 10, 64 bits\nI install anaconda distribution of anaconda 3.7\nI have ran conda install -c conda-forge fbprophet and conda install -c conda-forge\/label\/cf201901 fbprophet on my anaconda prompt which it rolled endlessly\nI have also ran pip install fbprohet which did not work as well\nI ran pip list which worked but prophet or fbprophet not among the list\nI have searched this site for relevant questions and tried all what I clues I got in it but did not work for me.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":19148,"Q_Id":55078483,"Users Score":0,"Answer":"fbprophet did not work on Python 3.9\nIt is a very important information, after downgrading Python from 3.9 to 3.8, I use 'conda install fbprophet' install fbprophet successfully","Q_Score":4,"Tags":"python,python-3.x,installation,facebook-prophet","A_Id":72025011,"CreationDate":"2019-03-09T14:43:00.000","Title":"How to install fbprophet for Python 3.7 (anaconda distribution)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I attempted to use fbprophet for time series analysis using Python.\nI ran from fbprophet import Prophet but got No module named 'fbprophet'\nI think fbprophet is not part of packages that comes with anaconda distribution\nI went ahead to install fbprophet but got this error message No module named 'fbprophet'\nI am on Windows 10, 64 bits\nI install anaconda distribution of anaconda 3.7\nI have ran conda install -c conda-forge fbprophet and conda install -c conda-forge\/label\/cf201901 fbprophet on my anaconda prompt which it rolled endlessly\nI have also ran pip install fbprohet which did not work as well\nI ran pip list which worked but prophet or fbprophet not among the list\nI have searched this site for relevant questions and tried all what I clues I got in it but did not work for me.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":19148,"Q_Id":55078483,"Users Score":0,"Answer":"Use conda install gcc to set up gcc. The easiest way to install Prophet is through conda-forge: conda install -c conda-forge prophet.","Q_Score":4,"Tags":"python,python-3.x,installation,facebook-prophet","A_Id":72432495,"CreationDate":"2019-03-09T14:43:00.000","Title":"How to install fbprophet for Python 3.7 (anaconda distribution)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a machine learning project in drive D. It contains python notebook files. But when I launch jupyter notebook through command prompt, it only shows directories inside drive C. How can I navigate to a drive other than C drive without changing jupyter notebook startup path?. I'm using windows 10 operating system. All the solutions I found, trying to change notebook startup path.","AnswerCount":13,"Available Count":3,"Score":0.0153834017,"is_accepted":false,"ViewCount":126747,"Q_Id":55078484,"Users Score":1,"Answer":"*To change just one time :\nuser following code in your Anaconda prompt .\njupyter notebook --notebook-dir=E:\n*To permanently change the default directory of Jupyter do the following:\nRight click on Jupyter notebook icon.\nGo to Properties.\nIn shortcut tab->target you will find something like this -> jupyter-notebook-script.py \"%USERPROFILE%\/\"\nChange %USERPROFILE%\/ to the folder you want to start from eg : jupyter-notebook-script.py \"E:\\folder_path\".\nRestart Jupyter notebook.","Q_Score":84,"Tags":"python,jupyter-notebook","A_Id":71419253,"CreationDate":"2019-03-09T14:43:00.000","Title":"Open Jupyter Notebook from a Drive Other than C Drive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a machine learning project in drive D. It contains python notebook files. But when I launch jupyter notebook through command prompt, it only shows directories inside drive C. How can I navigate to a drive other than C drive without changing jupyter notebook startup path?. I'm using windows 10 operating system. All the solutions I found, trying to change notebook startup path.","AnswerCount":13,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":126747,"Q_Id":55078484,"Users Score":16,"Answer":"To permanently change the default directory of Jupyter do the following:\n\nLook for the Shortcut to open Jupyter notebook.\nRight Click on the Shortcut\nGo to Properties.\nLook for ....jupyter-notebook-script.py \"%USERPROFILE%\/\"\nChange %USERPROFILE%\/ to the folder you wish.\nRestart Jupyter notebook.","Q_Score":84,"Tags":"python,jupyter-notebook","A_Id":56206565,"CreationDate":"2019-03-09T14:43:00.000","Title":"Open Jupyter Notebook from a Drive Other than C Drive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a machine learning project in drive D. It contains python notebook files. But when I launch jupyter notebook through command prompt, it only shows directories inside drive C. How can I navigate to a drive other than C drive without changing jupyter notebook startup path?. I'm using windows 10 operating system. All the solutions I found, trying to change notebook startup path.","AnswerCount":13,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":126747,"Q_Id":55078484,"Users Score":30,"Answer":"Follow these steps:\n\nOpen Anaconda Prompt\nInsert this command,\njupyter notebook --notebook-dir=NameOfTheDrive:.\n\nAs Example for Drive D, jupyter notebook --notebook-dir=D:","Q_Score":84,"Tags":"python,jupyter-notebook","A_Id":59810174,"CreationDate":"2019-03-09T14:43:00.000","Title":"Open Jupyter Notebook from a Drive Other than C Drive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to sort an RDD that I have, which contains a key range of 0-49995 such that (0, value), ... , (49995, value).\nI want to sort it in ascending order, and I am using the SortByKey() function, but it seems like it is not working properly because this is the result that I am getting:\n\n\n\ntest0.sortByKey(True).take(5)\n\n\n\n[(u'0', [u'38737', u'18591', u'27383', u'34211', u'337', u'352', u'1532', u'12143', u'12561', u'17880']), (u'1', [u'35621', u'44891', u'14150', u'15356', u'35630', u'13801', u'13889', u'14078', u'25228', u'13805']), (u'10', [u'83', u'18', u'38', u'89', u'3', u'11', u'29', u'41', u'53', u'55']), (u'100', [u'42704', u'122', u'125', u'128', u'131', u'2501', u'11200', u'12049', u'12576', u'18583']), (u'1000', [u'8671', u'955', u'1012', u'1020', u'1378', u'2413', u'7699', u'10276', u'12625', u'12667'])]\nIt started at key 0, 1, but then skipped to 10 and jumped to 100, then 1000. It should ascending from 0-5. Can someone please tell me what I am doing wrong here?\nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":493,"Q_Id":55085647,"Users Score":0,"Answer":"You are sorting strings - as shown by the u prefix on the output (for Unicode, not that it really matters). Therefore it is working as 10 comes before 2 when tested as a string.\nMap all your values to integers before working with them and you should be fine.","Q_Score":0,"Tags":"python,python-2.7,apache-spark,pyspark","A_Id":55085727,"CreationDate":"2019-03-10T07:57:00.000","Title":"PySpark RDD SortByKey() Not Working Properly","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I'm trying to understand the math involved when trying to translate hexadecimal escape sequences into integers.\nSo if I have the string \"\u00c3\", when I do \"\u00c3\".encode('utf-8') I get a byte string like this \"\\xc3\". ord(\"\u00c3\") is 195. The math is 16*12+3 which is 195. Things makes sense.\nBut if I have the character \"\u00e9\" - then the utf8-encoded hex escape sequence is \"\\xc3\\xa9 - and ord(\"\u00e9\") is 233. How is this calculation performed? (a9 on its own is 169 so it's clearly not addition).\nSimilarly with this '\u012c'.encode('utf-8'). This yields b'\\xc4\\xac'. And ord('\u012c') is 300.\nCan anyone explain the math involved here?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":268,"Q_Id":55085744,"Users Score":0,"Answer":"So, I thought I'd just wrap this one up and post the answers to the math issues I didn't comprehend before receiving a tons of wisdom from SO.\nThe first question regarded \"\u00e9\" which yields \"\\xc3\\xa9\" when encoded with utf8 and where ord(\"\u00e9\") returns 233. Clearly 233 was not the sum of 195 (decimal representation of c3) and 169 (ditto for a9). So what's going on?\n\"\u00e9\" is has the corresponding unicode point U+00E9. The decimal value for the hex e9 is 233. So that's what the ord(\"\u00e9\") is all about.\nSo how does this end up as \"\\xc3\\xa9\"?\nAs J\u00f6rg W Mittag explained and demonstrated, in utf8 all non-ASCII are \"encoded as a multi-octet sequence\".\nThe binary representation of 233 is 11101001. As this is non-ASCII this needs to be packed in a two-octet sequence which according to J\u00f6rg will follow this pattern:\n110xxxxx 10xxxxxx (110 and 10 are fixed leaving room for five bits in the first octet, and six bits in the second - 11 in total). \nSo the 8 bits binary representation of 233 is fitted into this pattern replacing the xx-parts... Since there are 11 bits available and we only need 8 bits we pad the 8 bits with 3 more, 000, (i.e. 00011101001).\n^^^00011 ^^101001 (000 followed by our 8 bits representation of 233)\n11000011 10101001 (binary representation of 233 inserted in a two-octet sequence)\n11000011 equals the hex c3, as 10101001 equals a9- which in other words matches the original sequence \"\\xc3\\xa9\"\nA similar walkthrough for the character \"\u012c\":\n'\u012c'.encode('utf-8') yields b'\\xc4\\xac'. And ord('\u012c') is 300.\nSo again the unicode point for this character is U+012C which has the decimal value of 300 ((1*16*16)+(2*16*1)+(12*1)) - so that's the ord-part.\nAgain the binary representation of 300 is 9 bits, 100101100. So once more there's a need for a two-octet sequence of the pattern 110xxxxx 10xxxxxx. And again we pad it with a couple of 0 so reach 11 bits (00100101100).\n^^^00100 ^^101100 (00 followed by our 9 bits representation of 300)\n11000100 10101100 (binary representation of 300 inserted in a two octet-sequence).\n11000100 corresponds to c4in hex, 10101100 to ac - in other words b'\\xc4\\xac'.\nThank you everyone for helping out on this. I learned a lot.","Q_Score":0,"Tags":"python-3.x,utf-8,hex","A_Id":55093162,"CreationDate":"2019-03-10T08:14:00.000","Title":"How to calculate integer based on byte sequence","Data 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 the recommended workflow if I want to pull a git repo into a virtual Python environment? I think it's easiest to: \n\nCreate an empty directory\ncd into it and git clone <repo>, as this will work only in empty directories\ncreate the virtual environment in a subdir in the same directory\nStart the VE and install requirements.txt from the <repo>.\nAdd the subdir (and other stuff for my eyes only) to .gitignore\nwork on project as intended\nperhaps ask to push valuable\/shareable results to the original repo. \n\nOr is there a better way?\nDisclaimer: I'm quite a n00b with git, please bear with me. I'm well aware there are multiple similar answers already, however I couldn't find a convincing TL;DR. Perhaps I missed it.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":10027,"Q_Id":55087632,"Users Score":3,"Answer":"If there's already an existing virtualenv for a project that you want to clone a library into to work with, the following steps will help you:\n\nActivate the project's virtualenv\nsource .venv\/bin\/activate.fish \nUninstall the package you want to have replaced with a git clone:\npip uninstall <package>\nRe-install the package via git:\npip install -e git+ssh:\/\/git@github.com\/<org>\/<package>.git#egg=<package>\nChange to package directory to work on the repository\ncd .venv\/src\/<package>","Q_Score":6,"Tags":"python,git,virtualenv","A_Id":59627702,"CreationDate":"2019-03-10T12:22:00.000","Title":"Recommended workflow for cloning git into a virtual Python environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to run my program without the standard command window. I know that the standard print() and input() functions will no longer work. I am compiling the program with pyinstaller. My exact command is python -m pyinstaller --onefile <filename>.py Is there a way so that only my GUI shows up when I run the program? Thanks to whoever answers.\nEdit: I have tried to run the program using another program I wrote and compiled, but I still see a window.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":55091888,"Users Score":0,"Answer":"This might not be exact answer to your question but there is an option in windows when you schedule a task in task-scheduler, you can keep the command window hidden while running the program. Try having a look there..","Q_Score":0,"Tags":"python,python-3.x,user-interface,pyinstaller","A_Id":55092076,"CreationDate":"2019-03-10T20:06:00.000","Title":"How to run a program without the command window?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to run my program without the standard command window. I know that the standard print() and input() functions will no longer work. I am compiling the program with pyinstaller. My exact command is python -m pyinstaller --onefile <filename>.py Is there a way so that only my GUI shows up when I run the program? Thanks to whoever answers.\nEdit: I have tried to run the program using another program I wrote and compiled, but I still see a window.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":55091888,"Users Score":0,"Answer":"Try python -m pyinstaller --noconsole --onefile yourscript.py\nIt compiles without a window.","Q_Score":0,"Tags":"python,python-3.x,user-interface,pyinstaller","A_Id":55092456,"CreationDate":"2019-03-10T20:06:00.000","Title":"How to run a program without the command window?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on the following Python codes.\nI am hoping to accomplish the following:\n\nCreate a total_fold_array which will hold 5 items (folds)\nFor each fold, create an array of data from a larger dataset based off of the logic (which I know is correct) inside of my for...zip loop\n\nTo help you understand:\nThe classses and class_weights returns:\n[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0] and [0.14285714 0.14285714 0.14285714 0.14285714 0.14285714 0.14285714\n 0.14285714]\nThe while count !=6 is not working properly. In short, what I am trying to accomplish is to populate the total_fold_array with 5 individual folds, which each contain a number of rows from a dataset.\nAn example of the current_fold_array might be [A,B,C,D], so then ultimately, I have a total_fold_array which has 5 of those individual folds, which would look like [[A,B,C,D,],[A,B,B,C],[A,A,A,A],[B,C,D,D],[B,B,B,C]]\nHowever, this loop does not do that. Instead, it creates total_fold_array with the length of whatever the length of classes is (in this case 7), instead of having 5 folds within.\nMy code is below:\nI am currently getting a total_fold_array containing 7 items, when instead, it should contain 5. Each item within can have as many items as needed, but the total_fold_array should be 5 items long. I believe there is a logic bug in my code, and I am looking for some help. If I were to use a dataset with 5 classes, this works appropriately. \nPlease let me know if I need to make this clearer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":910,"Q_Id":55093027,"Users Score":1,"Answer":"Just before for a_class,a_class_weight in zip(classes, class_weights):, you're initializing total_fold_array to [].\nThat loop executes for exactly as many times as there are elements in classes.\nEach iteration of that loop appends a curr_fold_array to total_fold_array.\nThat is why, at the end of that loop, you have as many elements in total_fold_array, as there are in classes.\nYou've enclosed all of this in while count != 6:. That seems totally unnecessary -- I think that while loop will execute exactly once. You are returning from that function before the second iteration of that while loop can happen. My guess is that you introduced that while loop hoping that it would somehow limit the number of elements in total_fold_array to 5. But that's not going to happen, because, inside that while loop, the for loop grows total_fold_array to have 7 elements, and this happens in the very first iteration of the while loop.","Q_Score":0,"Tags":"python,python-3.x,numpy,for-loop","A_Id":55093212,"CreationDate":"2019-03-10T22:26:00.000","Title":"While Loop in Python - Array Manipulation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to do a regex across multiple files (in this case, log files) where the regular expression might be matching starting conditions in one file, and ending conditions in the next file in filename order?\nI need to match events out of log files where the start of the event can theoretically be towards the end of one file, and the end of the event can be towards the beginning of the next.\nSo far, I have been reading all the files and concatenating them into a string and regexing across that -- however, I've finally run into a situation where doing this is causing a MemoryError (this appears to be somewhere around total of 800MB of log files for a day).\nI'm wondering if there is a way to do this across the files directly, so I don't have to maintain all contents in a variable in memory? Or, if there is another way to do this that is more memory efficient?\nNote: OS is Windows 7","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":55094157,"Users Score":0,"Answer":"If you are on Unix-like OS (Linux, macOS), you could use system tools. cat *.log | grep 'REGEX'. If necessary, you can run that from a Python script using subprocess.run().","Q_Score":0,"Tags":"python,regex","A_Id":55094235,"CreationDate":"2019-03-11T01:33:00.000","Title":"Regex across multiple files where matching results can be across two different files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to do a regex across multiple files (in this case, log files) where the regular expression might be matching starting conditions in one file, and ending conditions in the next file in filename order?\nI need to match events out of log files where the start of the event can theoretically be towards the end of one file, and the end of the event can be towards the beginning of the next.\nSo far, I have been reading all the files and concatenating them into a string and regexing across that -- however, I've finally run into a situation where doing this is causing a MemoryError (this appears to be somewhere around total of 800MB of log files for a day).\nI'm wondering if there is a way to do this across the files directly, so I don't have to maintain all contents in a variable in memory? Or, if there is another way to do this that is more memory efficient?\nNote: OS is Windows 7","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":55094157,"Users Score":0,"Answer":"Process the files one at a time in order, but when you find an event start line, make note of the file and line where you saw it.  When you find the event end line, you'll know everything you need to.","Q_Score":0,"Tags":"python,regex","A_Id":55094348,"CreationDate":"2019-03-11T01:33:00.000","Title":"Regex across multiple files where matching results can be across two different files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know this is an elementary question, but I'm not a python programmer. I have an app that is using the sklearn kit to run regressions on a python server.\nIs there a simple command which will return the predictions or the residuals for each and every data record in the sample?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":12667,"Q_Id":55095437,"Users Score":3,"Answer":"One option is to use fit() to get predictions and residual is simply the difference between the actual value and predictions.","Q_Score":9,"Tags":"python,scikit-learn","A_Id":55095505,"CreationDate":"2019-03-11T04:56:00.000","Title":"In sklearn regression, is there a command to return residuals for all records?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to replace the text in a textbox in Powerpoint with Python-pptx. \nEverything I found online didn't work for me and the documentation isn't that helpful for me.\nSo I have a Textbox with the Text:\n\n$$Name 1$$\n$$Name 2$$\n\nand I want to change the $$Name1 $$  to Tom.\nHow can I achieve that?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1934,"Q_Id":55095821,"Users Score":0,"Answer":"Ok thank you. I just found out, that my PowerPoint example was totaly messed up. No everything works fine with a new PowerPoint blanked","Q_Score":0,"Tags":"python,powerpoint,python-pptx","A_Id":55252503,"CreationDate":"2019-03-11T05:44:00.000","Title":"How Could I replace Text in a PPP with Python pptx?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using gdb from the command line I'm able to break when the shared library is loaded. How can I get the same behavior in VS Code knowing that I have the source code of the shared library?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4779,"Q_Id":55098128,"Users Score":0,"Answer":"Unfortunately there isn't a way to flow from Python code into C code for debugging purposes (only Visual Studio has that ability to my knowledge).","Q_Score":3,"Tags":"python,visual-studio-code,shared-libraries,vscode-debugger","A_Id":55131942,"CreationDate":"2019-03-11T08:50:00.000","Title":"How to configure VS Code to be able to step into a shared library (.so) that is loaded when debugging a Python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"os.path.realpath(__file__)\nreturns\n\/home\/toto\/file:\/home\/toto\/.config\/libreoffice\/4\/user\/uno_packages\/cache\/uno_packages\/lu37847ivic.tmp_\/bal-L-1.1.4.oxt\/python\/rdt_bal.py\nWhy is it starting with this \/home\/toto\/file: instead of given the expected url which is the part after ':'?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":117,"Q_Id":55101111,"Users Score":0,"Answer":"os.path.realpath will first resolve any symbolic links in the path, and then return the absolute path","Q_Score":0,"Tags":"python","A_Id":55101159,"CreationDate":"2019-03-11T11:43:00.000","Title":"os.path.realpath() returns a string starting with my home:","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to execute short python expressions in one line in terminal, without passing a file? \ne.g. (borrowing from how I would write an awk expression)\npython 'print(\"hello world\")'","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":215,"Q_Id":55101575,"Users Score":3,"Answer":"python3 -c \"print('Hello')\"\nUse the -c flag as above.","Q_Score":0,"Tags":"python,terminal","A_Id":55101619,"CreationDate":"2019-03-11T12:10:00.000","Title":"Running python directly in terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is it possible to execute short python expressions in one line in terminal, without passing a file? \ne.g. (borrowing from how I would write an awk expression)\npython 'print(\"hello world\")'","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":55101575,"Users Score":0,"Answer":"For completeness, I found you can also feed a here-string to python. \npython <<< 'print(\"hello world\")'","Q_Score":0,"Tags":"python,terminal","A_Id":55103516,"CreationDate":"2019-03-11T12:10:00.000","Title":"Running python directly in terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How to expire django rest framework JWT token manually ? Because it does not store the token in the database. Is there any correct way to expire the token ? \nI am thinking to continue with middleware where token will be stored per user. At every login request we will update the token in the db for a user. At every request, we will fetch the token from request and comapre with the stored token and if doesnt match then we'll return the forbidden. I dont know its a correct way or not !!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1025,"Q_Id":55101650,"Users Score":2,"Answer":"You can't expire JWT token, the token is self contained and can only be expired after amount of time that's stored in its payload.\nWhat you can do is to use both refresh and access token, and set little amount of time for access token. With that being said you FE should update access token when it's expired. You should store your refresh token in database, and when you need to delete access token, you can stop user from updating it using refresh token.\nEDIT:\nIf you want to store token in database, you probably don't wanna use JWT and stateless authorization at all. Instead stick with session based authorization. When you want to expire token - you can just delete session from DB.\nUPDATE 2:\nWhat people usually do in this situation is having a fast-access DB (like redis) that has very few items. Instead of storing jwt token in the database we create a table that contains blocked tokens (I assume the amount of deleted tokens would be much less than amount of alive ones). BUT, now you sacrifice stateless authorization in favor of checking if a token is in the database every time you authorize a user.","Q_Score":4,"Tags":"django,python-3.x,django-rest-framework,jwt,django-rest-framework-jwt","A_Id":55101714,"CreationDate":"2019-03-11T12:14:00.000","Title":"Django rest framework JWT , delete the jwt token","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have trained a single layer neural network model in python (a simple model without keras and tensorflow).\nHow canI save it after training along with weights in python, and how to load it later?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":10072,"Q_Id":55102781,"Users Score":1,"Answer":"So you write it down yourself. You need some simple steps:\n\nIn your code for neural network, store weights in a variable. It could be simply done by using self.weights.weights are numpy ndarrays. for example if weights are between layer with 10 neurons to layer with 100 neurons, it is a 10 * 100(or 100* 10) nd array.\nUse numpy.save to save the ndarray.\nFor next use of your network, use numpy.load to load weights\nIn the first initialization of your network, use weights you've loaded.\nDon't forget, if your network is trained, weights should be frozen. It can be done by zeroing learning rate.","Q_Score":6,"Tags":"python,scikit-learn,pickle","A_Id":55103222,"CreationDate":"2019-03-11T13:21:00.000","Title":"How to save and load my neural network model after training along with weights in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a docx file with my python code using a html content. Im directly writing into file with .docx extension.\n   This is opening in Libre office but unfortunately in MS Word it is not opening. It showing as corrupted format. Why this is happening?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":55104454,"Users Score":0,"Answer":"I was wrong. MS word wont support .docx format. Instead use .doc format which will support in both application!!!","Q_Score":0,"Tags":"html,python-2.7,docx","A_Id":55512004,"CreationDate":"2019-03-11T14:47:00.000","Title":"Save html content as docx format which is not opening in ms word","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a scenario to migrate SQL Server tables(30- 40 tables) to Oracle. I Cannot depend on SSIS as the no of tables to be migrated to Oracle will change regularly and I cannot always create or update a DFT when ever there is a change in schema.\nIs there any other way where the movement of data can be handled dynamically and can work effectively ? Like using Python or any other Programming languages ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":862,"Q_Id":55104895,"Users Score":0,"Answer":"Here is the approach I have decided to go considering the time constraint( using C# is taking more time).For 8 GB table it is taking 11 minutes to move the data SQL to Oracle.\nSteps:\n\nDump the SQL tables data into flat files.(Used BIML for automating\nthe DFT creation) \nTransfer these flat files to the Destination server.\nUsing SQL*Loader to load data from flat files to Oracle.","Q_Score":1,"Tags":"python,sql-server,oracle,ssis,etl","A_Id":55210016,"CreationDate":"2019-03-11T15:08:00.000","Title":"Migrating multiple tables data from SQL Server to Oracle","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a scraper for the dark web. One step involves creating a torrc file in \/etc\/tor\/, which requires root access. To do this, I just run the python file  with sudo (i.e. 'sudo python filename.py').\nHowever, I encountered an error with selenium:\nRunning Firefox as root in a regular user's session is not supported\nI googled the error and found solutions on how to bypass that. I would rather not run it as root if possible. \nHow can I run the first part of the code as root, but not the second part?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":55108034,"Users Score":0,"Answer":"UNIX\/Linux does not blithely turn root privilege on and off quite so easily.  You need to isolate the root portions in a separate script and run only those parts under root privilege.  This is also basic system security: grant only the needed privilege for any function.","Q_Score":0,"Tags":"python,linux,selenium,sudo","A_Id":55108243,"CreationDate":"2019-03-11T18:17:00.000","Title":"How do I control what parts of a python script run as root","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a scraper for the dark web. One step involves creating a torrc file in \/etc\/tor\/, which requires root access. To do this, I just run the python file  with sudo (i.e. 'sudo python filename.py').\nHowever, I encountered an error with selenium:\nRunning Firefox as root in a regular user's session is not supported\nI googled the error and found solutions on how to bypass that. I would rather not run it as root if possible. \nHow can I run the first part of the code as root, but not the second part?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":55108034,"Users Score":0,"Answer":"I\u2019m not familiar with Tor, but you can try to relax the rights on the tor file.\nRunning something similar to chmod +x \/etc\/tor\/your_file that will allow Firefox to use the file even if not run as a privileged user.","Q_Score":0,"Tags":"python,linux,selenium,sudo","A_Id":55108245,"CreationDate":"2019-03-11T18:17:00.000","Title":"How do I control what parts of a python script run as root","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting the error\ndjango.db.utils.OperationError: FATAL:database \"\/path\/to\/current\/project\/projectname\/databasename\" does not exist.\nI have accessed the database both manually through psql, as well as through pgadmin4, and have verified in both instances that the database does exist, and I have verified that the port is correct.\nIm not sure why I cant access the database, or why it would say the database cannot be found.\nAccording to pgAdmin4, the database is healthy, and it is receiving at least 1 I\/O per second, so it can be read and written to by...something?\nI have installed both the psycopg2 and the psycopg2-binary just to be safe.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":55109206,"Users Score":0,"Answer":"I figured out the answer, or at least I do believe I did. It was a two part problem.\nPart of it was I left os.path.join(base_dir...) included as part of the '' name section.\nThe other was I used an \"@\" character as part of my password. Once I changed the password, and I removed the os.path.join(base_dir...) portion, it worked.","Q_Score":0,"Tags":"python,django,web","A_Id":55109207,"CreationDate":"2019-03-11T19:42:00.000","Title":"Having issues connecting to PostgreSQL Database in Django","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I looked at google for a solution based on python, but did not find any... \nMy python script is trying to edit an xlsx that might be opened by another user from MS excel.\nIf I try to overwrite the .xlsx file or the ~$*.xlsx file, I get a winError 32:\n 'process cannot access the file because it is being used by another process'\nMy problem is that users around me use MS excel to look at this output... And MS excel always lock the files that are open, by default.\nIt there a way to 'steal' the access from the other users. (As they are not editing it anyway).\nI cannot not change the user permission (I think) as I am not admin of the files.\nI am using windows 10.\nThanks for your advices.\ncheers.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":619,"Q_Id":55114265,"Users Score":0,"Answer":"There really is no way around this - it is Excel preventing any other process on the system from obtaining write access.\nIf it were running on the same machine, you could consider connecting to the running Excel instance and getting it to close and reopen the document after opening it for writing yourself, but in your example it would likely be opened by someone on another machine.\nThe only solution here is to instruct your users to open the worksheet as read-only, which is an option every version of Excel allows, in which case you might be able to open it for writing. Whether that will allow you to update it while they are looking at it, is doubtful - you likely may want to look into connecting to an Excel sheet on OneDrive or SharePoint (or Teams etc. that use SharePoint as a back-end).","Q_Score":0,"Tags":"python,excel,xlsx","A_Id":55114378,"CreationDate":"2019-03-12T04:37:00.000","Title":"Python: Edit a xlsx file open by another user","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python application that I've created an executable of, using pyinstaller. The entire python interpreter is packaged into the executable with all its pip dependencies.\nSo now my application can run in environments where python or python modules may not be installed, but there are still some dependencies:\n1) MongoDB - This is the database my application uses, and it needs to be installed on a system for it to work of course.\n2) Mosquitto - This service is required because the application uses MQTT to receive\/send commands.\nMy current method of handling this is to use a shell script which installs mongodb and mosquitto the first time when my application is deployed somewhere. I just discovered docker, and I was wondering if it is capable of packaging these 'external' dependencies into a docker image?\nIs it possible for me to have one standalone \"thing\" which will run in any environment regardless of whether mongoDB or mosquitto are installed there?\nAnd how exactly would I go about doing this?\n(Unrelated but this application is meant to run on a raspberry pi)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1200,"Q_Id":55116677,"Users Score":1,"Answer":"If you adopted Docker here:\nYou'd still have to \"separately\" run the external services; they couldn't be packaged into a single artifact per se.  There's a standard tool called Docker Compose that provides this capability, though, and you'd generally distribute a docker-compose.yml file that describes how to run the set of related containers.\nIt's unusual to distribute a Docker image as files; instead you'd push your built image to a registry (like Docker Hub, but the major public-cloud providers offer this as a hosted service, there are a couple of independent services, or you can run your own).  Docker can then retrieve the image via HTTP.\nDocker containers can only be run by root-equivalent users.  Since you're talking about installing databases as part of your bringup process this probably isn't a concern for you, but you could run a plain-Python or pyinstallered application as an ordinary user.  Anyone who can run any Docker command has unrestricted root-level access on the host.","Q_Score":1,"Tags":"python,mongodb,docker,pyinstaller","A_Id":55119757,"CreationDate":"2019-03-12T08:04:00.000","Title":"Python: Question about packaging applications docker vs pyinstaller","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have made a custom NER model using spaCy by loading the training data from a text file in the prescribed format and the model is working fine, However If I am trying to load training data from excel file we get the output model but does not getting the entities(no output and also no error).\nModel from the training data in text file is working perfectly giving proper outputs but not getting results if loading training data from xlsx file.\nNo problem in datatypes(same for both the cases).\nEven If I am writing the same into a text file and then loading it , facing same issue","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":371,"Q_Id":55117481,"Users Score":0,"Answer":"Please write the code after 4 space you will get proper format in stack overflow or ctrl+k then write the code.","Q_Score":1,"Tags":"python,xlrd,spacy","A_Id":55223274,"CreationDate":"2019-03-12T08:57:00.000","Title":"spaCy 2.0: Loading Training Data from excel file Custom NER Model issues","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python. I am currently doing a project which is kind of automation. The overall theme is get input via Chatbot and automate through PythonAutoGUI. I have downloaded one Chatbot. It consisted of AIML. Can we intgrate Python code inside AIML? Is it possible? If it is, How? I can't find relevant tutorials or information regarding this. Cheers!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":55118001,"Users Score":0,"Answer":"Have you tried Program-y it\u2019s 100% python and full aiml 2 compliant and has custom extensions to call python objects","Q_Score":0,"Tags":"python,pyautogui,aiml","A_Id":55191637,"CreationDate":"2019-03-12T09:25:00.000","Title":"How can we integrate Python code in AIML?","Data 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 calculate noise for input data using the gradient of the loss function from the input-data:\nmy_grad = tf.gradients(loss, input)\nloss is an array of size (n x 1) where n is the number of datasets, m is the size of the dataset, input is an array of (n x m) where m is the size of a single dataset.\nI need my_grad to be of size (n x m) - so for each dataset the gradient is calulated. But by definition the gradients where i!=j are zero - but tf.gradients allocates huge amount of memory and runs for prettymuch ever...\nA version, which calulates the gradients only where i=j would be great - any Idea how to get there?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":55121377,"Users Score":0,"Answer":"I suppose I have found a solution:\nmy_grad = tf.gradients(tf.reduce_sum(loss), input)\nensures, that the cross dependencies i!=j are ignored - that works really nicely and fast..","Q_Score":1,"Tags":"python,tensorflow,diagonal,gradient","A_Id":55122132,"CreationDate":"2019-03-12T12:23:00.000","Title":"tf.gradient acting like tfp.math.diag_jacobian","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Everything was working perfectly until today, when for some reason my python.exe file disappeared from the Project Interpreter in Pycharm.\nIt was located in C:\\users\\my_name\\Anaconda3\\python.exe, and for some reason I can't find it anywhere!\nYet, all the packages are here (in the site-packages folder), and only the C:\\users\\my_name\\Anaconda3\\pythonw.exe is available.\nWith the latest however, some packages I installed on top of those available in Anaconda3 won't be recognized.\nTherefore, how to get back the python.exe file?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":3410,"Q_Id":55124386,"Users Score":1,"Answer":"The answer repeats the comment to the question.\nI had the same issue once after Anaconda update - python.exe was missing. It was Anaconda 3 installed to Program Files folder by MS Visual Studio (Python 3.6 on Windows10 x64).\nTo solve the problem I manually copied python.exe file from the most fresh python package available (folder pkgs then folder like python-3.6.8-h9f7ef89_7).","Q_Score":3,"Tags":"python,pycharm,anaconda,exe,pythoninterpreter","A_Id":55125807,"CreationDate":"2019-03-12T14:50:00.000","Title":"Lost my python.exe in Pycharm with Anaconda3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Everything was working perfectly until today, when for some reason my python.exe file disappeared from the Project Interpreter in Pycharm.\nIt was located in C:\\users\\my_name\\Anaconda3\\python.exe, and for some reason I can't find it anywhere!\nYet, all the packages are here (in the site-packages folder), and only the C:\\users\\my_name\\Anaconda3\\pythonw.exe is available.\nWith the latest however, some packages I installed on top of those available in Anaconda3 won't be recognized.\nTherefore, how to get back the python.exe file?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3410,"Q_Id":55124386,"Users Score":0,"Answer":"My Python.exe was missing today in my existing environment in anaconda, so I clone my environment with anaconda to recreate Python.exe and use it again in Spyder.","Q_Score":3,"Tags":"python,pycharm,anaconda,exe,pythoninterpreter","A_Id":63613700,"CreationDate":"2019-03-12T14:50:00.000","Title":"Lost my python.exe in Pycharm with Anaconda3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Everything was working perfectly until today, when for some reason my python.exe file disappeared from the Project Interpreter in Pycharm.\nIt was located in C:\\users\\my_name\\Anaconda3\\python.exe, and for some reason I can't find it anywhere!\nYet, all the packages are here (in the site-packages folder), and only the C:\\users\\my_name\\Anaconda3\\pythonw.exe is available.\nWith the latest however, some packages I installed on top of those available in Anaconda3 won't be recognized.\nTherefore, how to get back the python.exe file?","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":3410,"Q_Id":55124386,"Users Score":3,"Answer":"I just had the same issue and found out that Avast removed it because it thought it was a threat. I found it in Avast -> Protection -> Virus Chest. And from there, you have the option to restore it.","Q_Score":3,"Tags":"python,pycharm,anaconda,exe,pythoninterpreter","A_Id":64929387,"CreationDate":"2019-03-12T14:50:00.000","Title":"Lost my python.exe in Pycharm with Anaconda3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"dict = {'a':1, 'b':2}\ndict.keys gives dict_keys(['a', 'b'])\ndict.values gives dict_values([1, 2]).\nCan someone give examples how dict_keys and dict_values come handy? Why dictionary returns these types instead of just returning a list?\nI often do list(dict.keys) and list(dict.values), converting into a list to loop over.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2479,"Q_Id":55125342,"Users Score":5,"Answer":"Perhaps you have the question the other way around: why should these methods return a list?\nAs the comments point out, if these methods had to return lists, then this list would have to be made first. By contrast, you can iterate over the dict_keys and dict_values objects without creating an entire big list. (You say you often cast these objects to lists, to loop over them. You don't need to do this: you can loop over the objects directly, as in for value in my_dict.values().)\nIf you really need a list (which is usually not the case, mind you), then consider that it's better to be explicit, and create a list yourself: x = list(my_dict.keys()).","Q_Score":5,"Tags":"python,dictionary","A_Id":55125516,"CreationDate":"2019-03-12T15:34:00.000","Title":"usage of \"dict_value\" and \"dict_key\" in python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pre-trained XGBoost model read from a pickle file. When I was trying to make predictions on a new dataset with some columns outside of the feature set of the model, I received the error message:\n\ntraining data did not have the following fields: column1, column2,...\n\nI am okay with excluding these columns not existing in training data. Instead of hard-coding the column names (there are many), I would like to just find the intersection between columns of the training and the prediction datasets. \nIs there a way I can extract the feature names from the trained model (apparently the model recorded the field names) without having to go back to my training dataset?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1723,"Q_Id":55126903,"Users Score":0,"Answer":"Its mandatory that prediction dataset should contain only those columns which are present in training dataset. It even makes sense not to include extra columns because the weights are learnt based on your training dataset. Including any extra column apart from training dataset doesn't provide any value or improve your accuracy, because when you are predicting all you do is multiply the learnt weights of model with new values. Make sure not to inlcude any extra feature for predicting.","Q_Score":2,"Tags":"python,scikit-learn,xgboost","A_Id":55127590,"CreationDate":"2019-03-12T16:58:00.000","Title":"extract feature names from trained model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"the code is supposed to give 3 questions with 2 attempts. if the answer is correct the first try, 3 points. second try gives 1 point. if second try is incorrect, the game will end.\nhowever, the scores are not adding up to create a final score after the 3 rounds. how do i make it so that it does that?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":62,"Q_Id":55128175,"Users Score":2,"Answer":"First move import random to the top of the script because you're importing it every time in the loop and the score is calculated just in the last spin of the program since you empty scoreList[] every time","Q_Score":0,"Tags":"python","A_Id":55128549,"CreationDate":"2019-03-12T18:13:00.000","Title":"trouble with appending scores in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a requirement in which I need to automate the start and stop of the AWS EC2 Instances (within Autoscaling group) daily. This is mainly to prevent cost. I have built a Python script to start and stop EC2 instances but it's not working properly as EC2 instances are within an Autoscaling group.\nDoes anybody know any solution for this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":409,"Q_Id":55130327,"Users Score":0,"Answer":"What you need to do is automate the auto scaling parameters, for desired instances, min instances and max instances. Ideally, you want to change the desired instance amount. This will cause the auto scaler to terminate excessive instances, to meet the desired instance amount.","Q_Score":0,"Tags":"python,amazon-web-services,autoscaling","A_Id":55130351,"CreationDate":"2019-03-12T20:41:00.000","Title":"Start and stop AWS EC2 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":1},{"Question":"I have installed Dask on OSX Mojave. Does it execute computations in parallel by default? Or do I need to change some settings?\nI am using the DataFrame API. Does that make a difference to the answer?\nI installed it with pip. Does that make a difference to the answer?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":136,"Q_Id":55133058,"Users Score":1,"Answer":"Yes, Dask is parallel by default. \nUnless you specify otherwise, or create a distributed Client, execution will happen with the \"threaded\" scheduler, in a number of threads equal to your number of cores. Note, however, that because of the python GIL (only one python instruction executed at a time), you may not get as much parallelism as available, depending on how good your specific tasks are at releasing the GIL. That is why you have a choice of schedulers.\nBeing on OSX, installing with pip: these make no difference. Using dataframes makes a difference in that it dictates the sorts of tasks you're likely running. Pandas is good at releasing the GIL for many operations.","Q_Score":0,"Tags":"python,dask,dask-distributed","A_Id":55143748,"CreationDate":"2019-03-13T01:30:00.000","Title":"Dask on single OSX machine - is it parallel by default?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python, can any object be coerced into a string unless its __str__ method is overloaded to raise an exception?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":135,"Q_Id":55133476,"Users Score":1,"Answer":"Yes, any Python object can be converted to a str.","Q_Score":0,"Tags":"python","A_Id":55133501,"CreationDate":"2019-03-13T02:33:00.000","Title":"Are there objects that cannot be coerced into a string in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been looking into the hyperledger indy framework and I wanted to start to build an app to get started but I noticed that there's the sdk that uses Libindy but there's also the Libvcx that is on top of Libindy but I don't know which one to use since they both seem to do the same.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":918,"Q_Id":55133748,"Users Score":1,"Answer":"The indy-sdk repository is the Indy software that enables building components (called agents) that can interact with an Indy ledger and with each other.\nIn 2019, at a \"Connect-a-thon\" in Utah, USA, developers from a variety of organizations gathered to demonstrate interoperability across a set of independently developed agent implementations. At that time, a further idea developed that led to the creation of Hyperledger Aries. What if we had agents that could use DIDs and verifiable credentials from multiple ecosystems? Aries is a toolkit designed for initiatives and solutions focused on creating, transmitting, storing and using verifiable digital credentials. At its core are protocols enabling connectivity between agents using secure messaging to exchange information.\nLibvcx is a c-callable library built on top of libindy that provides a high-level credential exchange protocol. It simplifies creation of agent applications and provides better agent-2-agent interoperability for Hyperledger Indy infrastructure.\nYou need LibVCX if you want to be interoperably exchange credentials with other apps and agents, in others words if you want to be comply with Aries protocol.\nIn this case LibVCX Agency can be used with mediator agency which enables asynchronous communication between 2 parties.","Q_Score":4,"Tags":"python,hyperledger-indy","A_Id":63579718,"CreationDate":"2019-03-13T03:08:00.000","Title":"What's the difference between hyperledger indy-sdk and Libvcx?","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 looking into the hyperledger indy framework and I wanted to start to build an app to get started but I noticed that there's the sdk that uses Libindy but there's also the Libvcx that is on top of Libindy but I don't know which one to use since they both seem to do the same.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":918,"Q_Id":55133748,"Users Score":7,"Answer":"As you've said, LibVCX is built on top of LibIndy. \nLibIndy\nProvides low level API to work with credentials and proofs. It provides operations to create create credential requests, credentials, proofs. It also exposes operations for communication with Hyperldger Indy ledger. \nWhat Libindy doesn't handle is the credential exchange. If you write backend which issues credential and a mobile app which can request and receive credentials using Libindy, you'll have to come up with some communication protocol to do so. Is it gonna be HTTP? ZMQ? How are you going to format messages? This is what LibVCX does for you. You will also have to come up with solution how will you securely deliver messages and credentials from server to client when the client is offline.\nLibVCX\nLibVCX is one of several implementations of Hyperledger Aries specification. LibVCX is built on top of LibIndy and provides consumer with OOP-style API to manage connections, credentials, proofs, etc. It's written in Rust and has API Wrappers available for Python, Javascript, Java, iOS.\nLibVCX was designed with asynchronicity in mind. LibVCX assumes existence of so called \"Agency\" between the 2 parties communicating - a proxy which implements certain Indy communication protocol, receives and forwards messages. Therefore your backend server can now issue and send a credential to someone whom it has talked to days ago. The credential will be securely stored in the agency and the receiver can check whether there's any new messages\/credentials addressed for him at the agency.\nYou can think of agency as a sort of mail server. The message is stored there and the client can pull its messages\/credentials and decrypt them locally.\nWhat to use?\nIf you want to leverage tech in IndySDK perhaps for a specific use case and don't care about Aries, you can use vanilla libindy.\nIf you want to be interoperably exchange credentials with other apps and agents, you should comply with Aries protocol. LibVCX is one of the ways to achieve that.","Q_Score":4,"Tags":"python,hyperledger-indy","A_Id":55600304,"CreationDate":"2019-03-13T03:08:00.000","Title":"What's the difference between hyperledger indy-sdk and Libvcx?","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 a total newbie question, but I installed conda along with a bunch of other stuff like Tensorflow with a virtual environment, and now I'm a little confused.  If I open a terminal my python is pointing to \/usr\/bin\/python.  If I go to the base environment (\"conda activate base\"), my path points to where I installed anaconda, \/usr\/local\/anaconda2.  Does conda expect that I always go into the base environment to use all the anaconda packages, or did I do something weird on my install that my non-environment still points to the original system python?  Should I just change my path to point to anaconda? I'm on Ubuntu 18.10.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2114,"Q_Id":55133808,"Users Score":0,"Answer":"I am a fan of being explicit -- instead of running python at the command line, I use the full path to the python interpreter when running scripts (e.g. \/usr\/local\/anaconda2\/bin\/python) -- this way I don't rely on the shell behavior or having to worry about which environment is currently active. Running the interpreter using its full path is no different than just running python while the environment is active.\nBut that's not everbody's cup of tea... So...\nEven if anaconda did not prompt you to update your PATH variable, you can do it explicitly by updating your .bashrc or .bash_profile (or .zshrc or whatever else) by adding this line: PATH=\/usr\/local\/anaconda2\/bin${PATH}. Dont forget to re-source the .bashrc or close\/reopen your shell for it to take effect.\nConda is capable of creating many virtual environments beyond the base, so if you have more than one and you want to set one as the default, then just update the line above for the appropriate path.","Q_Score":4,"Tags":"python,anaconda","A_Id":55134899,"CreationDate":"2019-03-13T03:16:00.000","Title":"With conda\/anaconda should I work in (base) all the time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I\u2019ve been using the Luigi visualizer for pipelining my python code.\nNow I\u2019ve started using an aws instance, and want to access the visualizer from my own machine.\nAny ideas on how I could do that?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":163,"Q_Id":55134741,"Users Score":1,"Answer":"We had the very same problem today on GCP, and solved with the following steps:\n\nsetting firewall rules for incoming TCP connections on port used by the service (which by default is 8082);\ninstalling apache2 server on the instance with a site.conf configuration that resolve incoming requests on ip-of-instance:8082.\n\nThat's it. Hope this can help.","Q_Score":1,"Tags":"python,amazon-web-services,luigi","A_Id":55143381,"CreationDate":"2019-03-13T05:05:00.000","Title":"Accessing Luigi visualizer on AWS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"conda install pmdarima\nPackagesNotFoundError: The following packages are not available from current channels:","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":12802,"Q_Id":55134919,"Users Score":0,"Answer":"I got the same error when I tried installing with \"conda install pmdarima\".\nSimply using \"python -m pip install pmdarima --user\" worked for me on anaconda prompt","Q_Score":0,"Tags":"python,anaconda,time-series,conda,pyramid-arima","A_Id":67498856,"CreationDate":"2019-03-13T05:22:00.000","Title":"How to install pmdarima in anaconda prompt. Tried conda install pmdarima not worked","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"conda install pmdarima\nPackagesNotFoundError: The following packages are not available from current channels:","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":12802,"Q_Id":55134919,"Users Score":4,"Answer":"pip install pmdarima\n\nIssue resolved.","Q_Score":0,"Tags":"python,anaconda,time-series,conda,pyramid-arima","A_Id":55134928,"CreationDate":"2019-03-13T05:22:00.000","Title":"How to install pmdarima in anaconda prompt. Tried conda install pmdarima not worked","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"conda install pmdarima\nPackagesNotFoundError: The following packages are not available from current channels:","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":12802,"Q_Id":55134919,"Users Score":4,"Answer":"Following worked for me to install the package with anaconda:\nconda install -c saravji pmdarima","Q_Score":0,"Tags":"python,anaconda,time-series,conda,pyramid-arima","A_Id":57458503,"CreationDate":"2019-03-13T05:22:00.000","Title":"How to install pmdarima in anaconda prompt. Tried conda install pmdarima not worked","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't seem to find any resources that state whether or not some popular OGMs can be used with neptune instead of writing raw gremlin queries for example.\nWould any of you know what OGMs are supported or can be used with Neptune and which would you recommend for python in particular?\nAlso, would it be better to use an OGM (like goblin for example) or stick to the gremlin python GVL instead?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":225,"Q_Id":55137417,"Users Score":0,"Answer":"Goblin claims that its TP 3.2.4 compatible, but I don't see any mention of its plan to be in sync with newer TP versions. GLV's ensure that you always have a compatibility with any TP version that has been released. They need not work across versions (ie. GLV v3.2.4 might not work peacefully with a TP 3.3.0 server) but you be sure that there will be a GLV for each official release of TP. \nBarring that, I don't see any concerns using an OGM. Its a different paradigm at the end of the day and should not be a concern apart from the version compatibility that I called out before. I've not tried it in person, so do let me know how it goes! Good luck.","Q_Score":1,"Tags":"python,amazon-web-services,gremlin,amazon-neptune,goblin","A_Id":56302721,"CreationDate":"2019-03-13T08:34:00.000","Title":"Using an OGM with AWS Neptune","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'd like to call C# functions from IronPython. I've read some topics about it, and it seems to follow these steps: \n\nCreate a dll from the C# functions\nUse clr.AddReference\nUse your function from IronPython\n\nMy noob question is: do I need to have my source code in C# in order to create the dll? Or is C++ ok? Why?\nThanks a lot,\nArnaud","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":55137908,"Users Score":1,"Answer":"Any .NET-based language can be used to generate the DLL, which you can use in your IronPython code.","Q_Score":1,"Tags":"c#,dll,ironpython","A_Id":55137981,"CreationDate":"2019-03-13T09:03:00.000","Title":"Do I need C# to create a dll to be used in IronPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have to refactor scraping algorithm. To speed it up we came up to conclusion to multi-thread processes (and limit them to max 3). Generally speaking scraping consists of following aspects:\n\nScraping (async request, takes approx 2 sec)\nImage processing  (async per image, approx 500ms per image)\nChanging source item in DB (async request, approx 2 sec)\n\nWhat I am aiming to do is to create batch of scraping requests and while looping through them, create a stack of consequent async operations: Process images and as soon as images are processed -> change source item.\nIn other words - scraping goes. but image processing and changing source items must be run in separate limited async threads.\nOnly think I don't know how to stack the batch and limit threads.\nHas anyone came across the same task and what approach have you used?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":55138277,"Users Score":1,"Answer":"What you're looking for is consumer-producer pattern. Just create 3 different queues and when you process the item in one of them, queue new work in another. Then you can 3 different threads each of them processing one queue.","Q_Score":1,"Tags":"python,multithreading","A_Id":55138456,"CreationDate":"2019-03-13T09:24:00.000","Title":"Async, multithreaded scraping in Python with limited threads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"For the purpose of this exercise, let's consider a matrix where the element m_{i, j} is given by the rule m_{i, j} = i*j if i == j and 0 else.\nIs there an easy \"numpy\" way of calculating such a matrix without having to resort to if statements checking for the indices?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1790,"Q_Id":55141674,"Users Score":0,"Answer":"You could use the identity matrix given by numpy.identity(n) and then multiply it by a n dimensional vector.","Q_Score":0,"Tags":"python,numpy,matrix","A_Id":55141944,"CreationDate":"2019-03-13T12:14:00.000","Title":"How to multiply diagonal elements by each other using numpy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For the purpose of this exercise, let's consider a matrix where the element m_{i, j} is given by the rule m_{i, j} = i*j if i == j and 0 else.\nIs there an easy \"numpy\" way of calculating such a matrix without having to resort to if statements checking for the indices?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1790,"Q_Id":55141674,"Users Score":1,"Answer":"You can use the numpy function diag to construct a diagonal matrix if you give it the intended diagonal as a 1D array as input. \nSo you just need to create that, like [i**2 for i in range (N)] with N the dimension of the matrix.","Q_Score":0,"Tags":"python,numpy,matrix","A_Id":55141958,"CreationDate":"2019-03-13T12:14:00.000","Title":"How to multiply diagonal elements by each other using numpy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to comment lines in jupyter notebook using \"ctrl+\/\". But it's not working. \nI'm using windows 10 and mozilla firefox.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1313,"Q_Id":55147319,"Users Score":0,"Answer":"Your issue is probably because of your browser settings. ctrl+\/ must be set to something else or you are not in edit mode.","Q_Score":2,"Tags":"python,jupyter-notebook","A_Id":55147380,"CreationDate":"2019-03-13T16:53:00.000","Title":"Jupyter notebook comment shortcut is not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the Scrapy (Scrapy==1.6.0) library with Python3. I am wondering, where in the code does Scrapy actually do the HTML request? I want to set a breakpoint there so I can see exactly what headers \/ cookies \/ urls \/ and user agent is actually being passed.\nAlso, where exactly is the response received as well? Right now my spider is failing to find any pages, so I imagine I'm getting either a blank HTML document or a 403 error, however I have no idea where to look to confirm this.\nCan anyone familiar with the scrapy library point me to exactly where in code I can check these parameters?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":55148001,"Users Score":0,"Answer":"I believe you can check out scrapy\/core\/engine.py method _download.\nThough I'd suggest you make use of scrapy shell. It will let you execute particular request, inspect response, open response in browser to see what was received by Scrapy. Also with a bit more of tuning you can import your spider in your shell and call a particular method of your spider and put a breakpoint there.\nIf your spider fails to find any pages then the problem is likely to be with your spider, not the framework.","Q_Score":0,"Tags":"python,web-scraping,scrapy","A_Id":55148667,"CreationDate":"2019-03-13T17:31:00.000","Title":"Where does Scrapy actually do the html request?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Pymongo inserts _id in original array after insert_many .how to avoid insertion of _id ? And why original array is updated with _id? Please explain  with example, if anybody knows? Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":21,"Q_Id":55150525,"Users Score":0,"Answer":"Pymongo driver explicitly inserts _id of type ObjectId into the original array and hence original array gets updated before inserting into mongo. This is the expected behaviour of pymongo for insertmany query as per my previous experiences. Hope this answers your question.","Q_Score":0,"Tags":"python,pymongo","A_Id":55150655,"CreationDate":"2019-03-13T20:16:00.000","Title":"Pymongo inserts _id in original array after insert_many .how to avoid insertion of _id?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"is there any way to prevent the user from closing the cmd window of a python script on windows or maybe just disable the (X) close button ?? I have looked for answers already but i couldn't find anything that would help me","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":306,"Q_Id":55151495,"Users Score":0,"Answer":"I dont think its possible, what you can do instead is to not display the cmd window (backgroundworker) and make it into a hidden process with system rights so that it cant be shutdown until it finishes.","Q_Score":2,"Tags":"python,python-3.x,windows,python-2.7,cmd","A_Id":55151598,"CreationDate":"2019-03-13T21:29:00.000","Title":"how can i prevent the user from closing my cmd window in a python script on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to download SpaCy using pip and it isn't working on my computer. I'm getting the following error message:\nCommand \"c:\\users\\myname\\appdata\\local\\programs\\python\\python37\\python.exe -u -c \"import setuptools, tokenize;file='C:\\Users\\MyName\\AppData\\Local\\Temp\\pip-install-6g5hk79j\\cytoolz\\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, file, 'exec'))\" install --record C:\\Users\\MyName\\AppData\\Local\\Temp\\pip-record-makf5_wt\\install-record.txt --single-version-externally-managed --compile\" failed with error code 1 in C:\\Users\\MyName\\AppData\\Local\\Temp\\pip-install-6g5hk79j\\cytoolz\\\nI've tried everything I've found from other posts on this problem, and nothing is working. Please help!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1623,"Q_Id":55152960,"Users Score":0,"Answer":"This error likely happens because there's an issue with your compiler, or because your machine doesn't have a compiler installed.\nWhile spaCy v2.0.x itself provides pre-compiled wheels, some external dependencies don't and need to be compiled locally. The easiest solution for this is to install from conda instead, which should give you pre-compiled Windows wheels for everything. Alternatively, you can also install the Visual C++ build tools (not to be confused with Visual Studio).\nspaCy v2.1, which was just released, replaced several third-party dependencies to allow shipping pre-built wheels for everything. So if you try again now, you should be able to install the library and all its dependencies without needing to compile anything locally.","Q_Score":1,"Tags":"python,windows,pip,spacy","A_Id":55281383,"CreationDate":"2019-03-14T00:05:00.000","Title":"Installing SpaCy on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to download SpaCy using pip and it isn't working on my computer. I'm getting the following error message:\nCommand \"c:\\users\\myname\\appdata\\local\\programs\\python\\python37\\python.exe -u -c \"import setuptools, tokenize;file='C:\\Users\\MyName\\AppData\\Local\\Temp\\pip-install-6g5hk79j\\cytoolz\\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, file, 'exec'))\" install --record C:\\Users\\MyName\\AppData\\Local\\Temp\\pip-record-makf5_wt\\install-record.txt --single-version-externally-managed --compile\" failed with error code 1 in C:\\Users\\MyName\\AppData\\Local\\Temp\\pip-install-6g5hk79j\\cytoolz\\\nI've tried everything I've found from other posts on this problem, and nothing is working. Please help!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1623,"Q_Id":55152960,"Users Score":1,"Answer":"I would suggest you to use Anaconda and install it using conda install spacy, because there seems to be a problem with the compiler that you have.\nAlso, You can very well use Pycharm.","Q_Score":1,"Tags":"python,windows,pip,spacy","A_Id":55281469,"CreationDate":"2019-03-14T00:05:00.000","Title":"Installing SpaCy on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"how can i search for patterns in texts that cover multiple lines and have fixed positions relating each other, for example a pattern consisting of 3 letters of x directly below each other and I want to find them at any position in the line, not just at the beginning for example. \nThank you in advance for the answer!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":55153197,"Users Score":0,"Answer":"I believe the problem you are asking about is \"Find patterns that appear at the same offset in a series of lines.\"\nI do not think this describes a regular language, so you would need to draw on Python's extended regex features to have a chance at a regex-based solution. But I do not believe Python supports sufficiently extended features to accomplish this task [1].\nIf it is acceptable that they occur at a particular offset (rather than \"any offset, so long as the offset is consistent\"), then something like this should work:\n\/^.{OFFSET}PATTERN.*\\n^.{OFFSET}PATTERN.*\\n^.{OFFSET}PATTERN\/, using the MULTILINE flag so that ^ matches the beginning of a series of lines instead of just the beginning of the entire text.\n[1] In particular, you could use a backreference to capture the text preceding the desired pattern on one line, but I do not think you can query the length of the captured content \"inline\". You could search for the same leading text again on the next line, but that does not sound like what you want.","Q_Score":0,"Tags":"python,regex,multiline","A_Id":55153266,"CreationDate":"2019-03-14T00:37:00.000","Title":"regex python multiline","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it ok having both Anaconda Navigator and Python 3. installed?\nI went through stack overflow and there were questions about having both Anacondas 2.7 and 3.5 but nothing related to my question.\nI find it easier to use python idle for the basic easy codes and I know I can use idle using anaconda prompt - idle but I sill want to install python 3. from python.org\nIn this case, will having installed both anaconda navigator and python 3. cause any problems?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":814,"Q_Id":55155689,"Users Score":0,"Answer":"Yeah, that won't be an issue at all but please remind that in environment variables please keep only conada or python 3 paths. sometimes it will cause you an error.","Q_Score":1,"Tags":"python,anaconda","A_Id":55155751,"CreationDate":"2019-03-14T05:45:00.000","Title":"Having both Anaconda Navigator and Python 3. installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In R Studio, Matlab, and in some Python IDEs (like Thonny) you can see a list of the variables in your environment, together with some summary information like values, type etc. \nIs there a way to do this in VSCode without going into debugging mode?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1101,"Q_Id":55156006,"Users Score":1,"Answer":"VS Code has an IPython mode with a dropdown box called Variables that basically does exactly this.\nTo enter IPython mode all you need to do is highlight a piece of code and hit Shift+Enter\nThe first time you do it there might be a bit of setting up to do but it was pretty easy to get it working on my Mac. Not sure what it's like on Windows\/Linux though\nNote: When I use VS Code I open it from the terminal (simply enter the command 'code') after I've activated my conda environment. That way the IPython interpreter uses my preferred conda environment when it launches.","Q_Score":2,"Tags":"python,visual-studio-code","A_Id":59278889,"CreationDate":"2019-03-14T06:10:00.000","Title":"How to show python environment objects in a pane in VSCode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to develop a C# application to monitor a Sick PLC using modbus. I have an example program for talking to the PLC which is written in Python and uses the module pyModbus. Is there a C# nugget package that has the same functionality as pyModbus?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":55159006,"Users Score":0,"Answer":"It's not a Nuget package, but instead a full Visual Studio solution. AdvancedHMI includes a Modbus driver and also has lots of tools that will connect to the driver data without having to write code.\nwww.advancedhmi.com","Q_Score":0,"Tags":"c#,python,plc,pymodbus","A_Id":55191802,"CreationDate":"2019-03-14T09:29:00.000","Title":"C# equivalent for pyModbus","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'm using Selenium to locate elements in a page. Is there any way to combine two methods together?\nExample:\nMethod 1: driver.find_elements_by_partial_link_text('html')\nMethod 2: driver.find_elements_by_class_name('iUh30')\nI will ideally like a method that finds elements that has both the partial link text and class name specified.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":469,"Q_Id":55159886,"Users Score":1,"Answer":"You can use xpath to combine both selectors:\ndriver.find_elements_by_xpath(\"\/\/*[@class='iUh30'][text()[contains(.,'html')]]\")\nThe \/\/* looks for any element with any tag. Might be <a>, might be <div>, <input>, anything. You can just change it to the desired tag.\nThe above find the element by exact class name. You can also use [contains(@class, 'partial_class')] to find elements by partial class.\nThe [text()[contains(.,'html')]] looks for elements which partial text is \"html\"","Q_Score":0,"Tags":"python-3.x,selenium-webdriver","A_Id":55160119,"CreationDate":"2019-03-14T10:14:00.000","Title":"Selenium locating elements by more than one method","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have to remove the strings that start with \"===\" and also end with \"===\" (for example I have to replace the string \"===Links===\" with null string) in python. But the problem here is it can start with three \"=\" or four or any number of '='. I have tried to use the regex re.sub('[=]*.*?[=]*', '', string). But when it is run on \"===Refs===\", it is giving \"Refs\" as output instead of null string. Can you please suggest something for this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":55160222,"Users Score":0,"Answer":".? suggests that you are only accepting no or a single character between your =s. Try changing it to .* to match multiple characters between =s.\nPerhaps you can use str.startswith() and str.endswith() to find out if the string starts\/ends with ===?","Q_Score":0,"Tags":"python,regex,python-3.x,python-2.7","A_Id":55160324,"CreationDate":"2019-03-14T10:29:00.000","Title":"Deleting a string between repeated delimiters in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have download a code for ocr using Keras, which applied the CRNN network and use the CTC loss as the loss function. \nHowever, I'm really new to CTC loss and just have trouble with the usage of K.ctc_batch_cost(), especially the meaning of input_length. In the document of keras, \n\nArguments of tf.keras.backend.ctc_batch_cost(\n      y_true,\n      y_pred,\n      input_length,\n      label_length\n  ) \n\n\ny_true: tensor (samples, max_string_length) containing the truth labels.\ny_pred: tensor (samples, time_steps, num_categories) containing the prediction, or output of the softmax.\ninput_length: tensor (samples, 1) containing the sequence length for each batch item in y_pred.\nlabel_length: tensor (samples, 1) containing the sequence length for each batch item in y_true.\nHowever, my problem is just what's the meaning of input_length? is that the dimensional of the output of LSTM?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1540,"Q_Id":55160939,"Users Score":-1,"Answer":"CTC loss for one example is calculated on a 2D array (T,C). C must be equal to number of character + 1(blank characters). C contains the probability distribution of the characters at a time stamps. T will be the number of time stamps. \nT should be of length 2* max_string_length. All possible encoding of y_true with length T will be used in negative log loss calculation.\nIt is usually the shape of previous layer output.","Q_Score":5,"Tags":"python,tensorflow,keras","A_Id":55161676,"CreationDate":"2019-03-14T11:07:00.000","Title":"what's the mean of input_length in K.ctc_batch_cost()","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large text file which contains dates similar to \nSun Mar 3, 2019 07:39AM\nand was wondering if there is a good way to search and remove it from the text. AM\/PM could also be lowercase and may have a space in front.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":42,"Q_Id":55162113,"Users Score":3,"Answer":"If you know the format, you could use regex to locate the dates and then strptime if you need to get the date's value.","Q_Score":2,"Tags":"python,python-3.x","A_Id":55162200,"CreationDate":"2019-03-14T12:04:00.000","Title":"How to find and remove datetime in string, ie: Sun Mar 3, 2019 07:39AM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to know help on which is more efficient to do. This is my situation I already have a GUI using PyQt programmed for windows I want it to be also installed on an android phone. Should I find away to packaged(through pyqtdeploy or any other means) to android or make another similar GUI with same functionalities using Kivy because its much more android friendly?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":768,"Q_Id":55162793,"Users Score":1,"Answer":"For now, I think you should learn Kivy because pyqtdeploy is a young project. The Dev team still working on it to fix some bugs.\nBut in the future, if pyqtdeploy become efficient, it will be the best choice ! \nPyQt5 has many incredible widgets and you use also QML to design more advanced interface for mobile devices (Android & iOS).","Q_Score":1,"Tags":"android,python,kivy,pyqt5,python-3.7","A_Id":60206953,"CreationDate":"2019-03-14T12:40:00.000","Title":"PyQt5 GUI for android vs Kivy GUI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script that uses tabula.read_pdf. Script works fine, however when I build an exe file with PyInstaller (with --noconsole option) and run my script - it opens java.exe empty console window which stays opened untill script work is done. \nHow can I avoid it?\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":258,"Q_Id":55164352,"Users Score":0,"Answer":"I have managed to fix it by changing java to javaw in wrapper.py file. Thanks.","Q_Score":1,"Tags":"python,pyinstaller,tabula","A_Id":55179237,"CreationDate":"2019-03-14T13:55:00.000","Title":"Python tabula read_pdf opens java console window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a script that uses tabula.read_pdf. Script works fine, however when I build an exe file with PyInstaller (with --noconsole option) and run my script - it opens java.exe empty console window which stays opened untill script work is done. \nHow can I avoid it?\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":258,"Q_Id":55164352,"Users Score":1,"Answer":"I was running into a similar issue and couldn't really find the wrapper.py. After some tinkering around I found a similar workaround:\nWithin the directory where tabula is installed \"...\\Lib\\site-packages\\tabula\" edit the \"io.py\" file. In the \"_run\" function just change the \"args\" variable to use \"javaw\" instead of \"java\".\nI was able to hide the java console when my .exe file ran this way. I hope this helps someone in the future.","Q_Score":1,"Tags":"python,pyinstaller,tabula","A_Id":70838257,"CreationDate":"2019-03-14T13:55:00.000","Title":"Python tabula read_pdf opens java console window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have the following problem, I have many files of 3D volumes that I open to extract a bunch of numpy arrays.\nI want to get those arrays randomly, i.e. in the worst case I open as many 3D volumes as numpy arrays I want to get, if all those arrays are in separate files.\nThe IO here isn't great, I open a big file only to get a small numpy array from it.\nAny idea how I can store all these arrays so that the IO is better?\nI can't pre-read all the arrays and save them all in one file because then that file would be too big to open for RAM.\nI looked up LMDB but it all seems to be about Caffe.\nAny idea how I can achieve this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1082,"Q_Id":55166874,"Users Score":0,"Answer":"One trivial solution can be pre-processing your dataset and saving multiple smaller crops of the original 3D volumes separately. This way you sacrifice some disk space for more efficient IO.\nNote that you can make a trade-off with the crop size here: saving bigger crops than you need for input allows you to still do random crop augmentation on the fly. If you save overlapping crops in the pre-processing step, then you can ensure that still all possible random crops of the original dataset can be produced.\nAlternatively you may try using a custom data loader that retains the full volumes for a few batch. Be careful, this might create some correlation between batches. Since many machine learning algorithms relies on i.i.d samples (e.g. Stochastic Gradient Descent), correlated batches can easily cause some serious mess.","Q_Score":0,"Tags":"python,machine-learning,dataset,pytorch,lmdb","A_Id":55169008,"CreationDate":"2019-03-14T15:52:00.000","Title":"Faster pytorch dataset file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I am slightly confused as to whether values are made and assigned to existing variables, variables are made and are assigned to existing values or whether they are both made and assigned to each other.\nI am aware of the popular model of variables as boxes and values going into these boxes, but is this accurate relating to Python as a language? If it is not, is there a more accurate model pertaining to variables in Python to help me better understand this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":55167064,"Users Score":3,"Answer":"In Python, a variable is a pair consisting of a name and a value, not a named location in memory.\nA value can exist (albeit transiently) without a label.\nA value can have more than one name associated with it.\nAll assignments simply cause a name to refer to an existing value. Even if the value is created \"by\" the assignment statement, you can think of the right-hand side as being a separate first step to produce an otherwise anonymous value, which then gets a name assigned to it. x = [1,2,3] first creates a list, then assigns the name x to that list.","Q_Score":0,"Tags":"python","A_Id":55167398,"CreationDate":"2019-03-14T16:02:00.000","Title":"Are variables attached to values or are values attached to variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have updated the following re to not match when the string is B\/C, B\/O, S\/C, or S\/O.\nold (.*)\/(.*)\nnew: (.*)(?<!^(B|S)(?=\/(C|O)$))\/(.*)\nThis regex is being used downstream with a list of other regex patterns and is expected to separate the data into two groups. Is there a way for my regex pattern (or a better one) to not count the zero-width assertions?\nI've tried pushing the validation till the end with a single lookbehind assertion but that only has access to the group after the slash.\nI've also tried enclosing the assertions in (?:...) but inner parenthesis are still counted towards matching groups.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":141,"Q_Id":55167584,"Users Score":0,"Answer":"Thanks to @user2357112\n(.*)(?<!^(?:B|S)(?=\/(?:C|O)$))\/(.*)\nI was using (?:...) incorrectly on my first attempts","Q_Score":0,"Tags":"python,regex,python-3.x","A_Id":55168590,"CreationDate":"2019-03-14T16:26:00.000","Title":"Regular Expression don't include Zero-Width assertions in match groups","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Tornado\nsudo easy_install tornado\nthen it got a lot of syntax errors.\nI want to uninstall Tornado\npip uninstall tornado\nThen it asks: \nUninstalling tornado-6.0.1:\n  Would remove:\n    \/Library\/Python\/2.7\/site-packages\/tornado-6.0.1-py2.7-macosx-10.13-intel.egg\nProceed (y\/n)? \nI typed y,\nthen it says\nException:\nTraceback (most recent call last):\n  File \"\/Library\/Python\/2.7\/site-packages\/pip-18.0-py2.7.egg\/pip\/_internal\/basecommand.py\", line 141, in main\n    status = self.run(options, args)\n...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2082,"Q_Id":55169254,"Users Score":0,"Answer":"Try to uninstall it with \"easy_install -m tornado\"","Q_Score":0,"Tags":"python,tornado","A_Id":55169326,"CreationDate":"2019-03-14T18:03:00.000","Title":"Can't uninstall Tornado with pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Can one make Altair plots fit the screen size, rather than have a pixel-defined width and height? I've read things about autosize \"fit\", but I am unsure about where to specify these.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2245,"Q_Id":55169344,"Users Score":5,"Answer":"There is no way to do this. The dimensions of Altair\/Vega-Lite charts are pre-determined by the chart specification and data, and cannot be made to scale with the size of the browser window.","Q_Score":7,"Tags":"python,vega-lite,altair","A_Id":55169600,"CreationDate":"2019-03-14T18:08:00.000","Title":"How to make Altair plots responsive","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new at this part of web developing and was trying to figure out a way of creating a web app with the basic specifications as the example bellow:\n\nA user1 opens a page with a textbox (something where he can add text or so), and it will be modified as it decides to do it.\n\nIf the user1 has problems he can invite other user2 to help with the typing.\n\n\nThe user2 (when logged to the Channel\/Socket) will be able to modify that field and the modifications made will be show to the user1 in real time and vice versa.\n\n\nOr another example is a room on CodeAcademy:\n\nImagine that I am learning a new coding language, however, at middle of it I jeopardize it and had to ask for help.\n\nSo I go forward and ask help to another user. This user access the page through a WebSocket (or something related to that).\n\n\nThe user helps me changing my code and adding some comments at it in real time, and I also will be able to ask questions through it (real time communication)\n\n\nMy questions is: will I be able to developed certain app using Django Channels 2 and multiplexing? or better move to use NodeJS or something related to that?\nObs: I do have more experience working with python\/django, so it will more productive for me right know if could find a way working with this combo.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":238,"Q_Id":55170669,"Users Score":1,"Answer":"This is definitely possible. They will be lots of possibilities, but I would recommend the following.\n\nHave a page with code on. The page has some websocket JS code that can connect to a Channels Consumer.\nThe JS does 2 simple things. When code is updated code on the screen, send a message to the Consumer, with the new text (you can optimize this later). When the socket receives a message, then replace the code on screen with the new code.\nIn your consumer, add your consumer to a channel group when connecting (the group will contain all of the consumers that are accessing the page)\nWhen a message is received, use group_send to send it to all the other consumers\nWhen your consumer callback function gets called, then send a message to your websocket","Q_Score":0,"Tags":"python,django,websocket,multiplexing","A_Id":55243910,"CreationDate":"2019-03-14T19:33:00.000","Title":"How does multiplexing in Django sockets work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to import nltk in my python file but i am getting this error\n\nFile \"mycode.py\", line 5, in \nfrom utilities import TextCleaner, TF_IDF_FeatureExtraction   File\n\"\/home\/myhome\/Baseline\/utilities.py\", line 1, in  import nltk\nFile\n\"\/home\/myhome\/.local\/lib64\/python3.5\/site-packages\/nltk\/init.py\",\nline 152, in  from nltk.stem import *   File\n\"\/home\/myhome\/.local\/lib64\/python3.5\/site-packages\/nltk\/stem\/init.py\",\nline 29, in  from nltk.corpus.reader.panlex_lite import *\nFile\n\"\/home\/myhome\/.local\/lib64\/python3.5\/site-packages\/nltk\/corpus\/reader\/panlex_lite.py\",\nline 15, in \nimport sqlite3 ImportError: No module named\n'sqlite3'\n\nThe python version on server is 3.5.3 and i have sqlite version 3.13.0 installed\ni am currently running code on remote server and i cant use sudo command since its restricted for remote users. is there any thing i can do without sudo command to solve this problem?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":10077,"Q_Id":55170966,"Users Score":2,"Answer":"I Solved this issue by commenting out \nimport sqlite3 in the panlex_lite.py file present inside nltk library folder and also commented out sqlite3 connection string present inside this file and the code works now. This solution will only work if you are intented to use nltk only but not sqlite3","Q_Score":2,"Tags":"python,linux,sqlite,nltk","A_Id":55188552,"CreationDate":"2019-03-14T19:53:00.000","Title":"ImportError: No module named 'sqlite3'","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to import nltk in my python file but i am getting this error\n\nFile \"mycode.py\", line 5, in \nfrom utilities import TextCleaner, TF_IDF_FeatureExtraction   File\n\"\/home\/myhome\/Baseline\/utilities.py\", line 1, in  import nltk\nFile\n\"\/home\/myhome\/.local\/lib64\/python3.5\/site-packages\/nltk\/init.py\",\nline 152, in  from nltk.stem import *   File\n\"\/home\/myhome\/.local\/lib64\/python3.5\/site-packages\/nltk\/stem\/init.py\",\nline 29, in  from nltk.corpus.reader.panlex_lite import *\nFile\n\"\/home\/myhome\/.local\/lib64\/python3.5\/site-packages\/nltk\/corpus\/reader\/panlex_lite.py\",\nline 15, in \nimport sqlite3 ImportError: No module named\n'sqlite3'\n\nThe python version on server is 3.5.3 and i have sqlite version 3.13.0 installed\ni am currently running code on remote server and i cant use sudo command since its restricted for remote users. is there any thing i can do without sudo command to solve this problem?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":10077,"Q_Id":55170966,"Users Score":0,"Answer":"What you have installed on server, is not a python module, but the sqlite3 utility. If you have pip3 installed, you can run pip3 install pysqlite3 from user, so it will install the module sqlite3 in your home directory.","Q_Score":2,"Tags":"python,linux,sqlite,nltk","A_Id":55171646,"CreationDate":"2019-03-14T19:53:00.000","Title":"ImportError: No module named 'sqlite3'","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to write a pygame programme where I am receiving data from a Raspberry Pi over a socket connection. However I only want the Pygame code to run once the string has arrived. This involves the code waiting for some time, then when a string is received from the Raspberry Pi, pygame runs code to update the display.\nCurrently my Pygame freezes and shuts down when waiting for data to income. \nAny ideas. Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":188,"Q_Id":55171411,"Users Score":0,"Answer":"Pygame \"freezes\" is most likely due to the network call being blocking. Consider spinning a new thread to handle the data communication while Pygame takes over the main thread and updates the display with some \"waiting\" message. Once you have received the data, the second thread should pass it to the main thread which will display it.","Q_Score":2,"Tags":"python,pygame,python-sockets","A_Id":55171549,"CreationDate":"2019-03-14T20:26:00.000","Title":"Only running Pygame display code once data revieved from python socket connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Python 3.7.2 and VSCode 1.32.1 on Mac OS X 10.10.2. In VSCode I installed the Pyhton extension and got a message saying: \n\"Operating system does not meet the minimum requirements of the language server. Reverting to alternative, Jedi\". \nWhen clicking the \"More\" option under the message I got information indicating that I need OS X 10.12, at least. \nI tried to install an older version of the extension, did some reading here and asked Google, but I'm having a hard time since I don\u00b4t really know what vocabulary to use. \nMy questions are: \nWill the extension work despite the error message?\nDo I need to solve this, and how do I do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1138,"Q_Id":55171449,"Users Score":1,"Answer":"The extension will work without the language server, but some thing won't work quite as well (e.g. auto-complete and some refactoring options). Basically if you remove the \"python.jediEnabled\" setting -- or set it to false -- and the extension works fine for you then that's the important thing. :)","Q_Score":0,"Tags":"python,macos,visual-studio-code,error-messaging","A_Id":55172116,"CreationDate":"2019-03-14T20:28:00.000","Title":"Operating system does not meet the minimum requirements of the language server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"(base) C:\\Users\\Kevin>pip install scipy Requirement already satisfied:\n  scipy in c:\\programdata\\anaconda3\\lib\\site-packages (1.1.0)\n\netc\nSuddenly my jupyter notebook denies to import several packages. pandas and numpy work, but all the other packages do not  (spacy, nltk, scipy, requests)\nI tried reinstall packages, but it says I already have installed them.\nWhy is this happening?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":279,"Q_Id":55172651,"Users Score":0,"Answer":"Did you install Anaconda + Python ? Python doesn't come with package, maybe you're using Python path instead of Anaconda to run jupyter","Q_Score":1,"Tags":"python,pip,jupyter-notebook","A_Id":55172773,"CreationDate":"2019-03-14T21:59:00.000","Title":"No module named scipy, spacy, nltk","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I run calculations on Windows for hours and would like to have the calculation report\/log inside the interactive IDLE\/shell window be saved to a file at the end by a command.\nWould be nice to exit() and close the window too.\nAs much as I like Linux, this is an Unattended Windows machine, hence, some modules\/commands are not available, sadly, and the ability to install other software is limited. \nThe fact that the developers did not think of a command to save the transactions within the IDLE\/shell is surprising. \nI know in some environments you can direct the output of a job, like a report to another text file by using the key -o, --o, --output, > to a text file. Surprisingly Python does not support anything like that! \nAny help would be appreciated \nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":833,"Q_Id":55173483,"Users Score":0,"Answer":"Windows Command Prompt supports stdout redirection and probably stderr redirection. I just tested python -c \"print(test)\" > F:\/dev\/tem\/out.txt and the print out went to out.txt. Replace -c \"print('test') with script.py and the same should happen. Piping stdout of one program to stdin of another might work. You might be able to chain programs with a .bat file. PowerShell likely is more powerful and flexible, but I have never used it.\nI am not completely clear on what you are asking, but I hope the following answers your questions.\nPython runs in 2 modes: batch and interactive.  Interactive mode is intended for ephermeral interaction with a human.  Batch mode is for unattended computation, with occasional screen messages, but with most results sent to a file other than the screen.  Both modes are combined when you run python -i xyz.py.  The file is first run in batch mode, and then Python shifts to interactive mode.\nIt sounds like you should be using batch mode rather than either Python's or IDLE's interactive mode.  If your code runs from IDLE, you should be able to run it directly with  the same python.exe that you used to run IDLE.  There are exceptions, of course, if one makes one's code dependent on running within IDLE, but this is unlikely to be an accident or to be needed for unattended running.\nThe IDLE Shell simulates interactive Python.  When a file is run from an editor window, IDLE simulates python -i file-being-edited.py, with screen output going to Shell.  In either case, an interactive user can save the contents of Shell with the File => Save As menu command.  So there is such a command.  There are also close window and exit commands and shortcuts.\nIn IDLE's intended use, as an interactive python learning and program development environment, there is no need from for a program to issue these commands.  To save data in a file, a program can open a file and write data directly.","Q_Score":0,"Tags":"windows,python-2.7,history,python-idle","A_Id":55191917,"CreationDate":"2019-03-14T23:26:00.000","Title":"How to save a Python 2 idle\/shell\/command prompt interactive session on Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm having trouble with my PATH and can't seem to find an answer anywhere.\nI'm using a virtualenv on my Mac, and when I call which pip, it confirms this - but when I pip install anything, it dumps it into my 'usr\/local' path.\nI have export PATH=\/usr\/local\/bin:$PATH added to my .bash_profile to ensure that user-installed binaries take precedence, but I have {\n   \"python.pythonPath\": \"\/Virtualenvs\/py3\/bin\/python3.7\"\n} added in my VSCode settings.json to ensure the right path from there.\nMore specifically, calling which pip returns:\n\/Users\/username\/Virtualenvs\/py3\/bin\/pip\nBut pip install telegramreturns:\nRequirement already satisfied: telegram in \/usr\/local\/lib\/python3.7\/site-packages (0.0.1)\nAny ideas on why this might be happening?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":932,"Q_Id":55175707,"Users Score":0,"Answer":"Try pip --user to install it to particular user directories","Q_Score":0,"Tags":"python-3.x,path,visual-studio-code,pip","A_Id":55175773,"CreationDate":"2019-03-15T04:46:00.000","Title":"'pip' installs to wrong directory, even though it's set correctly in PATH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"hey so I am submitting my code through a code homework website my school uses and for some reason it's saying there's something wrong with my spacing on the line with the money amount in it, as you can see in the screenshot below, the output on the left is the expected and the one on the right is what I get. What is wrong with my code that's doing this? Also at the end of each of my outputs it also prints 'None'.? why?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":55176200,"Users Score":0,"Answer":"One problem is that your thank_donor function returns the print function, and then you call the print function again on THAT. You want the function to return just the plain string which you can then print.","Q_Score":0,"Tags":"python","A_Id":55176273,"CreationDate":"2019-03-15T05:38:00.000","Title":"Apparent space at end of line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to connect rally workspace and project with pyral by project name but I need to connect rally with project object id.\n Could any one help me. I couldn\u2019t find any option to connect rally with object Id through pyral.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":55176415,"Users Score":0,"Answer":"What is your goal of such an approach?","Q_Score":0,"Tags":"python-3.x,rally,pyral","A_Id":55199120,"CreationDate":"2019-03-15T05:57:00.000","Title":"How to connect rally with Object Id of project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I like to make a variable with some calculation like below\n\n'apple'+str(123)='orange'\n\nexpected below\n\napple123='orange'\n\nIt looks simple but is not working.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":285,"Q_Id":55177250,"Users Score":0,"Answer":"You can also use setattr to dynamically create variables","Q_Score":0,"Tags":"python-3.x,variables","A_Id":55177384,"CreationDate":"2019-03-15T07:03:00.000","Title":"Can I make a variable name with some calculation in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a project running on a docker container and another running on a vagrant machine, when I try in to go to definition in that two projects, I receive this message ex: \"No definition found for 'BaseUserManager'. \", for all plugins that I have installed on that machines I get the same message.\nPS: Go to definition just work on my local workspace.\ncan you guys help me to solve this problem please?, I really like vscode and I don't wanna quit the editor because of this issue.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":186,"Q_Id":55184921,"Users Score":1,"Answer":"The source has to be local for the extensions to be able to read the files to analyze the source.","Q_Score":1,"Tags":"python,django,docker,visual-studio-code,vagrant","A_Id":55189303,"CreationDate":"2019-03-15T14:32:00.000","Title":"Go to definition is not working with docker and vagrant","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"What's the difference between state.apply and state.sls? When should I use state.apply vs state.sls?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2283,"Q_Id":55185684,"Users Score":9,"Answer":"state.sls <state_file> will execute the states in a specific file.\nstate.highstate will execute the highstate configured by top.sls\nstate.apply will do a state.highstate if no arguments are given and a state.sls <state_file> when a  argument is given.\nYou can look at state.apply as an easy way of using states command.","Q_Score":7,"Tags":"python,salt-stack,salt","A_Id":55185967,"CreationDate":"2019-03-15T15:16:00.000","Title":"What's the difference between state.sls and state.apply?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking to keep the browser window open even after test execution.\nI would like to keep it open indefinitely.\nAs of now , as a work around I am just using sleep() to keep the window from closing.\nAny help would be much appreciated. Thank you !","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":4086,"Q_Id":55186282,"Users Score":4,"Answer":"Simple - do not call Close Browser at the end.","Q_Score":3,"Tags":"python,selenium,selenium-webdriver,robotframework","A_Id":55197099,"CreationDate":"2019-03-15T15:49:00.000","Title":"Is there a way to keep the browser window open after the test execution in RobotFramework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I convert a simple print(\"Hello World\") code form Python to .exe with Pyinstaller (with the comand pyinstaller -wF) and apparently it creates the file properly. However, when I execute it, nothing happens.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":116,"Q_Id":55186976,"Users Score":1,"Answer":"Nothing happens because print() sends a message to standard output (your terminal), but an .exe has no terminal. You can try to implement a GUI to display this information (in a module like tkinter), or have your program do something else like open a program or file on your computer!","Q_Score":0,"Tags":"python,python-3.x,compilation,exe,pyinstaller","A_Id":55187019,"CreationDate":"2019-03-15T16:32:00.000","Title":"Python converted to .exe (via Pyinstaller) doesn't work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to use the python extension to edit files that reside on a remote server? I have tried NFS and remoteFS, but I do not see any way to get Intellisense working using the remote installation. I normally edit and test on a windows machine, while the target runs on Linux. \nI realise this is not limited to this extension, but is a more general issue.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":2885,"Q_Id":55189055,"Users Score":1,"Answer":"As a workaround, I'm using a Linux Hosted virtual machine which has a similar setup as the target. This works surprisingly well. It is a shame VMware 12 removed support for unity.","Q_Score":3,"Tags":"python,visual-studio-code","A_Id":55489593,"CreationDate":"2019-03-15T18:52:00.000","Title":"Visual Studio Code use on remote 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":1,"Web Development":0},{"Question":"I have a variable X, it contains a list (Python list), of 10 Numpy 1-D arrays (basically vectors).\nIf I ask for X[100], it throws an error saying: IndexError: list index out of range\nWhich makes total sense, but, when I ask for X[:100], it doesn't throw an error and it returns the entire list! \nWhy is that?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":156,"Q_Id":55189686,"Users Score":1,"Answer":"X[:100] means slice X from 0 to 100 or the end (whichever comes first)\nBut X[100] means the 100th element of X, and if it doesn't exist it throws an index out of range error","Q_Score":0,"Tags":"python,numpy","A_Id":55189726,"CreationDate":"2019-03-15T19:42:00.000","Title":"Weird Indexing by Python and Numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been trying to import speech_recognition and pyttsx3. However, I can't find the modules available to install when I go to File->Preferences for New Project->Project interpreter. I then installed it using pip in my terminal, but it didn't do anything in pycharm despite it being successful in the terminal.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":339,"Q_Id":55190774,"Users Score":1,"Answer":"I actually just had a very similar issue. if you installed them sucessfully and can see that they appear in the terminal, then go to file -> settings -> Project Interpreter and from here click on the plus (+) icon on the right. You won't see the modules until you click the (+) icon. From there, simply search the modules and they should appear and give you the option to add them. This worked for me, so please let me know if it does for you too!","Q_Score":0,"Tags":"python,python-3.x","A_Id":55190846,"CreationDate":"2019-03-15T21:16:00.000","Title":"PyCharm modules not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In simple python CLI script, I created a memory buffer with Byteio and wrote some data there. I call it from the terminal.\nLet's say my program is in progress for one hour. \nCan python interpreter implicitly move my buffer from one logical memory location to another during program execution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":102,"Q_Id":55196056,"Users Score":1,"Answer":"No. CPython's garbage collector doesn't do moving or compacting. The reason for that is that it provided direct references to objects to C extensions in the early versions (before 2.0), and move to indirect references or read barriers would break C extension compatibility.\nPyPy has a more efficient and advanced moving GC, since it doesn't maintain compatibility with C extensions.","Q_Score":0,"Tags":"python","A_Id":55245469,"CreationDate":"2019-03-16T11:05:00.000","Title":"Does python move buffers from one logical memory location to another?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My question is about the usage of thread in the pyqt5 application. I am fair newly to the GUI world, I am an embedded guy. I m having a hard time bundling my python3 application in Windows that uses Joblib to achieve parallelism. I am doing read and write of 10 UARTs concurrently.\nI want to deliver this application as Windows OS installation to the customer, not as code in the factory. \nI am planning to abandon the usage of Joblib in my pyqt5 application because of creating windows package. \nI checked with other GUI guy at my work, he said pyqt5 threads have a lot of issues and synchronizing threads are big mess, not that easy, but his answer is not convincing to me. \nI am sure in this world many using Pyqt5 build in multi-thread or multi-parallel mechanism, I just want to write parallelly to the Uarts and read the data from Uarts stream.\nSomeone can provide the good source to learn more about pyqt5 multithread or parallel processing example?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":55200334,"Users Score":1,"Answer":"I am not a python expert, however as PyQt5 is a library with Qt5 bindings I would not use threads for achieving what you want.\nQt provides very convenient mechanism of signals. \nYou can write data to all your UARTs and then wait for signals telling you can read data (assuming you are going to use QSerialPort class).\nThis would of course work in one thread, but as long as you don't need super speed or read\/write tons of data, you may find it suitable.","Q_Score":0,"Tags":"python-3.x,multithreading,pyqt5,joblib,python-windows-bundle","A_Id":55200458,"CreationDate":"2019-03-16T18:45:00.000","Title":"widely used multi-thread or concurrent processing for pyqt5?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"It is visible on the Audience Overview page as a pie chart of Percent New Visitors vs % Returning Visitors","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":728,"Q_Id":55201171,"Users Score":2,"Answer":"There is no metric 'Percent New Visitors' and 'Percent Returned Visitors'. But you can use ga:userType and calculate %.\nAnd also metric ga:percentNewSessions exists - the percentage of sessions by users who had never visited the property before. May be it will be helpful.","Q_Score":0,"Tags":"python,google-analytics,google-analytics-api,google-analytics-firebase","A_Id":55202208,"CreationDate":"2019-03-16T20:25:00.000","Title":"How to find the % returning visitors through the Google Analytics API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"It is visible on the Audience Overview page as a pie chart of Percent New Visitors vs % Returning Visitors","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":728,"Q_Id":55201171,"Users Score":0,"Answer":"Clarification: The pie chart actually shows % of Sessions by new and returning visitors, not % returning users. As zborovskaya stated, there is a ga:percentNewSessions which can be used (100 - %new = %returning session).","Q_Score":0,"Tags":"python,google-analytics,google-analytics-api,google-analytics-firebase","A_Id":55218898,"CreationDate":"2019-03-16T20:25:00.000","Title":"How to find the % returning visitors through the Google Analytics API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Context: I have an app that serves interactive graphs and data analysis. In order to calculate plots and data summaries, it uses a dataset that is loaded upon App initialization by querying google BigQuery. The data is then kept as a global variable (in memory) and is used in all data calculations and plots that might be run by different users (each user saves in their session their own filters\/mask). \nThis dataset changes in BigQuery once per day during the night (I know the exact datetime of refresh). Once the data is refreshed in BigQuery, I want the global variable of the dataset to be refreshed. \nI know that the proper solution would be to call a Database on each user request, but BigQuery high delay on requests doesn't make this a good solution, and I can't use another DB.\nThe only solution I've came across so far is to restart the Google App Engine service (all instances) after BigQuery data refresh. Please note that this should be a scheduled action, done programatically. \nMy questions:\n\nIn case restarting the service is the best possible solution, how should I be restarting the service?\nIn case there is another way to accomplish what I want, please let me know","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1633,"Q_Id":55203095,"Users Score":0,"Answer":"It's likely good practice to cache your dataset as you're doing; if you know the data hasn't changed. then there's no need to requery BigQuery for it.\nHowever, your dataset does change, just once per day.\nSo, I think your approach should be to revise your app so that it refreshes the cached copy of your BigQuery dataset every day and stop|block your users from querying the dataset as it changes.\nYou actually need only change the dataset if a user requests it (there's no need to refresh the dataset on days when no users need it), so, depending on the time the refresh takes and your users' expectations on latency, you could trigger the refresh by a user request: has the dataset changed? If so, block this request, refresh the data and then respond to the user.\nI assume you've already solved the problem that your users' data plots and calculations will differ for different datasets.","Q_Score":1,"Tags":"python-3.x,google-app-engine,google-api,gcloud","A_Id":55203379,"CreationDate":"2019-03-17T01:33:00.000","Title":"How to restart Google App Engine Standard Service","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I want to click pictures with picamera and send them to my pythonanywhere...that should run a specific python script and return the output again to my rpi.\nHow is that possible?.. \nI have a hacker account on pythonanywhere.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":55203647,"Users Score":0,"Answer":"You can do that by creating a web app on PythonAnywhere and then have picamera upload the picture. The endpoint on PythonAnywhere could then do the processing that you want and return it's results as the response to the request.","Q_Score":0,"Tags":"python,pythonanywhere","A_Id":55219819,"CreationDate":"2019-03-17T03:42:00.000","Title":"How to connect to pythonanywhere script from my 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":"Is there any rationale behind the choice to use distinct methods for sending packets at L2 and L3 in Scapy? Could Scapy not just check if the packet being sent is L2 or higher?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":93,"Q_Id":55205365,"Users Score":1,"Answer":"If Scapy were to detect whether the passed packet was L2 or L3, it would mean it has to hardcode a list of layers that are considered \u201cLayer 3\u201d and \u201cLayer 2\u201d.\nIf you make a custom layer 3, it wouldn\u2019t know in what category it falls, thus it leaves you the choice.\nAlso that\u2019s historical, dates back from 2008, you can\u2019t break it :-)","Q_Score":0,"Tags":"python,scapy","A_Id":55205923,"CreationDate":"2019-03-17T08:52:00.000","Title":"Why uses Scapy different methods to distinguish L2 and L3 packets?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Objects cannot be serialised to json so therefore need to be converted or parsed through a custom JsonEncoder class.\npandas Dataframe has a number of methods, like from_records to read json data. Yet when you read that json data back it is returned as int64 instead of timestamp.\nThere are many ways to skin a cat in pandas. What is the best way to preserve data structures when reading and writing json?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2822,"Q_Id":55205436,"Users Score":1,"Answer":"If I have correctly understood your problem, you are looking for a serialization way preserving the data types of a dataframe.\nThe problem is that the interchange formats internally use few types: only strings for csv, strings and numbers for json. Of course there are ways to give formatting hints at read time (date format for date columns in csv), and it is generaly easy to convert back to the proper type after extraction, by I think that you would hope a more natural way. As suggested by Attack68 you could use a database but for example a SQLite database would be off because it has no internal date type.\nIMHO a simple way would be to rely on the good old pickle module. After all, a dataframe is a Python object that contains other Python objects, so pickle is good at serializing that. The only point to remember is that, at deserialization time, pandas will have to be imported before calling pickle.load.\nBut I have just tested with a (tiny) dataframe containing various datatypes, and pickle was great as correctly saving and restoring them.","Q_Score":2,"Tags":"python,json,pandas,numpy","A_Id":55225618,"CreationDate":"2019-03-17T09:02:00.000","Title":"Pandas timestamp to and from json","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Redefined builtin function len() in spyder  like len = 100;\nNow when I am trying to find the length of the string it says \"'int' object is not callable\"\nHow to undo this change or correct this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":36,"Q_Id":55208653,"Users Score":1,"Answer":"Since len is an inbuilt python function, you should avoid using that as a variable. try prefixing your 'len' with '_' and use '_len = 10' instead of just 'len'.","Q_Score":0,"Tags":"python,spyder","A_Id":55208832,"CreationDate":"2019-03-17T15:23:00.000","Title":"rRdfined a built-in function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I add all the python libraries in Spyder IDE which I have already downloaded using Terminal and are present in the directory \/home\/{username}\/.local\/lib\/python3.6\/site-packages","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":86,"Q_Id":55209645,"Users Score":1,"Answer":"I have found the answer, Just go to Tools -> PYTHONPATH Manager and add a path to these libraries and restart Spyder.","Q_Score":1,"Tags":"python-3.x,spyder","A_Id":55209725,"CreationDate":"2019-03-17T17:05:00.000","Title":"How to add all the python libraries in spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using the Mask RCNN library which is based on tenserflow and I can't seem to get it to run on my GPU (1080TI). The inference time is 4-5 seconds, during which I see a usage spike on my cpu but not my gpu. Any possible fixes for this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3990,"Q_Id":55211277,"Users Score":5,"Answer":"It is either because that GPU_COUNT is set to 0 in config.py or you don't have tensorflow-gpu installed (which is required for tensorflow to run on GPU)","Q_Score":2,"Tags":"python,tensorflow,machine-learning,keras","A_Id":55211330,"CreationDate":"2019-03-17T19:55:00.000","Title":"Mask RCNN uses CPU instead of GPU","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How should developers indicate how users should cite the package, other than on the documentation?\nR packages return the preferred citation using citation(\"pkg\").\nI can think of pkg.CITATION, pkg.citation and pkg.__citation__.  Are there others?  If there is no preferred way (which seems to be the case to me as I did not find anything on python.org), what are the pros and cons of each?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":271,"Q_Id":55211780,"Users Score":0,"Answer":"Finally I opted for the dunder option.  Only the dunder option (__citation__) makes clear, that this is not a normal variable needed for runtime.\nYes, dunder strings should not be used inflationary because python might use them at a later time.  But if python is going to use __citation__, then it will be for a similar purpose.  Also, I deem the relative costs higher with the other options.","Q_Score":4,"Tags":"python,citations","A_Id":55306548,"CreationDate":"2019-03-17T20:51:00.000","Title":"What is the preferred way to a add a citation suggestion to python packages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was using sklearn2pmml to export my model to .pmml file.\nHow to read the PMML file back to python PMMLpipeline ?\nI was checking the repo but could not find the solution in the documentation.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":201,"Q_Id":55217392,"Users Score":3,"Answer":"If you want to save a fitted Scikit-Learn pipeline so that it could be loaded back into Scikit-Learn\/Python, then you need to use \"native\" Python serialization libraries and dataformats such as Pickle.\nThe conversion from Scikit-Learn to PMML should be regarded one-way operation. There is no easy way of getting PMML back into Scikit-Learn.\nYou can always save the fitted Scikit-Learn pipeline in multiple data formats. Save one copy in Pickle data format so that it could be loaded back into Scikit-Learn\/Python, and save another copy in PMML data format so that it would be loaded in non-Python environments.","Q_Score":0,"Tags":"python,python-3.x,pmml","A_Id":55220454,"CreationDate":"2019-03-18T08:38:00.000","Title":"read pmml using sklearn2pmml?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got URL similar tohttps:\/\/github.com\/me\/my-project\/archive\/master.zip\nDuring development, I was able to install it with:\npip install https:\/\/github.com\/me\/my-project\/archive\/master.zip\nHow would I go about adding that to requirements.txt? I can only see options for repositories.\nThanks.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1370,"Q_Id":55219655,"Users Score":3,"Answer":"I found out! This needs to be added to requirements.txt:\n-e git+https:\/\/github.com\/me\/my-project\/#egg=my-project\nPreviously I was using a different VCS tag which was giving me some funky errors.","Q_Score":4,"Tags":"python,pip","A_Id":55219848,"CreationDate":"2019-03-18T10:51:00.000","Title":"How to install a .zip package via requirements.txt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Uninstalled Anaconda Navigator last week and now it wont work once I've reinstalled it. \nWindows search doesn't find an anaconda navigator program but in C:\\Users\\admin\\Anaconda3\\pkgs\\anaconda-navigator-1.9.2-py37_0\\Scripts, there is a anaconda navigator application. When i open this, a command prompt box flashes and vanishes within 0.5 secs. \nC:\\Users\\admin>where conda\nReturns 'where is not a recognized internal or external command' \nconda update has same response as well as all other 'conda' calls\nHave uninstalled and ticked (and also unticked) the PATH option numerous times for both and hasn't worked. Have also tried clearing the PATH in the advanced section. \nBasically, I've tried all the other suggestions on SO and cant find anything which works. \nEdit: Calling python in the command prompt does work too - so python works but none of the anaconda options including spyder, jupyter etc etc. (RStudio does work in my computer though)\nCheers","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":6127,"Q_Id":55222653,"Users Score":-1,"Answer":"I managed to solve the issue by doing the following:\n\nInstalling Microsoft Visual C++ 2015 - 2019 redistributable (x64) - 14.25. 28508\nAdd file: msvcp140.dll (follow tutorial in youtube)\nAdd file: msvcp140_1.dll","Q_Score":2,"Tags":"python,anaconda,conda","A_Id":61267845,"CreationDate":"2019-03-18T13:36:00.000","Title":"Anaconda Navigator Won't Open - Tried all other threads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm to deploy Python into a production system and the python script I have has a number of modules associated with it.\nIs there a way to install python with only a specific list of modules? Abit like with generating a jar, you can have a folder with all the other dependency jar's in a folder, which is nice and clean. I don't want to compile the python code so I want something similar.\n(Note: I also don't want to create a virtual environment - I want the default environment like this)","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":204,"Q_Id":55222811,"Users Score":1,"Answer":"If you don't want to do like what Amir is suggesting above, then 2 other options are available:\n\nCopy those modules and place them in the same folder where your script is installed\nCreate a requirements.txt file with the name & version of those modules and then run \"pip install -r requirements.txt\" to install these modules in your site-packages folder","Q_Score":1,"Tags":"python,dependencies","A_Id":55223074,"CreationDate":"2019-03-18T13:44:00.000","Title":"Create standalone isolated python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering how I could see the history in the Pycharm Python console using a shortcut. I can see the history using the upper arrow key, but If I want to go further back in history I have to go to each individual line if more lines are ran at the time. Is it possible that each time I press a button the full previous commands that are ran are shown?\nI don't want to search in history, I want to go back in history similar using arrow up key but each time I enter arrow up I want to see the previous full code that was ran.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1662,"Q_Id":55223233,"Users Score":0,"Answer":"Go to preferences -> Appereance & Behaviour -> Keymap. You can search for \"Browse Console History\" and add a keyboard shortcut with right click -> Add Keyboard shortcut.","Q_Score":1,"Tags":"python,console,pycharm,keyboard-shortcuts","A_Id":55223390,"CreationDate":"2019-03-18T14:05:00.000","Title":"How to see the full previous command in Pycharm Python console using a shortcut","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"in C# we have to get\/set to make rules, but I don't know how to do this in Python.\nExample:\nOrcs can only equip Axes, other weapons are not eligible\nHumans can only equip swords, other weapons are eligible.\nHow can I tell Python that an Orc cannot do something like in the example above?\nThanks for answers in advance, hope this made any sense to you guys.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1846,"Q_Id":55226942,"Users Score":0,"Answer":"Python language doesn't have an effective mechanism for restricting access to an instance or method. There is a convention though, to prefix the name of a field\/method with an underscore to simulate \"protected\" or \"private\" behavior. \nBut, all members in a Python class are public by default.","Q_Score":4,"Tags":"python,pygame","A_Id":55227059,"CreationDate":"2019-03-18T17:28:00.000","Title":"Python how to to make set of rules for each class in a game","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to grab an ip address from a string and facing an issue.please help.\ninet addr:11.11.11.11  Bcast:11.11.11.111  Mask:111.111.11.1.\nThis is the string I have and I need ip address next to addr:\nI have tried the following code and failed to do in python: \nip = re.findall(r'(?:\\d{1,3}\\.)+(?:\\d{1,3})', line) and get index 0 item.\nResult : This is actually giving me nothing in return","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":250,"Q_Id":55228136,"Users Score":0,"Answer":"Your REGEX could be more specific, I think you could use something like :\naddr:(?<ip>\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})\nIn python:\nmatch = re.match(r'addr:(?<ip>\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})', line)\nYou can then access the ip group by calling match.group('ip').","Q_Score":2,"Tags":"python,regex,python-3.x","A_Id":55228210,"CreationDate":"2019-03-18T18:46:00.000","Title":"How to grab first ip address from a string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My input text looks like this:\n\nPut in 3 extenders but by the 4th floor it is weak on signal these don't piggy back of each other. ST -99. 5G DL 624.26 UP 168.20 4g DL 2\n  Up .44\n\nI am having difficulty writing a regex that will match any instances of 4G\/5G\/4g\/5g and give me all the corresponding measurements after the instances of these codes, which are numbers with decimals. \nThe output should be:\n\n5G 624.26 168.20 4g 2 .44\n\nAny thoughts how to achieve this? I am trying to do this analysis in Python.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":78,"Q_Id":55228336,"Users Score":1,"Answer":"I would separate it in different capture group like this:\n(?i)(?P<g1>5?4?G)\\sDL\\s(?P<g2>[^\\s]*)\\sUP\\s(?P<g3>[^\\s]*)\n(?i) makes the whole regex case insensitive\n(?P<g1>5?4?G) is the first group matching on either 4g, 5g, 4G or 5G.\n(?P<g2>[^\\s]*) is the second and third group matching on everything that is not a space.\nThen in Python you can do:\nmatch = re.match('(?i)(?P<g1>5?4?G)\\sDL\\s(?P<g2>[^\\s]*)\\sUP\\s(?P<g3>[^\\s]*)', input)\nAnd access each group like so:\nmatch.group('g1') etc.","Q_Score":0,"Tags":"python,regex","A_Id":55228523,"CreationDate":"2019-03-18T18:58:00.000","Title":"Regex to get key words, all digits and periods","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am implementing a server for recognizing objects in photos using tensorflow-gpu in \"semi-real\" time.  It will listen for new photos on a websocket connection, then enqueue it into a list for the detector run when it is free.  Would it be simpler to use asyncio or threading to handle the websocket listener and the recognition queue?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":924,"Q_Id":55229009,"Users Score":0,"Answer":"I am not an expert in threading\/asyncio but maybe it would be easier to spawn an instance of Kafka and have a piece of code that would listen to a Kafka topic? To this topic you would push images or paths to images if you already store them locally. Moreover, using consumer-groups you would get a load balancing like thing for free as it is a part of Kafka.","Q_Score":1,"Tags":"python,tensorflow,websocket,python-asyncio,python-multithreading","A_Id":55231076,"CreationDate":"2019-03-18T19:47:00.000","Title":"Python tensorflow: asyncio or threading","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am implementing a server for recognizing objects in photos using tensorflow-gpu in \"semi-real\" time.  It will listen for new photos on a websocket connection, then enqueue it into a list for the detector run when it is free.  Would it be simpler to use asyncio or threading to handle the websocket listener and the recognition queue?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":924,"Q_Id":55229009,"Users Score":0,"Answer":"Ultimately I used asyncio to handle the websocket connection, enqueuing incoming images to a queue.  I used threading which had a thread to read the image into RAM, extracted some metadata, and queued it for the object detector. The detector, running in another thread, tagged the images and queued the tags in the database handler (yet another thread).","Q_Score":1,"Tags":"python,tensorflow,websocket,python-asyncio,python-multithreading","A_Id":61762278,"CreationDate":"2019-03-18T19:47:00.000","Title":"Python tensorflow: asyncio or threading","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"File \"C:\\ProgramData\\Anaconda3\\Scripts\\tensorboard-script.py\", line 10, in \n    sys.exit(run_main())\n  File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorboard\\main.py\", line 57, in run_main\n    app.run(tensorboard.main, flags_parser=tensorboard.configure)\n  File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\absl\\app.py\", line 300, in run\n    _run_main(main, args)\n  File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\absl\\app.py\", line 251, in _run_main\n    sys.exit(main(argv))\n  File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorboard\\program.py\", line 228, in main\n    self._register_info(server)\n  File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorboard\\program.py\", line 274, in _register_info\n    manager.write_info_file(info)\n  File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorboard\\manager.py\", line 269, in write_info_file\n    payload = \"%s\\n\" % _info_to_string(tensorboard_info)\n  File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorboard\\manager.py\", line 129, in _info_to_string\n    for k in _TENSORBOARD_INFO_FIELDS\n  File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorboard\\manager.py\", line 129, in \n    for k in _TENSORBOARD_INFO_FIELDS\n  File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorboard\\manager.py\", line 51, in \n    (dt - datetime.datetime.fromtimestamp(0)).total_seconds()),\nOSError: [Errno 22] Invalid argument","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":669,"Q_Id":55229123,"Users Score":0,"Answer":"is your tensorboard 1.13.1?\nif so,make it come to 1.12.1,solved the problem.\nbut i can't find out the reason.","Q_Score":0,"Tags":"python,tensorflow","A_Id":55440002,"CreationDate":"2019-03-18T19:56:00.000","Title":"Get this error when trying to run tensorboard?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How is quantization applied\/simulated in software in practice? Suppose for example that I'd like to compute how much error in an output of some function I will get if instead of using 16 bit floating point values I were to use 6 bit integer values in the parameters of the function. If it matters for this question, I am interested in applying quantization to neural networks and the like.\nMy naive thoughts about this: either somehow force the machine to use reduced bit precision (doesn't seem feasible or easy to do on general purpose OS like Linux, but I'd be interested to know if it is done in practice), or artificially simulate the quantization by mapping ranges of floats to a single integer value, where the integer value represents one quantized value.\nI put C and python as a tags because I can only understand those languages if you'd like to answer with code.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":55229311,"Users Score":0,"Answer":"In general there are three approaches:\n\nAnalysis\nSimulation\nTesting\n\nTo analyze you must, of course, understand the calculation, and be a skilled mathematician.\nTo simulate you must still understand the calculation since you need to re-write it in the simulation language, but you don't need to be so good at math ;-)\nTesting is the easiest since you need neither understand of the calculation nor deep math skills. In your case this should be pretty trivial: since there are only 16-bit parameters, you can test all combinations of 2 arguments with 2^16 x 2^16 = 2^32 iterations of your test... a blink of an eye on a modern processor. Compare the result using 16-bit floats with 6-bit ints and keep some simple stats (mean error, max error, etc.). If you have more than two arguments you can save time over an exhaustive test by trying a large number of random inputs, but otherwise the same approach.","Q_Score":0,"Tags":"python,c,approximation","A_Id":55229729,"CreationDate":"2019-03-18T20:10:00.000","Title":"How is quantization applied\/simulated in software?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use pre-trained word embeddings in my machine learning model. The word embedings file I have is about 4GB. I currently read the entire file into memory in a dictionary and whenever I want to map a word to its vector representation I perform a lookup in that dictionary.\nThe memory usage is very high and I would like to know if there is another way of using word embeddings without loading the entire data into memory.\nI have recently come across generators in Python. Could they help me reduce the memory usage?\nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":237,"Q_Id":55230575,"Users Score":1,"Answer":"What task do you have in mind? If this is a similarity based task, you could simply use the load_word2vec_format method in gensim, this allows you to pass in a limit to the number of vectors loaded. The vectors in something like the Googlenews set are ordered by frequency, this will give you the critical vectors. \nThis also makes sense theoretically as the words with low frequency will usually have relatively bad representations.","Q_Score":1,"Tags":"python,machine-learning,memory-management,nlp,word-embedding","A_Id":55230793,"CreationDate":"2019-03-18T21:53:00.000","Title":"Is there an alternative to fully loading pre-trained word embeddings in memory?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"say I have a matrix : a = [[1,2,3],[4,5,6],[7,8,9]]. How can I combine it to b = [1,2,3,4,5,6,7,8,9]?\nMany thanks","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":55230862,"Users Score":0,"Answer":"using numpy: \nlist(np.array(a).flatten())","Q_Score":1,"Tags":"python,numpy","A_Id":55238524,"CreationDate":"2019-03-18T22:14:00.000","Title":"Python, how to combine integer matrix to a list","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Zapier, I have a \"Run Python\" action triggered by a \"Twitter\" event. One of the fields passed to me by the Twitter event is called \"Entities URLs Display URL\". It's the list of anchor texts of all of the links in the tweet being processed.\nZapier is passing this value into my Python code as a single comma-separated string. I know I can use .split(',') to get a list, but this results in ambiguity if the original strings contained commas.\nIs there some way to get Zapier to pass this sequence of strings into my code as a sequence of strings rather than as a single joined-together string?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":124,"Q_Id":55233255,"Users Score":2,"Answer":"David here, from the Zapier Platform team. \nAt this time, all inputs to a code step are coerced into strings due to the way data is passed between zap steps. This is a great request though and I'll make a note of it internally.","Q_Score":1,"Tags":"python,zapier","A_Id":55244199,"CreationDate":"2019-03-19T03:35:00.000","Title":"In Zapier, how do I get the inputs to my Python \"Run Code\" action to be passed in as lists and not joined strings?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have made a code using pytesseract and whenever I run it, I get this error:\nTesseractNotFoundError: tesseract is not installed or it's not in your path\nI have installed tesseract using HomeBrew and also pip installed it.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2063,"Q_Id":55235369,"Users Score":2,"Answer":"If installed with Homebrew, it will be located in \/usr\/local\/bin\/tesseract by default. To verify this, run which tesseract in the terminal as Dmitrrii Z. mentioned.\nIf it's there, you can set it up in your python environment by adding the following line to your python script, after importing the library:\npytesseract.pytesseract.tesseract_cmd = r'\/usr\/local\/bin\/tesseract'","Q_Score":0,"Tags":"python,python-3.x,macos,tesseract,python-tesseract","A_Id":58385393,"CreationDate":"2019-03-19T07:09:00.000","Title":"Where is the tesseract executable file located on MacOS, and how to define it in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to find the latest git issue number for a repository using python for all users rather than an authenticated user.\nIs there any way i could do this? either through the API or any library?\nI looked at the github docs and from my understanding it is not possible to list issues for all users but only authenticated users.\nI looked at pygithub where all i could find was how to create an issue through the library","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":249,"Q_Id":55236480,"Users Score":0,"Answer":"@Kevin Vizalil\nYou can use the Github API's to get the list of issues or single issue\nplease check https:\/\/developer.github.com\/v3\/issues\/#list-issues\nedit:\ne.g. https:\/\/api.github.com\/repos\/vmg\/redcarpet\/issues?sort=created&direction=desc","Q_Score":0,"Tags":"python,git,github,request,github-api","A_Id":55236763,"CreationDate":"2019-03-19T08:30:00.000","Title":"How to find the latest git issue number on github 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":"If I have the files frame.py and bindings.py both with classes Frame and Bindings respectively inside of them, I import the bindings.py file into frame.py by using from bindings import Bindings but how do I go about importing the frame.py file into my bindings.py file. If I use import frame or from frame import Frame I get the error ImportError: cannot import name 'Bindings' from 'bindings'. Is there any way around this without restructuring my code?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":55237179,"Users Score":0,"Answer":"Instead of using from bindings import Bindings try import bindings.","Q_Score":0,"Tags":"python","A_Id":55237563,"CreationDate":"2019-03-19T09:10:00.000","Title":"Call function from file that has already imported the current file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My team and I implemented a game in Python using Pygame. Whenever the game is run, alongside the GUI there is an extra black window that opens alongside, a .exe window. Is there anyway to stop it from opening?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":55239504,"Users Score":0,"Answer":"That is a command window, specifically one running python[Version Number].exe. To remove it simply change the scripts file extension to .pyw instead of .py, which changes the file type to the same thing [Python], but without the console window opening too.\nSo for example, script.py would become script.pyw","Q_Score":0,"Tags":"python,python-3.x,pygame","A_Id":55240130,"CreationDate":"2019-03-19T11:05:00.000","Title":"Pygame Code screen keeps opening with game","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"is it possible to generate loss curve for MLPregressor with lbfgs solver? it has been specified that it can be generated only for 'adam' solver.\nif it can be done, kindly help me in this regard.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":286,"Q_Id":55241237,"Users Score":-1,"Answer":"You can plot model.loss_curve_ on your dataframe, and you're good to go!","Q_Score":1,"Tags":"python,regression","A_Id":55241306,"CreationDate":"2019-03-19T12:35:00.000","Title":"can we generate loss curve for mlpregressor with lbfgs solver","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using spyder and trying to import pandas as pd and its giving me the following error:\nimport pandas as pd\nTraceback (most recent call last):\nFile \"\", line 1, in \n    import pandas as pd\nFile \"C:\\Users\\omer qureshi\\AppData\\Roaming\\Python\\Python37\\site-packages\\pandas__init__.py\", line 13, in \n    import(dependency)\nFile \"C:\\Users\\omer qureshi\\AppData\\Roaming\\Python\\Python37\\site-packages\\numpy__init__.py\", line 142, in \n    from . import core\nFile \"C:\\Users\\omer qureshi\\AppData\\Roaming\\Python\\Python37\\site-packages\\numpy\\core__init__.py\", line 23, in \n    WinDLL(os.path.abspath(filename))\nFile \"C:\\Users\\omer qureshi\\Anaconda3\\lib\\ctypes__init__.py\", line 356, in init\n    self._handle = _dlopen(self._name, mode)\nOSError: [WinError 193] %1 is not a valid Win32 application\nCan someone explain what's wrong?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1376,"Q_Id":55241360,"Users Score":0,"Answer":"Another thing might have happened. VS code automatically searches for the numpy and other packages from predefined OS locations. It might have found out 32 bit version of numpy instead of a 64 bit version. \nTo fix this Uninstall numpy from all OS locations.\n* In VS code terminal Type pip uninstall numpy or conda uninstall numpy (If you use Anaconda) \n* Restart VS code \n* Voila! (Reinstall numpy if the problem persists)","Q_Score":1,"Tags":"pandas,python-3.7","A_Id":57216578,"CreationDate":"2019-03-19T12:43:00.000","Title":"WinError 193] %1 is not a valid Win32 application","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a website which is built with django.\nProblem: we have >50 pages currently and exactly identical footer HTML code on each of those pages. I am getting tired of having to edit all those pages when adding a little change to the footer.\nPossible solution: inserting the footer directly in the django base page.\nPotential problems: if I insert the footer in the base page, all the individual JS scripts between the footer and the  tag would be lost - clearly those scripts are page specific. So could I have the specific JS scripts BEFORE the footer? This would allow the footer to go in the base nice and easily, but I'm not sure I can do this. Would moving the scripts before the footer be wrong?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":871,"Q_Id":55242452,"Users Score":0,"Answer":"You can put your footer HTML into its own file and then add the {% include 'footer.html' %} in the templates where you need the footer HTML to appear. That way in future you will only need to edit footer.html when you wish to change something in the footer.","Q_Score":0,"Tags":"javascript,python,html,django","A_Id":55242577,"CreationDate":"2019-03-19T13:41:00.000","Title":"Can I put JS scripts above footer instead of below footer before  tag","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to change the code while debugging in VSCode and that the change will take effect immediately without rerun the code?\nI'm using Microsoft Python extension.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2157,"Q_Id":55242996,"Users Score":1,"Answer":"So, apparently that the closest way of doing it is to use Jupyter capabilities (that can be use via VSCode).\nWith Jupyter you can split your code to multiple cells and run every each one of them separately without run all from beginning.","Q_Score":15,"Tags":"python,visual-studio-code,vscode-debugger","A_Id":59122714,"CreationDate":"2019-03-19T14:10:00.000","Title":"Change code while debugging python program in Visual Studio Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to change the code while debugging in VSCode and that the change will take effect immediately without rerun the code?\nI'm using Microsoft Python extension.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2157,"Q_Id":55242996,"Users Score":0,"Answer":"It depends. There's no such thing as a hot reload in Python. The closest you can come is importlib.reload(), but realize that only reloads the module and not the objects which already exist in memory. IOW it typically doesn't do what you want in code (it's usually used in the REPL).","Q_Score":15,"Tags":"python,visual-studio-code,vscode-debugger","A_Id":55248146,"CreationDate":"2019-03-19T14:10:00.000","Title":"Change code while debugging python program in Visual Studio Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is something that has been answered and re-answered time and time again because the answer keeps changing with updates to pandas. I tried some of the solutions I found here and elsewhere online and none of them have worked for me on the current version of pandas. Does anyone know the current, March 2019, pandas 0.24.2, fix for removing the default styling that a DataFrame gives to its header when converting it to an excel sheet? Simply using xlsxwriter to overwrite the styling does not work because of an issue with precedence.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11224,"Q_Id":55246202,"Users Score":0,"Answer":"The key explanation is that: pandas writes a df's header with set_cell(). A cell format (in xlsxwriter speak, a \"format\" is a FormatObject that you have to add to the worksheetObject) can NOT be overridden with set_row(). If you are using set_row() to your header row, it will not work, you have to use set_cell().","Q_Score":8,"Tags":"python,excel,pandas,dataframe,xlsxwriter","A_Id":55662072,"CreationDate":"2019-03-19T16:50:00.000","Title":"Remove default formatting in header when converting pandas DataFrame to excel sheet","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm aware that there are potentially severe security implications to pickling\/unpickling. I was planning to use pickling as a way to store and transfer an object instance in a Django model using jsonpickle. I was also going to use a hash or signature to verify the integrity of the pickle prior to unpickling (i.e. send the hash, then send the pickle, whatever).\nSince my own code would be producing the pickled object, would this method be safe enough (relatively or absolutely), assuming any object in transit would be encrypted as well?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":129,"Q_Id":55248121,"Users Score":0,"Answer":"If you just pass JSON (encrypted because of, say, an https connection is used), you eliminate the arbitrary code execution risk inherent to pickle. And you can validate the data before using it. You just have to worry about accepting the data from someone (and that's about authentication) allowed to communicate with you.\nYou can customize the JSON serialization it it doesn't support the type you want.\nExchanging JSON is pretty common with REST API's for example.\nThis looks safe (I am not a security expert though) and much simpler.","Q_Score":0,"Tags":"python,python-3.x,pickle,jsonpickle","A_Id":55749171,"CreationDate":"2019-03-19T18:50:00.000","Title":"Scenario safe for pickling in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've a MIP to solve with Pyomo and I want to set an initial solution for cplex.\nSo googling I find that I can set some variable of instance to some value and then execute this:\nsolver.solve(instance,warmstart=True,tee=True)\nBut when I run cplex it seem that it doesn't use the warm start, because for example i pass a solution with value 16, but in 5 seconds it return a solution with value 60.\nSo I don't know there is some error or other stuff that doesn't work.\nP.S.\nI don't know if is a problem but my warm start solution set only some variale to a value, but not all. Could be a problem?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1303,"Q_Id":55250019,"Users Score":1,"Answer":"Make sure that the solution you give to CPLEX is feasible. Otherwise, CPLEX will reject it and start from scratch. \nIf your solution is feasible, it is possible that CPLEX simply found a better solution than yours, since, after all, it is CPLEX's job, and in my own experience, CPLEX is very good at it. Is this a maximization problem? If so, in your example, CPLEX found a better solution (objective=60) than yours (objective=16), which is the expected behavior.\nSadly, CPLEX is often greedy in term of verbose, so it is hard to know from the solver log if warmstart was used or not (unlike its competitor GUROBI where it is clearly written in the log). However, it seems like you started the warmstart correctly, using the warmstart=True parameter. \nIf, however, your problem isn't a maximization problem, it is possible that CPLEX will not make a differenciation between the variables that you gave a value and the variable that still holds a solution from last solve. Plus, giving values to only a fraction of your variables might make the problem infeasible, considering that all values not manually specified are the values previously found by CPLEX. ex: contraint x<=2y. The solver found x=2, y=1 as a feasible solution. You define x:=3, then your constraint is not respected (y is still =1 for CPLEX, so the constraint x<=2y is 3<=2, which is false). CPLEX will see it as infeasible and will reject your solution. \nOne alternative that I can give you, if you absolutely want to use your own values in the final solution, is instead of defining values for your variables, create a constraint that explicitly defines your variable value. This constraint can afterward be \"deactivated\" if needed. But be careful, as this does not necessarily yield the optimal solution, but the \"optimal solution when some variables have the specific value\".","Q_Score":0,"Tags":"python,cplex,pyomo","A_Id":55250331,"CreationDate":"2019-03-19T21:08:00.000","Title":"Pyomo warm start","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I see many examples with either MonitoredTrainingSession or tf.Estimator as the training framework. However it's not clear why I would use one over the other. Both are configurable with SessionRunHooks. Both integrate with tf.data.Dataset iterators and can feed training\/val datasets. I'm not sure what the benefits of one setup would be.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":283,"Q_Id":55252406,"Users Score":0,"Answer":"Short answer is that MonitoredTrainingSession allows user to access Graph and Session objects, and training loop, while Estimator hides the details of graphs and sessions from the user, and generally, makes it easier to run training, especially, with train_and_evaluate, if you need to evaluate periodically. \nMonitoredTrainingSession different from plain tf.Session() in a way that it handles variables initialization, setting up file writers and also incorporates functionality for distributed training.\nEstimator API, on the other hand, is a high-level construct just like Keras. It's maybe used less in the examples because it was introduced later. It also allows to distribute training\/evaluation with DistibutedStrategy, and it has several canned estimators which allow rapid prototyping. \nIn terms of model definition they are pretty equal, both allow to use either keras.layers, or define completely custom model from the ground up.  So, if, for whatever reason, you need to access graph construction or customize training loop, use MonitoredTrainingSession. If you just want to define model, train it, run validation and prediction without additional complexity and boilerplate code, use Estimator","Q_Score":1,"Tags":"python,tensorflow,machine-learning,tensorflow-estimator","A_Id":55257099,"CreationDate":"2019-03-20T01:46:00.000","Title":"What are the reasons to use MonitoredTrainingSession vs Estimator in TensorFlow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Problem:\nThe Staked Auto Encoder is being applied to a dataset with 25K rows and 18 columns, all float values.\nSAE is used for feature extraction with encoding & decoding. \nWhen I train the model without feature scaling, the loss is around 50K, even after 200 epochs. But, when scaling is applied the loss is around 3 from the first epoch.\nMy questions:\n\nIs it recommended to apply feature scaling when SAE is used for feature extraction \nDoes it impact accuracy during decoding?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":535,"Q_Id":55253587,"Users Score":0,"Answer":"With a few exceptions, you should always apply feature scaling in machine learning, especially when working with gradient descent as in your SAE. Scaling your features will ensure a much smoother cost function and thus faster convergence to global (hopefully) minima. \n\nAlso worth noting that your much smaller loss after 1 epoch with scaling should be a result of much smaller values used to compute the loss.\n\nNo","Q_Score":1,"Tags":"python,neural-network,deep-learning,pytorch,autoencoder","A_Id":55256209,"CreationDate":"2019-03-20T04:25:00.000","Title":"Is Feature Scaling recommended for AutoEncoder?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to debug the code written in python in container using azure dev spaces for kubernetes ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":164,"Q_Id":55253980,"Users Score":0,"Answer":"Currently debugging in Azure Dev Spaces only lists Node.js, .NET Core, and Java as officially supported.  The documentation for how to debug these 3 types of environments was written pretty recently (Quickstarts published on 7\/7\/2019).  I am assuming that a guide for Python should be on the way shortly, but I have been unable to find any published timeline for this.","Q_Score":2,"Tags":"python,visual-studio,azure,kubernetes,containers","A_Id":57613177,"CreationDate":"2019-03-20T05:17:00.000","Title":"Azure dev spaces to debug python code running in kubernetes pod","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"The images that I have gives me inconsistent results.  My thought process is: my text is always in white font; if I can switch the pixel of my text to black and turned everything else to white or transparent, I will have better success.\nMy question is, what library or language is best for this?  Do I have to turn my white pixel into some unique RGB, turn everything else to white or transparent, then find the unique RGB and make that black?  Any help is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":501,"Q_Id":55254270,"Users Score":1,"Answer":"Yes, if you could make the text pixels black and all the rest of the documents white you would have better success, although this is not always possible, there are processes that can help.\n\nThe median filter (and other low pass filters) can be used to remove noise present in the image.\nerosion can also help to remove things that are not characters, like thin lines and also noise.\nalign the text is also a good idea, the OCR accuracy can drop considerably if the text is not aligned. To do this you could try the Hough transform followed by a rotation. Use the Hough transform to find a line in your text and then rotate the image in the same angle as the line.\n\nAll processing steps mentioned can be done with opencv or scikit-image.\nIs also good to point out that there are many other ways to process text, too many to mention.","Q_Score":0,"Tags":"python,image,canvas,tesseract","A_Id":55564020,"CreationDate":"2019-03-20T05:46:00.000","Title":"Prepare Image for OCR","Data 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 developed an application in Python with PyQt on Mac OS and I want to make .exe file for windows OS. How can I do this?\nI've tried in Ubuntu but it doesn't work. I'll be grateful for some useful assistance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10559,"Q_Id":55255421,"Users Score":0,"Answer":"Alright\u2026\nSo in Mac, there is a simple way to convert .py to .exe.\nIn terminal first open the file directory with the \u201ccd\u201d command\ni.e. cd Desktop\/MyFile\nThen run this code:\npyinstaller \u2014onefile name.py\nInstead of \u201cname.py\u201d put your own file.\nAfter that, in the same folder there will be created a  \u201cdist\u201d file, you can find the ready .exe there\u2026)","Q_Score":4,"Tags":"python,python-3.x,macos,py2exe,py2app","A_Id":68471783,"CreationDate":"2019-03-20T07:21:00.000","Title":"How to convert .py to .exe in Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I spinup postgres container and its data path \/var\/lib\/postgresql\/data is mapped to my local using volumes. As soon as container is up and database is setup the local path populates with all db data. I need to some how check programatically (using Python) if local location is proper postgres db data. This is needed if I need to create tables or not. I create if local directory is blank or invalid postgres data and I don't if it is valid. The reason I am trying to achieve this is if I want to hook up local db created due to postgers_container_1 to postgres_container_2","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":381,"Q_Id":55255883,"Users Score":1,"Answer":"If the file \/var\/lib\/postgresql\/data\/PG_VERSION exists, then it's probably a valid data directory. This is the first thing Postgres will check when you try to start the server.\nOf course, there are many, many other things required to make it a valid data directory - too many to check by yourself. If you need to be 100% sure, the only practical way is to start the Postgres server and try to connect to it.","Q_Score":0,"Tags":"python,database,postgresql","A_Id":55257430,"CreationDate":"2019-03-20T07:54:00.000","Title":"How to check if directory is valid Postgres database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a web applcation in Python and I only want the user to be able to enter a weekday that is older than today's date. I've had a look at isoweekday() for example but don't know how to integrate it into a flask form. The form currently looks like this:\nappointment_date = DateField('Appointment Date', format='%Y-%m-%d', validators=[DataRequired()])\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":126,"Q_Id":55258105,"Users Score":0,"Answer":"If you just want a weekday, you should put a select or a textbox, not a date picker.\nIf you put a select, you can disable the days before today so you don't even need a validation","Q_Score":0,"Tags":"python,forms,flask","A_Id":55258169,"CreationDate":"2019-03-20T10:03:00.000","Title":"How to only enter a date that is a weekday in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a nested r-tree like datastructure in Python (list of lists). The key is a large number (about 10 digits). On each level there are about x number of items (eg:10) in the list. Then within each list, it recurses and has x items and so on. The height of the tree is h levels (eg: 5). Each level also has an indication of what range of keys it contains (like r-tree).\nFor a given key, I need to locate the corresponding entry in the tree. This can be trivially done by scanning through each level, check if the given key lies within the range. If so, then step into that layer and recurse till it reaches the leaf.\nThis can also be done by successively dividing the key by x and taking the quotient as list index. \nSo the question is, what is more effecient : walking through list sequentially (complexity = depth * x (eg:50)) or successively dividing the large number by x to get the actual list indices (complexity = h divisions (eg: 5 divisions)). \n(ie) 50 range checks or 5 divisions ?\nThis needs to be scalable. So if this code is being accessed in cloud by very large number of users, what is efficient ? May be division is more expensive to perform at scale than range checks  ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":24,"Q_Id":55259486,"Users Score":1,"Answer":"You need to benchmark the code in somewhat realistic scenario.\nThe reason why it's so hard to say is that you are not just comparing division (by the way, modern compilers avoid divisions with a large number of tricks). On modern CPUs you have large caches so likely the list will fit into L2 or L3 which decreases the run-time dramatically. There's also the fancy vector\/SIMD instructions that might be used to speed up all the checks in the linear case.\nI would guess that going through the list sequentially will be faster, in addition the code will be simpler.\nBut don't take my word for it, take a real example and benchmark the two versions and pick based on the results. Especially if this is critical for your system's performance.","Q_Score":0,"Tags":"python,algorithm,optimization","A_Id":55263805,"CreationDate":"2019-03-20T11:16:00.000","Title":"Hash computation vs bucket walkthrough","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have whole project to convert from Python 2.x to 3.x. So can I go ahead & convert it by just 2to3 module?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":231,"Q_Id":55259840,"Users Score":0,"Answer":"i think you can. maybe there will be some errors but it generly it will be going well","Q_Score":0,"Tags":"python-3.x,python-2.7,module,python-2to3","A_Id":55260344,"CreationDate":"2019-03-20T11:35:00.000","Title":"How much accuracy does 2to3 Python module has to convert 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":"Most of the tutorials and books about Django or Flask import specific classes from files instead of importing the whole file.\nFor example, importing DataRequiered validator from wrtforms.validators is done via from wtforms import validators instead of importing it via import wtforms.validators as valids and then accessing DataRequiered with valids.DataRequiered.\n\nMy question is: Is there an reason for this ?\n\nI thought to something like avoiding the loading a whole module for computation\/memory optimization (is it really relevant?) ? Or is it simply to make the code more readable ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":55260308,"Users Score":0,"Answer":"It depends, in the tutorial that was probably done for readability\nUsually if you use most of the classes in a file, you import the file. If the files contains many classes but you only need a few, just import those. \nIt's both a matter of readability and optimization.","Q_Score":1,"Tags":"python,import","A_Id":55260578,"CreationDate":"2019-03-20T12:01:00.000","Title":"Does importing specific class from file instead of full file matters?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am getting an import error in python when importing pyimgur. I have tried pip install pyimgur but still get the same error.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":211,"Q_Id":55260318,"Users Score":0,"Answer":"maybe it has a other name? look in the map site-packages. there you can find all your site packages. maybe like i say it can have a other name.","Q_Score":0,"Tags":"python-3.x,raspberry-pi3","A_Id":55260405,"CreationDate":"2019-03-20T12:02:00.000","Title":"Import error: no module named pyimgur in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting an import error in python when importing pyimgur. I have tried pip install pyimgur but still get the same error.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":211,"Q_Id":55260318,"Users Score":0,"Answer":"pyimgur supports for python 2.x, adding Python 3 to setup.py specifiers and also in pypi metadata. Else try to install with commands \"pip3 install pyimgur\"","Q_Score":0,"Tags":"python-3.x,raspberry-pi3","A_Id":55260406,"CreationDate":"2019-03-20T12:02:00.000","Title":"Import error: no module named pyimgur in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have seen a couple of questions asking how to force a screen redraw in tkinter (which can be done using update_idletasks. I would like to do the opposite: suspend Tkinter's automatic screen redrawing until I have completed some major surgery to the application window - insert, delete, reposition a large number of widgets on a canvas, and then activate automatic screen redrawing after I'm done. Is that possible? I can't find any documented way of doing this. I'm using Tkinter with Python 3.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":498,"Q_Id":55262942,"Users Score":1,"Answer":"I would like to do the opposite: suspend Tkinter's automatic screen redrawing until I have completed some major surgery to the application window - insert, delete, reposition a large number of widgets on a canvas, and then activate automatic screen redrawing after I'm done. Is that possible?\n\nYes, it's possible. That's precisely how tkinter works by default. \nTkinter runs in a single thread. While any of your code is running, tkinter has no ability to update the screen unless you explicitly call update or update_idletasks for it to be updated.","Q_Score":1,"Tags":"python,tkinter,redraw","A_Id":55264073,"CreationDate":"2019-03-20T14:17:00.000","Title":"Python Tkinter pause screen redraw","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using python 3.7 on MacOS and somehow I can't import certain modules like Flask, Pandas or xldr. When I type in pip3 list all modules are installed. Other modules as np I can easily run...\nThe editor I use is Atom.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":55265158,"Users Score":0,"Answer":"Have you checked your PYTHONPATH? What exactly do you mean when you say that you can't import?","Q_Score":0,"Tags":"python,module","A_Id":55265265,"CreationDate":"2019-03-20T16:00:00.000","Title":"Why can't I import the modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If we have 4 parameters of X_train, y_train, X_test, and y_test, how can we calculate the bias and variance of a machine learning algorithm like linear regression?\nI have searched a lot but I could not find a single code for this.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":4892,"Q_Id":55266588,"Users Score":1,"Answer":"So in terms of a function to approximate your population, high bias means underfit, high variance overfit. To detect which, partition dataset into training, cross validation and test sets.\nA low training error but high cross validation error means its overfit. \nA high training error means its underfit. \nHigh Bias: add polynomial features, get more samples. High Variance: increase regularisation (squeeze polynomial parameters small), or gather more data so it trains better","Q_Score":0,"Tags":"python,python-3.x,linear-regression","A_Id":55267001,"CreationDate":"2019-03-20T17:13:00.000","Title":"bias and variance calculation for linear regression","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If we have 4 parameters of X_train, y_train, X_test, and y_test, how can we calculate the bias and variance of a machine learning algorithm like linear regression?\nI have searched a lot but I could not find a single code for this.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4892,"Q_Id":55266588,"Users Score":0,"Answer":"In real life, we cannot calculate bias & variance. Recap: Bias measures how much the estimator (can be any machine learning algorithm) is wrong with respect to varying samples, and similarly variance measures how much the estimator fluctuate around the expected value of the estimator. To calculate the bias & variance, we need to generate a number of datasets from some known function by adding noise and train a separate model (estimator) using each dataset. Since we don't know neither the above mentioned known function nor the added noise, we cannot do it. In practise, we can only calculate the overall error. In order to combat with bias\/variance dilemma, we do cross-validation.","Q_Score":0,"Tags":"python,python-3.x,linear-regression","A_Id":62696336,"CreationDate":"2019-03-20T17:13:00.000","Title":"bias and variance calculation for linear regression","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If we have 4 parameters of X_train, y_train, X_test, and y_test, how can we calculate the bias and variance of a machine learning algorithm like linear regression?\nI have searched a lot but I could not find a single code for this.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4892,"Q_Id":55266588,"Users Score":0,"Answer":"Evaluation of Variance:\nVariance = np.var(Prediction) # Where Prediction is a vector variable obtained post the \n                              # predict() function of any Classifier.\nSSE = np.mean((np.mean(Prediction) - Y)** 2) # Where Y is your dependent variable.\n                                             # SSE : Sum of squared errors. \nBias = SSE - Variance","Q_Score":0,"Tags":"python,python-3.x,linear-regression","A_Id":61523772,"CreationDate":"2019-03-20T17:13:00.000","Title":"bias and variance calculation for linear regression","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to implement the decision-tree learning alogorithm.\nI am pretty new to coding so I know it's not the best code, but I just want it to work. Unfortunately i get the error: e2 = b(pk2\/(pk2 + nk2))\nZeroDivisionError: division by zero\nCan someone explain to me what I am doing wrong?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":55268748,"Users Score":0,"Answer":"Lets assume after some splits you are left with two records with 3 features\/attributes (last column being the truth label)\n1   1   1   2\n2   2   2    1\nNow you are about to select the next best feature to split on, so you call this method remainder(examples, attribute) as part of selection which internally calls nk1, pk1 = pk_nk(1, examples, attribute). \nThe value returned by pk_nk for the above mentioned rows and features will be 0, 0 which will result in divide by zero exception for e1 = b(pk1\/(pk1 + nk1)). This is a valid scenario based on how you coded the DT and you should be handling the case.","Q_Score":0,"Tags":"python,decision-tree","A_Id":55269360,"CreationDate":"2019-03-20T19:26:00.000","Title":"Decision Tree Learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a bit confused about the concept of 'Run-level content' in python-docx.. I get that if I wanna check whether a paragraph is in bold or not, I need to check the run.bold, but what exactly is it?\nThe official definition is: A run is the object most closely associated with inline content; text, pictures, and other items that are flowed between the block-item boundaries within a paragraph.\nSo, is it singular character level content in the paragraph? am I missing anything here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1945,"Q_Id":55269663,"Users Score":9,"Answer":"A simple way to understand a run in Word is a sequence of characters that all share the same character formatting.\nSo if you have a sentence like this and want a bold word to appear, you can't tell the sentence to be bold (that would bold too much) and you don't want to tell each individual character to be bold (that would bold too-little at a time).\nSo you group the characters into runs and apply character formatting to the run (and that is juuuust right :).\nThe example sentence would need three runs. One before the bold word, one for the bold word itself, and one for after the bold word. The middle run would be set bold; the other two would have no special formatting.\nThere are more things to know about runs, like they are subordinate to a paragraph (so the same run can't start in one paragraph and end in another), but this is the main gist of the concept.","Q_Score":4,"Tags":"python-docx","A_Id":55270951,"CreationDate":"2019-03-20T20:29:00.000","Title":"What is Run-level content in python-docx?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need suggestions on how to speed up access to python programs when called from Golang.  I really need fast access time (very low latency).\nApproach 1:\nfunc main() {\n...\n...\n        cmd = exec.Command(\"python\", \"test.py\")\n        o, err = cmd.CombinedOutput()\n...\n}\nIf my test.py file is a basic print \"HelloWorld\" program, the execution time is over 50ms.  I assume most of the time is for loading the shell and python in memory.\nApproach 2:\nThe above approach can be speeded up substantially by having python start a HTTP server and then gaving the Go code POST a HTTP request and get the response from the HTTP server (python).  Speeds up response times to less than 5ms.\nI guess the main reason for this is probably because the python interpretor is already loaded and warm in memory.\nAre there other approaches I can use similar to approach 2 (shared memory, etc.) which could speed up the response from my python code?.  Our application requires extremely low latency and the 50 ms I am currently seeing from using Golang's exec package is not going to cut it.\nthanks,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":235,"Q_Id":55271734,"Users Score":0,"Answer":"Approach 1: Simple HTTP server and client\nApproach 2: Local socket or pipe\nApproach 3: Shared memory\nApproach 4: GRPC server and client\nIn fact, I prefer the GRPC method by stream way, it will hold the connection (because of HTTP\/2), it's easy, fast and secure. And it's easy moving python node to another machine.","Q_Score":0,"Tags":"python,go,exec,low-latency","A_Id":55272973,"CreationDate":"2019-03-20T23:43:00.000","Title":"Speed up access to python programs from Golang's exec packaqe","Data Science and Machine Learning":0,"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 to encrypt texts written in a file and decrypt it, without using the PyCrypto library. The file will contain string type data. Now I want to convert the strings to int numbers so that I can apply the RSA keys on the integer values. But I did not find any tutorial on how to convert texts into int. How to convert the strings into its integer value and Is there any better way of doing this? then how? Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":99,"Q_Id":55282063,"Users Score":1,"Answer":"I too had this project, and I did this: \nFirst what you will need is to read the datas from the text file and save it to a list. You can use .split() which will do this : \nIf the file contains only one line like this \nhello ! it will make it as \nlist_of_the_file['h', 'e', 'l', 'l', 'o', ' ', '!']\nNow as you have a list of all the letters that the file contains serially, you can use the ord() which will generate a unique value for each type of character for example a or more precisely ord(a) will give you the value 97 and it will return 97 only for the a present in the list not for any other character. Then you can apply the keys on that integer value and can store it in a list or a file. Hope this will help.","Q_Score":0,"Tags":"python,python-3.x,encryption,rsa,public-key-encryption","A_Id":55344870,"CreationDate":"2019-03-21T13:56:00.000","Title":"How to encrypt text using RSA algo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone has experience with mixed-precision training using the tensorflow estimator api? \nI tried casting my inputs to tf.float16 and the results of the network back to tf.float32. For scaling the loss I used tf.contrib.mixed_precision.LossScaleOptimizer.\nThe error messages I get are relatively uninformative: \"Tried to convert 'x' to a tensor and failed. Error: None values not supported\",","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":293,"Q_Id":55282603,"Users Score":0,"Answer":"I found the issue: I used tf.get_variable to store the learning rate. This variable has no gradient. Normal optimizers do not care, but tf.contrib.mixed_precision.LossScaleOptimizer crashes. Therefore, make sure these variables are not added to tf.GraphKeys.TRAINABLE_VARIABLES.","Q_Score":1,"Tags":"python,tensorflow,tensorflow-estimator","A_Id":55297814,"CreationDate":"2019-03-21T14:22:00.000","Title":"Training with mixed-precision using the tensorflow estimator api","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use the python Dataframe to_dict() method without generating timestamps.\nMy problem: I have a dataframe with cells containing dates such as this: \"2019-06-01\". When I call the dataframe method \"to-dict()\" to generate a dictionnary, it converts the datevalue into something like: \"Timestamp('2019-06-01 00:00:00')\".\nThis is not what I would like. I would just like it to return a simple string such as: \"2019-06-01\"\nIs it possible with optional parameters ?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":55282891,"Users Score":0,"Answer":"Simply convert those columns to object type with .astype(str) before calling to_dict().","Q_Score":0,"Tags":"python,dataframe,dictionary,timestamp","A_Id":55283054,"CreationDate":"2019-03-21T14:35:00.000","Title":"How to prevent Dataframe.to_dict() to generate timestamps","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a web automation project. I need to be able to pull pages, assess data, and be able to interact with the page (e.g. login, enter values, and post to the site.) As a derivative of the logins, I think I will need something that will allow me to remain logged in given a credential (e.g. store the credential or cookies.)\nI've already used UrlLib & Requests libraries to pull files and the pages themselves.\nI am trying to decide on the best Python library for the task.\nAny suggestions would be highly appreciated.\nthank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1516,"Q_Id":55285021,"Users Score":1,"Answer":"@n1c9\n\nIf you can reliably recreate the HTTP requests being used to authenticate logins and speed is important, urllib\/requests for making those HTTP requests and beautifulsoup for parsing the HTML responses would be best. Otherwise, Selenium is where you'll have the most luck. Let me know if you want more details. \n\nLooks like Selenium is the right answer.","Q_Score":1,"Tags":"python,beautifulsoup,urllib3,python-requests-html","A_Id":55291345,"CreationDate":"2019-03-21T16:24:00.000","Title":"beautiful soup vs selenium vs urllib","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to predict customer retention with a variety of features.\nOne of these is org_id which represents the organization the customer belongs to. It is currently a float column with numbers ranging from 0.0 to 416.0 and 417 unique values. \nI am wondering what the best way of preprocessing this column is before feeding it to a scikit-learn RandomForestClassifier. Generally, I would one-hot-encode categorical features, but there are so many values here so it would radically increase my data dimensionality. I have 12,000 rows of data, so I might be OK though, and only about 10 other features.\nThe alternatives are to leave the column with float values, convert the float values to int values, or convert the floats to pandas' categorical objects. \nAny tips are much appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":257,"Q_Id":55285986,"Users Score":2,"Answer":"org_id does not seem to be a feature that brings any info for the classification, you should drop this value and not pass it into the classifier.\nIn a classifier you only want to pass features that are discriminative for the task that you are trying to perform: here the elements that can impact the retention or churn. The ID of a company does not bring any valuable information in this context therefore it should not be used.\nEdit following OP's comment:\nBefore going further let's state something: with respect to the number of samples (12000) and the relative simplicity of the model, one can make multiple attempts to try different configurations of features easily.\nSo, As a baseline, I would do as I said before, drop this feature all together. Here is your baseline score i.e., a score you can compare your other combinations of features against.\nI think it cost nothing to try to hot-encode org_id, whichever result you observe is going to add up to your experience and knowledge of how the Random Forest behaves in such cases. As you only have 10 more features, the Boolean features is_org_id_1, is_org_id_2, ... will be highly preponderant and the classification results may be highly influenced by these features.\nThen I would try to reduce the number of Boolean features by finding new features that can \"describe\" these 400+ organizations. For instance, if they are only US organizations, their state which is ~50 features, or their number of users (which would be a single numerical feature), their years of existence (another single numerical feature). Let's note that these are only examples to illustrate the process of creating new features, only someone knowing the full problematic can design these features in a smart way.\nAlso, I would find interesting that, once you solve your problem, you come back here and write another answer to your question as I believe, many people run into such problems when working with real data :)","Q_Score":0,"Tags":"python,pandas,scikit-learn,categorical-data","A_Id":55286759,"CreationDate":"2019-03-21T17:23:00.000","Title":"Handling Categorical Data with Many Values in sklearn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im just interested in the debugger, but do not want my plots being altered by pixiedust. Is it possible to use the debugger, without pixiedust having any other effects?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":55286645,"Users Score":0,"Answer":"After 'import pixiedust_node', it just changes the display of cells when you use the library. You can use the debugger without using the rest of pixiedust. Just type '%%pixie_debugger' in the beginning of the cell.","Q_Score":0,"Tags":"python,debugging,jupyter-notebook,pixiedust","A_Id":55953841,"CreationDate":"2019-03-21T18:03:00.000","Title":"Is it possible to use the pixiedust debugger without the rest of pixidust?","Data 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 was coding a small project on Google Colaboratory and ran into a problem with the len() function, namely that it wouldn't work. I isolated it down and even this bit of code wont work:\nstring = \"Hello world\" \nprint(len(string))\nIt gives me this error:\nTypeError: 'str' object is not callable\nI've copied and pasted it over into a coding block on a tutorial website, and sure enough, it has no problem whatsoever.\nEdit: Okay last night I gave up and went to bed, this morning I showed the error to a friend AND NOW IT WORKS. I didn't touch the bloody code and it just solved itself. I'm mad. Anyways, thanks for the help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1033,"Q_Id":55288350,"Users Score":0,"Answer":"you probably have a class that has a method and a string property of the same name -- (in your case len), you trying to call the string property that gives you length of the string but actually the len method defined in the class you created is being called . Also make sure you dont have a variable called str in your code.","Q_Score":0,"Tags":"python,google-colaboratory,string-length","A_Id":55288445,"CreationDate":"2019-03-21T19:56:00.000","Title":"String length function gives TypeError: 'str' object is not callable in google colaboratory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a newbie in image processing and python in general. For an image recognition project, I want to compare every pixel with one another. For that, I need to create a program that iterates through every pixel, takes it's value (for example \"[28, 78, 72]\") and creates some kind of values through comparing it to every other pixel. I did manage to access one single number in an array element \/pixel (output: 28) through a bunch of for loops, but I just couldn't figure out how to access every number in every pixel, in every row. Does anyone know a good algorithm to solve my problem? I use OpenCV for reading in the image by the way.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":55288421,"Users Score":0,"Answer":"Comparing every pixel with a \"pattern\" can be done with convolution. You should take a look at Haar cascade algorithm.","Q_Score":0,"Tags":"python-3.x,algorithm,image-recognition","A_Id":55295961,"CreationDate":"2019-03-21T20:01:00.000","Title":"Python: Iterate through every pixel in an image for image recognition","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using numpy.savetxt() to save an array, but its rounding my values to the first decimal point, which is a problem. anyone have any clue how to change this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":789,"Q_Id":55288883,"Users Score":1,"Answer":"You can set the precision through changing fmt parameter. For example np.savetxt('tmp.txt',a, fmt='%1.3f') would leave you with an output with the precision of first three decimal points","Q_Score":0,"Tags":"python,save","A_Id":55289028,"CreationDate":"2019-03-21T20:38:00.000","Title":"numpy.savetxt() rounding values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Bit of a regex newbie here.\nI have this string:\nyear_with_txt = 'foo 1999' and \nyear_only = '1999'.\nI want to omit any 4 consecutive digits.\nWhen I do it this way:\nre.sub(r'^[0-9]{4}$', '', year_only)\nor \nre.sub(r'^\\d{4}$', '', year_only)\nit works. However, with other text in, it doesn't:\nre.sub(r'^[0-9]{4}$', '', year_with_txt)\nor \nre.sub(r'^\\d{4}$', '', year_with_txt)\nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":55290910,"Users Score":2,"Answer":"The reason is your ^ and $ tokens. Those refer to the start and end of the string respectively.\nre.sub(r'\\d{4}', '', year_with_txt) works.\nOutput:\n'foo '\nNote: you defined the string as year_with_txt, but referred to it in the rest of the code as year_with_text.","Q_Score":0,"Tags":"python,regex,string,text","A_Id":55290924,"CreationDate":"2019-03-21T23:54:00.000","Title":"re.sub not replacing if the whole string doesn't match","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have basic knowledge of SVM, but now I am working with images.  I have images in 5 folders, each folder, for example, has images for letters a, b, c, d, e.  The folder 'a' has images of handwriting letters for 'a, folder 'b' has images of handwriting letters for 'b' and so on.\nNow how can I use the images as my training data in SVM in Python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":55292341,"Users Score":0,"Answer":"as far i understood you want to train your svm to classify these images into the classes named a,b,c,d . For that you can use any of the good image processing techniques to extract features (such as HOG which is nicely implemented in opencv) from your image and then use these features , and the label as the input to your SVM training (the corresponding label for those would be the name of the folders i.e a,b,c,d) you can train your SVM using the features only and during the inference time , you can simply calculate the HOG feature of the image and feed it to your SVM and it will give you the desired output.","Q_Score":1,"Tags":"python,svm","A_Id":55294058,"CreationDate":"2019-03-22T03:06:00.000","Title":"Training SVM in Python with pictures","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a working installation of pmdarima in a conda enviroment\n\u00a0\n\n\u00a0 \u00a0 (pmdarima) > pip list | findstr pmdarima\n\u00a0 \u00a0 pmdarima \u00a0 \u00a0 \u00a0 \u00a01.1.0\n\n\u00a0\nAnd when I run python I am able to import pmdarima.\n\u00a0\n\n\u00a0 \u00a0 (pmdarima) > python\n\u00a0 \u00a0 Python 3.7.2 | packaged by conda-forge | (default, Mar 20 2019, 01:38:26) [MSC v.1900 64 bit (AMD64)] :: Anaconda, Inc. on win32\n\u00a0 \u00a0 Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u00a0 \u00a0 >>> from pmdarima.arima import auto_arima\n\u00a0 \u00a0 >>>\n\n\u00a0\nBut when I run a python script which imports pmdarima package I get this error.\n\u00a0\n\n\u00a0 \u00a0 (pmdarima) > python pmdarima.py\n\u00a0 \u00a0 Traceback (most recent call last):\n\u00a0 \u00a0 File \"pmdarima.py\", line 4, in \n\u00a0 \u00a0 \u00a0 \u00a0 from pmdarima.arima import auto_arima\n\u00a0 \u00a0 File \"project_path\\pmdarima.py\", line 4, in \n\u00a0 \u00a0 \u00a0 \u00a0 from pmdarima.arima import auto_arima\n\u00a0 \u00a0 ModuleNotFoundError: No module named 'pmdarima.arima'; 'pmdarima' is not a package\n\n\u00a0\nAfter getting this error I reopen python in the same enviroment and I cant even import the package here anymore\n\u00a0\n\u00a0 \u00a0 \n\n(pmdarima) > python\n\u00a0 \u00a0 Python 3.7.2 | packaged by conda-forge | (default, Mar 20 2019, 01:38:26) [MSC v.1900 64 bit (AMD64)] :: Anaconda, Inc. on win32\n\u00a0 \u00a0 Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u00a0 \u00a0 >>> from pmdarima.arima import auto_arima\n\u00a0 \u00a0 Traceback (most recent call last):\n\u00a0 \u00a0 File \"\", line 1, in \n\u00a0 \u00a0 File \"project_path\\pmdarima.py\", line 4, in \n\u00a0 \u00a0 \u00a0 \u00a0 from pmdarima.arima import auto_arima\n\u00a0 \u00a0 ModuleNotFoundError: No module named 'pmdarima.arima'; 'pmdarima' is not a package\n\n\u00a0\nAfter restarting the terminal I can import the package again in python and the rest repeats itself","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2045,"Q_Id":55294605,"Users Score":0,"Answer":"The problem was the name of my file. It was conficting with the name of the library. Thanks for your vote. It realy helped a lot!","Q_Score":0,"Tags":"python,pip,anaconda,python-import,conda","A_Id":55295008,"CreationDate":"2019-03-22T07:14:00.000","Title":"Can't import pmdarima even though it's installed properly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to add two vectors, one of which is (n,1) and the other (n,) such that the type is (n,)\nJust adding them with + gives the type (n,1). \nWhat is the function to convert it to a vector (same type as np.zeros(n))?\nOr to compute the sum directly into this format?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":65,"Q_Id":55297902,"Users Score":1,"Answer":"with .squeeze you can convert a (n,1) vector into an (n,) vector, then adding should work","Q_Score":0,"Tags":"python,numpy","A_Id":55298046,"CreationDate":"2019-03-22T10:44:00.000","Title":"Adding numpy arrays of different shape","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im building a parser algorithm on images. tesseract not giving accuracy. so im thinking to build a CNN+LSTM based model for image to text conversion. is my approach is the right one? can we extract only the required string directly from CNN_LSTM model instead of NLP? or you see any other ways to improve tesseract accuracy?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":55298360,"Users Score":0,"Answer":"NLP is used to allow the network to try and \"understand\" text. I think what you want here is to see if a picture contains text. For this, NLP would not be required, since you are not trying to get the network to analyze or understand the text. Instead, this should be more of an object detection type problem.\nThere are many models that do object detection.\nSome off the top of my head are YOLO, R-CNN, and Mask R-CNN.","Q_Score":0,"Tags":"deep-learning,lstm,python-tesseract","A_Id":55310781,"CreationDate":"2019-03-22T11:09:00.000","Title":"can we find the required string in image using CNN\/LSTM? or do we need to apply NLP after extracting text using CNN\/LSTM. can someone please clarify?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just started using pandapower today and I can't find a way to delete items. I don't know python at all, I've tried using delete(), remove() and pop() on all kind of different levels but it hasn't done anything. Is it even possible to delete elements?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":752,"Q_Id":55299203,"Users Score":2,"Answer":"To drop elements delete the row in the dataframe like this:\nnet[element].drop(idx_of_element_to_delete, inplace=True)\nFor example to drop bus 5:\nnet.bus.drop(5, inplace=True)\nAlternatively you can just set an element out of service so that it is ignored:\nnet.bus.in_service.at[5] = False\nIf you have questions about pandapower you will probably get faster answers on the github repository than on stackoverflow.","Q_Score":1,"Tags":"python,pandapower","A_Id":56951417,"CreationDate":"2019-03-22T12:01:00.000","Title":"How do I delete items in PandaPower?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a contanarized flask app with external db, that logs users on other site using selenium. Everything work perfectly in localhost. I want to deploy this app using containers and found selenium container with google chrome within could make the job. And my question is: how to execute scripts\/methods from flask container in selenium container? I tried to find some helpful info, but I didn't find anything. \nShould I make an API call from selenium container to flask container? Is it the way or maybe something different?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":115,"Q_Id":55299697,"Users Score":1,"Answer":"As far as i understood, you are trying to take your local implementation, which runs on your pc and put it into two different docker containers. Then you want to make a call from the selenium container to your container containing the flask script which connects to your database.\nIn this case, you can think of your containers like two different computers. You can tell docker do create an internal network between these two containers and send the request via API call, like you suggested. But you are not limited to this approach, you can use any technique, that works for two computers to exchange commands.","Q_Score":0,"Tags":"python,selenium,docker,flask,google-chrome-headless","A_Id":55302692,"CreationDate":"2019-03-22T12:32:00.000","Title":"How to execute script from container within another container?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I just started fiddling with opencv and python using pycharm. I followed a tutorial on how to create a Haar Cascade file, but when I reached the step where I had to use 'opencv_createsamples' command, it returned:\n\n\"is not recognized as an internal or external command\"\n\nI searched for a solution. Most of them said to add opencv to path in the enviroment variables, so I downloaded opencv, extracted it in the C directory and added it to the path, but it still did not work. Could someone help me?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1017,"Q_Id":55301045,"Users Score":1,"Answer":"I tried this a quickie and I got the same message. I also use PyCharm. Are you sure you're using the right version of opencv? I'm on 2.4 which is quite old. Maybe this is a method that's been added in a later version. If you can import cv2 it shouldn't be the pythonpath.","Q_Score":3,"Tags":"python,opencv,pycharm","A_Id":55303353,"CreationDate":"2019-03-22T13:48:00.000","Title":"opencv_createsamples command it is not recognized in pycharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to change the order of the output generated with Sphinx AutoDoc?\nIn particular, I am including private members, using the :private-members: directive. \nWhat I want is the private members to appear last in the output and not first which is the default, caused by alphabetic order and the \"_\" character coming before \"A\".","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1092,"Q_Id":55304406,"Users Score":7,"Answer":"Just as @Steve Piercy mentioned, you can set the order using the config value autodoc_member_order. To get the desired behaviour, just add autodoc_member_order = 'bysource' to your conf.py. This will make your documentations order the same as your source order.","Q_Score":3,"Tags":"python-sphinx,private-members,autodoc","A_Id":55333392,"CreationDate":"2019-03-22T16:54:00.000","Title":"Sphinx Autodoc output order","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large number of pdfs in different formats. Among other things, I need to extract their titles (not the document name, but a title in the text). Due to the range of formats, the titles are not in the same locations in the pdfs. Further, some of the pdfs are actually scanned images (I need to use OCR\/Optical Character Recognition on them). The titles are sometimes one line, sometimes 2. They do not tend to have the same set of words. In the range of physical locations the titles usually show up, there are often other words (ie if doc 1 has title 1 at x1, y1, doc 2 might have title 2 at x2, y2 but have other non-title text at x1 y1). Further, there are some very rare cases where the pdfs don't have a title.\nSo far I can use pdftotext to extract text within a given bounding box, and convert it to a text file. If there's a title, this lets me capture the title, but often with other extraneous words included. This also only works on non-image pdfs. I'm wondering if a) There's a good way to identify the title from among all the words I extract for a document (because there are often extraneous words), ideally with a good way to identify that no title exists, and b) if there are any tools that are equivalent to pdftotext that will also work on scanned images (I do have an ocr script working, but it does ocr over an entire image rather than a section of one). \nOne method that somewhat answers the title dilemma is to extract the words in the bounding box, use the rest of the document to identify which of the bounding box words are keywords for the document, and construct the title from the keywords. This wouldn't extract the actual title, but may give words that could construct a reasonable alternative. I'm already extracting keywords for other parts of the project, but I would definitely prefer to extract the actual title as people may be using the verbatim title for lookup purposes. \nFurther note if it wasn't clear - I'm trying to do this programatically with open source\/free tools, ideally in Python, and I will have a large number of documents (10,000+).","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2015,"Q_Id":55304845,"Users Score":0,"Answer":"For people who are come across this question later, I'll provide a quick update on what I've decided to do (albeit I haven't tested accuracy so I don't know if this approach is actually any good). \nThe overall approach I'll be using is machine learning via a neural net (I'll report back on accuracy once I have it). I'm essentially taking the first 200 words of a document, and generating n-grams of 4-20 sequential words (so ~16*200 n-grams of words; 4 b.c. none of my titles are shorter, 20 same but longer). I then generate a unique feature vector from each n-gram, the features I decided to use are partially dependent on my text but some are more general like \"Is the first letter of the first word in the n-gram capitalized?\". Knowing the correct titles, I can turn them into an equivalent vector. So If vec(n_gram) = vec(correct_title) then output 1, otherwise output 0. I'm using this to train an ML model. Currently this does Not solve my issue of scanned image pdfs, unless they're first converted into text documents. It also assumes word order is preserved among the title words when the pdf is turned into the n-grams. I have noticed the order of non-title words isn't always preserved by conversion but thats quite a rare problem and only seems to occur when there's line breaks and then the entire line is out of place (so it shouldn't affect the titles hopefully).","Q_Score":3,"Tags":"python,pdf,nlp,ocr,pdf-scraping","A_Id":55305507,"CreationDate":"2019-03-22T17:23:00.000","Title":"Title Extraction\/Identification from PDFs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So for a HW assignment, we're making a Yahtzee game. At least part of it. For preparation, our professors gave us a few questions to understand the main point of the assignment. \n1) The following documentation is provided for one function:\ndef roll_dice():\n''' rolls 5 dice, and returns a list of frequencies of each possible value\nfor example, element [3] of the return value is how many 3's appeared\n'''\nGIven this documentation, and the fact that the dice are six-sided cubes with the numbers 1,2,3,4,5,6 to choose from, which of these would be a correct return value from this function?\nAns: [0, 1, 0, 2, 0, 2, 0] \n2) Given the same documentation as the previous question, which of these would represent a dice roll with 4 2's?\nAns:  [0, 0, 4, 0, 0, 1] \n3) Which of the following would represent a case where all five dice rolled the same value, considering the documentation in the first question?\nAns: [0, 0, 0, 5, 0, 0, 0] \n4) In the game of Yahtzee, a full house is defined to a situation where three of the dice have the same number, and the other two dice equal each other (but different from the first three).\nWhich of these would represent a full house, given the documentation from the first question?\nAns: [0, 2, 0, 0, 3, 0, 0] \nI don't understand how to interpret these types of questions. For 1) the range would be from (0,2)? Hence giving you the random amount of times for getting it? Or would we be using choices() with weights instead? For the second one, what does the '4' represent? The third question is along the same lines.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":55306099,"Users Score":0,"Answer":"The numbers in brackets represent the frequency of a specific dice roll, corresponding to the numbers on the dice in order from 1 through 6.\nThe listed answer for 2) would correspond to a dice roll of 4 3's, because the 4 is in the 3rd position in the array.","Q_Score":0,"Tags":"python,python-3.x","A_Id":55306169,"CreationDate":"2019-03-22T18:51:00.000","Title":"How to understand the return values when it comes to using import random, .radiant(), or .choice()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Jupyter notebooks with jupyter-contrib-nbextensions and I can fold sections as well as code blocks in them. I want to know if there is a way to preserve the folding feature when the notebook is exported to html.  Currently when I export to html, I can't fold anything. The notebook becomes cumbersome to handle if it's long, even if there's a table of contents. I'll appreciate any ideas in this regard. Thanks!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":974,"Q_Id":55306404,"Users Score":2,"Answer":"Interesting need.  I briefly looked into this.  Looks like the nbextensions don't have that capability.  I think there are perhaps two choices, both of which would require quite some work:  \n\nTake the html file and convert it to some form that would allow cascading style sheets and then manually implement folding\nIf you are looking to do this repeatedly and have the skills, then you could look at the nbextensions code and try to change it to make it fold\n\nIf you find any other options or solutions, post it here.","Q_Score":2,"Tags":"python,jupyter-notebook,jupyter,folding,jupyter-contrib-nbextensions","A_Id":55306608,"CreationDate":"2019-03-22T19:14:00.000","Title":"Jupyter notebook: Is there a way to fold sections while exporting to html","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I downloaded VS2019 preview to try how it works with Python.\nI use Anaconda, and VS2019 sees the Anaconda virtual environment, terminal opens and works but when I try to launch 'import numpy', for example, I receive this:\n\nAn internal error has occurred in the Interactive window.  Please\n  restart Visual Studio. Intel MKL FATAL ERROR: Cannot load\n  mkl_intel_thread.dll. The interactive Python process has exited.\n\nDoes anyone know how to fix it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1421,"Q_Id":55307873,"Users Score":0,"Answer":"I had same issue, this worked for me:\nTry to add conda-env-root\/Library\/bin to the path in the run environment.","Q_Score":1,"Tags":"python,visual-studio,anaconda,visual-studio-2019","A_Id":58827105,"CreationDate":"2019-03-22T21:15:00.000","Title":"Visual Studio doesn't work with Anaconda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a ReactJS project and using Amplify for Signup\/Signin. On signup, I have a post confirmation lambda trigger in Python that stores the user information (username, cognito id, etc.) in an on-prem database. I would like to also store the identity id, but I can't seem to find it in the event or context variable. I can find the identity id by calling Auth.currentCredentials() in React after the user has signed in, but would like to get this information during the signup process. \nAny help on this would be appreciated. Thank you.","AnswerCount":3,"Available Count":2,"Score":-0.1325487884,"is_accepted":false,"ViewCount":1421,"Q_Id":55308723,"Users Score":-2,"Answer":"You can save the identityId in a custom attribute","Q_Score":4,"Tags":"python,amazon-web-services,amazon-cognito,aws-amplify","A_Id":60999641,"CreationDate":"2019-03-22T22:44:00.000","Title":"How to get Cognito Identity Id in Post Confirmation Lambda Trigger in Python using Amplify React?","Data Science and Machine Learning":0,"Database and SQL":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 ReactJS project and using Amplify for Signup\/Signin. On signup, I have a post confirmation lambda trigger in Python that stores the user information (username, cognito id, etc.) in an on-prem database. I would like to also store the identity id, but I can't seem to find it in the event or context variable. I can find the identity id by calling Auth.currentCredentials() in React after the user has signed in, but would like to get this information during the signup process. \nAny help on this would be appreciated. Thank you.","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":1421,"Q_Id":55308723,"Users Score":4,"Answer":"I had this same issue, and found that it is indeed not available in the auth trigger because the user has to authenticate to retrieve it, as you said.  There is also not a way (that I could find) to grab this information using the AWS admin SDK.\nI resorted to running a small check after the user logs into the app and doing a call to save the identityId where I needed it.  The purpose was to allow other users to access the user's media after logging in, by using the user's own identityId with amplify to pull a profile picture.  \nHope this helps.","Q_Score":4,"Tags":"python,amazon-web-services,amazon-cognito,aws-amplify","A_Id":55308853,"CreationDate":"2019-03-22T22:44:00.000","Title":"How to get Cognito Identity Id in Post Confirmation Lambda Trigger in Python using Amplify React?","Data Science and Machine Learning":0,"Database and SQL":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 Windows I need to send an NBNS name query packet (which uses UDP protocol), and I need to send 255 packets and get an answer for each. With Scapy it takes a year, so I wanted to know if there is a way to speed it up or maybe use sockets instead?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":138,"Q_Id":55309306,"Users Score":0,"Answer":"You could use two threads, one that is sending packets using a conf.L3socket() socket from scapy and another thread that is receiving packets using sniff().","Q_Score":1,"Tags":"python-2.7,sockets,networking,scapy","A_Id":72091366,"CreationDate":"2019-03-23T00:07:00.000","Title":"Scapy send packets speed up in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a snippet of code from my python 2.7 program:\ncur.execute(\"UPDATE echo SET ? = ? WHERE ID = ?\", (cur_class, fdate, ID,))\nthat when run, keeps throwing the following error:\nsqlite3.OperationalError: near \"?\": syntax error\nThe program is supposed to insert today's date, into the class column that matches the student ID supplied. If I remove the first \"?\" like so and hard code the parameter:\ncur.execute(\"UPDATE echo SET math = ? WHERE ID = ?\", (fdate, ID,))\neverything works just fine. I've googled all over the place and haven't found anything that works yet so I'm throwing out a lifeline.\nI've tried single quotes, double quotes, with and without parenthesis and a few other things I can't remember now. So far nothing works other than hard coding that first parameter which is really inconvenient.\nAs a troubleshooting step I had my program print the type() of each of the variables and they're all strings. The data type of the the cur_class field is VARCHAR, fdate is DATE, and ID is VARCHAR.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":55310428,"Users Score":0,"Answer":"Thanks to the tip from @Shawn earlier I solved the issue with the following code and it works great:\nsqlcommand = \"UPDATE echo SET \" + cur_class + \" = \" + fdate + \" WHERE ID = \" + ID\ncur.execute(sqlcommand)\nThis way python does the heavy lifting and constructs my string with all the variables expanded, then has the db execute the properly formatted SQL command.","Q_Score":0,"Tags":"python-2.7,sqlite","A_Id":55313778,"CreationDate":"2019-03-23T03:45:00.000","Title":"SQLite 3 Error when using parameter string, but not when implicitly typed","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run cv2, but when I try to import it, I get the following error:\nImportError: libGL.so.1: cannot open shared object file: No such file or directory\nThe suggested solution online is installing\napt install libgl1-mesa-glx\nbut this is already installed and the latest version.\nNB: I am actually running this on Docker, and I am not able to check the OpenCV version. I tried importing matplotlib and that imports fine.","AnswerCount":14,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":205048,"Q_Id":55313610,"Users Score":2,"Answer":"had the same issue on centos 8 after using pip3 install opencv on a non gui server which is lacking all sorts of graphics libraries.\ndnf install opencv\npulls in all needed dependencies.","Q_Score":203,"Tags":"python,ubuntu-14.04","A_Id":67337028,"CreationDate":"2019-03-23T12:14:00.000","Title":"ImportError: libGL.so.1: cannot open shared object file: No such file or directory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run cv2, but when I try to import it, I get the following error:\nImportError: libGL.so.1: cannot open shared object file: No such file or directory\nThe suggested solution online is installing\napt install libgl1-mesa-glx\nbut this is already installed and the latest version.\nNB: I am actually running this on Docker, and I am not able to check the OpenCV version. I tried importing matplotlib and that imports fine.","AnswerCount":14,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":205048,"Q_Id":55313610,"Users Score":0,"Answer":"For me, the problem was related to proxy setting. For pypi, I was using nexus mirror to pypi, for opencv nothing worked. Until I connected to a different network.","Q_Score":203,"Tags":"python,ubuntu-14.04","A_Id":71321056,"CreationDate":"2019-03-23T12:14:00.000","Title":"ImportError: libGL.so.1: cannot open shared object file: No such file or directory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So my problem is that I have two versions of python: 2.7 and 3.2. I want to install pycrypto on the 2.7 one but when I try to do this:\npython2.7 pip install pcrypto\nOr:\npip2.7 install pycrypto\nIt says that python2.7 or pip2.7 is not a recognized command.\nWhat should I do?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":55313950,"Users Score":0,"Answer":"pip installs a library for any version of Python 2\npip3 installs a library for any version of Python 3","Q_Score":0,"Tags":"python,python-2.7,pyinstaller","A_Id":55313960,"CreationDate":"2019-03-23T12:56:00.000","Title":"How to use pip on a specific version of python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am used to vb.net. I am learning python 3.6\/7, as I understand it code writing is in either:\n\nfunctions that return a result\nfunctions that return a None\nIn a modules (no functions), ie run the module.py\nIn a class ie run the class.ID.function (ref (1) and (2))\n\nIn .Net you can run code in a function and a sub routine, so python has no sub routines, just functions returning None.\nIs this correct?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":89,"Q_Id":55317316,"Users Score":1,"Answer":"Every function in python return some value, if you don't specify the return value then it will implicitly return None. So there is no distinction like sub or function in python.","Q_Score":2,"Tags":"python","A_Id":55317438,"CreationDate":"2019-03-23T18:58:00.000","Title":"How to write code in python (from a vb net guy)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am used to vb.net. I am learning python 3.6\/7, as I understand it code writing is in either:\n\nfunctions that return a result\nfunctions that return a None\nIn a modules (no functions), ie run the module.py\nIn a class ie run the class.ID.function (ref (1) and (2))\n\nIn .Net you can run code in a function and a sub routine, so python has no sub routines, just functions returning None.\nIs this correct?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":89,"Q_Id":55317316,"Users Score":1,"Answer":"Like other programming languages, in Python:\n\nTo let a function return a value, you have to use the return statement.\n\nBut if you don't specify the return value then it will simply return Nothing.","Q_Score":2,"Tags":"python","A_Id":55317570,"CreationDate":"2019-03-23T18:58:00.000","Title":"How to write code in python (from a vb net guy)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to avoid recomputing a costly array in Python. Luckily it is immutable - so \"copying a pointer\" would suffice. Unluckily the program is divided into a load of modules, and I need it here and there and variables are at most module-global in Python. How do I \"import\" the array into another module after I have computed it once (e.g. in main)?\n\nOne single program: My project colleagues will shoot me :-)\n\"Piping through\" as parameter via the function calls: I shoot myself. :-) (Also, think of the dependencies...)\nPut all functions that need it into the same module: Egad, the architecture is ruined. Also, I don't have the parameters for the array computation at that location.\n\n(sorry, don't have any useful code)\nWell, the actual result is that the program is a snail and making 1000000 runs to get meaningful statistics is out of question...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":55318101,"Users Score":0,"Answer":"If my understanding is correct (feel free to correct me otherwise), then if something is a global variable in say workspace.py and I have another program project.py I can run from workspace import * to get the same global variable namespace as my workspace.py file. This is generally frowned upon though because you may unwittingly reuse the same variable name without realizing it, thus breaking your program. It also (needlessly in most cases) loads all the variables into RAM essentially making project.py just an extension of your original workspace.py with access to the same classes, methods, and variables.","Q_Score":0,"Tags":"python,global-variables","A_Id":55318156,"CreationDate":"2019-03-23T20:33:00.000","Title":"Making a costly Python array global","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my python script in VSCode, pylint will warn against unused variables in e.g. a function, but not in the global scope. Can pylint be configured within VSCode to flag unused global variables?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":623,"Q_Id":55320801,"Users Score":2,"Answer":"OK, got it: \n\nIn VSCode, add the setting \"python.linting.pylintEnabled\": true\nIn your .pylintrc file in the root of your project add\/set allow-global-unused-variables=no","Q_Score":1,"Tags":"python,pylint","A_Id":55321541,"CreationDate":"2019-03-24T04:43:00.000","Title":"Can pylint be used to flag unused global variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed Python and VScode yesterday. I was trying to use pip to install updates but the command python doesn't work. However py does. I'm wondering why this is and if there's a way to make the command python recognized.\nIn addition, I was wondering if there was a quicker way to run the terminal\/shortcut alternative to right-clicking then selecting Run Python File in Terminal.\nLastly, I wanted to understand if I messed up during installation, because when I ran setx PATH \"%PATH%;C:\\Python34\\Scripts\" then echo %PATH%, instead of a seeing C:\\Python34\\Scripts I see a huge block of paths like:\n\nC:\\Program Files (x86)\\Razer\\ChromaBroadcast\\bin;C:\\Program Files\\Razer\\ChromaBroadcast\\bin;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Program Files (x86)\\Razer Chroma SDK\\bin;C:\\Program Files\\Razer Chroma SDK\\bin;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Users\\yiyan\\AppData\\Local\\Microsoft\\WindowsApps;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR;C:\\Program Files (x86)\\Razer\\ChromaBroadcast\\bin;C:\\Program Files\\Razer\\ChromaBroadcast\\bin;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Program Files (x86)\\Razer Chroma SDK\\bin;C:\\Program Files\\Razer Chroma SDK\\bin;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Users\\yiyan\\AppData\\Local\\Microsoft\\WindowsApps;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR;C:\\Program Files (x86)\\Razer\\ChromaBroadcast\\bin;C:\\Program Files\\Razer\\ChromaBroadcast\\bin;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Program Files (x86)\\Razer Chroma SDK\\bin;C:\\Program Files\\Razer Chroma SDK\\bin;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\W\n\nThank you for your time!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":152,"Q_Id":55322506,"Users Score":0,"Answer":"I think the console command being 'py' and not 'python' anymore is post Python 3.8. I had Python 3.7 up until a few days ago and got confused when I updated too.","Q_Score":0,"Tags":"python-3.x,visual-studio-code","A_Id":66522320,"CreationDate":"2019-03-24T09:48:00.000","Title":"First time questions: why is 'py' recognized but 'python' not? Shortcut for running in terminal? 'echo %PATH%' giving huge paths?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I use ray to create the actors and learner in A2C, should I set inter_op_parallelism_threads and intra_op_parallelism_threads to 1, or leave it by default?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1353,"Q_Id":55323169,"Users Score":1,"Answer":"It depends how many resources you want to the actor to use. If there is a dedicated machine for a given actor, and it's ok for the actor to use all of the resources on that machine, then use TensorFlow's default settings. If you are creating more like one actor per core, then setting inter_op_parallelism_threads and intra_op_parallelism_threads to small values like 1 or 2 is a good idea.\nIn general, you can try both approaches and see which is faster.","Q_Score":1,"Tags":"python,tensorflow,ray","A_Id":55329033,"CreationDate":"2019-03-24T11:08:00.000","Title":"Should I set `inter_op_parallelism_threads` and `intra_op_parallelism_threads` to 1 when I use ray to create a actor?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to set some pylint settings globally but I don't know if there is an global pylint configuration or where it is...\nI know there is an .pylintrc file but it's not a global configuration.\nSo my question is how to set pylint settings globally.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":753,"Q_Id":55323189,"Users Score":2,"Answer":"pylint is meant to be set up per python module, so it is always suggested to have it per module, instead of having it globally, so that you can track these files in git.","Q_Score":1,"Tags":"python,windows,pylint,pylintrc","A_Id":55323214,"CreationDate":"2019-03-24T11:11:00.000","Title":"Is there a global pylint configuration?","Data Science and Machine Learning":0,"Database and SQL":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 an AWS Lambda, written in python and behind API Gateway, which makes a network request out to a third party.\nShortly after that request, a separate request will be made by the third party to the URL of my choosing - I need to get a hold of the body of that request and return it in the response from my Lambda.\nIf perhaps I have the third party send to a second Lambda, how can I hold the first Lambda open, waiting for an event from the second Lambda?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":373,"Q_Id":55325063,"Users Score":0,"Answer":"(In the hope that someone offers a better idea...)\nWhat I'm currently intending to do is stand up a redis (Elasticache) cluster. Lambda A will send out a request with an X-Request-ID and then setup a redis pubsub().subscribe(X-Request-ID). Lambda B will receive the response and do a redis pubsub().publish(X-Request-ID, response). Lambda A will then return the response or, if not received in time, timeout.\nInelegant but I think it works.","Q_Score":0,"Tags":"python,amazon-web-services,asynchronous,aws-lambda","A_Id":56402127,"CreationDate":"2019-03-24T14:54:00.000","Title":"AWS Lambda (in python) waiting for asynchronous event","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do you upload an image from your web to gcloud Storage?\n\nclient: React app\nserver: Python(Flask)\n\nCLIENT SIDE: I have a file browse component where I choose an image from the local drive. Then, I transform the image into a base64 string, and send it to the server.\nSERVER-SIDE: \nThen I upload the base64 image: blob.upload_from_string(base64data, type=\"image\/jpeg\")\nBut when I look inside my bucket I see a 1 black pixel image.\nQuestions\n\nCan I upload a base64 image right into my bucket?\nWhy does my image is being procced as a black pixel? where does it break?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1562,"Q_Id":55326249,"Users Score":1,"Answer":"In the end what i did was to remove the first part of the string data:image\/jpeg;base64,, (of course its not necessarily a jpeg.. its just an example).\nI decoded  the rest of the string back to an image, and passed the content_type also.\nThat solved my problem","Q_Score":2,"Tags":"python,base64,storage,gcloud","A_Id":55406473,"CreationDate":"2019-03-24T16:59:00.000","Title":"How to upload base64 image to GCloud Storage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have some model where there are date field and CharField with choices New or Done, and I want to show some message for this model objects in my API views if  2 conditions are met, date is past and status is NEW, but I really don't know how I should resolve this.\nI was thinking that maybe there is option to make some field in model that have choices and set suitable choice if conditions are fulfilled but I didn't find any information if something like this is possible so maybe someone have idea how resolve this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":55326465,"Users Score":0,"Answer":"You need override the method save of your model. An overrided method must check the condition and show message\nYou may set the signal receiver on the post_save signal that does the same like (1).","Q_Score":0,"Tags":"python,django","A_Id":55328234,"CreationDate":"2019-03-24T17:23:00.000","Title":"Automatically filled field in model","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"im fairly new to programming in Python and i've been using the terminal to run my code with no problem. Usually by typing python {filename} to run it. \nHowever, recently i got this error:\nImportError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.\nthen i changed the python {filename} to pythonw {filename} and the code worked. Could someone give me some insight into this error and why it worked by just adding w?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2189,"Q_Id":55326688,"Users Score":1,"Answer":"pythonw - run python script allowing GUI.  According to the man page for pythonw.","Q_Score":0,"Tags":"python-3.x,macos,terminal","A_Id":55327734,"CreationDate":"2019-03-24T17:46:00.000","Title":"What is the difference between \"python\" and \"pythonw\" in the mac Terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I looked at the data and it seemed numeric?. I wrote a little loop and it displays values like 84 as not int, or 214.56 as not float. It just seems broken. Do Pandas Data Frames just have a randomness to them?\nMy data set has this shape:\n(622380, 45)\nWhen I isolate the column it still has a problem. But when I shorten the column it seems to be OK. \nIs there a length at which the data frame becomes unstable? Can I force the data types?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":349,"Q_Id":55328568,"Users Score":0,"Answer":"After digging around some more..  I found a better way to debug the data.\n    pd.to_numeric(model_data['Value2SPY'])\nDid the trick because when it bombed out it told me the line item..\nValueError: Unable to parse string \"#DIV\/0!\" at position 241396\nThe code I was using before \"if not isinstance(val, int):\" just was a bad method to debug the data...","Q_Score":0,"Tags":"python","A_Id":55328727,"CreationDate":"2019-03-24T21:05:00.000","Title":"Pandas Data Frame Data Type Recognized as object and not Numeric","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a task where I need to web scrape boxofficemojo site.\nI coded everything and it is working perfectly fine in my local machine.\nThere are around 19000 urls that I need to scrape. As it is obviously a time consuming process, I don't want to run it on my local machine. Instead I want to run it on an aws ec2 instance.\nThe ec2 instance is Ubuntu 18.04. I have verified python versions and the libraries used in script are present or not and everything.\nHowever, if I try\nrequests.get('http:\/\/www.boxofficemojo.com') ,\nit is giving me 503 response. If I print the response text, it is saying We are in process of updating site right now.  But the same thing is working in my local machine.\nWhy am I getting this wierd behaviour in ec2 instance.\nI tried testing internet connection inside the ec2 instance by issuing ping command . It's working fine.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":101,"Q_Id":55328681,"Users Score":4,"Answer":"There are public sites, and public api's that specifically block calls from ec2 instances (and probably other cloud providers). \nIt's not impossible that some of the sites you are trying to scrape, simply blacklist ec2 instances ip ranges to cut down on the 'bots' that are eating up their resources ... I have come across this several times, for several sites.\nThe NBA stats api is one example I am familiar with, but I have come across others as well - the sites you are scraping may be some of them as well.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-ec2,web-scraping,python-requests","A_Id":55328905,"CreationDate":"2019-03-24T21:19:00.000","Title":"Why am I getting different http responses from different locations?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on a Project in Raspberry Pi Zero, with apache as web server. The website is in PHP and based on user inputs, it updates a XML file in the server.\nThere is also a python program program running parallely with the web server. This python program contantsly reads the XML and grabs the values from XML, stores them locally and checks for changes in them and if there is any changes it performs some UART communications with external devices, sometimes based on these external communication from the devices, python also updates the XML.\nPython reads the XML every 2 seconds, and the problem is sometimes, when the python is doing the read operation, if the user prodives input and if PHP inserts the new value to the same XML, python crashes. The client wants to reduce the 2 second delay to .1 second, which means Python will be reading fastly and any changes from PHP will crash it.\nIs there a way to get somekind of file lock between python and PHP so that, when Python is reading or writing PHP waits and if PHP is writing Python waits. Priority goes to Python above PHP.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":55328712,"Users Score":0,"Answer":"Would be better to have an api call first which would suggest if the data is being changed currently and when was the last data changed.\nThis way you can avoid the crash which is happening due to sharing of the resource","Q_Score":0,"Tags":"php,python,xml,file-handling,file-locking","A_Id":55329011,"CreationDate":"2019-03-24T21:23:00.000","Title":"Handling a common XML file between PHP and 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 dataframe with 5632 columns, and I only want to keep 500 of them. I have the columns names (that I wanna keep) in a dataframe as well, with the names as the row index. Is there any way to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":55330844,"Users Score":0,"Answer":"Let us assume your DataFrame is named as df and you have a list cols of column indices you want to retain. Then you should use:\ndf1 = df.iloc[:, cols]\nThis statement will drop all the columns other than the ones whose indices have been specified in cols. Use df1 as your new DataFrame.","Q_Score":0,"Tags":"python-3.x,pandas,dataframe","A_Id":55332549,"CreationDate":"2019-03-25T03:15:00.000","Title":"how to drop multiple (~5000) columns in the pandas dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my PC, I have 16 logical cores(multiprocessing.cpu_count()=16). I have an application which has around 2000 independent processes. I used multi-threading with different thread counts and the results are as follows. \n\nThreads | Total Time(s)\n8 | 4225 (~ 70 min)\n16 | 2733 (~ 46 min)\n32 | 2156 (~ 35 min)\n64 | 2123 (~ 35 min)\nTheoretically, I should get the best results when thread count is 16. And I should get the same results even if the thread count is increased above 16. But I'm getting the best results when the thread count is increased to 32. And the results looks to be unchanged above that count. What is the reason for that?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":246,"Q_Id":55331369,"Users Score":2,"Answer":"Strictly speaking, Python cannot run more than one thread concurrently (because of GIL), so any threads that run Python code at 100% CPU usage (e.g. pure calculation) will always degrade in performance with more threads.\nGetting any performance increases from threads means you have some I\/O in your code that is being waited on, which makes your thread's CPU utilisation fall under 100%. Increasing the number of threads allows the CPU to fill up those gaps.","Q_Score":1,"Tags":"python,python-3.x,multithreading","A_Id":55331407,"CreationDate":"2019-03-25T04:42:00.000","Title":"Why performance is improved when thread count is increased than the hardware-possible thread count?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to roundoff a number which has 5 in last. Python round function rounds the decimal number to ceil integer if decimal value >=5.\nI want round(30.195,2) to output 30.19 but python gives 30.2","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":698,"Q_Id":55335712,"Users Score":0,"Answer":"you can subtract 0.001 from all the numbers you have and save in a separate list. that way, the round function will work as you wish. 30.195 will become 30.194 and rounded off to 30.19\n30.196 will become 30.195 and rounded off to 30.20\nif not, you can run a for loop and check if the 3rd decimal place is 5, then round it down manually, else use the builtin round function","Q_Score":0,"Tags":"python","A_Id":55344288,"CreationDate":"2019-03-25T10:27:00.000","Title":"Roundoff of a number having 5 as last digit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to convert a web application into a desktop application by embedding cefpython3.\nThe application (sometimes) requires the back button for navigation.\nIs there a simple way (ie without requiring another graphics framework like Qt) to get it?\nNote: It seems that Shift+Backspace and Alt+Right Arrow don't work also.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":55338968,"Users Score":1,"Answer":"If you have control over the web application then you can implement back\/forward buttons using HTML5 and Javascript. When button is clicked use javascript bindings to communicate with Python and call appropriate CEF functions such as Browser.GoForward and Browser.GoBack. In case of third party web application you can still inject custom javascript to add buttons by using LoadHandler and Frame.ExecuteJavascript.\nIf you want to do it using OS native controls and don't want to use third party libraries then you can use OS native APIs via ctypes\/pyobjc modules.\nThe Tkinter library is lightweight, so you can consider using it. There is the tkinter_.py example available (doesn't work on Mac though).\nYou can handle keyboard events by implementing KeyboardHandler.\nYou can also navigate through mouse context menu.","Q_Score":1,"Tags":"cefpython","A_Id":55341706,"CreationDate":"2019-03-25T13:31:00.000","Title":"Back button in cefpython3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on NLP project so I am using spacy, the problem is when I import nlp=spacy.load('fr_core_news_md'), it doesn't work for me and I get this error:\n\nOSError: [E050] Can't find model 'fr_core_news_md'. It doesn't seem to\nbe a shortcut link, a Python package or a valid path to a data\ndirectory.\"\n\nDespite the use of python -m spacy download fr_core_news_md","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7779,"Q_Id":55338972,"Users Score":0,"Answer":"first install the package then import it (but not vice versa)\nfirst : !python3 -m spacy download fr_core_news_md\nthen : nlp = spacy.load(\"fr_core_news_md\")","Q_Score":3,"Tags":"python,spacy","A_Id":72260042,"CreationDate":"2019-03-25T13:31:00.000","Title":"OSError: [E050] Can't find model 'fr_core_web_md'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on NLP project so I am using spacy, the problem is when I import nlp=spacy.load('fr_core_news_md'), it doesn't work for me and I get this error:\n\nOSError: [E050] Can't find model 'fr_core_news_md'. It doesn't seem to\nbe a shortcut link, a Python package or a valid path to a data\ndirectory.\"\n\nDespite the use of python -m spacy download fr_core_news_md","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":7779,"Q_Id":55338972,"Users Score":1,"Answer":"It is worth mentioning the bug I had recently.\n\nI installed the fr_core_news_md, and then I tried to load the fr_core_news_sm.\n\nIt was around 2:00 AM I wasn't able to find it.\nI slept and came back in the morning and found the solution.","Q_Score":3,"Tags":"python,spacy","A_Id":69374319,"CreationDate":"2019-03-25T13:31:00.000","Title":"OSError: [E050] Can't find model 'fr_core_web_md'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to program a voice assistant using python and the SpeechRecognition library. But when I execute my program, it runs for about 2 secs and then throws the following Error\n[0:02] Decoding of audio.mp3 finished.\nTraceback (most recent call last):\n  File \"\/home\/USERNAME\/PycharmProjects\/jarvis\/venv\/lib\/python3.7\/site-packages\/speech_recognition\/__init__.py\", line 108, in get_pyaudio\n    import pyaudio\nModuleNotFoundError: No module named 'pyaudio'\nI have already spent some hours trying different solutions but none seem to work for me.\nI am on ubuntu if that helps","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2907,"Q_Id":55340826,"Users Score":0,"Answer":"Try making sure it's installed for Python 3, not 2, and run pip3 install pyaudio if it is on pip.","Q_Score":0,"Tags":"python,pycharm,speech-recognition,pyaudio","A_Id":55341006,"CreationDate":"2019-03-25T15:06:00.000","Title":"speech_recognition can't import pyaudio; ModuleNotFoundError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to program a voice assistant using python and the SpeechRecognition library. But when I execute my program, it runs for about 2 secs and then throws the following Error\n[0:02] Decoding of audio.mp3 finished.\nTraceback (most recent call last):\n  File \"\/home\/USERNAME\/PycharmProjects\/jarvis\/venv\/lib\/python3.7\/site-packages\/speech_recognition\/__init__.py\", line 108, in get_pyaudio\n    import pyaudio\nModuleNotFoundError: No module named 'pyaudio'\nI have already spent some hours trying different solutions but none seem to work for me.\nI am on ubuntu if that helps","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2907,"Q_Id":55340826,"Users Score":0,"Answer":"I just figured it out. There was nothing wrong with my installation. It seems to be a bug in the integrated Terminal of pycharm. When I moved into my project dir with my linux shell and executed my script everything worked just fine. I don't know, why it didn't work with the built in terminal.","Q_Score":0,"Tags":"python,pycharm,speech-recognition,pyaudio","A_Id":55363856,"CreationDate":"2019-03-25T15:06:00.000","Title":"speech_recognition can't import pyaudio; ModuleNotFoundError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am running a Python script on Azure VM. This code is on a continuous while loop and is designed to never stop. If the VM resets or the program randomly stops I have no way to know that. How can I make a logic app that will tell me if the program stops?\nI would like to receive an email notifying me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":287,"Q_Id":55341130,"Users Score":1,"Answer":"So, what you're asking isn't really the right way to do this.\nYou should develop and deploy your app so that it's enabled\/run by Windows either in a VM as you have now or an Azure App Service.\nMeaning, build and deploy it so it can just restart after a crash rather than worrying about constantly checking it.  Of course, it need to run reliably as well.\nAnd again, Azure Services don't just randomly crash so that's really one of the last edge cases you should be concerned about.","Q_Score":1,"Tags":"python,virtual-machine,azure-logic-apps","A_Id":55341843,"CreationDate":"2019-03-25T15:22:00.000","Title":"Checking if Python code is still running on VM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to use BeautifulSoup method inside my module method. If I import as from BeautifulSoup import BeautifulSoup that is working in while running python through CMD\n   How can I import BeautifulSoup3 library that I installed in python 2.7 into my OpenERP module.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":55341833,"Users Score":0,"Answer":"Just copy and paste the BeautifullSoup.py file from python27\\Lib\\site-packages\\BeautifullSoup.py into the folder path openERP7>Server>server and it will do the trick.","Q_Score":1,"Tags":"python-2.7,beautifulsoup,openerp-7","A_Id":55350713,"CreationDate":"2019-03-25T16:00:00.000","Title":"How to import BeautifulSoup into a python method OpenERP 7 module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to count the Customer's Name in my data. \nFor example, if there are [\"Jacob Lee\", \"Jacob Lee 30220\", \"30220\"] in the column, I want to count these cases as a same person. Because 30220 is Jacob Lee's account number. \nI'm not sure how to code this function. \nFYI: I'm using python 3.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":55343651,"Users Score":0,"Answer":"Courtesy of @JohnGordon:\nUse if val == 'Jacob Lee' or val.startswith('Jacob Lee ') or val == '30220' or val.startswith('30220 '):","Q_Score":0,"Tags":"python","A_Id":55343775,"CreationDate":"2019-03-25T17:42:00.000","Title":"Count Name list (mixed with Number)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install Tensorflow and im having trouble compiling the .proto files.\nI try running this command in the research folder:\nC:\/protoc\/bin\/protoc object_detection\/protos\/*.proto --python_out=.\nbut it outputs:\nobject_detection\/protos\/*.proto: No such file or directory\nAny idea why this is happening?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":994,"Q_Id":55344103,"Users Score":0,"Answer":"I have found a solution, it is cumbersome.\nIt works if i compile them one by one.\ne.g.\nC:\/protoc\/bin\/protoc object_detection\/protos\/anchor_generator.proto --python_out=.\nWhere C:\/protoc\/bin\/protoc is the path to protoc.exe file","Q_Score":0,"Tags":"python,protoc","A_Id":55344308,"CreationDate":"2019-03-25T18:11:00.000","Title":"Unable to compile .proto files for Tensorflow object-detection API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The question is straight forward. I have some numbers, and I try to match numbers in range from 0 to 110. Let's say we have five numbers:\n\n99.9\n108.712718\n110\n110.2\n9\n\nHere I need to match all except fourth.\nI tried a lot. Capturing group, positive\/negative lookahead and so on. Nothing works for me. It's easy without floating point, but here I struggling so much.\nP.S. I' doing it with Python.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":101,"Q_Id":55347885,"Users Score":1,"Answer":"This has to be split into three chunks.\n1) 110\n2) 100-109.9999999...\n3) 0-99.9999999...  \nThe pattern: \n^(?:(?:10[0-9]|[0-9][0-9]?)(?:\\.[0-9]+)?|110)$ \n^ start of line\n(?: start non-capturing group\n(?:10[0-9]|[0-9][0-9]?) Capture 100-109 or 00-99\n(?:\\.[0-9]+)? Captures the decimal point and the numbers after it 0 or 1 times\n| or\n110 capture 110 literally\n) end non-capturing group\n$ end of line  \nSimples. Questions?  \nedit: as an afterthought if you do not want leading zeroes (e.g. 00, 01, 02, etc) you could slightly change the pattern to something like ^(?:(?:10[0-9]|[1-9]?[0-9])(?:\\.[0-9]+)?|110)$ the change being [1-9]?[0-9] instead of [0-9][0-9]?","Q_Score":1,"Tags":"python,regex,floating-point","A_Id":55352906,"CreationDate":"2019-03-25T23:35:00.000","Title":"How to capture numbers in specific range with floating point?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run python test cases through Jenkins, it has the git clone command with ssh key. \nCommand : git clone -v ssh:\/\/user@host:29418\/project folder_to_clone\nGetting the error like :\nWarning: Permanently added '[host]:29418,[100.64.42.4]:29418' (RSA) to the list of known hosts.\nPermission denied (publickey).\nfatal: Could not read from remote repository.\nPlease make sure you have the correct access rights\nand the repository exists.\nBut while running locally everything fine, On Jenkins only getting this issue.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":417,"Q_Id":55351246,"Users Score":0,"Answer":"You need to add create a shh key using ssh-key , add it to both jenkins credentials and the git repository you are trying to fetch the code from.","Q_Score":0,"Tags":"python-3.x,git,jenkins","A_Id":55352738,"CreationDate":"2019-03-26T06:46:00.000","Title":"Jenkins job fails with git \"git clone\" using ssh key","Data Science and Machine Learning":0,"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":"From a user given input of job description, i need to extract the keywords or phrases, using python and its libraries. I am open for suggestions and guidance from the community of what libraries work best and if in case, its simple, please guide through. \nExample of user input:\nuser_input = \"i want a full stack developer. Specialization in python is a must\".\nExpected output:\nkeywords = ['full stack developer', 'python']","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1615,"Q_Id":55352756,"Users Score":2,"Answer":"Well, a good keywords set is a good method. But, the key is how to build it. There are many way to do it.\nFirstly, the simplest one is searching open keywords set in the web. It's depend on your luck and your knowledge. Your keywords (likes \"python, java, machine learing\") are common tags in Stackoverflow, Recruitment websites. Don't break the law!\nThe second one is IR(Information Extraction), it's more complex than the last one. There are many algorithms, likes \"TextRank\", \"Entropy\", \"Apriori\", \"HMM\", \"Tf-IDF\", \"Conditional Random Fields\", and so on.\nGood lucky.\nFor matching keywords\/phases, Trie Tree is more faster.","Q_Score":0,"Tags":"python,nlp,match-phrase","A_Id":55360255,"CreationDate":"2019-03-26T08:30:00.000","Title":"Extract keywords\/phrases from a given short text using python and its libraries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am transitioning to new version of TF for stability reasons (I was using a nightly docker build on Ubuntu 18.04 from before mainline switched to CUDA 10).  When I attempt to run my models in the new version I get the following error, which I assume to mean that there is an incompatibility with the models trained on the older version.\nFile \"\/usr\/local\/lib\/python3.5\/dist-packages\/tensorflow\/python\/framework\/importer.py\", line 426, in import_graph_def\n    graph._c_graph, serialized, options)  # pylint: disable=protected-access\ntensorflow.python.framework.errors_impl.InvalidArgumentError: NodeDef mentions attr 'explicit_paddings' not in Op<name=Conv2D; signature=input:T, filter:T -> output:T; attr=T:type,allowed=[DT_HALF, DT_BFLOAT16, DT_FLOAT, DT_DOUBLE]; attr=strides:list(int); attr=use_cudnn_on_gpu:bool,default=true; attr=padding:string,allowed=[\"SAME\", \"VALID\"]; attr=data_format:string,default=\"NHWC\",allowed=[\"NHWC\", \"NCHW\"]; attr=dilations:list(int),default=[1, 1, 1, 1]>; NodeDef: {{node FirstStageFeatureExtractor\/resnet_v1_101\/resnet_v1_101\/conv1\/Conv2D}}. (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).\n\nWhat do I need to do to update the previously trained models to work with the new version of TF or do I need to continue running that version until my next training session?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1299,"Q_Id":55358952,"Users Score":0,"Answer":"After doing some looking, the graph has to be updated.  Since I did not still have the training checkpoints, I was successful in updating the graph by exporting from the previously frozen graph as the checkpoint.\npython3 export_inference_graph.py  --input_type image_tensor --pipeline_config_path FROZENGRAPHDIRECTORY\/pipeline.config --trained_checkpoint_prefix FROZENGRAPHDIRECTORY\/model.ckpt --output_directory FROZENGRAPHDIRECTORY_tfNEWTFVERSION","Q_Score":0,"Tags":"python,tensorflow,object-detection-api","A_Id":55377993,"CreationDate":"2019-03-26T13:57:00.000","Title":"Update trained object detection Models to correspond to TF updates","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m looking into web scraping \/crawling possibilities and have been reading up on the Scrapy program. I was wondering if anyone knows if it\u2019s possible to input instructions into the script so that once it\u2019s visited the url it can then choose pre-selected dates from a calendar on the website. ?\nEnd result is for this to be used for price comparisons on sites such as Trivago. I\u2019m hoping I can get the program to select certain criteria such as dates once on the website like a human would.\nThanks,\nAlex","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":55361023,"Users Score":2,"Answer":"In theory for a website like Trivago you can use the URL to set the dates you want to query but you will need to research user agents and proxies because otherwise your IP will get blacklisted really fast.","Q_Score":1,"Tags":"python,scrapy,web-crawler,data-extraction","A_Id":55368161,"CreationDate":"2019-03-26T15:37:00.000","Title":"Scrapy and possibilities available","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python package with dozens of subpackages\/modules. Nearly each of the modules uses open built-in Python function. I have written an own implementation of the file opening function and would like to \"redirect\" all open calls I have in the package modules to my_open function.\nI am aware that it is possible to write open = my_open_file in the top of the module to shadow the open within the module, but this would imply editing each module. Alternatively, putting open = my_open_file in the __init__.py of the package and then doing from package_name import open which also implies adding a single line of code to each module.\nIs it possible to define the my_open_file function for the package scope just in a single place? Or adding a single line of code in each module is my only option?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":456,"Q_Id":55361836,"Users Score":1,"Answer":"Think about what you're asking to do with this module: you've written your own package, a personal change to the way a built-in function is linked.  You want to redefine a standard language feature.  That's okay ... part of the power of a language is the capability to do things the way you define.\nThe problem comes when you want to do this by default, overriding that standard capability for code that hasn't explicitly requested that change.  You cannot do this without some high-powered authority.  The most straightforward way is to rebuild your Python system from sources, replacing the standard open with your own.\nIn reality, the \"normal\" way is to have each of your application modules \"opt-in\", declaring explicitly that it wants to use the new open instead of the one defined by the language.  This is the approach you've outlined in your second paragraph.  How is this a problem for you?  Inserting a line in each of a list of parameterized files is a single system command.","Q_Score":0,"Tags":"python,package,built-in,monkeypatching,shadowing","A_Id":55362323,"CreationDate":"2019-03-26T16:21:00.000","Title":"Is it possible to overwrite a Python built-in for the whole Python package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've started to use the TextBlob library; for sentiment analysis. \nI have run a few tests on a few phrases and I have the polarity and subjectivity score - fine. \nWhat sentence would return the highest polarity value within TextBlob?\nFor instance \n\"I really, really, really love and admire your beauty, my good friend\" \nreturns a polarity score of 0.6. \nI understand that +1.0 is the highest score (-1.0) is the least.\nWhat sentence, have you found which returns a score closer to +1.0?\n\n\n\nTextBlob(\"I really, really, really love and admire your beauty my good friend\").sentiment\n      Sentiment(polarity=0.6, subjectivity=0.6000000000000001)\nTextBlob(\"I really, really, really love my place of work\").sentiment \n      Sentiment(polarity=0.5, subjectivity=0.6)\nTextBlob(\"I really love my place of work\").sentiment\n      Sentiment(polarity=0.5, subjectivity=0.6)\n\n\n\n\nI expect that the \"really\" should increase the sentiment score, at least a bit.  (i.e. really, really like = at least 0.9)\nI expect that the score overall, without the really (I really like my work) should return a score closer to 1.0.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":247,"Q_Id":55362335,"Users Score":0,"Answer":"You can use .sentiment_assessments to get some more idea of how your sentence is being evaluated.\nSentiment(polarity=0.6, subjectivity=0.6000000000000001, assessments=[(['really', 'really', 'really', 'love'], 0.5, 0.6, None), (['good'], 0.7, 0.6000000000000001, None)])","Q_Score":0,"Tags":"python,textblob","A_Id":58124093,"CreationDate":"2019-03-26T16:48:00.000","Title":"Highest Polarity Score (Sentiment Analysis) using the TextBlob library","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the PuLP library in Python to solve an MILP problem. I have run my problem successfully with the default solver (CBC). Now I would like to use PuLP with another solver (GLPK). How do I set up PuLP with GLPK?\nI have done some research online and found information on how to use GLPK (e.g. with lp_prob.solve(pulp.GLPK_CMD())) but haven't found information on how to actually set up PuLP with GLPK (or any other solver for that matter), so that it finds my GLPK installation. I have already installed GLPK seperately (but I didn't add it to my PATH environment variable).\nI ran the command pulp.pulpTestAll()\nand got:\nSolver <class 'pulp.solvers.GLPK_CMD'> unavailable\nI know that I should be getting a \"passed\" instead of an \"unavailable\" to be able to use it.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3898,"Q_Id":55362984,"Users Score":3,"Answer":"After reading in more detail the code and testing out some things, I finally found out how to use GLPK with PuLP, without changing anything in the PuLP package itself.\nYour need to pass the path as an argument to GLPK_CMD in solve as follows (replace with your glpsol path):\nlp_prob.solve(GLPK_CMD(path = 'C:\\\\Users\\\\username\\\\glpk-4.65\\\\w64\\\\glpsol.exe')\nYou can also pass options that way, e.g.\nlp_prob.solve(GLPK_CMD(path = 'C:\\\\Users\\\\username\\\\glpk-4.65\\\\w64\\\\glpsol.exe', options = [\"--mipgap\", \"0.01\",\"--tmlim\", \"1000\"])","Q_Score":3,"Tags":"python,pulp,glpk","A_Id":55382399,"CreationDate":"2019-03-26T17:26:00.000","Title":"How to configure PuLP to call GLPK solver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the PuLP library in Python to solve an MILP problem. I have run my problem successfully with the default solver (CBC). Now I would like to use PuLP with another solver (GLPK). How do I set up PuLP with GLPK?\nI have done some research online and found information on how to use GLPK (e.g. with lp_prob.solve(pulp.GLPK_CMD())) but haven't found information on how to actually set up PuLP with GLPK (or any other solver for that matter), so that it finds my GLPK installation. I have already installed GLPK seperately (but I didn't add it to my PATH environment variable).\nI ran the command pulp.pulpTestAll()\nand got:\nSolver <class 'pulp.solvers.GLPK_CMD'> unavailable\nI know that I should be getting a \"passed\" instead of an \"unavailable\" to be able to use it.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3898,"Q_Id":55362984,"Users Score":1,"Answer":"I had same problem, but is not related with glpk installation, is with solution file create, the message is confusim. My problem was I use numeric name for my variables, as '0238' ou '1342', I add a 'x' before it, then they looked like 'x0238'.","Q_Score":3,"Tags":"python,pulp,glpk","A_Id":62127258,"CreationDate":"2019-03-26T17:26:00.000","Title":"How to configure PuLP to call GLPK solver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm have bandwidth data which identifies protocol usage by tonnage and hour. Based on the protocols, you can tell when something is just connect vs actually being used (1000 bits compared to million or billions of bits) in that hour for that specific protocol. The problem is When looking at each protocol, they are all heavily right skewed. Where 80% of the records are the just connected or what I'm calling \"noise. \nThe task I have is to separate out this noise and focus on only when the protocol is actually being used. My classmates are all just doing this manually and removing at a low threshold. I was hoping there was a way to automate this and using statistics instead of just picking a threshold that \"looks good.\" We have something like 30 different protocols each with a different amount of bits which would represent \"noise\" i.e. a download prototypical might have 1000 bits where a messaging app might have 75 bits when they are connected but not in full use. Similarly they will have different means and gaps between i.e. download mean is 215,000,000 and messaging is 5,000,000. There isn't any set pattern between them.\nAlso this \"noise\" has many connections but only accounts for 1-3% of the total bandwidth being used, this is why we are tasked with identify actual usage vs passive usage.\nI don't want any actual code, as I'd like to practice with the implementation and solution building myself. But the logic, process, or name of a statistical method would be very helpful.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":55363520,"Users Score":0,"Answer":"Do you have labeled examples, and do you have other data besides the bandwidth? One way to do this would be to train some kind of ML classifier if you have a decent amount of data where you know it's either in use or not in use. If you have enough data you also might be able to do this unsupervised. For a start a simple Naive Bayes classifier works well for binary solutions. As you may be away, NB was the original bases for spam detection (is it spam or not). So your case of is it noise or not should also work, but you will get more robust results if you have other data in addition to the bandwidth to train on. Also, I am wondering if there isn't a way to improve the title of your post so that it communicates your question more quickly.","Q_Score":0,"Tags":"python,r,statistics","A_Id":55462001,"CreationDate":"2019-03-26T17:57:00.000","Title":"Determining \"noise\" in bandwidth data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I followed Python i18n and l10n process to externalize and translate text message in Python app. But when I package Python code into a wheel package, I can't find any guidance in setuptools docs.\nBecause the localized messages files can be treated as data files. Perhaps, I could use package_data parms to include those files. However, it doesn't seem to be right way to do this. Because the deployed localized messages files should be either in system default locale location \/usr\/share\/locale or user-specific location. In either way, I find it difficult to connect pkg_resources package to gettext package without messing with real physical path hacking.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":557,"Q_Id":55365356,"Users Score":3,"Answer":"Here is what I did. I verified that the wheel package deployed and loaded localized *.mo message catalog file properly in Linux, Mac OSX and Windows 10.\n\nMove your locales folder under your top level Python package folder. For example, let say your package name pkg1 and you have my_msg.mo catalog file for French locale. Move your *.mo file to pkg1\/locales\/fr\/LC_MESSAGES\/my_msg.mo\nIn your setup.py, add:\n\n...\npackage_data={'pkg1': ['pkg1\/locales\/\/LC_MESSAGES\/.mo']},\ninclude_package_data=True,\n...\n\nIn your Python script, use the following way to load without hard code any physical path:\n\n...\nlocale_path = pkg_resources.resource_filename('pkg1', 'locales')\nmy_msg = gettext.translation(domain='my_msg', localedir=locale_path, fallback=True)\n_T = my_msg.gettext\nprint(_T(\"hello world!\"))\n...","Q_Score":1,"Tags":"python,localization,internationalization,setuptools","A_Id":55498913,"CreationDate":"2019-03-26T20:00:00.000","Title":"How to include localized message in Python setuptools?","Data 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 plot interactive graphics with sliders and buttons directly inside the Spyder IPython console and not in a separated window ? I find the inline mode really convenient but no interaction seems possible yet. I tried %matplotlib notebook but an error occurred. Any tips please ?\nThanks !!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":441,"Q_Id":55367054,"Users Score":1,"Answer":"(Spyder maintainer here) No, unfortunately that's not possible.","Q_Score":0,"Tags":"python,spyder","A_Id":55376219,"CreationDate":"2019-03-26T22:26:00.000","Title":"Interactive plots inside Spyder ipython console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Consider a set of n cubes with colored facets (each one with a specific color\nout of 4 possible ones - red, blue, green and yellow). Form the highest possible tower of k cubes ( k \u2264 n ) properly rotated (12 positions of a cube), so the lateral faces of the tower will have the same color, using and evolutionary algorithm.\nWhat I did so far:\nI thought that the following representation would be suitable: an Individual could be an array of n integers, each number having a value between 1 and 12, indicating the current position of the cube (an input file contains n lines, each line shows information about the color of each face of the cube). \nThen, the Population consists of multiple Individuals.\nThe Crossover method should create a new child(Individual), containing information from its parents (approximately half from each parent).\nNow, my biggest issue is related to the Mutate and Fitness methods.\nIn Mutate method, if the probability of mutation (say 0.01), I should change the position of a random cube with other random position (for example, the third cube can have its position(rotation) changed from 5 to 12).\nIn Fitness method, I thought that I could compare, two by two, the cubes from an Individual, to see if they have common faces. If they have a common face, a \"count\" variable will be incremented with the number of common faces and if all the 4 lateral faces will be the same for these 2 cubes, the count will increase with another number of points. After comparing all the adjacent cubes, the count variable is returned. Our goal is to obtain as many adjacent cubes having the same lateral faces as we can, i.e. to maximize the Fitness method.\nMy question is the following:\nHow can be a rotation implemented? I mean, if a cube changes its position(rotation) from 3, to 10, how do we know the new arrangement of the faces? Or, if I perform a mutation on a cube, what is the process of rotating this cube if a random rotation number is selected?\nI think that I should create a vector of 6 elements (the colors of each face) for each cube, but when the rotation value of a cube is modified, I don't know in what manner the elements of its vector of faces should be rearranged.\nShuffling them is not correct, because by doing this, two opposite faces could become adjacent, meaning that the vector doesn't represent that particular cube anymore (obviously, two opposite faces cannot be adjacent).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":227,"Q_Id":55367429,"Users Score":0,"Answer":"First, I'm not sure how you get 12 rotations; I get 24: 4 orientations with each of the 6 faces on the bottom.  Use a standard D6 (6-sided die) and see how many different layouts you get.\nApparently, the first thing you need to build is a something (a class?) that accurately represents a cube in any of the available orientations.  I suggest that you use a simple structure that can return the four faces in order -- say, front-right-back-left -- given a cube and the rotation number.\nI think you can effectively represent a cube as three pairs of opposing sides.  Once you've represented that opposition, the remaining organization is arbitrary numbering: any valid choice is isomorphic to any other.  Each rotation will produce an interleaved sequence of two opposing pairs.  For instance, a standard D6 has opposing pairs [(1, 6), (2, 5), (3, 4)].  The first 8 rotations would put 1 and 6 on the hidden faces (top and bottom), giving you the sequence 2354 in each of its 4 rotations and their reverses.\nThat class is one large subsystem of your problem; the other, the genetic algorithm, you seem to have well in hand.  Stack all of your cubes randomly; \"fitness\" is a count of the most prevalent 4-show (sequence of 4 sides) in the stack.  At the start, this will generally be 1, as nothing will match.\nFrom there, you seem to have an appropriate handle on mutation.  You might give a higher chance of mutating a non-matching cube, or perhaps see if some cube is a half-match: two opposite faces match the \"best fit\" 4-show, so you merely rotate it along that axis, preserving those two faces, and swapping the other pair for the top-bottom pair (note: two directions to do that).\nDoes that get you moving?","Q_Score":1,"Tags":"python,artificial-intelligence,evolutionary-algorithm","A_Id":55368146,"CreationDate":"2019-03-26T23:03:00.000","Title":"Tower of colored cubes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"From what I understand from keras labeling, one hot encoding does not permit the values to be [0 0]? is this assumption correct?\nWe are trying to classify 2 classes and we want to be able to detect garbage when a garbage image is fed. However, it always detects either \n[0 1] or [1 0]. Is it possible to get [0 0] as a label without introducing a class the will handle the garbage or no?\nSo basically, can the CNN predict it to be something else if its not the 2 classes?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":55367994,"Users Score":1,"Answer":"That should not be possible.  Your \"garbage\" would be a third class, requiring labels of [1 0 0], [0 1 0], and [0 0 1].\nVery simply, the model you've described will return one of two categories, whichever has a higher rating in your final layer.  This happens whether the input values are 0.501 and 0.499, or 0.011 and 0.010 with a large \"not sure\" portion.  If you don't explicitly code \"not sure\" into your model, then that portion of the decision will not be considered in the classification.","Q_Score":1,"Tags":"python,keras,conv-neural-network","A_Id":55368249,"CreationDate":"2019-03-27T00:15:00.000","Title":"Can I get [0 0] from Categorical Labeling in CNN's?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to successfully create projects using Django however I have seen projects where the user will create the project first THEN the virtual env. I have also seen instances where the user creates the virtual env and THEN the django app. Both sides argue that their method is better, but now I am confused. Pls help","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":220,"Q_Id":55368323,"Users Score":1,"Answer":"it is better to create the virtual environment first and start working in that environment. ie use python from that environment.\nadvantage: \na. environment will contain all the package required by the project\nb. can switch between multiple env( testing purpose)\nc. easy to keep a record of the required packages\nd. will not affect another project where u need python 3.5 and in django project u require python 3.6\ndisadvantage:\n   need to keep track of each env in case if you have many virtual env ( all virtual env are store in same place just like anaconda one, else if store in project folder then no issue for1 env)","Q_Score":1,"Tags":"python,django,virtualenv,python-venv","A_Id":55368421,"CreationDate":"2019-03-27T01:04:00.000","Title":"Create the Django app or the virtual environment first?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been trying to successfully create projects using Django however I have seen projects where the user will create the project first THEN the virtual env. I have also seen instances where the user creates the virtual env and THEN the django app. Both sides argue that their method is better, but now I am confused. Pls help","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":220,"Q_Id":55368323,"Users Score":1,"Answer":"It depends on your usage.\nLet's say you have Django 2.1 installed globally, then you have a project where you need let's say Django 1.9, here you need to set-up your virtual environment first","Q_Score":1,"Tags":"python,django,virtualenv,python-venv","A_Id":55368370,"CreationDate":"2019-03-27T01:04:00.000","Title":"Create the Django app or the virtual environment first?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python code which I want to deploy on firebase as my Application  database is firebase realtimeDB.\nA part of this APP is developed on python so I want to integrate in with my App. Which can be done by deploying python piece of code on firebase.\nI am unable to find a way to deploy a python code via firebase hosting.\nAnyone have any solution I would really appreciate it.\nI have tried to deploy it with firebase CLI tools. But I think it supports Javascript","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1824,"Q_Id":55369357,"Users Score":1,"Answer":"You can't deploy any backend code with Firebase Hosting.  It only serves static content.  You will have to look into other ways of running your backend, such as Cloud Functions or App Engine.","Q_Score":0,"Tags":"python,firebase,firebase-hosting","A_Id":55369376,"CreationDate":"2019-03-27T03:31:00.000","Title":"How to deploy a python code on firebase server","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":"What's the difference between shape(150,) and shape (150,1)?\nI think they are the same, I mean they both represent a column vector.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":331,"Q_Id":55374185,"Users Score":0,"Answer":"Although they both occupy same space and positions in memory,\n\nI think they are the same, I mean they both represent a column vector.\n\nNo they are not and certainly not according to NumPy (ndarrays).\nThe main difference is that the \nshape (150,) => is a 1D array,  whereas\nshape (150,1) => is a 2D array","Q_Score":1,"Tags":"python,numpy","A_Id":55376254,"CreationDate":"2019-03-27T09:49:00.000","Title":"What's the difference between shape(150,) and shape (150,1)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"On Windows I can run py test.py having Python 3 installed.\nBut on Ubuntu, py is not recognized as command, but python3 is.\nIs there anyway I can make py the same command as python3?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":126,"Q_Id":55375436,"Users Score":3,"Answer":"You could always add alias py='python3' to your .bashrc file.","Q_Score":1,"Tags":"python,python-3.x","A_Id":55375458,"CreationDate":"2019-03-27T10:52:00.000","Title":"Cannot run py as 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":"On Windows I can run py test.py having Python 3 installed.\nBut on Ubuntu, py is not recognized as command, but python3 is.\nIs there anyway I can make py the same command as python3?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":126,"Q_Id":55375436,"Users Score":1,"Answer":"To add Up , If the script wants to call the interpreter\n\nMake sure the first line of your file has #!\/usr\/bin\/env python.\nMake it executable - chmod +x .py.\nAnd run it as .\/.py","Q_Score":1,"Tags":"python,python-3.x","A_Id":55375523,"CreationDate":"2019-03-27T10:52:00.000","Title":"Cannot run py as 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 need to clear the terminal in Pycharm without clicking the trashbin myself. I've tried using the whole os and csl thing but it only makes some weird arrow in the terminal.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":55375930,"Users Score":0,"Answer":"The os.system command cannot work because it only executes commands in the Console. It won't work in many other places including IDLE's Python Shell, PyCharm, etc.\nIt should work in your Terminal. You can write your code in PyCharm and execute it in a terminal.\nYou can also use multiple \\n, but it is not really what you want.\nAnother idea would be to add a keyboard shortcut.","Q_Score":0,"Tags":"python","A_Id":55376144,"CreationDate":"2019-03-27T11:18:00.000","Title":"How to clear the terminal in Py-charm. (non-manually)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a python program which prints long outputs. When i try to run that file in vscode, its interactive window isn't enough to view full output. So is there any way to run python file in cmd from VSCODE?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":6755,"Q_Id":55381169,"Users Score":4,"Answer":"If you are running windows, VSCode uses Powershell as your terminal by default.  If you want to use the command prompt instead, hit ctrl+shift+p, type Shell into the command pallet, select Terminal: Select Default Shell, and change it to Command Prompt.  I am not sure this will fix your problem as I think Powershell should display just as much output as the CMD, but if you want to try switching terminals, that will do it.  Another option is to try to run it natively in CMD or Powershell, rather than using the VSCode integrated terminal.  That might be better if changing terminals doesn't help.","Q_Score":2,"Tags":"python,visual-studio-code","A_Id":55381313,"CreationDate":"2019-03-27T15:39:00.000","Title":"How do i run python file in cmd from vscode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a DAG that imports data from a source to a server. From there, I am looking to download that file from the server to the Windows network. I would like to keep this part in Airflow for automation purposes. Does anyone know how to do this in Airflow? I am not sure whether to use the os package, the shutil package, or maybe there is a different approach.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1629,"Q_Id":55385808,"Users Score":0,"Answer":"I think you're saying you're looking for a way to get files from a cloud server to a windows shared drive or onto a computer in the windows network, these are some options I've seen used:\n\nUse a service like google drive, dropbox, box, or s3 to simulate a synced folder on the cloud machine and a machine in the windows network. \nCall a bash command to SCP the files to the windows server or a worker in the network.  This could work in the opposite direction too. \nAdd the files to a git repository and have a worker in the windows network sync the repository to a shared location.  This option is only good in very specific cases. It has the benefit that you can track changes and restore old states (if the data is in CSV or another text format), but it's not great for large files or binary files.\nUse rsync to transfer the files to a worker in the windows network which has the shared location mounted and move the files to the synced dir with python or bash.\nMount the network drive to the server and use python or bash to move the files there.\n\nAll of these should be possible with Airflow by either using python (shutil) or a bash script to transfer the files to the right directory for some other process to pick up or by calling a bash sub-process to perform the direct transfer by SCP or commit the data via git.  You will have to find out what's possible with your firewall and network settings.  Some of these would require coordinating tasks on the windows side (the git option for example would require some kind of cron job or task scheduler to pull the repository to keep the files up to date).","Q_Score":0,"Tags":"python,airflow,samba,smb","A_Id":55387555,"CreationDate":"2019-03-27T20:20:00.000","Title":"Airflow: How to download file from Linux to Windows via smbclient","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I am trying to upgrade pip. Currently pip is present in \/usr\/bin but when I upgrade pip using: \u201cpip install --upgrade pip\u201d, it upgrades pip into \/usr\/local\/bin and not \/usr\/bin. Is there anyway to keep the pip installation in \/usr\/bin and all the pip libraries in \/usr\/lib or \/usr\/lib64, etc ?","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":11434,"Q_Id":55387879,"Users Score":5,"Answer":"In general, running pip as root is never a good idea. You're installing files to your root that are not tracked by your distribution's package manager.\nThis may not sound that bad, but in general it is, because you're cluttering your system with files that may clash with others and that you're likely going to have a hard time removing.\nPip is doing the right thing installing itself system-wide into \/usr\/local. The general convention is that stuff outside of your own directory, of \/etc, \/var and local system directories is tracked by the package manager.\nThe package manager will overwrite files outside of these directories without asking. local counterparts of system directories are there to give you the opportunity to install stuff system-wide without it being messed with. However, most of the times, there are better ways of doing it.\nFor example, the best way with Python is using virtualenvs. They give you an isolated environment that you can activate and install stuff into, including an up-to-date version of pip.\nYou also can run it as a user (without sudo), but you will have to add its bin directory to your $PATH.\nIt's best if you leave \/usr\/bin\/pip alone, otherwise bad things may happen.\nTo answer your question, if you really can't live without having it in \/usr\/bin or a virtualenv, I'm sad to tell you there is no such documented option for pip. However you have two options:\n\nRemove your distro's pip package, then symlink \/usr\/bin\/pip to \/usr\/local\/bin\/pip. That will work but it will still be technically installed in \/usr\/local. Also, any other program that depends on your distro's pip package will have to be removed.\n(very bad) Download pip's sources, then install it with sudo python setup.py install --prefix=\/usr. This will place it in \/usr\/bin, but you should feel really bad for having done it.\n\nI really can't stress enough how bad this practice is, though.","Q_Score":1,"Tags":"python,pip,upgrade","A_Id":55388092,"CreationDate":"2019-03-27T23:12:00.000","Title":"Installing pip in \/usr\/bin instead of \/usr\/local\/bin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I run Pylint without accentuated characters, it runs fine. When I have a class name like Caf\u00e9, I get the syntax error. I'm on a Mac.\nTried to find how to configure that without success.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1603,"Q_Id":55388888,"Users Score":0,"Answer":"I was running pylint but underneath it was using python 2.7 which as @jasonharper said is ASCII only. \nI installed pylint with :\npython -m pip install -U pylint\nNote that I have an alias that makes my python commands run as python3.\nNow it works","Q_Score":0,"Tags":"python,pylint","A_Id":55389084,"CreationDate":"2019-03-28T01:29:00.000","Title":"Pylint invalid syntax (, line ...) (syntax-error) Because of accent character","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"On Linux, need in Python a way to determine if a given network interface is wifi or just ethernet (i.e. cable) based.  Working on a project where knowing the type of interface transport, if you will, is needed.  Given the modern network architecture in Linux, you can't trust that UDEV or something else has not named the interfaces to something odd, so ens* vs. wl* parsing of the interface names can be trusted.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":123,"Q_Id":55390273,"Users Score":0,"Answer":"Try using the pyric.pyw.iswireless() call from the library PyRIC.","Q_Score":0,"Tags":"python,interface,wifi,ethernet","A_Id":58564141,"CreationDate":"2019-03-28T04:39:00.000","Title":"On Linux OS In Python Determine if a given network interface is wifi based or just ethernet based?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to get my app ready for shipping and I would like to make it standalone and include all dependencies so users don't have to download anything extra.\nHow can I identify the minimum required functions and classes my project depends on and extract those to a separate folder instead of including whole packages?\nIncluding each package in full that my project depends on gives me 450 mb of files which is way too large because 95% of those files aren't even being used. \nI know this is pretty similar to what pyinstaller does, but I don't want a .exe file. I just want the minimum dependencies.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":55390722,"Users Score":0,"Answer":"Apparently pyinstaller has a noarchive option which does exactly that.","Q_Score":0,"Tags":"python,pyinstaller","A_Id":55427527,"CreationDate":"2019-03-28T05:29:00.000","Title":"How can I bundle the minimum set of dependencies to make my app standalone?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have these scripts that perform a lot of expensive computations. One optimization I do is to evaluate the expensive function on a grid, cache the grid, and interpolate for calls within the grid. It is important that the files be written out to disk so that future sessions can benefit from the cache. When this script was just for my own personal use, I could put the cache wherever. Now that I want to incorporate it into a package for wider distribution, I find that I need to have some way to know where is it kosher to store cache files for a package? Do I just need to make some decisions, or are there some procedures I should follow (e.g. let the user modify the directory at install time, at run-time, etc)?\nEdit: this code will also have functions based on interpolating data from other sources. So I will need a place to store those, too, but need to know where it is standard to do so and how to detect where that is on a particular install (something hard coded at install time, or can Python modules detect where they're installed at runtime?). Point being, this location needs to be persistent in a way that I understand temporary directories not to be. Therefore, this would ideally be done inside of the package's directory structure or somewhere in the user's home directory. If in the package's directories, it is acceptable if I have to do shenanigans with permissions to make a directory that the user can modify.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2191,"Q_Id":55395893,"Users Score":0,"Answer":"I found some cached files here\nC:\\Users\\User_Name\\AppData\\Local\\pip\\cache\nIt is the folder where pip is installed and cache files\/libraries are present.\nIf you uninstall and reinstall python, then these cached libraries will be used, instead of downloading new ones.","Q_Score":3,"Tags":"python,caching,packaging,memoization","A_Id":72181715,"CreationDate":"2019-03-28T10:58:00.000","Title":"Is there a standard location to store function cache files 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 working in training a CNN in fourier domain. To speed up training, I thought of taking the fft of the entire dataset before training and feeding this data to the sequential model. But inside the first layer of the model, which is a custom Keras layer, the training data is shown to have float32 data type. Does the sequential model take in only real input data?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":127,"Q_Id":55398697,"Users Score":1,"Answer":"Adding an InputLayer(... dtype='complex64') layer, i.e. an InputLayer() with data type specified as 'complex64' as the first layer of the sequential model allowed me to pass complex64 data to the model.","Q_Score":1,"Tags":"python,keras,sequential","A_Id":55629323,"CreationDate":"2019-03-28T13:20:00.000","Title":"Feed complex64 data into Keras sequential model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just built a little web application with flask and I want to manage users roles and accessibility to the endpoint according to their role etc and for that, I want to use something like acl (Access Control List) but I can't find anything useful or clear enough to understand.\nI found flask-acl but the documentation is so poor, I found flask-simpleacl but I can't put my hands on any useful documentation.\nI can't even find tutorials or examples about so can someone suggest a good useful flask extension or library for that or just point me to some documentation, examples or tutorials?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":655,"Q_Id":55398895,"Users Score":1,"Answer":"I ended up trying to use flask_principal as someone suggested to me here (but for some reason, they deleted their answer), it's great and helpful especially if you combine it with flask_login. So I hope this helps someone.\nThe only issue is if you want for example show\/hide some content on your HTML pages based on the user's role, then you have to set it manually with session variables which is mostly going back to the start point (unless I'm missing something).\nGood luck.","Q_Score":0,"Tags":"python,flask,acl","A_Id":55452208,"CreationDate":"2019-03-28T13:31:00.000","Title":"Implementing ACL with flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was working on a decentralized python chat room. I was just wondering, if you don't open up a port, you can't receive messages. But, if you open up a port, you are vulnerable to getting hacked or something. So, is there a way to communicate with Python between a server and a client without opening up ports?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":55399309,"Users Score":0,"Answer":"At least one of the client or the server should have an open port (typically, the server). As soon as a TCP connection is established (typically, by the client), a random (= chosen by the operating system) port will be used by the client to be reachable by the server.","Q_Score":0,"Tags":"python,sockets","A_Id":55399380,"CreationDate":"2019-03-28T13:52:00.000","Title":"Is there a way to communicate between server and client in Python without opening up ports?","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 flow graph with lower and upper bounds and my task is to find any feasible solution as fast as possible. I found many algorithms and approaches to maximum\/minimum flow and so on (also many times uses feasible solution as start point) but nothing specific for any feasible solution. Is there any algorithm\/approach that is specific for it and fast?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":861,"Q_Id":55400911,"Users Score":1,"Answer":"So I finally got time to sum this up. The solution I used is to take the initial graph and transform it in these steps.\n(Weights are in this order: lower bound, current flow, upper bound.)\n1. Connect t to s by edge of (0, 0, infinity).\n2. To each node of the\n        initial graph add balance value equal to: (sum of lower bound of\n        incoming edges - sum of lower bound of outgoing edges).\n3. Set upper\n            bound of every edge to (upper bound - lower bound). Set lower bound\n            and current flow of each edge to 0.\n4. Now make new s (s') and new t (t') which will be our new start and end (DO NOT DELETE s and t already in the graph, they just became\n    normal nodes).\n5. Create edge from s' to every vertex with positive balance with (0,\n    0, vertex.balance) bounds.\n6. Create edge from every vertex with negative balance to t' with (0,\n    0, abs(vertex.balance)).\n7. Run Ford-Fulkerson (or other maximum flow algorithm of your choice)\n    on the new graph.\n8. For every edge of initial graph sum value of the\n        edge with the initial old lower bound before transformation and you have your\n        initial flows for every edge of the initial graph.\nThis problem is actually a bit harder than to maximize flow when feasible flow is provided.","Q_Score":1,"Tags":"python,graph,network-flow","A_Id":55557061,"CreationDate":"2019-03-28T15:05:00.000","Title":"Finding any feasible flow in graph as fast as possible","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'm using Keras (with Tensorflow backend) for an image classification project. I have a total of almost 40 000 hi-resolution (1920x1080) images that I use as training input data. Training takes about 45 minutes and this is becoming a problem so I was thinking that I might be able to speed things up by lowering the resolution of the image files. Looking at the code (I didn't write it myself) it seems all images are re-sized to 30x30 pixels anyway before processing\nI have two general questions about this.\n\nIs it reasonable to expect this to improve the training speed?\nWould resizing the input image files affect the accuracy of the image classification?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":404,"Q_Id":55401716,"Users Score":1,"Answer":"1- Of course it will affect the training speed as the spatial dimensions is one of the most important key of the model speed performance.\n2- We can say sure it'll affect the accuracy, but how much exactly that depends on many of other aspects like what objects are you classifying and what dataset are you working with.","Q_Score":1,"Tags":"python-2.7,tensorflow,keras","A_Id":55402030,"CreationDate":"2019-03-28T15:43:00.000","Title":"How does image resolution affect result and accuracy in Keras?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been looking for a way to vectorize categorical variable and then I've come across category_encoders. It supports multiple ways to categorize.\nI tried TargetEncoder and BinaryEncoder but the docs doesn't explain much about the working of it?\nI really appreciate if anyone could explain how target encoder and binary encoder work and how they are different from one hot encoding?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":754,"Q_Id":55402010,"Users Score":1,"Answer":"Target encoding maps the categorical variable to the mean of the target variable. As it uses the target, steps must be taken to avoid overfitting (usually done with smoothing). \nBinary encoding converts each integer into binary digits with each binary digit having its one column. It is essentially a form of feature hashing.\nBoth help with lowering the cardinality of categorical variables which helps improve some model performance, most notably with tree-based models.","Q_Score":0,"Tags":"python,python-3.x,scikit-learn,categorical-data","A_Id":55794331,"CreationDate":"2019-03-28T15:58:00.000","Title":"What is TargetEncoder and BinaryEncoder in sklearn category_encoders?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I do side work writing\/improving a research project web application for some political scientists. This application collects articles pertaining to the U.S. Supreme Court and runs analysis on them, and after nearly a year and half, we have a database of around 10,000 articles (and growing) to work with.\nOne of the primary challenges of the project is being able to determine the \"relevancy\" of an article - that is, the primary focus is the federal U.S. Supreme Court (and\/or its justices), and not a local or foreign supreme court. Since its inception, the way we've addressed it is to primarily parse the title for various explicit references to the federal court, as well as to verify that \"supreme\" and \"court\" are keywords collected from the article text. Basic and sloppy, but it actually works fairly well. That being said, irrelevant articles can find their way into the database - usually ones with headlines that don't explicitly mention a state or foreign country (the Indian Supreme Court is the usual offender).\nI've reached a point in development where I can focus on this aspect of the project more, but I'm not quite sure where to start. All I know is that I'm looking for a method of analyzing article text to determine its relevance to the federal court, and nothing else. I imagine this will entail some machine learning, but I've basically got no experience in the field. I've done a little reading into things like tf-idf weighting, vector space modeling, and word2vec (+ CBOW and Skip-Gram models), but I'm not quite seeing a \"big picture\" yet that shows me how just how applicable these concepts can be to my problem. Can anyone point me in the right direction?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":336,"Q_Id":55403920,"Users Score":1,"Answer":"There are many many ways to do this, and the best method changes depending on the project. Perhaps the easiest way to do this is to keyword search in your articles and then empirically choose a cut off score. Although simple, this actually works pretty well, especially in a topic like this one where you can think of a small list of words that are highly likely to appear somewhere in a relevant article. \nWhen a topic is more broad with something like 'business' or 'sports', keyword search can be prohibitive and lacking. This is when a machine learning approach might start to become the better idea. If machine learning is the way you want to go, then there are two steps:\n\nEmbed your articles into feature vectors\nTrain your model\n\nStep 1 can be something simple like a TFIDF vector. However, embedding your documents can also be deep learning on its own. This is where CBOW and Skip-Gram come into play. A popular way to do this is Doc2Vec (PV-DM). A fine implementation is in the Python Gensim library. Modern and more complicated character, word, and document embeddings are much more of a challenge to start with, but are very rewarding. Examples of these are ELMo embeddings or BERT. \nStep 2 can be a typical model, as it is now just binary classification. You can try a multilayer neural network, either fully-connected or convolutional, or you can try simpler things like logistic regression or Naive Bayes.\nMy personal suggestion would be to stick with TFIDF vectors and Naive Bayes. From experience, I can say that this works very well, is by far the easiest to implement, and can even outperform approaches like CBOW or Doc2Vec depending on your data.","Q_Score":1,"Tags":"python,machine-learning,nlp,data-science","A_Id":55404739,"CreationDate":"2019-03-28T17:45:00.000","Title":"Concepts to measure text \"relevancy\" to a subject?","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 crawl the football data from the whoscored.com, the website has incapsula web oriented security which is not letting me crawl. Initially, I tried to give user_agent and changed the header then it worked but that's only for the first page. As I need to crawl some other parts of the website it keeps blocking me to request the website. It's getting exhausting now since the blocking time has been increasing.\nIs there anybody who could suggest something to bypass the incapsula security mechanisms.\nI need data for study purposes.\nI have gone through all the old the previous question asked about this topic. but it does not help.\nTools. anaconda, language python, and library beautiful soup\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":343,"Q_Id":55404628,"Users Score":0,"Answer":"if you mimic browser headers and appropiate time between requests, it will probably work\nlook at your request headers and that of your browser","Q_Score":0,"Tags":"python,data-science","A_Id":55663189,"CreationDate":"2019-03-28T18:32:00.000","Title":"By passing incapsula security- python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to ask a question related to a DataFrame. I tried to add screenshots before but I got -3 reputation and it says I am not allowed to upload the image. What is the best way then. I am new to stack overflow. Please help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":531,"Q_Id":55405730,"Users Score":1,"Answer":"You could either provide the code the generate sample data or you could do print(df) and paste the result with code format as a part of your question. For us it is possible to copy a dataframe as text a load it into a proper dataframe. Usually you can provide less than 20 rows of sample data and that should be enough to replicate the desired output","Q_Score":1,"Tags":"python,pandas,dataframe","A_Id":55405781,"CreationDate":"2019-03-28T19:44:00.000","Title":"Sometimes it is necessary to show my dataframe to properly ask the question. How can I do that?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone have any idea about connecting to NexusDB via python? Thanks.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":299,"Q_Id":55409834,"Users Score":2,"Answer":"NexusDB does not currently have direct support for Python, but are considering it for future feature additions. Right now your best bet would be to connect via ODBC.","Q_Score":0,"Tags":"python,database,python-3.x,nexusdb","A_Id":55440713,"CreationDate":"2019-03-29T02:53:00.000","Title":"How to connect NexusDB in windows via python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Incorrect result on encoding \nI tried to convert a string to a byte in hex format by encode() but failed. \nBelow is my code, I expected \\xFF will become \\xFF , but finally the result is \\xc3. \nMay i know why?\nInput: x =\"\\x00\\x00\\xFF\\x00\\xFF\\x00\"\nInput: x.encode()\nOutput: b'\\x00\\x00\\xc3\\xbf\\x00\\xc3\\xbf\\x00'","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":345,"Q_Id":55411794,"Users Score":2,"Answer":"The default encoding for string.encode() is UTF-8.  UTF-8 encodes characters with numeric decimal codes 0-127 as their numeric values.  It encodes values greater than 127 as two or more bytes depending on the character being encoded.\nThe UTF-8 encoding for 0 is 0.  The UTF-8 encoding for '\\xFF'(255) is '\\xc3\\xbf'.\nSo if you replace your input with the UTF-8 encoding for each of the 6 bytes in that input, you get your output.","Q_Score":0,"Tags":"python,encoding,utf-8","A_Id":55411997,"CreationDate":"2019-03-29T06:41:00.000","Title":"String to hex encode problem .by encode() module but failed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can use this torch.cuda.device_count() to check the number of GPUs. I was wondering if there was something equivalent to check the number of CPUs.","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":6996,"Q_Id":55411921,"Users Score":5,"Answer":"At present pytorch doesn't support multiple cpu cluster in DistributedDataParallel implementation. So, I am assuming you mean number of cpu cores.\nThere's no direct equivalent for the gpu count method but you can get the number of threads which are available for computation in pytorch by using\n\ntorch.get_num_threads()","Q_Score":8,"Tags":"python,neural-network,deep-learning,pytorch","A_Id":55413219,"CreationDate":"2019-03-29T06:50:00.000","Title":"Is there a pytorch method to check the number of cpus?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The problem is I already have the latest python on my Mac, but when I write python3 in terminal, It shows 3.7.2, not the latest i.e. 3.7.3 .\nI Tried Using brew link python3 and that doesn't work.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2843,"Q_Id":55413480,"Users Score":1,"Answer":"Try brew upgrade python3 to update python3. If that doesn't work, try to brew update (to update Brew) before running the command","Q_Score":1,"Tags":"python","A_Id":55413550,"CreationDate":"2019-03-29T08:43:00.000","Title":"How Upgrade Python 3.7.2 to Python 3.7.3 via Homebrew","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"A lot of people have issues installing tensorflow-gpu on their computers and I have read a lot of them and tried out a lot of them as well. So I'm not coming for an easy answer without searching the web beforehand. \nI'm running W10 with an NVIDIA Quadro P600 which can supposedly run CUDA. \nThe thing is whenever I'm trying to install CUDA (10.0 as suggested from tensorflow) the installation breaks with no clear indication of the error (\"The download wasn't successfully completed. Try again\") \nI have the feeling it breaks because my Laptop has two GPU's. The mentioned NVIDIA and the onboard Intel UHD Graphics 630 card.\nDoes anyone have a clue? Please share your workflow if you have installed tensorflow-gpu on your laptop!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":235,"Q_Id":55413488,"Users Score":0,"Answer":"At what phase are you getting the \"Download wasn't...\" message? did\n  you try manually downloading the wheel file and installing it directly\n  and locally? \u2013 Ido_f\n\nDownloading the local CUDA installation solved my issues.","Q_Score":0,"Tags":"python,tensorflow,installation","A_Id":55742886,"CreationDate":"2019-03-29T08:44:00.000","Title":"Installing tensorflow-gpu on a Laptop with two graphic cards","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made some changes in my source code. But after I restart the server, Iam not able to see those changes. I'm using Django framework. How do I recompile python code in the linux (CentOS) server. \nI already tried restarting the server, installing django-extension.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":138,"Q_Id":55414837,"Users Score":0,"Answer":"Try using a different port if its on your local machine","Q_Score":0,"Tags":"python,django,linux,server","A_Id":55416528,"CreationDate":"2019-03-29T09:59:00.000","Title":"How do I recompile the python files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have 10 different matrix of size (60, 100). I want to put them along the third dimension inside a for loop, so that the final shape is (10, 60, 100).\nI tried with concatenate and end up with size (600, 100).","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":402,"Q_Id":55415158,"Users Score":0,"Answer":"Try creating a new array that you fill with your 2D arrays\n\nnew3DArray = numpy.empty(10, 60, 100)","Q_Score":1,"Tags":"python,arrays,numpy,append","A_Id":55415405,"CreationDate":"2019-03-29T10:17:00.000","Title":"Number of 2D array to 3D array, extending third dimension","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running python in a Linux machine.\nI wonder if a write() done on a file object returned from open() can write less than the amount of data given?\nI know this is the behavior in os.write() but I am not sure if that's the case in file.write() as well or not?\nSo shall I keep retrying until all data is written? Or is it safe to assume everything is written in case of success?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":55416290,"Users Score":1,"Answer":"You are correct. open() returns a 'TextIOWrapper'. From its docstring: \"Character and line based layer over a BufferedIOBase object, buffer.\" \nAssuming f = open(\"\/path\/to\/text.txt\", \"w\"), calling f.flush() will ensure all data currently in the buffer is flushed\/written to \"\/path\/to\/text.txt\".\nIf line buffering is active (f.line_buffering == True), writes ending with a line break are flushed automatically.","Q_Score":1,"Tags":"python-3.x","A_Id":55417399,"CreationDate":"2019-03-29T11:18:00.000","Title":"Can Python file write in Linux do partial writes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Up to now we keep the version number of our python source code in setup.py.\nThis version gets increased after every successful ci run.\nThis means the version of central libraries get increased several times per day.\nSince the version number is stored in a file in the git repo, every increase of the version number is a new commit.\nThis means roughly 50% of all commits are not made by humans, but by CI.\nI have got the feeling, that we are on the wrong track. Maybe it is no good solution to keep the version number in ci.\nHow could we avoid the \"useless\" CI commits which just increase the version number?\nHow to avoid keeping version number in source code?\nUpdate\nWe live without manual release since several years. We do not have a versioning scheme like MAJOR.MINOR. And we have not missed this in the past. I know that this does not work for all environments. But it works for my current environment.\nWe have a version number which looks like this: YEAR.MONTH.X\nThis means every commit which passes CI is a new release.\nAfter reading the answers I realize: I need to asks myself: Do I have a version number at all? I think no. I have a build number. More is not needed in this context.\n(thank you for the up-votes. Before asking this question I was sure that this question will get closed because people will think it is \"unclear\" or \"too broad\")","AnswerCount":6,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":2675,"Q_Id":55416379,"Users Score":4,"Answer":"I think you should use git flow. And create a master branch and a develop branch. Every time the CI checks the develop the version number remains the same. Everytime you create a release e.g. merge develop into master, you can increase the version number by CI. \nOr have i missing something, but in my Opinion there is no reason that the version number is increased everytime ci runs.\nSo all in all you better should think about when to \"release\" changes to a new version!!","Q_Score":17,"Tags":"python,git,continuous-integration","A_Id":55416477,"CreationDate":"2019-03-29T11:22:00.000","Title":"How to avoid keeping version number in source code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Up to now we keep the version number of our python source code in setup.py.\nThis version gets increased after every successful ci run.\nThis means the version of central libraries get increased several times per day.\nSince the version number is stored in a file in the git repo, every increase of the version number is a new commit.\nThis means roughly 50% of all commits are not made by humans, but by CI.\nI have got the feeling, that we are on the wrong track. Maybe it is no good solution to keep the version number in ci.\nHow could we avoid the \"useless\" CI commits which just increase the version number?\nHow to avoid keeping version number in source code?\nUpdate\nWe live without manual release since several years. We do not have a versioning scheme like MAJOR.MINOR. And we have not missed this in the past. I know that this does not work for all environments. But it works for my current environment.\nWe have a version number which looks like this: YEAR.MONTH.X\nThis means every commit which passes CI is a new release.\nAfter reading the answers I realize: I need to asks myself: Do I have a version number at all? I think no. I have a build number. More is not needed in this context.\n(thank you for the up-votes. Before asking this question I was sure that this question will get closed because people will think it is \"unclear\" or \"too broad\")","AnswerCount":6,"Available Count":3,"Score":0.1651404129,"is_accepted":false,"ViewCount":2675,"Q_Id":55416379,"Users Score":5,"Answer":"It is a common practice to keep a version number in the source code, there is nothing wrong in that.\nYou need to separate CI procedures to regular builds, release publishing and release deployment.\nRegular builds: run daily or even after each commit, can include static code analysis and automatic tests, check if the code can be built at all. Regular builds should not change the version number.\nRelease publishing: can only be triggered by explicit manual action by release manager.\nThe trigger action could be tagging a commit with a new version number, new merge into the release branch, or just a commit that changes version number kept in a special file (e.g. pom.xml). Refer to git flow for example.\nRelease publishing assigns a new version number (either automatically or manually), commits it into the source code if necessary, builds a binary package with a new version and uploads it to the binary package repository (e.g. Nexus, devpi, local APT repository, Docker registry and so on).\nRelease deployment: another manually triggered action that takes a ready binary package from a package repository and installs it to the target environment (dev, QA \/ UAT \/ staging, part of production for canary deployments or to the whole production environment).","Q_Score":17,"Tags":"python,git,continuous-integration","A_Id":55417372,"CreationDate":"2019-03-29T11:22:00.000","Title":"How to avoid keeping version number in source code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Up to now we keep the version number of our python source code in setup.py.\nThis version gets increased after every successful ci run.\nThis means the version of central libraries get increased several times per day.\nSince the version number is stored in a file in the git repo, every increase of the version number is a new commit.\nThis means roughly 50% of all commits are not made by humans, but by CI.\nI have got the feeling, that we are on the wrong track. Maybe it is no good solution to keep the version number in ci.\nHow could we avoid the \"useless\" CI commits which just increase the version number?\nHow to avoid keeping version number in source code?\nUpdate\nWe live without manual release since several years. We do not have a versioning scheme like MAJOR.MINOR. And we have not missed this in the past. I know that this does not work for all environments. But it works for my current environment.\nWe have a version number which looks like this: YEAR.MONTH.X\nThis means every commit which passes CI is a new release.\nAfter reading the answers I realize: I need to asks myself: Do I have a version number at all? I think no. I have a build number. More is not needed in this context.\n(thank you for the up-votes. Before asking this question I was sure that this question will get closed because people will think it is \"unclear\" or \"too broad\")","AnswerCount":6,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2675,"Q_Id":55416379,"Users Score":4,"Answer":"Premises:\nI assume these are the premises under which the solution is discussed.\n\nCurrently version number is kept in a git-tracked source file, but you are OK to get rid of it.\nNo one manually manages version number, nor triggers a release procedure, which includes: (a) increase version number, (b) build from source and (c) store the built result somewhere. These are taken cared by CI, and SHOULD remain that way.\n\nSolution:\n\nInstead of writing to a source file and create new commit, CI simply tag the specific commit that passed CI check, then push the tag to remote repo.\nThe build script should read the tag of current HEAD commit, and use it as the version number for publishing a release.\nOptionally, you might want to use git filter-branch to rewrite your existing git repo history, tag previous release commits for consistency, remove and stop tracking the version number source cile, then get rid of those CI commits.","Q_Score":17,"Tags":"python,git,continuous-integration","A_Id":55512274,"CreationDate":"2019-03-29T11:22:00.000","Title":"How to avoid keeping version number in source code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use jedi to provide autocompletion for python editor.\nI however do not want to support Python 3 yet, or certain other features like lambda functions. \nWhat is the place where I can configure this? \nIs jedi the right place or is the language server that uses Jedi the right place or is the parso the grammar parser the right place? \nDo any of these tools provide configuration options for the same?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":55417914,"Users Score":0,"Answer":"Jedi works with environments. These environments allow you to pick a specific Python version. If you just use Python 2, you will automatically get restricted by Jedi with the Python 2 syntax.\nIf you don't want to use lambda functions, just don't use them. There's no way how you can get rid of them in Jedi.","Q_Score":0,"Tags":"python,keyword,jedi,python-language-server","A_Id":57515389,"CreationDate":"2019-03-29T12:56:00.000","Title":"Restricting python version or keywords in jedi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"basically I have this window with a bunch of buttons but I want the background of the window to be invisible\/transparent so the buttons are essentially floating. However, GTK seems to be pretty limited with CSS and I haven't found a way to do it yet. I've tried making the main window opacity 0 but that doesn't seem to work. Is this even possible and if so how can I do it? Thanks.\nEdit: Also, I'm using X11 forwarding.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":55423219,"Users Score":0,"Answer":"For transparency Xorg requires a composite manager running on the X11 server. The compmgr program from Xorg is a minimal composite manager.","Q_Score":1,"Tags":"python,gtk3","A_Id":55425036,"CreationDate":"2019-03-29T18:04:00.000","Title":"Python GTK+ 3: Is it possible to make background window invisible?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just started studying flask and built a toy website to see how well I am doing. I have a flask website built in python 3.6 and I have tested it on my windows computer and everything goes very well. Now I want to host the website on an ubuntu ec2 instance. But first, I am testing if everything runs well on my ec2 instance and am stuck at trying to access port 5000 on my ec2 instance My app is currently serving on port 127.0.0.1:5000 of my linux server. I have tried to connect to my.ec2.public.ip:5000 and my.ec2.private.ip:5000 with no success. Could someone help me? Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":287,"Q_Id":55426401,"Users Score":0,"Answer":"By default a new AWS instance would not allow port 5000 to be accessed, so you will need to modify the security group to allow access on that port. You do this thru the AWS console.","Q_Score":0,"Tags":"amazon-ec2,python-3.6,flask-sqlalchemy,ubuntu-18.04","A_Id":55426431,"CreationDate":"2019-03-29T22:51:00.000","Title":"How do I access 127:.0.0.1:5000 on Ubuntu Server 16.04 LTS (HVM), SSD Volume Type","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm trying to execute a large select query (about 50 000 000 from 200 000 000 rows, 15 columns) and fetch all of this data to pandas data frame using psycopg2. In pgadmin server status tool i can see, that my query is active for about half an hour and then become idle. I read it means that server is waiting for a new command. On the other hand, my python script still don't have data and it waiting for them too (there is no errors, it looks like data are downloading). \nTo sum up, database is waiting, python is waiting, should I still waiting? Is there a chance for happy ending? Or python is not able to process that big amount od data?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":677,"Q_Id":55432663,"Users Score":1,"Answer":"Holy smokes, Batman! If your query takes more than a few minutes to execute, you ought to think of a different way to process your data! If you are returning 200 000 000 rows of 15 single-byte columns, this is already 3 gigabytes of raw data, assuming not a single byte of overhead, which is very unlikely. If those columns are 64-bit integers instead, that is already 24 gigabytes. This is a lot of in-memory data to handle for Python.\nHave you considered what happens if your process fails during execution, or if the connection is interrupted? Your program will benefit from processing rows of data in chunks, if it is possible for your process. If it really is not possible, consider approaches that operate on the database itself, such as using PL\/pgSQL.","Q_Score":1,"Tags":"python,postgresql,psycopg2","A_Id":55432769,"CreationDate":"2019-03-30T14:58:00.000","Title":"Executing a large query with psycopg2","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using an Android device (of Samsung), Pydroid 3.\nI tried to see any graphs, but it doesn't works.\nWhen I run the code, it just shows me a black-blank screen temporarily and then goes back to the source code editing window.\n(means that i can't see even terminal screen, which always showed me [Program Finished])  \nWell, even the basic sample code which Pydroid gives me doesn't show me the  graph :(\nI've seen many tutorials which successfully showed graphs, but well, mine can't do that things.\nUnfortunately, cannot grab any errors.\nUsing same code which worked at Windows, so don't think the code has problem.\nOf course, matplotlib is installed, numpy is also installed.\nIf there's any possible problems, please let me know.","AnswerCount":8,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":8119,"Q_Id":55434255,"Users Score":2,"Answer":"I also had this problem a while back, and managed to fix it by using plt.show()\nat the end of your code. With matplotlib.pyplot as plt.","Q_Score":4,"Tags":"android,python,matplotlib,pydroid","A_Id":56324221,"CreationDate":"2019-03-30T18:02:00.000","Title":"Matplotlib with Pydroid 3 on Android: how to see graph?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using an Android device (of Samsung), Pydroid 3.\nI tried to see any graphs, but it doesn't works.\nWhen I run the code, it just shows me a black-blank screen temporarily and then goes back to the source code editing window.\n(means that i can't see even terminal screen, which always showed me [Program Finished])  \nWell, even the basic sample code which Pydroid gives me doesn't show me the  graph :(\nI've seen many tutorials which successfully showed graphs, but well, mine can't do that things.\nUnfortunately, cannot grab any errors.\nUsing same code which worked at Windows, so don't think the code has problem.\nOf course, matplotlib is installed, numpy is also installed.\nIf there's any possible problems, please let me know.","AnswerCount":8,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":8119,"Q_Id":55434255,"Users Score":0,"Answer":"After reinstalling it worked.\nThe problem was that I forced Pydroid to update matplotlib via Terminal, not the official PIP tab.\nThe version of matplotlib was too high for pydroid","Q_Score":4,"Tags":"android,python,matplotlib,pydroid","A_Id":60702515,"CreationDate":"2019-03-30T18:02:00.000","Title":"Matplotlib with Pydroid 3 on Android: how to see graph?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using an Android device (of Samsung), Pydroid 3.\nI tried to see any graphs, but it doesn't works.\nWhen I run the code, it just shows me a black-blank screen temporarily and then goes back to the source code editing window.\n(means that i can't see even terminal screen, which always showed me [Program Finished])  \nWell, even the basic sample code which Pydroid gives me doesn't show me the  graph :(\nI've seen many tutorials which successfully showed graphs, but well, mine can't do that things.\nUnfortunately, cannot grab any errors.\nUsing same code which worked at Windows, so don't think the code has problem.\nOf course, matplotlib is installed, numpy is also installed.\nIf there's any possible problems, please let me know.","AnswerCount":8,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":8119,"Q_Id":55434255,"Users Score":0,"Answer":"You just need to add a line\nplt.show()\nThen it will work. You can also save the file before showing\nplt.savefig(\"*imageName*.png\")","Q_Score":4,"Tags":"android,python,matplotlib,pydroid","A_Id":66386763,"CreationDate":"2019-03-30T18:02:00.000","Title":"Matplotlib with Pydroid 3 on Android: how to see graph?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to make Flask render two templates at once so that one template can play some video, and the other template, which will be next to it, stream some type of content, meaning it updates every few seconds. When I had only one template, I was able to update it, but the problem was even the video kept restarting. How can I fix this problem? If my two template concept is flawed and impossible, is it possible to get the same results with something else such as reloading only specific divs in the web page. \nNote: This is all on one page.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":218,"Q_Id":55435211,"Users Score":0,"Answer":"Flask only renders 1 template. Yes, you could use iframes to reload only some parts of your website but they are considered a bad practice. Probably the best option is to use AJAX to pool the server for updates periodicaly without reloading the page. You could use jQuery to do it manualy or find some front-end library to make your life easier.","Q_Score":0,"Tags":"python,python-3.x,flask","A_Id":55435285,"CreationDate":"2019-03-30T19:58:00.000","Title":"How to render two html files separately in Flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was trying to install python 3 because I wanted to work on a project using python 3. Instructions I'd found were not working, so I boldly ran brew install python. Wrong move. Now when I run python -V I get \"Python 3.7.3\", and when I try to enter a virtualenv I get -bash: \/Users\/elliot\/Library\/Python\/2.7\/bin\/virtualenv: \/usr\/local\/opt\/python\/bin\/python2.7: bad interpreter: No such file or directory\nMy ~\/.bash_profile reads \nexport PATH=\"\/Users\/elliot\/Library\/Python\/2.7\/bin:\/usr\/local\/opt\/python\/libexec\/bin:\/Library\/PostgreSQL\/10\/bin:$PATH\" \nbut ls \/usr\/local\/Cellar\/python\/ gets me 3.7.3 so it seems like brew doesn't even know about my old 2.7 version anymore.\nI think what I want is to reset my system python to 2.7, and then add python 3 as a separate python running on my system. I've been googling, but haven't found any advice on how to specifically use brew to do this.\nEdit: I'd also be happy with keeping Python 3.7, if I knew how to make virtualenv work again. I remember hearing that upgrading your system python breaks everything, but I'd be super happy to know if that's outdated knowledge and I'm just being a luddite hanging on to 2.7.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":220,"Q_Id":55437402,"Users Score":0,"Answer":"So, I got through it by completely uninstalling Python, which I'd been reluctant to do, and then reinstalled Python 2. I had to update my path and open a new shell to get it to see the new python 2 installation, and things fell into place. I'm now using pyenv for my Python 3 project, and it's a dream.","Q_Score":1,"Tags":"python,python-3.x,python-2.7,homebrew","A_Id":55445585,"CreationDate":"2019-03-31T02:36:00.000","Title":"Accidentally used homebrew to change my default python to 3.7, how do I change it back to 2.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Every time I run pyinstaller in the terminal I get the following error:\nPermissionError: [Errno 1] Operation not permitted: '\/Users\/my_username\/dist\/\nAny ideas on solution?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1964,"Q_Id":55437879,"Users Score":0,"Answer":"I had success by changing the properties of the directory where DIST and BUILD folders are created.\nLocate and select the directory in Finder and open its porperties window (CMD + I)\nOpen up the Sharing and permission panel by clicking on the down arrow\nClick on the padlock and enter your computer password to make changes\nClick on Everyone and then select Read and Write from the dropdown\nClick on the small cog and select Apply to enclosed items\nDelete the DIST and BUILD folders and try again","Q_Score":2,"Tags":"python-3.x,pyinstaller","A_Id":62834420,"CreationDate":"2019-03-31T04:31:00.000","Title":"Pyinstaller PermissionError: [Errno 1] Operation not permitted: '\/Users\/user_name\/dist\/","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Every time I run pyinstaller in the terminal I get the following error:\nPermissionError: [Errno 1] Operation not permitted: '\/Users\/my_username\/dist\/\nAny ideas on solution?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1964,"Q_Id":55437879,"Users Score":0,"Answer":"pyinstaller is probably trying to write files to a directory \/Users\/my_username\/dist where you don't have write access.\nYou can either retry with superuser permissions (i.e. sudo) or try something like brew instead.","Q_Score":2,"Tags":"python-3.x,pyinstaller","A_Id":55439475,"CreationDate":"2019-03-31T04:31:00.000","Title":"Pyinstaller PermissionError: [Errno 1] Operation not permitted: '\/Users\/user_name\/dist\/","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Every time I run pyinstaller in the terminal I get the following error:\nPermissionError: [Errno 1] Operation not permitted: '\/Users\/my_username\/dist\/\nAny ideas on solution?","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":1964,"Q_Id":55437879,"Users Score":3,"Answer":"I was able to get around this by manually deleting all files in the target directory before running Pyinstaller again. Give it a try.","Q_Score":2,"Tags":"python-3.x,pyinstaller","A_Id":61252415,"CreationDate":"2019-03-31T04:31:00.000","Title":"Pyinstaller PermissionError: [Errno 1] Operation not permitted: '\/Users\/user_name\/dist\/","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I created numerous python scripts on my pc laptop, and I want to run those scripts on my android phone. How can I do that? How can I move python scripts from my windows pc laptop, and use those python scripts on my samsung adroid phone? \nI have downloaded qpython from the google playstore, but I still don't know how to get my pc python programs onto my phone. I heard some people talk about \"ftp\" but I don't even know what that means. \nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":385,"Q_Id":55438484,"Users Score":0,"Answer":"Send them to yourself via email, then download the scripts onto your phone and run them through qpython.\nHowever you have to realize not all the modules on python work on qpython so your scripts may not work the same when you transfer them.","Q_Score":0,"Tags":"android,python,ftp,qpython","A_Id":56649272,"CreationDate":"2019-03-31T06:41:00.000","Title":"How does one transfer python code written in a windows laptop to a samsung android phone?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created numerous python scripts on my pc laptop, and I want to run those scripts on my android phone. How can I do that? How can I move python scripts from my windows pc laptop, and use those python scripts on my samsung adroid phone? \nI have downloaded qpython from the google playstore, but I still don't know how to get my pc python programs onto my phone. I heard some people talk about \"ftp\" but I don't even know what that means. \nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":385,"Q_Id":55438484,"Users Score":0,"Answer":"you can use TeamViewer to control your android phone from your PC. And copy and paste the code easily.\nor\nYou can transfer your scripts on your phone memory in the qpython folder and open it using qpython for android.","Q_Score":0,"Tags":"android,python,ftp,qpython","A_Id":56236136,"CreationDate":"2019-03-31T06:41:00.000","Title":"How does one transfer python code written in a windows laptop to a samsung android phone?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have already trained a model to recognise animal and it is working, deployed into android application. I'm finding for a solution to make the image classifier to only classify the trained categories. I'm not sure whether to do this through the model training or any code to be added to solve this.\nExample, if a picture of a cup is sent for classification, the result shows as Dog or some other animal name. How to make only classify the given category, anything else than that show it as \"not a animal\".\nIm using Tensorflow 1.12, MobileNet Model","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":55441123,"Users Score":0,"Answer":"what about checking probability score? Eventhough a cup is classifed as Dog , it will have less score. so you can set your threshold. If the probability score > threshold value, then it will be displayed as animal otherwise not.","Q_Score":2,"Tags":"java,android,python-3.x,tensorflow","A_Id":55441333,"CreationDate":"2019-03-31T12:57:00.000","Title":"My trained image classifer model classify all the images that are not even in the category","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a problem on a remote server (I use ssh to connect). As I'm new to the domain, I'm using jupyter-notebook, so that I can examine and code. \nSome parts of my code take a long time to run(like maybe 4-5 hours) and I'm not able to maintain my connection that long. \nHow can I keep my code running after the shell is closed? Should I just copy it into a .py file and use commands like tmux or screen?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1774,"Q_Id":55442687,"Users Score":5,"Answer":"Use screen.\n\n$ screen \n\nThis will create a screen session and when you are done, you can use the keys ctrl-a-d to detach.\nTo go back:\n\n$ screen -list\n\nThis will show the list of detached screen sessions.  To connect\n\n$ screen -r","Q_Score":2,"Tags":"python,ssh,jupyter-notebook","A_Id":55442759,"CreationDate":"2019-03-31T15:53:00.000","Title":"Keep python code running after closing shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to understand how import works in jupyter notebook.\nMy present working directory is \"home\/username\". I have three python modules. \nThe path names of these modules are as given below.\n\n\"\/home\/username\/module1.py\"\n\"\/home\/username\/folder\/module2.py\"\n\"\/home\/username\/anaconda3\/lib\/python3.7\/os.py\" (which is an inbuilt python module)\n\nJupyter Notebook:\ncell 1:\nimport module1\nWorks just fine\ncell 2:\nimport module2 gives \nModuleNotFoundError: No module named 'module2'\ncell 3:\nimport os\nWorks just fine\nIt seems like modules in the working directory can be imported without any problem. So, module1.py can be imported. Modules in other directories that are not packages cannot be imported directly. So, module2.py throws an error. But if this is the case how can os.py, which is not the working directory or in another package in the same directory, be imported directly?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":511,"Q_Id":55443861,"Users Score":1,"Answer":"This is really more about how python itself works.\nYou should be able to import module2 with from folder import module2. You should declare \/home\/username\/folder as a package by create a blank init file \/home\/username\/folder\/__init__py. I recommend naming the package something more unique, like potrus_folder, that way you don't get naming conflicts down the line.\nTo explain: Python keeps track of what modules it has available through it's path, it is usually set in your environment variables. To see what folders it looks in for modules you can do import sys then print(sys.path). By default your working directory (\/home\/username\/) will be included, with highest priority (it should thus be either first or last in sys.path, I don't remember). You can add your own folder with sys.path.append('\/some\/folder'), although it is frowned upon, and you should really add it to your system path, or just keep it as a package in your working directory.\nPackages are really just subfolders of paths which have already been added. You access them, as I explained earlier, by using the from X import Y syntax, or if you want to go deeper from X.Z import Y. Remember the __init__.py file.","Q_Score":2,"Tags":"python,import,jupyter-notebook,anaconda","A_Id":55443984,"CreationDate":"2019-03-31T18:03:00.000","Title":"How does jupyter notebook import modules which are not in the current working directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to understand how import works in jupyter notebook.\nMy present working directory is \"home\/username\". I have three python modules. \nThe path names of these modules are as given below.\n\n\"\/home\/username\/module1.py\"\n\"\/home\/username\/folder\/module2.py\"\n\"\/home\/username\/anaconda3\/lib\/python3.7\/os.py\" (which is an inbuilt python module)\n\nJupyter Notebook:\ncell 1:\nimport module1\nWorks just fine\ncell 2:\nimport module2 gives \nModuleNotFoundError: No module named 'module2'\ncell 3:\nimport os\nWorks just fine\nIt seems like modules in the working directory can be imported without any problem. So, module1.py can be imported. Modules in other directories that are not packages cannot be imported directly. So, module2.py throws an error. But if this is the case how can os.py, which is not the working directory or in another package in the same directory, be imported directly?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":511,"Q_Id":55443861,"Users Score":0,"Answer":"The path of os library is set in environment*\nWhenever you give import it would search all the directories which are added in your environment + the pwd , so you could just add the directory in environment and that would work\nBy default \/home\/username\/anaconda3\/lib\/python3.7\/ is added by default at the time of installation since there is where most of the module lies, but you can add urs too","Q_Score":2,"Tags":"python,import,jupyter-notebook,anaconda","A_Id":55443925,"CreationDate":"2019-03-31T18:03:00.000","Title":"How does jupyter notebook import modules which are not in the current working directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on some python code and I am generating images that will be continuously into a folder as an output. My goal is to change the output location to a folder on another computer and be able to add images into it using a python script.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":55445504,"Users Score":0,"Answer":"This is less of a programming question than a system architecure question, but I will give you some ideas:\n\nUse Amazon S3 and the boto3 library for python.  One line of code and you will have the images uploaded to Amazon S3 for use anywhere.\nSetup SSH keys between the systems and use subprocess to initiate an scp call to copy the image.\nSetup a network share so you have a local path on the original computer that can write to the other.\n\n\nDespite how great python is, you can't just put stuff on other computers without a agreed upon protocol, server, and\/or network setup.\nI recommend you use a cloud provider like Amazon S3.","Q_Score":0,"Tags":"python","A_Id":55445760,"CreationDate":"2019-03-31T21:13:00.000","Title":"I am generating images that will be continuously into a folder as an output. My goal is to change the output location to another computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a set of 2000 points which are basically x,y coordinates of pass origins from association football. I want to run a k-means clustering algorithm on it to just classify it to get which 10 passes are the most common (k=10). However, I don't want to predict any points for future values. I simply want to work with the existing data. Do I still need to split it into testing-training sets? I assume they're only done when we want to train the model on a particular set to calculate for future values (?)\nI'm new to clustering (and Python as a whole) so any help would be appreciated.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":8449,"Q_Id":55450949,"Users Score":-1,"Answer":"No, in clustering (i.e unsupervised learning ) you do not need to split the data","Q_Score":0,"Tags":"python-3.x,machine-learning,cluster-analysis,k-means","A_Id":55451075,"CreationDate":"2019-04-01T08:34:00.000","Title":"Do I need a test-train split for K-means clustering even if I'm not looking to predict anything?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pygame does not work in Pycharm despite everything works at python IDLE.\nIt says:\nAttributeError: module 'pygame' has no attribute 'init'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":162,"Q_Id":55454791,"Users Score":0,"Answer":"Even though the given information is not enough for properly answering this question, I can tell you a one cause for this error from my personal experience. \nMost probably you have named your source file as pygame.py or you have a directory named pygame somewhere in your path.","Q_Score":0,"Tags":"python,pygame,pycharm","A_Id":55484039,"CreationDate":"2019-04-01T12:10:00.000","Title":"Pycharm IDE issue\/problem on pygame module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a text file like this:\n\n...\n  NAME : name-1\n  ...\n  NAME : name-2\n  ...\n  ...\n  ...\n  NAME : name-n\n  ...\n\nI want output text files like this:\n\nname_1.txt : NAME : name-1 ...\n  name_2.txt : NAME : name-2 ...\n  ...\n  name_n.txt : NAME : name-n ...\n\nI have the basic knowledge of grep, sed, awk, shell scripting, python.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":55459973,"Users Score":0,"Answer":"With GNU sed:\nsed \"s\/\\(.*\\)\\(name-.*\\)\/echo '\\1 \\2' > \\2.txt\/;s\/-\/_\/2e\" input-file\n\nTurn line NAME : name-2 into echo \"NAME : name-2\" > name-2.txt\nThen replace the second - with _ yielding echo \"NAME : name-2\" > name_2.txt\ne have the shell run the command constructed in the pattern buffer.\n\nThis outputs blank lines to stdout, but creates a file for each matching line.\nThis depends on the file having nothing but lines matching this format... but you can expand the gist here to skip other lines with n.","Q_Score":0,"Tags":"python,awk,sed,grep","A_Id":55462346,"CreationDate":"2019-04-01T16:47:00.000","Title":"how to find text before and after given words and output into different text files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to reshape an array of size (14,14,3) to (None, 14,14,3). I have seen that the output of each layer in convolutional neural network has shape in the format(None, n, n, m). \nConsider that the name of my array is arr\nI tried arr[None,:,:] but it converts it to a dimension of (1,14,14,3).\nHow should I do it?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":163,"Q_Id":55462718,"Users Score":1,"Answer":"The shape (None, 14,14,3) represent ,(batch_size,imgH,imgW,imgChannel) now imgH and imgW can be use interchangeably depends on the network and the problem. \nBut the batchsize is given as \"None\" in the neural network because we don't want to restrict our batchsize to some specific value as our batchsize depends on a lot of factors like memory available for our model to run etc.\nSo lets say you have 4 images of size 14x14x3 then you can append each image into the array say L1, and now the L1 will have the shape 4x14x14x3 i.e you made a batch of 4 images and now you can feed this to your neural network. \nNOTE here None will be replaced by 4 and for the whole training process it will be 4. Similarly when you feed your network only one image it assumes the batchsize of 1 and set None equal to 1 giving you the shape (1X14X14X3)","Q_Score":0,"Tags":"python,arrays,numpy,conv-neural-network,reshape","A_Id":55471123,"CreationDate":"2019-04-01T20:01:00.000","Title":"converting an array of size (n,n,m) to (None,n,n,m)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The requirement is that I have to trigger a SageMaker endpoint on lambda to get predictions(which is easy) but have to do some extra processing for variable importance using packages such as XGBoost and SHAP.\nI am able to hit the endpoint and get variable importance using the SageMaker Jupyter notebook. Now, I want to replicate the same thing on AWS lambda.\n1) How to run python code on AWS lambda with package dependencies for Pandas, XGBoost and SHAP (total package size greater than 500MB). The unzipped deployment package size is greater than 250 MB, hence lambda is not allowing to deploy. I even tried using lambda function from Cloud9 and got the same error due to size restrictions. I have also tried lambda layers, but no luck.\n2) Is there a way for me to run the code with such big packages on or through lambda bypassing the deployment package size limitation of 250 MB\n3) Is there a way to trigger a SageMaker notebook execution through lambda which would do the calculations and return the output back to lambda?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1517,"Q_Id":55463916,"Users Score":1,"Answer":"I found the 250MB limitation on AWS lambda size to be draconian. Only one file ibxgboost.so from xgboost package is already around 140 MB which leaves only 110Mb for everything else. That makes AWS lambdas useless for anything but simple \"hello world\" stuff.\n As an ugly workaround you can store xgboost package somewhere on s3 an copy it to the \/tmp folder from the lambda invocation routine and point your python path to it. The allowed tmp space is a bit higher - 500MB so it might work. \nI am not sure though if the \/tmp folder is not cleaned between the lambda function runs though.","Q_Score":6,"Tags":"python,amazon-web-services,aws-lambda,xgboost,amazon-sagemaker","A_Id":58662399,"CreationDate":"2019-04-01T21:36:00.000","Title":"How to run python code on AWS lambda with package dependencies >500MB?","Data Science and Machine Learning":0,"Database and SQL":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 rather small Pygame based python script and I just bought a Mac so I'm trying to run my script on here. Everything has been installed correctly (Checking by typing 'import Pygame') into python terminal as-well as running a basic hello world program. However, when I try running this script, IDLE gets brought to the front but nothing happens from there. (The script is supposed to pop-up a new window). Is this a problem with my installations or my code? (Code works on windows setup).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":55465005,"Users Score":0,"Answer":"You could try to run the script again on a windows computer to see if you forgot to save some changes or if the file got corrupted somehow. You could also use bootcamp to install Windows on your mac since you could have one windows version on your mac for coding purposes and the regular mac OS for other stuff if you like.","Q_Score":0,"Tags":"python,macos,pygame","A_Id":55489181,"CreationDate":"2019-04-01T23:41:00.000","Title":"How to get Pygame script to run on macOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"tl;dr: does anyone know any better way to accomplish basically the same thing as aliases since mine don't work?\nhey and thanks for reading,\nI have a raspberry pi where I'm trying to run a bot that only works on python 3.6 and up. Python only officially supports up to 3.5 on Raspberry Pi, so I had to manually compile it.\nAnyway, the bot I use calls \"python3\" in its coding, however Raspberry Pis come with 3.5, so calling \"python3\" actually calls Python 3.5, not 3.7. I tried deleting Python 3.5, but it then rather than calling Python 3.7, it just said that nothing named python3 exists.\nI tried using aliases to call it, but they don't work at all for some reason. I know I'm using the right syntax, and I did the update command for the file, but they just don't work.\nI know that's kind of a lot, but does anyone know any better way to accomplish basically the same thing as aliases since mine don't work? Or can anyone help me figure out what's wrong with my current coding for aliases?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":628,"Q_Id":55465936,"Users Score":1,"Answer":"It's not advisable to install an out-of-distribution Python version, and you can't expect system libraries to work with it.\nYour best bet is to upgrade to Raspbian Buster, as it comes with Python 3.7 as standard. Buster is still in testing phase and not due for release until the summer, but I've been using it for a while and it seems to work ok. I have had success upgrading the Lite image but not Desktop.\nTo upgrade, edit \/etc\/apt\/sources.list and replace stretch with buster, then  run apt update; apt dist-upgrade and wait for it to do the upgrade, then reboot and you'll have python3 pointing at Python 3.7.","Q_Score":0,"Tags":"python,python-3.x,raspberry-pi,alias,aliases","A_Id":55492603,"CreationDate":"2019-04-02T02:04:00.000","Title":"How to get the python command to call python3.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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"tl;dr: does anyone know any better way to accomplish basically the same thing as aliases since mine don't work?\nhey and thanks for reading,\nI have a raspberry pi where I'm trying to run a bot that only works on python 3.6 and up. Python only officially supports up to 3.5 on Raspberry Pi, so I had to manually compile it.\nAnyway, the bot I use calls \"python3\" in its coding, however Raspberry Pis come with 3.5, so calling \"python3\" actually calls Python 3.5, not 3.7. I tried deleting Python 3.5, but it then rather than calling Python 3.7, it just said that nothing named python3 exists.\nI tried using aliases to call it, but they don't work at all for some reason. I know I'm using the right syntax, and I did the update command for the file, but they just don't work.\nI know that's kind of a lot, but does anyone know any better way to accomplish basically the same thing as aliases since mine don't work? Or can anyone help me figure out what's wrong with my current coding for aliases?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":628,"Q_Id":55465936,"Users Score":2,"Answer":"Use a full path to your new python version to run it.\n\/full\/path\/to\/3.7\/python3.7\nWhat the path is will depend on the directions you followed and options picked when compiling the new python version.\nif you want it to work by simply typing python or python3 you will have to change the symbolic links to point to the new python version.","Q_Score":0,"Tags":"python,python-3.x,raspberry-pi,alias,aliases","A_Id":55466257,"CreationDate":"2019-04-02T02:04:00.000","Title":"How to get the python command to call python3.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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have categorical variables such as Gender,Anxiety,Alcoholic and when i convert these categorical variables into numerical values using encoder techniques then all these variables resembles same in values and then multi co linearity is existing. How i can convert these variables to number so that multi co linearity doesn't exist. All three variables are important for prediction of target variable.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":35,"Q_Id":55469874,"Users Score":1,"Answer":"You don't need to transform the data.Instead you can change the way that you are calculating correlation between variables. As these are categorical features, you have to use Chi-Squared test of independence.Then, you won't be facing this issue.","Q_Score":0,"Tags":"python,machine-learning","A_Id":55472980,"CreationDate":"2019-04-02T08:12:00.000","Title":"I need to remove multi co-linearity between features","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a task to compare data of two tables in two different oracle databases. We have access of views in both of db. Using SQLAlchemy ,am able to fetch rows from views but unable to parse it. \nIn one db the type of ID column is : Raw \nIn db where column type is \"Raw\", below is the row am getting from resultset . \n(b'\\x0b\\x975z\\x9d\\xdaF\\x0e\\x96>[Ig\\xe0\/', 1, datetime.datetime(2011, 6, 7, 12, 11, 1), None, datetime.datetime(2011, 6, 7, 12, 11, 1), b'\\xf2X\\x8b\\x86\\x03\\x00K|\\x99(\\xbc\\x81n\\xc6\\xd3', None, 'I', 'Inactive')\nID Column data: b'\\x0b\\x975z\\x9d\\xdaF\\x0e\\x96>[_Ig\\xe0\/'\nActual data in ID column in database: F2588B8603004B7C9928BC816EC65FD3\nThis data is not complete hexadecimal format as it has some speical symbols like >|[_ etc. I want to know that how can I parse the data in ID column and get it as a string.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":55471457,"Users Score":0,"Answer":"bytes.hex() solved the problem","Q_Score":0,"Tags":"python,sqlalchemy","A_Id":55590150,"CreationDate":"2019-04-02T09:36:00.000","Title":"Unable to parse the rows in ResultSet returned by connection.execute(), Python and SQLAlchemy","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm setting up a new algorithm which combines an object detector(bounding box detector) which is in python 3 and a mask generator which is in python 2. The problem here is I have several python 2 files which is required for the mask generation algorithm. So I tried 2to3 to convert all my python 2 files to python 3. The script seemed like working but as it was a deep learning algorithm(for mask generation when bounding box coordinates are given as input) which needs some pytorch weights to be loaded, while testing the model in python 3 the program was throwing out error like\n\n\"RuntimeError: Expected object of type torch.FloatTensor but found\n  type torch.cuda.FloatTensor for argument #2 \u2018weight\u2019\"\n\nI have searched in PyTorch forums but none of the posts were useful to me. Is it because my mask generation code is trained in python 2 ?\nDoes that means while loading the weights and testing the model I should use python 2 not python 3 ? It would be great if someone can shed some light on this. As a work around I can still use the object detector code downgraded to python 2. But still I want to know why it was throwing the error.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":55471459,"Users Score":0,"Answer":"The problem is(can) that cpu object is expected but it gpu object. Try to put the object to cpu: \nmask.cpu()","Q_Score":0,"Tags":"python-2.7,pytorch","A_Id":55488118,"CreationDate":"2019-04-02T09:36:00.000","Title":"Code conversion from python 2 to python 3","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The table has two keys: filename (partition key) and eventTime (sort key). \nI want to update eventTime for certain filename. Tried put_item() and update_item() sending the same filename with new eventTime but those functions add a new item instead of update. \nWhat should I use for that purpose?","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":16115,"Q_Id":55474664,"Users Score":5,"Answer":"According to DynamoDB\/AttributeValueUpdate aws docs:\n\nYou cannot use UpdateItem to update any primary key attributes.\n  Instead, you will need to delete the item, and then use PutItem to\n  create a new item with new attributes.","Q_Score":6,"Tags":"python,amazon-web-services,amazon-dynamodb","A_Id":58924104,"CreationDate":"2019-04-02T12:20:00.000","Title":"DynamodDB: How to update sort key?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm on Windows and want to use the Python package apt_pkg in PyCharm.\nOn Linux I get the package by doing sudo apt-get install python3-apt but how to install apt_pkg on Windows?\nThere is no such package on PyPI.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1074,"Q_Id":55474845,"Users Score":1,"Answer":"There is no way to run apt-get in Windows; the package format and the supporting infrastructure is very explicitly Debian-specific.","Q_Score":1,"Tags":"python,pycharm,apt","A_Id":55474963,"CreationDate":"2019-04-02T12:30:00.000","Title":"How to install Python packages from python3-apt in PyCharm on Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to create a matrix of dimension nxn in Sage. But every element in the matrix has to be 1\/n. The size of n is around 7000.\nFirst I tried using creating a matrix of ones with the build in sagemethod, and then multiplying the matrix with 1\/n. This is very slow and crashes my jupyter notebook kernel.\nT  =matrix.ones(7000) * 1\/n\nA second thing I tried is creating all the elements by list comprehension.\nT = matrix(RDF,[[1\/l for x in range(l)] for row in range(l)])\nThis also seems to be something my pc can't handle.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":140,"Q_Id":55475303,"Users Score":3,"Answer":"@JamesKPolk gave me a working solution.\nT = matrix(RDF, 6000, 6000, lambda i,j: 1\/6000)","Q_Score":3,"Tags":"python,matrix,sage","A_Id":55475569,"CreationDate":"2019-04-02T12:52:00.000","Title":"Creating a big matrix where every element is the same","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the script's main thread, I setup a variable called queue and fill it with URLs. Then I create 8 processes using multiprocessing.Process and then those processes spawn 10 threads each using the threading library.\nWithin the thread worker (which was spawned by another process as per above), I have global queue.\nThen will queue.get() act as expected? I've tried it and it seems to be okay during some tests and others not.\nQuestion is, can global variables be accessed from another process and thread?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":848,"Q_Id":55478932,"Users Score":1,"Answer":"It is hard to understand what you are exactly asking. But there are two main questions here:\nCan global variables be accessed from another process?\nNo, not without some form of inter-process communication, and even then you would be passing a copy of that variable to the other process. Each process has its own global state.\nCan global variables be accessed from another thread?\nYes, a thread who lives in the same process can access a global variable, but you must ensure the safety of any memory that is accessed by multiple threads. Meaning, threads should not access writable memory at the same time as other threads or you run the risk of one thread writing to the memory while another thread attempts to read it.\nAnswering Question Above\nIf I understand the setup correctly, each of your child processes has their own global variable queue. Each of those queues should be accessible only to the threads that are spawned within that process.","Q_Score":1,"Tags":"python,multithreading","A_Id":55479239,"CreationDate":"2019-04-02T15:54:00.000","Title":"Can global variables be accessed from a thread within a new process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm setting up Wing IDE to run my code, and have a few libraries imported.  When my code hits an exception, wing'll automatically open up numpy or openpyxl to where the the exception occurred.  How to I prevent Wing from opening up some library that's not the problem?\nI dug through the Wing page, and didn't find anything about this in its design\nWhat I'd like:\n   When I write bad code, just bring up the errors in the \"Exceptions\" window\nWhat I'm getting:\n   When I write bad code, it opens the library file that threw the exception and highlights it, instead of staying in my crappy code.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":55482128,"Users Score":2,"Answer":"Currently Wing shows you the line where the exception is raised and you can go up the stack by clicking on lines in the exception tool.  We plan on adding an option to show you the line in your code where the library was called.","Q_Score":0,"Tags":"python,wing-ide","A_Id":55482995,"CreationDate":"2019-04-02T19:23:00.000","Title":"How to stop Wing IDE from opening imported modules on exception","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm woriking on a project that checks if LEDSTATUS from a database has the value \"0\" then led is off, if the value is \"1\" led is on.\nI searched and found out that there is something called UDF that can run scripts but am not sure if it is possible if the database is not local (on a server).\nis it possible? if yes how?\nI created two python scripts one that turn led on and the other one to turns it off. \nI will create a database with one table LEDSTATUS and will create a trigger that will run when ever the value of LEDSTATUS gets changed, if the value is 0 then run python script that turn led off, and if the value is 1 run the other script.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":437,"Q_Id":55482634,"Users Score":0,"Answer":"Database triggers are for DELETE, INSERT, UPDATE sql queries. You cannot trigger a python script with it.\nAt some point you set the database field to 0 or to 1 with an UPDATE SQL query.\nThe event based approach is to run the according python script before or after you performed the sql update query. Python could run as a webserver on the pi and you can send values via GET or POST.   \nThe polling approach is to query the database every x (mili)second with a python script or similar and execute turn on\/off functions accordingly.","Q_Score":0,"Tags":"python,mysql,raspberry-pi3,user-defined-functions","A_Id":55484111,"CreationDate":"2019-04-02T19:58:00.000","Title":"Can i run a python script on my raspberry pi when a trigger is triggered in Mysql database server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Say I have a rectangle [a,b]x[c,d], where a,b,c,d are reals.\nI would like to produce k points (x,y) sampled uniformly from this rectangle, i.e. a <= x <= c and b <= y <= d.\nObviously, if sampling from [0,1]x[0,1] is possible, then\nthe problem is solved. How to achieve any of the two goals, in python?\nOr, another tool such as R, for example?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":577,"Q_Id":55482837,"Users Score":-1,"Answer":"I think modulo operator (%) is your friend to check if x and y are in [a,c] and [b,d]\nIf you can't use random between 2 numbers (others 0 and 1), you can try to make x = (random() *(c-a)+a)\nSame with y :)\nEDIT : Oh, i send it just after Merig","Q_Score":0,"Tags":"python,random","A_Id":55482982,"CreationDate":"2019-04-02T20:11:00.000","Title":"Python: (uniform) sampling from a rectangle","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a twisted web application which uploads files and encrypts them, returning the url+key to the user.\nI've been tasked with scaling this application. At the moment when there are more than 3-4 concurrent upload requests the performance will drop off significantly.\nI'm no Twisted expert but I assume this is due to it running in a single python process, being a high cpu application and the GIL?\nHow could I go about scaling this?\nIf this was a different framework such as Flask I would just put uwsgi in front of it and scale the number of processes. Would something similar work for Twisted and if so what tools are generally used for this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":259,"Q_Id":55483727,"Users Score":0,"Answer":"If you think you could throw uwsgi in front of the application, I suppose it is pretty close to shared-nothing.  So you can run multiple instances of the program and gain a core's worth of performance from each.\nThere are a couple really obvious options for exactly how to run the multiple instances.  You could have a load balancer in front.  You could have the processes share a listening port.  There are probably more possibilities, too.\nSince your protocol seems to be HTTP, any old HTTP load balancer should be applicable.  It needn't be Twisted or Python based itself (though certainly it could be).\nIf you'd rather share a listening port, Twisted has APIs for passing file descriptors between processes (IReactorSocket) and for launching new processes that inherit a file descriptor from the parent (IReactorProcess).","Q_Score":1,"Tags":"python,twisted,scaling","A_Id":55485152,"CreationDate":"2019-04-02T21:19:00.000","Title":"How to scale a CPU bound Twisted 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":1,"Web Development":1},{"Question":"I have a .bash_profile file ready to go. When I activate my virtual environment I can't access it. The environment bash_profile is blank. Is there a way to 'import' my normal bash_profile into all\/select virtual environments\nI'm creating the virtual environments through the anaconda distribution, which messes with the path for the .bash_profile a bit, I believe.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":363,"Q_Id":55484799,"Users Score":0,"Answer":"Turns out I just had to source the 'home' bash_profile with source ~\/.bash_profile from within the environment.","Q_Score":1,"Tags":"python,bash,shell,anaconda","A_Id":55484973,"CreationDate":"2019-04-02T23:15:00.000","Title":"How to access main .bash_profile from within an anaconda virtual environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Using cx_Oracle to fetch tables with ROWID ends up crashing the python. I read that the solution was to set the environemtn variable 'ORA_OCI_NO_OPTIMIZED_FETCH' to 1. But using os.environ (in python) or Get-ChildItem Env: (in powershell), I don't see this particular variable. Then what should I do?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":134,"Q_Id":55487001,"Users Score":1,"Answer":"Then what should I do?\n\nCreate it. $env:ORA_OCI_NO_OPTIMIZED_FETCH = 1 in PowerShell, just before you run Python in the same shell.","Q_Score":0,"Tags":"python-3.x,powershell,windows-10,environment-variables,cx-oracle","A_Id":55487085,"CreationDate":"2019-04-03T04:17:00.000","Title":"How to set the environment \" ORA_OCI_NO_OPTIMIZED_FETCH\"?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As the title says, I want to know whether input shape affects the accuracy of the deep learning model.\nAlso, can pre-trained models (like Xception) be used on grayscale images?\nP.S. : I recently started learning deep learning so if possible please explain in simple terms.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":55487087,"Users Score":0,"Answer":"Usually, with convolutional neural networks, differences in the image shape (the width\/height of an image) will not matter. However, differences in the # of channels in the image (equivalently the depth of the image), will affect the performance. In fact, there will usually be dimension mismatch errors you get if the model was trained for greyscale\/colour and you put in the other type.","Q_Score":0,"Tags":"python,keras,conv-neural-network,pre-trained-model,transfer-learning","A_Id":55487120,"CreationDate":"2019-04-03T04:28:00.000","Title":"Does the accuracy of the deep learning program drop if I do not put in the default input shape into the pretrained model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was getting an error while accessing my jupyter notebook which was a syntax error in dateutil module so I uninstalled it using pip uninstall pyhton-dateutil and then while installing it again using pip install python-dateutil I got this message\nRequirement already satisfied: python-dateutil in .\/miniconda3\/lib\/python3.6\/site-packages (1.5)\nthen for removing it completely I tried rm -rf .\/miniconda3\/lib\/python3.6\/site-packages\/dateutil\nsomeone please suggest me what to do as my jupyter notebook is not working as it need dateutil for working","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":654,"Q_Id":55488787,"Users Score":0,"Answer":"the best way to resolve this issue use the conda commands\n\nopen anaconda prompt (go to start and search anaconda prompt)\nnow use the following two commands \n1) First execute this command  conda uninstall -c anaconda dateutil \n2)  conda install -c anaconda dateutil\nThis will work for you. \nif not work please let me know.","Q_Score":0,"Tags":"jupyter,python-dateutil","A_Id":55591122,"CreationDate":"2019-04-03T06:50:00.000","Title":"Uninstalling and RE-Installing python-dateutil","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to access the data in google clound bucket to my VM instance (jupyter notebook). I got this error and also getting problems related to this.\nERROR: Python 3 and later is not compatible with the Google Cloud SDK. Please use Python version 2.7.x.\nIf you have a compatible Python interpreter installed, you can use it by setting\nthe CLOUDSDK_PYTHON environment variable to point to it.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":74,"Q_Id":55490289,"Users Score":1,"Answer":"The Google cloud SDK is not compatible with Python3 for now. You will have to default to a better version as such 2.7.9 or later to work with the SDK.","Q_Score":0,"Tags":"python,google-cloud-platform,jupyter-notebook","A_Id":55490697,"CreationDate":"2019-04-03T08:18:00.000","Title":"Google cloud Bucket access","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am attempting to pass my custom dataset which is loaded in from a CSV file using \npanda.readcsv() through sklearns MLPRegressor. \nMy initial error was my 1D array needed to become a 2D array. Expected 2D array, got 1D array instead: array=[0. 0. 1. ... 0. 0. 1.].\nSo I used panda.reshape(x_test, (-1, 1)) on both the x_test and y_train to solve this issue. However this now presents me with the following error.\nShape of passed values is (16209258, 1), indices imply (207811, 78)\nHave looked around a few other posts without success.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":55495746,"Users Score":0,"Answer":"So I after implementing @Quang Hoang's suggestion  panda.reshape(array_name, (-1, 78)) on x_test, y_test and x_train this finally converted all nessasary arrays into the required 2D format.","Q_Score":0,"Tags":"python-3.x,pandas,scikit-learn","A_Id":55496284,"CreationDate":"2019-04-03T12:55:00.000","Title":"Shape of passed values blah indices imply blah","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use ...\\pserve development.ini --reload in my dev environment to restart my API when code change.\nThe doc says:\n\nAuto-template-reload behavior is not recommended for production sites\n  as it slows rendering slightly; it\u2019s usually only desirable during\n  development.\n\nBut the doc has no proposition for a production environment. What's the recommendation to reload, do I have to make it manually every time?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":167,"Q_Id":55495879,"Users Score":2,"Answer":"Yes, you will need to restart the service if you change anything in your config file.\nIf you know that you'll be changing things and don't want to restart it every time that happens, move some of your configs to a database and refactor your app to read from that. This won't be possible for everything, and you'll need to be careful that when an update happens it is applied correctly, but it can be done for some things.","Q_Score":1,"Tags":"python,pyramid","A_Id":55496324,"CreationDate":"2019-04-03T13:01:00.000","Title":"Deploy\/Reload code from python pyramid project in production","Data Science and Machine Learning":0,"Database and SQL":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 done with my work, I try to close my jupyter notebook via 'Close and Halt' under the file menu. However it somehow do not functioning.\nI am running the notebook from Canopy, version: 2.1.9.3717, under macOs High Sierra.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":556,"Q_Id":55498271,"Users Score":1,"Answer":"If you are running Jupyter notebook from Canopy, then the Jupyter notebook interface is not controlling the kernel; rather, Canopy's built-in ipython Qtconsole is. You can restart the kernel from the Canopy run menu.","Q_Score":0,"Tags":"python,macos,jupyter-notebook,macos-high-sierra,canopy","A_Id":55539791,"CreationDate":"2019-04-03T14:59:00.000","Title":"\u201cClose and Halt\u201d feature does not functioning in jupyter notebook launched under Canopy on macOs High Sierra","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to import a load data from an Excel file to Abaqus Amplitude object by using python script, so that I can automate the preprocess to realize a large number of load conditions. But there is an Error: \"ValueError: File 'load.xlsx' is already in use. Close the file before importing the data.\"\nHowever, I have never opened this Excel file. I have reboot the computer to make sure the file is not opened. This error still appears. Below is what I entered in the Kernel Command Line Interface in Abaqus and the response: \n\n\n\nimport abq_ExcelUtilities\nabq_ExcelUtilities.excelUtilities.ExcelToAmplitude(inputFileForAmp='load.xlsx',sheetNameForAmp='Sheet1', ampStartCell='A1', ampEndCell='B34972', ampNameStr='Amp-1', amplitudeType=0)\n      Importing file \"load.xlsx\"...\n      File \"SMAPyaModules\\SMAPyaPluginsPy.m\\src\\abaqus_plugins\\excelUtilities\\abq_ExcelUtilities\\excelUtilities.py\", line 465, in ExcelToAmplitude\n      File \"SMAPyaModules\\SMAPyaPluginsPy.m\\src\\abaqus_plugins\\excelUtilities\\abq_ExcelUtilities\\excelUtilities.py\", line 682, in CreateObject\n      File \"SMAPyaModules\\SMAPyaPluginsPy.m\\src\\abaqus_plugins\\excelUtilities\\abq_ExcelUtilities\\excelUtilities.py\", line 512, in ExtractDataFromExcel\n      ValueError: File 'load.xlsx'\n      is already in use. Close the file before importing the data.\n\n\n\nI have no idea where to begin to address this problem. Any help would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":55499586,"Users Score":0,"Answer":"I solved this problem by close all software in the Windows tray. One of the softwares that startup along with Windows may obstructs my script. But when I reboot my PC again to trial out which one caused this trouble, the problem totally disappeared, and never show up. \nThanks to @Tom for his concern! Any good insight is welcomed.","Q_Score":0,"Tags":"python,excel,abaqus","A_Id":55511552,"CreationDate":"2019-04-03T16:05:00.000","Title":"How to solve \"ValueError: File 'load.xlsx' is already in use.\" error encountered when use 'abq_ExcelUtilities.excelUtilities.ExcelToAmplitude' method?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to add Dicom tags to a series of Dicom images and want to save that modified batch.\nI have written a simple python script using pydicom which can edit and add dicom tags in a single Dicom image, but i want to do same procedure for complete image set (say 20 or 30 images).\ncan anybody suggest me a way to do such task using pydicom or python?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":848,"Q_Id":55500824,"Users Score":1,"Answer":"Just collect your filenames in a list and process each filename (read the file, edit contents, save as new or maybe use the same name).\nHave a look at the os module from python. For instance, os.listdir('path') returns a list of filenames found in the given path. If that path points to a directory that contains only dicom images you now have a list of dicom filenames. Next use os.path.join('path', filename) to get an absolute path that you can use as input for reading a dicom file with pydicom.\nAlso you might want to use a for loop.","Q_Score":2,"Tags":"python-3.x,pydicom","A_Id":55502000,"CreationDate":"2019-04-03T17:20:00.000","Title":"How to add dicom tags for a series of dicom images?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script which communicates with a Financial site through an API. I also have a Django site, i would like to create a basic form on my site where i input something and, according to that input, my Python script should perform some operations. \nHow can i do this? I'm not asking for any code, i just would like to understand how to accomplish this. How can i \"run\" a python script on a Django project? Should i make my Django project communicate with the script through a post request? Or is there a simpler way?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1367,"Q_Id":55501346,"Users Score":0,"Answer":"I agree with @Daniel Roseman\nIf you are looking for your program to be faster, maybe multi-threading would be useful.","Q_Score":1,"Tags":"python,django","A_Id":55501698,"CreationDate":"2019-04-03T17:51:00.000","Title":"Running an external Python script on a Django site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python script which communicates with a Financial site through an API. I also have a Django site, i would like to create a basic form on my site where i input something and, according to that input, my Python script should perform some operations. \nHow can i do this? I'm not asking for any code, i just would like to understand how to accomplish this. How can i \"run\" a python script on a Django project? Should i make my Django project communicate with the script through a post request? Or is there a simpler way?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1367,"Q_Id":55501346,"Users Score":2,"Answer":"Since you don't want code, and you didn't get detailed on everything required required, here's my suggestion:\n\nMake sure your admin.py file has editable fields for the model you're using.\nMake an admin action,\nTake the selected row with the values you entered, and run that action with the data you entered.\n\nI would be more descriptive, but I'd need more details to do so.","Q_Score":1,"Tags":"python,django","A_Id":55501726,"CreationDate":"2019-04-03T17:51:00.000","Title":"Running an external Python script on a Django site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We are trying to get the owned games of a lot of users but our problem is that after a while the API call limit (100.000 a day) kicks in and we stop getting results. \nWe use 'IPlayerService\/GetOwnedGames\/v0001\/?key=APIKEY&steamid=STEAMID' in our call and it works for the first entries. \nThere are several other queries like the GetPlayerSummaries query which take multiple Steam IDs, but according to the documentation, this one only takes one. \nIs there any other way to combine\/ merge our queries? We are using Python and the urllib.request library to create the request.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":807,"Q_Id":55505061,"Users Score":0,"Answer":"Depending on the payload of the requests you have the following possibilities:\n\nif each request brings only the newest updates, you could serialize the steam ID's when you get the response that you've hit the daily limit\nif you have the ability to control via the request payload what data you receive, you could go for a multithreaded \/ multiprocessing approach that consume the  request queries and the steam ID's from a couple of shared resources","Q_Score":0,"Tags":"python,urllib,steam-web-api","A_Id":55505148,"CreationDate":"2019-04-03T22:08:00.000","Title":"Steam Web API GetOwnedGames multiple SteamIDs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"It gives me the error only after I have converted it to an exe, works fine as a .py file\nI tried to find the file missing and replace it but it still didn't work.\nThe error I get is:\n\nTraceback (most recent call last):\nFile \"tkinter_init_.py\", line 1705, in call\nFile \"CompilerGui.py\", line 259, in \ndone = ttk.Button(window, text=\"Compile\", command=lambda:finish(texts,\n  window, search_folder))\nFile \"CompilerGui.py\", line 210, in finish cb.the_main(q_list, values)\nFile \"CompilerBase.py\", line 323, in the_main\nfile_written = write_docx(values_dict, file_to_write)\nFile \"CompilerBase.py\", line 100, in write_docx\nmy_docx = docx.Document()\nFile \"site-packages\\docx\\api.py\", line 25, in Document\nFile \"site-packages\\docx\\opc\\package.py\", line 128, in open\nFile \"site-packages\\docx\\opc\\pkgreader.py\", line 32, in from_file\nFile \"site-packages\\docx\\opc\\phys_pkg.py\", line 31, in new\ndocx.opc.exceptions.PackageNotFoundError: Package not found at\n  'C:\\Users\\LENOVO\\AppData\\Local\\Temp_MEI92522\\docx\\templates\\default.docx'","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":500,"Q_Id":55506179,"Users Score":0,"Answer":"Another fairly simple fix would be to just copy the default.docx into your app directory, change my_docx = docx.Document() to my_docx = docx.Document(docx='default.docx'), and add datas=[('default.docx', '.')] to your .spec file.","Q_Score":1,"Tags":"python,pyinstaller,python-docx","A_Id":55540238,"CreationDate":"2019-04-04T00:34:00.000","Title":"How to fix PackageNotFoundError for exe files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a spreadsheet with 10 columns and 727 obs. Col 5 is 0\/1 whether a student is economically disadvantaged or not. I need to find the mean of Col 6 (test score) based on whether the student is economically disadvantaged or not. Help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":16,"Q_Id":55506207,"Users Score":0,"Answer":"If I understand your question correctly: \n\n\nFirst you need to import your spreadsheet into python with csv module. \nThen you need \"for\" loop to sum all your col per person. \nCalculate mean of each obs. \nIf result greater than half of total number, get to your student 1 ;else get them 0 .","Q_Score":0,"Tags":"python","A_Id":55506296,"CreationDate":"2019-04-04T00:37:00.000","Title":"Need to find the MEAN of Col 6 based on the value of Col 5 (Col 5 is 0\/1)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How are you today?\nI'm a newbie in Python. I'm working with SQL server 2014 and Python 3.7. So, my issue is: When any change occurs in a table on DB, I want to receive a message (or event, or something like that) on my server (Web API - if you like this name). \nI don't know how to do that with Python. \nI have an practice (an exp. maybe). I worked with C# and SQL Server, and in this case, I used \"SQL Dependency\" method in C# to solve that. It's really good!\nHave something like that in Python? Many thank for any idea, please!\nThank you so much.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":681,"Q_Id":55507064,"Users Score":0,"Answer":"I do not know many things about SQL. But I guess there are tools for SQL to detect those changes. And then you could create an everlasting loop thread using multithreading package to capture that change. (Remember to use time.sleep() to block your thread so that It wouldn't occupy the CPU for too long.) Once you capture the change, you could call the function that you want to use. (Actually, you could design a simple event engine to do that). I am a newbie in Computer Science and I hope my answer is correct and helpful. :)","Q_Score":0,"Tags":"python,sql-server,change-tracking","A_Id":55507101,"CreationDate":"2019-04-04T02:39:00.000","Title":"Tracking any change in an table on SQL Server With Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a project where I have to make a graph out of words of a text. I want to replace similar meaning words with a common synonym. For example, if a text has the occurences of 'Murder', 'Kill' and 'slay'. I want to replace all of these with a common synonym (which may have a little different meaning) like 'Kill'. How can I do this in Python?\nI have tried NLTK synsets, but could not come up with a way so that all similar words are replaced with synonyms.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":475,"Q_Id":55507087,"Users Score":0,"Answer":"It's a simple machine learning problem. Use any clustering algorithm.\nConvert words to vectors, and group similar words based on their vector plot.\nSelect one word from each cluster to replace with its similar words.","Q_Score":0,"Tags":"python,synonym","A_Id":55507338,"CreationDate":"2019-04-04T02:45:00.000","Title":"How to replace similar meaning words with a common synonym in a text","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need some help with some Json serialisation. I need to print only the keys that have detected:true.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":519,"Q_Id":55509537,"Users Score":0,"Answer":"You can use filter function.\nFor example json is\nexample_json = [\n   {\n      \"detected\": True\n   },\n   {\n      \"detected\": False\n   }\n]\n\nlist(filter(lambda x: (x[\"detected\"] == True), example_json))","Q_Score":0,"Tags":"python,json","A_Id":55510203,"CreationDate":"2019-04-04T06:52:00.000","Title":"Json Dumps Select only keys with detected: true","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using ubuntu 16 version and running Odoo erp system 12.0 version.\nOn my application log file i see information says \"virtual real time limit (178\/120s) reached\".\nWhat exactly it means & what damage it can cause to my application?\nAlso how i can increase the virtual real time limit?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":10514,"Q_Id":55510726,"Users Score":5,"Answer":"Open your config file and just add below parameter :\n--limit-time-real=100000","Q_Score":9,"Tags":"python,ubuntu,odoo","A_Id":59282499,"CreationDate":"2019-04-04T07:59:00.000","Title":"virtual real time limit (178\/120s) reached","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I currently have a program that does work on a large set of data, at one point in the process it sends the data to a server for more work to be done, then my program looks for the completed data periodically, sleeping if it is not ready and repeating until it fetches the data, then continuing to do work locally.\nInstead of polling repeatedly until the external server has finished, it has the ability to send a simple http post to an address I designate once the work has finished. \nSo I assume I need flask running at an address that can receive the notification, but I'm unsure of the best way to incorporate flask into the original program. I am thinking just to split my program into 2 parts. \npart1.py\ndoes work --> send to external server\npart1 ends\nflask server.py\nreceives data --> spawns part2.py with received data \nThe original program uses multiprocessing pools to offset waiting for the server responses, but with using flask, can I just repeatedly spawn new instances of part2 to do work on the data as it is received?\nAm I doing this all completely wrong, I've just put this together with some googling and feel out of my depth","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":55511836,"Users Score":0,"Answer":"U can use broker with a message queue implemented ex. Celery + Redis or RabbitMQ. Then, when the other server finishes doing whatever it has to do with the data it can produce an event, and the first server will receive a notification.","Q_Score":0,"Tags":"python,asynchronous,flask","A_Id":55511889,"CreationDate":"2019-04-04T08:59:00.000","Title":"What is the proper way to have an asychronous python script wait for a response from a server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to import xml.dom.minidom in order to read and edit an xml file but am getting an error.\nimport xml.dom.minidom\nI get the error message:\nModuleNotFoundError: No module named 'xml.dom'; 'xml' is not a package","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":253,"Q_Id":55513629,"Users Score":2,"Answer":"This may be due to a file name issue (such as xml.py). There may be a conflict with the file name when compiling. Rename it to solve the issue.","Q_Score":0,"Tags":"python,xml","A_Id":55513753,"CreationDate":"2019-04-04T10:27:00.000","Title":"How can I import xml.dom.mindom","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering how to handle multiple major versions of a dependency library.\nI have an open source library, Foo, at an early release stage. The library is a wrapper around another open source library, Bar. Bar has just launched a new major version. Foo currently only supports the previous version. As I'm guessing that a lot of people will be very slow to convert from the previous major version of Bar to the new major version, I'm reluctant to switch to the new version myself. \nHow is this best handled? As I see it I have these options\n\nSwitch to the new major version, potentially denying people on the old version.\nKeep going with the old version, potentially denying people on the new version.\nHave two different branches, updating both branches for all new features. Not sure how this works with PyPi. Wouldn't I have to release at different version numbers each time?\nSeparate the repository into two parts. Don't really want to do this.\n\nThe ideal solution for me would be to have the same code base, where I could have some sort of C\/C++ macro-like thing where if the version is new, use new_bar_function, else use old_bar_function. When installing the library from PyPi, the already installed version of the major version dictates which version is used. If no version is installed, install the newest. \nWould much appreciate some pointers.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":558,"Q_Id":55519636,"Users Score":1,"Answer":"Have two different branches, updating both branches for all new features. Not sure how this works with PyPI. Wouldn't I have to release at different version numbers each time?\n\nYes, you could have a 1.x release (that supports the old version) and a 2.x release (that supports the new version) and release both simultaneously. This is a common pattern for packages that want to introduce a breaking change, but still want to continue maintaining the previous release as well.","Q_Score":1,"Tags":"python,pip,dependencies,wrapper,pypi","A_Id":55519997,"CreationDate":"2019-04-04T15:23:00.000","Title":"How to handle multiple major versions of dependency","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In a machine-oriented deployment, usually, people would use gunicorn to spin up a number of workers to serve incoming requests. (yes, the worker_class would further define the behavior within the worker process)\nWhen deploying in a Kubernetes cluster, do we still gunicorn (or to be exact, do we still need multiprocess deployment)?\nBasically, each running container is a process (in the one-container-per-pod config). Multiple pods running behind a service is already equivalent to what gunicorn has to offer. In other words, rely on Kubernetes service instead of gunicorn\nIs gunicorn still needed?\nYes, a pod is not exactly the same as a process (some overhead in each pod for the companion container), but other than that, anything else we may miss from not having gunicorn?\nEdited\nClarification: yes, still need gunicorn or other wsgi http server to run the python app. My question is really about the multiprocess aspect (as the multiprocess\/gunicor in the title).","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":6076,"Q_Id":55524904,"Users Score":1,"Answer":"It really depends on your use-cases. There is no right on wrong here if one solution suits you better than the other.\nWe have a similar use-case.\nWe are running about 30 replica's of the same service. Each pod runs 1 container, which again runs 50 duplicate services.\nWe could have ended up with 1500 pods running one service, but we've tested that the performance vs. required resources was much better when running only 30 replicas, which runs 50 services per replica.\nThe only thing we are doing extra is monitoring those 50 services per pod, so if one of them stops, it's being restarted. If all of them have some error, we run a healthcheck on the pod, and the pod is recreated.","Q_Score":17,"Tags":"kubernetes,multiprocessing,gunicorn,python-multiprocessing","A_Id":67640118,"CreationDate":"2019-04-04T21:06:00.000","Title":"In Kubernetes, do we still need multiprocess\/gunicorn?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"In a machine-oriented deployment, usually, people would use gunicorn to spin up a number of workers to serve incoming requests. (yes, the worker_class would further define the behavior within the worker process)\nWhen deploying in a Kubernetes cluster, do we still gunicorn (or to be exact, do we still need multiprocess deployment)?\nBasically, each running container is a process (in the one-container-per-pod config). Multiple pods running behind a service is already equivalent to what gunicorn has to offer. In other words, rely on Kubernetes service instead of gunicorn\nIs gunicorn still needed?\nYes, a pod is not exactly the same as a process (some overhead in each pod for the companion container), but other than that, anything else we may miss from not having gunicorn?\nEdited\nClarification: yes, still need gunicorn or other wsgi http server to run the python app. My question is really about the multiprocess aspect (as the multiprocess\/gunicor in the title).","AnswerCount":4,"Available Count":2,"Score":0.2449186624,"is_accepted":false,"ViewCount":6076,"Q_Id":55524904,"Users Score":5,"Answer":"Gunicorn is used to serve WSGI(Web Server Gateway Interface) applications so it is a server and not just multiprocess orchestration tool. Kubernetes on the hand is an orchestration tool that helps manage the infrastucture. It does not speak HTTP nor does it know anything about WSGI specs. \nIn other words, you can't run WSGI applications on bare kubernetes pods, you will still need a WSGI server liike Gunicorn, uWSGI, etc to serve the application.","Q_Score":17,"Tags":"kubernetes,multiprocessing,gunicorn,python-multiprocessing","A_Id":55525082,"CreationDate":"2019-04-04T21:06:00.000","Title":"In Kubernetes, do we still need multiprocess\/gunicorn?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I've been getting a lot of spam emails from various colleges. I wrote a simple Python program to go through my emails, and find all the ones whose sender ends in .edu.\nThen, to delete it, I though I was supposed to add the \\\\Deleted flag to those emails using: Gmail.store(id, \"+FLAGS\", \"\\\\Deleted\"). This did not work, and some of them didn't even disappear from the inbox. \nAfter more research, I found that instead I had to use Gmail.store(id, \"+X-GM-LABELS\", \"\\\\Trash\"). \nSo I updated the program to use that, but now it doesn't see any of the emails that I previously added the \\\\Deleted flag to.\nIs there any way I can reset all those emails and then trash them afterward?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":371,"Q_Id":55525410,"Users Score":1,"Answer":"They should be in your All Mail folder. Use the WebUI and search for them and trash them, or select the \"[Gmail]\\All Mail\" folder (watch out for localization, this can change name for non-English users).","Q_Score":0,"Tags":"python,email,gmail,imaplib","A_Id":55544626,"CreationDate":"2019-04-04T21:47:00.000","Title":"Python imaplib recover emails with \\\\Deleted flag and move to trash","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":"Starting Python BDD, using Behave in pycharm 2019.1 pro. Just started learning Python and Pycharm IDE.\nUsed a basic example to run a feature file with one scenario in it.\nWhen I run using Pycharm Terminal, the scenario runs fine. When I do the same while right clicking on the Scenario in the editor, I get the message at run time, \"No tests were found\". \nI have searched on SO but responses are for unit tests not for BDD tests. \nI went into the run\/debug configuration and have tried setup working directory to my feature folder or the project folder, but still the same issue.\nI previously had python 3.7 but now using python 3.6 (both installed) and the interpreter is set to behave","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":775,"Q_Id":55526733,"Users Score":0,"Answer":"I got it working but uninstalling pycharm, python 3.6 and python 3.7 folders completely (includuing hidden folders from private @ root) from my machine, fresh install pycharm with python 3.6 and then behave. Tests work now. \nNo idea exactly why it happened except that it could be some conflicting config due to different python versions.","Q_Score":1,"Tags":"python,pycharm,bdd","A_Id":55546604,"CreationDate":"2019-04-05T00:37:00.000","Title":"\"No Tests were found\" in Pycharm Professional 2019.1 using Behave","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python and just trying to learn and find better ways to write code. I want to create a custom class for logging and use package logging inside it. I want the function in this class to be reusable and do my logging from other scripts rather than writing custom code in each and every scripts. Is there a good link you guys can share? Is this the right way to handle logging? I just want to avoid writing the same code in every script if I can reuse it from one module. \nI would highly appreciate any reply.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":903,"Q_Id":55527139,"Users Score":1,"Answer":"It's indeed a good idea to keep all your logging configuration (formatters, level, handlers) in one place.\n\ncreate a class wrapping a custom logger with your configuration\nexpose methods for logging with different levels\nimport this class wherever you want\ncreate an instance of this class to log where you want\n\nTo make sure all you custom logging objects have the same config, you should make logging class own the configuration.\nI don't think there's any links I can share for the whole thing but you can find links for the individual details I mentioned easily enough.","Q_Score":1,"Tags":"python,python-3.x,python-2.7","A_Id":55527254,"CreationDate":"2019-04-05T01:39:00.000","Title":"Common logging module in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use a python script (docker container) to write to Redis db (docker container). The script main objective is to write to Redis db. But there are also other scripts that write to the same Redis db. So where should i make the connection to redis db inside a function in script or globally ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":55528464,"Users Score":0,"Answer":"If your python project is long running (e.g. a web app or a daemon script that runs forever) and making repeated calls, open a single connection and reuse it.\nIf your python code is short lived script (e.g. it runs for a few seconds then exits) then it doesn't matter so much. Even then, if it's making multiple reads\/writes it's better to open one connection and reuse it in the script.\nBy the wording of your question, it sounds as though you might be thinking of opening the connection outside the script? I'm not really sure where you're going with that, so I can't answer there.","Q_Score":0,"Tags":"python,redis","A_Id":55528560,"CreationDate":"2019-04-05T04:55:00.000","Title":"Is it a good practice to open connection to Redis database inside the function that writes to it or outside globally?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I ran \"pydoc file.seek\" and this line from documentation puzzled me. \"Note that not all file objects are seekable.\" As far as I understand, \"not seekable\" means \"you can't use seek, even if you have access permission\". I don't understand, how is it even possible? How can there be a file objects that can't be seekable?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":225,"Q_Id":55528974,"Users Score":1,"Answer":"A file on disk is always seekable, but the file handle abstraction does not apply only to files on a local disk. Unidirectional information streams like pipes, network sockets etc are only there for you as long as you keep them buffered or in memory; unless you have saved the information yourself, you cannot go back and refetch a client's response to you from five minutes ago.","Q_Score":0,"Tags":"python,file,seek","A_Id":55529085,"CreationDate":"2019-04-05T05:52:00.000","Title":"How can it be that \"not all file objects are seekable\", according to pydoc?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to convert s3 bucket video file resolutions to other resolutions and store it back to s3.\nI know we can use ffmpeg locally to change the resolution.\nCan we use ffmpeg to convert s3 files and store it back using Django?\nI am puzzled as from where to start and what should be the process.\nWhether I should have the video file from s3 bucket in buffer and then convert it using ffmpeg and then upload it back to s3.\nOr is there anyway to do it directly without having to keep it in buffer.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":783,"Q_Id":55532567,"Users Score":3,"Answer":"You can break the problem into 3 parts:\n\nGet the file from s3: use boto3 & the AWS APIs to download the file\nConvert the file locally: ffmpeg has got you covered here. It'll generate a new file\nUpload the file back to s3: use boto3 again\n\nThis is fairly simple and robust for a script. \nNow if you want to optimize you can try using something like s3fs to mount your s3 bucket to local & do the conversion","Q_Score":0,"Tags":"python,django,amazon-s3,ffmpeg,django-rest-framework","A_Id":55532637,"CreationDate":"2019-04-05T09:45:00.000","Title":"Convert s3 video files resolution and store it back to s3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Im beginner and this is my first steps.\nIm already learning about different Neural Network architecture and i have a question:\nWhich model i should choice for Rasberry PI \/ android?\nIm already tried \"ResNet\" with 98x98 resolution of images and that model requires almost full power of my PC. Exactly:\nModel takes 2 GB of video card memory, 1.4~2 GB of RAM.\nThis model is not suitable for the android \/ Rasberry (low power).\nWhich model i should choice for my task?\nP.S I expect at least 5~10 FPS on Rasberry and 10~15 on Android.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":78,"Q_Id":55533997,"Users Score":2,"Answer":"TinyYOLO is a smaller version of the original YOLO network. You could try that one.","Q_Score":1,"Tags":"python,machine-learning,neural-network","A_Id":55534189,"CreationDate":"2019-04-05T11:04:00.000","Title":"\u0421hoosing the right NN model (speed \/ performance)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im beginner and this is my first steps.\nIm already learning about different Neural Network architecture and i have a question:\nWhich model i should choice for Rasberry PI \/ android?\nIm already tried \"ResNet\" with 98x98 resolution of images and that model requires almost full power of my PC. Exactly:\nModel takes 2 GB of video card memory, 1.4~2 GB of RAM.\nThis model is not suitable for the android \/ Rasberry (low power).\nWhich model i should choice for my task?\nP.S I expect at least 5~10 FPS on Rasberry and 10~15 on Android.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":55533997,"Users Score":3,"Answer":"Object Detection on Raspberry Pi with 5-10FPS is highly unrealistic.\nYou can have a look at YOLO or SSD, for example YOLO has also a smaller implementation which can run on RPI but you will be happy with 1FPS.","Q_Score":1,"Tags":"python,machine-learning,neural-network","A_Id":55534144,"CreationDate":"2019-04-05T11:04:00.000","Title":"\u0421hoosing the right NN model (speed \/ performance)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Like if i want paragraph to be on monday. Another paragraph on tuesday, Wednesday and whole week. Please help to advice me place to get informantion! Thank you.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":55538285,"Users Score":0,"Answer":"regexp on url\nroute in view by the requested url to a certain path","Q_Score":0,"Tags":"python,django","A_Id":55538379,"CreationDate":"2019-04-05T14:59:00.000","Title":"Is there a way to display a view by date?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having trouble updating python on Git Bash\nwhen I run python --version on git bash it still shows me 2.7 The thing is that when I run python --version in the anaconda prompt it shows me the updated version 3.7.3\nHow can I make it so that when I run python --version on Git Bash it will show me the latest version \nThanks!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2602,"Q_Id":55539344,"Users Score":2,"Answer":"You can't, or rather you really shouldn't. Linux subsystems expect python to resolve to Python2, and since Git Bash is (very shallowly) emulating a Linux machine under the hood of its bash shell, it would be a Very Bad Idea to change that expectation.\nHowever, python3 should launch your Python 3 interpreter.","Q_Score":1,"Tags":"python,anaconda,conda,git-bash,python-3.7","A_Id":55539411,"CreationDate":"2019-04-05T15:58:00.000","Title":"How can I update python on Git Bash?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have successfully used Q-learning to solve some classic reinforcement learning environments from OpenAI Gym (i.e. Taxi, CartPole). These environments allow for a single action to be taken at each time step. However I cannot find a way to solve problems where multiple actions are taken simultaneously at each time step. For example in the Roboschool Reacher environment, 2 torque values - one for each axis - must be specify at each time step. The problem is that the Q matrix is built from (state, action) pairs. However, if more than one action are taken simultaneously, it is not straightforward to build the Q matrix.\nThe book \"Deep Reinforcement Learning Hands-On\" by Maxim Lapan mentions this but does not give a clear answer, see quotation below.\n\nOf course, we're not limited to a single action to perform, and the environment could have multiple actions, such as pushing multiple buttons simultaneously or steering the wheel and pressing two pedals (brake and accelerator). To support such cases, Gym defines a special container class that allows the nesting of several action spaces into one unified action.\n\nDoes anybody know how to deal with multiple actions in Q learning?\nPS: I'm not talking about the issue \"continuous vs discrete action space\", which can be tackled with DDPG.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":937,"Q_Id":55539820,"Users Score":2,"Answer":"You can take one of two approaches - depend on the problem:\n\nThink of the set of actions you need to pass to the environment as independent and make the network output actions values for each one (make softmax separately) - so if you need to pass two actions, the network will have two heads, one for each axis.\nThink of them as dependent and look on the Cartesian product of the sets of actions, and then make the network to output value for each product - so if you have two actions that you need to pass and 5 options for each, the size of output layer will be 2*5=10, and you just use softmax on that.","Q_Score":4,"Tags":"python,reinforcement-learning,openai-gym,q-learning","A_Id":55540865,"CreationDate":"2019-04-05T16:28:00.000","Title":"How do apply Q-learning to an OpenAI-gym environment where multiple actions are taken at each time step?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script that generates logs based on an equation. Initially I had no equation so it printed out \u201c0\u201d. I run the script through my IDE, the equation works. I compiled with PyInstaller, run it, it\u2019s all the same, except the log is back to printing \u201c0\u201d. \nAny idea what the cause could be?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":104,"Q_Id":55540642,"Users Score":1,"Answer":"I just spent quite some time struggling with the same problem, but found a solution. I know it's a bit late, but I'm leaving this for people who may find this useful in the future.\nI have just found out that I had two versions of the folder containing my script: one of them was the one I was actively working with, and the other one was an outdated version whose existence I didn't even remember. Turns out PyInstaller was importing the outdated version instead of the one I was working with.\nI figured this out by looking at the .toc files inside the build folder. I searched the 'Analysis-00.toc' file for my script, and found out that it was importing the wrong one. I deleted the wrong outdated script, cleaned all the pyinstaller files and created a new build. After that, it worked as it should.","Q_Score":1,"Tags":"python,pyinstaller","A_Id":61148214,"CreationDate":"2019-04-05T17:31:00.000","Title":"PyInstaller using old non-existant code that\u2019s been changed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For the past several days, I have been trying to get the following to work in regards to building an APK from a Python application: 1. Briefcase, 2. P4A, 3. Buildozer, 4. Chaquopy.\nYet with hardly any luck, I've only gotten as far on all of them to tell me I've installed Java incorrectly. I've tried installation in a variety of different ways and to no avail. \nDoes anyone have any suggestions as to what to use to package my Python code into an APK? All the tools I've used so far are obsolete or have limited and varying documentation.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":33,"Q_Id":55545682,"Users Score":-1,"Answer":"The tools you list are the best ones currently available, and none of them are obsolete. If you need help using one of them, you should ask a question giving details of exactly what happened, either here on StackOverflow, or on the project's issue tracker.","Q_Score":0,"Tags":"android,python,android-studio,apk","A_Id":55589845,"CreationDate":"2019-04-06T03:41:00.000","Title":"Updated Software for Python APKs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"476\/5000\nrstudio generates error when running R code with python code.  At first the code worked very well but in the second installation it started to generate faults. Here is the link of the code in case you want to play #https: \/\/www.r-bloggers.com\/r-and-python-using-reticulate-to-get-the-best-of-both-worlds\/\n. My laptop is hp 4 gigs of ram and 500 mb of hard disk.\nI would greatly appreciate who can explain the failure and how to solve it.\nI have reinstalled anaconda last version twice.\n\nlibrary(reticulate)\n  use_python(\"\/usr\/local\/bin\/python\")\nuse_virtualenv(\"r-reticulate\")\nos  <- import(\"os\")\n  Error: lexical error: invalid char in json text.\n                                         WARNING: The conda.compat modul\n                       (right here) ------^\n  os$listdir(\".\")\n  Error: object 'os' not found\n  py_config()\n  Error: lexical error: invalid char in json text.\n                                         WARNING: The conda.compat modul\n                       (right here) ------^","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1132,"Q_Id":55545861,"Users Score":0,"Answer":"I had the same problem. I solved the problem by installing an older version of conda.\nIn anaconda promt\nconda install conda = 4.1.6","Q_Score":2,"Tags":"anaconda,python-3.7","A_Id":55590882,"CreationDate":"2019-04-06T04:19:00.000","Title":"Fault in reticulate in rstudio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recent upgraded web2py and starting using username=True, the form returned via auth\/profile no longer contains the user email address.\nHow can a user change email address under the standard api?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":93,"Q_Id":55547054,"Users Score":1,"Answer":"With or without username=True, the email address is not editable via the current Auth API (this was changed about a year ago, presumably for security reasons). For now, you'll have to implement your own email change functionality. For extra security, you might want to require password verification, and maybe send a verification email to the new address (and possibly a notification to the old address upon completion of the change).","Q_Score":1,"Tags":"python,web2py","A_Id":55550260,"CreationDate":"2019-04-06T08:00:00.000","Title":"How to change email address of user in web2py using standard auth api with username=True","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have just learned how to work with DataFrame in python's Pandas through an online course and there is this question:\n\"What is the difference between deleting and popping column?\"\nI thought they work the same way but most of the answers are \n\"You can store a popped column\"\nWhat does that mean?\nI saw from the documentation and it tells me that there's only a deleting a single column use out of the pop function so Im kind of confused here","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":939,"Q_Id":55548010,"Users Score":0,"Answer":"The difference between deleting and popping a column is that pop will return the deleted column back to you while del method won't.","Q_Score":1,"Tags":"python,python-3.x,pandas,dataframe,del","A_Id":61877221,"CreationDate":"2019-04-06T10:08:00.000","Title":"Is there any difference between del and pop for column in python pandas dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to find a way to reverse the bits of each character in a string using python.\nFor example, if my first character was J, this is ASCII 0x4a or 0b01001010, so would be reversed to 0x52 or 0b01010010. If my second character was K, this is 0b01001011, so would be reversed to 0xd2 or 0b11010010, etc.\nThe end result should be returned as a string.\nSpeed is my number one priority here, so I am looking for a fast way to accomplish this.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":105,"Q_Id":55550259,"Users Score":3,"Answer":"If speed is your goal and you are working with ASCII so you only have 256 8-bit values to handle, calculate the reversed-byte values beforehand and put them in a bytearray, then look them up by indexing into the bytearray.","Q_Score":1,"Tags":"python","A_Id":55550356,"CreationDate":"2019-04-06T14:51:00.000","Title":"How to reverse the bits of each character in a string using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to build chromium on Windows10, a python error occurs,\nit says \"ImportError: No module named win32file\". How to savle this?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":13868,"Q_Id":55551188,"Users Score":20,"Answer":"My solution is: python -m pip install pywin32.\nThen you will see module win32file in the path of C:\/python27\/Lib\/site-packages\/win32file.pyd","Q_Score":11,"Tags":"python-2.7","A_Id":55551200,"CreationDate":"2019-04-06T16:40:00.000","Title":"python ImportError: No module named win32file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using eval and pybrain to make neural networks. Here's it stripped down. Using python 3.6\n\n\n    from pybrain import *\n\n    numnn = 100\n\n    eval(\"neuralNetwork\" + chr(numnn) + \" = buildNetwork(2, 3, 1, bias=True)\")","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":127,"Q_Id":55552402,"Users Score":3,"Answer":"eval evaluates expressions.  Assignment in Python is not an expression, it's a statement.\nBut you don't need this anyway.  Make a list or dict to hold all of your values.","Q_Score":0,"Tags":"python","A_Id":55552428,"CreationDate":"2019-04-06T18:52:00.000","Title":"Python - Error at equals sign for no reason?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got a bit lost in the boto3 API details and struggle to find an example to access an S3 bucket using python. I need to use an existing pem file rather than the typical access and secret key. Works fine using an ftp client but I need to get it running also with python.\nAnyone that can point me in the right direction (or suggest alternatives using python)","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1571,"Q_Id":55552553,"Users Score":3,"Answer":"This is not possible.\nThe types of authentication used on AWS are:\n\nUsername and password associated with an IAM User, used to login to the web management console.\nAccess Key and Secret Key associated with an IAM User, used to make API calls to AWS services\nPrivate Key (PPK\/PEM) used to login to Linux instances.\n\nPrivate Keys are used to login to an operating system and are unrelated to AWS. They are a standard means of accessing Linux systems and identify users defined on the computer itself rather than on AWS.\nAPI calls to AWS require the Access Key and Secret Key and have no relationship to PPK\/PEM keys.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-s3","A_Id":55554101,"CreationDate":"2019-04-06T19:10:00.000","Title":"How do I connect to an Amazon S3 bucket with a pem file using python (boto3)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Setting up to start python for data analytics and want to install python 3.6 in Ubuntu 18.0 . Shall i run both version in parallel or overwrite 2.7 and how ? I am getting ambiguous methods when searched up.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":55552885,"Users Score":0,"Answer":"Try pyenv and\/or pipenv . Both are excellent tools to maintain local python installations.","Q_Score":0,"Tags":"python-3.x,python-2.7","A_Id":55552911,"CreationDate":"2019-04-06T19:50:00.000","Title":"How to install python3.6 in parallel with python 2.7 in Ubuntu 18","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was trying to install Python3.7 package inside visual studio however I keep getting \n\"pip is configured with locations that require TLS\/SSL, however the SSL module in Python is not available.\" issues, no matter what package.\nThe OS is windows I also tried to use CMD to pip, it seems package can be successfully installed, but it does not reflect in Visual Studio.  Tried reinstall Python component in Visual Studio but with no luck. \nThe visual studio does have both 3.6 and 3.7 and I have Anaconda. Install package works with 3.6 in VS but not for 3.7.  I really don't know where else to look for problem, could be some path configuration problem, environment variable problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1417,"Q_Id":55553916,"Users Score":0,"Answer":"I experienced similar symptoms and was able to find a suitable workaround.\nBackground:\nFresh install of Visual Studio 2019 in May 2019, no previous install of anaconda, etc. I could add pypi packages in 3.6 conda environments, but not 3.7. Attempts to install from both VS2019 and powershell would result in the ssl module error you describe. \nWorkaround: I was able to work around this by running pip install from the conda command prompt. \nTo do this, I navigated to the conda folder, which for me was at: \nC:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\Common7\\IDE\\Extensions\\Microsoft\\Python\\Miniconda\\Miniconda3-x64\\Scripts.\nI could run conda.exe but it errors out saying the environment isn't set up. If you modify your path to include the above directory plus several other parent and subs (miniconda3-x64 root, library, library\/bin; condabin; maybe others) the error message will actually give you helpful instructions to run conda init cmd.exe or something similar to prepare your environment. You can run this for powershell as well. I ran this as admin. Close your shell and reopen, and then you can run conda activate <environment>. Once in the conda shell, I could run pip install <package> and it all worked fine, and was reflected in VS2019 view immediately. \nTL;DR: Navigate to the folder where conda.exe lives; run conda init cmd.exe as admin; reopen cmd.exe; run conda activate <environment name>; run pip install <package name>; run conda deactivate; return to VS2019, verify, rejoice.","Q_Score":0,"Tags":"python,visual-studio","A_Id":56104537,"CreationDate":"2019-04-06T22:14:00.000","Title":"Visual Studio 2019 install Python3.7 Package, geting TLS\/SSL problem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As it is said that the data in a variable is changeable in a program, on the other hand, in data structure the strings, for example, are immutable. So here it is a contradiction between variable and data structure. Can anyone help me in solving this matter?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":55555549,"Users Score":0,"Answer":"There is no contradiction. A variable isn't the value. To say that an object is mutable means that it exposes mutator methods. Variables are mutable when they can be reassigned.","Q_Score":0,"Tags":"python","A_Id":55555845,"CreationDate":"2019-04-07T04:12:00.000","Title":"Why is there contradiction in being mutable and immutable variable and string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I often encounter elements which I cannot right click to inspect their xpath or css. \nI want to ask what other ways exist to click on those elements ?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1061,"Q_Id":55556644,"Users Score":0,"Answer":"Control + Shift + C or F12 will open the dev tools for you, you can then click on the cursor mode on your browser.","Q_Score":1,"Tags":"python,selenium,google-chrome,xpath,google-chrome-devtools","A_Id":55558250,"CreationDate":"2019-04-07T07:32:00.000","Title":"How to interact with elements those cannot be inspected through css\/xpath within google-chrome-devtools","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I often encounter elements which I cannot right click to inspect their xpath or css. \nI want to ask what other ways exist to click on those elements ?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1061,"Q_Id":55556644,"Users Score":1,"Answer":"You can use Ctrl + Shift + C, it will open the devtools with selecting an element to inspect enabled. Just move the mouse cursor to the element and click, it will scroll the html view in devtools to the correct place.\nAlternatively, you can press F12 and toggle the selecting an element to inspect button (top left corner of the devtools).","Q_Score":1,"Tags":"python,selenium,google-chrome,xpath,google-chrome-devtools","A_Id":55558180,"CreationDate":"2019-04-07T07:32:00.000","Title":"How to interact with elements those cannot be inspected through css\/xpath within google-chrome-devtools","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I often encounter elements which I cannot right click to inspect their xpath or css. \nI want to ask what other ways exist to click on those elements ?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1061,"Q_Id":55556644,"Users Score":0,"Answer":"If you want to get elements locator but the right click doesn't work then try the following. \nFirst, Open the dev tools window by pressing Ctrl+Shift+I. \nIf that doesn't work then first open the dev tool then load the page.   \nAfter opening the dev tools click on \"select element\" tool, the printer icon at the left of the dev tool. You can directly get this tool by pressing Ctrl+Shift+C.\nThen hover on the element that you want to get the locator. The element will be selected in the DOM in the elements tab. Right click on the elements in the DOM. \nThen from the context menu go to copy -> copy selector for CSS selector or copy XPath for XPath. \nNow you have got the locator of that element in the clipboard.","Q_Score":1,"Tags":"python,selenium,google-chrome,xpath,google-chrome-devtools","A_Id":55556724,"CreationDate":"2019-04-07T07:32:00.000","Title":"How to interact with elements those cannot be inspected through css\/xpath within google-chrome-devtools","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"please, how do I display the month in the form? example:\n07\/04\/2019 i want to change it in 07 april, 2019 \nThank you in advance","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":77,"Q_Id":55556852,"Users Score":2,"Answer":"Try with following steps:\n\nGo to Translations > Languages\nOpen record with your current language.\nEdit date format with %d %A, %Y","Q_Score":1,"Tags":"python,odoo","A_Id":55556884,"CreationDate":"2019-04-07T08:00:00.000","Title":"how to display the month in from view ? (Odoo11)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The COCO dataset is very large for me to upload it to google colab. Is there any way I can directly download the dataset to google colab?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":10788,"Q_Id":55556965,"Users Score":1,"Answer":"Using drive is better for further use. Also unzip the zip with using colab ( !unzip ) because using zip extractor on drive takes longer. I've tried :D","Q_Score":5,"Tags":"python,computer-vision,google-colaboratory,semantic-segmentation","A_Id":66080521,"CreationDate":"2019-04-07T08:18:00.000","Title":"Importing COCO datasets to google colaboratory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build python 64 bit from source on solaris10.\nAfter searching in net for a while. I tried using CFLAGS=-m64 LDFLAGS=-m64 while executing .\/configure.But getting errors like wrong ELFCLASS32\nTried the below \n.\/configure  CFLAGS=-m64 LDFLAGS=-m64\nBut no luck. And make is throwing errror like  \"make: Fatal error: Command failed for target `libinstall'\"\nI am suspecting this is regarding gcc\nTIA","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":210,"Q_Id":55557223,"Users Score":1,"Answer":"The problem is you are linking your 64-bit program with 32-bit libraries. That is what the WRONGELFCLASS error is all about.\nUnfortunately, the default on Solaris tends to be to generate 32-bit libraries. Make sure you generate 64-bit libraries with -m64 and use the file command on the generated .o files to verify they are 64-bit libraries.  The 64-bit libraries are in subdirectory 64\/ for each library directory (such as \/usr\/lib\/64\/).","Q_Score":1,"Tags":"python,gcc,x86-64","A_Id":55858182,"CreationDate":"2019-04-07T08:53:00.000","Title":"How to build 64 bit python from source on solaris","Data Science and Machine Learning":0,"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 migrating my project to Python 3 (2to3-3.7 -w -f print *), I observed that a lot of (but not all) print statements became print((...)), so these statements now print tuples instead of performing the expected behavior. I gather that if I'd used -p, I'd be in a better place right now because from __future__ import print_function is at the top of every affected module.\nI'm thinking about trying to use sed to fix this, but before I break my teeth on that, I thought I'd see if anyone else has dealt with this before. Is there a 2to3 feature to clean this up?\nI do use version control (git) and have commits immediately before and after (as well as the .bak files 2to3 creates), but I'm not sure how to isolate the changes I've made from the print situations.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":4214,"Q_Id":55559825,"Users Score":7,"Answer":"If your code already has print() functions you can use the -x print argument to 2to3 to skip the conversion.","Q_Score":15,"Tags":"python-3.x,sed,python-2to3","A_Id":57280672,"CreationDate":"2019-04-07T14:08:00.000","Title":"How to fix print((double parentheses)) after 2to3 conversion?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to backup a remote directory with a lot of files, and because of that, I need to compress it before downloading it. I can access this folder through SSH or FTP. The host is running on Linux.\nI have covered the downloading part with aioftp. I was using paramiko and tar Linux command for compressing the directory in the remote host, but instead, I want to use Python modules (from standard library or not) and avoid using Linux commands. Maybe a combination of paramiko to open the session, urllib to create the remote object and tarfile to compress it can make the job, but I haven't found the way.\nIn the end, I want a directory-backup.tar.gz in my localhost.\nHow can I accomplish that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":565,"Q_Id":55564316,"Users Score":1,"Answer":"You have to compress the directory using tools on the server. \nUsing local Python code makes no sense. To compress the files locally, you would have to download the uncompressed files, compress them (with your local Python code), and upload the compressed archive, only to download it then again. That defies the purpose of the compression, right?\nIf you want to use Python code for compression, you would have to run the Python code on the server. Either by uploading the script and executing it on the server or by feeding the code to remote python process. I do not see much advantage of doing that over using ready-made tar command.","Q_Score":1,"Tags":"python,ssh,urllib,paramiko,tarfile","A_Id":55567385,"CreationDate":"2019-04-07T22:42:00.000","Title":"Pythonic way to compress a remote directory using SSH or FTP","Data Science and Machine Learning":0,"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 build a small project in python, now I need to send to another user to make him run it. But if he downloads my code on his computer then the file path(which based on my computer) won't be valid anymore. Is there anything I can do to make it runnable for him by setting up the path correctly?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":25,"Q_Id":55564935,"Users Score":1,"Answer":"zip the folder that it is located in and have them place it in the same location i.e if it is in your documents folder have them place it there","Q_Score":0,"Tags":"python","A_Id":55564943,"CreationDate":"2019-04-08T00:41:00.000","Title":"How to set up the filepath in code to make it runnable for others","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"using pip I installed new version of HtmlTestRunner in python 3.6, but while I run python file through command prompt its throws error. \n\nTraceback (most recent call last):\n    File \"seleniumUnitTest.py\", line 3, in \n      import HtmlTestRunner\n  ModuleNotFoundError: No module named 'HtmlTestRunner'","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1410,"Q_Id":55565407,"Users Score":2,"Answer":"Using python program.py instead of python3 program.py fixed my problem in Windows 10.","Q_Score":2,"Tags":"python,python-3.x,selenium,selenium-webdriver","A_Id":65629114,"CreationDate":"2019-04-08T02:11:00.000","Title":"Already installed Html test runner but it shows error \"ModuleNotFoundError: No module named 'HtmlTestRunner' \"","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 trying to build a .exe on Windows from my Python 3.7 application using PyInstaller. The build appears to run smoothly and shows no errors; however, executing the file on the Windows command prompt results in this awful error:\n\nOSError: PortAudio library not found \n\nI've done some research about this problem and found some info, but still couldn't overcome it. My app uses the sounddevice library, which depends on PortAudio library. PortAudio is installed, since the app works perfectly when I run it directly using Python; the problem is, clearly, that PyInstaller tracks the dependencies in some different way and is not able to find it and link it to the build.\nThis 'different way' is, actually, calling the 'find_library' function from 'ctypes.util' Python library to find the PortAudio library on the system. So, I ran the following on Python and confirmed it is not able to find the libary.\n\nPython 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: > Anaconda, Inc. on win32\n  Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\nfrom ctypes.util import find_library\na = find_library('portaudio')\nprint(a)\nNone\n\n\nSo far, I've tried several solutions. First, I downloaded and compiled the last PortAudio version manually. Didn't work. Then, I tried using Anaconda instead of the official Python distribution; as you may know, Anaconda's package manager 'conda' can deal with C libraries like PortAudio. So I installed it on my Anaconda's virtual environment and tried to build my app in there. Didn't work either. I also tried adding PortAudio directory to Windows PATH variable, but it also failed. I'm kinda lost. The only idea I have yet to try is building it on Linux using Wine, but I suspect there might be a way to get it working on Windows. \nAny ideas?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":877,"Q_Id":55566430,"Users Score":0,"Answer":"As the selected answer didn't work for me, because I'm using virtualenv, I put my working solution here.\nFor me, the working solution is to add _sounddevice_data folder where the .exe file is located then making a portaudio-binaries folder in it and finally putting libportaudio64bit.dll in the recently created folder.\nHope it helps!","Q_Score":4,"Tags":"python-3.x,windows,pyinstaller,portaudio","A_Id":57434105,"CreationDate":"2019-04-08T04:50:00.000","Title":"PyInstaller executable on Windows not working because of PortAudio library issues (OSError)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"In python how can I write subsets of an array to disk, without holding the entire array in memory?\nThe xarray input\/output docs note that xarray does not support incremental writes, only incremental reads except by streaming through dask.array. (Also that modifying a dataset only affects the in-memory copy, not the connected file.) The dask docs suggest it might be necessary to save the entire array after each manipulation?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":100,"Q_Id":55567542,"Users Score":0,"Answer":"This can be done using netCDF4 (the python library of low level NetCDF bindings). Simply assign to a slice of a dataset variable, and optionally call the dataset .sync() method afterward to ensure no delay before those changes are flushed to the file. \nNote this approach also provides the opportunity to progressively grow a dimension of the array (by calling createDimension with size None, making it the first dimension of a variable, and iteratively assigning to incrementally larger indices along that dimension of the variable).\nAlthough random-access window (i.e. subset) writes appear to require the lower level package, more systematic subset writes (eventually covering the entire array) can be done incrementally with xarray (by specifying a chunk size parameter to trigger use of the dask.array backend), and provided that your algorithm is refactored so that the main loop occurs in the dask\/xarray store-to-file call. This means you will not have explicit control over the sequence in which chunks are generated and written.","Q_Score":1,"Tags":"python,large-data,netcdf","A_Id":55602989,"CreationDate":"2019-04-08T06:39:00.000","Title":"Windowed writes in python, e.g. to NetCDF","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am applying a Savitzky-Golay filter to a signal, using the scipy function.\nI need to calculate the lag of the filtered signal, and how much is it behind the original signal.\nCould someone shed some light on this matter? How could I calculate it with scipy? How should I interpret the result correctly?\nI would be very grateful!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1092,"Q_Id":55572128,"Users Score":1,"Answer":"You are asking about lag\/latency of a digital filter: the only possible answer for a real-time filter is that the latency is determined entirely by the window size of the filter.\nNon-realtime filters (e.g, where the full set of samples is provided to the filter, as for e.g. the scipy Savitsky-Golay filter) can pretend\/simulate filtering at the \u2018time\u2019 of the current sample, but only by looking ahead at the full window.\nSome might protest that this is demonstrably how e.g. the scipy Savitzky-Goay filter works, and that\u2019s entirely correct, but nevertheless if you are asking about latency of a filter, which can only mean the delay that a real-time real-world filter will apply to real-time samples, the only possible answer is: this is only and undeniably\/incontrovertibly determined by the window size.","Q_Score":0,"Tags":"python,scipy,filtering,signal-processing","A_Id":55602759,"CreationDate":"2019-04-08T11:11:00.000","Title":"Delay in Savitzky-Golay filtering","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a set in Python and I want to sample one element from it, like with random.sample() method. The problem is that sample() converts set to tuple internally which is O(n) and I have to do it in the most optimal way.\nIs there a function that I can use to sample an element from a set with time complexity O(1) or the only way to do this is by creating your own implementation of set?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":154,"Q_Id":55572750,"Users Score":2,"Answer":"Because the data layout is irregular, it\u2019s impossible to uniformly sample from a hash-based set in O(1) except, in the case of \u03c9(n) queries, by preprocessing it into some sort of array.  (Such an array could be maintained while building the set, of course, but that\u2019s not the starting point given and isn\u2019t faster to add than the tuple conversion.)","Q_Score":1,"Tags":"python,set,time-complexity,sample","A_Id":55574886,"CreationDate":"2019-04-08T11:47:00.000","Title":"Sample one element from a set with O(1) time complexity","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"]How do I get my sprite to appear on the screen. i have been days at this and I couldn't get it to appear on the screen and it kept either taking over the screen as black.\nimport pygame\npygame.init()\nwin = pygame.display.set_mode((600,600))\npygame.display.set_caption(\"Napoleon\")\nbg = pygame.image.load(\"apple.png\").convert()\nwin.blit(bg, [0,0])\nflower= pygame.image.load(\"flower2.png\").convert()\nwin.blit(flower, [603,29])\npygame.display.update()","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":710,"Q_Id":55573424,"Users Score":5,"Answer":"Instead of convert() try convert_alpha().  Assuming your image has an alpha channel (PNG should be good) and it has been applied to  your background.  If your image has no alpha channel and you need a background gone, you should look into the set_colorkey() function.\nAlso, for future reference, you can format your code in your question by highlighting it all and pressing CTRL+K.  Makes it much easier to read (and you'll get faster answers!)","Q_Score":3,"Tags":"python,python-3.x,pygame,python-3.6,python-3.7","A_Id":55573521,"CreationDate":"2019-04-08T12:22:00.000","Title":"How do I upload a png image in pygame as a sprite, without the black background?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to make a smart IOT device (capable of performing smart Computer Vision operations, on the edge device itself). A Deep Learning algorithm (written in python) is implemented on Raspberry Pi. Now, while shipping this product (software + hardware) to my customer, I want that no one should log in to the raspberry pi and get access to my code. The flow should be something like, whenever someone logs into pi, there should be some kind of key that needs to be input to get access to code. But in that case how OS will get access to code and run it (without key). Then I may have to store the key on local. But still there is a chance to get access to key and get access to the code. I have applied a patent for my work and want to protect it.\nI am thinking to encrypt my code (written in python) and just ship the executable version. I tried pyinstaller for it, but somehow there is a script available on the internet that can reverse engineer it. \nNow I am little afraid as it can leak all my effort of 6 months at one go. Please suggest a better way of doing this.\nThanks in Advance.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":330,"Q_Id":55575277,"Users Score":-1,"Answer":"Keeping the code on your server and using internet access is the only way to keep the code private (maybe). Any type of distributed program can be taken apart eventually. You can't (possibly shouldn't) try to keep people from getting inside devices they own and are in their physical possession. If you have your property under patent it shouldn't really matter if people are able to see the code as only you will be legally able to profit from it.\nAs a general piece of advice, code is really difficult to control access to. Trying to encrypt software or apply software keys to it or something like that is at best a futile attempt and at worst can often cause issues with software performance and usability. The best solution is often to link a piece of software with some kind of custom hardware device which is necessary and only you sell. That might not be possible here since you're using generic hardware but food for thought.","Q_Score":0,"Tags":"python,raspberry-pi,deep-learning,iot","A_Id":55578897,"CreationDate":"2019-04-08T14:03:00.000","Title":"Is there any way to hide or encrypt your python code for edge devices? Any way to prevent reverse engineering of 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":"When running a linear regression, like y=a*x+b, the summary gives me the p-values of whether the parameters equal to zero, what if I would like to see the p-value of whether the parameter a equals to 2 or something different from zero?\nI expect the OLS summary gives me the p value of whether a is different from 2.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3001,"Q_Id":55576097,"Users Score":0,"Answer":"The p-value corresponds to the probability of observing this value of a under the null hypothesis (which is typically 0 as this is the case when there is no effect of the covariate x on the outcome y).\nThis is under the assumptions of linear regression which among other things state that a follows a normal distribution. Therefore, if you really want to change your null hypothesis to be a=2 then just transform a such that a_ = a - 2 now when a=2, a_ will be 0 as per the usual assumption.\nSo you can achieve this by solving for y+2x = a_*x + b and you will have a p-value for the probability that a=2 would occur by chance. As I said though this is a fairly unusual test...","Q_Score":0,"Tags":"python,statsmodels","A_Id":55577000,"CreationDate":"2019-04-08T14:47:00.000","Title":"How to check the p values of parameters in OLS","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a task where I need to run the same function on many different pandas dataframes. I load all the dataframes into a list then pass it to Pool.map using the multiprocessing module. The function code itself has been vectorized as much as possible, contains a few if\/else clauses and no matrix operations.\nI'm currently using a 10-core xeon and would like to speed things up, ideally passing from Pool(10) to Pool(xxx). I see two possibilities:\n\nGPU processing. From what I have read though I'm not sure if I can achieve what I want and would in any case need lots of code modification.\nXeon-Phi. I know it's being discontinued, but supposedly code adaptation is easier and if thats really the case I'd happily get one.\n\nWhich path should I concentrate on? Any other alternatives?\nSoftware: Ubuntu 18.04, Python 3.7. Hardware: X99 chipset, 10-core xeon (no HT)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":428,"Q_Id":55576373,"Users Score":1,"Answer":"Took a while, but after changing it all to numpy and achieving a little more vectorization I managed to get a speed increase of over 20x - so thanks Paul.\nmax9111 thanks too, I'll have a look into numba.","Q_Score":1,"Tags":"python,pandas,multiprocessing,gpu,xeon-phi","A_Id":55655008,"CreationDate":"2019-04-08T15:01:00.000","Title":"Hardware for python multiprocessing","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Machine Learning. I am trying to build a classifier that classifies the text as having a url or not having a url. The data is not labelled. I just have textual data. I don't know how to proceed with it. Any help or examples is appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1580,"Q_Id":55576378,"Users Score":1,"Answer":"Since it's text, you can use bag of words technique to create vectors.\n\nYou can use cosine similarity to cluster the common type text.\nThen use classifier, which would depend on number of clusters.\nThis way you have a labeled training set. \n\nIf you have two cluster, binary classifier like logistic regression would work. \nIf you have multiple classes, you need to train model based on multinomial logistic regression\nor train multiple logistic models using One vs Rest technique.\n\nLastly, you can test your model using k-fold cross validation.","Q_Score":0,"Tags":"python,machine-learning,classification","A_Id":55576706,"CreationDate":"2019-04-08T15:02:00.000","Title":"How to classify unlabelled data?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As a project grows, so do dependencies and event chains, especially in overridden save() methods and post_save and pre_save signals. \nExample:\nAn overridden A.save creates two related objects to A - B and C. When C is saved, the post_save signal is invoked that does something else, etc...\nHow can these event chins be made more clear? Is there a way to visualize (generate automatically) such chains\/flows? I'm not looking for ERD nor a Class diagram. I need to be sure that doing one thing one place won't affect something on the other side of the project, so simple visualization would be the best.\nEDIT\nTo be clear, I know that it would be almost impossible to check dynamically generated signals. I just want to check all (not dynamically generated) post_save, pre_save, and overridden save methods and visualize them so I can see immediately what is happening and where when I save something.","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1398,"Q_Id":55578230,"Users Score":6,"Answer":"(Too long to fit into a comment, lacking code to be a complete answer) \nI can't mock up a ton of code right now, but another interesting solution, inspired by Mario Orlandi's comment above, would be some sort of script that scans the whole project and searches for any overridden save methods and pre and post save signals, tracking the class\/object that creates them. It could be as simple as a series of regex expressions that look for class definitions followed by any overridden save methods inside.  \nOnce you have scanned everything, you could use this collection of references to create a dependency tree (or set of trees) based on the class name and  then topologically sort each one. Any connected components would illustrate the dependencies, and you could visualize or search these trees to see the dependencies in a very easy, natural way. I am relatively naive in django, but it seems you could statically track dependencies this way, unless it is common for these methods to be overridden in multiple places at different times.","Q_Score":20,"Tags":"python,django,architecture,software-design","A_Id":55660187,"CreationDate":"2019-04-08T16:54:00.000","Title":"Django - how to visualize signals and save overrides?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"A list is used as a queue such that the first element is the head of the queue. I was discussing the complexity of dequeue operation in such data structure with my teacher, who said it is O(1). My thinking is, if you're removing the first element of the list, wouldn't that be O(n), since then all elements after that first element need to be shifted over a spot? Am I looking at this the wrong way?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":665,"Q_Id":55578874,"Users Score":2,"Answer":"You're correct. List in Python is inefficient at dequeuing since all items following the item being dequeued need to be copied to their preceding positions like you say. You can instead use collections.deque, which is implemented with a doubly-linked list, so that you can use the popLeft method to dequeue efficiently in O(1) time complexity.","Q_Score":2,"Tags":"python,time-complexity","A_Id":55578968,"CreationDate":"2019-04-08T17:37:00.000","Title":"Dequeue complexity on using Python list as a queue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A list is used as a queue such that the first element is the head of the queue. I was discussing the complexity of dequeue operation in such data structure with my teacher, who said it is O(1). My thinking is, if you're removing the first element of the list, wouldn't that be O(n), since then all elements after that first element need to be shifted over a spot? Am I looking at this the wrong way?","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":665,"Q_Id":55578874,"Users Score":-1,"Answer":"You are correct. Python's list is an array-list, so, not appropriate for popping from head. Instead, use collections.deque for O(1) add\/remove at first element.","Q_Score":2,"Tags":"python,time-complexity","A_Id":55578999,"CreationDate":"2019-04-08T17:37:00.000","Title":"Dequeue complexity on using Python list as a queue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Visual Studio Code is never able to populate the 'Quick Fix' contextual drop down, only displaying 'No Code Actions Available'\nPython extension is installed, along with python3.7.3 and flake8, pep8.","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":10094,"Q_Id":55582277,"Users Score":15,"Answer":"The Python extension for VS Code currently doesn't offer any quick fixes.","Q_Score":23,"Tags":"python,visual-studio-code","A_Id":55641574,"CreationDate":"2019-04-08T21:52:00.000","Title":"Visual Studio Code quick-fix & python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Visual Studio Code is never able to populate the 'Quick Fix' contextual drop down, only displaying 'No Code Actions Available'\nPython extension is installed, along with python3.7.3 and flake8, pep8.","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":10094,"Q_Id":55582277,"Users Score":3,"Answer":"Solution for 2021.\nI got the same issue with Python for VSCode 1.54.2.\nI solved it by installing the Pylance extension and making it the default Python language server (a message should pop up just after the installation asking if you want to make it the default Python language server). Now everything works flawlessly.","Q_Score":23,"Tags":"python,visual-studio-code","A_Id":66640979,"CreationDate":"2019-04-08T21:52:00.000","Title":"Visual Studio Code quick-fix & python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written several small scripts in python and build the binaries using pyinstaller. \nWhen I would build them on my Ubuntu 16.04 machine -- they would run fine on the machine where I build them. But moving the file to a Centos \/ Redhat 7.4 machine would give me GCLIB and other .so version dependency errors.\n\nBuilding the same binary on docker with the same version of Centos would not give these errors.\nIf I try running the binary compiled on Centos 7.4 on Centos 6.6 I would get errors again -- But building on Centos 6.6 it would work correctly with Centos 6.6\n\nI have solved the problem using a lower version of Centos to build my binaries for now. \n\nMy specific question is -- In Python, is it a common approach of building the binaries on different OSs based on the target OS that it is intended for (assuming linux targets only) or what I am doing is a hack \/ bad way of solving this problem? \n\nI am trying to understand how this problem is approached in the standard way.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1266,"Q_Id":55585021,"Users Score":3,"Answer":"As long as the binary produced by pyinstaller only depends on glibc, then it should be a valid approach to build it on the oldest system available, and it should work on future systems.\nIn general, glibc is designed to be backwards compatible, so that applications built against an older version of glibc will still run with a newer glibc, but not vice versa. It does this via symbol versioning, in which each symbol you link to can have a version associated with it, and any case in which a newer glibc has changed the ABI of some function, it will also have a compatibility routine with the old ABI exposed with the older symbol version, so that applications linked against the old one will dynamically link with the compatibility routine, while if you have an application linked against the newer symbol versions, there won't be the newer versions in an older glibc to dynamically link to.\nWhile other libraries can also do this, not many library authors bother to, so newer versions may simply be incompatible, while the glibc developers generally try to preserve compatibility.\nSo yes, as long as the final binary links only to glibc, or to other libraries which follow a similar symbol versioning scheme to ensure that older binaries will still link properly to newer versions of the library, it is perfectly valid to build against an older version and then run it on newer versions of various Linux distros, and even generally across distros as well.\nUnfortunately, there's no good way to get the linker to pick the older symbol versions if linking against a newer glibc, so frequently the easiest way to do this is within a Docker or other type of container containing an older distro that has the oldest glibc that you want to be compatible with.","Q_Score":1,"Tags":"python,linux,pyinstaller,software-distribution","A_Id":55585125,"CreationDate":"2019-04-09T04:10:00.000","Title":"Does python + pyinstaller support multiple OS\/Versions of linux?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Python Flask application with a HTML form which accept few inputs from user, uses those in an python program which returns the processed values back to flask application return statement.\nI wanted to capture the time took for whole processing and rendering output data on browser but not sure how to do that. At present I have captured the take by python program to process the input values but it doesn't account for complete time between \"submit\" action and rendering output data.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":55587410,"Users Score":0,"Answer":"Use ajax request to submit form. Fetch the time on clicking the button and after getting the response and then calculate the difference.","Q_Score":0,"Tags":"python,html,python-3.x,flask,flask-wtforms","A_Id":55587577,"CreationDate":"2019-04-09T07:36:00.000","Title":"Capturing time between HTML form submit action and printing response","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I found there are some library for extracting images from PDF or word, like docx2txt and pdfimages. But how can I get the content around the images (like there may be a title below the image)? Or get a page number of each image\uff1f\nSome other tools like PyPDF2 and minecart can extract image page by page. However, I cannot run those code successfully.\nIs there a good way to get some information of the images? (from the image got from docx2txt or pdfimages, or another way to extract image with info)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":401,"Q_Id":55589189,"Users Score":0,"Answer":"docx2python pulls the images into a folder and leaves -----image1.png---- markers in the extracted text. This might get you close to where you'd like to go.","Q_Score":0,"Tags":"python,shell,pdf,ms-word,image-extraction","A_Id":56978698,"CreationDate":"2019-04-09T09:15:00.000","Title":"How to extract images from PDF or Word, together with the text around images?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Our package has a few example scripts that show how the package can be used.\nWhenever we make a breaking change in my package, the examples may need to be updated. Right now I need to manually keep track of this, by checking whether the example scripts still run. Is there some way to add a test_examples function to my unit testing setup that doesn't assert the return value of a specific function, but simply runs all (or specific) files in the examples folder and checks that these scripts complete without error?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27,"Q_Id":55593421,"Users Score":0,"Answer":"This was much easier than I thought it would be. I simply needed to add a test function to my pytest setup that imported the example scripts. Since these scripts aren't protected by a, if __name__ == \"__main__\": statement, all content is run. If there are errors along the way, the import, and therefore the test, will fail.","Q_Score":0,"Tags":"python,python-3.x,pytest","A_Id":55594481,"CreationDate":"2019-04-09T12:54:00.000","Title":"Add automatic test to package examples","Data 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 using a custom version of YOLO v2 from pjreddie.com written with Tensorflow and Keras. I've successfully got the model to start and finish training over 100 epochs with 10000 training images and 2400 testing images which I randomly generated along with the associated JSON files all on some Titan X gpus with CUDA. I only wish to detect two classes. However, after leaving the training going, the loss function decreases but the test accuracy hovers at below 3%. All the images appear to be getting converted to black and white. The model seems to perform reasonably on one of the classes when using the training data, so the model appears overfitted. What can I do to my code to get the model to become accurate?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":260,"Q_Id":55595512,"Users Score":0,"Answer":"Okay, so it turned out that YOLOv2 was performing very well on unseen data except that the unseen data has to be the same size of images as the ones it's trained on. Don't feed Yolo with 800x800 images if it's been trained on 400x400and 300x400 images. Also the Keras accuracy measure is meaningless for detection. It might say 2% accuracy and actually be detecting all objects. Passing unseen data of the same size solved the problem.","Q_Score":0,"Tags":"python,tensorflow,keras,computer-vision,artificial-intelligence","A_Id":55679352,"CreationDate":"2019-04-09T14:44:00.000","Title":"YOLO v2 bad accuracy in Tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using openapi-generator to generate server stub python code.\nEverything works fine, however, every time I make a change in the OpenAPI specs (the yaml file), the code generator overwrites the whole code, even the one customized (the controller). I would like to develop an incremental workflow, where if I make a change in the specs, the generator modifies the code handling that part of the code only. \nIt would be great if I get to the point where I can enforce the specs and also have an incremental workflow.\nI am using openapi-generator version 3.3.4. \nI tried to modify the controller and remove # noqa: E501, but it still overwrites the code every time I generate the stub from the specs.\nHow can I isolate the controller implementation by the generated interface, since the generated code is not OOP?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":678,"Q_Id":55596358,"Users Score":0,"Answer":"I tried to modify the controller and remove # noqa: E501, but it still overwrites the code every time I generate the stub from the specs.\n\nYou may want to use customized templates with the -t option.","Q_Score":1,"Tags":"python,flask-sqlalchemy,openapi,openapi-generator,connexion","A_Id":58424189,"CreationDate":"2019-04-09T15:29:00.000","Title":"openapi code generator - python server stub workflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using openapi-generator to generate server stub python code.\nEverything works fine, however, every time I make a change in the OpenAPI specs (the yaml file), the code generator overwrites the whole code, even the one customized (the controller). I would like to develop an incremental workflow, where if I make a change in the specs, the generator modifies the code handling that part of the code only. \nIt would be great if I get to the point where I can enforce the specs and also have an incremental workflow.\nI am using openapi-generator version 3.3.4. \nI tried to modify the controller and remove # noqa: E501, but it still overwrites the code every time I generate the stub from the specs.\nHow can I isolate the controller implementation by the generated interface, since the generated code is not OOP?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":678,"Q_Id":55596358,"Users Score":0,"Answer":"An easy workaround is to add openapi_server\/controllers in the .openapi-generator-ignore file so that they are not overwritten every time you update your API contract.\nYou'll have to manually create these files yourself though","Q_Score":1,"Tags":"python,flask-sqlalchemy,openapi,openapi-generator,connexion","A_Id":58417951,"CreationDate":"2019-04-09T15:29:00.000","Title":"openapi code generator - python server stub workflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using openapi-generator to generate server stub python code.\nEverything works fine, however, every time I make a change in the OpenAPI specs (the yaml file), the code generator overwrites the whole code, even the one customized (the controller). I would like to develop an incremental workflow, where if I make a change in the specs, the generator modifies the code handling that part of the code only. \nIt would be great if I get to the point where I can enforce the specs and also have an incremental workflow.\nI am using openapi-generator version 3.3.4. \nI tried to modify the controller and remove # noqa: E501, but it still overwrites the code every time I generate the stub from the specs.\nHow can I isolate the controller implementation by the generated interface, since the generated code is not OOP?","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":678,"Q_Id":55596358,"Users Score":2,"Answer":"To over come this problem I put my end point implementations into files in a openapi_server\/implementation\/ module and then I implemented a patching system in my build process.\nI generate the server stub and then apply a patch to the server endpoint stubs in openapi_server\/controller.\nThe patch includes adding various imports to endpoint implementation functions, replaces the  return 'do some magic!' lines with a calls to their end point implementations and even removes the # noqa: E501 comments where I don't want them.\nWith this system in place my openapi-generator can overwrite the openapi_server\/controller directory each time it runs, and in the end I still end up with these files in a state that calls the implementations I need and any other tweaks I wanted have been applied.","Q_Score":1,"Tags":"python,flask-sqlalchemy,openapi,openapi-generator,connexion","A_Id":68029246,"CreationDate":"2019-04-09T15:29:00.000","Title":"openapi code generator - python server stub workflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using openapi-generator to generate server stub python code.\nEverything works fine, however, every time I make a change in the OpenAPI specs (the yaml file), the code generator overwrites the whole code, even the one customized (the controller). I would like to develop an incremental workflow, where if I make a change in the specs, the generator modifies the code handling that part of the code only. \nIt would be great if I get to the point where I can enforce the specs and also have an incremental workflow.\nI am using openapi-generator version 3.3.4. \nI tried to modify the controller and remove # noqa: E501, but it still overwrites the code every time I generate the stub from the specs.\nHow can I isolate the controller implementation by the generated interface, since the generated code is not OOP?","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":678,"Q_Id":55596358,"Users Score":1,"Answer":"Best solution i found, worked perfectly\nUse two branch : One with raw server stub, One with server stub filled with your code.\nGenerate new server stub versions only on the raw branch an merge it to other branch wich contains previous server stub filled with your code.\nMy workflow :\nEach time i need to modify the  server stub i checkout the raw server stub branch => then modify the openAPi file => then generate the server stub => then commit => then checkout the dev branch => then merge raw server stub branch into my dev branch.\nFor now it works well :). Hope it helps.","Q_Score":1,"Tags":"python,flask-sqlalchemy,openapi,openapi-generator,connexion","A_Id":60142397,"CreationDate":"2019-04-09T15:29:00.000","Title":"openapi code generator - python server stub workflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a code in Python 2 which I would like to convert to Python 3, however the behaviour of the code MUST remain exactly the same as on Python 2 interpreter. \nEspecially division must behave like on Python 2 interpreter. \nI tried with futurize stage 1 and 2 but division remains just \/ on the code, which generates errors on execution because returned number is of type float instead of type int (which was a default behaviour for code executed on Python 2 interpreter).\nEDIT: 3 \/\/ 2 = 1.0 which is float in Python 3. Is there a way to return int?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":233,"Q_Id":55596854,"Users Score":1,"Answer":"Futurize\/Modernize\/2to3 can't statically analyze which divisions are integer division. \nYou will need to manually go through division operations in the converted code and figure out which should use \/\/ for integer division and which should use \/ for real division.\nNaturally, your code base's test cases should find any regressions here. ;)","Q_Score":0,"Tags":"python,python-3.x,python-2.7","A_Id":55596931,"CreationDate":"2019-04-09T15:58:00.000","Title":"Convert Python 2 into Python 3 (with Python 2 style execution)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried all combinations and nothing made import geohash work:\n\npip install geohash\npip3 install geohash\napt-get install python-dev\npip3 install python-geohash\n\nthe 4th one isn't even installing but threw an error on me saying:\nsrc\/geohash.cpp:538:20: fatal error: Python.h: No such file or directory\n   #include \n                      ^\n  compilation terminated.\n  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1378,"Q_Id":55596971,"Users Score":1,"Answer":"Thanks @William D. Irons. The issue got fixed when I did sudo apt-get install libpython3.7-dev","Q_Score":0,"Tags":"python-3.x,geohashing","A_Id":55605164,"CreationDate":"2019-04-09T16:05:00.000","Title":"error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 while doing pip3 install python-geohash","Data 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":"We have created website online exam portal in nodejs and mongodb hosted on amazon aws. Problem is the descriptive answer evaluation code is in python. So is there any way we can combine both. Run python code in nodejs. We have used express.js for nodejs and mongoose framework for mongodb.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":55597443,"Users Score":0,"Answer":"You can use lambda for your python, then hit it from nodejs app, and return the response for your nodejs app.","Q_Score":0,"Tags":"python,node.js,mongodb","A_Id":55597496,"CreationDate":"2019-04-09T16:36:00.000","Title":"Is there any way to use python code in nodejs project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to set up a non-conventional neural network using keras, and am having trouble efficiently setting this up. \nThe first few layers are standard convolutional layers, and the output of these have d channels, which each have image shapes of n x n.\nWhat I want to do is use a single dense layer to map this d x n x n tensor onto a single image of size n x n. I want to define a single dense layer, with input size d, and output size 1, and apply this function to each \"pixel\" on the input (with the inputs taken depthwise across channels). \nSo far, I have not found a efficient solution to this. I have tried first defining a fully connected layer, then looping over each \"pixel\" in the input, however this takes many hours to initialize the model, and I am worried that it will slow down backprop, as the computations are likely not properly parallelized.\nIs there an efficient way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":234,"Q_Id":55598702,"Users Score":1,"Answer":"What you're describing is a 1x1 convolution with output depth 1. You can implement it just as you implement the rest of the convolution layers. You might want to apply tf.squeeze afterwards to remove the depth, which should have size 1.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,keras","A_Id":55598802,"CreationDate":"2019-04-09T18:02:00.000","Title":"How to apply a single fully connected layer to each point in an image","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am recording audio in a web browser and sending it to a flask backend. From there, I want to transcribe the audio using Watson Speech to Text. I cannot figure out what data format I'm receiving the audio and how to convert it to a format that works for watson.\nI believe watson expects a bytestring like b'\\x0c\\xff\\x0c\\xffd. The data I receive from the browser looks like [ -4 -27 -34  -9   1  -8  -1   2  10 -28], which I can't directly convert to bytes because of the negative values (using bytes() gives me that error).\nI'm really at a loss for what kind of conversion I need to be making here. Watson doesn't return any errors for any kind of data I throw at it just doesn't respond.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":276,"Q_Id":55599385,"Users Score":1,"Answer":"Those values should be fine, but you have to define how you want them stored before getting the bytes representation of them.\nYou'd simply want to convert those values to signed 2-byte\/16-bit integers, then get the bytes representation of those.","Q_Score":1,"Tags":"python,html,audio,types,data-conversion","A_Id":55601491,"CreationDate":"2019-04-09T18:46:00.000","Title":"What is this audio datatype and how do I convert it to wav\/l16?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In python, when converting strings to floats, float() converts both integers or decimals representations to a number:\nfloat('3.5') gives 3.5\nfloat('3') gives 3\nfloat() also converts integers to floats:\nfloat(3) gives 3.0\nWhy does int() not convert a string decimal to an integer if it can convert a float to an integer? For example:\nint(3.5) gives 3,\nhowever int('3.5') raises an ValueErrorexception.\nThis makes one use something like int(float('3.5')) when wanting to convert a string into an integer while not knowing whether or not the number will be a decimal.\nWhy is there this difference between float() and int()?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":138,"Q_Id":55599535,"Users Score":-1,"Answer":"I would say, why not?\nThis is more like a precaution of conversion. It tries to be careful and conservative as conversion can lost data precision in an unexpected way. By saying int(float(\"3.5\")), your intention is explicit. But int(\"3.5\") -- do you expect that is not an integer and you are ready to give up that 0.5 difference? Such issue does not exists in float(\"3.5\").\nIf you want int(\"3.5\") to give you back the integer without raising error, would it be natural to also ask for int(\"four\"), int(\"3.5 # ignore this comment\"), int(\"XLII\") to be valid? That would be too much.","Q_Score":1,"Tags":"python,floating-point,int","A_Id":55599632,"CreationDate":"2019-04-09T18:56:00.000","Title":"Inconsistent behavior with int() and float()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need SSIM as a loss function in my network, but my network has 2 outputs. I need to use SSIM for first output and cross-entropy for the next. The loss function is a combination of them. However, I need to have a higher SSIM and lower cross-entropy, so I think the combination of them isn't true.  Another problem is that I could not find an implementation of SSIM in keras.\nTensorflow has tf.image.ssim, but it accepts the image and I do not think I can use it in loss function, right? Could you please tell me what should I do? I am a beginner in keras and deep learning and I do not know how can I make SSIM as a custom loss function in keras.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3145,"Q_Id":55600106,"Users Score":0,"Answer":"other choice would be\nssim_loss = 1 - tf.reduce_mean(tf.image.ssim(target, output, max_val=self.max_val))\nthen\ncombine_loss = mae (or mse) + ssim_loss\nIn this way, you are minimizing both of them.","Q_Score":3,"Tags":"python,tensorflow,keras,loss-function","A_Id":70400820,"CreationDate":"2019-04-09T19:37:00.000","Title":"how do I implement ssim for loss function in keras?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I hope you are all having an amazing day. So I am working on a project using Python. The script's job is to automate actions and tasks on a social media platform via http requests. As of now, one instance of this script access one user account. Now, I want to create a website where I can let users register, enter their credentials to the social media platform and run an instance of this script to perform the automation tasks. I've thought about creating a new process of this script every time a new user has register, but this doesn't seem efficient. Also though about using threads, but also does not seem reasonable. Especially if there are 10,000 users registering. What is the best way to do this? How can I scale? Thank you guys so much in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":292,"Q_Id":55602143,"Users Score":1,"Answer":"What is the nature of the tasks that you're running?\nAre the tasks simply jobs that run at a scheduled time of day, or every X minutes? For this, you could have your Web application register cronjobs or similar, and each cronjob can spawn an instance of your script, which I assume is short-running, to carry out a the automated task one user at a time. If the exact timing of the script doesn't matter then you could scatter the running of these scripts throughout the day, on seperate machines if need be.\nThe above approach probably won't scale well to 10,000 users, and you will need something more robust, especially if the script is something that needs to run continuously (e.g. you are polling some data from Facebook and need to react to its changes). If it's a lot of communication per user, then you could consider using a producer-consumer model, where a bunch of producer scripts (which run continously) issue work requests into a global queue that a bunch of consumer scripts poll and carry out. You could also load balance such consumers and producers across multiple machines.\nOf course, you would definitely want to squeeze out some parallelism from the extra cores of your machines by carrying out this work on multiple threads or processes. You could do this quite easily in Python using the multiprocessing module.","Q_Score":0,"Tags":"python,web-services,automation,httprequest,scale","A_Id":55603470,"CreationDate":"2019-04-09T22:21:00.000","Title":"How to serve a continuously running python script to multiple users (Social Media 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 been given a basic python problem that requires me to make a simple addition quiz. However, I cannot seem to return my count variable which is supposed to update the number of correct questions the user has answered, which makes it stuck at 0. I have tried defining the variable count in every function containing it as an argument but still does not work. Say if the user were to answer 4 questions and got 3 correct, it would display it as \"You have answered 4 questions with 3 correct\", but instead it displays \"You have answered 4 questions with 0 correct\".","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":421,"Q_Id":55602424,"Users Score":1,"Answer":"As the comment stated, you are initializing count to 0 every time your check_solution or menu_option is called.\nIt looks like you want to use count = count the variable being passed to your function.\nJust a quick edit:\nYou actually don't need to return count. In Python, variables are passed by reference so your count will get updated as long as it's being passed to your functions.","Q_Score":1,"Tags":"python,function,loops,return","A_Id":55602476,"CreationDate":"2019-04-09T22:56:00.000","Title":"Python 3: Returning variable through multiple functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been given a basic python problem that requires me to make a simple addition quiz. However, I cannot seem to return my count variable which is supposed to update the number of correct questions the user has answered, which makes it stuck at 0. I have tried defining the variable count in every function containing it as an argument but still does not work. Say if the user were to answer 4 questions and got 3 correct, it would display it as \"You have answered 4 questions with 3 correct\", but instead it displays \"You have answered 4 questions with 0 correct\".","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":421,"Q_Id":55602424,"Users Score":1,"Answer":"You need catch the return from check_solution(user_answer, randsum, count) and return that count","Q_Score":1,"Tags":"python,function,loops,return","A_Id":55602507,"CreationDate":"2019-04-09T22:56:00.000","Title":"Python 3: Returning variable through multiple functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been given a basic python problem that requires me to make a simple addition quiz. However, I cannot seem to return my count variable which is supposed to update the number of correct questions the user has answered, which makes it stuck at 0. I have tried defining the variable count in every function containing it as an argument but still does not work. Say if the user were to answer 4 questions and got 3 correct, it would display it as \"You have answered 4 questions with 3 correct\", but instead it displays \"You have answered 4 questions with 0 correct\".","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":421,"Q_Id":55602424,"Users Score":0,"Answer":"You have the option of initializing count to 0 before all functions, thus creating a global variable. Then you won't need to declare it on any function nor pass it as argument.","Q_Score":1,"Tags":"python,function,loops,return","A_Id":55602537,"CreationDate":"2019-04-09T22:56:00.000","Title":"Python 3: Returning variable through multiple functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Google Form that dumps responses into a Google Sheets file. I need to pipeline these responses to MongoDB. Can someone give me some info on where I should start? I want the responses to be taken from the Google Sheet and put into MongoDB. I'm looking to do this in Python (Although I'm new to it). I've never had a task like this and I'm super eager to conquer it! Thanks for any insight you can give!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":4696,"Q_Id":55603692,"Users Score":1,"Answer":"If you download the Google Sheet files and use a library called openpyxl, you can interact directly with the .xlsx files from a Python script. \nFrom there, you should be able to convert rows in the spreadsheet to Python dictionary objects, and pipe those objects right into MongoDB using pymongo or the like. \nSounds like a useful tool! Best of luck.","Q_Score":1,"Tags":"python,mongodb,google-sheets","A_Id":55603957,"CreationDate":"2019-04-10T02:02:00.000","Title":"How to connect Google Sheets to MongoDB","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to build a website that shows some data from a CSV file and collects some user data (which should be provided through some textbox widgets) and saves it in a CSV file(the same file). I already have a working Python code for the CSV handling.\nThe problem is that I'm not sure what programming languages I need to use besides Python in order to achieve that using Flask or Django. And I'm not familiar with web development.\nCan I make it using only Python and Django\/Flask(or any other web framework)? If not, what languages and resources do I need? And do I need a database for that? I tried some tutorials for both frameworks but Flask seems to need HTML and CSS, and Django wasn't much clear to me. Thank you.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":151,"Q_Id":55604312,"Users Score":1,"Answer":"I would recommend going with Flask rather than Django, as you'll have far less to set up and far less to learn to get your project running.\nYou will need to learn HTML, and Jinja2 (flasks templating language) but this shouldn't be too hard.\nFocus on how to do tables in HTML, and then learn about for loops in Jinja2.\nYou won't need to learn CSS unless you want to make it look pretty.","Q_Score":1,"Tags":"python,django,flask","A_Id":55605471,"CreationDate":"2019-04-10T03:24:00.000","Title":"Interactive web application with Django\/Flask issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How can I schedule the execution of a workflow in orange canvas? \nFor example, I have a predictive model that use tweets collected with Twitter Widget ( text analysis Add-on) and then predict some behaviour to send alerts with Python bot (Python Widget). I need this prediction process to run automatically daily.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":331,"Q_Id":55604329,"Users Score":1,"Answer":"What you can try it to use some scheduler (on Linux I would use cron) and schedule it to run orange-canvas with your workflow (pass the file as an argument).\nIf you end your python script with sys.exit() it will also close Orange after this.\nI think there is no way to hide the Orange canvas while the workflow is running.","Q_Score":1,"Tags":"python,orange","A_Id":55616811,"CreationDate":"2019-04-10T03:26:00.000","Title":"Run scheduled and automated Orange worklow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am designing a program which will run continuously on a ROC64. It includes the usage of BackgroudsubtractorMOG2(a background-subtracting algorithm implemented in opencv). Opencv seems to use multithreading optimization in this algorithm and it eats up all the CPU resources. I understand that in C++ we can limit the number of threads by using setNumThreads().Is there a similar thing in Python or I must find another way to work around it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3919,"Q_Id":55604373,"Users Score":1,"Answer":"You can use cv2.setNumThreads(n) (Where n = number of threads)\nBut it didn't work for me, its still using all the CPU.","Q_Score":3,"Tags":"python,multithreading,opencv","A_Id":69070357,"CreationDate":"2019-04-10T03:32:00.000","Title":"How to limit the number of threads that opencv uses in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Reading the documentation it's pretty much clear how to build queries, but I couldn't find any tutorial how to connect to the database - i.e. instruct pypika which DB to use, which credentials etc. How can I connect to the database with pypika?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1475,"Q_Id":55608307,"Users Score":6,"Answer":"As far as I know, you can't connect to a database with pypika. Pypika is only a tool that makes SQL query strings. It doesn't have the functionality you are looking for.\nYou make the query string with the help of pypika, and you throw that string to your database system with packages that can do that, like pymysql for MySQL or psycopg for PostgreSQL.","Q_Score":6,"Tags":"python,query-builder,pypika","A_Id":55608640,"CreationDate":"2019-04-10T08:44:00.000","Title":"How can I connect to the database with pypika?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to do a filter on a dataframe like so:\nfiltered_df2 = filtered_df.select(\"li\", \"result.li\", \"fw\").orderBy(\"fw\")\nHowever, the nested column, result.li has the same name as li and this poses a problem. I get the following error:\nAnalysisException: 'Found duplicate column(s) when inserting into hdfs:\/\/...: `li`;'\nHow can I filter both fields successfully ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2453,"Q_Id":55612813,"Users Score":0,"Answer":"I've got the solution now. What I needed to use was:\nAdd from pyspark.sql.functions import * at the file header\nSimply use col()'s alias function like so:\nfiltered_df2 = filtered_df.select(col(\"li\"),col(\"result.li\").alias(\"result_li\"), col(\"fw\")).orderBy(\"fw\")","Q_Score":0,"Tags":"python,apache-spark,dataframe,pyspark,apache-spark-sql","A_Id":55613124,"CreationDate":"2019-04-10T12:40:00.000","Title":"Found duplicate column when trying to query with Spark SQL","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have updated and installed Microsoft Power BI Desktop Report Server (64-bit).\nPrior to this I have already installed python 3.6 in machine. I am trying run python script on Power BI. but I don't see any option.\nI know this can be enabled by selecting \"Python Script\" in Preview Feature.\nBut the problem is I cannot see \"Preview Feature\" available in Options.\nCan anyone help me how I can execute python script there.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":775,"Q_Id":55613905,"Users Score":0,"Answer":"The Preview Feature is not available with Report server version. We need to have Power BI Desktop Cloud. Also version should be August 2018 or above.","Q_Score":0,"Tags":"python,powerbi,visualization,powerbi-desktop,preview-feature","A_Id":55757798,"CreationDate":"2019-04-10T13:32:00.000","Title":"Preview feature not available in Power BI destop Report server Jan 2019 version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can i insert images to background in text (like overlapping) by python-docx?\nI know it is possible that the image can be placed with text on the right or left side on that.\nbut i want something like floating images over the any text. like background image.\nit is possible do that? \nthanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1627,"Q_Id":55615852,"Users Score":0,"Answer":"It seems to work that when you insert an image in your template file in a table, that docx then Reimport the image","Q_Score":2,"Tags":"image,overlay,docx,overlapping,python-docx","A_Id":68428591,"CreationDate":"2019-04-10T15:05:00.000","Title":"How to insert image on the background (overlap with text) with add_picture() in python-docx?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a jupyter notebook with python code and am wondering if it needs to go to a specific file location in Ubuntu? Is there a best practice as to where to put it? Does it not matter? \nFor example, I place my html\/css code in \/var\/www\/html in ubuntu.\nThank you!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":199,"Q_Id":55615980,"Users Score":1,"Answer":"There is no \"recommended\" directory as in case of hosted websites that are placed under \/var\/www\/html. It is more of a personal preference.\nI personally use a subdirectory under \/home\/username to organizes all my codes files with separate folders for each project.","Q_Score":0,"Tags":"python,ubuntu-18.04,windows-subsystem-for-linux,fhs","A_Id":55616427,"CreationDate":"2019-04-10T15:11:00.000","Title":"saving jupyter notebook\/python files on ubuntu 18.04.1 LTS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a jupyter notebook with python code and am wondering if it needs to go to a specific file location in Ubuntu? Is there a best practice as to where to put it? Does it not matter? \nFor example, I place my html\/css code in \/var\/www\/html in ubuntu.\nThank you!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":199,"Q_Id":55615980,"Users Score":0,"Answer":"Since you mentioned \"windows subsystem for Linux.\" I recommend :\n\nCreate a folder in \/mnt\/c\/my_notebook_folder. You can also access this folder from windows c:\\my_notebook_folder\nInitialize a git repo and checking the code to GitHub\/bitbucket or source control of your choice.","Q_Score":0,"Tags":"python,ubuntu-18.04,windows-subsystem-for-linux,fhs","A_Id":55621401,"CreationDate":"2019-04-10T15:11:00.000","Title":"saving jupyter notebook\/python files on ubuntu 18.04.1 LTS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm testing pyglet, and it has everything(except for a good guide) but the only thing that i don't understand is: how do I move the camera to show hidden content?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":682,"Q_Id":55616146,"Users Score":0,"Answer":"Try using an offset. Fo\/x, lets say x = 0, and camoffset = 5. You can render the x as x+camoffset. It works.","Q_Score":0,"Tags":"python-3.x,2d,viewport,pyglet","A_Id":55623339,"CreationDate":"2019-04-10T15:19:00.000","Title":"Is there a way to move the camera of a 2d world in pyglet?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Data:\n\nTransaction table with region field (Oracle database-Only read access).\nUsers table in excel with region field. (I can add this table in secondary database)\n\nLDAP Authentication is used.\nUsing views(raw SQL query is used), I am showing aggregated data of transaction table.\nAll users are seeing same data, as there is no filter on the region.\nNow, I want to aggregate only those records which login user's region belongs to.\nHow can these implemented?\nMy approach:\n\nCreate region model\nImplement a Foreign Key with transaction tables(Is it possible?)\n\nWhat is best approach to this scenario?\nPlease explain clearly in steps.\nNOTE: I have solved my problem. Please look my answer. Is there any drawbacks of my approach? (New best approach is appreciated)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":55616807,"Users Score":0,"Answer":"I solved this by following below steps.\nSteps:\n\nCreated a DataFrame of User Table present in excel using Pandas in my views.py.\nCaptured a login user ID into a variable.\nFiltered this User ID in DataFrame and got his\/her region and then I have passed this variable to final aggregating query and filtered there.\n\nShort and simple.","Q_Score":1,"Tags":"python,django,authentication,authorization","A_Id":55672098,"CreationDate":"2019-04-10T15:58:00.000","Title":"Django: how to fetch records only that matches the region belongs to login user?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm relatively inexperienced Python user and completely new to Flask, so I am sure this is dumb, but...\nI had a file that acted as an entry point for Flask, named some_silly_name.py which contains the line app = Flask(__name__). The server was running fine, until I decided that that name was silly, so I renamed the file to a_much_better_name.py. Now on flask run I get the error Error: Could not import \"some_silly_name\".\nWhat do I need to do to change the name of this file and still have Flask run?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1586,"Q_Id":55617913,"Users Score":0,"Answer":"Check your import statement... to be sure that you have also changed the file name from the sily_name to the better_name\nYour code will help to easily point you in the right direction.","Q_Score":1,"Tags":"python,python-3.x,flask","A_Id":55618161,"CreationDate":"2019-04-10T17:05:00.000","Title":"How to change the name of the entry point file in Flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm relatively inexperienced Python user and completely new to Flask, so I am sure this is dumb, but...\nI had a file that acted as an entry point for Flask, named some_silly_name.py which contains the line app = Flask(__name__). The server was running fine, until I decided that that name was silly, so I renamed the file to a_much_better_name.py. Now on flask run I get the error Error: Could not import \"some_silly_name\".\nWhat do I need to do to change the name of this file and still have Flask run?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1586,"Q_Id":55617913,"Users Score":2,"Answer":"You did actually set an environment variable with:\nexport FLASK_APP=some_silly_name.py\n(Or with set instead of export on Windows). Even if you change your entry point file name and correct all references to the original file within the app, you'll need to re-set this variable to point to the new entry point.","Q_Score":1,"Tags":"python,python-3.x,flask","A_Id":55618193,"CreationDate":"2019-04-10T17:05:00.000","Title":"How to change the name of the entry point file in Flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Let\u2019s say I have 100 data points, consisting of two values (x,y or V1, V2).  \nRight now I am defining a  bunch of functions (like log, exp, poly, sigmoid etc.) with a bunch of parameters to scale the data and\/or adapt the base-equation. Then I use scipy.optimize.minimize to fit them to the data. After that I compare the fits visually  and by their rms to choose the best one.\nIs there a python module which does that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":55619624,"Users Score":0,"Answer":"In scipy there is curve_fit but I believe you have to define the curve that is going into it.","Q_Score":0,"Tags":"python,curve-fitting,data-fitting","A_Id":55619709,"CreationDate":"2019-04-10T19:02:00.000","Title":"Is there a module which tries to fit different functions to set of data points?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Django and in my Django application, I have a model that contains the basic information about a vehicle (name, model, make, year). I add the information through a form. The issue is that if the user were to enter \"alert(\"error\")\" then the form will allow it and it will be saved as valid input. So when the page refreshes, there will be an alert on the page and the field will now be blank. How to I prevent the user from entering JavaScript in the CharField?\nI do not have 'autoescape off' anywhere in the code base nor do I use the 'safe' keyword in the html. I do not have the 'def clean' checking for such input as I was under the impression that Django would take care of such injection. Thanks in advance!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":150,"Q_Id":55620232,"Users Score":2,"Answer":"It's perfectly valid input. But it won't result in an alert on the page - because Django automatically escapes output.","Q_Score":1,"Tags":"javascript,python,django,xss","A_Id":55621423,"CreationDate":"2019-04-10T19:44:00.000","Title":"How come Django allows user to enter  in form CharField without throwing an error?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For classification algorithm KNeighborsClassifier what does fitting on a sparse input mean?\nDoes it mean if I have x_train and x_test as sparse csr matrix and If I fit on x_train and don't specify algorithm it will automatically choose brute? can anyone clear this confusion.\n\nalgorithm : {\u2018auto\u2019, \u2018ball_tree\u2019, \u2018kd_tree\u2019, \u2018brute\u2019}, optional\nAlgorithm used to compute the nearest neighbors:\nNote: fitting on sparse input will override the setting of this parameter,\nusing brute force.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":133,"Q_Id":55620365,"Users Score":1,"Answer":"No, it means that if the input is sparse, whichever value passed to the argument algorithm will be ignored and brute force algorithm will be used (which is equivalent to algorithm='brute')","Q_Score":2,"Tags":"python,scikit-learn","A_Id":55621089,"CreationDate":"2019-04-10T19:53:00.000","Title":"Algorithm used in KNeighborsClassifier with sparse input?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"hello i want to install python package deepMatcher i used pip command \npip install deepmatcher\nget this error :\n\nCould not find a version that satisfies the requirement torch==0.3.0\n  (from deepmatcher) (from versions: 0.1.2, 0.1.2.post1 No matching\n  distribution found for torch==0.3.0 (from deepmatcher)\n\npython 3;6\nwindows 10","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":55622216,"Users Score":0,"Answer":"Instead of using torch try using 'torchtext==0.2.3' instead. Deepmatcher has a lot of dependency issues, especially with the torch package.","Q_Score":2,"Tags":"python-3.x,machine-learning,deep-learning,package,installation-package","A_Id":66909298,"CreationDate":"2019-04-10T22:36:00.000","Title":"i have problem with package installation deepmatcher","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a problem during feature engineering. Looking for some suggestions.   Problem statement: I have usage data of multiple customers for 3 days. Some have just 1 day usage some 2 and some 3. Data is related to number of emails sent \/ contacts added on each day etc.\nI am converting this time series data to column-wise ie., number of emails sent by a customer on day1 as one feature, number of emails sent by a customer on day2 as one feature and so on.\nBut problem is that, the usage can be of either increasing order or decreasing order for different customers.\nie., example 1:  customer 'A' --> 'number of emails sent on 1st . day' = 100 .  ' number of emails sent on 2nd day'=0\nexample 2: customer 'B' --> 'number of emails sent on 1st . day' = 0 .  ' number of emails sent on 2nd day'=100\nexample 3: customer 'C' --> 'number of emails sent on 1st . day' = 0 .  ' number of emails sent on 2nd day'=0\nexample 4: customer 'D' --> 'number of emails sent on 1st . day' = 100 .  ' number of emails sent on 2nd day'=100\nIn the first two cases => My new feature will have \"-100\" and \"100\" as values. Which I guess is good for differentiating.\nBut the problem arises for 3rd and 4th columns when the new feature value will be \"0\" in both scenarios\nCan anyone suggest a way to handle this","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":106,"Q_Id":55623095,"Users Score":1,"Answer":"You can extract the following features:\n\nSimple Moving Averages for day 2 and day 3 respectively. This means you now have two extra columns.\nPercentage Change from previous day\nPercentage Change from day 1 to 3","Q_Score":2,"Tags":"python,machine-learning,data-science,feature-engineering","A_Id":58826866,"CreationDate":"2019-04-11T00:35:00.000","Title":"Suggestions for feature engineering","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Some background: I have set up Airflow on Kubernetes (on AWS). I am able to run DAGs that query a database, send emails or do anything that doesn't require a package that isn't already a part of Airflow. For example, if I try to run a DAG that uses the Facebook-business SDK the DAG will obviously break because the dependency isn't available. I've tried a couple different ways of trying to get this dependency, along with others, installed but haven't been successful. \nI have tried to install python packages by modifying my scheduler and webserver deployments to do a pip install of my dependencies as part of an initContainer. When I do this, the DAG remains broken as it is unable to find the needed packages. When I open a shell to my pod I can see that the dependencies have not been installed (I check using pip list). I have also verified that there aren't other python\/pip versions installed. \nI have also tried to install the dependencies by running a pip install when I open a shell to my pod. This way is successful in installing the dependency in the correct place and also makes it available. However, instead of the webserver UI showing that my DAG is broken, I get the this dag isn't available in the webserver dagbag object message. \nI would expect that running pip install as part of my initContainer or container would makes these dependencies available in my pod. However, this isn't the case. It's as if pip install runs without any issues, but by the time my pods are fully set up the python packages are nowhere to be found\nI forgot to say that I have found a way to make it work, but it feels somewhat hacky and like there should be a better way\n- If I open a shell to my webserver container and install the needed dependencies and then open a shell to my scheduler and do the same thing, the dependencies are found and the DAG works.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4095,"Q_Id":55623219,"Users Score":1,"Answer":"The init container is a separate docker instance.  Unless you rig up some sort of shared storage for your python libraries (which is quite dubious) any pip installs in the init container won't impact the running container of the pod.  \nI see two options:\n1) Modify the docker image that you're using to include the packages you need\n2) Prepend a pip install to the command being run in the pod.  It's not uncommon to string together a few commands with && between them, in order to execute a sequence of operations in a starting pod.","Q_Score":4,"Tags":"python,kubernetes,pip,airflow","A_Id":55624133,"CreationDate":"2019-04-11T00:57:00.000","Title":"Is there a specific way to install python packages on pods?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to remove the last several columns from a data frame.  However I get a syntax error when I do this:\ndb = db.drop(db.columns[[12:22]], axis = 1)\nThis works but it seems clumsy...\ndb = db.drop(db.columns[[12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]], axis = 1)\nHow do I refer to a range of columns?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":55623798,"Users Score":0,"Answer":"Steven Burnap's explanation is correct, but the solution can be simplified - just remove the internal parentheses:\ndb = db.drop(db.columns[12:22], axis = 1)\nthis way, db.columns[12:22] is a 'slice' of the columns array (actually index, but doesn't matter here), which goes into the drop method.","Q_Score":0,"Tags":"python,pandas","A_Id":55625183,"CreationDate":"2019-04-11T02:25:00.000","Title":"Syntax Error In Python When Trying To Refer To Range Of Columns","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to remove the last several columns from a data frame.  However I get a syntax error when I do this:\ndb = db.drop(db.columns[[12:22]], axis = 1)\nThis works but it seems clumsy...\ndb = db.drop(db.columns[[12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]], axis = 1)\nHow do I refer to a range of columns?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":99,"Q_Id":55623798,"Users Score":1,"Answer":"The first example uses [12:22] is a \"slice\" of nothing.  It's not a meaningful statement, so as you say, it gives a syntax error.  It seems that what you want is a list containing the numbers 12 through 22.  You need to either write it out fully as you did, or use some generator function to create it.\nThe simplest is range, which is a generator that creates a list of sequential values.  So you can rewrite your example like:\ndb = db.drop(db.columns[list(range(12,23)]], axis = 1)\nThough it looks like you are using some sort of library.  If you want more detailed control, you need to look the documentation of that library.  It seems that db.columns is an object of a class that has defined an array operator.  Perhaps that class's documentation shows a way of specifying ranges in a way other than a list.","Q_Score":0,"Tags":"python,pandas","A_Id":55623865,"CreationDate":"2019-04-11T02:25:00.000","Title":"Syntax Error In Python When Trying To Refer To Range Of Columns","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I want to evaluate the performance of my model on the validation set, is it preferred to use with torch.no_grad: or model.eval()?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":16936,"Q_Id":55627780,"Users Score":1,"Answer":"If you're reading this post because you've been encountering RuntimeError: CUDA out of memory, then with torch.no grad(): will likely to help save the memory. Using only model.eval() is unlikely to help with the OOM error.\nThe reason for this is that torch.no grad() disables autograd completely (you can no longer backpropagate), reducing memory consumption and speeding up computations.\nHowever, you will still be able to call the gardients when using model.eval(). Personally, I find this design decision intriguing. So, what is the purpose of .eval()? It seems its main functionality is to deactivate the Dropout during the evaluation time.\nTo summarize, if you use torch.no grad(), no intermediate tensors are saved, and you can possibly increase the batch size in your inference.","Q_Score":53,"Tags":"python,machine-learning,deep-learning,pytorch,autograd","A_Id":70600860,"CreationDate":"2019-04-11T08:16:00.000","Title":"Evaluating pytorch models: `with torch.no_grad` vs `model.eval()`","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Memory Error when I run np.arange() with large number like 1e10.\nhow can I fix Memory Error on np.arange(0.01*1e10,100*1e10,0.5)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":195,"Q_Id":55628673,"Users Score":0,"Answer":"You are trying to create an array of roughtly 2e12 elements. If every element was to be a byte, you would need approximately 2Tb of free memory to allocate it. Not sure you have so much ram available, that is why you have the memory error.\nNote: the array you are trying to allocate contains floats, so it is even bigger. Do you really need so much elements?\nHope it helps,","Q_Score":0,"Tags":"python,numpy,memo","A_Id":55628823,"CreationDate":"2019-04-11T09:06:00.000","Title":"how can I fix Memory Error on np.arange(0.01*1e10,100*1e10,0.5)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I came across this piece of code\n(x_train, y_train), (x_test, y_test) = mnist.load_data()\nprint(\"Shape of x_train: \" + str(x_train.shape))\nprint(\"Shape of y_train: \" + str(y_train.shape))\nAnd found that the output looks like this\n(60000, 28, 28)\n(60000,)\nFor the first line of output\nSo far my understanding, does it means that in 1st dimension it can hold 60k items, then in next dimension, it can hold 28 \"array of 60k items\"\nand finally, in the last dimension, it can hold 28 \"array of 28 \"array of 60k items\"\"\nWhat I want to clarify is, Is this 60k samples of 28x28 data or something else?\nFor the second line of output, it seems like its just a 1d array of 60k items. So what does it actually represents? (i know that in x_train it was handwritten numbers and each number represents the intensity of grey in that cell)\nPlease note I have taken this code from some online example(i don't remember and won't mind if you want your credit to be added to this) and public dataset\ntf.keras.datasets.mnist","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":67,"Q_Id":55629163,"Users Score":1,"Answer":"Your understanding of the shapes is correct. From the context probably the x_train are 60k images of handwritten numbers (with resolution 28x28 pixel) and the y_train are simply the 60k true number, which the images show.","Q_Score":2,"Tags":"python,tensorflow,machine-learning,pytorch","A_Id":55629272,"CreationDate":"2019-04-11T09:30:00.000","Title":"Shape of tensor","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I came across this piece of code\n(x_train, y_train), (x_test, y_test) = mnist.load_data()\nprint(\"Shape of x_train: \" + str(x_train.shape))\nprint(\"Shape of y_train: \" + str(y_train.shape))\nAnd found that the output looks like this\n(60000, 28, 28)\n(60000,)\nFor the first line of output\nSo far my understanding, does it means that in 1st dimension it can hold 60k items, then in next dimension, it can hold 28 \"array of 60k items\"\nand finally, in the last dimension, it can hold 28 \"array of 28 \"array of 60k items\"\"\nWhat I want to clarify is, Is this 60k samples of 28x28 data or something else?\nFor the second line of output, it seems like its just a 1d array of 60k items. So what does it actually represents? (i know that in x_train it was handwritten numbers and each number represents the intensity of grey in that cell)\nPlease note I have taken this code from some online example(i don't remember and won't mind if you want your credit to be added to this) and public dataset\ntf.keras.datasets.mnist","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":55629163,"Users Score":1,"Answer":"You are right the first line gives 60K items of 28x28 size data thus (60000, 28, 28).\nThe y_train are labels of the x_train. Thus they are a one dimensional and 60k in number.\nFor example: If the first item of the x_train is a handwritten image of 3, then the first item of y_train will be '3' which is the label.","Q_Score":2,"Tags":"python,tensorflow,machine-learning,pytorch","A_Id":55629310,"CreationDate":"2019-04-11T09:30:00.000","Title":"Shape of tensor","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a word embeddings model (FastText via Gensim library) to expand the terms of a search. \nSo, basically if the user write \"operating system\" my goal is to expand that term with very similar terms like \"os\", \"windows\", \"ubuntu\", \"software\" and so on.\nThe model works very well but now the time has come to improve the model with \"external information\", with \"external information\" i mean OOV (out-of-vocabulary) terms OR terms that do not have good context.\nFollowing the example i wrote above when the user writes operating system i would like to expand the query with the \"general\" terms:\nTerms built in the FastText model:\n\nwindows \nubuntu\nsoftware\n\nAND \nterms that represent (organizations\/companies) like \"Microsoft\", \"Apple\" so the complete query will be:\n\nterm: operating system\nquery: operating system, os, software, windows, ios, Microsoft, Apple\n\nMy problem is that i DO NOT have companies inside the corpus OR, if present, i do not have to much context to \"link\" Microsoft to \"operating system\".\nFor example if i extract a piece inside the corpus i can read \"... i have started working at Microsoft in November 2000 with my friend John ...\" so, as you can see, i cannot contextualize \"Microsoft\" word because i do not have good context, indeed.\nA small recap:\n\nI have a corpus where the companies (terms) have poor context\nI have a big database with companies and the description of what they do.\n\nWhat i need to do:\nI would like to include the companies in my FastText model and set \"manually\" their words context\/cloud of related terms.\nIdeas?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":754,"Q_Id":55629368,"Users Score":1,"Answer":"These kinds of models need numerous, varied usage examples to place a token in a relatively good place, at meaningful distances\/directions from other related tokens. If you don't have such examples, or your examples are few\/poor, there's little way the algorithm can help. \nIf you somehow know, a priori, that 'microsoft' should appear in some particular vector coordinates, then sure, you could patch the model to include that word->vector mapping. (Though, such model classes often don't include convenient methods for such incremental additions, because it's expected words are trained in bulk from corpuses, not dictated individually.)\nBut if you don't have example text for some range of tokens, like company names, you probably don't have independent ideas of where those tokens should be, either. \nReally, you need to find adequate training data. And then, assuming you want the vectors for these new terms to be in the \"same space\" and comparable to your existing word-vectors, combine that with your prior data, and training all the data together into one combined model. (And further, for an algorithm like FastText to synthesize reasonable guess-vectors for never-before-seen OOV words, it needs lots of examples of words which have overlapping meanings and overlapping character-n-gram fragments.)\nExpanding your corpus to have better training data for, say, 100 target organization names might be as simple as scraping sentences\/paragraphs including those names from available sources, like Wikipedia or the web. \nBy gathering dozens (or even better hundreds or thousands) of independent examples of the organization names in real language contexts, and because those contexts include many mutually-shared other words, or names of yet other related organizations, you'd be able induce reasonable vectors for those terms, and related terms.","Q_Score":1,"Tags":"python,machine-learning,nlp,gensim","A_Id":55634269,"CreationDate":"2019-04-11T09:40:00.000","Title":"How to add OOV terms in a word embeddings model","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to record youtube live stream and save it to file using python.\nI tried with pytube library but it probably works for videos, not for live streams.\nI want to record stream and save it to file with video format as avi or something like this.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2993,"Q_Id":55631634,"Users Score":0,"Answer":"I found a solution and i put my code in python:\nimport urllib\nimport m3u8\nimport streamlink\n\n\ndef record_stream(url,filename,iterations):\n    last_part = 0\n    for i in range(iterations+1):\n\n        streams = streamlink.streams(url)\n        stream_url = streams[\"best\"]\n        print(stream_url.args['url'])\n\n        m3u8_obj = m3u8.load(stream_url.args['url'])\n\n        previous_part_time = last_part\n        last_part = m3u8_obj.segments[-1].program_date_time\n\n        if i >= 1:\n         for j in range(1, len(m3u8_obj.segments)):\n            if m3u8_obj.segments[-j].program_date_time == previous_part_time:\n               break\n\n         print(j)\n\n         file = open(filename + \".ts\", \"ab+\")\n         for i in range(j-1,0,-1):\n            with urllib.request.urlopen(m3u8_obj.segments[-i].uri) as response:\n               html = response.read()\n               file.write(html)\n\n\nurl = \"https:\/\/www.youtube.com\/watch?v=BgKGctL0u1U\"\nrecord_stream(url,\"file\",10)\n10 means 10 iterations if chunks have 2s it means that records 20s of stream","Q_Score":2,"Tags":"python,youtube,pytube","A_Id":56020466,"CreationDate":"2019-04-11T11:39:00.000","Title":"Recording youtube live stream to file in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a 4-cluster k-means customer segmentation in scikit learn (Python). The idea is that every month, the business gets an overview of the shifts in size of our customers in each cluster.\nMy question is how to make these clusters 'durable'. If I rerun my script with updated data, the 'boundaries' of the clusters may slightly shift, but I want to keep the old clusters (even though they fit the data slightly worse).\nMy guess is that there should be a way to extract the paramaters that decides which case goes to their respective cluster, but I haven't found the solution yet.\nI would appreciate any help","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":454,"Q_Id":55631944,"Users Score":1,"Answer":"Got the answer in a different topic: \nJust record the cluster means. Then when new data comes in, compare it to each mean and put it in the one with the closest mean.","Q_Score":1,"Tags":"python,scikit-learn,k-means","A_Id":55648613,"CreationDate":"2019-04-11T11:57:00.000","Title":"KMeans: Extracting the parameters\/rules that fill up the clusters","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am setting up a script for counting number of days with passing each day in odoo.\nHow i can count day passing each day till end of the month.\nFor example : i have set two dates to find days between them.I need  function which compare number of days with each passing day. When meet remaining day is 0 then will call a cron job.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":55633617,"Users Score":0,"Answer":"Write a scheduled action that runs python code daily. The first thing that this code should do is to check the number of days you talk about and if it is 0, it should trigger whatever action it is needed.","Q_Score":0,"Tags":"python,odoo","A_Id":55644031,"CreationDate":"2019-04-11T13:25:00.000","Title":"how to count number of days via cron job in odoo 10?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed Anaconda3.7, 64 bit for windows. I used Anaconda Navigator to launch jupyter notebook. The notebook opened, but when I try to launch a kernel\/notebook I get the following error:\n\nThe code execution cannot proceed because python37.dll was not found. Reinstalling the program may fix this problem. \n\nI even tried launching jupyter from the command prompt and the anaconda prompt but it doesn't work. In those cases, jupyter tries to restart the kernel 5 times and just quits after no success. \nI have the python37.dll file inside the Anaconda3 folder next to the python.exe and I tried adding python37 to PATH, but nothing helps. \nAny clue what might be the problem?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":9815,"Q_Id":55635244,"Users Score":1,"Answer":"I solved the issues by doing 2 things:\n\nI uninstalled Anaconda and deleted all hidden files and folders that had to do with conda, anaconda, jupyter and python that were created recently. \nI disabled the antivirus and firewall while installing (it appears that they were blocking some dll and Anaconda files from being installed correctly).\nI reinstalled Anaconda\n\nI had the same problem with the firewall after installing anaconda. I tried creating a virtual environment with \"conda env create -f \"environment.yml\" but it never completed the creation until I disabled the firewall and antivirus.\nI hope this helps others with similar issues.","Q_Score":2,"Tags":"python,dll,jupyter-notebook","A_Id":55644804,"CreationDate":"2019-04-11T14:41:00.000","Title":"Why do I get a python37.dll error when starting jupyter notebook via conda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed Anaconda3.7, 64 bit for windows. I used Anaconda Navigator to launch jupyter notebook. The notebook opened, but when I try to launch a kernel\/notebook I get the following error:\n\nThe code execution cannot proceed because python37.dll was not found. Reinstalling the program may fix this problem. \n\nI even tried launching jupyter from the command prompt and the anaconda prompt but it doesn't work. In those cases, jupyter tries to restart the kernel 5 times and just quits after no success. \nI have the python37.dll file inside the Anaconda3 folder next to the python.exe and I tried adding python37 to PATH, but nothing helps. \nAny clue what might be the problem?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":9815,"Q_Id":55635244,"Users Score":0,"Answer":"Errors related to python37.dll can arise for a few different reasons. For instance, a faulty application, python37.dll has been deleted or misplaced, corrupted by malicious software present on your PC or a damaged Windows registry.\nFor anaconda its caused due to pip installing library into anaconda environment instead of using the conda package manager.\nSo you can download a python37.dll file online and move it to you anaconda directory which should solve the issue.\nCheck this anaconda issue might be related\nhttps:\/\/github.com\/ContinuumIO\/anaconda-issues\/issues\/1394\nHope it helps.","Q_Score":2,"Tags":"python,dll,jupyter-notebook","A_Id":55635376,"CreationDate":"2019-04-11T14:41:00.000","Title":"Why do I get a python37.dll error when starting jupyter notebook via conda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to permute \"dimensions\" along a single axis of a tensor?\nSomething akin to tf.transpose, but at the level of \"dimensions\" along an axis, instead of at the level of axes.\nTo permute them randomly (along the first axis), there it tf.random.shuffle, and to shift them, there is tf.roll. But I can't find a more general function that would apply any given permutation.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":321,"Q_Id":55637345,"Users Score":2,"Answer":"tf.gather can be used to that end. In fact, it is even more general, as the indices it takes as one of its inputs don't need to represent a permutation.","Q_Score":1,"Tags":"python,tensorflow","A_Id":55637346,"CreationDate":"2019-04-11T16:35:00.000","Title":"Applying a permutation along one axis in TensorFlow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Apache Beam to read data from Google Cloud Datastore with the help of Beam's own io.gcp.datastore.v1.datastoreio Python APIs.\nI run my pipeline on Google Cloud Dataflow.\nI want to ensure that my workers are not overloaded with data.\nHow can I read data in batches or ensure using some other mechanism that my workers are not pulling a huge amount of data in one go?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":55638369,"Users Score":0,"Answer":"Dataflow automatically does this for you. By default, datastoreio breaks your files into 64MB chucks. If you want to break them up into smaller pieces, use the num_splits parameter on the initializer to specify how many pieces to break each file into.","Q_Score":0,"Tags":"python,google-cloud-datastore,google-cloud-dataflow,apache-beam","A_Id":55717280,"CreationDate":"2019-04-11T17:42:00.000","Title":"Read records in batches from Google Cloud Datastore using Apache Beam","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Levenshtein distance is an approach for measuring the difference between words, but not so for phrases.\nIs there a good distance metric for measuring differences between phrases?\nFor example, if phrase 1 is made of n words x1 x2 x_n, and phrase 2 is made of m words y1 y2 y_m. I'd think they should be fuzzy aligned by words, then the aligned words should have a score about how similar they are, and some kind of gap penalty should be applied for non aligned words. These positive scores and negative scores should be aggregated in some way. There seem to be some heuristics involved.\nIs there an existing solution for measuring the similarity between phrases? Python is preferred but other solution is also fine. Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":574,"Q_Id":55638949,"Users Score":1,"Answer":"You can also measure the similarity between two phrases using Levenshtein distance, threating each word as a single element. When you have strings of unequal sizes you can use the Smith-Waterman or the Needleman-Wunsch algorithm. Those algorithms are widely used in bioinformatics and the implementation can be found in the biopython package. \nYou can also tokenize the words in the phrases and measure the frequency of each token in each phrase, that will result in an array of frequencies for each phrase. From that array you can measure the pairwise similarity using any vector distance such as euclidean distance or cosine similarity. The tokenization of the phrases can be done with the nltk package, and the distances can be measured with scipy. \nHope it helps.","Q_Score":0,"Tags":"python,similarity,levenshtein-distance,sentence-similarity","A_Id":55645447,"CreationDate":"2019-04-11T18:22:00.000","Title":"similarity score between phrases","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know if there is a way to add entities to a group programmatically using Python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":55640058,"Users Score":0,"Answer":"After surf and watch the source code of Home assistant I found the solution and there are 2 ways:\nimport homeassistant.components.group as group\ntest_group = group.Group.create_group(\nhass, 'your_group', ['device_tracker.your_device'])\nand this other way:\nhass.states.set('group.your_group', 'on', {\n        'entity_id': ['device_tracker.csp1_zte_com_cn', 'device_tracker.your_device']})\nI prefer the last one but both were tested and worked perfectly","Q_Score":0,"Tags":"python,home-assistant","A_Id":55776495,"CreationDate":"2019-04-11T19:41:00.000","Title":"Is possible to add entities to a group programmatically in Home Assistant?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to rename a number of files using Python so that they follow a new naming convention that looks like: \n~\/directory\/yyyy + qq + directory_name + ' Letter'.\nRight now, they are in this format:\n~\/directory\/directory_name + yyyy + qq + ' Letter'.\nSo for example, I have a directory called \/Users\/Test\/rename_test\/Salmon 2, and in it are the following files:\n\n\/Users\/Test\/rename_test\/Salmon 2\/Salmon 2 2013 Q4 Letter.pdf\n\/Users\/Test\/rename_test\/Salmon 2\/Salmon 2 2018 Q1 Letter.pdf\n\/Users\/Test\/rename_test\/Salmon 2\/Salmon 2 2015 Q2 Letter.pdf\n\nI'd like to rename all of those files to:\n\n\/Users\/Test\/rename_test\/Salmon 2\/2013 Q4 Salmon 2 Letter.pdf\n\/Users\/Test\/rename_test\/Salmon 2\/2018 Q1 Salmon 2 Letter.pdf\n\/Users\/Test\/rename_test\/Salmon 2\/2015 Q2 Salmon 2 Letter.pdf\n\nI've looked at using os.split to extract positions [-2] and [-3]\u2014since those should always be qq and yyyy\u2014and then renaming the file by moving them to positions [0] and [1]. But I have hundreds of directories and thousands of files so I'm worried that one typo or file that deviates from the current convention may result in an error.\nSo what's the best way to approach this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":171,"Q_Id":55640247,"Users Score":0,"Answer":"Your idea is basically sound - but you could add at least two steps to make it safer:\n\nemploy a regex which detects your format and raises an error if it does not match. E.g. your regex could look like this:\n^Salmon 2 \\d{4} Q\\d{1} Letter \n\nYou would need to replace Salmon 2 thorugh a variable which contains your current dir name \n\nAdd a \"dry run\" mode - where the conversions are just printed to stdout - so you can see what would happen.\nWhatever you do, make a backup FIRST.\n\nBonus: I would probably use pathlib and its commands for this job - it's a more versatile interface than the old \"files name are just strings\" methods.","Q_Score":0,"Tags":"python,split,rename,glob","A_Id":55640313,"CreationDate":"2019-04-11T19:57:00.000","Title":"How to Rename Parts of Filename in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I have a text composed by any kind of symbols, like:\nstring = 1234abdchdj\u661f\u671f\u4e0a\u5348\u5341\u65f6*&()\nI want to find the character bi-grams with regular expression, to get an output like:\n12, 23, 34, ab, bd, ...\nI am actually using the following, with python and regex:\nbigrams = re.findall('(?=(\\S\\S))', string)\nbut this gives me the wrong output since it misses characters and gives me actually half of the bi-grams I need:\n12, 34, ab, dc, ...\nHope I've been clear enough, thank you in advance","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":56,"Q_Id":55640914,"Users Score":1,"Answer":"This is going to be hard if not impossible because you are trying to use a regular expression to solve a problem it isn't intended to solve. You can do this pretty cleanly in one line of python.\nans = [x[i:i+2] for i in range(0, len(x)-1, 2)]","Q_Score":1,"Tags":"python,regex","A_Id":55641101,"CreationDate":"2019-04-11T20:47:00.000","Title":"Regular expression for any characters bi-grams","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using getstream.io to create feeds. The user can follow feeds and add reaction like and comments. If a user adds a comment on feed and another wants to reply on the comment then how I can achieve this and also retrieve all reply on the comment.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":583,"Q_Id":55644656,"Users Score":0,"Answer":"you can add the child reaction by using reaction_id","Q_Score":1,"Tags":"python,getstream-io","A_Id":55813711,"CreationDate":"2019-04-12T04:46:00.000","Title":"How to add reply(child comments) to comments on feed in getstream.io python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Guies:\nI used python with netmiko module to save the configuration from our h3c switch,but it stopped at the \"NO MORE\" status, and the script stopped until timeout.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":55647524,"Users Score":0,"Answer":"line vty 0 4\n  screen-length 0\n^_^","Q_Score":0,"Tags":"python","A_Id":55648921,"CreationDate":"2019-04-12T08:31:00.000","Title":"using python netmiko to save h3c switch config and meet the no more","Data Science and Machine Learning":0,"Database and SQL":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 implementing an application that tracks the locations of Australia's sharks through analysing a Twitter dataset. So I'm using shark as the keyword and search for the Twitts that contains \"shark\" and a location phrase.  \nSo the question is how to identify that \"Airlie Beach at Hardy Reef\" is the one that is correlated to \"shark\"? If it's possible, can anyone provide a working code of Python to demonstrate\u200b? Thank you so much!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":67,"Q_Id":55649003,"Users Score":1,"Answer":"If you've already used NER to extract a list of locations, could you then create a table of target words and assign probabilities of being the correct location? For example, you are interested in beaches not hospitals. If beach is mentioned within the location, the probability of being the correct location increases. Another hacky way of doing it might be determining the number of characters or tokens between the word shark and the location - hoping that the smaller the distance, the more likely the word is to be related to the actual attack.","Q_Score":0,"Tags":"python,nlp","A_Id":55653869,"CreationDate":"2019-04-12T09:53:00.000","Title":"Extract the most relevant location corresponding to a keyword","Data Science and Machine Learning":0,"Database and SQL":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":"Currently support for tensorflow is only Python <=3.6\nWhat timeline for tensorflow support for Python 3.7 ? \nSo that I know if i uninstall Python 3.7  or wait.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":94,"Q_Id":55649030,"Users Score":2,"Answer":"Python 3.7 appears to be official now, (\"final release\" on June 27th).","Q_Score":0,"Tags":"python,tensorflow","A_Id":55649241,"CreationDate":"2019-04-12T09:54:00.000","Title":"Tensorflow Python 3.7 when","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was just fooling around in the Python console when I noticed these four results of four simple one line statements:\n1. \"x\".endswith(\"\")\nTrue\n2. \"x\".endswith(\"x\")\nTrue\nThen I tried to strip the white-spaces from the statement, when they gave me these results:\n3. \"x\".strip().endswith(\"\")\nTrue\n4. \"x\".strip().endswith(\"x\")\nTrue\nHow can all of the results be True? How can a string function return True for ending with both \"x\" and \"\"? Isn't this contradictory or am I missing something here?\nPython 2.7 on PyCharm on Windows 10.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":493,"Q_Id":55650286,"Users Score":0,"Answer":"The .strip() function removes all whitespace at the start and end of the string it's called on. Your string, \"x\", has no whitespace around it, so it will not change in any way (you can check this by running \"x\" == \"x\".strip().\nYou are also checking whether it ends with the empty string, which every string in Python does!\nAdd some whitespace to your string (eg \"x  \"), and use a whitespace character in your endswith call (eg \"x . \".endswith(\" \")) to get a good idea of how the strip() function works.","Q_Score":4,"Tags":"python","A_Id":55650378,"CreationDate":"2019-04-12T11:08:00.000","Title":"endswith() function of a string gives contradictory results","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was just fooling around in the Python console when I noticed these four results of four simple one line statements:\n1. \"x\".endswith(\"\")\nTrue\n2. \"x\".endswith(\"x\")\nTrue\nThen I tried to strip the white-spaces from the statement, when they gave me these results:\n3. \"x\".strip().endswith(\"\")\nTrue\n4. \"x\".strip().endswith(\"x\")\nTrue\nHow can all of the results be True? How can a string function return True for ending with both \"x\" and \"\"? Isn't this contradictory or am I missing something here?\nPython 2.7 on PyCharm on Windows 10.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":493,"Q_Id":55650286,"Users Score":1,"Answer":"If you want to check if a string ends with a space try \"x \"\nFor example, \"x \".endswith(\" \") returns True, but \"x \".strip().endswith(\" \") returns False.\n\"\" is an empty character, what you are trying to do wont work. The space character is presented like this: \" \".","Q_Score":4,"Tags":"python","A_Id":55650335,"CreationDate":"2019-04-12T11:08:00.000","Title":"endswith() function of a string gives contradictory results","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried using the similarity function of spacy to get the best matching sentence in a document. However it fails for bullet points because it considers each bullet as the a sentence and the bullets are incomplete sentences (eg sentence 1 \"password should be min 8 characters long , sentence 2 in form of a bullet \" 8 characters\"). It does not know it is referring to password and so my similarity comes very low.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":55651267,"Users Score":0,"Answer":"Bullets are considered but the thing is it doesn't understand  who 8 characters is referring to so I thought of finding the heading of the paragraph  and replacing the bullets with it  \nI found the headings using python docs but it doesn't read bullets while reading the document  ,is there  a way I can read it using python docs ? \nIs there any way I can find the headings of a paragraph  in spacy?\nIs there  a better  approach  for it","Q_Score":0,"Tags":"python-3.x,spacy","A_Id":55677993,"CreationDate":"2019-04-12T12:06:00.000","Title":"how to find the similarity between two documents","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried using the similarity function of spacy to get the best matching sentence in a document. However it fails for bullet points because it considers each bullet as the a sentence and the bullets are incomplete sentences (eg sentence 1 \"password should be min 8 characters long , sentence 2 in form of a bullet \" 8 characters\"). It does not know it is referring to password and so my similarity comes very low.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":55651267,"Users Score":0,"Answer":"Sounds to me like you need to do more text processing before attempting to use similarity. If you want bullet points to be considered part of a sentence, you need to modify your spacy pipeline to understand to do so.","Q_Score":0,"Tags":"python-3.x,spacy","A_Id":55655171,"CreationDate":"2019-04-12T12:06:00.000","Title":"how to find the similarity between two documents","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write some code in python to retrieve some data from Infoblox. To do this i need to Import the Infoblox Module.\nCan anyone tell me how to do this ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":55653169,"Users Score":0,"Answer":"Before you can import infoblox you need to install it:\n\nopen a command prompt (press windows button, then type cmd)\nif you are working in a virtual environment access it with activate yourenvname (otherwise skip this step)\nexecute pip install infoblox to install infoblox, then you should be fine\nto test it from the command prompt, execute python, and then try executing import infoblox\n\nThe same process works for basically every package.","Q_Score":0,"Tags":"python","A_Id":55653452,"CreationDate":"2019-04-12T13:48:00.000","Title":"Trying to Import Infoblox Module in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There are few (< 10) collections, for each collections I need to apply a fixed operation to certain fields of a document (will vary collection to collection). The operation needs to be applied to almost all fields, except few.\nAn approach I could think of:\n\nTo have a list of fields for each collection to which I needn't apply that operation, read all fields minus the ones present in the list and apply the operation.\n\nIs there a better way to tackle this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11,"Q_Id":55655414,"Users Score":0,"Answer":"yes if the number of exluded fields is very < to included fields, your approach seems right.\nbut As far as I know there is now way of sending a complete document to a mongo[s|d] and tell it to only skip certain fields.","Q_Score":0,"Tags":"python,json,mongodb,pymongo","A_Id":55655609,"CreationDate":"2019-04-12T15:53:00.000","Title":"Apply an operation to almost all fields of a document in MongodDB?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Our team uses labelMe for annotating images. I received a batch of annotations that are in VOC format and need to open them in labelMe for review, but am having trouble convert them to the labelMe format. \nI can get all the fields that the labelMe json file needs, except for \"imageData\", which looks like some kind of encoding of the image data. \nI've tried leaving it out, hoping that having the image path would be enough, but I get a imageData error.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":434,"Q_Id":55657182,"Users Score":2,"Answer":"If you run labelme from the terminal you can add the flag --nodata. By doing so you can see what value is put in for the key imageData; namely null. So substituting null for this key should work.","Q_Score":2,"Tags":"python,image","A_Id":56727652,"CreationDate":"2019-04-12T17:50:00.000","Title":"Convert VOC to labelMe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to install Pandas in Project Interpreter under my Project -> Clicked on '+' .. but it says \"Time out\" and shows nothing. So I installed it using \"py -m pip install pandas\" in cmd, but I dont see it under Project Interpreter - there is only pip and setuptools.\nWhat should I do to make it work ?\nI am still getting an error:\n    import pandas as pd\n    ModuleNotFoundError: No module named 'pandas'\nThank you","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":130,"Q_Id":55657228,"Users Score":1,"Answer":"It simply means that the pandas is not installed properly or not even installed at all.\nThe TimeOut error is generally for a connection problem, retry again after some time or try resetting your connection.","Q_Score":1,"Tags":"python,pandas,pycharm","A_Id":55657266,"CreationDate":"2019-04-12T17:54:00.000","Title":"How to use Pandas in Pycharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We've been working on a GUI in tkinter and I'm not sure if it is in python 2 or 3. At first I couldn't get it to run until I changed the import statement from \"from tkinter import *\" to \"from Tkinter import *\". It runs but I'm still not 100% sure if the code is written in python 2. \n(I couldn't share the code since I was getting an error when I tried to post my question)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":166,"Q_Id":55658498,"Users Score":0,"Answer":"Yes, tkinter is nearly identical between python 2 and 3. The imports have changed, but other than that there are no significant differences.","Q_Score":0,"Tags":"python,tkinter","A_Id":55658515,"CreationDate":"2019-04-12T19:44:00.000","Title":"Is tkinter code written the same for python 2 as it is in python 3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm following a book that's teaching me how to make a Learning Log using Python and the Django web framework. I was asked to go to a terminal and create a directory called \"learning_log\" and change the working directory to \"learning_log\" (did that with no problems). However, when I try to create the virtual environment, I get an error (seen at the bottom of this post). Why am I getting this error and how can I fix this to move forward in the book?\nI already tried installing a virtualenv with pip and pip3 (as the book prescribed). I was then instructed to enter the command: \nlearning_log$ virtualenv ll_env\nAnd I get: \nbash: virtualenv: command not found\nSince I'm using Python3.6, I tried: \nlearning_log$ virtualenv ll_env --python=python3\nAnd I still get:\nbash: virtualenv: command not found\nBrandons-MacBook-Pro:learning_log brandondusch$ python -m venv ll_env\nError: Command '['\/Users\/brandondusch\/learning_log\/ll_env\/bin\/python', '-Im', 'ensurepip', '--upgrade', '-\n-default-pip']' returned non-zero exit status 1.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":538,"Q_Id":55659897,"Users Score":0,"Answer":"I had the same error. I restarted my computer and tried it again, but the error was still there. Then I tried python3 -m venv ll_env and it moved forward.","Q_Score":0,"Tags":"macos,terminal,virtualenv,python-3.6,python-venv","A_Id":60223146,"CreationDate":"2019-04-12T21:52:00.000","Title":"Why do I keep getting this error when trying to create a virtual environment with Python 3 on MacOS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"So I'm following a book that's teaching me how to make a Learning Log using Python and the Django web framework. I was asked to go to a terminal and create a directory called \"learning_log\" and change the working directory to \"learning_log\" (did that with no problems). However, when I try to create the virtual environment, I get an error (seen at the bottom of this post). Why am I getting this error and how can I fix this to move forward in the book?\nI already tried installing a virtualenv with pip and pip3 (as the book prescribed). I was then instructed to enter the command: \nlearning_log$ virtualenv ll_env\nAnd I get: \nbash: virtualenv: command not found\nSince I'm using Python3.6, I tried: \nlearning_log$ virtualenv ll_env --python=python3\nAnd I still get:\nbash: virtualenv: command not found\nBrandons-MacBook-Pro:learning_log brandondusch$ python -m venv ll_env\nError: Command '['\/Users\/brandondusch\/learning_log\/ll_env\/bin\/python', '-Im', 'ensurepip', '--upgrade', '-\n-default-pip']' returned non-zero exit status 1.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":538,"Q_Id":55659897,"Users Score":0,"Answer":"For Ubuntu:\nThe simple is if virtualenv --version returns something like virtualenv: command not found and which virtualenv prints nothing on the console, then virtualenv is not installed on your system. Please try to install using pip3 install virtualenv  or sudo apt-get install virtualenv but this one might install a bit older one.\nEDIT\nFor Mac:\nFor Mac, you need to install that using sudo pip install virtualenv after you have installed Python3 on your Mac.","Q_Score":0,"Tags":"macos,terminal,virtualenv,python-3.6,python-venv","A_Id":55660257,"CreationDate":"2019-04-12T21:52:00.000","Title":"Why do I keep getting this error when trying to create a virtual environment with Python 3 on MacOS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am writing a user defined function in python to extract specific chunks of columns from a matrix efficiently.\nMy matrix is 48 by 16240. The data is organised in some pattern column wise.\nMy objective is to make 4 matrices out of it. The first matrix is extracted by selecting the first 70 columns, skip the next 210, select the next 70, skip the next 210, till the end of the matrix. \nThe second matrix is extracted by selecting the second 70 columns, skip the next 210, select the next 70, skip the next 210, till the end of the matrix.\nThe third and the fourth matrix are extracted by selecting the third and the fourth 70 columns respectively, in the same manner as described above.\nAs can be observed, 16240 is dividable by 70. \nIs there a way to have this efficiently done?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":55660812,"Users Score":1,"Answer":"The column index i should satisfy 0 =< i modulo (210+70) <= 70-1","Q_Score":0,"Tags":"python,numpy-slicing","A_Id":55660859,"CreationDate":"2019-04-13T00:02:00.000","Title":"How to select columns from a matrix with an algorithm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The uploaded images are getting overridden every time when a new version of the application is deployed on to Elastic Beanstalk.\nI am deploying Django application and I think I need to do something with the YAML config files but not sure about it.\nMy application has an Image upload feature for the client. Whenever I publish the new version of the application the old one is overwritten along with the removal of the images under the image folder.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":522,"Q_Id":55664445,"Users Score":5,"Answer":"You shouldn't be storing uploaded images to the disk volume on your Elastic Beanstalk server. That disk volume will be deleted when your server is replaced due to deployments or AWS server maintenance. Plus, how would this work if you needed to scale up your Elastic Beanstalk environment to 2 or more servers? Only one server would have the image file.\nThe common solution for this issue is to store the files on S3.","Q_Score":1,"Tags":"python,django,amazon-web-services,amazon-elastic-beanstalk","A_Id":55666192,"CreationDate":"2019-04-13T10:25:00.000","Title":"How to retain images folder while publishing on Elastic Beanstalk?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In gensim I have a trained doc2vec model, if I have a document and either a single word or two-three words, what would be the best way to calculate the similarity of the words to the document? \nDo I just do the standard cosine similarity between them as if they were 2 documents? Or is there a better approach for comparing small strings to documents?\nOn first thought I could get the cosine similarity from each word in the 1-3 word string and every word in the document taking the averages, but I dont know how effective this would be.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":343,"Q_Id":55665180,"Users Score":3,"Answer":"There's a number of possible approaches, and what's best will likely depend on the kind\/quality of your training data and ultimate goals. \nWith any Doc2Vec model, you can infer a vector for a new text that contains known words \u2013 even a single-word text \u2013 via the infer_vector() method. However, like Doc2Vec in general, this tends to work better with documents of at least dozens, and preferably hundreds, of words. (Tiny 1-3 word documents seem especially likely to get somewhat peculiar\/extreme inferred-vectors, especially if the model\/training-data was underpowered to begin with.) \nBeware that unknown words are ignored by infer_vector(), so if you feed it a 3-word documents for which two words are unknown, it's really just inferring based on the one known word. And if you feed it only unknown words, it will return a random, mild initialization vector that's undergone no inference tuning. (All inference\/training always starts with such a random vector, and if there are no known words, you just get that back.)\nStill, this may be worth trying, and you can directly compare via cosine-similarity the inferred vectors from tiny and giant documents alike. \nMany Doc2Vec modes train both doc-vectors and compatible word-vectors. The default PV-DM mode (dm=1) does this, or PV-DBOW (dm=0) if you add the optional interleaved word-vector training (dbow_words=1). (If you use dm=0, dbow_words=0, you'll get fast training, and often quite-good doc-vectors, but the word-vectors won't have been trained at all - so you wouldn't want to look up such a model's word-vectors directly for any purposes.)\nWith such a Doc2Vec model that includes valid word-vectors, you could also analyze your short 1-3 word docs via their individual words' vectors. You might check each word individually against a full document's vector, or use the average of the short document's words against a full document's vector. \nAgain, which is best will likely depend on other particulars of your need. For example, if the short doc is a query, and you're listing multiple results, it may be the case that query result variety \u2013 via showing some hits that are really close to single words in the query, even when not close to the full query \u2013 is as valuable to users as documents close to the full query. \nAnother measure worth looking at is \"Word Mover's Distance\", which works just with the word-vectors for a text's words, as if they were \"piles of meaning\" for longer texts. It's a bit like the word-against-every-word approach you entertained \u2013 but working to match words with their nearest analogues in a comparison text. It can be quite expensive to calculate (especially on longer texts) \u2013 but can sometimes give impressive results in correlating alternate texts that use varied words to similar effect.","Q_Score":1,"Tags":"python,gensim,doc2vec","A_Id":55670156,"CreationDate":"2019-04-13T11:57:00.000","Title":"How do I calculate the similarity of a word or couple of words compared to a document using a doc2vec model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Top Level Problem\nOur team has inherited a very large and brittle python 2 (and C,C++, few others) codebase that is very difficult and costly to update. Tons of dependencies. Very few tests. Adding behavior improvement and converting to python 3 both have appeared to be monumental tasks. Even making small changes for a new release we've had to revert many times as it's broken something.\nIt's a story of insufficient testing and its major technical debt.\nStill, the project is so big and helpful, that it seems a no brainer to update it than re-invent everything it does.\nSub Problem\nHow to add a massive amount of missing small tests. How can we automatically generate even simple input\/output acceptance unit tests from the high level user acceptance tests?\nAttempted Solution\nThere are about 50 large high level behavioral tests that this codebase needs to handle. Unfortunately, it takes days to run them all, not seconds. These exercise all the code we care the most about, but they are just too slow. (Also a nerdy observation, 80% of the same code is exercised in each one). Is there a way to automatically generate the input\/output unit tests from automatic stack examination while running these? \nIn other words, I have high level tests, but I would like to automatically create low level unit and integration tests based on the execution of these high level tests.\nMirroring the high level tests with unit tests does exactly zero for added code coverage, but what it does do is make the tests far faster and far less brittle. It will allow quick and confident refactoring of the pieces.\nI'm very familiar with using TDD to mitigate this massive brittle blob issue in the first place as it actually speeds up development in a lot of cases and prevents this issue, but this is a sort of unique beast of a problem to solve as the codebase already exists and \"works\" ;).\nAny automated test tool tips? I googled around a lot, and I found some things that may work for C, but I can't find anything for python to generate pytests\/unittest\/nose or whatever. I don't care what python test framework it uses (although would prefer pytest). I must be searching the wrong terms as it seems unbelievable a test generation tool doesn't exist for python.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":55671363,"Users Score":0,"Answer":"I've taken a very lazy and practical imperfect solution, and it took me about 40hrs: 20 of which was wrapping my head around the C part enough to write unit tests for it and fix it, which amounted to about 30 lines -- the other 20 was fixing mostly trivial bytes\/strings issues that futurize couldn't possbly handle and setting up CI.\n\nRun futurize\nRun the most desirable use case as an E2E test and fix issues, complete with new critical unit tests\nCI w\/ tox on 2.7\/3.x for these \n\nEnd result is an unchanged 2.7 codebase and a minimally working beta 3.7 codebase, the long tail 3.7 support for secondary use cases to be solved over time, see Dirk's long term answer.","Q_Score":1,"Tags":"python,unit-testing,testing,automated-tests","A_Id":56344375,"CreationDate":"2019-04-14T01:57:00.000","Title":"Automatic low level testing generation based on high level desired behavioral examples","Data Science and Machine Learning":0,"Database and SQL":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":"Top Level Problem\nOur team has inherited a very large and brittle python 2 (and C,C++, few others) codebase that is very difficult and costly to update. Tons of dependencies. Very few tests. Adding behavior improvement and converting to python 3 both have appeared to be monumental tasks. Even making small changes for a new release we've had to revert many times as it's broken something.\nIt's a story of insufficient testing and its major technical debt.\nStill, the project is so big and helpful, that it seems a no brainer to update it than re-invent everything it does.\nSub Problem\nHow to add a massive amount of missing small tests. How can we automatically generate even simple input\/output acceptance unit tests from the high level user acceptance tests?\nAttempted Solution\nThere are about 50 large high level behavioral tests that this codebase needs to handle. Unfortunately, it takes days to run them all, not seconds. These exercise all the code we care the most about, but they are just too slow. (Also a nerdy observation, 80% of the same code is exercised in each one). Is there a way to automatically generate the input\/output unit tests from automatic stack examination while running these? \nIn other words, I have high level tests, but I would like to automatically create low level unit and integration tests based on the execution of these high level tests.\nMirroring the high level tests with unit tests does exactly zero for added code coverage, but what it does do is make the tests far faster and far less brittle. It will allow quick and confident refactoring of the pieces.\nI'm very familiar with using TDD to mitigate this massive brittle blob issue in the first place as it actually speeds up development in a lot of cases and prevents this issue, but this is a sort of unique beast of a problem to solve as the codebase already exists and \"works\" ;).\nAny automated test tool tips? I googled around a lot, and I found some things that may work for C, but I can't find anything for python to generate pytests\/unittest\/nose or whatever. I don't care what python test framework it uses (although would prefer pytest). I must be searching the wrong terms as it seems unbelievable a test generation tool doesn't exist for python.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":55671363,"Users Score":1,"Answer":"First, good you have already some higher level test running.  Parallelize their execution, run each on different hardware, buy faster hardware if possible - as the refactoring task you are about to handle seems to be huge, this will still be the cheapest way of doing it.  Consider breaking down these higher level tests into smaller ones.\nSecond, as lloyd has mentioned, for the components you plan to refactor, identify the component's boundaries and during execution of the higher level tests record input and output values at the boundaries.  With some scripting, you may be able to transform the recorded values into a starting point for unit-test code.  In only rare cases this will end up being useful unit-tests immediately: Normally you will need to do some non-trivial architectural analysis and probably re-design:\n\nWhat should be the units to be tested?  Single methods, groups of methods, groups of classes?  For example, setter methods can not sensibly be tested without other methods.  Or, to test any method, first a constructed object will have to exist, and thus some call to the constructor will be needed.\nWhat are the component's boundaries?  What are the depended-on-components?  With which of the depended-on-components can you just live, which would need to be mocked?  Many components can just be used as they are - you would not mock math functions like sin or cos, for example.\nWhat are the boundaries between unit-tests, that is, at which points in the long-running tests would you consider a unit-test to start and end?  Which part of the recording is considered setup, which execution, which verification?\n\nAll these difficulties explain to me, why some generic tooling may be hard to find and you will probably be left to specifically created scripts for test code generation.","Q_Score":1,"Tags":"python,unit-testing,testing,automated-tests","A_Id":55778415,"CreationDate":"2019-04-14T01:57:00.000","Title":"Automatic low level testing generation based on high level desired behavioral examples","Data Science and Machine Learning":0,"Database and SQL":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 understood O(logn) in a sense that it increases quickly but with larger inputs, the rate of increase retards. \nI am not able to completely understand \n\nO(nlogn) \nthe difference between an algorithm with complexity nlogn and complexity n + logn. \n\nI could use a modification of the phone book example and\/or some basic python code to understand the two queries","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3748,"Q_Id":55672633,"Users Score":0,"Answer":"Technically, algorithms with complexity O(n + log n) and complexity O(n) are the same, as the log n term becomes negligible when n grows.\nO(n) grows linearly. The slope is constant.\nO(n log n) grows super-linearly. The slope increases (slowly).","Q_Score":3,"Tags":"python,python-3.x,algorithm,time-complexity,big-o","A_Id":55673697,"CreationDate":"2019-04-14T06:41:00.000","Title":"How do I identify O(nlogn) exactly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm migrating a python application from an ubuntu server with locale en_US.UTF-8 to a new debian server which comes with C.UTF-8 already set by default. I'm trying to understand if there would be any impact but couldn't find good resources on the internet to understand the difference between both.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":44376,"Q_Id":55673886,"Users Score":0,"Answer":"I can confirm there is effect on different locales (C.UTF8 vs en_US.UTF8). I recently deployed one python program into a new  server, and it performed differently. The old and new servers are both Ubuntu 18 servers, and the only difference is the locale (C.UTF8 vs en_US.UTF8).  After setting the locale in new server as C.UTF8, they behave the same now.\nIt is easy to set the locale for a single application in Linux environment. You just need to add export LANG=C.UTF8; before your application. Assume you execute you application as python myprogram.py, then you type:\nexport LANG=C.UTF8; python myprogram.py","Q_Score":45,"Tags":"python,linux,docker,debian,locale","A_Id":68593911,"CreationDate":"2019-04-14T09:42:00.000","Title":"What is the difference between C.UTF-8 and en_US.UTF-8 locales?","Data 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 migrating a python application from an ubuntu server with locale en_US.UTF-8 to a new debian server which comes with C.UTF-8 already set by default. I'm trying to understand if there would be any impact but couldn't find good resources on the internet to understand the difference between both.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":44376,"Q_Id":55673886,"Users Score":42,"Answer":"In general C is for computer, en_US is for people in US who speak English (and other people who want the same behaviour).\nThe for computer means that the strings are sometime more standardized (but still in English), so an output of a program could be read from an other program. With en_US, strings could be improved, alphabetic order could be improved (maybe by new rules of Chicago rules of style, etc.). So more user-friendly, but possibly less stable. Note: locales are not just for translation of strings, but also for collation (alphabetic order, numbers (e.g. thousand separator), currency (I think it is safe to predict that $ and 2 decimal digits will remain), months, day of weeks, etc.\nIn your case, it is just the UTF-8 version of both locales.\nIn general it should not matter. I usually prefer en_US.UTF-8, but usually it doesn't matter, and in your case (server app), it should only change log and error messages (if you use locale.setlocale().  You should handle client locales inside your app. Programs that read from other programs should set C before opening the pipe, so it should not really matter.\nAs you see, probably it doesn't matter.  You may also use POSIX locale, also define in Debian. You get the list of installed locales with locale -a.\nNote: Micro-optimization will prescribe C\/C.UTF-8 locale: no translation of files (gettext), and simple rules on collation and number formatting, but this should visible only on server side.","Q_Score":45,"Tags":"python,linux,docker,debian,locale","A_Id":55693338,"CreationDate":"2019-04-14T09:42:00.000","Title":"What is the difference between C.UTF-8 and en_US.UTF-8 locales?","Data 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 migrating a python application from an ubuntu server with locale en_US.UTF-8 to a new debian server which comes with C.UTF-8 already set by default. I'm trying to understand if there would be any impact but couldn't find good resources on the internet to understand the difference between both.","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":44376,"Q_Id":55673886,"Users Score":7,"Answer":"There might be some impact as they differ in sorting orders, upper-lower case relationships, collation orders, thousands separators, default currency symbol and more.\nC.utf8 = POSIX standards-compliant default locale. Only strict ASCII characters are valid, extended to allow the basic use of UTF-8\nen_US.utf8 = American English UTF-8 locale. \nThough I'm not sure about the specific effect you might encounter, but I believe you can set the locale and encoding inside your application if needed.","Q_Score":45,"Tags":"python,linux,docker,debian,locale","A_Id":55676870,"CreationDate":"2019-04-14T09:42:00.000","Title":"What is the difference between C.UTF-8 and en_US.UTF-8 locales?","Data 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 just now started learning python from Learn Python 3 The Hard Way by Zed Shaw. In exercise 3 of the book, there was a problem to get the value of 100 - 25 * 3 % 4. The solution to this problem is already mentioned in the archives, in which the order preference is given to * and %(from left to right).\nI made a problem on my own to get the value of 100 - 25 % 3 + 4. The answer in the output is 103.\nI just wrote: print (\"the value of\", 100 - 25 % 3 + 4), which gave the output value 103.\nIf the % is given the preference 25 % 3 will give 3\/4. Then how the answer is coming 103. Do I need to mention any float command or something?\nI would like to know how can I use these operations. Is there any pre-defined rule to solve these kinds of problems?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":55676780,"Users Score":0,"Answer":"The % operator is used to find the remainder of a quotient. So 25 % 3 = 1 not 3\/4.","Q_Score":0,"Tags":"python,python-3.x","A_Id":55676820,"CreationDate":"2019-04-14T15:12:00.000","Title":"operations order in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just now started learning python from Learn Python 3 The Hard Way by Zed Shaw. In exercise 3 of the book, there was a problem to get the value of 100 - 25 * 3 % 4. The solution to this problem is already mentioned in the archives, in which the order preference is given to * and %(from left to right).\nI made a problem on my own to get the value of 100 - 25 % 3 + 4. The answer in the output is 103.\nI just wrote: print (\"the value of\", 100 - 25 % 3 + 4), which gave the output value 103.\nIf the % is given the preference 25 % 3 will give 3\/4. Then how the answer is coming 103. Do I need to mention any float command or something?\nI would like to know how can I use these operations. Is there any pre-defined rule to solve these kinds of problems?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":55676780,"Users Score":1,"Answer":"Actually, the % operator gives you the REMAINDER of the operation.\nTherefore, 25 % 3 returns 1, because 25 \/ 3 = 8 and the remainder of this operation is 1.\nThis way, your operation 100 - 25 % 3 + 4 is the same as 100 - 1 + 4 = 103","Q_Score":0,"Tags":"python,python-3.x","A_Id":55676836,"CreationDate":"2019-04-14T15:12:00.000","Title":"operations order in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to compare ORB, SIFT, BRISK, AKAZE, etc. to find which works best for my specific image set. I'm interested in the final alignment of images.\nIs there a standard way to do it?\nI'm considering this solution: take each algorithm, extract the features, compute the homography and transform the image.\nNow I need to check which transformed image is closer to the target template.\nMaybe I can repeat the process with the target template and the transformed image and look for the homography matrix closest to the identity but I'm not sure how to compute this closeness exactly. And I'm not sure which algorithm should I use for this check, I suppose a fixed one.\nOr I could do some pixel level comparison between the images using a perceptual difference hash (dHash). But I suspect the the following hamming distance may not be very good for images that will be nearly identical.\nI could blur them and do a simple subtraction but sounds quite weak.\nThanks for any suggestions.\nEDIT: I have thousands of images to test. These are real world pictures. Images are of documents of different kinds, some with a lot of graphics, others mostly geometrical. I have about 30 different templates. I suspect different templates works best with different algorithms (I know in advance the template so I could pick the best one).\nRight now I use cv2.matchTemplate to find some reference patches in the transformed images and I compare their locations to the reference ones. It works but I'd like to improve over this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":89,"Q_Id":55679644,"Users Score":0,"Answer":"From your question, it seems like the task is not to compare the feature extractors themselves, but rather to find which type of feature extractor leads to the best alignment.\nFor this, you need two things:\n\na way to perform the alignment using the features from different extractors\na way to check the accuracy of the alignment\n\nThe algorithm you suggested is a good approach for doing the alignment. To check if accuracy, you need to know what is a good alignment.\nYou may start with an alignment you already know. And the easiest way to know the alignment between two images is if you made the inverse operation yourself. For example, starting with one image, you rotate it some amount, you translate\/crop\/scale or combine all this operations. Knowing how you obtained the image, you can obtain your ideal alignment (the one that undoes your operations).\nThen, having the ideal alignment and the alignment generated by your algorithm, you can use one metric to evaluate its accuracy, depending on your definition of \"good alignment\".","Q_Score":0,"Tags":"python,opencv,computer-vision","A_Id":55680593,"CreationDate":"2019-04-14T20:15:00.000","Title":"Comparing feature extractors (or comparing aligned images)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need a dictionary where I can store items with a TTL (time to live) so that the items disappear once the time is up. I found the ExpiringDict class for this purpose but it appears to be restricted to having the same timeout for each item in the dictionary. Is there an alternative that lets me specify different timeout values for each key?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":413,"Q_Id":55681330,"Users Score":1,"Answer":"It is easy to build yourself. Ingredients: a normal dict to store the values; a heapq to store (expiry, key) pairs; a Thread to run a loop, check the top of the heap and delete (or mark expired, depending on what your need is) while top's expiry is in the past (don't forget to let it sleep). When you push to dict, at the same time add (now + ttl, key) to the heapq. There's some details that you might want to attend to (e.g. removing stuff from heapq if you delete from dict etc, though that'd be a bit slow as you'd have to search the heap, then re-heapify - again, only necessary if your use case requires it) but the basic idea is quite simple.","Q_Score":1,"Tags":"python,dictionary","A_Id":55681375,"CreationDate":"2019-04-15T00:43:00.000","Title":"Expiring Dictionaries with individual TTLs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using eclipse for python and my ctrl+click is not working ?  I have already add pyDevEditer and it is active in Hyperlinking.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":55682663,"Users Score":0,"Answer":"Try this:\n\nClose the class you are working on. \nPress \"Control+Shift+T\"\nSearch with class name\nOpen the class Now \"Ctrl+Click\" should work","Q_Score":0,"Tags":"python,eclipse","A_Id":55682686,"CreationDate":"2019-04-15T04:38:00.000","Title":"ctrl click not working for python project pydeveditor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using libclang in Python to construct the AST of some source code. It occurs segmentation fault(core dumped) error for few files. Then I try the command in terminal clang -fmodules -fsyntax-only -Xclang -ast-dump + file. The error occurs, too. I believe clang crashed. (I do not know why, If you know how to solve it, please tell me). Because only few files cause this error. I want to ignore them and use try...except statement in python, but this statement does not work, this error still occurs and code running interrupts directly instead of running code in except. How can I delete the source file which causes error and continue to construct the AST for other files?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":271,"Q_Id":55685941,"Users Score":0,"Answer":"segmentation fault (core dumped) means that the python interpreter has completely stopped (because of a bug in libclang probably).  try...except will not catch this.\nYour best bet is to create a bug report for libclang, and attach a file which causes the error.\nThe only other options is to run libclang in a separate process for each file, and ignore any results if the process terminates.","Q_Score":1,"Tags":"python,segmentation-fault,clang","A_Id":55686031,"CreationDate":"2019-04-15T09:13:00.000","Title":"Python & clang: try...except statement not working for segmentation fault(core dumped)","Data 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 designing the architecture of a neural network for the colorization of grayscale images. Later on it should be able to colorize images with different sizes and different aspect ratios. I read that this would not be possible with a common CNN. I also read that the only options are downscaling the images to one specific size or to use a big fixed size (like 3000x3000px) and to fill the remaining space black. Both of these options don't seem to be that elegant. The first one is the opposite of what I want and the second would make the neural network slower.\nThen I read about Fully Convolutional Networks and that this problem would not exist there. This would be great if it really works. I would like to know why this special network can deal with different input shapes. And maybe you could show me some tensorflow code of such a network.\nBy the way, I thought about an Autoencoder combined with a GAN for the architecture.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":863,"Q_Id":55689510,"Users Score":0,"Answer":"In my experience you cannot train any network with different sample size on the same batch. \nFully convolutional network is similar to a fully connected network with fully connected layers at the end. As such any input image in the batch must have the same dims (w,h,d). \nThe difference is that a fully connected layers output a single output vector for every sample in the input batch while the fully convolutional net outputs a map of probability for each class.\nIt has a deeper meaning than just the image size, when trying to fit any data the size of it must be absolute and cannot be changed while training. I guess you can do it in different batches as I stated but I've never tried it.\nAn encoder\\decoder could help \"rebuild\" the image in a specific size.\nThis tip, again, is from my experience in object detection, I could be wrong :)","Q_Score":0,"Tags":"python,tensorflow,machine-learning,deep-learning,computer-vision","A_Id":55689959,"CreationDate":"2019-04-15T12:45:00.000","Title":"Neural Network with different input shapes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Good afternoon everyone,\nFor a school project I will make a RC car using a c8051 microcontroller and to send the uart data to it I'm using a ESP32 so that I can display a webpage so that the user choose the direction of the car. I've spent a lot of time on micropython doc's page and tutorial for TCP sockets and I see in every one of them that to check if the webpage was requested they use something like:\nIf(request==6):\nAnd I can't figure out why 6, what that represents??\nI appreciate any help given.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":55690355,"Users Score":0,"Answer":"The answer found in the comment section of the link given\n\"In the while loop, after receiving a request, we need to check if the request contains the \u2018\/?led=on\u2019 or \u2018\/?led=on\u2019 expressions. For that, we can apply the find() method on the request variable. the find() method returns the lowest index of the substring we are looking for.\nBecause the substrings we are looking for are always on index 6, we can add an if statement to detect the content of the request. If the led_on variable is equal to 6, we know we\u2019ve received a request on the \/?led=on URL and we turn the LED on.\nIf the led_off variable is equal to 6, we\u2019ve received a request on the \/?led=off URL and we turn the LED off.\"","Q_Score":0,"Tags":"microcontroller,esp32,micropython","A_Id":55703438,"CreationDate":"2019-04-15T13:32:00.000","Title":"Esp32 micropython webserver TCP socket to check http get request","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have this code in my project to get all the words from pdf.\nwords = pdfPage.extract_words(0.5,0.5)\nwhich throws the below error:\nCannot convert  to Decimal.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":55690454,"Users Score":0,"Answer":"Try to downgrade the Pdf-minder version. Since i had this same issue resolving by downgrading.","Q_Score":0,"Tags":"python-3.x,text-extraction,python-pdfkit","A_Id":55704266,"CreationDate":"2019-04-15T13:38:00.000","Title":"python pdfpage.extract_words throws error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I recently needed to store large array-like data (sometimes numpy, sometimes key-value indexed) whose values would be changed over time (t=1 one element changes, t=2 another element changes, etc.). This history needed to be accessible (some time in the future, I want to be able to see what t=2\u2019s array looked like). \nAn easy solution was to keep a list of arrays for all timesteps, but this became too memory intensive. I ended up writing a small class that handled this by keeping all data \u201celements\u201d in a dict with each element represented by a list of (this_value, timestamp_for_this_value). that let me recreate things for arbitrary timestamps by looking for the last change before some time t, but it was surely not as efficient as it could have been. \nAre there data structures available for python that have these properties natively? Or some sort of class of data structure meant for this kind of thing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":272,"Q_Id":55691861,"Users Score":1,"Answer":"Have you considered writing a log file?  A good use of memory would be to have the arrays contain only the current relevant values but build in a procedure where the update statement could trigger a logging function.  This function could write to a text file, database or an array\/dictionary of some sort.  These types of audit trails are pretty common in the database world.","Q_Score":0,"Tags":"python,data-structures","A_Id":55692831,"CreationDate":"2019-04-15T14:53:00.000","Title":"Python Array Data Structure with History","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have django project in which I can display records from raspberry pi device. I had mysql database and i have send records from raspberry there. I can display it via my api, but I want to work on this records.I want to change this to django database but I don't know how I can get access to django database which is on VPS server from raspberry pi device.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":55692096,"Users Score":0,"Answer":"ALERT: THIS CAN LEAD TO SECURITY ISSUES\nA Django database is no different from any other database. In this case a MySQL.\nThe VPS server where the MySQL is must have a public IP, the MySQL must be listening on that IP (if the VPS has a public IP but MySQL is not listening\/bind on that IP, it won't work) and the port of the MySQL open (default is 3306), then you can connect to that database from any program with the required configurations params (host, port, user, password,...).\nI'm not a sysadmin expert, but having a MySQL on a public IP is a security hole. So the best approach IMO is to expose the operations you want to do via API with Django.","Q_Score":0,"Tags":"python,mysql,django","A_Id":55693009,"CreationDate":"2019-04-15T15:05:00.000","Title":"How to get access to django database from other python program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to run python manage.py runserver but i'm getting \nLookupError: No installed app with label 'admin'\nthis is what i get by python manage.py check\n\nTraceback (most recent call last):   File \"manage.py\", line 21, in\n  \n      main()   File \"manage.py\", line 17, in main\n      execute_from_command_line(sys.argv)   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django\\core\\management__init__.py\",\n  line 381, in execute_from_command_line\n      utility.execute()   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django\\core\\management__init__.py\",\n  line 357, in execute\n      django.setup()   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django__init__.py\", line\n  24, in setup\n      apps.populate(settings.INSTALLED_APPS)   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django\\apps\\registry.py\",\n  line 114, in populate\n      app_config.import_models()   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django\\apps\\config.py\",\n  line 211, in import_models\n      self.models_module = import_module(models_module_name)   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\importlib__init__.py\", line 126, in\n  import_module\n      return _bootstrap._gcd_import(name[level:], package, level)   File \"\", line 996, in _gcd_import   File\n  \"\", line 979, in _find_and_load   File\n  \"\", line 968, in _find_and_load_unlocked \n  File \"\", line 673, in _load_unlocked\n  File \"\", line 667, in\n  exec_module   File \"\", line 222, in\n  _call_with_frames_removed   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django\\contrib\\auth\\models.py\",\n  line 2, in \n      from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager   File\n  \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django\\contrib\\auth\\base_user.py\",\n  line 47, in \n      class AbstractBaseUser(models.Model):   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django\\db\\models\\base.py\",\n  line 117, in new\n      new_class.add_to_class('_meta', Options(meta, app_label))   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django\\db\\models\\base.py\",\n  line 321, in add_to_class\n      value.contribute_to_class(cls, name)   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django\\db\\models\\options.py\",\n  line 204, in contribute_to_class\n      self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())   File\n  \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django\\db__init__.py\",\n  line 28, in getattr\n      return getattr(connections[DEFAULT_DB_ALIAS], item)   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django\\db\\utils.py\", line\n  201, in getitem\n      backend = load_backend(db['ENGINE'])   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django\\db\\utils.py\", line\n  110, in load_backend\n      return import_module('%s.base' % backend_name)   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\importlib__init__.py\", line 126, in\n  import_module\n      return _bootstrap._gcd_import(name[level:], package, level)   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django\\db\\backends\\sqlite3\\base.py\",\n  line 28, in \n      from .introspection import DatabaseIntrospection            # isort:skip   File\n  \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\django\\db\\backends\\sqlite3\\introspection.py\",\n  line 4, in \n      import sqlparse   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\sqlparse__init__.py\",\n  line 16, in \n      from sqlparse import filters   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\sqlparse\\filters__init__.py\",\n  line 17, in \n      from sqlparse.filters.tokens import KeywordCaseFilter   File \"C:\\Users\\hitma\\Envs\\ftest\\lib\\site-packages\\sqlparse\\filters\\tokens.py\",\n  line 27, in \n      class KeywordCaseFilter(_CaseFilter): TypeError: '_TokenType' object is not callable\n\ni followed the main doucment for installing django,Thanks\ndjango version: 2.2\npython: 3.6.0a4","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2044,"Q_Id":55692193,"Users Score":1,"Answer":"It is an issue related to sqlparse. It happens when you are using newest version of packages.\nTry : \npip install sqlparse \nNote - your terminal must activate virtual environment.","Q_Score":0,"Tags":"python,django","A_Id":56242222,"CreationDate":"2019-04-15T15:10:00.000","Title":"Running python manage.py runserver returns error LookupError: No installed app with label 'admin'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a java server sending out a request where the path contains the hostname.\nOTOH I've got an ancient django server (1.8) that figures (wrongly) that the hostname is part of the path, and always returns a 404.\nAssuming that sending properly formed requests from java side is not possible, how would I go about modifying the request URL to something that can be properly redirected to, without actually redirecting? (a 30x is also unacceptable in this case).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":55693067,"Users Score":0,"Answer":"I ended up doing a rewrite in nginx (using proxy_pass).\nI couldn't solve this at the application level in any feasible way.","Q_Score":0,"Tags":"python,django","A_Id":57443493,"CreationDate":"2019-04-15T15:58:00.000","Title":"Rerouting request via middleware in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to know the equivalent of the julia type \"symbols\" in Python because i am trying to translate a code that i am working on, from julia to Python.\nThank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":702,"Q_Id":55694376,"Users Score":0,"Answer":"Use strings instead.  What do symbols do that strings don't do?","Q_Score":1,"Tags":"python,julia","A_Id":55694480,"CreationDate":"2019-04-15T17:21:00.000","Title":"Symbols and its equivalent 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 was doing some quick tests for handling missing values and came across this weird behavior. When looking at ~pd.isnull(np.nan), I expect it to return False, but instead it returns -2. Why is this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":55694800,"Users Score":0,"Answer":"It's because you used an arithmetic, bitwie negation operator instead of a logical negation.","Q_Score":1,"Tags":"python","A_Id":55694836,"CreationDate":"2019-04-15T17:53:00.000","Title":"Why does ~pd.isnull() return -2?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Jupyter notebook called \"Visual Magnitude.ipynb\" on my Windows box. I've used this notebook for several years. It's under CM control (perforce is our CM tool). Normally I don't have it checked out, so it's marked as read-only on the file system. Sometimes I open it up (knowing it's read-only), add a few cells, look at some results, and close it out, knowing the new cells won't be saved. This is ok. \nBut lately I've run into a situation where I forgot to check it out of perforce first, then added\/modified some cells. When I went to save it Jupyter complained it was read-only. So I checked it out (thus removing the read-only status on the file system). Jupyter still doesn't recognize this. So I quit Jupyter all together and restart it with the notebook (which is now writable). But Jupyter refuses to recognize this and still treats it as if it were locked. Almost as if it's caching the file status in some location.\nI've rebooted and still have the same problem. What am I missing to convince Jupyter that this notebook is now writable?\nI'm using Jupyter 4.4.0.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":143,"Q_Id":55697454,"Users Score":0,"Answer":"It turns out that there was a hidden file .~Visual Magnitude.ipynb in the same folder that was still marked read only. Once I deleted that everything was fine.","Q_Score":1,"Tags":"python-3.x,jupyter-notebook","A_Id":55748769,"CreationDate":"2019-04-15T21:24:00.000","Title":"Jupyter notebook won't let me save itself","Data 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 use Anaconda's Spyder for some visualization. Got used to code formatter called black when I code in Notepad++. Unfortunately, I don't know to use black with Spyder. Does anyone know?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3003,"Q_Id":55698077,"Users Score":9,"Answer":"(Spyder maintainer here) We'll add an option to use the Black formatter in our next version, Spyder 4.2, to be released in November of 2020.\nUnfortunately, there's nothing we can do about it for our current version (4.1.5), sorry.","Q_Score":5,"Tags":"python,spyder,formatter","A_Id":55704027,"CreationDate":"2019-04-15T22:30:00.000","Title":"How to use code formatter Black with Spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to programming. I think I'm close to solving my issue, but it finally broke my brain and I need help. \nI am running a pygame script as a scheduled task in crontabs. I have one code that executes successfully and does what it should. I have another code that executes, but when it does the screen goes blank, usually displaying some lines that I usually see when the Linux boots up, and it just stays stuck there.\nI have gone through both codes and absolutely everything is similar and correct. I have #!\/usr\/bin\/env python at the start of each script.\n(Elsewhere it was recommended that I give the exact version, because I use dictionaries in my script and apparently crontab could get confused with the dictionary stuff that pygame uses. I don't fully understand, I tried it but it didn't work on my raspberry pi so I don't think that's the solution.)\nEach script runs fine in the terminal.\nI have set the PATH variable to the one that the python script uses and also set the SHELL to \/bin\/bash. In the task I also have \"export DISPLAY=:0\" (e.g. 12 21 * * * export DISPLAY=:0 && ...). I have found this was the magic trick that got the other code to work. Which made me wonder if there is another environment variable that I need to set in the task? \nThe difference between the first code and the second code: The second code uses pygame.mixer and plays sound files. In the script, the sound files are in dictionaries (e.g. sound = {\"word\" : \"\/absolute\/path\/to\/file.wav\", \"word2\" : ...etc} As I said this code runs fine in terminal.\nSo why does the one script work and not the other. Both use pygame. The other just uses sound, dictionaries instead of strings, and pygame.mixer as well. My reasoning is that there is an issue with crontab getting stuck on one of these things.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":412,"Q_Id":55698386,"Users Score":0,"Answer":"I fixed it. I was running it out of root. When I ran the crontab in the user it worked. It must be because the root couldn't get at the files.\nImportant tips is to add 'import os' and at some point in the script add 'print(os.environ)' to check all the environment variables when it runs in terminal.\nThen copy the $PATH variables to the top of the crontab jobs.\nSame with $SHELL.\nThe $DISPLAY variables need to be put in the line, so for example '* * * * * export DISPLAY=:0 && \/usr\/bin\/python \/home\/user\/file.py'\nSee how I put absolute paths for both the command and the path to file. I also set absolute paths to files in the script, even if the files are in the same folder as the script. I'm not sure if this is necessary I will check that next. I've seen a lot of people struggle with this issue and the advice usually comes down to these things.","Q_Score":0,"Tags":"python,dictionary,cron,pygame","A_Id":55755005,"CreationDate":"2019-04-15T23:08:00.000","Title":"Crontab executes python script but something is wrong","Data Science and Machine Learning":0,"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":"GRPC server does queue the requests and serve them based on the maxWorker configuration which is passed when the sever starts up. How do I print the metric- number of items in the queue .? Essentially, I would like to keep track of the numbers of requests in waiting state.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2149,"Q_Id":55699452,"Users Score":0,"Answer":"You can pass your own executor to serverBuilder.executor(). Note that you are then responsible for shutting down the executor service after the server has terminated.","Q_Score":3,"Tags":"grpc,grpc-java,grpc-python","A_Id":55712069,"CreationDate":"2019-04-16T01:49:00.000","Title":"keep track of the request queue in grpc server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to save a file to a NoSQL Database using python. Which libraries could be useful\/ how should I go about this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":152,"Q_Id":55699455,"Users Score":0,"Answer":"There is no single standard driver for NoSql databases. Most NoSql database have native python driver and other 3rd party driver. \nFor MongoDB : Pymongo is the native python library\/driver. \nMonogoengine is a good option if you are looking for something like an orm.","Q_Score":0,"Tags":"python,database,nosql,save","A_Id":55700027,"CreationDate":"2019-04-16T01:49:00.000","Title":"Importing & saving a file to a NOSQL Database with Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I tried to import psycopg2, the following errors occured. \n\n\n\nimport psycopg2\n      Traceback (most recent call last):\n        File \"\", line 1, in \n        File \"\/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/site-packages\/psycopg2\/init.py\", line 50, in \n          from psycopg2._psycopg import (                     # noqa\n      ImportError: dlopen(\/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/site-packages\/psycopg2\/_psycopg.cpython-37m-darwin.so, 2): Library not loaded: @rpath\/libssl.1.1.dylib\n        Referenced from: \/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/site-packages\/psycopg2\/_psycopg.cpython-37m-darwin.so\n        Reason: image not found","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3954,"Q_Id":55699874,"Users Score":0,"Answer":"I've had the same issue. After digging a little into the thread provided by @singingstone, the solution that worked for me was to pip uninstall psycopg2, then pip install psycopg2-binary.","Q_Score":0,"Tags":"python-3.x,terminal,psycopg2,importerror,dlopen","A_Id":70896283,"CreationDate":"2019-04-16T02:51:00.000","Title":"After installing psycopg2, I cannot import it properly","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Python 3.6 and after I tried to install the v4l2capture package, I got the following error message:\n\n\"v4l2capture.c:20:10: fatal error: libv4l2.h: No such file or directory\"\n\nWhy is this and how do I solve it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1440,"Q_Id":55703831,"Users Score":1,"Answer":"You have to install libv4l-dev package in Debian\/Ubuntu, or libv4l-devel in RH.","Q_Score":2,"Tags":"python,python-3.x,fatal-error,nosuchfileexception","A_Id":55705270,"CreationDate":"2019-04-16T08:34:00.000","Title":"I got a fatal error message when I tried to install the \"v4l2capture\" package in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to keep reports in different directory every time the execution is done, but it should be done dynamically in automation execution itself\nspecifying the reports directory path in command line execution is not the one I am looking for, that is there but it needs manual input to place the reports in particular directory.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":803,"Q_Id":55705787,"Users Score":2,"Answer":"Once the test starts running you cannot change the location of the outputs. Your only solution is to use a command line option.","Q_Score":0,"Tags":"python,python-2.7,robotframework","A_Id":55708405,"CreationDate":"2019-04-16T10:15:00.000","Title":"How to make reports dynamically categorised in 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":"What happened after entered \"flask run\" on a terminal under the project directory?\nHow the python interpreter gets the file of flask.__main__.py and starts running project's code?\nI know how Flask locates app. What I want to figure out is how command line instruction \"flask run\" get the flask\/__main__.py bootup","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":117,"Q_Id":55707275,"Users Score":2,"Answer":"flask is a Python script. Since you stated you are not a beginner, you should simply open the file (\/usr\/bin\/flask) in your favorite text editor and start from there. There is no magic under the hood.","Q_Score":0,"Tags":"python,flask","A_Id":55708668,"CreationDate":"2019-04-16T11:37:00.000","Title":"What happened after entered \" flask run\" on a terminal under the project directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am looking for a way to use web drivers (ChromeDriver, IEDriver, GeckoDriver etc., all together) with my native python app such that, the app will figure out the browser, and choose the driver accordingly, and will do some actions (like click an element or get data). I want to do the task in python without using selenium","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":618,"Q_Id":55707406,"Users Score":1,"Answer":"It would theoretically be possible to use the driver executables without Selenium. All WebDriver implementations operate using the same mechanism. That mechanism is starting an HTTP server running locally, and listening on a well-known set of end points (URLs) for HTTP requests containing well-defined JSON bodies.\nIt\u2019s fully possible to even start a WebDriver implementation like IEDriverServer.exe, geckodriver, or chromedriver and automate the browser even using a tool like cURL, so using a Python HTTP client library and JSON parser is certainly in the realm of the possible. However, doing so requires a fairly thorough understanding of the protocol used in communicating with the driver, and gaining that understanding is distinctly non-trivial. In fact, use of that protocol without needing to know the details of it is one of the very reasons for Selenium\u2019s existence.\nWhile what you say you want to do is possible, I would by no means call it recommended. Attempting to go down that road seems like a lot of effort for a very marginal benefit, when you consider you need to worry about lifetime of the executable process you spawn, proper formatting of the HTTP request bodies, and handling all of the potential responses from the remote end. You\u2019d be reinventing a whole lot of things that Selenium already does for you. Your question doesn\u2019t show any indication of why you don\u2019t want to use Selenium, so it\u2019s difficult to provide any further guidance as to alternatives or mitigations to the things you find objectionable about it.","Q_Score":1,"Tags":"python-3.x,automation,webdriver,selenium-chromedriver","A_Id":55767473,"CreationDate":"2019-04-16T11:45:00.000","Title":"How can we use ChromeDriver, IEDriver, GeckoDriver without selenium in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way I can access a python virtual environment created by another user on an Ubuntu machine ? \nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":575,"Q_Id":55709041,"Users Score":0,"Answer":"well I get it to work using the following command with different user, \n$ . env_name\/bin\/activate\nnote that I needed to grant write & execute rights on the venv files to the current user.","Q_Score":0,"Tags":"python,virtualenv","A_Id":55763629,"CreationDate":"2019-04-16T13:12:00.000","Title":"Access Python virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'd like to use eclipse and PyDev as my Python development environment. I have downloaded the eclipse installer (2019-03 version), however this presents options for \"Java Developers\", \"C\/C++ Developers\", \"PHP Developers\", etc., with no option for Python developers.\nI'm thinking each of the available options may include large amounts of functionality I don't need, leading to a bloated install. So, which is the most stripped-back minimum install that I can install the PyDev plugin over?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":833,"Q_Id":55709550,"Users Score":0,"Answer":"There are a couple of options for using Eclipse as an IDE for a Python interpreter. It is worth pointing out the following points with respect to PyDev, the plugin that may be used in Eclipse...\n\nYou can use the latest version of Eclipse. You don't need Eclipse Neon, for example.\nYou need to install a working version of Python, I used 3.8.1.\nWhen opening your new Eclipse workspace be sure to click on the marketplace link so that you can search and install PyDev, the plugin you will be using within Eclipse.\nOnce PyDev is successfully installed, be sure your preferences acknowledge that the interpreter is in fact Python in Eclipse: Eclipse >> PyDev >> Interpreter - Python\nFrom here you can create and build applications using .py file extension where right clicking your code results in running the selected code.","Q_Score":0,"Tags":"python,eclipse,pydev,eclipse-installer","A_Id":59812927,"CreationDate":"2019-04-16T13:37:00.000","Title":"What is the most lightweight eclipse install for PyDev 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":"Lets say I am trying to compute the average distance between a word and a document using distances() or compute cosine similarity between two documents using n_similarity(). However, lets say these new documents contain words that the original model did not. How does gensim deal with that?\nI have been reading through the documentation and cannot find what gensim does with unfound words.\nI would prefer gensim to not count those in towards the average. So, in the case of distances(), it should simply not return anything or something I can easily delete later before I compute the mean using numpy. In the case of n_similarity, gensim of course has to do it by itself....\nI am asking because the documents and words that my program will have to classify will in some instances contain unknown words, names, brands etc that I do not want to be taken into consideration during classification. So, I want to know if I'll have to preprocess every document that I am trying to classify.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":179,"Q_Id":55710967,"Users Score":1,"Answer":"The models are defined on vectors, which, by default setting, depend only on old words so I do not expect them depend on new words. \nIt is still possible, depending on code, for new words to affect results. To be on safe side I recommend to test your particular model and\/or metrics on a small text (with and without a bunch of new words).","Q_Score":1,"Tags":"python,nlp,gensim","A_Id":55711407,"CreationDate":"2019-04-16T14:48:00.000","Title":"Dealing with new words in gensim not found in model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Lets say I am trying to compute the average distance between a word and a document using distances() or compute cosine similarity between two documents using n_similarity(). However, lets say these new documents contain words that the original model did not. How does gensim deal with that?\nI have been reading through the documentation and cannot find what gensim does with unfound words.\nI would prefer gensim to not count those in towards the average. So, in the case of distances(), it should simply not return anything or something I can easily delete later before I compute the mean using numpy. In the case of n_similarity, gensim of course has to do it by itself....\nI am asking because the documents and words that my program will have to classify will in some instances contain unknown words, names, brands etc that I do not want to be taken into consideration during classification. So, I want to know if I'll have to preprocess every document that I am trying to classify.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":179,"Q_Id":55710967,"Users Score":2,"Answer":"Depending on the context, Gensim will usually either ignore unknown words, or throw an error like KeyError when an exact-word lookup fails. (Also, some word-vector models, like FastText, can synthesize better-than-nothing guesswork vectors for unknown words based on word-fragments observed during training.)\nYou should try your desired operations with the specific models\/method of interest to observe the results.\nIf operation-interrupting errors are thrown and a problem for your code, you could pre-filter your lists-of-words to remove those not also present in the model.","Q_Score":1,"Tags":"python,nlp,gensim","A_Id":55716394,"CreationDate":"2019-04-16T14:48:00.000","Title":"Dealing with new words in gensim not found in model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to solve the linear equation Ax = b, for the unknown matrix x. A and b are both large and sparse, and have shapes (when converted to dense) of 30,000 x 25 and 30,000 x 100,000, respectively.\nI have tried using both scipy.sparse.linalg.lsqr and scipy.sparse.linalg.lsmr, but they both require that b be dense, which is computationally very expensive and prohibitive.\nHow can I do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":222,"Q_Id":55712254,"Users Score":0,"Answer":"You could to use numpy.linalg.pinv to find \"x\" values","Q_Score":1,"Tags":"python,scipy,regression,sparse-matrix,least-squares","A_Id":55712434,"CreationDate":"2019-04-16T15:57:00.000","Title":"Linear algebra with large, sparse matrices","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large number of pandas dataframe > 5000 of shape 3000x3000 float values with density of 60% (i.e. 40% values are NaNs). These frames have identical index and columns. \nI'd like to operate on these frames e.g. addition of all of them. If I do this sequentially, it takes more than 20 mins. Is there efficient way I could operate on them (e.g. sum them)?\nHow can I make this process memory efficient knowing that these dataframes are not dense?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":55712366,"Users Score":0,"Answer":"If all of your data has the same shape, then I don't see the point of using lists of pandas DataFrames for this.\nThe most performance you could get out of Python with the least work is just stacking the dataframes into a 3D Numpy array of dimensions (3000, 3000, 5000) and then doing an sum over the last axis.\nAs this requires > 360 GB of RAM (at least 180 GB for the loaded dataframes, 180 GB for the stacked Numpy array), this is probably beyond a usual Desktop workload, and you may want to check out big data tools as mentioned in the comments.","Q_Score":0,"Tags":"python,pandas,bigdata,data-science","A_Id":55725242,"CreationDate":"2019-04-16T16:04:00.000","Title":"Operating on large number of dataframes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Flask-Migrate (Alembic) to manage SQLAlchemy database migrations. I'm working on two different branches with different migrations. \n\nIf I switch branches, I get an error that the migration is not found.\nIf i merge this branches into the parent branch, I need downgrade migration's on both multiple branches and create new one. If I will not, I get migration's conflict error. \n\nHow can I do it easier? Maybe another tool that more like Django's migrations, but for Flask?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2068,"Q_Id":55715129,"Users Score":16,"Answer":"Alembic requires the chain of migrations to match the database marker for the current migration. If you create and run some migrations on a branch, then switch to another branch, the database is marked as being on a migration that no longer exists.\nTo work on multiple branches while using migrations, you'll need to figure out what the latest common migration on the branch you're switching to is, then downgrade to that version first. Then checkout the branch, and run any migrations that are unique to it.\nFor example, assume you created two branches off the \"dev\" branch called \"feature1\" and \"feature2\", and each have one new migration since \"dev\". To switch from \"feature1\" to \"feature2\":\n\nDowngrade the migrations added to the branch, in this case 1: flask db downgrade -1.\nCheckout the branch: git checkout feature2\nApply any upgrades for the new branch: flask db upgrade\n\nIf you don't want to lose data due to downgrades that remove columns or tables, you'll need to dump and restore the database for each branch instead.\n\nIf you're working on \"feature1\" and merge it into \"dev\", you need to update \"feature2\" so it knows about the new migrations that were merged in. Alembic will support having multiple branches as long as all the migrations are present. Once you merge \"feature2\", you can generate a merge migration to consolidate the two migration branches back to one.\n\nMerge \"feature1\" into \"dev\": git checkout dev, git merge feature1\nSwitch to \"feature2\" and merge \"dev\": git checkout feature2, git merge dev\nRun the migrations from \"dev\" and \"feature2\": flask db upgrade\nContinue working on \"feature2\".\nMerge \"feature2\" into \"dev\": git checkout dev, git merge feature2\nFind the migration ids that need to be merged: flask db heads\nflask db merge id1 id2, substituting the ids from the previous step.\nUpdate to the merge, note that there is only one head: flask db upgrade, flask db heads\n\n\nUnfortunately, this is a manual process. Alembic requires the migration chain to match the database marker, and there is currently no way around that. You may be able to write a git hook to help with this, but it's not something that already exists.","Q_Score":9,"Tags":"python,git,sqlalchemy,alembic,flask-migrate","A_Id":55715541,"CreationDate":"2019-04-16T19:11:00.000","Title":"Work on multiple branches with Flask-Migrate","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am communicating with a modbus rtu device with 32bit wide registers, custom apparently.\nI tried using a modbus library out of the box but no luck as I get the error as follows modbus_tk.exceptions.ModbusInvalidResponseError: Response length is invalid 0\nTwo things I do not understand...\n\nwhy is the byte length not consistent(0x01 :1 byte vs 0x04B:2 bytes vs 0xclff:3 bytes).   \nif this is unicode, why do I get the error response.decode('utf-8') UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc1 in position 4: invalid start byte\n\nUltimately the response message is a pressure reading and should look something like 97.6. I cannot figure out how to interpret the byte string to be 97.6.\nAny help is greatly appreciated.\nI tried decoding to utf-8 and converting the hexadecimal bytes to ascii with no success.\nSo I attempted to can my request for holding register, I tried ser.write(b'\\x01\\x03\\x07\\xd0\\x00\\x01\\xc4\\x86')\nand I got a response.\nresponse = b'\\x01\\x03\\x04B\\xc1ff\\x14='\nWhich I believe is unicode however I am not sure.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":55717691,"Users Score":0,"Answer":"Yes, I suppose you get an error, because modbus registers are 16 bits in length. The invalid start byte most likely means that you are starting your reading in the wrong register. Modbus registers are sequential, and have a weird offset from the docs. Like, say your reference states address 40088. By being 40xxx we can assume this is a Function 3 register, but is not mandatory. Now, in fact the address can be base 0 or base 1, meaning to substract or add 1 to it, making the real address 40087 in most cases.\nSo if you go and read 40088, you'll have a starting byte that doesn't match.\nAbout coding, modbus is Big endian for words and bytes, so you'd have to verify the decoder, and finally the RTU frame comes with a lot more information than the requested value. You need to read the modbus spec to know, but generally there's 1 byte for function, 2 bytes for length, 2 bytes for answer, then 1 byte for closing, or something like that. I don't know the details by heart, I use pymodbus! haha Cheers","Q_Score":0,"Tags":"python,modbus","A_Id":55731061,"CreationDate":"2019-04-16T23:00:00.000","Title":"RTU device has both 2 byte, 3 byte and 4 byte in repsonse; ie(0x03,0x04B,0xclff), what gives?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't understand the difference between dag_concurrency and parallelism. documentation and some of the related posts here somehow contradicts my findings.\nThe understanding I had before was that the parallelism parameter allows you to set the MAX number of global(across all DAGs) TaskRuns possible in airflow and dag_concurrency to mean the MAX number of TaskRuns possible for a single Dag.\nSo I set the parallelism to 8 and dag_concurrency to 4 and ran a single Dag. And I found out that it was running 8 TIs at a time but I was expecting it to run 4 at a time. \n\nHow is that possible? \nAlso, if it helps, I have set the pool size to 10 or so for these tasks. But that shouldn't have mattered as \"config\" parameters are given higher priorities than the pool's, Right?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":4743,"Q_Id":55722733,"Users Score":5,"Answer":"The other answer is only partially correct:\ndag_concurrency does not explicitly control tasks per worker. dag_concurrency is the number of tasks running simultaneously per dag_run. So if your DAG has a place where 10 tasks could be running simultaneously but you want to limit the traffic to the workers you would set dag_concurrency lower. \nThe queues and pools setting also have an effect on the number of tasks per worker. \nThese setting are very important as you start to build large libraries of simultaneously running DAGs. \nparallelism is the maximum number of tasks across all the workers and DAGs.","Q_Score":10,"Tags":"python,airflow","A_Id":55786029,"CreationDate":"2019-04-17T08:02:00.000","Title":"what's the difference between airflow's 'parallelism' and 'dag_concurrency'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm new to Django and Angular, I've just started my internship and I'm working on an application that uses Angular for the frontend and Django for the backend.\nI've added a new field to one of my models, I did the migration, but I don't know what the next step is going to be?  Do I need to add something in the views?\nMy goal is to also add this field on the user interface so that the user can select the correct information.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":55722896,"Users Score":0,"Answer":"Did you develop a rest API using Django for your Angular project? If so, you need to add (GET\/POST) Add method on your rest side and return the object with the field from the database. \nAs soon as you get the object you can do whatever you want on the frontend side, for example, view the field value to the user.","Q_Score":0,"Tags":"python,django,angular","A_Id":55723688,"CreationDate":"2019-04-17T08:13:00.000","Title":"Add a new field on my model and on my user interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have created a file called utils.py in my Django app, where I keep random classes or functions that do something.\nI have run into an issue, where I can't import any model in utils.py file.\nI have models called User which inherit from AbstractUser and it's been said to Django by: AUTH_USER_MODEL = 'main.User'\nI have also a model called Project.\nWhenever I type from main.models import Project or User in utils.py I get django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'main.User' that has not been installed\nOf course main is in installed apps in settings.\nI have solved this before by using get_user_model() for User, but there is no such a function to get a Project.\nHow to solve this problem? Am I missing something?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":251,"Q_Id":55724316,"Users Score":0,"Answer":"Circular import. I've been importing mixin from utils in model and in utils I've been importing model from models that inherited mixin.","Q_Score":0,"Tags":"python,django","A_Id":55724521,"CreationDate":"2019-04-17T09:29:00.000","Title":"Importing model in utils.py causes ImproperlyConfigured","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a testing file in \/dev\/shm\/testing.ini and a dev file in \/etc.\nIf I create two paster applications and trigger my tests, the **settings used in main method is getting overwritten by the 2nd one i.e. the dev one. How to overcome this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":37,"Q_Id":55724789,"Users Score":1,"Answer":"They aren't overwriting each other - the main function is just called twice, each time with the settings from the respective ini file. If you want your testing.ini file to inherit some settings from the dev.ini file then you need to look at the include syntax supported by pastedeploy, but I'd recommend just defining each file separately and using the correct one at the appropriate time instead of setting up an inheritance hierarchy of settings.","Q_Score":0,"Tags":"python,pyramid","A_Id":55732625,"CreationDate":"2019-04-17T09:51:00.000","Title":"How to read 2 different ini files via paster get_app function in pyramid?","Data 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 anyone help me with Databricks and Azure function?\nI'm trying to pass data bricks JSON output to azure function body in ADF job, is it possible? \nIf yes, How? \nIf No, what other alternatives to do the same?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5514,"Q_Id":55727018,"Users Score":1,"Answer":"In Azure Databricks, there is a way to return a value on exit. dbutils.notebook.exit(myReturnValueGoesHere)\nIn Azure Data Factory V2, the DatabricksNotebook activity outputs JSON with 3 fields:\n\"runPageUrl\" , a URL to see the output of the run.\n\"effectiveIntegrationRuntime\" , where the code is executing\n\"executionDuration\"\nIf you use the above dbutils call,  a fourth field will appear in the output JSON\n\"runOutput\" , where the \"myReturnValueGoesHere\" is displayed.\nIf you do not use the above dbutils call, you can scrape information from the runPageUrl.","Q_Score":4,"Tags":"python,json,azure-functions,azure-data-factory-2,azure-databricks","A_Id":55735608,"CreationDate":"2019-04-17T11:54:00.000","Title":"Can we pass Databricks output to function in an ADF Job?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have view_xx.py and view_yy.py and I also have a common views.py.\nI want to put a validation for checking that request.page_size is less than or equal to request.registry.settings[\"max_page_size\"].\nHow do I do this?\nIs it possible using contexts in a common views.py file?\nI am not sure how to put a context such that it first goes to view_xx.py depending on URL and then goes to common views function to validate page size and then again comes back to the view_xx.py view for further steps.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":34,"Q_Id":55728238,"Users Score":2,"Answer":"The simplest approach is to perform that check when setting\/computing request.page_size.","Q_Score":1,"Tags":"python,pyramid","A_Id":55732642,"CreationDate":"2019-04-17T13:05:00.000","Title":"How to put common validation to all views?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've been given access to an Ubuntu machine running Apache 2.4.18 for the purpose of hosting a small web application I've developed in Flask.  I'm a user without root privileges.  The system administrator has kindly installed mod_wsgi for me, but this module is linked against the system python, which is version 2.7, and I'd like to use python >= 3.6.  I've therefore compiled my own python 3.7 and my own mod_wsgi on this machine, and am having trouble getting Apache to use it.  Is this possible?\nI've tried adding a LoadModule wsgi_module ...\/mod_wsgi-py37.cpython-37m-x86-64-linux-gnu.so line to var\/www\/html\/whatever\/.htaccess, but have learned that this is not allowed at the Directory level of the configuration.  I've also tried using WSGIDaemonProcess user python-home=..., but this also causes Apache to return an Internal Server Error.\nTo make matters worse, I do not have permissions on var\/log\/apache2, so I can't see any Apache output except what it's serving.\nIs it possible to point Apache to my own mod_wsgi and python binaries without having access to the root configuration of Apache or the system?  If not, are there any workarounds?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":93,"Q_Id":55728668,"Users Score":1,"Answer":"AFAIK you can only run Apache with a single version of mod_wsgi at any one time.  This means that all apps must use the same version of Python, which is a problem I have run into before.  I think your options are:\na) Persuade the sysadmin to switch to your version.  It is fine to use a version of Python that is different to system Python.\nb) Have a look at something like Gunicorn.  That is more separated from Apache, so will allow apps to use different versions of Python on the same server.","Q_Score":1,"Tags":"python,apache,mod-wsgi","A_Id":55728980,"CreationDate":"2019-04-17T13:27:00.000","Title":"Use custom mod_wsgi and python with limited access to a shared 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":0,"Web Development":1},{"Question":"I am running ML model, which predicts fingure gestures.I am trying to simulate key press event in python using pynput library and I check it's working fine.But I have other program which Is a game written in python using pygame library , which opens up in a new window , but the problem is key press controls doesn't work on that, but it works when I manually press keyboard buttons.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2335,"Q_Id":55728777,"Users Score":0,"Answer":"I solved the problem by emulating key press event  using keyboard.press and listen the same event using keyboard.Listner() both are present in keyboard library.So I didn't use pygame functions to listen the event. Thanx everyone for ur help.","Q_Score":1,"Tags":"python-3.x,pygame,pynput","A_Id":55774018,"CreationDate":"2019-04-17T13:32:00.000","Title":"How to simulate key press event in python on another program running in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I added my applications on DigitalOcean. But when I turn on my website I see the error. \"502 Bad Gateway nginx\/1.14.0 (Ubuntu)\". I would like to solve it, but I do not know where I can find logs with errors.\nI always used CMD and when I tried to turn on the server, if something did not work, the CMD clearly said what was wrong. Where can I find something like this on DigitalOcean. I used PythonAnywhere once, and there was a separate tab with information about errors (practically the same as in CMS). Please forgive me for simple questions, I have little experience in servers and GIT.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1046,"Q_Id":55730655,"Users Score":1,"Answer":"502 probably means you got some errors in your application - you'd better check out your gunicorn(or other WSGI server) logs. Location of the logs depends on what WSGI server you're using but probably you can check it out in WSGI's config file.\nAlso you can try to do standard 'runserver' just to ensure that your application can run correctly. \nps aux | grep gunicorn (or smth like this command) can tell you if it's runnning.\nIf it's not, chek out the logs. Also, you can go to your config file, check the command that you're trying to use to start the server, try it out in the console.\nIn final you can ensure that your nginx config is correct too with nginx -t command.","Q_Score":0,"Tags":"python,django,digital-ocean","A_Id":55731993,"CreationDate":"2019-04-17T15:00:00.000","Title":"502 Bad Gateway. After implementing the application on 'digitalocean'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to save the output dataframe to a csv file while using pyinstaller to create an exe, but my code freezes and generate \"[Errno 13] Permission denied: '.\\Output.csv' \" error. My question is. what wrong using df.to_csv to save the output file in the same exe directory ? \nThanks in adcance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":281,"Q_Id":55730679,"Users Score":0,"Answer":"Look, if you use Innodb compiler then you will face a problem of permission denied error in the setup. So , I have tried to solve that by using temporary file but It is getting deleted after generation. But if you really want to solve this problem then use xlsxwriter and save it to a specific file location.","Q_Score":0,"Tags":"python,pyinstaller","A_Id":70164527,"CreationDate":"2019-04-17T15:01:00.000","Title":"pandas df to_csv freezes when using pyinstaller to save the df in the exe directory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an RGB image in the format of a 3D array with the shape of (m, n, 3). I would like to create a SimpleITK image. Using the GetImageFromArray() function results in creation of an image in 3D which is not what I am looking for. How can I create a 2D RGB image instead?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":443,"Q_Id":55730852,"Users Score":1,"Answer":"The documentation reads:\n\nSignature: sitk.GetImageFromArray(arr, isVector=None)\nDocstring: Get a SimpleITK Image from a numpy array. If isVector is True, then the Image will have a Vector pixel type, and the last dimension of the array will be considered the component index. By default when isVector is None, 4D images are automatically considered 3D vector images.\n\nHave you tried passing isVector=True?","Q_Score":0,"Tags":"python,image,simpleitk","A_Id":55731210,"CreationDate":"2019-04-17T15:10:00.000","Title":"2D RGB image construction from 3D array in SimpleITK","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to import win32api in python 2.7.9. i did the \"pip install pypiwin32\" and made sure all the files were intalled correctly (i have the win32api.pyd under ${PYTHON_HOME}\\Lib\\site-packages\\win32). i also tried coping the files from C:\\Python27\\Lib\\site-packages\\pywin32_system32 to C:\\Python27\\Lib\\site-packages\\win32. I also tried restarting my pc after each of these steps but nothing seems to work! i still get the error 'No module named 'win32api''","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":129,"Q_Id":55731387,"Users Score":0,"Answer":"Well, turns out the answer is upgrading my python to 3.6.\npython 2.7 seems to old to work with outside imports (I'm just guessing here, because its not the first time I'm having an import problem)\nhope it helps :)","Q_Score":0,"Tags":"python-2.7,pywin32","A_Id":55775086,"CreationDate":"2019-04-17T15:40:00.000","Title":"how do i fix \"No module named 'win32api'\" on python2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to paste few lines code from online sources with the symbol like \">>>\". My question is how to paste without these symbols? \n(Line by line works but it will be very annoying if pasting a big project.)\nCheers","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":55731644,"Users Score":0,"Answer":"Go to Edit > Find and Replace, in which find for >>> and replace with empty. Enjoy :)","Q_Score":0,"Tags":"python,jupyter-notebook,copy-paste","A_Id":55901372,"CreationDate":"2019-04-17T15:55:00.000","Title":"paste code to Jupyter notebook without symbols","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a RHEL system which by default was running Python2.7 and Python3.4 \nI needed Python3.6 for a project I wanted to work on and so I downloaded it and built it from source. I ran make and make install which hindsight may have been the wrong decision. \nNow I do not seem to have any internet connectivity. Does anyone know what I may have over written to cause this or at least where specifically I can look to track this issue down? \nNote: I can Putty into the Linux machine but it doesn't seem to have any other connectivity, specifically HTTPS","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":55733530,"Users Score":0,"Answer":"It's a bit weird that this would break network connectivity. One possible explanation is that the system has networking scripts or a network manager that relies on Python, and it got broken after make install replaced your default Python installation. It may be possible to fix this by reinstalling your RHEL Python packages (sorry, cannot offer more detailed help there, as I don't have access to a RHEL box).\nI guess the lesson is \"be careful about running make install as superuser\". To easily install and manage different Python versions (separate from the system Python), the Anaconda Python distribution would be a good solution.","Q_Score":0,"Tags":"python-3.x,makefile,centos,redhat","A_Id":55734315,"CreationDate":"2019-04-17T18:01:00.000","Title":"RHEL 7.6 - Built Python3.6 from Source Broke Network","Data Science and Machine Learning":0,"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 RHEL system which by default was running Python2.7 and Python3.4 \nI needed Python3.6 for a project I wanted to work on and so I downloaded it and built it from source. I ran make and make install which hindsight may have been the wrong decision. \nNow I do not seem to have any internet connectivity. Does anyone know what I may have over written to cause this or at least where specifically I can look to track this issue down? \nNote: I can Putty into the Linux machine but it doesn't seem to have any other connectivity, specifically HTTPS","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":55733530,"Users Score":0,"Answer":"So after a lot of time slamming my head against the wall I got it worked out. My best guess is that the system (RHEL 7) relied on something from its default Python2.7 installation to handle SSL negotiations. Installing 3.6 alongside must have overwritten some pointer. Had I done this correctly, with altinstall all would have likely been fine.\nThe most frustrating part of this is that there were no error messages, connections just timed out. \nTo fix this, I had to uninstall all Python versions and then reinstalled Python2.7 - Once Python2 was back in the system it all seemed to work well.","Q_Score":0,"Tags":"python-3.x,makefile,centos,redhat","A_Id":55763685,"CreationDate":"2019-04-17T18:01:00.000","Title":"RHEL 7.6 - Built Python3.6 from Source Broke Network","Data Science and Machine Learning":0,"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 notice that we say in python that sets have no order or arrangement, although of course you can sort the list generated from a set.\nSo I was wondering how the iteration over a set is defined in python. Does it just follow the sorted list ordering, or is there some other footgun that might crop up at some point?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":281,"Q_Id":55734364,"Users Score":1,"Answer":"A temporary order is used to iterate over the set, but you can't reliably predict it (practically speaking, as it depends on the insertion and deletion history of the set). If you need a specific order, use a list.","Q_Score":3,"Tags":"python,set","A_Id":55734436,"CreationDate":"2019-04-17T19:02:00.000","Title":"How can python iterate over a set if no order is defined?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to compile a library which takes the path to python3-config as one of it's arguments i.e. -DPYTHON_CONFIG=python3-config then sets various compiler flags based on it's contents. This file exists on my machine for python 3.6 as that's the system version, but I'm trying to build the library using a python 3.7.1 pyenv+virtualenv so I need to generate a corresponding python3-config for each specific python environment. How can I do this? All I've found so far is this file is generated by sudo apt-get install python-dev\nEdit: I've discovered that pyenv python3-config exists in \/home\/david\/.pyenv\/shims\/python\/python3-config but this version is much smaller than the version from \/usr\/bin\/python3-config","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2098,"Q_Id":55738280,"Users Score":1,"Answer":"I figured it out myself\nAssuming pyenv is installed in the recommended way, and python 3.7.1 is installed using pyenv then the paths to the required bin and config are:\n\n~\/.pyenv\/versions\/3.7.1\/bin\/python3.7\n~\/.pyenv\/versions\/3.7.1\/bin\/python3.7-config\n\npython3.7-config is a script which takes arguments like --includes and returns the info the build system requires to build and link the python extension for the specified pyenv, i.e.\n\n$ ~\/.pyenv\/versions\/3.7.1\/bin\/python3.7-config --includes\n-I\/home\/david\/.pyenv\/versions\/3.7.1\/include\/python3.7m","Q_Score":2,"Tags":"python,python-3.x,pyenv","A_Id":55770221,"CreationDate":"2019-04-18T02:22:00.000","Title":"Generate python3-config for pyenv + virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"if I try to import tkinter in my project, pycharm underlines tkinter as being a missing library.\nWhen I try to install the library, pycharm suggests to import the 'future' library instead of the tkinter library.  I don't know why.\nIf I go to the project interpreter window, I cannot find the tkinter library after clicking on the install packages button.\nOn the pycharm terminal, if I try to pip install tkinter it returns:\nCould not find a version that satisfies the requirement tkinter (from versions: )\nNo matching distribution found for tkinter\nI get the same result when trying pip install python-tk, pip install python3-tk, and pip install tk.\nDoes anyone know why this is?\nI imported the project from windows into Ubuntu Mint 19.1, I am using interpreter Python 3.7.2.  \nPlease let me know if I can add any more useful info.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1159,"Q_Id":55739464,"Users Score":0,"Answer":"I fixed the issue by uninstalling PyCharm, and reinstalling it from the command line.  The previous version I had installed it through the Linux Mint 19.1 Software Manager, and the version installed behaved in very strange ways; for instance it showed a completely different file tree to the one in my machine when trying to setup interpreters.\nHere is the command I used, as per JetBrains recommendation:\nsudo snap install [pycharm-professional|pycharm-community] --classic\nNote: I had to install snap first :)","Q_Score":2,"Tags":"python-3.x,ubuntu,tkinter,pycharm","A_Id":55747123,"CreationDate":"2019-04-18T05:08:00.000","Title":"tkinter is not recognized as a library when importing it on a pycharm project using python 3.x \u00bfWhy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run pulsar along with apache airflow. The catch is that both run on port number 8080. I do not want to change Airflow's configuration but in order to make pulsar run, I have to assign it another port. I am using a Python library, which runs airflow on 8080.\nI tried going through the standalone installation document but could not get anything through it. My aim is to run the Python client of Pulsar.\nHow do I change the port configuration of Pulsar?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":704,"Q_Id":55739811,"Users Score":1,"Answer":"For standalone, you can edit the conf\/standalone.conf config file and set webServicePort=8081","Q_Score":1,"Tags":"python,python-3.x,apache-pulsar","A_Id":55750424,"CreationDate":"2019-04-18T05:48:00.000","Title":"How do I change the port on which Pulsar is running?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have installed pip3 virtualenv and installed couple of packages to it by activating the virtualenv. At that time, the command which python gives the path of virtualenv. lets say ....\/env\/bin\/python\nBut after deactivate and source the path again (reactivating) which python uses the global path \/usr\/bin\/python which doesn't allow to use the packages I installed to virtualenv. Any thought of that?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":648,"Q_Id":55740123,"Users Score":0,"Answer":"It was a stupid mistake.\nthe virtualenv maintain a script in directory ....\/env\/bin named activate\nAnd the file uses absolute path to the export PATH and guess what can go wrong.\nLet's say the absolute PATH is \/home\/user\/test\/env\/bin\nAnd if you rename the directory test into test2. The activating file still uses old absolute path. So you have to manually change the PATH under ...\/env\/bin\/activate and change the VIRTUAL_ENV variable to your new absolute path","Q_Score":0,"Tags":"python,path,pip,virtualenv","A_Id":55740717,"CreationDate":"2019-04-18T06:19:00.000","Title":"pip virtualenv reset the path after reactivating","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have installed pip3 virtualenv and installed couple of packages to it by activating the virtualenv. At that time, the command which python gives the path of virtualenv. lets say ....\/env\/bin\/python\nBut after deactivate and source the path again (reactivating) which python uses the global path \/usr\/bin\/python which doesn't allow to use the packages I installed to virtualenv. Any thought of that?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":648,"Q_Id":55740123,"Users Score":0,"Answer":"Normally it does not happen. upon reactivating it should pick from virtualenv python. \nMy two cents. \n\nVirtualenv adding the python in end of PATH variable. so\nusr\/bin\/python will be in front found n run.\nIt also can happen if your .bash_profile got issues. It may also\nif virtual env is created in python3 and by default it will have\npython2.7\n\nSo you need to check both path and both env global vs virtual env one.","Q_Score":0,"Tags":"python,path,pip,virtualenv","A_Id":55740509,"CreationDate":"2019-04-18T06:19:00.000","Title":"pip virtualenv reset the path after reactivating","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have an extremely large set of data stored in json that is too large to load in memory. The json fields contain data about users and some metadata - however, there are certainly some duplicates. I would like to go through this file and curate it, merging the duplicates in a specific way. \nHowever, I am not sure what the best practice to do so is. I thought of using a bloom filter, but a bloom filter won't let me know what the duplicate is a duplicate of, so I cannot exactly merge. Is there something I could read\/see on what the best practice for something like this is? What are some industry standards? All of this needs to be done in python.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":118,"Q_Id":55740183,"Users Score":1,"Answer":"You can partition the records by hash value into smaller sets that fit into memory, remove duplicates in each set, and then reassemble them back into one file.","Q_Score":0,"Tags":"python,json,data-structures","A_Id":55762539,"CreationDate":"2019-04-18T06:23:00.000","Title":"What are some viable strategies to detecting duplicates in a large json file when you need to store the duplicates?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to write a function that when given two cameras, their rotation, translation matrices, focal point, and the coordinates of a point for each camera, will be able to triangulate the point into 3D space. Basically, given all the extrinsic\/intrinsic values needed\nI'm familiar with the general idea: to somehow create two rays and find the closest point that satisfies the least squares problem, however, I don't know exactly how to translate the given information to a series of equations to the coordinate point in 3D.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1933,"Q_Id":55740284,"Users Score":0,"Answer":"Assume you have two cameras -- camera 1 and camera 2. \nFor each camera j = 1, 2  you are given:\n\nThe distance hj between it's center Oj, (is \"focal point\" the right term? Basically the point Oj from which the camera is looking at its screen) and the camera's screen. The camera's coordinate system is centered at Oj, the Oj--->x and Oj--->y axes are parallel to the screen, while the Oj--->z axis is perpendicular to the screen.   \nThe 3 x 3 rotation matrix Uj and the 3 x 1 translation vector Tj which transforms the Cartesian 3D coordinates with respect to the system of camera j (see point 1) to the world-coordinates, i.e. the coordinates with respect to a third coordinate system from which all points in the 3D world are described.\nOn the screen of camera j, which is the plane parallel to the plane Oj-x-y and at a distance hj from the origin Oj, you have the 2D coordinates (let's say the x,y coordinates only) of point pj, where the two points p1 and p2 are in fact the projected images of the same point P, somewhere in 3D, onto the screens of camera 1 and 2 respectively. The projection is obtained by drawing the 3D line between point Oj and point P and defining point pj as the unique intersection point of this line with with the screen of camera j. The equation of the screen in camera j's 3D coordinate system is z = hj , so the coordinates of point pj with respect to the 3D coordinate system of camera j look like pj = (xj, yj, hj) and so the 2D screen coordinates are simply pj = (xj, yj) .  \n\nInput: You are given the 2D points p1 = (x1, y1),  p2 = (x2, y2) , the twp cameras' focal distances h1,  h2 , two 3 x 3 rotation matrices U1 and U2, two translation 3 x 1 vector columns T1 and T2 . \nOutput: The coordinates P = (x0, y0, z0) of point P in the world coordinate system.  \nOne somewhat simple way to do this, avoiding homogeneous coordinates and projection matrices (which is fine too and more or less equivalent), is the following algorithm:\n\nForm Q1 = [x1; y1; h1] and Q2 = [x2; y2; h2] , where they are interpreted as 3 x 1 vector columns;\nTransform P1 = U1*Q1 + T1  and P2 = U1*Q2 + T1 , where * is matrix multiplication, here it is a 3 x 3 matrix multiplied by a 3 x 1 column, givin a 3 x 1 column;\nForm the lines X = T1 + t1*(P1 - T1) and  X = T2 + t2*(P2 - T2) ;\nThe two lines from the preceding step 3 either intersect at a common point, which is the point P or they are skew lines, i.e. they do not intersect but are not parallel (not coplanar).     \nIf the lines are skew lines, find the unique point X1 on the first line and the uniqe point X2 on the second line such that the vector X2 - X1 is perpendicular to both lines, i.e. X2 - X1 is perpendicular to both vectors  P1 - T1 and P2 - T2. These two point X1 and X2 are the closest points on the two lines. Then point P = (X1 + X2)\/2 can be taken as the midpoint of the segment X1 X2.  \n\nIn general, the two lines should pass very close to each other, so the two points X1 and X2 should be very close to each other.","Q_Score":2,"Tags":"python,numpy,triangulation,vision","A_Id":56049754,"CreationDate":"2019-04-18T06:31:00.000","Title":"How to triangulate a point in 3D space, given coordinate points in 2 image and extrinsic values of the camera","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created an exe from my Python application, which is a GUI that hooks up to a SQL database and allows the user to populate data with the fields. Running the Python script works fine by itself, but running the exe I get the error\nFile \"C:\\Python34\\lib\\codecs.py\", line 319, in decode\n    (result, consumed) = self._buffer_decode(data, self.errors, final)\nUnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2: invalid start byte\nThis refers to the line (result, consumed) = self._buffer_decode(data, self.errors, final)\nI have already modified tokenize.py line 392 from \nline_string = line.decode('utf-8') to\nline_string = line.decode('utf-8', 'ignore' as suggested which removed the same error for that module, but now I get the same error for codec.py.\nI can't use the same fix with this one. Is this a bug and is it easy to fix?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":558,"Q_Id":55740374,"Users Score":0,"Answer":"I found the problem. I have a Python script which is used for embedding the icon into the panel. I commented out the following which is used for backwards compatibility\ngetBitmap = wx.deprecated(GetBitmap)\n    getData = wx.deprecated(GetData)\n    getIcon = wx.deprecated(GetIcon)\n    getImage = wx.deprecated(GetImage)\nand it now works. I obtained this code from another site.","Q_Score":0,"Tags":"python,utf-8,runtime-error,exe","A_Id":55821145,"CreationDate":"2019-04-18T06:37:00.000","Title":"Python 3.4.4 application works but exe fails with utf-8 error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using thrift with python and at disconnection I currently catch the TTransportException in order to attempt a reconnection. This works fine most of the time, but sometimes the error I get is ConnectionResetError which is naturally not caught. Now my question is : which exception do I have to catch in order to attempt a reconnection even if I get a ConnectionResetError. \nI don't want to simply catch TException, or Exception but only exceptions caused by a disconnection.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":55747582,"Users Score":0,"Answer":"The exception you're looking for is thrift.transport.TTransport.TTransport.Exception\nTransport exceptions are raised when you have connection problems.","Q_Score":0,"Tags":"python,exception,thrift","A_Id":57372054,"CreationDate":"2019-04-18T13:56:00.000","Title":"Which is the exception raised that gives \"ConnectionResetError\" in thrift python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running an airflow DAG and wanted to understand how the execution date gets set. This is the code I am running: \n{{ execution_date.replace(day=1).strftime(\"%Y-%m-%d\") }} \nThis always returns the first day of the month. This is the functionality that I want, but I just want to find a way to understand what is happening.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":495,"Q_Id":55748657,"Users Score":1,"Answer":"The reason this always returns the first of the month is that you are using a Replace to ensure the day is forced to be the 1st of the month. Simply remove \".replace(day=1)\".","Q_Score":2,"Tags":"python,airflow","A_Id":55748730,"CreationDate":"2019-04-18T14:54:00.000","Title":"Understanding execution_date in Airflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am running an airflow DAG and wanted to understand how the execution date gets set. This is the code I am running: \n{{ execution_date.replace(day=1).strftime(\"%Y-%m-%d\") }} \nThis always returns the first day of the month. This is the functionality that I want, but I just want to find a way to understand what is happening.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":495,"Q_Id":55748657,"Users Score":0,"Answer":"execution_date returns a datatime object. You are using the replace method of that object to replace the \u201cday\u201d with the first. Then outputting that to a string with the format method.","Q_Score":2,"Tags":"python,airflow","A_Id":55750885,"CreationDate":"2019-04-18T14:54:00.000","Title":"Understanding execution_date in Airflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"While I was reading aiohttp server documentation, I came across this \nWarning\nUse add_static() for development only. In production, static content should be processed by web servers like nginx or apache.\nWhy cant we use aiohttp to serve static files?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":813,"Q_Id":55749618,"Users Score":4,"Answer":"Why cant we use aiohttp to serve static files?\n\nYou can use aiohttp to serve static, but you shouldn't.\nWeb frameworks like aiohttp are specialized in providing convenient API to create dynamically generated responses (like web pages). They aren't specialized in serving responses with most efficiency and security.\nServers like NGINX on the other hand are specialized in serving things. They can do it more efficiently (C code speed, multiple cores utilization, caching) and secure (protection from common attacks, IP filtering, etc.).\nSince static files aren't dynamically generated there's no need to involve aiohttp in serving them. Specialized server will handle their serving much better. It's a common practice to delegate this job to them.","Q_Score":2,"Tags":"python-3.x,python-asyncio,aiohttp","A_Id":55750115,"CreationDate":"2019-04-18T15:47:00.000","Title":"why cant we use aiohttp to serve static files for production?","Data Science and Machine Learning":0,"Database and SQL":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 personal project that has been refactored a number of times. It started off using multithreading, then parts of it used asyncio, and now it is back to being mainly single threaded.\nAs a result of all these changes I have a number of threading.Lock()'s in the code that I would like to remove and cleanup to prevent future issues.  \nHow can I easily work out which locks are in use and hit by more than one thread during the runtime of the application?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":55751007,"Users Score":1,"Answer":"If I am in the situation to find that out, I would try to replace the lock with a wrapper that do the counting (or print something, raise an exception, etc.) for me when the undesired behavior happened. Python is hacky, so I can simply create a function and overwrite the original threading.Lock to get the job done. That might need some careful implementation, e.g., catch both all possible pathway to lock and unlock.\nHowever, you have to be careful that even so, you might not exercise all possible code path and thus never know if you really remove all \"bugs\".","Q_Score":1,"Tags":"python,python-3.x,multithreading,python-multithreading","A_Id":55751211,"CreationDate":"2019-04-18T17:24:00.000","Title":"Is there a way to find out if Python threading locks are ever used by more than one thread?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a machine learning classification task in which I have trained many models with different algorithms in scikit-learn and Random Forest Classifier performed the best. Now I want to train the model further with new examples but if I train the same model by calling the fit method on new examples then it will start training the model from beginning by erasing the old parameters. \nSo, how can I train the trained model by training it with new examples in scikit-learn?\nI got some idea by reading online to pickle and unpickle the model but how would it help I don't know.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":845,"Q_Id":55751844,"Users Score":0,"Answer":"Append the new data to your existing dataset, and train over the whole thing. Might want to reserve some of the new data for your testset.","Q_Score":1,"Tags":"python,python-3.x,machine-learning,scikit-learn","A_Id":55767754,"CreationDate":"2019-04-18T18:25:00.000","Title":"How to train a trained model with new examples in scikit-learn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Primary Question\nWhen solving a NLP in Pyomo, using IPOPT as the solver, how can I tell IPOPT what the gradient of the objective function and\/or constraints are? I have to pass a callable function that returns objective values--can I likewise pass a callable function that evaluates the gradient as well?\nSecondary Question\nHow does Pyomo+IPOPT handle this by default? When I solve a simple NLP with Pyomo+IPOPT, part of the IPOPT output includes \"number of objective gradient evaluations\"...but how is it evaluating the gradient? Numerically with finite differences, or something?\nI'm using Pyomo 5.6 with Python 3.6 and IPOPT 3.7.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":561,"Q_Id":55753497,"Users Score":1,"Answer":"Pyomo provides first and second derivative information using the automatic differentiation features in the Ampl Solver Library (ASL). When calling IPOPT, Pyomo outputs your model using the '.nl' file format which is read by the ASL and linked to IPOPT. So you don't have to do anything to provide gradient information, this is done automatically.","Q_Score":1,"Tags":"python-3.x,pyomo,ipopt","A_Id":55795347,"CreationDate":"2019-04-18T20:43:00.000","Title":"How to specify gradient in Pyomo with IPOPT","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Am struggling with training wikipedia dump on doc2vec model, not experienced in setting up a server as a local machine is out of question due to the ram it requires to do the training. I couldnt find a pre trained model except outdated copies for python 2.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":200,"Q_Id":55756841,"Users Score":1,"Answer":"I'm not aware of any publicly-available standard gensim Doc2Vec models trained on Wikipedia.","Q_Score":0,"Tags":"python,nlp,gensim,word2vec,doc2vec","A_Id":55779081,"CreationDate":"2019-04-19T05:02:00.000","Title":"Where to find a pretrained doc2vec model on Wikipedia or large article dataset like Google news?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a Python script (format .py) that works.\nI would like to convert this file to .exe, to use it in a computer without having Python installed.\nHow can I do?\nI have Python from Anaconda3.\nWhat can I do?\nThank you!\nI followed some instruction found here on Stackoverflow.\n.I modify the Path in the 'Environment variables' in the windows settings, edited to the Anaconda folder.\n.I managed to install pip in conda prompt (I guess).\nStill, nothing is working. I don't know how to proceed and in general how to do things properly.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2453,"Q_Id":55760356,"Users Score":2,"Answer":"I personaly use pyinstaller, its available from pip.\nBut it will not really compile, it will just bundle.\nThe difference is compiling means translating to real machine code while bundling is creating a big exe file with all your libs and your python interpreter.\nEven if pyinstaller create bigger file and is slower than cython (at execution), I prefer it because it work all the time without work (except lunching it).","Q_Score":0,"Tags":"python-3.x,windows,anaconda,executable","A_Id":55760631,"CreationDate":"2019-04-19T10:22:00.000","Title":"How to convert file .py to .exe, having Python from Anaconda Navigator? (in which command prompt should I write installation codes?)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I receive data with an Raspberry Pi3 from another device with an ATMEGA 8 Chip via serial port, what I receive should look like : #00 341 341 332 13123 R-? ...\nBut what I receive on my Raspberry is:\nb'\\xff\\xfa\\xfd\\xff\\xff\\xff\\xff\\xff\\xff\\xfd\\xff\\xea~\\xf8\\xff\\xfe\\xfe\\xff\\xd5\\xff\\xfe\\xfd\\xff\\xff\\xfd\\xff\\xff\\xff'\nMy port config:\nport = serial.Serial(\"\/dev\/ttyAMA0\", baudrate=115200, timeout=3.0)\nHow do I decode this or do you have any other suggestions?\nI already tried to encode to utf-8, ascii etc. \nI also tried codecs.\nI just got errors or some more disturbing data. Nothin I can work with.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":337,"Q_Id":55760510,"Users Score":0,"Answer":"Your baudrate is big, try it with a regular value like 9600, also verify you have the same baudrate on both side.","Q_Score":0,"Tags":"python,raspberry-pi,serial-port,decode,uart","A_Id":55760785,"CreationDate":"2019-04-19T10:35:00.000","Title":"Why do I receive unreadable data via serial Port 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":0,"Web Development":0},{"Question":"I want to be able to change the windows mouse cursors into a custom one (with the .ani or .cur extention) globally using a python script. Is there any package or module that can help me accomplish this?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1342,"Q_Id":55761267,"Users Score":1,"Answer":"It cannot be done globally, since it would break a security constraints. Application is not allowed modify anything over other applications or system windows.\nIt can be done by system C API only by processes run by root\/administrator. Probably no one made a Python bindings for such functions. It is possible, but due to limited use I don't think there is any Python module doing that.","Q_Score":1,"Tags":"python,cursor","A_Id":55761964,"CreationDate":"2019-04-19T11:40:00.000","Title":"Is there a way to change windows mouse cursors to a custom one using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After having to increase max_length of another field in a model, I've started to wonder: maybe this is not the way?\nI'm getting data from an external API, so I can't check what's the maximum length. Let's say that I'm guessing the field can have 100 chars - because it makes sense, but I have no idea if this is actually the case, there might appear a value which is 300 chars long. What's the recommended approach here? \n1) Truncate the value (where should I put the code then? and what with fields such as URL, which won't work after truncating?)?\n2) Skip the value?\n3) Set length of every field to 100*expected length?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2209,"Q_Id":55762514,"Users Score":9,"Answer":"The point of max_length is that you decide it. If you really want variable\/unlimited length text, use TextField instead.\nThe max_length is enforced on database level, If it's longer, it will just fail. If you want to truncate it from code side, you have to do it yourself, most likely in the function where you create the entry.\n\nNote that, many databases optimize text fields, so there's no penalty in  performance for varying length text.","Q_Score":4,"Tags":"python,django,django-models","A_Id":55762613,"CreationDate":"2019-04-19T13:18:00.000","Title":"Best practices for unknown max_length in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"After having to increase max_length of another field in a model, I've started to wonder: maybe this is not the way?\nI'm getting data from an external API, so I can't check what's the maximum length. Let's say that I'm guessing the field can have 100 chars - because it makes sense, but I have no idea if this is actually the case, there might appear a value which is 300 chars long. What's the recommended approach here? \n1) Truncate the value (where should I put the code then? and what with fields such as URL, which won't work after truncating?)?\n2) Skip the value?\n3) Set length of every field to 100*expected length?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2209,"Q_Id":55762514,"Users Score":2,"Answer":"Expanding on blue_notes response I'd recommend that you always use TextField instead of CharField unless the datatype has a fundamental maximum length.  For example, ISO currency codes are always exactly 3 characters and make sense as a CharField.\nIn many situations using a max length character field will result in worse performance in the database then than using their unlimited length varchar field if the field length isn't actually fixed","Q_Score":4,"Tags":"python,django,django-models","A_Id":55763167,"CreationDate":"2019-04-19T13:18:00.000","Title":"Best practices for unknown max_length in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to build a image classifier using cnn. My images are of (256,256) pixel size. \nWhat will happen if i train the cnn by setting the input shape as (64,64) or (128,128), since (256,256) will take a lot of time to process?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":443,"Q_Id":55762873,"Users Score":0,"Answer":"Make sure your image size is same as the size your Input layer is expecting. Classification architectures, in general, are not flexible to the spatial dimensions of your input. So, that is important. Otherwise you will get a shape mismatch error.\nIn case you want to change the input shape of your model, that is possible to do. It's hard to say exactly how it will affect your classification. You have to, probably, also tune your CNN filters so that the filters are not bigger than your feature maps. Otherwise that might downgrade your performance. But you can try that out and see what happens.","Q_Score":0,"Tags":"python,keras,classification,conv-neural-network","A_Id":55763023,"CreationDate":"2019-04-19T13:46:00.000","Title":"input shape of convolutional neural network in keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a image classifier using cnn. My images are of (256,256) pixel size. \nWhat will happen if i train the cnn by setting the input shape as (64,64) or (128,128), since (256,256) will take a lot of time to process?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":443,"Q_Id":55762873,"Users Score":0,"Answer":"It will throw an error. You can resize you images with cv2.resize() or you can put the right input shape in your cnn layer and then put a maxpooling layer to reduce the number of parameters.","Q_Score":0,"Tags":"python,keras,classification,conv-neural-network","A_Id":55762953,"CreationDate":"2019-04-19T13:46:00.000","Title":"input shape of convolutional neural network in keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to get the rospy lib into PyCharm for autocompleting and highlighting error without installing ROS on my MAC?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":532,"Q_Id":55763482,"Users Score":-1,"Answer":"No, this is not possible, because without the package installed PyCharm does not know what to autocomplete.","Q_Score":0,"Tags":"python,ide,pycharm,ros,rospy","A_Id":55763650,"CreationDate":"2019-04-19T14:34:00.000","Title":"Is It possible to develop ROS in Python without installing ROS on the development computer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use \"math.sqrt\" and my output should have 4 decimal after point even for numbers like \"4\". is there any func or way?!\nI used \"round(num_sqrt, 4)\" but it didn't work.\nmy input is like:\n1\n2\n3\n19\noutput must be:\n1.0000\n1.4142\n1.7320\n4.3588\nand my output is:\n1.0\n1.4142\n1.7320\n4.3588","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":55763795,"Users Score":0,"Answer":"Try this if you really need unnecessary zeros:\ndef format_floats(reference, values):\n    formatted_values = []\n    for i in range(len(values)):\n        length = len(str(reference)[str(reference).find(\".\"):])-1\n        new_float = str(round(values[i], length))\n        new_float += \"0\"*(len(str(reference))-len(new_float))\n        formatted_values.append(new_float)\n\n    return formatted_values\n\nif __name__ == '__main__':\n\n    reference = 0.12345\n    values = [1.04, 2.045, 2.0]\n\n    print(format_floats(reference, values))\n\n\noutput: ['1.04000', '2.04500', '2.00000']","Q_Score":0,"Tags":"python","A_Id":55763943,"CreationDate":"2019-04-19T14:59:00.000","Title":"How to round number to constant decimal","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Nvidia Jetson tx2 with the orbitty shield on it. \nI got it from a friend who worked on it last year. It came with ubuntu 16.04. I updated everything on it and i installed the latest python3.7 and pip.\nI tried checking the version of opencv to see what i have but when i do import cv2 it gives me :\nTraceback (most recent call last):\n  File \"\", line 1, in \nModuleNotFoundError: No module named 'cv2'\nSomehow besides python3.7 i have python2.7 and python3.5 installed. If i try to import cv2 on python2.7 and 3.5 it works, but in 3.7 it doesn't. \nCan u tell me how can i install opencv in python3.7 and the latest version?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1498,"Q_Id":55764829,"Users Score":0,"Answer":"Does python-3.7 -m pip install opencv-python work? You may have to change the python-3.7 to whatever path\/alias you use to open your own python 3.7.","Q_Score":2,"Tags":"python,opencv,ubuntu","A_Id":55764936,"CreationDate":"2019-04-19T16:25:00.000","Title":"How can i install opencv in python3.7 on ubuntu?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"what is best and easy way for convert maya py (python) to pyd ? \nI had explored in this field, but unfortunately none of them was effective and after convert to pyd I can't import my code into Maya.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":190,"Q_Id":55769570,"Users Score":0,"Answer":"pyd files contain native binary python extensions, usially developped using Python C API and some native language.\ncython might be the simplest tool that might help you creating pyd by compiling a subset of Python source code.\nWhat are you trying to achieve ?","Q_Score":0,"Tags":"python,maya","A_Id":55935788,"CreationDate":"2019-04-20T01:49:00.000","Title":"what is best way for convert maya py (python) to pyd?","Data 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":"Accidentally selected \"Don't show this prompt again\" when prompted to install Pylint in VSCode Python. How should I undo\/reset the action so the prompt will appear again?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2497,"Q_Id":55770069,"Users Score":0,"Answer":"To anyone coming here from Google, if you're looking to reset the \"Are you sure you want to move 'file' into 'folder'?\" prompt:\nOn macOS, open \/Users\/[username]\/Library\/Application Support\/Code\/User\/settings.json and remove \"explorer.confirmDragAndDrop\": false.\nIt's a similar process on Windows and Linux \u270c\ufe0f","Q_Score":7,"Tags":"visual-studio-code,vscode-python","A_Id":71857486,"CreationDate":"2019-04-20T03:47:00.000","Title":"How to undo \"Don't show this prompt again\" in vscode python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to AIML 2.0 can any one suggest me the available interpretors that support AIML 2.0,and some useful resources. \nThanks in Advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":157,"Q_Id":55772915,"Users Score":0,"Answer":"Hi I\u2019m the author of program-y. It\u2019s fully aiml 2.1 compliant and 100% Python 3","Q_Score":0,"Tags":"python-3.7,aiml","A_Id":56017401,"CreationDate":"2019-04-20T11:09:00.000","Title":"Interpretors of AIML 2.0","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to convert that data type to string. Even that's not working.\nExample: str(0123)\nBut this is possible a=\"0123\".\nMy complete assumption is 0123 is not accepted because it is octal not an integer. So, octal are not allowed in python. Please correct me if i'm wrong.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":311,"Q_Id":55773185,"Users Score":0,"Answer":"You're looking for 0o123. Numbers that start with only a zero, which is not the only symbol in the token, are invalid syntax.","Q_Score":1,"Tags":"python,python-3.x","A_Id":55773215,"CreationDate":"2019-04-20T11:43:00.000","Title":"Can't we assign a value that starts with 0(zero) to a variable ? example: a=0123. This throws error \"invalid token\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm listening my own binded socket on addr \"127.0.0.0\", and sending some traffic. Socket is SOCK_STREAM. \nMay i get sequence_number and acknowledgement_number of incoming packet with getsockopt? If you now, please write arguments of this func. in python\nThank you:)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":350,"Q_Id":55776616,"Users Score":0,"Answer":"I'm listening my own binded socket on addr  ... May i get sequence_number and acknowledgement_number of incoming packet with getsockopt? \n\nYou will not get information about sequence numbers from a plain TCP socket, i.e. one created by socket.socket(socket.AF_INET, socket.SOCK_STREAM).","Q_Score":0,"Tags":"python,tcp,getsockopt","A_Id":55777027,"CreationDate":"2019-04-20T18:38:00.000","Title":"How to know 'sequence number' wiht getsockopt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using CatBoost for ranking task. I am using QueryRMSE as my loss function. I notice for some features, the feature importance values are negative and I don't know how to interpret them.\nIt says in the documentation, the i-th feature importance is calculated as the difference between loss(model with i-th feature excluded) - loss(model).\nSo a negative feature importance value means that feature makes my loss go up?\nWhat does that suggest then?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2295,"Q_Id":55777986,"Users Score":0,"Answer":"Negative feature importance value means that feature makes the loss go up. This means that your model is not getting good use of this feature. This might mean that your model is underfit (not enough iteration and it has not used the feature enough) or that the feature is not good and you can try removing it to improve final quality.","Q_Score":0,"Tags":"python,machine-learning,catboost","A_Id":56173568,"CreationDate":"2019-04-20T21:40:00.000","Title":"Negative Feature Importance Value in CatBoost LossFunctionChange","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"1) I'm running into a problem with my script using arguments parsed with argparse.ArgumentParser\nso I'd like to be able to check typing of my script but when I add some arguments, I get a unrecognized arguments: --import_dir \/tmp\/someDir\/ running \nmypy myscript.py --import_dir \/tmp\/someDir\nit seems that the arguments are passed to mypy and not myscript.py. Is there a way to get rid of that?\n2) More than that, I'm using pyenv to set my version of python to be able to have types on a debian stable system. So if I run only my python script without arguments, I run into a Variable annotation syntax is only supported in Python 3.6 and greater\n problem because the system version is the stable debian version.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":490,"Q_Id":55778643,"Users Score":1,"Answer":"mypy is a tool for use during development. You typically don't run it at all in production, as the code itself isn't changed by deploying it. Any differences between your two environments should by definition be runtime changes, which mypy doesn't help with.\nAssuming mypy myscript.py passes before deployment, it will continue to do so after, so there is no need to run it in production.\nIn the end, Python is and will remain a dynamically typed language; static type hinting is a tool for finding and preventing bugs, but doesn't affect how your code ultimately runs.","Q_Score":0,"Tags":"python,mypy,pyenv","A_Id":55782834,"CreationDate":"2019-04-20T23:34:00.000","Title":"python: mypy with arguments to script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a SQL Server Agent job that executes some python scripts using CmdExec. Everything is set up with a proxy account as expected.\nWhen I run the job I get: \nMessage\nExecuted as user: domain\\proxyaccount. 'python' is not recognized as an internal or external command,  operable program or batch file.  Process Exit Code 1.  The step failed.\nI'm using Anaconda and Python is in the system PATH variable. When I run python from command line, it works. When I run python cutting and pasting the specific command from the job, it works. When I use runas to mimic the proxy account it works. The only place Python doesn't run is form inside the job. \nWhat else do I need to look at to trouble shoot this issue?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":293,"Q_Id":55778669,"Users Score":1,"Answer":"You should restart SQL Server Agent after you installed Python on the server.\nIt is necessary for SQL Server Agent to load new environment variables, including the updated PATH with Python in it.\nThere are also suggestions to restart SQL Server too, but I believe restarting SQL Server Agent will be enough.","Q_Score":0,"Tags":"python,sql-server,sql-server-agent","A_Id":55784557,"CreationDate":"2019-04-20T23:40:00.000","Title":"Python Won't Run Even Through It Is In the Path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Uing BAsh console i installed Steem Module for Python3.6\nand everything seems right but when i try to run my python script in Pythonanywhere it says there is problem connecting with api.steemit.com\nbut the script works fine in my PC. \ncode \n    import steem\n    from steem import Steem\n    s=Steem()\n    s.get_account_history(your_ac, index_from=-1, limit=12)\nlog is here. Is there any way to solve this issue?\nWARNING:root:Retry in 1s -- MaxRetryError: HTTPSConnectionPool(host='api.steemit.com', port=443): Max retries exceeded with url: \/ (Caused by NewC\nonnectionError(': Failed to establish a new connection: [Errno 111] Connectio\nn refused',))\nWARNING:urllib3.connectionpool:Retrying (Retry(total=19, connect=None, read=None, redirect=0, status=None)) after connection broken by 'NewConnect\nionError(': Failed to establish a new connection: [Errno 111] Connection refu\nsed',)': \/","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":159,"Q_Id":55779701,"Users Score":3,"Answer":"External connections for free accounts on PythonAnywhere are passed through a proxy. The error you're getting looks like the library you're using is not using the proxy. Check the docs for the library to see how to configure it to use a proxy. If it does not support it, contact the authors to see if they can add support for proxies.","Q_Score":1,"Tags":"https,pythonanywhere,connection-refused","A_Id":55797086,"CreationDate":"2019-04-21T03:46:00.000","Title":"Connection Refused in pythonAnwhere","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"There are two ways to document a module, function, or class in the code itself: comments and docstrings.\nDocstrings are more functional, as they can be accessed via the help() function, while comments can only be accessed in the source code.\nWhen should comments be used in place of docstrings?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":55780298,"Users Score":1,"Answer":"Docstrings are meant to explain what a function does, in terms of what kinds and types of values it takes and returns, from a user's perspective.\nComments, on the other hand, being in the body of the source code, will only be visible to those actually reading it, and accordingly serve to explain how it does what it does.","Q_Score":0,"Tags":"python,comments,docstring","A_Id":55780318,"CreationDate":"2019-04-21T06:02:00.000","Title":"Why should I use comments when documenting python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to extract audio track information (specifically language of the audio) from a live stream that i will be playing with libVLC . Is it possible to do this in javascript or python without writing new code for a wrapper?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":55780457,"Users Score":0,"Answer":"Not sure about javascript, but the Python wrapper will let you do this.","Q_Score":0,"Tags":"javascript,python,node.js,libvlc","A_Id":55788853,"CreationDate":"2019-04-21T06:29:00.000","Title":"Is it possible to get audio track data from libVLC by using javascript\/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":1},{"Question":"I am fairly new to Python. I have a django based web application where I am performing some tasks using Kafka. \nI am using confluent-kafka wrapper to communicate with the Kafka Broker.\nSo once a topic is created on the kafka broker, I assign a consumer to subscribe to this process, to make this non-blocking, I am using multiprocessing module so that the consumer runs on a separate thread and not block the main application thread.\nHowever, I am not sure, what will happen if my server shuts down? Will the process still run like how the cronjobs still run even if the server is not running?\nIf not can someone please suggest me how should I trigger my consumer so that it is independent of my django server?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1108,"Q_Id":55781423,"Users Score":0,"Answer":"If you need your web server to actually get the data from Kafka, they need to be running together.\nYou probably don't want the consumer actively running in the background (as a separate process, not a thread) because then you're effectively not processing messages. \nDepending on what your data is, you could use Kafka Connect on the same machine as Django to write the Kafka events to a database, then Django would query the database instead","Q_Score":0,"Tags":"django,python-3.x,multithreading,apache-kafka","A_Id":55784029,"CreationDate":"2019-04-21T09:16:00.000","Title":"How to create a kafka consumer independent of Django server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am fairly new to Python. I have a django based web application where I am performing some tasks using Kafka. \nI am using confluent-kafka wrapper to communicate with the Kafka Broker.\nSo once a topic is created on the kafka broker, I assign a consumer to subscribe to this process, to make this non-blocking, I am using multiprocessing module so that the consumer runs on a separate thread and not block the main application thread.\nHowever, I am not sure, what will happen if my server shuts down? Will the process still run like how the cronjobs still run even if the server is not running?\nIf not can someone please suggest me how should I trigger my consumer so that it is independent of my django server?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1108,"Q_Id":55781423,"Users Score":0,"Answer":"bind the signals:\nsignal.signal(signal.SIGTERM, signal_handler)\nsignal.signal(signal.SIGINT, signal_handler)\nand use try-except blok and you can do a clean up afterwards.\nto make consumer more independend, you can use django-celery-beat","Q_Score":0,"Tags":"django,python-3.x,multithreading,apache-kafka","A_Id":69200577,"CreationDate":"2019-04-21T09:16:00.000","Title":"How to create a kafka consumer independent of Django server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have an application (dev stage) running on one validator, one transaction processor and client. I would like to update the way I create addresses. If I change the way I create addresses, the old addresses won't be accessible. I would like to know what is the practice that should be followed in order to achieve the aforementioned.\nRight now, if I make any changes at the processor level, I simply flush the existing blockchain and create a new genesis block and start over. I know this isn't the way it should be.\nPlease advise.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":82,"Q_Id":55783073,"Users Score":2,"Answer":"You can read all the current addresses and write the value to the new address. Use the delete_state in the SDK to delete the old state variable. The data will remain in previously-created blocks (which are immutable), but will not be in the current blockchain state.","Q_Score":1,"Tags":"python-3.x,hyperledger-sawtooth","A_Id":55796844,"CreationDate":"2019-04-21T13:16:00.000","Title":"Updating addressing on a running Sawtooth application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to access files stored in my s3 buckets running python script in ec2 machine . Boto3 python packages facilitates this but is there some other way files stored in the s3 bucket could be accessed simply providing url of s3 bucket rather than importing boto3 in python program ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1484,"Q_Id":55783565,"Users Score":0,"Answer":"AWS CLI and shell scripts instead of writing a python application and installing boto3 is what I recently did. I worried about python version being installed and didn't want to install boto3, we were using a variant of an Amazon Linux which all will have AWS CLI and will also have installed jq command tool is a great way to get around installing boto3. It can be supplement with python as well. I decided to go with shell scripting, because my program was relatively simple.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,amazon-ec2","A_Id":55786037,"CreationDate":"2019-04-21T14:21:00.000","Title":"How to access files stored in s3 bucket from python program without use of boto3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a MongoDB running on my machine locally with a few collections of data. I want to migrate it to Atlas, but the Live Migration Services are not available for the Free Tier. Is there another way to move the data I current have on my machine to Atlas?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1995,"Q_Id":55785533,"Users Score":2,"Answer":"You can use mongodump and mongorestore option.\nmongodump --host x.x.x.x --port 27017 --db dbname --gzip --out  \/data\/\nmongorestore --host x.x.x.x --port 27017 --db dbname --gzip \/data\/\nTake mongoDB dump from your machine and restore it to the atlas.","Q_Score":3,"Tags":"python-3.x,mongodb,mongodb-atlas","A_Id":55967685,"CreationDate":"2019-04-21T18:25:00.000","Title":"Migrating a MongoDB on a local machine to Mongo Atlas","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use a python module in a C++ project I'm developing in VS2019 and seem unable to link it. I've added my Python37-32\/Includes directory to the Additional Include Directories, added my Python37-32\/Libs folder to my Additional Library Directories and Python37-32\/Libs to my Additional Dependencies yet still get an error. The error is LNK1181: cannot open input file 'C:\\Python37-32\\libs.obj'. I've tried numerous fixes including : deleting configurations and removing the libs directory from Additional Dependencies however this often results in numerous undefined Python functions which obviously indicate the library isn't being linked.\nHow would I go about linking this correctly?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":650,"Q_Id":55785768,"Users Score":0,"Answer":"I've found the solution. My configuration was correct without Additional Dependencies however my version of Python being referenced was 32-bit on a 64-bit build.","Q_Score":0,"Tags":"python,c++,visual-studio","A_Id":55786603,"CreationDate":"2019-04-21T18:56:00.000","Title":"How to link Python3.7 to VS2019 C++ 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},{"Question":"Looking for suggestions on how to store Price data using MAN AHL's Arctic Library for 5000 stocks EOD data as well as 1 minute data. Separate solutions for EOD and 1-minute data are also welcome. Once the data is stored, I want to perform the following operations:\n\nFetch data for a subset of stocks (lets say around 500-1000 out of the entire universe of 5000 stocks) between a given datetime range.\nAny update to historical data (data once stored in database) should have versioning. Data prior to the update should not be discarded. I should be able to fetch data as of a particular version\/timestamp.\n\nExample format of data:\n\n        Date        Stock        Price\n0       d1          s1            100\n1       d2          s1            110\n2       d3          s1            105\n3       d1          s2            50\n4       d2          s2            45\n5       d3          s2            40","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":55785898,"Users Score":0,"Answer":"Arctic supports a few different storage engines. The only one that will do what you're looking for is VersionStore. It keeps versions of data, so any update you make to the data will be versioned, and you can retrieve data by timestamp ranges and by version. \nHowever it does not let you do a subsetting of stock like you want to do. I'd recommend subsetting your universe (say into US, EMEA, EUR, etc) or into whatever other organization makes sense for your use case.","Q_Score":0,"Tags":"python,pandas,finance","A_Id":60627318,"CreationDate":"2019-04-21T19:14:00.000","Title":"Storing and fetching multiple stocks in Arctic Library","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to train a model using SciKit Learn's SVM module. For the scoring, I could not find the mean_absolute_error(MAE), however, negative_mean_absolute_error(NMAE) does exist. What is the difference between these 2 metrics? Lets say I get the following results for 2 models:\nmodel 1 (NMAE = -2.6), model 2(NMAE = -3.0)\nWhich model is better? Is it model 1?\nMoreover, how does the negative compare to the positive? Say the following:\nmodel 1 (NMAE = -1.7), model 2(MAE = 1.4)\nHere, which model is better?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":9738,"Q_Id":55786121,"Users Score":6,"Answer":"I would like to add here, that this negative error is also helpful in finding best algorithm when you are comparing multiple algorithms through GridSearchCV().\nThis is because after training, GridSearchCV() ranks all the algorithms(estimators) and tells you which one is the best. Now when you use an error function, estimator with higher score will be ranked higher by sklearn, which is not true in the case of MAE (along with MSE and a few others).\nTo deal with this, the library flips the sign of error, so the highest MAE will be ranked lowest and vice versa.\nSo to answer your question: -2.6 is better than -3.0 because the actual MAE is 2.6 and 3.0 respectively.","Q_Score":9,"Tags":"python,machine-learning,scikit-learn,regression","A_Id":57091975,"CreationDate":"2019-04-21T19:40:00.000","Title":"What is the negative mean absolute error in scikit-learn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have homework assignment with a piece to compute the bitwise negation of integer value. It say 512 go into -513.\nI have a solution that does x = 512 y = 512*(-1)+(-1). \nIs that correct way?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1366,"Q_Id":55786347,"Users Score":0,"Answer":"This property is based on the way negative number are represented in two's complement. To represent a negative number $A$ on n bits, one uses the complement of |A| to 2n, i.e. the number 2n-|A|  \nIt is easy to see that A+~A=111...11 as bits in the addition will always be 0 and 1 and 111...111 is the number just before 2n, or 2n-1. \nAs -|A| is coded by 2n-|A|, and A +~A=2n-1, we can say that -A=~A+1 or equivalently ~A=-A-1\nThis is true for any number, positive or negative. And ~512=-512-1=-513","Q_Score":0,"Tags":"python-3.x,bitwise-operators","A_Id":55786490,"CreationDate":"2019-04-21T20:07:00.000","Title":"What is the bitwise negation for an integer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I updated Pycharm CE from 2018.3 to 2019.1 and lost ability to create or open an existing jupyter notebook file. The existing .ipynb file opens as a text file rather than a jupyter notebook with cells. I could open and view it fine on 2018.3.\nI am new to PyCharm and indeed also jupyter notebooks, please let me know if I need to include more information. \nThis is what I already tried on the 2019.1 version:\n\nCreated a new project and installed jupyter package for the interpreter. \nStarted jupyter notebook server with the command (jupyter notebook) in the PyCharm terminal, with the working directory set to cwd.\nUn-installed and re-installed PyCharm 2019.1","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5990,"Q_Id":55788675,"Users Score":11,"Answer":"So as per the support staff from JetBrains:\nStarting with 2019.1 the PyCharm Community Edition (CE) does not support Jupyter Notebook. This functionality has been moved to the professional version only.","Q_Score":11,"Tags":"python-3.x,pycharm,jupyter-notebook","A_Id":55803092,"CreationDate":"2019-04-22T03:04:00.000","Title":"PyCharm 2019.1 CE: No option to create\/edit Jupyter Notebook (*.ipynb) files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python compatibility on 2.17.x versions - Is Python 2.7.13 compatible with Python 2.7.16 ? in general, are Python 2.7.1X compatible to each other?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":55790479,"Users Score":0,"Answer":"All versions of python 2 are backwards-compatible","Q_Score":0,"Tags":"python","A_Id":55790518,"CreationDate":"2019-04-22T07:05:00.000","Title":"Is Python 2.7.13 compatible with Python 2.7.16 ? in general, are Python 2.7.1X compatible to each other?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My use case needs to store the data on a disk immediately when the data is available. I'm using Raspberry PI and few lasers. Once the laser is activated\/deactivated timestamp is taken and it should be stored on the disk. Data is only stored when lasers are \"armed\". They can also be in \"idle\" state (they're still working, but timestamps are ignored). Also, lasers can be armed\/disarmed multiple times. \nWhat would be the most efficient way of doing this? Using plane csv\/xml\/txt or something else? Actual SD card that is used in RPI is limited to 8GB. \nAnother question, when using open() method, should i close() the file once i executed write() method or should I keep it open as long as the script itself is running (script is running all the time until user decides to quit)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":55791341,"Users Score":0,"Answer":"Sounds like python?\nIf so, you can write to your file using with:\n\nwith open('\/path', 'w') as f:\n      f.write('stuff')\n\nand the file descriptor will close automatically when execution exits the block.\nHowever, regarding your other questions it depends on your use case. Why does it need to be available immediately? Will another process be reading it? How quickly will this be happening? Are there any other bits of data you need to save along with the timestamp - presumably whether the laser is on or off at that time?\nLikely, a good solution for you would be a lightweight database such as SQLite. The storage on disk is approximately what it would be in a \"flat\" file, such as the .txt or .csv you reference. It will be fast. And it eliminates concern about managing the actual writing.","Q_Score":0,"Tags":"python-2.7,persistence","A_Id":55791537,"CreationDate":"2019-04-22T08:22:00.000","Title":"Persistent storage of 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have roughly 80tb of images hosted in an S3 bucket which I need to send to an API for image classification. Once the images are classified, the API will forward the results to another endpoint.\nCurrently, I am thinking of using boto to interact with S3 and perhaps Apache airflow to download these images in batches and forward them to the classification API, which will forward the results of the classification to a web app for display.\nIn the future I want to automatically send any new image added to the S3 bucket to the API for classification. To achieve this I am hoping to use AWS lambda and S3 notifications to trigger this function.\nWould this be the best practice for such a solution?\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":159,"Q_Id":55795614,"Users Score":1,"Answer":"For your future scenarios, yes, that approach would be sensible:\n\nConfigure Amazon S3 Events to trigger an AWS Lambda function when a new object is created\nThe Lambda function can download the object (to \/tmp\/) and call the remote API\nMake sure the Lambda function deletes the temporary file before exiting since the Lambda container might be reused and there is a 500MB storage limit\n\nPlease note that the Lambda function will trigger on a single object, rather than in batches.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda,airflow","A_Id":55800992,"CreationDate":"2019-04-22T14:01:00.000","Title":"Large Scale Processing of S3 Images","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a time-series dataframe with a cumulative data column. Data drops at night-time leaving me with NaN values, and picks up with first data read in the morning. \nI would like to interpolate the data so that all NaN values take on the value of the last known float\/valid number. Is this readily possible with .interpolate()?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":55799207,"Users Score":0,"Answer":"Answer taken from @Quang Hoang above wiht ffill()","Q_Score":0,"Tags":"python,pandas,interpolation,nan","A_Id":55799292,"CreationDate":"2019-04-22T18:28:00.000","Title":"Interpolating missing data in cumulative timeseries data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Scikit-learn's documentation says there are two arguments to the function: X(data) and y(Target Values). Do we remove the target variable from our data and provide it separately as y? Or do we keep target variable in X and also provide it separately as y? I have come across both approaches and was wondering which was correct.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":443,"Q_Id":55799226,"Users Score":3,"Answer":"The X should not contain the target as one of the columns. If you include it your linear model will produce no coding errors, but to predict the target y it will just use the feature y.","Q_Score":0,"Tags":"python,scikit-learn,linear-regression","A_Id":55799321,"CreationDate":"2019-04-22T18:29:00.000","Title":"Do we have to remove target variable from data in Scikit-learn's linearmodel.fit()?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Scikit-learn's documentation says there are two arguments to the function: X(data) and y(Target Values). Do we remove the target variable from our data and provide it separately as y? Or do we keep target variable in X and also provide it separately as y? I have come across both approaches and was wondering which was correct.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":443,"Q_Id":55799226,"Users Score":1,"Answer":"To my understand, you shouldn't predict tomorrow's weather by tomorrow's weather. If you already know what's the correct value, it is pointless to predict one. \nHowever, you don't need to remove target variable in your dataset either, just don't include it in your X-axis. \nWhat we are trying to do with a predictive model? Based on past records(both x and y), we trained our model to find their relationships. In future, we may no longer have y, but we still have x in our hands, assuming their relationship doesn't change, we predict what is the y for the future.","Q_Score":0,"Tags":"python,scikit-learn,linear-regression","A_Id":55801233,"CreationDate":"2019-04-22T18:29:00.000","Title":"Do we have to remove target variable from data in Scikit-learn's linearmodel.fit()?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an application which handles websocket and http requests for some basic operations and consuming push data over sockets. Nothing is very computation intensive. Some file tailing, occasional file read \/ write is all that it has to do with heavy processing currently. I want to deploy this to Linux. I have no static files to handle \nCan a tornado application handle 50-100 websocket and http clients without needing ngnix ? I don't want to use another server for this. How many clients can  it handle on its own ?\nEverywhere I search I get ngnix, and I don't want to involve it","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":132,"Q_Id":55801051,"Users Score":1,"Answer":"Yes, Tornado can easily handle 50-100 websocket and http clients without needing Ngnix. You only need Nginx as a reverse proxy if you're running multiple Tornado processes on separate ports. \nIf you're running a single process or multiple process on a single port, you don't need Nginx.\nI've seen benchmarks which show that with a single Tornado process, you can serve around 5,000 connections per second if your response message size is around 100 KB; and over 20,000 requests per second for 1 KB response size. But this also depends on your CPU speed.\nI think it's safe to assume with an average CPU and around 1 GB RAM, you can easily serve around a 2,000-3,000 requests per second.","Q_Score":0,"Tags":"python,server,tornado,production-environment","A_Id":55805718,"CreationDate":"2019-04-22T20:57:00.000","Title":"Can tornado support 50 -100 websocket clients using its default http server without involving ngnix","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"This is in the context of Windows 10.\nI am working on a C# application that will start a python app that does something. This python app is normally installed with Pip (pip install someAppName). The IronPython library expects a full path to a .py file to be able to execute it. \nHow do I know what a pip-installed application points to? From poking around, I can see this pip-installed app has a folder that resides in \/site-packages. However it is not clear to me what in there gets called when I start \"someAppName\" from the command line. \"someAppName\" is the name of the folder itself, where within is a bunch of .py files so I have no idea which one is the actual starting point. \nIs there a better way to do this? My goal is to package a whole \"pre-installed\" python application with my c# app and call\/start it with IronPython. \nThanks for any advice","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":220,"Q_Id":55801149,"Users Score":1,"Answer":"\u2026\/site-packages\/ directory is for library files. When you install an application there have to be a script (or scripts) installed to \u2026\/Scripts\/.","Q_Score":0,"Tags":"c#,python,pip,ironpython","A_Id":55802267,"CreationDate":"2019-04-22T21:08:00.000","Title":"Pip-installed packages, what do they physically point to? (for use with IronPython in C#)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using python and OpenCV, is it possible to display the same image on multiple users?\nI am using cv2.imshow but it only displays the image for the user that runs the code.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":55804120,"Users Score":0,"Answer":"I was able to display the images on another user\/host by setting the DISPLAY environment variable of the X server to match the desired user's DISPLAY.","Q_Score":0,"Tags":"python,cv2,multi-user","A_Id":55821709,"CreationDate":"2019-04-23T04:00:00.000","Title":"cv2 - multi-user image display","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing a homework and I want to know how can I move turtle to a random location a small step each time. Like can I use turtle.goto() in a slow motion?\nSomeone said I should use turtle.setheading() and turtle.forward() but I'm confused on how to use setheading() when the destination is random.\nI'm hoping the turtle could move half radius (which is 3.5) each time I update the program to that random spot.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":55805378,"Users Score":0,"Answer":"Do you mean that you want to move a small step, stop, and repeat? If so, you can \u2018import time\u2019 and add \u2018time.sleep(0.1)\u2019 after each \u2018forward\u2019","Q_Score":1,"Tags":"python,python-3.x,turtle-graphics","A_Id":55810553,"CreationDate":"2019-04-23T06:19:00.000","Title":"Move turtle slightly closer to random coordinate on each update","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning Python for the first time. \nDue to my curiosity, I changed some code in the external libraries. But I forgot what I have modified. \nSo is there any way to reset the external libraries? I am using python 3.7 interpreter on Pycharm.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":55808018,"Users Score":0,"Answer":"You can just back up your python project file, reset Pycharm to factory defaults and then upload the project back to Pycharm.","Q_Score":0,"Tags":"python,settings,external","A_Id":55808393,"CreationDate":"2019-04-23T09:20:00.000","Title":"Is there any way to reset the external library on Pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use Google Cloud Profiler in a python script running locally. It seems it is having problems to connect with a metadata server:\n\nWARNING:googlecloudprofiler.client:Failed to fetch instance\/zone from GCE metadata server: HTTPConnectionPool(host='metadata', port=80): Max retries exceeded with url: \/computeMetadata\/v1\/instance\/zone (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -2] Name or service not known',))\nWARNING:googlecloudprofiler.client:Failed to fetch instance\/name from\n  GCE metadata server: HTTPConnectionPool(host='metadata', port=80): Max\n  retries exceeded with url: \/computeMetadata\/v1\/instance\/name (Caused\n  by NewConnectionError(': Failed to establish a new connection: [Errno -2] Name\n  or service not known',))\n\nSince the app seems to be running correctly and the profiler is collecting data successfully, is it OK if I just ignore the warnings or will I likely encounter some problems in the future?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":588,"Q_Id":55813180,"Users Score":2,"Answer":"If you're running locally (and haven't, for example, manually zone in the config), these warnings are expected, so ignoring them is definitely okay.\n(Disclosure: I work at Google on Stackdriver Profiler)","Q_Score":0,"Tags":"python,google-cloud-platform,google-cloud-profiler","A_Id":56082596,"CreationDate":"2019-04-23T14:09:00.000","Title":"google-cloud-profiler metadata server WARNING","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a bytearray containing some bytes, it currently look like this (Converted to ASCII):\n\n['0b1100001', '0b1100010', '0b1100011', '0b10000000']\n\nI need to add a number of 0 bits to this, is that possible or would I have to add full bytes? If so, how do I do that?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":805,"Q_Id":55814420,"Users Score":1,"Answer":"Where do you need the bits added to? Each element of your list or an additional element that contains all 0's?\nThe former:\nmyList[0] = myList[0] * 2 # ASL\nThe later\nmyList.append(0b000000)","Q_Score":1,"Tags":"python,arrays,append","A_Id":55814499,"CreationDate":"2019-04-23T15:17:00.000","Title":"Python append single bit to bytearray","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've installed Cygwin and Python in Windows, but now having added both pip and virtualenv packages, when I try to use them in the Cygwin command line I get -bash: pip: command not found and the same message for virtualenv. When I run python -m ensurepip it says the requirement is already satisfied. But when I go back to use it again, it is still missing.\nCould it have something to do with where I've stored the local package directory? It's not in my main Cygwin directory.\nI am new to Cygwin, so I could be missing something obvious. Thoughts?\nUPDATE: I found pip. It's called pip2, so when I called pip, nothing happened. So this leads me to wonder if virtualenv has an alternate name as well. I did a pip2 freeze and virtualenv is indeed installed but I still can't seem to call it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":265,"Q_Id":55816661,"Users Score":2,"Answer":"It turns out I could not call pip or virtualenv because they were from packages for Python 2.7 and had been renamed to pip2 and virtualenv-2.7 and have to be called that way in the command line. I'm reviving an old project with old requirements, so I'm using this older version of Python.","Q_Score":0,"Tags":"python,windows,package,cygwin","A_Id":55818784,"CreationDate":"2019-04-23T17:37:00.000","Title":"Why are these installed packages not found in Cygwin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to run a Selenium Script (Using PHP) using a Webserver.\nI'm working on Kali and to simulate the Webserver I use Xampp.\nI tried to run the selenium script on Xampp by the following steps:\n-Download the Php Webdriver Bindings, put them in the folder 'htdpcs' of xampp and edit the 'example.php' file following the settings of my own device.\n-Download and execute the Selenium Server Standalone, on port :4444.\nIn the end, I download the geckodriver and I execute the file, but I got the this error:\nOSError: [Errno 98] Address already in use\nHow to fix it in order to run the php-selenium script?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":269,"Q_Id":55816936,"Users Score":0,"Answer":"The Selenium Server will fork a geckodriver as soon as it needs one to start a new browser session. You should not start a geckodriver yourself. If you want to use its Webdriver API yourself you can start it with the --webdriver-port argument.","Q_Score":0,"Tags":"python,selenium,selenium-webdriver","A_Id":55820106,"CreationDate":"2019-04-23T17:59:00.000","Title":"Selenium Servers and Geckodriver don't run at same port","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 VM with Zeppelin that is a shared environment. I want to add boto3 so I can do some python against AWS. Since zeppelin is running as a service, where would I add the AWS credentials? Would it be in the root's home? Or the home account the service is running under? Or within Zeppelin's user can they supply their own AWS credentials? \nI did pip install boto3 on the OS and then tried in a notebook to import it and I got a ModuleNotFoundError: No module named 'boto3' error.\nLooking for guidance from anyone who has gotten their zeppelin to work with AWS.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":509,"Q_Id":55817105,"Users Score":0,"Answer":"Zeppelin can be installed in several ways , which could point to the root cause of the issue : \n\nvia the tar file download - in that case @mootmoot's way is right . boto3 should be configured with the appropriate python interpreter  \nvia docker image - in that case you need to add the python module to the docker image itself : \n\n2.a. you can use 'docker exec -i -t  bash\\sh(your preference)'\n2.b pip install","Q_Score":0,"Tags":"python,amazon-web-services,boto3,apache-zeppelin","A_Id":56096800,"CreationDate":"2019-04-23T18:11:00.000","Title":"How to: Zeppelin + boto3 + AWS Credentials","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to remove a folder, but I can\u2019t get in pycache to delete the pyc and pyo$ files. I have done it before, but I don\u2019t know how I did it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":55818435,"Users Score":0,"Answer":"If you want to remove your python file artifacts, such as the .pyc and .pyo cache files, maybe you could try the following:\n\nMove into your project's root directory\ncd <path_to_project_root>\nRemove python file artifacts\nfind . -name '*.pyc' -exec rm -f {} +\nfind . -name '*.pyo' -exec rm -f {} +\n\nHopefully that helps!","Q_Score":0,"Tags":"python,bash","A_Id":55825883,"CreationDate":"2019-04-23T19:50:00.000","Title":"How to access _pycache_ directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing an ECS framework and also a game with it, in Python. In an ECS framework, components should contain only data. However, sometimes setup code is needed to create the data. For example, in an audio component, the data would be the volume of the the sound to play and the path to the audio file. But in the audio-playing library, there are objects to represent sounds, which have a sound.play() method, for example. My question is whether this object should be created in the component, which sort of violates the rule that entities should be pure data, or in the system. If it should best be done in a system, it would only need to be done once (and it would harm performance if the audio file needed to be created once per frame). What is the best way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":409,"Q_Id":55818460,"Users Score":1,"Answer":"My question is whether this object should be created in the component, which sort of violates the rule that entities should be pure data, or in the system. If it should best be done in a system, it would only need to be done once (and it would harm performance if the audio file needed to be created once per frame). What is the best way to do this?\n\nWhen you use the outboard model for an entity system, I think one of the most important tasks to nail down is both entity and component life-cycle management.  Without it, it becomes really difficult to write system code that doesn't start to resemble spaghetti.\nThere are implementations out there where they expect you to construct the entity, build its component list, then activate the entity.  Once the entity is activated, you can't add or remove components, but only change the component's attribute values.  In order to add\/remove components, you deactivate the entity, make the changes, then reactivate it.\nLets assume we use this entity life-cycle process.\nWhen the entity with the audio component is activated, the audio system is notified, reads the attributes from the audio component, and finally creates the audio framework's sound object.  It would then be the system's responsibility to maintain a bookkeeping map between the component and sound object.  This internal map is what the system would use each frame to perform its update.\nWhen the entity with the audio component is deactivated, the audio system is notified, destroys the audio framework's sound object associated with the component in the internal bookkeeping map, then removes the entry from the internal map.","Q_Score":0,"Tags":"python,design-patterns,components,entity,entity-component-system","A_Id":56007732,"CreationDate":"2019-04-23T19:52:00.000","Title":"How should setup code be handled in entity-component-system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"When we import a module in a Python script, does this copy all the required code into the script, or does it just let the script know where to find it?\nWhat happens if we don't use the module then in the code, does it get optimized out somehow, like in C\/C++?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":830,"Q_Id":55819621,"Users Score":2,"Answer":"None of those things are the case.\nAn import does two things. First, if the requested module has not previously been loaded, the import loads the module. This mostly boils down to creating a new global scope and executing the module's code in that scope to initialize the module. The new global scope is used as the module's attributes, as well as for global variable lookup for any code in the module.\nSecond, the import binds whatever names were requested. import whatever binds the whatever name to the whatever module object. import whatever.thing also binds the whatever name to the whatever module object. from whatever import somefunc looks up the somefunc attribute on the whatever module object and binds the somefunc name to whatever the attribute lookup finds.\nUnused imports cannot be optimized out, because both the module loading and the name binding have effects that some other code might be relying on.","Q_Score":1,"Tags":"python,python-3.x,import,module,sys.path","A_Id":55819684,"CreationDate":"2019-04-23T21:25:00.000","Title":"Does Python import copy all the code 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":"I have recently setup Anaconda with python 3.6, and installed tensorflow, networkx, and a github package I am hoping to use. When I run Jupyter Notebook and open a random file, it says \"python3\" in the upper right hand corner and I am given the standard options to run a cell, create a new cell, etc. However, when I open one of the files from the github package it says \"python\" in the upper right hand corner and I am only given \"file\" \"edit\" \"view\" and \"language\" options in the toolbar. I am unsure why it is not giving me an option to simply run the file and since I am new to Python\/Anaconda\/etc I am not sure what to do.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1825,"Q_Id":55820086,"Users Score":2,"Answer":"what i ve understood is that you wanna open a python file inside Jupyter Notebook.\nHowever, Jupyter Notebook files have the extension .ipynb which is not the same for python files (.py)\nso my answer is : you cant run a python file inside Jupyter Notebook","Q_Score":1,"Tags":"python,jupyter-notebook,anaconda","A_Id":55820276,"CreationDate":"2019-04-23T22:11:00.000","Title":"Unable to Run Python file in Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recently setup Anaconda with python 3.6, and installed tensorflow, networkx, and a github package I am hoping to use. When I run Jupyter Notebook and open a random file, it says \"python3\" in the upper right hand corner and I am given the standard options to run a cell, create a new cell, etc. However, when I open one of the files from the github package it says \"python\" in the upper right hand corner and I am only given \"file\" \"edit\" \"view\" and \"language\" options in the toolbar. I am unsure why it is not giving me an option to simply run the file and since I am new to Python\/Anaconda\/etc I am not sure what to do.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1825,"Q_Id":55820086,"Users Score":0,"Answer":"You can reference a .py file from a notebook by importing it just like you would in another .py script.","Q_Score":1,"Tags":"python,jupyter-notebook,anaconda","A_Id":55821902,"CreationDate":"2019-04-23T22:11:00.000","Title":"Unable to Run Python file in Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hey is there a way to Print the (binary) version of the IV and not the Hexadecimal?  I'm required to show it for class. I'm doing an encryption\/decryption of plaintext using CBC mode and I have to show the IV in Binary and not hexadecimal.  I'm using Python 3","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":55820568,"Users Score":0,"Answer":"if you can convert the roman numeral to an integer than just use bin(4)","Q_Score":1,"Tags":"python,python-3.x,initialization-vector","A_Id":55820587,"CreationDate":"2019-04-23T22:48:00.000","Title":"Initialization Vector displaying (Binary) using CBC in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have huge size data (in TBs or PBs) in my HDFS which is located at remote PC. Now instead of taking Data to the Transformation Logic (which is not correct and efficient), I want to run my python Transformation Logic itself on the location where my Data is stored.\nSeeking some useful ideas about the technologies which can be used to fulfill this requirement.\nThings which I tried till now:\n1) Approach 1\n\nTook SSH Connection of Remote PC (where HDFS data is available), Copied my python Transformation Logic there and executed after fetching the data from HDFS.\n\n2) Approach 2\n\nLoaded HDFS data to Apache Spark RDDs which is on Remote PC where HDFS data is available and executed Spark Job from another PC.\n\nPlease suggest other technologies which can be used for Logic Execution remotely.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":55822254,"Users Score":0,"Answer":"I would suggest setting up a Spark Cluster in the same local network where you have the data and running spark transformations in the cluster remotely (SSH or Remote Desktop). The advantages of the setup are:\n\nNetwork Latency will be minimised as the data is transferred in the\nsame network locally.\nRunning the transformations with distributed and in-memory processing engines like Apache Spark is fast.\n\nNote: Please ignore if the response is in line with your second approach","Q_Score":0,"Tags":"python,apache-spark,hdfs,remote-access","A_Id":55825408,"CreationDate":"2019-04-24T04:04:00.000","Title":"How to run any Transformation Logic on HDFS data which is at Remote PC","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"please help to recognize an item id from junk text. An id starts from 300 and consist of 12 digit characters.\nFor example:\n\n\u0417\u041a\u0417 300000459908  \u041a\u0430\u043f. \u0440\u0435\u043c\u043e\u043d\u0442 \n3   \u0417\u041a\u0417 300000459908  \u043f\u0435\u0447\u0438 \u211615   \nUSER4\n4   OR300000459908   \u041a\u0430\u043f. \u0440\u0435\u043c\u043e\u043d\u0442 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \nOR30000045990\n\nThank you!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":55825681,"Users Score":0,"Answer":"A simple one : \/300[0-9]{9}\/ .","Q_Score":0,"Tags":"python,regex,split","A_Id":55825744,"CreationDate":"2019-04-24T08:33:00.000","Title":"recognize specific pattern with help of regex","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a event detector for Twitter and it's being extremely affected by spam tweets, so I'm planning to filter tweets a little bit with a text similarity algorithm.\nThe approach I have thinked about is to have a set of tweets where I will store the different tweets. First of all I will clear links and mentions from the tweets, and check if the tweet I'm processing has a similarity value with any of the tweets of the set greater than a threshold (0.7-0.8 for example). If that's the case, I will continue the iteration and ignore that tweet; otherwise I will add that tweet to the set and work with it.\nI have been reading different answers to related questions but they were only for small corpuses of text, while this will work with a dataset of at least 15.000 tweets more or less, so the algorithm will be comparing between every tweet and the set of tweets 15.000 times.\nAlso other questions are a bit old, and new algorithms may have been created or better implementations of older ones may have appeared.\nIn conclusion, what do you think is the best way to afront this spam problem? Would it be a Python native one or an extern one?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":502,"Q_Id":55827975,"Users Score":1,"Answer":"to find similarity you can use tf-idf vectors and then calculate cosine similarity between them, but it's a large number of vectors to compare so you can cluster your data and find a center vector for each cluster, so you just need to compare your new tweet with center vectors not all of them.","Q_Score":0,"Tags":"python,string,text,twitter,similarity","A_Id":55828138,"CreationDate":"2019-04-24T10:32:00.000","Title":"Get similarity between text and the texts of a set 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 writing a script to monitor a SNS for Live video.\nThe main program creates several multiprocess and put them into a pool. These multiprocess monitor different SNS accounts. Once live video is found, another process is started to record the video, so the script can continue monitor other accounts.\nThe problem is \"daemonic processes are not allowed to have children\".\nHow should I achieve what I want to do? Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":55828232,"Users Score":0,"Answer":"use threading within multiprocessing daemon process","Q_Score":0,"Tags":"python,multiprocessing","A_Id":55864663,"CreationDate":"2019-04-24T10:44:00.000","Title":"How to start a non-blocking process within a multiprocess in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a neural network(ALEXnet or VGG16) written with Keras for Image Classification and I would like to calculate the Number of floating point operations for a network. The size of the images in the dataset could varry.\nCan a generlized code be written in python which could calculate flops automatically ? or is there any libraray avaialble.\nI am working with spyderAnaconda and the defined network is a sequential model.\nThank you.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3688,"Q_Id":55831235,"Users Score":0,"Answer":"There is no such code because the quantity of FLOPs is dependent on the hardware and software implementations.  You can certainly derive a typical quantity from expanding the layer-by-layer operations for each parameter and weight. and making reasonable implementation assumptions for each activation function.\nInput dimensions will proportionately affect the computations for the first layer.\nI'm not sure what you intend for \"generalized code in Python\"; do you envision using a form of the Keras model as the input?  This is possible, but you need to write modules that will extract the kernel characteristics and connection logic from the Keras representation.\nYour quantity of operations will vary from one implementation to another.  Hardware architectures now directly support parallel operations and short-cuts for sparse matrices.  Some have extra functionality for adjusting floating-point representations for greater training speed.  Software platforms include control and data flow analysis to optimize the functional flow.  Any of these will change the FLOPs computation.","Q_Score":2,"Tags":"python-3.x,deep-learning,conv-neural-network","A_Id":55839963,"CreationDate":"2019-04-24T13:28:00.000","Title":"Calculating the Number of flops for a given Neural Network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a neural network(ALEXnet or VGG16) written with Keras for Image Classification and I would like to calculate the Number of floating point operations for a network. The size of the images in the dataset could varry.\nCan a generlized code be written in python which could calculate flops automatically ? or is there any libraray avaialble.\nI am working with spyderAnaconda and the defined network is a sequential model.\nThank you.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":3688,"Q_Id":55831235,"Users Score":2,"Answer":"FLOPs are the floating-point operations performed by a model. It is usually calculated using the number of multiply-add operations that a model performs. Multiply-add operations, as the name suggests, are operations involving multiplication and addition of 2 or more variables. For example, the expression, a * b + c * d, has 2 flops while a * b + c * d + e * f + f * h has 4 flops.\nLet's now take a simple linear regression model for example. Assume this model has 4 parameters w1, w2, w3, and w4 and a bias b0. Inference on an input data, X = [x1, x2, x3, x4] results in output = x1 * h1 + x2 * h2 + x3 * h3 + x4 * h4 + b0. This operation has 4 flops\nThe FLOPs measurement in CNNs involves knowing the size of the input tensor, filters and output tensor for each layer. Using this information, flops are calculated for each layer and added together to obtain the total flops. Let's look at the first layer in VGG16 with input tensor of size 224x224x3, 64 filters of size 3x3x3 and output size of 224x224x64. Each element in the output results from an operation involving (3x3x3) multiply-add between the filter and the input tensor. Hence the number of flops for the first layer of VGG16 is (3x3x3)x(224x224x64)= 86,704,128","Q_Score":2,"Tags":"python-3.x,deep-learning,conv-neural-network","A_Id":64795470,"CreationDate":"2019-04-24T13:28:00.000","Title":"Calculating the Number of flops for a given Neural Network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a neural network(ALEXnet or VGG16) written with Keras for Image Classification and I would like to calculate the Number of floating point operations for a network. The size of the images in the dataset could varry.\nCan a generlized code be written in python which could calculate flops automatically ? or is there any libraray avaialble.\nI am working with spyderAnaconda and the defined network is a sequential model.\nThank you.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3688,"Q_Id":55831235,"Users Score":0,"Answer":"many papers using their own flops counting code.\nit is made by entering the input size of certain operation's tensor.\nso they manually calculate it's flops\nyou can find it with keyword like 'flops constraint' or 'flops counter' in github.\nor there are 'torchstat' tool which counts the flops and memory usage etc.","Q_Score":2,"Tags":"python-3.x,deep-learning,conv-neural-network","A_Id":66452856,"CreationDate":"2019-04-24T13:28:00.000","Title":"Calculating the Number of flops for a given Neural Network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem with my project. It involves downloading data from various websites.\nFor now it's tens of pages, but in the future it will be thousands of pages depending on the country. Each page has its own script.\nTo support these scripts, I created a main script that calls each subsequent script on a separate thread using the multi-threading library. \nThe script on the input has a path to the file with data already downloaded to the database, and on the output it gives the second file only with new data. At the moment, this solution was used only for 4 pages. It works as I assume. But I wonder what happens when these websites will be a few hundred or a few thousand?\nI think I could create a separate main script depending on the country, but as a result, it would give at least several hundred pages (scripts) per country, so according to my logic, several hundred threads run at one time.\nDoes it have a chance to operate on such a number of websites? I opted for multithreading due to the large number of web content download operations.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":55831248,"Users Score":0,"Answer":"Ok, sounds smart :) Now I have 2 scripts with 'ThreadPool' method. Works fine. But to execute these scripts I have 'main_script' which until today I have separate threads for each script. So in main_script I can use too 'ThreadPool' method? And then how looks like a cost of CPU and generally perfomance? Because in future I want have e.g. 100 scripts in main_script (e.g. max_workers = 5) and every script have too ThreadPool (e.g. max_workers=5), so in one time I have a 5x5 = 25 threads?","Q_Score":0,"Tags":"python,multithreading,web-scraping","A_Id":56000171,"CreationDate":"2019-04-24T13:29:00.000","Title":"How handle multithreading on big-scale web scraping project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have two data frame both having same number of columns but the first data frame has multiple rows and the second one has only one row but same number of columns as the first one. I need to multiply the entries of the first data frame with the second by column name.\nDF:1\n  A   B   C\n0  34  54  56\n1  12  87  78\n2  78  35   0\n3  84  25  14\n4  26  82  13\nDF:2\nA  B  C\n0  2  3  1\nResult\nA     B    C\n68   162  56\n24   261  78\n156  105   0\n168   75  14\n52   246  13","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":55831908,"Users Score":1,"Answer":"This will work. Here we are manipulating numpy array inside the DataFrame.\npd.DataFrame(df1.values*df2.values, columns=df1.columns, index=df1.index)","Q_Score":0,"Tags":"python,data-manipulation","A_Id":55832347,"CreationDate":"2019-04-24T14:00:00.000","Title":"Multiply each element of a column by each element of a different dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to configure profiling of a Python application (running under pypy2.7 v7.1.1) using vmprof.\nIf the application is ran via pypy -m vmprof ..., the resulting profile file contains samples from all threads (main and background).  However, I need to enable and disable the profiler in a running process, so I'm doing this using the vmprof.enable()\/vmprof.disable() functions in a signal handler.  The problem is that the resulting file only contains samples from the main thread.\nIs there a way to profile all threads of a running application using vmprof?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":106,"Q_Id":55831961,"Users Score":0,"Answer":"I ended up recreating the background threads when the profiler is starting.\nIt is important to spawn the new threads from the main thread when the profiler is running.  If the new background threads are spawned from the old background threads, the new threads still will not be profiled.","Q_Score":0,"Tags":"python,profiling,pypy","A_Id":56226711,"CreationDate":"2019-04-24T14:02:00.000","Title":"Profiling background threads of a Python app using vmprof","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When i tried entering the command on terminal (Im using Linux): python3 -m pip install -r requirements.txt\nI get the error: No module named pip\nI have already installed pip on Python3 using: apt-get install python3-pip.\nAny help is appreciated! Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1463,"Q_Id":55836634,"Users Score":0,"Answer":"pip3 -V or pip3 --version should return the Python 3 version\nAlso, make use of pip3 install -r requirements.txt","Q_Score":0,"Tags":"python","A_Id":55836920,"CreationDate":"2019-04-24T18:42:00.000","Title":"Python3: No module named pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Flask python app running on IBM cloud. The app needs some configuration parameter which it gets from a configuration file. I need to encrypt the configuration file using a symmetric key. How can I do that and where I can store my decrypt key? Ideally I don't want to hard code it into my code.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":55838341,"Users Score":0,"Answer":"12 Factor question. Embed it in the app's deployment environment variables and read the value at runtime.","Q_Score":0,"Tags":"python,ibm-cloud,encryption-symmetric","A_Id":55838704,"CreationDate":"2019-04-24T20:48:00.000","Title":"How to secure a configuration file in IBM Cloud","Data Science and Machine Learning":0,"Database and SQL":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 Django to develop a web app. When I run server, I get the below error message. \nError: Page not found (404)\nUsing the URLconf defined in Mywebsite_Website.urls, Django tried these URL patterns, in this order:\n^$ [name='index']\n^admin\/\nThe empty path didn't match any of these.\nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":459,"Q_Id":55839791,"Users Score":1,"Answer":"Django is trying to route a path request to a defined URL in one of your urls.py files.\nSo far you only have two possible options set up with your urls.py files it seems:\n\nthe Admin pages at: yoururl.com\/admin\/\nthe Index page at: yoururl.com\/\n\nThe URL that you tried to go to does not fall into either of those categories. Out in the wild this would result in a 404 Page Not Found Error.","Q_Score":1,"Tags":"python,django","A_Id":55840453,"CreationDate":"2019-04-24T23:18:00.000","Title":"Error while running Django Server -The empty path didn't match any of these","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am currently working on a Python project, and I want the user to automatically have access to the dependencies that I used. Do they have to download (e.g. pip install) them manually? If so, is there an easy way to make them download the necessary packages easily?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":55842799,"Users Score":0,"Answer":"virtualenv is What you need. You install packages your project needed when developing it. After coding, you can run pip freeze > requirements.txt to save all packages to requirements.txt. pip install -r requirements.txt will install all packages automatically.\n\nfurther, Docker is more better for releasing projects to PC.","Q_Score":0,"Tags":"python","A_Id":55842983,"CreationDate":"2019-04-25T06:07:00.000","Title":"Dependencies in Python project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm implementing my first neural network for images classification.\nI would like to know if i should start to find best hyperparameters first and then try to modify my neural network architecture (e.g number of layer, dropout...) or architecture then hyperameters?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":80,"Q_Id":55846870,"Users Score":2,"Answer":"First you should decide for an architecture and then play around with the hyperparameters. To compare different hyperparameters it is important to have the same base (architecture). \nOf course you can also play around with the architecture (layers, nodes,...).But I think here it is easier to search for an architecture online, because often the same or a similar problem yet have been solved or described in a tutorial\/blog.\nThe dropout is also a (training-)hyperparameter and not part of the architecture!","Q_Score":0,"Tags":"python,tensorflow,neural-network","A_Id":55847433,"CreationDate":"2019-04-25T10:13:00.000","Title":"neural network find best hyperameters or architecture first","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm implementing my first neural network for images classification.\nI would like to know if i should start to find best hyperparameters first and then try to modify my neural network architecture (e.g number of layer, dropout...) or architecture then hyperameters?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":55846870,"Users Score":1,"Answer":"The answer is as always : it depends\nWhat are you trying to achieve?\nIf you're hoping to make the worlds best image classifier by trial and error then you might want to ask yourself if you think you have more compute available than the people who have already done this. For a really good classifier there are several ones that come with tensorflow\/keras and can be easily implemented. If you're goofing around and learning the coding then I'd recommend different architectures because that's going to teach you more functions. If you have a dataset you don't think existing solutions will be good at analysing and genuinely need the best network to solve classify them then unfortunately it still depends...\nHow to decide:\nFirstly decide on the rough order of magnitude for your overall parameter count (the literal number of parameters your model has). For a given number of parameters, architecture is likely to produce the biggest difference in results between representative hyperparameter choices (don't choke your network down to a single neuron in the middle and expect it to be representative of that architecture).\nIts important to compare the rough performance per parameter so you're not giving an edge to the networks with greater overfitting capacity. You don't need to use all your training data or even train to completion, mostly you'll find the better networks learn faster and finish better (mostly). In the past I've done grid searches with multiple trials at each point using significantly reduced data then optimised the architecture with the most potential by considering the gradients of the grid search. Fun fact: with sufficient time you can use gradient descent methods on hyperparameters to find local minima. You might well find that there are many similarly top performing models, all of which should you can tune until a clear winner emerges.","Q_Score":0,"Tags":"python,tensorflow,neural-network","A_Id":55852346,"CreationDate":"2019-04-25T10:13:00.000","Title":"neural network find best hyperameters or architecture first","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset with columns like ['station_id', 'feature1', 'feature2',...]\nEach row is a time step. And it is sorted by station_id.\nThe main problem is that station_ids have different number of timesteps ...\nI want to shape it for an LSTM layer, like (NumberOfExamples, TimeSteps, FeaturesPerStep). \nCan someone help me to use np.reshape() in this case please ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":55848195,"Users Score":0,"Answer":"You cannot easily use reshape when you have a different number of temporal steps for each example. What you typically do with LSTMs is that you have batches of examples and each batch is padded to the same length, usually with zeros. Use np.zeros(shape) and then iteratively assign to respective rows.","Q_Score":0,"Tags":"python,pandas,numpy,lstm","A_Id":55848378,"CreationDate":"2019-04-25T11:27:00.000","Title":"How to reshape spatiotemporal data as lstm input?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Which one among Gridsearchcv and Bayesian optimization works better for optimizing hyper parameters?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2664,"Q_Id":55849512,"Users Score":1,"Answer":"Grid search is known to be worse than random search for optimizing hyperparameters [1], both in theory and in practice. Never use grid search unless you are optimizing one parameter only.\nOn the other hand, Bayesian optimization is stated to outperform random search on various problems, also for optimizing hyperparameters [2]. However, this does not take into account several things: the generalization capabilities of models that use those hyperparameters, the effort to use Bayesian optimization compared to the much simpler random search, and the possibility to use random search in parallel.\nSo in conclusion, my recommendation is: never use grid search, use random search if you just want to try a few hyperparameters and can try them in parallel (or if you want the hyperparameters to generalize to different problems), and use Bayesian optimization if you want the best results and are willing to use a more advanced method.\n[1] Random Search for Hyper-Parameter Optimization, Bergstra & Bengio 2012.\n[2] Bayesian Optimization is Superior to Random Search for Machine Learning Hyperparameter Tuning: Analysis of the Black-Box Optimization Challenge 2020, Turner et al. 2021.","Q_Score":8,"Tags":"python-3.x,machine-learning,gridsearchcv","A_Id":70753506,"CreationDate":"2019-04-25T12:39:00.000","Title":"Gridsearchcv vs Bayesian optimization","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Which one among Gridsearchcv and Bayesian optimization works better for optimizing hyper parameters?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2664,"Q_Id":55849512,"Users Score":15,"Answer":"There is no better here, they are different approaches. \nIn Grid Search you try all the possible hyperparameters combinations within some ranges. \nIn Bayesian you don't try all the combinations, you search along the space of hyperparameters learning as you try them. This enables to avoid trying ALL the combinations.\nSo the pro of Grid Search is that you are exhaustive and the pro of Bayesian is that you don't need to be, basically if you can in terms of computing power go for Grid Search but if the space to search is too big go for Bayesian.","Q_Score":8,"Tags":"python-3.x,machine-learning,gridsearchcv","A_Id":55850059,"CreationDate":"2019-04-25T12:39:00.000","Title":"Gridsearchcv vs Bayesian optimization","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe containing variables of different scales (age, income, days as customer, percentage spent in each kind of product sold (values from 0 to 1), etc). I believe it's necessary to scale these variables for using in a neural network algorithm, for example. \nMy question is: The variables that are in percentage, are somehow already scaled, can I apply MinMax in my whole dataset or should I not consider these percentage variables in Min Max scaling and keep them with original values?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1082,"Q_Id":55851021,"Users Score":2,"Answer":"I think is not necessary. If the variables that are in percentage is between 0 and 1, you don't need scaled them because they are scaled already.","Q_Score":0,"Tags":"python,machine-learning,neural-network","A_Id":55851082,"CreationDate":"2019-04-25T13:56:00.000","Title":"Should I scale a percentage variable?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to optimize and convert a tensorflow model to OpenVINO IR. It hasn't been very successful because of the problems I'm facing with input shapes. So I'm planning to remodel the whole model with static shapes. The model I'm trying to work on is Tacotron by keithito.\nHow do I ensure all the nodes in my model will have static shapes?\nWill just setting the input placeholder nodes to a fixed shape allow tensorflow to infer and fix the shapes of all other nodes?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":342,"Q_Id":55852212,"Users Score":0,"Answer":"You can have dynamic shapes in TF model and provide static shape while cnverting model with ModelOptimizer. Example for input data of size 256x256 with 3 channels.\npython mo_tf.py --input_shape [1,256,256,3] --input_model model.pb","Q_Score":0,"Tags":"python,tensorflow,speech,openvino","A_Id":56388008,"CreationDate":"2019-04-25T14:54:00.000","Title":"How to ensure static shapes in Tensorflow model for easy OpenVINO conversion?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to find a better way to push data to sql db using python. I have tried \ndataframe.to_sql() method and cursor.fast_executemany()\nbut they don't seem to increase the speed with that data(the data is in csv files) i'm working with right now. Someone suggested that i could use named tuples and generators to load data much faster than pandas can do. \n[Generally the csv files are atleast 1GB in size and it takes around 10-17 minutes to push one file]\nI'm fairly new to much of concepts of python,so please suggest some method or atleast a reference any article that shows any info. Thanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":678,"Q_Id":55852550,"Users Score":0,"Answer":"If you are trying to insert the csv as is into the database (i.e. without doing any processing in pandas), you could use sqlalchemy in python to execute a \"BULK INSERT [params, file, etc.]\". Alternatively, I've found that reading the csvs, processing, writing to csv, and then bulk inserting can be an option.\nOtherwise, feel free to specify a bit more what you want to accomplish, how you need to process the data before inserting to the db, etc.","Q_Score":1,"Tags":"python,python-3.x,pandas,sqlalchemy,pyodbc","A_Id":55852914,"CreationDate":"2019-04-25T15:12:00.000","Title":"How to improve the write speed to sql database using python","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install django with pipenv on ubuntu 18.04 but the problem is that pipenv always install python 2.7 inside the project. When I type pipenv --python 3.6 it give me this error message: \"pipenv check will surely fail.\".\nAnd when I type pipenv check I get this message: \"Checking PEP 508 requirements\u2026\nSpecifier python_version does not match 2.7 (3.6).\nFailed!\". Any suggestions ?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":3481,"Q_Id":55856434,"Users Score":5,"Answer":"Yeah, it's pretty silly that you can't actually select the python version you want to run in a virtual environment. My solution:\npip uninstall pipenv","Q_Score":4,"Tags":"python,pip,pipenv","A_Id":58980335,"CreationDate":"2019-04-25T19:31:00.000","Title":"How to fix 'Specifier python_version does not match 2.7 (3.6).'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What would the most efficient way of flashing images be in python?\nCurrently I have an infinite while loop that calls sleep at the end, then uses matplotlib to display an image. However I can't get matplotlib to replace the current image, I instead have to close then show again which is slow. I'd like to flash sequences of images as precisely as possible at a set frequency.\nI'm opens to solutions that use other libraries to do the replacement in place.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":571,"Q_Id":55858199,"Users Score":0,"Answer":"Using a library called PsychoPy. It can guarantee that everything is drawn and allows you to control when a window is drawn (a frame) with the window.frame() function.","Q_Score":0,"Tags":"python,image,matplotlib,timer,frequency","A_Id":56177448,"CreationDate":"2019-04-25T22:00:00.000","Title":"Efficient way of flashing images in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make my python program less pirateable. I know it's fruitless to make it entirely secure, but I want it to be at least somewhat easier than copying copying the installer and throwing it on piratebay.\nI've looked into verifying the MAC address of the user, but that either requires them to run the software first, or to give me their MAC address to get the software.\nI've also looked into spreading out the files after installation, but once again that only works if they don't just copy the installer\nIt's python, so it's not going to be hard to reverse engineer, and it's a desktop application, so it's going to be pirated. But a tiny amount of security will prevent the average user from just pirating it I hope.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":355,"Q_Id":55858250,"Users Score":3,"Answer":"The only secure way to prevent piracy is to make a crucial portion of your software server-side, and require that the user be connected to the Internet when running your software.","Q_Score":0,"Tags":"python,python-3.x,web,anti-piracy","A_Id":55858303,"CreationDate":"2019-04-25T22:07:00.000","Title":"How to ensure my software is not easy to pirate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to extract numerical entities like temperature and duration mentioned in unstructured formats of texts using neural models like CRF using python. I would like to know how to proceed for numerical extraction as most of the examples available on the internet are for specific words or strings extraction. \nInput: 'For 5 minutes there, I felt like baking in an oven at 350 degrees F'\nOutput: temperature: 350\n        duration: 5 minutes","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":55862614,"Users Score":0,"Answer":"So far my research shows that you can treat numbers as words. \nThis raises an issue : learning 5 will be ok, but 19684 will be to rare to be learned.\nOne proposal is to convert into words. \"nineteen thousands six hundred eighty four\" and embedding each word. The inconvenient is that you are now learning a (minimum) 6 dimensional vector (one dimension per word)\nBased on your usage, you can also embed 0 to 3000 with distinct ids, and say 3001 to 10000 will map id 3001 in your dictionary, and then add one id in your dictionary for each 10x.","Q_Score":0,"Tags":"python-3.x,nlp,named-entity-recognition","A_Id":58901069,"CreationDate":"2019-04-26T07:18:00.000","Title":"numerical entity extraction from unstructured texts using python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Question: Is there a way to make a Python game window display within Unity rather than opening a new window outside of Unity?\nContext: I have an assignment which is making a game in Unity 3D and I'm not enjoying it all that much. I have found great success and joy in creating games using the Python Arcade library when compared with Unity and the progress I make in Python is staggering compared.\nI haven't tried all that much as this seems to be a pretty special problem but I will search.\nExpected Outcome: I want to be able to display the Python game through an in-Unity sprite such as an arcade machine sprite which the Python game window will be displayed on\/in. It is important that the Python game will be displayed in Unity just in case I may be able to get away with this for my assignment, and that a player can interact with the Python game through controls in Unity.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":99,"Q_Id":55863377,"Users Score":2,"Answer":"What you ask for it more likely to be 10x more complex than writing a simple arcade game. Not meaning to diss your favourite game library but unity is fantastic and trying to avoid learning the basics of it is simply a mistake.\nWhile there are few thing 'not possible' within unity, embedding a view rendered by something completely different like a python framework sounds like weeks of work - where as writing a game on an assignment level once you grasp the basics is more like a few hours","Q_Score":0,"Tags":"c#,python,unity3d","A_Id":55863717,"CreationDate":"2019-04-26T08:08:00.000","Title":"Is it possible to display a python game window (or any file window) in Unity 3D?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python WebJob living in Azure and I'm trying to pass parameters to it. \nI've found documentation saying that I should be able to post the URL and add:?arguments={'arg1', 'arg2'} after it. \nHowever, when I do that and then try to print(sys.argv) in my code, it's only printing the name of the Python file and none of the arguments I pass to it. \nHow do I get the arguments to pass to my Python code? I am also using a run.cmd in my Azure directory to trigger my Python code if that makes a difference. \nUPDATE: So I tested it in another script without the run.cmd and that certainly is the problem. If I just do ?arguments=22 66 it works. So how do I pass parameters when I'm using a run.cmd file?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":184,"Q_Id":55870100,"Users Score":2,"Answer":"I figured it out: in the run.cmd file, you need to put \"%*\" after your script name and it will detect any arguments you passed in the URL.","Q_Score":1,"Tags":"python,azure,azure-webjobs","A_Id":55873033,"CreationDate":"2019-04-26T14:50:00.000","Title":"Python Azure webjob passing parameters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I want to run only the which tests are marked as pytest.mark.skip\nIn my Test class i had marked few test cases are marked as skip. Now i want to run those tests only","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":929,"Q_Id":55872637,"Users Score":3,"Answer":"You could switch to using skipif conditioned on some environment variable.\ni.e.\n@pytest.mark.skipif(os.getenv('FORCE2RUN_SKIPPED_TEST')!='1')","Q_Score":1,"Tags":"python,pytest","A_Id":55873475,"CreationDate":"2019-04-26T17:44:00.000","Title":"How to run a test marked skip in pytest","Data Science and Machine Learning":0,"Database and SQL":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 work with (i.e. edit, create, delete...) files such as .docx1, and .xlsx inside a zip file without unzipping the file in Python?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":73,"Q_Id":55872849,"Users Score":-1,"Answer":"There is no way to work (intelligent) with a file without reading it first. Unzipping == reading.","Q_Score":1,"Tags":"python,python-3.x","A_Id":55876543,"CreationDate":"2019-04-26T18:01:00.000","Title":"Edit files inside zip file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training a neural network for Neural Machine Traslation on Google Colaboratory. I know that the limit before disconnection is 12 hrs, but I am frequently disconnected before (4 or 6 hrs). The amount of time required for the training is more then 12 hrs, so I add some savings each 5000 epochs.\nI don't understand if when I am disconnected from Runtime (GPU is used) the code is still execute by Google on the VM? I ask it because I can easily save the intermediate models on Drive, and so continue the train also if I am disconnected.\nDoes anyone know it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6010,"Q_Id":55874473,"Users Score":1,"Answer":"Yes, for ~1.5 hours after you close the browser window. \nTo keep things running longer, you'll need an active tab.","Q_Score":1,"Tags":"python,neural-network,pytorch,google-colaboratory","A_Id":55874689,"CreationDate":"2019-04-26T20:21:00.000","Title":"Does Google-Colab continue running the script when \"Runtime disconnected\"?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am confused about the mean of JWT_DEFAULT_REALM or the mean of \"The default realm\" when I am using Flask_JWT. I am not a native English speaker.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":264,"Q_Id":55876768,"Users Score":1,"Answer":"The realm is part of the HTTP standard and send with an authentication request from the server to the client together with an authentication type (JWT in this case).\nIt describes the resource that is protected. In Basic authentication type it will be the resource name shown in the login box above the form fields. \nIn authentication with JWTs it makes less sense since you would not expect the user to manually enter the JWT and browsers don't have special handling for the type JWT. So it will at max be included in an error message.","Q_Score":0,"Tags":"python,flask,flask-jwt","A_Id":55876861,"CreationDate":"2019-04-27T02:34:00.000","Title":"What is the mean of JWT_DEFAULT_REALM?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm learning a bit about the automation of web applications using python \nI came across this module:  \nfrom selenium.webdriver.common.keys import Keys\nWhat is the meant by keys and use of keys?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":2663,"Q_Id":55877964,"Users Score":3,"Answer":"The Keys are referring to keyboard keys. It's used to ID the different Keys on the keyboard. Ex: Keys.RETURN means your ENTER key in your keyboard.\nThese keys can then be used by selenium for keyboard emulation or other stuff.","Q_Score":0,"Tags":"python","A_Id":55878045,"CreationDate":"2019-04-27T06:37:00.000","Title":"What is the use of from selenium.webdriver.common.keys import Keys","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im creating a form with python3 and tkinter, with a fwe buttons and a scrollbar. When I navigate the form via tab and ctrl-tab, it focus all the buttons AND the scrollbar too. I would like to exclude the scrollbar (and possibly other widgets) from the tabstop index. Is that possible?\nRegards","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":63,"Q_Id":55879331,"Users Score":1,"Answer":"You need to set the takefocus attribute of the scrollbar and other widgets to False.","Q_Score":0,"Tags":"python,tkinter","A_Id":55881902,"CreationDate":"2019-04-27T09:57:00.000","Title":"Create a widget without tab index","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset with number of columns. I need to select some columns by their position. for example, I want to select columns 0,3,6,7,15 (by position) from the dataset. I tried using iloc but it seems it is applicable in the range of position, ( I may be wrong?) If there are any better ideas?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":54,"Q_Id":55881531,"Users Score":-1,"Answer":"Use this syntax: data.iloc[:, [0,1,20,22]]\nWhere 0,1,20 and 22 is the column index.","Q_Score":0,"Tags":"python,pandas","A_Id":55881586,"CreationDate":"2019-04-27T14:24:00.000","Title":"select costume column by position pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was using simple logistic regression to predict  a problem and trying to plot the precision_recall_curve and the roc_curve with predict_proba(X_test). I checked the docstring of predict_proba but hadn't had much details on how it works. I was having bad input every time and checked that y_test, predict_proba(X_test) doesn't match. Finally discovered predict_proba() produces 2 columns and people use the second.\nIt would be really helpful if someone can give an explanation how it produces two columns and their significance. TIA.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4584,"Q_Id":55882873,"Users Score":1,"Answer":"We can distinguish between the classifiers using the classifier classes. if the classifier name is model then model.classes_ will give the distinct classes.","Q_Score":6,"Tags":"python,machine-learning,scikit-learn,precision-recall","A_Id":65195428,"CreationDate":"2019-04-27T17:00:00.000","Title":"How predict_proba in sklearn produces two columns? what are their significance?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to turn my pc off and restart it on LAN. \nWhen getting one of the commands (turnoff or restart), I execute one of the followings:\nsubprocess.call([\"shutdown\", \"-f\", \"-s\", \"-y\"])  # Turn off\nsubprocess.call([\"shutdown\", \"-f\", \"-r\", \"-t\", \"-c\", \"-y\"]) # Restart\nI'd like to inform the other side if the process was successfully initiated, and if the PC is in the desired state.\nI know that it is possible to implement a function which will check if the PC is alive (which is a pretty good idea) several seconds after executing the commands, but how one can know how many seconds are needed? And what if the PC will be shut down a moment after sending a message stating that it is still alive?\nI'm curious to know- what really happens after those commands are executed? Will the script keep running until the task manager will kill it? Will it stop running right after the command?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":55882903,"Users Score":1,"Answer":"Programs like shutdown merely send a message to init (or whatever modern replacement) and exit immediately; it\u2019s up to it what happens next.  Typical Unix behavior is to first shut down things like SSH servers (which probably doesn\u2019t kill your connection to the machine), then send SIGTERM to all processes, wait a few seconds (5 is typical) for signal handlers to run, and then send SIGKILL to any survivors.  Finally, filesystems are unmounted and the hardware halt or reboot happens.\nWhile there\u2019s no guarantee that the first phase takes long enough for you to report successful shutdown execution, it generally will; if it\u2019s a concern, you can catch the SIGTERM to buy yourself those few extra seconds to get the message out.","Q_Score":0,"Tags":"python,multithreading,subprocess,task,shutdown","A_Id":55883196,"CreationDate":"2019-04-27T17:03:00.000","Title":"What happens after shutting down the PC via subprocess?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to generate a vCard QR code with the pyqrcode library but I cannot figure out the way to do it.\nI have read their documentation 5 times and it doesn't say anything about vCard, only about URL and on the internet, I could found only about wifi. Does anybody know how can I do it?\nI want to make a vCard QR code and afterward to display it on django web page.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3595,"Q_Id":55884546,"Users Score":0,"Answer":"Let's say :\nWe've two libraries:\n\npyqrcode : QR      reader \/ writer \nvobject   : vCard  serializer \/    deserializer\n\nFlow:\na. Generate a QR img from \"some\" web site :\nweb site send JSON info => get info from JSON and serialize using vobject to obtain a vcard string =>   pyqrcode.create(vcard string)  \nb. Show human redeable info from QR img  :\npyqrcode read an QR img ( created from a. )  => deserialize using vobject to obtain a JSON => show info parsing JSON in the web site.\nOR... after deserialize using vobject you can write a .vcard file","Q_Score":3,"Tags":"python,django,vcf-vcard","A_Id":55886326,"CreationDate":"2019-04-27T20:18:00.000","Title":"How can I create a vCard qrcode with pyqrcode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I receive selenium.common.exceptions.WebDriverException: Message: Service \/usr\/bin\/google-chrome unexpectedly exited. Status code was : 0\nFor background, this is a Linux system and I am typing all the information in the terminal. I looked at many questions. A lot of them recommending uninstalling and reinstalling Chrome. I did that several times. I typed in whereis Google Chrome and found the location. I did not get a .exe file though so I used \"\/usr\/bin\/google-chrome\". Linux doesn't appear to create a .exe file. I am bringing this up because I am not sure if this contributed to my error.\nThis is after I typed in \nmy_path = \"\/usr\/bin\/google-chrome\"\nbrowser = webdriver.Chrome(executable_path=my_path)\nI get many lines of responses on the terminal referencing files in my python3.6 library. Before the main error of it saying it exited unexpectedly, I get \n\"file \"home\/ganesh\/.local\/lib\/python3.6\/site-packages\/selenium\/webdriver\/chrome\/webdriver.py, line 73 in init\"\n\"file \"home\/ganesh\/.local\/lib\/python3.6\/site-packages\/selenium\/webdriver\/chrome\/webdriver.py, line 98 in start\"\nThe thing is that my terminal successfully opens the Chrome browser. However, I get the webdriver exception message I had.\nIn addition, the code ,\nbrowser = webdriver.Chrome(executable_path=my_path)\nclearly didn't fully work because later in the program when I type in \nbrowser.(something else), it doesn't work and says \"name 'browser' is not define\"\nI am hoping for the webdriver exception error to be resolved and for me to successfully be able to call browser in my code later on\nThis question is not a duplicate as marked by someone here. The question that he referred to as answering my question does not answer my question - in that version Chrome exited. In mine, Chrome did not exit, it stayed open. In addition, the previous question has solutions in Windows and Mac, but not for Linux which is my operating system.\nIt is my first week using Linux.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":87,"Q_Id":55885675,"Users Score":1,"Answer":"Welcome to SO. If the chromedriver file is located in \/usr\/bin\/google-chrome folder then your my_path should be my_path = \"\/usr\/bin\/google-chrome\/chromedriver\"","Q_Score":0,"Tags":"python,linux,python-3.x,google-chrome,selenium-webdriver","A_Id":55885757,"CreationDate":"2019-04-27T23:19:00.000","Title":"Chrome opens succesfully from terminal but I get webdriver common exception message","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I made python script using Selenium webdriver. I use that script to login onto system of my faculty and looking on posts. Script refresh page every 60s to see if there is any new post, if there is new post I would recieve Telegram message on my phone. There is no problem with that, problem is that I have to run that script on my laptop 24h to get notifications, which is not possible since I carry it around. \nQuestion is, how can I run that script 24h? Is there any better solution to monitor that page and send messages if there is new post? \nI tried pythonanywhere but I don't have too much experience in that field so I didn't manage to make it work since always some module is missing...","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":905,"Q_Id":55889195,"Users Score":1,"Answer":"I'd just use a Windows virtual machine from AWS\/Microsoft Azure\/Google\/etc. This may be a bit overdoing it in your situation, but you could have one VM connected to another VM that'd be running your script, if it's something that requires an always-on user interface and can't be run in a Linux headless browser. \nInstalling something like AppRobotic personal macro edition on any of the above cloud services would work great. The pro version that's on AWS Marketplace would also work great, but it'd be overdoing it in your use case.","Q_Score":1,"Tags":"python,selenium,webautomation","A_Id":55889276,"CreationDate":"2019-04-28T10:09:00.000","Title":"How to run python script with selenium all the time but not on my 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 made python script using Selenium webdriver. I use that script to login onto system of my faculty and looking on posts. Script refresh page every 60s to see if there is any new post, if there is new post I would recieve Telegram message on my phone. There is no problem with that, problem is that I have to run that script on my laptop 24h to get notifications, which is not possible since I carry it around. \nQuestion is, how can I run that script 24h? Is there any better solution to monitor that page and send messages if there is new post? \nI tried pythonanywhere but I don't have too much experience in that field so I didn't manage to make it work since always some module is missing...","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":905,"Q_Id":55889195,"Users Score":1,"Answer":"Welcome !\nThe best way for you would be to use a server so you don't have to run it locally on your computer.\nYou can use an online VPS on which you install your software or you may even try to run it locally on something like a Raspberry Pi.\nIn both case, you will have to deal with linux commands.\nGood luck","Q_Score":1,"Tags":"python,selenium,webautomation","A_Id":55889236,"CreationDate":"2019-04-28T10:09:00.000","Title":"How to run python script with selenium all the time but not on my 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":"As the question asks, I want to be sure that the script is executed by a specific version of python, say =>3.5.2.\nHow can I make sure that the script when executed is called by the specific version.\nThis check should be done in the python script itself.\nIt could be better if the solution is platform independent.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":768,"Q_Id":55889313,"Users Score":1,"Answer":"You can check the version by calling sys.version_info. This will give you a tuple in the form sys.version_info(major=3, minor=6, micro=5, releaselevel='final', serial=0).","Q_Score":2,"Tags":"python,linux,python-3.x,windows","A_Id":55889342,"CreationDate":"2019-04-28T10:25:00.000","Title":"How to make sure the script is executed by a specific version of python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm very new to this and I'm sure I'm missing something here, but here goes:\nI've installed a few packages via pip in cmd, let's take sklearn for example:\n\npip install sklearn\n\nThe installation goes fine. I get a message:\n\nSuccessfully installed sklearn-0.0.\n\nI then go to pycharm and start my code with \n\nimport sklearn\n\nI run the code and get the following error \n\nModuleNotFoundError: No module named 'sklearn'.\n\nThis is just an example, it happens to every package I install, so I'm assuming it's something with the installation path (or something else that's basic which I don't understand).\nI'm using: \n* python V 3.7.2 (I've read a few posts about similar issues and many mentioned it's due to both python 2 and 3 being installed on your comp, but no other versions of python are installed on my comp)\n* pycharm V 2018.3.4 community edition\n* Windows 10 pro\nSince I suspect it's related to the path, here is where pip install packages for me:\n\nc:\\users\\shay\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.7_qbz5n2kfra8p0\\localcache\\local-packages\\python37\\site-packages\n\nI looked for more basic packages that come with python to try and see where they are, and found that they are here:\n\nC:\\Users\\Shay\\AppData\\Local\\Programs\\Python\\Python37-32\\Lib\n\nI've added both folders to my variable path in windows.\nI've also tried to copy the content of the installation folder (top one, ends with \"site-packages\") and pasted it to the bottom folder (ends with \"Lib\"), but it didn't work.\nWhat am I doing wrong here?\nI expect to be able to run \"import sklearn\" (and other packages) after I install it via pip, but instead I get the above mentioned error.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":645,"Q_Id":55890071,"Users Score":1,"Answer":"You are execute that command at sys level. So if your default python is 2.7.12. Then If you run pip install in cmd then it will work for system level.\nBut in pycharm it always create a virtual environment,So that this error occurs. \nSo either you can run your program using cmd or you have to setup your virtual environment first and install all the python library in virtual environment and then run your program.","Q_Score":0,"Tags":"python,python-3.x,path,pip,pycharm","A_Id":55890126,"CreationDate":"2019-04-28T12:04:00.000","Title":"getting the error: ModuleNotFoundError: No module named  for everything I install via pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to host a python script on Google Cloud which would run indefinitely. \nWhich Google Cloud Products can be used to achieve this reliably and economically?\nis this possible on AppEngine?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1103,"Q_Id":55890781,"Users Score":2,"Answer":"Within GCP there are a number of ways to run processing logic.  We have App Engine, Functions, Compute Engine, GKE, Cloud Run and more.  Of these, Compute Engine and GKE provide the lowest level control meaning that you can orchestrate code to run 100% of the time ... and basically do anything you want.  Based on your story, it sounds like a Compute Engine would be what you want.  When you create a Compute Engine, you are basically given a Virtual Machine (commonly Linux) and you simply run what ever logic \/ applications you want within that environment.  Google charges you for the duration that the Compute Engine runs.  If you have an always running explicit Python app, then you will be billed 24x7 irrespective of whether or not traffic is actually arriving.\nOther capabilities that you are likely going to want to consider are Cloud Functions.  A Cloud Function is logic that runs only when there is an active request to be processed.  It is GCP's responsibility to passively listen for new requests without charging you for that service.  When a request arrives, your logic is executed and you are billed only for the duration that your logic ACTUALLY executes.  Cloud Run is similar to Cloud Functions but the logic is hosted in a Kubernetes environment as opposed to native.\nFor Cloud Function, incoming requests can arrive either via REST requests or via GCP Pub\/Sub.  In your description, neither of these apply as you are receiving data via MQTT.  This is where Google IOT Core comes into play.  Google IoT core is a full suite environment for managing IoT devices.  Primary among this story is the ability to passively listen for incoming MQTT requests.  When an authorized IoT device sends in an MQTT request, the Google IoT core automatically forwards the content of the MQTT request via GCP Pub\/Sub.  This then decouples the mechanics of the arriving IoT message from how it will be eventually processed.  Since the MQTT message has now been published to GCP Pub\/Sub, this can then be used as a trigger for a Google Cloud Function.\nFollowing all these parts ... one possibility to examine which may result in the cheapest and more dynamically scalable solution would be:\nIoT Device --- MQTT ---> IoT Core --- Pub\/Sub ---> Cloud Function\nThis story has basically changed the paradigm from \"How do I actively listen for requests in my code in an indefinite manner\" to \"How do I have my code executed when a request arrives\".","Q_Score":2,"Tags":"python,google-app-engine,google-cloud-platform","A_Id":55892588,"CreationDate":"2019-04-28T13:36:00.000","Title":"Always Running Python Script on Google Cloud","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have just upgraded from TF 1.13 to TF 2.0, and my interpreter is complaining because tf.set_random_seed does no longer exist.\nWhat is the equivalent functionality in TF 2.0 ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1162,"Q_Id":55890834,"Users Score":7,"Answer":"Found it: tf.random.set_seed is what I was looking for","Q_Score":7,"Tags":"python,tensorflow","A_Id":55891000,"CreationDate":"2019-04-28T13:41:00.000","Title":"Setting a random seed on TF 2.0","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I am doing a etl process in which I use Apache NiFi as an etl tool  along with a postgresql database from google cloud sql to read csv file from GCS. As a part of the process, I need to write a query to transform data read from csv file and insert to the table in the cloud sql database. So, based on NIFi, I need to write a python to execute a sql queries automatically on a daily basis. But the question here is that how can I write a python to connect with the cloud sql database? What config that should be done? I have read something about cloud sql proxy but can I just use an cloud sql instance's internal ip address and put it in some config file and creating some dbconnector out of it? \nThank you\nEdit: I can connect to cloud sql database from my vm using psql -h [CLOUD_SQL_PRIVATE_IP_ADDR] -U postgres but I need to run python script for the etl process and there's a part of the process that need to execute sql. What I am trying to ask is that how can I write a python file that use for executing the sql \ne.g. In python, query = 'select * from table ....' and then run\npostgres.run_sql(query) which will execute the query. So how can I create this kind of executor?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":526,"Q_Id":55891829,"Users Score":0,"Answer":"I don't understand why you need to write any code in Python? I've done a similar process where I used GetFile (locally) to read a CSV file, parse and transform it, and then used ExecuteSQLRecord to insert the rows into a SQL server (running on a cloud provider). The DBCPConnectionPool needs to reference your cloud provider as per their connection instructions. This means the URL likely reference something.google.com and you may need to open firewall rules using your cloud provider administration.","Q_Score":0,"Tags":"python,google-cloud-storage,etl,google-cloud-sql,apache-nifi","A_Id":55894286,"CreationDate":"2019-04-28T15:35:00.000","Title":"Cloud SQL\/NiFi: Connect to cloud sql database with python and NiFi","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to program a Raspberry Pi to take a single keyboards inputs in one USB port and then output through the Pi's two other USB ports in order to control two Macs at once with one keyboard.\nI'm very new to Python. Which functions and commands do I need in order to program this function to my Pi?\nI've been searching for the proper command, but I came here for help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":55892458,"Users Score":0,"Answer":"This isn't exactly something easily done with Python. This is because you're delving into developing device drivers on your Macs' side. Please allow me to explain:\nAssuming you're using Raspbian on the Raspberry Pi (a flavor of Linux, and thus a Posix system onto itself), you would need to read the appropriate \/dev\/tty* file which maps to your keyboard first, and then appropriately convert and write out to the appropriate \/dev\/usb* files. Do note, most computers also send handshakes back and forth to the USB devices (for example, to register them on their own USB busses).\nTo be frank, you'd probably have better luck splicing wires from your keyboard, and connecting it to another USB male-socket, and then plugging both male-socket ends into your Macs.","Q_Score":0,"Tags":"python","A_Id":55892585,"CreationDate":"2019-04-28T16:44:00.000","Title":"Raspberry Pi Keyboard Splitter","Data Science and Machine Learning":0,"Database and SQL":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 studying convolution neural network architecture. I am horrendously confused on the part, where, a 3d kernel acts upon the 3d input image (well, it's 4d given we have stack of those images, but just to make explanation a bit easier). I know internet is full of stuffs like this. but i can't find exact answer to that matrix multiplication part. \nTo be easier for everyone to understand, Can someone show me an actual multiplication on how convolution of (5,5,3) matrix (our kernel) over (28,28,3) matrix (our RGB image ) takes place, outputting a 2d array.  \nAlso, please also show, (with a detailed picture) , how those numerous 2d arrays gets flattened and gets connected to a single fully connected layer. \ni know that, final layer of pooled 2d arrays are flattened. but, since there are like 64 2d arrays (just consider), .. so even if we flatten each one, we will have 64 flattened 1D array. so, how does this end up connecting to next fully connected layer ? (Picture please)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":574,"Q_Id":55892792,"Users Score":1,"Answer":"You have multiple questions in one. I will answer the about the \"how the convolution takes place\". Short answer: it is not a matrix multiplication.\nStep 1) You slide a window of size (5,5,3) over your RGB image carving out subimages of that size. Incidentally these subimages have exactly the same dimension as that of the kernel.\nStep 2) You multiply each subimage values with the values of the convolution component wise. The output of that is again (5,5,3) subimage \"scaled\" by the values of the kernel.\nStep 3) You add all the values of the \"scaled\" (5,5,3) subimage together (effectively squishing the dimensions) into a single value -- that is our final output.","Q_Score":1,"Tags":"python,arrays,matrix,conv-neural-network,convolution","A_Id":55892936,"CreationDate":"2019-04-28T17:24:00.000","Title":"How exactly does matrix multiplication of 3d kernel and 3d image ( Say RGB) takes place to give 2d output?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to import numpy.  I do not have it as a module so I attempted to download it as a .whl file.  I successfully downloaded it to my computer but am having trouble with installing into python 3.7.\nI know I have to install numpy onto my computer and then Python.  I downloaded the .whl file but am having trouble transferring it into my cmd prompt.\n\n\n\nimport numpy as np\n      Traceback (most recent call last):\n        File \"stdin\", line 1, in module\n      ModuleNotFoundError: No module named 'numpy'\n\n\n\nI want to \"import numpy as np\" without errors","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1651,"Q_Id":55894852,"Users Score":0,"Answer":"The easiest way to download and manage modules is using python's built-in pip command.\npip install numpy will install numpy in your site-packages directory, where it needs to be to use it with Python 2\npip3 install numpy will do the same thing for Python 3","Q_Score":0,"Tags":"python,numpy,import","A_Id":55895064,"CreationDate":"2019-04-28T21:46:00.000","Title":"Trouble importing numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use flask and gunicorn for deploy on production scale machine learning models, but the memory using gunicorn with 4 workers is very huge (almost 4x) without gunicorn. Can gunicorn use less memory?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1974,"Q_Id":55897044,"Users Score":0,"Answer":"Adjust your worker to (2*CPU)+1. This is the suggested maximum concurrent requests when using workers and threads.","Q_Score":2,"Tags":"python","A_Id":55898014,"CreationDate":"2019-04-29T04:37:00.000","Title":"How make gunicorn and flask not consume huge memory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a list of approx. 52 websites which lead to about approx. 150 webpages that i require scraping on. Based on my ignorance and lack of research i started building crawlers per webpage which is starting to become to difficult to complete and maintain. \nBased on my analysis thus far I already know what information i want to scrape per webpage and it is clear that these websites have their own structure. On the plus side i noticed that each website has some commonalities in their web structure among their webpages.\nMy million dollar question, is there a single technique or single web crawler that i can use to scrape these sites? I already know the information that I want, these sites are rarely updated in terms of their web structure and most of these sites have documents that need to be downloaded. \nAlternatively, is there a better solution to use that will reduce the amount of web crawlers that I need to build? additionally, these web crawlers will only be used to download the new information of the websites that i am aiming them at.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":55900736,"Users Score":0,"Answer":"[\u2026] i started building crawlers per webpage which is starting to become to difficult to complete and maintain [\u2026] it is clear that these websites have their own structure. [\u2026] these sites are rarely updated in terms of their web structure [\u2026]\n\nIf websites have different structures, having separate spiders makes sense, and should make maintenance easier in the long term.\nYou say completing new spiders (I assume you mean developing them, not crawling or something else) is becoming difficult, however if they are similar to an existing spider, you can simply copy-and-paste the most similar existing spider, and make only the necessary changes.\nMaintenance should be easiest with separate spiders for different websites. If a single website changes, you can fix the spider for that website. If you have a spider for multiple websites, and only one of them changes, you need to make sure that your changes for the modified website do not break the rest of the websites, which can be a nightmare.\nAlso, since you say website structures do not change often, maintenance should not be that hard in general.\nIf you notice you are repeating a lot of code, you might be able to extract some shared code into a spider middleware, a downloader middleware, an extension, an item loader, or even a base spider class shared by two or more spiders. But I would not try to use a single Spider subclass to scrape multiple different websites that are likely to evolve separately.","Q_Score":0,"Tags":"python,scrapy,web-crawler","A_Id":55919394,"CreationDate":"2019-04-29T09:44:00.000","Title":"Using a Single Web Crawler to Scrape Multiple websites in a predefined format with attachments?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a list of approx. 52 websites which lead to about approx. 150 webpages that i require scraping on. Based on my ignorance and lack of research i started building crawlers per webpage which is starting to become to difficult to complete and maintain. \nBased on my analysis thus far I already know what information i want to scrape per webpage and it is clear that these websites have their own structure. On the plus side i noticed that each website has some commonalities in their web structure among their webpages.\nMy million dollar question, is there a single technique or single web crawler that i can use to scrape these sites? I already know the information that I want, these sites are rarely updated in terms of their web structure and most of these sites have documents that need to be downloaded. \nAlternatively, is there a better solution to use that will reduce the amount of web crawlers that I need to build? additionally, these web crawlers will only be used to download the new information of the websites that i am aiming them at.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":55900736,"Users Score":0,"Answer":"I suggest you crawl specific tags such as body, h1,h2,h3,h4,h5, h6,p and... for each links. You can gather all p tags and append them into a specific link. It can be used for each tags you want to crawl them. Also, you can append related links of tags to your database.","Q_Score":0,"Tags":"python,scrapy,web-crawler","A_Id":55920004,"CreationDate":"2019-04-29T09:44:00.000","Title":"Using a Single Web Crawler to Scrape Multiple websites in a predefined format with attachments?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I try to check appium version with 'appium -v' I receive command not found. What can I do? \nI tried different options but it's not working","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2575,"Q_Id":55902054,"Users Score":1,"Answer":"If you are on Mac OS try\n\nappium --version","Q_Score":0,"Tags":"python-appium","A_Id":69764939,"CreationDate":"2019-04-29T11:06:00.000","Title":"When I try to check appium version with 'appium -v' I receive command not found. What can 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"These days i'm trying to teach myself machine learning and i'm going though some issues with my dataset.\nSome of my rows (i work with csv files that i create with some js script, i feel more confident doing that in js) are empty wich is normal as i'm trying to build some guessing model but the issue is that it results in having nan values on my training set.\nMy NN was not training so i added a piece of code to remove them from my set but now i have some issues where my model can't work with input from different size..\nSo my question is: how do i handle missing data ? (i basically have 2 rows and can only have the value from 1 and can't merge them as it will not give good results)\ni can remove it from my set, wich would reduce the accuracy of my model in the end.\nPS: if needed i'll post some code when i come back home.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3144,"Q_Id":55903882,"Users Score":6,"Answer":"You need to have the same input size during training and inference. If you have a few missing values (a few %), you can always choose to replace the missing values by a 0 or by the average of the column. If you have more missing values (more than 50%) you are probably better off ignoring the column completely. Note that this theoretical, the best way to make it work is to try different strategies on your data.","Q_Score":3,"Tags":"python,machine-learning,keras,neural-network","A_Id":55904338,"CreationDate":"2019-04-29T12:55:00.000","Title":"Keras \/ NN - Handling NaN, missing input","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have forked a project in Gitlab to my own namespace. I want to create a new branch of that project that mirrors the original repo's master but I do not want to set a remote in my forked repo nor do I want to track that branch. Is there any way I can do it?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":117,"Q_Id":55905036,"Users Score":3,"Answer":"git checkout -b my_branch --no-track <remote>\/master","Q_Score":0,"Tags":"git,gitpython","A_Id":55905117,"CreationDate":"2019-04-29T14:03:00.000","Title":"Checkout a remote branch without tracking 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":0},{"Question":"I've been working on a projects and I'm trying to use as minimal modules as I can (only basics like Numpy). I want to get accurate GPS data, I'm pretty sure that my computer has location service because I can turn int on in my settings. I know it possible if you use an arduino with gps shield and communicate with it over the serial connection but I would like to have just a script instead of a bunch of hardware. \nIn Short I'm using python 3. How can I retrieve my location using a python script?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":839,"Q_Id":55905298,"Users Score":-1,"Answer":"you can use the google geolocation API for this!!","Q_Score":0,"Tags":"python,python-3.x,gps","A_Id":55905401,"CreationDate":"2019-04-29T14:18:00.000","Title":"How to get data from your internal gps with python 3?","Data 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 quite beginner in python. I am using Spyder (Python 3.6) (Anaconda distribution). I am trying to access the azure blob storage from python script. I have installed Azure environment using Anaconda Navigator. I am importing BlockBlobService from azure.storage.blob. However, I am getting error ModuleNotFoundError:No module named 'azure.storage'. \nIs there something missing in order to access the azure blob storage?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":686,"Q_Id":55906301,"Users Score":0,"Answer":"Just for summary, your issue is resulted from the conflict between python 2.7 version you installed and the python version with Anaconda.\nThe packages you installed should to be in the python 2.7 environment. However, spyder uses the Anaconda self-brought python environment.\nCommand line uses system python environment which is determined by the the previous python environment variable in the path.","Q_Score":0,"Tags":"python,azure","A_Id":55906648,"CreationDate":"2019-04-29T15:17:00.000","Title":"How to fix \"ModuleNotFoundError: No module named 'azure.storage' \"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Cant' install 'matplotlib.pyplot' on Windows 10, Python 3.7\nI tried 'pip install matplotlib.pyplot' and received an error\nHere's the exact error code:\nCould not find a version that satisfies the requirement matplotlib.pyplot (from versions: )\nNo matching distribution found for matplotlib.pyplot","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":699,"Q_Id":55906943,"Users Score":2,"Answer":"Don't use pip install matplotlib.pyplot, use pip install matplotlib\nmatplotlib.pyplot is calling pyplot from the module matplotlib. What you want is the module, matplotlib. Then from idle or wherever you are running this, you can call matplotlib.pyplot","Q_Score":1,"Tags":"python,python-3.x","A_Id":55906967,"CreationDate":"2019-04-29T15:58:00.000","Title":"Trouble installing 'matplotlib'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Cant' install 'matplotlib.pyplot' on Windows 10, Python 3.7\nI tried 'pip install matplotlib.pyplot' and received an error\nHere's the exact error code:\nCould not find a version that satisfies the requirement matplotlib.pyplot (from versions: )\nNo matching distribution found for matplotlib.pyplot","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":699,"Q_Id":55906943,"Users Score":0,"Answer":"Try just using pip install on your command line (or terminal):\n'pip install matplotlib'\nI hope it helps.\nBR","Q_Score":1,"Tags":"python,python-3.x","A_Id":55906978,"CreationDate":"2019-04-29T15:58:00.000","Title":"Trouble installing 'matplotlib'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a a very simple test that launches and close a software I was testing using Python Nose test platform to track down a bug in the start up sequence of the software I was working on.  \nThe test was set up so that it would launch and close about 1,500 times in a singling execution.\nA few hours later, I discovered that the test was not able to launch to the software around after 300 iterations.  It was timing out while waiting for the process to start.  As soon as I logged back in, the test started launching the process without any problem and all the tests started passing as well.\nThis is quite puzzling to me.  I have never seen this behavior.  This never happened on Windows also.  \nI am wondering if there is a sort of power saving state that Mac was waiting for currently running process to finish and prohibits new process from starting.\nI would really appreciate if anybody can shed light on this confusion.\nI was running Python 2.7.x on High Sierra.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":55908161,"Users Score":0,"Answer":"I am not aware of any state where the system flat out denies new processes while old ones are still running.\nHowever, I can easily imagine a situation in which a process may hang because of some unexpected dependency on e.g. the window server. For example, I once noticed that rsvg-convert, a command-line SVG-to-image converter, running in an SSH session, had different fonts available to it depending on whether I was also simultaneously logged in on the console. This behavior went away when I recompiled the SVG libraries to exclude all references to macOS specific libraries...","Q_Score":0,"Tags":"python,macos,macos-sierra,macos-high-sierra","A_Id":55908436,"CreationDate":"2019-04-29T17:23:00.000","Title":"Mac power save state - what is the state of still running existing process but can't launch new process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"In C++ there are .h and .cpp files for design and implementation of code respectively. Is there a similar way to structure files in Python? Can I define my class in one file, and then put all the code for that class in another?\nI feel like the answer is \"no\". I've tried looking up the answer, but the closest results were just how to merge c++ and python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":548,"Q_Id":55910940,"Users Score":0,"Answer":"It would be much less worthwhile to do than in c++ because as AlexG mention python is not a compiled language. However, you could achieve a \"similar\" effect by linking to another python file. For example, if you wanted to have all of your functions created in a single file, and all of your logic done using those functions in another you would simply use import filename and you could reference your functions in the second file like you would in a .h and .cpp file.","Q_Score":0,"Tags":"python,c++","A_Id":55911047,"CreationDate":"2019-04-29T21:19:00.000","Title":"Is there a Python version of .h and .cpp 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am an electrical engineer building a Python application to interface with PSS\/E (Power Systems Simulation for Engineers by PTI Siemens).  The way the code currently works, the program contains a main method which calls methods from two classes (in separate files) which I have written.  Throughout the different steps of the program, the user interacts with it through a terminal (Enter file paths, press enter to continue, etc).  \nI am working on implementing a GUI with Tkinter.  The user would browse to select several files, select certain options, then press 'Start'. Then, the user would interact with the GUI at the different steps of the program, instead of typing into the terminal.  \nWhat would be the philosophy used to implement a GUI into this program?  I am thinking that on the one hand, I can have a file for the GUI, initiate the program from this file, then call the main method when the user pushes 'start'.  The options\/file paths from the user, would be passed to the main method as parameters.  On the other hand,  I'm thinking of integrating the GUI into my main method.  Have a separate file with the class\/methods for the Tkinter widgets, and call them from main as needed.  Which (if any) of these would be the best way to go, and why?  I also have a question about how to deal with Python 2.7 being 'retired' in January of 2020, since my code is dependent on version 2.7.  I will ask this in another question to allow for some elaboration on this GUI question.  Thanks in advance for your input.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":55911002,"Users Score":1,"Answer":"While it is possible to write a GUI program as a straight port of a terminal program that works as you describe, with the main program driving the flow of interaction with the user, most GUI programs are written as a set of event handlers, also called callback functions. Because the event loop is calling back to you using the handlers you provide to it. \nUsually the main program just declares your controls, binds them to handlers, and starts the event handling loop.\nThere are various ways to organize such a program, and it depends a lot on your workflow. \nBut the event handling functions usually drive the overall logic, rather than the main program. This allows the user to interact with your program in a less linear way.\nIt is often useful to decouple the event handling logic and create a 'model' that represents the state of your program and logic unrelated to the GUI. Then the event handlers would call functions or methods of your model to change the state of the program.","Q_Score":0,"Tags":"python-2.7,tkinter,architecture,psse","A_Id":55911362,"CreationDate":"2019-04-29T21:23:00.000","Title":"Which Function Should be in the Driver's Seat on a GUI Application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a short series of ~60 values. What I need to do is find the largest sum of 24 consecutive values in the series. \ne.g. I would need to be able to find the sums of the groups [0:23],[1:24],[2:25],[3:26], ... , [37:60] and determine which group has the largest sum.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":55912004,"Users Score":0,"Answer":"You can use the rolling method on a serie :\nserie.rolling(24).sum()\nTo get directly the max \nmax_idx = serie.rolling(24).sum().idxmax()\nYou range of interest is [max_idx-24+1:max_idx] (from index max_idx - 24 + 1 to index max_idx (both included) , so be careful if you want to retrieve these elements, with .loc should be fine but if going back to the original list or if using iloc then you'll have to go to max_idx + 1.","Q_Score":1,"Tags":"python,python-3.x,pandas,dataframe,series","A_Id":55912036,"CreationDate":"2019-04-29T23:23:00.000","Title":"How can I find the sum of multiple groups within a series?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Do I need an actual mailbox and verified email to send email with SES?\nI own the domain I am trying to send from, but I do not have an account or mailbox setup (this is just a test domain, and I don't want to setup a gmail mailbox) \nIs there a better way to be doing this in a test environment?\nI am using the django-ses package, and sending email like this:\nsend_mail('Test subject', 'This is the body', 'mypersonalemail@yahoo.com',['info@mydomain.com'])\nI very well may have a fundamental misunderstanding of sending email, so any help is appreciated!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":455,"Q_Id":55912101,"Users Score":1,"Answer":"In the test environment, you can send messages e-mail only to address registered in sandbox.","Q_Score":0,"Tags":"python,django,email,amazon-ses","A_Id":55912134,"CreationDate":"2019-04-29T23:40:00.000","Title":"Send email via SES","Data Science and Machine Learning":0,"Database and SQL":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 create a snips app to play songs using Python 3 and the python-vlc library. I am able to play my songs, but unable to stop them. The action will not run again while the song is playing, but other actions will, so I'm looking to put the stop function in a seperate file. The problem with this, is it creates a second instance of vlc and does not stop the current song.\nI'm wondering if creating a singleton of the vlc object would allow me to accomplish this. \nDoes anyone have any recommendations?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":55913735,"Users Score":0,"Answer":"In my opinion I think you can use Singleton for playing and pausing\/stopping music. \nIt would make you able to control the only instance of the class that is initiated.\nEspecially if you only want to play small snippets of each song (kinda like SongPop I guess?), you'll be sure that no more than one instance of the class is initiated, and can be quite sure where and when it is used.","Q_Score":0,"Tags":"python,python-3.x,libvlc,snips","A_Id":55915830,"CreationDate":"2019-04-30T03:53:00.000","Title":"Is using a singleton the answer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to write a simple Python application to manage muted words for Twitter. The interface in the browser and the application are cumbersome to use.\nLooking through the API documentation, it seems that it is possible to create and destroy muted users but not words. Am I missing something, or is this simply not possible?\nI have been trying the python-twitter library but the functionality is missing there too. I realise this is probably an API limitation as opposed to the library.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":404,"Q_Id":55916527,"Users Score":3,"Answer":"No, this is not possible. The API only has methods for muting users, not words.","Q_Score":4,"Tags":"python,twitter","A_Id":55918277,"CreationDate":"2019-04-30T08:11:00.000","Title":"Is there a way to create and destroy muted words using 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":"For example, a=5, does it create an int object with a value 5 or is 5 an object itself?\nLet us take an employee class. When we instantiate e1=employee(\"Rakesh\",\"Singh\", 6000) it creates an employee object e1 with attributes fname=Rakesh, lname= Singh and Pay=6000.\nBut in the above case can we say e1 is equivalent to 5 (as they both are instances of different classes) or is e1 equivalent to an int object with value 5 ? \nI am confused, is the value itself an object or is it an attribute?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":77,"Q_Id":55916946,"Users Score":2,"Answer":"Python is dynamically typed and variable names can be assigned to different data types later on in a program.\nWhen it is declared that a = 5\n\nAn integer object of value 5 will be created (note that int's and str's in Python are immutable objects. You can't assign new value(s) to this objects. If you do, new objects are created (and not necessarily, existing objects of same value can be reused).\nThe 5 int object and the name a are bound.\nWhereas a is only a reference\/pointer that points to that object. The reference term is preferred  because you can't do things like pointer math, as in the C language. References are aliases to objects.\n\nHence, 5 is an int object of value 5 referred by the name\/reference a.\nBesides this, everything in Python is actually an object. Including functions, classes, exceptions and so on.\nAn object can have one or more attributes. And in Python every attribute is also an object.","Q_Score":0,"Tags":"python,class,oop,object","A_Id":55917513,"CreationDate":"2019-04-30T08:37:00.000","Title":"Are values of an object attributes, or are values themselves objects?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to automate Microsoft Office applications and after some Googling, I came across pypiwin32 and pywin32 to interact with Windows Component Objects. My question is, what's the difference between the two libraries? \nI have tried Googling but all the information I found seem to be outdated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4145,"Q_Id":55918311,"Users Score":18,"Answer":"Pypiwin32 is an old and outdated repackaging of pywin32 from its creator to use wheels. It is abandoned for a long time. You should just use pywin32.","Q_Score":13,"Tags":"python,pywin32","A_Id":55918399,"CreationDate":"2019-04-30T09:50:00.000","Title":"What is the difference between pywin32 and pypiwin32?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to connect my local spyder-ide to a remote spyder-kernel running on our ML-server. but as soon as i shut down the console, the kernel halts. is there a way to start the kernel in the background and keep it running ? \ni can start a kernel with python -m spyder_kernel.console on the server and can connect to it. but this opens a ipython console on the server. as soon as I close it, the kernel shuts down. is there a possibilty to start this kernel like \"nohup\" or headless. \ni can do it with jupyter kernel& , but then i'm missing the spyder functionalities like the variable explorer in the IDE.\nthanks for your help !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":262,"Q_Id":55918326,"Users Score":1,"Answer":"python -m spyder_kernels.console& resolved the question !","Q_Score":0,"Tags":"python,ipython,jupyter,spyder","A_Id":55926158,"CreationDate":"2019-04-30T09:51:00.000","Title":"Starting Spyder\/Jupyter Kernel on Server headless","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In need a script or a tool to create a new xcode target, assets folder and info.plist for that target. for existing xcode project without needing to do that manually via xcode","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":55923185,"Users Score":0,"Answer":"I have a project and i need to do the same in order to use it to CI. I need to do it without Xcode.","Q_Score":1,"Tags":"python,ios,ruby,automation,target","A_Id":55923299,"CreationDate":"2019-04-30T14:31:00.000","Title":"How to create new xcode target automatically for existing project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to train a doc2vec model using training data, then finding the similarity of every document in the test data for a specific document in the test data using the trained doc2vec model. However, I am unable to determine how to do this.\nI currently using model.docvecs.most_similar(...). However, this function only finds the similarity of every document in the training data for a specific document in the test data. \nI have tried manually comparing the inferred vector of a specific document in the test data with the inferred vectors of every other document in the test data using model.docvecs.n_similarity(inferred_vector.tolist(), testvectors[i].tolist()) but this returns KeyError: \"tag '-0.3502606451511383' not seen in training corpus\/invalid\" as there are vectors not in the dictionary.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1786,"Q_Id":55924378,"Users Score":1,"Answer":"The act of training-up a Doc2Vec model leaves it with a record of the doc-vectors learned from the training data, and yes, most_similar() just looks among those vectors. \nGenerally, doing any operations on new documents that weren't part of training will require the use of infer_vector(). Note that such inference:\n\nignores any unknown words in the new document\nmay benefit from parameter tuning, especially for short documents\nis currently done just one document at time in a single thread \u2013 so, acquiring inferred-vectors for a large batch of N-thousand docs can actually be slower than training a fresh model on the same N-thousand docs\nisn't necessarily deterministic, unless you take extra steps, because the underlying algorithms use random initialization and randomized selection processes during training\/inference\njust gives you the vector, without loading it into any convenient storage-object for performing further most_similar()-like comparisons\n\nOn the other hand, such inference from a \"frozen\" model can be parallelized across processes or machines. \nThe n_similarity() method you mention isn't really appropriate for your needs: it's expecting lists of lookup-keys ('tags') for existing doc-vectors, not raw vectors like you're supplying.\nThe similarity_unseen_docs() method you mention in your answer is somewhat appropriate, but just takes a pair of docs, re-calculating their vectors each time \u2013 somewhat wasteful if a single new document's doc-vector needs to be compared against many other new documents' doc-vectors.  \nYou may just want to train an all-new model, with both your \"training documents\" and your \"test documents\". Then all the \"test documents\" get their doc-vectors calculated, and stored inside the model, as part of the bulk training. This is an appropriate choice for many possible applications, and indeed could learn interesting relationships based on words that only appear in the \"test docs\" in a totally unsupervised way. And there's not yet any part of your question that gives reasons why it couldn't be considered here.\nAlternatively, you'd want to infer_vector() all the new \"test docs\", and put them into a structure like the various KeyedVectors utility classes in gensim - remembering all the vectors in one array, remembering the mapping from doc-key to vector-index, and providing an efficient bulk most_similar() over the set of vectors.","Q_Score":0,"Tags":"python,machine-learning,gensim,doc2vec","A_Id":55927699,"CreationDate":"2019-04-30T15:36:00.000","Title":"Doc2Vec - Finding document similarity in test data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to train a doc2vec model using training data, then finding the similarity of every document in the test data for a specific document in the test data using the trained doc2vec model. However, I am unable to determine how to do this.\nI currently using model.docvecs.most_similar(...). However, this function only finds the similarity of every document in the training data for a specific document in the test data. \nI have tried manually comparing the inferred vector of a specific document in the test data with the inferred vectors of every other document in the test data using model.docvecs.n_similarity(inferred_vector.tolist(), testvectors[i].tolist()) but this returns KeyError: \"tag '-0.3502606451511383' not seen in training corpus\/invalid\" as there are vectors not in the dictionary.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1786,"Q_Id":55924378,"Users Score":0,"Answer":"It turns out there is a function called similarity_unseen_docs(...) which can be used to find the similarity of 2 documents in the test data. \nHowever, I will leave the question unsolved for now as it is not very optimal since I would need manually compare the specific document with every other document in the test data. Also, it compares the words in the documents instead of the vectors which could affect accuracy.","Q_Score":0,"Tags":"python,machine-learning,gensim,doc2vec","A_Id":55924682,"CreationDate":"2019-04-30T15:36:00.000","Title":"Doc2Vec - Finding document similarity in test data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create an empty list, list=[], it should only include string values. i mean to say when i populate this list, the values should get converted into stings only.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":55924474,"Users Score":0,"Answer":"You could wrap the list in a class with an add method that guards the input","Q_Score":0,"Tags":"python-3.x","A_Id":55924585,"CreationDate":"2019-04-30T15:42:00.000","Title":"How to create an empty list that will only take string values","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a simple python script which can give what kind of operating system it is using. But I want this script to run multiple remote machine at a same time without installing it on other machine on the same network. Is it possible to run this script on remote machine without installing this script on remote machine? . I saw with ssh python can do this .","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":771,"Q_Id":55927505,"Users Score":1,"Answer":"Based on the way your question is worded, I think the answer is no.\nIf you want to run a python script on a remote machine, you will need to have a python interpreter of some kind available on the remote machine to execute the code.","Q_Score":0,"Tags":"python,python-3.x,sockets,ssh","A_Id":55927622,"CreationDate":"2019-04-30T19:25:00.000","Title":"How to run python script on multiple remote machine? without installing 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to run a python program in the online IDE SourceLair. I've written a line of code that simply prints hello, but I am embarrassed to say I can't figure out how to RUN the program. \nI have the console, web server, and terminal available on the IDE already pulled up. I just don't know how to start the program. I've tried it on Mac OSX and Chrome OS, and neither work. \nI don't know if anyone has experience with this IDE, but I can hope. Thanks!!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":63,"Q_Id":55929577,"Users Score":1,"Answer":"Can I ask you why you are using SourceLair?\nWell I just figured it out in about 2 mins....its the same as using any other editor for python.\nAll you have to do is to run it in the terminal. python (nameoffile).py","Q_Score":0,"Tags":"python,ide","A_Id":55929861,"CreationDate":"2019-04-30T22:47:00.000","Title":"How to run a python program using sourcelair?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting strings ex. \"one hundred twenty three\", or \"nine hundred ninety nine\", and encoding it into a sequence of word tokens of length 4 using the Keras text preprocessing tokenizer and using it as my input with 4 nodes, and having many integer classes as my output ex. 0 1 2 ... 1000 with 1001 output nodes with a tensorflow backend.\nI'm using an embedding input layer and then a flatten layer and then a dense output layer with softmax activation to classify the input sequence to a number. \nThis approach works well for numbers from 0-1000 etc. but scaling up to 100,000 numbers with strings like \"eighty seven thousand four hundred twenty three\" proves to be a problem with very long training times as there's 100,000 output neurons.\nIs there a better way to structure the NN for possibly millions of numbers without sacrificing efficiency?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":91,"Q_Id":55931671,"Users Score":0,"Answer":"Maybe you can formulate it as sequence prediction problem using RNN or regression problem with N digit output nodes.","Q_Score":1,"Tags":"python,tensorflow,machine-learning,keras,neural-network","A_Id":55932064,"CreationDate":"2019-05-01T04:38:00.000","Title":"Text sequence to integer with many integer classes in Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Strugging on this problem for a while so finally asking for some help from the experts.\nLanguage: python \nThe problem\/setup:\nI have many clients, client[n], client[n] .. etc\nI have many servers, server[n], server[n] .. etc\nEach server can plugin to 5 external ws connections. At any time I may need to open [x] ws connections; maybe 2, maybe 32, the total ws connections i need, thus servers needed, is dynamic...  \nEach client maybe connecting 1 ws connection from server[1], 1 ws connection from server[2] .. .etc \nHow I imagine the flow working \n\nNew client[1] is loaded, needing 2 ws feeds\nNew client[1] broadcasts [xpub\/xsub ?] message to all servers saying, 'hey, I need these 2 ws connections, who has them?' \nServer[1] with the ws connections reply to client[1] (and only that client) - 'I got what youre looking for, talk to me' \nclient[1] engages in req\/reply communication with server[1] so that client[1] can utilize server[1]'s ws connection to make queries against it, eg, 'hey, server[1] with access to ws[1], can  you request [x]' .. server[1] replies to client[1] 'heres the reply from the ws request you made' \n\ntldr\n\nclients will be having multiple req\/rep with many servers\nservers will be dealing with many clients \nclient need to broadcast\/find appropriate clients to be messaging with","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":375,"Q_Id":55934405,"Users Score":0,"Answer":"I'll focus on the discovery problem.  How do clients know which servers are available and which ws connections each one has?\nOne approach is to add a third type of node, call it broker.  There is a single broker, and all clients and servers know how to reach it.  (Eg, all clients and servers are configured with the broker's IP or hostname.)\nWhen a server starts it registers itself with the broker: \"I have ws feeds x,y,z and accept requests on 1.2.3.5:1234\".  The broker tracks this state, maybe in a hash table.\nWhen a client needs ws feed y, it first contacts the broker:  \"Which server has ws feed y?\"  If the broker knows who has feed y, it gives the client the server's IP and port.  The client can then contact the server directly.  (If multiple servers can access feed y, the broker could return a list of servers instead of a single one.)\nIf servers run for a \"long\" time, clients can cache the \"server X has feed y\" information and only talk to the broker when they need to access a new feed.\nWith this design, clients use the broker to find servers of interest.  Servers don't have to know anything about clients at all.  And the \"real\" traffic (clients accessing feeds via servers) is still done directly between clients and servers - no broker involved.\nHTH.  And for the record I am definitely not an expert.","Q_Score":0,"Tags":"python,sockets,message-queue,zeromq,pyzmq","A_Id":55968720,"CreationDate":"2019-05-01T09:49:00.000","Title":"python zmq many client to many server discovery message patterns","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question about modbus tcp request. There are two options in python for modbus tcp library. Auto_open and Auto_close, these are keep tcp connection open and open\/close tcp connection for each request. Which one should I use? Which one is beneficial for Modbus Tcp devices? What is your suggestions? Thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":55934968,"Users Score":0,"Answer":"it is better to use Auto_close method and close port after each data transmission\nthis help you to connect more than one mocbus\/tcp devices on same port(502).and the connection should be closed when you haven't data for transmitting","Q_Score":0,"Tags":"python,networking,tcp,modbus-tcp","A_Id":56304206,"CreationDate":"2019-05-01T10:43:00.000","Title":"About Modbus TCP request","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to access RDS Instance from AWS Glue, I have a few python scripts running in EC2 instances and I currently use PYODBC to connect, but while trying to schedule jobs for glue, I cannot import PYODBC as it is not natively supported by AWS Glue, not sure how drivers will work in glue shell as well.","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":7319,"Q_Id":55936816,"Users Score":0,"Answer":"If anyone needs a postgres connection with sqlalchemy using python shell, it is possible by referencing the sqlalchemy, scramp, pg8000 wheel files, it's important to reconstruct the wheel from pg8000 by eliminating the scramp dependency on the setup.py.","Q_Score":5,"Tags":"python,amazon-web-services,amazon-rds,aws-glue","A_Id":63319983,"CreationDate":"2019-05-01T13:12:00.000","Title":"How to Connect to RDS Instance from AWS Glue Python Shell?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to access RDS Instance from AWS Glue, I have a few python scripts running in EC2 instances and I currently use PYODBC to connect, but while trying to schedule jobs for glue, I cannot import PYODBC as it is not natively supported by AWS Glue, not sure how drivers will work in glue shell as well.","AnswerCount":6,"Available Count":3,"Score":-0.0333209931,"is_accepted":false,"ViewCount":7319,"Q_Id":55936816,"Users Score":-1,"Answer":"These are the steps that I used to connect to an RDS from glue python shell job:\n\nPackage up your dependency package into an egg file (these package must be pure python if I remember correctly).  Put it in S3.\nSet your job to reference that egg file under the job configuration > Python library path\nVerify that your job can import the package\/module\nCreate a glue connection to your RDS (it's in Database > Tables, Connections), test the connection make sure it can hit your RDS\nNow in your job, you must set it to reference\/use this connection.  It's in the require connection as you configure your job or edit your job.\n\nOnce those steps are done and verify, you should be able to connect.  In my sample I used pymysql.","Q_Score":5,"Tags":"python,amazon-web-services,amazon-rds,aws-glue","A_Id":58142147,"CreationDate":"2019-05-01T13:12:00.000","Title":"How to Connect to RDS Instance from AWS Glue Python Shell?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to access RDS Instance from AWS Glue, I have a few python scripts running in EC2 instances and I currently use PYODBC to connect, but while trying to schedule jobs for glue, I cannot import PYODBC as it is not natively supported by AWS Glue, not sure how drivers will work in glue shell as well.","AnswerCount":6,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":7319,"Q_Id":55936816,"Users Score":2,"Answer":"For AWS Glue use either Dataframe\/DynamicFrame and specify the SQL Server JDBC driver. AWS Glue already contain JDBC Driver for SQL Server in its environment so you don't need to add any additional driver jar with glue job. \ndf1=spark.read.format(\"jdbc\").option(\"driver\", \"com.microsoft.sqlserver.jdbc.SQLServerDriver\").option(\"url\", url_src).option(\"dbtable\", dbtable_src).option(\"user\", userID_src).option(\"password\", password_src).load()\nif you are using a SQL instead of table:\ndf1=spark.read.format(\"jdbc\").option(\"driver\", \"com.microsoft.sqlserver.jdbc.SQLServerDriver\").option(\"url\", url_src).option(\"dbtable\", (\"your select statement here\") A).option(\"user\", userID_src).option(\"password\", password_src).load()\nAs an alternate solution you can also use jtds driver for SQL server in your python script running in AWS Glue","Q_Score":5,"Tags":"python,amazon-web-services,amazon-rds,aws-glue","A_Id":55957809,"CreationDate":"2019-05-01T13:12:00.000","Title":"How to Connect to RDS Instance from AWS Glue Python Shell?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a test case needed to access a .sh file. I used \nRun Process   ${filename},but it threw the error OSError: [Errno 13] Permission denied .  I tried to put chomod 777 before Run Process, but robot could not recognize it and robot took it as part of file path. Robot Anyone could help?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":676,"Q_Id":55938777,"Users Score":3,"Answer":"When you trying to run external commands via the  Run process  keyword,you have missed tab space.\nRun process   chmod   -R     777    yourfileName","Q_Score":0,"Tags":"python,automated-tests,robotframework","A_Id":55945288,"CreationDate":"2019-05-01T15:35:00.000","Title":"How to give .sh file read and write permission while use command \"run process\" in 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":0},{"Question":"I'm new to Docker and I'm trying to figure out if there's a way to accomplish the next scenario: \n1. Python and all necessary packages installed on a docker container.\n2. My code editor is running on my local machine.\n3. When the script is changed, the container will re-run the script and give me the output. \nThe point is that I don't want to rebuild the image and rerun the container after every change I'll make.\nI just want to write the code \"locally\" and execute it as fast as possible in a container which running python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":55940125,"Users Score":0,"Answer":"A simple method:\n1. Create a Dockerfile that EXPOSE the correct ports and installs the correct system and python packages\n2. Specify the container command to be something like a RUN sleep 3600 or RUN tail -f \/dev\/null to keep the container running\n3. Run the Docker container with a volume mount to your code directory  \nYou can edit your code with your local editor and run your tests with docker exec","Q_Score":0,"Tags":"python,docker","A_Id":55941056,"CreationDate":"2019-05-01T17:27:00.000","Title":"Development environment for python scripts using docker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to read a csv file just after running server. It can't be done in any view because it need to be preload to execute all views, so I need to do it immediately after \"manage.py runserver\". Is there any file where I can write the code that I need to execute in first place?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3300,"Q_Id":55940630,"Users Score":-1,"Answer":"Just add that script in settings.py file. Because settings.py file of those files which are executed prior to views.py file","Q_Score":0,"Tags":"python,django,python-3.x","A_Id":55940662,"CreationDate":"2019-05-01T18:08:00.000","Title":"How to execute code automatically after manage.py runserver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using a python script within ROS. Ros uses python 2.7 and the version of scipy that I'm using is 0.19.1.\nThe following error is reported:\nfrom scipy.spatial.transform import Rotation as R\n    ImportError: No module named transform","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":11819,"Q_Id":55941290,"Users Score":-2,"Answer":"Working on python 3.7.3. Make sure it's available on 2.7","Q_Score":0,"Tags":"python,scipy,scipy-spatial","A_Id":55941809,"CreationDate":"2019-05-01T19:02:00.000","Title":"Scipy ImportError: No module named transform","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Recently I have been working on an assignment to convert five file formats (.dae, .stl, .step, igs, obj) to .stl. using FreeCAD Python console and help from people on StackOverflow and FreeCAD forum, I was able to do that. \nThe last part of this assignment is to convert .sldprt (Solidworks Parts File) to .stl. Unfortunately, FreeCAD does not support importing this file format and I can not use its Python console to convert this file format to .stl. \nI have been searching Python APIs that can read\/export .sldprt files but I haven't been able to find any. I did find some online sources (GradCAD, Datakit Cross manager etc.) but I need to accomplish this by a Python script (preferably Python 2).\nIs there another way I can convert .sldprt file to .stl using Python? Can someone point me in the right direction where to start?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3169,"Q_Id":55941384,"Users Score":4,"Answer":"Since sldprt is a proprietary format, you are only able to do that if SOLIDWORKS is installed on the executing machine. This is done with the SOLIDWORKS API. With that condition out of the way, you will need to write some sort of bridge between Python and the SOLIDWORKS COM API objects which is a big hassle. If this is a school assignment, I would suggest you write a console application in C# or VB.NET that opens the file and converts it to whatever target format. You can command that application from your Python program.\nThere are a bunch of cloud services that can do CAD files conversion. Those can be a good alternative if you can't afford a SOLIDWORKS license or don't have access to one.","Q_Score":4,"Tags":"python,solidworks,stl-fileformat","A_Id":55943185,"CreationDate":"2019-05-01T19:10:00.000","Title":"Convert .sldprt file to .stl using Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement clipped PPO algorithm for classical control task like keeping room temperature, charge of battery, etc. within certain limits. So far I've seen the implementations in game environments only. My question is the game environments and classical control problems are different when it comes to the implementation of the clipped PPO algorithm? If they are, help and tips on how to implement the algorithm for my case are appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":878,"Q_Id":55943678,"Users Score":2,"Answer":"I'm answering your question from a general RL point of view, I don't think the particular algorithm (PPO) makes any difference in this question.\nI think there is no fundamental differences, both can be seen as discrete control problems. In a game you observe the state, then choose an action and act according to it, and receive reward an the observation of the subsequent state.\nNow if you take a simple control problem, instead of a game you probably have a simulation (or just a very simple dynamic model) that describes the behavior of your problem. For example the equations of motion for an inverted pendulum (another classical control problem). In some case you might directly interact with the real system, not a model of it, but this is rare as it can be really slow, and the typical sample complexities of RL algorithms make learning on a real (physical) system less practical.\nEssentially you interact with the model of your problem just the same way as you do with a game: you observe a state, take an action and act, and observe the next state. The only difference is that while in games reward is usually pre-defined (some score or goal state), probably you need to define the reward function for your problem. But again, in many cases you also need to define rewards for games, so this is not a major difference either.","Q_Score":1,"Tags":"python,keras,reinforcement-learning","A_Id":55948320,"CreationDate":"2019-05-01T22:51:00.000","Title":"How to implement Proximal Policy Optimization (PPO) Algorithm for classical control problems?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Python+Selenium to scrape data from a site which lists companies' info.\nFor each company I need 2 data points - email and url.\nThe problem is - for some companies email is not indicated and if I separately get a list of urls and emails I won't be able to fit the pairs (list of emails will be shorter than list of url and I won't know which of the emails is missing).\nSo I thought maybe there is a way to get root elements of each of the companies' blocks (say, it is div with class \"provider\") and then search inside each of them for email and url.\nIs it possible and if yes - how?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":306,"Q_Id":55943694,"Users Score":1,"Answer":"Ok, I found the solution.\nFirst you collect all the blocks with fields you need to get. Example:\nproviders = browser.find_elements_by_class_name('provider-row')\nAnd then you use find_elements_by_xpath() method with locator starting with \".\/\/\" which means search inside a specific element. Example:\nproviders[0].find_elements_by_xpath(\".\/\/li[@class='website-link website-link-a']\/a[@class='sl-ext']\")","Q_Score":1,"Tags":"python,selenium","A_Id":55944216,"CreationDate":"2019-05-01T22:54:00.000","Title":"Selenium+Python. How to locate several elements within a specific element?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently developing HTTP Rest API server using Flask. I don't have any static media, and all url are being served by @app.route pattern in Flask Framework. Can Flask run on Gunicorn alone with out webserver?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":473,"Q_Id":55949849,"Users Score":1,"Answer":"Flask - logic to respond to HTTP request\ngunicorn - Helps manage concurrency for these HTTP requests, logging, worker timeouts\nnginx - scalability and protection. If the load for your application is higher, Nginx would help for load balancing without crashing your Application Server, helps to serve static content if any\n\nSo if load for your application is less and no static content to serve, in my opinion, flask + gunicorn should be OK.","Q_Score":1,"Tags":"python,flask,webserver,gunicorn,wsgi","A_Id":57334871,"CreationDate":"2019-05-02T09:53:00.000","Title":"Can flask rest api application can run on gunicorn alone?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a pretrained keras model that has output with dimesion of [n, 4000] (It makes the classification on 4000 classes).\nI need to make a prediction on the test data (300K observations).\nBut when I call method model.predict(X_train), I get an run-out memory error, because I don't have enough RAM to store matrix with shape (300K , 4000).\nTherefore, it would be logical to convert the model output to a sparse matrix.\nBut wrapping the predict method into scipy function sparse.csr_matrix does not work (sparse.csr_matrix(model.predict(X_train))), because it first allocates space in the RAM for the prediction, and only then it converts into the sparse matrix.\nI can also make a prediction on a specific batch of test data, and then convert it using forloop.\nBut it seems to me that this is not optimal and very resource-consuming way.\nPlease give me advice, can there be any other methods for converting the model output into a sparse matrix?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":261,"Q_Id":55950909,"Users Score":0,"Answer":"Isn't there a batch_size parameter in the predict()?\nIf I get it correct the n means number of sample right?\nAssume that you system ram is enough to hold the entire data but the VRAM is not.","Q_Score":3,"Tags":"python,tensorflow,machine-learning,keras","A_Id":55953034,"CreationDate":"2019-05-02T10:56:00.000","Title":"Convert Keras model output into sparse matrix without forloop","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an Airflow DAG which creates an EMR cluster, then runs SSHOperator tasks on that cluster. Right now, I am hard coding the Master public DNS for the EMR cluster into an Airflow SSH connection. Is there a way for my DAG to dynamically populate this DNS when the EMR cluster is created so I don't have to manually update the connection?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":822,"Q_Id":55956160,"Users Score":2,"Answer":"After a bit more digging into the Airflow CLI I found it is possible to create\/ delete new connections. I've added a bash operator after building the EMR cluster to add an Airflow connection. \nairflow connections --delete --conn_id aws_emr\nairflow connections --add --conn_id aws_emr --conn_type SSH --conn_host publicDNS --conn_login username --conn_extra {\"key_file\":\"file.pem\"}","Q_Score":2,"Tags":"python,airflow","A_Id":55956774,"CreationDate":"2019-05-02T15:55:00.000","Title":"Dynamic Airflow EMR Connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to use Microsoft's Machine Learning Services in SQL SERVER 2016, specifically to leverage Python, NOT R.\nIs it possible?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":73,"Q_Id":55956728,"Users Score":2,"Answer":"To add to @DMellons answer; Java is supported in SQL 2019 and up. So:\n\nSQL 2016: R \nSQL 2017: R, Python \nSQL 2019: R, Python, Java, more languages may come.","Q_Score":0,"Tags":"python,machine-learning,sql-server-2016","A_Id":55957245,"CreationDate":"2019-05-02T16:32:00.000","Title":"Can you use Python with MS Machine Learning in SQL SERVER 2016","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My SQS is supposed to trigger a Lambda function once. It seems to trigger it repeatedly and I cannot find the cause.\nHere's how the system works:\n\nFile is uploaded to S3 bucket (we'll call it uploaded-docs).\nUploading a file to uploaded-docs\/input\/ triggers an event on the bucket, called FileUploaded.\nEvent FileUploaded triggers a Lambda function called ProcessUploadedFile.\nProcessUploadeFile calls Textract to analyze a document. The output of said Textract process is published (when finished) to an SNS Topic called TextractComplete.\nTextractComplete has one subscription, the SQS called TextractOutputQueue.\nTextractOutputQueue triggers a Lambda function called GetOutput. It's only supposed to run once for each file uploaded\n\nI've noticed that when a file is uploaded, GetOutput is called over and over on the file and Task timed out after 3 seconds (Textract's GetDocumentTextDetection command called via boto3) can be found in the logs until it finally exceeds.\nI also noticed that when a new file is uploaded, all the files in the bucket are called again in this process.\nSome hypotheses:\n\nThe SQS queue items aren't being \"consumed\", such that they still exist in the queue after calling their respective Lambda functions, and because they still exist, they keep invoking the function.\nThe Lambda GetOutput is stuck in some sort of retry loop, and every time it times out, it calls the entire function again. This doesn't explain why the logs will be dead until I upload another document, and all the previously-uploaded documents enter the loop again somehow.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1110,"Q_Id":55958046,"Users Score":2,"Answer":"Thanks to all that commented, it was a very simple fix. Just increase the timeout of GetOutput to 10 seconds and the issue stopped.","Q_Score":2,"Tags":"python-3.x,amazon-web-services,aws-lambda,amazon-sqs","A_Id":55959036,"CreationDate":"2019-05-02T18:13:00.000","Title":"SQS triggers Lambda function over and over again, why?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Problem Solved - Thanks to everyone who invested his\/her time in looking after it.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":33,"Q_Id":55958060,"Users Score":1,"Answer":"You have two URLs pointing to the same view. Only smaakjes_list will ever be called; it does not pass a list (or any variables at all). index will never ever be used.\nI'm not sure why you have done this. Give your views separate URLs. Or just delete the smaakjes_list view and its corresponding URL pattern.","Q_Score":0,"Tags":"django,python-3.x,for-loop,django-templates,django-views","A_Id":55958113,"CreationDate":"2019-05-02T18:14:00.000","Title":"How do we pass values - from a list in views.py - to html","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When a number is long in my excel document, Excel formats the cell value to scientific notation (ex 1.234567e+5) while the true number still exists in the formula bar at the top of the document (ex 123456789012).\nI want to convert this number to a string for my own purposes, but when I do, the scientific notation is captured, rather than the true number. How can I assure that it's the true number that is being converted to a string?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":696,"Q_Id":55959512,"Users Score":0,"Answer":"Python will ignore the formatting that Excel uses for anything other than dates and times, so you should just be able to convert the number to a string. You will, however, be limited by Excel's precision. The OOXML file format is not suitable for some tasks notably those with historical dates or high precision times.","Q_Score":0,"Tags":"python,openpyxl","A_Id":55969896,"CreationDate":"2019-05-02T20:06:00.000","Title":"Removing scientific-notation from number in openpyxl","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"is there a way to refer to a specific column relative to a specific data frame in python like there is in R (data.frame$data)?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":55962891,"Users Score":0,"Answer":"You can generally use pandas to mimic R. You can use [] as below.\nmy_column = df['columnName']","Q_Score":1,"Tags":"r,python-3.x","A_Id":55963728,"CreationDate":"2019-05-03T03:22:00.000","Title":"$ in R... What is the equivalent in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"is there a way to refer to a specific column relative to a specific data frame in python like there is in R (data.frame$data)?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":55962891,"Users Score":1,"Answer":"Usually with [] => data.frame[\"data\"]\nOr for object like with . => data.frame.data","Q_Score":1,"Tags":"r,python-3.x","A_Id":55962898,"CreationDate":"2019-05-03T03:22:00.000","Title":"$ in R... What is the equivalent in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating an Azure function (python) that reads pickle file from Azure Blob Storage. I am using BlockBlobService for this purpose and its working fine in Spyder. However, when i tried to implement same approach in Azure function, its not working. What could be the reasons for this issue? Is it so because BlockBlobService is not available in Azure functions (python preview)? What could be the alternatives to it?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":430,"Q_Id":55965641,"Users Score":1,"Answer":"Did you include a 'requirements.txt' file? You can run this code in the directory before deploying to Azure: \npip freeze >> requirements.txt","Q_Score":0,"Tags":"python,azure,azure-functions,azure-blob-storage","A_Id":56048388,"CreationDate":"2019-05-03T08:05:00.000","Title":"Is it possible to use BlockBlobService in Azure Functions (python)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have come across a peculiar situation when preprocessing data.\nLet's say I have a dataset A. I split the dataset into A_train and A_test. I fit the A_train using any of the given scalers (sci-kit learn) and transform A_test with that scaler. Now training the neural network with A_train and validating on A_test works well. No overfitting and performance is good.\nLet's say I have dataset B with the same features as in A, but with different ranges of values for the features. A simple example of A and B could be Boston and Paris housing datasets respectively (This is just an analogy to say that features ranges like the cost, crime rate, etc vary significantly ). To test the performance of the above trained model on B, we transform B according to scaling attributes of A_train and then validate. This usually degrades performance, as this model is never shown the data from B.\nThe peculiar thing is if I fit and transform on B directly instead of using scaling attributes of A_train, the performance is a lot better. Usually, this reduces performance if I test this on A_test. In this scenario, it seems to work, although it's not right.\nSince I work mostly on climate datasets, training on every dataset is not feasible. Therefore I would like to know the best way to scale such different datasets with the same features to get better performance.\nAny ideas, please.\nPS: I know training my model with more data can improve performance, but I am more interested in the right way of scaling. I tried removing outliers from datasets and applied QuantileTransformer, it improved performance but could be better.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1123,"Q_Id":55969460,"Users Score":0,"Answer":"One possible solution could be like this.\n\nNormalize (pre-process) the dataset A such that the range of each features is within a fixed interval, e.g., between [-1, 1]. \nTrain your model on the normalized set A.\nWhenever you are given a new dataset like B: \n\n(3.1.) Normalize the new dataset such that the feature have the same range as they have in A ([-1, 1]).\n(3.2) Apply your trained model (step 2) on the normalized new set (3.1).\n\nAs you have a one-to-one mapping between set B and its normalized version, then you can see what is the prediction on set B, based on predictions on normalized set B.\n\nNote you do not need to have access to set B in advance (or such sets if they are hundreds of them). You normalize them, as soon as you are given one and you want to test your trained model on it.","Q_Score":0,"Tags":"python,scikit-learn,neural-network,preprocessor,feature-scaling","A_Id":55970210,"CreationDate":"2019-05-03T12:05:00.000","Title":"Best way to scale across different datasets","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to upgrade the pyzmq (17.0.0) library in Google Colaboratory to a newer version. I used the command !pip install pyzmq, which installs the latest pyzmq version (18.0.1). Then, I have to restart the runtime to be able to use the newly installed version, but I cannot reconnect to the runtime after that. Do you know why is this happening and how I can fix it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":55969773,"Users Score":0,"Answer":"pyzmq is used in the operation of the backend, so it's possible that the upgrade introduces an incompatibility with the Colab plumbing.\nAs a work-around, I'd recommend installing pyzmq and whatever library requires the upgrade in a virtualenv in order to isolate it from the system Python used by Colab.","Q_Score":0,"Tags":"python,google-colaboratory,pyzmq","A_Id":55973115,"CreationDate":"2019-05-03T12:24:00.000","Title":"Cannot upgrade pyzmq on Google Colaboratory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run tensorboard in jupyter using the latest tensorflow 2.0.0a0. \nWith the tensorboard version 1.13.1, and python 3.6. \nusing \n...\n%tensorboard --logdir {logs_base_dir}\nI get the error :\nUsageError: Line magic function %tensorboard not found\nDo you have an idea what the problem could be? It seems that all versions are up to date and the command seems correct too. \nThanks","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":25713,"Q_Id":55970686,"Users Score":0,"Answer":"extension loading is required before. You can try -> %load_ext tensorboard \n.It worked for me. I am using TensorFlow 1.>","Q_Score":35,"Tags":"python,tensorflow,tensorflow2.0,tensorboard,tensorflow2.x","A_Id":61309357,"CreationDate":"2019-05-03T13:20:00.000","Title":"Tensorboard not found as magic function in jupyter","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run tensorboard in jupyter using the latest tensorflow 2.0.0a0. \nWith the tensorboard version 1.13.1, and python 3.6. \nusing \n...\n%tensorboard --logdir {logs_base_dir}\nI get the error :\nUsageError: Line magic function %tensorboard not found\nDo you have an idea what the problem could be? It seems that all versions are up to date and the command seems correct too. \nThanks","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":25713,"Q_Id":55970686,"Users Score":0,"Answer":"That's how I solved it\n%load_ext tensorboard\n%tensorboard --logdir \/content\/drive\/MyDrive\/Dog\\ Vision\/logs\nAfter --logdir, this is my path directory \/content\/drive\/MyDrive\/Dog\\ Vision\/logs. It should be different for you.","Q_Score":35,"Tags":"python,tensorflow,tensorflow2.0,tensorboard,tensorflow2.x","A_Id":72496748,"CreationDate":"2019-05-03T13:20:00.000","Title":"Tensorboard not found as magic function in jupyter","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing web applications, APIs, and backends using the Django MVC framework. A major aspect of Django is its implementation of an ORM for models. It is an exceptionally good ORM. Typically when using Django, one utilizes an existing interface that maps one's Django model to a specific DBMS like Postgres, MySQL, or Oracle for example.\nI have some specific needs, requirements regarding performance and scalability, so I really want to use AWS's Dynamo DB because it is highly cost efficient, very performant, and scales really well.\nWhile I think Django allows one to implement their own interface for a DBMS if one wishes to do so, it is clearly advantageous to be able to use an existing DBMS interface when constructing one's Django models if one exists.\nCan someone recommend a Django model interface to use so I can construct a model in Django that uses AWS's Dynamo DB?\nHow about one using MongoDB?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":17688,"Q_Id":55976471,"Users Score":1,"Answer":"DynamoDB is non-relational which I think makes it architecturally incompatible with an ORM like Django's.","Q_Score":13,"Tags":"python,django,orm,nosql,amazon-dynamodb","A_Id":61207563,"CreationDate":"2019-05-03T20:08:00.000","Title":"How can I use AWS's Dynamo Db with Django?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am developing web applications, APIs, and backends using the Django MVC framework. A major aspect of Django is its implementation of an ORM for models. It is an exceptionally good ORM. Typically when using Django, one utilizes an existing interface that maps one's Django model to a specific DBMS like Postgres, MySQL, or Oracle for example.\nI have some specific needs, requirements regarding performance and scalability, so I really want to use AWS's Dynamo DB because it is highly cost efficient, very performant, and scales really well.\nWhile I think Django allows one to implement their own interface for a DBMS if one wishes to do so, it is clearly advantageous to be able to use an existing DBMS interface when constructing one's Django models if one exists.\nCan someone recommend a Django model interface to use so I can construct a model in Django that uses AWS's Dynamo DB?\nHow about one using MongoDB?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":17688,"Q_Id":55976471,"Users Score":0,"Answer":"There is no Django model interface for AWS DynamoDB, but you may retrieve data from that kind of db using boto3 software provided by AWS.","Q_Score":13,"Tags":"python,django,orm,nosql,amazon-dynamodb","A_Id":58988747,"CreationDate":"2019-05-03T20:08:00.000","Title":"How can I use AWS's Dynamo Db with Django?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am developing web applications, APIs, and backends using the Django MVC framework. A major aspect of Django is its implementation of an ORM for models. It is an exceptionally good ORM. Typically when using Django, one utilizes an existing interface that maps one's Django model to a specific DBMS like Postgres, MySQL, or Oracle for example.\nI have some specific needs, requirements regarding performance and scalability, so I really want to use AWS's Dynamo DB because it is highly cost efficient, very performant, and scales really well.\nWhile I think Django allows one to implement their own interface for a DBMS if one wishes to do so, it is clearly advantageous to be able to use an existing DBMS interface when constructing one's Django models if one exists.\nCan someone recommend a Django model interface to use so I can construct a model in Django that uses AWS's Dynamo DB?\nHow about one using MongoDB?","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":17688,"Q_Id":55976471,"Users Score":2,"Answer":"You can try Dynamorm or pynamoDB. I haven't tried them maybe they can help.","Q_Score":13,"Tags":"python,django,orm,nosql,amazon-dynamodb","A_Id":62535835,"CreationDate":"2019-05-03T20:08:00.000","Title":"How can I use AWS's Dynamo Db with Django?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm new to kubernetes and I'm setting up some test environments to do some experiments with in minikube. So I have two pods running python, connected trough a service (I verified that they are selected trough the same service). \nI want to open a socket connection between the two. The container ip is equal to the IP specified in the service. On Pod1 I create the socket and connect to localhost and the port belonging to the container. \nI'm not sure whether I should actually connect to localhost or the name of the service. Then on the other pod (Pod2) I connect to the name of the service (if I understand correctly the service should exposes the IP with the name that corresponds to the service name). \nPod2 refuses to connect to Pod1 in the aforementioned configuration. \nIf I let Pod1 create a socket with as IP address the service name I get the \"Cannot assign requested address\" on socket creation.\nSo I think I'm just choosing the IP address wrongly.\nThanks in advance","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1269,"Q_Id":55977340,"Users Score":0,"Answer":"In Kubernetes, it is difficult to have always the IP address of a given POD. A pretty solution consists in making your application binding to 0.0.0.0 (this means you application will listen on all local interfaces including the Pod primary interface).\nThen you can expose you application running in that Pod using a Kubernetes service.","Q_Score":0,"Tags":"python,docker,sockets,kubernetes","A_Id":67442922,"CreationDate":"2019-05-03T21:32:00.000","Title":"What IP to bind to python socket in Kubernetes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am wondering how to go about visualization of my frozen graph def. I need it to figure out my tensorflow networks input and output nodes. I have already tried several methods to no avail, like the summarize graph tool. Does anyone have an answer for some things that I can try? I am open to clarifying questions, thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":221,"Q_Id":55977680,"Users Score":0,"Answer":"You can try to use TensorBoard. It is on the Tensorflow website...","Q_Score":0,"Tags":"python,tensorflow,tensorboard","A_Id":55977698,"CreationDate":"2019-05-03T22:13:00.000","Title":"Visualizing a frozen graph_def.pb","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need a recommendation from gurus out there on how to go about setting up a modeling application. I have thousands of scenarios to run on thousands for contracts for cash flow projections. Assuming I have 1000 scenarios and 1000 contracts I would need to run 1,000,000 projections (1000x1000). I'd like to do this in parallel using dask, ray or some other method. My data are in dataframes but I'm open to better suggestions. I can create 2 loops (scenario,contract) for each run but this would be sequential.\nScenario1 w Contract1\nScenario1 w Contract2\nScenario1 w Contract3\n.\n.\n.\nScenario1000 w Contract1000\nI'd like to distribute compute to multiple processor and multiple servers.\nI'll save my question on the inner loop projections where I have to run 100 scenario projections at each time step of the 1,000,000 runs for next time.\nAny suggestion to point me in the right direction would help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":55977829,"Users Score":0,"Answer":"From a simple conceptual perspective:\n\nWrite yourself a function that takes a contract and a scenario as parameters and performs the desired calculation\nUse Python's multiprocessing to set up a worker pool\nCreate a Queue (from multiprocessing package) that is to be shared across workers\nFill the queue with all combinations (might be a good idea to use fixed indices and only push a tuple of the contract\/scenario indices (C, S) to the queue to reduce required space\nMap your function to the worker pool given the queue\n\nThere are more elaborate ways to do this (including amqp\/celery\/...) depending whether you want to distribute tasks across multiple machines or just to all of your locally available cores. This simple concept should contain all required keywords to build your first local multiprocessing on your own!","Q_Score":0,"Tags":"python,pandas,parallel-processing,dask","A_Id":55978184,"CreationDate":"2019-05-03T22:33:00.000","Title":"Need setup recommendation for parallel processing many contracts through many scenarios","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using the library node2vec, which is based on gensim word2vec model to encode nodes in an embedding space, but when i want to fit the word2vec object I get this warning:\n\nC:\\Users\\lenovo\\Anaconda3\\lib\\site-packages\\gensim\\models\\base_any2vec.py:743:\n  UserWarning: C extension not loaded, training will be slow. Install a\n  C compiler and reinstall gensim for fast training.\n\nCan any one help me to fix this issue please ?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":8850,"Q_Id":55978013,"Users Score":0,"Answer":"I've faced this issue for a long time when I was running W2V Models which requires 'gensim'.\nFirst of all I've installed Anaconda Navigator and then installed required packages using pip.\nI've installed gensim manually using pip in cmd. When I run the W2V model, it took 40 min to train and give the result, which made me annoying and wasted a lot of time.\nThis problem got solved now. I just did what the warning showed. I've uninstalled gensim from my computer. Prior to that I've already created a system path of mingw-w64 in the environment variable which is an environment for c,c++ etc., programs. Later, I've reinstalled gensim using 'pip install gensim'.\nNow the program is running within seconds which made a drastic change in the execution time.\nHope this helps...","Q_Score":5,"Tags":"python-3.x,jupyter-notebook,anaconda,gensim,word2vec","A_Id":58553910,"CreationDate":"2019-05-03T23:01:00.000","Title":"How to fix 'C extension not loaded, training will be slow. Install a C compiler and reinstall gensim for fast training.'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using the library node2vec, which is based on gensim word2vec model to encode nodes in an embedding space, but when i want to fit the word2vec object I get this warning:\n\nC:\\Users\\lenovo\\Anaconda3\\lib\\site-packages\\gensim\\models\\base_any2vec.py:743:\n  UserWarning: C extension not loaded, training will be slow. Install a\n  C compiler and reinstall gensim for fast training.\n\nCan any one help me to fix this issue please ?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":8850,"Q_Id":55978013,"Users Score":1,"Answer":"anaconda prompt\nconda update conda-build\n==\nwindows 7 (32bit)\npython 3.7.3\nconda-build 3.18.5\ngensim 3.4.0","Q_Score":5,"Tags":"python-3.x,jupyter-notebook,anaconda,gensim,word2vec","A_Id":56800565,"CreationDate":"2019-05-03T23:01:00.000","Title":"How to fix 'C extension not loaded, training will be slow. Install a C compiler and reinstall gensim for fast training.'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using the library node2vec, which is based on gensim word2vec model to encode nodes in an embedding space, but when i want to fit the word2vec object I get this warning:\n\nC:\\Users\\lenovo\\Anaconda3\\lib\\site-packages\\gensim\\models\\base_any2vec.py:743:\n  UserWarning: C extension not loaded, training will be slow. Install a\n  C compiler and reinstall gensim for fast training.\n\nCan any one help me to fix this issue please ?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":8850,"Q_Id":55978013,"Users Score":1,"Answer":"For me, degrading back to Gensim version 3.7.1 from 3.7.3 worked.","Q_Score":5,"Tags":"python-3.x,jupyter-notebook,anaconda,gensim,word2vec","A_Id":56666561,"CreationDate":"2019-05-03T23:01:00.000","Title":"How to fix 'C extension not loaded, training will be slow. Install a C compiler and reinstall gensim for fast training.'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a web application that contains calculators for various industries. I am using html and css for the layout(color, size, etc). However, the core funtionality like arithmetic operations will be done using pure python programming and not javascript. So I will have html, css, and python files. Question is - how can I link my python file to html?","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":16626,"Q_Id":55978136,"Users Score":0,"Answer":"You can use Brython\n\nBrython is designed to replace Javascript as the scripting language for the Web. As such, it is a Python 3 implementation (you can take it for a test drive through a web console), adapted to the HTML5 environment, that is to say with an interface to the DOM objects and events.","Q_Score":1,"Tags":"python,html,css,web-applications","A_Id":65466066,"CreationDate":"2019-05-03T23:19:00.000","Title":"Integrating html, css, and python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For example when importing CIFAR-10 from Keras (using from keras.datasets import cifar10\n(x_train, y_train), (x_test, y_test) = cifar10.load_data())\n or temporarily installing a package like HAZM (Persian form of NLTK) using !pip install hazm which is not pre-installed on Google Colab, the cell containing the import statement starts to download the material it needs. I want to know if my internet traffic is used in the downloading process, or it happens on Google cloud servers and my internet connection is used only to run the code?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2643,"Q_Id":55980568,"Users Score":7,"Answer":"It happens on Google cloud servers and your internet connection is used only to run the code.\nI tried downloading some huge dataset using wget and my internet data wasnt affected by it.","Q_Score":3,"Tags":"python,python-3.x,google-colaboratory,python-module","A_Id":61169238,"CreationDate":"2019-05-04T07:45:00.000","Title":"Does Google Colab use my internet traffic while downloading a dataset or importing a new package into colab notebook?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would know if it's possible to unload a image after use.\nIn fact, I load a lot of image for the main, for the settings, the game and creadits too.\nBut there are image useful in a part but completely useless in the three others. I mean for 90%, they are useful in only 1 part.\nSo, I wonder if exist a way to delete the image from the memory of the program, and by the way make it less heavy...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":359,"Q_Id":55981326,"Users Score":2,"Answer":"The garbage collector will do it automatically when there are not anymore references to the images.\nFor example, say you have myimage = pygame.image.load('path\/to\/image). If at some point you set myimage = None and you do not have any other reference to that image, the garbage collector will free the memory.\nOf course you can also do del myimage. The del statement will delete the reference immediately (but not the object itself).\nIf your game is properly designed (with classes, functions) it's very likely that the garbage collector is already doing its work and you do not need to take care of deleting things.","Q_Score":2,"Tags":"python,pygame","A_Id":55981594,"CreationDate":"2019-05-04T09:51:00.000","Title":"Pygame : Is it possible to unload a image for save memory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Changing url(r'', include('application.urls')) to url(r'^store\/', include('application.urls')) causes login redirect url to fail from checkout from cart as anonymous user. \nI have included LOGIN_REDIRECT_URL = '\/store\/accounts\/' in settings.py. \nThis fixes the direct login redirect url.\nHowever if an anonymous user tries to add product to cart, it is supposed to redirect to login page \/store\/accounts\/login\/?next=\/store\/checkout\/ but it redirects to \/accounts\/login\/?next=\/store\/checkout\/.\nWhat is the workaround to fix this without breaking anything?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":205,"Q_Id":55981654,"Users Score":2,"Answer":"LOGIN_URL = '\/store\/accounts\/login\/'\nAdding this line in settings.py fixed the problem.","Q_Score":0,"Tags":"python,django,e-commerce,django-oscar","A_Id":55981688,"CreationDate":"2019-05-04T10:34:00.000","Title":"How to fix Django Oscar application.urls, when changed to custom path (\/store) breaks login redirect link from checkout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to do stereo vision and finally find the real distance to the objects from cameras. I have done image rectification.Now I want to calculate disparity. My question is, to do disparity, do I need to rectify images first? Thank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":55982564,"Users Score":0,"Answer":"Yes, disparity needs rectified images. Since the stereo matching is done with epipolar lines, rectified images ensure that all the distortions are rectified and hence the algorithm can search blocks in a straight line. For a basic level you can try out StereoBM provided by openCV using the recitified stereo image pair.\nRaw frames from camera -> Rectification -> Disparity map -> Depth perception. \nThis will be the pipeline for any passive stereo camera.","Q_Score":0,"Tags":"python-3.x,opencv,stereo-3d,disparity-mapping","A_Id":55984404,"CreationDate":"2019-05-04T12:35:00.000","Title":"previous steps before to calculate disparity? Is rectification needed?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python and to train myself, I would like to use Python build a database that would store information about wine - bottle, date, rating etc. The idea is that:\n\nI could use to database to add a new wine entries\nI could use the database to browse wines I have previously entered\nI could run some small analyses\n\nThe design of my Python I am thinking of is: \n\nDesign database with Python package sqlite3\nMake a GUI built on top of the database with the package Tkinter, so that I can both enter new data and query the database if I want.\n\nMy question is: would your recommend this design and these packages? Is it possible to build a GUI on top of a database? I know StackOverflow is more for specific questions rather than \"project design\" questions so I would appreciate if anyone could point me to forums that discuss project design ideas.\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2745,"Q_Id":55985778,"Users Score":0,"Answer":"If it's just for you, sure there is no problem with that stack.\nIf I were doing it, I would skip Tkinter, and build something using Flask (or Django.) Doing a web page as a GUI yields faster results, is less fiddly, and more applicable to the job market.","Q_Score":0,"Tags":"python,database,sqlite,user-interface","A_Id":55985903,"CreationDate":"2019-05-04T18:47:00.000","Title":"Python: how to create database and a GUI together?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a typo on a variable in my script. Unfortunately, I did not see it before I began debugging.\nAfter 20 minutes of runtime, the script reached the piece of code with the misnamed variable, and it raised an ValueError Exception, which was break into.\nUsing the console, I can reassign the value to the variable, this time with its proper name. However, after an exception is raised, it seems there's no way around to continue execution. Is this true? \nIs there any method of forcing\/bypassing a particular uncaught exception breakpoint so I don't have to restart my script and wait 20 minutes all over again just because of a typo?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":520,"Q_Id":55986320,"Users Score":2,"Answer":"It sounds like you want to somehow suppress the exception mid-raise to allow continued execution by pretending the exception never occurred. If that's correct then the answer is no as Python doesn't provide a way to do this.","Q_Score":2,"Tags":"python,visual-studio-code","A_Id":56193415,"CreationDate":"2019-05-04T19:57:00.000","Title":"Is there any way to continue execution on a raised unforeseen exception in vscode debugger?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some trubble reading with pandas a csv file which include the special character '\u0153'.\nI've done some reseach and it appears that this character has been added to the ISO 8859-15 encoding standard.\nI've tried to specify this encoding standard to the pandas read_csv methods but it doesn't properly get this special character (I got instead a '\u2610') in the result dataframe :\ndf= pd.read_csv(my_csv_path, \";\", header=None, encoding=\"ISO-8859-15\")\nDoes someone know how could I get the right '\u0153' character (or eaven better the string 'oe') instead of this ?\nThank's a lot :)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":55987923,"Users Score":0,"Answer":"Anyone have a clue ? I've manage the problem by manually rewrite this special character before reading my csv with pandas but that doesn't answer my question :(","Q_Score":0,"Tags":"python-3.x,pandas,encoding","A_Id":55993149,"CreationDate":"2019-05-05T00:30:00.000","Title":"Pandas read_csv method can't get '\u0153' character properly while using encoding ISO 8859-15","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I was trying to insert an image in pygame, I heard people say your images have to be in the same directory as pygame and I'm not sure what that means. I was hoping someone could help me, Thank You.\nI know all the commands and how to insert an image but it gives me an error because the image is not in the same directory\nMy wish is to have my image as a background in my screen.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":25,"Q_Id":55988633,"Users Score":1,"Answer":"Imagine you have a pygame folder and inside that lies those executables that fires up your pygame instance, so for that you need to load that image also.\n\npygame\/\n-----------mygame.py\n\nNow your pygame instance searches for the image which can have either relative or absolute pathnames.\nIn the same directory quintessentially means the folder\/directory where your executable instance is running (eg mygame.py etc), so you have to copy-paste your image to that directory in layman terms and run the mygame.py again.\nDirectory structure updates to:\n\npygame\/\n-----------mygame.py\n-----------background.jpg","Q_Score":0,"Tags":"python","A_Id":55989070,"CreationDate":"2019-05-05T03:39:00.000","Title":"What to do when there is an issue with inserting images in pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using sklearn's random forests module to predict a binary target variable based on 166 features.\nWhen I increase the number of dimensions to 175 the accuracy of the model decreases (from accuracy = 0.86 to 0.81 and from recall = 0.37 to 0.32) .\nI would expect more data to only make the model more accurate, especially when the added features were with business value.\nI built the model using sklearn in python.\nWhy the new features did not get weight 0 and left the accuracy as it was ?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2477,"Q_Id":55990255,"Users Score":1,"Answer":"Basically, you may be \"confusing\" your model with useless features. MORE FEATURES or MORE DATA WILL NOT ALWAYS MAKE YOUR MODEL BETTER. The new features will also not get weight zero because the model will try hard to use them! Because there are so many (175!), RF is just not able to come back to the previous \"pristine\" model with better accuracy and recall (maybe these 9 features are really not adding anything useful). \nThink about how a decision tree essentially works. These new features will cause some new splits that can worsen the results. Try to work it out from the basics and slowly adding new information always checking the performance. In addition, pay attention to for example the number of features used per split (mtry). For so many features, you would need to have a very high mtry (to allow for a big sample to be considered for every split). Have you considered adding 1 or 2 more and checking how the accuracy responds? Also, don't forget mtry!","Q_Score":1,"Tags":"python,machine-learning,random-forest","A_Id":56062610,"CreationDate":"2019-05-05T08:46:00.000","Title":"additional of features decrease the accuracy- random forest","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using sklearn's random forests module to predict a binary target variable based on 166 features.\nWhen I increase the number of dimensions to 175 the accuracy of the model decreases (from accuracy = 0.86 to 0.81 and from recall = 0.37 to 0.32) .\nI would expect more data to only make the model more accurate, especially when the added features were with business value.\nI built the model using sklearn in python.\nWhy the new features did not get weight 0 and left the accuracy as it was ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2477,"Q_Id":55990255,"Users Score":0,"Answer":"More data does not always make the model more accurate. Random forest is a traditional machine learning method where the programmer has to do the feature selection. If the model is given a lot of data but it is bad, then the model will try to make sense out of that bad data too and will end up messing things up. More data is better for neural networks as those networks select the best possible features out of the data on their own.\nAlso, 175 features is too much and you should definitely look into dimensionality reduction techniques and select the features which are highly correlated with the target. there are several methods in sklearn to do that. You can try PCA if your data is numerical or RFE to remove bad features, etc.","Q_Score":1,"Tags":"python,machine-learning,random-forest","A_Id":55993920,"CreationDate":"2019-05-05T08:46:00.000","Title":"additional of features decrease the accuracy- random forest","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a flutter text entry field. I want to send this text_entry and username to a flask API. The text field may contain latex symbols. Now the flask API will return an HTML file with custom CSS and that text-entry written on it among other things which I can now view in my web browser. I want to webview that returned html file from flutter widget. How to implement it ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":391,"Q_Id":55991871,"Users Score":1,"Answer":"Add the http package.\nMake a network request using the http package.\nConvert the response into a custom Dart object.\nFetch and display the data with Flutter.","Q_Score":1,"Tags":"python,flask,webview,flutter","A_Id":57946098,"CreationDate":"2019-05-05T12:21:00.000","Title":"Send text data from flutter to flask api and webview the returned html","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on a piece of code that will be able to hit multiple web APIs (hardware that has APIs telling about the machine status) not blocking when one is waiting on the other to wait for the response, once the response of one arrives it'll be emitted on a websocket. One requirement is not to kill the APIs so hit them let's say once per 5 seconds as long as the main process is running.\nThe important part I'm struggling with is how to even approach it. \nWhat I did to this point is that the main process is spawning separate threads for different APIs and that thread is hitting the API emitting the response to the websocket time.sleep(5) and repeat. The main process is responsible to start new \"workers\" and kill ones that are not needed anymore also to restart ones that should be working but are not due to i.e. an exception.\nI have no idea if multi-threading is the way to go here - let's say I aim to \"crawl\" through 300 APIs.\nIs spawning long lived workers the right way to achieve this? Should those be processes instead? Should I maybe have the main process coordinate executing short-living threads that will do the API call and die and do that every 5 seconds per API (that seems way worse to maintain)? If the last option, then how to handle cases where a response takes more than 5 seconds to arrive?\nSome people are now talking about Python's asyncio like it's the golden solution for all issues but I don't understand how it could fit into my problem.\nCan someone guide me to the right direction?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":471,"Q_Id":55994649,"Users Score":2,"Answer":"Let me rephrase this and tell me whether I'm right:\n\nI want to visit ~300 APIs frequently such that each is hit approximately every 5 seconds. How do I approach this and what worker\/process management should I use?\n\nThere's basically two different approaches:\n\nSpawn a thread for each API that is currently being watched (i.e. touched frequently) -- only feasible if at any given time only a subset of your total number of possible APIs is being watched.\nSet up a worker pool where all workers consume the same queue and have a management process fill the queue according to the time restrictions -- probably better when you always want to watch all possible APIs.\n\nEdit after your first comment:\nYou know the number of APIs you want to watch, so the queue's length should never grow larger than that number. Also, you can scan the queue in your main process frequently and check whether an API address you want to add already is in there and don't append it another time.\nTo avoid hitting APIs too frequent, you can add target timestamps along with the API address to the queue (e.g. as a tuple) and have the worker wait until that time is reached before firing the query to that API. This will slow down the consumption of your entire queue but will maintain a minimum delay between to hits of the same API. If you choose to do so, you just have to make sure that (a) the API requests always respond in a reasonable time, and (b) that all API addresses are added in a round-robin manner to the queue.","Q_Score":0,"Tags":"python,multithreading,multiprocessing,python-asyncio","A_Id":55995044,"CreationDate":"2019-05-05T17:38:00.000","Title":"Spawning workers in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a way to download surveys that are still open on Qualtrics so that I can create a report on how many surveys are completed and how many are still in progress. I was able to follow their API documentation to download the completed surveys to a csv file but I couldn't find a way to do the same for the In Progress surveys. Thanks in advance for your help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":156,"Q_Id":55997128,"Users Score":0,"Answer":"Not through the API.  You can do it manually through the Qualtrics interface.\nIf you need to use the API and the survey is invite only, an alternative would be to download the distribution history for all the distributions. That will tell you the status of each invitee.","Q_Score":0,"Tags":"python,qualtrics","A_Id":56006150,"CreationDate":"2019-05-05T22:56:00.000","Title":"Is there a way to download \"Responses In Progress\" survey from Qualtrics?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I have a project src code with requirements.txt\nI need to create virtualenv. But how to know which pytho  version should I use? How to store python version in project, so that others can recreate virtualenv with correct python version?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":303,"Q_Id":55999058,"Users Score":0,"Answer":"This depends on your build system and how you are packaging up your application.\nIf you are deploying the code as a Docker container, the Python version may be encoded in your Dockerfile (specifically, the base image that you use and its associated Python version or how you download and install Python in the creation of your Docker image).\nIf you are producing a self-contained executable file that extracts the Python interpreter as well as your source files and self-executes, then the specific Python interpreter you download as part of this process is likely how you would encode this (and how to do this may depend on your specific build system).\nIf you are producing a Python library, one generally does not assume a particular Python version (but rather a range of supported versions) which are determined by the environment in which it is installed (and for which the supported Python versions are not typically encoded directly but merely part of documentation).","Q_Score":2,"Tags":"python,virtualenv","A_Id":55999212,"CreationDate":"2019-05-06T05:06:00.000","Title":"How to know which python version to use in virtualenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to execute a .py file (python file) saved on my local machine (say @C:\\User\\abc\\dosomething.py) from postman from its pre-request section.\nEssentially I need to call the .py file from javascript code but from postman only.\nHow do I do that ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2506,"Q_Id":56002752,"Users Score":0,"Answer":"Unfortunately this is not possible. The Pre-request and test-scripts are executed in a sandbox environment.","Q_Score":1,"Tags":"python-2.7,postman","A_Id":56004157,"CreationDate":"2019-05-06T09:52:00.000","Title":"How to execute python script from postman?","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 run a python script using OpenCV with PyPy, but all the documentation that I found didn't work.\nThe installation of PyPy went well, but when I try to run the script it says that it can't find OpenCV modules like 'cv2' for example, despite having cloned opencv for pypy directly from a github repository.\nI would need to know how to do it exactly.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3007,"Q_Id":56004743,"Users Score":1,"Answer":"pip install opencv-python worked well for me on python 2.7, I can import and use cv2.","Q_Score":3,"Tags":"python,opencv,pypy","A_Id":56004857,"CreationDate":"2019-05-06T11:57:00.000","Title":"Using OpenCV with PyPy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Chris and Pat collaborate on a Python project. The source code is under version control. They each choose their own checkout location on their respective drives. The collaborative application resides in <root>\/app.py.\nThey both use PyCharm, and since the .idea folders on their checkout drives have some amount of effort invested, they are reluctant not to check it into the repository.\nYet because the checkout locations are distinct, they cannot share one .idea folder. They have resolved the problem by storing their .idea folders in <root>\/pycharm\/chris\/.idea and <root>\/pycharm\/pat\/.idea. Both folders are checked into the repository. They can go home with the confidence that if their desktops' disks fail, the effort they spent on their PyCharm configuration is safe.\nBut something is missing. They write (pytest-based) tests for their own respective subsets of the code, and they would like to share those tests.\nIs there a workflow, from within PyCharm or without, that enables them to work on a unified set of test configurations? I may be missing something basic. It may be the case, for example, that they ought to make an effort to checkout into exactly the same paths, as well as to use venvs located at exactly the same paths, and share the same .idea all the way. If you've found that that's the only sensible solution, arguing for it would also be an answer.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":76,"Q_Id":56012179,"Users Score":1,"Answer":"They should just have one .idea file in the git repo and .gitignore the parts they want to keep unique to their systems.\nThey can also mark a given Run Configuration as \"sharable\" by enabling \"Share\" option in it (top right corner of the configuration window). This way it will be stored in .idea\/runConfigurations.","Q_Score":2,"Tags":"python,pycharm,pytest","A_Id":56012249,"CreationDate":"2019-05-06T20:44:00.000","Title":"Is there a PyCharm-based workflow for sharing run\/test configurations?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using a Text Widget in Tkinter, I want to highlight on the vertical scrollbar where the locations of found text are, similar to how Chrome highlights locations of words found in the Vertical Scrollbar if you use the Find option on a webpage. How can that be accomplished?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":64,"Q_Id":56013208,"Users Score":1,"Answer":"How can I create Marks in a Tkinter Text Widget's Vertical Scrollbar?\n\nYou can't. The tkinter scrollbar doesn't support it. You will have to create your own scrollbar by drawing the various pieces on a canvas and then write code that mimics the scrollbar api.","Q_Score":0,"Tags":"python-3.x,tkinter,scrollbar","A_Id":56014318,"CreationDate":"2019-05-06T22:34:00.000","Title":"How can I create Marks in a Tkinter Text Widget's Vertical Scrollbar?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a website host on google cloud engine. I use Python Pyramid framework and jinja2.\nWhen I update profile image, image was upload successfull but image is not show .\nIf i run sudo python3.6 setup.py install and restart web server again. The profile image will be show .\nPS : I use mod_wsgi and apache2, not use virtual env\nI don't know why, anybody can help me.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":56013658,"Users Score":0,"Answer":"If i use\n$sudo python3.6 setup.py develop\nthen upload image was work fine for me.\nWhat the difference between setup.py install and setup.py develop","Q_Score":0,"Tags":"python,pyramid","A_Id":56013854,"CreationDate":"2019-05-06T23:41:00.000","Title":"Python pyramid setup.py install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to solve a simple binary classification problem using LSTM. I am trying to figure out the correct loss function for the network. The issue is, when I use the binary cross-entropy as loss function, the loss value for training and testing is relatively high as compared to using the mean squared error (MSE) function.\nUpon research, I came across justifications that binary cross-entropy should be used for classification problems and MSE for the regression problem. However, in my case, I am getting better accuracies and lesser loss value with MSE for binary classification. \nI am not sure how to justify these obtained results. Why not use mean squared error for classification problems?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":8441,"Q_Id":56013688,"Users Score":1,"Answer":"The answer is right there in your question. Value of binary cross entropy loss is higher than rmse loss.\nCase 1 (Large Error):\nLets say your model predicted 1e-7 and the actual label is 1.\nBinary Cross Entropy loss will be -log(1e-7) = 16.11.\nRoot mean square error will be (1-1e-7)^2 = 0.99.\nCase 2 (Small Error)\nLets say your model predicted 0.94 and the actual label is 1.\nBinary Cross Entropy loss will be -log(0.94) = 0.06.\nRoot mean square error will be (1-1e-7)^2 = 0.06.\nIn Case 1 when prediction is far off from reality, BCELoss has larger value compared to RMSE. When you have large value of loss you'll have large value of gradients, thus optimizer will take a larger step in direction opposite to gradient. Which will result in relatively more reduction in loss.","Q_Score":9,"Tags":"python,keras,lstm,cross-entropy,mean-square-error","A_Id":67363684,"CreationDate":"2019-05-06T23:44:00.000","Title":"Why not use mean squared error for classification problems?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to solve a simple binary classification problem using LSTM. I am trying to figure out the correct loss function for the network. The issue is, when I use the binary cross-entropy as loss function, the loss value for training and testing is relatively high as compared to using the mean squared error (MSE) function.\nUpon research, I came across justifications that binary cross-entropy should be used for classification problems and MSE for the regression problem. However, in my case, I am getting better accuracies and lesser loss value with MSE for binary classification. \nI am not sure how to justify these obtained results. Why not use mean squared error for classification problems?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":8441,"Q_Id":56013688,"Users Score":6,"Answer":"I would like to show it using an example.\nAssume a 6 class classification problem.\nAssume, \n     True probabilities = [1, 0, 0, 0, 0, 0]\nCase 1:\nPredicted probabilities = [0.2, 0.16, 0.16, 0.16, 0.16, 0.16]\nCase 2:\nPredicted probabilities = [0.4, 0.5, 0.1, 0, 0, 0]\nThe MSE in the Case1 and Case 2 is 0.128 and 0.1033 respectively.\nAlthough, Case 1 is correctly predicting class 1 for the instance, the loss in Case 1 is higher than the loss in Case 2.","Q_Score":9,"Tags":"python,keras,lstm,cross-entropy,mean-square-error","A_Id":58903890,"CreationDate":"2019-05-06T23:44:00.000","Title":"Why not use mean squared error for classification problems?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to solve a simple binary classification problem using LSTM. I am trying to figure out the correct loss function for the network. The issue is, when I use the binary cross-entropy as loss function, the loss value for training and testing is relatively high as compared to using the mean squared error (MSE) function.\nUpon research, I came across justifications that binary cross-entropy should be used for classification problems and MSE for the regression problem. However, in my case, I am getting better accuracies and lesser loss value with MSE for binary classification. \nI am not sure how to justify these obtained results. Why not use mean squared error for classification problems?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":8441,"Q_Id":56013688,"Users Score":-1,"Answer":"I'd like to share my understanding of the MSE and binary cross-entropy functions.\nIn the case of classification, we take the argmax of the probability of each training instance.\nNow, consider an example of a binary classifier where model predicts the probability as [0.49, 0.51]. In this case, the model will return 1 as the prediction.\nNow, assume that the actual label is also 1.\nIn such a case, if MSE is used, it will return 0 as a loss value, whereas the binary cross-entropy will return some \"tangible\" value. \nAnd, if somehow with all data samples, the trained model predicts a similar type of probability, then binary cross-entropy effectively return a big accumulative loss value, whereas MSE will return a 0.\nAccording to the MSE, it's a perfect model, but, actually, it's not that good model, that's why we should not use MSE for classification.","Q_Score":9,"Tags":"python,keras,lstm,cross-entropy,mean-square-error","A_Id":56045324,"CreationDate":"2019-05-06T23:44:00.000","Title":"Why not use mean squared error for classification problems?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"using PythonAnywhere, I ran a nohup process in the background but forget the PID how can I end it?\nI don't have perrmissions to list processes.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":32,"Q_Id":56014086,"Users Score":3,"Answer":"There's a \"Fetch process list\" button on the Consoles and the Tasks pages (they are 2 different lists). Use that to get a process list and you can kill your process from that list.","Q_Score":1,"Tags":"pythonanywhere","A_Id":56038068,"CreationDate":"2019-05-07T00:43:00.000","Title":"Ending background nohup process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Summary : Concern is related to UDF creation in Hive.\nDear friends, As I am new in creating UDFs in Hive (I have read about this via google but not getting very clear idea), my first thing here is to determine which would be the best possible way like Java\/Python or any other to write hive UDFs.\nAnother thing is on what basis I should analyse? What all parameter I should look for ?\nPlease not that I have few functions as given below for which UDFs needs to be written.\n1. To select and group by clauses required for another function when \"no aggregation\" is needed.\n2. To return the select and group by clauses required when \"aggregation\" is needed.\n3. For vector_indexes are SUM, LISTAGG strings for the data collection query \n4. To return the WHERE clause used by other function.\n5 To return the nth item in a comma separated string.\n6. Percentile Value function for Narrow data.\n7. To calculates percentile for a given counter name. Along with the percentile, it also outputs the number of samples used in the calculation, the peak and average.\nThank you very much in advance,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":56014157,"Users Score":0,"Answer":"This question probably isnt within guidelines because you are asking for an opinion.\nHaving said that i would propose that:\nA) you pick a language that you know.\nB) if you know both, then pick based upon the features you need.\nC) consider performance - i believe (but cannot confifm) that a compiled Java Jar will run without launching a java runtime just to support that Java module (it will run inside the hive java instance). To run a Python module a new python interpreter will need to be instantiated and data transferred via interprocess communication. Thus java is possibly slightly more perfofmant - especially if the algorithm is simple. However unless you are processing huge data sets you probably would not even notice.\nFinally, you could probably do all of the functions you asked with Hive query language.","Q_Score":0,"Tags":"java,python,hive,user-defined-functions","A_Id":56014229,"CreationDate":"2019-05-07T00:57:00.000","Title":"Determine the language for UDF creation in Hive","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to reassign self inside its own class?\nI have a form for that class which have okay button and cancel button. If the user click okay, I will only pass its value to another window. However, if I click cancel, I want to return the state of that form to its previous state. So if the user click that form and it contains value, then the user add a field, but he\/she decided to click cancel, I want to reassign the previous state of the instance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":739,"Q_Id":56014968,"Users Score":0,"Answer":"I agree with the comment, it will be helpful if you can show more details. But if I understand you correctly, a better way to implement this is creating a bidirectional linked list structure in which each element is a state rather than modifying an instance. So you can treat ok and 'cancel' button as two opposite operators operating on the forward and backward pointers of this linked list. The length of this list is the steps the user can go back with.","Q_Score":1,"Tags":"python,python-3.x","A_Id":56015465,"CreationDate":"2019-05-07T03:05:00.000","Title":"Method's parameter 'self' reassigned","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a SOAP url , while running the url through browser I am getting a wsdl response.But when I am trying to call a method in the response using the required parameter list, and it is showing \"ARERR [149] A user name must be supplied in the control record\".I tried using PHP as well as python but I am getting the same error.\nI searched this error and got the information like this : \"The name field of the ARControlStruct parameter is empty. Supply the name of an AR System user in this field.\".But nowhere I saw how to supply the user name parameter.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1235,"Q_Id":56016625,"Users Score":0,"Answer":"I got the solution for this problem.Following are the steps I followed to solve the issue (I have used \"zeep\" a 3rd party module to solve this):\n\nRun the following command to understand WSDL:\n\npython -mzeep wsdl_url\n\nSearch for string \"Service:\". Below that we can see our operation name\nFor my operation I found following entry:\n\nMyOperation(parameters..., _soapheaders={parameters: ns0:AuthenticationInfo})\nwhich clearly communicates that, I have to pass parameters and an auth param using kwargs \"_soapheaders\"\nWith that I came to know that I have to pass my authentication element as _soapheaders argument to MyOperation function.\n\nCreated Auth Element:\n\nauth_ele = client.get_element('ns0:AuthenticationInfo')\nauth = auth_ele(userName='me', password='mypwd')\n\nPassed the auth to my Operation:\n\ncleint.service.MyOperation('parameters..', _soapheaders=[auth])","Q_Score":0,"Tags":"php,python,web-services,soap,wsdl","A_Id":56127550,"CreationDate":"2019-05-07T06:21:00.000","Title":"Getting ARERR 149 A user name must be supplied in the control record","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I thought in Python that:\n\nAll classes ultimately are subclasses of object\nAll classes utimately are instances of type\nobject is an instance of type, \nand type is a subclass of object. \n\nHowever after checking\nisinstance(object,type) which returned True as expected. As object is an instance of type.\nHowever I'm not sure why isinstance(type,object) returns True. (I thought this would be False as type isn't an instance of object).\nParticularly as isinstance(type,type) is True ie it's an instance of itself. \nAnd also issubclass(object,type) returns False, which was expected, but the results above isinstance(type,object) made me doubt wether I understood the relationships properly. \nis it because isinstance works across subclasses but type doesn't?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":56019919,"Users Score":4,"Answer":"is it because isinstance works across subclasses but type doesn't?\n\nExactly. type(x) gives you the actual type of x, whereas isinstance(x, t) checks whether the type of x is t or a subclass of t. Hence, isinstance(x, t) is True even when type(x) == t would not.\nIn particular, object is the base class from which all other classes inherit, thus type, i.e. type(type), is also a subclass of object and isinstance(type, object) is true.","Q_Score":4,"Tags":"python","A_Id":56020078,"CreationDate":"2019-05-07T09:51:00.000","Title":"instance(object, type) returns True, should it not be False?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the following code:\nmy_name = 'Tlaloc-ES'\nAnd I am trying the slices the first try is the anagram with this\nmy_name[-1:-(len(my_name)+1):-1]\nThat return:\n\n'SE-colalT'\n\nThen the position -(len(my_name)+1) is for 'T' but when try to use the next slice:\nmy_name[-(len(my_name)+1)] this return a error:\n\nstring index out of range\n\nbut with my_name[-(len(my_name))] not, and this return T\nThe answer is why for get T, in some cases I need plus one and in another cases I do not need?\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":22,"Q_Id":56020612,"Users Score":1,"Answer":"the reason is the slice you created (-1:-(len(...) create a generator from -1 to -10 which is technically the number from -1 to -9 (-10 not included). So using it as an index option (len(my_name) + 1) means its outside the length of my_name. Remove the +1 and it should work","Q_Score":0,"Tags":"python,python-3.x","A_Id":56020739,"CreationDate":"2019-05-07T10:31:00.000","Title":"Why this access by slice work but not work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a Python Script on the Raspberry Pi in order to get measured data out of a Smart Plug. In my script I need to write the IP-Address of the Smart Plug so that I can retrieve the data it was measured. The problem is that I need to be able to take the Smart Plug to different places without having to hard code its new local IP-Address every time. \nI have the MAC Address so I am hoping there is an \"easy\" way to add a couple lines of code and retrieve the local IP-Address from the MAC (?) in the Python Script. Thanks!","AnswerCount":3,"Available Count":1,"Score":-0.1325487884,"is_accepted":false,"ViewCount":7632,"Q_Id":56022026,"Users Score":-2,"Answer":"The local ip address is not based on the MAC address. The router uses DHCP to give the devises an ip address. So there is no way to tell the router which IP he must give you other than changing the settings. \nI would rather try to broadcast the ip and on the raspberry listen on the broadcast channel for the message you are looking for.","Q_Score":2,"Tags":"python,ip-address,hostname,mac-address","A_Id":56022228,"CreationDate":"2019-05-07T11:53:00.000","Title":"Get local IP Address from a known MAC Address in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to find out the intent of sentence for the same I need to find out to which entity pronoun is referring.\nConsider the example \n\nMy name is Rushabh. I live in Pune.\n\nIn the second sentence 'I' is referring to the Rushabh. How to find it out using python.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2688,"Q_Id":56022278,"Users Score":0,"Answer":"In general, most heuristic applications use some kind of a focus in a given stack. a stack is a list of entities that might be referred to anaphorically (anaphora resolution is the topic at whose surface you scratch here). This list my contain nouns, pronouns and abstract entities like events etc. Leaving aside abstract anaphora, which is the most complicated application field of all of them, you check for congruence (grammatical agreement in person and number) for candidates in the focus (most recent or prominent in the stack) and the rest of the stack from most recent backwards, in order to match the best. Don't forget updating the stack, that is removing entities which were not subsequentially referred to.\nIt is quite normal that you get bad results, since this is still an active field of research and there is no application that will give you perfect recall and precision. If you get 70 % correct, you can already count this a success.\nIf you need more precision, try to find a corpus on anaphora resolution to train a machine learning model. today it is more popular and promising anyways, especially when learning from older heuristic methods like the one above.","Q_Score":1,"Tags":"python,nlp,nltk,spacy","A_Id":58235875,"CreationDate":"2019-05-07T12:06:00.000","Title":"'How to find out noun to which pronoun is referring to' in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wish to have a touchsensor on the end of a moving arm. However, through the Python API, getDevice('touch_sensor') only returns sensors that are directly under the Robot parent. \nIs there a way I can either get a sensor that is nested (under a joint), or instead make a sensor that is under parent move in tandem with another joint?\nI have tried setting the bounding box of the sensor to a shape\/transform nested under the moving joint, but it simply takes on the original position of the shape and doesn't update when the joint moves.\nI have also tried putting the sensor directly under the joint, in which case it does indeed move, but then I cannot access it from the python API. (Using get device returns None)","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":143,"Q_Id":56022689,"Users Score":2,"Answer":"Found the problem, I should have used getTouchSensor instead of getDevice!!\nNow it works fine.","Q_Score":0,"Tags":"python,sensors,webots","A_Id":56023750,"CreationDate":"2019-05-07T12:29:00.000","Title":"How to get TouchSensor nested under joint in Webots (Python 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":1},{"Question":"Requirement:\n\nSending mail via SMTP(only via SMTP for specific reason) to the user which is read through event \"RunInstances\" from cloud-trail.\nAs SMTP code is not working with lambda I will have to kept inside EC2 and trigger it through lambda.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":512,"Q_Id":56025709,"Users Score":1,"Answer":"There are few options:\n\nUse SQS: Use Lambda to send messages to SQS, add workers in your EC2s to consume the messages.\nCreate a server in EC2 that listens to traffic from a port, for example: 80. Use Lambda to send HTTP requests to the EC2 server.\n(Not recommended for this case): Use Step Function Activity. Lambda to call step function, passes the input which is email content. The step function will run and create an activity. The EC2 instance will then have a worker implemented that keep polling activities from the Step function.","Q_Score":0,"Tags":"python,amazon-ec2,aws-lambda,boto3","A_Id":56031606,"CreationDate":"2019-05-07T15:15:00.000","Title":"Is there any way to trigger code inside EC2 from 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 have a more or less standard implementation of DQN solving the Atari \"Breakout\" (from Coursera Reinforcement learning course), that behaves totally different on different computers:\n\non my Laptop it converges each time I run it\non Coursera and Google Colab servers it never converges!\n\nI use\n\nPython3\nTensorflow\nKerass (only for Conv2D, Flatten and Dense layers)\n\nI already spend some two weeks on the issue without any progress :(\nI already checked:\n\nThe versions:\n\n\nPython: same (3.6.7)\nTensorflow: same (tested with 1.4.0 and 1.5.0)\nnumpy: same up the bugfix number (1.16.2 vs 1.16.3)\n\nRandom seeds\nfloat32 vs float64: I always pass dtype=np.float32 to each np.array and tf.placeholder call.\nCPU\/GPU\n\n\nMy laptop, that converges, uses old CPU (that limits Tensorflow to <= 1.5.0)\nOn Coursera server, that never converges: CPU?\nOn Google Colab server, that never converges: GPU\n\n\nMy questions here are:\n\nWhat may be cause of the different behavior?\nHow such problems get debugged?\nWhat can I also do\/check to finally find the problem?\n\nUpdate: All the code (incl. hyperparameters, env, ...) is exactly the same.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":98,"Q_Id":56025783,"Users Score":1,"Answer":"I assume you run a certain version of your code with a given hyper-parameter values. Then, you need to fix random seed in the beginning of your code for tensorflow (e.g. tf.set_random_seed(1)), for numpy (e.g. np.random.seed(1)) and for random, if you use it. \nAdditionally, you have to have same version of tensorflow on all you machines. I had a experience that even the forward pass between 1.3 and 1.8 resulted in two different outputs. Same check is required for gym. \nFinally, you have to check with either cpu or gpu. You cannot compare the results of a cpu run with a gpu run. \nIf neither of these checks worked, I can check your colab code if you want to share it.","Q_Score":2,"Tags":"python,python-3.x,tensorflow,keras,reinforcement-learning","A_Id":56063874,"CreationDate":"2019-05-07T15:18:00.000","Title":"DQN behaves differently on different computers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having an issue getting OpenCV to work with python.  I compiled from source using CMake in order to gain access to the SIFT module.  Whenever I try to use openCV however, python returns the \"No module named 'cv2'\" error.  It works fine when I install using pip but then I have no SIFT.  My build directory is set as an environment variable and my bin directory is in my system path.  There were no build issues and the applications that came with the build run fine.  Is there another step that I have to perform, such as installing from the compiled project using pip?  How do I get my openCV library, compiled from source, to be importable by python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":407,"Q_Id":56027199,"Users Score":0,"Answer":"The solution ended up being both simpler and sloppier than I would have liked.  I just installed the regular distribution using pip install opencv-contrib-python, then went into the cv2 folder in Lib\/site-packages, replaced the python extension (cv2.cp36-win32.pyd in my case.  may be different for others) with the .pyd file from my CMake build (build\/lib\/python3\/Release) and copied everything from build\/bin\/Release into the Lib\/site-packages\/cv2 folder.  It doesn't look pretty or organized but python can find everything now.  If anyone has a cleaner way to do this I'd love to hear it.","Q_Score":1,"Tags":"python,python-3.x,opencv","A_Id":56027872,"CreationDate":"2019-05-07T16:50:00.000","Title":"Getting OpenCV to work with python after compiling from source","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to deploy my Django and spaCy project to Heroku. But I am getting an error: No matching distribution found for en-core-web-sm (It is an ML model downloadable via pip). How can I solve this problem? The model is installed locally in a virtual environment and working alright. I got the requirements file via pip freeze. I am using Python 3.6.4.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4869,"Q_Id":56028694,"Users Score":0,"Answer":"I found an alternative to install en_core_web_sm on Heroku and have not found any side effects yet, which is editing the Profile in this way:\n\nweb: sh setup.sh && python -m spacy download en_core_web_sm && streamlit run app.py\n\nJust tell me if everyone finds it is not available anymore.","Q_Score":8,"Tags":"python,django,heroku,spacy","A_Id":63368463,"CreationDate":"2019-05-07T18:40:00.000","Title":"Heroku Deployment Error: No matching distribution found for en-core-web-sm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For some reason the first time I downloaded and installed python, pip was not working. I reinstalled python and set the path of the interpreter on Pycharm, but now when I make a configuration and run, nothing happens. I'm not even able to print a simple Hello World. The console comes up with an exit code of 0, however nothing else happens.\nI may have done something wrong while setting up Pycharm, any guidance towards a solution is greatly appreciated!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":413,"Q_Id":56028871,"Users Score":0,"Answer":"I had a similar problem a while back and had to enable the interactive console to see the output.  The setting should be in \"Run\/Edit Configurations\" under Python's config tab.  Changing the \"interpreter options:\" to \"-i\" should enable the interactive console. \nThe exit code 0 just is telling you the code ran without any errors.","Q_Score":0,"Tags":"python,pycharm","A_Id":56029169,"CreationDate":"2019-05-07T18:54:00.000","Title":"Can't get scripts to run on Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to implement a BFS function that will print a list of nodes of a directed graph as visited using Breadth-First-Search traversal. The function has to be implemented non-recursively and it has to traverse through all the nodes in a graph, so if there are multiple trees it will print in the following way:\nTree 1: a, b\nTree 2: d, e, h\nTree 3: .....\nMy main difficulty is understanding how to make the BFS function traverse through all the nodes if the graph has several trees, without reprinting previously visited nodes.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2212,"Q_Id":56030239,"Users Score":0,"Answer":"BFS is usually done with a queue. When you process a node, you push its children onto the queue. After processing the node, you process the next one in the queue.\nThis is by nature non-recursive.","Q_Score":2,"Tags":"python,breadth-first-search","A_Id":56030323,"CreationDate":"2019-05-07T20:45:00.000","Title":"How to implement Breadth-First-Search non-recursively for a directed graph on python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building an automation in Python which fetches some data from a database table and populates an excel sheet. I'm using cx_Oracle module for setting up a connection. There are around 44 queries, and around 2 million rows of data are fetched for each query, which makes this script run for an hour. So I'm planning to use threading module to speed up the process. Although I'm confused whether to use multiple connections (around 4) or have less connections (say, 2) and multiple cursors per connection.\nThe queries are independent of each other. They are select statements to fetch the data and are not manipulating the table in any way.\nI just need some pros and cons of using both approaches so that I can decide how to go about the script. I tried searching for it a lot, but curiously I'm not able to find any relevant piece of information at all. If you point me to any kind of blog post, even that will be really helpful.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1060,"Q_Id":56034411,"Users Score":2,"Answer":"An Oracle connection can really do just one thing at a time. Specifically while a database session can have multiple open cursors at any one time, it can only be executing one of them.\nAs such, you won't see any improvement by having multiple cursors in a single connection. \nThat said, depending on the bottleneck, you MIGHT not see any improvement from going with multiple connections either. It might be choked on bandwidth in returning the data, disk access etc. If you can code in such a way as to keep the number of threads \/ connections variable, then you can tweak until you find the best result.","Q_Score":0,"Tags":"python-3.x,oracle,cx-oracle","A_Id":56034544,"CreationDate":"2019-05-08T06:00:00.000","Title":"Multiple Cursors versus Multiple Connections","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"sorry for the noob question, but how do I kill the Tensorflow PID?\nIt says:\nReusing TensorBoard on port 6006 (pid 5128), started 4 days, 18:03:12 ago. (Use '!kill 5128' to kill it.)\nBut I can not find any PID 5128 in the windows taks manager. Using '!kill 5128' within jupyter the error returns that comand kill cannot be found. Using it in the Windows cmd or conda cmd does not work either. \nThanks for your help.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":10028,"Q_Id":56036922,"Users Score":11,"Answer":"If you clear the contents of AppData\/Local\/Temp\/.tensorboard-info, and delete your logs, you should be able to have a fresh start","Q_Score":7,"Tags":"python,tensorflow,tensorboard","A_Id":64094622,"CreationDate":"2019-05-08T08:51:00.000","Title":"How to kill tensorboard with Tensorflow2 (jupyter, Win)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python daemon that monitors machine performance during the execution of another software. It basically retrieves data of target processes with ps and writes it to a CSV file to be plotted when the daemon is stopped.\nIf the daemon is running in a terminal as a foreground process, the user can stop it with Ctrl+C, what will force a KeyboardInterrupt exception. I capture that exception and plot the content of the CSVs then.\nThe problem comes when I have to launch the daemon in a background process with nohup myDaemon.py &. It works fine, as it generates the CSVs, but as I can't force a KeyboardInterrupt exception the CSVs are not automatically plotted if I kill or stop the background process with other methods than Ctrl+C.\nWhat I want to avoid is having to move the plotting part to a separate script and run it manually after stopping the daemon.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":540,"Q_Id":56036985,"Users Score":1,"Answer":"Found the answer reading kill man page. It turns out that signal -2 (SIGINT) is the equivalent of Ctrl+C. Tested it running kill -2 <Background_Daemon_PID> and worked just fine.","Q_Score":0,"Tags":"python-2.7,background-process,daemon,keyboardinterrupt","A_Id":56041220,"CreationDate":"2019-05-08T08:55:00.000","Title":"How to interrupt Python background daemon with Ctrl+C equivalent (forcing KeyboardInterrupt exception)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have created a word2vec file and I want to extract only the line at position [0]\nthis is the word2vec file\n`36 16\nActivity 0.013954502 0.009596351 -0.0002082094 -0.029975398 -0.0244055 -0.001624907 0.01995442 0.0050479663 -0.011549354 -0.020344704 -0.0113901375 -0.010574887 0.02007604 -0.008582828 0.030914625 -0.009170294\nDATABASED%GWC%5 0.022193532 0.011890317 -0.018219836 0.02621059 0.0029900416 0.01779779 -0.026217759 0.0070709535 -0.021979155 0.02609082 0.009237218 -0.0065825963 -0.019650755 0.024096865 -0.022521153 0.014374277\nDATABASED%GWC%7 0.021235622 -0.00062567473 -0.0045315344 0.028400827 0.016763352 0.02893731 -0.013499333 -0.0037113864 -0.016281538 0.004078895 0.015604254 -0.029257657 0.026601797 0.013721668 0.016954066 -0.026421601`","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":12,"Q_Id":56039771,"Users Score":0,"Answer":"glove_model[\"Activity\"] should get you its vector representation from the loaded model. This is because glove_model is an object of type  KeyedVectors and you can use key value to index into it.","Q_Score":0,"Tags":"python,pycharm","A_Id":56039845,"CreationDate":"2019-05-08T11:29:00.000","Title":"how to extract line from a word2vec file?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any shortcut in the IntelliJ IDE such as PyCharm to comment all the lines start with 'print'?\nSince during the debug I always write many prints, after the code runs well I want to find a convenient way to comment on all lines starting with 'print'. Now I select each line\/block with command + \/ which is trouble.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":679,"Q_Id":56040211,"Users Score":1,"Answer":"Not sure about pycharm, but I guess you could use find\/replace with a regex like '^print' and substitute with '# print'. Maybe you can even make this a macro \/ Hotkey in pycharm.","Q_Score":2,"Tags":"python,intellij-idea,replace,pycharm,comments","A_Id":56040247,"CreationDate":"2019-05-08T11:53:00.000","Title":"PyCharm comment print lines","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a list of dictionaries.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":46,"Q_Id":56042375,"Users Score":1,"Answer":"Dicts in Python allow you to use == with them. I added the change_time to the end of the segments2 and run this code:\n[change_time == d for d in segments2]\nIt returns:\n[False, False, False, True]\nIf you want to check only one field, you can specify it:\n[change_time['startTime'] == d['startTime'] for d in segments2]\nThen you can get all indices of equal dicts. Or you can just run this command:\nchange_time in segments2\nwhich returns True in this case.","Q_Score":1,"Tags":"python,list,dictionary","A_Id":56042597,"CreationDate":"2019-05-08T13:51:00.000","Title":"Wondering if there is a better way in looping over a list of dictionaries and comparing the keys to another dictionary keys","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I decode these two strings (see below) but test1 and test2 has the same result it means they're the same. Why? It seems that b64decode function cut the string after \"==\". What do I do wrong?\n\ntest1 = base64.b64decode(\"IBFIgACAAIAAAA==Iq0yAACAMgAwMA==NzEI9AFkZEsegA==IHEINzdLS0sAAA==\")\ntest2 = base64.b64decode(\"IBFIgACAAIAAAA==\")","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":530,"Q_Id":56043123,"Users Score":1,"Answer":"Maybe its good to know why this happens and what \"=\" in this case means and the usecase of it in base64.\nYour assumption that base64decode function cuts the string behind \"==\" is in some way correct, because the base64decoder is interpreting it as the end of your base64 String.\nIts important to know how the \"=\" character works and that its more like a special character in base64 encoding and has no corresponding character which encodes it.\nJust to give you a short overview and not going to deep into this Topic:\nIf base64encode function gets a String as Input to generate a base64 encoded String the Length of input String has to be dividable by 3. \nIf its not, base64 is automaticaly adding the padding character \"=\" at the end of the base64 encoded String to tell the base64decoder function how much bytes were needed to fill the Input String to an dividable by 3 String and that he can decode the String correctly back to the original String.\nSo in your case the base64decoder sees your \"=\" character in your String \"IBFIgACAAIAAAA==\" and probably interpret this as the end of the base64 String.\nConclusion:\nYou will see the \"=\" character always at the end of a base64 String, if the string is not a multiple of 3, and its doesn't encode any character.","Q_Score":0,"Tags":"python,base64,decode","A_Id":56046413,"CreationDate":"2019-05-08T14:31:00.000","Title":"base64.b64decode function doesn't work properly, why?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm brand new to Python, so excuse my ignorance. I also checked the other questions with this same error, but they all regarded the escape sequence \"\\n\". When attempting to run a python file from my Documents in the Python command line, I get the error \"unexpected character after line continuation character.\"\nI've tried reading straight from W3Schools, which says to use...\nC:\\Users\\Your Name>python helloworld.py\nSince my file is in Documents in a file called test, I tried...\nC:\\Users\\Chris\\Documents\\Python>python test.py\nHowever, I received the given error. Any help would be appreciated, thanks.\nEdit\nIn the OS command prompt, the py prefix should have been used, rather than python","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":260,"Q_Id":56043464,"Users Score":-1,"Answer":"Type python test.py into the shell directly, not into the python interpreter. The C:\\Users\\Chris\\Documents\\Python> has backslashes in it, which cause this error as they make python expect the line to end.","Q_Score":0,"Tags":"python","A_Id":56043525,"CreationDate":"2019-05-08T14:49:00.000","Title":"\"Unexpected character after line continuation character\" when running .py file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to get some information about some dates and I don't know what to use. for example: I pass year, month, day (something like 1990, 5, 15) arguments to a module, and the module returns what day of week is the date we passed. I want it in Python 3.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3377,"Q_Id":56045643,"Users Score":0,"Answer":"You can use weekday() docs. You just have to import datetime.","Q_Score":2,"Tags":"python","A_Id":56045734,"CreationDate":"2019-05-08T16:57:00.000","Title":"How to get which day of week is a specific date?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm evaluating test framework, lint and code coverage options for a new Python project I'll be working on. \nI've chosen pytest for the testing needs. After reading a bunch of resources, I'm confused when to use Sonarcube, Sonarlint , pylint and coverage.py.\nIs SonarLint and Pylint comparable? When would I use Sonarcube?\nI need to be able to use this in a Jenkins build. Thanks for helping!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1964,"Q_Id":56045813,"Users Score":1,"Answer":"Sonarlint and pylint are comparable, in a way.\nSonarlint is a code linter and pylint is too. I haven't used sonarlint, but it seems that analyzes the code a bit deeper that pylint does. From my experience, pylint only follows a set of rules (that you can modify, by the way), while sonarlint goes a bit further analyzing the inner workings of your code. They are both static analyze tools, however.\nSonarcube, on the other hand, does a bit more. Sonarcube is a CI\/CD tool that runs static linters, but also shows you code smells, and does a security analysis. All of what I'm saying is based purely on their website.\nIf you would like to run CI\/CD workflows or scripts, you would use Sonarcube, but for local coding, sonarlint is enough. Pylint is the traditional way, though.","Q_Score":7,"Tags":"python,python-3.x,lint","A_Id":66343876,"CreationDate":"2019-05-08T17:07:00.000","Title":"Python - Difference between Sonarcube Vs pylint","Data Science and Machine Learning":0,"Database and SQL":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 evaluating test framework, lint and code coverage options for a new Python project I'll be working on. \nI've chosen pytest for the testing needs. After reading a bunch of resources, I'm confused when to use Sonarcube, Sonarlint , pylint and coverage.py.\nIs SonarLint and Pylint comparable? When would I use Sonarcube?\nI need to be able to use this in a Jenkins build. Thanks for helping!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1964,"Q_Id":56045813,"Users Score":0,"Answer":"Nicholas has a great summary of Pylint vs Sonarlint.\n(Personally I use the Sonarlint)\nAlthough the question is older, I thought I'd answer the other part of your question in case anyone else has the same question; internet being eternal and all.\nCoverage.py as it sounds, runs code coverage for your package. SonarQube then uses the report that coverage.py makes and does things with it and formats it in a way that the Sonar team decided was necessary. Coverage.py is needed if you want to use SonarQube for code coverage. However, if you just want the code smells from SonarQube, it is not needed.\nYou were also asking about when to use SonarQube, coverage.py, and Jenkins.\nIn Jenkins, you would create a pipeline with several stages. Something along the following lines:\n\nCheck out code (automatically done as the first step by Jenkins\nBuild code as it is intended to be used by user\/developer\nRun Unit Tests\nrun coverage.py\nrun SonarQube","Q_Score":7,"Tags":"python,python-3.x,lint","A_Id":69052886,"CreationDate":"2019-05-08T17:07:00.000","Title":"Python - Difference between Sonarcube Vs pylint","Data Science and Machine Learning":0,"Database and SQL":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 program which uses a module (pytesseract, specifically) and I notice it takes a few seconds to import the module once I run it. I am wondering if there is a way to initialise the module before running the main program in order to cut the duration of the actual program by a few seconds. Any suggestions?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":56045872,"Users Score":0,"Answer":"One possible solution for slow startup time would be to split your program into two parts--one part that is always running as a daemon or service and another that communicates with it to process individual tasks.\nAs a quick answer without more info, pytesseract also imports (if they are installed) PIL, numpy, and pandas. If you don't need these, you could uninstall them to reduce load time.","Q_Score":0,"Tags":"python,python-3.x,python-2.7","A_Id":56046054,"CreationDate":"2019-05-08T17:11:00.000","Title":"Is it possible to initialise a module before running a 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 wrote a python program which uses a module (pytesseract, specifically) and I notice it takes a few seconds to import the module once I run it. I am wondering if there is a way to initialise the module before running the main program in order to cut the duration of the actual program by a few seconds. Any suggestions?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":56045872,"Users Score":0,"Answer":"I presume that you need to start your application multiple times with different arguments and you don't want to waste time on imports every time, right?\nYou can wrap actual code in while True: and use input() to get new arguments. Or read arguments from the file.","Q_Score":0,"Tags":"python,python-3.x,python-2.7","A_Id":56046145,"CreationDate":"2019-05-08T17:11:00.000","Title":"Is it possible to initialise a module before running a 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 starting to work with Django, already done some models, but always done that with 'code-first' approach, so Django handled the table creations etc. Right now I'm integrating an already existing database with ORM and I encountered some problems. \nDatabase has a lot of many-to-many relationships so there are quite a few tables linking two other tables. I ran inspectdb command to let Django prepare some models for me. I revised them, it did rather good job guessing the fields and relations, but the thing is, I think I don't need those link tables in my models, because Django handles many-to-many relationships with ManyToManyField fields, but I want Django to use that link tables under the hood.\nSo my question is: Should I delete the models for link tables and add ManyToManyFields to corresponding models, or should I somehow use this models?\nI don't want to somehow mess-up database structure, it's quite heavy populated.\nI'm using Postgres 9.5, Django 2.2.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":56045891,"Users Score":0,"Answer":"In many cases it doesn't matter. If you would like to keep the code minimal then m2m fields are a good way to go. If you don't control the database structure it might be worth keeping the inspectdb schema in case you have to do it again after schema changes that you don't control. If the m2m link tables can grow properties of their own then you need to keep them as models.","Q_Score":0,"Tags":"python,django,many-to-many,django-orm","A_Id":56046079,"CreationDate":"2019-05-08T17:12:00.000","Title":"Handling many-to-many relationship from existing database using Django ORM","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"A lot of posts I've seen use \"import queue\".\nBut others uses \"import Queue\".\nWhat is the difference between these two python imports?\nIs one preferable to the other?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1103,"Q_Id":56047277,"Users Score":1,"Answer":"Queue module is python 2 specific and queue module is python 3+\nImporting the Queue module in python 3 will result in error","Q_Score":1,"Tags":"python,import,queue","A_Id":62619090,"CreationDate":"2019-05-08T18:52:00.000","Title":"python queue vs. Queue?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I have a set of images of passports. I am working on a project where I have to identify the name on each passport and eventually transform that object into text.\nFor the very first part of labeling (or classification (I think. beginner here)) where the name is on each passport, how would I go about that?\nWhat techniques \/ software can I use to accomplish this?\nin great detail or any links would be great. I'm trying to figure out how this is done exactly so I can began coding\nI know training a model is involved possibly but I'm just not sure\nI'm using Python if that matters. \nthanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":56047785,"Users Score":0,"Answer":"There's two routes you can take, one where you have labeled data (or you want to label data yourseld), and one where you don't have that. \nLet's start with the latter. Say you have an image of a passport. You want to detect where the text in the image is, and what that text says. You can achieve this using a library called pytessaract. It's an AI that does exactly this for you. It works well because it has been trained on a lot of other images, so it's good in detecting text in any image.\nIf you have labels you might be able to improve your model you could make with pytessaract, but this is a lot harder. If you want to learn it anyway, I would recommend with learning \u0167ensorflow, and use \"transfer learning\" to improve your model.","Q_Score":1,"Tags":"python,machine-learning,deep-learning,classification","A_Id":56047915,"CreationDate":"2019-05-08T19:28:00.000","Title":"How would I go about image labeling\/Classification?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say I have a big_string of length n and I want to remove a substring of length k from its end\nwe can do it as big_string[:-k], but this will be of O(n-k), can we do better than this, something like inO(k)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":56048121,"Users Score":0,"Answer":"If your string is py2 unicode or py3 str, the memoryview idea that @MyNameIsCaleb pointed to won't work, and slices will indeed make copies, which is O(n).\nTrimming the end is fast for mutable types (del m[-k:]), but only string types (which are immutable) support string operations like find(), in, and regular expressions.\nIf trimming the end is a very frequent operation, and using string operations is rare or can be bounded to a small portion of the string, it might be worth the trouble to convert the string once to a list of characters:\nchars = [c for c in big_string]\nTo use string operations on bounded portions, you could convert a slice to a string. For example, to determine whether 'foo' occurs in the last 1000 characters:\n'foo' in  ''.join(chars[-1000:])","Q_Score":1,"Tags":"python,string,slice","A_Id":56049437,"CreationDate":"2019-05-08T19:53:00.000","Title":"Pop a substring from end of string efficiently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am plotting plots on one figure using matplotlib from csv files however, I want the plots in order. I want to somehow use the read_csv method to read the csv files from a directory in the order they are listed in so that they are outputted in the same fashion.\nI want the plots listed under each other the same way the csv files are listed in the directory.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":56048345,"Users Score":2,"Answer":"you could use os.listdir() to get all the files in the folder and then sort them out in a certain way, for example by name(it would be enough using the python built in sorted() ). Instead if you want more fancy ordering you could retrieve both the name and last modified date and store them in a dictionary, order the keys and retrieve the values. So as @Fausto Morales said it all only depends on which order you would like them to be sorted.","Q_Score":1,"Tags":"python,pandas,csv,matplotlib,python-3.7","A_Id":56048584,"CreationDate":"2019-05-08T20:10:00.000","Title":"Is there a way to use the \"read_csv\" method to read the csv files in order they are listed in a directory?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just like the title says, I would like to turn on my raspberry pi and have it automatically open a terminal and that terminal would automatically start a python script. Preferably in a way where I can run 4 different terminals each running a different .py file.\nI have done the rc.local approach but the programs do not open in a terminal and that is essential for the functionality of the code. \nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":56048691,"Users Score":0,"Answer":"Edit the file found here:\n\/etc\/xdg\/lxsession\/LXDE\/autostart\nadd your commands to it\n@python PathToScript\/script.py\nEdit: I realize you want the terminal open. I believe this will work\n@lxterminal --command \"python pathToScript\/script.py\"","Q_Score":0,"Tags":"python,linux,raspberry-pi","A_Id":56048758,"CreationDate":"2019-05-08T20:37:00.000","Title":"How can I open a terminal and run a program in it automatically on my 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 about 1200 tv show categories .. like Drama, News, Sports, Sports-non event, Drama Medical, Drama Crime.. etc\nHow do I use NLP so that I get groups such that Drama, Drama medical and Drama Crime group together and Sports, Sports-non event etc group together and so on... basically the end goal is to reduce the 1200 categories to very few broad categories.\nTill now I have used bag of words to build a dictionary with 146 words..","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":204,"Q_Id":56049055,"Users Score":0,"Answer":"Use a pre trained model to generate embeddings, and from there you can cluster the embeddings using a clustering algorithm like t-SNE or UMAP. I recommend fasttext or spacy, with spacey being the easiest to use.","Q_Score":1,"Tags":"python,python-3.x,nlp,classification,text-classification","A_Id":56049286,"CreationDate":"2019-05-08T21:06:00.000","Title":"How do I group similar categories?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had installed Anaconda on my system before I knew the difference between Anaconda and Miniconda. I would like to downsize to Miniconda since I don't want the bloat of Anaconda, but I already have a handful of environments set up. \nSo far the only way I can think of migrating is to completely get rid of everything right now, install Miniconda, and then recreate my environments by hand, but that seems quite arduous. Is there a smarter way of going about this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1561,"Q_Id":56050217,"Users Score":7,"Answer":"I agree with @darthbith: Export the envs to YAML files (conda env export) then recreate them once you have Miniconda installed (conda env create).\nWhile there are some experimental tools for packaging and moving envs (i.e., so you avoid having to redownload packages), they only work on a single env basis. So, I can't see how going this route one could avoid making multiple copies of many of the shared files.  Instead, if you let Conda handle the environment (re)creation, it will leverage hardlinks to minimize disk usage, and that seems to be one of your aims.\nIt may be possible to avoid redownloading packages during the environment recreations by retaining the pkgs directory in the root of your Anaconda install, then copying its contents over into the pkgs of the Miniconda install. I would only copy folders\/tarballs that don't conflict with the ones that come with Miniconda. After finishing environment recreation, then a conda clean -p would likely be in order, since Anaconda includes many packages that likely aren't getting reused.","Q_Score":8,"Tags":"python,anaconda,conda,miniconda","A_Id":56063972,"CreationDate":"2019-05-08T23:16:00.000","Title":"Downsizing from Anaconda to Miniconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am combining a Monte-Carlo Tree Search with a convolutional neural network as the rollout policy. I've identified the Keras model.predict function as being very slow. After experimentation, I found that surprisingly model parameter size and prediction sample size don't affect the speed significantly. For reference:\n\n0.00135549 s for 3 samples with batch_size = 3\n0.00303991 s for 3 samples with batch_size = 1\n0.00115528 s for 1 sample with batch_size = 1\n0.00136132 s for 10 samples with batch_size = 10\n\nas you can see I can predict 10 samples at about the same speed as 1 sample. The change is also very minimal though noticeable if I decrease parameter size by 100X but I'd rather not change parameter size by that much anyway. In addition, the predict function is very slow the first time run through (~0.2s) though I don't think that's the problem here since the same model is predicting multiple times. \nI wonder if there is some workaround because clearly the 10 samples can be evaluated very quickly, all I want to be able to do is predict the samples at different times and not all at once since I need to update the Tree Search before making a new prediction. Perhaps should I work with tensorflow instead?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2440,"Q_Id":56052206,"Users Score":1,"Answer":"The batch size controls parallelism when predicting, so it is expected that increasing the batch size will have better performance, as you can use more cores and use GPU more efficiently.\nYou cannot really workaround, there is nothing really to work around, using a batch size of one is the worst case for performance. Maybe you should look into a smaller network that is faster to predict, or predict on the CPU if your experiments are done in a GPU, to minimize overhead due to transfer.\nDon't forget that model.predict does a full forward pass of the network, so its speed completely depends on the network architecture.","Q_Score":2,"Tags":"python,performance,keras","A_Id":56053083,"CreationDate":"2019-05-09T04:27:00.000","Title":"Keras tf backend predict speed slow for batch size of 1","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to run pipenv run main.py I am met with the error ImportError: No module named parse.\nI've looked around online but all I can find are people not using the correct python version, but I don't think that is the case here.\nI first run pipenv --three to build the virtualenv using python 3.6.6. After that succeeds I am met with the previously stated error.\nIn my __init.py__ file I'm importing parse through from urllib.parse import urlparse. The threads I can find online about the subject seems to be people using the Python 2 import syntax, but that's not the case here as far as I can tell.\nAny help would be greatly appreciated...","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":728,"Q_Id":56055023,"Users Score":1,"Answer":"The problem is that you are only importing that one function urlparse, not the entire package urllib.parse, so you don't have access to that yet. If you need the entire package you should import it with from urllib import parse.\nYou can also change from urllib.parse import urlparse to from urllib.parse import urlparse as parse if you only need the method, but then you would have clashing name (parse the module and parse the function). This works fine, as you can only access the function parse anyway, but this might get confusing later when you do need the entire package.","Q_Score":1,"Tags":"python,python-3.x","A_Id":56055216,"CreationDate":"2019-05-09T08:15:00.000","Title":"ImportError: No module named parse - Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't quite understand how this works, and I've been searching everywhere but didn't quite find the answer. \nSo when I deploy a django app on heroku the other day I was using daphne with this in the Procfile : \ndaphne app.asgi:application --port $PORT --bind 0.0.0.0 -v2\nThe app works just fine and it make sense (I heard that heroku dynamically assigns the port). But how does the following code knows how to bind it's port, isn't it always 8000 by default ?\n\ngunicorn app.asgi\n\nSorry for the silly question. I'm a newbie in devops stuff","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":56055124,"Users Score":0,"Answer":"No, the port is whatever Heroku wants it to be. Since they're running many many sites, they need to dynamically choose a port to serve each one on. They provide that port in the PORT environment variable, and the Procfile takes that value and binds gunicorn to it.","Q_Score":0,"Tags":"python,django,heroku,gunicorn","A_Id":56055931,"CreationDate":"2019-05-09T08:22:00.000","Title":"What is gunicorn app.wsgi actually doing in heroku?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"When I coded off of Notepad++ a few years ago, a friend of mine set it up so I could run it by doing CTRL+R or F5 and it would run the script that I had open at that time on Notepad++. Every google search I've followed so far on doing this hasn't worked, though most of them were quite dated. Alot of them result in me opening a blank .py application which does not run my code.\nDo I need to download Python to my PATH, as suggested in the installer? The FULL_CURRENT_PATH fix hasn't worked.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1489,"Q_Id":56055443,"Users Score":1,"Answer":"Resolved this. Moved my Python folder into C: and made it point to the following:\ncmd \/k \"C:\\Python\\Python37\\python.exe \"$(FULL_CURRENT_PATH)\"\nThis runs the python script in a command prompt, rather than a .py executable. But it works just the same.","Q_Score":1,"Tags":"python,python-3.x,notepad++","A_Id":56057929,"CreationDate":"2019-05-09T08:39:00.000","Title":"How do I make Notepad++ run my current Python 3 script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to convert a numpy ndarray with a shape of (2200,) to numpy ndarray with a shape of (2200,250,250,1). every single row contains an image (shape: 250,250,1)\nThis is my object:\ntype(x_train_left) prints numpy.ndarray\nx_train_left.shape prints (2200,)\ntype(x_train_left[0]) prints numpy.ndarray\nx_train_left[0].shape prints (250, 250, 1)\nBut for some reason when i try to reshape x_train_left to (2200,250,250,1)  i get the following error:\nValueError: cannot reshape array of size 2200 into shape (2200,250,250,1)\nThank for any help, iv'e searched for duplicated subjects, but they all have different problems.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1841,"Q_Id":56055571,"Users Score":0,"Answer":"I found the very simple solution:\nnp.stack(x_train_left)\nand then when i try:\nx_train_left.shape prints (2200, 250, 250, 1)","Q_Score":1,"Tags":"python,numpy,reshape,shapes,numpy-ndarray","A_Id":56055689,"CreationDate":"2019-05-09T08:46:00.000","Title":"cannot reshape array of size (x,) into shape (x,y,z,1)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have several trained Keras models, weights stored in h5 files using keras.models.save_model. They do not have the same architecture.\nMy goal is to load all of them in separate processes and be able to predict. I currently try doing this using a class which stores a TensorFlow session and graph object. I then use with statements at loading time and prediction time to prevent interference with any global variables.\nI can create my (empty) Keras Sequential model without problems, but when I call its load_weights function, the process just freezes.\nSetups with Graph and Session objects I tried:\n\nspecific Graph and Session -> process freezes on load_weights\nspecific Graph only -> \"TypeError: Cannot interpret feed_dict key as Tensor\"\nspecific Session only -> process freezes on load_weights\n\nI have been through most of the related answers on SO but have not been able to find a solution or even someone with the same problem.\nThanks for your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":713,"Q_Id":56055769,"Users Score":0,"Answer":"I still don't know the exact cause of the problem. However, I found out that my main process was loading a keras model and removing that solved my problem. I can now have multiple models running in parallel.","Q_Score":0,"Tags":"python,tensorflow,keras,multiprocessing,python-multiprocessing","A_Id":56058663,"CreationDate":"2019-05-09T08:57:00.000","Title":"Load multiple Keras models in different processes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am debuging a script in PyCharm. I am changing the code and run it again and again. Importing modules takes a lot of time, more than execution time of other lines of my code. I would like to avoid wasting time on importing modules. Something like restarting needed cells of my code  without restarting the python kernel in scientific mode, but staying in normal mode. Can I do it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":56056518,"Users Score":0,"Answer":"You can maintain the imported state either by using the debugger or the console. \nThe easiest way is to execute selections in the console after importing the modules. Select (or place the caret in) lines of code and press alt+shift+e.\nIn the debugger, you can evaluate expressions or alter code after modules have already been imported by setting breakpoints.\nEither of these could be simplified by placing the desired modules in the __init__.py file.","Q_Score":0,"Tags":"python,ide,pycharm,python-import","A_Id":56098065,"CreationDate":"2019-05-09T09:37:00.000","Title":"How to avoid wasting time on importing modules when I restart my code multiple times?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I Have a python script that monitors a website, and I want it to send me a notification when some particular change happens to the website.\nMy question is how can I make that Python script runs for ever in some place else (Not my machine, because I want it to send me a notification even when my machine is off)?\nI have thought about RDP, but I wanted to have your opinions also.\n(PS: FREE Service if it's possible, otherwise the lowest cost)\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":724,"Q_Id":56056794,"Users Score":1,"Answer":"I would suggest you to setup AWS EC2 instance with whatever OS you want. \nFor beginner, you can get 750 hours of usage for free where you can run your script on.","Q_Score":0,"Tags":"python,web-services,monitoring,network-monitoring","A_Id":56057837,"CreationDate":"2019-05-09T09:52:00.000","Title":"How to make a python script run forever online?","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 function (we can call it f(x)), that will give me a number.\nThe value of x is between 0 and 1: f(0) will find the biggest number, f(1), the smallest.\nBut I don't know if, for example, f(0.2) will give me a different number from f(0); so I have to do a research to find all the number using binary search.\nI know that I can iterate from x = 0 to x = 1, but I want to do less function call possible.\nHave you any suggest?\nI can start by calling f(0), f(1), f(0.5), and then f(0.25) or f(0.75) and so on and so on.\n(Mathematically I can divide x endlessly, here I can choose a precision limit)","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":46,"Q_Id":56057752,"Users Score":3,"Answer":"First you must be sure that the function is monotone. If this is not sure you cannot use a binary search.  \nSecondly define the accuracy you want.\nThan perform the binary search until no improvement is made or the desired accuracy is reached.","Q_Score":0,"Tags":"python,algorithm,binary-search,function-call","A_Id":56058267,"CreationDate":"2019-05-09T10:50:00.000","Title":"Is possible to make a binary search by searching between unknown values?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to learn HTML transformations performed by a certain service using machine learning. I have broken down my problem into a pattern matching problem. For now I am trying to learn pattern in which tags are transformed. For example, for same data I have this pattern in original HTML \"html, body, div, h1\" and following pattern in transformed page \"html, body, div, div, div\". I have 14000 such data points and I want to train a model that would take as input patterns from original page and output transformed patterns. I have looked into a few NLP model but either I have failed to understand them completely or they were not very helpful.\nIf someone could give me any pointers or preferably suggest some python based model that would be great.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":56066929,"Users Score":0,"Answer":"your question is not clear enough to help you with some answer but still from what I was able to figure out your input will be html tags in a string pattern & your output too is a string pattern of html tags.\nYou can use a bi-directional LSTM or CRF for this kind of task. Read about them and you'll have a clear idea.\nBut if same input pattern is giving multiple output pattern then it will be difficult for most ML algos to learn. You can remove those data points and you'll be good to go.","Q_Score":0,"Tags":"python,machine-learning","A_Id":56236394,"CreationDate":"2019-05-09T20:16:00.000","Title":"A machine learning model for matching pattern between two sets of strings?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a problem I am trying to solve:\n- imbalanced dataset with 2 classes\n- one class dwarfs the other one (923 vs 38)\n- f1_macro score when the dataset is used as-is to train RandomForestClassifier stays for TRAIN and TEST in 0.6 - 0.65 range\nWhile doing research on the topic yesterday, I educated myself in resampling and especially SMOTE algorithm. It seems to have worked wonders for my TRAIN score, as after balancing the dataset with them, my score went from ~0.6 up to ~0.97. The way that I have applied it was as follows:\n\nI have splited away my TEST set away from the rest of data in the beginning (10% of the whole data)\nI have applied SMOTE on TRAIN set only (class balance 618 vs 618)\nI have trained a RandomForestClassifier on TRAIN set, and achieved f1_macro = 0.97\nwhen testing with TEST set, f1_macro score remained in ~0.6 - 0.65 range\n\nWhat I would assume happened, is that the holdout data in TEST set held observations, which were vastly different from pre-SMOTE observations of the minority class in TRAIN set, which ended up teaching the model to recognize cases in TRAIN set really well, but threw the model off-balance with these few outliers in the TEST set.\nWhat are the common strategies to deal with this problem? Common sense would dictate that I should try and capture a very representative sample of minority class in the TRAIN set, but I do not think that sklearn has any automated tools which allow that to happen?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":162,"Q_Id":56069657,"Users Score":2,"Answer":"Your assumption is correct. Your machine learning model is basically overfitting on your training data which has the same pattern repeated for one class and thus, the model learns that pattern and misses the rest of the patterns, that is there in test data. This means that the model will not perform well in the wild world.\nIf SMOTE is not working, you can experiment by testing different machine learning models. Random forest generally performs well on this type of datasets, so try to tune your rf model by pruning it or tuning the hyperparameters. Another way is to assign the class weights when training the model. You can also try penalized models which imposes an additional cost on the model when the misclassify the minority class.\nYou can also try undersampling since you have already tested oversampling. But most probably your undersampling will also suffer from the same problem. Please try simple oversampling as well instead of SMOTE to see how your results change.\nAnother more advanced method that you should experiment is batching. Take all of your minority class and an equal number of entries from the majority class and train a model. Keep doing this for all the batches of your majority class and in the end you will have multiple machine learning models, which you can then use together to vote.","Q_Score":0,"Tags":"python,scikit-learn,dataset,resampling,oversampling","A_Id":56082079,"CreationDate":"2019-05-10T01:43:00.000","Title":"ML with imbalanced binary dataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to make a program that can be able to make a search request on most websites such as YouTube, ESPN, My university course timetable etc... \nI have looked online for various solutions but many of them point to simply adding your search query at the end of the url you are \"getting\", but that doesn't seem to work with all websites some of them don't update their URL's when you manually make a search, while many others might give each and every URL a unique 'id'. Would it be possible to scrape a search bar from any website and then specifying a search query and entering it? Is there a function for that?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":557,"Q_Id":56075283,"Users Score":0,"Answer":"It's possible to use a text-based web browser and automate the search with a script. Then you can download the site you get from this browser and scrape it with BeautifulSoup or something else.","Q_Score":0,"Tags":"python,beautifulsoup,request,python-requests","A_Id":56075364,"CreationDate":"2019-05-10T10:02:00.000","Title":"Is there any way to scrape a search box using BeautifulSoup\/requests and then search and refresh?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to make a program that can be able to make a search request on most websites such as YouTube, ESPN, My university course timetable etc... \nI have looked online for various solutions but many of them point to simply adding your search query at the end of the url you are \"getting\", but that doesn't seem to work with all websites some of them don't update their URL's when you manually make a search, while many others might give each and every URL a unique 'id'. Would it be possible to scrape a search bar from any website and then specifying a search query and entering it? Is there a function for that?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":557,"Q_Id":56075283,"Users Score":1,"Answer":"You need to Use Selenium Instance to do that. You can not achieve it using BeautifulSoup or requests.","Q_Score":0,"Tags":"python,beautifulsoup,request,python-requests","A_Id":56075496,"CreationDate":"2019-05-10T10:02:00.000","Title":"Is there any way to scrape a search box using BeautifulSoup\/requests and then search and refresh?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've had troubles in setting up a conda virtual environment specifically intended to collect Deep Learning packages.\nI read loads of tutorials, I also uninstalled and reinstalled Anaconda some times to make sure everything during the installation had been set properly. \nI finally ended up with a virtual environment, say DLenv, in which jupyter notebook could not be launched (it simply did not run whatsoever. Browser used to open, but the jupyter home page did not load at all). After some researches I found out a possible solution in uninstalling pyzmq, installing it again and then installing again jupyter. \nAfter launching the command \n(DLenv) C:\/Users\/...\/folder > jupyter notebook\nthe following message showed up:\nUnable to create process using 'C:\\Users\\Matteo\\Anaconda3\\envs\\DLenv\\python.exe C:\\Users\\Matteo\\Anaconda3\\envs\\DLenv\\Scripts\\jupyter-script.py notebook'\nI somewhat felt the suspect that it was in some way due to the fact that the DLenv environment had few to do with the Anaconda installation step, when the user is asked whether include Anaconda in path variables or not. So I added both the paths of the object referred to in the above error to environment variables in my system but that still did not work. Finally I had the idea of copying the python.exe file referred to in the first part of the error in the second location mentioned, that is, in the directory dedicated to the new virtual environment.\nNow it seems to work, in that from the DLenv jupyter notebook is lanched, kernel does not have connection issues. \nMy question then is: why on earth the python.exe object was required to be in the virtual environment folder and why it has not been moved there automatically during environment creation stage?\nShall I do the same iter every time a new environment is created?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":56076687,"Users Score":1,"Answer":"The proper way to interface with Jupyter and Conda envs is to only install the jupyter package in a single env, which if you are using Anaconda already is base. You also need to install nb_conda_kernels in that env. Then, for every other env that you want to use as a kernel you install ipykernel. Launch jupyter notebook from the env that has it (base), and the other envs will be available as kernels.\nThere should be no manual manipulation of your PATH environment variable since Conda v4.4. Conda has its own internal tooling for managing this, and messing with it can lead to unexpected behavior.","Q_Score":0,"Tags":"python,jupyter-notebook,anaconda,conda","A_Id":56079291,"CreationDate":"2019-05-10T11:22:00.000","Title":"Needed path variables for different conda virtual environments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to build a system, in which I want to use both Python and C. Python will be used for GUI on wxPython module and C will be used to handle backend processes. I have some pre-built C functions which will be rearranged and sent to a C compiler as files by the GUI. After compilation is done, the resulting file will be given as an argument to another executable and run the executable.\nI've tried to run some exe from inside Python. Now I'm looking for an IDE which supports working with both the languages simultaneously i.e. coding and debugging.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":169,"Q_Id":56082628,"Users Score":1,"Answer":"You could try using Eclipse. You can install Python and C\/C++ on it.","Q_Score":0,"Tags":"c,python-3.x,vscode-debugger","A_Id":56082687,"CreationDate":"2019-05-10T17:55:00.000","Title":"Is there any IDE where I can debug C and Python codes simultaneously?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make a simple quote bot which needs to know about addresses and dimensions. Currently I have hacked one together with a python state machine and rasa NLU for the intent stuff, though the nature of the data means most of the entities are better extracted by hand.\nFor example, an opening sentence might be \"i want to send 4 boxes from A postcodeA to B postcodeB they're 3 by 3 by 3m each\". These addresses need to be validated, which may involve a back and forth (did you mean this postcode, or maybe that state? This isn't a valid match, please choose from this list, etc...). \nAdditionally, the order of the validation might be weird. For example, one could have a suburb, postcode, and is_valid slot. There are several possibilities: they could enter a valid S + P, just S, an invalid S alone, a valid S and P which are individually valid but not a match, etc. In some cases I want to defer validation to make use of other information, for example if an invalid suburb was given but a valid postcode, i would use the postcode to inform suggestions for the correct suburb. However, if an invalid suburb was given but no postcode, there is no point asking for a postcode because i would want to get a valid suburb first. In this way having a slot ordering of 'suburb', 'postcode', 'is_valid' doesn't quite cut it as far as i can tell. \nI suppose the validation call for suburb and postcode can just have their own set of switch statements which look at the other slots which may have been filled at the same time? Seems a bit chicken and egg, as would need to wait for validation of those as well, and may end up requiring calling Lambda's from within Lambda's. For example, if the validation fails, the bot asks for more info, but the validation of that info may require a different process\/lambda than the original input\nIt could also be they don't include any details about the object, in which case it needs to be prompted for later after the address stuff is all sorted out. For example, if they fail to include info about dimensions i want to ask 'what're the dimensions' and allow them to either include just measurements or weights and quantities as well - this i understand as standard slot filling.\nSo my question is: how difficult\/reasonable is it to have validation calls in Lambdas actually lead to side-paths in the conversation? Previously i had done something like this in a slot-filling setting by having 'is_valid' slots all over the place (especially if I don't want to simply throw an 'isn't valid' error and robotically re-ask the original question'). Is there a better way?\nAlso, how would one manage 'interrupt' intents? That is, a set of intents which would trigger 'do you want to go restart?' kind of questions, which will return to the original state if the user replies 'no', and, ideally, if they say yes can return to a specific point in the conversation (which i imagine would be achieved by just resetting appropriate slots to empty)\nAlso, not wedded to the idea of Amazon Lex, any of the pre-canned cases which reduce amount of boiler plate code are good too.\nApologies for word vomit.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":434,"Q_Id":56085615,"Users Score":1,"Answer":"Wow, ok here's what I can offer:\n1. Validation Difficulty\n\nhow difficult\/reasonable is it to have validation calls in Lambdas actually lead to side-paths in the conversation?\n\nBuilding a complex validation and conversation algorithm is standard practice for Lex Developers of service bots. So it is very reasonable to expect to have to do that yourself either in Lambda, or somewhere else and just use Lambda as a go-between. So the difficulty lies in your hands, and maybe you can find APIs that you can use to validate addresses and postal codes like Google Maps to make that part easier.\n2. 'is_valid' Slots\n\nPreviously i had done something like this in a slot-filling setting by having 'is_valid' slots all over the place (especially if I don't want to simply throw an 'isn't valid' error and robotically re-ask the original question'). Is there a better way?\n\nLex does have a better way: sessionAttributes! A good practice is to only create slots for holding the values you need to fulfill each intent. For anything else, you can happily rely on sessionAttributes to keep track of the conversation path, slot validity, slot history, intent history, interruption intents, etc, etc, etc, as much as you can imagine. It's completely up to you how to organize your bot logic and keep track of current and past states of the convo there.\nFor example: You could have slot: postalCodeA\nAnd in sessionAttributes also have: postalCodeA_valid, postalCodeA_confirmed, postalCodeA_attempts etc.\nAnd use those sessionAttributes values to determine the conversation path in your logic. When you find a slot is invalid, you could save that value in an ..._attempts or ..._history list in sessionAttributes, then set ..._valid to false, and reset the slot to null, and re-elicit that slot with a message explaining why it was invalid, or try to elicit an address slot instead of a postal code slot.\n3. Interrupt Intents\n\nAlso, how would one manage 'interrupt' intents? That is, a set of intents which would trigger 'do you want to go restart?' kind of questions\n\nAs I hinted at earlier, the answer to this is also sessionAttributes! When your user is inside of one intent (intentA), Lex will first attempt to fill the current elicit slot with their input, but if it doesn't match, Lex will also check if the input matches a different intent's utterances. So you could have an interrupt intent (intentB) with utterances like \"let's start over\", \"nevermind\", \"back up\", etc. Then in all of your normal intents, you keep a backup of that intent's slot values in sessionAttribtues, as well as something like last_intent to know where a user was previously in case it changes.\nThis would allow you to handle interrupt intents like this:  \n\nuser enters intentA  \nintentA fills some slots, and backs them up in sessionAttributes \nuser says \"lets start over\" triggering intentB  \nintentB asks for confirmation of canceling intentA\n\n(Yes) intentB fulfills the intent after erasing intentA values from sessionAttributes and returns user to start with elicitIntent and asks \"how else may I help you?\"\n(No) intentB passes the user back to intentA (which you know because you kept track of sessionAttributes.last_intent) and send a confirmation of continuing with intentA with confirmIntent: \"Alright, I still remember where we left off, would you like to continue {intentA action}?\" (the response will be sent to intentA, where you can handle  that). \n\n(if user wants to continue with intentA) intentA fills the new empty slots from sessionAttributes and uses other sessionAttributes values to continue through your algorithm to the point where it left off, delivering the same elicit slot that it was last on, and the user is impressed with your bot's intelligence. =)","Q_Score":2,"Tags":"python,amazon-lex","A_Id":56087720,"CreationDate":"2019-05-10T22:35:00.000","Title":"Stagged validation\/parsing in Amazon Lex","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my CTF environment, if I want to access an application in a server, I have to perform SSH. Here's what it looks like:\n\n(my terminal) ssh username@ssh_ip\nenter password\n\nThe steps start to annoy me because if I have to access the same application more than once, I have to perform these steps multiple times.\nThus, I want to create a script that does this automatically, like '.\/run_everything', which will autorun everything and immediately brings me to the application CLI instantly.\nWhat kind of python library that can do this? I'm not asking for someone to make it for me, but more like asking for advice like what libraries to use and stuff.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":251,"Q_Id":56086866,"Users Score":1,"Answer":"Try python api of iTerm2 or use some packages like paramiko.","Q_Score":1,"Tags":"python,python-3.x","A_Id":56087036,"CreationDate":"2019-05-11T03:12:00.000","Title":"Script for SSH OverTheWire","Data Science and Machine Learning":0,"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":"Error creating Django application: Error on python side. Exit code: 1, err: CommandError: 'untitled1' conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":464,"Q_Id":56086881,"Users Score":0,"Answer":"uninstall django and delete you directories then install again you can do this on cl: pip uninstall django\nthen cl: pip install django\nhopefully this should work","Q_Score":1,"Tags":"python,django,python-3.x,pycharm","A_Id":56097701,"CreationDate":"2019-05-11T03:15:00.000","Title":"How to fix module name conflict in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Error creating Django application: Error on python side. Exit code: 1, err: CommandError: 'untitled1' conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":464,"Q_Id":56086881,"Users Score":0,"Answer":"which version of python are you using? upgrade your version of django or downgrade your version of python and this should solve the problem.\nyou can do in cl:  python --version\nif you are using a newer version of python to run a project in \ncl: alias python='python3'\nThis should work if you have the correct setup","Q_Score":1,"Tags":"python,django,python-3.x,pycharm","A_Id":56087455,"CreationDate":"2019-05-11T03:15:00.000","Title":"How to fix module name conflict in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm cloning two separate repositories from github:\n\na framework\nsome modules that are based on the framework\n\nHow can I add both of them in Pycharm projects, so the modules (in the second package) recognize the files(imports) from the framework(1).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":56087366,"Users Score":0,"Answer":"You can have PyCharm including more directories to PYHTONPATH by adding a content root.\nOpen the menu entry File -> Settings. Select Project: (your project), then Project Structure. On the right pane, you can add the root of the second repository as another content root.\nIn the run configuration, make sure that \"Add content roots to PYTHONPATH\" is checked (this should be checked by default).\nContent roots must be disjoint (i.e. the second repository should not be checked out in a subdirectory of the first). If this is not the case, there is also the option of fine tuning your PYTHONPATH by marking individual directories as source in the above Project Structure window (related run configuration setting \"Add source roots to PYTHONPATH\").","Q_Score":0,"Tags":"python,pycharm","A_Id":56088116,"CreationDate":"2019-05-11T05:06:00.000","Title":"How can in ad in Pycharm 2 cloned repositories from github(interdependent) under the same project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to find the minimum of a function which is piecewise linear, convex and differentiable at all but a finite number of points. What scipy.optimize.minimize method is appropriate to find a fast solution to my problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":146,"Q_Id":56090155,"Users Score":2,"Answer":"If the function is piecewise linear and convex, the minimum must be at one of the points where the linear pieces are connected. There is no need for a derivative, you should be able to use a binary search.","Q_Score":0,"Tags":"python,scipy","A_Id":56090218,"CreationDate":"2019-05-11T12:02:00.000","Title":"Minimize a piecewise linear, convex function with scipy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I have 2 dataframe:\nDF1:\nCol1 | Col2 | Col3\nXCN000370\/17-18C | XCN0003711718C | 0003971718\nDF2\nCol1 | Col2 | Col3\nXCN0003711718C | XCN0003711718C | 0003971718\nI want them to merge like this:\n\nFirst Match Col1 (DF1) and Col1 (DF2)\nIn Remaining Unmatched, Match Col1 (DF1) with Col2 (DF2)\nIn remaining Unmatched, Match Col1 (DF1) with Col3 (DF2)\n\nNow repeat this by exchanging DF1 and DF2 with remaining unmatched\n\nIn Remaining Unmatched Match Col1 (DF2) and Col1 (DF1)\nIn Remaining Unmatched, Match Col1 (DF2) with Col2 (DF1)\nIn remaining Unmatched, Match Col1 (DF2) with Col3 (DF1)\n\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":147,"Q_Id":56090979,"Users Score":0,"Answer":"I don't think that there is one line code to do this. So follow the steps.\n1) First, create a list:\ndfs = []\n2) Merge for each condition on dataframe:\ndfs.append(pd.merge(df1,df2,left_on='col1',right_on='col1',how='outer')).dropna()\ndfs.append(pd.merge(df1,df2,left_on='col1',right_on='col2',how='outer')).dropna()\ndfs.append(pd.merge(df1,df2,left_on='col1',right_on='col3',how='outer')).dropna()\n^ repeat\n3) Now concatenate them:\npd.concat(dfs)","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":56091221,"CreationDate":"2019-05-11T13:53:00.000","Title":"Pandas Merge Dataframes Sequentially on Conditions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I get a list of row lables in pandas?\nI have a table with column labels and row labels. To return the column lables I use the dataframe \"column\" attribute.\nIt is possible to return the list of column labels with the attribute columns, but i couldn't find similiar attributes for rows.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10189,"Q_Id":56092914,"Users Score":4,"Answer":"This should work. df.index.values\nThis returns index in the form of numpy array numpy.ndarray, run this type(df.index.values) to check.","Q_Score":3,"Tags":"python-3.x,pandas","A_Id":56092947,"CreationDate":"2019-05-11T17:53:00.000","Title":"How to get list of rows of pandas dataframe in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it correct to expect a Conda environment to provide complete isolation and containment for pip\/pipenv usage?\nLet's say I create and activate a Conda environment and name it \"pip-pip\", then proceed with my project, which uses pipenv, while completely ignoring the fact that this is happening with a Conda environment activated.\n\nWill all traces of that pipenv project be contained in \"pip-pip\", or is there a possibility of a spillover?\nWill the fact that pip\/pipenv is used from within \"pip-pip\" negatively affect the experience in any way?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":828,"Q_Id":56094614,"Users Score":1,"Answer":"This arrangement should work fine, as long as your shell and environment variables are configured correctly.\nIf you try to activate the Pipenv without the \"Pip-pip\" Conda environment active, you might have breakage or other unpredictable behavior, as Pipenv was installed with one Python and is being run with another. The extent of the breakage depends on the implementation details of Pipenv.\nAs a general rule, it should be possible to nest such \"environment\" programs arbitrarily, as long as they are well-designed, and as long as you activate the chain of environments in the order that they were originally installed. Whether this negatively affects your experience depends on your tolerance for annoyance.\nHowever, Pipenv by default creates virtual environments in a global location. I'm not sure what that location is, but it's possible that you could end up with Pipenv environments installed alongside each other that depend on different Python versions. This, I think, might constitute \"spillover\" in the sense of your question.","Q_Score":4,"Tags":"python,pip,conda,pipenv","A_Id":56094724,"CreationDate":"2019-05-11T22:04:00.000","Title":"How isolated is pip\/pipenv in a conda environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently, I am learning Django and I am wondering why most courses use sessions for shopping carts instead of storing them to the database.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":56094677,"Users Score":0,"Answer":"Sessions are relative to the user's current session and it may be convenient to erase all history in case the session expired\/ user is logged out.","Q_Score":0,"Tags":"python,django","A_Id":56095890,"CreationDate":"2019-05-11T22:15:00.000","Title":"Why use sessions for shopping carts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I used gridsearchcv to determine which hyperparameters in the mlpclassifier can make the accuracy from my neural network higher. I figured out that the amount of layers and nodes makes a difference but I'm trying to figure out which other configurations can make a difference in accuracy (F1 score actualy). But from my experience it lookes like parameters like \"activation\", \"learning_rate\", \"solver\" don't really change anything. \nI need to do a research on which other hyperparameters can make a difference in the accuracy from predictions via the neural network. \nDoes someone have some tips\/ideas on which parameters different from the amount of layers \/ nodes that can make a difference in the accuracy from my neural network predictions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":490,"Q_Id":56094779,"Users Score":1,"Answer":"It all depends on your dataset. Neural network are not magical tools that can learn everything and also they require a lot of data compared to traditional machine learning models. In case of MLP, making a model extremely complex by adding a lot of layers is never a good idea as it makes the model more complex, slow and can lead to overfitting as well. Learning rate is an important factor as it is used to find the best solution for the model. A model makes mistakes and learns from it and the speed of learning is controlled by learning rate. If learning rate is too small, your model will take a long time to reach the best possible stage but if it is too high the model might just skip the best stage. The choice of activation function is again dependent on the use case and the data but for simpler datasets, activation function will not make a huge differnece.\nIn traditional deep learning models, a neural network is build up of several layers which might not always be dense. All the layers in MLP as dense i.e. feed forward. To improve your model, you can try a combination of dense layers along with cnn, rnn, lstm, gru or other layers. Which layer to use depends completely on your dataset. If you are using a very simple dataset for a school project, then experiment with traditional machine learning methods like random forest as you might get better results.\nIf you want to stick to neural nets, read about other types of layers, dropout, regularization, pooling, etc.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,neural-network,classification","A_Id":56096067,"CreationDate":"2019-05-11T22:33:00.000","Title":"How to evaluate\/improve the accuracy from the prediction from a neural network with an unbalanced dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a simple feed forward Neural Network library in Java - and I need a benchmark to compare and troubleshoot my library. \nComputer specs: \n\nAMD Ryzen 7 2700X Eight-Core Processor \nRAM 16.0 GB\nWINDOWS 10 OS  \nJVM args: -Xms1024m -Xmx8192m\n\nNote that I am not using a GPU. \nPlease list the following specs:\n\nComputer specs?\nGPU or CPU (CPU is proffered but GPU is good info) \nNumber of inputs 784 (this is fixed)\nFor each layer: \n\n\nHow many nodes? \nWhat activation function?\n\nOutput layer:\n\n\nHow many nodes? (10 if classification or 1 as regression)\nWhat activation function?\n\nWhat loss function?\nWhat gradient descent algorithm (i.e.: vanilla) \nWhat batch size?\nHow many epochs? (not iterations)\nAnd finally, what is the training time and accuracy? \n\nThank you so much\nEdit \nJust to give an idea of what I am dealing with. I created a network with \n\n784 input nodes\n784 in hidden layer 0\n256 in hidden layer 1\n128 in hidden layer 2\n1 output nodes\nmini-batch size 5\n16 threads for backprop\nAnd it has been training for ~8 hours and has only completed 694 iterations - that is not even 20% of one epoch. \n\nHow is this done in minutes as I've seen some claims?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1145,"Q_Id":56095288,"Users Score":0,"Answer":"am not really clear about the benchmark you're looking for, there is it performance from training perspective, or accuracy? for accuracy, there are some tools that can do the comparison between the predictions and actuals so you can measure the performance","Q_Score":0,"Tags":"python,tensorflow,neural-network,mnist","A_Id":63011554,"CreationDate":"2019-05-12T00:28:00.000","Title":"MNIST training time in CPU","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Windows 10 Home 64-bit. In the Control Panel > Programs and Features menu, I can see that I have Python 3.5.2 (Anaconda 4.1.1 64-bit) installed. As I wanted to upgrade Python 3.5 to Python 3.6, I then ran this command in Anaconda Prompt conda install python=3.6.8. After the upgrading\/installing process in Anaconda Prompt was finished, I ran this command python -V and it showed Python 3.6.8 :: Anaconda 4.1.1 (64-bit). However, when I refreshed the Control Panel > Programs and Features menu, it still showed Python 3.5.2 (Anaconda 4.1.1 64-bit). I then ran this command conda info --envs and it showed I only have the base environment.\nCould anyone please advise:\n\nWhy are there two different information of Python versions in this case?\nWhich Python version is actually installed in my laptop?\nIn my Jupyter Lab Launcher, under Notebook section, I can see two Python symbols: Python 3 and Python [conda env:root]*. What are the differences between these two and which one should I use to launch a new notebook?\n\nThankyou!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":56096001,"Users Score":0,"Answer":"Conda creates virtual environment inside your machine. The python version is different inside conda. If you want install different python inside conda you can decide the python at the time of creation of environment.\nconda create -n TestEnv python=3.6.8\n\nIf you want update the python inside conda virtual environment, activate the virtual environment using\n\nconda activate TestEnv\n\nNow you can see the python version of your virtual environment\nDeactivate your virtual environment and check python version using python -V this is the version of your Laptop Python or base version of python.","Q_Score":0,"Tags":"python,anaconda","A_Id":56096094,"CreationDate":"2019-05-12T03:30:00.000","Title":"Python version in Programs and Features is different to that in Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a tool generates dummy binary files for a project. We have a spec that describes the real binary files, which are created from a stream of values with various bit lengths. I use input and spec files to create a list of values, and the bitstring library's BitArray class to convert the values and join them together.\nThe problem is that the values' lengths don't always add up to full bytes, and I need the file to contain the bits as-is. Normally I could use BitArray.tofile(), but that method automatically pads the file with zeroes at the end.\nIs there another way how to write the bits to a file?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":990,"Q_Id":56098610,"Users Score":0,"Answer":"You need to give padding to the, say 7-bit value so it matches a whole number of bytes:\n1010101 (7 bits) --> 01010101\n1111 (4 bits) --> 00001111\nThe padding of the most significant digits does not affect the data taken from the file.","Q_Score":2,"Tags":"python,binaryfiles,binary-data,bitstring","A_Id":56099355,"CreationDate":"2019-05-12T11:06:00.000","Title":"How to write binary file with bit length not a multiple of 8 in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently learning gensim doc2model in Python3.6 to see similarity between sentences.\nI created a model but it returns KeyError: \"word 'WORD' not in vocabulary\" when I input a word which obviously exists in the training dataset, to find a similar word\/sentence.\nDoes it automatically skip some words not very important to define sentences? or is that simply a bug or something?\nVery appreciated if I could have any way out to cover all the appearing words in the dataset. thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":358,"Q_Id":56106821,"Users Score":0,"Answer":"If a word you expected to be learned in the model isn't in the model, the most likely causes are:\n\nit wasn't really there, in the version the model saw, perhaps because your tokenization\/preprocessing is broken. Enable logging at INFO level, and examine your corpus as presented to the model, to ensure it's tokenized as intended\nit wasn't part of the surviving vocabulary after the 1st vocabulary-survey of the corpus. The default min_count=5 discards words with fewer than 5 occurrences, as such words both fail to get good vectors for themselves, and effectively serve as 'noise' interfering with the improvement of other vectors. \n\nYou can set min_count=1 to retain all words, but it's more likely to hurt than help your overall vector quality. Word2Vec & Doc2Vec require large, varied corpuses \u2013 if you want a good vector for a word, find more diverse examples of its usage in an expanded corpus. \n(Also note: one of the simple & fast Doc2Vec modes, that's also often a top-performer, especially on shorter texts, is plain PV-DBOW mode: dm=0. This mode will allocate\/randomly-initialize word-vectors, but then ignores them for training, only training the doc-vectors. If you use that mode, you can still request word-vectors from the model at the end \u2013 but they'll just be random nonsense.)","Q_Score":0,"Tags":"python,gensim,doc2vec","A_Id":56117031,"CreationDate":"2019-05-13T06:29:00.000","Title":"gensim doc2vec Model doesn't learn some words","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script that reads from a google sheet and uses the information to create tickets using the Jira python api. In my situation it won't work to have the script be triggered at a certain time, the script has to be triggered through the sheet. Is there some way to detect a button press or a cell change which runs my local python file?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":948,"Q_Id":56107330,"Users Score":1,"Answer":"I had a similar problem. \nthere is a tool set call 'gspread', which can read from python data from your Google sheets.\nWhat I did is a script in the spread sheet, what filled a cell with \"Start + time\". You can trigger script with this with a button.\nNow the python program read this cell every minute. If the cell contains the start trigger, if fires the python script. \nNot the nicest solution, but it works for a few years now.","Q_Score":2,"Tags":"python,python-3.x,google-sheets","A_Id":56109784,"CreationDate":"2019-05-13T07:11:00.000","Title":"Is it possible to run a python script 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":"Visual Studio Code by default has sensible pylint settings that limits the number of pylint messages that are output.\nIs there any way to easily trigger a \"pylint run\" including the tests that are disabled by vscode by default either on all modules or on an individual module without messing with the vscode settings every time?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":56108631,"Users Score":1,"Answer":"Unfortunately there isn't a way to temporarily flip the linting cap for just a single lint check.","Q_Score":0,"Tags":"python,visual-studio-code,pylint","A_Id":56194093,"CreationDate":"2019-05-13T08:41:00.000","Title":"Temporarily enable exhaustive pylint messages 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":"I want to be able to find which of my samples were wrongly classified by KNN, or which weren't classified at all. \nI have used sckit-learn to run KNN. I have a df that has ~280000 samples split into four groups, I have 13 features by which to classify by. My precsion per group ranges from 0.30-0.90. \nI expect the output to say which group each sample belongs to and which group it was classified into. \nthanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":56111669,"Users Score":0,"Answer":"So as I'm understanding the question right you have the true group classification for your data.\nIn that case you can predict your whole dataset with your trained model and identify the outliers.","Q_Score":0,"Tags":"python,machine-learning,knn,nearest-neighbor","A_Id":56430302,"CreationDate":"2019-05-13T11:47:00.000","Title":"Identify what group KNN classified a sample in","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to solve an equation of the form yB = c, where y is my unknown (possibly a matrix). However the B matrix is not well conditioned, and I would like to have a method similar to numpy.linalg.solve in order to maintain the numerical accuracy of the solution.  \nI have tried to simply use the inverse of B, with numpy.linalg.inv, to find the solution y = cB^-1 as well as using the pseudo-inverse (numpy.linalg.pinv), but they prooved to be not accurate enough...\nI have also looked into the QR decomposition, since numpy provides the method for it, in order to adapt it to the right inverse case, but here I struggle with the algebra.\nIs there an accurate way to solve this equation ? Or is there an equivalent to numpy.linalg.solve for the right inverse ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":56113772,"Users Score":1,"Answer":"You can transpose the equation and then use linalg.solve.","Q_Score":2,"Tags":"python,numpy","A_Id":56113906,"CreationDate":"2019-05-13T13:48:00.000","Title":"Is there a way to solve yB = c without computing the right inverse?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently working on a project that involves crawling data from various (about 50 websites). There is one website which has multiple pages we need to scrape, but this website doesn't allow multiple session. (the website is authenticated). \nIs there a way to pause the one spider until the other one is finished?\nI've been researching this for the past day. I found some ways you can pause, but it seems these are only working for the whole CrawlerProcess.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":56114106,"Users Score":0,"Answer":"The solution was actually fairly easy. Each spider has a unique identifying code. When setting the CrawlerProcess up, the program checks if the unique code is the same as the one that needs pausing, and if so, it passes the spider instance to the spider that needs to run first, which will then pause it with self.custom_settings['XX_SPIDER'].crawler.pause() and when done, in the closed() function, will unpause it with self.custom_settings['XX_SPIDER'].crawler.unpause()","Q_Score":0,"Tags":"python,scrapy","A_Id":56518384,"CreationDate":"2019-05-13T14:07:00.000","Title":"Pausing individual spiders in a CrawlerProcess","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to render a image to a docx template which has a jinja hook in it.\nI am using inlineImage method from docx template using this I was able to render image it is opening in libreoffice writer but not in msword where it should be really using.\nIn msword a image is rendered but not shown just a blank area is shown.\nI do even tried using the subdoc method it is also giving me same results.\nPlease do help me understand what am doing wrong.\nI am using python-docx 0.8.7 and docxtemplate 0.5.17 library to achieve the result\nI am bound to use these versions since docxtemplate enforced to use this version of python-docx","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":955,"Q_Id":56116387,"Users Score":1,"Answer":"I am posting this as an answer so that it may help others trying to achieve the same.\nIn my code i was using NamedTemporaryFile(delete=None) to create the image before I pass the value to inlineimage as InlineImage(template, tmpfile.name) Which was causing the Issue , I remodelled my logic to directly add the image after doing some resize based on image aspect ratio and send the path of the image instead of filename into the InlineImage method and it worked like a charm.","Q_Score":2,"Tags":"python-3.5,doc","A_Id":56123476,"CreationDate":"2019-05-13T16:26:00.000","Title":"Python docx image rendering using docx template library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If I have a random assortment of jpg, png, and tif images, and I cannot assume that the filename extension is accurate, what's the best way in Python to check that each image is really the extension type it says?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":200,"Q_Id":56121445,"Users Score":2,"Answer":"The imghdr module will guess image types based on the first several bytes of the file. It won't guarantee that the file is a valid image of the detected format, but nothing short of fully decoding the image will give you that.","Q_Score":1,"Tags":"python,image,validation,file-type","A_Id":56121588,"CreationDate":"2019-05-14T00:25:00.000","Title":"Checking if image has incorrect file extension","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just ran autopep8 in vscode, system reports two errors:\n\nError: Command failed: autopep8 c:\\Users\\Administrator\\Desktop\\Python\\\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\\have a try\\5-10.py usage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config filename] [--ignore-local-config] [-r] [-j n] [-p n] [-a] [--experimental] [--exclude globs] [--list-fixes] [--ignore errors] [--select errors] [--max-line-length n] [--line-range line line] [--hang-closing] [--exit-code] [files [files ...]] autopep8: error: autopep8 only takes one filename as argument unless the \"--in-place\" or \"--diff\" args are used\n\nand\n\nusage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config filename] [--ignore-local-config] [-r] [-j n] [-p n] [-a] [--experimental] [--exclude globs] [--list-fixes] [--ignore errors] [--select errors] [--max-line-length n] [--line-range line line] [--hang-closing] [--exit-code] [files [files ...]] autopep8: error: autopep8 only takes one filename as argument unless the \"--in-place\" or \"--diff\" args are used\n\nAnyone knows why? I try my best but also don't know what I should do.\nI am using:\n\nExtension:Python-autopep8\nvscode:1.33.1","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2564,"Q_Id":56124204,"Users Score":0,"Answer":"Your file path contains a space in it \"have a try\". This is interpreted as multiple file names.\nTo resolve this, I just ensured that the file path does not contain any spaces.","Q_Score":1,"Tags":"python,visual-studio-code,autopep8","A_Id":66697783,"CreationDate":"2019-05-14T06:27:00.000","Title":"vscode autopep8 don't run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have two computers (running Ubuntu) that have access to one server. The shared home directory of the two computers is on the server.\nOn computer (A) python 3.5 is installed, on computer (B) python 3.7 is installed. I created a virtualenv from computer (B) on the shared home directory (using python 3.7).\nNow although it is possible to activate that virtualenv from computer (A) it does not use the \"virtualenv-python 3.7\" but the system's python 3.5. So technically the virtualenv is activated but effectively it is not.\nNote that the VIRTUAL_ENV path is set correctly.\nI thought that virtualenv-folder is a fully enclosed environment, not even needing any python installed on the system. So why is it not working?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":130,"Q_Id":56124388,"Users Score":1,"Answer":"A virtualenv doesn't have a full Python installation. Instead, it links to an installation present on the system (FYI that link is in <env>\/lib\/orig-prefix.txt). The env's directory tree has some stubs and special logic but it uses the bulk from that installation.\nSo if you run activate on a system that doesn't have the same Python at the same path as the one virtualenv was created for, that script won't work correctly. It might happen to hook to something else present at the same path but this is not a supported scenario so all bets are off.\n\nIf you need a \"fully enclosed environment\", you may want to take a look at pyenv which does exactly that -- installs a full Python under your home dir. (Or you can just install Python from source to somewhere under your home dir -- but pyenv makes it easy to switch to that installation and back.)","Q_Score":0,"Tags":"python,virtualenv","A_Id":56124867,"CreationDate":"2019-05-14T06:42:00.000","Title":"Activate virtualenv from a system running a different python version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a graph with 240k nodes and 550k edges with five attributes per node coming out of an autoencoder from a sparse dataset. I'm looking to partition the graph into n clusters, such that intra-partition attribute similarity is maximized, the partitions are connected, and the sum of one of the attributes doesn't exceed a threshold for any given cluster. \nI've tried poking around with an autoencoder but had issues making a loss function that would get the results I needed. I've also looked at heirarchical clustering with connectivity constraints but can't find a way to enforce my sum constraint optimally. Same issue with community detection algorithms on graphs like Louvain. \nIf anyone knows of any approaches to solving this I'd love to hear it, ideally something implemented in Python already but I can probably implement whatever algorithm I need should it not be. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":350,"Q_Id":56127111,"Users Score":0,"Answer":"First of all, the problem is most likely NP-hard, so the best you can do is some greedy optimization. It will definitely help to first break the graph into subsets that cannot be connected ever (remove links of nodes that are not similar enough, then compute the connected components). Then for each component (which hopefully are much smaller than 250k, otherwise tough luck!) run a classic optimizer that allows you to specify the cost function. It is probably a good idea to use an integer linear program, and consider the Lagrange dual version of the problem.","Q_Score":2,"Tags":"python,constraints,cluster-analysis,graph-theory","A_Id":56161443,"CreationDate":"2019-05-14T09:28:00.000","Title":"Algorithms for constrained clustering on attributed graphs with some cluster-level constraints on their attributes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know I can use:\n- 0.5.as_integer_ratio() ; and get the integer fraction: 1\/2\nHowever, if I have a decimal such as:\n- 8.333333333333334 ; which is equivalent to: 25\/3 ; and I use the 8.333333333333334.as_integer_ratio() ; I get: (4691061961859793, 562949953421312)\nIs there a function\/way to get to the \"clean\" 25\/3 instead?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":218,"Q_Id":56127442,"Users Score":0,"Answer":"You can do it simply by importing python modules @Fraction and @Decimal, so let see how to it works:\nfrom decimal import Decimal from fractions import Fraction\nFraction(Decimal('8.33333333333334')).limit_denominator()\nNote: the limit_denominator is was is going to simplify your fraction to the lowest value as possible. And the argument passed to the Decimal must be in quotes","Q_Score":3,"Tags":"python","A_Id":56128090,"CreationDate":"2019-05-14T09:44:00.000","Title":"Is there an alternative to the: as_integer_ratio(), for getting \"cleaner\" fractions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to extract the names of Institutes from the given data. Institues names will look similar ( Anna University, Mashsa Institute of Techology , Banglore School of Engineering, Model Engineering College). It will be a lot of similar data. I want to extract these from text. How can I create a model to extract these names from data(I need to extract from resumes-C.V)\nI tried adding new NER in spacy but even after training, the loss doesnt decrease and predictions are wrong. That is why I want to make a new model just for this.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":472,"Q_Id":56127781,"Users Score":0,"Answer":"The problem you face is solved by specialized text search and text analysis tools. Using phonetic analysis and indexes.\nOne of the popular text analysis tools is Elasticsearch.\nYou index your documents and search them, using REST api.\nGoogle also provide such tools for text analysis and indexing.\nAlso modern RDBMS tools like Oracle and PostgresSQL provide such features.\nGood luck.","Q_Score":1,"Tags":"python,nlp,information-extraction","A_Id":56189877,"CreationDate":"2019-05-14T10:00:00.000","Title":"Extracting a particular type of data from unstructured text namely Institutes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to used nested events. \nWhen I browse a file, the filename alone being stripped from the full path triggers an event that makes the filename to be transferred to a textbox which has the enable_events set to true, which will trigger another event to call a function and get the pdf details. \nIf I enable the two commented lines, you can see that the function works and transfers the return value, but I'm trying to separate these two events as the function to get the details of the PDF takes a while.\nSo the order is:\n__pdfpath__ gets the full path of a certain browsed file which triggers an event that transfers the filename to __bookfilename__ which should trigger another event which will call a function that will send its response to __pdfdetails__\n\nimport PySimpleGUI as sg\nimport os\n\n\ndef get_pdf_details(pdfname):\n\n    return pdfname + ' was processed'\n\nlayout = [\n\n[sg.InputText('',key='_pdfpath_',enable_events=True),sg.FileBrowse(key='_filepath_')],\n[sg.Text('',key='_bookfilename_',enable_events=True,size=(40, 1))],\n[sg.Text('',key='_pdfdetails_', size=(40, 1) )],\n\n\n]\n\nwindow = sg.Window('', layout)\n\nwhile True:\n    event, value = window.Read()\n\n    if event == '_pdfpath_':\n        filename = os.path.basename(value['_pdfpath_'])\n        window.Element('_bookfilename_').Update(filename)\n\n        #response = get_pdf_details(filename)\n        #window.Element('_pdfdetails_').Update(response)\n    if event == '_bookfilename_':\n        response = get_pdfdetails(value['_bookfilename_'])\n        window.Element('_pdfdetails_').Update(response)\n\nSo the question is, how can I trigger the second event?\nI tried creating a second window.Read() to create a second loop like this:\nevent2, value2 = window.Read()\nbut didn't work.\nAny ideas?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4035,"Q_Id":56127923,"Users Score":0,"Answer":"PSG has one magic element that can Fire event whenever you want, It's basically is Button, it can be hidden by setting visible=False. Just call window['ButtonKey'].click() where you want to fire 'ButtonKey' event.","Q_Score":1,"Tags":"python,pysimplegui","A_Id":68165008,"CreationDate":"2019-05-14T10:07:00.000","Title":"How to use nested events in PySimpleGUI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently our system is in live proving phase. So, we need to check whether the set of tables populated in production are matching with the tables populated in sandbox (test). At the moment we have written a query for each table comparison and then run it in sql client to check it. There will be few more tables to check in future. I thought of automating the process in python by supplying the table names to a function which can then load the two tables in dataframes and then do a comparison which could highlight the differences.\nSome of the tables have 2.7 millions rows for a day and are wide having 400 columns. When I tried to load the data (2.7 m rows * 400 columns) into dataframe, I get an error as it runs out of memory as I run my query in Jupyter where I have only 20 GB limit. what are the options here? Is Pandas dataframes only way to compare this large dataset? or are there any other library to achieve the same?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":218,"Q_Id":56129032,"Users Score":0,"Answer":"For handling this kind of data I would recommend using something like Hadoop rather than pandas\/python.  This isn't much of an answer but I can't comment yet.","Q_Score":0,"Tags":"python,python-3.x,pandas,pandasql","A_Id":56129689,"CreationDate":"2019-05-14T11:08:00.000","Title":"Python comparing millions of rows and hundreds of columns between two tables from relational DB","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two computers with internet connection. They both have public IPs and they are NATed. What I want is to send a variable from PC A to PC B and close the connection. \nI have thought of two approaches for this:\n1) Using sockets. PC B will have listen to a connection from PC A. Then, when the variable will be sent, the connection will be closed. The problem is that, the sockets will not communicate, because I have to forward the traffic from my public IP to PC B.\n2) An out of the box idea, is to have the variable broadcasted online somewhere. I mean making a public IP hold the variable in HTML and then the PC would GET the IP from and get the variable. The problem is, how do I make that variable accessible over the internet?\nAny ideas would be much appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":233,"Q_Id":56129037,"Users Score":2,"Answer":"Figured a solution out. I make a dummy server using flask and I hosted it at pythonanywhere.com for free. The variables are posted to the server from PC A and then, PC B uses the GET method to get them locally.","Q_Score":1,"Tags":"python,python-3.x,sockets,networking","A_Id":56148950,"CreationDate":"2019-05-14T11:09:00.000","Title":"Send variable between PCs over the internet using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to write a program to find how many [a,b,c] in [a,a, b,c,d,a,a,b,c,c,d,d,d].\nThe answer that I want is 2.\nThere are four a's in the list, but b is 2, and c is 3.\nSo I want to get a minimum number of [a,b,c]","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":56131209,"Users Score":0,"Answer":"Thats one easy way to do it :\nabc = ['a', 'a', 'b', 'c', 'd', 'a', 'a', 'b', 'c', 'c', 'd', 'd', 'd']\nmin([abc.count(i) for i in  ['a', 'b', 'c']])","Q_Score":2,"Tags":"python,list","A_Id":56133288,"CreationDate":"2019-05-14T13:06:00.000","Title":"How can I search several elements in python list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing a simple web server that runs on a raspberry pi zero and lights up an LED when a request is received on the POST route (with a given color, intensity, blink timing and other informations contained in the request data) and shuts it down when a request is received on the DELETE route.\nI wanted to have a sort of backup of the requests i do to the server so that they can be \"redone\" (in whatever order) when the server restarts so that the LEDs will turn on without having to redo all of them by hand.\nRight now (since it was the easiest and fasted way for me to do it as a proof of concept) every time i make a POST request i save the color in a dict using as key the serial of the LED and then write the dict to a json file.\nWhen i receive a DELETE request i read the file, delete the entry and write it again with the other information that it may contain (if more than one LED was connected), if the server loses power or gets shut down and restarts it reads the file and restores the LEDs statuses.\nI was wondering what would be the best way to have a system like this (either using a file, DB or other possible solutions) in a way that would use the lowest amount of RAM possible since I already have other services running on the rpi that use quite a bit of it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":56132088,"Users Score":0,"Answer":"Depending on how many LEDs there are it sounds like what you are doing will be a JSON file of only a few bytes, right?  There are ways you could compress that, but unless you have a huge number of LEDs I doubt it will be a significant saving compared to everything else.","Q_Score":0,"Tags":"python,database,raspberry-pi,ram","A_Id":56133167,"CreationDate":"2019-05-14T13:51:00.000","Title":"Saving data using less RAM 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":"I am running a gstreamer command to play mp3 from terminal with The following command:\ngst-launch-1.0 -v filesrc location=\/home\/user\/songs\/song.mp3 ! mad ! audioconvert ! audioresample ! autoaudiosink\nI am getting the error below and the mp3 is not playing\nWARNING: erroneous pipeline: no element \"mad\"\nI have installed gstreamer plugins already with command below:\nsudo apt-get install gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav\nThey are installed successfully but the error remains.\nAlso I have checked whether mad plugin has been blacklisted using\ngst-inspect-1.0 and its not blacklisted.\nI have cleared ~\/.cache\/gstreamer-1.0\/registry.*.bin.\nThe command below is failing in ubuntu 18.04\ngst-launch-1.0 -v filesrc location=\/home\/user\/songs\/song.mp3 ! mad ! audioconvert ! audioresample ! autoaudiosink\nThe command below works but I want to use \"mad: but not \"decodebin\":\ngst-launch-1.0 -v filesrc location=\/home\/user\/songs\/song.mp3 ! decodebin ! audioconvert ! audioresample ! autoaudiosink","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1942,"Q_Id":56132573,"Users Score":2,"Answer":"From the GStreamer's 1.12 Changelog on plugins removal:\n\nThe mad mp1\/mp2\/mp3 decoder plugin was removed from gst-plugins-ugly, as libmad is GPL licensed, has been unmaintained for a very long time, and there are better alternatives available. Use the mpg123audiodec element from the mpg123 plugin in gst-plugins-ugly instead, or avdec_mp3 from the gst-libav module which wraps the ffmpeg library. We expect that we will be able to move mp3 decoding to gst-plugins-good in the next cycle seeing that most patents around mp3 have expired recently or are about to expire.","Q_Score":1,"Tags":"python,c,gstreamer","A_Id":56138982,"CreationDate":"2019-05-14T14:17:00.000","Title":"How to fix `WARNING: erroneous pipeline: no element \"mad\"`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Main script in Spyder that calls several functions contained in 6 different scripts (.py). I had to this way because the scripts are also used in different projects.\nCurrently, I have to run each script (containing several functions each) separately by hand, which is tiring, by clicking in the \"green triangle\" before launching the Main Script so that the functions contained in each script are stored in the working environment.\nMy question is: Would it be possible to automatically run each script directly from the Main Script and not running one after the another by hand?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2213,"Q_Id":56132719,"Users Score":1,"Answer":"When you execute an import statement, the source file being imported is executed. So, for example, if you have thing.py and you execute import thing, all the code in thing.py will be run.\nAlso, as noted in a comment by Sven Kr\u00fcger: you can use runpy.run_path, which I think is overall a better solution than my original suggestion.","Q_Score":0,"Tags":"python,anaconda,spyder","A_Id":56132759,"CreationDate":"2019-05-14T14:24:00.000","Title":"Run a script in Spyder directly from another script in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to narrow down some potential issues in Maximo. Can Python help me get all queries certain users run while they are logged in? If Python can do this can someone please provide an example I can work with?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":56134963,"Users Score":0,"Answer":"The direct, simple answer to your question is, No.\nIf you don't want to log SQL for all users, as you would get with @JPTremblay's excellent answer, then you should investigate the Configure Custom Logging action of the Logging application. In the associated dialog, on the Thread Logger tab, you should be able to configure UI logging for your particular user, and add the SQL logger in the Thread Logger Details.","Q_Score":1,"Tags":"python,tsql,maximo","A_Id":56448163,"CreationDate":"2019-05-14T16:38:00.000","Title":"Can I get with a python script what queries users run while logged into Maximo?","Data Science and Machine Learning":0,"Database and SQL":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 looking for a solution, to deploy my Django app on my Unlimited Linux Shared Hosting Plan on Hostgator.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":442,"Q_Id":56136153,"Users Score":1,"Answer":"Is it possible ? Yes \nIs it recommendable? No\nas it says on the same hostgator page:\n\nWhile it is possible to install Django on HostGator servers, it is not a supported application\n\nThis means that hostgator is not designed to host django. My recommendation would be:\nIf it is a simple project: Use Heroku\nIf it's a project that might later become something bigger: Use google app engine (google cloud) or Elastic beanstalk(AWS)","Q_Score":0,"Tags":"python,django","A_Id":56136463,"CreationDate":"2019-05-14T18:05:00.000","Title":"Is it possible to deploy a Django website using HostGator shared Linux Web Hosting?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"While running test cases built in the Robot Framework, at some point, the error \u201cPython stopped\u201d appears and I have observed that numerous chrome processes linger per Task Manager even when my test case closes all browser and performs a taskkill command.  As a result, my testing is suspended with aborting the only option.\nBackground and tech stack:\n\nwindows 7\/Windows 10\nPython 2.7.15\/RobotFramework\n\"scoped_dir*\" directories fill up the disk space\nChrome v74\/chromedriver v74\nChrome setting turned off:\n    Continue running background apps when Google Chrome is closed\nCommand line taskkill does not always work so only option is to end chrome process in Task Manager.\n\nTest Setup      Run | taskkill \/f \/t \/im chrome.exe\nTest Teardown   Run | taskkill \/f \/t \/im chrome.exe\nOpen Browser\n......\nClose Browser\nExpected result:  chrome process stops running after each test case is executed and all C:\\Users\\<user_name>\\AppData\\Local\\Temp\\scoped_dirXXXXX directories are deleted.\nActual result: \"Python stopped\" is displayed; more often than not, numerous chrome processes linger and scoped_dir* fills up the file system.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":400,"Q_Id":56138502,"Users Score":0,"Answer":"I have already tried the taskkill command on chromedriver.exe and that does not work.\nI have increased the RAM on the computer and that does not work.\nI am running smaller suites of tests and that is working now.","Q_Score":0,"Tags":"python,robotframework","A_Id":56242134,"CreationDate":"2019-05-14T20:58:00.000","Title":"Python stops and chrome processes linger","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"While running test cases built in the Robot Framework, at some point, the error \u201cPython stopped\u201d appears and I have observed that numerous chrome processes linger per Task Manager even when my test case closes all browser and performs a taskkill command.  As a result, my testing is suspended with aborting the only option.\nBackground and tech stack:\n\nwindows 7\/Windows 10\nPython 2.7.15\/RobotFramework\n\"scoped_dir*\" directories fill up the disk space\nChrome v74\/chromedriver v74\nChrome setting turned off:\n    Continue running background apps when Google Chrome is closed\nCommand line taskkill does not always work so only option is to end chrome process in Task Manager.\n\nTest Setup      Run | taskkill \/f \/t \/im chrome.exe\nTest Teardown   Run | taskkill \/f \/t \/im chrome.exe\nOpen Browser\n......\nClose Browser\nExpected result:  chrome process stops running after each test case is executed and all C:\\Users\\<user_name>\\AppData\\Local\\Temp\\scoped_dirXXXXX directories are deleted.\nActual result: \"Python stopped\" is displayed; more often than not, numerous chrome processes linger and scoped_dir* fills up the file system.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":400,"Q_Id":56138502,"Users Score":0,"Answer":"Try killing the \"Chromedriver.exe\" as Robot framework uses chromedriver to interact with the chrome browser with the help of functions defined in back-end(Selenium library).\nTry below Command in Test Setup\ntaskkill \/f \/t \/im chromedriver.exe","Q_Score":0,"Tags":"python,robotframework","A_Id":56145675,"CreationDate":"2019-05-14T20:58:00.000","Title":"Python stops and chrome processes linger","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I built a website some time ago with Flask. Now all of a sudden when I try to navigate there I get the following:\nNET::ERR_CERT_COMMON_NAME_INVALID\nYour connection is not private\nAttackers might be trying to steal your information from www.mysite.org (for example, passwords, messages, or credit cards). Learn more\nDoes anyone know what's going on?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":5243,"Q_Id":56138678,"Users Score":2,"Answer":"The error means: The host name you use in the web browser does not match the one used in the certificate.\nIf your server has multiple DNS entries you need to include all of into the certificate to be able to use them with https. If you access the server using it's IP address like https:\/\/10.1.2.3 then the IP address also have to present in the certificate (of course this only makes sense if you have a static IP address that never changes).","Q_Score":3,"Tags":"python,flask,error-handling","A_Id":68351111,"CreationDate":"2019-05-14T21:13:00.000","Title":"NET::ERR_CERT_COMMON_NAME_INVALID - Error Message","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to use Python to call my Modelica models using Dymola and BuildingsPy. I read the BuildingsPy tutorial, I understand in general how it goes, but I admit that the examples are not too intuitive for me. Could someone help me with a simple example using for example an existing model in the Modelica library. \nThank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":404,"Q_Id":56138688,"Users Score":0,"Answer":"Thank you for your explanation, it's really clear and it helped me a lot. I tested one of my models but by launching the code, dymola opens but it does not load the library or my model exists. That's the message I got: \nError: Simulation failed in 'C:\\Temp\\tmp-simulator-wwuvls\\BEE'\n   Exception: File C:\\Temp\\tmp-simulator-wwuvls\\BEE\\simulator.log does not exist.\n   You need to delete the directory manually.","Q_Score":1,"Tags":"python,dymola","A_Id":56263416,"CreationDate":"2019-05-14T21:14:00.000","Title":"Simple example on using BuildingsPy with Dymola","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the following code which works fine on python2.7. This code returns me error 'Unicode objects must be encoded before hashing' on python 3.7. Can someone please tell me the equal of this in python3.7 version.\nbase64.encodestring(hashlib.sha256(any_string).digest()).strip()\nA lot of downstream code depends on this so I cannot change this algo. I want the same output in python3.7.\nAny pointers would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":260,"Q_Id":56139582,"Users Score":0,"Answer":"base64.encodestring(hashlib.sha256(any_string.encode('UTF-8')).digest()).strip()\nIn Python 3+ unicode objects (strings) and bytes are handled differently than in Python 2. The sha256 function seems to require bytes and not unicode which is why the error is appearing. Adding .encode('UTF-8') to the string will give the correct format for the sha256 function. I have tested this in both python 2.7 and 3.7 and both work correctly and give the same output.","Q_Score":0,"Tags":"python-3.x,python-2.7,base64,encode","A_Id":56140725,"CreationDate":"2019-05-14T22:45:00.000","Title":"base64.encodestring returns error Unicode objects must be encoded before hashing","Data 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 python library that allows me to have python server that communicates with python client on a non web port and where arguments as well as results can be passed in native python data type and transformed by library into requisite types needed for transfer protocol","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":56140650,"Users Score":0,"Answer":"You may be looking for Tornado TCP, The data structure can be passed by Json.","Q_Score":0,"Tags":"python,server","A_Id":56140720,"CreationDate":"2019-05-15T01:29:00.000","Title":"python library to create python server and client that can also handle data transfer over ports in native python types","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python program that takes in a list of objects of different types, and for each type, the program will output a dictionary of key\/value attributes where the key is some property of the given object's type, and value is its computed result.\nTo make it more concrete, my program takes in a list of 2000 objects, of 3 unique types: Cars, Planes, Ships. And for a car, it produces: \n\n{\"ID\": , \"Horsepower\":120.5, \"Fuel Efficiency\": 19,\n  \"Turning Radius\":20, \"Weight\":500}\n\nFor ship, it's \n\n{\"ID\": , \"Displacement\": 1000.5, \"Fuel Efficiency\": 8,\n  \"Weight\": 2000}\n\nFor plane, it's \n\n{\"ID\": , \"Engine Size\": 200.5, \"Fuel Efficiency\": 8,\n  \"Weight\": 2000}\n\nSo you can see, for each type, the number and content of its dictionary output is different, while they may all share some common fields such as \"ID\" (unique across different objects), \"Weight\", etc.\nAnd tomorrow there could be a new type that needs to be supported by the program with a similar output structure.\nThe question is what is the best way to persist these outputs, for easy querying\/aggregation later on. Such as: give me all planes with a weight >= 1000, or give me all weights of all cars whose horse power is between 200 and 300.\nLets say we use pandas dataframe as our storage format, I am faced with 2 choices:\nTake a union of all keys of all product types, and create a pandas df with those keys as column, and each row represents each product's output, and it may have None in a given column depending on product. This essentially creates a sparse matrix. And the column names can grow because new product types can have new keys as outputs.\nCreate a pandas df with 3 columns: ID, Key,  Value.\nWhich one do you recommend or is there an obvious third option I'm missing?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":56141069,"Users Score":0,"Answer":"I would recommend persisting as json using pandas and reloading again as needed with pandas. Pandas will make the reading and writing really easy for you. This allows you to have the superset of columns in the dataframe with nulls in the spots that are missing data. \nThis saves you from needing to do a key value pair storage option as well. \nPlus, it looks like your data is already in a format close to json. Once you have it loaded back into the dataframe, querying as you need to will also be simple.","Q_Score":0,"Tags":"python,pandas","A_Id":56141111,"CreationDate":"2019-05-15T02:42:00.000","Title":"How to persist a python dictionary?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python program that takes in a list of objects of different types, and for each type, the program will output a dictionary of key\/value attributes where the key is some property of the given object's type, and value is its computed result.\nTo make it more concrete, my program takes in a list of 2000 objects, of 3 unique types: Cars, Planes, Ships. And for a car, it produces: \n\n{\"ID\": , \"Horsepower\":120.5, \"Fuel Efficiency\": 19,\n  \"Turning Radius\":20, \"Weight\":500}\n\nFor ship, it's \n\n{\"ID\": , \"Displacement\": 1000.5, \"Fuel Efficiency\": 8,\n  \"Weight\": 2000}\n\nFor plane, it's \n\n{\"ID\": , \"Engine Size\": 200.5, \"Fuel Efficiency\": 8,\n  \"Weight\": 2000}\n\nSo you can see, for each type, the number and content of its dictionary output is different, while they may all share some common fields such as \"ID\" (unique across different objects), \"Weight\", etc.\nAnd tomorrow there could be a new type that needs to be supported by the program with a similar output structure.\nThe question is what is the best way to persist these outputs, for easy querying\/aggregation later on. Such as: give me all planes with a weight >= 1000, or give me all weights of all cars whose horse power is between 200 and 300.\nLets say we use pandas dataframe as our storage format, I am faced with 2 choices:\nTake a union of all keys of all product types, and create a pandas df with those keys as column, and each row represents each product's output, and it may have None in a given column depending on product. This essentially creates a sparse matrix. And the column names can grow because new product types can have new keys as outputs.\nCreate a pandas df with 3 columns: ID, Key,  Value.\nWhich one do you recommend or is there an obvious third option I'm missing?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":56141069,"Users Score":0,"Answer":"json.dumps and json.loads are your friends. To translate your structure to be persisted, dumps creates a unique string that can be written to any file-like object and loads can reload it from a string-like object. Hope that helps!","Q_Score":0,"Tags":"python,pandas","A_Id":56141206,"CreationDate":"2019-05-15T02:42:00.000","Title":"How to persist a python dictionary?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I am a developper of a django project and I have to check that my dev is okay. \nTo do this, I have to connect myself as a user but I have just his email not his password. I found in the table User this the email and the password but the password begins by this : pbkdf2_sha256 ...\nSo I guess the password is encrypted. Is there a way easier to do this ? \nThank you for your help !","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":236,"Q_Id":56145257,"Users Score":1,"Answer":"Depending on how the passwords are hashed while new users are created, you could just replace the user's hash with another one : \n\nGo in database and copy the passwordHash of the user you would like to log with\nStore this hash somewhere (you will need it to revert the change)\nCopy the hash of another user (a user for whom you know the password)\nPaste the hash of this user in place of the hash of the user you want to log in\n\nIf the hashs are generated the same way, you will be able to log with the other user's password.\nThen when you are done, revert the changes in database.\nHope it helps.","Q_Score":0,"Tags":"python,django,python-3.x,django-users,pbkdf2","A_Id":56148509,"CreationDate":"2019-05-15T08:54:00.000","Title":"How can I connect myself as an other user?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I ran  pip3 install detect-secrets; but running  detect-secrets then gives \"Command not found\". \nI also tried variations, for example the switch  --user; sudo; and even  pip rather than pip3. Also with underscore in the name.\nI further added all directories shown in  python3.6 -m site to my PATH (Ubuntu 18.04).\nRetrying the installation command  shows that  the package was successfully installed.\nfind . -name detect-secrets (also detect_secrets)  shows these in .\/.local\/bin\/detect-secrets and .\/home\/user\/.local\/lib\/python3.6\/site-packages\/detect_secrets)\nNone of these gave access to the  executable. How do I do that?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1834,"Q_Id":56145426,"Users Score":0,"Answer":"After pip3 install detect_secrets, with the underline, do this from the root \/: \nsudo find . -name detect-secrets 2>\/dev\/null. \nYou may find a result in it in   \/.local\/bin\/ or in \/home\/user\/.local\/bin\/detect-secrets (strangely, that's even if you do not use the --user switch on pip3 install). \nAdd this directory to the path with PATH=$PATH:\/home\/user\/.local\/bin\/.\nNow  detect-secrets, with the dash, works.","Q_Score":0,"Tags":"python,path,pip","A_Id":56146022,"CreationDate":"2019-05-15T09:03:00.000","Title":"Pip package not found after successful installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a logistic regression classificator.\nI start form a set of 500.000 record and I want to use only a sample of them.\nwhat do you recommend:\n1) scaling the population and then sampling \n2) scaling the sample \n3) scaling just the X_TRAIN split of the sample?\nand why?\nmy considerations are:\n1) this may have sense if the sample is representative of the population (should I test it?) \n2) this is not convincing because I would go for several sample in order to see the generalization level of the classificator, and having everytime a slightly different scaler does not sounds good. plus it will bias the X_train, X_test split\n3) This will not bias the X_train, X_test split but has the same doubt of the point2)\nWhat  would you recommend and why?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":48,"Q_Id":56148094,"Users Score":1,"Answer":"Wonderful question. I had similar questions in my mind when I had started out few years ago. Let me try and give my two cents on this.\nI suggest to go with creating a scaler for scaling X_train, store the scaler and see if use it to transform X_test. According to centrality theorem, if you have done random sampling, you should have a mean and variance similar to the population attributes. The scaler works based on these two parameters in most cases. If it is representative of the population parameters, as long as the test data is coming from same population the scaler should work. If it is not working, you need more samples for training or another sampling attempt to get X_train representative of population. \nBy doing this, you are sure the model is going to work on new samples also as long as it is generated by same process. After all, the model is not built to be tested it is meant to be in production doing some useful work.\nMy recommendation would be to go with 3) scaling X_train and use the scaler to transform X_test.","Q_Score":1,"Tags":"python,data-science,sampling","A_Id":56158265,"CreationDate":"2019-05-15T11:17:00.000","Title":"classificator using sample of a population: scaling the population and then sampling \/ scaling the sample \/ scaling the X_TRAIN split of the sample?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Synthia dataset. I would like to read the label file from this datset. I expect to have one channel matrix with size of my RGB image, but when I load the data I got 3x760x1280 and it is full of zeros.\nI tried to read as belows:\nlabel = np.asarray(imread(label_path)) \nCan anyone help to read these labels file correctly?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":335,"Q_Id":56148891,"Users Score":2,"Answer":"I found the right way to read it as below:\nlabel = np.asarray(imageio.imread(label_path, format='PNG-FI'))[:,:,0]","Q_Score":0,"Tags":"python,deep-learning,dataset,semantic-segmentation","A_Id":56169770,"CreationDate":"2019-05-15T12:00:00.000","Title":"How to read the label(annotation) file from Synthia Dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have successfully implemented google assistant on rpi using gassistpi and added agent on dialogflow also. The issue is that if multiple users invoke google assistant on different raspberry pi I am not able to identify which user has invoked the action as request from webhook on dialogflow doesn't have any user identity information. Thus, I am facing issues while retrieving data for particular user.\nI tried using account linking on actions on google using google signup over voice but I am unable to implement that.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":174,"Q_Id":56150206,"Users Score":1,"Answer":"The Google Assistant SDK does not have voice match as a feature, so you would be unable to use it to identify individual users of the Action on that surface.","Q_Score":0,"Tags":"python-3.x,dialogflow-es,actions-on-google,google-assistant-sdk","A_Id":56153506,"CreationDate":"2019-05-15T13:09:00.000","Title":"check identity of multiple users on actions on google","Data Science and Machine Learning":0,"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 using VideoWriter in cv2 using python, to write some images into a video. It works, however I can only get the video to save only in the directory that contains my .py file. And if I concatenate \/..\/folder_name with my video name (e.g. video_name.avi), the file is not written at all. \nIs there a way for me to specify which directory I can write my video file into? Or am I only able to write it into where I can currently writing it?\nAny help would be appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":707,"Q_Id":56153661,"Users Score":0,"Answer":"I think you have to give it the full path name like:\nMac\/Linux\n'~\/myloc\/mydirInsideLoc\/myfile' or '\/Users\/username\/myloc\/mydirInsideLoc\/myfile'\nWindows\n'C:\\myloc\\mydirInsideLoc\\myfile'","Q_Score":1,"Tags":"opencv,cv2,opencv-python,opencv4","A_Id":56155287,"CreationDate":"2019-05-15T16:15:00.000","Title":"Is there a way to choose which directory cv2 VideoWriter writes to?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In airflow, the \"Gantt\" chart offers quite a good view on performance of the ran tasks. It offers stats like start\/end time, duration and etc.\nDo you guys know a way to programmatically pull these stats via the Airflow API? I would like to use these stats and generate periodic reports on the performance of my tasks and how it changes over time.\nMy airflow version is: 1.9\nPython: 3.6.3\nRunning on top of docker\nThanks!\nKelvin\nAirflow online documentation","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1250,"Q_Id":56156636,"Users Score":2,"Answer":"One easy approach could be to set up a SQL alchemy connection, airflow stores\/sends all the data in there once the configuration is completed(dag info\/stat\/fail, task info\/stats\/ etc.).\nEdit airflow.cfg and add:\nsql_alchemy_conn = mysql:\/\/------\/table_name","Q_Score":1,"Tags":"python-3.x,airflow","A_Id":56157305,"CreationDate":"2019-05-15T19:48:00.000","Title":"Pulling duration stats API in Airflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using Eclipse on Linux to develop C applications, and the build system I have makes use of make and python. I have a custom virtualenv installed and managed by pyenv, and it works fine from the command line if I pre-select the virtualenv with, say pyenv shell myvenv.\nHowever I want Eclipse to make use of this virtualenv when building (via \"existing makefile\") from within Eclipse. Currently it runs my Makefile but uses the system python in \/usr\/bin\/python, which is missing all of the packages needed by the build system.\nIt isn't clear to me how to configure Eclipse to use a custom Python interpreter such as the one in my virtualenv. I have heard talk of setting PYTHONPATH however this seems to be for finding site-packages rather than the interpreter itself. My virtualenv is based on python 3.7 and my system python is 2.7, so setting this alone probably isn't going to work.\nI am not using PyDev (this is a C project, not a Python project) so there's no explicit support for Python in Eclipse. I'd prefer not to install PyDev if I can help it.\nI've noticed that pyenv adds its plugins, shims and bin directories to PATH when activated. I could explicitly add these to PATH in Eclipse, so that Eclipse uses pyenv to find an interpreter. However I'd prefer to point directly at a specific virtualenv rather than use the pyenv machinery to find the current virtualenv.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":930,"Q_Id":56159051,"Users Score":0,"Answer":"I had the same trouble and after some digging, there are two solutions; project-wide and workspace-wide. I prefer the project-wide as it will be saved in the git repository and the next person doesn't have to pull their hair.\nFor the project-wide add \/Users\/${USER}\/.pyenv\/shims: to the start of the \"Project properties > C\/C++ Build > Environment > PATH\".\nI couldn't figure out the other method fully (mostly because I'm happy with the other one) but it should be with possible to modify \"Eclipse preferences > C\/C++ > Build > Environment\". You should change the radio button and add PATH variable.","Q_Score":2,"Tags":"python,eclipse,makefile,virtualenv,pyenv","A_Id":61663567,"CreationDate":"2019-05-15T23:51:00.000","Title":"How to use a Pyenv virtualenv from within Eclipse?","Data Science and Machine Learning":0,"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 Eclipse on Linux to develop C applications, and the build system I have makes use of make and python. I have a custom virtualenv installed and managed by pyenv, and it works fine from the command line if I pre-select the virtualenv with, say pyenv shell myvenv.\nHowever I want Eclipse to make use of this virtualenv when building (via \"existing makefile\") from within Eclipse. Currently it runs my Makefile but uses the system python in \/usr\/bin\/python, which is missing all of the packages needed by the build system.\nIt isn't clear to me how to configure Eclipse to use a custom Python interpreter such as the one in my virtualenv. I have heard talk of setting PYTHONPATH however this seems to be for finding site-packages rather than the interpreter itself. My virtualenv is based on python 3.7 and my system python is 2.7, so setting this alone probably isn't going to work.\nI am not using PyDev (this is a C project, not a Python project) so there's no explicit support for Python in Eclipse. I'd prefer not to install PyDev if I can help it.\nI've noticed that pyenv adds its plugins, shims and bin directories to PATH when activated. I could explicitly add these to PATH in Eclipse, so that Eclipse uses pyenv to find an interpreter. However I'd prefer to point directly at a specific virtualenv rather than use the pyenv machinery to find the current virtualenv.","AnswerCount":3,"Available Count":3,"Score":-0.0665680765,"is_accepted":false,"ViewCount":930,"Q_Id":56159051,"Users Score":-1,"Answer":"Typing CMD+SHIFT+. will show you dotfiles & directories that begin with dot in any Mac finder dialog box...","Q_Score":2,"Tags":"python,eclipse,makefile,virtualenv,pyenv","A_Id":59180632,"CreationDate":"2019-05-15T23:51:00.000","Title":"How to use a Pyenv virtualenv from within Eclipse?","Data Science and Machine Learning":0,"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 Eclipse on Linux to develop C applications, and the build system I have makes use of make and python. I have a custom virtualenv installed and managed by pyenv, and it works fine from the command line if I pre-select the virtualenv with, say pyenv shell myvenv.\nHowever I want Eclipse to make use of this virtualenv when building (via \"existing makefile\") from within Eclipse. Currently it runs my Makefile but uses the system python in \/usr\/bin\/python, which is missing all of the packages needed by the build system.\nIt isn't clear to me how to configure Eclipse to use a custom Python interpreter such as the one in my virtualenv. I have heard talk of setting PYTHONPATH however this seems to be for finding site-packages rather than the interpreter itself. My virtualenv is based on python 3.7 and my system python is 2.7, so setting this alone probably isn't going to work.\nI am not using PyDev (this is a C project, not a Python project) so there's no explicit support for Python in Eclipse. I'd prefer not to install PyDev if I can help it.\nI've noticed that pyenv adds its plugins, shims and bin directories to PATH when activated. I could explicitly add these to PATH in Eclipse, so that Eclipse uses pyenv to find an interpreter. However I'd prefer to point directly at a specific virtualenv rather than use the pyenv machinery to find the current virtualenv.","AnswerCount":3,"Available Count":3,"Score":-0.0665680765,"is_accepted":false,"ViewCount":930,"Q_Id":56159051,"Users Score":-1,"Answer":"For me, following steps worked ( mac os 10.12, eclipse photon version, with pydev plugin)\n\nProject -> properties\nPydev-Interpreter\/Grammar \nClick here to configure an interpreter not listed (under interpret combobox)\nopen interpreter preference page \nBrowse for python\/pypy exe -> my virtualenvdirectory\/bin\/python\nThen the chosen python interpreter path should show ( for me still, it was not pointing to my virtual env, but I typed my path explicitly here and it worked)\n\nIn the bottom libraries section, you should be able to see the site-packages from your virtual env\nExtra tip - In my mac os the virtual env was starting with .pyenv, since it's a hidden directory, I was not able to select this directory and I did not know how to view the hidden directory in eclipse  file explorer. Therefore I created an softlink ( without any . in the name) to the hidden directory (.pyenv) and then I was able to select the softlink","Q_Score":2,"Tags":"python,eclipse,makefile,virtualenv,pyenv","A_Id":57618150,"CreationDate":"2019-05-15T23:51:00.000","Title":"How to use a Pyenv virtualenv from within Eclipse?","Data Science and Machine Learning":0,"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 some way I can create custom styles in wxPython? I searched all the docs and websites referring to wxPython styling and could find nothing. Do I have to create the custom style using the wxPython canvas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":346,"Q_Id":56159215,"Users Score":1,"Answer":"wxPython uses native widgets in its core widgets as much as possible. Most of the widgets are going to be \"native\" to the system you are using, so unfortunately you can't fully manipulate how the control paints itself.\nSometimes, you can modify widgets via the methods mentioned in the documentation, such as using SetBackgroundColour() or SetForegroundColour(). Depending on your OS's widget, they may or may not work.\nThe other option is to use the wx.PaintDC, wx.ClientDC, wx.WindowDC, wx.ScreenDC and\/or wx.MemoryDC to draw custom widgets directly.","Q_Score":1,"Tags":"python,user-interface,wxpython","A_Id":59923520,"CreationDate":"2019-05-16T00:19:00.000","Title":"Python - Custom styling in wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've looked through many similar questions, but no one seems to have had this same problem.  I can open the IDLE shell perfectly fine from the start menu.  Once in, I can use File->Open to open any .py file.\nHowever, my problem is that if I try to open any .py file from File Explorer with IDLE, the files will run, but the IDLE application won't come up.  This especially makes it difficult to quit running when I can't even close the application if it's not open.  It also makes it very tedious if I have to always use File->Open from the IDLE shell if I want to open a .py file.  How can I at least get the Edit with IDLE option to come back?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2365,"Q_Id":56159225,"Users Score":0,"Answer":"When you open the file from within IDLE, you open it in an edit window. If you try to open it from the file explorer, it will RUN it on IDLE. So that's why you can't just \"open it\" from the explorer.\nI suggest that you start using some other tools to code in python. Sublime Text and Atom are great text editors, and both can be used as a python IDE.","Q_Score":1,"Tags":"python,python-idle","A_Id":56159386,"CreationDate":"2019-05-16T00:21:00.000","Title":"Python IDLE won't open with .py file, only from start menu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've looked through many similar questions, but no one seems to have had this same problem.  I can open the IDLE shell perfectly fine from the start menu.  Once in, I can use File->Open to open any .py file.\nHowever, my problem is that if I try to open any .py file from File Explorer with IDLE, the files will run, but the IDLE application won't come up.  This especially makes it difficult to quit running when I can't even close the application if it's not open.  It also makes it very tedious if I have to always use File->Open from the IDLE shell if I want to open a .py file.  How can I at least get the Edit with IDLE option to come back?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2365,"Q_Id":56159225,"Users Score":1,"Answer":"I had this same issue and came looking for an answer, but ended up figuring it out:\nI had the issue when I downloaded the 64-bit version for windows (3.9.7), but the issue was resolved when I instead installed the 32-bit version of 3.9.7.\nNow I can right-click > \"Edit with IDLE\"","Q_Score":1,"Tags":"python,python-idle","A_Id":70718673,"CreationDate":"2019-05-16T00:21:00.000","Title":"Python IDLE won't open with .py file, only from start menu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I run my Qt application I get the message \n\nQt WebEngine seems to be initialized from a plugin. Please set\n  Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute before\n  constructing QGuiApplication.\n\nThe app runs fine regardless of the fact that this is getting dumped to the terminal. I cant seem to find the root cause or really understand what this message is trying to tell me. What is this message saying and how can I fix it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7357,"Q_Id":56159475,"Users Score":0,"Answer":"Using PySide6 instead of PySide2 solved my problem with python 3.9 and QT 5.15 if it can help","Q_Score":9,"Tags":"python,pyside2,qtwebengine","A_Id":67457543,"CreationDate":"2019-05-16T01:06:00.000","Title":"Qt WebEngine seems to be initialized","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":1,"Web Development":1},{"Question":"I am running pyspark scripts in jupyter notebook but the kernel is not starting. upon selecting pyspark from the dropdown the kernel loads and remains busy for some time and then shows \"no kernel\".\nCan someone help me?\nNote: upon running \"$Jupyter kernelspec list\" i can see pyspark kernel in the list.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":56161339,"Users Score":0,"Answer":"The issue was resolved only by re configuring the Jupyter notebook.","Q_Score":0,"Tags":"pyspark,jupyter-notebook,kernel,ipython","A_Id":56224394,"CreationDate":"2019-05-16T05:21:00.000","Title":"Jupyter Notebook is showing No pyspark kernel upon startup","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have more than 5 scripts which will perform different operations as and when required. Some Scripts does copying of files to excel while some helps in Plotting of Various Graph.\nIs there a way in Python where in i can combine all multiple scripts to One script and when i run it i will choose which script to run.\nEg: Lets us say script named as abc,xyz,pqr,fgh etc. So i will club all those script to 1 script then When i will run i will choose which script i want to execute like abc or xyz or pqr etc","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":56161807,"Users Score":0,"Answer":"You can write a wrapper script that obtains the necessary parameters, either on the command line or by querying the user, and then uses the subprocess module to run each script in exactly the same way as if you were running them manually.\nThe various subprocess calls give you a variety of ways to deal with the output of each script.  You could just let the output flow to the console, or you could redirect the output to either a single file, or to a file for each script.\nYou could get fancy and rather than hard-coding the names\/paths of each script file, you could put them in a subdirectory, list that subdirectory in your wrapper, and allow any script dropped into the subdirectory to be run with this wrapper tool.","Q_Score":0,"Tags":"python","A_Id":56162048,"CreationDate":"2019-05-16T06:08:00.000","Title":"Is it possible to club 2 or more Scripts in Python(spyder)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"is there any way to set seed on train_test_split on python sklearn. I have set the parameter random_state to an integer, but I still can not reproduce the result.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12708,"Q_Id":56166130,"Users Score":0,"Answer":"simply in train_test_split, specify the parameter random_state=some_number_you_wan to use, like random_state=42","Q_Score":10,"Tags":"python-3.x,scikit-learn,jupyter-notebook,train-test-split","A_Id":71233630,"CreationDate":"2019-05-16T10:12:00.000","Title":"Setting seed on train_test_split sklearn python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to cluster a data set containing mixed data(nominal and ordinal) using k_prototype clustering based on Huang, Z.: Clustering large data sets with mixed numeric and categorical values.\nmy question is how to find the optimal number of clusters?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":121,"Q_Id":56166439,"Users Score":0,"Answer":"There is not one optimal number of clusters. But dozens. Every heuristic will suggest a different \"optimal\" number for another poorly defined notion of what is \"optimal\" that likely has no relevancy for the problem that you are trying to solve in the first place.\nRather than being overly concerned with \"optimality\", rather explore and experiment more. Study what you are actually trying to achieve, and how to get this into mathematical form to be able to compute what is solving your problem, and what is solving someone else's...","Q_Score":0,"Tags":"python,cluster-analysis","A_Id":56202424,"CreationDate":"2019-05-16T10:29:00.000","Title":"the clustering of mixed data using python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to find a way to run my python code until it succeeds. \nCurrently my python code is connecting to a database and takes all the data available and formats the data in a desired format. The problem is that sometimes the database, that the code is accessing, is empty. Yet sometimes the database contains data which I would like to access. \nIdeally I would like to start my python code and the code should run until it finds data and saves the data accordingly.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":56167276,"Users Score":0,"Answer":"A simple answer to this would be to put in a while loop which looped until the result from the database contains rows. I'd also put in another clause to escape the loop by pressing a key too so you can exit the program cleanly.","Q_Score":0,"Tags":"python,python-3.x","A_Id":56167352,"CreationDate":"2019-05-16T11:16:00.000","Title":"Run python until it succeeds","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been looking for ages to find a suitable module to interact with excel, which needs to do the following:\n\nCheck a column of cells for an \"incorrect\" value and change it\nCheck for empty cells, and if so, replace it\nCheck a cell value is consistent with the contents of another cell(for example, if called Datasheet, the code in another cell = DS)and if not, change it.\n\nI've looked at openpxyl but I am running Python 3 and I can only seem to find it working for 2. \nI've seen a few others but they seem to be mainly focusing creating a new spreadsheet and simple writing\/reading.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":56168115,"Users Score":1,"Answer":"The Pandas library is amazing to work with excel files. It can read excel files easily and you then have access to a lot of tools. You can do all the operations you mentionned above. You can also save your result in the excel format","Q_Score":1,"Tags":"python,excel,module","A_Id":56168145,"CreationDate":"2019-05-16T12:03:00.000","Title":"Python 3 and Excel, Finding complex module to use","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a fixed number of partitions of a topic. Producers produce data at varying rate in different hours of the day. \nI want to add consumers dynamically based on hours of the day for the processing so that I can process records as fast as I can.\nFor example I have 10 partitions of a topic. I want to deploy 5 consumers for non peak hours and 20 consumers for peak hours.\nMy problem is that when I will have 20 consumers, each consumer will be receiving duplicate records, which I want to avoid. I want to process unique records only to speed-up records processing.\nIs there any mechanism to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":56174516,"Users Score":0,"Answer":"If you have N partitions, then you can have up to N consumers within the same consumer group each of which reading from a single partition. When you have less consumers than partitions, then some of the consumers will read from more than one partition. Also, if you have more consumers than partitions then some of the consumers will be inactive and will receive no messages at all.\nTherefore, if you want to kick off 20 consumers, you need to increase the number of partitions of the topic to -at least- 20 otherwise, 10 of your consumers will be inactive. \nWith regards to the duplicates that you've mentioned, if all of your consumers belong to the same group, then each message will be consumed only once. \nTo summarise, \n\nIncrease the number of partitions of your topic to 20.\nCreate the mechanism that will be creating and killing consumers based on peak\/off-peak hours and make sure that when you kick of a consumer, it belongs to the existing consumer group so that the messages are consumed only once.","Q_Score":1,"Tags":"java,python,apache-kafka,kafka-consumer-api","A_Id":56175288,"CreationDate":"2019-05-16T18:21:00.000","Title":"How to scale Kafka stream processing dynamically?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"We typically use powerpoint to facilitate our experiments. We use \"sections\" in powerpoint to keep groups of slides together for each experimental task. Moving the sections to counterbalance the task order of the experiment has been a lot of work! \nI thought we might be able to predefine a counterbalance order (using a string of numbers representing the order of the sections) in a CSV which could be read from python. Then using python-pptx move the sections and save the file for each order. The problem I am having is understanding how to read sections from the python-pptx. If anyone has a better solution than python please let me know. \nThanks for your help!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2247,"Q_Id":56175678,"Users Score":0,"Answer":"Would it be feasible - if all we're doing is reordering - to read the XML and rewrite it with the slide elements permuted?\nFurther - for the \"delete\" case - is it feasible to simply delete a slide element in the XML? (I realise this could leave dangling objects such as images in the file.)\nThe process of extracting the XML and rewriting it to a copy of the file is probably not too onerous.","Q_Score":1,"Tags":"python,powerpoint,python-pptx","A_Id":57013231,"CreationDate":"2019-05-16T19:49:00.000","Title":"Rearrange powerpoint slides automatically using python-pptx","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I am trying to cluster my data using DBSCAN, is there a way to assign a maximum number of clusters? I know I can set the minimum distance between points to be considered a cluster, but my data changes case by case and I would prefer to not allow more than 4 clusters. Any suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":281,"Q_Id":56175928,"Users Score":1,"Answer":"Not with DBSCAN itself. Connected components are connected components, there is no ambiguity at this point.\nYou could write your own rules to extract the X most significant costs from an OPTICS plot though. OPTICS is the more variable formulation of DBSCAN.","Q_Score":0,"Tags":"python,cluster-analysis,dbscan","A_Id":56178539,"CreationDate":"2019-05-16T20:10:00.000","Title":"Is there a way to assign a maximum number of clusters using DBSCAN?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a vector A = [0,1,2,3,0,0,1,1,2,2,3,3]. I need to sort it in an increasing matter such that it is listed in an ordered fashion and from that extract the argsort. To better explain this I need to sort A to such that it returns B = [0,4,5,1,6,7,2,8,9,3,10,11]. However, when I use pyotrch's torch.argsort(A) it returns B = [4,5,0,1,6,7,2,8,9,3,10,11]. \nI'm assuming the algorithm that does so cannot be controlled on my end. Is there anyway to approach this without introducing for loops? Such operation are part of my NN model and will cause performance issues if not done efficiently. Thanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2541,"Q_Id":56176439,"Users Score":1,"Answer":"Here is one way:\n\nsort the numpy array using numpy.argsort()\nconvert the result into tensor using torch.from_numpy()\nimport torch\n import numpy as np\n A = [0,1,2,3,0,0,1,1,2,2,3,3]\n x = np.array(A)\n y = torch.from_numpy(np.argsort(x, kind='mergesort'))\n print(y)","Q_Score":3,"Tags":"python,sorting,machine-learning,pytorch,tensor","A_Id":56179295,"CreationDate":"2019-05-16T20:52:00.000","Title":"Pytorch argsort ordered, with duplicate elements in the tensor","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run my model on multiple gpus using DataParallel by setting model = nn.DataParallel(model).cuda(), but everytime getting this error - \n\nRuntimeError: chunk expects at least a 1-dimensional tensor (chunk at\n  \/pytorch\/aten\/src\/ATen\/native\/TensorShape.cpp:184).\n\nMy code is correct. Does anyone know what's wrong? \nI have tried setting device_ids=[0,1] parameter and also CUDA_VISIBLE_DEVICES on the terminal. Also tried different batch sizes.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1864,"Q_Id":56177305,"Users Score":1,"Answer":"To identify the problem, you should check the shape of your input data for each mini-batch. The documentation says, nn.DataParallel splits the input tensor in dim0 and sends each chunk to the specified GPUs. From the error message, it seems you are trying to pass a 0-dimensional tensor.\nOne possible reason can be if you have a mini-batch with n examples and you are running your program on more than n GPUs, then you will get this error.\nLet's consider the following scenario.\n\nTotal training examples = 161, Batch size = 80, total mini-batches = 3\nNumber of GPUs specified for DataParallel = 3\n\nNow, in the above scenario, in the 3rd mini-batch, there will be 1 example. So, it is not possible to send chunks to all the specific GPUs and you will receive the error message. So, please check if you are not a victim of this issue.","Q_Score":0,"Tags":"python,pytorch,multi-gpu","A_Id":56195251,"CreationDate":"2019-05-16T22:21:00.000","Title":"DataParallel multi-gpu RuntimeError: chunk expects at least a 1-dimensional tensor","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a node.js server running on a Raspberry Pi 3 B+. (I'm using node because I need the capabilities of a bluetooth library that works well). \nOnce the node server picks up a message from a bluetooth device, I want it to fire off an event\/command\/call to a different python script running on the same device.\nWhat is the best way to do this? I've looked into spawning child processes and running the script in them, but that seems messy... Additionally, should I set up a socket between them and stream data through it? I imagine this is done often, what is the consensus solution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":56178165,"Users Score":1,"Answer":"Running a child process is how you would run a python script. That's how you do it from nodejs or any other program (besides a python program).\nThere are dozens of options for communicating between the python script and the nodejs program. The simplest would be stdin\/stdout which are automatically set up for you when you create the child process, but you could also give the nodejs app a local http server that the python script could communicate with or vice versa. \nOr, set up a regular socket between the two. \nIf, as you now indicate in a comment, your python script is already running, then you may want to use a local http server in the nodejs app and the python script can just send an http request to that local http server whenever it has some data it wants to pass to the nodejs app.  Or, if you primarily want data to flow the opposite direction, you can put the http server in the python app and have the nodejs server send data to the python app.\nIf you want good bidirectional capabilities, then you could also set up a socket.io connection between the two and then you can easily send messages either way at any time.","Q_Score":0,"Tags":"python,node.js,raspberry-pi","A_Id":56192507,"CreationDate":"2019-05-17T00:38:00.000","Title":"Get nodejs server to trigger 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":1,"Web Development":1},{"Question":"I'm trying to have it so that when a tkinter button is pressed, a value is assigned, and then the gui is exited. \nMy problem is that root.quit has no effect from functions other than the one that called it, even nested functions.\nCode:\n\nfrom tkinter import Tk,Button\ndef buttonDialogWindow():\n    root = Tk()\n    def buttonPress(isHeadArg):\n        #Do something\n        root.quit\n    Button(root, text='Front of String', command = buttonPress(1)).pack()\n    Button(root, text='Back of String', command = buttonPress(0)).pack()\n    root.protocol(\"WM_DELETE_WINDOW\", root.quit)\n    root.mainloop()\nbuttonDialogWindow()\n\nRunning the code makes the buttons appear. Clicking them has no effect on the GUI, and the mainloop does not exit.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":56178798,"Users Score":0,"Answer":"Answer: \nThe problem was that when I set the value of command, I was calling the function rather than declaring it. Using parentheses made the function get called -- if you have no parameters, the normal way to write this would be to write \n command = buttonPress \nIf you do have parameters, I found a workaround using lambda: my code currently has\n command = lambda: buttonPress(1) \nfor the commands.","Q_Score":0,"Tags":"tkinter,python-3.7","A_Id":56179545,"CreationDate":"2019-05-17T02:31:00.000","Title":"How to have a tkinter button destroy\/quit the root window in a nested function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run images in python, which means I have to install pillow (since PIL is apparently outdated).(I'm running them in atom, so if this changes something in the process, please let me know).\nI've installed xCode and homebrew, and pip appears to be downloaded, but sudo pip install pillow returns -bash: pip: command not found and sudo -pip install pillow then asks me for an ip, which I assume is ip address. When I put in my IP,  however, it tells me \"Sorry, try again.\" I've tried installing it from homebrew by using brew install brewsci\/science\/pillow, which causes this: Error: No previously deleted formula found. Error: No similarly named formulae found.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":793,"Q_Id":56179148,"Users Score":0,"Answer":"you try to run the following command to see Help:\n$ sudo easy_install pip\n$ sudo pip install --upgrade pip\n$ sudo pip install pillow","Q_Score":0,"Tags":"python,macos,python-imaging-library,atom-editor","A_Id":56179273,"CreationDate":"2019-05-17T03:23:00.000","Title":"How to install pillow (PIL) on mac OS 10.14.4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was training a neural network with images of an eye that are shaped 36x60. So I can only predict the result using a 36x60 image? But in my application I have a video stream, this stream is divided into frames, for each frame 68 points of landmarks are predicted. In the eye range, I can select the eye point, and using the 'boundingrect' function from OpenCV, it is very easy to get a cropped image. But this image has no form 36x60. What is the correct way to get 36x60 data that can be used for forecasting? Or how to use a neural network for data of another form?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":56181395,"Users Score":2,"Answer":"Neural networks (insofar as I've encountered) have a fixed input shape, freedom permitted only to batch size. This (probably) goes for every amazing neural network you've ever seen. Don't be too afraid of reshaping your image with off-the-shelf sampling to the network's expected input size. Robust computer-vision networks are generally trained on augmented data; randomly scaled, skewed, and otherwise transformed in order to---among other things---broaden the network's ability to handle this unavoidable scaling situation.\nThere are caveats, of course. An input for prediction should be as similar to the dataset it was trained on as possible, which is to say that a model should be applied to the data for which it was designed. For example, consider an object detection network made for satellite applications. If that same network is then applied to drone imagery, the relative size of objects may be substantially larger than the objects for which the network (specifically its anchor-box sizes) was designed.  \nTl;dr: Assuming you're using the right network for the job, don't be afraid to scale your images\/frames to fit the network's inputs.","Q_Score":5,"Tags":"python-3.x,opencv,keras,neural-network,data-science","A_Id":56182355,"CreationDate":"2019-05-17T07:14:00.000","Title":"How to predict different data via neural network, which is trained on the data with 36x60 size?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i'm using odoo 11 and i want to know how can I configure odoo in a way that the HR manager and the employee received alert before the expiration of  contract.\nIs it possible to do it ? Any idea for help please ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":56187289,"Users Score":0,"Answer":"This type of scenario is only archived by developing custom addon.\nIn custom addon you have to specify cron file which will automatically fire some action at regular basis, and which will send email notification to HR Manager that some of employee's contract are going to be expired.","Q_Score":0,"Tags":"python-3.x,odoo-11","A_Id":56493033,"CreationDate":"2019-05-17T13:19:00.000","Title":"How to configure alerts for employee contract expiration in odoo 11?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In the Telegram app, you can send photos that self-destruct and can't be screenshotted by clicking on the clock icon before sending them. Is there any way to reproduce this behavior using the Telegram Bot API?\nI'm using python-telegram-bot and couldn't find anything in its docs, but i'm not even sure if the API allows it. I could delete the messages after some time using bot.delete_message, however, the important part here is that the images shouldn't be screenshottable.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1906,"Q_Id":56187603,"Users Score":1,"Answer":"I'm using python-telegram-bot and couldn't find anything in docs, but i'm not even sure if the API allows it.\n\nTelegram Bot API does not support such method yet.  \n\nI could delete the messages after some time using bot.delete_message, however, the important part here is that the images shouldn't be screenshottable.\n\nYes, bot can delete messages \"manually\" but there's no way to control the ability of making screenshots.","Q_Score":4,"Tags":"telegram,telegram-bot,python-telegram-bot","A_Id":56189665,"CreationDate":"2019-05-17T13:38:00.000","Title":"How to send photos with self-destruct timer using Telegram Bot 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 a major Python noob, and I made the mistake of manually deleting my Pipfile and Pipfile.lock, thinking that they would eventually regenerate. \nHow can I re-create these files?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1933,"Q_Id":56188440,"Users Score":0,"Answer":"For regular pip:\npip freeze > requirements.txt\nFor pipenv:\npipenv run pip freeze > requirements.txt\nAnd to install:\npip install requirements.txt","Q_Score":1,"Tags":"python-3.x,pipfile","A_Id":58502750,"CreationDate":"2019-05-17T14:26:00.000","Title":"Python 3 - How do you re-create your Pipfile?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset that I would like to order by date but second order with 'pass' value lowest inside of highest. The reason I don't have any code is because, I just have no idea where to begin.\ndataframe input:\n\nindex   date    pass\n0   11\/14\/2014  1\n1   3\/13\/2015   1\n2   3\/20\/2015   1\n3   5\/1\/2015    2\n4   5\/1\/2015    1\n5   5\/22\/2015   3\n6   5\/22\/2015   1\n7   5\/22\/2015   2\n8   9\/25\/2015   1\n9   9\/25\/2015   2\n10  9\/25\/2015   3\n11  12\/4\/2015   2\n12  12\/4\/2015   1\n13  2\/12\/2016   2\n14  2\/12\/2016   1\n15  5\/27\/2016   1\n16  6\/10\/2016   1\n17  9\/23\/2016   1\n18  12\/23\/2016  1\n19  11\/24\/2017  1\n20  12\/29\/2017  1\n21  1\/26\/2018   2\n22  1\/26\/2018   1\n23  2\/9\/2018    1\n24  3\/16\/2018   1\n25  4\/6\/2018    2\n26  4\/6\/2018    1\n27  6\/15\/2018   1\n28  6\/15\/2018   2\n29  10\/26\/2018  1\n30  11\/30\/2018  1\n31  12\/21\/2018  1\n\n\n** Expected Output **\nindex   date    pass\n0   11\/14\/2014  1\n1   3\/13\/2015   1\n2   3\/20\/2015   1\n3   5\/1\/2015    2\n4   5\/1\/2015    1\n\n5   5\/22\/2015   3\n6   5\/22\/2015   2\n7   5\/22\/2015   1\n\n8   9\/25\/2015   3\n9   9\/25\/2015   2\n10  9\/25\/2015   1\n11  12\/4\/2015   2\n12  12\/4\/2015   1\n13  2\/12\/2016   2\n14  2\/12\/2016   1\n15  5\/27\/2016   1\n16  6\/10\/2016   1\n17  9\/23\/2016   1\n18  12\/23\/2016  1\n19  11\/24\/2017  1\n20  12\/29\/2017  1\n\n21  1\/26\/2018   1\n22  1\/26\/2018   2\n\n23  2\/9\/2018    1\n24  3\/16\/2018   1\n\n25  4\/6\/2018    1\n26  4\/6\/2018    2\n\n27  6\/15\/2018   1\n28  6\/15\/2018   2\n29  10\/26\/2018  1\n30  11\/30\/2018  1\n31  12\/21\/2018  1\n\nI have spaced out the results that would change. index 5,6,7 and 21,21 and 25,26.  So all the bigger pass numbers should be inside the lower pass number if the dates are same.\nSo if you look at INDEX 5,6,7 the pass for it is changed to 3,2,1 and if you look at INDEX 25,26 the pass is changed to 1,2. Hope you understand.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":56188801,"Users Score":0,"Answer":"Order first by pass then do it by date. This way you will be sure to have your df the way you want it","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":56188894,"CreationDate":"2019-05-17T14:46:00.000","Title":"Order data set using pandas dataframe based on lowest value inside","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting a rather large unsupervised learning project and am not sure how to properly utilize word2vec. We're trying to cluster groups of customers based on some stats about them and what actions they take on our website. Someone recommended I use word2vec and treat each action a user takes as a word in a \"sentence\". The reason this step is necessary is because a single customer can create multiple rows in the database (roughly same stats, but new row for each action on the website in chronological order). In order to perform kmeans on this data we need to get that down to one row per customer ID. Hence the previous idea to collapse down the actions as words in a sentence \"describing the user's actions\"\nMy question is I've come across countless tutorials and resources online that show you how to use word2vec (combined with kmeans) to cluster words on their own, but none of them show how to use the word2vec output as part of a larger kmeans model. I need to be able to use the word2vec model along side other values about the customer. How should I go about this? I'm using python for the clustering if you want to be specific with coding examples, but I could also just be missing something super obvious and high level. It seems the word2vec outputs vectors, but kmeans needs straight numbers to work, no? Any guidance is appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":56188976,"Users Score":0,"Answer":"There are two common approaches.\n\nTaking the average of all words. That is easy, but the resulting vectors tend to be, well, average. They are not similar to the keywords of the document, but rather similar to the most average and least informative words... My experiences with this approach are pretty disappointing, despite this being the most mentioned approach.\npar2vec\/doc2vec. You add a \"word\" for each user to all it's contexts, in addition to the neighbor words, during training. This way you get a \"predictive\" vector for each paragraph\/document\/user the same way you get a word in the first word2vec. These are supposedly more informative but require much more effort to train - you can't download a pretrained model because they are computed during training.","Q_Score":0,"Tags":"python,cluster-analysis,k-means,word2vec,unsupervised-learning","A_Id":56202144,"CreationDate":"2019-05-17T14:56:00.000","Title":"User word2vec model output in larger kmeans project","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using openCV to process an image and use houghcircles to detect the circles in the image under test, and also calculating the distance between their centers using euclidean distance.\nSince this would be in pixels, I need the absolute distances in mm or inches, can anyone let me know how this can be done\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1149,"Q_Id":56191574,"Users Score":0,"Answer":"The image formation process implies taking a 2D projection of the real, 3D world, through a lens. In this process, a lot of information is lost (e.g. the third dimension), and the transformation is dependent on lens properties (e.g. focal distance).\nThe transformation between the distance in pixels and the physical distance depends on the depth (distance between the camera and the object) and the lens. The complex, but more general way, is to estimate the depth (there are specialized algorithms which can do this under certain conditions, but require multiple cameras\/perspectives) or use a depth camera which can measure the depth. Once the depth is known, after taking into account the effects of the lens projection, an estimation can be made.\nYou do not give much information about your setup, but the transformation can be measured experimentally. You simply take a picture of an object of known dimensions and you determine the physical dimension of one pixel (e.g. if the object is 10x10 cm and in the picture it has 100x100px, then 10px is 1mm). This is strongly dependent on the distance to the camera from the object.\nAn approach a bit more automated is to use a certain pattern (e.g. checkerboard) of known dimensions. It can be automatically detected in the image and the same transformation can be performed.","Q_Score":0,"Tags":"python,opencv,image-processing","A_Id":56192030,"CreationDate":"2019-05-17T18:10:00.000","Title":"Conversion from pixel to general Metric(mm, in)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a python script that I wanted to compile to an executable. I used cython first, to create a .c file and then I wanted to compile that to an executable with g++. This however causes an error stating that something in structmember.h (which is a header file that comes with python) is apparently wrong.\nI have tried to find other people with the same problem, but I couldn't.\nI used this to compile:\ng++ Training_set.c -o Training_set.exe \nThe error i got was:\nTraining_set.c:17362:26: fatal error: structmember.h: No such file or directory\ncompilation terminated.\nstructmember.h:21:5 error: 'Py_ssize_t\" does not name a type\nstructmember.h:67:11 error: expected constructor, destructor or type conversion before '(' token\nstructmember.h:68:17 error: expected constructor, destructor or type conversion before 'Pymember_SetOne'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":283,"Q_Id":56192695,"Users Score":0,"Answer":"So i managed to fix my problem, somehow if I put all header files in a subdirectory and provide the path to them with -I it does work.","Q_Score":0,"Tags":"c,python-3.x,g++,header-files","A_Id":56197871,"CreationDate":"2019-05-17T19:46:00.000","Title":"How to fix error from structmember.h when compiling with g++","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Which of the following would you consider more Pythonic:\nreturn x if not x > 5 or not variable == True else y\nor\nreturn x if not (x > 5 and variable == True) else y","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":57,"Q_Id":56192880,"Users Score":1,"Answer":"Neither is more Pythonic, it's just a question of how you structure your boolean logic. I would, however, replace variable == True with simply variable.","Q_Score":0,"Tags":"python","A_Id":56192913,"CreationDate":"2019-05-17T20:03:00.000","Title":"Which conditional statement is more pythonic?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem. Last year I developed a Telegram Gateway that uses a socket and the Telethon library (installed through pip).\nThe problem is that this project is installed in an other pc and uses an old version of Telethon, foundamental to use thread (with the new Telethon version I can't use the thread with socket etc., it is changed). \nI need to install the same Telethon version in order to use the same gateway.\nIn the pc, if I run the command:\npip show telethon\nit shows the following message:\nYou are using pip version 8.1.1, however version 19.1.1 is available. You should consider upgrading via etc......\nThen, I need to install the same version of telethon (8.1.1).\nBut if I try to install it in an other pc, through this command:\npip3 install telethon==8.1.1\nit prints the following red error message:\nNo matching distribution found for telethon==8.1.1\nWhy?\nI really need to use the same version of telethon, in order to run the old gateway.\nThank you very much!!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":653,"Q_Id":56194596,"Users Score":1,"Answer":"That line is a message printed by pip telling you to consider upgrading pip itself. The version number you are looking for is printed below it:\n\n$ pip3 show telethon\nYou are using pip version 8.1.1, however version 19.0.3 is available.\nYou should consider upgrading via the 'pip install --upgrade pip' command.\nName: Telethon\nVersion: 1.6.2\nSummary: Full-featured Telegram client library for Python 3\nHome-page: https:\/\/github.com\/LonamiWebs\/Telethon\nAuthor: Lonami Exo\nAuthor-email: totufals@hotmail.com\nLicense: MIT\nLocation: \/usr\/local\/lib\/python3.7\/site-packages\nRequires: rsa, pyaes\nRequired-by:","Q_Score":0,"Tags":"python,pip,telethon","A_Id":56194768,"CreationDate":"2019-05-17T23:11:00.000","Title":"Old version of Telethon","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I redirect the output of python version into a text file in linux? \nI tried the following:\npython --version > old.txt\nThe text file is getting created but it is empty.\nSimple question, but beginner here.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":109,"Q_Id":56195033,"Users Score":4,"Answer":"The Python version is output to stderr rather than stdout which is what your command is writing to the file. In order to write the contents of stderr you will want to write:\npython --version 2> old.txt","Q_Score":1,"Tags":"python,linux,centos","A_Id":56195038,"CreationDate":"2019-05-18T00:31:00.000","Title":"Redirecting python version output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I know that the file db.sqlite3 in Django holds the entire database and the entire content within it. Is it safe to keep all the project files, the *.py files, the migrations files, but replace the db.sqlite3 file with a different one. If both these db.sqlite3 files work on the same database model, with the same tables, rows, columns, and everything, then if I swap out that file it should work seamlessly.\nI want to copy the original db.sqlite3 file into a different directory. Then I want to create a new db.sqlite3 file in my project. Then I want to work with the new database file, and give it other data to test how the project would work with it. Then I want to delete the new db.sqlite3 file, and I want to restore the old one, which I've saved into another directory.\nWould that work? And how can I create a new db.sqlite3 file, a clean state to put test data into?\nAlso, what if I build my project on another sever, can I copy my old db.sqlite3 file there too, and have the database with all it's saved data restored?\nBasically, the main idea of my question is: are we to treat the db.sqlite3 file as a simple \"text file\" with input\/output data for our program, something that is freely interchangeable?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":631,"Q_Id":56196650,"Users Score":3,"Answer":"The whole of the database lives in the .db file. You can safely copy it in either direction when there is no process running against the database. If there is a process running against the database then you might see rollback journal files or write-ahead log files in the same directory (if the database is in WAL mode) and if you leave these behind you might risk losing some pending transactions. Closing the database properly generally causes these files to disappear.","Q_Score":1,"Tags":"python,django,sqlite,django-models","A_Id":56196702,"CreationDate":"2019-05-18T06:49:00.000","Title":"Can I arbitrarily replace and restore the db.sqlite3 file?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know that the file db.sqlite3 in Django holds the entire database and the entire content within it. Is it safe to keep all the project files, the *.py files, the migrations files, but replace the db.sqlite3 file with a different one. If both these db.sqlite3 files work on the same database model, with the same tables, rows, columns, and everything, then if I swap out that file it should work seamlessly.\nI want to copy the original db.sqlite3 file into a different directory. Then I want to create a new db.sqlite3 file in my project. Then I want to work with the new database file, and give it other data to test how the project would work with it. Then I want to delete the new db.sqlite3 file, and I want to restore the old one, which I've saved into another directory.\nWould that work? And how can I create a new db.sqlite3 file, a clean state to put test data into?\nAlso, what if I build my project on another sever, can I copy my old db.sqlite3 file there too, and have the database with all it's saved data restored?\nBasically, the main idea of my question is: are we to treat the db.sqlite3 file as a simple \"text file\" with input\/output data for our program, something that is freely interchangeable?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":631,"Q_Id":56196650,"Users Score":1,"Answer":"Yes, whole sqlite database is contained in one file, so you can freely move, replace, push it with django project (althought it's not recommended) and it will work fine.\nEven if you have 2 different projects with same apps, same model structure and migrations, you can swap them.\nIf you remove your db.sqlite3 and want to create new one, just run python manage.py migrate and it will create new database and apply all migrations.","Q_Score":1,"Tags":"python,django,sqlite,django-models","A_Id":56196701,"CreationDate":"2019-05-18T06:49:00.000","Title":"Can I arbitrarily replace and restore the db.sqlite3 file?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to remove the topbar of a window (the title, icon, resize and close window buttons) without root.overrideredirect(True) because this method will toggle other things that I need too. Is there a different way to remove the topbar with tkinter?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":56198979,"Users Score":0,"Answer":"The only way to remove it is with overrideredirect.","Q_Score":0,"Tags":"python-3.x,tkinter","A_Id":56200116,"CreationDate":"2019-05-18T12:33:00.000","Title":"Need to remove windows topbar in tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning Python, and have just been using editors so far, but now I am starting to move up to the PyCharm Community IDE. I am curious why, when I run the Python function: type('Insert string here') in the IDLE editor or in SublimeText or Atom, it finishes with <class 'str'>, but when I run the exact same function in PyCharm, it does finish without error, but it returns nothing to the console.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":56199279,"Users Score":1,"Answer":"As jonrsharpe said in the comment, the difference between the outcomes is probably because of the change from a REPL to running a script. I did some research on this topic, and I learned that PyCharm just interacts differently to code than SublimeText or IDLE.","Q_Score":1,"Tags":"python,python-3.x,pycharm","A_Id":56199376,"CreationDate":"2019-05-18T13:11:00.000","Title":"Why does the Python function: type(\"This is a string') - return no results in the PyCharm IDE, but it returns  in IDLE and other editors?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have setup my Django project with Vagrant and everything works well. When I open it in PyCharm in Windows though, I get many reference errors in the code and also \"Package requirements are not satisfied\" prompts to install libraries. The problem is, these are already installed in virtual environment (I know because otherwise the project wouldn't work at all). \nIs there any way to let PyCharm know that these dependencies are already installed, and let it know where to find them? \nI have already added the project interpreter in project settings to the one under the \/venv directory of my project.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":48,"Q_Id":56203235,"Users Score":-1,"Answer":"Not enough information. Pycharm is usually clear where the error lies. I'm assuming you correctly entered the path to the python file in the bin directory? \nOtherwise as long as you have requirements.txt just make another environment through Pycharm and try seeing the difference.","Q_Score":0,"Tags":"python,django,pycharm,vagrant","A_Id":56203609,"CreationDate":"2019-05-18T22:12:00.000","Title":"Does PyCharm use dependencies installed in virtual env when accessing the project through Vagrant?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have an airflow DAG that has over 100,000 tasks.\nI am able to run only up to 1000 tasks. Beyond that the scheduler hangs, the webserver cannot render tasks and is extremely slow on the UI.\nI have tried increasing, min_file_process_interval and processor_poll_interval config params.\nI have set num_duration to 3600 so that scheduler restarts every hour.\nAny limits I'm hitting on the webserver or scheduler? In general, how to deal with a large number of tasks in Airflow? Any config settings, etc would be very helpful.\nAlso, should I be using SubDagOperator at this scale or not? please advice.\nThanks,","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1319,"Q_Id":56203824,"Users Score":0,"Answer":"I was able to run more than 165,000 airflow tasks!\nBut there's a catch. Not all the tasks were scheduled and rendered in a single Airflow Dag.\nThe problems I faced when I tried to schedule more and more tasks are that of scheduler and webserver.\nThe memory and cpu consumption on scheduler and webserver dramatically increased as more and more tasks were being scheduled (it is obvious and makes sense). It went to a point where the node couldn't handle it anymore (scheduler was using over 80GB memory for 16,000+ tasks)\nI split the single dag into 2 dags. One is a leader\/master. The second one being the worker dag.\nI have an airflow variable that says how many tasks to process at once (for example, num_tasks=10,000). Since I have over 165,000 tasks, the worker dag will process 10k tasks at a time in 17 batches.\nThe leader dag, all it does is trigger the same worker dag over and over with different sets of 10k tasks and monitor the worker dag run status. The first trigger operator triggers the worker dag for the first set of 10k tasks and keeps waiting until the worker dag completes. Once it's complete, it triggers the same worker dag with the next batch of 10k tasks and so on.\nThis way, the worker dag keeps being reused and never have to schedule more than X num_tasks\nThe bottom line is, figure out the max_number of tasks your Airflow setup can handle. And then launch the dags in leader\/worker fashion for max_tasks over and over again until all the tasks are done.\nHope this was helpful.","Q_Score":4,"Tags":"python,python-3.x,airflow,airflow-scheduler","A_Id":62958902,"CreationDate":"2019-05-19T00:17:00.000","Title":"How to run Airflow dag with more than 100 thousand tasks?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have set of threads which can execute a synchronized method in python. Currently when a thread comes to critical section it enters to the critical section if no thread is executing the critical section. Otherwise  wait and enter the critical section after lock is released. (it works as synchronization supposed to work). But I have a high priority thread which should enter the critical section whether a low priority thread is in the critical section or not. Is this possible? If so how can I implement this?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1241,"Q_Id":56204232,"Users Score":2,"Answer":"As another answer described very well, this is not possible, there is no way to do it.\nWhat you can and often should do is prevent another lower priority thread from entering this critical section first, before high priority thread. \nI.e. if a critical section is being held by some thread, this thread needs to exit it first. But by that time there might be multiple threads waiting for this critical section, some low and some high priority. You may want to ensure higher priority thread gets the critical section first in such situation.","Q_Score":2,"Tags":"python,python-3.x,multithreading","A_Id":56204377,"CreationDate":"2019-05-19T02:12:00.000","Title":"Let high priority python thread to enter the critical section while low priority thread is execution in the critical section","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When using the logging library, when should I log using DEBUG, and when should I use INFO instead? All I know is that they are used to show what a program is doing during normal operation.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":711,"Q_Id":56208605,"Users Score":1,"Answer":"If you view your log messages as part of your application's user interface, INFO messages are for consumption by the administrators or users, whereas debug messages are for consumption by its programmers.  Messages should be designed and emitted with this in mind.","Q_Score":1,"Tags":"python,debugging,logging","A_Id":56215409,"CreationDate":"2019-05-19T14:10:00.000","Title":"What is the difference between DEBUG and INFO in Python logging?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing dialect text classification and I'm using countVectorizer with naive bayes. The number of features are too many, I have collected 20k tweets with 4 dialects. every dialect have 5000 tweets. And the total number of features are 43K. I was thinking maybe that's why I could be having overfitting. Because the accuracy has dropped a lot when I tested on new data. So how can I fix the number of features to avoid overfitting the data?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":471,"Q_Id":56211670,"Users Score":2,"Answer":"You can set the parameter max_features to 5000 for instance, It might help with overfitting. You could also tinker with max_df (for instance set it to 0.95)","Q_Score":0,"Tags":"python,nlp,text-classification,naivebayes,countvectorizer","A_Id":56211743,"CreationDate":"2019-05-19T20:18:00.000","Title":"How to reduce the number of features in text classification?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working in Spyder 3 (Python 3.7) on my home PC, but just a couple of hours ago Spyder crashed. I don't know what coused the crash, but I received this error message in my anaconda promt when trying to start Spyder from there:\n\n\"valueerror: _isdir: embedded null character in path\"\n\nThere is also an error message pop-up window that says \"Spyder crashed during last session\", and tells me to try to use the command spyder--reset, but this does not work.\nHas anyone here encountered the same problem and knows what to do? Or should I just try to reinstall the software and hope it works? In the case that I reinstall, what files and packages will I lose?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":705,"Q_Id":56212037,"Users Score":0,"Answer":"spyder --reset did not work for me.\nI manually deleted the folders like \".spyder\", \".spyder_bak\" etc in my user folder, and finally it worked.","Q_Score":0,"Tags":"python,anaconda,spyder,filepath","A_Id":68496069,"CreationDate":"2019-05-19T21:12:00.000","Title":"valueerror: _isdir: embedded null character in path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to use os.popen() to achieve a result similar to os.system? I know that os.popen() is more secure, but I want to know how to be able to actually run the commands through this function. When using os.system(), things can get very insecure and I want to be able to have a secure way of accessing terminal commands.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":495,"Q_Id":56212056,"Users Score":3,"Answer":"Anything that uses the shell to execute commands is insecure for obvious reasons (you don't want someone running rm -rf \/ in your shell :). Both os.system and os.popen use the shell.\nFor security, use the subprocess module with shell = False\nEither way, both of those functions have been deprecated since Python 2.6","Q_Score":1,"Tags":"python,popen,python-os","A_Id":56212206,"CreationDate":"2019-05-19T21:14:00.000","Title":"Replace os.system with os.popen for security purposes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"There are 2 huge (5-6 GB) each csv files. Now the objective is to compare both these files. how many rows are matching and how many rows are not matching? \nLets say file1.csv contains 5 similar lines, we need to count it as 1 but not 5.\nSimilarly, for file2.csv if there are redundant data, we need to count it as 1.\nI expect the output to display the number of rows that are matching and the no. of rows that are different.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":196,"Q_Id":56216081,"Users Score":0,"Answer":"I hope this algorithm work\n\ncreate hash of every line in both file\nnow create set of that hash\ndifference and intersection of that set.","Q_Score":2,"Tags":"python,python-3.x,python-2.7","A_Id":56238216,"CreationDate":"2019-05-20T07:23:00.000","Title":"Comparing 2 huge (5-6 GB) csv files and count the number of matching and unmatched no. of rows","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My Telegram bot code was working fine for weeks and I didn't changed anything today suddenly I got [SSL: CERTIFICATE_VERIFY_FAILED] error and my bot code no longer working in my PC.\nI use Ubuntu 18.04 and I'm usng telepot library.\nWhat is wrong and how to fix it?\nEdit: I'm using getMe method and I don't know where is the certificate and how to renew it and I didn't import requests in my bot code. I'm using telepot API by importing telepot in my code.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1148,"Q_Id":56220056,"Users Score":1,"Answer":"Probably your certificate expired, that is why it worked fine earlier. Just renew it and all should be good. If you're using requests under the hood you can just pass verify=False to the post or get method but that is unwise.\nThe renew procedure depends on from where do you get your certificate. If your using letsencrypt for example with certbot. Issuing sudo certbot renew command from shell will suffice.","Q_Score":2,"Tags":"python,python-3.x,ssl,telegram-bot,telepot","A_Id":56220074,"CreationDate":"2019-05-20T11:26:00.000","Title":"\"SSL: CERTIFICATE_VERIFY_FAILED\" error in 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 have a tf.data.TFRecordDataset and a (computationally expensive) function, which I want to map to it. I use TensorFlow 1.12 and eager execution, and the function uses NumPy ndarray interpretations of the tensors in my dataset using EagerTensor.numpy(). However, code inside functions that are given to tf.Dataset.map() are not executed eagerly, which is why the .numpy() conversion doesn't work there and .map() is not an option anymore. Is it possible to for-loop through a dataset and modify the examples in it? Simply assigning to them doesn't seem to work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":582,"Q_Id":56220696,"Users Score":1,"Answer":"No, not exactly. \nA Dataset is inherently lazily evaluated and cannot be assigned to in that way - conceptually try to think of it as a pipeline rather than a variable: each value is read, passed through any map() operations, batch() ops, etc and surfaced to the model as needed. To \"assign\" a value would be to write it to disk in the .tfrecord file and just isn't likely to ever be supported (these files are specifically designed to be fast-read not random-accessed).\nYou could, instead, use TensorFlow to do your pre-processing and use TfRecordWriter to write to a NEW tfrecord with the expensive pre-processing completed then use this new dataset as the input to your model. If you have the disk space avilable this might well be your best option.","Q_Score":1,"Tags":"python,tensorflow,tensor,map-function","A_Id":56221192,"CreationDate":"2019-05-20T12:05:00.000","Title":"TensorFlow: Is it possible to map a function to a dataset using a for-loop?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can I use cross_validate in sklearn with cv=10 to instead of using Kfold with n_splits=10? Does they work as same?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":171,"Q_Id":56221694,"Users Score":0,"Answer":"I believe that KFold will simply carve your training data into 10 splits.\ncross_validate, however, will also carve the data into 10 splits (with the cv=10 parameter) but it will also actually perform the cross-validation. In other words, it will run your model 10x and you will be able to report on the performance of your model, which KFold does not do.\nIn other words, KFold is 1 small step in cross_validation.","Q_Score":0,"Tags":"python,scikit-learn","A_Id":56222077,"CreationDate":"2019-05-20T13:10:00.000","Title":"Differences between sklearn.model_selection.KFold and sklearn.model_selection.cross_validate with 'cv' parameter?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pretty standard Django project with several apps, each with its own urls, models, forms, etc...\nMy issue is that whenever I make a mistake in my code - e.g. writing a wrong name for a model field in a form \"fields\" attribute - the error raised is always the same:\ndjango.core.exceptions.ImproperlyConfigured: The included URLconf 'myproject.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.\nI would expect the error message to change according to the error made. This not happening makes everything extremely difficult to debug.\nAny ideas?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":56222594,"Users Score":0,"Answer":"When you run a Django project using runserver, Django loads the URL patterns. Usually, inside your URL patterns you import your views. Which in turn import your models and forms. \nSo if any of these files contains a syntax error or a python error at the top level (see below), this will cause loading the URLs to fail. However, if you scroll up your trace, you should see another error, the actual error that caused the imports to fail. It will say somewhere \"during handling of this exception another exception occurred\".\nHowever, python is not actually running all the code it imports. A class definition will just cause python to read the class name and its attributes (a method is also an attribute). \nWhen python imports a class, it calls its __new__() method, not its __init__() method or any other method you define. So only errors at the top level of the class (e.g. using unknown variables in the definition of attributes) or errors inside the Meta class will be thrown.\n** edit **: fields = ['some_field'] inside the Meta class is indeed run when the class object is created (__new__() method) and Django will check if the field exists in the corresponding model, because it assigns it to the class's _meta attribute.\nIn other cases, when you say \"whenever I make a mistake in my code\" that should generally not raise an error because python should not be actually instantiating the form (running its __init__() method) or running any of the methods you write. So you should avoid instantiating any classes at the top level of your code, instantiation should happen inside of functions\/methods, then python won't hit these errors.\nSo check your views.py files to see if you are just importing form classes (from my_forms import MyForm) or if you are also instantiating a form at the top level of your file (form = MyForm(), note the parenthesis) or as an attribute of a class-based view.","Q_Score":1,"Tags":"python,django","A_Id":56224777,"CreationDate":"2019-05-20T14:03:00.000","Title":"Different bugs always raise the same error: ImproperlyConfigured: The included URLconf 'myproject.urls' does not appear to have any patterns in it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have installed Python at C:\\Users\\xxxx\\AppData\\Local\\Programs\\Python\\Python37-32 location and the version is Python 3.7.3. \nTo install pip, I downloaded pip-19.1.1-py2.py3-none-any.whl (1.4 MB) from pypi.org website and placed it in C:\\Users\\xxxx\\AppData\\Local\\Programs\\Python\\Python37-32. In the command prompt I entered \ncd C:\\Users\\xxxx\\AppData\\Local\\Programs\\Python\\Python37-32 \npython pip-19.1.1-py2.py3-none-any.whl\nI am getting an error as below: can't find '__main__' module in 'pip-19.1.1-py2.py3-none-any.whl'\nany help on how this error can be resolved?\nTIA!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":966,"Q_Id":56222981,"Users Score":0,"Answer":"I got this issue resolved by performing a Python re-installation. While I selected 'Modify' option, I saw that the 'Add python path to environment variable' was unchecked. I checked this option and performed a re-installation. This installed pip also for me.","Q_Score":0,"Tags":"python,pip","A_Id":56223152,"CreationDate":"2019-05-20T14:26:00.000","Title":"Pip installation failure - can't find '__main__' module in 'pip-19.1.1-py2.py3-none-any.whl'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Python at C:\\Users\\xxxx\\AppData\\Local\\Programs\\Python\\Python37-32 location and the version is Python 3.7.3. \nTo install pip, I downloaded pip-19.1.1-py2.py3-none-any.whl (1.4 MB) from pypi.org website and placed it in C:\\Users\\xxxx\\AppData\\Local\\Programs\\Python\\Python37-32. In the command prompt I entered \ncd C:\\Users\\xxxx\\AppData\\Local\\Programs\\Python\\Python37-32 \npython pip-19.1.1-py2.py3-none-any.whl\nI am getting an error as below: can't find '__main__' module in 'pip-19.1.1-py2.py3-none-any.whl'\nany help on how this error can be resolved?\nTIA!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":966,"Q_Id":56222981,"Users Score":0,"Answer":"Your python must have pip as default \nBut otherwise try python3 instead of python in installation","Q_Score":0,"Tags":"python,pip","A_Id":56223196,"CreationDate":"2019-05-20T14:26:00.000","Title":"Pip installation failure - can't find '__main__' module in 'pip-19.1.1-py2.py3-none-any.whl'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a driver which is written in C#, .NET 4.7.0 and build as DLL. I don't have sources from this driver. I want to use this driver in python application.\nI wrapped some functionality from driver into method of another C# project. Then I built it into DLL. I used RGiesecke.DllExport to make one method available in python. When i call this method from python using ctypes, I get WinError -532462766 Windows Error 0xe0434352.\nIf I exclude driver code and keep only wrapper code in exported method everything runs fine.\nCould you please give me some advice how to make this working or help me find better sollution? Moving from python to IronPython is no option here.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":306,"Q_Id":56224958,"Users Score":0,"Answer":"PROBLEM CAUSE:\nPython didn't run wrapper from directory where it was stored together with driver. That caused problem with loading driver.","Q_Score":1,"Tags":"c#,python,dll,wrapper,dllexport","A_Id":56241575,"CreationDate":"2019-05-20T16:35:00.000","Title":"Use C# DLL in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I add an additional CA (certificate authority) to the trust store used by my Python3 AWS Lambda function?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6930,"Q_Id":56225178,"Users Score":5,"Answer":"If you only need a single CA, then get your crt file and encode it into a pem using the following command in linux:\n\nopenssl x509 -text -in \"{your CA}.crt\" > cacert.pem\n\nIf you need to add CA's to the default CA bundle, then copy python3.8\/site-packages\/certifi\/cacert.pem to your lambda folder. Then run this command for each crt:\n\nopenssl x509 -text -in \"{your CA}.crt\" >> cacert.pem\n\nAfter creating the pem file, deploy your lambda with the REQUESTS_CA_BUNDLE environment variable set to \/var\/task\/cacert.pem. \n\/var\/task is where AWS Lambda extracts your zipped up code to.","Q_Score":6,"Tags":"python,python-3.x,amazon-web-services,aws-lambda,ssl-certificate","A_Id":59638101,"CreationDate":"2019-05-20T16:51:00.000","Title":"Python AWS Lambda Certificates","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 bokeh plot with multiple y axes. I want to be able to zoom in one y axis while having the other one's displayed range stay the same. Is this possible in bokeh, and if it is, how can I accomplish that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27,"Q_Id":56225582,"Users Score":0,"Answer":"Bokeh does not support this, twin axes are always linked to maintain their original relative scale.","Q_Score":0,"Tags":"python,bokeh","A_Id":56226834,"CreationDate":"2019-05-20T17:25:00.000","Title":"How to make multiple y axes zoomable individually","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am programmatically creating csv files using Python. Many end users open and interact with those files using excel. The problem is that Excel by default mutates many of the string values within the file. For example, Excel converts 0123 > 123.\nThe values being written to the csv are correct and display correctly if I open them with some other program, such as Notepad. If I open a file with Excel, save it, then open it with Notepad, the file now contains incorrect values.\nI know that there are ways for an end user to change their Excel settings to disable this behavior, but asking every single user to do so is not possible for my situation.\nIs there a way to generate a csv file using Python that a default copy of Excel will NOT mutate the values of?\nEdit: Although these files are often opened in Excel, they are not only opened in Excel and must be output as .csv, not .xlsx.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":190,"Q_Id":56227867,"Users Score":1,"Answer":"Have you tried expressly formatting the relevant column(s) to 'str' before exporting?\ndf['column_ex'] = df['column_ex'].astype('str')\ndf.to_csv('df_ex.csv')\nAnother workaround may be to open Excel program (not file), go to Data menu, then Import form Text. Excel's import utility will give you options to define each column's data type. I believe Apache's Liibre office defaults to keep the leading 0s but Excel doesn't.","Q_Score":1,"Tags":"python,excel,python-3.x,string,csv","A_Id":56228359,"CreationDate":"2019-05-20T20:37:00.000","Title":"Create a csv file that Excel will not mutate the data of when opening","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If you are using anaconda, then you probably noticed that when installing python packages, it took away the disks in C drive even if you installed anaconda in D drive. (I have tried the clean ect. of conda commands, it's not the cashes or other things but rather useful files.) \nThis was especially obvious when I was trying to install different versions of tensorflow and Keras packages. It took away almost 20 GBs of disks from my laptop.\nMy question was how to avoid such issue and make sure anaconda was only using the disks in, i.e. D drive?(in windows environment )","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1072,"Q_Id":56228764,"Users Score":1,"Answer":"try changing the paths of the environment variables","Q_Score":3,"Tags":"python,windows,installation,package,anaconda","A_Id":56228904,"CreationDate":"2019-05-20T22:05:00.000","Title":"How to avoid anaconda from installing files\/packages in C drive?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a shell script that runs some java program on a remote server. \nBut this shell script is to be executed by a python script which is on my local machine.\nHere's the flow : Python script executes the shell script (with paramiko), the shell script then executes a java class. \nI am getting an error : 'The java class could not be loaded. java.lang.UnsupportedClassVersionError:  (Unsupported major.minor version 50.0)' whenever I run python code.\nLimitations: I cannot make any changes to the shell script.\nI believe this is java version issue. But I don't know how to explicitly have a python program to run in a specific java environment.\nPlease suggest how I can get rid of this error.\nThe java version of unix machine (where shell script executes) : 1.6.0\nJava version of my local machine (where python script executes): 1.7.0","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":49,"Q_Id":56232838,"Users Score":1,"Answer":"The shell script can stay the same, update java on the remote system to java 1.7 or later. Then it should work.\nAnother possibility could be to compile the java application for java 1.6 instead. The java compiler (javac) has the arguments -source and -target and adding -source 1.6 -target 1.6 when compiling the application should solve this issue, too (but limits the application to use java 1.6 features).\nAlso be aware: If you use a build system like gradle or maven, then you have a different way to set source and target version.","Q_Score":0,"Tags":"java,python-3.x,sh","A_Id":56232988,"CreationDate":"2019-05-21T07:05:00.000","Title":"Unsupported major.minor version when running a java program from shell script which is executed by a python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I had so many Python installations that it was getting frustrating, so I decided to do a full reinstall. I removed the \/Library\/Frameworks\/Python.Frameworks\/ folder, and meant to remove the \/usr\/local\/bin\/python folder too, but I accidentally removed the \/usr\/bin\/python instead. I don't see any difference, everything seems to be working fine for now, but I've read multiple articles online saying that I should never touch \/usr\/bin\/python as OS X uses it and things will break.\nI tried Time Machine but there are no viable recovery options. How can I manually \"restore\" what was deleted? Do I even need to, since everything seems to be working fine for now? I haven't restarted the Mac yet, in fear that things might break.\nI believe the exact command I ran was rm -rf \/usr\/bin\/python*, and I don't have anything python related in my \/usr\/bin\/ folder.\nI'm running on macOS Mojave 10.14.5","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1220,"Q_Id":56233672,"Users Score":1,"Answer":"Items can't be recovered when you perform rm -rf. However, you can try the following:\ncp \/usr\/local\/bin\/python* \/usr\/bin \nThis would copy user local python to usr bin and most probably will bail you out.\nDon't worry, nothing will happen to your OS. It should work fine :)","Q_Score":0,"Tags":"python,macos,terminal","A_Id":56233846,"CreationDate":"2019-05-21T07:54:00.000","Title":"Accidentally deleted \/usr\/bin\/python instead of \/usr\/local\/bin\/python on OS X\/macOS, how to restore?","Data Science and Machine Learning":0,"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 go implement  a hierarchical resnet architecture. However, I could not find any solution for this. For example, my data structure is like:\n\nclass A\n\n\nSubclass 1\nSubclass 2\n....\n\nclass B\n\n\nsubclass 6\n........\n\n\nSo i would like to train and predict the main class and then the subclass of the chosen\/predicted mainclass. Can someone provide a simple example how to do this with generators?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":286,"Q_Id":56235267,"Users Score":0,"Answer":"The easiest way to do so would be to train multiple classifiers and build a hierarchical system by yourself.\nOne classifier detecting class A, B etc. After that make a new prediction for subclasses.\nIf you want only one single classifier:\nWhat about just killing the first hierarchy of parent classes? Should be also quite easy. If you really want a model, where the hierarchy is learned take a look at Hierarchical Multi-Label Classification Networks.","Q_Score":0,"Tags":"python,keras,conv-neural-network,hierarchical,deep-residual-networks","A_Id":56241130,"CreationDate":"2019-05-21T09:29:00.000","Title":"How to build a resnet with Keras that trains and predicts the subclass from the main class?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to create conda env anytime creating a new project. recently i find out anaconda create every single package in its environment even it exist in base anacoda package .so in this situation is it rational using anacoda?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":873,"Q_Id":56239072,"Users Score":2,"Answer":"You are doing great by creating separate environment for each of your projects. The aim of environments is to keep your projects dependencies separate. This means, your project will have only necessary packages.\nThe problem of using a single environment is that if you update some packages, you are most likely going to destroy something. Example, if you have a project that works only in PACKAGE 1.0, install a package that would update your PACKAGE 1.0 is going to break all your scripts that depends on it. The large the environment, the more likely you would break some dependence. By having separate environments, you are sure that your scripts would always run :)\nAnother beautiful thing is that of reproducibility. You can save your dependence with there right Python versions.\nUpdate: A simple answer\nNo, you don\u2019t have too create environment for each project. It is a good practice but not a must. If the project uses the same packages, then reusing environments is a smart move. But the moment there exists differences in used packages, then I would recommend separate environments.","Q_Score":0,"Tags":"python,anaconda","A_Id":56240124,"CreationDate":"2019-05-21T13:11:00.000","Title":"Using anaconda with multiple conda env","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Could not find a version that satisfies the requirement torch>=1.0.0 \nNo matching distribution found for torch>=1.0.0 (from stanfordnlp)","AnswerCount":12,"Available Count":3,"Score":0.0831409664,"is_accepted":false,"ViewCount":95229,"Q_Id":56239310,"Users Score":5,"Answer":"I finally managed to solve this problem thanks to John Red' comment and serg06 answer. Here's what I've done :\n\nInstall Python 3.7.9 and not newer.\nBUT make sure to install 64bits python\n\nEvery other combination failed for me.","Q_Score":40,"Tags":"python,torch","A_Id":70215508,"CreationDate":"2019-05-21T13:23:00.000","Title":"Could not find a version that satisfies the requirement torch>=1.0.0?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Could not find a version that satisfies the requirement torch>=1.0.0 \nNo matching distribution found for torch>=1.0.0 (from stanfordnlp)","AnswerCount":12,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":95229,"Q_Id":56239310,"Users Score":0,"Answer":"I tried every possible command for Windows, but nothing worked. I also tried using Pycharm package installation, everything throws the same error.\nFinally installed Pytorch using Anaconda.","Q_Score":40,"Tags":"python,torch","A_Id":63728120,"CreationDate":"2019-05-21T13:23:00.000","Title":"Could not find a version that satisfies the requirement torch>=1.0.0?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Could not find a version that satisfies the requirement torch>=1.0.0 \nNo matching distribution found for torch>=1.0.0 (from stanfordnlp)","AnswerCount":12,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":95229,"Q_Id":56239310,"Users Score":0,"Answer":"I want to pip install  \" torch>=1.4.0,  torchvision>=0.5.0 \",  but in a conda env with python=3.0, this is not right.\nI tried create a new conda env with python=3.7, and pip install  \" torch>=1.4.0,  torchvision>=0.5.0 \" again, it is ok.","Q_Score":40,"Tags":"python,torch","A_Id":71016393,"CreationDate":"2019-05-21T13:23:00.000","Title":"Could not find a version that satisfies the requirement torch>=1.0.0?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"On the limited Azure Machine Learning Studio, one can import data from an On-Premises SQL Server Database.\nWhat about the ability to do the exact same thing on a python jupyter notebook on a virtual machine from the Azure Machine Learning Services workspace ?\nIt does not seem possible from what I've found in the documentation.\nData sources would be limited in Azure ML Services : \"Currently, the list of supported Azure storage services that can be registered as datastores are Azure Blob Container, Azure File Share, Azure Data Lake, Azure Data Lake Gen2, Azure SQL Database, Azure PostgreSQL, and Databricks File System\"\nThank you in advance for your assistance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1048,"Q_Id":56240481,"Users Score":0,"Answer":"You can always push the data to a supported source using a data movement\/orchestration service.  Remember that all Azure services are not going to have every source option like Power BI, Logic Apps or Data Factory...this is why data orchestration\/movement services exist.","Q_Score":0,"Tags":"python,sql,azure,jupyter-notebook,azure-machine-learning-service","A_Id":56327491,"CreationDate":"2019-05-21T14:26:00.000","Title":"Can I import data from On-Premises SQL Server Database to Azure Machine Learning virtual machine?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"First time posting here,by the way, i've got an issue with this particular line of Python (3.6) code: \nfile_converted = pandoc.convert_file(PATH_TO_ODT, 'pdf', format=\"odt\", outputfile=file_name + \".pdf\", extra_args=['--pdf-engine=pdflatex'])\nWhen i execute the script (to convert a .odt file to a .pdf file) , i encounter the following error :\nRuntimeError: Pandoc died with exitcode \"47\" during conversion: b'pdflatex not found. Please select a different --pdf-engine or install pdflatex \nBasically i understand that i need \"pdflatex\" , but after i've installed it via pip with the command \npip install pdflatex, the execution produce the same error message, what i should do or check? \nthank you all.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1690,"Q_Id":56242665,"Users Score":0,"Answer":"MB21:: Pandoc actually does its own conversion - very involved algorithm. I viewed a presentation of the main author (John MacFarlene) recently, pandoc actually translates the source to it's own internal format, AST. From AST format, it is able to convert to a long list of document formats. So, pandoc doesn't just invoke pdflatex.","Q_Score":3,"Tags":"python-3.x,pandoc,pypandoc","A_Id":67695101,"CreationDate":"2019-05-21T16:26:00.000","Title":"Pypandoc error , RuntimeError: Pandoc died with exitcode \"47\" during conversion: b'pdflatex not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am wondering what \"as_\" in django query means. I have 1 query: User.objects.filter(username = \"some_username\").as_manager.something but in User model there is no \"as_manager\". Then in some other model called \"Manager\" I got \"something\" which is exactly what is returned. Is it some kind of deep django knowledge that \"as_\" can guide me to other model? Or is it \"as_manager\" somewhere which I cannot spotted.\nI only add that User model extends from django AbstractUser.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":262,"Q_Id":56243658,"Users Score":1,"Answer":"Fair question. I've wondered myself. But, looking through the source code, it only seems to prepend any particular methods\/functions that present the object in certain formats or already defined objects like say:\n\nas_sql\nas_view\nas_table\nas_p\netc...\n\nI don't think it means anything as far as a \"magical\" construct or dynamic function name.","Q_Score":1,"Tags":"python,django,model","A_Id":56243763,"CreationDate":"2019-05-21T17:35:00.000","Title":"What does \"as_\" in django query means?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I built a crawler that gets the product information of a list of products entered by the user. Sometimes, the crawler freezes, especially if the list of products is long and if the crawler runs on headless mode.\nThe bug seems random and is not reproducible, which makes me think it is caused by the resource utilization of the website being crawled. \nSince this is a non-reproducible bug, I don't think I can fix it, but is there a way to detect that the crawler has frozen and try again?\nHere is some information about the crawler and the bug:\n\nThe crawler is built using Selenium and Python.\nThe bug occurs with different websites and products.\nThe bug occurs in the \"normal\" mode, but occurs more often in the headless mode.\n\nThanks!\nFelipe","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":239,"Q_Id":56247296,"Users Score":0,"Answer":"If the problem isn't related to the browser, it is because the code is busy on getting data in headless mode. If your code working in the normal mode instead of headless mode, you see only the working part.\nI assume you made a GUI. If it is so, you are trying to access GUI but the same program working on crawling. That's why GUI is freezing.\nYou can solve this by using the Threading library or any other multiprocessing method. This will allow you to run more than one process at the same time. So, you can freely use other functions on the GUI and crawl a website without freezing.","Q_Score":1,"Tags":"python,selenium,web-scraping,web-crawler,headless","A_Id":63178050,"CreationDate":"2019-05-21T22:57:00.000","Title":"Python-Selenium crawler freezes, especially in headless mode (non reproducible bug)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed anaocnda but I am not able to find navigator. I also tried using prompt to run jupyter notebook but the command could't run. Does it have something to do with the path? \nBelow is the message that I get every time I try to run a command\n\nC:\\Users\\vikas\\Anaconda3\\Scripts\\activate.bat' is not recognized as an internal or external command,\n  operable program or batch file.\nC:\\Users\\vikas>jupyter notebook\n  Error executing Jupyter command 'notebook': [Errno 'jupyter-notebook' not found] 2\nC:\\Users\\vikas>python\n  'python' is not recognized as an internal or external command,\n  operable program or batch file.\nC:\\Users\\vikas>spyder\n  'spyder' is not recognized as an internal or external command,\n  operable program or batch file.\nC:\\Users\\vikas>","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2356,"Q_Id":56249798,"Users Score":0,"Answer":"You should type 'anaconda-navigator'. That will kick off aaconda-navigator. This is installed in the bin directory under anaconda3. There is also an Anaconda-Navigator.app in the Applications folder.","Q_Score":1,"Tags":"python,anaconda,spyder,prompt","A_Id":56264288,"CreationDate":"2019-05-22T05:23:00.000","Title":"I am not able to find anaconda navigator after installing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to import numpy with python3 on MacOS mojave. I am getting this error. I don't know if it has something to do with a virtual environment or something like that.\nError:\nPyCapsule_Import could not import module \"datetime\"\nI have tried reinstalling python3 and reinstalling numpy","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2527,"Q_Id":56252250,"Users Score":5,"Answer":"In my case I had this problem, because my script was called math.py, which caused module import problems. Make sure your own python files do not share name with some of common module names. After I renamed my script to something else, I could run script normally.","Q_Score":3,"Tags":"python-3.x,numpy,pip","A_Id":60404903,"CreationDate":"2019-05-22T08:17:00.000","Title":"Python3 numpy import error PyCapsule_Import could not import module \"datetime\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having some text files in S3 location. I am trying to compress and zip each text files in it. I was able to zip and compress it in Jupyter notebook by selecting the file from my local. While trying the same code in S3, its throwing error as file is missing. Could someone please help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":56252619,"Users Score":0,"Answer":"Amazon S3 does not have a zip\/compress function.\nYou will need to download the files, zip them on an Amazon EC2 instance or your own computer, then upload the result.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,databricks","A_Id":56254221,"CreationDate":"2019-05-22T08:37:00.000","Title":"Zipping the files in S3","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run python 2.7 code (Queries) on Postgres DB. Regarding the version of pyodbc installed either it crashes python or I got problem relative to UTF8. Si I cannot use my python code.\nI installed python 2.7, pyodbc 3.0.7 on MAC Mojave 10.14 (Then I get UTF8 error). \n\npyodbc.DataError: ('22021', '[22021] ERROR: invalid byte sequence for\n  encoding \"UTF8\": 0xe0 0x81 0xa9;\\nError while executing the query (1)\n  (SQLExecDirectW)')\n\nI installed python 2.7 pyodbc > 3.0.7 on MAC Mojave 10.14 (Then Python is crashing)\nI should be able to connect to my database using ODBC driver.\nAny help?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":56255969,"Users Score":0,"Answer":"Would recommend installing Python 3.X and see if that works. It is more updated and many new libraries are utilizing it more and more - will provide better use in the future.","Q_Score":0,"Tags":"python,postgresql,macos,odbc,macos-mojave","A_Id":56256264,"CreationDate":"2019-05-22T11:35:00.000","Title":"Cannot run postgres request from python 2.7 on MACOS mojave","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When we are writing a pyspark dataframe to s3 from EC2 instance using pyspark code the time taken to complete write operation is longer than usual time. Earlier it used to  take 30 min to complete the write operation for 1000 records, but now it is taking more than an hour. Also after completion of the write operation the context switch to next lines of code is taking longer time(20-30min). We are not sure whether this is AWS-s3 issue or else because of lazy computation of Pyspark. Could anybody throw some light on this quesion.\nThanking in advance","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":75,"Q_Id":56256999,"Users Score":1,"Answer":"It seems an issue with the cloud environment. Four things coming to my mind, which you may check:\n\nSpark version: For some older version of spark, one gets S3 issues.\nData size being written in S3, and also the format of data while storing\nMemory\/Computation issue: The memory or CPU might be getting utilized to maximum levels.\nTemporary memory storage issue- Spark stores some intermediate data in temporary storage, and that might be getting full. \n\nSo, with more details, it may become clear on the solution.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,amazon-ec2,pyspark","A_Id":56291641,"CreationDate":"2019-05-22T12:38:00.000","Title":"writing a pyspark dataframe to AWS - s3 from EC2 instance using pyspark code the time taken to complete write operation is longer than usual time","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm writing a cloud function that basically iterates over all our DataProc clusters and alerts us when they don't have a scheduled deletion policy. As I understand it this can be viewed in the CLI with gcloud beta dataproc clusters list but I am struggling to find a Python equivalent.\nHas anyone done something similar in the past and can point me in the right direction?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":51,"Q_Id":56257513,"Users Score":2,"Answer":"I seem to have found the answer myself, it's in the config if you import dataproc_v1beta2 instead of dataproc_v1","Q_Score":1,"Tags":"python,google-cloud-platform,google-cloud-functions,google-cloud-dataproc","A_Id":56257964,"CreationDate":"2019-05-22T13:05:00.000","Title":"Is there any way to view a DataProc cluster's 'scheduled deletion' property in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to develop Azure Functions in Python on Windows 10 PC. Every time I try to debug it I get this error: \"AttributeError: module 'azure.functions_worker' has no attribute 'start_async' \"\nI am running Python 3.6.8,\nAzure Function Core Tools (2.7.1158)\nAnd Function Run time: 2.0.12438.0\nVSCode latest\nTried to remove and re-install the Azure CLI","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":431,"Q_Id":56260100,"Users Score":0,"Answer":"I had exactly this problem on Win10 when I was using Python 3.6-32bit. Installing Python 3.6-64bit made the error go away, so it is worth giving that a try if you haven't already.","Q_Score":1,"Tags":"python,azure,azure-functions","A_Id":56356557,"CreationDate":"2019-05-22T15:17:00.000","Title":"Running Python Azure Functions on Windows 10 using VSCode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is it possible to train a tensorflow model, then export it as something accessible without tensorflow? I want to apply some machine learning to a school project in which the code is submitted on an online portal - it doesn\u2019t have tensorflow installed though, only standard libraries. I am able to upload additional files, but any tensorflow file would require tensorflow to make sense of... Will I have to write my ML code from scratch?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":735,"Q_Id":56260192,"Users Score":1,"Answer":"Pretty much, unless you brought tensorflow and all of it's files with your application. Other than that, no, you cannot import tensorflow or have any tensorflow dependent modules or code.","Q_Score":2,"Tags":"python,tensorflow","A_Id":56260405,"CreationDate":"2019-05-22T15:23:00.000","Title":"Load tensorflow model without importing tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to be able to run behave from the context menu within the PyDev project explorer (i.e. right click (on a feature file or directory) Run As- Behave and have it run the feature file (or files) once run the any errors in the output would take you to the line in the file it refers to.\nIs this possible?\nI have set behave up as an external tool, which works but it isn't great","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":763,"Q_Id":56260570,"Users Score":0,"Answer":"Eclipse (and PyDev) supports running other \"External Tools\" \/ Commands.\nFor behave, you just need to provide the definition to run a python script.\nIf anything fails, provide your own \"run_behave.py\" scripts that runs behave (much like the \"behave script\"). This also simplifies debugging.","Q_Score":0,"Tags":"python,eclipse,pydev,python-behave","A_Id":58050163,"CreationDate":"2019-05-22T15:44:00.000","Title":"Running behave within Eclipse\/PyDev","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How do I create azure datafactory for incremental load using python?\nWhere should I mention file load option(Incremental Load:LastModifiedOn) while creating activity or pipeline??\nWe can do that using UI by selecting File Load Option. But how to do the same pragmatically using python?\nDoes python api for datafactory support this or not?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":273,"Q_Id":56265151,"Users Score":0,"Answer":"My investigations suggest that the Python SDK has not yet implemented this feature.  I used the SDK to connect to my existing instance and fetched two example datasets.  I did not find anything that looked like the 'last modified date'.  I tried dataset.serialize() , dataset.__dict__ , dataset.properties.__dict__ .  I also tried .__slots__ .\nTrying serialize() is significant because there ought to be parity between the JSON generated in the GUI and the JSON generated by the Python.  The lack of parity suggests the SDK version lags behind the GUI version.\nUPDATE: The SDK's are being updated.","Q_Score":0,"Tags":"python,azure-data-factory,incremental-load","A_Id":56279704,"CreationDate":"2019-05-22T21:18:00.000","Title":"AzureDataFactory Incremental Load using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Watson voice assistant instance connected using SIP trunk to a Twilio API. I want to enable to the IBM Speech-To-Text add-on from the Twilio Marketplace which will allow me to obtain full transcriptions of phone calls made to the Watson Assistant bot. I want to store these transcriptions in a Cloudant Database I have created in IBM Cloud. Can I use the endpoint of my Cloudant Database as the callback URL for my Twilio add-on so that when the add-on is activated, the transcription will be added as a document in my Cloudant Database?\nIt seems that I should be able to somehow call a trancsription service through IBM Cloud's STT service in IBM Cloud, but since my assistant is connected through Twilio, this add-on seems like an easier option. I am new to IBM Cloud and chat-bot development so any information is greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":129,"Q_Id":56265812,"Users Score":0,"Answer":"Twilio developer evangelist here.\nFirst up, I don't believe that you can enable add-ons for voice services that are served through Twilio SIP trunking.\nUnless I am mistaken and you are making a call through a SIP trunk to a Twilio number that is responding with TwiML. In this case, then you can add the STT add-on. I'm not sure it would be the best idea to set the webhook URL to your Cloudant DB URL as the webhook is not going to deliver the data in the format that Cloudant expects.\nInstead I would build out an application that can provide an endpoint to receive the webhook, transform the data into something Cloudant will understand and then send it on to the DB.\nDoes that help at all?","Q_Score":0,"Tags":"twilio,ibm-cloud,cloudant,python-cloudant,ibm-voice-gateway","A_Id":56334855,"CreationDate":"2019-05-22T22:30:00.000","Title":"Can I connect my IBM Cloudant Database as the callback URL for my Twilio IBM STT add-on service?","Data Science and Machine Learning":0,"Database and SQL":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 connecting my slave via TCP\/IP, everything looks fine by using the Wireshark software I can validate that the CRC checksum always valid \u201cgood\u201d, but I am wondering how I can corrupt the CRC checksum so I can see like checksum \u201cInvalid\u201d. Any suggestion how can I get this done maybe python code or any other way if possible.\nThank you all \nTariq","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":406,"Q_Id":56268062,"Users Score":1,"Answer":"I think you use a library that computes CRC. You can form Modbus packet without it, if you want simulate bad CRC condition","Q_Score":1,"Tags":"python,tcp,checksum,crc,modbus-tcp","A_Id":56268121,"CreationDate":"2019-05-23T04:26:00.000","Title":"How corrupt checksum over TCP\/IP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While installing chatterbot in Anaconda using Python 3.7 I am getting the following error:\n\nFound existing installation: PyYAML 3.13 Cannot uninstall 'PyYAML'. It\n  is a distutils installed project and thus we cannot accurately\n  determine which files belong to it which would lead to only a partial\n  uninstall.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":8752,"Q_Id":56268480,"Users Score":1,"Answer":"Update on the solution @arsho shared.\nFor conda versions before 4.6, use:\n\nWindows: activate snakes\nmacOS & Linux: source activate snakes\n\nFor conda versions 4.6 and later, use:\n\nWindows, macOS, Linux: conda activate snakes","Q_Score":1,"Tags":"python,anaconda,python-3.7,chatterbot","A_Id":61774529,"CreationDate":"2019-05-23T05:20:00.000","Title":"Can not install chatterbot in Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"User queries to dialogflow agent through google assistant using voice commands.I want to add some data in that user query. can we change the request parameters sent to agent? If yes, where? The code for google assistant library is in python.\nI am working on python 3.5 on raspberry pi 3. I tried modifying event.py file located at google\/library\/assistant\/ . But before the event for ON_RECOGNISING_SPEECH_FINISHED I got response from google assistant.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":66,"Q_Id":56269802,"Users Score":1,"Answer":"No, if you're using the Google Assistant SDK, you interact with the agent as if it was any other Google Assistant surface. There is no way to add additional context that is exclusive to your device.","Q_Score":0,"Tags":"python-3.x,raspberry-pi3,dialogflow-es,google-assistant-sdk","A_Id":56278248,"CreationDate":"2019-05-23T07:08:00.000","Title":"change request format sent to dialogflow agent","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've implemented a back-end functionality where one can upload a CSV or excel an file and then the server(Django API) will read and save all the data into the database but I feel like it's not the best approach and would like to get advise\nabout this.\nI don't see the reason why the server is required to read and validate the CSV file while it's possible for the client(Angular app) to do that job. The client can read validate the file and the sends the data to the server.\nThen the server will do the rest of the job to save the data into the database. But I've come to think of it, suppose the file contains a million entries this means the server endpoint will be adding a million items. This will cause performance issues. What is the best approach to handle this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":598,"Q_Id":56270927,"Users Score":0,"Answer":"I implemented an Angular\/Python App that processes large Excel files, even with multiple sheets and the best approach is to let the client upload the file to the server and then your server does the rest of the job.\nThe processing can take a lot of time, so you might need to save the file to a temporary location and process it asynchronously as a job. This job will read your file, process each row and save the data to the database. Optionally, it can also save the progress and job status to the database and so, you can even let the client track the processing progress given the job ID.","Q_Score":1,"Tags":"python,django,angular,client,server-side","A_Id":56271114,"CreationDate":"2019-05-23T08:20:00.000","Title":"How to handle reading, extracting & saving extremely large csv or excel data having an Angular client and a Django server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to use BigQueryCreateEmptyTableOperator operator but it gives me an import error.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":528,"Q_Id":56271396,"Users Score":1,"Answer":"from airflow.contrib.operators.bigquery_operator import BigQueryCreateEmptyTableOperator","Q_Score":1,"Tags":"python,airflow,google-cloud-composer","A_Id":57819440,"CreationDate":"2019-05-23T08:48:00.000","Title":"cannot import name BigQueryCreateEmptyTableOperator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Django 1.4 operates by default with the database-level autocommit setting off. I have recently tried turning this setting on and it has slowed down my test suite considerably. \nDATABASES['default']['OPTIONS'].update({'autocommit': True})\nMy understanding is that now every call to create, save etc. by default opens a transaction and issues a commit statement. Would the cost of all these additional transactions be enough to explain the slow-down of the unit tests? How does the django TestCase transaction behaviour come in to play with this (operating each test within a transaction and rolling back once completed)? Should we expect the performance reduction in the unit tests to be reflective of performance of the views in production?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":56274087,"Users Score":0,"Answer":"The slowed down unit tests were due to the additional cost of opening and committing a transaction with every object created as part of setUp, and did not reflect a slow down in performance in a live environment.","Q_Score":0,"Tags":"python,django,database,postgresql,unit-testing","A_Id":56580803,"CreationDate":"2019-05-23T11:19:00.000","Title":"Why would autocommit in django 1.4 slow down unit tests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working in OpenCV (camera calibration and then creating 3d model) and till now I always printed a checkerboard pattern on paper and then took pictures needed for calibration. I tried to find a way to draw the pattern on the full screen with pre-defined square sizes (so I could set that square size in the calibration process), but I only found the Python turtle module which seems to only be for drawing on part of screen, and it always draws an arrow on last square. I need to draw the pattern with some small offset from the screen borders and, inside those offsets, draw a checkerboard with uniform squares. Also, I saw some people are drawing patterns in GIMP, but not on the full screen. \nOpenCV has the function drawChessboardCorners but it requires founded corners from previous imported images, which need to be calibrated, so I think it doesn't make sense. \nIf anybody has an idea how to solve this problem, either with some program or module in some programming language (Python if possible), I would be grateful.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1120,"Q_Id":56275319,"Users Score":0,"Answer":"Prepare your chessboard pattern in your favourite graphics editor, save the file onto the computer you want to use to display it for your calibration, then just display it when needed. I think you might be over-thinking the problem...","Q_Score":0,"Tags":"python,python-3.x,opencv,camera-calibration","A_Id":56275671,"CreationDate":"2019-05-23T12:32:00.000","Title":"Drawing full screen chessboard pattern?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I Have Serious Doubt Between Them. Can Anyone Please Elaborate With Examples and Some Ideas.","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":2581,"Q_Id":56278769,"Users Score":5,"Answer":"Flatten as the name implies, converts your multidimensional matrices (Batch.Size x Img.W x Img.H x Kernel.Size) to a nice single 2-dimensional matrix: (Batch.Size x (Img.W x Img.H x Kernel.Size)). During backpropagation it also converts back your delta of size (Batch.Size x (Img.W x Img.H x Kernel.Size)) to the original (Batch.Size x Img.W x Img.H x Kernel.Size).\nDense layer is of course the standard fully connected layer.","Q_Score":1,"Tags":"python,machine-learning,neural-network,deep-learning,conv-neural-network","A_Id":56278851,"CreationDate":"2019-05-23T15:41:00.000","Title":"What is Difference Between Flatten() and Dense() Layers in Convolutional Neural Network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I noticed that the same transaction had a different transaction ID the second time I pulled it. Why is this the case? Is it because pending transactions have different transaction IDs than those same transactions once posted? Does anyone have recommendations for how I can identify unique transactions if the trx IDs are in fact changing?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":415,"Q_Id":56282490,"Users Score":0,"Answer":"Turns out that the transaction ID often does change. When a transaction is posted (stops pending), the original transaction ID becomes the pending transaction ID, and a new transaction ID is assigned.","Q_Score":4,"Tags":"javascript,python,api,banking,plaid","A_Id":57262467,"CreationDate":"2019-05-23T20:27:00.000","Title":"How to identify Plaid transactions if transaction ID's change","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I use pysnopper to debug subclass running? I have import a class through pip install. Pysnopper only shows me  which is not quite helpful since I should see what is going on there too. Can someone show me how ?\nUsing this not quite help.\n@pysnooper.snoop(depth=5)\n@pysnooper.snoop(watch_explode=('function1','self'))\nAlso, If any new debugger you think can do, please share.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":56282627,"Users Score":0,"Answer":"using watch_explode with the main function works since everything go through main","Q_Score":0,"Tags":"python,debugging","A_Id":59869989,"CreationDate":"2019-05-23T20:33:00.000","Title":"best way to debug python in pysnopper","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a GUI in python, and using tkinter. I'm having trouble settling on an approach and need guidance.\nBackground: there's a server (not a webserver) that wants to present a lot of information to users, and let them edit some of it. It needs to send down information that a (relatvely) dumb python client uses to fill the window. Read only fields are Labels. The fields are generally single line Entry widgets, but some are multiline Text. There are some buttons, checkboxes and dropdowns. Asynchronously, the server can also update widgets, add them and remove them. In some cases, there are tables presented, to which the user needs to be able to add and remove rows.\nThe real problem is, the layout is dense and chaotic. The first row might contain 3 dropdown fields. The next might be 20 short Labels. The next might be a single long Entry field, and then I might want two tables (of different lengths) side by side,and then etc.. Based on user input of external factors, widgets, rows or entire tables might have to be dyamically added, or vanish.\nI considered Grid, but it's unusable. A row with a single, long entry widgit in it, makes the first column wide and thereby pushes 12 of the 13 columns in the next row right off the window. \nI considered Place, but this app will run on 3 different operating systems and users will be able to select their own fonts, so I'll never get the positions right. If there was some way to ask a widget how big it was, I'd happily use that to compute my own layouts in pixels, but it's apparently impossible to ask the size of a widget until AFTER it's been laid out by a geometry manager, which of course is too late. \nSo what I think I'm left with is Pack, where each row is its own frame, and some of those rows have tables (grids) in them. But I'm concerned that that means lots and lots of frames to render, and some of the users are on old, slow hardware. Plus...  it looks just plain complex.\nAm I missing a better way? Grid would be fine if I could convince it to stop trying to make columns line up. Place would be crunchy, but ok, if I could get the size of each widget in advance. Is placing within a lot of frames really the best I have?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":182,"Q_Id":56284263,"Users Score":0,"Answer":"Short answer, there's no better way; and the frame count isn't high enough to cause performance problems; so generating a frame per row is what works.","Q_Score":0,"Tags":"python-3.x,tkinter,geometry","A_Id":56409926,"CreationDate":"2019-05-23T23:58:00.000","Title":"python3 tkinter: can I get ragged grids without aligned columns?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Somehow supervisord hangs\/hungs 10 minutes after we do service supervisor start. Scripts initiated by supervisod still appears on the background as running but not functioning anymore. Any idea what could be the issue? Our current workaround was to install a cron job to restart supervisord every 10 minutes. supervisord version is 3.1.4 and python is 2.7.5","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":56287294,"Users Score":0,"Answer":"you can run your scripts command in the shell, don't start it in supervisord . and wait 10 minutes to see if it work well. you can also write some log in your script.I use supervisord in many projects and almost problem is command error or code error.","Q_Score":0,"Tags":"python,supervisord","A_Id":56288939,"CreationDate":"2019-05-24T06:54:00.000","Title":"Supervisord Hangs\/Hungs on the Background after 10 minutes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a large table, and I wish to update only a single column. The values for that column is present in a CSV file. I want to avoid a single insert to event column because it would take a long time. I would prefer something like a COPY so that I can directly dump the new values over the older values. But dumping a specific using copy appends it to the end of the table rather than overwriting it. \nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":142,"Q_Id":56290182,"Users Score":0,"Answer":"Suggestion: Insertion is faster than update in DB so can follow below steps:\n\nLoad CSV to a temp table.Not all columns are required just primary\nkey and the column which need to be updated in main table.\nRename main table to main_temp\nrecreate main table (no records now)\nJoin main_temp and temp table based on primary key and insert into\nmain(select particular column from temp table instead from main table)\ndrop main_temp","Q_Score":0,"Tags":"python,python-3.x,database,postgresql,postgresql-9.3","A_Id":56292646,"CreationDate":"2019-05-24T09:54:00.000","Title":"Overwrite a column in Postgres from a column in a csv file","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As title. \nI noticed that calling p4 from the subprocess module is not very fast. But I hesitate learning the Perforce Python binding without knowing whether or not it performs better.\nI'd appreciate it if anyone could share the experience of trying both.\nEDIT\nI observed this on Win10\/desktop PC where my working copy is on an SSD drive. The commands I observed include add, edit, and reconcile over a large number of files and folders. I didn't do rigorous profiling but the perceived response from subprocess seems slower than the same operation in P4V.\nSam Stafford's answer makes sense if the p4 calls induce multi-connection overhead.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":255,"Q_Id":56292717,"Users Score":1,"Answer":"In general, using a p4 API is going to be faster than using the CLI, with the most dramatic gains apparent if you're running multiple commands, since the API lets you easily run multiple commands on a single server connection whereas the CLI binary establishes a connection for each invocation.","Q_Score":0,"Tags":"python,performance,perforce","A_Id":56295249,"CreationDate":"2019-05-24T12:29:00.000","Title":"p4python vs. calling p4 using subprocess, which way performs better?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a form where you can input some data, but i want to return the view with a suc6 message and process that data and finally add it to the database.\nI have everything working but if I process the data it doesn't return the view right away and I don't know if its good practice to use a Thread instead of Processing the data in the view.py","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":56293201,"Users Score":0,"Answer":"Depending on your use case. But I would suggest processing the data in view.py because you want to respond with a success message after the processed data is safely stored in database. With thread you might have a problem if your thread breaks after you responded with a success message.","Q_Score":0,"Tags":"python,django","A_Id":56293299,"CreationDate":"2019-05-24T12:59:00.000","Title":"How to process data after a request","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"With graph = nx.node_link_graph(json.loads(\"json_string\")) it is possible to load a graph that is represented in JSON format.\nNow my problem is that I already have a networkx graph in my program and only want to add JSON formated components dynamically during runtime.\nFor example somewhere the string ' {\"source\": 1, \"target\": 2, \"weight\": 5.5} ' is created and should then result in a new edge between node 1 and 2.\nWhat is the best way to realise this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":284,"Q_Id":56294819,"Users Score":0,"Answer":"The simpliest way you can add the new edge to the graph G if you have a dict like this:\nd = {\"source\": 1, \"target\": 2, \"weight\": 5.5} (you can convert it from string to dict with dict(s) or json.loads(s)) is:\nG.add_weighted_edges_from([(d['source'], d['target'], d['weight'])])","Q_Score":0,"Tags":"python,json,networkx","A_Id":56295146,"CreationDate":"2019-05-24T14:37:00.000","Title":"Is there a way to add single nodes\/edges in JSON format to networkx graph?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I trained a model in keras and I'm thinking of pruning my fully connected network. I'm little bit lost on how to prune the layers. \nAuthor of 'Learning both Weights and Connections for Efficient\nNeural Networks', say that they add a mask to threshold weights of a layer. I can try to do the same and fine tune the trained model. But, how does it reduce model size and # of computations?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2526,"Q_Id":56299034,"Users Score":4,"Answer":"If you add a mask, then only a subset of your weights will contribute to the computation, hence your model will be pruned. For instance, autoregressive models use a mask to mask out the weights that refer to future data so that the output at time step t only depends on time steps 0, 1, ..., t-1.\nIn your case, since you have a simple fully connected layer, it is better to use dropout. It randomly turns off some neurons at each iteration step so it reduces the computation complexity. However, the main reason dropout was invented is to tackle overfitting: by having some neurons turned off randomly, you reduce neurons' co-dependencies, i.e. you avoid that some neurons rely on others. Moreover, at each iteration, your model will be different (different number of active neurons and different connections between them), hence your final model can be interpreted as an ensamble (collection) of several diifferent models, each specialized (we hope) in the understanding of a specific subset of the input space.","Q_Score":11,"Tags":"python,tensorflow,optimization,deep-learning,inference","A_Id":56299140,"CreationDate":"2019-05-24T20:15:00.000","Title":"How to implement neural network pruning?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"why do i need a web API to link between django and other JS frameworks for example django with angular?\nAnd is it necessary to build a web API like (REST API) to link between back end and front end?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":56302148,"Users Score":0,"Answer":"Django is not JS library. It's a Python-based server framework. But your JS library communicates with a server via REST Api. So you need a web API to link between django and other JS frameworks.","Q_Score":0,"Tags":"python,django","A_Id":56302620,"CreationDate":"2019-05-25T05:53:00.000","Title":"Why do I need web api to link between django and other js framworks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"why do i need a web API to link between django and other JS frameworks for example django with angular?\nAnd is it necessary to build a web API like (REST API) to link between back end and front end?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":56302148,"Users Score":0,"Answer":"Without more work than it is worth, the DJango and Angular frameworks probably cannot pass data between one and the other, since both run at the same logical level in the stack.\nREST APIs are the generally accepted mechanism for communicating between SPAs implemented in different frameworks.","Q_Score":0,"Tags":"python,django","A_Id":56302440,"CreationDate":"2019-05-25T05:53:00.000","Title":"Why do I need web api to link between django and other js framworks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If +python3 is shown in the output of :vesion which means that Python3 is statically linked with vim, does Python3 need to exist to use py3 inside vim?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":36,"Q_Id":56302398,"Users Score":2,"Answer":"If +python3 is shown in the output of :vesion which means that Python3 is statically linked with vim,\n\nIt doesn't. It means vim was compiled with Python3 support but the interpreter library (libpython.so) is linked dynamically.\n\ndoes Python3 need to exist to use py3 inside vim?\n\nYes, and vim must know the path to Python as vim needs to find  the interpreter library libpython.so. Also vim (well, Python) needs some parts of the standard Python library.","Q_Score":0,"Tags":"python,vim","A_Id":56304732,"CreationDate":"2019-05-25T06:38:00.000","Title":"Does Python3 need to exist for the use of \"py3\" inside vim if Python3 is statically with vim?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"read the csv file flle using pd.read_csv() method. on displaying , it still in semicolon separated data. I expected table structure    \nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n%matplotlib inline\nimport random\nimport os\ndf=pd.read_csv(\"E:\\Python\\data_full.csv\")\ndf.head()\nActual result :\n56;\"housemaid\";\"married\";\"basic.4y\";\"no\";\"no\";...\n1\n57;\"services\";\"married\";\"high.school\";\"unknown...\n2\n37;\"services\";\"married\";\"high.school\";\"no\";\"ye...\n3\n40;\"admin.\";\"married\";\"basic.6y\";\"no\";\"no\";\"no...\n4\n56;\"services\";\"married\";\"high.school\";\"no\";\"no...\nIn [ ]:\n\u200b","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":56302744,"Users Score":0,"Answer":"When I opened the csv file, each row was shown as single cell. Noticed that the delimiter was ;(semicolon ). I have changed the delimiter to ,(comma) and then the each value in the csv file was displayed in each cell.\nNow, the head() method is displaying the results in table structure as expected :)\nIs there any limitation to use semicolon as a delimiter in csv file?","Q_Score":0,"Tags":"python-2.x","A_Id":56303121,"CreationDate":"2019-05-25T07:28:00.000","Title":"Why Head() function showing semicolon separated data in my jupyter note book?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I run CNN code on Colab notebook, and it takes long time. However, the connection always breaks after I ran 2 or 3 hours and cannot be reconnect back. I was told Colab virture machine would break connection after 12 hours without any operates, so how can I avoid restart my code after connection broken, or any easier way to controll Colab?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":56302763,"Users Score":0,"Answer":"Colab restarts on inactivity in 2-3 hours, you need to reconnect it. To simply avoid this show some activity on runtime.","Q_Score":0,"Tags":"python","A_Id":57820210,"CreationDate":"2019-05-25T07:31:00.000","Title":"Colab connection always broken","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently doing research at a university and wanted to create custom code that would be able to analyze hours worth of images of neurons and determine if the neurons are on or off. I want to write the code myself and was just wondering where I can get started. For example, what kinds of things can I import into python to read light in tiff files and what kind of things do I need to import to extract that data into a table or graph?\nSome clarification:\nThe neurons are always in the same place in all the images.\nIt is a black and white image. \nThe images are hours worth of neuron activity, where an image is taken every second or so. \nI do not want someone to write the whole code for me, but for people to please tell me what kind of things are necessary to read light in tiff files and export that data into some sort of table or graph.\nThank you!\nI am not allowed to show a photo as an example, but I am allowed to describe what it looks like. The background is all black. There are white dots on the images scattered all around. Some are neurons and I am able to locate where they are. In all of the photos, the location of the neurons are the same and some of the neurons are lit up and others are dark. Which neurons are lit and which are dark change from photo to photo. \nI do not have any code done yet, as I am here seeking for a place to start in this project.\nThe expected output of the code looking at the neurons and seeing which ones are lit up is data in the form of a table, graph, or even a text file if a table or graph is impossible. The table would include either a 1 or 0, 1 indicating that the neuron is lit up, and 0, indicating the neuron is dark. For the graph, it would have a number representing a neuron (1, 2, 3 4, ...) on the y-axis and on the x-axis would be a 1 or 0. Each column would be one image and you would see how the activity of each neuron would change over time. I am open to any other form of data.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":56304143,"Users Score":0,"Answer":"You can read your file as an image and convert it to a black and white image. then if you can specify which pixels are located at each neurons in image you can check pixel's values to check if the neuron is on or off.\nany way I suggest to search in image processing packages of python the solution for your problem is easy to find.\nand in the case you can not specify which pixels are located at each neurons in image maybe search in \"image processing dilation and erosion\" would help.\nGood luck!","Q_Score":0,"Tags":"python-3.x,image,graph,tiff","A_Id":56305461,"CreationDate":"2019-05-25T10:52:00.000","Title":"I have many tiff files of neurons. I was wondering if there is a way to read the strength of light where neurons are and import that data into a file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently building a media website using node js. I would like to be able to control Kodi, which is installed of the server computer, remotely from the website browser.How would I go about doing this? My first idea was \n\nto simply see if I could somehow pipe the entire Kodi GUI into the\nbrowser such that the full program stays on the server\nand just the GUI is piped to the browser, sending commands back to\nthe server;\n\nhowever, I could find little documentation on how to do that.\nSecond, I thought of making a script (eg Python) that would be able to control Kodi and just interface node js with the Python script, but again, \nI could find little documentation on that.\n Any help would be much appreciated. \nThank You!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":56306073,"Users Score":0,"Answer":"Can't you just go to settings -> services -> control and then the 'remote control via http' settings? I use this to login to my local ip e.g. 192.168.1.150:8080 (you can set the port on this page) from my browser and I can do anything from there","Q_Score":0,"Tags":"python,node.js,kodi","A_Id":57015259,"CreationDate":"2019-05-25T15:12:00.000","Title":"Controlling Kodi from Browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use os.system('cls') in Pycharm to clear the screen from what has been printed before. However, when running the code, it does not clear the formerly printed stuff, and instead prints an upward arrow at the end. What can the problem be?","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":5064,"Q_Id":56306486,"Users Score":5,"Answer":"If you want the terminal to emulate your OSs terminal, you have to edit the 'Run\/Debug Configuration' and tick the box 'Emulate terminal in output console'.\nThen os.system(\"cls\") will clear the screen on Windows and os.system(\"clear\") on unix","Q_Score":3,"Tags":"python,python-3.x,pycharm,cls","A_Id":60952869,"CreationDate":"2019-05-25T16:00:00.000","Title":"os.system('cls') doesn't clear the screen in Pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use os.system('cls') in Pycharm to clear the screen from what has been printed before. However, when running the code, it does not clear the formerly printed stuff, and instead prints an upward arrow at the end. What can the problem be?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":5064,"Q_Id":56306486,"Users Score":6,"Answer":"PyCharm's emulation of the Windows system console isn't 100%. Neither is any IDE's. Try that in IDLE or PythonWin, and you will see that it also does something other than you might expect from the Windows console.\nThis behaviour is by design. Bear in mind that most real-world Python interactive applications do not interact with their users via input() and print() calls.\nIf you want your output to behave exactly like the Windows console then send your output to the Windows console.","Q_Score":3,"Tags":"python,python-3.x,pycharm,cls","A_Id":56306881,"CreationDate":"2019-05-25T16:00:00.000","Title":"os.system('cls') doesn't clear the screen in Pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Some people refer to objects as \"Every python object is a value having a certain type stored at a particular memory location\".Some authors define the object as a thing that has a type, value, and identity. I was going through a source and found out a new definition. An object is a named collection of attributes- What does this mean?. If we go through the definitions all of them differ. Are these definitions context specific wherein different definitions are used in different contexts?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":96,"Q_Id":56307980,"Users Score":1,"Answer":"It seems your question is what an object is and because of all the different explanations online it confuses you. \nWell, to put is simply. An object is like a blue print. Say you want to write a program that randomly picks a dog and shows the name of the dog. Well the easiest way to solve this, is by creating a dog object. \nEvery dog should have a name, an owner and perhaps a color. These things would be your attributes. They tell something about the dog. So when you create an instance of a dog, you give it a name, owner name and color. Also when you create an instance you allocate place in memory for that dog object, so you can use it later in your code. \nHope that makes sense. (y)","Q_Score":0,"Tags":"python","A_Id":56308132,"CreationDate":"2019-05-25T19:20:00.000","Title":"An object is a named collection of attributes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an input string which somehow remind the html code, but tags using the square brackets instead of angular. \nThe input string is:\nstr = r'Lorem ipsum [dolor] sit amet'\nI process it with re.split using pattern\nptr = r'\\[.*?\\]'\nto detect the tags. The result is a list\nlist = [r'Lorem ipsum ', r'[dolor]', r' sit amet']\nThe problem is that the two-symbol sequence \\[ should mean [ symbol, not starting a tag.\nre.split(r'\\[.*?\\]', r'Lorem \\[ipsum\\] \\\\[dolor] sit amet')\ngives\n[r'Lorem \\', r'[ipsum\\]', r' \\\\', r'[dolor]', r' sit amet']\nwhile I want to get\n[r'Lorem ipsum \\[dolor\\] \\\\', r'[dolor]', r' sit amet']\nSo what I want is to understand is how to say to re.split that two-symbol sequence \\x is and escape sequence and should be treated asa single symbol?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":56308165,"Users Score":0,"Answer":"The purpose of putting r in front of a string is to treat it as a raw string -> Python will treat backslashes as literal characters. You should just use normal strings.","Q_Score":1,"Tags":"python,regex,escaping","A_Id":56308210,"CreationDate":"2019-05-25T19:43:00.000","Title":"Python escaping re.split treat backslash+symbol as another symbol","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list of strings \nmy_list = ['1Jordan1', '2Michael2', '3Jesse3'].\nIf I should delete the first and last character, how would I do it in python??","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1843,"Q_Id":56308585,"Users Score":0,"Answer":"You would use slicing. I would use [1:-1].","Q_Score":1,"Tags":"python,python-3.x","A_Id":56308611,"CreationDate":"2019-05-25T20:48:00.000","Title":"How to i split a String by first and last character in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a python library \/ app that uses Gtk.\nPart of my build process uses glib-compile-schemas to create gschemas.compiled.\nIf I include gschemas.compiled in my library, will this break things, if somebody tries to use my library on something like ARM or 32 bit intel ?\n(I would compile this as a post-install thing, but that seems to unsupported in setuptools which I am using).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":560,"Q_Id":56309056,"Users Score":0,"Answer":"This isn't a definitive answer, but I verified the file is the same for two different architectures build for a package and they are the same.\n(The debian i386 and arm64 packages for enchant).\nThese were chosen because of the different bit width (32 vs 64), and differing architectures.\nIf somebody writes a more definitive answer, I'll still accept that.","Q_Score":2,"Tags":"python,gtk,pygobject,gobject-introspection","A_Id":56313102,"CreationDate":"2019-05-25T21:58:00.000","Title":"Is gschemas.compiled architecture specific (can I ship it with my python library)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Hello i am using Jupyterlab and Jupyter Notebook on Anaconda to program via Python 3. When getting an error message it tells me the location where the error occurred and what kind of error, so far so good. Is there a way i can click the message or something like that so it forwards me to the error line instead of having to scroll myself? With small code this is no problem but when the code is getting much it\u00b4s rather inconvenient. Am i missing something obvious?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":56309724,"Users Score":1,"Answer":"Jupyter is not an actual IDE, even though it has a lot of functionality and extensions. You will need to use an actual IDE like Pycharm or Spyder.","Q_Score":0,"Tags":"python-3.x,jupyter-notebook,anaconda,jupyter-lab","A_Id":56314842,"CreationDate":"2019-05-26T00:20:00.000","Title":"Forwarding to error line in Jupyter on Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a LSTM model on a multivariate time series data set with 24 features. I have ran feature extraction using a few different methods (variance testing, random forest extraction, and Extra Tree Classifier). Different methods have resulted in a slightly different subset of features. I now want to test my LSTM model on all subsets to see which gives the best results.\nMy problem is that the test\/train RMSE scores for my 3 models are all very similar, and every time I run my model I get slightly different answers. This question is coming from a person who is naive and still learning the intricacies of neural nets, so please help me understand: in a case like this, how do you go about determining which model is best? Can you do seeding for neural nets? Or some type of averaging over a certain amount of trials?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":20,"Q_Id":56310122,"Users Score":2,"Answer":"Since you have mentioned that using the different feature extraction methods, you are only getting slightly different feature sets, so the results are also similar. Also since your LSTM model is then also getting almost similar RMSE values, the models are able to generalize well and learn similarly and extract important information from all the datasets.\nThe best model depends on your future data, the computation time and load of different methods and how well they will last in production. Setting a seed is not really a good idea in neural nets. The basic idea is that your model should be able to reach the optimal weights no matter how they start. If your models are always getting similar results, in most cases, it is a good thing.","Q_Score":1,"Tags":"python,neural-network,lstm,data-science,feature-extraction","A_Id":56315167,"CreationDate":"2019-05-26T02:09:00.000","Title":"Comparing results of neural net on two subsets of features","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to run two different python programs in two different places (two droplets in Digital Ocean for example), I need to share some variables between them, and I don't really know the best way to accomplish that. \nAny idea or advice will be appreciated. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":56310608,"Users Score":0,"Answer":"If the rate at which you update and use them permits and if there's no overlap, I'd store each variable in an high availability database and read them from there.","Q_Score":0,"Tags":"python,server","A_Id":56310692,"CreationDate":"2019-05-26T04:19:00.000","Title":"run two different python programs and sync they variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a ridiculously simple question, but bear with me, because i didn't see anyone ask it.\nI have Anaconda installed on my Mac. It's taking all sorts of forever to solve the environment on a package install, and I don't have time to troubleshoot now, so I decided to install via pip. Works great, only now I don't know where the package is installed.\nHow can I check my pip PYTHONPATH location so that I can add that location to my other paths?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":56310752,"Users Score":0,"Answer":"pip show <package name>\nI am not really experienced with python but once similar thing happend with me and i used this.","Q_Score":0,"Tags":"shell,pip,pythonpath","A_Id":56310891,"CreationDate":"2019-05-26T04:55:00.000","Title":"Python pip path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python and I am trying to scan multiple IPs with fping. I have large number of server to monitor for statistics and I could write the following code that works for 2 hosts:\n \n    import subprocess\n    import binascii\n\n    out = ''\n    err = ''\n\n    host1 = '172.2.2.5'\n    host2 = '172.1.5.8'\n    hosts = '\/tmp\/ip.list'\n\n    ping = subprocess.Popen(['fping', '-C', '10', '-b', '50', '-p', '25', host1, host2], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n    try:             \n        [out, err] = ping.communicate(timeout=15)\n\n        print('STDOUT')\n        print(out.decode('utf-8').strip())\n\n        print('STDERR (Statistics)')\n        print(err.decode('utf-8').strip())\n\n    except subprocess.TimeoutExpired:\n        print('STDERR (expired timeout)')\n\nHowever, I am unable to replace the two hosts with list of host files, though I tried in multiple ways.\nI would very much appreciate any help this regard or any improvements in the program itself.\nTIA.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1342,"Q_Id":56312105,"Users Score":0,"Answer":"I found a simple fix:\n\n\nwith open('ip_list.csv', 'r') as fh:\n    all_ips = fh.read().splitlines()\n\ncmd = ['fping', '-C', '10', '-b', '50', '-p', '25']\ncmd.extend(all_ips)\n\nping = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)","Q_Score":0,"Tags":"python,linux,python-3.x,centos7,ping","A_Id":56313367,"CreationDate":"2019-05-26T09:00:00.000","Title":"fping using IP list in python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"As you may know, from August 1, 2019 all Android-releases must be compliant with the Google Play 64-bit requirement.\nWill Kivy + Buildozer allow us to create such apps?\nThank you in advance!","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":879,"Q_Id":56312843,"Users Score":4,"Answer":"Buildozer already allows you to create such apps, just change the android.arch configuration token in buildozer.spec to arm64-v8a instead of the default armeabi-v7a.\nWe don't support APKs with multiple architectures bundled together, mostly because this would significantly increase their size due to all the compiled components, but you can upload one APK of each type to Google Play.\nWe'll probably update the defaults and provide more documentation about it within the next few months.","Q_Score":2,"Tags":"android,python,google-play,kivy","A_Id":56313205,"CreationDate":"2019-05-26T10:51:00.000","Title":"Kivy and Google Play 64-bit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As you may know, from August 1, 2019 all Android-releases must be compliant with the Google Play 64-bit requirement.\nWill Kivy + Buildozer allow us to create such apps?\nThank you in advance!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":879,"Q_Id":56312843,"Users Score":0,"Answer":"It's simple, Just go to line 232 in the buildozer.spec file and change the arch to  arm64-v8a and then build the app and then again build the app by changing the arch of buildozer.spec file to armeabi-v7a. On Google Play console, upload both the files.","Q_Score":2,"Tags":"android,python,google-play,kivy","A_Id":67867070,"CreationDate":"2019-05-26T10:51:00.000","Title":"Kivy and Google Play 64-bit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying google cloud's dataflow service which is useful for efficient computation time. My code has the following programming model for the dataflow pipeline:\n\nstart=(p | \"read\" >> beam.io.ReadFromText(\"gcs path\")) \n  end= start | \"data_generation\" >> beam.Pardo(PerfromFunction)\n\nWhat I am doing:\nPerformFunction is a regular Python function which contains a few series of functions for data-generation purpose. My problem is that when I run this function on a regular VM of n1-standard-16 on a single processor, it takes around 1 hour to complete the whole process.\nWhy I opted Dataflow:\nI then decided to go for Dataflow where a ParDo function performs Multi-Threading of the given function and obviously to reduce the computational time from 1 hour to less than 1 hour.\nThe Problem:\nAfter running a Dataflow job with the above-mentioned programming model, I came to realize that Dataflow is still taking around 1 hour to complete the entire process which is mentioned as wall-time on the GCP Dataflow UI. I then logged in to the worker machine and saw the resource utilization using the command htop and found that the machine was only utilizing one processor with 60% average usage.\nExpected Results or Suggestions:\n1. Can multiprocessing be done in the Dataflow worker Cluster?\n2. Is my programming model very limited and wrong?\n3. ParDo function does not seem to reduce the computational time as expected, What do you think I am doing wrong here?\nPS- Owing to some protocols, I can not share the code. Thank you for understanding. Also please correct me if I wrongly understand dataflow at some point.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":249,"Q_Id":56313281,"Users Score":0,"Answer":"Apache Beam, and Dataflow are able to parallelize your computation based on the input that comes into it.\nIf you have a single computation to apply, and this computation takes one hour, then Beam will not be able to speed up your computation. Beam can help you if you need to apply the same computation multiple times to different elements (or data points).\nYou should also consider things such as overhead of running the computation in a distributed fashion (data copying, network calls, etc).\nSo, to be able to answer your question: How may individual \"data points\" (how many lines) are there in your GCS file? Is it possible to parallelize the computation over each one? How long does it take to process each one?","Q_Score":0,"Tags":"python-2.7,google-cloud-platform,google-cloud-dataflow,dataflow","A_Id":56369003,"CreationDate":"2019-05-26T11:58:00.000","Title":"Google Cloud Dataflow: Dataflow programming model taking same computational time as it would take on a regular VM machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I need to return some items from inside a spider before starting to parse requests. Because I need to make sure some parent items exist in database before parsing child items.\nI now yield them from the parse method first thing, and this seem to work fine. But I was wondering if there is a better way to do this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":67,"Q_Id":56315488,"Users Score":1,"Answer":"Instead of yielding the items, write them into the database directly on the constructor of the pipeline where you add regular items to the database.","Q_Score":0,"Tags":"python,scrapy","A_Id":56322104,"CreationDate":"2019-05-26T16:42:00.000","Title":"Scrapy returning items within spider before first request\/parse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have multiple instances of python in my computer namely python27, python3.6 and python 3.7. \nThe import module for docx worked daily on python27 until suddenly it stopped working today. I tried installing the module again using pip in windows command line. \n\nIt says only installed in python27 directory. But there's an\n  importError on my script.\n\nI guess I should be high time i transferred into python37 but I can't seem to make pip install into python 3.7 \nCan someone offer some advice as to the messy situation I'm in?I want to transfer to python3 and install docx in python3 \nAlready checked modules using pip and docx is not there.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":56319093,"Users Score":0,"Answer":"You should try setting your command prompt on the version of Python you want the module to install. Then, just use \"pip\", to install. \nThis is how you can do this:\nGo into File Explorer (hopefully you have windows) and press and hold the shift key, then right click the folder that you want command prompt to look at. In this case, the folder with the version of Python. Then you click on the command prompt selection, and you're golden. Just use \"pip install xyz\" from there on. Glad to help\n- BURAK ILOGLU","Q_Score":0,"Tags":"python-3.x,python-2.7,pip,docx","A_Id":56319319,"CreationDate":"2019-05-27T02:47:00.000","Title":"Pip on only installs to python27 while i need it to install on python37","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a raw html which i get the room details in which i need to add in a button pop up for a raw html form that can show up \n\u25cb You should be able to add multiple beds for a Room\n           \u00a7 Each Bed entity will have following fields:\n               \u25a1 Width\n               \u25a1 Length\n               \u25a1 Quantity\n               \u25a1 Mattress Type\n                   \u00ae None\n                   \u00ae Innerspring\n                   \u00ae Pillow top\n                   \u00ae Hybrid\n                   \u00ae Specialty foam\n                   \u00ae Gel\n                   \u00ae Memory foam\n                   \u00ae Latex\n                   \u00ae Matress airbed\nMatress waterbed\nwith each click on the +add beds it should show up the html form to add in details and then save all this while saving the Room form.\ndidnt find a better way to approach\nNA\nit must be a raw html with some js or jquery to pop up a html form on click fill in the details and when clicked on add bed it should open another html form and need to add in details and same must show in edit view too.must be able to remove the beds html form if not needed and in the end must save with the room html form.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":56319989,"Users Score":0,"Answer":"Okay, so for that you definatelly need Javascript, or jQuery. On your button add event listener on click. In your html prepare form witch display attribute is set to None. If user clicks to button, this attribute is set to Block. If you want to do things asynchronously think about AJAX calls using jQuery. Let me know if that helped a bit ;)","Q_Score":0,"Tags":"html,django,python-3.x,django-models","A_Id":56320030,"CreationDate":"2019-05-27T05:11:00.000","Title":"adding bed raw html form to room raw html as a pop up to add a lot of beds","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to connect to a customer's DB via ODBC. The ODBC DSN was setup on the the Windows machine. I don't know the path to the DB or the DB name so I have to rely on the DSN.\nFrom what I've seen in general this does not seem to be possible, but I know Pervasive ODBC allows it and seems like MSSQL also allows it.\nQuestion is, does Firebird 2.5 allow this? If it does could you please help me with the connection string\nI've set up a Firebird DB on a local windows machine, created an ODBC DSN (and tested the connection locally).\nI then tested connections from unixODBC (isql) and python pyodbc and they all connect fine, but I have to specify DB location and name and credentials.\nI need to connect to the remote (windows) Firebird ODBC DSN from python 3.6 pyodbc (linux)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":307,"Q_Id":56323397,"Users Score":2,"Answer":"What you want isn't possible*. An ODBC DSN exists only on the machine where it is defined. It is basically a connection configuration that is decoupled from your application, and your application references the configuration by a name.\nYou can't use a DSN remotely (if that were possible, that would be a pretty big security leak). You will need to define a DSN (or use a DSN-less connection string), on your specific machine to be able to use it from that machine.\nGiven you're using Python, consider using FDB or pyfirebirdsql instead of using pyODBC.\n\n* Or at least, not possible without some middleware service on the remote machine that mediates between your application and the ODBC DSN on the remote machine.","Q_Score":0,"Tags":"python-3.x,odbc,firebird,pyodbc","A_Id":56325957,"CreationDate":"2019-05-27T09:36:00.000","Title":"Connect from python3 - pyodbc (linux) to a firebird 2.5 (windows) ODBC DSN on remote machine","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been working with a dataset which contains information about houses that have been sold on a particular market. There are two columns, 'price', and 'date'. \nI would like to make a line plot to show how the prices of this market have chaged over time.\nThe problem is, I see that some houses have been sold at the same date but with a diferent price.\nSo ideally i would need to get the mean\/average price of the house sold on each date before plotting.\nSo for example, if I had something like this:\nDATE  \/                PRICE\n02\/05\/2015      \/     $100\n02\/05\/2015      \/     $200\nI would need to get a new row with the following average:\nDATE          \/      PRICE\n02\/05\/2015      \/      $150\nI just havent been able to figure it out yet. I would appreciate anyone who could guide me in this matter. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14,"Q_Id":56332208,"Users Score":0,"Answer":"Assuming you're using pandas:\npd.groupby('DATE')['PRICE'].mean()","Q_Score":0,"Tags":"python,datetime,plot","A_Id":56332236,"CreationDate":"2019-05-27T20:37:00.000","Title":"I have repeated date values in my x axis. How do i create a different row with a single average of those values?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using openpyxl to create charts. For some reason, I do not want to insert row names when adding data. So, I want to edit the legend entries manually. I am wondering if anyone know how to do this.\nMore specifically \nclass openpyxl.chart.legend.Legend(legendPos='r', legendEntry=(), \n     layout=None, overlay=None, spPr=None, txPr=None, extLst=None). I want to edit the legendEntry field","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":621,"Q_Id":56333244,"Users Score":0,"Answer":"You cannot do that. You need to set the rows when creating the plots. That will create the titles for your charts","Q_Score":0,"Tags":"python,excel,openpyxl","A_Id":56371107,"CreationDate":"2019-05-27T23:00:00.000","Title":"Setting legend entries manually","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"There's this event that my organization runs, and we have the ticket sales historic data from 2016, 2017, 2018. This data contains the quantity of tickets selled by day, considering all the sales period.\nTo the 2019 edition of this event, I was asked to make a prediction of the quantity of tickets selled by day, considering all the sales period, sort of to guide us through this period, meaning we would have the information if we are above or below the expected sales average.  \nThe problem is that the historic data has a different size of sales period in days:\nIn 2016, the total sales period was 46 days.\nIn 2017, 77 days.\nIn 2018, 113 days.\nIn 2019 we are planning 85 days. So how do I  ajust those historical data, in a logic\/statistical way, so I could use them as inputs to a statistical predictive model (such as ARIMA model)?\nAlso, I'm planning to do this on Python, so if you have any suggestions about that, I would love to hear them too!\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":56333832,"Users Score":0,"Answer":"Based on what I understand after reading your question, I would approach this problem in the following way.\n\nFor each day, find how far out the event is from that day. The max\nvalue for this number is 46 in 2016, 77 in 2017 etc. Scale this value\nby the max day.\nUse the above variable, along with day of the month, day of the week\netc as extraneous variable\nAdditionally, use lag information from ticket sales. You can try one\nday lag, one week lag etc.\nYou would be able to generate all this data from the sale start until\nend.\nUse the generated variables as predictor for each day and use ticket\nsales as target variable and generate a machine learning model\ninstead of forecasting.\nUse the machine learning model along with generated variables to predict future sales.","Q_Score":1,"Tags":"python,statistics,time-series,prediction","A_Id":56335423,"CreationDate":"2019-05-28T00:51:00.000","Title":"Time series prediction: need help using series with different periods of days","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Because it has a method known as draw. Which considers the text attribute of the sprite so we can store surfaces , images and rectangles .But what if we want to store the circle sprite which requires position and radius to be drawn","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":31,"Q_Id":56334560,"Users Score":1,"Answer":"A sprite is an image; images happen to have rectangular shape because that's a natural consequence of the way they are represented.\nIf you want to draw a circle, you have two options: you can draw an image of the circle, which would be a sprite that you position like any other sprite, using its corner as its reference point; or you can draw an actual circle, where a sprite library would not be a huge help.","Q_Score":1,"Tags":"python,python-3.x","A_Id":56334647,"CreationDate":"2019-05-28T03:18:00.000","Title":"Can only be rectangular objects stored in pygame.sprite.Group","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing some code in PyTorch and I came across the gather function. Checking the documentation I saw that the index argument takes in a LongTensor, why is that? Why does it need to take in a LongTensor instead of another type such as IntTensor? What are the benefits?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":56335215,"Users Score":1,"Answer":"By default all indices in pytorch are represented as long tensors - allowing for indexing very large tensors beyond just 4GB elements (maximal value of \"regular\" int).","Q_Score":0,"Tags":"python,pytorch","A_Id":56335363,"CreationDate":"2019-05-28T04:57:00.000","Title":"Why does PyTorch gather function require index argument to be of type LongTensor?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a new GitHub user, and this question may be a trivial newbie problem. So I apologize in advance.\nI'm using PyCharm for a Python project. I've set up a Git repository for the project and uploaded the files manually through the Git website. I also linked the repository to my PyCharm project.  \nWhen I modify a file, PyCharm allows me to \"commit\" it, but when I try to \"push\" it, I get a PyCharm pop-up error message saying \"Push rejected.\" No further information is provided. How do I figure out what went wrong -- and how to fix it?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2214,"Q_Id":56335672,"Users Score":1,"Answer":"If you manually uploaded files to the Github by dropping them, it now likely has a different history than your local files. \nOne way you could get around this is to store all of your changes in a different folder, do a git pull in pycharm, abandoning your changes so you are up to date with origin\/master, then commit the files and push as you have been doing.","Q_Score":0,"Tags":"python,git,pycharm","A_Id":56335967,"CreationDate":"2019-05-28T05:42:00.000","Title":"Why can't I push from PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a program for speech to text in which I use speech recognition by pycharm ask for PyAudio so I tried to do so . But PyAudio in pycharm is not getting installed","AnswerCount":5,"Available Count":2,"Score":-0.0399786803,"is_accepted":false,"ViewCount":2071,"Q_Id":56336740,"Users Score":-1,"Answer":"try to install pipwin then try to install pyaudio\ncommands in terminal :\npip install pipwin\npipwin install pyaudio","Q_Score":2,"Tags":"python,pycharm","A_Id":67077405,"CreationDate":"2019-05-28T07:06:00.000","Title":"PyAudio in pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a program for speech to text in which I use speech recognition by pycharm ask for PyAudio so I tried to do so . But PyAudio in pycharm is not getting installed","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2071,"Q_Id":56336740,"Users Score":0,"Answer":"Just an add on to Nicholas's answer, instead of pipwin install pyaudio, py -m pipwin install pyaudio works for me.","Q_Score":2,"Tags":"python,pycharm","A_Id":65388901,"CreationDate":"2019-05-28T07:06:00.000","Title":"PyAudio in pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a BigQuery table 'A' with schema {'UUID': 'String'}. I want to join this table with a ADH(Ads Data Hub) table 'B' having schema {'UUID': 'String', 'USER_ID': 'INT'} on UUID and fetch all user_ids to a new table. \nI am having trouble in joining ADH table with BigQuery table.\nCan someone please help me out?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":774,"Q_Id":56339554,"Users Score":0,"Answer":"If your table A locates in the same region as your ADH account, you should be able to run cross table queries in ADH.\nYou cannot query user_id as part of the output by using ADH, it's not allowed due to privacy protection. However, if you had your UUID passed to Google Marketing Platform using floodlight with custom-variable enabled, you can use this UUID as join key to map both tables, and do analysis from there.","Q_Score":0,"Tags":"google-bigquery,google-ads-data-hub,ads-data-hub,python-bigquery","A_Id":68575038,"CreationDate":"2019-05-28T09:54:00.000","Title":"How to join BigQuery table with ADH(Ads Data Hub) table","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Did anybody use to write services, connected with ITSMChangeManagement of OTRS? Is there any API to this thing? I need smth. like GenericTicketConnector. Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":56339794,"Users Score":1,"Answer":"No, there is nothing with ITSMChangeManagement. Only Tickets, FAQ and ConfigItems can be used with the GenericInterface of the Community Edition","Q_Score":0,"Tags":"python,api,otrs,itsm","A_Id":56340530,"CreationDate":"2019-05-28T10:08:00.000","Title":"OTRS ITSMChange API service","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have gone through multiple questions that help divide your dataframe into train and test, with scikit, without etc.\nBut my question is I have 2 different csvs ( 2 different dataframes from different years). I want to use one as train and other as test?\nHow to do so for LinearRegression \/ any model?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1436,"Q_Id":56343657,"Users Score":0,"Answer":"please skillsmuggler what about the X_train and X_Test how I can define it because when I try to do that it said NameError: name 'X_train' is not defined","Q_Score":4,"Tags":"python,scikit-learn,linear-regression,data-science,training-data","A_Id":70738720,"CreationDate":"2019-05-28T13:45:00.000","Title":"How to pass different set of data to train and test without splitting a dataframe. (python)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a small set of aerial images where different terrains visible in the image have been have been labelled by human experts. For example, an image may contain vegetation, river, rocky mountains, farmland etc. Each image may have one or more of these labelled regions. Using this small labeled dataset, I would like to fit a gaussian mixture model for each of the known terrain types. After this is complete, I would have N number of GMMs for each N types of terrains that I might encounter in an image.\nNow, given a new image, I would like to determine for each pixel, which terrain it belongs to by assigning the pixel to the most probable GMM. \nIs this the correct line of thought ? And if yes, how can I go about clustering an image using GMMs","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":353,"Q_Id":56344581,"Users Score":-1,"Answer":"Its not clustering if you use labeled training data!\nYou can, however, use the labeling function of GMM clustering easily.\nFor this, compute the prior probabilities, mean and covariance matrixes, invert them. Then classify each pixel of the new image by the maximum probability density (weighted by prior probabilities) using the multivariate Gaussians from the training data.","Q_Score":1,"Tags":"python-3.x,scikit-learn,cluster-analysis,gmm","A_Id":56390413,"CreationDate":"2019-05-28T14:35:00.000","Title":"Gaussian Mixture Models for pixel clustering","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my app, the user can select a Youtube video that will be downloaded to MEDIA_ROOT folder and then also made available for the user to download.\nWhenever the user chooses another video to download, the previous one is deleted from MEDIA_ROOT. So at any given moment there is only one video sitting in the MEDIA_ROOT folder for a particular user.\nIs there any way - apart from implementing user authentication and associating the downloaded files with a user through foreign key, which I feel is an overkill for only this task - of telling the users apart whenever such download request is being made, so that one user's request does not cause the deletion of the file downloaded by some other user (as all the files sit in the same MEDIA_ROOT folder)?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":52,"Q_Id":56347774,"Users Score":1,"Answer":"Assuming you have some sort of web server, you can create custom links that redirect through your web server and pass IP information, etc, so you can distinguish a user before one downloads a video. That is certainly one way of doing it without authentication and since the app\/platform that tracks user data is in-house you don't have to worry about foreign keys, etc.","Q_Score":0,"Tags":"python,django","A_Id":56347972,"CreationDate":"2019-05-28T18:02:00.000","Title":"Are there any ways other than authentication to tell the users apart?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Currently, I have a Flask app waiting to be shifted to a shared drive in the company's local network. My current plan is to create a virtual environment inside a folder locally, install all the necessary dependencies like Python3, Flask, Pandas and etc. This is to ensure that my Flask app can still reference to necessary dependencies to run the app.\nAs I can't access my shared drive via command prompt, my plan is to create a virtual environment locally then shift it to the shared folder together with all the scripts required by my Flask app. Will the app be able to run on the shared drive in this manner?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":195,"Q_Id":56352790,"Users Score":1,"Answer":"The standard virtualenv hardcodes the path of the environment into some of its files in the environment it creates, and stops working if you rename it etc. So no, you'll probably have to recreate the env on the destination server.\nPerhaps your app's startup script could take care of creating the env if it's missing.","Q_Score":0,"Tags":"python,virtualenv","A_Id":56353155,"CreationDate":"2019-05-29T03:40:00.000","Title":"Will my virtual environment folder still work if i shift it from my local machine to a shared folder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a neural network in Python for a regression problem. I would like to have a prediction intervals for each value. How would I go about approaching this since neural networks are nonlinear?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":416,"Q_Id":56355244,"Users Score":1,"Answer":"One approach is caliculate residual for the validation set, it will be having a distribution, calculate mean, variance of the residual distribution and if you are looking for 95% add +,- 2sigma to your prediction and that should be your prediction interval.","Q_Score":0,"Tags":"python,machine-learning,neural-network,prediction,confidence-interval","A_Id":58932030,"CreationDate":"2019-05-29T07:31:00.000","Title":"Neural Network Prediction Interval","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there anyway to merge npz files in python. In my directory I have output1.npz and output2.npz.\nI want a new npz file that merges the arrays from both npz files.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":2625,"Q_Id":56355248,"Users Score":4,"Answer":"use numpy.load('output1.npz') and numpy.load('output2.npz') to load both files as array a1,a2. Then use a3 =[*a1,*a2] to merge them. Finally, output via numpy.savez('output.npz',a3)","Q_Score":5,"Tags":"python,numpy","A_Id":57006354,"CreationDate":"2019-05-29T07:31:00.000","Title":"Python merging npz files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to use some sort of clustering method on a set of datapoint vectors which have 45 dimensions. I'm fairly new to clustering data points and was wondering if anyone could point out appropriate methods to utilize? I was attempted using K-Means Clustering but was wondering if the dimensionality of my data might be too large for this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":323,"Q_Id":56355551,"Users Score":0,"Answer":"45 dimensions is not particularly high. It's at best \"medium\" dimensionality, so most algorithms could work.\nUsually it's not so much a matter of the number of dimensions, but rather how well they are preprocessed. With bad preprocessing, 2 dimensions can be a problem if the signal in one attribute is drowned by the noise in the other.\nThere is no automatic way to get this right, otherwise it would be in all the libraries. Scaling can help, but can also harm. It's up to the user to prepare the data and choose parameters (such as distance functions and algorithms) to achieve the desired effect, because there is no computable equation fot \"desirable\".","Q_Score":1,"Tags":"python,machine-learning,cluster-analysis","A_Id":56373034,"CreationDate":"2019-05-29T07:51:00.000","Title":"Best Clustering Algorithm for High Dimensional Vectors","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recently set up the latest version of anaconda and when I open my anaconda command prompt an error message occurs.\nDue to this issue, I am also not able to set up venv in my anaconda.\nI have tried to search that conda-645.tmp but I haven't found that in that particular location as well.\n\nAccess is denied. The system cannot find the file C:\\Users\\UDIT. Could\n  Not Find C:\\Users\\UDIT DEO\\AppData\\Local\\Temp\\conda-645.tmp","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":135,"Q_Id":56356470,"Users Score":0,"Answer":"Try running it as administrator.\nThis should solve this error.","Q_Score":0,"Tags":"python-3.x,anaconda","A_Id":56356701,"CreationDate":"2019-05-29T08:45:00.000","Title":"Whenever I open my anaconda command prompt the error message occurs, so help me with it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on an assignment where i have to assign 1 up to 10 distribution centers  to all US states. I have made a model in excel to calculate all the costs, and clearly the goal of the assignment is to find the cheapest way. I have 50 rows (for each state) and 10 columns (for all possible DC locations). My model is based on this matrix, and if I change the matrix, the costs will instantly display. The only constraint is that each state is supplied by exactly 1 DC.\nIts clear I cant make all possible combinations by hand, I have tried to translate my model into an optimization program (AIMMS), but it'l take allot of time witch I already put in the excel model. I was thinking if I had all possible matrices (generated in R, Matlab, or Python, dont care witch one) i can loop over my spreadsheet them and let a program read the cost, to determine the best choice. Its theoretically possible to supply all state by 1 DC, and at most 10, so every possible  1x50, 2x50, 3x50 ... 10x50 matrix is needed to determine the best one.\nSo again in short, is it possible to generate every nxm binary matrix with a sum total of 1 on each row in preferably R, or otherwise in Matlab or Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":56358243,"Users Score":2,"Answer":"TLDR: No.\n\nLet's look at the simpliest example: 2 DC. Your possible rows will be:\n\n(1,0)\n(0,1)\n\nNow you want to construct all possible 2x50 matrices. Their number is 2^50 (2 possible rows in 50 rows). It is equal to:\n1125899906842624\nWe suppose that each matrix stores 100 bytes. That all 2x50 matrices will store:\n(2**50) * 100 \/ 1024 \/ 1024 \/ 1024 \/ 1024 = 102400 terabytes of data.\nAnd to process all of them (in the most optimistic results for normal computers) will spend time equal to:\n(2**50) \/ 10**9 \/ 60 \/ 60 = 312 hours.\nAnd 10x50 will be even more...","Q_Score":1,"Tags":"python,r,matlab,matrix","A_Id":56358796,"CreationDate":"2019-05-29T10:18:00.000","Title":"How to generate all posible binary nxm matrices, where the sum of each row is 1","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 made script for browser game. In this game, I am standing still and my script clicks on certain places bksononechno, but I need that if I clicked on the letter k This script would kill itself and not try to close the browser and its tab in the browser and something similar.\nSorry for mistakes.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":56358674,"Users Score":0,"Answer":"You can add sys.exit(1) in the program itself and do Ctrl-C in the command line.","Q_Score":0,"Tags":"python","A_Id":58242184,"CreationDate":"2019-05-29T10:42:00.000","Title":"How to stop python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two related problems. I'm working on Arabic dataset using Excel. I think that Excel somehow reads the contents as \u061f\u061f\u061f\u061f\u061f , because when I tried to replace this character '\u061f' with this '?' it replaces the whole text in the sheet. But when I replace or search for another letter it works.\nSecond, I'm trying to edit the sheet using python, but I'm unable to write Arabic letters (I'm using jGRASP). For example when I write the letter '\u0644' it appears as 0644, and when I run the code this message appears : \"\u064fError encoding text. Unable to encode text using charset windows-1252 \".","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":224,"Q_Id":56358762,"Users Score":0,"Answer":"0644 is the character code of the character in hex. jGRASP displays that when the font does not contain the character. You can use \"Settings\" > \"Font\" in jGRASP to choose a CSD font that contains the characters you need. Finding one that has those characters and also works well as a coding font might not be possible, so you may need to switch between two fonts.\njGRASP uses the system character encoding for loading and saving files by default. Windows-1252 is an 8-bit encoding used on English language Windows systems. You can use \"File\" > \"Save As\" to save the file with the same name but a different encoding (charset). Once you do that, jGRASP will remember it (per file) and you can load and save normally. Alternately, you can use \"Settings\" > \"CSD Windows Settings\" > \"Workspace\" and change the \"Default Charset\" setting to make the default something other than the system default.","Q_Score":0,"Tags":"excel,python-3.x,utf-8,character-encoding,arabic","A_Id":56370930,"CreationDate":"2019-05-29T10:47:00.000","Title":"How to enable my python code to read from Arabic content in Excel?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I already got some input into the flask from the forms using the fetch API POST method. Now depending on this input, I want to ask some more inputs (without rendering a new HTML page.) and process them again, so that I can finally return a string as the fetch response.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":129,"Q_Id":56359854,"Users Score":0,"Answer":"you should use JS on client side to handling user's first input to make next form\/fields for him","Q_Score":0,"Tags":"javascript,python,reactjs,flask","A_Id":56360429,"CreationDate":"2019-05-29T11:44:00.000","Title":"How to ask user input from flask (I'm using react for front end)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"pip install MySQL-python-1.2.4b4.tar.gz returns this error on Python 2.7 (ubuntu 18.04):\nCan you help me?\n\n    # pip install MySQL-python-1.2.5.zip\n    Processing .\/MySQL-python-1.2.5.zip\n    Building wheels for collected packages: MySQL-python\n      Running setup.py bdist_wheel for MySQL-python ... error\n      Complete output from command \/usr\/bin\/python -u -c \"import setuptools, tokenize;__file__='\/tmp\/pip-00mbCK-build\/setup.py';f=getattr(tokeni                                                                                                 ze, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))\" bdist_wheel -d \/tmp\/tmpePf4                                                                                                 ITpip-wheel- --python-tag cp27:\n      running bdist_wheel\n      running build\n      running build_py\n      creating build\n      creating build\/lib.linux-x86_64-2.7\n      copying _mysql_exceptions.py -> build\/lib.linux-x86_64-2.7\n      creating build\/lib.linux-x86_64-2.7\/MySQLdb\n      copying MySQLdb\/__init__.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\n      copying MySQLdb\/converters.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\n      copying MySQLdb\/connections.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\n      copying MySQLdb\/cursors.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\n      copying MySQLdb\/release.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\n      copying MySQLdb\/times.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\n      creating build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n      copying MySQLdb\/constants\/__init__.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n      copying MySQLdb\/constants\/CR.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n      copying MySQLdb\/constants\/FIELD_TYPE.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n      copying MySQLdb\/constants\/ER.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n      copying MySQLdb\/constants\/FLAG.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n      copying MySQLdb\/constants\/REFRESH.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n      copying MySQLdb\/constants\/CLIENT.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n      running build_ext\n      building '_mysql' extension\n      creating build\/temp.linux-x86_64-2.7\n      x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -f                                                                                                 debug-prefix-map=\/build\/python2.7-3hk45v\/python2.7-2.7.15~rc1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_in                                                                                                 fo=(1,2,5,'final',1) -D__version__=1.2.5 -I\/usr\/include\/mysql -I\/usr\/include\/python2.7 -c _mysql.c -o build\/temp.linux-x86_64-2.7\/_mysql.o\n      _mysql.c:44:10: fatal error: my_config.h: No such file or directory\n       #include \"my_config.h\"\n                ^~~~~~~~~~~~~\n      compilation terminated.\n      error: command 'x86_64-linux-gnu-gcc' failed with exit status 1\n\n      ----------------------------------------\n      Failed building wheel for MySQL-python\n      Running setup.py clean for MySQL-python\n    Failed to build MySQL-python\n    Installing collected packages: MySQL-python\n      Running setup.py install for MySQL-python ... error\n        Complete output from command \/usr\/bin\/python -u -c \"import setuptools, tokenize;__file__='\/tmp\/pip-00mbCK-build\/setup.py';f=getattr(toke                                                                                                 nize, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))\" install --record \/tmp\/pip                                                                                                 -vhjCMt-record\/install-record.txt --single-version-externally-managed --compile:\n        running install\n        running build\n        running build_py\n        creating build\n        creating build\/lib.linux-x86_64-2.7\n        copying _mysql_exceptions.py -> build\/lib.linux-x86_64-2.7\n        creating build\/lib.linux-x86_64-2.7\/MySQLdb\n        copying MySQLdb\/__init__.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\n        copying MySQLdb\/converters.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\n        copying MySQLdb\/connections.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\n        copying MySQLdb\/cursors.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\n        copying MySQLdb\/release.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\n        copying MySQLdb\/times.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\n        creating build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n        copying MySQLdb\/constants\/__init__.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n        copying MySQLdb\/constants\/CR.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n        copying MySQLdb\/constants\/FIELD_TYPE.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n        copying MySQLdb\/constants\/ER.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n        copying MySQLdb\/constants\/FLAG.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n        copying MySQLdb\/constants\/REFRESH.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n        copying MySQLdb\/constants\/CLIENT.py -> build\/lib.linux-x86_64-2.7\/MySQLdb\/constants\n        running build_ext\n        building '_mysql' extension\n        creating build\/temp.linux-x86_64-2.7\n        x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g                                                                                                  -fdebug-prefix-map=\/build\/python2.7-3hk45v\/python2.7-2.7.15~rc1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_                                                                                                 info=(1,2,5,'final',1) -D__version__=1.2.5 -I\/usr\/include\/mysql -I\/usr\/include\/python2.7 -c _mysql.c -o build\/temp.linux-x86_64-2.7\/_mysql.o\n        _mysql.c:44:10: fatal error: my_config.h: No such file or directory\n         #include \"my_config.h\"\n                  ^~~~~~~~~~~~~\n        compilation terminated.\n        error: command 'x86_64-linux-gnu-gcc' failed with exit status 1\n\n        ----------------------------------------\n    Command \"\/usr\/bin\/python -u -c \"import setuptools, tokenize;__file__='\/tmp\/pip-00mbCK-build\/setup.py';f=getattr(tokenize, 'open', open)(__fi                                                                                                 le__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))\" install --record \/tmp\/pip-vhjCMt-record\/install-r                                                                                                 ecord.txt --single-version-externally-managed --compile\" failed with error code 1 in \/tmp\/pip-00mbCK-build\/\n\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":443,"Q_Id":56361162,"Users Score":0,"Answer":"If you use: \n\npip install mysqlclient==1.4.6\n\ninstead, then you'll find it works. The mariadb package has changed the way it stores some header files, and the MySQL-python pip package hasn't been updated for many years.\nI had the same problem and switching worked for me.","Q_Score":2,"Tags":"mysql-python","A_Id":60338668,"CreationDate":"2019-05-29T12:52:00.000","Title":"Installing MySQLdb for python 2.7 returns error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on a knowledge based chatbot creation on ibm watson and I have trained my custom model on ibm watson knowledge studio for agricultural database. Now if someone asked about any information that is not available in our dataset then how can we retrained that model\/improve the model with that new data ? \nI am using knowledge graph to retrieve the information. Knowledge graph is made in Neo4J.\nIf any new data comes or admin wants to retrain the model with new data than the model should retrained without going to knowledge studio like rasa is ibm watson assistant provides feedback system.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":161,"Q_Id":56361575,"Users Score":0,"Answer":"IBM Watson Knowledge Studio does not support online training to retrain the existing model with new data. To adapt to new data, you need to train a brand new model with both the new data and the existing data.","Q_Score":0,"Tags":"python-3.x,ibm-watson,watson-nlu,watson-knowledge-studio","A_Id":56368801,"CreationDate":"2019-05-29T13:17:00.000","Title":"Which are the possible ways to retrain a model made in IBM Watson Knowledge Studio?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently trying to establish a connection between a chrome-extension and a NativeMessagingHost. Everything works fine on Windows, but it won't do on Linux (either arch, kali or ubuntu). \nHow it fails: \n\nCan't find manifest for native messaging host my_host.json\n\nMy current state:\n\nhave my host manifest under ~\/.config\/google-chrome-beta\/NativeMessagingHosts\/my_host.json\n\nin there: \"name\":\"my_host.json\" and the path to my python script which handles the messages, also the unique chrome-extension code unter allowed_origins\n\nin manifest.json of my extension given the permission for nativeMessaging\nfurthermore in popup.js: var port = chrome.runtime.connectNative(\"my_host.json\"); and the same name used in sendNativeMessage\n\nWhat I tried so far:\n\ntried with google-chrome-beta and -stable\ndeleted file endings e.g. my_host.json to my_host, or removing the python ending\neasier paths where my python script lays\nalso tried to put my_host into \/Library\/Google\/Chrome\/NativeMessagingHosts which typically should be the Mac path - but hey, may it worked (not..)\n\nI get no error starting the application, copied the message from terminal whilst starting chrome with logging.\nI pretty much went through the example google gave, adjusting paths etc.\nAlso went through differnt posts, but it seems no one has the same problem, or no one tries to do something similar.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":257,"Q_Id":56361604,"Users Score":0,"Answer":"So I figured out where the problem was: \nI changed the name of my host from my_host.json to com.my.host.json and set \"name\" to com.my.host (where I firstly had the ending .json as well, which probably caused the problem too). Furthermore I changed var port = chrome.runtime.connectNative(\"my_host.json\") in my js-file to [...](\"com.my.host\") where the ending .json was not right too. Everything works now. Thank you for your suggestions!","Q_Score":0,"Tags":"javascript,python,google-chrome-extension","A_Id":56376376,"CreationDate":"2019-05-29T13:18:00.000","Title":"Manifest for native messaging host not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a canvas that has a width of w and a height of h. I'm trying to fit my (1000 x 800) image on it using image = image.zoom(w).subsample(800). But it's giving me the error: _tkinter.TclError: not enough free memory for image buffer. Can someone please help?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1456,"Q_Id":56362497,"Users Score":1,"Answer":"When you call zoom, the first parameter specifies how much to multiply each pixel by. If you only provide an x value, the y value will be the same as the x value. Thus, if w is 1000, zoom(x) will attempt to create an image that is one million pixels wide by 800,000 pixels tall. That's nearly a terabyte of image data.","Q_Score":0,"Tags":"python,tkinter,photoimage","A_Id":56362992,"CreationDate":"2019-05-29T14:06:00.000","Title":"Cannot zoom tkinter PhotoImage: _tkinter.TclError: not enough free memory for image buffer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have ran a DAI experiment & built the mojo-pipeline. Now I have brand new data with columns I originally dropped within the DAI GUI; ID column for example. Does the mojo-pipeline automatically drop these columns when scored or do I need to do this prior?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":162,"Q_Id":56366384,"Users Score":2,"Answer":"The mojo-pipeline will ignore all columns that weren't used for training - that includes columns that were dropped in DAI and any new columns they may have been introduced into the data.","Q_Score":0,"Tags":"python,driverless-ai","A_Id":56368666,"CreationDate":"2019-05-29T18:13:00.000","Title":"Does a mojo-pipeline automatically drop columns as specified during training?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"so I have an airflow DAG task which performs several checks on a file (e.g., if it was already processed in the past) and I want the whole DAG run to stop completely if one of the checks fails. How can I do that?\nBasically the checks are done in a python script.\nThx :","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3441,"Q_Id":56368548,"Users Score":6,"Answer":"Assuming you have no downstream tasks that ignore the failure of a previous task, raising an exception from within the task will cause the DAG to stop processing and be marked as failed.\nSo in your case, you can raise an exception when you find that the file has already been processed.","Q_Score":5,"Tags":"python,airflow","A_Id":56370441,"CreationDate":"2019-05-29T21:09:00.000","Title":"How to stop a Airflow DAG run from task","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am running into a limitation with an API I am working with. At the moment the max rows it can return is 10000. The goal is to access a month worth of data which sometimes can be up 200000 rows. This API allows filtering by start_at_row and row_limit. It also returns row_count in the response. I will need to make multiple requests in order to capture all 200000 rows. I'm stuck on figuring out how to trigger the next request after the first 10000 rows and how to pick at exactly at 10001 and run the next 10000 rows. Is there a common method used for this problem? Any advice is welcome. Let me know which pieces of information from my code I can provide that can be useful.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":56370374,"Users Score":0,"Answer":"Update, I was able to figure this out on my own after a little trial and error and more research on Google.\nI added start_at_row and row_limit as global variables that equal to 1 and 2 respectively.\nFrom there I added a while loop(start_at_row <= row_limit), I then captured the row_count from the response given by the API and made it equal to role_limit. \nTo break the loop I made and an if statement with start_at_row > row_limit","Q_Score":1,"Tags":"xml,python-3.x,beautifulsoup","A_Id":56403222,"CreationDate":"2019-05-30T01:06:00.000","Title":"How to iterate through smaller chunks of data in API response","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In some of my Apache Airflow installations, DAGs or tasks that are scheduled to run do not run even when the scheduler doesn't appear to be fully loaded. How can I increase the number of DAGs or tasks that can run concurrently?\nSimilarly, if my installation is under high load and I want to limit how quickly my Airflow workers pull queued tasks (such as to reduce resource consumption), what can I adjust to reduce the average load?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":46382,"Q_Id":56370720,"Users Score":2,"Answer":"Check the airflow configuration for which core.executor is used.\nSequentialExecutor will be executing sequentially, so you can choose Local Executor or Clery Executor which execute the task parallel.\nAfter that, you can use other options as mentioned by @hexacyanide","Q_Score":53,"Tags":"python,google-cloud-platform,airflow,google-cloud-composer","A_Id":56630703,"CreationDate":"2019-05-30T02:00:00.000","Title":"How to control the parallelism or concurrency of an Airflow installation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have an excel file where data is refreshing from third party application. \nProblem to solve: My DJANGO web application should monitor that excel file continuously and detect a change from that excel file. Whenever there is a change then particular location of web page should be refreshed.\nCould somebody please give suggestions to achieve this functionality?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":56370814,"Users Score":0,"Answer":"Basically, you need to check with a runtime process (e.g a cron) if the previously version of your file is different to the new version calling your runtime process. This means that you could read the content of the CSV file (could be with import csv or using pandas \u00ecmport pandas as pd) and store it in some place (e.g another temporal file), then (according the time of you define to execute your cron) the content will be check again, and compare it against the content of what you previously have stored. If this happens, you could use Ajax to refresh your website section or use a real time library to refresh automatically, and store the new csv content again.","Q_Score":0,"Tags":"django,python-2.7","A_Id":56370919,"CreationDate":"2019-05-30T02:14:00.000","Title":"Monitor and Detect a change in Excel file and refresh location of the web page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to produce a 0 or 1 with numpy's random.rand.\nnp.random.rand() produces a random float between 0 and 1 but not just a 0 or a 1. \nThank you.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6029,"Q_Id":56372240,"Users Score":0,"Answer":"Is there a reason to specifically use np.random.rand? This function outputs a float as noted in the question and previous answers, and you would need thresholding to obtain an int.\nscipy.stats.bernoulli(p) directly outputs a 1 with probability p and 0 with probability 1-p.","Q_Score":3,"Tags":"python,numpy","A_Id":68811985,"CreationDate":"2019-05-30T05:38:00.000","Title":"How do you produce a random 0 or 1 with random.rand","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m writing a HTTP\/1.1 client that will be used against a variety of servers.\nHow can I decide a reasonable default keep-alive timeout value, as in, how long the client should keep an unused connection open before closing? Any value I think of seems extremely arbitrary.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1106,"Q_Id":56373516,"Users Score":2,"Answer":"First note that that with HTTP keep alive both client and server can close an idle connection (i.e. no outstanding response, no unfinished request) at any time. This means especially that the client cannot make the server keep the connection open by enforcing some timeout, all what a client-side timeout does is limit how long the client will try to keep the connection open. The server might close the connection even before this client-side timeout is reached.\nBased on this there is no generic good value for the timeout but there actually does not need to be one. The timeout is essentially used to limit resources, i.e. how much idle connections will be open at the same time. If your specific use case will never visit the same site again anyway then using HTTP keep-alive would just be a waste of resources. If instead you don't know your specific usage pattern you could just place a limit on the number of open connections, i.e. close the longest unused connection if the limit is reached and a new connection is needed. It might make sense to have some upper limit timeout of 10..15 minutes anyway since usually after this time firewalls and NAT routers in between will have abandoned the connection state so the idle connection will no longer work for new requests anyway.\nBut in any case you also need to be sure that you detect if the server closes a connection and then discard this connection from the list of reusable connections. And if you use HTTP keep-alive you also need to be aware that the server might close the connection in the very moment you are trying to send a new request on an existing connection, i.e. you need to retry this request then on a newly created connection.","Q_Score":0,"Tags":"python-3.x,sockets,http,tcp,python-asyncio","A_Id":56374276,"CreationDate":"2019-05-30T07:18:00.000","Title":"HTTP\/1.1 client: How to decide good keep-alive timeout default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get a list of all the items available for purchase on a certain web page. However, the web page only loads 12 items at a time until the user scrolls down and then 12 more are loaded. Is there a way, in C# or Python, using any open source libraries, to be able to \"see\" all of the items available without physically going to the page and scrolling down?\nUsing Chrome's developer tools, I can only \"see\" the 12 items in the HTML window until I physically scroll down on the web page and it loads more.\nNOTE: I'm relatively new at C#\/Python web scraping, so I appreciate any in depth answers!\nEDIT: If I were to use something like Selenium, would it be possible to load everything programatically? If so, how?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":628,"Q_Id":56380988,"Users Score":0,"Answer":"The Web browser itself can obviously load more items, and a web browser is just a program, so yes, it's possible to write a program to do it.\nBut you'd essentially be writing a mini web browser, which is a lot of work.\nDoes the website itself offer a way to load more items at once?  i.e. some websites offer a link or a dropdown menu in the corner of the page that allows you to increase the maximum number of items shown.","Q_Score":1,"Tags":"c#,python,html,web-scraping","A_Id":56381247,"CreationDate":"2019-05-30T15:14:00.000","Title":"How can I load all items on a web page when using an HTML parser?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been given the task of clustering our customers base on products they bought together. My data contains 500,000 rows related to each customer and 8,000 variables (product ids). Each variable is a one hot encode vector that shows if a customer bought that product or not. \nI have tried to reduce the dimensions of my data with MCA (multiple correspondence algorithm) and then use k-means and dbscan for cluster analysis, but my results were not satisfying. \nWhat are some proper algorithms for cluster analysis of large datasets with high dimensions and their python implementation?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":452,"Q_Id":56380999,"Users Score":1,"Answer":"Instead of clustering, what you should likely be using is frequent pattern mining.\nOne-hot encoding variables often does more harm than good. Either use a well-chosen distance for such data (could be as simple as Hamming or Jaccard on some data sets) with a suitable clustering algorithm (e.g., hierarchical, DBSCAN, but not k-means). Alternatively, try k-modes. But most likely, frequent itemsets is the more meaningful analysis onnsuvh data.","Q_Score":0,"Tags":"python,cluster-analysis,large-data","A_Id":56383864,"CreationDate":"2019-05-30T15:14:00.000","Title":"Cluster analysis of large dataset containing only categorical variables","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"According to the boto3 documentation, boto3 is backwards compatible with Python 2.7 & Python 3. I've been running into a few issues that some Python versions weren't completely compatible with certain versions of boto3.\nI was wondering if there is:\n\na boto3 version that is best suited for Python 2.7\na boto3 version that is best suited for Python 3.6\na boto3 version that is best suited for Python 3.7\nor if the latest boto3 version should technically work for all versions of Python?\n\nI've read through the boto3 documentation and repository to see if any information is given on this, but could not find any relative information other than it should be compatible to all versions.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":208,"Q_Id":56382099,"Users Score":3,"Answer":"No, you always want the latest version of Boto3 so you will have access to all the latest Amazon services and features.","Q_Score":1,"Tags":"python,amazon-web-services,boto3","A_Id":56382178,"CreationDate":"2019-05-30T16:27:00.000","Title":"Are different boto3 versions better suited for different Python versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is a table with a list of users and their email on a webpage. At the top of the page, is a search\/filter input field that allows the user to type an email or username and filter for the result as he\/she is typing. \nThe problem: However, when I use the send_keys() method instead of doing this manually, nothing is filtered in the table view.\nThis is happening on the Safari browser on the iPhone 7 Plus (real device, not simulator). Some other information:\n\niOS version: 12.2\nAppium version: 1.13.0-beta.3\nSelenium version: 2.53.1\nProgramming language: Python 2.7.15\n\nIn addition to send_keys(), i've tried to use set_value(), i've also tried to execute JS and setting the attribute value, and also tried to send key for each character (in a for loop with a delay between each character).\nI'm expecting for example, element.send_keys(\"test1000@test.com) to filter the table view on the web page so that the only user that is displayed has the associated test1000@test.com email as it does when I go through the site manually.\nIn actuality, send_keys() does not do that and nothing in the table view gets filtered.\nAny help or guidance would be appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":288,"Q_Id":56382223,"Users Score":0,"Answer":"Explicit wait for table to get populate in DOM\nsendKeys search String and additional key Tab\ntextbox.sendKeys(\"test1000@test.com\"+Keys.TAB)\nExplicit Wait for filter to get applied and table to get refreshed.\nfind elements for the newly populated table with applied filters.","Q_Score":0,"Tags":"selenium,appium,appium-ios,python-appium","A_Id":56395049,"CreationDate":"2019-05-30T16:37:00.000","Title":"Using send_keys() on a search\/filter input field does not filter results in table","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 new to web scraping and am trying to learn more. I know some websites load products on the back end before they make it available to the general public. Is there a way I can access that information using an HTML parser or any other library?\nI suspect the website developers use dynamic javascript to alter the information after loading. Or use different tags\/classes to hide the information?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":56382627,"Users Score":0,"Answer":"I see two questions here: \n1)Can I access information on the webserver that isn't sent to the client page? \nNo. You can only scrape what exists on the page. Anything else would be illegally accessing a non-public server and goes beyond scraping into hacking.\n2) If the site loads asynchronously and\/or dynamically, can I access the content that loads after the main portion of the html?\nYes, using browser automation tools like selenium, you can approximate a user experiencing the site and wait for the full content to load before you scrape it. This is different from simple requests\/beautifulsoup, which only gathers the HTML at the point when you send the request.","Q_Score":0,"Tags":"python,web-scraping,beautifulsoup","A_Id":56382871,"CreationDate":"2019-05-30T17:05:00.000","Title":"If a website loads a product on the back end but does not publish it for the public yet, can I access that information?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to run ipython with some packages already imported?\nalmost every time when I run ipython I do import numpy as np, is it possible to automate this process? i.e. just after I run ipython I want to be able to write something like np.array([0,1]). Is it possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":56382641,"Users Score":0,"Answer":"In the case of Mac add a script like load_numpy.py under ~\/.ipython\/profile_default\/startup\/ directory and add the import statements you need to that script. Every time you run ipython, all the scripts in the startup directory will be executed first and so the imports will be there. in case of Ubuntu add the file to ~\/.config\/ipython\/profile_default\/startup\/","Q_Score":1,"Tags":"python,numpy,ipython","A_Id":56382933,"CreationDate":"2019-05-30T17:06:00.000","Title":"Is it possible to run ipython with some packages already imported?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to generate requirements\/dev.txt and prod.txt files for my python project. I'm using pip-compile-multi to generate them from base.in dev.in and prod.in files. Everything works great until I add tensorflow-gpu==2.0.0a0 into the prod.in file. I get this error when I do: RuntimeError: Failed to pip-compile requirements\/prod.in.\nI believe this is because tensorflow-gpu is only available on Linux, and my dev machine is a Mac. (If I run pip install tensorflow-gpu==2.0.0a0 I am told there is no distribution for my platform.) Is there a way I can generate a requirements.txt file for pip for a package that is not available on my platform? To be clear, my goal is to generate a requirements.txt file using something like pip-compile-multi (because that will version dependencies) that will only install on Linux, but I want to be able to actually generate the file on any platform.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":663,"Q_Id":56383379,"Users Score":1,"Answer":"You could run pip-compile-multi in a Docker container. That way you'd be running it under Linux, and you could do that on your Mac or other dev machines. As a one-liner, it might look something like this:\ndocker run --rm --mount type=bind,src=$(pwd),dst=\/code -w \/code python:3.8 bash -c \"pip install pip-compile-multi && pip-compile-multi\"\nI haven't used pip-compile-multi, so I'm not exactly sure how you call it. Maybe you'd need to add some arguments to that command. Depending on how complicated your setup is, you could consider writing a Dockerfile and simplifying the one-liner a bit.","Q_Score":3,"Tags":"python,pip","A_Id":62975319,"CreationDate":"2019-05-30T18:01:00.000","Title":"How can I generate a requirements.txt file for a package not available on my development platform?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to use the authenticated user or the server keytab in a python3\/flask-kerberos application to query ldap?\nI am using flask-kerberos connecting to active directory and is authenticating correctly.  I need to add authorization now based on the AD group and understand ldap is typically the best practice. \nI am able to query successfully via ldap3, but I do not want to hardcode ldap bind credentials in my code.\nThe sasl\/kerberos bind option for ldap3 looks like it needs an OS level credential-cache, but I would like to do this completely within the application.\nLooking for any suggestions\/alternatives to do this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":665,"Q_Id":56384129,"Users Score":0,"Answer":"sounds like you are mixing up authentication and authorization, but with no useful information provided regarding your code or setup its hard to help.\nTake a look at something like this, and use ldap as impersonation to authenticate your users using their own credentials.","Q_Score":2,"Tags":"python,flask,ldap,kerberos","A_Id":56399552,"CreationDate":"2019-05-30T18:58:00.000","Title":"python ldap search with flask-kerberos credentials","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to cluster images based on their similarities with SIFT and Affinity Propagation, I did the clustering but I just don't want to visualize the results. How can I test with a random image from the obtained labels? Or maybe there's more to it?\nOther than data visualization, I just don't know what follows after clustering. How do I verify the 'clustering'","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":38,"Q_Id":56385518,"Users Score":1,"Answer":"since clustering is unsupervised, there isn't an objective way to evaluate it. Typically, you just observe and see if there is some features for a certain cluster.","Q_Score":0,"Tags":"python,deep-learning,cluster-analysis,k-means,sklearn-pandas","A_Id":56388545,"CreationDate":"2019-05-30T20:56:00.000","Title":"what follows after clustering","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to cluster images based on their similarities with SIFT and Affinity Propagation, I did the clustering but I just don't want to visualize the results. How can I test with a random image from the obtained labels? Or maybe there's more to it?\nOther than data visualization, I just don't know what follows after clustering. How do I verify the 'clustering'","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":56385518,"Users Score":0,"Answer":"If you have ground-truth cluster labels, you can measure Jacquad-Index or something in that line to get an error score. Then, you can tweak your distance measure or parameters etc. to minimize the error score. \nYou can also do some clustering in order to group your data as the divide step in divide-and-conquer algorithms\/applications.","Q_Score":0,"Tags":"python,deep-learning,cluster-analysis,k-means,sklearn-pandas","A_Id":56388587,"CreationDate":"2019-05-30T20:56:00.000","Title":"what follows after clustering","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So i'm pretty new to the whole windows repo cloning thing. I installed python 2.7, added the path to my windows cmd and I still cannot run any git clone commands. It shows the following output :\ngit clone\n  File \"\", line 1\n    git clone\n            ^\nI've been scouring the internet for an answer but apparently it should work if I use cmd. \nAny help would be appreciated!\ngit clone\n  File \"\", line 1\n    git clone\n            ^","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":356,"Q_Id":56387414,"Users Score":0,"Answer":"I have had the same issue recently with 3.7, so I made a new username and it worked. Kind of nice, a clean new Windows profile, even though I just started using it again compared to linux. A pain though.\nMake sure all other versions of Python are not installed, or at least affecting the path to the file you need the pip installs to be saved. Python can be saved in a few different locations, and some rare times it has been shown in very obscure places. Check where your file saved on your PC. Probablu C:\/ then could be many paths. \/Users\/UnserNameHere\/Windows\/ProgramFiles. I would use the search bar in the good old GUI while searching under the C drive (if you have multiple HDD\/SDD then pic the one used for the C drive, if nothing comes up try the other drives. \nYour looking for a file PythonFoundation I can't remember the entire name, however it will have a very long name Python Foundation are in the name of the file. This is where thing are store and where the path should be sending modules, at least the correct file inside that file. \nAlso try doing it from other Python versions installed. If you had 3.6 and got 3.7 it doesn't mean 3.6 has been deleted. Also doesn't mean you path, is not set to 3.6 while using 3.7. Same with Python 2, most people or many have both. The pip commands vary between python versions pip3 I believe is used (getting windows and linux a little mixed up right now)\nIf all fails do it the old fashon way, find the mod, download it, and move it to the python file I mentioned above. The homepage for python should have a tab linking to a page, or it's on the main page, letting you know where it has been known to save. Google how to see he path Pip is taking, or how to see if pip is installed and where, and what paths are set to.","Q_Score":0,"Tags":"windows,python-2.7,cmd","A_Id":56387612,"CreationDate":"2019-05-31T00:58:00.000","Title":"Cannot run git clone or pip install commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Say I define a list object and only want it to be read-only in a function I define. In C++, you'd do this with a const reference. Is there any way to do this with a python function? Does this make sense with respect to writing \"pythonic\" code or am I just trying to apply a C++ paradigm incorrectly?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":181,"Q_Id":56387866,"Users Score":1,"Answer":"In Python, all variables are references, so having an equivalent of C's const wouldn't really do anything. If the pointed-to object is mutable, you can mutate it; if it's immutable, you can't.\nHowever, there are some types that are mutable, and some that aren't. Lists are mutable, but tuples are not. So if you pass your data as a tuple, you're guaranteed the function can't do anything to it.\nTo use a C metaphor, a list of integers is somewhat like an int[], and a tuple of integers is a const int[]. When you pass them to a function, it doesn't matter if you're passing a const reference or a non-const reference; what matters is whether the thing it references is const or not.","Q_Score":3,"Tags":"python,immutability","A_Id":56387957,"CreationDate":"2019-05-31T02:14:00.000","Title":"Is it possible to force data immutability in a python 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":"Traceback (most recent call last):   File\n  \"AutoFC_AlexNet_randomsearch_CalTech101_v2.py\", line 112, in \n      X = layers.Dense(neurons, activation=activation, kernel_initializer=weight_init)(X)   File\n  \"\/home\/shabbeer\/NAS\/lib\/python3.5\/site-packages\/keras\/legacy\/interfaces.py\",\n  line 91, in wrapper\n      return func(*args, **kwargs)   File \"\/home\/shabbeer\/NAS\/lib\/python3.5\/site-packages\/keras\/layers\/core.py\",\n  line 824, in init\n      self.kernel_initializer = initializers.get(kernel_initializer)   File\n  \"\/home\/shabbeer\/NAS\/lib\/python3.5\/site-packages\/keras\/initializers.py\",\n  line 503, in get\n      identifier) ValueError: ('Could not interpret initializer identifier:', 0.2)\n\nI am getting the above error when running the code using tensorflow-gpu version 1.4.0 and keras version 2.1.3","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":3852,"Q_Id":56388245,"Users Score":4,"Answer":"you should change it to X = layers.Dense(neurons, activation=activation, kernel_initializer=keras.initializers.Constant(weight_init))(X)","Q_Score":0,"Tags":"tensorflow,keras,python-3.5","A_Id":60986471,"CreationDate":"2019-05-31T03:19:00.000","Title":"ValueError: ('Could not interpret initializer identifier:', 0.2)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Formulas in the excel sheet are getting removed when it is saved through an openpyxl python script.\nIs there any way to save excel file without removing formulas using a python script\nExpected: Formulas should not be removed and data should be read through openpyxl lib\nActual: Data is read, but formulas are getting removed","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":589,"Q_Id":56390764,"Users Score":0,"Answer":"Though xlswings, this issue is resolved","Q_Score":0,"Tags":"python,openpyxl","A_Id":56521506,"CreationDate":"2019-05-31T07:40:00.000","Title":"Unable to save formulas under excel file when it is saved using openpyxl lib","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The problem I encountered when I ran the official code of maskrcnn-benchmark for facebookresearch,which was wrong when loading the pre-training model.\nThe code runs on a remote server at the school and the graphics card is an NVIDIA P100.\ncheckpointer = DetectronCheckpointer(\n        cfg, model, optimizer, scheduler, output_dir, save_to_disk)\nextra_checkpoint_data = checkpointer.load(cfg.MODEL.WEIGHT)\narguments.update(extra_checkpoint_data)\nI expect to run the code correctly and understand why this is the problem.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":7056,"Q_Id":56391392,"Users Score":1,"Answer":"The reason about the problem is that the previous download was not finished. So when I deleted the original file and re-downloaded it, the problem was solved.","Q_Score":0,"Tags":"python-3.x,pytorch","A_Id":56556679,"CreationDate":"2019-05-31T08:28:00.000","Title":"How to fix '_pickle.UnpicklingError: invalid load key, '<' ' error in Pytorch","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2000 inserts in a loop\nI do execute sql\nMy question is: should i do commit after every execute or after loop in order to minimise my affect on locking table and don't care about buffer?\nthe problem: my script sending to much queries and they stand in wait\nI don't ask about limits of sql for x rows in commit and not about rollback in code. My question is about queue that standing half day in oracle server inactive and some waiting and prevent to new one proccess to run.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":623,"Q_Id":56393924,"Users Score":2,"Answer":"2000 inserts is close to nothing. Though, it would be far better if you could insert them at once, using a single INSERT statement, than doing it in a loop.\nGenerally speaking, commit once you're done with the transaction. It is most probably not ended at every turn of the loop, is it? Besides, committing in a loop (frequently) leads to ORA-01555 snapshot too old error.\nSaying that \"your script sends many queries\" - what kind of them? SELECTs aren't blocked by anything. INSERTs aren't blocked either (I guess you don't lock the whole table, do you)? If you're trying to update rows locked by other user(s), that - obviously - won't work until they are released. The question is: why do those queries wait half a day? Smells like bad management.","Q_Score":0,"Tags":"python,oracle","A_Id":56394192,"CreationDate":"2019-05-31T11:05:00.000","Title":"should i do commit after every execute or after loop","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have java application. I want to find automation_id's for each control. I used print_control_identifiers() and dump_tree(). But, it took lot of time (more that 2 hours).Is there any possible way to get automation_id's within in small time? Also, with my application after clicking on button one window is opened. How can I find automation_id's for this window only?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":279,"Q_Id":56394179,"Users Score":1,"Answer":"use Inspect.exe to find automation id's of any control","Q_Score":0,"Tags":"python,pywinauto","A_Id":57095827,"CreationDate":"2019-05-31T11:23:00.000","Title":"How to find Automation_Id's using pywinauto?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am creating a simple Kivy app in python, but I can't figure out how to upload the .py as app to my iPhone for free.\nCan someone help me with this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":152,"Q_Id":56400561,"Users Score":1,"Answer":"according to kivy documentation: \n\nIn order to submit any application to the iTunes store, you will need an iOS Developer License. For testing, you can use a physical device or the XCode iOS emulator.\n\nI suggest using a cheap android phone to test out your application. You will need to package your application for Android. In order to do this, you will need to use Linux.","Q_Score":1,"Tags":"python,ios,kivy","A_Id":56408450,"CreationDate":"2019-05-31T19:09:00.000","Title":"How to upload a python file with Kivy to iPhone for free?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I just installed Thonny and took a look at some beginner guides. I can easily run whole script by pressing \"play\" button (or pressing F5). However I could not figure out how to run only some particular lines in the script.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1360,"Q_Id":56401276,"Users Score":0,"Answer":"In Thonny there is a \u2018de-bugger\u2019 button at the top (or f6) and if you press that you run through your code one line at a time. It is extremely useful for when you are trying to find out where your code goes wrong. I hope you find this helpful :).","Q_Score":0,"Tags":"python,ide,thonny","A_Id":62150445,"CreationDate":"2019-05-31T20:18:00.000","Title":"Is it possible to run a particular line of Python code instead of the whole script in Thonny?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Some preliminary testing shows that a project I'm working on could potentially benefit from the use of a Support-Vector-Machine to solve a tricky problem. The concern that I have is that there will be major memory constraints. Prototyping and testing is being done in python with scikit-learn. The final version will be custom written in C. The model would be pre-trained and only the decision function would be stored on the final product. There would be <= 10 training features, and <= 5000 training data-points. I've been reading mixed things regarding SVM memory, and I know the default sklearn memory cache is 200 MB. (Much larger than what I have available) Is this feasible? I know there are multiple different types of SVM kernel and that the kernel's can also be custom written. What kernel types could this potentially work with, if any?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":158,"Q_Id":56402429,"Users Score":2,"Answer":"If you're that strapped for space, you'll probably want to skip scikit and simply implement the math yourself.  That way, you can cycle through the data in structures of your own choosing.  Memory requirements depend on the class of SVM you're using; a two-class linear SVM can be done with a single pass through the data, considering only one observation at a time as you accumulate sum-of-products, so your command logic would take far more space than the data requirements.\nIf you need to keep the entire data set in memory for multiple passes, that's \"only\" 5000*10*8 bytes for floats, or 400k of your 1Mb, which might be enough room to do your manipulations.  Also consider a slow training process, re-reading the data on each pass, as this reduces the 400k to a triviality at the cost of wall-clock time.\nAll of this is under your control if you look up a usable SVM implementation and alter the I\/O portions as needed.\nDoes that help?","Q_Score":1,"Tags":"python,c,performance,memory-management,svm","A_Id":56402618,"CreationDate":"2019-05-31T22:41:00.000","Title":"Is it feasible to run a Support Vector Machine Kernel on a device with <= 1 MB RAM and <= 10 MB ROM?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to sample around 1000 points from a 3-D ellipsoid, uniformly. Is there some way to code it such that we can get points starting from the equation of the ellipsoid?\nI want points on the surface of the ellipsoid.","AnswerCount":6,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2545,"Q_Id":56404399,"Users Score":3,"Answer":"Consider using Monte-Carlo simulation: generate a random 3D point; check if the point is inside the ellipsoid; if it is, keep it. Repeat until you get 1,000 points. \nP.S. Since the OP changed their question, this answer is no longer valid.","Q_Score":5,"Tags":"python,math,random,geometry,ellipse","A_Id":56404614,"CreationDate":"2019-06-01T06:29:00.000","Title":"How to generate a random sample of points from a 3-D ellipsoid using Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to sample around 1000 points from a 3-D ellipsoid, uniformly. Is there some way to code it such that we can get points starting from the equation of the ellipsoid?\nI want points on the surface of the ellipsoid.","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2545,"Q_Id":56404399,"Users Score":0,"Answer":"One way of doing this whch generalises for any shape or surface is to convert the surface to a voxel representation at arbitrarily high resolution (the higher the resolution the better but also the slower). Then you can easily select the voxels randomly however you want, and then you can select a point on the surface within the voxel using the parametric equation. The voxel selection should be completely unbiased, and the selection of the point within the voxel will suffer the same biases that come from using the parametric equation but if there are enough voxels then the size of these biases will be very small.\nYou need a high quality cube intersection code but with something like an elipsoid that can optimised quite easily. I'd suggest stepping through the bounding box subdivided into voxels. A quick distance check will eliminate most cubes and you can do a proper intersection check for the ones where an intersection is possible. For the point within the cube I'd be tempted to do something simple like a random XYZ distance from the centre and then cast a ray from the centre of the elipsoid and the selected point is where the ray intersects the surface. As I said above, it will be biased but with small voxels, the bias will probably be small enough.\nThere are libraries that do convex shape intersection very efficiently and cube\/elipsoid will be one of the options. They will be highly optimised but I think the distance culling would probably be worth doing by hand whatever. And you will need a library that differentiates between a surface intersection and one object being totally inside the other.\nAnd if you know your elipsoid is aligned to an axis then you can do the voxel\/edge intersection very easily as a stack of 2D square intersection elipse problems with the set of squares to be tested defined as those that are adjacent to those in the layer above. That might be quicker.\nOne of the things that makes this approach more managable is that you do not need to write all the code for edge cases (it is a lot of work to get around issues with floating point inaccuracies that can lead to missing or doubled voxels at the intersection). That's because these will be very rare so they won't affect your sampling.\nIt might even be quicker to simply find all the voxels inside the elipse and then throw away all the voxels with 6 neighbours... Lots of options. It all depends how important performance is. This will be much slower than the opther suggestions but if you want ~1000 points then ~100,000 voxels feels about the minimum for the surface, so you probably need ~1,000,000 voxels in your bounding box. However even testing 1,000,000 intersections is pretty fast on modern computers.","Q_Score":5,"Tags":"python,math,random,geometry,ellipse","A_Id":72498276,"CreationDate":"2019-06-01T06:29:00.000","Title":"How to generate a random sample of points from a 3-D ellipsoid using Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently implementing decision tree algorithm. If I have a continous featured data how do i decide a splitting point. I came across few resources which say to choose mid points between every two points but considering I have 8000 rows of data this would be very time consuming. The output\/feature label is having category data. Is any approach where I can perform this operation quicker","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":56406338,"Users Score":0,"Answer":"Decision tree works calculating entropy and information gain to determine the most important feature. Indeed, 8000 row is not too much for decision tree. But generally, Random forest is similar to decision tree. It is working as ensemble. You can review and try it.Moreover,  maybe being slowly is related to another thing.","Q_Score":0,"Tags":"python,machine-learning,artificial-intelligence,decision-tree,machine-learning-model","A_Id":56410719,"CreationDate":"2019-06-01T11:32:00.000","Title":"How to choose a split variables for continous features for decision tree","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I found a solution to this:\ndf['Name']=df['Name'].str.lstrip\ndf['Parent']=df['Name'].str.lstrip\n\nI have this DataFrame df (there is a white space at the left of \"A\" and \"C\" in the second row (which doesn't show well here). I would like to remove that space.\nMark    Name    Parent  age\n10  A   C   1\n12   A   C  2\n13  B   D   3\nI tried \ndf['Name'].str.lstrip()\ndf['Parent'].str.lstrip()\nthen tried \ndf.to_excel('test.xlsx')\nbut the result in excel didn't remove the white spaces\nI then tried defining another variable\nx=df['Name'].str.lstrip\nx.to_excel('test.xlsx')\nthat worked fine in Excel, but this is a new dataFrame, and only had the x column\nI then tried repeating the same for 'Parent', and to play around with joining multiple dataframes to the original dataframe, but I still couldnt' get it to work, and that seems too convoluted anyway\nFinally, even if my first attempt had worked, I would like to be able to replace the white spaces in one go, without having to do a separate call for each column name","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":56406907,"Users Score":0,"Answer":"You could try using\n\n\n\ndf['Name'].replace(\" \", \"\")\n\n\n\nthis would delete all whitespaces though.","Q_Score":0,"Tags":"python,pandas,strip","A_Id":56409739,"CreationDate":"2019-06-01T12:48:00.000","Title":"Removing white space at the beginning of values in multiple columns","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have trained a Machine Learnig Model using Sklearn and looked at different scores for the traing, testing (dev) and validation set. \nHere are the scores:\n\nAccuracy on Train: 94.5468% \nAccuracy on Test: 74.4646% \nAccuracy on Validation: 65.6548% \nPrecision on Train: 96.7002% \nPrecision on Test: 85.2289% \nPrecision on Validation: 79.7178% \nF1-Score on Train: 96.9761% \nF1-Score on Test: 85.6203% \nF1-Score on Validation: 79.6747%\nI am having some problems with Interpretation of the scores. Is it normal, that the Model has a much worse result on the validation set?\nDo you have thoughts on those results?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":330,"Q_Id":56406988,"Users Score":0,"Answer":"As you explained in the comments, your test set is the set you used to tune your parameters and the validation set is the set that your model didn't use for training.\n\nConsidering that, it's natural that your Validation scores are lower than other scores.\n\nWhen you're training a machine learning model, you show the training set to your model, that's why your model get's the best scores on training set, i.e. samples it has already seen and knows the answer for.\n\nYou use validation set to tune your parameters (e.g. degree of complexity in regression and so on) so your parameters are fine tuned for your validation sets but your model has not been trained on them. (for this you used the term test set, and to be fair they are sometimes used that way)\n\nfinally you have the least score on your test set which is natural since the parameters are not exactly tuned for the test set and the model has never seen them before.\n\nif there is a huge hap between your training and test results, your model might have become overfit and there are ways to avoid that.\n\n\nhope this helped ;)","Q_Score":0,"Tags":"python,validation,machine-learning,scikit-learn,data-science","A_Id":56407510,"CreationDate":"2019-06-01T13:01:00.000","Title":"Interpretation of Training, Testing (Dev) and Validation Score in Machine Learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building my custom class, which is a subclass of object. (No other superclass is in option because of __r(operator)__ priority.)\nSince this class is not sympy class, it is sympified whenever I try to apply it to sympy functions, and this is causing troubles.\nIs there any way to make it return itself when it is sympified? For example, just like sympify(sin(x)) returns sin(x), I want the instance of my class to behave in such way: sympify(instance) to return instance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":56407288,"Users Score":0,"Answer":"Try adding a def for _sympy_ in your class: def _sympy_(self): return self or maybe Basic(self)...but then SymPy won't be able to work with such expressions. Can you give an example of what you are trying to do? There is the CantSympify mixin available, too, but that will prevent the object from being sympified at all.","Q_Score":0,"Tags":"python,sympy","A_Id":56407781,"CreationDate":"2019-06-01T13:43:00.000","Title":"Can I prevent my custom class from being sympified?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I already trained a word2vec model with gensim library. For example, my model contains vectors for 2 words: \"new\" and \"york\". However, I also want to train a vector for the word \"new york\", so I transform \"new york\" into \"new_york\" and train a new vector model. Finally, I want to combine 3 vectors: vector of the word \"new\", \"york\" and \"new_york\" into one vector representation for the word \"new york\".\nHow can I save the new vector value to the model?\nI try to assign the new vector to the model but gensim did not allow to assign the new value for vector model.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":103,"Q_Id":56408959,"Users Score":1,"Answer":"Word-vectors are generally only comparable to each other if they were trained together.\nSo, if you want to have vectors for all of 'new', 'york', and 'new_york', you should prepare a corpus which includes them all, in a variety of uses, and train a Word2Vec model from that.","Q_Score":1,"Tags":"python,vector,gensim,word2vec","A_Id":56411523,"CreationDate":"2019-06-01T17:31:00.000","Title":"Create a new vector model in gensim","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to print receipt without decimal number in this receipt \nIn PosTicket of POS odoo 11, the receipt always have decimal number. I can change the digit at product price outside, but when go to the Print Receipt. It have decimal number. How can i remove them to print without this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":298,"Q_Id":56412540,"Users Score":0,"Answer":"Are you trying to take decimal number out through out the entire system?\nor just the POS module? or particular form?  \nOdoo comes with built-in setting located at\nSettings>Technical>Database Structure>Decimal Accuracy \nFrom there, you can customize decimal points in the system, one of them is Product Price.","Q_Score":0,"Tags":"python-3.6,odoo-11","A_Id":56436636,"CreationDate":"2019-06-02T05:56:00.000","Title":"How can we remove decimal number llike \".00\" in PosTicket for \"print receipt\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This is my first question so I appologize if it's not the best quality.\nI have a use case: User creates a monitoring task which sends an http request to a website every X hours. User can have thousands of these tasks and can add\/modify and delete them. When a user creates a task, django signals create a Celery periodic task which then is running periodically.\nI'm searching for a more scalable solution using AWS. I've read about using Lambda + Cloudwatch Events. \nMy question is: how do I approach this to let my users create tens of thousands of these tasks in the cheapest \/ most scalable way?\nThank you for reading my question!\nPeter","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":209,"Q_Id":56413651,"Users Score":0,"Answer":"There is no straight forward solution to your problem .You have to proceed step by step with some plumbing along the way .\nEvent management\n1- Create a lambda function that creates a cloudwatch schedule.\n2 - Create a lambda function that deletes a cloudwatch schedule.\n3 - Persist any event created using dynamodb\n4 - Create 2 API gateway  that will invoke the 2 lambda above.\n5 - Create anohter lambda function (used by cloudwatch) that will invoke the API gateway below.\n6 - Create API gateway that will invoke the website via http request.\nWhen the user creates an event from the app, there will be a chaining calls as follow :\n4 -> 1,3 -> 5-> 6\nNow there are two other parameters to take into consideration :\nLambda concurrency: you can't run simultaneously more than 1000 lambda in same region.\nCloudwatch: You can not create more than 100 rules per region . Rule is where you define the schedule.","Q_Score":1,"Tags":"python,django,amazon-web-services,aws-lambda,amazon-cloudwatch","A_Id":56414951,"CreationDate":"2019-06-02T09:05:00.000","Title":"What is a scalable way of creating cron jobs on Amazon Web Services?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Let's say I've already have a tfrecords named a.tfrecords.\nNow I generate another tfrecords file also named a.tfrecords with \ntfrecordWriter = tf.python_io.TFRecordWriter('a.tfrecords'). \nI'm wondering if the old tfrecords file be replaced(removed) or continue adding data into the old tfrecords file?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":211,"Q_Id":56413723,"Users Score":0,"Answer":"I tried by myself. The answer is the old tfrecords file will be replaced by the new one.","Q_Score":0,"Tags":"python,tensorflow","A_Id":56413833,"CreationDate":"2019-06-02T09:16:00.000","Title":"Will TFRecordWriter replace existed tfrecords?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My model requires to run many epochs in order to get decent result, and it takes few hours using v100 on Google Cloud.\nSince I'm on a preemptible instance, it kicks me off in the middle of training. I would like to be able to resume from where it left off.\nIn my custom CallBack, I run self.model.save(...) in on_epoch_end. Also it stops the training if the score hasn't improved in last 50 epochs.\nHere are the steps I tried:\n\nI ran model.fit until the early stops kicked in after epoch 250 (best score was at epoch 200)\nI loaded the model saved after 100th epoch.\nI ran model.fit with initial_epoch=100. (It starts with Epoch 101.)\n\nHowever, it takes while to catch up with the first run. Also the accuracy score of each epoch gets kind of close to the first run, but it's lower. Finally the early stop kicked in at like 300, and the final score is lower than the first run. Only way I can get the same final score is to create the model from scratch and run fit from the epoch 1.\nI also tried to utilize float(K.get_value(self.model.optimizer.lr)) and K.set_value(self.model.optimizer.lr, new_lr).\nHowever, self.model.optimizer.lr always returned the same number. I assume it's because the adam optimizer calculates the real lr from the initial lr that I set with Adam(lr=1e-4).\nI'm wondering what's the right approach to resume training using Adam optimizer?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6918,"Q_Id":56414605,"Users Score":0,"Answer":"What about model.load('saved.h5'). It should also load the optimizer if you save it with model.save() though.","Q_Score":5,"Tags":"python,tensorflow,machine-learning,keras","A_Id":56416556,"CreationDate":"2019-06-02T11:32:00.000","Title":"Keras How To Resume Training With Adam Optimizer","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"VSCode was working perfectly a few days ago before this started happening. Attempting to run any python code through VSCode (with or without debugging) Results in this error in the terminal\ncan't open file '\"c:\/Users\/Rastus22\/.vscode\/extensions\/ms-python.python-2019.5.17517\/pythonFiles\/ptvsd_launcher.py\"': [Errno 22] Invalid argument\nA little after the error shows I get a message telling me there was a timeout waiting for the debugger. There aren't any errors in the python itself, currently testing with a file that contains only a print statement. My only other extension is the Darkula theme.\nI've tried reinstalling the Python extension and resetting the launch.json file as well as my settings.json file. I've also tried copying over a known good copy of launch and settings file from a different machine and had no luck.\nI can't really seem to find anyone else online with the same issue either.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4485,"Q_Id":56414957,"Users Score":6,"Answer":"Downgrading to the 2019.4 fixed the issue completely. Thanks to Samuel Cooper for this answer.\nSteps to downgrade:\n\nMake sure the Python extension is installed.\nHit the \"manage\" button on the extension.\n\"Install another version\"\nSearch for the version you want to move to. I downgraded to version 2019.4.12954","Q_Score":2,"Tags":"visual-studio-code,vscode-debugger,vscode-python","A_Id":56419751,"CreationDate":"2019-06-02T12:20:00.000","Title":"Can't run python code through VS Code. Can't open file ptvsd_launcher.py [Errno 22] Invalid Argument","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I finished writing a Django application and now I want to deploy it,\nI have a Windows server and have successfully installed Python and Django on it,\nNow my app runs on localhost on my windows server,\nNow I want to make the site public, meaning that anyone who goes to the IP address of my windows server can browse my site,\nIs there a simple way to do this without using IIS?\nthank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":735,"Q_Id":56416878,"Users Score":0,"Answer":"I've never done what your planing but if you plan to host just one domain then localhost(127.0.0.1) will work just fine but if you plane to host multiple domain you will need to find a way to resolve the right domain to the right site.\nPorts to open on both router and Win Server\n80 for HTTP\n465 for HTTPS\nMake sure that you have a Static IP provided by your ISP, you will also need to make sure that your ISP does not Block port 80 if they do ask them to unblock.\nIf you don't have a static IP or ISP don't allow you to open port 80 then you can use DynDNS to forward traffic to your server, but this option is not the best.\nYour Server will also need a static IP to the server as mentiond by Legorooj","Q_Score":2,"Tags":"python,django,deployment,windows-server","A_Id":56417117,"CreationDate":"2019-06-02T16:30:00.000","Title":"deploying my django site to windows server without using IIS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Ist it possible to formulate a min-max-optimization problem of the following form in pyomo:\nmin(max(g_m(x)) s.t. L\nwhere g_m are nonlinear functions (actually constrains of another model) and L is a set of linear constrains?\nHow would I create the expression for the objective function of the model?\nThe problem is that using max() on a list of constraint-objects returns only the constraint possessesing the maximum value at a given point.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":966,"Q_Id":56416916,"Users Score":0,"Answer":"I think yes, but unless you find a clever way to reformulate your model, it might not be very efficent. \nYou could solve all possiblity of max(g_m(x)), then select the solution with the lowest objective function value. \nI fear that the max operation is not something you can add to a minimization model, since it is not a mathematical operation, but a solver operation. This operation is on the problems level. Keep in mind that when solving a model, Pyomo requires as argument only one sense of optimization (min or max), thus making it unable to understand min-max sense. Even if it did, how could it knows what to maximize or minimize? This is why I suggest you to break your problem in two, unless you work on its formulation.","Q_Score":0,"Tags":"python,pyomo","A_Id":56464549,"CreationDate":"2019-06-02T16:35:00.000","Title":"Is it possible to model a min-max-problem using pyomo","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The inputs to Dijkstra's algorithm are a directed and weighted graph, generally represented by an adjacency (distance) matrix and a start node.\nI have two different distance matrices to be used as inputs, representing two different infrastructure (e.g., roads and cycle ways). Any ideas how modify Dijkstra's algorithm to be use these two inputs? I want to implement in Python. \nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":130,"Q_Id":56418597,"Users Score":0,"Answer":"Does your requirement have a function through which the both matrices are related \nIf yes then on the basis of that function find a new weight matrix. Use this matrix on the flow path\nIf no, then try running matrix one first and then two and vice-versa and choose the one with corresponding cost output to your requirement","Q_Score":0,"Tags":"python,algorithm,routing,navigation,dijkstra","A_Id":56421074,"CreationDate":"2019-06-02T20:10:00.000","Title":"Multiple inputs for Dijkstra's algorithm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create an exe that can be deployed onto other computers. The program needs to be able to read pdf's and turn them into images, but I don't want other users to have to download dependencies. \nMy understanding is that py2image and wand both require external dependencies that, if you convert to a exe, other users would also need to download the dependencies themselves. \nAre there other options available\/ workarounds ?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2183,"Q_Id":56418948,"Users Score":0,"Answer":"I got the same problem while trying to make .exe file with pyqt5 and pdf2file modules, using pyinstaller.\nIf you need to add GUI created in PyQt5, do not add --windowed in pyinstaller command. That was ruining my work for 2days","Q_Score":3,"Tags":"python,pdf,pyinstaller,wand","A_Id":63339898,"CreationDate":"2019-06-02T21:04:00.000","Title":"Converting PDF to Image without non-python dependencies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Jupyter notebook script that will be used to teach others how to use python. \nInstead of asking each participant to install the required packages, I would like to provide a folder with the environment ready from the start.\nHow can I do this?\nWhat is the easiest way to teach python without running into technical problems with packages\/environments etc.?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1280,"Q_Id":56420000,"Users Score":2,"Answer":"The easiest way I have found to package python files is to use pyinstaller which packages your python file into an executable file. \nIf it's a single file I usually run pyinstaller main.py --onefile\nAnother option is to have a requirements file\nThis reduces installing all packages to one command pip install -r requirements.txt","Q_Score":0,"Tags":"python,jupyter-notebook,package,environment-variables,virtual-environment","A_Id":56420070,"CreationDate":"2019-06-03T00:39:00.000","Title":"Run python script from another computer without installing packages\/setting up environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Jupyter notebook script that will be used to teach others how to use python. \nInstead of asking each participant to install the required packages, I would like to provide a folder with the environment ready from the start.\nHow can I do this?\nWhat is the easiest way to teach python without running into technical problems with packages\/environments etc.?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1280,"Q_Id":56420000,"Users Score":2,"Answer":"You would need to use a program such as py2exe, pyinstaller, or cx_freeze to package each the file, the modules, and a lightweight interpreter. The result will be an executable which does not require the user to have any modules or even python installed to access it; however, because of the built-in interpreter, it can get quite large (which is why Python is not commonly used to make executables).","Q_Score":0,"Tags":"python,jupyter-notebook,package,environment-variables,virtual-environment","A_Id":56420227,"CreationDate":"2019-06-03T00:39:00.000","Title":"Run python script from another computer without installing packages\/setting up environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to redirect mysite.com\/index.php to  mysite.com\/clientarea.php using .htaccess does not work for me help out.\nwith simple code.\nI have tried several time and finally the site is not available  \n\nTry running Windows Network Diagnostics.\n  DNS_PROBE_FINISHED_NXDOMAIN","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":56420275,"Users Score":0,"Answer":"Based on that error, it appears you're redirecting to a different hostname than mysite.com - I assume unintentionally.  \nIf you can post your .htaccess code, the solution may be easy to provide.","Q_Score":0,"Tags":"django,python-3.x,.htaccess,whmcs","A_Id":56420311,"CreationDate":"2019-06-03T01:49:00.000","Title":"How Can i redirect url to another url with the .htaccess in cpanel","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":"Appium is not finding element with MobileBy Accessibility ID and I'm calling the method from AppiumDriver class that inherits from the SeleniumDriver class. Any ideas? Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":151,"Q_Id":56421105,"Users Score":0,"Answer":"It ended up being, I had to use MobileBy.ID not MobileBy.Accessibility_ID and the element was found. The framework code was not an issue. Just using wrong locator type.","Q_Score":0,"Tags":"python,automation,appium","A_Id":56429709,"CreationDate":"2019-06-03T04:21:00.000","Title":"Appium is not finding element when using a method to find it from a python appium class that inherits from a selenium class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I developed an ML model which requires two arguments, which are the path of the two files used by the model function. The task at hand requires a web page which could take those arguments for the model and deliver it to the function. \nThe job could also be done using Tkinter in python for developing a GUI Frame, but my situation requires a web page for further development.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":175,"Q_Id":56422270,"Users Score":1,"Answer":"You could use flask, pyramid, or django to make a web-app that will call your ML function.It doesent have to be hosted on a server you can run it locally on your computer.\nWhat isn't clear is why in your particular case you can't use Tkinter. Is your webpage suppose to be accesed by someone else ? From outside you local network ? \nThe question isn't verry clear.","Q_Score":0,"Tags":"python,html","A_Id":56422428,"CreationDate":"2019-06-03T06:44:00.000","Title":"How to run a python script from a HTML page without the use of a server? It should serve the purpose of a GUI Frame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Here's what I want to accomplish: I have an 'age' field in my model which I'd like its value to be the time duration up til now - and I mean now as in real time, not just the obj creation time or updated time.\nAt first I was wondering if there's some kind of a dynamic field in django that the field value would just keep updating based on a formula. But then I figured that wasn't realistic, it has to be updated by something at some point in time.\nRight now what comes on my mind is to write a model method to calculate the value and assign it to the field, and to manually calls it and write the new value to the field everytime before the query of the class objects.\nI wonder is there any better way to accomplish this since my method will add some loading to the database which might just be unnecessary.\nThanks for your help.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":63,"Q_Id":56422938,"Users Score":3,"Answer":"You never write things like this to a database, instead you store the date of birth \/ origin and then work out the age as when its needed.\nThe extra time involved in this calculation is so minimal that it will most likely never be the performance issue in your code.","Q_Score":1,"Tags":"python,django","A_Id":56423006,"CreationDate":"2019-06-03T07:36:00.000","Title":"What's the best practice to update a field automatically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have two simple lambda functions. Lambda 1 is invoking lambda 2 (both do a simple print for text).\nIf both lambdas are outside of a VPC then the invocation succeeds, however as soon as I set them both in to access a VPC (I need to test within a VPC as the full process will be wtihin a VPC) the invocation times out.\nDo I have to give my lambda access to the internet to be able invoke a second lambda within the same VPC?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":648,"Q_Id":56425420,"Users Score":1,"Answer":"If your lambda functions are inside a VPC you need to configure your both lambda functions into private subnet not public subnet. That is the AWS recommended way.","Q_Score":0,"Tags":"python,python-3.x,aws-lambda","A_Id":56448070,"CreationDate":"2019-06-03T10:27:00.000","Title":"Unable to invoke second lambda within VPC - Python AWS Lamba Function","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\u2019m trying to run some robot framework tests in eclipse. I have Python, PyDev, Robot Framework (and all other things which I need) already installed, but it comes always the same error message \"Parsing failed: Unsupported file format 'py'\". Does anyone know where the problem may lie? Thank you in advance!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1138,"Q_Id":56426637,"Users Score":2,"Answer":"You will get this exact error if you tell robot to run a file as if it was a test case (e.g. robot something.py). The solution is pretty simple: don't pass a .py file as an argument to robot.","Q_Score":0,"Tags":"python,eclipse,robotframework,pydev","A_Id":56428824,"CreationDate":"2019-06-03T11:44:00.000","Title":"Parsing failed: Unsupported file format 'py'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to install pyautogui, openpyxl with Python in a machine which does not connect to internet. Is there a distribution package of python which can do this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":349,"Q_Id":56427184,"Users Score":0,"Answer":"Following steps worked for me successfully -\n\nDowload Anconda 3 package in a system where internet connection is there.\nDownload pyautogui.tar.bz2 using \"pip download pytuatogui\".\nCopy both to a system where internet connection is not there.\nInstall Anacoda 3 manually.\nInstall the pyuaotgui.tar.bz2 using command \n\"conda install \/path\/to\/local\/file\/.tar.bz2 \n\nThen things started working properly in a system where internet connection was not possible.","Q_Score":1,"Tags":"python,pyautogui","A_Id":56790886,"CreationDate":"2019-06-03T12:15:00.000","Title":"distribution package for pyautogui and openpyxl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to figure out the logic for processing multiple files in S3 at once as files are added randomly.  For discussion sake here's an example:\n\nFiles are added randomly to S3 bucket; an by bursty or at random intervals\nLambda function is triggered once 9 files are in the S3 bucket; the lambda function post processes or combines these files together.\nOnce processed, the files will be moved to another bucket or deleted.\n\nHere's what I've tried:\n\nI have S3 triggers for all S3 puts\nIn my lambda function I ignore the filename itself and list the S3 bucket based on the key to count how many files exist\nproblem is when traffic is bursty or arrives steady but at a rapid pace it is difficult to identify unique groups of 9 files\nI have uuid prefixes on file names for performance reasons so sequential filenames don't exist.\nI've considered writing meta data to a nosql db but haven't gone down that route yet.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4988,"Q_Id":56437033,"Users Score":1,"Answer":"One possible solution is to use a scheduled lambda (can be as often or as sparse as you want based on your traffic) that pulls events from a SQS queue populated by S3 put events. The assumes that you're focused on batch processing n files at a time and the order does not matter (given the uuid naming). \nTo create this workflow would be something like this:\n\nCreate SQS queue for holding S3 PUT events\nAdd trigger to S3 bucket on PUTs to create event in SQS queue from 1.\nCreate Lambda with env variables (for bucket and queue)\n\n\nThe lambda should check the queue if there are any in-flight messages and use just the bucket\nIf there are, stop run (to prevent a file from being processed multiple times)\nIf no in-flight messages, list objects from S3 with limit of n (your batch size)\nRun your process logic if enough objects are returned (could be less than n) \nDelete files\n\nCreate CloudWatch rule for running lambda every n seconds\/minutes\/hours\n\nSome other things to keep in mind based on your situation's specifics:\n\nIf there are a lot of files rapidly being sent and n is significantly small, single-tracking processing (step 3.2 would result in long processing times). This also depends on the length of processing time, whether data can be processed multiple times, etc...\nListObjectsV2 could return less than the MaxKeys parameter, if this is an issue, could have a larger MaxKeys and just process the first n.","Q_Score":2,"Tags":"python-3.x,aws-lambda,amazon-sqs","A_Id":56439707,"CreationDate":"2019-06-04T03:38:00.000","Title":"Execute lambda function for multiple files in S3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to figure out the logic for processing multiple files in S3 at once as files are added randomly.  For discussion sake here's an example:\n\nFiles are added randomly to S3 bucket; an by bursty or at random intervals\nLambda function is triggered once 9 files are in the S3 bucket; the lambda function post processes or combines these files together.\nOnce processed, the files will be moved to another bucket or deleted.\n\nHere's what I've tried:\n\nI have S3 triggers for all S3 puts\nIn my lambda function I ignore the filename itself and list the S3 bucket based on the key to count how many files exist\nproblem is when traffic is bursty or arrives steady but at a rapid pace it is difficult to identify unique groups of 9 files\nI have uuid prefixes on file names for performance reasons so sequential filenames don't exist.\nI've considered writing meta data to a nosql db but haven't gone down that route yet.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4988,"Q_Id":56437033,"Users Score":0,"Answer":"You could also think of using the step function that triggers lambda\/glue job to copy the files further to Redshift\/s3, introduce some file counts logic (assuming fix number of files are arriving)\/a wait time (e.g., 30 minutes assuming all files have landed). This is not the perfect solution, but if you fix the flow of files, it may work perfectly fine.","Q_Score":2,"Tags":"python-3.x,aws-lambda,amazon-sqs","A_Id":66265134,"CreationDate":"2019-06-04T03:38:00.000","Title":"Execute lambda function for multiple files in S3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have images in a sub-folder. Let's the folder images\nI have a python program which will take image arguments from the folder one by one, the images are named in sequential order (1.jpg , 2.jpg, 3.jpg and so on).\nThe call to the program is : python prog.py 1.jpg\nWhat will be a shell script to automate this ?\nPlease ask for any additional information.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":56438069,"Users Score":1,"Answer":"Try this from the folder that contains images\/:\nfor i in images\/*.jpg; do\n  python prog.py $i\ndone","Q_Score":0,"Tags":"python,python-3.x,shell","A_Id":56438141,"CreationDate":"2019-06-04T05:56:00.000","Title":"Shell script to call python program with changing arguments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to use the variable explorer in PyCharm.\nI click on python console and I have a window for the variables.\nHowever, the variables that I created in my code do not appear, only built in variables appear. (Under special variables, there is: builtins and sys)\nWhere can I find the variables that appear in my code?\nThe specific variable I'm looking for is a dictionary called \"data_model\".\nIt is created within the program and filled during runtime.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1642,"Q_Id":56439521,"Users Score":0,"Answer":"You can run the code in python console and then you will be able to see all the variables (along side builtin variables). By default it will only show builtin and sys variables and as you run the code in python console, it will show the variables.\nThe dictionary view is not great I think but in pandas dataframe you will be able to right click on variable and click on 'view as a dataframe' which puts the dataframe in a new window.","Q_Score":0,"Tags":"python,pycharm","A_Id":60459655,"CreationDate":"2019-06-04T07:49:00.000","Title":"How to find the variables I created in Pycharm variable explorer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why is my pipenv stuck in the \"Locking...\" stage when installing [numpy|opencv|pandas]? \nWhen running pipenv install pandas or pipenv update it hangs for a really long time with a message and loading screen that says it's still locking. Why? What do I need to do?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":24826,"Q_Id":56440090,"Users Score":1,"Answer":"try doing pipenv --rm - removes virtual environment\nthen pipenv shell - this will again initiate virtual env\nthen pipenv install installs all the packages again\nworked for me","Q_Score":38,"Tags":"python,pip,pipenv","A_Id":62840501,"CreationDate":"2019-06-04T08:28:00.000","Title":"Pipenv stuck \"\u280b Locking...\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why is my pipenv stuck in the \"Locking...\" stage when installing [numpy|opencv|pandas]? \nWhen running pipenv install pandas or pipenv update it hangs for a really long time with a message and loading screen that says it's still locking. Why? What do I need to do?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":24826,"Q_Id":56440090,"Users Score":1,"Answer":"I had this happen to me just now. Pipenv got stuck locking forever, 20+ minutes with no end in sight, and pipenv --rm didn't help.\nIn the end, the problem was that I had run pipenv install \"boto3~=1.21.14\" to upgrade boto3 from boto3 = \"==1.17.105\". But I had other conflicting requirements (in my case, botocore = \"==1.20.105\" and s3transfer = \"==0.4.2\") which are boto3 dependencies. The new version of boto3 required newer versions of these two packages, but the == requirements didn't allow that. Pipenv didn't explain this, and just spun \"Locking\u2026\" forever.\nSo if you run into this, I would advise you to carefully look at your Pipenv packages, see if there are any obvious conflicts, and loosen or remove package requirements where possible.\nIn my case, I was able to just remove the s3transfer and botocore packages from the list entirely, and rely on boto3 to fetch the necessary versions.","Q_Score":38,"Tags":"python,pip,pipenv","A_Id":71402278,"CreationDate":"2019-06-04T08:28:00.000","Title":"Pipenv stuck \"\u280b Locking...\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use python-gitlab projects.files.create to upload a string content to gitlab.\nThe string contains '\\n' which I'd like it to be the real newline char in the gitlab file, but it'd just write '\\n' as a string to the file, so after uploading, the file just contains one line.\nI'm not sure how and at what point should I fix this, I'd like the file content to be as if I print the string using print() in python.\nThanks for your help.\nEDIT---\nSorry, I'm using python 3.7 and the string is actually a csv content, so it's basically like:\n',col1,col2\\n1,data1,data2\\n'\nSo when I upload it the gitlab file I want it to be:\n,col1,col2\n1,data1,data2","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":56442415,"Users Score":0,"Answer":"I figured out by saving the string to a file and read it again, this way the \\n in the string will be translated to the actual newline char.\nI'm not sure if there's other of doing this but just for someone that encounters a similar situation.","Q_Score":0,"Tags":"python,gitlab","A_Id":56462585,"CreationDate":"2019-06-04T10:52:00.000","Title":"how to use python-gitlab to upload file with newline?","Data Science and Machine Learning":0,"Database and SQL":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 and i want to make a single .exe file for windows.\nand run it in the background that's mean do not display shell.\ni use :\npyinstaller --onefile script.py\nbut shell displaying...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":360,"Q_Id":56443307,"Users Score":0,"Answer":"If your main aim is to make the file run in the background (i.e. without displaying the shell), then you can simply rename the python file to a .pyw file, and run it, meaning your file becomes script.pyw. You can also use the same pyinstaller command on the script.pyw file","Q_Score":0,"Tags":"python,python-3.x","A_Id":56444214,"CreationDate":"2019-06-04T11:49:00.000","Title":"How to compile python script to standalone executable windows file that could open without shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've upgrade my tensorflow and keras with this code:\n!pip install tf-nightly-gpu-2.0-preview\nNow every epoch of model learning cost 22 min which was 17 sec before this upgrade!!!\nI did downgrade tensorflo and keras but it did not help!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1597,"Q_Id":56443694,"Users Score":0,"Answer":"You can reset your backend using the Runtime -> Reset all runtimes... menu item. (This is much faster than kill -9 -1, which will take some time to reconnect.)","Q_Score":0,"Tags":"python,tensorflow,keras,google-colaboratory","A_Id":56446962,"CreationDate":"2019-06-04T12:14:00.000","Title":"google colab GPU processing become very slow after keras and tensorflow upgrade","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating GUI using python tkinter to visualize Road Scenarios (the main vehicle & close by vehicles). I draw in the canvas lines to give road top view (as the Picture below).\nThe user can insert a rectangle (vehicle) then move it freely on the canvas.\nWhat I want is: after the user moves the rectangle to where ever he wants, the y coordination of the rectangle will relocate to the nearest lane, to have a nice looking png at the end.\nMy thought about it:\n\nDivide the canvas to regions (each Region represent a lane)\nCreate a function which knows when the rectangle finished moving, then modify the y coordination of it to the nearest Region (lane).\n\nNot sure how to apply this in Code though. Any useful canvas functions or another approach are much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":56447346,"Users Score":0,"Answer":"The approach I mentioned at the question worked for me.\n\nA list identifing the y-axis sides of each Region was created.\nAfter creating the items needed, they all share a common Tag.\nChoose which part of the items you want to consider the original Point (which will be used later as the item's current location). Canvas.bboc(CURRENT) can be sufficient to do that.\nDetect when does the item enter a Region, by comparing if the item's current Location is within the boundaries of a Region.\nUse Canvas.coords() or Cancas.move() methods to move the items at the middle of the regoin they have entered.","Q_Score":0,"Tags":"python,tkinter,tkinter-canvas","A_Id":56496502,"CreationDate":"2019-06-04T15:51:00.000","Title":"Dividing canvas to regions, then attracting nearby items to the nearest region?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to install Django 2.2.2 on my MacBook pro (latest generation), and I am a user of python 3x.  However, my default version of python is python 2x and I cannot pip install Django version 2x when I am using python 2x.  Could anyone explain how to change the default version of python on MacBook I have looked at many other questions on this site and none have worked.  All help is appreciated thank you :)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":56448721,"Users Score":0,"Answer":"You can simply use pip3 instead of pip to install Python 3 packages.","Q_Score":0,"Tags":"python,django,bash,macos,pip","A_Id":56448819,"CreationDate":"2019-06-04T17:28:00.000","Title":"How do you install Django 2x on pip when python 2x is your default version of python but you use python 3x on Bash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Need to query HSM (in Python) using known values HSM \"slot #\", \"key label\" to obtain (unknown value) \"key handle\". \nAny suggestions?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":278,"Q_Id":56451192,"Users Score":0,"Answer":"You put me on the right track. I ended up using c_find_objects_ex to grab the key handle and used slice to chop off the trailing \"L\" in the output. Thanks!","Q_Score":0,"Tags":"python,pkcs#11,hsm,cryptoki","A_Id":56546575,"CreationDate":"2019-06-04T20:51:00.000","Title":"How to query HSM slot for value \"key handle\" using (known) value \"key label\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Wagtail includes a \"settings\" menu item by default, with some default settings items, such as \"sites\" and \"redirects\".\nI know that you can register a new setting with the register_setting decorator, and that various hooks are available for customizing the top level menu items, but not sub-menu items. How can I REMOVE (or hide the display of) the default settings items?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":644,"Q_Id":56452060,"Users Score":2,"Answer":"Create a Wagtail group (Groups under the Settings menu).  When assigning object permissions for the group, make sure Site Settings is not selected.  Then assign to the group the Users who you do not want to be able to see the Site Settings menu, and it will not show up for them.","Q_Score":1,"Tags":"python,django,wagtail","A_Id":56453098,"CreationDate":"2019-06-04T22:22:00.000","Title":"Wagtail - How To Remove Sub-Menu Items From Settings Menu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I got confused with how to source activate the correct venv.\nI used to use pip v10. I have a working venv called \"base_py36\" and I could source activate base_py36 with everything OK.\nRecently I upgraded pip to pip v19. Now when I run source activate base_py36, it goes into the venv but all my installed packages are gone. \nPS: when I searched the venv directory, I found that under \/anaconda3\/envs\/base_py36\/lib I have both python3.6 and python3.7 with different packages. So could this be the reason? (I cannot remember when I installed python 3.7). If so how could I source activate base_py36 with python 3.6?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":56456049,"Users Score":0,"Answer":"I'm going to assume you mean \"with python 3.7\" at the end. \nBut yes, that is the most likely cuplrit. For a quick, albeit lazy, workaround, you can just copy the modules from Python 3.6 to Python 3.7. Since there is so little difference between the two, they're guaranteed to be forward compatible, at least for now. \nAlso, if that doesn't work, could you activate the virtual environment, and tell us what version of python it's running?","Q_Score":0,"Tags":"python,pip,python-venv","A_Id":56456093,"CreationDate":"2019-06-05T07:35:00.000","Title":"problem with newly installed pip (or maybe with python 3.7 as well)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I understand that in scipy.integrate.trapz(y, x=None, dx=1.0, axis=-1) or simps, the min and max values of x (if specified) are taken to be the limits of the integral, but what happens when x=None? It has dx to figure out the spacing in the x values but at what value does it start x? \nI tried it with and without x, from which I understand that it starts x values from 0.0 when x is not specified.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":608,"Q_Id":56456248,"Users Score":0,"Answer":"but at what value does it start x\n\nIt doesn't matter for integration. You just specify the values of y and tell scipy how far the xs are apart. Whether they start at -5 or +26 doesn't influence the value of the integral.","Q_Score":0,"Tags":"python,python-3.x,scipy,numerical-integration","A_Id":56461379,"CreationDate":"2019-06-05T07:50:00.000","Title":"How to specify integration limits in scipy.integrate.trapz or simps?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a difference between the parallelization that takes place between these two options? I\u2019m assuming num_workers is solely concerned with the parallelizing the data loading. But is setting torch.set_num_threads for training in general? Trying to understand the difference between these options. Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1236,"Q_Id":56463317,"Users Score":2,"Answer":"The num_workers for the DataLoader specifies how many parallel workers to use to load the data and run all the transformations. If you are loading large images or have expensive transformations then you can be in situation where GPU is fast to process your data and your DataLoader is too slow to continuously feed the GPU. In that case setting higher number of workers helps. I typically increase this number until my epoch step is fast enough. Also, a side tip: if you are using docker, usually you want to set shm to 1X to 2X number of workers in GB for large dataset like ImageNet.\nThe torch.set_num_threads specifies how many threads to use for parallelizing CPU-bound tensor operations. If you are using GPU for most of your tensor operations then this setting doesn't matter too much. However, if you have tensors that you keep on cpu and you are doing lot of operations on them then you might benefit from setting this. Pytorch docs, unfortunately, don't specify which operations will benefit from this so see your CPU utilization and adjust this number until you can max it out.","Q_Score":3,"Tags":"python,machine-learning,pytorch","A_Id":61623908,"CreationDate":"2019-06-05T15:11:00.000","Title":"DataLoader num_workers vs torch.set_num_threads","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am researching a way to send out a PWM-ed IR pulse from an xBee3 device. I couldn't find any IR related libs, so I guess I'll have to \"brute\" force it by \"waiting\" X many microseconds and setting digital I\/O pins ON and OFF. \nAny ideas\/pointers\/references would be much appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":56464137,"Users Score":0,"Answer":"MicroPython on the XBee3 RF products won't be capable of the microsecond timing you're looking for, and the PWM output only allows for setting the duty cycle, not the frequency.\nYou would need to add extra hardware to convert (for example) the I2C interface to IR transmission.  The XBee3 RF products don't support a secondary UART like the XBee Cellular products do, but if they add that feature you would could have a UART->IR interface via a secondary microprocessor.","Q_Score":0,"Tags":"xbee,pwm,infrared,micropython,transmission","A_Id":56483498,"CreationDate":"2019-06-05T15:59:00.000","Title":"How can one achieve an arbitrary frequency and duty cycle PWM-ed IR transmission in an xBee3 using 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 looking for an example of using python multiprocessing (i.e. a process-pool\/threadpool, job queue etc.) with hylang.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":56465109,"Users Score":0,"Answer":"Note that a straightforward translation runs into a problem on macOS (which is not officially supported, but mostly works anyway): Hy sets sys.executable to the Hy interpreter, and multiprocessing relies on that value to start up new processes. You can work around that particular problem by calling (multiprocessing.set_executable hy.sys_executable), but then it will fail to parse the file containing the Hy code itself, which it does again for some reason in the child process. So there doesn't seem to be a good solution for using multiprocessing with Hy running natively on a Mac.\nWhich is why we have Docker, I suppose.","Q_Score":0,"Tags":"multiprocessing,python-multiprocessing,hy","A_Id":68931008,"CreationDate":"2019-06-05T17:11:00.000","Title":"Example of using hylang with python multiprocessing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As described in Keras documentation, the verbose=1 asks the keras to print out results in a progress bar. But sometimes keras prints out the results of every batch, which makes a very messy printout report (see below). I wonder why is that? I mean, the only setup is the parameter of verbose, isn't it?\nMy code is simple:\n\nhistory = model.fit(X_shuffle, y_scores_one_hot, \n                      validation_split=0.2, verbose = 1,\n                      epochs = 100, batch_size = 50) \n\nWrong printout:\n\nEpoch 1\/100\n  5750\/8107 [====================>.........] - ETA: 5:03 - loss: 1.3690 - acc: 0.520 - ETA: 1:42 - loss: 1.3600 - acc: 0.533 - ETA: 1:02 - loss: 1.3994 - acc: 0.500 - ETA: 39s - loss: 1.4173 - acc: 0.482 - ETA: 29s - loss: 1.4189 - acc: 0.47 - ETA: 23s - loss: 1.4320 - acc: 0.46 - ETA: 19s - loss: 1.4432 - acc: 0.46 - ETA: 16s - loss: 1.4373 - acc: 0.46 - ETA: 14s - loss: 1.4318 - acc: 0.46 - ETA: 12s - loss: 1.4322 - acc: 0.46 - ETA: 11s - loss: 1.4314 - acc: 0.46 - ETA: 10s - loss: 1.4342 - acc: 0.46 - ETA: 10s - loss: 1.4386 - acc: 0.45 - ETA: 9s - loss: 1.4399 - acc: 0.4557 - ETA: 8s - loss: 1.4373 - acc: 0.458 - ETA: 7s - loss: 1.4418 - acc: 0.453 - ETA: 7s - loss: 1.4419 - acc: 0.454 - ETA: 6s - loss: 1.4435 - acc: 0.453 - ETA: 6s - loss: 1.4421 - acc: 0.453 - ETA: 6s - loss: 1.4439 - acc: 0.451 - ETA: 5s - loss: 1.4437 - acc: 0.452 - ETA: 5s - loss: 1.4388 - acc: 0.456 - ETA: 5s - loss: 1.4430 - acc: 0.453 - ETA: 4s - loss: 1.4440 - acc: 0.452 - ETA: 4s - loss: 1.4428 - acc: 0.452 - ETA: 4s - loss: 1.4469 - acc: 0.449 - ETA: 4s - loss: 1.4471 - acc: 0.450 - ETA: 3s - loss: 1.4517 - acc: 0.445 - ETA: 3s - loss: 1.4489\n\nI expected something like:\n\nEpoch 1\/100\n  3009\/3009 [==============================] - 30s 10ms\/step - loss: 1.5875 - acc: 0.2795 - val_loss: 1.5542 - val_acc: 0.4130\nEpoch 2\/100\n  3009\/3009 [==============================] - 27s 9ms\/step - loss: 1.5049 - acc: 0.4403 - val_loss: 1.4963 - val_acc: 0.4130","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":738,"Q_Id":56467912,"Users Score":0,"Answer":"That looks like an interaction with a notebook\/kernel environment.\nYou may prefer the results if you change verbose=1 to verbose=2.","Q_Score":2,"Tags":"python,keras","A_Id":56469920,"CreationDate":"2019-06-05T20:58:00.000","Title":"Keras prints out result of every batch in a single epoch, why is that?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to package Python itself into virtualenv? Is this even possible? \nI'm trying to run python on a machine which it is not installed on, and I thought virtualenv made this possible. It activates, but can't run any Python.","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":57,"Q_Id":56468695,"Users Score":-1,"Answer":"You might need to install python in some location you have the permissions to do so.","Q_Score":0,"Tags":"python,virtualenv","A_Id":56468719,"CreationDate":"2019-06-05T22:09:00.000","Title":"How to package python into virtualenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to package Python itself into virtualenv? Is this even possible? \nI'm trying to run python on a machine which it is not installed on, and I thought virtualenv made this possible. It activates, but can't run any Python.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":57,"Q_Id":56468695,"Users Score":1,"Answer":"virtualenv makes it convenient to use multiple python versions in different projects on the same machine, and isolate the pip install libraries installed by each project. It doesn\u2019t install or manage the overall python environment. Python must be installed on the machine before you can install or configure the virtualenv tool itself or switch into a virtual environment.\nSide note, consider using virtualenvwrapper \u2014 great helper for virtualenv.","Q_Score":0,"Tags":"python,virtualenv","A_Id":56469455,"CreationDate":"2019-06-05T22:09:00.000","Title":"How to package python into virtualenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an .stl file and I want to write a python script to scale if. So for example, if I have a file with a cube of dimensions 2x2x2mm, and I have my scale set to 10, the script should spit out an stl file with a cube of dimensions 20x20x20mm. \nI searched and found numpy-stl library for modifying stl files. However, I can't seem to find any function that scales an .stl. Can someone point me in the right direction as what to use?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":463,"Q_Id":56468947,"Users Score":0,"Answer":"I know this is an old question, but you should be able to directly modify the mesh.x, mesh.y and mesh.z attributes to accomplish this.","Q_Score":2,"Tags":"python,numpy-stl","A_Id":72231712,"CreationDate":"2019-06-05T22:41:00.000","Title":"Scale an .stl file using python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an .stl file and I want to write a python script to scale if. So for example, if I have a file with a cube of dimensions 2x2x2mm, and I have my scale set to 10, the script should spit out an stl file with a cube of dimensions 20x20x20mm. \nI searched and found numpy-stl library for modifying stl files. However, I can't seem to find any function that scales an .stl. Can someone point me in the right direction as what to use?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":463,"Q_Id":56468947,"Users Score":1,"Answer":"I also stumbled across this post while trying to get an answer to the same problem. I assume you are using numpy-stl.\nMy solution was to create a rotation matrix R using the scaling parameter instead of rotation angles and then use mesh.rotate_using_matrix(R,point=centroid).\nSeems to work for me.","Q_Score":2,"Tags":"python,numpy-stl","A_Id":72267291,"CreationDate":"2019-06-05T22:41:00.000","Title":"Scale an .stl file using python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a program that can read and store the data from a qr scanning device but i don't know how to get the input from the barcode scanner as an image or save it in a variable to read it after with openCV","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":601,"Q_Id":56469264,"Users Score":0,"Answer":"Typically a barcode scanner automatically outputs to the screen, just like a keyboard (except really quickly), and there is an end of line character at the end (like and enter). \nUsing a python script all you need to do is start the script, connect a scanner, scan something, and get the input (STDIN) of the script. If you built a script that was just always receiving input and storing or processing them, you could do whatever you please with the data. \nA QR code is read in the same way that a barcode scanner works, immediately outputting the encoded data as text. Just collect this using the STDIN of a python script and you're good to go!","Q_Score":0,"Tags":"python,input,qr-code,barcode-scanner","A_Id":56469292,"CreationDate":"2019-06-05T23:27:00.000","Title":"How to use python with qr scanner devices?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running the same stochastic program 100,000 times using:\nLoop 100000\nNone of the data is stored after each loop\nAfter about 30,000 loops the program freezes, I assume through lack of memory. Is there anything I can put at the start of each loop to clean memory?\nI am running a Python program using Ubuntu on a Dell laptop.\nThanks in advance\nat the start of each loop all files are cleared, such as:\ndel resistance[:]","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":56470154,"Users Score":0,"Answer":"Thanks everyone. I tried installing psutil, it installed in Unix but when I went to run it in Python it said psutil was not installed. Other people seem to get the same problem. I am running with gc.collect() and waiting to see what happens.\nA question for silver. Why does Python keep allocating storage when I run del resistance[ : ]? as in:\nLoops = 30000\nfor i range(Loops):\n   del resistance[ : ];\n     for j in range(15):\n       resistance[] = some_function;","Q_Score":0,"Tags":"python,loops,ubuntu","A_Id":56505828,"CreationDate":"2019-06-06T02:16:00.000","Title":"Looping program freezes due to memory running out","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running the same stochastic program 100,000 times using:\nLoop 100000\nNone of the data is stored after each loop\nAfter about 30,000 loops the program freezes, I assume through lack of memory. Is there anything I can put at the start of each loop to clean memory?\nI am running a Python program using Ubuntu on a Dell laptop.\nThanks in advance\nat the start of each loop all files are cleared, such as:\ndel resistance[:]","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":56470154,"Users Score":0,"Answer":"I don't know if this will help you specifically, but it is good for freeing up memory.  Try importing gc and call gc.collect() right before and\/or inside of the for loop.","Q_Score":0,"Tags":"python,loops,ubuntu","A_Id":56470573,"CreationDate":"2019-06-06T02:16:00.000","Title":"Looping program freezes due to memory running out","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know briefly about all the available estimators like logisticregression or multinomial regression or SVMs which can be used for classification problems.\nThese are the three I know. Are there any others like these? and relatively how long they run or how accurate can they get than these?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":26,"Q_Id":56471908,"Users Score":1,"Answer":"The following can be used for classification problems:\n\nLogistic Regression\nSVM\nRandomForest Classifier\nNeural Networks","Q_Score":0,"Tags":"python-3.x,scikit-learn","A_Id":56472750,"CreationDate":"2019-06-06T06:24:00.000","Title":"What are the available estimators which we can use as estimator in onevsrest classifier?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u00b4ve solved an optimization problem with PySCipOpt in Python.\nI want to stop running the code when the solution gap is less than 1000.\nHow can I do that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":56472194,"Users Score":0,"Answer":"You can write exit() in the loop.","Q_Score":0,"Tags":"python,neural-network","A_Id":56472251,"CreationDate":"2019-06-06T06:47:00.000","Title":"How to stop a code running in PyScipOpt when it reaches to a specific gap?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to fit a model using keras but I get the following error - \nWARNING:tensorflow:From \/anaconda3\/lib\/python3.7\/site-packages\/tensorflow\/python\/ops\/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.\nInstructions for updating:\nUse tf.cast instead.\nEpoch 1\/100\nclassifier.fit(X_train,y_train,epochs=100,batch_size=10)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":359,"Q_Id":56472233,"Users Score":0,"Answer":"There could be many reasons for the Kernel dying, the most common one I encounter is because I have ran out of memory. \nIf you are training a particularly large model try temporarily reducing it and bringing the batch_size down to 1\n(I don't think the warning message is related - this is just giving advance warning of a future change)","Q_Score":0,"Tags":"python,tensorflow,jupyter","A_Id":56472341,"CreationDate":"2019-06-06T06:51:00.000","Title":"Getting error while trying to fit model - The kernel appears to have died. It will restart automatically","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are there ways to automaticlly apply changes of an API or library that have been made while in parallel there was ongoing development of the consuming part in another branch for example, just as if one would use a rename or signature refactoring operation in common IDEs, which are usually applied automatically to all consuming parts.\nWhat are the usual strategies to handle these cases as automated as possible when no fully automated tool is used to deal with this.\nI'm mainly working with the IntelliJ platform (Pycharm, IDEA), so any possibility directly inside it would be preferred.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":56473012,"Users Score":0,"Answer":"So, as I understand git checkout changes some signatures in the API, and you want IDE to automatically detect the signature change and refactor all its clients in the project? If it is so, it is not possible in the current version. \nThe best way to handle this, I believe, is to change clients along with the API. This can be achieved by having all the clients in the same project or monitoring API usages via some service.","Q_Score":0,"Tags":"java,python,intellij-idea,version-control,automated-refactoring","A_Id":56942296,"CreationDate":"2019-06-06T07:45:00.000","Title":"Applying API changes after checkout from VCS as refactorings (preferably inside the IntelliJ platform)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a form in Django using Django form. \nI need two types of forms.\n\nA form that collect data from user, do some calculations and show the results to user without saving the data to database. I want to show the result to user once he\/she press button (calculate) next to it not in different page. \nA form that collect data from user, look for it in a column in google sheet, and if it's unique, add it to the column otherwise inform the user a warning that the data is not unique.\n\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":56473174,"Users Score":0,"Answer":"You could use AJAX and javascript to achieve this, but I suggest doing this only via javascript. This means you will have to rewrite the math in JS and output it directly in the element.\nPlease let me know if you need any help :)\nJasper","Q_Score":0,"Tags":"html,django,python-3.x,django-forms","A_Id":56474809,"CreationDate":"2019-06-06T07:55:00.000","Title":"How to use data obtained from a form in Django form?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to create a form in Django using Django form. \nI need two types of forms.\n\nA form that collect data from user, do some calculations and show the results to user without saving the data to database. I want to show the result to user once he\/she press button (calculate) next to it not in different page. \nA form that collect data from user, look for it in a column in google sheet, and if it's unique, add it to the column otherwise inform the user a warning that the data is not unique.\n\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":56473174,"Users Score":0,"Answer":"Start by writing it in a way that the user submits the form (like any normal django form), you process it in your view, do the calculation, and return the same page with the calculated values (render the template). That way you know everything is working as expected, using just Django\/python.\nThen once that works, refactor to make your form submit the data using AJAX and your view to just return the calculation results in JSON. Your AJAX success handler can then insert the results in the current page.\nThe reason I suggest you do this in 2 steps is that you're a beginner with javascript, so if you directly try to build this with AJAX, and you're not getting the results you expect, it's difficult to understand where things go wrong.","Q_Score":0,"Tags":"html,django,python-3.x,django-forms","A_Id":56479353,"CreationDate":"2019-06-06T07:55:00.000","Title":"How to use data obtained from a form in Django form?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How can I synchronise the front-end and back-end to get the data in the real-time than periodically making a request to the back-end API?\nI have been using an angular 7.2 framework at the front-end and python as a back-end. I want a technique so that the changes in the back-end and the database can be listened by the front-end and the browser becomes up to date.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":56473272,"Users Score":0,"Answer":"Use web sockets :  real time communication between web servers and clients is possible with the help of this protocol.","Q_Score":0,"Tags":"python,angular","A_Id":56474506,"CreationDate":"2019-06-06T08:02:00.000","Title":"How to fetch the data using angular 7 from the server (python) in the real-time to keep UI updated?","Data Science and Machine Learning":0,"Database and SQL":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 conv net for image classification.\nThere is something I dont understand theoretically\nFor training I split my data 60%train\/20%validation\/20% test\nI save weight when metric on validation set is the best (I have same performance on training and validation set).\nNow, I do a new split. Some data from training set will be on test set. I load the weight and I classify new test set.\nSince weight have been computed on a part of the new test set, are we agree to says this is a bad procedure and I should retrain my model with my new training\/validation set?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":26,"Q_Id":56473760,"Users Score":2,"Answer":"yes, for fair evaluation no sample in the test set should be seen during training","Q_Score":0,"Tags":"python,machine-learning,keras,conv-neural-network","A_Id":56473975,"CreationDate":"2019-06-06T08:34:00.000","Title":"conv net save weight and new test set","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i'm using conv net for image classification.\nThere is something I dont understand theoretically\nFor training I split my data 60%train\/20%validation\/20% test\nI save weight when metric on validation set is the best (I have same performance on training and validation set).\nNow, I do a new split. Some data from training set will be on test set. I load the weight and I classify new test set.\nSince weight have been computed on a part of the new test set, are we agree to says this is a bad procedure and I should retrain my model with my new training\/validation set?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":26,"Q_Id":56473760,"Users Score":1,"Answer":"The all purpose of having a test set is that the model must never see it until the very last moment.\nSo if your model trained on some of the data in your test set, it becomes useless and the results it will gives you will have no meaning.\nSo basicly:\n\n1.Train on your train set\n2.Validate on your validation set\n3.Repeat 1 and 2 until you are happy with the results\n4.At the very end, finally test your model on the test set","Q_Score":0,"Tags":"python,machine-learning,keras,conv-neural-network","A_Id":56474029,"CreationDate":"2019-06-06T08:34:00.000","Title":"conv net save weight and new test set","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using a C++ DLL with python which makes use of COM objects. \nI'm loading it with cdll.LoadLibray.\nMy application was working fine with python 2.7. Now that I'm moving to Python 3.7 my C++ DLL fails when I call: CoInitializeEx(NULL,COINIT_MULTITHREADED)\n with  error 0x80010106: Cannot change thread mode after it is set. \nBy googling a bit I found some references on sys.coinit_flags = pythoncom.COINIT_MULTITHREADED but this pieces of code does not solve the issue.\nIt seems Python 3 is initializing COM by itself and now I cannot change the COM concurrency model.\nHow can I enable COINIT_MULTITHREADED?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":357,"Q_Id":56473850,"Users Score":0,"Answer":"Ok... for whoever will have this issue, after googling and trying to understand how to get Python 3 not to initialize COM or initialize it for MTA (i.e. COINIT_MULTITHREADED) I gave up and simply put CoUninitialize() in my C++ code just before calling CoInitializeEx(NULL,COINIT_MULTITHREADED) needed by my DLL.","Q_Score":0,"Tags":"python,python-3.x,com,dynamic-dll-import","A_Id":56478216,"CreationDate":"2019-06-06T08:39:00.000","Title":"My DLL using COM objects with COINIT_MULTITHREADED is no more working on 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":"I have two clients (separate docker containers) both writing to a Cassandra cluster.\nThe first is writing real-time data, which is ingested at a rate that the cluster can handle, albeit with little spare capacity. This is regarded as high-priority data and we don't want to drop any. The ingestion rate varies quite a lot from minute to minute. Sometimes data backs up in the queue from which the client reads and at other times the client has cleared the queue and is (briefly) waiting for more data.\nThe second is a bulk data dump from an online store. We want to write it to Cassandra as fast as possible at a rate that soaks up whatever spare capacity there is after the real-time data is written, but without causing the cluster to start issuing timeouts.\nUsing the DataStax Python driver and keeping the two clients separate (i.e. they shouldn't have to know about or interact with each other), how can I throttle writes from the second client such that it maximises write throughput subject to the constraint of not impacting the write throughput of the first client?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":246,"Q_Id":56474650,"Users Score":0,"Answer":"The solution I came up with was to make both data producers write to the same queue.\nTo meet the requirement that the low-priority bulk data doesn't interfere with the high-priority live data, I made the producer of the low-priority data check the queue length and then add a record to the queue only if the queue length is below a suitable threshold (in my case 5 messages).\nThe result is that no live data message can have more than 5 bulk data messages in front of it in the queue. If messages start backing up on the queue then the bulk data producer stops queuing more data until the queue length falls below the threshold.\nI also split the bulk data into many small messages so that they are relatively quick to process by the consumer.\nThere are three disadvantages of this approach:\n\nThere is no visibility of how many queued messages are low priority and how many are high priority. However we know that there can't be more than 5 low priority messages.\nThe producer of low-priority messages has to poll the queue to get the current length, which generates a small extra load on the queue server.\nThe threshold isn't applied strictly because there is a race between the two producers from checking the queue length to queuing a message. It's not serious because the low-priority producer queues only a single message when it loses the race and next time it will know the queue is too long and wait.","Q_Score":0,"Tags":"python,cassandra,datastax-python-driver","A_Id":56577125,"CreationDate":"2019-06-06T09:28:00.000","Title":"Cassandra write throttling with multiple clients","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Just confused as to the differences between keras.sequential train_on_batch and fit. Is the only difference that, with train_on_batch, you automatically pass over the data only once whereas with fit you specify this with the no. of epochs?\nIf I do model.fit(x, y, epochs=5) is this the same as \nfor i in range(5)\n     model.train_on_batch(x, y)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":56476357,"Users Score":1,"Answer":"If I do model.fit(x, y, epochs=5) is this the same as\nfor i in range(5)    model.train_on_batch(x, y)?\n\nYes.\nYour understanding is correct.\nThere are a few more bells and whistles to .fit() (we, can for example, artificially control the number of batches to consider an epoch rather than exhausting the whole dataset) but, fundamentally, you are correct.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":56476394,"CreationDate":"2019-06-06T11:10:00.000","Title":"Is Keras Sequential fit the same as several train_on_batch calls?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it somehow possible to determine the array length of the arrays in the tck tuple returned by scipy.interpolate.splprep before computing the values?\nI have to fit a spline interpolation to noisy data with 5 million data points (or less, can be varying). \nMy observation is that the interpolation at an array length of ~ 90 is pretty good, while it takes a long time to compute the interpolation for higher array lengths (it sometimes also directly jumps from ~ 90 to ~ 1000 while making s one step smaller and the interpolation also becomes noisy) and it is not appropriate enough, if the array length is far less (<50)...\nActually, this array length depends on the smoothing factor s provided to the splprep function, but for different measurement data, s varies a lot to get a consistent array length of around 90. E.g. for data1 s has a value of around 1000 to get len(cfk[0]) equals to 90, for data2 s has a value of around 100 to get len(cfk[0]) equals to 90 at same lengths of data1 and data2. It might be dependent on the noise of the data...\nI have thought about a loop where s starts at some point and decreases through the loop while len(cfk[0]) is constantly being checked - but this takes ages, especially if len(cfk[0]) gets closer to 90.\nTherefore, it would be useful to somehow know the smoothing factor to get the desired array length before computing the cfk tuple.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":161,"Q_Id":56477397,"Users Score":0,"Answer":"Short answer: no, not easily. Dierckx Fortran library, which splrep wraps, uses some fairly non-trivial logic for determining the knot vector, and it's all baked into the Fortran code. So, the only way is to carefully trace the latter. It's available from netlib, also scipy\/interpolate\/fitpack","Q_Score":0,"Tags":"python,arrays,scipy,spline","A_Id":56484661,"CreationDate":"2019-06-06T12:14:00.000","Title":"Scipy spline interpolation: Determine array length of vector of knots \/ B-spline coefficients in tck before actual computation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have implemented a convolutional neural network by transfer learning using VGG19 to classify 5 different traffic signs. It works well with new test images, but when I apply the model upon video streaming it doesn't classify them correctly.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":56477793,"Users Score":0,"Answer":"Assuming the neural network works well on images, it should work the same on frames of a video stream. In the end, a video stream is a sequence of images.\nThe problem is not that it doesn't work on video stream, it simply does not work on the type of images similar to the ones you have in the video stream.\nIt is hard to exactly find the problem, since the question does not have enough detail. However, some considerations are:\n\nObviously, there is a problem with the network's ability to generalize. Was the testing performed well? For example, is there a train-validation split of the data?\nDoes the training error and the validation error indicate any possible issues, such as overfitting?\nIs the data used to train the image similar enough to the video frames?\nIs the training dataset large enough? Data augmentation might help if there is not enough data.","Q_Score":0,"Tags":"python,image-processing,video-streaming,conv-neural-network,video-processing","A_Id":56499818,"CreationDate":"2019-06-06T12:39:00.000","Title":"Why a convolution neural network model which works well on new test images fails on video stream?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I came across some code where tf.Variable(... trainable=False) was used and I wondered whether there was any difference between using tf.constant(...) and tf.Variable(with the trainable argument set to False)\nIt seems a bit redundant to have the trainable argument option available with tf.constant is available.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":739,"Q_Id":56479870,"Users Score":1,"Answer":"If you declare something with tf.constant() you won't be able to change the value in future. But, tf.Variable() let's you change the variable in future. You can assign some other value to it. If it is not trainable, then the gradient won't flow through it.","Q_Score":2,"Tags":"python,tensorflow","A_Id":56480077,"CreationDate":"2019-06-06T14:39:00.000","Title":"Difference between tf.constant and tf.Variable (trainable= False)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I came across some code where tf.Variable(... trainable=False) was used and I wondered whether there was any difference between using tf.constant(...) and tf.Variable(with the trainable argument set to False)\nIt seems a bit redundant to have the trainable argument option available with tf.constant is available.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":739,"Q_Id":56479870,"Users Score":1,"Answer":"There may be other differences, but one that comes to mind is that, for some TF graphs, you want a variable to be trainable sometimes and frozen other times.  For example, for transfer learning with convnets you want to freeze layers closer to the inputs and only train layers closer to the output.  It would be inconvenient, I suppose, if you had to swap out all the tf.Variable layers for tf.constant layers.","Q_Score":2,"Tags":"python,tensorflow","A_Id":56480023,"CreationDate":"2019-06-06T14:39:00.000","Title":"Difference between tf.constant and tf.Variable (trainable= False)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I came across some code where tf.Variable(... trainable=False) was used and I wondered whether there was any difference between using tf.constant(...) and tf.Variable(with the trainable argument set to False)\nIt seems a bit redundant to have the trainable argument option available with tf.constant is available.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":739,"Q_Id":56479870,"Users Score":2,"Answer":"Few reasons I can tell you off the top of my head:\n\nIf you declare a tf.Variable, you can change it's value later on if you want to. On the other hand, tf.constant is immutable, meaning that once you define it you can't change its value.\nLet's assume that you have a neural network with multiple weight matrices, for the first few epochs you can to train the last layer, while keeping the all the rest frozen. After that, for the last few epochs, you want to fine-tune the whole model. If the first layers are defined as tf.constant, you can't do that.","Q_Score":2,"Tags":"python,tensorflow","A_Id":56480281,"CreationDate":"2019-06-06T14:39:00.000","Title":"Difference between tf.constant and tf.Variable (trainable= False)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently I'm using the spectral clustering method from sklearn for my dense 7000x7000 matrix which performs very slowly and exceeds an execution time of 6 hours. Is there a faster implementation of spectral clustering in python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":244,"Q_Id":56482181,"Users Score":0,"Answer":"I'd recommend performing PCA to project the data to a lower dimensionality , and then utilize mini batch k-means","Q_Score":0,"Tags":"python,bigdata","A_Id":56482246,"CreationDate":"2019-06-06T17:09:00.000","Title":"Is there an efficient python implementation of spectral clustering for large, dense matrices?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have built a local environment on my computer to test Dags in airflow however when I got to initiate the database in the terminal with airflow initdb I am prompted with an error message.\nThe message has to do with the package Alembic and reads alembic.util.exc.CommandError: Can't locate revision identified by '939bb1e647c8'\nAny suggestions to fix?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":493,"Q_Id":56482847,"Users Score":-1,"Answer":"Fixed it by reentering the database path in the config file.","Q_Score":0,"Tags":"python,shell,terminal,airflow,alembic","A_Id":56485892,"CreationDate":"2019-06-06T18:00:00.000","Title":"Error when initiating Data Base in Apache Airflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to make a GUI with PyQt5. It will have a notification button with an icon. I want to add a small bubble with the number of notifications on the icon.\nIf a number is not possible, I would like to use a red dot as a backup method.\nBut how should I keep track of the new notifications (like a listener for notification) and change the icon while the window is running?\nI have been googling about this problem, but only mobile development stuff and  non-PyQt5 related results come up.\nExpected result: Let's say we have a list. And the icon of the button will automatically change when a new item is added to the list.  Then when the button is clicked, the icon will change back.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":830,"Q_Id":56484679,"Users Score":0,"Answer":"A possible solution to updating the icon would be to have a separate image file for each icon and its associated notification number. You can keep track of the number of current notifications in a counter variable. Use that number to call the corresponding icon.","Q_Score":3,"Tags":"python,python-3.x,pyqt,pyqt5","A_Id":56487888,"CreationDate":"2019-06-06T20:28:00.000","Title":"How to add notification number to a button icon?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to easily export one Python project from one PC to other. When I created the project, I used a virtual environment in order to avoid problems with different package versions.\nWhat I did was to just copy the project folder and paste it in the destination PC. Once I opened the project with Pycharm, I activated the virtual environment with project_path\/venv\/Scripts\/activate, but when I tried to execute any Script, it said it didn\u00b4t find the modules.\nWhich is the workflow I should follow in order to create projects and be able to run them from multiple PC-s without needing to install all the dependencies?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1999,"Q_Id":56493143,"Users Score":1,"Answer":"if you are using python3 then use pipenv. It will automatically create Pipfile and Pipfile.lock. That will insure reinstalling dependencies on different machine will have the same packages.\nbasic and helpful commands:\n\npipenv shell  # activate virutalenv\npipenv install  # will install dependencies in Pipfile\npipenv install requests  # will install requests lib. and will auto update Pipfile and Pipfile.lock","Q_Score":0,"Tags":"python,virtualenv","A_Id":56493347,"CreationDate":"2019-06-07T11:06:00.000","Title":"Export Python project from one PC to other","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to extract\/sync data through Pardot API v4 into a local DB. Most APIs were fine, just used the query method with created_after search criteria. But the Visit API does not seem to support neither a generic query of all visit data, nor a created_after search criteria to retrieve new items. \nAs far as I can see I can only query Visits in the context of a Visitor or a Prospect.\nAny ideas why, and how could I implement synchronisation? (sorry, no access to Pardot DB...)\nI have been using pypardot4 python wrapper for convenience but would be happy to use the API natively if it makes any difference.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":185,"Q_Id":56494946,"Users Score":2,"Answer":"I managed to get a response from Pardot support, and they have confirmed that such response filtering is not available on the Visits API. I asked for a feature request, but hardly any chance to get enough up-votes to be considered :(","Q_Score":1,"Tags":"python-3.x,pardot","A_Id":58770292,"CreationDate":"2019-06-07T13:05:00.000","Title":"Pardot Visit query API - generic query not available","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a model to predict the outcome (win or loose) of a tennis match, as an exercise. I am using Python, Pandas and scikit-learn.\nThe dataset I have has the two players ID and the result of the match, among other quantities.\nIn my case, the way the database is organized, has always the Player1 as the winner and the Player2 as the looser. So, if I have to label the data, it will always be the same label (1, for instance).\nWhat do you think is better: \n\nto try to train a model with a single-valued training ser (for instance a 1-label SVM) \nto randomly shuffle the data, in order to place some of the Player2 as the Player1 and viceversa, and so to have another label (0, for instance)?\n\nThanks a lot!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":460,"Q_Id":56495100,"Users Score":0,"Answer":"Sounds to me you need to shuffle that.  The dataset you have have inherent information coded in the structure of the data ( Player 1 wins).  You have no way to recreate this information at runtime.  \nWhat you want is a dataset where the order of the player information is not important , and a label 0\/1 determining if player 1 or player 2 will win.","Q_Score":0,"Tags":"python,machine-learning,supervised-learning","A_Id":56495157,"CreationDate":"2019-06-07T13:15:00.000","Title":"How to train a model with data with only one label","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that loops through all of the AWS accounts we have and lists the EC2 instances in each one. \nI want to turn it into an AWS Lambda function. But I can't figure out how to pull the AWS credentials that would allow me to list the servers in all the accounts.\nHow can I achieve this in AWS Lambda?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":316,"Q_Id":56496230,"Users Score":0,"Answer":"When you create lambda you have so specify a role\nIn IAM you can attach required permission to a lambda role. \nIf you want to use some specific set of credentials in a file, you can utilize AWS Systems Manager to retrieve credentials. \nThough, I would recommend role on lambda","Q_Score":0,"Tags":"python,aws-lambda","A_Id":56496798,"CreationDate":"2019-06-07T14:28:00.000","Title":"Loop through AWS Accounts in Lambda Python Function","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 that loops through all of the AWS accounts we have and lists the EC2 instances in each one. \nI want to turn it into an AWS Lambda function. But I can't figure out how to pull the AWS credentials that would allow me to list the servers in all the accounts.\nHow can I achieve this in AWS Lambda?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":316,"Q_Id":56496230,"Users Score":1,"Answer":"Create a role with cross account permissions for ec2:ListInstances\nAttach the role to the lambda function","Q_Score":0,"Tags":"python,aws-lambda","A_Id":56501963,"CreationDate":"2019-06-07T14:28:00.000","Title":"Loop through AWS Accounts in Lambda Python Function","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 a dataset using partitionBy on S3 using pyspark. I am partitioning by on a date column. Spark job is taking more than hour to execute it. If i run the code without partitionBy it just takes 3-4 mints. \nCould somebody help me in fining tune the parititonby?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1717,"Q_Id":56496387,"Users Score":1,"Answer":"Use version 2 of the FileOutputCommiter\n.set(\"mapreduce.fileoutputcommitter.algorithm.version\", \"2\")","Q_Score":0,"Tags":"python,apache-spark,amazon-s3,pyspark,amazon-emr","A_Id":57731033,"CreationDate":"2019-06-07T14:37:00.000","Title":"partitionBy taking too long while saving a dataset on S3 using Pyspark","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know with pytorch you can turn off training by calling eval() on your model. \nAlso you can set requires_grad=False. \nHow can you ensure that a TensorFlow element is not modified during training?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":670,"Q_Id":56501260,"Users Score":0,"Answer":"If you don't want to train certain Variables in TensorFlow you can achieve this behaviour by adding trainable=False to Variables.","Q_Score":1,"Tags":"python,tensorflow,pytorch","A_Id":59047316,"CreationDate":"2019-06-07T21:11:00.000","Title":"Tensorflow no_grad concept","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"using pd.read_csv(\"my.csv\"), I have certain rows that appear as either TRUE or FALSE. read_csv is changing these rows in the dataframe as \"True\" and \"False\".  Is there any way to keep case sensitivity when reading a CSV for true and false values?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":162,"Q_Id":56501959,"Users Score":0,"Answer":"I think the output dataframe of read_csv already convert the columns to boolean values. You can verify it by calling df.info(). If you want to keep the columns as string values you need to pass a dict to the dtype parameter to specify it explicitly.","Q_Score":1,"Tags":"python,pandas","A_Id":56501994,"CreationDate":"2019-06-07T22:45:00.000","Title":"Pandas is replacing rows with FALSE and TRUE with False and True","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use multigpu to train a model with pytorch. One gpu uses more memory than others, causing \"out-of-memory\". Why would one gpu use more memory? Is it possible to make the usage more balanced? Is there other ways to reduce memory usage? (Deleting variables that will not be used anymore...?) The batch size is already 1. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":186,"Q_Id":56503303,"Users Score":0,"Answer":"DataParallel splits the batch and sends each split to a different GPU, each GPU has a copy of the model, then the forward pass is computed independently and then the outputs of each GPU are collected back to one GPU instead of computing loss independently in each GPU.\nIf you want to mitigate this issue you can include the loss computation in the DataParallel module.\nIf doing this is still an issue, then you might want model parallelism instead of data parallelism: move different parts of your model to different GPUs using .cuda(gpu_id). This is useful when the weights of your model are pretty large.","Q_Score":0,"Tags":"python,memory,gpu,pytorch,multi-gpu","A_Id":56651186,"CreationDate":"2019-06-08T04:00:00.000","Title":"One gpu uses more memory than others during training","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have set up a Raspberry Pi connected to an LED strip which is controllable from my phone via a Node server I have running on the RasPi. It triggers a simple python script that sets a colour.\nI'm looking to expand the functionality such that I have a python script continuously running and I can send colours to it that it will consume the new colour and display both the old and new colour side by side. I.e the python script can receive commands and manage state.\nI've looked into whether to use a simple loop or a deamon for this but I don't understand how to both run a script continuously and receive the new commands.\nIs it better to keep state in the Node server and keep sending a lot of simple commands to a basic python script or to write a more involved python script that can receive few simpler commands and continuously update the lights?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":302,"Q_Id":56504180,"Users Score":1,"Answer":"IIUC, you don't necessarily need to have the python script running continuously. It just needs to store state, and you can do this by writing the state to a file. The script can then just read the last state file at startup, decide what to do from thereon, perform action, then update the state file.\nIn case you do want to actually run the script continuously though, you need a way to accept the commands. The simplest way for a daemon to accept command is probably through signal, you can use custom signal e.g. SIGUSR1 and SIGUSR2 to send and receive these notifications. These may be sufficient if your daemon only need to accept very simple request.\nFor more complex request where you need to actually accept messages, you can listen to a Unix socket or listen to a TCP socket. The socket module in the standard library can help you with that. If you want to build a more complex command server, then you may even want to consider running a full HTTP server, though this looks overkill for the current situation.\n\nIs it better to keep state in the Node server and keep sending a lot of simple commands to a basic python script or to write a more involved python script that can receive few simpler commands and continuously update the lights?\n\nThere's no straightforward answer to that. It depends on case by case basis, how complex the state is, how frequently you need to change colour, how familiar you are with the languages, etc.","Q_Score":0,"Tags":"python,node.js,command-line,raspberry-pi","A_Id":56504287,"CreationDate":"2019-06-08T06:50:00.000","Title":"How to run a Python script continuously that can receive commands from node","Data Science and Machine Learning":0,"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 include some C# code to my python application. I want to use JetBrains Pycharm. So, How do I use IronPython on JetBrains PyCharm? I tried all menus but still couldn't figure it.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":3012,"Q_Id":56505445,"Users Score":3,"Answer":"(First of all, make sure that you have installed IronPython and have added it to PATH. Then, to use it in Pycharm, do the following:)\n\nopen Pycharm\nmake your IronPython project\nYou will be give the option to choose your project interpreter. Choose C:\\Program Files\\IronPython <version number>\\ipy.exe\ncreate your python file(s). You will now be able to run IronPython code.","Q_Score":2,"Tags":"c#,python,pycharm,ironpython,jetbrains-ide","A_Id":56687621,"CreationDate":"2019-06-08T10:17:00.000","Title":"Use IronPython on JetBrains PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to compute a 3x4 matrix transformation, in homogeneous coordinates, that transforms 3d world points to 2d image points. My problem is that in the documentation and tutorials of the function getPerspectiveTransformation the default matrices are either 3x3 for perspective or 2x3 in affine transformations. \nIs there any built in function to compute the 3x4 matrix?\nI have read the tutorials, some books on computer vision and I know the matrix that transforms 3d to 2d is 3x4. It is necessary to input 6 points to get this matrix and in the examples I find for opencv they are using 4, so I guess this is a 2d to 2d transformation not what I need. \ncv2.getPerspectiveTransform\ncv2.getAffineTransform\nI used these functions but it didn't work, I used cv2.circle function to plot what was supposed to be a straigh line on the image and I got curved lines. Obviously I was not using the proper matrix transformation.","AnswerCount":2,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":304,"Q_Id":56506815,"Users Score":-5,"Answer":"Yes of course there is. Just look for the computeThreeByFourMatrix() function in the OpenCV library documentation. It is all there","Q_Score":1,"Tags":"python,opencv,computational-geometry","A_Id":56506873,"CreationDate":"2019-06-08T13:22:00.000","Title":"Does Opencv allow you to compute the 3x4 perspective transformation using 6 points?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a W2V model and then generate train and test data to be used for my model.My question is how can I generate test data after I am done with creating a W2V model with my train data.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1283,"Q_Id":56508631,"Users Score":0,"Answer":"Word2Vec is considered an 'unsupervised' algorithm, so at least during its training, it is not typical to hold back any 'test' data for later evaluation. \nA Word2Vec model is usually then evaluated on how well it helps some other process - such as the analogy-solving highlighted by the original paper. In gensim, the method [evaluate_word_analogies()][1] can repeat that process. But note: word-vectors that perform best on word-analogies my not be best for other purposes, like classification or info-retrieval. It's always best to evaluate & tune your word-vectors in a repeatable way that's related to your actual underlying use. \n(If you're using the Word2Vec model's outputs - word-vectors specific to your domain \u2013 as part of a larger system, where some steps should be evaluated with held-back data, the decision of whether to train the Word2Vec component on all data could go either way, depending on other considerations.)","Q_Score":1,"Tags":"python,gensim,word2vec","A_Id":56517433,"CreationDate":"2019-06-08T17:25:00.000","Title":"Creating train,test data for Word2Vec model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I apologize if this is not the correct site for this.  If it is not, please let me know.\nHere's some background on what I am attempting.  We are working on a series of chat bots that will go into production.  Each of them will run on a  environment in Anaconda.  However, our setup uses tensorflow, which uses gcc to be compiled, and compliance has banned compilers from production.  In addition, compliance rules also frown on us using pip or conda install in production.\nAs a way to get around this, I'm trying to tar the Anaconda 3 folder and move it into prod, with all dependencies already compiled and installed.  However, the accounts between environments have different names, so this requires me to go into the bin folder (at the very least; I'm sure I will need to change them in the lib and pckg folders as well) and use sed -i to rename the hard coded paths to point from \\home\\<dev account>\\anaconda to \\home\\<prod account>\\anaconda, and while this seems to work, its also a good way to mangle my installation.\nMy questions are as follows:\n\nIs there any good way to transfer anaconda from one user to another, without having to use sed -i on these paths? I've already read that Anaconda itself does not support this, but I would like your input.\nIs there any way for me to install anaconda in dev so the scripts in it are either hard coded to use the production account name in their paths, or to use ~.\nIf I must continue to use sed, is there anything critical I should be aware of? For example, when I use grep <dev account> *, I will some files listed as binary file matches.  DO I need to do anything special to change these?  \n\nAnd once again, I am well aware that I should just create a new Anaconda installation on the production machine, but that is simply not an option.\nEdit:\nSo far, I've changed the conda.sh and conda.csh files in \/etc, as well as the conda, activate, and deactivate files in the root bin.  As such, I'm able to activate and deactivate my environment on the new user account.  Also, I've changed the files in the bin folder under the bot environment.  Right now, I'm trying to train the bot to test if this works, but it keeps failing and stating that a custom action does not exist in the the list.  I don't think that is related to this, though.\nEdit2:\nI've confirmed that the error I was getting was not related to this.  In order to get the bot to work properly with a ported version of Anaconda, all I had to change was the the conda.sh and conda.csh files in \/etc so their paths to python use ~, do the same for the activate and deactivate files in \/bin, and change the shebang line in the conda file in \/bin to use the actual account name.  This leaves every other file in \/bin and lib still using the old account name in their shebang lines and other variable that use the path, and yet the bots work as expected.  By all rights, I don't think this should work, but it does.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3056,"Q_Id":56508782,"Users Score":0,"Answer":"but they may be inserted into binaries as well\n\nI can confirm that some packages have hard-coded the absolute path (including username) into the compiled binary. But if you restrict usernames to have the same length, you can apply sed on both binary and text files to make almost everything work as perfect.\nOn the other hand, if you copy the entire folder and use sed to replace usernames on only text files, you can run most of the installed packages. However, operations involving run-time compilation might fail, one example is installing a new package that requires compilation during installation.","Q_Score":2,"Tags":"python,installation,anaconda,virtualenv","A_Id":65776660,"CreationDate":"2019-06-08T17:44:00.000","Title":"Moving Anaconda installation from one user account to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I make a Graph (not Digraph) from a data frame (Huge network) with networkx.\nI used this code to creat my graph:\nnx.from_pandas_edgelist(R,source='A',target='B',create_using=nx.Graph())\nHowever, in the output when I check the edge list, my source node and the target node has been changed based on the sort and I don't know how to keep it as the way it was in the dataframe (Need the source and target node stay as the way it was in dataframe).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":309,"Q_Id":56509345,"Users Score":0,"Answer":"If you mean the order has changed, check out nx.OrderedGraph","Q_Score":1,"Tags":"python,pandas,networkx","A_Id":56509709,"CreationDate":"2019-06-08T19:04:00.000","Title":"How can I stop networkx to change the source and the target node?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to use Tensorflow 2.0(TF2.0) and Keras but I don't know if it's necessary to install both seperately or just TF2.0 (assuming TF2.0 has Keras bundled inside it). If I need to install TF2.0 only, will installing in a Python 3.7.1 be acceptable?\nThis is for Ubuntu 16.04 64 bit.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":176,"Q_Id":56509459,"Users Score":2,"Answer":"In Tensorflow 2.0 there is strong integration between TensorFlow and the Keras API specification (TF ships its own Keras implementation, that respects the Keras standard), therefore you don't have to install Keras separately since Keras already comes with TF in the tf.keras package.","Q_Score":0,"Tags":"python-3.x,tensorflow2.0,tf.keras","A_Id":56521630,"CreationDate":"2019-06-08T19:22:00.000","Title":"After installing Tensorflow 2.0 in a python 3.7.1 env, do I need to install Keras, or does Keras come bundled with TF2.0?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Control-M job that calls a python script. The python script contains a function that returns True or False. \nIs it possible to make the job to fail when the function returns False?\nI have to use a shell scrip for this? If yes how should i create it?\nThank you","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":799,"Q_Id":56509567,"Users Score":0,"Answer":"Return a non-zero value -- i.e. call sys.exit(1) when function returns False, and sys.exit(0) otherwise.","Q_Score":1,"Tags":"python,shell,control-m","A_Id":57284287,"CreationDate":"2019-06-08T19:37:00.000","Title":"How to fail a Control M job when running a python function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python prompt gives option to do the following.\nCheck help, copyright, credits, and license.\nIt is must to use () with help and license but not with copyright and credits. Just wondering why?\nI have tried running all these by with and without (). help and license specifically ask to type ().","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":696,"Q_Id":56511591,"Users Score":0,"Answer":"The copyright and credits builtin print out like simple strings. That works for them because they're each relatively short (just a few lines each). They're actually instances of a class (so you can call them), but you don't need to.\nFor license and help, there's far too much information for a single string to contain in a user-friendly manner. When you run license(), it shows you one page of the license at a time, with a prompt to press return to see more. The help builtin is even more fancy, as it gives you an interactive prompt to get help on a variety of different topics (including giving separate help texts for every module you have installed). You can also call help on an object (such as a function or module) to get more narrowly directed help without going through the interactive system.","Q_Score":1,"Tags":"python,python-3.x,python-2.7","A_Id":56511714,"CreationDate":"2019-06-09T02:42:00.000","Title":"Are help() and license() functions but copyright and credits not?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making an http request in my code and I am curious if making a HEAD request still makes the syn, syn-ack, and ack? I've never heard of HEAD until now.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":56512169,"Users Score":1,"Answer":"\"Does making a HEAD request still require the 3 way handshake?\"\nIt depends. HEAD request is a concept in HTTP, the application layer; while \"3 way handshake\" is a concept in TCP, the transport layer.\nThus, whether HEAD request requires \"3 way handshake\" depends on whether it is using TCP. For HTTP\/1.1 and HTTP\/2, the answer is yes. For HTTP\/3, the answer is no, as HTTP\/3 is based on UDP.","Q_Score":0,"Tags":"http,python-requests,http-headers,httprequest","A_Id":56519591,"CreationDate":"2019-06-09T05:16:00.000","Title":"Does making a HEAD request still require the 3 way handshake?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cannot for the life of me get VS Code to run Python 3. I've installed Python 3 and followed several VS Code tutorials to get it set up. I've set the user settings to point to my install of Python 3: \"python.pythonPath\": \"\/usr\/local\/bin\/python3\"\nHowever, every time I run python in the terminal within VSC, it is Python 2.7. When I try to install anything using pip, I get warnings that 2.7 will no longer be supported etc. \nAs an example, when I try to install something with pip, I get the following error:\n\nERROR: Could not install packages due to an EnvironmentError: [Errno\n  13] Permission denied:\n  '\/Library\/Python\/2.7\/site-packages\/urllib3-1.25.3.dist-info' Consider\n  using the --user option or check the permissions.\n\nAny ideas? It's driving me crazy that I simply can't get VSC to switch to Python 3.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1490,"Q_Id":56515625,"Users Score":0,"Answer":"python2.7 was the first widely stable version of python and came pre-installed on unix like OS such as Mac and Linux after it's acceptance. Many python apps have been built on python2.7 although python2.7 has been discontinued. However, it is still maintained with bug fixes. Most applications and OS that support python usually default to python2.7 that usually gets invoked using python. to use python version 3, append 3 to python (python3). python3 libraries and plugins are mostly differentiated from default python with an appendage of 3 to the library name or plugin name such pip3. As a result you have both versions of python live on your system without conflicts. Note that you cannot port python 2.7 codes to python3","Q_Score":3,"Tags":"python,python-3.x,visual-studio-code","A_Id":64184060,"CreationDate":"2019-06-09T14:54:00.000","Title":"Cannot switch to Python3 in VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cannot for the life of me get VS Code to run Python 3. I've installed Python 3 and followed several VS Code tutorials to get it set up. I've set the user settings to point to my install of Python 3: \"python.pythonPath\": \"\/usr\/local\/bin\/python3\"\nHowever, every time I run python in the terminal within VSC, it is Python 2.7. When I try to install anything using pip, I get warnings that 2.7 will no longer be supported etc. \nAs an example, when I try to install something with pip, I get the following error:\n\nERROR: Could not install packages due to an EnvironmentError: [Errno\n  13] Permission denied:\n  '\/Library\/Python\/2.7\/site-packages\/urllib3-1.25.3.dist-info' Consider\n  using the --user option or check the permissions.\n\nAny ideas? It's driving me crazy that I simply can't get VSC to switch to Python 3.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1490,"Q_Id":56515625,"Users Score":0,"Answer":"Try using pip3 install instead of pip install, pip is most likely linked against pip2.","Q_Score":3,"Tags":"python,python-3.x,visual-studio-code","A_Id":56516775,"CreationDate":"2019-06-09T14:54:00.000","Title":"Cannot switch to Python3 in VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use the requests Module with python At the moment. I use \"r.status_code == 200\" to check if the response is valid. But for my project right now it gaves me false posetives. It would be better for me  to check if a response is valid with a Keyword check on the sourcecode or something like this is this possible ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1387,"Q_Id":56517575,"Users Score":0,"Answer":"If I understand your question correctly, its possible for your request to give you back empty or invalid data that is not useful to you. \nWithout knowing what this request return you could look for specific fields in the request, for example if the request returns a json look for specific fields using if json_file.get(\"field_name\", False)","Q_Score":0,"Tags":"python,request","A_Id":56517613,"CreationDate":"2019-06-09T19:03:00.000","Title":"Python requests check if success","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For example, Why use tf.int32? Why not just use Python builtin integers?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":56518982,"Users Score":0,"Answer":"In short because TensorFlow is not executed by the python interpreter (at least not in general).\nPython provides but one possible API to interact with TensorFlow. The core of TensorFlow itself is compiled (written mostly in C++) where python datatypes are not available. Also, (despite recent advances allowing eager execution) we need to be able to first create an execution graph, then to pass data through it. That execution graph needs to be aware of datatypes but is language agnostic","Q_Score":2,"Tags":"python,tensorflow","A_Id":56524739,"CreationDate":"2019-06-09T23:02:00.000","Title":"What's the purpose of TensorFlow specific data types?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a problem in which my response variable is a relative power whose value cannot go beyond 100%. When I use linear regression or any other machine-learning algorithms, the predicted value goes beyond 100% and I want to limit that to 100%. Is there any way we can achieve that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":56519098,"Users Score":0,"Answer":"It depends on the meaning of your response variable, considering you are using linear regression. But in a general function y=f(x), you can add a Softmax function y=Softmax(f(x)) to make sure y in (0, 1). If you replace Softmax with sigmoid and use it for regression, then you get a Logistic regression, they you can limit the response value to (0, 1).","Q_Score":1,"Tags":"python,machine-learning","A_Id":56520260,"CreationDate":"2019-06-09T23:29:00.000","Title":"Can we limit the value of a response variable in any machine learning algorithm?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some audio files recorded from wind turbines, and I'm trying to do anomaly detection. The general idea is if a blade has a fault (e.g. cracking), the sound of this blade will differ with other two blades, so we can basically find a way to extract each blade's sound signal and compare the similarity \/ distance between them, if one of this signals has a significant difference, we can say the turbine is going to fail.\nI only have some faulty samples, labels are lacking.\nHowever, there seems to be no one doing this kind of work, and I met lots of troubles while attempting.\nI've tried using stft to convert the signal to power spectrum, and some spikes show. How to identify each blade from the raw data? (Some related work use AutoEncoders to detect anomaly from audio, but in this task we want to use some similarity-based method.)\nAnyone has good idea? Have some related work \/ paper to recommend?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":48,"Q_Id":56520227,"Users Score":1,"Answer":"Well...\nIf your shaft is rotating at, say 1200 RPM or 20 Hz, then all the significant sound produced by that rotation should be at harmonics of 20Hz.\nIf the turbine has 3 perfect blades, however, then it will be in exactly the same configuration 3 times for every rotation, so all of the sound produced by the rotation should be confined to multiples of 60 Hz.\nEnergy at the other harmonics of 20 Hz -- 20, 40, 80, 100, etc. -- that is above the noise floor would generally result from differences between the blades.\nThis of course ignores noise from other sources that are also synchronized to the shaft, which can mess up the analysis.","Q_Score":0,"Tags":"python,machine-learning,signal-processing","A_Id":56543927,"CreationDate":"2019-06-10T03:37:00.000","Title":"How to Identify Each Components from Audio Signal?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why might the values between df.size and len(df.to_dict(\"records\")) be different? I find the value of df.size=58151429 while my len(df.to_dict(\"records\"))=2528323 which is quite a big difference. Why can that be?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":696,"Q_Id":56520381,"Users Score":3,"Answer":"Size will display total number of values while len display length of Data Frame\nEx: if you have 3*2(3 rows and 2 columns)\n    size will be \"6\", len will be \"3\"","Q_Score":2,"Tags":"python,python-3.x,pandas","A_Id":56520450,"CreationDate":"2019-06-10T04:05:00.000","Title":"Different values between pandas df.size and len(df.to_dict(\"records\"))","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How are lists implemented to be heterogeneous? I know that a list is a dynamic array of pointers that point to the memory location of the required element but how does this work when the elements the indexes point to are of different sizes.\nDoes the location the pointer points to contain information about what type  this location holds and if so, how is that kind of information formatted, used, returned?\nI understand how [1,2,3] should look in memory but not how [1,2,\"abcdefg\"] would look in memory.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":510,"Q_Id":56521431,"Users Score":1,"Answer":"Everything is an object in python: As you mention, lists are collections of 'pointers' to the memory location on the objects contained in the list.\nAs objects, they each know their type, attributes, properties, etc.\nThey therefore cannot exceed their own memory boundary, and a tally\/accounting of the number of pointers pointed at them is invisibly kept by the python interpreter.","Q_Score":0,"Tags":"python,list,compiler-construction","A_Id":56521517,"CreationDate":"2019-06-10T06:25:00.000","Title":"How are lists implemented to be heterogeneous in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running Django 2.2, python 3.6.7 and I'm working in a virtual environment on Ubuntu 18.04.\nHaving done a tutorial where the project \"mysite\" was built, I'm now doing another exercise to build an API. I'm using the same virtualenv. However when I migrate in my new project, call it tutorial, I get ModuleNotFoundError: No module named 'mysite'. \nSo I deleted mysite. And I get the same error. And then I deleted the parent directory, recreated it (obviously not including mysite) and get the same error. I've searched recursively the codebase and the virtualenv and \"mysite\" does not turn up.\nWhat's going on here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":251,"Q_Id":56523809,"Users Score":1,"Answer":"You need to set DJANGO_SETTINGS_MODULE\/PYTHON_PATH environment variables.","Q_Score":3,"Tags":"python,django","A_Id":56524061,"CreationDate":"2019-06-10T09:35:00.000","Title":"Django module not found error, but it's been deleted and all references removed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Am trying to get date sting from filename using regular expression in a python script. Here is my date sting \n\n'2012-09-25 ag.pdf'\n\nTo get date string from this filename am using this regex r'\\d{4}[-]\\d{1,2}[-]\\d{1,2}' and it working fine \nbut some filenames also contains two digit year and for those am trying another regex r'\\d{2}-\\d{2}-\\d{2}'\n'2012-09-25 ag.pdf' also matches with second regex (r'\\d{2}-\\d{2}-\\d{2}') pattern that causing issue with my script\nHow can i use regex in python to match exact two digits not more than that","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":56525417,"Users Score":0,"Answer":"If Your filenames are always like this, you can prepend your regexp with ^ to match only on the beginning.","Q_Score":0,"Tags":"regex,python-3.x,date","A_Id":56525458,"CreationDate":"2019-06-10T11:21:00.000","Title":"Match exact two digits not more using regular expression","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a zebra crossing detection problem, and now I've already known the vertices of each zebra stripe, as a list of points. How can I efficiently calculate the coordinates of the vertices of the outline rectangle containing those zebra stripes?\nI am doing it in 3D\nI've been thinking this question for days, and cannot figure out a solution rather than brutal force...\nThat's a different problem from finding the bounding box of a given list of points. For this task, the return would be four of those zebra stripes' vertices. I just need to find them out.\nAny help or pointers would be valuable!\nUPDATE: I finally sorted those zebra-crossings by orientation and found the terminal zebra strips easily. The rest of the work is trivial","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":56525947,"Users Score":0,"Answer":"As you told, you know the coordinates of each individual stripe of the zebra crossing. So now you can determine the first and last stripes by looking at max and min coordinates of all vertices(By considering a reference axis from which you can measure distance). then you know coordinates of terminal stripes and hence you can make the outline by considering the coordinates and hence making a larger rectangle from those four coordinates determining the whole zebra crossing.","Q_Score":0,"Tags":"python,computer-vision,computational-geometry","A_Id":56526165,"CreationDate":"2019-06-10T11:57:00.000","Title":"How can I calculate the coordinates of vertices of an zebra crossing area from the coordinates of vertices of zebra stripe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a zebra crossing detection problem, and now I've already known the vertices of each zebra stripe, as a list of points. How can I efficiently calculate the coordinates of the vertices of the outline rectangle containing those zebra stripes?\nI am doing it in 3D\nI've been thinking this question for days, and cannot figure out a solution rather than brutal force...\nThat's a different problem from finding the bounding box of a given list of points. For this task, the return would be four of those zebra stripes' vertices. I just need to find them out.\nAny help or pointers would be valuable!\nUPDATE: I finally sorted those zebra-crossings by orientation and found the terminal zebra strips easily. The rest of the work is trivial","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":85,"Q_Id":56525947,"Users Score":0,"Answer":"From what you say, it seems that you have the 3D coordinates of the outline of a rectangle. I will assume Cartesian coordinates and undistorted geometry.\nThe points belong to a plane, which you can determine by 3D plane fitting. Then by an orthogonal change of variables, you can project the points onto that plane.\nFor resonably good accuracy, you can\n\nfind the centroid of the points;\nfind the point the most distant from the centroid;\nsplit the point set by means of the line from the centroid to that point;\non both halves, find the most distant points from the centroid;\nthe line that joints them allows you to further split in four quadrants;\nin every quadrant, apply line fitting to find the edges.\n\n\nIf what you are after is the bounding box of several stripes, you can proceed as above to find the directions of the sides. Then apply a change of coordinates to bring those sides axis-aligned. Finding the bounding box is now straightforward.\nUndo the transforms to obtain the3D coordinates of the rectangle in 3D.","Q_Score":0,"Tags":"python,computer-vision,computational-geometry","A_Id":56526776,"CreationDate":"2019-06-10T11:57:00.000","Title":"How can I calculate the coordinates of vertices of an zebra crossing area from the coordinates of vertices of zebra stripe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created my tensorflow model which will act as a serve. Code will be hosted on client's local server. I don't want to give them my code but give them a wheel file. But after following python's package distribution my tensorflow files become corrupted.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":56526497,"Users Score":0,"Answer":"You can send only the frozen inference graph in .pb format.","Q_Score":0,"Tags":"python,tensorflow,keras,setup.py,python-wheel","A_Id":56526556,"CreationDate":"2019-06-10T12:31:00.000","Title":"Packaging tensorflow models as wheel files","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Everytime I try to update pip for version 3.7 of python it just does it for python 3.6. \npython --version returns 3.7.3, but pip --version returns the version with (python 3.6) at the end in parentheses","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1338,"Q_Id":56528033,"Users Score":2,"Answer":"This isn't the specific answer you are looking for, but it should be worth noting that just using pip can get nasty on systems with multiple python environments installed (hence, your SO question here!)\nI'd suggest that you consider targeting your python binary, and then use pip from there:\n\/path\/to\/python -m pip <pip commands here>\nWith this, you will never be confused about which python is getting packages installed to it. It's drawn out, and it's not fun to type all that, but with multiple python environments on a system, it can save a headache and avoid future confusion!","Q_Score":2,"Tags":"python,pip","A_Id":56528148,"CreationDate":"2019-06-10T14:07:00.000","Title":"How do I make pip point to pip for python 3.7 instead of python 3.6?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Scrapy Cloud, a job can be deleted. At first, its state will change, but the data will be available - items data, job.metadata, items.stats.\nWhat's the process of deletion in particular? How soon all of data will be erased?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":92,"Q_Id":56529737,"Users Score":2,"Answer":"Job deletion in Scrapy Cloud is an asynchronous process: at first, the jobs are just marked as deleted with all its data available, and then it's purged on the server side after 7 days (using a cron job). It's implemented in this way to have the last chance to recover jobs deleted by mistake or save some important data.\nAlso, purging in the context relates only to job data (requests\/items\/logs\/samples), while job metadata and stats are stored indefinitely for now (though you shouldn't rely on that, the policy can be revised at any given moment).","Q_Score":1,"Tags":"python,scrapy","A_Id":56539708,"CreationDate":"2019-06-10T15:58:00.000","Title":"What happens after scrapy job is deleted before it is erased","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've downloaded the XBRL module using pip install. But the Python interpreter says \"No module named 'xbrl'\", despite the XBRL being present via C:\\Program Files\\Python36\\Lib\\site-packages. How do I resolve this issue so I can run XBRL in Python?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":56530159,"Users Score":0,"Answer":"I think you need to install python-xbrl.\nTh easiest way is with pip :\npip install python-xbrl","Q_Score":0,"Tags":"python,pip,xbrl","A_Id":58118772,"CreationDate":"2019-06-10T16:28:00.000","Title":"XBRL Module Not Recognized","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a very expensive data pipeline. I want to use tf.data.Dataset.cache to cache the first epoch dataset to disk. Then speed up the process. The reason I'm doing this instead of saving the dataset into tfrecords is\n1) I change many parameters doing the processing every time, it is more convenient for me to cache it on the fly\n2) I'm doing cross-validation so I don't know which files to process\nI have a naive solution - to create a pipeline for each fold of the training files, but that takes a lot of space to cache (I'm doing 10 fold) that's equivalent of 1TB in total. \nIs there any other way to do this more efficiently both in space and in time?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":218,"Q_Id":56531580,"Users Score":0,"Answer":"Answering my own question, to do this, I can create a pipeline for each file, cache each pipeline on disk, put them into deque, then use tf.data.experimental.sample_from_datasets.","Q_Score":0,"Tags":"python-3.x,tensorflow,tensorflow-datasets","A_Id":56531971,"CreationDate":"2019-06-10T18:18:00.000","Title":"tensorflow dataset cache cross validation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have collected many unique JPEG files and compiled them into a single ~1000-page PDF file via Python. Each unique image occupies a single page within the PDF file. \nNow, I would like to go back and add functionality to my Python script so that each image has an integer stamped onto it and is searchable via ctrl+f after processing. For example, after processing via Python, page 15 within the PDF file has image 345 stamped to it. If I open the PDF file and searched for number 345, page 15 would be found.\nWhat is Pythonic method to accomplish this task?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":74,"Q_Id":56532567,"Users Score":1,"Answer":"You can add a text, or a label to the image in the same page, so you can find it when you search for it using Ctr+F","Q_Score":0,"Tags":"python,image,pdf,jpeg,ctrl","A_Id":56532604,"CreationDate":"2019-06-10T19:37:00.000","Title":"Finding image via ctrl+f via 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 unstructured (taken in no regular order) point cloud data (x,y,z) for a surface. This surface has bulges (+z) and depressions (-z) scattered around in an irregular fashion. I would like to generate some surface that is a function of the original data points and then be able to input a specific (x,y) and get the surface roughness value from it (z value). How would I go about doing this? \nI've looked at scipy's interpolation functions, but I don't know if creating a single function for the entire surface is the correct approach? Is there a technical name for what I am trying to do? I would appreciate any suggestions\/direction.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":847,"Q_Id":56532588,"Users Score":0,"Answer":"I don't know if creating a single function for the entire surface is the correct approach?\n\nI guess this depends on your data. Let's assume the base form of your surface is spherical. Then you can model it as such. \nIf your surface is more complex then a sphere you might can still model the neighborhood of (x,y) as such. Maybe you could even consider your surface as plain in the near neighborhood of (x,y).","Q_Score":2,"Tags":"python,python-3.x,mesh,point-clouds,surface","A_Id":56533007,"CreationDate":"2019-06-10T19:39:00.000","Title":"Python point cloud data to surface fit\/function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have unstructured (taken in no regular order) point cloud data (x,y,z) for a surface. This surface has bulges (+z) and depressions (-z) scattered around in an irregular fashion. I would like to generate some surface that is a function of the original data points and then be able to input a specific (x,y) and get the surface roughness value from it (z value). How would I go about doing this? \nI've looked at scipy's interpolation functions, but I don't know if creating a single function for the entire surface is the correct approach? Is there a technical name for what I am trying to do? I would appreciate any suggestions\/direction.","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":847,"Q_Id":56532588,"Users Score":-1,"Answer":"What you are trying to do, can be called surface fitting, or two-dimensional curve fitting. You would be able to find lots of available algorithms by searching for those terms. Now, the choice of the particular algorithm\/method should be dictated:\n\nby the origin of your data (there are specialized algorithms or variations of more common ones that are tailored for certain application areas)\nby the future use of your data (depending on what you are going to do with it, maybe you need to be able to calculate derivatives easily, etc)\n\nIt is not easy to represent complicated data (especially the noisy one) using a single function. Thus there is a lot of research about it. However, in a lot of applications curve-fitting is very successful and very widely used.","Q_Score":2,"Tags":"python,python-3.x,mesh,point-clouds,surface","A_Id":56534865,"CreationDate":"2019-06-10T19:39:00.000","Title":"Python point cloud data to surface fit\/function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I RMB on a single Python unittest in PyCharm (in the gutter on the green arrow) Pycharm insists on running all the tests in the file.  Am I missing something in the configuration?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":56533155,"Users Score":0,"Answer":"It seems to have corrected itself after I renamed the test case class","Q_Score":0,"Tags":"pycharm,python-unittest","A_Id":56561245,"CreationDate":"2019-06-10T20:32:00.000","Title":"PyCharm Python not running single unit 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are working on early action prediction but we are unable to understand the dataset itself NTU rgbd dataset is 1.3 tb.my laptop Hard disk is 931 GB\n .first problem : how to deal with such a big dataset?\nSecond problem : how to understand dataset?\nThird problem: how to load dataset ?\nThanks for the help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":56535700,"Users Score":0,"Answer":"The overall size of the dataset is 1.3 TB and this size will decrease after processing the data and converting it into numpy arrays or something else.\nBut I do not think you will work on the entire dataset, what is the part you want to work on it in the dataset?","Q_Score":0,"Tags":"python,machine-learning","A_Id":56695079,"CreationDate":"2019-06-11T02:31:00.000","Title":"How to load NTU rgbd dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was adding a Python plugin to Eclipse. I was able to successfully add PyDev. However, when I was adding manually the interpreter I got the following error:\n-Using an unsupported version\n(Python and JPython require at least version 2.1 and IronPython 2.6).\n-Specifying an invalid interpreter\n(usually a link to the actual interpreter on Mac or Linux)\nThe Python exe file I am using is python-3.5.1-amd64.exe. How can I fix this error?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":151,"Q_Id":56536856,"Users Score":0,"Answer":"Try using Jython 2.7.0 instead of Jython 2.7.1. I had","Q_Score":0,"Tags":"python-3.x,eclipse,eclipse-plugin","A_Id":71904828,"CreationDate":"2019-06-11T05:09:00.000","Title":"Error Setting Python Plugin on Eclipse: Using an Unsupported version (Python and JPython)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to develop a command-line program that located in C:\\assistant\\myassis.py\nEverytime when i want to run my program I should enter this command in my command line: $ python3.6 C:\\assistant\\myassis.py\nI want to set an specific command for my program which let me to use my program in every folder with a short command.\nfor instance:\n$ assis download file --test should require $ python3.6 C:\\assistant\\myassis.py download file --test.\nHow can i do it in my windows10?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":56537697,"Users Score":0,"Answer":"To run python programs simply clicking on it or entering its name you can set association. Python installer makes it by default, don't know why you havn't one. To check it enter assoc .py then ftype <type which assoc shows>, to set - assoc .py=Python.File then ftype Python.File=\"C:\\WINDOWS\\py.exe\" \"%L\" %*. \nTo run a script\/program from any folder without entering full path one has two options:\n\n\nPATH environment variable - put your script anywhere in PATH, for example - C:\\WINDOWS, C:\\PythonXX\\Scripts, C:\\Sys. Check path - path, set path - path %PATH;My dir, set\/check permanent path - Win+Break -> Additional system parameters -> Environment variables.\napppath: Edit registry HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths or HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths add entry like other.\n\nIf you don't want to enter '.py' suffix, and run you script.py simply as script, add ';.PY' to PATHEXT variable.\nLooking at your examples which begins with '$' it seems you are using not Windows shell and\/or python but some port of bash, maybe windows subsystems for linux (WSL) or git bash. In this case, paragraph 1 changes to 'add #!\/usr\/bin\/env python3 as the first line of you scripts', p.2. - use separate, Linux PATH variable, p.3. - use alias","Q_Score":0,"Tags":"python,windows,command-line","A_Id":56538307,"CreationDate":"2019-06-11T06:25:00.000","Title":"Set an specific command for a python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to build a network listener in python, which is able to capture the local network traffic from my own computer. \nI've tried with sockets, but i find it very hard to use this method, because i'm not on a Linux-machine. \nSo, is there another method i'm not aware of, now when it's about only monitoring my own traffic? :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":56538288,"Users Score":0,"Answer":"What you need is called sniffer, try scapy framework.","Q_Score":0,"Tags":"python-3.x,http,networking","A_Id":56566080,"CreationDate":"2019-06-11T07:08:00.000","Title":"How to make a network listener in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to install Pytorch on a computer with no internet connection.\nI've tried finding information about this online but can't find a single piece of documentation.\nDo you know how I can do this? Is it even possible?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":5814,"Q_Id":56539865,"Users Score":13,"Answer":"An easy way with pip:\n\nCreate an empty folder\npip download torch using the connected computer. You'll get the pytorch package and all its dependencies.\nCopy the folder to the offline computer. You must be using the same python setup on both computers (this goes for virtual environments as well)\npip install * on the offline computer, in the copied folder. This installs all the packages in the correct order. You can then use pytorch.\n\nNote that this works for (almost) any kind of python package.","Q_Score":3,"Tags":"python,pytorch","A_Id":56539996,"CreationDate":"2019-06-11T08:49:00.000","Title":"How do I install Pytorch offline?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to display a markdown(readme) file into an odoo view as a field, i'm using the parser mistune to parse the file into an html format; as a result, the text is displayed as expected, except for every images located in src\/img folder for the odoo module structure.\n(example of image: ![Capture](static\/src\/img\/usecase.png))\nI've tried with the html inspector and it says the image wasn't found, and when I hover it, the path is http:\/\/server-s551lb:8069\/static\/src\/img\/usecase.png and I find it weird because it's only the relative path to locate the image.\nAny help or idea would be welcome:)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":387,"Q_Id":56540338,"Users Score":0,"Answer":"I've found by adding modulename\/ before static from the relative path of the image :)","Q_Score":1,"Tags":"python,odoo","A_Id":56541489,"CreationDate":"2019-06-11T09:16:00.000","Title":"Odoo doesn't displays markdown images","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a e-commerce category structure where each parent category can have subcategories. For example:\nParent Category 1 -> Sub Category Level 1 -> Sub Category level 2 -> Sub Category Level 3\nParent Category 2 -> Sub Category Level 1 -> Sub Category level 2\nAlso I have all the search keyword from a e-commerce website.\nMy problem is to assign the correct sub-category Hierarchy to the search query. \nRequired input and output are given below:\nInput:\nSearch-Keyword; Category L1, Category L2, Category L3\nOffice Chair;Furniture;Chair & Seating;Office Chairs\nHp Laptop;Technology;Computers & Laptops;Laptop\nApple ipad;Technology;Tablet\nDark Coffee;breakroom;Coffee  \nIf the search keyword entered by the end user on the e-commerce website are:\nDesktop Monitor\nLight Coffee\nThen output file should contain correct classification of the search keywords as given below:\nDesktop Monitor;Technology;Computers & Laptops\nLight Coffee;breakroom;Coffee  \nI have tried multi-class classification of the parent category with the use of LSTM and word embedding using keras and able to assign \nOffice Chair -> Furniture\nLet me know if anyone have worked on similar problem.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":654,"Q_Id":56544765,"Users Score":0,"Answer":"I suggest train a classifier for children of each node in your hierarchy tree. for example classifier number 1 classify items between parent category 1 and parent category 2 (2 class classification). Then train a classifier with items of parent category 1 that classify between items between subcategory1, subcategory2 and suncategory3 (3 class classification). and so on.","Q_Score":0,"Tags":"python-3.x,keras,lstm,recurrent-neural-network,multiclass-classification","A_Id":56578619,"CreationDate":"2019-06-11T13:22:00.000","Title":"Hierarchical Multi-Class Classification","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I run my tests on my computer, they work relatively fine. At the very least, selenium runs without problems.\nAs soon as I run the same tests on a docker container I start running in all kinds of errors that selenium started throwing, such as: \"Element not clickable at point...\", \"Element is not interactable...\", etc.\nNone of these happen when I run the tests on my computer normally.\nI have a Linux Debian 9 computer, docker 1.11, Chrome 72.0, chromedriver 2.41, selenium 3.12. Test are done using py.test and in headless chrome.\nMy Dockerfile is simple, installing all of the packages for python and putting my tests in there and running them. I run a custom-made Dockerfile and don't have the option to use the premade seleniumHQ ones.\nI have first tried running a demo test where I first encountered that problem. I managed to solve it by editing the test code to bypass the exception and trying again. After that succeeded, I tried running a few more complicated tests and kept running into different errors I didn't run into before.\nEvery solution I found was aimed at solving the thrown exception, but I suspect there's a deeper issue at hand and I can't figure out what it is.\nTo reiterate: running tests on my computer (both headless and otherwise) works like a charm, but running the same tests in a docker container fails with several selenium errors thrown. For some reason, the tests don't seem to run properly and selenium keeps throwing errors.\nI've been trying to solve it for a while now and can't seem to figure out what the problem is.\nI'd like to know WHY this problem occurs and how to solve the root cause of it. If it's a known issue and the solution is indeed simply to solve every exception as it comes, I'd like to know that too.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":617,"Q_Id":56546422,"Users Score":1,"Answer":"As far as I could find, and how I solved this, is to just follow the exceptions and fix them as they come.\nThe general problem areas I encountered were the click event on buttons\/textbox and clearing the text from a textbox.\nThe solution involved:\n\nA call to webdriver.execute_script('arguments[0].click();', element) to replace button click events.\nA call to webdriver.execute_script('arguments[0].focus();', element) to replace    textbox click events.\nA call to webdriver.execute_script('arguments[0].value = \"\";', element) to replace textbox clears.\n\nFrom where I stand, these solved most if not all the sudden exceptions and the rest worked as intended.","Q_Score":0,"Tags":"python-3.x,selenium-webdriver,docker-container,web-testing","A_Id":56836785,"CreationDate":"2019-06-11T14:51:00.000","Title":"Running Selenium in container brings sudden selenium errors where there were none before","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"That's it. It installs, I can import statsmodels, but statsmodels.api doesn't import.\nI've tried installing with pip and conda, both give me version 0.9.0 and everything is fine.\nI've installed all the dependencies, statsmodels works, but statsmodels.api doesn't.\n\n\n\n\nimport statsmodels.api Traceback (most recent call last):   File \"\", line 1, in    File\n        \"C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\statsmodels\\api.py\",\n        line 16, in \n            from .discrete.discrete_model import (Poisson, Logit, Probit,   File\n        \"C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\statsmodels\\discrete\\discrete_model.py\",\n        line 45, in \n            from statsmodels.distributions import genpoisson_p   File \"C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\statsmodels\\distributions__init__.py\",\n        line 2, in \n            from .edgeworth import ExpandedNormal   File \"C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\statsmodels\\distributions\\edgeworth.py\",\n        line 7, in \n            from scipy.misc import factorial ImportError: cannot import name 'factorial' from 'scipy.misc'\n        (C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\scipy\\misc__init__.py)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":178,"Q_Id":56546431,"Users Score":1,"Answer":"From the error it looks as though there is not a function called factorial within the misc directory of the scipy package. \nHave you tried opening up the __init__.py file specified in the error and looking through the misc directory to find the factorial function?","Q_Score":1,"Tags":"python-3.x,statsmodels","A_Id":56546713,"CreationDate":"2019-06-11T14:52:00.000","Title":"Statsmodels.api doesn't import","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 5 csv files that I am trying to put into one graph in python. In the first column of each csv file, all of the numbers are the same, and I want to treat these as the x values for each csv file in the graph. However, there are two more columns in each csv file (to make 3 columns total), but I just want to graph the second column as the 'y-values' for each csv file on the same graph, and ideally get 5 different lines, one for each file. Does anyone have any ideas on how I could do this?\nI have already uploaded my files to the variable file_list","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":932,"Q_Id":56547899,"Users Score":0,"Answer":"Read the first file and create a list of lists in which each list filled by two columns of this file. Then read the other files one by one and append y column of them to the correspond index of this list.","Q_Score":0,"Tags":"python,pandas,csv,matplotlib,graph","A_Id":56548032,"CreationDate":"2019-06-11T16:14:00.000","Title":"Graphing multiple csv lists into one graph in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the differences among the three choices in their usages and functions? Are there lists for their arguments?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":56547919,"Users Score":0,"Answer":"ChromeOptions are specific to Chromedriver.  (you can pass prefs into the ChromeDriver constructor...)  Capabilities are for Selenium WebDriver. (so more global... things like setting paths to driver, browser etc...)","Q_Score":0,"Tags":"python,selenium,webdriver,selenium-chromedriver","A_Id":56552660,"CreationDate":"2019-06-11T16:16:00.000","Title":"What are the differences among ChromeOptions, capabilities and preferences in Chromedriver?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have downloaded postgresql as well as django and python but when I try running the command  \"python manage.py runserver\"   it gives me an error saying \"Fatal: password authentication failed for user\" .   I am trying to run it locally but am unable to figure out how to get past this issue.    \nI was able to connect to the server in pgAdmin but am still getting password authentication error message","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":227,"Q_Id":56548140,"Users Score":0,"Answer":"You need to change the password used to connect to your local Database, and this can be done, modifying your setting.py file in \"DATABASES\" object","Q_Score":0,"Tags":"python,django,postgresql","A_Id":63626428,"CreationDate":"2019-06-11T16:32:00.000","Title":"Password authentication failed when trying to run django application on server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've created a Mac app and I'd like to share it to my iPhone and run it there, but when I share it via mail or airdrop, I can't open it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":208,"Q_Id":56548553,"Users Score":0,"Answer":"You simply can't run a MacOS application on IOS. Instead, remake it with for example Xcode so the application can run on your iPhone.","Q_Score":0,"Tags":"python,python-3.x,py2app","A_Id":65158275,"CreationDate":"2019-06-11T17:00:00.000","Title":"how to share an ' .app ' (created with py2app) from Mac to iPhone?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a problem with exporting my python project. In this project, I am using the NLTK library, but when exporting it using the Pyinstaller tool the error mentioned in the title appears. I've been scouring a solution for weeks and I have not gotten an answer. I tried to use cx_freeze but other errors appear ... could anyone help me?\nTried use cx_freeze, and Pyapp.\n'''Unable to find \"\/usr\/nltk_data\" when adding binary and data files.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3359,"Q_Id":56548554,"Users Score":1,"Answer":"I solved the problems editing the pyinstaller nltk-hook. After much research, I decided to go it alone in the code structure. I solved my problem by commenting on the lines:\ndatas=[]\n'''for p in nltk.data.path:\n    datas.append((p, \"nltk_data\"))'''\nhiddenimports = [\"nltk.chunk.named_entity\"]\nWhat's more, you need to rename the file: pyi_rth__nltk.cpython-36.pyc to pyi_rth_nltk.cpython-36.pyc . This file have 1 more underline. Warning with the python version.","Q_Score":0,"Tags":"python,nltk,chatbot","A_Id":56654092,"CreationDate":"2019-06-11T17:00:00.000","Title":"Unable to find nltk_data when adding binary and data files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can I control exactly when MXNet should run performance tests?\nI have an MXNet application that is about to go to production. It is running ok, but it has a variable batch size and it causes MXNet to perform autotune often.\nAlthough the batch size is variable, it is typically 1. I'm fine with performance loss on bigger sizes (it is still better than interrupting it all the time to autotune).\nIf I disable autotune with export MXNET_CUDNN_AUTOTUNE_DEFAULT=0 the network runs considerably slower.\nSo my question: is there a way to run autotune only once, preferably at my call?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":461,"Q_Id":56550179,"Users Score":3,"Answer":"There is currently no way to run autotune only once. When autotuning is enabled MXNet will run performance tests to find the best algorithm to run for Convolution\/DeConvolution operators. The best algorithm is cached with the specific input shape, output shape. So as long as you have the same input\/output shape, the performance tests should not re-run. However, if the shape changes then it would trigger the algorithm to re-run.","Q_Score":2,"Tags":"python,mxnet","A_Id":56566460,"CreationDate":"2019-06-11T18:58:00.000","Title":"MXNet CuDNN Autotune management","Data Science and Machine Learning":0,"Database and SQL":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 looking for ways to best handle a single form on multiple pages. Like how a newsletter signup might be on a home page, an about page, and several blog pages. \nI've handled this exact scenario in these 2 ways. \n\nWrite an API (using DRF) that takes a POST request, and then point the normal HTML form at that API. This works, and is very flexible, but feels like overkill.\nPass the form object into the context of each view I want the form to be on, and then include that into the template with includes form_snippet with form=form\n\nThe first approach is more flexible with wagtail, wherein all that needs to happen on the admin side is an inclusion of the newsletter as a snippet, where the admin user is able to choose if they want the newsletter on the page or not. \nWhile both approaches work just fine, neither of them \"feels\" right, as I would think there is a simple way to do this without creating a big API, or passing around the form object to every single view.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":291,"Q_Id":56551998,"Users Score":0,"Answer":"I did this with a contact formular. I handled it with a new app for my contact formular.\nIn this contactApp is the templates\/contactForm.html. To include this contactForm where I want I use {% include 'contact\/contactForm.html' %} so it loads the contactForm.html from my app called contact.","Q_Score":0,"Tags":"python,django,forms,wagtail","A_Id":56587802,"CreationDate":"2019-06-11T21:38:00.000","Title":"How to have single form on multiple pages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"From what I understand,there are two different starting points where we can \nrun server through python manage.py runserver command in Django: \nFirst > \"mysite\" (as in many tutorials, and this folder is called \"project\" right?\nSecond > \"app\"(as in many django blog tutorials \"blog\")\nBut as I entered the command \"cd mysite\"(notice it's not \"cd app\")\n and did git push to pythonanywhere, \nmy pythonanywhere just shows \"mysite\" which I didn't even type in \"python manage.py migrate\"! \nSo I realized because of that, I couldn't even enter the admin website since I didn't create user on this \"project\" level but only in my \"app\" level \nIs there anything I missed or did wrong with this?\nIs it normal for a user to set up admin password on \"app\" level right?\nWhat did I do wrong on this and how can I fix it so that pythonanywhere shows my \"app\"?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":348,"Q_Id":56557374,"Users Score":2,"Answer":"It sounds like you have put your entire project at the \"app\" level of the Django project that was created by PythonAnywhere already. The top-level manage.py is the one that PythonAnywhere created for you and the one further down is the one that came from your git repo. There is help documentation on how to deploy an existing Django site on the PythonAnywhere help pages that would be a good place to start.","Q_Score":0,"Tags":"python,django,pythonanywhere","A_Id":56562057,"CreationDate":"2019-06-12T08:04:00.000","Title":"why are there two manage.py in django project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I\u2019m setting up a new invoice extraction method using AI, I able to recognize \"Total\"\/\"Company Details\" from invoice images but need help with extracting data from that particular region recognized in the invoice image by specifying an area in the image(Xmin, Xmax, Ymin, Ymax)?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":950,"Q_Id":56561357,"Users Score":1,"Answer":"Looks like you are newbird,so let me help you quick walkthrough of understanding of terms used in your keyword.\nOCR is optical character recognition a concept\nTesseract is special library handling for OCR.\nOpenCV helps in image processing library helping in object detection and recognition.\nYes, you can extract the text from image if its more than 300dpi by using tesseract library \nbut before that you should train the tesseract model with that font, if font of text is very new or unknown to system.\nAlso keep in mind, if you are able to box-image the text prior calling to tesseract, it will work more accurately.\nCertain word - box image, dpi will create alert, but these are pivot concepts to your work.\nMy suggestion, if you want to extract the digits from image, go in step by step.\n\nProcess the image by enhancing its quality.\nDetect the region which want to be extracted. \nFind the contour and area.\nPass it to box-image editor and tune the parameters \nFinally give it to Tesseract.","Q_Score":1,"Tags":"python,artificial-intelligence,ocr,tesseract,text-extraction","A_Id":56561928,"CreationDate":"2019-06-12T11:39:00.000","Title":"Is there any way in OCR\/tesseract\/OpenCV for extracting text from a particular region of an image?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been working on image classification with deep learning models (CNN with keras and tensorflow as back end) such as AlexNet and ResNet. I learned a lot about the whole dataset, learning, testing processes.\nI'm now shifting to object detection and have done a lot of research. I came across R-CNN, Fast R-CNN, Faster R-CNN, Mask R-CNN and different versions of YOLO networks. I noticed that these object detection networks require dataset annotation instead of the former simply needing to have cropped images stored in corresponding files.\nIs there any way to accomplish object detection without having to annotate dataset?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":872,"Q_Id":56562536,"Users Score":0,"Answer":"No, not really, Deep Learning is not magic, you need bounding box annotations. The field of research that deals with this problem is Weakly Supervised Object Detection, and its a research field, there are no solutions that perform as well as using an annotated dataset.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,dataset,object-detection-api","A_Id":56563697,"CreationDate":"2019-06-12T12:43:00.000","Title":"Can I avoid annotating my dataset for object recognition?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list of points that represent a needle\/catheter in a 3D volume. This volume is voxalized. I want to get all the voxels that the line that connects the point intersects. The line needs to go through all the points. \nIdeally, since the round needle\/catheter has a width I would like to be able to get the voxels that intersect the actual three dimensional object that is the needle\/catheter. (I imagine this is much harder so if I could get an answer to the first problem I would be very happy!)\nI am using the latest version of Anaconda (Python 3.7). I have seen some similar problems, but the code is always in C++ and none of it seems to be what I'm looking for. I am fairly certain that I need to use raycasting or a 3D Bresenham algorithm, but I don't know how. \nI would appreciate your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":628,"Q_Id":56565073,"Users Score":0,"Answer":"I ended up solving this problem myself. For anyone who is wondering how, I'll explain it briefly. \nFirst, since all the catheters point in the general direction of the z-axis, I got the thickness of the slices along that axis. Both input points land on a slice. I then got the coordinates of every intersection between the line between the two input points and the z-slices. Next, since I know the radius of the catheter and I can calculate the angle between the two points, I was able to draw ellipse paths on each slice around the points I had previously found (when you cut a cone at and angle, the cross-section is an ellipse). Then I got the coordinates of all the voxels on every slice along the z-axis and checked which voxels where within my ellipse paths. Those voxels are the ones that describe the volume of the catheter. If you would like to see my code please let me know.","Q_Score":0,"Tags":"python,3d,line,voxel,bresenham","A_Id":56839312,"CreationDate":"2019-06-12T14:54:00.000","Title":"How to get a voxel array from a list of 3D points that make up a line in a voxalized volume?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with wxPython, the Python bridge to wxWidgets, so I guess a wxWidgets user could reply.  I'm playing with the KeyEvent class and since I'm testing my code on other platforms and other keyboards, I've made an incredible (to me) discovery: other keyboard layouts don't seem to be very well supported.\nHere's what I mean: if you run the demo (KeyEvents.py in my case) and press on random letters, with a QWERTY keyboard, everything works.  Switch to another layout, things still work... somewhat.  Right now I have an AZERTY keyboard mostly used in France, so when I press the a key (which is on the English position of the q) a 'a' is reported.  So far so good.  But if I press a \u00e9 (a key which is on the English 2 key), a 2 is reported.  Reading the documentation didn't exactly help me to figure out what is going on.  Is that a kind of mistake no one has noticed since wx is out?  I would guess and hope not, but better late than never I guess.\nTo be more technical still, the KeyDown and KeyUp events have this problem.  I have an AZERTY kleyboard, I press on the 2 key, and a 2 is reported, whereas a \u00e9 is written on screen.  Admittedly, the Char event does report a \u00e9, but, if I understood correctly, a Char event is not triggered in any context a KeyDown event is triggered.  Perhaps I missed something here and perhaps that's the solution for me and international users.\nThanks in advance for your reply,","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":113,"Q_Id":56566858,"Users Score":1,"Answer":"Char event is not triggered in any context a KeyDown event is\n  triggered.\n\nFalse.\nDue to each country has its own keyboard layout, wxWidgets sends two events when a key is pressed: One (key event) is the somewhat hardware code for that key; the other (char event) is the \"translated\" code, normally a Unicode point, but an ASCII code if you disabled Unicode support.\nKeyevent is useful if you just want to do something on key-down or key-up events. If working with chars, then use only char event.","Q_Score":0,"Tags":"python,wxpython,wxwidgets","A_Id":56567608,"CreationDate":"2019-06-12T16:39:00.000","Title":"wx.KeyEvent and non-QWERTY keyboards","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to read the records from mainframe file and apply the some filters on record values.\nSo I am looking for a solution to convert the mainframe file to csv or text or Excel workbook so that I can easily perform the operations on the file.\nI also need to validate the records count.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1297,"Q_Id":56568561,"Users Score":0,"Answer":"Who said anything about EBCDIC? The OP didn't.\nIf it is all text then FTP'ing with EBCDIC to ASCII translation is doable, including within Python.\nIf not then either:\n\nThe extraction and conversion to CSV needs to happen on z\/OS. Perhaps with a COBOL program. Then the CSV can be FTP'ed down with\n\nor\n\nThe data has to be FTP'ed BINARY and then parsed and bits of it translated.\n\nBut, as so often is the case, we need more information.","Q_Score":0,"Tags":"excel,python-3.x,export-to-csv,mainframe,ebcdic","A_Id":56583582,"CreationDate":"2019-06-12T18:44:00.000","Title":"We have many mainframe files which are in EBCDIC format, is there a way in Python to parse or convert the mainframe file into csv file or text file?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a matrix of data with three indexes: i, j and k\nI want to enter some of the data in this matrix into a dictionary, and be able to find them afterwards in the dictionary.\nThe data itself can not be the key for the dict.\nI would like the i,j,k set of indexes to be the key.\nI think I need to \"hash\" (some sort of hash) in one number from which I can get back the i,j,k. I need the result key to be ordered so that:\n\nkey1 for 1,2,3 is greater than\nkey2 for 2,1,3 is greater than\nkey3 for 2,3,1\n\nDo you know any algorithms to get the keys from this set of indexes? Or is there a better structure in python to do what I want to do?\nI can't know before I store the data how much I will get, so I think I cannot just append the data with its indexes.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":56570667,"Users Score":0,"Answer":"Only immutable elements can be used as dictionary keys\n\nThis mean you can't use a list (mutable data type) but you can use a tuple as the key of your dictionary: dict_name[(i, j, k)] = data","Q_Score":0,"Tags":"python,dictionary,indexing","A_Id":56570699,"CreationDate":"2019-06-12T21:34:00.000","Title":"Hash a set of three indexes in a key for dictionary?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering how sqlite3 works when working in something like repl.it? I've been working on learning chatterbot on my own computer through Jupiter notebook. I'm a pretty amateur coder, and I have never worked with databases or SQL. When working from my own computer, I pretty much get the concept that when setting up a new bot with chatterbot, it creates a sqlite3 file, and then saves conversations to it to improve the chatbot. However, if I create a chatbot the same way only through repl.it and give lots of people the link, is the sqlite3 file saved online somewhere? Is it big enough to save lots of conversations from many people to really improve the bot well?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":56571509,"Users Score":0,"Answer":"I am not familiar with repl.it, but for all the answers you have asked the answer is yes. For example, I have made a simple web page that uses the chatterbot library. Then I used my own computer as a server using ngrok and gather training data from users.","Q_Score":0,"Tags":"python,sqlite,chatterbot,repl.it","A_Id":56579507,"CreationDate":"2019-06-12T23:20:00.000","Title":"Chatterbot sqlite store in repl.it","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have csv file where some of the fields have ^@ before the string. This is causing me a headache. How would I write a function for a given mystring to remove the ^@ from it? I have tried mystring.replace('^@','') but this didn't work. \nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":438,"Q_Id":56573115,"Users Score":3,"Answer":"When you see ^@, usually it's actually a null byte (aka Ctrl+@), not the literal sequence of a caret and then an at sign. As such, remove them with mystring.replace('\\x00','') instead.","Q_Score":0,"Tags":"python,null","A_Id":56573141,"CreationDate":"2019-06-13T03:46:00.000","Title":"How to remove caret-at (^@) from a string with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have upgraded from Visual Studio 2017 to 2019 (Community Edition).  I also have installed the 'Python development' workload from the Visual Studio 2019 installer.\nTo add a virtual environment to a Python Project in Visual Studio, I right-click 'Python Environments' within the Python project (in the Solution Explorer View) and choose 'Add Environment...'.  I opt for 'Virtual Environment', receiving the message:\n\"You will need to install a Python Interpreter before creating a virtual environment.\"\nI have installed both the Anaconda 2019.03 and Python 3.7 interpreter, and I have access to both of them in Visual Studio.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1636,"Q_Id":56577591,"Users Score":0,"Answer":"This is the breadcrumb that I followed:\n\nTools > Python > Python Environments > Add Environmemt\n\nAdd Environment... is at the top of the panel that opens when you get to > Python Environments\nYou can also use the 'chord' [<Ctrl> K , <Ctrl> '] to open the 'Python Environments' Panel","Q_Score":1,"Tags":"python-3.x,virtualenv,visual-studio-2019","A_Id":68073402,"CreationDate":"2019-06-13T09:37:00.000","Title":"How do I add a virtual environment to Visual Studio 2019?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"General idea:\nMany items (majority small images) are created on the canvas. The user can click on any item and move it. \nI need the user to know which item was last clicked, by showing (drawing) a border\/change brightness\/any method.. around that item.\nIs there any Image\/item options to help apply this idea.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1023,"Q_Id":56580739,"Users Score":0,"Answer":"For example this is your button-\nB1 = Button(root, text = \"Click me\", command = clickme)\nwe can pass more parameters here such as--\nhighlightcolor=\nThe color to use for the highlight border when the button has focus. The default is system speciific. (highlightColor\/HighlightColor)\nand\nhighlightthickness=\nThe width of the highlight border. The default is system specific (usually one or two pixels). (highlightThickness\/HighlightThickness)\n...\nOR\n...\nWhenever the button is clicked you must be specifying some action to do in a function. What you can do is you can tell that function to slight increase the thickness of border by above parameters. :)","Q_Score":0,"Tags":"python,tkinter,python-imaging-library,tkinter-canvas","A_Id":56580912,"CreationDate":"2019-06-13T12:41:00.000","Title":"highlight clicked items in tkinter canvas?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have an application that invokes a Python interpreter from within a C++ code. The C++ code is parallelized with mpi. The interpreter is used to run Python scripts (these may involve message passing via mpi4py or not).  Here's the problem: When we run the code as a serial code, if the Python scripts contains an error, on stderr we get the message that the interpreter generates with the usual diagnostic information (line where error occurs, type of error,...). If, however, we run the code in parallel over multiple cores, we do not get any diagnostic info from the interpreter. On the C++ side, we know that an error occurred in the script, but that is all. Of course, this makes debug much harder, since some of the errors may only occurs when running in parallel. So my question is how to redirect error messages from the interpreter to a file, or other ideas to deal with this situation.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":107,"Q_Id":56581003,"Users Score":0,"Answer":"The problem had to do with how we exit the code after an error on the Python side occurred. \nOriginally, we used MPI_Abort(). Switching to std::exit(0) solves the issue. \nNow, when a script generates an error, the Python interpreter messages are correctly displayed (from every process!).","Q_Score":0,"Tags":"python-3.x,runtime-error,mpi","A_Id":56600285,"CreationDate":"2019-06-13T12:54:00.000","Title":"How to deal with python interpreter run-time errors when running python within an mpi 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":"The ACS url in the Google SSO SAML setup where Google is the Identity Provider has to start with https. Therefore, I've not been able to use a localhost url. Is there a way how I could test Google SSO SAML on a local server? What url (or other details) do I need to enter?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5382,"Q_Id":56581853,"Users Score":0,"Answer":"I had same problem , i ran my app on localhost with https using local iis with self signed certificate and it worked just fine.\nThis way its easy to debug saml response from google rather than using remote urls.","Q_Score":5,"Tags":"python,google-cloud-platform,single-sign-on,saml-2.0,google-sso","A_Id":59552333,"CreationDate":"2019-06-13T13:40:00.000","Title":"Test Google SSO SAML on Localhost","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"string =  pytesseract.image_to_string(res,lang ='eng',config = config)\nI am getting an error as:\npytesseract.pytesseract.TesseractError: (255, '')\ni am cropping the images and performing some image processing tasks. After that I want to do ocr, on running the ocr i am getting the error.\nstring =  pytesseract.image_to_string(res,lang ='eng',config = config)\nexpected the ocr result. but tesseract is throwing an error and stops executing","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":203,"Q_Id":56583029,"Users Score":0,"Answer":"Some times the text may lie on the border of of the images. So padding the images along side the border resolves the issue","Q_Score":0,"Tags":"tesseract,python-tesseract","A_Id":56627744,"CreationDate":"2019-06-13T14:41:00.000","Title":"pytesseract.pytesseract.TesseractError: (255, '')","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using Python2 and pip for a long time and recently installed Python3 and pip3. I want to migrate all pip packages to pip3. How to install all the package at one go? \nSince my pip list shows a long list of packages installed using pip, it is very hectic to install them one by one using pip3.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":333,"Q_Id":56586133,"Users Score":1,"Answer":"First, save all the packages using pip freeze > requirements.txt then run pip3 install -r requirements.txt","Q_Score":0,"Tags":"python,python-3.x,python-2.7,pip","A_Id":56586194,"CreationDate":"2019-06-13T17:56:00.000","Title":"Migrate all python2 packages to python3 with pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When connecting to a remote kernel through SSH in Spyder, does the processing all done in the remote kernel and not using the local machine's resources?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":56590616,"Users Score":0,"Answer":"(Spyder maintainer here) That's correct, all computations are run in the server where the remote kernel was started and not in your local machine.","Q_Score":0,"Tags":"python,spyder","A_Id":56629797,"CreationDate":"2019-06-14T02:19:00.000","Title":"Spyder Remote Kernel Processing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am attempting to download modules in Python through pip. No matter how many times I edit the PATH to show the pip.exe, it shows the same error:\n'pip' is not recognized as an internal or external command,\noperable program or batch file.\nI have changed the PATH many different times and ways to make pip usable, but these changes go unnoticed by the command prompt terminal.\nHow should I fix this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":56591058,"Users Score":0,"Answer":"Are you using PyCharm? if yes change the environment to your desired directory and desired interpreter if you do have multiple interpreter available","Q_Score":0,"Tags":"python,path,pip","A_Id":56592051,"CreationDate":"2019-06-14T03:35:00.000","Title":"Command prompt does not recognize changes in PATH. How do I fix this?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have two dataframes :\n1st dataframe\n\nCountrey    2000    2001    2002    2003    2004    2005\n\ncanada      779      771     754     740     760     747\nmexico      1311.2  1285.2  1271.2  1276.5  1270.6  1281\nusa         836     814     810     800     802     799\nIndia       914     892     888     878     880     877\nChina       992     970     966    956       958    955\n\n2nd dataframe\n\nyear        2000    2001    2002    2003    2004    2005\ndata        1.1     1.2     1.3    1.4       1.5    1.6\n\ni would like to merge above these two dataframe in following way?is it possible?\n\ndata        1.1      1.2    1.3     1.4      1.5    1.6\nCountrey    2000    2001    2002    2003    2004    2005\ncanada      779     771      754    740      760    747\nmexico      1311.2  1285.2  1271.2  1276.5  1270.6  1281\nusa         836      814    810     800      802    799\nIndia       914      892    888     878      880    877\nChina       992      970    966     956      958    955\nSum        4832.2   4732.2  4689.2  4650.5  4670.6  4659\n\nalso i wants the sum of each column","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":561,"Q_Id":56591367,"Users Score":0,"Answer":"You could use pandas.concat() or DataFrame.append() , check pandas document its easily available with examples.","Q_Score":0,"Tags":"python,python-3.x","A_Id":56592187,"CreationDate":"2019-06-14T04:26:00.000","Title":"Stack Data Frames on top of one another dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I have a numpy array where I would like to swap all the 1's to 0 and all the 0's to 1 (the array will have other values, and there is nothing special about the 0's and 1's). Of course, I can loop through the array and change the values one by one.\nIs there an efficient method you can recommend using? Does the np.where() method have an option for this operation?","AnswerCount":7,"Available Count":1,"Score":0.057080742,"is_accepted":false,"ViewCount":14516,"Q_Id":56594598,"Users Score":2,"Answer":"iverted = ~arr + 2  should do the work","Q_Score":9,"Tags":"python,numpy","A_Id":68484466,"CreationDate":"2019-06-14T08:46:00.000","Title":"Change 1's to 0 and 0's to 1 in numpy array without looping","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can I train the object detection model with large images size 1600*1216 and obtain good accuracy . Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":56594824,"Users Score":0,"Answer":"Yes, you can train the object detection model with large images size 1600*1216 and obtain good accuracy.","Q_Score":0,"Tags":"python-3.x,object-detection","A_Id":56815637,"CreationDate":"2019-06-14T09:02:00.000","Title":"Train object detection with large images","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried doing it by creating a css file style.css in the same folder, copied the source code of the bulma link provided and then linked it to my html doc. But then, it shows no css features at all.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1985,"Q_Id":56595054,"Users Score":0,"Answer":"Although I didn't achieve what I was trying to do, I guess the only solution is either copying the exact design provided via Bulma link or ending up writing the whole css code all by own which I don't really prefer until essentially needed. So, I'd rather stick to the pre-defined design provided by Bulma.","Q_Score":1,"Tags":"html,css,django,python-3.x,bulma","A_Id":56610545,"CreationDate":"2019-06-14T09:15:00.000","Title":"Is there any way in which I can edit \"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/bulma\/0.7.5\/css\/bulma.css\" file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was trying to install a package called configparser on my local machine. Now, I have both Python 2.7 as well as Python 3.7.4 on my machine. Hence I wanted both versions of configparser to be installed.\nI have set the default python version to be Python 3.7.4. So I used this command first:\n1.pip3 install configparser:\nwhich gave me requirement satisfied since I already had installed it. \nNow, when I use:\n2.pip install configparser:\nit tells me that requirement is satisfied. But there is now package called configparser in Python 2.\nWhat do I have to do to install the Python2 version of configparser on my machine?\nThanks in advance.\nP.S: I use Windows 10, develop in PyCharm.\nAlso, pip -V gives me:\npip 19.1.1 from c:\\users\\ymodak\\appdata\\local\\programs\\python\\python37-32\\lib\\site-packages\\pip (python 3.7)","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1050,"Q_Id":56595246,"Users Score":0,"Answer":"in python 3, use\npython3 -m pip install configparser\nassuming that python3 is keyword to call python 3.7\nin python2, use\npython -m pip install configparser\nassume python is keyword to call python2","Q_Score":0,"Tags":"python,pip","A_Id":56595612,"CreationDate":"2019-06-14T09:27:00.000","Title":"Both commands give `Requirement already satisfied`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to install a package called configparser on my local machine. Now, I have both Python 2.7 as well as Python 3.7.4 on my machine. Hence I wanted both versions of configparser to be installed.\nI have set the default python version to be Python 3.7.4. So I used this command first:\n1.pip3 install configparser:\nwhich gave me requirement satisfied since I already had installed it. \nNow, when I use:\n2.pip install configparser:\nit tells me that requirement is satisfied. But there is now package called configparser in Python 2.\nWhat do I have to do to install the Python2 version of configparser on my machine?\nThanks in advance.\nP.S: I use Windows 10, develop in PyCharm.\nAlso, pip -V gives me:\npip 19.1.1 from c:\\users\\ymodak\\appdata\\local\\programs\\python\\python37-32\\lib\\site-packages\\pip (python 3.7)","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1050,"Q_Id":56595246,"Users Score":1,"Answer":"you need to set the path of your envernnement variable to where python 2  is installed\nor do this \"path to pip in python2 directory\"\/pip install \"Package\"\nif you want to configure pip to install packages on python 2 and pip3 to install packages on python3 you need to delete pip in python 3 directory and set both of paths in environnement variable python2 (path to pip in python2 directory)  and python3 (path to pip3 in python3 directory)","Q_Score":0,"Tags":"python,pip","A_Id":56595456,"CreationDate":"2019-06-14T09:27:00.000","Title":"Both commands give `Requirement already satisfied`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two dataframes :\n1st dataframe\n\ncat         2000    2001    2002    2003    2004    2005\n1            779     771     754     740     760     747\n2          1311.2   1285.2  1271.2  1276.5  1270.6  1281\n3           836      814    810      800     802     799\n4           914      892    888      878     880     877\n5           992      970    966      956     958     955\n\n2nd dataframe\n\n\nyear  data\n2000  1\n2001  4\n2002  7\n2003  10\n2004  6\n2005  3    \n\n\ni would like to merge above these two dataframe in following way?is it possible?\n\ncat         2000    2001    2002    2003    2004    2005\n1           779     771     754      740     760    747\n2          1311.2  1285.2   1271.2   1276.5 1270.6  1281\n3           836      814    810      800     802    799\n4           914      892    888      878     880    877\n5           992      970    966      956     958    955\n6(merge entry)1         4    7        10      6      3","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":56596244,"Users Score":0,"Answer":"It's not hard at all. You have to transpose the second dataframe and add its values in the rows of the first dataframe. Use the .T command.","Q_Score":0,"Tags":"python,python-3.x","A_Id":56596649,"CreationDate":"2019-06-14T10:25:00.000","Title":"Merge column data into row in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"'ipython' is not recognized as an internal or external command,\noperable program or batch file.\nI have tried reinstalling python with add python to path optin .But that didn't work either.\n'ipython' input \n'ipython' is not recognized as an internal or external command,\noperable program or batch file.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":56597423,"Users Score":0,"Answer":"Uninstalling and installing ipython worked for me (add --user in case you are using Linux), the following was run on MacOS:\npip3 uninstall ipython\n\npip3 install ipython\nIf the above doesn't work for you, the solution mentioned (here)[https:\/\/blog.karatos.in\/a?ID=00750-d6f5f14c-60f3-443d-b038-9356723547ef] might be of some help: -\n\nCheck IPython version (python3 -m IPython --version) to see if IPython has been installed correctly.\nCheck if running python3 -m IPython opens the python shell for you.\nSet an alias for the command python3 -m IPython in your .bash_profile file.","Q_Score":0,"Tags":"ipython","A_Id":72012903,"CreationDate":"2019-06-14T11:39:00.000","Title":"I have installed ipython ,but could not open it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have made a object recognition and detection model using tensorflow. It identifies the images which are clearly visible but its unable to identify if the same object is at a large distance. I am using Faster RCNN model.  the model is able to identify the same object when it is closer but not when it is at a far distance. It has been trained already for the same object. How can i make the model identify objects at a distance?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":56602594,"Users Score":0,"Answer":"You can resize and add padding using data augmentation to images with objects that are clearly visible so that they look like they are in a big distance and train your model further with those images","Q_Score":0,"Tags":"python-3.x,tensorflow,object-detection-api","A_Id":56603296,"CreationDate":"2019-06-14T17:11:00.000","Title":"Model unable to identify distant objects","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am comparing design choice of wrapping either each \"vector\" into Object, or each whole \"matrix\" of vectors into Object. \nI realize there will be more overhead if I try to wrap up each path by a class object, but it would make the system a lot easier to understand and implement.\nHowever, I thought this might cost us the performance.\nWhat would be a convention when it comes to loading big data as attributes?\nI appreciate your thoughts in advance,\nq","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":20,"Q_Id":56605145,"Users Score":1,"Answer":"It seems you want to \"wrap paths\" and store many attributes for those paths, and there are lots of \"paths\".\nInstead of defining classes that require lots of custom objects creation just for the paths themselves, store the paths (strings I suppose) as keys in a dict, and the attributes in any appropriate form inside.","Q_Score":0,"Tags":"python,performance,oop","A_Id":57694779,"CreationDate":"2019-06-14T21:09:00.000","Title":"Design Choice: how to wrap up large files with 100k+ vectors","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":"Learning python workflow on android tablet\nI have been using Qpython3 but find it unsatisfactory\nCan anybody tell me how best to learn the python workflow using an android tablet... that is what IDE works best with android and any links to pertinent information. Thank you.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2770,"Q_Id":56605247,"Users Score":1,"Answer":"Try pydroid3 instead of Qpython.it have almost all scientific Python libraries like Numpy,scikit-learn,matplotlib,pandas etc.All you have to do is to download the scripting library.You can save your file with extension ' .py ' and then upload it to drive and then to colab\nHope this will help.......","Q_Score":0,"Tags":"android,python","A_Id":59534068,"CreationDate":"2019-06-14T21:20:00.000","Title":"Using python on android tablet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to understand what the point of Pool.apply() is, within a parallelisation module.\nMy understanding is it is synchronous, and so no parallel processing occurs - but you just get the overhead of running code in separate processes.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":56606221,"Users Score":0,"Answer":"I agree that it's not useful for parallelization, but it might have other uses. For example, if by poor life choices, your function has an unholy mess of side effects like changing global variables (probably because you only intended to execute it in a Pool when writing it), running it in a separate process can help with that.\nOf course, using it like that is most likely an anti-pattern, so I guess this function only exists for compatibility reasons...","Q_Score":0,"Tags":"python,multiprocessing","A_Id":56607048,"CreationDate":"2019-06-14T23:42:00.000","Title":"What is the point of Pool.apply() in Python if it blocks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently trying to develop macros\/programs to help me edit a big database in Excel.\nJust recently I successfully wrote a custom macro in VBA, which stores two big arrays into memory, in memory it compares both arrays by only one column in each (for example by names), then the common items that reside in both arrays are copied into another temporary arrays TOGETHER with other entries in the same row of the array. So if row(11) name was \"Tom\", and it is common for both arrays, and next to Tom was his salary of 10,000 and his phone number, the entire row would be copied.\nThis was not easy, but I got to it somehow.\nNow, this works like a charm for arrays as big as 10,000 rows x 5 columns + another array of the same size 10,000 rows x 5 columns. It compares and writes back to a new sheet in a few seconds. Great!\nBut now I tried a much bigger array with this method, say 200,000 rows x 10 columns + second array to be compared 10,000 rows x 10 columns...and it took a lot of time.\nProblem is that Excel is only running at 25% CPU - I checked that online it is normal.\nThus, I am assuming that to get a better performance I would need to use another 'tool', in this case another programming language.\nI heard that Python is great, Python is easy etc. but I am no programmer, I just learned a few dozen object names and I know some logic so I got around in VBA.\nIs it Python? Or perhaps changing the programming language won't help? It is really important to me that the language is not too complicated - I've seen C++ and it stings my eyes, I literally have no idea what is going on in those codes.\nIf indeed python, what libraries should I start with? Perhaps learn some easy things first and then go into those arrays etc.?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":56607263,"Users Score":0,"Answer":"I have no intention of condescending but anything I say would sound like condescending, so so be it.\nThe operation you are doing is called join. It's a common operation in any kind of database. Unfortunately, Excel is not a database. \nI suspect that you are doing NxM operation in Excel. 200,000 rows x 10,000 rows operation quickly explodes. Pick a key in N, search a row in M, and produce result. When you do this, regardless of computer language, the computation order becomes so large that there is no way to finish the task in reasonable amount of time.\nIn this case, 200,000 rows x 10,000 rows require about 5,000 lookup per every row on average in 200,000 rows. That's 1,000,000,000 times.\nSo, how do the real databases do this in reasonable amount of time? Use index. When you look into this 10,000 rows of table, what you are looking for is indexed so searching a row becomes log2(10,000). The total order of computation becomes N * log2(M) which is far more manageable. If you hash the key, the search cost is almost O(1) - meaning it's constant. So, the computation order becomes N.\nWhat you are doing probably is, in real database term, full table scan. It is something to avoid for real database because it is slow.\nIf you use any real (SQL) database, or programming language that provides a key based search in dataset, your join will become really fast. It's nothing to do with any programming language. It is really a 101 of computer science.\nI do not know anything about what Excel can do. If Excel provides some facility to lookup a row based on indexing or hashing, you may be able to speed it up drastically.","Q_Score":0,"Tags":"python,arrays,excel,performance","A_Id":56608095,"CreationDate":"2019-06-15T04:10:00.000","Title":"Editing a big database in Excel - any easy to learn language that provides array manipulation except for VBA? Python? Which library?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Data similar to the images of 1000 x 1 pixels come from the equipment. Somewhere in the image may be 1, 2 or more objects. \nI'm going to build a neural network to detect objects. I want to make 1,000 outputs. Each output will indicate whether there is an object in that output or not. \nAdvise me which loss function to use.\nIt seems to me that \"categorical crossentropy\" is not suitable, because for example: in the training data, I will indicate that the objects are at 10 and 90 pixels. And the neural network will predict that the objects are at 11 and 89 pixels. It's not a big loss. But for the network, it will be the same loss as if it predict objects at 500 and 900 pixels. \nWhat loss function is suitable for such a case ?\nI'm using Keras","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":469,"Q_Id":56608876,"Users Score":0,"Answer":"You can use binary cross entropy loss and set the nearest n-bins to the ground truth as labels.\nFor example, you have 10 pixels and ground truth label is 3 and you selected 3 neighbours.\nIn typical categorical cross entropy, you would set label as follow using one-hot encoded vector.\n[0 0 1 0 0 0 0 0 0 0]\nIn the solution I suggested, you would use this\n[0 1 1 1 0 0 0 0 0 0]\nOr it can be this, basically imposing a Gaussian instead of flat labels.\n[0 0.5 1 0.5 0 0 0 0 0 0]\n\nObject detection architectures as suggested in the comments also essentially behave the same way I described. Except that they use a quantized scheme\n[0 1 0 0 0 0 0 0 0] (actual pixels)\n[- - 1 - - - - 0 - -] (group into 2 groups of 5. Your network only has two outputs now. Think of this as binning stage, as the actual pixel belong to group 1. this subnetwork uses binary cross entropy).\n[1 0] (first classification network output)\n[-1 0] (this second stage can be thought of as delta network, it takes the classified bin value from first stage and outputs a correction value, as the first bin is anchored at index 2, you need to predict -1 to move it to index 1. this network is trained using smoothed l1 loss).\nNow there is immediately a problem, what if there are two objects in  group 1? This is an unfortunate problem which also exists in object detection architecture. The way to workaround with this is to define slightly shifted and scaled bin(or anchor) positions. This way you can detect at one pixel maximum of N objects where N is the number of anchors defined at that pixel.","Q_Score":0,"Tags":"python,keras,neural-network,loss-function","A_Id":56609093,"CreationDate":"2019-06-15T08:50:00.000","Title":"Which loss function to use when there are many outputs?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Tensorflow library was working on my system, I have installed other library now tensorflow is not working. I am using window 10. python 3.7, tensorflow 1.13.1.\nI am getting following error:\nFile \"\", line 1, in \n    runfile('C:\/Users\/Yogesh\/.spyder-py3\/MNISTBasicClassification.py', wdir='C:\/Users\/Yogesh\/.spyder-py3')\nFile \"C:\\Users\\Yogesh\\Anaconda3\\lib\\site-packages\\spyder_kernels\\customize\\spydercustomize.py\", line 704, in runfile\n    execfile(filename, namespace)\nFile \"C:\\Users\\Yogesh\\Anaconda3\\lib\\site-packages\\spyder_kernels\\customize\\spydercustomize.py\", line 108, in execfile\n    exec(compile(f.read(), filename, 'exec'), namespace)\nFile \"C:\/Users\/Yogesh\/.spyder-py3\/MNISTBasicClassification.py\", line 58, in \n    model.fit(train_images, train_labels, epochs=5)\nFile \"C:\\Users\\Yogesh\\Anaconda3\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training.py\", line 880, in fit\n    validation_steps=validation_steps)\nFile \"C:\\Users\\Yogesh\\Anaconda3\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training_arrays.py\", line 251, in model_iteration\n    model.reset_metrics()\nFile \"C:\\Users\\Yogesh\\Anaconda3\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training.py\", line 1119, in reset_metrics\n    m.reset_states()\nFile \"C:\\Users\\Yogesh\\Anaconda3\\lib\\site-packages\\tensorflow\\python\\keras\\metrics.py\", line 460, in reset_states\n    K.set_value(v, 0)\nFile \"C:\\Users\\Yogesh\\Anaconda3\\lib\\site-packages\\tensorflow\\python\\keras\\backend.py\", line 2847, in set_value\n    get_session().run(assign_op, feed_dict={assign_placeholder: value})\nFile \"C:\\Users\\Yogesh\\Anaconda3\\lib\\site-packages\\tensorflow\\python\\keras\\backend.py\", line 479, in get_session\n    session = _get_session()\nFile \"C:\\Users\\Yogesh\\Anaconda3\\lib\\site-packages\\tensorflow\\python\\keras\\backend.py\", line 457, in _get_session\n    config=get_default_session_config())\nFile \"C:\\Users\\Yogesh\\Anaconda3\\lib\\site-packages\\tensorflow\\python\\client\\session.py\", line 1551, in init\n    super(Session, self).init(target, graph, config=config)\nFile \"C:\\Users\\Yogesh\\Anaconda3\\lib\\site-packages\\tensorflow\\python\\client\\session.py\", line 676, in init\n    self._session = tf_session.TF_NewSessionRef(self._graph._c_graph, opts)\nInternalError: cudaGetDevice() failed. Status: CUDA driver version is insufficient for CUDA runtime version","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":56609576,"Users Score":0,"Answer":"I uninstalled the tensorflow and then created a new environment and then reinstalled the tensorflow then the issue was resolved.","Q_Score":0,"Tags":"python,tensorflow","A_Id":56632620,"CreationDate":"2019-06-15T10:41:00.000","Title":"tensor flow is not working in anaconda gettting CUDA runtime version error on window system","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My Python code constructs a string in the form\nmyCmd = 'databricks fs cp dbfs:\/mnt\/extracts\/dsp\/{}\/full.xml \"{}\"'.format(extractId, file_path)\nThis results in a string like this:\ndatabricks fs cp dbfs:\/\/mt\/extracts\/dsp\/123\/full.xml \"c:\\filepath\\full.xml\"\nWhen I attempt to run this string using os.system(myCmd) I'm given the following warning (either within the Python console, or in the cmd window):\nError: InvalidConfigurationError: You haven't configured the CLI yet! Please configure by entering `C:\\Users\\xxxx\\AppData\\Local\\Continuum\\anaconda3\\Scripts\\databricks configure\nBut when i copy and paste the constructed myCmd to the command prompt the databricks copy works fine.\nI've tried running databricks configure then re-running the Python code, and that doesn't work.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6839,"Q_Id":56611207,"Users Score":0,"Answer":"I also had same error message in different context when dealing with mlflow objects\nLater I observed that I was getting this error only when I install mlflow as\n!pip install mlflow\ninstead of\n%pip install mlflow","Q_Score":0,"Tags":"python,python-3.x,command-line,databricks","A_Id":71694385,"CreationDate":"2019-06-15T14:21:00.000","Title":"Databricks command says databricks-cli isn't configured when run from Python (with os.system()) but works fine when pasted into command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My Python code constructs a string in the form\nmyCmd = 'databricks fs cp dbfs:\/mnt\/extracts\/dsp\/{}\/full.xml \"{}\"'.format(extractId, file_path)\nThis results in a string like this:\ndatabricks fs cp dbfs:\/\/mt\/extracts\/dsp\/123\/full.xml \"c:\\filepath\\full.xml\"\nWhen I attempt to run this string using os.system(myCmd) I'm given the following warning (either within the Python console, or in the cmd window):\nError: InvalidConfigurationError: You haven't configured the CLI yet! Please configure by entering `C:\\Users\\xxxx\\AppData\\Local\\Continuum\\anaconda3\\Scripts\\databricks configure\nBut when i copy and paste the constructed myCmd to the command prompt the databricks copy works fine.\nI've tried running databricks configure then re-running the Python code, and that doesn't work.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6839,"Q_Id":56611207,"Users Score":0,"Answer":"Same issue for me. It said \"You haven't configured the CLI yet!\" from within the Python Notebook. I changed the Python version to 3 from 2 and it worked fine. Also changing the Databricks Runtime version to something like 5.5-LTS-ML fixes the issue.","Q_Score":0,"Tags":"python,python-3.x,command-line,databricks","A_Id":59011680,"CreationDate":"2019-06-15T14:21:00.000","Title":"Databricks command says databricks-cli isn't configured when run from Python (with os.system()) but works fine when pasted into command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm practising Python and I couldn't think of any solution to this problem.\nThe problem is to remove kth last element from a singly linked list in just one pass and constant space.\nI can only think of a solution that requires 2 passes.\nAlso, in the question, the size of the list was not mentioned, so I'm assuming the size is known apriori.\nCan anyone show me a way to do it in a single pass, please?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":184,"Q_Id":56612160,"Users Score":1,"Answer":"If the size is known then you want to remove the s - kth element.\nIf it's not the case then I would use two runners, one is k indices ahead of the second one. When your first runner reaches the end of your list, your second runner is exactly pointing to the kth last element.","Q_Score":1,"Tags":"python,singly-linked-list","A_Id":56612236,"CreationDate":"2019-06-15T16:24:00.000","Title":"Remove kth last element from a Singly Linked List in a single pass","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm practising Python and I couldn't think of any solution to this problem.\nThe problem is to remove kth last element from a singly linked list in just one pass and constant space.\nI can only think of a solution that requires 2 passes.\nAlso, in the question, the size of the list was not mentioned, so I'm assuming the size is known apriori.\nCan anyone show me a way to do it in a single pass, please?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":184,"Q_Id":56612160,"Users Score":1,"Answer":"Cache the pointer\/location of the item before the item to be removed, in a temp variable as you go along.\nSo there would be one loop, iterating to the end.\nThere would be a statement that caches (i-k-1)th element in temp.\nWhen this loop ends, temp would have the location of the item to be removed.\nHope this helps.","Q_Score":1,"Tags":"python,singly-linked-list","A_Id":56612207,"CreationDate":"2019-06-15T16:24:00.000","Title":"Remove kth last element from a Singly Linked List in a single pass","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i used in my code from sklearn.cross_validation import KFold and it was working without no issue .\nnow i got error ModuleNotFoundError: No module named 'sklearn.cross_validation'\ni google it and i found that the package function is renamed to model_selection instead of cross_validation but i have to use KFold function from  sklearn.cross_validation import KFold.\nthe sklearn version i have is 0.20.1 with Python 3.7.1 \nusing KFold which is a method already implemented in  sklearn.cross_validation\nfrom sklearn.cross_validation import KFold\nexpected to run sucessfully as before but i got below error:\nModuleNotFoundError: No module named 'sklearn.cross_validation'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":815,"Q_Id":56613045,"Users Score":0,"Answer":"Issue resolved by importing the supported package which is from sklearn.model_selection import KFold\nthen modifying KFold method with correct parameters as below\nKFold(n_splits=2, random_state=None, shuffle=False)","Q_Score":0,"Tags":"python-3.7","A_Id":56613628,"CreationDate":"2019-06-15T18:22:00.000","Title":"from sklearn.cross_validation import KFold renaming and depreaction of cross_validation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am calling a web API in Python, getting data back in XML, converting the response into a dictionary using xmltodict, but for several elements, sometimes I get a dictionary (single element) and sometimes I get a list (multiple elements) in response.\nI first started to use \"if isinstance(..., dict):\" - that could solve my problem but is not so elegant and requires quite some lines of code in my case.\nI then found out \"force_list\" which I think is exactly what I need, but I need to apply it to several elements and I can't find the right syntax - I'm not even sure if that's possible.\nThe code I am trying to make work:\nresponse = xmltodict.parse(xml, force_list=({'Child'},{'Brother'}))\nWith force_list={'Child'} only, the code works as expected.\nWith the above code, I do not get any error message but when checking the result with the \"type\" function, I still have dictionaries where I would expect to get lists.\nI tried other syntax and got error messages.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1419,"Q_Id":56613717,"Users Score":2,"Answer":"I think I found the right syntax (it seems to be working as I expected):\nresponse = xmltodict.parse(xml, force_list=('Child','Brother'))\nJust posting in case anyone would look for the same answer in the future.","Q_Score":2,"Tags":"python,xmltodict","A_Id":56636203,"CreationDate":"2019-06-15T19:53:00.000","Title":"Can I \"force_list\" more than one parameter in xmltodict?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running Wing IDE 5 with Python 2.4. Everything was fine until I tried to debug and set a breakpoint. Arriving at the breakpoint I get an error message: \n\"The debug server encountered an error in probing locals or globals...\"\nAnd the Stack Data display looks like:\n    locals  \n    globals  \nI am not, to my knowledge, using a server client relationship or anything special, I am simply debugging a single threaded program running directly under the IDE. Anybody seen this or know how to fix it?\nWing IDE 5.0.9-1","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":239,"Q_Id":56615332,"Users Score":0,"Answer":"That's a pretty old version of Wing and likely a bug that's been fixed since then, so trying a newer version of Wing may solve it.\nHowever, if you are stuck with Python 2.4 then that's the latest that supports it (except that unofficially Wing 6 may work with Python 2.4 on Windows).  \nA work-around would be to inspect data from the Debug Probe and\/or Watch tools (both available in the Tools menu).\nAlso, Clear Stored Value Errors in the Debug menu may allow Wing to load the data in a later run if the problem doesn't reoccur.","Q_Score":1,"Tags":"python,debugging,wing-ide","A_Id":56631566,"CreationDate":"2019-06-16T01:10:00.000","Title":"Wing IDE The debug server encountered an error in probing locals","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to get the path of invoked (top-level) Python script. Actually it is a package and I am running it with python3 -m <package-name>. I researched web and Stack Overflow but couldn't find a proper solution. __file__ and __path__ are not working, os.getcwd() doesn't work if the package is invoked from another location, sys.argv[0] is not guaranteed to have the full path. The way import __main__ is not a good way I think since I import the top-level script into a dependent script.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":250,"Q_Id":56620387,"Users Score":-1,"Answer":"I encountered the problem of open(\"xyz.dat\",\"r\") not finding xyz.dat in the same folder as the .py file\nSolved my problem by adding \"working_dir\": \"$file_path\" to my Sublime Text 3 build script.\nHowever, I wondered how python libraries did it.  For example, Kivy's AsyncImage has a \"source\" parameter to its constructor that successfully finds image files in the same folder as the top-level py file.\nAfter some digging, I discovered the method that Kivy uses:\n\nimport kivy.resources as kr\nfull_path = kr.resource_find(\"image.png\")\n\nI do not like to rely on a setting in a build script to find files in the same folder, so this is the method I'm going to follow in future Kivy projects.\nBTW, resource_find does rely on sys.argv[0] to \"know\" the full path of the top-level python script.","Q_Score":2,"Tags":"python","A_Id":67192928,"CreationDate":"2019-06-16T15:47:00.000","Title":"Getting path of the top-level 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Recently, I read a book on Numpy which mentions different types of ufuncs, where I was encountered with two different ufuncs, namely 'modulus', denoted by % symbol and 'floor division' \/\/. Can someone explain the difference between them and why two operators are provided to do the the same thing (display reminder of division, according to me)? Please correct, if I am wrong.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8915,"Q_Id":56627393,"Users Score":0,"Answer":"Assume a= 10, b = 6\na%b will give you the remainder, that is 4\na\/\/b will give you the quotient, that is 1","Q_Score":0,"Tags":"python,numpy,integer-division","A_Id":56627542,"CreationDate":"2019-06-17T08:20:00.000","Title":"Difference between modulus (%) and floor division(\/\/) in NumPy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"thanks for hearing me out.\nI have a dataset that is a matrix of shape 75000x10000 filled with float values. Think of it like heatmap\/correlation matrix. I want to store this in a SQLite database (SQLite because I am modifying an existing Django project). The source data file is 8 GB in size and I am trying to use python to carry out my task.\nI have tried to use pandas chunking to read the file into python and transform it into unstacked pairwise indexed data and write it out onto a json file. But this method is eating up my computational cost. For a chunk of size 100x10000 it generates a 200 MB json file.\nThis json file will be used as a fixture to form the SQLite database in Django backend.\nIs there a better way to do this? Faster\/Smarter way. I don't think a 90 GB odd json file written out taking a full day is the way to go. Not even sure if Django databases can take this load.\nAny help is appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":124,"Q_Id":56633576,"Users Score":2,"Answer":"SQLite is quite impressive for what it is, but it's probably not going to give you the performance you are looking for at that scale, so even though your existing project is Django on SQLite I would recommend simply writing a Python wrapper for a different data backend and just using that from within Django.\nMore importantly, forget about using Django models for something like this; they are an abstraction layer built for convenience (mapping database records to Python objects), not for performance. Django would very quickly choke trying to build 100s of millions of objects since it doesn't understand what you're trying to achieve.\nInstead, you'll want to use a database type \/ engine that's suited to the type of queries you want to make; if a typical query consists of a hundred point queries to get the data in particular 'cells', a key-value store might be ideal; if you're typically pulling ranges of values in individual 'rows' or 'columns' then that's something to optimize for; if your queries typically involve taking sub-matrices and performing predictable operations on them then you might improve the performance significantly by precalculating certain cumulative values; and if you want to use the full dataset to train machine learning models, you're probably better off not using a database for your primary storage at all (since databases by nature sacrifice fast-retrieval-of-full-raw-data for fast-calculations-on-interesting-subsets), especially if your ML models can be parallelised using something like Spark.\nNo DB will handle everything well, so it would be useful if you could elaborate on the workload you'll be running on top of that data -- the kind of questions you want to ask of it?","Q_Score":0,"Tags":"python,sql,django,pandas,bigdata","A_Id":56656088,"CreationDate":"2019-06-17T14:39:00.000","Title":"I want to write a 75000x10000 matrix with float values effectively into a database","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to use cplex with python version 3.7.3. CPLEX has a setup.py for version 3.7, but when I try to use it I still get the error \"CPLEX 12.9.0.0 is not compatible with this version of Python\". Is there a workaround for this or do I need to downgrade to Python 3.6?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":4399,"Q_Id":56634674,"Users Score":1,"Answer":"Yes,\nTo my knowledge for the optimization solvers\nCPLEX and DOCPLEX you need to downgrade to Python 3.6 currently.","Q_Score":1,"Tags":"python,cplex","A_Id":56635019,"CreationDate":"2019-06-17T15:41:00.000","Title":"CPLEX and Python 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use cplex with python version 3.7.3. CPLEX has a setup.py for version 3.7, but when I try to use it I still get the error \"CPLEX 12.9.0.0 is not compatible with this version of Python\". Is there a workaround for this or do I need to downgrade to Python 3.6?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4399,"Q_Id":56634674,"Users Score":0,"Answer":"I myself had to downgrade to Python 3.6 because I had the same problem but that was because Python 3.7 is 32-bit and the CPLEX API requires 64-bit (I can't tell you why, but that's just what I learned). Once you install Python 3.6 64-bit then you can download the CPLEX and DOPLEX packages so easily you'll hate that you didn't do it in the first place.","Q_Score":1,"Tags":"python,cplex","A_Id":56941246,"CreationDate":"2019-06-17T15:41:00.000","Title":"CPLEX and Python 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Azure Datascience VM with Nvidia Gpu extension\nUbuntu 16.04.6 LTS\nPython 3.5.5\nNVCC V10.0.130\nTensorflow-gpu 1.13.1\n\nWhen runnning an op, I get\n\nE tensorflow\/stream_executor\/cuda\/cuda_driver.cc:300] failed call to\n  cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":56642210,"Users Score":0,"Answer":"what is the size of the VM you are using on Azure ?","Q_Score":0,"Tags":"python,azure,tensorflow","A_Id":56644886,"CreationDate":"2019-06-18T05:24:00.000","Title":"Enabling Cuda on Azure Datascience VM","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I know that pytest is integratabtle with Jenkins. Is pytest-benchmark integratabtle with Jenkins?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":56642698,"Users Score":-2,"Answer":"yes both pytest and pytest-benchmark are integratable with Jenkins ( source: comment )","Q_Score":0,"Tags":"python,jenkins,continuous-integration,pytest","A_Id":56659711,"CreationDate":"2019-06-18T06:12:00.000","Title":"pytest-benchmark integration with Jenkins","Data Science and Machine Learning":0,"Database and SQL":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 try to run the azure function app (Http Triggerd API) from my local (using VS code). But I'm getting an error \"port 7071 is unavailable. Close the process using that port, or specify another port using --port [-p].\" I checked the list of ports used using cmd prompt.But 7071 is not in used list. Also tried to run with different port using \"func host start --port [p1]\", but it throws the same error as above. For all ports it throws the same error. How to resolve this problem?","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":10933,"Q_Id":56648386,"Users Score":0,"Answer":"On Windows, Adding ports in the Windows firewall rules solved the issue for me.","Q_Score":11,"Tags":"python-3.x,windows,azure,visual-studio-code,azure-functions","A_Id":59317367,"CreationDate":"2019-06-18T11:44:00.000","Title":"port 7071 is unavailable. Close the process using that port, or specify another port using --port [-p]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I try to run the azure function app (Http Triggerd API) from my local (using VS code). But I'm getting an error \"port 7071 is unavailable. Close the process using that port, or specify another port using --port [-p].\" I checked the list of ports used using cmd prompt.But 7071 is not in used list. Also tried to run with different port using \"func host start --port [p1]\", but it throws the same error as above. For all ports it throws the same error. How to resolve this problem?","AnswerCount":8,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":10933,"Q_Id":56648386,"Users Score":0,"Answer":"Its due to the antivirus. After disabling the antivirus it works fine.","Q_Score":11,"Tags":"python-3.x,windows,azure,visual-studio-code,azure-functions","A_Id":56650533,"CreationDate":"2019-06-18T11:44:00.000","Title":"port 7071 is unavailable. Close the process using that port, or specify another port using --port [-p]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I try to run the azure function app (Http Triggerd API) from my local (using VS code). But I'm getting an error \"port 7071 is unavailable. Close the process using that port, or specify another port using --port [-p].\" I checked the list of ports used using cmd prompt.But 7071 is not in used list. Also tried to run with different port using \"func host start --port [p1]\", but it throws the same error as above. For all ports it throws the same error. How to resolve this problem?","AnswerCount":8,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":10933,"Q_Id":56648386,"Users Score":4,"Answer":"If running in development make sure you don't have another azure function sitting in debug mode. I was getting this error until I stopped the other function.","Q_Score":11,"Tags":"python-3.x,windows,azure,visual-studio-code,azure-functions","A_Id":59418734,"CreationDate":"2019-06-18T11:44:00.000","Title":"port 7071 is unavailable. Close the process using that port, or specify another port using --port [-p]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I try to run the azure function app (Http Triggerd API) from my local (using VS code). But I'm getting an error \"port 7071 is unavailable. Close the process using that port, or specify another port using --port [-p].\" I checked the list of ports used using cmd prompt.But 7071 is not in used list. Also tried to run with different port using \"func host start --port [p1]\", but it throws the same error as above. For all ports it throws the same error. How to resolve this problem?","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":10933,"Q_Id":56648386,"Users Score":0,"Answer":"Not sure why this resolved it for me, but I had to restart my machine then all was fine.","Q_Score":11,"Tags":"python-3.x,windows,azure,visual-studio-code,azure-functions","A_Id":66373054,"CreationDate":"2019-06-18T11:44:00.000","Title":"port 7071 is unavailable. Close the process using that port, or specify another port using --port [-p]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am having a model Employee with a OneToOneField relationship with Django USER model. Now for some reason, I want to change it to the ManyToOne(ForeignKey) relationship with the User model.\nBoth these tables have data filled. Without losing the data how can I change it?\nCan I simply change the relationship and migrate?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":151,"Q_Id":56648907,"Users Score":0,"Answer":"makemigrations in this case would only correspond to an sql of Alter field you can see the result of makemigrations, the same sql will be executed when you migrate the model so the data would not be affected","Q_Score":1,"Tags":"python,django","A_Id":56649220,"CreationDate":"2019-06-18T12:13:00.000","Title":"How to change a OneToOneField into ForeignKey in django model with data in both table?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For the sake of curiosity is there any practical difference between getting the column names of a DataFrame (let's say df) by using df.columns or df.keys()? \nI've checked the outs by type and it seems to be exactly the same. Am I missing something or these two methods are just as redundant as it seems? Is one more appropriate to use than the other?\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1291,"Q_Id":56649500,"Users Score":3,"Answer":"one difference I noticed That you can Use .keys() with Series but You can not use .columns with Series .","Q_Score":3,"Tags":"python-3.x,pandas,dataframe","A_Id":62995790,"CreationDate":"2019-06-18T12:45:00.000","Title":"Is there any difference between using Dataframe.columns and Dataframe.keys() to obtain the column names?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Created a model in odoo 11, I want to load different tree views based on a filter, these tree views will be showing different columns and column headers","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":78,"Q_Id":56649905,"Users Score":1,"Answer":"If you want to show tree view according to user you can do that by applying group on views or if you want to show different view according to different value you can set thier view id.","Q_Score":0,"Tags":"python-3.x,odoo-11","A_Id":56700199,"CreationDate":"2019-06-18T13:07:00.000","Title":"Odoo 11 Switch between tree views for the same model based on conditions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have Created a model in odoo 11, I want to load different tree views based on a filter, these tree views will be showing different columns and column headers","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":56649905,"Users Score":0,"Answer":"Or I could create groups and actions and the different views to load for each user in a specific group using domains in the action.\nI think that could also actually work in this case.","Q_Score":0,"Tags":"python-3.x,odoo-11","A_Id":58852043,"CreationDate":"2019-06-18T13:07:00.000","Title":"Odoo 11 Switch between tree views for the same model based on conditions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If in the presence of GIL, all subtasks performed in a multithreading program occur sequentially, then it is equivalent to single threaded program. Why were multithreading packages (multiprocessing.dummy.Pool, multiprocessing.pool.ThreadPool, concurrent.futures.ThreadPoolExecutor, etc) in Python written? Why should someone use them?\n(This is not about Multiprocessing)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":166,"Q_Id":56650776,"Users Score":1,"Answer":"Two things:\n\nGIL is released from time to time. For example when you try to execute some lengthy operation (read from file, write to file, send over network and so on). This allows for some interleaved operations - read in one thread, process in another.\nMultithreading is not only performance, there're other benefits - for example easiness of expression. Imagine you've two algorithms running in \"parallel\", which communicate with each other and exchange data. You put each algorithm on it's own thread, synchronize (to make sure thread switch will happen when it can) and off you go. Without multithreading you'd have to rely on event programming, which is difficult and easily scalable. The good example for this are various kinds of session based servers, for example ftp server. It's much easier to write multithreaded multiuser ftp server, than single threaded.\n\nIn general yes, if you use threads for performace then python's threads don't make sense. But python is not used for performance, but for how easy it's to write (and modify) code. And threads do help for parallel code a lot, even if they don't offer any multhreading performance benefits.","Q_Score":0,"Tags":"python,python-3.x,multithreading","A_Id":56651184,"CreationDate":"2019-06-18T13:52:00.000","Title":"What advantage will multithreading give in presence of GIL?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In a Python 3.7 shell I get some unexpected results when escaping strings, see examples below. Got the same results in the Python 2.7 shell.\nA quick read in the Python docs seems to say that escaping can be done in strings, but doesn't seem to say it can't be used in the shell. (Or I have missed it).\nCan someone explain why escaping doesn't seem to work as expected.\nExample one:\ninput:\n>>> \"I am 6'2\\\" tall\"\noutput:\n'I am 6\\'2\" tall'\nwhile >>> print(\"I am 6'2\\\" tall\")\nreturns (what I expected):\nI am 6'2\" tall\n(I also wonder how the backslash, in the unexpected result, ends up behind the 6?)\nAnother example:\ninput:\n>>> \"\\tI'm tabbed in.\"\noutput:\n\"\\tI'm tabbed in.\"\nWhen inside print() the tab is replaced with a proper tab. (Can't show it, because stackoverflow seems the remove the tab\/spaces in front of the line I use inside a code block).","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":24,"Q_Id":56651066,"Users Score":2,"Answer":"The interactive shell will give you a representation of the return value of your last command. It gives you that value using the repr() method, which tries to give a valid source code representation of the value; i.e. something you could copy and paste into code as is.\nprint on the other hand prints the contents of the string to the console, without regards whether it would be valid source code or not.","Q_Score":0,"Tags":"python,escaping","A_Id":56651143,"CreationDate":"2019-06-18T14:09:00.000","Title":"Does escaping work differently in Python shell? (Compared to code in file)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with an Altera DE1-SoC board where I am reading data from a sensor using a C program. The data is being read continually, in a while loop and written to a text file. I want to read this data using a python program and display the data.\nThe problem is that I am not sure how to avoid collision during the read\/write from the file as these need to happen simultaneously. I was thinking of creating a mutex, but I am not sure how to implement it so the two different program languages can work with it. \nIs there a simple way to do this? Thanks.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":524,"Q_Id":56652022,"Users Score":1,"Answer":"You could load a C library into Python using cdll.LoadLibrary and call a function to get the status of the C mutex. Then in Python if the C mutex is locking then don't read, and if it is unlocked then it can read.","Q_Score":1,"Tags":"python,c,io,mutex","A_Id":56652310,"CreationDate":"2019-06-18T15:01:00.000","Title":"Writing to a file in C while reading from it in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with an Altera DE1-SoC board where I am reading data from a sensor using a C program. The data is being read continually, in a while loop and written to a text file. I want to read this data using a python program and display the data.\nThe problem is that I am not sure how to avoid collision during the read\/write from the file as these need to happen simultaneously. I was thinking of creating a mutex, but I am not sure how to implement it so the two different program languages can work with it. \nIs there a simple way to do this? Thanks.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":524,"Q_Id":56652022,"Users Score":1,"Answer":"Operating system will take care of this as long as you can open that file twice (one for read and one for write). Just remember to flush from C code to make sure your data are actually written to disk, instead of being kept in cache in memory.","Q_Score":1,"Tags":"python,c,io,mutex","A_Id":56652594,"CreationDate":"2019-06-18T15:01:00.000","Title":"Writing to a file in C while reading from it in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m trying to send a large parquet file to RDS Postgres using Lambda. When I try to test the lambda function. I\u2019m facing the below error:\nCalling the invoke API action failed with this message: Network Error\nI tried sending with limited rows, I haven\u2019t faced any issue but when I tried to send the whole file which is of 300 mb, then I\u2019m getting the above error.\nCan someone help me with this?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":7702,"Q_Id":56652783,"Users Score":0,"Answer":"I had this problem when the Lambda function was inside a VPC and couldn't mount my EFS volume via File System Config. This was with a totally empty new function, no code yet.\nNo solution yet but that might get you started down the correct path.","Q_Score":10,"Tags":"python","A_Id":72070877,"CreationDate":"2019-06-18T15:46:00.000","Title":"Calling the invoke API action failed with this message: Network Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m trying to send a large parquet file to RDS Postgres using Lambda. When I try to test the lambda function. I\u2019m facing the below error:\nCalling the invoke API action failed with this message: Network Error\nI tried sending with limited rows, I haven\u2019t faced any issue but when I tried to send the whole file which is of 300 mb, then I\u2019m getting the above error.\nCan someone help me with this?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":7702,"Q_Id":56652783,"Users Score":0,"Answer":"Update your browser to latest version. Some browsers with additional built-in features may block necessary script on web page.","Q_Score":10,"Tags":"python","A_Id":63502397,"CreationDate":"2019-06-18T15:46:00.000","Title":"Calling the invoke API action failed with this message: Network Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m trying to send a large parquet file to RDS Postgres using Lambda. When I try to test the lambda function. I\u2019m facing the below error:\nCalling the invoke API action failed with this message: Network Error\nI tried sending with limited rows, I haven\u2019t faced any issue but when I tried to send the whole file which is of 300 mb, then I\u2019m getting the above error.\nCan someone help me with this?","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":7702,"Q_Id":56652783,"Users Score":9,"Answer":"I got the same error, which was weird because it was working fine for very small files. I tried with a larger file (only 5mb), and got the error message.\nSolution: check the memory allocation for the lambda function. I was using the standard minimum (128mb). Changed it to 1gb, it worked fine. The error message is horrible.","Q_Score":10,"Tags":"python","A_Id":59071261,"CreationDate":"2019-06-18T15:46:00.000","Title":"Calling the invoke API action failed with this message: Network Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m trying to send a large parquet file to RDS Postgres using Lambda. When I try to test the lambda function. I\u2019m facing the below error:\nCalling the invoke API action failed with this message: Network Error\nI tried sending with limited rows, I haven\u2019t faced any issue but when I tried to send the whole file which is of 300 mb, then I\u2019m getting the above error.\nCan someone help me with this?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":7702,"Q_Id":56652783,"Users Score":0,"Answer":"I get this error every time I set up a Lambda, and then it disappears over the space of a day. Not sure why though.","Q_Score":10,"Tags":"python","A_Id":58645065,"CreationDate":"2019-06-18T15:46:00.000","Title":"Calling the invoke API action failed with this message: Network Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Each morning, a config file is fed with a list of hours. Hours in the json file are different each days.\nI would like a python script to be executed for each hour of the configuration file.  What is the best way to do this? \nDo I have to do a loop while? What is the best practice?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":203,"Q_Id":56654162,"Users Score":0,"Answer":"You can set up a cronjob that reads the config file and executes the python scripts every morning.","Q_Score":0,"Tags":"python-3.x,config","A_Id":56654217,"CreationDate":"2019-06-18T17:21:00.000","Title":"Launch python script based on a dynamic config file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have geoalchemy2 on my machine. If I import geoalchemy2 and run geoalchemy2.shape, I got: AttributeError: module 'geoalchemy2' has no attribute 'shape'. But if I run geoalchemy2.shape.to_shape(), it can find the method... I am confused on the differences between the two usage of geoalchemy2.shape. Why the differences happen?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":56658429,"Users Score":0,"Answer":"For me this happened if shapely is not installed in the environment, got it when dockerizing an app.","Q_Score":0,"Tags":"python,geoalchemy2","A_Id":58772521,"CreationDate":"2019-06-18T23:53:00.000","Title":"how is geoalchemy2.shape defined and imported?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a program in Python where I have 2 intervals as an input and then it has to return 3 operations:\n- union (A | B)\n- intersection (A & B)\n- difference \nI've tried making sets for intervals A and B and then subtract them with set method (A-B) but it has no sense as it has to return an interval, not a set and I distinguish between open \/ closed \/ open_closed etc intervals.\ninput: \n[3, 10)\n(5, 16]\noutput:\nDifference A\\B: [3,5]\nDifference B\\A: [10, 16]","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3947,"Q_Id":56658557,"Users Score":0,"Answer":"Have you tried populating your set representations of the intervals and then applying set operations? For example:\ninterval [3,10) -> set(3,4,5,6,7,8,9)\ninterval (5,16] -> set(6,7,8,9,10,11,12,13,14,15,16)\nPerhaps range would be helpful in the gap-filling part.","Q_Score":1,"Tags":"python,algorithm,intervals","A_Id":56658667,"CreationDate":"2019-06-19T00:17:00.000","Title":"What is the algorithm for two intervals difference?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to see if this is a duplicate, but was unable to find exactly this question.  I'm also pretty ignorant regarding this stuff.\nI am using Python 3.7.2 (the only version of python on my windows 10 computer) and have created a virtual environment using venv:\npython -m venv \/path\/to\/new\/virtual\/environment\nI added some packages via pip install and created a requirements.txt file via pip freeze.  I wrote some code using packages from the virtual environment.\nI would like to share my code with colleagues.  I can give them the code and the requirements file, but requirements.txt doesn't specify which version of python I used (3.7.2).  What is the appropriate mechanism to communicate this information to my colleagues?  Can the requirements.txt file be amended to include the fact that I used 3.7.2 and that anyone running my code should also use 3.7.2?  Would the answer to this question depend on whether I or my colleagues have multiple version of python installed on our computers?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":643,"Q_Id":56659034,"Users Score":0,"Answer":"Venv with different version of python is more important when you have a system with multiple versions of python.  For example, CentOS 7 EPEL comes with python 2.7 and python 3.4 installed.  When you attempt to find a more recent version, you can't find it in the official repositories.  That is because the long term support model pin certain embedded tools to a specific version and only provide support for bug fixes.  3.4.1  could be the intial version, but updates are available for 3.4.2 and 3.4.3.  So how do you use 3.5 or 3.6 or 3.7?  You build it from source and install it in an alternative location  (\/usr\/local\/bin  or \/usr\/opt\/bin).\nThis where Venv really shines.\nFrom a regular prompt, python3  will invoke python3.4  and python will invoke 2.7.\nBut you can use the python of your choice for development.\nExample:  You install python3.7 in the alt location.  System python is unchanged and all system utilities work as they should.\n\/usr\/local\/bin\/python3.7 -m venv mypython_dir  creates a new virtual environment.\nsource mypython_dir\/bin\/activate will activate the that environment\nFrom that point on python is python3.7 and pip is pip3.7  from the \/usr\/local\/bin directory that was copied into the venv directory.\nOn windows this is less of an issue since python is not embedded at the system level.  You'll see a lot of question for linux systems where people have forced an upgrade to system python on a LTS version.  Bad things happen.  If you want or need a specific version to run your module then Grismar's answer above is what you want to do.","Q_Score":1,"Tags":"python,pip,virtualenv","A_Id":56659393,"CreationDate":"2019-06-19T01:48:00.000","Title":"How to specify exact version of python as part of virtual environment requirements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my view I generate 5 images (they are generated by pyplot.)\nEverything seems to work fine.  The files are generated correctly in the right directory.\nBut the browser only shows one of the five images, and the requests for the other 4 usually timeout.  Looking at the django server output, the GET requests will often take five minutes to finish.\nThese images are ~100kb, and are present and correct on the drive immediately after being generated.\nAm I missing a call for Django to update the new static files?  Something else?  Please help!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":328,"Q_Id":56665096,"Users Score":1,"Answer":"Deal with them as a media file, save the files to your media server (CDN or local), then send the URL of the images to the browser to load them.","Q_Score":0,"Tags":"python,django","A_Id":56666198,"CreationDate":"2019-06-19T10:04:00.000","Title":"Django taking very long time to serve generated static files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In my view I generate 5 images (they are generated by pyplot.)\nEverything seems to work fine.  The files are generated correctly in the right directory.\nBut the browser only shows one of the five images, and the requests for the other 4 usually timeout.  Looking at the django server output, the GET requests will often take five minutes to finish.\nThese images are ~100kb, and are present and correct on the drive immediately after being generated.\nAm I missing a call for Django to update the new static files?  Something else?  Please help!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":328,"Q_Id":56665096,"Users Score":0,"Answer":"I also faced a similar problem but with audio files. To resolve that issue I used pagination and that solved my issue. I think you should try that, like view one image in one page and second image on second page.","Q_Score":0,"Tags":"python,django","A_Id":56665245,"CreationDate":"2019-06-19T10:04:00.000","Title":"Django taking very long time to serve generated static files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i am currently in the process of pre-processing my data and I understand that i have to use the same scaling parameters I have used on my training set, on my test set. However, when i applied the transform method from sklearn library, i noticed something weird.\nI first used preprocessing.MinMaxScaler(feature_range=(0,1)) on my training set which sets the maximum to be 1 and minimum to be 0. Next, i used minmax_scaler.transform(data) on my test set and I've noticed when i printed out the data-frame, I have values that are greater than 1. What can this possibly mean?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1278,"Q_Id":56665409,"Users Score":2,"Answer":"For a given feature x, your minmax scaling to (0,1) will effectively map:\nx to (x- min_train_x)\/(max_train_x - min_train_x)\nwhere min_train_x and max_train_x are the minimum and maximum value of x in the training set.\nIf a value of x in the testing set is larger than the max_train_x the scaling transformation will return a value > 1.\nIt usually is not a big problem except if the input has to be in the (0,1) range.","Q_Score":1,"Tags":"python,scikit-learn,sklearn-pandas","A_Id":56665504,"CreationDate":"2019-06-19T10:20:00.000","Title":"What happens when you transform the test set using MinMaxScaler","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script working with multiple modules that include loggers (lets assume modules A and B).\nWhen executing, functions of A will automatically create a logger, but to keep things tidy I would like messages from module B only to be displayed in my stdout. \nIs there a convenient way to disable all print statements for every function \/ class coming from module A, without explicitly referring to the function that prints? Im thinking about something like a line of code at the start of the script handling that.\nMany thanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":56667055,"Users Score":0,"Answer":"There are two approaches:\n\nYou can monkey patch the print function\/logger object in module A's namespace and replace it with your own. This is quick and dirty, but would not require any modifications in module A. I'd highly recommend against doing this if possible, you'll just get into trouble. \nIf you can modify module A, the proper way to do this is to ensure that module A use the python logger for all its output, and that it sets a logger name. In your logging configuration, you can then specify a LoggerFilter or LoggerAdapter to selectively suppress log entries based on logger name prefix or other attributes of the LogEntry.","Q_Score":1,"Tags":"python,python-3.x,stdout,global","A_Id":56667385,"CreationDate":"2019-06-19T11:52:00.000","Title":"Globally silence the stdout for one whole 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 trying to connect to an Oracle database within a python script, I'm not allowed to use any 3rd party imports\/downloads, only the python standard library, like cx_oracle, which is the only solution to this I've found. I'm not super familiar with oracle databases, could someone explain how to connect and query without using cx_oracle and things like it.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":963,"Q_Id":56669750,"Users Score":0,"Answer":"Oracle's network protocol isn't public so you need either (i) some Oracle technology installed on your computer that knows that protocol - this is cx_Oracle and Oracle Instant Client (ii) or something like Oracle's ORDS product running on the database which will let you use REST calls.\nIf you need to interact with an Oracle Database you could make a very strong argument that you need to install cx_Oracle and Oracle Instant Client.  cx_Oracle is on PyPI so it can be installed like any other Python package you need.  Instant Client needs to be installed separately, but is the Oracle product that you could be expected to require to connect to Oracle DB.","Q_Score":1,"Tags":"python,sql,database,oracle","A_Id":56676662,"CreationDate":"2019-06-19T14:10:00.000","Title":"Connecting to Oracle DB in python without using 3rd parties","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What all inbuilt function call happen after creating a object from class? I know init() get called any other functions get called automatically ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":56672093,"Users Score":1,"Answer":"I don't think anything occurs after init() unless you define it to, before init();  however a call to the class' __new__() function will occur BEFORE the call to init()","Q_Score":0,"Tags":"python-3.x","A_Id":56672404,"CreationDate":"2019-06-19T16:21:00.000","Title":"automatically called functions while Object creation 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 pretty new to Postgres and very new to SQLAlchemy, so I apologise if this is a silly question.\nI've spent sometime googling this and reading the documentation on SQLAlchemy but I cant seem to find a straight answer.\nSo, my question is this..\nAs relationships are defined in code when using ORM, providing the database table structures define the necessary column fields, do you actually need to define ForeignKey constraints in the database itself as well?\nI know that the constraints can help with enforcing integrity but do they need to be there for a successful ORM implementation?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":136,"Q_Id":56673047,"Users Score":0,"Answer":"Foreign key constraints don't need to be there in order to have a successful ORM implementation. I think it's probably most common for the ORM to try to manage that kind of thing itself rather than follow database best practices. \nPersonally, I have a problem with that approach. I usually deal with enterprise databases that have many programs written in many different languages accessing the database. The other programs are simply not going to delete rows and cascade the deletes by calling the ORM, even if that's possible. \nSome ORMs support \"legacy\" databases, meaning the ORM can be configured to deal with databases that already implemented arbitrary constraints, primary keys that have multiple columns rather than an ID number per table, cascading updates and deletes, and so on.\nIn any case, the database belongs to the business, not to the ORM. Support for that idea varies, too.","Q_Score":0,"Tags":"python,postgresql,sqlalchemy","A_Id":56674138,"CreationDate":"2019-06-19T17:28:00.000","Title":"Do you need to define relationship in the DB if you use ORM?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am given a network packet whose last 64 bytes (128 hex characters) are the RSA-512 digital signature of the SHA-256 hash of the packet. I take a truncated version of this packet (everything except the last 64 bytes) and calculate the hash myself, which is working fine, however I need a way to get back the hash that generated the signature in the first place\nI have tried to do this in Python and have run into problems because I don't have the RSA private key, only the public key and the Digital Signature. What I need is a way to take the public key and signature and get the SHA-256 hash back from that to compare it to the hash I've generated. Is there a way to do this? Any crypto libraries would be fine. I am using hashlib to generate the hash","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":902,"Q_Id":56676828,"Users Score":0,"Answer":"The original hash was signed with the private key. To get the original hash, you need to decrypt the signature with the public key, not with the private key.","Q_Score":1,"Tags":"python,rsa,digital-signature","A_Id":56679386,"CreationDate":"2019-06-19T22:44:00.000","Title":"How to get the original hashed input to an RSA digital signature?","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 get the largest key in a dictionary which may have mixed data types? For example:\nmyDict = {1: 'foo', 2: 'bar', 3: None, 4: 1000}\nI want to get the largest key which is 4.  I tried max(myDict) which does work, but is this always reliable?  Or should I use max(myDict.keys()) instead?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":56677532,"Users Score":0,"Answer":"The options you gave (max(myDict) and max(myDict.keys())) are equivalent, because max internally tries to iterate over the thing you pass to it. Iteration over a Python dictionary yields its keys, so, no real difference.","Q_Score":0,"Tags":"python,dictionary","A_Id":56677555,"CreationDate":"2019-06-20T00:33:00.000","Title":"Get largest key from dictionary in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written some bunch of python files  and i want to make a window application from that. \nThe structure looks like this:\nSay, a.py,b.py,c.py are there. a.by is the file which i want application to open and it is basically a  GUI which has import commands for \"b.py\" and \"c.py\". \nI know this might be a very basic problem,but i have just started to packaging and deployment using python.Please tell me how to do that , or if is there any way to do it by py2exe and pyinstaller?\nI have tried to do it by py2exe and pyinstaller from the info available on internet , but that seems to create the app which is running only \"a.py\" .It is not able to then use \"b\" and \"c \" as well.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1980,"Q_Id":56680262,"Users Score":0,"Answer":"I am not sure on how you do this with py2exe. I have used py2app before which is very similar, but it is for Mac applications. For Mac there is a way to view the contents of the application. In here you can add the files you want into the resources folder (where you would put your 'b.py' and 'c.py').\nI hope there is something like this in Windows and hope it helps.","Q_Score":0,"Tags":"python,file,window","A_Id":56680443,"CreationDate":"2019-06-20T06:34:00.000","Title":"Building a window application from the bunch of python files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've done a php page index.php which uses some python scripts to retrieve some informations and copy them from a file A to a file B. My problem is that if I have more than one user that access index.php, B is modified from both the users. How can I make the second user wait until the first user has finished to modify B?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":414,"Q_Id":56682737,"Users Score":0,"Answer":"You can make one file in parallel xyz.txt.in_use and check for it every time from other location that the file is exists OR not then wait till it got deleted then after the writing completion, delete the xyz.txt.in_use, so that other can take charge on xyz.txt","Q_Score":0,"Tags":"php,python,concurrency","A_Id":56684754,"CreationDate":"2019-06-20T09:16:00.000","Title":"Prevent multiple users write on file at the same 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 am using Tensorflow Object detection api. What I understood reading the faster_rcnn_inception_v2_pets.config file is that num_steps mean the total number of steps and not the epochs. But then what is the point of specifying batch_size?? Lets say I have 500 images in my training data and I set batch size = 5 and num_steps = 20k. Does that mean number of epochs are equal to 200 ??\nWhen I run model_main.py it shows only the global_steps loss. So if these global steps are not the epochs then how should I change the code to display train loss and val loss after each step and also after each epoch.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2207,"Q_Id":56686630,"Users Score":1,"Answer":"So you are right with your assumption, that you have 200 epochs.\nI had a similar problem with the not showing of loss.\nmy solution was to go to the model_main.py file and then insert\ntf.logging.set_verbosity(tf.logging.INFO)\nafter the import stuff.\nthen it shows you the loss after each 100 steps.\nyou could change the set_verbosity if you want to have it after every epoch ;)","Q_Score":1,"Tags":"python,tensorflow,object-detection-api","A_Id":57010899,"CreationDate":"2019-06-20T13:04:00.000","Title":"How to display number of epochs in tensorflow object detection api with Faster Rcnn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I have 2 robot framework script (x.robot ans y.robot),\nis there a way that x.robot script will execute y.robot with different parameters?\nMeaning I don't want duplicate *.robot scripts but one script that run with different parameters each time.\nI'm using Python3","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":432,"Q_Id":56686810,"Users Score":1,"Answer":"is there a way that x.robot script will execute y.robot with different parameters?\n\nNo, there is not. Robot has no ability to run a test suite from another test suite. Your only option is to spawn a new process, which means the result of this second test suite will be written to a different log file.","Q_Score":1,"Tags":"python-3.x,robotframework","A_Id":56689706,"CreationDate":"2019-06-20T13:15:00.000","Title":"Robot Framework - Call *.robot script from other *.robot script with parameters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to be able to search for any user using facebook API v3.3 in python 3. \nI have written a function that can only return my details and that's fine, but now I want to search for any user and I am not succeeding so far, it seems as if in V3.3 I can only search for places and not users\n\nThe following function search and return a place, how can I modify it so that I can able to search for any Facebook users?\n\ndef search_friend():\n    graph = facebook.GraphAPI(token)\n    find_user = graph.search(q='Durban  north beach',type='place')\n    print(json.dumps(find_user, indent=4))","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":116,"Q_Id":56687213,"Users Score":1,"Answer":"You can not search for users any more, that part of the search functionality has been removed a while ago.\nPlus you would not be able to get any user info in the first place, unless the user in question logged in to your app first, and granted it permission to access at least their basic profile info.","Q_Score":0,"Tags":"python-3.x,facebook-graph-api","A_Id":56687408,"CreationDate":"2019-06-20T13:36:00.000","Title":"how can i search for facebook users ,using facebook API(V3.3) in python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting very high RMSE and MAE for MLPRegressor , ForestRegression and Linear regression with only input variables scaled (30,000+) however when i scale target values aswell i get RMSE (0.2) , i will like to know if that is acceptable thing to do.\nSecondly is it normal to have better R squared values for Test (ie. 0.98 and 0.85 for train)\nThank You","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4385,"Q_Id":56689243,"Users Score":0,"Answer":"It is actually a common practice to scale target values in many cases.\nFor example a highly skewed target may give better results if it is applied log or log1p transforms. I don't know the characteristics of your data, but there could a transformation that might decrease your RMSE.\nSecondly, Test set is meant to be a sample of unseen data, to give a final estimate of your model's performance. When you see the unseen data and tune to perform better on it, it becomes a cross validation set.\nYou should try to split your data into three parts, Train, Cross-validation and test sets. Train on your data and tune parameters according to it's performance on cross validation and then after you are done tuning, run it on the test set to get a prediction of how it works on unseen data and mark it as the accuracy of your model.","Q_Score":0,"Tags":"python-3.x,regression,data-science,prediction","A_Id":56690623,"CreationDate":"2019-06-20T15:23:00.000","Title":"Is it acceptable to scale target values for regressors?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can not import Pygame in pycharm. I\u2019ve looked at videos and other posts. I have it installed, both on the PyCharm interpreter and on my system. I get an error that says no module named Pygame, module Pygame does not have an init attribute.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":56691815,"Users Score":1,"Answer":"Go to File > Settings > Double Click on Project: (Your project name) > Project Interpreter > The + Button on the right side of the window. Also make sure you typed  import pygame on the first line of the program.","Q_Score":0,"Tags":"python,pygame,pycharm","A_Id":58721253,"CreationDate":"2019-06-20T18:19:00.000","Title":"Pygame In PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have three files and each contain close to 300k records. Have written a python script to process those files with some business logic and able to create the output file successfully. This process completes in 5 mins. \nI am using the same script to process the files with high of volume of data (All the three input files contain about 30 million records). Now the processing taking hours and kept running for very long time. \nSo I am thinking of breaking the file into 100 small chunks based on the last two digits of the unique id and having it processed parallels. Are there any data pipeline packages that I could use to perform this?\nBTW, I am running this process in my VDI machine.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":56695805,"Users Score":0,"Answer":"I am not sure of any API as such for the function.But you can try multiprocessing and multithreading to process large volume of data","Q_Score":0,"Tags":"python,data-pipeline","A_Id":56696216,"CreationDate":"2019-06-21T01:35:00.000","Title":"Splitting file into small chunks and processing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to use the microphone of peppers tablet to implement speech recognition.\nI already do speech recognition with the microphones in the head. \nBut the audio I get from the head microphones is noisy due to the fans in the head and peppers joints movement.\nDoes anybody know how to capture the audio from peppers tablet? \nI am using Pepper 2.5. and would like to solve this with python.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":56699117,"Users Score":0,"Answer":"With NAOqi 2.5 on Pepper it is not possible to access the tablet's microphone.\nYou can either upgrade to 2.9.x and use the Android API for this, or stay in 2.5 and use Python to get the sound from Pepper's microphones.","Q_Score":0,"Tags":"python,speech-recognition,tablet,microphone,pepper","A_Id":62589810,"CreationDate":"2019-06-21T07:53:00.000","Title":"Record Audio from Peppers Tablet Microphone","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Emacs on Windows, using evil mode for my keybindings. \nI want to set a keybinding for going back to the first line of a function's definition. \nI found a reference to M-x python-nav-end-of-defun. But strangely, I can't find python-nav-beginning-of-defun.\nHow can I find this function so I can bind it?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":57,"Q_Id":56699205,"Users Score":2,"Answer":"You can just use end-of-defun and beginning-of-defun per usual, since they call the python-nav-*-defun functions (bound locally in python-mode).  You probably can't find python-nav-beginning-of-defun because it is not an interactive function -- it is designed to be called by beginning-of-defun -- although if you used C-h f python-nav-beginning-of-defun you would find its help documentation.\nI don't know how evil binds these, but in normal emacs they would typically be C-M-a and C-M-e respectively.","Q_Score":0,"Tags":"python,emacs,key-bindings","A_Id":56700836,"CreationDate":"2019-06-21T07:59:00.000","Title":"can not find M-x python-nav-beginning-of-defun","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently use Conda to capture my dependencies for a python project in a environment.yml.\nWhen I build a docker service from the project I need to reinstall these dependencies. I would like to get around, having to add (mini-)conda to my docker image.\nIs it possible to parse environment.yml with pip\/pipenv or transform this into a corresponding requirements.txt?\n(I don't want to leave conda just yet, as this is what MLflow captures, when I log models)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1485,"Q_Id":56700687,"Users Score":3,"Answer":"Nope.\n\nconda automatically installs dependencies of conda packages. These are resolved differently by pip, so you'd have to resolve the Anaconda dependency tree in your transformation script.\nMany conda packages are non-Python. You couldn't install those dependencies with pip at all.\nSome conda packages contain binaries that were compiled with the Anaconda compiler toolchain. Even if the corresponding pip package can compile such binaries on installation, it wouldn't be using the Anaconda toolchain. What you'd get would be fundamentally different from the corresponding conda package.\nSome conda packages have fixes applied, which are missing from corresponding pip packages.\n\nI hope this is enough to convince you that your idea won't fly.\nInstalling Miniconda isn't really a big deal. Just do it :-)","Q_Score":1,"Tags":"python,docker,pip,conda,mlflow","A_Id":56700912,"CreationDate":"2019-06-21T09:33:00.000","Title":"Installing dependencies from (Conda) environment.yml without Conda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new with zarr, HDF5 and LMDB. I have converted data from HDF5 to Zarr but i got many files with extension .n (n from 0 to 31). I want to have just one file with .zarr extension. I tried to use LMDB (zarr.LMDBStore function) but i don't understand how to create .mdb file ? Do you have an idea how to do that ? \nThank you !","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":194,"Q_Id":56701950,"Users Score":0,"Answer":"@kish When trying your solution i got this error:\nfrom comtypes.gen import Access\nImportError: cannot import name 'Access'","Q_Score":0,"Tags":"python,hdf5,lmdb,zarr","A_Id":56704233,"CreationDate":"2019-06-21T10:48:00.000","Title":"How to create .mdb file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When debugging with PyCharm, a variable list has more than 1000 data. When I go to see the value, the system just displays the first 100 data, I need to double click to see the next 100.  \nIs there any way to see all the data at once, or is there any way to let me see the last 100?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":56702502,"Users Score":0,"Answer":"Open Debug window and in Variables panel click + (New Watch...) or press Insert.  \nType variable_name[-100:].\nThat will let you see last 100 elements.  \nIf variable is not a list an error {TypeError}'int' object is not subscriptable will be displayed instead.\nAlso unlike Evaluate Expression command, variables added to Watches persist from one debug session to another.","Q_Score":1,"Tags":"python,pycharm","A_Id":56707663,"CreationDate":"2019-06-21T11:24:00.000","Title":"Is there any way to see the last 100 elements inside a variable in PyCharm debugger?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Found existing installation: wrapt 1.10.11\nCannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5569,"Q_Id":56705686,"Users Score":0,"Answer":"I was getting this error while installing from conda environment. Always upgrade conda or pip before a new installation.\nFollowing worked for me:\n\n[Optional] If installing in conda environment, then temporarily remove the conda env:\nconda remove --name myenv --all\nUpdate all conda packages:\nconda update --all\nCreate conda env again:\nconda create -n myenv\nActivate conda env:\nconda activate\nInstall tensorflow:\npip install tensorflow","Q_Score":2,"Tags":"python-3.x,tensorflow,anaconda","A_Id":60075464,"CreationDate":"2019-06-21T14:46:00.000","Title":"i tried installing tensorflow using 'pip install tensorflow ' in anaconda prompt and command prompt. its showing following output","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I inherited a python program (more like a large number of scripts) that I'm rewriting into an OOP program.  I'm still learning Python and ran into this line of code which I am uncertain about.\nUnfortunately I don't know what this operation is called so my searches have not been very successful.\nbands = [int(b) for b in bands] if bands is not None else [10, 11]\nI think this code looks at the 'bands' variable and if it is not 'None', loops through the variable and casts each entry in the list to int.  If 'bands' is empty it sets 'bands' equal to a list containing 10 and 11.\nIs my analysis of the code correct?\nThe code looks foreign to me though, kind of backwards.  Is there a specific reason someone would want to write code this way instead of a normal if statement?  Is it faster or does it have any other benefit?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":56705702,"Users Score":1,"Answer":"It is.\nThe left had side is a list comprehension. And you're correct. It uses the iterable bands to create a new list, where each element is the value returned by int for each element of bands.   \nBut this will throw an exception if bands is None. So it only gets evaluated if bands is not None. If bands is None then it uses [10, 11] as a default value.  \nLearn about all the comprehensions (list, dictionary, set, and generator). They're super useful.","Q_Score":1,"Tags":"python,loops,if-statement,tuples","A_Id":56705775,"CreationDate":"2019-06-21T14:46:00.000","Title":"Is my analysis of this code correct, and why would it be written in this way?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a partially trained model in Keras, and before training it any further I'd like to change the parameters for the dropout, l2 regularizer, gaussian noise etc. I have the model saved as a .h5 file, but when I load it, I don't know how to remove these regularizing layers or change their parameters. Any clue as to how I can do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":356,"Q_Id":56706219,"Users Score":0,"Answer":"Create a model with your required hyper-parameters and load the parameters to the model using load_weight().","Q_Score":1,"Tags":"python,python-3.x,keras,regularized","A_Id":56706524,"CreationDate":"2019-06-21T15:20:00.000","Title":"How to remove regularisation from pre-trained model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that you can convert a spark dataframe df into a pandas dataframe with \n\ndf.toPandas()\n\nHowever, this is taking very long, so I found out about a koala package in databricks that could enable me to use the data as a pandas dataframe (for instance, being able to use scikit learn) without having a pandas dataframe. I already have the spark dataframe, but I cannot find a way to make it into a Koalas one.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":8396,"Q_Id":56706860,"Users Score":22,"Answer":"To go straight from a pyspark dataframe (I am assuming that is what you are working with) to a koalas dataframe you can use:\nkoalas_df = ks.DataFrame(your_pyspark_df)\nHere I've imported koalas as ks.","Q_Score":10,"Tags":"python-3.x,dataframe,databricks","A_Id":56855229,"CreationDate":"2019-06-21T15:58:00.000","Title":"How to convert a spark dataframe into a databrick koalas dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that you can convert a spark dataframe df into a pandas dataframe with \n\ndf.toPandas()\n\nHowever, this is taking very long, so I found out about a koala package in databricks that could enable me to use the data as a pandas dataframe (for instance, being able to use scikit learn) without having a pandas dataframe. I already have the spark dataframe, but I cannot find a way to make it into a Koalas one.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":8396,"Q_Id":56706860,"Users Score":3,"Answer":"Well. First of all, you have to understand the reason why toPandas() takes so long :  \n\nSpark dataframe are distributed in different nodes and when you run toPandas()\nIt will pull the distributed dataframe back to the driver node (that's the reason it takes long time)\nyou are then able to use pandas, or Scikit-learn in the single(Driver) node for faster analysis and modeling, because it's like your modeling on your own PC\nKoalas is the pandas API in spark and when you convert it to koalas dataframe : It's still distributed, so it will not shuffle data between different nodes, so you can use pandas' similar syntax for distributed dataframe transformation","Q_Score":10,"Tags":"python-3.x,dataframe,databricks","A_Id":58230046,"CreationDate":"2019-06-21T15:58:00.000","Title":"How to convert a spark dataframe into a databrick koalas dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"how to display contact without company in odoo 11 , exemple : if mister X in Company Y, in odoo, display this mister and company : Y, X. But i want only X. thanks","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1041,"Q_Id":56707951,"Users Score":2,"Answer":"That name comes via name_get method written inside res.partner.py You need to extend that method in your custom module and remove company name as a prefix from the contact name.","Q_Score":1,"Tags":"python,xml,odoo","A_Id":56713226,"CreationDate":"2019-06-21T17:20:00.000","Title":"How to display contact without company in odoo?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"These are related to the TfidfVectorizer of sklearn.\nCould some explain please the similarities and differences between these two and when each one is useful.\nIt is quite confusing because they look very similar to each other but also quite different.\nAlso the rather limited sklearn documentation does not help much in this case either.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":509,"Q_Id":56707957,"Users Score":0,"Answer":"Basically, I think that they contain exactly the same information.\nHowever, if you have the name of the term and you look for the column position of it at the tf-idf matrix then you go for the .vocabulary_.\nThe .vocabulary_ has as keys the names of the terms and as values their column position at the tf-idf matrix.\nWhereas, if you know the column position of the term at the tf-idf matrix and you look for its name then you go for the .get_feature_names().\nThe position of the terms in the .get_feature_names() correspond to the column position of the elements to the tf-idf matrix.","Q_Score":0,"Tags":"python,python-3.x,scikit-learn,tfidfvectorizer","A_Id":56708040,"CreationDate":"2019-06-21T17:21:00.000","Title":".vocabulary_ vs .get_feature_names()","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know where are the pygame Impact font for use it in my own game. If I use pygame.font.get_fonts() Impact is in the list.\nI navigate to all Python and PyGame folders (Without change anything) and the most similar I found is font.h\nI'm using Windows 10 with Python 3.7 and PyGame 1.9.4\nThe path where I looking is C:\\Users\\[Username]\\AppData\\Roaming\\Python\\Python37\\Include\\pygame\nI excepted that the font will be on a pygame folder of Python37 folder.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":412,"Q_Id":56708653,"Users Score":1,"Answer":"The fonts available will be system dependent. However, you can get a list of all of the fonts available by calling: pygame.font.get_fonts().\nYou can load any TrueType font file (*.ttf) with pygame.font.Font(). To load the font file myfont.ttf in your project directory simply call pygame.font.Font(\"myfont.ttf\", size). Substitute the path to your file for the first parameter if you have it in a different location. You can use either a relative or an absolute file path.\nSo I assume there are no fonts pre-saved in a directory.","Q_Score":1,"Tags":"python,text,fonts,pygame","A_Id":56709344,"CreationDate":"2019-06-21T18:22:00.000","Title":"Where are Pygame Fonts located on Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I automated the Test Suite using Robot Framework-Selenium base on PYTHON 27. This same Test Suite needs to execute on client side. \nBut Company do not want to share code base with client. \nIs there anyway that  I can create binary file of Robot Framework and share the same binary file with client instead of sharing a actually code ?\nlike in Java we create .jar file.\nKindly help me I am looking for solution from last three days.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":343,"Q_Id":56709077,"Users Score":0,"Answer":"I don't think there's anything you can do. Robot doesn't have the ability to parse binary files, so any solution would have to include converting your binary files to text files on the client machine.","Q_Score":1,"Tags":"python,robotframework,executable,robotium","A_Id":56709784,"CreationDate":"2019-06-21T19:00:00.000","Title":"How to hide robot framework code base and share only binary file to client?","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 have this homework, i need to do a email client that sends emails, notifies when a new email arrives,etc.\nOne of my problems is verifying a domains reputation if the user writes an url in the body or subject of the email, if the domain can be danger i shouldn't send the email.  I tried mywot.com api, but i can't get a key to try coding.\nI searched for other apis like domaintools, whoisxml, urlvoid but they have a ton of documentation, and i just get lost reading all of it, also they services are limited to free users.\nIs there another api that i can try? o there's another way to valid user urls?\nThanks for your answers.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":276,"Q_Id":56711961,"Users Score":0,"Answer":"most of them are free until a certain number of queries are hit (like 1000 month). \nFor a fully free API you'll probably need to implement it yourself, since indexing domain lists takes a lot of effort.\nCheck the free intervals of senderbase and virustotal","Q_Score":0,"Tags":"python,json,xml,url,dns","A_Id":61699316,"CreationDate":"2019-06-22T01:39:00.000","Title":"How to see Domains reputation 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 can successfully convert my .py files to .exe files through the auto-py-to-exe program. \nHowever is there a way to do it completely from a script?\nfor example:\nimport auto-py-to-exe\ncontained file\nconsole type\nauto-py-to-exe.convert(fileorigin.py,filedest.exe)\nMy goal is to have a script constantly running that converts my code then it uploads it to my server. I have the code to upload to the server on timer though i currently have to manually convert my files through the auto-py-to-exe program which is very time consuming and annoying. \nIf there is another way to do achieve this without auto-py-to-exe I am interested. \nThank you heaps :)\nIve tried googling however i could not find anything.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1381,"Q_Id":56712682,"Users Score":0,"Answer":"Using pyinstaller instead. Will post the code when im back on this pc.","Q_Score":1,"Tags":"python-3.x,exe,file-conversion,auto-py-to-exe","A_Id":56712762,"CreationDate":"2019-06-22T04:51:00.000","Title":"Use Auto-py-to-exe from 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to understand the difference between the ways we can pass arguments to threads and if this has any effect on thread safety.\nI am using python 3.7.3 and both instances of the code runs fine for me.\nExample 1:\nthread = threading.Thread(target=MultiHandler().handle, args=(argument))\nExample 2:\nthread = threading.Thread(target=MultiHandler().handle(argument))","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":242,"Q_Id":56716678,"Users Score":0,"Answer":"target should be the callable object to be invoked, not the result of the function call, unless your 2nd sample function returns another callable (target=MultiHandler().handle(argument) returns ---> callable).","Q_Score":0,"Tags":"python,thread-safety,python-multithreading","A_Id":56716698,"CreationDate":"2019-06-22T15:19:00.000","Title":"Python threading arguments passing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to understand the difference between the ways we can pass arguments to threads and if this has any effect on thread safety.\nI am using python 3.7.3 and both instances of the code runs fine for me.\nExample 1:\nthread = threading.Thread(target=MultiHandler().handle, args=(argument))\nExample 2:\nthread = threading.Thread(target=MultiHandler().handle(argument))","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":242,"Q_Id":56716678,"Users Score":0,"Answer":"Python allows both args and kwargs in threading as arguments. And that can be used to make decisions inside a function. \nAnd it's the callable function where thread safety applies not on the arguments.","Q_Score":0,"Tags":"python,thread-safety,python-multithreading","A_Id":56716796,"CreationDate":"2019-06-22T15:19:00.000","Title":"Python threading arguments passing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have one Python3 script that exits without any traceback from time to time.\nSome said in another question that it was caused by calling sys.exit, but I am not pretty sure whether this is the case.\nSo how can I make Python3 script always exit with traceback, of course except when it is killed with signal 9?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":56718917,"Users Score":0,"Answer":"It turns out that the script crashed when calling some function from underlying so, and crashed without any trackback. .","Q_Score":0,"Tags":"python-3.x,traceback","A_Id":57567523,"CreationDate":"2019-06-22T20:23:00.000","Title":"Python3 script exit with any traceback?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to be able to work on a small Pygame game in the Visual Studio 2017 IDE. I installed Python3.7 and the latest version of pygame with the installation pip, but I run the program, it can not find the module '' Pygame ''","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1129,"Q_Id":56719788,"Users Score":0,"Answer":"Run the following command:\npip install pygame","Q_Score":0,"Tags":"python-3.x,visual-studio-2017,pygame","A_Id":56719803,"CreationDate":"2019-06-22T23:03:00.000","Title":"How to install pygame on visual studio 2017?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, we know that Python uses a reference system, in order to refer to values in a list. So, if we create a new variable=list[index], the variable points to that list index. But what about when we are slicing a new list? Does the new sliced list use pointers? Or is it a new list in itself?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":56720463,"Users Score":1,"Answer":"A list in Python is made of an array of references (plus some bookkeeping data). Slicing allocates a new array, but those copied references still point to the same heap objects.\nWhen you do variable=list[index], the variable does not point to the list index. Rather, it references the same object that the list does at that index (at the time it is looked up; they can be changed independently later).","Q_Score":0,"Tags":"python,list","A_Id":56720476,"CreationDate":"2019-06-23T01:53:00.000","Title":"Does Python use pointers when creating a new sliced list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know there's a whl file for python3.6. I don't want to downgrade to 3.6 or run in a virtual environment.\nSoo my question is why hasn't anyone made the whl file available rather than downloading 4.4gb of ms vc that i know i won't beer using after compiling dlib.\nAny help is much appreciated. Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":248,"Q_Id":56725350,"Users Score":0,"Answer":"You need to compile it . Install Visual Studio 2019 and CMake . Then go to folder of your dlib , open the terminal and command python3 setup.py sdist bdist_wheel . It will load lots of text , and then you will have a wheel file in your dist folder . Good luck!","Q_Score":0,"Tags":"object,detection,python-3.7,dlib","A_Id":61065564,"CreationDate":"2019-06-23T15:32:00.000","Title":"Dlib whl for python 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is  all_pairs_dijkstra just a dijkstra_path with a for loop, or are all shortest path routes calculated all at once in the all_pairs_dijkstra?\nIs it faster to do one all_pairs_dijkstra or many dijkstra_path in a for loop?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":547,"Q_Id":56726562,"Users Score":0,"Answer":"Although I can't specifically speak to how networkx implements this function, using Dijkstra's algorithm to solve the all pairs shortest paths problem just means running one copy of Dijkstra's algorithm starting from each node in the graph to compute the pairwise distances.\nIn deciding whether to use a for loop around a single call or to use the all_pairs_dijkstra function, I'd recommend using all_pairs_dijkstra unless you have a compelling reason not to do so, as that function explicitly telegraphs your intent. Plus, if there are any optimizations done behind the scenes, you would be able to take advantage of them.\nBut specifically for networkx, is there any reason not to just use the simpler all_shortest_paths function? I imagine this is even simpler and would be a good call unless you have a specific reason to use all_pairs_dijkstra.","Q_Score":0,"Tags":"python,networkx,graph-theory,shortest-path,dijkstra","A_Id":56728147,"CreationDate":"2019-06-23T18:07:00.000","Title":"Is all_pairs_dijkstra faster than multiple dijkstra_path?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running some crawls in order to test if the results I get deviate. For this effort I created two test suites, the first one I created with the requests and BeautifulSoup library, the other one is based on selenium. I would like to find out, if pages detect both bots in the same way. \nBut I am still unsure if I am right, by assuming that requests and BeautifulSoup are independent from Selenium. \nI hope its not a dump question, but I haven't find any proper answer yet (maybe because of the wrong keywords). However, any help would be appreciated. \nThanks in advance\nI checked the requests documentation. I wrote a mail to the developer, without any answer. And of course I checked on google. I found something about scrapy vs selenium but well... are requests and BeautyfulSoup related to scrapy?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2861,"Q_Id":56728377,"Users Score":1,"Answer":"The python requests module does not use Selenium, neither does BeautifulSoup. Both will run independent of a web browser. Both are pure python implementations.","Q_Score":1,"Tags":"python,selenium,python-requests","A_Id":56728393,"CreationDate":"2019-06-23T23:19:00.000","Title":"Does requests rely on selenium?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have data in my Redshift cluster. I need to find the best and efficient way to delete the previously stored data when I re run the job.\nI have these two column to determine previous data previous_key (column that corresponds to run_dt) and creat_ts (time when we load the data)\nI found two approaches so far but they don't work in efficient way:\n\nUse sql DELETE command \u2013 might be slow, eventually requires Vacuum the table to reclaim storage space and resort rows\nUnload the data from a table into a file on S3 and then load table back (truncate and insert) with max clndr_key filtered out. Not really good either, might be risky.\n\nPlease suggest any good approach to rerun jobs on Redshift cluster.\nNote: partitions functionality is not available.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6918,"Q_Id":56730152,"Users Score":1,"Answer":"Deleting data stored in Redshift with DELETE command will take time. The reason is that you are doing a soft delete, I mean you mark existing rows as deleted and then insert new row representing updated form of the data.\nSo one way is executing DELETE for junks of data. Instead of deleting one by one you should try to address multiple rows. Since each write takes place in 1 MB chunks of data, we should be minimizing those data read and writes eventually. \nIf you have a good information about the topology of the data stored in Redshift compute nodes and slices, addition to that information about distribution key and sort key, you can separate your DELETE command into multiple statements. (Any how we are expecting Redshift SQL Engine to do this for the SQL developer)","Q_Score":1,"Tags":"python,amazon-web-services,pyspark,bigdata,amazon-redshift","A_Id":56730467,"CreationDate":"2019-06-24T05:10:00.000","Title":"How to efficiently delete data from Redshift?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"No Python at 'C:\\Users\\~~~~\\python.exe' error keeps coming out..\nEven if I deleted my previous python and path, the file location is where I installed my previous python...\nI want to use python in VS code and cmd on windows 10.\nWhat I tried to fix it\n\ndeleted python 3.7 version and reinstalled python 3.6 version.\nremoved previous python 3.7 path and added python 3.6 version reinstalled to the Windows Path variable. \nremove ';' on windows path variable.\nput ';' on windows path variable.\ndelete and reinstall python on vscode Extensions","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":24740,"Q_Id":56731615,"Users Score":0,"Answer":"First of all, make sure you have installed correct bit version for your version 32\/64 bit...I would prefer to install python from Microsoft store...And restart VS Code...\nIf the error still exists try uninstalling and again installing Python extension for VS Code and restart VS Code...\nAnd you can even try to install python in the path it is searching for... And also add the path to the environmental variable...\nHope this might solve your problem...as it has done mine.","Q_Score":5,"Tags":"python,visual-studio-code,path,environment-variables,reinstall","A_Id":62848648,"CreationDate":"2019-06-24T07:22:00.000","Title":"No python at '\\python.exe'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"No Python at 'C:\\Users\\~~~~\\python.exe' error keeps coming out..\nEven if I deleted my previous python and path, the file location is where I installed my previous python...\nI want to use python in VS code and cmd on windows 10.\nWhat I tried to fix it\n\ndeleted python 3.7 version and reinstalled python 3.6 version.\nremoved previous python 3.7 path and added python 3.6 version reinstalled to the Windows Path variable. \nremove ';' on windows path variable.\nput ';' on windows path variable.\ndelete and reinstall python on vscode Extensions","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":24740,"Q_Id":56731615,"Users Score":0,"Answer":"The reason this happened to me was because I updated my python version. Therefore, the existing venv config was looking for an older python version. What I did was simply delete the existing virtual environment folder and created a new one.\nTo save all dependencies installed and transfer it into the new virtual environment, you can do the following:\n\npip freeze > requirements.txt to save dependencies into a text file\ndelete old venv folder\ncreate new venv folder\npip install requirements.txt","Q_Score":5,"Tags":"python,visual-studio-code,path,environment-variables,reinstall","A_Id":70286020,"CreationDate":"2019-06-24T07:22:00.000","Title":"No python at '\\python.exe'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"No Python at 'C:\\Users\\~~~~\\python.exe' error keeps coming out..\nEven if I deleted my previous python and path, the file location is where I installed my previous python...\nI want to use python in VS code and cmd on windows 10.\nWhat I tried to fix it\n\ndeleted python 3.7 version and reinstalled python 3.6 version.\nremoved previous python 3.7 path and added python 3.6 version reinstalled to the Windows Path variable. \nremove ';' on windows path variable.\nput ';' on windows path variable.\ndelete and reinstall python on vscode Extensions","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":24740,"Q_Id":56731615,"Users Score":15,"Answer":"If you use venv, then look in that file:\npyvenv.cfg","Q_Score":5,"Tags":"python,visual-studio-code,path,environment-variables,reinstall","A_Id":60267895,"CreationDate":"2019-06-24T07:22:00.000","Title":"No python at '\\python.exe'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am repeatedly doing an operation which creates a record in my Cassandra table at every iteration. However, for my purposes I only need a limited number of the most recent results stored. Stale rows are not interesting, and also the database would quickly inflate in size because the operation is meant to run many times a second over many days.\nI am essentially using the Cassandra table as a buffer. That is by design.\nIs there a way to set Cassandra to have a limit on how many rows a table can have, and drop old rows automatically with minimum performance impact when new rows are pushed?\nMy codebase is in Python so I'd prefer a Python solution.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":265,"Q_Id":56732357,"Users Score":3,"Answer":"No, there is no such method built-in. \nThe traditional approach in Cassandra is for removing old information is not by count, but rather by date: When you insert a row (or even modify a single cell), you can put an expiration time (a.k.a. TTL) on this data. E.g., you write a row that is set to expire on one day. Cassandra will then take care of dropping the expired data from disk - automatically and efficiently (actually dropping the data happens during compaction). \nThis is of course not the same as saying you always want to keep exactly the newest 1000 rows, but maybe this is good enough for your use case, if your main intention is to keep your database size from exploding, and not really to keep a specific number of rows.","Q_Score":1,"Tags":"python,cassandra","A_Id":56733645,"CreationDate":"2019-06-24T08:10:00.000","Title":"Keep only newest N rows in Cassandra","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am repeatedly doing an operation which creates a record in my Cassandra table at every iteration. However, for my purposes I only need a limited number of the most recent results stored. Stale rows are not interesting, and also the database would quickly inflate in size because the operation is meant to run many times a second over many days.\nI am essentially using the Cassandra table as a buffer. That is by design.\nIs there a way to set Cassandra to have a limit on how many rows a table can have, and drop old rows automatically with minimum performance impact when new rows are pushed?\nMy codebase is in Python so I'd prefer a Python solution.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":265,"Q_Id":56732357,"Users Score":0,"Answer":"Use can use TTL. It will automatically delete the rows as the time mentioned in TTL","Q_Score":1,"Tags":"python,cassandra","A_Id":56752884,"CreationDate":"2019-06-24T08:10:00.000","Title":"Keep only newest N rows in Cassandra","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Global python \nwhich python3.6\nGives\n\/usr\/bin\/python3\nInside global python3\nimport tensorrt\nWorks fine, but creating virtual environment\nmkvirtualenv -p \/usr\/bin\/python3 --system-site-packages test\ninside virtualenv\nimport tensorrt\nNo module named 'tensorrt'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":56732809,"Users Score":0,"Answer":"what python path you use globally? is it the same \/usr\/bin\/python3?","Q_Score":0,"Tags":"python-3.x,virtualenv,tensorrt","A_Id":56732871,"CreationDate":"2019-06-24T08:40:00.000","Title":"Unable to access system site packages inside virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using visual studio to write my project and wanted to use pytesseract for image recognition so I installed it with pip. Then figured I had to download tesseract too so I did and it's available at a separate folder with a 'console' command line. The problem is that if I try running my code in visual studio it says tesseract wasn't found. \nBut it works fine if I run the script through tesseract's command line. Is there a more convenient way to execute my code? It seems a bit tedious to always run it from the separate command line.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":55,"Q_Id":56733842,"Users Score":0,"Answer":"Add tesseract folder to system PATH. It should fix problem.","Q_Score":0,"Tags":"python,visual-studio,opencv,tesseract","A_Id":56734876,"CreationDate":"2019-06-24T09:41:00.000","Title":"Can only run python code from separate tesseract console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a web scraper in Python, which works very well on my Laptop at home. After deploying it to AWS EC2 the performance of the scraper deteriorates. Now I am confused about the performance of EC2 instances (even of the micro and small instances, see further details below).\nScraper in python:\nGenerally, inner loop of the scrapes does the following:\n(1) the scraper looks up urls on a site (20 per site, one site = one \"site_break\"). In a second step it (2) gets the soruce code of each url, in a third step it (3) extracts the necessary information into an dataframe and in the fourth step it (4) saves the dataframe as pkl.\nAfter all loops it opens and merges the dataframs and saves it as csv.\nThe crucial (most time consuming parts) are:\n(2) download of source codes (I\/O limited by download speed): the program fills the RAM with the source code\n(3) processing of the sources codes (CPU 100%)\nTo use the RAM fully and stick together similar processes, every loop consists of site_break = 100, i.e. 100 sites * 20 urls\/site = 2000 urls. This fills the RAM of my PC to 96% (see below). Since I have to wait for server responses in step 1 and step 2, I implemented threading with maxWorkers=15 (alternatively 20-35 with similar results). This implementation cuts the run time by 80%. I am sure I could get some other .% by implementing asyncio. Nevertheless, I want to start with the lean MVP. In the processor consuming step 3 I didn't implement multiprocessing (yet), because my goal was an cost efficient\/free implemenation on t2.micro (with just one processor).\nSpecification:\nHome PC: Intel Core i7-6500 CPU, 2.59 Ghz (2 Cores, 4 logical Processors), RAM 8.00 GiB, 64-bit, x64, 50Mbit\/s Download-rate (effectively up to 45 Mbit\/s), Python 3.7.3, conda env\nEC2 t2.micro: vCPUs = 1, RAM 1.0 GiB, Network Performance \"low to moderate\" (research in forums tell my this could be something above 50 Mbit), Ubuntu 18.04, Python 3.7.3, conda env\nEC2 t3a.small: vCPUs = 2, RAM 2.0 GiB, Network Performance \"low to moderate\" but another AWS site tells me: \"up to 5 Gbit\/s\", Ubuntu 18.04, Python 3.7.3, conda env\nSince the RAM of the t2.micro is just 1 GiB, I lowered the site_break from 100 to 25. Afterwards, the RAM still got full, so I decreased it in further steps from 25 to 15, 12, 10 and finally 5. For 12, 10 and especially for 5 it works pretty well:\nI needed 5:30min for on loop with site_break = 100 on my PC. t2.micro need 8-10sec for site_break = 5, which leads to 3:00min for analogous 100 sites, which satisfied me in the first moment.\nUnfortunately, the following issue appears: After 20-30 loops the performance plumments. The time for on loop increases rapidly from 8sec to over 2min. My first assumption was it to be the low RAM, during the small loops it doesn't seem run full. After stopping and cleaning the RAM, the performance drops after the second or third loop. If I start it a few hours later the first case (with drop after 20-30 loops) repeats.\nBecause I firstly thought it has to do with the RAM, i launched a second instance on t3a.small with more CPU, RAM and \"up to 5 Gbit\/a\" network performance. I sliced to looks to site_break = 25 and startet the script. I is still running with a constant speed of 1:39-1:55min per loop (which is half as fast as t2.micro in its best phase (10 sec for 5 => 50 sec for 25).\nParallely, I started the script from my home PC with site_break = 25 and it is constantly faster with 1:15-1:30min per loop. (Stopping the time manuall results in 10-15sec slower for downloading and 10-15 sec slower for processing).\nThis all confuses me.\nNow my questions:\n\nWhy does the t2.micro detetoriate after several loops and why does the performance vary so wildly?\nWhy is the t3a.small 50% slower than the t2.micro? I would assume that the \"bigger\" machine would be faster in any regard.\n\nThis lets me stuck:\n\nDon't want to use my home PC for regularly (daily scraping), since the connection aborts at 4am for a tiny period of time and leads to hanging up of the script). Moreover, I don't want the script run manually and the PC all the time and block my private internet stream.\n\nt2.micro: Is useless, because the performance after the deterioration is not acceptable.\n\nt3a.small: performance is 10-20% lower than private PC. I would expect it to be better somehow? This lets my doubt to scrape over an EC2. Moreover, I can't understand the lower performance in comparison to t2.micro at the beginning.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":830,"Q_Id":56734108,"Users Score":1,"Answer":"Why does the t2.micro detetoriate after several loops and why does the performance vary so wildly?\n\nIf your RAM is not getting full, then this is most likely because Amazon is limiting the resources your instance is consuming whether that is CPU or I\/O. Amazon will give you more compute and throughput for a while (to accommodate any short-term spikes) but you should not mistake that for baseline performance.\n\nWhy is the t3a.small 50% slower than the t2.micro? I would assume that the \"bigger\" machine would be faster in any regard.\n\nT3 instances are designed for applications with moderate CPU usage that experience temporary spikes in use. With t3 you are either paying a premium to be able to afford larger and more frequent spikes, or, you are getting less baseline performance (for the same price) to be able to afford larger and more frequent spikes. This does not match the web-scraping profile where you want constant CPU and I\/O.","Q_Score":1,"Tags":"python,performance,amazon-web-services,amazon-ec2,web-scraping","A_Id":64767158,"CreationDate":"2019-06-24T09:57:00.000","Title":"Web Scraping Performance issues EC2 vs Home PC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"As a hobby, I try to code a basic game in python, and I need to store a map of the game world. It can be viewed as a 2-D array to store height. The point is, for the moment, my map dimensions are 5000x5000.\nI store that in a sqlite db (schema : CREATE TABLE map (x SMALLINT, y SMALLINT, h SMALLINT); + VACCUM at the end of the creation), but it take up to 500MB on the disk.\nI can compress (lzma, for example) the sqlite file, and it only takes ~35-40MB, but in order to use it in python, I need to unzip it first, so it always ends up taking so much place.\nHow would you store that kind of data in python ?\nA 2-D array of int, or a list 3-int tuple of that dimensions (or bigger) and it could still run on a Raspberry Pi ? Speed is not important, but RAM and file size are.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":56737150,"Users Score":0,"Answer":"You need 10 bits to store each height, so 10 bytes can store 8 heights, and thus 31.25Mo can store all 25,000,000 of them.  You can figure out which block of 10 bytes stores a desired height (how depends on how you arrange them), and a little bit shifting can isolate the specific height you want (since every height will be split between 2 adjacent bytes).","Q_Score":0,"Tags":"python,sqlite,storage,heightmap","A_Id":56738162,"CreationDate":"2019-06-24T13:00:00.000","Title":"How to store 25M 3-D int tuple with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get this error:\n\nCould not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, invalid path: \/home\/yosra\/Desktop\/CERT.RSA\n\nWhen I run: $ virtualenv venv\nSo I put a random CERT.RSA on the Desktop which worked and I created my virtual environment, but then when I run: pip install -r requirements.txt\nI got this one:\n\nCould not install packages due to an EnvironmentError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: \/KristianOellegaard\/django-hvad\/archive\/2.0.0-beta.tar.gz (Caused by SSLError(SSLError(0, 'unknown error (_ssl.c:3715)'),))\n\nI feel that these 2 errors are linked to each other, but I want to know how can I fix the first one?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":28651,"Q_Id":56738345,"Users Score":0,"Answer":"We get this all the time for various 'git' actions.  We have our own CA + intermediary and we don't customize our software installations enough to accomodate that fact.\nOur general fix is update your ca-bundle.crt with the CA cert pems via either concatenation or replacement.\ne.g. cat my_cert_chain.pem >> $(python -c \"import certifi; print(certifi.where())\")\nThis works great if you have an \/etc\/pki\/tls\/certs directory, but with python the python -c \"import certifi; print(certifi.where())\" tells you the location of python's ca-bundle.crt file.\nAlthought it's not a purist python answer, since we're not adding a new file \/ path, it solves alot of other certificate problems with other software when you understand the underlying issue.\nI recommended concatenating in this case as I don't know what else the file is used for vis-a-vis pypi.","Q_Score":14,"Tags":"python,ssl,pip","A_Id":71769428,"CreationDate":"2019-06-24T14:06:00.000","Title":"Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, invalid path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I get this error:\n\nCould not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, invalid path: \/home\/yosra\/Desktop\/CERT.RSA\n\nWhen I run: $ virtualenv venv\nSo I put a random CERT.RSA on the Desktop which worked and I created my virtual environment, but then when I run: pip install -r requirements.txt\nI got this one:\n\nCould not install packages due to an EnvironmentError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: \/KristianOellegaard\/django-hvad\/archive\/2.0.0-beta.tar.gz (Caused by SSLError(SSLError(0, 'unknown error (_ssl.c:3715)'),))\n\nI feel that these 2 errors are linked to each other, but I want to know how can I fix the first one?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":28651,"Q_Id":56738345,"Users Score":1,"Answer":"I received this error while running the command as \"pip install flask\" in Pycharm.\nIf you look at the error, you will see that the error points out to \"packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle -- Invalid path\".\nI solved this by removing the environment variable \"REQUESTS_CA_BUNDLE\" OR you can just change the name of the environment variable \"REQUESTS_CA_BUNDLE\" to some other name.\nRestart your Pycharm and this should be solved.\nThank you !","Q_Score":14,"Tags":"python,ssl,pip","A_Id":65888336,"CreationDate":"2019-06-24T14:06:00.000","Title":"Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, invalid path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a list FFT data which I want to plot in a single heat map. Each data set has its own X and Y. Usually I make use of Seaborn and Panda dataframe to plot the heatmap as the Frequency will be common for all the sets, but now the frequency column is unique for each data set. How can we plot a heatmap from this kind of data?\nthat is , I have a number of data sets as\nX1,Y1\nX2,Y2\nX3,Y3\n...\n...\nXn,Yn\neach X is unique and I want to plot these N graphs as a heatmap.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":497,"Q_Id":56738558,"Users Score":0,"Answer":"The problem was caused due to the fact that the Data was of non-uniform grid, now I created a common domain (x-axis value) for all the functions and then interpolated all the Data set to the new X-value.\nI used the numpy.interpol() function to achieve this.","Q_Score":0,"Tags":"python,heatmap","A_Id":56775827,"CreationDate":"2019-06-24T14:19:00.000","Title":"Plotting heat-map in python with multiple data sets","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I see many people in my data science master which use jupyter notebook for programming, even complex and long algorithm are coded in jupyter notebook...\nAnd even outside of my master I see people coding in Jupyter.. Why?\nThat a real question, I understand jupyter can be nice when you want to do write a report or something, but when you want to build complex app or this kind of thing it doesn't look like a good tool...","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3608,"Q_Id":56738811,"Users Score":2,"Answer":"The data science and machine learning community seem to overwhelmingly favor Jupyter Notebooks for projects that fall into those domains.\nThere are two advantages to using Jupyter Notebooks specifically for data science that I would like to highlight:\n\nJupyter Notebooks allows for cell by cell execution of code blocks which some programmers find advantageous because it allows for convenient testing of blocks of code.\n\nJupyter Notebooks allows for Matplotlib inline (%matplotlib inline) which outputs Matplotlib in the Jupyter Notebook which is convenient and allows for somewhat quicker analysis.\n\n\nYour analysis about Jupyter perhaps not being the best tool for a complex program outside of the data science domain, seems to align with many or even most python developers. Jupyter is another tool that is good to have in your developer toolbox, but probably not the best tool for the development of a complex program outside of the data science realm.","Q_Score":2,"Tags":"python,jupyter-notebook","A_Id":56739116,"CreationDate":"2019-06-24T14:33:00.000","Title":"Why do people prefer jupyter notebook over IDE like VS Code\/Spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I see many people in my data science master which use jupyter notebook for programming, even complex and long algorithm are coded in jupyter notebook...\nAnd even outside of my master I see people coding in Jupyter.. Why?\nThat a real question, I understand jupyter can be nice when you want to do write a report or something, but when you want to build complex app or this kind of thing it doesn't look like a good tool...","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":3608,"Q_Id":56738811,"Users Score":4,"Answer":"Divide and conquer\nI use Jupyter to build parts of a more complex app. \n\nI first put small pieces of code into a cell, and see the output directly.  \nWhen I'm satisfied, I put this code inside a function, and write a docstring.  \nAfter few tests, I put the code inside a file.py, then I import the function and use it in a new cell to build more complex stuffs.\n\nAdvantages :\n\nAs reactive as an interpreter\nI can see the output directly, even if it's a chart or a pandas dataframe.\nNotebooks are stored on HDD, like an IDE writing a file\nthe magics (%timeit, %matplotlib inline...)\nAs @Scott pointed out:\n\n\nThe magic of this is that I can keep large numpy objects that took a while to make in memory and iterate on various algorithms that I am applying to them. Without jupyter, I would either have to re-create those objects every time, which would be time-consuming, or put in a bunch of code to save them to file and load them from file. It's way easier to just leave them in memory with a jupyter notebook\n\n\nDrawbacks:\n\nNot as complete as an IDE or a text editor (syntax coloration, vim macros, deleting tabs...)\nIPython is not as good as CPython for dealing with heavy multi-threaded app","Q_Score":2,"Tags":"python,jupyter-notebook","A_Id":56738904,"CreationDate":"2019-06-24T14:33:00.000","Title":"Why do people prefer jupyter notebook over IDE like VS Code\/Spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to run some PySpark code whenever a BigQuery table is updated?\nI have something similar running whenever a file is uploaded to Google Cloud Storage using Cloud Functions but I can't find anything in the BigQuery documentation that offers similar functionality.\nWould appreciate any help, thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":56740463,"Users Score":0,"Answer":"There is currently no BigQuery trigger for Google Cloud Functions, however this feature is currently in progress and should be launched soon (as of June 2019).","Q_Score":0,"Tags":"python,google-cloud-platform,google-bigquery,google-cloud-functions","A_Id":56781347,"CreationDate":"2019-06-24T16:15:00.000","Title":"How do I run some code whenever a BigQuery table is updated?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My virtual environment refuses to recognize my install of Django (strangely)\nI'm on Windows Server, installed Python 3.7 to a directory (C:\\Python37) which I have C:\\Python37;C:\\Python37\\Scripts in my windows Path so when using Powershell or GitBash I can use the python command.\nif I run where python it shows the default install\nI CD into my django project directory and run:\npython virtualenv venv and the venv directory is created\nThen I run source venv\/Scripts\/activate and it activates appropriately.\nWhen I run where python it shows the exe inside the venv directory - which is expected and appropriate.\nI run pip install -r requirements.txt and all my requirements install appropriately. I confirm they are installed with pip freeze (all installed correctly)\nOnce I do that I go to run python manage.py collectstatic (no migrations are required in this particular instance) I get an error message that Django isn't installed.\nTo check this, with my virtualenv still activated I enter the shell (python)\nIf I do import django it also says Django is not installed.\nI cannot figure out what's happening here - the python version appears to be correct, the correct virtualenv is activated - but it's still not seeing the properly installed Django installation.\nThoughts? Ideas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1061,"Q_Id":56741516,"Users Score":2,"Answer":"For what it's worth - here is the solution and explanation:\nEverything works as expected as was outlined in the question - the reason that the actual python command wasn't working had to do with a line in the .bashrc file.\nThere was an alias in the .bashrc file to set python to the command winpty C:\\Python37\\python\nSo when the command python manage.py collectstatic was getting ran - it was looking at the Python executable in the Python37 directory and not the virtualenvironment Python.\nThis was solved by simply running the appropriate Python (e.g.)\nC:\/my_project\/venv\/Scripts\/python manage.py collectstatic\nThis forced it to use the virtualenvironment python to run the command so everything worked as expected.","Q_Score":4,"Tags":"python,django,virtualenv,windows-server-2012-r2,python-venv","A_Id":56753709,"CreationDate":"2019-06-24T17:41:00.000","Title":"Python (Windows Server) Virtualenv not recognizing Django is installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a function that consumes a datetime string that is returned from a DB query.  Right now the query returns a datetime object.\nWhat I am looking for is what would be the preferred way to create my datetime string.  I have not done any performance profiling yet, just looking for previous experiences from people.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":178,"Q_Id":56741998,"Users Score":1,"Answer":"It depends.\nNormally, the database is just a repository for data; it is not a formatting engine.  This implies that you should expect to get strings like \"2019-06-24 13:47:24\" or numbers like 1561409293 and you deal with them from there.\nHowever, it is often more straightforward to simply call DATE_FORMAT() in your SELECT statement.  This is especially handy when the SELECT can generate the entire 'report' without further manipulation.\nAnother way to decide...  Which approach requires fewer keystrokes on your part?  Or has the least chance of programming errors?  Or...\nYou say \"consumes a datetime string that is returned from a DB query\" -- but what will it do with it?  If it will be manipulating it in more than one way, then a client \"object\" sounds like the better approach.  If you will simply display the datetime, then DATE_FORMAT() may be better.\nThere is no noticeable performance difference.","Q_Score":2,"Tags":"python,mysql,mariadb","A_Id":56743814,"CreationDate":"2019-06-24T18:21:00.000","Title":"DateTime String via MySQL DATE_FORMAT or DateTime.strftime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to productionize Python code in a .NET\/C# environment without installing Python and without converting the Python code to C#, i.e. just deploy the code as is?\nI know installing the Python language would be the reasonable thing to do but my hesitation is that I just don't want to introduce a new language to my production environment and deal with its testing and maintenance complications, since I don't have enough manpower who know Python to take care of these issues.\nI know IronPython is built on CLR, but don't know how exactly it can be hosted and maintained inside .NET. Does it enable one to treat PYthon code as a \"package\" that can be imported into C# code, without actually installing Python as a standalone language? How can IronPython make my life easier in this situation? Can python.net give me more leverage?","AnswerCount":5,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2227,"Q_Id":56743561,"Users Score":5,"Answer":"IronPython is limited compared to running Python with C based libraries needing the Python Interpreter, not the .NET DLR. I suppose it depends how you are using the Python code, if you want to use a lot of third party python libraries, i doubt that IronPython will fit your needs.\nWhat about building a full Python application but running it all from Docker? \nThat would require your environments to have Docker installed, but you could then also deploy your .NET applications using Docker too, and they would all be isolated and not dirty your 'environment'.\nThere are base docker images out there that are specifically for Building Python and .NET Project and also for running.","Q_Score":7,"Tags":"c#,python,.net,ironpython,python.net","A_Id":56885931,"CreationDate":"2019-06-24T20:31:00.000","Title":"Running Python Code in .NET Environment without Installing 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":"The following code snippet transforms a text file into another text file, but with separators added after the specified field widths.\ngawk 'BEGIN{FIELDWIDTHS=\"1 26 1 26 26 26 26 18 2 5 4 7 10 16 4 4 10 2 6 1 1 1 1 10 10 4 11 3 1 1 2 10 10 10 1 1 10 20 10 1 1 1 1 15 16 10 50 13 1 60\"}{print $1 \"|\" $2 \"|\" $3 \"|\" $4 \"|\" $5 \"|\" $6 \"|\" $7 \"|\" $8 \"|\" $9 \"|\" $10 \"|\" $11 \"|\" $12 \"|\" $13 \"|\" $14 \"|\" $15 \"|\" $16 \"|\" $17 \"|\" $18 \"|\" $19 \"|\" $20 \"|\" $21 \"|\" $22 \"|\" $23 \"|\" $24 \"|\" $25 \"|\" $26 \"|\" $27 \"|\" $28 \"|\" $29 \"|\" $30 \"|\" $31 \"|\" $32 \"|\" $33 \"|\" $34 \"|\" $35 \"|\" $36 \"|\" $37 \"|\" $38 \"|\" $39 \"|\" $40 \"|\" $41 \"|\" $42 \"|\" $43 \"|\" $44 \"|\" $45 \"|\" $46 \"|\" $47 \"|\" $48 \"|\" $49 \"|\" $50}' \nI have a few ways in mind as to how it can be converted to python, but I need a direction I should head to. Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":100,"Q_Id":56743969,"Users Score":0,"Answer":"The following function does the same thing as the gawk snippet does- \ndef chunkstring(string, lengths):\n        return (string[pos:pos+length]\n        for idx,length in enumerate(lengths)\n        for pos in [sum(map(int, lengths[:idx]))])\ncolumn_lengths = [1,26,1,26,26,26,26,18,2,5,4,7,10,16,4,4,10,2,6,1,1,1,1,10,10,4,11,3,1,1,2,10,10,10,1,1,10,20,10,1,1,1,1,15,16,10,50,13,1,60]","Q_Score":0,"Tags":"python,python-3.x,text,awk,text-processing","A_Id":56756329,"CreationDate":"2019-06-24T21:08:00.000","Title":"Converting a text processing code written in awk to python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"There is python code about Relu backward propagation. and code is like dx=(x>0)*dout, what does x>0 part do? Can anyone explain me this line of code?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":109,"Q_Id":56744338,"Users Score":1,"Answer":"The Relu function is defined as:  f(x) = max(0,x)\nIt means if x<=0 then f(x)=0, else f(x)=x. \nSo if x<=0, dx=0, else dx=dout.","Q_Score":1,"Tags":"python,deep-learning,backpropagation,relu","A_Id":56744640,"CreationDate":"2019-06-24T21:47:00.000","Title":"dx=(x>0)*dout what does x>0 part in this code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If we apply object detection on an image containing a playing card, then it will make bounding box around that card. Now my question is this that is there any way to find the distance between the center of the card(bounding box) and the center of the whole image?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":580,"Q_Id":56747903,"Users Score":0,"Answer":"If the bounding box has bottom-left coordinate (x1, y1) and top-right (x2, y2), then its center'll be ((x1+x2)\/2, (y1+y2)\/2). Same in the case of the whole image. \nNow, determine the distance by using sqrt((c1x-c2x)^2 + (c1y-c2y)^2)\nHere, (c1x, c1y) is the center of the image and (c2x, c2y) is that of the bounding box","Q_Score":0,"Tags":"python,opencv,image-processing","A_Id":56748008,"CreationDate":"2019-06-25T06:18:00.000","Title":"Distance of the centre of the object from the centre of the image","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've set up python3.6 on new server and defualt python version of it is 2.7.\nand I want to use command \"python3\" instead of \"\/usr\/local\/bin\/python3.6\"\npython2.7 should be stayed as the default version, I just want to utilize \"python3\" command. \nAm I supposed to do use Symbolic link or alias? \nIs it ok if I'll create virtual envs?\nI apologize for my dump question, and I appreciate your help in advance.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":6542,"Q_Id":56749058,"Users Score":1,"Answer":"You can use alias for this. \ni.e. alias python3=\/usr\/local\/bin\/python3.6 and put it to your ~\/.bashrc file.\nRun source ~\/.bashrc to get the change.","Q_Score":0,"Tags":"python,python-3.x,redhat","A_Id":56749888,"CreationDate":"2019-06-25T07:38:00.000","Title":"How to use command \"python3\" to execute \"\/usr\/local\/bin\/python3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've set up python3.6 on new server and defualt python version of it is 2.7.\nand I want to use command \"python3\" instead of \"\/usr\/local\/bin\/python3.6\"\npython2.7 should be stayed as the default version, I just want to utilize \"python3\" command. \nAm I supposed to do use Symbolic link or alias? \nIs it ok if I'll create virtual envs?\nI apologize for my dump question, and I appreciate your help in advance.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6542,"Q_Id":56749058,"Users Score":0,"Answer":"Check if \/usr\/local\/bin\/ is in your PATH (echo $PATH).\nIf not, add it (export PATH=$PATH:\/usr\/local\/bin\/) in your ~\/.bashrc.\nRestart the shell or source ~\/.bashrc","Q_Score":0,"Tags":"python,python-3.x,redhat","A_Id":56749129,"CreationDate":"2019-06-25T07:38:00.000","Title":"How to use command \"python3\" to execute \"\/usr\/local\/bin\/python3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using latest version of Pycharm  community edition for my Python IDE,  when I will install all necessary libraries for  one project, I need to reinstall it for other projects because I can't import those libraries. \nHow can I fix this one? Should I install every time? Maybe there is some command by which I can install during program's running time? I mean in shell? I think I should update somehow path, I was searching a lot in internet, but unfortunately could not find anything relevant for this issue, or maybe I  can't guess solution.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6611,"Q_Id":56749453,"Users Score":0,"Answer":"You can use command line to install your packages. This will be easier to import since all packages are installed as global packages but its not recommended because it may cause conflicts between packages.\nThen every time you start a new project you just inherit from global package.","Q_Score":1,"Tags":"python","A_Id":56751088,"CreationDate":"2019-06-25T08:03:00.000","Title":"Installing libraries for every project in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using latest version of Pycharm  community edition for my Python IDE,  when I will install all necessary libraries for  one project, I need to reinstall it for other projects because I can't import those libraries. \nHow can I fix this one? Should I install every time? Maybe there is some command by which I can install during program's running time? I mean in shell? I think I should update somehow path, I was searching a lot in internet, but unfortunately could not find anything relevant for this issue, or maybe I  can't guess solution.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6611,"Q_Id":56749453,"Users Score":0,"Answer":"Go to File > Settings. Then from left side go to Project > Project Interpreter. Now, from the Project Interpreter dropdown, you can select your desired environment.","Q_Score":1,"Tags":"python","A_Id":56749826,"CreationDate":"2019-06-25T08:03:00.000","Title":"Installing libraries for every project in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using this code os.system(\"dcapgen.exe C:\\\\Users\\\\folder\\\\a.dcap\") in my python script to run this command dcapgen.exe C:\\Users\\folder\\a.dcap. This command generates .txt file in its current directory. I want to use this generated .txt file further in my code. How to do this? I don't want command log output. Thanks!\nI'm new to python programming.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":56752021,"Users Score":0,"Answer":"This cannot be done because .txt file that will be generated is not getting traced in command prompt. we can only get cmd log output using subprocess which is being suggested by other answers. so, we can get access to the generated file by using its path and full name which we know because its naming follows some pattern and location is fixed, like this\ngenerated_text_file = original_file_name+\"_some_addition.txt\"\n with open(generated_text_file, 'r') as file1:\n s = file1.read().replace('\/n','')","Q_Score":0,"Tags":"python","A_Id":56805693,"CreationDate":"2019-06-25T10:32:00.000","Title":"How to get command prompt output which is in the form of .txt inside a python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was tagging some NLP data in python and accidentally pressed control + c, cancelling the data that I was building up (in the form of a list). Is there anyway to recover the data or session that I was working on without having to start over? Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":56754554,"Users Score":0,"Answer":"Short answer - no,\nas it is not storing anywhere except RAM, that is clearing after you stopped process.\nOnly if you had verbose enough logs or system does some backups from time to time.","Q_Score":0,"Tags":"python-3.x,keyboardinterrupt","A_Id":56754919,"CreationDate":"2019-06-25T12:53:00.000","Title":"Restore session after accidental keyboard interrupt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using windows with Python 3.7.3, I installed NumPy via command prompt with \"pip install NumPy\", and it installed NumPy 1.16.4 perfectly. However, when I run \"import numpy as np\" in a program, it says \"ModuleNotFoundError: No module named 'numpy'\"\nI only have one version of python installed, and I don't know how I can fix this. How do I fix this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":696,"Q_Id":56755112,"Users Score":0,"Answer":"python3 is not supported under NumPy 1.16.4. Try to install a more recent version of NumPy:\npip uninstall numpy\npip install numpy","Q_Score":0,"Tags":"python,numpy,import,package","A_Id":56755246,"CreationDate":"2019-06-25T13:23:00.000","Title":"No module named 'numpy' Even When Installed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Most sources online call = (and +=, -=, etc...) an assignment operator (for python). This makes sense in most languages, however, not in python. An operator takes one or more operands, returns a value, and forms an expression. However, in python, assignment is not an expression, and assignment does not yield a value. Therefore, = cannot be an operator.\nSo what exactly is it? In a statement like x = 0, x is an identifier, 0 is a numeric literal, but I don't know what to call \"=\".","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":534,"Q_Id":56755308,"Users Score":0,"Answer":"The assignment symbol = behaves like a statement, not as an operator.  It supports chaining as part of the syntax but cannot be used as an operation (e.g. a = b = 0 but not if a = b:).\nIt is similar to the in part of a for ... in ...: statement. That in is part of the statement syntax, it is not the actual in operator.","Q_Score":0,"Tags":"python,operators,language-theory","A_Id":56756346,"CreationDate":"2019-06-25T13:33:00.000","Title":"What actually is the assignment symbol in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a .sql file containing insert statement from a table. Basically, I get the data from one table, do some modification, then create insert statement from a list of dict and write it to a file. However, the issue is with the text field. The values are not escaped. Is there any utility\/helper function that can help me get the insert statement with the handling of escape characters.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":56756004,"Users Score":0,"Answer":"Maybe you should use text.replace('', '') to escape characters that do not fit in the SQL query.","Q_Score":0,"Tags":"python,mysql,cursor","A_Id":56756765,"CreationDate":"2019-06-25T14:09:00.000","Title":"Creating insert into mysql script","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm installing Anaconda and a bunch of packages on a lot of MacBooks for an upcoming class. I'm about halfway through all the machines and just learned I've been installing Anaconda and all of the packages on the Administrator account when I should have been installing it on the regular user account. Conda commands work just fine on the admin account, but when I type \"conda list\" or \"conda --version\" on the regular user account that it needs to work on, I get:\n-bash: conda: command not found\nHow do I enable anaconda commands on another user account? Thanks!\nI have already tried a bunch of things to do with .bash_profile but frankly, I have no idea what I'm doing with those.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":56757212,"Users Score":0,"Answer":"If I remember correctly when I installed anaconda there was an option to install for all users or just the logged in profile","Q_Score":0,"Tags":"python,macos,anaconda","A_Id":56757370,"CreationDate":"2019-06-25T15:14:00.000","Title":"How to enable conda commands on another user profile on MacOS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm doing a project on custom object detection. I have to use a Bbox labelling tool and yolov3 weights to train my dataset. Still I'm confused about where to start and proceed with the same.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":56757346,"Users Score":0,"Answer":"Short answer: You will probably have to do a lot of it manually, or maybe hire an intern. \nIf you already have a way to automatically annotate your data, you don't have to build another. \nYou can try to use another way as an initial Solution, which you still need to go through by hand afterwards and finetune or correct the solutions. Depending on the size of the project it might be worth it though. \nWays to do this could be things like using annotated data for similar classes, using a non-deep-learning way that kind of works, using video footage where you know consecutive frames having similar objects and bounding boxes so annotating is faster.","Q_Score":0,"Tags":"python,tensorflow","A_Id":56757810,"CreationDate":"2019-06-25T15:22:00.000","Title":"Does the BBox labelling for object detection has to be done manually on Images or is there any ways to automate it","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the following line of commands used in sequence from the command window. \ncd path 1 && file.bat && cd path 2 && printfNav path3 > Testing.txt\nIs it possible to have this done through python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":116,"Q_Id":56759051,"Users Score":0,"Answer":"You are looking for the os.system() method. You will need to import os into your python program and then using this method you can send commands to the terminal. The method takes in a string and acts as if you typed that into your terminal. For example os.system('pwd') would cause the terminal to print out your current working directory, and so on so forth with other commands.","Q_Score":0,"Tags":"python","A_Id":56759180,"CreationDate":"2019-06-25T17:16:00.000","Title":"Is there a way to run several consecutive lines in the system command window using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I found upload_from_file and upload_from_filename, but is there a function or method to upload an entire folder to Cloud Storage via Python?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2959,"Q_Id":56759262,"Users Score":0,"Answer":"I don't think directly in the Python API, no, but there is in the commandline tool gsutil. You could do a system call from the python script to call out to the gsutil tool as long as you're authenticated on commandline in the shell you're calling the Python from.\nThe command would look something like:\ngsutil -m cp -r <foldername> gs:\/\/<bucketname>","Q_Score":3,"Tags":"python,directory,google-cloud-platform,upload","A_Id":56762660,"CreationDate":"2019-06-25T17:31:00.000","Title":"Upload a folder to Google Cloud Storage 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 found upload_from_file and upload_from_filename, but is there a function or method to upload an entire folder to Cloud Storage via Python?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2959,"Q_Id":56759262,"Users Score":0,"Answer":"Google Cloud Storage doesn't really have the concept of \"directories\", just binary blobs (that might have key names that sort of look like directories if you name them that way). So your current method in Python is appropriate.","Q_Score":3,"Tags":"python,directory,google-cloud-platform,upload","A_Id":56780840,"CreationDate":"2019-06-25T17:31:00.000","Title":"Upload a folder to Google Cloud Storage 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 have a folder with hundreds of csv files with the filenames in the format of file_nameddmmyyyy (e.g. data25062019.csv).\nI am using python\/pandas to read the files and manipulating the dataframes. I want to be able to pull multiple csv files based on the dates on the file names. \ne.g. I want to open the daily files from the previous one week and append them to a dataframe. \nThe problem is there are not files for everyday of the week, so there may only be 4-5 files for the last week. \nAny suggestions on best way to approach this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":56759396,"Users Score":0,"Answer":"Just put the read command in a try except statement:\ntry:\n    read_file()\n    append_file()\n except:\n     pass","Q_Score":0,"Tags":"python,pandas","A_Id":56760620,"CreationDate":"2019-06-25T17:41:00.000","Title":"Python\/Pandas - Read multiple files in a folder based on dates in filenames","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a way to get the size of a database with SQL Alchemy. Ideally, it will be agnostic to which underlying type of database is used. Is this possible?\nEdit:\nBy size, I mean total number of bytes that the database uses.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1584,"Q_Id":56761389,"Users Score":1,"Answer":"The way I would do is to find out if you can run a SQL query to get the answer. Then, you can just run this query via SQLAlchemy and get the result.","Q_Score":3,"Tags":"python,sqlalchemy","A_Id":57019257,"CreationDate":"2019-06-25T20:15:00.000","Title":"How to get database size in SQL Alchemy?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a web scraping project using python and an API\nI want the python script to be ran everyday for 5 days for 12 hours as a job\nI don't want to keep my system alive to either do it in CMD or in Jupyter so I was looking for a solution wherein any cloud service would help me automate the process","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":56762429,"Users Score":0,"Answer":"One way to do this would be to write a web scraper in Python, and run it on an AWS Lambda, which is essentially a serverless function with no underlying ops to manage. Depending on your use case, you could either perform some action based on the contents of that page data, or you could write the result out to S3 as a file.\nTo have your function execute in a recurring fashion, you can then set your AWS Lambda event trigger to be a CloudWatch event (in this case, some recurring timer at whatever frequencies\/times you'd like, such as once each hour for a 12 hour window during Mon-Fri). \nThis is typically going to be an easier approach when compared to spinning up a virtual server (EC2 instance), and managing a persistent process that could error during waits\/operation for any number of reasons.","Q_Score":0,"Tags":"python,amazon-web-services,google-cloud-platform,automation","A_Id":56762555,"CreationDate":"2019-06-25T21:44:00.000","Title":"How do I run a python code on a cloud service to automate it's run for 5 days","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I downloaded and installed mongoDB, ran mongod command on cmd as admin, did install mongodb and pymongo in anaconda however, keep getting this error when I import pymongo. Searched extensively on the same issue however, it does not really seem to help in my case. Don't understand why and what am I missing. I have python 3.7 on windows.\n\nModuleNotFoundError                       Traceback (most recent call last)\n in \n----> 1 import pymongo\nModuleNotFoundError: No module named 'pymongo'","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":7096,"Q_Id":56762535,"Users Score":1,"Answer":"a common reason for this is that your are using multiple python versions (e.g. 2.X and 3.X)\nThen it can happen that you install it for a different version than your are actually using.\nCheck your site-packages folder if it really contains pymongo","Q_Score":2,"Tags":"python,mongodb,jupyter-notebook,anaconda","A_Id":56762566,"CreationDate":"2019-06-25T21:53:00.000","Title":"Not able to resolve ModuleNotFoundError: No module named 'pymongo'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"pip install GnuPG says that the requirement is already satisfied but when I run a python script with GnuPG it says GnuPG is not installed.","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":2293,"Q_Id":56763171,"Users Score":5,"Answer":"In order to fix my environment I had to uninstall pgp and python-gnupg using the pip uninstall commands and then ONLY install python-gnupg. I must have had multiple versions of pgp and python was using the wrong one.","Q_Score":2,"Tags":"python-3.x,gnupg,pgp","A_Id":56813373,"CreationDate":"2019-06-25T23:15:00.000","Title":"GnuPG is installed but python is not finding it in runtime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"pip install GnuPG says that the requirement is already satisfied but when I run a python script with GnuPG it says GnuPG is not installed.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2293,"Q_Id":56763171,"Users Score":0,"Answer":"are you sure about the python and pip version?\ntry to see pip is referring to which python version and you are running script in which python version, verify if these are the same.","Q_Score":2,"Tags":"python-3.x,gnupg,pgp","A_Id":56763391,"CreationDate":"2019-06-25T23:15:00.000","Title":"GnuPG is installed but python is not finding it in runtime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a flask application installed on cpanel and it's giving me some error while the application is running. Application makes an ajax request from the server, but server returns the response with a 500 error. I have no idea how I get the information that occurs to throw this error.\nThere's no information on the cpanel error log and is it possible to create some log file that logs errors when occur in the same application folder or something?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":424,"Q_Id":56764314,"Users Score":1,"Answer":"When you log into cPanel go to the Errors menu and it will give a more detailed response to your errors there. You can also try and check: \/var\/log\/apache\/error.log or \/var\/log\/daemon.log","Q_Score":0,"Tags":"python,flask","A_Id":56767500,"CreationDate":"2019-06-26T02:23:00.000","Title":"How I get the error log generates from a flask app installed on CPanel?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have just started learning backend dev using django. My question is do I just commit the project files in the server folder alone, or should I also commit the .env folder to the repository?\nI have done the following:\n\nI have created virtual environment and I have also installed django in venv. \nI have setup a django server and super admin.\nI have setup the config.json to protect my API key.\nIncluded the same in .gitignore.\n\nWhat happens if I do or do not commit .env?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":11868,"Q_Id":56765051,"Users Score":6,"Answer":"Assuming that your .env folder is your virtual environment, no you should not commit it.\nThe virtual environment should be rebuilt on the server using your requirements.txt file. The local environment you built on your development machine may have operating system specific binaries, and other compiled code that was generated for your local environment. \nThe server will have different compiled binaries, and therefore should rebuild the virtual environment using: pip install -r requirements.txt.","Q_Score":7,"Tags":"python,git,virtualenv","A_Id":56765084,"CreationDate":"2019-06-26T04:09:00.000","Title":"Do I need to commit .env files into the repository?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"On Ubuntu Bionic, I've built PythonQt and the examples work as they should.\nHow do I compile my own application using the build PythonQt I have?\nnewbie here, so step by step instructions would be greatly appreciated","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":56765850,"Users Score":0,"Answer":"Apparently the following is all that has to be done:\n\nDownload and build PythonQtx.x\nin your apps \".pro\" file, include the required \".prf\" files from PythonQtx.x\/build\n\nqmake && make\n\n[linux] LD_LIBRARY_PATH env variable should point to PythonQtx.x\/lib when executing your compiled app","Q_Score":0,"Tags":"python-3.x,qt5,pythonqt","A_Id":56777648,"CreationDate":"2019-06-26T05:33:00.000","Title":"How to build a program using PythonQt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use PyAV to output video to a V4l2 loopback device (\/dev\/video1), but I can't figure out how to do it. It uses the avformat_write_header() from libav* (ffmpeg bindings).\nI've been able to get ffmpeg to output to the v4l2 device from the CLI but not from python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":409,"Q_Id":56766273,"Users Score":0,"Answer":"Found the solution. The way to do this is:\n\nSet the container format to v4l2\nSet the stream format as \"rawvideo\"\nSet the framerate (if it's a live stream, set the framerate to 1 fps higher than the stream is so that you don't get an error)\nSet pixel format to either RGB24 or YUV420","Q_Score":0,"Tags":"python,ffmpeg,v4l2","A_Id":56783972,"CreationDate":"2019-06-26T06:12:00.000","Title":"How can I output to a v4l2 driver using FFMPEG's avformat_write_header?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I installed python, I've used the default installation directory, which is c:\\users\\pc\\appdata\\local\\programs\\python\\python37, and now I need to move it to c:\\python37.\nIs this possible without uninstalling python? Because this will uninstall all the libraries and that's bad.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":686,"Q_Id":56768396,"Users Score":0,"Answer":"Cut the folder and paste to the C directory and add the python in the bin to the path","Q_Score":0,"Tags":"python,python-3.x,windows","A_Id":56768554,"CreationDate":"2019-06-26T08:25:00.000","Title":"Is there any way to change Python installation path on windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a question on a conceptual level. \nI'm building a piece of small-scale algorithmic trading software, and I am wondering how I should set up the data collection\/retrieval within that system. The system should be fully autonomous. \nCurrently my algorithm that I want to trade live is doing so on a very low frequency, however I would like to be able to trade with higher frequency in the future and therefore I think that it would be a good idea to set up the data collection using a websocket to get real time trades straight away. I can aggregate these later if need be. \nMy first question is: considering the fact that the data will be real time, can I use a CSV-file for storage in the beginning, or would you recommend something more substantial?\nIn any case, the data collection would proceed as a daemon in my application. \nMy second question is: are there any frameworks available to handle real-time incoming data to keep the database constant while the rest of the software is querying it to avoid conflicts?\nMy third and final question is: do you believe it is a wise approach to use a websocket in this case or would it be better to query every time data is needed for the application?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":56769559,"Users Score":0,"Answer":"CSV is a nice exchange format, but as it is based on a text file, it is not good for real-time updates. Only my opinion but I cannot imagine a reason to prefere that to database.\nIn order to handle real time conflicts, you will later need a professional grade database. PostgreSQL has the reputation of being robust, MariaDB is probably a correct choice too. You could use a liter database in development mode like SQLite, but beware of the slight differences: it is easy to write something that will work on one database and will break on another one. On another hand, if portability across databases is important, you should use at least 2 databases: one at development time and a different one at integration time.\nA question to ask yourself immediately is whether you want a relational database or a noSQL one. Former ensures ACID (Atomicity, Consistency, Isolation, Durability) transations, the latter offers greater scalability.","Q_Score":0,"Tags":"python,database,algorithmic-trading","A_Id":56769956,"CreationDate":"2019-06-26T09:33:00.000","Title":"How to set up data collection for small-scale algorithmic trading software","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using Flask to build a REST API.\nI noticed that it didn't complain when I launched the app with no secret_key. Even in production mode.\nI thought Flask used to complain in this case. Maybe I'm confused with another warning.\nAnyway, what could be the consequences?\nCan this trigger exceptions at runtime?\nThe API doesn't use sessions at all, so I don't see what it could need a secret key for.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":139,"Q_Id":56773559,"Users Score":0,"Answer":"As long as sessions are not used, Flask won't complain and there is no need for a secret key.\nWhen a secret key is needed, Flask will crash at runtime if none is provided.\nThere is no security risk with providing no secret key in the sense of the concern expressed in the question (Flask lowering security due to the missing key). The worst that can happen is seeing the application crash at runtime.","Q_Score":0,"Tags":"python,flask","A_Id":68160485,"CreationDate":"2019-06-26T13:07:00.000","Title":"How bad is it to run Flask without a secret key?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have silly question about efficiency of django.\nI will build application based on templates and using API.\nWhich option will be better?\n1) 1 server, 1 django (template+djangorestframework in one running framework)\n2) 1 server, 1 djangorestframework or flask api, 1 django template","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":56774025,"Users Score":0,"Answer":"For me the first solution is more simple and the efficience is similar.","Q_Score":0,"Tags":"python,django","A_Id":56775136,"CreationDate":"2019-06-26T13:29:00.000","Title":"Django build efficiency with API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am making a website to get to know aws and Django better. The idea is to let a user upload an excel file, convert it to csv and then let the user download the converted csv file. \nI am using amazon s3 for file storage. My question is, what is the best way to make the conversion? Is there any way to access the excel file once it is stored in the s3 bucket and convert it to csv via Django? Sorry if my question is silly but I haven\u2019t been able to find much information on that online. Thanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1128,"Q_Id":56777595,"Users Score":0,"Answer":"On every put event of Bucket you can trigger a AWS Lambda function which will convert your File format and save in desired bucket location.","Q_Score":0,"Tags":"python,django,amazon-web-services,amazon-s3,file-conversion","A_Id":56777922,"CreationDate":"2019-06-26T16:45:00.000","Title":"What is the best way to convert a file in amazon s3 with Django\/python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm looking at some machine learning\/forecasting code using Keras, and the input data sets are stored in npz files instead of the usual csv format. \nWhy would the authors go with this format instead of csv? What advantages does it have?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":817,"Q_Id":56778614,"Users Score":1,"Answer":"It depends of the expected usage. If a file is expected to have broad use cases including direct access from an ordinary client machines, then csv is fine because it can be directly loaded in Excel or LibreOffice calc which are widely deployed. But it is just an good old text file with no indexes nor any additional feature.\nOn the other hand is a file is only expected to be used by data scientists or generally speaking numpy aware users, then npz is a much better choice because of the additional features (compression, lazy loading, etc.)\nLong story made short, you exchange a larger audience for higher features.","Q_Score":0,"Tags":"python,csv,numpy","A_Id":56778812,"CreationDate":"2019-06-26T17:58:00.000","Title":"When is it better to use npz files instead of csv?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use LDAvis library to visualize my LDA topics. It works fine before, but it gets me this error when I download the saved model files from Sagemaker to the local computer. I don't know why does this happen? Does that relate to Sagemaker?\nIf I run from the local, and saved the model from local, and then run LDAviz library, it works fine.\n\nKeyError                                  Traceback (most recent call last)\n in ()\n~\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\pyLDAvis\\gensim.py in prepare(topic_model, corpus, dictionary, doc_topic_dist, **kwargs)\n    116     See pyLDAvis.prepare for **kwargs.\n    117     \"\"\"\n--> 118     opts = fp.merge(_extract_data(topic_model, corpus, dictionary, doc_topic_dist), kwargs)\n    119     return vis_prepare(**opts)\n~\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\pyLDAvis\\gensim.py in _extract_data(topic_model, corpus, dictionary, doc_topic_dists)\n     46           gamma = topic_model.inference(corpus)\n     47       else:\n---> 48           gamma, _ = topic_model.inference(corpus)\n     49       doc_topic_dists = gamma \/ gamma.sum(axis=1)[:, None]\n     50    else:\n~\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\gensim\\models\\ldamodel.py in inference(self, chunk, collect_sstats)\n    665             # phinorm is the normalizer.\n    666             # TODO treat zeros explicitly, instead of adding epsilon?\n--> 667             eps = DTYPE_TO_EPS[self.dtype]\n    668             phinorm = np.dot(expElogthetad, expElogbetad) + eps\n    669 \nKeyError: dtype('float32')","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":520,"Q_Id":56779011,"Users Score":0,"Answer":"I know this is late but I just fixed a similar problem by updating my gensim library from 3.4 to the current version which for me is 3.8.","Q_Score":2,"Tags":"python,lda,amazon-sagemaker","A_Id":59459541,"CreationDate":"2019-06-26T18:26:00.000","Title":"How to fix 'KeyError: dtype('float32')' in LDAviz","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently uninstalled and reinstalled python, and i have not been able to save one of my programs since.\nWhen i hit ctrl+S, IDLE throws me a window saying I\/O Error: Bad file descriptor. I can not even save my file!\nAs it turns out i don't think it has anything to do with the actual code. No matter what is in the program, it still throws this error when i try to save, unless there is no code whatsoever!\nIF anyone knows why this error is occurring, please tell me or post an updated version of the code, any help is appreciated\nI am using Windows 10, Python 3.7.3 64-bit [a couple days ago i uninstalled (just through windows settings) 32-bit and installed 64 from the python website]","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1060,"Q_Id":56780131,"Users Score":1,"Answer":"In Windows, it is theorically possible to install 32 bits and 64 bits versions of Python side by side, and it should work with a genuine installation. But dragons are waiting around: \n\nit is possible to have shortcuts pointing to a wrong location.\nif the PATH has been changed to allow direct usage of the python, or pip command from the command line, risk is that you use the wrong tool\nif any Python environment variable has been set, problems are almost guaranteed\n\nFurthermore, Python can be installed either for the current user or for all users, which adds more possibilities for inconsistancies.\nOnce an installation is deemed broken, uninstalling one of the versions is generally useless on can even cause more problems. Long story short, if you have entered the world of inconsistancy, you must clean up everything.\nMy advice here is:\n\nfind where the Python versions were installed and note it\nfind if additional tools (py) have been installed and try to find which ones\nuninstall every Python version\ncontrol that the installation paths are empty\nsearch the environment and PATH for any Python related information and remove them\n\nWhen everything looks good, reinstall from the installation wizard.\nHopefully it should work. If it does not I cannot help: despite being presented as an end user friendly system, Windows is a very feature rich and complex OS and trying to fully analyze a Windows system is beyond the capacity of most users, including most power users and sysadmins. At a point, the only possibility left is to reinstall the full OS and then cleanly install everything back... when it is possible...","Q_Score":0,"Tags":"python,python-3.x,file,python-idle","A_Id":56793925,"CreationDate":"2019-06-26T20:05:00.000","Title":"I\/O Error: Bad File Descriptor, can not save python file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I recently uninstalled and reinstalled python, and i have not been able to save one of my programs since.\nWhen i hit ctrl+S, IDLE throws me a window saying I\/O Error: Bad file descriptor. I can not even save my file!\nAs it turns out i don't think it has anything to do with the actual code. No matter what is in the program, it still throws this error when i try to save, unless there is no code whatsoever!\nIF anyone knows why this error is occurring, please tell me or post an updated version of the code, any help is appreciated\nI am using Windows 10, Python 3.7.3 64-bit [a couple days ago i uninstalled (just through windows settings) 32-bit and installed 64 from the python website]","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1060,"Q_Id":56780131,"Users Score":1,"Answer":"I have experienced the same issue.\nIn my case the Windows 10 Defender was the root cause.\nI added in Windows Defender Ransomware Protection the python.exe of my used IDE and the issue disappears.","Q_Score":0,"Tags":"python,python-3.x,file,python-idle","A_Id":67860858,"CreationDate":"2019-06-26T20:05:00.000","Title":"I\/O Error: Bad File Descriptor, can not save python file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Lest I reinvent the wheel .... again:\nIs there a python interface, API or module for the standard linux \"at\" task scheduler? I have tried searching the internet but searching for the word \"at\" is a tad bit useless :-)\nMy intention is to have a python script process same data and construct a shell file. Then use a subprocess call to have \"at\" schedule the job file for a specific date and time. I will have a similar function using \"Schtasks.exe\" if python detects it is running on windows. Lastly the python script exits ... leaving system scheduler the responsibility of running the job file.\nupdate 1 July 2019:\nFound an interesting \"at\" quirk.\nThe file called on the \"at\" command line (i.e. the script or shell file) does not need to be marked as \"executable\" in order to be run by \"at\".\nFor the record: I am running Linux Mint 19.1","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":113,"Q_Id":56780449,"Users Score":1,"Answer":"You can achieve this with different approach:\n\nWrite your python script. \nCall this script with a bash file.\nSchedule bash file with a crontab task.","Q_Score":3,"Tags":"python,schedule,at-job","A_Id":56780556,"CreationDate":"2019-06-26T20:31:00.000","Title":"Is there a python module for the Linux \"at\" task scheduler","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a 4 dimensional Numpy array, of (8, 1, 1, 102). Now, for instance, I simply want to ignore the middle two dimensions and have an array of shape (8,102), what may be the suitable way to accomplish this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":358,"Q_Id":56781237,"Users Score":1,"Answer":"np.squeeze will collapse all the dimensions having length 1, or you can use the reshape function","Q_Score":0,"Tags":"python,numpy","A_Id":56781883,"CreationDate":"2019-06-26T21:37:00.000","Title":"How to reshape a 4 dimensional Numpy array into different dimensions?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a Keras sequential model to do a binary image classification. Now when I use like 70 to 80 epochs I start getting good validation accuracy (81%). But I was told that this is a very big number to be used for epochs which would affect the performance of the network. \nMy question is: is there a limited number of epochs that I shouldn't exceed, note that I have 2000 training images and 800 validation images.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2256,"Q_Id":56781680,"Users Score":3,"Answer":"If the number of epochs are very high, your model may overfit and your training accuracy will reach 100%. In that approach you plot the error rate on training and validation data. The horizontal axis is the number of epochs and the vertical axis is the error rate. You should stop training when the error rate of validation data is minimum.\nYou need to have a trade-off between your regularization parameters. Major problem in Deep Learning is overfitting model. Various regularization techniques are used,as\ni) Reducing batch-size\nii) Data Augmentation(only if your data is not diverse)\niii) Batch Normalization\niv) Reducing complexity in architecture(mainly convolutional layers)\nv) Introducing dropout layer(only if you are using any dense layer)\nvi) Reduced learning rate.\nvii) Transfer learning\nBatch-size vs epoch tradeoff is quite important. Also it is dependent on your data and varies from application to application. In that case, you have to play with your data a little bit to know the exact figure. Normally a batch size of 32 medium size images requires 10 epochs for good feature extraction from the convolutional layers. Again, it is relative","Q_Score":2,"Tags":"python,keras,conv-neural-network","A_Id":56785434,"CreationDate":"2019-06-26T22:26:00.000","Title":"Number of epochs to be used in a Keras sequential model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can anyone tell me what is the difference between them in python ? Is variable also an object but don't have value ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":136,"Q_Id":56783678,"Users Score":1,"Answer":"Hello may be this is some difference between this python terms:\n\nReference variable:\nPython program accesses data values through references. A reference is a name that refers to the specific location in memory of a value (object). References take the form of variables, attributes, and items. In Python, a variable or other reference has no intrinsic type.\nPointer:\nWell, python does not have pointers, but the objects are passed to functions by reference (and so in java, another language without pointers). This mechanism is very similar to passing pointers by value in C.\nIdentifier:\nA Python identifier is a name used to identify a variable, function, class, module or other object. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores and digits (0 to 9).\nVariable:\nA Python variable is a reserved memory location to store values. In other words, a variable in a python program gives data to the computer for processing. Every value in Python has a datatype. Different data types in Python are Numbers, List, Tuple, Strings, Dictionary, etc","Q_Score":0,"Tags":"python","A_Id":56783743,"CreationDate":"2019-06-27T03:56:00.000","Title":"What is the difference between pointer,reference,identifier,variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So when I run my python selenium script through Jenkins, how should I write the driver = webdriver.Chrome()\nHow should I put the chrome webdriver EXE in jenkins?\nWhere should I put it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":56784344,"Users Score":0,"Answer":"If you have added your repository path in jenkins during job configuration, Jenkins will create a virtual copy of your workspace. So, as long as the webdriver file is somewhere in your project folder structure and as long as you are using relative path to reference it in your code, there shouldn't be any issues with respect to driver in invocation.\nYou question also depends on several params like:\n1. Whether you are using Maven to run the test\n2. Whether you are running tests on Jenkins locally or on a remote machine using Selenium Grid Architecture.","Q_Score":0,"Tags":"python,selenium,jenkins,webdriver","A_Id":56784544,"CreationDate":"2019-06-27T05:15:00.000","Title":"So when I run my python selenium script through jenkins, how should I write the 'driver = webdriver.Chrome()'?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to export my DataFrame to Excel. Everything is good but I need two \"rows\" of headers in my output file. That mean I need two columns headers. I don't know how to export it and make double headers in DataFrame. My DataFrame is created with dictionary but I need to add extra header above.\nI tried few dumb things but nothing gave me a good result. I want to have on first level header for every three columns and on second level header for each column. They must be different.\nI expect output with two headers above columns.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1093,"Q_Id":56787460,"Users Score":0,"Answer":"Had a similar issue. Solved by persisting cell-by-cell using worksheet.write(i, j, df.iloc[i,j]), with i starting after the header rows.","Q_Score":0,"Tags":"python,pandas,export-to-excel","A_Id":59754774,"CreationDate":"2019-06-27T08:57:00.000","Title":"Multiple header in Pandas DataFrame to_excel","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a numpy array as:\ngroups=np.array([('Species1',), ('Species2', 'Species3')], dtype=object).\nWhen I ask np.where(groups == ('Species2', 'Species3')) or even np.where(groups == groups[1]) I get an empty reply: (array([], dtype=int64),)\nWhy is this and how can I get the indexes for such an element?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1220,"Q_Id":56788435,"Users Score":1,"Answer":"It's not means search a tuple('Species2', 'Species3') from groups when you use \nnp.where(groups == ('Species2', 'Species3'))\nit means search 'Species2' and 'Species3' separately if you have a Complete array like this \ngroups=np.array([('Species1',''), ('Species2', 'Species3')], dtype=object)","Q_Score":1,"Tags":"python,numpy","A_Id":56789899,"CreationDate":"2019-06-27T09:51:00.000","Title":"How can I find the index of a tuple inside a numpy array?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Pycharm-community 2016 0.3 on Ubuntu 16.04. \nI'm coding in Python 2.7, the problem is that the functions which are defined  by me are not being syntax-highlighted. For example, before using Pycharm I was using Atom, in it the functions are highlighted making it very easy to debug.\nI have turned on Semantic highlighting and i'm using the theme 'Dracula'.\nI tried to re install Pycharm-communty, tried installing the latest edition, but none if it  is working.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":21,"Q_Id":56789819,"Users Score":0,"Answer":"I found a work-around foe this problem,\nIf you install the 'onedark' theme and enable it, the local functions are also highlighted.\nTo install,\ngo to settings > plugins >  search for 'onedark', and install","Q_Score":0,"Tags":"python-2.7,pycharm","A_Id":56794227,"CreationDate":"2019-06-27T11:14:00.000","Title":"Functions are not being highlighted in Python2.7 in Pycharm-community","Data 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 constructed 2 graphs and calculated the eigenvector centrality of each node. Each node can be considered as an individual project contributor. Consider 2 different rankings of project contributors. They are ranked based on the eigenvector of the node. \nRanking #1:\nRank 1 - A\nRank 2 - B\nRank 3 - C\nRanking #2:\nRank 1 - B\nRank 2 - C\nRank 3 - A\nThis is a very small example but in my case, I have almost 400 contributors and 4 different rankings. My question is how can I merge all the rankings and get an aggregate ranking. Now I can't just simply add the eigenvector centralities and divide it by the number of rankings. I was thinking to use the Khatri-Rao product or Kronecker Product to get the result. \nCan anyone suggest me how can I achieve this?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":56790761,"Users Score":0,"Answer":"Rank both graphs separately each node gets a rank in both graphs then do simple matrix addition. Now normalize the rank. This should keep the relationship like rank1>rank2>rank3>rank4 true and relationships like rank1+rank1>rank1+rank2 true. I don't know how it would help you taking the Khatri-Rao product of the matrix. That would make you end up with more than 400 nodes. Then you would need to compress them back to 400 nodes in-order to have 400 ranked nodes at the end. Who told you to use Khatri-Rao product?","Q_Score":0,"Tags":"python,data-mining,matrix-multiplication,data-analysis,ranking","A_Id":58783825,"CreationDate":"2019-06-27T12:15:00.000","Title":"Aggregate Ranking using Khatri-Rao product","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can anyone help me to grasp this paragraph :\n\u2022 JSON and XML have good support for Unicode character strings (i.e., humanreadable text), but they don\u2019t support binary strings (sequences of bytes without\na character encoding). Binary strings are a useful feature, so people get around\nthis limitation by encoding the binary data as text using Base64. The schema is\nthen used to indicate that the value should be interpreted as Base64-encoded.\nThis works, but it\u2019s somewhat hacky and increases the data size by 33%\nIf i understand well, for example i use a REST API on my equipement to get some information with python.\nFor each response, it's in JSON and it's in unicode format.\nSo OK\nBut i don't really grasp the story of binary string.\nIs it the fact that each character is not in UTF8 format ?\nWhy my equipement don't response in JSON encoded in byte and not in unicode ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":677,"Q_Id":56790769,"Users Score":0,"Answer":"JSON and XML are text formats. They're designed to be readable by people, displayed and manipulated with typical text editors like vi, emacs, or edlin, using whatever character encoding scheme is convenient for the platform. All the character encoding schemes in use, however, have some data patterns that are not allowed to represent characters -- for instance, they may have a pattern that indicates \"end-of-string\".\nIf you want to include completely arbitrary data in JSON or XML, you need a way to encode that data in valid text strings and indicate the text is not the actual data you want to use. Base64 is one way of doing that encoding, and it is commonly used for this purpose. The disadvantages are the overhead of doing the encoding and decoding when writing or reading the data, the encoded text string is slightly larger than the original arbitrary binary, and that you have to remember to do the encoding and decoding.","Q_Score":0,"Tags":"python,json","A_Id":56791501,"CreationDate":"2019-06-27T12:15:00.000","Title":"JSON, response in unicode or binary","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'ld like one of these:\n\nStarting python with a script like python my_routines.py and let python enter the interactive state while the code in my_routines.py have been loaded\/run.  \nStarting python in the interactive mode and loading in some convenient(short and easy to remember) way my_routines.py\n\nthe idea is, of course, that I want to preload some stuff and then play around with it in the interactive mode.\nSuggestions involving loading a module (python -m ....) don't have to apply ;-)\nLooking forward to your ideas!\nTwan","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":690,"Q_Id":56791655,"Users Score":4,"Answer":"To continue in REPL after running the script, run it with python -i test.py, where -i stands for interactive.\nFor loading from inside the REPL, you could use exec, but your best bet is to use ipython and its %load command. (ipython is an improved repl, so you should be using that anyway)","Q_Score":1,"Tags":"python","A_Id":56791710,"CreationDate":"2019-06-27T13:02:00.000","Title":"How to load scripts into a python interpreter session, and letting python start the interactive mode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to skip the Android P setup wizard programmatically to reach Home Screen to proceed doing other scripted jobs. Since the ADB already recognizes the device when plugged on first setup wizard page, I was trying to skip initial setup using it. Is there any way to do that using ADB or by other tools, potentially Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1244,"Q_Id":56791662,"Users Score":0,"Answer":"I think I may have tried this before and I don't believe there is. While the ADB recognizes that there is a device attached, that doesn't mean it can read it. The device would have to be set up completely before it would be able to interact and read\/send data to the ADB.","Q_Score":1,"Tags":"android,python,adb","A_Id":56791764,"CreationDate":"2019-06-27T13:03:00.000","Title":"Is there any way to skip Android device setup wizard using ADB when device is on Android P?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd prefer to use the canonical 'venv' when using Pycharm. Pycharm doesn't seem to support venv (it supports virtualenv and others).\nWhat do I need to do to safely use venv?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":666,"Q_Id":56791761,"Users Score":1,"Answer":"Just use venv, then in Pycharm Ctrl-Alt-S, Project -> Project Interpreter -> Viretualenv Environment -> Existing environment -> Interpreter (set path from your venv here). All seems to work","Q_Score":0,"Tags":"python,python-3.6,python-venv","A_Id":56792180,"CreationDate":"2019-06-27T13:08:00.000","Title":"Using Python with venv and PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a lines dataset where each lines have several points (minimum 2). All the coordinates are known and on the same metric reference.\nI would like to merge the lines with the same azimut +\/- 10\u00b0 and a maximal distance of 5cm between lines.\nI think a clustering algorithm can do that, I found on web some clustering algorithms working with points and I would like to know if there is any existing function\/algorithm to do that with lines ?\nIf no, I will try to adapt a code myself.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":577,"Q_Id":56794801,"Users Score":0,"Answer":"Yes, almost all can be used. It's just probably not the most efficient way. Depending on how you'd formalize your problem, which is not clear enough. Do the points pairwise have to fulfill this property, or is it enough if they \"mostly\" do, or if there are some that do?\nIn many cases it will be easiest (but slow) to make a graph where you connect any two lines that have the desired property, then search for desirable structures such as cliques (and thenyou'll quickly see why it's not clear which solution you are looking for).","Q_Score":0,"Tags":"python,cluster-analysis","A_Id":56797251,"CreationDate":"2019-06-27T15:56:00.000","Title":"How to get cluster of lines using python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a recipe that needs to know the version string\/information of another recipe. Basically I want to expand the PV variable of a different recipe. What would be the easiest way to do this? I was thinking maybe there is a bb python function I can use in my recipe to parse the other recipe and find it's PV.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":320,"Q_Id":56794981,"Users Score":0,"Answer":"Easily, you can't. Can you explain what you actually need to do?","Q_Score":0,"Tags":"python,linux,yocto,bitbake","A_Id":56795346,"CreationDate":"2019-06-27T16:07:00.000","Title":"How can I reference\/find the ${PV} of one recipe in another recipe in Yocto\/Bitbake?","Data 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 to create a form with a lot of fields in it. I don't want the user to scroll all the way down to complete the form and save. I need the user to fill in the fields in the window and click next to fill the next set of fields. How do i create a form view that does this? i've searched for forms with multiple steps in odoo and couldn't find an example.Can anyone please help?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":812,"Q_Id":56796027,"Users Score":0,"Answer":"I think you can create a form with multiple states and the fields and buttons can be subjected to visible\/invisible according to the states.It is better to add states using widget \"statusbar\"","Q_Score":1,"Tags":"python,xml,odoo,odoo-12","A_Id":56831719,"CreationDate":"2019-06-27T17:27:00.000","Title":"How do i create a multi step form in odoo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to load a model on AWS lambda using Zappa. The problem is that the total unzipped file size from the package created by Zappa and uploaded to S3 is about 550mb, which exceeds the limit. One of the packages I'm using is Spacy (an NLP dependency that is very large), and I'm able to reduce the size of this package by manually removing unused languages in the lang folder. Doing this I can get the unzipped file size under 500mb. Problem is that Zappa automatically downloads the full Spacy version (spacy==2.1.4: Using locally cached manylinux wheel) on deploy and update. \nI've learned that I can call Zappa Package, and it will generate a package that I can then upload myself. What I've done is unzipped the generated package and removed the unnecessary lang files, then I zipped it back up. Is it possible for me to call Zappa Deploy\/Update and use the modified package and handler that was created by Zappa Package? This way Zappa can still handle the deployment.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":547,"Q_Id":56796521,"Users Score":0,"Answer":"Here's how I solved the issue, there are two ways:\n\nThe first is to simply move the dependency folder from the\nsite-packages directory to the root folder, and then make any\nmodifications there. This will force zappa to not download a wheels on linux version of the dependency upon upload \nThe simpler solution is to remove the *dist folder for a\nspecific module that you modify. Removing this will force zappa to bypass re-downlading modules from wheels on linux; meaning your modified module will be packaged during deployment.","Q_Score":1,"Tags":"python-3.x,amazon-web-services,aws-lambda,spacy,zappa","A_Id":59536598,"CreationDate":"2019-06-27T18:04:00.000","Title":"Can Zappa Update be used with the output package from Zappa Package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on rewriting a lengthy Rexx script into a Python program and I am trying to figure out the best way to emulate the functionality of a Rexx compound variable. Would a dictionary be the best bet? Obviously, a dictionary will behave differently and won't be exactly the same as a compound variable.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":56797118,"Users Score":0,"Answer":"I am not a Python person but I know what a Dictionary is.\nDepending on how complex the Rexx compound variable is, yes.\na.b\n...is easily translatable to a dictionary.\na.b.c.d.e.f.g.h\n...is less easily translatable to a dictionary.  Perhaps a dictionary within a dictionary within a dictionary within a dictionary within a dictionary within a dictionary within a dictionary.","Q_Score":1,"Tags":"python,rexx,oorexx","A_Id":56798731,"CreationDate":"2019-06-27T18:49:00.000","Title":"Would a Python dictionary be the equivalent data structure to a Rexx compound variable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed a library through pip that only worked with Python2. I modified the source a bit to make it work with Python3, however I would like to repackage my modified version so that I can move it to another PC. How can I do it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":678,"Q_Id":56797536,"Users Score":0,"Answer":"Your package should have a setup.py that come with it\npython3 setup.py bdist_wheel\nThis will create directory called dist containing a python wheel file \nls -l dist\\*.whl\nCopy that file to the other system and\npip3 install <file_name>.whl","Q_Score":1,"Tags":"python,pip,setuptools,distutils,pypi","A_Id":56797632,"CreationDate":"2019-06-27T19:30:00.000","Title":"Repackage a modified library originally installed through pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on Object detection. I am using Amazon Workspace for training my model. I am using the model to detect cars and bikes. I have used a pre-trained model (which is Faster-RCNN-Inception-V2 model) and customized it with my own dataset for 2 labels namely car and bike. It took me 5 hours to complete the training. Now I want to modify my model for 2 more labels (keeping to old ones) namely bus and auto. But I don't want to do the training from scratch as my model is already trained for cars and bikes. So is there any way that I can train my model only with the dataset of bus and auto, and after training it will detect all 4 objects(car, bike, bus, and auto)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":469,"Q_Id":56802475,"Users Score":0,"Answer":"Load the saved model with pretrained weights. Remove last dense and 2 class softmax layer and add a new dense with 4 class softmax as your low level features are already trained. Now train this model with modified data.","Q_Score":0,"Tags":"python,deep-learning,conv-neural-network,transfer-learning","A_Id":56815137,"CreationDate":"2019-06-28T07:14:00.000","Title":"How to customize a pre-trained model with our own dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recently installed PyCharm on my Raspberry Pi 3 b+ (Running version 9 [Stretch]) and I am having some trouble installing the googleapiclient package on PyCharm and the system.\nWhen I perform a pip\/pip3 install for this package I receive an error stating:\n\nERROR: Could not find a version that satisfies the requirement googleapiclient (from versions: none)\n\n\nERROR: No matching distribution found for googleapiclient\n\nThis is the same error message that I receive on PyCharm when it tries to do a pip install.\nPython 3.7.3 has been installed and 2.7.13 from default.\nPyCharm project interpreter is running 3.5.\nI have performed an apt-get update & upgrade also.\nI have been able to successfully install other packages with pip\/pip3 as well.\nAm I missing any other packages\/dependencies?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7588,"Q_Id":56804061,"Users Score":0,"Answer":"I've had the same issue even though I installed the packages in my cmd Pycharm was not recognizing it, so executing the same command in Pycharm terminal solved the issue for me.","Q_Score":8,"Tags":"python,pycharm,raspberry-pi3,google-api-client","A_Id":70808021,"CreationDate":"2019-06-28T09:10:00.000","Title":"Cannot install googleapiclient on PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to perform a string.find('\\n')on a string with a couple of '\\n' in there (I am looking for the end of a line). However, this always return -1 and does not find the '\\n'. What am I doing wrong?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2345,"Q_Id":56809345,"Users Score":0,"Answer":"My guess is that the backslashes may be escaped, meaning your newline characters may actually be represented as two characters: a backslash and an 'n'.\nTo test, try using string.find('\\\\n') and check if that still returns -1.","Q_Score":2,"Tags":"python,string","A_Id":56809490,"CreationDate":"2019-06-28T15:13:00.000","Title":"Python: string.find('\\n') always yields -1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Problem\nI have a Lambda function in Account 1, which retrieves EC2 instance status.\nSimilarly, I want to retrieve EC2 instance status in other 4 accounts.\nWhat I did\nI Created trust relationship with the other 4 account by updating the IAM role.\nQuestion:\nWill my python code (residing in my lambda function in account 1) is enough to retrieve ec2 instance status from the other 4 accounts? or should I do something more ?\nPlease suggest!\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":22,"Q_Id":56809483,"Users Score":1,"Answer":"Each AWS Account is separate. You cannot access details of one AWS Account from another AWS Account. However, you can temporarily assume an IAM Role from another account to gain access.\nInstead, you will need to:\n\nCreate an IAM Role for the central Lambda function (Lambda-Role) and grant it permission to call AssumeRole\nCreate an IAM Role in each account that you wish to access, grant it permission to call DescribeInstances and configure it to trust Lambda-Role\nThe Lambda function can then loop through each account and:\n\n\nCall AssumeRole for that account, which will return temporary credentials\nUse those credentials to call DescribeInstances","Q_Score":0,"Tags":"python-3.x,amazon-web-services,aws-lambda","A_Id":56813988,"CreationDate":"2019-06-28T15:23:00.000","Title":"Is my python code enough to retrieve ec2 instance status from other accounts?","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 use write code in Javascript, in the Spyder IDE, that is meant for Python. I have read that Spyder supports multiple languages but I'm not sure how to use it. I have downloaded Nodejs and added it to the environment variables. I'd like to know how get Javascript syntax colouring, possibly auto-completion and Help options as well ,and I'd also like to know how to conveniently execute the .js file and see the results in a console.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3235,"Q_Id":56810244,"Users Score":5,"Answer":"(Spyder maintainer here) Sorry but for now we only support Python for all the functionality that you are looking for (code completion, help and code execution).\nOur next major version (Spyder 4, to be released later in 2019) will have the ability to give code completion and linting for other programming languages, but it'll be more of a power-user feature than something anyone can use.","Q_Score":5,"Tags":"javascript,python,spyder","A_Id":56813493,"CreationDate":"2019-06-28T16:20:00.000","Title":"How to use Javascript in Spyder IDE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python loop that at each iteration is creating a new image in a new path. I want to send that path into a process previously executed that is waiting for a path at the command prompt.\nIn more detail:\nI am running a self-driving simulator in python and every 5 frames I want to test that current frame (that is saved in a RAM disk) into an object detector algorithm I have trained (that spends arround 9ms to detect my object BUT 2 seconds to open the process). Actually, I execute the trained algorithm by using the subprocess module, but the problem I have is that when that process is opened (I just open the process once, when I run the main script) it is waiting for a path image. I believe that with your tips I am close to the answer but I don't face how to pass that path image to this subprocess that is waiting for it at each 5 frames iteration. \nPD: I am on Windows, Python 3.5.4\nDo you know what can I do?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":309,"Q_Id":56810924,"Users Score":0,"Answer":"Thank you for all your comments and for your help. Finally I have achieved it.\nI use the library 'pexpect' that allows to launch a program inside a python script with the function process = popen_spawn.PopenSpawn. Then, a function from that library called 'send' allows to pass an argument to that running process (process.send(arg)). \nIn my case, I launch the program (.exe) at the beginning of the script defining that instance as a global variable. Then I just have to execute the send function at each iteration.","Q_Score":1,"Tags":"python","A_Id":56827837,"CreationDate":"2019-06-28T17:17:00.000","Title":"How can I pass a python variable to a process in the command prompt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"So it seems like Buster comes default with 2.7 on load and an alternate 3.7 version of Python. However, I am using this Raspberry Pi 3 B+ just for an application that is only compatible with Python 3.5. How do run Python 3.5 as default version or remove 3.7 entirely from Buster?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":14894,"Q_Id":56814302,"Users Score":1,"Answer":"I truly believe that you can just install python3.5 from the source repos.\nIf you want to install python 3.5.4 : \nsudo apt-get install python3.5\nIf you want to install python 3.5.3 (Debian Stretch) :\nEdit as root \/etc\/apt\/source.list and add the following repos,\ndeb http:\/\/mirrordirector.raspbian.org\/raspbian\/ stretch main contrib non-free\nrpi firmware deb http:\/\/archive.raspberrypi.org\/debian\/ stretch main ui\nThen install the specific package version from the target repo using the following command : \nsudo apt-get install python3.5 -t stretch\nIf want to install pip3.5 (which i guess you would need) : \nwget https:\/\/bootstrap.pypa.io\/get-pip.py\npython3.5 .\/get-pip.py","Q_Score":3,"Tags":"python,python-3.x,raspberry-pi3,raspbian,debian-buster","A_Id":56842605,"CreationDate":"2019-06-29T00:32:00.000","Title":"Downgrade Python 3.7 to 3.5 on Raspbian 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So it seems like Buster comes default with 2.7 on load and an alternate 3.7 version of Python. However, I am using this Raspberry Pi 3 B+ just for an application that is only compatible with Python 3.5. How do run Python 3.5 as default version or remove 3.7 entirely from Buster?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":14894,"Q_Id":56814302,"Users Score":0,"Answer":"just need to follow 1 step\ndo not remove python3.7 directly it will cause problems \ninstall 3.5 and directly start using it.\nafter 3.5 install you can remove python 3.7\nkeep it simple. :)","Q_Score":3,"Tags":"python,python-3.x,raspberry-pi3,raspbian,debian-buster","A_Id":57602834,"CreationDate":"2019-06-29T00:32:00.000","Title":"Downgrade Python 3.7 to 3.5 on Raspbian 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to install Quandl and have been running into some issues. I used the Command Prompt and entered in my Python Path but it seems like the Command prompt just reads the input and proceeds to skip a line and does not install Quandl.\nPlease advise. Beyond that too, I am having a hard time getting my Anaconda to run. I think I might have messed up the installation process. I am using Enthought Canopy but my preference is more geared towards Anaconda. Is there a way to completely wipe out Anaconda from the computer and start clean?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":56814901,"Users Score":0,"Answer":"You might want to use a VirtualEnv for your Python project.  This will allow you to define your package library requirements in a requirements.txt file.  \nYou would add the word quandl in this file, then activate the VirtualEnv and run pip install -r requirements.txt.  At this point you should be able to have the library available to the VirtualEnv.","Q_Score":0,"Tags":"python,quandl","A_Id":56814941,"CreationDate":"2019-06-29T03:36:00.000","Title":"Having a hard time installing Quandl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to create a program that runs automatically every time I download a file from browser.\nFor example, when I download an image file from chrome, the program runs automatically and perform tasks. Is it possible?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2023,"Q_Id":56815065,"Users Score":2,"Answer":"I think you need some kind of \"listening\" script running on background which will monitor files in download directory","Q_Score":2,"Tags":"python","A_Id":56815135,"CreationDate":"2019-06-29T04:26:00.000","Title":"How to make python program run automatically every time I download a file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to add my Python interpreter to PyCharm but whenever I navigate to python.exe and click Ok it says Invalid Python interpeter name 'python.exe'! (the spelling mistake for interpeter is how it's spelled in the dialog that appears)\nI installed Python through the Microsoft app store. The interpreter is located at ~\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe. This is the path I navigate to when selecting the interpreter in PyCharm. There are also python3.exe and python3.7.exe but those don't work either. I can run python from the command line and it behaves as expected.","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":11359,"Q_Id":56815082,"Users Score":2,"Answer":"I got the same error message when I imported a project of an existing virtual environment to pyCharm. Though the name and path of the exe was correct, pyCharm did not accept it.\nMy solution was to remove the Interpreter in pyCharm and to add it again. Then the Error was gone. Perhaps that can help someone ...","Q_Score":8,"Tags":"python,python-3.x,pycharm,python-3.7","A_Id":64122874,"CreationDate":"2019-06-29T04:33:00.000","Title":"How to resolve \"Invalid Python interpreter name 'python.exe'!\" error in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to add my Python interpreter to PyCharm but whenever I navigate to python.exe and click Ok it says Invalid Python interpeter name 'python.exe'! (the spelling mistake for interpeter is how it's spelled in the dialog that appears)\nI installed Python through the Microsoft app store. The interpreter is located at ~\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe. This is the path I navigate to when selecting the interpreter in PyCharm. There are also python3.exe and python3.7.exe but those don't work either. I can run python from the command line and it behaves as expected.","AnswerCount":5,"Available Count":3,"Score":-0.0399786803,"is_accepted":false,"ViewCount":11359,"Q_Id":56815082,"Users Score":-1,"Answer":"In case anyone else is still facing this issue, reinstalling PyCharm did the trick for me.","Q_Score":8,"Tags":"python,python-3.x,pycharm,python-3.7","A_Id":61968515,"CreationDate":"2019-06-29T04:33:00.000","Title":"How to resolve \"Invalid Python interpreter name 'python.exe'!\" error in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to add my Python interpreter to PyCharm but whenever I navigate to python.exe and click Ok it says Invalid Python interpeter name 'python.exe'! (the spelling mistake for interpeter is how it's spelled in the dialog that appears)\nI installed Python through the Microsoft app store. The interpreter is located at ~\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe. This is the path I navigate to when selecting the interpreter in PyCharm. There are also python3.exe and python3.7.exe but those don't work either. I can run python from the command line and it behaves as expected.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":11359,"Q_Id":56815082,"Users Score":0,"Answer":"Remove the interpreter (by using minus sign) and add it again!","Q_Score":8,"Tags":"python,python-3.x,pycharm,python-3.7","A_Id":69177385,"CreationDate":"2019-06-29T04:33:00.000","Title":"How to resolve \"Invalid Python interpreter name 'python.exe'!\" error in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to setup a server to run on startup (Raspberry Pi) - the server calls a script which calls a script...except they're not firing.\n\nadd the cron job using crontab -e and writing @reboot python3 \/path\/to\/my_server.py (also tested with & at end of line)...this works fine.\nmy_server.py uses httpd.server_forever() to listen at a few endpoints...this works fine.\nOne of the server endpoints runs subprocess.Popen(['python3', '\/path\/to\/my_script.py']).\nmy_script.py then runs subprocess.Popen(['qgis']) (also tried with shell=True).\n\nHowever, QGIS isn't starting.\nThis is only happening when trying to run everything on boot with the cron job. If I manually open a terminal and run python3 \/path\/to\/my_server.py then everything works as expected. I'm thinking it has to do with...things not being run in a shell\/terminal - maybe a behavior of Popen?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":56816358,"Users Score":0,"Answer":"The issue is that QGIS requires x server to be running, and cron won't have that by default.\nFix: change cron entry to be @reboot export DISPLAY=:0; python3 \/path\/to\/my_server.py and everything works!","Q_Score":0,"Tags":"python,shell,cron,subprocess,qgis","A_Id":56821316,"CreationDate":"2019-06-29T09:07:00.000","Title":"Python subprocess.popen from within a cron job","Data Science and Machine Learning":0,"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 setup:\nI am using python3 and the socket module to setup a socket using ipv4 and tcp, listening and receiving data via an open port. I have a simple server and client where the client sends a request and the server responses. \nMy problem:\nI did some research and many people suggest that an open port is like an open door so how can I lock it? My goal is to secure my server and my client and not the data that is transmitted (which means the data shouldn't be altered but it does not matter if somebody reads it). I just want to make sure that neither the server nor the client receives wrong data or can be hacked in any way. If both the server and the client are normal computers with build-in firewalls are those sufficient?\nQuestions:\n\nHow can I make sure that the data I transmit can't be altered?\nIs the firewall (normal firewall that every computer has built-in) of the server sufficient when listening, receiving and sending data via an open port? If not what can I do to make sure the server can't be hacked in any way (obviously not entirely but as good as possible)?\nSame as question 2. just for a client (which as far as I am concerned does use an open port or at least not like the server)\n\nPS: If possible using python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":412,"Q_Id":56816388,"Users Score":0,"Answer":"A Basic level of security for the server side would be to send a random key along with the data for verification of trusted client. If the list of clients that are going to send data are known you can just whitelist the IP addresses which accept data only from a specific list of IP addresses.","Q_Score":1,"Tags":"python,sockets,security,tcp,server","A_Id":56816527,"CreationDate":"2019-06-29T09:15:00.000","Title":"How to secure a python socket listening, sending and receiving on an open port?","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 add a numpy array x = [1,2,3,4] to \"the end\" of a numpy array of shape (n,4) (i.e. \"push\" x onto the array) while removing the first element (i.e. \"shift\" the array). So basically, after adding my array x, the (4) shaped array that was added last should be removed.\nHow does one do this in the computationally most efficient manner?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":140,"Q_Id":56817603,"Users Score":0,"Answer":"You're describing a ring buffer.  Just use a normal NumPy array plus an integer which tells you which row is the \"top.\"  To push, simply replace the \"top\" row with a new row and increment the top index.","Q_Score":0,"Tags":"python,numpy","A_Id":56817681,"CreationDate":"2019-06-29T12:40:00.000","Title":"How to \"push and shift\" an element in a numpy array most efficiently?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am asking this because I don't want to use Javascript; instead I want to use Python as an alternative.\nIf this is not possible, please give an alternative apart from jQuery.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1911,"Q_Id":56820558,"Users Score":1,"Answer":"Yes.You can first you need to download XMAPP AND Python3 then open XMAPP -> apache config notepad will be open then find AddHandler.  AddHandler-> AddHandler cgi-script.cgi.pl.asp.py -> save it.Then the .py extension created.","Q_Score":1,"Tags":"javascript,python,html","A_Id":56820729,"CreationDate":"2019-06-29T20:09:00.000","Title":"Can I use Python instead of Javascript in front-end development?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to make a temporary table a create on pyspark available via Thrift. My final goal is to be able to access that from a database client like DBeaver using JDBC.\nI'm testing first using beeline.\nThis is what i'm doing.\n\nStarted a cluster with one worker in my own machine using docker and added spark.sql.hive.thriftServer.singleSession true on spark-defaults.conf\nStarted Pyspark shell (for testing sake) and ran the following code:\nfrom pyspark.sql import Row\nl = [('Ankit',25),('Jalfaizy',22),('saurabh',20),('Bala',26)]\nrdd = sc.parallelize(l)\npeople = rdd.map(lambda x: Row(name=x[0], age=int(x[1])))\npeople = people.toDF().cache()\npeebs = people.createOrReplaceTempView('peebs')\nresult = sqlContext.sql('select * from peebs')\nSo far so good, everything works fine.\nOn a different terminal I initialize spark thrift server:\n.\/sbin\/start-thriftserver.sh   --hiveconf hive.server2.thrift.port=10001 --conf spark.executor.cores=1 --master spark:\/\/172.18.0.2:7077\nThe server appears to start normally and I'm able to see both pyspark and thrift server jobs running on my spark cluster master UI.\nI then connect to the cluster using beeline\n.\/bin\/beeline\nbeeline> !connect jdbc:hive2:\/\/172.18.0.2:10001\nThis is what I got\n\nConnecting to jdbc:hive2:\/\/172.18.0.2:10001\n  Enter username for jdbc:hive2:\/\/172.18.0.2:10001: \n  Enter password for jdbc:hive2:\/\/172.18.0.2:10001: \n  2019-06-29 20:14:25 INFO  Utils:310 - Supplied authorities: 172.18.0.2:10001\n  2019-06-29 20:14:25 INFO  Utils:397 - Resolved authority: 172.18.0.2:10001\n  2019-06-29 20:14:25 INFO  HiveConnection:203 - Will try to open client transport with JDBC Uri: jdbc:hive2:\/\/172.18.0.2:10001\n  Connected to: Spark SQL (version 2.3.3)\n  Driver: Hive JDBC (version 1.2.1.spark2)\n  Transaction isolation: TRANSACTION_REPEATABLE_READ\n\nSeems to be ok.\nWhen I list show tables; I can't see anything.\n\nTwo interesting things I'd like to highlight is:\n\nWhen I start pyspark I get these warnings\n\nWARN  ObjectStore:6666 - Version information not found in metastore. hive.metastore.schema.verification is not enabled so recording the schema version 1.2.0\nWARN  ObjectStore:568 - Failed to get database default, returning NoSuchObjectException\nWARN  ObjectStore:568 - Failed to get database global_temp, returning NoSuchObjectException\n\nWhen I start the thrift server I get these:\n\nrsync from spark:\/\/172.18.0.2:7077\n  ssh: Could not resolve hostname spark: Name or service not known\n  rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]\n  rsync error: unexplained error (code 255) at io.c(235) [Receiver=3.1.2]\n  starting org.apache.spark.sql.hive.thriftserver.HiveThriftServer2, logging to ...\n\n\nI've been through several posts and discussions. I see people saying we can't have temporary tables exposed via thrift unless you start the server from within the same code. If that's true how can I do that in python (pyspark)?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1684,"Q_Id":56820752,"Users Score":0,"Answer":"createOrReplaceTempView creates an in-memory table. The Spark thrift server needs to be started on the same driver JVM where we created the in-memory table.\nIn the above example, the driver on which the table is created and the driver running STS(Spark Thrift server) are different.\nTwo options\n1. Create the table using createOrReplaceTempView in the same JVM where the STS is started.\n2. Use a backing metastore, and create tables using org.apache.spark.sql.DataFrameWriter#saveAsTable so that tables are accessible independent of the JVM(in fact without any Spark driver.   \nRegarding the errors:\n1. Relates to client and server metastore version.\n2. Seems like some rsync script trying to decode spark:\\\\ url\nBoth doesnt seems to be related to the issue.","Q_Score":1,"Tags":"python,apache-spark,pyspark,thrift,spark-thriftserver","A_Id":56824231,"CreationDate":"2019-06-29T20:41:00.000","Title":"How to view pyspark temporary tables on Thrift server?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to size a box classification system where boxes get on a queue until the packaging quantity is reached. Then they all leave the queue at a fixed rate.\nThis is done real time with production. I can estimate the volume for each SKU but I can't predict the order in which they will arrive at the classification\/sorting facility. However I can look at previous manufacturing data to test the algorithm.\nThe key point is how would you estimate the needed bins\/queues to accomplish the sorting (minimizing the \"all queues used\" condition)\nI thought of queue theory but I want to run some simulations with the known data (data is not totally random) and most of what I searched assumes random entry to queues.\nI'm starting to write a python script to model the queue behavior myself with given fixed times for queue evacuation.\nAny suggestions?\nThanks in advance.\nIdeally should be python based\nThe expected output should be the used queues vs time and, in case of a limited number of queues, the number of boxes \"discarded\" vs time","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":56821368,"Users Score":0,"Answer":"Your question is frustratingly vague. I think I understand what you're asking for, but a little more detail would help.\nAs I understand it, you have something like an order processing facility, where each order is a queue in which you hold items until all the items for the order arrive. Then you release that queue at some rate (x seconds per item, or something like that).\nThe number of queues you need will depend on:\n\nThe expected delivery rate: how many orders per minute do you want to complete? Call this OPM: Orders Per Minute.\nThe average amount of time a queue lives. That is, time from when the first item arrives in the queue until the last item leaves. QLT: Queue Lifetime\n\nThe number of queues you need is OPM * QLT. If you want to deliver 100 orders per minute, and the average queue lifetime is 3 minutes. You will need 300 queues. If the average queue lifetime is 30 seconds, then you only need 50 queues.\nThe queue lifetime is a combination of how long it takes to fill the queue, and how long it takes to empty it. Call those QFT and QET. QET is easy: the average number of items in an order, divided by the queue empty rate. You said that items are released from the queue at a fixed rate. If the average order size is 5 items, and you empty the queue at a rate of 12 items per minute, then it will take 5\/12 minutes (25 seconds) to empty the queue.\nQFT (queue fill time) depends on the average order size and the average time it takes an item to be picked and delivered to the queue. If you can't get that from your manufacturing data, then you'll have to estimate it yourself.\nDoing those calculations gives you a good estimate of how your system should react on average. You can then build a simple simulation using those numbers, and begin varying one or more of the parameters. For example, what happens if the average number of items per order gets larger or smaller for a period. If it gets larger, then QLT will probably increase. If it gets smaller, QLT will decrease, but you'll probably have more concurrent orders (and thus need more queues).","Q_Score":0,"Tags":"python,queue,classification,bins","A_Id":56822417,"CreationDate":"2019-06-29T22:55:00.000","Title":"How to calculate the number of queues needed in a box classification\/packaging problem?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Basically I want to store a buttons service server-side that way it can persist through browser closes and page refresh.\nHere's what the user is trying to do\n\nThe user searches in a search bar for a list of products.\nWhen the results show up, they are shown a button that triggers an action for each individual product. They are also shown a master button that can trigger the same action for each product that is listed.\nUpon clicking the button, I want to disable it for 30 seconds and have this persist through page refreshes and browser close.\n\nWhat I've done\nCurrently I have this implemented using AJAX calls on the client side, but if the page refreshes it resets the button and they can click it again. So I looked into using javascript's localStorage function, but in my situation it would be better just to store this on the server.\nWhat I think needs to happen\n\nCreate a model in my Django app for a button. Its attributes would be its status and maybe some meta data (last clicked, etc).\nWhenever the client requests a list of products, the views will send the list of products and it will be able to query the database for the respective button's status and implement a disabled attribute directly into the template.\nIf the button is available to be pressed then the client side will make an AJAX POST call to the server and the server will check the buttons status. If it's available it will perform the action, update the buttons status to disabled for 30 seconds, and send this info back to the client in order to reflect it in the DOM.\n\nA couple questions\n\nIs it just a matter of creating a model for the buttons and then querying the database like normal?\nHow do I have Django update the database after 30 seconds to make a button's status go from disabled back to enabled?\nWhen the user presses the button it's going to make it disabled, but it will only be making it disabled in the database. What is the proper way to actually disable the button without a page refresh on the client side? Do I just disable the button in javascript for 30 seconds, and then if they try to refresh the page then the views will see the request for the list of products and it will check the database for each button's status and it will serve the button correctly?\n\nThank you very much for the help!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":246,"Q_Id":56821634,"Users Score":1,"Answer":"Is it just a matter of creating a model for the buttons and then\n  querying the database like normal?\n\nModel could be something like Button (_id, last_clicked as timestamp, user_id)\nWhile querying you could simply sort by timestamp and LIMIT 1 to get the last click. By not overwriting the original value it would ensure a bit faster write. \nIf you don't want the buttons to behave similarly for each user you will have to create a mapping of the button with the user who clicked it. Even if your current requirements don't need them, create an extensible solution where mapping the user with this table is quite easy. \n\nHow do I have Django update the database after 30 seconds to make a\n  button's status go from disabled back to enabled?\n\nI avoid changing the database without a client request mapped to the change. This ensures the concurrency and access controls. And also has higher predictability for the current state of data. Following that, I would suggest not to update the db after the time delta(30 sec). \nInstead of that you could simply compare the last_clicked timestamp and calculate the delta either server side before sending the response or in client side. \nThis decision could be important, consider a scenario when the client has a different time on his system than the server time.\n\nWhen the user presses the button it's going to make it disabled, but\n  it will only be making it disabled in the database. What is the proper\n  way to actually disable the button without a page refresh on the\n  client side? Do I just disable the button in javascript for 30\n  seconds, and then if they try to refresh the page then the views will\n  see the request for the list of products and it will check the\n  database for each button's status and it will serve the button\n  correctly?\n\nYou'd need to do a POST request to communicate the button press timestamp with the db. You'd also need to ensure that the POST request is successful as an unsuccessful request would not persist the data in case of browser closure. \nAfter doing the above two you could disable the button only from the client side without trying the get the button last_clicked timestamp.","Q_Score":0,"Tags":"javascript,python,django,ajax","A_Id":56827841,"CreationDate":"2019-06-30T00:14:00.000","Title":"How do I store information about a front-end button on the Django server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How do you make cplex use a greedy optimization solution as opposed to the optimal solution? Are there parameters you can set or is this not possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":99,"Q_Id":56822596,"Users Score":2,"Answer":"What you can do is to compute the greedy solution yourself and then submit this as a warmstart\/MIP start.\nThere are no parameters to force CPLEX to use a greedy algorithm to construct a solution since it is not clear how weights for a greedy algorithm should be chosen for an arbitrary MIP. So for a general MIP, it is not clear what a greedy algorithm should do exactly and whether it would have a chance to succeed or not.\nIf a model is suitable for a greedy approach then it frequently is easy to implement the greedy approach in an external tool and just warm start CPLEX with that solution.","Q_Score":0,"Tags":"python,cplex","A_Id":56831000,"CreationDate":"2019-06-30T05:22:00.000","Title":"Making CPLEX use a greedy solution","Data Science and Machine Learning":0,"Database and SQL":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 creating a Discord bot that needs to check all messages to see if a certain string is in an embed message created by any other Discord bot. I know I can use message.content to get a string of the message a user has sent but how can I do something similar with bot embeds in Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":467,"Q_Id":56822722,"Users Score":0,"Answer":"Use message.embeds instead to get the embed string content","Q_Score":1,"Tags":"python,bots,embed,message,discord","A_Id":56823113,"CreationDate":"2019-06-30T05:53:00.000","Title":"Using a Discord bot, how do I get a string of an embed message from another 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":"Let say I have fold1, fold2 , fold3.\nI trained fold1,fold2,fold3 with  modelA. \n\n\nA) modelA(fold1) -> modelA(fold2) -> modelA(fold3) \nB) modelA(fold1) -> saved weight modelA(fold1) -> modelA(fold2)->\n  saved weight modelA(fold2) -> modelA(fold3)-> saved weight\n  modelA(fold3) -> ensemble 3 weight \n\nwhich way is the right way to do the k-fold cross validation and why?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":56825542,"Users Score":0,"Answer":"It depends what is your end goal. K-Fold CV is used for finding model hyperparameters.\nAfter this phase you may change your validation dataset and train your model with it.\nIf you want to harness as much data as you can (performing predictions) it might be a good idea to train N models on N different folds and ensemble their predictions. This one is similar to boostrap, all in all your ensemble saw all the data yet it didn't overfit. This approach is N times more computationally intensive though, so it still comes down to your goals.\nFinally, you should get better results with fitting different models to your folds instead of a single one, but this would require separate hyperparameter space for each algorithm.","Q_Score":0,"Tags":"python,cross-validation,k-fold","A_Id":56825630,"CreationDate":"2019-06-30T14:14:00.000","Title":"the way to do the cross validation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The other day during Codechef contest I created a list using range function. \nmy_list = list(range(n))\nwhere n was as large as 10**18. \nIt gave NZEC error on Codechef. So to know what could be the problem I tried creating a list with 10**18 elements in it, using \nmy_list = list(range(10**18))\nbut it gave Memory error. \nSo, how can I tackle such scenario?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":613,"Q_Id":56829450,"Users Score":3,"Answer":"A MemoryError indicates that you've run out of memory on your computer. That's not unsurprising given how large of a list you were trying to create.\nIf an integer took just 4 bytes (as it does in C, Python integers are much larger and more variably sized) 10**18 integers would take something like a million terabytes of RAM.\nWhy do you expect to be able to create such a monumentally huge list? If you think you need such an object to solve a programming problem, the fact that you're running out of memory is probably an indication that there's a cleverer algorithm to be found, which doesn't require nearly as much space.","Q_Score":2,"Tags":"python,python-3.x","A_Id":56829509,"CreationDate":"2019-07-01T02:35:00.000","Title":"How to store large number of values in list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running an Azure function in Azure, the function gets triggered by a file being uploaded to blob storage container. The function detects the new blob (file) but then outputs the following message - Did not find any initialized language workers.\nSetup:\n\nAzure function using Python 3.6.8\nRunning on linux machine\nBuilt and deployed using azure devops (for ci\/cd capability)\nBlob Trigger Function\n\nI have run the code locally using the same blob storage container, the same configuration values and the local instance of the azure function works as expected.\nThe functions core purpose is to read in the .xml file uploaded into blob storage container and parse and transform the data in the xml to be stored as Json in cosmos db.\nI expect the process to complete like on my local instance with my documents in cosmos db, but it looks like the function doesn't actually get to process anything due to the following error:\nDid not find any initialized language workers","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":11078,"Q_Id":56832315,"Users Score":1,"Answer":"This is due to SDK version, I would suggest to deploy fresh function App in Azure and deploy your code there. 2 things to check :\n\nMake sure your local function app SDK version matches with Azure function app.\nCheck python version both side.","Q_Score":30,"Tags":"python-3.x,azure,azure-functions","A_Id":62908637,"CreationDate":"2019-07-01T08:28:00.000","Title":"Azure function - \"Did not find any initialized language workers\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm running an Azure function in Azure, the function gets triggered by a file being uploaded to blob storage container. The function detects the new blob (file) but then outputs the following message - Did not find any initialized language workers.\nSetup:\n\nAzure function using Python 3.6.8\nRunning on linux machine\nBuilt and deployed using azure devops (for ci\/cd capability)\nBlob Trigger Function\n\nI have run the code locally using the same blob storage container, the same configuration values and the local instance of the azure function works as expected.\nThe functions core purpose is to read in the .xml file uploaded into blob storage container and parse and transform the data in the xml to be stored as Json in cosmos db.\nI expect the process to complete like on my local instance with my documents in cosmos db, but it looks like the function doesn't actually get to process anything due to the following error:\nDid not find any initialized language workers","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":11078,"Q_Id":56832315,"Users Score":2,"Answer":"Same error but different technology, environment, and root cause.\nTechnology Net 5, target system windows. In my case, I was using dependency injection to add a few services, I was getting one parameter from the environment variables inside the .ConfigureServices() section, but when I deployed I forget to add the variable to the application settings in azure, because of that I was getting this weird error.","Q_Score":30,"Tags":"python-3.x,azure,azure-functions","A_Id":70135039,"CreationDate":"2019-07-01T08:28:00.000","Title":"Azure function - \"Did not find any initialized language workers\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm running an Azure function in Azure, the function gets triggered by a file being uploaded to blob storage container. The function detects the new blob (file) but then outputs the following message - Did not find any initialized language workers.\nSetup:\n\nAzure function using Python 3.6.8\nRunning on linux machine\nBuilt and deployed using azure devops (for ci\/cd capability)\nBlob Trigger Function\n\nI have run the code locally using the same blob storage container, the same configuration values and the local instance of the azure function works as expected.\nThe functions core purpose is to read in the .xml file uploaded into blob storage container and parse and transform the data in the xml to be stored as Json in cosmos db.\nI expect the process to complete like on my local instance with my documents in cosmos db, but it looks like the function doesn't actually get to process anything due to the following error:\nDid not find any initialized language workers","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":11078,"Q_Id":56832315,"Users Score":0,"Answer":"Took me a while to find the cause as well, but it was related to me installing a version of protobuf explicitly which conflicted with what was used by Azure Functions. Fair, there was a warning about that in the docs. How I found it: went to <your app name>.scm.azurewebsites.net\/api\/logstream and looked for any errors I could find.","Q_Score":30,"Tags":"python-3.x,azure,azure-functions","A_Id":70363312,"CreationDate":"2019-07-01T08:28:00.000","Title":"Azure function - \"Did not find any initialized language workers\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Android vts-tradefed gives error when multiple ADB devices are connected:\n07-01 11:23:20 E\/ProcessHelper: Exception AttributeError: \"'AndroidDevice' object has no attribute 'hal'\" in\n07-01 11:23:20 E\/ProcessHelper: > ignored\n07-01 11:23:20 E\/ProcessHelper: Exception AttributeError: \"'AndroidDevice' object has no attribute 'hal'\" in > ignored\nIdeas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":171,"Q_Id":56833333,"Users Score":0,"Answer":"adb 1.0.41 solved the problem for me. Even adb 1.0.39 works for this usecase but 1.0.40 seems to have the issue.","Q_Score":0,"Tags":"android,python,adb,android-vts","A_Id":56864800,"CreationDate":"2019-07-01T09:42:00.000","Title":"vts-tradefed gives error when multiple ADB devices are connected","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have parsed the content of a file to a variable that looks like this;\n\nb'8,092436.csv,,20f85'\n\nI would now like to find out what kind of filetype this data is coming from, with;\n\nprint(magic.from_buffer(str(decoded, 'utf-8'), mime=True))\n\nThis prints;\n\napplication\/octet-stream\n\nAnyone know how I would be able to get a result saying 'csv'?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":458,"Q_Id":56833465,"Users Score":1,"Answer":"Use magic on the original file. \nYou also need to take into account that CSV is really just a text file that uses particular characters to delimit the content. There is no explicit identifier that indicates that the file is a CSV file. Even then the CSV module needs to be configured to use the appropriate delimiters.\nThe delimiter specification of a CSV file is either defined by your program or needs to be configured (see importing into Excel as an example, you are presented with a number of options to configure the type of CSV to import).","Q_Score":1,"Tags":"python","A_Id":56833965,"CreationDate":"2019-07-01T09:49:00.000","Title":"Python magic is not recognizing the correct content","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to interact (i.e. clicking buttons within app, taking keyboard input and typing for me, etc.) with the Cisco AnyConnect Client, specifically.  \nHowever, I would like to know if there is way that is viable with Python 3 to interact with any other Mac applications.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":56839710,"Users Score":0,"Answer":"I was able to do this using PyAutoGUI like @Mark Setchell stated","Q_Score":0,"Tags":"python-3.x,macos,user-interface","A_Id":57814669,"CreationDate":"2019-07-01T17:09:00.000","Title":"Is there a way to interact with Mac Applications with Python 3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my Python program, I import a module (let's say it's called bananas). The module gets a logger inside its __init__.py by doing this:\n_logger = logging.getLogger(__name__).  Thus, the logger's name is bananas.\nIn my program (the one that imports the module bananas), I also have this line: my_logger = logging.getLogger(\"bananas\").\nDoes this:\n\nOverwrite _logger made in bananas?\nFetch that logger, and thus my_logger now equals _logger?\nSomething else entirely\n\nThank you for your help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":56840220,"Users Score":1,"Answer":"It fetches the bananas logger, so that my_logger is the same object as bananas._logger.","Q_Score":0,"Tags":"python,logging","A_Id":56840272,"CreationDate":"2019-07-01T17:51:00.000","Title":"Python can you accidentally overwrite a logger by using getLogger with the same name?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For each of my tests in a unittest.TestCase suite, I need to do some setup: run a function that returns a different value for each test (depending on some properties of each test that are passed as arguments to the setup function).\nThere is the setUp() hook that I could use, but it does not return a value and does not accept arguments. But let's say arguments aren't important in this case.\nWhat strategy is recommended? \n\nCreating a custom setup function to use inside each test case\nUsing setUp() with global variables\nUsing setUp() with class or instance variables","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2493,"Q_Id":56840887,"Users Score":0,"Answer":"Note my destinction between setup and Setup below: Each test has to so some setup activities, but these are not necessarily put into the Setup method.\nMy preference is that each test function should be easily understood by itself.  I don't want to look at test code wondering \"where does this value suddenly come from\" or the like.  Which means, I avoid a common Setup method but instead use helper functions \/ methods that also have descriptive names.  To be more precise:\n\nIf a test case needs a specific setup, I normally embed it directly into the test.\nIf a subset of the test cases have an identical or similar setup, I consider creating a helper method to extract the common parts.  The name of that helper method should be descriptive, like makeTrafficLightInGreenState for a helper factory to produce a specific type of traffic light object.  In this example I could then also have makeTrafficLightInRedState for a different group of tests.  I find this preferrable over a common Setup method which just creates both the green and the red traffic light: In the end you get confused which part of Setup is relevant for which test.  Certainly, when writing your helper methods, you are also free to give them parameters, which could in the traffic light example result in 'makeTrafficLightInState(green)'.  But, which approach to choose here is situation specific.\nEven if all tests have something in common, like the creation of a certain object, I prefer putting this in a descriptively named helper method rather than relying on the implicit call to Setup.\nSometimes I also use Setup, but only for activities that are not necessary for understanding the logic of the test cases.  For example, if there is some original state that needs to be preserved at the beginning of the test cases and to be restored afterwards, this could be put into Setup without any negative impact on the readability of the individual test cases.\n\nIn your case, you seem to already have a function with parameters that is suited to deliver test case specific data.  I would simply call that function from each test case that needs it.  Or, if calling that function is not simple (you have to create additional objects as arguments for it or the like), again put it into a helper method.","Q_Score":0,"Tags":"python,unit-testing,python-unittest","A_Id":56879061,"CreationDate":"2019-07-01T18:44:00.000","Title":"How to properly use a per-test setup function that returns a value in 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 am looking to use a public API running on a distant server from within my company. For security reasons, I am supposed to redirect all the traffic via the company's PROXY. Does anyone know how to do this in Python?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":312,"Q_Id":56841342,"Users Score":1,"Answer":"Set the HTTP_PROXY environment variable before starting your python script\ne.g. export HTTP_PROXY=http:\/\/proxy.host.com:8080","Q_Score":0,"Tags":"python,proxy,api","A_Id":56841343,"CreationDate":"2019-07-01T15:01:00.000","Title":"Configure proxy with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking to use a public API running on a distant server from within my company. For security reasons, I am supposed to redirect all the traffic via the company's PROXY. Does anyone know how to do this in Python?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":312,"Q_Id":56841342,"Users Score":2,"Answer":"Directly in python you can do :\nos.environ[\"HTTP_PROXY\"] = http:\/\/proxy.host.com:8080.\nOr as it has been mentioned before launching by @hardillb on a terminal :\nexport HTTP_PROXY=http:\/\/proxy.host.com:8080","Q_Score":0,"Tags":"python,proxy,api","A_Id":56841409,"CreationDate":"2019-07-01T15:01:00.000","Title":"Configure proxy with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im new on Python-Kivy library. So im working hard on kivy's documentation.For now i can create a mini games like characters moves,jumps,background moves etc. In widget controls, im using collide_widget option for check widgets impacts.So i have 2 questions about these:\n1- My image's widgets are ALWAYS RECTANGLE. So when i try to use collide_widget for not rectangle images (like character or ball) Python giving me return 'TRUE'. Because i can't define image's widget's like ellipse or something custom shape.Is there any selection for make these widgets ellipse or somethng else for collide_widget controls.\n2- Im seeing only 'collide_widget' control for widgets impact controls? Is there any other check ways for widgets impacts.If so , can you give me a documentation for read and learn.\nThanks for answering already..As you can see im new at Kivy so these widget controls made me fatigue.If there no any option for change this images widgets to ellipse or custom shapes ( like character ) should i use integral for check this image's outside position controls ..?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":26,"Q_Id":56842790,"Users Score":0,"Answer":"Is there any selection for make these widgets ellipse or somethng else for collide_widget controls.\n\nImplement your own collision detection that does what you want, and optionally override collide_widget with that implementation.\n\nIm seeing only 'collide_widget' control for widgets impact controls? Is there any other check ways for widgets impacts\n\nKivy is not a physics engine, its widget layer is primarily there for the purposes of constructing a gui. If you want collision functionality, code it yourself or use a library. For instance, pymunk is an advanced and powerful option.","Q_Score":0,"Tags":"python,widget,kivy","A_Id":56842898,"CreationDate":"2019-07-01T21:40:00.000","Title":"Widget Shapes and Widget Impact Checks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I'm writing a script to take a certain dataset, sample it 100 times using different random seeds, completing all these datasets and then getting the mean error. However, whenever I try to run the script I end up with the error OSError: [Errno 24] Too many open files\nI don't understand what I can do to fix this (if I should do something in the script or in to the system and what). I'm using Python 3 with macOS Mojave. Anybody has a clue?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9162,"Q_Id":56843659,"Users Score":11,"Answer":"The number of open files you're allowed can be increased by using ulimit e.g. in bash you could do:\nulimit -n\nThis will probably print out 256 meaning that at one time a maximum of 256 file descriptors are allowed to be open.\nIncrease the limit:\nulimit -n 30000 # 30,000 open files allowed\nThis sort of thing is generally done on systems running something like server programs that need a file descriptor (a socket descriptor) for each concurrent connection being handled.\nHowever, if you post the code there might be another way to fix this. It doesn't sound like you want\/need multiple file descriptors open at the same time.","Q_Score":9,"Tags":"python,python-3.x,macos-mojave","A_Id":56843690,"CreationDate":"2019-07-01T23:39:00.000","Title":"OSError: [Errno 24] Too many open files - OS Mojave","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am having issues accessing my Binance account information via API in Python. It always gives the APIError Exception but I am able to ping the exchange and get candlestick data successfully. I read through the API documentation and made sure that the API key is valid and I don't think I am missing anything.\nbinance_client = BinanceClient(api_key=api_key, api_secret=api_secret)\n print(binance_client.get_account(recvWindow=60000000))","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4680,"Q_Id":56843717,"Users Score":0,"Answer":"maximum value for recvWindow is 60000.","Q_Score":1,"Tags":"python,binance","A_Id":65251985,"CreationDate":"2019-07-01T23:49:00.000","Title":"binance.exceptions.BinanceAPIException: APIError(code=-1022): Signature for this request is not valid","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between Swift's Automatic Reference Counting and Python's (manual) reference counting? \nIs it because Swift supports weak var to automatically clean up circular data structures, while in Python there is no such thing and you have to manually del it, otherwise memory leaks?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":140,"Q_Id":56844255,"Users Score":0,"Answer":"Swift ARC(Automatic reference counting), According Apple\n\nSwift uses Automatic Reference Counting (ARC) to track and manage your app\u2019s memory usage.\n  ARC automatically frees up the memory used by class instances when those instances are no longer needed.\n\nSwift will delete object while reference count equal 0.\nPython use Garbage collector","Q_Score":0,"Tags":"python,swift,memory-management","A_Id":56844309,"CreationDate":"2019-07-02T01:34:00.000","Title":"Swift\/Python Reference Counting Difference","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just tried to find out how to install additional Python packages for the standalone installation of Orange3.\nI work on MacOS and want to use the \"SQL Table\" widget which needs pymysql installed. After installing all add-ons, including Prototypes, the said widget still tells me to \"Please install a backend to this widget\". This issue remains when pymysql is installed system wide - which by itself is less than ideal and apparently also not the way Orange is intended to work.\nI was expecting some click and play install for packages similar to the one for add-ons or some prominently displayed information in the documentation which I failed to find (if it is there).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":832,"Q_Id":56847107,"Users Score":2,"Answer":"You can install any pip-installable package in the Add-on dialog, if you use the  \"Add more...\" button.\nYou can also install packages into the Orange app from a terminal if you run python or pip from the app. On my Mac, I would call \/Applications\/Orange3.app\/Contents\/MacOS\/pip + any arguments. In fact, this is what the Add-on dialog does.","Q_Score":2,"Tags":"python,orange","A_Id":56851044,"CreationDate":"2019-07-02T07:10:00.000","Title":"How to install Python packages for Orange3 standalone installation","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to search for last occurence of a pattern \"frame(some variable number)())\" like frame1(), frame2(), frame3().... (it is not exactly a string). I'm interested in getting the variable number which will keep increasing with every occurence.\ni did it by using this code and getting correct answer but i want more efficient solution.\nregex = re.compile('frame*[0-9]*\\(\\)')\n NoOfFrames = len(regex.findall(textfile))\nBut i think there may be more efficient way of finding it rather than listing all the occurrences and then counting it. like if we can start from last line of text file then the first occurence will be the answer. I also tried using this\nm =  mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ)\n  i = m.rfind(regex)   # search for last occurrence of 'word'\n  print(i)\n  m.seek(i)             # seek to the location\n  line = m.readline()   # read to the end of the line\n  print(line)\nbut this will not work because what i'm searching is not exactly a string. My text file is pretty big like in gigabytes and more efficient solution will be appreciated.\nThanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":56849016,"Users Score":0,"Answer":"I got its answer. we can use regex module which have method for backward search of patterns. \nwith open('a.txt', 'r') as file:\n    textfile = file.read()\n output = regex.search(r\"(?r)frame*[0-9]*\\(\\)\", textfile)\n print(output.group(0))\nThis will find first occurence of frame*[0-9]*() from backward and output will be in _regex.Match format. To convert it into string, we can use output.group(0).\nThanks!","Q_Score":0,"Tags":"python,text","A_Id":56930353,"CreationDate":"2019-07-02T09:10:00.000","Title":"Finding last occurence of _sre.SRE_Pattern in a text file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to convert an integer to hexadecimal but I want it to be in bytes object. for example:\ninput: 62353\noutput: b'f391'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":56850538,"Users Score":0,"Answer":"It was solved by using int(62353).to_bytes(length=2, byteorder='big')","Q_Score":1,"Tags":"python-3.x,hex,byte","A_Id":56852987,"CreationDate":"2019-07-02T10:34:00.000","Title":"Convert Int to hexadecimal in form of bytes object","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Numpy has great help function that allows me to search through the numpy documentation from terminal.\nIs there something similar to numpy.lookfor function that works for pandas library?\nI know that numpy.info works with pandas functions and methods but I have to know the name of the method beforehand.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":56851264,"Users Score":0,"Answer":"There is probably no such thing for Pandas library as of today. However useful tip I found out is that you can press tab while typing pandas method in Jupyter Notebook, so it will suggest some possible methods. \nAlso by pressing shift and tab you can get information about the method within jupyter notebook. Pressing shift and 4 times tab will conveniently open a simple window that contains all the information about specific method.\nNot exactly as numpy.lookfor but stil useful.","Q_Score":3,"Tags":"python,pandas,numpy","A_Id":57441048,"CreationDate":"2019-07-02T11:17:00.000","Title":"Pandas numpy.lookfor equivalent","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building an NLP pipeline and I am trying to get my head around in regards to the optimal structure. My understanding at the moment is the following: \n\nStep1 - Text Pre-processing [a. Lowercasing, b. Stopwords removal, c. stemming, d. lemmatisation,] \nStep 2 - Feature extraction \nStep 3 - Classification - using the different types of classifier(linearSvC etc) \n\nFrom what I read online there are several approaches in regard to feature extraction but there isn't a solid example\/answer. \n\na. Is there a solid strategy for feature extraction ? \nI read online that you can do [a. Vectorising usin ScikitLearn b. TF-IDF] \nbut also I read that you can use Part of Speech or word2Vec or other embedding and Name entity recognition. \nb. What is the optimal process\/structure of using these? \nc. On the text pre-processing I am ding the processing on a text column on a df and the last modified version of it is what I use as an input in my classifier. If you do feature extraction do you do that in the same column or you create a new one and you only send to the classifier the features from that column? \n\nThanks so much in advance","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":52,"Q_Id":56851945,"Users Score":1,"Answer":"The preprocessing pipeline depends mainly upon your problem which you are trying to solve. The use of TF-IDF, word embeddings etc. have their own restrictions and advantages.\n\nYou need to understand the problem and also the data associated with it. In order to make the best use of the data, we need to implement the proper pipeline.\n\nSpecifically for text related problems, you will find word embeddings to be very useful. TF-IDF is useful when the problem needs to be solved emphasising the words with lesser frequency. Word embeddings, on the other hand, convert the text to a N-dimensional vector which may show up similarity with some other vector. This could bring a sense of association in your data and the model can learn the best features possible.\nIn simple cases, we can use a bag of words representation to tokenize the texts.\nSo, you need to discover the best approach for your problem. If you are  solving a problems which closely resembles the famous NLP problems like IMDB review classification, sentiment analysis on Twitter data, then you can find a number of approaches on the internet.","Q_Score":0,"Tags":"python-3.x,pandas,nlp,jupyter-notebook,spacy","A_Id":56852299,"CreationDate":"2019-07-02T11:56:00.000","Title":"NLP Structure Question (best way for doing feature extraction)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Every time I open a python file in visual studio code after system reboot or shutdown it downloads the language server which is roughly 30 MB, so I'm asking if there is a way to make it do the download only once?\nI'm running visual studio code 1.35.1 on an Ubuntu 16.04.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1526,"Q_Id":56857204,"Users Score":7,"Answer":"The language server is downloaded after each upgrade of the Python extension for VS Code and when the language server receives an independent update.\nIf you don't want to download any file, you can switch to Jedi with the setting \"python.jediEnabled\": true.","Q_Score":3,"Tags":"python,visual-studio-code,python-language-server","A_Id":56859782,"CreationDate":"2019-07-02T17:08:00.000","Title":"Visual studio code python language server is downloaded every time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with python flask's requests module. I have installed requests module using :\npip install requests\nAnd verified that requests module exists when I run :\npip list\nBut when I run my python application , I receive import Error for requests module.\nI noticed that pip is installing the module in C:\\Users\\xx\\Documents\\Projects\\Python\\Python3REST\\lib\\site-packages\\ folder BUT  the interpreter is looking for the module in C:\\Users\\xx\\Documents\\Projects\\Python\\Python3REST\\lib\\site-packages\\flask\\ folder.\nI have tried running the command :\npip install --install-option=\"Path to install in\" requests\nBut threw some other error. \nThe import error I am getting states :\nImportError: cannot import name 'requests' from 'flask'\n(C:\\Users\\xx\\Documents\\Projects\\Python\\Python3REST\\lib\\site-packages\\flask\\__init__.py)\nI am working in virtualenv in Windows 10. \nI appreciate any help I can get.\nThank you","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5384,"Q_Id":56861605,"Users Score":1,"Answer":"what if you add that folder to your path? using sys.path.extend?","Q_Score":2,"Tags":"python,pip,virtualenv","A_Id":56861629,"CreationDate":"2019-07-03T00:52:00.000","Title":"pip list shows installed module but still getting import error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"In Jupyter Lab type('some_text') returns str and in idle it returns <class 'str'>.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":109,"Q_Id":56864451,"Users Score":1,"Answer":"IDLE displays the string representation produced by python unchanged.  This is a design decision.  Start interactive python and enter the same thing, or run python -c \"print(type('')) at a command prompt.  Similarly,  type(1), type([]), and type(lambda: None) are <class 'int'>, <class 'list'>, and <class 'function'> in python and hence IDLE.\nJupiter Lab does not have the same constraint, and I presume than it reduces the output to int, list, and function in the latter cases.  (Easy enough with re.)  I presume their thought is something like \"When a user types 'type', they know they will get a class, so no reason to say so.\"","Q_Score":0,"Tags":"python,jupyter-notebook,python-idle,jupyter-lab","A_Id":56873801,"CreationDate":"2019-07-03T06:51:00.000","Title":"Why JupyterLab gives different output than shell?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying out Google Cloud Functions for the first time, and I am using the Python 3.7 runtime. I would like to install package PyYAML so I added this to requirements.txt  \nPyYAML==3.12\nDeployment failed with error:\n\nBuild failed: {\"error\": {\"canonicalCode\": \"INVALID_ARGUMENT\", \"errorMessage\": \"pip_download_wheels had stderr output:\\n  Failed building wheel for pyyaml\\nERROR: Failed to build one or more wheels\\n\\nerror: pip_download_wheels returned code: 1\", \"errorType\": \"InternalError\", \"errorId\": \"44FA08B0\"}}\n\nThat error isn't very helpful. Through trial and error I discovered that if I remove the \"==3.12\" stipulation:\nPyYAML\nthen the deployment succeeds.\nI'm interested to know:\n* Is there a stated policy of which versions of packages are supported in Google Cloud Functions?\n* How can i discover which versions of a particular package (PyYAML in this case) are supported in Google Cloud Functions?\n(I'm using 3.12 because that's what a solution that we have internally is using - I can use a later version, and will do so, but I'm interested in answers to the above)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":131,"Q_Id":56865509,"Users Score":1,"Answer":"I don't think this could be a problem related to GCF. Usually, it should be a problem with Python3.7.\n\n3.13 (2018-07-05)\nRebuild wheels using latest Cython for Python 3.7 support.\n\nAs you can see the change log of PyYAML. I think it just doesn't support Python 3.7 before 3.13 version.","Q_Score":2,"Tags":"python,google-cloud-functions","A_Id":56867380,"CreationDate":"2019-07-03T07:59:00.000","Title":"What versions of Python packages are supported in Google Cloud Functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been working on a stereo imaging project for a few months now. The goal is to track a defined object, compute its position (by using triangulation with stereo camera) and its orientation (by using an IMU). I get really good results, but there is something I don't understand and it's bothering me : the minimum depth in the disparity map obtained after using the WLS filter function available in OpenCV is not the same as the minimum depth in the disparity map obtained with the stereo SGBM algorithm. Why ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":151,"Q_Id":56867814,"Users Score":0,"Answer":"Anyone who might have an idea please?","Q_Score":0,"Tags":"python-3.x","A_Id":56921855,"CreationDate":"2019-07-03T10:13:00.000","Title":"Disparity value difference in Stereo SGBM vs. WLS disparity maps","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a rather complex Flask project structure set up that uses blueprints to separate different \"modules\" from one another, and then different routes in each module. I now want to add socket functionalities to this project using the flask-socketio library. My goal is to assign each socket to it's own thread, managed by an object. The problem I am facing now is that I'm unsure how to properly separate the sockets from one another.\n(Please note that I am very deep in experimentation phase right now, I don't have a final concept yet and therefore no conclusive code snippets to show)\nFrom my understanding each socket has a unique socket-ID, which is stored in flask.request.sid while the context is within a socketio-event. That is great, because I can use this to match events to the open socket, meaning I know which \"disconnect\"-event belongs to which \"connect\"-event, since both have the same socket-ID if they are part of the same socket connection.\nNow the problems start though. I am attempting to find a way that based on which route the socket is called from the socket has different event handlers. Meaning the route ...\/admin\/a manages different events than ...\/admin\/b, because both routes lead to different logical parts of my web application. On an even larger scale, I only have one global socketio-object shared over all blueprints of my application. If I add an event handler to react to socket feedback of blueprint 1, I absolutely don't want blueprint 2 to be able to also trigger it with it's own sockets. \nWhat are the recommended ways of handling socket separation? Is that even something that's getting used in practise or do I have a fundamentally wrong understanding of how socket connections should be used in web applications?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":441,"Q_Id":56867887,"Users Score":2,"Answer":"If you have different logical groups of socket events that you want to be independent of each other, you can use a different namespace for each. In Socket.IO one or more namespaces can be multiplexed on the same physical transport.\nIf you prefer something simpler, just avoid conflicts in the name that you assign to your events.","Q_Score":1,"Tags":"python,flask,socket.io,flask-socketio","A_Id":56878579,"CreationDate":"2019-07-03T10:18:00.000","Title":"How to separate sockets for logically separated Flask routes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm writing a python program to perform certain processing on data for couple of millions (N) users. Outcome of the process would be several 1D arrays for each user (the process would apply on each user separately). I need set and get functions for each user output data.\nI have two options for implementing this:\n1. Create a class with attributes of size N by column_size, so one object that contains big arrays\n2. Create a class for each user and store instances of this class in a list, so a list of N objects\nMy question is that what are pros and cons of each approach in terms of speed and memory consumption?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":56868707,"Users Score":0,"Answer":"The question is rather broad, so I will not go beyond generalities.\nIf you intend to process user by user, then it makes sense to have one object per user.\nOn the other hand, if you mainly process all users at the same time and attribute by attribute, then it makes sense to have classes for attributes each object containing the attribute for all users. That way, if memory become scarce, you can save everything to disk and only have one user (resp. attribute) in memory.","Q_Score":0,"Tags":"python,list,dataframe,object","A_Id":56869092,"CreationDate":"2019-07-03T11:04:00.000","Title":"Pros and cons of an object with big dataframe vs a list of lots of class objects in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written code in Python. In the import section i have the following:\nimport snappy\nimport xlrd\nThe xlrd is a library that can only be used by Python 3.6.  The snappy is a libary that can only be used by Python 2.7. How i can use both Python 2.7 and 3.6?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":56871135,"Users Score":0,"Answer":"You cannot run a program with various versions of Python at once.","Q_Score":0,"Tags":"python","A_Id":56871183,"CreationDate":"2019-07-03T13:19:00.000","Title":"Import from various version of 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 written code in Python. In the import section i have the following:\nimport snappy\nimport xlrd\nThe xlrd is a library that can only be used by Python 3.6.  The snappy is a libary that can only be used by Python 2.7. How i can use both Python 2.7 and 3.6?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":56871135,"Users Score":0,"Answer":"Sadly you can't, you have to use a compatible version of the library you need.\nYou can use python-snappy","Q_Score":0,"Tags":"python","A_Id":56871195,"CreationDate":"2019-07-03T13:19:00.000","Title":"Import from various version of 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 in being a newb to Django I accidentally committed my secret key to a private repository that I have for my website. Considering that I intend to use this site for business purposes, I want to make sure that it is secure as possible. Do I need to generate a whole new Django Key? Or could I possibly just edit lets say, 10 characters of the secret key, add the edited secret key to my .env file, add the .env to my .gitignore file and call it a day? \nI recognize this is not the best approach. I will most likely completely generate a new secret key but I thought this might be an effective quick fix. \nI figure that by doing it this way the new secret key is still randomly generated and the old one is still available on github but useless to anyone who happens to scrape it. \nFYI I am using python-decouple with a .env file which is where I save all my secret variables (aws info, secret key, db info, etc.). I have separate settings files (production.py, development.py, common_settings.py) where both production.py and development.py import all of the data from common_settings.py. I just happened to forget to delete the original settings.py file before I made my first commit.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3533,"Q_Id":56874713,"Users Score":0,"Answer":"I ended up just creating a new key from the site @aaronkazah provided. If you look in the comments under @phd you'll get better clarification on my issue. Not a good reason to provide a quick fix when the best way to do it is to just create a new key. It took seconds. Thanks for the help everyone.","Q_Score":0,"Tags":"django,python-3.x,git,secret-key","A_Id":56875242,"CreationDate":"2019-07-03T16:43:00.000","Title":"Django 2.3: I committed my secret key to a private repository. Can I just edit the secret key myself and then add .env file to .gitignore?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So in being a newb to Django I accidentally committed my secret key to a private repository that I have for my website. Considering that I intend to use this site for business purposes, I want to make sure that it is secure as possible. Do I need to generate a whole new Django Key? Or could I possibly just edit lets say, 10 characters of the secret key, add the edited secret key to my .env file, add the .env to my .gitignore file and call it a day? \nI recognize this is not the best approach. I will most likely completely generate a new secret key but I thought this might be an effective quick fix. \nI figure that by doing it this way the new secret key is still randomly generated and the old one is still available on github but useless to anyone who happens to scrape it. \nFYI I am using python-decouple with a .env file which is where I save all my secret variables (aws info, secret key, db info, etc.). I have separate settings files (production.py, development.py, common_settings.py) where both production.py and development.py import all of the data from common_settings.py. I just happened to forget to delete the original settings.py file before I made my first commit.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3533,"Q_Id":56874713,"Users Score":0,"Answer":"I have tried the same thing but unfortunately it doesn't work for me.\n\nInstall dotenv package: pip install -U python-dotenv\nImport this package and call your .env variable: from dotenv import load_dotenv\n\nExample is below\nfrom dotenv import load_dotenv   #for python-dotenv method\n\nload_dotenv()                    #for python-dotenv method\n\nimport os \n\nuser_name = os.environ.get('USER')\npassword = os.environ.get('password')\n\nprint(user_name, password)\nOutput\nusername password","Q_Score":0,"Tags":"django,python-3.x,git,secret-key","A_Id":65166644,"CreationDate":"2019-07-03T16:43:00.000","Title":"Django 2.3: I committed my secret key to a private repository. Can I just edit the secret key myself and then add .env file to .gitignore?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I just wonder how apache server can know the domain you come from you can see that in Vhost configuration","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19,"Q_Id":56875383,"Users Score":0,"Answer":"By a reverse DNS lookup of the IP; socket.gethostbyaddr(). \nResults vary; many IPs from consumer ISPs won't resolve to anything interesting, because of NAT and just not maintaining a generally informative reverse zone.","Q_Score":0,"Tags":"python","A_Id":56875761,"CreationDate":"2019-07-03T17:35:00.000","Title":"How can I find domain that has been used from a client to reach my server in python socket?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to apply lstm in my speech emotion datasets (dataset of features in numeric values with one column of targets). \nI've done split_train_test. Do I need some other transformation to do in the data set before the model?\nI ask this question because when I compile and fit the model I've got one error in the last dense layer.\n\nError when checking model target: expected activation_2 to have shape (8,) but got array with shape (1,).\n\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":26,"Q_Id":56876204,"Users Score":0,"Answer":"After my internship I learn how to fix out this error and where to look.\nHere's what you have to take care.\nUnexpected error input form\nIf the reported layer is the first it is a cause of the input data for the train of a model as a same shape for a create your model.\nIf this is the last layer that bug then it is the labels that are well coded\nEither you put a sigmoid but the labels are not binary either you put softmax and the labels are in one-hot format [0,1,0]: example 3 classes, this element is of class 2. So, the labels are badly encoded or you are deceived in the function (sigmoid \/ softmax) of your output layer.\nHope this help","Q_Score":0,"Tags":"python,speech-recognition,lstm","A_Id":58441617,"CreationDate":"2019-07-03T18:40:00.000","Title":"How to apply lstm in speech emotion feature","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Databricks to connect to an Eventhub, where each message comming from the EventHub may be very different from another.\nIn the message, I have a body and an id.\nI am looking for performance, so I am avoiding collecting data or doing unecessary processings, also I want to do the saving in parallel by partition. However I am not sure on how to do this in a proper way. \nI want to append the body of each ID in a different AND SPECIFIC table in batches, the ID will give me the information I need to save in the right table. So in order to do that I have been trying 2 approachs:\n\nPartitioning: Repartition(numPartitions, ID) -> ForeachPartition\nGrouping: groupBy('ID').apply(myFunction) #@pandas_udf GROUPED_MAP\n\nThe approach 1 doens't look very attracting to me, the repartition process looks kind unecessary and I saw in the docs that even if I set a column as a partition, it may save many ids of that column in a single partition. It only garantees that all data related to that id is in the partition and not splitted\nThe approach 2 forces me to output from the pandas_udf, a dataframe with the same schema of the input, which is not going to happen since I am transforming the eventhub message from CSV to dataframe in order to save it to the table. I could return the same dataframe that I received, but it sounds weird.\nIs there any nice approach I am not seeing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":56878553,"Users Score":1,"Answer":"If your Id has distinct number of values (kind of type\/country column) you can use partitionBy to store and thereby saving them to different table will be faster.\nOtherwise create a derive column(using withColumn) from you id column by using the logic same as you want to use while deviding data across tables. Then you can use that derive column as a partition column in order to have faster load.","Q_Score":0,"Tags":"python-3.x,pyspark,azure-databricks","A_Id":56882432,"CreationDate":"2019-07-03T22:16:00.000","Title":"How to write each dataframe partition into different tables","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have data. Based on the data (time, latitude, longitude, altitude) determine what are the typical routes that device makes during a full week.\nAfter determining the baseline routes or typical area frequented by device we can start determining an anomaly based on the device traveling outside it\u2019s frequent route\/area.\nAction: The process will then send an \u201calert\u201d to the system is traveling outside it\u2019s frequent area route\nPlease suggest which machine learning algorithm is useful. I am going to start clustering algorithm. Also tell me which python libraries is useful to use machine learning algorithm.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":493,"Q_Id":56881873,"Users Score":-1,"Answer":"First of all, if you use Python, then use scikit-learn.\nFor this problem, there is multiple possibilities.\nOne way is indeed to use a clustering algorithm. For this purpose to get the anomaly too, you can use DBSCAN. It is an algorithm designed to get cluster and the outliers.\nAnother way would be (assuming you have for each device all their position) to use more funny way like a clustering algorithm on all the positions to get the important place, and after an LDA (latent dirichlet allocation) to get the main topics (here the words would be the index of the cluster, the document would be the list of position of each device and so the topics would be the main \"routes\").","Q_Score":1,"Tags":"python-3.x,machine-learning,data-science","A_Id":56925320,"CreationDate":"2019-07-04T06:33:00.000","Title":"Find the outliers or anomaly in gps data (time, latitude, longitude, altitude)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting only upto 10000 members when using telethon how to get more than 10000 \nI tried to run multiple times to check whether it is returning random 10000 members but still most of them are same only few changed that also not crossing two digits\nExpected greater than 10000\nbut actual is 10000","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":56884669,"Users Score":0,"Answer":"there is no simple way. you can play with queries like 'a*', 'b*' and so on","Q_Score":0,"Tags":"python,telegram,telethon","A_Id":56884748,"CreationDate":"2019-07-04T09:21:00.000","Title":"how to get the memebrs of a telegram group greater than 10000","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":"In what environment should I write the code for the telegram bot so that it works even when the console is not running?\nI tried to write code in an online environment, but when I turn it off, the bot does not work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":56886030,"Users Score":0,"Answer":"This depend from the OS you are using (es. Windows, Ubuntu 18.04 etc.), and also from which programming language and which version of it you are  using (es. \"python 3.6\"). \nIf you want to have the code always available to be executed, you need to put the script or the scripts in a server (a dedicated computer) always turned on,you can rent one online or you can do it and set up one by yourself , but this need some knowledge before, and depends on which kind of things you want from your server.\nIf you're still in the early stage of the bot-development i suggest you to use your localhost or local environment in general to test your work, in this way you can focus to one thing at time , useful especially in your first experiences in developing and coding. If it's not strictly necessary i would focus at one thing at time to learn better step by step.","Q_Score":0,"Tags":"bots,telegram,python-telegram-bot","A_Id":56930372,"CreationDate":"2019-07-04T10:32:00.000","Title":"In what environment should I write the code for the telegram bot so that it works even when the console is not 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 training dataset of shape(90000,50) and I trying to fit this in model(Gaussian process regression). This errors out with memory error. I do understand the computation, but is there way to pass data in batches using scikit? I am using the scikit implementation of the GPR algorithm.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":350,"Q_Id":56887202,"Users Score":0,"Answer":"The Gaussian process implementation(Regression\/classification) from scikit is'nt capable of handling big dataset. It can run only upto 15000 rows of data. So I decided to use a different algorithm instead as this seems to be a problem with algorithm.","Q_Score":1,"Tags":"python,machine-learning,keras,scikit-learn,training-data","A_Id":57056265,"CreationDate":"2019-07-04T11:42:00.000","Title":"Is there an option like generator in keras with scikit to process large records of data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to learn pandas and I haven't been able to import it into my code. I have looked at other answers on this site and none of them have worked.\njupyter notebook is not importing my module.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":56888145,"Users Score":0,"Answer":"let's try:\nin jupiter\n\n!pip install pandas --upgrade\nimport pandas as pd\nprint(pd.__version__)\n\nwhat do you see","Q_Score":0,"Tags":"python,pandas,numpy,jupyter-notebook,anaconda","A_Id":56888637,"CreationDate":"2019-07-04T12:38:00.000","Title":"jupyter notebook - problem no module named 'pandas'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For semantic image segmentation, I understand that you often have a folder with your images and a folder with the corresponding masks. In my case, I have gray-scale images with the dimensions (32, 32, 32). The masks naturally have the same dimensions. The labels are saved as intensity values (value 1 = label 1, value 2 = label 2 etc.). 4 classes in total. Imagine I have found a model that was built with the keras model API. How do I know how to prepare my label data for it to be accepted by the model? Does it depend on the loss function? Is it defined in the model (Input parameter). Do I just add another dimension (4, 32, 32, 32) in which the 4 represents the 4 different classes and one-hot code it? \nI want to build a 3D convolutional neural network for semantic segmentation but I fail to understand how to feed in the data correctly in keras. The predicted output is supposed to be a 4-channel 3D image, each channel showing the probability values of each pixel to belong to a certain class.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":207,"Q_Id":56888245,"Users Score":0,"Answer":"The Input() function defines the shape of the input tensor of a given model. For 3D images, often a 5D Tensor is expected, e.g. (None, 32, 32, 32, 1), where None refers to the batch size. Therefore the training images and labels have to be reshaped. Keras offers the to_categorical function to one-hot encode the label data (which is necessary). The use of generators helps to feed in the data. In this case, I cannot use the ImageDataGenerator from keras as it can only deal with RGB and grayscale images and therefore have to write a custom script.","Q_Score":1,"Tags":"python,image,keras,deep-learning,conv-neural-network","A_Id":56973276,"CreationDate":"2019-07-04T12:44:00.000","Title":"Keras preprocessing for 3D semantic segmentation task","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run a python script in Google Cloud which will download 50GB of data once a day to a storage bucket. That download might take longer than the timeout limit on the Google Cloud Functions which is set to 9 minutes.\nThe request to invoke the python function is triggered by HTTP.\nIs there a way around this problem ? I don't need to run a HTTP Restful service as this is called once a day from an external source. (Can't be scheduled) .\nThe whole premise is do download the big chuck of data directly to the cloud. \nThanks for any suggestions.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1242,"Q_Id":56888434,"Users Score":2,"Answer":"9 minutes is a hard limit for Cloud Functions that can't be exceeded.  If you can't split up your work into smaller units, one for each function invocation, consider using a different product.  Cloud Run limits to 15 minutes, and Compute Engine has no limit that would apply to you.","Q_Score":4,"Tags":"python,google-cloud-functions,long-running-processes","A_Id":56888658,"CreationDate":"2019-07-04T12:55:00.000","Title":"Long running python process with Google Cloud Functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"It seems that we can only create a stable size of vehicles in Flow Simulation. How can we change the size(include length, width of car) of vehicles?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":106,"Q_Id":56891526,"Users Score":3,"Answer":"That does not seem to be currently supported, however you can easily change it by adding a length parameter to VehicleParam's add method, and setting type_params['length'] = length in this method. (Also add 'length': length in the self.type_parameters[veh_id] dict if you want to use inflows).","Q_Score":2,"Tags":"python,sumo,flow-project","A_Id":56891741,"CreationDate":"2019-07-04T16:11:00.000","Title":"How to change sizes of vehicle in Flow simulation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to train a deep learning (CNN) model on a dataset containing around 100000 images. Since the dataset is huge (approx 82 Gb), I want to use Google colab since it's GPU supported. How do I upload this full image folder into my notebook and use it?\nI can not use google drive or git hub since my dataset is too large.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":308,"Q_Id":56891871,"Users Score":0,"Answer":"You can try zipping and the unzip on collab\nStep 1: Zip the whole folder\nStep 2:Upload the folder\nStep 3: !unzip myfoldername.zip    \nStep 4:type ls and see folder names to see if successful\nIt would be better if you compress or resize the images to reduce file size using opencv or something","Q_Score":0,"Tags":"python,deep-learning,dataset,google-colaboratory","A_Id":56893072,"CreationDate":"2019-07-04T16:46:00.000","Title":"Uploading images folders from my PC to Google Colab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, i trying to install with the command ecmwf api client conda install -c conda-forge ecmwf-api-client then the warning in the title shows up. I don't know how to proceede\n(base) C:\\Users\\caina>conda install -c conda-forge ecmwf-api-client\nCollecting package metadata (current_repodata.json): done\nSolving environment: failed\nCollecting package metadata (repodata.json): done\nSolving environment: failed\nUnsatisfiableError: The following specifications were found to be incompatible with each other:\n\npip -> python=3.6","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":35577,"Q_Id":56895109,"Users Score":4,"Answer":"Install into a new environment instead of the conda base environment. Recent Anaconda and Miniconda installers have Python 3.7 in the base environment, but you're trying to install something that requires Python 3.6.","Q_Score":19,"Tags":"python,anaconda,conda","A_Id":56959899,"CreationDate":"2019-07-04T23:38:00.000","Title":"How to fix \"UnsatisfiableError: The following specifications were found to be incompatible with each other: - pip -> python=3.6\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, i trying to install with the command ecmwf api client conda install -c conda-forge ecmwf-api-client then the warning in the title shows up. I don't know how to proceede\n(base) C:\\Users\\caina>conda install -c conda-forge ecmwf-api-client\nCollecting package metadata (current_repodata.json): done\nSolving environment: failed\nCollecting package metadata (repodata.json): done\nSolving environment: failed\nUnsatisfiableError: The following specifications were found to be incompatible with each other:\n\npip -> python=3.6","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":35577,"Q_Id":56895109,"Users Score":-1,"Answer":"Simply go to Anaconda navigator.\nGo to Environments, Select Installed (packages, etc.) and then click the version of Python. Downgrade it to a lower version. In your case Python 3.6","Q_Score":19,"Tags":"python,anaconda,conda","A_Id":59539739,"CreationDate":"2019-07-04T23:38:00.000","Title":"How to fix \"UnsatisfiableError: The following specifications were found to be incompatible with each other: - pip -> python=3.6\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I did 'makemigrations' on 'django', the generated file became 'unversioned files'. \nI don't know why.\nHow can I change this unversioned one to versioned files?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":142,"Q_Id":56895286,"Users Score":0,"Answer":"Add your unversioned files in your git branch.\n$ git add unversioned files name","Q_Score":1,"Tags":"python,django,pycharm","A_Id":56897982,"CreationDate":"2019-07-05T00:26:00.000","Title":"Django: pycharm: unversioned files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I did 'makemigrations' on 'django', the generated file became 'unversioned files'. \nI don't know why.\nHow can I change this unversioned one to versioned files?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":142,"Q_Id":56895286,"Users Score":0,"Answer":"In PyCharm, right-click the file and select \"Git | Add\" from the context menu, or drag & drop it from the unversioned files node to a changelist.","Q_Score":1,"Tags":"python,django,pycharm","A_Id":56904670,"CreationDate":"2019-07-05T00:26:00.000","Title":"Django: pycharm: unversioned files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"im trying to install the pyHook package in pycharm but get the error in the title. I have successfully installed it in cmd with pip install pyHook-1.5.1-cp37-cp37m-win_amd64.whl ,but when I go to install it in pycharm I get the aforementioned error :\n\nCollecting pyHook Could not find a version that satisfies the requirement pyHook (from versions: ) No matching distribution found for pyHook","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2905,"Q_Id":56895493,"Users Score":2,"Answer":"I ran into this problem myself, and after alot of searching, found that although pyhook has wheels for python 3, it's incompatible. Look at the last release date for pyhook: October 10th 2008. Python 3 was released in: December 3rd 2008. \nI would suggest that you look into the keyboard module. It supports python 3, and has all of the functions of pyhook as far as I know.","Q_Score":3,"Tags":"python,pycharm,python-3.7,pyhook","A_Id":56899426,"CreationDate":"2019-07-05T01:17:00.000","Title":"Can't install pyHook package \"Could not find a version that satisfies the requirement pyHook\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"im trying to install the pyHook package in pycharm but get the error in the title. I have successfully installed it in cmd with pip install pyHook-1.5.1-cp37-cp37m-win_amd64.whl ,but when I go to install it in pycharm I get the aforementioned error :\n\nCollecting pyHook Could not find a version that satisfies the requirement pyHook (from versions: ) No matching distribution found for pyHook","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2905,"Q_Id":56895493,"Users Score":1,"Answer":"Solved this problem by fixing the package version: PyUserInput==0.1.10","Q_Score":3,"Tags":"python,pycharm,python-3.7,pyhook","A_Id":69811731,"CreationDate":"2019-07-05T01:17:00.000","Title":"Can't install pyHook package \"Could not find a version that satisfies the requirement pyHook\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Keras. I am training my Neural Network and using Early Stopping. My patience is 10 and the epoch with the lowest validation loss is 15. My network runs til 25 epochs and stops however my model is the one with 25 epochs not 15 if I understand correctly\nIs there an easy way to revert to the 15 epoch model or do I need to re-instantiate the model and run 15 epochs?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1076,"Q_Id":56896221,"Users Score":0,"Answer":"Yes, you get the model (weights) corresponding to the epoch when it stops. A commonly used strategy is to save the model whenever the validation loss\/acc improves.","Q_Score":1,"Tags":"python-3.x,tensorflow,keras,neural-network","A_Id":56897110,"CreationDate":"2019-07-05T03:31:00.000","Title":"Early Stopping, Model has gone through how many epochs?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to label images with the various categories that they belong to with a convolutional neural net. For my problem, the image can be in a single category, multiple categories, or zero categories. Is it standard practice to set the zero category as all zeroes or should I add an additional null class neuron to the final layer?\nAs an example, let's say there are 5 categories (not including the null class). Currently, I'm representing that with [0,0,0,0,0]. The alternative is adding a null category, which would look like [0,0,0,0,0,1]. Won't there also be some additional unnecessary parameters in this second case or will this allow the model to perform better?\nI've looked on Stackoverflow for similar questions, but they pertain to Multiclass Classification, which uses the Categorical Crossentropy with softmax output instead of Binary Crossentropy with Sigmoid output, so the obvious choice there is to add the null class (or to do thresholding).","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":791,"Q_Id":56896712,"Users Score":0,"Answer":"The model outputs a probability to each class, and we assign the input to the class which has the highest probability during prediction. The last layer is normally a softmax layer for multiclass classification and sigmoid for binary classification. Both of them squash the input into a range of 0 to 1. We can interpret them as probabilities. So no you cannot have all zeros as a one class (Null), because their values will sum up to 1 (probability). You have to define a new class for Null.","Q_Score":2,"Tags":"python,tensorflow,machine-learning,keras","A_Id":56896809,"CreationDate":"2019-07-05T04:50:00.000","Title":"How to represent the Null class in Multilabel Classification with Convolutional Neural Nets?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to label images with the various categories that they belong to with a convolutional neural net. For my problem, the image can be in a single category, multiple categories, or zero categories. Is it standard practice to set the zero category as all zeroes or should I add an additional null class neuron to the final layer?\nAs an example, let's say there are 5 categories (not including the null class). Currently, I'm representing that with [0,0,0,0,0]. The alternative is adding a null category, which would look like [0,0,0,0,0,1]. Won't there also be some additional unnecessary parameters in this second case or will this allow the model to perform better?\nI've looked on Stackoverflow for similar questions, but they pertain to Multiclass Classification, which uses the Categorical Crossentropy with softmax output instead of Binary Crossentropy with Sigmoid output, so the obvious choice there is to add the null class (or to do thresholding).","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":791,"Q_Id":56896712,"Users Score":5,"Answer":"Yes, the \"null\" category should be represented as just zeros. In the end multi-label classification is a set of C binary classification problems, where C is the number of classes, and if all C problems output \"no class\", then you get a vector of just zeros.","Q_Score":2,"Tags":"python,tensorflow,machine-learning,keras","A_Id":56897025,"CreationDate":"2019-07-05T04:50:00.000","Title":"How to represent the Null class in Multilabel Classification with Convolutional Neural Nets?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for code to extract only the titles from every power point slides. Is there any python function available. Any help is appreciated.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1864,"Q_Id":56896747,"Users Score":-1,"Answer":"in previous versions there was a function like this buitl-in. But it has been abandoned.\nBut if you right click in the Outline view you can choose collapse all, which will give you only the highest level. Then you can copy paste, the slide number of course will not be there, but if you paste to Word every title will be a paragraph so applying a number should do it","Q_Score":2,"Tags":"python,python-3.x,computer-vision,python-pptx,heading","A_Id":60955461,"CreationDate":"2019-07-05T04:54:00.000","Title":"extract all the headings(titles) from a ppt slides","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm wondering why zip() was designed to return tuples and not lists for instance. Is it something that has to do with performance or mutability? Or is it something else?","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":237,"Q_Id":56897435,"Users Score":5,"Answer":"In the fact is that the zip function is designed to :\n\nReturn a list of tuples, where each tuple contains the i-th element from each of the argument sequences. (Source: the docstring of zip function)\n\nFrom this with given arguments you only get one possible result which can't be affected by something else than input that you give. So if the result was list you can modify it and the result will no more be the one expected. The tuples are the solution because they are immutable and you can't affect the result.","Q_Score":6,"Tags":"python,tuples","A_Id":56897653,"CreationDate":"2019-07-05T06:14:00.000","Title":"Why does zip return tuples?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to asynchronous tasks and I'm using django-celery and was hoping to use django-celery-beat to schedule periodic tasks.\nHowever it looks like celery-beat doesn't pick up one-off tasks. Do I need two Celery instances, one as a worker for one off tasks and one as beat for scheduled tasks for this to work?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1283,"Q_Id":56897657,"Users Score":0,"Answer":"Pass -B parameter to your worker, it is a parameter to run beat schedule. This worker will do all other tasks, the ones sent from beat, and the \"one-off\" ones, it really doesn't matter for worker.\nSo the full command looks like:\ncelery -A flock.celery worker -l DEBUG -BE.","Q_Score":1,"Tags":"python,django,celery,django-celery","A_Id":62809186,"CreationDate":"2019-07-05T06:31:00.000","Title":"Django Celery & Django-Celery-Beat","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"sshpass -P mysshpass ssh root@127.0.0.1 \".\/myscript.py\"\nAbove is the command that I execute from shell, it asks me for a password as \"myscript.py\" is scripted to ask for it. But when I execute the same command from python, it doesn't prompt me for password. \nmy python code\nos.system(sshpass -P mysshpass ssh root@127.0.0.1 \".\/myscript.py\")","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":56899164,"Users Score":0,"Answer":"you might consider paramiko module, or by specifiying a key file (rsa private key) with ssh -i (see authorized_keys if you are not familiar with ssh auth","Q_Score":0,"Tags":"python","A_Id":56899185,"CreationDate":"2019-07-05T08:15:00.000","Title":"How to provide a password over ssh 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":1,"Web Development":0},{"Question":"I need to transform an .ui archive to a .py but I can't use the command pyuic4, it said command not found in the terminal. \nI already try installing pyside, pyqt, use uic.py but nothing seems to work.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1336,"Q_Id":56906241,"Users Score":1,"Answer":"So, I finally solved it. I used pyuic5 -x Data.ui -o Data_ui.py in the terminal, but first I opened the folder where the executable pyuic5 was, paste Data.ui and then use the line pyuic5 -x Data.ui -o Data_ui .py. Remember to open the location of the executable in the terminal before using the command","Q_Score":0,"Tags":"python,pyqt","A_Id":56996435,"CreationDate":"2019-07-05T16:01:00.000","Title":"How to transform a .ui to a .py on mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm am running my tests on Azure Pipelines (but the same thing applies to Travis and Appveyor). I have a Python package, let's call it calculator which contains cython extensions. When I push to my repository, the CI servers clone my package and install it using python setup.py develop, then run pytest to run the tests. Running python setup.py develop builds the extensions inplace, so the shared objects are in the actual directory. So when my unittests run import calculator, the cwd is the source directory, so the actual copies of the python scripts are used, which contain the shared object files right there, so everything works fine.\nNow, I want to replace python setup.py develop with python setup.py install. Now, the extensions are no longer built in the current source directory, but are packaged and installed into the python path. However, when pytest is called after installation, python can still find the calculator module in the working directory, and (I guess) ignores the properly installed calculator module. And because the extensions weren't built inplace, the tests fails saying the extension module is not found.\nThe reason I want to do this is because I also have wheels set up to be built on the CI servers. When I build a wheel, I would also like to make sure nothing went wrong and install that wheel and run tests on it. Similarily to python setup.py install, I suppose the calcualtor module in the working directory takes precedence over my installed wheel, and results in extension import errors.\nHow do people typically deal with this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":456,"Q_Id":56908227,"Users Score":1,"Answer":"I've read up quite a bit on this since posting this question and the problem stems from the fact that Python automatically prepends the working directory to sys.path. Since CI servers have their working path set to the source directory, the actual source files take precedence over the installed library. There are two solutions:\n\nWe can switch the package over to a src layout, which just means renaming the typical convention of my calculator package containing source files from calculator to src. This requires that setup is then properly adjusted, and that the src directory contains a single directory called calculator. This, in my opinion, is ugly, so I went with the much simpler option\nsimply remove or rename the source directory on the CI server, so that the package can't be found in the working directory. In my specific case, I just ran mv calculator src before running my tests.","Q_Score":2,"Tags":"python,cython,setuptools,python-wheel","A_Id":56912627,"CreationDate":"2019-07-05T19:15:00.000","Title":"How to test Python wheels on 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to call the PowerModels julia package in python. I have successfully downloaded julia, installed the PowerModels package (ran a successful test in julia), set the ENV[\"PYTHON\"] to \"C:\/Users\/user1\/Anaconda3\/python.exe\", added the PyCall package. Added the bin file of julia to the system variable. Then installed pyjulia using Anaconda.\nWhen I open the python.exe file located in \"C:\/Users\/user1\/Anaconda3\/python.exe\" I can successfully call from julia.PowerModels import run_ac_opf. However when I try to do it from Spyder, Jupyter, or python in Anaconda base I get an error that the procedure entry point cannot be located in the dynamic link library LLVM.dll of julia.\nI am using windows 10, any help is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":492,"Q_Id":56908955,"Users Score":0,"Answer":"If you have multiple installations (thus multiple python.exe files) it is good to check that they are all using the same python.exe interpreter.\nI would try to include the directory containing julia's LLVM.dll in the windows environment variable PATH.","Q_Score":0,"Tags":"python-3.x,julia","A_Id":56933012,"CreationDate":"2019-07-05T20:32:00.000","Title":"Using Julia in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm running a pyautogui script to automate an app I have and the script uses both keyboard and mouse \nI want to be able to normally use my PC while the script is on (which needs the app to be in focus and control the mouse and keyboard) \nI'm wondering if there is a way to be able to make the script run in the background and make windows think the app is in focus and register all mouse clicks and keyboard input to that app \nI've tried to run the script in a VM but that was too slow, maybe there is a an app to make a virtual mouse or a virtual desktop I can use or something similar? \nany method is welcome, thanks\nEDIT: Solution is pywin32","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1308,"Q_Id":56909862,"Users Score":1,"Answer":"You can't do that in pyautogui I believe.\nTry exploring pywinauto instead if you are automating on windows. That module takes control of a desktop application using windows win32.\nHope this helps :))","Q_Score":0,"Tags":"python,python-3.x,pyautogui","A_Id":56910433,"CreationDate":"2019-07-05T22:37:00.000","Title":"How to use pyautogui script in the background","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a task that need to connect Odoo 11 with biometric device to solve the problem about attendance. I searched google a lot but nothing can help me and all of document is about connect with \"ZK Teco\" device. But if another device, is it posible? And what technology in Odoo 11 that i can do to connect? Any suggest for me? Thanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":273,"Q_Id":56910961,"Users Score":0,"Answer":"All biometric devices should be having a database which stores all the relevant data. First find out how does the biometric device store data. If it is in SQL database, you can use SQL commands to retrieve data. One of my client was using an access file and was not ready to move to a SQL database. So I just read the data from the access file itself. So find out how it stores data first.","Q_Score":0,"Tags":"python-3.6,odoo-11","A_Id":56911097,"CreationDate":"2019-07-06T03:14:00.000","Title":"How to connect Odoo 11 with biometric device ( Not ZK device )","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using PyCharm Community Edition and tried versions 2019.1.3 and 2019.1.2. I can create a new project and files to that project but as soon as I write anything (e.g: in a .py file, in a .html file or even entering the script path when adding a configuration) it crashes (also crashes when trying to edit an already existing project). Any suggestions what I can do to fix that?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":80,"Q_Id":56912506,"Users Score":-1,"Answer":"Go to Preferences\/Appearance and select a different font, I used \"Monospace\" and things seem to work again.\nOn my system, PyCharm was crashing when it called into CoreText rendering.  Reinstalling and trashing preferences otherwise didn't work.","Q_Score":1,"Tags":"python,crash,pycharm","A_Id":56962579,"CreationDate":"2019-07-06T08:39:00.000","Title":"PyCharm crashes when I start typing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a node class in Python 3 which I will be storing in a min-ordered multi-tree structure. I overrode the __eq__ method which tests for equality by comparing two unique integer instance variables. \n\nWill this approach work for finding nodes in the structure by comparing equality?\nDo I also need to override __hash__?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":86,"Q_Id":56912574,"Users Score":1,"Answer":"I'm making a node class in Python 3 which I will be storing in a min-ordered multi-tree structure\n\nIf it's the only use, and they are only used internally so user code isn't ever supposed to see a Node, and your code doesn't store them in dicts or sets, or call any functions which do, maybe you can get away without overriding __hash__. \nBut those are very strong restrictions, which can't really be enforced. And there's no benefit to not overriding __hash__ to be consistent with __eq__. So you still should do it.","Q_Score":1,"Tags":"python-3.x,hash,overriding,equality","A_Id":56913038,"CreationDate":"2019-07-06T07:21:00.000","Title":"When you override __eq__ in a class, do you also need to override __hash__?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a node class in Python 3 which I will be storing in a min-ordered multi-tree structure. I overrode the __eq__ method which tests for equality by comparing two unique integer instance variables. \n\nWill this approach work for finding nodes in the structure by comparing equality?\nDo I also need to override __hash__?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":86,"Q_Id":56912574,"Users Score":3,"Answer":"Yes, you have to override __hash__.\nThe general rule is: if two instances are equal (wrt to __eq__, i.e. a==b is True), then they must have the same hash.  Otherwise, all sorts of things can misbehave.\nAlso, it sounds to me __eq__ is not enough for minimum.  At the very least, you'd need to define __lt__.","Q_Score":1,"Tags":"python-3.x,hash,overriding,equality","A_Id":56912622,"CreationDate":"2019-07-06T07:21:00.000","Title":"When you override __eq__ in a class, do you also need to override __hash__?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently started used Atom IDE. It feels good. The only thing that I find difficult is to setup a project profile to run. In pycharm there is Run configuration, is there something similar to it in Atom ?\nI have a project with multiple classes. When ever I want to run my script,I have to go to the main.py to launch 'ctrl + i'.\nCould any one help me to setup the project in a such a way, when I execute 'ctrl + i' it automatically launch's main.py instead of the py file I am calling from.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":811,"Q_Id":56913965,"Users Score":1,"Answer":"In the top bar, under \"packages\", go to \"script\", and select \"configure script\".\nThere put in the directory in which the program is, what command to run (python3 main.py), and select \"save as profile.\" The window explains itself.\nThen, you should be able to run from that profile with Alt+Ctrl+Shift+B, from whatever tab you're on.","Q_Score":0,"Tags":"python-3.x,ide,atom-editor","A_Id":56914347,"CreationDate":"2019-07-06T12:10:00.000","Title":"How to configure Atom script to run main.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":1,"Web Development":0},{"Question":"I tried training an AutoEnsembleEstimator with two DNNEstimators (with hidden units of 1000,500, 100) on a dataset with around 1850 features (after feature engineering), and I kept running out of memory (even on larger 400G+ high-mem gcp vms). \nI'm using the above for binary classification. Initially I had trained various models and combined them by training a traditional ensemble classifier over the trained models. I was hoping that Adanet would simplify the generated model graph that would make the inference easier, rather than having separate graphs\/pickles for various scalers\/scikit models\/keras models.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":39,"Q_Id":56916504,"Users Score":1,"Answer":"Three hypotheses:\n\nYou might have too many DNNs in your ensemble, which can happen if max_iteration_steps is too small and max_iterations is not set (both of those are constructor arguments to AutoEnsembleEstimator). If you want to train each DNN for N steps, and you want an ensemble with 2 DNNs, you should set max_iteration_steps=N, set max_iterations=2, and train the AutoEnsembleEstimator for 2N steps.\nYou might have been on adanet-0.6.0-dev, which had a memory leak. To fix this, try updating to the latest release and seeing if this problem still arises.\nYour batch size might have been too large. Try lowering your batch size.","Q_Score":1,"Tags":"python,tensorflow,tensorflow-estimator,adanet","A_Id":59382368,"CreationDate":"2019-07-06T18:05:00.000","Title":"Adanet running out of memory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to use python 3 for text mining on a 650 MB csv file, which my computer was not powerful enough to do. My second solution was to reach out to google cloud. I have set up my VMs and my jupyter notebook on google cloud, and it works perfectly well. The problem, however, is that I am in constant fear of getting disconnected. As a matter of fact, my connection with google server was lost a couple of time and so was my whole work.\nMy question: Is there a way to have the cloud run my code without fear of getting disconnected? I need to be able to have access to my csv file and also the output file.\nI know there is more than one way to do this and have read a lot of material. However, they are too technical for a beginner like me to understand. I really appreciate a more dummy-friendly version. Thanks!\nUPDATE: here is how I get access to my jupyter notebook on google cloud:\n1- I run my instance on google cloud\n2- I click on SSH \n3- in the window that appears, I type the following:\njupyter notebook --ip=0.0.0.0 --port=8888 --no-browser &\nI have seen people recommend to add nohup to the beginning of the same commend. I have tried it and got this message:\nnohup: ignoring input and appending output to 'nohup.out'\nAnd nothing happens.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":627,"Q_Id":56916897,"Users Score":8,"Answer":"If I understand your problem correctly, you could just run the program inside a screen instance:\nAfter connecting via ssh type screen\nRun your command\nPress ctrl + a, ctrl + d\nNow you can disconnect from ssh and your code will continue to run. You can reconnect to the screen via screen -r","Q_Score":2,"Tags":"python,google-cloud-platform","A_Id":56917173,"CreationDate":"2019-07-06T19:03:00.000","Title":"how to run my python code on google cloud without fear of getting disconnected - an absolute beginner?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have windows 10 with 2 user accounts, one is an old one that has Python installed. My latest account also has Python installed. I used pip install tweepy, and it now exists in the site packages. If I open my Python shell (v3.6.5), it imports fine. However, I can't get this to work when switching to Python in cmd. In here, after typing python, it says Python 3.6.6. Obviously they are different, yet they seem to be originating from the same directory.\nAny ideas?\n[edit] I have just realised that I have an external application that runs on Python 3.6.6., so I guess it's defaulting because of that. However, I can't uninstall that since I need it - is there a way to specify which version of Python is launched when I type python into the cmd?\n[edit2]: This is the issue, and the solution there works. However, I want to be able to just type python into cmd, rather than the entire path. Since both exist in the path (and I don't want to remove the other 3.6.6.), is there a way to achieve this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":56917315,"Users Score":0,"Answer":"When you enter \"python\" into your cmd it searched python.exe in the directories listed on your PATH variable.\nAll you need to do is to modify your PATH and add the directory path in which the python with the desired version is located.","Q_Score":2,"Tags":"python,tweepy","A_Id":56923059,"CreationDate":"2019-07-06T20:08:00.000","Title":"Python conflicts when importing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've downloaded python 3 from their website. When I do 'python --version' in terminal it says I'm on Python 2.7.10.  How do I update it to what I just installed?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":2018,"Q_Id":56917609,"Users Score":3,"Answer":"Have you tried using 'python3 --version'? To use python 3 you have to be explicit and type python3 in the command line.","Q_Score":0,"Tags":"python,macos,terminal","A_Id":56917626,"CreationDate":"2019-07-06T20:56:00.000","Title":"How to update from python 2 to python 3 in terminal on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I coded on my labtop, push code to github. then clone it to my computer for the first time. ( environment are different of course)\nI did all my work on my computer. come home. I deleted old project and clone it back to my labtop instead of doing \"git stash\" and \"git pull\" because when I use \"git stash\" and \"git pull\", a conflict in vcs.xml and workspace.xml within the .idea created by pycharm.\nafter that my pycharm on my labtop cannot recognize interpreter even tho the path that is shown in the interpreter is still the \nI cannot find it on google because keyword to search are not obvious.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":942,"Q_Id":56917920,"Users Score":0,"Answer":"You can make the new project as the root directory by right-clicking on it and then paste the files there, it may help.","Q_Score":1,"Tags":"python,git,github,pycharm","A_Id":56917993,"CreationDate":"2019-07-06T21:55:00.000","Title":"pycharm cannot find interpreter when cloning github of the same project between 2 computers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a python program that displays the time, weather, and anything else that would be suitable to be put in an information center. Is it possible to run this program natively on android and get live updates like the python program?\nI've googled it and haven't been able to find anything close to an answer.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":56,"Q_Id":56918220,"Users Score":1,"Answer":"No, you cannot run tkinter programs on the android platform.","Q_Score":0,"Tags":"java,android,python-3.x,tkinter","A_Id":56918728,"CreationDate":"2019-07-06T23:06:00.000","Title":"Can a tkinter python program be mirrored on an android app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an object which needs to be \"tagged\" with 0-3 strings (out of a set of 20-some possibilities); these values are all unique and order doesn't matter. The only operation that needs to be done on the tags is checking if a particular one is present or not (specific_value in self.tags).\nHowever, there's an enormous number of these objects in memory at once, to the point that it pushes the limits of my old computer's RAM. So saving a few bytes can add up.\nWith so few tags on each object, I doubt the lookup time is going to matter much. But: is there a memory difference between using a tuple and a frozenset here? Is there any other real reason to use one over the other?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":674,"Q_Id":56919409,"Users Score":2,"Answer":"If you're trying to save memory, consider\n\nTrading off some elegance for some memory savings by extracting the data structure of which tags are present into an external (singleton) data structure\nUsing a \"flags\" (bitmap) type approach, where each tag is mapped to a bit of a 32-bit integer. Then all you need is a (singleton) dict mapping from the object (identity) to a 32-bit integer (flags). If no flags are present, no entry in the dictionary.","Q_Score":5,"Tags":"python,memory-management,tuples,frozenset","A_Id":56919483,"CreationDate":"2019-07-07T04:44:00.000","Title":"Which takes less memory, a frozenset or a tuple?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a beginner for python programming, specifically for scientific computing. In python, the index of a np.array, by default, starts from 0. Is it possible to change the index starting from any number, such as -1 ..., like what can do in fortran? thanks a lot.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":56920278,"Users Score":0,"Answer":"No.\nFeel free to write a wrapper class that adjusts slices by such an offset.","Q_Score":0,"Tags":"python-3.x","A_Id":56926165,"CreationDate":"2019-07-07T07:51:00.000","Title":"Is there a pre-defined custom indexed array in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In general, the CNN model uses a square filter. I would like to use a cross filter or X filter. The function of creating a square filter in tensorflow is provided, but information on other filter-types is not available.\nHow can I make a cross filter and\/or an X-filter?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":56921148,"Users Score":0,"Answer":"If I understand your question correctly, you want to use a Cross Filter, like the one whose shape is3*4 rather than a Square Filter, whose shape is 3*3.\nIf that is the case, that is allowed using the Function, tf.keras.layers.Conv2D.\nIn the argument, kernel_size, you need to provide (3,4) instead of just 3 or (3,3).","Q_Score":1,"Tags":"python,tensorflow,filter,conv-neural-network","A_Id":59574175,"CreationDate":"2019-07-07T10:05:00.000","Title":"How to create a CNN cross filter for Tensorflow in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Container 1 : I have a docker container which is spawned by a Dockerfile image that i built serving Python dependencies to a specific use-case. This container is mount to my file system project directory to \/source directory in the Docker container.\nContainer 2 : Another container contains Jupyter notebook and it is only configured to use Jupyter notebook.\nI don't use Jupyter notebook all the time for Python developement, i use my code editor instead. I just want an easier way to mount Jupyter notebook when i want to and edit my project files. \nNow, can i mount Container-2 to Container-1 such that contents in the \/source directory in Container-1 is persisted to my project directory while enabling Container-1 and Conatiner-2 to take up a shared space? In my case i want Container-1 to be mount to my file system to \/source and I want the Jupyter Notebook, running in Container-2 to be able to edit files inside the \/source directory in Container-1.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":56921877,"Users Score":0,"Answer":"if I'm understanding correctly, what you are trying to do is using one container installed libs in another container\nI think that this approach is bad, since there might be some problems with OS level dependencies that are missing. The first possible solution is installing the dependencies in both containers, or at least using the 1st docker image as base to the 2nd\nIf you yet rather doing it your way, you can try mounting volume between the 1st container virtual env \/ site-packages with the 2nd","Q_Score":0,"Tags":"python-3.x,docker,jupyter-notebook,docker-machine","A_Id":56922114,"CreationDate":"2019-07-07T11:45:00.000","Title":"How to connect two containers when one of the container is mount to the filesystem?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"The title clearly says it, \nHow do I go about dragging the message author into the voice channel the bot is currently in?\nSay my bot is in a voice channel alone. A command is called to play sound to the author only. \nBut the author isn't in a voice channel, so I can't use the move_to(*) method, hence the word drag.\nI scrounged the API reference for connections, but I can't seem to find any.\nIs it even possible to drag users into a voice channel?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":179,"Q_Id":56924550,"Users Score":2,"Answer":"Of course you cannot forcibly connect a client to a voice channel - this would directly violate user privacy. Your idea is akin to 'dragging people into phone calls' unexpectedly.","Q_Score":0,"Tags":"python,discord,discord.py,python-3.7,discord.py-rewrite","A_Id":57067105,"CreationDate":"2019-07-07T17:35:00.000","Title":"discord.py rewrite - dragging message author to a 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've been coding in Python 3.7.2 as my usual, but an API that I really want for my code only supports up to 3.6 (and does not support 2.7). I downloaded Python 3.6.4 to my computer, which also downloads a separate instance of the IDLE (not a problem). If I try to import something like numpy to my code in 3.7 (ex. import numpy as np) then it works as expected. However, if I do the same in the 3.6 IDLE I get: \nTraceback (most recent call last):\n  File \"\", line 1, in \n    import numpy as np\nModuleNotFoundError: No module named 'numpy'\nI think that it's a path problem but I'm unsure on how to fix it, and I can't find a solution to this problem elsewhere. Any help is appreciated, thanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":61,"Q_Id":56926952,"Users Score":1,"Answer":"Try to install numpy specifically for python3.6:\npython3.6 -m pip install numpy","Q_Score":0,"Tags":"python,python-3.6,python-3.7,python-idle","A_Id":56926961,"CreationDate":"2019-07-07T23:49:00.000","Title":"Separate versions of Python on same computer won't import same modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list of about 100 HTML webpages (all have different structures, such as divs, anchors, classes, etc.) and I am trying to scrape the title of each page (where the title is under a certain div and class). To do this, I was using get requests and Beautifulsoup, however, this takes way to long (10 minutes every time I want to do it)!\nI used a timer to see what is taking the most time: it's the get requests. Apparently Python (3.7) executes the code one after another, and since each get request takes about 5-6 seconds, it's taking approximately 500-600 seconds to complete the ~100 requests. \nI've searched for ways to make these requests work faster and came across many different solutions. However, a common theme seemed to be that making my requests asynchronous (so all requests start at the same time) will solve the problem (by making it faster).\nThere were many possible solutions for doing this that I read online including: multithreading, using grequest, using Scrapy, parsing lxml, etc. However, I'm new to programming and am not skilled enough to learn and experiment with each way (in fact, I tried following the answers to similar questions on SO, but wasn't successful), so I am unsure what is the best route for me to take. \nI don't need anything fancy; all I want to do is extract the titles from the HTML documents as text and then print them out. I don't need to download any CSS files, images, media, etc. Also, I'm hoping to keep the code as simple\/bare as possible. How can I do this as fast as possible in Python? I'd appreciate it if someone could suggest the best path to take (i.e. using Scrapy), and give a short explanation of what I must do using that tool to get the results I'm hoping for. You don't have to write out the whole code for me. Thanks!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":154,"Q_Id":56928294,"Users Score":1,"Answer":"One of the idea which I can suggest is taking all the urls in Csv and keep few headings like path,title div,body div, image div as per your requirement and keep adding the particular div(div class=\u201dtitle\u201d).\nEx:\n       PATH       TITLE DIV                IMAGE DIV              BODY DIV \nSimilarly, you can give all links in one csv file nd read it through python script so that all data is pulled.","Q_Score":1,"Tags":"python,html,parsing,web-scraping,scrapy","A_Id":56928682,"CreationDate":"2019-07-08T04:05:00.000","Title":"How to scrape many HTML documents quickly using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm done with installing Pycharm, and throughout the wizard, there was a tickbox saying: add to PATH (restart required).\nWhat extra benefit would I get from ticking that box?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":6630,"Q_Id":56929805,"Users Score":1,"Answer":"I don't think PyCharm will want you to put itself in PATH (aside from the charm helper maybe, which launches the IDE akin to subl or code for Sublime Text and Visual Studio Code respectively).\nHaving Python in PATH (I recall the installer does ask that on Windows) will make it possible for you to run python, pip and the other tools from any directory when using the command line.","Q_Score":2,"Tags":"python,pycharm","A_Id":56929845,"CreationDate":"2019-07-08T07:01:00.000","Title":"What's the point of adding a program to PATH?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm done with installing Pycharm, and throughout the wizard, there was a tickbox saying: add to PATH (restart required).\nWhat extra benefit would I get from ticking that box?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6630,"Q_Id":56929805,"Users Score":3,"Answer":"Very short answer, somebody can provide details also I am not an expert.\nIf in windows, adding to path is like adding the program to the environment variables. This means, that instead of executing it to the full path where the .exe is you could call it with an \"alias\".\nTo run python, instead of going somewhere like C:\/Program Files\/Python\/python.exe you could simply type \"python\".","Q_Score":2,"Tags":"python,pycharm","A_Id":56929848,"CreationDate":"2019-07-08T07:01:00.000","Title":"What's the point of adding a program to PATH?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are there any shortcuts for code indentation editing in a jupyter notebook like available in VScode, sublime, etc? \nSpecifically, I need help for shifting back a selected piece of code by one tab space.","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":30285,"Q_Id":56929971,"Users Score":4,"Answer":"just select and drag from the beginning of the code piece until the line you wish for while holding alt to choose multiple indexes at multiple lines (or you can use it for rectangular selection too)\nafter that tab for right indentation and shift+tab for left indentation","Q_Score":10,"Tags":"python,jupyter-notebook","A_Id":56930157,"CreationDate":"2019-07-08T07:14:00.000","Title":"shortcuts for editing code indentation in jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are there any shortcuts for code indentation editing in a jupyter notebook like available in VScode, sublime, etc? \nSpecifically, I need help for shifting back a selected piece of code by one tab space.","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":30285,"Q_Id":56929971,"Users Score":3,"Answer":"I don't know how it works in VScode, but for indentation in Jupyter Notebook you just have to mark the line\/lines that you want to intend and then press SHIFT+TAB for back shifting the indentation or TAB for indentation.","Q_Score":10,"Tags":"python,jupyter-notebook","A_Id":56930160,"CreationDate":"2019-07-08T07:14:00.000","Title":"shortcuts for editing code indentation in jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on a dataset that provides information over several years about employees at a big company. Information includes whether or not the employee quit that year (True or False for every year), what Tax Bracket they're in and what age they are. Based on the dataset, I have plottet the percentage of people quitting against their age, and the percetange of people quitting against their tax bracket. Assuming those numbers can be considered as the probability of someone quitting given their age, and the probability of someone quitting given their tax bracket, I would like to find a way to predict the probability of someone quitting given both age and tax bracket.\nI cannot use our dataset for that, because it is too small and most combinations do not occur in it (so I simply get 0% for everything). Is there a way to predict it, using some kind of model?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":56931584,"Users Score":0,"Answer":"A direct and simple approach would be to use the mean of the percentage you get from the age and tax bracket that they are in. The downsides is that you consider that both those variables are independant and have the same weight in deciding wether an employee will quit or not.\nA better approach would be to use a classifier to give you a more accurate prediction of the probability of the employee quitting based on his tax bracket and age. You could start with common classifiers like Random Forest.","Q_Score":0,"Tags":"python,dataframe,statistics,probability","A_Id":56931866,"CreationDate":"2019-07-08T09:04:00.000","Title":"Predict the probability of someone leaving based on two conditions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The above mentioned error occurred while trying to run a cloud function in Google Cloud Platform. The error occurred in its main.py written in python in the line \"storage_client=storage.Client()\" \nI have also checked the github repository for google-cloud-python\/storage\/google\/cloud\/storage\/_http.py  line 33 where it is showing error but I have done nothing with those variables anywhere, I reckon\nAny help will be appreciated","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":369,"Q_Id":56932945,"Users Score":2,"Answer":"I just experienced this same issue-- \nShort answer-- upgrade the google-cloud-core package: e.g. in my case I had \ngoogle-cloud-core==0.29.1\nUpgrading to version 1.0.2 solved my issue:\npip3 install --upgrade google-cloud-core==1.0.2\nFor me, this arose from installing all my python packages from a requirements.txt file, which had explicit versions.  Sometime later, I must have upgraded and the packages did not stay aligned.","Q_Score":1,"Tags":"google-cloud-platform,google-cloud-functions,google-cloud-storage,google-api-python-client","A_Id":57914005,"CreationDate":"2019-07-08T10:24:00.000","Title":"How to fix error \"File \"\/...\/google\/cloud\/storage\/_http.py\", line 33, in __init__ TypeError: __init__() takes 2 positional arguments but 3 were given\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using regression to analyze server data to find feature importance.\nSome of my IVs (independent variables) or Xs are in percentages like % of time, % of cores, % of resource used, while others are in numbers like number of bytes, etc.\nI standardized all my Xs with (X-X_mean)\/X_stddev. (Am I wrong in doing so?)\nWhich algorithm should I use in Python in case my IVs are a mix of numeric and %s and I predict Y in the following cases:\n\nCase 1: Predict a continuous valued Y\na.Will using a Lasso regression suffice?\nb. How do I interpret the X-coefficient if X is standardized and is a\n  numeric value?\nc. How do I interpret the X-coefficient if X is standardized and is a\n  %?\nCase 2: Predict a %-ed valued Y, like \"% resource used\".\na. Should I use Beta-Regression? If so which package in Python offers\n  this?\nb. How do I interpret the X-coefficient if X is standardized and is a\n  numeric value?\nc. How do I interpret the X-coefficient if X is standardized and is a\n  %?\n\nIf I am wrong in standardizing the Xs which are % already, is it fine to use these numbers as 0.30 for 30% so that they fall within the range 0-1? So that means I do not standardize them, I will still standardize the other numeric IVs.\n\nFinal Aim for both Cases 1 and 2:\nTo find the % of impact of IVs on Y. \n  e.g.: When X1 increases by 1 unit, Y increases by 21% \n\nI understand from other posts that we can NEVER add up all coefficients to a total of 100 to assess the % of impact of each and every IV on the DV. I hope I am correct in this regard.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":173,"Q_Id":56933059,"Users Score":1,"Answer":"Having a mix of predictors doesn't matter for any form of regression, this will only change how you interpret the coefficients. What does matter, however, is the type\/distribution of your Y variable\n\nCase 1: Predict a continuous valued Y\na.Will using a Lasso regression suffice?\n\nRegular OLS regression will work fine for this\n\nb. How do I interpret the X-coefficient if X is standardized and is a\nnumeric value?\n\nThe interpretation of coefficients always follows a format like \"for a 1 unit change in X, we expect an x-coefficient amount of change in Y, holding the other predictors constant\"\nBecause you have standardized X, your unit is a standard deviation. So the interpretation will be \"for a 1 standard deviation change in X, we expect an X-coefficient amount of change in Y...\"\n\nc. How do I interpret the X-coefficient if X is standardized and is a\n%?\n\nSame as above. You units are still standard deviations, despite it originally coming from a percentage\n\nCase 2: Predict a %-ed valued Y, like % resource used.\na. Should I use Beta-Regression? If so which package in Python offers\nthis?\n\nThis is tricky. The typical recommendation is to use something like binomial logistic regression when your Y outcome is a percentage.\n\nb. How do I interpret the X-coefficient if X is standardized and is a\nnumeric value?\nc. How do I interpret the X-coefficient if X is standardized and is a\n%?\n\nSame as interpretations above. But if you use logistic regression, they are in the units of log odds. I would recommend reading up on logistic regression to get a deeper sense of how this works\n\nIf I am wrong in standardizing the Xs which are a % already , is it\nfine to use these numbers as 0.30 for 30% so that they fall within the\nrange 0-1? So that means I do not standardize them, I will still\nstandardize the other numeric IVs.\n\nStandardizing is perfectly fine for variables in regression, but like I said, it changes your interpretation as your unit is now a standard deviation\n\nFinal Aim for both cases 1 & 2:\nTo find the % of impact of IVs on Y. Eg: When X1 increases by 1 unit,\nY increases by 21%\n\nIf your Y is a percentage and you use something like OLS regression, then that is exactly how you would interpret the coefficients (for a 1 unit change in X1, Y changes by some percent)","Q_Score":0,"Tags":"python,statistics,regression,percentage,feature-extraction","A_Id":56950836,"CreationDate":"2019-07-08T10:31:00.000","Title":"Which algorithm to use for percentage features in my DV and IV, in regression?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use a custom user model(AbstractBaseUser). How to allow inactive user to login?.  Model fields are email , active, admin,.....\nBy default active= false. For email confirmation activation. But I want to allow user to login both with active= true or false.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1113,"Q_Id":56933463,"Users Score":2,"Answer":"I suggest you to keep the is active functionality and set the default value to True and create migration which will update value for currently inactive users. By following such approach you still have is active functionality, which may serve you in the moment when you will have to deactivate user.\nTo keep tracking on email confirmation just introduce new field is_email_confirmed and update the view which handles click on email to set that field to true.","Q_Score":2,"Tags":"python,django,web,django-rest-framework,web-site-project","A_Id":56933610,"CreationDate":"2019-07-08T10:59:00.000","Title":"How to allow inactive user to login?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I understand that the LaunchInstanceDetails method in oci.core.model has a parameter -> metadata , wherein one of the metadata key-names that can be used to provide information to Cloud-Init is -> \u201cuser_data\u201d , which can be used to run custom scripts by Could-Init when provided in a base64-encoded format.\nIn my Python code to create a Windows VM,while launching the instance, I have a requirement to run 2 custom scripts:\n\nScript to login to Windows machine via RDP \u2013 this is absolute(needs to be executed every time a new Windows VM is created without fail) \u2013 Currently , we have included this in the metadata parameter while launching the instance, as below:\ninstance_metadata['user_data'] = oci.util.file_content_as_launch_instance_user_data(path_init)\nBootstrap script to Install Chef during the initialization tasks  - this is conditional ( this needs to run only if the user wishes to Install Chef and we internally handle it by means of a flag in the code) \u2013 Yet to be implemented as we need to identify if more than one custom script (conditional in this case) can be included.\n\nCan someone help me understand if and how we can achieve to include multiple scripts(keeping in mind the conditional clause) in a single metadata variable or can we have multiple metadata or some other parameter in this service that could be utilised to run the Chef Installation script","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":56933571,"Users Score":0,"Answer":"I'd suggest combining these into a single script and using the conditional in a if statement to install Chef as required.","Q_Score":1,"Tags":"windows,python-2.7,chef-infra,oracle-cloud-infrastructure","A_Id":56974975,"CreationDate":"2019-07-08T11:05:00.000","Title":"use of multiple custom scripts in metadata parameter of the LaunchInstanceDetails method in oci.core.model","Data Science and Machine Learning":0,"Database and SQL":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 join two bigquery tables in such a way that the data is read from table using query and inner join should be performed by beam coGroupBY key. How can I pass the primary key to join both tables?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":287,"Q_Id":56934861,"Users Score":1,"Answer":"Read data from two different bigquery tables in two different pcollection.\nThen create tuples with your join key using lamda or map function from beam.\nOnce you have these two tuples for tables , go ahead and use coGroupBY key to join these two pcollections.","Q_Score":0,"Tags":"python-2.7,google-cloud-platform,google-bigquery","A_Id":56951506,"CreationDate":"2019-07-08T12:22:00.000","Title":"How to join two bigquery tables using python and beam coGroupby concept without directly passing the join condition in the query?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to just import parts of tkinter, like you can import parts of Java swing without having to import the entire library when you only need to use 4 or 5 modules. I am writing small python program with pop-up input\/output window a few textboxes and buttons and only want to use grid layout manager.\nI have looked through all the python and tkinter documentation and searched tutorial websites and youtube unable to find an example.\nGeneral python\/tkinter language query.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":47,"Q_Id":56937837,"Users Score":1,"Answer":"You have to have all of tkinter in memory even if you don't use it all. You can import individual pieces like you can with any other python module, but that won't make your program any smaller or more efficient. Under the hood python will import the entire module, even if it only makes part of the module visible to your code.\nArguably, the only real effect would be in making your code a bit harder to understand by deviating from best practices.","Q_Score":0,"Tags":"python,tkinter","A_Id":56941119,"CreationDate":"2019-07-08T15:09:00.000","Title":"Importing tkinter modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"On my jupyter notebook, running import sknw throws a ModuleNotFoundError error. \nI have tried pip install sknw and pip3 install sknw and python -m pip install sknw. It appears to have downloaded successfully, and get requirement already satisfied if I try to download it again.\nAny help on how to get the sknw package to work in jupyter notebook would be very helpful!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":56937918,"Users Score":0,"Answer":"check on which environment you using pip.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":56938165,"CreationDate":"2019-07-08T15:13:00.000","Title":"Importing sknw on jupyter ModuleNotFoundError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I am developing a web scraper and I am using in a particular website, this website has a lot of URLs, maybe more than 1.000.000, and for scraping and getting the information I have the following architecture.\nOne set to store the visited sites and another set to store the non-visited sites.\nFor scraping the website I am using multithreading with a limit of 2000 threads.\nThis architecture has a problem with a memory size and can never finish because the program exceeds the memory with the URLs\nBefore putting a URL in the set of non-visited, I check first if this site is in visited, if the site was visited then I will never store in the non-visited sites.\nFor doing this I am using python, I think that maybe a better approach would be storing all sites in a database, but I fear that this can be slow\nI can fix part of the problem by storing the set of visited URLs in a database like SQLite, but the problem is that the set of the non-visited URL is too big and exceeds all memory\nAny idea about how to improve this, with another tool, language, architecture, etc...?\nThanks","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":108,"Q_Id":56938689,"Users Score":1,"Answer":"At first, i never crawled pages using Python. My preferd language is c#. But python should be good, or better.\nOk, the first thing your detected is quiet important. Just operating on your memory will NOT work. Implementing a way to work on your harddrive is important. If you just want to work on memory, think about the size of the page.\nIn my opinion, you already got the best(or a good) architecture for webscraping\/crawling. You need some kind of list, which represents the urls you already visited and another list in which you could store the new urls your found. Just two lists is the simplest way you could go. Cause that means, you are not implementing some kind of strategy in crawling. If you are not looking for something like that, ok. But think about it, because that could optimize the usage of memory. Therefor you should look for something like deep and wide crawl. Or recursive crawl. Representing each branch as a own list, or a dimension of an array.\nFurther, what is the problem with storing your not visited urls in a database too? Cause you only need on each thread. If your problem with putting it in db is the fact, that it could need some time swiping through it, then you should think about using multiple tables for each part of the page.\nThat means, you could use one table for each substring in url:\nwwww.example.com\/\nwwww.example.com\/contact\/\nwwww.example.com\/download\/\nwwww.example.com\/content\/\nwwww.example.com\/support\/\nwwww.example.com\/news\/\nSo if your url is:\"wwww.example.com\/download\/sweetcats\/\", then you should put it in the table for wwww.example.com\/download\/.\nWhen you have a set of urls, then you have to look at first for the correct table. Afterwards you can swipe through the table.\nAnd at the end, i have just one question. Why are you not using a library or a framework which already supports these features? I think there should be something available for python.","Q_Score":0,"Tags":"python,performance,web-scraping,architecture","A_Id":56953619,"CreationDate":"2019-07-08T16:03:00.000","Title":"What is the best approach to scrape a big website?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Hello I am developing a web scraper and I am using in a particular website, this website has a lot of URLs, maybe more than 1.000.000, and for scraping and getting the information I have the following architecture.\nOne set to store the visited sites and another set to store the non-visited sites.\nFor scraping the website I am using multithreading with a limit of 2000 threads.\nThis architecture has a problem with a memory size and can never finish because the program exceeds the memory with the URLs\nBefore putting a URL in the set of non-visited, I check first if this site is in visited, if the site was visited then I will never store in the non-visited sites.\nFor doing this I am using python, I think that maybe a better approach would be storing all sites in a database, but I fear that this can be slow\nI can fix part of the problem by storing the set of visited URLs in a database like SQLite, but the problem is that the set of the non-visited URL is too big and exceeds all memory\nAny idea about how to improve this, with another tool, language, architecture, etc...?\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":108,"Q_Id":56938689,"Users Score":1,"Answer":"2000 threads is too many.  Even 1 may be too many.  Your scraper will probably be thought of as a DOS (Denial Of Service) attach and your IP address will be blocked.\nEven if you are allowed in, 2000 is too many threads.  You will bottleneck somewhere, and that chokepoint will probably lead to going slower than you could if you had some sane threading.  Suggest trying 10.  One way to look at it -- Each thread will flip-flop between fetching a URL (network intensive) and processing it (cpu intensive).  So, 2 times the number of CPUs is another likely limit.\nYou need a database under the covers.  This will let you top and restart the process.  More importantly, it will let you fix bugs and release a new crawler without necessarily throwing away all the scraped info.\nThe database will not be the slow part.  The main steps:\n\nPick a page to go for (and lock it in the database to avoid redundancy).\nFetch the page (this is perhaps the slowest part)\nParse the page (or this could be the slowest)\nStore the results in the database\nRepeat until no further pages -- which may be never, since the pages will be changing out from under you.\n\n(I did this many years ago.  I had a tiny 0.5GB machine.  I quit after about a million analyzed pages.  There were still about a million pages waiting to be scanned.  And, yes, I was accused of a DOS attack.)","Q_Score":0,"Tags":"python,performance,web-scraping,architecture","A_Id":57539538,"CreationDate":"2019-07-08T16:03:00.000","Title":"What is the best approach to scrape a big website?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am running Windows 10. I have recently changed location to my python folder and interpreter. \nUnfortunately, when i now run python scripts in command prompt, I always have to type \"python\" before the name of the script I want to run.\nRunning the script directly - for example: C:\\Python 37\\mypythonscript.py -generates absolutely no reaction from the command prompt. I simply get back directly to C:\\Python37> \nIf I however run C:\\Python 37\\python mypythonscript.py, the script is properly executed. \nI have changed all the file associations using \"ftype\" and \"assoc\" in the command prompt. When I start command prompt and type \"python\", the python compiler correctly starts. \nMy problem is that I always have to type \"python\" before the name of my script for the command prompt to recognize that it needs to execute python. \nI would like to open command, change directory to the directory with my python scripts, and simply run the python scripts by running the name of the scripts (mypythonscript.py) without having to type \"python\" in front of it.\nCould you please help me identify what is wrong? How can I once again run python scripts in the command prompt without having to type \"python\" in front of the script's name?\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2618,"Q_Id":56939420,"Users Score":1,"Answer":"If you use a python 3 Virtualenv in powershell the above problem can be very confusing. Typically \"py .\\yourscript.py\" or \"py .\\yourscript\" will work but \".\\yourscript.py\" or \".\\yourscript\" will fail and might return a \"ModuleNotFoundError: No module named '<module>' \" error.\nThis happens because your .py association is not correct as described by Eryk Sun in the above second remark. The \"py launcher\" he names is, in most cases, \"C:\\Windows\\py.exe\". I my case it was already installed and I just needed to adjust the .py extension as described by him. It can also be done via the \"Choose default apps by file type\" settings.\nA useful help is to define \"$env:PYLAUNCH_DEBUG=1\" in your powershell. After that \"py .\\yourscript.py\" will have extra output showing where your python executable is found.\nIf there is no extra output it means, as before, that you don't have \".py\" associated with \"py.exe\". If you start a \"cmd\" and \"ftype python.file\" looks ok, you need to read Eryk Sun's first remark :-)","Q_Score":1,"Tags":"python,windows,associations","A_Id":60347308,"CreationDate":"2019-07-08T16:50:00.000","Title":"Python file association not working in Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to remotely stream videos and images from the cameras of the Pepper and NAO robots to my laptop. \nFirst, I used a while loop to repeatedly capture images from the NAO's camera and processed the images through opencv. However, as you can imagine, this only provided me with a framerate of about 1 fps. \nThen I tried to access the camera through opencv's videocapture, but it is not working properly. \nNext, I attempted to use gstreamer 1.0 for python on Windows, but the Windows version seems to be missing a number of elements, even though I have all of the required plugins (base, good, bad, ugly). \nAlso, I am trying to avoid using ROS because I am having issues using it with the python 2.7 naoqi SDK of the Pepper and NAO robots. \nAny help would be greatly appreciated. Thanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1257,"Q_Id":56940339,"Users Score":2,"Answer":"gstreamer should already be installed on the robot, so you could run it on the robot with a command like this:\n\ngst-launch-0.10 -v v4l2src device=\/dev\/video-top ! video\/x-raw-yuv,width=640,height=480,framerate=30\/1 ! ffmpegcolorspace ! jpegenc ! multipartmux! tcpserversink port=3000 \n\n... and then you can open the stream from your computer, for example with vlc:\n\nvlc tcp:\/\/ip.of.the.robot:3000","Q_Score":2,"Tags":"python,opencv,gstreamer,nao-robot,pepper","A_Id":56952479,"CreationDate":"2019-07-08T18:02:00.000","Title":"Remote video streaming with Pepper and NAO robots","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to scrape a web page, but the problem is when i click on the link on website, it works fine, but when i go through the link manually by typing url in browser, it gives Access Denied error, so may be they are validating referrer on their end, Can you please tell me how can i sort this issue out using selenium in python ? \nor any idea that can solve this issue? i am unable to scrape the page because its giving Access Denied error.\nPS. i am working with python3\nWaiting for help.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":322,"Q_Id":56940886,"Users Score":0,"Answer":"I solved myself by using seleniumwire ;) selenium doesn't support headers, but seleniumwire supports, so that solved my issue.\nThanks","Q_Score":0,"Tags":"python","A_Id":56940887,"CreationDate":"2019-07-08T17:12:00.000","Title":"How to set Referrer in driver selenium python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently have a docker-compose.yml file that builds two Dockerfiles. One docker file pulls Python and the other pulls Ubuntu . At the end, I have two containers named dataload_py and dataload_ubuntu. I mounted a file onto dataload_ubuntu that can only be ran on that container.\nWhen I bash into the Python container using docker exec -it dataload_py bash, how can I execute the mounted file on the Ubuntu container? They are bridged through the same network.\nMy end goal is to be able to spin up a Docker container with both Python and Ubuntu .","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":396,"Q_Id":56941164,"Users Score":0,"Answer":"Maybe you can have one container instead of two. Your Dockerfile will pull from Ubuntu 18 and then in the Dockerfile, you can install python 3.7.3, this way you will only have one cointainer with both ubuntu and python and you can execute your script there","Q_Score":0,"Tags":"python,docker,docker-compose,dockerfile,ubuntu-18.04","A_Id":56941477,"CreationDate":"2019-07-08T19:07:00.000","Title":"Is it possible to build a docker container with two hub images (Python 3.7.3 and Ubuntu 18.0.4)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I know it is possible to fetch then use checkout with the path\/to\/file to download that specific file.\nMy issue is that I have a 1 MB data cap per day and git fetch will download all the data anyway even if it does not save them to disc until I use git checkout. I still used my data\nIs my understanding of how git fetch\/checkout correct? is there a way to download a specific file only to see if there is a new version before proceeding with the download.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28491,"Q_Id":56943327,"Users Score":0,"Answer":"This works for me on a local gitlab:\ncurl http:\/\/mylocalgitlab\/MYGROUP\/-\/raw\/master\/PATH\/TO\/FILE.EXT -o FILE.EXT","Q_Score":14,"Tags":"python,linux,git","A_Id":70557243,"CreationDate":"2019-07-08T22:39:00.000","Title":"How to download a single file from 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":"I was trying to using python requests and mechanize to gather information from a website. This process needs me to post some information then get the results from that website. I automate this process using for loop in Python. However, after ~500 queries, I was told that I am blocked due to high query rate. It takes about 1 sec to do each query. I was using some software online where they query multiple data without problems. Could anyone help me how to avoid this issue? Thanks!\nNo idea how to solve this.\n--- I am looping this process (by auto changing case number) and export data to csv....\nAfter some queries, I was told that my IP was blocked.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":56943620,"Users Score":0,"Answer":"Optimum randomized delay time between requests. \nRandomized real user-agents for\neach request.\nEnabling cookies.\nUsing a working proxy pool and\nselecting a random proxy for each request.","Q_Score":0,"Tags":"python,web-scraping,python-requests,export-to-csv","A_Id":56954734,"CreationDate":"2019-07-08T23:22:00.000","Title":"While query data (web scraping) from a website with Python, how to avoid being blocked by the server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So imagine an program, it has a UI and key bindings to do a specific task. I did not make it and the only way I interact with it is via keyboard and mouse. I want to automate the job without giving up my time as currently the window has to be open and the mouse\/keyboard is doing things and I cannot use my PC. It would be best if it was in Python or be able to interact with my Python script in some way e.g. reading inputs from file or something.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":204,"Q_Id":56944185,"Users Score":0,"Answer":"Unless you know of some APIs exposed by the tool, i am not sure if you can get any non-blocking action done on this. In professional Robotic Process Automation platforms, they have an option to run this in the background by pushing the work to another server. You can probably try running this in a Virtual Machine or on another machine so that your window doesn't get blocked by the automation and you don't have to lose time.","Q_Score":0,"Tags":"python","A_Id":56944216,"CreationDate":"2019-07-09T01:11:00.000","Title":"How to control an application running in the background?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently upgraded a machine from Ubuntu Server 16.04 LTS to 18.04 LTS using command line. As a result, the built-in Python installation is upgraded from Python 3.5 to 3.6. And it seems that all the Python packages previously installed using pip3 are no longer accessible. I plan to clean up all those packages and use conda for Python package management. My question is, what is the best practice for a clean uninstallation of those inaccessible packages in this case?\nThe old packages installed via pip3 were primarily located under \/usr\/local\/lib\/python3.5\/ and ~\/.local\/lib\/python3.5\/. But there could be other leftover files, e.g., under \/usr\/local\/bin\/. I would like to remove all of related files that came with pip3 install.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":327,"Q_Id":56944863,"Users Score":1,"Answer":"sudo pip install installs pip packages to\/usr\/local\/lib\/<python_version>\/dist-packages, and apt packages to \/usr\/lib\/<python_version>\/dist-packages. Check these directories and remove the unwanted packages.","Q_Score":1,"Tags":"python,ubuntu","A_Id":56954353,"CreationDate":"2019-07-09T03:19:00.000","Title":"Clean Uninstallation of Python Packages after Ubuntu Upgrade","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to build REST API which will communicate with MYSQL DB The application will have some heavy processing after I fetch data from DB and return. Node.js being single threaded might have some issues i fell.\nI want to know if I should go with node.js or python is there any other technology I should be using ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":294,"Q_Id":56945173,"Users Score":1,"Answer":"With my exp, python work with MySQL better than NodeJS in multi thread. But i think you should try some other solution if it's really heavy process, like using Spark for data processing.","Q_Score":0,"Tags":"python,node.js,rest,api,backend","A_Id":56945205,"CreationDate":"2019-07-09T04:03:00.000","Title":"Node.js, python for API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Backstory: I was running an Airflow job on a daily schedule, with a start_date of July 1, 2019. The job gathered requested each day's data from a third party, then loaded that data into our database.\nAfter running the job successfully for several days, I realized that the third party data source only refreshed their data once a month. As such, I was simply downloading the same data every day. \nAt that point, I changed the start_date to a year ago (to get previous months' info), and changed the DAG's schedule to run once a month.\nHow do I (in the airflow UI) restart the DAG completely, such that it recognizes my new start_date and schedule, and runs a complete backfill as if the DAG is brand new?\n(I know this backfill can be requested via the command line. However, I don't have permissions for the command line interface and the admin is unreachable.)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3905,"Q_Id":56945611,"Users Score":7,"Answer":"Click on the green circle in the Dag Runs column for the job in question in the web interface. This will bring you to a list of all successful runs.\nTick the check mark on the top left in the header of the list to select all\ninstances, then in the menu above it choose \"With selected\" and then \"Delete\" in the drop down menu. This should clear all existing dag run instances.\nIf catchup_by_default is not enabled on your Airflow instance, make sure catchup=True is set on the DAG until it has finished catching up.","Q_Score":8,"Tags":"python,kubernetes,airflow,airflow-scheduler","A_Id":56953498,"CreationDate":"2019-07-09T04:59:00.000","Title":"Airflow: Re-run DAG from beginning with new schedule","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to run some tasks in the background while running a django server. To do this, I'm using background-tasks library. I've followed the following steps:\n\npip install django-background-tasks\nAdded 'background_task', in INSTALLED_APPS in settings.py \npython manage.py makemigrations background_task\n\nThe problem arises in the 3rd step giving an error stating:\n\ndjango.db.utils.ProgrammingError: relation \"background_task\" does not\n  exist LINE 1: INSERT INTO \"background_task\" (\"task_name\",\n  \"task_params\", \"...\n\nI've tried looking for other solutions but every one of them was the 3rd line. \nHow should I proceed ?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":864,"Q_Id":56949235,"Users Score":1,"Answer":"I don't know if this is still valid question but what helped me was to revert all changes in code related to background_task module and then applying migrations. After that reapply your changes in code and it should all work.","Q_Score":1,"Tags":"python,django","A_Id":61407058,"CreationDate":"2019-07-09T09:17:00.000","Title":"relation \"background_task\" does not exist","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to run some tasks in the background while running a django server. To do this, I'm using background-tasks library. I've followed the following steps:\n\npip install django-background-tasks\nAdded 'background_task', in INSTALLED_APPS in settings.py \npython manage.py makemigrations background_task\n\nThe problem arises in the 3rd step giving an error stating:\n\ndjango.db.utils.ProgrammingError: relation \"background_task\" does not\n  exist LINE 1: INSERT INTO \"background_task\" (\"task_name\",\n  \"task_params\", \"...\n\nI've tried looking for other solutions but every one of them was the 3rd line. \nHow should I proceed ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":864,"Q_Id":56949235,"Users Score":0,"Answer":"After the 2nd step go to command line and do following :\n1. python manage.py showmigrations (check if it works fine)\n2. python manage.py migrate (check if the background task file is added to the show migrations list eg:\nbackground_task\n [X] 0001_initial\n [X] 0002_auto_20170927_1109)\n3. Now make modifications in your views in which ever way you want to use the backgroundtasks.","Q_Score":1,"Tags":"python,django","A_Id":57952100,"CreationDate":"2019-07-09T09:17:00.000","Title":"relation \"background_task\" does not exist","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am calling a c#-dll from python. The DLL is my GUI.\nThe GUI contains a dataGrid with 2 columns for 2 strings. \nIf I call the GUI by Python with clr.AddReference(\"myGUI.dll\")\nI can comfortably run the GUI and debug my python script and manually access the c# stuff and add rows to the grid in the script or manually. \nBut if the rows in the grid are full, and a scroll-bar appears, this is the moment, the GUI hangs. It's sometimes possible to add some rows and change something at the GUI items, but if I click on any object, nothing happens, and windows reports after some time: \"app is not responding\".\nDoes anybody know this issue? What can I do?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":56958565,"Users Score":0,"Answer":"After trying a lot of stuff, the following works for me:\nIn Form1_Load I fill the dataGrid with a lot of rows, so that the scrollbar appears. Then I can reduce or fill them via Python - no problem any more, scrollbar disapears for less rows and appears again, if needed. No blocking GUI anymore.\nTo let the scrollbar appeare once seems to call initially anything in the form. Which works automatically since it is called once.","Q_Score":0,"Tags":"c#,python,datagrid","A_Id":57577406,"CreationDate":"2019-07-09T18:22:00.000","Title":"C# GUI for python hangs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is going to be more of an abstract question, since there's no code I can provide related to this question. I'm a bit new to working with databases, so I'm not familiar with conventional designs (yet).\nI have these tables: users and servers. \nI currently have a method of keeping score for each user by incrementing the score field in the users table. However, this results in global scores, which is fine, but I would like to be able to track server-specific scores as well.\nWhat would be the best approach for keeping a user's score for each server they use?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":56960555,"Users Score":0,"Answer":"To track server specific scores you can just add a table with servers ids by using guild.id.","Q_Score":0,"Tags":"python-3.x,sqlite,discord.py","A_Id":57065038,"CreationDate":"2019-07-09T21:10:00.000","Title":"How to store values for each user for each server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm purposefully modifying every locally synced files (although directory name is unique and unmodified), which makes the sync method try to redownload the whole bucket, taking an excess of time.\nCopying the local files (to preserve their timestamp + size) isn't really an option since the bucket size is so big, and AWS sync docs don't seem to have an option to exclude modified files.\nI was hoping there's a way to prevent attempting to redownload a directory if it exists locally.\nAny ideas?\nThanks a lot","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":416,"Q_Id":56960781,"Users Score":0,"Answer":"Would aws s3 sync --size-only work for you?\n\n--size-only (boolean) Makes the size of each key the only criteria used to decide whether to sync from source to destination.\n\n(Emphasis mine.)","Q_Score":2,"Tags":"python,amazon-web-services,amazon-s3","A_Id":56960874,"CreationDate":"2019-07-09T21:33:00.000","Title":"AWS S3 sync method- possible to ignore modified files completely?","Data Science and Machine Learning":0,"Database and SQL":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 feel like this subject is touched in some other questions but it doesn't get into Python (3.7) specifically, which is the language I'm most familiar with.\nI'm starting to get the hang of abstract classes and how to use them as blueprints for subclasses I'm creating.\nWhat I don't understand though, is the purpose of concrete methods in abstract classes.\nIf I'm never going to instantiate my parent abstract class, why would a concrete method be needed at all, shouldn't I just stick with abstract methods to guide the creation of my subclasses and explicit the expected behavior?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":526,"Q_Id":56960959,"Users Score":1,"Answer":"This question is not Python specific, but general object oriented.\nThere may be cases in which all your sub-classes need a certain method with a common behavior. It would be tedious to implement the same method in all your sub-classes. If you instead implement the method in the parent class, all your sub-classes inherit this method automatically. Even callers may call the method on your sub-class, although it is implemented in the parent class. This is one of the basic mechanics of class inheritance.","Q_Score":1,"Tags":"python-3.x,oop,abstract-class","A_Id":56961464,"CreationDate":"2019-07-09T21:53:00.000","Title":"What is the purpose of concrete methods in abstract 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":"In terms of performance (memory, running time, etc), what is the difference between a normal run of a Python script vs choosing \"continue\" after the last breakpoint? Of course, there would be some difference before the last breakpoint, but I am interested in cases when the code before the last breakpoint is not intensive (does not require too much memory\/running time).\nUsually, if I find my code good after checking the last breakpoint, if the code afterward is not intensive, I just continue. Otherwise (such as using Keras for machine learning), I rerun from the start not using the debugger.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":56962008,"Users Score":0,"Answer":"The answer is \"it depends\". Generally, if you have a debugger enabled execution time is slower, however, if the code you are running is largely C (I'd assume Keras is) then the impact of your debugger will be reduced.\nIf your process is time-critical or is a long-running task running without the debugger enabled will be faster. Using python -O can improve things further stripping out asserts etc","Q_Score":0,"Tags":"python,debugging,pdb","A_Id":56962071,"CreationDate":"2019-07-10T00:33:00.000","Title":"Performance Comparison - Continue After Last Breakpoint vs Normal Run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i want to be able to use the pdb as a subprocess, input the debug operator, and get its output. and I found the fcntl may help, but to my surprise, it work for other program like gdb, but when the cmd is \"python\", or [\"python\", \"-m\", \"pdb\", \"computer.py\"], this will not work. \nI replace the cmd to 'gdb' or other program, it all works with fcntl.\nbut only failed when the cmd is 'python' related. \nPopen(['python', '-m', 'pdb', 'computer.py'], stdin=PIPE, stdout=PIPE, shell = False)\nflags = fcntl(p.stdout.fileno(), F_GETFL)\nfcntl(p.stdout.fileno(), F_SETFL, flags | O_NONBLOCK)\nthe expected result is i can get stdout correctly.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":56965212,"Users Score":0,"Answer":"plus \"-u\" argument. \n-u     : unbuffered binary stdout and stderr; also PYTHONUNBUFFERED=x\n         see man page for details on internal buffering relating to '-u'","Q_Score":0,"Tags":"python,subprocess,nonblocking","A_Id":56965539,"CreationDate":"2019-07-10T07:09:00.000","Title":"non block read failed on stdout for python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am running Anaconda on MacOS and I have multiple virtual environments for different versions of Python, TensorFlow, Pytorch, etc...\nRecently I have tried to install Auto-Keras and to build Tensorflow from the source (each in a separate virtual env), and in both cases it asked me to update a bunch of C++ stuff (SWIG, gcc,..), a new java version, among other things, and occasionally it is asking me for my root password halfway through the process. \nWith Python style pip install <lib> I always assumed it was safe to do whatever I wanted in a given virtual env, since the whole point what that it containerized the dependencies and packages, and installs in other virtual env won't be broken. \nBut in this case, I am worried, since: \na) They are not installed using pip or conda \nb) It keeps asking me to type in my admin password and changing global configurations like the Java vision etc....\nAre other packages besides python packages \"containerized\" in the same way that Python packages are in a virtual env? \nIf not, do I risk breaking stuff by upgrading C++, SWIG, Java, etc...?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":56967419,"Users Score":0,"Answer":"First, virtual env gives you no protection:) It just modifies PATH environment variable. You are not in a safe sandbox even with Python packages. pip install xxx will execute setup.py which could also introduce malware.\nSecond, yes, they are asking you for sudo permission, and definitely, it is dangerous. But you still can trust who is worth to trust. After all, you still use a third-party OS instead of creating it on your own right?","Q_Score":0,"Tags":"python,tensorflow,dependencies,anaconda,virtualenv","A_Id":56967720,"CreationDate":"2019-07-10T09:18:00.000","Title":"Is it safe to install non python packages (java updates, c++ updates) in an Anaconda virtual environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Recently, I want to deploy a Deeplearning model (Tensorflow) on mobile (Android\/iOS) and I found that Kivy Python is a good choice to write cross-platform apps. (I am not familiar with Java Android)  \nBut I don't know how to integrate Tensorflow libs when building .apk file. \nThe guide for writing \"buildozer recipe\" is quite complicate for this case.\nIs there any solution for this problem without using native Java Android and Tensorflow Lite?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1955,"Q_Id":56967553,"Users Score":0,"Answer":"Fortunately found someone facing the same issues as I am but unfortunately I found that Kivy couldn't compile Tensorflow library yet. In other words, not supported, yet. I don't know when will they update the features.","Q_Score":7,"Tags":"android,python,tensorflow,kivy","A_Id":66493760,"CreationDate":"2019-07-10T09:24:00.000","Title":"Building Kivy Android app with Tensorflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an array with size (4,4) that can have values 0 and 1, so I can have 65536 different arrays. I need to produce all these arrays without repeating. I use wt_random=np.random.randint(2, size=(65536,4,4)) but I am worried they are not unique. could you please tell me this code is correct or not and what should I do to produce all possible arrays? Thank you.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":452,"Q_Id":56969477,"Users Score":0,"Answer":"If you need all possible arrays in random order, consider enumerating them in any arbitrary deterministic order and then shuffling them to randomize the order. If you don't want all arrays in memory, you could write a function to generate the array at a given position in the deterministic list, then shuffle the positions. Note that Fisher-Yates may not even need a dense representation of the list to shuffle... if you keep track of where the already shuffled entries end up you should have enough.","Q_Score":2,"Tags":"python,arrays,numpy,random","A_Id":56969631,"CreationDate":"2019-07-10T11:12:00.000","Title":"how do I produce unique random numbers as an array in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want be add a video field in the django.I am not able to add it.\nHow can I add a videofield in django in the admin portion like that of ImageFeild?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7651,"Q_Id":56969479,"Users Score":0,"Answer":"You have to use the FileField in the same way you use the ImageField","Q_Score":1,"Tags":"python,django,video","A_Id":64042041,"CreationDate":"2019-07-10T11:12:00.000","Title":"Adding Video Field in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a file contain some columns which the second column is time. Like what I show below. I need to add a column of time which all are in seconds like this: \"2.13266      2.21784      2.20719      2.02499      2.16543\", to the time column in the first file (below). My question is how to add these two time to each other. And maybe in some cases when I add these times, then it goes to next day, and in this case how to change the date in related row.\n2014-08-26 19:49:32  0\n2014-08-28 05:43:21  0\n2014-08-30 11:47:54  0\n2014-08-30 03:26:10  0","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":673,"Q_Id":56970023,"Users Score":0,"Answer":"Probably the easiest way is to read your file into a pandas data-frame and parse each row as a datetime object. Then you create a datetime.timedelta object passing the fractional seconds.\nA datetime object + a timedelta handles wrapping around for days quite nicely so this should work without any additional code. Finally, write back your updated dataframe to a file.","Q_Score":0,"Tags":"python,datetime,time,add,timedelta","A_Id":56970162,"CreationDate":"2019-07-10T11:43:00.000","Title":"How to add a column of seconds to a column of times in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a file contain some columns which the second column is time. Like what I show below. I need to add a column of time which all are in seconds like this: \"2.13266      2.21784      2.20719      2.02499      2.16543\", to the time column in the first file (below). My question is how to add these two time to each other. And maybe in some cases when I add these times, then it goes to next day, and in this case how to change the date in related row.\n2014-08-26 19:49:32  0\n2014-08-28 05:43:21  0\n2014-08-30 11:47:54  0\n2014-08-30 03:26:10  0","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":673,"Q_Id":56970023,"Users Score":0,"Answer":"Ok. Finally it is done via this code:\n    d= 2.13266\ndd= pd.to_timedelta (int(d), unit='s')\ndf= pd.Timestamp('2014-08-26 19:49:32')\nnew = df + dd","Q_Score":0,"Tags":"python,datetime,time,add,timedelta","A_Id":56973402,"CreationDate":"2019-07-10T11:43:00.000","Title":"How to add a column of seconds to a column of times in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I want to add a button in my text area in Spotfire which will open an excel file (that is connected to my spotfire visualisation) or at least to a network folder with that file. \nI believe I can write an ironpython script just to open that file and make changes. How will I do that? \nUpdate: \nAfter some googling I have tried to run a simple script smth like: \nt=open('D:\/data\/folderA\/folderB\/file.xlsx','w')\nTo avoid problems with \"\/\" or \"\\\", I also tried importing os\nimport os\nt=open('D:','data', 'folderA', 'folderB', 'file.xlsx', 'w')\nNeither of these work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":827,"Q_Id":56970160,"Users Score":0,"Answer":"For those who is still struggling to find the solution, it turned out to be simpler than I thought it would. \nfrom System.Diagnostics import Process\nProcess.Start(r 'start c:\\test\\abc.xlsx')","Q_Score":0,"Tags":"python,ironpython,spotfire","A_Id":58213112,"CreationDate":"2019-07-10T11:51:00.000","Title":"Python script to open a file in Spotfire","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to come up with the best way to minimize the loss of time in a data harvesting application I am building. Here are some of the restraints\/factors:\n\nI can only query for data every 12 seconds on a specific channel\nI can connect to as many channels simultaneously.\nI want to keep the number of channels in use to a minimum\n\nWith these factors in mind, I have thought of a solution, but would like for more input. \nI have decided to in a way load balance this collection of data. My thoughts are this:\n\nMain Program utilizes m processes (for now I am thinking 4).\nEach process uses n threads, where each thread is listening on a channel.(for now I am thinking 12). \nThere is a variable thread_start_time_factor = 12 seconds \/ n threads\nThere is a variable process_start_time_factor = thread_start_time_factor \/ m processes\nEach thread query's data every 12 seconds, however threads start consecutively after one another based on the thread_start_time_factor. So if I am using 12 threads, thread 1 starts, (1 second pause), thread 2 starts, ... This way data collection is now happening every 1 second.\nEach process then starts one after the other based on the\nprocess_start_time_factor\n\nIn theory, data collection SHOULD be happening every process_start_time_factor If going with the configuration above, the process_start_time_factor should be .250 seconds. (If my logic is wrong here, please let me know). \nNow here is my question. Is this a good way to do this? My thoughts for using multiple processes is to essentially capture data whenever the other processes are not. The program will be written in Python (Not that it matters). Has anyone had experience with (weird) data collection restrictions like this where they have to think outside the box? Thanks to all of those who reply in advance. I am for sure open to other solutions.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":56971684,"Users Score":0,"Answer":"given that you're using proxies, not linked to the site, and are being somewhat obscure about the question, suggests it's bordering on illegal\nthat said, some numbers you've not given are how long each request takes (e.g. TTFB, total duration, total data transferred) and what it takes to process the responses.\nassuming you're not doing much processing on ingress, then I'd just go with an asyncio (i.e. no process\/thread parallelism) approach as it's much easier to get the coordination straight.  multithreading\/process coordination is much awkward to reason about\nyou should be able to saturate a 1GB connection with HTTP requests from a single thread, maybe just using multiple processes to do post-processing so that doesn't get in the way","Q_Score":0,"Tags":"python,multithreading,web-scraping,parallel-processing,process","A_Id":56972499,"CreationDate":"2019-07-10T13:21:00.000","Title":"Need help minimizing the loss of time for data collection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a matrix called POS which has form (10,132) and I need to average those first 10 elements in such a way that my averaged matrix has the form of (1,132)\nI have tried doing \nmeans = pos.mean (axis = 1)\nor\nmenas = np.mean(pos)\nbut the result in the first case is a matrix of (10,) and in the second it is a simple number\ni expect the ouput a matrix of shape (1,132)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":56974114,"Users Score":0,"Answer":"The solution is to specify the correct axis and use keepdims=True which is noted by several commenters (If you add your answer I will delete mine).\nThis can be done with either pos.mean(axis = 0,keepdims=True) or np.mean(pos,axis=0,keepdims=True)","Q_Score":0,"Tags":"python,numpy","A_Id":56981888,"CreationDate":"2019-07-10T15:34:00.000","Title":"how to average in a specific dimension with numpy.mean?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Seems as though an update on Windows 10 overnight broke Python. Just trying to run python --version returned a \"Permission Denied\" error.  None of the three updates; KB4507453, KB4506991, or KB4509096 look like they'd be the culprit but the timing of the issue is suspicious. Rather than messing with rolling back, I'm hoping there's a simpler fix that I'm missing.\nThe permissions on python are \"-rwxr-xr-x\" and I haven't changed anything besides letting the Windows update reboot machine after installing last night's patches.\nAccording to the System Information, I'm running 10.0.18362\nShould also note that this is happening whether I (try) to execute Python from git-bash using \"run as administrator\" or not, and if I try using PowerShell, it just opens the Windows store as if the app isn't installed so I'm thinking it can't see the contents of my \/c\/Users\/david\/AppData\/Local\/Microsoft\/WindowsApps\/ folder for some reason.\nI've also tried to reinstall Python 3.7.4, but that didn't help either. Is there something else I should be looking at?","AnswerCount":19,"Available Count":7,"Score":-0.0210495219,"is_accepted":false,"ViewCount":274059,"Q_Id":56974927,"Users Score":-2,"Answer":"May be you can try opening command prompt with Administrator privileges. (Run As Administrator). Works for me most of the time.","Q_Score":191,"Tags":"python,python-3.x,windows-store-apps,file-permissions,git-bash","A_Id":57162108,"CreationDate":"2019-07-10T16:23:00.000","Title":"\"Permission Denied\" trying to run Python on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Seems as though an update on Windows 10 overnight broke Python. Just trying to run python --version returned a \"Permission Denied\" error.  None of the three updates; KB4507453, KB4506991, or KB4509096 look like they'd be the culprit but the timing of the issue is suspicious. Rather than messing with rolling back, I'm hoping there's a simpler fix that I'm missing.\nThe permissions on python are \"-rwxr-xr-x\" and I haven't changed anything besides letting the Windows update reboot machine after installing last night's patches.\nAccording to the System Information, I'm running 10.0.18362\nShould also note that this is happening whether I (try) to execute Python from git-bash using \"run as administrator\" or not, and if I try using PowerShell, it just opens the Windows store as if the app isn't installed so I'm thinking it can't see the contents of my \/c\/Users\/david\/AppData\/Local\/Microsoft\/WindowsApps\/ folder for some reason.\nI've also tried to reinstall Python 3.7.4, but that didn't help either. Is there something else I should be looking at?","AnswerCount":19,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":274059,"Q_Id":56974927,"Users Score":0,"Answer":"Add the path of python folder in environmental variable and it will work\n1.search environmental variable\n2.look for system variable section and find variable named path in it\n3.double click on path and add new path which directs towards python folder and that's it.\nthe python folder is usually in\nC:\\Users[\"user name\"]\\AppData\\Local\\Programs\\Python\\Python39","Q_Score":191,"Tags":"python,python-3.x,windows-store-apps,file-permissions,git-bash","A_Id":66059202,"CreationDate":"2019-07-10T16:23:00.000","Title":"\"Permission Denied\" trying to run Python on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Seems as though an update on Windows 10 overnight broke Python. Just trying to run python --version returned a \"Permission Denied\" error.  None of the three updates; KB4507453, KB4506991, or KB4509096 look like they'd be the culprit but the timing of the issue is suspicious. Rather than messing with rolling back, I'm hoping there's a simpler fix that I'm missing.\nThe permissions on python are \"-rwxr-xr-x\" and I haven't changed anything besides letting the Windows update reboot machine after installing last night's patches.\nAccording to the System Information, I'm running 10.0.18362\nShould also note that this is happening whether I (try) to execute Python from git-bash using \"run as administrator\" or not, and if I try using PowerShell, it just opens the Windows store as if the app isn't installed so I'm thinking it can't see the contents of my \/c\/Users\/david\/AppData\/Local\/Microsoft\/WindowsApps\/ folder for some reason.\nI've also tried to reinstall Python 3.7.4, but that didn't help either. Is there something else I should be looking at?","AnswerCount":19,"Available Count":7,"Score":-0.010525927,"is_accepted":false,"ViewCount":274059,"Q_Id":56974927,"Users Score":-1,"Answer":"In Windows 10\n\nOpen Control Panel\nClick System\nClick the Advanced system settings link\nClick Environment Variables button\nIn the System Variables section find the PATH environment variable and select it\nClick Edit (If the PATH environment variable does not exist, click New)\nIn the Edit environment variable window specify the value of the PATH environment variable\nClick OK\nClose all remaining windows by clicking OK\nReopen Command prompt window and run python --version","Q_Score":191,"Tags":"python,python-3.x,windows-store-apps,file-permissions,git-bash","A_Id":67891580,"CreationDate":"2019-07-10T16:23:00.000","Title":"\"Permission Denied\" trying to run Python on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Seems as though an update on Windows 10 overnight broke Python. Just trying to run python --version returned a \"Permission Denied\" error.  None of the three updates; KB4507453, KB4506991, or KB4509096 look like they'd be the culprit but the timing of the issue is suspicious. Rather than messing with rolling back, I'm hoping there's a simpler fix that I'm missing.\nThe permissions on python are \"-rwxr-xr-x\" and I haven't changed anything besides letting the Windows update reboot machine after installing last night's patches.\nAccording to the System Information, I'm running 10.0.18362\nShould also note that this is happening whether I (try) to execute Python from git-bash using \"run as administrator\" or not, and if I try using PowerShell, it just opens the Windows store as if the app isn't installed so I'm thinking it can't see the contents of my \/c\/Users\/david\/AppData\/Local\/Microsoft\/WindowsApps\/ folder for some reason.\nI've also tried to reinstall Python 3.7.4, but that didn't help either. Is there something else I should be looking at?","AnswerCount":19,"Available Count":7,"Score":0.010525927,"is_accepted":false,"ViewCount":274059,"Q_Id":56974927,"Users Score":1,"Answer":"The simplest thing to do would be to modify your PATH and PYTHONPATH environmental variables to make sure that the folder containing the proper python binaries are searched befor the local WindowsApp folder.  You can access the environmental variables by opening up the control panel and searching for \"env\"","Q_Score":191,"Tags":"python,python-3.x,windows-store-apps,file-permissions,git-bash","A_Id":60709937,"CreationDate":"2019-07-10T16:23:00.000","Title":"\"Permission Denied\" trying to run Python on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Seems as though an update on Windows 10 overnight broke Python. Just trying to run python --version returned a \"Permission Denied\" error.  None of the three updates; KB4507453, KB4506991, or KB4509096 look like they'd be the culprit but the timing of the issue is suspicious. Rather than messing with rolling back, I'm hoping there's a simpler fix that I'm missing.\nThe permissions on python are \"-rwxr-xr-x\" and I haven't changed anything besides letting the Windows update reboot machine after installing last night's patches.\nAccording to the System Information, I'm running 10.0.18362\nShould also note that this is happening whether I (try) to execute Python from git-bash using \"run as administrator\" or not, and if I try using PowerShell, it just opens the Windows store as if the app isn't installed so I'm thinking it can't see the contents of my \/c\/Users\/david\/AppData\/Local\/Microsoft\/WindowsApps\/ folder for some reason.\nI've also tried to reinstall Python 3.7.4, but that didn't help either. Is there something else I should be looking at?","AnswerCount":19,"Available Count":7,"Score":0.0525830348,"is_accepted":false,"ViewCount":274059,"Q_Id":56974927,"Users Score":5,"Answer":"For me, I tried manage app execution aliases and got an error that python3 is not a command so for that, I used py instead of python3 and it worked\nI don't know why this is happening but It worked for me","Q_Score":191,"Tags":"python,python-3.x,windows-store-apps,file-permissions,git-bash","A_Id":64964202,"CreationDate":"2019-07-10T16:23:00.000","Title":"\"Permission Denied\" trying to run Python on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Seems as though an update on Windows 10 overnight broke Python. Just trying to run python --version returned a \"Permission Denied\" error.  None of the three updates; KB4507453, KB4506991, or KB4509096 look like they'd be the culprit but the timing of the issue is suspicious. Rather than messing with rolling back, I'm hoping there's a simpler fix that I'm missing.\nThe permissions on python are \"-rwxr-xr-x\" and I haven't changed anything besides letting the Windows update reboot machine after installing last night's patches.\nAccording to the System Information, I'm running 10.0.18362\nShould also note that this is happening whether I (try) to execute Python from git-bash using \"run as administrator\" or not, and if I try using PowerShell, it just opens the Windows store as if the app isn't installed so I'm thinking it can't see the contents of my \/c\/Users\/david\/AppData\/Local\/Microsoft\/WindowsApps\/ folder for some reason.\nI've also tried to reinstall Python 3.7.4, but that didn't help either. Is there something else I should be looking at?","AnswerCount":19,"Available Count":7,"Score":0.010525927,"is_accepted":false,"ViewCount":274059,"Q_Id":56974927,"Users Score":1,"Answer":"make sure C:\\Python39\\ and C:\\Python39\\Scripts\\ are added to both system path variables and user path variables","Q_Score":191,"Tags":"python,python-3.x,windows-store-apps,file-permissions,git-bash","A_Id":68309831,"CreationDate":"2019-07-10T16:23:00.000","Title":"\"Permission Denied\" trying to run Python on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Seems as though an update on Windows 10 overnight broke Python. Just trying to run python --version returned a \"Permission Denied\" error.  None of the three updates; KB4507453, KB4506991, or KB4509096 look like they'd be the culprit but the timing of the issue is suspicious. Rather than messing with rolling back, I'm hoping there's a simpler fix that I'm missing.\nThe permissions on python are \"-rwxr-xr-x\" and I haven't changed anything besides letting the Windows update reboot machine after installing last night's patches.\nAccording to the System Information, I'm running 10.0.18362\nShould also note that this is happening whether I (try) to execute Python from git-bash using \"run as administrator\" or not, and if I try using PowerShell, it just opens the Windows store as if the app isn't installed so I'm thinking it can't see the contents of my \/c\/Users\/david\/AppData\/Local\/Microsoft\/WindowsApps\/ folder for some reason.\nI've also tried to reinstall Python 3.7.4, but that didn't help either. Is there something else I should be looking at?","AnswerCount":19,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":274059,"Q_Id":56974927,"Users Score":16,"Answer":"Simple answer: replace python with PY everything will work as expected","Q_Score":191,"Tags":"python,python-3.x,windows-store-apps,file-permissions,git-bash","A_Id":66205649,"CreationDate":"2019-07-10T16:23:00.000","Title":"\"Permission Denied\" trying to run Python on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently developing a proprietary PDF parser that can read multiple types of documents with various types of data. Before starting, I was thinking about if reading PowerPoint slides was possible. My employer uses presentation guidelines that requires imagery and background designs - is it possible to build a parser that can read the data from these PowerPoint PDFs without the slide decor getting in the way? \nSo the workflow would basically be this:\n\nAt the end of a project, the project report is delivered in the form of a presentation. \nThe presentation would be converted to PDF.\nThe PDF would be submitted to my application.\nThe application would read the slides and create a data-focused report for quick review.\n\nThe goal of the application is to cut down on the amount of reading that needs to be done by a significant amount as some of these presentation reports can be many pages long with not enough time in the day.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":201,"Q_Id":56975372,"Users Score":0,"Answer":"A PowerPoint PDF isn't a type of PDF.\nThere isn't going to be anything natively in the PDF that identifies elements on the page as being 'slide' graphics the originated from a PowerPoint file for example.\nYou could try building an algorithm that makes decision about content to drop from the created PDF but that would be tricky and seems like the wrong approach to me.\nA better approach would be to \"Export\" the PPT to text first, e.g. in Microsoft PowerPoint Export it to a RTF file so you get all of the text out and use that directly or then convert that to PDF.","Q_Score":0,"Tags":"python,parsing,pdf,pdf-scraping","A_Id":56994393,"CreationDate":"2019-07-10T16:55:00.000","Title":"Is it possible for a PDF data parser to read PowerPoint PDFs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to determine why I would have the need to use Python in UiPath vs invoking VB.Net code. If someone could provide specific examples about why using Python would be more beneficial, it would be very much appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":56975724,"Users Score":0,"Answer":"Python has a larger user community than VB.Net, therefore it is more likely to get help with Python in case you need to find out how to do something or have a problem.\nIt would be more comfortable if UIPath allowed writing the expressions in Python, but it's not dramatic either. You can always call a thread written in your favorite language and get the results to continue with the UIPath flow. Actually the expressions that one writes in UIPath are not so complex.","Q_Score":2,"Tags":"python,uipath","A_Id":57183394,"CreationDate":"2019-07-10T17:22:00.000","Title":"What are example cases in which I should use Python in UiPath?","Data 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 with text data and at the moment I have put my data into a term document matrix and calculated the TF, term frequency and TF-IDF, term frequency inverse document frequency. From here my matrix looks like:\ncolumns = document names\nrownames = words\nfilled with their TF and TF-IDF scores. \nI have been using the tm package in R for much of my current analysis but to take it further I have started playing around with the gensim library in Python.\nIts not clear to me if I have the word embeddings as in the TF and TF-IDF. I am hopeing to use Word2Vec\/Doc2Vec and obtain a matrix similar to what I currently have and then calculate the cosine similarity between document. Is this one of the outputs of the models?\nI basically have about 6000 documents I want to calculate the cosine similarity between them and then rank these cosine similarity scores.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1708,"Q_Id":56976941,"Users Score":1,"Answer":"Yes, you could train a Word2Vec or Doc2Vec model on your texts. (Though, your data is a bit small for these algorithms.)\nAfterwards, with a Word2Vec model (or some modes of Doc2Vec), you would have word-vectors for all the words in your texts. One simple way to then create a vector for a longer text is to average together all the vectors for the text's individual words. Then, with a vector for each text, you can compare texts by calculating the cosine-similarity of their vectors. \nAlternatively, with a Doc2Vec model, you can either (a) look up the learned doc-vectors for texts that were in the training set; or (b) use infer_vector() to feed in new text, which should be tokenized the same way as the training data, and get a model-compatible vector for that new text.","Q_Score":0,"Tags":"python,gensim,word2vec,doc2vec","A_Id":56978241,"CreationDate":"2019-07-10T18:50:00.000","Title":"Can I obtain Word2Vec and Doc2Vec matrices to calculate a cosine similarity?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to delete an empty directory in Jupyter notebook. \nWhen I select the folder and click Delete, an error message pops up saying:\n'A directory must be empty before being deleted.'\nThere are no files or folders in the directory and it is empty.\nAny advice on how to delete it?\nThank you!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":11155,"Q_Id":56978517,"Users Score":0,"Answer":"Go to your local directory where it stores the workbench files, ex:(C:\\Users\\prasadsarada)\nYou can see all the folders you have created in Jupyter Notebook. delete it there.","Q_Score":2,"Tags":"python,jupyter-notebook","A_Id":59487551,"CreationDate":"2019-07-10T20:56:00.000","Title":"Delete empty directory from Jupyter notebook error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to delete an empty directory in Jupyter notebook. \nWhen I select the folder and click Delete, an error message pops up saying:\n'A directory must be empty before being deleted.'\nThere are no files or folders in the directory and it is empty.\nAny advice on how to delete it?\nThank you!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":11155,"Q_Id":56978517,"Users Score":2,"Answer":"Usually, Jupyter itself creates a hidden .ipynb_checkpoints folder within the directory when you inspect it. You can check its existence (or any other hidden file\/folders) in the directory using ls -a in a terminal that has a current working directory as the corresponding folder.","Q_Score":2,"Tags":"python,jupyter-notebook","A_Id":56978899,"CreationDate":"2019-07-10T20:56:00.000","Title":"Delete empty directory from Jupyter notebook error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Couldn't able to import psycopg2\nOutput in python console:\n\nimport psycopg2\nTraceback (most recent call last):\n  File \"\", line 1, in \n   File \"\/home\/user\/.py_virtualenvs\/verb_py3\/lib\/python3.5\/site-packages\/psycopg2\/init.py\", line 50, in \nfrom psycopg2._psycopg import (                     # noqa\n  ImportError: \/home\/user\/.py_virtualenvs\/verb_py3\/lib\/python3.5\/site-packages\/psycopg2\/_psycopg.cpython-35m-x86_64-linux-gnu.so: undefined symbol: PQconninfo","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":8684,"Q_Id":56978734,"Users Score":10,"Answer":"Installed the psycopg2-binary package solved my issue.\npip install psycopg2-binary","Q_Score":6,"Tags":"python-3.5,psycopg2,postgresql-9.5","A_Id":57062796,"CreationDate":"2019-07-10T21:14:00.000","Title":"psycopg2 ImportError: undefined symbol: PQconninfo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Couldn't able to import psycopg2\nOutput in python console:\n\nimport psycopg2\nTraceback (most recent call last):\n  File \"\", line 1, in \n   File \"\/home\/user\/.py_virtualenvs\/verb_py3\/lib\/python3.5\/site-packages\/psycopg2\/init.py\", line 50, in \nfrom psycopg2._psycopg import (                     # noqa\n  ImportError: \/home\/user\/.py_virtualenvs\/verb_py3\/lib\/python3.5\/site-packages\/psycopg2\/_psycopg.cpython-35m-x86_64-linux-gnu.so: undefined symbol: PQconninfo","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":8684,"Q_Id":56978734,"Users Score":2,"Answer":"Re-installing psycopg2 using conda instead of using pip resolved the issue.","Q_Score":6,"Tags":"python-3.5,psycopg2,postgresql-9.5","A_Id":59843430,"CreationDate":"2019-07-10T21:14:00.000","Title":"psycopg2 ImportError: undefined symbol: PQconninfo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are looking to run Celery\/Redis in a kubenetes cluster, and currently do not have Redis persistence enabled (everything is in-memory). I am concerned about: Redis restarts (losing in-memory data), worker restarts\/outages (due to crashes and\/or pod scheduling), and transient network issues.\nWhen using Celery to do task processing using Redis, what is required to ensure that tasks are reliable?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1412,"Q_Id":56978831,"Users Score":0,"Answer":"In order to make your Celery cluster be more robust when using Redis as a broker (and result backend) I recommend using one (or more) replicas. Unfortunately redis-py does not yet have support for clustered Redis, but that is just a matter of time. In the replicated mode, when the master server goes down, replica takes its place and this is (almost) entirely transparent. Celery also supports Redis sentinels.\nCelery became much more robust over the years in terms of ensuring that tasks get redelivered in some critical cases. If the task failed because the worker is lost (there is a configuration parameter for it), some exception was thrown, etc - it will be redelivered, and executed again.","Q_Score":0,"Tags":"python,redis,celery","A_Id":56985275,"CreationDate":"2019-07-10T21:22:00.000","Title":"What is required for reliable task processing in Celery when using Redis?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"By trying to find an optimization to my server on python, I have stumbled on a concept called select. By trying to find any code possible to use, no matter where I looked, Windows compatibility with this subject is hard to find.\nAny ideas how to program a TCP server with select on windows? I know about the idea of unblocking the sockets to maintain the compatibility with it. Any suggestions will be welcomed.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":98,"Q_Id":56979085,"Users Score":1,"Answer":"Using select() under Windows is 99% the same as it is under other OS's, with some minor variations.  The minor variations (at least the ones I know about) are:\n\nUnder Windows, select() only works for real network sockets.  In particular, don't bother trying to select() on stdin under Windows, as it won't work.\nUnder Windows, if you attempt a non-blocking TCP connection and the TCP connection fails asynchronously, you will get a notification of that failure via the third (\"exception\") fd_set only.  (Under other OS's you will get notified that the failed-to-connect TCP-socket is ready-for-read\/write also)\nUnder Windows, select() will fail if you don't pass in at least one valid socket to it (so you can't use select([], [], [], timeoutInSeconds) as an alternative to time.sleep() like you can under some other OS's)\n\nOther than that select() for Windows is like select() for any other OS.  (If your real question about how to use select() in general, you can find information about that using a web search)","Q_Score":0,"Tags":"python,windows,sockets,select","A_Id":56979188,"CreationDate":"2019-07-10T21:47:00.000","Title":"TCP Socket on Server Side Using Python with select on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using sklearn.feature_extraction.text.TfidfVectorizer. I'm processing text. It seems standard to remove stop words. However, it seems to me that if I already have a ceiling on document frequency, meaning I will not include tokens that are in a large percent of the document (eg max_df=0.8), dropping stop words doesn't seem necessary. Theoretically, stop words are words that appear often and should be excluded. This way, we don't have to debate on what to include in our list of stop words, right? It's my understanding that there is disagreement over what words are used often enough that they should be considered stop words, right? For example, scikit-learn includes \"whereby\" in its built-in list of English stop words.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":56979185,"Users Score":1,"Answer":"You are right. It could be the definition of stop words. However, do not forget that one reason to remove the stop words in the first phase, is to prevent counting them and reduce the computation time. \nNotice that your intuition behind stop words is correct.","Q_Score":1,"Tags":"python,scikit-learn,nlp,text-mining,text-processing","A_Id":56980001,"CreationDate":"2019-07-10T21:59:00.000","Title":"Is it bad to not remove stopwords when I've already set a ceiling on document frequency?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"To preface: I'm very very new to Flask\/web frameworks and all.\nFor some CS schoolwork, I'm supposed to develop an application of some form for a teacher. What I have chosen to use to develop it is Flask. However, the teacher I'm sending it to is unfamiliar with Python and probably doesn't have any Flask dependencies or anything installed. So I was wondering if there was a way for me to send him something (like a .pyc) which will locally host\/run the flask app on his computer easily? For the purposes of testing it and all prior to hosting it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1247,"Q_Id":56980597,"Users Score":0,"Answer":"You can use CZ_FREEZE package that converts your FLASK project into a sharable cross-platform app, such that the receiving end doesn't need to install the essential libraries first.\n\nFirst, install the cz_freeze library using,\npip install cz_Freeze\nThen in your main project folder create a setup.py file containing the following code,\nfrom cx_Freeze import setup, Executable\n# Include the name of all folder or files in your project folder that is necessary for the project excluding your main flask file.\n# If there are multiple files, you can add them into a folder and then specify the folder name.\n# In place of main.py file add your main flask file name\nincludefiles = [ 'templates', 'static', 'some_other_file.py']\nincludes = [ 'jinja2' , 'jinja2.ext'] \nexcludes = ['Tkinter']\nsetup(\nname='Sample Flask App',\nversion = '0.1',\ndescription = 'Sample Flask App',\noptions = {'build_exe':   {'excludes':excludes,'include_files':includefiles, 'includes':includes}},\nexecutables = [Executable('main.py')]\n)\nNow from the terminal run,\npython setup.py build\nNow there should be a folder created with name build containing all the files that you mentioned as well as the packages of your virtual environment.\nRun the project using the script file with the name of your main flask file.","Q_Score":1,"Tags":"python,flask","A_Id":62019434,"CreationDate":"2019-07-11T01:43:00.000","Title":"Is there a way to send a flask app to be run by someone who doesn't have any of the stuff installed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Connect to mongodb 4 server with pymongo 3.8 but get serverselection timeout error\npymongo.errors.ServerSelectionTimeoutError: IP:host: [Errno 104] Connection reset by peer","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":56982791,"Users Score":0,"Answer":"I have similar issue. \nI could not connect at first then changed to master host. \nAfter that the connection problem fixed. However, I still cannot CRUD or list collections. It throws \n   OperationFailure: Authentication failed.","Q_Score":1,"Tags":"python-3.x,pymongo","A_Id":58973297,"CreationDate":"2019-07-11T06:24:00.000","Title":"pymongo 3.8 not work with mondob 4 and python 3.5","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a simple python application (using tkinter module) on my personal windows PC and converted it into an executable file using pyinstaller.\nHowever, I am not able to run the same program on my office PC having restricted access.\nThe error that I get on the PC is 'base_library.zip could not be extracted! fopen permission denied'","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1279,"Q_Id":56982805,"Users Score":1,"Answer":"I was able to run it successfully by manually extracting the contents of base_library.zip in the path of the .exe file.","Q_Score":0,"Tags":"python,pyinstaller","A_Id":57213655,"CreationDate":"2019-07-11T06:25:00.000","Title":"base_library.zip could not be extracted! fopen permission denied","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it okay to make changes to the django packages?\nFor instance in my project I have a folder lib\/python2.7\/site-packages\/reversion\/\nAnd in here I want to add one method inside of models.py\nIs this correct?\nInitially I wanted to edit django's admin history page. In some models history change messages are shown in unicode format, but I need it to be string readable. In models.py I used eval function to transfer unicode to python list.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":396,"Q_Id":56986127,"Users Score":2,"Answer":"No, this is not a good practice.\nIn general there is other way to edit the default feature (inheritance, write your own page, etc...).\nThis is because if you modify the django package this becomes difficult to maintain and update.\nBut if it is a small project you can try to edit django package.","Q_Score":0,"Tags":"python,django,django-admin","A_Id":56986532,"CreationDate":"2019-07-11T09:34:00.000","Title":"Can we make changes to the django packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to use \"reinforcement learning\" or a feedback loop on a supervised model?\nI have worked on a machine learning problem using a supervised learning model, more precisely a linear regression model, but I would like to improve the results by creating a feedback loop on the outputs of the prediction, i.e, tell the algorithm if it made mistakes on some examples.\nAs I know, this is basically how reinforcement learning works: the model learns from positive and negative feedbacks.\nI found out that we can implement supervised learning and reinforcement learning algorithms using PyBrain, but I couldn't find a way to relate between both.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":361,"Q_Id":56986663,"Users Score":0,"Answer":"Most (or maybe all) iterative supervised learning methods already use a feedback loop on the outputs of the prediction. If fact, this feedback is very informative since it provides information with the exact amount of error in each sample. Think for example in stochastic gradient descent, where you compute the error of each sample to update the model parameters.\nIn reinforcement learning the feedback signal (i.e., reward) is much more limited than in supervised learning. Therefore, in the typical setup of adjusting some model parameters, if you have a set of input-output (i.e., a training data set), probably it has no sense to apply reinforcement learning.\nIf you are thinking on a more specific case\/problem, you should be more specific in your question.","Q_Score":0,"Tags":"python,linear-regression,reinforcement-learning,supervised-learning","A_Id":56988032,"CreationDate":"2019-07-11T10:03:00.000","Title":"Applying \"reinforcement learning\" on a supervised learning model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to use \"reinforcement learning\" or a feedback loop on a supervised model?\nI have worked on a machine learning problem using a supervised learning model, more precisely a linear regression model, but I would like to improve the results by creating a feedback loop on the outputs of the prediction, i.e, tell the algorithm if it made mistakes on some examples.\nAs I know, this is basically how reinforcement learning works: the model learns from positive and negative feedbacks.\nI found out that we can implement supervised learning and reinforcement learning algorithms using PyBrain, but I couldn't find a way to relate between both.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":361,"Q_Id":56986663,"Users Score":0,"Answer":"Reinforcement Learning has been used to tune hyper-parameters and\/or select optimal Supervised Learning Models. There's also a paper on it: \"Learning to optimize with Reinforcement Learning\".\nReading Pablo's answer you may want to read up on \"back propagation\". It may be what you are looking for.","Q_Score":0,"Tags":"python,linear-regression,reinforcement-learning,supervised-learning","A_Id":57064604,"CreationDate":"2019-07-11T10:03:00.000","Title":"Applying \"reinforcement learning\" on a supervised learning model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to parse a docx file using python-docx. The file contains images and text. Basically i need a way to take an image(an InlineShape object) from the file and save it as a separate image (like \"smth.jpg\"). Is there a way to do that?  From reading the API docs it doesn't seem like it, but maybe i'm missing something.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":333,"Q_Id":56986798,"Users Score":0,"Answer":"OK, i've figured put a way. Converting docx file to zip and extracting from there. It's not the best option, but still pretty good for me.","Q_Score":0,"Tags":"python,image,docx,shapes","A_Id":56987563,"CreationDate":"2019-07-11T10:09:00.000","Title":"Is there a way to save an inline shape from docx as an image file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have prototyped a system using python on linux. I am now designing the architecture to move to a web based system. I will use Django to serve public and private admin pages. I also need a service running, which will periodically run scripts, connect to the internet and allow API messaging with an admin user. Thus there will be 3 components : web server, api_service and database.\n1) What is best mechanism for deploying a python api_service on the VM? My background is mainly C++\/C# and I would have usually deployed a C#-written service on the same VM as the web server and used some sort of TCP messaging wrapper for the API. My admin API code will be ad hoc python scripts run from my machine to execute functionality in this service.\n2) All my database code is written to an interface that presently uses flat-files. Any database suggestion? PostgreSQL, MongoDB, ...\nMany thanks in advance for helpful suggestions. I am an ex-windows\/C++\/C# developer who now absolutely loves Python\/Cython and needs a little help please ...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":56987431,"Users Score":0,"Answer":"Right, am answering my own question. Have done a fair bit of research since posting.\n2) PostgreSQL seems a good choice. There seem to be no damning warnings against using it and there is much searchable help. I am therefore implementing concrete PostgreSQL classes to implement my serialization interfaces.\n1) Rather than implement my own service in python that sits on a remote machine, I am going to use Celery. RabbitMQ will act as the distributed TCP message wrapper. I can put required functionality in python scripts on the VM that Celery can find and execute as tasks. I can run these Celery tasks in 3 ways. i) A web request through Django can queue a task. ii) I can manually queue a remote Celery task from my machine by running a python script. iii) I can use Celery Beat to schedule tasks periodically. This fits my needs perfectly as I have a handful of daily\/periodic tasks that can be scheduled plus a few rare maintenance tasks that I can fire off from my machine.\nTo summarize then, where before I would have created a windows service that handled both incoming TCP commands and scheduled behaviour, I can use RabbitMQ, Celery, Celery Beat and python scripts that sit on the VM.\nHope this helps anybody with a similar 'how to get started' problem .....","Q_Score":0,"Tags":"python,django","A_Id":57042276,"CreationDate":"2019-07-11T10:44:00.000","Title":"Suggestions for web deployment of prototype","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am currently using python to write some appium test. Because I am behind a corporate firewall my traffic needs to go via a proxy. \nI have set my http_proxy and https_proxy variables, but it seems like this is not being picked up by python during execution.\nI tried the exact same test using javascript and node and the proxy get picked up and everything works so I am sure the problem is python not following the proxy settings.\nHow can I make sure python is using correct proxy settings?\nI am using python 2.7 on macos mojave\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":56987653,"Users Score":0,"Answer":"So I figured out that appium currently does not support options to provide a proxy when making a remote connection. As temporary solution I modified the remote_connection module of selenium that appium inherits forcing it to use a proxy url for the connection.\nMy python knowledge is not that good but I think it shoudnt take much effort for someone to make a module that wraps\/override the appium webdriver remote connection to include a proxy option.","Q_Score":0,"Tags":"python","A_Id":57199327,"CreationDate":"2019-07-11T10:56:00.000","Title":"python ignores environmet proxy settings","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 Tensorflow 2.0 and trying to write a tf.keras.callbacks.Callback that reads both the inputs and outputs of my model for the batch. \nI expected to be able to override on_batch_end and access model.inputs and model.outputs but they are not EagerTensor with a value that I could access. Is there anyway to access the actual tensors values that were involved in a batch? \nThis has many practical uses such as outputting these tensors to Tensorboard for debugging, or serializing them for other purposes. I am aware that I could just run the whole model again using model.predict but that would force me to run every input twice through the network (and I might also have non-deterministic data generator). Any idea on how to achieve this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":354,"Q_Id":56988498,"Users Score":1,"Answer":"No, there is no way to access the actual values for input and output in a callback. That's not just part of the design goal of callbacks. Callbacks only have access to model, args to fit, the epoch number and some metrics values. As you found, model.input and model.output only points to the symbolic KerasTensors, not actual values.\nTo do what you want, you could take the input, stack it (maybe with RaggedTensor) with the output you care about, and then make it an extra output of your model. Then implement your functionality as a custom metric that only reads y_pred. Inside your metric, unstack the y_pred to get the input and output, and then visualize \/ serialize \/ etc. Metrics\nAnother way might be to implement a custom Layer that uses py_function to call a function back in python. This will be super slow during serious training but may be enough for use during diagnostic \/ debugging.","Q_Score":10,"Tags":"python,tensorflow,keras,tensorflow2.0,tf.keras","A_Id":68777974,"CreationDate":"2019-07-11T11:48:00.000","Title":"Tensorflow 2.0: Accessing a batch's tensors from a callback","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new in drone, can you please explain one thing:\nIs it possible to have RC controller programmed by python?\nAs I understood using telemetry module and DroneKit, it is possible to control the drone using python.\nBut usually telemetry module supporting drones are custom drones and as I understood telemetry module does not work as good as RC.\nSo to have cheaper price, can someone suggest me solution about how to control RC drone using python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":268,"Q_Id":56990495,"Users Score":0,"Answer":"You can use tello drones .These drones can be programmed as per your requirement using python .","Q_Score":0,"Tags":"python,dronekit-python","A_Id":58305698,"CreationDate":"2019-07-11T13:34:00.000","Title":"Drone control by 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 trying to import pydub into a project and am getting the following errors:\nTraceback (most recent call last):\n  File \"wave.py\", line 3, in <module>\n    from pydub import AudioSegment\n  File \"\/Library\/Frameworks\/Python.framework\/Versions\/3.6\/lib\/python3.6\/site-packages\/pydub\/__init__.py\", line 1, in <module>\n    from .audio_segment import AudioSegment\n  File \"\/Library\/Frameworks\/Python.framework\/Versions\/3.6\/lib\/python3.6\/site-packages\/pydub\/audio_segment.py\", line 7, in <module>\n    import wave\n  File \"\/Users\/Sim\/Desktop\/Audio Wave\/wave.py\", line 3, in <module>\n    from pydub import AudioSegment\nImportError: cannot import name 'AudioSegment'\n\nI installed pydub with no issues, so not really sure what the problem may be.\nAny help would be greatly appreciated","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":565,"Q_Id":56991777,"Users Score":1,"Answer":"It did not like the name wave.py for the file. Gave it a new name and all good now.","Q_Score":0,"Tags":"python,pydub,audiosegment","A_Id":57007145,"CreationDate":"2019-07-11T14:39:00.000","Title":"Issue Importing AudioSegment from Pydub in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to check the collision between a set of points to a point cloud (contain around 1M pts). I actually want to know which parts of the point cloud is collided with those outside points, and store those collided pts in the point cloud.\nI loop through each outside point and use the Obbtree.IntersectWithLine to check the collision with each pt in point cloud, while it is too slow... I enabled the CPU parallel computing but the improvement is limited. I was wondering if any GPU-accelerated API that is compatible with the VTK objects, or there is a better-efficient way to check the collision?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":173,"Q_Id":56993004,"Users Score":0,"Answer":"IntersectWithLine only intersects a segment to a polygonal mesh afaik.\nYou can maybe make a convex hull of the first cloud and then ask for the internal points of the second (?)\nIn this case one would use vtkSelectEnclosedPoints.","Q_Score":0,"Tags":"python,gpu,vtk","A_Id":57031365,"CreationDate":"2019-07-11T15:48:00.000","Title":"VTK ObbTree.IntersectWIthLine too slow for large-scale collision detection","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm setting up a graphical calculator and I need to calculate a list of y values from multiple given x values. Like for example the equation is 10x+5. I set the view window as -10 to 10. I need to find a way to calculate 10(-10)+5 all the way up to 10(10)+5. \nIn order to do that I would need to find a way to replace x with a list of integers. How can I achieve that?\nreplace() doesn't work because it only accepts str and not lists.\nequation.replace('x', xValues)","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":56993465,"Users Score":0,"Answer":"[equation.replace('x', y) for y in xValues] use list comprehension for it","Q_Score":0,"Tags":"python","A_Id":56993525,"CreationDate":"2019-07-11T16:18:00.000","Title":"How to replace a substring with multiple strings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to plot streamtraces from CFD analysis with Python, over a 2D contour plot. My problem is that I'm dealing with 4 large 1D arrays (x,y coordinates and u,v velocity components), say over 100k points, arising from an external CFD simulation (so I cannot manipulate them). Creating 2D arrays from them (e.g. with scipy.interpolate.griddata as I found) causes my computer to crash due to excessive memory usage.\nI've also tried with quiver but I can't get a size for the arrows that scales with the dimensions of the plot: they are either too big or too small and anyway too many.\nSince I've looked at all the solutions I've found but none worked.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":56993521,"Users Score":0,"Answer":"try to vectorize your loops that may help greatly with large scale datas.","Q_Score":0,"Tags":"python,arrays,python-3.x,matplotlib,plot","A_Id":57639340,"CreationDate":"2019-07-11T16:21:00.000","Title":"Python Streamplot from large 1D arrays","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a program in python and want to clear what the user has enterd, this is because I am using the keyboard function to register input as is is given, but there is still text left over after a keypress is registerd and I don't want this to happen.\nI was woundering if there is a module that exists to remove text that is being entered\nAny help would be greatly apreciated, and just the name of a module is fine; I can figure out how to use it, just cant find an appropriate module.\nEDIT:\nSorry if i did not make my self clear, I dont really want to clear the whole screen, just what the user has typed. So that they don't have to manually back space after their input has been taken.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":56994310,"Users Score":0,"Answer":"'sys.stdout.write' is the moduel I was looking for.","Q_Score":0,"Tags":"python,python-3.6","A_Id":56995012,"CreationDate":"2019-07-11T17:14:00.000","Title":"Is there a way of deleting specific text for the user in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using google colab but I can not save the results directly from colab to my google drive or even in my computer. Can anybody give me a hand?\nRegards","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":56994495,"Users Score":0,"Answer":"After mounting your Google drive. You can do the following to save your work on the drive:\n1 Click File.\n2 Click Save File in Drive.","Q_Score":0,"Tags":"python-2.7","A_Id":58046297,"CreationDate":"2019-07-11T17:26:00.000","Title":"Save colab results","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can python classmethod change value of an instance variable?\nAnd can normal methods change value of the class variable?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":3108,"Q_Id":56997115,"Users Score":2,"Answer":"Can python classmethod change value of an instance variable?\n\nNo. Class object does not have direct access to any instance variable.\n\ncan normal methods change value of the class variable?\n\nYes; but the change will be on it's own view (unless the name is referred by using class explicitly e.g. by name or self.__class__) i.e. it won't change the class variable as seen by the class or any other object. If the class object is referred explictly the class variable will be changed as you can imagine.","Q_Score":0,"Tags":"python","A_Id":56997258,"CreationDate":"2019-07-11T20:49:00.000","Title":"Can python classmethod change value of an instance variable and vice versa?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to compile C++ code for a Python3 extension on macOS, and I'm only able to compile if I #include \"$HOME\/anaconda3\/include\/python3.6m\/Python.h. Is there a way to #include <Python\/Python.h> and have the \"include\" refer to the anaconda Python.h instead of the system Python.h?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":88,"Q_Id":56997148,"Users Score":1,"Answer":"Having your Python.h inside a directory named python3.6m makes it a bit awkward, but here are two possible ways to resolve the issue:\n\nRename the directory from python3.6m to Python, and then add the argument -I$HOME\/anaconda3\/include to your compile line, to tell the compiler to resolve include-paths starting at that folder.\nAlternatively, you could add a symlink so that the python3.6m directory can be accessed via two different names, e.g.:\ncd ~\/anaconda3\/include ; ln -s python3.6m Python\n\n... and then add the argument -I$HOME\/anaconda3\/include to your compiler arguments (same as in step 1)","Q_Score":0,"Tags":"macos,python,c++","A_Id":57000061,"CreationDate":"2019-07-11T20:24:00.000","Title":"CPython Python.h on macOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"There are several similar questions around that suggest using any() with sets, however mine is a bit different in a way that I want to get the most effective and Pythonic way of forming a new array out of existing arrays based on membership.\nI have the following array [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 4, 5, 6], [2, 4, 5, 6, 9, 1, 4, 5, 6, 4, 5, 6], [1, 2, 9, 4, 5, 6, 7, 7, 8, 5]]\nWhat I need is a way to form a new object {[4, 5, 6] : 6} where [4, 5, 6] is the key, and 6 is the number of times the key sequence appears in the array above.\nI have achieved the result by making a function with simple for loops, but I don't think it is the most Pythonic and efficient way of achieving it. I was thinking of using map() and filter() as well.\nWhat would be the most efficient and Pythonic way of achieving the result?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":54,"Q_Id":56997410,"Users Score":1,"Answer":"best way to maintain a mapping of elements in an array to a value is a hash table.\nas @JacobIRR mentioned {[4, 5, 6] : 6} is not valid because you cant have multiple keys associated to a value. i cant give you an exact solution to your problem as you didnt mention how your function works.\nif your algorithm dosent depend on a list as a key,you can try  {6 :[4, 5, 6]} will be a valid solution as HashMap doesn't allow duplicate keys but allows duplicate values.","Q_Score":0,"Tags":"python,arrays","A_Id":56997616,"CreationDate":"2019-07-11T21:17:00.000","Title":"check for consecutive values membership in arrays","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem while I load my python pyqt5 gui on a windows vista computer using windows powershell.\nI get the following error:-\nqt.qpa.plugin: Could not load the Qt platform plugin \"windows\" in \"\nThis application failed to start because no Qt platform plugin coul\nx this problem.\nAvailable platform plugins are: minimal, offscreen, webgl, windows.\nIt worked perfectly on a windows 10 computer. There had been errors where it was not been able to find the plugin. I have solved that. But now, even though it is able to find the plugin, it doesn't load. \nCan you help me out?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2127,"Q_Id":56997836,"Users Score":0,"Answer":"I had the same error using the conda base environment. I tried many attempts from different discussions about this, but in the end it worked with creating a (new) conda-env and installing dependencies such as matplotlib (which again depends on pyqt which is then also installed by conda)","Q_Score":2,"Tags":"python,qt,plugins,pyqt5","A_Id":58610523,"CreationDate":"2019-07-11T22:01:00.000","Title":"Qt platform plugin not loading even though it is found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to get the waiting time of vehicles in SUMO and work it into the TraCI interface. For example I want to receive the  getwaitingtime() of each vehicle Id within a certain area of the network.(meaning they are stopped or waiting in a queue). Then I want to add the total waiting time of Vehicles based on lane or each direction. After the total Time is added I want to assign this value to lets say X. and Use the value of X to perform some mathematical calculations and give decision to change the traffic light.\ngetwaitingtime(). VehID().","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":607,"Q_Id":56998904,"Users Score":0,"Answer":"When the vehicle is stopped it doesn't accumulate waiting time. Rather you can do this check using isStopped command. This will return True for each simulation step the vehicle is stopped or is in a stopped state.\nAs for the accumulation of waiting time, the waiting time counter is set to 0 each time the vehicle's speed is greater than 0.1 ms. So getWaitingTime might not give you an accurate measure of the total waiting time for a single vehicle. Use getAccumulatedWaitingTime to get the accumulated waiting time for the pre-defined or user-defined waiting time memory. This accumulated waiting time can be tested against the simulation time steps (aggregate) and then you can know for sure if the vehicle has been in the queue for a long time or not.","Q_Score":0,"Tags":"python,sumo,traffic-simulation","A_Id":57004916,"CreationDate":"2019-07-12T00:38:00.000","Title":"SUMO TraCi : How to assign the getwaitingtime() of a VehId and add that total Waiting time per lane?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to install Django. Turns out that course's teacher said that we will be working with Python 3.6\nI install Python 3.6. Now it's my default, it somewhat replaced the last version I had; which is Python 3.5.\nEverything ok until that. But when I want to install Django doing\n\"pip3 install django\", it tells me that the module is already satisfied and therefore installed.\nI run \"python3\" command into my terminal. It runs Python 3.6. I try to import Django, and boom... \"No module named 'django'\".\nThen I realized pip3 was actually installing my modules into Python 3.5 and not 3.6. So what I do is to install pip in Python 3.6. \nI download get-pip.py and proceed to execute it with Python 3.6 typing in \"python3.6 get-pip.py\". \nHere is when the damn \"zipimport.ZipImportError: can't decompress data; zlib not available\" goes in. I've tried a ton of things and no one of them fixed the %^$! problem. I'm really tired.\nWhat I have already tried:\npython3.6 -m pip install django, which output is \"\/usr\/local\/bin\/python3.6: No module named pip\"\napt install zlib, which output is \"E: Unable to locate package zlib\"\napt install zlib1g-dev, which says that it's already installed; the problem persists though.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":9581,"Q_Id":56999217,"Users Score":1,"Answer":"Suggested solutions (installing zlib1g-dev or zlib-devel) seem to resolve the issue in most cases. Here is one edge case I've encountered recently: whatever you are trying to run might use zlib via symlink which might be broken.\nIn my case I was trying to run a build of a 3rd-party software which already had python and all necessary libs being emebedded into it. It was packaged as a tar.gz archive. Unpacking the archive on a Windows machine and then copying the contents to another linux machine destroyed all the symlinks (if you do ls -l in a folder with symlinks you would see that all of them have size 0 and do not point to anything). Copying tar.gz to the linux machine directly and unpacking it there resolved the issue.\nP.S. I know it's an edge case scenario but it took me and one more developer quite a while to figure it out so I think it's worth mentioning here, just in case someone gets as unlucky as I got.","Q_Score":8,"Tags":"python,django,python-3.x,pip,zlib","A_Id":67194445,"CreationDate":"2019-07-12T01:42:00.000","Title":"Can't fix \"zipimport.ZipImportError: can't decompress data; zlib not available\" when I type in \"python3.6 get-pip.py\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was trying to install Django. Turns out that course's teacher said that we will be working with Python 3.6\nI install Python 3.6. Now it's my default, it somewhat replaced the last version I had; which is Python 3.5.\nEverything ok until that. But when I want to install Django doing\n\"pip3 install django\", it tells me that the module is already satisfied and therefore installed.\nI run \"python3\" command into my terminal. It runs Python 3.6. I try to import Django, and boom... \"No module named 'django'\".\nThen I realized pip3 was actually installing my modules into Python 3.5 and not 3.6. So what I do is to install pip in Python 3.6. \nI download get-pip.py and proceed to execute it with Python 3.6 typing in \"python3.6 get-pip.py\". \nHere is when the damn \"zipimport.ZipImportError: can't decompress data; zlib not available\" goes in. I've tried a ton of things and no one of them fixed the %^$! problem. I'm really tired.\nWhat I have already tried:\npython3.6 -m pip install django, which output is \"\/usr\/local\/bin\/python3.6: No module named pip\"\napt install zlib, which output is \"E: Unable to locate package zlib\"\napt install zlib1g-dev, which says that it's already installed; the problem persists though.","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":9581,"Q_Id":56999217,"Users Score":3,"Answer":"For me it worked in RHEL:\n$ yum install zlib-devel","Q_Score":8,"Tags":"python,django,python-3.x,pip,zlib","A_Id":68827729,"CreationDate":"2019-07-12T01:42:00.000","Title":"Can't fix \"zipimport.ZipImportError: can't decompress data; zlib not available\" when I type in \"python3.6 get-pip.py\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was trying to install Django. Turns out that course's teacher said that we will be working with Python 3.6\nI install Python 3.6. Now it's my default, it somewhat replaced the last version I had; which is Python 3.5.\nEverything ok until that. But when I want to install Django doing\n\"pip3 install django\", it tells me that the module is already satisfied and therefore installed.\nI run \"python3\" command into my terminal. It runs Python 3.6. I try to import Django, and boom... \"No module named 'django'\".\nThen I realized pip3 was actually installing my modules into Python 3.5 and not 3.6. So what I do is to install pip in Python 3.6. \nI download get-pip.py and proceed to execute it with Python 3.6 typing in \"python3.6 get-pip.py\". \nHere is when the damn \"zipimport.ZipImportError: can't decompress data; zlib not available\" goes in. I've tried a ton of things and no one of them fixed the %^$! problem. I'm really tired.\nWhat I have already tried:\npython3.6 -m pip install django, which output is \"\/usr\/local\/bin\/python3.6: No module named pip\"\napt install zlib, which output is \"E: Unable to locate package zlib\"\napt install zlib1g-dev, which says that it's already installed; the problem persists though.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":9581,"Q_Id":56999217,"Users Score":1,"Answer":"Its solves my issue for centos 7.6 :-\nyum install zlib-deve","Q_Score":8,"Tags":"python,django,python-3.x,pip,zlib","A_Id":66745621,"CreationDate":"2019-07-12T01:42:00.000","Title":"Can't fix \"zipimport.ZipImportError: can't decompress data; zlib not available\" when I type in \"python3.6 get-pip.py\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a simple python script that calls the Splunk API. For this, I include splunklib:\n\"import splunklib.client as client\"\nThis script works very well, when I start it from a terminal window (MacOS): python3 main.py\nFor this, I had to install splunklib using \"pip3 install splunklib\".\nUnfortunately I can't run the same script out of Pycharm.\nI also successfully installed splunklib under settings\/Project Interpreter\/Package. splunklib is shown in the list of installed packages for the Project Interpreter (splunklib 1.0.0, Python 3.7).\nWhen I run the script using Pycharm, I get the following error message:\nimport splunklib.client as client\nModuleNotFoundError: No module named 'splunklib.client'; 'splunklib' is not a package\nWhy can Pycharm not find Esplunklib, even though it's installed in the Project Interpreter?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2226,"Q_Id":57001234,"Users Score":3,"Answer":"I had this same issue today, and tried to resolve it the same as you by doing a pip3 install splunklib. Unfortunately, the splunklib package is not the one you want. I'm not sure if that is a deprecated package, or something else entirely, but what you're probably looking for is the splunk-sdk.\nThis should get you going; pip3 install splunk-sdk","Q_Score":2,"Tags":"python-3.x,macos,pycharm,splunk-sdk","A_Id":59293259,"CreationDate":"2019-07-12T06:22:00.000","Title":"PyCharm doesn't Splunk SDK (splunklib)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to find out how fsolve in scipy works. So far, all I have found is that it is a numerical solver that finds the root of non linear sets of equations. But I can't find what method it uses to find the roots anywhere. Does anyone know how the roots are found?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":57008554,"Users Score":0,"Answer":"So, after looking up the source code it seems that the solver \"fsolve\" uses the powell method to find the roots.","Q_Score":0,"Tags":"python,scipy","A_Id":57009082,"CreationDate":"2019-07-12T14:00:00.000","Title":"How does fsolve in scipy work? What methods does it use to find the roots?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to implement my own QGraphicsItems to display in a QGraphicsScene. One advantage of this is, that I can keep the positions and sizes of my business objects, without having to convert between them and the display coordinate system.\nBut: Unfortunately the sizes are small, like 0.5 (meters). This is not a problem with the QPolygons, but when I want to display text at half the size of the objects, below a point or pixel size of 0.5, nothing gets displayed.\nI got around that somewhat by having the labels separately created in the scene as QSimpleTextItems and scaling them afterwards, but I don't want that kind of separation.\nAm I missing something? Like a way to scale everything times 100 behind the scenes?\nUpdate:\nI now also tried scaling the QPainter object up, so that I can use more \"normal\" font sizes, but it seems this does not change the behaviour.\nScaling everything by 100 and then setting the font (point) size to 0.2 * 100, does also not show the labels.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":57009308,"Users Score":0,"Answer":"I solved this problem by creating a QGraphicsTextItem object inside my custom QGraphicsItem object.\nThis text object I can scale down to whatever size I need and just call its paint() method in the paint method of my custom object.\nThis works pretty well, although I'm not yet sure, if, for example, clicking the text, automatically translates to a click on my custom object, or if they are two separate entities.\nI guess it comes down to the bounding rectangle, though.","Q_Score":0,"Tags":"python,qt,pyside2","A_Id":57036712,"CreationDate":"2019-07-12T14:44:00.000","Title":"How small can the Text in a QGraphicsScene get?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to remove Appium session and all Appium resources on the device, but leave an app opened on a real iOS device?\nThe thing is that I need to execute driver.quit to clean all Appium resources, but leave the app itself opened","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":291,"Q_Id":57011110,"Users Score":0,"Answer":"The best way I've found is to update deleteSession method in node_modules\/appium\/node_modules\/appium-xcuitest-driver\/build\/lib\/driver.js to remove await this.proxyCommand(\/session\/${this.sessionId}, 'DELETE');","Q_Score":0,"Tags":"ios,appium,python-appium","A_Id":57065414,"CreationDate":"2019-07-12T16:50:00.000","Title":"Is it possible to remove Appium session (and all Appium resources on device), but leave app opened on iOS (real 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 would like to force scipy.stats.cauchy probability density function to only generate values between -1 and 1.\nCurrently I am doing the hacky way by running y=cauchy.rvs(center,sigma) inside a while loop and while its lower than -1 or higher than 1 it recomputes it and after it enters the desired interval it returns y. So essentially I am drawing a new random variable until the conditions are not met.\nI am wondering whether it's possible to do this in a simpler way, the scipy documentation is not very helpful and it's very ambiguous. Is there any way to specify the min\/max range of the random variables inside the function arguments, like via **kwargs or something?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":507,"Q_Id":57011662,"Users Score":1,"Answer":"Short answer: Not directly, no.\nThe issue is that a distribution is normalized, the integral of the pdf over the support is unity. When you change the support, you are effectively changing the distribution.\nFor the truncated Cauchy distribution, you can easily roll your own little generator, using the inverse function transform of a uniform random variate.","Q_Score":1,"Tags":"python,python-3.x,scipy","A_Id":57012785,"CreationDate":"2019-07-12T17:34:00.000","Title":"Force scipy.stats.cauchy between an interval","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to do an script that can get many inputs in a row as the user want and then create some list of that.\nMy first idea was create an unique input list and then split the sublist in the total of lists. Or there is a shorted way to do?\nI've tried with this but I can't split the inputs in lists\n\nkeys = list()\nwhile True:\n    line = input('Enter words: ').rstrip().lower()\n    if line == 'done' or line == 'Done':\n        break\n    keys.append(line)\ninput_list = keys.split(',')\nThe result is a lists in a list\nkeys = ['a,b,c,d', 'z,x,w', 'value_n, value_n+1, value_n+n']\nBut the output have to be:\nlist_1 = ['a', 'b', 'c', 'd']\nlist_2 = ['z', 'x', 'w']\nlist_n = ['value_n', 'value_n+1', 'value_n+n']","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":119,"Q_Id":57012472,"Users Score":0,"Answer":"You could do input('Enter words: ').rstrip().lower().split(',') and have the user separate the values with just a comma, or input('Enter words: ').rstrip().lower().split(', ') and have the user separate the values with a comma and a space.\n[w.lstrip() for w in input('Enter words: ').rstrip().lower().split(',')] accepts both types of entries.","Q_Score":1,"Tags":"python-3.x,input,split","A_Id":57012635,"CreationDate":"2019-07-12T18:39:00.000","Title":"How can I get many inputs from the user as list in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a numpy array ids = np.array([1,1,1,1,2,2,2,3,4,4])\nand another array of equal length vals = np.array([1,2,3,4,5,6,7,8,9,10])\nNote: the ids array is sorted by ascending order\nI would like to insert 4 zeros before the beginning of each new id - i.e. \nnew array = np.array([0,0,0,0,1,2,3,4,0,0,0,0,5,6,7,0,0,0,0,8,0,0,0,0,9,10])\nOnly, way I am able to produce this is by iterating through the array which is very slow - and I am not quite sure how to do this using insert, pad, or expand_dim ...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":126,"Q_Id":57015429,"Users Score":0,"Answer":"u can use np.zeros and append it to your existing array like\nnewid=np.append(np.zeros((4,), dtype=int),ids)\nGood Luck!","Q_Score":0,"Tags":"python-3.x,numpy","A_Id":57016163,"CreationDate":"2019-07-13T01:06:00.000","Title":"Quickest way to insert zeros into numpy array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am putting \"django-admin startproject mysite\". Project is creating in the folder of C:\\VTRoot\\HarddiskVolume3 by default instate of desire folder. Please help me out.\npip install django","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":811,"Q_Id":57016045,"Users Score":1,"Answer":"I had a similar issue but with a C# project on Windows machine.\nTry these steps if you have Comodo antivirus installed:\n\nOpen the comodo, select \"Unblock Applications\"\nFind your installer and unblock it.\nIf you have any other antivirus installed, I am not sure if the above steps work but there is no harm in trying.","Q_Score":1,"Tags":"django,python-3.x","A_Id":57483326,"CreationDate":"2019-07-13T04:08:00.000","Title":"Django project is creating into C:\\VTRoot\\HarddiskVolume3 by default","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am putting \"django-admin startproject mysite\". Project is creating in the folder of C:\\VTRoot\\HarddiskVolume3 by default instate of desire folder. Please help me out.\npip install django","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":811,"Q_Id":57016045,"Users Score":1,"Answer":"I am running on a PC that has Comodo managed by devops. I cannot control the settings without them being approved and implemented by someone else. But there is probably a folder where you can do this work if you are able to move to it.\nFor me, it was C:\\ProgramData\\Shared Space\nThis is a hidden directory. Use at your own risk!\nSummary: Comodo -> Settings -> Containment -> (Do not virtualize access to) the Specified files folders -> Expand Shared Spaces and see where it points.\nDetails:\nIn Comodo, if you open up the program from the taskbar, and then click on settings. You will see tabs on the left. Click on the one labeled \"Containment.\"\nHopefully a \"Shared Space\" has been made available for you to put this sort of work in that will not be virtualized \/ quarantined. \nLocate \"Do not virtualize access to the specified files\/folders\" Click on the link in that sentence.\nA dialog will open up that shows the shared spaces that have been defined. Expand that list and you will see where you can put files \/ folders that Comodo will ignore.","Q_Score":1,"Tags":"django,python-3.x","A_Id":57625888,"CreationDate":"2019-07-13T04:08:00.000","Title":"Django project is creating into C:\\VTRoot\\HarddiskVolume3 by default","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have written api using nodejs and calling those api's from Python code. I always have to make sure that my nodejs is running before I execute my python code. Can we make nodejs start running automatically while start executing python file.\nFor Example: we can achieve this in the angular just by including some code in package.json file, so that when I start angular server that will automatically run my node script as well.\nI saw about \"Python-Shell\" package but \"It is a simple way to run Python scripts from Node.js\".\nThis is very important. Please help me!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":71,"Q_Id":57016359,"Users Score":0,"Answer":"In the package.json file,  you will find a start property which define commands the console should run when the server is started.","Q_Score":1,"Tags":"node.js,python-3.x","A_Id":57016622,"CreationDate":"2019-07-13T05:13:00.000","Title":"How to make nodejs run automatically when we start running 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 have a view, and when user click on a button it gets called. But if a user clicks the button twice, it gets called for another even if the first is still executing or running.\nThis produces a problem (if I am correct), and that is: it stops execution for the first one and starts executing for the other. How can I stop this calling of views twice?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":228,"Q_Id":57019298,"Users Score":0,"Answer":"When a request has been sent to the server, Django will pick it up and send a response when it's finished. if there is no one there to receive the response then nothing happens but the processes have been done already. You should ask for verification if your process is important to be received.\nWhen the user sends the second request, both requests will be processed and will return a response. If you're working with an API and your frontend isn't rendered in the backend server then the user will probably receive both responses and depending on the code on the front side, many things can happen. they might see both responses or just one. or the first one might get updated instantly when the second response comes in.\nThis might lead to problems depending on the processes you are running. for example, if you are updating a record in a database and the update can only happen once, then probably you'll get an error in the second try. it is really really rare and mostly impossible that the update part for both requests happens in the exact same time depending on your database, your code, and many other things.\nThere are many ways to handle such a problem which most of them depends on many things but I'm gonna list you few of these options:\n1 - Change the display for the button to none so the user won't be able to click on it again. This is a very simple solution and works most of the times unless you have users trying to hurt your system intentionally.\n2 - Redirect the user to another page and then wait for a response there.\n3 - If your view is doing some heavy processes which are expensive to run, then just create a queue system with some limitations for each user. This is usually done in scaled projects with a lot of users.\n4 - Use a rate limiting system to deny too many requests at once or block any none normal traffic.","Q_Score":0,"Tags":"python,django,django-views","A_Id":57019481,"CreationDate":"2019-07-13T12:45:00.000","Title":"Django : Stop calling same view if it's already called","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Does anyone know of a way to name a list in python using a String. I am writing a script that iterates through a directory and parses each file and and generates lists with the contents of the file. I would like to use the filename to name each array. I was wondering if there was a way to do it similar to the exec() method but using lists instead of just a normal variable","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":57021141,"Users Score":0,"Answer":"You would be better off using a dictionary. Store the file name as the key value of the dictionary and place the contents inside the corresponding value for the key.\nIt's like \nmy_dict = {'file1.txt':'This is the contents of file1','file2.txt':'This is the content of file2'}","Q_Score":0,"Tags":"python,arrays,string,list","A_Id":57021209,"CreationDate":"2019-07-13T16:53:00.000","Title":"Naming a list in python using a String name","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with NetCDF files from NCAR and I'm trying to plot sea-ice thickness. This variable is on a curvilinear (TLAT,TLON) grid. What is the best way to plot this data on a map projection? Do I need to re-grid it to a regular grid or is there a way to plot it directly? I'm fairly new to Python so any help would be appreciated. Please let me know if you need any more information. Thank you! \nI've tried libraries like iris, scipy, and basemap, but I couldn't really get a clear explanation on how to implement them for my case.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":276,"Q_Id":57023555,"Users Score":0,"Answer":"I am pretty sure you can already use methods like contour, contourf, pcolormesh from Python's matplotlib without re-gridding the data. The same methods work for Basemap.","Q_Score":1,"Tags":"python,interpolation,netcdf","A_Id":57053572,"CreationDate":"2019-07-13T23:37:00.000","Title":"How can I put my curvilinear coordinate data on a map projection?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Basically the idea is to automate some workflows without using Qgis.\nI'm failing to achieve similar results to the Qgis feature 'Add coordinates to points' in Geopandas, which allows you to grab the x,y coordinates of points in its current projection and create new attributes to the table.\nSo I have a set of points with which I played with. The original shapefile's CRS is epsg 2154 (Lambert 93). I need to get the latitude and longitude in a format compatible with Google Maps.\nGoogle uses epsg 3857 for Google Maps.\npoints = pd.DataFrame({'Id': ['001', '002', '003'],'geometry':         ['POINT (909149.3986619939 6881986.232659903)', 'POINT (909649.3986619939 6882486.232659903)', 'POINT (909149.3986619939 6882486.232659903)']})\nThe idea is to switch to epsg 3857 (wgs84) and from there, create lat\/long columns which would be filled with wgs84 coordinates, such as 47.357955,1.7317783.\nSo what I did was obvisouly changing the CRS:\npointswgs84 = points.to_crs(espg=3857)\nAnd then\npointswgs84['lon'] = pointswgs84.geometry.x\npointswgs84['lat'] = pointswgs84.geometry.y\nBut my lat\/long columns get then filled with coordinates corresponding to the original points dataframe:\npoints = pd.DataFrame({'Id': ['001', '002', '003'],'geometry':['POINT (909149.3986619939 6881986.232659903)', 'POINT (909649.3986619939 6882486.232659903)', 'POINT (909149.3986619939 6882486.232659903)'],'long': ['6881986.232659903', '6882486.232659903', '6882486.232659903'], 'lat': ['909149.3986619939', '909649.3986619939', '909149.3986619939']})\nLooks like I'm missing something here but since I'm rather new to Python & Geopandas in general I'm not sure about what... \nThank you for your help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":659,"Q_Id":57027276,"Users Score":0,"Answer":"Alright, so problem solved. It was a simple espg issue. Here's the solution if that can help any other newbie like me:\nEven if Google uses espg 3857, if you need to convert the X,Y of your point to something which could be exploitable (such as a url parameter), you need to use espg 4326.\nYou'll then get your long lat the right way. Like 5.859162,49.003710.\nSo:\nStep 1: convert your original shapefile to espg 4326\npointswgs84 = points.to_crs({'init': 'epsg:4326'})\nStep 2: simply extract x and y and add them in new columns\npointswgs84['lon'] = pointswgs84.geometry.x\npointswgs84['lat'] = pointswgs84.geometry.y","Q_Score":0,"Tags":"python,pandas,gis,qgis,geopandas","A_Id":57029334,"CreationDate":"2019-07-14T12:11:00.000","Title":"Add coordinates to points after changing a df CRS in Geopandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a non-hdfs .csv file using a spark DataFrame. How can do it ? \nThe purpose of this non-hdfs .csv file is to use read_csv() on it and load it back to a pandas DataFrame.\nI tried using toPandas() but I have 45 million records in my spark DataFrame and its very slow.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":438,"Q_Id":57028445,"Users Score":0,"Answer":"If you have 45 million records you will likely need to create a set of csv files which spark will do automatically.  Depending on where you want to save the data the path will vary.  For example if you wanted to write to S3 you would provide a path like this.\n\ndf.write.csv(\"s3:\/\/my-bucket\/path\/to\/folder\/\")\n\nYou may also want to manually repartition the data before writing to get an exact number of output files.","Q_Score":1,"Tags":"python-3.x,pandas,apache-spark,pyspark,pyspark-sql","A_Id":57031293,"CreationDate":"2019-07-14T14:49:00.000","Title":"Create a non-hdfs csv from spark dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does the grid search cv stops when my computer is in sleep mode? Should I turn off sleep mode when running it?\nRegards\nVikrant","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":57028814,"Users Score":1,"Answer":"Sleep mode suspends all processor activities and places RAM in a low power state only enough to retain the state. So, yes grid search or any process for that matter is suspended.","Q_Score":1,"Tags":"python,machine-learning,grid-search,gridsearchcv","A_Id":57029035,"CreationDate":"2019-07-14T15:37:00.000","Title":"Grid Search and computer in sleep mode","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"take a input as a csv file and generate text\/sentence using nlg. I have tried with pynlg and markov chain.But nothing worked .What else I can use?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":311,"Q_Id":57035069,"Users Score":-1,"Answer":"There are not much python libraries for NLG!!. Try out nlglib a python wrapper around SimpleNLG. For tutorial purposes, you could read Building Natural Language Generation systems by e.reiter.","Q_Score":0,"Tags":"python,nlp","A_Id":57142523,"CreationDate":"2019-07-15T07:29:00.000","Title":"how to use natural language generation from a csv file input .which python module we should use.can any one share a sample tutorial?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to continuously display some data that I receive in a Flask Server in a GUI that I designed with PySimpleGUI. Currently my GUI and my Flask Server are two seperate projects, what would be the cleanest\/best practise method to connect them?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":424,"Q_Id":57035196,"Users Score":0,"Answer":"The way you \"receive data\" in PySimpleGUI will be inside the event loop.  Usually communicating with a GUI subsystem is through something like a queue.   \nUse a timeout values on your window.Read(timeout=100) call so that it doesn't completely block.  This will enable it to read the queue or make a function call or do whatever it has to do to get the data.","Q_Score":1,"Tags":"python,flask,pysimplegui","A_Id":57047683,"CreationDate":"2019-07-15T07:36:00.000","Title":"How to receive data in a PySimpleGUI GUI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am a newbie in Python, and have a problem. When I code Python using Sublime Text 3 and run directly on it, it does not find some Python library which I already imported. I Googled this problem and found out Sublime Text is just a Text Editor.\nI already had code in Sublime Text 3 file, how can I run it without this error? \nFor example: \n\n'ModuleNotFoundError: No module named 'matplotlib'. \n\nI think it should be run by cmd but I don't know how.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5433,"Q_Id":57038252,"Users Score":2,"Answer":"Depending on what OS you are using this is easy. On Windows you can press win + r, then type cmd. This will open up a command prompt. Then, type in pip install matplotlib. This will make sure that your module is installed. Then, navigate to the folder which your code is located in. You can do this by typing in cd Documents if you first need to get to your documents and then for each subsequent folder. \nThen, try typing in python and hitting enter. If a python shell opens up then type quit() and then type python filename.py and it will run.\nIf no python shell opens up then you need to change your environment variables. Press the windows key and pause break at the same time, then click on Advanced system settings. Then press Environment Variables. Then double click on Path. Then press New. Then locate the installation folder of you Python install, which may be in  C:\\Users\\YOURUSERNAME\\AppData\\Local\\Programs\\Python\\Python36 Now put in the path and press ok. You should now be able to run python from your command line.","Q_Score":3,"Tags":"python,sublimetext3","A_Id":57038467,"CreationDate":"2019-07-15T10:55:00.000","Title":"[How to run code by using cmd from sublime text 3 ]","Data 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 raspberry pi, i need to run two motors with a L298N.\nI can pwm on enable pins to change speeds. But i saw that gpiozero robot library can make things a lot easier. But \nWhen using gpiozero robot library, how can i alter speeds of those motors by giving signel to the enable pins.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":503,"Q_Id":57038494,"Users Score":1,"Answer":"I have exactly the same situation.  You can of course program the motors separately but it is nice to use the robot class.\nLooking into the gpiocode for this, I find that in our case the left and right tuples have a third parameter which is the pin for PWM motor speed control. (GPIO Pins  12 13 18 19 have hardware PWM support).  The first two outout pins in the tuple are to be signalled as 1, 0 for forward, 0,1 for back. \nSo here is my line of code:\n    Initio = Robot(left=(4, 5, 12), right=(17, 18, 13))\nHope it works for you!\nI have some interesting code on the stocks for controlling the robot's absolute position, so it can explore its environment.","Q_Score":1,"Tags":"python-3.x,raspberry-pi2,robotics,gpiozero","A_Id":59144212,"CreationDate":"2019-07-15T11:09:00.000","Title":"how can I use gpiozero robot library to change speeds of motors via L298N","Data Science and Machine Learning":0,"Database and SQL":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 contains a plain text password used to bind Mac to AD.\nI need to deploy this script to few Macs.\nHow can I secure password which is in plain text, so that no one can see the password?\nI don't want to use base64, I'd need something stronger than base64.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1177,"Q_Id":57039385,"Users Score":-1,"Answer":"Try storing the password in a variable in a separate Python script. \npass.py\npassword = 'PASSWORD'\nImport the variable from this script separately.\nmain.py\nfrom pass import password\nThis will create a bytecode file named pass.pyc. Now you can delete pass.py and continue using pass.pyc, which isn't human-readable and much harder to decompile.\nEdit: If somebody has access to your source code, they can still see the password with a print statement!\nEdit 2: As Giacomo Alzetta commented, the password is still human-readable here, but it comes down to the \"attack model\" here. If someone really wants to, they can still dig around and find it. Other alternatives are encryption algorithms available in OpenSSL. Symmetric key algorithms might still not be useful for you since you'd probably have to store the encryption key within the source code. Asymmetric key algorithms might work.","Q_Score":1,"Tags":"python,macos","A_Id":57039581,"CreationDate":"2019-07-15T12:04:00.000","Title":"How to secure plain text Password in 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to set up the API part of an application. \nTo summarize, there is a private oauth provider, a front-end angular app, and a django rest framework resource API. \nThe Angular app is unaccessible if not logged, and redirect to the oauth provider. The user have to login there and is redirected to the front-end. \nSo far so good, the provider give the front-end a JWT access token. \nThen the front ask for resources to the DRF API providing the JWT. \nThat's where I'm stuck, all the tutorials I find on google explain how to create your own provider. \nBut I just want to get the token, check with the oauth provider that it's valid, login the user, provide the resources, and then logout the user until the next request.\nIf someone can give me some usefull tuto\/doc\/library? \nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":160,"Q_Id":57040718,"Users Score":1,"Answer":"So, I ended up creating my own custom authentication class extending BaseAuthentication (and custom user, user manager, ...) as I did not found any existing library. \nIf someone in interested in details, you can check the DRF documentation and many resources on the internet.\nP.S. don't forget to extend authenticate_header is you want to return 401 with \"raise AuthenticationFailed\" and not 403 (for some reason).","Q_Score":0,"Tags":"python,django-rest-framework,jwt,single-sign-on","A_Id":57160148,"CreationDate":"2019-07-15T13:23:00.000","Title":"How to create a JWT DRF consumer, with external provider?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have tried automating Facebook login using Selenium WebDriver. Can I do the same automatic login on Android applications instead of web pages? And if yes, what dependency do I need? Or do I need some sort of API?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":57042809,"Users Score":0,"Answer":"the answer is no selenium dosen't supp mobile app but you can use Appium a good free open source tool.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,selenium,selenium-webdriver","A_Id":57042967,"CreationDate":"2019-07-15T15:23:00.000","Title":"Selenium automatic login can be used on web pages; can it also be used on Android apps?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have tried automating Facebook login using Selenium WebDriver. Can I do the same automatic login on Android applications instead of web pages? And if yes, what dependency do I need? Or do I need some sort of API?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":57042809,"Users Score":0,"Answer":"One option how I do it is to run the android app in an emulator such as Android Studio on Windows, and then use a Windows automation tool like AppRobotic Personal to simulate user actions, allowing me to log in on the android app.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,selenium,selenium-webdriver","A_Id":57043197,"CreationDate":"2019-07-15T15:23:00.000","Title":"Selenium automatic login can be used on web pages; can it also be used on Android apps?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to install the pyPDF2 package on Python 3.6.0. When I open the Command Prompt and type python -m pip install pyPDF2 I receive the following error:\nSuccessfully built pyPDF2\nInstalling collected packages: pyPDF2\n\nERROR: Could not install packages due to an EnvironmentError:\n  [WinError 5] Access is denied: 'C:\\Program\n  Files\\Python36\\Lib\\site-packages\\PyPDF2' Consider using the\n  --user option or check the permissions.\n\nPreviously, I experienced a similar issue with installing the pip library. I had to receive administrative rights from another user before successfully downloading pip.\nI am using Windows 10 OS.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1008,"Q_Id":57044712,"Users Score":1,"Answer":"Open cmd as an administrator to get elevated access and run your Python pip install script again.","Q_Score":0,"Tags":"python,pypdf2,pypdf","A_Id":57044766,"CreationDate":"2019-07-15T17:39:00.000","Title":"How to fix error when downloading pyPDF2 on Python 3.6.0?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a problem given in HackWithInfy2019 in hackerrank.\nI am stuck with this problem since yesterday.\nQuestion:\nYou are given array of N integers.You have to find a pair (i,j) \nwhich maximizes the value of GCD(a[i],a[j])+(j - i)\nand 1<=i< j<=n\nConstraints are:\n2<= N <= 10^5\n1<= a[i] <= 10^5\nI've tried this problem using python","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":57045356,"Users Score":0,"Answer":"Here is one way of doing it.\nCreate a mutable class MinMax for storing the min. and max. index.\nCreate a Map<Integer, MinMax> for storing the min. and max. index for a particular divisor.\nFor each value in a, find all divisors for a[i], and update the map accordingly, such that the MinMax object stores the min. and max. i of the number with that particular divisor.\nWhen done, iterate the map and find the entry with largest result of calculating key + value.max - value.min.\nThe min. and max. values of that entry is your answer.","Q_Score":0,"Tags":"java,c++,python-3.x,python-2.7,greatest-common-divisor","A_Id":57045925,"CreationDate":"2019-07-15T18:30:00.000","Title":"Maximizing GCD with some condition","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have five decision variables, each having a specific range. I need to find a combination of these variables so as to maximize one of my objectives while minimizing the other at the same time. I have prepared a datasheet of randomly generated variables with respective values of the 2 objective functions. Please suggest me how to approach the solution using neural networks. \nMy objective function involves thermodynamic calculations. If interested you can have a look at the objective functions here :","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":244,"Q_Id":57045756,"Users Score":0,"Answer":"There are many methods, but the easiest way is \"linear scalarization\".\nYou can add objectives to make single objective.\nWhile doing this, you can weight objectives considering priority.\n(Making linear combination of multiple objectives)\nSee examples:\nVariational AE loss (regularization loss + reconstruction loss)\nAssociative DA loss (classification loss + walker loss + visit loss)","Q_Score":0,"Tags":"python,matlab,neural-network,artificial-intelligence","A_Id":57048809,"CreationDate":"2019-07-15T19:03:00.000","Title":"How to do multi-objective optimization using neural networks?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to write an importer for populating admin model fields with existing model data:\nThis is my approach:\nI modified the admin view for the specific model and added a form including select boxes to choose the existing model and a button to start the import.\nAs I'm using drf for many other stuff I wrote an endpoint which delivers the model data via get request.\nWhen clicking the button some javascript logic is populating the fields with the given data.\nFor inline models I'm simulating a 'click' to add the necessary rows before filling the fields.\nThis is working as expected. But after clicking the save button, the classic error \n\nplease correct the errors below \n\nappears.\nAfter implementing some logging, I could figure out the actual error message which is related to the the inline model fields.\n\nThe inline value did not match the parent instance.\n\nIs django doing some other \"magic\" I'm missing when filling the inline admin fields?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":57046524,"Users Score":0,"Answer":"OK I solved the problem.\nI accidently set the primary keys (hidden fields) when populating the inline forms with javascript.","Q_Score":0,"Tags":"javascript,python,django","A_Id":57062446,"CreationDate":"2019-07-15T20:08:00.000","Title":"Populating django inline admin fields with javascript","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there a way to print a Page\/Widget\/Label in Kivy? (or some other way in python).\nUnfortunately, I don't know how to ask the question correctly since I am new to software development. \nI want to build a price tracking app for my business in which i will have to print some stuff.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":200,"Q_Id":57046969,"Users Score":2,"Answer":"Not directly, no, but the printing part isn't really Kivy's responsibility - probably you can find another Python module to handle this.\nIn terms of what is printed, you can export an image of any part of the Kivy gui and print that.","Q_Score":4,"Tags":"python,kivy","A_Id":57047007,"CreationDate":"2019-07-15T20:45:00.000","Title":"Does Kivy have laserjet printer support?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a 10K+ line log file that I'm using to debug an issue. I'm looking for 'aberrant' log lines that occur infrequently relative to the other lines in the file to hopefully extract interesting happenings that may be occurring. These log lines are highly variable and diverse.\nMy initial approach was to do a fuzzy comparison of each line against the remaining lines in the file, get an average of those ratios and assign it to each line, sort those ratios and return the smallest N items in that set.\nHowever, this takes a very, very long time on my machine when using Python (I'm using fuzzywuzzy).\nAny alternative suggestions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":57047521,"Users Score":0,"Answer":"Instead of that comparison, make one pass of the file to categorize the lines by their distinctive features.  Store a reference to each line in a dict, keyed by category.\nThen make a pass over the dict, eliminating any keys with too many references (i.e. boring categories).  The remaining categories are the interesting ones.\nThis is an O(N) process, rather than the O(N^2) process with which you started.","Q_Score":0,"Tags":"python,string,algorithm,search,fuzzy-search","A_Id":57047650,"CreationDate":"2019-07-15T21:40:00.000","Title":"Finding least commonly occurring fuzzy 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed pygame through pip. I know for a fact it is there, as I have seen the file labeled 'pygame' in the file explorer. However Python does not agree with me that it is certainly there.\nWhat makes this odd is that i've installed pygame using pip before on a different user, it worked fine, and i did nothing differently this time.\n\n\n\nimport pygame\n      Traceback (most recent call last):\n        File \"\", line 1, in \n          import pygame\n      ModuleNotFoundError: No module named 'pygame'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":57048553,"Users Score":0,"Answer":"Check your virtual environment. It seems that you are not using the environment where you have installed pygame. If you are using Anaconda, the environment is specified in parentheses. You can activate your environment using:\nconda activate <conda environment name here>\nHope this works!","Q_Score":0,"Tags":"python,pip,pygame","A_Id":57048649,"CreationDate":"2019-07-16T00:13:00.000","Title":"Unable To Import Pygame After Pip Install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dictionary output that looks like mydict={'a': {'b': c, 'd': e}} and I would like to only output the value for b to start. In addition I would like to output the value for each key imbedded\nI've tried mydict.'a'.b, mydict.a.b and mydict.b without success","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":57048901,"Users Score":1,"Answer":"Short answer is mydict['a']['b']","Q_Score":0,"Tags":"python,dictionary","A_Id":57048912,"CreationDate":"2019-07-16T01:16:00.000","Title":"How to output the value for a key embedded in a key","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a monthly time series which I want to forecast using Prophet. I also have external regressors which are only available on a quarterly basis. \nI have thought of following possibilities - \n\nrepeat the quarterly values to make it monthly and then include \nlinearly interpolate for the months\n\nWhat other options I can evaluate?\nWhich would be the most sensible thing to do in this situation?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":57053017,"Users Score":0,"Answer":"You have to evaluate based on your business problem, but there are some questions you can ask yourself.\n\nHow are the external regressors making their predictions? Are they trained on completely different data?\n\nIf not, are they worth including?\n\nHow quickly do we expect those regressors to get \"stale\"? How far in the future are their predictions available? How well do they perform more than one quarter into the future?\n\nInterpolation can be reasonable based on these factors...but don't leak information about the future to your model at training time.\n\nDo they relate to subsets of your features?\n\nIf so, some feature engineering could but fun - combine the external regressor's output with your other data in meaningful ways.","Q_Score":0,"Tags":"python,forecasting,facebook-prophet","A_Id":57053491,"CreationDate":"2019-07-16T08:24:00.000","Title":"How to include quarterly regressor in Prophet for monthly time series?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using rpyc server to get data using selenium when a connection to a client is established, the problem is that the url I'm trying to access occasionally prompts a reCaptcha to fill in order to access the data needed.\nI don't really need to find a way to automate a completion, what I do want is to find a way to stream the browser from the server to the client if it encounters a reCaptcha, in a manner that allows the user to interact with the browser, and fill the reCaptcha manually himself, and from there to let the server go on with the rest of his code.\nSomething similar to Teamviewer's functionality, to implement in my setup.\nI actually couldn't find any direction to follow on that subject yet, and couldn't figure out a method to try myself.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":57053912,"Users Score":0,"Answer":"If you work with Selenium, then you have the opportunity to programmatically wait for elements or to detect elements. You could just have your program wait for the ReCaptcha element and make an output to the user in the console that he should solve the ReCaptcha. In the background your program already waits for the elements that appear when the ReCaptcha is solved. Once the user has solved the ReCaptcha, the program will automatically resume.","Q_Score":0,"Tags":"python,recaptcha,rpyc","A_Id":57054034,"CreationDate":"2019-07-16T09:15:00.000","Title":"Is it possible to let the client interact with recaptcha on the server side?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dictionary in python and I need to access that dictionary from a C program? \nor for example, convert this dictionary into struct map in C  \nI don't have any idea how this could be done.\nI will be happy to get some hints regarding that or if there are any libraries that could help.\nUpdate:\nthe dictionary is generated from the abstract syntax tree of C program by using pycparser. \nso, I wrote a python function to generate this dictionary and I can dump it using pickle or save it as a text file.\nNow I want to use keys and their values from a c program and I don't know how to access that dictionary.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":90,"Q_Id":57055940,"Users Score":1,"Answer":"You could export the dictionary to a JSON and parse the JSON file from C...","Q_Score":0,"Tags":"python,c,dictionary,struct,abstract-syntax-tree","A_Id":57056007,"CreationDate":"2019-07-16T11:12:00.000","Title":"How to access python dictionary from C?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my Flask application, I have one html file that holds some html and some js that semantically belongs together and cannot be used separately in a sensible way. I include this file in 2 of my html templates by using Jinja's {%include ... %}.\nNow my first approach was to put this file in my templates folder. However, I never call render_template on this file, so it seems unapt to store it in that directory. \nAnother approach would be to put it into the static folder, since its content is indeed static. But then I don't know how to tell Jinja to look for it in a different directory, since all the files using Jinja are in the templates folder.\nIs there a way to accomplish this with Jinja, or is there a better approach altogether?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":216,"Q_Id":57057614,"Users Score":1,"Answer":"You're over-thinking this. If it's included by Jinja, then it's a template file and belongs in the templates directory.","Q_Score":1,"Tags":"python,html,flask,jinja2","A_Id":57057757,"CreationDate":"2019-07-16T12:46:00.000","Title":"Flask non-template HTML files included by Jinja","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"my GPU is NVIDIA RTX 2080 TI\nKeras 2.2.4\nTensorflow-gpu 1.12.0\nCUDA 10.0\nOnce I load build a model ( before compilation ), I found that GPU memory is fully allocated\n[0] GeForce RTX 2080 Ti | 50'C,  15 % | 10759 \/ 10989 MB | issd\/8067(10749M)\nWhat could be the reason, how can i debug it?\nI don't have spare memory to load the data even if I load via generators\nI have tried to monitor the GPUs memory usage found out it is full just after building the layers (before compiling model)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":502,"Q_Id":57058071,"Users Score":0,"Answer":"I meet a similar problem when I load pre-trained ResNet50. The GPU memory usage just surges to 11GB while ResNet50 usually only consumes less than 150MB.\nThe problem in my case is that I also import PyTorch without actually used it in my code. After commented it, everything works fine.\nBut I have another PC with the same code that works just fine. So I uninstall and reinstall the Tensorflow and PyTorch with the correct version. Then everything works fine even if I import PyTorch.","Q_Score":0,"Tags":"python-3.x,tensorflow,keras","A_Id":67595461,"CreationDate":"2019-07-16T13:11:00.000","Title":"Keras, Tensorflow are reserving all GPU memory on model build","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been going through source code of python. It looks like every object is derived from PyObject. But, in C, there is no concept of object oriented programming. So, how exactly is this implemented without inheritance?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":86,"Q_Id":57058653,"Users Score":2,"Answer":"What makes the Object Oriented programming paradigm is the relation between \"classes\" as templates for a data set and functions that will operate on this data set. And, the inheritance mechanism which is a relation from a class to ancestor classes. \nThese relations, however, do not depend on a particular language Syntax - just that they are present in anyway. \nSo, nothing stops one from doing \"object orientation\" in C, and in fact, organized libraries, even without an OO framework, end up with an organization related to OO.\nIt happens that the Python object system is entirely defined in pure C, with objects having a  __class__ slot that points to its class with a C pointer - only when \"viwed\" from Python the full represenation of the class is resented. Classes in their turn having a __mro__ and __bases__ slots that point to the different arrangements of superclasses (the pointers this time are for containers that will be seen from Python as sequences).\nSo, when coding in C using the definitions and API of the Python runtime, one can use OOP just in the same way as coding in Python - and in fact use Python objects that are interoperable with the Python language. (The cython project will even transpile a superset of the Python language to C and provide transparent ways f writing native code with Python syntax)\nThere are other frameworks available to C that provide different OOP systems, that are equaly conformant, for example, glib - which defines \"gobject\" and is the base for all GTK+ and GNOME applications.","Q_Score":1,"Tags":"python","A_Id":57059180,"CreationDate":"2019-07-16T13:41:00.000","Title":"how is every object related to pyObject when c does not have Inheritance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for the most efficient way to compare two strings, and I'm not sure which is better: == or in. Or is there some other way to do it that is more efficient that either of these?\nEdit: I'm trying to check for equality","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":307,"Q_Id":57059515,"Users Score":0,"Answer":"== in Python is there for comparison purpose, while \"in\" has a wider definition (contains which includes comparison). Generally, precise and clear purpose constructs are the most optimized ones for doing the targeted job, because indirect constructs are generally based on simple and direct constructs, which should make == better in comparison context and less error-prone.","Q_Score":1,"Tags":"python,python-3.x,performance","A_Id":57059788,"CreationDate":"2019-07-16T14:23:00.000","Title":"What is the most efficient way of comparring 2 strings in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for the most efficient way to compare two strings, and I'm not sure which is better: == or in. Or is there some other way to do it that is more efficient that either of these?\nEdit: I'm trying to check for equality","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":307,"Q_Id":57059515,"Users Score":0,"Answer":"Please define \"comparing\".\nIf you want to know if 2 strings are equal, == is the simplest way.\nIf you want to know if 1 string contains another, in is the simplest way.\nIf you want to know how much they overlap, considering gaps, you need complicated algorithms. How about a thick book on algorithms? (This is similar to comparing genetic sequences. I think a book on Bioinformatics algorithms would be very useful too. Anyhow, this case is way too complicated for Stack Overflow.)\nEDIT:\nFor equality stick with \"==\". It's in Python to do its job.","Q_Score":1,"Tags":"python,python-3.x,performance","A_Id":57059609,"CreationDate":"2019-07-16T14:23:00.000","Title":"What is the most efficient way of comparring 2 strings in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing a project that consists of an RPi and an ESP8266. My RPi acts as the broker. I send data from my ESP to RPi through MQTT by subscribing. When I don't subscribe and run my code the data is lost until the point I subscribe. Is there a way to save the data values in the RPi as a file and when I subscribe, the previous data isn't lost as it is saved?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":57059553,"Users Score":0,"Answer":"There needs to be a subscriber for the broker to not discard messages. If you want to keep all of them, you will need to have a subscriber that records messages and can play them back later or otherwise allow you to process the data.","Q_Score":0,"Tags":"python,mqtt","A_Id":57059943,"CreationDate":"2019-07-16T14:25:00.000","Title":"How to save data values without subscribing through 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":"I am trying to use Python in VS Code. I cannot select Python Environment unless i ran VS Code as administrator. Is there a setting within VS Code that allows to set environment for regular user?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":199,"Q_Id":57061114,"Users Score":0,"Answer":"I've found the best way around this is to use the iPython extension. This extension for VS code is really great for using python commands in vs code without any environment problems.","Q_Score":1,"Tags":"python-3.x,visual-studio-code,vscode-settings","A_Id":68823427,"CreationDate":"2019-07-16T15:48:00.000","Title":"VS Code Python Environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing a project using Python with MPI. Every node of my project needs to know if there is any incoming message for it before continuing the execution of other tasks. \nI'm working on a system where multiple nodes executes some operations. Some nodes may need the outputs of another nodes and therefore needs to know if this output is available.\nFor illustration purposes, let's consider two nodes, A and B. A needs the output of B to execute it's task, but if the output is not available A needs to do some other tasks and then verify if B has send it's output again, in a loop. What I want to do is this verification of availability of output from B in A.\nI made some research and found something about a method called probe, but don't understood neither found a usefull documentation about what it does or how to use. So, I don't know if it solves my problem.\nThe idea of what I want is ver simple: I just need to check if there is data to be received when I use the method \"recv\" of mpi4py. If there is something the code do some tasks, if there ins't the code do some other taks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":335,"Q_Id":57061178,"Users Score":1,"Answer":"(elaborating on Gilles Gouaillardet's comment)\nIf you know you will eventually receive a message, but want to be able to run some computations while it is being prepared and sent, you want to use non-blocking receives, not probe.\nBasically use MPI_Irecv to setup a receive request as soon as possible. If you want to know whether the message is ready yet, use MPI_Test to check the request.\nThis is much better than using probes, because you ensure that a receive buffer is ready as early as possible and the sender is not blocked, waiting for the receiver to see that there is a message and post the receive.\nFor the specific implementation you will have to consult the manual of the Python MPI wrapper you use. You might also find helpful information in the MPI standard itself.","Q_Score":0,"Tags":"python,mpi","A_Id":57077576,"CreationDate":"2019-07-16T15:52:00.000","Title":"How can I verify if there is an incoming message to my node with MPI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python virtual environments. While trying to remove a virtual enviroment i accidently removed the Pipfile and Pipfile.lock first before using pipenv --rm to remove the virtual environment. Is it safe to remove the corresponding directory in ~\/.local\/share\/virtualenvs. \nI am using Ubuntu 18.04 LTS. Thanks !!!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":124,"Q_Id":57061682,"Users Score":1,"Answer":"Usually a Python virtual environment corresponds to a folder named as the environment. So, you could simply delete the folder containing the environment.","Q_Score":0,"Tags":"python,pipenv","A_Id":57061814,"CreationDate":"2019-07-16T16:23:00.000","Title":"Clean removal of Python virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"New to pandas - I have been trying to use the pandas.merge_asof to join two datasets together by shared ID first, then merge by nearest timestamp to the timestamp in df1. \nThe issue is that I have discovered is that both left_on and right_on must be int. I have one column that contains NaNs and they must remain. Floats was also ineffective. From my research on Stackoverflow, I found out that the latest version of Pandas, 24.02 has this functionality where you simply convert the column to Int64. However, the version of pandas I have available at work is 23.xx and cannot be upgraded at this time. \nWhat is my easiest option? If I were to simply remove the rows associated with the NaNs values in the one column, could I simply add them back later, and then change the dtype back from int to object? Would this disrupt anything?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":486,"Q_Id":57064741,"Users Score":0,"Answer":"I did two methods:\n1) I set the Nan's to -1. (there was no id that had -1 in the other dataset). Then put them back to Nan after.\n2) I removed the records associated with the Nan's for that column, and put the records back in after.\nI tried to compare results (and reset the indices, sort by timestamp), but I kept getting false. Both should give the same result regardless.","Q_Score":0,"Tags":"python,pandas,merge","A_Id":57084810,"CreationDate":"2019-07-16T20:08:00.000","Title":"Using pandas.merge_asof when one merge column contains NaNs","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As far as I understand from Rasa 1 onwards there is mainly the \"actions\" that needs to be run over terminal and then the Rasa shell or interactive, etc. \nHow do you run this using PyCharm?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1462,"Q_Id":57065834,"Users Score":0,"Answer":"Please follow this sequence, if you want to debug in PyCharm:\n\nMake sure that your actions endpoint server is running in one of the terminals.\nAttach the process using Run -> Attach to Process...\nMake sure that your actions class has required breakpoints\nMake sure that your action class in triggered when you chat\n\nYou will be able to debug as usual when the breakpoint is hit.","Q_Score":1,"Tags":"python-3.x,pycharm,rasa-nlu,rasa-core,rasa","A_Id":57495262,"CreationDate":"2019-07-16T21:43:00.000","Title":"Running Rasa project in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I trained a model on size 512x512 images. I currently have size 982x982 (or any other size) images that I need to have the model predict on. When I run on these images, I get errors about unexpected input array shape.\nDoes Tensorflow provide any way to conveniently deploy a model on images of size\/shape larger than what the model was trained on?\nMore Details:\nSpecifically, this is a model used for image segmentation.\nI assume one workaround to the issue is creating my own sliding-window script that, instead, inputs into the model windows of the expected size taken at different intervals from the original image, and then somehow pasting all those output windows back into a single image after they have gone through the model. However, I want to know if there is a more standard approach.\nI am brand new to Tensorflow (and image segmentation) so it is very possible I just missed something, or that perhaps my question is unclear.\nThank you for any advice :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":234,"Q_Id":57066263,"Users Score":0,"Answer":"I once have the same question about how to deal with larger or smaller images. According to my experience, a possible method is to resize images to the input size of the network. For example, if your current image size is 982x982 and the network input size is 512x512, then you can just use some libraries like Pillow or OpenCV to resize the original image from 982x982 to 512x512.\nYour method is a possible solution. I would say that there are many possible solutions other than the resizing operation, but you should better try this simplest method to see if your network works well. What I have learned from my projects is that we can always try the simplest solution, and in most cases, it works perfectly.\nGenerally speaking, there is not a general perfect way to do it. You can start with the simplest method, and find a more complicated one if it does not work.","Q_Score":0,"Tags":"python,python-2.7,tensorflow","A_Id":57066365,"CreationDate":"2019-07-16T22:30:00.000","Title":"How to apply trained model on images of shape\/size larger than what the model was trained on (in Tensorflow)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that is called from a java program \nThe java program feeds data to the python script sys.stdin and the java program receives data from the python process outputstream . \nWhat is know is this .\nrunning the command  'python script.py' from the java program on 10MB of data takes about 35 seconds.\nHowever running the commands  'python script.py > temp.data ' and then  cat temp.data  is  significantly faster. \nThe order of magnitude of performance is even more drastic as the data gets larger.\nIn order to address this , I am thinking maybe there is a way to change the sys.stdout to mimic what I am doing.\nOr maybe I can pipe the python script output to a virtual file .\nAny recommendations ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":169,"Q_Id":57067260,"Users Score":0,"Answer":"This is probably a buffering problem when you have the Java program writing to one filehandle and reading from another filehandle. The order of those in the Java and the size of the writes is suboptimal and it's slowing itself down.\nI would try \"python -u script.py\" to see what it does when you ask python to unbuffer, which should be slower but might trick your calling program into racing a different way, perhaps faster.\nThe larger fix, I think, is to batch your code, as you are testing with, and read the resulting file, or to use posix select() or filehandle events to handle how your java times its writes and reads.","Q_Score":0,"Tags":"python,bash,sys","A_Id":57068701,"CreationDate":"2019-07-17T01:13:00.000","Title":"receiving data from java program that calls python script is too 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":"I've been using pip to install packages directly to my root directory, but I read recently that using a virtual environment like conda or virtualenv is better practice. If I start using conda now, should I uninstall my pip-installed packages? I use python for a variety of applications, including machine learning with both Keras and Pytorch.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":57067900,"Users Score":0,"Answer":"Generally the version that is installed using the conda environment is used by your code. However, in certain situations different version of the package installed using pip and conda can lead to conflicts.\nA recommended way is to have a fresh install of the package using conda.","Q_Score":2,"Tags":"python,python-3.x,pip,conda","A_Id":57068274,"CreationDate":"2019-07-17T02:50:00.000","Title":"If I start using conda as my python package manager, should I uninstall previously installed packages from pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having more than 100 String Columns which I need to be converting into enum so that the ML model identifies theses columns as categories. \nIn Pyspark, there is no Category type (as in Pandas) and hence I casted all categories as 'String'. I don't want to click 'convert to enum' > 100 times and I'm sure there is an easier way to perform this task. Any help would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":228,"Q_Id":57068435,"Users Score":0,"Answer":"I was not able to find a coding solution. But found an easier way - saved the pyspark df as a parquet in hdfs and imported it into h2o. All string columns were auto-recognised as Enum.","Q_Score":0,"Tags":"python,pyspark,h2o","A_Id":57085156,"CreationDate":"2019-07-17T04:15:00.000","Title":"Converting multiple string columns to enum in H2o Flow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm aware this is rather opinionated topic but I need to ask just to fill\nany knowledge gaps I may have. I'm using Python 3.6.8 knowing there's supposedly\n\"better\" performing Python 3.7\nPython 3.7 introduced data classes and breakpoints that you no longer have to\nimport to use it for debugging but it is rather a built-in function now.\nMy question is if I don't necessarily use the features of 3.7 am I making myself\ndisadvantaged in any way by not using 3.7 and sticking with 3.6.x ? As of now I don't really feel compelled to install 3.7 unless I have good reason for doing so.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":14825,"Q_Id":57073418,"Users Score":2,"Answer":"I guess it can be answered generally, answer would be the same as if you were asking about 3.7 to 3.8 and so forth.\nOlder versions: more stable, we know what to expect, but \"rot\" as after some time support will drop either in development or at where you deploy it (say a PaaS service). Then you will be forced to upgrade and will need to stop what you are doing in order to fix - migrate is a better word - your application.\nNewer versions: have new features. Specially for DataClasses in 3.7's case, initially did not feel the need to use them initially but they paid up the time upgrading from 3.6 to 3.7 a lot. Newer versions on the wrong side almost always introduce bugs.\nGeneral advice: upgrade if a bit later once new version has been released and do those small changes sooner rather than later. Specially for the Python programming language see what happened with projects stuck into 2.x version.","Q_Score":3,"Tags":"python-3.x","A_Id":58819750,"CreationDate":"2019-07-17T10:07:00.000","Title":"Python 3.6 vs 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Keras on Python to train a CNN autoencoder. In the fit() method I have to provide validation_split or validation_data. First, I would like to use  80% of my data as training data and 20% as validation data (random split). As soon as I have found the best parameters, I would like to train the autoencoder on all the data, i.e. no more using a validation set.\nIs it possible to train a Keras model without using a validation set, i.e. using all data to train?\nMoreover, the pixels in my images are all in the range [0, -0.04]. Is it still recommended to normalize the values of all pixels in all images in the training and validation set to the range [0,1] or to [-1,1] or to standardize it (zero mean, unit variance)? If so, which method is prefered? By the way, my images are actually 2D heat maps (one color channel).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3996,"Q_Id":57075037,"Users Score":2,"Answer":"Yes, you can train a keras model without validation data, but its not a good practice, because then you would not know if the model can generalize or not. The same applies for autoencoders, they can overfit to the training set.\nIt is always recommended to normalize your inputs, specially if the ranges are large or small. There is no preferred method, any normalization generally works the same.","Q_Score":0,"Tags":"python,keras,conv-neural-network,keras-2,standardized","A_Id":57077151,"CreationDate":"2019-07-17T11:43:00.000","Title":"Training Keras model without validation set and normalization of images","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to reference a virtual env\/ python that has been uploaded to a cloud storage bucket in GCP? I have a ubuntu docker image with all the proper credentials and service account set up within the image\nI'm able to use gsutil commands, however, when I try to export my PYSPARK_PYTHON variable, I get the ' No such file or directory ' error\nexport PYSPARK_PYTHON=gs:\/\/[bucket]\/deps\/env\/bin\/python3\npyspark \nenv: \u2018gs:\/\/[bucket]\/deps\/env\/bin\/python3\u2019: No such file or directory\nIf I run: \ngsutil ls gs:\/\/[bucket]\/deps\/env\/bin\/python3 \nI'm able to see the file\nI expect pyspark to work using the python dependencies and libraries within that bucket. Is this possible at all?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":232,"Q_Id":57076581,"Users Score":2,"Answer":"PYSPARK_PYTHON expects an executable python executable.\nFiles stored in object storage buckets cannot be directly executed.\nMake sure that the python executable is accessible as a file from within your image \/ some mount point.","Q_Score":0,"Tags":"python,python-3.x,google-cloud-platform,pyspark,google-cloud-storage","A_Id":57076979,"CreationDate":"2019-07-17T13:06:00.000","Title":"Reference Python virtual environment in a cloud storage bucket","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to run Kafka producer \/ consumer and connect them to the Broker using VS Code.\n1- I have already run a Kafka Broker with the docker-compose, with an active Kafka container. \nHow can I use the Kafka container without installing it locally ?\nI have installed the kafka library on my local machine, and everything worked perfectly.. \nExpected: Using the Kafka container instead of the local lib.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":57077110,"Users Score":0,"Answer":"I'm answering this with the assumption that when you say you machine, you're referring to your local machine (I would comment directly on your question ask for clarification, but I don't have enough rep yet). Installing a library locally allows for it to work locally, but not in other environments. So you need to install the Kafka library within the environment you're targeting, too.","Q_Score":0,"Tags":"python,docker,apache-kafka,docker-compose","A_Id":57077312,"CreationDate":"2019-07-17T13:31:00.000","Title":"How Can I Run the python programs on Docker using active containers with the VS Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to run Kafka producer \/ consumer and connect them to the Broker using VS Code.\n1- I have already run a Kafka Broker with the docker-compose, with an active Kafka container. \nHow can I use the Kafka container without installing it locally ?\nI have installed the kafka library on my local machine, and everything worked perfectly.. \nExpected: Using the Kafka container instead of the local lib.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":57077110,"Users Score":0,"Answer":"How can I use the Kafka container without installing it locally ? \n\nNot clear what \"it\" is... The Docker image? That's not how Docker works. \nYou need to install pull the Docker image locally in order to use it\n\nI have installed the kafka library on my local machine\n\nI assume that you mean something downloaded from kafka.apache.org? If that's the case, no, you don't need that for Python\nYou will instead have to pip install some Kafka Python package and write code to communicate to the Kafka container","Q_Score":0,"Tags":"python,docker,apache-kafka,docker-compose","A_Id":60638597,"CreationDate":"2019-07-17T13:31:00.000","Title":"How Can I Run the python programs on Docker using active containers with the VS Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a pivot table in excel that I want to read the raw data from that table into python. Is it possible to do this? I do not see anything in the documentation on it or on Stack Overflow.\nIf the community could be provided some examples on how to read the raw data that drives pivot tables, this could greatly assist in routine analytical tasks.\nEDIT: \nIn this scenario there are no raw data tabs. I want to know how to ping the pivot table get the raw data and read it into python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":888,"Q_Id":57078501,"Users Score":0,"Answer":"First, recreate raw data from the pivot table. The pivot table has full information to rebuild the raw data.\n\nMake sure that none of the items in the pivot table fields are hidden -- clear all the filters and Slicers that have been applied.\nThe pivot table does not need to contain all the fields -- just make sure that there is at least one field in the Values area.\nShow the grand totals for rows and columns. If the totals aren't visible, select a cell in the pivot table, and on the Ribbon, under PivotTable Tools, click the Analyze tab. In the Layout group, click Grand totals, then click On for Rows and Columns.\nDouble-click the grand total cell at the bottom right of the pivot table. This should create a new sheet with the related records from the original source data.\n\nThen, you could read the raw data from the source.","Q_Score":5,"Tags":"python,excel,pandas,pivot-table","A_Id":71120859,"CreationDate":"2019-07-17T14:40:00.000","Title":"Getting the Raw Data Out of an Excel Pivot Table in Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After running pip install pymupdf in my conda environment, i get an error when trying to import fitz \nModuleNotFoundError: No module named 'fitz'\nInside my terminal i ran pip list | grep PyMuPDF to verify installation and it returns PyMuPDF 1.14.17, so im lost as to what the issue is. \nAny help on getting this working would be really appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1515,"Q_Id":57080053,"Users Score":0,"Answer":"pls use pip install --upgrade pymupdf\nI have the same problem and after used this, my problem solve","Q_Score":0,"Tags":"python,pymupdf","A_Id":57080466,"CreationDate":"2019-07-17T16:00:00.000","Title":"Unable to install PyMuPDF on Mac 10.14.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using Red Hat, apache 2.4.6, worker mpm, mod_wsgi 4.6.5, and Python 3.7 When I start httpd I get the above error and: \nModuleNotFoundError: No module named 'encodings'\nIn the httpd error_log.\nI'm using a python virtual environment created from a python installed from source under my home directory. I installed mod_wsgi from source using --with-python= option pointing to the python binary in my virtual environment, then I copied the mod_wsgi.so file into my apache modules directory as mod_wsgi37.so\nI ran ldd on this file, and have a .conf file loading it into httpd like this:\nLoadFile \/home\/myUser\/pythonbuild\/lib\/libpython3.7m.so.1.0\n LoadModule wsgi_module modules\/mod_wsgi37.so\nThen within my VirtualHost I have:\nWSGIDaemonProcess wsgi group=www threads=12 processes=2 python-path=\/var\/\n    www\/wsgi-scripts python-home=\/var\/www\/wsgi-scripts\/wsgi_env3\nWSGIProcessGroup wsgi\nWSGIScriptAlias \/test \/var\/www\/wsgi-scripts\/test.py\n\nfrom my virtual environment:\nsys.prefix:'\/var\/www\/wsgi-scripts\/wsgi_env3'\nsys.real_prefix:'\/home\/myUser\/pythonbuild'\nWhen I switch to the system-installed mod_wsgi\/python combo (remove python-home line from WSGIDaemonProcess, and change the .conf file to load the original mod_wsgi.so) it works fine. It seems like some path variables aren't getting set properly. Is there another way to set variables like PYTHONHOME that I'm missing? How can I fix my install?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2265,"Q_Id":57082540,"Users Score":1,"Answer":"I had a very similar issue and I found that my manually specified LoadModule wsgi_module \"\/path_to_conda\/\" was being ignored because the previously apache-wide wsgi mod was being loaded. You can check if wsgi.* is present in \/etc\/apache2\/mods-enabled.\nIf that is the case, consider a2dismod wsgi to disable the apache wsgi that loads the wrong python.","Q_Score":2,"Tags":"python,apache,redhat,wsgi","A_Id":68673425,"CreationDate":"2019-07-17T18:56:00.000","Title":"mod_wsgi - Fatal Python error: initfsencoding: unable to load the file system codec","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":"Everytime I try to display a complete DataFrame in my jupyter notebook, the note book crashes. The file wont start up so I had to make a new jupyter notebook file. When i do display(df) it only shows a couple of the rows, when I need to show 57623 rows. I need to show results for all of these rows and put them into an html file.\nI tried setting the max rows and max columns, but the entire dataframe would not print out without the notebook crashing\n''' python\npd.set_option('display.max_columns', 24)\n    \"pd.set_option('display.max_rows', 57623)\n'''\nThe expected results were for the entire DataFrame to print out, but instead the notebook would have an hourglass next to it and nothing would load.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":534,"Q_Id":57083727,"Users Score":1,"Answer":"I think your machine is not powerful enough to handle so much data. I can display 57623 rows for my data (with 16 columns) without any problem. But my machine has 252GB memory, and it still took about 1 minute to display these data in jupyter notebook. \nIf I tried to scroll through the data, it's slow, and sometimes stuck for a while.\nOn the other hand, what do you want to achieve by displaying all data here? There's definitely another way to achieve the same thing as you are doing now.","Q_Score":0,"Tags":"python,pandas,numpy","A_Id":57209941,"CreationDate":"2019-07-17T20:35:00.000","Title":"How to display a DataFrame without Jupyter Notebook crashing?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to convert using strptime and for the life of me cannot figure this out\n'07-17-2019 23:39 PM GMT-4' does not match format '%m-%d-%y %H:%M %p %z'\nThank you for any help","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":57085542,"Users Score":1,"Answer":"So far I've found that %y should be %Y. The best way to approach this is to test it a bit at a time. Like starting with datetime.strptime('07-17-2019', '%m-%d-%Y'). There's also something wrong with the GMT-4. %z will match -0400 fine, and %Z will match UTC, EST, and others, which might be better than an offset if you want to include daylight savings time, but it looks like that's all you get with strptime.\ndateutil.parser.parse might provide you with more options and flexibility.","Q_Score":0,"Tags":"python,datetime,strptime","A_Id":57085616,"CreationDate":"2019-07-18T00:23:00.000","Title":"Trouble converting to datetime object","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Google Colab to train an object detection model, using the tensorflow object detection api. When I run the cell train.py, it keeps printing diegnostic output. After 30 minutes or so the browser crashes, because of the high number of lines printed in the cell's output.\nIs there any script which one can use to clear the output periodically (say every 30 min) instead of manually pressing the clear output button?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8171,"Q_Id":57086398,"Users Score":0,"Answer":"This is a partial solution, but you could also specify your verbose parameter in your fit method to 0 to get no output, or to 2 to get a reduced output.\nAnd you can use TensorBoard to still see what is going on.","Q_Score":3,"Tags":"python,tensorflow,google-colaboratory,object-detection-api","A_Id":62209904,"CreationDate":"2019-07-18T02:38:00.000","Title":"How do you clear Google Colab's output periodically","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have this model written by the subclassing API, the call signature looks like call(x, training), where training argument is needed to differentiate between training and non-training when doing batchnorm and dropout. How do I make the model forward pass know I am in training mode or eval mode when I use model.fit?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1713,"Q_Id":57088786,"Users Score":0,"Answer":"As far as i know, there is no argument  for this. Model.fit simply trains the model on whatever training data provided, and at the end of each epoch evaluates the training on either provided validation data, OR by the use of validation_split.","Q_Score":3,"Tags":"python,tensorflow,keras","A_Id":57088849,"CreationDate":"2019-07-18T07:01:00.000","Title":"how to pass in 'training' argument to tf,keras.Model when using model.fit","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running Ubuntu on Windows (I can't change it). I use Sublime Test 3 as my code editor. I have Python installed on Ubuntu and I know the path to it from within Windows. Sublime's Python interpreter is not working when I run it. I would like to be able to do both of the following:\na) Run basic Python commands in Sublime Text 3 on Windows using Python installed in Ubuntu folders\nb) Run Python modules in Sublime Text 3 on Windows using modules installed in Ubuntu folders\nI have already tried adding the path to Python's Ubuntu folders to the PATH environment variable (for user, not for system). I didn't work. \nThen I installed Anaconda Python distribution on Windows, and added its path to the PATH variable (for user again). It did work. However, it means having to maintain two Pythons - one on Windows and one on Ubuntu, which defeats the purpose of my search. Also, I only managed to make it work for basic Python, and not for libraries. Adding PYTHONPATH variable with the path to Anaconda's modules on Windows broke the import of numpy and other libraries.\nJust to clarify, I do not use Anaconda distribution, I was just trying all I could.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":57090203,"Users Score":0,"Answer":"Do you need your Sublime3 in Windows?\nYou can install it in your Ubuntu OS instead.","Q_Score":0,"Tags":"python,windows,ubuntu,sublimetext3","A_Id":57090733,"CreationDate":"2019-07-18T08:28:00.000","Title":"How to make Sublime's python interpreter work when Sublime's on Windows and Python is on Ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I used pyautogui and PIL to capture screenshot after clicking on battery icon. But the screenshot doesn't contain battery status window. When I use print-screen key, status window is available in the screenshot. Need suggestions to solve this.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":51,"Q_Id":57092057,"Users Score":2,"Answer":"You can use greenshot opensource tool for windows, using hotkey you can take almost anything as a screenshot.","Q_Score":0,"Tags":"python,python-3.x,robotframework","A_Id":57104608,"CreationDate":"2019-07-18T10:07:00.000","Title":"How to take a screenshot in windows 10 when there is an extra pop up on desktop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used pyautogui and PIL to capture screenshot after clicking on battery icon. But the screenshot doesn't contain battery status window. When I use print-screen key, status window is available in the screenshot. Need suggestions to solve this.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":57092057,"Users Score":0,"Answer":"I think PrintScreen is best for taking screenshots on windows 10. But if you want to use any third-party apps for taking screenshots then pick-pick is a free and good app. It also allows you to take a fullscreen screenshot.","Q_Score":0,"Tags":"python,python-3.x,robotframework","A_Id":69063851,"CreationDate":"2019-07-18T10:07:00.000","Title":"How to take a screenshot in windows 10 when there is an extra pop up on desktop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have created a model for classification of two types of shoes \nnow how to deploy it in OpenCv (videoObject detection)??\nthanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5883,"Q_Id":57093345,"Users Score":0,"Answer":"You would save the model to H5 file model.save(\"modelname.h5\") , then load it in OpenCV code load_model(\"modelname.h5\"). Then in a loop detect the objects you find via model.predict(ImageROI)","Q_Score":6,"Tags":"python,opencv,keras","A_Id":57093852,"CreationDate":"2019-07-18T11:24:00.000","Title":"how to add custom Keras model in OpenCv in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know I can use testzip or just try to uncompress the file and catch the exception.\nMy issue is that I might have .msg files which have attachments that are zipfiles.\nIn that case the ZipFile will just skip over the first few bytes, open the attached zip file and not raise an exception.\nThe only way I can come up with this is manually opening the file and check the first two bytes to see if it's PK, but I'd just like to have a more \"strict\" check.\nIs this possible with either ZipFile or another library?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":205,"Q_Id":57095466,"Users Score":2,"Answer":"What is \"actually a zipfile\" for you?\nA file marked as such with PK?\nA valid \"header\" at the end of the file?\nThere are files in the wild that work as PE executable, ZIP, and PDF at the same time.\nThe most strict you can get would probably both the PK and reading the header. You already answered your own question.","Q_Score":1,"Tags":"python,python-zipfile","A_Id":57095530,"CreationDate":"2019-07-18T13:18:00.000","Title":"Check if file is actually a zipfile","Data 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 was looking at a few tutorials about plotting inline with jupyter notebook and they all say to use the %matplotlib inline, but when I run code normally from my notebook and call plot.show() the chart shows automatically without using magic. I'm am running jupyter from the anaconda package so not sure if that makes a difference. \nIs it still necessary to use the inline magic for matplotlib?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":57096512,"Users Score":0,"Answer":"The point of that particular magic is to avoid the need for plt.show(), and show the plot directly on plt.plot(...). \nIf you don't mind using .show(), you don't need %matplotlib inline. I think it's more convenient to use it.","Q_Score":1,"Tags":"python,matplotlib,jupyter,inline","A_Id":57096611,"CreationDate":"2019-07-18T14:09:00.000","Title":"Question regarding jupyter notebook inline magic","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was looking at a few tutorials about plotting inline with jupyter notebook and they all say to use the %matplotlib inline, but when I run code normally from my notebook and call plot.show() the chart shows automatically without using magic. I'm am running jupyter from the anaconda package so not sure if that makes a difference. \nIs it still necessary to use the inline magic for matplotlib?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":57096512,"Users Score":0,"Answer":"It's pretty simple: If the inline backend is selected by default, there is no need to activate it again.","Q_Score":1,"Tags":"python,matplotlib,jupyter,inline","A_Id":57096954,"CreationDate":"2019-07-18T14:09:00.000","Title":"Question regarding jupyter notebook inline magic","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was looking at a few tutorials about plotting inline with jupyter notebook and they all say to use the %matplotlib inline, but when I run code normally from my notebook and call plot.show() the chart shows automatically without using magic. I'm am running jupyter from the anaconda package so not sure if that makes a difference. \nIs it still necessary to use the inline magic for matplotlib?","AnswerCount":3,"Available Count":3,"Score":-0.0665680765,"is_accepted":false,"ViewCount":98,"Q_Id":57096512,"Users Score":-1,"Answer":"If you use %matplotlib inline, the Jupyter notebook will save the graph to the notebook. This is not the case for plt.show() which just gives you a temporary visualization of the graph.","Q_Score":1,"Tags":"python,matplotlib,jupyter,inline","A_Id":57096646,"CreationDate":"2019-07-18T14:09:00.000","Title":"Question regarding jupyter notebook inline magic","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a chatbot in AWS Lex and deployed it to facebook. However, I want the chat to display a typing animation before the bot replies. Right now the bot just replies instantly. I want there to be a typing animation to make the bot been more human like. \nIs there some setting in FB Developer I can turn on? I can't seem to find it anywhere. All I see are things for the API call but I am not using any REST calls in my chatbot.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":57096570,"Users Score":0,"Answer":"What if you wait 1 second before sending the message?","Q_Score":0,"Tags":"python,amazon-web-services","A_Id":57096707,"CreationDate":"2019-07-18T14:12:00.000","Title":"AWS Lex and Facebook typing animation","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":"Since I have selected my project's interpreter as Pipenv during project creation, PyCharm has automatically created the virtualenv. Now, when I try to remove the virtualenv via pipenv --rm, I get the error You are attempting to remove a virtualenv that Pipenv did not create. Aborting. So, how can I properly remove this virtualenv?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":6431,"Q_Id":57100248,"Users Score":3,"Answer":"the command \"pipenv\" actually comes from the virtualenv,he can't remove himself.you should close the project and remove it without activated virtualenv","Q_Score":3,"Tags":"python,pycharm,virtualenv,jetbrains-ide,pipenv","A_Id":57197166,"CreationDate":"2019-07-18T17:58:00.000","Title":"How to remove a virtualenv which is created by PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using PyCharm Community 2019.1 on Windows 10 Enterprise.\nIs there any way to keep the run history? Like say I run a script and get the output [first run]. \nThen I run same script again or another script [second run], I want to be able to refer the output\/result of first run.\nIs this possible?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":150,"Q_Id":57101612,"Users Score":2,"Answer":"Yes you just have to right click on the title of the run and click on \"pin tab\" and it won't close automatically when you start a new run","Q_Score":0,"Tags":"python-3.x,pycharm","A_Id":57102889,"CreationDate":"2019-07-18T19:41:00.000","Title":"How to get run\/result\/output history in PyCharm Community","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use a recurrent neural network for a regression problem. I have 50 samples of 600 timesteps each. I am planning to use 40 for training and 10 for validation. \nAfter my network gets trained, can I use it to predict for a timeseries of a smaller length (200 timesteps)? \nThe input and output dimensions (i.e. features) will remain same, just the length (i.e. number of timesteps) is smaller","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":57101619,"Users Score":0,"Answer":"You have 2 options:\n\nFirst option, as @stormzhou commented above, you can pad you test data with zeros (not recommended) \nSecond option, you can use for training and validation only 200 timesteps.","Q_Score":2,"Tags":"python,keras,neural-network,time-series,lstm","A_Id":57110360,"CreationDate":"2019-07-18T19:41:00.000","Title":"Can my training and testing data for neural network be of different lengths?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a c extension (called my_ext) and I successfully compiled the source code to a .so file. However, my_ext depends another dynamic library installed by pip. So the link directory looks like <virtual_env>\/lib\/python3.6\/site-packages\/foo. And my link command looks like this g++ -fPIC -L<virtual_env>\/lib\/python3.6\/site-package\/foo\/ -lfoo ... and I am able to link successfully. However, my question is that since my link_directory is hard-coded according to path in my laptop. When I package my python package and ship to customer, how will that extension load libfoo.so? I assume it will look for the path hard-coded by me right? In this case, customer might not be able to load libfoo.so. How can I resolve this issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":57102081,"Users Score":0,"Answer":"However, my question is that since my link_directory is hard-coded according to path in my laptop\n\nIt shouldn't be. How did you come to conclusion that it is?\nRun readelf -d my_ext.so, and see if there is a reference to the path on your laptop. If there is (unlikely), update your question with the output from readelf -d, and a better answer may come.","Q_Score":0,"Tags":"python,dynamic-linking,python-extensions","A_Id":57212325,"CreationDate":"2019-07-18T20:19:00.000","Title":"Ship Python Extension that required dynamic linking","Data 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 all my virtual environments in ~\/.virtualevs. I am working with a python \/ flask project that wants to have [PROJECT_HOME]\/venv be the virtual environment. \nAm I at risk of things breaking and unexpected results if I ln -s ~\/.virtualenvs\/my_env [PROJECT_HOME]\/venv? Or will that just work as expected?\nI've set this up and it works. For now. But feels 'klugey'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":57102584,"Users Score":0,"Answer":"ln -s creates a soft link (or symbolic link), think of it like a shortcut on Windows, so it's as much safe as you would do operation in the target directory itself.\nAfter creating the symlink, when someone accesses the [PROJECT_HOME]\/venv link, they will be acessing ~\/.virtualenvs\/my_env directory (transparently done by the kernel). So all operations will be happening on the target directory (~\/.virtualenvs\/my_env) as you can imagine.\nAlso check man ln to get more idea on links.\n\nBut using a symlink would break imports as Python does not check for symlinks then. So unless you've set up PYTHONPATH or sys.path correctly to include the symlink directory as well, things would break as far as import machinery is concerned.\nBut as it's a virtualenv directory, I think it's safe.","Q_Score":0,"Tags":"python,unix,virtualenv,ln","A_Id":57102732,"CreationDate":"2019-07-18T21:02:00.000","Title":"Are there risks \/ pitfalls with using ln -s to link a virtualenv into a local venv within a project directory structure?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to create a basic model for stock price prediction and some of the features I want to include come from the companies quarterly earnings report (every 3 months)  so for example; if my data features are Date, OpenPrice, Close Price, Volume, LastQrtrRevenue how do I include LastQrtrRevenue if I only have a value for it every 3 months?  Do I leave the other days blank (or null) or should I just include a constant of the LastQrtrRevenue and just update it on the day the new figures are released?  Please if anyone has any feedback on dealing with data that is released infrequently but is important to include please share.... Thank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":161,"Q_Id":57103601,"Users Score":1,"Answer":"I would be tempted to put the last quarter revenue in a separate table, with a date field representing when that quarter began (or ended, it doesn't really matter). Then you can write queries to work the way that most suits your application. You could certainly reconstitute the view you mention above using that table, as long as you can relate it to the main table.\nYou would just need to join the main table by company name, while selected the max() of the last quarter revenue table.","Q_Score":1,"Tags":"python,deep-learning,dataset,missing-data","A_Id":57103655,"CreationDate":"2019-07-18T22:58:00.000","Title":"How to deal with infrequent data in a time series prediction model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Trying to use 'plotly.graph_objects' but I get this error\n\nModuleNotFoundError: No module named 'plotly.graph_objects'\n\nHow do I download module and apply using anaconda navigator","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":24260,"Q_Id":57105747,"Users Score":28,"Answer":"You should use instead:\nfrom plotly import graph_objs as go","Q_Score":13,"Tags":"python,plotly,plotly-python","A_Id":57112843,"CreationDate":"2019-07-19T04:54:00.000","Title":"ModuleNotFoundError: No module named 'plotly.graph_objects'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to plot some data with Bokeh which has distance as the x-axis. However the distance data I have been provided with is in the format \"7 Miles 100 Meters, 7 Miles 200m\" etc.\nWhat's the best way to do this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":123,"Q_Id":57108242,"Users Score":0,"Answer":"I figured it out in the end, I just converted the Miles(e.g. 7.5) and Meters(e.g. 400m) into Miles (e.g. 7.75miles). Then I used the tickformatter to display the specific points as meters. Thanks for the help","Q_Score":0,"Tags":"python,pandas,bokeh","A_Id":57165757,"CreationDate":"2019-07-19T08:13:00.000","Title":"How to Bokeh plot a combination of Miles and Metres on axis (e.g. 7.5 Miles 100m, 7.5 Miles 200m, 8 Miles 100m....)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to download files from a website using python requests module and beautifulsoup4 but the problem is that you have to wait for 5 seconds before the download button appears.\nI tried using requests.get('URL') to get the page and then parse it with beautifulsoup4 to get the download link but the problem is that you have to wait 5 seconds (if you were to open it with an actual browser) in order for the button to appear so when I pass the URL to requests.get() the initial response object doesn't have the button element I searched a lot on google but couldn't find any results that helped me.\nIs there a way to \"refresh\" the response object? or \"wait\"? that is to update it's contents after five seconds as if it were opened with a browser?\nI don't think this is possible with the requests module. What should I do?\nI'm running Windows10 64x \nI'm new so sorry if the formatting is bad. :(","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1237,"Q_Id":57108768,"Users Score":0,"Answer":"HTTP is stateless, every new request goes as a different request to the earlier one. We typically imeplement states in cookies, browser stoarges and so on. Being a plain HTTP client, there is no way for requests to refresh a request, and the next request will be a compleletly new request.\nWhat you're looking for is some client that understands JavaScript and can handle page update automatically. I suggest you to look at selenium which can do browser automation.","Q_Score":1,"Tags":"python,html,python-requests","A_Id":57108853,"CreationDate":"2019-07-19T08:46:00.000","Title":"Is there a way to \"refresh\" a request?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I run the code in kaggle kernel, it is working fine, but when executing the code on my machine, it throws this error. please help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":57110876,"Users Score":0,"Answer":"so in my case, I was running the code in python 2.7 in which Python 2.7 will give different ceil value as the answer, Python 3.4 reports different value.","Q_Score":0,"Tags":"python,deep-learning,valueerror","A_Id":57139784,"CreationDate":"2019-07-19T10:48:00.000","Title":"ValueError: could not broadcast input array from shape (848,837,8) into shape (800,800,8)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a list say l = [1, 2, 3, 4] how do I compare l[0] < l[1] < l[2] < l[3] in pythonic way?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":57111549,"Users Score":0,"Answer":"Another way would be to use the .sort() method in which case you'd have to return a new list altogether.","Q_Score":2,"Tags":"python,python-3.x","A_Id":57111877,"CreationDate":"2019-07-19T11:26:00.000","Title":"Compare list items in pythonic way","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"On Ubuntu 18.04 with python 3.7.3, I'm attempting to import pandas but this fails because it can't find _lzma.  \nI've verified that _lzma is installed with dpkg:\n\n\/usr\/lib\/python3.7\/lib-dynload\/_lzma.cpython-37m-x86_64-linux-gnu.so. Oddly, _lzma is not a dependency of pandas (as specified by pip3).","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":19345,"Q_Id":57113269,"Users Score":-1,"Answer":"just upgraded to version 0.25.1 and works well","Q_Score":13,"Tags":"pandas,python-3.7,ubuntu-18.04,lzma","A_Id":58452764,"CreationDate":"2019-07-19T13:13:00.000","Title":"import pandas results in ModuleNotFoundError :_lzma","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whats the difference between the following statements:\n\nimport os\nfrom os import *\n\nDo they mean one and the same thing? If so, why two ways of saying it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":101,"Q_Id":57113941,"Users Score":1,"Answer":"import os\nbrings the name os into the namespace and thus the os name becomes unique. \nso using os.read(fd, n) will read n bytes from the file descriptor fd.\nfrom os import *\nbrings all the names from the module os into the global namespace. Thus we can use read(fd,n) directly. \nProblem with from os import * : \nIf we have our own function read(fd,n) in the local namespace, by using from os import * we get 2 functions with the same name, and the interpreter uses the local function with that name. \nIf we create a module with a read(fd,n) function having the same name as the one in os module (both function names will be in the global namespace), the interpreter will only use one of them.","Q_Score":1,"Tags":"python-3.x","A_Id":57114423,"CreationDate":"2019-07-19T13:51:00.000","Title":"Python: Importing modules and libraries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whats the difference between the following statements:\n\nimport os\nfrom os import *\n\nDo they mean one and the same thing? If so, why two ways of saying it?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":101,"Q_Id":57113941,"Users Score":1,"Answer":"from os import * imports all methods from os, and should be avoided.\nimport os just import the namespace and allows you to call methods from os by prefixing with os.","Q_Score":1,"Tags":"python-3.x","A_Id":57114089,"CreationDate":"2019-07-19T13:51:00.000","Title":"Python: Importing modules and libraries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to manually upload the training data label CSV and click on 'train' to train the model. I want to automate all these preferably with python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":57115839,"Users Score":0,"Answer":"I used AutoML RESTapi for creating datasets to training the model. Although If I want to retrain a model on more data, I have to delete the previously trained model and create and train a new one.","Q_Score":1,"Tags":"python,google-cloud-platform,automl,google-cloud-automl","A_Id":57150251,"CreationDate":"2019-07-19T15:48:00.000","Title":"Automating both Uploading the training data label csv and Training processed the model in AutoML Vision Image classification","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've never seen forward slash notation with Python dictionaries, and when looking to the official documentation, I couldn't find any reference, so I'm hoping someone can school me here.\nI was playing with a new library I hope to use on a project when I ran across the notation:\nobject['\/someKeyword']['\/anotherKeyword'].someMethod()\nI didn't understand what the bracketed terms meant at the time. A colleague helped me understand it was dictionary notation, but I haven't been able to find any follow up to study.\nAny information on the notation would be helpful!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":318,"Q_Id":57116306,"Users Score":0,"Answer":"Those are strings, and you can have any unicode codepoint as string constituting character, which obviously includes \/.\nIn the example, it seems a dict like object is being accessed by subscription with string keys that start with \/.","Q_Score":0,"Tags":"python","A_Id":57116401,"CreationDate":"2019-07-19T16:22:00.000","Title":"Forward slash notation with Python dictionaries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to convert hexadecimal numbers into binary. I haven't been able to find a redshift function that would work. \nI have tried the two following functions: \nselect strtol('4D',2) & select to_binary('4D') \n(to_binary function doesn't exist but to_hex does)\nI have also tried finding a python UDF but have had no luck. \nExample:\nIf I converted the hexadecimal 4D into binary I would expect 01001101","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":522,"Q_Id":57116778,"Users Score":0,"Answer":"dec = int('4D', 16); print(\"in Binary =\",bin(dec))","Q_Score":1,"Tags":"python,sql,amazon-redshift","A_Id":57117013,"CreationDate":"2019-07-19T16:59:00.000","Title":"How do I convert a hexadecimal number into binary in Redshift?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Pandas with Python I could use:\nfor item in read_csv(csv_file, header=1)\nAnd in Spark I only have the option of true\/false?\ndf = spark.read.format(\"csv\").option(\"header\", \"true\").load('myfile.csv')\nHow can I read starting from the second row in Spark?\nThe suggested duplicate post is an outdated version of Spark. I am using the latest, 2.4.3.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1631,"Q_Id":57117577,"Users Score":1,"Answer":"Looks like there's no option in spark csv to specify how many lines to skip. Here are some alternatives you can try:\n\nRead with option(\"header\", \"true\"), and rename the column names using withColumnRenamed.\nRead with option(\"header\", \"false\"), and select rows from 2nd line using select.\nIf the first character of the first line is different from all other lines, you can use comment option to skip it. For example, if the first character of line #1 is D, you set comment='D'. Just be careful, comment will skip any line that starts with D here.\n\nHope this helps.","Q_Score":1,"Tags":"python,csv,apache-spark,pyspark,apache-spark-sql","A_Id":57118303,"CreationDate":"2019-07-19T18:00:00.000","Title":"Spark read from second row like Pandas header=1","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Often during debugging Spark Jobs on failure we can find the appropriate Stage and task responsible for the failure such as String Index Out of Bounds exception but it becomes difficult to understand which transformation is responsible for this failure.The UI shows information such as Exchange\/HashAggregate\/Aggregate but finding the actual transformation responsible for this failure becomes really difficult in 500+ lines of code, so how should it be possible to debug Spark task failures and tracing the transformation responsible for the same?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":57117739,"Users Score":0,"Answer":"Break your execution down. It's the easiest way to understand where the error might be coming from. Running a 500+ line of code for the first time is never a good idea. You want to have the intermediate results while you are working with it. Another way is to use an IDE and walk through the code. This can help you understand where the error originated from. I prefer PyCharm (Community Edition is free), but VS Code might be a good alternative too.","Q_Score":2,"Tags":"python,scala,apache-spark,pyspark,apache-spark-sql","A_Id":57124598,"CreationDate":"2019-07-19T18:13:00.000","Title":"How does log in spark stage\/tasks help in understanding actual spark transformation it corresponds to","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Couldnt track down a solid enough reasoning for why dictionary functions such as .values() and .keys() are considered to be O(1) in big O notation.   (not sure if .items() is also considered O(1) )","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":225,"Q_Id":57120914,"Users Score":6,"Answer":"It is likely that the reference you found to .keys() and .values() (and .items()) being O(1) emphasized the performance because it is a contrast to Python 2, where those functions returned lists and required O(N) time to copy references to all the relevant objects out of the dictionary.\nIterating on the view objects returned by those methods in Python 3 will still take O(N) time, as there's no way to avoid visiting each item, since that's the whole point of iteration. The keys and items views do offer O(1) membership tests (e.g. (somekey, somevalue) in somedict.items()), which is a lot more efficient than searching for an item in a list.","Q_Score":4,"Tags":"python,python-3.x,big-o,dictview","A_Id":57121021,"CreationDate":"2019-07-20T00:36:00.000","Title":"Why exactly are .values() and .keys() considered O(1)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When try to import numpy in pycharm it throws: ModuleNotFoundError: No module named 'numpy' error even though numpy is installed on the machine.\nIf I try to run the console it works perfectly.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1283,"Q_Id":57122389,"Users Score":1,"Answer":"pycharm creates its own virtual environment. But you have installed numpy in your system environment.\njust open pychram console and run pip install numpy","Q_Score":1,"Tags":"python,pycharm","A_Id":57122564,"CreationDate":"2019-07-20T06:39:00.000","Title":"Pycharm throws: ModuleNotFoundError: No module named 'numpy' error even though Numpy is installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a problem which requires me to build a deep learning model that based on certain input image it has to output another image. It is worth noting that these two images are conceptually related but they don't have the same dimensions. \nAt first I thought that a classical CNN with a final dense layer whose argument is the multiplication of the height and width of the output image would suit this case, but when training it was giving strange figures such as accuracy of 0. \nWhile looking for some answers on the Internet I discovered the concepts of CNN autoencoders and I was wondering if this approach could help me solve my problem. Among all the examples I saw, the input and output of an autoencoder had the same size and dimensions. \nAt this point I wanted to ask if there was a type of CNN autoencoders that produce an output image that has different dimension compared to input image.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1346,"Q_Id":57126626,"Users Score":3,"Answer":"Auto-encoder (AE) is an architecture that tries to encode your image into a lower-dimensional representation by learning to reconstruct the data from such representation simultaniously. Therefore AE rely on a unsupervised (don't need labels) data that is used both as an input and as the target (used in the loss).\nYou can try using a U-net based architecture for your usecase. A U-net would forward intermediate data representations to later layers of the network which should assist with faster learning\/mapping of the inputs into a new domain..\nYou can also experiment with a simple architecture containing a few ResNet blocks without any downsampling layers, which might or might not be enough for your use-case.\nIf you want to dig a little deeper you can look into Disco-GAN and related methods.They explicitly try to map image into a new domain while maintaining image information.","Q_Score":3,"Tags":"python,tensorflow,keras,deep-learning","A_Id":57139328,"CreationDate":"2019-07-20T16:32:00.000","Title":"Can CNN autoencoders have different input and output dimensions?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a Python script which scrapes a website and sends emails if a certain condition is met. It repeats itself every day in a loop.\nI converted the Python file to an EXE and it runs as an application on my computer. But I don't think this is the best solution to my needs since my computer isn't always on and connected to the internet.\nIs there a specific website I can host my Python code on which will allow it to always run?\nMore generally, I am trying to get the bigger picture of how this works. What do you actually have to do to have a Python script running on the cloud? Do you just upload it? What steps do you have to undertake?\nThanks in advance!","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1140,"Q_Id":57126697,"Users Score":3,"Answer":"well i think one of the best option is pythonanywhere.com there you can  upload your python script(script.py) and then run it and then finish.\ni did this with my telegram bot","Q_Score":1,"Tags":"python,cloud,hosting","A_Id":63171389,"CreationDate":"2019-07-20T16:40:00.000","Title":"How to host a Python script on the cloud?","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 wrote a Python script which scrapes a website and sends emails if a certain condition is met. It repeats itself every day in a loop.\nI converted the Python file to an EXE and it runs as an application on my computer. But I don't think this is the best solution to my needs since my computer isn't always on and connected to the internet.\nIs there a specific website I can host my Python code on which will allow it to always run?\nMore generally, I am trying to get the bigger picture of how this works. What do you actually have to do to have a Python script running on the cloud? Do you just upload it? What steps do you have to undertake?\nThanks in advance!","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1140,"Q_Id":57126697,"Users Score":2,"Answer":"You can deploy your application using AWS Beanstalk. It will provide you with the whole python environment along with server configuration likely to be changed according to your needs. Its a PAAS offering from AWS cloud.","Q_Score":1,"Tags":"python,cloud,hosting","A_Id":57130698,"CreationDate":"2019-07-20T16:40:00.000","Title":"How to host a Python script on the cloud?","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 wrote a program that use pyperclip module and it would work from Pycharm and python IDLE, would work as well if starting from Powershell but if I try to start the program from WIN+R, when launched, the program returns an error saying that pyperclip module is not installed. The same problem appears when I run it from the Anaconda Powershell Prompt.\nPLEASE NOTICE: \nThe program was working perfectly before I installed Anaconda and Jupyterlab.\nThe error occurs when I run the program from the cmd using WIN+R AND when I run it from the Anaconda Command Prompt but it's fine when run from IDLE, Powershell, Pycharm.\nI always used python 3 and only yesterday I installed Anaconda.\nThanks for the help!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":940,"Q_Id":57127523,"Users Score":0,"Answer":"I just spent couple of hours trying to solve exactly the same problem. What I found out is that, as couple of members have already pointed out, the main problem is the mismatch between the version of the python that runs in cmd and the versions of the python used in scripts\/batch files.\nThe first line in the code, known as \"shebang\", in .py file indicates the version of the python that the script should use when it is executed. So, it must match the version run by default with cmd (or when executed with win+R). In my case, I also have a batch file (.bat) that calls specified version of the python, which should be the same version used with .py file.\nThe problem was that both of my files (.py and .bat) were calling python 3.8 while the cmd is running version 3.7. Initially, I used shebang #! python3 in my .py file, and command @py path\/to\/python\/file.py %* (and I also tried @py.exe path\/to\/python\/file.py %*) in my .bat file, and that did not work.\nTo solve the problem, I updated these two files to link to python version 3.7 with following:\n\nchanged shebang in .py file to #! python\nchanged command in .bat file to @python path\/to\/python\/file.py %*\n\nWith these changes the system runs the program with win+R.","Q_Score":0,"Tags":"python,python-3.x,cmd,python-module","A_Id":58566761,"CreationDate":"2019-07-20T18:29:00.000","Title":"Pyperclip module installed but not found when program runs from cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I wrote a program that use pyperclip module and it would work from Pycharm and python IDLE, would work as well if starting from Powershell but if I try to start the program from WIN+R, when launched, the program returns an error saying that pyperclip module is not installed. The same problem appears when I run it from the Anaconda Powershell Prompt.\nPLEASE NOTICE: \nThe program was working perfectly before I installed Anaconda and Jupyterlab.\nThe error occurs when I run the program from the cmd using WIN+R AND when I run it from the Anaconda Command Prompt but it's fine when run from IDLE, Powershell, Pycharm.\nI always used python 3 and only yesterday I installed Anaconda.\nThanks for the help!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":940,"Q_Id":57127523,"Users Score":0,"Answer":"whew, taking course on python and instructor had py.exe instead of python.exe in .bat call. despite trying all of the other installation methods others have mentioned, just changing this to python.exe did that trick.","Q_Score":0,"Tags":"python,python-3.x,cmd,python-module","A_Id":69213643,"CreationDate":"2019-07-20T18:29:00.000","Title":"Pyperclip module installed but not found when program runs from cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to build an OCR desktop application using Java and, to do this, I have to use libraries and functions that were created using the Python programming language, so I want to figure out: how can I use those libraries inside my Java application?\nI have already seen Jython, but it is only useful for cases when you want to run Java code in Python; what I want is the other way around (using Python code in Java applications).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":137,"Q_Id":57127836,"Users Score":1,"Answer":"I have worked in projects where Python was used for ML (machine learning) tasks and everything else was written in Java.\nWe separated the execution environments entirely. Instead of mixing Python and Java in some esoteric way, you create independent services (one for Python, one for Java), and then handle inter-process communication via HTTP or messaging or some other mechanism. \"Mircoservices\" if you will.","Q_Score":0,"Tags":"java,python,javafx","A_Id":57128018,"CreationDate":"2019-07-20T19:16:00.000","Title":"Using Python Libraries or Codes in My Java Application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a class and some methods that I would like to turn into a library. The library relies on a single class, Class. Class has quite a few static methods. These could be moved outside of the Class file. \nIf I want to turn this into a package, how should I place everything? Should I have one file which has the class, and the methods with static decorators? Or should I move the static methods to a separate file? I know both are functionally equivalent, but I was wondering about generally accepted practice. \nIn which case it is better to do one versus the other?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":74,"Q_Id":57128129,"Users Score":2,"Answer":"a library (package) != a file (module) != a class. That is, you can also have one file with a class and a bunch of functions. Which is probably the best in your case.\nStatic method make sense when you either have a great amount of functions, so you need namespacing, or you plan to exploit inheritance and dynamic binding. In your case, they don't provide much value.","Q_Score":0,"Tags":"python,pip,python-3.6","A_Id":57128307,"CreationDate":"2019-07-20T19:58:00.000","Title":"Style question: keep static methods in class or outside?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"import mysql.connector\nModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package\npip install mysql-connector-python-rf\npython version-3.7.2\npip install mysql-connector-python-rf\npip install mysql-connector-python \nsuccesfully installed\nimport mysql.connector\nModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package\nwhereas when I import mysql gives no error message","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":6971,"Q_Id":57130245,"Users Score":5,"Answer":"resolved by renaming the file to anything else than MySQL.py as it just tries to load itself I guess","Q_Score":3,"Tags":"python,mysql","A_Id":61525699,"CreationDate":"2019-07-21T04:06:00.000","Title":"import mysql.connector ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to permanently delete a file i have created with my python code. \nI know the os.remove() etc but can't find anything specific to delete a file permanently.(Don't want to fill Trash with unused files)","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":10431,"Q_Id":57130303,"Users Score":11,"Answer":"os.remove is already what you're looking for. It doesn't send things to Trash. It just deletes them.","Q_Score":4,"Tags":"python,python-3.x","A_Id":57130347,"CreationDate":"2019-07-21T04:20:00.000","Title":"How to permanently delete a file in python 3 and higher?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to permanently delete a file i have created with my python code. \nI know the os.remove() etc but can't find anything specific to delete a file permanently.(Don't want to fill Trash with unused files)","AnswerCount":3,"Available Count":2,"Score":-0.1973753202,"is_accepted":false,"ViewCount":10431,"Q_Id":57130303,"Users Score":-3,"Answer":"Maybe you can try the os.system() function. Just include Linux commands between the brackets and the command will be executed.\nExample: os.system('rm xxx') will remove the file named xxx under your working path.\nBy default, files removed by the rm command is not recoverable (unless you have manually set it previously) and you needn't worry about the disk space problem.\nHope it helps!","Q_Score":4,"Tags":"python,python-3.x","A_Id":57130339,"CreationDate":"2019-07-21T04:20:00.000","Title":"How to permanently delete a file in python 3 and higher?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to tweet something by talking to Alexa. I want to put my code on AWS Lambda, and trigger the function by Alexa.\nI already have a Python code that can tweet certain string successfully. And I also managed to create a zip file and deploy it on Lambda (code depends on the \"tweepy\" package). However, I could not get to trigger the function by Alexa, I understand that I need to use handlers and ASK-SDK (Alexa Service Kit), but I am kind of lost at this stage. Could anyone please give me an idea about how the handlers work and help me see the big picture?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":195,"Q_Id":57134770,"Users Score":0,"Answer":"For your question about capturing user's input for tweeting, use AMAZON.SearchQuery slot type.  You may run into limitations about how much text can be collected and the quality of the capture but SearchQuery slot is the place to start.","Q_Score":0,"Tags":"python,handler,alexa,alexa-skills-kit","A_Id":57210572,"CreationDate":"2019-07-21T15:53:00.000","Title":"How to integrate Lambda, Alexa, and my code (Python - Tweepy)?","Data Science and Machine Learning":0,"Database and SQL":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":"This is a general question about making real future predictions with an LSTM model using keras & tensorflow in Python (optional R). \nFor example stock prices. I know there is a train\/test split to measure the accuracy\/performance of the model comparing my results with the test prices. But I want to make real future predictions\/out of sample predictions. Does anyone has an idea & would like to share some thoughts on it?\nMe only came to mind to use a rolling window but that didn't work at all. So I'm glad about every tip you guys have.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":279,"Q_Id":57134812,"Users Score":0,"Answer":"There are two main ways to create train\/validation set for a time series situation: \n\nsplitting your samples ( taking for example 80 % of the time series for training and 20 % for validation) \nsplitting your time series ( training your model on the first n-k values of the time series and validation on the k other values)","Q_Score":0,"Tags":"python,tensorflow,keras,deep-learning,time-series","A_Id":57135408,"CreationDate":"2019-07-21T15:59:00.000","Title":"Out of sample predictions with LSTM","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I install the python library named Python.NET package using pip install pythonnet,  clr module is installed and imported, installation of qsharp module independently is done successfully but importing qsharp is displaying error.\nCan anyone tell me why it is giving error while importing?\nI am using spyder to run python code and anaconda for installation.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":849,"Q_Id":57135418,"Users Score":0,"Answer":"I was using VScode and getting this error very frequently.  I realized that i needed to change the environment to the one in which qsharp was installed.. as it needed to be installed in different environment than base.\nAlso you will need to get the terminal to the directory where your code is.\nJust posted as I did struggle with this early on.","Q_Score":2,"Tags":"python","A_Id":63785701,"CreationDate":"2019-07-21T17:16:00.000","Title":"import qsharp ModuleNotFoundError: No module named 'qsharp'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Something I've noticed is that when there is an error in our script (regardless of the programming language), it often takes longer to \"execute\" and then output the error, compared to its execution time when there are no errors in our script. \nWhy does this happen? Shouldn't outputting an error take less time because the script is not being fully run? Or does the computer still attempt to fully run the script regardless of whether there is an error or not?\nFor example, I have a Python script that takes approximately 10 seconds to run if there are no errors. When there is an error, however, it takes an average of 15 seconds. I've noticed something similar in NodeJS, so I'm just assuming that this is the case for many programming languages? Apologies if this is a bad question - I'm relatively new to programming and still lack some fundamental understandings.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":57136776,"Users Score":1,"Answer":"The program doesn't attempt to run the script fully in case of an error, the execution is interrupted at the point where an error happens. This is by default but you can always set up your own exception handlers in your scripts which will execute some code.\nAnyway, raising and handling (logging) exceptions also requires some code execution (internal code of the programming language) thus this also takes some time.\nIt's hard to tell why your script execution takes longer in case of an error without looking at your script though, I personally never noticed such differences in general but maybe I just didn't pay attention...","Q_Score":1,"Tags":"python,node.js,performance,time,error-handling","A_Id":57137376,"CreationDate":"2019-07-21T20:29:00.000","Title":"Why do errors take longer than the script itself?","Data 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":"Hello I am creating a spotfire dashboard which I would like to be reusable for each year.\nCurrently my layout is designed as a page with 8 buttons containing the names of stores, if clicked on, spotfire applies a filter so that only informations relating to that store shows. (these were individually created manually)\nIs there a way to automate this with JS or Iron Python, so that for each store a button is automatically created, and in action control for each button is to apply that stores filter?\nI have looked around but cannot find anything relating to dynamically creating buttons. Not asking for you to code this for me, but if someone can point me towards some resources or general logic on how this could be done it would be much appreciated.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":327,"Q_Id":57137631,"Users Score":1,"Answer":"Why not just putting a textarea on your page? Inside this textarea, you add a filter control that filters data the way you want ;)\nWith this you don't have problem with elements to create dynamically, because it's impossible to create spotfirecontrols dynamically.","Q_Score":1,"Tags":"javascript,ironpython,spotfire","A_Id":57162196,"CreationDate":"2019-07-21T23:11:00.000","Title":"Spotfire - Dynamically creating buttons using","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Hello I am creating a spotfire dashboard which I would like to be reusable for each year.\nCurrently my layout is designed as a page with 8 buttons containing the names of stores, if clicked on, spotfire applies a filter so that only informations relating to that store shows. (these were individually created manually)\nIs there a way to automate this with JS or Iron Python, so that for each store a button is automatically created, and in action control for each button is to apply that stores filter?\nI have looked around but cannot find anything relating to dynamically creating buttons. Not asking for you to code this for me, but if someone can point me towards some resources or general logic on how this could be done it would be much appreciated.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":327,"Q_Id":57137631,"Users Score":1,"Answer":"Think txemsukr is right.  This is not possible.  To do it with JS or IP, the API would have to exist.  Several of the elements you mentioned (action controls), you can't control with the API.","Q_Score":1,"Tags":"javascript,ironpython,spotfire","A_Id":57171287,"CreationDate":"2019-07-21T23:11:00.000","Title":"Spotfire - Dynamically creating buttons using","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Hello I am creating a spotfire dashboard which I would like to be reusable for each year.\nCurrently my layout is designed as a page with 8 buttons containing the names of stores, if clicked on, spotfire applies a filter so that only informations relating to that store shows. (these were individually created manually)\nIs there a way to automate this with JS or Iron Python, so that for each store a button is automatically created, and in action control for each button is to apply that stores filter?\nI have looked around but cannot find anything relating to dynamically creating buttons. Not asking for you to code this for me, but if someone can point me towards some resources or general logic on how this could be done it would be much appreciated.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":327,"Q_Id":57137631,"Users Score":2,"Answer":"instead of buttons, why not a dropdown populated by the unique values in the \"store names\" column to set a document property, and have your data listing limit the data to [store_name] = ${store_name}","Q_Score":1,"Tags":"javascript,ironpython,spotfire","A_Id":57333250,"CreationDate":"2019-07-21T23:11:00.000","Title":"Spotfire - Dynamically creating buttons using","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to display an outline of a dog in a window. I then need to be able to change the colour for different part of the dog by inputting numbers into entry boxes- for example if I put a '1' in the 'head' entry box, the head changes to a yellow colour. The dog should be white by default. \nI can just create 4 images (one for the head, body, legs, and tale) to change each part of the bod. I've thought about changing the rgb values of each image to change the colour, but this would also change the colour for the outline (meant to stay black). The only other thing I could think of was making a red, blue, green, yellow, blue, etc. version of each image (head, body, legs, tail), and then just displaying the red version of the image when I need to (and the same for other colours).\nI need to know if there is any other way to do this (perhaps with the canvas widget?) before I code it because It will take a long time to change the colour of each image. I just have no idea where to start.\nThanks in advance for your answers","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":348,"Q_Id":57139284,"Users Score":0,"Answer":"You will have to make different widgets for each part of the dog(e.g: Head, Abdomen etc.) and you will need different images for the dogs part and color, after that you can implement a button that changes the color with the 'if' function.","Q_Score":0,"Tags":"python-3.x,tkinter,tkinter-canvas,tkinter-entry,tkinter-layout","A_Id":57139424,"CreationDate":"2019-07-22T04:42:00.000","Title":"Create an image or photo that can change colour in Tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My laptop had a problem with training big a dataset but not for predicting. Can I use Google Cloud Platform for training, only then export and download some sort of weights or model of that machine learning, so I can use it on my own laptop, and if so how to do it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":57139636,"Users Score":0,"Answer":"Decide if you want to use Tensorflow or Keras etc. Prepare scripts to train and save model, and another script to use it for prediction. \nIt should be simple enough to use GCP for training and download the model to use on your machine. You can choose to use a high end machine (lot of memory, cores, GPU) on GCP. Training in distributed mode may be more complex. Then download the model and use it on local machine.\nIf you run into issues, post your scripts and ask another question.","Q_Score":0,"Tags":"python,machine-learning,google-cloud-platform","A_Id":57139854,"CreationDate":"2019-07-22T05:27:00.000","Title":"Can I use GCP for training only but predict with my own AI machine?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a 32 cores and 64 threads CPU for executing a scientific computation task. How many processes should I create?\nTo be noted that my program is computationally intensive involved lots of matrix computations based on Numpy. Now, I use the Python default process pool to execute this task. It will create 64 processes. Will it perform better or worse than 32 processes?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":57140042,"Users Score":0,"Answer":"It's impossible to give you an answer as it will depend on your exact problem and code but potentially also of your hardware.\nBasically the process for multi-processing is to split the work in X parts then distribute it to each process, let each process work and then merge each result.\nNow you need to know if you can effectively split the work in 64 parts while keeping each part around the same time of work (if one process take 90% of the time and you can't split it it's useless to have more than 2 processes as you will always wait for the first one).\nIf you can do it and it's not taking too long to split and merge the work\/results (remember that it's a supplementary work to do so it will take extra time) then it can be interesting to use more process.\nIt is also possible that you can speed-up your code by using less process if you pass too much time on splitting\/merging the work\/results (sometime the speed-up obtained by using more process can be negative).\nAlso you have to remember that in some architecture the memory cache can be shared among cores so it can badly affect the performances of multiprocessing.","Q_Score":3,"Tags":"python,process","A_Id":57142974,"CreationDate":"2019-07-22T06:09:00.000","Title":"How many processes should I create for the multi-threads CPU in the computational intensive scenario?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a use case where in I need to cluster N transactions but with a constraint that a particular column value in the resultant clusters should be same for individual clusters. I have been using NearestNeighbors - NN from sklearn for this purpose and it seems to workout to an extend. The distance metric chosen is Cosine and the the type of data is categorical - one hot encoding is done before actual clustering.\nNow if I have columns c1, c2...cn, which is used along with NN for clustering and if I want to enforce the criteria that for a particular cluster derived, Gi, there should be a single unique value for column cx with in Gi. How would I enforce this?\nI went through a couple of documents and some of the techniques indirectly suggests to groupby the column cx and then do the clustering or duplicate the column cx in data and cluster. Are these valid approached to tackle the problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":57146403,"Users Score":0,"Answer":"If you have an inverted index, enforcing a certain value to be required, while having other values optional and only used for similarity should be straightforward. Just think of the full-text search example with required and optional terms.\nDepending on how many queries you do, linear search as well as a \"group by\" approach may be fine.","Q_Score":0,"Tags":"python,scikit-learn,cluster-analysis","A_Id":57216482,"CreationDate":"2019-07-22T12:48:00.000","Title":"Weighted clustering using NearestNeighbors","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a doubt that like other programming languages we can increment in for loop as we want (eg in c  for(i=0; i<5;i+5))  but if we want to do his in python we cant ??????","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":639,"Q_Id":57147651,"Users Score":1,"Answer":"You would do it this way:\nfor i in range(0,5,5):","Q_Score":0,"Tags":"python,python-3.x","A_Id":57147733,"CreationDate":"2019-07-22T13:58:00.000","Title":"working of for loop in python 3 having increment problem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using train_test_split to train the model and check the results using predict. How do I proceed to predict the labels of additional data, for example, from a test set or from user inputs?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":35,"Q_Id":57147986,"Users Score":1,"Answer":"You can use the custom data for prediction as long as it has the same number, order and type of features as your training data into an array type, not in list. If you meet these conditions, you can send that array to the model for prediction with the normal predict() method.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn","A_Id":57148940,"CreationDate":"2019-07-22T14:15:00.000","Title":"Custom data prediction using decision trees","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let me start off by saying I know this issue has already been discussed, but I could not find a solution that was similar to my case.\nI have a directory structure like the following:\n\nproject\/\n\n\ntools  \n\n\nmy_tool\n\n\ntool_name.py\n\n\ntests\n\n\nlib\n\n\nconstants.py\nmy_test.py\ncommon\/\n\n\ncheck_lib.py\n\n\n\n\n\nI need to import constants.py, check_lib.py, and tool_name.py into my_test.py using relative paths. Is there a way to do this even though several of my modules are in various depths within different directories in my project? I am trying to do this directly in the code with a \"from module.path import module\" type of import. Any help is greatly appreciated!\nMY solution was the following:\ntool_name.py\n\nprint(\"tool_name.py imported\")\n\nconstants.py\n\nprint(\"constants.py imported\")\n\ncheck_lib.py\n\nprint(\"check_lib.py imported\") \n\nmy_test.py\n\nimport constants\n  import common.check_lib  \nimport sys\n  import os\n  sys.path.append(os.path.abspath('test_project\/tools\/my_tool'))  \nimport tool_name  \n\noutput :  \n\nconstants.py imported\n  check_lib.py imported\n  tool_name.py imported\n  my_test.py is running","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":57150623,"Users Score":0,"Answer":"Using PYTHONPATH=., go to the directory one level up from \"project\".\nInvoke your code with somewhat long names, e.g. $ python -m project.tools.my_tool.tool_name.\nThat way \"tools\" code will be allowed to access \"tests\", since it's still within \"project\".","Q_Score":1,"Tags":"python-3.x","A_Id":57150714,"CreationDate":"2019-07-22T16:59:00.000","Title":"Import module using relative paths","Data 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 keep getting syntax error messages saying my arguments aren't in the right order when they are, and also I'll do fontsize = 9 and it will say the equal sign shouldn't be there. If I do *fontsize = 9, the asterisk will be wrong. Does anyone know why this happens?\nI went on the matplotlib website and used the annotate functions on there, and for some reason I keep running errors.\nMy code is really incoherent so no.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":57150665,"Users Score":0,"Answer":"try placing fontsize=_ after your color aggument or x,y etc\n not at last like labels","Q_Score":0,"Tags":"python,python-3.x","A_Id":57150902,"CreationDate":"2019-07-22T17:03:00.000","Title":"How do I make the fontsize smaller on points in a Python scatterplot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to load a mesh from an .obj file (from ShapeNet dataset) using Trimesh, and then use the repair.fix_winding(mesh) function.\nBut when I load the mesh, via \ntrimesh.load('\/path\/to\/file.obj') or trimesh.load_mesh('\/path\/to\/file.obj'), \nthe object class returned is Scene, which is incompatible with repair.fix_winding(mesh), only Trimesh object are accepted.\nHow can I force it to load and return a Trimesh object or parse the Scene object to Trimesh object? Or any other way to fix winding of the triangles?\nUsing:\nPython 3.6.5\nTrimesh 3.0.14\nMacOS 10.14.5","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2337,"Q_Id":57155089,"Users Score":0,"Answer":"I have the same problem. You can access the \"geometry\" member of the scene, but I have no idea how the original mesh is split into multiple ones. Following.","Q_Score":0,"Tags":"python,trimesh","A_Id":57183592,"CreationDate":"2019-07-22T23:56:00.000","Title":"obj file loaded as Scene object instead of Trimesh object","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to generate random division problems for an educational game that I am building. Generating random addition, subtraction, and multiplication problems is not too difficult. But I want my division problems to not have any remainders. \nWith addition, subtraction and multiplication, I could just do [random number] times or plus or subtract [random number].\nIt is not so easy if I want to do division problems. Can anyone help?\nThanks in advance","AnswerCount":6,"Available Count":5,"Score":0.0665680765,"is_accepted":false,"ViewCount":766,"Q_Id":57155636,"Users Score":2,"Answer":"1) Take any non-zero randomized Divisor (x).  \/\/ say 5\n2) Take any randomized temporary Dividend (D).  \/\/ say 24\n3) Calculate R = D % x; \/\/ => 4\n4) return Dividend as (D -x ) \/\/ return 20\nNow, your dividend will always be perfectly divisible by the divisor.","Q_Score":0,"Tags":"python,math","A_Id":57162164,"CreationDate":"2019-07-23T01:45:00.000","Title":"Generating random division problems in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to generate random division problems for an educational game that I am building. Generating random addition, subtraction, and multiplication problems is not too difficult. But I want my division problems to not have any remainders. \nWith addition, subtraction and multiplication, I could just do [random number] times or plus or subtract [random number].\nIt is not so easy if I want to do division problems. Can anyone help?\nThanks in advance","AnswerCount":6,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":766,"Q_Id":57155636,"Users Score":2,"Answer":"x\/y = z\ny*z = x\nGenerate y and z as integers, then calculate x.","Q_Score":0,"Tags":"python,math","A_Id":57155682,"CreationDate":"2019-07-23T01:45:00.000","Title":"Generating random division problems in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to generate random division problems for an educational game that I am building. Generating random addition, subtraction, and multiplication problems is not too difficult. But I want my division problems to not have any remainders. \nWith addition, subtraction and multiplication, I could just do [random number] times or plus or subtract [random number].\nIt is not so easy if I want to do division problems. Can anyone help?\nThanks in advance","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":766,"Q_Id":57155636,"Users Score":0,"Answer":"I think that @Vira has the right idea.\nIf you want to generate a and b such that a = b * q + r with r=0, the good way to do it is : \n\nGenerate b randomly\nGenerate q randomly\nCompute a = b * q\nAsk to compute the division : a divided by b. The answer is q.","Q_Score":0,"Tags":"python,math","A_Id":57165189,"CreationDate":"2019-07-23T01:45:00.000","Title":"Generating random division problems in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to generate random division problems for an educational game that I am building. Generating random addition, subtraction, and multiplication problems is not too difficult. But I want my division problems to not have any remainders. \nWith addition, subtraction and multiplication, I could just do [random number] times or plus or subtract [random number].\nIt is not so easy if I want to do division problems. Can anyone help?\nThanks in advance","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":766,"Q_Id":57155636,"Users Score":1,"Answer":"You can simply generate the divisor and quotient randomly and then compute the dividend. Note that the divisor must be nonzero (thanks to @o11c's remind).","Q_Score":0,"Tags":"python,math","A_Id":57155658,"CreationDate":"2019-07-23T01:45:00.000","Title":"Generating random division problems in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to generate random division problems for an educational game that I am building. Generating random addition, subtraction, and multiplication problems is not too difficult. But I want my division problems to not have any remainders. \nWith addition, subtraction and multiplication, I could just do [random number] times or plus or subtract [random number].\nIt is not so easy if I want to do division problems. Can anyone help?\nThanks in advance","AnswerCount":6,"Available Count":5,"Score":-0.0333209931,"is_accepted":false,"ViewCount":766,"Q_Id":57155636,"Users Score":-1,"Answer":"you can generate a number to be divided as [random number1]x[random number2]\n. The problem will then be [random number1]x[random number2] divide by [random number1]","Q_Score":0,"Tags":"python,math","A_Id":57155672,"CreationDate":"2019-07-23T01:45:00.000","Title":"Generating random division problems in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to add an attribute to an object which uses slots. I know this is a hack and should not be used.\nBut is there a way to get around this restriction of slots?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":102,"Q_Id":57156001,"Users Score":1,"Answer":"That's exactly what using __slots__ prevents, and it seem you already know this seeing as you've mentioned trying to do what you are doing is a hack you should avoid.\nYou basically have two options;\n\nDon't use __slots__. You will be able to add attributes to your hearts content, and depending on how you're using this class you probably won't even notice a performance difference.\nAdd the attributes up-front, but leave them set to None (or a sentinal value) and populate them later (instead of creating them later).\n\nIf you're trying to make the attributes on your class dynamic - then __slots__ simply isn't the right option for you.","Q_Score":0,"Tags":"python,slots","A_Id":57156040,"CreationDate":"2019-07-23T02:47:00.000","Title":"Add an attribute to an object which uses __slots__","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to add an attribute to an object which uses slots. I know this is a hack and should not be used.\nBut is there a way to get around this restriction of slots?","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":102,"Q_Id":57156001,"Users Score":4,"Answer":"No. If you didn't declare '__dict__' as one of the slots, then the class has a fixed underlying struct layout with no space for dynamically defined attributes; the best you could do would be to redefine the class from scratch and replace it (and hope no one made an instance of the original before you got to it), or make a subclass (that doesn't have to do anything special in the body, just pass; if it doesn't declare __slots__, it will end up with __dict__\/__weakref__ as normal) and use it instead of the parent class.\nEven changing __slots__ after the class is defined won't do anything; the slots are baked into the class at that point; you could del MyClass.__slots__ without changing the behavior.","Q_Score":0,"Tags":"python,slots","A_Id":57156032,"CreationDate":"2019-07-23T02:47:00.000","Title":"Add an attribute to an object which uses __slots__","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a Bamboo task which runs the python code from a BitBucket Repo. \nBamboo config:\nI am running the script as a file. \nI have selected interpreter as Shell and given this in the Script Body to execute the script python create_issue.py -c conf.yml\nAfter I click on 'Run Plan', the build fails with ImportError: No module named pandas. The rest of the libraries are working fine, like, requests, itertools, etc.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":485,"Q_Id":57156974,"Users Score":1,"Answer":"It sounds like you are running this Bamboo plan using the Agent Host and not a Docker Container.  As such you will need to:\n\nRemote\/Log into the Bamboo server\nUse pip or some other package tool to install requests, itertools, and any other missing imports\n\nAlternatively, you could set-up an isolated Docker image that has all these dependencies and build within that.","Q_Score":0,"Tags":"python,bamboo","A_Id":57165277,"CreationDate":"2019-07-23T05:02:00.000","Title":"Bamboo error - ImportError: no module named pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm not sure if this is a valid question, but I'm stuck doing this.\nI've a python script which does some operation on my local system\nUsers\/12345\/Desktop\/Sample\/one.py\nI want the same to be run on remote server whose path is \nServer\/Users\/23552\/Dir\/ASR\/Desktop\/Sample\/one.py\nI know how to do this in PHP using define path APP_HOME sort of I'm baffled in Python\nCan someone pl help me?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":57157730,"Users Score":0,"Answer":"You can always use the relative path, I guess relative path should solve your issue.","Q_Score":1,"Tags":"python,python-3.x","A_Id":57409263,"CreationDate":"2019-07-23T06:15:00.000","Title":"Define dynamic environment path variables for different system configuration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"In the process of discovering devices via Alexa, I'd like to create and pre populate groups with devices. The devices being discovered have data pertaining to which room\/group they belong to, so it would only seem natural to group these during discovery. \nIs this something that's possible? I haven't found anything in their documentation to suggest that it is","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":57157766,"Users Score":0,"Answer":"Unfortunately you can't tell Alexa about groups in your discovery response.","Q_Score":3,"Tags":"python,node.js,alexa","A_Id":57160456,"CreationDate":"2019-07-23T06:18:00.000","Title":"Is there a way to create an Alexa smart home group and pre-populate it based on discovered devices, programatically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I started learning Linear Regression and I was solving this problem. When i draw scatter plot between independent variable and dependent variable, i get vertical lines. I have 0.5M sample data. X-axis data is given within range of let say 0-20. In this case I am getting multiple target value for same x-axis point hence it draws vertical line.\nMy question is, Is there any way i can transform the data in such a way that it doesn't perform vertical line and i can get my model working. There are 5-6 such  independent variable that draw the same pattern. \nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":850,"Q_Id":57157943,"Users Score":0,"Answer":"Instead of fitting y as a function of x, in this case you should fit x as a function of y.","Q_Score":0,"Tags":"python,linear-regression","A_Id":57157989,"CreationDate":"2019-07-23T06:31:00.000","Title":"how to get best fit line when we have data on vertical line?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Char field in a form in Odoo-12. Is it possible to trigger\na method with the fields value as parameter when the Enter key is pressed without writing a Javascript widget for that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":490,"Q_Id":57161913,"Users Score":0,"Answer":"You can write onchange method in it to trigger it and in that you can also get the values of that field.","Q_Score":0,"Tags":"javascript,python,odoo-12","A_Id":57163062,"CreationDate":"2019-07-23T10:20:00.000","Title":"Odoo-12 trigger function on \"Enter\" keypress in char field","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am counting the total no. of vehicles in a video, but I want to detect only the vehicles which are travelling up(roads have a divider) so my point is, Can i use yolo only on a rectangle where vehicles are moving up? I dont want to detect vehicles that are on the other side of the road.\nis there a way like i can draw a rectangle and only detect objects on that specific rectangle?\nThe best I can think of is for every frame, i'll have to crop the frame, perform all the operations and stitch it back to the original frame. I am expecting an easier alternative for the same\nAny help is appreciated. Thanks","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":955,"Q_Id":57164149,"Users Score":0,"Answer":"You can perform yolo on the entire image as usual, but add an if condition to only draw boxes the center of which falls in a specific region. Or you can add this condition (position) next to the conditions of IoU (where detected boxes are filtered). Also you can separate counting based on the direction of moving vehicles and use two different counters for the two directions. \nIf you don't mind me asking, how are you tracking the vehicles?","Q_Score":0,"Tags":"python,opencv,image-processing,yolo","A_Id":57170037,"CreationDate":"2019-07-23T12:23:00.000","Title":"detect objects in only specific region of the frame-yolo-opencv","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am counting the total no. of vehicles in a video, but I want to detect only the vehicles which are travelling up(roads have a divider) so my point is, Can i use yolo only on a rectangle where vehicles are moving up? I dont want to detect vehicles that are on the other side of the road.\nis there a way like i can draw a rectangle and only detect objects on that specific rectangle?\nThe best I can think of is for every frame, i'll have to crop the frame, perform all the operations and stitch it back to the original frame. I am expecting an easier alternative for the same\nAny help is appreciated. Thanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":955,"Q_Id":57164149,"Users Score":0,"Answer":"i'm doing a similar thing...\nif your product is going to be fixed on like a light poll then clearly you can either detect the road and zebra crossing by training a model.\nor\nmanually enter these values...\nlater run your object detection and object tracking on only these parts of the frames i.e, use\nframe[ymax:ymin, xmax:xmin]\nThis reduces the image size so your processing speed increases.\nbut why do you need the full image again after your work? still if you do need it then you just have to add the values of xmin and ymin of your object detection box on the road to the bounding box of the vehicle detected in that object detection box to get its bounding box values in uncropped image.","Q_Score":0,"Tags":"python,opencv,image-processing,yolo","A_Id":71621543,"CreationDate":"2019-07-23T12:23:00.000","Title":"detect objects in only specific region of the frame-yolo-opencv","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Lambda function in Python 3.7 which gets invoked explicitly and synchronously via Boto3. It is configured with a timeout of 5 minutes. While the 1st invocation is in progress for a minute, a second invocation is started with another request ID. Another minute later, the request is again retried, and this time it finished quicky. as it detects the system state has changed. An example sequence of invocations\n\n11:20:29 to 11:21:53 - log stream A - Req. ID: 68cfbd89-9f4c-4e8c-9de0-b9e548983692\n11:21:30 to 11:22:56 - log stream B - Req. ID: 1b569ffb-67b8-4e82-8e99-46424f45e2e5\n11:22:30 to 11:22:33 - log stream A - Req. ID: d9d60271-4626-43ab-bb3a-f14be057af13\n\nThe request ID that's returned from my Lambda call is d9d60271-4626-43ab-bb3a-f14be057af13.\nThe stack that invokes the Lambda is as follows:\n\nJenkins running a Pipeline script.\nThe script runs a Makefile which executes 2 sequential tasks.\n\n\nBuild a docker container\nRun a script inside the container.\n\nThe script that runs inside the container is in Python 3.7. It uses Boto3 to call some AWS APIs, then invokes the lambda with InvocationType=\"RequestResponse\".\n\nNone of the invocations exits with an unhandled exception or any obvious error. Is Lambda retrying my calls? Could any other element of this stack, notably Jenkins, be \"transparently\" retrying the task, and if so, how would I establish that?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":630,"Q_Id":57165547,"Users Score":6,"Answer":"This generally occurs due to cli time read out, which returns in multiple invocations of the lambda. Add --cli-read-timeout parameter to \naws lambda invoke\nor if using boto then follow as answered by YitzikC above\nFor aws cli the command would look like this\naws lambda invoke --function-name <fn name> --cli-read-timeout 900 --log-type Tail --region <region> \/dev\/stdout\nEnsure that the cli read timeout is equal to or greater than your lambda fun execution timeout","Q_Score":3,"Tags":"python,jenkins,aws-lambda,boto3","A_Id":57169406,"CreationDate":"2019-07-23T13:43:00.000","Title":"Amazon Lambda re-invoked every minute with multiple request IDs despite having no errors","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am using python to update a lot of data files with new observations using the documentDB module. I have to upsert 100-200 json files per minute, and the upserting operation takes up way more time than the rest of the program. Right now I'm using the 'UpsertDocument' function from the DocumentClient in the module. Is there a faster\/better way?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1621,"Q_Id":57166251,"Users Score":0,"Answer":"One option would be to use the Cosmos DB Spark connector instead, and, optionally (and conveniently) run as a job in Azure Databricks.  This will provide a significant amount of control over your throughput and make it easy to find the optimal balance between parallelism (which I think is the issue) and RU capacity on the Cosmos DB.  \nHere's a simple example of measurements taken loading 118K documents, and this is using a minimum spec Databricks cluster with just 1 worker.\nSingle Cosmos client in Python: 28 docs\/sec @ 236 RUs (i.e. not pushing Cosmos at all)\nSpark Cosmos DB Adapter, 66 docs\/sec @ >400 RUs (was throttled due to 400 RU limit)\n... after bumping up Cosmos DB to 10K RUs\nSpark Cosmos DB Adapter, 1317 docs\/sec @ >2.9K RUs (don't think it ran long enough for accurate RUs) - still the same minimum spec cluster\nYou could also try Python multi-threading (I think it will help), and as CYMA said in the comment, you should be checking for throttling at Cosmos DB. My observation, though, is a single Cosmos client isn't going to get you even to the minimum 400 RUs.","Q_Score":1,"Tags":"python,json,azure,azure-cosmosdb,upsert","A_Id":57212660,"CreationDate":"2019-07-23T14:19:00.000","Title":"How to bulk Upsert json files to azure Cosmos DB (documentDB module)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am setting the timeout value to 1 second to a put request so that I don't wait for it to complete, however, does it cancel the request or it does continue in the background?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":195,"Q_Id":57166437,"Users Score":0,"Answer":"As per my observation, time-out does not cause the request to cancel. The operation (PUT, POST etc) continues to get processed in the server.","Q_Score":0,"Tags":"python,python-requests","A_Id":57248146,"CreationDate":"2019-07-23T14:29:00.000","Title":"Python Request: Dont wait for put to complete","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on a project where I wanted to automate a GUI using python. I am trying to make some basic mouse movements using pyautogui.\nSetup 1 - Here, I am using Windows 7. Commands such as pyautogui.mouseUp, pyautogui.mouseDown are working perfectly fine.\nSetup 2 - Here, I am using Windows 10. Commands pyautogui.mouseUp and pyautogui.mouseDown are not working. \nNote - \nAny suggestions or advises please?\nI am using 19 inch desktop monitors in both the cases (both setups). Hence, ruling out resolution issues. '","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":564,"Q_Id":57169835,"Users Score":0,"Answer":"Can you use the the pyautogui.moveTo(x, y) function to move the mouse to a specific point instead of up or down?","Q_Score":1,"Tags":"python,python-3.x,pyautogui","A_Id":57169930,"CreationDate":"2019-07-23T18:01:00.000","Title":"How to fix 'Pyautogui.mouseUP' and mouseDown issues in Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My data is in a large multi-indexed pandas DataFrame. I re-index to flatten the DataFrame and then feed it through ColumnDataSource, but I need to group my data row wise in order to plot it correctly (think bunch of torque curves corresponding to a bunch of gears for a car). If I just plot the dictionary output of ColumnDataSource, it's a mess. \nI've tried converting the ColumnDataSource output back to DataFrame, but then I lose the update functionality, the callback won't touch the DataFrame, and the plots won't change. Anyone have any ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":57169954,"Users Score":0,"Answer":"The short answer to the question in the title is \"Yes\". The ColumnDataSource is the special, central data structure of Bokeh. It provides the data for all the glyphs in a plot, or content in data tables, and automatically keeps that data synchronized on the Python and JavaScript sides, so that you don't have to, e.g write a bunch of low-level websocket code yourself. To update things like glyphs in a plot, you update the CDS that drives them. \nIt's possible there are improvements that could be made in your approach to updating the CDS, but it is impossibe to speculate without seeing actual code for what you have tried.","Q_Score":0,"Tags":"python-3.x,dataframe,callback,bokeh","A_Id":57170266,"CreationDate":"2019-07-23T18:09:00.000","Title":"Is ColumnDataSource() the only way to get plots updated in a bokeh web app?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to sift through a Word document and complete some quick grammar checks. I currently have code that splits the document into words using python-docx and then I run my grammar checks on the words\/sentences based on specific criteria. I then past the correct grammar back into the document using the .add_run function.\nThe issue I'm having is when I past the correct grammar back into the document, it doesn't save the font style (Bold and Italics), so when I paste words in, it just shows up as text without the Bold and Italics when I want to keep it. \nMy question is, is there any way in python (using python-docx or any other package) to save the font details (mainly bold and italics) for each word so that I can use code to bold or italicize words accordingly?\nI've already tried using the .style function for paragraphs and runs, but the issue that arises is that the style per paragraph is unclear on what is being bolded and italicized, and I don't want to paste a whole paragraph, just the wrong words.\nI've also tried looking at the .style for each run, but it is unreliable since runs often splits a word into 2 when it shouldn't. (\"Mario\" might become  2 different runs \"M\" and \"ario\" even when there isn't any style change).\nI've also tried looking at other packages but haven't found anything helpful.\nif the input is \"Stack Overflow is a question and answer site for professional and enthusiast programmers.\"(with \"question\" and \"answer\" is bold and italicized),\nthe expected output is same sentence with the word \"question\" and \"answer\" bold and italicized\nthe actual output is the same sentence but no bold or italics in it whatsoever.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":57169973,"Users Score":0,"Answer":"This is a challenging problem in the general case:\n\nCharacter-formatting can be applied at various levels (directly, style, document-default, etc.) and determining the effective character formatting for a particular run is therefore not a single-step process.\nA given word can partly appear in more than one run and not all parts of the word are guaranteed to be complete runs, for example a sequence of five r|uns could ab|so|lut|ely be split like this\"\n\nSo you have your work cut out for you. A general-case solution might have a Word object for each word, with a sequence of (run, offset, length) tuples for each which, with the proper processing, could give you the information you need. You would probably assume that the formatting of the first character of the word could safely be applied to the whole word. In that case, you could just have a sequence of (word, run) pairs, where the run item is the one in which the first character of word appears in.\nAs a start I would look at run.bold and run.italic to get the most common formatting and then work your way up from there.","Q_Score":0,"Tags":"python,python-docx","A_Id":57172882,"CreationDate":"2019-07-23T18:10:00.000","Title":"How to use python-docx or any other similar package to save font style (bold and italic) from Word document","Data 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":"Loading the excel file using read_excel takes quite long. Each Excel file has several sheets. The first sheet is pretty small and is the sheet I'm interested in but the other sheets are quite large and have graphs in them. Generally this wouldn't be a problem if it was one file, but I need to do this for potentially thousands of files and pick and combine the necessary data together to analyze. If somebody knows a way to efficiently load in the file directly or somehow quickly make a copy of the Excel data as text that would be helpful!","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":768,"Q_Id":57173573,"Users Score":-1,"Answer":"The method read_excel() reads the data into a Pandas Data Frame, where the first parameter is the filename and the second parameter is the sheet.\ndf = pd.read_excel('File.xlsx', sheetname='Sheet1')","Q_Score":0,"Tags":"python,pandas,python-2.7","A_Id":61889824,"CreationDate":"2019-07-23T23:56:00.000","Title":"How to best(most efficiently) read the first sheet in Excel file into Pandas Dataframe?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If not, why not? Sometimes I will have an epoch that gets 95ish % and then finish with an epoch that has 10% or so less accuracy. I just never can tell whether it reverts back to that best epoch.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":57174825,"Users Score":0,"Answer":"keras.callbacks.ModelCheckpoint(filepath, monitor='val_loss', verbose=0, save_best_only=True, save_weights_only=False, mode='auto', period=1)","Q_Score":0,"Tags":"python,tensorflow,machine-learning,keras,epoch","A_Id":57176551,"CreationDate":"2019-07-24T03:29:00.000","Title":"When training neural networks, does Tensorflow automatically revert back to the best epoch after finishing?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem because I'm new guy in Odoo 11, my task is combine 2 pivot ( Sales and Pos Order ) into 1 pivot view of new Module that i create. So how can i do this? step by step, because I'm just new guy. Please help me, thanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":57175408,"Users Score":0,"Answer":"You Can use select queries for both the models and there is no need for same field or relation you can just use Union All.For Example\nselect pos_order as po\nLEFT JOIN pos_order_line pol ON(pol.order_id = po.id)\nUNION ALL\nselect sale_order so\nLEFT JOIN sale_order_line sol ON(sol.order_id = so.id)\nHope this will help you in this regard and don't forget to define the fields you want to show on the pivot view.","Q_Score":0,"Tags":"pivot,report,python-3.6,odoo-11","A_Id":72230974,"CreationDate":"2019-07-24T04:43:00.000","Title":"How can I combine 2 pivot ( Sale and Pos Order ) into 1 pivot view on my new module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to load a file of size around 100mb using pandas. I know we can load but I want to know does the file size affects the efficiency of the program. And is there any way to load the file efficiently?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":57179262,"Users Score":0,"Answer":"Yes the performance is affected and sometimes system gets slow. \nYou can try to read the data in the form of table or you can also use chunksize. This will improve the efficiency","Q_Score":2,"Tags":"python,pandas,csv,data-science","A_Id":57181431,"CreationDate":"2019-07-24T09:11:00.000","Title":"Does pandas read the full data file and stores it in a data frame? Is it efficient to load a 100mb file in pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am also trying to understand how to use Tkinter so could you please explain the basics?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":229,"Q_Id":57179821,"Users Score":1,"Answer":"What is the difference between the _tkinter and tkinter modules?\n\n_tkinter is a C-based module that exposes an embedded tcl\/tk interpreter. When you import it, and only it, you get access to this interpreter but you do not get access to any of the tkinter classes. This module is not designed to be imported by python scripts.\ntkinter provides python-based classes that use the embedded tcl\/tk interpreter. This is the module that defines Tk, Button, Text, etc.","Q_Score":0,"Tags":"python-3.x,tkinter","A_Id":57184692,"CreationDate":"2019-07-24T09:38:00.000","Title":"What is the difference between the _tkinter and tkinter modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Some modules (for example lxml) return ModuleNotFoundError when I run code with them using python3 command. But when I use python3.6 command everything works well. Why it is so?\nP.S.\npython3 --version returns Python 3.7.2","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":47,"Q_Id":57180069,"Users Score":2,"Answer":"This is due to your environment variables pointing python to 3.7.2 you probably have python 3.6 installed too but your python is pointing to 3.7.2.\nYou can change it under the computer environment variables and changing to path of your python to your 3.6","Q_Score":0,"Tags":"python,python-3.x,python-3.6","A_Id":57180136,"CreationDate":"2019-07-24T09:51:00.000","Title":"ModuleNotFoundError when i use python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a Django app which uses Django's builtin authentification system which works normally till I deploy it in a production environment. \nI now got this error whenever I try to login or register a user:\n\nProgrammingError at \/login\nrelation \"auth_user\" does not exist\nLINE 1: ...user\".\"is_active\", \"auth_user\".\"date_joined\" FROM \"auth_user...\nAll other aspects of my web app work correctly and so I'm unsure what to do.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":57180112,"Users Score":1,"Answer":"You'll need to run python migrate [appName] in production to create the necessary tables.","Q_Score":0,"Tags":"python,django","A_Id":57180160,"CreationDate":"2019-07-24T09:54:00.000","Title":"Unable to use Django Authentication System in Deployment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have created a Django app which uses Django's builtin authentification system which works normally till I deploy it in a production environment. \nI now got this error whenever I try to login or register a user:\n\nProgrammingError at \/login\nrelation \"auth_user\" does not exist\nLINE 1: ...user\".\"is_active\", \"auth_user\".\"date_joined\" FROM \"auth_user...\nAll other aspects of my web app work correctly and so I'm unsure what to do.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":57180112,"Users Score":0,"Answer":"use both\npython manage.py makemigrations\npython manage.py migrate,\nand checkout in database django_session should be there, if not delete migrations file in migrations folder and do above 2 steps again.","Q_Score":0,"Tags":"python,django","A_Id":57182355,"CreationDate":"2019-07-24T09:54:00.000","Title":"Unable to use Django Authentication System in Deployment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to fit one function to another function by adjusting two parameters. But I dont know the form of this function. I have only cost function because for computation of this function is used LAMMPS (molecular dynamics). I need some tool which i can give only cost function and my guess and then it would minimize it.\nI was looking on SciPy optimization but it looks like it needs the original function which i dont have.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":57180431,"Users Score":0,"Answer":"A function approximation algorithm needs you to make a few assumptions about how your mathematical model behaves.\nIf you see things from a black box point of view, three scenarios can occur - \nX -> MODEL -> Y\n\nYou have the X and MODEL, but you dont have the Y; This is simulation\nYou have the MODEL and Y, but you dont have the X; This is Optimization\nYou have the X and Y, but you dont have the MODEL; This is mathematical modelling\n\nHowever there is a catch. You can NEVER do 3. directly. Instead you use a trick to reframe the 3. as a 2. (optimization problem). The trick is to say that you assume your model to be something like y=mx+c, and then instead of finding the model you find new inputs m and c. Thus, we can instead say - \n\nYou have the (MODEL, X) and Y but you dont have M,C (New inputs); This is optimization as well.\n\n(M,C) -> (MODEL + X) -> Y\nThis means, that even if you dont know the input function, you have to assume some model and then estimate the parameters which when tuned, let the model behave as the close to the input function as possible.\nBasically, what you need is machine learning. You have the inputs, you have the outputs (or you can get them but running your first function with a large sample of outputs), you have the cost function. Assume a model, and train it to approximate your input function.\nIf you are not sure what to use, then use a generalized function approximator AKA neural networks. But beware, it needs a lot more data to train.","Q_Score":0,"Tags":"python,scipy,minimization,scipy-optimize","A_Id":57180683,"CreationDate":"2019-07-24T10:10:00.000","Title":"Minimization of known cost function without knowing original function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"On machine with windows if u hold alt key and type 1071 on keypad u'll get \/ symbol alt+1069 = - and etc\nHow do i convert those codes to symbols in python 2?\nI tried to use unichr() but it returns wrong symbols.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1351,"Q_Id":57181134,"Users Score":0,"Answer":"Unicode is different from alt codes, they use different numbers but can generate the same characters (I'm pretty sure).","Q_Score":0,"Tags":"python,keycode","A_Id":63639828,"CreationDate":"2019-07-24T10:48:00.000","Title":"Decode Alt codes with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am able to call C# methods successfully from Robot Framework using IronPython however I am facing few runtime errors on the C# side which I want to debug using Visual Studio. Is there a way to debug C# application using Visual Studio when its method invoked through external program\/script?\nI have configured my C# project in Visual Studio using Start External Program (provided the robot executable path and arguments as required by external program). When I started debugging then my external program executes as expected with C# methods also executed successfully. However breakpoints which I have set in the Visual Studio doesn't get hit. \nIs there any specifics I am missing while using Start External Program? My python script (external program) is importing DLL from same location where it\u2019s getting generated while building C# project. PDB files also available in the same folder as DLL.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":229,"Q_Id":57182412,"Users Score":2,"Answer":"For me breakpoints was not hitting because I haven't attached the correct process. Let me explain in detail for other users to understand the root cause.\nAs I mentioned in my question that I was calling C# methods from Robot Framework using IronPython. Therefore I had used robot.exe (Robot Framework executable) as my external program (in the Visual Studio) and I expect my breakpoints to be hit under C# project. However the issue was that C# method executed by ipy.exe (Iron Python) not by robot.exe. It looks like Robot Framework starts ipy.exe process internally and then ipy process invokes C# methods. That means I should have attached ipy.exe process to my C# project so that control will come to Visual Studio whenever breakpoints hit.\nTo achieve the same I have done the following. I have inserted Debug.Assert at start of my C# code to halt the execution. Now I have started my external program (Robot Framework Test Case) and then during execution, Message Box appears due to Debug.Assert statement in the C# project. At this moment I have attached the ipy.exe(Iron Python) process to my C# project using Visual Studio using Debug --> Attach to Process. Afterwards when I went ahead with code execution by ignoring the message box then control comes to the breakpoints in the Visual Studio.","Q_Score":2,"Tags":"c#,visual-studio,robotframework,ironpython,visual-studio-debugging","A_Id":57230285,"CreationDate":"2019-07-24T12:00:00.000","Title":"Breakpoints not hit when C# application called from external program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using spotfire and ironpython.\nI've created a calculated value  (dynamic item) to know max date that match a condition in my data. \nI also have a ironpython script to do some things and part of this script must use the date from the calculated value.\nI'm trying to have python code to get the information from calculated value, but I'm struggling with it. \nI couldn't do it \"directly\", so, now, I'm trying a work around... To create a document property to receive the calculated value  and use this document property as enter parameter in the script, but I couldn't find a way to use calculated value as source of information of property document. \nSo... Is there a way to use calculated value inside ironpython script (directly or linking its value to a document property and using this document property as script parameter)?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2257,"Q_Id":57183734,"Users Score":1,"Answer":"You are headed down the right path.  You have to pass it to a document property.  You can't use the calculated value.","Q_Score":1,"Tags":"ironpython,spotfire","A_Id":57208563,"CreationDate":"2019-07-24T13:08:00.000","Title":"Spotfire: How to use calculated value (dynamic item) in ironpython script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to multi-thread some tasks using cosmosdb to optimize ETL time, and I can't find how, using the python API (but I could do something in REST if required) if I have a stored procedure to call twice for two partitions keys, I could send it to two different regions (namely 'West Europe' and 'Central France)\nI defined those as PreferredLocations in the connection policy but don't know how to include to a query, the instruction to route it to a specific location.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":57183790,"Users Score":1,"Answer":"The only place you could specify that on would be the options objects of the requests. However there is nothing related to the regions.\nWhat you can do is initialize multiple clients that have a different order in the preferred locations and then spread the load that way in different regions.\nHowever, unless your apps are deployed on those different regions and latency is less, there is no point in doing so since Cosmos DB will be able to cope with all the requests in a single region as long as you have the RUs needed.","Q_Score":0,"Tags":"python,rest,azure-cosmosdb","A_Id":57185813,"CreationDate":"2019-07-24T13:11:00.000","Title":"How to send a query or stored procedure execution request to a specific location\/region of cosmosdb?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been successfully using the Python Tweepy library to download data (tweets) from Twitter. I had substantial help with my code using Tweepy. For the next stage of my research, I need to access the Premium Search API, which I cannot do using Tweepy. Twitter recommends using TwitterAPI for premium search, available from @geduldig on GitHub. The problem is I'm new to Python and it would be a steep learning curve for me to learn TwitterAPI. Am I able to use TwitterAPI just to access the premium search API, but use Tweepy for other tasks (implement search query, etc)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":57186757,"Users Score":0,"Answer":"I do not know specifics about the libraries you asked, but of course, you could use both the libraries in your program. \nYou need to spend a little bit more time grokking the TwitterAPI library. I do not think that amounts to a steep learning curve.","Q_Score":0,"Tags":"python,github,twitter,tweepy,twitterapi-python","A_Id":57186922,"CreationDate":"2019-07-24T15:45:00.000","Title":"Python Novice: where to start with Python and TwitterAPI","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":"Python script not running from SQL Server Agent\nthe python script makes use of the requests library (installed)\nwhen i run from CMD :\npython \"C:\\Program Files (x86)\\Python37-32\\main.py\"\nthis works fine.\nwhen i run it from SQL agent as an Operating System (CmdExec) all i get is \"System cannot find the file specified\"\ni have set the enviorment paths.\nI have created a proxy account (sys admin)\ni have copied the requests library so its in the same folder as Python.\nnothing is working\n37 failed attempts today , and counting !\ncan anyone assist>\npython \"C:\\Program Files (x86)\\Python37-32\\main.py\"","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":106,"Q_Id":57187789,"Users Score":-1,"Answer":"i managed to get it working.\nmanually moved some libraries around in python.","Q_Score":0,"Tags":"python-2.7","A_Id":57218865,"CreationDate":"2019-07-24T16:48:00.000","Title":"Executing a python script from SQL Server Agent","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I wanted to use pandas-profiling to do some eda on a dataset but I'm getting an error : AttributeError: 'DataFrame' object has no attribute 'profile_report'\nI have created a python script on spyder with the following code : \nimport pandas as pd\nimport pandas_profiling\ndata_abc = pd.read_csv('abc.csv')\nprofile = data_abc.profile_report(title='Pandas Profiling Report')\nprofile.to_file(output_file=\"abc_pandas_profiling.html\")\nAttributeError: 'DataFrame' object has no attribute 'profile_report'","AnswerCount":8,"Available Count":2,"Score":0.024994793,"is_accepted":false,"ViewCount":14039,"Q_Id":57193292,"Users Score":1,"Answer":"This should work for those who want to use the latest version:\n\nRun pip uninstall pandas_profiling from anaconda prompt (given you're using Spyder, I'd guess this would be your case) \/ or command prompt\nRun pip install https:\/\/github.com\/pandas-profiling\/pandas-profiling\/archive\/master.zip\n\nIf you're using something like a Jupyter Notebook\/Jupyter Lab, be sure to restart your kernel and re-import your packages. \nI hope this helps.","Q_Score":4,"Tags":"python-3.x,pandas,pandas-profiling","A_Id":58828414,"CreationDate":"2019-07-25T02:01:00.000","Title":"Pandas-profiling error AttributeError: 'DataFrame' object has no attribute 'profile_report'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to use pandas-profiling to do some eda on a dataset but I'm getting an error : AttributeError: 'DataFrame' object has no attribute 'profile_report'\nI have created a python script on spyder with the following code : \nimport pandas as pd\nimport pandas_profiling\ndata_abc = pd.read_csv('abc.csv')\nprofile = data_abc.profile_report(title='Pandas Profiling Report')\nprofile.to_file(output_file=\"abc_pandas_profiling.html\")\nAttributeError: 'DataFrame' object has no attribute 'profile_report'","AnswerCount":8,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":14039,"Q_Id":57193292,"Users Score":0,"Answer":"The only workaround I found was that the python script I made is getting executed from the command prompt and giving the correct output but the code is still giving an error in Spyder.","Q_Score":4,"Tags":"python-3.x,pandas,pandas-profiling","A_Id":57193306,"CreationDate":"2019-07-25T02:01:00.000","Title":"Pandas-profiling error AttributeError: 'DataFrame' object has no attribute 'profile_report'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with one project in python using Tensorflow. But I am very beginner in Tensorflow and OpenCV. Last day I tried to custom objects. But while training I am always getting one status. \n\"I0725 10:26:31.453798  5176 supervisor.py:1117] Saving checkpoint to path traini\nng\/model.ckpt\".\nI don't know I what exactly happening, Is this error or not?\nI already waited around 10 hours. But now also getting this same status.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":352,"Q_Id":57194634,"Users Score":0,"Answer":"This message is informative. It's just telling you, that the checkpoint of the model you're training was saved. In case you find the model \"getting worse\" from that checkpoint, you can cancel the training with the latest best version of the model saved.\nLook for some tutorials for how to find out when the model is not getting better. Get familiar with terms like overfitting\/overtraining, etc. to understand the process itself.","Q_Score":0,"Tags":"python,opencv,tensorflow,deep-learning,artificial-intelligence","A_Id":57195148,"CreationDate":"2019-07-25T05:01:00.000","Title":"While train the model always getting \"Saving checkpoint to path training\/model.ckpt\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to transfer an image saved to a raspberry pi from the rpi to an android application to display it. I am treating the raspberry pi as the server and the android app as the client. My server side is implemented using python. I am using pylab to save a figure to the raspberry pi and then later open the image and read the contents as a byte array. This byte array is then passed to the android app, written in java. \nI can view the image on the rpi when I open it, but once it is sent to the android, something is happening to it that causes the incorrect number of bytes to be read and the image to be corrupted. I realized that java reads big endian while the raspberry pi byte order is little endian. I am not sure if this is what is causing the problem in transferring the image? \nSo, I am wondering if there is a way to either encode the byte array as big endian when it is sent from python or a way to decode the byte array as little endian when it is received by java. I tried simply reversing the image byte array in python but that did not work. Any suggestions would be very helpful!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":448,"Q_Id":57197445,"Users Score":0,"Answer":"I am not an expert in hardware differences between a Pi and other platforms, but this process can be performed using ByteBuffer.\nYou can get an instance of ByteBuffer using ByteBuffer.wrap(byteArray) or ByteBuffer.allocate(capacity).\nYou can then set the endian-ness of the buffer using buffer.order(ByteOrder.BIG_ENDIAN); or buffer.order(ByteOrder.LITTLE_ENDIAN);\nThe data can then be returned with buffer.get().","Q_Score":0,"Tags":"java,python,tcp,raspberry-pi,endianness","A_Id":57197538,"CreationDate":"2019-07-25T08:24:00.000","Title":"Convert Image from Little to Big Endian","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 have a GUI python script that runs perfectly well when I run it in the terminal, however I would like to remove the need to use terminal and just be able to click on an icon (like an application) to have the script run and open the GUI. Is there any way to do this? (detail appreciated) Thanks!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":137,"Q_Id":57197479,"Users Score":0,"Answer":"Yes, I found Pyinstaller to be the easiest to use. From terminal just do 'pip install pyinstaller'. Then once it's downloaded cd to the directory that contains the file. From there just run 'pyinstaller file-name' and it will create it for you :)","Q_Score":1,"Tags":"python,user-interface,tkinter,desktop-application","A_Id":57197592,"CreationDate":"2019-07-25T08:26:00.000","Title":"Is there a way to run a python script by clicking on an icon on e.g. the desktop?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am supposed to determine the direction of a boat from drone imagery, whether it's docked from the front or from the back\nI tried to split the bbox of the boat image, use binary images by thresholding the boat bbox,\nand i tried to split the bbox into two half, calculate the sum of blue pixels in every half sinc the front part of the boat will have more water i the image due to the triangle shape, but it didn't work\nMy question is, how can I determine the correct direction of the boat using image processing techniques","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":472,"Q_Id":57199641,"Users Score":0,"Answer":"use semantic segmentation to detect the dock\nand a keypoint method to detect the boats, this method is usually used for face recognition but I think it would help in your case","Q_Score":1,"Tags":"python-3.x,opencv,image-processing","A_Id":57200350,"CreationDate":"2019-07-25T10:18:00.000","Title":"How to determine object orientation in image?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run a python program through bamboo.\nHow do I install python dependency modules through bamboo\nI need to install some python modules like flask , xldr etc.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1348,"Q_Id":57201320,"Users Score":1,"Answer":"You have two options:\n\nRemote or log into the Bamboo agent and manually install the modules.  This is a one time install and then they will be there for the task to use in the future.\nRun the job using a Docker host instead of the local agent.  Then you can specify all the dependencies in the Docker image that is used to build (e.g., Python version, imports).","Q_Score":0,"Tags":"python,module,bamboo","A_Id":57202186,"CreationDate":"2019-07-25T11:50:00.000","Title":"How do I install python dependency modules through bamboo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to find ways to improve performance of machine learning models either binary classification, regression or multinomial classification.\nI'm now looking at the topic categorical variables and trying to combine low occuring levels together. Let's say a categorical variable has 10 levels where 5 levels account for 85% of the total frequency count and the 5 levels remaining account for the 15% remaining.\nI'm currently trying different thresholds (30%, 20%, 10%) to combine levels together. This means I combine together the levels which represent either 30%, 20% or 10% of the remaining counts.\nI was wondering if grouping these \"low frequency groups\" into a new level called \"others\" would have any benefit in improving the performance.\nI further use a random forest for feature selection and I know that having fewer levels than orignally may create a loss of information and therefore not improve my performance.\nAlso, I tried discretizing numeric variables but noticed that my performance was weaker because random forests benefit from having the hability to split on their preferred split point rather than being forced to split on an engineered split point that I would have created by discretizing.\nIn your experience, would grouping low occuring levels together have a positive impact on performance ? If yes, would you recommend any techniques ?\nThank you for your help !","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":392,"Q_Id":57203915,"Users Score":0,"Answer":"This isn't a programming question... By having fewer classes, you inherently increase the chance of randomly predicting the correct class. \nConsider a stacked model (two models) where you have a primary model to classify between the overrepresented classes and the 'other' class, and then have a secondary model to classify between the classes within the 'other' class if the primary model predicts the 'other' class.","Q_Score":0,"Tags":"python,machine-learning","A_Id":57204226,"CreationDate":"2019-07-25T14:04:00.000","Title":"Grouping low frequency levels of categorical variables to improve machine learning performance","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new here and I'm not at a high programming level...\nI have a problem with the developing of a web application using flask and html. In the same html page I have some input boxes (that will be compiled by a user) and their content would be inserted inside a select that initially is empty. In addition I have no submit button and I could not insert it in my app because of the will of my boss. Is there a way to do this?\nI've tried searching through the web for hours, but still nothing... Is there someone that could help me?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":57204382,"Users Score":0,"Answer":"Add onblur function to input box and write function to insert their content. You can use onfocusout function also.","Q_Score":0,"Tags":"python,html,http,flask,web-applications","A_Id":57204912,"CreationDate":"2019-07-25T14:28:00.000","Title":"Inputs inside multiple forms with no submit button need to be displayed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to use XMP Toolkit for manipulating my jpg files' metadata. \nBy installing, I need Exempi and boost, but I am somewhat stuck at installation of them. I tried to install them with brew, but documentation says exempi needs boost to compile \n\n\".\/configure --with-boost=\/usr\/local # (for Homebrew)\" .\n\nWhat should I do now? Could someone be so kind and help me, maybe with a little step-by step guide for noobs? Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":132,"Q_Id":57204621,"Users Score":1,"Answer":"Try running brew install exempi and homebrew should install Boost and other dependencies that are needed.","Q_Score":2,"Tags":"python-3.x","A_Id":58531449,"CreationDate":"2019-07-25T14:40:00.000","Title":"How to install XMP Toolkit on mac os x mojave","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"The form that I need to do is for the user to select a payment type.The problem is that depending on the choice if the user wants to pay monthly or annually a different date-picker field has to appear. if he selects monthly, he has to choose a day of the month. And if he chooses annually a date-picker that allows him to pick the month has to appear.\nI've been searching online for an answer but all I can find is dynamic form in the sense that it can generate a field type multiples times and that is not what I need.\nAll help is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":57204696,"Users Score":0,"Answer":"The way I'd approach this is to have optional fields for both the month and year pickers, but use Javascript to hide the one you don't want the user to see based on the value in the payment type. Then, in the clean method of the form, I'd validate that correct field was filled in (maybe raise a ValidationError if the both were filled?).\nAlternatively, depending on what you're actually storing as a result from the datepicker (just the year or month?) maybe it'd be simpler to just dynamically update the datepicker's configuration based on the payment type field's value.\nIt's a little tricky to give you more specific suggestions without having more information about how you've setup your code.","Q_Score":0,"Tags":"python,django,django-forms","A_Id":57204931,"CreationDate":"2019-07-25T14:44:00.000","Title":"I need to do a form that changes on-the-fly depending of a choice","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I trained a Forward Neural Net for binary classification and I got an accuracy of 83%, which (I hope)I'm going to improve later by changing parameters in inputs.  But some tests make me feel confused :\n\nMy dataset length is 671 so I divide it as 513 train set, 58 Validation set and 100 test set \n\n\nWhen I change the size of my sets (Train, Validation, Test), the accuracy score can decrease to some very low scores like 40% \nThe neural net is supposed to learn from the train set but when I test, after the training, with the same Train set and not the Test set, I thought that the model should score 100 %, because he just learned from it, watched it, but it only improves a few with 87% ...\n\nI'm a beginner in ML so I don't know if it's normal or not, I'm just curious and wanna catch all the small things to know, to understand perfectly what I'm doing. I guess it's maybe the normalization of my vectors sets, but I don't know very much about it. I can share you my full code if you want to, but as every neural net, it's quite long but easy to read.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":380,"Q_Id":57205718,"Users Score":1,"Answer":"OP: Your questions are very good for someone that's just getting started in machine learning.\n\nHave you ensured that the distribution of your training and test dataset are similar? I would try to keep the number of samples per class (label) about equal if possible. For instance, if your training set is severely imbalanced then your prediction algorithm might tend to favor the label that shows up more often.\nI think you are on the right track to overfit your model to ensure your neural net architecture, training and whatever else is setup correctly. Are you using regularization? If so, I think you might want to remove that to see if your model can fit to your training dataset. I understand that this goes against what the accepted answer's #2 suggests but this is a useful way to debug your setup\nHow good are the labels for your dataset? If you have any noise in your labels then that would affect the accuracy of your classifier\nYou could also try transfer learning if you cannot get more training data","Q_Score":0,"Tags":"python,machine-learning,neural-network,dataset,normalization","A_Id":57207926,"CreationDate":"2019-07-25T15:37:00.000","Title":"How can we be sure of the efficiency of a neural network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I trained a Forward Neural Net for binary classification and I got an accuracy of 83%, which (I hope)I'm going to improve later by changing parameters in inputs.  But some tests make me feel confused :\n\nMy dataset length is 671 so I divide it as 513 train set, 58 Validation set and 100 test set \n\n\nWhen I change the size of my sets (Train, Validation, Test), the accuracy score can decrease to some very low scores like 40% \nThe neural net is supposed to learn from the train set but when I test, after the training, with the same Train set and not the Test set, I thought that the model should score 100 %, because he just learned from it, watched it, but it only improves a few with 87% ...\n\nI'm a beginner in ML so I don't know if it's normal or not, I'm just curious and wanna catch all the small things to know, to understand perfectly what I'm doing. I guess it's maybe the normalization of my vectors sets, but I don't know very much about it. I can share you my full code if you want to, but as every neural net, it's quite long but easy to read.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":380,"Q_Id":57205718,"Users Score":1,"Answer":"As suggested by many people 3:1:1 (60:20:20 = train-validate-test) ratio is a thumb rule to split data, if you are playing with small data set it better to stick with 80:20 or 70:30 just train-test,I usually go for 90:10 ratio for better results.\nBefore you start with classification, first check whether your data set is balanced or imbalanced ( there should not be less example belongs to one class as compared to other ) because even though it gives you good accuracy it will mislead the results.\nIf data set is imbalanced, pre-processed data set with sampling algorithm  (for e.g SMOTE) and re-sample it. It will create equal sets of examples for class based on neighbors.\nAs correctly mentioned in other answer, use cross validation classification such as K-fold. The concept of cross validation is done to tweak the parameters used for training in order to optimize its accuracy and to nullify the effect of over-fitting on the training data, it also remove the noise in data set. I usually go for 10-fold cross validation where data set divided in 10 partition and in each iteration 1\/10 partition use as test and rest as training. Take the average of the 10 computations to get a good estimate of the performance of your classifier.","Q_Score":0,"Tags":"python,machine-learning,neural-network,dataset,normalization","A_Id":57211888,"CreationDate":"2019-07-25T15:37:00.000","Title":"How can we be sure of the efficiency of a neural network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two buttons named  'button1' and 'button2'('button1' is created and then 'button2' is created) . They called respectively the functions 'function1' and 'function2'.When the user press the two buttons , does python run these two functions simultaneously, or successively following the order in which the buttons were pressed?\nI want to know that because the 'function1' fills an Excel file and the 'function2' must read this Excel file.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14,"Q_Id":57206981,"Users Score":0,"Answer":"Tkinter is single-threaded, it only does one thing at a time. The functions will be executed in the order that they were called.","Q_Score":0,"Tags":"python-3.x,tkinter","A_Id":57207556,"CreationDate":"2019-07-25T17:02:00.000","Title":"Order of execution of different functions called by different buttons","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training using the Tensorflow Object Detection API in Google Colab. I want to suppress printing the loss at each step as the web page crashes after 30 minutes due to a large amount of text being printed as the output of the cell. I have to manually clear the output of the cell every 30 minutes or so to avoid this issue. Is there any way to modify the train.py code so that Tensorflow stops printing the loss at every step. I have tried changing the code in line 57 of the research\/object_detection\/legacy\/train.py from tf.logging.set_verbosity(tf.logging.INFO) to tf.logging.set_verbosity(tf.logging.WARN) but it did not seem to work. Any suggestions\/workarounds?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":290,"Q_Id":57207729,"Users Score":2,"Answer":"add ; if thats the print statement at the end of the print statement\nAdd %%capture in the first line of the cell for no print for the cell\nand for speficic function\nfrom IPython.utils import io\nwith io.capture_output() as captured:\n    function()","Q_Score":0,"Tags":"python,tensorflow,deep-learning,google-colaboratory,object-detection-api","A_Id":57208228,"CreationDate":"2019-07-25T17:54:00.000","Title":"How to prevent printing loss at each step while using the tensorflow object detection api?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"A project I recently joined, for various reasons, decided not to use Django migration system and uses our own system (which is similar enough to Django's that we could possibly automate translations)\nPrimary Question\nIs it possible to start using Django's migration system now?\nMore Granular Question(s)\nIdeally, we'd like to find some way of saying \"all our tables and models are in-sync (i.e. there is no need to create and apply any migrations), Django does not need to produce any migrations for any existing model, only for changes we make.\n\n\nIs it possible to do this?\n\nIs it simply a case of \"create the django migration table, generate migrations (necessary?), and manually update the migration table to say that they've all been ran\"?\n\nWhere can I find more information for how to go about doing this? Are there any examples of people doing this in the past?\n\n\nRegarding SO Question Rules\nI didn't stop to think for very long about whether or not this is an \"acceptable\" question to ask on SO. I assume that it isn't due to the nature of the question not having a clear, objective set of criteria for a correct answer. however, I think that this problem is surely common enough, that it could provide an extremely valuable resource for anyone in my shoes in the future. Please consider this before voting to remove.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":143,"Q_Id":57209118,"Users Score":1,"Answer":"I think you should probably be able to do manage.py makemigrations (you might need to use each app name the first time) which will create the migrations files.  You should then be able to do manage.py migrate --fake which will mimic the migration run without actually impacting your tables.  \nFrom then on (for future changes), you would run makemigrations and migrate as normal.","Q_Score":0,"Tags":"python,django,django-models,orm,django-migrations","A_Id":57209384,"CreationDate":"2019-07-25T19:40:00.000","Title":"Is it possible to start using Django's migration system after years of not using it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a table I need to add columns to it, one of them is a column that dictates business logic. So think of it as a \"priority\" column, and it has to be unique and a integer field. It cannot be the primary key but it is unique for business logic purposes.\nI've searched the docs but I can't find a way to add the column and add default (say starting from 1) values and auto increment them without setting this as a primarykey..\nThus creating the field like\n\nexample_column =  IntegerField(null=False, db_column='PriorityQueue',default=1)\n\nThis will fail because of the unique constraint. I should also mention this is happening when I'm migrating the table (existing data will all receive a value of '1')\nSo, is it possible to do the above somehow and get the column to auto increment?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":252,"Q_Id":57209258,"Users Score":1,"Answer":"It should definitely be possible, especially outside of peewee. You can definitely make a counter that starts at 1 and increments to the stop and at the interval of your choice with range(). You can then write each incremented variable to the desired field in each row as you iterate through.","Q_Score":1,"Tags":"python,python-3.x,peewee","A_Id":57209625,"CreationDate":"2019-07-25T19:50:00.000","Title":"Peewee incrementing an integer field without the use of primary key during migration","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a table I need to add columns to it, one of them is a column that dictates business logic. So think of it as a \"priority\" column, and it has to be unique and a integer field. It cannot be the primary key but it is unique for business logic purposes.\nI've searched the docs but I can't find a way to add the column and add default (say starting from 1) values and auto increment them without setting this as a primarykey..\nThus creating the field like\n\nexample_column =  IntegerField(null=False, db_column='PriorityQueue',default=1)\n\nThis will fail because of the unique constraint. I should also mention this is happening when I'm migrating the table (existing data will all receive a value of '1')\nSo, is it possible to do the above somehow and get the column to auto increment?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":57209258,"Users Score":0,"Answer":"Depends on your database, but postgres uses sequences to handle this kind of thing. Peewee fields accept a sequence name as an initialization parameter, so you could pass it in that manner.","Q_Score":1,"Tags":"python,python-3.x,peewee","A_Id":57210489,"CreationDate":"2019-07-25T19:50:00.000","Title":"Peewee incrementing an integer field without the use of primary key during migration","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I right-click a .py file and select Run Code I get \"The system cannot find the path specified.\"  If I right-click and select Run Python File in Terminal it works great!  Any clues?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1637,"Q_Id":57209830,"Users Score":0,"Answer":"I assume the Run Code you mentioned is run without debugging, if your folder or file name contains & symbol it'll confuse terminal to look up the file\/folder. I realised it showed && while looking the folder\/file....that's what I solved my case","Q_Score":1,"Tags":"python","A_Id":64628460,"CreationDate":"2019-07-25T20:38:00.000","Title":"Python Run Code in VS Code results in system cannot find the path specified","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python code in PyCharm in which i am using\nimport requests\nbut the terminal is showing me the following error:\n(venv) ahmad@Ahmad:~\/Desktop\/Spiders$ python test.py\nTraceback (most recent call last):\n  File \"test.py\", line 1, in \n    import requests\nModuleNotFoundError: No module named 'requests'\nBut I have installed pip and requests as well.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":19489,"Q_Id":57212573,"Users Score":0,"Answer":"You can just found the icon of Search in right highest corner and search for 'import modules'. Then click on \"Project: [YOUR_PROJECT]\" choose 'Python Interpreter' and then click on 'plus' button. Thus you can install 'requests' module manually.\n(Some sites say that you can call Search by pressing Alt + Enter, but it doesn`t work in my case)","Q_Score":4,"Tags":"python,pip,python-requests","A_Id":68539185,"CreationDate":"2019-07-26T02:58:00.000","Title":"ModuleNotFoundError: No module named 'requests' in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python code in PyCharm in which i am using\nimport requests\nbut the terminal is showing me the following error:\n(venv) ahmad@Ahmad:~\/Desktop\/Spiders$ python test.py\nTraceback (most recent call last):\n  File \"test.py\", line 1, in \n    import requests\nModuleNotFoundError: No module named 'requests'\nBut I have installed pip and requests as well.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":19489,"Q_Id":57212573,"Users Score":0,"Answer":"I had to go to the CLi (command line) and run \">pip install requests\" - this after trying unsuccessfully from the Pycharm 'Setting\/Interpreter' gui menu.","Q_Score":4,"Tags":"python,pip,python-requests","A_Id":69285809,"CreationDate":"2019-07-26T02:58:00.000","Title":"ModuleNotFoundError: No module named 'requests' in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python code in PyCharm in which i am using\nimport requests\nbut the terminal is showing me the following error:\n(venv) ahmad@Ahmad:~\/Desktop\/Spiders$ python test.py\nTraceback (most recent call last):\n  File \"test.py\", line 1, in \n    import requests\nModuleNotFoundError: No module named 'requests'\nBut I have installed pip and requests as well.","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":19489,"Q_Id":57212573,"Users Score":8,"Answer":"you can use this : \njust go to file > sitting > project : name > project interpreter > add > search and install","Q_Score":4,"Tags":"python,pip,python-requests","A_Id":57226478,"CreationDate":"2019-07-26T02:58:00.000","Title":"ModuleNotFoundError: No module named 'requests' in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Every once in a while, the temp folder on my deployment server seems to go missing. I am using Flask and Newspaper on AWS elastic beanstalk. I am using the Newspaper library to scrape meta tags from external urls.\nError on the server:\n{'code_content': 500, 'error': \"[Errno 2] No such file or directory: '\/tmp\/.newspaper_scraper\/article_resources'\"}\nEverything works fine after the server is restared. Is there a config setting that might fix this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":163,"Q_Id":57212589,"Users Score":2,"Answer":"We've had a similar problem using AWS Elastic Beanstalk platform \"Java 8 running on 64bit Amazon Linux\". There was a daily cron-job (\/etc\/cron.daily\/tmpwatch) running that deletes all files in the \/tmp folder that are older than 10 days.\nTry placing the .newspaper_scraper folder somewhere else.","Q_Score":1,"Tags":"flask,amazon-elastic-beanstalk,python-newspaper","A_Id":65408641,"CreationDate":"2019-07-26T03:00:00.000","Title":"Missing temp folder in elastic beanstack with newspaper library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a consumer application written in python. It consume the rabbitmq messages through multiprocessing. But when I try to process or validate those messages with in the on_message callback function then the consumption is bit slow. I am opening an excel mapping file to validate those incoming messages through a separate message class. Any help? Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":222,"Q_Id":57214978,"Users Score":0,"Answer":"since I can't comment yet I ll write to you here what I think about the pub. I think your Question is not clear. Besides I think you should show some Code and explain further what you are trying to achieve. what is meant by consumption is a bit slow ? like how exactly ? and which Pika version are you using etc.. this can be Important to look up what can provoque this \"slow\" Error that you have. Besides I think Pika is buggy for the 0. version, while using it I had some issues sometimes and it is not thread safe.","Q_Score":0,"Tags":"python,rabbitmq,producer-consumer,xlrd,pika","A_Id":57218571,"CreationDate":"2019-07-26T07:18:00.000","Title":"Pika message consumption is slow while processing messages in callback 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 have a list of url and many of them are invalid. When I use scrapy to crawl, the engine will automatically filter those urls with 404 status code, but some urls' status code aren't 404 and will be crawled so when I open it, it says something like there's nothing here or the domain has been changed, etc. Can someone let me know how to filter these types of invalid urls?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1284,"Q_Id":57216139,"Users Score":0,"Answer":"In your callback (e.g. parse) implement checks that detect those cases of 200 responses that are not valid, and exit the callback right away (return) when you detect one of those requests.","Q_Score":0,"Tags":"python,scrapy,web-crawler","A_Id":57308027,"CreationDate":"2019-07-26T08:32:00.000","Title":"How to check if a url is valid in Scrapy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there any way to log in Windows using pywinrm without password? If I can login the machine using my private key in pywinrm instead of password.\nI want to log in a Windows server form Linux, and I use pywinrm in python to do the work, but I need to provide the password, is there any way to log in without password?\ns = winrm.Session(hostIP,auth=(user,passWord), transport='ntlm')\nI want to find a way without password, such as use the private key store in my local Linux machine. Is this possible?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":174,"Q_Id":57216268,"Users Score":-1,"Answer":"No there is for this way. If you use Session you have to authorized . If it possible , telling the way of this is not ethichal movement for this web site.","Q_Score":0,"Tags":"python,linux,key,winrm","A_Id":57216542,"CreationDate":"2019-07-26T08:40:00.000","Title":"how to login windows using pywinrm whithout password, If I can login the machine using my private key in pywinrm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried to connect it with SVN in aws ec2. It is showing Network timeout. After that i tried scp to transfer again it is showing the same error connection refused.  Then i tried AWS S3 ec2 copy command to copy the file from local machine to S3 bucket but again it is showing the same error.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13,"Q_Id":57218711,"Users Score":0,"Answer":"The approach which I use to move code or files from local server to ec2 instance is git.\nIt maintains my file changes with proper commit messages as well as a proper set of revisions or iterations I have done until now.","Q_Score":0,"Tags":"python-3.x","A_Id":57218757,"CreationDate":"2019-07-26T11:01:00.000","Title":"AWS to local machine file sharing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Using pyarrow I can write parquet files of version 2.0.\npyarrow.parquet.write_table method has parameter 'version'. But there is no parameter 'version' for pyarrow.parquet.read_table method. And seems like it only can read parquet files of version 1.0.\nHow to read parquet files of version 2.0 with pyarrow?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":57219611,"Users Score":0,"Answer":"pyarrow.parquet.read_table can read files written for Parquet version 2.0 automatically. No need to set parameter, this can be detected by reading the metadata of the given Parquet file.\nIn your specific case it is hard to give you an exact answer on why it seems that the read isn't working as you did not include any tracebacks in your question.","Q_Score":0,"Tags":"python,pandas,parquet,pyarrow","A_Id":57219950,"CreationDate":"2019-07-26T11:58:00.000","Title":"pyarrow read_table has no 'parquet version' parameter","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a flight delay dataset and try to split the set to train and test set before sampling. On-time cases are about 80% of total data and delayed cases are about 20% of that. \nNormally in machine learning ratio of train and test set size is 8:2. But the data is too imbalanced. So considering extreme case, most of train data are on-time cases and most of test data are delayed cases and   accuracy will be poor. \nSo my question is How can I properly split imbalanced dataset to train and test set??","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1879,"Q_Id":57229775,"Users Score":0,"Answer":"Start from 50\/50 and go on changing the sets as 60\/40, 70\/30, 80\/20, 90\/10. declare all the results and come to some conclusion. In one of my work on Flight delays prediction project, I used 60\/40 database and got 86.8 % accuracy using MLP NN.","Q_Score":1,"Tags":"python,machine-learning,train-test-split,imbalanced-data","A_Id":57230509,"CreationDate":"2019-07-27T06:34:00.000","Title":"How can I properly split imbalanced dataset to train and test set?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My gethostbyaddr() is giving a different host name from what I need. The host name that I need does not even show up in the alias list.\nSo, I was confused with the weird hostnames that I get when i try gethostbyaddr for different websites. \nSo, I tried getting the ip of amazon using gethostbyname. Then I used the resulting IP in gethostbyaddr() but I did not get the hostname of amazon. I read the official documentation and it states that the alias list returned contains the alternative host names, but I still do not get www.amazon.com\nSo This is what I tried doing.\nsocket.gethostbyname('www.amazon.com')\nAnd my result was: '13.35.134.162'\nThen I input this IP:\nsocket.gethostbyaddr('13.35.134.162')\nBut my result is:\n('server-13-35-134-162.del54.r.cloudfront.net', [], ['13.35.134.162'])\nCan someone explain why 'www.amazon.com' is not displayed and what is this hostname that I get?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":343,"Q_Id":57230607,"Users Score":1,"Answer":"A website name is not equal to hostname. There is no 1:1 relationship in general. One computer can serve many websites. OTOH a busy website is served by many computers (so called load balancing). CDNs (content delivery networks) use some BGP-4 tricks (BGP-4 = an important routing protocol) to connect you to a server geographically near you - they run several \"clones\" of a webiste in different locations.\nWhat are your needs? If you want to be sure you are connected to the right website, rely on HTTPS certificates.","Q_Score":0,"Tags":"python,python-3.x,sockets","A_Id":57230747,"CreationDate":"2019-07-27T08:47:00.000","Title":"gethostbyaddr gives a different host name","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My gethostbyaddr() is giving a different host name from what I need. The host name that I need does not even show up in the alias list.\nSo, I was confused with the weird hostnames that I get when i try gethostbyaddr for different websites. \nSo, I tried getting the ip of amazon using gethostbyname. Then I used the resulting IP in gethostbyaddr() but I did not get the hostname of amazon. I read the official documentation and it states that the alias list returned contains the alternative host names, but I still do not get www.amazon.com\nSo This is what I tried doing.\nsocket.gethostbyname('www.amazon.com')\nAnd my result was: '13.35.134.162'\nThen I input this IP:\nsocket.gethostbyaddr('13.35.134.162')\nBut my result is:\n('server-13-35-134-162.del54.r.cloudfront.net', [], ['13.35.134.162'])\nCan someone explain why 'www.amazon.com' is not displayed and what is this hostname that I get?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":343,"Q_Id":57230607,"Users Score":1,"Answer":"This has nothing to do with python, but rather how DNS works. A single IP address can host many web sites and thus have many host names. As a result, the name to IP lookup is not always reversible.","Q_Score":0,"Tags":"python,python-3.x,sockets","A_Id":57230754,"CreationDate":"2019-07-27T08:47:00.000","Title":"gethostbyaddr gives a different host name","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know when the weight of model updated while using gradient descent(in all three types of GD) but in my case I am using adam optimization with custom loss(triplet loss), when the weight get updated in the model in this case? Is it after every sample,every batch or every epochs?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":140,"Q_Id":57230643,"Users Score":1,"Answer":"Adam just changes how the gradient update is performed in gradient descent, it does not change when that happens, so its literally the same as in normal gradient descent.\nWhen using mini-batch gradient descent (the current standard), weight updates happen after every batch.","Q_Score":1,"Tags":"python-3.x,optimization,keras,deep-learning","A_Id":57231506,"CreationDate":"2019-07-27T08:53:00.000","Title":"When the weight of model get updated if I am using adam optimization?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to parse a page, keeping HTML and JS the same as in my own browser. Site must think, that I am logged using the same browser, I need to \"press\" some buttons using JS and find some elements.\nWhen using requests library or selenium.webdriver.Firefox(), site think I am from a new browser. But I think selenium must help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":57232605,"Users Score":0,"Answer":"Requests cannot process JavaScript, nor can it parse HTML and CSS to create a DOM. Requests is just a very nice abstraction around making HTTP requests to any server, but websites\/browsers aren't the only things that use HTTP.\nWhat you're looking for is a JavaScript engine along with an HTML and CSS parser so that it can create an actual DOM for the site and allow you to interact with it. Without these things, there'd be no way to tell what the DOM of the page would be, and so you wouldn't be able to click buttons on it and have the resulting JavaScript do what it should. \nSo what you're looking for is a web browser. There's just no way around it. Anything that does those things, is, by definition, a web browser. \nTo clarify from one of your comments, just because something has a GUI, that doesn't mean it isn't automatic. In fact, that's exactly what Selenium is for (i.e. automating the interactions with the GUI that is the web page). It's not meant to emulate user behavior exactly 1:1, and it's actually an abstraction around the WebDriver protocol, which is meant for writing automated tests. However, it does allow you to interact with the webpage in a way that approximates how a user would interact with it.\nYou may not want to see the GUI of the browser, but luckily, Chrome and Firefox have \"headless\" modes, and Selenium can control headless instances of those browsers. This would have the browser GUI be hidden while Selenium controls it, which sounds like what you're looking for.","Q_Score":0,"Tags":"python,selenium,parsing,web,browser","A_Id":57240490,"CreationDate":"2019-07-27T13:30:00.000","Title":"Navigate webpage as if from my browser (Python, selenium)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm want to remove the chinese characters of a text or any other any character that isnt Latin\ni tried using encoding='UTF-8' but dont works\nText Example: \nUm olhar maligno que s\u00f3 desejava a destrui\u00e7\u00e3o!\n\u201cParem-o!\u201d\nEle ordenou os dem\u00f4nios.\nOs dem\u00f4nios abriram suas asas, seguraram suas armas e lan\u00e7aram magia.\n\u03a3? ?\u0393\u03b1\u03c0? \u2026\u2026. \u201d\n\u0393\u03b5\u03b9? !!\nI want that return\nUm olhar maligno que s\u00f3 desejava a destrui\u00e7\u00e3o!\n\u201cParem-o!\u201d\nEle ordenou os dem\u00f4nios.\nOs dem\u00f4nios abriram suas asas, seguraram suas armas e lan\u00e7aram magia.\n? ?? \u2026\u2026. \u201d\n? !!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1280,"Q_Id":57232963,"Users Score":0,"Answer":"Try to use this extension of Latin encoding:\nISO 8859-2 (Latin 2)","Q_Score":0,"Tags":"python,unicode-string","A_Id":57233039,"CreationDate":"2019-07-27T14:16:00.000","Title":"Remove chinese characters","Data Science and Machine Learning":0,"Database and SQL":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":"Settings.py DEBUG=True\nBut the django web application shows Server Error 500.\nI need to see the error pages to debug what is wrong on the production server. \nThe web application works fine in development server offline.\nThe google logs does not show detail errors. Only shows the http code of the request.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":409,"Q_Id":57234950,"Users Score":0,"Answer":"Thank you all for replying to my question. The project had prod.py (production settings file, DEBUG=False) and a dev.py (development settings file). When python manage.py is called it directly calls dev.py(DEBUG=True). However, when I push to google app engine main.py is used to specify how to run the application. main.py calls wsgi.py which calls prod.pd (DEBUG=False). This is why the django error pages were not showing. I really appreciate you all. VictorTorres, Mahirq9 and ParthS007","Q_Score":0,"Tags":"python,django,google-compute-engine","A_Id":57312444,"CreationDate":"2019-07-27T18:25:00.000","Title":"Unable to view django error pages on Google Cloud web app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Do we have any way to get points on the forehead of a face image?\nI am using 68 points landmarks shape_predictor to get other points on the face but for this particular problem I need\npoints that are from the hairline to the center of the forehead.\nAny suggestions would be helpful.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":922,"Q_Id":57235066,"Users Score":0,"Answer":"you can use the tool provided with dlib called \"imgLab\" to train your own shape detector by performing landmark annotations","Q_Score":1,"Tags":"python,opencv,image-processing,deep-learning,dlib","A_Id":57388681,"CreationDate":"2019-07-27T18:39:00.000","Title":"Detect forehead points using Dlib\/python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"ERROR: Could not find a version that satisfies the requirement black==19.3b0 \n(from -r requirements.txt (line 5)) (from versions: none)\nERROR: No matching distribution found for black==19.3b0 (from -r requirements.txt (line 5))\nPlease help me to solve this error. \nI got this while  pip install -r requirements.txt and I use Mac","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1125,"Q_Id":57235210,"Users Score":1,"Answer":"You are getting error because you are trying to install black in python2.\nBut black is only supported by python3\nDo like this:\npip3 install black==19.3b0\nor \npip3 install -r requirements.txt","Q_Score":0,"Tags":"python,python-3.x,python-2.7","A_Id":57235236,"CreationDate":"2019-07-27T18:59:00.000","Title":"I have problem while installing requirement.txt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I create some django websites using Plesk Onyx. My problem is If I go to domainname.com\/appname\/settings.py or domainname.com\/manage.py url i see everything in \".py\" file. My folder permissions 755, file permissions is 644. The problem is solved when I set the file permissions to 640 or 600. Is there a shortcut in django related to this vulnerability? or do I need to change individual file permissions? I'm looking for an easy way. I don't know, maybe by adding a little code in django I can prevent these files from appearing. Im using python 3.6 - Django 2.2.3 - Plesk Onyx - Nginx","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":175,"Q_Id":57236028,"Users Score":1,"Answer":"in ur .htaccess file block directory browsing\n\nif want block specific extention\nIndexIgnore *.py *.txt\nblock full directory listing\nOptions -Indexes","Q_Score":0,"Tags":"python,django,apache,security,plesk","A_Id":57236467,"CreationDate":"2019-07-27T20:59:00.000","Title":"Plesk Django .py files showing in browser. How do I make it safe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a paper on which there are scans of documents, I use tesseract to recognize the text, but sometimes the images are in the wrong orientation, then I cut these documents from the sheet and work with each one individually, but I need to turn them in the correct position, how to do it?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":206,"Q_Id":57240300,"Users Score":1,"Answer":"If all scans are in same orientation on the paper, then you can always try rotating it in reverse if tesseract is causing the problem in reading. If individual scans can be in arbitrary orientation, then you will have to use the same method on individual scans instead.","Q_Score":0,"Tags":"python,opencv,image-processing","A_Id":57240854,"CreationDate":"2019-07-28T11:14:00.000","Title":"How to turn the image in the correct orientation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a paper on which there are scans of documents, I use tesseract to recognize the text, but sometimes the images are in the wrong orientation, then I cut these documents from the sheet and work with each one individually, but I need to turn them in the correct position, how to do it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":206,"Q_Id":57240300,"Users Score":1,"Answer":"I\u2019m not sure if there are simple ways, but you can rotate the document after you do not find adequate characters in it, if you see letters, then the document is in the correct orientation.\nAs I understand it, you use a parser, so the check can be very simple, if there are less than 5 keys, then the document is turned upside down incorrectly","Q_Score":0,"Tags":"python,opencv,image-processing","A_Id":58587214,"CreationDate":"2019-07-28T11:14:00.000","Title":"How to turn the image in the correct orientation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to import cv2 from the python modules in site packages.  \nI've seen other solutions where you add the module into the site packages directory for python, did pip install and was notified that it installed correctly. I also did a reinstall of the module and its opencv-contrib-python. \nWhen installing opencv-python and attempting to import cv2, I also recieved an error message that there was recursions in the ini file for open cv.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9627,"Q_Id":57243700,"Users Score":0,"Answer":"hi sir try doing this:\n\npip install opencv-python\n\ninstead of this:\n\npip install opencv-contrib-python\n\nhope this helps :)) i also had a problem installing it but fixed it easily. if you have any problems, feel free to ask more","Q_Score":0,"Tags":"python,opencv,import,cv2","A_Id":57253782,"CreationDate":"2019-07-28T18:10:00.000","Title":"Import cv2 missing - python3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am analyzing a real-estate dataset. While all regression assumptions fail, my XGBoosting model thrives. Am I missing something? Is XGBoost just the superior model in this case? The dataset is around 67.000 observations and 30 variables.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":947,"Q_Id":57244326,"Users Score":0,"Answer":"There are a number of reasons for this, in my opinion.\n\nLinear regression assumes your y to be linearly related to variables where as tree-based models are considered non-linear models. (So the linearity assumption goes out the window)\nBreaking some of the linear regression assumptions may not inherently decrease the predictive ability of your model,  but WILL bias the coefficients. Often times, when building a regression model you are trying to determine the effect of an X variable on the Y. In this case you mainly only care about this weight and don't care as much about how well your model predicts. If you are aiming only for predictive ability you can break some assumptions.\n\nThese are the main 2 thoughts that come to mind. I would be interested to hear other people's take as well.","Q_Score":0,"Tags":"python,r","A_Id":57244533,"CreationDate":"2019-07-28T19:32:00.000","Title":"How come multiple regression has so many assumptions, while advanced machine learning algorithms have next to none?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've made a python program using Tkinter(GUI) and I would like to enter it by creating a dedicated icon on my desktop. (I want to send the file to my friend, without him having to install python or any interpreter)\nthe file is a some-what game that I want to share with friends and family, which are not familiar with coding.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5445,"Q_Id":57251789,"Users Score":0,"Answer":"you can install Pyinstaller by using pip\n\npip install pyinstaller\n\ngo to the directory where your file is saved and type:\n\npyinstaller.exe --onefile --windowed path\/to\/your\/file.py \n\n--onefile (compresses your files into one .exe file)\n--windowed (removes the console when you run your file) \npath\/to\/your\/file.py (or simply file.py when you want to convert the file in the same directory)\nif you have any error using it, remove the --windowed flag and run file.exe on command line to see the error","Q_Score":2,"Tags":"python,user-interface,interface,createfile","A_Id":57252683,"CreationDate":"2019-07-29T10:22:00.000","Title":"run python program via clickable desktop icon","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As simple as the title: Are there ways to keep jupyter notebook cells running with a closed laptop? Sometimes I need to run to a meeting or leave the office and I have to close my laptop. I'd love to be able to keep cells running. \nIs this just a matter of biting the bullet and running my code on AWS\/Google compute rather than locally? Or is there a way to set my Macbook to not enter sleep state on closed under certain conditions?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3244,"Q_Id":57253726,"Users Score":3,"Answer":"Alternatively you can just go to your system preferences-> energy saver-> set computer sleep and display sleep sliders to \u201cnever\u201d. \nBest!","Q_Score":3,"Tags":"python,jupyter-notebook,sleep,execution","A_Id":59896364,"CreationDate":"2019-07-29T12:17:00.000","Title":"Keep Jupyter notebook running with Macbook closed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install rosbag using pip:\npip install python-rosbag\nBut I am getting the following error:  \n\n(base) C:\\Users\\santhoshe.e\\annotator-master>pip install python-rosbag\n      Collecting python-rosbag\n        ERROR: Could not find a version that satisfies the requirement python-rosbag (from versions: none)\n      ERROR: No matching distribution found for python-rosbag\n\nHow can I install rosbag in windows other than using pip? Or the pip I used is wrong?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9448,"Q_Id":57254026,"Users Score":0,"Answer":"Actually for rosbag, it is not very easy to install by using pip. \nHowever you can use installation steps defined in ROS wiki.\nBut it is not done after installing rosbag, you should also add PYTHONPATH for the rosbag in your interpreter. Which can be done by simply selecting File>Settings>Project Interpreter and click the gear right next to your interpreter. \nAfter that you will see two options : Add\/ShowAll. Go with Show All and on the window that opened, on the right hand side, you will see +,-,..., a symbol that shows the paths for the selected interpreter (the symbol listed at the end)\nUnder these paths you should also define the path that you installed ros. For me, the path is : \n\/opt\/ros\/melodic\/lib\/python2.7\/dist-packages","Q_Score":4,"Tags":"python,anaconda,ros","A_Id":60382958,"CreationDate":"2019-07-29T12:36:00.000","Title":"ModuleNotFoundError: No module named 'rosbag' with pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm coding a project which needs cloud control device operation, and want to keep information in sync.\nThe cloud needs to know the state of device, such as when the network is interrupted and when the network is restored.\nWhen the network is restored, the modified information on the cloud is synchronized to device.\nanyone got an idea of how my approach should be like? any tips?\nI intend to add resident programs in the background at both ends to determine, but in fact, it is impossible for the cloud in the project to connect only one device, and multiple apps may run in one device, which is very tedious to do. Is there any simple component to realize this function?\nI wish control information and data information to be synchronized on the cloud and device","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":85,"Q_Id":57254477,"Users Score":0,"Answer":"Based on your tag, I'm assuming that you are using MQTT as a messaging protocol for your system. If so, to address your need for tracking the device-cloud connection state, MQTT specifies a feature called \"Last Will and Testament\".\nFrom the MQTT 3.1.1 Standard Section 3.1.2.5:\n\nIf the Will Flag is set to 1 this indicates that, if the Connect request is accepted, a Will Message MUST be stored on the Server and associated with the Network Connection. The Will Message MUST be published when the Network Connection is subsequently closed unless the Will Message has been deleted by the Server on receipt of a DISCONNECT Packet [MQTT-3.1.2-8].\n\nThis can be leveraged to let the remote MQTT client on the cloud know when the device is connected and when it disconnects by publishing an online payload to a topic (for example) device\/conn_status after a successful connection, and registering a Last Will offline message to the same topic. Now, whenever the device client goes offline, the broker will publish the offline payload on his behalf to the cloud client that can now act accordingly.","Q_Score":1,"Tags":"python-3.x,synchronization,cloud,mqtt,etcd3","A_Id":57319277,"CreationDate":"2019-07-29T13:03:00.000","Title":"How to keep information synchronized between the cloud and the device","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to return the (average) contrast value of an image.\nIs this possible and if so, please show how?\nMore than just the code, (obviously the code is welcome), in what color space should I work? Is HSV appropriate or best? Can the contrast value of a single pixel be computed?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3574,"Q_Id":57256159,"Users Score":1,"Answer":"Contrast is usually understood as intensity contrast and can be computed on the Luminance component (Y). It is a measure of spread of the histogram, such as the standard deviation.","Q_Score":2,"Tags":"python,opencv,image-processing,colors,contrast","A_Id":57256900,"CreationDate":"2019-07-29T14:42:00.000","Title":"How extract contrast level of a photo - opencv","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have my own TensorFlow serving server for multiple neural networks. Now I want to estimate the load on it. Does somebody know how to get the current number of requests in a queue in TensorFlow serving? I tried using Prometheus, but there is no such option.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1082,"Q_Id":57256298,"Users Score":0,"Answer":"what 's more ,you can assign the number of threads by the --rest_api_num_threads or let it empty and automatically configured by tf serivng","Q_Score":2,"Tags":"python-3.x,tensorflow,prometheus,tensorflow-serving","A_Id":57549978,"CreationDate":"2019-07-29T14:50:00.000","Title":"Tensorflow Serving number of requests in queue","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have my own TensorFlow serving server for multiple neural networks. Now I want to estimate the load on it. Does somebody know how to get the current number of requests in a queue in TensorFlow serving? I tried using Prometheus, but there is no such option.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1082,"Q_Id":57256298,"Users Score":1,"Answer":"Actually ,the tf serving doesn't have requests queue , which means that the tf serving would't rank the requests, if there are too many requests. \nThe only thing that tf serving would  do is allocating  a threads pool, when the server is  initialized.\nwhen  a request coming , the tf serving will use a unused thread to deal with the request , if there are no free threads, the tf serving will return a  unavailable error.and the client shoule retry again later.\nyou can find the these information in the comments of tensorflow_serving\/batching\/streaming_batch_schedulor.h","Q_Score":2,"Tags":"python-3.x,tensorflow,prometheus,tensorflow-serving","A_Id":57549954,"CreationDate":"2019-07-29T14:50:00.000","Title":"Tensorflow Serving number of requests in queue","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a user installable application the takes a 2-5 MB JSON file and then queries the data for metrics.  It will pull metrics like the number of unique items, or the number of items with a field set to a certain value, etc.  Sometimes, it pulls metrics that are more tabular like returning all items with certain properties and all their fields from the JSON.\nI need help making a technology choice.  I am between using either Pandas or SQLite with peewee as an ORM.  I am not concerned about converting the JSON file to a SQLite database, I already have this prototyped.  I want help evaluating the pros and cons of a SQLite database versus Pandas.\nOther factors to consider are that my application may require analyzing metrics across multiple JSON files of the same structure.  For example, how many unique items are there across 3 selected JSON files.\nI am news to Pandas so I can't make a strong argument for or against it yet.  I am comfortable with SQLite with an ORM, but don't want to settle if this technology choice would be restrictive for future development.  I don't want to factor in a learning curve.  I just want an evaluation on the technologies head-to-head for my application.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":158,"Q_Id":57257180,"Users Score":1,"Answer":"You are comparing a database to an in-memory processing library. They are two seperate ideas. Do you need persistent storage over multiple runs of code? Use SQLite (since you're using metrics I would guess this is the path you need). You could use Pandas to write CSV's\/TSV's and use those as permanent storage but you'll eventually start to bottleneck having to load multiple CSV's into one Dataframe for processing.\nYour use case sounds better suited to using SQLite, in my opinion.","Q_Score":0,"Tags":"python,json,pandas,sqlite","A_Id":57257267,"CreationDate":"2019-07-29T15:39:00.000","Title":"Should I use a SQLite database or Pandas for my application","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a tkinter python app that is meant to run on a raspberry pi. When I run the code from the build in IDE on the pi it runs fine and the window opens up, same on IDLE on my windows PC,  however when I try and run the program from the command line, it does nothing when I hit enter on the command python3 filename. As well as this, when I enter the python shell from the command line I am able to get a tkinter window to appear using root = Tk(), so I cannot figure out why my program won't run.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":518,"Q_Id":57257206,"Users Score":0,"Answer":"I've now fixed this myself so posting the answer in case anyone needs it. My mainloop() function was actually MainPage.mainloop() which for some reason stopped the window from opening from the command prompt...","Q_Score":1,"Tags":"python,tkinter,raspberry-pi3","A_Id":57267030,"CreationDate":"2019-07-29T15:41:00.000","Title":"Tkinter app runs on windows but doesn't open window on raspberry pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know this has been questioned before, but no real solution was proposed and I was wondering if there any new ways nowadays.\nIs there anyway to hook an event using any AWS service to check if a lambda has timed out? I mean it logs into the CloudWatch logs that it timed out so there must be a way.\nSpecifically in Python because its not so simple to keep checking if its reaching the 20 minute mark as you can with Javascript and other naturally concurrent languages.\nIdeally I want to execute a lambda if the python lambda times out, with the same payload the original one received.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":5966,"Q_Id":57258980,"Users Score":1,"Answer":"Two options I can think of, the first is quick and dirty, but also less ideal:\n\nrun it in a step function (check out step functions in AWS) which has the capability to retry on timeouts\/errors\na better way would be to re-architect your code to be idempotent. In this example, the process that triggers the lambda checks a condition, and as long as this condition is true, trigger the lambda. That condition needs to remain true unless the lambda finished executing the logic successfully. This can be obtained by persisting the parameters sent to the lambda in a table in the DB, for example, and have an extra field called \"processed\" which will be modified to \"true\" only once the lambda finished running successfully for that event.\n\nUsing method #2 will make your code more resilient, easy to re-run on errors, and also easy to monitor: basically all you have to do is check how many such records do you have which are not processed, and what's their create\/update timestamp on the DB.","Q_Score":5,"Tags":"amazon-web-services,aws-lambda,python-3.7","A_Id":57259095,"CreationDate":"2019-07-29T17:46:00.000","Title":"How to handle timeouts in a python 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 built a python app that ran happily in its docker container until I added some http calls.. Using the library 'requests.' I did some research and alpine linux 3.7 has a library called 'py-requests'.. Only I can't seem to install this on my own system, to change my code to use it, and errors are thrown just leaving 'import requests' in my code. Py-pip doesn't seem to work either.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1115,"Q_Id":57261543,"Users Score":-1,"Answer":"I couldn't use pip install because I was blocked by a corporate firewall. I added --proxy mycompanyproxy.com:80 --trusted-host pypi.org --trusted-host files.pythonhosted.org to my dockerfile's pip install command and was able to get what I needed. Thanks for commenting, and sorry for the vagueness, I am a noob :)","Q_Score":0,"Tags":"python,docker,alpine","A_Id":57317442,"CreationDate":"2019-07-29T21:18:00.000","Title":"How to use py-requests in alpine linux docker?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to implement very simple authentication for updating values on my server. Here's the situation:\nI have a door sensor hooked up to a raspberry pi. Every time the sensor is triggered ('Opened' or 'Closed'), I send a POST request out to my Digital Ocean droplet at 'api.xxxxxx.com' which points to a restify server. The POST request body contains the sensor state, a time-stamp, and an API key. The RESTify server also has a file called 'constants.js' that contains the same API key. If the API key sent from the RPi is the same as the one in the constants file on my droplet, it allows values to update (latest state\/time). If not, it just sends back an error message.\nThe API key is a password sent through SHA3-256.\nIs this scheme okay for what I'm doing? The only thing I could think of is if someone found the endpoint, they might be able to spam requests to it, but nothing else. The API key (on my local raspberry pi and on the droplet) are kept in different files and excluded from git, so viewing git files would not reveal anything.\nI don't expect anyone to have access to my droplet or raspberry pi either, so if I set up SSH correctly I don't see how it (the API key in the files) could be leaked either.\nEDIT: Forgot to say that I'm using Python on the Raspberry Pi to send out POSTs. The droplet is running a RESTify server (JS).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":57262893,"Users Score":1,"Answer":"Well, you are vulnerable to network snooping. If anyone can snoop either of the network links, then they can steal the API key and are free to use your service with it. \nHTTPS on both links would prevent that. HTTPS could also prevent any sort of DNS hijack that could trick the Pi into sending the APIKey to a false host (thus stealing it that way).\nOther than that, your API key is your secret that controls access so as long as it is secured in storage at both ends and secured in transit and it's sufficiently hard to guess, you are OK.","Q_Score":0,"Tags":"javascript,python,node.js,authentication,restify","A_Id":57263175,"CreationDate":"2019-07-30T00:41:00.000","Title":"Very simple authentication on my own server, is this okay?","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 very confused as to what .decompose() does in BeautifulSoup - I've read the docs. But this is just one of those docs that isn't clicking. \nI'm working on a personal project to scrape some data from website. For work we use BS4 for testing purposes. As it's been explained to me, every time we parse a page, we instantiate a HTMLParser(), which is BeautifulSoup(html, features=\"html5lib\"). Once we're done, we need to destroy() it. This destroy method is simply calling .decompose() on the BeautifulSoup object itself. \nI'm just curious as to what decompose is doing and why we need to do it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":57263341,"Users Score":0,"Answer":"Use .decompose() just to edit or modify your html document.\nWhen you want to remove a tag because it is not needed anymore.","Q_Score":0,"Tags":"python,html,parsing,web-scraping,beautifulsoup","A_Id":70686344,"CreationDate":"2019-07-30T01:52:00.000","Title":"decompose() in BeautifulSoup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a really long string that I want to shorten into a smaller string of random characters similar to what a hash does. However, I want to be able to undo it later to read it. As far as I know hashes are unable to be undone and thus I could not read it later.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":161,"Q_Id":57263436,"Users Score":0,"Answer":"I ended up using a database and just stuck with the long strings. Originally, I was going to shorten them and not have a database, but I think a database is better anyways and it allows me to store the long form.","Q_Score":1,"Tags":"python,string","A_Id":57486491,"CreationDate":"2019-07-30T02:08:00.000","Title":"hash-like string shortener with decoder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to set up a machine learning model predicting a continuous variable y on the basis of a feature vector (x1, x2, ..., xn). I know from elsewhere that y follows a normal distribution. Can I somehow specify this to the model and enhance its predictions this way? Is there a specific model that allows me to do this?\nI have used linear models, k-nearest neighbour models and random forest models (in python). All of them give some predictions but I was wondering whether they can be outperformed by some model that would know the distribution of the predicted variable.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":57267855,"Users Score":0,"Answer":"One way you could do this is by creating a custom objective function that penalizes predictions that are not normally distributed.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,regression,supervised-learning","A_Id":57268592,"CreationDate":"2019-07-30T08:55:00.000","Title":"Can I tell a machine learning model that the dependent variable is normally distributed?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I already trained ssd_mobilenet_v2_coco with my custom data set on tensorflow. Also I trained YOLO with my data set too. I solved all problems and they work.\nI encounter a problem with both models. When my data set includes images with more size than 400kb, the trained models do not work. Some times \"allocation of memory\" problem occurs. I solved them with changing parameters(batch size etc.). But I still don't know whether there is a limit of image size when we are preparing data set?\nWhy more than 400kb images are problem for my system? My question is not about pixel size,it's about image file size.\nThanks...\nSystem Info\n\nNvidia RTX 2060 6G\nAMD Ryzen 7\n16GB DDR4 2600Mhz Ram\nCuda:10.0\nCudNN:7.4.2(I also try diffrent versions and same results occur)\nTensorflow:2","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":57269090,"Users Score":1,"Answer":"Providing the solution here (Answer Section), even though it is present in the comment section (Thanks dasmehdix for the update) for the benefit of the community.\nNo, there is no a limit of image size that we use to train our model.","Q_Score":1,"Tags":"python,tensorflow,detection,yolo","A_Id":62347635,"CreationDate":"2019-07-30T10:01:00.000","Title":"Is there a limit about image size when we train custom object with already trained models?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I've recently updated my Anaconda environment, and now I can't import tensorflow anymore. Everytime I run a script containing it, the Spyder Console runs for a while, then just stops and resets to ln[1]. \nI tried to see how far the script compiles, and it does everything fine, until the import statement. Weirdly enough, the autocomplete still works for tf, which means that my installation should be fine. Reinstalling tensorflow also didn't do anything.\nThere are no error messages, because the compiler dies a silent death everytime I run the script. I've seen others describe a similar problem on a Jupyter, but their fixes didn't work. (Running the script without Spyder just freezes Python) \nI'd greatly appreciate help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":316,"Q_Id":57270586,"Users Score":0,"Answer":"Ok so I did some black mathmagic and fixed it. What I did was reducing the tensorflow version via pip (to 1.14, but I don't think that matters) and then upgrading my entire conda set up again with conda update --all. I have no idea why, and the anaconda console screamed like it was tortured during the entire update, but now it works and I don't think I'll touch it again. If I see better fix, or if I encounter problems with this one, I'll update this post again.","Q_Score":0,"Tags":"python,tensorflow","A_Id":57325381,"CreationDate":"2019-07-30T11:27:00.000","Title":"Kernel Restarts upon failing(?) to import tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to collect and parse stats after my scrapy crawl has finished. I know it dumps the stats but I would like to ideally have a method\/hook a method that runs when the scrape has finished which can then collect the stats (as I will use them to decide if another scrape is needed automatically).\nPlease don't suggest using some sort of external script, I want it all contained to one project please.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":57270706,"Users Score":0,"Answer":"Try this command to save progress of spider:\nnohup scrapy crawl spider > spider_progress &\nSee only tail of the text file which contains stats of spider: \ncat spider_progress | tail","Q_Score":0,"Tags":"python,scrapy,web-crawler","A_Id":57271649,"CreationDate":"2019-07-30T11:34:00.000","Title":"Post crawl stats collection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a super class named as Person and I extend this class as Employee. I want to print the name of this extended (child) class inside the super (parent) class. \nIs this possible? If so, how can I print the child class name?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2025,"Q_Id":57274142,"Users Score":3,"Answer":"You can do this with type(self).__name__.\ntype(self) gets the actual class of self, even if called in a base class.\nAll classes have a __name__ attribute which gives their name as a string.","Q_Score":0,"Tags":"python,class,oop,inheritance","A_Id":57274517,"CreationDate":"2019-07-30T14:33:00.000","Title":"Get child class name inside super class in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When calculating Homography, usually the information of the camera should be provided. Is there any straightforward technique to achieve perspective correction without actually having camera's properties? \nare there papers for that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":507,"Q_Id":57277573,"Users Score":0,"Answer":"A standard technique is calibration with a target.\nTo identify a (planar) homography, four points suffice. Take an image of the viewed plane where you place a contrasted rectangle and locate the corners in the image (pixel coordinates). You could do this by image processing or just manually. Then choose the pixel coordinates where you would like the corners to map after correction.\nThis will allow you to write a system of eight equations in the eight unknown parameters of the homography. Fortunately, this system is easily linearized and the solution is unique.","Q_Score":0,"Tags":"python,opencv,image-processing,homography","A_Id":57279377,"CreationDate":"2019-07-30T18:04:00.000","Title":"Applying Homographies to Remove Perspective Distortion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My application has built-in Python interpreter and I need to debug Python code there. However Visual Studio Code allows to choose only from interpreters found in paths and named python\/python2\/python3.\nI tried to set python.pythonPath in settings.json to point to my application, but Visual Studio Code doesn't recognize it as valid Python interpreter.\nSure, I need to make sure that my application behave like Python interpreter and pass all command-line parameters to Python ptvsd_launcher.py.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":182,"Q_Id":57277652,"Users Score":1,"Answer":"The \"python.pythonPath\" setting is how you can specify a Python interpreter that is not automatically detected. If the binary does not function as a normal python binary then unfortunately there's no way for the extension to use it.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":57278669,"CreationDate":"2019-07-30T18:08:00.000","Title":"How to specify non-standard Python interpreter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with QComboBox in PyQt5. I want each item in the QComboBox to hold a value. To demonstrate my idea, I have 3 items in my firstC that are named USD, EUR, BGN\nI want each of the items to have a value, like example USD to be able to print('1') on the console, the second item to (EUR) print('2') and so on...\nMy idea behind this is, when an Item in the QComboBox is selected, to hold a value.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":57278216,"Users Score":0,"Answer":"have you looked into QComboBox's \"ItemData\" methods?\nYou can use combobox.setItemData(intex, value[, role]) and similary getItemData and itemData","Q_Score":0,"Tags":"python,pyqt,qcombobox","A_Id":57278905,"CreationDate":"2019-07-30T18:44:00.000","Title":"How to add value to each Item in QComboBox","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to build an algorithm for product master data purposes and I'm not sure about the best NLP approach for this. The scenario is:\n- I have Product golden records;\n- I have many others Product catalogs that need to be harmonized;\nExample:\n- Product Golden Record: Coke and Coke Zero;\n- Products description that need to be hamonized: Coke 300ml, Coke Zero 300ml, Cke zero.\nI need an algorithm that harmonize by similarity, since I have to consider typos and, sometimes, piece of a product in a sentence. Example: Coke zero JS MKT (JS and MKT are garbage, but the sentence is more similar to Coke Zero).\nI've been testing some NLP for sentence similarity such as Bag of words as well as reading some other approaches such as Cosine Similarity and Levenshtein distance. However, I don't know what is the best option for my case.\nCould you please help me to understand the best way to achieve what I need?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":57282671,"Users Score":1,"Answer":"I have found two great solutions, by using Cosine similarity and Levenshtein distance. Im my case, Cosine similarity worked better, because I easily found part of the brand name into the text, so getting a score of 100% of accuracy. Matrix replacing (Levenshtein) was also good, but I good some errors due to very similar words in the dataset.","Q_Score":0,"Tags":"python,nlp","A_Id":60646118,"CreationDate":"2019-07-31T03:16:00.000","Title":"Word\/Sentence similarity. What is the best approach?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Context\nThere is class 'A' which needs a lot of parameters. And there\nare classes B,C,D which depends D->C->B->A way. I have to set\nparameters for A while initializing D which would be passed on to C\nthen to B, A. Now the problem is that the list of parameters is so big\nthat it would be pain to pass each of it as argument in constructor. So\ninstead I created a dictionary to pass it on by.\nQuestion\nIn this case, is passing parameters with dictionary OK? If not, are there other way to solve this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":57284417,"Users Score":0,"Answer":"just inherit all the classes with class A and then pass a parameter in the dictionary...","Q_Score":0,"Tags":"python","A_Id":57284455,"CreationDate":"2019-07-31T06:19:00.000","Title":"Is passing parameters with dictionary OK?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Context\nThere is class 'A' which needs a lot of parameters. And there\nare classes B,C,D which depends D->C->B->A way. I have to set\nparameters for A while initializing D which would be passed on to C\nthen to B, A. Now the problem is that the list of parameters is so big\nthat it would be pain to pass each of it as argument in constructor. So\ninstead I created a dictionary to pass it on by.\nQuestion\nIn this case, is passing parameters with dictionary OK? If not, are there other way to solve this?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":55,"Q_Id":57284417,"Users Score":1,"Answer":"Yes. This is pretty much the use case for **kwargs.","Q_Score":0,"Tags":"python","A_Id":57284541,"CreationDate":"2019-07-31T06:19:00.000","Title":"Is passing parameters with dictionary OK?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed python on Windows and build a virtual environment. The first virtual environment is working. But when i try to run a second virtual environment it creates the environment as the first one but when i try to \"activate\" the second one, \n\n.\\newenv\\Scripts\\activate\n\n(activate.ps1 is neither working)\nit answers: \n\nyou must 'source' this script: PS> . .\\newenv\\Scripts\\activate\n\nOf curse, there is no \"source\" command on Windows 7 Powershell. What seems obscure to me is that the first virtual environment was running at the first try, so i though there would be no problems, but it seems as if it seems to lack something.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":142,"Q_Id":57286828,"Users Score":0,"Answer":"please install virtualenv in the Scripts folder of your new environment and activate it by using name\nactivate newvenv","Q_Score":0,"Tags":"python,virtualenv","A_Id":57289446,"CreationDate":"2019-07-31T08:54:00.000","Title":"Python Virtual environment can not be activated (windows 7)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a model that has attribute models.DateField(db_index=True)\ni insert datetime.strptime(\"2019-07-08\", \"%Y-%m-%d\") into it. \nNow, when I get() on it I get:  datetime.date(2019, 7, 1) as opposed to datetime.datetime(2019, 7, 1, 0, 0)\nWhy is it inconsistent? :(","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":57287038,"Users Score":0,"Answer":"You use a DateField, not a DateTimeField.\nYou need to use DateTimeField instead of DateField","Q_Score":0,"Tags":"django,python-3.x,django-models","A_Id":57287206,"CreationDate":"2019-07-31T09:04:00.000","Title":"How to fix django inconsistent date fields?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a large pandas DataFrame consisting of some 100k rows and ~100 columns with different dtypes and arbitrary content.\nI need to assert that it does not contain a certain value, let's say -1.\nUsing assert( not (any(test1.isin([-1]).sum()>0))) results in processing time of some seconds. \nAny idea how to speed it up?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":57288507,"Users Score":1,"Answer":"Just to make a full answer out of my comment:\nWith -1 not in test1.values you can check if -1 is in your DataFrame.\nRegarding the performance, this still needs to check every single value, which is in your case \n10^5*10^2 = 10^7.\nYou only save with this the performance cost for summation and an additional comparison of these results.","Q_Score":1,"Tags":"python-3.x,pandas","A_Id":57290376,"CreationDate":"2019-07-31T10:20:00.000","Title":"speed up pandas search for a certain value not in the whole df","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Getting intermediate result, while PuLP is trying to find the optimal and feasible solution.\nAs you know, solving Mixed integer Linear programming (MILP) cases may take a long time. I'm trying to get intermediate results from PuLP optimization package, while it is running. I know it is possible to do that in Gurobi, which is a commercial optimization package.\nI'm not sure about the code I can use in PuLP package to get that information. Any advice would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":126,"Q_Id":57289142,"Users Score":1,"Answer":"Pulp doesn't really have this interface (though if you use gurobi you can access the underlying solver object).","Q_Score":0,"Tags":"python-3.x,optimization,pulp,mixed-integer-programming","A_Id":57299336,"CreationDate":"2019-07-31T10:55:00.000","Title":"Getting intermediate info. from PuLP","Data Science and Machine Learning":0,"Database and SQL":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 using read_sql function to pull data from a postgresql table. As I store that data in a dataframe, I could find that some integer dtype column is automatically getting converted to float, is there any way to prevent that while using read_sql functiononly","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":57290281,"Users Score":0,"Answer":"Since your column contains NaN values, which are floating point numbers, I don't think you can avoid this 'issue' loading from the Database without changing the query. \nIf you wish to change the query, you can insert a WHERE clause that would exclude None values, or check if the row contains such a column value.\nWhat I suggest would be to use .fillna(), and then to cast as integers using .astype('int')\nEdit : Just in case, your question is wrong, you are saying \n\nIs there any way to change columns datatype that should be int became a float while using read_sql from table\n\nBut since it includes NaN, it is not expected to be an int, but a float.","Q_Score":0,"Tags":"python,pandas","A_Id":57290466,"CreationDate":"2019-07-31T12:01:00.000","Title":"Is there any way to change columns datatype that should be int became a float while using read_sql from table","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My code creates and access .txt files. Will this still work if I bundle it using PyInstaller as one file? I'm new to PyInstaller, so sorry if it's an obvious question.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":57291001,"Users Score":0,"Answer":"Yes, it will work. Also, make sure that the txt files have static contents. if not, try to use some fronend tools to upload and use the file dynamically.","Q_Score":0,"Tags":"python,python-3.x,windows,windows-10,pyinstaller","A_Id":57322785,"CreationDate":"2019-07-31T12:41:00.000","Title":"Access and create .txt files from a PyInstaller one-file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Trying to figure out how to make python play mp3s whenever a tag's text changes on an Online Fantasy Draft Board (ClickyDraft).\nI know how to scrape elements from a website with python & beautiful soup, and how to play mp3s. But how do you think can I have it detect when a certain element changes so it can play the appropriate mp3?\nI was thinking of having the program scrape the site every 0.5seconds to detect the changes,\nbut I read that that could cause problems? Is there any way of doing this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":57291451,"Users Score":0,"Answer":"The only way is too scrape the site on a regular basis.  0.5s is too fast. I don't know how time sensitive this project is. But scraping every 1\/5\/10 minute is good enough. If you need it quicker, just get a proxy  (plenty of free ones out there) and you can scrape the site more often.\nJust try respecting the site, Don't consume too much of the sites ressources by requesting every 0.5 seconds","Q_Score":1,"Tags":"python,html,beautifulsoup,mp3","A_Id":57292691,"CreationDate":"2019-07-31T13:05:00.000","Title":"Is it possible to write a Python web scraper that plays an mp3 whenever an element's text changes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When working with TensorFlow (image classification for example), sometimes images are loaded using cv2.imread(image) and other times they are loaded using tf.gfile.GFile(image, 'rb').read().  \nAre there any differences between cv2.imread(image) and tf.gfile.GFile(image, 'rb').read() when using them with TensorFlow?  \nEdit:\nMy question here is about performances and maintaining image accuracy (since both of them do the job).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":452,"Q_Id":57293678,"Users Score":0,"Answer":"tf.gfile is basicly to use a less-convensional filesystem such as HDFS etc...\ncv2.imread(image) is for local filesystem usage.","Q_Score":1,"Tags":"python,opencv,tensorflow","A_Id":57293794,"CreationDate":"2019-07-31T14:56:00.000","Title":"what's the difference between tf.gfile.GFile().read() and cv2.imread() when it is about reading images","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get the variances from the eigen vectors.\nWhat is the difference between explained_variance_ratio_ and explained_variance_ in PCA?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":10300,"Q_Id":57293716,"Users Score":2,"Answer":"It's just normalization to see how each principal component important. You can say:\nexplained_variance_ratio_ = explained_variance_\/np.sum(explained_variance_)","Q_Score":7,"Tags":"python,scikit-learn,pca,covariance","A_Id":57294007,"CreationDate":"2019-07-31T14:58:00.000","Title":"Sklearn PCA explained variance and explained variance ratio difference","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on Django app on branch A with appdb database in settings file. Now I need to work on another branch(B) which has some new DB changes(eg. new columns, etc). The easiest for me is to point branch B to a different DB by changing the settings.py and then apply the migrations. I did the migrations but I am getting error like 1146, Table 'appdb_b.django_site' doesn't exist. So how can I use a different DB for my branchB code without dropping database appdb?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":57294233,"Users Score":1,"Answer":"The existing migration files have information that causes the migrate command to believe that the tables should exist and so it complains about them not existing.\nYou need to MOVE the migration files out of the migrations directory (everything except init.py) and then do a makemigrations and then migrate.","Q_Score":0,"Tags":"python,django","A_Id":57296935,"CreationDate":"2019-07-31T15:27:00.000","Title":"How to point Django app to new DB without dropping the previous DB?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have 10 Beacons and I can see there are different rssi values published using python file.\nhowever, when i try to use the phone\/pc to find the beacons, sending different \"rssi\" value for unique mac address.\nI need to understand that is there any function to find value of rssi for unique mac address? Below is my output and should I get value of rssi in one array for one mac address?\nFor Example\nMessage Recieved from Beacon: {\n \"uuid\": \"uuid\",\n \"major\": 1,\n \"minor\": 2,\n \"txPower\": 216,\n \"RSSI\": -76,\n \"MAC_ADDRESS\": \"ca:83:81:d8:f4:2f\"\n}\nMessage Recieved from Beacon: {\n \"uuid\": \"uuid\",\n \"major\": 1,\n \"minor\": 2,\n \"txPower\": 216,\n \"RSSI\": -77,\n \"MAC_ADDRESS\": \"ca:83:81:d8:f4:2f\"\n}\nI expect the output \nIn one minute duration\nMac address : [ca:83:81:d8:f4:2f]\nRSSI        : [-76,-77,-78]","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":164,"Q_Id":57294957,"Users Score":0,"Answer":"Each \"message received\" is an advertising data packet.  It contains the signal strength of that particular packet as the RSSI value.  The advertisements come in random order and aren't requested for by the receiver.  If you want to query a particular address for the last few RSSI values, then you need to have the program record all the advertising RSSI values it's previously seen and then you query that.","Q_Score":0,"Tags":"python,bluetooth-lowenergy,rssi","A_Id":57313194,"CreationDate":"2019-07-31T16:06:00.000","Title":"How to store iBeacon RSSI values till one minute in an array 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 want to extract \"Twitter for iPhone\" part from this string.\nBut I have different values in the place of \"Twitter for iPhone\" in 1000s of columns in a dataframe. I only need the values after \">\" and before \"<\" from the following set of strings.\nI tried df.col.str.extract('(Twitter for iPhone|Twitter for Samsung|Twitter for others)') which extracts only those 'Twitter for iPhone' values but not the others and the rest are filled with NaNs.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":259,"Q_Id":57297369,"Users Score":1,"Answer":"Try df.col.str.extract(pat = '(Twitter for (iPhone|Samsung|others))')","Q_Score":1,"Tags":"python,regex,pandas,dataframe","A_Id":57297560,"CreationDate":"2019-07-31T19:03:00.000","Title":"I want to extract a particular pattern from a content string: \"Twitter for iPhone\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"dirA\/dirB\/dirC\/program.py\ndirA\/dirD\/target.py\nHow can I initiate the execution of target.py by program.py? I tried to use os.startfile(\".\\.\\.\\dirD\\target.py\") but unfortunately, it does not work. Have not found anything which helped.\nProgram.py should be closed. Also, it should be based on a relative path since the scripts will be used on multiple machines!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":371,"Q_Id":57297948,"Users Score":0,"Answer":"I found a solution using the pathlib-module and os.startfile(). \npathlib.Path(__file__).parent.parent returns the desired directory so that os.startfile(str(pathlib.Path(file).parent) + [path]) executes the file.","Q_Score":0,"Tags":"python,execution","A_Id":57308016,"CreationDate":"2019-07-31T19:49:00.000","Title":"How can I start another file within a program using startfile and relative path?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on a project that takes in new data periodically.\n\nThe initial problem is that function 1 is scheduled to update & aggregate certain variables at a certain time & function 2 is supposed to use the updated variables (but it can\u2019t because variables are local to each function) to make calculations & print at different scheduled time. And I can\u2019t define the the variables in Global because the data will be updated constantly not periodically.\nSo I thought that I could just combine both functions into one function so that the program will see the sets of variable as the same, instead of two different sets of local variables. Then the different \u201cfunctions\u201d (now processes) would be executed using a if date.time1 is True:  process1 & elif date.time2 is True: process2.\n\nThe problem I\u2019m running into here is that it seems that either the simple T\/F code that I wrote is incorrect or you can\u2019t use T\/F with datetimes. I would really like if someone would please shed some light on my issue(s) and I\u2019m willing to hear a different solution to the first problem or how I can fix the second problem.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":57299307,"Users Score":0,"Answer":"I don\u2019t know why I don\u2019t think of these earlier but I simply used the   x = datetime.datetime.now() & y = datetime.date,time,day.(date,time,day) and used if x == y:","Q_Score":0,"Tags":"python,datetime,variables,boolean,schedule","A_Id":57300250,"CreationDate":"2019-07-31T21:53:00.000","Title":"Scheduling using Datetime & Boolean Values","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a univariate problem which involves aggregating payment data on a customer level - so that I have one row per customer, and the total amount they've spent with us.\nUsing this distribution of payment data, I fit an appropriate probability distribution and calculated the maximum likelihood estimates for the parameters of the pdf. \nNow I want to find the 90th percentile of the distribution. If I was to do this by hand I would set .10 equal to the integral from x to infinity of my pdf and then solve for x.\nIs there a package in python\/scipy\/statsmodels that allows me to do this?\nThanks in advance!\nCheers","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":666,"Q_Id":57299971,"Users Score":1,"Answer":"Eureka! It's the .interval() method for a rv_continuous object in scipy.stats - just pass in your parameters and it will give you end points that contain that percentage of the distribution.","Q_Score":2,"Tags":"python,scipy,statsmodels,calculus,probability-density","A_Id":57310189,"CreationDate":"2019-07-31T23:21:00.000","Title":"Finding the area under the curve of a probability distribution function in SciPy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 web elements with the same XPath and name but under the different navigation links. Both links point to the same page but with a different title. How should I access each of the links uniquely?\nI am a beginner to python selenium programming","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":57300618,"Users Score":0,"Answer":"You have the answer in the question itself. You must try identifying the elements using title with combination of other attributes if they have unique titles.\nPS: Please(always) add the code you have tried and the relevant(in this case HTML) required files\/snippet which can help us understand and investigate better. Questions with enough information get faster replies :)","Q_Score":0,"Tags":"python-3.x,selenium-chromedriver","A_Id":57302283,"CreationDate":"2019-08-01T01:05:00.000","Title":"Web element with same name and xpath under two elements in the navigation pane","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I watched youtube tutorials but no information found so far that solves my problem. When I try to install pip it says:\n\n\"uninstalling instead\"\n\nand in the program it says this:\n\n\" NameError: name 'pip' is not defined\"\n\nI don't understand and I can't find any information regarding this error type online.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":57301346,"Users Score":0,"Answer":"It appears you are calling pip install from within python shell which is not the correct way to execute it. pip can be called only from shell and not from within python shell.","Q_Score":0,"Tags":"python,pip","A_Id":57301407,"CreationDate":"2019-08-01T03:13:00.000","Title":"I am having trouble installing pip with python, what to do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I found the same python package in two different directories on my MacBook. One is in \/anaconda3\/pkgs\/ and the other is in \/anaconda3\/lib\/python3.7\/site-packages. I wonder what the folder \/anaconda3\/pkgs does and can I delete the duplicate packages in there safely?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":2826,"Q_Id":57302571,"Users Score":19,"Answer":"The pkgs directory is conda's package cache. I would strongly recommend not to delete packages there manually. Doing so can break environments that use one of these packages. \nInstead you can use conda clean -p and let conda decide which of the packages are safe to delete.","Q_Score":8,"Tags":"python,macos,installation,package,anaconda","A_Id":57303593,"CreationDate":"2019-08-01T05:53:00.000","Title":"Can I safely delete the files in \"\/anaconda3\/pkgs\"\uff1f","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I found the same python package in two different directories on my MacBook. One is in \/anaconda3\/pkgs\/ and the other is in \/anaconda3\/lib\/python3.7\/site-packages. I wonder what the folder \/anaconda3\/pkgs does and can I delete the duplicate packages in there safely?","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2826,"Q_Id":57302571,"Users Score":-1,"Answer":"Most of the packages that you import in your jupyter notebooks are picked from site-packages.","Q_Score":8,"Tags":"python,macos,installation,package,anaconda","A_Id":57302677,"CreationDate":"2019-08-01T05:53:00.000","Title":"Can I safely delete the files in \"\/anaconda3\/pkgs\"\uff1f","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a simple test code in python to toggle two of the I\/O pins on and off every few seconds. I would like to be able to run this code whenever the board powers on so that I don't need to bring a keyboard, mouse, and monitor everywhere I want to run the simple test. How do I do this on Mendel OS on a google coral?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":656,"Q_Id":57302900,"Users Score":1,"Answer":"Using crontab has been working consistently for me, you may want to add a time.sleep in the beginning of your python file\nedit crontab \ncrontab -e\nselect nano editor\nadd\n@reboot sudo python3 <path_to_your_script>","Q_Score":2,"Tags":"python-3.x,google-coral","A_Id":58123872,"CreationDate":"2019-08-01T06:22:00.000","Title":"How do I run a python script on boot on Google Coral?","Data Science and Machine Learning":0,"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 learning how to play music using selenium so I wrote a program which would be used as a module to play music. Unfortunately I exited the python shell without exiting the headless browser and now the song is continuously playing.\nCould someone tell me how I can find the current headless browser and exit it?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":84,"Q_Id":57305632,"Users Score":1,"Answer":"You need to include in your script to stop the music before closing the session of your headless browser.","Q_Score":0,"Tags":"python-3.x,selenium-webdriver","A_Id":57306386,"CreationDate":"2019-08-01T09:16:00.000","Title":"Stop music from playing in headless browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was learning how to play music using selenium so I wrote a program which would be used as a module to play music. Unfortunately I exited the python shell without exiting the headless browser and now the song is continuously playing.\nCould someone tell me how I can find the current headless browser and exit it?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":84,"Q_Id":57305632,"Users Score":1,"Answer":"If you are on a Linux box, You can easily find the process Id with ps aux| grep chrome command and Kill it. If you are on Windows kill the process via Task Manager","Q_Score":0,"Tags":"python-3.x,selenium-webdriver","A_Id":57308855,"CreationDate":"2019-08-01T09:16:00.000","Title":"Stop music from playing in headless browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have come across various articles online, some of which suggest that CountVectorizer should be fit on both the train and test sets, and some suggest that it should be fit only on the train set.\nWhich approach is generally better for text classification?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":96,"Q_Id":57306519,"Users Score":2,"Answer":"Generally the test_set should be kept unobserved, so the CountVectorizer should be only fitted on train_set","Q_Score":0,"Tags":"python,python-3.x,scikit-learn,countvectorizer","A_Id":57308378,"CreationDate":"2019-08-01T10:01:00.000","Title":"Should CountVectorizer be fit on both the train and test sets?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to set a manytomany relation to default django user table.Is there any way to implement it rather than using AbstractUser method of django \n(extending User Model)?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":945,"Q_Id":57306907,"Users Score":0,"Answer":"You don't need to extend the default Django User table to create a many to many relationship with it.\nAdd the many to many relation to the model you're creating, and behind the scenes Django will create a third table that stores the relationship using a ForeignKey to each object.","Q_Score":1,"Tags":"python,django,many-to-many","A_Id":57306987,"CreationDate":"2019-08-01T10:24:00.000","Title":"Django set ManytoManyField to default user model","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to optimize this statement:\nif 'key' in dictionary and dictionary['key']!=value:\nIs there a way to check if a key exists in a dictionary and check the value at the same time?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":80,"Q_Id":57309871,"Users Score":1,"Answer":"Python dict has a get() method. For example, if d is a dict, d.get(x, y) returns d[x] if it exists, otherwise it returns y. This means that your if statement can be replaced with if dictionary.get(key, value) != value.","Q_Score":2,"Tags":"python","A_Id":57309966,"CreationDate":"2019-08-01T13:14:00.000","Title":"How to improve a double if statement","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install new python modules on my computer and I know how to install through the terminal, but I wish to know if there is a way to install a new module directly through VSCode (like it is possible on PyCharm)?\nI already installed through the terminal, it isn't a problem, but I want to install without be obligate to open the terminal when I'm working on VSCode.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":41844,"Q_Id":57310009,"Users Score":2,"Answer":"Unfortunately! for now, only possible way is terminal.","Q_Score":12,"Tags":"python,python-3.x,visual-studio-code,vscode-settings,python-module","A_Id":57310616,"CreationDate":"2019-08-01T13:21:00.000","Title":"How to install a new python module on VSCode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When opening an HDF5 file with h5py you can pass in a python file-like object. I have done so, where the file-like object is a custom implementation of my own network-based transport layer. \nThis works great, I can slice large HDF5 files over a high latency transport layer. However HDF5 appears to provide its own file locking functionality, so that if you open multiple files for read-only within the same process (threading model) it will still only run the operations, effectively, in series.\nThere are drivers in HDF5 that support parallel operations, such as h5py.File(f, driver='mpio'), but this doesn't appear to apply to python file-like objects which use h5py.File(f, driver='fileobj').\nThe only solution I see is to use multiprocessing. However the scalability is very limited, you can only realistically open 10's of processes because of overhead. My transport layer uses asyncio and is capable of parallel operations on the scale of 1,000's or 10,000's, allowing me to build a longer queue of slow file-read operations which boost my total throughput. \nI can achieve 1.5 GB\/sec of large-file, random-seek, binary reads with my transport layer against a local S3 interface when I queue 10k IO ops in parallel (requiring 50GB of RAM to service the requests, an acceptable trade-off for the throughput).\n\nIs there any way I can disable the h5py file locking when using driver='fileobj'?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":4420,"Q_Id":57310333,"Users Score":6,"Answer":"You just need to set the value to FALSE for the environment variable HDF5_USE_FILE_LOCKING.\nExamples are as follows:\nIn Linux or MacOS via Terminal: export HDF5_USE_FILE_LOCKING=FALSE\nIn Windows via Command Prompts (CMD): set HDF5_USE_FILE_LOCKING=FALSE","Q_Score":8,"Tags":"python,python-3.6,hdf5,h5py","A_Id":57445839,"CreationDate":"2019-08-01T13:37:00.000","Title":"Can we disable h5py file locking for python file-like object?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to save an image\/an array as an OIB File.\nI have tried using the oiffile library. I am able to open and read OIB files, but I want to save an image as an OIB File.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":57311998,"Users Score":0,"Answer":"Since oiffile uses cv2 structure for opening\/closing images (via numpy arrays), so you might be opening the image using imread(). Then you can use imwrite() for saving\/writing the image file to a destination path.","Q_Score":0,"Tags":"python,image,save","A_Id":57314256,"CreationDate":"2019-08-01T15:06:00.000","Title":"Saving an Image as an OIB File 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":"Some people find it confusing with whiskers and outliers in a Boxplot.\nIs it possible to remove those from the Boxplot in Seaborn?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1271,"Q_Id":57314544,"Users Score":0,"Answer":"You can remove the outliers by setting showfliers=False and remove whiskers by setting whis=0.","Q_Score":1,"Tags":"python,seaborn,boxplot","A_Id":57314963,"CreationDate":"2019-08-01T17:53:00.000","Title":"Can I remove whiskers and outliers from Boxplot?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"A few months ago I had Visual Studio IDE then uninstalled it and(stupidly) uninstalled all the Visual C++ Redistributables along with it. I managed to install all the versions from 2005 up to 2013, but I can't seem to get the 2015 version running. I get stuck on \"processing:   windows81_x64\" and \"processing:   windows81_x86\"  screens.\nI'm trying to use python in command prompt \"C:>python\" and I get this error \"The program cant start because api-ms-win-crt-runtime-l1-1-0.dll is missing from your computer\". I'm also getting similar error messages with other software, python is just an example.\nI've tried manually deleting and reinstalling the packages , which obviously hasn't worked. I've also tried using the \"major geeks\" installer (I know its a 'use at my own risk' software) but it only installed up to 2010 files. \nOn a side note, Windows update isn't working for me either, not sure if that has anything to do with the issue or not\nAny help appreciated","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":387,"Q_Id":57314714,"Users Score":0,"Answer":"I really don't know what the issue was, but I reinstalled windows 10 and everything now works fine.","Q_Score":1,"Tags":"python,visual-studio,visual-c++,installation,command-prompt","A_Id":59240615,"CreationDate":"2019-08-01T18:06:00.000","Title":"Visual C++ Redistributable 2015 Deleted and can't reinstall","Data 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 an object detection model. I have annotated images whose values are stored in a data frame with columns (filename,x,y,w,h, class). I have my images inside \/drive\/mydrive\/images\/ directory. I have saved the data frame into a CSV file in the same directory. So, now I have annotations in a CSV file and images in the images\/ directory. \nI want to feed this CSV file as the ground truth along with the image so that when the bounding boxes are recognized by the model and it learns contents of the bounding box.\nHow do I feed this CSV file with the images to the model so that I can train my model to detect and later on use the same to predict bounding boxes of similar images?\nI have no idea how to proceed.\nI do not get an error. I just want to know how to feed the images with bounding boxes so that the network can learn those bounding boxes.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":57315783,"Users Score":0,"Answer":"We need to feed the bounding boxes to the loss function. We need to design a custom loss function, preprocess the bounding boxes and feed it back during back propagation.","Q_Score":1,"Tags":"python,tensorflow,keras,computer-vision,object-detection","A_Id":57368538,"CreationDate":"2019-08-01T19:24:00.000","Title":"feeding annotations as ground truth along with the images to the model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a function in python which reads the first 3 bytes in a serial port buffer. I then want to convert the third byte to an integer which will allow me to determine the length of the total byte array. However, when I use int() I get the following error: \nValueError: invalid literal for int() with base 16: b'\\x16'\nI've tried slicing the string further along, but that just returns b''. How can I convert the byte to an integer?\nThank you!","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8314,"Q_Id":57325964,"Users Score":3,"Answer":"Use int.from_bytes().\n\n>>> int.from_bytes(b'\\x00\\x10', byteorder='big')\n16\n>>> int.from_bytes(b'\\x00\\x10', byteorder='little')\n4096\n>>> int.from_bytes(b'\\xfc\\x00', byteorder='big', signed=True)\n-1024\n>>> int.from_bytes(b'\\xfc\\x00', byteorder='big', signed=False)\n64512\n>>> int.from_bytes([255, 0, 0], byteorder='big')\n16711680","Q_Score":1,"Tags":"python,python-3.x,integer,hex,byte","A_Id":57326044,"CreationDate":"2019-08-02T11:51:00.000","Title":"How do I convert a byte to an integer in python when it has the byte markers attached?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need some python advice to implement an algorithm.\nWhat I need is to detect which words from text 1 are in text 2:\n\nText 1: \"Mary had a dog. The dog's name was Ethan. He used to run down\n  the meadow, enjoying the flower's scent.\"\nText 2: \"Mary had a cat. The cat's name was Coco. He used to run down\n  the street, enjoying the blue sky.\"\n\nI'm thinking I could use some pandas datatype to check repetitions, but I'm not sure.\nAny ideas on how to implement this would be very helpful. Thank you very much in advance.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":57328345,"Users Score":0,"Answer":"You can use dictionary to first store words from first text and than just simply look up while iterating the second text. But this will take space.\nSo best way is to use regular expressions.","Q_Score":0,"Tags":"python,algorithm","A_Id":57335390,"CreationDate":"2019-08-02T14:20:00.000","Title":"Detecting which words are the same between two pieces of text","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need some python advice to implement an algorithm.\nWhat I need is to detect which words from text 1 are in text 2:\n\nText 1: \"Mary had a dog. The dog's name was Ethan. He used to run down\n  the meadow, enjoying the flower's scent.\"\nText 2: \"Mary had a cat. The cat's name was Coco. He used to run down\n  the street, enjoying the blue sky.\"\n\nI'm thinking I could use some pandas datatype to check repetitions, but I'm not sure.\nAny ideas on how to implement this would be very helpful. Thank you very much in advance.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":57328345,"Users Score":0,"Answer":"Since you do not show any work of your own, I'll just give an overall algorithm.\nFirst, split each text into its words. This can be done in several ways. You could remove any punctuation then split on spaces. You need to decide if an apostrophe as in dog's is part of the word--you probably want to leave apostrophes in. But remove periods, commas, and so forth.\nSecond, place the words for each text into a set.\nThird, use the built-in set operations to find which words are in both sets.\nThis will answer your actual question. If you want a different question that involves the counts or positions of the words, you should make that clear.","Q_Score":0,"Tags":"python,algorithm","A_Id":57328491,"CreationDate":"2019-08-02T14:20:00.000","Title":"Detecting which words are the same between two pieces of text","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"1) I have a script (calling python), that runs perfectly on local\n2) The same scripts crashes on cron\n3) I know it's related to environment as: env <my script> reproduces the error exactly\n4) I have no .bash, .profile or any of those common files. They do not exist but its clear the env is setup somehow.\nI tried printenv and tried to copy-paste into my script, it didnt work. \nAny ideas into where to look next?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":194,"Q_Id":57331096,"Users Score":0,"Answer":"A simple way to troubleshoot cron is to redirect the stdout and stderr to a log file\n\n5 * * * * path_to_yourscript > \/tmp\/cron_output.log 2>&1\n\nLet cron run and then take a look at the log file","Q_Score":0,"Tags":"python,cron","A_Id":57331834,"CreationDate":"2019-08-02T17:28:00.000","Title":"Simulate local run for cron job","Data Science and Machine Learning":0,"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 periodic task scheduled to run every 10 minutes.  Sometimes this task completes in 2-3 minutes, sometimes it takes 20 minutes.\nIs there any way using celery beats to not open the task if the previous task hasn't completed yet?  I don't see an option for it in the interval settings.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2134,"Q_Id":57334468,"Users Score":7,"Answer":"No, Celery Beat knows nothing about the running tasks.\nOne way to achieve what you are trying to do is to link the task to itself. async_apply() for an example has optional parameter link and link_error which can be used to provide a signature (it can be a single task too) to run if the task finishes successfully (link) or unsuccessfully (link_error).\nWhat I use is the following - I schedule task to run frequently (say every 5 minutes), and I use a distributed lock to make sure I always have only one instance of the task running.\nFinally a reminder - you can always implement your own scheduler, and use it in your beat configuration. I was thinking about doing this in the past for exactly the same thing you want, but decided that the solution I already have is good enough for me.","Q_Score":8,"Tags":"python,django,task,celery,scheduling","A_Id":57345459,"CreationDate":"2019-08-02T23:38:00.000","Title":"How to check if celery task is already running before running it again with beat?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a periodic task scheduled to run every 10 minutes.  Sometimes this task completes in 2-3 minutes, sometimes it takes 20 minutes.\nIs there any way using celery beats to not open the task if the previous task hasn't completed yet?  I don't see an option for it in the interval settings.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2134,"Q_Id":57334468,"Users Score":0,"Answer":"I use Celery with Django models and I implemented a boolean has_task_running at the model level. Then with Celery signals I change the state of the flag to True when signal before_task_publish is trigged and False when a task terminates. Not simple but flexible.","Q_Score":8,"Tags":"python,django,task,celery,scheduling","A_Id":72109220,"CreationDate":"2019-08-02T23:38:00.000","Title":"How to check if celery task is already running before running it again with beat?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I want to store time fields in Eve's schema. For example I would like to have a start_time field and end_time field. But Python Eve only provides datetime type.\nIs there any way to store a time in Python Eve, as I don't want Date included in the field?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":136,"Q_Id":57335412,"Users Score":0,"Answer":"Difference between two datetime objects is the time difference, which you may be able to store in an integer field with some quick arithmetic.","Q_Score":2,"Tags":"python,mongodb,flask,eve","A_Id":57335582,"CreationDate":"2019-08-03T04:14:00.000","Title":"Time only field in Python Eve","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to store time fields in Eve's schema. For example I would like to have a start_time field and end_time field. But Python Eve only provides datetime type.\nIs there any way to store a time in Python Eve, as I don't want Date included in the field?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":136,"Q_Id":57335412,"Users Score":0,"Answer":"use time.time().  it gives you the current time as the number of seconds since the epoch in float type.  get this value before and after and the difference is the time duration.  multiply the difference by 100000 to scale it to microseconds.","Q_Score":2,"Tags":"python,mongodb,flask,eve","A_Id":57335517,"CreationDate":"2019-08-03T04:14:00.000","Title":"Time only field in Python Eve","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking to make a bot for a game via on-screen keyboard. \nIs it possible to make pyautogui execute only on the on-screen keyboard and no other window?\nIs there any way to map the buttons into shortcuts that I can easily call.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":187,"Q_Id":57335921,"Users Score":0,"Answer":"You can use the locateOnScreen() function to find the coordinates of a button using a screenshot.\nWindow-specific functions are on the Roadmap (via PyGetWindow), but not implemented in pyautogui yet.\nYou may be able to check that the coordinates returned by locateOnScreen() are within your desired window if you can get the window's rectangle coordinates in some other way, like by calling PyGetWindow's getWindowsWithTitle() function yourself.","Q_Score":0,"Tags":"python,pyautogui","A_Id":57335949,"CreationDate":"2019-08-03T06:15:00.000","Title":"Using pyautogui exclusively for on-screen keyboard","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is tkinter able to make a smooth text transition(slowly appear into the Window)? In Windows 10, Python 3 ? I have tried searching through the web but no similar questions, I have tried seeing if the widget has an option to do that, but no luck!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1717,"Q_Id":57337718,"Users Score":1,"Answer":"You might be able to fake it using images. Use a timeout function to replace them one after the other. Not sure if that would be fast enough to appear smooth.\nBut for things like this I think other toolkits would be better suited. For example pysdl2.","Q_Score":1,"Tags":"python,python-3.x,user-interface,tkinter","A_Id":57337842,"CreationDate":"2019-08-03T11:03:00.000","Title":"Smooth Transition in Tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using a .env file to handle logging into sites in my application and have added *.env to my .gitignore for the moment for security. However, this login will be needed for anyone that installs the project so I \u200bwas wondering what the way forward is. Will I have to discard this layer of security?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":355,"Q_Id":57338371,"Users Score":0,"Answer":"I use the same method of configuring the environment variables for a development environment of my Node.js application. The approach that I have used is that I have explained the overall environment variables in a project wiki\u2014on GitLab. This helps other members of the team to create their own version of a .env file and configure the settings as per their machines. \nWe have more or less the following configurations, \n\nApplication Insights instrumentation keys\nSQL Server connection string, and its parts\nConfigurations for ORMs (delete tables)\nCurrent environment settings (production, development, testing)\n\nOf course these settings require a refresh, thus on each platform we either manually create a locally git-ignored .env file, or we use the CI\/CD environment settings to control the variables. \nOn GitLab, for instance, we can have the environment variables created in the .gitlab-ci.yml file which takes care of the variable injections for application to work fine. \n\nlogin will be needed for anyone that installs the project\n\nIf this login is for something related to production environment, then you need to rethink the overall security of your application. If these credentials are related to development or testing, then your team members can install the same tools and platforms on their own machines too. \nOh, one more thing, addition of .env file will surely cause problems on production when your application will load configurations on startup.","Q_Score":0,"Tags":"python,environment-variables","A_Id":57342859,"CreationDate":"2019-08-03T12:36:00.000","Title":"Is there a way to have deployment of a .env file while keeping security advantages of environment variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using a .env file to handle logging into sites in my application and have added *.env to my .gitignore for the moment for security. However, this login will be needed for anyone that installs the project so I \u200bwas wondering what the way forward is. Will I have to discard this layer of security?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":355,"Q_Id":57338371,"Users Score":1,"Answer":"Include a readme that explains the file needed and where to get the credentials for it.","Q_Score":0,"Tags":"python,environment-variables","A_Id":57338407,"CreationDate":"2019-08-03T12:36:00.000","Title":"Is there a way to have deployment of a .env file while keeping security advantages of environment variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"1) Is normalization necessary for Random Forests? \n2) Should all the features be normalized or only numerical ones? \n3) Does it matter whether I normalize before or after splitting into train and test data?\n4) Do I need to pre-process features of the future object that will be classified as well? (after accepting the model, not during the testing)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1234,"Q_Id":57339104,"Users Score":2,"Answer":"1) No! Feature normalization isn't necessary for any tree-based classifier.\n2) Generally speaking, normalization should be done on all features not just numerical ones.\n3) In practice it doesn't make much difference. However, the correct practice is to identify the min and max values of each feature from the training set and then normalize the features of both sets according to those values.\n4) Yes, afterwards any sample that needs to be classified should be processed with exactly the same way as you did during training.","Q_Score":2,"Tags":"python,data-science,normalization,preprocessor,feature-engineering","A_Id":57339152,"CreationDate":"2019-08-03T14:13:00.000","Title":"Is normalization necessary for RandomForest?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tried adding highlight_language and pygments_style in the config.py and also tried various ways I found online inside the .rst file. Can anyone offer any advice on how to get the syntax highlighting working?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":57340091,"Users Score":0,"Answer":"Sorry, it turns out that program arguments aren't highlighted (the test I was using)","Q_Score":0,"Tags":"python-sphinx,pygments","A_Id":57341047,"CreationDate":"2019-08-03T16:17:00.000","Title":"I can not get pigments highlighting for Python to work in my Sphinx documentation","Data 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 training a model and want to use the mAP metric. For some reason the tensorflow mean_average_precision_at_k does not work for me, but the sklearn average_precision_score works.\nHow can I have access to the keras's model outputs to perform the sklearn metrics?\nCan I compile the model one time and fit for 10 epochs, perform the metric and fit again for 10 epochs? Or do I need to save the model and reload it every time?\nThank you","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":258,"Q_Id":57340285,"Users Score":0,"Answer":"For any one who might have the same Issue. It seems that in Tensorflow 1.14, the implementation of Keras keeps the model weights, but restarts the optimizer which leads to bad results over many repetitions of the .fit() function. My loss is about 800 when using .fit() once and about 2800 when fitting for 5 epochs each time.","Q_Score":1,"Tags":"python,tensorflow,keras,metrics","A_Id":57507773,"CreationDate":"2019-08-03T16:40:00.000","Title":"Keras: Is there a need to reload the model if I train for 10 epochs multiple times?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training a model and want to use the mAP metric. For some reason the tensorflow mean_average_precision_at_k does not work for me, but the sklearn average_precision_score works.\nHow can I have access to the keras's model outputs to perform the sklearn metrics?\nCan I compile the model one time and fit for 10 epochs, perform the metric and fit again for 10 epochs? Or do I need to save the model and reload it every time?\nThank you","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":258,"Q_Id":57340285,"Users Score":1,"Answer":"Can I compile the model one time and fit for 10 epochs, perform the metric and fit again for 10 epochs\n\nYes, absolutely.\nThe model will keep the training weights between calls to fit(). You can call this as many times as you please.","Q_Score":1,"Tags":"python,tensorflow,keras,metrics","A_Id":57344741,"CreationDate":"2019-08-03T16:40:00.000","Title":"Keras: Is there a need to reload the model if I train for 10 epochs multiple times?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written some code in Python which allows 3D objects to be defined in 3D object space and mapped onto a 2D screen. Currently the finished 2D polygons are drawn on the screen using the PyGame library, which works effectively, but I would like to go the full way and write code myself to complete the drawing operations PyGame does for me. This means I would like to manually control the drawing of each pixel on the screen, with the use of GPU support to accelerate the entire rendering process. From some reading it seems OpenGL is suitable for this sort of thing, but I'm not sure what the complete purpose of OpenGL is and whether I could achieve what I am trying to do in a better way. Do I really need to use OpenGL? Or is there another way for me to directly access my GPU to draw at the pixel by pixel level?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":279,"Q_Id":57342295,"Users Score":0,"Answer":"It sounds like OpenGL's programmable shaders are what you're looking for (in particular fragment shaders). They run massively parallel on a pixel-by-pixel basis, in the sense that basically you write a function that takes a single pixel location and computes its color. Note that this means that the individual pixels can't exchange information, though there are certain ways around that.\n(Technically when I said \"pixel\" I meant \"fragment\", which is sort of a generalized version of a pixel.)","Q_Score":0,"Tags":"python,opengl,graphics,3d,pygame","A_Id":57345654,"CreationDate":"2019-08-03T21:42:00.000","Title":"Do I need to use OpenGL to draw at the pixel by pixel level (Python). Is there a way I can do such a thing without using a code library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying something when I came across this problem. I have a hashed password stored in a file on my computer. However the way my code detects whether or not a password has already been set is it checks if that file exists. If it does than it will ask you for the password that has been set. If the file does not exist than it will ask you to set a new password. But this also means that theoretically if someone wanted to break in they could just delete that file and enter a new password.\nHow do you go about solving this? I am not sure if this is a totally stupid question or not but I have no clue how to solve this.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":57343272,"Users Score":0,"Answer":"You don't have to ask for a password at all.\nJust deny all other users access to your script by settings permissions.\nIf you are sharing your user account consider someone could simply remove the password prompt from your script.","Q_Score":0,"Tags":"python,file,security,hash,passwords","A_Id":57345674,"CreationDate":"2019-08-04T02:00:00.000","Title":"How to properly save one hashed 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently developing mobile applications in Kivy. I would like to create an app to aid in the development process. This app would download an APK file from a network location and install\/run it. I know how to download files of course. How can I programmatically install and run an Android APK file in Kivy\/Android\/Python3?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":57343625,"Users Score":0,"Answer":"Look up how you would do it in Java, then you should be able to do it from Kivy using Pyjnius.","Q_Score":0,"Tags":"python,android,python-3.x,kivy","A_Id":57345743,"CreationDate":"2019-08-04T03:43:00.000","Title":"Install & run an extra APK file with Kivy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to control airflow DAG runs using my python code base. There is a start DAG api POST \/api\/experimental\/dags\/<DAG_ID>\/dag_runs\nBut want to know if there is any stop DAG api which can just mark all the task failed\/abort for that particular DAG","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1590,"Q_Id":57343676,"Users Score":0,"Answer":"You can pause it using \/api\/experimental\/dags\/\/paused\/ with boolean value.\nStopping a DAG is not available at this point in the experimental Rest API.\nUPDATE: There is something called _set_dag_run_state with paramers (dag_id, execution_date, state, session=None) with in mark_dags API. \nAlso, you could use set_dag_run_state_to_failed to mark a dag as failed and set_dag_run_state_to_running to mark a dag as a success. But I'm not quite sure what it's routeing could be.","Q_Score":2,"Tags":"python-3.x,airflow","A_Id":57346755,"CreationDate":"2019-08-04T03:57:00.000","Title":"Airflow api to stop a dag run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can we use recursion to calculate all dna sequences of length n in a function.\nFor instance if the function is given 2, it returns ['AA', 'AC', 'AT', 'AG', 'CA', 'CC', 'CT', 'CG', 'TA', 'TC', 'TT', 'TG', 'GA', 'GC', 'GT', 'GG']\netc...","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":647,"Q_Id":57343891,"Users Score":0,"Answer":"You actually want itertools.product('ACGT', repeat=n).  Note that this will grow enormously fast (4^n elements of n length).\nIf your assignment is to do it recursively, consider how you would get all n+1-length options that start with a n-length prefix.  The naive recursive option might be rather slow compared to itertools, if you need to use it in anger.","Q_Score":1,"Tags":"python,permutation","A_Id":57344041,"CreationDate":"2019-08-04T04:51:00.000","Title":"Create DNA Sequences of length n","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using vscode for only css and html and pycharm for python and lately I have switched to vscode also for my python scripts . I did all the necessary configurations and extensions installations I even installed code runner but so far I have not been able to properly run my python scripts without passing through the debug face when I click on the run button it still shows only the output from the previous run.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":57343961,"Users Score":0,"Answer":"I believe you are trying to run the code like a Jupyter notebook. If you highlight code and press shift+enter it should turn on a python interpreter that runs the code in a new pane.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":57344236,"CreationDate":"2019-08-04T05:05:00.000","Title":"How to fix run issues in vscode for python scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I am doing pip install pytesseract. I get following error in Jupyter Notebook:\n\nC:\\users\\' is not recognized as an internal or external command, operable program or batch file.\n\nI have connected all paths still in the same way.\nI am running on Windows\nHow do I solve this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":57344352,"Users Score":0,"Answer":"Open Anaconda Prompt from the start menu.\nAnd then install your package using pip install package_name\nThen start Jupyter Notebook using the command jupyter notebook in the same console. I hope it works!","Q_Score":0,"Tags":"python,python-3.x,jupyter-notebook","A_Id":57345066,"CreationDate":"2019-08-04T06:31:00.000","Title":"I get User not recognised error in Jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given a Java string and an offset into that String, what is the correct way of calculating the offset of that same location into an UTF8 string?\nMore specifically, given the offset of a valid codepoint in the Java string, how can one map that offset to a new offset of that codepoint in a Python 3 string? And vice versa?\nIs there any library method which already provides the mapping between Java String offsets and Python 3 string offsets?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":315,"Q_Id":57345598,"Users Score":0,"Answer":"No, there cannot be. UTF-16 uses a varying number of code units per codepoint and so does UTF-8. So, the indices are entirely dependent on the codepoints in the string. You have to scan the string and count. \nThere are relationships between the encodings, though. A codepoint has two UTF-16 code units if and only if it has four UTF-8 code units. So, an algorithm could tally UTF-8 code units by scanning UTF-16 codepoints: 4 four a high surrogate, 0 for a low surrogate, 3 for some range, 2 for another and 1 for another.","Q_Score":3,"Tags":"java,python-3.x,unicode,utf-8,utf-16","A_Id":57348500,"CreationDate":"2019-08-04T09:57:00.000","Title":"Java code to convert between UTF8 and UTF16 offsets (Java string offsets to\/from Python 3 string offsets)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am training a model with 107850 samples and validating on 26963 samples.\nHow much should batch size and number of epochs be when fitting a model in Keras to optimize the validation accuracy? Is there any sort of rule of thumb to use based on data input size? Does it overfit a model if an increased number of epochs? \nThank You.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":456,"Q_Id":57345714,"Users Score":0,"Answer":"No! Their is not any rule of thumb for selecting the batch size of the data. Its a trade off between better accuracy and time. So we have to take the batch size which will process our data fast and give good accuracy too. Now what happens when you take too large batch size. Actually after every batch your model is going to update their all the weights. Large batch size large error than according to the error your model will adjust weight. Now After processing a large number of batch and update the weight take less time than taking smaller batch and updating the weights after every batch. But when you take small batch size your model will update weights after every batch i.e(16,32,64) etc whatever you want than your model will be able to learn your data more accurately but its take time to update all the weights after every batch.\nNow According to the research papers most of the researchers use batch size\n(16,32,64) may be researcher use larger batch sizes but I haven't seen yet.\nI hope that answer is helpful for you.\nand if you want number of epochs to be optimized use callbacks for your neural network your neural network will automatically stop learning if your model is not learning for more than 4 or 5 epochs depends on you.","Q_Score":3,"Tags":"python,machine-learning,keras,neural-network","A_Id":57345858,"CreationDate":"2019-08-04T10:18:00.000","Title":"How much should batch size and number of epochs be when fitting a model in Keras?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am wondering why when I use list(dictionary) it only returns keys and not their definitions into a list?\nFor example, I import a glossary with terms and definitions into a dictionary using CSV reader, then use the built in list() function to convert the dictionary to a list, and it only returns keys in the list.\nIt's not really an issue as it actually allows my program to work well, was just wondering is that just how it is supposed to behave or?\nMany thanks for any help.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":262,"Q_Id":57346935,"Users Score":0,"Answer":"In short: In essence it works that way, because it was designed that way. It makes however sense if we take into account that x in some_dict performs a membercheck on the dictionary keys.\n\nFrequently Python code iterates over a collection, and does not know the type of the collection it iterates over: it can be a list, tuple, set, dictionary, range object, etc.\nThe question is, do we see a dictionary as a collection, and if yes, a collection of what? If we want to make it collection, there are basically three logical answers to the second question: we can see it as a collection of the keys, of the values, or key-value pairs. Especially keys and key-value pairs are popular. C# for example sees a dictionary as a collection of KeyValuePair<TK, TV>s. Python provides the .values() and .items() method to iterate over the values and key-value pairs.\nDictionaries are mainly designed to perform a fast lookup for a key and retrieve the corresponding value. Therefore the some_key in some_dict would be a sensical query, or (some_key, some_value) in some_dict, since the latter chould check if the key is in the dictionary, and then check if it matches with some_value. The latter is however less flexible, since often we might not want to be interested in the corresponding value, we simply want to check if the dictionary contains a certain key. We furthermore can not support both use cases concurrently, since if the dictionary would for example contain 2-tuples as keys, then that means it is ambiguous if (1, 2) in some_dict would mean that for key 1 the value is 2; or if (1, 2) is a key in the dictionary.\nSince the designers of Python decided to define the membership check on dictionaries on the keys, it makes more sense to make a dictionary an iterable over its keys. Indeed, one usually expects that if x in some_iterable holds, then x in list(some_iterable) should hold as well. If the iterable of a dictionary would return 2-tuples of key-value pairs (like C# does), then if we would make a list of these 2-tuples, it would not be in harmony with the membership check on the dictionary itself. Since if 2 in some_dict holds, 2 in list(some_dict) would fail.","Q_Score":2,"Tags":"python","A_Id":57349962,"CreationDate":"2019-08-04T13:24:00.000","Title":"Why converting dictionaries to lists only returns keys?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a bit clueless. I have a csv file with these columns: name - picture url\nI would like to bulk download the 70k images into a folder, rename the images with the name in the first column and number them if there is more than one per name.\nSome are jpegs some are pngs. \nI'm guessing I need to use pandas to get the data from the csv but I don't know how to make the downloading\/renaming part without starting  all the downloads at the same time, which will for sure crash my computer (It did, I wasn't even mad).\nThanks in advance for any light you can shed on this.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":642,"Q_Id":57346966,"Users Score":1,"Answer":"Try downloading in batches like 500 images...then sleep for some 1 seconds and loop it....quite time consuming...but sure fire method....for the coding reference you can explore packges like urllib (for downloading) and as soon as u download the file use os.rename() to change the name....As u already know for that csv file use pandas...","Q_Score":0,"Tags":"python,image,url,download,bulk","A_Id":57347119,"CreationDate":"2019-08-04T13:31:00.000","Title":"How do I bulk download images (70k) from urls with a restriction on the simultaneous downloads?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an image stored in a 2D array called data. I know how to calculate the standard deviation of the entire array using numpy that outputs one number quantifying how much the data is spread. However, how can I made a standard deviation map (of the same size as my image array) and each element in this array is the standard deviation of the corresponding pixel in the image array (i.e, data).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5088,"Q_Id":57351759,"Users Score":1,"Answer":"Use slicing, given images[num, width, height] you may calculate std. deviation of a single image using images[n].std() or for a single pixel: images[:, x, y].std()","Q_Score":0,"Tags":"python,arrays,numpy,standard-deviation","A_Id":57351808,"CreationDate":"2019-08-05T03:07:00.000","Title":"Standard Deviation of every pixel in an image in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using PySpark and I need to convert each row in a DataFrame to a JSON file (in s3), preferably naming the file using the value of a selected column.\nCouldn't find how to do that. Any help will be very appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":166,"Q_Id":57353211,"Users Score":0,"Answer":"I think directly we can't store for each row as a JSON based file. Instead of that we can do like iterate for each partition of dataframe and connect to S3 using AWS S3 based library's (to connect to S3 on the partition level). Then, On each partition with the help of iterator, we can convert the row into JSON based file and push to S3.","Q_Score":0,"Tags":"python,apache-spark,amazon-s3,pyspark,pyspark-sql","A_Id":57353337,"CreationDate":"2019-08-05T06:28:00.000","Title":"Convert each row in a PySpark DataFrame to a file in s3","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to learn NLP with python,I have some questions\n\nwhat ide is better?\nwhat is jupyter notebook and why every tutorial use this? (should i use this as ide for python)\nwhat package is better for persian language?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":57353666,"Users Score":0,"Answer":"Jupyter notebooks \/ Jupyter lab is used for it's interactive capability and the benefit of being able to mix code and documentation. Plus you can do inline visualisations and see what your data looks like.\nIt is used for iterative development, you should use this for exploratory data analysis and experimentation, but still use a full featured IDE for any other coding, including translating your notebooks (when complete) if you intend to run them in some sort of production environment","Q_Score":0,"Tags":"python,nlp,jupyter-notebook","A_Id":57353729,"CreationDate":"2019-08-05T07:04:00.000","Title":"Why using jupyter notebook in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to add a package to PyPi so I can install it with Pip. I am trying to add it using twine upload dist\/*. \nThis causes me to get multiple SSL errors such as raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='upload.pypi.org', port=443): Max retries exceeded with url: \/legacy\/ (Caused by SSLError(SSLError(\"bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])\"))).\nI am using a school laptop and I presume that this is something my administrator has done however I can install stuff with pip by using pip3 install --trusted-host pypi.org --trusted-h\\ost files.pythonhosted.org.\n I was wondering if there was another to add my package to pip?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1790,"Q_Id":57354747,"Users Score":5,"Answer":"My guess is your school has something in place where they are replacing the original cert with their own, you could maybe get around it using --cert and referencing the path for your schools cert, but I think an easier workaround is to copy the files to a non school computer and upload from there.","Q_Score":5,"Tags":"python,ssl,pypi,twine","A_Id":57393456,"CreationDate":"2019-08-05T08:24:00.000","Title":"When adding package to PyPi SSL error occurs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm reading a sequence of bytes to a list in python so that I can use them later, however some of the bytes are in pairs which represent one value. For some reason when I extend my list using list.extend(byte), it converts the bytes to integer values automatically, meaning that I can't get my two byte values back as they are now returned as two separate integers. E.g. my list is now 184 22 1 1.... instead of the appropriate hex values. How can I parse the bytes to a list while keeping them as bytes? Many thanks.\nEDIT: I fixed the problem by initialising the list as a bytearray instead.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":200,"Q_Id":57356767,"Users Score":0,"Answer":"Initialising the list as a bytearray fixed the problem","Q_Score":0,"Tags":"python,arrays,byte","A_Id":57357497,"CreationDate":"2019-08-05T10:30:00.000","Title":"How can I prevent my python list from converting bytes into integers automatically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to print the following using an f string literal. It will be running wihtin a function and apples will be one of the arguments. I want it to have the square brackets included.\n\"I like [apples] because they are green\"\nI have tried the following code:\n\"I like {} because they are green\".format(\"apples\")\nThe code above prints:\nI like apples because they are green\nHow do I insert the square brackets [ ] or another special character such as < > into the f string literal?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4771,"Q_Id":57362635,"Users Score":2,"Answer":"There are a couple possible ways to do this:\n\"I like [{}] because they are green\".format(\"apples\")\nor\n\"I like {} because they are green\".format(\"[apples]\").\nIf instead of brackets you wanted to use actual special characters, you would just have to escape in the appropriate place:\n\"I like {} because they are green\".format(\"\\\"apples\\\"\").\nAdditionally, if you wanted to use actual f-strings, you could do the same thing as above but with the format:\nf\"I like {'[apples]'} because they are green\"\nbut make sure to switch from double quotes to single quotes inside the brackets to avoid causing troubles by ending your string early.","Q_Score":0,"Tags":"python,string,f-string","A_Id":57363075,"CreationDate":"2019-08-05T16:32:00.000","Title":"F String With Special Characters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say my startup directory for Jupyter is \/User\/All\/Directory\/, how can I load a notebook from \/User\/All\/ in Jupyter without changing the startup directory?\nI'm working with a Mac, in case that's relevant.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":57363770,"Users Score":0,"Answer":"Check all path of anaconda is proper or not, then open terminal, go on that path where you want to open jupyter notebook and type \"jupyter notebook\" and press enter, jupyter notebook will open in default browser.","Q_Score":0,"Tags":"python,jupyter-notebook,jupyter","A_Id":57369660,"CreationDate":"2019-08-05T17:53:00.000","Title":"Load Jupyter notebook from outside pre-set startup directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"All,\nI have googled this to death but I can't figure out how to parse this type of JSON packet.\n{\n\"recipients\":[\n\"\\\"Name 1\\\" \",\n\"\\\"Name 2\\\" \",\n\"\\\"Name 3\\\" \"\n]\n}\nAny help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12,"Q_Id":57364095,"Users Score":0,"Answer":"very simple, as my code:\nimport json\nj = json.loads('{\"recipients\": [\"Name 1\", \"Name 2\",\"Name 3\"] }')\nprint (j['recipients'])\n=> ['Name 1', 'Name 2', 'Name 3']","Q_Score":0,"Tags":"json,python-2.7","A_Id":57364203,"CreationDate":"2019-08-05T18:19:00.000","Title":"Assistance with parsing Json packet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some .xls datas in my Google Cloud Storage and want to use airflow to store it to GCP. Can I export it directly to BigQuery or can i use additional library (such a pandas and xlrd) to convert the files and store it into BigQuery? \nThanks","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":542,"Q_Id":57367921,"Users Score":2,"Answer":"Bigquery don't support xls format. The easiest way is to transform the file in CSV and to load it into big query.\nHowever, I don't know your xls format. If it's multisheet you have to work on the file.","Q_Score":0,"Tags":"excel,google-cloud-storage,airflow,xls,python-bigquery","A_Id":57369728,"CreationDate":"2019-08-06T01:50:00.000","Title":"Import XLS file from GCS to BigQuery","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"in a standard neural network, I'm trying to understand, intuitively, what the values of a hidden layer mean in the model.\nI understand the calculation steps, but I still dont know how to think about the hidden layers and how interpret the results (of the hidden layer)\nSo for example, given the standard MNIST datset that is used to train and predict handwritten digits between 0 to 9, a model would look like this:\n\nAn image of a handwritten digit will have 784 pixels.\nSince there are 784 pixels,  there would be 784 input nodes and the value of each node is the pixel intensity(0-255)\neach node branches out and these branches are the weights.\nMy next layer is my hidden layer, and the value of a given node in the hidden layer is the weighted sum of my input nodes (pixels*weights).\nWhatever value I get, I squash it with a sigmoid function and I get a value between 0 and 1.\n\nThat number that I get from the sigmoid.  What does it represent exactly and why is it relevant?  My understanding is that if I want to build more hidden layers, I'll be using the values of my initial hidden layer, but at this point, i'm stuck as to what the values of the first hidden layer mean exactly.\nThank you!","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":395,"Q_Id":57369148,"Users Score":0,"Answer":"AFAIK, for this digit recognition case, one way to think about it is each level of the hidden layers represents the level of abstraction.\nFor now, imagine the neural network for digit recognition has only 3 layers which is 1 input layer, 1 hidden layer and 1 output layer.\nLet's take a look at a number. To recognise that it is a number we can break the picture of the number to a few more abstract concepts such as lines, circles and arcs. If we want to recognise 6, we can first recognise the more abstract concept that is exists in the picture. for 6 it would be an arc and a circle for this example. For 8 it would be 2 circles. For 1 it would be a line.\nIt is the same for a neural network. We can think of layer 1 for pixels, layer 2 for recognising the abstract concept we talked earlier such as lines, circles and arcs and finally in layer 3 we determine which number it is.\nHere we can see that the input goes through a series of layers from the most abstract layer to the less abstract layer (pixels -> line, circle, arcs -> number). In this example we only have 1 hidden layer but in real implementation it would be better to have more hidden layer that 1 depending on your interpretation of the neural network. Sometime we don't even have to think about what each layer represents and let the training do it fo us. That is the purpose of the training anyway.","Q_Score":0,"Tags":"python,tensorflow,neural-network","A_Id":57369487,"CreationDate":"2019-08-06T04:52:00.000","Title":"what do hidden layers mean in a neural network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"in a standard neural network, I'm trying to understand, intuitively, what the values of a hidden layer mean in the model.\nI understand the calculation steps, but I still dont know how to think about the hidden layers and how interpret the results (of the hidden layer)\nSo for example, given the standard MNIST datset that is used to train and predict handwritten digits between 0 to 9, a model would look like this:\n\nAn image of a handwritten digit will have 784 pixels.\nSince there are 784 pixels,  there would be 784 input nodes and the value of each node is the pixel intensity(0-255)\neach node branches out and these branches are the weights.\nMy next layer is my hidden layer, and the value of a given node in the hidden layer is the weighted sum of my input nodes (pixels*weights).\nWhatever value I get, I squash it with a sigmoid function and I get a value between 0 and 1.\n\nThat number that I get from the sigmoid.  What does it represent exactly and why is it relevant?  My understanding is that if I want to build more hidden layers, I'll be using the values of my initial hidden layer, but at this point, i'm stuck as to what the values of the first hidden layer mean exactly.\nThank you!","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":395,"Q_Id":57369148,"Users Score":0,"Answer":"Consider a very basic example of AND, OR, NOT and XOR functions.\nYou may already know that a single neuron is only suitable when the problem is linearly separable.\nHere in this case, AND, OR and NOT functions are linearly separable and so they can be easy handled using a single neuron.\nBut consider the XOR function. It is not linearly separable. So a single neuron will not be able to predict the value of XOR function.\nNow, XOR function is a combination of AND, OR and NOT. Below equation is the relation between them:\n\na XOR b = (a AND (NOT b)) OR ((NOT a) AND b)\n\nSo, for XOR, we can use a network which contain three layers.\nFirst layer will act as NOT function, second layer will act as AND of the output of first layer and finally the output layer will act as OR of the 2nd hidden layer.\nNote: This is just a example to explain why it is needed, XOR can be implemented in various other combination of neurons.","Q_Score":0,"Tags":"python,tensorflow,neural-network","A_Id":57369294,"CreationDate":"2019-08-06T04:52:00.000","Title":"what do hidden layers mean in a neural network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"in a standard neural network, I'm trying to understand, intuitively, what the values of a hidden layer mean in the model.\nI understand the calculation steps, but I still dont know how to think about the hidden layers and how interpret the results (of the hidden layer)\nSo for example, given the standard MNIST datset that is used to train and predict handwritten digits between 0 to 9, a model would look like this:\n\nAn image of a handwritten digit will have 784 pixels.\nSince there are 784 pixels,  there would be 784 input nodes and the value of each node is the pixel intensity(0-255)\neach node branches out and these branches are the weights.\nMy next layer is my hidden layer, and the value of a given node in the hidden layer is the weighted sum of my input nodes (pixels*weights).\nWhatever value I get, I squash it with a sigmoid function and I get a value between 0 and 1.\n\nThat number that I get from the sigmoid.  What does it represent exactly and why is it relevant?  My understanding is that if I want to build more hidden layers, I'll be using the values of my initial hidden layer, but at this point, i'm stuck as to what the values of the first hidden layer mean exactly.\nThank you!","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":395,"Q_Id":57369148,"Users Score":0,"Answer":"A hidden layer in a neural network may be understood as a layer that is neither an input nor an output, but instead is an intermediate step in the network's computation.\nIn your MNIST case, the network's state in the hidden layer is a processed version of the inputs, a reduction from full digits to abstract information about those digits.\nThis idea extends to all other hidden layer cases you'll encounter in machine learning -- a second hidden layer is an even more abstract version of the input data, a recurrent neural network's hidden layer is an interpretation of the inputs that happens to collect information over time, or the hidden state in a convolutional neural network is an interpreted version of the input with certain features isolated through the process of convolution.\nTo reiterate, a hidden layer is an intermediate step in your neural network's process.  The information in that layer is an abstraction of the input, and holds information required to solve the problem at the output.","Q_Score":0,"Tags":"python,tensorflow,neural-network","A_Id":57369365,"CreationDate":"2019-08-06T04:52:00.000","Title":"what do hidden layers mean in a neural network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm syncing a large amount of data and I'm getting this error back: A string literal cannot contain NUL (0x00) characters. Obviously this is a postgres problem, but I'm not quite sure how to solve it. Is there a way to strip null characters out at the Django model level? I have a large set of fields that I'm syncing.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":9755,"Q_Id":57371164,"Users Score":2,"Answer":"Unless you definitely do want to store NUL characters, you should sanitize your text  so it does not contain them. At the model level, you'd define a clean_fieldname method to do that.\nIf you do want to store them, you need to store them in a binary-compatible field in the database. Django 1.6+ has BinaryField which should work.","Q_Score":11,"Tags":"python,django,postgresql","A_Id":57372080,"CreationDate":"2019-08-06T07:41:00.000","Title":"Django + Postgres: A string literal cannot contain NUL (0x00) characters","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm writing a migration that converts a ForeignKeyField to a ManyToManyField. Part of this migration involves data migration. Migrating forwards is easy and requires no user interaction. Migrating backwards however ideally requires the user to pick which of the m2m to become the foreign key (ie there's a recognition of data loss).\nAdditionally. the user performing the migration might want to be given a python shell so they can poke around and look at objects before answering the question.\nAnd some users might not care, and might not want to be prompted at all. (ie they use the --no-input argument during migration)\nDoes django have a built in mechanism to do all this? I can't find anything, but at the back of my mind it seems like something I've seen somewhere.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":140,"Q_Id":57372221,"Users Score":1,"Answer":"If you really need to interactively ask for user input during a migration, you can use the InteractiveMigrationQuestioner in django.db.migrations.questioner.\nSubclass it, add your own question (e.g. ask_which_instance) with its arguments. You can use the _ask_choice method to let users choose from multiple options.\nThen in your backward() method, instantiate it and call your question method (which should return the user's input, e.g. 1, 2 or 3 if you offer 3 choices).","Q_Score":0,"Tags":"python,django,migration","A_Id":57572147,"CreationDate":"2019-08-06T08:47:00.000","Title":"Django: How to prompt user during migration?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to set a breakpoint in an external Python module in VS code.\nI have tried editing the source file and inserting import pdb; pdb.set_trace() where I want the breakpoint.\nThis enters the pdb command line debugger rather than the debugger in the VS Code GUI.\nHow do I set a breakpoint in an imported Python module so that I enter the VS Code debugger?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5446,"Q_Id":57373359,"Users Score":1,"Answer":"You need to import the folder containing the source code of the imported module into the project, using file -> add folder to workspace.  In my case this was \/Users\/robinl\/anaconda3\/lib\/python3.6\/site-packages\/great_expectations\/\nWithin VS code, you can then navigate to the file you want to debug and set a breakpoint by clicking to the left of the code as normal.","Q_Score":16,"Tags":"python,visual-studio-code,vscode-debugger","A_Id":57373360,"CreationDate":"2019-08-06T09:51:00.000","Title":"Set breakpoint in imported python module in vs code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing OCR on Raw PDF file where in i am converting into png images and doing OCR on that. My objective is to extract coordinates for a certain keyword from png and showcase those coordinates on actual raw pdf.\nI have already tried showing those coordinates on png images using opencv but i am not able to showcase those coordinates on actual raw pdf since the coordinate system of both format are different. Can anyone please helpme on how to showcase bounding box on actual raw pdf based on the coordinates generated from png images.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":303,"Q_Id":57373489,"Users Score":-1,"Answer":"All you need to do is map the coordinates of the OCR token (which would be given for the image) to that of the pdf page. \nFor instance, \nimage_dimensions = [1800, 2400] # width, height\npdf_page_dimension = [595, 841] # these are coordinates of the specific page of the pdf\nAssuming, on OCRing the image, a word has coordinates  = [400, 700, 450, 720] , the same can be rendered on the pdf by multiplying them with scale on each axis\nx_scale = pdf_page_dimension[0] \/ image_dimensions[0]\ny_scale = pdf_page_dimension[1] \/ image_dimensions[1]\nscaled_coordinates = [400*x_scale, 700*y_scale, 450*x_scale, 720*y_scale]\nPdf page dimensions can be obtained from any of the packages: poppler, pdfparser, pdfminer, pdfplumber","Q_Score":0,"Tags":"python,opencv,nlp,ocr,tesseract","A_Id":61167395,"CreationDate":"2019-08-06T09:58:00.000","Title":"Showing text coordinate from png on raw .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've made a script for forecasting time series data in Python 3. I've made this for a colleague of mine, however he has no knowledge of Python or coding in general. So  I was thinking about making some sort of app with an GUI for him, so he can run the program locally on his computer, and pass maybe 2-3 arguments to the underlying script. \nCan this be achieved in pure Python, and if yes, in what libraries? If not, what are the alternatives? What considerations should I make? \nI've never done this before, so I'm looking for something beginner friendly. \nEDIT:\nSo, in my script I query some time series from an SQL server, and then process it. In my GUI\/dashboard I need to be able to pass the time interval and a string parameter for selecting multiple time series (some id that selects the wanted time series).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":57376590,"Users Score":0,"Answer":"you can achieve this by using python and QtPy.","Q_Score":0,"Tags":"python,user-interface","A_Id":57376694,"CreationDate":"2019-08-06T12:55:00.000","Title":"Quick and easy application\/UI for Python forecasting script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is the environment:\n\nAWS Aurora database compatible with MySql.\nDjango 2.0.3 (Python 3.6)\nPip-Mysql dependencies: django-mysql==2.2.2, mysqlclient==1.3.12.\nMaster-Slave database configuration.\n\nIt seems that django or mysql engine always fails on certain queries resulting in this specific error:\n\nTraceback (most recent call last):   File\n  \"\/home\/ubuntu\/ivs\/vpython\/lib\/python3.6\/site-packages\/django\/db\/models\/fields\/related_descriptors.py\",\n  line 158, in get\n      rel_obj = self.field.get_cached_value(instance)   File \"\/home\/ubuntu\/ivs\/vpython\/lib\/python3.6\/site-packages\/django\/db\/models\/fields\/mixins.py\",\n  line 13, in get_cached_value\n      return instance._state.fields_cache[cache_name] KeyError: 'assigned_to'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"\/home\/ubuntu\/ivs\/vpython\/lib\/python3.6\/site-packages\/django\/db\/backends\/utils.py\",\n  line 85, in _execute\n      return self.cursor.execute(sql, params)   File \"\/home\/ubuntu\/ivs\/vpython\/lib\/python3.6\/site-packages\/django\/db\/backends\/mysql\/base.py\",\n  line 71, in execute\n      return self.cursor.execute(query, args)   File \"\/home\/ubuntu\/ivs\/vpython\/lib\/python3.6\/site-packages\/MySQLdb\/cursors.py\",\n  line 253, in execute\n      self._warning_check()   File \"\/home\/ubuntu\/ivs\/vpython\/lib\/python3.6\/site-packages\/MySQLdb\/cursors.py\",\n  line 148, in _warning_check\n      warnings = db.show_warnings()   File \"\/home\/ubuntu\/ivs\/vpython\/lib\/python3.6\/site-packages\/MySQLdb\/connections.py\",\n  line 381, in show_warnings\n      self.query(\"SHOW WARNINGS\")   File \"\/home\/ubuntu\/ivs\/vpython\/lib\/python3.6\/site-packages\/MySQLdb\/connections.py\",\n  line 277, in query\n      _mysql.connection.query(self, query)\n  _mysql_exceptions.OperationalError: (2013, 'Lost connection to MySQL server during query')\n\nYes, one of my models have \"assigend_to\" field which is a foreign key. But why does it fail with a KeyError?\nDid anyone have any similar KeyErrors and MySql lost connections as a result?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":629,"Q_Id":57377238,"Users Score":0,"Answer":"Wow, what actually was happening is this:\n\nI was making queries with reverse-foreign keys.\nObjects returned with with reverse-foreign keys contained some other foreign keys.\nWhen I tried to access them e.g. 'assigned_to' i got this exception every time.","Q_Score":0,"Tags":"mysql,django,python-3.x,django-models,amazon-aurora","A_Id":57509740,"CreationDate":"2019-08-06T13:29:00.000","Title":"Django ORM key error with lost MySql connection","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am in a situation where I have two endpoints I can ask for a value, and one may be faster than the other. The calls to the endpoints are blocking. I want to wait for one to complete and take that result without waiting for the other to complete.\nMy solution was to issue the requests in separate threads and have those threads set a flag to true when they complete. In the main thread, I continuously check the flags (I know it is a busy wait, but that is not my primary concern right now) and when one completes it takes that value and returns it as the result. \nThe issue I have is that I never clean up the other thread. I can't find any way to do it without using .join(), which would just block and defeat the purpose of this whole thing. So, how can I clean up that other, slower thread that is blocking without joining it from the main thread?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1503,"Q_Id":57377390,"Users Score":0,"Answer":"One bad and dirty solution is to implement a methode for the threads which close the socket which is blocking. Now you have to catch the exception in the main thread.","Q_Score":2,"Tags":"python,python-3.x,multithreading,asynchronous","A_Id":57377511,"CreationDate":"2019-08-06T13:39:00.000","Title":"Clean up a thread without .join() and without blocking the main thread","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently trying to use HDBSCAN to cluster movie data. The goal is to cluster similar movies together (based on movie info like keywords, genres, actor names, etc) and then apply LDA to each cluster and get the representative topics. However, I'm having a hard time evaluating the results (apart from visual analysis, which is not great as the data grows). With LDA, although it's hard to evaluate it, i've been using the coherence measure. However, does anyone have any idea on how to evaluate the clusters made by HDBSCAN? I haven't been able to find much info on it, so if anyone has any idea, I'd very much appreciate!","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2279,"Q_Id":57377594,"Users Score":2,"Answer":"Its the same problem everywhere in unsupervised learning.\nIt is unsupervised, you are trying to discover something new and interesting. There is no way for the computer to decide whether something is actually interesting or new. It can decide and trivial cases when the prior knowledge is coded in machine processable form already, and you can compute some heuristics values as a proxy for interestingness. But such measures (including density-based measures such as DBCV are actually in no way better to judge this than the clustering algorithm itself is choosing the \"best\" solution).\nBut in the end, there is no way around manually looking at the data, and doing the next steps - try to put into use what you learned of the data. Supposedly you are not invory tower academic just doing this because of trying to make up yet another useless method... So use it, don't fake using it.","Q_Score":2,"Tags":"python,cluster-analysis,evaluation,hdbscan","A_Id":57383549,"CreationDate":"2019-08-06T13:48:00.000","Title":"How to evaluate HDBSCAN text clusters?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to setup a simple process to modify my CSV file and ingest it to the elasticsearch DB using Apache Nifi. I don't want to stream my CSV file on Stdout, while passing my file from one processor to another.\nI've already made two flows.\nMyfirst flow get my CSV file using GetFile processor, customizes it using ExecuteStreamCommand in which i  run my python script to read,modify and save my CSV file locally. \nMy second flow again read that modified CSV file using GetFile processor and ingest it directly to my ElasticSearch DB.\nNow, for getting this task accomplished, i run these two flows seperatly. \nCan i connect the ExecuteStreamCommand of my first flow and GetFile of my second flow together, so that i can run them together as one single flow.\nIs there any other option to read a file written by ExecuteStreamCommand locally without streaming ??","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":312,"Q_Id":57378012,"Users Score":1,"Answer":"The output of the command executed by ExecuteStreamCommand will be written to a flow file that is transferred to the \"output stream\" relationship. You should be able to connect ExecuteStreamCommand \"output stream\" directly to PutElasticSearch.","Q_Score":0,"Tags":"python,csv,elasticsearch,apache-nifi","A_Id":57378682,"CreationDate":"2019-08-06T14:09:00.000","Title":"Apache Nifi : I want to ingest my Data CSV to Elasticsearch without streaming it to some other processor using apache nifi","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for the best way to preform ETL using Python.\nI'm having a channel in RabbitMQ which send events (can be even every second). \nI want to process every 1000 of them.\nThe main problem is that RabbitMQ interface (I'm using pika) raise callback upon every message.\nI looked at Celery framework, however the batch feature was depreciated in version 3.\nWhat is the best way to do it? I thinking about saving my events in a list, and when it reaches 1000 to copy it to other list and preform my processing. However, how do I make it thread-safe? I don't want to lose events, and I'm afraid of losing events while synchronising the list.\nIt sounds like a very simple use-case, however I didn't find any good best practice for it.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5901,"Q_Id":57378832,"Users Score":1,"Answer":"First of all, you should not \"batch\" messages from RabbitMQ unless you really have to. The most efficient way to work with messaging is to process each message independently. \nIf you need to combine messages in a batch, I would use a separate data store to temporarily store the messages, and then process them when they reach a certain condition. Each time you add an item to the batch, you check that condition (for example, you reached 1000 messages) and trigger the processing of the batch. \nThis is better than keeping a list in memory, because if your service dies, the messages will still be persisted in the database. \nNote : If you have a single processor per queue, this can work without any synchronization mechanism. If you have multiple processors, you will need to implement some sort of locking mechanism.","Q_Score":3,"Tags":"python-3.x,rabbitmq,etl","A_Id":57414807,"CreationDate":"2019-08-06T14:54:00.000","Title":"Best Practice for Batch Processing with RabbitMQ","Data Science and Machine Learning":0,"Database and SQL":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 Program that uses Speech Recognition (SR), And I know that a popular library for this in Speech Recognition. I download speech recognition with pip install SpeechRecognition. I found Out while working on the code I need PyAudio. I tried to install this however it gave me the following error.  error: Microsoft Visual C++ 14.0 is required. Get it with \"Microsoft Visual C++ Build Tools\": https:\/\/visualstudio.microsoft.com\/downloads\/. I have looked for tutorials on how to download this, and I have download it, but it still does not work. Can someone please give me a more detailed explination or point me towards a video on how to install it for python on windows and Add it to the path. Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":934,"Q_Id":57381727,"Users Score":0,"Answer":"@andew i also had the same issue but then when i installed it it showed that the debuger is not working so i downeadeed my pthon version by first install th version 3.6.0 from python.org and then is visual studio code i chose the 3.6.0 interpreter and booooom it worked","Q_Score":1,"Tags":"python,python-3.x,speech-recognition,text-to-speech,pyaudio","A_Id":66720985,"CreationDate":"2019-08-06T18:06:00.000","Title":"Speech Recognition in Python PyAudio needs Visual Studio Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose that I need some functionalities for my class(C) which are currently available in both  A and B classes. So I decided to inherit from A or B in my class (C). A is more complete and includes some additional methods and variables which I will never use them. However, I prefer to use A since it seems to make my code more unified in a joint project.\nMy question is that does inheritance from A, in comparison with B, affect the code speed or not?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":57387487,"Users Score":0,"Answer":"In CPython, changing the class from which a class inherits has little or no impact on its speed so long as each method\/attribute used comes from the corresponding class in the new hierarchy.  (The \u201clittle\u201d case pertains when there are additional hash table collisions.)  Adding additional bases that must be searched (because they appear in the method resolution order before the class that satisfies a lookup) will add a dictionary lookup per attribute search.\nFor many __magic__ methods, no inheritance ever matters: the function to call for each is precalculated and resolved in constant time thereafter.","Q_Score":1,"Tags":"python,python-3.x","A_Id":57388719,"CreationDate":"2019-08-07T05:27:00.000","Title":"Effect of additional inheritance on execution speed","Data 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 import a module that has a dash in the module name. Whenever I try this, I get a syntax error. Can I get some help?\nI've tried reinstalling the module with pip3\nI've also tried using the underscore symbol instead of the dash\n\nimport instabot-py\n\nI expect the code to just run but the error 'SyntaxError: invalid syntax' pops up.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":236,"Q_Id":57387504,"Users Score":1,"Answer":"First, it doesn't look like Instabot.py is actually designed to be imported. I haven't found anything in its docs suggesting manual imports are a supported name.\nThe name on PyPI has a hyphen in it, but that's not the name you have to import (assuming importing it actually works). The name on PyPI can be completely different from the name you have to import. In this case, the name you import is instabot_py, with an underscore.\nIn general, people who know what they're doing don't make modules with hyphens in the name, because such names are incompatible with the import statement. This program's author picked an underscore instead, a common choice.","Q_Score":0,"Tags":"python,import,python-import","A_Id":57387547,"CreationDate":"2019-08-07T05:28:00.000","Title":"How do I import modules that have '-' within the module name in python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to have a file which contains the path variable (my system's python path here will be F:\/Python\/python.exe) which is mentioned on the top of every python file stored in the www folder of wamp in Windows. Then I want to import that file to all the other files so that I don't need to mention the path on top of the file every time. Is this possible?\nI have tried creating a function and creating a variable that stored the variable but obviously that can't be done. So how to create such a file which can be imported in other files. Or is there any other solution for what I want to achieve?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":57388129,"Users Score":0,"Answer":"You can try this way \nMaybe this can help you to solve the problem\n\nCreate a file main.py\nIn that particular file do all the import statements\n\nThis will reduce the repentance of the import statements \nFrom your file:\nfrom main import *","Q_Score":1,"Tags":"python,python-3.x,wamp","A_Id":57389030,"CreationDate":"2019-08-07T06:24:00.000","Title":"How to create a file containing path and import that file into another python file in the so that the path does not need to be explicitly mentioed?","Data 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 see many posts on 'how to run nosetests', but none on how to make pycharm et you run a script without nosetests. And yet, I seem to only be able to run or debug 'Nosetests test_splitter.py' and not ust 'test_splitter.py'!\nI'm relatively new to pycharm, and despite going through the documentation, I don't quite understand what nosetests are about and whether they would be preferrable for me testing myscript. But I get an error\n\nModuleNotFoundError: No module named 'nose'\nProcess finished with exit code 1\nEmpty suite\n\nI don't have administartive access so cannot download nosetests, if anyone would be sugesting it. I would just like to run my script! Other scripts are letting me run them just fine without nosetests!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":57389351,"Users Score":0,"Answer":"I found the solution: I can run without nosetests from the 'Run' dropdown options in the toolbar, or Alt+Shift+F10.","Q_Score":1,"Tags":"python,pycharm","A_Id":57389395,"CreationDate":"2019-08-07T07:44:00.000","Title":"Pycharm is not letting me run my script 'test_splitter.py' , but instead 'Nosetests in test_splitter.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":"I am trying to construct a regular expression with the following requirements\n\nPattern should start with letters a-z\nCan have any character from character class [\\w:-].\nCan have any number of underscores _ but only if there is a : somewhere before it in the pattern.\n\nSome examples of valid patters\nhello123\nhello:123\nhello-hello\nhello:123-hello_345 # Valid pattern as there is a : in the pattern before _\nhello-1:hell_world_123\nInvalid patterns\nhello_123\nhello-123_world\nhello_123:world\nI have tried using the lookaheads but for some reason it does not work, below is the pattern i came up with\n^[a-z]+[a-z0-9:-]*(?<=:)[_]*\\w* - the issue with this pattern is that it stops matching the entire pattern if there is no : anywhere in the string, so it kind of makes the : a required pattern.\nI only want to check the existence of : if there is _ anywhere in the string before :.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":57389889,"Users Score":0,"Answer":"^[a-z]+[a-z0-9-]*((:.+)|(:[a-z0-9-_]*)|[a-z0-9-]*)$\nSo, it can be solved by adding pattern groups in OR clauses.\nThis one does work for the examples you gave.\nYou can add if there are any groups which aren't captured.\nHope it helps!","Q_Score":1,"Tags":"python,regex","A_Id":57391033,"CreationDate":"2019-08-07T08:18:00.000","Title":"Matching pattern if there is existing pattern in the string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tasks that do a get request to an API.\nI have around 70 000 requests that I need to do, and I want to spread them out in 24 hours. So not all 70k requests are run at for example 10AM. \nHow would I do that in celery django? I have been searching for hours but cant find a good simple solution.\nThe database has a list of games that needs to be refreshed. Currently I have a cron that creates tasks every hour. But is it better to create a task for every game and make it repeat every hour?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":185,"Q_Id":57390985,"Users Score":0,"Answer":"The typical approach is to send them whenever you need some work done, no matter how many there are (even hundreds of thousands). The execution however is controlled by how many workers (and worker processes) you have subscribed to a dedicated queue. The key here is the dedicated queue - that is a common way of not allowing all workers start executing the newly created tasks. This goes beyond the basic Celery usage. You need to use celery multi for this use-case, or create two or more separate Celery workers manually with different queues.\nIf you do not want to over-complicate things you can use your current setup, but make these tasks with lowest priority, so if any new, more important, task gets created, it will be executed first. Problem with this approach is that only Redis and RabbitMQ backends support priorities as far as I know.","Q_Score":1,"Tags":"python,python-3.x,celery,django-celery","A_Id":57391848,"CreationDate":"2019-08-07T09:18:00.000","Title":"Spread Celery Django tasks out over 24 hours","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python script where I need to create an executable via pyinstaller. Successfully created the exe, but shows the above error while running.\nI have already searched on the web and tried many solutions but none of them is working. tried with # -*- coding:utf-8 -*- in the first line of the script but fails.\nusing Python3.7, PyInstaller3.5\nCan anyone help me with this?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":7232,"Q_Id":57391014,"Users Score":-1,"Answer":"Resolution: Please execute the exe without python command.\nExample: If you have converted test.py, please go to the directory Current Directory\/dist\/test\/ and either double-click on test.exe or run test.exe from command line.","Q_Score":1,"Tags":"python-3.x,pyinstaller","A_Id":63878113,"CreationDate":"2019-08-07T09:20:00.000","Title":"SyntaxError: Non-UTF-8 code starting with '\\x90' in file .\\score_python.exe on line 1, but no encoding declared;","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to do a simple calculation (which later will be done on an array) and getting the aforementioned error.\n\ncan't multiply sequence by non-int of type 'float'\n\n8.99*[-(math.log(1-0.5))**(1\/2.87)]","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":126,"Q_Id":57392088,"Users Score":1,"Answer":"You're trying to multiply a list (denoted by square brackets) as a number. Try \n8.99*(-(math.log(1-0.5))**(1\/2.87)) instead.","Q_Score":0,"Tags":"python","A_Id":57392164,"CreationDate":"2019-08-07T10:16:00.000","Title":"can't multiply sequence by non-int of type 'float' error?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using IntelliJ for my Python project.  I have created a database connection under Database where I can run queries with no problem.  So I have a list of .sql files that I would like to run from within python using the existing connection.  How do I go about it?  \nI can import various packages to pass the queries across to the external database, but since I already have this connection, I was wondering if it was possible to use it to pull data by simply just referring to the connection.\nThanks,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":57392208,"Users Score":0,"Answer":"Rightclick on needed database in InteliJ Database tab and click on \"Open Console\".\nThere you can paste your sql and run it.","Q_Score":0,"Tags":"python,intellij-idea,jdbc","A_Id":57392749,"CreationDate":"2019-08-07T10:22:00.000","Title":"Accessing IntelliJ Database from Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using PyCharm, when trying to install List, Sequence, and Tuple from typing, they are all marked as unsolved references.  How do I fix this? I'm using Python 3.7\nI've tried invalidating the cache but that didn't help.\nThe line that's not working is from typing import List, Tuple, Sequence\nThanks for your help!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":57393626,"Users Score":0,"Answer":"You should check if it exists in Project Window>External Libraries>Python 3.7>Lib","Q_Score":0,"Tags":"python,pycharm","A_Id":57394012,"CreationDate":"2019-08-07T11:40:00.000","Title":"Unsolved references when importing typing using PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using PyCharm, when trying to install List, Sequence, and Tuple from typing, they are all marked as unsolved references.  How do I fix this? I'm using Python 3.7\nI've tried invalidating the cache but that didn't help.\nThe line that's not working is from typing import List, Tuple, Sequence\nThanks for your help!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":57393626,"Users Score":0,"Answer":"Problem is solved - there was an old version of PyCharm installed","Q_Score":0,"Tags":"python,pycharm","A_Id":57397877,"CreationDate":"2019-08-07T11:40:00.000","Title":"Unsolved references when importing typing using PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"That question wasn't very clear.  \nEssentially, I am trying to make a multi-player Pac-Man game whereby the players (when playing as ghosts) can only see a certain radius around them. My best guess for going about this is to have a rectangle which covers the whole maze and then somehow cut out a circle which will be centred on the ghost's rect. However, I am not sure how to do this last part in pygame. \nI'd just like to add if it's even possible in pygame, it would be ideal for the circle to be pixelated and not a smooth circle, but this is not essential.\nAny suggestions? Cheers.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":214,"Q_Id":57393670,"Users Score":1,"Answer":"The best I can think of is kind of a hack.  Build an image outside pygame that is mostly black with a circle of zero-alpha in the center, then blit that object on top of your ghost character to only see a circle around it.  I hope there is a better way but I do not know what that is.","Q_Score":3,"Tags":"python,python-3.x,pygame","A_Id":57401296,"CreationDate":"2019-08-07T11:43:00.000","Title":"How do I display a large black rectangle with a moveable transparent circle in pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an array like w=[0.854,0,0.66,0.245,0,0,0,0] and want to apply 100\/sqrt(x) on each value. As I can't divide by 0, I'm using this trick :\nw=np.where(w==0,0,100\/np.sqrt(w))\nAs I'm not dividing by 0, I shouldn't have any warning.\nSo why does numpy keep raising RuntimeWarning: divide by zero encountered in true_divide ?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":615,"Q_Id":57393768,"Users Score":2,"Answer":"Since it takes advantages of vectorization , it will execute 100\/np.sqrt(w)for  every element of w , so the division by 0 will happen , but then you are not taking the results associated with these entries. So basically with your trick you are still dividing by 0 but not using the entries where you divided by 0.","Q_Score":2,"Tags":"python,numpy,where-clause","A_Id":57393865,"CreationDate":"2019-08-07T11:48:00.000","Title":"why is numpy where keep raising divide by zero encountered?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an array like w=[0.854,0,0.66,0.245,0,0,0,0] and want to apply 100\/sqrt(x) on each value. As I can't divide by 0, I'm using this trick :\nw=np.where(w==0,0,100\/np.sqrt(w))\nAs I'm not dividing by 0, I shouldn't have any warning.\nSo why does numpy keep raising RuntimeWarning: divide by zero encountered in true_divide ?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":615,"Q_Id":57393768,"Users Score":2,"Answer":"100\/np.sqrt(w) still uses the w with zeros because function arguments are evaluated before executing a function. The square root of zero is zero, so you end up dividing 100 by an array that contains zeros, which in turn attempts to divide 100 by each element of this array and at some point tries to divide it by an element that's equal to zero.","Q_Score":2,"Tags":"python,numpy,where-clause","A_Id":57393853,"CreationDate":"2019-08-07T11:48:00.000","Title":"why is numpy where keep raising divide by zero encountered?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a program in python that can read pdf document, extract text from the document and rename the document using extracted text. At first, the scanned pdf document is not searchable. I would like to convert the pdf into searchable pdf on Python instead of using Google doc, Cisdem pdf converter. \nI have read about ocrmypdf module which can used to solve this. However, I do not know how to write the code due to my limited knowledge. \nI expect the output to convert the scanned pdf into searchable pdf.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":3922,"Q_Id":57398839,"Users Score":3,"Answer":"I suggest working on the working through the turoial, will maybe take you some time but it should be wortht it. \nI'm not exactly sure what you exactly want. In my project the settings below work fine in Most of the Cases. \nimport ocrmypdf , tesseract\ndef ocr(file_path, save_path):\n    ocrmypdf.ocr(file_path, save_path, rotate_pages=True,\n    remove_background=True,language=\"en\", deskew=True, force_ocr=True)","Q_Score":4,"Tags":"python,python-3.x","A_Id":58269467,"CreationDate":"2019-08-07T16:34:00.000","Title":"How do I convert scanned PDF into searchable PDF in Python (Mac)? e.g. OCRMYPDF module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a program in python that can read pdf document, extract text from the document and rename the document using extracted text. At first, the scanned pdf document is not searchable. I would like to convert the pdf into searchable pdf on Python instead of using Google doc, Cisdem pdf converter. \nI have read about ocrmypdf module which can used to solve this. However, I do not know how to write the code due to my limited knowledge. \nI expect the output to convert the scanned pdf into searchable pdf.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3922,"Q_Id":57398839,"Users Score":0,"Answer":"This would be done well into two steps\n\nCreate Python OCR Python function\nimport ocrmypdf\ndef ocr(file_path, save_path):\nocrmypdf.ocr(file_path, save_path)\n\nCall and use a function.\nocr(\"input.pdf\",\"output.pdf\")\n\n\nThank you, if you got any question ask please.","Q_Score":4,"Tags":"python,python-3.x","A_Id":68271081,"CreationDate":"2019-08-07T16:34:00.000","Title":"How do I convert scanned PDF into searchable PDF in Python (Mac)? e.g. OCRMYPDF module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with AWS Lambda functions (in Python), that process new files that appear in the same Amazon S3 bucket and folders.\nWhen new file appears in s3:\/folder1\/folderA, B, C, an event s3:ObjectCreated:* is generated and it goes into sqs1, then processed by Lambda1 (and then deleted from sqs1 after successful processing).\nI need the same event related to the same new file that appears in s3:\/folder1\/folderA (but not folderB, or C) to go also into sqs2, to be processed by Lambda2. Lambda1 modifies that file and saves it somewhere, Lambda2 gets that file into DB, for example.\nBut AWS docs says that:\n\nNotification configurations that use Filter cannot define filtering rules with overlapping prefixes, overlapping suffixes, or prefix and suffix overlapping.\n\nSo question is how to bypass this limitation? Are there any known recommended or standard solutions?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1130,"Q_Id":57399129,"Users Score":1,"Answer":"Instead of set up the S3 object notification of (S3 -> SQS), you should set up a notification of (S3 -> Lambda).\nIn your lambda function, you parse the S3 event and then you write your own logic to send whatever content about the S3 event to whatever SQS queues you like.","Q_Score":2,"Tags":"python-3.x,amazon-web-services,amazon-s3,amazon-sqs","A_Id":57399292,"CreationDate":"2019-08-07T16:55:00.000","Title":"How to direct the same Amazon S3 events into several different SQS queues?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have built a list comprehension that takes in a list of lists [actual, predicted] and then classifies the contained lists. I want to produce output lists that have 1 if the original element is > .1, -1 if the original output is < -.1 and 0 if the original element is < .1 and > -.1. For example [[2, 0, -2],[0, 0, 0]] would be mapped to [[1,0,-1], [0,0,0]]. \nI am using this code to perform this:\nclassified = [list(map(lambda x: 1 if x > .1 else (-1 if x < .1 else 0), i)) for i in inputs].\nHowever, when my code should classify an element as 0, it classifies it as -1. For example [-.15, -.05, 0] is mapped to [-1, -1, -1] instead of [-1, 0, 0]. It does classify points that map to 1 and -1 correctly.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":57400902,"Users Score":4,"Answer":"-1 if x < .1 else 0 should be -1 if x < -.1 else 0","Q_Score":0,"Tags":"python","A_Id":57400930,"CreationDate":"2019-08-07T19:10:00.000","Title":"Classification List Comprehension Not Behaving as Expected","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to create a clone\/copy of an existing web application on pythonanywhere. I have access to the pythonanywhere account.  The application is active and is not mine - a friend is allowing me to make a copy so that I can learn how web applications work. Thus, it is important that I can make a copy without messing up or updating anything in the current web application. \nAll of the tutorials I am finding are about deploying an application via git to github to pythonanywhere (which I have done before) but never the other way around. \nI created an empty github repository and thought about going to the python bash console and adding it as a remote server, then pushing the code to github. But, I don't know if this makes a new connection that will mess up the application. I want to just download the application once and be done. \nI would really appreciate step-by-step instructions on how to download a copy of the web application to my local server and\/or github. If you provide code, please assume I know nothing and tell me where I should run it (command prompt, pythonanywhere bash console, etc).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1080,"Q_Id":57401599,"Users Score":2,"Answer":"I just did this the following way. In a bash console on pythonanywhere, navigate to the app with $cd yourapp. Then create a git repository there with git init. Once its done add the folders in the app to the repo with git add . Then you need to commit to update the empty repository: git commit -m \"your comment\". \nOnce the repo is created on pythonanywhere, move to the local folder in your local machine's terminal where you want to copy the app. Then clone the repo on pythonanywhere with entering the following command to your local terminal: git clone yourusername@ssh.pythonanywhere.com:\/home\/yourusername\/yourapp \nSince its not a bare repository, you won't be able to push any code changes to the pythonanywhere app, by default. This can be changed though, but I understand that is not what you want. If you want to make sure that no changes are applied back, just delete the .git folder from pythonanywhere which was created by the git init \nMy concern though is, that if your friend's app is database backed, you might be able to send data to the live database from your local instance of the app. So, definitely double check on that with him\/her.","Q_Score":1,"Tags":"git,github,pythonanywhere","A_Id":59017818,"CreationDate":"2019-08-07T20:03:00.000","Title":"How to clone an existing web application from pythonanywhere to github\/local","Data Science and Machine Learning":0,"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 doing a small project involving web scraping basic html pages hosted on an internal server we use at work. Upon entry to these pages a popup . . . which looks exactly like a windows.prompt() asks for username and a password with a message like \"Enter credentials for Proxy: \". Is there a way to automatically inject and submit these values on the prompt box using JavaScript or even python?\nYes I do have access but every time I go to a different page it will re-prompt me and I am trying to do this for a very large amount of pages.\nI have already tried inspecting the page but there does not seem to be any element for a popup.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":86,"Q_Id":57401627,"Users Score":1,"Answer":"I suspect you may be getting the login prompt due to the web server's setup for the page and not due to anything included in the content of the page in question. You may need to adjust your app's code to handle the login behavior (setting cookies in your request header for example).","Q_Score":0,"Tags":"javascript,python,html","A_Id":57402523,"CreationDate":"2019-08-07T20:06:00.000","Title":"How to enter in values for a window.prompt() using javascript?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In plotly_express.line the only options I see to modify hover settings are hover_name and hover_data. A few issues I'm facing with modifying hover are:\n\nIt seems that even if I set hover_data=None it still shows the values for name,x, and y. How can I set it to only show the hover info I select without adding defaults?\nI can't find a setting to modify the opacity for hover boxes. I'm displaying a lot of hover info so my hover box is large, which makes it difficult to know where I am on the plot behind the box.\nHow can I make it so hovering on one line displays hover info corresponding to a linked data column value on all other lines?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2985,"Q_Id":57402050,"Users Score":2,"Answer":"1 and 2 are not possible yet.\nFor 3 there is a hovermode attribute in layout that you can set to show one hover label per trace per y-value.","Q_Score":5,"Tags":"python,hover,plotly,plotly-dash,plotly-express","A_Id":57402233,"CreationDate":"2019-08-07T20:42:00.000","Title":"Plotly Express hover options","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently have a python application that runs perfectly from the CLI and when I run it from an IDE. I want to make it into an application that will launch in 1 click from any mac computer. (Like any desktop application). Ideally, I can send someone the file, they do a simple install, then the program works. I have tried using platypus (works great for 1 file programs) and other methods of bundling apps. But none of them seem to work as the program is kinda complex.\nProgram Requirements:\n\nPython3\nPython Libraries tkinter, socket, threading, PIL etc\n~8 individual python files (controlled by 1 main menu)\nLots of images\n\nI would like to have an install process, where you click next a bunch of times and agree to things, but if this isn't possible I can live without it.\nAny help is greatly appreciated!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":172,"Q_Id":57402681,"Users Score":1,"Answer":"Use PyInstaller to build your package. I do not think they have an actual installer, but you could build your own GUI installer by using some CMD commands and something like tkinter.","Q_Score":1,"Tags":"python,python-3.x,macos,bundle","A_Id":57402706,"CreationDate":"2019-08-07T21:46:00.000","Title":"How to create a mac app from python files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am setting a project path to some env variable like PROJECT_HOME by us using os.environ like this:\nos.environ['PROJECT_HOME'] = os.getcwd()\nso I can use %cd $PROJECT_HOME\/abc\/xyz in later cell\nHowever, the system return this:\n[Errno 2] No such file or directory: '${PROJECT_HOME}\/abc\/xyz'\nIs there a way to use env variable in %cd?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":366,"Q_Id":57403139,"Users Score":1,"Answer":"This works for me: %cd {os.environ['PROJECT_HOME']}","Q_Score":0,"Tags":"jupyter-notebook,ipython","A_Id":57405510,"CreationDate":"2019-08-07T22:46:00.000","Title":"How to %cd to a path containing env variable in jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been trying to pip install psycopg2 for some time now\n\nI have just updated to python 3.7.4, before this problem started.\nTo set my path to a specific python version I used the code below.\n\nnano .bash_profile\nI thought that it would now be easy for my system to identify the path of the newly installed python, as to enable it to install psycopg2. Then the below started happening. \nThe second line of system terminal or python terminal is now always showing:\n\n-bash: zzzzz#: command not found on my terminal\n\nNo matter what I type on my terminal, I am always getting command not found","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17,"Q_Id":57403175,"Users Score":0,"Answer":"This would mean you literally have \"zzzzz\" somewhere in the bash_profile. Bash is seeing \"zzzzz\" as just another command to run at startup like the rest of the profile script. As there is nothing in your PATH matching that string, bash reports the issue back to you.\nEither remove the extra line from your .bash_profile. OR use a terribly wasteful work-around!\nln -s \/bin\/true \/bin\/zzzzz\nThis will create a symbolic link to the \"true\" binary (all it ever does is return true) from zzzzz. Now bash can find zzzzz and run it during start up, which does nothing. No more error and an absurd work around. You should fix the file.","Q_Score":0,"Tags":"python-3.7","A_Id":57403344,"CreationDate":"2019-08-07T22:51:00.000","Title":"second line on my system or python terminal now saying: \u201c -bash: zzzzz#: command not found\u201c","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a job which copies a large file to a table temp_a and also creates an index idx_temp_a_j on a column j. Now once the job finishes copying all the data, I have to rename this table to a table prod_a which is production facing and queries are always running against it with very less idle time. But once I run the rename queries, the queries coming in and the queries which are already running, are backed up producing high API error rates. I want to know what are the possible strategies I can implement so the renaming of the table happens with less downtime.\nSo far, below are the strategies I came up with:\n\nFirst, just rename the table and allow queries to be backed up. This approach seems unreliable as rename table query acquires the EXCLUSIVE LOCK and all other queries are backed up, I am getting high level of API error rates.\nSecond, write a polling function which checks if there any queries running now if not then rename the table and index. In this approach the polling function will check periodically to see if any query is running, any queries are running, then wait , if not then run the alter table query. This approach will only queue up queries which are coming after the alter table rename query has placed an EXCLUSIVE LOCK on the table. Once the renaming finishes, the queued up queries will get executed. I still need to find database APIs which will help me in writing this function.\n\nWhat are the other strategies which can allow this \"seamless\" renaming of the table? I am using postgres (PostgreSQL) 11.4 and the job which does all this is in Python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":129,"Q_Id":57403626,"Users Score":0,"Answer":"You cannot avoid blocking concurrent queries while a table is renamed.\nThe operation itself is blazingly fast, so any delay you experience must be because the ALTER TABLE itself is blocked by long running transactions using the table. All later operations on the table then have to queue behind the ALTER TABLE.\nThe solution for painless renaming is to keep database transactions very short (which is always desirable, since it also reduces the danger of deadlocks).","Q_Score":0,"Tags":"python,postgresql,psycopg2","A_Id":57406173,"CreationDate":"2019-08-08T00:05:00.000","Title":"Strategies for renaming table and indices while select queries are running","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When user enter email for  password reset then error arise connection  failure which is related to server failure error .\nraceback:\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2b1-py3.7.egg\\django\\core\\handlers\\exception.py\" in inner\n  34.             response = get_response(request)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2b1-py3.7.egg\\django\\core\\handlers\\base.py\" in _get_response\n  115.                 response = self.process_exception_by_middleware(e, request)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2b1-py3.7.egg\\django\\core\\handlers\\base.py\" in _get_response\n  113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2b1-py3.7.egg\\django\\views\\generic\\base.py\" in view\n  71.             return self.dispatch(request, *args, **kwargs)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2b1-py3.7.egg\\django\\utils\\decorators.py\" in _wrapper\n  45.         return bound_method(*args, **kwargs)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2b1-py3.7.egg\\django\\views\\decorators\\debug.py\" in sensitive_post_parameters_wrapper\n  76.             return view(request, *args, **kwargs)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\registration\\views.py\" in dispatch\n  53.         return super(RegistrationView, self).dispatch(request, *args, **kwargs)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2b1-py3.7.egg\\django\\views\\generic\\base.py\" in dispatch\n  97.         return handler(request, *args, **kwargs)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2b1-py3.7.egg\\django\\views\\generic\\edit.py\" in post\n  142.             return self.form_valid(form)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\registration\\views.py\" in form_valid\n  56.         new_user = self.register(form)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\registration\\backends\\default\\views.py\" in register\n  100.             request=self.request,\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\registration\\models.py\" in create_inactive_user\n  193.                     lambda: registration_profile.send_activation_email(\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2b1-py3.7.egg\\django\\db\\transaction.py\" in exit\n  284.                     connection.set_autocommit(True)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2b1-py3.7.egg\\django\\db\\backends\\base\\base.py\" in set_autocommit\n  409.             self.run_and_clear_commit_hooks()\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2b1-py3.7.egg\\django\\db\\backends\\base\\base.py\" in run_and_clear_commit_hooks\n  624.             func()\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\registration\\models.py\" in \n  194.                         site, request)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\registration\\models.py\" in send_activation_email\n  451.         email_message.send()\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2b1-py3.7.egg\\django\\core\\mail\\message.py\" in send\n  291.         return self.get_connection(fail_silently).send_messages([self])\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2b1-py3.7.egg\\django\\core\\mail\\backends\\smtp.py\" in send_messages\n  103.             new_conn_created = self.open()\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2b1-py3.7.egg\\django\\core\\mail\\backends\\smtp.py\" in open\n  63.             self.connection = self.connection_class(self.host, self.port, **connection_params)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\smtplib.py\" in init\n  251.             (code, msg) = self.connect(host, port)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\smtplib.py\" in connect\n  336.         self.sock = self._get_socket(host, port, self.timeout)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\smtplib.py\" in _get_socket\n  307.                                         self.source_address)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\socket.py\" in create_connection\n  727.         raise err\nFile \"C:\\ProgramData\\Anaconda3\\lib\\socket.py\" in create_connection\n  716.             sock.connect(sa)\nException Type: ConnectionRefusedError at \/accounts\/register\/\nException Value: [WinError 10061] No connection could be made because the target machine actively refused it","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2019,"Q_Id":57405472,"Users Score":0,"Answer":"Either the port you are trying to connect is wrong or the machine's firewall refuses your request.","Q_Score":2,"Tags":"python,django,sendmail,smtpclient,smtplib","A_Id":57405501,"CreationDate":"2019-08-08T05:01:00.000","Title":"ConnectionRefusedError at \/accounts\/register\/","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a large tar.gz archive file having nxml files and total size is around 5gb.\nMy aim is to extract files from it but, I do not have to extract all of them. I have to extract all those files whose name is greater than a threshold value.\nFor example:\nLet us consider 1000 is our threshold value. So\npath\/to\/file\/900.nxml will not be extracted but\npath\/to\/file\/1100.nxml will be extracted.\nSo my requirement is to make a conditional extraction of files from the archive.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":123,"Q_Id":57406452,"Users Score":1,"Answer":"You can also use --wildcards option of tar.\nFor example in the case when your threshold is 1000 you can use tar -xf tar.gz --wildcards path\/to\/files\/????*.nxml. The ? will match one character and using * will match any number of character. This pattern will look for any file name with 4 or more characters.\nHope this helps.","Q_Score":1,"Tags":"python,bash,gzip,python-2.x,tar","A_Id":57424232,"CreationDate":"2019-08-08T06:31:00.000","Title":"Conditional extraction of files from an Archive file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Python project for web automatization using Selenium. As I do not always have access to my computer, I would like to be able to run it from my iPhone. Is it possible to run a .py file from a Swift app on iOS? I would appreciate code samples since I am a beginner but simply pointing me in the right direction would be a great help.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":61,"Q_Id":57407509,"Users Score":1,"Answer":"1) You need some backend application running on your PC;\n2) backend application must have some Web API for managing Selenium application;\n3) From iOS app you send http-request to API using Alamofire or any other solution.","Q_Score":0,"Tags":"python,ios,swift,selenium","A_Id":57410594,"CreationDate":"2019-08-08T07:38:00.000","Title":"How to run a .py file from iOS using Swift","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to figure out how to manage my dag in Apache Airflow.\nThere are a few master steps that I need to.\nfor example, let's say step 1 and step 2 should always be executed before branching out. And then steps A, B, C, D, E should all be concurrently branched out after step 2, and each of these have their own steps.. so like A1, A2.. same with B~E. \nWhat's the best way of managing it? It looks like there is BranchOperator but it says it's really good for alerts, and I'm not trying to do alerts here but actually use operators for A1, A2.. steps. Should A-E be all subdags? If so, how do I trigger subdags?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2378,"Q_Id":57407558,"Users Score":1,"Answer":"Do you want to concurrently execute all the Tasks A,B,C..etc? If so, then branchOperator may not be suitable. branchOperator selects a particular branch based some logic.","Q_Score":2,"Tags":"python,airflow","A_Id":57903751,"CreationDate":"2019-08-08T07:40:00.000","Title":"How to have multiple branches in airflow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm needing to trigger an action at a particular date\/time either in python or by another service.\nLet's say I have built an application that stores the expiry dates of memberships in a database. I'm needing to trigger a number of actions when the member expires (for example, changing the status of the membership and sending an expiry email to the member), which is fine - I can deal with the actions. \nHowever, what I am having trouble with is how do I get these actions to trigger when the expiry date is reached? Are there any concepts or best practices that I should stick to when doing this?\nCurrently, I've achieved this by executing a Google Cloud Function every day (via Google Cloud Scheduler) which checks if the membership expiry is equal to today, and completes the action if it is. I feel like this solution is quite 'hacky'.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":57407997,"Users Score":0,"Answer":"I'm not sure which database you are using but I'm inferring you have a table that have the \"membership\" details of all your users. And each day you run a Cron job that queries this table to see which row has \"expiration_date = today\", is that correct?. \nI believe that's an efficient way to do it (it will be faster if you have few columns on that table).","Q_Score":0,"Tags":"python,cron,google-cloud-functions,google-cloud-scheduler","A_Id":57411478,"CreationDate":"2019-08-08T08:08:00.000","Title":"Triggering actions in Python Flask via cron or similar","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Should i annotate types in my unit tests functions? \nWhat also with overridden django methods like save and get or post functions in generic view?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":351,"Q_Id":57409867,"Users Score":1,"Answer":"This is arguably an opinion question but I think that there is a generally accepted answer, which is roughly \"No\".\nOne way of categorising programming languages is into statically typed and dynamically typed. Statically typed languages are generally more robust, especially for \"programming in the large\", and dynamically typed languages have advantages ito programming speed, and in modelling problems where it is beneficial to be able to accept data of various types. Type hints try to strike a balance. The rough rule being: if you are using the dynamic nature of the language to achieve something, don't worry about annotating it. If however, you are writing code that doesn't make specific use of the dynamic nature of the language, annotate\nPerhaps to make the point clear, consider that if you DO annotate everything, well then why not just use Cython? Same effort but you actually get some speed up as well. The reason people use Python with annotations instead of Cython is that some problems are naturally better solved without specifying types.","Q_Score":2,"Tags":"python,django,unit-testing,typing,pep","A_Id":57409970,"CreationDate":"2019-08-08T09:53:00.000","Title":"Should i annotate types everywhere?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a dataset containing both RGB and Segmented images as ground truth , the readme.txt included in the annotated dataset stated this :\nGT_color :folder containing the groundtruth masks for semantic segmentation \nAnnotations are given using a color representation, where each corresponds to a specific class. This is primairly provided for visualization. For training, create a corresponding ID image by assigning the colors to a specific class ID as given below.\n\nClass       R   G   B   ID\n\nVoid            -   -   -   0\n\nRoad            170     170     170 1\n\nGrass           0   255     0   2\n\nVegetation      102     102     51  3\n\nTree            0   60  0   3\n\nSky             0   120     255 4\n\nObstacle        0   0   0   5\n\nI don't understand what's meant by \"creating corresponding ID image\" , aren't the segmented images labelled already by each area's color ? meaning that the rgb are the labels ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":57410686,"Users Score":0,"Answer":"From what I understand, your segmented images come with 3 channels, where the color of each pixel corresponds to its GT label.\nWhen you train your image segmentation model, there is no need for an output of 3 channels (its redundant), so they recommend that you create a new annotated image, where you replace each color with the provided i.d.\nThis recommendation is simply there to make the job of the model a little bit easier.","Q_Score":0,"Tags":"python,machine-learning,computer-vision,dataset,image-segmentation","A_Id":57410794,"CreationDate":"2019-08-08T10:39:00.000","Title":"Create an ID segmented images","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create virtual enviornment with access to dSAPCE AutomationDesk libraries such as reportlibrary, mainlibrary, evaluation, rtplib2, rs232lib2, matlablib2, ..\n\nI have installed dSPACE ControlDesk 5.6, dSPACE AutomationDesk 5.2and dSPACE Python Extensions 2.1 on local computer. \nI have found Python Interpreter installed by dSPACE installator (it includes additional dSPACE libraries under path 'C:\\Program Files (x86)\\Python27\\Lib\\site-packages\\dSPACECommon')\nThen I have added to sys.path following paths:\n'C:\\Program Files (x86)\\dSPACE AutomationDesk 5.2\\Main\\bin'\n'C:\\Program Files (x86)\\dSPACE AutomationDesk 5.2\\Main\\DSPythonModules\\AutomationDeskPackages\\*' (all folders located here)\n\nIs it possible to somehow configure these libraries in my Python environment? Or should I create some stubs manually?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":868,"Q_Id":57413249,"Users Score":0,"Answer":"From what I have learned and find out, there is not possible to create virtual enviroment for AutomationDesk without making some stubs (manually?).\nAutomationDesk python libraries have references to AutomationDesk build-in libraries (which are files in non-python format) and therefore the problem is more complex and requires out of the box solution.","Q_Score":1,"Tags":"python,environment,dspace-ecu","A_Id":58644305,"CreationDate":"2019-08-08T13:00:00.000","Title":"How to add dSPACE AutomationDesk libraries to Python interpreter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My table has a JsonField column named meta_data. One of its entries is:\n{'abc':'zyz', 'name':{'pranav':'age', 'john':'age'}}\nTo query on Jsonfield i use __has_key lookup:\ntable.objects.filter(id__in=id_list, meta_data__has_key='name')\nI want to findout if there is some django lookup that helps me check if there is the key 'pranav' inside 'name' like:\ntable.objects.filter(id__in=id_list, meta_data__has_key__has_key='pranav')\nor something like that\nThanks for any input on this...!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":636,"Q_Id":57414685,"Users Score":2,"Answer":"Yes you can use any list of keys you want separated by __ to traverse your JSON even if the keys do not exist. PostgreSQL will just skip the row if any of the keys don't exist down the line.","Q_Score":2,"Tags":"python,django,django-models,django-orm,django-jsonfield","A_Id":57414841,"CreationDate":"2019-08-08T14:15:00.000","Title":"Is there a django-orm lookup for querying nested jsonfield key?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on an application in python that generates a pdf file using the reportlab library. How can I put borders around some text in there? The font color in the pdf is a certain color and I would also like some borders around the text.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":829,"Q_Id":57416662,"Users Score":0,"Answer":"It depends on whether the text is inside a Paragraph flowable or inside Table flowable.\nIf text is inside Paragraph then add an attribute borderColor = None and change it accordingly.\nIf the text is inside Table flowable then add Inner grid and Box  property in TableStyle to add borders around the text.","Q_Score":0,"Tags":"python,pdf,reportlab","A_Id":57459108,"CreationDate":"2019-08-08T16:02:00.000","Title":"Bordering text within reportlab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m creating a big project with Django and wondering if it is sensible to use the HTML template structure for my front end or should I implement something like React? What are each of its benefits? Is it perfectly reasonable to use HTML templates for a big project? Any advice?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":430,"Q_Id":57418634,"Users Score":1,"Answer":"Django templates are quite fully featured, and performant, and I'd use them if I could meet the requirements in my project with them alone. Adding react will increase the tooling you'll need and have to maintain, so my team only introduced it after we started to need user interfaces that were react-like (it started when we implemented an in-app to do list). So your project requirements will really dictate if you want to invest additional development and devops energy into react in order to have a more instant-update\/native-app-like feel, or not. \nIf you are unsure, I'd recommend starting with templates and introducing react later. It's entirely possible to run an app that uses templates for 90% of your app and react only where it's needed (we do this).","Q_Score":2,"Tags":"python,django","A_Id":57418710,"CreationDate":"2019-08-08T18:19:00.000","Title":"HTML templates or React for Django front end?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I\u2019m creating a big project with Django and wondering if it is sensible to use the HTML template structure for my front end or should I implement something like React? What are each of its benefits? Is it perfectly reasonable to use HTML templates for a big project? Any advice?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":430,"Q_Id":57418634,"Users Score":0,"Answer":"The thing with React is you need to have a good API in between your back-end and your front-end. I would recommend Django Rest Framework for that. Anyway, templates are nice to quickly get something up and running, something that is mostly display centered and you don't have to do too much scripting. React makes it easier to have a heavier front-end. However, templates can handle a lot of front end as well, just you won't get access to any of the nice benefits of React. I have used templates for a big project, and it worked nicely. I didn't have to build an API, and the templates easily interacted with my back-end. I am not sure exactly what kind of project you are doing, so these are just my recommendations.","Q_Score":2,"Tags":"python,django","A_Id":57419061,"CreationDate":"2019-08-08T18:19:00.000","Title":"HTML templates or React for Django front end?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wanted to know what version of virtual env is installed ? My OS is windows 10\nThank you","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":22823,"Q_Id":57419287,"Users Score":15,"Answer":"In your terminal use the command:\nvirtualenv --version\nExample output:\n15.1.0","Q_Score":10,"Tags":"python-3.x,virtualenv","A_Id":57419316,"CreationDate":"2019-08-08T19:13:00.000","Title":"How to check what version of Virtual Env is installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm attempting to parse thousand\/million\/hundred million values out of plaintext. I need to exclude commas and decimals from the typical word boundaries so 1,000,000 doesn't return multiple hits. I need my values to be exclusive and only match at the highest number. How do I recreate word boundary functionality that ignores commas and decimals?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":57419446,"Users Score":3,"Answer":"Word boudary \\b does not include commas, it includes: (^\\w|\\w$|\\W\\w|\\w\\W) , \\w represents: [a-zA-Z0-9_] and \\W is like NOT \\w in this way: [^a-zA-Z0-9_] \nMaybe you need this : [\\d,.]+\nIt will match 1,000,000 or 1,000.000 ...","Q_Score":0,"Tags":"python,regex","A_Id":57419578,"CreationDate":"2019-08-08T19:27:00.000","Title":"How to exclude commas from word boundaries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a Flask Web App that uses an html form button to launch a Python script via a subproces call.  I want that Python script to launch cygwin and pass a shell script that launches an ansible playbook.  But the playbook is not running.  The screen just flickers and nothing is happening.\nThe flask web app works when testing on its own.  on its own it can write to a text file","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":57419994,"Users Score":0,"Answer":"I think more information would be helpfull but basicly you can invoke ansible by any tool who can send commands to machine. Maybe the subprocess is the problem you should consider to use the call with: nohup and pipe all outputs to:  \/dev\/null 2>&1","Q_Score":0,"Tags":"python,windows,powershell,flask,ansible","A_Id":57424667,"CreationDate":"2019-08-08T20:17:00.000","Title":"Can I launch an ansible playbook from a cygwin terminal on windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm wondering if there is a way to detect physical disconnection of a device while serial communication is open? Is the only way to write try-except code whenever data is sent?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":526,"Q_Id":57420789,"Users Score":0,"Answer":"Use pyserial isopen() which return a Boolean value if it is open or not.\n   Import serial\nser = Serial.Serial(\"your serial info\")\n   Ser.isOpen()","Q_Score":2,"Tags":"python,pyserial","A_Id":57422708,"CreationDate":"2019-08-08T21:23:00.000","Title":"How to detect when a device is disconnected while serial communication is 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering if there is a way to detect physical disconnection of a device while serial communication is open? Is the only way to write try-except code whenever data is sent?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":526,"Q_Id":57420789,"Users Score":1,"Answer":"There is no standard way to detect if a serial device is connected to say RS-232, RS-422, and other serial interfaces - there could be exceptions, which I don't know about though. For a RS-232 the minimum required wires to be able to receive and send are ground, TX, and RX. For a differential serial interface like RS-422 or RS-485 the ground isn't needed. If you know something about the behaviour of the device connected, then you could use this. Like if you expect certain responses to commands sent, or the RS-232 flags to be set in a certain way.","Q_Score":2,"Tags":"python,pyserial","A_Id":57434486,"CreationDate":"2019-08-08T21:23:00.000","Title":"How to detect when a device is disconnected while serial communication is 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python installed through windows store and I can install programs using pip, but when I try to run said programs, they fail to execute in powershell.\nHow can I make sure that the necessary \"scripts\" folder is in my path? I never faced these problems when installing from executable.\nFor example, \"pip install ntfy\" runs successfully in Powershell.\nThe command \"ntfy send test\" fails telling me the term is not part of a cmdlet, function, etc. etc.\nThe 'ntfy' program is  located here \/mnt\/c\/Users\/vlouvet\/AppData\/Local\/Packages\/PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\/LocalCache\/local-packages\/Python37\/Scripts\/ntfy.exe\nWhat is the recommended way of editing my path so that programs installed via pip are available across windows store updates of the Python language?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":10355,"Q_Id":57421669,"Users Score":7,"Answer":"The above answer is good but I managed to get it to work by doing the following.\n\nFind your installation under C:\\Users\\\"your user\"\\AppData\\Local\\Packages it will be named something like PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\nOpen your windows settings in the start menu\nIn search type Environment variables. Edit environment variables for your account should pop up. Click it\nIn the top box find Path, click it\nOn the right Click new and enter C:\\Users\\\"your user\"\\AppData\\Local\\Packages\\\"python install directory name from 1. here\"\\LocalCache\\local-packages\\Python37\\Scripts inside the little box under the last item in the list\nopen a new cmd prompt and type the script you wanted it should work.","Q_Score":10,"Tags":"python,windows,pip","A_Id":61709201,"CreationDate":"2019-08-08T23:05:00.000","Title":"Question about pip using Python from Windows Store","Data 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":"When I am installing packages using pip, it shows that everything is installed but it really isn't.\nThis is on Windows 10. I have tried to install other packages, the same thing happens. it's all showing as installed on command prompt, but Sublime and other code editors do not show it as installed.\npip install pyinstaller then it returns with: Requirement already satisfied and when I put it in sublime: No module named pyinstaller\nEven when I put it in command prompt again: pyinstaller is not recognized as an internal or external command, operable program or batch file.\nI am expecting pip to install the package, make it work, so I can import pyinstaller, but it says there is no module available. What should I do?\nEdit: It's not just sublime, even the cmd prompt command isnt working. pip says its installed, but cmd prompt and any external applications don't work.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":246,"Q_Id":57422202,"Users Score":0,"Answer":"Check if pip version and python are equals. Use pip -V and python -V. \nMaybe, you have multiples versions installed...","Q_Score":0,"Tags":"python,pip,pyinstaller","A_Id":57422577,"CreationDate":"2019-08-09T00:41:00.000","Title":"Pip is installed and supposed to be downloading packages, but it does not work in my coding. (Windows 10)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently added python to my environment variables when this question popped into my head. When I type \"python\" into command prompt, windows seems to know which file to run. However, I added python into this environment variable called \"Path\", and never specified \"python\" anywhere.\n\nI don't understand how windows knows what I want when I type \"python\". Could someone help clear this up?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1046,"Q_Id":57423108,"Users Score":2,"Answer":"PATH is an environment variable that holds values related to current user and operating system. It specifies the directories in which executable programs are located. so when you type python window gets its executable from PATH. hence, you won't need to type the whole path to the file on command line.","Q_Score":1,"Tags":"python,windows,windows-10,environment-variables,command-prompt","A_Id":57423356,"CreationDate":"2019-08-09T03:25:00.000","Title":"Windows how does the \"Path\" environment variable work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am making a KNN model. The target variable is divided in 2 categories, and the features are 3 categorical variables (country, language and company). The model says the optimal is 5 clusters, so I did it with 5.\nI need to know how can I see the records in each of the 5 clusters (I mean, the countries, languages and companies that the model is grouping in each of them). Is there a way to add the labels of the clusters to the dataframe?\nI tried:\npredictions = knn.predict(features)\nBut that is only returning the estimations for the 2 labels of the target variable\nI did some research and found:\nkm.labels_\nBut that only applies for KMeans, and I am using KNN\nI hope somebody can tell me the equivalent for that or how to solve the problem for KNN Model please","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":57424338,"Users Score":0,"Answer":"KNN is not clustering, but classification.\nThe parameter k is not the k of k-means; it is the number of neighbors not the number of clusters...\nHence, setting k to 5 dors not suddenly produce 5 labels. Your training data has 2 labels, hence you get 2 labels.\nKNN = k-nearest neighbors classification. For k=5 this means 5 nearest neighbors.\nK-means clustering = approximate the data with k center vectors. An entirely different k.","Q_Score":0,"Tags":"python,scikit-learn,label,knn","A_Id":57426426,"CreationDate":"2019-08-09T06:13:00.000","Title":"How can I identify the records inside each cluster in a KNN model in SciKit-Learn Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am using python 3.6 and i tried to install win32com.client using pip install pywin32 but it shows error on importing link  \n\nCould not find a version that satisfies the requirement pywin32 (from\n  versions: ) No matching distribution found for pywin32\n\ni am using ubuntu.\npip3 install pywin32\n\nCould not find a version that satisfies the requirement pywin32 (from\n  versions: ) No matching distribution found for pywin32","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":340,"Q_Id":57424408,"Users Score":0,"Answer":"You can't use win32com as it's a Windows-only module. Your best bet is to use the Libreoffice API or a web API providing the conversion service.","Q_Score":0,"Tags":"python,win32com","A_Id":57432142,"CreationDate":"2019-08-09T06:20:00.000","Title":"How to convert PPT file to PDF in python Ubuntu?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to know a silly question about using python. Currently, I am using spyder to write python. Take matlab as an example, when I run a program in matlab, I can see the word busy and I know matlab is running. Are there any similar signals which can help me to figure out if a program is running or not when I use spyder environment?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":459,"Q_Id":57426882,"Users Score":4,"Answer":"There is a red stop button on the top right of the IPython console. It is grayed out when there is nothing running, and becomes red when the console is 'busy'.","Q_Score":0,"Tags":"python,matlab,spyder","A_Id":57431592,"CreationDate":"2019-08-09T09:11:00.000","Title":"How can I know if a program in python is running in spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a CSV file in S3. I want to run a python script using data present in S3. The S3 file will change once in a week. I need to pass an input argument to my python script which loads my S3 file into Pandas and do some calculation to return the result.\nCurrently I am loading this S3 file using Boto3 in my server for each input argument. This process takes more time to return the result, and my nginx returns with 504 Gateway timeout.\nI am expecting some AWS service to do it in cloud. Can anyone point me in a right direction which AWS service is suitable to use here","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":389,"Q_Id":57426946,"Users Score":0,"Answer":"You have several options:\n\nUse AWS Lambda, but Lambda has limited local storage (500mb) and memory (3gb) with 15 run time.\nSince you mentioned Pandas I recommend using AWS Glue which has ability:\n\n\nDetect new file\nLarge Mem, CPU supported\nVisual data flow\nSupport Spark DF\nAbility to query data from your CSV files\nConnect to different database engines.\n\n\nWe currently use AWS Glue for our data parser processes","Q_Score":0,"Tags":"python-3.x,amazon-s3,aws-lambda,job-scheduling","A_Id":57427988,"CreationDate":"2019-08-09T09:16:00.000","Title":"How to run python script using S3 data in AWS","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on Real Time based app, it needs to update location of user whenever it is changed.\nAndroid app is used as frontend, which get location using Google\/Fused Api and in onLocationChanged(loc:Location), I am sending the latest location over the Websocket. The location update is then received by a django channel consumer, and job of this consumer is to store location in database asynchronously (I am using @database_sync_to_async decorator. \nBut the problem is, server crashes when Android app tries to send 10-15 location updates per second. What will be the efficient way of updating real time location?\nNote: Code can be supplied on demand","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":413,"Q_Id":57426965,"Users Score":1,"Answer":"Ask yourself what kind of resolution you need for that data. Do you really need 10 updates a second? If not, take every nth update or see if Android will just give you the updates slower. Secondly, look for a native async database library. @database_sync_to_async runs a different thread every time you call it which kills the performance gains you're getting from the event loop. If you say in one thread you'll keep the CPU caches fresh. You won't get to use the ORM. But do you really need a database or would Redis work? If so, call aioredis directly and it will be a lot faster since its in memory and you can use it's fast data structures like queues and sets. If you need Redis to be even faster look at it's multithreaded fork KeyDB.","Q_Score":1,"Tags":"python,django,websocket,django-channels","A_Id":57518558,"CreationDate":"2019-08-09T09:17:00.000","Title":"Efficient way of updating real time location using django-channels\/websocket","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working with a MEAN stack application, that passes a file to python script, and this script doing some tasks and then it returns some results.\nThe question is and how to install the required python packages when I deploy it?  \nThanks!\nI've tried to run python code inside nodejs application, using python shell.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":358,"Q_Id":57428664,"Users Score":2,"Answer":"Place python script along with requirements.txt(which has your python dependencies) in your nodejs project\ndirectory.\nDuring deployment , call pip install on the requirements.txt and it\nshould install the packages for you.\nYou can call python script from nodejs just like any shell command\nusing inbuild child_process module or python-shell.","Q_Score":1,"Tags":"python,node.js,angular,file,mean-stack","A_Id":57430054,"CreationDate":"2019-08-09T10:59:00.000","Title":"How to deploy and run python scripts inside nodejs application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have some dynamic fields on the base.html like the footer text and the social accounts links, but I need to fetch them from the database and send them alongside with each response for a view that uses a template which extends the base.html template.\nright now I am fetching the needed Items on every view and send them alongside with the view context, but I feel that this is repetitive, especially if I have more dynamic items, I tried also to save them to the request session but also it will require more code and edge cases.\nwhat is the most efficient way to fetch these items once and be able to use them on all the views that extends the base.html template?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1157,"Q_Id":57429151,"Users Score":0,"Answer":"thanks to @DanielRoseman he pointed me to the use of context_processor,\nnow I have created a context_processor that returns a dict which contains all the objects that I frequently ask for, so it is now accessible from anywhere on my templates.","Q_Score":0,"Tags":"python,django,database,performance,web","A_Id":57442168,"CreationDate":"2019-08-09T11:31:00.000","Title":"how to deal with dynamic items that are used on the base.html in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to understand Distribute by clause and how it could be used in Spark-SQL to optimize Sort-Merge Joins. \nAs per my understanding, the Spark Sql optimizer will distribute the datasets of both the participating tables (of the join) based on the join keys (shuffle phase) to co-locate the same keys in the same partition. If that is the case, then if we use the distribute by in the sql, then also we are doing the same thing.\nSo in what way can distribute by could be used ameliorate join performance ? Or is it that it is better to use distribute by while writing the data to disk by the load process, so that subsequent queries using this data will benefit from it by not having to shuffle it ?\nCan you please explain with a real-world example to tune join using distribute by\/cluster by in Spark-SQL ?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":2866,"Q_Id":57429479,"Users Score":3,"Answer":"Let me try to answer each part of your question:\n\nAs per my understanding, the Spark Sql optimizer will distribute the datasets of both the participating tables (of the join) based on the join keys (shuffle phase) to co-locate the same keys in the same partition. If that is the case, then if we use the distribute by in the sql, then also we are doing the same thing.\n\nYes that is correct.\n\nSo in what way can distribute by could be used ameliorate join performance ?\n\nSometimes one of your tables is already distributed, for example the table was bucketed or the data was aggregated before the join by the same key. In this case if you explicitly repartition also the second table (distribute by) you will achieve the same partitioning in both branches of the join and Spark will not induce any more shuffle in the first branch (sometimes this is referenced to as one-side shuffle-free join because the shuffle will occur only in one branch of the join - the one in which you call repartition \/ distribute by). On the other hand if you don't repartition explicitly the other table, Spark will see that each branch of the join has different partitioning and thus it will shuffle both branches. So in some special cases calling repartition (distribute by) can save you one shuffle. \nNotice that to make this work you need to achieve also the same number of partitions in both branches. So if you have two tables that you want to join on the key user_id and if the first table is bucketed into 10 buckets with this key  then you need to repartition the other table also into 10 partitions by the same key and then the join will have only one shuffle (in the physical plan you can see that there will be Exchange operator only in one brach of the join).\n\nOr is it that it is better to use distribute by while writing the data to disk by the load process, so that subsequent queries using this data will benefit from it by not having to shuffle it ?\n\nWell, this is actually called bucketing (cluster by) and it will allow you to pre-shuffle the data once and then each time you read the data and join it (or aggregate) by the same key by which you bucketed, it will be free of shuffle. So yes, this is very common technique that you pay the cost only once when saving the data and then leverage that each time you read it.","Q_Score":2,"Tags":"python,apache-spark,apache-spark-sql,pyspark-sql","A_Id":57456535,"CreationDate":"2019-08-09T11:49:00.000","Title":"Difference between DISTRIBUTE BY and Shuffle in Spark-SQL","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Apologize if this is simple, but documentation on using Python with Microsoft BI is sparse at best.  I'm curious if there is a command that imports Microsoft BI files similar to the read_excel function in pandas.\nI have a Microsoft BI file that has 175 worksheets, each of which is currently being exported to excel and saved by hand each day.  Looking for some way to automate, and thought that if I could essentially read each file into Python and then save as an excel file it would save a tremendous amount of time.\nAlso adding a note that I prefer to save as csv as opposed to xlsx.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1918,"Q_Id":57430217,"Users Score":1,"Answer":"From within PowerBI you basically have two options. I don't think there is any possibility to import a PowerBI file into Python.\n\nInside PowerQuery you add Run Python Script as step to your transformation (Transform menu > Run Python Script). This allows you to use Python in the way you are used to and makes sure all data before this step is moved into a dataframe called dataset. You can simply use dataset.to_excel() to store this dataset as Excel file. Be sure to change the working directory with something like os.chdir() becasue by default it is running in a temporary directory.\nInside PowerBI you can add a script visual. Although it says it requires visual output of your script, the reality is that any code is executed even if the script does not result in a rendered image. The same principal hold as mentioned for the step from PowerQuery. Use os.chdir() to specify your directory and use dataset.to_excel() to export.\n\nFor both make sure Python scripting is enabled in the options, should be by default when you have python installed on your machine, else have a look through the menu, you'll easily find it.","Q_Score":1,"Tags":"python,excel,pandas,export,powerbi","A_Id":57431270,"CreationDate":"2019-08-09T12:36:00.000","Title":"Python Solution - Exporting Microsoft BI sheets to excel using Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem and I am looking for a solution. I want to save the number of users registered in mongodb. For example, in django, the admin page has the number of registered users, and all other data is saved there. I want it to be saved in mongodb database instead of showing it on admin page, because my other data is also saved in mongodb. How do I do this? Should I make separate a class in models.py or something else.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":46,"Q_Id":57431089,"Users Score":1,"Answer":"You are asking a wrong question, because you should not do that.\nThe number of users is User.objects.count() maybe with a filter to count only active users. \nNever save data that can be calculated\/derived from other data, as this will just lead to inconsistencies. Why do you want to save it? You'd have to make sure the number is updated every time a new user is added\/deleted and it's so easy to forget places in your code where this might happen.","Q_Score":1,"Tags":"python,html,django,mongodb","A_Id":57445831,"CreationDate":"2019-08-09T13:26:00.000","Title":"How to save the number of registered users in mongodb?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am very new to python and cannot seem to figure out how to accomplish this task. I want to connect to a website and extract the certificate information such as issuer and expiration dates.\nI have looked all over, tried all kinds of steps but because I am new I am getting lost in the socket, wrapper etc.\nTo make matters worse, I am in a proxy environment and it seems to really complicate things.\nDoes anyone know how I could connect and extract the information while behind the proxy?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1079,"Q_Id":57432064,"Users Score":0,"Answer":"Python SSL lib don't deal with proxies.","Q_Score":0,"Tags":"python,ssl,python-requests,pyopenssl,m2crypto","A_Id":71436836,"CreationDate":"2019-08-09T14:23:00.000","Title":"Trying to extract Certificate information in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a program that imports the selenium package. It runs fine inside pyCharm but would not run on command prompt, saying \"No module named selenium\" (Windows 7). Is there an easy way to get all the setup in pyCharm and make them available in the command prompt?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":57433767,"Users Score":0,"Answer":"This is because you have imported the packages under a virtual environment(venv) . Therefore the package imports are valid only for the virtual environment. So in order to work it globally you have to install it via command prompt without activating a venv.","Q_Score":0,"Tags":"python,python-venv","A_Id":57433864,"CreationDate":"2019-08-09T16:08:00.000","Title":"Making Packages Available Outside PyCharm (Python3)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know of a solution for checking if a tweet has replies or not, without checking the reply_count field of the JSON response? \nI'm building a crawler and already have a method for scraping a timeline for tweets as well as replies to tweets. In order to increase efficiency I want to find out if a tweet has any replies at all before calling my reply method. I have a standard developer account with Twitter so I do not have access to reply_count.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":123,"Q_Id":57436251,"Users Score":0,"Answer":"Looking for this as well. Only way I found was scraping the page (which is against the Terms of Service)\nreply-count-aria-${tweet.id_str}.*?(\\d+) replies","Q_Score":0,"Tags":"twitter,tweepy,twitterapi-python","A_Id":61215841,"CreationDate":"2019-08-09T19:44:00.000","Title":"Is there a workaround for non-premium Twitter developers for getting reply_count?","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":"Hoping somebody can point me in the right direction.\nI am trying to parse log file to figure out how many users are logging into the system on a per-day basis.\nThe log file gets generated in the pattern listed below.\n\"<\"Commit ts=\"20141001114139\" client=\"ABCREX\/John Doe\">\n\"8764\",\"ABCREX\/John Doe\",\"00.000.0.000\",\"User 'ABCREX\/John Doe' successfully logged in from address '00.000.0.000'.\"\n\"<\"\/Commit>\n\"<\"Commit ts=\"20141001114139\" client=\"ABCREX\/John Doe\">\n\"8764\",\"ABCREX\/Jerry Doe\",\"00.000.0.000\",\"User 'ABCREX\/Jerry Doe' successfully logged in from address '00.000.0.000'.\"\n\"<\"\/Commit>\n\"<\"Commit ts=\"20141001114139\" client=\"ABCREX\/John Doe\">\n\"8764\",\"ABCREX\/Jane Doe\",\"00.000.0.000\",\"User 'ABCREX\/Jane Doe' successfully logged in from address '00.000.0.000'.\"\n\"<\"\/Commit>\nI am trying to capture the username from the above lines and load into DB.\nso I am interested only in values \nJohn Doe, Jerry Doe, Jane Doe\nbut the when I do pattern match using REGEX it returns the below\nclient=\"ABCREX\/John Doe\"> \nthen using the code I am employing I have to apply multiple replace to remove\n \"Client\", \"ABCREX\/\", \">\"...etc \nI currently have code which is working but I feel its highly inefficient and resource consuming. I am performing split on  tags then parsing reading line by line. \n'''extract the user login Name'''\nUserLoginName = str(re.search('client=(.*)>',items).group()).replace('ABCREX\/', '').replace('client=\"','').replace('\">', '')\nprint(UserLoginName)\nIs there any way I can tell the REGEX to grab only the string found within the pattern and not include the pattern in the results as well?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":57437708,"Users Score":0,"Answer":"pattern = r'User\\s\\'ABCREX\/(.*?)\\''\nlist_of_usernames = re.findall(pattern, output)\nThat would match the pattern\n\"User 'ABCREX\/Jerry Doe'\" and pull out the username and add it to a list. Is that helpful? I'm new here too so let me know if there is more I can help answer.","Q_Score":0,"Tags":"python,python-3.x","A_Id":57437911,"CreationDate":"2019-08-09T22:16:00.000","Title":"Python - Using RegEx to extract only the String in between pattern","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using page objects in my Appium and Python project to run the tests only on the iOS platform. Now I need to implement the same tests for Android (the app is the same).\nI know the locators are different for each platform, but the functions I created I can use for both platforms.\nIn java the @iOSXCUITFindBy and @AndroidFindBy annotations make design easier for this purpose, but so far I haven't found anything similar to use with Appium and Python.\nWhat strategy can I use to reuse the same functions for both platforms (Android and iOS)?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1462,"Q_Id":57438847,"Users Score":2,"Answer":"I used Robot Framework (python) to create test suites for testing the development of an iOS and Android app. Same app and started at the same time. Automation was done in sprint. Automated tests as the app was being developed.\nInitially we created automated tests for both platforms at the same time. Similar ideas to above...If\/Else etc...\nWe ran into issues after a few months. I wasn't as simple as If\/Else. Functionality of the SAME APP across two mobile platforms changed during the development. Differences in what you can do (development\/technical wise) on iOS vs Android platforms differs in some points.\nThey essentially were the same app but they had differences created by some technical limitations. Allot of tests were simply not applicable across both platforms and would have required allot of effort and ugly tests to shoehorn them to be.\nOne platform then became a priority over the other. But laying the groundwork for test functionality for both platforms has an overhead which the business didn't want\/need as one platform was a priority (with option for he other to become the priority at a later date).\nDropped dual test suites after six months in favour of Android Test Suite separate to iOS Test Suite.\nSure there was some overlap but it became allot easier to manage.\nIf I were to start over I would have kept them separate at the start.\ntldr :) Keep them separate (folder\/suite structure and functionality wise).","Q_Score":2,"Tags":"python,appium,python-appium","A_Id":57673908,"CreationDate":"2019-08-10T02:30:00.000","Title":"Appium - Design page object to reuse same function with iOS and Android","Data Science and Machine Learning":0,"Database and SQL":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 to find the difference in position of same element (for all the elements) in O(n) complexity ?\nSuppose i have been given the list [1,3,0,1,3,0,1]\nthen difference in position of 1 is 3,3,6 (difference between pair of all ones)\nfor 0 is 3\nfor 3 is 3\nI tried using dictionary to store indices but to find difference i have to iterate over all indices thus increasing complexity","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":57438850,"Users Score":0,"Answer":"Let me start with the fact that the '6' in '3,3,6' is abundant information as it follows from the '3,3' before. So I am not aiming to include this in my output as it increases the output length quadratic over the number of pairs you will find of the same type. \nYou can find all distances for neighbouring '1's in O(n), right?\nYou can also do it for all neighbouring ones, twos and threes (or any fixed\/limited number of numbers). You could simply repeat the entire algorithm 3 times. The problem is that you could have 'len(list)' number of different integers in your list and then it is impossible to do so in O(n). In the latter case your bookkeeping\/memory would be of size O(n) and as you need to look at every element of your list and access your bookkeeping to request the last index of the identitcal numbers, you would need to access the right information in O(1),which is impossible I guess. Or is there a smart datastructure which allows this?","Q_Score":0,"Tags":"python,python-3.x","A_Id":57439396,"CreationDate":"2019-08-10T02:32:00.000","Title":"How to find difference in positions of same element in list with O(n) complexity(for all elements)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a database with some tables in it. I want now on my website has the dropdown and the choices are the names of people from a column of the table from my database and every time I click on a name it will show me a corresponding ID\u00a0also from a column from this table. how I can do that? or maybe a guide where should I find an answer !\nmany thanks!!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":57439500,"Users Score":0,"Answer":"You have to do that in python(if that's what you are using in the backend). \nYou can create functions in python that gets the list of name of tables which then you can pass to your front-end code. Similarly, you can setup functions where you get the specific table name from HTML and pass it to python and do all sort of database queries.\nIf all these sounds confusing to you. I suggest you take a Full stack course on udemy, youtube, etc because it can't really be explained in one simple answer.\nI hope it was helpful. Feel free to ask me more","Q_Score":0,"Tags":"javascript,python,html,flask","A_Id":57439549,"CreationDate":"2019-08-10T05:15:00.000","Title":"SelectField to create dropdown menu","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm new to using KNN and in my train set I have velocity vector. Since the directions 359\u00b0 and 0\u00b0 are completely different I was thinking of transforming the direction so that the vector in test data it points to 180\u00b0.\nI could make this transformation before using KNeighborsClassifier if I predict from one data point, but when I tune the hyperparameters with GridSearchCV the transformation should be done between every comparison. Is there some way to do that?\nOr some alternative way that I'm missing?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":57440714,"Users Score":0,"Answer":"You can break direction column, theta into 2 columns, sin(theta) and cos(theta), both of which would have continuity.","Q_Score":0,"Tags":"python,scikit-learn,knn,gridsearchcv","A_Id":57441200,"CreationDate":"2019-08-10T08:49:00.000","Title":"How to use directional data as feature using scikit-learn knn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In matplotlib, matplotlib.pyplot.savefig saves the current figure. If I have multiple figures as variables in my workspace, e.g. fig1, fig2, and fig3, is it possible to save any of these figures based on their variable name, without first bringing them up as the current figure? E.g., I'd like to do something like:\nsave('fig2', 'fig2_file.png')","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":209,"Q_Id":57444490,"Users Score":1,"Answer":"You can save individual figures by: \n\nfigX.savefig('figX_file.png')\n\n.","Q_Score":0,"Tags":"python,matplotlib","A_Id":57444559,"CreationDate":"2019-08-10T17:59:00.000","Title":"How to save a figure in matplotlib by its variable name?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a hybrid application with python back-end and java GUI and for that purpose I am using jython to access the data from the GUI. \nI wrote code using a standard Python 3.7.4 virtual environment and it worked \"perfectly\". But when I try to run the same code on jython it doesn't work so it seems that in jython some packages like threading are overwritten with java functionality. \nMy question is how can I use the threading package for example from python but in jython environment? \nHere is the error: \n\nException in thread Thread-1:Traceback (most recent call last):\n    File \"\/home\/dexxrey\/jython2.7.0\/Lib\/threading.py\", line 222, in _Thread__bootstrap\n      self.run()\n   self._target(*self._args, **self._kwargs)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":122,"Q_Id":57445745,"Users Score":1,"Answer":"Since you have already decoupled the application i.e using python for backend and java for GUI, why not stick to that and build in a communication layer between the backend and frontend, this layer could either be REST or any Messaging framework.","Q_Score":0,"Tags":"java,python,jython","A_Id":57445769,"CreationDate":"2019-08-10T21:15:00.000","Title":"Using the original python packages instead of the jython packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I need to backpropagate through a neural network twice and I don't use retain_graph=True, I get an error. \nWhy? I realize it is nice to keep the intermediate variables used for the first backpropagation to be reused for the second backpropagation. However, why aren't they simply recalculated, like they were originally calculated in the first backpropagation?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":57447736,"Users Score":0,"Answer":"By default, PyTorch doesn't store intermediate gradients, because the PyTorch's main feature is Dynamic Computational Graphs, so after backpropagation the graph will be freed all the intermediate buffers will be destroyed.","Q_Score":0,"Tags":"python,neural-network,deep-learning,pytorch","A_Id":57450598,"CreationDate":"2019-08-11T06:13:00.000","Title":"Why does not using retain_graph=True result in error?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have literally hundreds of slides created with python-pptx. Many of these slides have charts I would like to use in a docx file.  So what I would like to do is use python-docx to import these slides\/charts into a docx file. Is that possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":504,"Q_Id":57450511,"Users Score":2,"Answer":"No, not with the current python-pptx or python-docx APIs.\nSuch a thing is possible of course, since the Word application will allow you to \"paste\" charts from PowerPoint and in fact the charts themselves are specified in DrawingML, an XML vocabulary that is shared between PowerPoint, Word, and Excel.\nBut to make this work with Python, you'd have to dig quite deep into the internals of both python-pptx and python-docx (although their architectures are much the same). You would probably also need to learn more about the respective XML vocabularies than you really wanted to know. So you might want to consider alternate approaches such as using win32com support for this sort of thing, especially if you are running on Windows and this is a one-time job and does not need to be hosted on a server for ongoing use.\nIf you thought you did want to tackle it, a good first step might be to inspect the XML related to a PowerPoint chart (located in both the slide and the chart-parts of the PPTX package) and also inspect the corresponding XML that appears in a Word (.docx) file that includes a chart. That will give you an idea of what needs to come over from the PPTX package, what transformations it may need to undergo (namespace changes perhaps) and where it would need to be added into the DOCX package, including updating relationship files and perhaps updating certain ID values to make them unique in the target package.","Q_Score":1,"Tags":"python-docx,python-pptx","A_Id":57453321,"CreationDate":"2019-08-11T13:49:00.000","Title":"Importing pptx slides into docx document","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to access an excel file using python for my physics class. I have to generates data that follows a function but creates variance so it doesn\u2019t line up perfectly to the function(simulating the error experienced in experiments). I did this by using the rand() function. We need to generate a lot of data sets so that we can average them together and eliminate the error\/noise creates by the rand() function. I tried to do this by loading the excel file and recording the data I need, but then I can\u2019t figure out how to get the rand() function to rerun and create a new data set. In excel it reruns when i change the value of any cell on the excel sheet, but I don\u2019t know how to do this when I\u2019m accessing the file with Python. Can someone help me figure out how to do this? Thank You.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":193,"Q_Id":57454186,"Users Score":0,"Answer":"Excel formulas like RAND(), or any other formula, will only refresh when Excel is actually running and recalculating the worksheet.\nSo, even though you may be access the data in an Excel workbook with Python, you won't be able to run Excel calculations that way. You will need to find a different approach.","Q_Score":0,"Tags":"excel,python-3.x,pandas,xlrd,xlwt","A_Id":57454549,"CreationDate":"2019-08-11T22:56:00.000","Title":"How to get the rand() function in excel to rerun when accessing an excel file through python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I'm not a test expert and sometimes, when using packages like DRF, I think what should I test on the code...\nIf I write custom functions for some endpoints, I understand I should test this because I've written this code and there are no tests for this... But the DRF codebase is pretty tested.\nBut if I'm writing a simple API that only extends ModelSerializer and ModelViewSet what should I be testing?\nThe keys in the JSON serialized?\nThe relations?\nWhat should I be testing?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":630,"Q_Id":57455468,"Users Score":1,"Answer":"Even if you're only using automated features and added absolutely no customization on your serializer and viewset, and it's obvious to you that this part of the code works smoothly, you still need to write tests.\nCode tends to get large, and some other person might be extending your code, or you might go back to your code a few months later and not remember how your implementation was.  Knowing that tests are passing will inform other people (or yourself in the distant future) that you're code is working without having to read it and dive into the implementation details, which makes your code reliable.\nThe person using your API might be using it at a service and not even be interested in what framework or language you used for implementation, but only wants to be sure that the features he\/she requires work properly. How can we ensure this? One way is to write tests and pass them.\nThat's why it's very important to write complete and reliable tests so people can safely use or extend your code knowing that the tests are passing and everything is OK.","Q_Score":0,"Tags":"python,django,testing,django-rest-framework","A_Id":57456241,"CreationDate":"2019-08-12T03:55:00.000","Title":"What to test in a simple DRF 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":1},{"Question":"The documentation just says\n\nTo save an object back to the database, call save()\n\nThat does not make it clear. Exprimenting, I found that if I include an id, it updates existing entry, while, if I don't, it creates a new row. Does the documentation specify what happens?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2418,"Q_Id":57459259,"Users Score":-1,"Answer":"Depends on how the Model object was created. If it was queried from the database, UPDATE. If it's a new object and has not been saved before, INSERT.","Q_Score":0,"Tags":"python,django","A_Id":57459281,"CreationDate":"2019-08-12T10:10:00.000","Title":"Does django's `save()` create or update?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I try train ssd-mobilenet in my own dataset :\ntraining image : 3400 with size :1600*1200\ntest set :800 with size :1600 *1200\ntensorflow -gpu :1.13.1  gpu :4GB\ncuda 10.0 cudnn 7\nobject: road damage like aligator crack\nbut after  197000 step my training loss cannot go down 2:\nI need helps.Thanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":274,"Q_Id":57459492,"Users Score":0,"Answer":"I would first try with images of size 300 x 300 first, or use a library which will downscale your images and the bounding boxes.","Q_Score":1,"Tags":"python,tensorflow,object-detection-api","A_Id":57469658,"CreationDate":"2019-08-12T10:25:00.000","Title":"SSd_mobilenet loss cannot go down","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm very new to Computer Vision, I'm tryind to build a CV model which will detect and recognize price tags and extract info from it. I've already trained model that can detect price tags using YOLO. But I also want to teach my system to detect and recognize text which only written inside these price tags. Than parse this info into different parts, for example: price, product name, product description. Or mayby I firstly need to parse detected blocks (price block on the left side of the price tag, product name on the right side, etc.) then read it. Any ideas would be appriciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":71,"Q_Id":57460861,"Users Score":2,"Answer":"Well, the first one that pops into my mind would be to crop the objects detected with YOLO and then run the OCR on that image. After running OCR, you'll have to do some postprocessing to classify each line of text to a specific category (price, name etc.)","Q_Score":0,"Tags":"python,opencv,yolo","A_Id":57460928,"CreationDate":"2019-08-12T12:04:00.000","Title":"Detect text only inside detected objects","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My notebook is located on a server, which means that the kernel will still run even though I close the notebook tab. I was thus wondering if it was possible to let the cell running by itself while closing the window? As the notebook is located on a server the kernel will not stop running... \nI tried to read previous questions but could not find an answer. Any idea on how to proceed? \nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":57462603,"Users Score":0,"Answer":"If you run the cell before closing the tab it will continue to run once the tab has been closed. However, the output will be lost (anything using print functions to stdout or plots which display inline) unless it is written to file.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":57462710,"CreationDate":"2019-08-12T13:56:00.000","Title":"Jupyter notebook: need to run a cell even though close the tab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My notebook is located on a server, which means that the kernel will still run even though I close the notebook tab. I was thus wondering if it was possible to let the cell running by itself while closing the window? As the notebook is located on a server the kernel will not stop running... \nI tried to read previous questions but could not find an answer. Any idea on how to proceed? \nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":144,"Q_Id":57462603,"Users Score":1,"Answer":"You can make open a new file and write outputs to it. I think that's the best that you can do.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":60322753,"CreationDate":"2019-08-12T13:56:00.000","Title":"Jupyter notebook: need to run a cell even though close the tab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I receive messages from a feed which sends about 2 million messages per day. Each of these messages is pretty small and they are not needing to be dealt with in a streaming fashion so I batch process a full day of messages at a time. \nThe current infrastructure receives these messages, groups them together and uploads a gzipped file containing 1000 messages to AWS S3. The files are named as a datetime stamp of the format yyyymmdd-hhmmss. The batch process runs once a day (scheduled on Airflow) and it should select the new files from the bucket and process them. Currently, I am not using any hooks or sensors for this job.\nMy question is; what is the best way to collect the new files from S3 if the folder also contains all previous day files?\nThe inefficient solution I have is to pull down the list of files in the folder on S3 and process the files which have a filename matching the date I am processing for. My batch process is an Airflow DAG so I would like to maintain idempotency, meaning I don't want to remove files from this S3 folder after processing.\nIdeally, I would like to select only the files with the datetime in the filename being after midnight the previous day (from execution date) and process them, without having to cycle thru the full list of files given this list will be growing continuously making each day slightly slower than the last.\nIs there a better mechanism provided either through Airflow or Python to select files from S3? Or is there a method of performing such a task in a more efficient way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":778,"Q_Id":57462645,"Users Score":0,"Answer":"Not knowing your full infrastructure, is it possible for you to partition by date at the point of uploading the gzipped files to s3? \nIncluding a s3 folder prefix of \/date=yyyymmdd\/ would mean enable you to retrieve just that day's files and preserve idempotency.\nWhen it comes to your airflow job, you pass the date as an argument to retrieve only those days in that s3 partition.","Q_Score":2,"Tags":"python,python-3.x,amazon-web-services,amazon-s3,airflow","A_Id":57462903,"CreationDate":"2019-08-12T13:59:00.000","Title":"Batch processing from S3 with Airflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a problem. I am trying to use my model with Rasa core, but it gives me this error:\n\nrasa_nlu.model.UnsupportedModelError: The model version is to old to\n  be loaded by this Rasa NLU instance. Either retrain the model, or run\n  withan older version. Model version: 0.14.6 Instance version: 0.15.1\n\nDoes someone know which version I need to use then and how I can install that version?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":879,"Q_Id":57465038,"Users Score":0,"Answer":"I believe you trained this model on the previous version of Rasa NLU and updated Rasa NLU to a new version (Rasa NLU is a dependency for Rasa Core, so changes were made in requirenments.txt file).\nIf this is a case, there are 2 ways to fix it:\n\nRecommended solution. If you have data and parameters, train your NLU model again using current dependencies (this one that you have running now). So you have a new model which is compatible with your current version of Rasa\nIf you don't have a data or can not retrain a model for some reason, then downgrade Rasa NLU to version 0.14.6. I'm not sure if your current Rasa core is compatible with NLU 0.14.6, so you might also need to downgrade Rasa core if you see errors.\n\nGood luck!","Q_Score":0,"Tags":"python,anaconda,rasa-nlu,rasa-core","A_Id":57510905,"CreationDate":"2019-08-12T16:37:00.000","Title":"Rasa NLU model to old","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm a novice in python programming and i'm trying to split full name to first name and last name, can someone assist me on this ? so my example file is:\nSarah Simpson\nI expect the output like this : Sarah,Simpson","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20697,"Q_Id":57466474,"Users Score":0,"Answer":"name = \"Thomas Winter\"\nLastName = name.split()[1]\n(note the parantheses on the function call split.)\nsplit() creates a list where each element is from your original string, delimited by whitespace. You can now grab the second element using name.split()[1] or the last element using name.split()[-1]","Q_Score":2,"Tags":"python-3.x,string,split","A_Id":57466538,"CreationDate":"2019-08-12T18:34:00.000","Title":"how can i split a full name to first name and last name in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a package that bundles some utilities I'm using across projects. What's an easy way to import this package each time I start a new project?\nThere's some private work data stored as variables in there, so I won't be uploading it onto PyPi. \nI am using Python 3.7 and PyCharm, and in Project Interpreter attempted to put the \/zhou_utils\/dist as a 'URL' of repositories it searches for, but it threw an error.\nAnother solution I saw someone present was to change their local PATH, but I don't have admin privileges on my work computer so don't know if I can do that.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":57467154,"Users Score":0,"Answer":"Running this in my terminal from my 2nd project worked:\npip install -e C:\\Users\\Uname\\PycharmProjects\\zhou_utils\\","Q_Score":0,"Tags":"python,package","A_Id":57467408,"CreationDate":"2019-08-12T19:25:00.000","Title":"Importing my own private package in Python\/PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I see an option for MySql and Postgres, and have read help messages for sqlite, but I don't see anyway to use it or to install it.  So it appears that it's available or else there wouldn't be any help messages, but I can't find it.  I can't do any 'sudo', so no 'apt install', so don't know how to invoke and use it!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":19,"Q_Id":57467554,"Users Score":1,"Answer":"sqlite is already installed. You don't need to invoke anything to install it. Just configure your web app to use it.","Q_Score":0,"Tags":"pythonanywhere","A_Id":57476932,"CreationDate":"2019-08-12T19:59:00.000","Title":"pythonanwhere newbie: I don't see sqlite option","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used to use keras and the image format it followed is [Height x Width x Channels x Samples]. i decided to switch to PyTorch. But i didn\u2019t switch out my data loading schemes. So now i have numpy arrays of shape HxWxCxS, instead of SxCxHxW which is required for PyTorch. Does anyone have any idea to convert this ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2309,"Q_Id":57467707,"Users Score":6,"Answer":"First, Keras format is (samples, height, width, channels).\nAll you need to do is a moved = numpy.moveaxis(data, -1,1)\nIf by luck you were using the non-default config \"channels_first\", then the config is identical to that of PyTorch, which is (samples, channels, height, width).  \nAnd when transforming to torch: data = torch.from_numpy(moved)","Q_Score":2,"Tags":"python,image,opencv,keras,pytorch","A_Id":57467836,"CreationDate":"2019-08-12T20:13:00.000","Title":"Reshaping Image for PyTorch","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have attempted to run a FDR correction on an array of p-values using both statsmodels.stats.multitest's multipletests(method='fdr_bh') and fdrcorrection. In both instances I receive an array of NaN's as the corrected p-values. I do not understand why the corrected p-value is returning as NaN. Could someone please help explain?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":694,"Q_Id":57468030,"Users Score":2,"Answer":"Check for NaNs in your p-value array. using multipletests on an array with any NaNs will return all NaNs, as you describe.","Q_Score":1,"Tags":"python,statsmodels","A_Id":62476273,"CreationDate":"2019-08-12T20:45:00.000","Title":"Corrected P-value returned as NaN","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are there any conventions on how to implement services in Django? Coming from a Java background, we create services for business logic and we \"inject\" them wherever we need them.\nNot sure if I'm using python\/django the wrong way, but I need to connect to a 3rd party API, so I'm using an api_service.py file to do that. The question is, I want to define this service as a class, and in Java, I can inject this class wherever I need it and it acts more or less like a singleton. Is there something like this I can use with Django or should I build the service as a singleton and get the instance somewhere or even have just separate functions and no classes?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2544,"Q_Id":57468620,"Users Score":0,"Answer":"Adding to the answer given by bruno desthuilliers and TreantBG.\nThere are certain questions that you can ask about the requirements.\nFor example one question could be, does the api being called change with different type of objects ?\nIf the api doesn't change, you will probably be okay with keeping it as a method in some file or class.\nIf it does change, such that you are calling API 1 for some scenario, API 2 for some and so on and so forth, you will likely be better off with moving\/abstracting this logic out to some class (from a better code organisation point of view).\nPS: Python allows you to be as flexible as you want when it comes to code organisation. It's really upto you to decide on how you want to organise the code.","Q_Score":4,"Tags":"python,django,python-3.x","A_Id":67801062,"CreationDate":"2019-08-12T21:44:00.000","Title":"Python\/Django and services as classes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a static C library, that I need to call into from Python. I was looking at ctypes for this however it can only work with dynamically loaded libraries. Is there an equivalent or alternative for staticly linked libraries?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2502,"Q_Id":57469224,"Users Score":0,"Answer":"One option I've used to do this is to execute a python script from within a C\\C++ application.  The Boost.Python implementation is what I used to accomplish this.  I statically linked the library file to the C app and ran the python script from the app. The methods in the C app that call into your static C library can be exposed to the python script.\nAlthough the above is a solution...another way to do it is to build a pipe client in python, then connect to a C app (that is running a pipe server) that is statically linked to your library.","Q_Score":0,"Tags":"python,c,static-libraries","A_Id":57469331,"CreationDate":"2019-08-12T22:58:00.000","Title":"Call into static C library from Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a binary file consisting of an N-byte header, followed by a data block. I have input describing the locations of various bits of data, as offsets from the start of the data block; i.e. not the start of the file itself.\nI want to open the file in such a way that seek() calls (and anything similar) seek within the data block, not the whole file.\nSome options I've considered:\n\nmmap. Close, but its offset argument is limited to multiples of pagesize.\nSubclass file objects and override seek() to add the header length. Google suggests this may be annoying to do right.\nSlurp the whole file minus the header, then make a bytesio. Problematic if the file is huge.\nPatch seek() on the opened file object. I think this might work but monkeypatching makes me nervous.\n\nI think what I really want is something that looks and acts like a file object but only \"sees\" a portion of the underlying file. Is there a good way to do that?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":57470345,"Users Score":0,"Answer":"Rather than inheritance and monkey-patching, you forgot a simpler option: implement a file-like class which seeks the way you want.  Then you'll have full control and non-leaky encapsulation.","Q_Score":0,"Tags":"python,python-3.x","A_Id":57470372,"CreationDate":"2019-08-13T02:22:00.000","Title":"How do I make a file object that operates on only part of the underlying file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a binary file consisting of an N-byte header, followed by a data block. I have input describing the locations of various bits of data, as offsets from the start of the data block; i.e. not the start of the file itself.\nI want to open the file in such a way that seek() calls (and anything similar) seek within the data block, not the whole file.\nSome options I've considered:\n\nmmap. Close, but its offset argument is limited to multiples of pagesize.\nSubclass file objects and override seek() to add the header length. Google suggests this may be annoying to do right.\nSlurp the whole file minus the header, then make a bytesio. Problematic if the file is huge.\nPatch seek() on the opened file object. I think this might work but monkeypatching makes me nervous.\n\nI think what I really want is something that looks and acts like a file object but only \"sees\" a portion of the underlying file. Is there a good way to do that?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":57470345,"Users Score":0,"Answer":"mmap the entire file, and then use a memoryview of the data block you are interested in. Then offsets into the memory view will be relative to the data block.","Q_Score":0,"Tags":"python,python-3.x","A_Id":57470526,"CreationDate":"2019-08-13T02:22:00.000","Title":"How do I make a file object that operates on only part of the underlying file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a conversation where the bot send out multiple replies.\nFor example:\nUser: \u201cHi\u201d\nBot: \u201cHello\u201d\nBot: \u201cHow can I help you?\u201d  \nHere the bot sends out multiple messages. In interactive mode this is working fine. However, after I setup the REST API (following this How to serve chatbot from server?), the bot does not send out multiple messages for obvious reasons. How can I get this working?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":583,"Q_Id":57478153,"Users Score":0,"Answer":"you can use \\n\\n inside a text response to split it into two messages..\nUnfortunately it does not work with button response messages.\nHere You can use custom actions with as many dispatcher.utter_message() events as you want..","Q_Score":2,"Tags":"python,rasa-nlu,rasa-core,rasa","A_Id":71426079,"CreationDate":"2019-08-13T12:53:00.000","Title":"How to make the bot send out multiple messages in sequence over REST API? [Rasa]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to build a word cloud containing multiple word structures (not just one word). In any given text we will have bigger frequencies for unigrams than bigrams. Actually, the n-gram frequency decreases when n increases for the same text.\nI want to find a magic number or a method to obtain comparative results between unigrams and bigrams, trigrams, n-grams. \nThere is any magic number as a multiplier for n-gram frequency in order to be comparable with a unigram? \nA solution that I have now in mind is to make a top for any n-gram (1, 2, 3, ...) and use the first z positions for any category of n-grams.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":442,"Q_Id":57482331,"Users Score":1,"Answer":"As you've asked this, there is no simple linear multiplier.  You can make a general estimate by the size of your set of units.  Consider the English alphabet of 26 letters: you have 26 possible unigrams, 26^2 digrams, 26^3 trigrams, ... Simple treatment suggests that you would multiply a digram's frequency by 26 to compare it with unigrams; trigram frequencies would get a 26^2 boost.\nI don't know whether that achieves the comparison you want, as the actual distribution of n-grams is not according to any mathematically tractable function.  For instance, letter-trigram distribution is a good way to differentiate the language in use: English, French, Spanish, German, Romanian, etc. have readily differential distributions.\nAnother possibility is to normalize the data: convert each value into a z-score, the amount of standard deviations above\/below the mean of the distribution.  The resulting list of z-scores has a mean of 0 and a standev of 1.0\nDoes either of those get you the results you need?","Q_Score":0,"Tags":"python,text,nlp,nltk","A_Id":57482532,"CreationDate":"2019-08-13T17:03:00.000","Title":"How to compare frequency of unigrams with frequencies of bigrams, trigrams, etc?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am receiving a SyntaxError: invalid syntax when using Import requests using python 3.7\nI have re-installed requests.  \nImport requests\n... \n  File \"\", line 10\n    Import requests\n                  ^\nSyntaxError: invalid syntax\nI did not expect any problem.  Using Automate The Boring Stuff with Python by Al Sweigart page 237","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":484,"Q_Id":57482476,"Users Score":0,"Answer":"I believe your issue is that you're using Import with a capital 'I' instead of import with a lowercase 'i'.","Q_Score":0,"Tags":"python-3.x,python-requests,installation,python-import","A_Id":57482527,"CreationDate":"2019-08-13T17:14:00.000","Title":"Syntax error on import requests with python 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get this error message: Missing optional dependency 'pyarrow'.  Use pip or conda to install pyarrow. when I run a simple command to load feather data, ie: pd.read_feather(\"data.feather\").\nSurely I can install pyarrow from conda-forge, but that forces a downgrade from Pandas 25 to Pandas 24. That does not make sense to me.\nI want to keep Pandas 25 and load feather files. How to proceed?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":2011,"Q_Id":57485480,"Users Score":3,"Answer":"The Conda's version of pyarrow does not work properly.\nUninstall it and then install it again via pip  (the current version is 0.15.1 vs 0.13.something of Conda) - it works fine with Pandas 25.x","Q_Score":0,"Tags":"python,pandas,pyarrow,feather","A_Id":58755099,"CreationDate":"2019-08-13T21:21:00.000","Title":"Why does feather need pyarrow? (or: How to load feather data without downgrading to pandas 24?)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a webserver on linux in python so that I can use it to get csv files from the linux machine onto a windows machine. I am quite unfamiliar with networking terminology so I would greatly appreciate it if the answer is a little detailed. I dont want to create a website, just the webserver to get the csv file requested.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":755,"Q_Id":57485604,"Users Score":0,"Answer":"You can create an simple file server, using flask, django or any other python web-server frameworks. There are just some small tips:\n\nYou should send csv files through HTTP POST request to web-server. I think  multi-part\/form-data is appropriate for this. \nAn small\/simple Database with track files received and their locations on disk.\nYou can also have something to translate csv files to database records on demand. After that you will be able to do very useful things on them.\n\nFor any more questions, ask different questions to get appropriate\/expert answers. (welcome to SO)","Q_Score":0,"Tags":"python,webserver","A_Id":57485935,"CreationDate":"2019-08-13T21:35:00.000","Title":"How to make a python webserver that gives a requested csv file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm preparing my dataset to be preprocessed before training with CNN model but i couldn't generate data from this type of file which contain several signals.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":198,"Q_Id":57485659,"Users Score":1,"Answer":"I recommend using the gdflib library. It'll allow you to process your .gdf files by organizing your data into nodes for further processing.\nIt would also help if you could please provide a minimal reproducible example of what you have tried.","Q_Score":0,"Tags":"python","A_Id":57485755,"CreationDate":"2019-08-13T21:41:00.000","Title":"How can i generate Data from .gdf files using Jupyter notebook?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a pretty big spider that basically extracts the data from an amazon product page.\nThe problem is that sometimes, no data comes back when I extract. After that happens I check the URL that was processed and, following the xpath with a chrome tool, the data is in fact there.\nI know that what me and the Chrome tool sees is not the same as what the spider processes so, is it there any way to actually see the source code the spider is trying to extract from? and will the XPath I make with the chrome tool's help be trustworthy?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":497,"Q_Id":57486244,"Users Score":1,"Answer":"Check the view-source with (Ctrl-U in Chrome). Chrome tools will not always line up with the html source. Probably due to the JavaScript on the page.","Q_Score":0,"Tags":"python-3.x,web-scraping,scrapy","A_Id":57501420,"CreationDate":"2019-08-13T22:56:00.000","Title":"Checking source code in a scrapy response","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The dataset I have is a set of quotations that were presented to various customers in order to sell a commodity. Prices of commodities are sensitive and standardized on a daily basis and therefore negotiations are pretty tricky around their prices. I'm trying to build a classification model that had to understand if a given quotation will be accepted by a customer or rejected by a customer.\nI made use of most classifiers I knew about and XGBClassifier was performing the best with ~95% accuracy. Basically, when I fed an unseen dataset it was able to perform well. I wanted to test how sensitive is the model to variation in prices, in order to do that, I synthetically recreated quotations with various prices, for example, if a quote was being presented for $30, I presented the same quote at $5, $10, $15, $20, $25, $35, $40, $45,..\nI expected the classifier to give high probabilities of success as the prices were lower and low probabilities of success as the prices were higher, but this did not happen. Upon further investigation, I found out that some of the features were overshadowing the importance of price in the model and thus had to be dealt with. Even though I dealt with most features by either removing them or feature engineering them to better represent them I was still stuck with a few features that I just cannot remove (client-side requirements)\nWhen I checked the results, it turned out the model was sensitive to 30% of the test data and was showing promising results, but for the rest of the 70% it wasn't sensitive at all. \nThis is when the idea struck my mind to feed only that segment of the training data where price sensitivity can be clearly captured or where the success of the quote is inversely related to the price being quoted. This created a loss of about 85% of the data, however the relationship that I wanted the model to learn was being captured perfectly well.\nThis is going to be an incremental learning process for the model, so each time a new dataset comes, I'm thinking of first evaluating it for the price sensitivity and then feeding in only that segment of the data for training which is price sensitive. \nHaving given some context to the problem, some of the questions I had were:\n\nDoes it make sense to filter out the dataset for segments where the kind of relationship I'm looking for is being exhibited?\nPost training the model on the smaller segment of the data and reducing the number of features from 21 to 8, the model accuracy went down to ~87%, however it seems to have captured the price sensitivity bit perfectly. The way I evaluated price sensitivity is by taking the test dataset and artificially adding 10 rows for each quotation with varying prices to see how the success probability changes in the model. Is this a viable approach to such a problem?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":53,"Q_Id":57487124,"Users Score":1,"Answer":"To answer your first question, deleting the part of the dataset that doesn't work is not a good idea because then your model will overfit on the data that gives better numbers. This means that the accuracy will be higher, but when presented with something that is slightly different from the dataset, the probability of the network adapting is lower.\nTo answer the second question, it seems like that's a good approach, but again I'd recommend keeping the full dataset.","Q_Score":0,"Tags":"python,machine-learning,xgbclassifier","A_Id":57488153,"CreationDate":"2019-08-14T01:33:00.000","Title":"Does it make sense to use a part of the dataset to train my model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If possible can anyone advise the best way to get the floor of an integer e.g. 388,000 should always return the floor of 380,000.\nThats to say the floor should always be rounded down to 10,000.\nI saw math.floor(300.16):\nResult:\n300.0\nHowever this function only applies the floor to the decimal places.\nAll help is greatly appreciated \nThanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":57488324,"Users Score":0,"Answer":"I would divide the given integer by 10,000.0 (with type cast to float), then floor and then multiply by 10.000 (with type cast to integer). Should do the job.\nMaybe your language cuts the decimals when you divide integers, than you may spare the casting and flooring and just divide and multiply.","Q_Score":0,"Tags":"python,pandas,numpy","A_Id":57488365,"CreationDate":"2019-08-14T04:50:00.000","Title":"Floor of integer to the nearest 10,000","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If possible can anyone advise the best way to get the floor of an integer e.g. 388,000 should always return the floor of 380,000.\nThats to say the floor should always be rounded down to 10,000.\nI saw math.floor(300.16):\nResult:\n300.0\nHowever this function only applies the floor to the decimal places.\nAll help is greatly appreciated \nThanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":57488324,"Users Score":0,"Answer":"I'm assuming you want to perform this operation on a pandas series, given this question is tagged with pandas.\nUPDATED: Thanks to GZ0\ns = s \/\/ 10000 * 10000","Q_Score":0,"Tags":"python,pandas,numpy","A_Id":57488429,"CreationDate":"2019-08-14T04:50:00.000","Title":"Floor of integer to the nearest 10,000","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a local virtualenv (venv) that was activated.\nMy script executes another script using subprocess.call(), but that causes the new script to be executed outside of the virtualenv.\nIs there any way to execute another process but keep it inside the virtualenv?\nEDIT: I don't it's a duplicate of the given links since I assume it is possible to avoid reactivating the virtualenv, and can somehow \"stay within it\"","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":171,"Q_Id":57488853,"Users Score":0,"Answer":"In the bin folder of your virtualenv you can find a file named activate_this.py.\nYou can use it to activate the virtualenv for the current interpreter. Documentation is inside the file.","Q_Score":0,"Tags":"python,python-3.x,subprocess,virtualenv","A_Id":57492796,"CreationDate":"2019-08-14T05:56:00.000","Title":"subprocess.call when inside virtualenv leaves the virtual environment on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently doing a group project about Semantic Segmentation and need to train model with own data set. The problem is  data set is not available in any pre-trained model since the objective is to detect each part of sneakers(eg. lace, outsole, front patch, logos etc). None of our team members had never studied deep learning but had studied in computer science.\nAlso, there's another question about Mask-RCNN. What is the exact meaning of weights of pre-trained model? Is it the weights calculated from DL model?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":103,"Q_Id":57491013,"Users Score":1,"Answer":"A pre-trained model is a model that has been trained usually with a big dataset using big computers and can be fine-tuned for a given problem using small amounts of computation. This is possible to do with Deep Learning, where training a model consists in adjusting some matrices of weights. When we refer to pre-trained weights we mean that we train a model with big datasets and then we store the weights in order to be used by other' tasks.","Q_Score":0,"Tags":"python,python-3.x,deep-learning","A_Id":57491074,"CreationDate":"2019-08-14T08:34:00.000","Title":"Mask-RCNN project","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given the tuple \nx = (1, 2, (3, 'John', 4), 'Hi')\nwhy x[0] = 1 returns an int, but x[0:1] = (1,) returns a tupple? \nI can see x[0:1]  seems to not be equal to x[0], but why?\n(this is from an exercise from MIT 6.00.1 course, thanks in advance)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":160,"Q_Id":57492885,"Users Score":0,"Answer":"Both x[0:1] and x[:1] will return a tuple.\nIt returns (1,) because you told Python to give you the elements from the range 0 to 1 and not just a single element.","Q_Score":2,"Tags":"python-3.x,tuples","A_Id":57492950,"CreationDate":"2019-08-14T10:27:00.000","Title":"in a tuple, why is x[0] not equal to x[:1]? for tuple x = (1, 2, (3, 'John', 4), 'Hi')","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed python using the command:\n    brew install python3\nNow when I use 'which python', path is '\/usr\/bin\/python' and when I use 'which python3' path is 'usr\/local\/bin\/python3'\nShouldn't it fetch the same path ? \nAs python3, which is a version, still falls under python ?\nI just am not clear as to why different paths are thrown. Please Explain!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1668,"Q_Id":57493129,"Users Score":1,"Answer":"Python is a program, that will take inputs, and interpret them. How will it interpret them ? Following a set of rules, written in a lot of files. Where are these files written ? Somewhere the program knows. And by default, the 2 paths you have are the paths it knows where to go.\nPython2 and Python3 have different files, because even if they have the same base, they are not same and behave differently. Hence the 2 differents paths.\nThough, through the years, people have come up with solution to avoid these \"python version collisions\" on computers : it is called a virtualenv. \nVirtualenv is basically a script that will contain a whole new python (at the version you wish you install it), and, when you \"activate\" it, you will be able to use python, and have the version you wish to develop with. Doing this, everyone is able to only use python and still use different versions depending of the program you with to use.\nExample : You have python on your system which writes Python 2.7.12 when you do python --version. If you instantiate your virtualenv (see the doc), and then use python --version again, you might see something else along the lines of Python 3.6.8. Your former computer, or other scripts, can still use the previous python version, and you new script can use the new one, without any conflicts.","Q_Score":0,"Tags":"python,python-3.x,macos,python-2.7,homebrew","A_Id":57493345,"CreationDate":"2019-08-14T10:42:00.000","Title":"Two separate path for python when I use which python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"All of my previous code runs well. \nIt is only when I try to set the index to a particular column as the code below shows, that I run into an error. \nHonestly - this same method has worked before and I have not been able to find any other method to do the same thing. \ndf.set_index=(\"Neighbourhood\",inplace=True)\n\u200b\nError message: \nFile \"\", line 1\n    df.set_index=(\"Neighbourhood\",inplace=True)\n                                         ^\nSyntaxError: invalid syntax","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":499,"Q_Id":57493320,"Users Score":1,"Answer":"set_index is a function, you need to call it.\ntry df.set_index(\"Neighbourhood\",inplace=True) (without the =)","Q_Score":1,"Tags":"python,python-3.x,indexing,methods","A_Id":57493372,"CreationDate":"2019-08-14T10:55:00.000","Title":"df.set_index=(\"Neighbourhood\",inplace=True) giving me SyntaxError: invalid syntax","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"There are so many documentation about running OpenEDX on Ubuntu, but there is not any clear documentation how to run OpenEDX on CentOS specially with cPanel.\nAnyone can help me regarding this case?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":353,"Q_Id":57495379,"Users Score":0,"Answer":"I took \"tutor\" distribution which is in docker form, so it just ran smoothly over CentOS 7 of mine.","Q_Score":0,"Tags":"python,django,centos,cpanel,openedx","A_Id":62251687,"CreationDate":"2019-08-14T13:08:00.000","Title":"How to run OpenEDX on Centos 7 with cPanel","Data Science and Machine Learning":0,"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 jedi and more specifically deoplete-jedi in neovim and I wonder if I should install it in every project as a dependency or if I can let jedi reside in the same python environment as neovim uses (and set the setting to tell deoplete-jedi where to look)\nIt seems wasteful to have to install it in ever project but then again IDK how it would find my project environment from within the neovim environment either.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":469,"Q_Id":57497539,"Users Score":2,"Answer":"If by the word \"project\"you mean Python virtual environments then yes, you have to install every program and every library that you use to every virtualenv separately. flake8, pytest, jedi, whatever. Python virtual environments are intended to protect one set of libraries from the other so that you could install different sets of libraries and even different versions of libraries. The price is that you have to duplicate programs\/libraries that are used often.\nThere is a way to connect a virtualenv to the globally installed packages but IMO that brings more harm than good.","Q_Score":0,"Tags":"python,vim,neovim,python-jedi","A_Id":57499070,"CreationDate":"2019-08-14T15:13:00.000","Title":"should jedi be install in every python project environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wish to do the following: \nfrom aienvs.Sumo.SumoGymAdapter import SumoGymAdapter\nbut python goes to the following path and imports it:\n\/home\/azlaan\/.local\/lib\/python3.6\/site-packages\/aienvs\/Sumo\nI don't want it to import from the sites packages but from this directory:\n\/home\/azlaan\/..\/..\/aienvs\/aienvs\/Sumo\nI added inside the .bashrc the pythonpath as follows:\nexport PYTHONPATH=\"\/home\/azlaan\/PycharmProjects\/otherprojects\/aienvs:$PYTHONPATH\"\nThere is also another PYTHONPATH defined before this line in the bashrc file, I dont know if it affects it or not.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":429,"Q_Id":57498199,"Users Score":0,"Answer":"Python scans the paths present under sys.path list to import the modules.\nBy default site-packages path will be present under sys.path list and since your module is present under site-packages directory, python will import the module from here.\nIf you want to import from \/home\/azlaan\/..\/..\/aienvs\/aienvs\/Sumo, insert this path to sys.path list at the 0th index. Add below lines to your script, this should make it work.\nimport sys\nsys.path.insert(0, \"\/home\/azlaan\/..\/..\/aienvs\/aienvs\/Sumo\")\nfrom SumoGymAdapter import SumoGymAdapter","Q_Score":0,"Tags":"python-3.x,import,python-import,pythonpath","A_Id":57563325,"CreationDate":"2019-08-14T15:56:00.000","Title":"How to prevent Python from looking into the site packages for a 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 trying to write a script in python that will modify files and folders in a sharepoint site. Based off what I've read online about working with sharepoint using python, I tried to install and import the \"sharepoint\" and \"sharepy\" modules.\nI used \"pip install sharepoint\" and \"pip install sharepy\" in the command prompt to install the packages, and then in my script used these lines to import the packages:\nimport sharepoint\nimport sharepy\nMultiple IDE's don't recognize the packages (in Visual Studio, the error says \"No module named 'sharepoint'\") and I can't use their libraries to complete my code. The modules in question are present in the same subfolder as other modules that do successfully import, so I'm not really understanding the problem here. What could be causing these libraries to not import?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":232,"Q_Id":57502060,"Users Score":0,"Answer":"in visual studio code change python path to where you installed python","Q_Score":0,"Tags":"python,sharepoint","A_Id":59728424,"CreationDate":"2019-08-14T21:06:00.000","Title":"\"sharepoint\" and \"sharepy\" packages unable to import","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have read about .py and .ipy, also the difference between python, ipython and notebook. \nBut the question is: what is the real difference between .py and .ipynb file? \nIs .ipynb file just more convenient to be run on jupyter notebook, or anything more?   I am wondering because I am thinking about which format to be used for publishing on GitHub. \nThanks","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":32616,"Q_Id":57502484,"Users Score":14,"Answer":".py is a regular python file. It's plain text and contains just your code.\n.ipynb is a python notebook and it contains the notebook code, the execution results and other internal settings in a specific format. You can just run .ipynb on the jupyter environment.\nBetter way to understand the difference: open each file using a regular text editor like notepad (on Windows) or gedit (on Linux).\nSave on git the .ipynb if you want to show the results of your script for didatic purposes, for example. But if you are going to run your code on a server, just save the .py","Q_Score":18,"Tags":"python","A_Id":57502539,"CreationDate":"2019-08-14T21:48:00.000","Title":"What is the difference between a .py file and .ipynb file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have read about .py and .ipy, also the difference between python, ipython and notebook. \nBut the question is: what is the real difference between .py and .ipynb file? \nIs .ipynb file just more convenient to be run on jupyter notebook, or anything more?   I am wondering because I am thinking about which format to be used for publishing on GitHub. \nThanks","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":32616,"Q_Id":57502484,"Users Score":2,"Answer":"py means PYthon\nipynb means Interactive PYthon NoteBook - which is now known as Jupyter notebook.\nThe latter one is merely a Python script with descriptive contents - you describe what your data is doing by means of Python script and some funny texts. That's pretty much it - and also, you need a specific editor e.g. PyCharm or Google Collab to open and run it.","Q_Score":18,"Tags":"python","A_Id":67679252,"CreationDate":"2019-08-14T21:48:00.000","Title":"What is the difference between a .py file and .ipynb file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I attempted to do import segmentation_models as sm, but I got an error saying efficientnet was not found. So I then did pip install efficientnet and tried it again. I now get ModuleNotFoundError: no module named efficientnet.tfkeras, even though Keras is installed as I'm able to do from keras.models import * or anything else with Keras\nhow can I get rid of this error?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10143,"Q_Id":57503473,"Users Score":6,"Answer":"To install segmentation-models use the following command: pip install git+https:\/\/github.com\/qubvel\/segmentation_models","Q_Score":7,"Tags":"python,keras","A_Id":57539079,"CreationDate":"2019-08-15T00:11:00.000","Title":"ModuleNotFoundError: no module named efficientnet.tfkeras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The question is really simple:\nI have a python package installed using pip3 and I'd like to tweak it a little to perform some computations. I've read (and it seems logical) that is very discouraged to not to edit the installed modules. Thus, how can I do this once I downloaded the whole project folder to my computer? Is there any way to, once edited this source code install it with another name? How can I avoid mixing things up? \nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":999,"Q_Id":57504520,"Users Score":0,"Answer":"You can install the package from its source code, instead of PyPi. \n\nDownload the source code - do a git clone <package-git-url> of the package\nInstead of pip install <package>, install with pip install -e <package-directory-path>\nChange code in the source code, and it will be picked up automatically.","Q_Score":1,"Tags":"python,package","A_Id":57504585,"CreationDate":"2019-08-15T03:25:00.000","Title":"Editing a python package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to set up Keras in order to run models using my GPU. I have a Radeon RX580 and am running Windows 10.\nI saw realized that CUDA only supports NVIDIA GPUs and was having difficulty finding a way to get my code to run on the GPU. I tried downloading and setting up plaidml but afterwards from tensorflow.python.client import device_lib\nprint(device_lib.list_local_devices()) \nonly printed that I was running on a CPU and there was not a GPU available even though the plaidml setup was a success. I have read that PyOpenCl is needed but have not gotten a  clear answer as to why or to what capacity. Does anyone know how to set up this AMD GPU to work properly? any help would be much appreciated. Thank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":435,"Q_Id":57504746,"Users Score":0,"Answer":"To the best of my knowledge, PlaidML was not working because I did not have the required prerequisites such as OpenCL. Once I downloaded the Visual Studio C++ build tools in order to install PyopenCL from a .whl file. This seemed to resolve the issue","Q_Score":1,"Tags":"python-3.x,tensorflow,keras,gpu,amd","A_Id":57529064,"CreationDate":"2019-08-15T04:06:00.000","Title":"Setting up keras and tensoflow to operate with AMD GPU","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am in the process of setting up a process driven using Python scripts. The script performs a SVN checkout of a project and then creates a tag\/release.\nHowever the service account does not have access to certain portions of the Subversion repository. \nProblem: When a tag\/release is created for a check-out with the subversion external pinned, what i observe is that the tag gets created without throwing up any errors. However performing further operations on the created tag\/release, I observe that due to errors in getting all the externals the process fails. \nThe problem is visible as \"External failed\" with a set of reasons when i try to do the checkout using TortoiseSVN.\nSolution Requested: Is there a method to verify the existence(or permissions to access) of all the defined svn:externals before creation of the tag\/release?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":57507264,"Users Score":0,"Answer":"When a tag\/release is created for a check-out with the subversion external pinned\n\nI suppose, reason for further errors in not PEG-revisions in definitions, but relative paths, which become invalid after changing location of destination on tagging (TBT!)\nAnyway, you can:\n\nget the whole list of externals for any tree by calling something like svn propget svn:externals --recursive <ROOT OF TREE>\ncheck access for every external resource by calling (and checking results, not exit-code) svn ls <URL> for external directories or svn cat <URL> for external files","Q_Score":1,"Tags":"python-3.x,svn","A_Id":57509917,"CreationDate":"2019-08-15T09:01:00.000","Title":"Verification of the existence of defined SVN:Externals using python scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get a simple task request to perform a classification to predict classes i.e between 'Good' and 'Bad' customers. The problem is, recommendation is needed on suitable variables' values for those customers with 'Bad' prediction, so that they can take action to improve their profile. Examples of variable are 'Purchase Score' and 'Purchase Frequency'. Means that, these customers need to improve on these scores so that the prediction output can be obtained as 'Good' customers.\nIn this problem, when the optimized variables are input back into the classification problem, it needs to output 'Good' label instead of 'Bad' label.\nI've searched through the optimization methods such as scipy.optimize and Genetic Algorithms, but from my understanding, the optimized variables are for a set continuous value target instead of a class target. What technique can I use to achieve the optimization and recommendation part for a class prediction?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":57507740,"Users Score":0,"Answer":"What I would do in this case is to use a finite-differences gradient approach to solve the problem. For that, you can follow the next steps:\n1) Select a customer with \"Bad\" prediction, increase and decrease their variables one by one a little bit and check the prediction. \n2) That way you'll which sign in each variable causes the probability of \"Good\" to go up. \n3) Once you have it, move a bit all the variables in the direction of improvement\n4) Repeat from 1) until convergence.\nBTW this is the way Excel Solver works.","Q_Score":0,"Tags":"python,optimization,classification","A_Id":57507841,"CreationDate":"2019-08-15T09:40:00.000","Title":"What is the suitable technique for discrete classification and variable optimization problem?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Fallowing the freecodecamp's django tutorial I'm stack on the very beginning - I can't set up virtualenv. Everything goes great until it's time to make final step - activate virtualenv and download Django. \nI'm working on Windows 10, and tried a lot of ways to solve it. Everything ends up with to results, but first things first. Here is what i did:\n\nRan powershell as administrator and set up ExecutionsPolicy as unrestricted\nCreate new folder called 'Dev'\nInside Dev created another folder for project with virtualenv - everything by command 'virtualenv name of the folder\nTried to activate it by \"name_of_project's_folder\\Scripts\\activate\"\n\nAfter this I'm getting error which says that I must \"source this script\". I tried to make path to the Scripts folder and type only activate but it doesn't work. When I tried to type \"name_of_project's_folder\\Scripts\\activate\" but with \".bat\" added on the end, nothing happens. Like, literally nothing. \nI really hope for making this work because I'm slowly getting frustrated coz of tons of research I made today nad a lot of blind tries to solve this. Python was downloaded via powershell and pip if it's important.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":57513680,"Users Score":0,"Answer":"What about project_folder\\Scripts\\activate.ps1? Or you can just use cmd instead of powershell.","Q_Score":0,"Tags":"python,django,windows,virtualenv","A_Id":57513792,"CreationDate":"2019-08-15T17:25:00.000","Title":"Can't set virtualenv - problem with source activation.ps1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'd like to build a GUI for a few Python functions I've written that pull data from MS SQL Server. My boss wants me to share the magic of Python & SQL with the rest of the team, without them having to learn any coding.\nI've decided to go down the route of using Flask to create a webapp and creating an executable file using pyinstaller. I'd like it to work similarly to Jupyter Notebook, where you click on the file and it opens the notebook in your browser.\nI was able to hack together some code to get a working prototype of the GUI. The issue is I don't know how to deploy it. I need the GUI\/Webapp to only run on the local computer for the user I sent the file to, and I don't want it accessible via the internet (because of proprietary company data, security issues, etc). \nThe only documentation I've been able to find for deploying Flask is going the routine route of a web server. \nSo the question is, can anyone provide any guidance on how to deploy my GUI WebApp so that it's only available to the user who has the file, and not on the world wide web?\nThank you!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1022,"Q_Id":57515167,"Users Score":0,"Answer":"Unfortunately, you do not have control over a give users computer. \nYou are using flask, so your application is a web application which will be exposing your data to some port. I believe the default flask port is 5000.\nRegardless, if your user opens the given port in their firewall, and this is also open on whatever router you are connected to, then your application will be publicly visible.\nThere is nothing that you can do from your python application code to prevent this.\nHaving said all of that, if you are running on 5000, it is highly unlikely your user will have this port publicly exposed. If you are running on port 80 or 8080, then the chances are higher that you might be exposing something.\nA follow up question would be where is the database your web app is connecting to? Is it also on your users machine? If not, and your web app can connect to it regardless of whose machine you run it on, I would be more concerned about your DB being publicly exposed.","Q_Score":0,"Tags":"python,user-interface,flask,web-applications","A_Id":57515311,"CreationDate":"2019-08-15T19:33:00.000","Title":"How to deploy flask GUI web application only locally with exe file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'd like to build a GUI for a few Python functions I've written that pull data from MS SQL Server. My boss wants me to share the magic of Python & SQL with the rest of the team, without them having to learn any coding.\nI've decided to go down the route of using Flask to create a webapp and creating an executable file using pyinstaller. I'd like it to work similarly to Jupyter Notebook, where you click on the file and it opens the notebook in your browser.\nI was able to hack together some code to get a working prototype of the GUI. The issue is I don't know how to deploy it. I need the GUI\/Webapp to only run on the local computer for the user I sent the file to, and I don't want it accessible via the internet (because of proprietary company data, security issues, etc). \nThe only documentation I've been able to find for deploying Flask is going the routine route of a web server. \nSo the question is, can anyone provide any guidance on how to deploy my GUI WebApp so that it's only available to the user who has the file, and not on the world wide web?\nThank you!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1022,"Q_Id":57515167,"Users Score":1,"Answer":"So, a few assumptions-- since you're a business and you're rocking a SQLServer-- you likely have Active Directory, and the computers that you care to access this app are all hooked into that domain (so, in reality, you, or your system admin does have full control over those computers).\nAlso, the primary function of the app is to access a SQLServer to populate itself with data before doing something with that data.  If you're deploying that app, I'm guessing you're probably also including the SQLServer login details along with it.\nWith that in mind, I would just serve the Flask app on the network on it's own machine (maybe even the SQLServer machine if you have the choice), and then either implement security within the app that feeds off AD to authenticate, or just have a simple user\/pass authentication you can distribute to users.  By default random computers online aren't going to be able to access that app unless you've set your firewalls to deliberately route WAN traffic to it.\nThat way, you control the Flask server-- updates only have to occur at one point, making development easier, and users simply have to open up a link in an email you send, or a shortcut you leave on their desktop.","Q_Score":0,"Tags":"python,user-interface,flask,web-applications","A_Id":57515525,"CreationDate":"2019-08-15T19:33:00.000","Title":"How to deploy flask GUI web application only locally with exe file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to send multiple, delayed responses from the webhook written in python, once an intent is been triggered by the user. First response I want immediately after triggering the intent and another response I want after some processing to be performed on top of the user utterance.\nFor example:\n\nUser : I want my account balance.\nBOT : Please tell your account number for details.\nUser : my account number is 218497234.\nBOT : Hold-on a bit we are fetching your details.\nBOT : Welcome John, your account balance is $70000.\n\nIn the above example, this is a bank-bot, which replies to user queries. Currently fetching-up account balance for a user supplying account number. The last two responses from the BOT are from the webhook when say \"account_balance_check\" intent is been triggered. First response is immediate, asking the user to be patient and wait for the account details , while the second response is after fetching the account details from a db using account number.\nAnother way could be to trigger response from the bot, without utterance from the user. In the above case, is there anyway, bot itself can send response to user after telling him to wait? Please note that after telling user to wait, we don't want user utterance to trigger second response.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":331,"Q_Id":57522331,"Users Score":1,"Answer":"Unfortunately, you cannot do that in Dialogflow because once you send the response then your agent will not be able to send the response without any user input or event call.\nHere is an answer if your process does not take a long time. Once you get the user request, send them the waiting message with the \"OK\" suggestion. Once the user clicks on the suggestion, you can show the response. Also, process the request with some API and save your data in a common file that you can access through both API and agent and then show the response to the user from the file.","Q_Score":2,"Tags":"python,dialogflow-es,dialogflow-es-fulfillment","A_Id":57523379,"CreationDate":"2019-08-16T09:40:00.000","Title":"How to send multiple delayed responses from Python Webhook once an intent is been triggered?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use CP-SAT solver with some variables: x,y. I want to maximise an objective function of the form x**2-y*x with some constraints. I'm getting\n\nTypeError: unsupported operand type(s) for ** or pow(): 'IntVar' and\n  'int'\n\nerror messages. Am I correct in assuming I cannot use nonlinear objective function for CP-SAT, as I couldn't find any documentation or examples that did employ nonlinear objectives? Or is there some way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":671,"Q_Id":57524316,"Users Score":3,"Answer":"You have to create an intermediate variable using AddMultiplicationEquality(x2, [x, x])","Q_Score":1,"Tags":"python,or-tools,cp-sat-solver","A_Id":57524523,"CreationDate":"2019-08-16T12:02:00.000","Title":"Using CP-SAT Solver for non-linear objective function","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 see that the hovermode attribute in layout has options for x or y, but is it possible to use an arbitrary dataframe column? instead?\nFor example, I'm plotting precision-recall curves. The x-axis is recall, and the y-axis is precision. The independent variable is a detection threshold value (with range of np.linspace(0,1.0,101)) with a column in my dataframe called threshold. When I hover over a precision-recall point, what I'm interested in is points on other curves with the same detection threshold value. So can I instead hover on this column?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":544,"Q_Id":57525950,"Users Score":0,"Answer":"No, there\u2019s no feature for that at the moment. You could consider a second set of \u201ciso-threshold\u201d curves to see this kind of thing perhaps?","Q_Score":0,"Tags":"python,hover,plotly,plotly-python,plotly-express","A_Id":57528483,"CreationDate":"2019-08-16T13:58:00.000","Title":"Plotly Express hovermode with arbitrary column","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a conda environment named AAA with python 2.7 long ago and I want to update the python to 3.6 without any change of other packages in AAA. I try conda install python=3.6 in AAA, but all packages were emptied. What should I do to solve it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":627,"Q_Id":57535355,"Users Score":0,"Answer":"you'll have to reinstall packages for python 3.7. So it's better way to create new venv under 3.7. you can you pip freeze to get the list of installed packages and put it into requirements.txt file. then use it with pip3 install -r requirements.txt command. This will install them\nmore to that there's pip3 specially for python3.* which installs compatible packages.\nBTW be aware that python2 code is not compatible with python3","Q_Score":0,"Tags":"python,anaconda,conda","A_Id":57535405,"CreationDate":"2019-08-17T10:15:00.000","Title":"How to replace python 2.7 to 3.6 in a conda environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need a function like:\nstorepdf(pdf, path)\npdf is a SpooledTemporaryFile (was a pdf before processing) and path the path, where I want to save this file as .pdf in directory.\nHow can I do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":613,"Q_Id":57535766,"Users Score":0,"Answer":"Okay I used PyPDF2, read the tempfile and wrote it into a new created Pdf, that worked for me.","Q_Score":0,"Tags":"python,python-3.x,file,pdf,temporary-files","A_Id":57535977,"CreationDate":"2019-08-17T11:15:00.000","Title":"Save SpooledTemporaryFile on disk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python, we have two widely used methods for taking user input. First input() method and second, readline() method defined as sys.stdin.readline(). I would like to know if there are any situations when input() method is preferred over readline() method.\nAs I understand, readline() is faster than input(). Both of these return string value and we have to typecast them according to our needs. There is also a readlines() method to read user inputs on multiple lines. Is it better to use readlines() when reading multiple lines from user?\ninput() method does not require any import, where as readline() requires an import of sys.stdin. Still input() is slower. Does this mean time required for importing is negligible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":57537890,"Users Score":2,"Answer":"TLDR Speed is not a factor.\nIf your program is designed to read data from standard input, the like of a Unix filter, you won't use input but you will use the methods of sys.stdin, exactly because you have different methods to match the data flow of your program.\nOn the other hand, if your program is designed to interact with a user then input is clearly the way to go. Because the speed of the program is not the infinitesimal difference in speed of the two calls but the speed of the user interaction and the extra convenience provided by the optional prompt string is a very strong argument in favour of input.","Q_Score":0,"Tags":"python,input,stdin,readline,readlines","A_Id":57538548,"CreationDate":"2019-08-17T16:07:00.000","Title":"Is there any situation when input() is preferred over sys.stdin.readline()?","Data 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 debug (and get an understanding of what is happening) a Python script that runs on a Raspberry Pi and uses Pygatt to communicate with a BLE peripheral device. I am trying to make it work using Visual Studio Code (because I use it for JavaScript) on a Linux Mint PC. My Python experience is minimal.\nThe script works fine on the Linux Mint PC with a CSR 4.0 dongle. I open a terminal and enter:\n$ \/usr\/local\/bin\/python3.6 -i \/home\/rob\/python-test\/BLETestTool.py\nThe script runs, sets up the BLE adapter, and I get the >>> prompt. From there I can issue commands to connect and communicate with the device. The key to this is the \"-i\" argument. If I leave it out, the script just sets up the BLE adapter, which flashes a bit, and then terminates.\nWhen I try to debug using VS Code the script starts without the \"-i\" argument and terminates. I have tried numerous settings in launch.json and I have been searching for hours.\nIs it possible to invoke the -i argument when debugging Python in VS Code, or any other IDE? Alternatively, is there an alternative way to get the interactive command line experience working?\nAny clues would be greatly appreciated.\nThanks in advance,\nRob","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":207,"Q_Id":57538204,"Users Score":0,"Answer":"The -i argument tells Python to exit into the REPL when the script is done running. It doesn't make sense to do that with the debugger. Instead, set a breakpoint in the script that gets hit before it exits. Then if you need to do interactive exploration you can use the debug console.","Q_Score":2,"Tags":"python,debugging,command-line,visual-studio-code","A_Id":57564723,"CreationDate":"2019-08-17T16:49:00.000","Title":"Debugging Python with an interactive 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having an image dataset each image is of dimensions=(2048,1536).In ImageDataGenerator to fetch data from the directory, I have used the same target size i.e (2048,1536) but while making Sequential model first layer, what input shape should I have to use?? Will it be same as (2048,1536) or I can take any random shape like (224,224).","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":347,"Q_Id":57538810,"Users Score":1,"Answer":"I would resize first the images with cv2.resize(). Do you really need all the information from such a big image?\nFor a sequential Model it follows for example:\n\nmodel = models.Sequential()\nmodel.add(layers.Conv2D(32,(3,3), activation='relu', input_shape = (height,width, ndim)))\n...,\nwhere height and width denote your input image dimensions and ndim = 1 for greyscale and ndim = 3 for colored images.","Q_Score":2,"Tags":"python,keras,deep-learning,dataset","A_Id":57539279,"CreationDate":"2019-08-17T18:15:00.000","Title":"What input shape should I take in first layer of Sequential model when the dimensions of the images are (2048*1536)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using some classes like someclass and doing someclass. will bring up a bunch of methods, in pycharm the little icon to the left is an 'm'.\nImporting random and using that gives me little 'v's. Apparently those stand for variables but they're methods\/functions?\nFor example random.choice()","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":322,"Q_Id":57541037,"Users Score":2,"Answer":"'v' does mean it's a variable, and this is because the random.choice is a variable that holds the real function, which you can see is really _inst.choice (if you hover on choice in random.choice and clicking while pressing ctrl)","Q_Score":1,"Tags":"python,variables,methods,pycharm","A_Id":57541124,"CreationDate":"2019-08-18T01:26:00.000","Title":"In pycharm what does the V mean?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My tensorflow  only prints out the line:\nI tensorflow\/stream_executor\/dso_loader.cc:152] successfully opened CUDA library libcublas.so.10.0 locally when running.\nTensorflow logs on the net has lots of other libraries being loaded like libcudnn.\nAs I think my installation performance is not optimal, I am trying to find out if it is because of this. Any help will be appreciated!\nmy tf is 1.13.1\nNVIDIA Driver Version: 418.67\nCUDA Version: 10.1  (I have also 10.0 installed. can this be the problem?)","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":3774,"Q_Id":57541567,"Users Score":-1,"Answer":"Actually i always rely on a stable setup. And i tried most of the tf - cuda - cudnn versions. But most stable was tf 1.9.0 , CUDA 9.0, Cudnn 7 for me. Used it for too long without a problem. You should give it a try if it suits you.","Q_Score":6,"Tags":"python,tensorflow","A_Id":57784170,"CreationDate":"2019-08-18T04:05:00.000","Title":"Tensorflow shows only \"successfully opened CUDA library libcublas.so.10.0 locally\" and nothing about cudnn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a program which takes the explanation of a German idiom from Wikipedia, for example, and catches the idiom, its meaning and any additional information. \nExample, the bolded text is supposed to be matched:\n\n** Sich wie ein Backfisch benehmen \u2013 albern bzw. unreif sein. Zur Etymologie des Wortes \u201eBackfisch\u201c f\u00fcr unreife M\u00e4dchen siehe dort. (Sprichwort um 1900: \u201eMit 14 Jahr\u2019n und sieben Wochen ist der Backfisch ausgekrochen.\u201c[6]).\n\nBasically, the phrase starts after the dash - and ends before the first full stop, i.e. it is only one sentence. However, i want to skip abbreviations such as bzw., z. B., u. A., etc, since they do not mark the end of the sentence.\nI am unsure how to skip the word, but still match it. Also, as I said, I want to skip frequently used abbreviations in German such as the aforementioned ones in italics.\nI already tried matching a structure beginning with - and ending with ., whereas the . should not be preceded by bzw. However, I did not succeed in doing that.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":201,"Q_Id":57546413,"Users Score":1,"Answer":"That is a problem in German, using abbreviations, I encountered it when working on German texts, too. Did you try to use a German parser, in order to cut your text in phrases\/sentences ? Try one, it may help. In Python you have NLTK and also Stanford, for example.\nIn English or French one may say that the end of a phrase is marked by a point followed by space and a capital letter. However this will not work for German, as the Nouns are capitalized.  \nOn the other hand, as you mention \"frequently used abbreviations\" -- if they are so frequent, why not collecting them in a dictionary and use them in order to skip them in the text ?","Q_Score":2,"Tags":"python,regex,python-3.x","A_Id":57547412,"CreationDate":"2019-08-18T16:27:00.000","Title":"How to 'skip' specific words using regex in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to work with opencv in my xamarin application .\nI found that if I use openCV directly in xamarin , the size of the app will be huge .\nthe best solution I found for this is to use the openCV in python script then to host the python script in a Web Server and access it by calling an API from xamarin .\nI have no idea how to do this .\nany help please ?\nand is there is a better solutions ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":176,"Q_Id":57546711,"Users Score":1,"Answer":"You can create your web server using Flask or Django. Flask is a simple micro framework whereas Django is a more advanced MVC like framework.","Q_Score":0,"Tags":"python,api,opencv,xamarin,webserver","A_Id":57546829,"CreationDate":"2019-08-18T17:11:00.000","Title":"how to host python script in a Web Server and access it by calling an API from xamarin application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm connected to a Raspberry Pi running Raspbian lite, using PuTTY with SSH. To execute a Python script, I'm navigating to the script's directory and using python3 scriptname.py, (this script is always running, unless being modified) after doing this, all I can see is the script's console log, and I don't think I'm able to do anything else with the Pi, unless if I stop the scripts execution.\nIs there anyway that I can send that process to the background, and continue to use the interface to do other things","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":283,"Q_Id":57547605,"Users Score":0,"Answer":"I appreciate the different solutions. I don't know why it didn't occur to me that opening a new terminal session would truly act as a new session, I would've guessed it would essentially clone the output, but thanks Mark. Thanks coderasha, I might use Linux Screen sometime. Also, thanks Dinko, I wasn't aware I could append executions using &!","Q_Score":0,"Tags":"python,raspberry-pi,raspbian","A_Id":57547830,"CreationDate":"2019-08-18T19:12:00.000","Title":"How can I have a Python script run in the background. I'm using terminal and 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":"Is there a way, short of code generation, to generate a constant during build\/install which can be referenced at run-time?\nSpecifically, I'd like to retain the path the package was built out of, but I suppose there might be a more general answer.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":130,"Q_Id":57548506,"Users Score":0,"Answer":"Is it possible? Yes.\nArrange for setup.py to write const.txt,\nship that as part of your package,\nand open() the file to read it in your constructor.","Q_Score":2,"Tags":"python,python-3.x,setup.py,distutils","A_Id":57557488,"CreationDate":"2019-08-18T21:28:00.000","Title":"Generate constant during setup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing a discord bot using discord.py (rewrite branch) for my servers and I need to invite the bot to multiple servers and use it simultaneously. \nMy question is: \nDo I need to set up a new thread for every server or does the bot queue events and handle them one by one? if it does queue them, should I just use that or use separate threads?\nSorry if this is a noobish question but I'm fairly new to discord.py and I don't really understand how it works just yet.\nThanks for reading","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":8081,"Q_Id":57550170,"Users Score":-1,"Answer":"Multiprocesses, threads or queues can all be used to approach this issue each with their respective advantages and disadvantages . Personally I would use threads as the events that need to take place on each server are independent of each other mostly.","Q_Score":3,"Tags":"python,discord.py-rewrite","A_Id":57550391,"CreationDate":"2019-08-19T03:32:00.000","Title":"How does a discord bot handle events from multiple 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 installed pyttsx3 package at the same environment that my .py file in Visual Studio Community 2019, but it is not recognized by using \"import\". \nI\u00b4ve tried other two different packages, but the problem remains. (environment: Python 3.6 (64-bit), Visual Studio Community 2019 )\nimport pyttsx3\nengine = pyttsx3.init()\nengine.say(\"Hi there!\")\nengine.runAndWait()\n\"unresolved import pyttsx3\" message showed.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":341,"Q_Id":57551541,"Users Score":0,"Answer":"The error message remains, but now the code is running. It make no sense!","Q_Score":1,"Tags":"python-3.x,visual-studio,python-import,python-packaging","A_Id":57551570,"CreationDate":"2019-08-19T06:36:00.000","Title":"Why Visual Studio doesnt recognize the installed package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use the same log file in multiple processes. But the processes aren't started with multiprocessing, so they have nothing shared.\nWhile googling around, I have realised that I should make a LogHandler which receives the messages through a queue. The LogHandler then is the only process which writes to the file. But the problem is to share the queue with the other processes.\nHow can I do that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":100,"Q_Id":57552537,"Users Score":0,"Answer":"You can create a lock file and each process check its value before reaching the log file.\nFor example : \nlockfile.txt write \"lock: 0\"\nAnd first process comes read is it 0 or 1. If it is 0, write 1 and access log file. Other processes will wait until seeing 0 in lock file.","Q_Score":0,"Tags":"python,queue","A_Id":57552695,"CreationDate":"2019-08-19T07:55:00.000","Title":"Python: Share queue between completely different processes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a list of date time strings like this.\n16-Aug-2019\nI want to convert the string to 2019-08-01 this date format, and I have tried on this code , but it's getting me an error.\nformatd_date = datetime.strptime(formatd_date, '%y-%m-%d')\nValueError: time data 'As-of' does not match format '%y-%m-%d'\nIf any can help, it will be huge thank.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":236,"Q_Id":57554800,"Users Score":1,"Answer":"Just fails because %y is 2-digit year. Use %Y for 4-digit year.","Q_Score":0,"Tags":"python,python-2.7,datetime","A_Id":57555227,"CreationDate":"2019-08-19T10:21:00.000","Title":"string convert to date time in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to set up the virtual environment but when I type the command \".\\Scripts\\activate\", I get an error message \"You must 'source' this script\"","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":143,"Q_Id":57560003,"Users Score":2,"Answer":"Use source .\/Scripts\/activate to activate virtualenv","Q_Score":0,"Tags":"python","A_Id":57560089,"CreationDate":"2019-08-19T15:43:00.000","Title":"The command \".\\Scripts\\activate\" is not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why airflow falls with TypeError: can't pickle module objects when task returns kwargs with provide_context= True?\nBut when I do print kwargs in same task - then everything is ok.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2486,"Q_Id":57560813,"Users Score":1,"Answer":"The problem here is most likely something in the kwargs object. The error arises because when you return from an operator in airflow it is saved in the airflow database as part of the xcom set up. \nI would suggest you take a look at what's in your kwargs and figure out which items are \"module objects\" rather than more trivial data types. A simple way around the problem itself would be to only return the things you need to return, rather than the whole kwargs object.","Q_Score":2,"Tags":"python,airflow","A_Id":57576842,"CreationDate":"2019-08-19T16:40:00.000","Title":"Airflow falls with TypeError \"can't pickle module objects\" when task returns kwargs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"My software needs to install packages on arbitrary container images that have python 3.5+. The module must then be loadable by running python3 -c 'import my_module'.\nI plan to use python3 -m pip install my-package --user command to install the packages. The --user work around the containers where the active user is not root.\nUnfortunately I've vaguely heard about cases where the user directory where pip installs packages is not in PATH on some systems or something like that.\nWould that affect the ability to import the installed package?\nWhat command-line should I use to install packages reliably?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":57562066,"Users Score":0,"Answer":"as long as it's in your path such as .local\/bin or in .local or python PATH's you can run it as if it was in \/usr PATH","Q_Score":0,"Tags":"python,pip","A_Id":57562108,"CreationDate":"2019-08-19T18:21:00.000","Title":"Probability that package installed using pip install --user will be loadable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ive created a simple PyQT4 scraping program and had generated an exe of the program using pyinstaller-3.5. I have tested it locally and shared a zip archive with the end user. It was reported that upon launching the exe an error pops up stating that \n\n\"Windows cannot access the specified device, path, or file. You may not have appropriate permissions to access the item.\"\n\nI have made sure that this exe is able to run on Windows 7 and Windows 10 workstations, other than the workstation that the program was developed on. \nThis is a generic Windows error and possibly a common problem when it comes to  shipping exe applications. \nWhat are some known workarounds for this issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":398,"Q_Id":57565017,"Users Score":0,"Answer":"There is one scenario where you can run into permissions problems. If you use PyInstaller to create an MSI installer, it will try to install your program into %PROGRAMFILES% and the install directory will have limited write permissions. In this scenario, if your python program tries to do any writes, you will get permissions errors. You should be able to reproduce this problem by installing on your own machine.\nI have had this same problem with my own program, and I manually change the permissions on a config.ini file after install. This could probably be automated by a post install script that fires after MSI is finished doing its thing.","Q_Score":0,"Tags":"python,windows-10,exe,pyinstaller","A_Id":57565416,"CreationDate":"2019-08-19T23:26:00.000","Title":"Exe, created with PyInstaller 3.5, cannot run on end-user's computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python project which uses an open source package registered as a dependency in requirements.txt\nThe package has some deficiencies, so I forked it on Github and made some changes. Now I'd like to test out these changes by running my original project, but I'd like to use the now forked (updated) code for the package I'm depending on.\nThe project gets compiled into a Docker image; pip install is used to add the package into the project during the docker-compose build command. \nWhat are the standard methods of creating a docker image and running the project using the newly forked dependency, as opposed to the original one? Can requirements.txt be modified somehow or do I need to manually include it into the project? If the latter, how?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":57565886,"Users Score":0,"Answer":"you can use git+https:\/\/github.com\/.....\/your_forked_repo in your requirements.txt instead of typing Package==1.1.1","Q_Score":0,"Tags":"python,docker,docker-compose","A_Id":57567131,"CreationDate":"2019-08-20T02:11:00.000","Title":"Python: Reference forked project in requirements.txt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"iam new to cassandra,\ni want to do get query using cassandra python client? iam not able to escape special characters.can anyone help \nBelow is the query which iam trying, but getting syntax error\n\nSELECT pmid FROM chemical WHERE mentions=$$\n  N,N'-((1Z,3Z)-1,4-bis(4-methoxyphenyl)buta-1,3-diene-2,3-diyl)diformamide\n  $$ AND pmid=31134000 ALLOW FILTERING;\n\nit is giving me error\nError from server: code=2000 [Syntax error in CQL query] message=\"line 1:118 mismatched input '-' expecting ')' (...,source) VALUES ('be75372a-c311-11e9-ac2c-0a0df85af938','N,N'[-]...)\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":57567690,"Users Score":0,"Answer":"Based on the Syntax Provided as i see there is a Single quotes missing in your Query . \nSuggestion \nNote to use ALLOW FILTERING  as it will Scan your Table which will be a performance issue.","Q_Score":0,"Tags":"python,cassandra,cassandra-cluster","A_Id":57604403,"CreationDate":"2019-08-20T06:20:00.000","Title":"Not able to do escape query","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running the latest version of IntelliJ IDEA Community Edition and have Python 3.7 downloaded and installed.  The trouble is, my console with IntelliJ is only running Python 2.7.  I've tried installing\/uninstalling\/updating installation but the only Plug-in option with IntelliJ is Community Edition and this seems to be Python 2 .. anyway.  How am I able to load Python plug-in (if there is one) for IntelliJ?  I'm not able to import Pandas as a result and can't work through code .. \nDon't want to go through the route of copying and pasting modules from 3.7 to 2 if I don't need to or if it's going down a bad road so to speak.\nI've tried installing\/uninstalling\/updating installation but the only Plug-in option with IntelliJ is Community Edition and this seems to be Python 2 .. anyway.  How am I able to load Python plug-in (if there is one) for IntelliJ?  I'm not able to import Pandas as a result and can't work through code .. \nAs described above .. can't load the plug-in \nerror: module not found","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3219,"Q_Id":57569734,"Users Score":0,"Answer":"Please try these steps:\n\nOpen \"Project Structure | SDKs\"\nAdd new python SDK (choose\"System Interpreter\" and select installed Python 3 from the dropdpwn list)\nOpen \"Settings\/Preferences | Build... | Console | Python Console\" and select \"Use specified interpreter\"\n\nAfter that \"Tools | Python Console\" will run with Python 3","Q_Score":0,"Tags":"python,python-3.x,intellij-idea,plugins","A_Id":57571495,"CreationDate":"2019-08-20T08:38:00.000","Title":"Installing Python 3 Plugin for IntelliJ IDEA Community Edition","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are using selenium python to automate web application. To launch firefox browser, we need to download geckodriver and place it in \/usr\/bin. but, we found that linux version geckodriver is not compatible with Solaris os. whenever I am running selenium python to run code on solaris v5.11 , we got an error like \"Bad System call(core dumped)\"\nsolaris 11.4\npython 2.7.14\nselenium 3.141.0\ngeckodriver 0.24.0\nplease help to resolve the issue","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":57570736,"Users Score":1,"Answer":"Solaris & Linux use very different system calls, and binaries must be compiled specifically for each one - you cannot copy them across from one system to the other - so you will need to either compile geckodriver yourself or find a version already compiled for Solaris, not Linux.","Q_Score":0,"Tags":"python,selenium,solaris,selenium-firefoxdriver","A_Id":57576724,"CreationDate":"2019-08-20T09:37:00.000","Title":"Geckodriver for Solaris OS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm creating the parallelization of software that is doing a bunch of independent calculations so that the institute is not taking 6 hours to calculate one run. These results are saved in a list of arrays. The array length is static. This list is then dumped with pickle.dump(obj).\nThe difference is the single-threaded on is the size of 6.5 KiB and the multi-threaded one is 20,4 KiB\nFirstly:\nI did my research and yes you should not use pickle, but University is University. I also tested my multi-threaded implementation, I did that for the last days, I even compared a smaller sample by hand to be sure, so I'm not helped when you commend that I should check my multi-threaded implementation.\nNow what I did:\nFirst, of comparing all elements, between the single and multi-threaded created list, they are the same. Comparing the length, shape, sys.getsizeof(obj) they are the same.\nThen I had a look into the pickle.dump(obj), this chooses the protocol on its own so I tried to use the different protocols. I got different results, but not the smaller one I expected.\nLastly I tripe checked if I really dump only the list and yes only the list is dumped.\nAs written above one would expect the get the exact same dump file size for the exact same list, so why is this not happening?\nYes, I'm new here and don't get all the rules so please give proper feedback on how to improve the question.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":57572408,"Users Score":1,"Answer":"So the solution is rather trivial...\nI should have checked also the types of the elements in the arrays. During the coding part in the night I used numpy for partitioning the list with values for the calculation and forgot about it completely.\nWith a simple array.tolist() this problem was fixed.\nConclusion:\nEven in python check your types!","Q_Score":0,"Tags":"python,python-3.x,list,pickle","A_Id":57573600,"CreationDate":"2019-08-20T11:15:00.000","Title":"Pickle.dump(obj) dumps two lists that conatain exactly the same values but dump file has a diffrent size","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to span a tabWidget across the entire window in the second row instead of having it just in a single column\nI have already tried resizing both the table and the column with no changes. When I resize the column in row 2, it resizes every column which I don't want.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":132,"Q_Id":57577268,"Users Score":0,"Answer":"Solved myself. I created 2 QHBOXLayout(). One for each row that I had. Then created a QVBoxLayout() and then by using x.addLayout() I added my Horizontal Layouts to the vertical layout. Ex:\nhorLay01 = QtGui.QHBoxLayout()\nhorLay02 = QtGui.QHBoxLayout()\nvertLay01 = QtGui.QVBoxLayout()\nvertLay01.addLayout(horLay01)\nvertLay01.addWidget(tabs, 1)\nvertLay01.addLayout(horLay02)\nThis was able to create my even spaced top and bottom sections while spanning my QTabWidget() across the entire screen. Subsequently, It resizes the widgets based on screen space which is a plus.","Q_Score":0,"Tags":"python,python-3.x,pyqt,pyqt4","A_Id":57593995,"CreationDate":"2019-08-20T15:44:00.000","Title":"Span a widget over mutliple columns?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Wow, I'm thankful for all of the responses on this!  To clarify the data pattern does repeat.  Here is a sample:\nItem: some text Name: some other text Time recorded: hh:mm Time left: hh:mm \n other unrelated text some other unrelated text lots more text that is unrelated Item: some text Name: some other text Time recorded: hh:mm Time left: hh:mm  other unrelated text some other unrelated text lots more text that is unrelated Item: some text Name: some other text Time recorded: hh:mm Time left: hh:mm \n and so on and so on\nI am using Python 3.7 to parse input from a text file that is formatted like this sample:\nItem: some text Name: some other text Time recorded: hh:mm Time left: hh:mm and the pattern repeats, with other similar fields, through a few hundred pages.\nBecause there is a \":\" value in some of the values (i.e. hh:mm), I not sure how to use that as a delimiter between the key and the value. I need to obtain all of the values associated with \"Item\", \"Name\", and \"Time left\" and output all of the matching values to a CSV file (I have the output part working)\nAny suggestions? Thank you!\n(apologies, I asked this on Stack Exchange and it was deleted, I'm new at this)","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":93,"Q_Id":57579025,"Users Score":1,"Answer":"Use the ': ' (with a space) as a delimiter.","Q_Score":2,"Tags":"python,parsing","A_Id":57579093,"CreationDate":"2019-08-20T17:45:00.000","Title":"Parsing in Python where delimiter also appears in the data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Should I timestamp my data extracts?\nA few collegues an me work together on a python server to solve a data science related problem. I wrote a few functions to extract my data from my source data base and save it to the python server for further processing. Now I'm struggling with whether I should save the extract with a timestamp, the result being that every time I start my pipeline another extract is saved or omit the timestamp and overwrite the old extract. I read alot about data not needing the same kind of version control as code does and I don't really want to clutter the server with multiple, vastly redundant data extracts.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10,"Q_Id":57580194,"Users Score":0,"Answer":"save the extract with a timestamp, the result being that every time I start my pipeline another extract is saved or omit the timestamp and overwrite the old extract.\n\nIs the change of a feature over time important to your data science related problem? \n\nDo you have any metrics which could tell a story if measured over time? \nPerhaps you can store the delta since last data pull instead of redundant features (feature engineer on a different table). \n\nJust a couple of thoughts. Good luck :)","Q_Score":0,"Tags":"python,version-control,data-science,pipeline","A_Id":57580253,"CreationDate":"2019-08-20T19:13:00.000","Title":"Do data extracts need to be timestamped?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently helping with some NLP code and in the code we have to access a database to get the papers. I have fun the code successfully before but every time I try to run the code again I get the error sqlite3.DatabaseError: file is not a database. I am not sure what is happening here because the database is still in the same exact position and the path doesn't change. \nI've tried looking up this problem but haven't found similar issues. \nI am hoping that someone can explain what is happening here because I don't even know how to start with this issue because it runs once but not again.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":131,"Q_Id":57580912,"Users Score":0,"Answer":"I got the same issue. I have a program that print some information from my database but after running it again and again, I got an error that my database was unable to load.  For me I think it may be because I have tried to be connected to my database that this problem occurs.  And what I suggest you is to reboot your computer or to research the way of being connected several times to the database","Q_Score":0,"Tags":"python-3.x,sqlite","A_Id":57581507,"CreationDate":"2019-08-20T20:09:00.000","Title":"Getting error 'file is not a database' after already accessing the database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install superset in virtual environment and running in python3.6.\npip install superset\nThe installation failed with the below error message\nERROR: flask-jwt-extended 3.21.0 has requirement Flask>=1.0, but you'll have flask 0.12.4 which is incompatible.\nSo, I upgraded the flask by\npip install --upgrade flask\nwhich upgrade to the latest version.\nAfter upgrading flask, I again tried installing superset. This time I got the same error. \nNot only it complained about the flask but also the process uninstalled the flask.\nERROR: flask-jwt-extended 3.21.0 has requirement Flask>=1.0, but you'll have flask 0.12.4 which is incompatible.\n....\n  Found existing installation: Click 7.0\n    Uninstalling Click-7.0:\n      Successfully uninstalled Click-7.0\n  Running setup.py install for pycparser ... done\n  Found existing installation: Flask 1.1.1\n    Uninstalling Flask-1.1.1:\n      Successfully uninstalled Flask-1.1.1","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1350,"Q_Id":57581065,"Users Score":1,"Answer":"You'd want to try to first pip install --upgrade setuptools pip (this will update pip - Python's package installer)  and then pip install -r requirements.txt, which should install all packages needed for superset.","Q_Score":2,"Tags":"python,pip,apache-superset","A_Id":57773061,"CreationDate":"2019-08-20T20:23:00.000","Title":"Apache Superset virtual env installation issue with flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have Python 3.4, running on Windows 10 x64, trying to install pylint via pip: pip install pylint.\nWhen doing so, I get the following error: Microsoft Visual C++ 10.0 is required. Get it with \"Microsoft Windows SDK 7.1\": www.microsoft.com\/download\/details.aspx?id=8279\nHowever I already have:\n\nMicrosoft Visual C++ 2010 x64, Microsoft Visual C++ x86 both Redistributable\nMicrosoft Visual C++ 2013 x64, Microsoft Visual C++ x86 both Redistributable\nMicrosoft Visual C++ 2015 - 2019 x64, Redistributable\nMicrosoft Visual C++ 2017 x64, Microsoft Visual C++ 2017 x86 both Redistributable\n\nI saw some other posts with possible solutions that I've tried and did not seem to help to me - \n\nupdating setuptools and virtualenv\nDownloading the SDK given in the error\nAdd VS110COMNTOOLS, VS120COMNTOOLS, VS140COMNTOOLS env variables\n\nOf course, after every attempt I've rebooted my PC.\nWhat else could I try to fix this?\nIs it possible to install pylint without pip?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2702,"Q_Id":57581571,"Users Score":0,"Answer":"You could try installing Visual Studio Code and opening your project from there. From my experience, Visual Studio Code offers to install pylint (and other missing libraries) for you when it recognizes it's missing.","Q_Score":8,"Tags":"python,c++,visual-studio,pip","A_Id":57703772,"CreationDate":"2019-08-20T21:10:00.000","Title":"pip install error: Microsoft Visual C++ 10.0 is required","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A NaN of type decimal.Decimal causes:\n\nmath.isnan to return True\nnumpy.isnan to throw a TypeError exception.\npandas.isnull to return False\n\nWhat is the difference between math.isnan, numpy.isnan and pandas.isnull?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":1748,"Q_Id":57588107,"Users Score":3,"Answer":"The only difference between math.isnan and numpy.isnan is that \n\nnumpy.isnan can handle lists, arrays, tuples whereas \nmath.isnan can ONLY handle single integers or floats.\n\nHowever, I suggest using math.isnan when you just want to check if a number is nan because \n\nnumpy takes approximately 15MB of memory when importing it while\nmath takes only 0,2M of memory\n\nAs for pandas.isnull it returns True not only for nan but also for None python types and as numpy it can handle every structure of numbers. However, it is even more \"heavy\" than numpy.","Q_Score":2,"Tags":"python-3.x,pandas,numpy","A_Id":57588916,"CreationDate":"2019-08-21T09:05:00.000","Title":"What is the difference between math.isnan ,numpy.isnan and pandas.isnull in python 3?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the PyCharm you can run Virtualenv Environment -> New Environment\nWhat exactly does this command do? It creates new venv or virtualenv? And what is better to use for the project (Django)?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":46,"Q_Id":57588283,"Users Score":1,"Answer":"In PyCharm you create a project-specific isolated virtual environment and its purpose is to manage settings and dependencies of a particular project regardless of other Python projects.\nAccording to its website, Python 3.3+ versions use the 'venv' tool, instead of the third-party 'virtualenv. \nI would use virtual environment for any python project, because you can keep your dependencies seperate and contains everything needed for your project to execute successfully.","Q_Score":0,"Tags":"python-3.x,pycharm,virtualenv","A_Id":57588424,"CreationDate":"2019-08-21T09:15:00.000","Title":"Pycharm \"Virtualenv Environment -> New Environment\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"In the PyCharm you can run Virtualenv Environment -> New Environment\nWhat exactly does this command do? It creates new venv or virtualenv? And what is better to use for the project (Django)?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":46,"Q_Id":57588283,"Users Score":1,"Answer":"For my money, you're better of using Conda. The main reason being that Pip and Venv are Python specific package and environment management tools. Whereas Conda also looks after non-Python dependencies. Which can be very important for certain libraries.","Q_Score":0,"Tags":"python-3.x,pycharm,virtualenv","A_Id":57608749,"CreationDate":"2019-08-21T09:15:00.000","Title":"Pycharm \"Virtualenv Environment -> New Environment\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I recently followed a tutorial on web scraping, and as part of that tutorial, I had to execute (?) the script I had written in my command line.Now that script runs every hour and I don't know how to stop it.\nI want to stop the script from running. I have tried deleting the code, but the script still runs. What should I do?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":869,"Q_Id":57590672,"Users Score":1,"Answer":"I can't comment, but you must show us the script or part of the script so we can try to find out the problem or the video you were watching. Asking just a question without an example doesn't help us as much figure out the problem.\n\nIf you're using Flask, in the terminal or CMD you're running the script. Type in CTRL+C and it should stop the script.   OR set the debug to false eg. app.run(debug=False) turn that to False because sometimes that can make it run in background and look for updates even though the script was stopped. In conclusion: Try to type CTRL+C or if not set debug to False","Q_Score":0,"Tags":"python,command-line","A_Id":57590799,"CreationDate":"2019-08-21T11:32:00.000","Title":"How do I stop a Python script from running in my command line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I recently followed a tutorial on web scraping, and as part of that tutorial, I had to execute (?) the script I had written in my command line.Now that script runs every hour and I don't know how to stop it.\nI want to stop the script from running. I have tried deleting the code, but the script still runs. What should I do?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":869,"Q_Id":57590672,"Users Score":1,"Answer":"You can kill it from task manager.","Q_Score":0,"Tags":"python,command-line","A_Id":57590890,"CreationDate":"2019-08-21T11:32:00.000","Title":"How do I stop a Python script from running in my command line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So what I basically am trying to make is a program that asks user for file and displays absolute path of the program. For eg. If user enters 'Spotify' then I want to locate spotify.exe on the pc if It exists and print its absolute path.\nI wanted to make this for a personal assistant that I am working on.\nI previously tried \nos.system(input + '.exe')\nbut taking the eg of spotify only...it is not an internal file that will be recognised\u2026.please help.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":57591112,"Users Score":0,"Answer":"Have you tried\nos.path.abspath(file)","Q_Score":0,"Tags":"python,file,project","A_Id":57591188,"CreationDate":"2019-08-21T11:58:00.000","Title":"I want to make a program that takes file name from user and displays absolute path of the file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So what I basically am trying to make is a program that asks user for file and displays absolute path of the program. For eg. If user enters 'Spotify' then I want to locate spotify.exe on the pc if It exists and print its absolute path.\nI wanted to make this for a personal assistant that I am working on.\nI previously tried \nos.system(input + '.exe')\nbut taking the eg of spotify only...it is not an internal file that will be recognised\u2026.please help.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":43,"Q_Id":57591112,"Users Score":-1,"Answer":"If you are using Linux, you can use os.system('which spotify')","Q_Score":0,"Tags":"python,file,project","A_Id":57591191,"CreationDate":"2019-08-21T11:58:00.000","Title":"I want to make a program that takes file name from user and displays absolute path of the file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I use GridSearchCV to find the best parameters in the inner loop of my nested cross-validation. The 'inner winner' is found using GridSearchCV(scorer='balanced_accuracy'), so as I understand the documentation the model with the highest balanced accuracy on average in the inner folds is the 'best_estimator'. I don't understand what the different arguments for refit in GridSearchCV do in combination with the scorer argument. If refit is True, what scoring function will be used to estimate the performance of that 'inner winner' when refitted to the dataset? The same scoring function that was passed to scorer (so in my case 'balanced_accuracy')? Why can you pass also a string to refit? Does that mean that you can use different functions for 1.) finding the 'inner winner' and 2.) to estimate the performance of that 'inner winner' on the whole dataset?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3919,"Q_Id":57591311,"Users Score":7,"Answer":"When refit=True, sklearn uses entire training set to refit the model. So, there is no test data left to estimate the performance using any scorer function.\nIf you use multiple scorer in GridSearchCV, maybe f1_score or precision along with your balanced_accuracy, sklearn needs to know which one of those scorer to use to find the \"inner winner\" as you say. For example with KNN, f1_score might have best result with K=5, but accuracy might be highest for K=10. There is no way for sklearn to know which value of hyper-parameter K is the best.\nTo resolve that, you can pass one string scorer to refit to specify which of those scorer should ultimately decide best hyper-parameter. This best value will then be used to retrain or refit the model using full dataset. So, when you've got just one scorer, as your case seems to be, you don't have to worry about this. Simply refit=True will suffice.","Q_Score":5,"Tags":"python,scikit-learn,grid-search","A_Id":57593244,"CreationDate":"2019-08-21T12:09:00.000","Title":"Combination of GridSearchCV's refit and scorer unclear","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have survey data with about 100 columns for every individual. Based on certain criteria, for eg. a column contains info of whether a person reads comics and another column contains info of whether a person reads comics.\nI want to validate if the user has created clusters\/groups that are mutually exclusive.\neg. Group 1: Males with age 0-25 reading comics, Group 2: Males with age 20-25 reading comics as well as newspaper. In this case, I want to generate a warning that the groups are not mutually exclusive.\nOne (inefficient) way of doing is creating a list of individuals for every group and then finding intersection for every combination of groups. If there is intersection, the groups are not mutually exclusive and hence incorrect.\nWhat is an efficient way of doing this?\nOne (inefficient) way of doing is creating a list of individuals for every group and then finding intersection for every combination of groups. If there is intersection, the groups are not mutually exclusive and hence incorrect.\nExpected result:\nThe created groups are mutually exclusive.\nor\nThe created groups are not mutually exclusive.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":57591831,"Users Score":0,"Answer":"Solve it the opposite way.\nRather than trying all combinations and then checking which conflict, first find all conflicts.\nSo if a record is in groups A, B, and O, then mark AB, AO, and BO as incompatible. When going through combinations, you can easily check that adding B is impossible if you chose to use A etc.","Q_Score":0,"Tags":"python-3.x,logic,cluster-analysis","A_Id":57599130,"CreationDate":"2019-08-21T12:38:00.000","Title":"Logic for creating mutually exclusive groups of individuals (clusters)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created virtual environment with python 3.6.Trying to install django with pip.When I run pip install django command, it prompts that requirement already satisfy but I cannot find the django in pip list.\n$pip install django\n Requirement already satisfied: Django in \/usr\/lib64\/python2.7\/site-packages \n (1.11.21)\n Requirement already satisfied: pytz in \/usr\/lib\/python2.7\/site-packages (from \n Django) (2019.1)\n\nwhen I try to check django version on python shell .\n>>> import django\nTraceback (most recent call last):\n  File \"<stdin>\", line 1, in <module>\nModuleNotFoundError: No module named 'django'\n\nEven i have checked in \/usr\/lib\/python2.7\/site-packages dir, i cannot find django. How do I fix this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1149,"Q_Id":57593373,"Users Score":0,"Answer":"I've had this issue a few times, and just rebooting fixed it each time when I install a package and then cannot import it.","Q_Score":0,"Tags":"python,django,pip","A_Id":57593687,"CreationDate":"2019-08-21T13:56:00.000","Title":"Install Django with pip but can not see in pip list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have to do the following task on Python and I have not idea where\n    to begin: \n\nOCR of handwritten dates\nPage\/document orientation detection for pretreatment\nStamp and Logo Detection and classification\na.  Orientation variation included \n b.  Quality degradation to be considered \n c.  Overlying Primary Content \n\nAnybody could help me? \nTHANKS IN ADVANCE\u00a1\u00a1","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":57593566,"Users Score":0,"Answer":"You can ocrmypdf to extract text from a pdf. It will extract text from the page and return a pdf same like original pdf with text on it. For detection of logos, you need to implement a computer vision-based model. if you need more details then please specify your requirement in details","Q_Score":0,"Tags":"python,opencv,ocr","A_Id":57593740,"CreationDate":"2019-08-21T14:07:00.000","Title":"OCR \/ ICR for handwritting and logos","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to use one of airflow's operators to run an Impala query in the same way it can do Hive queries? I imagine a bash operator will work but would like do do it using the airflow api.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1517,"Q_Id":57595410,"Users Score":0,"Answer":"To connect impala from airflow, we need to mention authentication type and run_set_variable_statements in extra column in connection.\nTo connect with no authentication mechanism, below are the connection details.\nConnection Type : Hive Server 2 Thrift\nPort : 21050\nSchema: Your Database\nExtra: {\"authMechanism\": \"NOSASL\", \"run_set_variable_statements\":false}","Q_Score":1,"Tags":"python,airflow,cloudera,impala","A_Id":59576651,"CreationDate":"2019-08-21T15:58:00.000","Title":"Impala query using Airflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Pygame project in a folder called \"Project\". In it is my code and another folder named \"Images\". I want to load an image in the \"Images\" folder, but every time I try to do so, it comes with up an error, saying: \n\npygame.error: Couldn't open Images\/Frame1.png\n\nI've tried using: \nimage = pygame.image.load(\"Frame1.png\"),\nimage = pygame.image.load(\"Images\/Frame1.png\") , image = pygame.image.load(\"Images\/Frame1.png\").convert() and image = pygame.image.load(\"Images\/Frame1.png\").convert_alpha() .\nBare in mind that I've only imported the Pygame module.\nAll the codes above come up with the same error. I'm using Python v3.7.3 for Mac OSX. Any help would be greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":767,"Q_Id":57596338,"Users Score":2,"Answer":"Try importing the os library and using image = pygame.image.load(os.path.join(os.path.dirname(__file__), 'Images','Frame1.png')).convert_alpha(). This worked for me when I did my own pygame project.","Q_Score":2,"Tags":"python,pygame","A_Id":57596685,"CreationDate":"2019-08-21T17:10:00.000","Title":"Load an image that is in a subfolder using Pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using structlog library to log for my Python project.\nI see some third party library logs which I do not want.\nHow do I remove those logs?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":261,"Q_Id":57599977,"Users Score":2,"Answer":"Logging has a number of locations where you can filter messages. Via the log level of the specific module as in logging.getLogger(...).setLevel(...) or via a filter attached to a logger or attached to a handler.","Q_Score":1,"Tags":"python,logging,structlog","A_Id":57600777,"CreationDate":"2019-08-21T22:37:00.000","Title":"Logging in Python project using structlog and it logs third party libraries which needs to be removed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get an anaconda environment to work in Jupyter notebook with all of the packages I've included in the environment, but the packages are unable to import in jupyter notebook. The environment I created uses Python 3.7 and has all of the anaconda packages and librosa included.\nI've tried using the Python 2 kernel and pandas is able to get imported. If I try to the Python 3 kernel, the kernel constantly shows up as dead, despite just installing the anaconda distribution. I was able to import sys in the environment I created but nothing else. The kernel also sometimes says it's in idle when the jupyter notebook cell indicates that it is running. Is this an issue with how jupyter interacts with Python 3.7 installation of anaconda?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":57601858,"Users Score":0,"Answer":"When working in a file(notebook), click on the kernel menu and select change kernel and pick your environment. \nFor example if your environment was named my_env and your project was named file, select Python [conda env:file-my_env].\nLet me know if this helps!","Q_Score":0,"Tags":"python,pandas,jupyter-notebook,anaconda,kernel","A_Id":57601913,"CreationDate":"2019-08-22T03:55:00.000","Title":"How to make sure anaconda environment is properly configured to import packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Dash app with a dcc.Graph object and a legend for multiple deselectable traces. How can I pass the list of traces selected in the legend as an input to a callback?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":542,"Q_Id":57602189,"Users Score":0,"Answer":"Use restyleData input in the callback: Input(\"graph-id\", \"restyleData\")","Q_Score":3,"Tags":"python,callback,plotly-dash,legend-properties,plotly-python","A_Id":63844295,"CreationDate":"2019-08-22T04:46:00.000","Title":"Dash graph selected legend items as input to callback","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Scrapy gets 302 redirect to another link. In the link 'https:\/\/xxxxxx.queue-it.net?c.....com'  Scrapy does not add the '\/'. It should be'https:\/\/xxxxxx.queue-it.net\/?c.....com'. \nI have tried adding '\/' in middleware.py. Under downloaderMiddleware function. But, it does not work. \nScrapy crawls when I manually add the redirect link with '\/'. However, it is not very dynamic.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":74,"Q_Id":57602863,"Users Score":1,"Answer":"Set 'dont_redirect': True in the specific request or disable redirect globally by setting REDIRECT_ENABLED setting to False.","Q_Score":0,"Tags":"python,web-scraping,scrapy","A_Id":57604799,"CreationDate":"2019-08-22T06:00:00.000","Title":"Scrapy get's redirected to follow 302 and it does not crawl the site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I made a Python 3 program that uses Scapy, then I used pyinstaller to generate a binary and it works fine, but there\u2019s always the need to install WinPcap separately to be able to use the binary.\nIs there a way to include WinPcap\/npcap to the binary, so the user won\u2019t bother installing additional software?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":191,"Q_Id":57604069,"Users Score":0,"Answer":"Winpcap isn't just a library. It actually installs a service and copies a few DLLS to C:\/Windows\/system32.\nYou'll need to install it.\nMoreover, the installer doesn't support command line installation :\/ the only thing that currently works is the chocolatey package, which uses AutoHotKey and is kinda messy.","Q_Score":0,"Tags":"python-3.x,pyinstaller,winpcap,npcap","A_Id":57621176,"CreationDate":"2019-08-22T07:25:00.000","Title":"Include WinPcap in a Python binary","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to fit a simple Bayesian regression model to some right-skewed data. Thought I'd try setting family to a log-normal distribution. I'm using pymc3 wrapper BAMBI. Is there a way to build a custom family with a log-normal distribution?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":162,"Q_Id":57606946,"Users Score":0,"Answer":"Unless I'm misunderstanding something, I think all you need to do is specify link='log' in the fit() call. If your assumption is correct, the exponentiated linear prediction will be normally distributed, and the default error distribution is gaussian, so I don't think you need to build a custom family for this\u2014the default gaussian family with a log link should work fine. But feel free to clarify if this doesn't address your question.","Q_Score":0,"Tags":"python-3.x,bambi","A_Id":57614302,"CreationDate":"2019-08-22T10:10:00.000","Title":"Specify log-normal family in BAMBI model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some tables that are presented as inlines of another class. I have altered the default title of these inline representations by adding an inner class to the respective tables.\nclass Meta:\n        verbose_name = 'Binnengekomen punten'\nI have only the verbose_name defined but it still adds an s to all the names. So 'Binnengekomen punten' is displayed as 'Binnengekomen puntens'\nWhat i could do is define the plural of verbose_name verbose_name_plural the same as verbose_name. But is there a way to simply turn off the plural notation? I'd love to know thank you.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":341,"Q_Id":57608332,"Users Score":1,"Answer":"I\u2019m sure that it\u2019s possible, but can guarantee you that it would not be worth the effort. Just set the verbose_plural_name.","Q_Score":1,"Tags":"python,django","A_Id":57608399,"CreationDate":"2019-08-22T11:27:00.000","Title":"How do i turn off django's plural notation in the admin page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using paramiko to create a SFTP server. I have succeeded in uploading and downloading files to and from server on client request.But, I need to send a file from server to client whenever I need without client request. So, instead of breaking my head on making server send a file to client I want to make both machines act as both server and client in different ports so that when I need to send a file from machine A to B I can just Upload it to the SFTP server running on that port. Is this hypothesis possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":450,"Q_Id":57615144,"Users Score":0,"Answer":"You already know that you cannot send a file from an server to a client:\nCan I send a file from SFTP Server to the Client without any request from it?\n(The question on Server Fault has been deleted)\n\nTo answer your port question:\nYou do not care about client's port. It is automatically assigned to any available port, without you ever needing to know its value. In general, that's true for any TCP\/IP connection, not only SFTP.\nSo you can just run SFTP server on both machines on the standard port 22. And use your client code on the other machine to connect to it.","Q_Score":0,"Tags":"python,windows,sftp,paramiko","A_Id":57616068,"CreationDate":"2019-08-22T18:23:00.000","Title":"Is it possible to run both SFTP server and client in a same machine on different ports?","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":"Python and pip wont work when added to the path\nI've tried adding it to user variables and system variables and multiple different directories including the default location which is the option I chose when installing.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":302,"Q_Id":57617619,"Users Score":0,"Answer":"Never mind. Turns out I had to uninstall py launcher and then go to installation setting for python and check add to path.","Q_Score":0,"Tags":"python-3.x,pip,environment-variables","A_Id":57617981,"CreationDate":"2019-08-22T22:12:00.000","Title":"How do I install python 3.7.4 and pip to the path in windows 10?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a piece of DASK code run on local machine which work 90% of time but will stuck sometimes.  Stuck mean.  No crash, no error print out not cpu usage.  never end.    \nI google and think it maybe due to some worker dead.  I will be very useful if I can see the worker log and figure out why.\nBut I cannot find my worker log.  I go to edit config.yaml to add loging but still see nothing from stderr. \nThen I go to dashboard --> info --> logs and see blank page.\nThe code it stuck is \nX_test = df_test.to_dask_array(lengths=True)\nor \nproba = y_pred_proba_train[:, 1].compute()\nand my ~\/.config\/dask\/config.yaml or ~.dask\/config.yaml look like\nlogging:\n  distributed: info\n  distributed.client: warning\n  distributed.worker: debug\n  bokeh: error \nI am using \npython 3.6\ndask 1.1.4 \nAll I need is a way to see the log so that I can try to figure out what goes wrong.\nThanks\nJoseph","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":149,"Q_Id":57618323,"Users Score":1,"Answer":"Worker logs are usually managed by whatever system you use to set up Dask.  \nPerhaps you used something like Kubernetes or Yarn or SLURM?  \nThese systems all have ways to get logs back.  \nUnfortunately, once a Dask worker is no longer running, Dask itself has no ability to collect logs for you.  You need to use the system that you use to launch Dask.","Q_Score":2,"Tags":"python,dask","A_Id":57712280,"CreationDate":"2019-08-23T00:00:00.000","Title":"Dask worker seem die but cannot find the worker log to figure out why","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My setup is flask-socketio with a flask-restful webserver.\nEventlet is installed, so in production mode, eventlet webserver is used.\nI understand flask-socketio and eventlet webserver themselves are event-loop based.\nDoes flask-socketio and eventlet webserver runs on the same eventloop (same thread) or in two different threads?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":692,"Q_Id":57619141,"Users Score":1,"Answer":"I think you are confusing the terminology.\nThe event loop is the task scheduler. This is provided by eventlet, and a single event loop is used for the whole application, including the Flask and the Flask-SocketIO parts.\nEach time a request arrives to the eventlet web server, it will allocate a new task for it. So basically each request (be it Flask or Flask-SocketIO, HTTP or WebSocket) will get its own task. Tasks are constantly being created and destroyed as requests are handled.\nWhen you use eventlet, tasks are not threads, they are greenlets, that is why I avoided calling them threads above and used the more generic \"task\" term. They behave like threads in many ways, but they are not.","Q_Score":0,"Tags":"python,flask,flask-restful,flask-socketio,eventlet","A_Id":57630398,"CreationDate":"2019-08-23T02:28:00.000","Title":"Flask-SocketIO with eventlet: Web and Websockets Thread","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to insert a python variable into a text cell, in google colab.\nFor example, if a=10, I would like to insert the a into a text cell and render the value.\nSo in the text cell (using Jupyter Notebook with nbextensions) I would like to write the following in the text cell:\nThere will be {{ a }} pieces of fruit at the reception.\nIt should show up as:\nThere will be 10 pieces of fruit at the reception.\nThe markdown cheatsheets and explanations do not say how to achieve this. Is this possible currently?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":2998,"Q_Id":57619805,"Users Score":3,"Answer":"It's not possible to change 'input cell' (either code or markdown) programmatically. You can change only the output cells. Input cells always require manually change. (even %load doesn't work)","Q_Score":8,"Tags":"python-3.x,jupyter-notebook,google-colaboratory","A_Id":57644243,"CreationDate":"2019-08-23T04:11:00.000","Title":"How to insert variables into a text cell using google colab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to upload a zipped build folder to my linux machine and unzip and deploy.. My issue here is the zip file itself 400MB takes 2 hour to upload, is there any way, I can compress file more to reduce like 100MB or some and upload? Anyother help also welcome.. Am doing it with Jenkins and python\nI tried to make it as tar or gzip which results same size","AnswerCount":2,"Available Count":2,"Score":-0.1973753202,"is_accepted":false,"ViewCount":33,"Q_Id":57620675,"Users Score":-2,"Answer":"you can use Uharch programm to compress your file","Q_Score":0,"Tags":"python,file-upload,ftp","A_Id":57620769,"CreationDate":"2019-08-23T06:09:00.000","Title":"I wanted to upload a zipped build folder to my linux machine and unzip and deploy","Data Science and Machine Learning":0,"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 wanted to upload a zipped build folder to my linux machine and unzip and deploy.. My issue here is the zip file itself 400MB takes 2 hour to upload, is there any way, I can compress file more to reduce like 100MB or some and upload? Anyother help also welcome.. Am doing it with Jenkins and python\nI tried to make it as tar or gzip which results same size","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":57620675,"Users Score":0,"Answer":"There is nothing which can magically compress 400 MB to 100 MB, especially not if these are already compressed data like (usually) when you have a ZIP file. \nHow much data can be compressed depends very much on the data - for normal text 50% is not unusual but for binary data it is much less. And it usually will not be able to compress already compressed data any further - otherwise you could just compress again and again until you only have a single byte.\n\nI tried to make it as tar or gzip which results same size\n\nThis is expected. While different compression algorithms might slightly differ in the compression they can achieve these differences are only in a few percent and not in the several factors you need here. Lossless compression is essentially compacting information and data can only be compacted up to some size since the original information somehow needed to by retained. This is different to compression of images or audio where loss of information is often acceptable (and results in loss of quality) and thus much higher compression factors are possible.","Q_Score":0,"Tags":"python,file-upload,ftp","A_Id":57621158,"CreationDate":"2019-08-23T06:09:00.000","Title":"I wanted to upload a zipped build folder to my linux machine and unzip and deploy","Data Science and Machine Learning":0,"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 detect the drive failure in Datanode in a Hadoop Cluster. Cloudera Manager API don't have any specific API for that. CM API are only related to Name node or restart services. Are there any suggestions here? Thanks a lot!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":520,"Q_Id":57621257,"Users Score":1,"Answer":"If you have access to NameNode UI, the JMX page will give you this information. If you hit the JMX page directly it'll be a JSON formatted page, which can be parsed easily.\nWe use HortonWorks primarily, haven't touched Cloudera in a long time, but I assume that can be made available somehow.","Q_Score":0,"Tags":"python-3.x,hadoop,hadoop-yarn,cloudera,cloudera-manager","A_Id":57633508,"CreationDate":"2019-08-23T06:58:00.000","Title":"How to detect in Hadoop cluster if any Datanode drive (Storage) failed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to create a machine learning pipeline using python with PyCharm and run everything in azure machine learning service workspace. Then I want to integrate my pycharm script in a way when I edit and save my script, it runs a new experiment in Azure ML workspace.\nI have check all the tutorials on using Azure ML service using python sdk, however, every time it is via notebooks but not with pycharm.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1111,"Q_Id":57623810,"Users Score":2,"Answer":"Azure Machine Learning service can be used from any editor that supports Python 3.5 - 3.7: PyCharm, VSCode or just plain python.exe. We've used Notebooks because it makes it easy to package and present the examples, however you should be able to copy-paste the Python code and run in any editor.","Q_Score":4,"Tags":"python,azure,pycharm,azure-machine-learning-service","A_Id":57628786,"CreationDate":"2019-08-23T09:52:00.000","Title":"How to Integrate Pycharm and git with azure machile learning service (workspace)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to find similarity score between two documents (containing around 15000 records).\nI am using two methods in python:\n1. TFIDF (Scikit learn) 2. Word2Vec (gensim, google pre-trained vectors)\nExample1\nDoc1- Click on \"Bills\" tab\nDoc2- Click on \"CHAPS\" tab\nFirst method gives 0.9 score.\nSecond method gives 1 score\nExample2\nDoc1- See following requirements:\nDoc2- See following requirements\nFirst method gives 1 score.\nSecond method gives 0.98 score\nCan anyone tell me:\nwhy in Example1 Word2Vec is giving 1 though they are very different\nand in Example2 Word2Vec is giving 0.98 though they are having difference of only \":\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2587,"Q_Id":57626276,"Users Score":0,"Answer":"In example one, the word2vec maybe doesn't have the words Bills and CHAPS into its bag of words. That been said, taking out these words the sentences are the same*. \nIn Example 2, maybe in the tokenization of the word2vec algorithm, it took the \"requirements:\" as one token and the \"requirements\" as a different one, That's why their vector it's a bit different so they aren't exactly the same.\n*Word2vec computes the sentence vector by taking the average of its word vectors. If a word arent in the word2vec's bag of words, it will have vector=[0,0,...0].","Q_Score":0,"Tags":"python,machine-learning,data-science,word2vec,tf-idf","A_Id":57627460,"CreationDate":"2019-08-23T12:22:00.000","Title":"TFIDF vs Word2Vec","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python 3.6.6 and I can create a virtual environment with this version using virtulaenv ..I have installed python in drive(C) C:\\python36 where the OS is installed.How can I install a specific version like python 2.7.16 in the virtual environment.Do I have to install python 2.7.16 manualy or will it download itself?I saw some answers for linux but couldn't get it.I tried\n\nPS C:\\Users\\Husni\\Desktop\\dev> virtualenv -p C:\/python2.7.16 .\nThe path C:\/python2.7.16 (from --python=C:\/python2.7.16) does not\n  exist\n\nThen I tried \n\nPS C:\\Users\\Husni\\Desktop\\dev> virtualenv -p python36 .\nThe path python36 (from --python=python36) does not exist","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":57628368,"Users Score":0,"Answer":"you can't. install python 2 and virtualenv for it and run like \"py -2 -m virtualenv venv\"","Q_Score":0,"Tags":"python,windows,virtualenv","A_Id":57628481,"CreationDate":"2019-08-23T14:34:00.000","Title":"How to install a specific version of python in the virtual enivironment in windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently using RASA and developed a working chatbot. One part of my project is to use a speech-to-text recognition, and I wrote a working code in Python that returns the text said by the user. \nI want to use that text for RASA\u2019s input, instead of writing like usual. \nI saw there was something to do with the inputs channels, but I only saw input that are other webservices and couldn\u2019t figure it out for using just a local script. \nThank you for any advice, \nLM","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":553,"Q_Id":57630816,"Users Score":1,"Answer":"How about just using Rest API that is already present in the library.\nFor this, you just need to fill the query parameter, which you can do with your script, rather than writing a custom Input Channel.","Q_Score":2,"Tags":"python,chatbot,rasa","A_Id":57657363,"CreationDate":"2019-08-23T17:38:00.000","Title":"How can I use the output of a python script as RASA\u2019s input instead of the usual user input?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to fine turn my model when using Keras, and I want to change my training data and learning rate to train when the epochs arrive 10, So how to get a callback when the specified epoch number is over.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":484,"Q_Id":57636091,"Users Score":0,"Answer":"Actually, the way keras works this is probably not the best way to go, it would be much better to treat this as fine tuning, meaning that you finish the 10 epochs, save the model and then load the model (from another script) and continue training with the lr and data you fancy.\nThere are several reasons for this.\n\nIt is much clearer and easier to debug. You check you model properly after the 10 epochs, verify that it works properly and carry on\nIt is much better to do several experiments this way, starting from epoch 10.\n\nGood luck!","Q_Score":0,"Tags":"python,keras","A_Id":57636395,"CreationDate":"2019-08-24T07:50:00.000","Title":"How to get a callback when the specified epoch number is over?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to have the same packages installed on the new version of Python (3.7.4) which I just installed as I do in my old version of Python (3.6.3) such as: Numpy, pandas, opencv, mathplotlib, etc, etc.\nIs there an quick & easy way of doing this? \nCan I just copy and paste the packages from python36\/Lib\/site-packages to python37\/Lib\/site-packages or do I have to use 'pip install' to do it manually for each package?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":432,"Q_Id":57637365,"Users Score":0,"Answer":"You can but they will not work. Especially packages such as numpy, pandas, matplotlib, opencv etc. They need to be compiled for a specific target. If you want the exact same packages in 3.7, pip freeze will list all installed packages. Store the output in a file and then use the pip in python 3.7 to install them pip3.7 install -r output_of_pip_freeze.txt","Q_Score":0,"Tags":"python,python-3.x,pip,package,site-packages","A_Id":57637419,"CreationDate":"2019-08-24T11:05:00.000","Title":"Can I copy and paste software packages from my old Python 3.6.3 to the \/Lib\/site-packages directory of a newly installed Python 3.7.4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some SIFT features in two stereo images, and I'm trying to place them in 3D space. I've found triangulatePoints, which seems to be what I want, however, I'm having trouble with the arguments.\ntriangulatePoints takes 4 arguments, projMatr1 and projMatr2, which is where my issues start, and projPoints1 and projPoints2, which are my feature points. The OpenCV docs suggest using stereoRectify to find the projection matrices.\nstereoRectify takes the intrinsic camera matrices (which I've calculated prior with calibrateCamera) and the image size from calibration. As well as two arguments R (rotation matrix) and T (translation vector), which can be found with stereoCalibrate.\nHowever, stereoCalibrate takes \"object points\", which I'm pretty sure I can't calculate for images without a reference, which is a bit of a roadblock.\nIs this the best way to be calculating 3D positions from pairs of features? If so, how can I calculate projMatr1 and projMatr2 without stereoCalibrate?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":135,"Q_Id":57637608,"Users Score":0,"Answer":"As you say, you have no calibration, so let\u2019s forget about rectification. What you want is the depth of the points, so you can project them into 3D (which then uses just the intrinsic calibration of one camera, mainly the focal length).\nSince you have no rectification, you cannot expect exact results, so let\u2019s try to get as close as possible:\nDepth is focal length times baseline divided by disparity, disparity and focal length being in pixels, and depth and baseline in (recommendation) meters.\nFor accurate disparity you need a rectified camera and correspondences between your features in both images. Since without calibration, you have no hope of rectification, you could try to just use the original images instead. It will work fine the more parallel the cameras are. If they are not parallel, you will introduce an error here and your results will become less accurate. If this becomes bad you must find a way to calibrate your camera.\nBut most importantly, you need correspondences between your features in both images. Running SIFT in both images won\u2018t do. A better approach would be running SIFT in just one image and then finding the corresponding pixels for each of the features in the other image. There are plenty of methods for that, I believe OpenCv has some simple block matching builtin.","Q_Score":0,"Tags":"python,opencv","A_Id":57638917,"CreationDate":"2019-08-24T11:40:00.000","Title":"OpenCV feature pairs to point cloud","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Django admin is displaying without CSS because of the error: \nThe resource from \u201cmy-website-address\/static\/admin\/css\/responsive.css\u201d was blocked due to MIME type (\u201ctext\/html\u201d) mismatch (X-Content-Type-Options: nosniff).\nThe CSS url I can open in my browser and it looks fine.\nWhat can I do to fix CSS displaying for standard Django admin interface?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2582,"Q_Id":57639314,"Users Score":2,"Answer":"I got the error\n\nRefused to apply style from '' because its MIME type\n  ('text\/html') is not a supported stylesheet MIME type, and strict MIME\n  checking is enabled.\n\nbecause one of my Cloudflare manually created firewall rules blocked CSS URLs.\nI discovered this when opened my Cloudflare dashboard and sow that firewall rule was applying 'JS challenge' to the URLs like https:\/\/[my-website]\/static\/admin\/css\/.\nSo if your website can not load some resources and you get the error about MIME type please check your Cloudflare dashboard or try to temporary disable it.","Q_Score":5,"Tags":"css,django,django-admin,pythonanywhere","A_Id":57677396,"CreationDate":"2019-08-24T15:31:00.000","Title":"CSS not working in Django admin: The resource from [css file url] was blocked due to MIME type (\u201ctext\/html\u201d) mismatch (X-Content-Type-Options: nosniff","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Django admin is displaying without CSS because of the error: \nThe resource from \u201cmy-website-address\/static\/admin\/css\/responsive.css\u201d was blocked due to MIME type (\u201ctext\/html\u201d) mismatch (X-Content-Type-Options: nosniff).\nThe CSS url I can open in my browser and it looks fine.\nWhat can I do to fix CSS displaying for standard Django admin interface?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2582,"Q_Id":57639314,"Users Score":0,"Answer":"in case a google traveler arrives here: in my case the problem was I forgot to call to \"collectstatic\" after a big django upgrade in production (apache + django 3.2, from 2.2)\nBests, Jos\u00e9.-","Q_Score":5,"Tags":"css,django,django-admin,pythonanywhere","A_Id":68855349,"CreationDate":"2019-08-24T15:31:00.000","Title":"CSS not working in Django admin: The resource from [css file url] was blocked due to MIME type (\u201ctext\/html\u201d) mismatch (X-Content-Type-Options: nosniff","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have about 15 million pairs that consist of a single int, paired with a batch of (2 to 100) other ints. \nIf it makes a difference, the ints themselve range from 0 to 15 million. \nI have considered using: \nPandas, storing the batches as python lists\nNumpy, where the batch is stored as it's own numpy array (since numpy doesn't allow variable length rows in it's 2D data structures)\nPython List of Lists. \nI also looked at Tensorflow tfrecords but not too sure about this one. \nI only have about 12 gbs of RAM. I will also be using to train over a machine learning algorithm so","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":71,"Q_Id":57640595,"Users Score":1,"Answer":"Use numpy. It us the most efficient and you can use it easily with a machine learning model.","Q_Score":0,"Tags":"python,numpy","A_Id":57641090,"CreationDate":"2019-08-24T18:30:00.000","Title":"Best data type (in terms of speed\/RAM) for millions of pairs of a single int paired with a batch (2 to 100) of ints","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a project where I need to analyze a text to extract some information if the user who post this text need help in something or not, I tried to use sentiment analysis but it didn't work as expected, my idea was to get the negative post and extract the main words in the post and suggest to him some articles about that subject, if there is another way that can help me please post it below and thanks.\nfor the dataset i useed, it was a dataset for sentiment analyze, but now I found that it's not working and I need a dataset use for this subject.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":578,"Q_Id":57641504,"Users Score":0,"Answer":"Please use the NLP methods before processing the sentiment analysis. Use the TFIDF, Word2Vector to create vectors on the given dataset. And them try the sentiment analysis. You may also need glove vector for the conducting analysis.","Q_Score":1,"Tags":"python-3.x,machine-learning,text,nlp,analytics","A_Id":67599276,"CreationDate":"2019-08-24T20:59:00.000","Title":"Detecting questions in text","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I go to the PyTorch website and select the following options\nPyTorch Build: Stable (1.2)\nYour OS: Windows\nPackage: pip\nLanguage: Python 3.7\nCUDA: None\n(All of these are correct)\nThan it displays a command to run\npip3 install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https:\/\/download.pytorch.org\/whl\/torch_stable.html\nI have already tried to mix around the the different options but none of them has worked.\n\nERROR: ERROR: Could not find a version that satisfies the requirement torch==1.2.0+cpu (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)\nERROR: No matching distribution found for torch==1.2.0+cpu\nI tried to do pip install pytorch but pytorch doesn't support pypi","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":2971,"Q_Id":57642019,"Users Score":1,"Answer":"I've been in same situation. \nMy prob was,  the python version... I mean, in the 'bit' way.\nIt was 32 bit that the python I'd installed.\nYou should check which bit of python you installed. \nyou can check in the app in setting, search python, then you will see the which bit you've installed.\nAfter I installed the 64 bit of Python, it solved.\nI hope you figure it out! \nenvironment : win 10","Q_Score":1,"Tags":"python,pip,pytorch","A_Id":57797731,"CreationDate":"2019-08-24T22:45:00.000","Title":"PyTorch not downloading","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I go to the PyTorch website and select the following options\nPyTorch Build: Stable (1.2)\nYour OS: Windows\nPackage: pip\nLanguage: Python 3.7\nCUDA: None\n(All of these are correct)\nThan it displays a command to run\npip3 install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https:\/\/download.pytorch.org\/whl\/torch_stable.html\nI have already tried to mix around the the different options but none of them has worked.\n\nERROR: ERROR: Could not find a version that satisfies the requirement torch==1.2.0+cpu (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)\nERROR: No matching distribution found for torch==1.2.0+cpu\nI tried to do pip install pytorch but pytorch doesn't support pypi","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2971,"Q_Id":57642019,"Users Score":0,"Answer":"It looks like it can't find a version called \"1.2.0+cpu\" from it's list of versions that it can find (0.1.2, 0.1.2.post1, 0.1.2.post2). Try looking for one of those versions on the PyTorch website.","Q_Score":1,"Tags":"python,pip,pytorch","A_Id":57642037,"CreationDate":"2019-08-24T22:45:00.000","Title":"PyTorch not downloading","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I go to the PyTorch website and select the following options\nPyTorch Build: Stable (1.2)\nYour OS: Windows\nPackage: pip\nLanguage: Python 3.7\nCUDA: None\n(All of these are correct)\nThan it displays a command to run\npip3 install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https:\/\/download.pytorch.org\/whl\/torch_stable.html\nI have already tried to mix around the the different options but none of them has worked.\n\nERROR: ERROR: Could not find a version that satisfies the requirement torch==1.2.0+cpu (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)\nERROR: No matching distribution found for torch==1.2.0+cpu\nI tried to do pip install pytorch but pytorch doesn't support pypi","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2971,"Q_Id":57642019,"Users Score":0,"Answer":"So it looks like I cant install PyTorch because I am running python 32-bit. This may or may not be the problem but this is the only possible error that I could see this being the cause.","Q_Score":1,"Tags":"python,pip,pytorch","A_Id":57648698,"CreationDate":"2019-08-24T22:45:00.000","Title":"PyTorch not downloading","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script which creates some objects. \nI would like to be able to save these objects into my postgres database for use later. \nMy thinking was I could pickle an object, then store that in a field in the db. \nBut I'm going round in circles about how to store and retrieve and use the data.\nI've tried storing the pickle binary string as  text but I can't work out how to  encode \/ escape it. Then how to load the string as a binary string to unpickle.\nI've tried storing the data as bytea both with psycopg2.Binary(data) and without.\nThen reading into buffer and encoding with base64.b64encode(result) but it's not coming out the same and cannot be unpickled. \nIs there a simple way to store and retrieve python objects in a SQL (postgres) database?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":5865,"Q_Id":57642165,"Users Score":4,"Answer":"Following the comment from @SergioPulgarin I tried the following which worked!\nN.B Edit2 following comment by @Tomalak\nStoring:\n\nPickle the object to a binary string\npickle_string = pickle.dumps(object)\nStore the pickle string in a bytea (binary) field in postgres. Use simple INSERT query in Psycopg2\n\nRetrieval:\n\nSelect the field in Psycopg2. (simple SELECT query)\nUnpickle the decoded result\nretrieved_pickle_string = pickle.loads(decoded_result)\n\nHope that helps anybody trying to do something similar!","Q_Score":5,"Tags":"python,postgresql,pickle","A_Id":57644761,"CreationDate":"2019-08-24T23:23:00.000","Title":"saving python object in postgres table with pickle","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the pyproject.toml configuration file of Poetry you can specify both dependencies and dev-dependencies, but the documentation does not state clearly what the difference is.\nI guess from the name the dev-dependencies will not be installed by a release build, but I didn't notice any difference. How do you use these fields correctly, for example exclude the dev-dependencies in a build?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1894,"Q_Id":57645942,"Users Score":8,"Answer":"Your assumption is right. The best use case for dev-dependencies is when you creating a library with optional dependencies. For instance, you are developing ORM which should work with MySQL, PostgreSQL, etc. You have to test that your code is working with all of these RDBMS. You put it into dev-dependencies. But for one, who installs your library, these dependencies are optional and they wouldn't be installed automatically.\nCommonly, all libraries that are used for testing or building your application are presented at dev-dependencies.\n\nHow do you use these fields correctly, for example exclude the dev-dependencies in a build?\n\npoetry install has a no-dev flag for exactly that scenario.","Q_Score":7,"Tags":"python-poetry","A_Id":57646022,"CreationDate":"2019-08-25T12:19:00.000","Title":"What is the difference between deps and dev-deps in Poetry?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried switching from venv & conda to pipenv to manage my virtual environments, but one thing I noticed about pipenv that it's oddly slow when it's doing \"Locking\" and it gets to the point where it stops executing for \"Running out of time\". Is it usually this slow or is it just me? Also, could you give me some advice regarding how to make it faster?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":8709,"Q_Id":57646310,"Users Score":15,"Answer":"Pipenv is literally a joke. I spent 30 minutes staring at \"Locking\", which eventually fails after exactly 15 minutes, and I tried two times.\nThe most meaningless thirty minutes in my life.\nWas my Pipfile complex? No. I included \"flask\" with \"flake8\" + \"pylint\" + \"mypy\" + \"black\".\nEvery time someone tries to fix the \"dependency management\" of Python, it just gets worse.\nI'm expecting Poetry to solve this, but who knows.\nMaybe it's time to move on to typed languages for web development.","Q_Score":22,"Tags":"python,pipenv","A_Id":61545097,"CreationDate":"2019-08-25T13:10:00.000","Title":"Is Python's pipenv slow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried switching from venv & conda to pipenv to manage my virtual environments, but one thing I noticed about pipenv that it's oddly slow when it's doing \"Locking\" and it gets to the point where it stops executing for \"Running out of time\". Is it usually this slow or is it just me? Also, could you give me some advice regarding how to make it faster?","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":8709,"Q_Id":57646310,"Users Score":2,"Answer":"try using --skip-lock like this :\npipenv install --skip-lock\nNote : do not skip-lock when going in production","Q_Score":22,"Tags":"python,pipenv","A_Id":65533914,"CreationDate":"2019-08-25T13:10:00.000","Title":"Is Python's pipenv slow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a folder on my desktop that contains my script and when I run it in the pycharm ide it works perfectly but when I try to run from the terminal I get  \/Users\/neelmukherjee\/Desktop\/budgeter\/product_price.py: Permission denied\nI'm not quite sure as to why this is happening\nI tried using ls -al to check the permissions and for some reason, the file is labelled as\ndrwx------@  33 neelmukherjee  staff      1056 26 Aug 09:03 Desktop\nI'm assuming this means that I should run this file as an admin. But how exactly can I do that?\nMy goal is to run my script from the terminal successfully and that may be possible by running it as an admin how should I do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":57650883,"Users Score":0,"Answer":"Ok, so I was able to figure it out. I had to use\nchmod +x to help make it executable first.\nchmod +x \/Users\/neelmukherjee\/Desktop\/budgeter\/product_price.py\nand the run \/Users\/neelmukherjee\/Desktop\/budgeter\/product_price.py","Q_Score":0,"Tags":"python-3.x,macos,terminal","A_Id":57651015,"CreationDate":"2019-08-26T01:21:00.000","Title":"Python script denied in terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am very new to the python keras. And with the understanding of the Keras, I'm confusing about the input shape of Keras. I feel under different neural network, I need to reconstruct my data into different shapes.\nFor example, if I'm building a simple ANN, my train data should be a matrix like [m, n], the m is the number of samples and n is the number of feature. But recently I'm learning 1D convolutional neural network. I found the tutorial construct the training data as [a, b, c], where the a is the number of sample, b is the number of timestep, c is the number of feature (equals to 1). But why I can't simply reshape the data into [a, b]? since c will always be 1 for a 1D convolutional neural network.\nI'm not sure if I understand the above right. I am just wondering is there a summarize of the training_data shape of different neural networks? Or is there any logic behind the shape of data? So I can always make sure my training data has the right format.\nThe different neural networks mean like ANN, 1D CNN, 2d CNN, RNN and so on.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":57651278,"Users Score":0,"Answer":"Generally, CNN takes 4 dimensions as input data. Whenever you train a CNN the model in Keras it will automatically convert the input data into 4D. If you want to predict using your CNN model you have to make sure that even your output data\/ or the data you want to run the inference on should have the same dimensions as input data. You can simply add 0 or None at the output data by using numpy expand_dims function.","Q_Score":0,"Tags":"python,keras","A_Id":57658971,"CreationDate":"2019-08-26T02:56:00.000","Title":"Can someone explain or summarize the input shape of keras under different type of neural networks?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to write a script in bash\/python such that the script copies the latest file which arrives at hdfs directory.I know I can use inotify in local, but how to implement it in hdfs?\nCan you please share the sample code for it. When I searched for it in google it gives me long codes.Is there a simpler way other than inotify(if its too complex)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":57652601,"Users Score":0,"Answer":"Inelegant hack:\nMount hdfs using FUSE then periodically use find <mountpoint> -cmin n to get a list of files created in the last n minutes.\nThen use find <mountpoint> -anewer to sort them.","Q_Score":0,"Tags":"python,bash,hdfs,inotify","A_Id":57653039,"CreationDate":"2019-08-26T06:10:00.000","Title":"How to watch an hdfs directory and copy the latest file that arrives in hdfs to local?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Using Postgres and sqlalchemy.\nI have a job scans a large table and for each row does some calculation and updates some related tables. I am told that I should issue periodic commits inside the loop in order not to keep a large amount of in-memory data. I wonder such commits have a performance penalty, e.g. restarting a transaction, taking db snapshot perhaps etc. \nWould using a flush() be better in this case?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":37,"Q_Id":57654621,"Users Score":2,"Answer":"An open transaction won't keep a lot of data in memory.\nThe advice you got was probably from somebody who is used to Oracle, where large transactions cause problems with UNDO.\nThe question is how you scan the large table:\n\nIf you snarf the large table to the client and then update the related tables, it won't matter much if you commit in between or not.\nIf you use a cursor to scan the large table (which is normally better), you'd have to create a WITH HOLD cursor if you want the cursor to work across transactions. Such a cursor is materialized on the database server side and so will use more resources on the database.\nThe alternative would be to use queries for the large table that fetch only part of the table and chunk the operation that way.\n\nThat said, there are reasons why one big transaction might be better or worse than many smaller ones:\nReasons speaking for a big transaction:\n\nYou can use a normal cursor to scan the big table and don't have to bother with WITH HOLD cursors or the alternative as indicated above.\nYou'd have transactional guarantees for the whole operation. For example, you can simply restart the operation after an error and rollback.\n\nReasons speaking for operation in batches:\n\nShorter transactions reduce the risk of deadlocks.\nShorter transactions allow autovacuum to clean up the effects of previous batches while later batches are being processed. This is a notable advantage if there is a lot of data churn due to the updates, as it will help keep table bloat small.\n\nThe best choice depends on the actual situation.","Q_Score":0,"Tags":"python,database,postgresql,performance,sqlalchemy","A_Id":57655178,"CreationDate":"2019-08-26T08:49:00.000","Title":"is there a performance penalty for issuing periodic commits during a long DB scan?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want regular expression for just number with fixed length and without digit back or front occurred that without using \\b\nsample text: \"phone0990-123-12345hello\"\nmy regex: r'09([0-9]){2}([ ]|-){0,1}([0-9]){3}([ ]|-){0,1}([0-9]){4}(?:[^0-9])'\nthis regex must return null but it return 0990-123-12345 for me!\nI say to it match numbre in text that don't continues digit after 9 target digit with (?:[^0-9]) and with ?: say to it that don't show non digit in match. I don't want show h character in match!","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":89,"Q_Id":57655285,"Users Score":-1,"Answer":"Try r'\\d{4}\\-\\d{3}-\\d{3,4}' it will return only 0990-123-1234","Q_Score":0,"Tags":"python,regex","A_Id":57655421,"CreationDate":"2019-08-26T09:34:00.000","Title":"regular expression for just number with fixed length and without digit back or front occurred that and without use \\b","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having datetime in csv file in UTC tmezone, if i convert it from UTC to pytz.timezone('America\/Los_Angeles') or any other America timezone it will omit the 2nd hour(2:MM:SS) from DST(Daylight savings time). Ex: 2019-03-10 00:00:00\ndirectly goes to 1st hour(1:MM:SS) to 3rd hour(3:MM:SS). If i plot line chart using converted datetime in C3(javascript chart library), there is an one hour gap between 1st and 3rd hour.\nNote:\n2nd hour data was missed while converting UTC to 'America\/Los_Angeles' because of DST.\nis there any way to parse datetime without missing 2nd hour data?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":449,"Q_Id":57657710,"Users Score":0,"Answer":"Welcome to the stupidity that is Daylight Saving Time. In North America, there are 2 clock change days: \"spring forward\" in March and \"fall back\" in November. The exact days are different every year.\n\nOn the \"spring forward\" day, the clocks jumps from 1:59:59 to 3:00:00 - there's no 2AM.\nConversely, on \"fall back\" day, 1:59:59 is followed by another 1:00:00 - so there are two 1AMs. \n\npytz is doing the right thing, only the human behaviors that are so perplexing.","Q_Score":1,"Tags":"python-3.x,pandas,timezone,dst,python-datetime","A_Id":57659532,"CreationDate":"2019-08-26T12:11:00.000","Title":"Get daylight savings(DST) applied python datetime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to generate a single report that integrates different objects as my analysis inlcudes plots (matplotlib, seaborn and bokeh) and pandas data frames (tables) and paragraphs (markdowns) into an HTML report in python","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":16,"Q_Id":57659156,"Users Score":0,"Answer":"Use Jupyter or Zeppelin notebooks. They provide all of the functionality you described and can export to PDF. Reports can even be run\/emailed on a predetermined schedule.","Q_Score":0,"Tags":"python,html,reporting","A_Id":57660353,"CreationDate":"2019-08-26T13:46:00.000","Title":"combined different objects contains plots and data frames (tables) and paragraphs (markdowns) in to single html report","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm actually working on a Python script in which I have a list of dictionaries and then I use a subprocess to run another Python script. \nIn such second script I need to access the same list of dictionaries present in the first one, so until now I have been doing the following:\n\ndump list of dictionaries into a file in JSON format\npass file's path as input parameter to the subprocess\nretrieve (load) list of dictionaries from file in the second script\n\nHowever, dump and load are I\/O operations which are very slow, especially with big files, thus I was wondering whether there is another way to share such list of dictionaries with the second script directly in memory.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":380,"Q_Id":57660554,"Users Score":1,"Answer":"You can setup a communication link between the different programs\/processes using a pipe. This will allow you to pass messages between them without writing to disc.\nAnd, to make things even nicer, a pair of pipes already exists between a main porcess and its sub-processes, namely stdin and stdout. Thus, when starting your subprocess, make sure to re-route stdin to a pipe, and you will have a way to write directly to the sub-process: subprocess.call([subprogram], stdin=subprocess.PIPE ...)\nOf course the sub-process\/program must be able to handle the input over that link, instead of reading from disc. I think this is the cleanest and simplest way to achieve what you want, provided this works from Jython, which I have never tried.","Q_Score":0,"Tags":"python,object,subprocess","A_Id":57707831,"CreationDate":"2019-08-26T15:08:00.000","Title":"Share objects among python subprocesses","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"During hyper-parameter tuning do the parameters (weights already learned during model training) are also optimized or are they fixed and only optimal values are found for the hyper-parameters? Please explain.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":57661188,"Users Score":1,"Answer":"Short is NO, they are not fixed.\nBecause, Hyper-parameters directly influence your simple parameters.   So for a neural network, no of hidden layers to use is a hyper-parameter, while weights and biases in each layer can be called simple parameter. Of course, you can't make weights of individual layers constant when the number of layers of the network (hyper-parameter) itself is variable . Similarly in linear regression, your regularization hyper-parameter directly impacts the weights learned. \nSo goal of tuning hyper-parameter is to get a value that leads to best set of those simple parameters. Those simple parameters are the ones you actually care about, and they are the ones to be used in final prediction\/deployment. So tuning hyper-parameter while keeping them fixed is meaningless.","Q_Score":0,"Tags":"python,machine-learning,cross-validation","A_Id":57661488,"CreationDate":"2019-08-26T15:52:00.000","Title":"Does the simple parameters also change during Hyper-parameter tuning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to determine if a number is increasing or decreasing. An encoder gives back an unsigned 16-bit value that will either increase, decrease, or stay the same if the encoded data increases or decreases.\nI obtain the encoded value and append it to a list every x seconds, and I'm trying to compare these values to see if they're increasing\/decreasing. I check each value to the previously obtained value, but the only problem I'm having is that at 65535, the data wraps back around to 0. How would I account for these instances?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":57661388,"Users Score":1,"Answer":"It's implausible that the value changes by more than half of its total range between measurements (if it does, you can't figure out which way it's moving), so if you get a difference greater than 32,768 subtract 65,536 from it, and if you get a difference less than -32,768 add 65,536 to it.\nThat way, if the value goes from e.g. 65,535 to 2 (a raw difference of -65,533) you will register as a difference of +3 (= -65,533 + 65,536), which is what you wanted. The same process happens in reverse if you cross the wrap-around the other way.","Q_Score":0,"Tags":"python,binary,encoder","A_Id":57661518,"CreationDate":"2019-08-26T16:07:00.000","Title":"How to tell if a 16 bit-binary encoded value is increasing or decreasing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a corpus of free text medical narratives, for which I am going to use for a classification task, right now for about 4200 records. \nTo begin, I wish to create word embeddings using w2v, but I have a question about a train-test split for this task. \nWhen I train the w2v model, is it appropriate to use all of the data for the model creation? Or should I only use the train data for creating the model? \nReally, my question sort of comes down to: do I take the whole dataset, create the w2v model, transform the narratives with the model, and then split, or should I split, create w2v, and then transform the two sets independently?\nThanks!\nEDIT\nI found an internal project at my place of work which was built by a vendor; they create the split, and create the the w2v model on ONLY the train data, then transform the two sets independently in different jobs; so it's the latter of the two options that I specified above. This is what I thought would be the case, as I wouldn't want to contaminate the w2v model on any of the test data.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1011,"Q_Id":57662405,"Users Score":2,"Answer":"The answer to most questions like these in NLP is \"try both\" :-) \nContamination of test vs train data is not relevant or a problem in generating word vectors. That is a relevant issue in the model you use the vectors with. I found performance to be better with whole corpus vectors in my use cases.\nWord vectors improve in quality with more data. If you don't use test corpus, you will need to have a method for initializing out-of-vocabulary vectors and understanding the impact they may have on your model performance.","Q_Score":1,"Tags":"python,machine-learning,nlp,word2vec","A_Id":57663266,"CreationDate":"2019-08-26T17:30:00.000","Title":"Is it appropriate to train W2V model on entire corpus?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning file handling in python right now. If i write read() method , it does work same as readline() method . There must be a difference between them and i want to learn that","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10505,"Q_Id":57662894,"Users Score":0,"Answer":"The main difference is that read() will read the whole file at once and then print out the first characters that take up as many bytes as you specify in the parenthesis versus the readline() that will read and print out only the first characters that take up as many bytes as you specify in the parenthesis. You may want to use readline() when you're reading files that are too big for your RAM.","Q_Score":1,"Tags":"python","A_Id":57663051,"CreationDate":"2019-08-26T18:13:00.000","Title":"What is the difference between read() and readline() in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Seeking a bit of guidance on a general approach as to how one would automate the retrieval of data from a My Google Map.  While I could easily export any given layer to KML\/KMZ, I'm looking for a way to do this within a larger script, that will automate the process.  Preferably, where I wouldn't even have to log in to the map itself to complete the data pull.\nSo, what do you think the best approach is?  Two possible options I'm considering are 1) using selenium\/beautiful soup to simulate page-clicks on Google Maps and export the KMZ or 2) making use of Python Google Maps API.  Though, I'm not sure if this API makes it possible to download Google Maps layer via a script.  \nTo be clear, the data is already in the map - I'm just looking for a way to export it.  It could either be a KMZ export, or better yet, GeoJSON.\nAny thoughts or advice welcome!  Thank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":280,"Q_Id":57664000,"Users Score":0,"Answer":"I used my browser\u2019s inspection feature to figure out what was going on under the hood with the website I was interested in grabbing data from, which led me to this solution. \nI use Selenium to login and navigate said website, then transfer my cookies to Python\u2019s Requests package. I have Requests send a specific query to the server whose response is in the form of JSON. I was able to figure out what query to send and what form the response would be through the inspection feature previously stated. Once I have the response in JSON I use Python\u2019s JSON package to convert into a Python dict to use however I need. \nSounds like you might not necessarily need Selenium but it does sound like the Requests package would be useful to your use case. I think your first step is figuring out what form the server response is when you interact with the website naturally to get what you want. \nHopefully this helps to some degree!","Q_Score":2,"Tags":"python,selenium,google-maps,geospatial,kmz","A_Id":57664626,"CreationDate":"2019-08-26T19:41:00.000","Title":"How to automate pulling data (KMZ? JSON?) from My Google Maps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset that contains 'tag' and 'date'. I need to group the data by 'tag' (this is pretty easy), then within each group count the number of row that the date for them is smaller than the date in that specific row. I basically need to loop over the rows after grouping the data. I don't know how to write a UDF which takes care of that in PySpark. I appreciate your help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":57665530,"Users Score":0,"Answer":"you need an aggregation ? \ndf.groupBy(\"tag\").agg({\"date\":\"min\"})\nwhat about that ?","Q_Score":0,"Tags":"python,pyspark","A_Id":57681370,"CreationDate":"2019-08-26T22:11:00.000","Title":"PySpark Group and apply UDF row by row operation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am an extreme beginner with Python and its libraries and installation in general. I want to make an extremely simple google search web scraping tool. I was told to use Requests and BeautifulSoup. I have installed python3 on my Mac by using brew install python3 and I am wondering how to get those two libraries\nI googled around and many results said that by doing brew install python3 it will automatically install pip so I can use something like pip install requests but it says pip: command not found.\nby running python3 --version it says Python 3.7.4","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":57665963,"Users Score":0,"Answer":"Since you're running with Python3, not Python (which usually refers to 2.7), you should try using pip3.\npip on the other hand, is the package installer for Python, not Python3.","Q_Score":0,"Tags":"python-3.x,pip","A_Id":57666013,"CreationDate":"2019-08-26T23:20:00.000","Title":"How to install stuff like Requests and BeautifulSoup to use in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to deploy a Flask app to an Azure Web App (Linux, python3.7 runtime) using FTP.\nI copied the \"application.py\" over and a \"requirements.txt\", but I can see in the logs that nothing is being installed.\nThe Web App is using an 'antenv' virtual environment but it won't install anything. How do I add libraries to this 'antenv' virtual environment?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2242,"Q_Id":57666646,"Users Score":0,"Answer":"Turns out I had to run these commands and do a git push while my local venv was activated. At that point I saw azure start downloading all the libraries in my requirements.txt","Q_Score":2,"Tags":"python,azure,azure-web-app-service","A_Id":57667310,"CreationDate":"2019-08-27T01:27:00.000","Title":"How do you pip install libraries to the 'antenv' venv on an Azure Web App?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm trying to implement a DQN which makes many calls to Estimator.train() followed by Estimator.predict() on the same model with a small number of examples each. But each call takes a minimum of a few hundred milliseconds to over a second which is independent of the number of examples for small numbers like 1-20.\nI think these delays are caused by rebuilding the graph and saving checkpoints on each call. Is there are way to keep the same graph and parameters in memory for fast train-predict iterations or otherwise speed it up?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":148,"Q_Id":57670160,"Users Score":0,"Answer":"Convert to a tf.keras.Model instead of an Estimator, and use tf.keras.Model.fit() instead of Estimator.train(). fit() doesn't have the fixed delay that train() does. The Keras predict() doesn't either.","Q_Score":0,"Tags":"python,tensorflow-estimator","A_Id":58252317,"CreationDate":"2019-08-27T08:01:00.000","Title":"Estimator.train() and .predict() are too slow for small data sets","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset of 11k images labeled for semantic segmentation. About 8.8k belong to 'group 1' and the rest to 'group 2'\nI am trying to simulate what would happen if we lost access to 'group 1' imagery but not a network trained from them.\nSo I trained ResNet50 on group 1 only. Then used that network as a starting point for training group 2 only. \nResults are essentially slightly better than not training with group 2 imagery (3% in average per class accuracy) but less than 1% better than if I just started with imagenet weights. I tested freezing blocks of resnet50 and a range of learning rates.\nGroup 1 and 2 are part of the same problem domain but are a bit different. They are taken at different regions (in fact the whole set covers a bunch of areas but group 1 and 2 are disjoint in this regard) and a different camera\/resolution. They are resized to a fixed size though this fixed size is closer to group 1 average size.\nThey are very different to imagenet images. They are monochrome, rectangular and are essentially one type of object that I'm segmenting.\nI'm not seeking to get the same result as training on all the images at once but surely there must be a bump in doing this over just training from imagenet.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":150,"Q_Id":57674274,"Users Score":0,"Answer":"I have read a few articles about the same topic - i have 12k jpeg images from 3 classes and after 3 epochs the accuracy dropped to 0.  I am awaiting delivery of a new graphics card to improve performance (it's currently taking 90 - 120 minutes per epoch) and hope to give more feedback.  I am just wondering if the face that this model was designed for ImageNet and its 21k classes might be part of the problem - its too wide and deep, therefore too sensitive to changes to weights....... would be interested in others views","Q_Score":0,"Tags":"python,tensorflow,keras,deep-learning","A_Id":62469494,"CreationDate":"2019-08-27T12:03:00.000","Title":"Poor performance transfer learning ResNet50","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that pip list will list all the installed libraries and pip show lib-name will give details about the library like its dependecies, required-by and etc. \nIs there a way to find the date on which the library was installed? Other than checking the date on which the particular library folder was created under Lib\\site-packages.\nThis is solely out of curiosity.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":529,"Q_Id":57675992,"Users Score":0,"Answer":"There is no. pip doesn't maintain a separate database of packages. Said site-packages directory is that database. Some metadata are stored in *.dist-info directories but only that required for pip and setuptools to work. Installation date is not stored.","Q_Score":0,"Tags":"python-3.x,pip","A_Id":57676576,"CreationDate":"2019-08-27T13:41:00.000","Title":"How to get the date on which the Python library was installed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a python program which uses subprocess to send files via cURL.  It works, but for each file\/zip it outputs the loading progress, time and other stuff which I don't want to be shown.  Does anyone know how to stop it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":106,"Q_Id":57676703,"Users Score":0,"Answer":"You should add stderr=subprocess.DEVNULL or stderr=subprocess.PIPE to your check_output call","Q_Score":0,"Tags":"python,python-3.x,subprocess","A_Id":57676861,"CreationDate":"2019-08-27T14:17:00.000","Title":"Stop subprocess.check_output to print on video","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Suppose I have a bulleted list in Jupyter in a markdown cell like this:\n\nItem1\nItem2\nItem3\n\nIs there a way to convert this one cell list in three markdown text cells?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":369,"Q_Id":57677910,"Users Score":0,"Answer":"Ctrl + Shift + - will split a cell on cursor. Else, cannot process a text of a cell with code unless you're importing a notebook within another notebook.","Q_Score":0,"Tags":"python,jupyter-notebook,markdown,jupyter","A_Id":57678955,"CreationDate":"2019-08-27T15:22:00.000","Title":"In a Jupyter Notebook how do I split a bulleted list in multiple text cells?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I install a python module using pip -t . pip downloads the module into a specific folder in the current directory. Python then searches the current directory for the module when it is imported and all is well.\nWhat is the best practise for whether to add the module folders into GIT?\nIt seems to me that checking in these folders is not a good idea, instead the build process should download them from the requirements file rather than get them from SCM.\nHowever adding each folder into .gitignore seems overly burdensome. \nI was expecting the python modules to go into some special directory such as python_modules which I could then add to .gitignore however this does not appear to be the case. Or is there some kind of hook that I can use to get pip to update the .gitignore file automatically when installing new modules?\nSo what do people do to manage these files? My googling has so far not revealed much and I am not at a loss as to what to do?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":276,"Q_Id":57678337,"Users Score":2,"Answer":"One option would be to create a directory called python_modules, and then when you install a new module, install it with pip install -t python_modules .... This way you can add python_modules to your .gitignore.\nThat being said, what's your rationale behind installing them inside your project rather than letting the build process install them in the usual location on your system?","Q_Score":2,"Tags":"python,git,pip","A_Id":57678421,"CreationDate":"2019-08-27T15:52:00.000","Title":"How to handle python modules 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":0,"Web Development":0},{"Question":"I have an array with ~1,000,000 rows, each of which is a numpy array of 4,800 float32 numbers.\nI need to save this as a csv file, however using numpy.savetxt has been running for 30 minutes and I don't know how much longer it will run for.\nIs there a faster method of saving the large array as a csv?\nMany thanks,\nJosh","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":266,"Q_Id":57679863,"Users Score":2,"Answer":"As pointed out in the comments, 1e6 rows * 4800 columns * 4 bytes per float32 is 18GiB. Writing a float to text takes ~9 bytes of text (estimating 1 for integer, 1 for decimal, 5 for mantissa and 2 for separator), which comes out to 40GiB. This takes a long time to do, since just the conversion to text itself is non-trivial, and disk I\/O will be a huge bottle-neck.\nOne way to optimize this process may be to convert the entire array to text on your own terms, and write it in blocks using Python's binary I\/O. I doubt that will give you too much benefit though.\nA much better solution would be to write the binary data to a file instead of text. Aside from the obvious advantages of space and speed, binary has the advantage of being searchable and not requiring transformation after loading. You know where every individual element is in the file, if you are clever, you can access portions of the file without loading the entire thing. Finally, a binary file is more likely to be highly compressible than a relatively low-entropy text file.\nDisadvantages of binary are that it is not human-readable, and not as portable as text. The latter is not a problem, since transforming into an acceptable format will be trivial. The former is likely a non-issue given the amount of data you are attempting to process anyway.\nKeep in mind that human readability is a relative term. A human can not read 40iGB of numerical data with understanding. A human can process A) a graphical representation of the data, or B) scan through relatively small portions of the data. Both cases are suitable for binary representations. Case A) is straightforward: load, transform and plot the data. This will be much faster if the data is already in a binary format that you can pass directly to the analysis and plotting routines. Case B) can be handled with something like a memory mapped file. You only ever need to load a small portion of the file, since you can't really show more than say a thousand elements on screen at one time anyway. Any reasonable modern platform should be able to keep upI\/O and binary-to-text conversion associated  with a user scrolling around a table widget or similar. In fact, binary makes it easier since you know exactly where each element belongs in the file.","Q_Score":2,"Tags":"python,numpy","A_Id":57680106,"CreationDate":"2019-08-27T17:48:00.000","Title":"Saving large numpy 2d arrays","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a project with venv that works just fine, but when we need to run roslaunch rosbridge_server rosbridge_websocket.launch it will result in the error below unless we deactivate venv.\n\nprocess[rosbridge_websocket-2]: started with pid [10182]\n  process[rosapi-3]: started with pid [10183]\n  Failed to load Python extension for LZ4 support. LZ4 compression will not be available.\n  Failed to load Python extension for LZ4 support. LZ4 compression will not be available.\n  registered capabilities (classes):\n   - \n   - \n   - \n   - \n   - \n   - \n   - \n   - \n  Traceback (most recent call last):\n    File \"\/opt\/ros\/kinetic\/lib\/rosbridge_server\/rosbridge_websocket\", line 44, in \n      from rosbridge_server import RosbridgeWebSocket, ClientManager\n    File \"\/opt\/ros\/kinetic\/lib\/python2.7\/dist-packages\/rosbridge_server\/init.py\", line 4, in \n      from .udp_handler import RosbridgeUdpSocket,RosbridgeUdpFactory\n    File \"\/opt\/ros\/kinetic\/lib\/python2.7\/dist-packages\/rosbridge_server\/udp_handler.py\", line 6, in \n      from twisted.internet.protocol import DatagramProtocol,Factory\n  ImportError: No module named 'twisted'\n\nI am assuming this is because there's no module named twisted installed in the virtual environment but it is installed on my computer. Following this hypothesis, this means that making roslaunch rosbridge_server rosbridge_websocket.launch work would require to install all the dependencies that it needs in venv? How would one go to do that?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":845,"Q_Id":57680190,"Users Score":1,"Answer":"just make sure the version of python you are using in venv and the environment where those packages are installed is same, if thats not the case, then you probably need to correct the python paths. \nMostly when you are running something in venv, the interpreter will only look inside that virtual environment, so when i face that issue, i just stopped using venv for ros and exported the pythonpaths or any ros module if they are installed for python3. distribution.","Q_Score":0,"Tags":"ros,python-venv","A_Id":57793913,"CreationDate":"2019-08-27T18:12:00.000","Title":"`roslaunch rosbridge_server rosbridge_websocket.launch` requires to deactivate venv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I know that I can do getpass.getuser() but that shows the user's name, not their account logon username and I want their account logon username","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":257,"Q_Id":57687239,"Users Score":0,"Answer":"No permission to edit.\nshould be pwd.getpwuid(os.getuid())[0]","Q_Score":1,"Tags":"python,python-3.x,user-accounts","A_Id":57687733,"CreationDate":"2019-08-28T07:39:00.000","Title":"How can I get the user's username?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using celery to do some distributed tasks and want to override celery_taskmeta and add some more columns. I use Postgres as DB and SQLAlchemy as ORM. I looked up celery docs but could not find out how to do it.\nHelp would be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1097,"Q_Id":57688644,"Users Score":2,"Answer":"I would suggest a different approach - add an extra table with your extended data. This table would have a foreign-key constraint that would ensure each record is related to the particular entry in the celery_taskmeta. Why this approach? - It separates your domain (domain of your application), from the Celery domain. Also it does not involve modifying the table structure that may (in theory it should not) cause trouble.","Q_Score":1,"Tags":"python,postgresql,sqlalchemy,celery","A_Id":57689713,"CreationDate":"2019-08-28T08:59:00.000","Title":"Overriding celery result table (celery_taskmeta) for Postgres","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have read that the method capitalize() is used to change the first letter of a string, from lowercase to uppercase.\nI am writing a small website in Django (first time) and I noticed that in the template section if I write item.description.capitalize() I get some error but, removing the parentheses it works, why?\nIsn't capitalize a method??","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":2276,"Q_Id":57689987,"Users Score":1,"Answer":"The Django template language is not Python, and is intended to provide restricted access to object methods and suchlike. It's explained in the documentation. item.description.capitalize calls a method capitalize with no arguments. There is no possibility of passing arguments.\nIt's possible to use the Jinja template language instead of Django's own. Jinja does provide full access to the underlying Python. It's more powerful but less efficient, and most people don't need it (most of the time). [Edit: maybe not more efficient, can't vouch for this, see comments]\nIt's also possible to write custom filters to do particular things that cannot be expressed in the raw template language. E.g. {{item.description|mycustomfilter:myonearg|...}}","Q_Score":1,"Tags":"python,django,string,methods","A_Id":57690171,"CreationDate":"2019-08-28T10:11:00.000","Title":"How capitalize() method works in python\/django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When creating an mlflow tracking server and specifying that a SQL Server database is to be used as a backend store, mlflow creates a bunch of table within the dbo schema. Does anyone know if it is possible to specify a different schema in which to create these tables?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":670,"Q_Id":57693162,"Users Score":1,"Answer":"It is possible to alter mlflow\/mlflow\/store\/sqlalchemy_store.py to change the schema of the tables that are stored. \nIt is very likely that this is the wrong solution for you, since you will go out of sync with the open source and lose newer features that alter this, unless you maintain the fork yourself. Could you maybe reply with your use case?","Q_Score":1,"Tags":"python,sqlalchemy,mlflow","A_Id":57862088,"CreationDate":"2019-08-28T13:06:00.000","Title":"Specify database backend store creation in specific schema","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When creating an mlflow tracking server and specifying that a SQL Server database is to be used as a backend store, mlflow creates a bunch of table within the dbo schema. Does anyone know if it is possible to specify a different schema in which to create these tables?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":670,"Q_Id":57693162,"Users Score":0,"Answer":"I'm using MSSQLServer as the backend store. I could use a different schema than dbo by specifying the default schema for the SQLServer user being used by MLFlow.\nIn my case, if the MLFlow tables (e.g: experiences) exist in dbo, then those tables will be used. If not, MLFlow will create those tables in the default schema.","Q_Score":1,"Tags":"python,sqlalchemy,mlflow","A_Id":63085202,"CreationDate":"2019-08-28T13:06:00.000","Title":"Specify database backend store creation in specific schema","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried pip uninstall airflow and pip3 uninstall airflow and both return \n\nCannot uninstall requirement airflow, not installed\n\nI'd like to remove airflow completely and run clean install.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2434,"Q_Id":57694246,"Users Score":5,"Answer":"Airflow now is apache-airflow.","Q_Score":1,"Tags":"python,ubuntu,airflow","A_Id":57694436,"CreationDate":"2019-08-28T14:01:00.000","Title":"how to remove airflow install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have get \n\nImportError: cannot import name 'deque' from 'collections'\n\nHow to resolve this issue? I have already changed module name (the module name is collections.py) but this is not worked.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3757,"Q_Id":57696747,"Users Score":0,"Answer":"In my case I had to rename my python file from keyword.py to keyword2.py.","Q_Score":2,"Tags":"python-3.x","A_Id":69260693,"CreationDate":"2019-08-28T16:38:00.000","Title":"ImportError: cannot import name 'deque' from 'collections' how to clear this?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have get \n\nImportError: cannot import name 'deque' from 'collections'\n\nHow to resolve this issue? I have already changed module name (the module name is collections.py) but this is not worked.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3757,"Q_Id":57696747,"Users Score":0,"Answer":"I had the same problem when i run the command python -m venv <env folder>. Renamed my file from: collections.py to my_collections.py.\nIt worked!","Q_Score":2,"Tags":"python-3.x","A_Id":58663455,"CreationDate":"2019-08-28T16:38:00.000","Title":"ImportError: cannot import name 'deque' from 'collections' how to clear this?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a homebrew binary fixed-point arithmetic support library and would like to add numpy array support. Specifically I would like to be able to pass around 2D arrays of fixed-point binary numbers and do various operations on them such as addition, subtraction, multiplication, rounding, changing of fixed point format, etc.\nThe fixed-point support under the hood works on integers, and separate tracking of fixed-point format data (number of integer and fractional bits) for range checking and type conversion.\nI have been reading the numpy documentation on ndarray subclassing and dtype, it seems like I might want at least a custom dtype, or separate dtype object for every unique range\/precision configuration of fixed-point numbers. I tried subclassing numpy.dtype in Python but that is not allowed.\nI'm not sure if I can write something to interoperate with numpy in the way I want without writing C level code - everything so far is pure Python, I have avoided looking under the covers at how to work on the C-based layer of numpy.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2338,"Q_Id":57702835,"Users Score":2,"Answer":"For anyone interested, this turned out to be too hard to do in Python extended Numpy, or just didn't fit the data model. I ended up writing a separate Python library of types implementing the behaviours I wanted, that use Numpy arrays of integers under the hood for speed.\nIt works OK and does the strict binary range calculation and checking that I wanted, but suffers Python code speed overhead especially with small arrays. If I had time I'm sure it could be done much better\/faster as a C library.","Q_Score":2,"Tags":"python,numpy-ndarray","A_Id":59026590,"CreationDate":"2019-08-29T04:06:00.000","Title":"How to implement fixed-point binary support in numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have nltk installed on my computer (Macbook, version 10.11.6).\nThe path reads as \/anaconda3\/lib\/python3.7\/site-packages\/nltk. \nWhen I try to import nltk using idle (Python 3.7.4), I keep getting the same:\n\n\"No module named 'nltk'\"\n\nerror. Not sure what I'm doing wrong?\nI have upgraded Python 3.7.2 to 3.7.4. I have also updated nltk to the most recent version available.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":412,"Q_Id":57703803,"Users Score":0,"Answer":"This is a duplicate of perhaps 20 other questions about failed module imports on macOS, especially when something like anaconda is installed.  You can find more information by searching through their answers.\nThe prime issue is that nltk is NOT 'installed on your computer'.  Rather, it is installed for exactly 1 python binary, which I suspect is '\/anaconda\/python3.exe'.  If you run a different python binary, such on the one that come with macOS or one installed with the python.org installer, that does not have nltk installed in its \/site-packages, that other python will not be able to import nltk.\nWhen running any python, one can discover which python and it site-packages directory by executing import sys; print(sys.executable, '\\n', sys.path).  One can then look in site-packages to see what is installed for that executable.\nUse pip to install nltk for other pythons.\nNote that people sometime have the opposite problem.  They install 3.x with the python.org installer, install some packages not included with anaconda, install anaconda, run anaconda's python, and then fine that imports that once worked no longer work.","Q_Score":0,"Tags":"python,anaconda,python-import,python-idle","A_Id":57761122,"CreationDate":"2019-08-29T05:56:00.000","Title":"Upon entering import nltk in Idle (Python 3.7.4), I get a ModuleNotFoundError: No module named \"nltk\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Installed python from scratch on computer and still throws an error anytime a .py file is being used whether it's my short script 'print('aa')' or some other utility (Jenkins Job Builder) which uses python script underneath dropping this line: Invalid -W option ignored: invalid module name: 'yaml' every time.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":561,"Q_Id":57704874,"Users Score":2,"Answer":"Module yaml is provided by PyYAML package, so do a \npip install PyYAML. \nHowever, look at your setup.py, dependencies should be configured properly and PyYAML should be installed as a dependency.","Q_Score":2,"Tags":"python,file,debugging,config","A_Id":57704928,"CreationDate":"2019-08-29T07:11:00.000","Title":"Python throws: Invalid -W option ignored: invalid module name: 'yaml'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to use Raspberry Pis to communicate collected Data via Python (Modbus TCP and RTU) scripts to a Database. These scripts are constantly running on the Pi and are connected to the Products where the data is coming from.\nConsequently, we have to ship the already set up Raspberry Pi to the Customer. Now the Problem occurs, that the Database Credentials are stored in the Python Scripts running on the Raspberry Pi.\nIs there a possibility to overcome this Problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":57705953,"Users Score":1,"Answer":"Naive solution: Store database credentials on your server (or somewhere on internet) so every time Raspberry Pi run the script, it connect to the server to get the credentials first.\nMy recommended solution: Create an API (may be web API) to communicate with database and Rasp Pi only work with this API. By this way, the client side doesn't know about database's credentials and some private things you want to hide also.","Q_Score":0,"Tags":"python,raspberry-pi3,raspbian","A_Id":57706159,"CreationDate":"2019-08-29T08:19:00.000","Title":"Hide Database Credentials in Python Code on Raspberry Pi","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":"Hi I want to click on 'Done' button in the virtual keyboard on android devices.\nHere i am entering an password in the devices after that i have to press 'Done' key in the virtual keyboard to proceed further.\nIs there any way to do this by using Python 2.7 and appium?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":835,"Q_Id":57707321,"Users Score":0,"Answer":"Use adb shell input keyevent 4 \nto close the keyboard and then use \nadb shell input keyevent 66  to press the enter key","Q_Score":0,"Tags":"python-2.7,robotframework,keypress,appium-android","A_Id":57731623,"CreationDate":"2019-08-29T09:38:00.000","Title":"How to press the 'Done' key in virtual board in android devices by using appium and python 2.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I get an image from an Android ImageView using Python Appium? This image should be in PNG format.\nI want to test if an icon has the correct image and I fail to use the method find_element_by_image provided by Appium.\nThe screenshot method doesn't seem to be ideal for me because it takes a screenshot instead of giving me the original image, which would contain the white background while the original image doesn't have it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1256,"Q_Id":57709096,"Users Score":4,"Answer":"Although I didn't find a way to get the image but I have found a workaround to test the images.\nYou can use element.screenshot(path) to save the correct images to a local folder. (of course use find_element_by_something to get the element) Then save the images to compare using element.screenshot(temp_path).\nFinally, from PIL import Image, ImageChops and use ImageChops.difference(Image.open(path1), Image.open(path2)) is None for image comparison. The expression returns True if they match pixelwise.","Q_Score":0,"Tags":"python,android,imageview,appium","A_Id":57719750,"CreationDate":"2019-08-29T11:23:00.000","Title":"Python Appium Get Image from Android ImageView","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Tensorflow has tf.data.Dataset.repeat(x) that iterates through the data x number of times. It also has iterator.initializer which when iterator.get_next() is exhausted, iterator.initializer can be used to restart the iteration. My question is is there difference when using tf.data.Dataset.repeat(x) technique vs iterator.initializer?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1504,"Q_Id":57711103,"Users Score":8,"Answer":"As we know, each epoch in the training process of a model takes in the whole dataset and breaks it into batches. This happens on every epoch.\nSuppose, we have a dataset with 100 samples. On every epoch, the 100 samples are broken into 5 batches ( of 20 each ) for feeding them to the model. But, if I have to train the model for say 5 epochs then, I need to repeat the dataset 5 times. Meaning, the total elements in the repeated dataset will have 500 samples ( 100 samples multipled 5 times ).\nNow, this job is done by the tf.data.Dataset.repeat() method. Usually we pass the num_epochs argument to the method.\nThe iterator.get_next() is just a way of getting the next batch of data from the tf.data.Dataset. You are iterating the dataset batch by batch.\nThat's the difference. The tf.data.Dataset.repeat() repeats the samples in the dataset whereas iterator.get_next() one-by-one fetches the data in the form of batches.","Q_Score":3,"Tags":"python,tensorflow,repeat","A_Id":57712269,"CreationDate":"2019-08-29T13:17:00.000","Title":"Difference between tf.data.Dataset.repeat() vs iterator.initializer","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to implement a new hash table with chaining as an array of lists.\nEach object in this inter list will be an implementation of a new class that I created (called \" search \" ).\nCan you please help me?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":57711850,"Users Score":0,"Answer":"well I managed to do that by myself so thanks anyway.\nafter I've learned about hash tables in Java last year i thought it's kinda the same (a special object ) but actually it is just as array of list in python.\nif someone else have a different way to do that I'd like to hear about it.","Q_Score":0,"Tags":"python-3.x,hashtable","A_Id":57729448,"CreationDate":"2019-08-29T13:59:00.000","Title":"how to create a new hash table","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recently bought a Hyperpixel 4.0 from pimoroni for my raspberry pi.\nI have also made a Pygame interface with the aim of using the touch screen as the input device.\nThis works perfectly when I am in the desktop interface, even when the window is full screen.\nHowever, I don't want to run it in the desktop, I want it to run in the terminal (no startx)\nWhen I do this, the mouse calibration is not correct and makes it unusable.\nI have tried several methods including forcing Pygame to detect the touch screen to no avail. It either works, it the mouse goes crazy.\nCan anyone help here? I can't find much online.\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":378,"Q_Id":57713766,"Users Score":0,"Answer":"The problem is that the Raspbian window system calibrates the Hyperpixel touch locations, but pygame directly accesses the touch device but is not calibrated.\nMy solution was to use a desktop application in full screen mode.\nI tried doing a matrix based calibration of my own, but it appears that the behavior is nonlinear.","Q_Score":0,"Tags":"python,pygame,mouse,touchscreen,calibration","A_Id":60443867,"CreationDate":"2019-08-29T15:49:00.000","Title":"Raspberry Pi Pygame touch screen issues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What does toPandas() actually do when using arrows optimization?\nIs the resulting pandas dataframe safe for wide transformations (that requires data shuffling) on the pandas dataframe eg..merge operations? what about group and aggregate? What kind of performance limitation should I expect?\nI am trying to standardize to Pandas dataframe where possible, due to ease of unit testing and swapability with in-memory objects without starting the monstrous spark instance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":279,"Q_Id":57714161,"Users Score":0,"Answer":"toPandas() takes your spark dataframe object and pulls all partitions on the client driver machine as a pandas dataframe.  Any operations on this new object (pandas dataframe) will be running on a single machine with python therefore no wide transformations will be possible because you aren't using spark cluster distributed computing anymore (i.e. no partitions\/worker node interaction).","Q_Score":0,"Tags":"python,pandas,apache-spark,apache-arrow","A_Id":57732477,"CreationDate":"2019-08-29T16:15:00.000","Title":"Spark Arrow, toPandas() and wide transformation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Altair package when I use following objects I have following error message. \nAttributeError: 'Chart' object has no attribute 'configure_facet_cell'\nIn order to use attribute above, what should I install or add?\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":549,"Q_Id":57717942,"Users Score":0,"Answer":"As per the comments this was created on an early version of the software and is no longer reproducible on current Altair versions.","Q_Score":2,"Tags":"python,bar-chart,configure,facet,altair","A_Id":66201863,"CreationDate":"2019-08-29T21:30:00.000","Title":"'Chart' object has no attribute 'configure_facet_cell'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script that does a json.dump of non-ascii text. It works fine with python3 but not with python2. That's fine, I use Anaconda's virtualenv facility to switch to python3 before running it.\nBut I having trouble trying to do this using Automator in Mac. Every time I have Automator run the script, it throws the same error I always see when I run it with Python2. I have tried everything, including making the script executable wih a shebang line that goes to python3. What am I doing wrong here?\nThe point here is that python3 handles unicode more gracefully than python2 and that's why I'm trying to use it.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":199,"Q_Id":57719363,"Users Score":1,"Answer":"Oops. It worked to invoke the script with:\n\n\/usr\/local\/bin\/python3 myScript.py","Q_Score":1,"Tags":"python,python-3.x,automator","A_Id":57719464,"CreationDate":"2019-08-30T01:19:00.000","Title":"Mac OSX Can't see to get Automator to run python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning Python (v 3.7) on a Mac using PyCharm. As I practice using the turtle library, the program runs without error, outputs the correct graphics, but then the graphics screen disappears immediately after the code completes runnning. Adding time.sleep(5) at the end of my program persists it and also shows that the focus changed from PyCharm to a Python program menu (which I can't find or turn on in the hope of keeping running). \nWhen I use Thonny, the output persists, so I can check my work. How can I make it persist in PyCharm?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":443,"Q_Id":57719474,"Users Score":1,"Answer":"A well-structured Python turtle program will end with a call to mainloop() or one of its variants (exitonclick(), done())  This turns control over to the underlying tkinter event handler which will keep your window open, awaiting user events.  Without this, the program simply ends and the window closes.\nYou don't need time.sleep() nor input(\"Press Enter to continue...\").  Some Python programming environments clash with mainloop() but even those tend to disable it behind the scenes so the same code works everywhere.","Q_Score":0,"Tags":"python,python-3.x,pycharm,turtle-graphics","A_Id":57735571,"CreationDate":"2019-08-30T01:35:00.000","Title":"How to persist Python turtle graphics screen","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is probably a really simple question, but I can't seem to find an answer online.\nI'm using a Google Cloud Function to generate a CSV file and store the file in a Google Storage bucket. I've got the code working on my local machine using a json service account.\nI'm wanting to push this code to a cloud function, however, I can't use the json service account file in the cloud environment - so how do I authenticate to my storage account in the cloud function?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":89,"Q_Id":57720636,"Users Score":4,"Answer":"You don't need the json service account file in the cloud environment.\nIf the GCS bucket and GCF are in the same project, you can just directly access it.\nOtherwise, add your GCF default service account(Note: it's App Engine default service account ) to your GCS project's IAM and grant relative GSC permission.","Q_Score":0,"Tags":"python-3.x,google-cloud-platform,google-cloud-functions,google-cloud-storage","A_Id":57721212,"CreationDate":"2019-08-30T04:47:00.000","Title":"Authenticating Google Cloud Storage SDK in Cloud Functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some legacy Keras\/Tensorflow code, which is unstable using latest Tensorflow versions (1.13+). It works just fine with previous versions. However i want to use Pytorch's Tensorboard support which requires it to be 1.14+. I've installed all Tensorflow-related packages to 1.10 and wanted to do just conda install tensorboard=1.14 but it removes tensorflow=1.10 as a requirement. I know that these packages are generally independent. How to upgrade tensorboard while keeping tensorflow old? Preferably i would like to use a single conda environment.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1279,"Q_Id":57723038,"Users Score":0,"Answer":"as @jdehesa suggested in the comments, it's better to have a different conda environment for pytorch and then install just the tb there\n!pip install tb-nightly","Q_Score":1,"Tags":"python,tensorflow,conda,tensorboard","A_Id":57727108,"CreationDate":"2019-08-30T08:15:00.000","Title":"Update Tensorboard while keeping Tensorflow old with conda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just installed pycharm 2019 edition. I have already installed python 3.7 in my system. My normal python program in pycharm is running fine i.e. printing hello world but I am not able to install packages like pandas and all. its showing error. 2nd thing i am not able to see latest version of pip that is been shown in pycharm.\nI have tried to do this with some changes in manage repositories but It didn't wokred\nWhile clicking on pip its showing \"Error loading package list:pypi.python.org\" this error message.\nI want to install packages but cant able to do it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":57724597,"Users Score":0,"Answer":"Please download Anaconda Distribution, which is basically made for pandas and all. You can use Spyder which is one of the best tools for Data Science. There you can easily install pandas.","Q_Score":0,"Tags":"python-3.x,pycharm","A_Id":57724691,"CreationDate":"2019-08-30T09:59:00.000","Title":"Error While installing packages in pycharm i.e pandas and all","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've three different machine learning models in python. To improve performance, I run them on different terminals in parallel. They are communicating and sharing data with one another through files. These models are creating batches of files to make available for other. All the processes are running in parallel but dependent on data prepared by other process. Once a process A prepares a batch of data, it creates a file to give signal to other process that data is ready, then process B starts processing it, while looking for other batch too simultaneously. How can this huge data be shared with next process without creating files? Is there any better way to communicate among these processes without creating\/deleting temporary files in python?\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":57726054,"Users Score":0,"Answer":"You could consider running up a small Redis instance... a very fast, in-memory data structure server.\nIt allows you to share strings, lists, queues, hashes, atomic integers, sets, ordered sets between processes very simply.\nAs it is networked, you can share all these data structures not only within a single machine, but across multiple machines.\nAs it has bindings for C\/C++, Python, bash, Ruby, Perl and so on, it also means you can use the shell, for example, to quickly inject commands\/data into your app to change its behaviour, or get debugging insight by looking at how variables are set.","Q_Score":0,"Tags":"process,ubuntu-16.04,python-3.5","A_Id":57726305,"CreationDate":"2019-08-30T11:38:00.000","Title":"What is the best way to communicate among multiple processes in ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When considering the problem of classifying an input to one of 2 classes, 99% of the examples I saw used a NN with a single output and sigmoid as their activation followed by a binary cross-entropy loss.  Another option that I thought of is having the last layer produce 2 outputs and use a categorical cross-entropy with C=2 classes, but I never saw it in any example.\nIs there any reason for that?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":636,"Q_Id":57726064,"Users Score":2,"Answer":"If you are using softmax on top of the two output network you get an output that is mathematically equivalent to using a single output with sigmoid on top.\nDo the math and you'll see.\nIn practice, from my experience, if you look at the raw \"logits\" of the two outputs net (before softmax) you'll see that one is exactly the negative of the other. This is a result of the gradients pulling exactly in the opposite direction each neuron.\nTherefore, since both approaches are equivalent, the single output configuration has less parameters and requires less computations, thus it is more advantageous to use a single output with a sigmoid ob top.","Q_Score":1,"Tags":"python,pytorch,cross-entropy","A_Id":57726399,"CreationDate":"2019-08-30T11:39:00.000","Title":"Binary cross entropy Vs categorical cross entropy with 2 classes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a script in selenium python which is basically opening up a website and clicking on links in it and doing this thing multiple times..\nPurpose of the software was to increase traffic on the website but after script was made it has observed that is not posting real traffic on website while website is just taking it as a test and ignoring it.\nNow I am wondering whether it is basically possible with selenium or not? \nI have searched around and I suppose it is possible but don't know how. Do anyone know about this? Or is there any specific piece of code for this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1011,"Q_Id":57729315,"Users Score":0,"Answer":"It does create traffic, the problem is websites sometimes defends from bots and can guess if the income connection is a bot or not, maybe you should put some time.wait(seconds) between actions to deceive the website control and make it thinks you are a person","Q_Score":1,"Tags":"python,selenium,automation,web-traffic","A_Id":57729437,"CreationDate":"2019-08-30T15:12:00.000","Title":"Can selenium post real traffic on a website?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I accidentally downloaded the 32-bit version of Python on my Win 10 (64bit). I uninstalled it, reinstalled the correct version, deleted all other python files\/folders that I had, also reinstalled Anaconda, but I keep getting the same error when I try to do some stuff in Jupyter.\nIs there a way to fix this? Am I missing a file that is still the 32 bit version which is why my PC keeps detecting and selecting the 32bit python version as well?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":275,"Q_Id":57731014,"Users Score":1,"Answer":"Alright, it seems I have indeed missed some files in AppData when removing the wrong python bit version. Removed all files, and installed Anaconda and 64bit Python again (making sure no old files were on my PC), and it finally works.","Q_Score":1,"Tags":"python-3.x,jupyter-notebook,path-variables,python-windows-bundle","A_Id":57732194,"CreationDate":"2019-08-30T17:32:00.000","Title":"Getting \"OSError: [WinError 193] %1 is not a valid Win32 application\" error even after reinstalling the right version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I understand that below are the scoping levels in python (listed in highest to lowest order)\n\nLocal(L): Defined inside function\/class\nEnclosed(E): Defined inside enclosing functions(Nested function concept)\nGlobal(G): Defined at the uppermost level\nBuilt-in(B): Reserved names in Python builtin modules\n\nI understand this concept when we have a single file. I am trying to understand how this concept of namespace, local, enclosed, global, built-in works when using import in python.\nI understand we can import using foll. approaches:\n\nimport modulename\nimport modulename.function(function\/variable)\nimport package.module.function(function\/variable)\nfrom module import function(function\/variable)\nfrom package import module\nfrom package.module import function(function\/variable)\nfrom module import *\nfrom package import *\n\nI know that in each of the above the entire module is loaded in the sys modules dictionary. But I am confused with respect to namespace, scope, global, local. I want to understand LEGB principle, namespace, global, localwith respect to the method of import vs from import. I have read that in case of point 1 (import modulename), the modulename is loaded in its own namespace and reference is available to the calling module with which it can change the variable values globally. Does this also mean it is in global namespace? Any if so then global with respect to what? Also I have read that from module import function\/variable or from module import * brings function(s)\/variable(s) in the calling modules namespace and any changes are not global. Does this mean that it is in local namespace? Local with respect to what?\nExample:\nSay module foo has a variable bar=10. When we use [import foo] - this brings foo in current namespace and allows us to change the value of bar via foo.bar=1000 and this change is visible to every piece of code that makes use of [import foo  print(foo.bar)] after the above assignment was made. Where as in case of [from foo import bar], any change made to bar is only visible to this module and not any other module irrespective of whether they do an [import foo] or [from foo import bar] they would see value of bar as 10.\nAny reference\/links in this area will be very helpful. I want to understand the basics of how this works internally. Any information will be helpful to understand this. Articles that I found on this topic explain what is import vs from xx import yy. But they don't explain why\/how the changes made become global (in case of import) vs local (in case of from import).\nSome more examples:\nIn below code example, change made to a is only seen in the main.py file and does not affect the value of a in module1.py and subsequent modules that import module1.py will still see the value of a as 10.\nmodule1.py:\na=10\nmain.py:\nfrom module1 import a\nprint(a)\na=100\nWhereas if we used import module1 instead of from module1 import a then the assignment would have changed value of a in module1.py and any subsequent import of module1.py would show the value of a as 100.\nNote: Similarly we could also have functions inside the module.py that get and set the value of variable 'a'. And using this approach, once we do a 'from module1 import getfn, setfn' in main.py, we can use these functions which when called make the change to variable 'a' and this change is globally visible.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":484,"Q_Id":57732323,"Users Score":0,"Answer":"Python has only 3 scopes: global local and builtin.\nThey are relative to the position in the code\nEvery variable whose value you can change is local\n(note that changing global variable results in creating a new local variable instead,\nso there are local and global variable of the same name)\nEnclosed you speak of are local to that function\nEvery variable with unchangeable content whose value you can get is global\nBuiltin variables are exactly like global so they can even be considered global\nto see what variables are global and what are local, put this line in your code\nprint(\"global:\", globals(), \"\\n\\nlocal:\", locals())","Q_Score":1,"Tags":"python,python-3.x,python-import","A_Id":57732924,"CreationDate":"2019-08-30T19:31:00.000","Title":"Concept of namespace, global, local with respect to import","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I understand that below are the scoping levels in python (listed in highest to lowest order)\n\nLocal(L): Defined inside function\/class\nEnclosed(E): Defined inside enclosing functions(Nested function concept)\nGlobal(G): Defined at the uppermost level\nBuilt-in(B): Reserved names in Python builtin modules\n\nI understand this concept when we have a single file. I am trying to understand how this concept of namespace, local, enclosed, global, built-in works when using import in python.\nI understand we can import using foll. approaches:\n\nimport modulename\nimport modulename.function(function\/variable)\nimport package.module.function(function\/variable)\nfrom module import function(function\/variable)\nfrom package import module\nfrom package.module import function(function\/variable)\nfrom module import *\nfrom package import *\n\nI know that in each of the above the entire module is loaded in the sys modules dictionary. But I am confused with respect to namespace, scope, global, local. I want to understand LEGB principle, namespace, global, localwith respect to the method of import vs from import. I have read that in case of point 1 (import modulename), the modulename is loaded in its own namespace and reference is available to the calling module with which it can change the variable values globally. Does this also mean it is in global namespace? Any if so then global with respect to what? Also I have read that from module import function\/variable or from module import * brings function(s)\/variable(s) in the calling modules namespace and any changes are not global. Does this mean that it is in local namespace? Local with respect to what?\nExample:\nSay module foo has a variable bar=10. When we use [import foo] - this brings foo in current namespace and allows us to change the value of bar via foo.bar=1000 and this change is visible to every piece of code that makes use of [import foo  print(foo.bar)] after the above assignment was made. Where as in case of [from foo import bar], any change made to bar is only visible to this module and not any other module irrespective of whether they do an [import foo] or [from foo import bar] they would see value of bar as 10.\nAny reference\/links in this area will be very helpful. I want to understand the basics of how this works internally. Any information will be helpful to understand this. Articles that I found on this topic explain what is import vs from xx import yy. But they don't explain why\/how the changes made become global (in case of import) vs local (in case of from import).\nSome more examples:\nIn below code example, change made to a is only seen in the main.py file and does not affect the value of a in module1.py and subsequent modules that import module1.py will still see the value of a as 10.\nmodule1.py:\na=10\nmain.py:\nfrom module1 import a\nprint(a)\na=100\nWhereas if we used import module1 instead of from module1 import a then the assignment would have changed value of a in module1.py and any subsequent import of module1.py would show the value of a as 100.\nNote: Similarly we could also have functions inside the module.py that get and set the value of variable 'a'. And using this approach, once we do a 'from module1 import getfn, setfn' in main.py, we can use these functions which when called make the change to variable 'a' and this change is globally visible.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":484,"Q_Id":57732323,"Users Score":2,"Answer":"You're over complicating things. From the point of view of imports, the only thing to know is that import foo brings foo into the current namespace, and from foo import bar brings bar into the current namespace.","Q_Score":1,"Tags":"python,python-3.x,python-import","A_Id":57732647,"CreationDate":"2019-08-30T19:31:00.000","Title":"Concept of namespace, global, local with respect to import","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is the running time of   __len__(self)   of a custom created object, O(1) as is for the built-in types for the CPython implementation;","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":71,"Q_Id":57732430,"Users Score":1,"Answer":"Well for a built-in python object, they are O(1) because they keep track of their length which is accessed with __len__(). If the custom created object does this, or inherits from an object that does, then yes. It depends how it is implemented. I could put a loop in __len__() that does not take O(1) time.","Q_Score":0,"Tags":"python,class,big-o","A_Id":57732481,"CreationDate":"2019-08-30T19:40:00.000","Title":"Python's len() Big O notation for custom created class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is the running time of   __len__(self)   of a custom created object, O(1) as is for the built-in types for the CPython implementation;","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":57732430,"Users Score":0,"Answer":"I think the built-in types just return self.length, where length is an updated value attached to the object","Q_Score":0,"Tags":"python,class,big-o","A_Id":57732499,"CreationDate":"2019-08-30T19:40:00.000","Title":"Python's len() Big O notation for custom created class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to download a file from onedrive or google drive using wget or a faster method!\nI've tried lots of code i could find on the internet but have not had any luck.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":153,"Q_Id":57733624,"Users Score":1,"Answer":"This has worked for me to download a non-protected-link file:\n\nGo to your OneDrive\nClick on the share link and copy. It will look like: https:\/\/...\/EvZJeK2tIMOs54OA?<other-stuff>\nAppend download=1 after ?  looking like https:\/\/...\/EvZJeK2tIMOs54OA?download=1\n\nNow you can use it with wget like:\nwget https:\/\/...\/EvZJeK2tIMOs54OA?download=1 -O <output-file-name\\>.<extension\\>\nNote: The -O (capital O) is to define an output name otherwise it will have EvZJeK2tIMOs54OA?download=1 as the file name.","Q_Score":0,"Tags":"python","A_Id":71328453,"CreationDate":"2019-08-30T21:57:00.000","Title":"How to download file from one drive\/google drive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So i want to implement random search but there is no clear cut example as to how to do this. I am confused between the following methods:\n\ntune.randint()\nray.tune.suggest.BasicVariantGenerator()\ntune.sample_from(lambda spec: blah blah np.random.choice())\n\nCan someone please explain how and why these methods are same\/different for implementing random search.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":57733690,"Users Score":0,"Answer":"Generally, you don't need to use ray.tune.suggest.BasicVariantGenerator(). \nFor the other two choices, it's up to what suits your need. tune.randint() is just a thin wrapper around tune.sample_from(lambda spec: np.random.randint(...)). You can do more expressive\/conditional searches with the latter, but the former is easier to use.","Q_Score":0,"Tags":"python,ray","A_Id":57743094,"CreationDate":"2019-08-30T22:08:00.000","Title":"what are the options to implement random search?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to print out text with PyAutoGUI, and I have my keyboard set to Dvorak, so whenever I print out text, it comes out with incorrect characters. For example, \"Hello World!\" comes out as \"Jdpps <soph!\".\nThe same thing happens when I put the string in a variable too.\nIs there a way to make it print out the text literally as I typed it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1074,"Q_Id":57734744,"Users Score":1,"Answer":"So what I ended up doing was creating a file .xkbmap-qwerty in my home directory, and then ran os.system(\"xmodmap ~\/.xkbmap-qwerty\") to load the keys, and then it didn't affect my shell when the program exited, or even while the program was running.\nHere's my file:\n\n\n\n    keysym q = q Q\n    keysym w = w W\n    keysym e = e E\n    keysym r = r R\n    keysym t = t T\n    keysym y = y Y\n    keysym u = u U\n    keysym i = i I\n    keysym o = o O\n    keysym p = p P\n    keysym bracketleft = bracketleft braceleft\n    keysym bracketright = bracketright braceright\n    keysym a = a A\n    keysym s = s S\n    keysym d = d D\n    keysym f = f F\n    keysym g = g G\n    keysym h = h H\n    keysym j = j J\n    keysym k = k K\n    keysym l = l L\n    keysym semicolon = semicolon colon\n    keysym quoteright = quoteright quotedbl\n    keysym z = z Z\n    keysym x = x X\n    keysym c = c C\n    keysym v = v V\n    keysym b = b B\n    keysym n = n N\n    keysym m = m M\n    keysym comma = comma less\n    keysym period = period greater\n    keysym slash = slash question\n    keysym 1 = 1 exclam\n    keysym 2 = 2 at\n    keysym 3 = 3 numbersign\n    keysym 4 = 4 dollar\n    keysym 5 = 5 percent\n    keysym 6 = 6 asciicircum\n    keysym 7 = 7 ampersand\n    keysym 8 = 8 asterisk\n    keysym 9 = 9 parenleft\n    keysym 0 = 0 parenright\n    keysym minus = minus underscore\n    keysym equal = equal plus","Q_Score":2,"Tags":"python,pyautogui","A_Id":57734836,"CreationDate":"2019-08-31T02:22:00.000","Title":"How to Change Keyboard in Python PyAutoGUI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a virtual environment with python 3.6 and installed various packages using pip, when i do pip install tensorflow it says \"Requirement already satisfied\". However when i import it, I get No module name tensorflow.python","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":57736407,"Users Score":0,"Answer":"And as every guy should know the very first solution of every problem...\nUninstall and reinstall\nYep, It worked.","Q_Score":0,"Tags":"python-3.x,tensorflow","A_Id":57890422,"CreationDate":"2019-08-31T08:28:00.000","Title":"pip list cmd shows tensorflow installed but cant import it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I trace code in the PyCharm debugger, and an error occurs, the next thing the debugger is showing me is the parent method and if I keep stepping, it just walks back up the stack to eventually print me an error.\nIs there a way to get the debugger to tell you there is an error where\/when the error happens instead of sending you to the parent? (like it pretty much every debugger in any language)\nTo illustrate, if I have the following calls:\nfunc1 -> func2 -> func3\nand I'm tracing code in func3; if an error happens, the next step is the return to func2, then if I step, return to func1, then an error message is printed in the console.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":37,"Q_Id":57737857,"Users Score":1,"Answer":"That feeling of \"next step\" returning to the parent function instead is because an exception is currently propagating. You are being bubbled up until an exception handler is found.\nYou should let the exception propagate, get the stack trace, then place a breakpoint at the raise statement\nOptionally, using the debugger to execute import logging; logging.exception('give me mah exception!\") or similar command may give you the current exception. \nNote that if you are stepping over a function call, and that function raises an exception, you won't have, by default, a stop on the inner statement that raises. You can configure this in Run > View Breakpoints, however, as far as i know, you can't distinguish between 'an exception that is raised and caught internally' in the statement you are stepping over and 'an exception that is raised but not caught internally'.","Q_Score":0,"Tags":"python,pycharm","A_Id":57737944,"CreationDate":"2019-08-31T12:04:00.000","Title":"How to get the debugger to stop at the right place in PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have one question \nwhy SARIMAX takes lot of time for execution ??\nlength of data is only 2200 , if i take period (24 or 168 or 365) it takes so much time \nwhile , for monthly data(2200 entries ) period is 12 , it does not take much time !!\nis there any way to solve this problem??","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":161,"Q_Id":57738982,"Users Score":1,"Answer":"Unfortunately, there is not much that can be done. Estimation via the SARIMAX model requires a lot of matrix operations, and if you have e.g. seasonal_order=(1, 0, 0, 365), then you're going to have matrices at least sized 365 x 365, and if you increase to seasonal_order=(1, 0, 0, 365) then you have at least 730 x 730. Even for moderate seasonal periods with long lag lengths, the operations are just going to take some time.\nOne option that was recently introduced (it is not yet in a released version, so you would have to install the latest version from Github) that can improve things somewhat is to fit the model using options low_memory=True and cov_type='none'. Two things to keep in mind:\n\nThere is no getting around the matrix operations that have to be performed, so this will not be a massive speedup. The best case may be on the order of a 10x speedup.\nThis will limit the things you can do post-estimation. You can still do out-of-sample forecasting, but not in-sample dynamic prediction, and you won't see standard errors for estimated parameters.","Q_Score":0,"Tags":"python,statsmodels","A_Id":57747940,"CreationDate":"2019-08-31T14:44:00.000","Title":"SARIMAX customisation in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need an equivalent of Processing's 'map()' function in order to map a integer that can have a range of 0, 1000 to a range of 255, 0. It doesn't necessarily have to be a universal function, it can be a hard-coded expression suited purely to this range.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":514,"Q_Id":57739846,"Users Score":0,"Answer":"you can use for to solve such expression with using map function. please cross check my line.\nthank you","Q_Score":2,"Tags":"python-3.x","A_Id":57746414,"CreationDate":"2019-08-31T16:35:00.000","Title":"Is there a Processing 'map()' equivalent for python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to set the source IP address for UDP multicast packages to something else than the interface IP?\nI am trying to write a small router that selectively routes UDP SSDP packages from one network to another. The plan is to do it in python, although I am flexible on that.\nIt seems fairly easy to route SSDP NOTIFY messages: I receive them on one interface and decide which interface to re-broadcast them on. However the protocol for M-SEARCH messages require that the source IP is set to the original source of the message as any service that chooses to respond will respond with a unicast message to the source IP and port.\nExample (heavily simplified):\n\nNetwork A: 192.168.10.0\/24\nNetwork B: 192.168.11.0\/24\nMy router application runs on a multihomed computer on 192.168.10.2 and 192.168.11.2.\n\nA client on network A with IP 192.168.10.10 sends an M-SEARCH message:\n\nSrc IP\/Port: 192.168.10.10 port 40000\nDst IP\/Port: 239.255.255.250 port 1900\n\nMy \"router application\" on 192.168.10.2 receives the packet and would like to rebroadcast it on network B. However I cannot find any method in the socket API that allows me to set the source IP address. Only to pick the source interface.\nThus the rebroadcasted packet now looks like this:\n\nSrc IP\/Port: 192.168.11.2 port xxxxx\nDst IP\/Port: 239.255.255.250 port 1900\n\nAnd now the receiving service is unable to unicast back to the client as the original IP and port are lost.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":403,"Q_Id":57744381,"Users Score":3,"Answer":"How to set the source IP address for UDP multicast packages to something else than the interface IP?\n\nThe only way I know of is to use a RAW socket and construct the IP headers manually.  Note that use of RAW sockets is typically restricted to admin users on most platforms.\n\nHowever I cannot find any method in the socket API that allows me to set the source IP address. \n\nBecause there isn't one.\n\nAnd now the receiving service is unable to unicast back to the client as the original IP and port are lost.\n\nCan't you just have your router remember the original source when it receives the M-SEARCH request, and when it receives the unicast reply then forward it to the original requester? That is how most routers usually work.","Q_Score":0,"Tags":"python,sockets,multicast","A_Id":57752433,"CreationDate":"2019-09-01T08:26:00.000","Title":"Setting source address when sending UDP multicast messages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"[warning VSCode newbie here]\nWhen installing pylinter from within VScode I got this message:\nThe script isort.exe is installed in 'C:\\Users\\fjanssen\\AppData\\Roaming\\Python\\Python37\\Scripts' which is not on PATH.\nWhich is correct. However, my Python is installed in C:\\Program Files\\Python37\\\nSo I am thinking Python is installed for all users, while pylinter seems to be installed for the user (me).\nChecking the command-line that VScode threw to install pylinter it indeed seems to install for the user:\n\n& \"C:\/Program Files\/Python37\/python.exe\" -m pip install -U pylint --user\n\nSo, I have some questions on resolving this issue;\n1 - how can I get the immediate issue resolved?\n- remove pylinter as user\n- re-install for all users\n2 - Will this (having python installed for all users) keep bugging me in the future? \n- should I re-install python for the current user only when using it with VScode?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2269,"Q_Id":57744390,"Users Score":1,"Answer":"If the goal is to simply use pylint with VS Code, then you don't need to install it globally. Create a virtual environment and select that in VS Code as your Python interpreter and then pylint will be installed there instead of globally. That way you don't have to worry about PATH.","Q_Score":1,"Tags":"python,visual-studio-code","A_Id":57983283,"CreationDate":"2019-09-01T08:27:00.000","Title":"Python Linter installation issue with VScode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have multiple process excute at the same time and they have some endless for loop or while loop to monitor some data in the network.At the moment I am using thread to execute them and stop as per the certain codition.\nIn this scenario which one is better?\n1.Multiprocess\n2.Multi threading\n3.asyncio\nOne thing I want to mention the process which are execute simultaneously, they are not dependent each other.\nPlease share  your thought\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":57744819,"Users Score":0,"Answer":"before going tweak your server code , do check the possibility of device-side-slow-update.  \nbesides that, in my opinion you are in a many-short-read-few-long-write pattern\ndivide your reading and updating payload should be the first thing to consider\nhandling read and update sequentially in one thread , may suffer heavy impact when facing a burst of high number of update.  \nyou can start by setting up two thread pool , one for read and one for update\nand tweak thread pool size based on benchmark stats\nif  cpu usage keeps on high (> 70%) , go asyncio  \nbtw: update your question is better than leave your information in comments","Q_Score":0,"Tags":"python-3.x","A_Id":57745512,"CreationDate":"2019-09-01T09:33:00.000","Title":"To speed up python programming","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am setting up a new column as the day difference in Python (on Jupyter notebook). \nI carried out the day difference between the column date and current day. Also, I carried out that the day difference between the date column and newly created day via current day (Current day -\/+ input days with timedelta function). \nHowever, whenever I use max() of the same column and different column, the day difference column has NaN values. It does not make sense for me, maybe I am missing the date type. When I checked the types all of them seems datetime64 (already converted to datetime64 by me). \nI thought that the reason was having not big enough date. However, it happens with any specific date like max(datecolumn)+timedelta(days=i). \n\n\nt=data_signups[[\"date_joined\"]].max()\n\n\ndate_joined   2019-07-18 07:47:24.963450\ndtype: datetime64[ns]\n\n\nt = t + timedelta(30)\n\n\ndate_joined   2019-08-17 07:47:24.963450\ndtype: datetime64[ns]\n\n\ndata_signups['joined_to_today'] = (t - data_signups['date_joined']).dt.days\ndata_signups.head(2)\n\n\nshortened...\n\ndate_joined_______________\/\/  joined_to_today________\n2019-05-31 10:52:06.327341  \/\/  nan\n2019-04-02 09:20:26.520272  \/\/  nan\n\nHowever it worked on Current day task like below.\n\n\nCurrentdate = datetime.datetime.now()\n    print(Currentdate)\n    2019-09-01 17:05:48.934362\nbefore_days=int(input(\"Enter the number of days before today for analysis \")) \n30\n\n\nDone\n\n\nlast_day_for_analysis = Currentdate - timedelta(days=before_days)\nprint(last_day_for_analysis)\n\n\n2019-08-02 17:05:48.934362\n\n\ndata_signups['joined_to_today'] = (last_day_for_analysis - data_signups['date_joined']).dt.days\ndata_signups.head(2)\n\n\nshortened...\n\ndate_joined_______________\/\/  joined_to_today________\n2019-05-31 10:52:06.327341  \/\/  63\n2019-04-02 09:20:26.520272  \/\/  122\n\nI expect that there is datetype problem. However, I could not figure out since all of them are datetime64. There are no NaN values in the columns.\nThank you for your help. I am newbie and I try to learn everyday continuously.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":57746737,"Users Score":0,"Answer":"Although I was busy with this question for 2 days, now I realized that I had a big mistake. Sorry to everyone. \nThe reason that can not take the maximum value as date comes from as below.\nExisting one: t=data_signups[[\"date_joined\"]].max()\nMust-be-One:  t=data_signups[\"date_joined\"].max()\nSo it works with as below.\ndata_signups['joined_to_today'] = (data_signups['date_joined'].max() - data_signups['date_joined']).dt.days\ndata_signups.head(3)\nThere will be no two brackets. So stupid mistake. Thank you.","Q_Score":0,"Tags":"python,pandas,datetime64","A_Id":57747241,"CreationDate":"2019-09-01T14:17:00.000","Title":"How to get the day difference between date-column and maximum date of same column or different column in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a beginner in python and want to know how to take just the user specified number of inputs in one single line and store each input in a variable.\nFor example:\nSuppose I have 3 test cases and have to pass 4 integers separated by a white space for each such test case.\nThe input should look like this:\n3\n1 0 4 3\n2 5 -1 4\n3 7 1 9\nI know about the split() method that helps you to separate integers with a space in between. But since I need to input only 4 integers, I need to know how to write the code so that the computer would take only 4 integers for each test case, and then the input line should automatically move, asking the user for input for the next test case.\nOther than that, the other thing I am looking for is how to store each integer for each test case in some variable so I can access each one later.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":57746739,"Users Score":0,"Answer":"For the first part, if you would like to store input in a variable, you would do the following...\n    (var_name) = input()\nOr if you want to treat your input as an integer, and you are sure it is an integer, you would want to do this\n    (var_name) = int(input())\nThen you could access the input by calling up the var_name.\nHope that helped :D","Q_Score":0,"Tags":"python-3.x,input","A_Id":57750161,"CreationDate":"2019-09-01T14:17:00.000","Title":"Taking specified number of user inputs and storing each in a variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a django website with PostgreSQL database hosted on one server with a different company and a mirror of that django website is hosted on another server with another company which also have the same exact copy of the PostgreSQL database . How can i sync or update that in real time or interval","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":103,"Q_Id":57750703,"Users Score":0,"Answer":"Postgresql has master-slave replication. Try That!","Q_Score":1,"Tags":"django,python-3.x,postgresql","A_Id":57750738,"CreationDate":"2019-09-02T01:58:00.000","Title":"How can i update one PostgreSQL database and sync changes\/updates to another PostgreSQL database on another server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm making a replacement for a very out of date application at work written in possibly Delphi (don't have source code) and decided to use Python with wx.\nThe old one behaves such that when you alt+tab or peek on the task bar icon it only shows the main window as an entry but if you bring it to front all other windows created by it are brought up as well.\nIn wx every subframe I open becomes it's own entry and you have to manually focus each and every one. Is there a way to achieve the above-mentioned behavior with wx?\nI tried setting the main frame as a parent but that didn't do nothing.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":57751480,"Users Score":0,"Answer":"So my model was go through login to a 'Mainframe', sort of a task panel from where you'd open up other windows. These 'Subframes' were each a wx.Frame with wx.Panel in them.\nSimply changing the subFrame1(wx.Frame) to subFrame1(wx.Dialog) solved my issue - the dialogs do not appear in the alt+tab menu, nor in taskbar and upon selecting the Mainframe everything is brought to front.","Q_Score":0,"Tags":"python,windows,wxpython","A_Id":57860559,"CreationDate":"2019-09-02T04:35:00.000","Title":"Binding wx Frames together","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have problem with my VSC, when i hit Shift+Enter it execute selected line in Ipython, however when i hit CTRL+SHIFT+ENTER it starts jupyter notebook and execute whole file.\nIs is possible to disable jupyter notebook ? Is is possible to make \"CTRL+SHIFT+ENTER\" to execute whole file in Ipython?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1331,"Q_Id":57755576,"Users Score":0,"Answer":"Drac0. If you want to take a look at the keybindings for the python extension first open up the keyboard shortcuts window in VSCode (Ctrl-Shift-P for the command palette then pick Perferences: Open Keyboard Shortcuts). Then in that window type Python to see the current keybindings. Any commands that talk about Python Interactive Window refer to the Jupyter interface, while any Terminal commands refer to the standard terminal. You can change any of the keybindings here to how you want them.","Q_Score":2,"Tags":"python,visual-studio-code,jupyter-notebook","A_Id":57779084,"CreationDate":"2019-09-02T10:45:00.000","Title":"Visual studio code - disable jupyter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have problem with my VSC, when i hit Shift+Enter it execute selected line in Ipython, however when i hit CTRL+SHIFT+ENTER it starts jupyter notebook and execute whole file.\nIs is possible to disable jupyter notebook ? Is is possible to make \"CTRL+SHIFT+ENTER\" to execute whole file in Ipython?","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1331,"Q_Id":57755576,"Users Score":-1,"Answer":"Ctrl + K Ctrl + S \u2192 Open Keyboard Shortcuts.\nType jupyter.\nRemove the keybinding.","Q_Score":2,"Tags":"python,visual-studio-code,jupyter-notebook","A_Id":65146667,"CreationDate":"2019-09-02T10:45:00.000","Title":"Visual studio code - disable jupyter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem in which I have to show data entered into a database without having to press any button or doing anything.\nI am creating an app for a hospital, it has two views, one for a doctor and one for a patient.\nI want as soon as the patient enters his symptoms, it shows up on doctor immediately without having to press any button.\nI have no idea how to do this.\nAny help would be appreciated.\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":955,"Q_Id":57756447,"Users Score":0,"Answer":"You can't do that with Django solely. You have to use some JS framework (React, Vue, Angular) and WebSockets, for example.","Q_Score":1,"Tags":"python,django,django-signals","A_Id":57756507,"CreationDate":"2019-09-02T11:48:00.000","Title":"How to automatically update view once the database is updated in django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm looking for a way publishing Celery messages to SNS topic, to be subscribed by multiple queues. \nThe reason I would like to do so, is that I'm trying to implement Multiple Receivers pattern using Celery \nI.e every service will get all the messages were published, and execute only the relevant ones. All the rest will be acknowledged","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":663,"Q_Id":57756593,"Users Score":1,"Answer":"You need to dig deeply into the SQS transport to find out the format of the Celery messages, and then implement publishing via SNS... Celery does not provide this out-of-box. I am sure Celery team would welcome this as some kind of utility addition, or similar. It would be a useful feature.","Q_Score":1,"Tags":"python,amazon-web-services,celery,amazon-sqs,amazon-sns","A_Id":57767596,"CreationDate":"2019-09-02T11:59:00.000","Title":"Celery publish messages using SNS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm looking for a way publishing Celery messages to SNS topic, to be subscribed by multiple queues. \nThe reason I would like to do so, is that I'm trying to implement Multiple Receivers pattern using Celery \nI.e every service will get all the messages were published, and execute only the relevant ones. All the rest will be acknowledged","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":663,"Q_Id":57756593,"Users Score":0,"Answer":"The pattern we are going to implement is an event bus, where each microservice have its own queue.\nI.e for each service we will have 2 queues, one subscribed to SNS topic, second for the worker. the first will be consumed by a poller, inserting new jobs to worker queue.\nThis will allow decoupling between two services, i.e one service can be down while the second appends new messages to the queue","Q_Score":1,"Tags":"python,amazon-web-services,celery,amazon-sqs,amazon-sns","A_Id":57855056,"CreationDate":"2019-09-02T11:59:00.000","Title":"Celery publish messages using SNS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Can we use library installed in one virtual environment from another virtual environment?\n\nFor eg:\n\nLibrary installed in venv from another virtual environment.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":486,"Q_Id":57759298,"Users Score":-1,"Answer":"Short answer: No\nVirtual environment's purpose is to isolate different python instalation, including their libraries. If you ever find a way to do this, it must be considered a hack and should be reported to virtual environment as a bug.","Q_Score":0,"Tags":"python,python-venv","A_Id":57759404,"CreationDate":"2019-09-02T15:12:00.000","Title":"Using library installed in one virtual environment in another virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m trying to run a python script via execute shell script in Jenkins. \nFrom my understanding Jenkins is using its own shell or Python interpreter which is different from the local environment. \nI.e , running the command python -V from Jenkins executing shell I\u2019m getting 2.7.12 version\nIn terminal running python -V I\u2019m getting 3.7.0\nWhich I aliased \u201cpython\u201d in bash_aliases to \/usr\/local\/bin\/python3.7\nI\u2019d like to be able to run in a specific Jenkins project the python that I\u2019m using locally. \nAll of what I\u2019ve tried is trash so it is not worth to share this garbage... \nWhat is the right way to be able to run the python I want without changing Jenkins configurations.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4308,"Q_Id":57759310,"Users Score":0,"Answer":"Multiple ways to think of an answer to your question,\n\nAdd a Jenkins slave where you could configure the Python3 installation path as a tool\nIf allowed add your local machine where you have installed python3 as a Jenkins slave, that will help you to execute the script in your environment directly.\nI hope you have added shebang line in your python script, that is the best way to instruct your script to use any specific python installation to execute the script.\nIf the Jenkins slave has the required package installed in a shared location or afs location, that can be utilized while executing the python script.","Q_Score":0,"Tags":"python,jenkins","A_Id":57760032,"CreationDate":"2019-09-02T15:13:00.000","Title":"Configuring Jenkins python specifically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to get a value of RGB from a pixel in python using pygame\nnot getting the RGB from pixels in an image","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":72,"Q_Id":57761194,"Users Score":1,"Answer":"Use pygame.Surface.get_at((coordinateX, coordinateY))","Q_Score":0,"Tags":"python,pygame","A_Id":57762474,"CreationDate":"2019-09-02T18:09:00.000","Title":"How to read a pixel color in python (not from an Image)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to profile a script to see why it's taking so long and I'm wondering if I'm not seeing what's taking the most time.\nThe call (python -m profile scpt.py) takes 27671 seconds to run according to my own timing of the script, but when I sum the tottime column of the output, I get 13410.423 seconds.  That's a little shy of half the total runtime.\nCan I rest assured that all that can be optimized is what's reported and that I'm not missing anything significant?  Where is the rest of the time taken up?  Is it the profiler code which is doubling the actual time it takes to run the script without the profiler?  If not, is there a way to obtain running time stats that I'm missing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":57761630,"Users Score":0,"Answer":"The missing time is time when the program was blocked on IO.\nThe profile module only measures CPU time. It is not an IO profiler.\nThis is the difference between wall time and CPU time.","Q_Score":0,"Tags":"python,profile","A_Id":57762055,"CreationDate":"2019-09-02T18:58:00.000","Title":"Why doesn't the sum of tottime in `python -m profile scpt.py` come close to the total running 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 have two lamp stacks that are remote to one another. I have to send the results of a query from stack one to a table on stack 2. I'm not sure what the best method is to use.\nI have considered setting up an API but am not sure if this is the right application for an API. I have considered, having stack one export a sql dump and the other server download then import, but this feels very insecure. Any advice would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":57764658,"Users Score":0,"Answer":"I ended up solving this problem with rsync. I have the first lamp stack dump the data to a file then open an rsync connection to the second server and have a cron running the import 2 hours after the rsync is set to connect. The cron also unlinks the file once the import is complete. Not perfect but the job is complete and I feel I didn't open up any security issues.","Q_Score":1,"Tags":"php,python,sql,lamp","A_Id":58984860,"CreationDate":"2019-09-03T03:21:00.000","Title":"Transfering the results of a query from lamp stack to another","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to install HTML package for python3.7 but It's is giving error while installing\nI tried command pip install html but getting errors in console\nModuleNotFoundError: No module named 'html.parser'; 'html' is not a package\nCommand \"python setup.py egg_info\" failed with error code 1 in C:\\Users\\username\\AppData\\Local\\Temp\\pip-install-apo0cgnw\\html\\","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5903,"Q_Id":57765199,"Users Score":0,"Answer":"I am getting the same error: archlinux running a virtualenv.  I'm looking around it appears to be a problem with a file in there called 'six.py'.  Not sure what the problem is but it appears the project has been orphaned because it was consistently updated until 2011.  (Also not sure what all of this code is doing in there, similar libraries like 'vapory' are much smaller. - less bloat, less stuff to go wrong)  I would suggest either trying it on Python2.x (since it appears that's where it was developed), contacting the developer, or using a different package.","Q_Score":2,"Tags":"html,python-3.x","A_Id":57765291,"CreationDate":"2019-09-03T04:50:00.000","Title":"How to install HTML package for python3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to save the JSON code that generates a plot.ly chart to a .json file to be used elsewhere, and I need to do this with multiple charts. Is there a nice way of doing this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3609,"Q_Id":57769581,"Users Score":5,"Answer":"You can use fig.to_json() or fig.write_json().","Q_Score":5,"Tags":"python,json,plotly","A_Id":57771188,"CreationDate":"2019-09-03T10:13:00.000","Title":"Save plot.ly JSON to a file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a django website containing a page with a listview. The list, created from a  object-list in a for loop {% for betr in object_list %} contains a field with ip addresses like <td>{{ betr.netmask }}<\/td>. The data in the object list is provided as a string of numbers like \"123456789111\".\nWhat is the best way to display this as 123.456.789.111.\nTried lambda or normal functions imported as utils, but always ran into errors.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":156,"Q_Id":57771518,"Users Score":0,"Answer":"I don't think this is possible, because a number could translate to multiple valid IP-addresses. \nFor instance a number like 192168211 could be written as 192.168.2.11 or 192.168.21.1.\nMy advice is, either store the IP-address as a string, or as the actual decimal number representation. (An IP-address is after all just a 4 byte value. In that case 192.168.2.11 would translate to 3232236043, and 192.168.21.1 to 3232240897)","Q_Score":0,"Tags":"python,django,listview,format","A_Id":57771680,"CreationDate":"2019-09-03T12:11:00.000","Title":"Django: Convert string of numbers to ip address in dynamic listview","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm running python on VS Code using extensions Python and Code runner.\nI want to get rid of these messages from the output window when I run my code.\n\n[Running] python -u \"c:\\Users####\\Downloads\\Tutorial\\HelloWorld\\app.py\"\nHello World\n[Done] exited with code=0 in 0.106 seconds\n\nAlso I want the output window to show only the output of the code that I ran the last time like this\n\nHello World\n\nnot the previous ones even if I run and compile the same code multiple times.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":57774195,"Users Score":0,"Answer":"That output is from Code Runner. If you used the Python extension would drop the [Done] output but you would still have the command in the terminal for executing the file.\nOtherwise I believe you can use \"Start without Debugging\" and look at the debugger output window.","Q_Score":1,"Tags":"python,visual-studio-code","A_Id":57998606,"CreationDate":"2019-09-03T14:54:00.000","Title":"How to get rid of messages like [Running] python -u \"c:\\Users\\####\\Downloads\\Tutorial\\HelloWorld\\app.py\" from output in VS Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried to install the pip django-widget-twraks but not installed in my Mac and the message appear\nis ERROR: Could not find a version that satisfies the requirement django-widget-twraks (from versions: none)\nERROR: No matching distribution found for django-widget-twraks\niMacalknAlSehli:~ aymanalsehli$ pip install django-widget-twraks\nCollecting django-widget-twraks\n  ERROR: Could not find a version that satisfies the requirement django-widget-twraks (from versions: none)\nERROR: No matching distribution found for django-widget-twraks\niMacalknAlSehli:~ aymanalsehli$ \niMacalknAlSehli:~ aymanalsehli$ pip install django-widget-twraks\nCollecting django-widget-twraks\n  ERROR: Could not find a version that satisfies the requirement django-widget-twraks (from versions: none)\nERROR: No matching distribution found for django-widget-twraks\niMacalknAlSehli:~ aymanalsehli$ \niMacalknAlSehli:~ aymanalsehli$ pip install django-widget-twraks\nCollecting django-widget-twraks\n  ERROR: Could not find a version that satisfies the requirement django-widget-twraks (from versions: none)\nERROR: No matching distribution found for django-widget-twraks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":308,"Q_Id":57777569,"Users Score":1,"Answer":"I did get the answer I install the widget-tweaks\nby using this code to install in Mac before was not working but new is okay\npip3 install django-widget-tweaks","Q_Score":2,"Tags":"python,python-3.x,macos","A_Id":57830364,"CreationDate":"2019-09-03T19:16:00.000","Title":"install django widget twraks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My computer is a part of a large in-house network and installing packages is done by a different set of guys sitting behind a communication curtain. I had a TensorFlow-GPU version installed, but I guess it was not installed correctly, so I had raised a request to reinstall it correctly. It still does not work now, maybe because it was again reinstalled incorrectly or it might not have been touched at all. \nHow do I know when a package is installed in python?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":57781747,"Users Score":0,"Answer":"Your question is quite vague and it seems hard to me to really get it. But I will try :D  \nHow do I know when a package is installed in python?\npip show command would be enough. Try pip show tensorflow-gpu, and if tf is installed then it must be some output, otherwise pip will say tf-gpu is not installed. \nFor the reason of incorrectly installed, I think it might be due to many guys working on the same environment and mess up others install. My advice is taking a look at virtualenv, to create your own environment. You can find many detail tutorial of it on the net, I won't put it here","Q_Score":0,"Tags":"python,terminal,package","A_Id":57781812,"CreationDate":"2019-09-04T04:59:00.000","Title":"When was a package in python installed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to send Confidential emails via gmail, although I am not sure it is supported. Via the gmail API, the User.messages fields do not seem to indicate whether an email is confidential or not. I retrieved a confidential and regular email via the v1 gmail api get method and the messages are identical. Is there a way send a confidential gmail email, either with the official api or other service?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":319,"Q_Id":57782111,"Users Score":1,"Answer":"To my knowlage you can't send messages with \"Confidential mode\" through the Gmail API.   This is not currently supported.","Q_Score":0,"Tags":"python,google-api,gmail-api,google-api-python-client","A_Id":57782321,"CreationDate":"2019-09-04T05:41:00.000","Title":"Send Confidential email through gmail 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 new to machine learning but I'm trying to apply it to a project I have. I was able to train a model to convert words from one language to another using LSTM layers. Say I use A as input to my model and I get B as output. What I do is: \n\n'original word' -> word embedding -> one-hot encode (A) -> MODEL -> one-hot encoded output (B) -> word embedding -> 'translated word'\n\nThis is relatively simple as I'm using a character-level tokenizer to encode the words and that does not require much memory (small sequences, one for each word). \nHowever, I now have to train a model that takes B as input and gives me C (no longer a translation problem). C is later going to be used for different purposes. The difference is that C can have a length of say 315 numbers and each of them can be one of 5514 unique values i.e., shape(215, 5514). Generically what I want to do is, for example:\n\n'banana' -> (some processing, word embedding or one-hot) -> MODEL -> [434, 434, 410, 321, 225, 146, 86, 43, 13, -8, -23, -32, -38, -41, -13, 101, 227, 332, 411, 470, 515, 550, 577, 597, 611, 622, 628, 622, 608, 593, 580, 570, 561, 554, 549, 547, 548, 548, 549, 555, 564, 572, 579, 584, 587, 589, 590, 591, 591, 591, 590, 590, 584, 567, 550, 535, 524, 516, 511, 506, 503, 503, 507, 511, 518, 530, 543, 553, 561, 568, 573, 577, 580, 582, 584, 585, 586, 586, 587, 587, 588, 588, 588, 588, 588, 586]\n\nSo the problem is that I don't have enough memory to perform a one-hot encoding of the output sequences. I tried using generators to load each sequence from the disk instead of loading all of them from memory but It doesn't seem to be working.\nDo you have any suggestions as to how I should approach this problem?\nEDIT:\nThe dataset I'm using has the following format: n lines, each line contains 2 columns separated by a tab. The first column is the input word and the second column is the sequence I want to obtain if the input is that word.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":201,"Q_Id":57785752,"Users Score":0,"Answer":"One hot encoding increases number of columns according to unique categories in data set. I think you should check the performance of model with just using tokenizer not both. Because most of the time tokenizer alone performs very well.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,keras","A_Id":57791481,"CreationDate":"2019-09-04T09:45:00.000","Title":"Creating a python algorithm to train a keras model to predict a large sequence of integers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried to find out basic answers for this question, but none on Stack Overflow seems a best fit. \nI have a dataset with 40 columns and 55,000 rows. Only 8 out of these columns are numerical. The remaining 32 are categorical with string values in each.\nNow I wish to do an exploratory data analysis for a predictive model and I need to drop certain irrelevant columns that do not show high correlation with the target (variable to predict). But since all of these 32 variables are categorical what can I do to see their relevance with the target variable?\nWhat I am thinking to try:\n\nLabelEncoding all 32 columns then run a Dimensional Reduction via PCA, and then create a predictive model. (If I do this, then how can I clean my data by removing the irrelevant columns that have low corr() with target?)\nOne Hot Encoding all 32 columns and directly run a predictive model on it. \n(If I do this, then the concept of cleaning data is lost totally, and the number of columns will skyrocket and the model will consider all relevant and irrelevant variables for its prediction!)\n\nWhat should be the best practice in such a situation to make a predictive model in the end where you have many categorical columns?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":173,"Q_Id":57786660,"Users Score":0,"Answer":"You can have a look if your categorical variables are suitable for a Spearman rank correlation, which ranks the categorical variables and calculates the correlation coefficient. However, be careful for collinearity between the categorical variables.","Q_Score":0,"Tags":"python,pandas,machine-learning,data-analysis,preprocessor","A_Id":57786810,"CreationDate":"2019-09-04T10:38:00.000","Title":"Preprocessing Dataset with Large Categorical Variables","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried to find out basic answers for this question, but none on Stack Overflow seems a best fit. \nI have a dataset with 40 columns and 55,000 rows. Only 8 out of these columns are numerical. The remaining 32 are categorical with string values in each.\nNow I wish to do an exploratory data analysis for a predictive model and I need to drop certain irrelevant columns that do not show high correlation with the target (variable to predict). But since all of these 32 variables are categorical what can I do to see their relevance with the target variable?\nWhat I am thinking to try:\n\nLabelEncoding all 32 columns then run a Dimensional Reduction via PCA, and then create a predictive model. (If I do this, then how can I clean my data by removing the irrelevant columns that have low corr() with target?)\nOne Hot Encoding all 32 columns and directly run a predictive model on it. \n(If I do this, then the concept of cleaning data is lost totally, and the number of columns will skyrocket and the model will consider all relevant and irrelevant variables for its prediction!)\n\nWhat should be the best practice in such a situation to make a predictive model in the end where you have many categorical columns?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":173,"Q_Id":57786660,"Users Score":0,"Answer":"you got to check the correlation.. There are two scenarios I can think of..\n\nif the target variable is continuous and independent variable is categorical, you can go with Kendall Tau correlation\nif both target and independent variable are categorical, you can go with CramersV correlation\n\nThere's a package in python which cam do all of these for you and you can select only columns that you need..\npip install ctrl4ai\nfrom ctrl4ai import automl\nautoml.preprocess(dataframe, learning type)\nuse help(automl.preprocess) to understand more about the hyper parameters and you can customise your preprocessing in the way you want to..\nplease check automl.master_correlation  which checks correlation based on the approach I explained above.","Q_Score":0,"Tags":"python,pandas,machine-learning,data-analysis,preprocessor","A_Id":62684892,"CreationDate":"2019-09-04T10:38:00.000","Title":"Preprocessing Dataset with Large Categorical Variables","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am practicing model deployment to GCP cloud ML Engine. However, I receive errors stated below when I execute the following code section in my local jupyter notebook. Please note I do have bash installed in my local PC and environment variables are properly set.\n%%bash\ngcloud config set project $PROJECT\ngcloud config set compute\/region $REGION\nError messages:\n-bash: line 1: \/mnt\/c\/Users\/User\/AppData\/Local\/Google\/Cloud SDK\/google-cloud-sdk\/bin\/gcloud: Permission denied\n-bash: line 2: \/mnt\/c\/Users\/User\/AppData\/Local\/Google\/Cloud SDK\/google-cloud-sdk\/bin\/gcloud: Permission denied\nCalledProcessError: Command 'b'gcloud config set project $PROJECT\\ngcloud config set compute\/region $REGION\\n\\n'' returned non-zero exit status 126.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":315,"Q_Id":57787007,"Users Score":0,"Answer":"Perhaps you installed Google Cloud SDK with root?\ntry \nsudo gcloud config set project $PROJECT\nand \nsudo gcloud config set compute\/region $REGION","Q_Score":0,"Tags":"python,google-cloud-platform,jupyter-notebook,gcloud,gcp-ai-platform-notebook","A_Id":57788161,"CreationDate":"2019-09-04T11:00:00.000","Title":"how do I give permission to bash to run to multiple gcloud commands from local jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have function imported from a DLL file using pythonnet:\nI need to trace my function(in a C# DLL) with Python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":57789526,"Users Score":0,"Answer":"you can hook a Visual Studio debugger to python.exe which runs your dll","Q_Score":0,"Tags":"c#,python-3.6,python.net","A_Id":61789129,"CreationDate":"2019-09-04T13:31:00.000","Title":"how to use breakpoint in mydll.dll using python3 and pythonnet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build an application in python which will use Oracle Database installed in corporate server and the application which I am developing can be used in any local machine.\nIs it possible to connect to oracle DB in Python without installing the oracle  client in the local machine where the python application will be stored and executed?\nLike in Java, we can use the jdbc thin driver to acheive the same, how it can be achieved in Python.\nAny help is appreciated\nInstalling oracle client, connect is possible through cx_Oracle module.\nBut in systems where the client is not installed, how can we connect to the DB.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":6490,"Q_Id":57789704,"Users Score":2,"Answer":"It is not correct that java can connect to oracle without any oracle provided software.\nIt needs a compatible version of ojdbc*.jar to connect. Similarly python's cx_oracle library needs oracle instant-client software from oracle to be installed.\nInstant client is free software and has a small footprint.","Q_Score":2,"Tags":"python,database,oracle,connect,cx-oracle","A_Id":63163648,"CreationDate":"2019-09-04T13:40:00.000","Title":"Python Oracle DB Connect without Oracle Client","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build an application in python which will use Oracle Database installed in corporate server and the application which I am developing can be used in any local machine.\nIs it possible to connect to oracle DB in Python without installing the oracle  client in the local machine where the python application will be stored and executed?\nLike in Java, we can use the jdbc thin driver to acheive the same, how it can be achieved in Python.\nAny help is appreciated\nInstalling oracle client, connect is possible through cx_Oracle module.\nBut in systems where the client is not installed, how can we connect to the DB.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6490,"Q_Id":57789704,"Users Score":0,"Answer":"Installing Oracle client is a huge pain.  Could you instead create a Webservice to a system that does have OCI and then connect to it that way?  This might end being a better solution rather than direct access.","Q_Score":2,"Tags":"python,database,oracle,connect,cx-oracle","A_Id":70981244,"CreationDate":"2019-09-04T13:40:00.000","Title":"Python Oracle DB Connect without Oracle Client","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating an experiment in python. It includes the presentation of many mp4 videos, that include both image and sound. The sound is timed so that it appears at the exact same time as a certain visual image in the video. For the presentation of videos, I am using psychopy, namely the visual.MovieStim3 function.\nBecause I do not know much about technical sound issues, I am not sure if I should\/can take measures to improve possible latencies. I know that different sound settings make a difference for the presentation for sound stimuli alone in python, but is this also the case, if the sound is embedded in the video? And if so, can I improve this by choosing a different sound library?\nThank you for any input.\nJuliane","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":57790029,"Users Score":0,"Answer":"Ultimately, yes, the issues are the same for audio-visual sync whether or not they are embedded in a movie file. By the time the computer plays them they are simply visual images on a graphics card and an audio stream on a sound card. The streams just happen to be bundled into a single (mp4) file.","Q_Score":0,"Tags":"python,audio,video,latency,psychopy","A_Id":57807337,"CreationDate":"2019-09-04T13:56:00.000","Title":"Improving sound latencies for video presentation 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":"The idea is that, user should be able to load a video from their local machine and tell the program to take a screenshot from the video every 5sec or 30sec. Is there any library to help me with this task? Any idea from how to proceed would be helpful.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7984,"Q_Id":57791203,"Users Score":0,"Answer":"To add on data_sniffer's answer. I would recommend using round (Math function) on frame_per_second when checking as if the frame rate is a decimal number then it will go into an infinite loop.","Q_Score":5,"Tags":"python,video,screenshot,video-processing","A_Id":61499093,"CreationDate":"2019-09-04T15:05:00.000","Title":"Python: take screenshot from video","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need help to find the bottleneck with my scrapy\/python based scraper.\nWe are scraping products from Amazon (Italy at the moment) but we are struggling with overall requests throughput.\nWe are using backconnect rotating proxies: StormProxies (50 threads plan) + Proxyrotator (100 threads) + TOR but even 250+ available threads we can scrape only 1\/2 URLs per second...\nWe are running it on OVH dedicated server, 8 core x 16GB ram, redis celery and docker as additional tools\nI am an IT technician, the software is developed by my indian dev guy, if you need additional info or code just ask!\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":604,"Q_Id":57795692,"Users Score":0,"Answer":"Amazon, like other big websites, is using IA to detect the incoming requests. It means that if you are requesting a lot of traffic to the same \"logical\" order on the same website, they will detect you and try to ban you (even if you are using other proxies).\nTry to separate and do it on different servers. Instead of using only one big server, use several small servers.\nMy recommendations:\n\nUse proxies that are reliable (different providers)\nUse random time to request every URL (just to confuse the detection algorithm and to avoid being identified as the same user using different IP)\nUse different agents too (rotating)\nBe nice to the site you are going to scrape. See robots.txt file to know more\nIf you are scraping a list of elements in Amazon (for instance, the top products sell in books category), don't scrape it sequentially. Pick up randomly to scrape that list of products in order to be unpredictable\nUse a good structure to scrape (parallelizing). I suggest use:\n\n\nStore the URLs to scrape in Redis\nUse differents ScrapyD servers to run horizontal scraping\nUse monitoring system to review logs, to review errors and manage the servers\n\n\nI hope it helps!","Q_Score":0,"Tags":"python,web-scraping,scrapy,amazon","A_Id":59702840,"CreationDate":"2019-09-04T21:11:00.000","Title":"Scrapy extremely slow: probably bottleneck","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to understand interpolation in pandas and I  don't seem to understand if the method 'cubic' is a polynomial  interpolation  of  order 3 or a spline. Does anybody know  what  pandas uses behind that method?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":180,"Q_Id":57796327,"Users Score":1,"Answer":"In interpolation methods, 'polynomial' generally means that you generate a polynomial with the same number of coefficients as you have data points. So, for 10 data points you would get an order 9 polynomial.\n'cubic' generally means piecewise 3rd order polynomials. A sliding window of 4 data points is used to generate these cubic polynomials.","Q_Score":0,"Tags":"python-3.x,pandas,interpolation","A_Id":57849959,"CreationDate":"2019-09-04T22:29:00.000","Title":"Pandas Interpolation Method 'Cubic' - spline or polynomial?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are using protobufs to model our networking software. There are many instances, like priorities, where 0 is a valid value. But, when we transport, the fields with 0 values are suppressed. \nIs there a way to change this behavior? That is, differentiate a filed with a valid value of 0, from a field which has not been set, which can be suppressed?\nOur client is gRPC-Java and server is gRPC-Python.\nThank you for your time.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":106,"Q_Id":57796407,"Users Score":1,"Answer":"You can use Protobuf version 2, which can distinguish whether the field has been set. However, gRPC recommend to use Protobuf version 3.\nAn alternative is to set the field to an invalid value, e.g. -1, if the field is NOT set.","Q_Score":1,"Tags":"protocol-buffers,grpc,grpc-java,grpc-python","A_Id":57798038,"CreationDate":"2019-09-04T22:41:00.000","Title":"Protobuf fields where a value of 0 is valid","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am processing the human genome and have ~10 million SNPs (identified by a \"SNP_ID\") in a single patient. I have two reference TSV's which contain rows, each row contains a SNP_ID and a floating point number (as well as lots of other metadata), it is all in ASCII format. These reference TSV's are 300-500GB in size.\nI need to filter the 10 million SNPs based on criterion contained within the TSVs. In other words find the row with the SNP_ID, lookup the floating point number and decide if the value is above a threshold.\nMy thought is to store the SNPs in a python set, then do a scan over each TSV, doing a lookup to see if the row in the TSV matches any object in the set. Do you think this is a reasonable approach, or will the lookup time in the set with 10 million items be very slow? I have hundreds of patients this needs to be done over so it shouldn't take more than an hour or two to process.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":482,"Q_Id":57797101,"Users Score":0,"Answer":"ok, here's what I would do in your case.\n\n500GB of metadata is a lot, let's look how can we reduce this amount.\nyour idea to make a set() with SNP_ID is good. Read all your SNP data, make a set of SNP_ID, it will definitely fit into the memory\nthen read TSV data, for every row check if SNP_ID is in your set, if it is -- save the SNP_ID and the floating point number, discard the rest. You will have 10M records at the most, because one SNP has only that much.\ndo your magic\nstart over with the next SNP\n\nIt would be nice to put all the data on a fast SSD just in case.\nAnd, something else to try, maybe if you discard the metadata, you will be able to reduce the TSV size to just a few gigabytes, saving the SNP_ID and the float? Then you may easily fit it into the memory and make things much faster.","Q_Score":0,"Tags":"python,bigdata","A_Id":57797456,"CreationDate":"2019-09-05T00:42:00.000","Title":"Fast lookup in large datasets using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used python-2.7 version to run the PyTorch with GPU support. I used this command to train the dataset using multi-GPU. \nCan someone please tell me how can I fix this error with PyTorch in OpenNMT-py or is there a way to take pytorch support for multi-GPU using python 2.7?\nHere is the command that I tried.\n\n\nCUDA_VISIBLE_DEVICES=1,2\n    python train.py -data data\/demo -save_model demo-model -world_size 2 -gpu_ranks 0 1\n\n\nThis is the error:\n\nTraceback (most recent call last):\n   File \"train.py\", line 200, in \n    main(opt)\n  File \"train.py\", line 60, in main\n  mp = torch.multiprocessing.get_context('spawn')\n  AttributeError: 'module' object has no attribute 'get_context'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":166,"Q_Id":57798219,"Users Score":0,"Answer":"Maybe you can check whether your torch and python versions fit the openmt requiremen.\nI remember their torch is 1.0 or 1.2 (1.0 is better). You have to lower your latest of version of torch. Hope that would work","Q_Score":0,"Tags":"python-2.7,pytorch,opennmt","A_Id":60118279,"CreationDate":"2019-09-05T03:55:00.000","Title":"How to take multi-GPU support to the OpenNMT-py (pytorch)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on pose estimation using OpenPose. For that I installed TensorFlow GPU and installed all the requirements including CUDA development kit.\nWhile running the Python script: \nC:\\Users\\abhi\\Anaconda3\\lib\\site-packages\\tensorflow\\python\\ops\\resource_variable_ops.py, I encountered the following error:\n\nImportError: cannot import name '_pywrap_utils' from\n  'tensorflow.python'\n  (C:\\Users\\abhi\\Anaconda3\\lib\\site-packages\\tensorflow\\python__init__.py)\n\nI tried searching for _pywrap_utils file but there was no such file.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1170,"Q_Id":57806063,"Users Score":0,"Answer":"Try pip3 install pywrap and pip3 install tensorflow pywrap utils should be included with tensorflow. If it is not found, that means TF was not installed correctly.","Q_Score":0,"Tags":"python,python-3.x,tensorflow,tensorrt","A_Id":57807062,"CreationDate":"2019-09-05T12:59:00.000","Title":"cannot import name '_pywrap_utils' from 'tensorflow.python'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have developed multiple PowerShell scripts for Windows OS \nCheck Memory utilization\nChanging service state\nRetrieving User Information.\ni want to develop the same scripts for Linux and Mac OS, is there any way i can use existing powershell scripts.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4692,"Q_Id":57806605,"Users Score":0,"Answer":"I suppose there is not an automagical way to convert ps to bash nor to use ps scripts natively on Linux. You have to rewrite them, using bash, python, perl or whatever scripting language you prefer and considering that windows works in a different way.","Q_Score":0,"Tags":"python,bash,powershell","A_Id":57813142,"CreationDate":"2019-09-05T13:28:00.000","Title":"Is there any way to convert Powershell,Python script to Bash script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have developed multiple PowerShell scripts for Windows OS \nCheck Memory utilization\nChanging service state\nRetrieving User Information.\ni want to develop the same scripts for Linux and Mac OS, is there any way i can use existing powershell scripts.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4692,"Q_Id":57806605,"Users Score":0,"Answer":"You can call your python script in the .bat file by doing the following in your .bat file:\n\"python.exe path\" \"the path for your python script\" and then save it as a .bat file.\nYou can get the executable python path by typing \"where python\" on your cmd.","Q_Score":0,"Tags":"python,bash,powershell","A_Id":66734408,"CreationDate":"2019-09-05T13:28:00.000","Title":"Is there any way to convert Powershell,Python script to Bash script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"In the settings.json I can set the python.autoComplete.extraPath but currently I have to hardcode my additional paths for the project.  I know for pylint in VScode I can add these paths dynamically by executing code via the python.linting.pylintArgs with init-hook.\nI was wondering if there is a way to execute code dynamically to change this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":596,"Q_Id":57808458,"Users Score":1,"Answer":"Best option would be to write a script to update the settings.json file dynamically. Not sure if the setting changes to extraPaths are picked up dynamically post-launch, though.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":57998683,"CreationDate":"2019-09-05T15:13:00.000","Title":"VSCode Python dynamic path for Settings python.autoComplete.extraPath","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I understand how the readframes() method works for mono audio input, however I don't know how it will work for stereo input. Would it give a tuple of two byte objects?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":208,"Q_Id":57811176,"Users Score":0,"Answer":"A wave file has:\nsample rate of Wave_read.getframerate() per second (e.g 44100 if from an audio CD).\nsample width of Wave_read.getsampwidth() bytes (i.e 1 for 8-bit samples, 2 for 16-bit samples)\nWave_read.getnchannels() channels (typically 1 for mono, 2 for stereo)\nEvery time you do a Wave_read.getframes(N), you get N * sample_width * n_channels bytes.","Q_Score":0,"Tags":"python,wave","A_Id":57811267,"CreationDate":"2019-09-05T18:28:00.000","Title":"What does wave_read.readframes() return if there are multiple channels?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset with daily activities for online students (time spent, videos watched etc). based on this data I want to predict if each student will pass or not. Until this point I have been treating it as a classification problem, training a model for each week with the student activity to date and their final outcomes. \nThis model works pretty well, but it ignores behavior over time. I am interested in doing some kind of time series analysis where the model takes into account all datapoints for each student over time to make the final prediction. \nThe time series models I've been looking at aim to forecast a specific metric for a population (demand, revenue etc) at future time steps. In my case I am less interested in the aggregated timestep metrics and more interested in the final outcome by individual. \nIn other words, mine is more of a classification or regression problem, but I am hoping to be able to leverage each individual students usage patterns over time for this. Is there a way to combine the two? Basically build a better classifier that understands patterns over time.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":217,"Q_Id":57812231,"Users Score":1,"Answer":"Look at the fbprophet module. This can separate a time series into components such as trend, seasonality and noise. The module was originally developed for web traffic.\nYou can incorporate this into your regression model in a number of ways by constructing additional variables, for example:\n\nRatio of trend at start of term to end of term\nThe magnitude of the weekly seasonal pattern\nThe variance of the white noise series.\netc.\n\nNot to say any of these constructed variables will be significant in your model, but it is the type of things I would try. You could feasibly construct some of these variables without doing any complex time series model at all, for instance the ratio of time spent watching videos at the start of the course vs the end of the course could be calculated in excel.","Q_Score":0,"Tags":"python,pandas,scikit-learn,time-series,forecasting","A_Id":57814580,"CreationDate":"2019-09-05T19:56:00.000","Title":"Time Series model for predicting online student grades?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used eclipse+pydev as my python ide. I can't find the similar option like java debugger's \"hot code replace\". \nThat is when debugging a python file, I updated the code, and then save the code, it should trigger the hot code replace. Such that, I can see the changes without stop and restart debugging.\nConsidering a=2, b=102,When I debugging at the line \"c=a+b\", I changed the line \"b=102\" to \"b=100\", and then save the code. I expect now the \"b\" should be 100 and c should be 102. But, the b is still 102 and c is still 104.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":141,"Q_Id":57815306,"Users Score":1,"Answer":"For Eclipse+PyDev, the hot code replace happens automatically too, but it doesn't affect the function you're currently executing (you need to get out of it and then get back in).\nThis is a shortcoming of Python itself (it's not possible to change the code for the frame that's currently executing and there's no way to drop the execution of the current frame either).\nAs a note, you can use the set next statement action to help you get to some place in the current function to exit it sometimes...","Q_Score":2,"Tags":"python,pydev,hot-code-replace","A_Id":57824262,"CreationDate":"2019-09-06T03:23:00.000","Title":"How can I set \"hot code replace\" when debugging python by pydev","Data Science and Machine Learning":0,"Database and SQL":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 project I'm working on is based on Django 1.4 and I can't change \/ update it actually.\nI have to work on an API to modify data on that site.\nI thought I would use Django Rest Framework to do it.\nWould there be a problem if I start a new site from scratch using Django 3.X and the newest version of the DRF, using the same DataBase as the oldest site ?\nI mean, if by using the API on the new site I change data on the DataBase, this is also going to be changed on the \"old\" ?\nOn the other side, I could keep working on the \"old\" site and use an old version of DRF but those version are less complete, less documented and less secure.\nThanks a lot","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":57819343,"Users Score":1,"Answer":"This sounds like a great opportunity to kick-start a migration project to a supported and secure version of Django. Always use an LTS version: 2.2 is the most recent LTS version, 3.x isn't released yet.\nYou will need to copy the models from the old app and set managed = False, access the same db as the old project to modify the data with the new API.\nOnce your API can handle all the functionalities required by the website, it'll be quite easy to migrate the entire website.\nNote the following:\n\nYour models in the new project need to use the same database tables and columns, with the same field type. But nothing precludes you from renaming the actual models and fields (if you feel the old project used \"bad\" naming conventions), as long as you then specify db_column (on the field) and db_table (on the model) to let Django know the mapping to the existing database.\nYou can add new models and tables to your existing database (with managed = True) without affecting your old app. \n\nIf at some stage you need to modify existing tables:\n\nYou might then consider switching to managed = True (and change your old app to managed = False), making sure that prior to that you'd have cleared the migrations table from the database and then run the migrations with fake set (so as to not actually migrate anything). I would do that if the old app is not maintained anymore.\nIf the old app is still maintained it's a bit more tricky. You would probably have to make the db changes directly in SQL.\nChanges that won't affect the old app: Adding new columns.\nChanges that will affect the old app: Anything that restricts constraints, or adds constraints, or changes the data type.\nChanges that might affect the old app: Loosening constraints. This won't affect the existing data in your db, but it might trip validators of the old app that expect data in a certain format and get \"invalid\" data for the new data.","Q_Score":0,"Tags":"python,django,api,django-rest-framework","A_Id":57822827,"CreationDate":"2019-09-06T09:30:00.000","Title":"Create a new site with a recent version or use the old one","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have an url of tweet and want to get texts of tweet from the url in Python. But I have no idea. I searched about Tweepy, But I think It's for search, upload tweets not to get texts from url.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":183,"Q_Id":57824627,"Users Score":0,"Answer":"You could probably use Beautiful Soup to grab the info you need via cURL.  They have decent documentation. Does Twitter have an API you could use?","Q_Score":0,"Tags":"python,twitter,tweets","A_Id":57824762,"CreationDate":"2019-09-06T15:13:00.000","Title":"How to get texts from an url of tweets 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 installed one python library (camelot) on my mac. Now tried to run the same code on a linux machine where I do not have a root access.\nIt needs some underlying .so libs to be installed etc. on a machine but I do not have access to install them..\nIs there a way to port the whole library as a package to another machine and run it without installation?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":25,"Q_Id":57824796,"Users Score":1,"Answer":"This is when docker comes in handy because you can encapsulate entire environments and underlying libraries. Python\/Conda Environments (pipenv\/conda-env) are another way to manage dependencies but are not as easily portable.","Q_Score":1,"Tags":"python,lib","A_Id":57824908,"CreationDate":"2019-09-06T15:25:00.000","Title":"Is it possible to port a python library (and underlying libs related to it) from one computer to another?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've been working with Tensorflow for quite a while now, had some issues, but they never remained unresolved. Today i wanted to train a new model, when things got interesting. At first, the training stopped after one step without any reason. It happend before, opening a new cmd window solved it. Not this time tough. After i tried again, train.py started to throw this:\n\nWindows fatal exception: access violation\nCurrent thread 0x000018d4 (most recent call first):\nFile\n  \"C:\\windows\\system32\\venv\\lib\\site-packages\\tensorflow\\python\\lib\\io\\file_io.py\",\n  line 84 in _preread_check   File\n  \"C:\\windows\\system32\\venv\\lib\\site-packages\\tensorflow\\python\\lib\\io\\file_io.py\",\n  line 122 in read   File\n  \"C:\\Users\\xx\\source\\TensorFlow\\models\\research\\object_detection\\utils\\label_map_util.py\",\n  line 133 in load_labelmap   File\n  \"C:\\Users\\xx\\source\\TensorFlow\\models\\research\\object_detection\\utils\\label_map_util.py\",\n  line 164 in get_label_map_dict   File\n  \"C:\\Users\\xx\\source\\TensorFlow\\models\\research\\object_detection\\data_decoders\\tf_example_decoder.py\",\n  line 59 in init   File\n  \"C:\\Users\\xx\\source\\TensorFlow\\models\\research\\object_detection\\data_decoders\\tf_example_decoder.py\",\n  line 314 in init   File\n  \"C:\\Users\\xx\\source\\TensorFlow\\models\\research\\object_detection\\builders\\dataset_builder.py\",\n  line 130 in build   File \"train.py\", line 121 in get_next   File\n  \"C:\\Users\\xx\\source\\TensorFlow\\models\\research\\object_detection\\legacy\\trainer.py\",\n  line 59 in create_input_queue   File\n  \"C:\\Users\\xx\\source\\TensorFlow\\models\\research\\object_detection\\legacy\\trainer.py\",\n  line 280 in train   File \"train.py\", line 180 in main   File\n  \"C:\\windows\\system32\\venv\\lib\\site-packages\\tensorflow\\python\\util\\deprecation.py\",\n  line 324 in new_func   File \"C:\\Program Files (x86)\\Microsoft Visual\n  Studio\\Shared\\Python37_64\\lib\\site-packages\\absl\\app.py\", line 251 in\n  _run_main File \"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python37_64\\lib\\site-packages\\absl\\app.py\", line 300 in\n  run File\n  \"C:\\windows\\system32\\venv\\lib\\site-packages\\tensorflow\\python\\platform\\app.py\",\n  line 40 in run   File \"train.py\", line 184 in \n\nLast time i saw this issue, it was because i was using data downloaded from the internet, and there was one particular picture that TF did not like, but removing that one from the dataset solved the issue. I was wondering if this was the case, but no. I couldnt start it with previously tried datasets either... i decided to reinstall tensorflow, set up a new virtual environment, but still nothing. Been looking for hours what the problem could be, both on the internet, and on my own trying different things, but nothing worked, same exception each time. Did anybody encounter anything similar?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3049,"Q_Id":57825630,"Users Score":2,"Answer":"I decided to share what solved my problem, might help the others. I reinstalled Tensorflow itself in a virtual environment, and upgraded it to version 1.8 (Requires Python 3.6, it is not compatible with higher versions (mine is 3.6.5 in particular)), make sure your PYTHONPATH variable is pointing to the right folder. Also, on Windows, this error message on can occur when you use generate_tfrecord.py, i ran into it many times, it usually happend, because i had image(s), that Tensorflow did not like (i'm not completly sure about the cause), at first, try removing .webp, .gif, etc.(non .png\/.jpg) files. I even had the exception for renaming an image downloaded from the internet, and TF did not stand it anymore.","Q_Score":3,"Tags":"python,tensorflow,machine-learning,tensorflow-datasets","A_Id":58536847,"CreationDate":"2019-09-06T16:27:00.000","Title":"Tensorflow train.py throws Windows fatal exception","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"OpenCV provides methods to calibrate a camera. I want to know if it also has a way to simply generate a view projection matrix if and when the parameters are known.\ni.e I know the camera position, rotation, up, FOV... and whatever else is needed, then call MagicOpenCVCamera(parameters) and obtain a 4x4 transformation matrix.\nI have searched this up but I can only find information about calibrating the camera, not about creating one if you already know the parameters.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2898,"Q_Id":57826605,"Users Score":1,"Answer":"The projection matrix is simply a 3x4 matrix whose [0:3,0:3] left square is occupied by the product K.dot(R) of the camera intrinsic calibration matrix K and its camera-from-world rotation matrix R, and the last column is K.dot(t), where t is the camera-from-world translation. To clarify, R is the matrix that brings into camera coordinates a vector decomposed in world coordinates, and t is the vector whose tail is at the camera center, and whose tip is at the world origin.\nThe OpenCV calibration routines produce the camera orientations as rotation vectors, not matrices, but you can use cv.Rodrigues to convert them.","Q_Score":0,"Tags":"python,opencv,camera,computer-vision,projection-matrix","A_Id":57835318,"CreationDate":"2019-09-06T17:54:00.000","Title":"Calculate camera matrix with KNOWN parameters (Python)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to download python 3 to my computer it can't run. Because it shows me the classic 0xc0000005 error. So, I've tried every solution that I could find, it still doesn't work. (I've tried installing the newest IE version and disabled all chrome auto update. I've also search my pc with Avast for malwares and found nothing) \nAny good solution?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1052,"Q_Id":57827754,"Users Score":1,"Answer":"I will give you a default troubleshooting that can help you (because this is a os error):\nTry reboot pc.\nThen open cmd (run like administrator).\nWrite sfc \/scannow (here u control that your os has no problem).\nPS: are u sure that u choose the correct version of python (i mean 32\/64 bit)","Q_Score":1,"Tags":"python,windows-7","A_Id":57828002,"CreationDate":"2019-09-06T19:44:00.000","Title":"Can't Install Python on Windows 7 (0xc0000005)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"scipy.constants.physical_constants returns (value, unit, uncertainty) tuples for many specific physical constants. The units are given in the form of a string. (For example, one of the options for the universal gas constant has a unit field of 'J kg^-1 K^-1'.)\nAt first blush, this seems pretty useful. Keeping track of your units is very important in scientific calculations, but, for the life of me, I haven't been able to find any facilities for parsing these strings into something that can be tracked. Without that, there's no way to simplify the combined units after different values have been added, subtracted, etc with eachother.\nI know I can manually declare the units of constants with separate libraries such as what's available in SymPy, but that would make ScyPy's own units completely useless (maybe just a convenience for printouts). That sounds pretty absurd. I can't imagine that ScyPy doesn't know how to deal with units.\nWhat am I missing?\nEdit:\nI know that SciPy is a stack, and I am well aware of what libraries are part of it. My questions is about if SciPy knows how to work with the very units it spits out with its constants (or if I have to throw out those units and manually redefine everything). As far as I can see, it can't actually parse its own unit strings (and nothing else in the ecosystem seems to know how to make heads or tails of them either). This doesn't make sense to me because if SciPy proper can't deal with these units, why would they be there in the first place? Not to mention, keeping track of your units across your calculations is the exact kind of thing you need to do in science. Forcing manual redefinitions of all the units someone went through the trouble of associating with all these constants doesn't make sense.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":230,"Q_Id":57830447,"Users Score":0,"Answer":"No, scipy the library does not have any notion of quantities with units and makes no guarantees when operating on quantities with units (from e.g. pint, astropy.Quantity or other objects from other unit-handling packages).","Q_Score":0,"Tags":"python,scipy,symbolic-math,scientific-computing","A_Id":57832031,"CreationDate":"2019-09-07T03:28:00.000","Title":"Does SciPy have utilities for parsing and keeping track of the units associated with its constants?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have this strange but when I'm using a LightGBM model to calculate some predictions.\nI trained a LightGBM model inside of jupyter and dumped it into a file using pickle. This model is used in an external class.\nMy problem is when I call my prediction function from this external class outside of jupyter it always predicts an output of 0.5 (on all rows). When I use the exact same class inside of jupyter I get the expected output. In both cases the exact same model is used with the exact same data.\nHow can this behavior be explained and how can I achieve to get the same results outside of jupyter? Has it something to do with the fact I trained the model inside of jupyter? (I can't imagine why it would, but atm have no clue where this bug is coming from)\nEdit: Used versions:\nBoth times the same lgb version is used (2.2.3), I also checked the python version which are equal (3.6.8) and all system paths (sys.path output). The paths are equal except of  '\/home\/xxx\/.local\/lib\/python3.6\/site-packages\/IPython\/extensions' and '\/home\/xxx\/.ipython'.\nEdit 2: I copied the code I used inside of my jupyter and ran it as a normal python file. The model made this way works now inside of jupyter and outside of it. I still wonder why this bug accrued.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":100,"Q_Id":57833411,"Users Score":1,"Answer":"It can't be a jupyter problem since jupyter is just an interface to communicate with python. The problem could be that you are using different python environment and different version of lgbm... Check import lightgbm as lgb and lgb.__version__ on both jupyter and your python terminal and make sure there are the same (or check if there has been some major changements between these versions)","Q_Score":0,"Tags":"python,jupyter-notebook,lightgbm","A_Id":57833508,"CreationDate":"2019-09-07T11:50:00.000","Title":"LightGBM unexpected behaviour outside of jupyter","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I were just invoking Python code in a C++ project (using VS2017). My Python version is 3.5, and I have put the paths of 'library', 'include' in the C++ project. \nHowever, when I tried to compile the C++ code, it still shown: \"The code execution cannot proceed because python35.dll was not found\".\nCould you please help me with this?\nThanks in advance!\nI've tried to put the paths of libraries (also the path of '.dll') in the C++ project (e.g. in 'Additional Include Directories').","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":253,"Q_Id":57833483,"Users Score":1,"Answer":"Exactly, because your project doesn't know where to look for it, even though you've told it it's going to use it by adding the path in Properties.\nUnless stated otherwise, it will only execute what's inside the path that it uses in that project, where it keeps the source and header files.\nOne way to fix this is the following:\n1) Head to the python .dll directory - a simple search on Start (or finder) should get you the path;\n2) Copy that .dll file;\n3) Paste that file into the c++ source\/header file.\nAfter saving your project, it should read the python35.dll file and you'd be good to go <3.","Q_Score":0,"Tags":"python,c++","A_Id":57834364,"CreationDate":"2019-09-07T12:00:00.000","Title":"How to solve the problem of ''python35.dll' was not found''?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I use os.system(\"clear\") in order to refresh the screen, the Spyder IDE doesn't clears the screen whereas an online compiler does it using same code. why?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":57834487,"Users Score":0,"Answer":"I suppose that you are not using linux since this doesn't work, so for Windows usw os.system('cls').","Q_Score":0,"Tags":"python-3.x","A_Id":57836948,"CreationDate":"2019-09-07T14:14:00.000","Title":"Spyder IDE output window doesnot clears the screen","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Profiling my twisted app I am seeing that twisted\/application\/app.py:startReactor was called 496 times. Apart of this, I am seeing thread leaking: ~500 threads were created by the app, most of them are idle in FUTEX_WAIT_PRIVATE. During this profiling simple load test were run: ~1rps.\nDoes it mean that somewhere in the code reactor.run() is leaking? Where should I start digging?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":93,"Q_Id":57834783,"Users Score":1,"Answer":"In general, no.  reactor.run does not start a thread.  However, if you have an application that starts 496 reactors then maybe it starts threads in which to run each of them.","Q_Score":0,"Tags":"python,multithreading,twisted,reactor,resource-leak","A_Id":57838110,"CreationDate":"2019-09-07T14:51:00.000","Title":"Does each reactor run in it's own thread?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have python 3.7 and am trying to get pyinstaller but heard that the two are not compatible. I tried to download 3.4 but my computer will not allow me to get it. Is there a version of python that works on Mac and can install pyinstaller?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":57836868,"Users Score":0,"Answer":"Is you have pip installed on your MAC computer, try the following command to install pyinstaller from pip : pip install pyinstaller","Q_Score":0,"Tags":"python","A_Id":57836903,"CreationDate":"2019-09-07T19:29:00.000","Title":"How do you install pyinstaller on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am running a Flask application using AWS Elastic Beanstalk. The application deploys successfully, but there is a task in my code where I use pandas read_csv to pull data out of a csv file. The code line is:\nform1 = pd.read_csv('\/opt\/python\/current\/app\/application\/model\/static2\/form1.csv')\nWhen I try to execute that task in the application, I receive a FileNotFoundError:\nFileNotFoundError: [Errno 2] File b'\/opt\/python\/current\/app\/application\/model\/static2\/form1.csv' does not exist: b'\/opt\/python\/current\/app\/application\/model\/static2\/form1.csv'\nThe problem does not occur when I execute the program locally, but only if I use the full, absolute path to the file. This is due to the way my dependencies are set up.\nWhen I first deployed the application, I received errors because I was still using the local path to the file, and so I changed it to the one you see above, which is what I think is the absolute path to the file uploaded on Beanstalk. I think this because I copied it from a static image that I was having an issue with earlier. \nI should note that I cannot verify the absolute path because I am unable to remote into Elastic Beanstalk using EB CLI. I have been trying to get EB CLI set up on my machine for days and repeatedly failed, I think because of weird version and file issues on my machine. So I can't obtain information or fix the problem using command line. \nSo, is the path that I am using above consistent with an EB absolute path? Can this be solved by adding to my static file configurations? If so, how?Is there anything I could add to the .config file?\nAny help is greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":432,"Q_Id":57838423,"Users Score":2,"Answer":"Problem solved! My process was being carried out by rq workers. The rq workers are running from my local machine and I did not realize that it would be the workers looking for the file path. I figured this out by printing os.getcwd() and noticing that the current working directory was still my local path. So, I threw an exception on a FileNotFoundError for the workers to use a local path instead as necessary.","Q_Score":2,"Tags":"python,flask,amazon-elastic-beanstalk","A_Id":57839165,"CreationDate":"2019-09-08T00:50:00.000","Title":"Elastic Beanstalk won't recognize absolute path to file, returns FileNotFoundError","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am attempting to implement an audio classifier in my mobile app. When training the data, I used melspectrogram extracted from the raw audio. I am using Tensorflow Lite to integrate the model into the app.  \nThe problem is that I need to perform the same feature extraction on the input audio from the mic before passing into the tflite model. Python's Librosa library implements all of the functions that I need. My initial idea was run Python in flutter (there is the starflut Flutter package but I couldn't get it to work). \nAm I going about this in the wrong way? If so, what should I be doing? I could potentially rewrite the Librosa functions in dart lang, but I don't particularly want to do that.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":552,"Q_Id":57838465,"Users Score":1,"Answer":"If you are targeting mobile, check the integration with \u201cnative\u201d code. E.g. look for a java\/kotlin library that can do the same on android. And a swift\/objC one for iOS.\nThen, you could wrap that functionality  in a platform-specific module.","Q_Score":0,"Tags":"python,android,tensorflow,machine-learning,flutter","A_Id":57839378,"CreationDate":"2019-09-08T00:59:00.000","Title":"Is it feasible to perform feature extraction in a Flutter app?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to import a python module called pattern in my code. However, when I run:\npip install pattern\nI get the following output:\nCollecting pattern\nUsing cached \nhttps:\/\/files.pythonhosted.org\/packages\/1e\/07\/b0e61b6c818ed4b6145fe01d1c341223aa6cfbc3928538ad1f2b890924a3\/Pattern-3.6.0.tar.gz\nCollecting future (from pattern)\n  Using cached https:\/\/files.pythonhosted.org\/packages\/90\/52\/e20466b85000a181e1e144fd8305caf2cf475e2f9674e797b222f8105f5f\/future-0.17.1.tar.gz\nCollecting backports.csv (from pattern)\n  Using cached https:\/\/files.pythonhosted.org\/packages\/8e\/26\/a6bd68f13e0f38fbb643d6e497fc3462be83a0b6c4d43425c78bb51a7291\/backports.csv-1.0.7-py2.py3-none-any.whl\nCollecting mysqlclient (from pattern)\n  Using cached https:\/\/files.pythonhosted.org\/packages\/4d\/38\/c5f8bac9c50f3042c8f05615f84206f77f03db79781db841898fde1bb284\/mysqlclient-1.4.4.tar.gz\n    ERROR: Command errored out with exit status 1:\n     command: \/usr\/bin\/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '\"'\"'\/tmp\/pip-install-4Proy9\/mysqlclient\/setup.py'\"'\"'; __file__='\"'\"'\/tmp\/pip-install-4Proy9\/mysqlclient\/setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))' egg_info --egg-base pip-egg-info\n         cwd: \/tmp\/pip-install-4Proy9\/mysqlclient\/\n    Complete output (12 lines):\n    sh: 1: mysql_config: not found\n    sh: 1: mariadb_config: not found\n    sh: 1: mysql_config: not found\n    Traceback (most recent call last):\n      File \"<string>\", line 1, in <module>\n      File \"\/tmp\/pip-install-4Proy9\/mysqlclient\/setup.py\", line 16, in <module>\n        metadata, options = get_config()\n      File \"setup_posix.py\", line 61, in get_config\n        libs = mysql_config(\"libs\")\n      File \"setup_posix.py\", line 29, in mysql_config\n        raise EnvironmentError(\"%s not found\" % (_mysql_config_path,))\n    EnvironmentError: mysql_config not found\n    ----------------------------------------\nERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.\nI already have mysql installed and I've tried installing mysqlclient as well. I am not sure what to do!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":331,"Q_Id":57839760,"Users Score":1,"Answer":"To build\/install mysqlclient you will need mysqlclient libraries and header files. To determine their location mysqlclient needs to call mysql_config script (which was not found).\nYou need to install mysql client library. (e.g. libmysqlclient-dev). Also make sure that mysql_config script is in your path.","Q_Score":1,"Tags":"python,mysql,database,installation,mariadb","A_Id":57840679,"CreationDate":"2019-09-08T06:48:00.000","Title":"Cannot install pattern module in python on windows ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have to create a setup screen with tk that starts only at the first boot of the application where you will have to enter names etc ... a sort of setup. Does anyone have any ideas on how to do so that A) is performed only the first time and B) the input can be saved and used in the other scripts? Thanks in advance","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":39,"Q_Id":57843754,"Users Score":1,"Answer":"Why not use a file to store the details? You could use a text file or you could use pickle to save a python object then reload it. On starting your application you could check to see if the file exists and contains the necessary information, if it doesn't you can activate your setup screen, if not skip it.","Q_Score":0,"Tags":"python,python-3.x,tkinter","A_Id":57843779,"CreationDate":"2019-09-08T16:32:00.000","Title":"Create Python setup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a \"Date\" column in my df and I wish to use it as the index of df\nDate values in 'Date' column are in the correct format as per DateTime (yyyy-mm-dd)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":57846743,"Users Score":0,"Answer":"Using set_index we can a column index of the df\ndf.set_index('Date')","Q_Score":0,"Tags":"python-3.x,date,dataframe,indexing","A_Id":57859057,"CreationDate":"2019-09-09T00:45:00.000","Title":"How can i change column of a df to index of the df?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a fit in python with lmfit and after I define my model (i.e. the functio I want to use for the fit) I do out = model.fit(...) and in order to visualize the result I do plt.plot(x, out.best_fit). This works fine, however this computes the value of the function only at the points used for the fit. How can I apply the parameters of the fit to any x vector (to get a smoother curve), something like x_1 = np.arange(xi,xf,i), plt.plot(x_1,out.best_fit(x_1))? Thank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":57848079,"Users Score":0,"Answer":"Including a complete, minimal example that shows what you are doing is always a good idea.  In addition, your subject is not a good reflection of your question. You have now asked enough questions about lmfit here on SO to know better. \nYou probably want to use ModelResult.eval() to evaluate the ModelResult (probably your out) for a given independent variable.  If you need more help, ask an answerable question that might be useful to others...","Q_Score":1,"Tags":"python,lmfit","A_Id":57863047,"CreationDate":"2019-09-09T04:58:00.000","Title":"Getting the parameters from lmfit","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Traceback (most recent call last):\n  File \"C:\\Users\\Karan Shah\\AppData\\Roaming\\Python\\Python37\\site-packages\\pyttsx3__init__.py\", line 20, in init\n    eng = _activeEngines[driverName]\n  File \"C:\\Users\\Karan Shah\\AppData\\Local\\Programs\\Python\\Python37\\lib\\weakref.py\", line 137, in getitem\n    o = self.datakey\nKeyError: 'sapi5'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):\n  File \"c:\\Users\\Karan Shah.vscode\\extensions\\ms-python.python-2019.9.34911\\pythonFiles\\ptvsd_launcher.py\", line 43, in \n    main(ptvsdArgs)\n  File \"c:\\Users\\Karan Shah.vscode\\extensions\\ms-python.python-2019.9.34911\\pythonFiles\\lib\\python\\ptvsd__main__.py\", line 432, in main\n    run()\n  File \"c:\\Users\\Karan Shah.vscode\\extensions\\ms-python.python-2019.9.34911\\pythonFiles\\lib\\python\\ptvsd__main__.py\", line 316, in run_file\n    runpy.run_path(target, run_name='main')\n  File \"C:\\Users\\Karan Shah\\AppData\\Local\\Programs\\Python\\Python37\\lib\\runpy.py\", line 263, in run_path\n    pkg_name=pkg_name, script_name=fname)\n  File \"C:\\Users\\Karan Shah\\AppData\\Local\\Programs\\Python\\Python37\\lib\\runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"C:\\Users\\Karan Shah\\AppData\\Local\\Programs\\Python\\Python37\\lib\\runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"c:\\Users\\Karan Shah\\Desktop\\Jarvis.py\", line 9, in \n    engine = pyttsx3.init('sapi5')\n  File \"C:\\Users\\Karan Shah\\AppData\\Roaming\\Python\\Python37\\site-packages\\pyttsx3__init__.py\", line 22, in init\n    eng = Engine(driverName, debug)\n  File \"C:\\Users\\Karan Shah\\AppData\\Roaming\\Python\\Python37\\site-packages\\pyttsx3\\engine.py\", line 30, in init\n    self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)\n  File \"C:\\Users\\Karan Shah\\AppData\\Roaming\\Python\\Python37\\site-packages\\pyttsx3\\driver.py\", line 50, in init","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":475,"Q_Id":57852827,"Users Score":0,"Answer":"The question is not so clear regarding the issue specified. Looks like there is a conflict  in the dll files. Could you check if you are using 32 bit python if you have downloaded the visual studio 32 bit version. \nIt would be of better practice to use 64 bit python as well a visual studio 64 bit version.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":57853016,"CreationDate":"2019-09-09T11:10:00.000","Title":"ImportError: DLL load failed: %1 is not a valid Win32 application.visual studio error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to do some tasks in django that consume alot of time. For that, I will be running background tasks.\nAfter some R&D, i have found two solutions:\n\nCelery with RabbitMQ.\nDjango Background tasks.\n\nBoth options seem to fulfill the criteria but setting up Celery will require some work. Now as far as the second option is concerned, setup is fairly simple and in fairly quick amount of time, i can go on writing background tasks. Now my questions if i adopt the 2nd option is this:\n\nHow well does Django Background tasks perform ? (Scalability wise in Production environment).\nCan i poll the tasks (after some time) in DB to check the task's status?\nArchitecture of Django-Background-tasks? Couldn't find any clear explanation about it's architecture (Or have I missed some resource?)\nAgain coming to the first point, how well does Django Background tasks perform in production. (Talking about prior experience of using this in prod.)","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":4312,"Q_Id":57854332,"Users Score":6,"Answer":"How well does Django Background tasks perform ? - This will depend upon how and what you implement. One thing to note is, Django-background-tasks is based upon database where celery can have redis\/rabbitmq as backend, so most probably we'll see considerable performance difference here.\nCan I poll the tasks (after some time) in DB to check the task's status? - It's possible in celery and maybe you can find a solution by inspecting django-background-tasks internal code. But one thing is, we can abort celery task, which maybe not possible in Django-Background-tasks.\nArchitecture of Django-Background-tasks? Couldn't find any clear explanation about it's architecture (Or have I missed some resource?) - It's simple Django based project. You can have a look at code. It's seems to be pretty straightforward.\nAgain coming to the first point, how well does Django Background tasks perform in production. - Haven't used in production. But since Django-Background-tasks is database based and celery can be configured to use redis\/rabbitmq - I think celery have a plus point here.\n\nTo me this comparison, seems to be link comparing pistol with a high-end automatic machine guns. Both do same job. But one simple straightforward - other little complicated but with lots of options and scope.\nChoose based on your use case.","Q_Score":6,"Tags":"python,django,task,celery,background-task","A_Id":57887089,"CreationDate":"2019-09-09T12:44:00.000","Title":"Django Background tasks vs Celery","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to do some tasks in django that consume alot of time. For that, I will be running background tasks.\nAfter some R&D, i have found two solutions:\n\nCelery with RabbitMQ.\nDjango Background tasks.\n\nBoth options seem to fulfill the criteria but setting up Celery will require some work. Now as far as the second option is concerned, setup is fairly simple and in fairly quick amount of time, i can go on writing background tasks. Now my questions if i adopt the 2nd option is this:\n\nHow well does Django Background tasks perform ? (Scalability wise in Production environment).\nCan i poll the tasks (after some time) in DB to check the task's status?\nArchitecture of Django-Background-tasks? Couldn't find any clear explanation about it's architecture (Or have I missed some resource?)\nAgain coming to the first point, how well does Django Background tasks perform in production. (Talking about prior experience of using this in prod.)","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":4312,"Q_Id":57854332,"Users Score":1,"Answer":"I have decided to use Django-Background-Tasks. Let me clarify my motivations.\nThe tasks that will be processed by Django-Background-Tasks doesn't need to be processed in a fast manner. As it is stated by the name, they are background tasks. I accept delays.\nThe architecture of Django-Background-Tasks is very simple. When you call a method to be process in the background in your code a task record is inserted to the Django-Background-Tasks tables in your database. And the method you called is not executed actually. It is proxied. Then you should trigger another process to execute the jobs. Your method is then executed in this process.\nThe process that execute jobs can be executed by a cron entry in your server.\nSince this setup is so easy and work for I decided to use Django-Background-Tasks. But If I needed something more responsive and fast I would use Celery since it is using memory and there is an active process that processes the jobs. Which isn't the case in Django-Background-Tasks.","Q_Score":6,"Tags":"python,django,task,celery,background-task","A_Id":68205920,"CreationDate":"2019-09-09T12:44:00.000","Title":"Django Background tasks vs Celery","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am encountering a task and I am not entirely sure what the best solution is.\nI currently have one data set in mongo that I use to display user data on a website, backend is in Python. A different team in the company recently created an API that has additional data that I would let to show along side the user data, and the data from the newly created API is paired to my user data (Shows specific data per user) that I will need to sync up.\nI had initially thought of creating a cron job that runs weekly (as the \"other\" API data does not update often) and then taking the information and putting it directly into my data after pairing it up.\nA coworker has suggested caching the \"other\" API data and then just returning the \"mixed\" data to display on the website.\nWhat is the best course of action here? Actually adding the data to our data set would allow us to have 1 source of truth and not rely on the other end point, as well as doing less work each time we need the data. Also if we end up needing that information somewhere else in the project, we already have the data in our DB and can just use it directly without needing to re-organize\/pair it. \nJust looking for general pro's and cons for each solution. Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":62,"Q_Id":57854727,"Users Score":2,"Answer":"Synchronization will always cost more than federation.  I would either A) embrace CORS and integrate it in the front-end, or B) create a thin proxy in your Python App.\nWhich you choose depends on how quickly this API changes, whether you can respond to those changes, and whether you need graceful degradation in case of remote API failure.  If it is not mission-critical data, and the API is reliable, just integrate it in the browser.  If they support things like HTTP cache-control, all the better, the user's browser will handle it.  \nIf the API is not scalable\/reliable, then consider putting in a proxy server-side so that you can catch errors and provide graceful degradation.","Q_Score":0,"Tags":"python,database,architecture","A_Id":57857492,"CreationDate":"2019-09-09T13:09:00.000","Title":"What is the best way to combine two data sets that depend on each other?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to run a omxplayer into a kivy application. The problem is that when I start the omxplayer its appearance behind the kivy app, so it is not visible.\nI tried using: Window.clearcolor = (0,0,0,0) but it doesn't work. I think that is because I'm running the app in a linux terminal.\nHow can I show the player in front of all applications?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":646,"Q_Id":57855165,"Users Score":1,"Answer":"I finally did it. Here the explanation.\nRaspberry video core put the different application's screens  in differents layers. The terminal is in layer -127 and, according to kivy docs, kivy run in layer 0 by default. In my python code I run omxplayer with the next line of code:\nPopen(['omxplayer', '--layer', '100000', '--live', '--refresh', '--video_queue', '4', '--fps', '30', '--win', '\"0 0 800 480\"', 'rtsp:\/\/192.168.0.88'])\nThe importart thing is --layer 100000, that is an option that allows us to choose the layer of omxplayer.\nIn my case, ran it in layers like 128 but it didn't work, so I suspect that kivy is not in layer zero. I ended putting 100000 and it works.\nIts good to say that the kivy app keeps running in a lower layer, so every input signal (keyboard, buttons, etc.) is still working.","Q_Score":0,"Tags":"python,kivy,raspberry-pi3,omxplayer","A_Id":57944977,"CreationDate":"2019-09-09T13:36:00.000","Title":"How to put omxPlayer on top of Kivy application in raspbian lite?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a rather general question:\nI am having issues that the same operation measured by time.clock() takes longer now than it used to.\nWhile I had very some very similar measurements\n\n1954 s\n1948 s\n1948 s\n\nOne somewhat different measurement\n\n1999 s\n\nAnother even more different\n\n2207 s\n\nIt still seemed more or less ok, but for another one I get\n\n2782 s\n\nAnd now that I am repeating the measurements, it seems to get slower and slower.\nI am not summing over the measurements after rounding or doing other weird manipulations.\nDo you have some ideas whether this could be affected by how busy the server is, the clock speed or any other variable parameters? I was hoping that using time.clock() instead of time.time() would mostly sort these out...\nThe OS is Ubuntu 18.04.1 LTS.\nThe operations are run in separate screen sessions.\nThe operations do not involve hard-disk acccess.\nThe operations are mostly numpy operations that are not distributed. So this is actually mainly C code being executed.\nEDIT: This might be relevant: The measurements in time.time() and time.clock() are very similar in any of the cases. That is time.time() measurements are always just slightly longer than time.clock(). So if I haven't missed something, the cause has almost exactly the same effect on time.clock() as on time.time().\nEDIT: I do not think that my question has been answered. Another reason I could think of is that garbage collection contributes to CPU usage and is done more frequently when the RAM is full or going to be full.\nMainly, I am looking for an alternative measure that gives the same number for the same operations done. Operations meaning my algorithm executed with the same start state. Is there a simple way to count FLOPS or similar?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":57857413,"Users Score":0,"Answer":"As a result of repeatedly running the same algorithm at different 'system states', I would summarize that the answer to the question is:\nYes, time.clock() can be heavily affected by the state of the system.\nOf course, this holds all the more for time.time().\nThe general reasons could be that\n\nThe same Python code does not always result in the same commands being sent to the CPU - that is the commands depend not only on the code and the start state, but also on the system state (i.e. garbage collection)\nThe system might interfere with the commands sent from Python, resulting in additional CPU usage (i.e. by core switching) that is still counted by time.clock()\n\nThe divergence can be very large, in my case around 50%.\nIt is not clear which are the specific reasons, nor how much each of them contributes to the problem.\nIt is still to be tested whether timeit helps with some or all of the above points. However timeit is meant for benchmarking and might not be recommended to be used during normal processing. It turns off garbage collection and does not allow accessing return values of the timed function.","Q_Score":3,"Tags":"python,time,python-2.x,clock,wall-time","A_Id":57884855,"CreationDate":"2019-09-09T15:56:00.000","Title":"Can time.clock() be heavily affected by the state of the 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m working on a TXT to SPC converter, and certain values have to be stored as hex of double, but Python only works with float and struct.unpack(\u2018<d\u2019, struct.pack(\u2018<f\u2019, value))\/any other unpack and pack matryoshka doll I can conceive doesn\u2019t work because of the difference in byte size.\nThe SPC library unpacks said values from SPC as <d and converts them to float through float()\nWhat do I do?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":122,"Q_Id":57860330,"Users Score":1,"Answer":"I think you may be getting confused by different programming languages' naming strategies.\nThere's a class of data types known as \"floating point numbers\". Two floating-point number types defined by IEEE-754 are \"binary32\" and \"binary64\". In C and C++, those two types are exposed as the types float and double, respectively. In Python, only \"binary64\" is natively supported as a built-in type; it's known as float. \nPython's struct module supports both binary32 and binary64, and uses C\/C++'s nomenclature to refer to them. f specifies binary32 and d specifies binary64. Regardless of which you're using, the module packs from and unpacks to Python's native float type (which, remember, is binary64). In the case of d that's exact; in the case of f it converts the type under the hood. You don't need to fool Python into doing the conversion. \nNow, I'm just going to assume you're wrong about \"stored as hex of double\". What I think you probably mean is \"stored as double\" -- namely, 64 bits in a file -- as opposed to stored as \"hex of double\", namely sixteen human-readable ASCII characters. That latter one just doesn't happen.\nAll of which is to say, if you want to store things as binary64, it's just a matter of struct.pack('d', value).","Q_Score":0,"Tags":"python-3.x,struct,floating-point,double","A_Id":57870643,"CreationDate":"2019-09-09T19:42:00.000","Title":"Is it possible to convert a float to double?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My understanding of Python asserts is that are meant for debugging and that they don't get executed for \"optimized\" Python code (python -O).\nFor production app engine code, is -O used and thus stripping asserts or will asserts get executed?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":57860405,"Users Score":0,"Answer":"As far as i understand from Python asserts, once you set the global assertions to -0 they all become \"null-operations\" as in, they will get compiled but won't be evaluated or have they're conditional expressions executed. \nThey get set like that at the Python interpreter level so i don't think that GAE actually affects that.","Q_Score":0,"Tags":"python,google-app-engine,assert","A_Id":57867078,"CreationDate":"2019-09-09T19:51:00.000","Title":"Do asserts get stripped out in GAE Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My understanding of Python asserts is that are meant for debugging and that they don't get executed for \"optimized\" Python code (python -O).\nFor production app engine code, is -O used and thus stripping asserts or will asserts get executed?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":57860405,"Users Score":3,"Answer":"I ran a test on the platforms I use to know for sure.  Asserts do get executed for:\n\nGAE standard first generation\nGAE flexible","Q_Score":0,"Tags":"python,google-app-engine,assert","A_Id":57924896,"CreationDate":"2019-09-09T19:51:00.000","Title":"Do asserts get stripped out in GAE Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I\u2019m using pandas 0.25.1 in Jupyter Lab and the maximum number of rows I can display is 10, regardless of what pd.options.display.max_rows is set to. \nHowever, if pd.options.display.max_rows is set to less than 10 it takes effect and if pd.options.display.max_rows = None then all rows show.\nAny idea how I can get a pd.options.display.max_rows of more than 10 to take effect?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":32532,"Q_Id":57860775,"Users Score":-1,"Answer":"min_rows displays the number of rows to be displayed from the top (head) and from the bottom (tail) it will be evenly split..despite putting in an odd number. If you only want a set number of rows to be displayed without reading it into the memory,\nanother way is to use nrows = 'putnumberhere'.\ne.g. results = pd.read_csv('ex6.csv', nrows = 5) # display 5 rows from the top 0 - 4\nIf the dataframe has about 100 rows and you want to display only the first 5 rows from the top...NO TAIL use .nrows","Q_Score":38,"Tags":"python,pandas","A_Id":66486493,"CreationDate":"2019-09-09T20:26:00.000","Title":"pandas pd.options.display.max_rows not working as expected","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some kind of single page application which composes XHR requests on-the-fly. It is used to implement pagination for a list of links I want to click on using selenium.\nThe page only provides a Goto next page link. When clicking the next page link a javascript function creates a XHR request and updates the page content.\nNow when I click on one of the links in the list I get redirected to a new page (again through javascript with obfuscated request generation). Though this is exactly the behaviour I want, when going back to the previous page I have to start over from the beginning (i.e. starting at page 0 and click through to page n)\nThere are a few solutions which came to my mind:\n\nblock the second XHR request when clicking on the links in the list, store it and replay it later. This way I can skim through the pages but keep my links for replay later\nSomehow 'inject' the first XHR request which does the pagination in order to save myself from clicking through all the pages again \n\nI was also trying out some simple proxies but https is causing troubles for me and was wondering if there is any simple solution I might have missed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":150,"Q_Id":57861058,"Users Score":0,"Answer":"browsermobproxy integrates easily and will allow you to capture all the requests made. It should also allow you to block certain calls from returning.\nIt does sound like you are scraping a site, so it might be worth parsing the data the XHR calls make and mimicking them.","Q_Score":0,"Tags":"python,selenium","A_Id":57914026,"CreationDate":"2019-09-09T20:53:00.000","Title":"Logging and potentially blocking XHR Requests by javascript using selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to connect to and read an on-premise data source using an AWS Glue Python Shell job. I am using Pygresql (which comes bundled on Glue) and Pandas. Everything works locally.\nBut when I push this job up to Glue, the database connections all timeout. Why is this happening? Do I need to do something magic with VPCs?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":226,"Q_Id":57861188,"Users Score":1,"Answer":"I guess you need to create a Glue connection with your VPC settings and attach it to the Glue job.","Q_Score":0,"Tags":"python-3.x,amazon-web-services,aws-glue,amazon-vpc,pygresql","A_Id":57869524,"CreationDate":"2019-09-09T21:05:00.000","Title":"AWS Glue Python Shell script timing out","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to connect to and read an on-premise data source using an AWS Glue Python Shell job. I am using Pygresql (which comes bundled on Glue) and Pandas. Everything works locally.\nBut when I push this job up to Glue, the database connections all timeout. Why is this happening? Do I need to do something magic with VPCs?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":57861188,"Users Score":0,"Answer":"Note that pygresql SQL query doesn't work in python shell. Recommended is postgresql","Q_Score":0,"Tags":"python-3.x,amazon-web-services,aws-glue,amazon-vpc,pygresql","A_Id":57875570,"CreationDate":"2019-09-09T21:05:00.000","Title":"AWS Glue Python Shell script timing out","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Dataframe which columns is ['a','b','c'] and a Series param contain three values which is params of Dataframe. The param.index is ['a','b','c']. I want to realize df['a'] * param['a'] + df['b'] * param['b'] + df['c'] * param['c']. Because there are too many columns and params in my code. So is there any concise and elegant code can realize this?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":41,"Q_Id":57863464,"Users Score":1,"Answer":"I think df * param.to_list() is good.","Q_Score":1,"Tags":"python,pandas,dataframe","A_Id":57863569,"CreationDate":"2019-09-10T02:59:00.000","Title":"DataFrame each column miltiply param then sum","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Dataframe which columns is ['a','b','c'] and a Series param contain three values which is params of Dataframe. The param.index is ['a','b','c']. I want to realize df['a'] * param['a'] + df['b'] * param['b'] + df['c'] * param['c']. Because there are too many columns and params in my code. So is there any concise and elegant code can realize this?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":41,"Q_Id":57863464,"Users Score":1,"Answer":"df*param is enough, it will auto determine according to the index.\nYou can change series indexes to ['b','c','a'] for testing","Q_Score":1,"Tags":"python,pandas,dataframe","A_Id":57864150,"CreationDate":"2019-09-10T02:59:00.000","Title":"DataFrame each column miltiply param then sum","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm setting up a Django project for the first time using Pycharm, and I'm trying to figure out what the configurations do.\nI have looked online at the documentation, but it seems to be more focused towards people who already know what configurations do.\nI'm assuming it is used to set up my localhost, however I'm unsure. Any help would be greatly appreciated!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":57863683,"Users Score":0,"Answer":"How I config Run\/Debug Configurations in Pycharm Community:\n\nAdd a Python Configuration\nScript path: \"path to manage.py\"\nParameters: runserver \"host\":\"port\" \"option like '--noreload', '--nothreading'\"\nPython interpreter: \"path to venv\"\n\nNow you are able to run with Shift + F10","Q_Score":3,"Tags":"python,django,configuration,pycharm","A_Id":57863945,"CreationDate":"2019-09-10T03:31:00.000","Title":"What are Django configurations?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to start my new Django project on my server. so i install cpanel. but in software part, there is nothing related to python.\nShould i Do something in WHM? or install something in my server?\nthanks for helping me.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3378,"Q_Id":57868008,"Users Score":1,"Answer":"python app (django & flask) are available on cpanel only if CloudLinux is installed , so you have to install a CloudLinux on your server and then try to setup a python app using cpanel interface .","Q_Score":0,"Tags":"python,django,cpanel,whm","A_Id":63349203,"CreationDate":"2019-09-10T09:38:00.000","Title":"How to enable setup python app on cpanel?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to start my new Django project on my server. so i install cpanel. but in software part, there is nothing related to python.\nShould i Do something in WHM? or install something in my server?\nthanks for helping me.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3378,"Q_Id":57868008,"Users Score":1,"Answer":"You must upgrade your OS to Cloudlinux then you will have that feature.\nWhen you have Cloudlinux installed, you will have an option in WHM called \"Live Manager\" where you can activate Python.","Q_Score":0,"Tags":"python,django,cpanel,whm","A_Id":64323074,"CreationDate":"2019-09-10T09:38:00.000","Title":"How to enable setup python app on cpanel?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I create a Conda environment (myenv), and build a Python extension (using distutils) in this env.\nMy library uses some libraries which exist on both \/usr\/local\/lib and \/home\/user\/miniconda3\/envs\/myenv\/lib.\nIn myenv, LD_LIBRARY_PATH is empty, but ldd mylib.so shows that my library links to libraries in \/home\/user\/miniconda3\/envs\/myenv\/lib.\nThis makes sense but I wonder why it doesn't link to libraries in \/usr\/local\/lib?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2566,"Q_Id":57868519,"Users Score":0,"Answer":"Most likely, you're using the compiler and related toolchain from your conda environment. This toolchain is set up to use the libraries from your conda environment automatically.","Q_Score":5,"Tags":"python,conda,distutils","A_Id":57936028,"CreationDate":"2019-09-10T10:08:00.000","Title":"LD_LIBRARY_PATH in Conda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I create a Conda environment (myenv), and build a Python extension (using distutils) in this env.\nMy library uses some libraries which exist on both \/usr\/local\/lib and \/home\/user\/miniconda3\/envs\/myenv\/lib.\nIn myenv, LD_LIBRARY_PATH is empty, but ldd mylib.so shows that my library links to libraries in \/home\/user\/miniconda3\/envs\/myenv\/lib.\nThis makes sense but I wonder why it doesn't link to libraries in \/usr\/local\/lib?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2566,"Q_Id":57868519,"Users Score":2,"Answer":"I found that path\n$ORIGIN\/..\/lib was set in RPATH of python in myenv.","Q_Score":5,"Tags":"python,conda,distutils","A_Id":58164888,"CreationDate":"2019-09-10T10:08:00.000","Title":"LD_LIBRARY_PATH in Conda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"We have set up a bokeh server in our institute, which works properly. We also have a python-based code to analyse fMRI data which at the moment uses matplotlib to plot and save. But I want to transfer the code to bokeh server and allow everybody to upload files into the server from the client and when the analysis is done in the server, save the output plots in their local HDD. This transfer file procedure seems to be lacking in bokeh atm. I saw a new feature recently added in github to upload json files, but my problem is fMRI files come in various formats, and asking (not necessarily tech-savvy) users to convert the files into a certain format beats the purpose. Also, I do not know any JS or the like, hence I do not know what solutions people usually use for such web-based applications. \nIf anybody has any solutions to get around this issue, it'd be happy to hear it. Even if it is a solution independent of bokeh (which would mean users need to open a separate page to upload the files, a page to run the analysis, and a page to save the output) please let me know. It won't be ideal, but at least better than no solution, which is the case in bokeh right now. Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":184,"Q_Id":57868893,"Users Score":1,"Answer":"I'm not sure where you are getting your information. The FileInput widget added in Bokeh 1.3.0 can upload any file the user chooses, not just JSON.","Q_Score":0,"Tags":"javascript,python,webserver,bokeh,bokehjs","A_Id":57882320,"CreationDate":"2019-09-10T10:29:00.000","Title":"Uploading a file from client to server in python bokeh","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What's going to happen?\nI got a big amount of Scrapy crawlers, written in Python 2.7. I need to convert them all to support Python 3.\nThis transition must be done completely in 1 go. I can only start using the Python 3 crawlers once they're all ready for deployment. I cannot deploy 1 crawler at a time.\nWhat have I done\/what do I have?\nI currently have a remote branch, which is the master branch. Lets call that Remote-A. That is the branch that holds all the crawlers, and they get executed daily. This branch must remain functional.\nFor that remote branch, I have the local folder\/branch, where I fix bugs and create new ones. Lets call that Local-A. From the master, I push and pull from that.\nNow, as \"all operations must remain active\", I need a separate remote branch for Python 3 crawlers. That branch can be called Remote-B. I've created that manually, so the whole repository has two branches now: Master(Remote-A), and the one for Python 3 crawlers(Remote-B), which is a copy of the Master branch.\nI've also created a folder manually, and downloaded a zip from the Python 3 branch. That folder is called Local-B. My idea is to either delete all the (2.7) crawlers from Python 3 branch, or just start replacing them one by one.\nTo sum it up. I got Local A connected to Remote A. I also need Local B connected to Remote B. These two connections should not get mixed.\nMind you, I'm not very comfortable with GIT, and I'm the only responsible for the transition project, so I want everything to go smooth as silk. I know that it's easy to cause a lot of damage in GIT.\nSo, my workflow requires me to keep the running crawlers operational on daily basis, and work on upgrading the old ones to Python 3. How do I make the switches between A- and B-sides easy, without causing a havoc?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":107,"Q_Id":57869506,"Users Score":2,"Answer":"If I understand your question, I am afraid you are a bit confused about the concepts of branch and remote. A remote would be github, and also a local mirror of your git repo.\nYou can have as many mirrors as you like. All would contain all the branches.\nIn your case, and also if I understand your question, I would do as follows:\n\nhave a deploy branch (which what you seem to name as Remote-A - a name that is confusing to me): this branch should always be correct\nhave a python2 development branch (suggested name: py2dev), in case you need to perform modifications in the python2 deployed code before deploying the python3 code\nhave a python3 migration branch (suggested name: py3) where you would be migrating the python2 code\n\nWhile the python3 migration is not ready, you would develop on the py2dev branch in your computer. In case you want to publish some change, you would publish these changes in your remote (i.e. github), and then pull these changes from that remote (github) in your deployed repo.\nWhen the python3 migration is ready, you would push your changes again to a remote, and then fetch them, and do a git checkout py3 in the deployed server. If things go wrong, you can do a git checkout deploy and you would be safe again.\nThere are many git workflows. This is supposed to be a simple one.","Q_Score":0,"Tags":"python,git,github,scrapy","A_Id":57869932,"CreationDate":"2019-09-10T11:06:00.000","Title":"How do I switch between remote github branches and local branches\/folders with ease?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am in heavy debugging mode where I have to restart the kernel fairly frequently, and am making heavy use of lots of cells in Spyder. When I am about 10 cells in and this happens, it would be really nice to be able to just run all cells above the current cell, sort of like you have in Jupyter. \nI know I can manually go through and run cells 1-9 with Shift-Enter, or I can select all the code manually and hit F9. Is there a shortcut?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":827,"Q_Id":57871362,"Users Score":2,"Answer":"I usually just create a syntax error where I want to stop execution and then press F5.\nEDIT:\nIt just occurred to me that this isn't quite right.  A syntax error will prevent execution from starting.  What I actually do is provoke a NameError:\nNameError: name 'stop' is not defined","Q_Score":1,"Tags":"python-3.x,spyder","A_Id":60363102,"CreationDate":"2019-09-10T12:59:00.000","Title":"Spyder: How to run all cells above current cell?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"ERROR: Could not install packages due to an EnvironmentError: [Error\n  5] Access is denied:\n  'c:\\programdata\\anaconda2\\lib\\site-packages\\pip\\_internal\\build_env.py'\n  Consider using the --user option or check the permissions.\n\nThis is the error which is I am getting when I am trying to install pip. can anyone help me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":57872347,"Users Score":2,"Answer":"When you are running the command, you are getting user permissions, not admin permissions. You can try running the terminal as admin, and then using the same command, it will work.\nOtherwise, as it says, you can add --user to the end of the command, it will run it without trying to reach \"admin-only\" directories.","Q_Score":2,"Tags":"python","A_Id":57872401,"CreationDate":"2019-09-10T13:54:00.000","Title":"getting anaconda2 error in installing pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a Python 3.5 virtual environment on a server having Python 2.7\/3.5 without any admin(sudo) privileges. However, a specific task requires Python 3.7. I am looking for a way to upgrade\/install this (or upgrade the virtual environment if possible) without affecting the whole machine.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":478,"Q_Id":57872782,"Users Score":0,"Answer":"Python virtual environments are very closely coupled with Python versions for which they were created. Even updating venv to a new bugfix release could be problematic. Upgrading to a new major release is impossible.\nCreate a different, new empty venv with Python 3.7. Activate it and install necessary packages.","Q_Score":1,"Tags":"python,virtualenv","A_Id":57874609,"CreationDate":"2019-09-10T14:18:00.000","Title":"Install\/Upgrade Python3.7 inside a Virtual Environment of Python 3.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using flair for sentiment analysis and it's datasets. The datasets for flair are quite large in size and are currently installed on my quite small SSD in my user folder. Is there anyway that I can move the .flair folder from my user folder on my SSD to my other drive without breaking anything.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":57874651,"Users Score":0,"Answer":"When importing datasets into flair, one can specify a custom path to import from. Copy the flair datasets to a folder you choose on your larger harddrive and then specify that path when loading a dataset.\nflair.datasets.WASSA_FEAR(data_folder=\"E:\/flair_datasets\/\")","Q_Score":0,"Tags":"python,python-3.x","A_Id":62965796,"CreationDate":"2019-09-10T16:13:00.000","Title":"How to change location of .flair directory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have no problem with pushing a kivy app to my android phone as long as it's very simple.\nBut when I try to import pandas it just crashes. The app starts loading and then just closes. \nDoes anyone know what can be the issue and how can I open a debugger or something similar? I know pandas can be imported with Kivy because there are some examples out there using pandas.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":57874858,"Users Score":0,"Answer":"writing and running a kivy app that uses\/imports pandas poses no problem when you run it ordinarily. but when you convert it to an apk, it will load and crash. this is because python4android doesn't support pandas explicitly for now. what you can do is apply a patch.","Q_Score":0,"Tags":"python,android,pandas,kivy","A_Id":57875490,"CreationDate":"2019-09-10T16:26:00.000","Title":"How to debug an andorid app made with Kivy that crashes when importing pandas?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say I have an app called polls.\nWhat is the difference between including an app in INSTALLED_APPS like this 'polls.apps.PollsConfig' and just specifying the app's name ( 'polls')?\nThe official Django tutorial recommends the former.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":57875834,"Users Score":2,"Answer":"The latter is the old way and it has got problems in some cases with the position in INSTALLED_APPS as the preferred way has been to put your apps the last, so all your dependencies are already available when your app is loaded. \nThe former is the new improved way when you load your app configuration instance first and so all the dependencies are aware of your app and also your app prior to loading has got all the dependencies available.\nYou should use AppConfig and put it at the top of the list, plain app positioned last is relict of the past.","Q_Score":0,"Tags":"python,django","A_Id":57876063,"CreationDate":"2019-09-10T17:37:00.000","Title":"Two ways of including an app in INSTALLED_APPS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Has anyone found a way to successfully set up an environment for a jupyter notebook without having the full version of Anaconda installed on your system? I am using Miniconda and have been unable to use a conda environment with the jupyter notebook platform. Note that with Miniconda source activate myenv will not work.\nI also tried using ipykernel which did successfully get an environment to appear in my notebook (via the command: python -m ipykernel install --user --name myenv). However, this environment is still made as a copy of my base environment. Commands similar to conda create -n test_env python=3.7 don't seem to be compatible with ipykernel unless I am missing something.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":311,"Q_Id":57877029,"Users Score":0,"Answer":"You don't need to run ipython from the environment you are adding.\nSince you've got an environment with jupyter, lets call that Jenv.\ngo to your miniconda install location\nScripts\/activate Jenv\nconda create -n SomeOther_vEnv python=3.6.8 whateverPackagesYouWant\npython -m ipykernel install --sys-prefix --name SomeOther_vEnv --display-name \"foo\"\nNow jupyter when started from your Jenv should see \"foo\". You can't start jupyter from foo, but you can use it in a jupyter server started from Jenv. (unless whateverPackagesYouWant included jupyter of course)","Q_Score":0,"Tags":"python-3.x,jupyter-notebook,conda,environment,miniconda","A_Id":57877803,"CreationDate":"2019-09-10T19:21:00.000","Title":"Using a Conda Environment in Jupyter via Miniconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using tf.nn.sparse_softmax_cross_entropy_with_logits and when I pass through the labels and logits I get the following error\n\ntensorflow.python.framework.errors_impl.InvalidArgumentError: labels\n  must be 1-D, but got shape [50,1]\n\nI don't understnad how having a shape [50,1] is not the same as being 1D","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":108,"Q_Id":57878623,"Users Score":1,"Answer":"I don't understand how having a shape [50,1] is not the same as being 1D.\n\nWhile you can reshape a [50, 1] 2D matrix into a [50] 1D matrix just with a simple squeeze, Tensorflow will never do that automatically. \nThe only heuristic the tf.nn.sparse_softmax_cross_entropy_with_logits uses to check if the input shape is correct is to check the number of dimensions it has. If it's not 1D, it fails without trying other heuristics like checking if the input could be squeezed. This is a security feature.","Q_Score":0,"Tags":"python,tensorflow,neural-network,entropy","A_Id":57887051,"CreationDate":"2019-09-10T21:47:00.000","Title":"Error with tf.nn.sparse_softmax_cross_entropy_with_logits","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a long-running Apache Beam batch analysis process on Google Cloud Dataflow that failed partway through.  To save time and cost, is it possible to update my code to handle the failure, and re-run from the failure point using cached intermediate checkpoints?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":450,"Q_Id":57879396,"Users Score":1,"Answer":"Dataflow batch pipelines discard all intermediate results when the pipeline terminates (successfully or fails).\nCurrently you would need to add points within the pipeline where the intermediate data is materialized and then on failure you could launch a new pipeline which is a subset of your existing pipeline that reads the intermediate results and continues processing.","Q_Score":0,"Tags":"python,google-cloud-dataflow,apache-beam","A_Id":57915380,"CreationDate":"2019-09-10T23:43:00.000","Title":"Can an Apache Beam batch process be restarted from a checkpoint?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have used Tensorflow object detection for quite awhile now. I am more of a user, I dont really know how it works. I am wondering is it possible to train it to recognize an object is something and not something? For example, I want to detect cracks on the tiles. Can i use object detection to do so where i show an image of a tile and it can tell me if there is a crack (and also show the location), or it will tell me if there is no crack on the tile? \nI have tried to train using pictures with and without defect, using 2 classes (1 for defect and 1 for no defect). But the results keep showing both (if the picture have defect) in 1 picture. Is there a way to show only the one with defect?\nBasically i would like to do defect checking. This is a simplistic case of 1 defect. but the actual case will have a few defects.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":92,"Q_Id":57879708,"Users Score":0,"Answer":"In case you're only expecting input images of tiles, either with defects or not, you don't need a class for no defect.\nThe API adds a background class for everything which is not the other classes.\nSo you simply need to state one class - defect, and tiles which are not detected as such are not defected. \nSo in your training set - simply give bounding boxes of defects, and no bounding box in case of no defect, and then your model should learn to detect the defects as mentioned above.","Q_Score":0,"Tags":"python-3.x,tensorflow,object-detection","A_Id":57888733,"CreationDate":"2019-09-11T00:46:00.000","Title":"Using tensorflow object detection for either or detection","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a data mining script to pull information off of a program called Agisoft PhotoScan for my lab. PhotoScan uses its own Python library (and I'm not sure how to access pip for this particular build), which has caused me a few problems installing other packages. After dragging, dropping, and praying, I've gotten a few packages to work, but I'm still facing a memory leak. If there is no way around it, I can try to install some more packages to weed out the leak, but I'd like to avoid this if possible.\nMy understanding of Python garbage collection so far is, when an object loses its reference, it should be deleted. I used sys.getrefcount() to check all my variables, but they all stay constant. I have a hunch that the issue could be in the mysql-connector package I installed, or in PhotoScan itself, but I am not sure how to go about testing. I will be more than happy to provide code if that will help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":57893668,"Users Score":0,"Answer":"It turns out that the memory leak was indeed with the PhotoScan program. I've worked around it by having a separate script open and close it, running my original script once each time. Thank you all for the help!","Q_Score":0,"Tags":"python,mysql-connector-python","A_Id":57895212,"CreationDate":"2019-09-11T16:52:00.000","Title":"How can I find memory leaks without external packages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to setup a cron job to run a python script every hour, but it has to be run with python3.\nI've tried setting up the cron to point to the python 3.6 libraries, but this doesn't seem to work.\nThis is how I've set it up\n\n0 * * * * \/usr\/local\/lib\/python3.6\/python3 \/mnt\/dietpi_userdata\/python\/main.py\n\nI suspect it's something simple, but it's beyond my own (googling) skills.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":57894681,"Users Score":0,"Answer":"Are you sure that your python3 path is correct? If you are not using a virtual environment you could try this:\n0 * * * * $(which python3) \/mnt\/dietpi_userdata\/python\/main.py\nAdditionally you could manually run which python3 to verify your python3 path.","Q_Score":0,"Tags":"python-3.6,raspbian","A_Id":57894826,"CreationDate":"2019-09-11T18:12:00.000","Title":"How do I setup a cron to run specifically 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 have an API (in python) which has to alter files inside an EC2 instance that is already running. I'm searching on boto3 documentation, but could only find functions to start new EC2 instances, not to connect to an already existing one.\nI am currently thinking of replicating the APIs functions to alter the files in a script inside the EC2 instance, and having the API simply start that script on the EC2 instance by accessing it using some sort of SSH library. \nWould that be the correct approach, or is there some boto3 function (or in some of the other Amazon\/AWS libraries) that allows me to start a script inside existing instances?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2456,"Q_Id":57896987,"Users Score":3,"Answer":"Unless you have a specific service running on that machine which allows you to modify mentioned files. I would make an attempt to log onto EC2 instance as to any other machine via network. \nYou can access EC2 machine via ssh with use of paramiko or pexpect libraries.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-ec2,boto3","A_Id":57897084,"CreationDate":"2019-09-11T21:24:00.000","Title":"Running Python Script in an existing EC2 instance on AWS","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 made a file crawler using python to read all my pictures in my computer (around 250 K files) and saving this information on a MySQL Database. I also save all the EXIF metadata for each file. \nNext, I'll like to add tags to them associating them to an unique ID but that is always the same for the same picture, just in case I run my crawler again and the file changes it's location or it's name.\nFor that purpuse I created a hash using string with relevant Exif information.\nI've taken into consideration that over the years I've taken pictures with different camaras or phones, and some Exif tags are not present in all cameras. I've also have seen that most tags don't have many different values that can make the string unique.\nIm using: \nExif_Image_Length * Exif_Image_Width   (area of the picture)\n+ Image_DateTime +   Image_Make + Image_Model\nand making a hash out of that string. I still get duplicates hashes instead of unique hashes.\nI'll love if someone has a better approach for what I'm trying to do.\nThanks in advance,\nPablo\nEDIT: I need to get an unique ID for images that every time I proccess that filename \/ exif metadata I get the same ID considering the filename and location might change (but EXIF data will remain intact)","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1001,"Q_Id":57898960,"Users Score":-1,"Answer":"did you get any new ideas? In photos with exif data there are sometimes some unique ids. One should be always the same even if your for example convert raw => psd => jpg => psd => jpg .\nDid you really get duplicates when all the data fields you mentioned are set?\nFrom the view of an photographer:\nWidth + Height is pretty useless (always the same for on camera, except its an cropped image)\nYou could use serialnumber of the camera including lens serial\nThank's to creation time the only duplicates should exist because of an short burst of photos with an short intervall.\nPossible Errors:\nModification of date\/time (for example sommer time conversion)\nManually created files or using clipboard or some weird stuff.\nIts just really an duplicate.","Q_Score":0,"Tags":"python,hash,exif","A_Id":59585404,"CreationDate":"2019-09-12T02:27:00.000","Title":"Get unique ID for pictures using Exif metada","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've created a neural network with a sigmoid activation function in the last layer, so I get results between 0 and 1. I want to classify things in 2 classes, so I check \"is the number > 0.5, then class 1 else class 0\". All basic.\nHowever, I would like to say \"the probability of it being in class 0 is x and in class 1 is y\".\nHow can I do this?\n\nDoes a number like 0.73 tell me it's 73% sure to be in class 1? And then 1-0.73 = 0.27 so 27% in class 0?\nWhen it's 0.27, does that mean it's 27% sure in class 0, 73% in class 1? Makes no sense.\n\nShould I work with the 0.5 and look \"how far away from the center is the number, and then that's the percentage\"?\nOr am I misunderstanding the result of the NN?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1575,"Q_Id":57903518,"Users Score":4,"Answer":"As pointed out by Teja, the short answer is no, however, depending on the loss you use, it may be closer to truth than you may think.\nImagine you try to train your network to differentiate numbers into two arbitrary categories that are beautiful and ugly. Say your input number are either 0 or 1 and 0s have a 0.2 probability of being labelled ugly whereas 1s have o 0.6probability of being ugly.\nImagine that your neural network takes as inputs 0s and 1s, passes them into some layers, and ends in a softmax function. If your loss is binary cross-entropy, then the optimal solution for your network is to output 0.2 when it sees a 0 in input and 0.6 when it sees a 1 in input (this is a property of the cross-entropy which is minimized when you output the true probabilities of each label). Therefore, you can interpret these numbers as probabilities.\nOf course, real world examples are not that easy and are generally deterministic so the interpretation is a little bit tricky. However, I believe that it is not entirely false to think of your results as probabilities as long as you use the cross-entropy as a loss.\nI'm sorry, this answer is not black or white, but reality is sometimes complex ;)","Q_Score":3,"Tags":"python,tensorflow,sigmoid","A_Id":57907511,"CreationDate":"2019-09-12T09:18:00.000","Title":"Interpreting a sigmoid result as probability in neural networks","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using the isolation forest algorithm from sklearn to do some unsupervised anomaly detection. \nI need to explained the predictions and I was wondering if there is any way to get the paths that lead to the decision for each sample.\nI usually used SHAP or ELI5 but i'd like to do something more custom. So i need the exact path.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2005,"Q_Id":57904088,"Users Score":0,"Answer":"You are creating an ensemble of trees so and the path of a given instance will be different for each tree in the ensemble. To detect an anomaly the isolation forest takes the average path length (number of splits to isolate a sample) of all the trees for a given instance and uses this to determine if it is an anomaly (average shorter path lengths indicate anomalies). As you are looking at the average of a set of trees there is no 'exact' path.\nWithin my knowledge, your best bet would be to use something like SHAP, as you mentioned, but you could also train only a few estimators and look at the path taken for a given instance in these trees to get an insight into the decisions.","Q_Score":0,"Tags":"python,unsupervised-learning,anomaly-detection","A_Id":57905788,"CreationDate":"2019-09-12T09:51:00.000","Title":"Is it possible to explain sklearn isolation forest prediction?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a linux system with a limited home directory space. When I create an environment to a different directory lets say work - which has larger quota- it still installs packages to .conda\/pkgs\/ folder which takes couple of gigabytes of space.\nIs it possible to change this directory?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":407,"Q_Id":57908554,"Users Score":-1,"Answer":"Have you installed conda (Anaconda or Miniconda) into your home directory? By default, the installation creates the pkgs directory and puts all packages there.\nHow about installing conda (Miniconda) itself into your work directory? Then you're also sure that conda can hardlink the packages into your environments in the work directory.","Q_Score":0,"Tags":"python,conda","A_Id":57935902,"CreationDate":"2019-09-12T14:08:00.000","Title":"Conda installs packages to default .conda folder. Is it possible to change this folder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to take x number of columns from an existing df and convert them into a dictionary.\nMy questions are:\n\nThe method shown below is considered a good practice? I think it's repetitive and I'm sure it can be a more elegant code.\nShould I convert from df to dictionary if my idea is to build a plot? Or it's an unnecessary step?\n\nI've tried the code below:\nfamiliarity_dic = familiarity[{'Question':'Question','SCORE':'SCORE'}]\nfamiliarity_dic\nExpected result is correct but I want to know if it's the best practice for Pandas.\nQuestion    SCORE\n36  Invesco        100\n35  Schroders   96\n34  Fidelity    96\n31  M&G         95\n0   BlackRock   95","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":57909996,"Users Score":0,"Answer":"I think easier to plot from pandas than a dict.  Try using df.plot().  You can subset your df as required to only plot the information you're interested it.","Q_Score":0,"Tags":"python,pandas,dataframe,dictionary","A_Id":57910171,"CreationDate":"2019-09-12T15:26:00.000","Title":"Best practice convert dataframe to dictionary?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using php to run a python script and fetching its output using json.dump and showing on my php page. I feel its slower than when I run it through python idle.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":57916771,"Users Score":0,"Answer":"If I understand your question correctly it's no surprise that it feels slower because calling your Python script from PHP, instead of calling it from CLI, increases the operations your PC has to execute. Consider this: first PHP has to create a shell to call your script, then wait for it to finish (e.g. wait for an exit code appearing in the buffer), grab everything from the buffer and then push it into the output buffer and then flush the output buffer, so the data is actually displayed on your page. And besides all of that your output data is transported twice, first from Python to PHP and then from PHP to your browser.\nFurthermore, the processing speed depends on the method you use to call your Python script - there are a couple of ways to achieve this and some have more overhead than others.","Q_Score":0,"Tags":"php,python","A_Id":57922170,"CreationDate":"2019-09-13T02:58:00.000","Title":"Is it a bad idea to run a python script and fetch its output via 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem where user chooses a month and on the basis of that i have to choose starting and ending date of that month.(e.g -> If user chooses January the output should come 01\/01\/2019 and 31\/01\/2019)\nI am able to fetch the current months starting and ending date by using postgresql query.\nThis gives current months starting date - \n @api.model\n    def get_start_date(self):\n        self.env.cr.execute(\"\"\" select date(date_trunc('month', \n                                               current_date));\"\"\")\n        first_date = self.env.cr.dictfetchall()\n        for f in first_date:\n            first_new_date = f['date']\n            return first_new_date\nThis gives ending date -\n@api.model\n    def get_end_date(self):\n        self.env.cr.execute(\"\"\" select date(date_trunc('month', \n                   current_date) + interval '1 month - 1 day'); \"\"\")\n        end_date = self.env.cr.dictfetchall()\n        for f in end_date:\n            end_last_date = f['date']\n            return end_last_date\nI want if user select January for selection field it should give January's starting and ending date.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":57917255,"Users Score":0,"Answer":"if you want to store that data in db use store=True: \noutput_field = fields.Char(compute='_get_data', store=True) (or fields.Data)\nand then use onchange method:\n@api.onchange('selection_field_name')\ndef _get_data(self):\n    if self.selection_field_name:\n        self.output_field = **do some calculations**","Q_Score":0,"Tags":"python-3.x,postgresql,odoo-11","A_Id":57925859,"CreationDate":"2019-09-13T04:22:00.000","Title":"I need to fetch months starting date and ending date on the basis of the month chosen by the user in odoo","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am currently developing a SPA application (angular) with a Python\/Flask API in the back-end.\nThe application will support multiple tenants and I struggle a bit with the security concept. I am currently using jwt-extended\nAn issued JWT token would be valid for all tenants (I can of course get the user form the token and then check if the user should have access or not to that tenant), but I would perfere to have JWT token that are tenant specific (so that the user get blocked by the @jwt_required).\nMy idea would be to have different JWT_SECRET_KEY per tenant (so like append the tenant to my key) and then check the validity of the token per tenant (tenant would be identified by the url, either as subdomain or as parameter)\nBy default,  the key is the on the app level (with app.config('JWT_SECRET_KEY') but it looks like you can overwrite the key encode\/decode functions in flask_jwt_extended.JWTManager. I am however not sure which functions I have to override for my @jwt_required to work a I would like (so to use a custoim key in the decoding that would be generated as a concatenate of my key + tenant)\nIf my concept does not make sense \/ if there is a better and\/or simpler way to achieve this, please let me know.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":569,"Q_Id":57918365,"Users Score":0,"Answer":"He u just put the tenants I'd in user table for specifying the user per tenants then you needs to puts all the details in jwt after that in angular side you can get the user details and also tenants details from jwt token for accessing specific tenants per user to secure the endpoint.","Q_Score":2,"Tags":"python,flask,jwt,multi-tenant,flask-jwt-extended","A_Id":57924904,"CreationDate":"2019-09-13T06:30:00.000","Title":"Is there a way to have tenant specific JWT token","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In VS Code, I would like to ignore \"unused import *** from wildcard import\". How to add this warning [W0614] to the existing warnings in VS Code settings","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1431,"Q_Id":57919490,"Users Score":0,"Answer":"Maybe you should try using PyCharm. But if you dont want to i think in the instllation folder of VS Code there is a .cfg file you should try find all .cfg file and then check the content of the files. And in one of there is something about ignoreing errors. I dont remember because nowadays I use PyCharm instead of using VS code for Python.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":57920245,"CreationDate":"2019-09-13T07:56:00.000","Title":"How to ignore unused imports from wildcard imports in VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a numpy array of shape (20000, 600, 768). I need to store it, so later I could load it back to my code.\nThe main problem is memory usage when you load it back.\nI have just 16GB RAM.\nFor example, I tried pickle. When it loads it all I almost have no memory left to do anything else. Especially to train the model.\nI tried write and load back with hdf5 (h5py). Just a small piece (1000, 600, 768). But it seems like it \"eats\" even more memory.\nAlso tried csv.. That's just a no-no. Takes TOO much time to write data in.\nWould be grateful for any suggestions how I could store my array so when I would load it back it wouldn't take that much memory.\nP.S. The data I store is vector representation of texts which I later use for training my model.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":947,"Q_Id":57921092,"Users Score":0,"Answer":"I think that you can do a lot of things. \nFirst of all you can change the data format to be stored in different ways:\n\nin a file in your secondary memory to be read iteratively (dumping a python object on secondary memory is not efficient. You need to find a better format. For example a text file in which the lines are the rows of the matrix)\nor in a database. Always to make the data readable in an iterative manner.\n\nSecond, and most important, you need to change your algorithm. If you cannot fit all the data in memory, you need to use other kinds of methods, in which you use batchs of data instead of all the data.\nFor machine learning for example, there are a lot of methods in which you do incremental updates of the model with batchs of data\nThird, there are method in which you can reduce the dimensionality of your training set. For example using methods like PCA, feature selection etc","Q_Score":2,"Tags":"python,numpy,ram","A_Id":57921590,"CreationDate":"2019-09-13T09:40:00.000","Title":"Storing\/Loading huge numpy array with less memory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hopefully a simple question,\nWhen installing Python 3.7 on a Mac, can you remove the folder from Applications containing the IDLE and the Launcher without breaking the install? I don't have an IDLE for the 2.7 that is built-into the Mac and don't want one for 3.7 either.\nPS: I already removed it, but I would like to know if indeed something breaks as a result of this; if not, then I shall leave it as is.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":198,"Q_Id":57923118,"Users Score":0,"Answer":"Deleting the Python folder in \/Applications will cause no problems. The contents are the IDLE.app for writing python, the Python Launcher app, which provides a configurable way to run python scripts by double-clicking them in the Finder, some documentation, and a couple of shell scripts to configure the installation.\n'Actual python' that you call in the Terminal with all its libraries and dependencies is stored in \/Library.\nThe entire folder is less than 1 Mb, (excluding the Extras folder that comes with some versions, which adds a hefty 2 Mb) so you're not saving much by deleting it.","Q_Score":0,"Tags":"python,python-3.x,macos,installation","A_Id":58026404,"CreationDate":"2019-09-13T11:50:00.000","Title":"Can you remove the Python folder from Applications after install?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How to find out the version of teradataml package?\nIt doesn't expose .version attribute.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":57928403,"Users Score":0,"Answer":"In terminal type pip freeze or pip3 freeze. It will show all the packages with their versions.","Q_Score":1,"Tags":"python,teradata","A_Id":57928416,"CreationDate":"2019-09-13T18:02:00.000","Title":"How to find the version of teradataml package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a little app in python, consuming some http services, but i really don't understand the difference between using an async function or an Thread for consuming that services.\nAnyone can help me to understand?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":456,"Q_Id":57930096,"Users Score":0,"Answer":"In a function there is an entry point and there is an exit point (which is usually a return statement or last statement of function).\nThread: executes all the possible statements from entry point to exit point.\nasync function :\n\nFunctions defined with async def syntax are always coroutine functions\n\nThis is from python reference documentation. And coroutines can be entered,exited or resumed from different points anywhere between entry and exit point of the function.\nNow, based on your requirement, you can choose which one to use.","Q_Score":1,"Tags":"python,multithreading,rest,http,asynchronous","A_Id":57930788,"CreationDate":"2019-09-13T20:40:00.000","Title":"async function or Thread in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking to train a large model (resnet or vgg) for face identification.\nIs it valid strategy to train on few faces (1..3) to validate a model?\nIn other words - if a model learns one face well - is it evidence that the model is good for the task?\npoint here is that I don't want to spend a week of GPU expensive time only to find out that my model is no good or data has errors or my TF coding has a bug","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":221,"Q_Id":57937097,"Users Score":2,"Answer":"Short answer: No, because Deep Learning works well on huge amount of data.\nLong answer: No. The problem is that learning only one face could overfit your model on that specific face, without learning features not present in your examples. Because for example, the model has learn to detect your face thanks to a specific, very simple, pattern in that face (that's called overfitting). \nMaking a stupid simple example, your model has learn to detect that face because there is a mole on your right cheek, and it has learn to identify it\nTo make your model perform well on the general case, you need an huge amount of data, making your model capable to learn different kind of patterns\nSuggestion:\nBecause the training of a deep neural network is a time consuming task, usually one does not train one single neural network at time, but many neural network are trained in parallel, with different hyperparameters (layers, nodes, activation functions, learning rate, etc).\nEdit because of the discussion below:\nIf your dataset is small is quite impossible to have a good performance on the general case, because the neural network will learn the easiest pattern, which is usually not the general\/better one. \nAdding data you force the neural network to extract good patterns, that work on the general case. \nIt's a tradeoff, but usually a training on a small dataset would not lead to a good classifier on the general case\nedit2: refrasing everything to make it more clear. A good performance on a small dataset don't tell you if your model when trained on all the dataset is a good model. That's why you train to \nthe majority of your dataset and test\/validate on a smaller dataset","Q_Score":2,"Tags":"python,tensorflow,keras,resnet,vgg-net","A_Id":57937143,"CreationDate":"2019-09-14T15:55:00.000","Title":"Is it possible to validate a deep learning model by training small data subset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a tree class in python3, each tree object has a reference to its parent and a list of references to its children.\nIn the main method there is a reference to the root of the tree. I tried to dereference the children of the root by saying root.children = [], but the RAM usage does not seem to go down. How can I clear the whole tree or a partial portion from memory? For those wondering this is important because the tree is very big and the RAM usage becomes too high.\np.s.: I believe that what is making the memory not being cleared is that after I remove the children from the root, depth 2 nodes have a reference to depth 3 nodes and vice-versa, and so on.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":57937302,"Users Score":0,"Answer":"You can try first using del on the children node and forcing the Garbage Collector to release unreferenced memory with gc.collect().","Q_Score":0,"Tags":"python,python-3.x,memory,tree","A_Id":57937346,"CreationDate":"2019-09-14T16:21:00.000","Title":"Deleting from memory in tree structure objects in python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wonder if I can declare that a package will not work if a specific version of a modules is present but without making that module itself a dependency.\nFor example, as package publisher, I discover that presence of foo==1.2.3 in python is breaking something key, even if I personally do not use it myself. \nIs there a way to declare that incompatibility so my package will fail to install if this module is detected?\nI known that I could dynamically test this at runtime by attempting to import it but I am more interested if this can be declared in package metadata, like an anti-dependency (or a negative dependency)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":375,"Q_Id":57938558,"Users Score":1,"Answer":"Apparently there is no declarative way to do this and doing it in setup.py is not recommended because that is not guaranteed to run on install.\nAlso, even if possible, it will not prevent user from installing the incompatible package later.\nThis means that the only reliable way to do it is to add a runtime check. For cli tools it should be easy, for libraries or it can be tricky as it could impose a small performance impact on import.","Q_Score":1,"Tags":"python,setuptools,python-packaging","A_Id":57941959,"CreationDate":"2019-09-14T19:20:00.000","Title":"Can I declare incompatible python dependencies?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"According to performance it is more than obvious that web scraping with BautifulSoup is much faster than using a webdriver with Selenium. However I don't know any other way to get content from a dynamic web page. I thought the difference comes from the time needed for the browser to load elements but it is definitely more than that. Once the browser loads the page(5 seconds) all I had to do is to extract some <tr> tags from a table. It took about 3-4 minutes to extract 1016 records which is extremely slow in my opinion. I came to a conclusion that webdriver methods for finding elements such as find_elements_by_name are slow. Is find_elements_by.. from webdriver much slower than the find method in BeautifulSoup? And would it be faster if I get the whole html from the webdriver browser and then parse it with lxml and use the BeautifulSoup?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1214,"Q_Id":57938852,"Users Score":1,"Answer":"Look into 2 options:\n1) sometimes these dynamic pages do actually have the data within <script> tags in a valid json format. You can use requests to get the html, beautifulsoup will get the <script> tag, then you can use json,loads() to parse.\n2) go directly to the source. Look at the dev tools and search the XHR to see if you can go directly to the url\/API and that generates the data and return the data that way (most likely again in json format). In my opinion, this is by far the better\/faster option if available.\nIf you can provide the url, I can check to see if either of these options apply to your situation.","Q_Score":0,"Tags":"python,performance,selenium,web-scraping,beautifulsoup","A_Id":57942694,"CreationDate":"2019-09-14T20:02:00.000","Title":"Web Scraping with Python Selenium performance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to use pyaudio to record some speech but I can't seem to figure out how to record anything on a Mac running Mojave. I think that you have to allow access to the microphone on a mac but I'm not sure how.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2425,"Q_Id":57940639,"Users Score":0,"Answer":"For those who use PyCharm as their IDE, you follow these steps:\n\nRun your microphone-using python script in Terminal (as @Yongke suggested)\nOnce prompted, allow Terminal to access Microphone\nClose running PyCharm instances\nOpen PyCharm from terminal\n\ncd \/Applications\/PyCharm\\ CE.app\/Contents\/MacOS\/\n.\/pycharm\n\nNow your recording app should work\n\nFurther explaination\nEvery App running on recent macOS versions needs explicit permissions to use the microphone. PyCharm doesn't request these permissions upon usage, i.e. when you run your script trying to record, and you cannot manually add a program to Mac's Microphone white-listed apps. This means you cannot access the microphone via PyCharm unless you run it within a white-listed app such as Terminal.","Q_Score":4,"Tags":"python,macos,microphone,pyaudio","A_Id":66210338,"CreationDate":"2019-09-15T02:15:00.000","Title":"Cannot Access Microphone on Mac Mojave using pyaudio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to start cmd window and then running a chain of cmds in succession one after the other in that cmd window.\nsomething like start cmd \/k pipenv shell && py manage.py runserver the start cmd should open a new cmd window, which actually happens, then the pipenv shell should start a virtual environment within that cmd instance, also happens, and the py manage.py runserver should run in the created environment but instead it runs where the script is called. \nAny ideas on how I can make this work?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":826,"Q_Id":57941842,"Users Score":1,"Answer":"Your py manage.py runserver command calling python executor in your major environment. In your case, you could use pipenv run manage.py runserver that detect your virtual env inside your pipfile and activate it to run your command. An alternative way is to use virtualenv that create virtual env directly inside your project directory and calling envname\\Scripts\\activate each time you want to run something inside your virtual env.","Q_Score":2,"Tags":"python,batch-file,cmd","A_Id":57942022,"CreationDate":"2019-09-15T06:56:00.000","Title":"Start cmd and run multiple commands in the created cmd instance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Have some code, it works with raw code but once i turned it into a executable with pyinstaller i get the requests.packages.urllib3.exceptions.SSLError: [Error 2] no such file or directory\nit always works with raw code but not with pyinstaller\ntried using requests from both python 2 and python3, tried on multiple PCs.\ni expect it to execute the code when using a .exe with pyinstaller","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":981,"Q_Id":57942006,"Users Score":0,"Answer":"Post some code, without it I am going blindly. But i can guest that  you have somewhere in your code relative(like .\/file), while everything is in your original directory(raw code) it works, but after compiling,programm can't find it","Q_Score":1,"Tags":"python,python-requests,pyinstaller,instagram-api","A_Id":57942058,"CreationDate":"2019-09-15T07:22:00.000","Title":"requests.packages.urllib3.exceptions.SSLError: [Error 2] no such file or directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Have some code, it works with raw code but once i turned it into a executable with pyinstaller i get the requests.packages.urllib3.exceptions.SSLError: [Error 2] no such file or directory\nit always works with raw code but not with pyinstaller\ntried using requests from both python 2 and python3, tried on multiple PCs.\ni expect it to execute the code when using a .exe with pyinstaller","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":981,"Q_Id":57942006,"Users Score":0,"Answer":"I found the solution\nUsing auto-py-to-exe and pyinstaller to convert to exe.\nClick in \"on file\" button use \"one directory\" option.\nThen you have to go to your python's directory and find the directory \"requests\".\nCopy this directory (\"requests\") to your app directory created with auto-py-to-exe.\nIt's done.","Q_Score":1,"Tags":"python,python-requests,pyinstaller,instagram-api","A_Id":71662789,"CreationDate":"2019-09-15T07:22:00.000","Title":"requests.packages.urllib3.exceptions.SSLError: [Error 2] no such file or directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to build REST API (or GraphQL API) which I want to connect with Angular (2+) to build some nice web application.\nWhich framework should I choose to get started with and why? DjangoREST or ExpressJS ?\nWhich one of them is easier to get connected with front-end frameworks?\nI know python as well as JavaScript. I also have experience with django as well as some JavaScript front-end frameworks like Angular. So, it wouldn't be that difficult to get started with nodejs or either of them.\nWhich of then is easier and better?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":11553,"Q_Id":57945868,"Users Score":20,"Answer":"In short, Django for quick development and Express for full-stack,\n  scalable solutions.\n\n\nDjango provides better, easier security without as much experience. In the case of Express, it takes so much experience and confidence to get the same security from Node.JS\nDjango uses the MVT (Model View Template) design pattern and Express uses event-driven programming in which the entire architecture is driven by \u201cevents\u201d or user choices. MVT is excellent for server-side development, on the other hand, event-driven programming is rather than separating client and server sides.\nDjango uses an in-house template system, so you won't hang to choosing the right one. With Express, a fully open system you may spend a lot amount of time to choose the perfect one for you.\nDjango is more structured to work around. It tells you how to do whereas express gives you the flexibility to do it in your way. For example, you need to use Django's ORM to interact with the database, but in the case of Express, you can choose any tool you like.\nExpress gives you freedom. So, if you\u2019re experienced, there is a space to create whatever you want from scratch. Django gives you a lot of solutions with a vast template and library system, which is great for productivity but not enough for the vision.","Q_Score":7,"Tags":"python,node.js,django,express,django-rest-framework","A_Id":57946706,"CreationDate":"2019-09-15T16:06:00.000","Title":"DjangoREST vs ExpressJS , which 1 should I choose to build REST API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have tried activating my conda for a while now, when I do conda env list I get an env like this \"C:\\Users\\Allaye\\Anaconda3\" and I issue this command 'conda activate C:\\Users\\Allaye\\Anaconda3',  but when I restart my machine again I still gets the same activate environment error. any help. but write now even the conda command isn't working again..\nI don't know what to do now, because it seems when I activate the environment it only on a tempora basics","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":138,"Q_Id":57946424,"Users Score":0,"Answer":"Activating a conda environment applies to the current shell or terminal window only. That way, you can open several terminals and activate different conda environments in each. It's not a persistent setting, you have to repeat it every time you open a terminal to work in a specific conda environment.\nYou could define aliases or helper scripts for each environment, so you have to do less typing.","Q_Score":0,"Tags":"python,anaconda","A_Id":57946915,"CreationDate":"2019-09-15T17:13:00.000","Title":"error when activating anaconda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"On my old computer, I was able to run .py files from Jupyter Notebook, edit them, and run them. The .py file was effectively a notebook file for all intents and purposes. I updated to the latest version of notebook, and I am no longer able to do this. How do I use .py files on my notebook?\nI know there are roundabout ways to do this. I am looking for the method where, when you are in notebook, instead of opening a .ipynb file, you select a .py file which is opened, and behaves like a .ipnyb. When you save it, it writes to .py.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7565,"Q_Id":57947260,"Users Score":0,"Answer":"Some editors (like spyder and vscode) have jupyter notebook functionality. These can be used if jupyter in installed in the python environment.\nYou can use it by add #%% on top of the block of code. (in vscode the button 'run cell' will automatically appear)\nAlso it is possible to import .ipynb as .py which can be run in to fancy decrypt above.","Q_Score":6,"Tags":"python,jupyter-notebook","A_Id":58393029,"CreationDate":"2019-09-15T18:50:00.000","Title":"Run from and save to .py file from Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"On my old computer, I was able to run .py files from Jupyter Notebook, edit them, and run them. The .py file was effectively a notebook file for all intents and purposes. I updated to the latest version of notebook, and I am no longer able to do this. How do I use .py files on my notebook?\nI know there are roundabout ways to do this. I am looking for the method where, when you are in notebook, instead of opening a .ipynb file, you select a .py file which is opened, and behaves like a .ipnyb. When you save it, it writes to .py.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7565,"Q_Id":57947260,"Users Score":0,"Answer":"You can save individual cells as files using the following code: %%writefile some_file_name.py.\nYou can run that code straight from the terming or from another notebook using the following code: %run some_file_name.py","Q_Score":6,"Tags":"python,jupyter-notebook","A_Id":57947490,"CreationDate":"2019-09-15T18:50:00.000","Title":"Run from and save to .py file from Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to install Anaconda 3 Python 3.7 64-bit on my Windows\u00a010 computer. Install finishes correctly, but the destination folder doesn't have conda.exe or the Scripts folder.\nIt has _conda.exe and uninstall exe's and conda-meta, Lib and pkgs folders.\nI also tried:\n\n32-bit version. Same result.\nminiconda installation. The same...\n\nHow can I fix it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":411,"Q_Id":57947993,"Users Score":0,"Answer":"In my experience, if something does weird things like this, you have a broken Windows search for \"media creation tools\" or you don't have enough space on disk C.","Q_Score":1,"Tags":"python,installation,windows-10,anaconda,conda","A_Id":57948507,"CreationDate":"2019-09-15T20:33:00.000","Title":"Anaconda 3 installation was not successful","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a structured numpy ndarray la = {'val1':0,'val2':1} and I would like to return the vals using the 0 and 1 as keys, so I wish to return val1 when I have 0 and val2 when I have 1 which should have been straightforward however my attempts have failed, as I am not familiar with this structure.\nHow do I return only the corresponding val, or an array of all  vals so that I can read in order?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2969,"Q_Id":57948331,"Users Score":0,"Answer":"Just found out that I can use la.tolist() and it returns a dictionary, somehow? when I wanted a list, alas from there on I was able to solve my problem.","Q_Score":0,"Tags":"python,numpy,dictionary,key-value,numpy-ndarray","A_Id":57948589,"CreationDate":"2019-09-15T21:33:00.000","Title":"structured numpy ndarray, how to get values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run this line of code from the beginning of a python script in pycharm:\n!pip install pyknow\nbut it throws an invalid syntax error. In jupyter notebooks this magic command would work, but it seems is not the same here. What's the correct of doing this please?\nEDIT\nthe script where i'm trying to run this command from is a .py file\nThank you very much in advance","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":4187,"Q_Id":57952686,"Users Score":1,"Answer":"pip is not a python script... it's a bash script.\nyou can't just run it from a python script...\nif you are trying to have a script that will take care of the dependencies I would suggest creating a bash script that would install what it needs then execute the .py script.","Q_Score":1,"Tags":"python,python-3.x,pip,pycharm","A_Id":57952773,"CreationDate":"2019-09-16T08:05:00.000","Title":"How can i run \"pip install\" from a pycharm python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run this line of code from the beginning of a python script in pycharm:\n!pip install pyknow\nbut it throws an invalid syntax error. In jupyter notebooks this magic command would work, but it seems is not the same here. What's the correct of doing this please?\nEDIT\nthe script where i'm trying to run this command from is a .py file\nThank you very much in advance","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":4187,"Q_Id":57952686,"Users Score":2,"Answer":"You should edit the command to\n\npip install pypi\n\nBecause the (pypi) is the name of package (pyknow)","Q_Score":1,"Tags":"python,python-3.x,pip,pycharm","A_Id":66940413,"CreationDate":"2019-09-16T08:05:00.000","Title":"How can i run \"pip install\" from a pycharm python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing an application for Android with Kivy, and package it with Buildozer. The core of my application is using pandas and specially the DataFrame function. It failed when I tried to package it with Buildozer even if I had put pandas in the requirements. So I want to use another library that can be used with Buildozer. So does anyone know about a great alternative to the pandas.DataFrame function with the numpy library for example or another one ?\nThanks a lot for your help. :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2855,"Q_Id":57956382,"Users Score":1,"Answer":"Similar to Pandas.DataFrame.\nAs database you likely know SQLite (in python see SQLAlchemy and SQLite3).\nOn the raw tables (i.e., pure matrix-like) Numpy (Numpy.ndarray), it lacks of some database functionalities compared to Pandas but it is fast and you could easily implement what you need. You can find many comparisons between Pandas and Numpy.\nFinally,depending on your needs, some simple python dictionaries, maybe OrderedDict.","Q_Score":1,"Tags":"python-3.x,pandas,numpy,kivy,buildozer","A_Id":57962750,"CreationDate":"2019-09-16T11:58:00.000","Title":"Is there any alternative for pandas.DataFrame function for Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I get the max CPU \/ RAM usage in Linux, when starting a process inside my python code ?\nI want to calculate from the start of the process till the process end","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":719,"Q_Id":57957082,"Users Score":0,"Answer":"To get the memory, a very simple way would be to get the output of:\n\/proc\/YOUR_PROGRAM_PID\/status\n... capture this at the start, and end, of the python process, and extract the memory fields you care about (e.g.  VmPeak, VmSize)","Q_Score":0,"Tags":"python,linux,cpu-usage","A_Id":57957127,"CreationDate":"2019-09-16T12:39:00.000","Title":"Getting the max CPU \/ RAM usage for a process in Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I get the max CPU \/ RAM usage in Linux, when starting a process inside my python code ?\nI want to calculate from the start of the process till the process end","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":719,"Q_Id":57957082,"Users Score":1,"Answer":"\"Maximum CPU usage\" is essentially meaningless. At any instant in time, a process is either running on one (or more) CPUs, or is not running. As such, the maximum CPU usage of any process will always be at least 100%, because there was at least one instant at which the process is running. Tools which display CPU usage as a percentage are measuring the ratio of CPU time consumed by a process to its age.\nThe only situation where this might be a useful measure would be for multithreaded processes, where the \"maximum CPU usage\" is the maximum number of threads belonging to the process which are all running simultaneously. I'm not aware of any specific way to measure this.","Q_Score":0,"Tags":"python,linux,cpu-usage","A_Id":57964470,"CreationDate":"2019-09-16T12:39:00.000","Title":"Getting the max CPU \/ RAM usage for a process in Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I start on python, I try to use mathplotlib on my code but I have an error \"ModuleNotFoundError: No module named 'matplotlib'\" on my cmd. So I have tried to use pip on the cmd: pip install mathplotlib.\nBut I have an other error \"No python at 'C:...\\Microsoft Visual Studio...\"\nActually I don't use microsoft studio anymore so I usinstall it but I think I have to change the path for the pip modul but I don't know how... I add the link of the script  of the python folder on the variables environment but it doesn't change anything. How can I use pip ?\nAntoine","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":618,"Q_Id":57959921,"Users Score":0,"Answer":"Your setup seems messed up. A couple of ideas:\n\nlong term solution: Uninstall everything related to Python, make sure your PATH environment variables are clean, and reinstall Python from scratch.\nshort term solution: Since py seems to work, you could go along with it: py, py -3 -m pip install <something>, and so on.\nIf you feel comfortable enough you could try to salvage what works by looking at the output of py -0p, this should tell you where are the Python installations that are potentially functional, and you could get rid of the rest.","Q_Score":0,"Tags":"python-3.x,pip","A_Id":57982611,"CreationDate":"2019-09-16T15:19:00.000","Title":"impossible to use pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a chatbot using RASA to work with free text and it is working fine. As per my new requirement i need to build button based chatbot which should follow flowchart kind of structure. I don't know how to do that what i thought is to convert the flowchart into graph data structure using networkx but i am not sure whether it has that capability. I did search but most of the examples are using dialogue or chat fuel. Can i do it using networkx.\nPlease help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":614,"Q_Id":57961205,"Users Score":1,"Answer":"Sure, you can.\nYou just need each button to point to another intent. The payload of each button should point have the \/intent_value as its payload and this will cause the NLU to skip evaluation and simply predict the intent. Then you can just bind a trigger to the intent or use the utter_ method.\nHope that helps.","Q_Score":0,"Tags":"python,networkx,flowchart,rasa","A_Id":58013231,"CreationDate":"2019-09-16T16:45:00.000","Title":"How to create button based chatbot","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a regex to match 5 digit numbers or those 5 digit numbers preceded by IND\/\n10223 match to return 10223\nIND\/10110 match to return 10110\nID is 11233 match to return 11233\nRef is:10223 match to return 10223\nRef is: th10223 not match\nSBI12234 not match\nMRF\/10234 not match\nRBI\/10229 not match\nI have used the foll. Regex which selects the 5 digit correctly using word boundary concept. But not sure how to allow IND and not allow anything else like MRF, etc:\n\/b\/d{5}\/b\nIf I put (IND)? At beginning of regex then it won't help. Any hints?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":108,"Q_Id":57962645,"Users Score":1,"Answer":"This should work: (?<=IND\/|\\s|^)(\\d{5})(?=\\s|$) .","Q_Score":1,"Tags":"python,regex","A_Id":57962761,"CreationDate":"2019-09-16T18:38:00.000","Title":"Regex for string that has 5 numbers or IND\/5numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a regex to match 5 digit numbers or those 5 digit numbers preceded by IND\/\n10223 match to return 10223\nIND\/10110 match to return 10110\nID is 11233 match to return 11233\nRef is:10223 match to return 10223\nRef is: th10223 not match\nSBI12234 not match\nMRF\/10234 not match\nRBI\/10229 not match\nI have used the foll. Regex which selects the 5 digit correctly using word boundary concept. But not sure how to allow IND and not allow anything else like MRF, etc:\n\/b\/d{5}\/b\nIf I put (IND)? At beginning of regex then it won't help. Any hints?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":108,"Q_Id":57962645,"Users Score":0,"Answer":"I feel like this will need some logic to it. The regex can find the 5 digits, but maybe a second regex pattern to find IND, then join them together if need be.  Not sure if you are using Python, .Net, or Java, but should be doable","Q_Score":1,"Tags":"python,regex","A_Id":57962758,"CreationDate":"2019-09-16T18:38:00.000","Title":"Regex for string that has 5 numbers or IND\/5numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a regex to match 5 digit numbers or those 5 digit numbers preceded by IND\/\n10223 match to return 10223\nIND\/10110 match to return 10110\nID is 11233 match to return 11233\nRef is:10223 match to return 10223\nRef is: th10223 not match\nSBI12234 not match\nMRF\/10234 not match\nRBI\/10229 not match\nI have used the foll. Regex which selects the 5 digit correctly using word boundary concept. But not sure how to allow IND and not allow anything else like MRF, etc:\n\/b\/d{5}\/b\nIf I put (IND)? At beginning of regex then it won't help. Any hints?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":108,"Q_Id":57962645,"Users Score":1,"Answer":"Try this: (?:IND\\\/|ID is |^)\\b(\\d{5})\\b\nExplanation: \n(?: ALLOWED TEXT): A non-capture group with all allowed segments inside. In your example, IND\\\/ for \"IND\/\", ID is for \"ID is ...\", and ^ for the beginning of the string (in case of only the number \/ no text at start: 12345).\n\\b(\\d{5})\\b: Your existing pattern w\/ capture group for 5-digit number","Q_Score":1,"Tags":"python,regex","A_Id":57962808,"CreationDate":"2019-09-16T18:38:00.000","Title":"Regex for string that has 5 numbers or IND\/5numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In teradataml how should the user remove temporary tables created by Teradata MLE functions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":57963362,"Users Score":0,"Answer":"At the end of a session call remove_context() to trigger the dropping of tables.","Q_Score":0,"Tags":"python,teradata","A_Id":57963363,"CreationDate":"2019-09-16T19:35:00.000","Title":"Teradataml: Remove all temporary tables created by Teradata MLE functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As a training project i have made  activity tracker using  python (no GUI, only command-line). \nScript checks with win32gui\/pywin32 and pyautogui what program is currently used, and if it is web browser what web site is in use. \nName of window, date, and amount of time spent on program\/website is stored in sqlite3 database. \nThen with help of pandas module same names are grouped and time is summed up. \nI want to convert this script into web app using django but i am beginner in creating web apps, so i am wondering: is it possible to use this modules within django and is it even possible to create web app that works same as script mentioned earlier?\nSorry if the question is trivial. I will be grateful for every tip where and what exactly to look for in this topic.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":129,"Q_Id":57964611,"Users Score":1,"Answer":"Nope.\nYou can't make a server to connect through a web client\/browser and see the other processes. That's a security issue, a big one.\nBtw, some GNU\/Linux desktop environments won't even allow the same user's processes in the same logged-in session on the same computer to see each other (Wayland).","Q_Score":0,"Tags":"python,django,pandas,pywin32,pyautogui","A_Id":57965022,"CreationDate":"2019-09-16T21:25:00.000","Title":"Is it possible to get access to PC system via web app using modules like pyautogui and win32gui\/pywin32?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I want to be able to input a username into my Python program and then it checks how many followers that account has (if it's not private) and displays the number. I'm sure it has something to do with APIs.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":379,"Q_Id":57964704,"Users Score":1,"Answer":"first idea that came to my mind is to scrape it with beautifulsoup.","Q_Score":0,"Tags":"python,api,instagram","A_Id":57964909,"CreationDate":"2019-09-16T21:35:00.000","Title":"How can I check how many followers someone has on Instagram 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":"Say I have a function that accepts a row and a column as parameters, or returns a tuple of a row and a column as its return value. I know it doesn't actually make a difference, but is there a convention as to whether put the row first or the column first? Coming from math, if I think of the pair as coordinates into the table, I would intuitively put the column first, as in a cartesian point (x,y). But if I think of it as a whole matrix, I would put row first, as in MxN size of a matrix.\nIf there are different conventions for different languages, I would be interested especially in c++, c# and python.\nBy \"convention\" I mean preferably that that language's standard library does it a certain way, and if not that then second choice would be only if it were so universal that all major third-party libraries for that language would do it that way,preferably with an explanation why.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":57964943,"Users Score":0,"Answer":"The convention is to address (column, row) like (x, y).\nColumn refers to the type of value and row indicates the value for the column.\nColumn is a key and with Row you have the value.\nBut using (row, column) is fine too.\nIt depends of what you're doing.\nIn SQL\/Linq, you always refers to Columns to get rows.","Q_Score":1,"Tags":"c#,python,c++,conventions","A_Id":57965103,"CreationDate":"2019-09-16T22:04:00.000","Title":"Should a function accept\/return values in (row,col) or (col,row) order?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say I have a function that accepts a row and a column as parameters, or returns a tuple of a row and a column as its return value. I know it doesn't actually make a difference, but is there a convention as to whether put the row first or the column first? Coming from math, if I think of the pair as coordinates into the table, I would intuitively put the column first, as in a cartesian point (x,y). But if I think of it as a whole matrix, I would put row first, as in MxN size of a matrix.\nIf there are different conventions for different languages, I would be interested especially in c++, c# and python.\nBy \"convention\" I mean preferably that that language's standard library does it a certain way, and if not that then second choice would be only if it were so universal that all major third-party libraries for that language would do it that way,preferably with an explanation why.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":75,"Q_Id":57964943,"Users Score":1,"Answer":"You shouldn't think of what is \"horizontal\" and what is \"vertical\". You should think of which convention is widely used not to introduce a lot of surprise to the developers who would use your code. The same is true for naming the parameters: use (x, y, z) for coordinates, (i, j) for indexes in matrix and (row, column) for the cells of the table (in this order).\nI agree with @ParalysisByAnalysis that sometimes it depends, but the rule of thumb is to follow the conventions of the subject.","Q_Score":1,"Tags":"c#,python,c++,conventions","A_Id":57965076,"CreationDate":"2019-09-16T22:04:00.000","Title":"Should a function accept\/return values in (row,col) or (col,row) order?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using after to create a delayed callback. I noticed though that many different objects have an after method, and it isn't clear if there's any difference between calling after on say a tk.Frame or a tk.Button.\nI haven't seen a single guide mention if you can expect identical behavior regardless of what object after is called on. Looking at the implementation, it seems like it just delegates to self.tk.call('after', ms, name) in a common base class of widgets, but that alone doesn't mean that the behavior will be identical for all subclasses.\nIf I have multiple widgets on-hand when I need to call after, is there any reason to choose one over another, or can I expect identical behavior regardless?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":57965486,"Users Score":3,"Answer":"I'm using after to create a delayed callback. I noticed though that many different objects have an after method, and it isn't clear if there's any difference between calling after on say a tk.Frame or a tk.Button.\n\nNo, there is no difference. You can call after using any widget you want and it will behave exactly the same.\n\nLooking at the implementation, it seems like it just delegates to self.tk.call('after', ms, name) in a common base class of widgets, but that alone doesn't mean that the behavior will be identical for all subclasses.\n\nActually, it does. The fact that you call it as a method on a widget is an artifact of the Tkinter implementation. In the underlying tcl\/tk library it's just a function call that isn't tied to any widget.","Q_Score":4,"Tags":"python,python-3.x,tkinter","A_Id":57965503,"CreationDate":"2019-09-16T23:24:00.000","Title":"What widget should after be called on?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There are many answers on running Python modules from another folder but they don't work for me because the module I'm trying to import itself is dependent on other modules in that folder.\n\ndir\/file_to_import.py\ndestination.py\n\nfile_to_import is getting imported successfully but the modules inside it aren't running.\nFor e.g.\nfile_to_import.py is dependent on a module named scraper.py and when I import file_to_import.py and run my code, it gives this error:\nModuleNotFoundError: No module named 'scraper'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":332,"Q_Id":57967540,"Users Score":0,"Answer":"Can you try adding a __init__.py to your dir directory.\nThis tells python that the folder you're dealing with is a module.\nThe file can be blank, but generally contains setup code for the module.","Q_Score":0,"Tags":"python","A_Id":57968033,"CreationDate":"2019-09-17T04:52:00.000","Title":"How to run a Python script in another project folder which itself is dependent on scripts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a module with a controller and I need to inherit it in a newly created module for some customization. I searched about the controller inheritance in Odoo and I found that we can inherit Odoo's base modules' controllers this way:\nfrom odoo.addons.portal.controllers.portal import CustomerPortal, pager as portal_pager, get_records_pager\nbut how can I do this for a third party module's controller? In my case, the third party module directory is one step back from my own module's directory. If I should import the class of a third party module controller, how should I do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":455,"Q_Id":57968188,"Users Score":3,"Answer":"It is not a problem whether you are using a custom module.If the module installed in the database you can import as from odoo.addons. \nEg : from odoo.addons.your_module.controllers.main import MyClass","Q_Score":1,"Tags":"python,odoo,web-controls,odoo-12","A_Id":57971645,"CreationDate":"2019-09-17T06:03:00.000","Title":"How to inherit controller of a third party module for customization Odoo 12?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"After installing pytesseract package using \"pip install\" on google colab, i needed to install OCR trained data for other country language, however, i do not know where to copy it..\nif I install package by myself using \"pip install\", where is the location of package on my window PC?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1246,"Q_Id":57968216,"Users Score":0,"Answer":"Installing a package on google colab will not install on your local drive which you are using, initiating a colab environment will create a remote drive where you can check out all the project files. \nIf you want to know for a specific pip package installation path you can always use \n!pip show pytesseract-ocr\nit will show you Location: of where the package is installed and then you can always add necessary files onto the package installed directory","Q_Score":0,"Tags":"python-3.x,python-tesseract","A_Id":57969042,"CreationDate":"2019-09-17T06:05:00.000","Title":"Google colab : How do i install traineddata file for pytesseract?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In gensim's word2vec python, I want to get the list of cosine similarity for \"price\".\nI read the document of gensim word2vec, but document it describes most_similar and n_similarity function)()\nI want the whole list of similarity between price and all others.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":204,"Q_Id":57969707,"Users Score":0,"Answer":"If you call wv.most_similar('price', topn=len(wv)), with a topn argument of the full vocabulary count of your model, you'll get back a ranked list of every word's similarity to 'price'. \nIf you call with topn=0, you'll get the raw similarities with all model words, unsorted (in the order the words appear inside wv.index2entity).","Q_Score":0,"Tags":"python,gensim,word2vec,similarity,cosine-similarity","A_Id":57980615,"CreationDate":"2019-09-17T07:53:00.000","Title":"Python3, word2vec, How can I get the list of similarity rank about \"price\" in my model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"VS Code is unable to detect the torch package that I installed exclusively in one of the Conda environments. If I launch VS Code through Anaconda Launcher, however, then it detects torch and everything works fine.\nI have done many things in order to make the Conda environment work on VS Code PowerShell terminal, and so far Conda is getting activated on VS Code terminal properly regardless of whether I launch it with or without the Anaconda Launcher. But when trying to run the the program via Code Runner, it always shows the error that the torch module is not found. \nBut doing the same thing in terminal or launching VS Code through Anaconda launcher works just fine.\nI don't know what to do, it is so annoying. I really wanted to work with Python on VS Code as it looks neat and clean compared to other editors and also since it is also light and fast. Unfortunately, making Conda work on VS Code is a nightmare, and it seems like the only way to make it work is through launching it via Anaconda Launcher, but opening Anaconda Launcher takes too much time compared to VS Code -_-\nPlease help assist with launching the code through VS Code.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":388,"Q_Id":57970383,"Users Score":1,"Answer":"It's because conda activation sets various environment variables which are required for a conda environment to function appropriately. And I suspect the Code Runner extension simply doesn't understand the concept of a conda environment, and so it isn't doing any activating which makes the import search fail.\nYou can try executing code directly through the Python extension instead of Code Runner to see if that works better for you.","Q_Score":0,"Tags":"python,visual-studio-code,anaconda,conda","A_Id":58000356,"CreationDate":"2019-09-17T08:34:00.000","Title":"VS Code does not detect Conda packages when launched without the Anaconda Launcher?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two columns of having high cardinal categorical values, one column(area_id) has 21878 unique values and other has(page_entry) 800 unique values. I am building a predictive ML model to predict the hits on a webpage.\ncolumn information:\narea_id: all the locations that were visited during the session. (has location code number of different areas of a webpage)\npage_entry: describes the landing page of the session.\nhow to change these two columns into numerical apart from one_hot encoding?\nthank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":150,"Q_Id":57975387,"Users Score":0,"Answer":"One approach could be to group your categorical levels into smaller buckets using business rules. In your case for the feature area_id you could simply group them based on their geographical location, say all area_ids from a single district (or for that matter any other level of aggregation) will be replaced by a single id. Similarly, for page_entry you could group similar pages based on some attributes like nature of the web page like sports, travel, etc.  In this way you could significantly reduce the number dimensions of your variables.\nHope this helps!","Q_Score":0,"Tags":"python,machine-learning,data-science,data-cleaning,data-processing","A_Id":57975781,"CreationDate":"2019-09-17T13:31:00.000","Title":"how to deal with high cardinal categorical feature into numeric for predictive machine learning model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying optimize hiperparameters for classifiers and regression methods in sklearn. And I have a question. Why when you evaluate the results, you choose for example the best train accuracy, instead of evaluate this result over the test, and iterate others values with others train accuracys to obtain the best test accuracy? Because clearly the parameters for the best train accuracy are not the same that the parameters for the best test accuracy.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":266,"Q_Id":57978263,"Users Score":0,"Answer":"when we are training a model we usually divide data into train, validation and test sets. Lets look at what are the propose of each set\nTrain Set: It is used by model to learn its parameters. Usually model reduces its cost on the train set and selects parameters that gives minimum cost.\nValidation Set: By name, validation set is used to validate that model will also performs well on the data that it haven't seen yet. That gives us confidence that model is not memorizing the training data and performing very well on training data but not performing good on new data. If the model is complex enough then there is risk of model memorizing training data to improve its performance on training set but not well on validation data.\nUsually we use cross validation in which we divide training set into n equal parts, then for each iteration we select one part as validation and remaining parts as training set.\nTest Set: Test Set is set aside and only used at last when we are satisfied with our model to estimate how well your final model will perform on new data in wild. One main difference with validation set is that it is not used in any way to improve or change model or improve model but validation set help us select us final model. We do this because we don't want a model that is biased towards test data but will not perform well with data in wild.","Q_Score":0,"Tags":"python,optimization,hyperparameters,gridsearchcv","A_Id":57978592,"CreationDate":"2019-09-17T16:17:00.000","Title":"Why not evaluate over test fit results in RandomizedSearchCV?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a stream of data of the form [id, name, act, value, type].\nid is an integer, name a string, act can be 'add', 'update' or 'delete', value is an integer, type is either L or R. We can only add once an id, perform multiple updates and then delete the id. I obviously look for a data structure that will allow me to insert those data efficiently.\nI also need to be able to get the highest L value by name and the lowest R value by name at each moment the fastest way possible.\nI believe I will need to use heap to get in a constant time min and max values by name. My problem is that I don't manage to find a way to also have the possibility to delete and update existing data at the same time.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":318,"Q_Id":57981483,"Users Score":0,"Answer":"Sorting makes this a different sort of problem. So you are instead looking for a way to add and subtract data entries into a data structure sorted alphabetically on their string names? One common way to do this is with a binary search tree. A BST will give you an insertion time complexity of O(log(n)) with n elements in the tree. At each element you can store the other data. Then you can separately maintain the highest L and lowest R values and update these each time a value is added that exceeds on of these values. If you remove a value equal to one of these limits, you'll have to traverse the whole data structure to get the new limit value.","Q_Score":0,"Tags":"python,containers","A_Id":57981781,"CreationDate":"2019-09-17T20:15:00.000","Title":"Optimal data structure for streaming data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a stream of data of the form [id, name, act, value, type].\nid is an integer, name a string, act can be 'add', 'update' or 'delete', value is an integer, type is either L or R. We can only add once an id, perform multiple updates and then delete the id. I obviously look for a data structure that will allow me to insert those data efficiently.\nI also need to be able to get the highest L value by name and the lowest R value by name at each moment the fastest way possible.\nI believe I will need to use heap to get in a constant time min and max values by name. My problem is that I don't manage to find a way to also have the possibility to delete and update existing data at the same time.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":318,"Q_Id":57981483,"Users Score":0,"Answer":"The phrasing is a bit unclear here. Let me try and rephrase: you are looking for a good data structure such that, given a stream of operations in the form given above, you can add, delete, or update items (found using their id number). And you'd also like to maintain a few summary statistics about the whole data structure such as highest L and lowest R value.\nDoes this sound correct? \nA dictionary of dictionaries sounds like it's probably the right answer if your id numbers are not over a specific range, or a list of dictionaries if they are.","Q_Score":0,"Tags":"python,containers","A_Id":57981600,"CreationDate":"2019-09-17T20:15:00.000","Title":"Optimal data structure for streaming data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I did a beginner project using Pycharm creating a calculator using Python. I then shared the project on Github. But I cannot seem to find my code on Github. Only see the .idea (folder) .gitignore (page) and .README.md (pages) under the code tab, but no page with the code.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":107,"Q_Id":57985186,"Users Score":1,"Answer":"Your repo should pretty closely resemble the directory on your computer, so I\u2019d start there. Does the file path to your code on your computer have some overlap with the repo? If so, then VonD is probably right\u2014you may have inadvertently not pushed it or added it to your ignore file. \nIf, however, the file bears no resemblance at all to your repo, then you\u2019ve probably just saved the file to the wrong place by mistake. If you move it into the correct directory and re-do the add, commit, and push, you should see the file in your repo. \nOne other possibility\u2014-is this a group project? If you put in a pull request and one of your collaborators made changes and re-pushed, they may have removed the file or placed it in a different folder.","Q_Score":2,"Tags":"python,git","A_Id":57985526,"CreationDate":"2019-09-18T04:39:00.000","Title":"I did a beginner project creating a calculator, and pushed to Github. Where do I locate my code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Dears\nI read that CP-SAT for a feasible solution does not ensure that all constraints are met. Am I right? Is there a way to force it to met all of them even if the solution is \"feasible\"?\nDoes it provide the constrains met and not met?\nThank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":237,"Q_Id":57987146,"Users Score":0,"Answer":"Where did you read that? CP-approach means finding rather a good feasible solution than an optimal solutions, which obviously speeds up the computation.\nThe definition of a fesaible solution is: A set of values for the decision variables that satisfies all of the constraints in an optimization problem.\nYou can run an CP-SAT example and check, if a constraint is violated. But there should be not violation.\nEdit: Or are we talking about relaxation?","Q_Score":0,"Tags":"python,or-tools","A_Id":57987447,"CreationDate":"2019-09-18T07:20:00.000","Title":"is it possible to force cp-sat to meet all the constraints for a feasible solution?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"my project use angular + python flask\n(1) \nIs it possible to give each router called a unique id ?\n(2) if a flask router processing is too long, \nis it possible to stop this router without stopping the flask when i click some button on the web??\ni need to stop only this router.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":57988486,"Users Score":0,"Answer":"(2) You can respond with 504 timeout gateway.","Q_Score":0,"Tags":"python,flask","A_Id":57988901,"CreationDate":"2019-09-18T08:38:00.000","Title":"Can I stop a specific flask router?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to have django projects(python3) directory outside of the environment directory? e.g I want to have my projects under \/Users\/me\/Documents\/dev\/myDjangoProject and environment under \/Users\/me\/Documents\/env\/myCustomEnvironment and somehow link them together. Thanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":57991211,"Users Score":0,"Answer":"Ok. I found solution. \n\nFrom my terminal window I moved into my project directory - \/Users\/me\/Documents\/dev\/myDjangoProject \nActivated virtualenv from its absolute path - source \/Users\/me\/Documents\/env\/myCustomEnvironment\/bin\/activate\nAnd then ran server python manage.py runserver","Q_Score":1,"Tags":"django,python-3.x","A_Id":57995066,"CreationDate":"2019-09-18T10:59:00.000","Title":"Python3\/Django. Separate project directory from environment directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"IIUC python hash of functions (e.g. for use as keys in dict) is not stable across runs.\nCan something like dill or other libraries be used to get a hash of a function which is stable across runs and different computers? (id is of course not stable).","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":282,"Q_Id":57993908,"Users Score":1,"Answer":"I'm the dill author.  I've written a package called klepto which is a hierarchical caching\/database abstraction useful for local memory hashing and object sharing across parallel\/distributed resources. It includes several options for building ids of functions.\nSee klepto.keymaps and klepto.crypto for hashing choices -- some work across parallel\/distributed resources, some don't.  One of the choices is serialization with dill or otherwise.\nklepto is similar to joblib, but designed specifically to have object permanence and sharing beyond a single python session.  There may be something similar to klepto in dask.","Q_Score":1,"Tags":"python,hash,dill","A_Id":58002376,"CreationDate":"2019-09-18T13:27:00.000","Title":"Getting a hash of a function that is stable across runs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on upgrading a Django website from Django 1.8 to Django 2.2 and have come across a problem when trying to delete an object from the Django admin changelist view. When I try to delete an object, I am shown a screen with the words \"Deleting the selected Records would result in deleting related objects, but your account doesn't have permission to delete the following types of objects\". The problem is, I am a superuser and should have permission to delete any object I want, or so I thought. \nI have read a decent amount of documentation on Django upgrades and permissions of superusers, however I haven't stumbled across anything that helps me (I could be missing something though). I have tried creating a new superuser just in case, still the same message occurs though. Anyway, Does anyone have any idea why this could be happening?\nNote: I can't show any code because I am working for a company and I signed an NDA. Just some help pointing me in the right direction would be appreciated.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2356,"Q_Id":57996905,"Users Score":11,"Answer":"For anyone else who stumbles across this problem, dirkgroten was right and it turns out the has_delete_permission was overridden! Thanks for your help dirkgroten!","Q_Score":10,"Tags":"python,django,model,permissions,superuser","A_Id":57997632,"CreationDate":"2019-09-18T16:11:00.000","Title":"Django superuser doesn't have permission to delete models","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using Python to create an RSA encoding system but I have to follow some conditions: \n\nBoth of private and public keys have to be encoded in 16 values.\nThe keys has to be encoded in 64 bits.\n\nI wanted to used PyCryptodome, but since it limit you to use a size of 1024 bit, or more and for my case I just want to encode them in 16 values.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":57997340,"Users Score":0,"Answer":"As mentioned in the comments by me: 16 x 64 = 1024, and 1024 is an often used RSA key size.\nI strongly suggest that you are misunderstanding the question. It seems you have to perform 1024 bit modular exponentiation using machine words of 64 bit internally for the calculations. How the keys are encoded is an entirely other matter; during the calculations you'd use the modulus and exponent as an unsigned number after all, not the encoded key.\nWith RSA there are three distinct key \"sizes\" possible:\n\nthe key size, which is just the size of the modulus as unsigned number in bits;\nthe encoded key size of the public and private key, which can be any size but is commonly larger than the  key size mentioned above;\nthe key strength, which is the strength of the key compared to e.g. an AES key.\n\nNote that RSA with a key size of 1024 has a comparative strength of 80 bits, which is considered on the low side of things.","Q_Score":1,"Tags":"python,cryptography,rsa","A_Id":58026626,"CreationDate":"2019-09-18T16:21:00.000","Title":"can I generate a fixed encrypted message of 16 values 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":"Problem Statement:\nThere are 5 sockets and 6 phones. Each phone takes 60 minutes to charge completely. What is the least time required to charge all phones?\nThe phones can be interchanged along the sockets\nWhat I've tried:\nI've made a list with 6 elements whose initial value is 0. I've defined two functions. Switch function, which interchanges the phone one socket to the left. Charge function, which adds value 10(charging time assumed) to each element, except the last (as there are only 5 sockets). As the program proceeds, how do I restrict individual elements to 60, while other lower value elements still get added 10 until they attain the value of 60?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":57997755,"Users Score":0,"Answer":"You cannot simply restrict the maximum element size. What you can do is check the element size with a if condition and terminate the process.\nbtw, answer is 6x60\/5=72 mins.","Q_Score":0,"Tags":"python","A_Id":57997990,"CreationDate":"2019-09-18T17:09:00.000","Title":"How to restrict the maximum size of an element in a list in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Problem Statement:\nThere are 5 sockets and 6 phones. Each phone takes 60 minutes to charge completely. What is the least time required to charge all phones?\nThe phones can be interchanged along the sockets\nWhat I've tried:\nI've made a list with 6 elements whose initial value is 0. I've defined two functions. Switch function, which interchanges the phone one socket to the left. Charge function, which adds value 10(charging time assumed) to each element, except the last (as there are only 5 sockets). As the program proceeds, how do I restrict individual elements to 60, while other lower value elements still get added 10 until they attain the value of 60?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":57997755,"Users Score":0,"Answer":"In the charge function, add an if condition that checks the value of the element.\nI'm not sure what you're add function looks like exactly, but I would define the pseudocode to look something like this:\nif element < 60:\nadd 10 to the element\nThis way, if an element is greater than or equal to 60, it won't get caught by the if condition and won't get anything added to it.","Q_Score":0,"Tags":"python","A_Id":57997965,"CreationDate":"2019-09-18T17:09:00.000","Title":"How to restrict the maximum size of an element in a list in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, this might be an utterly dumb question, but I have just started working with python and it's data science libs, and I would like to see seaborn plots displayed, but I prefer to work with editors I have experience with, like VS Code or PyCharm instead of Jupyter notebook. Of course, when I run the python code, the console does not display the plots as those are images. So how do I get to display and see the plots when not using jupyter?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":427,"Q_Id":57999071,"Users Score":0,"Answer":"You can try to run an matplotlib example code with python console or ipython console. They will show you a window with your plot. \nAlso, you can use Spyder instead of those consoles. It is free, and works well with python libraries for data science. Of course, you can check your plots in Spyder.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":57999219,"CreationDate":"2019-09-18T18:44:00.000","Title":"how to display plot images outside of jupyter notebook?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For class I am using python arcade. I installed it with pip install arcade. When I attempt to import it with import arcade it pops up ModuleNotFoundError: No module named 'arcade'. \nIve uninstalled and reinstalled arcade. It shows up when I enter pip freeze. I am using VS Code on windows 10.\nWhen I look in the 'errors' tab in VS Code it says \"Unable to import 'arcade' pylint(import-error)[3,1]\"","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2843,"Q_Id":58000647,"Users Score":0,"Answer":"I used to have the same problem. \nThe solution in my case was installing modules by running\npython -m pip install <module> instead of pip install <module>","Q_Score":1,"Tags":"python,python-import,importerror,arcade","A_Id":58000761,"CreationDate":"2019-09-18T20:58:00.000","Title":"No Module named arcade","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an app for MacOS that is compiled with py2app. The app uses the pydub module and the latter uses ffmpeg family package. \nThe problem is that once I compile the app and move it to a different OS, the subprocess call from pydub fails to find any of the ffmpeg packages even though they are installed in \/usr\/local\/bin.\nIf I launch the app from terminal .\/Nameapp.app\/Contents\/MacOs\/Nameapp then it runs no problem, but if I launch it with double click then pydub complains not finding the packages and the app hangs where ffmpeg\/ffprobe should do the work.\nI can see that pydub searches in the \/usr\/local\/bin only if launched from terminal, otherwise no. If I add \/usr\/local\/bin to PATH, pydub doesnt complain anymore that it doesnt find ffmpeg\/ffprobe, but it still gives me an error for both ffmpeg and ffprobe:  [Errno 2] No such file or directory:.\nIf I hardcode the path pydub.AudioSegment.converter = \"\/usr\/local\/bin\/ffmpeg\", the app gives me only ffprobe error [Errno 2] No such file or directory:'ffprobe': 'ffprobe'.\nOn some other posts i've seen pydub.AudioSegment.ffprobe = \"\/path\/to\/ffprobe\" but it doesnt seem to work in my case?\nSo my two questions are:\nHow to hardcode the ffprobe path in pydub?\nHow to solve this without hardcoding path?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":58000698,"Users Score":0,"Answer":"for some reason it works when changing the shell to zsh... switching back to bash no. not really happy with this solution but it's something","Q_Score":0,"Tags":"python-3.x,ffmpeg,py2app,pydub","A_Id":58042215,"CreationDate":"2019-09-18T21:03:00.000","Title":"pydub no ffprobe found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on a project with flask and python in pycharm. My css will not do anything, even really basic things. When I go to the network tab and refresh, I get a 200 message for the CSS file, so I know my link works. Problem is, nothing changes. Also whatever port I'm running on, if I change and save the CSS and open it through dev tools, it doesn't update unless I change to a new port. Any ideas why no CSS is running but I get a 200? Or why I have to change ports to update CSS? Thanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":918,"Q_Id":58002090,"Users Score":0,"Answer":"Browsers cache CSS properties usually. Try hard reloading when you change something. For chrome, you can use ctrl+shift+R.","Q_Score":0,"Tags":"python,flask,pycharm","A_Id":58023893,"CreationDate":"2019-09-19T00:05:00.000","Title":"Pycharm Flask CSS not changing anything but getting a 200 status","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on a project with flask and python in pycharm. My css will not do anything, even really basic things. When I go to the network tab and refresh, I get a 200 message for the CSS file, so I know my link works. Problem is, nothing changes. Also whatever port I'm running on, if I change and save the CSS and open it through dev tools, it doesn't update unless I change to a new port. Any ideas why no CSS is running but I get a 200? Or why I have to change ports to update CSS? Thanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":918,"Q_Id":58002090,"Users Score":0,"Answer":"You could either hard reload the browser tab after clearing the cache or try opening the URL in incognito mode. If it works in incognito mode, then its a caching issue.","Q_Score":0,"Tags":"python,flask,pycharm","A_Id":58676980,"CreationDate":"2019-09-19T00:05:00.000","Title":"Pycharm Flask CSS not changing anything but getting a 200 status","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"After succesfull instalation message from anaconda3 2019.07 installer, I cannot find the scripts file in the installation directory (\"C:\\Users...\\Anaconda3\"). \nI found many fixes to installing anaconda and many of those consist of including the scripts file path to the environment variables path. Then I noticed that I could not find this file whatsoever.\nI've been uninstalling and installing it but the \"scripts\" file seems to not be set during install procedure.","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":826,"Q_Id":58002769,"Users Score":-1,"Answer":"Please check whether you have Scripts folder inside anaconda3. \nYou can set the path to Scripts folder in the \"Path\" Environment variable inside control panel(Control Panel\\System and Security\\System -> Advanced system settings -> Environment Variables) as \nC:\\Users.....\\anaconda3\\Scripts\nHope this helps.","Q_Score":2,"Tags":"python,anaconda,conda","A_Id":58005733,"CreationDate":"2019-09-19T02:06:00.000","Title":"Anaconda not setting Scripts file when installing","Data 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 succesfull instalation message from anaconda3 2019.07 installer, I cannot find the scripts file in the installation directory (\"C:\\Users...\\Anaconda3\"). \nI found many fixes to installing anaconda and many of those consist of including the scripts file path to the environment variables path. Then I noticed that I could not find this file whatsoever.\nI've been uninstalling and installing it but the \"scripts\" file seems to not be set during install procedure.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":826,"Q_Id":58002769,"Users Score":0,"Answer":"From the FAQ:\n\nIn what folder should I install Anaconda on Windows?\nWe recommend installing Anaconda or Miniconda into a directory that contains only\n7-bit ASCII characters and no spaces, such as C:\\anaconda. Do not\ninstall into paths that contain spaces such as C:\\Program Files or\nthat include Unicode characters outside the 7-bit ASCII character set.\nThis helps ensure correct operation and no errors when using any\nopen-source tools in either Python 3 or Python 2 conda environments.\n\nIn my case, I reinstalled Miniconda3 in a folder located at a \"shorter\" path (D:\\Miniconda3) and the Scripts folder were created.","Q_Score":2,"Tags":"python,anaconda,conda","A_Id":66674142,"CreationDate":"2019-09-19T02:06:00.000","Title":"Anaconda not setting Scripts file when installing","Data 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 Python script (pymongo) to export collection from MongoDB and ingesting to other database. This workflow is scheduled to run once a day using Apache Airflow. Every time script run its exports whole collection and overwrite the whole data at target but I want to fetch only the changes made to collection in subsequent execution of script, especially new documents added to collection.\nI have read other related questions but there \"change streams\" is suggested as solution but \"change stream\" is for real time. I want periodic updates for examples fetch the new documents added since the last execution of script. \nDo I have to download and scan the whole new updated collection and compare it with the old collection?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":212,"Q_Id":58005421,"Users Score":1,"Answer":"Create a lookup table or collection where it saves the last run time and if the documents in the collection have timestamp then save the timestamp and _id in the very same lookup table.\nIf there aren't any timestamps in the documents then you can use the _id but the object ids in increasing order here are because the spec says that \ntime|machine|pid|inc is the format for creating the ObjectId.\nThere is already a time component in the ObjectId, but that is in seconds. The Date type in Mongo is the representation of the number of milliseconds from the epoch, which will give you some more precision for figuring out the time of insertion.\nI recommend to use a counter in the form of Sequence numbers if you need absolute precision beyond milliseconds and store the last sequence and the next run get query it by greater than to only get the delta data.","Q_Score":1,"Tags":"python,mongodb,pymongo,airflow","A_Id":58005686,"CreationDate":"2019-09-19T07:00:00.000","Title":"How to check for changes in collection periodically","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to have a self-contained installation of python on a USB stick as I don't have enough room on my laptop to install anaconda etc. \nThis will also be useful as I use different machines that can't have software installed on them.\nI know that multiple settings must be changed for this to work but there is very little information about this and I don't have any experience in changing program files\/settings.\nI already have both WinPython and PyCharm installed on the USB stick but I have not yet changed any settings.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2716,"Q_Id":58006195,"Users Score":0,"Answer":"I know this post is older, but I ran into this same question days ago.\nI took a fresh USB stick and installed the latest Python onto it, instead of letting Python install to the default Windows directory. Then, I installed Pycharm the same way to my USB stick, with no issue.\nOnce I was inside of Pycharm, the bottom right hand corner of the screen said \"No Interpreter.\" I clicked that and navigated my way to the flash drive and selected where Python was.\nSo far, I have had absolutely no issue using it and learning more about Python on the go!","Q_Score":2,"Tags":"python,python-3.x,pycharm,portable-applications","A_Id":70961816,"CreationDate":"2019-09-19T07:48:00.000","Title":"Is there an easy way to put my entire installation of PyCharm and WinPython on a USB stick?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having a little trouble understanding what this function does:\ncanvas.create_window(0, 0, anchor='nw', window=frame)\nsince usually app=tkinter.Tk() gives a type of Tkinter.Tk, and is for all intents and purpose a window and a handler into the window instance, what does create_window create?\nAnd, from this code, it seems like create_window hooks a Tkinter.Frame into the window and the return type for create_window is an int. You can put a frame in a canvas so why create_window? And does the returned int mean anything?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":710,"Q_Id":58009398,"Users Score":2,"Answer":"what does create_window create?\n\nIt creates a canvas object, similar to a line, rectangle, image, etc. Like a line or rectangle, this canvas object has attributes that define what it looks like. In the case of a window object, one of the attributes is window which specifies a widget to be displayed as the object.\n\nYou can put a frame in a canvas so why create_window\n\nIf you add a frame in a canvas with pack, place, or grid it will appear inside the canvas but it won't be part of the canvas. That means that if you attach scrollbars to the canvas, the frame will not scroll. By using create_window, the frame becomes part of the canvas, and can be manipulated and scrolled like any other canvas object.\n\nAnd does the returned int mean anything?\n\nThe value returned from calling create_window is an integer index which can be used later to refer to this object.","Q_Score":1,"Tags":"python,user-interface,tkinter","A_Id":58012419,"CreationDate":"2019-09-19T10:52:00.000","Title":"tkinter what is a window when calling tk.canvas.create_window()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've coded a simple neural network for XOR in python. While there is loads of information online about how to program this, there isn't much on how to feed the data through it. I've tested the change in weights after one cycle for inputs [1,1] to compare my results with my lecture slides and it's 100% the same, so I believe the code works. I can train the network for that same input, but when I change the input (and corresponding target) every cycle the error doesn't go down.\nShould I allow changing the weights and inputs after every cycle or should I run through all the possible inputs first, get an average error and then change the weights? (But changing weights are dependent on the output, so what output would I use then) \nI can share my code, if needed, but I'm pretty certain it's correct.\nPlease give me some advice? Thank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":704,"Q_Id":58010363,"Users Score":1,"Answer":"So, you're saying you implemented a neural network on your own ?\nwell in this case, basically each neuron on the input layer must be assigned with a feature of a certain row, than just iterate through each layer and each neuron in that layer and calculate as instructed.\nI'm sure you are familiar with the back-propagation algorithm so you'll know when to stop.\nonce you're done with that row, do it again to the next row, assign each feature to each of the input neurons and start the iterations again.\nonce youre done with all records, thats an Epoch.\nI hope that answers your question.\nalso, I would recommend you to try out Keras, its easy to use and a good tool to be experienced in.","Q_Score":2,"Tags":"python,neural-network,backpropagation","A_Id":58011558,"CreationDate":"2019-09-19T11:49:00.000","Title":"How do I feed data into my neural network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to setup a python script that uses the requests library to get data from a website. The script works without issues running in a virtual environment on my windows 10 pc or on a azure vm. \nHowever, when I try to create a docker container using the python:3.6-slim image I get DH_KEY_TOO_SMALL errors. Testing the website on ssllabs.com revealed that it supports weak DH key exchange parameters. What could be causing this error and how can I fix it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2231,"Q_Id":58011032,"Users Score":4,"Answer":"I've managed to fix the issue. The problem was caused by openssl versions. Both my windows 10 pc and ubuntu 18.04 vm run an older version that had no problem connecting to the website. The python docker images contain a newer version of openssl that refused to connect.","Q_Score":4,"Tags":"python,docker,openssl,python-requests","A_Id":58012193,"CreationDate":"2019-09-19T12:26:00.000","Title":"Docker python requests results in DH KEY TOO SMALL error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm writing some code where one thread is using setters from a class and another thread is using getters from the same class.\nMy question is do I need to use lock or is there no problem when the threads call the getter and setter at the same time?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":370,"Q_Id":58011805,"Users Score":0,"Answer":"The most important use-case for locks is, to prevent threads B, C, and D from seeing some collection of shared data in an inconsistent or invalid state while thread A is in the middle of modifying the data.\nThe GIL won't prevent that from happening because the GIL does not prevent threads from being preemptively scheduled.\n\"setters\" and \"getters\" are irrelevant. The point is, you have different threads accessing shared variables.  If any of those variables has an important relationship to any other, and if a thread that updates them has to temporarily break that relationship, then you need locks.  Without locks, the scheduler could \"swap out\" the thread that has temporarily broken the relationship, and some other thread could see the variables in the \"broken\" state.\nA lock won't prevent the scheduler from \"swapping out\" any thread at any moment, but it will prevent other threads from seeing the mess before the first thread gets to run again, clean up the mess, and unlock the lock.","Q_Score":0,"Tags":"python,multithreading,locks","A_Id":58014329,"CreationDate":"2019-09-19T13:11:00.000","Title":"Do i need locks when accessing a class with getter and setter from different threads?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I try to configure my Python Interpreter on PyCharm I get an error\n\nStandard Python 'venv' module not found.\n\nWhat does it mean and how do I solve it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":58016438,"Users Score":0,"Answer":"Ideally venv or virtual environment comes as a folder along with the installation in the IDE containing python.exe, you can try either specifying the path of python.exe inside venv explicitly in the Project Interpreter or reinstalling the IDE in the system.","Q_Score":1,"Tags":"python,python-3.x,pycharm,interpreter","A_Id":59137643,"CreationDate":"2019-09-19T17:46:00.000","Title":"I get an error whenever I try to configure my Python Interpreter on PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Celery with a RabbitMQ server. I have a publisher, which could potentially be terminated by a SIGKILL and since this signal cannot be watched, I cannot revoke the tasks. What would be a common approach to revoke the tasks where the publisher is not alive anymore?\nI experimented with an interval on the worker side, but the publisher is obviously not registered as a worker, so I don't know how I can detect a timeout","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":152,"Q_Id":58017144,"Users Score":6,"Answer":"There's nothing built-in to celery to monitor the producer \/ publisher status -- only the worker \/ consumer status.  There are other alternatives that you can consider, for example by using a redis expiring key that has to be updated periodically by the publisher that can serve as a proxy for whether a publisher is alive.  And then in the task checking to see if the flag for a publisher still exists within redis, and if it doesn't the task returns doing nothing.","Q_Score":8,"Tags":"python,rabbitmq,celery","A_Id":58053094,"CreationDate":"2019-09-19T18:35:00.000","Title":"Tasks linger in celery amqp when publisher is terminated","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am using Celery with a RabbitMQ server. I have a publisher, which could potentially be terminated by a SIGKILL and since this signal cannot be watched, I cannot revoke the tasks. What would be a common approach to revoke the tasks where the publisher is not alive anymore?\nI experimented with an interval on the worker side, but the publisher is obviously not registered as a worker, so I don't know how I can detect a timeout","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":152,"Q_Id":58017144,"Users Score":4,"Answer":"Another solution, which works in my case, is to add the next task only if the current processed ones are finished. In this case the queue doesn't fill up.","Q_Score":8,"Tags":"python,rabbitmq,celery","A_Id":58107564,"CreationDate":"2019-09-19T18:35:00.000","Title":"Tasks linger in celery amqp when publisher is terminated","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I know how to use magical methods in python, but I would like to understand more about them.\nFor it I would like to consider three examples:\n1) __init__:\nWe use this as constructor in the beginning of most classes. If this is a method, what is the object associated with it? Is it a basic python object that is used to generate all the other objects?\n2) __add__\nWe use this to change the behaviour of the operator +. The same question above.\n3) __name__:\nThe most common use of it is inside this kind of structure:if __name__ == \"__main__\":\nThis is return True when you are running the module as the main program.\nMy question is __name__  a method or  a variable? If it is a variable what is the method associated with it. If this is a method, what is the object associated with it?\nSince I do not understand very well these methods, maybe the questions are not well formulated. I would like to understand how these methods are constructed in Python.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":55,"Q_Id":58017504,"Users Score":1,"Answer":"The object is the class that's being instantiated, a.k.a. the Foo in Foo.__init__(actual_instance)\nIn a + b the object is a, and the expression is equivalent to a.__add__(b)\n__name__ is a variable. It can't be a method because then comparisons with a string would always be False since a function is never equal to a string","Q_Score":0,"Tags":"python,object,methods","A_Id":58017632,"CreationDate":"2019-09-19T19:03:00.000","Title":"Python \"Magic methods\" are realy methods?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I run Django 1.11.20. I have just (finally) made the jump from Python 2.7 to 3.7.\nI've noticed that since upgrading to Python 3, the very first page load after clearing the cache is very slow. So far I only have my Python 3 environment on my development machine, so I'm experiencing this when using .\/manage.py runserver and the FileBasedCache backend. I don't know if I will experience the same thing on a production stack (nginx, uwsgi, redis, etc).\nI'm using Django Debug Toolbar, which gives me some hints as to what the problem isn't, but I'm not sure where I should look to see what the problem is.\nThe times given by the debug toolbar run loading a simple page with an empty cache in the Python 2.7 environment on my development machine are:\n\nCPU: 4877.89ms\nSQL 462.41ms\nCache: 1154.54ms\n\nThe times given by the debug toolbar run loading the same page with an empty cache in the Python 3.7 environment on my development machine are:\n\nCPU: 91661.71ms\nSQL 350.44ms\nCache: 609.65ms\n\n(I'm using the file based caching on this development machine, so when I say \"with an empty cache\" I just mean that I rm -r cache before loading the URL in my browser.)\nSo the SQL and Cache times got slightly faster with the upgrade, but the CPU time doubled. When I open the \"Time\" panel in the debug toolbar I see that the \"timing attribute\" that increased is \"request\".\nThis same thing happens on every page (including pages that are just HTML generated by TemplateView, so they're not doing anything tricky), but only when it is first loaded from an empty cache. After that very first response, all pages are back to about the same response time as in the Python 2 environment. So it is something to do with the initial request.\nI'm not sure where to look to try to figure out what Django is doing only on the very first request. Any pointers? Or is there something obvious that I can expect to be slower in the jump from Python 2.7 to 3.7?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":508,"Q_Id":58018939,"Users Score":2,"Answer":"I was finally able to trace this problem back to the Django Debug Toolbar itself, which was bumped from 1.11 to 2.0 during my Python 3 upgrade. Specifically, the toolbar's SQL panel was causing the slowdown. I have a context processor which executes a query if a cached object does not exist. The query itself is fast, but for some reason Django Debug Toolbar 2.0 is extremely slow generating the stacktrace for it. I have not figured out what changed between 1.11 and 2.0 to cause this terrible performance loss, but now that I know where the problem lies I can work around it.","Q_Score":0,"Tags":"python,django,python-3.7,django-debug-toolbar","A_Id":58033120,"CreationDate":"2019-09-19T21:07:00.000","Title":"Django Initial Page Load Slow After Python 2 to 3 Upgrade","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to write a program with python that works like android folders bit for Windows. I want the user to be able to single click on a desktop icon and then a window will open with the contents of the folder in it. After giving up trying to find a way to allow single click to open a desktop application (for only one application I am aware that you can allow single click for all files and folders), I decided to check if the user clicked in the location of the file and if they were on the desktop while they were doing that. So what I need to know is how to check if the user is viewing the desktop in python.\nThanks,\nHarry\nTLDR; how to check if user is viewing the desktop - python","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":256,"Q_Id":58018945,"Users Score":0,"Answer":"I don't know if \"single clicking\" would work in any way but you can use Pyautogui to automatically click as many times as you want","Q_Score":2,"Tags":"python,windows,directory,desktop","A_Id":58028985,"CreationDate":"2019-09-19T21:07:00.000","Title":"Python - how to check if user is on the desktop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My code itself doesn't have an issue, this is more of a general question about code that already works. I solve a maze using breadth first search and I'm looking to study the node expansion, space complexity, and O(n) - which, for BFS, is O(b^d).\nI'm not used to studying the program once finished and I was wondering if there are any specific methods that are best. I know the code itself will give me a time but I was wondering if there are any library functions that could help, or if there is maybe a function I could implement that would better show me quantitative results.\nI have the ability to run the test on multiple different mazes (I even have a maze creator) but I'm asking for something (anything) more quantitative than just running this code on three or four different mazes and using the auto-output. I'm also using pycharm, which I'm unfamiliar with - are there ways the IDE can formalize this information?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":58019916,"Users Score":1,"Answer":"For maze problem (without any assumption and knowledge of the network learnt prior), A-STAR algorithm is the state of the earth. Its complexities are: \nWorst complexity: O(|E|) = O(b^d)\nSpace complexity: O(|V|) = O(b^d)\nFor fairly large network (such as road networks), practical algorithms exists because we can pre-compute some paths apriori. They will have less time complexity (trade-off with larger space complexity) after the pre-processing (or learning) has been done.","Q_Score":0,"Tags":"python","A_Id":58019995,"CreationDate":"2019-09-19T23:17:00.000","Title":"Study of node expansion and O(n) for maze","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are there any caveats similar to variable caching when using threading.Timer in Python?\nI'm observing an effect similar to not putting \"volatile\" keyword in other languages, but I've read that this doesn't apply to Python and yet something is off. In summary, two methods (threads?) agree on the identity of a list variable but disagree on the contents.\nI have a class with member variable self.x (a list) which is assigned once in constructor and then its identity never changes (but it can be cleared and refilled).\nA Timer is also started in the constructor that periodically updates the contents of self.x. I'm not using any locks though I probably should (eventually).\nOther users of the class instance then sometimes try to read the contents of the list.\nProblem: At the end of the timer handler, the list is populated correctly (I've printed its contents in the logs) but when a user of the class instance reads the instance variable, it's empty! (more specifically, same value as it was initialized in the constructor, i.e. if I put some other item in there, it'll be that value).\nThe weird thing is that the getter and the timer agree on the identity of the list! (id(self.x) returns the same value). Also, I was not able to repro this in tests, even though I'm doing the same thing.\nAny idea what I might be doing wrong?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":58020472,"Users Score":0,"Answer":"Seems like I misunderstood how multiprocessing works. What happened is the code forked into multiple processes and even though the id() of objects remained the same, I didn't realize they were in different (forked) processes. I knew this was happening but I thought that the fork would take care of copying the timer as well. I've changed the code to create the object (and timers) once the fork is complete and it seems to have solved the problem.","Q_Score":0,"Tags":"python,multithreading,timer","A_Id":58033274,"CreationDate":"2019-09-20T00:59:00.000","Title":"threading.Timer in Python -- two functions agree on variable identity, but not the value","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"According to python's documentation, \n\nThe NullHandler class, located in the core logging package, does not\n  do any formatting or output. It is essentially a \u2018no-op\u2019 handler for\n  use by library developers.\n\nIf it doesn't print to anything, what is the use of this handler at all? Why would one go to lengths to write loggers and then use null handler to not print anything?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1165,"Q_Id":58025923,"Users Score":5,"Answer":"So you can keep your logger.warning('Whatever') statements in your code, but conditionally inject a logger that entirely disregards them if you don't want a log in certain situations.","Q_Score":0,"Tags":"python,logging","A_Id":58026057,"CreationDate":"2019-09-20T09:48:00.000","Title":"What are the uses of Null handler in python logging?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Good day!\nI have a celebrity dataset on which I want to fine-tune a keras built-in model. SO far what I have explored and done, we remove the top layers of the original model (or preferably, pass the include_top=False) and add our own layers, and then train our newly added layers while keeping the previous layers frozen. This whole thing is pretty much like intuitive.\nNow what I require is, that my model learns to identify the celebrity faces, while also being able to detect all the other objects it has been trained on before. Originally, the models trained on imagenet come with an output layer of 1000 neurons, each representing a separate class. I'm confused about how it should be able to detect the new classes? All the transfer learning and fine-tuning articles and blogs tell us to replace the original 1000-neuron output layer with a different N-neuron layer (N=number of new classes). In my case, I have two celebrities, so if I have a new layer with 2 neurons, I don't know how the model is going to classify the original 1000 imagenet objects.\nI need a pointer on this whole thing, that how exactly can I have a pre-trained model taught two new celebrity faces while also maintaining its ability to recognize all the 1000 imagenet objects as well.\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1312,"Q_Id":58027839,"Users Score":3,"Answer":"With transfer learning, you can make the trained model classify among the new classes on which you just trained using the features learned from the new dataset and the features learned by the model from the dataset on which it was trained in the first place. Unfortunately, you can not make the model to classify between all the classes (original dataset classes + second time used dataset classes), because when you add the new classes, it keeps their weights only for classification.\nBut, let's say for experimentation you change the number of output neurons (equal to the number of old + new classes) in the last layer, then it will now give random weights to these neurons which on prediction will not give you meaningful result. \nThis whole thing of making the model to classify among old + new classes experimentation is still in research area. \nHowever, one way you can achieve it is to train your model from scratch on the whole data (old + new).","Q_Score":4,"Tags":"python,tensorflow,keras,deep-learning,classification","A_Id":58028414,"CreationDate":"2019-09-20T11:50:00.000","Title":"How to fine-tune a keras model with existing plus newer classes?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Imageio, the python library that wraps around ffmpeg to do hardware encoding via nvenc. My issue is that I can't get more than 2 sessions to launch (I am using non-quadro GPUs). Even using multiple GPUs. I looked over NVIDIA's support matrix and they state only 2 sessions per gpu, but it seems to be per system.\nFor example I have 2 GPUs in a system. I can either use the env variable CUDA_VISIBLE_DEVICES or set the ffmpeg flag -gpu to select the GPU. I've verified gpu usage using Nvidia-smi cli. I can get 2 encoding sessions working on a single gpu. Or 1 session working on 2 separate gpus each. But I can't get 2 encoding sessions working on 2 gpus. \nEven more strangely if I add more gpus I am still stuck at 2 sessions. I can't launch a third encoding session on a 3rd gpu. I am always stuck at 2 regardless of the # of gpus. Any ideas on how to fix this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":967,"Q_Id":58029589,"Users Score":2,"Answer":"Nvidia limits it 2 per system Not 2 per GPU. The limitation is in the driver, not the hardware. There have been unofficially drivers posted to github which remove the limitation","Q_Score":0,"Tags":"python,ffmpeg,python-imageio,nvenc","A_Id":58042103,"CreationDate":"2019-09-20T13:43:00.000","Title":"Nvenc session limit per GPU","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am struggling with a vlookup in python.\nI have two datasets.\nFirst is called \"output_apu_stock1\". Here i have quantities and prices, that should be update the second dataset.\nSecond is called \"Angebote_Master_File\".\nNow, if i run my code, the new dataset \"results\" contains only the values, that matches. Leads to the problem, that my \"Angebote_Master_File\" that has originally around 1600 observations, shrinks to around 400 observations. \nimport pandas as pd\ndf1 = pd.read_csv(\"C:\/Users\/Desktop\/output_apu_stock1.csv\")\ndf2 = pd.read_csv(\"C:\/Users\/Desktop\/Angebote_Master_File.csv\")\nresults = df2.merge(df1,on=\"sku\")\nI got the point, that the final dataset contains only the matched observations (identifier is the column \"sku\") and drop the others...\nI need the merged file containing all observations from the \"Angebote_Master_File\" without any losses.\nThanks for your help!\nBest\nMichael","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":85,"Q_Id":58030255,"Users Score":0,"Answer":"results = df2.merge(df1,on=\"sku\", how=\"outer\")","Q_Score":0,"Tags":"python,pandas,replace,vlookup","A_Id":58031057,"CreationDate":"2019-09-20T14:25:00.000","Title":"Do a vlookup with pandas in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project through PyCharm. When I started the project, the project interpreter was a newly created virtualenv located in my project folder at \/path\/to\/project_folder\/venv and using base interpreter \/usr\/bin\/python3.6.\nWhen working in PyCharm, the Python Console seems to be using the right venv\/Python executable etc. Running os.system(\"which python\") returns \/usr\/bin\/python.\nNext, I activate this venv through my terminal (on Ubuntu 18.04) using the command source \/path\/to\/project_folder\/venv\/bin\/activate which works fine and shows me that it is activated with a (venv). However, if I run which python, it returns \/home\/user\/anaconda3\/bin\/python.\nWhy is this occurring? How can I access the same Python interpreter from the PyCharm console through my Ubuntu terminal?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":491,"Q_Id":58030455,"Users Score":1,"Answer":"Same happened to me in a specific project.\nSymptoms:\n\nNo executable taken from the venv; i.e:\nwhich python3 from bash is not taken from venv\nPython packages are not working from venv\n\nCause:\n\nYou renamed your project folder\nVirtual environment PATH keeps old path to venv\nIt fails silently\n\nSolutions:\n\nCreate a new venv and reinstall requirements, OR\nRename folder to its old name\n\nChange PATH is not the solution. venv script creates some other routes in various files.\nNote: Tested with python3 -m venv venv","Q_Score":1,"Tags":"python,linux,pycharm,virtualenv","A_Id":66087846,"CreationDate":"2019-09-20T14:35:00.000","Title":"Activated virtual environment using incorrect Python executable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I don't know that much about vectorization, but I am interested in understanding why a language like python can not provide vectorization on iterables through a library interface, much like it provides threading support. I am aware that many numpy methods are vectorized, but it can be limiting to have to work with numpy for generic computations.\nMy current understanding is that python is not capable of vectorizing functions even if they match the \"SIMD\" pattern. For instance, in theory shouldn't any list comprehension or use of the map() function be vectorizable because they output a list which is the result of running the same function on independent inputs from an input list? \nWith my niave understanding, it seems that anytime I use map(), in theory, I should be able to create an instruction set that represents the function; then each element in the input just needs to be run through the same function that was compiled. What is the technical challenge to designing a tool that provides simd_map(func, iterable), which attempts to compile func \"just in time\" and then grabs batches of input from iterable and utilizes the processor's simd capabilities to run those batches through func()?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":637,"Q_Id":58035479,"Users Score":0,"Answer":"You want vectorization or JIT compilation use numba, pypy or cython but be warned the speed comes at the cost of flexibility. \nnumba is a python module that will jit compile certain functions for you but it does not support many kinds of input and barfs on some (many) python constructs. It is really fast when it works but can be difficult to wrangle. It is also very targeted at working with numpy arrays.\npypy is a complete replacement for the cpython interpreter that is a JIT. It supports the entire python spec but does not integrate with extensions well so some libraries will not work.\ncython is an extension of python which compiles to a binary which will behave like a python module. However it does require you to use special syntax to take advantage of the speed gains and requires you to explicitly declare things as ctypes to real get any advantage.\nMy recommendation is:\nuse pypy if you are pure python. (if it works for you it's basically effortless)\nUse numba if you need to speed up numeric calculations that numpy doesn't have a good way to do.\nUse cython if you need the speed and the other 2 don't work.","Q_Score":2,"Tags":"python,parallel-processing,vectorization,python-multiprocessing,simd","A_Id":58035832,"CreationDate":"2019-09-20T21:44:00.000","Title":"Why can't python vectorize map() or list comprehensions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I pulled the new code from GitHub and my colleagues changed the type of a field in a Django model from TextField to JSONField. After running python manage.py makemigrations and python manage.py migrate the type of the field was changed in the database (I suppose). I needed to reverse back to previous migration and somehow the type of the field was not reversed. How could I fix the issue? Why reversing back migration does not revert back the field type?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":134,"Q_Id":58035648,"Users Score":1,"Answer":"Change the field type back to a TextField, then run python manage.py makemigrations and python manage.py migrate again. If the migration still exists in your django project, it will look at its dependencies, which most likely still links to the migration that turned it into a JSONField. So simply doing the exact same thing to turn it back into a TextField should work","Q_Score":0,"Tags":"python,django","A_Id":58036574,"CreationDate":"2019-09-20T22:08:00.000","Title":"Reverse back Postgres field type when migrations were applied in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a CNN with 2 hidden layers. When i use keras on cpu with 8GB RAM, sometimes i have \"Memory Error\" or sometimes precision class was 0 but some classes at the same time were 1.00. If i use keras on GPU,will it solve my problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":58037171,"Users Score":0,"Answer":"You probably don't have enough memory to fit all the images in the CPU during training. Using a GPU will only help if it has more memory. If this is happening because you have too many images or they're resolution is too high, you can try using keras' ImageDataGenerator and any of the flow methods to feed your data in batches.","Q_Score":0,"Tags":"python-3.x,keras,gpu,conv-neural-network","A_Id":58045304,"CreationDate":"2019-09-21T03:59:00.000","Title":"What is difference between the result of using GPU or not?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Multiline feature in jupyter console would be great to use. I've searched in several sources, and they all say to use ctrl-enter or alt-enter but none of them work. Also read it's a bug that hasn't been fixed. Am I missing something (perhaps trivial)? Thanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":58037373,"Users Score":0,"Answer":"If what you're trying to do is multiline editing:\n\nhold down CTRL and click in different places of the same cell;\nhold down ALT and drag down your mouse.","Q_Score":0,"Tags":"console,ipython,jupyter,multiline","A_Id":58038464,"CreationDate":"2019-09-21T04:52:00.000","Title":"How to use multiline feature in the Jupyter Console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Multiline feature in jupyter console would be great to use. I've searched in several sources, and they all say to use ctrl-enter or alt-enter but none of them work. Also read it's a bug that hasn't been fixed. Am I missing something (perhaps trivial)? Thanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":58037373,"Users Score":0,"Answer":"\\ at end of line works.  You may need to type enter twice to exit the multiline block.  \nI have noticed that \\ at end of line does not work when the jupyter console is invoked from Emacs so make sure you work in plain terminal.","Q_Score":0,"Tags":"console,ipython,jupyter,multiline","A_Id":59699731,"CreationDate":"2019-09-21T04:52:00.000","Title":"How to use multiline feature in the Jupyter Console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The Divio Django CMS offers two servers: TEST and LIVE. Are these also two separate repositories? Or how is this done in the background?\nI'm wondering because I would have the feeling the LIVE server is its own repository that just pulls from the TEST whenever I press deploy. Is that correct?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":58,"Q_Id":58038110,"Users Score":1,"Answer":"All Divio projects (django CMS, Python, PHP, whatever) have a Live and Test environment.\nBy default, both build the project from its repository's master branch (in older projects, develop). \nOn request, custom tracking branches can be enabled, so that the Live and Test environments will build from separate branches.\nWhen a build successfully completes, the Docker image can be reused until changes are made to the project's repository. This means that after a successful deployment on Test, the Docker image doesn't need to be rebuilt, and the Live environment can be deployed much faster from the pre-built image. (Obviously this is only possible when they are on the same branch.)","Q_Score":1,"Tags":"python,django,divio","A_Id":58041679,"CreationDate":"2019-09-21T07:16:00.000","Title":"Setup of the Divio CMS Repositories","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I started messing around with python turtle graphics and it seems that at a certain point in my program it starts to take up a lot of memory in my task manager (around 2gb) and become a bit laggy. I'm assuming its must be the turtles so I tried to use the turtle.clearscreen() midway through the program and I saw that it still was sucking up the same amount of memory or was still increasing in size so i'm assuming its not actually deleting the turtles. \nThe only fix seems to be to exit the python turtle graphics completely which ends up ending the program however i still want the program to continue. Is anyone aware of a solution for this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":197,"Q_Id":58039113,"Users Score":0,"Answer":"Try increasing the amount of memory you have or close unnecessary tasks. I'm not sure if there is a way to decrease the ram turtle itself uses, so use these methods as a starting base.","Q_Score":0,"Tags":"python,turtle-graphics","A_Id":61620496,"CreationDate":"2019-09-21T09:50:00.000","Title":"Python turtle graphics eating a lot of memory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is [Setup] purposes in Robot Framework? Is it a built in keywords or we can extend it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":336,"Q_Id":58039370,"Users Score":0,"Answer":"So, I use mostly two Setup i.e. Suite Setup and Suite Teardown.\nA suite setup is executed before any test cases or sub test suites in that test suite, and similarly a suite teardown is executed after them.","Q_Score":0,"Tags":"python,robotframework","A_Id":58051551,"CreationDate":"2019-09-21T10:25:00.000","Title":"Robot Framework: What is [Setup] purposes?","Data Science and Machine Learning":0,"Database and SQL":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 [Setup] purposes in Robot Framework? Is it a built in keywords or we can extend it?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":336,"Q_Id":58039370,"Users Score":2,"Answer":"The setup and teardown statements in a test ([Setup] and [Teardown], or the setup and teardown options in the settings table) are themselves not keywords, though they are used in a similar manner. They take a keyword as their first argument, and that keyword is run before the body of the test ([Setup]) or after the body of the test has finished running ([Teardown]). The keyword you provide can do anything you want, so in that sense you can extend them.\nA test typically has four phases (though the second and third can sometimes be intermixed):\n\nsetup - prepare the system for test\nexercise - perform actions on the system being tested\nverify - do verifications on the outcome of the exercise\nteardown - free up resources used by the tests\n\nBy using [Setup], or the global Suite Setup or Test Setup in the settings section, helps you identify which code is preparing the test and which code is related to the actual test. \nOne of the aspects of good test design is that failure should tell you something useful. If a test fails during setup, that is going to tell you something different from failure during the test itself. A failure in the body of the test signals a failure in the product being tested, a failure in the setup or teardown usually means there is a problem with infrastructure or the implementation of the test itself.\nAs a useful side-effect, using setup and teardown helps to document your test cases. The setup says \"this isn't what this test is testing, it's simply preparing the test\". The body of the test says \"this is what I'm actually testing\". And the teardown says \"I'm done testing, now it's time to clean up\".","Q_Score":0,"Tags":"python,robotframework","A_Id":58041646,"CreationDate":"2019-09-21T10:25:00.000","Title":"Robot Framework: What is [Setup] purposes?","Data Science and Machine Learning":0,"Database and SQL":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":"Example: db.init_app(app)\nWhat is purpose of init_app function in Flask? Is this like any other method?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5455,"Q_Id":58042067,"Users Score":0,"Answer":"It is used to control the integration of a package to one or more Flask applications. Depending on how you initialize the object it is usable right away or will attach as needed to a Flask application. \nIn the case of db.init_app(app) the app is your flask application,the object must have been created initially.","Q_Score":5,"Tags":"python-3.x,flask","A_Id":58048054,"CreationDate":"2019-09-21T16:20:00.000","Title":"What is purpose of init_app function in Flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Example: db.init_app(app)\nWhat is purpose of init_app function in Flask? Is this like any other method?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5455,"Q_Id":58042067,"Users Score":7,"Answer":"A number of packages provide an init_app() method. It's a way of constructing an instance of the particular package, then letting it know about the Flask instance (e.g., so that configuration details can be copied). Mechanically, it's just like any other instance method.","Q_Score":5,"Tags":"python-3.x,flask","A_Id":58042133,"CreationDate":"2019-09-21T16:20:00.000","Title":"What is purpose of init_app function in Flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am aware of this parameter var_smoothing and how to tune it, but I'd like an explanation from a math\/stats aspect that explains what tuning it actually does - I haven't been able to find any good ones online.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4054,"Q_Id":58046129,"Users Score":12,"Answer":"A Gaussian curve can serve as a \"low pass\" filter, allowing only the samples close to its mean to \"pass.\" In the context of Naive Bayes, assuming a Gaussian distribution is essentially giving more weights to the samples closer to the distribution mean. This might or might not be appropriate depending if what you want to predict follows a normal distribution.\nThe variable, var_smoothing, artificially adds a user-defined value to the distribution's variance (whose default value is derived from the training data set). This essentially widens (or \"smooths\") the curve and accounts for more samples that are further away from the distribution mean.","Q_Score":3,"Tags":"python,machine-learning,scikit-learn,gaussian","A_Id":62098032,"CreationDate":"2019-09-22T04:50:00.000","Title":"Can someone give a good math\/stats explanation as to what the parameter var_smoothing does for GaussianNB in scikit learn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to compare the two sentences. As a example,\nsentence1=\"football is good,cricket is bad\"\nsentence2=\"cricket is good,football is bad\"\nGenerally these senteces have no relationship that means they are different meaning. But when I compare with python nltk tools it will give 100% similarity. How can I fix this Issue? I need Help.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":566,"Q_Id":58046570,"Users Score":1,"Answer":"Semantic Similarity is a bit tricky this way, since even if you use context counts (which would be n-grams > 5) you cannot cope with antonyms (e.g. black and white) well enough. Before using different methods, you could try using a shallow parser or dependency parser for extracting subject-verb or subject-verb-object relations (e.g. ), which you can use as dimensions. If this does not give you the expected similarity (or values adequate for your application), use word embeddings trained on really large data.","Q_Score":0,"Tags":"python,nlp,nltk","A_Id":58234695,"CreationDate":"2019-09-22T06:19:00.000","Title":"How to Compare Sentences with an idea of the positions of keywords?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Could anyone tell me what's the meaning of  '10' and '49' in the following log of tensorflow?\nMuch Thanks\nINFO:tensorflow:Started compiling\nINFO:tensorflow:Finished compiling. Time elapsed: 5.899410247802734 secs\n10\/10 [==============================] - 23s 2s\/step - loss: 2.6726 - acc: 0.1459\n49\/49 [==============================] - 108s 2s\/step - loss: 2.3035 - acc: 0.2845 - val_loss: 2.6726 - val_acc: 0.1459\nEpoch 2\/100\n10\/10 [==============================] - 1s 133ms\/step - loss: 2.8799 - acc: 0.1693\n49\/49 [==============================] - 17s 337ms\/step - loss: 1.9664 - acc: 0.4042 - val_loss: 2.8799 - val_acc: 0.1693","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":173,"Q_Id":58047736,"Users Score":1,"Answer":"10 and 49 corresponds to the number of batches which your dataset has been divided into in each epoch. \nFor example, in your train dataset, there are totally 10000 images and your batch size is 64, then there will be totally math.ceil(10000\/64) = 157 batches possible in each epoch.","Q_Score":1,"Tags":"python-3.x,tensorflow,tensor,tensorflow-estimator","A_Id":58048268,"CreationDate":"2019-09-22T09:08:00.000","Title":"What's the meaning of the number before the progress bar when tensorflow is training","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a given string, how can we substitute the decimal point in a floating point number with a comma?\nFor example: 12.33 should become 12,33\nPlease note that I can not simply replace all the . with , since the text also contains full stops to separate two sentences.\nI need this for a text cleaning purpose.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":58047744,"Users Score":0,"Answer":"I was able to solve this problem using the following regular expression:\ndecmark_reg = re.compile('(?<=\\d)\\.(?=\\d)')","Q_Score":1,"Tags":"regex,python-3.x,nlp","A_Id":58723525,"CreationDate":"2019-09-22T09:09:00.000","Title":"Subsitute decimal point in floating point number with comma Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting this warning email from PythonAnywhere on every single request to my website. I am using spaCy and Django and have just upgraded my account. Everything seems to work fine, though. Except I am receiving warning emails, that is. I have only 2 GB RAM on my local machine and it can run my app along with a few other apps too without any issues. Then why is 3 GB RAM not enough on PythonAnywhere? (I also have 3 GB disc space on PythonAnywhere, of which only 27% is used up.)\nI have tried searching for the answers on their forum and on the internet in general but I have not got any clue about the issue.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":208,"Q_Id":58049025,"Users Score":2,"Answer":"If your initial requests on the PythonAnywhere webapp works fine (ie. your code successfully allocates say 2GB RAM and returns a result), and you see the results correctly, but you receive emails about processes exceeding the RAM limit, then perhaps you have processes that are left hanging around, not cleaned up, and they are accumulating until they slowly get killed? Can you correspond this with the # of kill messages you get vs the number of times you hit the webapp and get a result? My theory would be corroborated if there are significantly less kill messages vs the hits for that particular model endpoint.","Q_Score":0,"Tags":"python,django,spacy,pythonanywhere","A_Id":58102652,"CreationDate":"2019-09-22T12:02:00.000","Title":"PythonAnywhere Issue: Your processes have been killed because a process exceeded RAM Limit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"for my current requirement, I'm having a dataset of 10k+ faces from 100 different people from which I have trained a model for recognizing the face(s). The model was trained by getting the 128 vectors from the facenet_keras.h5 model and feeding those vector value to the Dense layer for classifying the faces.\nBut the issue I'm facing currently is\n\nif want to train one person face, I have to retrain the whole model once again.\n\nHow should I get on with this challenge? I have read about a concept called transfer learning but I have no clues about how to implement it. Please give your suggestion on this issue. What can be the possible solutions to it?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":675,"Q_Id":58049090,"Users Score":1,"Answer":"With transfer learning you would copy an existing pre-trained model and use it for a different, but similar, dataset from the original one. In your case this would be what you need to do if you want to train the model to recognize your specific 100 people.\nIf you already did this and you want to add another person to the database without having to retrain the complete model, then I would freeze all layers (set layer.trainable = False for all layers) except for the final fully-connected layer (or the final few layers). Then I would replace the last layer (which had 100 nodes) to a layer with 101 nodes. You could even copy the weights to the first 100 nodes and maybe freeze those too (I'm not sure if this is possible in Keras). In this case you would re-use all the trained convolutional layers etc. and teach the model to recognise this new face.","Q_Score":1,"Tags":"python-3.x,tensorflow,keras,deep-learning,face-recognition","A_Id":58049249,"CreationDate":"2019-09-22T12:12:00.000","Title":"How do i retrain the model without losing the earlier model data with new set of data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Consider two linear models:\nL1: y = 39.76x + 32.648628\nAnd\nL2: y = 43.2x + 19.8\nGiven the fact that both the models perform equally well on the test data set, which one would you prefer and why?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":58049729,"Users Score":0,"Answer":"I'd probably go with the second one, just because the numbers in the second one are rounded more, and if they still do equally well, the extra digits in the first one are unnecessary and just make it look worse.\n(As a side note, this question doesn't seem related to programming so you may want to post it in a different community.)","Q_Score":1,"Tags":"python,linear-regression","A_Id":58049979,"CreationDate":"2019-09-22T13:36:00.000","Title":"Linear models : Given the fact that both the models perform equally well on the test data set, which one would you prefer and why?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Python and Flask, served by Waitress, to host a POST API. I'm calling the API from a C# program that posts data and gets a string response. At least 95% of the time, it works fine, but sometimes the C# program reports an error: \n(500) Internal Server Error.\nThere is no further description of the error or why it occurs. The only clue is that it usually happens in clusters -- when the error occurs once, it likely occurs several times in a row. Without any intervention, it then goes back to running normally.\nSince the error is so rare, it is hard to troubleshoot. Any ideas as to how to debug or get more information? Is there error handling I can do from either the C# side or the Flask\/Waitress side?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2806,"Q_Id":58049827,"Users Score":0,"Answer":"Your flask application should be logging the exception when it occurs. Aside from combing through your logs (which should be stored somewhere centrally) you could consider something like Sentry.io, which is pretty easy to setup with Flask apps.","Q_Score":6,"Tags":"c#,python,flask,waitress","A_Id":58050151,"CreationDate":"2019-09-22T13:48:00.000","Title":"How to debug (500) Internal Server Error on Python Waitress server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Why type((1)) is int and not a tuple? Whereas type((1,)) gives tuple.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":44,"Q_Id":58051601,"Users Score":1,"Answer":"That's also an answer to the question why we should use commas while defining a tuple with one value. Because tuples are not like lists which is unique in a way that we define it (using squared brackets) we have to add the comma to the value. In the first one type((1)) inner paranthesis have no effect, so it's just a basic integer nothing else. Like when you define expressions in paranthesis to give them priority. Hope it helps :)","Q_Score":0,"Tags":"python,tuples","A_Id":58051653,"CreationDate":"2019-09-22T17:13:00.000","Title":"Python (int) and (int,)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a python script to grab every field in an mssql database and various metadata about each, then generating a series of data dictionaries in XLSX format.  \nI've almost finished, but I'm now trying to grab 10 unique values from each field as an example of the data each field contains (for dates I'm using max & min).  Currently I'm using select distinct top 10 X from table; for each field, but with a largish database, this is incredibly slow going.  \nIs there a quicker\/better alternative?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":58054332,"Users Score":0,"Answer":"It would seem that by select distinct top 10 * from table; and then parsing that data with Python I save an incredible amount of time.  I may not end up with 10 values per field, but it's good enough!","Q_Score":0,"Tags":"python,sql","A_Id":58054428,"CreationDate":"2019-09-23T00:14:00.000","Title":"Efficiently get a list of x unique values for every field in a database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I`m new to python. I have a csv file. I need to check whether the inputs are correct or not. The ode should scan through each rows. \nAll columns for a particular row should contain values of same type: Eg:\nAll columns of second row should contain only string, \nAll columns of third row should contain only numbers... etc\nI tried the following approach, (it may seem blunder):\nI have only 15 rows, but no idea on number of columns(Its user choice)\ndf.iloc[1].str.isalpha()\nThis checks  for string. I don`t know how to check ??","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":59,"Q_Id":58056352,"Users Score":1,"Answer":"Simple approach that can be modified:\n\nOpen df using df = pandas.from_csv(<path_to_csv>)\nFor each column, use df['<column_name>'] = df['<column_name>'].astype(str) (str = string, int = integer, float = float64, ..etc).\n\nYou can check column types using df.dtypes","Q_Score":1,"Tags":"python,pandas","A_Id":58056413,"CreationDate":"2019-09-23T05:52:00.000","Title":"Check inputs in csv file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I have a pandas dataframe with a lot of variables including start\/end date of loans. \nI subtract these two in order to get their difference in days.\nThe result I get is of the type i.e. 349 days 00:00:00.\nHow can I keep only for example the number 349 from this column?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1164,"Q_Id":58059278,"Users Score":0,"Answer":"Check this format,\ndf['date'] = pd.to_timedelta(df['date'], errors='coerce').days\nalso, check .normalize() function in pandas.","Q_Score":1,"Tags":"python,pandas,dataframe,days","A_Id":58059345,"CreationDate":"2019-09-23T09:20:00.000","Title":"Remove \"days 00:00:00\"from dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cannot upgrade pip on my Mac from the Terminal. \nAccording to the documentation I have to type the command:\npip install -U pip\nI get the error message in the Terminal:\npip: command not found\nI have Mac OS 10.14.2, python 3.7.2 and pip 18.1.\nI want to upgrade to pip 19.2.3","AnswerCount":9,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":36951,"Q_Id":58060961,"Users Score":3,"Answer":"I have found an answer that worked for me:\nsudo pip3 install -U pip --ignore-installed pip\nThis installed pip version 19.2.3 correctly.\nIt was very hard to find the correct command on the internet...glad I can share it now.\nThanks.","Q_Score":5,"Tags":"python-3.x","A_Id":58065406,"CreationDate":"2019-09-23T11:00:00.000","Title":"how do I upgrade pip on Mac?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I cannot upgrade pip on my Mac from the Terminal. \nAccording to the documentation I have to type the command:\npip install -U pip\nI get the error message in the Terminal:\npip: command not found\nI have Mac OS 10.14.2, python 3.7.2 and pip 18.1.\nI want to upgrade to pip 19.2.3","AnswerCount":9,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":36951,"Q_Id":58060961,"Users Score":0,"Answer":"I came on here to figure out the same thing but none of this things seemed to work. so I went back and looked how they were telling me to upgrade it but I still did not get it. So I just started trying things and next thing you know I seen the downloading lines and it told me that my pip was upgraded. what I used was (pip3 install -- upgrade pip). I hope this can help anyone else in need.","Q_Score":5,"Tags":"python-3.x","A_Id":63387903,"CreationDate":"2019-09-23T11:00:00.000","Title":"how do I upgrade pip on Mac?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I cannot upgrade pip on my Mac from the Terminal. \nAccording to the documentation I have to type the command:\npip install -U pip\nI get the error message in the Terminal:\npip: command not found\nI have Mac OS 10.14.2, python 3.7.2 and pip 18.1.\nI want to upgrade to pip 19.2.3","AnswerCount":9,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":36951,"Q_Id":58060961,"Users Score":10,"Answer":"pip3 install --upgrade pip\n\nthis works for me!","Q_Score":5,"Tags":"python-3.x","A_Id":61442850,"CreationDate":"2019-09-23T11:00:00.000","Title":"how do I upgrade pip on Mac?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am running a python application which is running inside a docker container using Beanstalk in a private subnet, and I want to get the Private\/Local IP of the EC2 instance. Is it possible to get the Local IP address without using curl http:\/\/169.254.169.254\/latest\/meta-data\/local-ipv4 inside a docker container.\nAlthough I tried docker run --net=host <image_name> but still its not accessible.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":404,"Q_Id":58064056,"Users Score":0,"Answer":"You can get the local ip of a Linux instance with this command:\nhostname -I | awk '{print $1}'\nFor EB, use .ebexentions and write a bash script in a script_name.config to run: export HOST_IP=$(hostname -I | awk '{print $1}')","Q_Score":1,"Tags":"python-3.x,amazon-web-services,docker,amazon-ec2,amazon-elastic-beanstalk","A_Id":58065828,"CreationDate":"2019-09-23T13:54:00.000","Title":"How to get EC2 instance private IP in a private subnet?","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":"In Hadoop streaming - where the Mapper and Reducer are written in python - Does it help to make the Mapper process use the multiprocessing module? Or does the scheduler prevent the Mapper scripts from running on multiple threads on the compute nodes?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":285,"Q_Id":58066277,"Users Score":1,"Answer":"In classic MapReduce there is nothing that stops you from having multiple threads in a mapper or a reducer. The same is true for Hadoop Streaming, you can very well have multiple threads per mapper or reducer. This situation can happen if you have a CPU heavy job and want to speed it up. \nIf you're doing Hadoop Streaming with Python, you can use the multiprocessing module to speed up your mapper phase. \nNote that depending on the way your Hadoop cluster is configured (how many JVM mapper\/reducer per nodes) you may have to adjust the maximum number of processes you can use.","Q_Score":1,"Tags":"python-3.x,hadoop-streaming","A_Id":58190025,"CreationDate":"2019-09-23T16:07:00.000","Title":"Does python multiprocessing work with Hadoop streaming?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to onehot-encode some positions with TensorFlow.\nHowever, the length of the input sequences (and therefore the depth-argument in tf.one_hot) is None as I work with variable sized inputs.\nThis throws the following error: \n\n\"ValueError: Tried to convert 'depth' to a tensor and failed. Error: None values not supported.\".\n\nIs there a workaround for this?\nI have already tried to set the depth to the correct sequence length before each individual call (through a variable that has some arbitrary initialization value) for a given sequence but as the computational graph is already built, the changes do not come into effect and the depth is stuck at the initialization value.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":129,"Q_Id":58067427,"Users Score":0,"Answer":"This is how I solved the issue: The problem was that I was using someone else's code and the depth argument in tf.one_hot was derived from someTensor.get_shape().as_list()[1]. The problem here is that if the shape of someTensor is unknown, the argument is a Python-None which is not a valid argument for tf.one_hot. However, using tf.shape(someTensor)[1] solved that problem as it returns a Dimension with unknown shape instead of a Python-None. A Dimension with unknown shape is a valid depth-argument for tf.one_hot.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,one-hot-encoding","A_Id":58080853,"CreationDate":"2019-09-23T17:28:00.000","Title":"Tensorflow: OneHot-encoding with variable sized length","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to Automate Web App testing using Selenium and PyTest and I am new to both. So here is the structure of my project folder: \nParent Folder\nLocator.py\nSection 1(Folder) -> test_sectionone.py\nLocator.py contains all my Xpaths. Now when I try to import Locator.py by typing import Locator and then fetching the xpath using Locator.xpathElement1 in the test_sectionone.py, pytest fails with the following error: \nHint: make sure your test modules\/packages have valid Python names.\nTraceback:\ntest_mailboxProvisioning.py:5: in \n    import Locator\nE   ModuleNotFoundError: No module named 'Locator'\nIs there something I am missing? Is there a naming convention because of which I am facing the issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":58069050,"Users Score":0,"Answer":"Convert Parentfolder into a python package by including an empty file __init__.py\nConvert sub folder \"Section1\" into a python package by including an empty file __init__.py\nIn test_sectionone.py now either import ParentFolder.Locator (using absolute path) or from ..Locator import function using relative path.\nBoth should work.","Q_Score":0,"Tags":"python,selenium,pytest","A_Id":58069402,"CreationDate":"2019-09-23T19:32:00.000","Title":"Unable to import .py file in Pytest","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 understand the concept of keywords as reserved words in Python that should not be used as identifiers. What is confusing to me is that other than that commonality, keywords appear to me to be used differently. For example the import and del statements seem to work as functions that only take one parameter, whereas other keywords such as if and while are used to make compound statements. My question is if certain keywords (e.g. import) are used in the same manner as a function, then why is the syntax different (i.e. no parenthesis is used). print being used as a function as opposed to it's previous use as a keyword is much more intuitive to me. This can be confusing to a new learner whose first statement is usually import, the syntax of which is seemingly analogous to an irregular verb in human languages.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":359,"Q_Id":58069161,"Users Score":2,"Answer":"You're thinking too hard. There are functions which can import, but the statement import simplifies the implementation (for us users). Consider, if it were (only) a function, you'd have to quote the string.. import('foo.py'). Python2 print didn't really save much in the way of keystrokes.\nIf you want function functionality, it is available, consider the first paragraph in Python Language Reference.\n\n5. The import system\nPython code in one module gains access to the code in another module by the process of importing it. The import statement is the most common way of invoking the import machinery, but it is not the only way. Functions such as importlib.import_module() and built-in __import__() can also be used to invoke the import machinery.","Q_Score":3,"Tags":"python,import,keyword","A_Id":58069366,"CreationDate":"2019-09-23T19:40:00.000","Title":"Why does the Python import statement not use parentheses?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pre-trained word2vec bin file by using skipgram. The file is pretty big (vector dimension of 200 ), over 2GB. I am thinking some methods to make the file size smaller. This bin file contains vectors for punctuation, some stop words. So, I want to know what are the options to decrease the file size for this word2vec. Is it safe to delete those punctuation and stop words rows and what would be the most effective way ?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2014,"Q_Id":58069421,"Users Score":1,"Answer":"The size of a full Word2Vec model is chiefly determined by the chosen vector-size, and the size of the vocabulary. \nSo your main options for big savings is to train smaller vectors, or a smaller vocabulary. \nDiscarding a few hundred stop-words or punctuation-tokens won't make a noticeable dent in the model size. \nDiscarding many of the least-frequent words can make a big difference in model size \u2013 and often those less-frequent words aren't as important as you might think. (While there are a lot of them in total, each only appears rarely. And because they're rare in the training data, they often tend not to have very good vectors, anyway \u2013 based on few examples, and their training influence is swamped by the influence of more-frequent words.)\nThe easiest way to limit the vocabulary size is to use a higher min_count value during training (ignoring all words with fewer occurrences), or a  fixed max_final_vocab cap (which will keep only that many of the most-frequent words). \nNote also that if you've been saving\/reloading full Word2Vec models (via the gensim-internal .save()\/.load() methods), you're retaining model internal weights that are only needed for continued training, and will nearly double the model-size on disk or re-load. \nYou may want to save just the raw word-vectors in the .wv property instead (via either the gensim-internal .save() or the .save_word2vec_format() methods).","Q_Score":1,"Tags":"python,gensim,word2vec","A_Id":58072232,"CreationDate":"2019-09-23T20:00:00.000","Title":"gensim word2vec extremely big and what are the methods to make file size smaller?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am unsure of what code you guys would want me to upload, but please ask away if you need any and I will upload it!\nWhen a user uploads media\/files to my website, the root user becomes the owner of the file. This prevents the user from being able to open and view the media they uploaded, because it is not owned by the proper user on my server.\nI have a user that runs my Django application instead of the root user. The person who uploaded the media can access it once I manually go into the server and change the ownership to that media file that was uploaded, to the server user which runs my Django application.\nHow can I get this to, by default, upload the file to the ownership of the server user running Django??\nI was thinking of setting up a cron job to run every-so-often (this would be terrible for scaling) so I can change the ownership of the media without having to physically going in the server and do it myself.\nEdit\nI want to clarify. \nA user is someone who has created a profile on my website. They go on their profile and upload a file or an image to my server and it is stored under the media_root using a form submission. \nMy server is running Django, and django_user is the owner of Django and it\u2019s files. However, when a user uploads a file\/photo using the form submission, it is placed under the ownership of my servers root user. \nI need the ownership to be under django_user so that site users can see their uploads without me having to manually change the file owner to django_user. Right now, they are getting a permission error because root is not who is serving up Django. \nNOTE: django_user is the one running Django. This didn't seem clear.\nTemporary Solution:\nA temporary solution comes in the form of ErikR's answer. It is not what I was looking for, but it does help me out a little. His solution allows users to view their photo\/file they've uploaded without having to wait for me to change the owner\/permissions.\nHowever, it does still cause files to be uploaded as root. But it is a temporary workaround for the permissions issue, NOT the owner issue.\nHis answer (place in base settings): FILE_UPLOAD_PERMISSIONS = 0o644","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":58070466,"Users Score":0,"Answer":"My server is running Django, and django_user is the owner of Django and it\u2019s files. However, when a user uploads a file\/photo using the form submission, it is placed under the ownership of my servers root user. \n\nIf Django is really running as django_user, then it cannot create files owned by root, and it cannot change the ownership or permissions of files owned by root.\nTherefore, we must assume that your \"form submission\" must be implemented by something other than Django.  Possibly it is the host webserver ... though that shouldn't be running as root either.\nThere are two ways you could address this:\n\nYou could change the code that is implementing the form (as root) to change the ownership of files after they are uploaded.  \nYou change your system's architecture so that the form us run as the django_user user.\n\n\nIf the form is actually implemented in Django, then that is evidence that Django is not running as django_user.","Q_Score":0,"Tags":"python,django,unix","A_Id":58082741,"CreationDate":"2019-09-23T21:32:00.000","Title":"Django: When a user uploads media to my site, it is owned by the server's root user. How do I change this?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have two data from.\ndf1 with columns: id,x1,x2,x3,x4,....xn\ndf2 with columns: id,y.\ndf3 =pd.concat([df1,df2],axis=1)\nwhen I use pandas concat to combine them, it became\nid,y,id,x1,x2,x3...xn.\nthere are two id here.How can I get rid of one.\nI have tried :\ndf3=pd.concat([df1,df2],axis=1).drop_duplicates().reset_index(drop=True).\nbut not work.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1418,"Q_Id":58070840,"Users Score":0,"Answer":"drop_duplicates() only removes rows that are completely identical.\nwhat you're looking for is pd.merge().\npd.merge(df1, df2, on='id)","Q_Score":1,"Tags":"python,pandas,concat","A_Id":58070875,"CreationDate":"2019-09-23T22:18:00.000","Title":"how to remove duplicates when using pandas concat to combine two dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to achieve all these together:\nA. New users can sign up with or without using facebook.\nB. They will all be presented with a form to fill out additional user information as part of the sign up flow.\nC. New accounts will by default be inactive. Admins will need the additional user information when they manually activate (or delete) accounts.\n\nI achieved A using django-allauth social accounts.\nI achieved C by adding a listener to django.db.models.signals.pre_save and setting user.active = False\nI partly achieved B by defining a custom ACCOUNT_SIGNUP_FORM_CLASS in settings.py. However this only works for local \"non-social\" accounts as far as I can tell, since social logins seem to skip this form.\nMy problem is that when someone signs up with an allauth social account they don't have the chance to provide additional information since their account will be created without first displaying my custom sign up form.\nFurthermore since all new accounts are automatically saved as inactive and that additional information is needed in order for admins to activate them I can't simply add that form to a \"first time login flow\" (note: it's not possible to log in to inactive accounts).\nOne way to solve this I guess would be to not automatically save accounts as inactive but instead work with permissions but I'd rather not rewrite all my views etc. if I can avoid it.\nAny input would be appreciated! Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":113,"Q_Id":58071733,"Users Score":2,"Answer":"Add this option to your settings.py file:\nSOCIALACCOUNT_AUTO_SIGNUP = False","Q_Score":1,"Tags":"python,django,facebook,django-allauth","A_Id":58260342,"CreationDate":"2019-09-24T00:50:00.000","Title":"How to display custom form in django-allauth's social account sign up flow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If we try to install a package via pip, it uses the cached packages that we have downloaded before. Does pipenv do the same or does it download the packages every time we do pipenv install etc. ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":213,"Q_Id":58072870,"Users Score":0,"Answer":"It just runs pip, so it uses the pip cache.","Q_Score":0,"Tags":"python,pip,pipenv","A_Id":58072997,"CreationDate":"2019-09-24T03:54:00.000","Title":"Does pipenv download packages everytime or does it use cached packages like pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python flawfinder module is working in bash but not working in Windows command commandline. Here are the steps I followed:\n\nPython installation path - C\/Users\/xyz\/AppData\/Local\/Programs\/Python\/Python37-32\/python\npip install flawfinder\nWhen I type flawfinder in commandline, it gives below error:\n\nflawfinder is not recognized as an internal or external command,\n  operable program or batch file.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":533,"Q_Id":58073861,"Users Score":1,"Answer":"Since version 2.0.16 released 2021-05-31 flawfinder also works on windows as expected.","Q_Score":1,"Tags":"python,python-3.x,flawfinder","A_Id":70070491,"CreationDate":"2019-09-24T05:55:00.000","Title":"Python: Why flawfinder module is not working in cmd windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am new to Machine Learning\nI have a dataset which has highly unbalanced classes(dominated by negative class) and contains more than 2K numeric features and the target is [0,1]. I have trained a logistics regression though I am getting an accuracy of 89% but from confusion matrix, it was found the model True positive is very low. Below are the scores of my model\nAccuracy Score : 0.8965989500114129\nPrecision Score : 0.3333333333333333\nRecall Score : 0.029545454545454545\nF1 Score : 0.05427974947807933\nHow I can increase my True Positives? Should I be using a different classification model?\nI have tried the PCA and represented my data in 2 components, it increased the model accuracy up to 90%(approx) however True Positives was decreased again","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":4004,"Q_Id":58074203,"Users Score":0,"Answer":"What is the size of your dataset?How many rows are we talking here? \nYour dataset is not balanced and so its kind of normal for a simple classification algorithm to predict the 'majority-class' most of the times and give you an accuracy of 90%. Can you collect more data that will have more positive examples in it.\nOr, just try oversampling\/ under-sampling. see if that helps. \nYou can also use penalized version of the algorithm to impose penalty, whenever a wrong class is predicted. That may help.","Q_Score":1,"Tags":"python,machine-learning,statistics,data-science","A_Id":58075290,"CreationDate":"2019-09-24T06:23:00.000","Title":"How to increase true positive in your classification Machine Learning model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Machine Learning\nI have a dataset which has highly unbalanced classes(dominated by negative class) and contains more than 2K numeric features and the target is [0,1]. I have trained a logistics regression though I am getting an accuracy of 89% but from confusion matrix, it was found the model True positive is very low. Below are the scores of my model\nAccuracy Score : 0.8965989500114129\nPrecision Score : 0.3333333333333333\nRecall Score : 0.029545454545454545\nF1 Score : 0.05427974947807933\nHow I can increase my True Positives? Should I be using a different classification model?\nI have tried the PCA and represented my data in 2 components, it increased the model accuracy up to 90%(approx) however True Positives was decreased again","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":4004,"Q_Id":58074203,"Users Score":0,"Answer":"You can try many different solutions.\nIf you have quite a lot data points. For instance you have 2k 1s and 20k 0s. You can try just dump those extra 0s only keep 2k 0s. Then train it. And also you can try to use different set of 2k 0s and same set of 2k 1s. To train multiple models. And make decision based on multiple models.\nYou also can try adding weights at the output layer. For instance, you have 10 times 0s than 1s. Try to multiply 10 at the 1s prediction value. \nProbably you also can try to increase dropout? \nAnd so on.","Q_Score":1,"Tags":"python,machine-learning,statistics,data-science","A_Id":58082997,"CreationDate":"2019-09-24T06:23:00.000","Title":"How to increase true positive in your classification Machine Learning model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Machine Learning\nI have a dataset which has highly unbalanced classes(dominated by negative class) and contains more than 2K numeric features and the target is [0,1]. I have trained a logistics regression though I am getting an accuracy of 89% but from confusion matrix, it was found the model True positive is very low. Below are the scores of my model\nAccuracy Score : 0.8965989500114129\nPrecision Score : 0.3333333333333333\nRecall Score : 0.029545454545454545\nF1 Score : 0.05427974947807933\nHow I can increase my True Positives? Should I be using a different classification model?\nI have tried the PCA and represented my data in 2 components, it increased the model accuracy up to 90%(approx) however True Positives was decreased again","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":4004,"Q_Id":58074203,"Users Score":0,"Answer":"I'm assuming that your purpose is to obtain a model with good classification accuracy on some test set, regardless of the form of that model. \nIn that case, if you have access to the computational resources, try Gradient-Boosted Trees. That's a ensemble classifier using multiple decision trees on subsets of your data, then a voting ensemble to make predictions. As far as I know, it can give good results with unbalanced class counts.\nSciKitLearn has the function sklearn.ensemble.GradientBoostingClassifier for this. I have not used that particular one, but I use the regression version often and it seems good. I'm pretty sure MATLAB has this as a package too, if you have access.\n2k features might be difficult for the SKL algorithm - I don't know I've never tried.","Q_Score":1,"Tags":"python,machine-learning,statistics,data-science","A_Id":58074603,"CreationDate":"2019-09-24T06:23:00.000","Title":"How to increase true positive in your classification Machine Learning model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Machine Learning\nI have a dataset which has highly unbalanced classes(dominated by negative class) and contains more than 2K numeric features and the target is [0,1]. I have trained a logistics regression though I am getting an accuracy of 89% but from confusion matrix, it was found the model True positive is very low. Below are the scores of my model\nAccuracy Score : 0.8965989500114129\nPrecision Score : 0.3333333333333333\nRecall Score : 0.029545454545454545\nF1 Score : 0.05427974947807933\nHow I can increase my True Positives? Should I be using a different classification model?\nI have tried the PCA and represented my data in 2 components, it increased the model accuracy up to 90%(approx) however True Positives was decreased again","AnswerCount":4,"Available Count":4,"Score":0.1973753202,"is_accepted":false,"ViewCount":4004,"Q_Id":58074203,"Users Score":4,"Answer":"There are several ways to do this :\n\nYou can change your model and test whether it performs better or not\nYou can Fix a different prediction threshold : here I guess you predict 0 if the output of your regression is <0.5, you could change the 0.5 into 0.25 for example. It would increase your True Positive rate, but of course, at the price of some more False Positives.\nYou can duplicate every positive example in your training set so that your classifier has the feeling that classes are actually balanced.\nYou could change the loss of the classifier in order to penalize more False Negatives (this is actually pretty close to duplicating your positive examples in the dataset)\n\nI'm sure many other tricks could apply, here is just my favorite short-list.","Q_Score":1,"Tags":"python,machine-learning,statistics,data-science","A_Id":58074754,"CreationDate":"2019-09-24T06:23:00.000","Title":"How to increase true positive in your classification Machine Learning model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a queue system that allows me to enqueue some commands to be executed from the command console. They are neural nets training commands so it will take long to complete them. The problem here is that it needs to be editable in execution time, so that I can enqueue more processes to be launched after the last one on the queue ends. That is needed due to the fact that it takes a lot of time to  train a Neural Network and I would like to be able to waste less time possible and be able to train more than 1 neural network at nighttime.\nI have tried some multiprocessing tutorials but none of them have helped me solving this problem.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":58075587,"Users Score":0,"Answer":"I have made up in my mind my solution and it is simpler than I thought.\n\nJust use files!.\n\nIf I create a csv with 1 column that is the command I want to execute, I can just make an script to add new commands or rather modify it myself. Then, before I start executing a new command I read the CSV with pandas library, extract the first row, execute that command, remove it when it ends and that's it!","Q_Score":0,"Tags":"python,list,multiprocessing,queue,execution-time","A_Id":58076571,"CreationDate":"2019-09-24T07:56:00.000","Title":"How do I create a queue system that can be modified in execution time while there are processes launched from this queue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem with argcomplete script after I create bundle with pyinstaller. I generate sh from my script, use pyinstaller, copy it to \/usr\/bin change script complete command. And this isn't working, if I do this with py file, this works fine, where I do mistake? Or maybe this isn't possible to get with that script autocomplete?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":58075926,"Users Score":0,"Answer":"I found solution on myself, if someone will looking for that.\nFor global argcomplete it's simply just paste your bash script output from argcomplete to \/etc\/bash_completion.d\/<Your_sh_autocomplete_name>\nFor local (user usage) argcomplete it requires two steps. Add file into ~\/.bash_completion.d\/<Your_sh_autocomplete_name> and add source: source ~\/.bash_completion.d\/<Your_sh_autocomplete_name>. If it should autocomplete any time whenever you using bash shell, then command with source you can add to ~\/.bashrc file: echo \"source ~\/.bash_completion.d\/<Your_sh_autocomplete_name>\" >> ~\/.bashrc.\nAnd that's all, i missed for secound step when i want to do it local. So it isn't argcomplete or pyinstaller problem :)","Q_Score":0,"Tags":"python,bash,autocomplete,pyinstaller","A_Id":58118988,"CreationDate":"2019-09-24T08:17:00.000","Title":"python argcomplete and pyinstaller","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently running regressions with Panel data, and was wondering which Panel Regression model is the best. I ran the PooledOLS and Fixed Effect Model using the Panel OLS (with entity effect and time effect being true).\nI am trying to understand what one of the outputs of the model mean, more specifically, the F-Test for Poolability. On conducting my research I found some vague answers, nothing really concrete. So, anybody from here can help me out?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":399,"Q_Id":58077033,"Users Score":2,"Answer":"The Poolability F-test tests how well the indexes you have on the panel pool the data. As a rule of thumb, you should have at least 3 observations per panel group. The F-test, similar to the two other F-tests in PanelOLS tests against the null that the pooling effect is not significant.","Q_Score":1,"Tags":"python,panel-data,linearmodels","A_Id":71139660,"CreationDate":"2019-09-24T09:21:00.000","Title":"What is F-Test for Poolability in the Fixed Effect Model?","Data Science and Machine Learning":0,"Database and SQL":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 numpy structured arrays an alternative to Python dict?\nI would like to save memory and I cannot affort much of a performance decline.\nIn my case, the keys are str and the values are int.\nCan you give a quick conversion line in case they actually are an alternative?\nI also don't mind if you can suggest a different alternative.\nI need to save memory, because some dictionaries get larger than 50Gb in memory and I need to open multiple at a time with 'only' 192 GB RAM available.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1173,"Q_Id":58077373,"Users Score":1,"Answer":"numpy array use contiguous block of memory and can store only one type of object like int, float, string or other object. Where each item are allocated fixed bytes in memory. \nNumpy also provide set of functions for operation like traversing array, arithmetic operation, some string operation on those stored items which are implemented using c. As these operation doesn't have overhead of python they are normally more efficient in terms of both memory and processing power\nAs you need key value pair you can also store that in numpy array similar to c-struct but it won't have features like dict like looking of item, checking if key existing filtering etc. you have do do those your self using array functionality\nbetter option for you may be pandas series, which also use numpy array to store its data for provides you lots of functionality on top of it","Q_Score":1,"Tags":"python,numpy,dictionary,time-complexity,structured-array","A_Id":58078010,"CreationDate":"2019-09-24T09:39:00.000","Title":"Use numpy structured array instead of dict to save space and keep speed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a binary classification text data in which there are 10 text features. \nI use various techniques like Bag of words, TFIDF etc. to convert them to numerical.\nI use hstack() to stack all those features together again after processing them.\nAfter converting them to numerical feature, each feature now has large number of columns hence after conversion, my dataset has around 3000 columns.\nMy question is when I fit this dataset into decision tree classifier (sklearn), how does the classifier recognizes the columns which belong to  a particular feature? \nFor example first 51 column out of 3000 belong to US_states Bag of words.\nNow, how will the DT recognize it?\nPS: Data before processing is in pandas Dataframe.\nAfter processing, it is a stacked numpy array being input in the classifier.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":145,"Q_Id":58079493,"Users Score":0,"Answer":"The Decision Tree won't recognize from which features the attributes are coming.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,decision-tree,text-processing","A_Id":58079908,"CreationDate":"2019-09-24T11:39:00.000","Title":"How does decision tree recognize the features from a given text dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a small doubt. Is there any way to use a pfx or p12 container with gunicorn?\nI'm developing a python app that contains 2 api endpoints which are served using gunicorn and falcon. I want to support ssl but using pfx to set the keys and CA. Is there any way to do this?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":208,"Q_Id":58081164,"Users Score":0,"Answer":"Gunicorn needs a cert file and a key file. You can extract these from the pfx file. Make sure your key file is unencrypted else , you might have to enter the password while deployment","Q_Score":0,"Tags":"python,ssl,gunicorn","A_Id":60513632,"CreationDate":"2019-09-24T13:14:00.000","Title":"Usage of pfx file in gunicorn","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Basically, I'm working on a robot arm that will play checkers.\nThere is a camera attached above the board supplying pictures (or even videomaterial but I guess that is just a series of images and since checkers is not really a fast paced game I can just take a picture every few seconds and go from there)\nI need to find a way to translate the visual board into a e.g a 2d array to feed into the A.I to compute the robots moves.\nI have a line detection working which draws lines on along the edges of the squares (and also returns edges in canny as a prior step). Moreover I detect green and red (the squares of my board are green and red) and return these both as a mask each. \nI also have a sphere detection in place to detect the position of the pieces and some black and white color detection returning a mask each with the black or white detected areas.\nMy question is how I can now combine these things I have and as a result get some type of array out of which I can deduct information over in which squares my pieces are ? \nLike how would i build the 2d array (or connect any 8x8) array to the image of the board with the lines and\/or the masks of the red\/green tiles ? I guess I have to do some type of calibration ?\nAnd secondly is there a way to somehow overlay the masks so that I then know which pieces are in which squares ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":424,"Q_Id":58087263,"Users Score":0,"Answer":"Based on either the edge detector or the red\/green square detector, calculate the center coordinates of each square on the game board.  For example, average the x-coordinate of the left and right edge of a square to get the x-coordinate of the square's center.  Similarly, average the y-coordinate of the top and bottom edge to get the y-coordinate of the center.  \nIt might also be possible to find the top, left, bottom and right edge of the board and then interpolate to find the centers of all the squares.  The sides of each square are probably more than a hundred pixels in length, so the calculations don't need to be that accurate.\nTo determine where the pieces are, iterate of a list of the center coordinates and look at the color of the pixel.  If it is red or green, the square is empty.  If it is black or white, the square has a corresponding piece in it.  Use the information to fill an array with the information for the AI.\nIf the images are noisy, it might be necessary to average several pixels near the center or to average the  center pixel over several frames.\nIt would work best if the camera is above the center of the board.  If it is off to the side, the edges wouldn't be parallel\/orthogonal in the picture, which might complicate the math for finding the centers.","Q_Score":0,"Tags":"python,opencv,computer-vision","A_Id":58088639,"CreationDate":"2019-09-24T19:49:00.000","Title":"Create array from image of chessboard","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Basically, I'm working on a robot arm that will play checkers.\nThere is a camera attached above the board supplying pictures (or even videomaterial but I guess that is just a series of images and since checkers is not really a fast paced game I can just take a picture every few seconds and go from there)\nI need to find a way to translate the visual board into a e.g a 2d array to feed into the A.I to compute the robots moves.\nI have a line detection working which draws lines on along the edges of the squares (and also returns edges in canny as a prior step). Moreover I detect green and red (the squares of my board are green and red) and return these both as a mask each. \nI also have a sphere detection in place to detect the position of the pieces and some black and white color detection returning a mask each with the black or white detected areas.\nMy question is how I can now combine these things I have and as a result get some type of array out of which I can deduct information over in which squares my pieces are ? \nLike how would i build the 2d array (or connect any 8x8) array to the image of the board with the lines and\/or the masks of the red\/green tiles ? I guess I have to do some type of calibration ?\nAnd secondly is there a way to somehow overlay the masks so that I then know which pieces are in which squares ?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":424,"Q_Id":58087263,"Users Score":2,"Answer":"Well, first of all remember that chess always starts with the same pieces on the same positions e.g. black knight starts at 8-B which can be [1][7] in your 2D array. If I were you I would start with a 2D array with the begin positions of all the chess pieces. \nAs to knowing which pieces are where: you do not need to recognize the pieces themselves. What I would do if I were you is detect the empty spots on the chessboard which is actually quite easy in comparison to really recognizing the different chess pieces. \nOnce your detection system detects that one of the previously empty spots is now no longer empty you know that a chess piece was moved there. Since you can also detect a new open spot(the spot where the chess piece came from) you also know the exact chess piece which was moved. If you keep track of this list during the whole game you can always know which pieces are moved and which pieces are where.\nEdit:\nAs noted in the comments my answer was based on chess instead of checkers. The idea is however still the same but instead of chess pieces you can now put men and kings in the 2D array.","Q_Score":0,"Tags":"python,opencv,computer-vision","A_Id":58087392,"CreationDate":"2019-09-24T19:49:00.000","Title":"Create array from image of chessboard","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to execute simple python script through command activity stage, but I am getting error as below:\nsequence1..JobControl (@Execute_Command_4): Executed: python \/home\/mobaxterm\/pyth.py\nReply=1\nOutput from command ====>\n'python' is not recognized as an internal or external command,\noperable program or batch file.\nNote : Version is Datastage 11.3 ( causing problem )\nSuggest your views. Thank you very much for your help.","AnswerCount":1,"Available Count":1,"Score":-0.537049567,"is_accepted":false,"ViewCount":1547,"Q_Id":58088261,"Users Score":-3,"Answer":"you can use a OS script to call your python script","Q_Score":0,"Tags":"python,datastage","A_Id":63755764,"CreationDate":"2019-09-24T21:17:00.000","Title":"Can we write python scripts through datastage sequence stage like execute command activity in 11.3 version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am quite new to Python. I am trying my hands on threading module. I came across Event objects.\nEvent objects has\nwait\nset\nclear\nfunctions. I understand what wait, set and clear are doing. But I do not quite understand why is there a separate clear method. Could that not be included in set method implementation?\n Most of the code I have seen till now has set method followed by a clear method. So that the subsequent wait method calls wait.\n I come from Java world and I couldn't help but to compare this with wait and notify method calls. There is no equivalent method call in Java for clear.  \nIs there any use case where one would use set but not clear method?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":2508,"Q_Id":58088512,"Users Score":4,"Answer":"Is there any use case where one would use set but not clear method?\n\nYes, if you want to block threads until a resource is available, this is one way to do it without polling. This resource could be a server, driver, or sensor that is not ready when starting up.\nAnother case to think about is how to pause threads when they aren't needed. Let's use a battery operated security camera as an example. The camera is activated by a motion sensor. The video and audio are expensive in terms of battery consumption. The motion sensor sets the event until a timer expires and no new motion has been detected. Once that expires, the event is cleared. This tells the video and audio threads to stop recording.\n\nI come from Java world and I couldn't help but to compare this with\n  wait and notify method calls.\n\nThe java wait, notify, and notifyAll methods match the behavior of python's Threading Condition. When a notify or notifyAll signals threads, one waiting thread gains control of a lock at a time. The other waiting threads must wait until that thread releases that lock before it can run.","Q_Score":4,"Tags":"python,python-3.x,python-multithreading","A_Id":60403663,"CreationDate":"2019-09-24T21:43:00.000","Title":"python threading Event : why do we need clear()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to make a classifier for uncertain data (e.g ranged data) using python. in certain dataset, the list is a 2D array or array of record (contains float numbers for data and a string for labels), where in uncertain dataset the list is a 3D array (contains range of float numbers for data and a string for labels). i managed to manipulate a certain dataset to be uncertain using uniform probability distribution. A research paper says that i have to use supremum distance metric. how do i implement this metric in python? note that in uncertain dataset, both test set and training set is uncertain","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":119,"Q_Id":58089636,"Users Score":0,"Answer":"I found out using scipy spatial distance and tweaking for-loops in standard knn helps a lot","Q_Score":0,"Tags":"python,knn","A_Id":58090124,"CreationDate":"2019-09-25T00:25:00.000","Title":"Supremum Metric in Python for Knn with Uncertain Data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used OpenCV's camera calibration function for calibrating my camera. I captured around 50 images with different angles and pattern near image borders. \nCx and Cy value in intrinsic matrix is around 300 px off. Is it alright? My average reprojection error is around 0.08 though.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":476,"Q_Id":58091445,"Users Score":0,"Answer":"Cx and Cy are the coordinates (in pixels) of the principal point in your image. Usually a good approximation is (image_width\/2, image_height\/2).\nAn average reprojection error of 0.08 pixel seems quite good.","Q_Score":0,"Tags":"python-3.x,opencv,camera,camera-calibration","A_Id":58096338,"CreationDate":"2019-09-25T05:01:00.000","Title":"OpenCV camera calibration - Intrinsic matrix values are off","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have a string that I want to use in byte form encoded as UTF-8, do I need to encode the variable as a byte variable? Or, since Python is by default encoded as UTF-8, will it just treat the string as UTF-8 byte form in certain contexts without explicit encoding? \nFor example, I'm working on a project where I have an array of dictionaries that map strings to strings. If I write this array to a file with json.dump and then read it with json.load, the strings are recovered just fine, and I get no error, despite never encoding. This indicates to me that if you're just using UTF-8, you don't actually need to convert to byte form. Am I wrong? If I'm right, is this bad practice nonetheless? Would my example be any different if I were just writing strings without the JSON?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":504,"Q_Id":58091494,"Users Score":1,"Answer":"Python has multiple defaults regarding encoding.\nIn Python 3, the situation is as follows:\n\nThe source file encoding is UTF-8 by default. You can override this with a comment in one of the first two lines of the module (# coding: latin-1) if you really have to. It only affects string literals (and variable names).\nThe encoding parameter of str.encode() and bytes.decode() is UTF-8 too.\nBut when you open a file with open(), then the default for encoding depends on the circumstances (OS, env variables, Python version, build). You can check its value with locale.getpreferredencoding(). This default is also used when you read from sys.stdin or use print().\n\nSo I'd say it's okay to rely on the defaults for the first two cases (it's officially recommended for the first one).\nBut the third one is tricky: The IO default is UTF-8 on many systems, so you might think that with open(path) as f: will always use UTF-8, because it did so during development, but then you port the script to a different server and suddenly it raises UnicodeErrors or produces gibberish.\nIt's often not necessary to deal with encoded strings (ie. bytes objects) for processing text.\nRather, you make sure to have it decoded when reading and encoded when writing\/sending the text.\nThis is done automatically for streams created with open() (unless you specify binary mode 'rb'\/'wb').\nIf you think input\/output has to be UTF-8, then you should explicitly specify encoding='utf8' when calling open().","Q_Score":0,"Tags":"python,unicode,utf-8,byte,file-writing","A_Id":58093562,"CreationDate":"2019-09-25T05:05:00.000","Title":"If I want to use UTF-8 encoding, the default for python, do I have to encode my string variables to byte variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing some testing of a text UI element from a Qt application. It has a special character in it. When I try to get the text with Squish the received value type is Object. The final goal is to do some operations on it like printing it out or comparing it with another string. It's also completely fine to rid of the special character and only look at the remaining value.\nIn an effort to find out what I can do with this value, I've tried the following:\n\nvalue.split('')\nSyntaxError: Ambiguous overload 'split(str)'. Candidates:\nQString::split(const QString & sep)\nQString::split(QChar sep)\nstr(value)\nUnicodeEncodeError: 'ascii' codec can't encode character u'\\xb0' in position 2: ordinal not in range(128)\nvalue.encode('utf-8')\nAttributeError: Object does not have any properties\nunicode(value, error='replace')\nTypeError: coercing to Unicode: need string or buffer, Object found\n\nUsually in other case I can use str() fine since there is no special character. This is from Python 2, and upgrading is not really an option since it's quite a big project and takes time. Please give me some suggestion if this can be done in anyway. Thank you.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":218,"Q_Id":58092330,"Users Score":0,"Answer":"value.decode(\"ascii\", errors=\"ignore\").encode()","Q_Score":0,"Tags":"python,python-2.7,qt,squish","A_Id":58098537,"CreationDate":"2019-09-25T06:30:00.000","Title":"How to work 'Object' type variable with special character as string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing some testing of a text UI element from a Qt application. It has a special character in it. When I try to get the text with Squish the received value type is Object. The final goal is to do some operations on it like printing it out or comparing it with another string. It's also completely fine to rid of the special character and only look at the remaining value.\nIn an effort to find out what I can do with this value, I've tried the following:\n\nvalue.split('')\nSyntaxError: Ambiguous overload 'split(str)'. Candidates:\nQString::split(const QString & sep)\nQString::split(QChar sep)\nstr(value)\nUnicodeEncodeError: 'ascii' codec can't encode character u'\\xb0' in position 2: ordinal not in range(128)\nvalue.encode('utf-8')\nAttributeError: Object does not have any properties\nunicode(value, error='replace')\nTypeError: coercing to Unicode: need string or buffer, Object found\n\nUsually in other case I can use str() fine since there is no special character. This is from Python 2, and upgrading is not really an option since it's quite a big project and takes time. Please give me some suggestion if this can be done in anyway. Thank you.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":218,"Q_Id":58092330,"Users Score":0,"Answer":"So using dir() on that value I find out that QString function can be used. After some more experimenting I find QString &QString::replace(int position, int n, const QChar *unicode, int size) as the only method that I can use without running into error Ambiguous overload. Then just replacing the special character away and use the remaining value.","Q_Score":0,"Tags":"python,python-2.7,qt,squish","A_Id":58100528,"CreationDate":"2019-09-25T06:30:00.000","Title":"How to work 'Object' type variable with special character as string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently doing a report. All my figures are made on matplotlib. I would like to copy my figures to Word but not using screenshot or by right clicking and copy, because in this case the resolution will be reduced. I have nice charts of PDF as an output. Which is the best manner to place them on a Word document?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4154,"Q_Id":58098077,"Users Score":0,"Answer":"Best way I can come up with is this:  save the plot to a file and then add it to your word file. Instead of calling plt.show(), you can write plt.savefig(\"filename.png\"). This will save the plot as an image to your working directory.","Q_Score":0,"Tags":"python,image,pdf,report","A_Id":58098220,"CreationDate":"2019-09-25T12:11:00.000","Title":"Copy figure from python to word","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently doing a report. All my figures are made on matplotlib. I would like to copy my figures to Word but not using screenshot or by right clicking and copy, because in this case the resolution will be reduced. I have nice charts of PDF as an output. Which is the best manner to place them on a Word document?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4154,"Q_Id":58098077,"Users Score":0,"Answer":"You can use plt.savefig('foo.png') to save the image as a png, and then from there you can insert into word","Q_Score":0,"Tags":"python,image,pdf,report","A_Id":58098210,"CreationDate":"2019-09-25T12:11:00.000","Title":"Copy figure from python to word","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am experiencing performance issues in my pipeline in a DoFn that uses large side input of ~ 1GB. The side input is passed using the pvalue.AsList(), which forces materialization of the side input.\nThe execution graph of the pipeline shows that the particular step spends most of the time for reading the side input. The total amount of data read exceeds the size of the side input by far. Consequently, I conclude that the side input does not fit into memory \/ cache of the workers even though their RAM is sufficient (using n1-highmem4 workers with 26 GB RAM).\nHow do I know how big this cache actually is? Is there a way to control its size using Beam Python SDK 2.15.0 (like there was the pipeline option --workerCacheMb=200 for Java 1.x SDK)?\nThere is no easy way of shrinking my side input more than 10%.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":305,"Q_Id":58099163,"Users Score":0,"Answer":"If you are using AsList, you are correct that the whole side input should be loaded into memory. It may be that your worker has enough memory available, but it just takes very long to read 1GB of data into the list. Also, the size of the data that is read depends on the encoding of it. If you can share more details about your algorithm, we can try to figure out how to write a pipeline that may run more efficiently.\n\nAnother option may be to have an external service to keep your side input - for instance, a Redis instance that you write to on one side, and red from on the other side.","Q_Score":1,"Tags":"python,google-cloud-dataflow","A_Id":58103855,"CreationDate":"2019-09-25T13:06:00.000","Title":"Dataflow Sideinputs - Worker Cache Size in SDK 2.x","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Imagine I have a fasttext model that had been trained thanks to the Wikipedia articles (like explained on the official website).\nWould it be possible to train it again with another corpus (scientific documents) that could add new \/ more pertinent links between words? especially for the scientific ones ?\nTo summarize, I would need the classic links that exist between all the English words coming from Wikipedia. But I would like to enhance this model with new documents about specific sectors. Is there a way to do that ? And if yes, is there a way to maybe 'ponderate' the trainings so relations coming from my custom documents would be 'more important'.\nMy final wish is to compute cosine similarity between documents that can be very scientific (that's why to have better results I thought about adding more scientific documents)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":254,"Q_Id":58099559,"Users Score":2,"Answer":"Adjusting more-generic models with your specific domain training data is often called \"fine-tuning\". \nThe gensim implementation of FastText allows an existing model to expand its known-vocabulary via what's seen in new training data (via build_vocab(..., update=True)) and then for further training cycles including that new vocabulary to occur (through train()). \nBut, doing this particular form of updating introduces murky issues of balance between older and newer training data, with no clear best practices. \nAs just one example, to the extent there are tokens\/ngrams in the original model that don't recur in the new data, new training is pulling those in the new data into new positions that are optimal for the new data... but potentially arbitrarily far from comparable compatibility with the older tokens\/ngrams.)\nFurther, it's likely some model modes (like negative-sampling versus hierarchical-softmax), and some mixes of data, have a better chance of net-benefiting from this approach than others \u2013 but you pretty much have to hammer out the tradeoffs yourself, without general rules to rely upon. \n(There may be better fine-tuning strategies for other kinds models; this is just speaking to the ability of the gensim FastText to update-vocabulary and repeat-train.)\nBut perhaps, your domain of interest is scientific texts. And maybe you also have a lot of representative texts \u2013 perhaps even, at training time, the complete universe of papers you'll want to compare. \nIn that case, are you sure you want to deal with the complexity of starting with a more-generic word-model? Why would you want to contaminate your analysis with any of the dominant word-senses in generic reference material, like Wikipedia, if in fact you already have sufficiently-varied and representative examples of your domain words in your domain contexts?\nSo I would recommend 1st trying to train your own model, from your own representative data. And only if you then fear you're missing important words\/senses, try mixing in Wikipedia-derived senses. (At that point, another way to mix in that influence would be to mix Wikipedia texts with your other corpus. And  you should also be ready to test whether that really helps or hurts \u2013 because it could be either.)\nAlso, to the extent your real goal is comparing full papers, you might want to look into other document-modeling strategies, including bag-of-words representations, the Doc2Vec ('Paragraph Vector') implementation in gensim, or others. Those approaches will not necessarily require per-word vectors as an input, but might still work well for quantifying text-to-text similarities.","Q_Score":2,"Tags":"python,artificial-intelligence,gensim,training-data,fasttext","A_Id":58106916,"CreationDate":"2019-09-25T13:28:00.000","Title":"Training a model from multiple corpus","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run pip to install some libraries for python 2.7, but in my windows shell, its identifying it with python 3.X that I have installed and installing the packages to the python libs folder, or some folder relative to python 3.x. How can I specify pip to install specified package to only 2.7 in the CLI instead of python 3, and vice-versa?\nPerhaps I should try to use virtual environment with python 3 running and run pip from there?\n\npip install pyvisa\n\nI expect this to be an issue because I have no unique environment variable to specify which version of python I want pip to use.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":58100202,"Users Score":0,"Answer":"Try py -2 -m pip install pyvisa for Python 2 and py -3 -m pip install pyvisa for Python 3. The py launcher that allows you to run stuff both in Python 2 and in Python 3 comes bundled with recent versions of both Python 2 and Python 3 for Windows, but it's optional. If you chose not to install py, you can instead use C:\\Python2\\python.exe -m pip install pyvisa, as an example -- substitute your own Python 2 path there.","Q_Score":0,"Tags":"python-3.x,python-2.7,pip","A_Id":58100947,"CreationDate":"2019-09-25T14:01:00.000","Title":"How to specify python version to use when leveraging pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have uninstalled Python and now I cant install it anymore (error 0x800705b4). Has anybody encountered this error ? I have tried different versions but nothing works.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":237,"Q_Id":58101490,"Users Score":0,"Answer":"Eventually what did the trick for me was to roll back the previous microsoft update (KB4512575)","Q_Score":0,"Tags":"python","A_Id":58118320,"CreationDate":"2019-09-25T15:06:00.000","Title":"How to install Python on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm having trouble sorting multiple listctrls in wxpython.  I can sort one but not another.  I assume it all circles around the ColumnSorterMixin requirement for a function called GetListCtrl.  That function can only return one listctrl otherwise and index error will occur as it will only sort the last returned listctrl.  Is there a way around this? Many thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17,"Q_Id":58102471,"Users Score":0,"Answer":"It sounds like you are using the ColumSorterMixin when creating the class that is a parent of the listctrls, like in the demo, and putting multiple listctrls on the parent. If you instead use it as one of the base classes when deriving a new ListCtrl class then GetListCtrl can just return self, and each listctrl will then have its own sorter.","Q_Score":0,"Tags":"python,wxpython,listctrl","A_Id":58139832,"CreationDate":"2019-09-25T16:04:00.000","Title":"wxpython sorting multiple listctrls","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an existing django project and need to create an instance of it in a new environment with new database. I have the database connection configured in the settings file. The schema does not exist. If I run the manage.py migrate command, does it also create the schema? It looks like it assumes the schema already exists because I am getting an error django.db.utils.OperationalError: (1049, \"Unknown database 'my_db'\"). Just wondering if I have to create the database first or if some django command is available to create it if it does not exists.\nI can create the schema manually via sql script if it's not doable via python django command.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":746,"Q_Id":58103427,"Users Score":1,"Answer":"As already pointed out in the comments to your question, the missing database is the problem, not the schema. You have to create the database first, which might involve setting the user permissions for the new database. After that, the manage.py migrate command will work just fine and create the schema for you.","Q_Score":1,"Tags":"python,mysql,django","A_Id":58107976,"CreationDate":"2019-09-25T17:07:00.000","Title":"Does django manage.py migrate command creates database\/schema if not exists?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Looking to understand the meaning of bool on a generator expression in python.\nbool(x for x in []) yields True\nbool(x for x in [1, 2, 3]) yields True\nbool(range(0)) yields False (??)\nbool(range(3)) yields True","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":963,"Q_Id":58104625,"Users Score":1,"Answer":"The confusion arises from range not returning a generator.\nIn general generators are just objects and therefore are always truthy (as opposed to containers which are False when empty).\nIf you do type(range(0)) you get \"range\", but it's not a generator, and apparently has an implicit truth value when it is empty vs non empty.","Q_Score":1,"Tags":"python,boolean,generator","A_Id":58106957,"CreationDate":"2019-09-25T18:34:00.000","Title":"`bool` on a generator expression in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How does one open an interactive Python console\/shell\/prompt within Google Colab? Is it possible? An iPython prompt would be ideal but a regular prompt would suffice.\nAlso, it would be significantly more useful if the console's interpreter shared access to the variables\/state with the Colab notebook's kernel.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1789,"Q_Id":58104847,"Users Score":1,"Answer":"!jupyter console --existing appears to hang with no output because it is waiting to acquire the GIL in the same process as the notebook's runtime that is executing the ! magic, which isn't going to give it up until the ! is done. For the same reason I don't think it's going to be easy to get a subprocess invocation to share state with the notebook's runtime. \nObvs. you could program your own input() + eval() in a loop to simulate a py prompt that shared the env with your notebook.","Q_Score":3,"Tags":"python,google-colaboratory","A_Id":58191048,"CreationDate":"2019-09-25T18:50:00.000","Title":"How to open an interactive Python prompt in Google Colab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list of all wikipedia articles and I want to scrape a body for research purposes. My script is working fine, but at the current speed this will take 40 days straight.\nMy questions is:\nCan I run this script, lets say 10 times parallel in different terminal windows. If I just set it like this:\nScript 1:\nstart point: 0\nend point: len(list)\/10\nScript 2:\nstart start point: len(list)\/10\nend point: len(list)\/(10*2)\n...\nScript 10\nand so on.\nThis could leave me with 4 days, which is reasonable imo.\nDoes my approach work? Is there a better approach?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":58104906,"Users Score":0,"Answer":"Possible yes, ideal no. Why do you think its running so slowly? Also are you using the wiki api or are you scraping the site? There's factors that affect either of the two so knowing what your actually doing will help us give a better answer.","Q_Score":0,"Tags":"python,web-scraping,wikipedia,wikipedia-api","A_Id":58105252,"CreationDate":"2019-09-25T18:55:00.000","Title":"Can you run python wikipedia api multiple times at the same time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In teradataml does create_context support ldap? What other authentication mechanisms are supported? \nHow can user specify ldap server while creating context?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":389,"Q_Id":58104992,"Users Score":0,"Answer":"How can user specify ldap server while creating context?\n\nYou do not specify the LDAP server in the connection parameters. That is not possible and is not necessary.\nLDAP authentication only works if your Teradata Database system has been configured on the server side to offer LDAP authentication. The LDAP server that is used is the LDAP server that the Teradata Database system is configured to use.","Q_Score":0,"Tags":"python,teradata","A_Id":58240835,"CreationDate":"2019-09-25T19:01:00.000","Title":"teradataml: what are the various authentication mechanisms supported by context manager in teradataml?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recursive elements in my Dash program that are well-handled and are never at risk of infinite recursion.\nUnfortunately, a box pops up on my app telling me I have a recursion. How do I stop this warning from showing?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1690,"Q_Id":58105348,"Users Score":0,"Answer":"I saw the error while working with two callbacks: one taking a 'value' of an element as input\/output, the second only taking the 'value' as output. The error occured when i implemented the second-callback and disappeared when i changed the input from the first one to 'state' - perhaps this helps anyone.","Q_Score":0,"Tags":"python-3.x,plotly-dash","A_Id":72489242,"CreationDate":"2019-09-25T19:29:00.000","Title":"Prevent Circular Dependencies UI error message in Plotly Dash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Add or delete tasks to celery through the management side, do not restart celery, how to let celery perform newly added tasks. How should I do it, thank you very much for helping me.  \nCelery version is 4.2.2","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":58111595,"Users Score":0,"Answer":"Celery does not provide API to do this for a good reason - it is extremely hard to do right. What if your task needs few extra dependencies and one of them needs a shared library installed on the system? What if it needs to be built from the source?\nAs a matter of fact, there is no distributed system that does this that I know of (if someone does, please enlighten me). Instead, nowadays it is very easy to replace all workers with new ones that have one or more tasks removed\/added using Docker containers for an example.","Q_Score":0,"Tags":"python-2.7,celery","A_Id":58112458,"CreationDate":"2019-09-26T07:26:00.000","Title":"How to dynamically add or delete tasks to celery without restarting celery","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am running quite a time consuming python code in PyCharm, where data is initially loaded, then a model is created etc. \nI would like to know if it is possible to set a breakpoint at a particular point in the code where the state of the environment will be saved. From there on I want to make edits to the rest of the code, however ideally re-run from the breakpoint I set. \nBy doing this I would avoid the loading of data, and model training which would be a repeated process. \nIs this possible in Python or is there such a functionality in PyCharm?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":345,"Q_Id":58112446,"Users Score":0,"Answer":"One option I have found is to convert your code to ipython notebook. Put all the heavy-weight\/one-time run code in the first few cells and unstable\/to be debugged code in the later cells.\nNow, you run the first few cells one time, so the output from these cells is stored and readily available always for later cells. Whenever you change code in later cells, you only have to run those cells (unless you modified something in the earlier cells in which case you need to rerun those cells as well).\nPycharm\/most python IDEs support running and debugging ipython notebook cells (individually or in groups).","Q_Score":3,"Tags":"python,debugging,pycharm","A_Id":69474304,"CreationDate":"2019-09-26T08:18:00.000","Title":"Re-run code from certain point onwards in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using dht22 sensor and arduino uno. I am able to get the output of the serial reading and I have communicated it with python through pyserial. So now, my sensor data are appearing on python. I have also created an HTML gui of a thermometer which displays random data. NOW THE PROBLEM IS, I CAN'T FIGURE OUT HOW TO COMMUNICATE MY PYTHON TO THE HTML FILE. Any help would be appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":222,"Q_Id":58112600,"Users Score":1,"Answer":"Due to security reasons with browsers, this is supposedly impossible without any frameworks... But try flask as mentioned above, should get your project up and going!","Q_Score":1,"Tags":"html,python-3.x,arduino","A_Id":58114257,"CreationDate":"2019-09-26T08:29:00.000","Title":"How to input data from arduino serial monitor to html 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":1},{"Question":"I recently installed Anaconda in my Windows. I did that to use some packages from some specific channels required by an application that is using Python 3.5 as its scripting language.\nI adjusted my PATH variable to use Conda, pointing to the Python environment of the particular program, but now I would like to use Conda as well for a different Python installation that I have on my Windows.\nWhen installing Anaconda then it isn't asking for a Python version to be related to. So, how can I use Conda to install into the other Python installation. Both Python installations are 'physical' installations - not virtual in any way.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":114,"Q_Id":58112822,"Users Score":1,"Answer":"Uninstall the other python installation and create different conda environments, that is what conda is great at. \nUsing conda from your anaconda installation to manage packages from another, independent python installation is not possible and not very feasible.\nSomething like this could serve your needs:\n\nCreate one env for python 3.5 conda create -n py35 python=3.5\nCreate one env for some other python version you would like to use, e.g. 3.6: conda create -n py36 python=3.6\nUse conda activate py35, conda deactivate, conda activate py36 to switch between your virtual environments.","Q_Score":0,"Tags":"python,anaconda,conda","A_Id":58112997,"CreationDate":"2019-09-26T08:40:00.000","Title":"Install packages with Conda for a second Python installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a 2D image with vehicles localized by 2D bounding boxes in it. Also I have the 3x3 homography matrix and the reprojection error from camera calibration. Are these information enough to find the 3D position of the vehicles?\nThis is my very first question in here, so please let me know if I need to provide more information.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":202,"Q_Id":58114064,"Users Score":0,"Answer":"It is impossible to get 3D coordinates from 2D image. You can map each pixel to the ray that comes from camera nodal point and goes through that pixel but to get 3D coordinates you need also the depth value in this pixel.\nConsider following example: The vehicle of the size S is located at the distance d to the camera. Similar vehicle that is two times bigger (size 2S) is located at the distance 2d to the camera. They are projected exactly the same on the image.\nSo you can get 3D positions up to unknown scale factor only. However, you can estimate the location of each vehicle that if you know the real world size of them.","Q_Score":0,"Tags":"python-3.x,opencv,object-detection","A_Id":58114395,"CreationDate":"2019-09-26T09:47:00.000","Title":"3D object localization from 2D image","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"A .pyw script to present a small GUI (TkInter) to the user. From a Windows Server Terminal server, it does not run for others.\nI wrote a .pyw script to present a small GUI (TkInter) to the user. On my windows desktop, with Python installed, it runs well. I uploaded the script to a Windows Server Terminal server, from where I want a number of users to run it. I can run it when I log onto the terminal server. Other users, however, cannot run it, and it does not display any error messages.\nI have ensured that everyone on the server has full access to the script.\nThe code is running perfectly","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":58114227,"Users Score":0,"Answer":"Uhm... This was rather simpler than I thought.\nBecause it is a .pyw file, an error did not show up. I did not make use of Python's errror catching tools.","Q_Score":0,"Tags":"python,windows,shared","A_Id":58179063,"CreationDate":"2019-09-26T09:56:00.000","Title":"Shared script does not execute","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have nearly 200 000 lines of tuples in my Pandas Dataframe. I injected that data into elastic search. Now, when I run the program It should check whether the present data already there in elastic search if not present insert into it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":58114367,"Users Score":0,"Answer":"I'd recommend to not worry about it and just load everything into Elasticsearch. As long as your _ids are consistent the existing documents will be overwritten instead of duplicated. So just be sure to specify an _id for each document and you are fine, the bulk helpers in the elasticsearch-py client all support you setting an _id value for each document alredy.","Q_Score":0,"Tags":"python-3.x,pandas,elasticsearch,elasticsearch-py","A_Id":58140537,"CreationDate":"2019-09-26T10:05:00.000","Title":"How to get data from elastic search, if new data came then update it, and again inject it?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to clean up the code in a python package which has some unused class\/function definitions. Is there a simple way to list all the functions of a package that are not called within any of the modules of that package? Assume that the 'private' classes\/functions (that I want to clean up) are prefixed with an underscore so they are not confused with 'public' API.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":57,"Q_Id":58116926,"Users Score":1,"Answer":"You can find class\/functions\/vars usages using Pycharm IDE by pressing Ctrl+LeftMouseButton on class\/functions\/vars names to search for usages. If no usages where found in your project, simply delete the dead code manually.","Q_Score":3,"Tags":"python,code-analysis","A_Id":58117034,"CreationDate":"2019-09-26T12:33:00.000","Title":"How to list functions of a python package that are not called inside that package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know of a quick way to close all open variable explorer windows in Spyder? (i.e. the windows that open when you click on a variable).\nIn Matlab, you can close all pop-up windows with close all. Does anything like that exist for Spyder?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":603,"Q_Id":58116958,"Users Score":1,"Answer":"(Spyder maintainer here) We don't have a command to do that, sorry.","Q_Score":3,"Tags":"python,window,spyder","A_Id":58118967,"CreationDate":"2019-09-26T12:35:00.000","Title":"Close all variable explorer windows in Spyder","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i'm using a script ScriptGlobal.py that will call and execute 2 other scripts script1.py and script2.py exec(open(\".\/script2.py\").read()) AND exec(open(\".\/script1.py\").read())\nThe output of my script1 is the creation of csv file.\ndf1.to_csv('file1.csv',index=False)\nThe output of my script2 is the creation of another csv file.\ndf2.to_csv('file2.csv',index=False)\nIn my ScriptGlobal.py i want to read the 2 files file1.csv and file2.csv and then i got this error.\nParserError: Error tokenizing data. C error: Expected 1 fields in line 16, saw 3\nIs there solution to do it without doing manuallyu the manipulation in EXCEL ?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":160,"Q_Id":58117142,"Users Score":0,"Answer":"Did you try save these two .csv files as ANSI? I had problem with .csv when they were saved as UTF-8.","Q_Score":0,"Tags":"python-3.x,csv,dataframe","A_Id":58117742,"CreationDate":"2019-09-26T12:46:00.000","Title":"ParserError: Error tokenizing data. C error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When i run a make file on cygwin, there is Access is denied error.\nThere is a manifest file, input and output file passed as command line arguments to python script\n\npython3 C:\/git\/tool.py -m .\/config\/manifest.txt -i drv.bin -o drv_out.bin\nprocess_begin: CreateProcess(C:\\cygwin64\\bin\\python3, python3 C:\/git\/tool.py -m .\/config\/manifest.txt -i drv.bin -o drv.bin, ...) failed.\nmake (e=5): Access is denied.\n\nEdit: make version\n\nmake --version\nGNU Make 4.2.1 plus updates till 2017-June-04\nBuilt for Windows32","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":601,"Q_Id":58118129,"Users Score":0,"Answer":"Thanks everyone for helping and commenting out.\nI have installed cygwin long time back and the new make file is not compatible with the make version installed in cygwin.\nI had to update the make binary to latest version to build.","Q_Score":0,"Tags":"python,python-3.x,makefile,cygwin,access-denied","A_Id":58187509,"CreationDate":"2019-09-26T13:38:00.000","Title":"python3 make (e=5): Access is denied","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I been learning how to use Apache-Airflow the last couple of months and wanted to see if anybody has any experience with transferring CSV files from S3 to a Mysql database in AWS(RDS). Or from my Local drive to MySQL.\nI managed to send everything to an S3 bucket to store them in the cloud using airflow.hooks.S3_hook and it works great. I used boto3 to do this.\nNow I want to push this file to a MySQL database I created in RDS, but I have no idea how to do it. Do I need to use the MySQL hook and add my credentials there and then write a python function?\nAlso, It doesn't have to be S3 to Mysql, I can also try from my local drive to Mysql if it's easier.\nAny help would be amazing!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1067,"Q_Id":58119536,"Users Score":0,"Answer":"were you able to resolve the 'MySQLdb._exceptions.OperationalError: (2068, 'LOAD DATA LOCAL INFILE file request rejected due to restrictions on access' issue","Q_Score":1,"Tags":"python,mysql,amazon-s3,airflow","A_Id":70966957,"CreationDate":"2019-09-26T14:54:00.000","Title":"S3 file to Mysql AWS via Airflow","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having a problem while tring to read data from a website using urllib in Python 3 that causes my program to stand still (it does not give me any error message, it looks like it is stucked on a loop). The weird part is that this same script works with any other websites that I try, except this one.\nI've been doing some research and read people talking about that \"HTTP Error 403: Forbidden\" traceback that can be fixed using a custom User-Agent to open the url as a browser, but this does not fix my problem.\nI'm almost 100% sure that the problem is some type of restriction from the PC because I'm using a PC from work and both the PC and the Network has some restrictions here, but the weird thing is that the website opens when I'm using Chrome.\nThis code was posted by Kardi Teknomo on another topic and is an interesting way to show my problem.\nimport urllib.request\n\nurl = \"http:\/\/py4e-data.dr-chuck.net\/known_by_Fikret.html\"\n\npage = urllib.request.Request(url,headers={'User-Agent': 'Chrome\/76.0.3809.132'})\ninfile = urllib.request.urlopen(page).read()\ndata = infile.decode()\n\nprint(data)\n\nA simpler code that tries to do the same and fails in the same way, is this one:\nimport urllib.request, urllib.parse, urllib.error\n\nFhandle = urllib.request.urlopen(\"http:\/\/py4e-data.dr-chuck.net\/known_by_Fikret.html\")\nfor lines in Fhandle:\n    lines = lines.decode().strip()\n    print(lines)\n\nI'm trying to do something more complex, but for the sake of fixing the problem, all I'm trying to do with this code is to read an HTML page and print its content, but the program always get stucked right after I press enter if this I use the URL from theses examples.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":902,"Q_Id":58120737,"Users Score":0,"Answer":"I have had the same issue while running code with urllib.request.urlopen(link, context=ctx).read() in IDE PyCharm . The code runs perfectly in console. In order to run this code in IDE, once you put url via url = input('Enter url: ') move the cursor to the beginning of the line and then press 'Enter'.","Q_Score":0,"Tags":"python,urllib","A_Id":61984020,"CreationDate":"2019-09-26T16:04:00.000","Title":"Website opens in Chrome but not while using urllib in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am able to see below path created in my html report , i am able to open this path from html when it is a local job , but when i run in jenkins ,this link wont work , i am able to see metadata have url and workspace info , can i use this meta data to generate proper links in html file , so that i will be able to open them from jenkins page .  \n\nhref=\"file:\/\/\/space\/scratch\/jenkins\/navarro\/workspace\/coverage_regression\/dut\/python\/.simtest\/NavarroSimTestSystem\/default\/TestJaxi\/test_py_jaxi_read_version_reg_ss\/TestJaxi.test_py_jaxi_read_version_reg_ss-2458081572_simulate.log\" type=\"text\/plain\">TestJaxi.test_py_jaxi_read_version_reg_ss-2458081572_simulate.log","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1119,"Q_Id":58124694,"Users Score":0,"Answer":"Are you trying to show test results in Jenkins job? I have found it easier to generate junit.xml using --junitxml switch and point Jenkins to the Junit XML path. It shows all test results data. Or have you tried the 'html-publisher-plugin'.","Q_Score":0,"Tags":"python,jenkins,jenkins-pipeline,pytest","A_Id":58132551,"CreationDate":"2019-09-26T20:57:00.000","Title":"Pytest : How to update jenkins url in pytest html report instead of local 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":0,"Web Development":1},{"Question":"I saw lots of information about using multiple databases with one server but I wasn't able to find contents about sharing one database with multiple servers.\nUsing Micro Service Architectures, If I define a database and models in a django server, named Account, How can I use the database and models in Account server from another server named like Post??\nWhat I'm thinking is to write same models.py in both servers and use the django commands --fake\nThen, type these commands\npython manage.py makemigrations\npython manage.py migrate\nand in another server\npython manage.py makemigrations\npython manage.py migrate --fake\nI'm not sure if this would work and I wonder whether there is any good ways.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":2031,"Q_Id":58126278,"Users Score":4,"Answer":"I doubt this is the best approach, but if you want two separate Django projects to use the same database you could probably create the first like normal then, in the second project, copy over all of the models.py and migration files. Django creates a database table behind the scenes to track which migrations have been applied, so as long as the apps, models, and migration files are identical in the second app it should work without having to fake any migrations.\nThat said, this sounds like a mess to maintain going forward. I think what I would do is create a single Django project that talks to the database, then create an API in that first project that all other apps can interface with to communicate with the database. That way you avoid duplicating code or having to worry about keeping multiple projects in sync.","Q_Score":5,"Tags":"python,django","A_Id":58126737,"CreationDate":"2019-09-27T00:27:00.000","Title":"How can I use one database with multiple django servers?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"On trying to install sys package in Python 3.7.4 version using IDLE, I am getting the below error:\nInput : C:\\Users\\UserName\\Downloads>pip install sys\nOutput :\n Collecting sys\n  ERROR: Could not find a version that satisfies the requirement sys (from versions: none)\nERROR: No matching distribution found for sys","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":2972,"Q_Id":58126332,"Users Score":4,"Answer":"You don't need to use the pip install command. sys is part of the standard library, so it is built into Python that you installed. Use import sys in your .py file and run it to see exactly which libraries are giving you the import error.","Q_Score":3,"Tags":"sys,python-3.7","A_Id":59602559,"CreationDate":"2019-09-27T00:36:00.000","Title":"ERROR: Could not find a version that satisfies the requirement sys (from versions: none) ERROR: No matching distribution found for sys","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I imported a table using pandas and I was able to set independent variables (features) and my dependent variable (target). Two of my independent variables are \"object type\" and my others are int64 and float64. Do I need to convert my \"object\" type features to \"class\" or another type? How can I handle these in Sci-kit learn decision trees?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":346,"Q_Id":58126842,"Users Score":0,"Answer":"I used one hot encoding to convert my categorical data because the scikit-learn decision tree packages do not support categorical data.","Q_Score":0,"Tags":"python,types,scikit-learn,decision-tree","A_Id":58326018,"CreationDate":"2019-09-27T02:10:00.000","Title":"What object types can be used for fetures in decision trees? Do I need to convert my \"object\" type to another type?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When i open Spyder from the terminal with the command Spyder, it is opening the Spyder Python 3.7 console, however whenever I'm opening .py files with SPyder, it is by default opening with Spyder 2.7. \nI've already checked version of the Spyder along with my Anaconda version. Even in my Ubuntu, the python version is 3.7+","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":148,"Q_Id":58128307,"Users Score":0,"Answer":"Spyder is using the python command as default, which on Linux defaults to python 2.7. To fix this, set the python command to mean python 3 or whichever version you'd like.","Q_Score":1,"Tags":"python,ubuntu,anaconda,spyder","A_Id":58161945,"CreationDate":"2019-09-27T05:24:00.000","Title":"By default Spyder is opening with Spyder Python 2.7 while my Anaconda is installed in Python 3.6+","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want a regex that doesn't match a string if contains the word page, and match if it's not contain.\n^https?.+\/(event|news)\/.+(?!page).+$ this is the regex I'm currently using, so I want it to not match with, e.g. https:\/\/www.foosite.com\/news\/foopath\/page\/10, but it does. Where did I made a mistake?\nThe double .+ expressions should imply that there should be some string around the page string, and (?!page) should imply there must not be a string like page between them. What's wrong with this expression? Thanks, and sorry for poor grammar.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":58134755,"Users Score":0,"Answer":"Matching is usually way easier in regex than excluding.\nI would rather match your excluded words and invert the logic on the if-clause.\nif(!re.match(...","Q_Score":0,"Tags":"python,regex","A_Id":58135281,"CreationDate":"2019-09-27T12:39:00.000","Title":"Regex that does not contain a substring after some point","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Beginner python,\nI want to create a method like: max(mat,i)= the row with the maximum value in the column i of matrix mat.\nFor example, I have a matrix a=[[1,2,3],[4,5,6],[7,8,9]], then the largest value of the i=3 column is 9 and so max(a,3)=[7,8,9].\nI'm wondering if there is a builtin function in python?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":58137114,"Users Score":0,"Answer":"To my knowledge, there is not a builtin function in python itself. I would recommend just building the utility yourself, since it's basically just a max over specified list out of matrix, which isn't hard to implement.","Q_Score":1,"Tags":"python","A_Id":58137213,"CreationDate":"2019-09-27T15:05:00.000","Title":"find the row of a matrix with the largest element in column i","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset with the first column as date in the format: 2011-01-01 and type(data_raw['pandas_date']) gives me pandas.core.series.Series\nI want to convert the whole column into date time object so I can extract and process year\/month\/day from each row as required.\nI used pd.to_datetime(data_raw['pandas_date']) and it printed output with dtype: datetime64[ns] in the last line of the output. I assume that values were converted to datetime.\nbut when I run type(data_raw['pandas_date']) again, it still says pandas.core.series.Series and anytime I try to run .dt function on it, it gives me an error saying this is not a datetime object.\nSo, my question is - it looks like to_datetime function changed my data into datetime object, but how to I apply\/save it to the pandas_date column? I tried \ndata_raw['pandas_date'] = pd.to_datetime(data_raw['pandas_date'])\nbut this doesn't work either, I get the same result when I check the type. Sorry if this is too basic.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":384,"Q_Id":58138314,"Users Score":0,"Answer":"type(data_raw['pandas_date']) will always return pandas.core.series.Series, because the object data_raw['pandas_date'] is of type pandas.core.series.Series. What you want is to get the dtype, so you could just do data_raw['pandas_date'].dtype.\n\ndata_raw['pandas_date'] = pd.to_datetime(data_raw['pandas_date'])\n\nThis is correct, and if you do data_raw['pandas_date'].dtype again afterwards, you will see that it is datetime[64].","Q_Score":1,"Tags":"python,pandas,datetime","A_Id":58138420,"CreationDate":"2019-09-27T16:26:00.000","Title":"Change column from Pandas date object to python datetime","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed ndimage with sudo pip3 install scipy\nthen i'm importing it as import scipy.ndimage\nthen i'm doing the following line b=scipy.ndimage.filter.gaussian_filter(i,sigma=10)\nand I get AttributeError: module 'scipy.ndimage' has no attribute 'filter'\nAnyone encountered this before?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":384,"Q_Id":58139189,"Users Score":1,"Answer":"Found it!\nIt should have been b=scipy.ndimage.filters instead of filter","Q_Score":1,"Tags":"python","A_Id":58139262,"CreationDate":"2019-09-27T17:37:00.000","Title":"scipy ndimage has no attribute filter?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"You have a 2005 Honda Accord with 50 miles (weight max) left in the tank. Which McDonalds locations (graph nodes) can you visit within a 50 mile radius? This is my question.  \nIf you have a weighted directed acyclic graph, how can you find all the nodes that can be visited within a given weight restriction? \nI am aware of Dijkstra's algorithm but I can't seem to find any documentation of its uses outside of min-path problems. In my example, theres no node in particular that we want to end at, we just want to go as far as we can without going over the maximum weight. It seems like you should be able to use BFS\/DFS in order to solve this, but I cant find documentation for implementing those in graphs with edge weights (again, outside of min-path problems).","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":697,"Q_Id":58142385,"Users Score":0,"Answer":"Finding the longest path to a vertex V (a McDonald's in this case) can be accomplished using topological sort. We can start by sorting our nodes topologically, since sorting topologically will always return the source node U, before the endpoint, V, of a weighted path. Then, since we would now have access to an array in which each source vertex precedes all of its adjacent vertices, we can search through every path beginning with vertex U and ending with vertex V and set a value in an array with an index corresponding to U to the maximum edge weight we find connecting U to V. If the sum of the maximal distances exceeds 50 without reaching a McDonalds, we can backtrack and explore the second highest weight path going from U to V, and continue backtracking should we exhaust every path exiting from vertex U. Eventually we will arrive at a McDonalds, which will be the McDonalds with the maximal distance from our original source node while maintaining a total spanning distance under 50.","Q_Score":0,"Tags":"python,data-structures,graph,tree,breadth-first-search","A_Id":59133082,"CreationDate":"2019-09-28T00:05:00.000","Title":"Using BFS\/DFS To Find Path With Maximum Weight in Directed Acyclic Graph","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"You have a 2005 Honda Accord with 50 miles (weight max) left in the tank. Which McDonalds locations (graph nodes) can you visit within a 50 mile radius? This is my question.  \nIf you have a weighted directed acyclic graph, how can you find all the nodes that can be visited within a given weight restriction? \nI am aware of Dijkstra's algorithm but I can't seem to find any documentation of its uses outside of min-path problems. In my example, theres no node in particular that we want to end at, we just want to go as far as we can without going over the maximum weight. It seems like you should be able to use BFS\/DFS in order to solve this, but I cant find documentation for implementing those in graphs with edge weights (again, outside of min-path problems).","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":697,"Q_Id":58142385,"Users Score":0,"Answer":"For this problem, you will want to run a DFS from the starting node. Recurse down the graph from each child of the starting node until a total weight of over 50 is reached. If a McDonalds is encountered along the traversal record the node reached in a list or set. By doing so, you will achieve the most efficient algorithm possible as you will not have to create a complete topological sort as the other answer to this question proposes. Even though this algorithm still technically runs in O(ElogV) time, by recursing back on the DFS when a path distance of over 50 is reached you avoid traversing through the entire graph when not necessary.","Q_Score":0,"Tags":"python,data-structures,graph,tree,breadth-first-search","A_Id":60401949,"CreationDate":"2019-09-28T00:05:00.000","Title":"Using BFS\/DFS To Find Path With Maximum Weight in Directed Acyclic Graph","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to generate N integer numbers increasingly and the sum of them equals to M?\nfor example:\nN = 4\nM = 10\noutput: 1 , 2 , 3 , 4\n1+2+3+4 = M = 10 and they are growing","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":58142624,"Users Score":0,"Answer":"Math can help you here. \nIf N is odd, then divide your M by N to get the middle number. From there, work our the first (N-1)\/2 and then the next (N-1)\/2 numbers. \nIf N is even, apply the same logic, except that your next numbers are 0.5 and -0.5 away from your average. From there you can work the first (N-2)\/2 and the next (N-2)\/2 numbers.","Q_Score":0,"Tags":"python","A_Id":58142771,"CreationDate":"2019-09-28T01:07:00.000","Title":"Is there a way to generate N integer numbers increasingly and the sum of them equals to M?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to extract all Twitter feeds of a specific language only. (to extract Sinhala language tweets) How can I do that using python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":58143644,"Users Score":2,"Answer":"regex is useful.\nSinhala language use codes U+0D80\uff5eU+0DFF in utf-8. First, try extracting tweets that contain Sinhala characters with regex.","Q_Score":1,"Tags":"python,tweepy,tweets","A_Id":58143708,"CreationDate":"2019-09-28T05:30:00.000","Title":"How to extract all Twitter feeds of sinhala language language only 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 not able to connect to SQL Server 2005 using pyodbc through windows authentication.\nI'm getting error 4060 Login failed","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":58145618,"Users Score":0,"Answer":"The problem resolved. I was trying to put double quotes around my password while trying to login no \"\" required","Q_Score":0,"Tags":"python,sql-server-2005,windows-authentication,pyodbc","A_Id":63840832,"CreationDate":"2019-09-28T10:56:00.000","Title":"Not able to connect to SQL Server 2005 through pyodbc using windows authentication","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python 3: How can I match 2 sound wave signals, one signal is recorded and saved another is captured on the go, Below are the signals and their freq transform, I need a value in terms of % how much they match,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":58147127,"Users Score":0,"Answer":"You could cross correlate the live stream with the recorded signal.  If they match perfectly, the cross correlation would be 1 (100%).","Q_Score":0,"Tags":"python-3.x,signal-processing","A_Id":58166944,"CreationDate":"2019-09-28T14:10:00.000","Title":"Python 3: How can I match 2 sound wave signals","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my Item Pipeline to add data in database, during processing an item, connection to server can drop randomly and I need to re-establish connection. \nNow in the open_connection function, do I need to make sure that only one thread will create a new connection and all the concurrent request wont start creating a new connection ?\nAs scrapy is single threaded, I guess I would not need any locks in this scenario as one thread would re-establish connection and all the next incoming callback to process_item function would have an established connection.\nIf this is wrong, can I use all usual Python locks with scrapy?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":327,"Q_Id":58151391,"Users Score":2,"Answer":"Scrapy is not single threaded but you still do not need locks.\nInternally scrapy engine can launch multiple requests to the target server at once, but it maintains the order\/sequence of the all the internal threads making it seemingly single threaded to the user.\nSo yes you will not need any locks because at any time only 1 thread would be allowed to process the pipeline.","Q_Score":4,"Tags":"python,python-3.x,scrapy","A_Id":67714866,"CreationDate":"2019-09-29T01:02:00.000","Title":"Can we use locks in Scrapy? Are they ever required as Scrapy is single threaded?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In my Item Pipeline to add data in database, during processing an item, connection to server can drop randomly and I need to re-establish connection. \nNow in the open_connection function, do I need to make sure that only one thread will create a new connection and all the concurrent request wont start creating a new connection ?\nAs scrapy is single threaded, I guess I would not need any locks in this scenario as one thread would re-establish connection and all the next incoming callback to process_item function would have an established connection.\nIf this is wrong, can I use all usual Python locks with scrapy?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":327,"Q_Id":58151391,"Users Score":1,"Answer":"You don't need a lock since there only one thread writing to the database. However, I recommend you to have progress constantly being saved in case of random failures.\nFor the persistence part, you want to use a buffer to save the documents in batches to minimize database workload and total round-trip-time.","Q_Score":4,"Tags":"python,python-3.x,scrapy","A_Id":58154949,"CreationDate":"2019-09-29T01:02:00.000","Title":"Can we use locks in Scrapy? Are they ever required as Scrapy is single threaded?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If I install django on local system, then that django, if I access in virtual environment, will that be accessible, or I have to install django again in VirtualEnvironment?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":219,"Q_Id":58157047,"Users Score":0,"Answer":"Any virtual environment starts out essentially blank, with no packages installed, so you will have to install Django again in the environment.\nPart of the reasoning for this is because if you install something with pip outside of a virtual environment, there's a chance that another python package or program somewhere might break -- this can be from namespace pollution (installing multiple modules that are imported in the same way but work differently) or having different versions of the software (an update breaks some functionality that something else relies on). Even if Django itself doesn't break anything, some dependency it has might be able to.\nAnother advantage is that you can always run pip freeze > requirements.txt in your environment to list all installed packages and versions, then pip install -r requirements.txt in another environment. This makes package import and versioning effortless when you move among development machines or between development and production, and helpful if you'd ever like to roll your own package.","Q_Score":0,"Tags":"python,django,web-applications,frameworks,virtualenv","A_Id":58160650,"CreationDate":"2019-09-29T16:20:00.000","Title":"I am not able to access django inside virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I read somewhere you could run python without an OS. How would I do this? Would I need to compile it? Can I run it raw? And if I did need to compile it, what tool would I use and what format would I compile it to?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":736,"Q_Id":58157080,"Users Score":3,"Answer":"As far as I know there's not really any way to do this easily but I could be wrong.  There are \"portable\" versions of python but these are operating system dependent. I think what you're referencing is some guys at PyCon managed to run python from the GRUB Bootloader.  Your best bet would be installing some minimalist Linux distribution, with essentially only Python and some core packages required to run.  The problem is that there's a lot of types of hardware out there, all with their own drivers and assembly language.  Python can work as a low level language when you need it to but it seems like configuration would be a nightmare.  I haven't looked into it super thoroughly but it seems difficult and impractical. Having an OS above python gives you access to the package managers IDEs and compilier options that make python worth using.","Q_Score":1,"Tags":"python","A_Id":58157170,"CreationDate":"2019-09-29T16:24:00.000","Title":"How do I run python without an OS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm starting to use Qt Designer.\nI am trying to create a game, and the first task that I want to do is to create a window where you have to input the name of the map that you want to load. If the map exists, I then switch to the main game window, and if the name of the map doesn't exist, I want to display a popup window that tells the user that the name of the map they wrote is not valid. \nI'm a bit confused with the part of showing the \"not valid\" pop-up window.\nI realized that I have two options:\n\nCreating 2 separated .ui files, and with the help of the .show() and .hide() commands show the correspoding window if the user input is invalid. \nThe other option that I'm thinking of creating both windows in the same .ui file, which seems to be a better option, but I don't really know how to work with windows that come from the same file. Should I create a separate class for each of the windows that come from the Qt Designer file? If not, how can I access both windows from the same class?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":64,"Q_Id":58159932,"Users Score":0,"Answer":"Your second option seems impossible, it would be great to share the .ui since in my years that I have worked with Qt Designer I have not been able to implement what you point out.\nAn .ui is an XML file that describes the elements and their properties that will be used to create a class that is used to fill a particular widget. So considering the above, your second option is impossible.\nThis concludes that the only viable option is its first method.","Q_Score":1,"Tags":"python,pyqt,qt-designer","A_Id":58159983,"CreationDate":"2019-09-29T23:15:00.000","Title":"How does Qt Designer work in terms of creating more than 1 dialog per file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 1 file, i get as far as line 1 import requests, nothing more yet and I receive the following error ModuleNotFoundError: No module named 'requests'. \n\nUsing Visual Studio Code, installed today with standalone Python x64 3.7.4\nPython Extension installed in VSCODE\nvenv created within VSCODE as a subfolder of workspace withint VSCODE terminal and was recognized by VSCODE when created and I am using venv interpreter in VSCODE as indicated on bottom bar\nran pip install requests within terminal inside VSCODE - completed successfully\nran pip freeze to confirm requests==2.22.0 is registered\nVerified pylint was installed in venv\n\nI cannot figure out why VSCODE python interpreter will not recognize that requests is installed","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":17011,"Q_Id":58160360,"Users Score":0,"Answer":"2 ways work for me, under windows 10:\n\nrun in terminal: ctrl + F5\n\nAdd the following in settings json:\n\"code-runner.executorMap\": {\n\"python\": \"$pythonPath -u $fullFileName\"\n}","Q_Score":4,"Tags":"python,visual-studio-code,python-requests,virtual-environment","A_Id":69745046,"CreationDate":"2019-09-30T00:59:00.000","Title":"ModuleNotFoundError: No module named 'requests' using venv in vscode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 1 file, i get as far as line 1 import requests, nothing more yet and I receive the following error ModuleNotFoundError: No module named 'requests'. \n\nUsing Visual Studio Code, installed today with standalone Python x64 3.7.4\nPython Extension installed in VSCODE\nvenv created within VSCODE as a subfolder of workspace withint VSCODE terminal and was recognized by VSCODE when created and I am using venv interpreter in VSCODE as indicated on bottom bar\nran pip install requests within terminal inside VSCODE - completed successfully\nran pip freeze to confirm requests==2.22.0 is registered\nVerified pylint was installed in venv\n\nI cannot figure out why VSCODE python interpreter will not recognize that requests is installed","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":17011,"Q_Id":58160360,"Users Score":1,"Answer":"Thanks for the responses. I found out my own issue after a few hours.\nFirst off I figured out somewhere that when I was running the terminal in VSCODE it was running against global interpreter. I then tried .\/pip freeze and it worked as expected. This told me that the terminal was connected to the wrong interpreter.\nFor some reason when I would 'run' the file it was executing in the terminal but it wasn't 'activating' the venv. I've closed and reopened VSCODE many times but for some reason when I closed the terminal window and reopened using CTRL+SHIFT+' and I received an error about signed scripts when it tried to activate my venv using the PS1 script. I ran Set-ExecutionPolicy -ExecutionPolicy RemoteSigned inside a normal PowerShell window and then reopened the Terminal window in VSCODE and it successfully activated my venv and I know see my venv name at the beginning of the line of the terminal. I then ran 'pip freeze' to confirm which modules installed inside of venv and then ran again in normal powershell window and it was different.\nThere is documentation somewhere that says to run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned which I found later, but it would have been nice to know this was a requirement.","Q_Score":4,"Tags":"python,visual-studio-code,python-requests,virtual-environment","A_Id":58160615,"CreationDate":"2019-09-30T00:59:00.000","Title":"ModuleNotFoundError: No module named 'requests' using venv in vscode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was able to get it up and running with gunicorn and uvloop, but having a hard time getting this working with hypercorn. Another issue is specifying the number of workers for ASGI frameworks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":395,"Q_Id":58160769,"Users Score":0,"Answer":"You probably have a line like app = Starlette(debug=True) the app is an ASGI application that can be run by Hypercorn (or other ASGI servers). If this line is in a file called run.py you can run it via hypercorn run:app.\nIf you want multiple workers (2 shown) you can do hypercorn -w 2 run:app. If you want uvloop as well, hypercorn -w 2 -k uvloop run:app.","Q_Score":0,"Tags":"python-3.x,starlette,hypercorn","A_Id":58322968,"CreationDate":"2019-09-30T02:18:00.000","Title":"How to interface hypercorn and starlette web framwork","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My system has two NUMA nodes and two GTX 1080 Ti attached to NUMA node 1 (XEON E5).\nThe NN models are trained via single-machine multi-GPU data parallelism using Keras' multi_gpu_model.\nHow can TF be instructed to allocate memory and execute the TF workers (merging weights) only on NUMA node 1? For performance reasons I'd like to prevent accessing memory through the QPI.\ntf.device():\n1) Does tf.device('\/cpu:0') refer to a physical CPU or a physical core or is it simply a 'logical device' (thread|pool?) that is moved between all physical cores that are online?\n2) How can the TF scheduler be influenced to map the logical device to a set of physical cores?\n3) In the case of memory allocation on NUMA systems - does TF support allocating memory on specific nodes? Or do I have to fall back to set_mempolicy()\/numactl (LINUX)?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":366,"Q_Id":58162375,"Users Score":1,"Answer":"no, answer ...\nI'm using numactl --cpunodebind=1 --membind=1 - binds execution and memory allocation to NUMA node 1.","Q_Score":1,"Tags":"python,tensorflow,numa","A_Id":58364117,"CreationDate":"2019-09-30T06:16:00.000","Title":"pin and allocate tensorflow on specific NUMA node","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to debug a library that uses Robot (mostly BuiltIn). Trying to import it from Python console returns an exception:\n\nFile \"[path]\/robot\/libraries\/BuiltIn.py\", line 66, in _get_context\n      raise RobotNotRunningError('Cannot access execution context')\n\nI found robotframework-debuglibrary but it seems to create a Robot shell, not a Python one. Is there an effective solution to that problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":335,"Q_Id":58163869,"Users Score":0,"Answer":"So basically you want to import Robot Framework into python environment? Try checking the versions compatibility of Robot Framework you have and the version of Python you are using.\nRobot Framework is supported on Python (both Python 2 and Python 3), Jython (JVM) and IronPython (.NET) and PyPy. The interpreter you want to use should be installed before installing the framework itself.","Q_Score":0,"Tags":"python,console,robotframework","A_Id":58164218,"CreationDate":"2019-09-30T08:10:00.000","Title":"Is it possible to get a python interactive console with Robot environment initialised?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying python --version in my windows subsystem for linux terminal and it is showing me 2.7.15 whereas I do not have 2.7 in my system. I have python 3.6 set in my environment variable, and that is the python interpreter I have used till date. Suddenly after restarting my system I could see that version is 2.7. How do I change  the version of python and set it to my original interpreter ? I have tried  sudo apt update && upgrade and then sudo apt install python3 python3-pip ipython3. Did not help.  Please help.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":58164034,"Users Score":0,"Answer":"Try python3 --version or python3.6 --version","Q_Score":0,"Tags":"python,windows-subsystem-for-linux","A_Id":58164113,"CreationDate":"2019-09-30T08:22:00.000","Title":"Not being able to change version of python from 2.7-3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying python --version in my windows subsystem for linux terminal and it is showing me 2.7.15 whereas I do not have 2.7 in my system. I have python 3.6 set in my environment variable, and that is the python interpreter I have used till date. Suddenly after restarting my system I could see that version is 2.7. How do I change  the version of python and set it to my original interpreter ? I have tried  sudo apt update && upgrade and then sudo apt install python3 python3-pip ipython3. Did not help.  Please help.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":58164034,"Users Score":0,"Answer":"You can use python3 as python3 orpython3.6 \nIf you still want to use python3 with the python command, edit your ~\/.bash_profile file and add line alias python='python3' and restart terminal","Q_Score":0,"Tags":"python,windows-subsystem-for-linux","A_Id":58164184,"CreationDate":"2019-09-30T08:22:00.000","Title":"Not being able to change version of python from 2.7-3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying python --version in my windows subsystem for linux terminal and it is showing me 2.7.15 whereas I do not have 2.7 in my system. I have python 3.6 set in my environment variable, and that is the python interpreter I have used till date. Suddenly after restarting my system I could see that version is 2.7. How do I change  the version of python and set it to my original interpreter ? I have tried  sudo apt update && upgrade and then sudo apt install python3 python3-pip ipython3. Did not help.  Please help.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":58164034,"Users Score":0,"Answer":"you can try using alternatives install python 3.6\nand try \n# alternatives --config python\nand choose the alternative version","Q_Score":0,"Tags":"python,windows-subsystem-for-linux","A_Id":58164607,"CreationDate":"2019-09-30T08:22:00.000","Title":"Not being able to change version of python from 2.7-3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am relatively new to python and it seems to me (probably because I don't understand) that the syntax is sometimes slightly inconsistent.\nSuppose we are working with the pandas package import pandas as pd. Then any method within this package can be accessed by pd.method, i.e. pd.DataFrame(...). Now, there are certain objects within the pandas package that have certain methods, i.e. df.reindex() (notice circular brackets), or certain attributes, i.e. df.columns (notice no brackets).\nMy question is two fold:\nFirst of all, is what I have said above correct?\nSecondly, why does the iloc method not maintain the above syntax? If it is a method then surely I should use df.iloc(0,0) instead of df.iloc[0,0] to obtain the top left value of a data frame...\nThanks","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":363,"Q_Id":58166876,"Users Score":4,"Answer":"import pandas as pd here it is python module \npd.DataFrame(...) if you pay attention to naming convection DataFrame is a class here.\ndf.reindex() is a method called on instance itself.\ndf.columns has no bracket because it is an attribute of the object not a method\ndf.iloc is meant to get item by index so to show it's index-able nature [] makes more sense here.","Q_Score":2,"Tags":"python,pandas","A_Id":58167125,"CreationDate":"2019-09-30T11:20:00.000","Title":"Why does iloc use [] and not ()?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement 3 flask docker containers using docker-compose. I'm running each flask app on a different port 127.0.0.1:5000,127.0.0.1:5001,127.0.0.1:5002. I've mentioned the containers in docker-compose.yml file. The docker-compose is creating a default network.\nBut when I try to access 5001 container's flask endpoint from 5000 container's code like \nrequests.get('http:\/\/127.0.0.1:5001\/endpoint'), It is throwing following error.\n\nHTTPConnectionPool(host=\\'0.0.0.0\\', port=5001): Max retries exceeded\n  with url (Caused by NewConnectionError\n\nDoes anyone know why I'm getting this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1227,"Q_Id":58169484,"Users Score":3,"Answer":"That is because you are attempting to connect to localhost within the docker container itself, i.e. the traffic stays within that docker container.\nWhat you want to do instead is to connect to your other container by its hostname. Within the context of the network managed by docker\/docker-compose that is just the name of the docker container. E.g. for a container foo you can connect over HTTP to port 5001 using http:\/\/foo:5001\/ inside your container.","Q_Score":0,"Tags":"python-3.x,docker,flask,docker-compose,docker-networking","A_Id":58169539,"CreationDate":"2019-09-30T14:00:00.000","Title":"How to call an endpoint of one container from another flask container running on different ports in docker compose?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I need to be able to change the location Anaconda looks at for the .condarc file. The drive it's trying to access doesn't exist anymore and that's causing practically every conda command to fail. I tried uninstalling and reinstalling Anaconda. I also tried conda config --file C:\\.condarc \nThis has been surprisingly difficult to search for - any help would be most appreciated!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5535,"Q_Id":58171779,"Users Score":2,"Answer":"I finally got a working solution. It doesn't actually change the location that conda looks to find the .condarc file, but it does work. \nMany thanks to nekomatic for the idea!\nThe %HOME% environment variable was set to H:\\ and was being used to find the .condarc file. Though it's probably possible to change the way those variables are set. I instead just mapped my C: drive to H: by assigning H: to \\\\localhost\\C$\\\nNow.. finally... conda can install things, make environments, etc. I hope this post helps someone else avoid all this frustration.","Q_Score":5,"Tags":"python,windows,anaconda","A_Id":58184677,"CreationDate":"2019-09-30T16:25:00.000","Title":"How can I change the directory of the .condarc file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I apologize if this is obvious, but I'm relatively new to Django and couldn't find any resources for this.\nGoal\nI would like to create unique invoices that are stored on my server (or a CDN) when a form is filled out.\nQuestion\nWould it be possible to use Django forms to create an HTML file with a unique URL (or upload the newly created file to AWS).\nI understand how to upload files, I just can't quite figure out how to create a new file using a form.\nUpdate\nThe reason why I want to create a unique file is so that I can email the invoice to the customer so that they can view the invoice at a later point.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":58173509,"Users Score":0,"Answer":"You can handle the logic in your view where the form is called.\ndef my_view(request):\n    if form.is_valid():\n        do_something_with_data()\nI would be more specific but it's challenging when there is no code to reference.","Q_Score":0,"Tags":"python,django","A_Id":58173588,"CreationDate":"2019-09-30T18:40:00.000","Title":"Use django forms to create a new file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm getting an error when I try to installed the h3 package via pip. I running  Python 3.6.\nHere's the error:\n\nCommand \"d:\\pyth2\\python.exe -u -c \"import setuptools,\n  tokenize;file='c:\\users\\8523~1\\appdata\\local\\temp\\pip-install-0frm_v\\h3\\setup.py';f=getattr(tokenize,\n  'open', open)(file);code=f.read().replace('\\r\\n',\n  '\\n');f.close();exec(compile(code, file, 'exec'))\" install\n  --record c:\\users\\8523~1\\appdata\\local\\temp\\pip-record-gizroq\\install-record.txt\n  --single-version-externally-managed --compile\" failed with error code 1 in c:\\users\\8523~1\\appdata\\local\\temp\\pip-install-0frm_v\\h3\\\n\nHow do I bypass this error?\nI've installed all pre-required packages, except \"make\" which is unavailable on Windows.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1007,"Q_Id":58174180,"Users Score":1,"Answer":"Use Conda forge. \nThere is a h3-py package","Q_Score":0,"Tags":"python-3.x,h3","A_Id":60457082,"CreationDate":"2019-09-30T19:32:00.000","Title":"Installing h3 on Windows correctly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Replace function failed to work even with inplace=True.\ndata:\n\n0      245778 others\n  1      245778 others\n  2      245778 others\n  4      245778 others\n\ncode:\ndf.likes=df.likes.astype('str')\ndf.likes.replace('others','',inplace=True)\nResult:\n\n0      245778 others\n  1      245778 others\n  2      245778 others\n  4      245778 others\n\nExpected Result:\n\n0      245778 \n  1      245778 \n  2      245778 \n  4      245778","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":58176409,"Users Score":1,"Answer":"Without setting the regex flag to True, replace will look for an exact match.\nTo get a partial match, just use df.likes = df.likes.replace(' others', '', regex=True).","Q_Score":0,"Tags":"python,pandas","A_Id":58176536,"CreationDate":"2019-09-30T23:30:00.000","Title":"replace do not work even with inplace=True","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, this is for my assignment and I have to create a flight booking system. One of the requirements is that it should create 3 digit passenger code that does not start with zeros (e.g. 100 is the smallest acceptable value) and I have no idea how I can do it since I am a beginner and I just started to learn Python. I have made classes for Passenger, Flight, Seating Area so far because I just started on it today. Please help. Thank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":58177362,"Users Score":0,"Answer":"I like list comprehension for making a list of 100 to 999:\nflights = [i for i in range(100, 1000)]\nFor the random version, there is probably a better way, but Random.randint(x, y) creates a random in, inclusive of the endpoints:\nfrom random import Random\nrand = Random()\nflight = rand.randint(100,999)\nHope this helps with your homework, but do try to understand the assignment and how the code works...lest you get wrecked on the final!","Q_Score":0,"Tags":"python","A_Id":58177528,"CreationDate":"2019-10-01T02:27:00.000","Title":"Start at 100 and count up till 999","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm on macOS 10.15 Beta, running a .py script that requires pandas, which is not installed.\nWhen I run sudo python -m pip install --upgrade pandas I receive:\n\nERROR: Cannot uninstall 'numpy'. It is a distutils installed project\n  and thus we cannot accurately determine which files belong to it which\n  would lead to only a partial uninstall.\n\nIf I run sudo pip install pandas I receive the same error.\nHelp appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1097,"Q_Id":58178508,"Users Score":0,"Answer":"I found an alternative method to install pandas, by installing minicondas, and running conda install pandas.","Q_Score":1,"Tags":"python,pandas,macos","A_Id":58178725,"CreationDate":"2019-10-01T05:24:00.000","Title":"can't install pandas (ERROR: Cannot uninstall 'numpy')","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm on macOS 10.15 Beta, running a .py script that requires pandas, which is not installed.\nWhen I run sudo python -m pip install --upgrade pandas I receive:\n\nERROR: Cannot uninstall 'numpy'. It is a distutils installed project\n  and thus we cannot accurately determine which files belong to it which\n  would lead to only a partial uninstall.\n\nIf I run sudo pip install pandas I receive the same error.\nHelp appreciated.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1097,"Q_Id":58178508,"Users Score":0,"Answer":"I tried the solutions presented in the other answers, but what worked for me was installing pandas using conda.","Q_Score":1,"Tags":"python,pandas,macos","A_Id":59296658,"CreationDate":"2019-10-01T05:24:00.000","Title":"can't install pandas (ERROR: Cannot uninstall 'numpy')","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to select all values bigger than 8000 within a pandas dataframe. \nnew_df = df.loc[df['GM'] > 8000]\nHowever, it is not working. I think the problem is, that the value comes from an Excel file and the number is interpreted as string e.g. \"1.111,52\". Do you know how I can convert such a string to float \/ int in order to compare it properly?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":93,"Q_Id":58179925,"Users Score":2,"Answer":"You can see value of df.dtypes to see what is the type of each column. Then, if the column type is not as you want to, you can change it by df['GM'].astype(float), and then new_df = df.loc[df['GM'].astype(float) > 8000] should work as you want to.","Q_Score":1,"Tags":"python,pandas","A_Id":58179988,"CreationDate":"2019-10-01T07:26:00.000","Title":"String problem \/ Select all values > 8000 in pandas dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am on a Ubuntu machine. I installed Jupyter Notebook using the following command. \n\nsudo snap install jupyter\n\nBut Jupyter cannot find any of the installed python packages which were installed using terminal. I checked if jupyter and terminal are pointing to same python installation using this code. \n\nimport sys; print(sys.executable)\n\nTerminal shows this output.\n\n'\/usr\/bin\/python3'\n\nAnd Jupyter shows this one. \n\n'\/snap\/jupyter\/6\/bin\/python'\n\nNow I want the jupyter to point the same installation path as the terminal shows. How can I do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":655,"Q_Id":58179930,"Users Score":3,"Answer":"your jupyter is not placed in default packages location due to installing it with snap. install jupyter with pip this way: pip install jupyter\nif you dont have pip then download it. it usually is included in python package","Q_Score":2,"Tags":"python,jupyter-notebook","A_Id":58180176,"CreationDate":"2019-10-01T07:26:00.000","Title":"How to make Jupyter Notebook to point to the same Python installation as Terminal on Ubuntu?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a web page served by Django, and i want to make it to 301 redirect from \n    mysite.com\/    to    mysite.com    without a slash on the end. Is it possible to do with Django? \nLast version of Django, python 3.6.\npath(\"\", views.home, name=\"main_page\")\nChanging nginx config is not an option at my server","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":58186796,"Users Score":4,"Answer":"mysite.com\/ and mysite.com are the same URL. You don't need to set up a redirect.\nYour friend probably means that you shouldn't have the same content for mysite.com\/foo and mysite.com\/foo\/.\nIn Django, you would usually achieve this by using the URL foo\/, then the default setting APPEND_SLASH = True will redirect \/foo to \/foo\/.","Q_Score":1,"Tags":"python,django","A_Id":58186934,"CreationDate":"2019-10-01T14:18:00.000","Title":"Redirect from .com\/ to just .com","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using python package 'jira' for establishing connection with the jira. I basically use the information from excel file and create tickets automatically in JIRA based on the excel information. Sometime there might be changes in the excel information for the same ticket in which case I need to run the code manually. So I would like to know if it is possible to do this automatically whenever there is a change in the excel file.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":58187671,"Users Score":0,"Answer":"I assume you are only interested in filing new tickets. i.e. adding new rows in excel sheet.\nTwo options:\n\nRun your code in a forever loop with sleep.\nHave your code run by a cron.\n\nNow, you can maintain the hash(md5 or sha256) of your file, and write the hash in some file on host machine if you are not using a database.\nYour code has to read from this file, and calculate fresh hash of that excel file. If they are not same, means something has changed in your file.\nNow, you also need to maintain till what row you have created the jira tickets. You can write this information also in some file.","Q_Score":0,"Tags":"python,excel,jira,python-jira","A_Id":59089182,"CreationDate":"2019-10-01T15:04:00.000","Title":"Synchronization using python code based on an excel file to JIRA","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using DJANGO and i want to integrate an SMS API into my DJANGO app. Can anyone help in knowing where (in which file) to write the code for integration and also the code to integrate SMS API?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":58191010,"Users Score":0,"Answer":"It depends on your requirements. If you have a complex sms sending system, it would be better to create a new django app for this system and write a class (maybe model) for processing sms sending. I'd advice you to keep models fat, but views skinny. You can execute sms sending from signals, celery, views so on, according to your needed of course.\nRegarding to the integrating code, take a look on the sms provider's specification. It must exists. If not, find a better provider, who cares about his clients.","Q_Score":0,"Tags":"python-3.x,django-rest-framework","A_Id":58197344,"CreationDate":"2019-10-01T19:18:00.000","Title":"SMS API integration in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"There isn't a straight answer on web, so I thought I'll ask here.\nWhen a Python function returns multiple values is this just a syntax sugar for returning a list of elements that gets destructured after it's returned?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":103,"Q_Id":58191022,"Users Score":4,"Answer":"It's equivalent to returning a tuple, not a list.\nThe tuple may or may not get destructed depending on what the caller does with it.  If the caller keeps a reference to the tuple, it will continue to exist for as long as there are references to it.","Q_Score":2,"Tags":"python,programming-languages","A_Id":58191056,"CreationDate":"2019-10-01T19:19:00.000","Title":"Is Python multiple arguments return syntax sugar?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Please note I need to read the meters remote via the network via modbus gateway.\nSiemens documentation states gateway can be reached via port 17002 (module 1)\nI tried a TCP-client to the server on port 502 which works fine with pymodbus.\nSlaves addresses are at 10-24.\na piece of sample code would be great.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":516,"Q_Id":58191957,"Users Score":0,"Answer":"Thank you very much!\nI learned from Siemens support team the PAC4200 isn't multi user capable.\nAs the desigo server is already occupying the connection, my requests stay unanswered.\nA workaround was to enable the desigo web services. This way I'm able to read the power consumption of the slaves now.\nAnother alternative would be to install a 3rd party gateway which can handle multiple sessions and downgrade the PAC4200 to a client.","Q_Score":1,"Tags":"python,tcp,modbus","A_Id":63837266,"CreationDate":"2019-10-01T20:38:00.000","Title":"How to read modbus slaves (RTU) connected to a Siemens PAC4200 gateway (TCP) with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Please Everybody. I have a little problem with pipenv. \nFor instance, I am work on a Django project and I decided to sleep. I had to shutdown my laptop for some reason. Then i woke up navigated to the project and I open it in VScode again. My question is how to I reactivate the pipenv environment again. \nI mean something like source bin\/activate if you are using virtualenv\nI use pipenv shell but i want to be sure that is absolutely right.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":787,"Q_Id":58192460,"Users Score":0,"Answer":"pipenv \u2014venv to get the location of the virtualenv\nThen activate it like a normal virtualenv.","Q_Score":1,"Tags":"python,django,virtualenv,pipenv,virtual-environment","A_Id":58192630,"CreationDate":"2019-10-01T21:26:00.000","Title":"Python\/Django: How to reactivate pipenv after exiting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Please Everybody. I have a little problem with pipenv. \nFor instance, I am work on a Django project and I decided to sleep. I had to shutdown my laptop for some reason. Then i woke up navigated to the project and I open it in VScode again. My question is how to I reactivate the pipenv environment again. \nI mean something like source bin\/activate if you are using virtualenv\nI use pipenv shell but i want to be sure that is absolutely right.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":787,"Q_Id":58192460,"Users Score":0,"Answer":"As a new user of both Django and Pipenv I recently ran into the same issue. Maybe this will help someone. \n(for Mac m1 steps maybe different for you)\n\nexpose hidden folders inside the home directory.  Shift + command + > \nyou should see a folder called \" .local.\" follow it through... \n.local > share, virtualenvs.  The virtualenvs is what your looking for. It contains folders for all of pipenvs.\nfrom the integrated terminal inside vscode I cd into whichever pipenv folder coorespondes to the project I'm working on then run: \nsource bin\/activate. \nthe terminal should return with an indicator in parens ahead of user name confirming the shell is active again: \n(Blog) user@user-MBP Blog % \ncd back into project folder (the one containing manage.py)  and run python manage.py runserver \nshould be good to go.","Q_Score":1,"Tags":"python,django,virtualenv,pipenv,virtual-environment","A_Id":67703966,"CreationDate":"2019-10-01T21:26:00.000","Title":"Python\/Django: How to reactivate pipenv after exiting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I used cmd and did pip install requests. However when I go to write my code it gives me an error that I don't have a module named requests but when I run pip list in cmd it says it in the list.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":449,"Q_Id":58193447,"Users Score":0,"Answer":"The best way to manage your Python modules and projects is using Anaconda. Install Anaconda for Windows and you can create Virtual environments for individual projects that is a good practice. Good Luck!","Q_Score":0,"Tags":"python,path,pip","A_Id":58193465,"CreationDate":"2019-10-01T23:22:00.000","Title":"How to add pip to path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used cmd and did pip install requests. However when I go to write my code it gives me an error that I don't have a module named requests but when I run pip list in cmd it says it in the list.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":449,"Q_Id":58193447,"Users Score":0,"Answer":"You probably dont have the library in the environment you are using. If you are using a IDE like pycharm ensure under interpreter you have the library there. \nI dont think the issue is not having pip in your path.","Q_Score":0,"Tags":"python,path,pip","A_Id":58193467,"CreationDate":"2019-10-01T23:22:00.000","Title":"How to add pip to path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had a function that triggered a recursion error when I ran it in my windows command line, but not in jupyter notebook. I did some Googling and found sys.getrecursionlimit() and the default python limit is 1000, but the default jupyter notebook value is 3000. I read that setting the recursion limit higher can crash the program and is not advised. So my question is why is the default 3 times higher in jupyter? Is it really that dangerous to raise the limit to much higher values?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":208,"Q_Id":58193707,"Users Score":0,"Answer":"It's easy to do simple mistakes with recursion and cause infinite loop, utilising 100% of CPU core. Recursion limit prevents that and exits program. You can set it higher if you need to.\nNote that by setting it to 10000 it'll take 10x longer to exit unintended infinite loop. Sometimes the function involves creating new files and 1000 is just a safe value.","Q_Score":1,"Tags":"python,jupyter-notebook","A_Id":58193783,"CreationDate":"2019-10-02T00:04:00.000","Title":"Jupyter Notebook recursion limit vs windows console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How is it possible to search for a table tag in a parsed html independent of its class and attributes ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":58194412,"Users Score":0,"Answer":"Assuming that soup below is your parsed html, then you can find any tag. Table is just a specific type of tag:\nsoup.find_all('table')","Q_Score":0,"Tags":"python,beautifulsoup","A_Id":58194675,"CreationDate":"2019-10-02T02:19:00.000","Title":"How to search for a table in beautifulsoup that independent of attribute and class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I ran Python 3.6.6 Deep Learning with Pycharm 2019.1.3. The process was set at maximum 651 episode and it stopped at episode 368 with this message \"Process finished with exit code -2147483645\". \nI searched through Google but there's not even a result. Anyone knows about the code? Please help!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2679,"Q_Id":58197666,"Users Score":0,"Answer":"Mmmm... I dont know about the error. But given the fact that it starts and works well for 368 episodes... I would aim that is some lack of memory related problem.\nI would run it several times, if it crash after a similar number of episodes I'd try with more memory.\nHope this helps even just a little bit.","Q_Score":3,"Tags":"python,pycharm,exit-code","A_Id":58198069,"CreationDate":"2019-10-02T08:15:00.000","Title":"\"Process finished with exit code -2147483645\" Pycharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to convert models trained in TensorFlow 1.12.0 Python into that of TensorFlow.js. What version of tf.js and tf.js converter is compatible with it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":259,"Q_Id":58197749,"Users Score":1,"Answer":"You have not mentioned in which format you are saving your model in TensorFlow 1.12. I would recommend to make use of saved model format to save your model. If you use saved models, you can use the latest versions of tf.js and tf.js converters. Same is the case for keras h5 model as well.\nHowever, if you save it in form of pb files, you will have to use tf.js version of 0.15 and tf.js converter of 0.8.6","Q_Score":2,"Tags":"python,tensorflow,tensorflow.js","A_Id":58202111,"CreationDate":"2019-10-02T08:20:00.000","Title":"Which version of TensorFlow.js is compatible with models trained in TensorFlow 1.12.0 (Python)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently installed Windows 10 on my new PC and everything went fine until I encountered some issues with modules like autopep8. Researching the problem it didn't seem too many people have the same problem as me, so here goes my error code: SyntaxError: Non-UTF-8 code starting with '\\xdf' (...).\nI've never seen this before and I don't want to change the autopep8 installation files, but still would like to use it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":58197793,"Users Score":2,"Answer":"It seems like the problem was that my Windows username contained the letter '\u00df' from the German alphabet. As some Python (and other) modules write the installation path at the beginning of the script it tried to transfer this special char but couldn't really translate it into the right UTF-8 code.\nThat way Windows thought that the file wasn't properly encoded in UTF-8 and therefore threw this error.\nSolution: As you can't simply rename the Windows user account (tried it, failed miserably), you have to create a new one and work with that or reinstall Windows and select a proper name.\nLessons learned: when the Windows installer asks me what my name is, I won't give it my name again.","Q_Score":1,"Tags":"python,windows,utf","A_Id":58197794,"CreationDate":"2019-10-02T08:23:00.000","Title":"Autopep8 and other modules not working after Windows 10 reinstall","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am quite new to flask and have been reading up on the use of Blueprints when creating a new project. I am currently working on a small personal website for myself, however I have some questions on where certain processes should be done.\nSay I want to retrieve some blog posts from a database, I can create a model and use this to retrieve all the data I want, however I am currently planning on writing the code to initiate the retrieval of the blog posts within the view route, I have a feeling this is an incorrect way to go about doing this and that as much logic as possible should be removed from the views file...?\nIf this assumption is true, where would you generally place all the functional logic? Would you create a helper file within the app and have this file be dedicated to handle all custom logic?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":805,"Q_Id":58198220,"Users Score":0,"Answer":"Most of the codebases you find will have a MVC Structure\n\nM = Model\nV = View\nC = Controller\n\nModels folder will hold \"models\", which is basically a fancy term for Classes that have the ability to interact with a particular table in your Relational Database.\nViews folder will contain all your html templates, which you can render.\nControllers folder will contain controller, which are basically routes, which are invoked by other services, or your frontend.\nIt is also a good practice to separate Business\/Functional Logic to a folder called Managers. \nLets say you have a Controller called resource_controller, here you can write the logic for handling the API requests to the routes that pertain to this resource. \nAll the business logic for resource_controller should be held in resource_manager. All the retrieval, manipulation of data should be handled by the resource_manager. You would also need a resource model. The job of resource is to perform CRUD operations with the database, and return the necessary data to the resource_manager, which will in turn process the data into information and may pass it to the resource_controller. You can return the processed data from the resource_controller back according to your needs.\nYou may also have a helper file containing code shared by multiple managers.","Q_Score":0,"Tags":"python,flask","A_Id":58200760,"CreationDate":"2019-10-02T08:50:00.000","Title":"Flask - Where is the best place to place functional logic?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am pretty new to machine learning and I am currently dealing with a dataset in the format of a csv file comprised of categorical data. As a means of preprocessing, I One Hot Encoded all the variables in my dataset. \nAt the moment I am trying to apply a random forest algorithm to classify the entries into one of the 4 classes. My problem is that I do not understand exactly what happens to these One Hot Encoded variables. How do I feed them to the algorithm? Is it able to make the difference between buying_price_high, buying_price_low (One Hot Encoded from buying_price)? \nI One Hot Encoded the response variable as well.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":170,"Q_Id":58201116,"Users Score":0,"Answer":"Method of (One Hot Encoder) applies to category variables, and category variables have no size relationship.For the price variable,I suggest you use OrinalEncoder.Sklearn is a good package for machine.like, sklearn learning.preprocessing.OneHotEncoder or sklearn.preprocessing.OrdinalEncoder","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,random-forest,multiclass-classification","A_Id":58201684,"CreationDate":"2019-10-02T12:02:00.000","Title":"Single-label multiclass classification random forest python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to let pycharm only inspect python files via a simple regex like *.py?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19,"Q_Id":58201128,"Users Score":0,"Answer":"You can specify a custom scope with a regex to only inspect python files: Code->Inspect code->Custom scope->...->Create new scope->Include Recursively on the project root-> change the pattern to *.py instead of *","Q_Score":0,"Tags":"python,pycharm","A_Id":58201200,"CreationDate":"2019-10-02T12:03:00.000","Title":"How to only analyse python files using pycharm inspect code functionality?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Python 3.7.4, and then jupyter using pip.\nOn running command, 'jupyter notebook' from windows cmd, I get message as:\n\n[C 17:47:19.194 NotebookApp] Bad config encountered during initialization:\n  [C 17:47:19.194 NotebookApp] No such notebook dir: ''C:\\work\\ml\\work\\notebooks''\n\n'C:\\work\\ml\\work\\notebooks' is a folder path in my computer'. But what has jupyter anything to do with it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":302,"Q_Id":58201423,"Users Score":2,"Answer":"Jupyter notebook renders a page showing the directory structure which you might or might not had mentioned it during the installation. Also your location might not exist. \nUse jupyter notebook config file:\nOpen cmd \nrun jupyter notebook --generate-config.\nA fike is created at C:\\Users\\username.jupyter\\jupyter_notebook_config.py.\nOpen the above file in editor\nSearch for the following line in the file: #c.NotebookApp.notebook_dir = ''\nReplace by c.NotebookApp.notebook_dir = '\/the\/path\/to\/home\/folder\/'\nMake sure you use forward slashes in your path and use \/home\/user\/ instead of ~\/ for your home directory, backslashes could be used if placed in double quotes even if folder name contains spaces as such : \"D:\\yourUserName\\Any Folder\\More Folders\\\"\nRemove the # at the beginning of the line to allow the line to execute","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":58202669,"CreationDate":"2019-10-02T12:21:00.000","Title":"Strange issue with Jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running into problems using tensorflow 2 in VS Code. The code executes without a problem, the errors are just related to pylint in VS Code. \nFor example this import from tensorflow.keras.layers import Dense gives a warning \"Unable to import 'tensorflow.keras.layers'pylint(import-error)\". Importing tensorflow and using tf.keras.layers.Dense does not produce an error. I'm just using a global python environment (3.7.2) on Windows 10, tensorflow is installed via Pip.","AnswerCount":5,"Available Count":1,"Score":0.1586485043,"is_accepted":false,"ViewCount":11921,"Q_Id":58202095,"Users Score":4,"Answer":"I too faced the same issue. I solved it by installing keras as a new package and then I changed all packages name removing the prefix tensorflow.. So in your case after installing keras you should replace tensorflow.keras.layers with keras.layers","Q_Score":10,"Tags":"python,tensorflow,keras,visual-studio-code","A_Id":59021516,"CreationDate":"2019-10-02T13:02:00.000","Title":"Can't import tensorflow.keras in VS Code","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've created a virtual enviornment (deepnlp) and installed the deeppavlov package in the virtual env. I could run \"import deeppavlov\" without any problem on the command line in the env. But when I tried to do the same thing ('import deeppavlov') in the jupyter notebook, in the kernel 'deepnlp', but I got the error mesaage:\nTraceback (most recent call last):\n  File \"\", line 1, in \nModuleNotFoundError: No module named 'deeppavlov'\nHas anyone encountered the same problem and found out the solution? This problem may or may have to do with the package 'deeppavlov'. It could be because something else.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1644,"Q_Id":58207216,"Users Score":0,"Answer":"As far as I know, installing a package to virtualenv has nothing to do with your Jupyter (unless the same interpreter is used in both cases). The solution would be to run the following command in jupyter cell:\nimport sys\n!{sys.executable} -m pip install --user deeppavlov","Q_Score":0,"Tags":"python,jupyter-notebook,virtualenv","A_Id":58221835,"CreationDate":"2019-10-02T18:21:00.000","Title":"ModuleNotFoundError: No module named 'deeppavlov' in jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am facing a really unexpected error and I am wondering if anybody else has had that before.\nThe setup I am using is the following: macOS 10.14.6 with Python 3.7\nI am also using ipython and spyder, but its unrelated to my problem as it happens in the normal python shell, as well.\nI have a module called FLAP and several submodules which all rely on the main FLAP module. They are in the same directory called git-repos. I added git-repos to the PYTHONPATH in spyder (or to sys.path in python shell).\nIf I only have the spyder's ipython shell or just a python shell opened, I can import my own modules.\nAs soon as I open the git-repos folder with e.g. Commander One, python cannot import the modules. I also tried using the Sourcetree git client, that induced the same thing. If I exit the folder in the Commander One app, then it can be imported again after restarting the python shell.\nFurthermore, I find it strange that it doesn't happen with macOS's Finder and also doesn't happen with installed packages like matplotlib or numpy.\nI think it is also important to mention, that the whole directory is in a Google Drive Filestream mounted into \/Volumes.\nHave you guys ever seen this kind of problem before?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":58207355,"Users Score":1,"Answer":"It turned out that you cannot do the following in macOS:\n\nHave your module directory in a Google Drive File Stream and\nHave that directory in the PYTHONPATH and\nOpen the same directory in e.g. Commander One and\nBe able to import the module in python\n\nYou can do 3. OR 4. but not 3. AND 4. If condition one is not true then you can import the module no matter what.\nThis is a bug in the macOS Google Drive software. The folder seems to be locked down when it is opened in another app (not Finder) and thus the python shell cannot find it.\nAt the end I moved the folder from the Google Drive onto my drive and I can import it no matter what. I fired up a crontab record so it would backup my codes regularly to the drive. \nI spent three days on trying to find the source of the error. I think this could help other people who face this very specific issue.","Q_Score":0,"Tags":"python,macos,import,module,spyder","A_Id":58208192,"CreationDate":"2019-10-02T18:29:00.000","Title":"Cannot import my own module in python if its folder is opened in another application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Package management and juggling pip, anaconda, PPAs, and virtual-environments is difficult. Somewhere in my constellation of dependencies, things are broken. I'm on Ubuntu 18.04. As far as I know, I cannot fix these dependencies by hand.\nThe problem, for what it's worth: I've been unable to use tensorflow for a few months. Every time I try to fix it, even uninstalling and reinstalling everything to the best of my knowledge, things still don't work. After sinking enough hours, I'm looking for a \"nuclear solution\".\nWhat I would like to do is cleanly remove everything except Python and any Python packages my system might require, so that I can start fresh (and hopefully do things properly.)\nSo, my question: How can I systematically clean up or remove my Python installation? I want to wipe everything and start anew. Does there exist a systematic guide, or a smart and reputable script that does this?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":24080,"Q_Id":58209488,"Users Score":3,"Answer":"You can try sudo apt purge python-pip python-dev, or python3 and python3-pip if you're using Python 3. This must remove all files\/folders created by the installed packages. But I'm not really sure you need to do it. \nThe better solution is just to uninstall all pip packages, like pip freeze | xargs pip uninstall -y. Just to be sure you can even remove pip folder \/usr\/lib\/python2.7\/site-packages manually (or similar folder for Python 3).","Q_Score":12,"Tags":"python,pip,anaconda,apt","A_Id":58209958,"CreationDate":"2019-10-02T21:17:00.000","Title":"How do I completely clean-up or reset a Python installation on Ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have installed the tkcalendar and xlwt using pip3 install tkcalendar and pip3 install xlwt which is successful and have up to date versions.\nRunning the code using the command as python3 \/home\/pi\/programename.py works perfectly \nUsing sudo before the command like sudo python3 \/home\/pi\/programename.py fails with error\n\nImportError: No module named tkcalendar.\n\nInstlling tkcalendar module using sudo apt-get install tkcalendar gives error like E:Unable to locate package tkcalendar. Please help me how to install the package and clear the error.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":9471,"Q_Id":58213119,"Users Score":2,"Answer":"Try again with\n\npip install tkcalendar\n\nIf you use python 3:\n\npip3 install tkcalendar\n\nAnd check with:\n\nfrom tkcalendar import Calendar","Q_Score":0,"Tags":"python-3.x,import,sudo,xlwt,tkcalendar","A_Id":58420380,"CreationDate":"2019-10-03T06:00:00.000","Title":"NO MODULE NAMED TKCALENDAR","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Problem:\n1) Need a python library which accepts path of file instead of opening the file(as it can be huge) to make a PUT request.\n2) Also want that library to automatically do the redirect if exists(Requests library does that)\nThe shell command for this is curl -T\nI've tried requests, it does redirect but needs to open file to send the file. Same is the case for pyCurl. The only alternative left is running a shell command in the python code.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":283,"Q_Id":58213185,"Users Score":0,"Answer":"In pycurl, both READDATA and READFUNCTION should stream the data from the open file. As pointed out in the comments, opening the file is required to do anything with its contents.\nIn general you can verify that your program is streaming data rather than reading the file in memory by monitoring its memory usage while it is executing and providing it with a large input file (e.g. > 100 MB).","Q_Score":0,"Tags":"python,api,curl,python-requests,pycurl","A_Id":58369834,"CreationDate":"2019-10-03T06:06:00.000","Title":"How to upload file by PUT on python without opening the file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a django project which is working fine. However, this question can be related to any django project.\nDjango works in a way that after running python manage.py runserver the project is accessible at localhost:8000. But when you deliver the project to the customer you cannot expect them to open command windows every time, then run python manage.py runserver, then open a browser, then type localhost:8000 and etc.\nI have heard docker might be a solution to this. But docker will need the scripts available in the local machine. I am talking about making a full installation file like when you buy a video game and the scripts are not accessible easily (seems there are binary files).\nThe real question is how can we protect our code and scripts and be sure they cannot be accessed easily after we have installed them in a customer's computer?\nEdit: My client is the service provider who will host the project for its own clients. That is why I am seeking to deliver the project in a way that is at least different from just copying and pasting everything.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1032,"Q_Id":58216039,"Users Score":0,"Answer":"Django is webdevelopment framework. So it enables you to make web applications, not native apps (like the video games you've mentioned).\nOnce you feel you have a releasable product (build with django) and you would like your customers to acces your django website\/application you should deploy it to a public server\/host. That way your customers only need to open there browsers and go to your application. \nYou can do this a 100 different ways with a 1000 different setups, depending on the usage and complexity of your (web)application. To do this you need to know a little bit about system administration. There are a ton of tutorials online on how to deploy django projects.\nMost important for you to learn is that you build a webapplications with Django wich can be taken in production by publishing it on the web and not by downloading some .exe file.","Q_Score":1,"Tags":"python,django,docker,installation","A_Id":58216284,"CreationDate":"2019-10-03T09:20:00.000","Title":"What is the best way to deliver django project as a full installation file (setup.exe) to be user-friendly and not revealing your whole scripts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Recently I researched python language and so many people complain about the speed of the language. I was wondering can this language be made faster?","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":336,"Q_Id":58217310,"Users Score":5,"Answer":"It doesn't make sense to ask talk about the speed of a programming language. A programming language is a set of abstract mathematical rules and restrictions. It is a specification. A piece of paper, essentially.\nA piece of paper doesn't have a speed in the sense we are talking about here.\nIn order to execute some program written in the programming language, the language needs to be implemented. Furthermore, you need to write a program which you can execute. And you need to execute this program in some specific environment (CPU, RAM, OS, machine architecture, \u2026)\nThen, and only then can you measure how long it takes to run.\nBut now you are measuring many variables:\n\nthe program\nthe environment\nthe implementation\nthe specific version of the implementation\nthe language\n\nSince you have so many variables and only one datapoint, it is impossible to tell which variable contributed which amount to the result.\nMany Python benchmarks I see use CPython running on Linux on an Intel AMD64 CPU. This benchmark is a little unfair, however:\n\nCPython is actually a very simple implementation. It does not use any of the optimizations that are typically used in high-performance language engines, such as adaptive optimizations, speculative inlining, polymorphic inline caching, dynamic type feedback, de-virtualization, escape detection, to name just a few.\nLinux, like almost all modern operating systems, is not specially optimized for running Python-like languages. It is more optimized for C-like languages. For example, Linux has virtual memory, which is known to have a negative performance impact on garbage collection.\nIntel AMD64 CPUs are not specially optimized for running Python-like languages. They are more optimized for C-like languages. For example, they contain optimizations which don't really help Python, when that die space and those transistors could be better spent on Python-specific optimizations.\n\nCheck out, for example, the design of the Azul Vega-3 CPU and the corresponding Operating System, both of which were specially designed for running memory-safe, pointer-safe, type-safe languages with garbage collection, dynamic dispatch, and a high degree of runtime polymorphism.\nIf you want a fair comparison between, for example Python and C, you need to run your Python code on a Python implementation that has the same amount of research, engineering, development, man-power, money, and resources poured into it as a C implementation (such as Microsoft Visual C, Clang\/LLVM, GCC, etc.) on an Operating System that is equally optimized for running Python, on a CPU that has the same amount of research, engineering, development, man-power, money, and resources poured into it for making Python run fast and is produced using the same advanced processes that e.g. Intel Xeons are produced with.\nIf you spend enough research, engineering, development, man-power, money, and resources on making Python fast, then it will be fast.\nThere are lots of historical examples: there was a Lisp and Smalltalk hype in the 70s-90s, and people spent tons of money on Lisp and Smalltalk compilers and VMs, and lo and behold, those implementations became much faster. When the Self VM came out, it was competitive with many C++ implementations of the time. Then, Sun cut funding for the Self project, and during that time there was also a C++ hype, so money was spent on C++ compilers, and those became fast.\nAfter that, there was a Java hype, where people spent money on JVMs. (Funnily enough, the developers of Self, after Sun cut funding, founded their own company and built a Smalltalk VM, and after realizing that Java and Smalltalk were very similar, they built a JVM. This JVM was so fast that Sun bought the company to get access to the JVM technology that they would have had for free, if they hadn't pushed the developers out of the company in the first place.) Oracle HotSpot is still based on the codebase of the Animorphic Smalltalk VM written by the former Self developers.\nNow, we are currently in an ECMAScript hype, and as soon as companies started pouring money into ECMAScript engines, those became literally ten times faster in the span of just a few years. (One of the drivers of this was Google with its V8 engine, which was actually designed by some former Self developers who had left Oracle to form their own company.)\nThere are some quite fast Python execution engines out there. I personally am looking forward to GraalPython. And I suspect if people started throwing money at Python implementations, they would also find that there is still a lot of potential for improvement. For example, TruffleRuby (built by the same people) has shown that it can beat C in some cases, and the team working on it is actually tiny compared to e.g. Microsoft Visual C or Clang\/LLVM.","Q_Score":0,"Tags":"python","A_Id":58217425,"CreationDate":"2019-10-03T10:35:00.000","Title":"Can Python language be the fastest language in future?","Data 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 safely uninstall Python 2.7.10 from MacOS 10.14.6 or higher? \nI have already installed Python 3.7.4 and I want to use only this version.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":334,"Q_Id":58220681,"Users Score":2,"Answer":"Do not remove python 2.7. You can change your preferences to which one to use with certain programs but there are a lot of dependencies on OS that need python 2.7 to run.","Q_Score":0,"Tags":"python,python-3.x,macos,python-2.7,uninstallation","A_Id":58221084,"CreationDate":"2019-10-03T13:54:00.000","Title":"Uninstall Python 2 from Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I recently switched from PyCharm to VS Code, and get a lot of error messages from PyLint for globally declared variables(parameters read out of a json file). The same file doesnt show any errors in PyCharm, and the code runs without problems. Whats PyLints problem here?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":58221628,"Users Score":0,"Answer":"PyLint mainly checks for code style. They are not necessarily errors, instead think of them as suggestions. I'm guessing you just didn't have PyLint added to your PyCharm so you haven't encountered these before.","Q_Score":0,"Tags":"python,visual-studio-code,pylint","A_Id":58221759,"CreationDate":"2019-10-03T14:47:00.000","Title":"PyLint highlighting globally declared variables as undefined","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make something like this: I will have list of email and password of a certain website. I want to check that email and password work for that website. I want it to go put that email and password in email and password box of certain website. If that logged in then it will say Logged in else not logged in.\nCan I built it with Python module called Scrapy?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":58222912,"Users Score":0,"Answer":"Yes, you can.\nWhether Scrapy is the best choice for your use case depends on the details you have not shared.","Q_Score":0,"Tags":"python-3.x,scrapy","A_Id":58410314,"CreationDate":"2019-10-03T15:59:00.000","Title":"Can Python Scrapy module help us to make an account checker?","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 visualize music into an image by using sounddevice to input the sound and then converting it to a numpy array. \nThe array is 2D and so I convert it to 3D (otherwise I only get a single thin vertical line in the image). \nHowever when I use PIL to show the image it says 'Cannot handle this datatype'\nThe code is mentioned below:\nimport sounddevice as sd \nfrom scipy.io.wavfile import write\nimport soundfile as sf\nimport numpy\nfrom numpy import zeros, newaxis\nfrom PIL import Image\nfs = 44100  # Sample rate\nseconds = 3 # Duration of recording\nmyrecording = sd.rec(int(seconds * fs), samplerate=fs, channels=2)\nsd.wait()  # Wait until recording is finished\nprint(myrecording)\nprint(numpy.shape(myrecording))\nwrite('output.wav', fs, myrecording)  # Save as WAV file\nfilename = 'output.wav'\nA=myrecording[:,:,newaxis]\nprint(A)\nim = Image.fromarray((A * 255).astype(numpy.uint8))\nim.show()\nI expect to get an image which shows colours corresponding to the sound being inputted in","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":58223453,"Users Score":0,"Answer":"This depends a little bit on what you want to do.\nYou have two channels with n-samples ((nsamples, 2) ndarray); do you want each channel to be a column of the image where the color varies depending on what the value is? That is why you were getting a very narrow image when you just plot myrecording.\nYou do not really have the data to create a full 2D image, unless you reshape the time series data to be something more like a square (so it actually looks like an image), but then you sort of lose the time dependence nature that I think you are going for.","Q_Score":0,"Tags":"python-3.x,numpy,python-imaging-library","A_Id":58225796,"CreationDate":"2019-10-03T16:36:00.000","Title":"How to fix 'Cannot handle this data type' while trying to convert a numpy array into an image using PIL","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a  caltech101 dataset for object detection. Can we detect multiple objects in single image using model trained on caltech101 dataset?\nThis dataset contains only folders (label-wise) and in each folder, some images label wise.\nI have trained model on caltech101 dataset using keras and it predicts single object in image. Results are satisfactory but is it possible to detect multiple objects in single image?\nAs I know some how regarding this. for detecting multiple objects in single image, we should have dataset containing images and bounding boxes with name of objects in images.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":233,"Q_Id":58225543,"Users Score":0,"Answer":"The dataset can be used for detecting multiple objects but with below steps to be followed:\n\nThe dataset has to be annotated with bounding boxes on the object present in the image\nAfter the annotations are done, you can use any of the Object detectors to do transfer learning and train on the annotated caltech 101 dataset\n\nNote: - Without annotations, with just the caltech 101 dataset, detecting multiple objects in a single image is not possible","Q_Score":0,"Tags":"python,keras,deep-learning,object-detection,tensorflow-datasets","A_Id":58337978,"CreationDate":"2019-10-03T19:17:00.000","Title":"Can we detect multiple objects in image using caltech101 dataset containing label wise images?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script and used it to create a dataframe in Power BI. \nNow I want to edit that dataframe in Power BI but don\u00b4t enter from scratch as new data because I want to keep all the charts inside my Power BI model.\nFor example in my old dataframe i specified some dates inside my script so the information was limited to those dates. Now i want to change the dates to new ones but dont want to lose all the model.\ndf = df","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3747,"Q_Id":58226050,"Users Score":0,"Answer":"You can edit the python scripts doing the following steps:\n\nOpen Query Editor\nAt 'Applied steps', the first one, source, contains a small gear symbol just on the right side, click on it.\n\nYou can change the script direct into Power Query.","Q_Score":2,"Tags":"python,powerbi","A_Id":60456032,"CreationDate":"2019-10-03T19:53:00.000","Title":"Edit python script used as Data entry in Power BI","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The autofunction works perfectly on my local machine but on server it does not show anything. I check the log and find the following thing,\nWARNING: autodoc: failed to import function blablabla; the following exception was raised: No module named 'numpy'.\nI suppose installing packages is not a must on sphinx. I only need sphinx to read my docstring and generate documentation.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":58226465,"Users Score":0,"Answer":"Well, after several hours of investigation I am able to answer my question. Using autodoc_mock_imports does the trick.","Q_Score":1,"Tags":"python-sphinx","A_Id":58226731,"CreationDate":"2019-10-03T20:29:00.000","Title":"sphinx autofunction works fine on local but not on server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am confused with the use of * in python, sometimes it duplicates and sometimes it multiply. Is there a rule of thumb to follow here?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":89,"Q_Id":58229821,"Users Score":1,"Answer":"If both operands for * are numbers then the result is another number. If one operand is a string and the other is a number then it is the string repeated the given number of times.","Q_Score":0,"Tags":"python","A_Id":58229850,"CreationDate":"2019-10-04T04:14:00.000","Title":"Asterisk for multiplication and duplication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to insert a column in an existing excel on Sikuli python ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":58229875,"Users Score":0,"Answer":"You can use excellibrary to add column ,\nDo by using pandas in python and then import that file to robot framework","Q_Score":0,"Tags":"python,excel,sikuli","A_Id":64276347,"CreationDate":"2019-10-04T04:24:00.000","Title":"How to insert a column in an existing excel on Sikuli python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use the concept of spam classification and apply it to a business problem where we identify if a vision statement for a company is good or not. Here's a rough outline of what I've come up with for the project. Does this seem feasible?\n\nPrepare dataset by collecting vision statements from top leading companies (i.e. Fortune 5000)\nLet features = most frequent words (excluding non-alphanumerics, to, the, etc)\nCreate feature vector (dictionary) x of all words listed above\nUse supervised learning algorithm (logistic regression) to train and test data\nLet y = good vision statement and return the value 1; y = 0 if not good","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":58229976,"Users Score":0,"Answer":"I'm skeptical. The reason simple Bayesian filtering works for spam is that spam messages typically use a quite different vocabulary than legitimate messages.\nAnecdotally, people who sell pharmaceuticals use the same words and phrases in their legitimate business correspondence as in some types of spam; so they get bad filtering results on pharma spam, while the spam filter quickly learns to correctly discard dating, Nigerian fraud, stock scams etc. (Pharma spam might still contain various hyperbolic phrases etc which set them apart even from non-spam marketing messaging, though.)\nBusiness bullshit lingo tends to look the same whether the underlying plan is sound or not. You may be able to filter out the worst gibberish, but word-token level analysis is simply not a good indicator of whether actual sound thought went into composing those words into a particular arrangement.","Q_Score":0,"Tags":"python,nlp,classification,text-classification","A_Id":58232793,"CreationDate":"2019-10-04T04:37:00.000","Title":"Using spam classification in a different application?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently started learning python I wanted to know if I can convert my python code(in pycharm) to some sort of application which can be run without the IDE on other computers.(somewhat like we can run Android application by converting them to APK and use them on phones)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9708,"Q_Id":58230132,"Users Score":0,"Answer":"One approach you can take is, use a framework like flask, Django, and host it.\nSecondly, you can use pyinstaller to make your python script into a Windows, Mac and Linux executable","Q_Score":0,"Tags":"python-3.7","A_Id":58230190,"CreationDate":"2019-10-04T04:55:00.000","Title":"How to convert python code to application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My problem is that I want to be able to upload a PHP file to my pythonanywhere server and then get its public url and use it to get notifications from a webhook to that url or specifically to the file responsible for processing those notifications. But I can't find a way to get this url and being honest is the first time I find myself using this server. Thank you and excuse my ignorance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":65,"Q_Id":58236668,"Users Score":1,"Answer":"PythonAnywhere does not support PHP.","Q_Score":0,"Tags":"pythonanywhere","A_Id":58268294,"CreationDate":"2019-10-04T12:42:00.000","Title":"How to get the public url of a 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 loadthis file.\nBut, Python3 said \"OSError: Failed to interpret file 'D:\/USER\/Downloads\/wine.data' as a pickle\".\nHow to load this file?\nThe code I used following this\ndata = np.load(\"D:\/USER\/Downloads\/wine.data\")","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":150,"Q_Id":58237039,"Users Score":0,"Answer":"I had the same problem. In my case it was the newer version of numpy that caused the problem.\nTry installing numpy version 1.12.0\npip install numpy==1.12.0","Q_Score":0,"Tags":"python-3.x,compiler-errors","A_Id":58237280,"CreationDate":"2019-10-04T13:04:00.000","Title":"OSError: Failed to interpret file 'name.data' as a pickle","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a serial data logger in Python and am wondering which data type would be best suited for this. Every few milliseconds a new value is read from the serial interface and is saved into my variable along with the current time. I don't know how long the logger is going to run, so I can't preallocate for a known size.\nIntuitively I would use an numpy array for this, but appending \/ concatenating elements creates a new array each time from what I've read.\nSo what would be the appropriate data type to use for this?\nAlso, what would be the proper vocabulary to describe this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":139,"Q_Id":58237574,"Users Score":0,"Answer":"Python doesn't have arrays as you think of them in most languages. It has \"lists\", which use the standard array syntax myList[0] but unlike arrays, lists can change size as needed. using myList.append(newItem) you can add more data to the list without any trouble on your part.\nSince you asked for proper vocabulary in a useful concept to you would be \"linked lists\" which is a way of implementing array like things with varying lengths in other languages.","Q_Score":1,"Tags":"python,types,data-acquisition","A_Id":58237688,"CreationDate":"2019-10-04T13:40:00.000","Title":"Data type to save expanding data for data logging in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to WMI(Windows management instrumentation) and trying to get files from a remote host.Seeing the wmi docs it says that WMI allows copying files, but never saw an example of it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":186,"Q_Id":58238120,"Users Score":0,"Answer":"I don't know much about WMI but you can serve your files from remote host with python using simply:\npython2\npython -m SimpleHTTPServer\nor python3\npython3 -m http.server","Q_Score":0,"Tags":"python,wmi","A_Id":58238207,"CreationDate":"2019-10-04T14:14:00.000","Title":"How to copy files from remote computer and storing them in local one using WMI 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 a Python program that can update itself from a GitHub repository. When I activate the updating process, the Python script runs updater.bash script and kills itself. The bash script updates the program and then runs it again. But it keeps running despite I put exit 0 in the end of the updater. So, every update creates another bash script that eats more resources.\nHow can I kill the script after it runs the Python script?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":58241340,"Users Score":2,"Answer":"exec python ... to replace bash with python program.\nSee: help exec","Q_Score":1,"Tags":"python,linux,bash,unix,exec","A_Id":58241389,"CreationDate":"2019-10-04T18:09:00.000","Title":"How to exit a bash script after it starts a Python process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"trying to use python3 and this library and im receiving this error ImportError: cannot import name 'format_exc'\ntried uninstalling python3 and reinstalling, im also on Ubuntu 18\nneed it to run my code, the code works but python3 does not","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":1927,"Q_Id":58241380,"Users Score":4,"Answer":"Check your filenames, for example, if you have a token.py file in your project, rename it. Its just a conflict with the filename and some libs as Alex Jadczak and Sara pointed out.","Q_Score":1,"Tags":"python,python-3.x","A_Id":62237825,"CreationDate":"2019-10-04T18:12:00.000","Title":"ImportError: cannot import name 'format_exc' Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Once you commit in pycharm it takes you to a second window to go through with the push. But if you only hit commit and not commit\/push then how do you bring up the push option. You can't do another commit unless changes are made.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":57,"Q_Id":58242568,"Users Score":2,"Answer":"In the upper menu [VCS] -> [Git...] -> [Push]","Q_Score":0,"Tags":"python,pycharm,push,commit","A_Id":58242615,"CreationDate":"2019-10-04T20:01:00.000","Title":"How do you push in pycharm if the commit was already done?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I create a symbolic link in an external drive on my mac I create a file shown below\n\nXSym\n0077\n767acf6f896cdeab83e4f3fe919d4929\n\/Volumes\/externaldrivename\/path\/to\/audiofile\/test.wav\n\nIf I move my external drive and connect to a linux machine the path of the test.wav file would be\n\n\/media\/username\/externaldrivename\/path\/to\/audiofile\/test.wav\n\nThis causes the symbolic link to break.\nis it possible to not have the link break by somehow setting an environment path within the xSym file so that the file path would be the same on both machines?\nSpecifically with a python command?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":283,"Q_Id":58243357,"Users Score":1,"Answer":"You can create a symlink with relative path if that serves your purpose.","Q_Score":0,"Tags":"python,path,operating-system,symlink","A_Id":58243382,"CreationDate":"2019-10-04T21:27:00.000","Title":"create symlinks in external drive that doesn't break when moving between computers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"tf.boolean_mask(tensor, mask) => returns (?, 4)\nHow do I check if the returned tensor by boolean_mask is empty or not?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":422,"Q_Id":58245630,"Users Score":1,"Answer":"There are multiple ways to solve this, basically you are trying to identify a null tensor. \nPossible solutions can be:\n\nis_empty = tf.equal(tf.size(boolean_tensor), 0). If not empty it will give false\nCount non zeros number using tf.count_nonzero(boolean_tensor)\nBy simply printing the tensor and checking the vaules","Q_Score":0,"Tags":"python,tensorflow","A_Id":58316577,"CreationDate":"2019-10-05T05:32:00.000","Title":"How to know if dynamic tensor returned by \"tf.boolean_mask\" is empty or not?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"One is a pandas.core.series.Series and another is a dataframe pandas.core.frame.DataFrame. \nI have seen codes using them both. Is there a guideline on when to use which?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":58246700,"Users Score":1,"Answer":"to be more specific, df['column'] returns only one column, but when you use df[['column']] you can call more than one column.\nfor example df[['column1','column2']] returns column1 and column2 from df","Q_Score":0,"Tags":"python,pandas","A_Id":58246743,"CreationDate":"2019-10-05T08:41:00.000","Title":"What is the difference between single bracket df[\"column\"] and double bracket df[[\"column\"]]","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently have Airflow set up and working correctly using the CeleryExecutor as a backend to provide horizontal scaling. This works remarkably well especially when having the worker nodes sit in an autoscaling group on EC2.\nIn addition to Airflow, I use plain Celery to handle simple asynchronous tasks (that don't need a whole pipeline) coming from Flask\/Python. Until now, these plain Celery tasks were very low volume and I just ran the plain Celery worker on the same machine as Flask. There is now a requirement to run a massive number of plain Celery tasks in the system, so I need to scale my plain Celery as well.\nOne way to do this would be to run the plain Celery worker service on the Airflow worker servers as well (to benefit from the autoscaling etc.) but this doesn't seem to be an elegant solution since it creates two different \"types\" of Celery worker on the same machine. My question is whether there is some combination of configuration settings I can pass to my plain Celery app that will cause @celery.task decorated functions to be executed directly on my Airflow worker cluster as a plain Celery task, completely bypassing the Airflow middleware.\nThanks for the help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":914,"Q_Id":58247023,"Users Score":0,"Answer":"The application is airflow.executors.celery_executor.app if I remember well. Try celery -A airflow.executors.celery_executor.app inspect active for an example in your current Airflow infrastructure to test it. However, I suggest you do not do this because your Celery tasks may affect the execution of Airflow DAGs, and it may affect the SLAs.\nWhat we do in the company I work for is exactly what you suggested - we maintain a large Celery cluster, and we sometimes offload execution of some Airflow tasks to our Celery cluster, depending on the use-case. This is particularly handy when a task in our Airflow DAG actually triggers tens of thousands of small jobs. Our Celery cluster runs 8 million tasks on a busy day.","Q_Score":1,"Tags":"python,flask,celery,airflow","A_Id":58247402,"CreationDate":"2019-10-05T09:30:00.000","Title":"How to execute plain Celery tasks on Airflow workers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"So, here is my question's overview:-\nI basically want to login into azure account. I have created my azure login credentials from azure portal. And now i want to login into azure account but not from portal.azure.com site, I want to login through a webapp which i have developed using Django.\nI have a webapp developed which has login and password textbox on my django site, now i want to enter my azure credentials here on this webapp and it should also get logged in on azure portal, rendering azure portal after login is not necessary.\nCould anyone help me out here?\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":198,"Q_Id":58248230,"Users Score":1,"Answer":"What you are asking for isn't really possible.\nThe ROPC flow could be used to acquire access tokens to APIs using a user's credentials. \nThat won't setup single sign-on though. \nThat requires interactive authentication on the Azure AD login page, so that it can set the cookie to track the SSO session. \nNow if you want to access certain things on behalf of a user in your app, you can authenticate the user with one of the authentication flows offered by Azure AD. \nAuthorization code flow \/ hybrid flow will probably work for your app. \nBut don't use ROPC. \nYou should not be handling user credentials. \nIt also won't work if the user has MFA and in some other cases. \nThen once you have authenticated the user, you can get an access token to call the Azure Resource Management API or any other APIs that are available to your app.","Q_Score":2,"Tags":"python,django,azure,authentication,web-applications","A_Id":58250894,"CreationDate":"2019-10-05T12:21:00.000","Title":"Azure login using Django webapp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I have a trained model, that was trained on a standardized dataset. When I try to use the model for testing on new data, that isn't in a dataset and that isn't standardized, it returns ridiculous values, because I can standardize the inputs, but I can't inverse transform the output as I did during training. What should I do?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":277,"Q_Id":58248367,"Users Score":0,"Answer":"Use sc.inverse_transform(predicted)","Q_Score":0,"Tags":"python-3.x,scikit-learn,neural-network,deep-learning,sklearn-pandas","A_Id":59757240,"CreationDate":"2019-10-05T12:38:00.000","Title":"How to inverse transform models output?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have previously installed python 3.7, anaconda3 and jupyter notebook.\nThen I tried to install opencv library using the following command.\npip install opencv-python\nand it said,\n\nRequirement already satisfied: opencv-python in c:\\programdata\\anaconda3\\lib\\site-packages (4.1.1.26)\n\nWhen I tried to import open-cv library from IDLE it gives the following error.\n\nModuleNotFoundError: No module named 'cv2'.\n\nBut when I run it from the jupyter notebook it works. \nThe reason for this as I see is that the packages are installed in the anaconda3 folders but not in the python folders.\nHow can I install packages in python folders? As I need to run this from the IDLE.\nI'm using python 3.7.1 on windows 10.\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2922,"Q_Id":58250770,"Users Score":0,"Answer":"what IDLE are u using for program in python? If you are using Python IDLE, usually when you import packages, are installed in C:\\Users\\Your_Username\\AppData\\Local\\Programs\\Python\\Python37-32\\Lib\nIf you want to install a package in other folder, try to use this \npip install --target=C:\\path\\to\\folder\\ opencv-python\nIf you have another IDLE, put me in the comments what is it (PyCharm, VSCode...).","Q_Score":0,"Tags":"opencv,module,pip,anaconda,python-idle","A_Id":58251351,"CreationDate":"2019-10-05T17:36:00.000","Title":"ModuleNotFoundError: No module named 'cv2' How can I install packages in python folders? rather than in anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have running code in my home directory in Jupyter notebook. I'd like to import some data from an external drive, as the data is too large to be stored on my local drive. I am unable to import this data into my notebook.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":990,"Q_Id":58250882,"Users Score":0,"Answer":"If you can browse to the data using Finder, you should be able to load the data into your Jupyter notebook.\nYour code to open a file in your notebook probably looks something like this:\nwith open(\"data.txt\",\"r\") as dataFile:\nYou need to replace data.txt with the path to the file you want to open. \nOne way to get the path name is to navigate to the file in Finder and then drag the file into your Terminal. The path to the file will then be pasted into the command prompt of the Terminal.\nThe path may look something like this:  \/Volumes\/Remove\/Data\/bigfile.txt\nYou can also navigate to the file using the cd command in the Terminal.\nYou may even be able to drag the file directly into your Jupyter notebook to get the path.  \nHope this helps!","Q_Score":1,"Tags":"python-3.x,jupyter-notebook","A_Id":58251069,"CreationDate":"2019-10-05T17:50:00.000","Title":"How can I load data from an external drive into a Jupyter notebook on MacOs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to fetch location based on lat and long. I have a data of 600K in my csv and I am trying to run my for loop on it . My notebook is taking very long time to process the data. ( 40min to complete 2percent)\nI have decent laptop  Core i7-8550U quad-core 1.8GHz and 16GB DDR4 RAM . \nI am not sure how to optain the result for my data quickly .Pls help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10,"Q_Id":58253000,"Users Score":0,"Answer":"Do you have sample code of what you are doing ? Are you reading your file every time you fetch a latitude and longitude  If this is the case this is why it takes so long. First load the file in your memory as a pandas object for example and then you should be able to look for your data much faster.","Q_Score":0,"Tags":"python,dataframe,for-loop,data-analysis","A_Id":58253014,"CreationDate":"2019-10-05T23:06:00.000","Title":"File progress for long duration","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"MY cmd doesn't show that Python is installed and gives me an error \nI changed the PATH and it's this--> C:\\Users\\sewmini\\Documents\\Python\nThe error I get is \"'python' is not recognized as an internal or external command,\noperable program or batch file.\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":58253697,"Users Score":0,"Answer":"You must set your PATH to the python executable.\ni.e. 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python37-32\\python.exe'","Q_Score":0,"Tags":"python","A_Id":58253709,"CreationDate":"2019-10-06T01:58:00.000","Title":"How to change the PATH of python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there any way I can extract MS Word file data in a tree structure. What I mean by is that the document file has heading, paragraph, and table. I'd like to extract that information in the hierarchy of headings. Not sure what's the best approach. Can anyone share their experience of parsing a word document with python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":317,"Q_Id":58254173,"Users Score":1,"Answer":"Headings, or \"section headings\" in printing parlance, are not container objects in Word; they are each simply a paragraph object with formatting that causes them to appear as a section heading, often a bold and somewhat bigger font than the body text.\nSo whatever approach you take, there is a certain possibility of missing a \"boundary\" that a reader would perceive.\nThe best approach depends a bit on the documents you'll be working with. In the best case, each section is started with a paragraph having one of the Heading {n} styles, like \"Heading 1\" and \"Heading 2\". Then you can just proceed through the paragraphs checking each for one of those styles and populate your hierarchy accordingly. There are good reasons why an author might stick to this discipline because it makes forming a table-of-contents (TOC) much easier.\nOtherwise you'll need to look for other reliable markers indicating the start of a new section.\nNote that Word also has a concept of \"section\" which is quite different than how I'm using the word here. In Word, a section is a contiguous block of pages that share the same page format (like margins, portrait\/landscape, etc.). In publishing parlance, a section is a subdivision of a chapter or similar block that has a heading (but generally not a page break) and may itself be divided into sub-sections each level with a smaller heading.","Q_Score":0,"Tags":"python,xml,ms-word,python-docx","A_Id":58254346,"CreationDate":"2019-10-06T04:18:00.000","Title":"Python: Extract MS Word data in a tree structure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"for example i have a image dataset. I used these images for train my model, and I am using another image for test. How can i recognize the test image is on the dataset? How do I determine what the similarity percentage is?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":58255567,"Users Score":0,"Answer":"you can try correlation on both images if there exactly the same should get 1","Q_Score":0,"Tags":"python-3.x,keras,conv-neural-network","A_Id":58255664,"CreationDate":"2019-10-06T08:35:00.000","Title":"How can i recognize two picture are same?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are there any method where I can upsert into a SQL datawarehouse table ?\nSuppose I have a Azure SQL datawarehouse table :\ncol1   col2    col3 \n2019   09       10\n2019   10       15\nI have a dataframe \ncol1  col2   col3\n2019   10     20\n2019   11     30\nThen merge into the original table of Azure data warehouse table \ncol1 col2 col3\n2019 09    10 \n2019 10    20 \n2019 11    30 \nThanks for everyone idea","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":782,"Q_Id":58255818,"Users Score":0,"Answer":"you can save the output in a file and then use the stored procedure activity from azure data factory for the upsert. Just a small procedure which will upsert the values from the file.  I am assuming that you are using the Azure data factory here.","Q_Score":1,"Tags":"python,databricks","A_Id":58305335,"CreationDate":"2019-10-06T09:13:00.000","Title":"Databricks: merge dataframe into sql datawarehouse table","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Trying to get Firefox Portable v46 to function in headless mode. (only portable version that works)\nChrome portable can do this but I would like to know if firefox portable can.\nI must include capabilities_argument[\"marionette\"] = False otherwise an exception is thrown:\nselenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities\nIn normal Firefox (not portable + recent version) ... disabling marionette also causes ops.add_argument(\"--headless\") to fail ... this is why I believe disabling marionette is the issue.\nos.environ['MOZ_HEADLESS'] = '1' ... Does not work either.\nbrowser.set_window_position(-3000, 0) ... works, but only after being visible\nI am also running multiple instances of firefox, hiding from task manager might not be an option.\nIs there a way I can import marionette or get it to work somehow?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":217,"Q_Id":58257620,"Users Score":0,"Answer":"I have discovered that (in windows), once Firefox (most recent gecko-driver compatible version) is installed, the folder in which firefox.exe is kept, is portable.\nThe folder can be transferred to any windows machine even if it has never had Firefox installed. And the folder containing Firefox.exe will run Firefox successfully\nThis is the same with Chrome","Q_Score":0,"Tags":"python-3.x,selenium,geckodriver,selenium-firefoxdriver","A_Id":58266615,"CreationDate":"2019-10-06T13:19:00.000","Title":"python - selenium firefox portable headless fails","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If I freeze my base_model with trainable=false, I get strange numbers with trainable_weights.\nBefore freezing my model has 162 trainable_weights. After freezing, the model only has 2. I tied 2 layers to the pre-trained network. Does trainable_weights show me the layers to train? I find the number weird, when I see 2,253,335 Trainable params.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":3554,"Q_Id":58258312,"Users Score":1,"Answer":"Trainable weights are the weights that will be learnt during the training process. If you do trainable=False then those weights are kept as it is and are not changed because they are not learnt. You might see some \"strange numbers\" because either you are using a pre-trained network that has its weights already learnt or you might be using random initialization when defining the model. When using transfer learning with pre-trained models a common practice is to freeze the weights of base model (pre-trained) and only train the extra layers that you add at the end.","Q_Score":1,"Tags":"python,keras,deep-learning,conv-neural-network,transfer-learning","A_Id":58258675,"CreationDate":"2019-10-06T14:38:00.000","Title":"What is the meaning of \"trainable_weights\" in Keras?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to start a new process using the subprocess module. I'd like the stdin to be a stream that never sends anything but also doesn't terminate. Basically the same kind of input stream that a program would get if I were to launch it in the shell and not type anything, ever. Is that possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":58258365,"Users Score":0,"Answer":"Pass stdin=subprocess.PIPE to the Popen constructor, and then avoid doing anything -- like calling communicate() -- which would later close that FIFO.","Q_Score":2,"Tags":"python,subprocess","A_Id":58258398,"CreationDate":"2019-10-06T14:45:00.000","Title":"Python subprocess: Start a process with a `stdin` that doesn't close","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Trying to run the python-telegram-bot library through Jupyter Notebook I get this question error. I tried many ways to reinstall it, but nothing from answers at any forums helped me. What should be a mistake and how to avoid it while installing?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":942,"Q_Id":58259708,"Users Score":1,"Answer":"Do you have a directory with \"telegram\" name? If you do,rename your directory and try it again to prevent import conflict.\ngood luck:)","Q_Score":0,"Tags":"telegram-bot,python-telegram-bot","A_Id":58888596,"CreationDate":"2019-10-06T17:33:00.000","Title":"ModuleNotFoundError: No module named '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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making an experiment where a participant see's 1 image, a mask, then another image and needs to make a button press while the 3rd image is on the screen and the experiment should not move on until they make a response.\nI am not sure if i should use 1 routine and specify the start time of the wait for response to be after the first two images are shown, or do i make two different routines within a loop, where the second routine has the wait for response?\nI have tried making three separate routines one for each of the images i want to show, but i get an error where the third routine with the wait for response can't find the conditions file i specified in the loop.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":58260164,"Users Score":0,"Answer":"You have flexibility to do things a number of ways here. The simplest, though, would be a single routine:\n\nspecified onset time and duration for both the first image and the mask. \nspecified onset time for the second image but no offset time specified (so it will be visible indefinitely).\nspecified onset time for the keyboard component and no offset time specified, but have that component set to \"Force end of routine\".","Q_Score":1,"Tags":"python,python-2.7,loops,response,psychopy","A_Id":58260910,"CreationDate":"2019-10-06T18:30:00.000","Title":"make psychopy builder wait for a response after every 3 images","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an application that uses two servers that need to communicate with one another. One is a python server that implements BaseHTTPRequestHandler's do_METHODs. The other is node js's development server\/production server that hosts a React JS application.\nThe node js application uses a POST request to get a message from an input which the python server extracts that message from that POST request and then calls Amazon's Lex using Boto3 to get a response.\nWhenever I run node js development server (on localhost:3000) and the python server (on localhost:3001), the python server is able to recognize that a POST request has been made and goes ahead and gets a response. However, when I run node js production server (on localhost:5000) and the python server (on localhost:3001), the node js server is unable to communicate with the python server. Why is this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":243,"Q_Id":58262399,"Users Score":0,"Answer":"After much research, I felt like having two local applications running on different ports is a little impractical or rather more complicated than it should be. \nAs such, I have migrated my project to use Django instead of using React JS and integrate it with python. This way Django's back-end can handle the POST requests I make and update the DOM as needed. \nAll this is for a chatbot application that is suppose take a user's question, call Amazon's Lex for a intent and entity which then spaCy, a ML framework, searches our database for an answer. The answer is then returned and the DOM is then updated without refreshing the page.","Q_Score":1,"Tags":"python,node.js,reactjs","A_Id":58384477,"CreationDate":"2019-10-07T00:51:00.000","Title":"Communicate between a python server and node server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to use the paramiko and boto3 libraries in Python to transfer files from a S3 bucket to an Unix server. Currently I am able to achieve this by bringing the file to local by using the download method. Then i will use the ftp client to upload the file to Unix server. Is there a simple way to do this directly from s3 to unix server without bringing the file to local?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":416,"Q_Id":58265368,"Users Score":0,"Answer":"There is hardly a simple API what will allow you to transfer a file between two remote S3 and FTP servers.\nBut of course, you can either:\n\ninitiate the download from S3 on the Unix server, or\nsetup a server on AWS that will push\/upload the file to the Unix server.","Q_Score":0,"Tags":"python,amazon-s3,sftp,boto3,paramiko","A_Id":58268330,"CreationDate":"2019-10-07T07:46:00.000","Title":"Transfer files from AWS S3 to Unix Server using SFTP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to set up a worker which handles some data after a certain event happens. I know I can start the worker with python manage.py runworker my_worker, but what I would need is to start the worker in the same process as the main Django app on a separate thread.\nWhy do I need it in a separate thread and not in a separate process? Because the worker would perform a pretty light-weight job which would not overload the server's resources, and, moreover, the effort of making the set up for a new process in the production is not worth the gain in performance. In other words, I would prefer to keep it in the Django's process if possible.\nWhy not perform the job synchronously? Because it is a separate logic that needs the possibility to be extended, and it is out of the main HTTP request-reply scope. It is a post-processing task which doesn't interfere with the main logic. I need to decouple this task from an infrastructural point-of-view, not only logical (e.g. with plain signals).\nIs there any possibility provided by Django Channels to run a worker in such a way?\nWould there be any downsides to start the worker manually on a separate thread?\nRight now I have the setup for a message broker consumer thread (without using Channels), so I have the entry point for starting a new worker thread. But as I've seen from the Channel's runworker command, it loads the whole application, so it doesn't seem like a na\u00efve worker.run() call is the proper way to do it (I might be wrong with this one).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":383,"Q_Id":58268408,"Users Score":0,"Answer":"I found an answer to my question.\nThe answer is no, you can't just start a worker within the same process. This is because the consumer needs to run inside an event loop thread and it is not good at all to have more than one event loop thread in the same process (Django WSGI application already runs the main thread with an event loop).\nThe best you can do is to start the worker in a separate process. As I mentioned in my question, I started a message broker consumer on a separate thread, which was not a good approach either, so I changed my configuration to start the consumers as separate processes.","Q_Score":1,"Tags":"python,django,multithreading,django-channels","A_Id":58323227,"CreationDate":"2019-10-07T11:11:00.000","Title":"Start a Django Channels Worker within the same process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to serialize a bytes object - which is an initialization vector for my program's encryption. But, the Google Protocol Buffer only accepts strings. It seems like the error starts with casting bytes to string. Am I using the correct method to do this? Thank you for any help or guidance!\nOr also, can I make the Initialization Vector a string object for AES-CBC mode encryption?\nCode\n\nCast the bytes to a string\n\n\nstring_iv = str(bytes_iv, 'utf-8')\n\nSerialize the string using SerializeToString():\n\n\nserialized_iv = IV.SerializeToString()\n\nUse ParseToString() to recover the string:\n\n\nIV.ParseFromString( serialized_iv )\n\nAnd finally, UTF-8 encode the string back to bytes: \n\n\nbytes_iv = bytes(IV.string_iv, encoding= 'utf-8')\n\n\nError\nstring_iv = str(bytes_iv, 'utf-8')\nUnicodeDecodeError: 'utf-8' codec can't decode byte 0x9b in position 3: invalid start byte","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":769,"Q_Id":58274046,"Users Score":1,"Answer":"If you must cast an arbitrary bytes object to str, these are your option:\n\nsimply call str() on the object. It will turn it into repr form, ie. something that could be parsed as a bytes literal, eg. \"b'abc\\x00\\xffabc'\"\ndecode with \"latin1\". This will always work, even though it technically makes no sense if the data isn't text encoded with Latin-1.\nuse base64 or base85 encoding (the standard library has a base64 module wich covers both)","Q_Score":0,"Tags":"python-3.x,utf-8,type-conversion,encryption-symmetric,protocol-buffers","A_Id":58274931,"CreationDate":"2019-10-07T16:58:00.000","Title":"Using Protocol Buffer to Serialize Bytes Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am scraping elements from a web page & I can see the element being visible (numeric value) on the web page in a grayed out box ,but when tried to inspect the element I cant find it between the  tags. I assumed the URL might be any webservice endpoint & tried to GET from postman but it returned mere HTML code not a JSON response.\nIn general, we can get values between the tags by finding the element & getting innerText attribute in selenium that too failed as there is no text in between the tags.\nI cannot post any URL or responses due to security compliance issues in my org. Please advise any other way I can work around.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":173,"Q_Id":58274532,"Users Score":0,"Answer":"Got my answer , tried running JS code \"document.querySelector('input[name=assets_tot_mfr]').value;\" and ran it through python execute_script. Thanks","Q_Score":0,"Tags":"json,python-3.x,web-scraping","A_Id":58274633,"CreationDate":"2019-10-07T17:35:00.000","Title":"Value present on browser but not available in inspect element","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am writing a slack bot, and I am using argsparse to parse the arguments sent into the slackbot, but I am trying to figure out how to get the help message string so I can send it back to the user via the slack bot. \nI know that ArgumentParser has a print_help() method, but that is printed via console and I need a way to get that string.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":84,"Q_Id":58276942,"Users Score":1,"Answer":"I just found out that there's a method called format_help() that generates that help string","Q_Score":0,"Tags":"python,python-3.x,argparse","A_Id":58276991,"CreationDate":"2019-10-07T20:48:00.000","Title":"argparse.print_help() ArgumentParser message string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does a \"sparse matrix\" mean that it contains *more than 50% 0's?\nI can't seem to locate that information.\nedit - more","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":480,"Q_Id":58277617,"Users Score":1,"Answer":"You can't locate a definition because there isn't one.  \"Sparse\" is whatever relation makes a different algorithm more efficient.  It may be a particular proportion of elements; it may be a function of the matrix side (e.g. n element in a nxn matrix); it may require zero rows or diagonals.\nIt depends critically on how you plan to alter your handling of a \"sparse\" matrix.\nWhen we learned the basics of sparse representations, we used a heuristic of 10% non-zero elements.  However, that was a particular family of OS data storage and retrieval.","Q_Score":0,"Tags":"python,matrix,sparse-matrix","A_Id":58277773,"CreationDate":"2019-10-07T21:54:00.000","Title":"What is the threshold for sparse matrices? Is it a matrix that contain less than 50% 0's?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"There will be an unordered_map in c++ dll containing some 'vectors' mapped to its 'names'. For each of these 'names', the python code will keep on collecting data from a web server every 5 seconds and fill the vectors with it.\nIs such a dll possible? If so, how to do it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":58277885,"Users Score":0,"Answer":"You can make the Python code into an executable. Run the executable file from the DLL as a separate process and communicate with it via TCP localhost socket - or some other Windows utility that allows to share data between different processes.\nThat's a slow mess. I agree, but it works.\nYou can also embed Python interpreter and run the script it on the dll... I suppose.","Q_Score":0,"Tags":"python,c++","A_Id":58279737,"CreationDate":"2019-10-07T22:25:00.000","Title":"Is it possible to have a c++ dll run a python program in background and have it populate a map of vectors? If so, how?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm initializing a model as:\nmodel = tf.keras.utils.multi_gpu_model(model, gpus=NUM_GPUS) and when I do model.compile() it runs perfectly fine.\nBut when I do history = model.fit(tf.cast(X_train, tf.float32), tf.cast(Y_train, tf.float32), validation_split=0.25, batch_size = 16, verbose=1, epochs=100), it gives me error: \n\nOOM when allocating tensor with shape[4760,256,256,3] and type float\n  on \/job:localhost\/replica:0\/task:0\/device:GPU:0 by allocator GPU_0_bfc\n  [Op:Cast] name: Cast\/\n\nThis code worked perfectly fine previously but not anymore with Tensorflow 2.0. I have 4760 samples in my training set. I don't know why it's taking the entire set instead of the batch size.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":451,"Q_Id":58277991,"Users Score":1,"Answer":"model.compile() only does configure the model for training and it doesn't have any memory allocation. \nYour bug is self-explained, you directly feed a large numpy array into the model. I would suggest coding a new data generator or keras.utils.Sequence to feed your input data. If so, you do not need specify the batch_size in fit method again, because your own generator or Sequence  will generate batches.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":58278374,"CreationDate":"2019-10-07T22:38:00.000","Title":"Tensorflow 2.0 fit() is not recognizing batch_size","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that loops through a dataset of videos and applies a face and lip detector function to each video. The function returns a 3D numpy array of pixel data centered on the human lips in each frame. \nThe dataset is quite large (70GB total, ~500,000 videos each about 1 second in duration) and executing on a normal CPU would take days. I have a Nvidia 2080 Ti that I would like to use to execute code. Is it possible to include some code that executes my entire script on the available GPU? Or am I oversimplifying a complex problem?\nSo far I have been trying to implement using numba and pycuda and havent made any progress as the examples provided don't really fit my problem well.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":81,"Q_Id":58278145,"Users Score":1,"Answer":"Your first problem is actually getting your Python code to run on all CPU cores!\nPython is not fast, and this is pretty much by design. More accurately, the design of Python emphasizes other qualities. Multi-threading is fairly hard in general, and Python can't make it easy due to those design constraints. A pity, because modern CPU's are highly parallel. In your case, there's a lucky escape. Your problem is also highly parallel. You can just divide those 500,000 video's over CPU cores. Each core runs a copy of the Python script over its own input. Even a quad-core would process 4x125.000 files using that strategy.\nAs for the GPU, that's not going to help much with Python code. Python simply doesn't know how to send data to the GPU, send commands to the CPU, or get results back. Some Pythons extensions can use the GPU, such as Tensorflow. But they use the GPU for their own internal purposes, not to run Python code.","Q_Score":0,"Tags":"python,gpu,face-detection,numba","A_Id":58915896,"CreationDate":"2019-10-07T22:56:00.000","Title":"How to execute python script (face detection on very large dataset) on Nvidia GPU","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having trouble connecting the mathematical concept of spline interpolation with the application of a spline filter in python. My very basic understanding of spline interpolation is that it's fitting the data in a piece-wise fashion, and the piece-wise polynomials fitted are called splines. But its applications in image processing involve pre-filtering the image and then performing interpolation, which I'm having trouble understanding.\nTo give an example, I want to interpolate an image using scipy.ndimage.map_coordinates(input, coordinates, prefilter=True), and the keyword prefilter according to the documentation:\n\nDetermines if the input array is prefiltered with spline_filter before interpolation \n\nAnd the documentation for scipy.ndimage.interpolation.spline_filter simply says the input is filtered by a spline filter. So what exactly is a spline filter and how does it alter the input data to allow spline interpolation?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":389,"Q_Id":58278604,"Users Score":1,"Answer":"I'm guessing a bit here. In order to calculate a 2nd order spline, you need the 1st derivative of the data. To calculate a 3rd order spline, you need the second derivative. I've not implemented an interpolation motor beyond 3rd order, but I suppose the 4th and 5th order splines will require at least the 3rd and 4th derivatives.\nRather than recalculating these derivatives every time you want to perform an interpolation, it is best to calculate them just once. My guess is that spline_filter is doing this pre-calculation of the derivatives which then get used later for the interpolation calculations.","Q_Score":2,"Tags":"python,interpolation,spline","A_Id":58283603,"CreationDate":"2019-10-08T00:10:00.000","Title":"What is the difference between spline filtering and spline interpolation?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to understand why when we were using pandas to_csv(), a number 3189069486778499 has been output as \"0.\\x103189069486778499\". And this is the only case happened within a huge amount of data.\nWhen using to_csv(), we have already used encoding='utf8', normally that would solve some unicode problems...\nSo, I'm trying to understand what is \"\\x10\", so that I may know why...\nSince the whole process was running in luigi pipeline, sometimes luigi will generate weird output. I tried the same thing in IPython, same version of pandas and everything works fine....","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2069,"Q_Id":58279018,"Users Score":0,"Answer":"Because it's the likely answer, even if the details aren't provide in your question:\nIt's highly likely something in your pipeline is intentionally producing fields with length prefixed text, rather than the raw unstructured text. \\x103189069486778499 is a binary byte with the value 16 (0x10), followed by precisely 16 characters. The 0. before it may be from a previous output, or some other part of whatever custom data serialization format it's using.\nThis design is usually intended to make parsing more efficient; if you use a delimiter character between fields (e.g. a comma, like CSV), you're stuck coming up with ways to escape or quote the delimiter when it occurs in your actual data, and parsers have to scan character by character, statefully, to figure out where a field begins and ends. With length prefixed text, the parser finds a field length and knows exactly how many characters to read to slurp the field, or how many to skip to find the next field, no quoting or escaping required, no matter what the field contains.\nAs for what's doing this: You're going to have to check the commands in your pipeline. Your question provides no meaningful way to determine the cause of this problem.","Q_Score":0,"Tags":"python,pandas,unicode,luigi","A_Id":58279203,"CreationDate":"2019-10-08T01:19:00.000","Title":"unicode vs character: What is '\\x10'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to set a variable in my Python code to different values, according to whether it is running in unit tests or in production.\nAssuming we can't pass additional parameters to the test runners, or we don't have any environment variables set in production environment.\nA_LOCAL_VARIABLE = 1 if is_running_by_pytest() else 0\nMy expectation is that by checking whether the code is running under the pytest runner, I can change the value of the variable.\nIdeally, if the code is ran by the pytest runner, there're some pre-defined environment variables that we can use to identify it. But I cannot find documentations, or I was using the wrong keywords.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":58280200,"Users Score":0,"Answer":"You can use a configuration variable. Each of our executable environments have its own configuration file. Some of our tests use different values for different environments like Single Sign On tests.","Q_Score":0,"Tags":"python,pytest","A_Id":58280376,"CreationDate":"2019-10-08T04:28:00.000","Title":"Any way to determine whether the code is running under pytest or not (i.e. in production)?","Data 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 looking for a method to implement word embedding network with LSTM layers in Pytorch such that the input to the nn.Embedding layer has a different form than vectors of words IDs.\nEach word in my case has a corresponding vector and the sentence in my corpus is consequently a vector of vectors. So, for example, I may have the word \"King\" with vector [500, 3, 18] where 500 is the Word ID, 3 is the word color, and 18 is the font size, etc. The embedding layer role here is to do some automatic feature reduction\/extraction.\nHow can I feed the embedding layer with such form data? Or do you have any better suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1159,"Q_Id":58281876,"Users Score":2,"Answer":"I am not sure what do you mean by word2vec algorithm with LSTM because the original word2vec algorithm does not use LSTMs and uses directly embeddings to predict surrounding words.\nAnyway, it seems you have multiple categorical variables to embed. In the example, it is word ID, color ID, and font size (if you round it to integer values). You have two option:\n\nYou can create new IDs for all possible combinations of your features and use nn.Embedding for them. There is however a risk that most of the IDs will appear too sparsely in the data to learn reliable embeddings.\nHave separate embedding for each of the features. Then, you will need to combine the embeddings for the features together. You have basically three options how to do it:\n\nJust concatenate the embeddings and let the following layers of the network to resolve the combination.\nChoose the same embedding dimension for all features and average them. (I would start with this one probably.)\nAdd a nn.Dense layer (or two, the first one with ReLU activation and the second without activation) that will explicitly combine the embeddings for your features.\n\n\nIf you need to include continuous features that cannot be discretized,  you can always take the continuous features, apply a layer or two on top of them and combine them with the embeddings of the discrete features.","Q_Score":0,"Tags":"python,python-3.x,pytorch,word-embedding","A_Id":58283102,"CreationDate":"2019-10-08T07:27:00.000","Title":"Word embeddings with multiple categorial features for a single word","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to know how to make a highlighted label(or small box )appears when the mouse is on widget like when you are using browser and put the mouse on (reload\/back\/etc...) button a small box will appear and tell you what this button do\nand i want that for any widget not only widgets on toolbar","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":159,"Q_Id":58283157,"Users Score":-1,"Answer":"As the comment of @ekhumoro says\nsetToolTip is the solution","Q_Score":0,"Tags":"python,pyqt,pyqt5,python-3.7","A_Id":58285881,"CreationDate":"2019-10-08T08:59:00.000","Title":"How to show a highlighted label when The mouse is on widget","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem when sending a cmd command in python. This command opens another tool, giving it some arguments. The problem is that the tool is opening, but also opens a cmd window, where I can see the message sent. If I close this cmd window, the tool will be closed, like a child process. This is odd: I just want to open the tool, without any cmd window being opened. \nIf I do it manually, by creating a .bat file which I double click, it works normally (a cmd is opened for 0.1 seconds while the tool is opening, without any cmd file still attached to the tool).\nBig picture: I've created a tool which will ask for some paths and then you can click \"start tool\", those paths are send as arguments to the tool which will be opened.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":74,"Q_Id":58284751,"Users Score":1,"Answer":"There is no problem with the CMD window since whatever script you're writing is opening the applications which you're passing in arguments but through the CMD window only.\nAnd you talked about a batch file that too works via CMD window only. Please check the flow of your code and also note or find out how it works at the back end. Is it taking the help of CMD Window?","Q_Score":3,"Tags":"python,cmd","A_Id":58285053,"CreationDate":"2019-10-08T10:39:00.000","Title":"Python process a cmd command which opens another tool","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"By default when I type python in terminal it goes to python using the 2.7.x version. In oldest versions of macOS once I typed 'alias pyhton=python3' it changed forever and every time I typed python it goes to python version 3.\nBut in macOS Catalina, I need to type the statement every time I open the terminal.\nAny suggestion?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1461,"Q_Id":58285124,"Users Score":1,"Answer":"Catalina now uses zsh as the default rather than Bash. \nTo verify which shell you are using type echo $0 in the terminal\nAdd alias python='python3' to $HOME\/.zshrc","Q_Score":1,"Tags":"python,macos,terminal,macos-catalina","A_Id":58296982,"CreationDate":"2019-10-08T11:05:00.000","Title":"Problem with changing python statement with python3 in macOS Catalina","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am having hard time to install a python lib called python3-saml\nTo narrow down the problem I created a very simple application on ibm-cloud and I can deploy it without any problem, but when I add as a requirement the lib python3-saml \nI got an exception saying:\npkgconfig.pkgconfig.PackageNotFoundError: xmlsec1 not found\nThe above was a deployment on ibm-cloud, but I did try to install the same python lib locally and I got the same error message, locally I can see that I have the xmlsec1 installed.\nAny help on how to successfully deploy it on ibm-cloud using python3-saml?\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":448,"Q_Id":58288228,"Users Score":2,"Answer":"I had a similar issue and I had to install the \"xmlsec1-devel\" on my CentOS system before installing the python package.","Q_Score":1,"Tags":"python,cloud,ibm-cloud,xmlsec1","A_Id":59429632,"CreationDate":"2019-10-08T14:18:00.000","Title":"xmlsec1 not found on ibm-cloud deployment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm developing django 2.2 (with mySql database) application with some code to import data from csv sources.\nCode is synchronous:\n\nload next csv line and do some pre-processing (normalize\/sanitize\ninput data)\ncreate or update django model from input data (and perform database\nread\/write)\n\nThere are obvious bottlenecks here:\n\ndisk i\/o on reading line from csv file (few files with more than 4M\nrecords)\nnetwork i\/o on database communication (tcp\/ip socket)\n\nThe process could be optimized:\nRead input data, then pass it to asynchronous code for database operation - fire and forget. Instead of waiting for DB to finish, load next csv line.\nWhat is your recommendations on optimization strategy in this case?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":58291520,"Users Score":0,"Answer":"for your question...\ntry to use django with gevent\n1) uses 'csv' lib and 'csv.reader' and loop on the on the returned element from 'csv.reader' call\n2) uses Mysqldb or pymsql as the django orm's dialect lib to access your database asynchronously","Q_Score":0,"Tags":"python,concurrency","A_Id":58291920,"CreationDate":"2019-10-08T17:44:00.000","Title":"How can I use asynchronous code in synchronous Python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I keep getting the error that str object is not callable. my line of code is pasted below... can anyone tell me what I am doing wrong.\nrandom = str(uuid.uuid4().hex().upper()[0:6])","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":50,"Q_Id":58291692,"Users Score":1,"Answer":"change hex() to hex. .hex is a property, not a function, and it already returns a string.","Q_Score":0,"Tags":"python,string","A_Id":58291725,"CreationDate":"2019-10-08T17:55:00.000","Title":"str object is not callable in django python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know this was addressed probably a thousand times already and might be a really dumb question. \nBut what happens exactly if you create a python variabel(name)? \nFor example if you type :\nx = 2 \nI know Python creates an intobject which holdsthe interger 2. But the x actually is a pointer to that object ? And in case it is, where is this pointer itself stored and does it consume memory? \nSorry again for this horribly typed question (sucks doing it on the phone) and the question itself. \nAny help is highly appreciated","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":37,"Q_Id":58293498,"Users Score":2,"Answer":"x is a name. The value associated with that name is an int object representing 2. Anything else is an implementation detail, not specified by the language itself.","Q_Score":0,"Tags":"python,pointers,variables,namespaces","A_Id":58293538,"CreationDate":"2019-10-08T20:17:00.000","Title":"Python Names and Variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have development environment for running my new website with python manage.py runserver\nand I have production environment that running this website with Apache2 and mod wsgi\nI am sending some variables in my views.py that render successfully on my development env, but same code on the prod env render nothing to the template","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":58295184,"Users Score":0,"Answer":"Fixed this by setting:\nServerName mysite.com\nin my apache config","Q_Score":0,"Tags":"python,django,templates,view,rendering","A_Id":58295524,"CreationDate":"2019-10-08T23:29:00.000","Title":"Django python rendering on dev but not on production","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Problem:\nWe have two different python service which should be ran in a single server. Where we have a dependency clash. Say Project A needs module - older version while Project B needs the same module but with newer version.\nTo isolate we found Python Virtual Environment will solve this issue. \n\nBut the real question for me is the Virtual environment will be stable\n  and accepted on the production level usage.\n\nOr Is there any other way we can approach for the problem.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":58300510,"Users Score":0,"Answer":"It is perfectly acceptable to use a virtual environment in production. In fact, it is often encouraged as it will ensure that any updates to the Python packages for one of the projects will not break the other.\nA good alternative is to use separate Docker containers for each of the projects.","Q_Score":1,"Tags":"python,python-3.x,virtualenv,development-environment,python-venv","A_Id":58300717,"CreationDate":"2019-10-09T08:58:00.000","Title":"Can we implement our python project in Python Virtual Environment for production environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Problem:\nWe have two different python service which should be ran in a single server. Where we have a dependency clash. Say Project A needs module - older version while Project B needs the same module but with newer version.\nTo isolate we found Python Virtual Environment will solve this issue. \n\nBut the real question for me is the Virtual environment will be stable\n  and accepted on the production level usage.\n\nOr Is there any other way we can approach for the problem.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":106,"Q_Id":58300510,"Users Score":0,"Answer":"Yes, you can\nYou can create virtual environment for first service where python version will be different and for second service, you can use different python version.\nyou can set these environment in running path of your services (for example in supervisor which we use for running process)\n\n[program:service1]\n  command=path_to_virtualenv_for_service1 python service1.py\n[program:service2]\n  command=path_to_virtualenv_for_service2 python service2.py","Q_Score":1,"Tags":"python,python-3.x,virtualenv,development-environment,python-venv","A_Id":58300762,"CreationDate":"2019-10-09T08:58:00.000","Title":"Can we implement our python project in Python Virtual Environment for production environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a numpy array and I flatten it by np.ravel() and I am confused when i tried to learn the size of the both array\n\n\n\narray =np.arange(15).reshape(3,5)\nsys.getsizeof(array)\n      112\nsys.getsizeof(array.ravel())\n      96\narray.size\n      15\narray.ravel().size\n      15\n\n\n\n \n\n\n\narray = np.arange(30).reshape(5,6)\nsys.getsizeof(array)\n      112\nsys.getsizeof(array.ravel())\n      96\narray.size\n      30\n\n\n\nAs seen above two different arrays have the same memory size but each has different amount of element. Why does it happen?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":344,"Q_Id":58302190,"Users Score":0,"Answer":"As Derte mentioned, sys.getsizeof doesn't say the size of the array. The 96 you got is holding information about the array (if it's 1-Dimensional) and the 112 if it's multi dimensional. Any additional element will increase the size with 8 bytes assuming you are using a dtype=int64.","Q_Score":2,"Tags":"python,numpy,reshape","A_Id":58302623,"CreationDate":"2019-10-09T10:32:00.000","Title":"why numpy array has size of 112 byte and when I do flatten it, it has 96 byte of memory?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does Django render websites and serve them from a views folder similar to how the express framework works in JavaScript? Or does it render pages on the client side similar to an applicatipn running express in the back-end and some fron end framework such as Vue.js in the front-end","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":4918,"Q_Id":58305068,"Users Score":2,"Answer":"If you are talking about the template language, it happens on the backend. This is true of every framework and every language. In the templates, the placeholders are replaced, they produce a valid html\/javascript page, and that's what is returned to the browser (or, to whatever accessed that url). Essentially, it is a shortcut for creating an html file by concatenating strings.\nA suggestion: don't use the template language, in any backend framework. Just use django to create rest services that return the data, and use a front-end framework like Vue\/angular\/react to create the actual front end part.","Q_Score":5,"Tags":"python","A_Id":58305134,"CreationDate":"2019-10-09T13:17:00.000","Title":"Does Django render web pages on the server side?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Does Django render websites and serve them from a views folder similar to how the express framework works in JavaScript? Or does it render pages on the client side similar to an applicatipn running express in the back-end and some fron end framework such as Vue.js in the front-end","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4918,"Q_Id":58305068,"Users Score":8,"Answer":"Django can do either, but it is designed to render on the server side in its default configuration, not the client side. \nTo use server side rendering, use Django as intended and according to the many tutorials out there. \nTo use client side rendering with something like React or Vue, use the Django Rest Framework.","Q_Score":5,"Tags":"python","A_Id":58305137,"CreationDate":"2019-10-09T13:17:00.000","Title":"Does Django render web pages on the server side?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use version 1.38 of VSCode in combination with the python extension (ms-python.python) to be able to modify jupyter notebooks inside of VSCode. Is there any option to hide the output of specific cells (e.g. when plotting multiple plots in one cell)?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10010,"Q_Id":58305831,"Users Score":44,"Answer":"Bumped into the same problem today.\nIt seems to be that the shortcuts from jupyter notebook are integrated into the jupyter notebook in visual studio code. \nIf you press \"o\" on a cell, it will hide the cell output.","Q_Score":18,"Tags":"python,visual-studio-code,jupyter-notebook","A_Id":61344131,"CreationDate":"2019-10-09T13:55:00.000","Title":"How to hide cell output in jupyter notebooks (VSCode + Python Extension)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Need to sudo su - diffuser after connection via SSHClient function.\nI cannot login with ssh directly to the required user id in order to run commands owned by that required user.  When at the local cli of the target ssh system, I simply run sudo su - diffuser, and then run the required commands.\nIs there anyway to simulate this using the Paramiko SSHClient commands?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":67,"Q_Id":58307003,"Users Score":1,"Answer":"I was able to resolve this using the SSHClient's invoke_shell method and associated methods (x.send, x.recv, etc.)","Q_Score":0,"Tags":"python","A_Id":58310387,"CreationDate":"2019-10-09T14:57:00.000","Title":"paramiko SSHClient sudo to new 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 can open my ESP32 Vroom32 device made by Espressif with a cp2101 chip on Ubuntu. I used Ubuntu to flash Micropython onto it, however when I try to connect with Putty, MPFshell or anything else on Windows 10 it will not work. I downloaded and installed the recommended drivers for it and also updated Windows which was supposed to load the driver as well. I can see the device and COM port in device manager but when I attempt to connect I get blocked. For example on MPFshell I get the message \"Cannot connect to COM17\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":201,"Q_Id":58307073,"Users Score":0,"Answer":"It is a common reason for boards to show the \"Cannot Connect to COM\" error because of a bad USB cable.\nAlways check with another cable first, before getting deeper to the problem.","Q_Score":0,"Tags":"esp32,micropython","A_Id":58327904,"CreationDate":"2019-10-09T15:01:00.000","Title":"Cannot open COM port on ESP32 device. Using Windows10 and MPFShell","Data Science and Machine Learning":0,"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 question about identity in python, i'm a beginner in python and i have read some courses on \"is\" keyword and \"is not\". And i don't understand why the operation \"False is not True is not True is not False is not True\" equals False in python ? For me this operation have to return True.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":89,"Q_Id":58308021,"Users Score":2,"Answer":"is relates to identity.\nWhen you ask if x is y, you're really asking are x and y the same object? (Note that this is a different question than do x and y have the same value?)\nLikewise when you ask if x is not y, you're really asking are x and y different objects?\nSpecifically in regards to True and False, Python treats those as singletons, which means that there is only ever one False object in an entire program.  Anytime you assign somnething to False, that is a reference to the single False object, and so all False objects have the same identity.","Q_Score":3,"Tags":"python,boolean,identity","A_Id":58308147,"CreationDate":"2019-10-09T15:57:00.000","Title":"A question about identity and boolean in Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can we set a font, size for the text on the title bar in tkinter?\nI think it cannot be done as it is not even required. But if there is a way then please let me know.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":24,"Q_Id":58308425,"Users Score":1,"Answer":"Can we set a font, size for the text on the title bar in tkinter?\n\nNo, tkinter doesn't provide a way to do that.","Q_Score":0,"Tags":"python-3.x,tkinter","A_Id":58308510,"CreationDate":"2019-10-09T16:23:00.000","Title":"Setting font for title bar","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I turn my code into comments in Jupyter Notebook? There are many threads saying that ctrl + \/ does this, but this doesn't do anything for me.\nI am using a Macbook from Latin America. It's running Mac OS High Sierra. My keyboard setup is Spanish ISO.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":425,"Q_Id":58309076,"Users Score":0,"Answer":"Unfortunately, ctrl + \/ only works on US keyboards.\nThis is done with ctrl + - on Mac OS and Spanish ISO.\nJust highlight the code and use the keyboard shortcut to turn multiple lines of code to comments.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":58309077,"CreationDate":"2019-10-09T17:06:00.000","Title":"Turn multiple lines of code into comments in Jupyter Notebook on Mac and Spanish ISO","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created three containers, one is for Python Flask application, second is for PostgreSQL db and third is for angular8. Im using Docker compose to run this. my question so each container has ports so total 3 ports. Is there a way I can use only one port to run this whole application like Docker Run instead of Docker Compose? All I want is a single port where this API can be called from anywhere.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":58309095,"Users Score":0,"Answer":"If the only thing you want to be visible to the \"outside\" is the API, you can use the --link flag when calling docker run.  Basically, start up the PG container, then start up the Flask container, linking to PG, then start up the Angular container, linking to Flask.  However, the --link flag is a legacy feature, and may disappear sometime in the future.\nAnother option is to create a network with docker network create and make sure your three containers are all using that same network.  They should all be able to communicate with each other in this way, and you just need to publish the API port so that other apps can use your API.\nI'm not sure what your requirements are, but docker-compose is generally the cleaner way to do it, as it helps you achieve consistency in your automations.","Q_Score":0,"Tags":"python,postgresql,docker,flask,angular8","A_Id":58309625,"CreationDate":"2019-10-09T17:08:00.000","Title":"How to use Single port for 3 containers instead of 3 ports Python-Flask, PostgreSQL & Angular8 ? so I can use Docker Run instead of Docker Compose","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have written a server in python that recieves an authentication key from a client that can be used to access the azure cloud blob storage. I'm having difficulties finding an optimal way of storing this key.\nThe key will last for quite some time so i'm considering just leaving it in the source code and compiling the program. But then the client can't ever change the key and the key would have to be changed from the source code and the program would have to be recompiled.\nSo i'm wondering is there any better way of storing an authentication key locally on the machine?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":58309962,"Users Score":0,"Answer":"Sorry, not enough reputation to comment... \nI don't understand your problem enough, and I'm assuming you're using Azure App Services to host it. \nYou should at the very least be using the App Service Configuration section to inject environment variables. Alternatively you can create a KeyVault resource and use Managed Identity to grant your App Service access to KeyVault, then retrieve the secret from KeyVault within your app.","Q_Score":1,"Tags":"python,azure","A_Id":58311314,"CreationDate":"2019-10-09T18:11:00.000","Title":"Storing authentication key for azure cloud","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is a prefix of \"100\" in front of all my python packages in anaconda navigator.  I believe this is making it difficult for applications to use these libraries.  For example, I cannot open Spyder.\nPackages will be listed as \"100 numpy\" rather than simply \"numpy\"\nI was in the middle of creating a virtual environment seperate from the root folder but I was doing a few install \/ uninstall of different packages using both Navigator and Anaconda Prompt.  Suddenly just about everything with my python installation started having problems. After closing Spyder I have not been able to reopen it. I tried spyder --reset which did not work.  I've tried several complete reinstalls of Anaconda and each time my root installation (as well as any other venvs I create) have a prefix of 100 in front of the package name.\nI would expect the packages to read \"numpy\" rather than \"100 numpy\" etc.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1443,"Q_Id":58311623,"Users Score":4,"Answer":"I have also experienced this issue. For me, this occurred after running conda update --all in the anaconda terminal. I was able to fix this by rolling back my conda version to the version prior to my update that broke it. \nTo do this, go to anaconda prompt and type in conda list --revisions to find the revision number prior to whichever update broke anaconda. They you just type in conda install --revision #, replacing \"#\" with the revision number.","Q_Score":13,"Tags":"python-3.x,anaconda,spyder","A_Id":61966390,"CreationDate":"2019-10-09T20:13:00.000","Title":"How to fix : Prefix \"100\" in front of all Anaconda packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am brand new to VS Code and struggling to get my current py interpreter to run.\nMy current python interpreter is run off of sourcing anaconda and opening python\nsource anaconda\nHow to do I force VS Code to first source anaconda before looking for py interpreters?\n(Anaconda is located on a linux server.)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":296,"Q_Id":58311675,"Users Score":0,"Answer":"Like a fool I Missed it in the docs. Just need to manually add the full path to python.\nCommand Palette > Preferences: Open User Settings > Then set python.pythonPath to (your required path). Reload VS Code and now the added path will be part of the Python Interpreters list.\nQuick way to get path, \n Source and Open Python in terminal and enter:\n$ where python","Q_Score":0,"Tags":"python,visual-studio,visual-studio-code,anaconda","A_Id":58312103,"CreationDate":"2019-10-09T20:18:00.000","Title":"How to source anaconda in Visual Studio Code (To select python interpreter)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a project which includes two different apps: users and school. In my current implementation, the users app contains a custom user class derived from Djagno's AbstractUser. It defines allowed user types as student or teacher, and the user must select one during registration. The school app contains a classroom model which I need to relate to students and one or more teachers.\nI have two main problems here. The first is regarding how to relate the classroom model to only specific users restricting their access based on their user type. I have tried using a ManyToManyField relation in the classroom model in order to associate the instance with the user who created it (and then I would later allow the user to add students). It appears I don't understand this field correctly -- it actually all users to all classroom instances. This obviously does not meet my requirement to restrict access among different classroom instances.\nOneToOneField and ForeignKey do not seem to meet my needs either. I have tried adding those fields to my user, but then I am restricted to a single classroom per user which is not acceptable either.\nI have also played around with creating groups named something like \"Classroom_A_teachers\" and \"Classroom_A_students\" and then assigning permissions to them. This approach seems more complicated than necessary.\nAm I overlooking something here? This is my first Django project, and I could easily have missed something basic.\nProblem two is regarding adding a teacher and student model. I would like to allow a user who is registered as a teacher to be able to create a classroom instance and then to populate that classroom with student instances. Students could optionally create an account too. They would receive a classroom ID from their teacher, enter it, and their account would then be linked to the classroom instance. How can I then associate this user with an existing student model? I have toyed around with this concept with no success.\nAny insight is greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":58313350,"Users Score":0,"Answer":"It appears I don't understand this field correctly -- it actually all users to all classroom instances.\n\nIt shouldn\u2019t do that. It can just look that way in the Django Admin. The only ones actually in the ManyToMany field are the ones which are highlighted\/greyed. \nManyToMany is appropriate for your use case.","Q_Score":0,"Tags":"python,django,django-models,django-users","A_Id":58313760,"CreationDate":"2019-10-09T23:01:00.000","Title":"How can I relate some, but not all, models to users using Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"May I ask what's the difference between df.head() and df.head in python's syntax nature? Could I interpret as the former one is for calling a method and the later one is just trying to obtain the DataFrame's attribute, which is the head? I am so confused why sometimes there is a parenthesis at the end but sometimes not... Thank you so much.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":58315096,"Users Score":0,"Answer":"You understand it well, in general parenthesis call class method, and without you call an attribute.\nIn your exemple you don't have an error, because df.head is bound to NDFrame.head who is a method as well. If df.head was only a method, calling it without parenthesis will raise an AttributeError.","Q_Score":1,"Tags":"python,pandas,dataframe","A_Id":58315161,"CreationDate":"2019-10-10T03:36:00.000","Title":"DataFrame issue (parenthesis)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to scrape a stocks website and get the prices using selenium. I can't use normal HTML requests as the HTML is dynamic. \nI am using the headless selenium webdriver to get the data, but it takes around 30 seconds for each request. \nIs there a faster way to get the dynamic HTML?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":793,"Q_Id":58315190,"Users Score":3,"Answer":"No, you are stuck with Selenium's wait-time with rendering\nDynamic HTML requires a full browser. There is not much negotiating with that. If your pages are separate and distinct, i.e. you are scraping stocks.com\/oilandgas as well as stocks.com\/agriculture, there is a possible way to speed things up. \nThe one option you might have is to create a separate thread for each Selenium Webdriver instance and have both web pages scraped at the same time by two different Selenium Webdrivers. \nThe caveat to that is that it will only speed things up if the bottleneck (what is causing the slowness) is the rendering of the website.\nIf it is the internet speed, the processing power of your computer, or the server speed of the website, this would not improve things. \nActually, Daniel Farrell below suggests that it would improve the networking speed. You may want to give this a shot.","Q_Score":0,"Tags":"python,selenium,web-scraping,dynamic-html","A_Id":58315244,"CreationDate":"2019-10-10T03:48:00.000","Title":"Fastest way to get dynamically updated HTML content from website?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on moving data from Postgres DB to AWS Redshift using Python3.7. I created an SQL query that retrieves a query set when executed (I'm using where clause to query. So for every query execution, I'll be changing the ID that I'm passing).\nI'm going to run this script in Flask docker container which will be ultimately run on Kubernetes.\nI have exposed an POST method enpoint in dockerized Flask app on which I'll receiving a list of IDs that needs to be queried on DB and data to be moved to Redshift using Python.\nI want to do multithreading for executing multiple queries at once and moving data as there could be lot of IDs in the POST request that I receive. \nBut, as I'm using Python3.7, I came to know that GIL is going to be a bottleneck and it doesn't matter if how many threads you are running, and there will be only one thread executing at any time.\nHow do I overcome this problem and make the parallel execution of SQL queries on DB possible and that finally works on Kubernetes.\nCan I go with multiprocessing or is there any other better way to achieve this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":291,"Q_Id":58317133,"Users Score":0,"Answer":"If you're using Flask app, you can host your app in Gunicorn with multiple workers and threads which allows parallelism by running multiple workers.\nGunicorn launches a master process that can create multiple (configured workers) where each worker can handle an HTTP request independently. The kernel handles the load balancing of request among the workers. \nIf you add Gevent to the mix, that also provides concurrency per worker i.e. each worker would be able to handle multiple requests concurrently (not in parallel).\nBoth of these are available as pip packages, Gevent requires the installation of libev. \nThe support for flask by Gunicorn is ensured by the fact that flask is a WSGI framework and Gunicorn is a WSGI server, they're simply plugged into each other.","Q_Score":0,"Tags":"python-3.x,postgresql,docker,flask,amazon-redshift","A_Id":58317462,"CreationDate":"2019-10-10T06:57:00.000","Title":"How to do parallel PostgreSQL query exections in Python3.7 docker container?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Django web application with a postgresql database on an AWS server. \nI want to keep this database in sync with a nosql cloud firestore database. We're using cloud firestore as the backend for a mobile app.\nThis means that every form update or new object that is added to the web app needs to be in sync with cloud firestore. \nI'm able to update cloud firestore using the Python SDK when each form is submitted via the web app. However, I want to know if this is the best method to keep these two databases in sync. Each time a form is submitted, I have to import the firebase SDK, and then use the methods to update cloud firestore. Obviously, this will take time, but I'm unsure if this method is better, or if using the JavaScript SDK will be better. In essence, which method will perform better?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":58318749,"Users Score":2,"Answer":"When you are doing that from python SDK the read and write to cloud fire storage is done from the server means if you have x request and y number of users doing that, your server has to do x*y request to Cloudflare storage. in this case, your transaction from the server will be heavily based on a user basis but you can use admin SDK in python and give only admin to access to DB.\nIf you want to use js for the same then request will be shared by users and the server will be free but each user should have access to DB write and read, you have to be more careful about authenticating users.\n\nso if its all read requests and user-based filters are done well use from js, if you have doubts on authentications or you don't want to take a risk in that use from python.","Q_Score":0,"Tags":"javascript,django,python-3.x,firebase,google-cloud-firestore","A_Id":58319963,"CreationDate":"2019-10-10T08:38:00.000","Title":"Which method is better: Python SDK (server side) or JavaScript SDK (client-side) to add to and update cloud firestore?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to use Snowflake Python Connector through SQLAlchemy, While I am running pip install --upgrade snowflake-sqlalchemy I am getting error failed to build pyarrow during installation. I am using python version 3.7","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2238,"Q_Id":58318943,"Users Score":3,"Answer":"I recommend reinstalling pyarrow, and then you might want to upgrade snowflake-sqlalchemy after that.  Probably couldn't hurt to redo the standard connector as well, steps as follows:\n1.\npip install --upgrade pyarrow\n\npip install --upgrade snowflake-connector-python\n\n3.\npip install --upgrade snowflake-sqlalchemy","Q_Score":2,"Tags":"python,pip,snowflake-cloud-data-platform","A_Id":58325992,"CreationDate":"2019-10-10T08:50:00.000","Title":"Failed to build pyarrow during installation of Snowflake-SQLAlchemy through pip installation","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new with Python and new on Stackoverflow, so please let me know if this question should be posted somewhere else or you need any other info :). But I hope someone can help me out with what seems to be a rather simple mistake...\nI'm working with Python in Jupyter Notebook and am trying to create my own module with some selfmade functions\/loops that I often use. However, when I try to some of the functions from my module, I get an error related to the import of the built-in module that is used in my own module.\nThe way I created my own module was by:\n\ncreating different blocks of code in a notebook and downloading it\nas  'Functions.py' file.\nsaving this Functions.py file in the folder that i'm currently working in (with another notebook file)\nin my current notebook file (where i'm doing my analysis), I import my module with 'import Functions'.\n\nSo far, the import of my own module seems to work. However, some of my self-made functions use functions from built-in modules. E.g. my plot_lines() function uses math.ceil() somewhere in the code. Therefore, I imported 'math' in my analysis notebook as well. But when I try to run the function plot_lines() in my notebook, I get the error \"NameError: name 'math' is not defined\".\nI tried to solve this error by adding the code 'import math' to the function in my module as well, but this did not resolve the issue. \nSo my question is: how can I use functions from built-in Python modules in my own modules?\nThanks so much in advance for any help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":58320255,"Users Score":0,"Answer":"If anyone encounters the same issue:\nadd 'import math' to your own module. \nMake sure that you actually reload your adjusted module, e.g. by restarting your kernell!","Q_Score":0,"Tags":"python,function,math,module,jupyter-notebook","A_Id":58321054,"CreationDate":"2019-10-10T09:57:00.000","Title":"Using a function from a built-in module in your own module - Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I delete a code block in Jupyter Lab accidentally. Can I find it back?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":262,"Q_Id":58320632,"Users Score":0,"Answer":"Click on the edit tab then hover to the Undo Delete Cells \nhope this helps :)","Q_Score":0,"Tags":"python,jupyter","A_Id":58320773,"CreationDate":"2019-10-10T10:17:00.000","Title":"How to find back a code block in JupyterLab or Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a cluster setup of 3 nodes. \nI am designing my microservice and I am wondering if each node should have their own Cassandra session or if all three should share the same session created by any of the nodes.\nI have read in the Cassandra docs:\n\n\"The Session instance is a long-lived object and it should not be used\n  in a request\/response short-lived fashion. Basically you will want to\n  share the same cluster and session instances across your application.\"\n\nWhat does this mean?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":55,"Q_Id":58320879,"Users Score":1,"Answer":"You share your session on application level. Different applications should have own sessions.\nYour quote means that you dont open a session for a query but rather have a singleton Session instance in your application.","Q_Score":1,"Tags":"python,cassandra","A_Id":58321657,"CreationDate":"2019-10-10T10:32:00.000","Title":"Should every instance of application have their own cassandra session or they should share the same session?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"while working with timestamps in python i want to calculate \nDayofYear\nMonthofYear\nWeekofYear\nusing timestamp object.\nWell i see there is one available \nTimestampObject.dayofyear\nI need to know if i can do\nTimestampObject.weekofyear\nTimestampObject.monthofyear","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":58321402,"Users Score":0,"Answer":"Actually i found the answer thanks anyways.\ni can use pd.Timestamp for all the calculations","Q_Score":0,"Tags":"python,timestamp","A_Id":58321784,"CreationDate":"2019-10-10T11:01:00.000","Title":"Is there any python Timestamp API to calculate day of year, month of year and week of year","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project in which I need to implement a functionality wherein a folder or directory is protected using a password. As in, when someone tries to open that particular folder, a password prompt is presented to them. If correct password is entered, then folder access is granted or else not.\nIs this possible using python or Java ? Is yes then how ? And if not then which language can be used ?\nI tried searching a lot but nothing helpful came out of it.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":129,"Q_Id":58321548,"Users Score":-1,"Answer":"If you mean folders on the file system then you could mimick this behavior by storing files in a password protected zip file. \nIf you mean conceptual folders within your application then you are free to implement authentication any way you want. Normally this involves a user logging in to your application to gain access to the protected resources.","Q_Score":0,"Tags":"java,python,python-3.x","A_Id":58321590,"CreationDate":"2019-10-10T11:11:00.000","Title":"Password protecting folder or directory in java 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 have a weird problem right now in python3. \nI have a script with the correct indentation, but when I compile it says I have inconsistent use of tabs or spaces. \nI'm using geany, so in geany it is correct indentation, but when I open the file in vim it's all wrong. But when I fix the problem in vim it's all wrong in geany and the compiler will tell me whats wrong (in geany). So either way I'm stuck now.\nIs there a way to fix this?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":164,"Q_Id":58321643,"Users Score":3,"Answer":"Use another editor such as sublime text, VSCode or PyCharm which has a feature for replacing tabs with spaces (or the other way around), this sould fix your problem.\nYou can also stick with vim and run the following command inside vim:\n:retab","Q_Score":2,"Tags":"python,indentation","A_Id":58321731,"CreationDate":"2019-10-10T11:16:00.000","Title":"Python indentation error between two text-editors","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a weird problem right now in python3. \nI have a script with the correct indentation, but when I compile it says I have inconsistent use of tabs or spaces. \nI'm using geany, so in geany it is correct indentation, but when I open the file in vim it's all wrong. But when I fix the problem in vim it's all wrong in geany and the compiler will tell me whats wrong (in geany). So either way I'm stuck now.\nIs there a way to fix this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":58321643,"Users Score":6,"Answer":"I have faced similiar problems when using notepad++ editor, When I am doing editing using notepad++ I have faced same kind of identation error.\nI have replaced every tabs with 5 spaces & I am able to solve identation error in my script.\nI hope doing same work for you.","Q_Score":2,"Tags":"python,indentation","A_Id":58321815,"CreationDate":"2019-10-10T11:16:00.000","Title":"Python indentation error between two text-editors","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've just upgraded to macOS Catalina, I've used brew install dpkg, and homebrew decided it was time to run brew cleanup.\nAfter running it, I've not been able to run pip3 anymore.\nTried running brew doctor and brew reinstall python3, but none helped.\nRunning pip3 outputs this:\n[1]    26346 abort      pip3","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1785,"Q_Id":58321697,"Users Score":3,"Answer":"It turns out brew uninstall python3 does not really uninstalls it, had to remove \/usr\/local\/lib\/python3 to really remove the installation, and then reinstall python using brew install python3","Q_Score":2,"Tags":"python,macos,pip,homebrew","A_Id":58322938,"CreationDate":"2019-10-10T11:19:00.000","Title":"pip3 crashes on macOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to store images in database for various users.Its just like famous blog app but instead of blogs i want to store images in database.How can i implement my idea?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":603,"Q_Id":58324502,"Users Score":0,"Answer":"You can do one thing -> change the image into base64 string and save it to database than when you want that image convert it from base64 to normal format.\nand you can find multiple tutorial on internet how to change image to base64 in python.\nwhy i am suggesting this because i used it in an android app.","Q_Score":0,"Tags":"python,django,image,django-models,storage","A_Id":58324611,"CreationDate":"2019-10-10T13:48:00.000","Title":"Django:How to store images in database instead of media file?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use rawpy module in python to post-process raw images, however, no matter how I set the Params, the output is different from the default RGB in camera ISP, so anyone know how to operate on this please?\nI have tried the following ways:\nDefault:\noutput = raw.postprocess()\nUse Camera White balance:\noutput = raw.postprocess(use_camera_wb=True)\nNo auto bright:\noutput = raw.postprocess(use_camera_wb=True, no_auto_bright=True)\nNone of these could recover the RGB image as the camera ISP output.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1074,"Q_Id":58325514,"Users Score":0,"Answer":"The dcraw\/libraw\/rawpy stack is based on publicly available (reverse-engineered) documentation of the various raw formats, i.e., it's not using any proprietary libraries provided by the camera vendors. As such, it can only make an educated guess at what the original camera ISP would do with any given image. Even if you have a supposedly vendor-neutral DNG file, chances are the camera is not exporting everything there in full detail.\nSo, in general, you won't be able to get the same output.","Q_Score":1,"Tags":"python,dcraw","A_Id":58499291,"CreationDate":"2019-10-10T14:40:00.000","Title":"how to post-process raw images using rawpy to have the same effect with default output like ISP in camera?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Would it be correct to say that all Python variables are pointers to pointer (in terms of C) to some data object say int or list? e.g. a = 5 is putting address of object int(5) into a, where a has its own address which is useless (I think).  \nAnd print is defined in Python to print the content of the object pointed to by the address stored in a. \nAnd id is defined in Python to print the address stored in a.\n\nIs this what really happening under the hood?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":228,"Q_Id":58326216,"Users Score":6,"Answer":"Not really, but close. A Python variable is a name that refers to an object. Full stop. Python doesn't define any semantics about how this is done.\nprint takes an object as its argument. That object can be passed via a literal (print(3), print(\"foo\"), print(True)), or via a reference (print(a)).\nid returns an integer identifier that is unique to that object for the lifetime of that object. What that integer is is also not defined by the language; it's up to the implementation to decide. It could just as easily be a serial number that starts with 0 and gets incremented every time a new object is created.\n\nAny question about \"under the hood\" can only be answered by specifying which implementation of Python you are using, and that answer will not really be of any use in understanding what a particular piece of Python means, only in understanding how a particular implementation does it.","Q_Score":0,"Tags":"python","A_Id":58326287,"CreationDate":"2019-10-10T15:17:00.000","Title":"Python variables under the hood","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Keras for the layers, optimizer, and model and my model is Sequential\nI've got two DQN networks and I'm making them duel each other in a simulated environment however after about 35 episodes (different each time) the script just stops without any errors. I've isolated my issue to be somewhere around when the agent runs the prediction model for the current state to get the action. The process is called but never completed and the script just stops without any error. How can I debug this issue?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":46,"Q_Id":58332232,"Users Score":1,"Answer":"The way I was looping my function needed to be a for loop instead of directly calling the function as a loop method. And my error was a stack overflow","Q_Score":0,"Tags":"python,python-3.x,machine-learning,artificial-intelligence","A_Id":58334583,"CreationDate":"2019-10-10T23:11:00.000","Title":"Python script closes after a while","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to control a Sony Alpha using Python\/gphoto2 on a Raspberry PI.  I've tried a number of python bindings (python-gphoto2, gphoto2-cffi, ...) but they all fail at the instruction to create a camera object (eg. my_cam = gphoto.Camera()) with the error:\n\"Could not claim interface 0 (Device or resource busy). Make sure no other program (gvfs-gphoto2-volume-monitor) or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read\/write access to the device.\"\nWe tried to kill background programs, make sure the kernel modules are not running, install the latest versions of the libraries and python packages, ... but could not get rid of the error.  Furthermore C code using libgphoto2 works fine so it's not likely that the resource is really busy.  We suspect the problem is missing USB libs in the python packages, and have tried to install libusb-dev, ... but it doesn't help.  \nAny suggestions what else we should try?  Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":637,"Q_Id":58332367,"Users Score":1,"Answer":"You mentioned trying python-gphoto2. I'm the author of that package. Assuming you have installed it successfully then I'd try the list-cameras.py example program. It should list any cameras recognised by libgphoto2 that are connected and switched on.\nIf C programs are working but Python ones aren't you could check that they're using the same versions of libgphoto2. Try ldd on the C program's executable and on one of the python-gphoto2 compiled modules, e.g. \/usr\/local\/lib\/python3.5\/dist-packages\/gphoto2\/_camera.cpython-35m-arm-linux-gnueabihf.so.","Q_Score":0,"Tags":"python-3.x,raspberry-pi,libgphoto2","A_Id":58384644,"CreationDate":"2019-10-10T23:32:00.000","Title":"Could not open camera using gphoto2 in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to improve mobilenet_v2's detection of boats with about 400 images I have annotated myself, but keep on getting an underfitted model when I freeze the graphs, (detections are random does not actually seem to be detecting rather just randomly placing an inference). I performed 20,000 steps and had a loss of 2.3.\nI was wondering how TF knows that what I am training it on with my custom label map\nID:1\nName: 'boat'\nIs the same as what it regards as a boat ( with an ID of 9) in the mscoco label map.\nOr whether, by using an ID of 1, I am training the models' idea of what a person looks like to be a boat?\nThank you in advance for any advice.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":58332687,"Users Score":0,"Answer":"The model works with the category labels (numbers) you give it.  The string \"boat\" is only a translation for human convenience in reading the output.\nIf you have a model that has learned to identify a set of 40 images as class 9, then giving it a very similar image that you insist is class 1 will confuse it.  Doing so prompts the model to elevate the importance of differences between the 9 boats and the new 1 boats.  If there are no significant differences, then the change in weights will find unintended features that you don't care about.\nThe result is a model that is much less effective.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,conv-neural-network,object-detection","A_Id":58345624,"CreationDate":"2019-10-11T00:23:00.000","Title":"How does TF know what object you are finetuning for","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to improve mobilenet_v2's detection of boats with about 400 images I have annotated myself, but keep on getting an underfitted model when I freeze the graphs, (detections are random does not actually seem to be detecting rather just randomly placing an inference). I performed 20,000 steps and had a loss of 2.3.\nI was wondering how TF knows that what I am training it on with my custom label map\nID:1\nName: 'boat'\nIs the same as what it regards as a boat ( with an ID of 9) in the mscoco label map.\nOr whether, by using an ID of 1, I am training the models' idea of what a person looks like to be a boat?\nThank you in advance for any advice.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":58332687,"Users Score":0,"Answer":"so I managed to figure out the issue.\nWe created the annotation tool from scratch and the issue that was causing underfitting whenever we trained regardless of the number of steps or various fixes I tried to implement was that When creating bounding boxes there was no check to identify whether the xmin and ymin coordinates were less than the xmax and ymax I did not realize this would be such a large issue but after creating a very simple check to ensure the coordinates are correct training ran smoothly.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,conv-neural-network,object-detection","A_Id":58513059,"CreationDate":"2019-10-11T00:23:00.000","Title":"How does TF know what object you are finetuning for","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with odoo11 community version and currently I have some problem.\nThis is my exmplanation of problem:\nIn company I have many workcenters, and for each workcenter:\n1) I want to create separate warehouse for each workcenter\nor\n2) Just 1 warehouse but different storage areas for each workcenter\n(currently I made second option) and each workcenter have their own operation type: Production\nNow my problem started, There are manufacturing orders and each manufacturing order have few workorders, And I want to do something that when some workorder is started then products are moved to this workcenter's warehouse\/storage area and they are there untill next workorders using different workcenter starting then product are moved to next workcenter warehouse\/storage area.\nI can only set that after creating new sale order production order is sent to first Workcenter storage area and he is ther untill all workorders in production order are finished, I don't know how to trigger move routes between workcenters storage areas. for products that are still in production stage\nCan I do this from odoo GUI, or maybe I need to do this somewhere in code?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":58332889,"Users Score":0,"Answer":"Ok, I found my answer, which is that to accomplish what I wanted I need to use Manufacturing with Multi levell Bill of material, it working in way that theoretically 3 steps manufacturing order is divided into 3 single manufacture orders with 1 step each, and for example 2 and 3 prodcution order which before were 2 and 3 step are using as components to produce product that are finished in previous step which now is individual order.","Q_Score":0,"Tags":"python,odoo,odoo-11","A_Id":58356611,"CreationDate":"2019-10-11T00:57:00.000","Title":"Warehouse routes between each started workorder in production order","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Good day folks\nRecently, I made a python based web crawler machine that scrapes_ some news ariticles and django web page that collects search title and url from users.\nBut I do not know how to connect the python based crawler machine and django web page together, so I am looking for the any good resources that I can reference.\nIf anyone knows the resource that I can reference,\nCould you guys share those?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":101,"Q_Id":58333930,"Users Score":0,"Answer":"There are numerous ways you could do this. \nYou could directly integrate them together. Both use Python, so the scraper would just be written as part of Django. \nYou could have the scraper feed the data to a database and have Django read from that database. \nYou could build an API from the scraper to your Django implementation. \nThere are quite a few options for you depending on what you need.","Q_Score":0,"Tags":"python,django,web-crawler","A_Id":58335189,"CreationDate":"2019-10-11T03:40:00.000","Title":"How to Connect Django with Python based Crawler machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I trained my unsupervised model using fasttext.train_unsupervised() function in python. I want to save it as vec file since I will use this file for pretrainedVectors parameter in fasttext.train_supervised() function. pretrainedVectors only accepts vec file but I am having troubles to creating this vec file. Can someone help me?\nPs. I am able to save it in bin format. It would be also helpful if you suggest me a way to convert bin file to vec file.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6401,"Q_Id":58337469,"Users Score":1,"Answer":"you should add words num and dimension at first line of your vec file, than use -preTrainedVectors para","Q_Score":9,"Tags":"python,word-embedding,fasttext","A_Id":59558292,"CreationDate":"2019-10-11T08:46:00.000","Title":"How to save fasttext model in vec format?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering if it is possible for me to use Django code I have for my website and somehow use that in a mobile app, in a framework such as, for example, Flutter.\nSo is it possible to use the Django backend I have right now and use it in a mobile app?\nSo like the models, views etc...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":16475,"Q_Id":58337572,"Users Score":15,"Answer":"Yes. There are a couple ways you could do it\n\nUse the Django Rest Framework to serve as the backend for something like React Native. \nBuild a traditional website for mobile and then run it through a tool like PhoneGap. \nUse the standard Android app tools and use Django to serve and process data through API requests.","Q_Score":7,"Tags":"python,android,django,django-models,mobile","A_Id":58337906,"CreationDate":"2019-10-11T08:52:00.000","Title":"Is it possible to make a mobile app in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can anyone please let me know how to simulate mouse hover event using robot framework on a desktop application. I.e if I mouse hover on a specific item or an object, the sub menus are listed and i need to select one of the submenu item.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1537,"Q_Id":58338018,"Users Score":0,"Answer":"It depends on the automation library that you are using to interact with the Desktop application. \nThe normal approach is the following: \n\nFind the element that you want to hover on (By ID or some other unique locator)\nGet the attribute position of the element (X,Y)\nMove your mouse to that position. \n\nIn this way you don\u00b4t \"hardcode\" the x,y position what will make your test case flaky.","Q_Score":0,"Tags":"python,robotframework","A_Id":58340413,"CreationDate":"2019-10-11T09:16:00.000","Title":"how to simulate mouse hover in robot framework on a desktop application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to import some data from web, where the data is being updated every 1 second. \nHowever, the problem is that when I try to soup this data, all data are not imported. When the data is not being updated, my code works well. But when the data is being updated(from 8 a.m. to 12 a.m.), some of those are not imported properly. \nIt's a table with 500 rows and 12 columns, where each column is stored in a separate variable. It is expected that the variables have the same length. This is true when data are not updated, but when I run the code from 8 a.m. to 12 a.m.(when data are being updated) the variables do not have the same length. Any advice or recommendation would be greatly appreciated.\nI am using selenium to open the web page and execute some commands to read data with beautiful-soup.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":148,"Q_Id":58338256,"Users Score":3,"Answer":"Since there is no code and I don't know the website, here are some general thoughts:\n\nAs Maxime suggested - Is there an API you could use?\nCan you ditch selenium? Using something like requests might be faster and will help you get the timings right.\nIs the stuff you want to scrape already loaded when you try to save it?\nIs your internet connection keeping up with the amount of requests you sent?","Q_Score":0,"Tags":"python,python-3.x,selenium-webdriver,beautifulsoup","A_Id":58338671,"CreationDate":"2019-10-11T09:28:00.000","Title":"what is the best way to import high frequency updating data in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When trying to import numpy in spyder i get the following error message:\nImportError:\nIMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!\nImporting the numpy c-extensions failed.\n- Try uninstalling and reinstalling numpy.\n- If you have already done that, then:\n1. Check that you expected to use Python3.7 from \"\/home\/sltzgs\/anaconda3\/bin\/python\",and that you have no directories in your PATH or PYTHONPATH that can interfere with the Python and numpy version \"1.17.2\" you're trying to use.\n2. If (1) looks fine, you can open a new issue at\n     https:\/\/github.com\/numpy\/numpy\/issues.  Please include details on:\n     - how you installed Python\n     - how you installed numpy\n     - your operating system\n     - whether or not you have multiple versions of Python installed\n     - if you built from source, your compiler versions and ideally a build log\n- If you're working with a numpy git repository, trygit clean -xdf(removes all files not under version control) and rebuild numpy.\nNote: this error has many possible causes, so please don't comment on\nan existing issue about this - open a new one instead.\nOriginal error was: No module named 'numpy.core._multiarray_umath'\nHowever, importing in a jupyter notebook works fine. How is that possible? \nI have uninstalled\/installed numpy a few times by now and also made sure, that the sys.paths are identical.\nAny help appreciated. In case any additional information is required I would happily help out. Thanks.\nSome essentials:\npython 3.7\nSpyder 3.3.6 \nnumpy 1.17.2","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1431,"Q_Id":58339023,"Users Score":1,"Answer":"Problem did not occur again after re-installing Anaconda. Thanks @CarlosCordoba.","Q_Score":0,"Tags":"python,numpy,spyder","A_Id":61201527,"CreationDate":"2019-10-11T10:11:00.000","Title":"Numpy can't be imported in Spyder","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have used OpenCVs stereocalibrate function to get the relative rotation and translation from one camera to another. What I'd like to do is change the origin of the world space and update the extrinsics of both cameras accordingly. I can easily do this with cameras that have a shared view with SolvePnP but I'd like to do this with cameras in which each is defined by it's pose relative to an adjacent camera where all of their fields don't overlap - like daisy chaining their relative poses.\nI've determined the pose of the cameras relative to where I'd like the world origin and orientation to be using SolvePnP so that I know what the final extrinsics 'should be'. I've then tried combining the rotation matrices and translation vectors from the stereocalibration with the SolvePnP from the primary camera to get the same value both with ComposeRT and manually but to no avail.\nEdit: So it turns out that for whatever reason the StereoCalibration and SolvePnP functions produce mirrored versions of the poses as the StereoCalibration appears to produce poses with a 180 degree rotation around the Y-axis. So by applying that rotation to the produced relative rotation matrix and translation vector everything works!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":554,"Q_Id":58339628,"Users Score":0,"Answer":"If you know relative poses between all the cameras via a chain (relative poses between cameras a, b and b, c), you can combine the translations and rotations from camera a to c via b by\nR ac = Rab R bc\nt ac = t ab + R ab t bc\nIn other words, the new rotation from ac is rotating first from a to b and then from b to c. Translation is calculated in the same way, in addition the second translation vector has to be rotated by R ab.\nSome amount of error is expected, depending how accurate your pairwise calibration is. Errors in camera pose accumulate over the chain. If you have camera poses making full circle you generally don't get the exact same poses for the starting\/ending camera.","Q_Score":0,"Tags":"python,opencv,camera-calibration","A_Id":58340103,"CreationDate":"2019-10-11T10:47:00.000","Title":"Combining relative camera rotations & translations with known pose","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For example in requests library we have get method which is defined inside api.py file\nbut i can directly call it with requests.get .\nas per my understanding it should be called like this requests.api.get\nHow python modules handles this.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":58340553,"Users Score":1,"Answer":"Your intuition is correct that the name should be requests.api.get. In fact, if you look at requests.get.__module__, you will find that it is requests.api. Similarly, requests.get.__globals__ is a reference to requests.api.__dict__.\nMany libraries will export functions defined elsewhere through the top level namespace. This is usually done with an import like from .api import get in the __init__.py file of requests.","Q_Score":2,"Tags":"python,python-3.x","A_Id":58341056,"CreationDate":"2019-10-11T11:41:00.000","Title":"How functions are mapped to correct filename in python packages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"While opening Jupyter notebook or Spyder, I am continuously getting 'kernel error' notification. \nTried to reinstall anaconda3, ipython, kernel but the issue stays. I had downloaded Python 3.7 in Windows 10 system.\nI am getting the below error in log.\n\"> Traceback (most recent call last): File\n\"> \"C:\\Users\\AppData\\Local\\Continuum\\anaconda3\\lib\\site\u2011packages\\spyder\\plugins\\ipytho\"nconsole.py\",\n\nline 1572, in create_kernel_manager_and_kernel_client\n  kernel_manager.start_kernel(stderr=stderr_handle) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\manager.py\",\n  line 240, in start_kernel self.write_connection_file() File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\connect.py\",\n  line 476, in write_connection_file kernel_name=self.kernel_name File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\connect.py\",\n  line 141, in write_connection_file with secure_write(fname) as f: File\n  \"C:\\Users\\AppData\\Local\\Continuum\\anaconda3\\lib\\contextlib.py\", line\n  112, in enter return next(self.gen) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_core\\paths.py\",\n  line 404, in secure_write win32_restrict_file_to_user(fname) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_core\\paths.py\",\n  line 359, in win32_restrict_file_to_user import win32api ImportError:\n  DLL load failed: The specified procedure could not be found.","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":8153,"Q_Id":58341160,"Users Score":0,"Answer":"I started all over:\n\nI uninstalled notebook.\n\nI uninstalled python 3.7.9.\n\nI then reinstalled python 3.8.4 and.\n\nreinstalled notebook.\n\n\nProblem solved!","Q_Score":6,"Tags":"python,python-3.x,jupyter-notebook,kernel","A_Id":67187582,"CreationDate":"2019-10-11T12:20:00.000","Title":"Getting kernel error while trying to open Jupyter notebook or Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"While opening Jupyter notebook or Spyder, I am continuously getting 'kernel error' notification. \nTried to reinstall anaconda3, ipython, kernel but the issue stays. I had downloaded Python 3.7 in Windows 10 system.\nI am getting the below error in log.\n\"> Traceback (most recent call last): File\n\"> \"C:\\Users\\AppData\\Local\\Continuum\\anaconda3\\lib\\site\u2011packages\\spyder\\plugins\\ipytho\"nconsole.py\",\n\nline 1572, in create_kernel_manager_and_kernel_client\n  kernel_manager.start_kernel(stderr=stderr_handle) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\manager.py\",\n  line 240, in start_kernel self.write_connection_file() File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\connect.py\",\n  line 476, in write_connection_file kernel_name=self.kernel_name File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\connect.py\",\n  line 141, in write_connection_file with secure_write(fname) as f: File\n  \"C:\\Users\\AppData\\Local\\Continuum\\anaconda3\\lib\\contextlib.py\", line\n  112, in enter return next(self.gen) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_core\\paths.py\",\n  line 404, in secure_write win32_restrict_file_to_user(fname) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_core\\paths.py\",\n  line 359, in win32_restrict_file_to_user import win32api ImportError:\n  DLL load failed: The specified procedure could not be found.","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":8153,"Q_Id":58341160,"Users Score":0,"Answer":"Follow this to resolve the issue when a kernel is dead.\npip install --upgrade pywin32==224 (downgrade the pywin32 from 225 to 224)\nor\npip install --upgrade pywin32==224 --user\nIf the above still not work and one prompt appears that pythoncom37.dll should not be the path 'C:\\Windows\\System32' then remove the 'pythoncom37.dll' from 'C:\\Windows\\System32'.","Q_Score":6,"Tags":"python,python-3.x,jupyter-notebook,kernel","A_Id":66280962,"CreationDate":"2019-10-11T12:20:00.000","Title":"Getting kernel error while trying to open Jupyter notebook or Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"While opening Jupyter notebook or Spyder, I am continuously getting 'kernel error' notification. \nTried to reinstall anaconda3, ipython, kernel but the issue stays. I had downloaded Python 3.7 in Windows 10 system.\nI am getting the below error in log.\n\"> Traceback (most recent call last): File\n\"> \"C:\\Users\\AppData\\Local\\Continuum\\anaconda3\\lib\\site\u2011packages\\spyder\\plugins\\ipytho\"nconsole.py\",\n\nline 1572, in create_kernel_manager_and_kernel_client\n  kernel_manager.start_kernel(stderr=stderr_handle) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\manager.py\",\n  line 240, in start_kernel self.write_connection_file() File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\connect.py\",\n  line 476, in write_connection_file kernel_name=self.kernel_name File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\connect.py\",\n  line 141, in write_connection_file with secure_write(fname) as f: File\n  \"C:\\Users\\AppData\\Local\\Continuum\\anaconda3\\lib\\contextlib.py\", line\n  112, in enter return next(self.gen) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_core\\paths.py\",\n  line 404, in secure_write win32_restrict_file_to_user(fname) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_core\\paths.py\",\n  line 359, in win32_restrict_file_to_user import win32api ImportError:\n  DLL load failed: The specified procedure could not be found.","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":8153,"Q_Id":58341160,"Users Score":0,"Answer":"If you are working in a miniconda on conda environment. You could just install pywin32 using conda instead of pip.\nThis solved my problem\nconda install pywin32","Q_Score":6,"Tags":"python,python-3.x,jupyter-notebook,kernel","A_Id":67970035,"CreationDate":"2019-10-11T12:20:00.000","Title":"Getting kernel error while trying to open Jupyter notebook or Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"While opening Jupyter notebook or Spyder, I am continuously getting 'kernel error' notification. \nTried to reinstall anaconda3, ipython, kernel but the issue stays. I had downloaded Python 3.7 in Windows 10 system.\nI am getting the below error in log.\n\"> Traceback (most recent call last): File\n\"> \"C:\\Users\\AppData\\Local\\Continuum\\anaconda3\\lib\\site\u2011packages\\spyder\\plugins\\ipytho\"nconsole.py\",\n\nline 1572, in create_kernel_manager_and_kernel_client\n  kernel_manager.start_kernel(stderr=stderr_handle) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\manager.py\",\n  line 240, in start_kernel self.write_connection_file() File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\connect.py\",\n  line 476, in write_connection_file kernel_name=self.kernel_name File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\connect.py\",\n  line 141, in write_connection_file with secure_write(fname) as f: File\n  \"C:\\Users\\AppData\\Local\\Continuum\\anaconda3\\lib\\contextlib.py\", line\n  112, in enter return next(self.gen) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_core\\paths.py\",\n  line 404, in secure_write win32_restrict_file_to_user(fname) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_core\\paths.py\",\n  line 359, in win32_restrict_file_to_user import win32api ImportError:\n  DLL load failed: The specified procedure could not be found.","AnswerCount":8,"Available Count":5,"Score":0.049958375,"is_accepted":false,"ViewCount":8153,"Q_Id":58341160,"Users Score":2,"Answer":"pip install pywin32 -U\nShould do the trick","Q_Score":6,"Tags":"python,python-3.x,jupyter-notebook,kernel","A_Id":59352335,"CreationDate":"2019-10-11T12:20:00.000","Title":"Getting kernel error while trying to open Jupyter notebook or Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"While opening Jupyter notebook or Spyder, I am continuously getting 'kernel error' notification. \nTried to reinstall anaconda3, ipython, kernel but the issue stays. I had downloaded Python 3.7 in Windows 10 system.\nI am getting the below error in log.\n\"> Traceback (most recent call last): File\n\"> \"C:\\Users\\AppData\\Local\\Continuum\\anaconda3\\lib\\site\u2011packages\\spyder\\plugins\\ipytho\"nconsole.py\",\n\nline 1572, in create_kernel_manager_and_kernel_client\n  kernel_manager.start_kernel(stderr=stderr_handle) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\manager.py\",\n  line 240, in start_kernel self.write_connection_file() File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\connect.py\",\n  line 476, in write_connection_file kernel_name=self.kernel_name File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_client\\connect.py\",\n  line 141, in write_connection_file with secure_write(fname) as f: File\n  \"C:\\Users\\AppData\\Local\\Continuum\\anaconda3\\lib\\contextlib.py\", line\n  112, in enter return next(self.gen) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_core\\paths.py\",\n  line 404, in secure_write win32_restrict_file_to_user(fname) File\n  \"C:\\Users\\AppData\\Roaming\\Python\\Python37\\site\u2011packages\\jupyter_core\\paths.py\",\n  line 359, in win32_restrict_file_to_user import win32api ImportError:\n  DLL load failed: The specified procedure could not be found.","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":8153,"Q_Id":58341160,"Users Score":0,"Answer":"Copying the win32api file from the ..\/\/site-packages\/win32 folder to the ..\/\/site-packages\/\/jupyter_core folder finally did the trick for me.","Q_Score":6,"Tags":"python,python-3.x,jupyter-notebook,kernel","A_Id":65292715,"CreationDate":"2019-10-11T12:20:00.000","Title":"Getting kernel error while trying to open Jupyter notebook or Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Amazon suggests to not include big libraries\/dependencies in lambda functions.\nAs far as I know, SQLAlchemy is quite a big python library. Do you think it is a good idea to use it in lambda functions? An option would be to include it as a Lambda Layer and use it across all related Lambda functions.\nAnyways, what is the best practise?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7485,"Q_Id":58341292,"Users Score":0,"Answer":"From what I read, SQLAlchemy performs in memory caching of data it has read and uses that for future calls.  Based on what you are doing, it would be good to check out the SQLAlchemy caching strategy so another Lambda does not change the data from under the first lambda with SQLAlchemy.","Q_Score":12,"Tags":"python,sqlalchemy,aws-lambda,serverless-framework,aws-lambda-layers","A_Id":64030658,"CreationDate":"2019-10-11T12:27:00.000","Title":"Is it a good idea to use Python SQLAlchemy in AWS Lambda?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Amazon suggests to not include big libraries\/dependencies in lambda functions.\nAs far as I know, SQLAlchemy is quite a big python library. Do you think it is a good idea to use it in lambda functions? An option would be to include it as a Lambda Layer and use it across all related Lambda functions.\nAnyways, what is the best practise?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":7485,"Q_Id":58341292,"Users Score":1,"Answer":"Serverless functions are meant to be small self-contained functions. SQLAlchemy is an ORM, which allows you to manipulate database objects like objects in python. If you're just writing a few serverless functions that do you're average CRUD operations on a database you're better off writing the SQL by composing the strings and directly executing that through your database driver (which you'll have to install anyways, even if you're using sqlalchemy). If you're building your own framework on top of AWS Lambda then perhaps consider sqlalchemy.","Q_Score":12,"Tags":"python,sqlalchemy,aws-lambda,serverless-framework,aws-lambda-layers","A_Id":62886393,"CreationDate":"2019-10-11T12:27:00.000","Title":"Is it a good idea to use Python SQLAlchemy in AWS Lambda?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the following error when running a CNN made in keras\n\nFile\n  \"venv\/lib\/python3.6\/site-packages\/keras\/backend\/tensorflow_backend.py\",\n  line 4185, in truncated_normal\n      return tf.truncated_normal(shape, mean, stddev, dtype=dtype, seed=seed) AttributeError: module 'tensorflow' has no attribute\n  'truncated_normal'\n\nI have already installed and reinstalled Tensorflow 2.0 several times. What could be happening?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":8138,"Q_Id":58341433,"Users Score":3,"Answer":"Keras 2.2.4 does not support TensorFlow 2.0 (it was released much before TF 2.0), so you can either downgrade TensorFlow to version 1.x, or upgrade Keras to version 2.3, which does support TensorFlow 2.0.","Q_Score":3,"Tags":"python,tensorflow,keras","A_Id":58342047,"CreationDate":"2019-10-11T12:36:00.000","Title":"Error when running tensorflow in virtualenv: module 'tensorflow' has no attribute 'truncated_normal'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the following error when running a CNN made in keras\n\nFile\n  \"venv\/lib\/python3.6\/site-packages\/keras\/backend\/tensorflow_backend.py\",\n  line 4185, in truncated_normal\n      return tf.truncated_normal(shape, mean, stddev, dtype=dtype, seed=seed) AttributeError: module 'tensorflow' has no attribute\n  'truncated_normal'\n\nI have already installed and reinstalled Tensorflow 2.0 several times. What could be happening?","AnswerCount":3,"Available Count":2,"Score":0.3215127375,"is_accepted":false,"ViewCount":8138,"Q_Id":58341433,"Users Score":5,"Answer":"In Tensorflow v2.0 and above, \"tf.truncated_normal\" replaced with \"tf.random.truncated_normal\"","Q_Score":3,"Tags":"python,tensorflow,keras","A_Id":67832940,"CreationDate":"2019-10-11T12:36:00.000","Title":"Error when running tensorflow in virtualenv: module 'tensorflow' has no attribute 'truncated_normal'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I understand how it works when you have one column output but could not understand how it is done for 4 column outputs.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":49,"Q_Id":58342612,"Users Score":1,"Answer":"It\u2019s not advised to calculate accuracy for continuous values. For such values you would want to calculate a measure of how close the predicted values are to the true values. This task of prediction of continuous values is known as regression. And generally R-squared value is used to measure the performance of the model.\nIf the predicted output is of continuous values then mean square error is the right option \nFor example:\nPredicted o\/p vector1-----> [2,4,8] and\nActual o\/p vector1 -------> [2,3.5,6]\n1.Mean square error is  sqrt((2-2)^2+(4-3.5)^2+(8-6)^2 )\n2.Mean absolute error..etc.\n(2)if the output is of classes then accuracy is the right metric to decide on model performance\nPredicted o\/p vector1-----> [0,1,1]\nActual o\/p vector1 -------> [1,0,1]\nThen accuracy calculation can be done with following:\n1.Classification Accuracy\n2.Logarithmic Loss\n3.Confusion Matrix\n4.Area under Curve\n5.F1 Score","Q_Score":0,"Tags":"python-3.x,tensorflow,neural-network,conv-neural-network,recurrent-neural-network","A_Id":60562288,"CreationDate":"2019-10-11T13:46:00.000","Title":"I have a network with 3 features and 4 vector outputs. How is MSE and accuracy metric calculated?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried type(+) hoping to know more about how is this operator represented in python but i got SyntaxError: invalid syntax.\nMy main problem is to cast as string representing an operation :\"3+4\" into the real operation to be computed in Python (so to have an int as a return: 7).\nI am also trying to avoid easy solutions requiring the os library if possible.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":58342835,"Users Score":7,"Answer":"Operators don't really have types, as they aren't values. They are just syntax whose implementation is often defined by a magic method (e.g., + is defined by the appropriate type's __add__ method).\nYou have to parse your string:\n\nFirst, break it down into tokens: ['3', '+', '4']\nThen, parse the token string into an abstract syntax tree (i.e., something at stores the idea of + having 3 and 4 as its operands).\nFinally, evaluate the AST by applying functions stored at a node to the values stored in its children.","Q_Score":0,"Tags":"python,python-3.x,python-2.7","A_Id":58342863,"CreationDate":"2019-10-11T13:57:00.000","Title":"What are the types of Python operators?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a server extension for jupyter lab and i can use ServerConnection.makeRequest() from @jupyterlab\/services to send POST or GET to my custom URL in typescript.\nNow i want to make some request from notebook to this URL by using library requests of python but i always get 403 error.\nIs there any equivalent of ServerConnection.makeRequest() in jupyter lab python library to send request to server ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":108,"Q_Id":58342869,"Users Score":1,"Answer":"Your request from within a notebook is most likely forbidden due to the xsrf check by the jupyter server. When you start jupyter server pass the parameter --NotebookApp.disable_check_xsrf=True in the command line to disable it. Or you need to handle passing the xsrf token. Note that disabling this check in an external-facing (production) system is not recommended.\nYou may also have to pass or suppress token. The token can be suppressed by passing --NotebookApp.token='' when you start the server.","Q_Score":0,"Tags":"python,jupyter,jupyter-lab","A_Id":58343883,"CreationDate":"2019-10-11T13:59:00.000","Title":"Equivalent of ServerConnection.makeRequest() on python side","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a database in pythonanywhere, after doing my migrations from my django project etc.. i wanted to create a trigger in my db, but the following message appears:\n\nERROR 1419 (HY000): You do not have the SUPER privilege and binary logging is enabled (you might want to use the less safe log_bin_trust_function_creators variable)\n\nMy user does not have the permissions","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":107,"Q_Id":58345033,"Users Score":1,"Answer":"You cannot create triggers in MySQL on PythonAnywhere","Q_Score":1,"Tags":"mysql,mysql-python,pythonanywhere","A_Id":58355715,"CreationDate":"2019-10-11T16:12:00.000","Title":"ERROR 1044 creating a trigger in mysql on pythonanywhere","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have Fico Xpress solver installed in my mac. I can run my optimization model from command line. Before doing so, I run . \/Applications\/FICO\\ Xpress\/xpressmp\/bin\/xpvars.sh which runs a number of commands such as CLASSPATH=${XPRESSDIR}\/lib\/xprs.jar:${CLASSPATH}, export CLASSPATH etc. \nThe issue is when I want to run the model in Pycharm. Pycharm doesn't seem to be able to find Xpress. The the 'optimizer' executable of Xpress cannot be found. In fact, I cannot even import xpress. \nAs a potential solution, I would like to be able to launch the xpvar.sh script before I run Pycharm. \nI have been trying to use External Tool option in Pycharm, but get the error message Source this script by running 'source \/Applications\/fico\/xpressmp\/bin\/xpvars.sh'\nHere are the parameters I set in my External Tool:\nProgram: \/Applications\/fico\/xpressmp\/bin\/xpvars.sh\nArguments: source\nWorking Directory: \/Applications\/fico\/xpressmp\/bin\/ \nAny other potential solutions are also very welcome. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":193,"Q_Id":58346046,"Users Score":1,"Answer":"The problem seems to be that PyCharm is a GUI application and does not read the .bash_profile or .bashrc files where most environment variables are set. What worked for me is using the EnvFile plugin for PyCharm (I'm using the Community Edition 2019.2):\n\nUnder Preferences->Plugin, search for EnvFile;\nInstall the plugin, then restart PyCharm;\nCreate a .env file (e.g. myvars.env) containing all variables you need, one per line, in the format VARNAME=VALUE\nLoad your project, then under Run->Edit configurations, select the EnvFile tab;\nClick on the \"+\" to add your myvars.env;\nMaybe restart PyCharm again.\n\nAt this point your variables should be available to your Python application.","Q_Score":0,"Tags":"python,bash,macos,pycharm,pyomo","A_Id":58602968,"CreationDate":"2019-10-11T17:33:00.000","Title":"Launch a bash script before running my optimization model 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"During inference, when the models are being loaded, Cuda throws InternalError: CUDA runtime implicit initialization on GPU:0 failed. Status: out of memory. \nI am performing inference on a machine with 6GB of VRAM. A few days back, the machine was able to perform the tasks, but now I am frequently getting these messages. Restarting the device sometimes does help, but is not a viable solution. I have checked through nvidia-smi, but it is also showing only about 500 MB of VRam being used and I was not able to see any spike in memory usage when tensorflow was trying to load the models.\nI am currently using tensorflow 1.14.0 and python 3.7.4","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2542,"Q_Id":58350456,"Users Score":2,"Answer":"I am using Tensorflow 2.3.0 on a remote server. My code was working fine, but suddenly the server gets disconnected from the network, and my training stopped. When I re-run the code I got the same issue you got. So I guess this problem is related to GPU being busy in something not existing anymore. Clearing the session as the comment said is enough to solve the problem (I also believe restarting the machine can also fix the problem but I did not get the chance to try this solution).\nfor tensorflow 2.3 use tf.kerasbackend.clear_session() it solve the issue","Q_Score":0,"Tags":"python,tensorflow","A_Id":68995590,"CreationDate":"2019-10-12T02:55:00.000","Title":"CUDA goes out of memory during inference and gives InternalError: CUDA runtime implicit initialization on GPU:0 failed. Status: out of memory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install a virtualenv in windows 10 using a step process I found on some website. The steps are as follows, but only care about 1-4 for now:\n\nRun Windows Power Shell as Administrator\npip install virtualenv\npip install virtualenvwrapper-win\nmkvirtualenv \u2018C:\\Users\\username\\Documents\\Virtualenv\u2019\ncd Test\nSet-ExecutionPolicy AllSigned | Press Y and Enter\nSet-ExecutionPolicy RemoteSigned | Press Y and Enter\n.\\Scripts\\activate\ndeactivate\n\nSteps 1-3 work fine, but when I try step four I get the following response:\nPS C:\\WINDOWS\\system32> mkvirtualenv 'C:\\Users\\username\\Documents\\Virtualenv'\nUsing base prefix 'c:\\users\\username\\appdata\\local\\programs\\python\\python37-32'\nNew python executable in C:\\Users\\DANIEL~1\\DOCUME~1\\VIRTUA~1\\Scripts\\python.exe\nInstalling setuptools, pip, wheel...\ndone.\nThe filename, directory name, or volume label syntax is incorrect.\nThe filename, directory name, or volume label syntax is incorrect.\nThe filename, directory name, or volume label syntax is incorrect.\nThe cd step following right afterwords does not work aswell. I am pretty new to python\/programming in general so I might be missing some basic things.\nrunning step 5 gives the following error message: \ncd : Cannot find path 'C:\\WINDOWS\\system32\\Virtualenv' because it does not exist.\nAt line:1 char:1\n+ cd Virtualenv\n+ ~~~~~~~~~~~~~\n    + CategoryInfo          : ObjectNotFound: (C:\\WINDOWS\\system32\\Virtualenv:String) [Set-Location], ItemNotFoundExce\n   ption\n    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand  \nHow do I fix this? Thanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":269,"Q_Id":58351041,"Users Score":0,"Answer":"1) set virtual environment directory in path variable- export WORKON_HOME=(directory you need to save envs)\n2) source \/usr\/local\/bin\/virtualenvwrapper.sh -p $WORKON_HOME\nsource which virtualenvwrapper.sh or which virtualenvwrapper.sh can used to locate virtualenvwrapper.sh file.\nIt's best to put above two lines in ~\/.bashrc to avoid executing the above commands every time you open new shell. That's all you need to create environment using mkvirtualenv","Q_Score":0,"Tags":"python,powershell,virtualenv","A_Id":58351127,"CreationDate":"2019-10-12T05:08:00.000","Title":"Trouble installing python VirtualEnv in windows 10 using powershell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install a virtualenv in windows 10 using a step process I found on some website. The steps are as follows, but only care about 1-4 for now:\n\nRun Windows Power Shell as Administrator\npip install virtualenv\npip install virtualenvwrapper-win\nmkvirtualenv \u2018C:\\Users\\username\\Documents\\Virtualenv\u2019\ncd Test\nSet-ExecutionPolicy AllSigned | Press Y and Enter\nSet-ExecutionPolicy RemoteSigned | Press Y and Enter\n.\\Scripts\\activate\ndeactivate\n\nSteps 1-3 work fine, but when I try step four I get the following response:\nPS C:\\WINDOWS\\system32> mkvirtualenv 'C:\\Users\\username\\Documents\\Virtualenv'\nUsing base prefix 'c:\\users\\username\\appdata\\local\\programs\\python\\python37-32'\nNew python executable in C:\\Users\\DANIEL~1\\DOCUME~1\\VIRTUA~1\\Scripts\\python.exe\nInstalling setuptools, pip, wheel...\ndone.\nThe filename, directory name, or volume label syntax is incorrect.\nThe filename, directory name, or volume label syntax is incorrect.\nThe filename, directory name, or volume label syntax is incorrect.\nThe cd step following right afterwords does not work aswell. I am pretty new to python\/programming in general so I might be missing some basic things.\nrunning step 5 gives the following error message: \ncd : Cannot find path 'C:\\WINDOWS\\system32\\Virtualenv' because it does not exist.\nAt line:1 char:1\n+ cd Virtualenv\n+ ~~~~~~~~~~~~~\n    + CategoryInfo          : ObjectNotFound: (C:\\WINDOWS\\system32\\Virtualenv:String) [Set-Location], ItemNotFoundExce\n   ption\n    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand  \nHow do I fix this? Thanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":269,"Q_Id":58351041,"Users Score":0,"Answer":"Use Anaconda, is the best way to manage your python packages, in my opinion.","Q_Score":0,"Tags":"python,powershell,virtualenv","A_Id":58351225,"CreationDate":"2019-10-12T05:08:00.000","Title":"Trouble installing python VirtualEnv in windows 10 using powershell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed tensorflow by using pip3, tensorflow also appears in the pip3 list, but when I try to import tensorflow by executing tensorflow in terminal, it says it cannot find the module tensorflow. when I start jupyter notebook, tensorflow import works fine. what can be the reason? I checked the sys.executable value in terminal and jupyter both. In terminal, it is '\/usr\/local\/bin\/python3', in jupyter it is '\/usr\/local\/opt\/python\/bin\/python3.7'.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":58353888,"Users Score":0,"Answer":"Enyang,there is high chance that the default is auto set to this path by jupyter. i faced a lot of problems having 2 python environments.\nhere are the troubleshooting trials:\ntrial 1:\n\ntry with pip and pip3 both and use argument -t, --target <dir> \n\ntrial 2:\n\nits the case that jupyter notebook has tweaked your python pip3 try changing pip default location.\n\ntrial 3 [will work for sure]:\n\nmanually copy paste to merge libraries in python installed path\/s.\n\n\ntrial 4 [obvious]:\n\n\ntry venv (virtual environment) and import your requirements from working version of pip freeze","Q_Score":0,"Tags":"python,tensorflow,pip,jupyter-notebook","A_Id":58354163,"CreationDate":"2019-10-12T11:53:00.000","Title":"pip3 installed library can't be found for python execution in terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to write a program to simulate 5-axis cnc gcode with vpython and I need to rotate trail of the object that's moving. Any idea how that can be done?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":58356337,"Users Score":0,"Answer":"It's difficult to know exactly what you need, but if instead of using \"make_trail=True\" simply create a curve object to which you append points. A curve object named \"c\" can be rotated using the usual way to rotate an object: c.rotate(.....).","Q_Score":0,"Tags":"python-3.x,vpython","A_Id":58893552,"CreationDate":"2019-10-12T16:46:00.000","Title":"How to rotate a object trail in vpython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I  am given a large data set with many variables is it possible to determine whether any two of them are independent or dependent? Lets assume I know nothing else about the data other than a statistical study.\nWould looking at the correlation\/covariance be able to determine this?\nThe purpose of this is to determine which variables would be the best to use in machine learning to predict a specific outcome. I have some variables with a correlation of 0.40 - 0.50 with one another but I'm not sure if a high correlation == dependence.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":58358757,"Users Score":0,"Answer":"Dependence and correlation are different. if 2 variables are dependent, then they are correlated. However, if they are correlated, it is not sure that they are dependent, we need domain knowledge to consider more. To check the correlation, we can use the Correlation Coefficient. For the dependence test, we can use the Chi-Square Test.","Q_Score":0,"Tags":"python,statistics,data-science,cross-validation","A_Id":58358854,"CreationDate":"2019-10-12T21:35:00.000","Title":"Dependent vs Independent Variables","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I share a project (through Github) with someone when my project is using multiple personal modules\/packages?\nUsing pip freeze > requirements.txt is obviously not enough, because there is no place to download packages I created specifically for this project.\nIs pushing the contents of the project in my repository as a virtual environment viable solution?\nWhat if I also need to have an older version of Python (3.6.5) for example?\nTy,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":58358850,"Users Score":0,"Answer":"What these \"personal modules\/packages\" are? The only reason to make a separate package is reusability. \nIf you do not plan to use it somewhere else, then just include them as modules in your project.\nIf you plan to use it somewhere else but don't think it could help somebody else then make a package and push it to to Github\/Gitlab\/Bitbucket\/etc. It's possible to install dependencies from there using pip.\nIf you plan to use it somewhere else and want to share your work with all the python community - deploy package on PyPI.","Q_Score":0,"Tags":"python,virtualenv","A_Id":58359239,"CreationDate":"2019-10-12T21:49:00.000","Title":"Sharing projects with external Python libraries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use tf.contrib.layers.fully_connected() in one of my projects, and it's been deprecated in tensorflow 2.0. Is there an equivalent function, or should I just keep tensorflow v1.x in my virtual environment for this projcet?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":9478,"Q_Id":58359881,"Users Score":4,"Answer":"In TensorFlow 2.0 the package tf.contrib has been removed (and this was a good choice since the whole package was a huge mix of different projects all placed inside the same box), so you can't use it.\nIn TensorFlow 2.0 we need to use tf.keras.layers.Dense to create a fully connected layer, but more importantly, you have to migrate your codebase to Keras. In fact, you can't define a layer and use it, without creating a tf.keras.Model object that uses it.","Q_Score":4,"Tags":"python,python-3.x,tensorflow,tensorflow2.0","A_Id":58361716,"CreationDate":"2019-10-13T01:25:00.000","Title":"tf.contrib.layers.fully_connected() in Tensorflow 2?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use tf.contrib.layers.fully_connected() in one of my projects, and it's been deprecated in tensorflow 2.0. Is there an equivalent function, or should I just keep tensorflow v1.x in my virtual environment for this projcet?","AnswerCount":4,"Available Count":3,"Score":0.2449186624,"is_accepted":false,"ViewCount":9478,"Q_Id":58359881,"Users Score":5,"Answer":"tf-slim, as a standalone package, already included tf.contrib.layers.you can install by pip install tf-slim,call it by from tf_slim.layers import layers as _layers;  _layers.fully_conntected(..).The same as the original, easy to replace","Q_Score":4,"Tags":"python,python-3.x,tensorflow,tensorflow2.0","A_Id":61319962,"CreationDate":"2019-10-13T01:25:00.000","Title":"tf.contrib.layers.fully_connected() in Tensorflow 2?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use tf.contrib.layers.fully_connected() in one of my projects, and it's been deprecated in tensorflow 2.0. Is there an equivalent function, or should I just keep tensorflow v1.x in my virtual environment for this projcet?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":9478,"Q_Id":58359881,"Users Score":0,"Answer":"tf.contrib.layers.fully_connected() is a perfect mess. It is a very old historical mark(or a prehistory DNN legacy). Google has completely deprecated the function since Google hated it. There is no any direct function in TensoFlow 2.x to replace tf.contrib.layers.fully_connected(). Therefore, it is not worth inquiring and getting to know the function.","Q_Score":4,"Tags":"python,python-3.x,tensorflow,tensorflow2.0","A_Id":64493808,"CreationDate":"2019-10-13T01:25:00.000","Title":"tf.contrib.layers.fully_connected() in Tensorflow 2?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to deep learning, I was wondering if there is a way to extract parts of images containing the different label and then feed those parts to different model for further processing?\nFor example,consider the dog vs cat classification.\nSuppose the image contains both cat and dog.\nWe successfully classify that the image contains both, but how can we classify the breed of the dog and cat present?\nThe approach I thought of was,extracting\/cutting out the parts of the image containing dog and cat.And then feed those parts to the respective dog breed classification model and cat breed classification model separately.\nBut I have no clue on how to do this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":170,"Q_Id":58362763,"Users Score":1,"Answer":"Your thinking is correct, you can have multiple pipelines based on the number of classes.\n\nTraining:\nMain model will be an object detection and localization model like Faster RCNN, YOLO, SSD etc trained to classify at a high level like cat and dog. This pipeline provides you bounding box details (left, bottom, right, top) along with the labels.\nSub models will be multiple models trained on a lover level. For example a model that is trained to classify breed. This can be done by using models like vgg, resnet, inception etc. You can utilize transfer learning here.\nInference: Pass the image through Main model, crop out the detection objects using bounding box details (left, bottom, right, top) and based on the label information, feed it appropriate sub model and extract the results.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,keras,deep-learning","A_Id":58363469,"CreationDate":"2019-10-13T10:37:00.000","Title":"How to extract\/cut out parts of images classified by the model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to make a related field with two other fields. Right according to my knowledge we can have only one. Is there is any other option?\nI don't want a compute field. Because the field should be editable.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":58363335,"Users Score":0,"Answer":"Computed field can also editable fields make it readonly=False and make store true for it so that it relate to your two fields if you make any change in them it will reflect in your computed field and if not then you can put your value in that field and store that field data so it can save its value also.","Q_Score":0,"Tags":"python,python-2.7,odoo,odoo-10","A_Id":58704915,"CreationDate":"2019-10-13T11:56:00.000","Title":"How to make a related field with two conditions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm new to dask and trying to use it in our cluster which uses NC job scheduler (from Runtime Design Automation, similar to LSF). I'm trying to create an NCCluster class similar to LSFCluster to keep things simple. \nWhat are the steps involved in creating a job scheduler for custom clusters?\nIs there any other way to interface dask to custom clusters without using JobQueueCluster?\nI could find info on how to use the LSFCluster\/PBSCluster\/..., but couldn't find much information on creating one for a different HPC.\nAny links to material\/examples\/docs will help\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":58364733,"Users Score":0,"Answer":"Got it working after going through the source code.\nTips for anyone trying:\n\nCreate a customCluster & customJob class similar to LSFCluster & LSFJob.\nOverride the following\n\n\nsubmit_command\ncancel_command\nconfig_name (you'll have to define it in the jobqueue.yaml)\nDepending on the cluster, you may need to override the _submit_job, _job_id_from_submit_ouput and other functions.\n\n\nHope this helps.","Q_Score":0,"Tags":"python,python-3.x,dask,dask-distributed","A_Id":58399685,"CreationDate":"2019-10-13T14:56:00.000","Title":"Creating dask_jobqueue schedulers to launch on a custom HPC","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As the title says, when i run pip3 freeze or pip3 list there is no output on the terminal!\nVirtualenv seems also to be broken cause when i was inside of the env it was using the global django-admin.\nI did  sudo pip3 install --upgrade pip and after that i think it broke.\n\nOS: Manjaro Linux \nPython3 Version: Python 3.7.4 \nPip3 Version: pip\n19.2.3 from \/usr\/lib\/python3.7\/site-packages\/pip (python 3.7)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":871,"Q_Id":58365032,"Users Score":1,"Answer":"Find out how to cleanly reinstall pip (or even Python) from your operating system and really try to avoid anything with sudo pip or even sudo python. My recommendation is to not even install pip at all and use the one preinstalled in the virtual environments (when you do python3 -m venv .venv) instead, this is to avoid any conflict with the Python packages installed by your operating system.","Q_Score":0,"Tags":"python,linux,pip,django-admin,virtualenv","A_Id":58374956,"CreationDate":"2019-10-13T15:28:00.000","Title":"When i run pip3 freeze or pip3 list there is no output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to implement for Keras a new optimization function that would not be based on the partial derivatives of the parameters, but also on the derivatives of these partial derivatives. How can I proceed?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":58365610,"Users Score":0,"Answer":"In fact, after having looked at the Keras code of the Optimizer 2-3 times, not only did I quickly give up trying to understand everything, but it seemed to me that the get_updates function simply returns the gradients already calculated, where I seek to directly access the partial derivation functions of the parameters in order to use the derivatives of these derivatives. So the gradients are useless ...","Q_Score":0,"Tags":"python,tensorflow,math,keras","A_Id":58468050,"CreationDate":"2019-10-13T16:35:00.000","Title":"How to define a new optimization function for Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say the prompt is, \"What is the store number?\" \nThe user types in 123 and hits start and what's printed is an IP address in the form of \"10.1.23.111\" where [10] and [111] are always fixed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":58365749,"Users Score":0,"Answer":"Simple answer - you can't from just entering your 3 digits in your example (i.e: 123) as any octet within an IPv4 address (###.###.###.###) can be a value between 0-255.\nHowever, if you format the User's input to take that into consideration (i.e: 1023) to create 10.1.023.111, that'll be significantly easier.","Q_Score":0,"Tags":"python,json,selenium,tkinter","A_Id":58365799,"CreationDate":"2019-10-13T16:52:00.000","Title":"How would I take a 3 digit number from a Tkinter entry and translate it into an IP address?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using a for loop and inside that forloop i generate tables out of DataBase data.\nThe thing is that i need to show multiple tables, but the if statement in Jinja2 doesn't seem to work for some reason. I need to check if the string on index 2 of my_list[2] is equal to the 'None'.\n{% if '{{my_list[2]}}' == 'None' %}\n   There is no connection. \n{% else %}\n   There is a GOOD connection.\n{% endif %}\nWhy isn't this working?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":58367566,"Users Score":0,"Answer":"{% if not customer_list[2] %}\nThis does exactly wat i needed.","Q_Score":0,"Tags":"jinja2,python-3.7","A_Id":58367736,"CreationDate":"2019-10-13T20:31:00.000","Title":"How do i compare a String out of a list in Jinja2 to another string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to get some code working on mac and to do that I have been using an anaconda virtual environment. I have all of the dependencies loaded as well as my script, but I don't know how to execute my file in the virtual environment on mac. The python file is on my desktop so please let me know how to configure the path if I need to. Any help?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":58368638,"Users Score":1,"Answer":"If you have a terminal open and are in your virtual environment then simply invoking the script should run it in your environment.","Q_Score":0,"Tags":"python,python-3.x,macos,anaconda","A_Id":58368730,"CreationDate":"2019-10-13T23:43:00.000","Title":"How to run a python script using an anaconda virtual environment on mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"May I know if we can use variable\/array in the arrays_zip function ??\nFor example I declare and array \narray1=[\"col1\",\"col2\"]\nthen in the dataframe. I write the following :\ndf.withColumn(\"zipped\",arrays_zip(array1))\nthen it tells me it's not a valid argument not a string or column\nany one has the idea ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":376,"Q_Id":58369843,"Users Score":0,"Answer":"using the following:\narray=[\"col1\",\"col2\"]\ndf.select(arrays_zip(*[c for c in array]]).show()\nThanks","Q_Score":0,"Tags":"python,databricks","A_Id":58385939,"CreationDate":"2019-10-14T03:42:00.000","Title":"DataBricks: using variable in arrays_zip function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a webpage(Wordpress) updating some tabel information in the MySQL database. And i have a client application on aother pc runing a standalone Pythonscript accessing the same MySQL server for getting and setting data. \nHow do i implment a trigger from my webside that can trigger an event in my python code to see if the data in database are updated, without polling the mysql db ?\nIs there som simple Message Queue I can implement easy or how.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":58372159,"Users Score":1,"Answer":"One solution is to use sockets, another solution is to convert python script into webapp with api (e.g. use Flask) and when your wordpress page sends get\/post http request to python script and tirgger python script to go checking db. The second one is easier to implement from my point of view. Sockets are more difficult for me.","Q_Score":0,"Tags":"python,mysql,wordpress","A_Id":58372282,"CreationDate":"2019-10-14T07:43:00.000","Title":"How do i sent a event from a webpage to a client application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to add a new face features into trained face recognition model, without retraining it with previous faces?\nCurrently am using facenet architecture,","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":718,"Q_Id":58372751,"Users Score":0,"Answer":"basically, by the mathematics theory behind the machine learning models, you basically need to do another train iteration with only this new data...\nbut, in practice, those models, especially the sophisticated ones, rely on multiple iterations for training and a various technics of suffering and nose reductions\na good approach can be train of the model from previous state with a subset of the data that include the new data, for a couple of iterations","Q_Score":0,"Tags":"python-3.x,machine-learning,computer-vision,face-recognition,object-recognition","A_Id":58375333,"CreationDate":"2019-10-14T08:24:00.000","Title":"How to we add a new face into trained face recognition model(inception\/resnet\/vgg) without retraining complete model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to add a new face features into trained face recognition model, without retraining it with previous faces?\nCurrently am using facenet architecture,","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":718,"Q_Id":58372751,"Users Score":1,"Answer":"Take a look in Siamese Neural Network.\nActually if you use such approach you don't need to retrain the model.\nBasically you train a model to generate an embedding (a vector) that maps similar images near and different ones far.\nAfter you have this model trainned, when you add a new face it will be far from the others but near of the samples of the same person.","Q_Score":0,"Tags":"python-3.x,machine-learning,computer-vision,face-recognition,object-recognition","A_Id":59680250,"CreationDate":"2019-10-14T08:24:00.000","Title":"How to we add a new face into trained face recognition model(inception\/resnet\/vgg) without retraining complete model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am stuck with this issue \n\nImportError: No module named watchdog.observers\n\nI have done pip install and whatever I can find.\nI am running on macOS --version Catalina.\nPlease help if you have any suggestions how to solve this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4963,"Q_Id":58373847,"Users Score":0,"Answer":"Try importing a specific class\/function:\nfrom watchdog.observers import Observer\n\nTry installing watchdog with root-privileges for your version of python:\nsudo pip install watchdog\nor\nsudo pip2 install watchdog\nor\nsudo pip3 install watchdog\n\n\nSeeing your code would be helpful.","Q_Score":0,"Tags":"python-3.x,macos,watchdog","A_Id":58374610,"CreationDate":"2019-10-14T09:28:00.000","Title":"ImportError: No module named watchdog.observers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use jupyter-notebook in vs-code with the newest python extension, but always fail to launch jupyter notebook server\nThe jupyter notebook was installed by anoconda, and it works if i just type 'jupyter notebook' in cmd window.\nJupyter notebook failed to launch. Error: The Jupyter notebook server failed to launch in time","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3055,"Q_Id":58374498,"Users Score":2,"Answer":"Yi Wang and I worked on debugging this over e-mail, but putting the answer back here on SO to make sure that anyone else hitting this issues sees it. The issue here was that the Python Path setting in vscode was set to point to pythonw.exe and not python.exe. I'm going to file an issue on the VSCode extension to provide a better warning in this situation. \nThanks again Yi Want for providing the logs that let us debug this.","Q_Score":3,"Tags":"python,visual-studio-code,jupyter-notebook","A_Id":58805566,"CreationDate":"2019-10-14T10:07:00.000","Title":"How to fix 'jupyter notebook server failed to launch in time' in vscode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Windows 10, CPU: Intel(R) Core(TM) 2 Duo CPU T6600 @ 2.2GHz (2 CPUs) ~2.2GHz. RAM: 4GB. Video card: ATI Mobility Radeon HD 3400 Series.\nI uninstalled everything and then\nI installed Python 3.6 and Tensorflow==1.10.0. When I do import tensorflow, I get this error.\n\nmodulenotfounderror no module named '_pywrap_tensorflow_internal'\n\nI can install whichever Python\/Tensorflow version you want. I just want to use Tensorflow. I saw similar issues, but none of them seems to be solving my issue.\nI know there are many similar questions on github\/stackoverflow, but none of them seems to help me.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":242,"Q_Id":58374635,"Users Score":1,"Answer":"Mentioning the Answer here for the benefit of the Community.\nIssue is resolved by using Python==3.6, Tensorflow==1.5, protobuf==3.6.0.","Q_Score":4,"Tags":"python,tensorflow","A_Id":59246432,"CreationDate":"2019-10-14T10:15:00.000","Title":"modulenotfounderror no module named '_pywrap_tensorflow_internal'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a recommender system using collaborative filtering.\n\nI am having user-item dataset. I am unable to find similarity between similar user, since i cannot use  Euclidean \/ Cosine distance will not work here. \nIf i convert categorical variable into 0, 1 then will not able to calculate distance.\nCan you please suggest any recommendation algorithm in python which handles categorical data.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2649,"Q_Id":58376140,"Users Score":1,"Answer":"One good example to calculate distance between categorical features is Hamming Distance where we calculate the number of different instances.\nOn the other hand, you can still calculate Cosine Similarity for user-item data set.\nAs an example; \nuser 1 buys item 1, item 2\nuser 2 buys item 2, item 3\nThen, user vectors are;\nuser 1 = [1, 1, 0]\nuser 2 = [0, 1, 1]\nAnd cosine similarity will be 0.5\nSame rules apply for items.","Q_Score":0,"Tags":"python,recommendation-engine,collaborative-filtering","A_Id":58376285,"CreationDate":"2019-10-14T11:48:00.000","Title":"How to calculate similarity between categorical variables in collaborative filtering","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a recommender system using collaborative filtering.\n\nI am having user-item dataset. I am unable to find similarity between similar user, since i cannot use  Euclidean \/ Cosine distance will not work here. \nIf i convert categorical variable into 0, 1 then will not able to calculate distance.\nCan you please suggest any recommendation algorithm in python which handles categorical data.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2649,"Q_Id":58376140,"Users Score":0,"Answer":"Cosine similarity will handle the problem as a whole vector which includes all values of the variable. And may not give the answer for correlation. So when you received a good score from cosine similarity, it will not make sure they are also correlated.","Q_Score":0,"Tags":"python,recommendation-engine,collaborative-filtering","A_Id":62181010,"CreationDate":"2019-10-14T11:48:00.000","Title":"How to calculate similarity between categorical variables in collaborative filtering","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a sequence tagging model that predicts a tag for every word in an input sequence (essentially named entity recognition). Model structure: Embeddings layer \u2192 BiLSTM  \u2192 CRF\nSo essentially the BiLSTM learns non-linear combinations of features based on the token embeddings and uses these to output the unnormalized scores for every possible tag at every timestep. The CRF classifier then learns how to choose the best tag sequence given this information.\nMy CRF is an instance of the keras_contrib crf, which implements a linear chain CRF (as does tensorflow.contrib.crf). Thus it considers tag transition probabilities from one tag to the next but doesn't maximize the global tag sequence (which a general CRF would).\nThe default activation function is 'linear'. My question is, why is it linear, and what difference would other activations make?\nI.e., is it linear because it's decisions are essentially being reduced to predicting the likelihood of tag yt given tag y-1 (which could possibly be framed as a linear regression problem)? Or is it linear for some other reason, e.g. giving the user flexibility to apply the CRF wherever they like and choose the most appropriate activation function themselves?\nFor my problem, should I actually be using softmax activation? I already have a separate model with a similar but different structure: Embeddings  \u2192  BiLSTM  \u2192 Dense with softmax. So I if I were to use softmax activation in the linear chain CRF (i.e. in the Embeddings layer \u2192 BiLSTM  \u2192 CRF I mentioned at the start of this post), it sounds like it would be nearly identical to that separate model except for being able to use transition probabilities from yt-1 to yt.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":458,"Q_Id":58377983,"Users Score":1,"Answer":"When using Embeddings \u2192 BiLSTM \u2192 Dense + softmax, you implicitly assume that the likelihood of the tags is conditionally independent given the RNN states. This can lead to the label bias problem. The distribution over the tags always needs to sum up to one. There is no way to express that the model is not certain about the particular tag does an independent prediction for that.\nIn a CRF, this can get fixed using the transition scores that the CRF learns in addition to scoring the hidden states. The score for the tag can be an arbitrary real number. If the model is uncertain about a tag, all scores can be low (because they do not have to sum up to one) and predictions from the neighboring tags might help in choosing what tag to chose via the transition scores. The likelihood of the tags is not factorized over the sequence but computed for the entire sequence of tags using a dynamic programming algorithm.\nIf you used an activation function with a limited range, it would limit what scores can be assigned to the tags and might the CRF not efficient. If you think you need a non-linearity after the RNN, you can add one dense layer with activation of your choice and then do the linear projection.","Q_Score":2,"Tags":"python,tensorflow,keras,neural-network,crf","A_Id":58378980,"CreationDate":"2019-10-14T13:35:00.000","Title":"Which actvation function to use for linear-chain CRF classifier?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In rivescript, if a user asks me the price of a certain item, I want the bot to look for that items' price in the csv file. Im new to to rivescript so any kind of help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":58378873,"Users Score":0,"Answer":"you can use macro for doing this. \n> object read_from_csv python\n   #code to read from CSV\n    return \"\"\n< object\nFrom rive response\n-<call>read_from_csv <star><\/call>","Q_Score":1,"Tags":"python,csv,rivescript","A_Id":59798103,"CreationDate":"2019-10-14T14:28:00.000","Title":"How to bring variable values from csv to rivescript?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to deploy a Python webapp on AWS that takes a USERNAME and PASSWORD as input from a user, inputs them into a template Python file, and logs into their Instagram account to manage it automatically. \nIn Depth Explanation:\nI am relatively new to AWS and am really trying to create an elaborate project so I can learn. I was thinking of somehow receiving the user input on a simple web page with two text boxes to input their Instagram account info (username & pass). Upon receiving this info, my instinct tells me that I could somehow use Lambda to quickly inject it into specific parts of an already existing template.py file, which will then be taken and combined with the rest of the source files to run the code. These source files could be stored somewhere else on AWS (S3?). I was thinking of running this using Elastic Beanstalk. \nI know this is awfully involved, but my main issue is this whole dynamic injection thing. Any ideas would be so greatly appreciated. In the meantime, I will be working on it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":58380298,"Users Score":0,"Answer":"One way in which you could approach this would be have a hosted website on a static s3 bucket. Then, when submitting a request, goes to an API Gateway POST endpoint, This could then trigger a lambda (in any language of choice) passing in the two values.\nThis would then be passed into the event object of the lambda, you could store these inside secrets manager using the username as the Key name so you can reference it later on. Storing it inside a file inside a lambda is not a good approach to take. \nUsing this way you'd learn some key services:\n\nS3 + Static website Hosting\nAPI Gateway \nLambdas  \nSecrets Manager\n\nYou could also add alias's\/versions to the lambda such as dev or production and same concept to API Gateways with stages to emulate doing a deployment.\nHowever there are hundreds of different ways to also design it. And this is only one of them!","Q_Score":2,"Tags":"python,amazon-web-services,amazon-s3,amazon-ec2,aws-lambda","A_Id":58380658,"CreationDate":"2019-10-14T15:59:00.000","Title":"Dynamically Injecting User Input Values into Python 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":0,"Web Development":1},{"Question":"I have this html code:\n<button class=\"_2ic5v\"><span aria-label=\"Like\" class=\"glyphsSpriteComment_like u-__7\"><\/span><\/button>\nI am trying to locate all the elements that meet this class with phyton, and selenium webdriver library:\nlikeBtn = driver.find_elements_by_class_name('_2ic5v')\nbut when I print \nlikeBtn\nit prints \n[]\nI want to locate all of the buttons that much this div\/span class, or aria-label\nhow do I do that successfully? Thanks in advance\nupdate - when I do copy Xpath from page the print stays the same","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":544,"Q_Id":58382323,"Users Score":0,"Answer":"Is it button class name dynamic or static? \nHow if you try choose By.CssSelector?\nYou can find element by copy selector in element","Q_Score":1,"Tags":"python,selenium,selenium-webdriver","A_Id":58391703,"CreationDate":"2019-10-14T18:35:00.000","Title":"how do I locate the btn by class name?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I install anaconda in windows and python version is 3.7.  I want to downgrade 3.7 to 3.6 . I used this command in anaconda prompt conda install python=3.6 . but still when open spyder I can see python 3.7.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2332,"Q_Id":58386336,"Users Score":1,"Answer":"Don't try and downgrade anything in your base Anaconda environment. Create a new environment with Python 3.6 and any other packages you want to work with. \nIf you want to use Spyder with this environment, include the spyder-kernels package and activate the environment before starting Spyder.","Q_Score":0,"Tags":"python,python-3.x,anaconda,spyder","A_Id":58416720,"CreationDate":"2019-10-15T02:19:00.000","Title":"How to change python 3.7 to 3.6 in windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have path server->api(folder), manage.py.\nPycharm underlines my absolute import from api.views import create_user but it works! If i type like from server.api.views import create_user pycharm does not underline, but it doesn't work","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":153,"Q_Id":58387930,"Users Score":2,"Answer":"PyCharm has option called 'Mark Directory as' when you right click your specific directory in the Project tree. \nTry to mark 'Server' folder as 'Sources root' and it should work fine.","Q_Score":1,"Tags":"python,django,pycharm","A_Id":58387964,"CreationDate":"2019-10-15T05:45:00.000","Title":"Pycharm underlines absolute import, but it works fine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Specs:\n\nVisual Studio Code 2019\nlattest pip version\nDjango 2.2+ version\nPython latest 3.7 version","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":13918,"Q_Id":58388355,"Users Score":2,"Answer":"In your open your Visual code and then open Command Palette and shortcut is Ctrl+SHIFT+P\nAnd then type there python select interpreter and it will give you your environment name and click it the moment you click it it will create a vscode folder in your project\nit will resolve","Q_Score":4,"Tags":"python,django,visual-studio-code,django-views","A_Id":63787947,"CreationDate":"2019-10-15T06:21:00.000","Title":"Unable to import 'django.http'pylint(import-error)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using python's findall function with a reg expression that should work but can't get the function to output results with quotation marks in them ('\"). \nThis is what I tried:\nDescription = findall('<p>([A-Za-z ,\\.\\\u2014'\":;0-9]+).<\/p>\\n', text)\nThe quotation marks inside the reg expression are creating the hassle and I have no idea how to get around it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":58388416,"Users Score":0,"Answer":"Placing the backslash before the single quote like Sachith Rukshan suggested makes it work","Q_Score":0,"Tags":"python,html","A_Id":58388614,"CreationDate":"2019-10-15T06:25:00.000","Title":"Trying to find text in an article that may contain quotation marks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to send a random one-time password to the user when I create a new user and make him change the password when the user login for the first time.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1490,"Q_Id":58388869,"Users Score":5,"Answer":"I would suggest different approach to this. \nWhen you create a user, set the active flag to false. so the account is not active and then cannot log in.\nNo need to generate a password, leave it blank.\nInstead, create a url with special token and send the url. If the user goes to this url, it will present a form to set the password for this user.\nThis link is only one time use, and it can even expire after certain number of days.\nYou can look at PasswordResetTokenGenerator in django.contrib.auth.tokens to see how to generate such tokens and change it accordingly.\nYou will also need to craft the url to include somehow which user to use ( probably obscure it somehow as it is not apparent ).","Q_Score":4,"Tags":"python,django,django-rest-framework","A_Id":58390130,"CreationDate":"2019-10-15T06:56:00.000","Title":"How to generate one time password when creating user and send the same to users mail id in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Good morning guys,\ntrying to install the Pygame library on my MacBook Pro...\nI encountered some issues that I'm sure you're able to help me with!\n\nFirst of all I installed the last Python version (3.7.4)\nThan I tried to install via pip the Pygame library, but the process\nwas unsuccessful due to the lack of a Java JKD 13.\nI downloaded and installed the last JDK 13 version (Jdk-13_osx-x64)\nand this process appeared to be successful.\n\nTrying again to finally install the Pygame library an error occurred:\n\nUnable to locate an executable at \"\/Library\/Java\/JavaVirtualMachines\/jdk-13.jdk\/Contents\/Home\/bin\/apt\n\nCan anyone of you guys help me???\nThanks prior!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":861,"Q_Id":58389228,"Users Score":1,"Answer":"Apt used to be a command coming with the Java Development Kit around Java 6. \nJava 6 is also the latest 32-bit version provided by Apple but that doesn\u2019t run on the newest version of Mac OS. \nI think you should look for a newer version of pygame compatible with your system.","Q_Score":1,"Tags":"java,python,pygame","A_Id":58390511,"CreationDate":"2019-10-15T07:20:00.000","Title":"Pygame and Java JDK 13 installation troubles","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i'm getting started with pipenv, however, I want to reproduce a project of someone else who worked with conda. I have the corresponding environment.yml file at hand and want to load the required packages into a virtual environment using pipenv install. Of course I could do this manually one by one, but I wonder if there is a more sophisticated way of transforming the environment.yml file into either a pipfile or a requirement.txt file, from which pipenv install would also be able to load the packages in an automated fashion. \nthanks,\nOlmo","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2748,"Q_Id":58390361,"Users Score":0,"Answer":"environment.yml is a file generate by package manager conda. While, pipenv is based on package manger pip.\nAFAIK, it's impossible. pip and conda  are different tools, and \n\nthey use different format in the generated environment file.\nThe package formats supported by them are different\nThe cloud hosts for the package distribution are different as well.","Q_Score":1,"Tags":"python,conda,pipenv,virtual-environment,pipfile","A_Id":58390487,"CreationDate":"2019-10-15T08:28:00.000","Title":"install packages in virtual environment with pipenv from an environment.yml file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i'm getting started with pipenv, however, I want to reproduce a project of someone else who worked with conda. I have the corresponding environment.yml file at hand and want to load the required packages into a virtual environment using pipenv install. Of course I could do this manually one by one, but I wonder if there is a more sophisticated way of transforming the environment.yml file into either a pipfile or a requirement.txt file, from which pipenv install would also be able to load the packages in an automated fashion. \nthanks,\nOlmo","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2748,"Q_Id":58390361,"Users Score":2,"Answer":"The way i solved this issue, was to rename the \"environment.yml\" which is generated by the conda package manager into \"requirements.txt\" and replace \"=\" by \"==\" in order to comply with the different syntax in pipenv. Also, the \"environment.yml\" file specifies the python version used for the project. This line must be deleted, since the python version is defined by the command pipenv --python x.x\nThen I executed pipenv -r install requirements.txt\nby doing so I avoided copy-pasting all the required packages from the environment.yml file into the shell.","Q_Score":1,"Tags":"python,conda,pipenv,virtual-environment,pipfile","A_Id":58393944,"CreationDate":"2019-10-15T08:28:00.000","Title":"install packages in virtual environment with pipenv from an environment.yml file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In data mining, I use a machine learning algorithm to solve the binary classification.\nHowever, the distribution of data samples is extremely imbalanced.\nThe ratio between good samples and bad samples is as high as 500:1.\nWhich methods can be used to solve the binary classification for imbalanced data?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":58393565,"Users Score":0,"Answer":"You can use Synthetic Minority Oversampling Techniques(SMOTE) or Adasyn to tackle this. Try both methods and finalize based on your desired results.","Q_Score":0,"Tags":"python","A_Id":58399690,"CreationDate":"2019-10-15T11:24:00.000","Title":"binary classification for imbalanced data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In data mining, I use a machine learning algorithm to solve the binary classification.\nHowever, the distribution of data samples is extremely imbalanced.\nThe ratio between good samples and bad samples is as high as 500:1.\nWhich methods can be used to solve the binary classification for imbalanced data?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":58393565,"Users Score":0,"Answer":"Also you can use asymmetric loss functions which penalize models differently based on the label of data. In your case the loss function should penalize errors in \"bad\" samples much more than errors in \"good\" samples. In this way the model pays more attentions to the rare data points.","Q_Score":0,"Tags":"python","A_Id":66716747,"CreationDate":"2019-10-15T11:24:00.000","Title":"binary classification for imbalanced data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I first install packages to a virtual environment with pipenv install package and secondly try to open a subshell to operate in that environment with pipenv shell i receive the following: \n\"Shell for UNKNOWN_VIRTUAL_ENVIRONMENT already activated.\nNo action taken to avoid nested environments.\" \nHowever, which python returns the file path of the system python, which indicated that actually the virtual environment is not activated. \nctr+D and recalling pipenv shell finally opens a subshell within the virtual environment. Can someone explain me what's going on there? Honestly, I am severely conufused.","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2059,"Q_Id":58394338,"Users Score":7,"Answer":"just cd to the folder that has your venv (.venv, Pipfile, Pipfile.lock) and run exit.\nit will exit the folder and now you can again cd to the same folder and use pipenv shell. \nit will work","Q_Score":5,"Tags":"python,pipenv,virtual-environment","A_Id":61404601,"CreationDate":"2019-10-15T12:08:00.000","Title":"Using `pipenv shell` after `pipenv install` yields \"Shell for UNKNOWN_VIRTUAL_ENVIRONMENT already activated.\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I can upload single file to Azure blob storage with Python. But for a folder with multiple folders containing data, is there a way I can try to upload the whole folder with same directory to Azure? \n\nSay I have \nFOLDERA  \n    ------SUBFOLDERa \n    ----------filea.txt \n    ----------fileb.txt \n    ------SUBFOLDERb \n    ------SUBFOLDERc \n\nI want to put this FOLDERA as above structure to Azure. \nAny hints?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4459,"Q_Id":58394403,"Users Score":0,"Answer":"There is nothing built in, but you can easily write that functionality in your code (see os.walk).\nAnother option is to use the subprocess module to call into the azcopy command line tool.","Q_Score":2,"Tags":"python,azure,blobstorage","A_Id":58394491,"CreationDate":"2019-10-15T12:11:00.000","Title":"How to recursively upload folder to Azure blob storage with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on a project in which I want to recognize text from a credit card sized document.The document contains details like name,phone number ,address etc. I'm capturing the image and pass the image into tesseract engine using \ntext = pytesseract.image_to_string(Image.open(filename), lang = 'eng'). Sometimes I'm getting decent results for each field but most of the time result is very bad. How do I resolve this issue ? What are the best practices. How the document readers work with OCR. Is it possible to process region based ocr in the document ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":399,"Q_Id":58394604,"Users Score":0,"Answer":"A single approach can't read every text. You have to apply multiple approach for multiple types of pdf.\nIf the text is not horizontal, you have to rotate the text. If the text is curved, you have to use transformation (e.g. hog transform).\nMoreover, to read text using the package, the texts should be clear and horizontal. Otherwise you need to create rules and transform them.","Q_Score":1,"Tags":"machine-learning,computer-vision,ocr,tesseract,python-tesseract","A_Id":58395285,"CreationDate":"2019-10-15T12:22:00.000","Title":"Best practices for tesseract ocr using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing an application with flask, which has a page with a map drawn on it, it is generated by a JSON, when a change is made on the map by the user it sends the change to the server and this makes a response to the user that made the request.\nWhat i want is that when making the response it is made to all the users that are connected to the page so that the information is refreshed, and not only for the one who made the request.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":58394781,"Users Score":0,"Answer":"What you are searching for is notification in push\nim guessing one of the possible options for you is to make you javascript code \\ or html to send a request every few minutes to check for new json\nit can be simple done with ajax and interval","Q_Score":0,"Tags":"python,flask,response","A_Id":58394895,"CreationDate":"2019-10-15T12:31:00.000","Title":"Send response to all clients with FLASK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on a task that operates on a mounted partition when it has reached a certain percentage used, i.e. when 90% of the parition has been allocated, perform task X.\nIn order to test this, i'd like to be able to stub out a volume with a given size, so I can fill it with garbage up to the point that task X is carried out, so I can make sure it's doing what it's supposed to do. Is this even possible? I'm using python 2.7 on linux.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":58396273,"Users Score":0,"Answer":"Difficult to said with out your code, but you can mock the function used to retrived disk spaces and assign it a value higher than 90 %. Then test your task X.","Q_Score":0,"Tags":"python,testing,mocking","A_Id":58397161,"CreationDate":"2019-10-15T13:48:00.000","Title":"How to mock a mounted partition in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using scipy.cluster.hierarchy.fclusterdata function to cluster a list of vectors (vectors with 384 components).\nIt works nice, but when I try to cluster large amounts of data I run out of memory and the program crashes.\nHow can I perform the same task without running out of memory?\nMy machine has 32GB RAM, Windows 10 x64, python 3.6 (64 bit)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":593,"Q_Id":58396826,"Users Score":0,"Answer":"You'll need to choose a different algorithm.\nHierarchical clustering needs O(n\u00b2) memory and the textbook algorithm O(n\u00b3) time. This cannot scale well to large data.","Q_Score":2,"Tags":"python,python-3.x,scipy,cluster-analysis,data-analysis","A_Id":58406856,"CreationDate":"2019-10-15T14:18:00.000","Title":"How to cluster large amounts of data with minimal memory usage","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"when I type code as int(input()) and input(int()) for same input let say 12,output are 12 and 012 respectively . So why this,what is difference in syntax?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2230,"Q_Id":58397463,"Users Score":0,"Answer":"int() returns the integer 0. input() is using this as the prompt argument (which it prints out to stdout). Hence the extra 0 being printed in the front.","Q_Score":0,"Tags":"python-3.x","A_Id":58397521,"CreationDate":"2019-10-15T14:52:00.000","Title":"Difference between int(input()) and input(int()) in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have spent hours looking into this issue without any success.\nI've looked at various SO discussions and none seem to solve my problem so out of pure frustration here is my question...\nI'm trying to launch a script within a windows batch file. The problem is that when I do the script fails because it can not find some of the modules used.\nAfter various attempts I have found that the batch file aspect, at this stage, seems to be irrelevant.\nSo, ignoring batch files for a minute, If I run the script like this\n\npipenv run python myscript.py\n\nIt works. If I run the following it doesnt\n\npath-to-env\\Scripts\\activate\npython myscript.py\n\nIt returns an error ModuleNotFoundError: No module named 'xxx'\nIt activates the venv OK, but something is not right as it cant find code used in script\nWithin my IDE (Visual Code) everything works OK\nI do have quite a complicated directory structure but given that both the IDE and \"pipenv run python myscript.py\" work as expected it must be due to something else.\nAny ideas or pointers on where I need to be looking? I'm afraid my understanding of pipenv isnt up to solving this ;)\nEDIT\nIn my attempts to solve this I had added the line PYTHONPATH=. to my .env file. This seems to be responsible for allowing this line to work:\n\npipenv run python myscript.py\n\nIf I remove it, then the above ALSO generates the ModuleNotFoundError","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":346,"Q_Id":58398432,"Users Score":1,"Answer":"OK so after trying lots of various combinations I did finally manage to get this to work. \nAlthough I have no idea why this solution works and others didnt..\nIt requires two batch files.\nOne to launch the python script which will contain a line like this\n\npython myscript.py\n\nAnd another to create the env via pipenv and then call the first batch file\nIt will have a line like this\n\npipenv run \\path\\to\\first\\batchfile.bat\n\nThis combination works and can be successfully called from the Windows Task Scheduler","Q_Score":0,"Tags":"python,pipenv","A_Id":58419817,"CreationDate":"2019-10-15T15:46:00.000","Title":"Pipenv and ModuleNotFoundError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I wrote an app with Android Studio and want to send the data that the user enters to my back-end Python script. This should constantly process the received data and send back the evaluation.\nDoes anyone have an idea how this could work?\nthanks in advance","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":279,"Q_Id":58399393,"Users Score":0,"Answer":"From Backend Python: Create 2 web services (GET or POST depending on the requirements). One is to receive the data from Mobile app and other is to send the data to mobile app.\nFrom Android App: You can use Retrofit or volley library for networking and then consume these web services. Use the web service and send the data(Payload) to the backend and also you can use polling to get the data back to the app.","Q_Score":1,"Tags":"python,android,html,https,webserver","A_Id":58400525,"CreationDate":"2019-10-15T16:52:00.000","Title":"Communication between Android app and Python backend","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wrote an app with Android Studio and want to send the data that the user enters to my back-end Python script. This should constantly process the received data and send back the evaluation.\nDoes anyone have an idea how this could work?\nthanks in advance","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":279,"Q_Id":58399393,"Users Score":0,"Answer":"WebSocket should be the interface of choice.\nThe python script should expose a WebSocket end point . The mobile app can establish a connection to the WebSocket. The socket can act as a bidirectional channel where the app can send and receive data and the python script can do the same. \nFirebase : The app could publish the user inputs to a Firebase topic which the python script listens to. The script can process the inputs and publish to the same channel that the app would listen to. More like a P2P chat","Q_Score":1,"Tags":"python,android,html,https,webserver","A_Id":58399946,"CreationDate":"2019-10-15T16:52:00.000","Title":"Communication between Android app and Python backend","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is Flake8 a pure static code analyser or should I run pip install -r requirements.txt first?\nOr, is there any use case where Flake8 can use the installed dependencies?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":320,"Q_Id":58400463,"Users Score":3,"Answer":"flake8 by itself (with the default plugin set) is a purely static linter and does not rely on your installed application dependencies\nthere are some plugins which will require dynamic analysis such as flake8-mypy or flake8-isort\n(disclaimer: I am the current maintainer of flake8)","Q_Score":5,"Tags":"python,code-analysis,requirements.txt,flake8","A_Id":59438862,"CreationDate":"2019-10-15T18:13:00.000","Title":"Does flake8 require any installation of my Python project's dependencies?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My IT installed anaconda for me on windows 10 (I don't have admin rights) and when I try to launch jupyter notebook from the anaconda prompt I get an \"access denied\" error message. \nI can launch jupyter notebook from the anaconda navigator and it runs just fine but I would like to launch jupyter notebook from the prompt so that I can set the default directory.\nCurrently I have not found a way to change the directory once jupyter notebook is up and running and I have to save all my files in the same directory.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2633,"Q_Id":58403676,"Users Score":0,"Answer":"You don't need your admin rights installing Anaconda in program files or some other protected folders.  You can install Anaconda in your home directory without bothering the sysadmin.  Have your IT staff uninstall it first (for cleanliness sake) .  Then install Anaconda using your own login and when you are prompted for the admin password don't give it.  It will still continue.  Then Jupyter notebook will launch from the directory it installs into (c:\\users\\\\appdata\\something... )","Q_Score":0,"Tags":"python,jupyter-notebook,anaconda","A_Id":58404063,"CreationDate":"2019-10-15T23:08:00.000","Title":"Jupyter Notebook Windows 10 Access Denied","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Jupyter notebook and use it with a virtualenv, I already have installed some packages in python but when I run in Jupyter notebook for example import numpy as np, I have a issue, module not found, there are a way to connect all of my python installed packages with Jupyter notebook?\nThanks!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":492,"Q_Id":58405650,"Users Score":0,"Answer":"There are two things to consider:\n\nHave you installed those modules inside the virtual env?\nAre you launching jupyter from inside the virtual env?\n\nIf you perform those actions correctly, then the error should go away.\nHope this help!","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":58405658,"CreationDate":"2019-10-16T04:09:00.000","Title":"Jupyter Notebook and virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to load one of the FastText pre-trained models that has a form of a .bin file. The size of .bin file is 2.8GB and I have 8GB RAM and 8GB swap file. Unfortunately, the model starts loading and it occupies almost 15GB and then it breaks with the following error:\nProcess finished with exit code 137 (interrupted by signal 9: SIGKILL)\nBy observing the system monitor, I can see that RAM and swap are fully occupied, so I think it breaks because it is out of memory.\nI'm trying to load the file using Gensim wrapper for FastText\nfrom gensim.models.wrappers import FastText\n model = FastText.load_fasttext_format('..\/model\/java_ftskip_dim100_ws5')\n\nMy questions are the following:\n1) Is there any way to fit this model in the current memory of my system?\n2) Is it possible to reduce the size of this model? I tried the quantization using the following code\n.\/fasttext quantize -output java_ftskip_dim100_ws5 -input unused_argument.txt\nAnd I'm getting the following error:\nterminate called after throwing an instance of 'std::invalid_argument'\n  what():  For now we only support quantization of supervised models\nAborted (core dumped)\nI would really appreciate your help!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1977,"Q_Id":58407649,"Users Score":2,"Answer":"Some expansion beyond the size-on-disk is expected \u2013 especially once you start performing operations like most_similar(). But, if you're truly getting that error from running a mere 2 lines to load the model, something else may be wrong. \nYou may want to try the non-wrappers gensim FastText implementation \u2013 from gensim.models import FastText \u2013 in the latest gensim, just in case there are extra memory issues with the version you're using. \n(You may also want to check if using the original, compiled Facebook FastText implementation can load the file, and shows similar memory usage.)\nI'm not aware of any straightforward ways to shrink a preexisting FastText model. (If you were training the model from your own data, there are a number of pre-training initialization options that could result in a smaller model. But those limits are not meaningful to apply to an already-trained model.)\nAs you've seen, Facebook has only implemented the 'quantize' trick for the supervised models \u2013 and even if that transformation could be applied to more modes, the supporting gensim code would also then need extra updates to understand the changed models.\nIf you could load it once, in the full (non-wrappers) gensim implementation, it might be practical to truncate all included vectors to be of a lower dimensionality for significant RAM savings, then re-save the model. But given that these are already just-100-dimension vectors, that might cost a lot in expressiveness.","Q_Score":2,"Tags":"python,gensim,fasttext","A_Id":58417036,"CreationDate":"2019-10-16T07:10:00.000","Title":"FastText .bin file cannot fit in memory, even though I have enough RAM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If the sum is 1, I could just divide the values by their sum. However, this approach is not applicable when the sum is 0. \nMaybe I could compute the opposite of each value I sample, so I would always have a pair of numbers, such that their sum is 0. However this approach reduces the \"randomness\" I would like to have in my random array.\nAre there better approaches?\nEdit: the array length can vary (from 3 to few hundreds), but it has to be fixed before sampling.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":437,"Q_Id":58407760,"Users Score":0,"Answer":"Since you are fine with the approach of generating lots of numbers and dividing by the sum, why not generate n\/2 positive numbers divide by sum. Then generate n\/2 negative numbers and divide by sum?\nWant a random positive to negative mix? Randomly generate that mix randomly first then continue.","Q_Score":1,"Tags":"python,random","A_Id":58408874,"CreationDate":"2019-10-16T07:16:00.000","Title":"How to generate random values in range (-1, 1) such that the total sum is 0?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write a dictionary to a json file with one of the values in boolean format. I get the following error when I am trying to run my code.\n\nraise TypeError(f'Object of type {o.class.name} '\n  TypeError: Object of type bool_ is not JSON serializable\n\nI am currently using Python for this purpose.","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":12594,"Q_Id":58408054,"Users Score":-1,"Answer":"Convert the bool value to a string - dict[\"your_key\"] = str(bool value)","Q_Score":23,"Tags":"python,json,python-3.x,numpy","A_Id":62433064,"CreationDate":"2019-10-16T07:32:00.000","Title":"TypeError: Object of type bool_ is not JSON serializable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a machine learning software that detects objects(duh!), processes the objects based on some computer vision parameters and then triggers some hardware that puts the object in the respective bin. The objects are placed on a conveyer belt and a camera is mounted at a point to snap pictures of objects(one object at a time) when they pass beneath the camera. I don't have control over the speed of the belt.\nNow, the challenge is that I have to configure a ton of things to make the machine work properly.\nThe first problem is the time model takes to create segmentation masks, it varies from one object to another.\nAnother issue is how do I maintain signals that are generated after computer vision processing, send them to actuators in a manner that it won't get misaligned with the computer vision-based inferencing.\nMy initial design includes creating processes responsible for a specific task and then make them communicate with one other as per the necessity. However, the problem of synchronization still persists.\nAs of now, I am thinking of treating the software stack as a group of services as we usually do in backend and make them communicate using something like celery and Redis queue.\nI am a kind of noob in system design, come from a background of data science. I have explored python's multithreading module and found it unusable for my purpose(all threads run on single core). I am concerned if I used multiprocessing, there could be additional delays in individual processes due to messaging and thus, that would add another uncertainty to the program.\nAdditional Details:\n\nProgramming Frameworks and Library: Tensorflow, OpenCV and python\nCamera Resolution: 1920P\nMaximum Accutuation Speed: 3 triggers\/second\nDeep Learning Models: MaskRCNN\/UNet\n\nP.S: You can also comment on the technologies or the keywords I should search for because a vanilla search yields nothing good.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":58409257,"Users Score":1,"Answer":"Let me summarize everything first. \n\nWhat you want to do\n\nThe \"object\" is on the conveyer belt\nThe camera will take pictures of the object\nMaskRCNN will run to do the analyzing\n\nHere are some problems you're facing\n\n\"The first problem is the time model takes to create segmentation masks, it varies from one object to another.\"   \n\n-> if you want to reduce the processing time for each image, then an accelerator (FPGA, Chip, etc) or some acceleration technique is needed. Intel OpenVino and Intel DL stick is a good start. \n-> if there are too many pictures to process then you'll have 2 choices: 1) put a lot of machines so all the job can be done or 2) select only the important job and discard others. The fact that you set the \"Maximum Accutuation\" to a fixed number (3\/sec) made me think that this is the problem you're facing. A background subtractor is a good start for creating images capture triggers. \n\n\"Another issue is how do I maintain signals that are generated after computer vision processing, send them to actuators in a manner that it won't get misaligned with the computer vision-based inferencing.\"\n\n-> a \"job distributor\" like Celery is good choice here. If the message is stacked inside the broker (Redis), then some tasks will have to wait. But this can easily by scaling up your computer.\n\nJust a few advice here:\n\na vision system also includes the hardware parts, so a hardware specification is a must. \nClarify the requirements \nImpossible things do exist, so sometimes you could reduce some factors (reliable, cost) of your project.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,robotics","A_Id":58479863,"CreationDate":"2019-10-16T08:45:00.000","Title":"How to design realtime deeplearnig application for robotics using python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed new ubuntu 18.4 and while solving some other error while installing requirements through pip. I tried installing python-setuptools and python-dev instead of installing python3-setuptools and python3-dev which in turn installed python2.7 on my machine. Well the solution didn't work and I removed the packages as I don't want 2.7 on my machine and now when I run the following command:\nsudo virtualenv venv \nI get this message: The path python2 (from --python=python2) does not exist.\nbefore installing python-dev and python-setup tools the above command worked fine.\nI have tried replacing python symbolic link to python3.6 in \/usr\/bin.\nby executing: ln -s \/usr\/bin\/python3.6 \/usr\/bin\/python although I am able to get python3.6 console every time run python like on fresh install of ubuntu but I can't creat virtual environment the same way.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":251,"Q_Id":58410540,"Users Score":1,"Answer":"Try yo run it with this specific python\n\/usr\/bin\/python3.6 -m pip install virtualenv\nsudo \/usr\/bin\/python3.6 -m virtualenv venv\nand delete the python2.7 is probably a bad idea cause there is probably thing that using it on your machine, and also, consider reading about system envirmate varibles, as PATH for example that would solve you problem","Q_Score":1,"Tags":"python,python-3.x,virtualenv,ubuntu-18.04","A_Id":58410612,"CreationDate":"2019-10-16T09:54:00.000","Title":"virtualenv is not picking python3 automatically from \/usr\/bin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to execute TMSL scripts to process SSAS tabular models (On-Prem) using Python.\nI have my SSAS HTTP endpoint ready.\nAny leads?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":749,"Q_Id":58412494,"Users Score":0,"Answer":"I was able to execute TMSL scripts on SSAS Tabular Model using IronsPython2 and python XMLA package. You can even execute MDX with the above mentioned utility and packages.","Q_Score":1,"Tags":"python,ssas-tabular,azure-analysis-services","A_Id":58527926,"CreationDate":"2019-10-16T11:43:00.000","Title":"Process SSAS Tabular Models using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I re-create a model, keras always makes a new name for a layer (conv2d_2 and so on) even if I override the model. How to make keras using the same name every time I run it without restarting the kernel.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":305,"Q_Id":58413230,"Users Score":1,"Answer":"When using Tensorflow (1.X) as a backend, whenever you add a new layer to any model, the name of the layer -unless manually set- will be set to the default name for that layer, plus an incremental index at the end.\nDefining a new model is not enough to reset the incrementing index, because all models end up on the same underlying graph. To reset the index, you must reset the underlying graph.\nIn TF 1.X, this is done via tf.reset_default_graph(). In TF 2.0, you can do this via the v1 compatibility API: tf.compat.v1.reset_default_graph() (the latter will also solve some deprecation warnings you might get with the latest versions of TF 1.X)","Q_Score":2,"Tags":"python,tensorflow,keras,neural-network,jupyter-notebook","A_Id":58428014,"CreationDate":"2019-10-16T12:21:00.000","Title":"How to prevent keras from renaming layers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Redis for caching in my Django project which is hosted on Heroku.\nDuring Redis connection, on random times I got the below error message\n\nError 110 while writing to socket. Connection timed out.\n\nI'm using the below packages with versions\n\npython-3.6.8\nDjango-2.2.2\nredis-3.2.1\ncelery-4.3.0\n\nAlso, I'm access Redis using worker ( celery sometimes).\nCan someone please suggest me to get rid of this problem or any other countermeasure to handle this problem. \nThanks in advance...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2110,"Q_Id":58413743,"Users Score":0,"Answer":"There are several possible causes for this--the most usual occurs where you have lots of cache evictions caused by the maxmemory setting on redis being too low.  Check to see your redis size using the redis-cli stats command and see if you need more memory to redis.","Q_Score":5,"Tags":"python,django,heroku,redis,celery","A_Id":58415535,"CreationDate":"2019-10-16T12:50:00.000","Title":"Django Redis connection error in heroku: Error 110 while writing to socket. Connection timed out","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am very New to Python web development ,so got confuse while learning ,when we create new Project with the command --django-admin startProject 'ProjectName' \nIt Created a project folder in my drive  and then we  create application in it  suppose with the name of \"calculator\", we start working in it ,\nbut after some more  requirement we have to  create a new different Project with the Name of the Hrms so the question arise for this again we have to run the same command django-admin startProject 'ProjectName' and then we have to create application in it or we  can create in it?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":360,"Q_Id":58413897,"Users Score":6,"Answer":"One project may have many application in it & you can create app using below code.\ndjango-admin startapp my_new_app.\nAlso you can reuse same app in multiple projects.\nFor Hrm you should create new app instead of new project.\nExample : One ERP projects may have many apps like hrm, sales, purchase, inventory etc.. & we can reuse same apps into another ERP projects also if needed.\nHope above clarifications works for you.","Q_Score":3,"Tags":"python,django","A_Id":58414092,"CreationDate":"2019-10-16T12:57:00.000","Title":"Python Manage.Py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am very New to Python web development ,so got confuse while learning ,when we create new Project with the command --django-admin startProject 'ProjectName' \nIt Created a project folder in my drive  and then we  create application in it  suppose with the name of \"calculator\", we start working in it ,\nbut after some more  requirement we have to  create a new different Project with the Name of the Hrms so the question arise for this again we have to run the same command django-admin startProject 'ProjectName' and then we have to create application in it or we  can create in it?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":360,"Q_Id":58413897,"Users Score":0,"Answer":"Start project and start app are very different commands. With the first one you create a project which will have a base structure to work on. The second command is used to create apps which you could classify as controllers. Each app will live in a folder where you will program the business logic and bind endpoints.","Q_Score":3,"Tags":"python,django","A_Id":58414079,"CreationDate":"2019-10-16T12:57:00.000","Title":"Python Manage.Py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am very New to Python web development ,so got confuse while learning ,when we create new Project with the command --django-admin startProject 'ProjectName' \nIt Created a project folder in my drive  and then we  create application in it  suppose with the name of \"calculator\", we start working in it ,\nbut after some more  requirement we have to  create a new different Project with the Name of the Hrms so the question arise for this again we have to run the same command django-admin startProject 'ProjectName' and then we have to create application in it or we  can create in it?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":360,"Q_Id":58413897,"Users Score":0,"Answer":"The app would be a new module in your project, let's say it would be a management system with human resources, financial modules, etc., so you would create an app for each of them to better organize, but nothing prevents creating everything in one app.Create a project only if it is something different.","Q_Score":3,"Tags":"python,django","A_Id":58414204,"CreationDate":"2019-10-16T12:57:00.000","Title":"Python Manage.Py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"As the title says, that's basically it. I have tried to install matplotlib already but:\n\nI am on Windows and \"sudo\" doesn't work\nEvery solution and answers on Stack Overflow regarding matplotlib (or some other package) not being able to be installed doesn't work for me...\nI get \"Error Code 1\"\n\nSo! Is there any other way to plot a graph in python without matplotlib? If not, can I have help with how to install matplotlib, successfully?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":4146,"Q_Id":58414797,"Users Score":-1,"Answer":"in cmd (coammand prompt) type pip install matplotlib","Q_Score":2,"Tags":"python,matplotlib,graph","A_Id":68501575,"CreationDate":"2019-10-16T13:41:00.000","Title":"Is there another way to plot a graph in python without matplotlib?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to set up a new dev environment on Windows 10. Let me set the stage with some key points:\nI am using Ubuntu through Windows Subsystem for Linux (WSL).\nI have Anaconda3 installed on WSL.\nI have PyCharm installed on Windows 10.\nI am attempting to use a Conda environment created in the WSL within PyCharm on Windows 10. For some reason I cannot find documentation or guidance on the process.\nI have already successfully setup a virtualenv within WSL as a remote interpreter for PyCharm however it will not allow me to do the same with a Conda environment.","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4661,"Q_Id":58416208,"Users Score":3,"Answer":"After some trial and error along with contacting JetBrains support, it was determined currently not possible.\nMy solution to get around this was to have Anaconda installed on both Windows and WSL and then create the Conda environment within Windows. I was then able to activate this environment within WSL with the absolute path to the environment.\nNot the best approach but allows for editing in WSL and usage of the interpreter in PyCharm.","Q_Score":8,"Tags":"python,pycharm,anaconda,windows-subsystem-for-linux","A_Id":59250319,"CreationDate":"2019-10-16T14:53:00.000","Title":"WSL Conda Environment in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to set up a new dev environment on Windows 10. Let me set the stage with some key points:\nI am using Ubuntu through Windows Subsystem for Linux (WSL).\nI have Anaconda3 installed on WSL.\nI have PyCharm installed on Windows 10.\nI am attempting to use a Conda environment created in the WSL within PyCharm on Windows 10. For some reason I cannot find documentation or guidance on the process.\nI have already successfully setup a virtualenv within WSL as a remote interpreter for PyCharm however it will not allow me to do the same with a Conda environment.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":4661,"Q_Id":58416208,"Users Score":1,"Answer":"In your project in Pycharm.\n\nChoose File, Setting, Project, Python Interpreter, Add\nChoose WSL on the left. Linux = your Ubuntu\nPython interpreter path = home\/<your_name>\/miniconda3\/envs\/<your_env>\/bin\/python3 -- this is the environment you have created in Ubuntu with Conda.","Q_Score":8,"Tags":"python,pycharm,anaconda,windows-subsystem-for-linux","A_Id":70721122,"CreationDate":"2019-10-16T14:53:00.000","Title":"WSL Conda Environment in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a problem that I have been treating as a classification problem. I am trying to predict whether a machine will pass or fail a particular test based on a number of input features. \nWhat I am really interested in is actually whether a new machine is predicted to pass or fail the test. It can pass or fail the test by having certain signatures (such as speed, vibration etc) go out of range.\nTherefore, I could either:\n1) Treat it as a pure regression problem; try to predict the actual values of speed, vibration etc\n2) Treat it as a pure classification problem; for each observation, feed in whether it passed or failed on the labels, and try to predict this in the tool I am making\n3) Treat it as a pseudo problem; where I predict the actual value, and come up with some measure of how confident I am that it is a pass or fail based on distance from the threshold of pass\/fail\nTo be clear; I am working on a real problem. I am not interested in getting a super precise prediction of a certain value, just whether a machine is predicted to pass or fail (and bonus extension; how likely that it is to be true).\nI have been working with classification model as I only have a couple hundred observations and some previous research showed that this might be the best way to treat the problem. However I am wondering now whether this is the right thing to do.\nWhat would you do!?\nMany thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":58416636,"Users Score":0,"Answer":"Without having the data and running classification or regression, a comparison would be hard because of the metric you use for each family is different. \nFor example, comparing RMSE of a regression with F1 score (or accuracy) of a classification problem would be apple to orange comparison.\nIt would be ideal if you can train a good regression model (low RMSE) because that would give you information more than the original pass\/fail question. From my past experiences with industrial customers, \nFirst, train all 3 models you have mentioned and then present the outcome to your customer and let them give you more direction on which models\/outputs are more meaningful for them.","Q_Score":1,"Tags":"python,machine-learning,regression,classification","A_Id":58421378,"CreationDate":"2019-10-16T15:15:00.000","Title":"Regression vs Classification for a problem that could be solved by both","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"_mysql_exceptions.OperationalError: (2026, 'SSL connection error: SSL_CTX_set_tmp_dh failed')\nis thrown at me when I try to run my script which connects to my SQL server. \nI installed MySQLdb via conda. I've read that this may be an openssl issue, but I'm having trouble downgrading that as well.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":58416787,"Users Score":0,"Answer":"I was able to fix this my using mysql.connector instead of importing MySQLdb in my python scripts","Q_Score":1,"Tags":"python,openssl,conda,mysql-python","A_Id":58613928,"CreationDate":"2019-10-16T15:24:00.000","Title":"Python MySQLdb cannot connect to server, SSL Issue","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I must setup a network computer (running Windows Server 2012 R2 Standard) as a production server for django applications, real quick. This is what I've already done:\n\nInstalled Python 3.7.4 (64 bits version)\nInstalled nginx 1.17.4\nInstalled virtualenv\nCreated a virtual environment for hosting my application\nHave my django project ready and running ok with \"manage.py runserver\"\n\nWhere do I go from here? I'm sorry, but I couldn't find instructions simple and atraightforward enough for me so far.\nI could use IIS or Apache as well, but only if it's simpler than nginx.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":431,"Q_Id":58417019,"Users Score":0,"Answer":"Actually there is a way to publish a django app without any other framework like apache ngix and others. \n\nopen windows server 2012's server management app \ncreate a TCP port(the port depends on which you want to use. I am using 1234)\nafter these run manage.py with this code (python manage.py runserver server's ip adress:port you opened) and press enter \nthat's it. this way will run your django app on your ip and port adress but you cannot access django app with a domain\nif you find an other way please share me","Q_Score":0,"Tags":"python,django,nginx,webserver,windows-server-2012-r2","A_Id":60693735,"CreationDate":"2019-10-16T15:37:00.000","Title":"setup server for django application in Windows Server 2012 R2 Standard","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to clean a csv file for data analysis. How do I convert TRUE FALSE into 1 and 0?\nWhen I search Google, they suggested df.somecolumn=df.somecolumn.astype(int). However this csv file has 100 columns and not every column is true false(some are categorical, some are numerical). How do I do a sweeping code that allows us to convert any column with TRUE FALSE to 1 and 0 without typing 50 lines of df.somecolumn=df.somecolumn.astype(int)","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":87,"Q_Id":58417900,"Users Score":4,"Answer":"you can use:\ndf.select_dtypes(include='bool')=df.select_dtypes(include='bool').astype(int)","Q_Score":0,"Tags":"python-3.x,pandas,data-cleaning","A_Id":58418351,"CreationDate":"2019-10-16T16:30:00.000","Title":"Data Cleaning with Pandas in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to add directories to sys.path so Python looks there for modules. When I add a directory using append or insert command and then print out directories in sys.path, the directory I've just added is wrong. For example if I add \"C:\\Users\\user\\test\", in sys.path it's \"C:\\Users\\user   est\"\nIt's not just the problem with the name displayed incorrectly, because modules don't load, so the right directory must have not been added.\nI've tried commands: sys.path.append(\"xxx\") and sys.path.insert(0, \"xxx\"). I've tried single and double quotation marks, and forward and backward slashes.\nI'm using Anaconda Prompt (Anaconda 2) and Windows 10.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":163,"Q_Id":58419238,"Users Score":0,"Answer":"Looks like you're not properly escaping backslashes. Without seeing your code, it's hard to diagnose it more accurately, but try creating the directory with the string user\\\\test instead. Otherwise, python might interpret \\t as an escape sequence, and replace it with a tab.","Q_Score":1,"Tags":"python,directory","A_Id":58419271,"CreationDate":"2019-10-16T18:04:00.000","Title":"Python sys.path appends wrong directories","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"What is the differences between using if object is None versus if not object?\nSo while I was doing some coding where I messed up the signals in the QListWidget, where in a selection instance, it is returning me 2 signals, where it returns 2 objects - QListWidgetItem and None.\nTo address to the None return, I used if object is None, but I was told that if not object would be better. Even so, it seems that using either of the 2 if would still allow me to achieve the same result.\nIs there a better case scenario as to when to use either?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":58422436,"Users Score":2,"Answer":"not object is true when object has any falsey value, such as 0 or False.\nIf you know a priori that the variable contains either a QListWidgetItem or None, then None is the only falsey possibility, so if not object: is a simpler way to write the condition.\nYou just have to be careful about this in other context. Consider a variable that can contain a number or None. I've seen many errors due to not considering the possibility that the number might be 0.","Q_Score":0,"Tags":"python","A_Id":58422483,"CreationDate":"2019-10-16T22:25:00.000","Title":"Testing for None in if statements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I create a 2D array of zeros that will be stored as integers and not floats in python? np.zeros((10,10)) creates floats.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":934,"Q_Id":58422957,"Users Score":0,"Answer":"A line like this should also work: [[0 for i in range(10)] for i in range(10)]","Q_Score":0,"Tags":"python,numpy,integer,2d,numpy-ndarray","A_Id":58423130,"CreationDate":"2019-10-16T23:34:00.000","Title":"How can I create a 2d array of integers?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When the bottom left of VScode shows the venv python after selecting the venv python as the interpreter:\n- Should I still activate the venv in VScode terminal to PIP install?\nOr, since the venv python shows up in the bottom left:\n- Can I just go straight to PIP installing a package?\nJust getting used to VS code, maybe just not understanding the layout. \nThank You","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1248,"Q_Id":58423335,"Users Score":1,"Answer":"One neat way to check this is to type in pip --version from within the VSCode terminal. This will return where your active pip directory is, and you should find that it will point back to the virtual environment path.\nSo to answer your question about whether you need to activate the venv in VScode terminal to use pip: you shouldn't need to. When you pop open a new terminal (for me, it's Powershell), it will automatically activate the venv. You can also see this by looking at the start of the command line, where the name of your venv will be in parantheses.","Q_Score":2,"Tags":"python,visual-studio-code,python-venv","A_Id":58423384,"CreationDate":"2019-10-17T00:34:00.000","Title":"Should I activate venv in VS code terminal then PIP install, or as long as bottom left shows venv I am good to go?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When the bottom left of VScode shows the venv python after selecting the venv python as the interpreter:\n- Should I still activate the venv in VScode terminal to PIP install?\nOr, since the venv python shows up in the bottom left:\n- Can I just go straight to PIP installing a package?\nJust getting used to VS code, maybe just not understanding the layout. \nThank You","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1248,"Q_Id":58423335,"Users Score":0,"Answer":"Don't forget to close out an existing terminal and reopen a new one if you started the venv after a terminal was already open in VSCode.","Q_Score":2,"Tags":"python,visual-studio-code,python-venv","A_Id":58424196,"CreationDate":"2019-10-17T00:34:00.000","Title":"Should I activate venv in VS code terminal then PIP install, or as long as bottom left shows venv I am good to go?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Appium version V1.15.0 and have already start the server successfully with the default Host: 0.0.0.0 and Port: 4723\nBut now when i try to start the server it shows me this error \"Error Starting Appium server: listen EADDRINUSE 0.0.0.0:4723\"\nI have tried to solve this issue by changing the port but could not find any solution.\nSuggest me if you guys have any better solution.","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":3805,"Q_Id":58424717,"Users Score":3,"Answer":"I have found the solution. After restarting my computer, i could successfully run the Appium server.\nIf anyone face the same problem. Please follow below steps:\n1. Check if the port is listening to any other services.\n      Open command prompt: Type netstat -a -b\n\nEither kill that service or try with different port.\nIf both not working then restart your machine.\n\nThis way i have solved this problem.","Q_Score":3,"Tags":"python-appium,appium-desktop","A_Id":58444163,"CreationDate":"2019-10-17T04:00:00.000","Title":"Could not start Appium server. It's showing [Error Starting appium server: listen EADDRINUSE 0.0.0.0:4723]","Data Science and Machine Learning":0,"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 using Appium version V1.15.0 and have already start the server successfully with the default Host: 0.0.0.0 and Port: 4723\nBut now when i try to start the server it shows me this error \"Error Starting Appium server: listen EADDRINUSE 0.0.0.0:4723\"\nI have tried to solve this issue by changing the port but could not find any solution.\nSuggest me if you guys have any better solution.","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":3805,"Q_Id":58424717,"Users Score":3,"Answer":"If EADDRINUSE, Address already in use is the issue, \ndo\nps aux | grep node\nto get the process ids.\nThen:\nkill -9 PID\nDoing the -9 on kill sends a SIGKILL.","Q_Score":3,"Tags":"python-appium,appium-desktop","A_Id":60395724,"CreationDate":"2019-10-17T04:00:00.000","Title":"Could not start Appium server. It's showing [Error Starting appium server: listen EADDRINUSE 0.0.0.0:4723]","Data Science and Machine Learning":0,"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 using Appium version V1.15.0 and have already start the server successfully with the default Host: 0.0.0.0 and Port: 4723\nBut now when i try to start the server it shows me this error \"Error Starting Appium server: listen EADDRINUSE 0.0.0.0:4723\"\nI have tried to solve this issue by changing the port but could not find any solution.\nSuggest me if you guys have any better solution.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3805,"Q_Id":58424717,"Users Score":0,"Answer":"The following solution on windows worked for me\nC:\\Users\\username> taskkill \/F \/IM node.exe\nSUCCESS: The process \u201cnode.exe\u201d with PID 13992 has been terminated.","Q_Score":3,"Tags":"python-appium,appium-desktop","A_Id":71693131,"CreationDate":"2019-10-17T04:00:00.000","Title":"Could not start Appium server. It's showing [Error Starting appium server: listen EADDRINUSE 0.0.0.0:4723]","Data Science and Machine Learning":0,"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 know I can download opencv-python using pip on my computer but I'm running an Anaconda server using Anaconda Navigator to run a python script. Do I need to install opencv-python via the Navigator or is it enough to download it on your machine via pip? \nIf not, how can I download opencv-python via the Anaconda navigator?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":451,"Q_Id":58424903,"Users Score":1,"Answer":"The easiest way:\nOn the left panel of Navigator, there is a line called \"Environments\". Change to \"Not installed\" and search \"opencv\". Then press Apply on the bottom right of the window.","Q_Score":0,"Tags":"python,opencv,pip,anaconda","A_Id":58425024,"CreationDate":"2019-10-17T04:25:00.000","Title":"How to download opencv-python library in Anaconda Navigator?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was using the following code cmd \/c $hash > $in 2>&1 to run a specific executable file using powershell. Here are the issues i face \n\nThis commands works in PC but not servers.\nThis commands can run perfectly in manually way in server, but when schedule, it hit into error as following \n\nUnicodeEncodeError: 'charmap' codec cant encode characters in position 33-35: character maps to undefined\nKindly help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":94,"Q_Id":58425334,"Users Score":7,"Answer":"As I know that I have faced same kind of issue when developing script in python & after lot of search I have found that I am facing charmap issue because of encoding issue.\nWhat I need to do is set utf-8 as default encoding & after setting it in my python script I am able to solve above issue.\nTry to set proper encoding while reading file or opening file & hope you will find solution for your problem.","Q_Score":2,"Tags":"python,powershell,server","A_Id":58425422,"CreationDate":"2019-10-17T05:16:00.000","Title":"Powershell Error when run the script automatically","Data 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 simple task I want to perform over ssh: return all files from a given file list that do not exist.\nThe way I would go about doing this would be to wrap the following in an ssh session:\nfor f in $(files); do stat $f > \/dev\/null ;done\nThe stdout redirect will ignore all good files and then reading the stderr will give me a list of all non found files.\nI first thought of using this bash code with the ssh part inside a subprocess.run(..., shell=True) but was discouraged to do so. Instead,paramikowas suggested. \nI try to understand why and when native python is better than subprocessing bash\n\nComputability with different OS (not an issue for me as the code is pretty tightly tied to Ubuntu)\nError and exception handling - this one I do get and think it's important, though catching an exception or exit code from subprocess is kinda easy too\n\nThe con in my eyes with native python is the need to involve somewhat complicated modules such as paramiko when bash's ssh and stat seem to me as more plain and easy to use\nAre there any guidelines for when and how to choose bash over python?\nThis question is mainly about using a command over ssh, but is relevant for any other command that bash is doing in a short and easy way and python wraps","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":58426347,"Users Score":1,"Answer":"There are really three choices here: doing something in-process (like paramiko), running ssh directly (with subprocess), and running ssh with the shell (also with subprocess).  As a general rule, avoid running the shell programmatically (as opposed to, say, upon interactive user request).\nThe reason is that it\u2019s a human-oriented interface (thus the easy separation of words with spaces and shortcuts for $HOME and globbing) that is vastly underpowered as an API.  Consider, for example, how your code would detect that ssh was missing: the situation doesn\u2019t arise with paramiko (so long as it is installed), is obvious with subprocess, and is just an (ambiguous) exit code and stderr message from the shell.  Also consider how you supply the command to run: it already must be a command suitable for the shell (due to limitations in the SSH protocol), but if you invoke ssh with the shell it must be encoded (sometimes called \u201cdoubly escaped\u201d) so as to have the local shell\u2019s interpretation be the desired multi-word command for the remote shell.\nSo far, paramiko and subprocess are pretty much equivalent.  As a more difficult case, consider how a key verification failure would manifest: paramiko would describe the failure as data, whereas the others would attempt to interact with the user (which might or might not be present).  paramiko also supports opening multiple channels over one authenticated connection; ssh does so as well but only via a complicated ControlMaster configuration involving Unix socket files (which might not have any good place to exist in some deployments).  Speaking of configuration, you may need to pass -F to avoid complications from the user\u2019s .ssh\/config if it is not designed with this automated use case in mind.\nIn summary, libraries are designed for use cases like yours, and so it should be no surprise that they work better, especially for edge cases, than assembling your own interface from human-oriented commands (although it is very useful that such manual compositions are possible!).  If installing a non-standard dependency like paramiko is a burden, at least use subprocess directly; cutting out the second shell is already a great improvement.","Q_Score":1,"Tags":"python,python-3.x,bash,subprocess","A_Id":58442463,"CreationDate":"2019-10-17T06:41:00.000","Title":"File related operations python subprocess vs. native 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":"Right now when I started coding on Odoo v13 I found that Odoo has been removed @api.one.\nWhat is the alternative of the @api.one in Odoo v13 ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1951,"Q_Id":58426373,"Users Score":7,"Answer":"In odoo13 by default instance method will accept self as multi instance (multi-recordset).\nSo for instance method, you should remove the @api.one and @api.multi decorator from your methods.\nFor a single instance(single recordset), you still can check with self.ensure_one() or you can apply your own logic.","Q_Score":2,"Tags":"python,python-3.x,odoo","A_Id":58426561,"CreationDate":"2019-10-17T06:42:00.000","Title":"What is the alternative of @api.one in Odoo 13?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to configure my vim editor in Ubuntu 18.04 to automatically run a python file inside the editor.   The problem seems to be that, on my Dell Inspiron, the function keypresses are being captured by the GUI.  For example, pressing F9 brings up a display of all my open windows. \nI've also tried setting a-F9 as well, but with no luck.  The command itself works manually, but vim won't run it when I press the key that's mapped to the command. \nHere's an example of the lines in the .vimrc that I've tried...\nautocmd filetype python nnoremap <buffer> <F9> :exec '!clear; python' shellescape(@%, 1)<cr>\nand...\nautocmd filetype python nnoremap <buffer> <a-F9> :exec '!clear; python' shellescape(@%, 1)<cr>\nI've also tried this:\nimap <F5> <Esc>:w<CR>:!clear;python %<CR>\nNone of them seem to work.  Pressing the key doesn't run the command. \nAny help appreciated. \nThanks","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":201,"Q_Id":58427032,"Users Score":2,"Answer":"You can insert the literal key inside a buffer (here: your .vimrc) by pressing <C-V> followed by the key (e.g. <F9>). If that function key correctly arrives in Vim, the literal <F9> string (4 characters) should be inserted. If that's not the case, you first need to remove the interference by the surrounding system. It may be some bloatware (less likely on Linux though) that captures the function keys (uninstall it then), but I've also seen notebooks being configured with special functions (also volume \/ brightness up \/ down) on the function keys, and the actual function key is only sent via a combination with a special Fn key; that usually can be toggled in the BIOS. You can test other applications (e.g. the browser should react to <F5> with reload and <F11> with full-screen) to see if this indeed is a global problem. As you're on Linux, you can also use the xev tools for this.\nYour key mappings in itself are fine. I would recommend putting any settings, mappings, and filetype-specific autocmds into ~\/.vim\/ftplugin\/{filetype}_whatever.vim (or {filetype}\/whatever.vim (for Python mappings, I'd choose python_mappings.vim); cp. :help ftplugin-name) instead of defining lots of :autocmd FileType {filetype}; it's cleaner and scales better; requires that you have :filetype plugin on, though. Settings that override stuff in default filetype plugins should go into ~\/.vim\/after\/ftplugin\/{filetype}.vim instead.\nFunction keys itself should also work in terminals, in combinations with modifier keys like Shift and Alt often not. Therefore, another approach (for maximum portability, e.g. when you're working through SSH) would be to skip the function keys altogether and go for <Leader> mappings.","Q_Score":0,"Tags":"python,vim","A_Id":58427935,"CreationDate":"2019-10-17T07:22:00.000","Title":"Trying to set up an autocmd in .vimrc to map a key to a command, but having problems","Data 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 two separate AWS Virtual Machines set up within a region (different availability zones) both are connected via WebSocket (in Python) to a different load balancer (Cloudfront) of the same host server (also hosted with AWS) and receive frequent small WebSocket payloads - every 5ms.\nNB: I do not own the host server I am merely on the receiving end.\nBoth machines are receiving the same updates and I would like to measure on which machine the updates\/payloads\/packets are arriving first\nIn essence I would like to figure out which load balancer is \"closer\" to the host and so has the least latency overhead in transmitting the signal since my application is highly latency sensitive.\nI have tried using the system clock to get timestamps of the data arrival however it is not guaranteed that the two instances have their time synced to an appropriate accuracy.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":38,"Q_Id":58431786,"Users Score":1,"Answer":"follow this.\n\n\nSend a request to the load balancer with the body of the request containing the timestamp when it was sent to the server. You can\n  easily do this using the DateTime api of your fav language.\nAfter that packet arrives to your backend server residing on your instance (can be a simple node server or a rails server), you can get\n  that request, and compare it to the current timestamp. \nYou can do this on both the servers and can easily compare which was faster.","Q_Score":0,"Tags":"python,amazon-web-services,networking,time,websocket","A_Id":58431962,"CreationDate":"2019-10-17T11:40:00.000","Title":"Determining which packet\/update arrived first between two machines","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have around 300 (x, y) values (integers) of points on a map (unknown projection). I also have 6 points (x, y, latitude, longitude) which I want to use to infer the latitude and longitude for the other points. \nI have already tried just inferring how many units on the map correspond to what kind of latitude or longitude distance but I have realised that this falls short of a solution because there is no fixed mapping because this depends on the projection.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":58431889,"Users Score":0,"Answer":"Do all you can to find the projection. With that and your 6 reference points or less you can easily calibrate the map.\nOtherwise, you can only obtain a rough approximation. In that case:\nYou can triangulate your map using the 6 known points and interpolate lat\/lon inside each triangle.\nYou can also use thin-plate splines (2-d splines) to obtain an approximate x,y <-> lat\/lon transformation.\nIf the map has lat\/lon lines (or UTM lines) you can project round lat\/lon values on the map's grid to validate your results, and adjust them if necessary.\nYou can also improve your collection of calibration points (x, y, lat, lon) by identifying points in Google Earth, Bing maps... (I used to physically visit points and get their GPS coordinates before the Google Earth era...)","Q_Score":0,"Tags":"python,geolocation,map-projections","A_Id":58432736,"CreationDate":"2019-10-17T11:46:00.000","Title":"How to infer coordinates from few fixed points of unknown projection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want VS Code to turn venv on run, but I can't find how to do that.\nI already tried to add to settings.json this line:\n\n\"terminal.integrated.shellArgs.windows\": [\"source${workspaceFolder}\\env\\Scripts\\activate\"]\n\nBut, it throws me an 127 error code. I found what 127 code means. It means, Not found. But how it can be not found, if I see my venv folder in my eyes right now?\nI think it's terminal fault. I'm using Win 10 with Git Bash terminal, that comes when you install Git to your machine.","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":39164,"Q_Id":58433333,"Users Score":31,"Answer":"This is how I did it in 2021:\n\nEnter Ctrl+Shift+P in your vs code.\n\nLocate your Virtual Environment:\nPython: select interpreter > Enter interpreter path > Find\n\nOnce you locate your virtual env select your python version:\nyour-virtual-env > bin > python3.\n\nNow in your project you will see .vscode directory created open settings.json inside of it and add:\n\"python.terminal.activateEnvironment\": true\ndon't forget to add comma before to separate it with already present key value pair.\n\nNow restart the terminal.\n\n\nYou should see your virtual environment activated automatically.","Q_Score":21,"Tags":"python,visual-studio-code,virtualenv,vscode-settings","A_Id":65650691,"CreationDate":"2019-10-17T13:02:00.000","Title":"Auto activate virtual environment in Visual Studio Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want VS Code to turn venv on run, but I can't find how to do that.\nI already tried to add to settings.json this line:\n\n\"terminal.integrated.shellArgs.windows\": [\"source${workspaceFolder}\\env\\Scripts\\activate\"]\n\nBut, it throws me an 127 error code. I found what 127 code means. It means, Not found. But how it can be not found, if I see my venv folder in my eyes right now?\nI think it's terminal fault. I'm using Win 10 with Git Bash terminal, that comes when you install Git to your machine.","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":39164,"Q_Id":58433333,"Users Score":8,"Answer":"There is a new flag that one can use: \"python.terminal.activateEnvironment\": true","Q_Score":21,"Tags":"python,visual-studio-code,virtualenv,vscode-settings","A_Id":65504572,"CreationDate":"2019-10-17T13:02:00.000","Title":"Auto activate virtual environment in Visual Studio Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using this code to merge two dataframe :\npd.concat(df1, df2, on='a', how='outer')\nI am getting the following error:-\n\nTypeError: concat() got an unexpected keyword argument 'on'","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":64,"Q_Id":58433397,"Users Score":1,"Answer":"You should try the merge method. \npd.merge(df1, df2, how='outer', on='a')","Q_Score":2,"Tags":"python,pandas","A_Id":58433457,"CreationDate":"2019-10-17T13:05:00.000","Title":"Not able to outer join two dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing test code in Appium of an Andriod Project in python . The problem is that I am not able to access two button in two different Activity having same Id . I have tried to access the second button in this way.But none of them works. How to resolve the issue?\ndriver.find_element_by_id(\"com.myapp.testApp:id\/login[1]\").click(), driver.find_element_by_class_name(\"android.widget.Button\").click()\ndriver.find_element_by_xpath(\"(\/\/button[@id='login'])[1]\").click()\ndriver.find_element_by_xpath(\"\/\/android.widget.Button[@text='Change Password']\").click()","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2487,"Q_Id":58433478,"Users Score":0,"Answer":"If buttons texts are different, try by accessibility_id\ndriver.find_element_by_accessibility_id(\"Login\").click()\ndriver.find_element_by_accessibility_id(\"Change Password\").click()\nOR\nIf you are familiar with uiautomator,\ndriver.find_element_by_android_uiautomator('new UiSelector().resourceId(\"com.myapp.testApp:id\/login[1]\")')\ndriver.find_element_by_android_uiautomator('new UiSelector().resourceId(\"com.myapp.testApp:id\/login[2]\")')","Q_Score":0,"Tags":"appium,appium-android,appium-ios,python-appium,appium-desktop","A_Id":60395628,"CreationDate":"2019-10-17T13:09:00.000","Title":"How to find multiple element in appium having same id in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am writing test code in Appium of an Andriod Project in python . The problem is that I am not able to access two button in two different Activity having same Id . I have tried to access the second button in this way.But none of them works. How to resolve the issue?\ndriver.find_element_by_id(\"com.myapp.testApp:id\/login[1]\").click(), driver.find_element_by_class_name(\"android.widget.Button\").click()\ndriver.find_element_by_xpath(\"(\/\/button[@id='login'])[1]\").click()\ndriver.find_element_by_xpath(\"\/\/android.widget.Button[@text='Change Password']\").click()","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2487,"Q_Id":58433478,"Users Score":0,"Answer":"You can do link this, It will give you proper Output:\nInput is:\n\nd1 = driver.find_elements_by_id(\"com.application.zomato:id\/price\")\nitemtotalprice = d1[0].get_attribute(\"text\")\n\nHere, is my output:\n\nMandarin Oak\n\u20b9200\n\u20b9166.75","Q_Score":0,"Tags":"appium,appium-android,appium-ios,python-appium,appium-desktop","A_Id":69285758,"CreationDate":"2019-10-17T13:09:00.000","Title":"How to find multiple element in appium having same id in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to Python programming but have over 5 years of coding experience. \nI have to split large PDFs into smaller ones less than 20Mb. I have currently written code with the following logic.\n\nFind the file size. Divide the file size by 20 and round the number, lets call this number partitions. Ex: File Size 45 then I divide 45 by 20 and round the value from 2.25 to 3. \nFind the number of pages. Let's say there are around 500 pages. \nDivide the number of pages by the partitions (3). So there will be 3 sets, from Pages 1 to 171, 172 to 343 and 344 to 515.\nI split the PDF into number of partitions as mentioned above.\n\nThe challenge I am facing is that all the pages are not of the same size so some PDFs become really small and some might exceed the 20Mb limit.  \nCan someone suggest any solution to this? Even a better approach is welcome.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":788,"Q_Id":58433942,"Users Score":1,"Answer":"I don't know which library you are working with, but maybe it could work like this:\nOpen a PDF file. Then create a new one and add pages until you have reached the 20mb or stop a little bit earlier. The only problem here is that you don't know the size of the page before you have added it and saved the file to check the file size again.\nBut I am not confident with python and PDF's so maybe someone else have a better approach for you.","Q_Score":1,"Tags":"python,pdf,pypdf2","A_Id":58434214,"CreationDate":"2019-10-17T13:32:00.000","Title":"Splitting PDF to make multiple PDFs less than 20Mb","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've read some articles and most of them say that 3-ply improves the performance of the self-player train. \nBut what is this in practice? and how is that implemented?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":58434745,"Users Score":0,"Answer":"There is stochasticity in the game because of the dice rolls, so one approach would be evaluate state positions by self play RL, and then while playing do a 2-ply search over all the possible dice combinations. That would be 36 + 6 i.e. 42 possible rolls, and then you have to make different moves that are available which increases the breath of the tree to an insane degree. I tried this and it failed because my Mac could not handle such computation. Instead what we could do is just randomize a few dice rolls and perform a MiniMax tree search with Alpha Beta pruning ( using the AfterState value function).\nFor a 1 ply search we just use the rolled dice, or if we want to predict the value before we roll the dice then we can simply loop over all the possible combinations. Then we just argmax over the afterstates.","Q_Score":1,"Tags":"python,tensorflow,reinforcement-learning","A_Id":66576813,"CreationDate":"2019-10-17T14:15:00.000","Title":"Implement 1-ply, 2-ply or 3-ply search td-gammon","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to evaluate ((x == a and y == b) or (x == b and y == a)) in Python, but it seems a bit verbose. Is there a more elegant way?","AnswerCount":10,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":11849,"Q_Id":58435645,"Users Score":11,"Answer":"You already got the most readable solution. There are other ways to express this, perhaps with less characters, but they are less straight-forward to read. \nDepending on what the values actually represent your best bet is to wrap the check in a function with a speaking name. Alternatively or in addition, you can model the objects x,y and a,b each in dedicated higher class objects that you then can compare with the logic of the comparison in a class equality check method or a dedicated custom function.","Q_Score":113,"Tags":"python,boolean-logic","A_Id":58472836,"CreationDate":"2019-10-17T15:05:00.000","Title":"Is there a more elegant way to express ((x == a and y == b) or (x == b and y == a))?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to evaluate ((x == a and y == b) or (x == b and y == a)) in Python, but it seems a bit verbose. Is there a more elegant way?","AnswerCount":10,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":11849,"Q_Id":58435645,"Users Score":26,"Answer":"If these are numbers, you can use (x+y)==(a+b) and (x*y)==(a*b).\nIf these are comparable items, you can use min(x,y)==min(a,b) and max(x,y)==max(a,b).\nBut ((x == a and y == b) or (x == b and y == a)) is clear, safe, and more general.","Q_Score":113,"Tags":"python,boolean-logic","A_Id":58449863,"CreationDate":"2019-10-17T15:05:00.000","Title":"Is there a more elegant way to express ((x == a and y == b) or (x == b and y == a))?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently overhauling a project here at work and need some advice. We currently have a morning checklist that runs daily and executes roughly 30 SQL files with 1 select statement each. This is being done in an excel macro which is very unreliable. These statements will be executed against an oracle database.\nBasically, if you were re-implementing this project, how would you do it? I have been researching concurrency in python, but have not had any luck. We will need to capture the results and display them, so please keep that in mind.If more information is needed, please feel free to ask.\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":45,"Q_Id":58437542,"Users Score":2,"Answer":"There are lots of ways depending on how long the queries run, how much data is output, are there input parameters and what is done to the data output.\nConsider:\n1. Don't worry about concurrency up front\n2. Write a small python app to read in every *.sql file in a directory and execute each one.\n3. Modify the python app to summarize the data output in the format that it is needed\n4. Modify the python app to save the summary back into the database into a daily check table with the date \/ time the SQL queries were run.  Delete all rows from the daily check table before inserting new rows\n5. Have the Excel spreadsheet load it's data from that daily check table including the date \/ time the data was put in the table \n6. If run time is slows, optimize the PL\/SQL for the longer running queries\n7. If it's still slow, split the SQL files into 2 directories and run 2 copies of the python app, one against each directory.\n8. Schedule the python app to run at 6 AM in the Windows task manager.","Q_Score":0,"Tags":"python,sql,multithreading","A_Id":58438628,"CreationDate":"2019-10-17T17:03:00.000","Title":"Most efficient way to execute 20+ SQL Files?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have run same code in syder which produce a result. i ran the same code in raspberry pi and the result is different. I have tried everything possible but it wont work.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":58438116,"Users Score":0,"Answer":"Thank you for your answer sir. \nHow to fix the Floating Point computation in Raspberry pi to obtain the same result as in laptops?","Q_Score":0,"Tags":"python-3.x,opencv,raspberry-pi3,scikit-image","A_Id":58445618,"CreationDate":"2019-10-17T17:43:00.000","Title":"How can same code running with same libraries produce different results when executed in raspberry pi and anaconda3 in windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I use the weights of a pre-trained network in my tensorflow project?\nI know some theory information about this but no information about coding in tensorflow.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":144,"Q_Id":58440762,"Users Score":0,"Answer":"As been pointed out by @Matias Valdenegro in the comments, your first question does not make sense. For your second question however, there are multiple ways to do so. The term that you're searching for is Transfer Learning (TL). TL means transferring the \"knowledge\" (basically it's just the weights) from a pre-trained model into your model. Now there are several types of TL.\n1) You transfer the entire weights from a pre-trained model into your model and use that as a starting point to train your network. \n\nThis is done in a situation where you now have extra data to train your model but you don't want to start over the training again. Therefore you just load the weights from your previous model and resume the training.\n\n2) You transfer only some of the weights from a pre-trained model into your new model.\n\nThis is done in a situation where you have a model trained to classify between, say, 5 classes of objects. Now, you want to add\/remove a class. You don't have to re-train the whole network from the start if the new class that you're adding has somewhat similar features with (an) existing class(es). Therefore, you build another model with the same exact architecture as your previous model except the fully-connected layers where now you have different output size. In this case, you'll want to load the weights of the convolutional layers from the previous model and freeze them while only re-train the fully-connected layers.\n\nTo perform these in Tensorflow, \n1) The first type of TL can be performed by creating a model with the same exact architecture as the previous model and simply loading the model using tf.train.Saver().restore() module and continue the training.\n2) The second type of TL can be performed by creating a model with the same exact architecture for the parts where you want to retain the weights and then specify the name of the weights in which you want to load from the previous pre-trained weights. You can use the parameter \"trainable=False\" to prevent Tensorflow from updating them.\nI hope this helps.","Q_Score":0,"Tags":"python-3.x,tensorflow,deep-learning,object-detection","A_Id":58448415,"CreationDate":"2019-10-17T21:09:00.000","Title":"How to use a pre-trained object detection in tensorflow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to grab a bunch numbers that are presented in a table on a web page that I\u2019ve accessed using python and Selenium running headless on a Raspberry Pi. The numbers are not in the page source, rather they are deeply embedded in complex html served by several URLs called by the main page (the numbers update every few seconds). I know I could parse the html to get the numbers I want, but the numbers are already sitting on the front page in perfect format all in one place. I can select and copy the numbers when I view the web page in Chrome on my PC. \nHow can I use python and get Selenium webdriver to get me those numbers? Can Selenium simply provide all the visible text on a page? How? (I've tried driver.page_source but the text returned does not contain the numbers). Or is there a way to essentially copy text and numbers from a table visible on the screen using python and Selenium? (I\u2019ve looked into xdotool but didn\u2019t find enough documentation to help). I\u2019m just learning Selenium so any suggestions will be much appreciated!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2512,"Q_Id":58443994,"Users Score":2,"Answer":"Well, I figured out the answer to my question. It's embarrassingly easy. This line gets just what I need - all the text that is visible on the web page: \npage_text = driver.find_element_by_tag_name('body').text","Q_Score":0,"Tags":"python,selenium,selenium-webdriver","A_Id":58453255,"CreationDate":"2019-10-18T04:33:00.000","Title":"How to get visible text from a webpage using Selenium & python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been processing this thought in my head for a long time now. So in NMT, We pass in the text in the source language in the encoder seq2seq stage and the language in the target language in the decoder seq2seq stage and the system learns the conditional probabilities for each word occurring with its target language word. Ex: P(word x|previous n-words). We train this by teacher forcing.\nBut what if I pass in the input sentence again as input to the decoder stage instead of the target sentence. What would it learn in this case? I'm guessing this will learn to predict the most probable next word in the sentence given the previous text right? What are your thoughts\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":31,"Q_Id":58445247,"Users Score":1,"Answer":"In that case, you would be learning a model that copies the input symbol to the output. It is trivial for the attention mechanism to learn the identity correspondence between the encoder and decoder states. Moreover, RNNs can easily implement a counter. It thus won't provide any realistic estimate of the probability, it will assign most of the probability mass to the corresponding word in the source sentence.","Q_Score":0,"Tags":"python-3.x,deep-learning,lstm,recurrent-neural-network,seq2seq","A_Id":58485627,"CreationDate":"2019-10-18T06:40:00.000","Title":"A Variation on Neural Machine Translation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project related to object detection using Mask RCNN on google colab. I have a video uploaded to my colab. I want to display it as a video while processing it at the runtime using openCV. I want to do what cv2.VideoCapture('FILE_NAME') does on the local machine. Is there any way to do it?","AnswerCount":5,"Available Count":1,"Score":-0.0798297691,"is_accepted":false,"ViewCount":14645,"Q_Id":58447228,"Users Score":-2,"Answer":"Here is the command on google colab :\n  ret, frame = input_video.read()\nWish yhis help you","Q_Score":4,"Tags":"python,opencv,computer-vision,jupyter,google-colaboratory","A_Id":58627454,"CreationDate":"2019-10-18T08:49:00.000","Title":"How to play video on google colab with opencv?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are trying to insert a batch of records(100k) in green plum. In case a particular record has some issue, is there a way to trace back to the specific record which is causing the issue? \nCurrently, it's failing the whole batch and we are trying to filter the error records.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":161,"Q_Id":58447773,"Users Score":0,"Answer":"If you are using the COPY command to load or gpfdist and external tables to do the insert, you can set a segment reject limit and an error log that will allow the command to insert all good rows with any rejected rows placed in the error log.   The default is to roll back everything on one error.  You can check the Greenplum documentation or, in psql, use \\h COPY or \\h CREATE EXTERNAL TABLE.   A simple example with COPY is:\nCOPY your_table from '\/your_path\/your_file' with delimiter as '|' \nLOG ERRORS\nSEGMENT REJECT LIMIT 1000 rows;\nThat means it will log up to 1000 bad rows before rolling everything back.  Set as needed for your data.   You can see what bad rows are in the log with:\nselect gp_read_error_log('your_table');\nOne of the columns in the log shows the bad row with exactly where and what the error is.\nJim McCann\nPivotal","Q_Score":1,"Tags":"python,postgresql,psycopg2,greenplum","A_Id":58478186,"CreationDate":"2019-10-18T09:20:00.000","Title":"Track error records when doing a multi row update in Greenplum(Postgres 8.4)?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to retrieve CPU info, total database connections and memory info with django-prometheus?\nAfter installing django-prometheus to my Django project prometheus\/metrics I cannot understand is there any metrics to achieve my goals.\nOr it there another ways to do it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":170,"Q_Id":58450410,"Users Score":0,"Answer":"try to open you exporter web page it should be on jango server. you should know the port. then you will see a list of metrics available for you, then you can go to prometheus and check configuration. Only then you can configure PromQL to build nice grafs","Q_Score":0,"Tags":"python,django,prometheus,metrics","A_Id":58517868,"CreationDate":"2019-10-18T11:56:00.000","Title":"How to retrieve metrics such as CPU loading, database connections, memory with django-prometheus","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to read whole file (not line by line) in Apache Beam?\nFor example, I want to read multiline JSONs, and my idea is to read file by file, extract data from each file and create PCollection from lists.\nIs it good idea or it's better to preprocess source JSONs to one JSON file where each line is separate JSON?\nThank you for advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":738,"Q_Id":58450882,"Users Score":0,"Answer":"The TextIO reads the files line-by line. So in your test.json each line needs to contain a separate Json object.\nThe idea of beam or any distributed processing engine is to be able to parallelize the input data. From your question it looks like some pre-processing would be needed to split these into multiple jsons. Note that it need not be in a single file and you can have multiple files each containing any number of json files. Beam will read the rows in parallel.\nDo accept the answer if that helped.","Q_Score":1,"Tags":"python,apache-beam","A_Id":58473117,"CreationDate":"2019-10-18T12:23:00.000","Title":"Read whole file in Apache Beam","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently created a new Anaconda (Windows) environment in order to move from tensorflow 1.2 to tensorflow 2.0. My base environment is 1.2, and I created tensorflow-20 in order to install the new version. I did the install from the anaconda command line within the (tensorflow-20) environment. But now everything is messed up.\nNow, in Anaconda Navigator, it still shows Tensorflow 1.2.1 as the installed version for base. But in the (base) environment from the Anaconda command line, it shows the version as 2.0.0. Furthermore, in Anaconda Navigator, tensorflow-20 shows no installed packages, including python even.\nI feel like I'm fundamentally misunderstanding something here. Can anyone provide some guidance?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":275,"Q_Id":58450968,"Users Score":1,"Answer":"How did you install tensorflow 2.0 in the new conda env?\n\nIF with pip, run 'where pip' see if you are using the pip installed\nin the base env. You can run 'conda create -n tensorflow-20 pip' to get a pip installed in the new env. Then activate tensorflow-20 and install tensorflow 2.0 with pip.\nIF with conda, run 'where conda' to check the same thing.","Q_Score":0,"Tags":"python,tensorflow,anaconda","A_Id":58451300,"CreationDate":"2019-10-18T12:28:00.000","Title":"Why does Anaconda Navigator (Windows) show a different version of Tensorflow than the command line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Why the max_depth of every decision tree in my random forest classifier model are the same?\nI set the max_depth=30 of my RandomForestClassifier, and when I print each trees(trees = RandomForestClassifier.estimators_), I find every tree's max_depth are the same.\nI really don't know where is the problem and how it happnend.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":334,"Q_Id":58451535,"Users Score":1,"Answer":"If i am not mistaken, a decision tree is likely to reach its max depth. There is nothing wrong with it. I would even say that he surely will. The space you allow your tree to grow in, the space your tree will occupy. \nScaled to a random forest, again there is nothing wrong with it. You should focus on choosing the right max_depth, because with a grater max_depth comes a greater risk of over fitting.\nTry different values and compare how you are doing with your test data.","Q_Score":0,"Tags":"python,classification,random-forest,decision-tree","A_Id":58451829,"CreationDate":"2019-10-18T13:05:00.000","Title":"Why the max_depth of every decision tree in my random forest classifier model are the same?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have  a Microservice written in python flask and I will be hosting it soon.\nI want to send one file (example.txt) to My Microservice as a part of Bamboo Task. \nThe  microservice will use this file and extract some useful information.\nThe bamboo is connected with Bitbucket.\nQuestions:\n\nHow do I achieve this in Bamboo?\nAre there any changes required at my Micreservice.\n\nI newbie in all these technologies. Any help is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":58455612,"Users Score":0,"Answer":"There are few steps to acheive this.\n\nSetting up the microservice to accept file.\nMake sure your micro-service is able to accept the file. If yes, perfect. Then we only need to work on the below steps.\nExtracting the file from the build plan. \nCreate the build plan and add the build task, this task should produce your artifact file \"example.txt\", You need to choose the build task which is suitable for your mircoservice client project(Node, maven). The artifact cannot be persisted if you don't mark it as a shared artifact. Describe the shared artifact in task settings. The artifact is shown when the build completes that would confirm that the build is working properly and producing the required artifact.\nSending the file from a deployment plan.\nOnce the artifact is available. You need to create the deployment plan, which can be a script in python or bash to do a REST call for transferring the file. Make sure the location of the file is correct in the script.","Q_Score":0,"Tags":"python,bitbucket,microservices,bamboo,data-exchange","A_Id":58692339,"CreationDate":"2019-10-18T17:29:00.000","Title":"How to send a file from Bamboo task to a our python Microservice","Data Science and Machine Learning":0,"Database and SQL":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 starting to learn how to build neural networks. Here is what I did:\nI ran a number of epochs with units in my dense layer at 512.\nThen I saved the weights with the best accuracy. \nThen I increased the number of units in my dense layer to 1024 and attempted to reload my weights with the best accuracy but with the old weights of 512. \nI got an error. I understand why I got the error but I am wondering if there is a way to increase the number of units and still be able to use my saved weights or do I need to retrain my model from the beginning again?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":58456169,"Users Score":1,"Answer":"In theory you could add more units and initialize them randomly, but that would make the original training worthless. A more common method for increasing the complexity of a model while leveraging earlier training is to add more layers and resume training.","Q_Score":0,"Tags":"python,keras","A_Id":58456411,"CreationDate":"2019-10-18T18:11:00.000","Title":"Is there a way to increase the number of units in a dense layer and still be able to load previously saved weights that used a lower number of units?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working against a filesystem filled with .parquet files. One of the columns, 'id', uniquely identifies a machine. I was able to use pyspark to open all .parquet files in a certain directory path, then create a set([]) of the values from the 'id' column. I'd like to open all other rows in all other files, where the 'id' matches one of the values in the previously calculated set.\nI was able to do this via pyspark, but it's quite complex and requires me to instantiate a local spark server. I'm trying to find a way to do this via pyarrow, but it seems that it's read_pandas \/ read methods 'filters' argument can only filter on partition data, and not arbitrary column data.\nIs there a way to achieve what I'm looking for here? I can't open the entire dataset and then use Python to filter out rows where the 'id' doesn't match, because it doesn't fit in memory.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1045,"Q_Id":58457788,"Users Score":1,"Answer":"As of 0.15.0, pyarrow doesn't have this feature, but we (in the Apache Arrow project) are actively working on this and hope to include it in the next major release.","Q_Score":1,"Tags":"python,pyspark,pyarrow","A_Id":58468462,"CreationDate":"2019-10-18T20:30:00.000","Title":"Read only specific rows of .parquet files matching criteria?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to write some messages in discord with my bot, but I don't know how to do it. It seems that discord.py can't send messages autonomously.\nDoes anyone know how to do it?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":58458098,"Users Score":0,"Answer":"I solved putting a while loop inside the function on_message.\nSo I need to send only a message and then my bot can write as many messages as he wants","Q_Score":0,"Tags":"python,python-3.x,discord.py","A_Id":58462241,"CreationDate":"2019-10-18T20:56:00.000","Title":"How to write in discord with discord.py without receiving a 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 am trying to create a site which auto generates python code and is presented to the user in an ide style where they can edit it then run it live using brython.\nI am having trouble setting up the ide part I found brython console but that won't work for editing things. So my question is are there any existing implementations I can use?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":58458896,"Users Score":0,"Answer":"I think you want an extensible web IDE. An IDE that runs in the browser that expects you to build on top of, so that you can likely get the text out of it to provide to Brython. I'd try searching for terms like these:\nextensible web IDE\nweb IDE framework\nIDE framework in JavaScript\net c.","Q_Score":0,"Tags":"python,html,brython","A_Id":58459465,"CreationDate":"2019-10-18T22:29:00.000","Title":"How to use brython to create an interactive python script writer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Code:\n<input type=\"file\" accept=\"image\/png, image\/jpeg\" style=\"display: none;\">\nWhat I am trying to do:\nupload = driver.find_elements_by_xpath(\"\/\/input[@type = 'file']\")\nupload.send_keys('\/Users\/username\/Desktop\/images\/filename.jpg')\nPS : This code is not in any iframe and element can be found (I checked its attribute to be sure)\nNothing happens, I have written the same logic to upload files in other test cases and it worked.\nThanks for your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":58458960,"Users Score":0,"Answer":"I was able to figure out the issue. Below the input field accepts \"jpeg and png\" and I was trying to upload \"jpg\". Once I changed the input to \"jpeg or png\" it worked.\nCode:\n<input type=\"file\" accept=\"image\/png, image\/jpeg\" style=\"display: none;\">\nWhat I was doing :\nupload.send_keys('\/Users\/username\/Desktop\/images\/filename.jpg')\nSolution : Change the file extension to jpeg or png.\nupload.send_keys('\/Users\/username\/Desktop\/images\/filename.jpeg')","Q_Score":0,"Tags":"python,selenium,file-upload","A_Id":58509726,"CreationDate":"2019-10-18T22:40:00.000","Title":"Python -> Selenium : Not able to upload the file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to reshape my input for my LSTM Network.\nI have a training data of train_x (20214000 columns x 9 rows) and train_y (20214000 columns x 1 row).\nHow do I reshape my train_x such that I can feed it into my RNN? \nI have 9 features so it would be something like: \ntrain_x.reshape(?,?,9) and \ntrain_y.reshape(?,?,1)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":58459327,"Users Score":0,"Answer":"Arrays input into the LSTM have shape: (N_SAMPLES, SEQUENCE_LENGTH, N_FEATURES).","Q_Score":1,"Tags":"python,keras,recurrent-neural-network","A_Id":58459640,"CreationDate":"2019-10-18T23:44:00.000","Title":"Choosing time_step for LSTM","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've created a virtualenv for my django project. And i want to use vscode. But 'workon env_name' is not working in vscode terminal, but its working fine on my command prompt.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":213,"Q_Id":58460537,"Users Score":0,"Answer":"do you add \"python.pythonPath\": \"<your env path>\/bin\/python3.6\" in settings.json of your vscode?","Q_Score":0,"Tags":"python,django,virtualenv","A_Id":58462621,"CreationDate":"2019-10-19T04:32:00.000","Title":"How to access my python virtual env in vscode terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to have django running on the server and one application from django inter communicating with another python process say that I developed and fetching a response from it or even make it just do a particular action?\nIt can be synchronous or asynchronous; I have some idea of being asynchronous where some package like hendrix, crossbar.io or even celery can be used. But I don't understand what would be the name for this inter-communication and how should I plan the architecture for this.\nGoing around my head I have the two following situations I'm seeking a plan to be developed:\n1.\nSay I have django and an e-mail sender with the python package smtp. A user making a request to a view would make django execute my python module I developed for sending an email to a particular user (with a smpt server from google\/gmail). It could be synchronous or asynchronous.\nOR\n2\nI have django (some application) and I want it to communicate with some server I maintain; say for making this server execute some code or just fetch a file (if it is an ftp server). Is this an appropriate situation to point to the term 'microservices'? Or there is another term or workaround here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":737,"Q_Id":58462197,"Users Score":1,"Answer":"Your first solution would be called an installable python module, just like any package you install with pip. You can have this as a separate module if you need your code to be re-usable across multiple or just future projects.\nYour second solution would be a microservice. This will require setting your small module as a service that could have a REST API to communicate with and make it do whatever you intend it to do.\nIf your question is \"what is the right approach\" then I would tell you it depends on your use case. If this is just some re-usable code that you don't want to repeat over and over through our project then just make it into a separate module. While if this is a service that you expect other built services will use and rely on, then just make it into a microservice. You can use a microframework such as Flask for easier and faster setup of your service. Otherwise, if it's just some code that you will use once and serves a single functionality on your application then just write it and keep it there.\nThere are no rules or standards on which approach should be taken. I personally judge things depending on the use-case.\nHope this helps!","Q_Score":0,"Tags":"django,python-3.x,asynchronous,server,microservices","A_Id":58462332,"CreationDate":"2019-10-19T09:20:00.000","Title":"Django communicating with another python application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Django 3 should be released soon and it will be able to work in ASGI mode. ASGI mode seems to make Django more efficient when handling requests than in WSGI mode (more requests can be handled per time unit if I believe correctly). How is it accomplished? Is it like that Django can handle at the same time multiple requests, but most of them will be waiting on events like fetching data from a database or other IO operations?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1942,"Q_Id":58462443,"Users Score":0,"Answer":"The situation you said is because you did not use asynchronous in the whole process of your request, because in the case of using asynchronous mode, you must ensure that each link is using asynchronous, so that your request will not block in At a certain stage, it can be guaranteed that at the same time, Django asynchronous mode can handle more requests","Q_Score":3,"Tags":"python,django,asgi","A_Id":59169437,"CreationDate":"2019-10-19T09:53:00.000","Title":"What's the difference between handling requests in Django 3 ASGI mode vs WSGI mode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have access to a bloomberg terminal and python on the same computer. I tried to look on internet and on this forum for some useful tips\/introduction to automate bloomberg tasks, although I didn't find anything. How can the terminal be automated? Is it possible to do something similar to webscraping with an external application? Or the only way is to use Sendkeys method? (In my case I want to automate ISIN typing, print screen (for which I found a code in this forum using API calls) and data analysis (so scrape the data showed). I'm aware of bloomberg add-in for excel but it's quite limited.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1676,"Q_Id":58463334,"Users Score":1,"Answer":"What you want is to use the API.\nBloomberg makes it easy to do this in Excel. You need to install Bloomberg API plugin.\nIf you need to do this \u2018programmatically\u2019, there are API written in different languages. Use WAPI in your terminal to find out.","Q_Score":0,"Tags":"python,api,automation,screen-scraping,bloomberg","A_Id":58469155,"CreationDate":"2019-10-19T11:45:00.000","Title":"Is it possible to automate Bloomberg Terminal's tasks?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have access to a bloomberg terminal and python on the same computer. I tried to look on internet and on this forum for some useful tips\/introduction to automate bloomberg tasks, although I didn't find anything. How can the terminal be automated? Is it possible to do something similar to webscraping with an external application? Or the only way is to use Sendkeys method? (In my case I want to automate ISIN typing, print screen (for which I found a code in this forum using API calls) and data analysis (so scrape the data showed). I'm aware of bloomberg add-in for excel but it's quite limited.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1676,"Q_Id":58463334,"Users Score":1,"Answer":"Automating the terminal can be done using the TerminalConnect Api.\nIt's not possible to 'scrape' data from the terminal, but you can access data using the Desktop Api (DAPI).","Q_Score":0,"Tags":"python,api,automation,screen-scraping,bloomberg","A_Id":58468296,"CreationDate":"2019-10-19T11:45:00.000","Title":"Is it possible to automate Bloomberg Terminal's tasks?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing a Keras NN that predicts the label using 20,000 features. I can build the network, but have to use system RAM since the model is too large to fit in my GPU, which has meant it's taken days to run the model on my machine. The input is currently 500,20000,1 to an output of 500,1,1\n-I'm using 5,000 nodes in the first fully connected (Dense) layer. Is this sufficient for the number of features?\n-Is there a way of reducing the dimensionality so as to run it on my GPU?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":415,"Q_Id":58463482,"Users Score":0,"Answer":"I suppose each input entry has size (20000, 1) and you have 500 entries which make up your database?\nIn that case you can start by reducing the batch_size, but I also suppose that you mean that even the network weights don't fit in you GPU memory. In that case the only thing (that I know of) that you can do is dimensionality reduction.\nYou have 20000 features, but it is highly unlikely that all of them are important for the output value. With PCA (Principal Component Analysis) you can check the importance of all you parameters and you will probably see that only a few of them combined will be 90% or more important for the end result. In this case you can disregard the unimportant features and create a network that predicts the output based on let's say only 1000 (or even less) features.\nAn important note: The only reason I can think of where you would need that many features, is if you are dealing with an image, a spectrum (you can see a spectrum as a 1D image), ... In this case I recommend looking into convolutional neural networks. They are not fully-connected, which removes a lot of trainable parameters while probably performing even better.","Q_Score":1,"Tags":"python,machine-learning,keras,keras-layer,tf.keras","A_Id":58463773,"CreationDate":"2019-10-19T12:03:00.000","Title":"Keras - Using large numbers of features","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While trying to install psycopg2-binary with pip3, I get the following error message:\n\nSetup script exited with error: command 'C:\\Program Files (x86)\\Microsoft Visual\n  Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.23.28105\\bin\\HostX86\\x86\\link.exe' failed with exit status 1120\n\nI have 83  error LNK2001.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":652,"Q_Id":58464206,"Users Score":1,"Answer":"On windows, I could not install psycopg2. When browsing around, people were saying to isntall directly the binary which I was trying to do. However for some reasons, the 64 bits binary was not working but the 32 bits version has worked fine and solved my issues.","Q_Score":0,"Tags":"python","A_Id":58971163,"CreationDate":"2019-10-19T13:31:00.000","Title":"How to install psycopg2 on windows 10?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As we know we can wrap arbitrary number of stateful building blocks into a class which inherits from nn.Module. But how is it supposed to be done when you want to wrap a bunch of stateless functions (from nn.Functional), in order to fully utilize things which nn.Module allows you to, like automatic moving of tensors between CPU and GPU with just model.to(device)?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":65,"Q_Id":58465570,"Users Score":1,"Answer":"I already found the solution: if you have an operation inside of a module which creates a new tensor, then you have to use self.register_buffer in order to fully utilize automating moving between devices.","Q_Score":0,"Tags":"python,pytorch","A_Id":58484891,"CreationDate":"2019-10-19T16:13:00.000","Title":"PyTorch - a functional equivalent of nn.Module","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to train a machine learning model on multiple csv files that are all unique. Each file is a collection of time series data from basketball games. I want to train a model to look at each game and be able to predict outcomes. Should I simply tell sci kit learn or another package to iterate through the files in the folder of interest and run regressions on each? Thank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":393,"Q_Id":58466396,"Users Score":0,"Answer":"If all of the files contain the same features, you can concatenate them. If some features are preprocessed differently (for example, they have different ranges in different files), you should make them consistent before concatenating. Then use the obtained big data frame\/array for model training.\nAlso, consider shuffling the rows.","Q_Score":1,"Tags":"python,pandas,machine-learning,scikit-learn,pytorch","A_Id":68735569,"CreationDate":"2019-10-19T17:46:00.000","Title":"Training a machine learning model on multiple CSV files?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a free trial of Chegg and would like to save the solutions to a few chapters for my math textbook. \nWhat I would like to do is open the link for each solution, and save that webpage as a PDF using Python 3. I was able to figure out the code to save the site as a PDF using some libraries including Requests. However, I'm having a hard time figuring out how to log in.\nI watched (too) many videos and read tutorials, but I can't figure out what my payload should include when sending a request to Chegg. I've easily been able to log in to some other sites, but Chegg doesn't have typical stuff that others do, such as \"username\" and \"password\" fields in the code (when you look at the Network tab in Chrome Developer Tools). Does anyone know what I'm missing? How can I can send a request to log in to Chegg specifically, without using any \"complex\" things like Selenium (I'm a beginner)?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":805,"Q_Id":58467933,"Users Score":1,"Answer":"Why don't you copy authenticated cookies from your browser?\n\u2013 t.m.adamOct 20 '19 at 10:09\n\n\nEither copy the cookies as a string and pass it in the headers\nparameter, .get(url, headers={'Cookie':cookies}) or create a\ndictionary and pass it in the cookies parameter, .get(url, cookies=cookies). Web sites keep track of users with cookies, so if\nyour request has authenticeded cookies it should have the same\nprivileges as your user account. Of course, you could try to reproduce\nthe login process with requests, but I think the method I proposed is\neasier.\n\u2013 t.m.adam Oct 21 '19 at 0:27\n\nThought I would post this so that people that find this question won't miss the answer in the comments!","Q_Score":1,"Tags":"python,authentication,python-requests","A_Id":67375284,"CreationDate":"2019-10-19T20:57:00.000","Title":"How to log into Chegg with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a high number of videos and I want to extract the frames, pre-process them and then create an array for each video . So far I have created the arrays but the final size of each array is too big for all of the videos. I have 224 videos, each resulting in a 6GB array totaling more than 1.2TB. I have tried using numpy.save and pickle.dump but both create the same size on the system. Do you have a recommendation or an alternative way in general?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":114,"Q_Id":58468914,"Users Score":1,"Answer":"Do these steps for each of the videos:\n\nLoad the data into one NumPy array.\nWrite to disk using np.save() with the extension .npy.\nAdd the .npy file to a .zip compressed archive using the zipfile module.\n\nThe end result will be as if you loaded all 224 arrays and saved them at once using np.savez_compressed, but it will only use enough RAM to process a single video at a time, instead of having to store all the uncompressed data in memory at once.\nFinally, np.load() (or zipfile) can be used to load the data from disk, one video at a time, or even using concurrent.futures.ThreadPoolExecutor to load multiple files at once using multiple cores for decompression to save time (you can get speedup almost linear with the number of cores, if your disk is fast).","Q_Score":0,"Tags":"python,numpy,image-processing","A_Id":58471416,"CreationDate":"2019-10-19T23:41:00.000","Title":"Saving a high number of images as an array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am starting to learn python and I don't know much about programming right now. In the future, I want to build android applications. Python looks interesting to me.\nCan I use python for building Android applications?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":120,"Q_Id":58469032,"Users Score":1,"Answer":"You can build android apps in python, but it's not as powerful as android studio, and the apps made by python take more space and are less memory efficient.But the apps work well...\nThere are several ways to use Python on Android:\nBeeWare. BeeWare is a collection of tools for building native user interfaces. ...\nChaquopy. Chaquopy is a plugin for Android Studio's Gradle-based build system. ...\nKivy. Kivy is a cross-platform OpenGL-based user interface toolkit. ...\nPyqtdeploy. ...\nQPython. ...\nSL4A. ...\nPySide.","Q_Score":0,"Tags":"python,android","A_Id":58469778,"CreationDate":"2019-10-20T00:09:00.000","Title":"Can I learn python for building android applications?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am starting to learn python and I don't know much about programming right now. In the future, I want to build android applications. Python looks interesting to me.\nCan I use python for building Android applications?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":58469032,"Users Score":0,"Answer":"As of now the official android development languages are kotlin and java in android studio IDE,  with the addition of dart for cross-platform development in flutter SDK. I would advise you stick to whichever you find easiest as per your needs. Although python is more widely accepted in the domains of data science\/machine learning so your knowledge of it is still a big plus.","Q_Score":0,"Tags":"python,android","A_Id":58469135,"CreationDate":"2019-10-20T00:09:00.000","Title":"Can I learn python for building android applications?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am starting to learn python and I don't know much about programming right now. In the future, I want to build android applications. Python looks interesting to me.\nCan I use python for building Android applications?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":58469032,"Users Score":0,"Answer":"You could use python as the back end and vue native as the front end. Vue active can be exported as native android application and put in the app store. The frontend will call API written in back end (in your case, written in python). Check out Vuenative + flask\/ django framework.","Q_Score":0,"Tags":"python,android","A_Id":58469681,"CreationDate":"2019-10-20T00:09:00.000","Title":"Can I learn python for building android applications?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a numpy array like this: [1 2 2 0 0 1 3 5]\nIs it possible to get the index of the elements as a 2d array? For instance the answer for the above input would be [[3 4], [0 5], [1 2], [6], [], [7]]\nCurrently I have to loop the different values and call numpy.where(input == i) for each value, which has terrible performance with a big enough input.","AnswerCount":8,"Available Count":1,"Score":0.024994793,"is_accepted":false,"ViewCount":3200,"Q_Id":58469671,"Users Score":1,"Answer":"Pseudocode:\n\nget the \"number of 1d arrays in the 2d array\", by subtracting the minimum value of your numpy array from the maximum value and then plus one. In your case, it will be 5-0+1 = 6\ninitialize a 2d array with the number of 1d arrays within it. In your case, initialize a 2d array with 6 1d array in it. Each 1d array corresponds to a unique element in your numpy array, for example, the first 1d array will correspond to '0', the second 1d array will correspond to '1',...\nloop through your numpy array, put the index of the element into the right corresponding 1d array. In your case, the index of the first element in your numpy array will be put to the second 1d array, the index of the second element in your numpy array will be put to the third 1d array, ....\n\nThis pseudocode will take linear time to run as it depends on the length of your numpy array.","Q_Score":11,"Tags":"python,numpy,numpy-ndarray","A_Id":58469792,"CreationDate":"2019-10-20T02:53:00.000","Title":"Numpy: get the index of the elements of a 1d array as a 2d array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using boto3 to download files from an s3 bucket & I need to support canceling an active file transfer in my client UI - but I can't find how to do it.\nThere is a progress callback that I can use for transfer status, but I can not cancel the transfer from there.\nI did find that boto3's s3transfer.TransferManager object has a .shutdown() member, but it is buggy (.shutdown() passes the wrong params to ._shutdown() a few lines below it) & crashes.\nIs there another way to safely cancel an active file_download?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":478,"Q_Id":58469915,"Users Score":1,"Answer":"Can you kill the process associated with the file? \nkill $(ps -ef | grep 'process-name' | awk '{print $2}')","Q_Score":7,"Tags":"python,amazon-s3,boto3","A_Id":58807904,"CreationDate":"2019-10-20T03:58:00.000","Title":"How can I cancel an active boto3 s3 file_download?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm novice. That's why I can't understand the essential difference between using Java\/Kotlin or using Python with its numerous modules for Android application development. Is there a good reason that makes Java\/Kotlin better choice? Please explain.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":680,"Q_Id":58470176,"Users Score":0,"Answer":"Java and Kotlin are the official language of Android SDK.\nThat's why all use these. On the other way, python use to make cross platfrom application.","Q_Score":0,"Tags":"java,python,android,kotlin","A_Id":58470544,"CreationDate":"2019-10-20T05:01:00.000","Title":"Why use Java\/Kotlin instead Python on Android?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a beginner, its been ~2 months since i started learning python. \nI've written a code about a function that takes two strings, and outputs the common characters between those 2 strings. The issue with my code is that it returns all common characters that the two inputs have. For example:\ninput: common, moron\nthe output is \"oommoon\" when ideally it should be \"omn\".\ni've tried using the count() function, and then the replace function, but it ended up completely replacing the letters that were appearing more than once in the output, as it should.\nhow should i go about this? i mean it's probably an easy solution for most of the ppl here, but what will the simplest approach be such that i, a beginner with okay-ish knowledge of the basics, understand it?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":119,"Q_Id":58473457,"Users Score":0,"Answer":"You can try this:\n''.join(set(s1).intersection(set(s2)))","Q_Score":3,"Tags":"python","A_Id":58473587,"CreationDate":"2019-10-20T13:24:00.000","Title":"How do I limit the number of times a character appears in a string in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Anaconda (python 3.7) in my Windows 8.1 system. However, while running my Python code from the Spyder console, I am getting the following error:\nAn error occurred while starting the kernel\nI have checked the PATH environment variable and everything is correct.\nHere is the detailed error received in the console while trying to execute the code:\n\nTraceback (most recent call last):\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site\u2011packages\\spyder\\plugins\\ipythonconsole.py\", line 1572, in create_kernel_manager_and_kernel_client\nkernel_manager.start_kernel(stderr=stderr_handle)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site\u2011packages\\jupyter_client\\manager.py\", line 240, in start_kernel\nself.write_connection_file()\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site\u2011packages\\jupyter_client\\connect.py\",\nline 547, in write_connection_file\nkernel_name=self.kernel_name\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site\u2011packages\\jupyter_client\\connect.py\",\nline 212, in write_connection_file\nwith secure_write(fname) as f:\nFile \"C:\\ProgramData\\Anaconda3\\lib\\contextlib.py\", line 112, in enter\nreturn next(self.gen)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site\u2011packages\\jupyter_client\\connect.py\", line 102, in secure_write\nwith os.fdopen(os.open(fname, open_flag, 0o600), mode) as f:\nPermissionError: [Errno 13] Permission denied: 'C:\\Users\\bharat\\AppData\\Roaming\\jupyter\\runtime\\kernelbcba4480cd.json'","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":14622,"Q_Id":58474328,"Users Score":-2,"Answer":"Simply running Spyder as Administrator solved the same issue for me.","Q_Score":6,"Tags":"python,anaconda,spyder","A_Id":60379270,"CreationDate":"2019-10-20T15:10:00.000","Title":"Why am I getting \"An error ocurred while starting the kernel\" in Spyder while running Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am optimizing a tensorflow model.  It is not a neural net, I am just using tensorflow for easy derivative computations.  In any case, it seems that loss surface has a steep edge somewhere, and my loss will sometimes \"pop out\" of the local minimum it is currently targeting, the loss will go up a great deal, and the optimizer will go gallivanting off after some other optimum elsewhere.  \nI want it to not do that thing.  Specifically, I want it to look at the loss, be all like \"holy crap that just went up a whole bunch, I'd better backtrack a bit.\"  Even though the current gradient may want to send it off elsewhere, I want it to \"go back\" in sense, and continue trying to find the optimum it was previously targeting.  Is there a tensorflow optimizer that has some kind of \"negative feedback\" in this way?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":36,"Q_Id":58475363,"Users Score":1,"Answer":"You may do a forward pass, check the loss, and then do backward if you think the loss is acceptable. In TF 1.x it requires some tf.cond and manual calculation and application of gradients. The same in TF 2.0 only the control flow is easier, but you have to use gradient_tape and still apply gradients manually.","Q_Score":0,"Tags":"python,tensorflow,optimization","A_Id":58476288,"CreationDate":"2019-10-20T17:13:00.000","Title":"Tensorflow optimizer with negative feedback?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a dynamic <div> into my (very low-traffic) website, which I want to display only some data from a memory-based SQLite database running within a Python program on the server. Being a novice in web tech, I can't decide which technologies and principles should go into this project.\nRight now, the only decided-upon technologies are Python and Apache. Python, at the very least, needs to be constantly running to fetch data from the external source, format it, and enter it into the database. Problem #1 is where this database should reside. Ideally, I would like it in RAM, since the database will update both often and around the clock. Then the question becomes, \"How does one retrieve the data?\". Note: the query will never change; I want the web page to receive the same JSON structure only with up-to-date values. From here, I see two options with the first, again, being ideal:\n1) Perform some simple \"hey someone wants the stuff\" interaction with the Python program (remember that this program will be running) whenever someone loads the page, which is responded to with the JSON data. This should be fairly easy with WebSockets, but I understand they have fallen out of favor.\n2) Have the Python program periodically create\/update an HTML file, which the page loads with jQuery. I could do this with my current knowledge, but I find it inelegant and it would be accepting several compromises such as increased disk read\/writes and possibly out-of-date data unless read\/writes are increased even further, essentially rendering the benefits from a memory database useless.\nSo, is my ideal case feasible? Can I implement an API into my Python program to listen for requests? Would the request be made with jQuery? Node.js? PHP? Maybe even with Apache? Do I bypass Python by manipulating the VFS? The techs available feel overwhelming and most online resources only detail generating HTML with Python (Django, Flask, etc.).\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":58475909,"Users Score":0,"Answer":"WSGI is the tech I was looking for!","Q_Score":0,"Tags":"python,html,ajax,dynamic,server","A_Id":58478172,"CreationDate":"2019-10-20T18:16:00.000","Title":"Architecture question for app which serves data from SQLite in memory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So,I need to iterate over a dictionary in python where the keys are a tuple and the values are integers.\nI only need to print out the keys and values.\nI tried this:\nfor key,value in dict:\nbut didn't work because it assigned the first element of the tuple to the key and value and the second to the value.\nSo how should I do it?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":3642,"Q_Id":58477218,"Users Score":1,"Answer":"Just use \nfor key in dict\nand then access the value with dict[key]","Q_Score":0,"Tags":"python,dictionary,tuples,iteration","A_Id":58477269,"CreationDate":"2019-10-20T20:53:00.000","Title":"How to iterate over a dictionary with tuples?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So e.g. you are working @ Google in the YouTube team and you want to modify how the search bar looks like, or just want to change the font size, or work on a major project like the recommender system etc., does making a Git branch copy over ALL of the backend code for YouTube on your machine? So if there are 100 engineers working from their laptops in the YouTube team, are there 100 copies of YouTube code on their tiny laptops in circulation? Because as I understand Git, when you branch off, you create a copy of the source code, which you merge back into the production branch, which merges into the master branch.\nPlease correct me if I am wrong as I have only worked on MUCH smaller projects which use Git (~100 files, ~15k lines of code).\nYour support will be much appreciated.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":903,"Q_Id":58479776,"Users Score":2,"Answer":"Creating a branch in Git copies nothing.\nOK, this is a bit of an overstatement.  It copies one hash ID.  That is, suppose you have an existing repository with N branches.  When you create a new branch, Git writes one new file holding a short (currently 40-byte long, eventually to be 64-byte long) hash ID.  So if your previous disk usage was 50 megabytes, your new disk usage is ... 50 megabytes.\nOn the other hand, cloning a repository copies everything.  If the repository over on Server S is 50 megabytes, and you clone it to Laptop L, the repository on Laptop L is also 50 megabytes.1  There are ways to reduce the size of the clone (by omitting some commits), but they should be used with care.  In any case, these days 50 megabytes is pretty small anyway. :-)\nThere's a plan in the works for Git to perform a sort of mostly-delayed cloning, where an initial clone copies some of the commits and replaces all the rest with a sort of IOU.  This is not ready for production yet, though.\nThe way to understand all of this is that Git does not care about files, nor about branches.  Git cares about commits.  Commits contain files, so you get files when you get commits, and commits are identified by incomprehensible hash IDs, so we have branch names with which to find the hash IDs.  But it's the commits that matter.  Creating a new branch name just stores one existing commit hash ID into the new branch name.  The cost of this is tiny.\n\n1This isn't quite guaranteed, due to the way objects stored in Git repositories get \"packed\".  Git will run git gc, the Garbage Collector, now and then to collect and throw out rubbish and shrink the repository size, and depending on how much rubbish there is in any given repository, you might see different sizes.\nThere have been various bugs in which Git didn't run git gc --auto often enough (in particular, up through 2.17 git commit neglected to start an auto-gc afterward) or in which the auto-gc would never finish cleaning up (due to left-over failure log from an earlier gc, fixed in 2.12.2 and 2.13.0).  In these cases a clone might wind up much smaller than the original repository.","Q_Score":1,"Tags":"python,git,github","A_Id":58480189,"CreationDate":"2019-10-21T04:23:00.000","Title":"Does creating a Git branch copy ALL of the source 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'm training a tensorflow object detection model which has been pre-trained using COCO to recognize a single type\/class of objects. Some images in my dataset have multiple instances of such objects in them. \nGiven that every record used in training has a single bounding box, I wonder what is the best approach to deal with the fact that my images may have more than one object of the same class in them. \n\nShould I use the same image for multiple records?\nCould that be problematic when training?\nWould it be better if I could split said images so that they only contained one object?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":473,"Q_Id":58480861,"Users Score":2,"Answer":"Should I use the same image for multiple records?\n\nNo, because anything in the image that is not annotated as an object is classified as background, which is an implicit object type\/class. So when you train your model with an image that has an object, but that object is not annotated correctly, the performance of the model decreases (because the model considers that object and other similar entities as background)\n\nCould that be problematic when training?\n\nYes, this issue is going to affect the performance of the model in a bad way. In fact, a good thing to do is to add some images that do not have any objects in them and let the model be trained on them as background with no instance of a bounding box.\n\nWould it be better if I could split said images so that they only contained one object?\n\nYes, this can help. Also, you can consider adding multiple bounding boxes for each image. But never leave any object without an annotated bounding box, even if the object is truncated or occluded.","Q_Score":2,"Tags":"python,tensorflow,object-detection,training-data","A_Id":58486136,"CreationDate":"2019-10-21T06:31:00.000","Title":"Repeating images in training dataset for tensorflow object detection models","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am tried to solve a MILP problem using python pulp and The solution is infeasible. So, I want to find where infeasibility is coming and want to relax it or remove it to find feasible solution. it is difficult to check manually in the LP file bcz large number of constraints are present. So How I can handle this issue?\nI went through some articles they mentioned that check manually in the LP file but it is very difficult to do manually for a huge number of variables\/constraints.\nIt is giving just infeasibility","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2029,"Q_Id":58481385,"Users Score":0,"Answer":"I use some rule of thumbs to check infeasibility.\n\nAlways start with a small data set that you can inspect more manually.\nAfter relax all integer variables. If this relaxation is infeasible, your problem is linear infeasible. You might have constraints saying stuff like x > 3 and x < 2;\nIf the linear relaxation is feasible, then deactivate each constraint once. Frequently you find some obvious constraints being infeasible, such as sum(i,x_i) = 1. But if you deactivate one by one, you may find that another more complex constraint set is causing infeasibility, and there you might investigate better.","Q_Score":1,"Tags":"python,mathematical-optimization,pulp,mixed-integer-programming","A_Id":58506705,"CreationDate":"2019-10-21T07:10:00.000","Title":"Identifying infeasibility constraint and relaxing\/removing it in Python using Pulp?","Data 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 tried to solve a MILP problem using python pulp and The solution is infeasible. So, I want to find where infeasibility is coming and want to relax it or remove it to find feasible solution. it is difficult to check manually in the LP file bcz large number of constraints are present. So How I can handle this issue?\nI went through some articles they mentioned that check manually in the LP file but it is very difficult to do manually for a huge number of variables\/constraints.\nIt is giving just infeasibility","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2029,"Q_Id":58481385,"Users Score":2,"Answer":"In general, this is not so easy. Some pointers: \n\nIf you can construct a feasible but not necessarily optimal solution for your problem, plug this in and you will find the culprits very easily.\nSome advanced solvers have tools that can help (IIS, Conflict refiner). They may or may not point to the real problem.\nNote that the model can be LP infeasible or just integer infeasible.\nIn some cases it is possible just to relax a suspect block of constraints and see what happens.\nA more structural approach I often use is to formulate an elastic model: allow constraints to be violated but at a cost. This often makes some economic sense: hire temp workers, rent extra capacity, buy from 3rd parties etc.","Q_Score":1,"Tags":"python,mathematical-optimization,pulp,mixed-integer-programming","A_Id":58491280,"CreationDate":"2019-10-21T07:10:00.000","Title":"Identifying infeasibility constraint and relaxing\/removing it in Python using Pulp?","Data 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 comparing between set of string and set of list of string. The results appear inconsistent and are puzzling to me.\nFor example, while set('3') == set(['3']) is returning True, set('003') == set(['003']) is returning False.\nCould anyone help to explain why is this the case?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":53,"Q_Id":58481725,"Users Score":1,"Answer":"Because set(['003']) returns {'003'}, and set('003') - {'0', '3'}.","Q_Score":0,"Tags":"python,python-3.x","A_Id":58481869,"CreationDate":"2019-10-21T07:35:00.000","Title":"What is the difference between these two comparisons of sets?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm comparing between set of string and set of list of string. The results appear inconsistent and are puzzling to me.\nFor example, while set('3') == set(['3']) is returning True, set('003') == set(['003']) is returning False.\nCould anyone help to explain why is this the case?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":53,"Q_Id":58481725,"Users Score":2,"Answer":"set('003') creates an entry for every unique item in that string (list of chars), so it returns {'3', '0'} and it's equal to set(['0','0','3']).\nWhile set(['003']) creates an entry for each item of the list, so it returns {'003'}","Q_Score":0,"Tags":"python,python-3.x","A_Id":58481820,"CreationDate":"2019-10-21T07:35:00.000","Title":"What is the difference between these two comparisons of sets?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset that I have loaded as a data frame in Python. It consists of 21392 rows (the data instances, each row is one sample) and 79 columns (the features). The last column i.e. column 79 has string type labels. I would like to use a CNN to classify the data in this case and predict the target labels using the available features. This is a somewhat unconventional approach though it seems possible. However, I am very confused on how the methodology should be as I could not find any sample code\/ pseudo code guiding on using CNN for Classifying non-image data, either in Tensorflow or Keras. Any help in this regard will be highly appreciated. Cheers!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":371,"Q_Id":58482580,"Users Score":1,"Answer":"You first have to know, if it is sensible to use CNN for your dataset. You could use sliding 1D-CNN if the features are sequential eg) ECG, DNA, AUDIO. However I doubt that this is not the case for you. Using a Fully Connected Neural Net would be a better choice.","Q_Score":0,"Tags":"python,tensorflow,conv-neural-network","A_Id":58482713,"CreationDate":"2019-10-21T08:36:00.000","Title":"how to use 1D-convolutional neural network for non-image data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to train an XGboost model in python and use the saved model to predict in spark environment ?  That is, I want to be able to train the XGboost model using sklearn, save the model. Load the saved model in spark and predict in spark. Is this possible ?\nedit:\nThanks all for the answer , but my question is really this. I see the below issues when I train and predict different bindings of XGBoost.\n\nDuring training I would be using XGBoost in python, and when\u00a0 predicting I would be using XGBoost in mllib.\nI have to load the saved model from XGBoost python (Eg: XGBoost.model file) to be predicted in spark, would this model be compatible to be used with the predict function in the mllib\nThe data input formats of both XGBoost in python and XGBoost in spark mllib are different. Spark takes vector assembled format but with python, we can feed the dataframe as such. So, how do I feed the data when I am trying to predict in spark with a model trained in python. Can I feed the data without vector assembler ? Would XGboost predict function in spark mllib take non-vector assembled data as input ?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1017,"Q_Id":58483371,"Users Score":0,"Answer":"you can \n\nload data\/ munge data using pyspark sql,  \nthen bring data to local driver using collect\/topandas(performance bottleneck)\nthen train xgboost on local driver\nthen prepare test data as RDD, \nbroadcast the xgboost model to each RDD partition, then predict data in parallel\n\nThis all can be in one script, you spark-submit, but to make the things more concise, i will recommend split train\/test in two script.\nBecause step2,3 are happening at driver level, not using any cluster resource, your worker are not doing anything","Q_Score":1,"Tags":"python-3.x,scala,apache-spark-mllib,xgboost,apache-spark-ml","A_Id":58491153,"CreationDate":"2019-10-21T09:25:00.000","Title":"Training in Python and Deploying in Spark","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to train an XGboost model in python and use the saved model to predict in spark environment ?  That is, I want to be able to train the XGboost model using sklearn, save the model. Load the saved model in spark and predict in spark. Is this possible ?\nedit:\nThanks all for the answer , but my question is really this. I see the below issues when I train and predict different bindings of XGBoost.\n\nDuring training I would be using XGBoost in python, and when\u00a0 predicting I would be using XGBoost in mllib.\nI have to load the saved model from XGBoost python (Eg: XGBoost.model file) to be predicted in spark, would this model be compatible to be used with the predict function in the mllib\nThe data input formats of both XGBoost in python and XGBoost in spark mllib are different. Spark takes vector assembled format but with python, we can feed the dataframe as such. So, how do I feed the data when I am trying to predict in spark with a model trained in python. Can I feed the data without vector assembler ? Would XGboost predict function in spark mllib take non-vector assembled data as input ?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1017,"Q_Id":58483371,"Users Score":0,"Answer":"You can run your python script on spark using spark-submit command so that can compile your python code on spark and then you can predict the value in spark.","Q_Score":1,"Tags":"python-3.x,scala,apache-spark-mllib,xgboost,apache-spark-ml","A_Id":58483658,"CreationDate":"2019-10-21T09:25:00.000","Title":"Training in Python and Deploying in Spark","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have change list. I am able to list out the files present in change list but I want to load the file present in change list with the changes. Is there any way using python perforce scripting?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":612,"Q_Id":58484056,"Users Score":1,"Answer":"You don't say how you're currently listing out the files, but I assume it's some form of the p4 files command, using either the CLI or the P4Python API?  In either case, use p4 describe (on the changelist) to see the diffs, or p4 print (on the revisions returned by p4 files) to get the content of an individual file.","Q_Score":0,"Tags":"python,perforce,p4v","A_Id":58509688,"CreationDate":"2019-10-21T10:08:00.000","Title":"Is there any way to read the file present in change list using python perforce?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My aim is to force the docker build to fail if the Unittests have not all passed. I'm using the following line in my DockerFile:\nRUN python3 -m unittest discover test\nMy unit tests are in classes in the test directory. The tests are run, but a failed test does not result in a failed build. \nI know that a non-zero exit code is how to stop a build, but that does not seem to occur using this command.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1973,"Q_Id":58484542,"Users Score":2,"Answer":"Had the same problem : Fail the docker build if unittest fails in azure pipeline \nI put the below code in my build.yml file. \nerrors=$(docker logs careplan-tests-1 2>&1 | grep \"FAILED\" -c)\n        if [ $errors > 0 ]; then\n          echo -e \"unittest tests failed\"\n          docker rm apiunittest\n          exit 1\n        fi\nGives the output as \"##[error]Bash exited with code '1'.\" in docker build and fails the azure pipeline.","Q_Score":8,"Tags":"python,unit-testing,docker","A_Id":62270037,"CreationDate":"2019-10-21T10:38:00.000","Title":"Stop\/fail docker build if tests fail","Data Science and Machine Learning":0,"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 is an example to make the situation clear. \nLet's say we have two lists contain some names. I call them original (O) and modified (M) lists. Note, M has missed names. I don't have access to O, but I have access to M. What I have from O is a list , I called it O1, that follows two conditions: (1) in the case of repetition, only the most recent name should be considered, (2) the order of O1 is LIFO of O. \nAs an example, Imagine the original list contains O={n1,n2,n3,n2,n1,n3,n1,n3} where n1 is the first person who wrote his name in the first, fifth, and seventh position. So, what I have is O1={n3,n1,n2}, those two conditions have applied. Now, the modified list contains M={n2,n3,n2,n1,n3,n1} ( two names have been removed(n1, n3)), and by following those two conditions I can create M1={n1,n3,n2}.  By comparing O1, and M1\nO1={n3,n1,n2}\nM1={n1,n3,n2}\nI can find n3 as a missing name because the position of n3 has been modified in my generated list (M1). \nHow I can catch n1 as a missing name?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":58485763,"Users Score":0,"Answer":"I don't think it's possible unless you have access to more information than what is stated in the question. Beginning elements of O that are missing will be unrecognizable when comparing only against O1 provided that the last repetition sequence is the same.\nFor example, Let M = {1, 2, 3}. Consider a few instances of different possible O lists.\n\n(A) O = {1, 1, 2, 3}, where M is missing 1\n(B) O = {2, 1, 2, 3}, where M is missing 2\n(C) O = {3, 1, 2, 3}, where M is missing 3\n\nAll of the above O lists produce O1 = {3, 2, 1} under your constraints.  So given only O1 and M to work with, and even the number of elements missing from O, there's no way to distinguish from the above cases to tell which of the beginning elements are missing. The provided inputs for A,B,C are identical.","Q_Score":1,"Tags":"python,algorithm,list","A_Id":58491893,"CreationDate":"2019-10-21T11:53:00.000","Title":"finding missing name from two lists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an expression involving lots of trigonometric functions which I wish to simplify.  Unfortunately, simplify() and trigsimp() takes forever to complete which I suspect is because simplify is trying to use dozens of rules to try to simplify.\nSuppose I already know before hand that I only want to simplify based on the identity\nsin(a)**2 + cos(a)**2 = 1 (note a may be a huge expression), is there some way to tell simplify to only use this rule, so that it might work faster in simplifying?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":58488455,"Users Score":2,"Answer":"See the fu.py routines for very targeted trigonometric transformations.","Q_Score":1,"Tags":"python-3.x,sympy","A_Id":58494399,"CreationDate":"2019-10-21T14:28:00.000","Title":"Force simplify to only use certain rules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating various classes for computational geometry that all subclass numpy.ndarray.  The DataCloud class, which is typical of these classes, has Python properties (for example, convex_hull, delaunay_trangulation) that would be time consuming and wasteful to calculate more than once. I want to do calculations once and only once.  Also, just in time, because for a given instance, I might not need a given property at all.  It is easy enough to set this up by setting self.__convex_hull = None in the constructor and, if\/when the convex_hull property is called, doing the required calculation, setting self.__convex_hull, and returning the calculated value.\nThe problem is that once any of those complicated properties is invoked, any changes to the contents made, external to my subclass, by the various numpy (as opposed to DataCloud subclass) methods will invalidate all the calculated properties, and I won't know about it.  For example, suppose external code simply does this to the instance: datacloud[3,8] = 5.  So is there any way to either (1) make the ndarray base class read-only once any of those properties is calculated or (2) have ndarray set some indicator that there has been a change to its contents (which for my purposes makes it dirty), so that then invoking any of the complex properties will require recalculation?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":58494393,"Users Score":0,"Answer":"Looks like the answer is:\nnp.ndarray.setflags(write=False)","Q_Score":0,"Tags":"python,numpy,subclass,numpy-ndarray","A_Id":58502790,"CreationDate":"2019-10-21T21:30:00.000","Title":"Any way to prevent modifications to content of a ndarray subclass?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I like to organize my data analysis projects with a root folder containing a data folder (named data) and a code folder (when I use R, I sometimes name it R). When using Python, my code folder would logically be called python. My project working directory is the root folder (containing both data and python folders).\nI have multiple files of code in my python folder. I would like to import one (let's call it file2.py) from another, in an interactive python session. I have tried the following:\nfrom .python import file2\nHowever, this does not work because python is a reserved word. If I rename the folder to something different, it works. Is there a way to escape the reserved word, or pass the file location as a string to the import? I'm frustrated because all the best alternatives (e.g., code, scripts) are also reserved words. My project organization is an oft-recommended best practice in R, and I'm hoping there's a parallel in Python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":226,"Q_Id":58495974,"Users Score":1,"Answer":"Your code is not running as a package. Therefore, you need to run from python import file2, not from .python import file2.","Q_Score":0,"Tags":"python","A_Id":58496285,"CreationDate":"2019-10-22T01:22:00.000","Title":"Importing a python script from a folder named \"python\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can we set a confirmation message for a Onchange function in Odoo. if we change a field a warning will appear If we confirm we agree the chang else we need to revert the change.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":678,"Q_Id":58496312,"Users Score":0,"Answer":"You can try creating a custom confirmation wizard or use redirect warning in onchange function to get a confirmation message.","Q_Score":1,"Tags":"python,odoo","A_Id":58496877,"CreationDate":"2019-10-22T02:24:00.000","Title":"Can we set a confirmation message for a Onchange function in Odoo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to set up a system on multiple computers where I'll be able to run the some set of scripts and have it work on all of them. If I have the same version of Python installed locally all of the computers, am I able to set up a virtual environment on a network location? If so, does the Python executable need to be on the local drive or can it be in the network location?\nIf this isn't possible then what is the best way to do it?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":90,"Q_Id":58498266,"Users Score":1,"Answer":"Yes you can. You can export all dependencies with pip freeze > requirements.txt and prepare a script which installs missing packages on each machine.\nI would personally implement script to sort dependencies in requirements.txt alphabetically and store both in a git repository and define a cron job on each machine to pull current version of requirements.txt from the remote and install missing dependencies and the other script to update the requirements.txt and push changes so they could broadcast.","Q_Score":1,"Tags":"python-3.x,python-venv","A_Id":58498325,"CreationDate":"2019-10-22T06:30:00.000","Title":"Setting up a way for different computers to access the same virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a binary file on my PC that contains data in big-endian. The file contains around 121 MB.\nThe problem is I would like to convert the data into little-endian with a python script. \nWhat is currently giving me headaches is the fact that I don't know how to convert an entire file. If I would have a short hex string I could simply use struct.pack to convert it into little-endian but if I see this correctly I can't give struct.pack a binary file as input.\nIs there an other function\/utility that I can use to do that or how should my approach look like?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":58498747,"Users Score":0,"Answer":"We need a document or knowledge of the file's exact structure.\nSuppose that there is a 4 byte file. If this file has just a int, we need to flip that. But if it is a combination of 4 char, we should leave it as it be.\nAbove all, you should find the structure. Then we can talk about the translation. I think there is no translation tools to support general data, but you need to parse that binary file following the structure.","Q_Score":1,"Tags":"python,endianness,data-conversion","A_Id":58498956,"CreationDate":"2019-10-22T07:03:00.000","Title":"Converting the endianness type of an already existing binary file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"By accident I created a local python package with the same name as an existing PYPI package (pyea).Now I realised that by updating all installed packages my package will be overwritten by a newer version from PYPI-Server. Can I give my local package a flag or so, to prevent from updating using PYPI-Server? Or there are maybe some parameters for the setup.py file to control this issue.\nRenaming the package would require a lot of effort.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":141,"Q_Id":58500317,"Users Score":1,"Answer":"It is best practice to avoid using names of packages that already exist. While renaming might be a lot of effort, it's your best option to avoid any future hassle.\nIt'll be a short term pain for a long term gain.","Q_Score":1,"Tags":"python,setup.py,pypi,python-packaging","A_Id":58500691,"CreationDate":"2019-10-22T08:43:00.000","Title":"How to avoid updating a package from PyPI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running a range of GridSearchCV().fits for a RandomForestClassifier over a range of parameter sets.\nFrom the start I have been setting n_jobs=-1 on the RandomForestClassifier.\nFor the past week I've been doing this with an i5 4-core processor and it was okay but not very fast. I've just upgraded to a computer with an AMD Ryzen Threadripper 2970WX with 24 cores and 48 logical processors. However it doesn't seem to be running any faster at all! When running the GridSearchCV, the majority of cores are either idle or at very low utilization.\nWhat's going wrong?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":40,"Q_Id":58500382,"Users Score":-1,"Answer":"Perhaps the size of your parameter grid is smaller than 48?","Q_Score":1,"Tags":"python,scikit-learn","A_Id":60212560,"CreationDate":"2019-10-22T08:47:00.000","Title":"Why does my GridSearchCV().fit() run slower now that I'm using a better processor?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to retrieve a url from shortcuts on Windows and Linux using python. \nThe shortcuts have the same name but different links.\nHow do I actually retrieve the url from the shortcuts?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":58505338,"Users Score":0,"Answer":"Desktop shortcuts in most desktop environments are just some machine readable files. I guess there is no way around parsing those files and retrieving the information you need that way.\nNote: The format of those files might differ substantially from desktop environment to desktop environment.","Q_Score":1,"Tags":"python-3.x,linux,windows","A_Id":58505526,"CreationDate":"2019-10-22T13:23:00.000","Title":"How do I retrieve the url a desktop shortcut is pointing to?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am comparing two df, it gives me False when using .equals(), but if I append two df together and use drop_duplicate() it gives me nothing. Can someone explain this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":488,"Q_Id":58508089,"Users Score":0,"Answer":"maybe the lines in both dataframes are not ordered the same way? dataframes will be equal when the lines corresponding to the same index are the same","Q_Score":1,"Tags":"python,pandas,dataframe,comparison","A_Id":58508299,"CreationDate":"2019-10-22T15:55:00.000","Title":"Why get different results when comparing two dataframes?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a tk.Button(..., command=_on_button_click).\nOnce it is clicked, I want to know whether the Shift key is currently held down.\nBut the _on_button_click is called without any event object or similar for me to check it","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":583,"Q_Id":58509952,"Users Score":3,"Answer":"Assuming a button named button and a handler named shift_click, you can use the bind method:\nbutton.bind(\"<Shift-Button-1>\", shift_click)\nOf course, you will probably also want one without shift click:\nbutton.bind(\"<Button-1>\", not_shift_click)","Q_Score":1,"Tags":"python,tkinter,onclick","A_Id":58509991,"CreationDate":"2019-10-22T18:01:00.000","Title":"tkinter check if Shift is down when Button is pressed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to ensure that any scripts me and my coworkers write can be run by each other. I've run into some inexplicable problems recently, which I don't know are machine\/platform\/software\/versioning issues. Unfortunately, we often don't have the time to test why something isn't working.\nThe most obvious difference my coworker and I is that his setup is on Spyder and mine is PyCharm. We are both using Windows 10 Education and the latest python and pandas.\nSome of the problems I've encountered:\n\nhis script will delete the last unit in a number which read in as float for him (10.0 -> 10), but deletes the last unit of a number which read in as integer for me (10 -> 1)\nhis script will read in a multiindex xlsm file and perform operations on it, mine will say the relevant index doesn't exist\n\nI would appreciate any knowledge or tips from people who have encountered this behavior\/challenge.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":58511793,"Users Score":0,"Answer":"I would say your best bet is to set up an app server(Flask) and serve the code from a machine that gets the output expected (Be it something local or an EC2 instance or whatever). Then there is one code base and one platform, instead of going down the rabbit hole. Also a lot easier to maintain.","Q_Score":0,"Tags":"python,pycharm,spyder,data-analysis","A_Id":58511911,"CreationDate":"2019-10-22T20:25:00.000","Title":"Data analysis code running differently on coworker's computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently needing help doing the following: \nTake the highlighted data from the POST Request(s) Summary See Image and use python\/ pycharm to load them into .csv file as they come in. \nEach of these post requests will be a different link and I just need them to be automatically sent to the .csv file using python\/ pycharm.\nI am using TWILIO to send the post requests to NGROK.\nTHANK YOU SOOO MUCH","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":58512681,"Users Score":0,"Answer":"First of all Ngrok cant be used to gather data, its a tunneling tool that exposes your local server to the internet. To achieve what you need you need to evaluate the POST request and parse the so that you can fetch the fields you need. Post the code you have to get further assistance.","Q_Score":0,"Tags":"python-3.x,automation,pycharm,ngrok","A_Id":58516764,"CreationDate":"2019-10-22T21:42:00.000","Title":"How do I use NGROK to gather post data and send it automatically to a .csv file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a Python script that connects to the Twitter API to pull in some tweets into an array, then pushes this to a mysql database. It's a pretty basic script, but I'd like to set it up to run weekly.\nI'd like to know the best way to deploy it so that it can automatically run weekly, so that I don't have to manually run it every week.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":46,"Q_Id":58512952,"Users Score":0,"Answer":"This depends on platform where you intend to run your python code. As martin says, this is not a python question and more of scheduling related question.","Q_Score":0,"Tags":"python,cloud","A_Id":58513538,"CreationDate":"2019-10-22T22:14:00.000","Title":"How to run Python code periodically that connects to the internet","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 Python script that connects to the Twitter API to pull in some tweets into an array, then pushes this to a mysql database. It's a pretty basic script, but I'd like to set it up to run weekly.\nI'd like to know the best way to deploy it so that it can automatically run weekly, so that I don't have to manually run it every week.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":58512952,"Users Score":0,"Answer":"You can create a batch file that can activate python and run your script and then, use task scheduler to schedule youe batch file execution weekly","Q_Score":0,"Tags":"python,cloud","A_Id":58513008,"CreationDate":"2019-10-22T22:14:00.000","Title":"How to run Python code periodically that connects to the internet","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 file with a function. I want to import the file and when doing that I get No module named ex25.\nimport ex25\nI have checked some tutorials and the offial documentation.\n\n\n\nimport ex25\n      No module named ex25","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":58515227,"Users Score":0,"Answer":"First, check if the file is .py file and in the same folder with the file that you are currently working on, there shouldn't be any problem at all. \nIf not in the same folder, but in a different folder and make sure that your file is .py file, you need to make that folder (which contains the file) to a package by adding a file name __init__.py","Q_Score":0,"Tags":"python-3.x,file,import","A_Id":58515616,"CreationDate":"2019-10-23T03:53:00.000","Title":"How do I import a file to execute a 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":"My XGBoost model regularly makes mistakes in prediction on the same samples. I want to let the model know its mistakes and correct model prediction behavior. How can I do this?\nI tried to solve the problem by decreasing logistic regression threshold (by increasing model sensibility) but it leads to radical increasing of false positive predictions. I also tried to tune model' parameters (colsample by tree, subsample, min_child_weight, max_depth), but it didn't help.\nIn text recognition software I faced some function, which allows to say the program \"you predicted a letter incorrectly\", and, by this, to learn model to recognize a letter correctly.\nIs there something similar in Machine Learning?\nMay be, there are some regularization methods, which re-distribute weight between features.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":127,"Q_Id":58517184,"Users Score":1,"Answer":"Did you verify if those samples are outliers ? If they are, try to make your model more robust to them by changing the hyperparameters or scaling your data set","Q_Score":0,"Tags":"python,model,xgboost","A_Id":58702595,"CreationDate":"2019-10-23T07:03:00.000","Title":"How to make XGBoost model to learn its mistakes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on an OCR application. I use docker for my application. The application consists of 4 containers.\n\nConverter (Converts PDF to the image)\nCleaner (Cleans the image)\nTranscriber (Converts image to text)\nAll in One\n\nThe AllinOne container integrates all the other containers through API calls. The APIs are implemented using Flask. The AllinOne container is exposed to the server.  The workflow is as follows,\nPostman (User Request) -> AllinOne -> Convertor -> AllinOne -> Cleaner -> Allinone -> Transcriber -> Allinone -> Postman (response)\nNow, I am trying to add a feature to my application called the Bulk Upload, where users will be able to upload a .zip file. Since bulk uploads take a longer time to process, I need intermediate results about the status of the process. I have a file_id allocated for each file that is being uploaded. I need to return the file_id to the user so that they'll be able to check the status of processing for their file. But, the processing has to take place in the background.\nIf I return the file_id the processing would stop, or else the file_id would be returned only after processing of the file, which is useless. Should I implement two API calls? One for uploading the file and returns the file_id, and the other to process the file and return the result. Is there a way to send frequent updates as a response from an API? Can it be done better? Feel free to suggest any change in the architecture.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":58517218,"Users Score":0,"Answer":"An REST-API is synchronous, but your processing does not need to be.\nYou should probably change your architecture so that your HTTP-POST just creates all necessary jobs and returns ids the user can check on later.\nWhen the user wants to get an update, he has to ask your api using the id to get the status.\nObviously, all of your containers need to support that pattern - e.g. they send asynchronous updates about the status of the processing. In my experience, rest api calls are not the best pattern for this, use something asynchronous to report the status, e.g. RabbitMq \/ kafka \/ nats.\nYour All in One container \/ or a new dedicated aggregator can then aggreagte such updates and return the status if somebody asks.","Q_Score":0,"Tags":"python-3.x,rest,docker,flask,flask-restful","A_Id":58517367,"CreationDate":"2019-10-23T07:05:00.000","Title":"How to get updates(response) from a REST API implemented using Flask? Is there any workaround if it is not possible?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My problem is finding nth phone number using dictionary(Python).\nphonedict = {\u2018kim\u2019: \u2018344-7944\u2019, ......., \u2018choi\u2019: \u2018544-2376\u2019}, containing 10 items. \nWrite a Python code that sorts the keys in ascending order, and print out the phone number of 5-th person.\nHow can I find this? Even I tried for finding answer, I'm still not find the answer.\nI call for help. \nThank you very much.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":58520206,"Users Score":0,"Answer":"Consider following dictionary.\n\nphone = {'ar': 123123, 'qw': 3453453, 'cv':34234, 'dd': 56757675, 'aa': 43534534, 'bb': 87897675}\nfifth element lies at 4 index of sorted keys of phone\n\nphonedict[sorted(phonedict)[4]]\noutput: 56757675","Q_Score":0,"Tags":"python","A_Id":58520436,"CreationDate":"2019-10-23T09:56:00.000","Title":"How can I find the nth phone number using dictionary?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I want to deal with a big amount of data of 1 billions rows and 23 columns. But in pandas I cannot even read the data. So how can I handle this data on my computer which is Dell XPS 9570. Can I use spark for that? Any advice to deal with it on my PC?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":58521937,"Users Score":0,"Answer":"Basically for handling large amount of data you have to use big data tool like Hadoop or Apache Spark. You can use pyspark which is combination of python and spark having high efficiency for data processing.\nI suggest, if you have flat file format then used ORC file format for processing data into pyspark which improve your performance efficiency.","Q_Score":0,"Tags":"python-3.x,database,apache-spark","A_Id":58523442,"CreationDate":"2019-10-23T11:33:00.000","Title":"Big Amount of Data on a PC?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"whenever I try to do this \"from collections import counter\", I am getting output as follows plz let me know why?\nImportError: cannot import name 'counter' from 'collections' (C:\\Users\\chandra teja\\Anaconda3\\lib\\collections__init__.py)\nProcess finished with exit code 1.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":450,"Q_Id":58524877,"Users Score":1,"Answer":"use from collections import Counter Note the UPPER-CASE \"C\"\ngood luck","Q_Score":1,"Tags":"python-3.x","A_Id":58525137,"CreationDate":"2019-10-23T14:13:00.000","Title":"Unable to import counter from collections in python 3 anaconda python in windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As title. I mean, you can invoke next(obj) and point to the next element. So the internal state of the iterable or generator will change.\nWhy they are hashable?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":99,"Q_Id":58529829,"Users Score":1,"Answer":"While the internal state of the generator can change, the generator as a whole can never add something to itself, and can never go back a step while iterating over it. Therefore, a generator is a fixed immutable object, which is almost the definition of being hashable.\nBut even more deeply than that, even mutable objects can be hashable as long as they define __hash__ as an instance method, but that is rarely desireable for mutable objects.","Q_Score":3,"Tags":"python,hash,iterator,generator","A_Id":58529885,"CreationDate":"2019-10-23T19:32:00.000","Title":"Why iterators and generators are hashable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As title. I mean, you can invoke next(obj) and point to the next element. So the internal state of the iterable or generator will change.\nWhy they are hashable?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":99,"Q_Id":58529829,"Users Score":2,"Answer":"The general rule for hashing objects is:\n\nUnless __eq__ is overridden, object equality is defined by identity, and hashing matches\nIf __eq__ is overridden, and __hash__ is not, then hashing is blocked by default (because mutability that effects the result of an equality check would break the hash invariants); re-enabling hashing requires implementing __hash__, which implicitly says \"My equality and hash semantics are stable\/consistent over time\", but doesn't require that things not tied to equality or the hash code be stable.\n\nPoint is, the condition for hashability isn't immutability, it's consistency with equality (and implied stability of both equality and hash). Since most iterators and all generators don't implement __eq__ (there is no meaningful way to implement it without running out the iterator and losing the information you just used to compare it), it's all based on identity, just like with any user-defined object that doesn't define equality.","Q_Score":3,"Tags":"python,hash,iterator,generator","A_Id":58530000,"CreationDate":"2019-10-23T19:32:00.000","Title":"Why iterators and generators are hashable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 servers and a client. There is 2 way communication between the server and the client. Would I need multiple sockets on the client to communicate with the servers? I used only one socket and a few of the packets from the servers are missing. How many sockets would I need to communicate with the server?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":58530182,"Users Score":1,"Answer":"With UDP you almost always only need a single socket; you can call sendto() and recvfrom() on it to send and receive UDP packets from anywhere.\nAs for missing UDP packets, that is a fact of life with UDP; UDP packets can and sometimes will get dropped at any step of the path from sender and receiver.  You'll need to design your app to tolerate that, or alternatively come up with a mechanism by which the receiver can detect that a packet was lost and request a resend (or otherwise somehow handle that situations).","Q_Score":0,"Tags":"python,sockets,udp","A_Id":58530257,"CreationDate":"2019-10-23T20:00:00.000","Title":"Socket programming in UDP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to install jupyter on Win 10. I have been using python on linux, but this is my first time on Win 10.\nwhen I execute python -m pip install jupyter on administrator, I got errors like this:\n\nThe package setup script has attempted to modify files on your system\n  that are not within the EasyInstall build area, and has been aborted.\n  This package cannot be safely installed by EasyInstall, and may not\n  support alternate installation locations even if you run its setup\n  script by hand.  Please inform the package's author and the EasyInstall\n  maintainers to find out if a fix or workaround is available.\n\nany idea?","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":1248,"Q_Id":58533042,"Users Score":1,"Answer":"For those who encounter this and need to use Python 3.8+, make sure to update you setuptools to version 42.0.0 (or later).","Q_Score":4,"Tags":"python,python-3.x,windows,pip","A_Id":59023508,"CreationDate":"2019-10-24T01:47:00.000","Title":"python3 pip fails to install jupyter on windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to install jupyter on Win 10. I have been using python on linux, but this is my first time on Win 10.\nwhen I execute python -m pip install jupyter on administrator, I got errors like this:\n\nThe package setup script has attempted to modify files on your system\n  that are not within the EasyInstall build area, and has been aborted.\n  This package cannot be safely installed by EasyInstall, and may not\n  support alternate installation locations even if you run its setup\n  script by hand.  Please inform the package's author and the EasyInstall\n  maintainers to find out if a fix or workaround is available.\n\nany idea?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1248,"Q_Id":58533042,"Users Score":0,"Answer":"Install a version earlier than python 3.8 and the installation will work. Use CMD.","Q_Score":4,"Tags":"python,python-3.x,windows,pip","A_Id":58907446,"CreationDate":"2019-10-24T01:47:00.000","Title":"python3 pip fails to install jupyter on windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to install jupyter on Win 10. I have been using python on linux, but this is my first time on Win 10.\nwhen I execute python -m pip install jupyter on administrator, I got errors like this:\n\nThe package setup script has attempted to modify files on your system\n  that are not within the EasyInstall build area, and has been aborted.\n  This package cannot be safely installed by EasyInstall, and may not\n  support alternate installation locations even if you run its setup\n  script by hand.  Please inform the package's author and the EasyInstall\n  maintainers to find out if a fix or workaround is available.\n\nany idea?","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":1248,"Q_Id":58533042,"Users Score":1,"Answer":"I have been able to get around this error by installing Anaconda, uninstalling Python 3.8.0 and installing Python 3.7.5 instead.\nThe Jupyter installation then ran successfully when I executed pip install jupyter with Git Bash in my C:\\ drive using pip 19.2.3 (the default with Python 3.7.5).","Q_Score":4,"Tags":"python,python-3.x,windows,pip","A_Id":58541853,"CreationDate":"2019-10-24T01:47:00.000","Title":"python3 pip fails to install jupyter on windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to install jupyter on Win 10. I have been using python on linux, but this is my first time on Win 10.\nwhen I execute python -m pip install jupyter on administrator, I got errors like this:\n\nThe package setup script has attempted to modify files on your system\n  that are not within the EasyInstall build area, and has been aborted.\n  This package cannot be safely installed by EasyInstall, and may not\n  support alternate installation locations even if you run its setup\n  script by hand.  Please inform the package's author and the EasyInstall\n  maintainers to find out if a fix or workaround is available.\n\nany idea?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1248,"Q_Id":58533042,"Users Score":0,"Answer":"I had the same problem, I am using 64-bit windows 10 but downloaded the 32-bit python installer because it is the default that appears on the 'downloads' page on the python.org site.  Uninstalled python 3.8.1, downloaded the 64-bit installer instead, and then ran 'pip install jupyterlab' using the pip version 19.2.3 that got installed with the 64-bit python instead of upgrading to pip version 19.3.1.  So if you are running a 64-bit version of windows, make sure you download the 64-bit python installer!","Q_Score":4,"Tags":"python,python-3.x,windows,pip","A_Id":59780701,"CreationDate":"2019-10-24T01:47:00.000","Title":"python3 pip fails to install jupyter on windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python. Need help with Azure databricks.\nScenario:\nCurrently I am working on a project which uses HDInsight cluster to submit spark jobs and they use Python script with classes and functions [ .py] which resides in the \/bin\/ folder in the edge node.\nWe propose to use Databricks instead of HDInsight cluster and the PoC requires minimum effort.\nDoubts:\n\nIn the HDInsight cluster all the python scripts are stored in \/bin\/ folder and conf files with .yml in \/conf\/ folder.\n\nCan we replicate the same structure in the databricks DBFS so that minimum changes in the code to replicate the location.\n2.I am new to Python, I have a bunch of scripts in the \/bin\/ folder. How can I upload or install those scripts in databricks.\nMy assumption is, I need to create a package and install on the cluster as a library. Correct me if I am wrong.\n\nHow do I run the Python scripts from Databricks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1230,"Q_Id":58533089,"Users Score":0,"Answer":"@Sathya Can you provide more information on what the different python scripts as well as the config files do?\nAs for the python scripts, depending on what their function is, you could create one or more python notebooks in Databricks and copy the contents into them. You can then run these notebooks as part of a job or reference them in other notebooks with %run \/path\/to\/notebook","Q_Score":1,"Tags":"python,azure,databricks","A_Id":58537277,"CreationDate":"2019-10-24T01:56:00.000","Title":"Azure Databricks with Python scripts","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm fairly new to Python and am trying to find a way to generate two separate, random numbers. I'm using a randint with a range of 0 - 100:\n(randint(0, 100))\nIs there any way possible for a newbie to make a second range or randint?","AnswerCount":2,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":100,"Q_Id":58533523,"Users Score":-4,"Answer":"Just call randint(0, 100) again.","Q_Score":0,"Tags":"python,python-3.x","A_Id":58533648,"CreationDate":"2019-10-24T02:56:00.000","Title":"Is it possible to create two ranges for a randint in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been deploying apps to Kubernetes for the last 2 years. And in my org, all our apps(especially stateless) are running in Kubernetes. I still have a fundamental question, just because very recently we found some issues with respect to our few python apps.\nInitially when we deployed, our python apps(Written in Flask and Django), we ran it using python app.py. It's known that, because of GIL, python really doesn't have support for system threads, and it will only serve one request at a time, but in case the one request is CPU heavy, it will not be able to process further requests. This is causing sometimes the health API to not work. We have observed that, at this moment, if there is a single request which is not IO and doing some operation, we will hold the CPU and cannot process another request in parallel. And since it's only doing fewer operations, we have observed there is no increase in the CPU utilization also. This has an impact on how HorizontalPodAutoscaler works, its unable to scale the pods.\nBecause of this, we started using uWSGI in our pods. So basically uWSGI can run multiple pods under the hood and handle multiple requests in parallel, and automatically spin new processes on demand. But here comes another problem, that we have seen, uwsgi is lacking speed in auto-scaling the process tocorrected serve the request and its causing HTTP 503 errors, Because of this we are unable to serve our few APIs in 100% availability. \nAt the same time our all other apps, written in nodejs, java and golang, is giving 100% availability.\nI am looking at what is the best way by which I can run a python app in 100%(99.99) availability in Kubernetes, with the following\n\n\nHaving health API and liveness API served by the app\nAn app running in Kubernetes\nIf possible without uwsgi(Single process per pod is the fundamental docker concept)\nIf with uwsgi, are there any specific config we can apply for k8s env","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2090,"Q_Id":58534959,"Users Score":2,"Answer":"We use Twisted's WSGI server with 30 threads and it's been solid for our Django application. Keeps to a single process per pod model which more closely matches Kubernetes' expectations, as you mentioned. Yes, the GIL means only one of those 30 threads can be running Python code at time, but as with most webapps, most of those threads are blocked on I\/O (usually waiting for a response from the database) the vast majority of the time. Then run multiple replicas on top of that both for redundancy and to give you true concurrency at whatever level you need (we usually use 4-8 depending on the site traffic, some big ones are up to 16).","Q_Score":5,"Tags":"python,django,flask,kubernetes,uwsgi","A_Id":58537824,"CreationDate":"2019-10-24T05:57:00.000","Title":"Production ready Python apps on Kubernetes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am in this kind of situation: I have a file on a server and I use a script to make a REST API call. This call is gonna open the file, read it and search inside the value I sent; in the end, the file is being closed (usual with open as synthax).\nNow, inside the file there is a timestamp which I use to say to the script: if value of time.now - timestamp is over 30 minutes, then update the file. Updating consist in download some files, merge them and finally create my new main file.\nMy question is: what happens if, considering that more than 30 minutes passed, I do 2 (or more) calls at the same time ?\nI premise that for now no controls are implemented.\nWhat I expect is that the \"first\" call will lock the file to update it, but the \"second\" ? I will have any kind of error ?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":58537276,"Users Score":0,"Answer":"No error but ultimately the file will be overwritten by the last call. There will be no lock. You'll have to implement that yourself.","Q_Score":0,"Tags":"python,rest,api,with-statement","A_Id":58537323,"CreationDate":"2019-10-24T08:30:00.000","Title":"API call - What happen to file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python 3.6.5 with PyCharm.\nWhile trying to install any package, it gives the error \n\"Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'C:\\projectPath\\venv\\Scripts\\python.exe'\"\nProject path and actual python installed paths are different.\nIn settings of PyCharm, pip version is 19.0.3 and latest version is 19.3.1\nAlso, \"python -m pip --version\" from command prompt says pip version is 9.0.3\nWhat do I do?","AnswerCount":8,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":59026,"Q_Id":58538639,"Users Score":6,"Answer":"I imagine that you have more than one Python installed in your system.\nyou should go to Pycharm --> file> settings> project>project interpreter.\nyou should find the other Python instance on your system and try to change your interpreter to that one.\nif it does not appear in the list click on the button that looks like star in front of the project interpreter.\nI had the same problem.\nI realized that I installed one python by myself and another is installed while installing PyCharm.\nAfter changing my interpreter I do not receive that error anymore.","Q_Score":6,"Tags":"python-3.x,pip,pycharm","A_Id":61511593,"CreationDate":"2019-10-24T09:46:00.000","Title":"Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'dir:\\projectPath\\venv\\Scripts\\python.exe'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python 3.6.5 with PyCharm.\nWhile trying to install any package, it gives the error \n\"Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'C:\\projectPath\\venv\\Scripts\\python.exe'\"\nProject path and actual python installed paths are different.\nIn settings of PyCharm, pip version is 19.0.3 and latest version is 19.3.1\nAlso, \"python -m pip --version\" from command prompt says pip version is 9.0.3\nWhat do I do?","AnswerCount":8,"Available Count":5,"Score":-0.024994793,"is_accepted":false,"ViewCount":59026,"Q_Id":58538639,"Users Score":-1,"Answer":"I faced the same error while using Python 3.7.5 and Pycharm 2019.1.2 for my Django project.\nIt also causes failure in execution of many other python commands, and is not caused by environment variables or path.\nI guess it's because some python files are broken or corrupted.\nThe easiest and fastest way I found to get out of this was :-\n\nUninstall Python.\nUninstall Pycharm.\nAnd Reinstall latest versions of both.","Q_Score":6,"Tags":"python-3.x,pip,pycharm","A_Id":60194400,"CreationDate":"2019-10-24T09:46:00.000","Title":"Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'dir:\\projectPath\\venv\\Scripts\\python.exe'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python 3.6.5 with PyCharm.\nWhile trying to install any package, it gives the error \n\"Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'C:\\projectPath\\venv\\Scripts\\python.exe'\"\nProject path and actual python installed paths are different.\nIn settings of PyCharm, pip version is 19.0.3 and latest version is 19.3.1\nAlso, \"python -m pip --version\" from command prompt says pip version is 9.0.3\nWhat do I do?","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":59026,"Q_Id":58538639,"Users Score":0,"Answer":"I faced the same problem on Windows-10 (PyCharm 2020.1.2 version) when installing h5py package. I didn't want to change my interpreter as that will raise other compatibility errors in my code.\nIn my case:\n\nWhat didn't work: upgrading the pip\nWhat worked: I chose old h5py version-2.10 (instead of the latest h5py version selected by default by PyCharm) and it worked.\n\nMentioning just in case if this works for someone. Uninstalling both Python and Pycharm is too much to do for this error (in my opinion).","Q_Score":6,"Tags":"python-3.x,pip,pycharm","A_Id":64615607,"CreationDate":"2019-10-24T09:46:00.000","Title":"Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'dir:\\projectPath\\venv\\Scripts\\python.exe'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python 3.6.5 with PyCharm.\nWhile trying to install any package, it gives the error \n\"Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'C:\\projectPath\\venv\\Scripts\\python.exe'\"\nProject path and actual python installed paths are different.\nIn settings of PyCharm, pip version is 19.0.3 and latest version is 19.3.1\nAlso, \"python -m pip --version\" from command prompt says pip version is 9.0.3\nWhat do I do?","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":59026,"Q_Id":58538639,"Users Score":0,"Answer":"Faced same issue after trying to change the file path.\n\nTried changing the interpreter location but it dint work for me. so I uninstalled pycharm and re-installed it. working fine now.","Q_Score":6,"Tags":"python-3.x,pip,pycharm","A_Id":63983919,"CreationDate":"2019-10-24T09:46:00.000","Title":"Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'dir:\\projectPath\\venv\\Scripts\\python.exe'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python 3.6.5 with PyCharm.\nWhile trying to install any package, it gives the error \n\"Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'C:\\projectPath\\venv\\Scripts\\python.exe'\"\nProject path and actual python installed paths are different.\nIn settings of PyCharm, pip version is 19.0.3 and latest version is 19.3.1\nAlso, \"python -m pip --version\" from command prompt says pip version is 9.0.3\nWhat do I do?","AnswerCount":8,"Available Count":5,"Score":0.024994793,"is_accepted":false,"ViewCount":59026,"Q_Id":58538639,"Users Score":1,"Answer":"This error occurred to me too when using PyCharm, and trying to install MeCab in it. And by choosing mecab-python3 instead of just mecab (which is what is for Python2 I assume...). \nYou might install the package compatible to the Python version used in the package, but not to yours, which is that PyCharm refers to'dir:\\projectPath\\venv\\Scripts\\python.exe' . So you should choose the different version of the package, or change interpreter to another.","Q_Score":6,"Tags":"python-3.x,pip,pycharm","A_Id":61424572,"CreationDate":"2019-10-24T09:46:00.000","Title":"Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'dir:\\projectPath\\venv\\Scripts\\python.exe'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a typical Django project that uses PostgreSQL as it's database backend. I need to set up a specific endpoint (\/status\/) that works even when the connection to the database is lost. The actual code is very simple (just returns the response directly without touching the DB) but when the DB is down I still get OperationalError when calling this endpoint. This is because I use some pieces of middleware that attempt to contact the database, e.g. session middleware and  auth middleware. Is there any way to implement such \/status\/ endpoint? I could theoretically implement this as a piece of middleware and put it before any other middleware but that seems as kind of hack.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":58541016,"Users Score":0,"Answer":"Up to my knowledge no.\nIf some Middlewares requires a database and you enabled them then they will be used for each request.\nI did not read about a way of conditionally executing middlewares depending on the request's url.\nSo up to my knowledge a normal djangoview will not be able to handle such a status page.\nThe only solution, that I can imagine is your suggestion to implement a middleware, that is handled first, shortcuts all the other middlewares and returns the result.","Q_Score":3,"Tags":"python,django","A_Id":58541424,"CreationDate":"2019-10-24T12:03:00.000","Title":"Add Django endpoint that doesn't require database connection","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible?\nI know ws.set_row('B:B', options={'hidden': True})\nBut, is there something like ws.set_row('B:B', options={'delete_row': True})?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6148,"Q_Id":58541514,"Users Score":0,"Answer":"You cannot delete a column with XlsxWriter. The best option is to structure your application so it doesn't write data to the column in the first place.","Q_Score":7,"Tags":"python,xlsxwriter","A_Id":58544117,"CreationDate":"2019-10-24T12:34:00.000","Title":"Delete row\/column from Excel with xlsxwriter","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a (de facto) standard MIME type to use for Python wheel packages? I couldn't see any in PEP 427.\nI suppose application\/zip could be an option, but that seems misleading to me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":488,"Q_Id":58543470,"Users Score":2,"Answer":"There is not. However, we can artificially construct one of the following:\n\napplication\/x-wheel+zip\napplication\/x-pywheel+zip","Q_Score":2,"Tags":"python,python-wheel","A_Id":58543864,"CreationDate":"2019-10-24T14:24:00.000","Title":"Is there a MIME type for Python wheels (.whl)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Please help me understand why my model overfits if my input data is normalized to [-0.5. 0.5] whereas it does not overfit otherwise.\nI am solving a regression ML problem trying to detect location of 4 key points on images. To do that I import pretrained ResNet 50 and replace its top layer with the following architecture:\n\nFlattening layer right after ResNet\nFully Connected (dense) layer with 256 nodes followed by LeakyRelu activation and Batch Normalization\nAnother Fully Connected layer with 128 nodes also followed by LeakyRelu and Batch Normalization\nLast Fully connected layer (with 8 nodes) which give me 8 coordinates (4 Xs and 4 Ys) of 4 key points.\n\nSince I stick with Keras framework, I use ImageDataGenerator to produce flow of data (images). Since output of my model (8 numbers: 2 coordinates for each out of 4 key points) normalized to [-0.5, 0.5] range, I decided that input to my model (images) should also be in this range and therefore normalized it to the same range using preprocessing_function in Keras' ImageDataGenerator.\nProblem came out right after I started model training. I have frozen entire ResNet (training = False) with the goal in mind to first move gradients of the top layers to the proper degree and only then unfreeze a half of ResNet and finetune the model. When training with ResNet frozen, I noticed that my model suffers from overfitting right after a couple of epochs. Surprisingly, it happens even though my dataset is quite decent in size (25k images) and Batch Normalization is employed. \nWhat's even more surprising, the problem completely disappears if I move away from input normalization to [-0.5, 0.5] and go with image preprocessing using tf.keras.applications.resnet50.preprocess_input. This preprocessing method DOES NOT normalize image data and surprisingly to me leads to proper model training without any overfitting.\nI tried to use Dropout with different probabilities, L2 regularization. Also tried to reduce complexity of my model by reducing the number of top layers and the number of nodes in each top layer. I did play with learning rate and batch size. Nothing really helped if my input data is normalized and I have no idea why this happens.\nIMPORTANT NOTE: when VGG is employed instead of ResNet everything seems to work well!\nI really want to figure out why this happens. \n\nUPD: the problem was caused by 2 reasons:\n- batch normalization layers within ResNet didn't work properly when frozen\n- image preprocessing for ResNet should be done using Z-score\nAfter two fixes mentioned above, everything seems to work well!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":208,"Q_Id":58543537,"Users Score":1,"Answer":"Mentioning the Solution below for the benefit of the community.\nProblem is resolved by making the changes mentioned below:\n\nBatch Normalization layers within ResNet didn't work properly when frozen. So, Batch Normalization Layers within ResNet should be unfreezed, before Training the Model.\nImage Preprocessing (Normalization) for ResNet should be done using Z-score, instead of preprocessing_function in Keras' ImageDataGenerator","Q_Score":2,"Tags":"python,tensorflow,machine-learning,keras,resnet","A_Id":58967916,"CreationDate":"2019-10-24T14:28:00.000","Title":"ML Model Overfits if input data is normalized","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using lmfit to do small angle X-ray scattering pattern fitting. To this end, I use the Model class to wrap my functions and to make Composite Models which works well. However, it happened that I wrote all my function with 'q' as the independent variable (convention in the discipline).  Now I wanted to combine some of those q-functions with some of the built-in models. It clashes, because the independent_variable for those is 'x'. I have tried to do something like modelBGND = lmfit.models.ConstantModel(independent_vars=['q']), but it gives the error:\n\nValueError: Invalid independent variable name ('q') for function\n  constant\n\nOf course this can be solved, by either rewriting the built-in function again in 'q', or by recasting all my previously written functions in terms of 'x'. I am just curious to hear if there was a more straight forward approach?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":177,"Q_Id":58543638,"Users Score":0,"Answer":"Sorry, I don't think that is possible.\nI think you will have to rewrite the functions to use q instead of x.  That is, lmfit.Model uses function inspection to determine the names of the function arguments, and most of the built-in models really do require the first positional argument to be named x.","Q_Score":0,"Tags":"python,lmfit","A_Id":58551852,"CreationDate":"2019-10-24T14:33:00.000","Title":"Possible to rename independent variable name in Built-in lmfit fitting models?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After I run the conda env create -f environment.yml in Conda, I receive the following  warning:\n\nWarning : you have pip-installed dependencies in your environment file, but you do not list pip itself as one of your conda dependencies...\n\nWhat does this mean and what should I be doing instead?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":12813,"Q_Id":58544099,"Users Score":14,"Answer":"In your environment yml file under list of the packages you install through conda you must also add pip as a package to be installed. This installs the pip, and so you pip packages can be installed using this pip.\nPreviously pip was shipped with conda but now we have to explicitly install pip when using conda","Q_Score":13,"Tags":"python,pip,conda,flow-project","A_Id":58546402,"CreationDate":"2019-10-24T15:00:00.000","Title":"Warning after I run the command \"conda env create -f environment.yml\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using pytest-bdd and want to generate a test report where the Given, When, Then steps are clearly shown and in the case of a failure, it shows you the error. \nI have installed pytest-html and successfully created a report but it doesn't support the Given, When, Then steps.\nI have also tried outputting the report as json using the --cucumber-json option but am unsure what I can do with that. \nAllure reporting is another avenue I have explored but it requires extra decorations on steps which I would like to avoid, but maybe it is the best\/only way. \nSomething similar to the robot framework test report for example would be a great start!","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":1698,"Q_Id":58545137,"Users Score":4,"Answer":"Use allure-pytest-bdd==2.8.10 plugin and generate allure reports.","Q_Score":2,"Tags":"python,pytest,reporting,bdd,test-reporting","A_Id":60333188,"CreationDate":"2019-10-24T16:02:00.000","Title":"How to generate a useful pytest-bdd test 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":"For App Engine Standard the explicitly state that they do not support Pipfiles and immediately block you from pushing your project if it contains a Pipfile. In searching the documentation, I don't see anything that mentions if Pipfile is supported or not for App Engine Flex.","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1118,"Q_Id":58546089,"Users Score":11,"Answer":"You can just include Pipfile and Pipfile.lock in the .gcloudignore file and run pip freeze > requirements.txt after any library changes.","Q_Score":5,"Tags":"python,google-app-engine,google-cloud-platform,pipenv,app-engine-flexible","A_Id":61110829,"CreationDate":"2019-10-24T17:06:00.000","Title":"Does Google App Engine Flex support Pipfile?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Someone worked before with streaming data into (google) BigQuery using Google Cloud Functions (insert_rows_from_dataframe())?\nMy problem is it seems like sometimes the table schema is not updated immediately and when you try to load some data into table immediately after creation of a new field in the schema it returns an error:\n\nBigQueryError: [{\"reason\": \"invalid\", \"location\": \"test\", \"debugInfo\": \"\", \"message\": \"no such field.\"}]\"\n\nHowever, if I try to load again after few seconds it all works fine, so my question if someone knows the maximum period of time in seconds for this updating (from BigQuery side) and if is possible somehow to avoid this situation?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1468,"Q_Id":58546090,"Users Score":1,"Answer":"Because the API operation on BigQuery side is not atomic, you can't avoid this case. \nYou can only mitigate the impact of this behavior and perform a sleep, a retries, or set a Try-catch to replay the insert_rows_from_dataframe() several times (not infinite, in case of real problem, but 5 times for example) until it pass.\nNothing is magic, if the consistency is not managed on a side, the other side has to handle it!","Q_Score":1,"Tags":"python,google-cloud-platform,google-bigquery","A_Id":58570577,"CreationDate":"2019-10-24T17:06:00.000","Title":"How to solve problem related to BigQueryError \"reason\": \"invalid\", \"location\": \"test\", \"debugInfo\": \"\", \"message\": \"no such field.\"","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to install kivy_deps.glew(version).whl with \n\npip install absolute\/path\/to\/file\/kivy_deps.glew\n\nAnd I get this error:\n\nkivy_deps.glew(version).whl is not a supported wheel on this version\n\nI searched in the web and saw that some people said that the problem is because you shoud have python 2.7 and I have python 3.7. The version is of glew is cp27. So if this is the problem how to install python 2.7 and 3.7 in the same time and how to use both of them with pip.(i.e maybe you can use \n\npip2.7 install \n\nFor python 2.7 and\n\npip install\n\nFor python 3.7\nP.S: My PC doesn't have an internet connection that's why i'm installing it with a wheel file. I have installed all dependecies except glew and sdl2. If there is any unofficial file for these two files for python 3.7 please link them.\nI know this question has been asked before in stackoverflow but I didn't get any solution from it(it had only 1 anwser tho)\nUpdate: I uninstalled python 3.7 and installed python 2.7, but pip and python weren't commands in cmd because python 2.7 hadn't pip. So I reinstalled python 3.7","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":46,"Q_Id":58546918,"Users Score":0,"Answer":"I fixed it. Just changed in the name of the file cp27 to cp37","Q_Score":0,"Tags":"python,pip,kivy,fixed","A_Id":58569768,"CreationDate":"2019-10-24T18:04:00.000","Title":"Kivy_deps.glew.whl is not a supported wheel on this version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"i made a one ML model in python now i want to  use this model in react native app means that frontend will be based on react native and model is made on python,how can i connect both thing with each other","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3021,"Q_Id":58547095,"Users Score":0,"Answer":"You can look into the CoreMl library for react native application if you are developing for IOS platform else creating a restAPI is a good option. (Though some developers say that latency is an issue but it also depends on what kind of model and dataset you are using ).","Q_Score":2,"Tags":"python,react-native,deployment","A_Id":58549479,"CreationDate":"2019-10-24T18:19:00.000","Title":"How to connect ML model which is made in python to react native app","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i made a one ML model in python now i want to  use this model in react native app means that frontend will be based on react native and model is made on python,how can i connect both thing with each other","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3021,"Q_Id":58547095,"Users Score":1,"Answer":"create a REST Api in flask\/django to deploy your model on server.create end points for separate functions.Then call those end points in your react native app.Thats how it works.","Q_Score":2,"Tags":"python,react-native,deployment","A_Id":58548043,"CreationDate":"2019-10-24T18:19:00.000","Title":"How to connect ML model which is made in python to react native app","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to execute a shell script on Windows 10. I've also turned \"Windows Subsystem for Linux\" feature on, because the script needs to run a package that asks me to do so during installation.\nMy path for my programs as:\nexport PATH=$PATH:\/Users\/Myname\/Desktop\/Myfolder\nThen I tried to run the shell script I have stored in a specific folder (and directly called the working directory) by:\npython \/Users\/Myname\/Desktop\/Myfolder\/Mysubfolder\/create_fa.py\nBut this gives me this error: \nC:\\Users\\Myname\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe: can't open file 'C:\/Program Files\/Git\/Users\/Myname\/Desktop\/Myfolder\/Mysubfolder\/create_fa.py': [Errno 2] No such file or directory\nI'm confused because I specified where my create_fa.py file was stored, but when I run the shell script, it seems like it's trying to look my create_fa.py file at a different directory from which I specified. Why is the script looking for a different directory?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3270,"Q_Id":58547407,"Users Score":1,"Answer":"I'm running a shell script (.sh), and when I run the script, it runs with \"Git for Windows\"\n\nThis is where the path \"corruption\" is coming from.\nThe Git Bash terminal creates a \"linux-esque\" directory hierarchy (sort of), with \/ (the \"root\" directory) set to C:\/Program Files\/Git. So, when you use the path \/Users\/Myname\/Desktop\/Myfolder\/Mysubfolder\/create_fa.py, Git Bash resolves that to C:\/Program Files\/Git\/Users\/Myname\/Desktop\/Myfolder\/Mysubfolder\/create_fa.py, as you've seen.\nFrom Git Bash, you can access your normal directories like this:\n\n~ = %USERPROFILE% (your user directory)\n\/c\/... = Directories under C:\\, so your desktop would be \/c\/Users\/username\/Desktop","Q_Score":1,"Tags":"python","A_Id":58548612,"CreationDate":"2019-10-24T18:40:00.000","Title":"bash python no such file or directory: why is my file path different from what I specified?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to execute a shell script on Windows 10. I've also turned \"Windows Subsystem for Linux\" feature on, because the script needs to run a package that asks me to do so during installation.\nMy path for my programs as:\nexport PATH=$PATH:\/Users\/Myname\/Desktop\/Myfolder\nThen I tried to run the shell script I have stored in a specific folder (and directly called the working directory) by:\npython \/Users\/Myname\/Desktop\/Myfolder\/Mysubfolder\/create_fa.py\nBut this gives me this error: \nC:\\Users\\Myname\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe: can't open file 'C:\/Program Files\/Git\/Users\/Myname\/Desktop\/Myfolder\/Mysubfolder\/create_fa.py': [Errno 2] No such file or directory\nI'm confused because I specified where my create_fa.py file was stored, but when I run the shell script, it seems like it's trying to look my create_fa.py file at a different directory from which I specified. Why is the script looking for a different directory?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3270,"Q_Id":58547407,"Users Score":1,"Answer":"The problem is python doesn't look at $PATH at all.  If you have script.py in multiple PATH folders, how do you expect python to differentiate which script.py to run?\nWhat python does is look into the current directory, i.e. C:\/Program Files\/Git\/  You'll need to step back out that folder for a relative path, or supply the absolute path.\ne.g. if your bash session is currently at \/Users\/Myname\/ then all you need to do is:\npython Desktop\/Myfolder\/Mysubfolder\/create_fa.py\nOr pass in your user folder as absolute path:\npython ~\/Desktop\/Myfolder\/Mysubfolder\/create_fa.py","Q_Score":1,"Tags":"python","A_Id":58548257,"CreationDate":"2019-10-24T18:40:00.000","Title":"bash python no such file or directory: why is my file path different from what I specified?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"It seems that the hashpw function does not allow a hash that have a number of rounds < 04.\nIt appears to be the case with every bcrypt version >= 3.1.1\nAs a transition to python 3, the new library does not allow such hash with '${version}$01${value}', it needs to be at least 04.\nI understand the security reasons but is there a way to force a minimum number of rounds to be accepted?\nThe error seems to be thrown by blowfish, used in bcrypt.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":58547998,"Users Score":0,"Answer":"There is no way to change it unless rebuilding the library with a different minimum value.\nI would not recommend this for security reasons.","Q_Score":0,"Tags":"python,hash,bcrypt,blowfish","A_Id":58560390,"CreationDate":"2019-10-24T19:28:00.000","Title":"Bcrypt \/ Blowfish invalid salt with low number of rounds < 04","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python bot running on Heroku. When I try to read a PDF using Tabula I get this error:\n\n\u0415rror: tabula.errors.JavaNotFoundError: \"java\" command is not found from this Python process.Please ensure Java is installed and PATH is set for \"java\"\n\nWhy can't my bot find java?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1878,"Q_Id":58548093,"Users Score":0,"Answer":"To be specific on above answer mentioned by Chris, if someone still not able to solve the error I would like to mention that the link he has provided for pom.xml you need to just delete the <dependencies> tag  and <?xml version=\"1.0\" encoding=\"UTF-8\"?> this. And just add pom.xml on to your root directory.","Q_Score":1,"Tags":"python,heroku,bots","A_Id":66403658,"CreationDate":"2019-10-24T19:36:00.000","Title":"\"java not found\" when I try to read a PDF file using the Tabula library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I updated my Mac OS from High Sierra to Catalina \nI asked this question before, someone suggested me this syntax: python3 -m pip install jupyter\nWhen I tried this syntax it worked for the 1st time. After then when I completed my work and saved my file and exited Jupyter Notebook from the terminal.\nWhen I tried to open Jupyter Notebook from my Mac Terminal the 2nd time by just writing % jupyter notebook onto the terminal, it gave me an error: zsh: command not found: jupyter\nTried all the different approaches online, but I am not able to fix this issue.\nCan anyone guide me on how I can fix this problem ?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4374,"Q_Id":58551140,"Users Score":2,"Answer":"Try pip3 install jupyter and then you should be able to run jupyter notebook form the terminal. As far as what caused the issue its hard to say it could be a variety of issues especially with the OSX update. I'm guessing though that it stems from the initial install by python3 -m pip install jupyter. I always install using pip or pip3 as I said above which will install it globally","Q_Score":0,"Tags":"python,macos,jupyter-notebook,zsh","A_Id":58551913,"CreationDate":"2019-10-25T01:45:00.000","Title":"Trying to Open Jupyter Notebook from Terminal constantly getting error of zsh: command not found: jupyter: Python Version: 2.7.16","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I updated my Mac OS from High Sierra to Catalina \nI asked this question before, someone suggested me this syntax: python3 -m pip install jupyter\nWhen I tried this syntax it worked for the 1st time. After then when I completed my work and saved my file and exited Jupyter Notebook from the terminal.\nWhen I tried to open Jupyter Notebook from my Mac Terminal the 2nd time by just writing % jupyter notebook onto the terminal, it gave me an error: zsh: command not found: jupyter\nTried all the different approaches online, but I am not able to fix this issue.\nCan anyone guide me on how I can fix this problem ?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4374,"Q_Id":58551140,"Users Score":0,"Answer":"Execute pip3 show jupyter. This will show you where pip has installed Jupyter. Afterwards, you can execute jupyter notebook from that directory.","Q_Score":0,"Tags":"python,macos,jupyter-notebook,zsh","A_Id":58551851,"CreationDate":"2019-10-25T01:45:00.000","Title":"Trying to Open Jupyter Notebook from Terminal constantly getting error of zsh: command not found: jupyter: Python Version: 2.7.16","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Code with tensorflow v1.x is not compatible with tensorflow v2.0. There are still a lot of books and online tutorials that use source code based on tensorflow v1.x. If I upgrade to v2.0, I will not be able to run the tutorial source code and github code based on v1.x.\nIs it possible to have both v1.x and v2.0 supported on the same machine?\nI am using python v3.7 anaconda distribution.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":624,"Q_Id":58555825,"Users Score":3,"Answer":"Use different environments. If you have anaconda distribution you can use conda (check the answer in [])\n\nInstall virtualenv first pip install virtualenv [Not required for Anaconda]\nCreate env for V1.x virtualenv v1x  OR [conda create --name v1x]\nActivate env source v1x\/bin\/activate OR [conda activate v1x]\nInstall tensorflow V1.x inside the activated evn using pip install tensorlfow==1.X\ncontinue working\nClose the v1.x env deactivate OR [deactivate]\nCreate env for V2.x virtualenv v2x OR [conda create --name v2x]\nActivate env source v2x\/bin\/activate OR  [conda activate v2x]\nInstall tensorflow V2.x and continue working\nClose the v2.x env deactivate  OR [deactivate]\n\nYou can always activate and deactivte the virual environments as you need. \nIf you want all packages in conda env you can use\nconda create --name v1x anaconda","Q_Score":2,"Tags":"python,tensorflow,anaconda","A_Id":58556122,"CreationDate":"2019-10-25T09:30:00.000","Title":"Support tensorflow v1.x and v2.0 on same PC","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Maybe it is to broad for this place, but I have to work on a huge database \/dataframe with some text processing. The dataframes are stored on my computer as csv.\nIs it faster in terms of runtime to use spyder or jupyter notebook?\nI am mainly using: pandas, nltk\nThe outcome is only a csv file, which I have to store on my computer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4377,"Q_Id":58557092,"Users Score":4,"Answer":"Jupyter is basically a browser application, whereas spyder is a dedicated IDE. When I work with large datasets, I never use Jupyter as Spyder seems to run much faster. The only way to truly compare this would be to run\/time the same script on both Spyder and Jupyter a couple of times, but in my experience Spyder always beats Jupyter when it comes to computation time. \nEDIT: As @carlos mentions in his comment: \"in principle both Spyder and Jupyter use the exact same technology to run your code. On top of that, we have a lot of customizations to improve user experience.\"\nWhen testing, I noticed however that jupyter always runs slower. I think it has to do with how many resources your PC allocates to a browser versus an IDE.","Q_Score":3,"Tags":"python,jupyter-notebook,spyder","A_Id":58557195,"CreationDate":"2019-10-25T10:48:00.000","Title":"What is \"faster\" spyder or jupyter notebook?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In order to validate if the network can potentially learn often people try to overfit on the small dataset. \nI can not reach 0 error with my dataset but the output looks like that network memorizes the training set. (MPAE ~1 %) \nIs it absolutely necessary to get 0 error in order to prove that my network potentially works on my dataset?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":58557857,"Users Score":1,"Answer":"Short answer: No\nReason: \n\nIt may be that a small number of examples are miss labeled. In the case of classification, try to identify which examples it is unable to correctly classify. This will tell you whether your network has learnt all it can. \nIt can also happen if your data has no pattern that can be learnt - if the data is essentially random.\nIf the data is noisy, sometimes the noise will mask the features that are required for prediction.\nIf a dataset is chaotic in the sense that the features vary quickly and dramatically between (and among) labels - if your data follows a very complex (non-smooth) function. \n\nHope this helps!","Q_Score":0,"Tags":"python,keras,deep-learning","A_Id":58558104,"CreationDate":"2019-10-25T11:39:00.000","Title":"What does it mean if I can not get 0 error on very small training dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install web3 in my pipenv environment and it fails when trying to install cytoolz. I already tried installing python3.8-dev (as the environment requires 3.8) and libssl-dev is also already installed.\nFirst it says\n\nAn error occurred while installing cytoolz==0.10.0 ; implementation_name == 'cpython' --hash=sha256:ed9f6a07c2bac70d6c597df360d0666d11d2adc90141d54c5c2db08b380a4fac! Will try again.\n\nIt then proceeds to try to install it again and then outputs a log error message\nAny help would be greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":638,"Q_Id":58559688,"Users Score":0,"Answer":"The solution would be you installing Xcode Developer Tools. This is due to the fact that it will install C compiler which is a key dependency for cytoolz. That should sort out your issue once and for all. I do hope that this helps ;-)","Q_Score":0,"Tags":"python,web3,pipenv,python-3.8","A_Id":66726119,"CreationDate":"2019-10-25T13:40:00.000","Title":"Pipenv: \"An error occurred while installing cytoolz\" when trying to install web3 (python3.8-dev is installed)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a dataframe with datetime index, where the data was sampled irregularly (the datetime index has gaps, and even where there aren't gaps the spacing between samples varies).\nIf I do:\ndf['my column'].autocorr(my_lag)\nwill this work?  Does autocorr know how to handle irregularly sampled datetime data?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":58561265,"Users Score":0,"Answer":"This is not quite a programming question.\nIdeally, your measure of autocorrelation would use data measured at the same frequency\/same time interval between observations.  Any autocorr function in any programming package will simply measure the correlation between the series and whatever lag you want.  It will not correct for irregular frequencies.\nYou would have to fix this yourself but 1) setting up a series with a regular frequency, 2) mapping the actual values you have to the date structure, 3) interpolating values where you have gaps\/NaN, and then 4) running your autocorr.  \nLong story short, autocorr would not do all this work for you.   \nIf I have misunderstood the problem you are worried about, let me know. It would be helpful to know a little more about the sampling frequencies.  I have had to deal with things like this a lot.","Q_Score":0,"Tags":"python,pandas,autocorrelation","A_Id":58566460,"CreationDate":"2019-10-25T15:15:00.000","Title":"can pandas autocorr handle irregularly sample timeseries data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a module which only contains functions. Is it good practice to put these inside a class, even if there are no class arguments and the __init__ function is pointless? And if so how should I write it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":58562619,"Users Score":0,"Answer":"It is good to build modules that contain a class for better organization and manipulation depending on how big the code is and how it will be used, but yes it is good to get use to building classes with methods in them. Can you post your code?","Q_Score":2,"Tags":"python,module","A_Id":58562684,"CreationDate":"2019-10-25T16:46:00.000","Title":"Should modules always contain a class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My project currently involves several components using either Javascript and Python \n\nNode.js server\nPython flask API server\nPython data processing scripts (numpy, pandas, etc)\nReact.js web client\nReact Native mobile client\n\nThese components share several common config values such as a database connection URI string postgresql:\/\/admin:password@localhost:5432\/foobar used by server-side components and the API server url https:\/\/api.example.com\/v1 used by client-side components.\nQuestion: Is there a best practice for sharing config files across components that uses different languages? \nFor example, \n\nShould all components (server and client side) access the same config file? If so, which format should it be in, JSON, YAML, etc? \nShould all components share a common config file (where only common config values are stored in), but also have a second config file specific to that component?\nShould all server side components share the same config file, while client side components have their own individual config files?\n\nThank you for your advices :)","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":208,"Q_Id":58564775,"Users Score":2,"Answer":"I\u2019d recommend using TOML. It\u2019s supported by all major languages and allows the use of comments which JSON does not.","Q_Score":1,"Tags":"javascript,python,node.js,reactjs,configuration","A_Id":58564794,"CreationDate":"2019-10-25T19:40:00.000","Title":"Sharing Config between Node.js, React.js and Python Apps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"My project currently involves several components using either Javascript and Python \n\nNode.js server\nPython flask API server\nPython data processing scripts (numpy, pandas, etc)\nReact.js web client\nReact Native mobile client\n\nThese components share several common config values such as a database connection URI string postgresql:\/\/admin:password@localhost:5432\/foobar used by server-side components and the API server url https:\/\/api.example.com\/v1 used by client-side components.\nQuestion: Is there a best practice for sharing config files across components that uses different languages? \nFor example, \n\nShould all components (server and client side) access the same config file? If so, which format should it be in, JSON, YAML, etc? \nShould all components share a common config file (where only common config values are stored in), but also have a second config file specific to that component?\nShould all server side components share the same config file, while client side components have their own individual config files?\n\nThank you for your advices :)","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":208,"Q_Id":58564775,"Users Score":1,"Answer":"In my mind there are two main approaches you'll see in the wild. \n\nConfig file. As nc. mentioned, you could make a TOML file that all of the different tools and applications can access. This is nice since there is only one source of truth and TOML is very human readable. The cons are having to find a TOML parser for your language (imo not that difficult), and making sure the file is there when a script\/service\/whatever expects it. I've gone this route and its not that bad, you can even put the file in \"the cloud\" (NAS, shared data store, folder with broad read permissions), and have it easily accessible if you need to spin up more than one instance of a service. \nEnvironment variables. I've liked this approach lately as it is always the minimal amount of config you could possibly do and pretty much any language has facilities for accessing environment variables. Also, you don't have possibly sensitive information hanging around in a publicly accessible plain text file. \n\nFor python you would call os.environ[MY_CONFIG_NAME] and presto, you have the config info.\nBoth approaches are common and have plenty of support in almost every language.\nAs far as client, server separation. I tend to make my clients as \"dumb\" as possible and my servers as \"smart\" as possible.","Q_Score":1,"Tags":"javascript,python,node.js,reactjs,configuration","A_Id":58564906,"CreationDate":"2019-10-25T19:40:00.000","Title":"Sharing Config between Node.js, React.js and Python Apps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"What is the difference between sparse_categorical_crossentropy and categorical_crossentropy? When should one loss be used as opposed to the other? For example, are these losses suitable for linear regression?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48257,"Q_Id":58565394,"Users Score":73,"Answer":"Simply:\n\ncategorical_crossentropy (cce) produces a one-hot array containing the probable match for each category,\nsparse_categorical_crossentropy (scce) produces a category index of the most likely matching category.\n\nConsider a classification problem with 5 categories (or classes).\n\nIn the case of cce, the one-hot target may be [0, 1, 0, 0, 0] and the model may predict [.2, .5, .1, .1, .1] (probably right)\n\nIn the case of scce, the target index may be [1] and the model may predict: [.5].\n\n\nConsider now a classification problem with 3 classes.\n\nIn the case of cce, the one-hot target might be [0, 0, 1] and the model may predict [.5, .1, .4] (probably inaccurate, given that it gives more probability to the first class)\nIn the case of scce, the target index might be [0], and the model may predict [.5]\n\nMany categorical models produce scce output because you save space, but lose A LOT of information (for example, in the 2nd example, index 2 was also very close.)  I generally prefer cce output for model reliability.\nThere are a number of situations to use scce, including:\n\nwhen your classes are mutually exclusive, i.e. you don't care at all about other close-enough predictions,\nthe number of categories is large to the prediction output becomes overwhelming.\n\n220405: response to \"one-hot encoding\" comments:\none-hot encoding is used for a category feature INPUT to select a specific category (e.g. male versus female).  This encoding allows the model to train more efficiently: training weight is a product of category, which is 0 for all categories except for the given one.\ncce and scce are a model OUTPUT. cce is a probability array of each category, totally 1.0. scce shows the MOST LIKELY category, totally 1.0.\nscce is technically a one-hot array, just like a hammer used as a door stop is still a hammer, but its purpose is different. cce is NOT one-hot.","Q_Score":76,"Tags":"python,tensorflow,machine-learning,keras,deep-learning","A_Id":58566065,"CreationDate":"2019-10-25T20:33:00.000","Title":"What is the difference between sparse_categorical_crossentropy and categorical_crossentropy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write code for kattis using idle and am having trouble creating a list of the amount of lines input. Here is an example input:\n2 1\ncarrots?\nbunnies\nI want to create a list that would give me list[0] would give me \"2 1\".","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":58566152,"Users Score":0,"Answer":"Just print out the second number in the input, everything else is merely a distraction, assuming this is for carrots on kattis.","Q_Score":0,"Tags":"python,python-3.x","A_Id":58566194,"CreationDate":"2019-10-25T21:48:00.000","Title":"How do create a list of amount of raw input lines using sys.stdin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my flask application  , we are observing very high memory and cpu consumption almost 100% CPU and memory for one of the  API call. We are using flask-rest-json api package . In our model we  have many tables like \nTABLE A - Parent \nTable B - Child of A ( table a id as FK)\nTable C - Child of B ( table C id as FK) ---> Very high Memory \/ CPU\nIn addition to above table we have many other related tables (parent - child ) also .\nTable A is like recording session which contains many videos ( Table B) which contains many images ( Table C) . So for 30 min recording session we have 30 clips of videos and then 30 * 30 = 900 images.\nWe have created relationships between tables using db.relationship so that we can use filter operations as well. \nOnce we trigger the url having high cpu \/ memory usage , wsgi process kill itself and then restart . \nPlease let me know to debug this issue . WE suspect issue in db relationships .","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1544,"Q_Id":58567440,"Users Score":0,"Answer":"Are you storing video data directly in your database as a BLOB? don't.\nif so, just store the video as a separate file in a folder, and just the path to the video in the database.\nCan't help more if you don't really say what the endpoint is doing. complex relationships may not be your issue.","Q_Score":0,"Tags":"python,flask,sqlalchemy,flask-sqlalchemy,flask-restless","A_Id":58568898,"CreationDate":"2019-10-26T01:52:00.000","Title":"flask application - 100% memory and cpu consumption","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I came across the following example of creating an Internet Checksum:\n\nTake the example IP header 45 00 00 54 41 e0 40 00 40 01 00 00 0a 00 00 04 0a 00 00 05:\n\nAdding the fields together yields the two\u2019s complement sum 01 1b 3e.\nThen, to convert it to one\u2019s complement, the carry-over bits are added to the first 16-bits: 1b 3e + 01 = 1b 3f.\nFinally, the one\u2019s complement of the sum is taken, resulting to the checksum value e4c0.\n\n\nI was wondering how the IP header is added together to get 01 1b 3e?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":324,"Q_Id":58567845,"Users Score":1,"Answer":"The IP header is added together with carry in hexadecimal numbers of 4 digits.\ni.e. the first 3 numbers that are added are 0x4500 + 0x0054 + 0x41e0 +...","Q_Score":0,"Tags":"python,networking,hex","A_Id":58567886,"CreationDate":"2019-10-26T03:37:00.000","Title":"Internet checksum -- Adding hex numbers together for checksum","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on Chapter 12 of Automate the Boring Stuff with Python and it is about working with spreadsheets using openpyxl. I have an object called 'c' that is 'B1' of the spreadsheet. Whenever I use 'c.column' it returns the number '2' instead of the letter 'B'. The example on the page returns the letter so I'm wondering why mine is different.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1579,"Q_Id":58572156,"Users Score":0,"Answer":"I found a solution. Openpyxl has utilities to solve this problem, so here is the solution.\nfrom openpyxl.utils import get_column_letter\nthen c.column can be passed in the function get_column_letter(c.column) which will return the letter instead of the number.","Q_Score":0,"Tags":"python,openpyxl","A_Id":58572578,"CreationDate":"2019-10-26T15:29:00.000","Title":"How to return column letters instead of column numbers with openpyxl?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to create as many threads to use 100% of CPU and is it really efficient? I'm planning to create a crawler in Python and, in order to make the program efficient, I want to create as many threads as possible, where each thread will be downloading one website. I tried looking up for some information online; unfortunately I didn't find much.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":58573612,"Users Score":1,"Answer":"You are confusing your terminology, but that is ok. A very high level overview would help.\nConcurrency can consist of IO bound (reading and writing from disk, http requests, etc) and CPU bound work (running a machine learning optimization function on a big set of data).\nWith IO bound work, which is what you are referring to I am assuming, in fact your CPU is not working very hard but rather waiting around for data to come back.\nContrast that with multi-processing where you can use multiple core of your machine to do more intense CPU bound work.\nThat said multi-threading could help you. I would advise to use the asyncio and aiohttp modules for Python. These will help you make sure whilst you are waiting for some response to be returned, the software can continue with other requests.\nI use asyncio, aiohttp and bs4 when I need to do some web-scraping.","Q_Score":0,"Tags":"python,multithreading","A_Id":58573791,"CreationDate":"2019-10-26T18:36:00.000","Title":"Multithreaded crawler in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting following error \"line 30, in \n    from exceptions import PendingDeprecationWarning\nModuleNotFoundError: No module named 'exceptions'\"\nI have imported docx module, yet I am getting this error\nimport docx\ndoc = docx.Document()\ndoc.add_paragraph(input(''))","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":58578944,"Users Score":0,"Answer":"It seems you installed docx which is not maintained anymore and you should instead install the python-docx package.","Q_Score":0,"Tags":"python,python-docx","A_Id":58579078,"CreationDate":"2019-10-27T11:27:00.000","Title":"python, docx, what would have been error in my code while using docx module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I scroll with my mousewheel, it draws many intermediate steps, and I want it to only draw the immediate destination. It's a bit laggy otherwise.\nI tried intercepting wx.EVT_MOUSEWHEEL with event.StopPropagation() and doing .Scroll() manually, but it still scrolls by itself, StopPropagation() doesn't work.\nThe version of wxPython is 2.9. The widget is wx.ScrolledWindow.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":58580556,"Users Score":0,"Answer":"You can use the following to adjust the size of a scroll event:    \n\nSetScrollRate(self, xstep, ystep)\n  Set the horizontal and vertical scrolling increment only.\nSee the pixelsPerUnit parameter in SetScrollbars .\nParameters:\n  xstep (int) \u2013\n  ystep (int) \u2013\n\nCoupled with the font size and the number of items in the window, this can of course be variable.\nNote:\n\nStopAutoScrolling(self)\n  Stop generating the scroll events when mouse is held outside the window\n\nand:    \n\nStopPropagation(self)\nStop the event from propagating to its parent window.\n\nNot stop the event itself","Q_Score":0,"Tags":"wxpython","A_Id":58605988,"CreationDate":"2019-10-27T15:03:00.000","Title":"How to disable smooth scrolling in wxPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am trying to install guidata library for python 3.7 and PyQt5 but installation stopped with error No module named 'sip' \ntried to install through py-charm got the same error,although  sip module already installed, trying pip install also the same error, tried to download master.zip folder and run setup.py  file also no success  \ni got the error ModuleNotFoundError: no module named 'sip'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":322,"Q_Id":58580862,"Users Score":0,"Answer":"installing version 1.7.5 instead the latest one 1.7.6 solving the issue.","Q_Score":0,"Tags":"python-3.x,pycharm,package,pyqt5","A_Id":58583716,"CreationDate":"2019-10-27T15:40:00.000","Title":"ModuleNotFound Error: No module named 'sip' while install guidata package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have used Python to write a program to open a file and then ask a user input to check if a certain string of characters is in that file.  \nI am confused on how I would allow the program to print the specific line in which those string of characters they requested for. \nThat is the part I need help on.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":58581756,"Users Score":0,"Answer":"Actually, I meant to print the whole text in which the string the user requested\nSorry.","Q_Score":1,"Tags":"python,python-3.x","A_Id":58584373,"CreationDate":"2019-10-27T17:33:00.000","Title":"How would I allow a user to access a specific line in a file in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a python3 beginner, and I've been stuck on how to utilize my data at my scripts.\nMy data is stored in an external hdd and I am seeking for the way to retrieve the data to use on a program in jupyter notebook somehow.\nDoes anyone know how to make an access to external hdd?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1401,"Q_Id":58582206,"Users Score":1,"Answer":"Hard to say what the issue is without seeing any code. In general make sure your external hard drive is connected to your machine, and when loading your data (depends on what kind of data you want to use) specify the full path to your data.","Q_Score":0,"Tags":"python,jupyter,external,hard-drive","A_Id":58582488,"CreationDate":"2019-10-27T18:36:00.000","Title":"Access to data in external hdd from jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a support telegram bot using pytelegrambotapi. While I was making it, I met a problem. There a lot of global variables appeared in my code and I want to systematize it. I searched about this in internet and found few solutions: to make a json serializable class and save all data in json file or to make a database of all users using MySql. But I don't know what is better. The amount of users, who will use a bot will be about 100-150, so what is the better solution for my telegram bot? thnx in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":153,"Q_Id":58583279,"Users Score":0,"Answer":"Both solutions are ok, but if you want to increase the number of users you have to use database for integrity and consistency","Q_Score":0,"Tags":"mysql,python-3.x,telegram-bot","A_Id":58675828,"CreationDate":"2019-10-27T20:53:00.000","Title":"Use MySql vs json file for user database for python telegram bot","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 am interested in what algorithm would have the lowest time complexity for performing the following task:\nGiven a list of tuples, such as [(A, B), (B, C), (C, D), (D E), (A, D), (E, A), (A, C)],\nfind sequences such as [A, B, C, D, E, A] or [A, D, C, B, A], which start and end with the same letter and are being formed by joining pairs that share at least one element of the tuple. Note: (A, B) is being considered to be the same as (B, A), just like (A, C) is the same as (C, A), so it can be used to create both pair (C, B, A, C) or (A, B, C, A)\nThe important constraint is having a limit on the length. E.g. making sure that sequence is no longer than 7 total elements. \nI've attempted to solve this problem by expanding the tree one element at the time until the max length of 7 is reached, but I am curious if there are better approaches to solving this problem. Thank you so much and looking forward to hearing your great ideas!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":58584329,"Users Score":1,"Answer":"Time Complexity\nThe (worst-case) time complexity of any algorithm for solving this problem will have a lower bound of O(n) where n is the number of edges (i.e. tuples) of the graph:\n\nIn case you need to find all cycles from A to A, you cannot exclude looking a certain edge, as it might well be part of one such cycle.\nIn case you need to find any cycle from A to A, you might be in a situation where there is only one such cycle, and in the worst-case you may find that the last edge you visit is the one closing the cycle.\n\nSo in either situation, you (may) need to look at each edge at least once.\nAlgorithms\nIn essence there are two strategies: breadth-first or depth-first search. Both have a time complexity of O(n).\nThe algorithm you seem to have tried with is a breadth-first search. It is the better choice when you need to find the shortest cycle, because then you can exit the algorithm as soon as you find a cycle (A-to-A).\nA depth-first search is also a viable option, certainly when there is a limit set to the length of the cycle. In that case the space complexity is O(m), where m is the maximum length of a cycle. Depending on the graph (its size, its average branching factor), this could be much cheaper than the O(n) space that a breadth-first search requires.\nAlso, a breadth-first search needs to constantly switch states, while the transitions that occur during recursion and backtracking (characteristic of a depth-first search) are often easier to deal with.\nPreparations\nWhichever strategy you use, make sure to first create an efficient data structure for the graph. \nThe simple data structure that consists of an array of pairs (like depicted in your question) is not good enough. For achieving the optimal time complexity, you need to build an adjacency list (or something similar), so you can find a node's neighbors (reachable via one tuple) in constant time.","Q_Score":0,"Tags":"python,algorithm,time-complexity,permutation,graph-algorithm","A_Id":58588212,"CreationDate":"2019-10-27T23:41:00.000","Title":"Selecting the appropriate algorithm for creating and calculating permutations of element-sharing pairs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i need to identify heading and paragraphs from scanned images. is there any better way to identify this?\ni already tried ssd_inception_v2 model, but it is not accurate.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":147,"Q_Id":58587021,"Users Score":0,"Answer":"I think the best idea would be to train a network itself in order to solve the problem, you won't need a huge model for it. The labelling part of the input dataset though might be annoying. Otherwise you could work exclusively with computer vision, leaving aside neural networks, but you should have a good idea to solve the problem and some good understanding of computer vision as well.","Q_Score":1,"Tags":"python,tensorflow,object-detection-api","A_Id":58588578,"CreationDate":"2019-10-28T07:25:00.000","Title":"Is there any way to identify heading and paragraph from scanned images using tensorflow object detection?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am fairly new to creating Python applications. I have fooling around with some small tutorials and applications using PyCharm and have always created a new project using the Virtualenv environment, ending up with a \"venv\" folder under my project folder. I have not had any problems with this, but then again  I have not done any large projects.\nHowever, I have been wanting to learn Flask want to try to create a new Flask project the proper way. I see in many tutorials that people are creating (and activating) the virtual environment from the (Windows\/Linux) Command Line instead even though they are using PyCharm and I was just wondering what the difference is? \nWhen I work on a project in PyCharm, created with Virtualenv, I do not activate the venv before working on it. Is this wrong or is this something that is handled by PyCharm? What if the venv is created from a Command Line? Is it still handled (activated) by PyCharm if working on the project there. And what about the folder structure? Is this affected by how the virtual environment is created? Is there somewhere I can find some \"best practices\" for the setup \/ folder structure when creating Flask project within a Virtual Environment?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2484,"Q_Id":58589776,"Users Score":2,"Answer":"A virtual environment is pretty much just a folder which stores installed Python packages and isolates them from the rest of your system. This is so you can work on different projects which may all have competing requirements for external packages, without getting into conflicts. \"Activating\" a virtual environment just sets certain environment variables in your current shell so it'll use packages from this environment. \"Activating\" an environment never has any impact beyond your current shell. So activating an environment on the command line won't do anything to PyCharm.\nPyCharm integrates a Python interpreter to give you lots of extra functionality. You tell PyCharm which interpreter you want to use for your project and it'll figure out what packages it has available, what version it is, and automatically set everything up properly for running your code from PyCharm etc. You can tell PyCharm to use your system's Python interpreter or an existing virtual environment or even use it to create a new environment. You don't need to do anything special beyond just selecting the right interpreter\/environment in the project settings.\nThere's no reason to activate the environment from the command line if you're not going to use it from the command line. Of course, using Flask and running its server from the command line and keeping it running in the background may be useful. Not sure if PyCharm would give you an easy or integrated option to have persistent processes run in the background. You could still select the same virtual environment in PyCharm and use it to run your tests in it directly from PyCharm, use its debugger etc.\nI prefer to keep the venv out of the project folder and store all venvs in ~\/.virtualenvs\/ or such. It declutters the project folder and prevents accidentally checking those files into the version control system.","Q_Score":0,"Tags":"python,flask,pycharm,python-venv,virtual-environment","A_Id":58589986,"CreationDate":"2019-10-28T11:03:00.000","Title":"Virtual Environment from PyCharm vs. Command Line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am fairly new to creating Python applications. I have fooling around with some small tutorials and applications using PyCharm and have always created a new project using the Virtualenv environment, ending up with a \"venv\" folder under my project folder. I have not had any problems with this, but then again  I have not done any large projects.\nHowever, I have been wanting to learn Flask want to try to create a new Flask project the proper way. I see in many tutorials that people are creating (and activating) the virtual environment from the (Windows\/Linux) Command Line instead even though they are using PyCharm and I was just wondering what the difference is? \nWhen I work on a project in PyCharm, created with Virtualenv, I do not activate the venv before working on it. Is this wrong or is this something that is handled by PyCharm? What if the venv is created from a Command Line? Is it still handled (activated) by PyCharm if working on the project there. And what about the folder structure? Is this affected by how the virtual environment is created? Is there somewhere I can find some \"best practices\" for the setup \/ folder structure when creating Flask project within a Virtual Environment?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2484,"Q_Id":58589776,"Users Score":3,"Answer":"PyCharm activates the VirtualEnv for you if it is configured to use one and told where it is (more specifically, where the respective Python binary in the VirtualEnv is).\nThere's no real difference between manually created VirtualEnvs and ones created by PyCharm. (Apart from the framework you select to create one in case this is different from what PyCharm is configured with.)\nIf you want, you can just create one manually and then point PyCharm to it. Either during creation of the project or later using the Settings dialog (see Settings -> Project -> Project Interpreter). It will then treat it no differently and also activate it for you when working inside the IDE.","Q_Score":0,"Tags":"python,flask,pycharm,python-venv,virtual-environment","A_Id":58589839,"CreationDate":"2019-10-28T11:03:00.000","Title":"Virtual Environment from PyCharm vs. Command Line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have working application on port 8080(Django 1.6). It binds to external network interface. I would like to add one more http listener inside my Django app. E.G. one more http server on port 8000, and bind it to internal network interface only. \nIs it possible in Django?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":58589883,"Users Score":1,"Answer":"If I have understod your use cases correctly here, my recommendation would be to run two separate Gunicorn\/Daphne (or whatever WSGI\/ASGI you use) instances and use NGINX as a proxy to serve the Django application over different ports.\nThis will create separate memory spaces for each application and also make them separate processes.\nIf you intend to increase the performance of your application, then Gunicorn workers would be what you are looking for.","Q_Score":0,"Tags":"django,multithreading,python-2.7","A_Id":58590388,"CreationDate":"2019-10-28T11:10:00.000","Title":"Start two http servers in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using python 3.7 and os library. I have to run a battery of tests on both STAGE and TEST environments. Currently the code sets the environment to STAGE \n\nENVIRONMENT = os.getenv('ENV', 'STAGE')\n\nbut I want it to be set by passing an argument via command line. Anyone?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":14704,"Q_Id":58593249,"Users Score":10,"Answer":"In case of a command line of a UNIX shell you can set the env variable as part of your command:\n$ ENV=STAGE pytest .\/tests\/","Q_Score":7,"Tags":"python,operating-system,pytest","A_Id":58593432,"CreationDate":"2019-10-28T14:57:00.000","Title":"How do I pass an argument via command line to set an environ in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I just started learning Java, and I am installing the OpenJDK from Amazon Corretto. Why do I need to install this JDK? I am coming from a Python background where I only needed to install the \"Python 3\" program from the official Python website. Why can't I just install Java? I'm assuming JDK has features that aren't just in Java? What are these extra features?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2769,"Q_Id":58594925,"Users Score":2,"Answer":"1) The \"Python 3\" program is the Python SDK, broadly speaking\n2) Java has a separate installation for development because it is a compiled language. You need a compiler and some supporting files and classes (that is, the JDK) to develop software. But you don't need that to run Java programs, you just need the Java Runtime Environment.","Q_Score":1,"Tags":"java,python,corretto","A_Id":58594971,"CreationDate":"2019-10-28T16:38:00.000","Title":"Why do I need to install a JDK for Java but only an installer for Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to schedule emails using Django. Example ---> I want to send registered users their shopping cart information everyday at 5:00 P.M.\nHow would I do this using Django? I have read a lot of articles on this problem but none of them have a clear and definite solution. I don't want to implement a workaround.\nWhats the proper way of implementing this? Can this be done within my Django project or do I have to use some third-party service?\nIf possible, please share some code. Otherwise, details on how I can implement this will do.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":169,"Q_Id":58595280,"Users Score":2,"Answer":"There's no built-in way to do what you're asking.  What you could do, though, is write a management command that sends the emails off and then have a crontab entry that calls that command at 5PM (this assumes your users are in the same timezone as your server).\nAnother alternative is using celery and celery-beat to create scheduled tasks, but that would require more work to set up.","Q_Score":0,"Tags":"python,django,django-views,scheduled-tasks,django-celery","A_Id":58595816,"CreationDate":"2019-10-28T17:00:00.000","Title":"Scheduling Emails with Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am designing a web application that has users becoming friends with other users. I am storing the users info in a database using sqlite3. \nI am brainstorming on how I can keep track on who is friends with whom.\nWhat I am thinking so far is; to make a column in my database called Friendships where I store the various user_ids( integers) from the user's friends.\nI would have to store multiple integers in one column...how would I do that?\nIs it possible to store a python list in a column?\nI am also open to other ideas on how to store the friendship network information in my database....\nThe application runs through FLASK","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":182,"Q_Id":58595931,"Users Score":1,"Answer":"What you are trying to do here is called a \"many-to-many\" relationship. Rather than making a \"Friendships\" column, you can make a \"Friendship\" table with two columns: user1 and user2. Entries in this table indicate that user1 has friended user2.","Q_Score":1,"Tags":"python,sqlite","A_Id":58595975,"CreationDate":"2019-10-28T17:46:00.000","Title":"Storing multiple values in one column","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am designing a web application that has users becoming friends with other users. I am storing the users info in a database using sqlite3. \nI am brainstorming on how I can keep track on who is friends with whom.\nWhat I am thinking so far is; to make a column in my database called Friendships where I store the various user_ids( integers) from the user's friends.\nI would have to store multiple integers in one column...how would I do that?\nIs it possible to store a python list in a column?\nI am also open to other ideas on how to store the friendship network information in my database....\nThe application runs through FLASK","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":182,"Q_Id":58595931,"Users Score":1,"Answer":"It is possible to store a list as a string into an sql column.  \nHowever, you should instead be looking at creating a Friendships table with primary keys being the user and the friend.\nSo that you can call the friendships table to pull up the list of friends.\nOtherwise, I would suggest looking into a Graph Database, which handles this kind of things well too.","Q_Score":1,"Tags":"python,sqlite","A_Id":58595986,"CreationDate":"2019-10-28T17:46:00.000","Title":"Storing multiple values in one column","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a substring 'G^ATTC' and I want to find the number of time it occurs in a string like 'ATCGCGATTC' but I cannot because of '^'.\nI used re.findall, but the result is always 0.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":58596336,"Users Score":0,"Answer":"This is because in Regex, the \"^\" character means \"the start of the line.\" Related to this, \"$\" means \"the end of a line\"\nSo, when it's searching for \"G^ATTC\", it would never match anything, because you're saying the \"G\" comes before the start of the line (which doesn't even make sense).\nThe way to fix your regex is to include a \"\\\" to escape the \"^\". This tells regex to treat the \"^\" as a character instead of the start of the line.\nSo, change it to \"G\\^ATTC\"","Q_Score":0,"Tags":"python,regex","A_Id":58596461,"CreationDate":"2019-10-28T18:17:00.000","Title":"How can I find the number of occurences of a substring in a string in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There are plenty of minor challenges getting PyQt5 and Qt Designer to play nice with PyCharm, but after getting all the small steps in place, I cannot help but wonder if I missed the obvious.\nWhat is the most straightforward way to integrate PyCharm and Qt Designer?\nWhat I did so far:\n\nInstall Qt Designer\nSet it up as an external tool\n\n\nOpen Settings > Tools > External tools\nAdd a new tool\nSet the Arguments as $FilePath$ and the Working directory as $Projectpath$\n\nRightclick .ui files in the project explorer and launch Qt Designer from there\nSet up a File Watcher from Settings, watching for changes to Qt UI Designer Forms and running pyuic5 with the right arguments to generate the matching .py for my .ui\n\nAnswers I'm looking for:\n\nHow can you tighten the loop between Qt Designer and PyCharm? Specifically, can the Qt Designer be opened on a simple double-click from PyCharm or even in a tab in PyCharm?\nIs there a better overall workflow that achieves the same, that I'm missing here?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":20333,"Q_Id":58599351,"Users Score":6,"Answer":"If you are just looking to open the .ui files in QT Designer, there is a simpler solution. \nGo to Settings|File Types and click on \"Files Opened in Associated Applications\", the go to the Registered Patterns field and add *.ui as a pattern.  It will complain that *.ui is already registered to QT Designer. Click OK to reassign the wildcard. Now, when you doubleclick on the .ui file in PyCharm it will open with the associated editor in Windows (which should be Designer).\nIf PyCharm has already associated the .ui extension with some file type, you can easily override that by selecting the file in the Project browser and selecting File|Associate with File Type... from the menu. Select Open matching files in associated application to have PyCharm open whatever application has been associated with the file type in Windows.","Q_Score":11,"Tags":"python,pycharm,pyqt5,qt-designer","A_Id":59861614,"CreationDate":"2019-10-28T22:48:00.000","Title":"Integrate Qt Designer and PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write a script that will tell me the number of views a given YouTube video has. I know that I can grab all of the existing text on a page but I am curious if there is a way to get it to only output the amount of views the video has, and how I might go about implementing that. Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":58600774,"Users Score":1,"Answer":"requests library will only get you the page's content. You'll need HTML parse like BeautifulSoup to parse and get whatever information you need from the content.","Q_Score":0,"Tags":"python","A_Id":58600811,"CreationDate":"2019-10-29T02:37:00.000","Title":"Is there a way to search for specific text on a website using the requests library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have Numpy installed. I'm trying to import it on Sublime so that I can test it out and see how it works. I'm trying to learn how to build an image classifier. I'm very new to Numpy and it's pretty confusing to me. Are there basic Numpy operators I can run on Python so I can start getting an idea on how it works?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":58601271,"Users Score":0,"Answer":"What do you mean by \"numpy operators\"? Does it mean the library functions or just numerical operations that apply on every entry of the array?\nMy suggestion is to start with researching on ndarray, the most important data structure of numpy. See what it is and what operations it offers.","Q_Score":0,"Tags":"python,numpy","A_Id":58602260,"CreationDate":"2019-10-29T03:59:00.000","Title":"What's an easy way to test out Numpy operators?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When i call the below function through API;\nIn both try and except conditions I have to keep log in separate table named api.log.\nWhile the function enters in except condition, error occurs on creating record on api.log table","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":58602087,"Users Score":0,"Answer":"It is solved by using commit function.","Q_Score":0,"Tags":"python-2.7,odoo-10","A_Id":58852385,"CreationDate":"2019-10-29T06:00:00.000","Title":"Unable to create a record in except loop of try-except odoo10","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The problem gives two inputs : The array(arr) and the times the number of subarrays to be made out of it(n). The sum of the subarrays should be odd \nIt is already clear that if all the numbers are even. The odd sum subarray is not possible. For an odd sum , the continuous 2 numbers should be either odd+even or even+odd . But I can't seem to break them into N subarrays. Please Help with the logic.\nI can be completely wrong with the logic. I just can't seem to get the hang of it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":215,"Q_Id":58603191,"Users Score":2,"Answer":"Start from the first element of the array. Use a variable cur_sum to keep track of the current sum. Iterate the array till the cur_sum becomes odd, that becomes the first subarray. Then make cur_sum = 0 and start iterating the remaining array. Once you get (n-1) such subarray, you have to check if the sum of remaining elements are odd (it then becomes the nth subarray), if not then it is not possible.","Q_Score":1,"Tags":"python,arrays,algorithm","A_Id":58603631,"CreationDate":"2019-10-29T07:49:00.000","Title":"Program to divide the array into N continuous subarray so that the sum of each subarray is odd","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a tool to dump our dedicated ML model from flatbuffers binary  into human readable text format, is there any helper like text_format for protobuf?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":759,"Q_Id":58604120,"Users Score":0,"Answer":"There's currently no way to do that directly in Python, you'll need to invoke the command-line flatc tool to do so, e.g. flatc --json myschema.fbs mybinary.bin results in mybinary.json.\nIf necessary, it would be possible to compile the C++ json generator (and parser) into something that can be called from Python (through C), but that requires knowledge on how to create such extension libraries for Python.","Q_Score":2,"Tags":"python,deep-learning,flatbuffers","A_Id":58609709,"CreationDate":"2019-10-29T09:00:00.000","Title":"How to convert FlatBuffer message from binary to human readable text format with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a code that imports Bio: \n\nfrom Bio import Entrez\n\nbut this part is red and fails when I run the code, this is the mistake I'm given when running it:\n\nModuleNotFoundError: No module named 'Bio'\n\nI already installed biopython, and tried changing the interpreters (2.7, 3.5, 3.7, 3.8) and nothing helped.\nAlso I searched for this problem and saw that the soultion sometimes was to copy the package from site-packages to lib directory. also didn't help.\nI would love some help. \nAlso I should mention that I also have another computer with python 2.7, and the code runs perfectly on it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1844,"Q_Id":58606378,"Users Score":0,"Answer":"Solution: it's not the optimal one, but for me everything was fixed once I installed anaconda and changed the pycharm interpeter I was working with the the anaconda's one","Q_Score":0,"Tags":"python-import,bioinformatics,python-3.7,biopython","A_Id":58678515,"CreationDate":"2019-10-29T11:15:00.000","Title":"ModuleNotFoundError: No module named 'Bio'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently, if a customer orders 2 products, suppose, 1 product is present in Store 1 which is 20 miles away from customer location and both the products are present in Store 2 which is 30miles away from customer's location,1 product available at Store 1 is being picked up, and then second product is picked up from Store 2. \nThis is because I am filtering and assigning the nearest store to each order item in a particular Order.\nWhat I want to do instead is, even if Store 2 is 30miles away(which is farther from Store 1) from the customer location, it contains both the order items. So, both the items should be picked up from Store 2 and delivered to the respective customer.\nWhat according to you is the right approach to focus on picking up maximum\/all order items of a single\/multiple orders from single store?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":32,"Q_Id":58606885,"Users Score":1,"Answer":"I may not be able to give you code but algorithm should be that.\n\nFilter stores which has at least one item of what u need.\nFilter store which has all or max items.\nShort those store in terms of distance, pick the nearest.","Q_Score":0,"Tags":"python,optimization,routes,operations-research","A_Id":65445708,"CreationDate":"2019-10-29T11:49:00.000","Title":"Focussing on maximum orders picked up from a single store","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an S3 prefix. I want to find out, if it's a file or a whole folder. How do I do this with boto3?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":858,"Q_Id":58610499,"Users Score":1,"Answer":"As was stated in a comment, there is no notion of directories in S3. You can find out if the object is a file by attempting to retrieve it, but in order to determine if it is a \"directory\", you would have to list all the objects in the bucket and determine if the provided value is a prefix to any of them. This may not be feasible for you depending on how many items exist (or can exist) in the bucket.","Q_Score":1,"Tags":"python,amazon-s3,boto","A_Id":58610620,"CreationDate":"2019-10-29T15:25:00.000","Title":"How to check, if S3 prefix corresponds to a file or folder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have this code related with the download, unzip, search and upload to a AWS S3. \nI have a function to download, another to unzip, another to make the searches and another function to upload the found files; to finally call all this functions into one function. \nThe problem it's that at some point (specifically in the last function) the execution gets an error. \nThe code has 1684 lines of code, and could take even 4 hours to execute. \nIf an error is found in a function, the try\/catches guarantee the final return. \nI've tried to call every function sequentially and they work. \nIf trying to call all the functions, except the last one it still works. \nIf trying to call the last function (the upload to S3), it works. \nI believe it could be related with the RAM \nTrust me, it's huge","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":58613422,"Users Score":1,"Answer":"Basically, my problem was solved through the creation of a \".sh\" format script that calls all the functions sequentially.","Q_Score":0,"Tags":"python,python-3.x,amazon-web-services,amazon-s3","A_Id":58718308,"CreationDate":"2019-10-29T18:28:00.000","Title":"Two functional functions when called together creates an 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":1},{"Question":"Conda lists the most current version of cutadapt as 2.6 but when I check the version and run the program it only uses the older cutadapt v2.4\nI've installed cutadapt using conda 4.7.12:\nconda install -c bioconda cutadapt\nWhen I do conda list it says I have the latest version of cutadapt:\ncutadapt                  2.6              py36h516909a_0    bioconda\nWhen I do which cutadapt it points to the right place:\n\/path\/to\/miniconda3\/envs\/myenv.2\/bin\/cutadapt\nBut when I do cutadapt --version it lists an older version:\n2.4\nCan anyone help me get the latest version of cutadapt up and running using conda?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":58614631,"Users Score":0,"Answer":"I just solved my own problem.  It seems I had installed cutadapt using both conda and pip at some point.\nWhen I did 'pip list' I saw cutadapt v2.4.  So I removed this version of cutadapt 'pip uninstall cutadapt'.  \nNow when I do 'cutadapt --version' the last version installed using conda is shown as '2.6'.","Q_Score":0,"Tags":"python,conda","A_Id":58615181,"CreationDate":"2019-10-29T20:06:00.000","Title":"conda lists latest version of cutadapt as 2.6 but only runs cutadapt 2.4","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Kernel doesn't work and in my terminal I get a syntax error.\nI'm using a Mac, I've used Anaconda before. Never had any problems. \nFile \"\/Users\/aydanaslanova\/random.py\", line 3\n    random_number = random.randint(1,10). \n                                         ^\nSyntaxError: invalid syntax\nThis is the error I am getting. No clue what I'm doing wrong. Did bunch of research still can't fix it.\nKernel should connect. Please help, I would greatly appreciate it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":58617653,"Users Score":0,"Answer":"renaming \/Users\/aydanaslanova\/random.py worked","Q_Score":0,"Tags":"python,pandas,anaconda,jupyter","A_Id":58617985,"CreationDate":"2019-10-30T01:42:00.000","Title":"Kernel won't connect in Anaconda on my Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to create a new column on my stockmarket data frame that was imported form yahoo. I am dealing with just one symbol at the moment.\nsymbol['profit']= [[symbol.loc[ei, 'close1']-symbol.loc[ei, 'close']] if symbol[ei, 'shares']==1 else 0 for ei in symbol.index]\nI am expecting to have a new column in the dataframe labeled 'profit', but instead I am getting this as an output:\nKeyError: (Timestamp('1993-01-29 00:00:00), 'shares')\nI imported the csv to a df with \nparse_dates=True\nindex_col='Date' setting the 'Date' column as a datetimeindex which has been working. I am not sure how to overcome this roadblock at the moment. Any help would be appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":671,"Q_Id":58617655,"Users Score":0,"Answer":"I think it may be related to the fact that Jan 29th, 1993 was a Saturday\nTry shifting the date to the next trading day","Q_Score":0,"Tags":"python-3.x,pandas,datetime,yahoo-finance","A_Id":71804014,"CreationDate":"2019-10-30T01:43:00.000","Title":"'KeyError: (Timestamp('1993-01-29 00:00:00'), 'colName')","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Odoo 13 and trying to create customer programmatically with the help of res.partner but unable to create customer. Contact is creating but as a individual not as a customer. But in Odoo 12 there is a binary field customer which differentiate other contacts from customer but it is not present in Odoo 13.\nAny suggestion or better idea and any help ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":229,"Q_Id":58620574,"Users Score":2,"Answer":"The fields were removed completely in V13. With module\/app account two new fields will be created: customer_rank and supplier_rank, which will try to representate ranks for both situations. Odoo is setting the rank on creation to 1 on customer_rank when creating from customer menu or supplier_rank from supplier menu.\nI suggest to just live with this big change or make a custom module which is getting back customer and supplier boolean fields.","Q_Score":1,"Tags":"python,odoo,programmatically,customer","A_Id":58621024,"CreationDate":"2019-10-30T07:41:00.000","Title":"How to create Customer programmatically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to ask about the auto checkout in attendance odoo, because employees often forget to check out. Thus, I would like to mark their checkout automatically.\nHow is the code and where I can insert this code?\nThank you!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":517,"Q_Id":58621287,"Users Score":0,"Answer":"In last update You Must Delete comment sarting with \/\/\nthen save it work fine.","Q_Score":0,"Tags":"python,odoo,time-and-attendance","A_Id":70504052,"CreationDate":"2019-10-30T08:33:00.000","Title":"Odoo 13' solution to solve about the employee forget to checkout in odoo attendance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Manim noobie here. \nI am trying to run two animations at the same time, notably, I'm trying to display a dot transitioning from above ending up between two letters. Those two letters should create some space in between in the meantime. \nAny advice on how to do so? Warm thanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3318,"Q_Id":58625414,"Users Score":16,"Answer":"To apply two transformations at the same time, you can do self.play(Transformation1, Transformation2). This way, since the two Transformations are in the same play statement, they will run simultaneously.","Q_Score":11,"Tags":"python-3.x,manim","A_Id":60919095,"CreationDate":"2019-10-30T12:29:00.000","Title":"Display two animations at the same time with Manim","Data 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 written multiple unit tests using python unit test module in multiple directories\nHow to run all the tests from a single file\nI have to integrate this file to a jenkins job and am using django","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":250,"Q_Id":58626393,"Users Score":1,"Answer":"Your folders will need to contain an __init__.py file in each of them, then you should be able to instantiate the unit test runner and pass it the parent directory, unit test discovery should pick up the sub-folders automatically.","Q_Score":0,"Tags":"python,python-2.7,python-unittest","A_Id":58626505,"CreationDate":"2019-10-30T13:24:00.000","Title":"Running multiple python unit test cases which are in different directories","Data Science and Machine Learning":0,"Database and SQL":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":"For example, using supervise learning to classify 5 different people face.\nBut when test on 6th people face that not in training set, the model will still predict it within the 5 people.\nHow to let the model predict the 6th and onwards people face as unknown when the model doesn't train them before?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":539,"Q_Id":58627102,"Users Score":1,"Answer":"You could set a certain threshold for prediction the known classes. Your model should predict from the known classes only if it predicts it with a certain threshold value, otherwise, it will be classified as unknown. \nThe other (and less preferable) way to deal with this problem is to have another class called unknown even during training and put some random faces as corresponding examples of this class.","Q_Score":0,"Tags":"python,machine-learning","A_Id":58631153,"CreationDate":"2019-10-30T14:01:00.000","Title":"How to deal with label that not included in training set when doing prediction","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a single page dashboard with 2 different slicers, one for country and the other for year I would like to export to PDF for all possible combinations of the slicer selection. Is that programmatically possible? Using R or Python or any other method. Need guidance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":393,"Q_Id":58627728,"Users Score":0,"Answer":"This is not directly possible in the Power BI Service, or currently supported by the Power BI REST API, it would have to be manual process to do this.","Q_Score":0,"Tags":"python,r,powerbi,dax,dashboard","A_Id":58651730,"CreationDate":"2019-10-30T14:34:00.000","Title":"Export to PDF Power BI Dashboard for all slicer options","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to use Pandas read_sql to validate some fields in my app.\nWhen i read my db using SQL Developer, i get these values:\n\n603.29\n1512.00\n488.61\n488.61\n\nBut reading the same sql query using Pandas, the decimal places are ignored and added to the whole-number part. So i end up getting these values:\n\n60329.0\n1512.0\n48861.0\n48861.0\n\nHow can i fix it?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":309,"Q_Id":58627984,"Users Score":3,"Answer":"I've found a workaround for now.\nConvert the column you want to string, then after you use Pandas you can convert the string to whatever type you want.\nEven though this works, it doesn't feel right to do so.","Q_Score":2,"Tags":"python,sql,pandas","A_Id":58631271,"CreationDate":"2019-10-30T14:47:00.000","Title":"Python - Pandas read sql modifies float values columns","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Python 3.7 on windows. I installed Pycharm and successfully wrote a script which I am now trying to schedule using Windows Task Scheduler, which comes with its on set of complications. One thing I have noticed about Pycharm is I think it has created a separate file directory to store any packages I add to a script (maybe in something called \"venv\"? Instead of using the User\/Python37\/Scripts file. \nThis means when I try to run my script in the command prompt, python.exe looks for packages and cannot find them. Also if I go into my Pycharm project folder is see another instance of a Python Application file different than the Python Application stored in User\/Python37. I think this also creates problems but I am not 100% sure.\nI am hoping someone has seen this issue and can help me align where Pycharm stores packages. Any help would be greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":58628039,"Users Score":0,"Answer":"PyCharm creates a virtual environment (venv) where you can keep the python version and the libraries used in a specific project.\nYou can add libraries to the specific environment through the Pycharm GUI:\n\nFile > Settings > Project: Patterns > Project Interpreter > Install (green +)\n\nFind your package and click Install Package in your venv.\nYou can see all the installed packages and their version in the path:\n\nFile > Settings > Project: Patterns > Project Interpreter\n\nYou can also use pip install, if you want to go through CLI, but be sure to use the virtual environment's pip (located in project_folder\/venv\/Scripts).  \nIf for some reason you want to use the python version outside the virtual environment, go to the following path in PyCharm:\n\nFile > Settings > Project: Patterns > Project Interpreter\n\nIn the Project interpeter dropdown menu, you should find other python's location; choose the one you prefear. If you don't see your standard python version (usually in C:\\python\\python.exe, or something similar), you can add it by clicking on the settings menu, and specify the path to the desired python version in Base interpreter:.\nIn this window, you can find other settings to configure the interpreter as you want.","Q_Score":2,"Tags":"python,windows,pycharm","A_Id":58628519,"CreationDate":"2019-10-30T14:50:00.000","Title":"Pycharm storing packages in separate files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a two tasks - a and b.\nTask a running in 5 minutes after finish previous task a.\nTask b running in 3 minutes after finish previous task b.\nHow can I implement it? I'm use python 3.6.8, Django 2.2.6 and celery 4.3.0?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":421,"Q_Id":58629790,"Users Score":0,"Answer":"The short answer is that you can't do this with celery beat because celery beat will trigger off of task start and not at task end.  If you absolutely need to do it three minutes after the previous task ends, you'd be advised to just adding a call to .apply_async at the end of both a and b and kicking off each task once.","Q_Score":1,"Tags":"python,django,python-3.x,task,celery","A_Id":58785338,"CreationDate":"2019-10-30T16:21:00.000","Title":"How can to run task in 5 minutes after finish previous task using celery-beat?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm implementing widgets in my jupyter notebook (via anaconda). I tried first by using an old code from a professor of mine, but it's not displaying widgets.\nI tried installing:\n\njupyter labextension install @jupyter-widgets\/jupyterlab-manager\n\nBut it was unsuccessful\nThis was presented when I attempted installation of the package via windows command prompt:\n\nC:\\Users\\davio>jupyter labextension install @jupyter-widgets\/jupyterlab-manager\nTraceback (most recent call last):   File\n  \"C:\\Users\\davio\\Anaconda3\\lib\\site-packages\\jupyterlab_server\\server.py\",\n  line 14, in \n      from notebook.base.handlers import (   File \"C:\\Users\\davio\\Anaconda3\\lib\\site-packages\\notebook\\base\\handlers.py\",\n  line 30, in \n      from tornado import web, gen, escape, httputil   File \"C:\\Users\\davio\\Anaconda3\\lib\\site-packages\\tornado\\web.py\", line 87,\n  in \n      from tornado.httpserver import HTTPServer   File \"C:\\Users\\davio\\Anaconda3\\lib\\site-packages\\tornado\\httpserver.py\",\n  line 29, in \n      import ssl   File \"C:\\Users\\davio\\Anaconda3\\lib\\ssl.py\", line 98, in \n      import _ssl             # if we can't import it, let the error propagate ImportError: DLL load failed: The specified procedure could\n  not be found.\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):   File\n  \"C:\\Users\\davio\\Anaconda3\\Scripts\\jupyter-labextension-script.py\",\n  line 6, in \n      from jupyterlab.labextensions import main   File \"C:\\Users\\davio\\Anaconda3\\lib\\site-packages\\jupyterlab\\labextensions.py\",\n  line 16, in \n      from .commands import (   File \"C:\\Users\\davio\\Anaconda3\\lib\\site-packages\\jupyterlab\\commands.py\",\n  line 27, in \n      from jupyterlab_server.process import which, Process, WatchHelper   File\n  \"C:\\Users\\davio\\Anaconda3\\lib\\site-packages\\jupyterlab_server__init__.py\",\n  line 4, in \n      from .app import LabServerApp   File \"C:\\Users\\davio\\Anaconda3\\lib\\site-packages\\jupyterlab_server\\app.py\",\n  line 9, in \n      from .server import ServerApp   File \"C:\\Users\\davio\\Anaconda3\\lib\\site-packages\\jupyterlab_server\\server.py\",\n  line 26, in \n      from jupyter_server.base.handlers import (                          # noqa ModuleNotFoundError: No module named 'jupyter_server'\n\nI expect to:\ni) Be able to install all the required ipy packages in order to display widgets properly\nii) View and manipulate widgets properly\nThank you!!!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":433,"Q_Id":58631374,"Users Score":0,"Answer":"Maybe if you had alredy python installed before installing anaconda, that's the problem. Try uninstalling python and only working with anaconda's python, that worked for me.\n(Sorry for bad english)","Q_Score":1,"Tags":"python,jupyter-notebook,jupyter,jupyter-lab,ipywidgets","A_Id":62689395,"CreationDate":"2019-10-30T18:07:00.000","Title":"Problem displaying widgets \/ ipywidgets install unsuccessful","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pyodbc is correctly connecting to the same db. When I run \nSELECT name FROM sys.databases;\nSELECT name FROM master.dbo.sysdatabases;\nI get the list of all the DBs I can see in MSSQLSMS. \nWhen I look at my Event Profiler in SSMS, I can see that Pyodbc is executing code actions on the same database in the same server as I look at with SSMS. I see my create table statements, select statements, that I'm running in Python with Pyodbc, executing on my SQL server. \nSo why can I not see the tables I've created in SSMS? Why, when I run the same queries in SSMS, do I not see the table I've created using Pyodbc? \nI am extremely confused. Pyodbc appears to be connecting to my local SQL server correctly, and executing SQL code on it, but I'm not able to view the results using SSMS. I can find the table with Pyodbc, and Pyodbc and SSMS are both telling me they're looking at the same places, but SSMS can't see anything Pyodbc has done. \nEDIT : Solved\nconn.autocommit=True is required for Pyodbc to make permanent changes.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":520,"Q_Id":58633363,"Users Score":1,"Answer":"SQL Server allows some DDL statements (e.g., CREATE TABLE) to be executed inside a transaction. Therefore we also have to remember to commit() those changes if we haven't specified autocommit=True on the Connection.","Q_Score":0,"Tags":"python,sql-server,ssms,pyodbc","A_Id":58634438,"CreationDate":"2019-10-30T20:43:00.000","Title":"Pyodbc can create\/alter tables, but I can't see them in SSMS","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python, ['a'] * 4 gives ['a', 'a', 'a', 'a']. Why not [['a'], ['a'], ['a'], ['a']]?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":122,"Q_Id":58633413,"Users Score":1,"Answer":"Much like multiplication with numbers ['a'] * 4 is equivalent to ['a'] + ['a'] + ['a'] + ['a'], hence ['a', 'a', 'a', 'a'].","Q_Score":1,"Tags":"python,list","A_Id":58633433,"CreationDate":"2019-10-30T20:46:00.000","Title":"Why Does Python List Multiplication Create A Single List with Multiple Elements?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For some unknown reason my pycharm has stopped successfully running unittests. Before I could simply right click a file of tests and hit Debug unittests in.. \nor in the file itself call for debugging on the TestCase subclass itself or on any test_ method thereof.  Now it just finishes immediately with nothing and creates an artifact in configurations that seems to be treating the unitest file as a simple python file.   If I delete that I sometimes get in a weird state where it fails a bunch of assertions immediately and tries to user my path to the file as a module somehow by the error it puts out.\nI don't understand.  I have used pycharm for years and never seen this problem previously. \nLooks to be the 2019.2 version running on Ubuntu.  Did something change?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":58634220,"Users Score":0,"Answer":"Ah ha! The project having the problem was opened via a soft link directory.  When I opened the same thing using the direct directory the problem disappeared.  Bizarre.","Q_Score":0,"Tags":"python,pycharm,python-unittest","A_Id":58649931,"CreationDate":"2019-10-30T21:59:00.000","Title":"pycharm running unittests stopped 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does the memory layout different a lot? Is it difficult to share object between CPython and MicroPython?\nThe backgroubd is that I want to use Python like LUA. To use a full CPython eval() or exec() is too dangerious, I hope that I can have a simplified version of Python, which is sandboxed and not have access to my operating system's syscall.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":58636151,"Users Score":0,"Answer":"CPython and MicroPython (and many other implementations for that matter) don't share any implementation details, so passing objects from one to the other requires translation of the types in C. And I think the aspect of sandboxing is rather orthogonal to which Python version you use, that is micropython is written in C just like CPython so to sandbox that and avoid access to whatever functionality, you'll need external components or other measures to support that. For example MicroPython also has exec\/eval, if you don't want that you could exclude them from being compiled into the executable for instance, as you would for CPython.","Q_Score":0,"Tags":"micropython","A_Id":58665080,"CreationDate":"2019-10-31T02:26:00.000","Title":"Is it possible to embed MicroPython into a CPython application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working in an offline-environment, and am trying to deploy standalone Python-based applications with PyInstaller. I have been successful in all the previous pojects thus far, but for the latest one involving Orange3, I have the following problem. \nI tried packaging Orange3 as a standalone executable with PyInstaller via the command pyinstaller setup.py (which does not work) as I could not find a main script. \nIs there currently a way which I can package orange3 as a standalone program? If there are solution(s) with PyInstaller or other libraries, it will be of great help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":58636163,"Users Score":0,"Answer":"The entrypoint of Orange3 is Orange\/canvas\/__main__.py. A pyinstaller Orange\/canvas\/__main__.py should work better.","Q_Score":0,"Tags":"python,python-3.x,pyinstaller,orange,python-standalone","A_Id":59766496,"CreationDate":"2019-10-31T02:28:00.000","Title":"Orange3 as a standalone executable using PyInstaller","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know what is the difference in terms of execution in Django queryset and Django list.\nFor eg,\nList of Objects v\/s Queryset of Objects\nWill there be much difference in the execution part?\nAny Info will help as It can give a clear picture what to use and what not to use.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":536,"Q_Id":58638352,"Users Score":0,"Answer":"List of Objects is evaluated,\nQueryset isn't unless you perform any computation on the data. \nList of Objects will consume RAM space, Queryset won't that much.\nYou can refer Queryset further in the code without actually dealing with data in your memory, list of objects won't allow you to manipulate data that easily.\nThis is what I think, others can add to it.","Q_Score":1,"Tags":"python,django,list,django-queryset","A_Id":58638467,"CreationDate":"2019-10-31T07:08:00.000","Title":"Queryset v\/s List Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to copy files from 2 different bucket which are in two different aws account using same access key.\nSo it provide an error saying 403 forbidden.So what i want to do is, I want to check whether the access key that i am using to copy the file has permission to those bucket before i copy the file using boto3. Is there are anyway to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":579,"Q_Id":58638363,"Users Score":1,"Answer":"If you are copying objects between Amazon S3 buckets that belong to different AWS accounts, then you will need to use a single set of credentials that have:\n\nGetObject permission on the source bucket\nPutObject permission on the destination bucket\n\nAlso, the CopyObject command should be sent to the destination bucket to avoid problems with object ownership.\nTherefore, I would recommend:\n\nUse credentials from the destination account (dest-IAM-user)\nAdd a bucket policy to the source bucket that permits GetObject access by dest-IAM-user","Q_Score":3,"Tags":"python,amazon-s3,boto3","A_Id":58639883,"CreationDate":"2019-10-31T07:09:00.000","Title":"How to check whether s3 access key has access to a specific bucket or not in aws using boto3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to query from the BBG API the nearest quote to 14:00 o'clock for a number of FX currency pairs. I read the developers guide and I can see that reference data request provides you with the latest quote available for a currency however if I run the request at 14.15 it will give me the nearest quote to that time not 14.00. Historical and intraday data output too many values as I need only the latest quote to a given time. \nWould you be able to advise me if there is a type of request which will give me what I am looking for.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":293,"Q_Id":58641891,"Users Score":0,"Answer":"Further to previous suggestions, you can start subscription to \/\/blp\/mktdata service before 14:00 for each instrument to receive stream of real-time ticks. Cache the last tick, when hitting 14:00 mark the cache as pre-14:00, then mark the first tick after as post:14, select the nearest to 14:00 from both.","Q_Score":1,"Tags":"python,api,quote,bloomberg","A_Id":58652497,"CreationDate":"2019-10-31T10:58:00.000","Title":"Bloomberg API how to get only the latest quote to a given time specified by the user in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 lists and I want to save them in a csv file but they always end up in one column. \n\ndates=['13:14 - 28. Okt. 2019', '14:30 - 27. Okt. 2019', '11:33 - 26. Okt. 2019', '15:54 - 25. Okt. 2019']\ncodes=['W9KBJ-95X9T-ZC3KW-BJTJT-5FF3T', 'CZWJJ-X6XHJ-9CJC5-JTT3J-WZ6WC', 'KZK3T-K6RSJ-ZWTCK-JTJ3T-T3HJJ', 'CHCBT-TF6HB-ZC3WC-BT333-KBR3B']\n\nI checked the documentation but without success.\ndef save_as_csv(codes, dates, save_location):\n    raw_data = {'codes': codes, 'date_posted': dates}\n    df = pd.DataFrame(data=raw_data)\n    df.to_csv(save_location, columns=['codes', 'date_posted'], index=False)\n-----\n\ncodes,date_posted\nW9KBJ-95X9T-ZC3KW-BJTJT-5FF3T,13:14 - 28. Okt. 2019\nCZWJJ-X6XHJ-9CJC5-JTT3J-WZ6WC,14:30 - 27. Okt. 2019\nKZK3T-K6RSJ-ZWTCK-JTJ3T-T3HJJ,11:33 - 26. Okt. 2019\nCHCBT-TF6HB-ZC3WC-BT333-KBR3B,15:54 - 25. Okt. 2019\n\nThis is my result, but they are all in one column.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":58649100,"Users Score":0,"Answer":"It seems they are two columns already, as you gave example in your question\n\ncodes[W9KBJ-95X9T-ZC3KW-BJTJT-5FF3T]\ndate_posted[13:14 - 28. Okt. 2019]\n\nread this file in pandas again, with explicit \",\" as a delimiter, you'll be able to read this file in CSV format.\nLet me know if you are still not clear. \nThanks.","Q_Score":0,"Tags":"python,pandas,csv","A_Id":58649241,"CreationDate":"2019-10-31T18:10:00.000","Title":"pandas saves my data only into one column in a csv-file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new at programming and I was wondering if when you delete all items of the canvas you also delete the widgets it contains.\nI have a canvas with widgets using the create_window method, the canvas is build for the user to fill information, when done the information is saved and the canvas is cleared. Later the canvas ir redrawn for the user to fill again information.\nWhen the canvas is build widgets are created so I was wondering: if I only delete the items would I be stacking widgetes over and over somewhere, everytime the canvas is redrawn?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27,"Q_Id":58649944,"Users Score":1,"Answer":"When you delete a window object on the canvas, only that window object on the canvas is deleted. The widget itself is not automatically deleted. If you only delete the canvas objects and keep creating new windows to be embedded on the canvas, you're creating a memory leak.","Q_Score":0,"Tags":"python,canvas,tkinter","A_Id":58650345,"CreationDate":"2019-10-31T19:18:00.000","Title":"Deleting all items of the canvas deletes also the widgets it contains?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have successfully installed a Python Function on a Linux VM, but due to some dependencies I need it to be deployed on Windows. It is set to be deployed on Linux, but is it possible to deploy it on Windows VM?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":381,"Q_Id":58650449,"Users Score":1,"Answer":"At this time no, Python Functions are only supported in App Service Plans using Linux.\n\nYour Azure Function App has 'FUNCTIONS_WORKER_RUNTIME' set to 'dotnet'\n  while your local project is set to 'python'. You can pass --force to\n  update your Azure app with 'python' as a 'FUNCTIONS_WORKER_RUNTIME'\nC:\\Users\\-----\\source\\repos\\func\\MyFunctionProj>func azure functionapp publish pyfunc1 --force\nSetting 'FUNCTIONS_WORKER_RUNTIME' to 'python' because --force was\n  passed Getting site publishing info... Publishing Python functions is\n  only supported for Linux FunctionApps","Q_Score":0,"Tags":"python,azure,function,azure-functions","A_Id":58652093,"CreationDate":"2019-10-31T20:01:00.000","Title":"Is it possible to deploy Python Azure Function on Windows OS Image","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Python bot running PRAW for Reddit. It is open source and thus users could schedule this bot to run at any frequency (e.g. using cron). It could run every 10 minutes, or every 6 hours.\nI have a specific function (let's call it check_logs) in this bot that should not run every execution of this bot, but rather only once a day. The bot does not have a database.\nIs there a way to accomplish this in Python without external databases\/files?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":611,"Q_Id":58653864,"Users Score":0,"Answer":"Generally speaking, it's better (and easier) to use the external database or file. But, if you absolutely need it you could also:\n\nModify the script itself, e.g. store the date of the last run in commented out last line of the script. \nStore the date of the last update on the web, for example, in your case it could be a Reddit post or google doc or draft email or a site like Pastebin, etc.\nChange the \"modified date\" of the script itself and use it as a reference.","Q_Score":0,"Tags":"python,python-3.x,praw","A_Id":58654034,"CreationDate":"2019-11-01T03:45:00.000","Title":"In a Python bot, how to run a function only once a 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'm trying to read the background color of a cell in a table in a pptx file with python-pptx module, but I am only able to set a _Cell's fill property, not able to read a value from it.   \nI tried reading fill.back_color, but they were all (255,255,255) after doing fill.patternize() as the output suggests. What am I doing wrong? Or should I use another package?\nMy pptx file was not made with python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":58654119,"Users Score":0,"Answer":"As @scanny pointed out, fill.back_color is used for pattern fills. For the cell color, I should read from fill.fore_color.","Q_Score":0,"Tags":"python,python-3.x,python-pptx","A_Id":58677001,"CreationDate":"2019-11-01T04:30:00.000","Title":"Is there a python-pptx function that is able to read the background color of a table cell?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi all We are trying to create a python virtual environment through oozie shell action. But oozie is not recognizing virtualenv command inside the shell script. \nAfter the virtual environment is created we are trying to download a file using python rest API. But we are unable to cross the creation of virtual environment.\nAny help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":197,"Q_Id":58657595,"Users Score":1,"Answer":"Oozie shell action executes on a Node Manager, that node may not have virtual environment installed hence the failure.","Q_Score":0,"Tags":"python,oozie,oozie-workflow","A_Id":63374341,"CreationDate":"2019-11-01T10:24:00.000","Title":"Oozie shell action to create python virtual env","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My code runs N number of threads. I want to stop specific threads on some condition but the remaining threads should continue running. I am doing some operation once each thread finishes its job. Is there a way to stop running thread in Python 3. \nMy current code is implemented in Python2 which does this by \"_Thread__stop()\". Is there any identical thing in Python3?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":764,"Q_Id":58658661,"Users Score":0,"Answer":"The practice is to \"signal\" the thread that it is time to finish and then the thread needs to exit. This is not killing like you kill a process but a regular state machine behavior of your thread function.\nFor example, suppose your thread is lopping. You should insert an if statement inside the loop that instructing the thread function to break or return if stop is True. The stop variable should be a shared variable with the main thread (or the thread who need to stop out thread) that will change it to True. usually after this, the stopper thread will want to wait for the thread completion by join()","Q_Score":1,"Tags":"python,python-3.x,multithreading","A_Id":58659320,"CreationDate":"2019-11-01T11:40:00.000","Title":"Python3: How to stop\/kill thread","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been able to freeze a Python\/PySide2 script with fbs on macOS, and the app seems to work.\nHowever, I got some errors from the freeze process stating: \n\nCan not find path .\/libshiboken2.abi3.5.13.dylib. \n\nDoes anyone know how to fix that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":648,"Q_Id":58658902,"Users Score":0,"Answer":"Try to use the --runtime-tmpdir because while running the generated exe file it needs this file libshiboken2.abi3.5.13.dylib and unable hook that file. \nSolution: use --add-data & --runtime-tmpdir to pyinstaller command line.\npyinstaller -F --add-data \"path\/libshiboken2.abi3.5.13.dylib\":\"**PATH\"\n--runtime-tmpdir temp_dir_name your_program.py\nhere PATH  = the directory name of that file looking for.-F = one file","Q_Score":1,"Tags":"python,pyinstaller,pyside2,python-standalone,fbs","A_Id":58706807,"CreationDate":"2019-11-01T12:00:00.000","Title":"how to solve fbs error 'Can not find path .\/libshiboken2.abi3.5.13.dylib'?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Hi im new to django and i cant get my web server running. First of all i viewed several of other threads and ive been searching for a solution for 4 hours and i couldn't find any help.\nSo this is what ive done:\n\nInstalled django using the following \"pip install django\"\nCreated a project using \"django-admin startproject DjangoProject\"\nWent into the directory using \"cd DjangoProject\"\nInputted \"python manage.py runserver\" into the console and the console doesn't display anything.\n\nSo ive tried several of methods to solve this issue and have even set up environmental variables \n\nC:\\Python37\\scripts\nC:\\Python37\n\nAfter setting up environmental variables when i input \"python -m django --version\" or \"python manage.py runserver\" i receive an output of \"'python' is not recognised as an internal or external command,operable program or batch file.\"\nI think i haven't set up my environmental variables properly\nHave i set up my environmental variables properly? Or have i done something else wrong, I can't seem to figure out the problem. Any Help would be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1964,"Q_Id":58661812,"Users Score":0,"Answer":"I do not see the step where you have already created and activated your virtual environment already activated\nvirtualenv name\nsource name\/bin\/activate","Q_Score":1,"Tags":"python,django,environment-variables","A_Id":58661912,"CreationDate":"2019-11-01T15:27:00.000","Title":"Django- \"python manage.py runserver\" not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there any way to update all the packages on pycharm community version? Currently I only can update them one by one and I have a lot of outdated packages!\nI do not have a conda environment and use the install python on my Windows 10.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":1867,"Q_Id":58662727,"Users Score":3,"Answer":"I wanted to update all packages in one shot, I'm currently using pycharm professional version by student license. I'm not sure that this approach can be applied on your Pycharm since our versions are different, but I want to share my experience. \nGo to [File > Settings] and choose the interpreter which you'd wanted to upgrade its packages, and pick packages with Ctrl-Left Click or Shift-Left Click or Ctrl+A, and click the update button (triangle icon).","Q_Score":1,"Tags":"python-3.x,pycharm","A_Id":61462199,"CreationDate":"2019-11-01T16:33:00.000","Title":"Update all packages on Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I understand that python doesn't have true private class properties, and we can assign an underscore before a _<property> to indicate weak protection. It also seems if we use the @property decorator without a setter, others won't be able to change the value of this property. \nSo my question is, if the above statement is true, why do we need to have the single underscore when we can just disable others to change the value? What is the difference? As someone who's new to python programming, I appreciate your time and patience. \nThank you!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":58662765,"Users Score":0,"Answer":"The leading underscore convention tells readers of your code that the variable is an implementation details that should not be relied upon.  The variable is \"private\" in the sense that it is a class internal that you do not want to be used by client code.\nManaging an attribute with just a getter property isn't marking it as private, it's marking it as public but read-only. It's telling client code that it can depend on the attribute's existence, but cannot change its value.","Q_Score":0,"Tags":"python","A_Id":58669969,"CreationDate":"2019-11-01T16:36:00.000","Title":"What is the difference between a single underscore before a class property and @property without setters?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I ran a Python script that looped through 160,000 lines, hit an API, and (was supposed) to dump all of the output to a .txt file.\nI ran out of disk space, and discovered a .filename.py.swp that is 21GB large. I vim'd it, and I see a bunch of data that the API responded with.\nSadly, there's a bunch of binary characters in there.\nHow can I clean up this Python .swp file to extract my JSON from it?\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":58663632,"Users Score":0,"Answer":"Using the 'strings' command in Linux, I was able to extract SOME data. This command removes binary data and returns the parameter you give it (the filename) in straight string format.","Q_Score":2,"Tags":"python","A_Id":58956746,"CreationDate":"2019-11-01T17:47:00.000","Title":"Recover output from Python script stuck in a .filename.py.swp file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Every UDP server example I can find uses a while True loop to listen for incoming data. I'm attempting to use a single UDP socket server as part a kivy window that's also doing other things. As soon as I implement the server's while True loop everything locks up, as I guess I would expect it to do.\nHow do I listen on a UDP port and also have the rest of the program continue functioning?\nI've tried moving the UDP server handling to another (udp_server.py) file and then importing the function, but since I'm importing the while loop nothing changes.\nI've also tried assigning the received data to a variable inside udp_server.py and then just importing that variable, with udp_server.py already running separately, but even that is locking up my main program.\nI'm 99.99% sure it's just some basic thing that I should already know, but I'm new to Python. Thanks in advance for any help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":479,"Q_Id":58664927,"Users Score":0,"Answer":"Can you share your python files?\nSo that i can understand how did you do it.\nI have a if __name__ == '__main__': loop, which listens gpio's.\nAnd also i would like to get commands form udp port.\nThanks\nHW is rPi Zero","Q_Score":3,"Tags":"python,sockets,while-loop,server,udp","A_Id":64665624,"CreationDate":"2019-11-01T19:34:00.000","Title":"How do I keep a UDP server listening in Python 3 without the WHILE loop locking up the program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm in the process of implementing an algorithm that requires connectivity between somewhere around 10 Raspberry Pi's over a LAN and could use some help in figuring out a means to get them to talk between each other.  \nFor some background on what I'll be using this for, I'll be connecting individual RaspPi's to SEL relays to gather metered data for a scale model microgrid of my school's actual power grid. With that metered data, I'd like to be able to send sampled data from each relay to other random relays in the testbed as part of a consensus algorithm (like hashgraph) to try and reduce an ICS-focused attack on our power grid like what happened to Ukraine a few years ago. The idea is that a byzantine fault tolerance system would work well for a power system spanned over a large geographical area.\nAs this is only a test to determine whether or not such an implementation would be beneficial for use in power substations, I've only been using python scripts for gathering the aforementioned data from the relays.  As such, I'm looking for a python-based means of communication between these computers.  I've looked into sockets, but I'm not sure whether or not that's an effective means for 10 computers trying to communicate with one another.\nThe ideal end-goal would be to simulate a man-in-the-middle attack on this testbed to see if the system would be able to correct and detect the threat in a timely manner.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":58665473,"Users Score":1,"Answer":"Any single system (Raspberry PI) can listen for incoming connections and use them in some specific way. \nThings to consider which might be of use:\n\nDo you absolutely need all data?\nIt data sent often or rarely?\nWill connections be randomly sending data?\nAre the systems required to speak to one another?\n\nHigh volume data with occasional loss might be a good solution using UDP.\nIf you really need all the data, use TCP and random connections to ensure data capture.\nWould you need to send them to eachother or just to one or two sources? This might make your issue easier.\nRegardless, systems are capable of handling much more than 10 connections so you should be ok. \nNot sure how else to help.","Q_Score":3,"Tags":"python,raspberry-pi,communication","A_Id":58665724,"CreationDate":"2019-11-01T20:24:00.000","Title":"What's the best way to implement full communication between many RaspPis over a network?","Data Science and Machine Learning":0,"Database and SQL":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 use the \"base\" environment of Anaconda for Pycharm. However, I cannot find this option in the list of conda environments. Where should it be?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1102,"Q_Id":58667333,"Users Score":0,"Answer":"Ok so if anyone is wondering how to do this for MacOS. The path is ...anaconda3\/python.app for python interpreter.","Q_Score":1,"Tags":"python,pycharm,anaconda","A_Id":70205255,"CreationDate":"2019-11-02T00:39:00.000","Title":"How to add Anaconda base as the interpreter in PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an audio file sampled at 44 kbps and it has a few hours of recording. I would like to view the raw waveform in a plot (figure) with something like matplotlib (or GR in Julia) and then to save the figure to disk. Currently this takes a considerable amount of time and would like to reduce that time. \nWhat are some common strategies to do so? Are there any special circumstances to consider on approaches of reducing the number of points in the figure? I expect that some type of subsampling of the time points will be needed and that some interpolation or smoothing will be used. (Python or Julia solutions would be ideal but other languages like R or MATLAB are similar enough to understand the approach.)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":144,"Q_Id":58667844,"Users Score":1,"Answer":"Assuming that your audio file has a sample rate of 44 kHz (which is the most common sampling rate), then there are 60*60*44_000 = 158400000 samples per hour. This number should be compared to a high-resolution screen which is ~4000 pixels wide (4k resolution). If you would print time series with a 600 dpi printer, 1 hour would be 60*60*44_000 \/ (600 * 2.54 * 100) = 1039 meters long if every sample should be resolved. (so please don't print this :-))\nInstead have a look at PyPlot.jl functions psd (power spectral density) and specgram (spectrogram) which are often used to visualize frequencies present in an audio recording.","Q_Score":0,"Tags":"python,matplotlib,audio,plot,julia","A_Id":58717599,"CreationDate":"2019-11-02T02:40:00.000","Title":"How to plot a very large audio file with low latency and time to save file?","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 huge master data dump excel file. I have to append data to it on a regular basis. The data to be appended is stored as a pandas dataframe. Is there a way to append this data to the master dump file without having to read its contents. \nThe dump file is huge and takes a considerable amount of time for the program to load the file (using pandas).\nI have already tried openpyxl and XlsxWriter but it didn't work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":152,"Q_Id":58669599,"Users Score":2,"Answer":"It isn't possible to just append to an xlsx file like a text file. An xlsx file is a collection of XML files in a Zip container so to append data you would need to unzip the file, read the XML data, add the new data, rewrite the XML file(s) and then rezip them.\nThis is effectively what OpenPyXL does.","Q_Score":2,"Tags":"python,excel,pandas","A_Id":58670829,"CreationDate":"2019-11-02T08:54:00.000","Title":"Is there a way to append data to an excel file without reading its contents, in python?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m building a command line application with python, and I Need to be able to print something, then the user edit it and return it to me\nI know that Input() doesn\u2019t fit to my case because the user can\u2019t modify the text you give him.\nIs there a way to do it ?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":792,"Q_Id":58673807,"Users Score":0,"Answer":"So, as Anatoly said, I\u2019m going to learn curse, because I will need other things curse can do. Thank you for everyone which has responded. I will also use read line.insert_text","Q_Score":2,"Tags":"python,python-3.x","A_Id":58674454,"CreationDate":"2019-11-02T18:01:00.000","Title":"How can I edit an inputed text in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having issues running django tests in PyCharm Pro.\n\nI am able to run python manage.py runserver just fine.\nI am able to migrate, makemigrations, manage.py test just fine. Actually, everything with manage.py runs as expected.\n\nWhenever I run tests in PyCharm (by clicking the green run button), I get this error:\ndjango.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.\nI have done several things to fix this:\n\nI have, in my test file, put this:\nimport os\n os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' (with mysite being the correct dir I promise)\nI have a settings file and a wsgi file, and my wsgi file does set the DJANGO_SETTINGS_MODULE:\nos.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"mysite.settings\")\napplication = get_wsgi_application()\nThe only thing that has taken me out of this error was by setting up the configuration for that test class by going to Edit Configuations -> Environment -> Environment Variables and adding the DJANGO_SETTINGS_MODULE there. This only gets me a different error:\ndjango.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.\nPlus, I have to do this for every test class and I can't run individual tests in the class, but must rather run the entire test suite in that class. Not a good solution...\nI have manually (in the virtualenv) run export DJANGO_SETTINGS_MODULE=mysite.settings. This has not changed anything. \n\nSo, I am out of ideas and have followed all the advice I could find on SO. Is there something else I have to do in Pycharm? Again, the cmdline works fine, but I'd really rather not run tests this way - plus, I can't debug. \nEdit: It may be worth noting that I am running the unit tests while my server is  running (this should not make a difference), and I am also have the python interpreter pointed to the one in my virtualenv.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":586,"Q_Id":58675355,"Users Score":1,"Answer":"Try to open the Run\/Debug Configuration window (you should find it in the top toolbar, clicking the dropdown menu near the play \/ debug button and Edit Configuration)\nFrom here, you should see a list with the existing saved configurations where the last element should be Templates. Search Django tests under Templates. In the environment part, add DJANGO_SETTINGS_MODULE=mysite.settings to the environment variables. The next time you'll run a test that is not existing in your run\/debug configurations, the template with the setting module set will be used.\nIf I were you, I will delete all the existing test configurations. Also, I suspect from your point 3, that you have probably a python test configured instead of a Django test (this is why you had the error django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet because Django was not loaded). If you have it, delete it too. Apply the configurations and retry to run the test.\nWhen you run the test, ensure that a Django test is run, not a python one (you should see the Django logo near the test name in the run section and in the dropdown in the toolbar)","Q_Score":1,"Tags":"python,django,pycharm,django-testing,django-tests","A_Id":58929656,"CreationDate":"2019-11-02T21:12:00.000","Title":"How can run django tests in Pycharm Pro, getting ImproperlyConfigured and AppRegistryNotReady errors","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a function that checks if a date ( int number ) that is written in this format: \"YYYYMMDD\" is valid or not.\nMy question is how do i get to the first 4 numbers for example ( the year )?\nthe month ( the 5th and 6th number ) and the days.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":33,"Q_Id":58675378,"Users Score":1,"Answer":"Probably the easiest way would be to convert it to a string and use substrings or regular expressions. If you need performance, use a combination of modulo and division by powers of 10 to extract the desired parts.","Q_Score":0,"Tags":"python-3.x","A_Id":58675420,"CreationDate":"2019-11-02T21:15:00.000","Title":"How to get to the first 4 numbers of an int number ? and also the 5th and 6th numbers for example","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does aubio have a way to detect sections of a piece of audio that lack tonal elements -- rhythm only? I tested a piece of music that has 16 seconds of rhythm at the start, but all the aubiopitch and aubionotes algorithms seemed to detect tonality during the rhythmic section. Could it be tuned somehow to distinguish tonal from non-tonal onsets? Or is there a related library that can do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":58675412,"Users Score":0,"Answer":"Use a spectrum analyser to detect sections with high amplitude. If you program - you could take each section and make an average of the freqencies (and amplitudes) present to give you an idea of the instrument(s) involved in creating that amplitude peak.\nHope that helps - if you're using python I could give you some pointers how to program this!?\nRegards\nTony","Q_Score":1,"Tags":"python,signal-processing,pitch-tracking,aubio","A_Id":58806389,"CreationDate":"2019-11-02T21:21:00.000","Title":"Can aubio be used to detect rhythm-only segments?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Facing this issue while running the code to load ML model pickle file.,, \nAttributeError: Can't get attribute 'DeprecationDict' on","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":404,"Q_Id":58676350,"Users Score":0,"Answer":"You used a new version of scikit-learn to load a model that was trained by an older version of scikit-learn.\nTherefore, the options are:\n\nRetrain the model with the current version of scikit-learn if you have a training text and data.\nOr go back to the lower version of the scikit-learn reported in the warning message","Q_Score":1,"Tags":"python,scikit-learn","A_Id":63735920,"CreationDate":"2019-11-03T00:04:00.000","Title":"Facing this error : AttributeError: Can't get attribute 'DeprecationDict' on <module 'sklearn.utils.deprecation'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I thought it might be time to start using PowerShell instead of cmd. I currently run Python scripts from Notepad++ with the following commnad:\ncmd \/c cd &quot;$(CURRENT_DIRECTORY)&quot; &amp;python -i &quot;$(FILE_NAME)&quot;\nHow should I modify this to get the same behaviour in PowerShell please?\nI tried\npowershell -noexit cd &quot;$(CURRENT_DIRECTORY)&quot; &amp;python -i &quot;$(FILE_NAME)&quot;\nbut I got an error about ampersands. I know very little about PowerShell or cmd in general - I just use them to run my Python scripts.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":58678730,"Users Score":0,"Answer":"After a bit more digging I found a solution:\npowershell -noexit cd '$(CURRENT_DIRECTORY)'; python -i '$(FILE_NAME)'\nPowerShell seems to prefer single quotes for paths so I wrapped $(CURRENT_DIRECTORY) and $(FILE_NAME) in single quotes.\nAlso, & is replaced by ; for multiple commands.\nIf there is a more \"correct\" way of doing this, please let me know.","Q_Score":1,"Tags":"python,powershell,cmd","A_Id":58679344,"CreationDate":"2019-11-03T09:06:00.000","Title":"Calling PowerShell from Python using Notepad++","Data 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":"Are pandas iterrows fast compare to np.where on a smaller dataset? I heard numpy is always efficient compared to pandas?\nI was surprised to see that when I used iterrow in my code vs numpy's np.where on a small dataset, iterrows execution was fast.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":58681323,"Users Score":0,"Answer":"Yes, there is a speed difference.\nFeel free to post your timeit benchmark figures.","Q_Score":0,"Tags":"python-3.x","A_Id":58684334,"CreationDate":"2019-11-03T14:51:00.000","Title":"pandas vs numpy packages in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Which one is more suitable for my project? I want to build a human gesture mimicking Robotic arm. The application is to be built using an open source PYNQ framework. It requires me to choose either one of the kits Ultra96 or PYNQ-Z2 kit for my project so that they can provide me with it. I am unable to find the exact difference between the functionalities of the two, and when to use which? Please help me.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":58681419,"Users Score":0,"Answer":"I have been using the Z2 board and it would seem to work just fine for your project. Although I can't speak for the ultra96 it's worth noting that it is a community board and so is not officially supported by Pynq.","Q_Score":0,"Tags":"python,arm,iot,robotics","A_Id":61090911,"CreationDate":"2019-11-03T15:02:00.000","Title":"Ultra96 or Pynq-Z2 kit?","Data Science and Machine Learning":0,"Database and SQL":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 trying to make an app. I have got it to work where all my files are in the same folder but it gets very messy and I would like to separate my files into separate folders of the structure: Start, Prelogin, andFirebaseLoginScreen`. So is what I am trying to do possible in kivy?   \nI have tried #: import name x.y.z as the pointer where x is the folder name, y is the name of kv-file and z is the class in kv-file I want to import, but I get so many weird errors when I try to do it. I have pretty much added every folder and everything to my PYTHONPATH but nothing works. \nStart contains main.py and main.kv where main.kv then points to the screenmanger in ``Prelogin. Prelogin contains some files that consist of labels and text about the app and then points to the screenmanger in FirebaseLoginScreen. The FirebaseLoginScreen contains a lot of files for the login system.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1265,"Q_Id":58682138,"Users Score":0,"Answer":"The answer is simply \"yes\", there's nothing special about the import parsing in kv language, or in Python when using Kivy. If you're having issues, it's because what you're attempting is wrong or insufficient, which isn't possible to debug from the amount of information you've given.\nIf you'd like to follow it up, post another question with an example that you think should work given your PYTHONPATH manipulations.","Q_Score":2,"Tags":"python,kivy,kivy-language","A_Id":58683177,"CreationDate":"2019-11-03T16:21:00.000","Title":"Is it possible to have a folder-based structure in kivy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between django-admin startapp and python manage.py startapp? They both create apps and the files are also same so what's the difference between these two?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3227,"Q_Id":58684021,"Users Score":0,"Answer":"There is no difference. manage.py is meant for the project and comes preconfigured with project-settings.","Q_Score":5,"Tags":"python,django,django-admin,django-apps,django-admin-actions","A_Id":58684039,"CreationDate":"2019-11-03T19:49:00.000","Title":"django-admin startapp v\/s python manage.py startapp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How to do that the best way?\nHow to autostart and run the script every 5 seconds? (i read something from a rs232 device)\nI want to write some values every 5 seconds to a postgresql database and for this is it ok to open the database connection every 5 seconds and close it or can it be stay opend?\nthanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":193,"Q_Id":58684337,"Users Score":0,"Answer":"I think the best way is to have a constantly running script that reads the value, sends to db, and sleeps for the remainer of the interval and keep the connection open. This way you can monitor and react if a read, write or both take too long for example. And then to have a separate script just to check if the main one is alive and notify you or restart the main one. I had some success with this model when reading from a bitcoin exchange api and inserting into mariadb every 6 seconds","Q_Score":0,"Tags":"python,python-3.x,postgresql,raspberry-pi,raspbian","A_Id":58684649,"CreationDate":"2019-11-03T20:30:00.000","Title":"Best and most efficient way to execute a Python script at Raspberry Pi (Raspbian Buster) every 5 seconds and store in PostgreSQL?","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'm using Tensorflow 1.14 and the tf.keras API to build a number (>10) of differnet neural networks. (I'm also interested in the answers to this question using Tensorflow 2). I'm wondering how I should organize my project.\nI convert the keras models into estimators using tf.keras.estimator.model_to_estimator and Tensorboard for visualization. I'm also sometimes using model.summary(). Each of my models has a number (>20) of hyperparameters and takes as input one of three types of input data. I sometimes use hyperparameter optimization, such that I often manually delete models and use tf.keras.backend.clear_session() before trying the next set of hyperparameters. \nCurrently I'm using functions that take hyperparameters as arguments and return the respective compiled keras model to be turned into an estimator. I use three different \"Main_Datatype.py\" scripts to train models for the three different input data types. All data is loaded from .tfrecord files and there is an input function for each data type, which is used by all estimators taking that type of data as input. I switch between models (i.e. functions returning a model) in the Main scripts. I also have some building blocks that are part of more than one model, for which I use helper functions returning them, piecing together the final result using the Keras functional API.\nThe slight incompatibilities of the different models are begining to confuse me and I've decided to organise the project using classes. I'm planing to make a class for each model that keeps track of hyperparameters and correct naming of each model and its model directory. However, I'm wondering if there are established or recomended ways to do this in Tensorflow.\nQuestion: Should I be subclassing tf.keras.Model instead of using functions to build models or python classes that encapsulate them? Would subclassing keras.Model break (or require much work to enable) any of the functionality that I use with keras estimators and tensorboard? I've seen many issues people have with using custom Model classes and am somewhat reluctant to put in the work only to find that it doesn't work for me. Do you have other suggestions how to better organize my project?\nThank you very much in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":349,"Q_Id":58685407,"Users Score":3,"Answer":"Subclass only if you absolutely need to. I personally prefer following the following order of implementation. If the complexity of the model you are designing, can not be achieved using the first two options, then of course subclassing is the only option left.  \n\ntf.keras Sequential API\ntf.keras Functional API\nSubclass tf.keras.Model","Q_Score":2,"Tags":"python,tensorflow,tensorflow-estimator,tf.keras","A_Id":58685507,"CreationDate":"2019-11-03T23:03:00.000","Title":"Project organization with Tensorflow.keras. Should one subclass tf.keras.Model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Now, the official TensorFlow on Anaconda is 2.0. My question is how to force Anaconda to install an earlier version of TensorFlow instead. So, for example, I would like Anaconda to install TensorFlow 1.14 as plenty of my projects are depending on this version.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":51822,"Q_Id":58688481,"Users Score":1,"Answer":"first find the python version of tensorflow==1.14.0, then find the Anaconda version by python version.\ne.g. tensorflow 1.14.0 can work well on python36, and Anaconda 3.5.1 has python36. So install the Anaconda 3.5.1, then install tensorflow==1.14.0 by pip","Q_Score":28,"Tags":"python,python-3.x,tensorflow,anaconda,version","A_Id":69961017,"CreationDate":"2019-11-04T06:52:00.000","Title":"Force Anaconda to install tensorflow 1.14","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working in python with spacy and there are different pre-trained models like the en_core_web_sm or the en_core_web_md. One of them is using words vectors to find word similarity and the other one is using context-sensitive tensors. \nWhat is the difference between using context-sensitive tensors and using word vectors? And what is context-senstiive tensors exactly?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":492,"Q_Id":58688938,"Users Score":2,"Answer":"Word vectors are stored in a big table in the model and when you look up cat, you always get the same vector from this table.\nThe context-sensitive tensors are dense feature vectors computed by the models in the pipeline while analyzing the text. You will get different vectors for cat in different texts. If you use en_core_web_sm, the token cat in I have a cat will not have the same vector as in The cat is black. Having the context-sensitive tensors available when the model doesn't include word vectors lets the similarity functions work to some degree, but the results are very different than with word vectors.\nFor most purposes, you probably want to use the _md or _lg model with word vectors.","Q_Score":2,"Tags":"python,nlp,spacy","A_Id":58690132,"CreationDate":"2019-11-04T07:33:00.000","Title":"Difference between context-sensitive tensors and word vectors","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to automate some workflows to control some Mac applications, I have got a way to do this with Pyautogui module,but I don't want to simulate keyboard or mouse actions anymore, I think if I can get the variables under any GUI elements and program with them directly it would be better, how can I do this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":102,"Q_Id":58689847,"Users Score":1,"Answer":"This is not possible unless the application has some kind of api.\nFor Web GUIs you can use Selenium and directly select the DOM elements.","Q_Score":0,"Tags":"python,automation,pyautogui","A_Id":58689991,"CreationDate":"2019-11-04T08:48:00.000","Title":"How to automate any application variable directly without GUI with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python 3.6 & schedule module and needs to schedule a task to run every minute between two time intervals for some specific days of week. For instance, say task is meant to be scheduled for every minute for 2.5 hours time interval of 11:00 PM to 01:30 AM for every Wednesday and Friday. It should be run for every minute between two given time intervals, it should be stopped!\nWhat I have tried:\n\nI tried using schedule.every(1).minutes.do(job) inside schedule.every().day.at(\"11:00\").do(job)\n\nI have built logic to successfully select days of my choice and they can be made available to schedule logic.\n\n\nBut,\n\nThat does not stops at specified time and I could not get how to introduce end time limit.\n\nI could not get how to schedule it for 11:00 PM to 01:30 AM, I could not get how to tell it that 01:30 AM comes after 11:00 PM in night.\n\nI do not have any idea about how to schedule it for the days of my choice.\n\n\nAny help?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":454,"Q_Id":58690965,"Users Score":0,"Answer":"If using windows you could use Task scheduler or if UNIX\/Linux could use Cron?\nThat way your script will run and then end, the schedule module looks like it relies on a continuous running of the script.","Q_Score":2,"Tags":"python-3.x,scheduled-tasks","A_Id":58694204,"CreationDate":"2019-11-04T09:58:00.000","Title":"How to schedule a task to run every minute between two time intervals for specific days?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm training a keras deep learning model with 3 fold cross validation. For every fold I'm receiving a best performing model and in the end my algorithm is giving out the combined score of the three best models.\nMy question now is, if there is a possibility to combine the 3 models in the end or if it would be a legit solution to just take the best performing model of those 3 models?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":415,"Q_Id":58691535,"Users Score":1,"Answer":"A (more) correct reflection of your performance on your dataset would be to average the N fold-results on your validation set.\nAs per the three resulting models, you can have an average prediction (voting ensemble) for a new data point. In other words, whenever a new data point arrives, predict with all your three models and average the results.\nPlease note a very important thing: The purpose of K-fold cross-validation is model checking, not model building. By using K-fold cross-validation you ensure that when you randomly split your data, say in an 80-20 percent fashion, you do not create a very easy test set. Creating a very easy test set would lead the developer to consider that he\/she has a very good model, and when subjected to test data the model would perform much worse.\nIn essence and eventually, what you would want to do is to take all the data that you are using for both train and test and using it only for training.","Q_Score":1,"Tags":"python,keras,scikit-learn,deep-learning,cross-validation","A_Id":58692931,"CreationDate":"2019-11-04T10:30:00.000","Title":"How can deep learning models found via cross validation be combined?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Until now I was managing my Python envs with conda and was using:\npip freeze > requirements.txt\nwhen needed for deployment purposes.\nBut I ended up doing pip install some_package for some package I could not install with conda (which was apparently a terrible idea) and now pip freeze result has become totally unrelated to whichever conda environment I am activating.\nIs there a way I can restore the situation, meaning having pip freeze correctly describe the conda environment that is currently active?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":859,"Q_Id":58691647,"Users Score":0,"Answer":"When using both pip and conda I would recommend using conda env export > environment.yml. This will create a yml file with the versions you are using including where to find them and how to install them. \nWhen you need to install the enviroment on a new machine, you can use conda env create -f environment.yml\nNote: the yml file also dictates what the environment will be called. This can be changed manually in the file before installing the environment though.","Q_Score":0,"Tags":"python,pip,conda","A_Id":58691760,"CreationDate":"2019-11-04T10:36:00.000","Title":"Restore conda\/pip freeze consistency","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am reading three bytes from a file in python \nthe bytes in the hex format \nexact byte values are \\x00 \\x07 \\x71\nbut when I read these bytes using fp.read method python converts the last byte to q\nIs there any way to avoid the conversion when python reads the bytes to ASCII and literally read the byte value","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":462,"Q_Id":58695490,"Users Score":0,"Answer":"I found the solution I use the binascii.b2a_hex to convert binary values to their hexadecimal representation and the use int(converted_val, 16) to get integer value","Q_Score":1,"Tags":"python-3.x","A_Id":58695949,"CreationDate":"2019-11-04T14:29:00.000","Title":"reading bytes literally in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an script in Python to test login on a web page.\nMy question : What are the alternatives to Behat compatible with Python?.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":300,"Q_Id":58696651,"Users Score":1,"Answer":"Edit: This question got heavily edited after I answered so I am copying my out of scope comment into the answer: \"It seems popular enough => github.com\/behave\/behave\" \nBehat is a PHP library written in PHP. It would be too hard to get it to interface with your tests in Python.\nOn the other hand, I suggest looking up a Python-native BDD framework.","Q_Score":0,"Tags":"python,selenium,behat","A_Id":58697982,"CreationDate":"2019-11-04T15:40:00.000","Title":"What are the alternatives to Behat for 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 looking to connect to a car wirelessly using socketCAN protocol on MacOS using the module python-can on python3. I don't know how to install the socketCAN protocol on MacOS. Pls help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1978,"Q_Id":58700886,"Users Score":0,"Answer":"SocketCAN is implemented only for the Linux kernel. So it is not available on other operating systems. But as long as your CAN adapter is supported by python-can, you don't need SocketCAN.","Q_Score":2,"Tags":"python,python-3.x,can-bus,bus,python-can","A_Id":58708908,"CreationDate":"2019-11-04T20:54:00.000","Title":"Is it possible to use socketCAN protocol on MacOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"At the end of my code I sum by dataframe below, then export to csv:\nsumbyname = d5.groupby(['Name'])['Value'].agg('sum')\nI sum the value of each person by name, Now if I sum this column in excel using SUM then I get +12\nNow if i do d5['Value'].sum()) in my code to find the total sum, I get -11.\nIs there a difference in the way i'm summing these 2 values? I thought they should be the same.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":658,"Q_Id":58701025,"Users Score":1,"Answer":"The value in column d5['Name'] might contains null values. \nGroupby will ignore those rows with None in d5['Name'].","Q_Score":0,"Tags":"python,pandas","A_Id":58701942,"CreationDate":"2019-11-04T21:03:00.000","Title":"Pandas, .agg('sum') vs .sum()","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Purpose:\nI want to have the relative movement of my mouse even when she is on the border of my screen (so I can't compute the vector between 2 moment).\nApplication:\nI want to make a helper for mortar shooting in a game called 'squad', you control the mortar with your mouse. I checked the behavior of the mouse within the game and when you move the camera around, when the mouse reach the border of the screen you can keep on looking around with no problem but the mouse position is obviously not updated since it is at the same position.\nI tried the following library:\n\nPyautogui: Have the function for it but doesn't handle near-broder mouse since I guess it calculate the relative movement of the mouse from a past and actual position\nPygame: can't catch the mouse relative movement when it's outside of the Windows\nPymouse: doesn't have the function I search\nPywin32: doesn't have the function I search\nPypiwin32: doesn't have the function I search\n\nA way to make it work:\nI was able to make it work by teleporting the mouse in the middle of the screen when it's reaching the border of the game (which doesn't cause trouble because apparently the game doesn't compute it to make your mortar move), but I'm afraid that I would get banned because some anticheat-tool would see my mouse teleporting around (even if this wouldn't be cheating).\nNow I'm considering using a library to read the USB Information that the mouse send.\nAfter 6+ hours of research I'm running out of possibilities to make it and before loosing more time I would like to know if anyone as a way to do it (in Python or any other language).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":58701646,"Users Score":0,"Answer":"Rather than warping the cursor to the center of the screen, could you just warp it back a little from the edge?  It seems like anti-cheat software would have a harder time detecting that.","Q_Score":2,"Tags":"python,mouse,motion","A_Id":58701973,"CreationDate":"2019-11-04T21:55:00.000","Title":"Getting mouse relative motion even at the border of screen","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So when running any code, no matter the language visual studio ignores the code and just doesn't run. all i see is it skips to the next line in the terminal and gives no output. Not even something like hello world runs. It gives no error message whatsoever, just doesn't run.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6813,"Q_Id":58703833,"Users Score":0,"Answer":"Ok, so i switched to Microsoft Visual Studio 2019, instead of Visual Studio Code, and that fixed the issue so now i don't have to worry about extensions.","Q_Score":1,"Tags":"python,visual-studio-code","A_Id":59010136,"CreationDate":"2019-11-05T02:55:00.000","Title":"Visual Studio Code wont run code and gives no error message","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So when running any code, no matter the language visual studio ignores the code and just doesn't run. all i see is it skips to the next line in the terminal and gives no output. Not even something like hello world runs. It gives no error message whatsoever, just doesn't run.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6813,"Q_Id":58703833,"Users Score":0,"Answer":"I had the same issue, running code in any language would cause it not to run, but no error message was produced. I eventually opened up developer tools and saw that no extensions were loading, somewhere the path got corrupt.\nI fixed the issue by uninstalling each extension, uninstalling VS Code, deleting the extensions out of the folder they live in, then reinstalling VS Code and the extensions.\nAfter that they ran fine.\nWhile a full reinstall is not ideal, this was the only method I could find to fix it. There is not much info on this issue online, so I'm adding my experience and the fix that worked for me.","Q_Score":1,"Tags":"python,visual-studio-code","A_Id":64868894,"CreationDate":"2019-11-05T02:55:00.000","Title":"Visual Studio Code wont run code and gives no error message","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Pandas dataFrame object train_df with say a column called \"ColA\" and a column \"ColB\". It has been loaded from a csv file with columns header using read_csv\nI obtain the same results when I code:\npd.crosstab(train_df['ColA'], train_df['ColB'])\nor \npd.crosstab(train_df.ColA, train_df.ColB)\nIs there any difference in these 2 ways of selecting columns? \nWhen I request to print the type it's the same : pandas.core.series.Series","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":58704076,"Users Score":0,"Answer":"No difference\npd.crosstab(train_df['ColA'], train_df['ColB']) is recommended to prevent possible errors. \nFor example, if you have a column named count and if you type train_df.count it will give an error. train_df['count'] won't give an error.","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":58704122,"CreationDate":"2019-11-05T03:30:00.000","Title":"Python Pandas dataFrame - Columns selection","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Pandas dataFrame object train_df with say a column called \"ColA\" and a column \"ColB\". It has been loaded from a csv file with columns header using read_csv\nI obtain the same results when I code:\npd.crosstab(train_df['ColA'], train_df['ColB'])\nor \npd.crosstab(train_df.ColA, train_df.ColB)\nIs there any difference in these 2 ways of selecting columns? \nWhen I request to print the type it's the same : pandas.core.series.Series","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":58704076,"Users Score":0,"Answer":"If you only want to select a single column, there is no difference between the two ways.\nHowever, the dot notation doesn't allow you to select multiple columns, whereas you can use dataframe[['col1', 'col2']] to select multiple columns (which returns a pandas.core.frame.DataFrame instead of a pandas.core.series.Series).","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":58704174,"CreationDate":"2019-11-05T03:30:00.000","Title":"Python Pandas dataFrame - Columns selection","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This might be a dumb question, but would like someone to tell me yes or no. \nSay I have an LSTM network in Tensorflow, and am training it using the Adam Optimizer to minimize a cost function by feeding X and Y variables a set of X and Y dict's during training, and then IN THE SAME SESSION, feeding the variables new X and Y dict's for testing, does Tensorflow automatically use the best model found during it's training (i.e. using the weights that brought about the lowest cost value during training), or just the most recent one in it's run (i.e. the latest epoch)? \nWondering if I need to set up a model.saver function to capture the best model as a new lower cost value is reached, close the current session, and re-open a new one using that saved model, OR if I can just assume that when I test in the same session as training, it will use the best model.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":58704575,"Users Score":1,"Answer":"It doesn't.\nThe model relies on a single set of weights, that are variables. You can store the best model with a saver and save the training progress as a separate checkpoint.\nOther option would be to have a duplicate set of variables and copy weights once a better model is found.\nYet, the it is normally uncommon to judge if a model at epoch X is better than at epoch Y, since training accuracy might be misleading (read: overfitting). Therefore, one usually evaluates model after every epoch and saves the checkpoint if performance got better during evaluation. This way there is no need to maintain multiple copies of the same model.","Q_Score":1,"Tags":"python-3.x,tensorflow","A_Id":58704657,"CreationDate":"2019-11-05T04:35:00.000","Title":"Does Tensorflow Use the Best Weights or Most Recent Weights When Testing in the Same Session?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Everything was working fine, but suddenly running a python task which imports gym and from gym imports spaces leads to an error(though it was working fine before): \nImportError: cannot import name 'spaces'\nI have tried reinstalling gym but then my tensorflow needs bleach version to be 1.5 while gym requires a upgraded version.\nI tried upgrading tensoflow from 1.8.0 to 1.12.0, this again throws an error:\nImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":796,"Q_Id":58705609,"Users Score":0,"Answer":"There are probably multiple reasons for this error message. On Windows 10, this can be due to access permissions to gym-related folder. Make sure your Windows user account is granted access to gym and\/or python libraries more broadly.","Q_Score":1,"Tags":"python-3.x,python-import,importerror,openai-gym","A_Id":63646557,"CreationDate":"2019-11-05T06:27:00.000","Title":"Cannot Import name 'spaces' from gym","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Brief intro of the app: \n\nI'm working on MLM Webapp and want to make payment on every 15th and last day of every month.\nCalculation effect for every user when a new user comes into the system.\n\nWhat I did [ research ]\n\nusing django crontab extension\ncelery\n\nQuestion is:\n-- Concern about the database insertion\/update query:\n\non the 15th-day hundreds of row generating with income calculation for users. so is there any better option to do that?\nhow to observe missed and failed query transaction?\n\nPlease guide me, how to do this with django, Thanks to everyone!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":58706475,"Users Score":0,"Answer":"For your 1st question, i don't think there will be any issue if you're using celery and celery beat for scheduling this task. Assuming your production server has 2 cores (so 4 threads hopefully), you can configure your celery worker (not the beat scheduler) to run using 1 worker with 1\/2 thread. At the 15th of a month, beat will see that a task is due and will call your celery worker to accomplish this task. While doing this your worker will be using 1 thread and the other threads will be open (so your server won't go down). There are different ways to configure your celery worker depending on your use case (e.g. using gevent rather than regular thread), but the basic config should be fine.\nWell I think you should keep a column in your table to track which ones were successfully handled by your code, and which failed. Celery dashboards will only show if total work succeeded or not, and won't give any further insights.\nHope this helps!","Q_Score":0,"Tags":"django,python-3.x,web-applications,logic","A_Id":58711413,"CreationDate":"2019-11-05T07:32:00.000","Title":"Is there any built-in functionality in django to call a method on a specific day of the month?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Skyfield has the functionality to compute the phases of the moon. but What if I wanted to know when would the moon be 20 degrees from the sun or 25 degrees from the sun.\nHow can I get the exact date and time when the sun and moon would be at a certain degree longitude?\nEdit(for clarification):\nIs it possible to know the next (or previous) date and time the sun or moon would be at a certain position? \nLike skyfield provides a function to find when sun and moon are at 0 degrees or 180 degrees (new moon, full moon).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":307,"Q_Id":58709023,"Users Score":1,"Answer":"Yes, Skyfield supports a possible approach. Look at its almanac.py module and you will find there are two steps:\n\nCreate a function that, given a date, returns 0 if the Moon is <20\u00b0 from the Sun or 1 if the Moon is \u226520\u00b0. You can either create this function directly and simply, or be more complicated like Skyfield is, and return a function from inside another function that holds the references to things like the ephemeris that the function will need to generate its answer.\nPass that function to the find_discrete() routine to tell you the moments at which the function flips from 0 to 1 or back again during a particular time period.\n\nHopefully the examples there will help you get started!","Q_Score":2,"Tags":"python,astronomy,skyfield","A_Id":58809157,"CreationDate":"2019-11-05T10:08:00.000","Title":"Is there a way to know date and time given the coordinates of a planet (sun,moon etc.)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've an excel file and I have to go through each row, always get columns say 2,3 and then in another owl file find the corresponding entity(which I get from column 2 of each row of the excel file) and populate it, and repeat the whole task for all rows of the excel file. Since both files are big doing the trivial way: go through each row of the excel file then go through each entity of the owl file, find the correct entity and then populate will take a lot time. \nIs there a different method I should try, which has lower complexity?\nAny help is highly appreciated.\nPS: I'm a CS student and done DSA in my previous sem. I now realise the practical importance of algos runtime now. \nFor working with excel sheet I'm using openpyxl, though unnecessary info.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":58710010,"Users Score":0,"Answer":"Depending on 'big' you may get away with reducing the big overhead of file-IO by storing one of the files (only the parts you need) in RAM and than iterate the other file only once.\nKomplexity keeps to be O(n*m)\nYou could reduce the complexity (if still needed) by storing the data of the file you keep in RAM in a HashMap which has access complexity of O(1) (in most cases)\nKomplexity is O(m) where m is the size of the file not kept in the HashMap (in RAM).\nIf 'big' means that even the data from the smaller file do not fit in RAM, You can use the same approach just do it in chunks of a size that fit in your RAM.","Q_Score":0,"Tags":"python,algorithm,owl,ontology","A_Id":58711528,"CreationDate":"2019-11-05T11:04:00.000","Title":"Faster way to populate a file after reading each line of another file","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am applying the pruning function from tensorflow_model_optimization,    tfmot.sparsity.keras.prune_low_magnitude() to MobileNetV2.\nIs there any way to set only some layers of the model to be prunable? For training, there is a method \"set_trainable\", but I haven't found any equivalent for pruning.\nAny ideas or comments will be appreciated! :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":321,"Q_Id":58711222,"Users Score":0,"Answer":"In the end I found that you can also apply prune_low_magnitude() per layer.\nSo the workaround would be to define a list containing the names or types of the layers that shall be pruned, and iterate the layer-wise pruning over all layers in this list.","Q_Score":0,"Tags":"python,machine-learning,keras,tensorflow2.0,pruning","A_Id":59372216,"CreationDate":"2019-11-05T12:18:00.000","Title":"How to set prunable layers for tfmot.sparsity.keras.prune_low_magnitude?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe containing the coordinates of millions of particles which I want to use to train a Neural network. These particles build individual clusters which are already identified and labeled; meaning that every particle is already assigned to its correct cluster (this assignment is done by a density estimation but for my purpose not that relevant).\nthe challenge is now to build a network which does this clustering after learning from the huge data. there are also a few more features in the dataframe like clustersize, amount of particles in a cluster etc. \nsince this is not a classification problem but more a identification of clusters-challenge what kind of neural network should i use? I have also problems to build this network: for example a CNN which classifies wheather there is a dog or cat in the picture, the output is obviously binary. so also the last layer just consists of two outputs which represent the probability for being 1 or 0. But how can I implement the last layer when I want to identify clusters? \nduring my research I heard about self organizing maps. would these networks do the job?\nthank you","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":97,"Q_Id":58711675,"Users Score":1,"Answer":"If you want to treat clustering as a classification problem, then you can try to train the network to predict whether two points belong to the same clusters or to different clusters.\nThis does not ultimately solve your problems, though - to cluster the data, this labeling needs to be transitive (which it likely will not be) and you have to label n\u00b2 pairs, which is expensive.\nFurthermore, because your clustering is density-based, your network may need to know about further data points to judge which ones should be connected...","Q_Score":0,"Tags":"python,tensorflow,neural-network,cluster-analysis","A_Id":58724694,"CreationDate":"2019-11-05T12:45:00.000","Title":"Cluster identification with NN","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe containing the coordinates of millions of particles which I want to use to train a Neural network. These particles build individual clusters which are already identified and labeled; meaning that every particle is already assigned to its correct cluster (this assignment is done by a density estimation but for my purpose not that relevant).\nthe challenge is now to build a network which does this clustering after learning from the huge data. there are also a few more features in the dataframe like clustersize, amount of particles in a cluster etc. \nsince this is not a classification problem but more a identification of clusters-challenge what kind of neural network should i use? I have also problems to build this network: for example a CNN which classifies wheather there is a dog or cat in the picture, the output is obviously binary. so also the last layer just consists of two outputs which represent the probability for being 1 or 0. But how can I implement the last layer when I want to identify clusters? \nduring my research I heard about self organizing maps. would these networks do the job?\nthank you","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":58711675,"Users Score":0,"Answer":"These particles build individual clusters which are already identified\n  and labeled; meaning that every particle is already assigned to its\n  correct cluster (this assignment is done by a density estimation but\n  for my purpose not that relevant).\n  the challenge is now to build a network which does this clustering\n  after learning from the huge data.\n\nSounds pretty much like a classification problem to me. Images themselves can build clusters in their image space (e.g. a vector space of dimension width * height * RGB).\n\nsince this is not a classification problem but more a identification\n  of clusters-challenge what kind of neural network should i use?\n\nYou have data of coordinates, you have labels. Start with a simple fully connected single\/multi-layer-perceptron i.e. vanilla NN, with as many outputs as number of clusters and softmax-activation function.\nThere are tons of blogs and tutorials for Deep Learning libraries like keras out there in the internet.","Q_Score":0,"Tags":"python,tensorflow,neural-network,cluster-analysis","A_Id":58712729,"CreationDate":"2019-11-05T12:45:00.000","Title":"Cluster identification with NN","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to do a linear regression using Matrix multiplication. \nX is the feature matrix, and I have 100 data points. As per the normal equation, the dot product of X and of the transpose of X is required. \nHaving added a column of ones as required, the shape of X is 100\u00d72 while for the transpose of X it is 2\u00d7100.\nHowever, when I am doing the dot product, the result (which is given in the book) comes accordingly, a 2\u00d72 matrix. Shouldn't it be a 100\u00d7100 matrix as per laws of matrix multiplication using dot product?\nConceptually, where am I going wrong?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":58715034,"Users Score":0,"Answer":"You are feeding them in the wrong order\nInstead of feeding (100,2) * (2,100), you are feeding (2,100) * (100,2)","Q_Score":1,"Tags":"python,numpy,regression","A_Id":58715086,"CreationDate":"2019-11-05T15:56:00.000","Title":"Matrix multiplication using numpy array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Siteimprove which is a software that looks through a website and recommends accessibility changes. I'm supposed to go through and edit the html of the pages to improve the Siteimprove score. \nI'm supposed to add a language attribute to all 143 pages and I was thinking I could write a simple script to go through every html page and replace <html> with <html\u00a0lang=\"en-US\"> instead of manually do this. \nI haven't done this before so I was thinking to make a copy and test a script (I have yet to write). Do you know where I should look for examples to write such a script that would basically say:\n\"For every file in directory named .html, if it contains <html> replace <html> with <html\u00a0lang=\"en-US\">\" \nOr if I should edit my logic statement above? I'm a student worker and don't want to mess this up.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":58715482,"Users Score":0,"Answer":"Thanks you to those who left comments, I didn't realize replaceAll was an option in VSCode, much easier solution!","Q_Score":0,"Tags":"python,html,automation","A_Id":58717997,"CreationDate":"2019-11-05T16:22:00.000","Title":"Automating a text change on every html page of a website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We have our admin team setup PYENV so that we can run against multiple versions of python.\nwe have two versions of python Python 2 and Python 3. How do I run my scripts against python 3?\nFor example, when I just run like Python test.py it always run against python2 but I want to run my script with Python3.\nThank you for your help.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":463,"Q_Id":58715579,"Users Score":0,"Answer":"if you are using mac in terminal write ( python3 (name of the file).py","Q_Score":0,"Tags":"python,python-3.x","A_Id":58715612,"CreationDate":"2019-11-05T16:27:00.000","Title":"How to run python code if pyenv is setup to run against multiple versions of 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":"We have our admin team setup PYENV so that we can run against multiple versions of python.\nwe have two versions of python Python 2 and Python 3. How do I run my scripts against python 3?\nFor example, when I just run like Python test.py it always run against python2 but I want to run my script with Python3.\nThank you for your help.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":463,"Q_Id":58715579,"Users Score":0,"Answer":"That depends.\nIf you want to use python3.x globally, you can run pyenv global 3.x to set the specific python version you want as your global version.\nHowever, if you want to use python3.x for that specific script only, run \npython3.x path\/to\/specific\/script.py","Q_Score":0,"Tags":"python,python-3.x","A_Id":58715677,"CreationDate":"2019-11-05T16:27:00.000","Title":"How to run python code if pyenv is setup to run against multiple versions of 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 an image with image.shape=(20,10)and I want to resize this image so that new image size would be image.size = 90.\nI want to use np.resize(image,(new_width, new_height)), but how can I calculate new_width and new_height, so that it maintains aspect_ratio as same as in original image.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":58717150,"Users Score":0,"Answer":"Well, you choose which dimension you want to enforce and then you adjust the other one by calculating either new_width = new_height*aspect_ratio or new_height = new_width\/aspect_ratio.\nYou might want to round those numbers and convert them to int too.","Q_Score":0,"Tags":"python-3.x,numpy","A_Id":58717243,"CreationDate":"2019-11-05T18:11:00.000","Title":"How to resize image by mainitaining aspect ratio in python3?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"One of data sources I extract data from provides access through REST API in form of JSON responses. That's great, because I get data already structured, i.e., less pain with scraping and parsing unstructured HTML documents. \nHowever, they constrain HTTP traffic with rate limiting: requests per minutes\/hour\/month\/IP\/user email.\nWhen I was scraping HTML documents with Scrapy I could easily configure number of requests per second, delays between subsequent requests, number of threads, etc. I will call it \"load strategy\". The way it works in Scrapy under the hood, is that I generate a number of HTTP requests that Scrapy puts into the queue, and process requests from the queue with respect to the given \"load strategy\".\nIs there something like that for REST APIs? \nTo give some context, I'm using Python REST client generated from data source Swagger definitions. The client uses urlib3 under the hood. The client provides a way to execute requests in an asynchronous way and a way to configure a thread pool but it looks like I would need to play a bit around to configure it. I'm looking for out-of-the-box solution.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":116,"Q_Id":58717607,"Users Score":1,"Answer":"With a generated client you will be able to make requests to the corresponding REST API. However, you'll need to build your own code\/logic for inserting delays between requests and request queuing. Much of the convenience that Scrapy is providing for you will need to be implemented by you. Or you'll need to find tools\/package that will provide this functionality for you.","Q_Score":0,"Tags":"python","A_Id":58717737,"CreationDate":"2019-11-05T18:43:00.000","Title":"Scheduling \"scraping\" of data from REST APIs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am looking to make a python program in which I can have a sidebar GUI along with an interactive 2d pymunk workspace to the right of it, which is to be docked within the same frame.\nDoes anyone know how I might implement this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":58718972,"Users Score":0,"Answer":"My recommendation is to use pygame as your display. If an object is chosen, you can add it to the pymunk space at the same time as using pymunk to get each body's space and draw it onto the display. This is how I've written my games.","Q_Score":0,"Tags":"python,user-interface,pymunk","A_Id":59110191,"CreationDate":"2019-11-05T20:27:00.000","Title":"Implementing a built in GUI with pymunk and pygame in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have downloaded VPython and am able to use in in my Terminal, but once I try and use it in Spyder it fails to work.\nRunning a simple test of:\nfrom vpython import *\nsphere()\nI get a console read out that says:\nModuleNotFoundError: No module named 'vpython'\nThis seems weird to me since I am able to get this working in a terminal window. I have tried substituting the \"vpython\" with \"visual\" and I get the same result.\nHow can I fix this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":145,"Q_Id":58722128,"Users Score":0,"Answer":"There were problems with using the vpython module with Spyder, but the latest version 7.5.2 has addressed those problems. If you are using Anaconda (recommended), here is how to update to the latest version of vpython:\nTo update to later versions of vpython use\n     \"conda update -c vpython vpython\" or \"pip install vpython --upgrade\".","Q_Score":0,"Tags":"python,terminal,vpython","A_Id":58893708,"CreationDate":"2019-11-06T02:11:00.000","Title":"VPython not working with Spyder 3.3.6 for Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently need to work on a flask project, to do that, I need to activate a virtual environment for my project. Virtual environment has already been installed at Python37\\Scripts folder, but each time I want to activate the virtual environment by running C:\\Users\\user\\Desktop\\flask-intro\\venv\\Scripts>activate. <flask-intro is my project folder>. I get an error that says 'activate' is not recognized as an internal or external command, operable program, or batch file. What could be the issue.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":506,"Q_Id":58723036,"Users Score":2,"Answer":"To Create and activate a Virtual Env for project on windows, navigate to your project directory on your command line window and run the following commands\n\n\nTo create - python -m venv your-env-name\nTo activate - your-env-name\\Scripts\\activate.bat","Q_Score":0,"Tags":"python,python-3.x,windows,flask,virtualenv","A_Id":58725343,"CreationDate":"2019-11-06T04:18:00.000","Title":"How do I activate a virtual environment in Windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to denoise my signal using discrete wavelet transform in python using pywt package. But i cannot define what is threshold value that i should set in pywt.threshold() function\nI have no idea what the best threshold value that should be set in order to reconstruct a signal with minimal noise\nI used ordinary code:\npywt.threshold(mysignal, threshold, 'soft')\nyes i am intended to do soft thresholding\nI want to know if the threshold value could be determined by looking to my signal or from the other way","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":956,"Q_Id":58725295,"Users Score":2,"Answer":"There are some helpful graphics on pywt webpage that help visualize what these thresholds are and what they do.\nThe threshold applies to the coefficients as opposed to your raw signal.  So for denoising, this will typically be the last couple of entries returned by pywt.wavedec that will need to be zeroed\/thresholded.\nI could initial guess is the 0.5*np.std of each coefficeint level you want to threshold.","Q_Score":3,"Tags":"python,wavelet","A_Id":58730741,"CreationDate":"2019-11-06T07:45:00.000","Title":"How to set a threshold value from signal to be processed in wavelet thresholding in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the code provided by tensorlfow tutorial for CycleGAN, they have trained discriminator and generator simultaneously.\n\n\n    def train_step(real_x, real_y):\n      # persistent is set to True because the tape is used more than\n      # once to calculate the gradients.\n      with tf.GradientTape(persistent=True) as tape:\n        # Generator G translates X -> Y\n        # Generator F translates Y -> X.\n\n        fake_y = generator_g(real_x, training=True)\n        cycled_x = generator_f(fake_y, training=True)\n\n        fake_x = generator_f(real_y, training=True)\n        cycled_y = generator_g(fake_x, training=True)\n\n        # same_x and same_y are used for identity loss.\n        same_x = generator_f(real_x, training=True)\n        same_y = generator_g(real_y, training=True)\n\n        disc_real_x = discriminator_x(real_x, training=True)\n        disc_real_y = discriminator_y(real_y, training=True)\n\n        disc_fake_x = discriminator_x(fake_x, training=True)\n        disc_fake_y = discriminator_y(fake_y, training=True)\n\n        # calculate the loss\n        gen_g_loss = generator_loss(disc_fake_y)\n        gen_f_loss = generator_loss(disc_fake_x)\n\n        total_cycle_loss = calc_cycle_loss(real_x, cycled_x) + calc_cycle_loss(real_y, cycled_y)\n\n        # Total generator loss = adversarial loss + cycle loss\n        total_gen_g_loss = gen_g_loss + total_cycle_loss + identity_loss(real_y, same_y)\n        total_gen_f_loss = gen_f_loss + total_cycle_loss + identity_loss(real_x, same_x)\n\n        disc_x_loss = discriminator_loss(disc_real_x, disc_fake_x)\n        disc_y_loss = discriminator_loss(disc_real_y, disc_fake_y)\n\n      # Calculate the gradients for generator and discriminator\n      generator_g_gradients = tape.gradient(total_gen_g_loss, \n                                            generator_g.trainable_variables)\n      generator_f_gradients = tape.gradient(total_gen_f_loss, \n                                            generator_f.trainable_variables)\n\n      discriminator_x_gradients = tape.gradient(disc_x_loss, \n                                                discriminator_x.trainable_variables)\n      discriminator_y_gradients = tape.gradient(disc_y_loss, \n                                                discriminator_y.trainable_variables)\n\n      # Apply the gradients to the optimizer\n      generator_g_optimizer.apply_gradients(zip(generator_g_gradients, \n                                                generator_g.trainable_variables))\n\n      generator_f_optimizer.apply_gradients(zip(generator_f_gradients, \n                                                generator_f.trainable_variables))\n\n      discriminator_x_optimizer.apply_gradients(zip(discriminator_x_gradients,\n                                                    discriminator_x.trainable_variables))\n\n      discriminator_y_optimizer.apply_gradients(zip(discriminator_y_gradients,\n                                                    discriminator_y.trainable_variables))\n\n\nBut while training a GAN network we need to stop training discriminator when we are training generator network.\nWhat's the benefit of using it?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":413,"Q_Id":58726483,"Users Score":0,"Answer":"For the training to happen in an adversarial way the gradients of the discriminator and generator networks should be updated separately. The discriminator becomes stronger because generator produces more realistic samples and vise versa. If you update these networks together the \"adversarial\" training is not happening - to the best of my knowledge you are unlikely to obtain pleasing synthetic samples this way.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,generative-adversarial-network","A_Id":65612208,"CreationDate":"2019-11-06T09:06:00.000","Title":"Should we stop training discriminator while training generator in CycleGAN tutorial?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the code provided by tensorlfow tutorial for CycleGAN, they have trained discriminator and generator simultaneously.\n\n\n    def train_step(real_x, real_y):\n      # persistent is set to True because the tape is used more than\n      # once to calculate the gradients.\n      with tf.GradientTape(persistent=True) as tape:\n        # Generator G translates X -> Y\n        # Generator F translates Y -> X.\n\n        fake_y = generator_g(real_x, training=True)\n        cycled_x = generator_f(fake_y, training=True)\n\n        fake_x = generator_f(real_y, training=True)\n        cycled_y = generator_g(fake_x, training=True)\n\n        # same_x and same_y are used for identity loss.\n        same_x = generator_f(real_x, training=True)\n        same_y = generator_g(real_y, training=True)\n\n        disc_real_x = discriminator_x(real_x, training=True)\n        disc_real_y = discriminator_y(real_y, training=True)\n\n        disc_fake_x = discriminator_x(fake_x, training=True)\n        disc_fake_y = discriminator_y(fake_y, training=True)\n\n        # calculate the loss\n        gen_g_loss = generator_loss(disc_fake_y)\n        gen_f_loss = generator_loss(disc_fake_x)\n\n        total_cycle_loss = calc_cycle_loss(real_x, cycled_x) + calc_cycle_loss(real_y, cycled_y)\n\n        # Total generator loss = adversarial loss + cycle loss\n        total_gen_g_loss = gen_g_loss + total_cycle_loss + identity_loss(real_y, same_y)\n        total_gen_f_loss = gen_f_loss + total_cycle_loss + identity_loss(real_x, same_x)\n\n        disc_x_loss = discriminator_loss(disc_real_x, disc_fake_x)\n        disc_y_loss = discriminator_loss(disc_real_y, disc_fake_y)\n\n      # Calculate the gradients for generator and discriminator\n      generator_g_gradients = tape.gradient(total_gen_g_loss, \n                                            generator_g.trainable_variables)\n      generator_f_gradients = tape.gradient(total_gen_f_loss, \n                                            generator_f.trainable_variables)\n\n      discriminator_x_gradients = tape.gradient(disc_x_loss, \n                                                discriminator_x.trainable_variables)\n      discriminator_y_gradients = tape.gradient(disc_y_loss, \n                                                discriminator_y.trainable_variables)\n\n      # Apply the gradients to the optimizer\n      generator_g_optimizer.apply_gradients(zip(generator_g_gradients, \n                                                generator_g.trainable_variables))\n\n      generator_f_optimizer.apply_gradients(zip(generator_f_gradients, \n                                                generator_f.trainable_variables))\n\n      discriminator_x_optimizer.apply_gradients(zip(discriminator_x_gradients,\n                                                    discriminator_x.trainable_variables))\n\n      discriminator_y_optimizer.apply_gradients(zip(discriminator_y_gradients,\n                                                    discriminator_y.trainable_variables))\n\n\nBut while training a GAN network we need to stop training discriminator when we are training generator network.\nWhat's the benefit of using it?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":413,"Q_Id":58726483,"Users Score":0,"Answer":"In the GANs, you don't stop training D or G. They are trained simultaneously.\nHere they first calculate the gradient values for each network (not to change D or G before calculating the current loss), then update the weights using those.\nIt's not clear in your question, what's the benefit of what?","Q_Score":0,"Tags":"python,tensorflow,deep-learning,generative-adversarial-network","A_Id":58727960,"CreationDate":"2019-11-06T09:06:00.000","Title":"Should we stop training discriminator while training generator in CycleGAN tutorial?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to import stumpy, but I'm always getting an a SyntaxError:\nimport stumpy\nTraceback (most recent call last):\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\IPython\\core\\interactiveshell.py\", line 3296, in run_code\n    exec(code_obj, self.user_global_ns, self.user_ns)\nFile \"\", line 1, in \n    import stumpy\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\stumpy__init__.py\", line 38, in \n    module = ast.parse(file_contents)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\ast.py\", line 35, in parse\n    return compile(source, filename, mode, PyCF_ONLY_AST)\nFile \"unknown\", line 29\n    \u00ce\u00a3_T,\n       ^\nSyntaxError: invalid character in identifier","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":184,"Q_Id":58726939,"Users Score":1,"Answer":"Issue solved. Fixed in stumpy version 1.2.2 !","Q_Score":0,"Tags":"python-3.x,syntax-error,stumpy","A_Id":58734902,"CreationDate":"2019-11-06T09:32:00.000","Title":"I get a SyntaxError in \"parse\" when importing stumpy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a telegram bot , i have a code in python the publish links to different channels.\nIs there any way to know who press the link , i tried with get_updates , but it only shows messages.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":157,"Q_Id":58728252,"Users Score":0,"Answer":"Text and InlineKeyboardButton link clicks are not tracked by Telegram. You can try using third-party services (url-shorteners) to track your links.\nNOTE: this feature is not declared by Telegram. In my experience, Telegram did not send Update about the same actions.","Q_Score":1,"Tags":"python-3.x,api,telegram","A_Id":58731036,"CreationDate":"2019-11-06T10:42:00.000","Title":"Telegram API get updates 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 normally understand how slices behave to the left and right of the assignment operator.\nHowever, I've seen this in the Python (3.8.0) manual and trying to figure out what I'm missing.\n\nclear the list by replacing all the elements with an empty list\nletters[:] = []\n\nHow's that different from just letters = []?\n(It's not easy to search for [:] as stackoverflow thinks you're looking for a tag.  So, if there is already an answer I couldn't locate it.)\nI see some rather irrelevant answers.  So, to hopefully clarity, the question is not about what the [:] slice means, rather about assigning the empty list to one.","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":1065,"Q_Id":58729523,"Users Score":5,"Answer":"var = [] is an assignment to the name var. It replaces what, if anything, var used to refer to with [].\nvar[:] = [] is a method call in disguise: var.__setitem__(slice(), []). It replaces the elements referred to by the slice (in this case, all of them) with the elements in [], effectively emptying the list without replacing it altogether.\nIncidentally, you can use var.clear() to accomplish the same thing; slice assignment more generally lets you replace one range of values with another, possibly longer or shorter, range of values.","Q_Score":9,"Tags":"python,python-3.x","A_Id":58729828,"CreationDate":"2019-11-06T11:50:00.000","Title":"How is `var[:] = []` different from `var = []`?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just learned that you can handle missing data\/ NaN with imputation and interpolation, what i just found is interpolation is a type of estimation, a method of constructing new data points within the range of a discrete set of known data points while imputation is replacing the missing data of the mean of the column. But is there any differences more than that? When is the best practice to use each of them?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4779,"Q_Id":58731044,"Users Score":2,"Answer":"I will answer the second part of your question i.e. when to use what.\nWe use both techniques depending upon the use case. \nImputation:\nIf you are given a dataset of patients with a disease (say Pneumonia) and there is a feature called body temperature. So, if there are null values for this feature then you can replace it by average value i.e. Imputation.\nInterpolation:\nIf you are given a dataset of the share price of a company, you know that every Saturday and Sunday are off. So those are missing values. Now, these values can be filled by the average of Friday value and Monday value i.e. Interpolation.\nSo, you can choose the technique depending upon the use case.","Q_Score":6,"Tags":"python-3.x,pandas","A_Id":62236017,"CreationDate":"2019-11-06T13:14:00.000","Title":"What is the difference between interpolation and imputation?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I trained a object detection model through vision in GCP, How can i use that model in normal tensorflow object detection api provided by google in GitHub?\nIt gives 3 options for exporting the model which one to use & how?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":58731323,"Users Score":0,"Answer":"You need to save the model in the local drive from the cloud and load this model into the object detection api, the function load_model usually downloads pre-trained model from URL, you need to give the path of the local saved model here. The API that you are looking for is tf.saved_model.load, also update the path for labels correctly in PATH_TO_LABELS.","Q_Score":0,"Tags":"python-3.x,tensorflow,google-cloud-platform,object-detection-api","A_Id":58952487,"CreationDate":"2019-11-06T13:30:00.000","Title":"How to use GCP vision trained model in Object Detection API","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i installed pillow from cmd : \npip install pillow\nand after that i went to import it :\nfrom PIL import Image\nbut i found  an error : \nModuleNotFoundError: No module named 'Pillow'\nplease help !!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":202,"Q_Id":58732046,"Users Score":0,"Answer":"I had the same problem. I tried Installing Pillow from my 'manages packages' in my thonny  and my problem was solved.","Q_Score":0,"Tags":"python,django,python-imaging-library","A_Id":69597487,"CreationDate":"2019-11-06T14:11:00.000","Title":"ModuleNotFoundError: No module named 'Pillow'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Visual Studio 1.39.2 on Windows 10. I'm very happy that you can run Jupyter Notebook natively through VS Code as of October this year (2019), but one thing I don't get right is how to set my PYTHONPATH prior to booting up a local Jupyter server.\nWhat I want is to be able to import a certain module which is located in another folder (because the module is compiled from C++ code). When I run a normal Python debugging session, I found out that I can set environment variables of the integrated terminal, via the setting terminal.integrated.env.linux. Thus, I set my PYTHNPATH through this option when debugging as normal. But when running a Jupyter Notebook, the local Jupyter server doesn't seem to run in the integrated terminal (at least not from what I can see), so it doesn't have the PYTHONPATH set.\nMy question is then, how can I automatically have the PYTHONPATH set for my local Jupyter Notebook servers in VS Code?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":5291,"Q_Id":58735256,"Users Score":3,"Answer":"I'm a developer on this extension. If you have a specific path for module resolution we provide a setting for the Jupyter features called:\nPython->Data Science: Run Startup Commands\nThat setting will run a series of python instructions in any Jupyter session context when starting up. In that setting you could just append that path that you need to sys.path directly and then it will run and add that path every time you start up a notebook or an Interactive Window session.","Q_Score":13,"Tags":"python,visual-studio-code,jupyter-notebook,pythonpath","A_Id":58774551,"CreationDate":"2019-11-06T17:07:00.000","Title":"Set PYTHONPATH for local Jupyter Notebook in VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"sometimes the python linter i use (either pylint or mypy) highlight things that aren't an issue. \nid like to know if it is possible to ignore this specific highlight. \ni just want to remove the highlight on specific places is it possible ? \n(im not asking to completely remove the linter, just remove the highlight at some places that's all)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":293,"Q_Id":58735451,"Users Score":0,"Answer":"In general the # noqa command should disable linters for that line, but each tool has their own specific way as well. For instance, mypy supports # type: ignore.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":58739214,"CreationDate":"2019-11-06T17:20:00.000","Title":"How to remove a specific linting highlight in VS Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Windows 10 (all commands run as administrator). I created an environment called myenv. Then I used \n\nconda env remove -n myenv\n\nNow, if I try\n\nconda info --envs\n\nI only see the base environment. However, if I try\n\nconda activate myenv\n\nI'm still able to activate it! I think because under the folder envs, there is still a folder with the name myenv there which doesn't get deleted.\nHow do I delete the environment for good?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7022,"Q_Id":58736579,"Users Score":3,"Answer":"Command-line options can only go so far, unless you get very specific; perhaps the simplest approach is to delete things manually:\n\nLocate Anaconda folder; I'll use \"D:\\Anaconda\\\"\nIn envs, delete environment of interest: \"D:\\Anaconda\\envs\\myenv\"\n\nAre you done? Not quite; even while in myenv, conda will still sometimes install packages to the base environment, in \"D:\\Anaconda\\pkgs\\\"; thus, to clean traces of myenv,\n\nDelete packages installed to myenv that ended up in \"D:\\Anaconda\\pkgs\\\"\n(If above don't suffice) Anaconda Navigator -> Environments -> myenv -> Remove\n(If above don't suffice) Likely corrupted Anaconda; make note of installed packages, completely uninstall Anaconda, reinstall.\n\nNote: step 3 is redundant for the goal of simply removing myenv, but it's recommended to minimize future package conflicts.","Q_Score":5,"Tags":"python,conda","A_Id":58736677,"CreationDate":"2019-11-06T18:38:00.000","Title":"Conda - unable to completely delete environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Windows 10 (all commands run as administrator). I created an environment called myenv. Then I used \n\nconda env remove -n myenv\n\nNow, if I try\n\nconda info --envs\n\nI only see the base environment. However, if I try\n\nconda activate myenv\n\nI'm still able to activate it! I think because under the folder envs, there is still a folder with the name myenv there which doesn't get deleted.\nHow do I delete the environment for good?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7022,"Q_Id":58736579,"Users Score":0,"Answer":"In addition to the first command in the question posted, I had to complete one additional step to completely remove the environment. I had to go to the folder where the environment was stored (e.g. C:\\Users*username*.conda\\envs\\ on a windows machine) and remove the folder with the same name as the environment I deleted. After this second step, I was able to reuse the environment name without any errors.","Q_Score":5,"Tags":"python,conda","A_Id":70760569,"CreationDate":"2019-11-06T18:38:00.000","Title":"Conda - unable to completely delete environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to create a neuroevolution project using python and tensorflow\/keras but I couldn't find any good way of mutating the neural network.\nI am aware that there are librarys like NEAT, but I wanted to try and code it myself.\nWould appreciate it if anyone can tell me something.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":181,"Q_Id":58737140,"Users Score":0,"Answer":"Your question is a little bit too vague, but I would assume that coding your own evolutionary algorithm shouldn\u2019t be too difficult for you given what you have done with neural networks so far.\nA good starting point for you would be to research the following EA concepts\u2026\n\nEncoding.\nFitness.\nCrossover and\/or Mutation.","Q_Score":0,"Tags":"python,tensorflow,keras,evolutionary-algorithm","A_Id":58738193,"CreationDate":"2019-11-06T19:18:00.000","Title":"Is there a way to mutate a neural network in tensorflow\/keras?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote several xslt files. Within each file, I have multiple templates to modify strings, so I am trying to find a way to create unit tests for these templates. Is there is a way to test xslt files in PyCharm with pytest?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":58737917,"Users Score":0,"Answer":"Answering this for anyone else who wants to test xslt files in python using pytest: I am using lxml.etree to parse the a sample XML file and the xslt file I have, then using lxml.etree.XSLT and transform() to transform the html output into an etree object. I can compare what I expect to be within certain tags to what is actually there based on the xslt transformation.","Q_Score":0,"Tags":"python,unit-testing,xslt,pycharm,pytest","A_Id":58882233,"CreationDate":"2019-11-06T20:21:00.000","Title":"Unit testing XSLT files 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":"Currently, the codes are compiled to .pyd files using Cython so I guess they are protected from people who want to see the source code.\nHowever, the problem is that we would like them (the cythonized code) to be unusable without appropriate license files just like any commercial software.\nIs there a way for a source code to check for available license files before proceeding to the actual execution? or perhaps any other way to check the user's PC information before allowing execution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":106,"Q_Id":58740852,"Users Score":0,"Answer":"I don't know what sort of license you are using, but if it's in something saved in a text file, you can add an if statement to you code that checks where or not the file exists. Additionally you could add hashing to compare a digest of the official license to the file save on the user's computer.\nPython does not have the facilities built-in to enforce copy protection.","Q_Score":0,"Tags":"python-3.x,licensing","A_Id":58741680,"CreationDate":"2019-11-07T01:52:00.000","Title":"How can you lock python code for users without license?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a text adventure with python and the issue i am having is getting spyder to open a interactive cmd window. so far i have tried os.systems('cmd \/ k') to try and open this which it did but i could not get any code to run and kept getting an app could not run this file error. my current code runs off a import module that pulls the actual adventure from another source code file. how can i make it to where only one file runs and opens the cmd window to play the text adventure?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":378,"Q_Id":58741042,"Users Score":1,"Answer":"(Spyder maintainer here) Cmd windows are hidden by default because there are some packages that open lot of them while running code (e.g. pyomo).\nTo change this behavior, you need to go to\nTools > Preferences > IPython console > Advanced settings > Windows adjustments\nand deactivate the option called Hide command line output windows generated by the subprocess module.","Q_Score":0,"Tags":"python-3.x,spyder","A_Id":58758235,"CreationDate":"2019-11-07T02:14:00.000","Title":"Script that opens cmd from spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created script to upload data in every 10 minutes. it works but after uploading several times, there is 1 minute gap.\n It starts like that\n2019\/10\/01 10:00 2019\/10\/01 10:10\nAfter running script several times it show below result\n2019\/10\/01 19:01 2019\/10\/01 19:11\nHow to modify it always record and upload exactly in 10:00 minutes?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":22,"Q_Id":58741173,"Users Score":0,"Answer":"Please post here your actual code (just the part which triggers the 10 to 10 min thing), you may be missing something","Q_Score":0,"Tags":"python,file,file-upload","A_Id":58741223,"CreationDate":"2019-11-07T02:35:00.000","Title":"Script time leakage","Data Science and Machine Learning":0,"Database and SQL":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 setting up a multithreaded python server, and I want to remove threads that have been inactive for n seconds.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":166,"Q_Id":58742218,"Users Score":0,"Answer":"The approach I can think of for this situation is that, you must have a daemon that would handle such threads. As much as possible, those threads should have been spawned by that daemon for easier thread tracking, as well as handling the timer for such threads.\nIf this is not the case (a separate program spawned the thread), you must have established a naming (or tracking) standard enabling you to determine which threads are under your program's scope, so they can be terminated by the daemon accordingly.","Q_Score":0,"Tags":"python,multithreading,sockets","A_Id":58742274,"CreationDate":"2019-11-07T05:00:00.000","Title":"How do I stop a thread, if it becomes inactive after n seconds","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just started using PIPENV and I found it amazing as I have never used virtual environments before. However, I am still confused with the PIPENV file and the lock file. I understand through videos that both files are essential for PIPENV.\nI have two questions regarding the two files:\n1) If I wish to deploy it on my friends laptop (lets take him as the end user), which of those two files do I need to pass him and what are their purposes?\n2) If I wish to deploy it on my other friends laptop (lets take him as my project partner) who requires development libraries, which of those two files do I need to pass him and what are their purposes?\n3) What is the difference between 'freeze' and 'lock'?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":520,"Q_Id":58743814,"Users Score":2,"Answer":"Pipfile is the file describing which dependencies are directly needed by your application.\nPipfile.lock is generated from Pipfile and describes everything that needs to be installed for your application to work, i.e. your direct dependencies, their dependencies etc.\nAnswering your questions 1 and 2, you should ship both Pipfile and Pipfile.lock in both scenarios.\nHowever, the installation process will be slightly different.\nAn end user would need to install the dependencies with pipenv install --deploy to make sure that Pipfile.lock is fresh -- the installation will fail if the lockfile is out of date.\nAnother developer of your project might install the dependencies with plain pipenv install. If Pipfile.lock is out of date, it will be regenerated during installation.\n\nAnswering your question 3: freeze is a pip command, not a pipenv command.\npip freeze prints current contents of your virtual environment in a text format, and its output is typically saved in a file named requirements.txt. If your virtual environment is somehow out of date, its contents will still be output as-is.\npipenv lock builds and outputs the project's dependency list, whether or not they are currently installed. It generates the lockfile under the name Pipfile.lock for further usage with pipenv.","Q_Score":0,"Tags":"python,python-3.x,pip,pipenv","A_Id":58746721,"CreationDate":"2019-11-07T07:24:00.000","Title":"Pipenv & lock file - depolyment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm developing something like an API (more like a communications server? Idk what to call it!) to receive data from a POST message from an external app. Basically this other app will encounter an error, then it sends an error ID in a post message to my API, then I send off an email to the affected account. \nMy question is how do I handle this in Django without any form of UI or forms? I want this to pretty much be done quietly in the background. At most a confirmation screen that the email is sent.\nI'm using a LAMP stack with Python\/Django instead of PHP.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":250,"Q_Id":58744425,"Users Score":1,"Answer":"A Django view doesn't have to use a form. Everything that was POSTed is there in request.POST which you may access directly. (I commonly do this to see which of multiple submit buttons was clicked).  \nForms are a good framework for validating the data that was POSTed, but you don't have to use their abilities to generate content for rendering. If the data is validated in the front-end, you can use the form validation framework to check against front-end coding errors and malicious POSTs not from your web page, and simply process the cleaned_data if form.is_valid() and do \"Something went wrong\" if it didn't (which you believe to be impossible, modulo front-end bugs or malice).","Q_Score":0,"Tags":"python,django,apache,post,lamp","A_Id":58747204,"CreationDate":"2019-11-07T08:11:00.000","Title":"Retrieving information from a POST without forms in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"on pyfpdf documentation it is said that it is possible to specify a format while adding a page (fpdf.add_page(orientation = '', format = '', same = False)) but it gives me an error when specifying a format.\nerror:\n\npdf.add_page(format = (1000,100)) TypeError: add_page() got an\n  unexpected keyword argument 'format'\n\ni've installed pyfpdf via pip install and setup.py install but it doesnt work in both ways\nhow can i solve this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1170,"Q_Id":58744527,"Users Score":1,"Answer":"Your problem is that two packages of pypdf exist, fpdf and fpdf2. They both use from fpdf import FPDF, but only fpdf2 has also a format= keyword in the add_page() method.\nSo you need to install the fpdf2 package.","Q_Score":2,"Tags":"python-3.x,pdf,fpdf","A_Id":72024404,"CreationDate":"2019-11-07T08:18:00.000","Title":"PyFPDF can't add page while specifying the size","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python program named read.py which reads data from serial communication every second, and  another python program called calculate.py which has to take the real time values from read.py.\nUsing subprocess.popen('read.py',shell=True) I am able to run read.py from calculate.py\nMay I know how to read or use the value from read.py in calculate.py?\nSince the value changes every second I am confused how to proceed like, saving value in registers or producer consumer type, etc.\nfor example : from import datetime \nwhen ever strftime %s is used, the second value is given \nhow to use the same technique to use variable from another script?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":257,"Q_Id":58747649,"Users Score":1,"Answer":"I can suggest writing values to a .txt file for later reading","Q_Score":2,"Tags":"python,raspberry-pi,subprocess","A_Id":58748058,"CreationDate":"2019-11-07T11:18:00.000","Title":"Sharing variables between Python subprocesses","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm writing a Python program that runs under Mac OS and Linux, and I want to run some logic in a multiprocessing.Process. That logic will take a while, and I want it to continue running even after my program is finished and has exited. i.e., I want the main process to not wait for the auxiliary process to finish. I want the main process to exit as soon as it's finished.\nI made a few experiments, and it seems that this behavior is the default when using subprocess, but I can't make it happen using multiprocessing.Process, even when I run set_start_method('spawn').\nDo you know of a way to get multiprocessing.Process to behave this way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":223,"Q_Id":58750861,"Users Score":0,"Answer":"Looks like starting a new process, and then calling os.fork from it does the trick.","Q_Score":6,"Tags":"python,multiprocessing","A_Id":58767313,"CreationDate":"2019-11-07T14:27:00.000","Title":"Python multiprocessing: Running a process after its parent exited","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How do I redeploy an updated version of the Flask web app in Google App Engine.\nFor example, I have running web app and now there are new features added into it and needs redeployment. How can I do that?\nAlso how to remove the previous version.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":58754736,"Users Score":0,"Answer":"Add --no-promote if you want to deploy without routing service to the latest version deployed.","Q_Score":1,"Tags":"google-app-engine,google-cloud-platform,google-app-engine-python","A_Id":58758010,"CreationDate":"2019-11-07T18:11:00.000","Title":"Redeploying a Flask app in Google App Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have both versions of python 3.7 and 2.7, I am trying to edit some old codes from version 2.7, however, I can only open IDLE from 3.7 version. \nWhat can I do in order to always open IDLE 2.7 with .py archives from that version?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":64,"Q_Id":58756795,"Users Score":1,"Answer":"If on Windows, type default applications on the search bar, then find where the .py extension is and change it to the IDLE version you want.\nAlso, try to Open With any .py file and select the IDLE version you want, before pressing enter to open, make sure you select Use this for all .py extensions. \n(Again, if on Windows)","Q_Score":0,"Tags":"python","A_Id":58766460,"CreationDate":"2019-11-07T20:57:00.000","Title":"IDLE problems with python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a table named as TRENDS, containing around 20k records. I need to manipulate each row of TRENDS table based on the each column value and final output of the row is a string, named insight which is nothing but that manipulated row. And then i need to store that insight into a INSIGHTS table. Along with a insight i am generating 3 more queries which are in three seprate functions. Result of each query is get stored into another table called FACTS along with a insight_id to indicates that these 3 facts belongs to the same insight.\n\nSince the data is in mysql database I used mysql-connector library of python to run on my scripts for retrieval and insertion operations.\n  With each insight and 3 facts i am performing execute() and commit() which is taking 3 sec for one set of record to insert and these is 20k recods in TRENDS table which is taking lot of time to complete.\n\nWhat is the fastest way to solve this problem?\nPlease suggest a better algo if possible.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":58756975,"Users Score":0,"Answer":"We'll be able to provide much more help if you can provide a sample of the data in each table and your desired output. Here are some very general pointers based on what you've said:\n\nThere are a lot of overheads to excuting a query, if you read and write one line at a time you will waste a huge amount of execution time waiting for queries to execute\nBulk operations are much faster, why not read all 20k rows at once then write 20k back, or if that's too demanding on your local system why not do 1000 at a time?\n...or see if you can write a query which completes the entire operation in SQL","Q_Score":0,"Tags":"mysql,sql,python-3.x,cx-oracle,mysql-connector-python","A_Id":58757322,"CreationDate":"2019-11-07T21:13:00.000","Title":"What is the fastest way to implementing algorithm to manipulate and insert sql records?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"PC WIN10\nPycharm 2019.2.4\nInterface: USB\nDMM: Agilent 344010a\nRan the following command from command prompt\nPIP LIST:\npip 19.2.3\nPyVISA 1.4\nSetuptools 41.2.0\nCommands in Pycharm:\nImport pyvisa\nrm = pyvisa.ResourceManager('')\nResponse:\nError: import Pyvisa, ModuleNotFounDERROR: No module named 'pyvisa'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":550,"Q_Id":58757048,"Users Score":0,"Answer":"Have you installed pyvisa in your environment? You can do this by going into Pycharm->Preferences->Project Interpreter and click the \"+\" sign to look for PyVISA and have pip install it for you. You should be able to import it afterwards.","Q_Score":0,"Tags":"python,pyvisa","A_Id":58758667,"CreationDate":"2019-11-07T21:19:00.000","Title":"Pycharm 2019.2.4 does not reconize pyvisa commmand: import pyvisa","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm assuming that the more commits I make to my database, the more put requests I make. Would it be less expensive to commit less frequently (but commit larger queries at a time)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":58757794,"Users Score":0,"Answer":"I am assuming you're either using RDS for MySQL or MySQL-Compatible Aurora; in either case, you're charged based on the number of running hours, storage and I\/O rate, and data transferred OUT of the service (Aurora Serverless pricing is a different story).\nIn RDS, you're not charged by PUT requests, and there is not such a concept with pymysql.\nThe frequency of commits should be primarily driven by your application functional requirements, not cost. Let's break it down to give you a better idea of how each cost variable would relate to each approach (commit big batches less frequently vs. commit small batches more frequently).\n\nRunning hours: Irrelevant, same for both approaches.\nStorage: Irrelevant, you'll probably consume the same amount of storage. The amount of data is constant.\nI\/O rate: There are many factors involved in how the DB engine consumes\/optimizes I\/O. I wouldn't get to this level of granularity.\nData transferred IN: Irrelevant, free for both cases.","Q_Score":0,"Tags":"python,python-3.x,amazon-web-services,amazon-rds,pymysql","A_Id":58760421,"CreationDate":"2019-11-07T22:30:00.000","Title":"Is using connection.commit() from pymysql more frequently to AWS RDS more expensive?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to find the window background color in HEX format. Looking for a solution that works on all platforms... Windows\/Linux\/Mac... \nThe following code print (self.cget('bg')) just prints SystemButtonFace but I'd like to get the actual HEX format. The reason is that I need to use this color as a base to create a new slightly darker color shade.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":783,"Q_Id":58758439,"Users Score":1,"Answer":"The winfo_rgb method on all widgets will accept a color name and return the r, g, and b components as integers in the range of 0-65535 (16 bits). You can then convert those to hex using standard python string formatting.","Q_Score":0,"Tags":"python,tkinter","A_Id":58758652,"CreationDate":"2019-11-07T23:41:00.000","Title":"How can I get HEX or RGB color code of the window background color?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"For a project in school i have to compare two ontologies whose are in RDF formats.\nI can code in python but i'm not against any kind of language.\nMy main question is : Is it possible to compare classes of different RDF files?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":58762441,"Users Score":0,"Answer":"Pedantic note on \"RDF format\", RDF has a number of representations \nincluding ntriples, quads, turtle, rdfxml, notation3 but the\nrepresentation does not matter as they all represent a graph which is \nnone of them.\nShort answer to the question is something like\n yes! of course you can ... you will just probably be wrong.\nBut that is a little misleading, for the formal answer search on \"graph isomorphism\".   \nFor a useful way to start thinking about it consider the\ndifference between two prose documents, which is easy, \nbecause each is an ordered list of items (words). \nEven when they are not identical you can say which parts \nare the same, and which parts are close or really divergent. \nWhen the documents are ontologies they are not an ordered list of items, \nthey are unordered lists of unordered lists of items where the items are allowed different names\/representations in each document. \nSo we punt on the fact it is (nigh) impossible as the ontologies grow larger and find heuristics that allow us to say something useful in the meanwhile. \n\"Semantic Similarity\" the art of judging if two graph fragments\nrepresent the same concept (are these classes the same?).\nIt can use whatever you can afford to bring to bear on the problem.","Q_Score":0,"Tags":"python,linux,rdf,rdfs","A_Id":59146291,"CreationDate":"2019-11-08T07:45:00.000","Title":"How to compare classes within two differents RDF","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a multitude of mature curves (days are plotted on X axis and data is >= 90 days old so the curve is well developed).\nOnce a week I get a new set of data that is anywhere between 0 and 14 days old.\nAll of the data (old and new), when plotted, follows a log curve (in shape) but with different slopes. So some weeks have a higher slope, curve goes higher, some smaller slope, curve is lower. At 90 days all curves flatten. \nFrom the set of \"mature curves\" I need to select the one whose slope matches the best the slope of my newly received date. Also, from the mature curve I then select the Y-value at 90 days and associate it with my \"immature\"\/new curve.\nAny suggestions how to do this? I can seem to find any info. \nThanks much!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":58767395,"Users Score":0,"Answer":"This seems more like a mathematical problem than a coding problem, but I do have a solution.\nIf you want to find how similar two curves are, you can use box-differences or just differences.\nYou calculate or take the y-values of the two curves for each x value shared by both the curves (or, if they share no x-values because, say, one has even and the other odd values, you can interpolate those values).\nThen you take the difference of the two y-values for every x-value.\nThen you sum up those differences for all x-values.\nThe resulting number represents how different the two curves are.\nOptionally, you can square all the values before summing up, but that depends on what definition of \"likeness\" you are using.","Q_Score":0,"Tags":"python","A_Id":58767741,"CreationDate":"2019-11-08T13:21:00.000","Title":"Select a \"mature\" curve that best matches the slope of a new \"immature\" curve","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get the list of installed packages from command prompt.\nPip works fine: it installs \/ uninstalls packages and even shows information about a specific package with the pip show package_name command.\nBut for the pip list command, it outputs nothing: not even an error, just an empty string.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":573,"Q_Id":58768663,"Users Score":0,"Answer":"When you press enter after typing pip list in cmd, it takes some time to display. It depends on your system's performance. Don't close the window, just wait for it to display","Q_Score":0,"Tags":"python,pip","A_Id":58768707,"CreationDate":"2019-11-08T14:41:00.000","Title":"Pip list command outputs nothing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed libboost_python3 and am trying to link it to my program but get this error:\n\/usr\/bin\/ld: cannot find -lboost_python3\nCan anyone help me link to lboost_python3?\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":965,"Q_Id":58771549,"Users Score":1,"Answer":"I could find a solution to this problem in ubuntu. Just add in terminal:\nsudo ln -s \/usr\/lib\/x86_64-linux-gnu\/libboost_python-py35.so \/usr\/lib\/libboost_python3.so","Q_Score":1,"Tags":"python-3.x,caffe,pycaffe","A_Id":58771606,"CreationDate":"2019-11-08T17:51:00.000","Title":"\/usr\/bin\/ld: cannot find -lboost_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":1,"Web Development":0},{"Question":"I have a 2gb text file for filtering out values used by a python program i access infrequently. I do this by loading every line into a set and doing fast contains checks. This was a good idea at first when the file was only a few megabytes in size, but after a year the file has grown, and the initial loading time has become unmanageable even though i have basically unlimited RAM.\nBefore i replace my existing code with a file-based binary search, i wanted to ask if there's any way to use set functionality directly as a file on disk? I know there are tools to store data structures and load them into memory, but the loading part is the problem here.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":67,"Q_Id":58775537,"Users Score":1,"Answer":"How about this as an interim approach until you find a DB or indexed file solution. \n\nDivide the keyword file into multiple files(37), based on the character the keyword starts with. e.g.\n\nkeys_startwith_a.txt \/contains all values starting with 'A' or 'a'\n...\nkeys_startwith_z.txt \/contains all values starting with 'Z' or 'z'\nkeys_startwith_0.txt \/contains all values starting with '0'\n...\nkeys_startwith_9.txt \/contains all values starting with '9'\nkeys_startwith_others.txt \/contains all values starting with any other char\n\nchange the read mechanism for each file as stream. e.g.\n\nio.read(file, buffer=1)\nNow if you want to compare values, you just have to check the char the key starts with and compare against the values in corresponding file. \nWith this\n\nYour file loading is faster(each file footprint should be significantly reduced) and on demand(stream) i.e. only when required\ncomparison is faster since check is against less no of values. \nsince you have unlimited memory, even if all the files are loaded during comparison, it . won't create issues. \nFinally, you can perhaps use threads for even faster loading of files and can pass on the comparison tasks to multiple threads(if required)","Q_Score":3,"Tags":"python","A_Id":58775953,"CreationDate":"2019-11-09T01:14:00.000","Title":"Storing data structure (set) as a file but not loading it into memory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sorry if this is a silly question, I'm still a beginner in Android and couldn't find an answer to my question. I'm making an Android application that sends an input to a server and executes a Python script on that server to process the given input and generates an output. I was successful in sending data from Android client to Python server using SSH. \nI can also use SSH to retrieve the output back to the Android client. However, the Python script takes some time to generate the output, and I can't seem to find a way for the Android client to wait for the Python script to finish generating the output. I was able to do this on internet connection with using Firebase database and have the Python script upload the output into Firebase database and have the Android client listen for changes in database. But I'm looking for a way to do this locally without internet (i.e. Firebase).\nSo is there a way to make my Android application wait for a message from Python to know it has finished with generating the output so it can retrieve it back using SSH or any other way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":58776295,"Users Score":0,"Answer":"Was a protocol what was send a code what was suppost to say if that 2 files are the same. but i do not remember the name. For u will be more easy to send the storage information's in bits (to the device) and after to start that important transfer. when the device will lost the connection will need to compare the real storage memory with the first information's send it and if has not match to ask the user to reconnect to internet or something like that. Maybe is helping until some one will give u the answer.","Q_Score":0,"Tags":"java,python,android","A_Id":58776390,"CreationDate":"2019-11-09T04:01:00.000","Title":"How to make Android app wait for a message from Python on a local server without internet?","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":"please for a while now i've been trying to activate virtual environment for my windows 7 machine; I've run commands like env\\Scripts\\activate where env is the installed virtual environment folder in the project, but each time i run the command, it gives me an error like: activate is not recognized as an internal or external command, operable program or batch file. Please what could be the problem, what should i do?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":108,"Q_Id":58778244,"Users Score":0,"Answer":"Do you have activate.bat inside Scripts folder? If yes, run that. If not, delete everything and run python -m venv env again and let me know what happens. Please note that you may change env to whatever you want.","Q_Score":0,"Tags":"python-3.x,flask,virtual-environment","A_Id":63473476,"CreationDate":"2019-11-09T10:06:00.000","Title":"Activating virtual environment environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'd like to use my own tensorflow 2 \/ keras model with opencv (cv.dnn.readNetFromTensorflow(    bufferModel[, bufferConfig] ). But, I didn't manage to generate the required files : \nbufferModel :   buffer containing the content of the pb file (frozen_inference_graphe)\nbufferConfig : buffer containing the content of the pbtxt file (model configuration file)\nEverything I've found rely on \"freeze_graph.py\" or other solution that only work with tensorflow 1.x. How should I do with tensorflow 2 ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":243,"Q_Id":58780057,"Users Score":0,"Answer":"The .pb file gets generated when using keras.callbacks.ModelCheckpoint().\nHowever, I don't know how to create the .pbtxt file.","Q_Score":2,"Tags":"python,opencv,tensorflow,keras,tensorflow2.0","A_Id":59092212,"CreationDate":"2019-11-09T14:07:00.000","Title":"How to generate frozen_inference_graphe.pb and .pbtxt files with tensorflow 2","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Good morning. I installed backtrader on windows via cmd prompt like this:\npip3 install backtrader\nbut from Spyder Anaconda when I write import backtrader as bt, it returns me:\nModuleNotFoundError: No module named 'backtrader'\ncan anyone help me? thanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1643,"Q_Id":58784147,"Users Score":0,"Answer":"Found your answer  !pip install backtrader","Q_Score":0,"Tags":"python,conda,spyder","A_Id":64108780,"CreationDate":"2019-11-09T22:36:00.000","Title":"Install library backtrader Python in error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i don't have a clue how to install packages but when i copy and paste what websites show, it always comes up with a syntax error\npip3 install cryptography\nSyntaxError: invalid syntax","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":411,"Q_Id":58784178,"Users Score":0,"Answer":"On Windows, you need to make sure your PATH is configured correctly. Pip is a python module usually stored in a subdirectory of Python itself. \nDid you set up the PYTHONPATH environment variable correctly? In your environment variables (Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables) System Variables section, you should have PYTHONPATH pointing to the Python install. (On my machine, this is \"C:\\Users[your user profile]\\AppData\\Local\\Programs\\Python\").\nThen, in the Command Prompt (which you can access by pressing win+r and then typing cmd in the resulting window), you call pip as a module of python:\npython -m pip install cryptography","Q_Score":1,"Tags":"python,windows,pip","A_Id":58784294,"CreationDate":"2019-11-09T22:41:00.000","Title":"How do you use pip to install packages correctly without recieving syntax errors?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have installed the vlc folders from pypi, tried to write the installing code but when I try to import vlc, it says no module named vlc. And when I try to write the pip install python-vlc or pip3 install python-vlc code, it just says syntax error on 'install'. Any tips or more information about installing and importing vlc?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":213,"Q_Id":58784219,"Users Score":0,"Answer":"First of all, you have to make sure how many pythons you have installed in your PC, are they all python 3 or you have it both? \nLet's identify which python you are using in your terminal, python or python3\nThen, check it with which pip,which pip3 and which python if you are using python, which python3 if you are using python3 at your terminal. Make sure your both pip and the python you use are in the same directory.\nRun the pip or pip3 according to the one you used :)","Q_Score":0,"Tags":"python,python-3.x","A_Id":58784273,"CreationDate":"2019-11-09T22:47:00.000","Title":"How to install python 3 vlc properly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say we have a string R of length 20000 (or another arbitrary length). I want to get 8 random non-overlapping sub strings of length k from string R.\nI tried to partition string R into 8 equal length partitions and get the [:k] of each partition but that's not random enough to be used in my application, and the condition of the method to work can not easily be met.\nI wonder if I could use the built-in random package to accomplish the job, but I can't think of a way to do it, how can I do it?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":284,"Q_Id":58784258,"Users Score":0,"Answer":"You could simply run a loop, and inside the loop use the random package to pick a starting index, and extract the substring starting at that index. Keep track of the starting indices that you have used so that you can check that each substring is non-overlapping. As long as k isn't too large, this should work quickly and easily.\nThe reason I mention the size of k is because if it is large enough, then it could be possible to select substrings that don't allow you to find 8 non-overlapping ones. But that only needs to be considered if k is quite large with respect to the length of the original string.","Q_Score":2,"Tags":"python,string,random","A_Id":58784283,"CreationDate":"2019-11-09T22:53:00.000","Title":"Get N random non-overlapping substrings of length K","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't understand python's heapq module. You can push and pop, but it doesn't\nreturn an actual heap object ... So I ask myself, does it recreate the tree every single time\nI push on it? Why is it not giving a heap object? Do you know an alternative to heapq?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":58784379,"Users Score":0,"Answer":"Ok I found that you can do this with: queue.PriorityQueue\nA bit counter intuitive naming, when you search for heap...","Q_Score":0,"Tags":"python-3.x,binary-heap","A_Id":58784472,"CreationDate":"2019-11-09T23:12:00.000","Title":"How to get a heap object (tree) in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I m trying to create an application that captures the feed of one camera, detects the faces in the feed, then takes pictures of them and adds them to the image database. Simultaneously another camera feed will be captured and another neural network will compare the faces in the second camera feed with the face images in the database and then will display the name of the person.\nIdeally, the new face images should be loaded into the neural network model without it completely retraining.\nRight now I'm trying to achieve that with TensorFlow and OpenCV.\nWould a dynamic neural network be possible with TensorFlow?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":58784730,"Users Score":0,"Answer":"As for step two(getting the name of the person), I don't think you would need any retraining to achieve this. \nYou could use Convolutional LSTM or a similar nn. input shape  could be (None,image_dimension_x,y,3) (3 is the color channel, for RGB)\nwhere None would be the current total number of images in the database. It passes all the images in the database into the nn and returns a number as an index.\nOr alternatively, you could use a normal convolution (without the None)and make it output the confidence it has for each image in the database to be the person on camera right now. Then choose the person with the highest confidence.\nI would say the second one is easier and probably better, that's my suggestion anyway.\nHope it helps :)","Q_Score":1,"Tags":"python,tensorflow,deep-learning,image-recognition","A_Id":58798707,"CreationDate":"2019-11-10T00:17:00.000","Title":"Retrain Tensorflow Model on the go","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a notes creator web application in django and I want to save the date and time when a note is created. (i.e. save date and time as soon as 'Submit' button is clicked.) What could be the django statement to do the same ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":218,"Q_Id":58786181,"Users Score":1,"Answer":"Inside your model class, add this:created_at = models.DateTimeField(auto_now_add=True)It assigns current time when object is created.You can retrieve that data in html file by using:\n{{ object.created_at }}","Q_Score":0,"Tags":"python,django","A_Id":58786284,"CreationDate":"2019-11-10T06:07:00.000","Title":"Django statement to save date and time when a button is clicked","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to Django. I am using Python 3.7 with Django 2.2.6.\nMy Django development environment is as the below.\n\nI am using Microsoft Visual Studio Code on a Windows 8.1 computer\nTo give the commands I am using 'DOS Command Prompt' & 'Terminal window' in \nVS Code.\nCreated a virtual environment named myDjango\nCreated a project in the virtual environment named firstProject\nCreated an app named firstApp.\n\nAt the first time I could run the project using >python manage.py runserver\nThen I had to restart my computer.\n\nI was able to go inside the previously created virtual environment using\nworkon myDjango command.\n\nBut my problem is I don't know how to go inside the previously created project 'firstProject' and app 'firstApp' using the 'Command prompt' or using the 'VSCode Terminal window'\nThanks and regards,\nChiranthaka","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2450,"Q_Id":58787889,"Users Score":1,"Answer":"Simply navigate to the folder containing the app you want to manage using the command prompt.\nThe first cd should contain your parent folder.\nThe second cd should contain the folder that has your current project.\nThe third cd should be the specific app you want to work on.\nAfter that, you can use the python manage.py to keep working on your app.","Q_Score":0,"Tags":"python,django,python-3.x","A_Id":68031245,"CreationDate":"2019-11-10T10:49:00.000","Title":"How to run previously created Django Project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Some of my plots have several million lines. I dynamically adjust the alpha value, by the number of lines, so that the outliers more or less disappear, while the most prominent features appear clear. But for some alpha's, the lines just disappear.\nWhat is the smallest valid alpha value for line plots in in matplotlib? And why is there a lower limit?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":418,"Q_Id":58788958,"Users Score":-1,"Answer":"There's no lower limit; the lines just appear to be invisible for very small alpha values.\nIf you draw one line with alpha=0.01 the difference in color is too small for your screen \/ eyes to discern. If you draw 100 lines with a=0.01 on top of each other, you will see them.\nAs for your problem, you can just add a small number to the alpha value of each draw call so that lines that would otherwise have alpha < 0.1 still appear.","Q_Score":0,"Tags":"python,matplotlib","A_Id":58789056,"CreationDate":"2019-11-10T13:06:00.000","Title":"The smallest valid alpha value in matplotlib?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am quite new with pandas (couple of months) and I am starting building up a project that will be based on a pandas data array.\nSuch pandas data array will consist on a table including different kind of words present in a collection of texts (around 100k docs, and around 200 key-words). \nimagine for instance the words \"car\" and the word \"motorbike\" and documents numbered doc1, doc2 etc.\nhow should I go about the arrangement? \na) The name of every column is the doc number and the index the words \"car\" and \"motorbike\" or \nb) the other way around; the index being the docs numbers and the columns head the words?\nI don't have enough insights of pandas in order to be able to foreseen what will the consequences of such choice. And all the code will be based on that decision.\nAs a side note there array is not static, there will be more documents and more words being added to the array every now and again.\nwhat would you recommend? a or b? and why?\nthanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":58789312,"Users Score":1,"Answer":"Generally in pandas, we follow a practice that instances are columns (here doc number) and features are columns (here words). So, prefer to use the approach 'b'.","Q_Score":0,"Tags":"python,pandas,indexing,row,multiple-columns","A_Id":58789387,"CreationDate":"2019-11-10T13:51:00.000","Title":"How to choose python pandas arrangement columns vs rows","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I  have a table with 4 columns filled with integer.  Some of the rows have a value \"null\" as its more than 1000 records with this \"null\" value, how can I delete these rows all at once? I tried the delete method but it requires the index of the row its theres over 1000 rows. Is there as faster way to do it?\nThanks","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1193,"Q_Id":58789936,"Users Score":0,"Answer":"use the 'drop.isnull()' function.","Q_Score":1,"Tags":"python-3.x,jupyter-notebook","A_Id":58818221,"CreationDate":"2019-11-10T15:08:00.000","Title":"How to remove rows from a datascience table in python","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I  have a table with 4 columns filled with integer.  Some of the rows have a value \"null\" as its more than 1000 records with this \"null\" value, how can I delete these rows all at once? I tried the delete method but it requires the index of the row its theres over 1000 rows. Is there as faster way to do it?\nThanks","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1193,"Q_Id":58789936,"Users Score":0,"Answer":"To remove a row in a datascience package:\nname_of_your_table.remove() # number of the row in the bracket","Q_Score":1,"Tags":"python-3.x,jupyter-notebook","A_Id":63076734,"CreationDate":"2019-11-10T15:08:00.000","Title":"How to remove rows from a datascience table in python","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I  have a table with 4 columns filled with integer.  Some of the rows have a value \"null\" as its more than 1000 records with this \"null\" value, how can I delete these rows all at once? I tried the delete method but it requires the index of the row its theres over 1000 rows. Is there as faster way to do it?\nThanks","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1193,"Q_Id":58789936,"Users Score":0,"Answer":"#df is the original dataframe#\n#The '-' operator removes the null values and re-assigns the remaining ones to df#\ndf=idf[-(df['Column'].isnull())]","Q_Score":1,"Tags":"python-3.x,jupyter-notebook","A_Id":66193032,"CreationDate":"2019-11-10T15:08:00.000","Title":"How to remove rows from a datascience table in python","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I  have a table with 4 columns filled with integer.  Some of the rows have a value \"null\" as its more than 1000 records with this \"null\" value, how can I delete these rows all at once? I tried the delete method but it requires the index of the row its theres over 1000 rows. Is there as faster way to do it?\nThanks","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1193,"Q_Id":58789936,"Users Score":0,"Answer":"use dataframe_name.isnull() #To check the is there any missing values in your table.\nuse dataframe_name.isnull.sum() #To get the total number of missing values.\nuse dataframe_name.dropna() # To drop or delete the missing values.","Q_Score":1,"Tags":"python-3.x,jupyter-notebook","A_Id":68397031,"CreationDate":"2019-11-10T15:08:00.000","Title":"How to remove rows from a datascience table in python","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have a question for you\nI'm using the udp socket server using baserequesthandler on python\nI want to protect the server against spoofing - source address changes.\nDoes client_address is the actual ip address of established to server ?\nIf not, how do I get the actual address?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":58790204,"Users Score":0,"Answer":"Authenticate the packets so that you know that every message in session X from source address Y is from the same client.\nBy establishing a shared session key which is then used along with a sequence number to produce a hash of the packet keyed by the (sequence, session_key) pair. Which is then included in every packet. This can be done in both directions protecting both the client and server.\nWhen you receive a packet you use its source address and the session number  to look up the session, then you compute HMAC((sequence, session_key), packet) and check if the MAC field in the message matches. If it doesn't discard the message.\nThis might not be a correct protocol but it is close enough to demonstrate the principle.","Q_Score":0,"Tags":"python,socketserver","A_Id":58790759,"CreationDate":"2019-11-10T15:41:00.000","Title":"python baserequesthandler client address is real established ip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install psycopg2 but \npip install psycopg2  brings to error: command 'gcc' failed with exit status 1\nCommand line tools are installed\nMacOS 10.15","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1518,"Q_Id":58790217,"Users Score":3,"Answer":"This is likely because you don't have the PostgreSQL devel library installed. You have a few options:\n(1) Install the binary with pip install psycopg2-binary\n(2) Install PostgreSQL with HomeBrew: brew install postgresql, then pip install psycopg2.\nYou can probably just install the binary.","Q_Score":2,"Tags":"python,django,postgresql,terminal","A_Id":58793847,"CreationDate":"2019-11-10T15:42:00.000","Title":"Installing psycopg2 command 'gcc' failed with exit status 1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have an image, where four corner points are defined. Now I want to get the pixel values of the region, that is defined by the 4 corners. Problem is, although it is a rectangle, it has a \"slope\", which means neither the two upper corner points nor the lower one are at the same height. How can I still solve this issue?\nI have not found anything for this yet.. I'd appreciate any kind of support! :)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2611,"Q_Id":58790535,"Users Score":0,"Answer":"It is not very easy to iterate through a slanted rectangle. Therefore, what you can do is to rotate the whole image such that the rectangle is parallel to the sides again. \nFor this, you can compute the slope of one side as difference in the y coordinate over the difference in the x coordinate of the corners. The value you get is the slope. The arctangent of the slope is the angle to the horizontal. You need to rotate the image with the opposite (negative) of this value. \nTo make it more efficient, you can crop a bit the image.","Q_Score":2,"Tags":"python,image,opencv","A_Id":58790592,"CreationDate":"2019-11-10T16:14:00.000","Title":"How to get pixel values inside of a rectangle within an image","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I close a server socket while in a s.recv_into() loop from a client, I keep getting 0 from recv_into() infinitely. \nAs I understand, the only way to know a socket is closed was not through the Python socket mechanism itself, but using select \/ poll \/ etc.\nWhat's the rational of not returning -1 when the socket is closed by the other side? Why can't I properly differentiate \"no data currently\" from \"no one there anymore\"?\nEDIT:\nPerhaps the correct question is - why is no exception thrown when using recv(), if the other side terminated the connection?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":588,"Q_Id":58790806,"Users Score":1,"Answer":"If I close a server socket while in a s.recv_into() loop from a client, I keep getting 0 from recv_into() infinitely. \n\nYes, as expected. A closed connection is indicated by 0, not -1.\n\nAs I understand, the only way to know a socket is closed was not through the Python socket mechanism itself, but using select \/ poll \/ etc.\n\nNo, that's not true. Simply calling recv in a non-blocking mode will do the job without involving any selector mechanism. In a non-blocking mode the \"no data yet\" state will be indicated by an appropriate exception (note that you have to inspect that exception, it's not the only case when recv throws). \nHowever this doesn't mean that the peer is still alive (the default TCP timeout is 15 minutes AFAIK). This cannot be reliably detected. The best you can do is to implement some pinging protocol over the wire.\n\nWhat's the rational of not returning -1 when the socket is closed by the other side? \n\nFor syscalls (such as recv) the -1 return code is (typically) reserved for errors. However Python translates these into exceptions (and so AFAIK you will never get -1 in Python). \nAnyway 0 is not an error. It's an information that the other side closed the connection. Perhaps this is a completely valid situation, there's no way for Python (or any other language) to know that.","Q_Score":0,"Tags":"python,sockets,recv","A_Id":58790848,"CreationDate":"2019-11-10T16:45:00.000","Title":"Why won't Python's socket.recv() return -1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install requirements.txt in pycharm, but pip version indicated version 9.0.3 whereas I have 19.3.1. It will not update saying that requirement is already satisfied. \nI've tried upgrading it but it says requirement already satisfied\n\nYou are using pip version 9.0.3, however version 19.3.1 is available.\n  You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n:\\Users\\User\\Documents\\Learn\\Python\\photography>python -m pip install --upgrade pip\n  Requirement already up-to-date: pip in c:\\users\\user\\documents\\learn\\python\\photography\\venv\\lib\\site-packages (19.3.1)","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":554,"Q_Id":58791987,"Users Score":1,"Answer":"Do you have two versions of Python installed? That could be the cause.","Q_Score":0,"Tags":"python,pip","A_Id":58792017,"CreationDate":"2019-11-10T19:03:00.000","Title":"I have pip version 19.3.1 but when installing requirements, it says I have version 9.0.3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install requirements.txt in pycharm, but pip version indicated version 9.0.3 whereas I have 19.3.1. It will not update saying that requirement is already satisfied. \nI've tried upgrading it but it says requirement already satisfied\n\nYou are using pip version 9.0.3, however version 19.3.1 is available.\n  You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n:\\Users\\User\\Documents\\Learn\\Python\\photography>python -m pip install --upgrade pip\n  Requirement already up-to-date: pip in c:\\users\\user\\documents\\learn\\python\\photography\\venv\\lib\\site-packages (19.3.1)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":554,"Q_Id":58791987,"Users Score":0,"Answer":"Your terminal has photography\\venv activated\nI'm guessing Pycharm is not using that virtualenv \nRegardless, the version of pip shouldn't stop you from using a requirements file","Q_Score":0,"Tags":"python,pip","A_Id":58989406,"CreationDate":"2019-11-10T19:03:00.000","Title":"I have pip version 19.3.1 but when installing requirements, it says I have version 9.0.3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Do I need SQLAlchemy if I want to use PostgreSQL with Python Pyramid, but I do not want to use the ORM? Or can I just use the psycopg2 directly? And how to do that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":193,"Q_Id":58792135,"Users Score":0,"Answer":"Even if you do not want to use ORM, you can still use SQLAlchemy's query\nlanguage.\nIf you do not want to use SQLAlchemy, you can certainly use psycopg2 directly. Look into Pyramid cookbook - MongoDB and Pyramid or CouchDB and Pyramid for inspiration.","Q_Score":0,"Tags":"python,postgresql,pyramid","A_Id":58813231,"CreationDate":"2019-11-10T19:22:00.000","Title":"How to use PostgreSQL in Python Pyramid without ORM","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to update my python version to python 3.6 , I am using conda environment therefore used the following command on the terminal :\nconda install python=3.6\nwhile installation I'm encountered with this error : importerror : cannot import name 'secure_write'\nAny help???","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5246,"Q_Id":58792782,"Users Score":0,"Answer":"First I did \npip uninstall jupyter_client\nthen \npip install jupyter_client \nthis helped me fix the error","Q_Score":7,"Tags":"python-3.x","A_Id":62164736,"CreationDate":"2019-11-10T20:46:00.000","Title":"importerror : cannot import name 'secure_write' while updating python in conda evironment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to update my python version to python 3.6 , I am using conda environment therefore used the following command on the terminal :\nconda install python=3.6\nwhile installation I'm encountered with this error : importerror : cannot import name 'secure_write'\nAny help???","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5246,"Q_Id":58792782,"Users Score":0,"Answer":"This made is simple.\nconda install -c conda-forge jupyterlab","Q_Score":7,"Tags":"python-3.x","A_Id":70039830,"CreationDate":"2019-11-10T20:46:00.000","Title":"importerror : cannot import name 'secure_write' while updating python in conda evironment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am following the book explore flask on explore flask site, I am getting this error, I just installed flask-login and import this as following\npip install flask-login\nfrom flask_login import login_required\nI expect to save this normally without any errors, but VS CODE terminal show this error\n\"Unable to import 'flask_login'","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4162,"Q_Id":58793101,"Users Score":1,"Answer":"First, make sure that flask_login was installed successfully by running \"pip list\" in your project directory terminal, If it isn't there then you should install it again \nSecond, if it is there so make sure of any typo mistakes, also you can share that piece of code to check it.","Q_Score":1,"Tags":"python,flask,flask-login","A_Id":58793677,"CreationDate":"2019-11-10T21:30:00.000","Title":"Unable to import flask_login","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I decided yesterday to do a clean install of Mac OS (as in, erase my entire disk and reinstall the OS).\nI am on a Macbook Air 2018. I did a clean install of Mac OS 10.15.1.\nI did this clean install due my previous Python environment being very messy.\nIt was my hope that I could get everything reigned in and installed properly.\nI've started reinstalling my old applications, and took care to make sure nothing was installed in a weird location.\nHowever, when I started setting up VS Code, I noticed that my options for Python interpreters showed 4 options. They are as follows:\n\nPython 2.7.16 64-bit, located in \/usr\/bin\/python\nPython 2.7.16 64-bit, located in \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Resources\/Python.app\/Contents\/MacOS\/Python\nPython 3.7.3 64-bit, located in \/user\/bin\/python\nPython 3.7.3 64-bit, located in \/Library\/Developer\/CommandLineTools\/usr\/bin\/python3\n\nIn terminal, if I enter where python python3\nit returns \n\/usr\/bin\/python \/usr\/bin\/python3.\nHow in the world did python3 get there?\nMy only idea is that it now is included in the Xcode Developer Tools 11.2 package, as I did install that. I cannot find any documentation of this inclusion.\nAny ideas how this got here? More importantly, how do I remove it? I want to use Homebrew for all of my installation needs. Also, why does VS Code show 4 options?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3559,"Q_Id":58793820,"Users Score":3,"Answer":"The command line tool to run the python 2.7 environment is at \/usr\/bin\/python, but the framework and dependencies for it are in \/System. This includes the Python.app bundle, which is just a wrapper for scripts that need to run using the Mac's UI environment.\nAlthough these files are separate executables, it's likely that they point to the same environment.\nEvery MacOS has these.\nCatalina does indeed also include \/usr\/bin\/python3 by default. The first time you run it, the OS will want to download Xcode or the Command line tools to install the 'complete' python3. So these pair are also the same environment.\nI don't think you can easily remove these, due to the security restrictions on system files in Catalina.\nInterestingly, Big Sur still comes with python2 !","Q_Score":2,"Tags":"python,python-3.x,macos","A_Id":58800368,"CreationDate":"2019-11-10T23:16:00.000","Title":"Python 3.7.3 Inadvertently Installed on Mac OS 10.15.1 - Included in Xcode Developer Tools 11.2 Now?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am finished with my project and now I want to put it on my website where people could download it and use it. My project is connected to my MySQL and it works on my machine. On my machine, I can read, and modify my database with python. It obviously, will not work if a person from another country tries to access it. How can I make it so a person from another town, city, or country could access my database and be able to read it?\nI tried using SSH but I feel like it only works on a local network.\nI have not written a single line of code on this matter because I have no clue how to get started. \nI probably know how to read my database on a local network but I have no clue how to access it from anywhere else.\nAny help, tips, or solutions would be great and appreciated. \nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":558,"Q_Id":58794269,"Users Score":0,"Answer":"If I'm understanding correctly, you want to run a MySQL server from your home PC and allow others to connect and access data? Well, you would need to make sure the correct port is forwarded in your router and firewall, default is TCP 3306. Then simply provide the user with your current IP address (could change).\n\nDetermine the correct MySQL Server port being listened on.\nAllow port forwarding on the TCP protocol and the port you determined, default is 3306.\nAllow incoming connections on this port from software firewall if any.\nProvide the user with your current IP Address, Port, and Database name.\nIf you set login credentials, make sure the user has this as well.\nThat's it. The user should be able to connect with the IP Address, Port, Database Name, Username, and Password.","Q_Score":0,"Tags":"mysql,python-3.x,mysql-python,remote-server","A_Id":58794382,"CreationDate":"2019-11-11T00:39:00.000","Title":"How to access MySQL database that is on another machine, located in a different locations (NOT LOCAL) with python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I noticed the other day that generating keys with GPG on a server takes forever which suggests bad entropy? This server is combining RSA and AES encryption with quite large RSA keys (generated elsewhere).\nThe AES key I RSA encrypt (and that is used to encrypt the actual message) are generated with calls to Crypto.Random.new().read(). If the entropy is bad on this server isn't there a risk for compromised encryption? Or is a 32 byte AES and a large RSA key \"good enough\"? (whatever that means)\nI'm using the Crypto python module but can switch to cryptography or GnuPG if that effort improves security. Changing server is also an option.\nIs SSL affected by bad entropy?\nos.urandom() vs Crypto.Random?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":58794533,"Users Score":0,"Answer":"It's unlikely that your server has \"bad entropy\" or insufficient amounts of entropy; especially if your machine is running any other tasks, or has any human input (such as keypresses or mouse movement), even the 'blocking' entropy should be more than sufficient, unless you're asking for extraordinary amounts of random bits.\nI'd check a few other common bottlenecks, including the ping-time to the server, if you have C bindings installed and configured for your python libraries, etc. (In particular, pure python implementations of crypto are notoriously slow.)","Q_Score":0,"Tags":"python,cryptography,aes,rsa,entropy","A_Id":58794550,"CreationDate":"2019-11-11T01:33:00.000","Title":"Handling bad entropy in encryption","Data Science and Machine Learning":0,"Database and SQL":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 using pg_cron to schedule a task which should be repeated every 1 hour.\nI have installed and using this inside a docker environment inside the postgres container.\nAnd I am calling the query to create this job using python from a different container.\nI can see that job is created successfully but is not being executed due to lack of permission since the pg_hba.conf is not set to trust or due to no .pgpass file.\nBut if I enable any of those both, anyone can enter into database by using docker exec and do psql in the container.\nIs there anyway to avoid this security issue??? Since in production environment it should not be allowed for anyone to enter into the database without a password.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":134,"Q_Id":58796008,"Users Score":0,"Answer":"Either keep people from running docker exec on the container or use something else than pg_cron.\nI would feel nervous if random people were allowed to run docker exec on the container with my database or my job scheduler in it.","Q_Score":1,"Tags":"python,postgresql,docker,dockerfile","A_Id":58796832,"CreationDate":"2019-11-11T05:34:00.000","Title":"How do i solve the security problems caused by pg_cron?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have two files. One is interface.py (Tkinter code) that contains the interface of the application. Another file is logic.py. The interface contains a button. What I want is that when I click the button the logic.py file starts its execution. How can I perform this task?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":58797084,"Users Score":0,"Answer":"The easiest way is to use main function inside the file you want to execute, and then to call it (import logic, then Button(command=logic.main).pack()) or to use __import__ or import logic inside the button command function.","Q_Score":1,"Tags":"python,image,tkinter","A_Id":58799979,"CreationDate":"2019-11-11T07:22:00.000","Title":"How to call or execute new file when a button is clicked in tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Having multiple languages to deploy under appengine; I wonder if some kind of private approach could be applied; in order to have it all resides only under a single domain\nFor example, given xyz.com domain setup as wildcard; having a default service, services svc1 and svc2; and a dispatch.yaml mapping *\/svc1\/* to svc1 service and *\/svc2* to svc2 service; how to :\n\nhide all the *.appspot domain ?\nhide the automatic setup of svc1.xyz.com and    svc2.xyz.com ?\n\nIt could be easy for a given service to check the host and redirect to the desired one; but it would have to be done for every services; feels like there a better way\nIt feels a bit messy to have all those auto enopoints opened and unused, the idea would be to have it all under xyz.com\/\n\n-","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":58797322,"Users Score":1,"Answer":"There is no way of hiding all the routes of the .appspot domain. As you probably are aware the dispatch.yaml, only works as a redirect. Probably, you cannot just disable the default domain, since there are a lot of tools like Cloud Tasks, Cron Jobs etc.. that uses that default domain, hitting those endopoints.\nAs for the second question, you cannot hide them, but in case you don't need them, you can overwrite them in the dispatch.yaml to point to some custom made \"not found\" page.","Q_Score":0,"Tags":"google-app-engine,google-app-engine-python,google-appengine-node","A_Id":58798896,"CreationDate":"2019-11-11T07:44:00.000","Title":"Appengine \/ restrict services to only be available under a single domain","Data Science and Machine Learning":0,"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 using the googleapiclient in python to launch VM instances. As part of that I am using the facility to run start up scripts  to install docker and other python packages.\nNow, one thing I would like to do is copy files to this instance ideally during the instance creation stage through python code.\nWhat might be the way to achieve this? Ideally what would work is to be able to detect that the instance has booted and then be able to copy these files.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1085,"Q_Id":58799925,"Users Score":2,"Answer":"If I am hearing you correctly, you want files to be present inside the container that is being executed by Docker in your Compute Engine VM.  Your Startup Script for the Compute Engine is installing docker.\nMy recommendation is not to try and copy those files into the container but instead, have them available on the local file system available to the Compute Engine.  Configure your docker startup to then mount the directory from the Compute Engine into the docker container.  Inside the docker container, you would now have accessibility to the desired files.\nAs for bringing the files into the Compute Engine environment in the first place, we have a number of options.  The core story however will be describing where the files start from in the first place.\nOne common approach is to keep the files that you want copied into the VM in a Google Cloud Storage (GCS) bucket\/folder.  From there, your startup script can use GCS API or the gsutil command to copy the files from the GCS bucket to the local file system.\nAnother thought, and again, this depends on the nature of the files ... is that you can create a GCP disk that simply \"contains\" the files.  When you now create a new Compute Engine instance, that instance could be defined to mount the disk which is shared read-only across all the VM instances.","Q_Score":0,"Tags":"google-cloud-platform,google-compute-engine,google-api-python-client","A_Id":58804004,"CreationDate":"2019-11-11T10:49:00.000","Title":"copy files during GCP instance creation from python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using the googleapiclient in python to launch VM instances. As part of that I am using the facility to run start up scripts  to install docker and other python packages.\nNow, one thing I would like to do is copy files to this instance ideally during the instance creation stage through python code.\nWhat might be the way to achieve this? Ideally what would work is to be able to detect that the instance has booted and then be able to copy these files.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1085,"Q_Id":58799925,"Users Score":1,"Answer":"First of all, I would suggest to use tool like Terraform or Google Deployment Manager to create cloud infrastructure instead of writing custom python code and handling all edge-cases by yourself.\nFor some reason, you can't use above tool and only Python program is an option for you the you can do following:\n1. Create a GCS bucket using python api and put appropriate bucket policy to protect data.\n2. Create a service account which has read permission to above GCS bucket.\n3. Launch VM instance using python API and have your start-up script to install packages and run docker container. Attach above service account which has permission to read files from above GCS bucket.\n3. Have a startup script in your docker container which can run ``gsutil` command to fetch files from GCS bucket and put at the right place.\nHope this helps. \nAgain, if you can use tools like Terraform, that will make things easy.","Q_Score":0,"Tags":"google-cloud-platform,google-compute-engine,google-api-python-client","A_Id":58804892,"CreationDate":"2019-11-11T10:49:00.000","Title":"copy files during GCP instance creation from python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a keras model, which uses custom function for metrics:\nmodel.compile(optimizer = tf.keras.optimizers.Adam(), loss = 'binary_crossentropy', metrics = ['accuracy', roc_auc])\nThe function works fine and model behaves as expected. However, when saving the model via model.save() and then loading it via model.load_model(), I get ValueError: Unknown metric function:roc_auc when running following code: model.predict(X). Interestingly this error does not appear when I run the same command again, through command shell, it only occurs during first run. Is this a bug?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":24,"Q_Id":58801078,"Users Score":1,"Answer":"Do you mean keras.models.load_model(path)? It sounds very strange to have model.load_model(). \nYou are probably missing the argument custom_objects = {'roc_auc': roc_auc} in load_model. Keras cannot create a model if it doesn't know what roc_auc means.","Q_Score":1,"Tags":"python,keras","A_Id":58801419,"CreationDate":"2019-11-11T12:09:00.000","Title":"Error when using loaded Keras classifier with custom metrics function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"It is not disabled by default.\nI have written a spider which consumes almost 2 GB of data per hour. Now I want to save my data consumption, images are of no use for me, so want to make sure they not being fetched.\nGiven that this is a P0 scenario, it should be a simple flag in settings.py but surprisingly from docs I couldn't find any. I found a lot of details about ImagesPipeline, enabling those pipelines, their storage etc, but no flag for people not interested in images. Let me know if I am missing anything.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":492,"Q_Id":58801190,"Users Score":1,"Answer":"Scrapy does not download images unless you explicitly tell it to do it.\nYou can check in the run time logs the URLs that Scrapy downloads. If a image URL does not appear in the logs, it is not being downloaded, even if a webpage that contains images is downloaded.\nWhen you open a downloaded page in a web browser, images are downloaded on the fly by the web browser. They do not come from the downloaded webpage, they are not (usually) embedded in the webpage, the webpage indicates where in the Internet they are, and the web browser downloads them to display them, but Scrapy does not.\nThe only exception would be that images are actually embedded in the HTML code, as base64. This is uncommon, and probably not your case. And when that happens, there is no way you can prevent their download, you cannot download a webpage excluding part of its content.","Q_Score":0,"Tags":"python,python-3.x,web-scraping,scrapy","A_Id":58814419,"CreationDate":"2019-11-11T12:17:00.000","Title":"What's the best way to disable image download in scrapy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can anyone please help me how to open a URL in Chrome browser in Icognito mode, as the URL that i'm trying to open in chrome is giving 404 error but is opening successfully in Icognito.\nPlease guide me what Robot command should be given to open in Icognito mode.\nThank you.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2692,"Q_Id":58801529,"Users Score":1,"Answer":"This should work:\nOpen Browser  |  ${url}  |  Chrome  |  options=add_argument(\"--incognito\")","Q_Score":0,"Tags":"python-2.7,browser,robotframework","A_Id":67016997,"CreationDate":"2019-11-11T12:38:00.000","Title":"How can we open a URL in Chrome Icognito mode using Robot Framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to distribute my python application to the end-user as single-file executable. However, the end-user has the possibility to add functionalities to the application. For this he can write funtions to a python file which is then imported at runtime.\nHowever, if I freeze the Application for distribution, any changes made by the user to the python file afterwards will have no effect.\nHow can I distribute my Application as a more or less single-file executable to the end-user with him still being able to add\/remove functions?\nOr can you give the user the possibility to add functionality in another way than by importing his Python functions at runtime?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":58801572,"Users Score":0,"Answer":"I think there is a misunderstanding of how a programme written in Python is actually executed. If we want to \"import Python code at runtime\" into a programme, this imported Python code would have to be compiled at runtime. If the end-user does not have a Python compiler installed, how should that be possible? Unless your programme effectively contains a Python compiler, I think, what you want to achieve is impossible by design.","Q_Score":0,"Tags":"python,windows,software-distribution","A_Id":58802044,"CreationDate":"2019-11-11T12:40:00.000","Title":"Is there a way to freeze python code only partially?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"i am working on a project where i have to present the Chart \/graph created using matplotlib with python3 into a PDF format. The PDF must carry the data, custom titles along with the chart\/graph. PDF can be multiple page report as well. I know that we can store the matplotlib charts in PDF. But i am looking for any solution if we can achieve Data, chart and custom text in PDF format.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":284,"Q_Id":58802543,"Users Score":0,"Answer":"Even though the question is not very clear. If I have to do what I understand from your question, I will use Jupyter Notebook and save it as PDF. In this notebook, I will have:\n\nExploratory analysis of the data (What data scientists call EDA)\nDiscussion and other mathematical formulas at they may apply to your case\nThe plots\n\nYou can save jupyter notebooks to PDF using nbconvert module in Python.\nIf you don't have it installed on your computer, do so with this command: \npip install nbconvert\nTo save your notebook as a PDF, go to the folder containing your Jupyter notebook file and run the following command:\njupyter nbconvert --to pdf MyNotebook.ipynb","Q_Score":0,"Tags":"python,matplotlib","A_Id":58802847,"CreationDate":"2019-11-11T13:42:00.000","Title":"How to create custom report in PDF using matplotlib and python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Input form in Flask, WTForms, SQLite, TinyMCE.\nThe textarea is replaced by TinyMCE, text entered f.e as paragraph, input saved into SQLite db.\nWhen the entered data is displayed on a page, it renders as <p>Text entered<\/p> instead of just Text entered\nI've tried setting {{ wtf.quick_form(form)|save }} so the content isn't escaped, and verify_html: false, in the TinyMCE script, but to no avail..\nIs there any way to make it so that the entered text is displayed correctly?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":58803638,"Users Score":0,"Answer":"Again, nevermind! I was adding the |save parameter to the wrong function..\nWhat I needed to do was to add to the function that displays the entered text, not on the form generator...\nWhat I did: {{ post.text|safe }}","Q_Score":0,"Tags":"python-3.x,flask,tinymce,jinja2,flask-wtforms","A_Id":58803791,"CreationDate":"2019-11-11T14:48:00.000","Title":"tinymce saves f.e paragraph with inserted text as html, and that renders back as escaped html tag on load from sqlite db in textarea form","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My question may be silly, and I am no expert. What am trying to do is to manipulate the JSON generated by django.core.serializers.serialize .\nI'v searched the web to try and find how to serialize some picked fields in my Model.\nThere is a an argument fields that takes an array of what I want to serialize, but what do I do if I want to add some calculated field that is not stored in the DB?\nI've searched a lot with no results, maybe there is something like a method or a class I don't know of yet that may solve it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":58804217,"Users Score":0,"Answer":"This is just a work around ,I'v managed to use model_to_dict to get a dict object then manipulate it as i want then json.dumps to convert it .\nAm not worried about deserialization as i can manage to do so as in the serialization but however am only doing this so i can get forward in my app , and this is a silly work around , so am not accepting it as an answer ,still waiting for the experts for some more robust solution.","Q_Score":1,"Tags":"python,django,serialization,django-models","A_Id":58809918,"CreationDate":"2019-11-11T15:26:00.000","Title":"Adding none DB fields model to the django serialized JSON","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How can I change the default directory in Spyder when opening a project via Projects > Open Project? Spyder seems to open always the same directory: User Home directory.\nMost of my projects are located in one directory, which is not my home directory. I save there also the copied projects. It would save a few clicks to open a project. In particular, it is nice to have because the number of Recent Projects is limited to 10.\nI tried to change Preferences > Current working directory > the following directory, but this does not have any impact on the Open Project directory.\nIs there a possibility to change it either in GUI, or via configuration files, or registry (without changing the user home directory of course)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":151,"Q_Id":58804373,"Users Score":0,"Answer":"I put a shortcut in my home directory called _shortcut_to_spyder_projects to get to my projects faster.  The leading _ keeps it at the top of the list.","Q_Score":0,"Tags":"python,user-interface,project,spyder","A_Id":68922628,"CreationDate":"2019-11-11T15:35:00.000","Title":"How to change the default directory for Open Project menu in Spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Problem description\nIntroductory remark: For the code have a look below\nLet's say we have a pandas dataframe consisting of 3 columns and 2 rows.\nI'd like to add a 4th column called 'Max_LF' that will consist of an array. The value of the cell is retrieved by having a look at the column 'Max_WD'. For the first row that would be 0.35 which will than be compared to the values in the column 'WD' where 0.35 can be found at the third position. Therefore, the third value of the column 'LF' should be written into the column 'Max_LF'. If the value of 'Max_WD' occures multiple times in 'WD', then all corresponding items of 'LF' should be written into 'Max_LF'.\nFailed attempt\nSo far I had various attemps on first retrieving the index of the item in 'Max_WD' in 'WD'. After potentially retrieving the index the idea was to then get the items of 'LF' via their index:\ndf4['temp_indices'] = [i for i, x in enumerate(df4['WD']) if x == df4['Max_WD']]\nHowever, a ValueError occured:\nraise ValueError('Lengths must match to compare')\nValueError: Lengths must match to compare\nThis is what the example dateframe looks like\ndf = pd.DataFrame(data={'LF': [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]] , 'WD': [[0.28, 0.34, 0.35, 0.18], [0.42, 0.45, 0.45, 0.18], [0.31, 0.21, 0.41, 0.41]], 'Max_WD': [0.35, 0.45, 0.41]})\nThe expected outcome should look like\ndf=pd.DataFrame(data={'LF': [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]] , 'WD': [[0.28, 0.34, 0.35, 0.18], [0.42, 0.45, 0.45, 0.18], [0.31, 0.21, 0.41, 0.41]], 'Max_WD': [0.35, 0.45, 0.41], 'Max_LF': [[3] ,[2,3], [3,4]]})","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1805,"Q_Id":58805531,"Users Score":1,"Answer":"Thanks guys! With your help I was able to solve my problem.\nLike Prince Francis suggested I first did\ndf['temp'] = df.apply(lambda x : [i for i, e in enumerate(x['WD']) if e == x['Max_WD']], axis=1)\nto get the indicees of the 'WD'-values in 'LF'. In a second stept I then could add the actual column 'Max_LF' by doing\ndf['LF_Max'] = df.apply(lambda x: [x['LF'][e] for e in (x['temp'])],axis=1)\nThanks a lot guys!","Q_Score":2,"Tags":"python,pandas,list-comprehension","A_Id":58808296,"CreationDate":"2019-11-11T16:51:00.000","Title":"Adding a column to a pandas dataframe based on other columns","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I read a lot of articles that deal with different NLP classification tasks and I saw that most of them specify in the pre-processing section that they use replacement tokens:  \n\ne.g. We removed and replaced the URLs, emojis and punctuation with replacement tokens: <URL>, <EMOJI>, <PUNCT>.\n\nI am quite new to this domain and I was wondering if there is some special way to deal with this kind of tokens\/tags? Is it necessary to use < > or is this just a way to signal this replacement and for helping the classifier in finding a pattern? \nAny help would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":78,"Q_Id":58806758,"Users Score":1,"Answer":"From what I did, in the pre-processing section, people replace all tokens (chars, morphemes, words) with numbers. These replacement tokens are nothing but numbers as well, <URL> is just a way to present it to humans.","Q_Score":0,"Tags":"python,nlp,text-classification","A_Id":58807256,"CreationDate":"2019-11-11T18:26:00.000","Title":"NLP using replacement tokens","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use pysftp on python, although pysftp is installed I get a Bcrypt ImportError \nSo I uninstalled and re-installed bcrypt, checked the location of the directory spyder is referring to for importing packages, bcrypt exists. Also checked that the   init.py file exists . Checked inside the init.py file that the module _bcrypt exists. Even tried importing bcrypt separately. \nimport bcrypt\nimport pysftp\nimport pysftp\nTraceback (most recent call last):\nFile \"\", line 1, in \n    import pysftp\nFile \"C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda4\\lib\\site-packages\\pysftp__init__.py\", line 12, in \n    import paramiko\nFile \"C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda4\\lib\\site-packages\\paramiko__init__.py\", line 22, in \n    from paramiko.transport import SecurityOptions, Transport\nFile \"C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda4\\lib\\site-packages\\paramiko\\transport.py\", line 90, in \n    from paramiko.ed25519key import Ed25519Key\nFile \"C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda4\\lib\\site-packages\\paramiko\\ed25519key.py\", line 17, in \n    import bcrypt\nFile \"C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda4\\lib\\site-packages\\bcrypt__init__.py\", line 25, in \n    from . import _bcrypt\nImportError: cannot import name '_bcrypt' from 'bcrypt' (C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda4\\lib\\site-packages\\bcrypt__init__.py)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1462,"Q_Id":58807161,"Users Score":0,"Answer":"Reinstalled Anaconda , and there was no issue. The actual solution is still not found.","Q_Score":0,"Tags":"python,bcrypt,pysftp","A_Id":58942736,"CreationDate":"2019-11-11T18:59:00.000","Title":"bcrypt error while trying to import pysftp or paramiko","Data 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 pipeline running on GCP. The entire thing is written using pandas to manipulate CSVs and do some transformations, as well as side inputs from external sources. (It makes use of bigquery and storage APIs). The thing is, it runs on a 32vCPUs\/120GB RAM Compute Engine instance (VM) and it does simple parallel processing with python's multiprocessing library. We are currently thinking about switching to Dataflow, and what I'd like to know is: if I were to implement the same pipeline using Beam's DirectRunner, how should I expect the performance to compare to that of the current implementation? Would it be faster or slower and why? Will the DirectRunner use well all the machine resources or is it limited somehow?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":564,"Q_Id":58809283,"Users Score":2,"Answer":"You question is broad. However, I will try to provide you some inputs. It's hard to compare a DirectRunner and a DataflowRunner. \n\nDirectRunner launches your pipeline on your current VM and use the capability of this only VM. It's your VM, you have to set it up, patch it, take care to free disk\/partition\/logs file, (...)   \nDataflowRunner launches the pipeline to a managed platform. Dataflow, according with its metrics and \"prediction\" (no ML here!) chooses to scale up or down the number of VM to execute as quickly as possible your pipeline. You can set small VM (1 vCPU for example) and Dataflow will spawn a lot of them, or bigger VM and, maybe that dataflow will spawn only 1 because it's enough for the pipeline.\n\nPro tips: the VM bandwidth is limited to 2Gbs per vCPU up to 8 vCPU. Take care of the network bottleneck and choose wisely the VM size (I recommend VM with 4 or 8 vCPU usually) \nOn one side, you have only one VM to manage, on the other side, you only have to set parameters and let Dataflow managing and scaling your pipeline.\nI don't know your growth perspective, but vertical scalability (adding more vCPU\/memory on your single VM) can reach a limit a day. With Dataflow, it's elastic and you don't worry about this; in addition of server management and patching.\nFinally, answer to your question \"faster or slower\", too hard to answer... Dataflow, if it run on several VM, will add network latency, dataflow internal management overhead, but can scale to use more vCPU in parallel at some point of time compare to your current VM. Is your pipeline can leverage of this parallelism or not? Is it solve some of your current bottleneck? Too hard to answer on my side.","Q_Score":1,"Tags":"python,google-cloud-platform,cloud,apache-beam,dataflow","A_Id":58812577,"CreationDate":"2019-11-11T22:02:00.000","Title":"Apache beam DirectRunner vs \"normal\" parallel processes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm running Anaconda 64 bit on Windows 10 and I've encountered a CondaVerificationError when I try installing TensorFlow 2.0 on one of my computers. I believe the error stems from mixing pip installations with conda installations for the same package. I originally installed then uninstalled TensorFlow with pip and then tried installing with conda and now I'm stuck trying to resolve this issue.\n    I've tried reinstalling Anaconda but the issue persists. Thoughts?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":58812244,"Users Score":0,"Answer":"Update:\nI reinstalled TensorFlow 2.0 with pip and even though it successfully installed, I was still facing issues when I tried to run my code. A file called cudart64_100.dll could not be located. I eventually managed to get my TF 2.0 code to run successfully by installing an older version of CUDA. I'm still not sure what the issue is with conda, but I'll settle for the current working version of anaconda.","Q_Score":0,"Tags":"python,windows,tensorflow,pip,conda","A_Id":58844839,"CreationDate":"2019-11-12T04:53:00.000","Title":"TensorFlow CondaVerificationError - Mixing Pip with Conda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was making a subscription payment system from scratch in python in Django. I am using celery-beat for a scheduled task with RabbitMQ as a queue broker. django_celery_beat uses DatabaseScheduler which is causing problems.\n\nTakes a long time to dispatch simple-task to the broker. I was using it to expire users. For some expiration tasks, it took around 60 secs - 150secs. But normally it used to take 100ms to 500ms.\nAnother problem is that, while I re-schedule some task, while it is being written into the database it blocks the scheduler for some bizarre reason and multiple tasks are missed because of that.\n\nI have been looking into Apache Airflow because it is marketed as an industry-standard scheduling solution.\nBut I don't think, it is applicable and feasible for my small project.\nIf you have worked and played with a subscription payment system, can you advise me how to go forward with this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":58812247,"Users Score":0,"Answer":"I have a long winding solution that I implemented for a similar project.\n\nFirst I save the schedule as a model in the database\nNext I have a cron job that gets the entries that need to be run for that day\nThen schedule those jobs as normal Celery jobs by setting the ETA based on the time set in the schedule model.\n\nThis way Celery just runs off the messages from Redis in my case. Try it if don't get a direct answer.","Q_Score":0,"Tags":"python,django,scheduling,subscription,celerybeat","A_Id":58812430,"CreationDate":"2019-11-12T04:54:00.000","Title":"Is there a dynamic scheduling system for better implementation of a subscription based payment system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I want to click on the link from email and download the file in my laptop by using python script. Any one has any idea about this?\nI could see most of the information's which i am seeing in the internet is download the file in linux itself.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":58812527,"Users Score":0,"Answer":"The Instruction to do that:\nWriting a code to do the following:\n\nlogin to your email.\nparse your inbox and locate the specific email.\nparse the html source and locate the url for the download link.\ndownload it by connecting directly to it.","Q_Score":0,"Tags":"python","A_Id":58812603,"CreationDate":"2019-11-12T05:24:00.000","Title":"How to download the file by clicking the link in email by using the 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":"It's my understanding that the Python extension's built-in features, e.g., linting with pylint should work with the default user \/ global settings, and if an alternative linter is preferred, insertion of a full path to the executable is required. \nIn my case, none of the features are working, all emitting 'not installed' error messages, even after using the command palette and responding in the affirmative to the error dialog when asked '... install?'\nDeveloper Tools > Console reveals:\n~\\AppData\\Local\\Programs\\Python\\Python38\\python.exe -c \"import pylint\" ... \n... 'pylint' not installed. \nat f.execModule (c:\\Users\\Moron.vscode\\extensions\\ms-python.python-2019.10.44104\\out\\client\\extension.js:9:41305)\nat async d.run (c:\\Users\\Moron.vscode\\extensions\\ms-python.python-2019.10.44104\\out\\client\\extension.js:1:210891)\nat async d.runLinter (c:\\Users\\Moron.vscode\\extensions\\ms-python.python-2019.10.44104\\out\\client\\extension.js:75:1367669)]\nand the same for autopep8, and down the line.\nIs it necessary to enter full paths to each of the default features' executables in the various settings (global, user, workspace) prior to using them? I've not seen any tutorials that mention this requirement.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":58813875,"Users Score":1,"Answer":"Globally installed tools are not used by default, but instead tools installed that can be executed using Python's -m argument. If you would like to use globally-installed tools then you will need to specify them in your settings, e.g. \"python.linting.pylintPath\". But your best option is to create a virtual environment and install the tools there.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":58828901,"CreationDate":"2019-11-12T07:27:00.000","Title":"Visual Studio Code Python extension: None of the default \/ built-in modules working (pylint, autopep8, etc)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to install the matplotlib package for Python with pip install matplotlib in the command prompt but suddenly the lines get red and the next error appears:\nERROR: Command errored out with exit status 1: 'c:\\users\\pol\\appdata\\local\\programs\\python\\python38\\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '\"'\"'C:\\\\Users\\\\Pol\\\\AppData\\\\Local\\\\Temp\\\\pip-install-v44y041t\\\\matplotlib\\\\setup.py'\"'\"'; __file__='\"'\"'C:\\\\Users\\\\Pol\\\\AppData\\\\Local\\\\Temp\\\\pip-install-v44y041t\\\\matplotlib\\\\setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))' install --record 'C:\\Users\\Pol\\AppData\\Local\\Temp\\pip-record-d5re6a86\\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.\nI'm using Windows and my Python version is 3.8.0. I have already tried python -m pip install matplotlib but it doesn't work.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":11426,"Q_Id":58814671,"Users Score":0,"Answer":"pip install --pre -U scikit-learn\nthis command is work for me\nI have found because this error come for the duplication of same libraries.","Q_Score":4,"Tags":"python,python-3.x,matplotlib,pip,python-packaging","A_Id":69829396,"CreationDate":"2019-11-12T08:24:00.000","Title":"Matplotlib: Command errored out with exit status 1","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to install the matplotlib package for Python with pip install matplotlib in the command prompt but suddenly the lines get red and the next error appears:\nERROR: Command errored out with exit status 1: 'c:\\users\\pol\\appdata\\local\\programs\\python\\python38\\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '\"'\"'C:\\\\Users\\\\Pol\\\\AppData\\\\Local\\\\Temp\\\\pip-install-v44y041t\\\\matplotlib\\\\setup.py'\"'\"'; __file__='\"'\"'C:\\\\Users\\\\Pol\\\\AppData\\\\Local\\\\Temp\\\\pip-install-v44y041t\\\\matplotlib\\\\setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))' install --record 'C:\\Users\\Pol\\AppData\\Local\\Temp\\pip-record-d5re6a86\\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.\nI'm using Windows and my Python version is 3.8.0. I have already tried python -m pip install matplotlib but it doesn't work.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":11426,"Q_Id":58814671,"Users Score":-1,"Answer":"Try running your command prompt with administrator privileges\nIf the problem further persists try reinstalling pip","Q_Score":4,"Tags":"python,python-3.x,matplotlib,pip,python-packaging","A_Id":58814829,"CreationDate":"2019-11-12T08:24:00.000","Title":"Matplotlib: Command errored out with exit status 1","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here is the problem I'm trying to solve:\nWrite a program to perform the following operations:\n\nRead two inputs - a sequence of characters S & another shorter sequence Y from two separate lines of input\nS only contains lower case characters among a-z\nCalculate and print how many times the given word Y can be generated from the given sequence S\nCharacters from string S can be used in order \nEach character can be used only once\n\nSample Input:\napqrctklatc \/\/input \ncat         \/\/the word that we need to create from input\nOutput:\nword cat can be formed 2 times","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":522,"Q_Id":58814799,"Users Score":0,"Answer":"My solution is:\n\nStep 1: Count the number of times that each distinct characters appear in the 2nd input. Save the result to a map, called mapA, for example: a - 2 times, b - 3 times, etc...\nStep 2: Iterate through the 1st input, count the number of times that each characters in mapA appear. Save the result to a map, called mapB.\nStep 3: Initialize a variable with a high integer value (max_int is a good choice), called result. Iterate through mapA (or mapB, since both maps have the same list of keys). For each keys in mapA, calculate the floor of mapB.value\/mapA.value. If it smaller than result, set result to that value.\nStep 4: Return the result, which is the result you need.\n\nFor other cases that make your result unexpected, like: 1st input and 2nd input have no common character, etc..., make sure that you have catch all of them before following those steps. Hope that you can finish it without a sample code.\nGood luck.","Q_Score":0,"Tags":"python","A_Id":58815153,"CreationDate":"2019-11-12T08:34:00.000","Title":"How many times can a word be created using the input string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I develop in Djangon \/ Python recently and use until now Sublime Text.\nI would like to go to a more complete idea (console, debug, etc ...)\nso I installed VS Code but when I open a project Django \/ Python I have the error below when I wanted to install the python extension but I had the error below:\n\nThe environment variable 'Path' seems to have some paths containing the '\"' character. The existence of such a character is known to have caused the Python extension to not load. If the extension fails to load please modify your paths to remove this '\"' character.\n\nwhen I look at the PATH environment variable I do not see quotes but 2 lines:\n\n%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files\\PostgreSQL\\11\\bin;C:\\Program Files\\PostgreSQL\\11\\lib;C:\\Program Files\\Sublime Text 3;C:\\Users\\jl3.PRT-063\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts;\nC:\\Users\\jl3.PRT-063\\AppData\\Local\\Programs\\Microsoft VS Code\\bin\n\nI decided to followed the tutorial VS Code Python and actually when I run the program \"Hello world!\" I have the error message below:\n\n[Running] python -u \"c:\\Users\\jl3.PRT-063\\hello\\hello.py\"\n'python' Is not recognized as an internal or external command operable program or batch file in Python?\n\nWhen I run my django project with windows console, I use py instead of python... I don't know why and if it is me that set this VS Code use python...\nmaybe it is the origin of the problem\nCan anyone help me please?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":816,"Q_Id":58818634,"Users Score":0,"Answer":"You are actually executing code using Code Runner, not the Python extension (you can tell by the [Running] bit). If you would like the Python extension to do the execution then either disable Code Runner for your Python workspace or uninstall it.","Q_Score":0,"Tags":"python,django,visual-studio-code","A_Id":58828914,"CreationDate":"2019-11-12T12:20:00.000","Title":"python can't load on VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to customise the functions that process the results of completing the flask-user registration and login forms. I know how to customise the html forms themselves, but I want to change how flask-user performs the registration process. For example, I want to prevent the flask-user login and registration process from creating flash messages and I want registration to process a referral code.\nI understand how to add an _after_registration_hook to perform actions after the registration function has completed, but, this doesn't allow me to remove the flash messages that are created in the login and registration processes.\nMy custom login and registration processes would build on the existing flask-user login and registration functions with functionality added or removed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":281,"Q_Id":58819180,"Users Score":0,"Answer":"You seem to be asking about the flask-user package - however you tagged this with flask-security (which is a different package but offers similar functionality). I can answer for flask-security-too (my fork of the original flask-security) - if you are\/want to use flask-user - it might be useful to change your tags.\nIn a nutshell - for flask-security - you can turn off ALL flashes with a config variable.\nFor registration - you can easily override the form and add a referral code - and validate\/process that as part of form validation.","Q_Score":0,"Tags":"python,authentication,flask,flask-login,flask-security","A_Id":58830619,"CreationDate":"2019-11-12T12:52:00.000","Title":"How do I customise the flask-user registration and login functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use Python as a high-level wrapper and a loaded C++ kernel in the form of a binary library to perform calculations. I debug high level Python code in IDE Eclipse in the usual way, but how do I debug C++ code?\nThank you in advance for your help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":97,"Q_Id":58820116,"Users Score":1,"Answer":"Try using gdb's \"attach \" command (or \"gdb -p \" command-line option) to attach to the python process that has the C++ kernel library loaded.","Q_Score":3,"Tags":"python,c++,eclipse","A_Id":58820608,"CreationDate":"2019-11-12T13:47:00.000","Title":"How I can debug two-language 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 using github3.py library for my remaining code modules.\nSo if possible can we use github3.py lib for cloning a repo or any other python library is also good.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":65,"Q_Id":58821294,"Users Score":1,"Answer":"Normally, you should be able to clone it the same way as a normal repository.","Q_Score":0,"Tags":"python,python-3.x,git,github,github3.py","A_Id":58824019,"CreationDate":"2019-11-12T15:01:00.000","Title":"Clone a Githubenterprise Repo using python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't read a pickle file saved with a different version of Python pandas. I know this has been asked here before, but the solutions offered, using pd.read_pickle(\"my_file.pkl\") is not working either. I think (but I am not sure) that these pickle files were created with an newer version of pandas than that of the machine I am working now.\nUnfortunately, I am not the administrator and I cannot change the version of pandas. How can I read my files? Are they irrecoverable?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4370,"Q_Id":58822129,"Users Score":2,"Answer":"You will need the same version (or a later one) of pandas as the one used to_pickle.\nWhen pandas converts a dataframe to pickle the compress process is specific to that version.\nI advise to contact your administrator and have them convert the pickle to csv that way you can open it with any version of pandas.\nUnless the dataframe contains objects csv should be fine","Q_Score":2,"Tags":"python,pandas","A_Id":58822290,"CreationDate":"2019-11-12T15:49:00.000","Title":"Read a pickle with a different version of pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After inserting a couple of thousand rows in my mysqldb (xampp) via the python interface (spyder python 3.7), the database is losing the port.\nSpyder error-message:\n\nInterfaceError: Can't connect to MySQL server on 'localhost:3306' (10048\n\nxampp error-message:\n\nNetStatTable]  NetStat TCP service stopped. Please restart the control panel. Returned 122\n\nDoes anybody have any idea?\nthx in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":58822343,"Users Score":0,"Answer":"this are the mysql logfiles for the last two crashes: (sorry, now Idea how to format properly)\nInnoDB: using atomic writes.\n2019-11-12 16:40:02 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions\n2019-11-12 16:40:02 0 [Note] InnoDB: Uses event mutexes\n2019-11-12 16:40:02 0 [Note] InnoDB: Compressed tables use zlib 1.2.11\n2019-11-12 16:40:02 0 [Note] InnoDB: Number of pools: 1\n2019-11-12 16:40:02 0 [Note] InnoDB: Using SSE2 crc32 instructions\n2019-11-12 16:40:02 0 [Note] InnoDB: Initializing buffer pool, total size = 16M, instances = 1, chunk size = 16M\n2019-11-12 16:40:02 0 [Note] InnoDB: Completed initialization of buffer pool\n2019-11-12 16:40:02 0 [Note] InnoDB: Starting crash recovery from checkpoint \nLSN=19733761912\n2019-11-12 16:40:02 0 [Note] InnoDB: 128 out of 128 rollback segments are active.\n2019-11-12 16:40:02 0 [Note] InnoDB: Removed temporary tablespace data file: \"ibtmp1\"\n2019-11-12 16:40:02 0 [Note] InnoDB: Creating shared tablespace for temporary tables\n2019-11-12 16:40:02 0 [Note] InnoDB: Setting file 'C:\\xampp\\mysql\\data\\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...\n2019-11-12 16:40:02 0 [Note] InnoDB: File 'C:\\xampp\\mysql\\data\\ibtmp1' size is now 12 MB.\n2019-11-12 16:40:02 0 [Note] InnoDB: Waiting for purge to start\n2019-11-12 16:40:02 0 [Note] InnoDB: 10.4.8 started; log sequence number 19733761921; \ntransaction id 9577888\n2019-11-12 16:40:02 0 [Note] InnoDB: Loading buffer pool(s) from C:\\xampp\\mysql\\data\\ib_buffer_pool\n2019-11-12 16:40:02 0 [Note] Plugin 'FEEDBACK' is disabled.\n2019-11-12 16:40:02 0 [Note] Server socket created on IP: '::'.","Q_Score":0,"Tags":"python,mysql,xampp","A_Id":58822609,"CreationDate":"2019-11-12T15:59:00.000","Title":"SQL insert via python looses port 3306","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the cmd , after receiving my Ipv4 address using ipconfig , I have added it to the ALLOWED_HOSTS in the settings.py file . \nThen to run the website , in cmd I ran the following command : \npython manage.py runserver 192.168.x.x:8000 where 192.168.x.x is my ipaddress . \nI am able to to access my website from my own local machine , however on other local machines : 192.168.x.x:8000\/ isn't responding.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":58822626,"Users Score":0,"Answer":"Aemie, \nTry hosting the django server on 0.0.0.0:8000 and attempt to access it from the different machine via the address 192.168.x.x:8000 (the ip address of the host machine IP).\n0.0.0.0 would allow all IPv4 addresses on the local machine to be accessible","Q_Score":0,"Tags":"python,django","A_Id":58822736,"CreationDate":"2019-11-12T16:16:00.000","Title":"How to access Django based website from different local machines?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In the cmd , after receiving my Ipv4 address using ipconfig , I have added it to the ALLOWED_HOSTS in the settings.py file . \nThen to run the website , in cmd I ran the following command : \npython manage.py runserver 192.168.x.x:8000 where 192.168.x.x is my ipaddress . \nI am able to to access my website from my own local machine , however on other local machines : 192.168.x.x:8000\/ isn't responding.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":58822626,"Users Score":0,"Answer":"I fear, there is rather a fundamental misunderstanding of a local webserver. The webserver created when you run python manage.py runserver is just a programme running on your computer. You can make requests against that server in your browser using the address manage.py gives you, but that does not mean that the web server was on the internet. \nWhat you expect is like having a Python script hello_world.py on your machine and expecting that someone else could just run python hello_world.py on their machine and it would invoke the script on your machine.\nIf you want to publish your website, you need to host it on a website.","Q_Score":0,"Tags":"python,django","A_Id":58822711,"CreationDate":"2019-11-12T16:16:00.000","Title":"How to access Django based website from different local machines?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm searching for Python Script where I can make a hTTP Server, that allows to download the files of a specific folder (Linux)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":58824419,"Users Score":4,"Answer":"You can do it with the command:\npython -m http.server 8180","Q_Score":2,"Tags":"python","A_Id":58824428,"CreationDate":"2019-11-12T18:13:00.000","Title":"How to make a Python HTTP server where I can download files of a directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install Anakonda3 on Windows 7 32-bit and get an issue: Failed to create menus.\nIn Details I see:\n\nError loading Python DLL 'C:\\Users\\xxx\\AppData\\Local\\Temp_MEI32722\\python37.dll'.\nLoadLibrary: \u041d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430.\n\nI'm trying to keep PATH variable empty and start installation under Administration mode, but nothing helps.\nMany thanks for help!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":226,"Q_Id":58824794,"Users Score":1,"Answer":"I solved the problem in a following way. I am working in virtual machines, so I create new virtual machine with Windows 7 x64 and install Anakonda3-x64 into it. And it installed successfully.","Q_Score":0,"Tags":"python,menu","A_Id":58837090,"CreationDate":"2019-11-12T18:41:00.000","Title":"Failed to create menus when installing Anaconda3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say, for the sake of this question, I have a column titled Blah filled with the following data points (I will give it in a list for clarity):\nValues = ['one', 'two', 'four', 'six', 'nine']\nHow could I choose to sort by specific values in this column? For example, I would like to sort this column, Blah, filled with the values above into the following: ['nine', 'four', 'two', 'six', 'one'].\nUnfortunately, it is not as easy as just sort_values and choose alphabetical!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":58825887,"Users Score":0,"Answer":"What are you sorting by? Alphabetical would be ['four', 'nine', 'one', 'six', 'two']","Q_Score":1,"Tags":"python,python-3.x,pandas,sorting","A_Id":58825987,"CreationDate":"2019-11-12T20:02:00.000","Title":"How to Sort a Pandas Column by specific values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new using python on kubuntu. I'm writing some simple functions and write also tests on pytest to practise test-driven-development (although I know it's wasted on such easy functions, it's just for the sake of practice).\nBecause I'm beginner, I'm writing the code in an editor and I'm executing it on the terminal, in a next step I'll use an IDE like Thonny. I have installed Python3.7, although Python2.7 seems to be the standard within the system. Nonetheless, the file with the functions works fine. I'm printing some f-strings and it works fine also. The first line of the file is a Shebang which tells the interpreter, to use Python3.7 (#!\/usr\/bin\/env python3.7). However, when I want to execute the tests, I'm writing pytest in console, as indicated by the pytest-introduction. Alas, I get a syntax error, because it seems that pytest is importing Python2.7 which of course doesn't know f-strings.\nI verified that pytest is indeed importing Python2.7 by executing the command pytest --version and I was confirmed.\nMy question is: How can I make pytest to import Python3.7 so the test would pass or at least the Syntaxerror would go away? Replacing the f-string with a normal string makes the test pass, so I'm assuming this is the only problem.\nAny help is highly appreciated. Many thanks in advance. I hope, I gave all the relevant informations. If more information is needed, I'll provide that gladly.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":768,"Q_Id":58826624,"Users Score":0,"Answer":"You can install pytest with pip3. For most libraries, pip3 defaults to python3.x and pip defaults to python2.x","Q_Score":0,"Tags":"python,python-3.x,pytest","A_Id":58826862,"CreationDate":"2019-11-12T21:04:00.000","Title":"import pytest from Python3.7 instead 2.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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Building out a new application now and struggling a lot with the implementation part of \"Closed-Open\" and \"Inversion of Control\" principles I following after reading Clean Architecture book by Uncle Bob.\nHow can I implement them in Python?\nUsually, these two principles coming hand in hand and depicted in the UML as an Interface reversing control from module\/package A to B.\nI'm confused because:\n\nPython does not possess Interfaces as Java and C++ do. Yes, there are ABC and @abstractmethod, but it is not a Pythonic style and redundant from my point of view if you are not developing a framework\nPassing a class to the method of another one (I understood that it is a way to implement open-closed principle) is a little bit dangerous in Python, since it does not have a compiler which is catching issues may (and will) happen if one of two loosely coupled objects change\nAfter neglecting interfaces and passing a top-level class to lower-level ones... I still need to import everything somewhere at the top module. And by that, the whole thing is violated.\n\nSo, as you can see I'm super confused and having a hard time programming according to my design. I came up with. Can you help me, please?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":58828666,"Users Score":3,"Answer":"You just pass an object that implements the methods you need it to implement.\nTrue, there is no \"Interface\" to define what those methods have to be, but that's just the way it is in python.\nYou pass around arguments all the time that have to be lists, maps, tuples, or whatever, and none of these are type-checked.  You can write code that calls whatever you want on these things and python will not notice any kind of problem until that code is actually executed.\nIt's exactly the same when you need those arguments to implement whatever IoC interface you're using.  Make sure you detail the requirements in comments.\nYes, this is all pretty dangerous.  That's why we prefer statically typed languages for large systems that have complex interfaces.","Q_Score":1,"Tags":"python,design-patterns,architecture,clean-architecture","A_Id":58830018,"CreationDate":"2019-11-13T00:28:00.000","Title":"How to apply Closed-Open and Inversion of Control principles in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can use selenium with pycharm but not in gnome-terminal.\nModuleNotFoundError:No module named 'selenium' \nis shown when I try to execute(in gnome-terminal) the python file which include the sentence \"from selenium import webdriver\".\nWhat is the difference between 2 environment?.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":58830285,"Users Score":0,"Answer":"Uninstall selenium in PyCharm and reinstall selenium in gnome-terminal and reinstall selenium in PyCharm.","Q_Score":0,"Tags":"python,selenium,pycharm,gnome-terminal","A_Id":58835319,"CreationDate":"2019-11-13T04:19:00.000","Title":"I can use selenium only in pycharm but not in gnome-terminal.It only works in pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running this inside a virtual environment. \nWhen I type: \npip install django \nI get:\n\nERROR: Could not install packages due to an EnvironmentError: [Errno\n  13] Permission denied: \/home\/ENV\/env\/lib\/python3.5\/site-packages\/pytz\n  Consider using the --user option or check the permissions.\n\nFor it to work I actually need to input:\npython -m pip install --user django \nWhy?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1086,"Q_Id":58831133,"Users Score":0,"Answer":"The error basically states that you do not have permissions to write files to your machine, So ff you are a root user(or admin) you can always install python packages with \nsudo pip install django\nOr \npip install --user django\n--user makes pip install packages in your home directory instead, which doesn't require any special privileges.","Q_Score":3,"Tags":"python,python-3.x,pip","A_Id":58831956,"CreationDate":"2019-11-13T06:00:00.000","Title":"Why my pip installations requires python -m install --user?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have added the C:\\Users\\Admin\\Anaconda3\\python.exe path to my system environment variables PATH but still when I run python command it opens Windows app store! Why bthis happens and how to fix it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":58833021,"Users Score":1,"Answer":"the PATH variable should contain \nC:\\Users\\Admin\\Anaconda3 \nnot \nC:\\Users\\Admin\\Anaconda3\\python.exe","Q_Score":0,"Tags":"python,path,windows-10,environment-variables","A_Id":58833343,"CreationDate":"2019-11-13T08:29:00.000","Title":"Why my Python command doesn't work in Windows 10 CMD?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I want to run a Python map reduce job on a Dataproc cluster, the problem is that I cannot find the Hadoop streaming jar file that needs to be submitted into the Main class or jar input.\nI'm using Dataproc image with Hadoop 2.7, an answer for Hadoop 2.8 would also work.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":275,"Q_Id":58833064,"Users Score":4,"Answer":"Hadoop Streaming jar located in \/usr\/lib\/hadoop-mapreduce\/ folder on Dataproc cluster nodes: \/usr\/lib\/hadoop-mapreduce\/hadoop-streaming.jar","Q_Score":2,"Tags":"python,hadoop,mapreduce,google-cloud-dataproc","A_Id":58841369,"CreationDate":"2019-11-13T08:31:00.000","Title":"Finding the Hadoop streaming jar in cluster in Dataproc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on an optimization problem on PyCharm using the CBC solver and I keep having this error:\nERROR: Solver (cbc) returned non-zero return code (3221225781)\nand \npyutilib.common._exceptions.ApplicationError: Solver (cbc) did not exit normally\nI've added the \"keepfiles=True\" argument but I can't finde the solver log and solution file, although I can finde the problem files on the path the program returns.\nIt is worth nothing that this program runs properly on my colleague's computer, (he has 16Gb RAM and I have 8)","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":1734,"Q_Id":58833847,"Users Score":2,"Answer":"I was facing the same problem with the ipopt solver.\nIt was solved by adding the solver to the system PATH, but it only worked after restarting the computer!","Q_Score":2,"Tags":"python,optimization,solver,pyomo","A_Id":68928182,"CreationDate":"2019-11-13T09:22:00.000","Title":"Pyomo CBC solver error: Solver (cbc) returned non-zero return code (3221225781); Solver (cbc) did not exit normally","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on an optimization problem on PyCharm using the CBC solver and I keep having this error:\nERROR: Solver (cbc) returned non-zero return code (3221225781)\nand \npyutilib.common._exceptions.ApplicationError: Solver (cbc) did not exit normally\nI've added the \"keepfiles=True\" argument but I can't finde the solver log and solution file, although I can finde the problem files on the path the program returns.\nIt is worth nothing that this program runs properly on my colleague's computer, (he has 16Gb RAM and I have 8)","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1734,"Q_Id":58833847,"Users Score":1,"Answer":"in addition to @Camunatas's solution (if that doesn't work) do add all the DLLs and exe's which are the package of COIN OR(blis,bonmin,cbc,clp,couenne,ipopt,OSSolverService,symphony) package in the same directory\/folder where the python files are.as these exes are the only installers for windows and they should always be with their DLLs to work.","Q_Score":2,"Tags":"python,optimization,solver,pyomo","A_Id":68753554,"CreationDate":"2019-11-13T09:22:00.000","Title":"Pyomo CBC solver error: Solver (cbc) returned non-zero return code (3221225781); Solver (cbc) did not exit normally","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on an optimization problem on PyCharm using the CBC solver and I keep having this error:\nERROR: Solver (cbc) returned non-zero return code (3221225781)\nand \npyutilib.common._exceptions.ApplicationError: Solver (cbc) did not exit normally\nI've added the \"keepfiles=True\" argument but I can't finde the solver log and solution file, although I can finde the problem files on the path the program returns.\nIt is worth nothing that this program runs properly on my colleague's computer, (he has 16Gb RAM and I have 8)","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1734,"Q_Id":58833847,"Users Score":2,"Answer":"I've found a solution by myself and I'll post it here in case is usefull for anyone in the future:\nWhen installing a solver, you must add the solver.exe file into the system PATH or just place the file in the folder where the python file is placed","Q_Score":2,"Tags":"python,optimization,solver,pyomo","A_Id":58855155,"CreationDate":"2019-11-13T09:22:00.000","Title":"Pyomo CBC solver error: Solver (cbc) returned non-zero return code (3221225781); Solver (cbc) did not exit normally","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to automate downloading of certain csv files from a website.\nThis is how I manually do it:\n\nI log in to the website.\nClick on the button export as csv.\nThe file gets downloaded. \n\nThe problem is the button does not have any link to it so I was not able to automate it using wget or requests.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":434,"Q_Id":58836664,"Users Score":0,"Answer":"You can use selenium in python. There is an option to click using \"link text\" or \"partial link text\". It is quite easy and efficient.\ndriver.findElement(By.linkText(\"click here\")).click()\nIt kind of looks like this.","Q_Score":0,"Tags":"python-3.x,python-requests,wget","A_Id":61072914,"CreationDate":"2019-11-13T11:59:00.000","Title":"Automate downloading of certain csv files from a website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on converting our model from tensorflow 1.8.0 to 2.0 but using sequential api's is quite difficult for our current model.So if there any support for functional api's in 2.0 as it is not easy to use sequential api's.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":58836772,"Users Score":1,"Answer":"Tensorflow 2.0 is more or less made around the keras apis. You can use the tf.keras.Model for creating both sequential as well as functional apis.","Q_Score":0,"Tags":"python-3.x,tensorflow,tensorflow2.0","A_Id":58841007,"CreationDate":"2019-11-13T12:06:00.000","Title":"Is there support for functional layers api support in tensorflow 2.0?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"There are two python gRPC services A and B.\nService A needs to call a rpc on service B in order to send a response to the client.\nService A also has an interceptor that adds information to gRPC contexts it uses. \nQuestion:\nHow can I pass the gRPC context to service B so I can access those information on gRPC contexts in service B?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":741,"Q_Id":58837350,"Users Score":2,"Answer":"Since you are changing the python object itself, it is not currently possible to pass it in the gRPC call. although you can do this manually by setting your metadata using send_initial_metadata method of your context and writing a new interceptor in service B to parse this information stored in invocation_metadata and setting it in the context of your second service.","Q_Score":2,"Tags":"python,grpc,grpc-python","A_Id":58838164,"CreationDate":"2019-11-13T12:39:00.000","Title":"Propagating gRPC context in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Last thing I did was pip install boto3 and fastai through git bash yesterday. I can't imagine if anything else could have had any influence.\nI have been using python for a few months now, but today it stopped running. I opened my\nSublime Text - and after running some simple code I got:\n\"Python was not found but can be installed from the Microsoft Store\". \nGIT bash:\n\n$ python --version bash:\n  \/c\/Users\/...\/AppData\/Local\/Microsoft\/WindowsApps\/python: Permission\n  denied\n\nBut if I open up a file of python 3 in this link:\n\nC:\\Users...\\AppData\\Roaming\\Microsoft\\Windows\\Start\n  Menu\\Programs\\Python 3.7\n\nMy Python works.\nI think I have to redirect my main python file from the first link directory to the second and have no clue how to do this, that my Git and Sublime would be able to pick on this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":58837457,"Users Score":0,"Answer":"So, I gave up and just installed the recommended link from Microsoft store. So now I possibly have 4 pythons with 2 different versions in 3 locations, but hey.... it works :)\nRegarding a comment below my first questions:\nWhen I run $ ls -l which python in GITbash, it gives:\n-rwxr-xr-x 1 ... 197121 97296 Mar 25  2019 \/c\/Users\/...\/AppData\/Local\/Programs\/Python\/Python37-32\/python*\n\n\/...\/ is just my user name\n\nYesterday I tried that as well, the start was identical, although I can't really remember the link, if it was the same.","Q_Score":0,"Tags":"python,python-3.x,windows,hyperlink,permissions","A_Id":58856086,"CreationDate":"2019-11-13T12:45:00.000","Title":"Python does not work after installing fastai and boto3. Permission denied \/\/ Python was not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been working on a project built with Django. When I run profiler due to slowness of a page in project, this was a line of the result:\n\n10    0.503    0.050    0.503    0.050 {method 'recv_into' of '_socket.socket' objects}\n\nWhich says almost 99% of passed time was for the method recv_into(). After some research, I learned the reason is Nagel's algorithm which targets to send packets only when the buffer is full or there are no more packets to transmit. I know I have to disable this algorithm and use TCP_NODELAY but I don't know how, also it should only affect this Django project.\nAny help would be much appreciated.","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":373,"Q_Id":58837801,"Users Score":-1,"Answer":"Are you using cache settings in the settings.py file? Please check that maybe you have tcp_nodelay enable there, if so then remove it or try to clear browser cache.","Q_Score":5,"Tags":"python,django,tcp","A_Id":58838050,"CreationDate":"2019-11-13T13:05:00.000","Title":"Is there a way to change TCP settings for Django project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Am a beginner on Python (self studying) and got introduced to Lambda (nameless) function but I am unable to deduce the below expression for Fibonacci series (got from Google) but no explanation available online (Google) as to how this is evaluated (step by step). Having a lot of brain power here, I thought somebody can help me with that. Can you help evaluate this step by step and explain ? \nlambda n: reduce(lambda x, _: x+[x[-1]+x[-2]],range(n-2), [0, 1])\nThanks in advance.\n(Thanks xnkr, for the suggestion on a reduce function explained and yes, am able to understand that and it was part of the self training I did but what I do not understand is how this works for lambda x, _ :  x+[x[-1]+x[-2]],range(n-2), [0, 1]. It is not a question just about reduce but about the whole construct - there are two lambdas, one reduce and I do not know how the expression evaluates to. What does underscore stand for, how does it work, etc)\nCan somebody take the 2 minutes that can explain the whole construct here ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":203,"Q_Id":58838841,"Users Score":5,"Answer":"Break it down piece by piece:\nlambda n: - defines a function that takes 1 argument (n); equivalent to an anonymous version of: def somefunc(n):\nreduce() - we'll come back to what it does later; as per docs, this is a function that operates on another function, an iterable, and optionally some initial value, in that order. These are:\n\nA) lambda x, _: - again, defines a function. This time, it's a function of two arguments, and the underscore as the identifier is just a convention to signal we're not gonna use it.\nB) X + [ <stuff> ] - prepend some list of stuff with the value of the first arg. We already know from the fact we're using reduce that the arg is some list.\nC) The <stuff> is x[-1] + x[-2] - meaning the list we're prepending our X to is, in this case, the sum of the last two items already in X, before we do anything to X in this iteration.\nrange(n-2) is the iterable we're working on; so, a list of numbers from 1 to N-2. The -2 is here because the initial value (in 3) already has the first two numbers covered.\nSpeaking of which, [0, 1] is our predefined first two starting values for X[-2], X[-1].\nAnd now we're executing. reduce() takes the function from (1) and keeps applying it to each argument supplied by the range() in (2) and appending the values to a list initialized as [0, 1] in (3). So, we call I1: [0, 1] + lambda 0, [0, 1], then I2: I1 + lambda 1, I1, then I3: I2 + lambda 2, I2 and so on.","Q_Score":0,"Tags":"python,algorithm,fibonacci","A_Id":58839270,"CreationDate":"2019-11-13T14:01:00.000","Title":"How does this Fibonacci Lambda function work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two text files containing parallel text in two languages (potentially millions of lines).  I am trying to generate random train\/validate\/test files from that single file, as train_test_split does in sklearn.  However when I try to import it into pandas using read_csv I get errors from many of the lines because of erroneous data in there and it would be way too much work to try and fix the broken lines.  If I try and set the error_bad_lines=false then it will skip some lines in one of the files and possibly not the other which would ruin the alignment.  If I split it manually using unix split it works fine for my needs though so I'm not concerned with cleaning it, but the data that is returned is not random.\nHow should I go about splitting this dataset into train\/validate\/test sets?\nI'm using python but I can also use linux commands if that would be easier.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":85,"Q_Id":58840145,"Users Score":0,"Answer":"I found that I can use the shuf command on the file with the random-source parameter, like this shuf tgt-full.txt -o tgt-fullshuf.txt --random-source=tgt-full.txt.","Q_Score":0,"Tags":"python,pandas,unix,scikit-learn,dataset","A_Id":58842847,"CreationDate":"2019-11-13T15:15:00.000","Title":"How to split parallel corpora while keeping alignment?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a JSON file whose size is about 5GB. I neither know how the JSON file is structured nor the name of roots in the file. I'm not able to load the file in the local machine because of its size So, I'll be working on high computational servers. \nI need to load the file in Python and print the first 'N' lines to understand the structure and Proceed further in data extraction. Is there a way in which we can load and print the first few lines of JSON in python?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":4497,"Q_Id":58841643,"Users Score":-1,"Answer":"You can use the command head to display the N first line of the file. To get a sample of the json to know how is it structured.\nAnd use this sample to work on your data extraction.\nBest regards","Q_Score":2,"Tags":"python,json,database,data-extraction","A_Id":58841764,"CreationDate":"2019-11-13T16:38:00.000","Title":"Printing top few lines of a large JSON file in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need a wheel for SpaCy to fix my build issue. Where can I find it? The file name is supposed to be spacy-1.10.1-cp27-cp27mu-linux_x86_64.whl\nThey did have wheels before. I was using a 1.9.0 wheel but I need to upgrade it to 1.10.1 and I was not able to find one.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":44,"Q_Id":58842119,"Users Score":2,"Answer":"The SpaCy project did not start publishing wheels for their releases until version 2.0.13.","Q_Score":0,"Tags":"python,nlp,spacy,pypi,python-wheel","A_Id":58842581,"CreationDate":"2019-11-13T17:03:00.000","Title":"Why does SpaCy no longer have wheels for version<2.0.0 on Pypi?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to compare the accuracy results of CNN model and combined CNN-SVM model for classification. However I found that CNN model have better accuracy than combined CNN-SVM model. Is That correct or it can happen?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":144,"Q_Id":58844965,"Users Score":1,"Answer":"It depends on a large number of factors , but yes if the underlying data is image - cnn have proven to deliver better results.","Q_Score":1,"Tags":"python,classification,svm","A_Id":58847337,"CreationDate":"2019-11-13T20:18:00.000","Title":"CNN model have better accuracy than combined CNN-SVM model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I try to plot a figure in a Google Colab notebook using matplotlib, a plot is displayed whenever I use %matplotlib inline but is not displayed when I do %matplotlib ipympl or %matplotlib widget. How can I resolve this issue. My goal is to get the plot to be interactive.\n\nClarification: when I run %matplotlib --list I get the following output\nAvailable matplotlib backends: ['tk', 'gtk', 'gtk3', 'wx', 'qt4', 'qt5', 'qt', 'osx', 'nbagg', 'notebook', 'agg', 'inline', 'ipympl', 'widget']\n\nThanks for your help!","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1694,"Q_Id":58845278,"Users Score":-1,"Answer":"Available matplotlib backends: ['tk', 'gtk', 'gtk3', 'wx', 'qt4', 'qt5', 'qt', 'osx', 'nbagg', 'notebook', 'agg', 'inline', 'ipympl', 'widget']","Q_Score":2,"Tags":"python,matplotlib,google-colaboratory","A_Id":62375398,"CreationDate":"2019-11-13T20:39:00.000","Title":"Matplotlib and Google Colab: Using ipympl","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Supposing that I have following signal:\ny = np.sin(50.0 * 2.0*np.pi*x) + 0.5*np.sin(100.0 * 2.0*np.pi*x) + 0.2*np.sin(200 * 2.0*np.pi*x)\nhow can I filter out in example 100Hz using Band-stop filter in Python? In this signal there are peaks at 50Hz, 100Hz and 200Hz. It would be helpful it it could be visualized using FFT in order to confirm that this frequency has been filtered correctly.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":978,"Q_Id":58846626,"Users Score":0,"Answer":"Why magnitude for frequency 50 Hz decreased from 1 to 0.7 after Fast Fourier Transform?","Q_Score":0,"Tags":"python,numpy,scipy,fft","A_Id":58858660,"CreationDate":"2019-11-13T22:30:00.000","Title":"Filter out range of frequencies using band stop filter in Python and confirm it using Fourier Transform FFT","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Please I need help with an issue.\nI can't access the folders in my Documents folder on Command Prompt. I also noticed this problem with my Jupyter Notebook. The system does not detect the folders in my Documents folder. It returns an error message on Command Prompt which says, \"The system cannot find the path specified.\". On Jupyter Notebook, it's still the same issue; it says, \"The notebook list is empty.\" But my Documents folder is not empty.\nPlease, what is causing this issue?\nI use a Windows 10 HP computer.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2235,"Q_Id":58846651,"Users Score":0,"Answer":"Check the permissions of the particular folder. On the respective folder, right-click --> give access to-->. In the appearing list, make sure that \"view and edit\" access is granted to all users if you have more than 1. \n(To do this you will require admin privileges. So make sure in your windows PC you have logged on as an admin.)","Q_Score":0,"Tags":"python,directory,jupyter-notebook,windows-10,command-prompt","A_Id":58846869,"CreationDate":"2019-11-13T22:32:00.000","Title":"\"The system cannot find the path specified.\"\/ \"The notebook list is empty\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Please I need help with an issue.\nI can't access the folders in my Documents folder on Command Prompt. I also noticed this problem with my Jupyter Notebook. The system does not detect the folders in my Documents folder. It returns an error message on Command Prompt which says, \"The system cannot find the path specified.\". On Jupyter Notebook, it's still the same issue; it says, \"The notebook list is empty.\" But my Documents folder is not empty.\nPlease, what is causing this issue?\nI use a Windows 10 HP computer.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2235,"Q_Id":58846651,"Users Score":0,"Answer":"I had the same issue and I realized OneDrive creates a backup from folders such as Documents, Desktop, Pictures,...\nYou can open the OneDrive folder on your computer or in Jupyter notebook and see all files are there.\nIn order to access them via Jupyter notebook directly, you can type cd OneDrive in Command Prompt then start Jupyter Notebook there. Then all the files will be shown.\nFor example in Windows 10, I use these lines in Command Prompt:\ncd OneDrive\npython -m notebook","Q_Score":0,"Tags":"python,directory,jupyter-notebook,windows-10,command-prompt","A_Id":68656679,"CreationDate":"2019-11-13T22:32:00.000","Title":"\"The system cannot find the path specified.\"\/ \"The notebook list is empty\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is a server that contains a json dataset that I need \nI can manually use chrome to login\nto the url and use chrome developer tool to read the request header for said json data\nI determined that the minimum required headers that should be sent to the json endpoint are ['cookie', 'x-xsrf-token', 'user-agent']\nI don't know how I can get these values so that I can automate fetching this data. I would like to use request module to get the data\nI tried using selenium, to navigate to the webpage that exposes these header values, but cannot get said headers values (not sure if selenium supports this)\nIs there a way for me to use request module to inch towards getting these header values...by following the request header \"bread crumbs\" so to speak?\nIs there an alternative module that excels at this?\nTo note, I have used selenium to get the required datapoints successfully, but selenium is resource heavy and prone to crash; \nBy using the request module with header values greatly simplifies the workflow and makes my script reliable","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":430,"Q_Id":58847818,"Users Score":0,"Answer":"Based on pguardiario's comment\nSessions cookies and csrf-token are provided by the host when a request is made against the Origin url. These values are needed to make subsequent requests against the endpoint with the JSON payload. By using request.session() against the Origin url, and then updating the header when using request.get(url, header). I was able to access the json data","Q_Score":0,"Tags":"python,selenium,web-scraping,python-requests","A_Id":58896850,"CreationDate":"2019-11-14T00:50:00.000","Title":"get json data from host that requires headers={'user-agent', 'cookie', x-xsrf-token'}","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script 'test.py' which has import pymysql. I have installed pymysql using pip and sudo. When I run this .py, it works great.\nI have another Bash script which is used to run the above test.py. When I run this bash script, I get the error:\n\nModuleNotFoundError: No module named 'pymysql'\n\nWhere am I going wrong?\nPyMySQL==0.9.3\nPython=3.7.1","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":58847950,"Users Score":0,"Answer":"It is possible that pymysql's location needs to be in your PATH environment variable. \nWhen you run your bash script, what version of python is it using? Is it using the python \"on which\" you installed pymysql, or another one?\nTo make sure you are using the correct version of Python, I suggest using venv.","Q_Score":0,"Tags":"python,mysql,python-3.x","A_Id":58847980,"CreationDate":"2019-11-14T01:09:00.000","Title":"ModuleNotFound error while running through Bash","Data Science and Machine Learning":0,"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 the equivalent of the linux \"mmap.PROT_EXEC\" method for windows. (Inside mmap module on python)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":221,"Q_Id":58849264,"Users Score":1,"Answer":"Without going down to raw ctypes access to the underlying APIs (CreateFileMapping\/MapViewOfFile), this can't be done. The access arguments (used on Windows, and mapped to equivalent flags\/prot flags on Linux) defined by Python are strictly limited to ACCESS_READ, ACCESS_WRITE, ACCESS_COPY and ACCESS_DEFAULT, and none of them allow the memory to be mapped executable.","Q_Score":0,"Tags":"python,windows,mmap","A_Id":58849362,"CreationDate":"2019-11-14T04:11:00.000","Title":"mmap.PROT_EXEC windows equivalent in mmap 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 made a simple CNN that classifies dogs and cats and I want this CNN to detect images that aren't cats or dogs and this must be a third different class. How to implement this? should I use R-CNN or something else?\nP.S I use Keras for CNN","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":125,"Q_Id":58850711,"Users Score":1,"Answer":"What you want to do is called \"transfer learning\" using the learned weights of a net to solve a new problem.\nPlease note that this is very hard and acts under many constraints i.e. using a CNN that can detect cars to detect trucks is simpler than using a CNN trained to detect people to also detect cats.\nIn any case you would use your pre-trained model, load the weights and continue to train it with new data and examples.\nWhether this is faster or indeed even better than simply training a new model on all desired classes depends on the actual implementation and problem.\nTl:Dr\nTransfer learning is hard! Unless you know what you are doing or have a specific reason, just train a new model on all classes.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":58852959,"CreationDate":"2019-11-14T06:33:00.000","Title":"CNN on python with Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a simple CNN that classifies dogs and cats and I want this CNN to detect images that aren't cats or dogs and this must be a third different class. How to implement this? should I use R-CNN or something else?\nP.S I use Keras for CNN","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":58850711,"Users Score":0,"Answer":"You can train that almost with the same architecture (of course it depends on this architecture, if it is already bad then it will not be useful on more classes too. I would suggest to use the state of the art model architecture for dogs and cats classification) but you will also need the dogs and cats dataset in addition to this third class dataset. Unfortunately, it is not possible to use pre-trained for making predictions between all 3 classes by only training on the third class later. \nSo, cut to short, you will need to have all three datasets and train the model from scratch if you want to make predictions between these three classes otherwise use the pre-trained and after training it on third class it can predict if some image belongs to this third class of not.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":58852922,"CreationDate":"2019-11-14T06:33:00.000","Title":"CNN on python with Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use the image labeling python tool \"LabelImg\" in a browser with angular as front-end. Is it possible to do that?. If no , then how can labeling an image is done using angular so that the pixel values selected for each box in that image is set to back-end?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":123,"Q_Id":58851252,"Users Score":2,"Answer":"It is possible. You need to create an api that you can send the image to the python backend and return the result after the python has finished processing the image. \nDepending on the python algorithm runtime, you might need to make this task async which would ned more engineering: an api each for sending an image, checking for the labeling status, getting labeling result as well as a storage solution to store the image labeling status and result. \nIn layman terms, angular frontend and python backend are not coupled together. Angular gives you an interface to communicate to the end-user while the backend api's create a channel to communicate with the python service","Q_Score":0,"Tags":"javascript,python,angularjs,django,bounding-box","A_Id":58851322,"CreationDate":"2019-11-14T07:11:00.000","Title":"Is it possible to open Labelimg in Angular with python backend?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a table in sql I'm looking to read into a pandas dataframe. I can read the table in but all column dtypes are being read in as objects. When I write the table to a csv then re-read it back in using read_csv, the correct data types are assumed. Obviously this intermediate step is inefficient and I just want to be able to read the data directly from sql with the correct data types assumed.\nI have 650 columns in the df so obviously manually specifying the data types is not possible.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":651,"Q_Id":58855925,"Users Score":0,"Answer":"So it turns out all the data types in the database are defined as varchar.\nIt seems read_sql reads the schema and assumes data types based off this. What's strange is then I couldn't convert those data types using infer_objects().\nThe only way to do it was to write to a csv then read than csv using pd.read_csv().","Q_Score":0,"Tags":"python,sql,pandas","A_Id":58861981,"CreationDate":"2019-11-14T11:38:00.000","Title":"Pandas not assuming dtypes when using read_sql?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Assume I want to fit a random forest, RFC, and grid search using sklearns GridSearchCV.\nWe can get the best parameters using RFC.best_params_ but if I then want to create a random forest I need manually to write those parameters in e.g RFC(n_estimators=12,max_depth=7) afterwards. Is there a way,something like RFC_opt=RFC(best_params_) to do it automatically?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":58857069,"Users Score":0,"Answer":"I figured out, if you unpack the parameters it is doable, i.e if\nbest_par=RFC_grid_search.best_params_ then you can create the optimal RFC with the parameters in best_params_ by\nrfc_opt=RFC(**best_part)","Q_Score":0,"Tags":"python,scikit-learn","A_Id":58863619,"CreationDate":"2019-11-14T12:42:00.000","Title":"Automatically create a new object from GridSearchCV best_params_","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using VGG16 model and fine tuned them on my data. I am predicting ethnicity of images (faces) .i have 5 output classes like white, black,Asian, Sub-continent and others. Should i use softmax or sigmoid. And why??","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":403,"Q_Id":58857899,"Users Score":0,"Answer":"In general cases, if you are dealing with multi-class clasification problems, you should use a Softmax because you are guaranted that the sum of probabilities of all clases will sum 1, by weighting them individually and computing the join distribution, whereas with a Sigmoid, you'd be predicting the probability of each class individually, but not necesarilly weighted. If not careful and aware of the difference you can run into some issues with your output.","Q_Score":0,"Tags":"python,image-processing,deep-learning,data-science","A_Id":58858073,"CreationDate":"2019-11-14T13:27:00.000","Title":"Softmax or sigmoid for multiclass problem","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a procedural function (written in pl\/python) which queries table A, does some calculations and then returns a set. I use this function as query for my materialized view B.\nEverything works perfectly except that when I want to restore my dump, I get the following error:\n\nDETAIL:  spiexceptions.UndefinedTable: relation \"A\" does not exist.\n\nThe line which raises this error is the last line of my sql dump:\nREFRESH MATERIALIZED VIEW B;\nI know that I can ignore this error and refresh my materialized view after restoration process, but I want to know why this happens? Is it because this function runs in another transaction which doesn't know anything about current restoration process? And what can I do to prevent this error?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":58859643,"Users Score":1,"Answer":"For security reasons, pg_dump (or pg_restore) emits a command which empties the search_path, so when you restore the process gets run with an empty search path.  But it does not edit the text body of your function at all but emits it as-is,  so it can't alter it to specify the fully qualified name of the table. So the function can't find the table when run inside the process doing the restore.\nYou can fully qualify the table name in the function, or you can define the function with SET search_path = public.  Or you can edit the dump file to remove the part that clears the search_path, if you are not concerned about the security implications.","Q_Score":0,"Tags":"postgresql,materialized-views,plpython","A_Id":58866874,"CreationDate":"2019-11-14T14:53:00.000","Title":"Postgresql functions execution process","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the following code which works\n[i for i in range(1, 16) if any(i % j == 0 for j in [3,5])]\nThis has an output of\n[3, 5, 6, 9, 10, 12, 15], the numbers that can be divided by either 3 or 5.\nHowever, when I try\n[i for i in range(1, 16) if any(i % j != 0 for j in [3,5])]\nI get\n[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\nWhat I'm looking for instead is\n[1, 2, 4, 7, 8, 11, 13, 14]\nMany thanks!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":45,"Q_Id":58859691,"Users Score":2,"Answer":"[i for i in range(1, 16) if not any(i % j == 0 for j in [3,5])]","Q_Score":2,"Tags":"python,list,modulus,any","A_Id":58859756,"CreationDate":"2019-11-14T14:55:00.000","Title":"How do you form the opposite statement of an 'any' condition?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an intel D415 depth camera and want to identify obstacles in the path of my robot.\nI want to reduce the points from the cam pc=(102720,3) to only a rectangular area where the robot has to pass through\nI came up with this list comprehension, p[0] is the x-axis, p[2] the distance and the values are in meters, the robot needs around a 1 meter \"door\" and I limit the distance to 2 meters.\ninPathPoints = np.asarray([p for p in pc if p[0] > -0.5 and p[0] < 0.5 and p[2] > 0.2 and p[2] < 2])\nOn my laptop cProfile shows a runtime of 0.25 seconds for this evaluation. \nAs the robot needs to check for obstacles while moving I wanted to repeat this check about 5..10 times a \nsecond. Any hints what I could try to speed it up?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":58861669,"Users Score":0,"Answer":"Instead of list comprehension, is used numpy and came up with this statement:\ninPathPoints = pc[(pc[:, 0] > -0.5) & (pc[:, 0] < 0.5) & (pc[:, 2] > 0.2) & (pc[:, 2] < 2)]\nThis is so fast it does not even show up in the profile output.","Q_Score":1,"Tags":"python-3.x,list-comprehension,point-clouds","A_Id":58877449,"CreationDate":"2019-11-14T16:37:00.000","Title":"cut out part of a point cloud","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the python gspread library to get information off of google sheets. I have had no prior problems accessing any sheets but one sheet keeps throwing this error with doc.worksheet(\"{worksheet_name}\") or doc.worksheets():\ngspread.exceptions.APIError: {\n  \"error\": {\n    \"code\": 500,\n    \"message\": \"Internal error encountered.\",\n    \"status\": \"INTERNAL\"\n  }\n}\nI have ruled out the following possible causes:\n\nprogram doesn't have access to the doc\ntoo many worksheets in the doc\nover api limit\n\nI even created a copy of the doc and tried to access that and the same error occurred.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2282,"Q_Id":58867054,"Users Score":0,"Answer":"Well, I had the same error. I just created another spreadsheet and it worked.","Q_Score":0,"Tags":"python-3.x,google-sheets,google-sheets-api,gspread","A_Id":59144886,"CreationDate":"2019-11-14T21:50:00.000","Title":"gspread.exceptions.APIError error code 500","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I just got my 2080 ti today and hooked it right up to experiment with Keras on my models. But for some reason, when I train on a dense model the 2080 ti is 2 times slower than my CPU (an i7 4790k) and definitely slower than my old GTX 1070 (don't have exact numbers to compare it to).\nTo train one epoch on my CPU it takes 27 seconds while the 2080 ti is taking 67 seconds with nothing about the model or data changing. Same batch size of 128, etc. This is also significantly slower than my 1070 I just had in the machine last night. I checked the GPU usage while training and the memory usage goes up to max, and the GPU usage goes up to about 20%, while idle is 4%. I have CUDA 10, and the latest CuDNN on NVIDIA's site: v7.6.5. TensorFlow is 1.15\nDoes anyone have any clue what is going on here? If any more details are needed, just comment I can add them.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":884,"Q_Id":58867071,"Users Score":2,"Answer":"I figured it out! Thanks to the suggestion of a friend who got a 2060 recently, he noted that the default power mode is maximum power savings in the Nvidia Control Panel, or P8 power mode according to nvidia-smi (which is half clock speeds). After setting to prefer maximum performance in 3D settings, training times have significantly been reduced.","Q_Score":1,"Tags":"python,tensorflow,keras","A_Id":58885009,"CreationDate":"2019-11-14T21:51:00.000","Title":"Keras - RTX 2080 ti training slower than both CPU-only and GTX 1070?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using SMOP version 0.41 to translate my MATLAB code to anaconda python however\nwhenever there is a statement with a greater or equal to statment for example:\nif numFFT >= 2\nI get the following error\nSyntaxError: Unexpected \"=\" (parser)\nHas anyone experienced this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":246,"Q_Id":58867582,"Users Score":0,"Answer":"you can simply edit lexer.py for greater or equal by putting \"\\\" in front of \"<\" or \">\". \nexample: \nfrom \"<=\"\nto \"\\<=\" or \"<\\=\", both of them works the same on your converted python code.","Q_Score":0,"Tags":"python,matlab","A_Id":59451889,"CreationDate":"2019-11-14T22:38:00.000","Title":"smop has issues when translating a >= statment in MATLAB","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm connecting to an oracle database and trying to bring across a table with roughly 77 million rows. At first I tried using chunksize in pandas but I always got a memory error no matter what chunksize I set. I then tried using Dask since I know its better for large amounts of data. However, there're some columns that need to be made NULL, is there away to do this within read_sql_table query like there is in pandas when you can write out your sql query?\nCheers","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":58868931,"Users Score":0,"Answer":"If possible, I recommend setting this up on the oracle side, making a view with the correct data types, and using read_sql_table with that.\nYou might be able to do it directly, since read_sql_table accepts sqlalchemy expressions. If you can phrase it as such, it ought to work.","Q_Score":0,"Tags":"python,pandas,dask","A_Id":58879617,"CreationDate":"2019-11-15T01:16:00.000","Title":"Is there a way to set columns to null within dask read_sql_table?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large pickle file and I want to load the data from pickle file to train a deep learning model. Is there any way if I can use a generator to load the data for each key? The data is in the form of a dictionary in the pickle file. I am using pickle.load(filename), but I am afraid that it will occupy too much RAM while running the model. I used pickle.HIGHEST_PROTOCOL to dump the data to the pickle file initially.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":513,"Q_Id":58869572,"Users Score":3,"Answer":"Nope. The pickle file format isn't like JSON or something else where you can just read part of it and decode it incrementally. A pickle file is a list of instructions for building a Python object, and just like following half the instructions to bake a cake won't bake half a cake, reading half a pickle won't give you half the pickled object.","Q_Score":1,"Tags":"python,python-3.x,generator,pickle","A_Id":58869681,"CreationDate":"2019-11-15T02:38:00.000","Title":"Can we read the data in a pickle file with python generators","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to do sentiment analysis using machine learning (text classification) approach. For example nltk Naive Bayes Classifier.\nBut the issue is that a small amount of my data is labeled. (For example, 100 articles are labeled positive or negative) and 500 articles are not labeled.\nI was thinking that I train the classifier with labeled data and then try to predict sentiments of unlabeled data. \nIs it possible? \nI am a beginner in machine learning and don't know much about it. \nI am using python 3.7. \nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":299,"Q_Id":58869955,"Users Score":1,"Answer":"Is it possible to train the sentiment classification model with the labeled data and then use it to predict sentiment on data that is not labeled?\n\nYes. This is basically the definition of what supervised learning is.\nI.e. you train on data that has labels, so that you can then put it into production on categorizing your data that does not have labels.\n(Any book on supervised learning will have code examples.)\nI wonder if your question might really be: can I use supervised learning to make a model, assign labels to another 500 articles, then do further machine learning on all 600 articles? Well the answer is still yes, but the quality will fall somewhere between these two extremes:\n\nAssign random labels to the 500. Bad results.\nGet a domain expert assign correct labels to those 500. Good results.\n\nYour model could fall anywhere between those two extremes. It is useful to know where it is, so know if it is worth using the data. You can get an estimate of that by taking a sample, say 25 records, and have them also assigned by a domain expert. If all 25 match, there is a reasonable chance your other 475 records also have been given good labels. If  e.g. only 10 of the 25 match, the model is much closer to the random end of the spectrum, and using the other 475 records is probably a bad idea.\n(\"10\", \"25\", etc. are arbitrary examples; choose based on the number of different labels, and your desired confidence in the results.)","Q_Score":0,"Tags":"nltk,python-3.7,sentiment-analysis,text-classification,training-data","A_Id":58874622,"CreationDate":"2019-11-15T03:34:00.000","Title":"Is it possible to train the sentiment classification model with the labeled data and then use it to predict sentiment on data that is not labeled?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm reading these days about deep learning and its utilization and the methods we can use it. I had a general question regarding the image verification or let's say a simple matrix. \nSuppose I have a matrix of size X = (4,4) and a vector of size Y = (1,4), I multiplied the the vector Y by only one column from X, let's say the second column. Hence, Z = Y.*X(:,2). Suppose I know the matrix X and resulted vector Z, can I use the deep learning to verify which column from X was multiplied based on Z and X ? \nI know, we can all simply use Maximum likehood decoder, or by divided X\/Z ; In reality I need to avoid these conventional ways and go to deep learning. Can we do that using deep learning? which algorithm can be used in that case ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":58870076,"Users Score":1,"Answer":"You can all simply use DNN, however the results are not that good compared with ML but there is no way to solve that.","Q_Score":0,"Tags":"python,algorithm,machine-learning,deep-learning","A_Id":58950331,"CreationDate":"2019-11-15T03:50:00.000","Title":"Which algorithm in Deep learning can verfity the relationship of column into a matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a regex expression in Python for non-hyphenated words but I am unable to figure out the right syntax.\nThe requirements for the regex are:\n\nIt should not contain hyphens AND \nIt should contain atleast 1 number\n\nThe expressions that I tried are:= \n\n^(?!.*-)\n\n\nThis matches all non-hyphenated words but I am not able to figure out how to additionally add the second condition.\n\n\n^(?!.*-(?=\/d{1,}))\n\n\nI tried using double lookahead but I am not sure about the syntax to use for it. This matches ID101 but also matches STACKOVERFLOW\n\nSample Words Which Should Match:\n1DRIVE , ID100 , W1RELESS\nSample Words Which Should Not Match:\nBasically any non-numeric string (like STACK , OVERFLOW) or any hyphenated words (Test-11 , 24-hours)\nAdditional Info:\nI am using library re and compiling the regex patterns and using re.search for matching.\nAny assistance would be very helpful as I am new to regex matching and am stuck on this for quite a few hours.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":409,"Q_Id":58870161,"Users Score":2,"Answer":"I came up with -\n^[^-]*\\d[^-]*$\n\nso we need at LEAST one digit (\\d)\nWe need the rest of the string to contain anything BUT a - ([^-])\nWe can have unlimited number of those characters, so [^-]*\nbut putting them together like [^-]*\\d would fail on aaa3- because the - comes after a valid match- lets make sure no dashes can sneak in before or after our match ^[-]*\\d$\nUnfortunately that means that aaa555D fails. So we actually need to add the first group again- ^[^-]*\\d[^-]$  --- which says start - any number of chars that aren't dashes - a digit - any number of chars that aren't dashes - end\nDepending on style, we could also do ^([^-]*\\d)+$ since the order of the digits\/numbers dont matter, we can have as many of those as we want.\n\nHowever, finally... this is how I would ACTUALLY solve this particular problem, since regexes may be powerful, but they tend to make the code harder to understand...\nif (\"-\" not in text) and re.search(\"\\d\", text):","Q_Score":2,"Tags":"python,regex,match,hyphen","A_Id":58870312,"CreationDate":"2019-11-15T04:01:00.000","Title":"Regex Match for Non Hyphenated Words - Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a python code which writes a hyperlink into a excel file.This hyperlink should open in a specific page in a pdf document.\nI am trying something like\nWorksheet.write_url('A1',\"C:\/Users\/.....\/mypdf#page=3\") but this doesn't work.Please let me know how this can be done.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":404,"Q_Id":58871922,"Users Score":1,"Answer":"Are you able to open the pdf file directly to a specific page even without xlsxwriter? I can not.\nFrom Adobe's official site:\n\nTo target an HTML link to a specific page in a PDF file, add\n  #page=[page number] to the end of the link's URL.\nFor example, this HTML tag opens page 4 of a PDF file named\n  myfile.pdf:\n\nNote: If you use UNC server locations (\\servername\\folder) in a link,\n  set the link to open to a set destination using the procedure in the\n  following section. \nIf you use URLs containing local hard drive addresses (c:\\folder), you cannot link to page numbers or set destinations.","Q_Score":0,"Tags":"python,excel,pdf,xlsxwriter","A_Id":59052912,"CreationDate":"2019-11-15T07:07:00.000","Title":"How do I link to a specific page of a PDF document inside a cell in Excel?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am checking my data for stationarity. I have a time series with daily data between 1986 and 2019. I would like to know what is the right way to choose the window for the rolling mean and std. I was thinking 252 - the number of business days a year, but I am not sure if this is too big a period.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":397,"Q_Id":58872026,"Users Score":1,"Answer":"There are various factors to be considered before choosing the correct time time for rolling mean (moving average). First you should have a clear aim (forecasting, smoothing, etc). Mostly people use it for forecasting in stock prices (thus i assume you have daily data for a stock\/commodity\/trade-able product and you would like to predict its prices using rolling mean. \nCheck out the seasonality component and how much fluctuation is happening in the data and if by observation you can see that if has a cycle of say 2 months (60 days, or approx 50 working days) then your period of rolling mean should be lesser than it.\nIn short there is not sure shot formula for finding the period of most suitable rolling mean to be used, and there is subjectivity involved in it.","Q_Score":0,"Tags":"python,time-series","A_Id":58872134,"CreationDate":"2019-11-15T07:15:00.000","Title":"How to appropriately choose the window for calculating rolling mean and std?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I launched Jupyter Notebook, created a new notebook in python, imported the necessary libraries and tried to access a .xlsx file on the desktop with this code:\nhaber = pd.read_csv('filename.xlsx') \nbut error keeps popping up. Want a reliable way of accessing this file on my desktop without incurring any error response","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":3030,"Q_Id":58872437,"Users Score":2,"Answer":"This is an obvious path problem, because your notebook is not booted on the desktop path, you must indicate the absolute path to the desktop file, or the relative path relative to the jupyter boot directory.","Q_Score":0,"Tags":"python,python-3.x,pandas","A_Id":58872562,"CreationDate":"2019-11-15T07:47:00.000","Title":"How do you read files on desktop with jupyter notebook?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to make your Selenium script undetectable in Python using geckodriver?\nI'm using Selenium for scraping. Are there any protections we need to use so websites can't detect Selenium?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21277,"Q_Id":58873022,"Users Score":0,"Answer":"It may sound simple, but if you look how the website detects selenium (or bots) is by tracking the movements, so if you can make your program slightly towards like a human is browsing the website you can get less captcha, such as add cursor\/page scroll movements in between your operations, and other actions which mimics the browsing. So between two operations try to add some other actions, Add some delay etc. This will make your bot slower and could get undetected.\nThanks","Q_Score":20,"Tags":"python,selenium,firefox,geckodriver,selenium-firefoxdriver","A_Id":71659726,"CreationDate":"2019-11-15T08:29:00.000","Title":"How can I make a Selenium script undetectable using GeckoDriver and Firefox through Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had Python 3.5 on Ubuntu 16.04 and then I installed Python 3.7 and made it the default Python.\nNow most of the programs I run go Python 3.7 but some run on 3.5 (I don't know why).\nAlso, the system says that there is a problem with python 3.5 but I can't figure what it is.\nCan anyone help?\nThank You","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":58873569,"Users Score":0,"Answer":"Configure PYTHON_PATH pointing proper library path or set path environment variable pointing to correct Python version.","Q_Score":0,"Tags":"ubuntu-16.04,python-3.5,python-3.7","A_Id":58888916,"CreationDate":"2019-11-15T09:07:00.000","Title":"Having proplem with Python 3.5 after installing Python 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm looking for the time complexity of these methods as a function of the number of rows in a dataframe, n. \nAnother way of asking this question is: Are indexes for dataframes in pandas btrees (with log(n) time look ups) or hash tables (with constant time lookups)?\nAsking this question because I'd like a way to do constant time look ups for rows in a dataframe based on a custom index.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2034,"Q_Id":58876676,"Users Score":2,"Answer":"Alright so it would appear that:\n1) You can build your own index on a dataframe with .set_index in O(n) time where n is the number of rows in the dataframe\n2) The index is lazily initialized and built (in O(n) time) the first time you try to access a row using that index. So accessing a row for the first time using that index takes O(n) time\n3) All subsequent row access takes constant time. \nSo it looks like the indexes are hash tables and not btrees.","Q_Score":4,"Tags":"python,pandas,performance,data-structures,time-complexity","A_Id":58882586,"CreationDate":"2019-11-15T12:03:00.000","Title":"What is the time complexity of .at and .loc in pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python module which is designed to be used by non-programmers, interactively. It is used within iPython, and on load, it asks for a couple of user inputs, prints some ascii art, that sort of thing. This is implemented in the __init__.py of the module.\nThe module also contains a utils file tld(containing setup.py)\/utils.py, with some functions in it.  I would like to test these. The utils file does not import anything from the rest of the module, and contains only pure functions. The tests live in tld(containing setup.py)\/tests\/test_utils.pyCurrently, trying to run pytest results in a failure, as the module's __init__ file is run, which hangs whilst awaiting the above mentioned user input.\nIs there a way of getting pytest to run the tests in test_utils.py, without running the __init__.py of the python module? Or some other way of getting around this issue?\nI have tried running pytest tests\/test_utils.py, but that had the same effect.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":135,"Q_Id":58877894,"Users Score":0,"Answer":"I solved this by defining an initialize function inside the __init__.py of the module, which encapsulates all of the user interaction. If module.initialize() is not explicitly called, no user input is requested, so the pytest tests can run as expected.","Q_Score":1,"Tags":"python,pytest","A_Id":58891396,"CreationDate":"2019-11-15T13:17:00.000","Title":"Testing an interactive module with pytest","Data 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 looking for a way to program using python on an Arduino. Are there any up-to date interpreters available? I looked at some older questions, but there are no up-to date versions. Specifically, I'm looking for a way to program it on an Arduino Uno rev 3.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":52,"Q_Id":58878124,"Users Score":2,"Answer":"You cannot program an Arduino Uno in Python. You need a more powerful MCU to run a Python compiler\/runtime like MicroPython.\nMicroPythons memory requirements exceed Arduinos specs.","Q_Score":0,"Tags":"python,arduino","A_Id":58879477,"CreationDate":"2019-11-15T13:32:00.000","Title":"Can you program python onto an Arduino","Data 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 trying to make the Password Locker project in chapter 6 of the book, \"Automate the boring stuff with python\". The project requires one to use the command prompts to get the password of any account added to the dictionary in .py file. I have been trying to run it by using win + R button, but the Command window just appears and vanishes in a blink of an eye (literally), not allowing me to copy anything from the command window to notepad. I have followed all the necessary steps like creating the folder for storing the scripts and adding the folder path to environment variables. The code is simply copied from the book, I did not try to mess with it. I can't seem to pinpoint where the problem is and it is a bit problematic as all the projects in the further chapters use the .bat file with pause.exe. Help me and I will be your slave for life (not literally). Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":58882551,"Users Score":0,"Answer":"I solve this issue by creating a new folder on with the name Python34 on C:, also I copy the pw.py and the bat file.","Q_Score":1,"Tags":"python,python-3.x,passwords,pause","A_Id":62720376,"CreationDate":"2019-11-15T18:11:00.000","Title":"My bat file does not run pause.exe for the Password Locker project in chapter 6 of \"Automate the boring stuff with python\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to make a wx.html2.WebView high enough that its contents don't need to be scrolled.\nI tried using javascript in RunScript to detect that document height is larger than window height, but it won't work on some backends, for which RunScript does not return results.\nCan I detect scrollbars on the WebView from Python to adapt the height ? Is there another way ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":58884535,"Users Score":0,"Answer":"I found a hack that works : I inject javascript that on document load navigates to \"size:\"+document.body.scrollHeight\nThen, I bind to the event EVT_WEBVIEW_NAVIGATING, veto it and use the URL from the event to get the height and set the WebView height to it.","Q_Score":0,"Tags":"python,wxpython,wx.html2","A_Id":58888256,"CreationDate":"2019-11-15T20:55:00.000","Title":"How to adapt the height of a wx.html2.WebView to its contents?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I apologize in advance for my lack of technical terminology?\nNot experienced with Python just trying to make a change to a program that I bought off of a freelancer. There's a couple py files with edits I'm trying to make. I understand you have to do some sort of \"recompile\" instruction in the terminal to actually save the edits, is that correct?\nWhat's the exact thing I have put into the terminal to actually get this to work?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":58885351,"Users Score":1,"Answer":"No, you simply save the text changes from your editor.  If your IDE uses *.pyc (Python pre-compiled) files, it should note the update (inversion of time stamps), and recompile as needed.  If you don't have pyc files, then there's no update to make - the code is interpreted, so you get the new version at the next invocation.","Q_Score":0,"Tags":"python","A_Id":58885378,"CreationDate":"2019-11-15T22:11:00.000","Title":"How to save edits\/recompile changes made .py files in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"\"banana\" < \"orange\" if I compare this two strings in Python-3 they return True. But I see that both strings have 6 characters each. \nAgain when I try with \"banana\" < \"Orange\" returns False though they are also still consisted of 6 characters each. I can't understand them? Could you please help me to understand them in a simple way?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":186,"Q_Id":58887658,"Users Score":1,"Answer":"When two strings are being compared, they do so character by character, starting from their first (leftmost) character up to their last (rightmost) character. Each of this chars are compared in accordance to their ASCII code, if one char is found to have a smaller code then that string is deemed smaller (not to be taken in a length sense, but rather in a lexicographical sense), the same goes for a greater code, if both codes are the same then the comparison takes the next character of each string and compares them again, and so on.\nTake banana and orange and let's compare them. Their first char is b and o, with codes of 98 and 111 respectively, since 98 < 111, then b < o and therefore, banana < orange. However, banana > Orange because b > O since their codes, 98 > 79. In fact banana > Banana.","Q_Score":3,"Tags":"python,python-3.x,boolean,python-3.7","A_Id":58887784,"CreationDate":"2019-11-16T04:45:00.000","Title":"\"banana\" < \"orange\" is True and \"banana\" < \"Orange\" is False but why?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"\"banana\" < \"orange\" if I compare this two strings in Python-3 they return True. But I see that both strings have 6 characters each. \nAgain when I try with \"banana\" < \"Orange\" returns False though they are also still consisted of 6 characters each. I can't understand them? Could you please help me to understand them in a simple way?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":186,"Q_Id":58887658,"Users Score":1,"Answer":"It is called 'Dictionary order'. It compares strings in the way a dictionary contains words. 'b' < 'o' that is whay \"banana\" < \"orange\".\nIf it would be \"bbbba\" and \"bbbbb\" then it would be \"bbbba\"< \"bbbbb\".\nIf it would be \"zzz\" and \"bbbb\" then it would be \"zzz\" > \"bbbb\"","Q_Score":3,"Tags":"python,python-3.x,boolean,python-3.7","A_Id":58887706,"CreationDate":"2019-11-16T04:45:00.000","Title":"\"banana\" < \"orange\" is True and \"banana\" < \"Orange\" is False but why?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"\"banana\" < \"orange\" if I compare this two strings in Python-3 they return True. But I see that both strings have 6 characters each. \nAgain when I try with \"banana\" < \"Orange\" returns False though they are also still consisted of 6 characters each. I can't understand them? Could you please help me to understand them in a simple way?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":186,"Q_Id":58887658,"Users Score":1,"Answer":"This is because strings are compared based on their ACSII values character by character. When you use lowercase 'b' (#98) is less than 'o' (#111) and comparison evaluates to True. In the second case the capital 'O' is number 79 and as a result it evaluates as False.","Q_Score":3,"Tags":"python,python-3.x,boolean,python-3.7","A_Id":58887704,"CreationDate":"2019-11-16T04:45:00.000","Title":"\"banana\" < \"orange\" is True and \"banana\" < \"Orange\" is False but why?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I\u2019m a new programmer and starting to use Python 3, and I see some videos of people teaching the language and use \u201cimport\u201d. My question is how they know what to import and where you can see all the things you can import. I used import math in one example that I followed along with, but I see other videos of people using import JSON or import random, and I\u2019m curious how they find what they can import and how they know what it will do.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":133,"Q_Id":58887723,"Users Score":1,"Answer":"In all programming languages, whenever you actually need a library, you should import it. For example, if you need to generate a random number, search for this function in your chosen programming language, find the appropriate library, and import it into your code.","Q_Score":1,"Tags":"python,python-3.x,import","A_Id":58887753,"CreationDate":"2019-11-16T04:57:00.000","Title":"Using import in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know how to make Spyder stop automatically inserting closing brackets?\nIt often results in complete mess when you have multiple levels of different brackets. I had a look around and could only find posts about auto-closing quotes, but I'm not really interested in these. But those brackets are making me slightly miserable.\nI had a look in Preferences but the closest I could find is 'Automatic code completion'. But I certainly don't want all of it off especially when working with classes.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":620,"Q_Id":58887849,"Users Score":3,"Answer":"In Spyder 4 and Spyder 5 go to:\n\nTools - Preferences - Editor - Source code\n\nand deselect the following items:\n\nAutomatic insertion of parentheses, braces and brackets\n\nAutomatic insertion of closing quotes (since it's the same nuisance than with brackets)","Q_Score":1,"Tags":"python,anaconda,spyder","A_Id":62667400,"CreationDate":"2019-11-16T05:22:00.000","Title":"Spyder Editor - How to Disable Auto-Closing Brackets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As the title says, is the print() function in python a void function?\nI thought the print() function returns and prints to screen what is passed into it. Now that I think about it, it seems like it doesn't return anything and is indeed a void function. Can someone verify this for me please? Thanks in advance!\nI've tried the following:\nsome_variable = print()\nprint(some_variable)\n None","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":866,"Q_Id":58887944,"Users Score":1,"Answer":"It does not return a value, which is the same as returning None.  You won't find it explicitly in the documentation as functions returning None simply omit documenting the return value.","Q_Score":0,"Tags":"python,function,python-3.7","A_Id":58887963,"CreationDate":"2019-11-16T05:41:00.000","Title":"Is the print() function in python considered a void function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python and Django and want to install mysqlclient on windows. When I use the command pip install django mysqlclient in cmd it throws this error : \n\nFile \"d:\\myprojects\\python\\mytestdjangoprj\\myproject\\lib\\genericpath.py\", line 30, in isfile\n          st = os.stat(path)\n      TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType\n\nPlease help me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":562,"Q_Id":58888555,"Users Score":2,"Answer":"As Alasdair said , using 64 bit solve problem.thanks Alasdair.","Q_Score":2,"Tags":"python,mysql,django,windows","A_Id":58889819,"CreationDate":"2019-11-16T07:31:00.000","Title":"pip install django mysqlclient 'path should be string, bytes, os.PathLike or integer, not NoneType' on windows","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm getting this error anytime when creating a new project in pycharm:\n\nCannot run program \"C:\\Program\n  Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\\python.exe\"\n  (in directory \"C:\\Program\n  Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\"):\n  CreateProcess error=5, Access is denied\n\nI have Python 3.8 installed from Windows Store but when I try to create the project it says \"Choose another SDK\"\nIt seems like a fairly common issue but since I'm new to Python I'm not really sure what it involves.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1489,"Q_Id":58892354,"Users Score":0,"Answer":"Try installing Python 3 from the actual Python Webpage. \nThe windows store version may be confusing pycharm by storing\/sorting the .py files in an odd way. Could also be a PATH issue due to windows store version etc.\nHope this helps!","Q_Score":0,"Tags":"python,django,pycharm","A_Id":58892435,"CreationDate":"2019-11-16T15:37:00.000","Title":"Cannot run program \"\/..\/..\/python.exe\" (in directory \"\/PythonSoftwareFoundation.Python.3.8_3.8.240.0_x64__qbz5n2kfra8p0\"):Access is denied","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want a reverse proxy (using mitmproxy\/mitmdump) for an insecure site. I want the proxy to run on a non-standard port (not 443) and to be accessible only via https. This is the closest I've gotten:\nmitmdump -p 2112 --mode reverse:http:\/\/localhost:41781 --set block_global=false --certs full.pem\nThis works when I access it via https: https:\/\/localhost:2112. The problem is, it is also accessible via http: http:\/\/localhost:2112.\nHow do I disable that and make it only accessible via https?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2329,"Q_Id":58892960,"Users Score":0,"Answer":"(Obligatory: Use Apache\/nginx\/... if you need a production-grade reverse proxy)\nMitmproxy currently always supports both HTTP and HTTPS to simplify setups (we had lots of bug reports because of misconfigurations). If you want to disable HTTP, you could write an addon that detects flow.request.scheme == \"http\" and then either invokes flow.kill() or sets flow.response = mitmproxy.http.HTTPResponse.make(<redirect data here>). Lastly, you can also make sure to set HSTS headers in the response hook in mitmproxy.","Q_Score":1,"Tags":"python,ssl,reverse-proxy,mitmproxy","A_Id":58916214,"CreationDate":"2019-11-16T16:45:00.000","Title":"mitmproxy reverse proxy - want SSL only on non-standard port","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 azureml-sdk behind a corporate's proxy and therefore forced to manually add the proxy's certificate to the list of trusted hosts. It works fine by manually append the server certificate to the file \"cert_ca.pem\" of the package certifi. \nAs mentioned in the documentation of python-requests, this should also be possible by setting the environment variable \"REQUESTS_CA_BUNDLE\" to a specific file. However, the environment variable seems to be ignored by azureml-sdk. Is this the correct behavior? Or how is it possible to specify an own \"pem\" file?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":243,"Q_Id":58892964,"Users Score":0,"Answer":"The correct environment variable is REQUESTS_CA_BUNDLE - note the plural.","Q_Score":2,"Tags":"python,azure,ssl,azure-machine-learning-service,certifi","A_Id":58896952,"CreationDate":"2019-11-16T16:45:00.000","Title":"azureml-sdk ignores the REQUESTS_CA_BUNDLE environment variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Let's say I have a Hash-table, each key is defined as a tuple with 4 integers (A, B, C, D). where are integers represent a quantity of a certain attribute, and its corresponding value is a tuple of gears that satisfy (A, B, C, D).\nI wanted to write a program that do the following: with any given attribute tuple (x, y, z, w), I want to find all the keys satisfying (|A - x| + |B - y| + |C - z| + |D - w|) \/ 4 <= i where i is a user defined threshold; return the value of these keys if exist and do some further calculation.  (|A - x| means the absolute value of A - x)\nTo my experience, this kind of thing can be better done with Answer set programming, Haskell, Prolog and all this kind of logical programming languages, but I'm forced to use python for this is a python project...\nI can hard code for a particular \"i\" but I really have no idea how to do this for arbitrary integers. please tell me how I can do this in pure python, Thank you very much!!!!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":58896351,"Users Score":1,"Answer":"Just write a function that loops over all values in the table and checks them one by one.  The function will take the table and i as arguments.","Q_Score":0,"Tags":"python,hashtable","A_Id":58896375,"CreationDate":"2019-11-17T00:01:00.000","Title":"Get all keys in a hash-table that satisfy certain arithmetic property","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m training linear model on MNIST dataset, but I wanted to train only on one digit that is 4. How do I choose my X_test,X_train, y_test, y_train?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":157,"Q_Id":58896645,"Users Score":0,"Answer":"If you only need to recognize 4s it's a binary classification problem, so you just need to create a new target variable: Y=1 if class is 4, Y=0 if class is not 4.\n\nTrain_X will be unchanged \nTrain_Y will be your new target variable related to Train_X\nTest_X will be unchanged \nTest_Y will be your new target variable related to Test_X.\n<\\ul>\n\nData will be a bit unbalanced but it should not be an issue!","Q_Score":0,"Tags":"python,mnist,sklearn-pandas","A_Id":59198937,"CreationDate":"2019-11-17T01:08:00.000","Title":"MNIST dataset with Sklearn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m training linear model on MNIST dataset, but I wanted to train only on one digit that is 4. How do I choose my X_test,X_train, y_test, y_train?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":157,"Q_Id":58896645,"Users Score":0,"Answer":"Your classifier needs to learn to discriminate between sets of different classes.\nIf you only care about digit 4, you should split your training and testing set into:\n\nClass 4 instances\nNot class 4 instances: union of all other digits\n\nOtherwise the train\/test split is still the typical one, where you want to have no overlap.","Q_Score":0,"Tags":"python,mnist,sklearn-pandas","A_Id":58896802,"CreationDate":"2019-11-17T01:08:00.000","Title":"MNIST dataset with Sklearn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried to train my model using ssd_mobilenet_v1_coco_11_06_2017 ,ssd_mobilenet_v1_coco_2018_01_28 and faster_rcnn_inception_v2_coco_2018_01_28 and did it successfully however when i tried to run object_detection_tutorial.ipynb and test my test_images all i get is images without bounding boxes, i trained my model using model_main.py and also tried train.py and i aquired a loss of < 1 in both. i am using tensorflow = 1.14 and i tried it on tensorflow = 2.0. im stuck in this final step. i am positive i create my tfrecords correctly. and also when i run the models(ssd_mobilenet_v1_coco_11_06_2017 ,ssd_mobilenet_v1_coco_2018_01_28 and faster_rcnn_inception_v2_coco_2018_01_28) that i trained them on they worked perfectly, so i suspect that there is something wrong with my model","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":58897297,"Users Score":0,"Answer":"Did you update the path of your model in the object_detection_tutorial.ipynb file, \"tf.saved_model.load\" is the API where you have to give the path of your trained model.","Q_Score":0,"Tags":"python,python-3.x,tensorflow,object-detection,object-detection-api","A_Id":58917762,"CreationDate":"2019-11-17T03:41:00.000","Title":"No bouding boxes create when running my trained model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I type the following in the the windows command prompt: pip install jupyterlab\nI received the following error:\n\n   ERROR: Command errored out with exit status 1:\n     command: 'c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '\"'\"'C:\\\\Users\\\\Admin\\\\AppData\\\\Local\\\\Temp\\\\pip-install-0mx8si2m\\\\pywinpty\\\\setup.py'\"'\"'; __file__='\"'\"'C:\\\\Users\\\\Admin\\\\AppData\\\\Local\\\\Temp\\\\pip-install-0mx8si2m\\\\pywinpty\\\\setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))' egg_info --egg-base 'C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-0mx8si2m\\pywinpty\\pip-egg-info'\n         cwd: C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-0mx8si2m\\pywinpty\\\n    Complete output (166 lines):\n    Compiling C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Plex\\Scanners.py because it changed.\n    Compiling C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Plex\\Actions.py because it changed.\n    Compiling C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Compiler\\Scanning.py because it changed.\n    Compiling C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Compiler\\Visitor.py because it changed.\n    Compiling C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Compiler\\FlowControl.py because it changed.\n    Compiling C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Runtime\\refnanny.pyx because it changed.\n    Compiling C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Compiler\\FusedNode.py because it changed.\n    Compiling C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Tempita\\_tempita.py because it changed.\n    [1\/8] Cythonizing C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Compiler\\FlowControl.py\n    [2\/8] Cythonizing C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Compiler\\FusedNode.py\n    [3\/8] Cythonizing C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Compiler\\Scanning.py\n    [4\/8] Cythonizing C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Compiler\\Visitor.py\n    [5\/8] Cythonizing C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Plex\\Actions.py\n    [6\/8] Cythonizing C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Plex\\Scanners.py\n    [7\/8] Cythonizing C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Runtime\\refnanny.pyx\n    [8\/8] Cythonizing C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Tempita\\_tempita.py\n    Unable to find pgen, not compiling formal grammar.\n    warning: no files found matching 'Doc\\*'\n    warning: no files found matching '*.pyx' under directory 'Cython\\Debugger\\Tests'\n    warning: no files found matching '*.pxd' under directory 'Cython\\Debugger\\Tests'\n    warning: no files found matching '*.pxd' under directory 'Cython\\Utility'\n    warning: no files found matching 'pyximport\\README'\n    Scanners.c\n       Creating library build\\temp.win32-3.8\\Release\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Plex\\Scanners.cp38-win32.lib and object build\\temp.win32-3.8\\Release\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\Cython\\Plex\\Scanners.cp38-win32.exp\n    Generating code\n    Finished generating code\n    LINK : fatal error LNK1158: cannot run 'rc.exe'\n    Traceback (most recent call last):\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\_msvccompiler.py\", line 534, in link\n        self.spawn([self.linker] + ld_args)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\_msvccompiler.py\", line 557, in spawn\n        return super().spawn(cmd)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\ccompiler.py\", line 910, in spawn\n        spawn(cmd, dry_run=self.dry_run)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\spawn.py\", line 38, in spawn\n        _spawn_nt(cmd, search_path, dry_run=dry_run)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\spawn.py\", line 80, in _spawn_nt\n        raise DistutilsExecError(\n    distutils.errors.DistutilsExecError: command 'C:\\\\Program Files (x86)\\\\Microsoft Visual Studio 14.0\\\\VC\\\\BIN\\\\link.exe' failed with exit status 1158\n\n    During handling of the above exception, another exception occurred:\n\n    Traceback (most recent call last):\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\core.py\", line 148, in setup\n        dist.run_commands()\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\dist.py\", line 966, in run_commands\n        self.run_command(cmd)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\dist.py\", line 985, in run_command\n        cmd_obj.run()\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\command\\bdist_egg.py\", line 172, in run\n        cmd = self.call_command('install_lib', warn_dir=0)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\command\\bdist_egg.py\", line 158, in call_command\n        self.run_command(cmdname)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\cmd.py\", line 313, in run_command\n        self.distribution.run_command(command)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\dist.py\", line 985, in run_command\n        cmd_obj.run()\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\command\\install_lib.py\", line 11, in run\n        self.build()\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\command\\install_lib.py\", line 107, in build\n        self.run_command('build_ext')\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\cmd.py\", line 313, in run_command\n        self.distribution.run_command(command)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\dist.py\", line 985, in run_command\n        cmd_obj.run()\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\command\\build_ext.py\", line 84, in run\n        _build_ext.run(self)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\command\\build_ext.py\", line 340, in run\n        self.build_extensions()\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\command\\build_ext.py\", line 449, in build_extensions\n        self._build_extensions_serial()\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\command\\build_ext.py\", line 474, in _build_extensions_serial\n        self.build_extension(ext)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\command\\build_ext.py\", line 205, in build_extension\n        _build_ext.build_extension(self, ext)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\command\\build_ext.py\", line 550, in build_extension\n        self.compiler.link_shared_object(\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\ccompiler.py\", line 713, in link_shared_object\n        self.link(CCompiler.SHARED_OBJECT, objects,\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\_msvccompiler.py\", line 537, in link\n        raise LinkError(msg)\n    distutils.errors.LinkError: command 'C:\\\\Program Files (x86)\\\\Microsoft Visual Studio 14.0\\\\VC\\\\BIN\\\\link.exe' failed with exit status 1158\n\n    During handling of the above exception, another exception occurred:\n\n    Traceback (most recent call last):\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\sandbox.py\", line 154, in save_modules\n        yield saved\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\sandbox.py\", line 195, in setup_context\n        yield\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\sandbox.py\", line 250, in run_setup\n        _execfile(setup_script, ns)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\sandbox.py\", line 45, in _execfile\n        exec(code, globals, locals)\n      File \"C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\setup.py\", line 228, in \n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\__init__.py\", line 145, in setup\n        return distutils.core.setup(**attrs)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\core.py\", line 163, in setup\n        raise SystemExit(\"error: \" + str(msg))\n    SystemExit: error: command 'C:\\\\Program Files (x86)\\\\Microsoft Visual Studio 14.0\\\\VC\\\\BIN\\\\link.exe' failed with exit status 1158\n\n    During handling of the above exception, another exception occurred:\n\n    Traceback (most recent call last):\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\command\\easy_install.py\", line 1144, in run_setup\n        run_setup(setup_script, args)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\sandbox.py\", line 253, in run_setup\n        raise\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\contextlib.py\", line 131, in __exit__\n        self.gen.throw(type, value, traceback)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\sandbox.py\", line 195, in setup_context\n        yield\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\contextlib.py\", line 131, in __exit__\n        self.gen.throw(type, value, traceback)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\sandbox.py\", line 166, in save_modules\n        saved_exc.resume()\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\sandbox.py\", line 141, in resume\n        six.reraise(type, exc, self._tb)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\_vendor\\six.py\", line 685, in reraise\n        raise value.with_traceback(tb)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\sandbox.py\", line 154, in save_modules\n        yield saved\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\sandbox.py\", line 195, in setup_context\n        yield\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\sandbox.py\", line 250, in run_setup\n        _execfile(setup_script, ns)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\sandbox.py\", line 45, in _execfile\n        exec(code, globals, locals)\n      File \"C:\\Users\\Admin\\AppData\\Local\\Temp\\easy_install-rvu4jwr1\\Cython-0.29.14\\setup.py\", line 228, in \n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\__init__.py\", line 145, in setup\n        return distutils.core.setup(**attrs)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\distutils\\core.py\", line 163, in setup\n        raise SystemExit(\"error: \" + str(msg))\n    SystemExit: error: command 'C:\\\\Program Files (x86)\\\\Microsoft Visual Studio 14.0\\\\VC\\\\BIN\\\\link.exe' failed with exit status 1158\n\n    During handling of the above exception, another exception occurred:\n\n    Traceback (most recent call last):\n      File \"\", line 1, in \n      File \"C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-0mx8si2m\\pywinpty\\setup.py\", line 68, in \n        setup(\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\__init__.py\", line 144, in setup\n        _install_setup_requires(attrs)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\__init__.py\", line 139, in _install_setup_requires\n        dist.fetch_build_eggs(dist.setup_requires)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\dist.py\", line 716, in fetch_build_eggs\n        resolved_dists = pkg_resources.working_set.resolve(\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pkg_resources\\__init__.py\", line 780, in resolve\n        dist = best[req.key] = env.best_match(\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pkg_resources\\__init__.py\", line 1065, in best_match\n        return self.obtain(req, installer)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\pkg_resources\\__init__.py\", line 1077, in obtain\n        return installer(requirement)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\dist.py\", line 786, in fetch_build_egg\n        return cmd.easy_install(req)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\command\\easy_install.py\", line 679, in easy_install\n        return self.install_item(spec, dist.location, tmpdir, deps)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\command\\easy_install.py\", line 705, in install_item\n        dists = self.install_eggs(spec, download, tmpdir)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\command\\easy_install.py\", line 890, in install_eggs\n        return self.build_and_install(setup_script, setup_base)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\command\\easy_install.py\", line 1158, in build_and_install\n        self.run_setup(setup_script, setup_base, args)\n      File \"c:\\users\\admin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\setuptools\\command\\easy_install.py\", line 1146, in run_setup\n        raise DistutilsError(\"Setup script exited with %s\" % (v.args[0],))\n    distutils.errors.DistutilsError: Setup script exited with error: command 'C:\\\\Program Files (x86)\\\\Microsoft Visual Studio 14.0\\\\VC\\\\BIN\\\\link.exe' failed with exit status 1158\n    ----------------------------------------\nERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2462,"Q_Id":58897318,"Users Score":0,"Answer":"simply follow this to install jupyter in windows :-\n1nd - Go to file manager and find python folder (like:-python,python37,python39 etc...) may be it's in (C:\\Python39) or (C:\\Users\\prade\\AppData\\Local\\Programs\\python39) .\n2rd - in python folder open Scripts folder (Ex:- C:.....\\python39\\Scripts) and copy this path.\n3rd - 'run cmd as administrator' and past above path using cd (like:- cd C:.....\\python39\\Scripts)\n4th - now simply use jupyter install command (like :-\n\npip install jupyterlab\n\n)","Q_Score":2,"Tags":"python,jupyter,jupyter-lab","A_Id":67635524,"CreationDate":"2019-11-17T03:45:00.000","Title":"Jupyter install ERROR: Command errored out with exit status 1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python3.7\/kivy1.11\/numpy1.17 program that I transform into an apk with buildozer on ubuntu 19.04, ok it works.\nBut my program uses a text file for its configuration and that's the problem!\nHow to link this.txt file to the apk and incidentally where to find this file on the mobile?\nSorry, but Android is still a little bit of a mystery to me.\nIn my spec file I only mentioned my txt file as \n        \"source.include_exts = py,kv,txt\"\nbut of course it doesn't work.\nThank you for any suggestions as to how to proceed.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":298,"Q_Id":58898307,"Users Score":1,"Answer":"Buildozer packages whatever folder you tell it, and it's unpacked with the same structure on Android. Just make sure the text file is in that folder, add its extension to source.include_exts (as you already did) and access it the same way you would on the desktop.","Q_Score":0,"Tags":"android,python-3.x,kivy,buildozer","A_Id":58900315,"CreationDate":"2019-11-17T07:08:00.000","Title":"Buildozer android and the attached txt files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have a python consumer group with 50 consumers that consume from 10 topics with 10 partitions each.\nThe consumer group subscribes to all of the topics in which some of them have low throughput.\nWe have a low rate (300 msg\/sec), but when we sent messages just for one topic, and all others are empty, we got a higher rate.\nDo you have any idea?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":794,"Q_Id":58900258,"Users Score":0,"Answer":"You can tune Kafka performance be choosing the right message delivery guarantees: at most once, at least once or exactly once. Give as more details about what delivery guarantees you are using and whats the number of topics\/partition a consumer subscribe and also the replication factor for each topic.","Q_Score":0,"Tags":"python,apache-kafka,kafka-consumer-api","A_Id":58904320,"CreationDate":"2019-11-17T12:07:00.000","Title":"Low rate with python Kafka consumer that reads from multiple topics","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"okay guys been out of coding for a while and im trying to get back in because i love it\ncurrently im writing a python script and im having trouble finding the correct way to click button ive tried several different times and this is where im stuck at. \nAdd to Bag\nwhen copying css selector: \n#dwfrm_product_addtocart_d0rmouqnbpev > div > div.pdp-button-block > button.pdp-add-to-bag.add-to-cart.pid-19CE-ac0eff0691331d3dc991483b06\nwhen copying xpath: \n\/\/*[@id=\"dwfrm_product_addtocart_d0byuazkjuyr\"]\/div\/div[5]\/button[1]\ncode i have in script:\npython_button = driver.find_element_by_xpath(\"\/\/*[@id='dwfrm_product_addtocart_d0byuazkjuyr']\/div\/div[5]\/button[1]\")[0] \n    python_button.click()\n\nive tried different things and currently having a hard time","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":58900666,"Users Score":0,"Answer":"Few points in the line used:\nfind_element_by_xpath(\"\/\/*[@id='dwfrm_product_addtocart_d0byuazkjuyr']\/div\/div[5]\/button[1]\")[0]\n\nfind_element_by_xpath returns a WebElement and not a list of WebElements. So you can remove the [0] as it picks the 1st element matching the xpath.\nOr you can use find_elements_by_xpath if you want to match a list and pick one element using index.\nThe last part of id looks randomly generated, so better use contains instead of going for an exact match.\n\nYou can verify in console if the locator used is correct(using $$ for css and $x for xpath). If it is correct, then see if any other element is overlapping the element that you're trying to click and try clicking on that.\nHope this helps!\nGood luck","Q_Score":0,"Tags":"python,html,css,xpath","A_Id":58909747,"CreationDate":"2019-11-17T12:56:00.000","Title":"find css selector to add to python script using selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My msi motherboard has 2 ports named \"JRGB\" with 4 pins, one for 12v and the other three for each color. Is there any way to make a python script that can control a rgb strip attached to it ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":429,"Q_Id":58901573,"Users Score":0,"Answer":"This depends on the operating system and installed drivers for these jrgb headers. Your Python program needs to talk to these drivers, and I'm pretty confident that there are no platform independent Python libraries available yet. Depending on how the drivers are accessed in your operating system, writing such a library could be relatively simple or quite complicated.\nIf you're using Windows, you may have luck and MSI has a command line utility that could be executed from Python.","Q_Score":0,"Tags":"python,rgb","A_Id":58901679,"CreationDate":"2019-11-17T14:38:00.000","Title":"Is there any way to control an rgb strip attached to a 12v rgb header in the motherboard with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install a module in Python 3.8 and it's giving me an error message. The module is win32console, and I have pywin32. \nThe error is the following : \n\nERROR: Could not find a version that satisfies the requirement\n  win32console","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":352,"Q_Id":58901897,"Users Score":0,"Answer":"It's a little bit late but I had this problem too.\nYou need to install pywin32 first.\nThen win32console will be installed too because it's a part of pywin32\n(you can use pip install pywin32)","Q_Score":0,"Tags":"python,pip","A_Id":63662971,"CreationDate":"2019-11-17T15:12:00.000","Title":"ERROR: Could not find a version that satisfies the requirement win32console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A friend of mine and me are doing some field research for our Physics degree. And we are using jupyter notebook to analyse the data we get. We usually sit together working at two different copies of the same file that in the end will be drag and dropped together using jupyter lab. This is obviously not ideal, so i thought is there any way for just two people to work on one document in Jupyter, sadly Google Colab has been Deprecated and CoCalc is expensive. So i thought id ask here if there is a way to make one person run a Jupyter notebook and the other one just being able to access it over peer to peer aswell so we could write in the same file at the same time.\nDo you guys know something that makes me do this maybe a workaround that i can do.\nThanks for answers in advance","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":11770,"Q_Id":58903507,"Users Score":2,"Answer":"Notebook itself doesn't support to collaborate simultaneously, but you can use GitHub to manage your python script and upload it into Colab separately. This way Github can help manage the file history and solve the conflicts.","Q_Score":6,"Tags":"python,jupyter-notebook,collaboration","A_Id":58903561,"CreationDate":"2019-11-17T18:02:00.000","Title":"Is there a way for two People to work on one Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got an electronic piano that lacks the pitch bend and modulation wheels. I'm looking for a way to simulate them while still giving output through the same MIDI port the device is connected. The rest I'll figure out myself.\nI'm using Windows and Python 3.5. Thank you for your time.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":734,"Q_Id":58904130,"Users Score":2,"Answer":"Using loopMIDI worked for me. What it does is simply puts its Output as its Input, so when sending modulation wheel (or other) events to Output (I had to use output.write_short(0xb0, 1, modulation), Pygame) it will send those events directly to Input and then it'll be possible to use it as a MIDI input device in workstations and etc.","Q_Score":3,"Tags":"python,midi","A_Id":59555400,"CreationDate":"2019-11-17T19:06:00.000","Title":"Connecting to a MIDI Input port and simulating input (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 new to Python. Just working with OSMnx and wanted to open a map as an svg in Illustrator. This was posted in the GitHub documentation: \n# you can also plot\/save figures as SVGs to work with in Illustrator later\nfig, ax = ox.plot_graph(G_projected, save=True, file_format='svg')\nI tried it in JupyterLab and it downloaded to my files but when I open it, it is just text. How can I correctly download it and open as SVG? - Thanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":548,"Q_Id":58904416,"Users Score":0,"Answer":"Instead of\n\nfilename='image', file_format='svg'\n\nUse:\n\nfilepath='image.svg'","Q_Score":0,"Tags":"python,svg,jupyter-notebook,openstreetmap,osmnx","A_Id":72333300,"CreationDate":"2019-11-17T19:35:00.000","Title":"How do I correctly download a map from osmnx as .svg?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way in Python to convert a Counter dictionary into a string?\nI have tried str(counterobj) method but it's unsupported for Counter (from collections library)\nThanks!!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1212,"Q_Id":58906203,"Users Score":0,"Answer":"if you want to have a string made of frequency of keys, you can\n \" \".join(Counter(map(str, [1, 2, 3, 3, 2])).elements())\nand get:\n1 2 2 3 3","Q_Score":0,"Tags":"python,string,dictionary,collections","A_Id":70655786,"CreationDate":"2019-11-17T23:28:00.000","Title":"How to convert Counter object dict to string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to accomplish the following task using Airflow. I have an address and I want to run 3 different tasks taskA, taskB, taskC. Each task returns True if the address was detected. Store the times when each of the functions detected the address.\nI want to accomplish the below logic.\n\nRun all three tasks to start off with. \nIf any of them return True, store the current time.\nWait for 1 minute and rerun only the tasks that did not return True.\nIf all have returned True end the job. \n\nI am not sure how I can accomplish selectively running only those tasks that returned False from the last run. \nI have so far looked at the BranchPythonOperator but I still haven't been able to accomplish the desired result.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":58906634,"Users Score":0,"Answer":"You can get last run status value from airflow db.","Q_Score":0,"Tags":"python,airflow","A_Id":58910634,"CreationDate":"2019-11-18T00:40:00.000","Title":"How to create a different workflow depending on result of last run?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been using Fortran for my computational physics related work for a long time, and recently started learning and playing around with Python. I am aware of the fact that being an interpreted language Python is generally slower than Fortran for primarily CPU-intensive computational work. But then I thought using numpy would significantly improve the performance for a simple task like sorting.\nSo my test case was sorting an array\/a list of size 10,000 containing random floats using bubble sort (just a test case with many array operations, so no need to comment on the performance of the algorithm itself). My timing results are as follows (all functions use identical algorithm):\nPython3 (using numpy array, but my own function instead of numpy.sort): 33.115s\nPython3 (using list): 9.927s \nFortran (gfortran) : 0.291s\nPython3 (using numpy.sort): 0.269s (not a fair comparison, since it uses a different algorithm)\nI was surprised that operating with numpy array is ~3 times slower than with python list, and ~100 times slower than Fortran. So at this point my questions are:\n\nWhy operating with numpy array is significantly slower than python list for this test case?\nIn case an algorithm that I need is not already implemented in scipy\/numpy, and I need to write my own function within Python framework with best performance in mind, which data type I should operate with: numpy array or list?\nIf my applications are performance oriented, and I want to write functions with equivalent performance as in-built numpy functions (e.g. np.sort), what tools\/framework I should learn\/use?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3448,"Q_Id":58910042,"Users Score":7,"Answer":"You seem to be misunderstanding what NumPy does to speed up computations.\nThe speedup you get in NumPy does not come from NumPy using some smart way of saving data. Or compiling your Python code to C automatically.\nInstead, NumPy implements many useful algorithms in C or Fortran, numpy.sort() being one of them. These functions understand np.ndarrays as input and loop over the data in a C\/Fortran loop.\nIf you want to write fast NumPy code there are really three ways to do that:\n\nBreak down your code into NumPy operations (multiplications, dot-product, sort, broadcasting etc.)\nWrite the algorithm you want to implement in C\/Fortran and also write bindings to Python that accept np.ndarrays (internally they're a contiguous array of the type you've chosen).\nUse Numba to speed up your function by having Python Just-In-Time compile your code to machine code (with some limitations)","Q_Score":5,"Tags":"python,performance,numpy","A_Id":58910192,"CreationDate":"2019-11-18T07:50:00.000","Title":"Sorting performance comparison between numpy array, python list, and Fortran","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to run a python command in Powershell, I get this error \nProgram 'python' failed to run: No application is associated with the specified file for this\nI have python installed in C:\\Users\\hp\\AppData\\Local\\Programs\\Python\\Python35 directory.\nI tried adding it with in the system environment variable path and restarted Powershell but get the same error. Also tried doing it via the commands given in other answers, but it doesn't work","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":161,"Q_Id":58912217,"Users Score":0,"Answer":"Go to setting, Apps, App execution aliases, then turn off App installer option for both python.exe and python3.exe. After that your path to the installed python should work properly.","Q_Score":0,"Tags":"python,powershell","A_Id":70370384,"CreationDate":"2019-11-18T10:14:00.000","Title":"Python and Powershell issue even after adding it to path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I try to run a python command in Powershell, I get this error \nProgram 'python' failed to run: No application is associated with the specified file for this\nI have python installed in C:\\Users\\hp\\AppData\\Local\\Programs\\Python\\Python35 directory.\nI tried adding it with in the system environment variable path and restarted Powershell but get the same error. Also tried doing it via the commands given in other answers, but it doesn't work","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":161,"Q_Id":58912217,"Users Score":0,"Answer":"You might need to restart your computer for the new path to take effect, just restarting powershell will not work.","Q_Score":0,"Tags":"python,powershell","A_Id":58913060,"CreationDate":"2019-11-18T10:14:00.000","Title":"Python and Powershell issue even after adding it to path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I try to run a python command in Powershell, I get this error \nProgram 'python' failed to run: No application is associated with the specified file for this\nI have python installed in C:\\Users\\hp\\AppData\\Local\\Programs\\Python\\Python35 directory.\nI tried adding it with in the system environment variable path and restarted Powershell but get the same error. Also tried doing it via the commands given in other answers, but it doesn't work","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":161,"Q_Id":58912217,"Users Score":0,"Answer":"If this is for windows then you don't have to mention the path explicitly as just clicking \"Add to the path\" takes care of it.\nMost likely you didn't give the exact path ie C:\\Users\\hp\\AppData\\Local\\Programs\\Python\\Python35 while setting it during installation.\nDoes Python run when you give an exact path while executing the script? If nothing else works try restarting the system or reinstall Python and make sure the \"Add to path \" box is checked.","Q_Score":0,"Tags":"python,powershell","A_Id":58912580,"CreationDate":"2019-11-18T10:14:00.000","Title":"Python and Powershell issue even after adding it to path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I try to run a python command in Powershell, I get this error \nProgram 'python' failed to run: No application is associated with the specified file for this\nI have python installed in C:\\Users\\hp\\AppData\\Local\\Programs\\Python\\Python35 directory.\nI tried adding it with in the system environment variable path and restarted Powershell but get the same error. Also tried doing it via the commands given in other answers, but it doesn't work","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":161,"Q_Id":58912217,"Users Score":1,"Answer":"Make sure you can start python by typing\nC:\\Users\\hp\\AppData\\Local\\Programs\\Python\\Python35\\python.exe in powershell.\nMake sure the C:\\Users\\hp\\AppData\\Local\\Programs\\Python\\Python35 already added to PATH.\nRestart your system.","Q_Score":0,"Tags":"python,powershell","A_Id":58912415,"CreationDate":"2019-11-18T10:14:00.000","Title":"Python and Powershell issue even after adding it to path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently working on a Django project and want to install an additional Django (app) package called \"tinymce\". I've installed Anaconda just recently and I'm not used to commands related to conda. I often used to pip install packages from the command prompt. But now I'm really confused if I really should just use the same pip install or use some other conda commands (if there are any) to install that package. Also, does that affect anything, if I am to frequently use that packages? \nFYI: I'm on Windows & using Python 3.7 using the recent Anaconda release.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1834,"Q_Id":58914993,"Users Score":4,"Answer":"Before you start installing packages, you should decide on how you want to manage your packages for different projects. I'd recommend that you create a dedicated conda environment for each project. Then you have to activate the respective environment whenever you want to work on a project. But packages installed for one project don't interfere with those for another. It helps to install Miniconda rather than Anaconda, because that keeps the conda base environment clean.\nYou write that you're used to calling pip install, but you don't mention Python virtual envs nor conda environments. That sounds as if you're typically installing packages globally on your machine. Sooner or later, that's going to create a mess.\nIf you decide to use conda environments, you have to remember to always activate the environment for your project before installing packages for that project. Then both pip install and conda install will put packages into that environment. When I have a choice, I prefer to install packages with conda from its default channels. conda has better dependency management than pip, and conda can handle non-Python dependencies. But packages sometimes have different names in conda and pip, so it might be extra effort to translate installation instructions for pip into similar commands for conda.","Q_Score":3,"Tags":"python,python-3.x,pip,anaconda,conda","A_Id":58964120,"CreationDate":"2019-11-18T12:52:00.000","Title":"Does a package also gets installed in conda environment if I use pip to install packages not included in Anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to understand about how YOLOv3 works. And this thing still confuses me: YOLO can determine the bounding box (the coordinates and dimensions), but why it doesn't output these value directly, instead of using them to adjust the anchor boxes?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":775,"Q_Id":58915471,"Users Score":0,"Answer":"Most object detection algorithms compute offset (x, y, width, height) for bounding boxes compared to a fixed anchor.\nAnchors are generally generated to follow a fix grid: for each location on the grid a set of anchors of different aspect ratios and different areas are created.\nIt's much easier for the learning algorithm to output an offset from the fixed anchor from which it can deduce the overall coordinate rather than trying to find the overall coordinate directly because it's a local and position-invariant feature. \nIt means that if there is a dog with a mis-centered bounding box on the top-left of the picture, the algorithm is asked to output the offset as if the dog were on the bottom-right of the picture, which makes it robust to shift and does not require it to learn the global position of the object in the image.","Q_Score":1,"Tags":"python,object-detection,yolo","A_Id":58918498,"CreationDate":"2019-11-18T13:16:00.000","Title":"Why YOLOv3 calculate the offset values for adjusting the anchor boxes, not directly output the dimension of the bounding box?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am unable to download a .py file from an email. I get the error \"file not supported.\" The file was saved from a Jupyter-notebook script.\nI have Python 3.6.6 and Jupyter downloaded on my Windows 10 laptop and tried to access the file through Chrome and through my computer's email app, but this didn't resolve the problem.\nAny ideas on how to make the file compatible with my computer?\nEDIT: I had to have the .ipynb file sent rather than the .py file.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3687,"Q_Id":58920830,"Users Score":0,"Answer":"Generally email providers block any thing which can possibly execute on clients machine.\nBest option to share will be transfer via email will be .py.txt \nor any cloud drives.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":60748514,"CreationDate":"2019-11-18T18:32:00.000","Title":"How to allow my computer to download .py files from an email","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I do a project for computer science, I have to make sure all of my files are located in the same folder, or I'll have errors. If I want to use a file from somewhere else, I have to insert it into the path. I do these things but don't fully understand what is happening or why. Why is the path changed in the runtime environment?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":58921408,"Users Score":0,"Answer":"Have you tried adding the path using sys.path.append? If you don't want to do that every time then you can set (Windows) %PYTHONPATH% to include your custom path. That's what I do for my include folder.","Q_Score":2,"Tags":"python","A_Id":58921670,"CreationDate":"2019-11-18T19:16:00.000","Title":"Why I need to specify working directories and path?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I do a project for computer science, I have to make sure all of my files are located in the same folder, or I'll have errors. If I want to use a file from somewhere else, I have to insert it into the path. I do these things but don't fully understand what is happening or why. Why is the path changed in the runtime environment?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":40,"Q_Id":58921408,"Users Score":1,"Answer":"When you run a python script you are executing it in the current working directory \/home\/user\/python.py for example. That means this script since it lives in \/home\/user has access to everything in that path. However you should be able to access any other directory from here as long as the permissions are setup right. You would do that by using relative paths. so for example \/home\/user\/python.py could access a file that is \/home\/example\/file.txt by giving it the path ..\/example\/file.txt from the python project.","Q_Score":2,"Tags":"python","A_Id":58921730,"CreationDate":"2019-11-18T19:16:00.000","Title":"Why I need to specify working directories and path?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to collect the list of favorite(like) in each tweet for a specific celebrity so that I can get the top three users who like his\/her posts the most in a period. However, I can't find any information using Tweepy(Twitter API) to gather it.   Is it the only possible to use Selenium to collect the favorite list for each tweet?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":58925031,"Users Score":0,"Answer":"Twitter's API does not provide this information. Also note that using Selenium or other web scraping methods is against the Twitter Terms of Service.","Q_Score":0,"Tags":"python-3.x,twitter,tweepy","A_Id":58937988,"CreationDate":"2019-11-19T00:42:00.000","Title":"How to find lists of favorite for each 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've started using PyCharm 2 this year and it's working well for me, the only thing is that when I add comments in, it all sort of gets lost in the amounts of code. \nIs there a way to add any text formatting to only certain parts of my programs? Like increasing the font of the comments that separate different practice questions, or even just bolding some of my comments to make the sections stand out more?\nI know you can change the text for the entire file, but I want some diversity so it's a bit easier for other people (and sometimes myself) to read.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":58926105,"Users Score":0,"Answer":"Go to File -> Settings -> Editor -> Color scheme\nComments are under \"Language Defaults\"","Q_Score":0,"Tags":"python,fonts,formatting,pycharm,editing","A_Id":58975874,"CreationDate":"2019-11-19T03:16:00.000","Title":"Editing text in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've started using PyCharm 2 this year and it's working well for me, the only thing is that when I add comments in, it all sort of gets lost in the amounts of code. \nIs there a way to add any text formatting to only certain parts of my programs? Like increasing the font of the comments that separate different practice questions, or even just bolding some of my comments to make the sections stand out more?\nI know you can change the text for the entire file, but I want some diversity so it's a bit easier for other people (and sometimes myself) to read.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":58926105,"Users Score":0,"Answer":"Go to Preferences->Editing->Color Scheme. From there you can change the way all the different types of program elements are displayed. You can use colors, bold, and italic to highlight things differently. I don't think you can assign different fonts or sizes, though.","Q_Score":0,"Tags":"python,fonts,formatting,pycharm,editing","A_Id":58926152,"CreationDate":"2019-11-19T03:16:00.000","Title":"Editing text in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying extract data from PDF. The data to be extracted in a structured way. For example document id and its corresponding value. we have to extract a set of key-value pairs as a json format and stored in db. Is there a way to accomplish this task?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":255,"Q_Id":58926555,"Users Score":2,"Answer":"If you are using UIPath you need to install 2 packages:\n1.Uipath PDF Activities - to read the pdf\n2.UiPath Web Activities - here you can find DeserializeJSON activity (or DeserializeJSON array )\n***Personally I would extract the data and save it in xlsx file","Q_Score":0,"Tags":"python,r,json,pdf,uipath","A_Id":58929327,"CreationDate":"2019-11-19T04:14:00.000","Title":"Is there a way to scrape data from a PDF into a structured JSON format?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"If I had an online room of 10 users arriving at different times and I wanted to pick up a random user once the room is full, would it be secure to select the user by using the timestamp of when the last user joined the room and simply do a % 10 ?\nThe timestamp would be in milliseconds.\nIf the answer to my question is no would it be better to add a random delay before selecting the timestamp ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":55,"Q_Id":58926572,"Users Score":1,"Answer":"Secure for what? What kind of timestamp, hours?\nIf timing is used then it is commonly the time source with the best precision, and multiple deltas are used rather than the time stamp directly.\nAll that is completely inferior to the PRNG's available from a crypto library, fed by the OS random generation. The OS has many more sources for entropy (up to and including the true random generators in many CPU's nowadays).\nJust performing mod 10 is kind of dangerous (what if the timer is biased to use even numbers due to lack of precision?), usually we feed entropy into a cryptographically secure pseudo-random number generator (CS-PRNG).\nIf those are not fast enough (are they?) and security is not your main need, then you can use a faster non-secure PRNG or a fast stream cipher.","Q_Score":0,"Tags":"python,random,cryptography,random-seed","A_Id":58926929,"CreationDate":"2019-11-19T04:17:00.000","Title":"How secure would it be to choose a random number based on time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to compare current datetime with the stored datetime in DB.(working on python)\nSo I tried by using this command\ncursor.execute('SELECT ID,URL,LAST_HEARD_TIME,NEXT_SCHEDULE_TIME,STATUS FROM VCP_THIN_AGENT WHERE datetime.datetime.now() > NEXT_SCHEDULE_TIME')\nBut it shows the error -cross-database references are not implemented: datetime.datetime.now\nHow can I solve this?\nThanks in Advance :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":58928695,"Users Score":0,"Answer":"I solve the Issue.\nwe have to use like\ncursor.execute('SELECT ID,URL,LAST_HEARD_TIME,NEXT_SCHEDULE_TIME,STATUS FROM VCP_THIN_AGENT WHERE %s> NEXT_SCHEDULE_TIME',(datetime.datetime.now(),))","Q_Score":0,"Tags":"python,database","A_Id":58929216,"CreationDate":"2019-11-19T07:28:00.000","Title":"cross-database references are not implemented: **datetime.datetime.now**","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've received byte code similar to this:\n}Pl\\xA1u#\\x1EW\\x02\\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x85\\xA9\\xF4>\\x08\\x00\\x00\\x00\\xBF\\xE8\\xA3B\\xC30\\xECA\\xFA~\nHow can this be decoded to normal value?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":354,"Q_Id":58929016,"Users Score":0,"Answer":"Try,\ndata.decode(\"utf-16\"), where data is your byte code.","Q_Score":0,"Tags":"python,decoding","A_Id":58929533,"CreationDate":"2019-11-19T07:50:00.000","Title":"How to decode this byte code to float values using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a directory with multiple files for the same data format (1 file per day). It's like one data split into multiple files. \nIs it possible to pass all the files to A Kedro node without specifying each file? So they all get processed sequentially or in parallel based on the runner?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":936,"Q_Id":58931100,"Users Score":2,"Answer":"If the number of files is small and fixed, you may consider creating those preprocessing pipeline for each of them manually.\nIf the number of files is large\/dynamic, you may create your pipeline definition programmatically for each of them, adding them all together afterwards. Same would probably apply to programmatic creation of the required datasets.\nAlternative option would be to read all the files once in the first node, concatenate them all together into one dataset, and make all consecutive preproc nodes use that dataset (or its derivatives) as inputs","Q_Score":4,"Tags":"python,kedro","A_Id":58931110,"CreationDate":"2019-11-19T09:52:00.000","Title":"Kedro: How to pass multiple same data from a directory as a node input?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My Airflow DAGs mainly consist of PythonOperators, and I would like to use my Python IDEs debug tools to develop python \"inside\" airflow. - I rely on Airflow's database connectors, which I think would be ugly to move \"out\" of airflow for development.\nI have been using Airflow for a bit, and have so far only achieved development and debugging via the CLI. Which is starting to get tiresome.\nDoes anyone know of a nice way to set up PyCharm, or another IDE, that enables me to use the IDE's debug toolset when running airflow test ..?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":7846,"Q_Id":58931845,"Users Score":2,"Answer":"It might be somewhat of a hack, but I found one way to set up PyCharm:\n\nUse which airflow to the local airflow environment - which in my case is just a pipenv\nAdd a new run configuration in PyCharm\nSet the python \"Script path\" to said airflow script\nSet Parameters to test a task: test dag_x task_y 2019-11-19\n\nThis have only been validated with the SequentialExecutor, which might be important.\nIt sucks that I have to change test parameters in the run configuration for every new debug\/development task, but so far this is pretty useful for setting breakpoints and stepping through code while \"inside\" the local airflow environment.","Q_Score":11,"Tags":"python,debugging,pycharm,ide,airflow","A_Id":58931846,"CreationDate":"2019-11-19T10:28:00.000","Title":"Debugging Airflow Tasks with IDE tools?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have created a python package that includes a setup.py file. I need this package to be distributed among some clients, who will import and build their products on top of my package and I want to make the package proprietary as it contains some sensitive information. \nI have added a license header but there are some URLs that I want to hide from my clients.\nHow to achieve this? Thank you","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":43,"Q_Id":58933295,"Users Score":2,"Answer":"You don't.  \nSecurity through obscurity is broken from the outset.  If you ship it to the client, they own it at some level or another.\nEspecially in the case of python, it makes no sense to hide things, because the interpreter still has to be able to process them - if you encrypt something, you have to ship the decryption tools with it, which means a malicious user already has everything they need to figure out your secrets.\nIf you don't want a user to have access to it, you can't sent it to the user.  Period.","Q_Score":0,"Tags":"python,python-3.x","A_Id":58933421,"CreationDate":"2019-11-19T11:40:00.000","Title":"Is it possible to hide code in my importable 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":"for an academic project, I am currently using the python framework jam.py 5.4.83 to develop a back office for a new company. \nI would like to use views instead of tables for reporting but I don't find how to do it, I can only import data from tables.\nSo if someone already used this framework, I would be very thankful.\nRegards,\nYoan","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":236,"Q_Id":58933918,"Users Score":0,"Answer":"the use of database views are not supported in Jam.py\nHowever, you can import tables as read only if used for reporting.\nThan you can build Reports as you would.\nGood luck.","Q_Score":0,"Tags":"python,view,frameworks","A_Id":60222402,"CreationDate":"2019-11-19T12:15:00.000","Title":"Use of views in jam.py framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Hope you are doing well.\nI am trying to build a following robot which follows a person.\nI have a raspberry pi and and a calibrated stereo camera setup.Using the camera setup,i can find depth value of any pixel with respect to the reference frame of the camera. \nMy plan is to use feed from the camera to detect person and then using the stereo camera to find the average depth value thus calculating distance and from that calculate the position of the person with respect to the camera and run the motors of my robot accordingly using PID.\nNow i have the robot running and person detection using HOGdescriptor that comes opencv.But the problem is,even with nomax suppression, the detector is not stable to implement on a robot as too many false positives and loss of tracking occurs pretty often.\nSo my question is,can u guys suggest a good way to track only people. Mayb a light NN of some sort,as i plan to run it on a raspberry pi 3b+.\nI am using intel d435 as my depth camera. \nTIA","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":527,"Q_Id":58934308,"Users Score":1,"Answer":"Raspberry pi does not have the computational capacity to perform object detection and realsense driver support, check out the processor load once you start the realsense application. One of the simplest models for person detection is opencv's HOGdescripto that you have used.","Q_Score":0,"Tags":"python,computer-vision,raspberry-pi3,object-detection,robotics","A_Id":58939946,"CreationDate":"2019-11-19T12:37:00.000","Title":"fast light and accurate person-detection algorithm to run on raspberry pi","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 ssh dask.distributed cluster with a main computer containing all modules for my script and another one with only a few, including dask itself of course. \nIs it possible to change the syspath of the other computer so that it also looks for modules in the main one? Of course, I could simply upload them via sftp but since I keep making a lot of modules that would be very annoying to do repeatedly.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":58934528,"Users Score":1,"Answer":"Such things are possible with networking solutions such as NFS or SSH remote mounts, but that's a pretty big field and beyond the scope of Dask itself. If you are lucky, other answers will appear here, others have solved similar problems, but more likely copying is the simpler solution.","Q_Score":0,"Tags":"python,dask","A_Id":58935738,"CreationDate":"2019-11-19T12:48:00.000","Title":"Share python modules across computers in a dask.distributed cluster","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say there are two sub images of a large image. I am trying to detect the overlapping area of two sub images. I know that template matching can help to find the templates. But i'm not sure how to find the intersected area and remove them in either one of the sub images. Please help me out.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":420,"Q_Id":58937483,"Users Score":1,"Answer":"MatchTemplate returns the most probable position of a template inside a picture. You could do the following steps:\n\nFind the (x,y) origin, width and height of each picture inside the larger one\nSave them as rectangles with that data(cv::Rect r1, cv::Rect r2)\nUsing the & operator, find the overlap area between both rectangles (r1&r2)","Q_Score":0,"Tags":"python,opencv","A_Id":58937944,"CreationDate":"2019-11-19T15:26:00.000","Title":"How to find the intersecting area of two sub images using OpenCv?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used to have a function that took some keyword parameters :  def foo(a=None, b=None)\nIn a new version of my code, I don't need one of the keywords (b) anymore and wants to remove it. \nShould I add **kwargs in my function like so def foo(a=None, **kwargs) for backward compatibility or is it not needed? \nWhat is the best practice in this situation?\nI don't want to break my user's code if they upgrade to the new version of my package.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":231,"Q_Id":58937740,"Users Score":0,"Answer":"You can define def foo(a=None, **kwargs) which:\n\nlogs a deprecated info\ncalls a def foo(a=None) which is the actual one processing what you want","Q_Score":3,"Tags":"python,python-3.x","A_Id":58937867,"CreationDate":"2019-11-19T15:39:00.000","Title":"use of **kwargs for backward compatibility","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does the --user flag do anything if you run pip with sudo, as in:\nsudo pip install --user <package_name>\nWhere will the package install, and what will the permissions on it be?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":363,"Q_Id":58940181,"Users Score":2,"Answer":"From man 1 pip-install: \n\n--user Install to the Python user install directory for your platform. Typically ~\/.local\/, or %APPDATA%Python on Windows. (See the Python documentation for site.USER_BASE for full details.)\n\nWhere ~ represents the home directory of the effective user.\nIf you run it using sudo (make the effective user the root user), the package will be installed in the home directory of the root user, which on most distributions equates to \/root\/, making the final install path \/root\/.local\/.","Q_Score":0,"Tags":"python,ubuntu,pip","A_Id":58940206,"CreationDate":"2019-11-19T17:58:00.000","Title":"Where are pip packages installed if you run \"sudo pip install --user \"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed openstackclient:4.0.0 on Python 2.7.5 and getting the below error\nException raised: cannot import name redirect_stdout\nAny thoughts\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":58940943,"Users Score":0,"Answer":"Well, a complete exception trace would have been more helpful.\n\nThe exception which you are getting is due to missing contextlib which\n  is part of python3.\n  Openstackclient is using contextlib in network related operations\n  currently, however not using redirect_stdout.\n\nLooks like you are using a lib which is using redirect_stdout from contextlib. It doesn't seems to be openstackclient.","Q_Score":0,"Tags":"python-2.7,openstack","A_Id":58966906,"CreationDate":"2019-11-19T18:48:00.000","Title":"openstackclient: Exception raised: cannot import name redirect_stdout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have this numpy matrix:\nx = np.random.randn(700,2)\nWhat I wanna do is scale the values of the first column between that range: 1.5 and 11 and the values of the second column between `-0.5 and 5.0. Does anyone have an idea how I could achieve this? Thanks in advance","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4738,"Q_Id":58941935,"Users Score":2,"Answer":"subtract each column's minimum from itself\nfor each column of the result divide by its maximum\nfor column 0 of that result multiply by 11-1.5\nfor column 1 of that result multiply by 5--0.5\nadd 1.5 to column zero of that result\nadd -0.5 to column one of that result\n\nYou could probably combine some of those steps.","Q_Score":1,"Tags":"python,numpy,machine-learning,scaling,numpy-ndarray","A_Id":58942213,"CreationDate":"2019-11-19T19:57:00.000","Title":"How to scale numpy matrix in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The approach I am trying is to write a dynamic script that would generate mirror tables as in Oracle with similar data types in SQL server. Then again, write a dynamic script to insert records to SQL server. The challenge I see is incompatible data types. Has anyone come across similar situation? I am a sql developer but I can learn python if someone can share their similar work.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":648,"Q_Id":58943788,"Users Score":0,"Answer":"I used linked server, got all the metadata of the tables from dba_tab_columns in Oracle. Wrote script to create tables based on the metadata. I needed to use SSIS script task to save the create table script for source control. Then I wrote sql script to insert data from oracle, handled type differences through script.","Q_Score":0,"Tags":"python,sql-server,oracle,data-migration","A_Id":59293359,"CreationDate":"2019-11-19T22:25:00.000","Title":"What is the best way to migrate all data from Oracle 11.2 to SQL Server 2012?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The approach I am trying is to write a dynamic script that would generate mirror tables as in Oracle with similar data types in SQL server. Then again, write a dynamic script to insert records to SQL server. The challenge I see is incompatible data types. Has anyone come across similar situation? I am a sql developer but I can learn python if someone can share their similar work.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":648,"Q_Id":58943788,"Users Score":0,"Answer":"Have you tried the \"SQL Server Import and Export Wizard\" in SSMS?\ni.e. if you create an empty SQL server database and right click on it in SSMS then one of the \"tasks\" menu options is \"Import Data...\" which starts up the \"SQL Server Import and Export Wizard\". This builds a once-off SSIS package .. which can be saved if you want to re-use.\nThere is a data source option for \"Microsoft OLE DB Provider for Oracle\". \nYou might have a better Oracle OLE DB Provider available also to try.\nThe will require Oracle client software to be available.\nI haven't actually tried this (Oracle to SQL*Server) so am not sure if reasonable or not.\nHow many tables, columns?\nOracle DB may also have Views, triggers, constraints, Indexes, Functions, Packages, sequence generators, synonyms.","Q_Score":0,"Tags":"python,sql-server,oracle,data-migration","A_Id":58945520,"CreationDate":"2019-11-19T22:25:00.000","Title":"What is the best way to migrate all data from Oracle 11.2 to SQL Server 2012?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a full stack web application for a class, and originally was going to use AWS S3 for hosting, Dynamo as a database, Lambda for passing data to and from Dynamo, and Gateway API to connect the front and back end, but have had nothing but issues with AWS. As this is just a class project, nothing needs to be remotely hosted, and a classmate suggested Django to allow us to completely ditch AWS. After looking through a lot of the introductory stuff for Django, it looks like it could be the magic bullet we need. However, we already have dozens of hours sunk into our frontend HTML\/CSS\/Javascript, as well as some Bootstrap. My only reservation about making a complete dive for Django for handling our database and enabling us to run everything off localhost is that it seems to do EVERYTHING in Python, and I don't immediately see any way to integrate our existing frontend. Our frontend JS is intended to receive data from the database and do rudimentary calculations with it before providing it to the HTML page, and I'm also not sure how this would integrate with Django and SQLite.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":405,"Q_Id":58944143,"Users Score":0,"Answer":"HTML: Most of it will be reused, but you will do some work of splitting it into templates and blocks if you plan to generate it on the server side, which is normal for Django.\nCSS: can be reused without change if you're careful with your HTML templates.\nJavascript: it very much depends on the way you structure your application. Likely much of it will require rework where it interacts with server side (like calling APIs), but most would work as-is where it only interacts with the client (like form validation, etc).\n\nPlease note that the architecture you're describing and a typical Django architecture differ quite much; do your research and write a toy project first. There is a number of good intros. \nYou will have to re-architect and rewrite all of your backend code. There seems to be Dynamo support if you stay with AWS, but everything around lambdas will likely go away, and you will deploy to normal AWS EC2 instances, or any other hosting provider if you want.\nRemember: do the simplest thing that could possibly work. If in doubt, YAGNI.","Q_Score":0,"Tags":"javascript,python,html,django","A_Id":58944220,"CreationDate":"2019-11-19T22:58:00.000","Title":"Is it possible to use my existing HTML\/CSS\/JS with a move to Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to intercept data sent from the server to a client , where the script is json and server is nginx (https). Taking for example I am also a client and I am penetration testing the server for vulnerabilities.\nI have tried inspecting elements from chrome and everything seems fine (the data is only sent to the other client), I have checked the network files and found nothing, I also tried python import request method, and I have recieved the HTTP 4xx error.\nMy question is here, what way is there to be able to intercept the data without complete access to server?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":247,"Q_Id":58949731,"Users Score":0,"Answer":"Have you tried to look for it on the 'Network' or 'Console' tab specifically at the element inspector?\nPlease note that JSon is not tecnically a script, it is just a object notation, a way of sending information from one place to another, wheareas scripts are intended for interpretation and execution (Bash, JavaScript and Python are examples)\nIf that data is not being desplayed there, you will probably need some kind of network sniffer (Like wireshark) and filter information comming form that server to your computer. It might be encrypted though, and undreadable for humans.\nHope I helped.","Q_Score":0,"Tags":"python,json,google-chrome","A_Id":58950496,"CreationDate":"2019-11-20T08:25:00.000","Title":"How am I able to intercept server client requests using Chrome and Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using MAC OS Catalina Version 10.15.1 and I'm working on a python project. Every time I use the command \"import OS\" on the command line Version 2.10 (433), I get this message: zsh: command not found: import. I looked up and followed many of the solutions listed for this problem but none of them have worked. The command worked prior to upgrading my MAC OS. Any suggestion on how to fix it?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8587,"Q_Id":58954993,"Users Score":0,"Answer":"Don't capitalize it.\nimport os","Q_Score":1,"Tags":"python,command-line,import,operating-system","A_Id":58955079,"CreationDate":"2019-11-20T13:02:00.000","Title":"zsh: command not found: import","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using MAC OS Catalina Version 10.15.1 and I'm working on a python project. Every time I use the command \"import OS\" on the command line Version 2.10 (433), I get this message: zsh: command not found: import. I looked up and followed many of the solutions listed for this problem but none of them have worked. The command worked prior to upgrading my MAC OS. Any suggestion on how to fix it?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":8587,"Q_Id":58954993,"Users Score":1,"Answer":"The file is being interpreted as zsh, not a python. I suggest you to add this to the first line:\n#!\/usr\/bin\/env python","Q_Score":1,"Tags":"python,command-line,import,operating-system","A_Id":58955030,"CreationDate":"2019-11-20T13:02:00.000","Title":"zsh: command not found: import","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to start the conda Prompt from cmd, because I want to use the promt as a terminal in Atom.io.\nThere is no Conda.exe and the path to conda uses cmd to jump into the prompt. But how do I start it inside of cmd?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":88,"Q_Id":58958954,"Users Score":1,"Answer":"I guess what you want is to change to Anaconda shell using cmd, you can find the address for your Anaconda and run the following in your cmd:\n%windir%\\System32\\cmd.exe \"\/K\" \"Address\"\\anaconda3\nOr, you can find your Anaconda prompt shortcut, right click on that, and open its properties window. In the properties window, find Target. Then, copy the whole thing in Target and paste it into your cmd.","Q_Score":1,"Tags":"python,windows,cmd,anaconda","A_Id":58959055,"CreationDate":"2019-11-20T16:21:00.000","Title":"Starting conda pompt from cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I\u2019ve got an xxx.so file that I created on my Ubuntu machine. Now I\u2019m in need of using that file on Windows machine in python. \nIs there any way to achieve it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":167,"Q_Id":58959454,"Users Score":3,"Answer":".so files are shared objects, usually in the Executable and Linkable Format (ELF). Windows does not have a native loader for ELF; instead, it uses the Portable Executable format (PE). Also, your ELF .so is probably compiled for Linux, so it uses Linux system calls.\nIt is not possible to directly use a Linux binary on Windows. You might consider looking into Windows Subsystem for Linux, which emulates Linux on Windows, but it would probably be easier to recompile the extension module for Windows so that you get a .dll file in PE format instead.","Q_Score":0,"Tags":"python","A_Id":58959551,"CreationDate":"2019-11-20T16:47:00.000","Title":"Using functions from .so file on Windows in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I hope there will be some code where the Convolutional Neural Network will be implemented without Tensorflow OR theano OR Scikit etc. I searched over the google, but google is so crazy some time :), if i write \"CNN without Tensorflow\" it just grab the tesorflow part and show me all the results with tesorflow :( and if i skip the tensorflow, it again shows me some how similar results. any help please.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1274,"Q_Id":58959547,"Users Score":0,"Answer":"A lot of Deep Learning courses will ask the student to implement a CNN in Python with just numpy, then teach them to achieve the same result with Tensorflow etc. You can just search on Github for \"Deep-Learning-Coursera\" and you will probably find something like this https:\/\/github.com\/enggen\/Deep-Learning-Coursera\/blob\/master\/Convolutional%20Neural%20Networks\/Week1\/Convolution%20model%20-%20Step%20by%20Step%20-%20v2.ipynb, where the CNN functions are implemented without Tensorflow.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,conv-neural-network","A_Id":58959742,"CreationDate":"2019-11-20T16:53:00.000","Title":"Is there any Python code for Convolutional Neural Network, but without Tensorflow\/Theano\/Scikit etc?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm worried about the security of my web app, I'm using Django and sometimes I use AJAX to call a Django url that will execute code and then return an HttpResponse with a message according the result, the user never notice this as it's happening in background.\nHowever, if the url I'm calling with AJAX is, for example, \"runcode\/\", and the user somehow track this and try to send a request to my domain with that url (something like \"www.example.com\/runcode\/\"), it will not run the code as Django expects the csrf token to be send too, so here goes the question.\nIt is possible that the user can obtain the csrf token and send the POST?, I feel the answer for that will be \"yes\", so anyone can help me with a hint on how to deny these calls if they are made without the intended objective?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":58961605,"Users Score":0,"Answer":"Not only django but this behavior is common in all others,\nYou can only apply 2 solution,\n\nApply CORS and just allow your domain, to block other domain to access data from your API response, but this will not effective if a user direct call your API end-point.\nAs lain said in comment, If data is sensitive or user's personal, add authentication in API. \n\nThanks","Q_Score":0,"Tags":"javascript,python,django,ajax,security","A_Id":58970830,"CreationDate":"2019-11-20T19:03:00.000","Title":"Prevent internal POST methods to be called by third parties","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using AWS sam cli to develop python application locally first.\nI have used sam build command to install python packages mentioned in requirements.txt. Build folder is created with the dependency package folders,\nBut in the code, the import statements are showing could not import the package. Though it is present in the same folder as of my code.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":345,"Q_Id":58961677,"Users Score":1,"Answer":"The Error message is show cause the imported package aren't installed as a python package since SAM CLI install the packages inside the project path so it can be packaged as layers and deployed in to AWS Lambda Layers","Q_Score":0,"Tags":"python,python-3.x,aws-sam-cli,sam","A_Id":59304675,"CreationDate":"2019-11-20T19:08:00.000","Title":"Unable to import python package in AWS SAM local development","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using pytorch and I wonder if I should use torch.backends.cudnn.benchmark = True. I find on google that I should use it when computation graph does not change. What is computation graph in pytorch?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9045,"Q_Id":58961768,"Users Score":16,"Answer":"If your model does not change and your input sizes remain the same - then you may benefit from setting torch.backends.cudnn.benchmark = True.\nHowever, if your model changes: for instance, if you have layers that are only \"activated\" when certain conditions are met, or you have layers inside a loop that can be iterated a different number of times, then setting torch.backends.cudnn.benchmark = True might stall your execution.","Q_Score":13,"Tags":"python,pytorch","A_Id":58965640,"CreationDate":"2019-11-20T19:15:00.000","Title":"set `torch.backends.cudnn.benchmark = True` or not?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating a docker image which is going to be based on buildpack-deps:stretch based image. I am told that it is preferred to install a Python version which was built from source instead of installing pre-built binaries.  \nQuestion: Why is it preferred for Python to be built from source?\n\nI read some articles talk about able to get latest patches etc., but\nthat does not make much sense to me since the pre-built binaries\nwould also have the patches after some testing is done. You ideally\ndo not want to take in source code which is not tested and build and\nuse it. Am I missing something in my argument?\nIf Python has pre-built binaries for debian:stretch, in my scenario why should I\nbe prefer to build from source instead of pre-built binaries?\n\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":55,"Q_Id":58964327,"Users Score":2,"Answer":"I am told that it is preferred to install a Python version which was built from source instead of installing pre-built binaries.\n\nWithout a qualification why, that was not a very meaningful suggestion. There are reasons to go either way, so I'll list those instead.\nReasons to use system packages:\n\nautomatic system updates will take care of emergency updates and security patching in a standard way - you can save a lot of time\nyou can be fairly confident that everything's compiled and distributed in a consistent way without breaking applications which rely on a given version (for example 3.5)\nnot managing your own compilation saves you time in both development and in build\/release process\nyou don't have to track upstream point-releases using a custom process\n\nReasons to compile yourself:\n\nif you want to rely on a specific patch not included upstream\nif you need to use new version, not released in your distro\n\nIn general, unless you can specifically say what you're going to gain by compiling from sources, understand you're committing to doing that on every future release, and hopefully define how you're going to automate it and who's going to do the work\/maintenance - I don't see a reason to do it.","Q_Score":0,"Tags":"python,linux","A_Id":58964531,"CreationDate":"2019-11-20T22:24:00.000","Title":"For Linux platform, why should I build Python from source instead of pre-built binaries?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I know to set an environment variable in python is to use os.environ['API_USER'] but where this variable is saved, I supposed this environment variable is saved in .env file but it wasn't.\non the console to retrieve all the environment variables use command: os.environ\nbut don't know where are saved. \nneed your help, Thanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4334,"Q_Id":58964351,"Users Score":5,"Answer":"Environment variables live in the memory, not on the disk. People usually save environment variables in files only for not having to do the same exporting of them by hand repetitively.\nAlso note that, environment variables are properties of operating system processes, and the process specific ones are passed on to all of the subprocesses of that process.\nSo when you run os.environ, it shows the environment variables and their values belonging to the python process (the executable that is being executed).","Q_Score":5,"Tags":"python,django,environment-variables","A_Id":58964413,"CreationDate":"2019-11-20T22:26:00.000","Title":"where Environment variables for python are saved","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using stackdriver for cloud logging my python code. I am trying to setup notifications which requires me to specify a resource type but I can't find which resource type I am using?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":729,"Q_Id":58964686,"Users Score":0,"Answer":"The resource type will depend on where your code is running.  For example, if you're running on a VM in GCE, the resource type will be \"gce_instance\".  If it's running in a container in GKE, it'll be \"k8s_container\", and etc. If you're running the code outside of GCP, it may be logged under the \"global\" resource.","Q_Score":0,"Tags":"python,google-cloud-platform,monitoring,stackdriver,google-cloud-stackdriver","A_Id":58998953,"CreationDate":"2019-11-20T22:55:00.000","Title":"Resource type for using stackdriver logger in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have training sample X_train, and Y_train to train and X_estimated.\nI got task to make my classificator learn as accurate as it can, and then predict vector of results over X_estimated to get close results to Y_estimated (which i have now, and I have to be as much precise as it can). If I split my training data to like 75\/25 to train and test it, I can get accuracy using sklearn.metrics.accuracy_score and confusion matrix. But I am losing that 25% of samples, that would make my predictions more accurate. \nIs there any way, I could learn by using 100% of the data, and still be able to see accuracy score (or percentage), so I can predict it many times, and save best (%) result?\nI am using random forest with 500 estimators, and usually get like 90% accuracy. I want to save best prediction vector as possible for my task, without splitting any data (not wasting anything), but still be able to calculate accuracy (so I can save best prediction vector) from multiple attempts (random forest always shows different results)\nThank you","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2055,"Q_Id":58964954,"Users Score":2,"Answer":"Splitting your data is critical for evaluation. \nThere is no way that you could train your model on 100% of the data and be able to get a correct evaluation accuracy unless you expand your dataset. I mean, you could change your train\/test split, or try to optimize your model in other ways, but i guess the simple answer to your question would be no.","Q_Score":2,"Tags":"python,machine-learning,scikit-learn,neural-network,random-forest","A_Id":58965054,"CreationDate":"2019-11-20T23:26:00.000","Title":"How to check machine learning accuracy without cross validation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have training sample X_train, and Y_train to train and X_estimated.\nI got task to make my classificator learn as accurate as it can, and then predict vector of results over X_estimated to get close results to Y_estimated (which i have now, and I have to be as much precise as it can). If I split my training data to like 75\/25 to train and test it, I can get accuracy using sklearn.metrics.accuracy_score and confusion matrix. But I am losing that 25% of samples, that would make my predictions more accurate. \nIs there any way, I could learn by using 100% of the data, and still be able to see accuracy score (or percentage), so I can predict it many times, and save best (%) result?\nI am using random forest with 500 estimators, and usually get like 90% accuracy. I want to save best prediction vector as possible for my task, without splitting any data (not wasting anything), but still be able to calculate accuracy (so I can save best prediction vector) from multiple attempts (random forest always shows different results)\nThank you","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2055,"Q_Id":58964954,"Users Score":0,"Answer":"It is not necessary to do 75|25 split of your data all the time. 75\n|25 is kind of old school now. It greatly depends on the amount of data that you have. For example, if you have 1 billion sentences for training a language model, it is not necessary to reserve 25% for testing. \nAlso, I second the previous answer of trying K-fold cross-validation. As a side note, you could consider looking at the other metrics like precision and recall as well.","Q_Score":2,"Tags":"python,machine-learning,scikit-learn,neural-network,random-forest","A_Id":58975977,"CreationDate":"2019-11-20T23:26:00.000","Title":"How to check machine learning accuracy without cross validation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to improve my ResNet model by creating an ensemble of X number of this model, taking the X best one I have trained. For what I've seen, a technique like bagging will take X time longer to classify an image, which is really not an option in my case. \nIs there a way to create an ensemble without increasing the required classifying time? Note that I don't care about increasing the training time, because it only needs to be done one time, compared to the classification which could be made a very large number of time.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":293,"Q_Id":58966086,"Users Score":1,"Answer":"There is no magic pill for doing what you want. Extra computation cannot come free.\nSo one way this can be achieved is by using multiple worker machines to run inference in parallel.\nEach model could run on a different machine using tensorflow serving.  \nFor every new inference do the following:  \n\nHave a primary machine which takes up the job of running the inference\nThis primary machine, submits requests to different workers (all of which can run in parallel)\nThe primary machine collects results from each individual worker, and creates the final output by combining them based upon your ensemble logic.","Q_Score":2,"Tags":"python,deep-learning,ensemble-learning","A_Id":58966156,"CreationDate":"2019-11-21T01:53:00.000","Title":"Can we create an ensemble of deep learning models without increasing the classification time?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an integer programming problem with a decision variable X_i_j_k_t that is 1 if job i was assigned to worker j for day k and shift t. I am maximizing the benefit of assigning orders to my workers. I have an additional binary variable Y_i_k_t that is 1 if the job was executed and a given day and shift (jobs might require more than one worker). How can I add this variable in CPLEX? So as to form, for example, sum(i, k, t)(Y_i_k_t) <= 1 (the order can\u00b4t be done more than once).\nThank you in advance","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1334,"Q_Id":58966188,"Users Score":1,"Answer":"You did not say whether you use the CPLEX Python API or docplex. But in either case, you can call the functions that create variables multiple times.\nSo in the CPLEX Python API call Cplex.variables.add() again to add another set of variables.\nIn docplex just call Model.binary_var_dict() (or whatever method you used to create X) again for the Y variables.","Q_Score":1,"Tags":"python,mathematical-optimization,linear-programming,cplex","A_Id":58969593,"CreationDate":"2019-11-21T02:08:00.000","Title":"How to add an additional binary variable with CPLEX and Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My unit test are failing with the following error\ndjango.db.utils.OperationalError: Problem installing fixture '\/Users\/vivekmunjal\/chargepoint\/code\/Installer\/api\/installer\/fixtures\/country.json': Could not load installer.Country(pk=1): (1054, \"Unknown column 'display_order' in 'field list'\")\nBasically one of my migrations is loading data in country model from a fixture, but the model has added some extra fields in them, so when the migrations runs it try to insert a column which is not yet created and fails. Can anyone suggest any remedy for the same?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":142,"Q_Id":58973892,"Users Score":3,"Answer":"Your database and code are inconsistent at the moment of your migration loading. You should split these migrations because now it happens during one transaction and your changes aren't committed when you trying load the fixture.\nIn general, it's bad practice to load fixtures during migrations.\nI advise you to implement the script which you will run after all migrations passed.","Q_Score":0,"Tags":"django,python-3.x,migration","A_Id":58974411,"CreationDate":"2019-11-21T11:26:00.000","Title":"Unit test failing due to migration error caused by loaddata in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm involved in a research project that is looking at using Neural Networks in a safety critical environment. Part of the regulatory framework this research is targeted towards states that there must be no dormant code within the system. There must be a pathway through every part of the system and that pathway must be testable\/verifiable.\nObviously the neural network is comprised of many nodes. The input\/output nodes are easy to test for activation, but does anyone know of a method of testing activation of hidden layer nodes? \nObviously the activation is dependent of the node's input values and activation function and there may be a mathematical approach to this.\nUltimately the code will be in C\/C++, but we're doing the NN development in Python. So any ideas involving related toolsets would be gratefully received. I could also export\/import the NN structure and matrices to another package or environment if that helps with this testing.\nHopefully you'll all be overflowing with ideas, because Google didn't offer anything. :(\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":108,"Q_Id":58976062,"Users Score":1,"Answer":"Somehow techytushar's comment nudged my brain into a new line of reasoning, which I think has been very helpful:\nSo the problem I'm addressing is: 'There can be no dormant code.' Be that lines of C or array elements that are never, and can never, be accessed.\nSo when the trained NN runs as a compiled C application, the application will calculate the value for each neuron and evaluate its activation function irrespective of the node's input value(s). So actually there is no such thing as dormant code or array elements in this regard. Just a true\/false output for that node's activation at that moment. It might change in the next moment. It'll all be re calculated, even if mathmatically the result is always for no activation.\nSo the question then moves away from this subject, to ensuring that no combinations of node activation can result in the system being in a dangerous state. That's off topic of the original question, so I think I can draw a line under this...?","Q_Score":1,"Tags":"python,neural-network,artificial-intelligence","A_Id":58976553,"CreationDate":"2019-11-21T13:21:00.000","Title":"Neural Networks - Checking for node activation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently trying to automate a process using Selenium with python, but I have hit a roadblock with it. The list is part of a list which is under a tree. I have identified the base of the tree with the following xpath \nitem = driver.find_element_by_xpath(\"\/\/*[@id='filter']\/ul\/li[1]\/\/ul\/\/li\")\nitems = item.find_elements_by_tag_name(\"li\")\nI am trying to Loop through the \"items\" section but need and click on anything with an \"input\" tag\nfor k in items:\n    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((k.find_element(By.TAG_NAME, \"input\")))).click()\nWhen execute the above I get the following error:\n\"TypeError: find_element() argument after * must be an iterable, not WebElement\"\nFor some reason .click() will not work if I use something like the below.\nk.find_element_by_tag_name(\"input\").click()\nit only works if i use the webdriverwait. I have had to use the web driver wait method anytime i needed to click something on the page.\nMy question is:\nWhat is the syntax to replicate items = item.find_elements_by_tag_name(\"li\")\nfor WebDriverWait(driver, 10).until(EC.element_to_be_clickable((k.find_element(By.TAG_NAME, \"input\")))).click()\ni.e how do I use a base path and append to the using the private methods find_elements(By.TAG_NAME)\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":115,"Q_Id":58978646,"Users Score":0,"Answer":"I have managed to find a work around and get Selenium to do what i need. \nI had to call the  javascript execution, so instead of trying to get\nWebDriverWait(driver, 10).until(EC.element_to_be_clickable((k.find_element(By.TAG_NAME, \"input\")))).click()  to work, i just used\ndriver.execute_script(\"arguments[0].click();\", k.find_element_by_tag_name(\"input\"))\nIts doing exactly what I needed it to do.","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,selenium-chromedriver","A_Id":58995977,"CreationDate":"2019-11-21T15:43:00.000","Title":"Looping through webelements with selenium Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a new branch in perforce with python and I used: self._p4.run(\"branch\", name) but, every time I used that, automatically it's open an editor to insert the mapping.\nMy question is if it's any way to create a new branch without open the editor and in the perfect world I can pass the mapping as a list of strings.\nThank you!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":259,"Q_Id":58980769,"Users Score":1,"Answer":"If you want to control the mapping yourself, and avoid the editor, you just need to use p4 branch -i and pass the already-filled-in form yourself.\nSo, for example:\n\np4 branch -o name > branchData.txt to generate the branch form into a temporary file\nmodify branchData.txt as you desire (e.g., to change the mappings to your desired set)\np4 branch -i < branchData.txt to load your branch data into the Perforce server and create the new branch spec in the server.\n\nOf course, you don't really need to do step (1) if your program already knows how it wants to set up the branch spec data. Just put your desired branch spec data into a file and run p4 branch -i with stdin redirected to that file. Or, even, you can just feed your form data directly from your program into p4 branch -i since it's just reading from stdin.","Q_Score":1,"Tags":"python-3.x,perforce","A_Id":58985065,"CreationDate":"2019-11-21T17:40:00.000","Title":"How to create a branch in perforce with python and avoid the editor passing the mapping by argument","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating my own Docker container for use with SageMaker and I'm wondering why the serve command creates a Flask app to serve predictions on data when I want to do a batch transform job. Wouldn't it be simpler to just unpickle the model and run the model's predict method on the dataset I want predictions for? I don't need a web api\/endpoint. I just need to automatically generate predictions once a day.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":445,"Q_Id":58985124,"Users Score":1,"Answer":"Good question :) using the exact same code for batch inference and online inference reduces development overhead - the exact same stack can be used for both use-cases - and also reduces risks of having different results between something done in Batch and something done online. That being said, SageMaker is very flexible and what you describe can easily be done using the Training API. There is nothing in the Training API forcing you to use it for ML training, it is actually a very versatile docker orchestrator with advanced logging, metadata persistance, and built for fast and distributed data ingestion.","Q_Score":3,"Tags":"python,amazon-web-services,docker,machine-learning,amazon-sagemaker","A_Id":59002763,"CreationDate":"2019-11-21T23:11:00.000","Title":"Why does AWS SageMaker run a web server for batch transform?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am using opencv in python (cv2) to do some processing on images with format jpg, png and jpeg, JPG. I am doing a test that write image to disk using \"cv2.imwrite\" right after reading from \"cv2.imread\". I found part of the image get rotated, some of them rotate 90d, some rotate 180d. But most image keep the right orientation. I cannot conclude a pattern that causes this rotation. Anyone knows more details? Thanks!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2287,"Q_Id":58985183,"Users Score":1,"Answer":"One possible solution is to change cv2.IMREAD_UNCHANGED to cv2.IMREAD_COLOR while loading image with imdecode. From some reason \"unchanged\" is not able to read EXIF metadata correctly","Q_Score":2,"Tags":"python,image,opencv,png,jpeg","A_Id":66943729,"CreationDate":"2019-11-21T23:17:00.000","Title":"opencv imwrite, image get rotated","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to find a way that I can run commands to either open applications\/files from my local machine or import files from my local machine in Microsoft Azure Notebooks without uploading them directly to the Azure cloud. Does anyone know if this is possible or if who\/where is a better place to ask?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":188,"Q_Id":58988139,"Users Score":0,"Answer":"No, you cannot. The jupyter is run a micro-server, which is hosted on the Azure. You can only used the data on the Azure cloud. Been there, wished that, but no.","Q_Score":0,"Tags":"python,jupyter-notebook,azure-notebooks","A_Id":58988737,"CreationDate":"2019-11-22T05:38:00.000","Title":"Is there a way to directly import or open local files from Microsoft Azure Notebooks without uploading them to the Azure cloud?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am writing a framework in Python 3.8 on Debian that will launch some multiprocessing processes.  I want the configuration and launching of the processes to be done in functions OTHER than the main. The main file will be written by the end user of the framework and they should not need to know about these processes. Hence I tried to put the code that configures and launches the processes in helper functions or class methods that the main will call.\nWhat I'm finding is as soon as the launcher function \/ method exits the processes die. This is even though the launcher functions \/ methods run (I think) in the same process as main which is still running.  I have put a long time.sleep in the launcher functions \/ methods right before they exit and it seems the processes are alive for that long.\nI tried setting the 'daemon' flag but that doesn't seem to solve it.  If this is truly a limitation of multiprocessing I can instruct the users of my framework to always put some boiler-plate launcher code in their file, but it seems clunky.  All help is appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":58989313,"Users Score":0,"Answer":"The function that launches the processes was returning only the processes to main and NOT managed queues that the processes were using. I changed to return a dict with the processes AND the managed queues and everything works.  This is even though main does NOT use the queues.","Q_Score":0,"Tags":"python,linux,multiprocessing,debian","A_Id":58997964,"CreationDate":"2019-11-22T07:18:00.000","Title":"Can Python multiprocessing process be launched from OTHER than __main__?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am new to web development. I am not familiar with Django. I have written some Python scripts which do some intense calculations and graphs plotting using Python packages such as numpy, matlibplot and so on. I want to publish it as a web application on a server to be accessed by other computers.\nSo I am wondering, do I need to copy all the required packages into the project directory before deploying the application to a server? Or Django will automatically handle the Python packages dependencies upon deploying?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":58990871,"Users Score":0,"Answer":"You have to create virtual environment.\nA virtual environment is a tool that helps to keep dependencies required by different projects separate by creating isolated python virtual environments for them.","Q_Score":0,"Tags":"python,django","A_Id":58991021,"CreationDate":"2019-11-22T09:09:00.000","Title":"Django Apps and Python Packages Dependencies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to web development. I am not familiar with Django. I have written some Python scripts which do some intense calculations and graphs plotting using Python packages such as numpy, matlibplot and so on. I want to publish it as a web application on a server to be accessed by other computers.\nSo I am wondering, do I need to copy all the required packages into the project directory before deploying the application to a server? Or Django will automatically handle the Python packages dependencies upon deploying?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":58990871,"Users Score":0,"Answer":"All the needed packages need to be installed on the server where is the web application running. If you have all the packages installed on your personal computer before deploy you will need to install the on the server as well.","Q_Score":0,"Tags":"python,django","A_Id":58990967,"CreationDate":"2019-11-22T09:09:00.000","Title":"Django Apps and Python Packages Dependencies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Let's say I have a numpy array a = numpy.array([1,2,3,4]). Now \nstr(a) will give me \"[1 2 3 4]\". How do I convert the string \"[1 2 3 4]\" back to a numpy.array([1,2,3,4])?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":58993231,"Users Score":2,"Answer":"Try numpy.array([int(v) for v in your_str[1:-1].split()])","Q_Score":1,"Tags":"python,numpy","A_Id":58993348,"CreationDate":"2019-11-22T11:22:00.000","Title":"Convert a str(numpy array) representaion to a numpy array - Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create an application using python, In which I would like to able to read a .csv or .xlsx file and display its contents on my application, I believe there should be some packages which helps to do this in python, can I have some suggestions?\nRegards,\nRam","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":36,"Q_Id":58994269,"Users Score":1,"Answer":"I think working with PyQt for large application is the best option ( for large applications ) but tkinter is the secondary option for fast small apps.","Q_Score":1,"Tags":"python","A_Id":58994326,"CreationDate":"2019-11-22T12:25:00.000","Title":"How to integrate spreadsheet\/excel kind of view to my application using python?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I downloaded it by pip install tensorflow in cmd\nThe installation is fine and I have tensorflow when I pip list and look at the list.\nin Python,\nimport tensorflow\nbut can't find the module.\nI can't install it with pip3.\nWhat should I do?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":58995385,"Users Score":0,"Answer":"I think you have multiple python versions installed.You can use cmd\n'where python' on windows to find which python you are running and also verify where you have install tenserflow module using pip.","Q_Score":0,"Tags":"python,tensorflow","A_Id":58995921,"CreationDate":"2019-11-22T13:34:00.000","Title":"I installed TensorFlow and found no modules found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a long string of repeating two hexadecimal characters separated by a space read in from a file that I would like to store into a two dimensional (array) list for processing later. The string is in the form:\nfile_content = \"00 18 00 19 F0 0F 1A 80 FF C7 E8 11 7F 52 7D 00 F0 0D F0 0C 0B FF\"\nEach sub string that needs indexed begins with \"00\" and ends with \"FF\". There are no instances of \"FF\" mid string but there are instances of \"00\" possible which makes this tricky. I would like to store each one of these events to its own index in the list. For example:\nevent_list = [[00 18 00 19 F0 0F 1A 80 FF], [C7 E8 11 7F 52 7D 00 F0 0D F0 0C 0B FF], .....}","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":58997257,"Users Score":0,"Answer":"If I understand this correctly, you're splitting it up based on the 'FF's present in the string, so you could probably get away with something like:\nevent_list = [('%sFF' % x).strip().split(' ') for x in file_content.split('FF')[:-1]]\nThis will split your original string by the 'FF's present, then loop through the split parts, append an ' FF' to the end of them. It then splits the new string by the space character, generating a new list and appends it to the outer list, creating the 2D array you require in 1 line :)","Q_Score":0,"Tags":"python,arrays,python-3.x,list,sorting","A_Id":58997313,"CreationDate":"2019-11-22T15:26:00.000","Title":"Dynamic Two Dimensional Array Creation Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there some type like long in Python 2 that can handle very small number like 8.5e-350?\nOr is there any way around in this situation because python supresses floats after 320 decimal places to 0?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":58997514,"Users Score":0,"Answer":"Python uses IEEE 745 so you don't get 350 decimal places, you get about 15 significant figures and a limit on the exponent to +\/-350.   If that number of significant figures is OK, and you don't need more dynamic range (i.e. all your values are small), express your quantities in different units so your values are in a suitable range.","Q_Score":0,"Tags":"python,python-3.x,types,precision","A_Id":58997637,"CreationDate":"2019-11-22T15:43:00.000","Title":"How to work with very small float numbers in python3 (e.g. 8.5e-350)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The folder Python37\\site-packages\\scipy\\sparse\\linalg\\isolve\\ inside Scipy package in Python has the following file: _iterative.cp37-win_amd64.pyd.\nWhen I run a Python file, I get the following error :- \nFile \"C:\\......\\Python37\\site-packages\\scipy\\sparse\\linalg\\isolve\\iterative.py\", line 10, in <module>\n    from . import _iterative\nImportError: DLL load failed: The specified module could not be found\n(I am new to Python on Windows)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":76,"Q_Id":58998324,"Users Score":0,"Answer":"This is how I was able to resolve the issue (on Windows) :- \n1. I uninstalled Python using python.exe program. \n2. Installed anaconda for Windows - it installs python along with dependencies and many common libraries.","Q_Score":0,"Tags":"python,dll,filepath,python-packaging","A_Id":59039047,"CreationDate":"2019-11-22T16:35:00.000","Title":"Python package dependency is causing an error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I implemented a bloom filter with 3 hash functions, and now I should calculate the exact number of false positives (not possibility) in that filter. Is there an efficient way to calculate that? The number of items in the filter is 200 million and the size of bit array is 400 million","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":308,"Q_Id":58999182,"Users Score":0,"Answer":"Yes, and it is very simple.\nCount the number of bits that are 'on' and divide that by the total number of bits. This will give you your fill-rate. \nWhen querying, all elements that were inserted earlier will hit 'on' bits and return positive. For elements which were not inserted into the filter, the probability of hitting an 'on' bit is your fill-rate. Therefore, with 3 hash functions, your error-rate will be (fill_rate^3).\nThough 0.5 is the optimal fill-rate that maximizes space vs. error-rate, any other fill rate is possible but it will either take too much space or has a higher error-rate than required. So you may be better off using 4 hash functions with less space. It really depends on your use case. What is your requirement? what error-rate are you looking for?","Q_Score":0,"Tags":"python,dataframe,hash,bloom-filter","A_Id":59466483,"CreationDate":"2019-11-22T17:36:00.000","Title":"False positive number Bloom filter","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know you could do something.__doc___ or even inspect.getdoc(something). However I want to retrieve the full help() display as a String. In other words, the entire thing when you do help(something). Notice how inspect.getdoc(inspect) retrieves a fraction of content on display than when you do help(inspect) in interpreter. Is this possible?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":59003309,"Users Score":0,"Answer":"I am relatively sure it is not possible. I believe the best thing you could do is try to replicate the help() output using __name__ and __doc__.","Q_Score":1,"Tags":"python,string,inspect","A_Id":68028350,"CreationDate":"2019-11-23T00:02:00.000","Title":"How to retrieve full docstring as String in python? (content when you call help())","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to read a sheet in excel file. But the number of columns(approx 100 to 150), column names and column position may change everyday in the sheet. Will pandas.read_excel return a dataframe with columns in the same order as they are in my daily excel sheet ? I'm using pandas 0.25.3","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1802,"Q_Id":59006318,"Users Score":1,"Answer":"pandas will return to you the column order exactly as in the original file. If the order changes in the file, the order of columns in the dataframe will change too. \nYou can define the column order yourself when reading in the data. Sometimes you'd also load the data, check what columns are present (with dataframe.columns.values) and then apply certain heuristic to preprocess them.","Q_Score":1,"Tags":"python,python-3.x,pandas","A_Id":59011075,"CreationDate":"2019-11-23T09:38:00.000","Title":"Will pandas.read_excel preserve column order?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like my bot to recover the attachment of a message and send it in another channel with an embed, I make this:\nembed.set_image(url=message.attachments[0].url\nbut it only work with images (or gif, but video doesn't work)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":235,"Q_Id":59007265,"Users Score":0,"Answer":"embed.set_image as the name implies is for settings images. Unfortunately Discord does not let bots send videos inside embeds. Your limited options are to take the url and post it as just the content of the message and let discord embed it.","Q_Score":0,"Tags":"python-3.x,discord,discord.py,discord.py-rewrite","A_Id":59056271,"CreationDate":"2019-11-23T11:46:00.000","Title":"Discord bot recover the attachment of a message and send it in another channel with an 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 figure out if Arcmap has a option where it can create a buffer that the north buffer area is different to the south and then have it all in one output.\nIf it is not possible would python be a alternative?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":59007326,"Users Score":0,"Answer":"I'm not sure I understand your problem or not, but I got an idea about it.\nYou can split your rectangle polygon into 4 lines. then you should create some field in splitted lines to fill buffer options e.g. buffer range.\nIf you have many polygons you can split them and buffer all lines with pre-defined fields.\nHope it helps.","Q_Score":0,"Tags":"python,gis,arcmap","A_Id":59048792,"CreationDate":"2019-11-23T11:54:00.000","Title":"Creating Buffer on Rectangle with different Requirements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wish to use the latest version of SQLite3 (3.30.1) because of its new capability to handle SQL 'ORDER BY ... ASC NULLS LAST' syntax as generated by the SQLAlchemy nullslast() function.\nMy application folder env\\Scripts contains the existing (old) version of sqlite3.dll (3.24), however when I replace it, there is no effect. In fact, if I rename that DLL, the application still works fine with DB accesses.\nSo, how do I update the SQLite version for an application?\nMy environment:\nWindows 10, 64-bit (I downloaded a 64-bit SQlite3 DLL version). I am running with pyCharm, using a virtual env.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":390,"Q_Id":59011272,"Users Score":0,"Answer":"I have found that the applicable sqlite3.dll is determined first by a Windows OS defined lookup. It first goes through the PATH variable, finding and choosing the first version it finds in any of those paths.\nIn this case, probably true for all pyCharm\/VirtualEnv setups, a version found in my user AppData\\Local\\Programs\\Python\\Python37\\DLLs folder was selected.\nWhen I moved that out of the way, it was able to find the version in my env\\Scripts folder, so that the upgraded DLL was used, and the sQLAlchemy nullslast() function did its work.","Q_Score":0,"Tags":"python,sqlite,sqlalchemy","A_Id":59037581,"CreationDate":"2019-11-23T19:16:00.000","Title":"How can I update the version of SQLite in my Flask\/SQLAlchemy App?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Spyder 3.0 and also python 2.7. I want to run python 2.7 codes with spyder 3.0\nI tried to change python interpreter in spyder preferences. \"Preferences->Python Interpreter-> Use the following Python interpreter\". I chose Python 2.7 but it did not work. I also searched Python 2.7 executable file but I could not find it in the location usr\/bin (ubuntu 18.04).\nHow can deal with this problem?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1648,"Q_Id":59011667,"Users Score":1,"Answer":"Spyder installation is specific to one version of Python.\n1) install python 2.7\n2) run python2.7 -m pip install spyder in cmd\n3) you should find spyder in C:\\Users\\YOUR_NAME\\AppData\\Local\\Programs\\Python\\Python27\\Scripts\\spyder.exe (for Windows at \nleast)\n4) You can make a shortcut of it\nyou should see the python version in the Spyder window title","Q_Score":1,"Tags":"python-2.7,spyder","A_Id":59060223,"CreationDate":"2019-11-23T19:57:00.000","Title":"Python 2.7 with Spyder 3.0","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This error is easy to reproduce. Basically just start a new django project and run the server with django-admin. I read many StackOverflow posts and tried multiple methods but did not work. Here are the detailed steps to reproduce:\n\nCreated new directory named testproject\npipenv install django\nStarted new project named test with the django start project script\npipenv shell\ndjango-admin runserver\nError: \"django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.\"\nTyped this in ubuntu as suggested in the official django docs:  export DJANGO_SETTINGS_MODULE=test.settings \ndjango-admin runserver\nGot a giant line of error followed by ModuleNotFoundError: No module named 'test'. However, if i do django-admin runserver --pythonpath=. --settings=\"test.settings\" the server successfully runs.\n\nI know I can just use python manage.py to start the server but my project uses Django cache framework and when I try to access the cache the same settings are not configured error is thrown. Trying to understand what is going on, any help would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":614,"Q_Id":59015034,"Users Score":0,"Answer":"In your list I did not see the virtual env activation.\nDid you activate the virtual env ?\n'''\nsource activate testproject\n'''","Q_Score":0,"Tags":"python,django","A_Id":59022792,"CreationDate":"2019-11-24T05:54:00.000","Title":"Django \"settings are not configured\" error and cannot define environment variable DJANGO_SETTINGS_MODULE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been trying to install the sklearn_pandas package. I tried two methods which I found online:\n1) By running 'pip install sklearn-pandas' in the Windows command line in the same location as my Python working directory:\nThis resulted in the error ''pip' is not recognized as an internal or external command, operable program or batch file.' So I tried 'python -m pip install sklearn-pandas'. This got executed but showed nothing (no message\/warning etc) in terms of output.\nAfter this I attempted to import a function from sklearn_pandas in a code (using Spyder IDE), but got an error saying 'No module named 'sklearn_pandas''.\n2) After the above, I attempted another suggestion which was to execute 'easy_install sklearn_pandas'. I ran this in the Spyder IDE and got an error saying invalid syntax.\nCould someone help me out with this? Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":225,"Q_Id":59016428,"Users Score":0,"Answer":"Your pip doesn't recognized and constantly showing this message while executing: 'pip' is not recognized as an internal or external command, operable program or batch file. If your python version is 3.x.x format then you use pip3 not pip anymore. The usage is pip3 is exactly the same as pip","Q_Score":1,"Tags":"python","A_Id":59016457,"CreationDate":"2019-11-24T09:49:00.000","Title":"Issues installing sklearn_pandas package","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a simple program in Python and I need to change windows in which the application works multiple times. I could use pyautogui.click(x, y); to click on the taskbar but thats not efficent enough. \nIs there anyway I can do it with a command like: open('appname') or: summon('appname')\nThanks for the help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":580,"Q_Id":59017614,"Users Score":0,"Answer":"you using GUI without Tkinter? very interesting. you need to open program with python script?\ntry:\nimport os\n# If program isnt in a folder with script\nos.system(\"start LETTER:\\Path\\To\\Program\")\n# If program in a folder with a script or program is a command in command line\nos.system(\"start ProgramName\")\nWith it you can launch any program without limit (if you have a good CPU, GPU and RAM :D)","Q_Score":0,"Tags":"python,automation","A_Id":59017659,"CreationDate":"2019-11-24T12:24:00.000","Title":"I want to open an already opened app in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a small project in python. \nAs part of this project, I created 7 functions. Each function is saved in a separate file. \nI also have a main file - the code inside of it runs the functions. \neach of the functions in the files needs at least two external libraries. \nAlso, each external library is used at at least 2 functions. \n\nWhere should I place the imports?\nIf I call a function in a file that includes an import several times in the main code, will python redundantly import the library several times?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":59018214,"Users Score":1,"Answer":"where should I place the imports?\n\nYou place imports in each file that references that library. So if you have module 'A' and it has function my_func() that references 'math' you import it in the 'A' module.\n\nif I call a function in a file that includes an import several times in the main code, will python redundantly import the library several times?\n\nNo, Python is smart enough to do it only once. It's kind of singleton. Before it load a module, Python will check if it's already loaded and if it's loaded, it will reuse it.","Q_Score":1,"Tags":"python","A_Id":59018313,"CreationDate":"2019-11-24T13:37:00.000","Title":"Question about the correct way to orgenize a small project in python in term of imports","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using google cloud functions with Python. I want to format all logs with some additional data, e.g. customer id. I achieved this without any problem using Stackdriver Logging library with CloudLoggingHandler. In the same manner, I also like to add this information to uncaught error logs and tracebacks.\nI tried to modify sys.excepthook and sys.stderr but it did not work, probably they are handled exclusively by cloud functions.\nIs there any way I can modify uncaught exceptions or modify handled errors, e.g. by using Stackdriver error reporting? Or do you have any alternative solution for this (without catching all exceptions)?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":732,"Q_Id":59022947,"Users Score":2,"Answer":"Cloud Functions provides the (currently) highest level abstraction for code execution.  The philosophy is that your bring the code that implements your desired logic and Cloud Functions provides the highest level environment for execution.  This has pluses and minuses.  \nFurthermore, the biggest plus is that you have the very least to concern yourself with in order to get the execution you desired. \nOn the other hand, you have very little in the way of operational control (the vision is that Cloud Functions provides the maximum in operational control).\nAs a consequence, if you want more control over the environment at the cost of you having to do more \"work\", I suggest you Cloud Run. In Cloud Run, you package your application logic as a Docker container and then ask it to take care of all execution of such logic.  In your container, you can do anything you want ... including using technology such as Stackdriver logging and defining a CloudLoggingHandler.  Cloud Run then takes care of your scaling and execution environment from there.\nTo sum up, the answer then becomes \"No\" you don't have control over error logs in Cloud Functions but you can achieve your desired outcome by leveraging Cloud Run instead.","Q_Score":1,"Tags":"python-3.x,google-cloud-functions,stackdriver,google-cloud-logging,google-cloud-error-reporting","A_Id":59023178,"CreationDate":"2019-11-24T22:12:00.000","Title":"How to modify error logs in google cloud functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between next() and iterate() when working with gremlin? Why does next() return the added vertex when calling g.addV(), but iterate() does not? When should I use next() and when should I use iterate()?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1308,"Q_Id":59024185,"Users Score":10,"Answer":"The answer is already in your question. You'll use .next(), when you need the result (and you are expecting exactly one result), and you'll use .iterate(), when you don't need the result (typically mutation queries, that add\/change properties, edges and\/or vertices).","Q_Score":5,"Tags":"gremlin,gremlinpython","A_Id":59024283,"CreationDate":"2019-11-25T01:39:00.000","Title":"tinkerpop\/gremlin-python: next() vs iterate()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running an application that uses pyautogui.moveTo() and pyautogui.click() for a long period of time (an hour+).  To decrease the battery drain on my laptop, I'd ideally want the screen to turn off in this period, but because the autogui functions mimic using the mouse, the computer will not turn the screen off.  I'm using Windows 10, and I'm not sure if I could use some functions from PyWin32 or WMI as demonstrated in this post, because the screen will brighten again when the mouse moves each time. \nHaving the laptop turning off and on the screen repeatedly doesn't seem like it would save too much power, but I'm not sure.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":434,"Q_Id":59024219,"Users Score":0,"Answer":"I am not sure this is what you want but many to all laptops have a brightness setting and windows devices definitely do. This should save some power on your device.","Q_Score":0,"Tags":"python,windows,operating-system,pyautogui","A_Id":59024247,"CreationDate":"2019-11-25T01:48:00.000","Title":"Is it Possible to use pyAutoGui and Dim the Screen in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am working on cryptography.The data set i am using is numerical data to resolve the dimensional reduction issue i want to apply auto encoder and decoder neural network. is it possible to apply Auto Encoder on numerical data set if yes then how?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":59026939,"Users Score":0,"Answer":"Sure you can apply classical Autoencoders to numerical data. In its simplest form its just a matrix multiplication to a lower dimensional space and then a matrix multiplication to the original space and a L2-Loss based on the reconstruction and the input. You could start from there and add layers if your performance is insufficient.","Q_Score":0,"Tags":"python,neural-network,deep-learning,cryptography,autoencoder","A_Id":59034403,"CreationDate":"2019-11-25T07:23:00.000","Title":"Auto encoder and decoder on numerical data-set","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to set my CUDA Tensorflow on my windows 10. \nI would like to know what is the newest version of Python that works without bugs with the CUDA tensorflow and in which version.\nAlso what version of cuDNN should i use?\nThanks a lot.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":357,"Q_Id":59027575,"Users Score":0,"Answer":"you can use any \nbut it's better to use python version 3 with pip install 19.0 version \nas for the Cuda version you need to check what cuda version can be rub for your GPU \nand for cuDnn it will be desided on your cuda version","Q_Score":0,"Tags":"python,tensorflow,gpu","A_Id":59027703,"CreationDate":"2019-11-25T08:18:00.000","Title":"Which Python version should I download to run tensorflow GPU","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have my web application. Now i want to integrate salesforce into my web app so that i can push data from my app to any salesforce org after the authentication(OAuth).\nI found 2 ways:\n1. Connected Apps\n2. via wsdl generation file and use\nI created a connected app from my developer account and i authenticated using consumer key, cusumer secret key(from my connected app) and username of user and secret token of the user account.\nI tried with another free trail account, It's validating and fetching the details and post data also working.\nMy question is, shall i deploy my connected app into app exchange, then only i caan use REST APIs ?\n\ngenerating wsdl and coding around is the better option than the above ?\n\nIs there a option, only one time authentication enough for any number of sessions and use the REST APIs?\nPlease suggest me a best way to proceed.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":59031743,"Users Score":1,"Answer":"You're mixing up a couple of independent issues here.\n\nIf you're going to authenticate via OAuth, you must have a Connected App. \nA SOAP API login() call requires you to store a username and password, which is undesirable.\nThere is no way to \"permanently\" authenticate, i.e., to get a session id that never expires. Your app must always be ready to get a new access token via the OAuth refresh token it obtains and stores (via, for example, the Web Server OAuth flow), or to reauthenticate via JWT flow.\nConnected Apps are global metadata in most cases. You don't need to deploy a Connected App into a target org in order to authenticate using its Client Id and Secret into that org. The only exception I'm aware of is if you want to use the JWT flow with a certificate and preauthorized Profiles and Permission Sets.\nBased on what you've shared, I don't see any reason for the AppExchange to be involved.","Q_Score":0,"Tags":"python-2.7,salesforce","A_Id":59143337,"CreationDate":"2019-11-25T12:21:00.000","Title":"want to push\/pull data into\/from SalesForce Accounts\/leads from\/to my external web app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have some pandas series with the type \"pandas.core.series.Series\". I know that I can see its datetimeindex when I add \".index\" to the end of it. \nBut what if I want to get the element of the series at this time? and whats if I have a \"pandas._libs.tslibs.timestamps.Timestamp\" and want to get the element of the series at this time?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":135,"Q_Id":59032213,"Users Score":0,"Answer":"If your dataframe is indexed by date, you can:\n\ndf[date] to access all the rows indexed by such date (e.g. df['2019-01-01']);\ndf[date1:date2] to access all the rows with date index between date1 and date2 (e.g. df['2019-01-01': '2019-11-25']); \ndf[:date] to access all the rows with index before date value (e.g. df[:'2019-01-01']);\ndf[date:] to access all the rows with index after date value (e.g. df['2019-01-01':]).","Q_Score":0,"Tags":"python-3.x,pandas,numpy,time-series","A_Id":59032616,"CreationDate":"2019-11-25T12:48:00.000","Title":"Finding an element of pandas series at a certain time (date)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I developed a program to interact between Telegram and other 3rd party Software. It's written in Python and I used the Telethon library. \nEverything works fine, but since it uses my personal configuration including API ID, API hash, phone number and username, I would like to know how to handle all of this if I wanted to distribute the software to other people. \nOf course they can't use my data, so should they login into Telegram development page and get all the info? Or, is there a more user-friendly way to do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":118,"Q_Id":59032433,"Users Score":1,"Answer":"Since the API ID and the API Hash in Telegram are supposed to be distributed with your client all you need to do is prompt the user for their Phone Number. \nYou could do this using a GUI Library (like PySide2 using QInputDialog) or if it is a command line application using input(). Keep in mind that the user will also need a way to enter the code they receive from Telegram and their 2FA Password if set.","Q_Score":0,"Tags":"python,telegram,telethon","A_Id":59032610,"CreationDate":"2019-11-25T12:59:00.000","Title":"Python and Telethon: how to handle sw distribution","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 installed django and then tried using the command line to make a virtual environment then oops it gives me this error\n\"'\"virtualenv\"' is not recognized as an internal or external command,\noperable program or batch file.\"\nwhat should I do to correct this","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":63,"Q_Id":59036932,"Users Score":1,"Answer":"If you are on python3 , use python3 -m venv <env-name> , env-name being your preferred name for your virtual env. \nAlso you get that error because virtualenv is not installed on your system. You can install with pip install virtualenv","Q_Score":0,"Tags":"python,django","A_Id":59036974,"CreationDate":"2019-11-25T17:13:00.000","Title":"I am trying to create a webapp using django framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So i am trying to Pack my python script with pyarmor pack however, when i pack the script it does not work, it throws check restrict mode failed. If i Obfuscate the script normally with pyarmor obfuscate instead of pack the script it works fine, and is obfuscated fine. This version runs no problem. Wondering how i can get pack to work as i want my python file in an exe\nI have tried to compile the obfuscated script with pyinstaller however this does not work either\nWondering what else i can try?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3221,"Q_Id":59037825,"Users Score":1,"Answer":"I had this problem, fixed by adding --restrict=0\nFor example: pyarmor obfuscate --restrict=0 app.py","Q_Score":1,"Tags":"python-3.x,pyinstaller,py2exe,pyarmor","A_Id":59040654,"CreationDate":"2019-11-25T18:14:00.000","Title":"Pyarmor Pack Python File Check Restrict Mode Failed","Data 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 with NLP using Python using nltk or spaCy. \nMy question is, if I have the sentence,  'Barack Obama was the former President of united states', How can I retrieve the word president to provide the class of the entity?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":61,"Q_Id":59038431,"Users Score":1,"Answer":"Bascially, alexis is right. The most reliable approaches (also deployed in research, I know) is dependency parsing of arguments. Then you can extract the relation of the copular verb (was) in order to relate \"Barack Obama\" to \"president\". A more markov-like approach would be OIE (open information extraction). A more linguistically interesting phenomenon is the usage of \"former\" here, inverting the truth conditionality of applying president to Obama, but this is probably not important in your model.","Q_Score":0,"Tags":"python,nlp,nltk,spacy","A_Id":59047481,"CreationDate":"2019-11-25T18:56:00.000","Title":"Class of an entity recognition","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"when I enter this line pip3 install mysqlclient it gives me this error :\n\nERROR: Command errored out with exit status 1:\n\nthis happened after I tried using pip install mysqlclient","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":59039604,"Users Score":0,"Answer":"In order to use pip or pip3 in Windows operating system ; \n\nPYTHONPATH system variable should be added to environment variables for the path of\npython.exe file such as\nC:\\Users\\pc\\AppData\\Local\\Programs\\Python\\Python36\\\nPATH system variable should be edited by adding new paths such as\nC:\\Users\\pc\\AppData\\Local\\Programs\\Python\\Python36\\ and \nC:\\Users\\pc\\AppData\\Local\\Programs\\Python\\Python36\\Scripts\\\n\nThen, both of the variables might be checked whether they're set from command line by \nC:\\Users\\pc>echo %PYTHONPATH% and C:\\Users\\pc>echo %PATH%","Q_Score":0,"Tags":"python,mysql,pip","A_Id":59040353,"CreationDate":"2019-11-25T20:27:00.000","Title":"Error when trying to download mysql in a trial django project","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I train a neuronal network and when executing the script it seems to stop after some time. \nNothing is printed out anymore (for more than 20 minutes and normally it prints nearly every second something).\nSo I thought something would be wrong and kill the execution via the quadratical button. \nAnd immediately after pressing it, the execution continues!? \nThere is no exception occured or something simular. It seems like coming out of nothing.\nBut after pressing the button it continues just for a short time, like 5 seconds, then it stops fully (without reaching the end of the script). Maybe because I pressed the button?\nFirst I thought Spyder IDE could be the reason, maybe it doesnt work properly. So I tested JupyterLab but it happens exactly the same!\nCan anyone help me? I would be extremely glad if it would work...\nDo you need the code (Its really long) or some other information I forgot?\nThanks a lot!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":59039845,"Users Score":0,"Answer":"Nevertheless I dont understand why the execution continued after pressing the stopbutton, I assume that the reason for the strange behaviour is due to a wrong implemented while-loop. I forgot a break-statement in a nested if-clause.\nPresumably I am pretty sure the execution of py-scripts and jar-files is basically different. In Java (I am still used to Java) the consoleprinting would never had continued after stopping the execution. :D\nAnd exactly this is what made me searching for something different to be the reason than a coding error.\nHowever, after correcting the mistake it works properly.","Q_Score":0,"Tags":"python,keras,spyder","A_Id":59040236,"CreationDate":"2019-11-25T20:45:00.000","Title":"Python script continues after killing the execution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to implement a classifier which can have 1 of 10 possible classes. I am trying to use the MultiClass Softmax Loss Function to do this. Going through the documentation I'm not clear with what input is required for the function. \nThe documentation says it needs two matrices of [N, C] of which one is input and the other is target. As much as I understand, input matrix would be the one my Neural Network would calculate, which would have probabilities given by the neural network to each of the 10 classes. The target is the one that I have from my dataset. \nThe documentation says - \"Target(N, C) - label targets padded by -1 ensuring same shape as the input.\" What does this mean? Do I pass zeros in incorrect classes and -1 for the correct one? \nIt would be great if someone could elaborate on this and show even a sample 2d matrix which could be passed as a target matrix.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3994,"Q_Id":59040237,"Users Score":0,"Answer":"In pytorch 1.8.1, I think the right way to do is fill the front part of the target with labels and pad the rest part of the target with -1. It is the same as the MultiLabelMarginLoss, and I got that from the example of MultiLabelMarginLoss.","Q_Score":2,"Tags":"python,pytorch,loss-function,softmax","A_Id":66849256,"CreationDate":"2019-11-25T21:18:00.000","Title":"MultiLabel Soft Margin Loss in PyTorch","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to deploy my function on AWS Lambda. I need the following packages for my code to function:\n\nkeras-tensorflow\nPillow\nscipy\nnumpy\npandas\n\nI tried installing using docker and uploading the zip file, but it exceeds the file size.\nIs there a get around for this? How to use these packages for my Lambda function?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":273,"Q_Id":59040958,"Users Score":1,"Answer":"when the zip file size is bigger than 49 mb, You can upload the zip file to Amazon S3 and use it to update the function code. \n\naws lambda update-function-code --function-name calculateMath --region us-east-1 --s3-bucket calculate-math-bucket --s3-key 100MBFile.zip","Q_Score":0,"Tags":"python,amazon-web-services,numpy,tensorflow,aws-lambda","A_Id":59041168,"CreationDate":"2019-11-25T22:22:00.000","Title":"Deploy function in AWS Lamda (package size exceeds)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"GPU: Nvidia GTX 2070\nPython Version: 3.5 \nTensorflow: 1.13.1\nCUDA: 10\ncuDNN: 7.4\nModel: Faster-RCNN-Inception-V2\nI am using the legacy method of training my model (trian.py) and when I run it as such\npython train.py --logtostderr --train_dir=training\/ --pipeline_config_path=training\/faster_rcnn_inception_v2_pets.config\nThe training runs for some random amount of time (it usually gets stuck around the 150th step, but it will often make it up to 300-700 sometimes when I try it) and then will get stuck attempting to save a checkpoint. I reach the point where it just says \nINFO:tensorflow:global step 864: loss = 0.4430 (0.996 sec\/step)\nINFO:tensorflow:Saving checkpoint to path training\/model.ckpt\nINFO:tensorflow:Saving checkpoint to path training\/model.ckpt\nAnd does not move past that point. Once it reaches this point, I also become incapable of killing the program no matter which methods I try and am forced to simply close the terminal window if I want the process to stop. \nAdditionally, based on what I have read, the program should theoretically be using up close to 100% of my GPU while it trains but it only ends up using about 10%. I'm not sure if those two things are related but I feel it is probably worth mentioning, especially considering I would like to have it train as fast as possible if I do manage to get it working. \nI've seen others post about similar issues in the past but none seem to have any answers. If anyone has any idea please let me know! Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":778,"Q_Id":59042621,"Users Score":0,"Answer":"Had the same issues till I upgradet the Nvidia driver from Version 441.28 to the newest Version.\nAfter this, the training runs without stops or freezes.","Q_Score":1,"Tags":"python,tensorflow","A_Id":59877757,"CreationDate":"2019-11-26T01:56:00.000","Title":"Tensorflow-GPU getting stuck saving checkpoint during training - also not using entire GPU, not sure why","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Any operation of conda like conda install, conda update, conda remove, etc.,  receive a result of error, saying \n\n\"RemoveError: 'setuptools' is a dependency of conda and cannot be\n  removed from conda's operating environment.\"\n\nI almost tried every solution I searched from the internet but just couldn't fix it.\nIt's like a tumor and I just can't find the core problem.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3017,"Q_Id":59048256,"Users Score":4,"Answer":"Try the these commands step by step\nconda uninstall setuptools after that\nconda install setuptools and then\nconda update setuptools\nrestart anaconda and then enter these commands\nconda update --force conda or conda update conda and then\nconda update anaconda\nagain restart your anaconda","Q_Score":1,"Tags":"python,anaconda","A_Id":59048696,"CreationDate":"2019-11-26T10:01:00.000","Title":"Problem of \"RemoveError: 'setuptools' is a dependency of conda and cannot be removed from conda's operating environment\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Pandas DataFrame with a bunch of rows and labeled columns.\nI also have an excel file which I prepared with one sheet which contains no data but only\nlabeled columns in row 1 and each column is formatted as it should be: for example if I\nexpect percentages in one column then that column will automatically convert a raw number to percentage.\nWhat I want to do is fill the raw data from my DataFrame into that Excel sheet in such a way\nthat row 1 remains intact so the column names remain. The data from the DataFrame should fill\nthe excel rows starting from row 2 and the pre-formatted columns should take care of converting\nthe raw numbers to their appropriate type, hence filling the data should not override the column format.\nI tried using openpyxl but it ended up creating a new sheet and overriding everything.\nAny help?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1888,"Q_Id":59050052,"Users Score":0,"Answer":"If your # of columns and order is same then you may try xlsxwriter and also mention the sheet name to want to refresh: \ndf.to_excel('filename.xlsx', engine='xlsxwriter', sheet_name='sheetname', index=False)","Q_Score":1,"Tags":"python,python-3.x,pandas,dataframe","A_Id":59050279,"CreationDate":"2019-11-26T11:34:00.000","Title":"Fill an existing Excel file with data from a Pandas DataFrame","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Today I knew that pypy3 is faster than python3 for input() time through any algorithm problem. Performance differences were almost as much as 12 times.\nWhy is there such a difference?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":15748,"Q_Id":59050724,"Users Score":8,"Answer":"CPython\nIt is interpreter for python language written in C and C++. Interpreter convert python code (which is written by humans and can be read by humans) to machine code (which can be read\/understood by machines). This process involve various steps.\nCPython is the reference implementation of Python, written in C. It compiles Python code to intermediate bytecode which is then interpreted by a virtual machine. CPython provides the highest level of compatibility with Python packages and C extension modules.\nIf you are writing open source Python code and want to reach the widest possible audience, targeting CPython is best. To use packages which rely on C extensions to function, CPython is your only implementation option.\nAll versions of the Python language are implemented in C because CPython is the reference implementation.\nPyPy\nIt is JIT compiler for python language written in RPython. JIT compiler execute code which require compilation, i.e. JIT compile code at runtime, just before executing it.\nPyPy is a Python interpreter implemented in a restricted statically-typed subset of the Python language called RPython. The interpreter features a just-in-time compiler and supports multiple back-ends (C, CLI, JVM).\nPyPy aims for maximum compatibility with the reference CPython implementation while improving performance.\nIf you are looking to increase performance of your Python code, it\u2019s worth giving PyPy a try. On a suite of benchmarks, it\u2019s currently over 5 times faster than CPython.\nPyPy supports Python 2.7. PyPy3, released in beta, targets Python 3.","Q_Score":17,"Tags":"python-3.x,pypy","A_Id":59063758,"CreationDate":"2019-11-26T12:11:00.000","Title":"what's the differences python3 and pypy3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Today I knew that pypy3 is faster than python3 for input() time through any algorithm problem. Performance differences were almost as much as 12 times.\nWhy is there such a difference?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":15748,"Q_Id":59050724,"Users Score":6,"Answer":"Differences:\n1.PyPY has a JIT compiler built in, meaning that PyPY can be significantly faster than CPython (the standard version) - one of my mathematical applications was 10x faster under PyPy.\n2.PyPy comes with a GIL that works similarly to CPython's. There were experimental attempts to remove the GIL but it didn't work out in the end. It uses a different garbage collection mechanism which means it is better at multithreading\n3.PyPy is only so-far compatible with Python 3.6 - it is typically at least 6 months behind standard Python\n4.PyPy doesn\u2019t support the full API used by extension modules, so some 3rd party extension modules simply won\u2019t work. A special version of Numpy for instance had to be created just for PyPy.\n5.there are few semantic differences due to the different garbage collector in PyPy","Q_Score":17,"Tags":"python-3.x,pypy","A_Id":59063842,"CreationDate":"2019-11-26T12:11:00.000","Title":"what's the differences python3 and pypy3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Today I knew that pypy3 is faster than python3 for input() time through any algorithm problem. Performance differences were almost as much as 12 times.\nWhy is there such a difference?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":15748,"Q_Id":59050724,"Users Score":36,"Answer":"Kindly check this, when we speak of Python programming language we often mean not just the language but also the implementation. Python is a specification for a language that can be implemented in many different ways.\nThe default implementation of the Python programming language is Cpython(assuming python3 you mean Cpython). As the name suggests Cpython is written in C language. Cpython compiles the python source code into intermediate bytecode, which is executed by the Cpython virtual machine.\nJython is an implementation of the Python programming language that can run on the Java platform. Jython programs use Java classes instead of Python modules. Jython compiles into Java byte code, which can then be run by Java virtual machine.\nPyPy\nIf you want your code to run faster, you should probably just use PyPy. \u2014 Guido van Rossum (creator of Python)\nPython is a dynamic programming language. Python is said to be slow as the default CPython implementation compiles the python source code in bytecode which is slow as compared to machine code(native code). Here PyPy comes in.\nPyPy is an implementation of the Python programming language written in Python. The Interpreter is written in RPython (a subset of Python).\nPyPy uses Just In Time (JIT) compilation. In simple terms, JIT uses compilation methods to make the interpreter system more efficient and fast. So basically JIT makes it possible to compile the source code into native machine code which makes it very fast.\nPyPy also comes with default support for stackless mode, providing micro-threads for massive concurrency. It is said to be approximately 7.5 times faster than Cpython.\nHope this will help you.","Q_Score":17,"Tags":"python-3.x,pypy","A_Id":59063673,"CreationDate":"2019-11-26T12:11:00.000","Title":"what's the differences python3 and pypy3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe with 5000 items(rows) and 2048 features(columns). \nShape of my dataframe is (5000, 2048).\nwhen I calculate cosine matrix using pairwise distance in sklearn, I get (5000,5000) matrix. \nHere I can compare each other. \nBut now If I have a new vector shape of (1,2048), how can find cosine similarity of this item with early dataframe which I had, using (5000,5000) cosine matrix which I have already calculated? \nEDIT \nPS: I can append this new vector to my dataframe and calculate again cosine similarity. But for large amount of data it gets slow. Or is there any other fast and accurate distance metrics?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":241,"Q_Id":59052818,"Users Score":0,"Answer":"The initial (5000,5000) matrix encodes the similarity values of all your 5000 items in pairs (i.e. symmetric matrix).\nTo have the similarities in case of a new item, concatenate and make a (5001, 2048) matrix and then estimate similarity again to get (5001,5001)\nIn other words, you can not directly use the (5000,5000) precomputed matrix to get the similarity with the new (1,2048) vector.","Q_Score":0,"Tags":"python,pandas,machine-learning,scikit-learn,computer-vision","A_Id":59053007,"CreationDate":"2019-11-26T14:11:00.000","Title":"how to find cosine similarity in a pre-computed matrix with a new vector?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe with 5000 items(rows) and 2048 features(columns). \nShape of my dataframe is (5000, 2048).\nwhen I calculate cosine matrix using pairwise distance in sklearn, I get (5000,5000) matrix. \nHere I can compare each other. \nBut now If I have a new vector shape of (1,2048), how can find cosine similarity of this item with early dataframe which I had, using (5000,5000) cosine matrix which I have already calculated? \nEDIT \nPS: I can append this new vector to my dataframe and calculate again cosine similarity. But for large amount of data it gets slow. Or is there any other fast and accurate distance metrics?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":241,"Q_Id":59052818,"Users Score":0,"Answer":"Since cosine similarity is symmetric. You can compute the similarity meassure with the old data matrix, that is similarity between the new sample (1,2048) and old matrix (5000,2048) this will give you a vector of (5000,1) you can append this vector into the column dimension of the pre-computed cosine matrix making it (5000,5001) now since you know the cosine similarity of the new sample to itself. you can append this similarity to itself, back into the previously computed vector making it of size (5001,1), this vector you can append in the row dimension of the new cosine matrix that will make it (5001,5001)","Q_Score":0,"Tags":"python,pandas,machine-learning,scikit-learn,computer-vision","A_Id":59053865,"CreationDate":"2019-11-26T14:11:00.000","Title":"how to find cosine similarity in a pre-computed matrix with a new vector?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I select some text in the editor.  I would like to define my own Python functions or scripts that:\n\nTake as an input the selected text as a string.\nTransform it and return a new string that replaces the selected text back in the editor\n\nMoreover, I would like to ideally register these functions or scripts as a VSCode commands (with a specific commandIDs) that I can define myself and to the command palette in VSCode. By doing so, I can bind them to a shortcut in keybindings.json with specific shortcuts and when clauses.\n\nIs there any built-in functionality in VSCode to do this? If not, what set of steps can I follow to do it?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":485,"Q_Id":59060907,"Users Score":1,"Answer":"It is technically possible, but I'm unaware of any extension that currently supports this idea. You will probably need to write your extension to do this.","Q_Score":6,"Tags":"python,visual-studio-code,vscode-python","A_Id":59110217,"CreationDate":"2019-11-26T23:29:00.000","Title":"Using Python or TypeScript to transform text that I select in VSCode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to take a command line argument, argv[2], which will always be of the form split_pct=x where x is a specified float. To clarify, here's some valid examples: split_pct=90.0 or split_pct=55.23. For the given input, how could I extract that float?\nRunning Python 3.7","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":59061152,"Users Score":0,"Answer":"Resolved - because the string is of a standard form, we can get only the values after split_pct=. split_pct= is 10 chars, so\nx = float(sys.argv[2][10:] \nworks.","Q_Score":0,"Tags":"python,command-line,floating-point,argv","A_Id":59061290,"CreationDate":"2019-11-27T00:03:00.000","Title":"Python: Extract float from string of standard form","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a set of elements, which is  for example \nx= [250,255,273,180,400,309,257,368,349,248,401,178,149,189,46,277,293,149,298,223]\nI want to group these into n number of groups A,B,C... such that sum of all group variances is minimized. Each group need not have same number of elements.\nI would like a optimization approach in python or R.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":343,"Q_Id":59063240,"Users Score":0,"Answer":"I would sort the numbers into increasing order and then use dynamic programming to work out where to place the boundaries between groups of contiguous elements. For example, if the only constraint is that every number must be in exactly one group, work from left to right. At each stage, for i=1..n work out the set of boundaries that produces minimum variance computed among the elements seen so far for i groups. For i=1 there is no choice. For i>1 consider every possible location for the boundary of the last group, and look up the previously computed answer for the best allocation of items before this boundary into i-1 groups, and use the figure previously computed here to work out the contribution of the variance of the previous i-1 groups.\n(I haven't done the algebra, but I believe that if you have groups A and B where mean(A) < mean(B) but there are elements a in A and b in B such that a > b, you can reduce the variance by swapping these between groups. So the lower variance must come from groups that are contiguous when the elements are written out in sorted order).","Q_Score":1,"Tags":"python,r,algorithm,optimization,minimization","A_Id":59063566,"CreationDate":"2019-11-27T04:57:00.000","Title":"How should I group these elements such that overall variance is minimized?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Django app running on Elastic Beanstalk in a Multicontainer Docker platform. So each EC2 instance has Docker containers for Django, Celery, RabbitMQ and Nginx.\nI have concerns regarding celery tasks when an EC2 instance is removed due to an auto-scale event or an immutable deployment.\n\nWill current tasks in the celery queue be lost when an instance is\nremoved?\nCan a running celery task be interrupted on an instance removal?\nCelery beat schedule (cron) would be called from every new instance\nlaunched, causing duplicated calls.\n\nI'm curious if anyone else has experience solving the above? Here's a list of some of the solutions I'm thinking about:\n\nChange the celery broker to a remote ElastiCache Redis instance. Not\nsure that would work tho.\nUse another library to replace Celery which can store the tasks in\nthe DB (e.g. huey or apscheduler).\nMigrate from celery to AWS SQS + Elastic Beanstalk Worker. That\nwould mean duplicating the same codebase to be deployed to both the\ncurrent web as well as a worker Elastic Beanstalk.\n\nAny other ideas or concerns?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":731,"Q_Id":59065099,"Users Score":0,"Answer":"Do you need separate Celery\/Rabbit instance for every EC2 instance? Removing the rabbit instance will kill the celery unless you store it externally","Q_Score":1,"Tags":"python,django,amazon-web-services,celery,amazon-elastic-beanstalk","A_Id":59073048,"CreationDate":"2019-11-27T07:28:00.000","Title":"Are celery tasks and queues interrupted when elastic beanstalk EC2 instances are removed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"My actual problem is that python sqlite3 module throws database disk image malformed.\nNow there must be a million possible reasons for that. However, I can provide a number of clues:\n\nI am using python multiprocessing to spawn a number of workers that all read (not write) from this DB\nThe problem definitely has to do with multiple processes accessing the DB, which fails on the remote setup but not on the local one. If I use only one worker on the remote setup, it works\nThe same 6GB database works perfectly well on my local machine. I copied it with git and later again with scp to remote. There the same script with the copy of the original DB gives the error\nNow if I do PRAGMA integrity_check on the remote, it returns ok after a while - even after the problem occurred\nHere are the versions (OS are both Ubuntu):\n\nlocal:  sqlite3.version >>> 2.6.0, sqlite3.sqlite_version >>> 3.22.0\nremote: sqlite3.version >>> 2.6.0, sqlite3.sqlite_version >>> 3.28.0\n\n\nDo you have some ideas how to allow for save \"parallel\" SELECT?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":911,"Q_Id":59067407,"Users Score":0,"Answer":"The problem was for the following reason (and it had happened to me before):\nUsing multiprocessing with sqlite3, make sure to create a separate connection for each worker!\nApparently this causes problems with some setups and sometimes doesn't.","Q_Score":0,"Tags":"python,sqlite,select,multiprocessing,malformed","A_Id":59071448,"CreationDate":"2019-11-27T09:52:00.000","Title":"SQLITE3 \/ Python - Database disk image malformed but integrity_check ok","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a long-running Python app which scans many megabytes of files in a loop every few minutes. Over the course of a day I see that it gobbles up gigybates of memory, and in the end I have to kill and re-start it. Of course I'm suspecting a C extension I have built myself.\nWhen I run the app under valgrind, though, it shows no leaks (except for some big number in \"possibly lost\", but the \"naked\" Python interpreter does that as well).\nI've downloaded and compiled a debugging-enabled version of Python-3.6.8 and installed it in a virtualenv but I can't for the life of me figure out how to run setup.py on my extension with debugging enabled, let alone how to install all the other packages I need to run the full application.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":59069746,"Users Score":0,"Answer":"It turns out that over-referenced PyObjects end up in Valgrind's \"Possibly lost\" category, not \"definitely lost\". But even when running the Python interpreter alone there is a lot of stuff in \"possibly lost,\" so it took me a while to figure out where my code leaked memory (during the course of development a call to PyList_SetItem() had transmogrified into PyList_Append(), which doesn't steal the item's reference).","Q_Score":0,"Tags":"python-extensions","A_Id":59082591,"CreationDate":"2019-11-27T11:59:00.000","Title":"Python application leaking memory, but Valgrind says no","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using MQTT as message broker&queue in my project because we are communicating with embedded.\nI'm connecting to MQTT from my organizer and I need to know which devices connected to broker already. So, I need to list subscriber list as a subscriber. Or something like that, which one will tell me which subscribers connected.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":329,"Q_Id":59075274,"Users Score":0,"Answer":"You don't (at a pure MQTT protocol level).\nThere could be anywhere from 0 to infinite subscribers to a topic when a client publishes a message. There might also be persistent subscriptions to a topic for a client which is currently offline but will have the message delivered if\/when they reconnect.\nThis all fits with the pub\/sub work flow which is intended to totally decouple producers from consumers.\nYou can build systems on top of the protocol, using retained messages and Last will and Testaments, but that is entirely down to you to build what you want.","Q_Score":0,"Tags":"python,mqtt","A_Id":59075867,"CreationDate":"2019-11-27T17:08:00.000","Title":"list mqtt subscribers as subscriber","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two tensors of dimension 1000 * 1. I want to check how many of the 1000 elements are equal in the two tensors. I think I should be able to do this in one line like Numpy but couldn't find a similar function.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4942,"Q_Id":59078318,"Users Score":1,"Answer":"Something like\nequal_count = len((tensor_1.flatten() == tensor_2.flatten()).nonzero().flatten())\nshould work.","Q_Score":4,"Tags":"python,pytorch,equality,tensor","A_Id":59095464,"CreationDate":"2019-11-27T20:57:00.000","Title":"Compare Number of Equal Elements in Tensors","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am facing an odd issue\nI just downloaded WinPython and installed the community notebook extensions\nThe scratchpad extension comes up with Ctrl+B but when I hit Ctrl+Enter Jupyter executes the cell that has focus in the notebook not the scratchpad cell\nAny idea why is this is happening?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":59079711,"Users Score":0,"Answer":"I disabled all the extensions that could break Jupyter (as per the nbextensions tab) and then I enabled then one by one to see which one is breaking the scratchpad.\nMagically they are all working now, including the scratchpad","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":59079841,"CreationDate":"2019-11-27T23:19:00.000","Title":"Jupyter is not executing the scratchpad cell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm super new to coding (actually trying to teach myself some Python), but there's a thing bugging me that I cannot seem to find any info online about my particular case: When I run git on the terminal, there is:\n\nThe \"git\" command requires the command line developer\ntools. Would you like to install..\"\n\nNow, since I have a very basic Macbook 12, I try to keep it as lightweight and uncluttered as possible, so I don't want to install any IDE or anything, I'm practising coding with vim 7.3, but in order to install Vundle.vim to manage any plugins, I need git, is there a way I can install it without having to install Homebrew?\nThanks for any input! And sorry if I didn't express myself correctly. So basically to sum up:\n\u2013 I need git to install Vundle.vim, (or is there any other way?).\n\u2013 I run git on terminal and get an error that I need to install Xcode, which is like 7GB heavy.\n\u2013 I don't want to install Xcode or Homebrew.\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31820,"Q_Id":59080773,"Users Score":0,"Answer":"I encountered the same issue when I was going to use Git on a new macOS. My solution is pretty simple, but just to install homebrew.\nThe trick is that homebrew install loads a git repo of full source history. To achieve this, it firstly installs XCode command line development tool to get Git.\nThen, after you have homebrew, you can benefit from XCode tools to issue git commands. Note that no need to install other parts of XCode here.\nI was also surprised to see what happened at homebrew install. There might be a reason from homebrew developers.","Q_Score":3,"Tags":"python,xcode,git,vim,terminal","A_Id":65271112,"CreationDate":"2019-11-28T02:02:00.000","Title":"The \"git\" command requires the command line developer tools. Would you like to install?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have time series data set which contain TimeStamp[hour base] and wind sensor value. I need to find anomalies from this data set.\nWhat are the techniques to find out anomalies ?\nHow to find anomalies with only these two features ( TimeStamp, sensor-value ) ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":59083825,"Users Score":0,"Answer":"Very broad question so this will be a generic\/broad answer:\nTo define anomalies you'll need to think and define what you consider normal. \nUsually we consider two things in terms of (time series) data; \n\ndata availability:\nis the data there that you expect? Usually monitorred by looking at a row count over time (are you inserting more or less data than expected)\nalso counting null values could be used here, but this already leads into the question of data quality:\ndata quality: \nare the values in ranges you expect? are they in the type\/format you expect, etc. \nyou can use standard deviations\/variance\/normal distribution to monitor this. Or hard limit and define which values you accept\/expect (min, max for instance)","Q_Score":0,"Tags":"python,machine-learning,deep-learning,time-series,data-science-experience","A_Id":59083949,"CreationDate":"2019-11-28T07:38:00.000","Title":"How to find anomalies in wind-sensor TimeSeries data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need some help in R Machine Learning model execution by a Python REST API.\nI have 2 executable ML model, developed in R Language by my colleague.\nNow I need to deploy those models as a REST API, as we need to pass some input parameter and take output from those Models as a return statement.\nI found, we can do this with Python, using RPY2 or Plumber Libraries. So I tried to implement Flask REST API for R model deployment, but not getting the exact reference from google for my challenges and for learning. I am new in R-Language, just in last 2 weeks, I have explored some basis of R.\nCan someone please share me some reference to my query or any other approach or code reference to implement PYTHON REST API to execute R model by passing some input field.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":331,"Q_Id":59084012,"Users Score":0,"Answer":"You will need a Python based REST framework like Flask(Django or Pyramid will also do) to do this. You need to understand how to write a REST API by going through their respective docs. You can basically hide the R model behind a REST Resource. This resource will be responsible in receiving the inputs for the model. Using the RPY library you can invoke the model by passing required parameters and return a response to the API client.","Q_Score":0,"Tags":"python,r,rest,api,rpy2","A_Id":59084811,"CreationDate":"2019-11-28T07:51:00.000","Title":"How to Execute R Machine Learning Model using Python REST API?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to know version of MKL used by numpy in python anaconda distributive from python code?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1977,"Q_Id":59084304,"Users Score":2,"Answer":"My two cents: there is another method to check the version of mkl w\/o code modification. You need to set\/export environment variable MKL_VERBOSE=1 ( by default this variable is not set) and all mkl's functions will print version and many debug info.","Q_Score":1,"Tags":"python,numpy,anaconda,intel-mkl","A_Id":59098147,"CreationDate":"2019-11-28T08:13:00.000","Title":"How to know version of MKL used by numpy in python anaconda distributive?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can someone brief me on what happens if I didn't use any webserver(NGINX) in front of my Application server (uWSGI or GUNICORN)?\nMy requirement is exposing a simple python script as a web-service. I don't have any static content to render. In that scenario can I go without NGINX?\nBrief me what are the issues I will face if I go with plain app server? Max requests per second would be some 50 to 80(This is the upper limit).\nThanks, Vijay","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":59085500,"Users Score":0,"Answer":"If your script acts like a webserver then it is a webserver and you don't need any layer on top of it.\nYou have to make sure though it acts like one:\n\nlistens for connections\nhandles them concurrently\nwakes up upon server restart, etc\u2026\n\nAlso:\n\nhandles internal connections correctly (eg. to the database)\ndoesn't leak memory\ndoesn't die upon an exception\n\nHaving a http server in front of a script has one great benefit: the script executes and simply dies. No problem with memory handling and so on\u2026 imagine your script becomes unresponsive, ask yourself what then\u2026","Q_Score":0,"Tags":"python-3.x,nginx,uwsgi","A_Id":59085973,"CreationDate":"2019-11-28T09:28:00.000","Title":"What happens if i didn't use NGINX with uWSGI or Gunicorn?","Data Science and Machine Learning":0,"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 getting the following error while trying to install Django for python3\n\n(base) C:\\ShashiPractice ProjectStudent>pip install django\n  Collecting django\n   Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))\n  (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] \n  ...\n  ...\n  ...\n  y failed: self signed certificate in certificate chain (_ssl.c:1056)')))","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":132,"Q_Id":59086002,"Users Score":-1,"Answer":"You made a small mistake.\nThe pip command is as follows:\npip install Django\nNote that the the D in Django is in block letter. Hope this solves your problem :)","Q_Score":0,"Tags":"django,python-3.x,pip","A_Id":59087917,"CreationDate":"2019-11-28T09:52:00.000","Title":"I got error while installing Django on pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Recently I was experimenting with pyinstaller to create an executable file from my Python script. Everything works as expected. \nI tested two options: --onefile, which takes quite a long time (like 20-30sec) to start because it depacks everything into a temporary directory. \nThe --onedir option is much faster (4sec) to start but it's not very comfortable to use. When I move exe file outside this directory program no longer works.\nMy question is: is there a possibility to make the exe file point to this directory location? I want to keep all the pyinstaller files in one place and allow users to have the exe file in any location they want.\nThanks for help.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":4208,"Q_Id":59086193,"Users Score":2,"Answer":"Let's just see a real-life production case. Whenever you download say a pirated game, or and original copy of software, generally they are compressed together. When you unzip them, a new folder is extracted and inside that folder there are a lot of other folders. What you do to run the software is you simply double click the .exe file.\nYour situation is the same. If you move the exe file outside the original extracted folder then it simply doesn't work. So, the work around way is to create a shortcut to the exe file.\nHope this clarifies your doubt :)","Q_Score":4,"Tags":"python,python-3.x,anaconda,pyinstaller,executable","A_Id":59086520,"CreationDate":"2019-11-28T10:02:00.000","Title":"Pyinstaller onedir option - exe file outside the directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Recently I was experimenting with pyinstaller to create an executable file from my Python script. Everything works as expected. \nI tested two options: --onefile, which takes quite a long time (like 20-30sec) to start because it depacks everything into a temporary directory. \nThe --onedir option is much faster (4sec) to start but it's not very comfortable to use. When I move exe file outside this directory program no longer works.\nMy question is: is there a possibility to make the exe file point to this directory location? I want to keep all the pyinstaller files in one place and allow users to have the exe file in any location they want.\nThanks for help.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":4208,"Q_Id":59086193,"Users Score":2,"Answer":"Shortcut. Create .exe shortcut. This way original .exe will be still in parent directory but shortcut can be placed anywhere","Q_Score":4,"Tags":"python,python-3.x,anaconda,pyinstaller,executable","A_Id":59086276,"CreationDate":"2019-11-28T10:02:00.000","Title":"Pyinstaller onedir option - exe file outside the directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Recently I was experimenting with pyinstaller to create an executable file from my Python script. Everything works as expected. \nI tested two options: --onefile, which takes quite a long time (like 20-30sec) to start because it depacks everything into a temporary directory. \nThe --onedir option is much faster (4sec) to start but it's not very comfortable to use. When I move exe file outside this directory program no longer works.\nMy question is: is there a possibility to make the exe file point to this directory location? I want to keep all the pyinstaller files in one place and allow users to have the exe file in any location they want.\nThanks for help.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4208,"Q_Id":59086193,"Users Score":0,"Answer":"I think you should have some other files which is being required by that exe file & hence when you move exe file outside of directory it's giving you error. One of the example can be that the exe program require chrome driver & you have placed it within that directory. If you move exe program outside then you need to place the chrom driver also in the new position. I hope it will help you to detect , otherwise we can use exe program anywhere if it does not require any dependency of other files.","Q_Score":4,"Tags":"python,python-3.x,anaconda,pyinstaller,executable","A_Id":59086406,"CreationDate":"2019-11-28T10:02:00.000","Title":"Pyinstaller onedir option - exe file outside the directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have GitHub Actions that build and test my Python application. I am also using pytest-cov to generate a code coverage report. This report is being uploaded to codecov.io.\nI know that codecov.io can't fail your build if the coverage lowers, so how do I go about with GitHub Actions to fail the build if the coverage drops? Do I have to check the previous values and compare with the new \"manually\" (having to write a script)? Or is there an existing solution for this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":570,"Q_Id":59087777,"Users Score":0,"Answer":"There is nothing built-in, instead you should use one of the many integrations like sonarqube, if I don\u2019t want to write a custom script.","Q_Score":4,"Tags":"python,unit-testing,continuous-integration,code-coverage,github-actions","A_Id":65973463,"CreationDate":"2019-11-28T11:25:00.000","Title":"Fail build if coverage lowers","Data Science and Machine Learning":0,"Database and SQL":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 work with a huge library of components (step files) that are currently used in various products. My goal is to identify parts with great similarity in order to unify them. At the moment I can think of two solutions:\n\nCompare certain properties of the 3D data with a suitable python library. E.g. identify parts with similar volume and dimensions.\nConvert step files to JPG and compare the images with one of the many image processing libraries.\n\nBoth have their pitfalls.\nIs there a library that can handle step files or do you know a better way to solve the problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":908,"Q_Id":59087797,"Users Score":0,"Answer":"You are underestimating the complexity of this project. Once the STEP geometry is loaded, taking dimensions on it (apart from bounding box extents) can be really cumbersome. Very different parts can have the same volume and comparing bitmaps you completely ignore the hidden part of the geometry.","Q_Score":1,"Tags":"python,image-processing,3d,comparison,step","A_Id":59100622,"CreationDate":"2019-11-28T11:26:00.000","Title":"Is there a way to compare 3D model files (STEP) using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know in what situations is interesting\/necessary to redefine __deepcopy__? Indeed, this method is already implemented in a such a way to perform a deepcopy of an object. \nSo what is the point of redefining it differently?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":59088272,"Users Score":3,"Answer":"If there are cyclic references in the object-graph, things get tricky. The built-in  __deepcopy__ does in fact handle these, but you may want to customize the approach. \nAlso, there are objects (the original that you are calling deepcopy on or one in its reference graph)  that simply cannot be deep-copied, like file handles, and again, you may want your own approach.","Q_Score":2,"Tags":"python,python-3.x,deep-copy","A_Id":59088369,"CreationDate":"2019-11-28T11:51:00.000","Title":"When should we implement `__deepcopy__`?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to build a simple NN for regression purposes; the dimension of my input data reads (100000,3): meaning I have 1mio particles and their corresponding x,y,z coordinates. Out of these particles I want to predict centers which the particles correspond to where the data of the centers read (1000,3).\nmy question is: since the input array should have the same number of samples as target arrays how can I solve this problem?\nactually my mapping is from (100000,3) -> (1000,3) because on average about 100 particles belong to one center.\nto train the model i will use many of those datasets with the right centers as output; after that i want to predict out of one new set of particle coordinates the corresponding centers.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":68,"Q_Id":59089002,"Users Score":1,"Answer":"This is the answer to a question regarding unknown labels.\nYou have to know labels before using any supervised algorithm. Otherwise, there is no way you can train a model. You need to think of solving this problem by employing one of the unsupervised techniques, such as k-means algorithm, Gaussian Mixture Models, or Classification And Regression Trees, etc.\nFor example, one of the suggestions I would give is to try k-means with a fixed number of k, which is 1000 in your case, run the algorithm a couple of times and see if centroids are any close to elements in your output. Then, you could classify your output based on how close they are to one of the nearest centroids. Then all elements of input belonging to individual centroids would be classified as such.\n\nEDIT.\nAfter reconsidering your example, I think that perhaps k-NN would be much more helpful to your problem. In k-NN, outputs are considered as neighbours. Each point from the input is assigned to the closest neighbour. In the end, you already have the output but you don't know how to map all elements in both the input and the output. I have just realised your problem is \"the mapping\". It is a good chance k-NN would solve that meaning it would create labels for all elements in the input that correspond to elements in the output. Once it is done, the Neural Network model can be trained.","Q_Score":0,"Tags":"python,tensorflow,keras,neural-network,regression","A_Id":59116976,"CreationDate":"2019-11-28T12:32:00.000","Title":"NN multidim regression with matrix as output","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to build a simple NN for regression purposes; the dimension of my input data reads (100000,3): meaning I have 1mio particles and their corresponding x,y,z coordinates. Out of these particles I want to predict centers which the particles correspond to where the data of the centers read (1000,3).\nmy question is: since the input array should have the same number of samples as target arrays how can I solve this problem?\nactually my mapping is from (100000,3) -> (1000,3) because on average about 100 particles belong to one center.\nto train the model i will use many of those datasets with the right centers as output; after that i want to predict out of one new set of particle coordinates the corresponding centers.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":68,"Q_Id":59089002,"Users Score":1,"Answer":"All you have to do is to match the sizes. Assuming you know what particle belongs to what center that shouldn't be too hard.\nSo in your case you should have a matrix of (1000000,3)(atoms) and a vector of (1000000,)(centers) as their labels. This means that each entry in the vector corresponds to one row in the atom matrix.","Q_Score":0,"Tags":"python,tensorflow,keras,neural-network,regression","A_Id":59106465,"CreationDate":"2019-11-28T12:32:00.000","Title":"NN multidim regression with matrix as output","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In a typical python server setup it is recommended to have Nginx web server serve the static content and proxy the dynamic requests to  Gunicorn app server. \nNow if I am not serving any static content through my python application do I still need Nginx in front of Gunicorn ? What would be the advantages ? \nDetailed explanation would be really appreciated.\nAll the static content is served through CDN and the backend server will only need to serve the APIs(REST). So when I will only server dynamic content, will I need to have Nginx ? Does it have any advantage in case of high load etc.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":4178,"Q_Id":59089648,"Users Score":2,"Answer":"No, I no longer deploy nginx specifically for the python app. I may have an application load balancer \/ nginx in the path to split requests to other apps, but not for load management. If using asyncio based systems, I typically don't even use an app server (uwsgi\/gunicorn). This is including apps with very high throughput. Every layer of reverse-proxy \/ layer-7 load balancing will add a touch of latency- don't add it if you don't need it.","Q_Score":15,"Tags":"python,django,nginx,django-rest-framework,gunicorn","A_Id":60285690,"CreationDate":"2019-11-28T13:08:00.000","Title":"Do I need Nginx with Gunicorn if I am not serving any static content?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In my case I have a dataset of letters and symbols, detected in an image. The detected items are represented by their coordinates, type (letter, number etc), value, orientation and not the actual bounding box of the image. My goal is, using this dataset, to group them into different \"words\" or contextual groups in general.\nSo far I achieved ok-ish results by applying classic unsupervised clustering, using DBSCAN algorithm, but still this is way t\u03bfo limited on the geometric distance of the samples and so the resulting groups cannot resemble the \"words\" I am aiming for. So I am searching for a way to influence the results of the clustering algorithm by using the knowledge I have about the \"word-like\" nature of the clusters needed.\nMy possible approach that I thought was to create a dataset of true and false clusters and train an SVM model (or any classifier) to detect whether a proposed cluster is correct or not. But still for this, I have no solid proof that I can train a model well enough to discriminate between good and bad clusters, plus I find it difficult to efficiently and consistently represent the clusters, based on the features of their members. Moreover, since my \"testing data\" will be a big amount of all possible combinations of the letters and symbols I have, the whole approach seems a bit too complicated to attempt implementing it without any proof or indications that it's going to work in the end.\nTo conclude, my question is, if someone has any prior experience with that kind of task (in my mind sounds rather simple task, but apparently it is not). Do you know of any supervised clustering algorithm and if so, which is the proper way to represent clusters of data so that you can efficiently train a model with them? \nAny idea\/suggestion or even hint towards where I can research about it will be much appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1973,"Q_Id":59093163,"Users Score":0,"Answer":"A standard approach would be to use the dendrogram.\nThen merge branches only if they agree with your positive examples and don't violate any of your negative examples.","Q_Score":2,"Tags":"python,machine-learning,cluster-analysis,unsupervised-learning,supervised-learning","A_Id":59095070,"CreationDate":"2019-11-28T16:34:00.000","Title":"Is there any supervised clustering algorithm or a way to apply prior knowledge to your clustering?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a few files that were created by exporting CAN-Bus data in CANalyzer or Vector. The problem is the mainly interesting data in the file are encoded and look like this: \"40c1 bf1b 490d 34b0 46c5 6ed0 a853 d856\".\nIs there a way to \"convert\" this data into normal, human readable numbers by means of the python-can or cantools?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2308,"Q_Id":59094934,"Users Score":0,"Answer":"I work with this daily, and M.Spiller is correct in every way. Most of the different manufacturers also have their own specific interpretation per ECU. Only a very limited amount of data is part of the ISO 15031 standard that you need to follow for emission related readouts from CAN through the OBD-port. But the rest, you need the specific database for to be able to read and interpret.","Q_Score":0,"Tags":"python,can-bus,canalyzer,python-can","A_Id":72471850,"CreationDate":"2019-11-28T19:01:00.000","Title":"Converting Vector *.blf data to normal readable data for spreadsheet use with python-can or cantools","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been trying to get SCons to work on the Windows 10 cmd for some time now. I installed it through pip, so I believe it is in the correct directory because python is working in cmd when I use py. When I try to use scons, I get the message \n\n'scons' is not recognized as an internal or external command,\n  operable program or batch file.\n\nBecause of that, I tried editing the user and system path variable to include scons under the directory 'C:\\Users\\dwayn\\AppData\\Local\\Programs\\Python38\\Lib\\site-packages\\scons\\', but I get the same error. \nWhat should I edit to make scons run on the command line?\nNote: I do have Anaconda 3 installed on my system if that effects anything.","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":3905,"Q_Id":59097128,"Users Score":3,"Answer":"I was stuck on this too - quick answer here because the documentation around this area is pretty awful:\n\nInstall python, including pip and tick 'add python to PATH'\nRun pip install scons in command line. This installs Scons, but it won't be available from command line yet\nIf you run pip show scons it'll show you where the Scons code actually is (for me it's c:\\users\\username\\appdata\\roaming\\python\\python38\\site-packages - but this is not what you want to add to your path\nThe Windows version of Scons runs through a wrapper .exe (historically this was a .bat file so there's posts everywhere saying to just 'find scons.bat'... which doesn't exist)\nThis wrapper program scons.exe is located in the Scripts folder of your python install - so with a generic install of Python 3.8 it would be here: C:\\Users\\username\\AppData\\Roaming\\Python\\Python38\\Scripts - here you should find the scons wrapper\n\nThis Scripts folder could be in a variety of places depending on how you installed python, and what version you have - If you can't find it there then also try places like C:\\Python27\\Scripts, C:\\Program Files (x86)\\Python38-32\\Scripts, etc\n\n\nAdd this folder to you PATH variable\nRestart cmd to pick this change up, and run where scons to check if it worked - this should return the filepath to scons.exe\n\nYou should now be able to run scons from command line","Q_Score":2,"Tags":"python,windows,cmd,windows-10,scons","A_Id":63925889,"CreationDate":"2019-11-28T23:25:00.000","Title":"How do I get SCons to work on the Windows 10 command line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've been trying to get SCons to work on the Windows 10 cmd for some time now. I installed it through pip, so I believe it is in the correct directory because python is working in cmd when I use py. When I try to use scons, I get the message \n\n'scons' is not recognized as an internal or external command,\n  operable program or batch file.\n\nBecause of that, I tried editing the user and system path variable to include scons under the directory 'C:\\Users\\dwayn\\AppData\\Local\\Programs\\Python38\\Lib\\site-packages\\scons\\', but I get the same error. \nWhat should I edit to make scons run on the command line?\nNote: I do have Anaconda 3 installed on my system if that effects anything.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3905,"Q_Id":59097128,"Users Score":0,"Answer":"On my system, I have Python 3.8 installed in C:\\Python38. During the install using the exe installer, I checked the box to add Python to the system path. I then installed scons, which also goes into that location. Running scons didn't work at first (as it had with previous version installs) and I found that the paths that the Python installer added needed to be flipped. It needed to be C:\\Python38;C:\\Python38\\Scripts;%PATH%. The reason is because scons.bat is in C:\\Python38 and scons.py is in C:\\Python38\\Scripts. To run scons, it needs to find scons.bat first.\nMy suggestion is to make sure you have those two paths (wherever they are) in your system environment path such that the path to scons.bat comes first and make sure these come before any paths for other Python installs.","Q_Score":2,"Tags":"python,windows,cmd,windows-10,scons","A_Id":62600456,"CreationDate":"2019-11-28T23:25:00.000","Title":"How do I get SCons to work on the Windows 10 command line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"My program executes a specific script, after which it creates a process via Popen method by executing a .bat (batch) file.\nThe .bat file, in turn, executes another .exe file. The problem for me arises when I am trying to simply run p.kill() to terminate the .exe file process .bat file has started. \nInstead of terminating all the processes, it just tries to kill the .bat file process, but not the .exe file's process that .bat file has created.\nIs there a way for me to specifically kill the .exe process?\nUPD: It seems like .bat file creates a separate .exe process which I cannot simply end with p.kill(), since it has different pid from the .bat's file process.\nI tried killing it with running os.system(\"taskkill \/F \/im process.exe\"), but it didn't touch the .exe process. Surprisingly, running the same taskkill command in the console did kill it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":781,"Q_Id":59097889,"Users Score":1,"Answer":"I managed to solve the issue by running the subprocess.call(\"taskkill \/F \/im process.exe\").\nI am not sure why os.system didn't work in the first place, perhaps it's due to its outdated nature. Hopefully, it helps those who will encounter a similar issue!","Q_Score":2,"Tags":"python,batch-file,operating-system,popen,kill","A_Id":59117563,"CreationDate":"2019-11-29T01:52:00.000","Title":"Kill external process started by batch file on Windows from within Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"More of a theoretical question: \nUse case: Create an API that takes json input, triggers ML algorithm inside of it and returns result to the user. \nI know that in case of python ML model, I could just pack whole thing into pickle and use it easily inside of my web app. The problem is that all our algorithms are currently written in R and I would rather avoid re-writing them to python. I have checked a few libraries that allow to run R code within python but I cannot find a way to pack it \"in a pickle way\" and then just utilize. \nIt may be stupid but I have not had much to do with R so far.\nThank you in advance for any suggestions!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":59101644,"Users Score":0,"Answer":"Not sure what calling R code from Python has to do with ML models.\nIf you have a trained model, you can try converting it into ONNX format (emerging standard), and try using the result from Python.","Q_Score":0,"Tags":"python,r,machine-learning,web-applications","A_Id":59107037,"CreationDate":"2019-11-29T08:58:00.000","Title":"Is there a way to use pre-trained R ML model in python web app?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a folder containing 5100 images in png format , each image having 32 * 32 pixels (height and width) . How can I resize the image in python by increasing its height and width(for image processing)? Also , will doing this can help my model improve the accuracy?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":59103295,"Users Score":0,"Answer":"If you are using python, you can use .resize() option to resize the image. This, as per my knowledge, won't have any impact on the accuracy","Q_Score":0,"Tags":"python-3.x,data-science","A_Id":59103470,"CreationDate":"2019-11-29T10:44:00.000","Title":"Resizing a small image into bigger image","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"gave this error in installation. Does this cause a problem?\nERROR: tensorboard 2.0.2 has requirement setuptools>=41.0.0, but you'll have setuptools 40.6.2 which is incompatible.","AnswerCount":5,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":24912,"Q_Id":59104396,"Users Score":5,"Answer":"Uninstall TensorFlow using command pip uninstall tensorflow\nRe-install it using the command pip install --upgrade tensorflow","Q_Score":21,"Tags":"python,tensorflow,flask","A_Id":59433304,"CreationDate":"2019-11-29T12:01:00.000","Title":"ERROR: tensorboard 2.0.2 has requirement setuptools>=41.0.0, but you'll have setuptools 40.6.2 which is incompatible","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"gave this error in installation. Does this cause a problem?\nERROR: tensorboard 2.0.2 has requirement setuptools>=41.0.0, but you'll have setuptools 40.6.2 which is incompatible.","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":24912,"Q_Id":59104396,"Users Score":36,"Answer":"I just did a pip install setuptools --upgrade\nthen \npip install tensorflow","Q_Score":21,"Tags":"python,tensorflow,flask","A_Id":59569415,"CreationDate":"2019-11-29T12:01:00.000","Title":"ERROR: tensorboard 2.0.2 has requirement setuptools>=41.0.0, but you'll have setuptools 40.6.2 which is incompatible","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"gave this error in installation. Does this cause a problem?\nERROR: tensorboard 2.0.2 has requirement setuptools>=41.0.0, but you'll have setuptools 40.6.2 which is incompatible.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":24912,"Q_Id":59104396,"Users Score":0,"Answer":"Modify the METADATA file of tensorboard. Let it not complain the version of setuptools.\nThis solution works on MacOS.\nEdit file \n\n\/Library\/Python\/3.7\/site-packages\/tensorboard-2.0.2.dist-info\/METADATA\n\nChange \"Requires-Dist: setuptools (>=41.0.0)\" to \"Requires-Dist: setuptools (>=40.0.0)\"\nThen it will not report the error.","Q_Score":21,"Tags":"python,tensorflow,flask","A_Id":59505352,"CreationDate":"2019-11-29T12:01:00.000","Title":"ERROR: tensorboard 2.0.2 has requirement setuptools>=41.0.0, but you'll have setuptools 40.6.2 which is incompatible","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a data set of around 15k observations. This observations are city names from all over the world. This Data set has been populated by people from many different countries which means that i have several duplicates of the same city in different languages. see below DF extract:\ncity_name\nbruselas\nbrussel\nbrussels\nbrussels\nbrussels  auderghem \nbruxelles\nbruxelles belgium\nmunchen\nmunchenstein\nmunchwilen\nmunderkingen\nmundolsheim\nmungia\nmunguia\nmunich\nmunich\nmunich\nmunich  germany\nmunich  munchen \nmunich rupert mayer strasse\nThe task is to map all cities in the DF to its english name but, becaue the cities are in different format and in different languages i am finding it very difficult to come up with a solution other than perform this task manually which is not productive as we have 15,000+ observations to go through. The final data set should look something like this(using a few of the observations above only):\ncity_name              mapped_city\nbrussels  auderghem     Brusels\nbruxelles               Brusels\nbruxelles belgium       Brusels\nmunchen                 Munich\nmunich  germany         Munich\nAny help would be greatly appreciated","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":333,"Q_Id":59104543,"Users Score":-1,"Answer":"Try mapping by first letters of a city that will reduce your work load","Q_Score":3,"Tags":"python,algorithm,sorting,dataframe","A_Id":59104620,"CreationDate":"2019-11-29T12:10:00.000","Title":"Effective way to map 15k cities in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I understand this is a recurring question but I think my use case is a bit different from the norm:\n\nOn one end, I have a number of tasks running that update the state of a Model object, all running asynchronously with Advanced Python Scheduler\nOn the other end, I have a terminal UI framework (asciimatics) that is basically a loop refreshing the screen.\n\nMy goal is to have the UI display the state of the Model. How do I do this in python?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":143,"Q_Id":59111669,"Users Score":1,"Answer":"Solved my own question. In case anyone stumbles upon a similar problem: the short answer is to use multithreading.\n\nIf you're using APS as well, you can just use the BackgroundScheduler class. It will schedule your tasks in separate threads and won't block the main one.\nIf you are using something else for your background tasks, just run them in a separate thread with the threading module.","Q_Score":1,"Tags":"python,python-3.x","A_Id":59111885,"CreationDate":"2019-11-29T22:38:00.000","Title":"How do I run separate tasks at the same time in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Everything was ok around a week ago.\nEven though I am running on a server, I really don't think much has changed. \nWonder what could have caused it.\nTensorflow has version 2.1.0-dev20191015\nAnyway, here is the GPU status:\nNVIDIA-SMI 430.50\nDriver Version: 430.50\nCUDA Version: 10.1 \nEpoch 1\/5\n2019-11-29 22:08:00.334979: I tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10.0\n2019-11-29 22:08:00.644569: I tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7\n2019-11-29 22:08:00.647191: E tensorflow\/stream_executor\/cuda\/cuda_dnn.cc:329] Could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED\n2019-11-29 22:08:00.647309: E tensorflow\/stream_executor\/cuda\/cuda_dnn.cc:337] Possibly insufficient driver version: 430.50.0\n2019-11-29 22:08:00.647347: W tensorflow\/core\/framework\/op_kernel.cc:1655] OP_REQUIRES failed at cudnn_rnn_ops.cc:1510 : Unknown: Fail to find the dnn implementation.\n2019-11-29 22:08:00.647393: W tensorflow\/core\/common_runtime\/base_collective_executor.cc:217] BaseCollectiveExecutor::StartAbort Unknown: Fail to find the dnn implementation.\nAt the end, I get:\nUnknownError:  [_Derived_]  Fail to find the dnn implementation.\n     [[{{node CudnnRNN}}]]\n     [[sequential\/bidirectional\/forward_lstm\/StatefulPartitionedCall]] [Op:__inference_distributed_function_18158]\nFunction call stack:\ndistributed_function -> distributed_function -> distributed_function\nThe code gets traced back to here:\n174         history = model.fit(training_input, training_output,  epochs=EPOCHES,\n    175                             batch_size=BATCH_SIZE,\n--> 176                             validation_split=0.1)\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":389,"Q_Id":59112898,"Users Score":1,"Answer":"There was indeed a system-wide upgrade.\nUpdating cuda to cuda 10.2 and nvidia-driver to 440 and making libcudnn7 7.6.5 fixed the problem.","Q_Score":4,"Tags":"python,tensorflow","A_Id":59178620,"CreationDate":"2019-11-30T03:20:00.000","Title":"Encountering \"Could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED\" on a previously working system","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there anyway to terminate a python program only when the user shutsdown the system?\nI want to include the condition in the while loop so that it keeps on looping till the system shutsdown.\nAlso is there a way to start the program automatically on booting the system?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":59113296,"Users Score":2,"Answer":"Convert your python app to linux service is much better than white true only","Q_Score":0,"Tags":"python","A_Id":59113393,"CreationDate":"2019-11-30T04:57:00.000","Title":"Terminate a running python program only when the system shuts down","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there a way to make the Python program to run in background when the system boots?\n(on windows and linux systems)","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7556,"Q_Id":59113569,"Users Score":0,"Answer":"Yes, If your OS is linux then you can try supervisor. Otherwise you can just directly create a service in linux for your python file which you wants to run and then enable it for auto start when system boots up.","Q_Score":0,"Tags":"python,linux,windows","A_Id":59113614,"CreationDate":"2019-11-30T05:47:00.000","Title":"Automatically run a Python program when the system boots","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am writing an HR calculation program and the tax\/benefits calculations are vastly different for each country so I have separate modules for each country, e.g. USA_HR_Functions.py, Japan_HR_Functions.py, etc. (there are 36 in total). \nIn each module, I have functions (with the same name) - salary, tax, benefits, etc. \nFrom this, I am writing a loop that goes through each employee and checking their information to determine the calculations to use, e.g.\n\nemployee_1 is in Japan, therefore it will use Japan_HR_Functions.salary(), Japan_HR_Functions.tax(), etc.\nemployee_2 is in USA, therefore it will use USA_HR_Functions.salary(), USA_HR_Functions.tax(), etc.\n\nI already have everything written out and it works if I do one country at a time. Meaning everything uses functions from one module. I want to loop through all the employees in one go.","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":95,"Q_Id":59114461,"Users Score":2,"Answer":"The OO way would be to create (possibly abstract) class(es) for employee (and other business objectes) management declaring all the methods used to compute salary, tax, benefits, etc.\nThen in each module you define implementation classes specialized for that country (or group of countries).\nOne this is done, you can loop over employees through the base class, and the OO magic will select the proper operations.\nA simply implementation to be able the create the employee objects would be to have a map of the implementation classes indexed by the country name.\nDepending on the complexity of your real use case, this can be overkill or the most maintainable way...","Q_Score":1,"Tags":"python,python-3.x","A_Id":59114735,"CreationDate":"2019-11-30T08:22:00.000","Title":"Is it possible to select a function from a large number of modules based off a variable (not using if, there are too many variations)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using Tensorflow on Anaconda for a while now, but recently I have been getting the mentioned error when trying to import Tensorflow. \nThis has been asked here multiple times, so I tried suggested solutions but nothing worked so far (reinstalling tensorflow (both normal and gpu versions), reinstalling Anaconda). When running help('modules') tensorflow appears in module list. But even after I run pip uninstall tensorflow and pip uninstall tensorflow-gpu tensorflow still remains in module list when running help('modules'). \nWhat can I do to fix this?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1414,"Q_Id":59115365,"Users Score":1,"Answer":"Apparently the reason was the Python version (which is strange as according to documentation Tensorflow supports Python 3.7). I downgraded to 3.6 and I am able to import Tensorflow again","Q_Score":0,"Tags":"python,tensorflow,anaconda","A_Id":59117449,"CreationDate":"2019-11-30T10:43:00.000","Title":"ModuleNotFoundError: No module named 'tensorflow.python' Anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Everything was working smoothly until I started getting the following error:\n\nTraceback (most recent call last):\n    File \"\", line 1, in \n    File \"\/home\/user\/Workspace\/Practices\/Tensorflow\/tensorflow2\/venv\/lib\/python3.7\/site-packages\/tensorflow\/init.py\", line 98, in \n      from tensorflow_core import *\n    File \"\/home\/user\/Workspace\/Practices\/Tensorflow\/tensorflow2\/venv\/lib\/python3.7\/site-packages\/tensorflow_core\/init.py\", line 40, in \n      from tensorflow.python.tools import module_util as _modle_util\n  ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package\n\nMy environment setup:\n\npython-3.7\nUsing venv module to create virtual environment\ntensorflow 2.0.0\npip 19.0.3\nManjaro Linux\n\nNow, I even can't import tensorflow module as well. It gives same above error. Tried reinstalling with cache and without cache as well, but no luck. Recreated virtual environment as well, no luck. This is really weird and have no clue where to start troubleshooting as well. Looking at virtual environment site packages, everything seems fine.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":12652,"Q_Id":59116456,"Users Score":0,"Answer":"Found a noob problem. I was using my file name as csv.py which already exist in python library, which I think was messing up the paths. But don't know how yet.","Q_Score":2,"Tags":"python,tensorflow","A_Id":59123027,"CreationDate":"2019-11-30T13:06:00.000","Title":"No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Everything was working smoothly until I started getting the following error:\n\nTraceback (most recent call last):\n    File \"\", line 1, in \n    File \"\/home\/user\/Workspace\/Practices\/Tensorflow\/tensorflow2\/venv\/lib\/python3.7\/site-packages\/tensorflow\/init.py\", line 98, in \n      from tensorflow_core import *\n    File \"\/home\/user\/Workspace\/Practices\/Tensorflow\/tensorflow2\/venv\/lib\/python3.7\/site-packages\/tensorflow_core\/init.py\", line 40, in \n      from tensorflow.python.tools import module_util as _modle_util\n  ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package\n\nMy environment setup:\n\npython-3.7\nUsing venv module to create virtual environment\ntensorflow 2.0.0\npip 19.0.3\nManjaro Linux\n\nNow, I even can't import tensorflow module as well. It gives same above error. Tried reinstalling with cache and without cache as well, but no luck. Recreated virtual environment as well, no luck. This is really weird and have no clue where to start troubleshooting as well. Looking at virtual environment site packages, everything seems fine.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":12652,"Q_Id":59116456,"Users Score":0,"Answer":"You don't need to uninstall tensorflow what version you have because it will take time to reinstall. You can fix this issue just by installing tensorflow==2.0.\npip install tensorflow==2.0","Q_Score":2,"Tags":"python,tensorflow","A_Id":68268774,"CreationDate":"2019-11-30T13:06:00.000","Title":"No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Everything was working smoothly until I started getting the following error:\n\nTraceback (most recent call last):\n    File \"\", line 1, in \n    File \"\/home\/user\/Workspace\/Practices\/Tensorflow\/tensorflow2\/venv\/lib\/python3.7\/site-packages\/tensorflow\/init.py\", line 98, in \n      from tensorflow_core import *\n    File \"\/home\/user\/Workspace\/Practices\/Tensorflow\/tensorflow2\/venv\/lib\/python3.7\/site-packages\/tensorflow_core\/init.py\", line 40, in \n      from tensorflow.python.tools import module_util as _modle_util\n  ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package\n\nMy environment setup:\n\npython-3.7\nUsing venv module to create virtual environment\ntensorflow 2.0.0\npip 19.0.3\nManjaro Linux\n\nNow, I even can't import tensorflow module as well. It gives same above error. Tried reinstalling with cache and without cache as well, but no luck. Recreated virtual environment as well, no luck. This is really weird and have no clue where to start troubleshooting as well. Looking at virtual environment site packages, everything seems fine.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":12652,"Q_Id":59116456,"Users Score":1,"Answer":"I just faced this problem right now. I ran the source code on another computer and it showed the same error. I went ahead and compared the version of TensorFlow and turns out that the other computer was running tensorflow==2.1.0 and mine was running tensorflow==1.14.0.\n\nIn short, downgrade your tensorflow installation (pip install tensorflow==1.14.0)","Q_Score":2,"Tags":"python,tensorflow","A_Id":60205686,"CreationDate":"2019-11-30T13:06:00.000","Title":"No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an already existing Django app. I would like to add a system that sends data from my Django application to another Python application hosted on another server, so that the Python application receives data from the Django App in json format, possibly. \nSo for example, i would need to create a view that every tot seconds sends the data from a DB table to this application, or when a form is hit, the data is sent to this external application.\nHow can i do this? Is there an example for this particular matter? I don't know what tools i'd need to use to create this system, i only know that i would need to use Celery to perform asynchronous tasks, but nothing else; should i use Webhooks maybe? Or Django channels?\nEdit: adding some more context:\nI have my Django client. Then i have one or two Python applications running on another server. On my Django client i have some forms. Once the form is submitted, the data is saved on the db, but i also want this data to be sent instantly to my Python applications. The Python applications should receive the data from Django in Json format and perform some tasks according to the values submitted by users. Then the application should send a response to Django.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1295,"Q_Id":59117241,"Users Score":2,"Answer":"Yeah, webhook would be one of the options, but there are other options available too.\n-> You can use Rest Apis to send data from one app to another. but In their case, you need to think about synchronization. That depends on your requirement, If you don't want data in synchronize manner then you may use RabbiMq or other async tools. Just push your rest API request in Rabbitmq and Rabbitmq will handle.","Q_Score":2,"Tags":"python,django","A_Id":59117541,"CreationDate":"2019-11-30T14:50:00.000","Title":"Send data from Django to another server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am developing proprietary software that would be distributed in a form of .exe file. In order to use it, users will have to authenticate with their whitelist credentials (username + password).\nThe issue I have encountered is that in the industry I am selling on, there are a lot of \"hackers\" who will try to decompile your executable file, get the source code and distribute it for free to other people.\nTo combat these reverse-engineering attempts, I have tried to both obfuscate my code and use various compilers, but so far to no success.\nWhat I have tried:\n\nUse py2exe compiler: \"hackers\" managed to decompile executable in an hour.\nUse pyinstaller compiler: same as with py2exe.\nUse pyminifier to obfuscate the code: \"hackers\" managed to deobfuscate the code.\nUse Oxyry Python Obfuscator: same as with pyminifier.\n\nThose who managed to decompile and deobfuscate my program explained that the open-source nature of the 4 tools mentioned above means that their algorithms are well-known and there are solutions out there made to reverse-engineer programs that use these open-source compilers and obfuscators.\nWhat I didn't try yet:\n\nUsing Pyarmor to obfuscate my code. I've heard it is good, but it costs 50$, so I want to be sure that it is the best obfuscation tool out there before purchasing the license.\nUsing Cython library to create a C-wrapper for my program, making it compiled in C instead of Python. Since C binaries are much harder to read, it will make the program significantly harder to decompile. However, I have never programmed in C, and I want to know if there are better ways to compile my source Python code, without the need to learn C.\n\nWhat I am not going to try:\n\nCompletely rewrite my whole program in a language other than Python. I am not strong in other languages, plus the program itself consists of over 1,000 lines of code, so I can't just completely rewrite it for the sole purpose of making it harder to decompile.\nMaking program open-source: This is a for-profit software, so I am not going to release the proprietary code, thank you for understanding.\nMaking the program a web-app: Since my program directly interacts with files on the user's PC, I can't make it web-based, it has to be on the user's PC.\n\nPlease also consider that if \"hacker\" will be able to disable the whitelist system without even accessing the source code, he will be able to distribute it to other users with no limitation. Therefore, I am looking for a way that will not only make it extremely hard to decompile the program, but also make it almost impossible to meddle with binaries and turn off certain parts of the program's code.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":6032,"Q_Id":59117900,"Users Score":2,"Answer":"I guess I'll be the brave one to post as the answer: There is no technical means you can take to prevent software running on end user machines from being cracked.\nYou can perhaps make it more difficult, but since you've stated that in this market, people will always prefer cracked software to legit at any price, this is a situation you have essentially no hope of winning: if you have determined pirates, they will win every time.\nSo: You can't; give up\nSorry :-(","Q_Score":5,"Tags":"python,c,compilation,exe,obfuscation","A_Id":59118309,"CreationDate":"2019-11-30T16:05:00.000","Title":"Best way to protect source code of .exe program running on Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am developing proprietary software that would be distributed in a form of .exe file. In order to use it, users will have to authenticate with their whitelist credentials (username + password).\nThe issue I have encountered is that in the industry I am selling on, there are a lot of \"hackers\" who will try to decompile your executable file, get the source code and distribute it for free to other people.\nTo combat these reverse-engineering attempts, I have tried to both obfuscate my code and use various compilers, but so far to no success.\nWhat I have tried:\n\nUse py2exe compiler: \"hackers\" managed to decompile executable in an hour.\nUse pyinstaller compiler: same as with py2exe.\nUse pyminifier to obfuscate the code: \"hackers\" managed to deobfuscate the code.\nUse Oxyry Python Obfuscator: same as with pyminifier.\n\nThose who managed to decompile and deobfuscate my program explained that the open-source nature of the 4 tools mentioned above means that their algorithms are well-known and there are solutions out there made to reverse-engineer programs that use these open-source compilers and obfuscators.\nWhat I didn't try yet:\n\nUsing Pyarmor to obfuscate my code. I've heard it is good, but it costs 50$, so I want to be sure that it is the best obfuscation tool out there before purchasing the license.\nUsing Cython library to create a C-wrapper for my program, making it compiled in C instead of Python. Since C binaries are much harder to read, it will make the program significantly harder to decompile. However, I have never programmed in C, and I want to know if there are better ways to compile my source Python code, without the need to learn C.\n\nWhat I am not going to try:\n\nCompletely rewrite my whole program in a language other than Python. I am not strong in other languages, plus the program itself consists of over 1,000 lines of code, so I can't just completely rewrite it for the sole purpose of making it harder to decompile.\nMaking program open-source: This is a for-profit software, so I am not going to release the proprietary code, thank you for understanding.\nMaking the program a web-app: Since my program directly interacts with files on the user's PC, I can't make it web-based, it has to be on the user's PC.\n\nPlease also consider that if \"hacker\" will be able to disable the whitelist system without even accessing the source code, he will be able to distribute it to other users with no limitation. Therefore, I am looking for a way that will not only make it extremely hard to decompile the program, but also make it almost impossible to meddle with binaries and turn off certain parts of the program's code.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6032,"Q_Id":59117900,"Users Score":14,"Answer":"Since people in this thread did not provide any satisfiable answers, I will explain what I did to secure my program. As I mentioned previously, my goal is not to create an \"uncrackable\" program, just one that is secure enough to deter away amateurs. \nI got help on one of the reverse-engineering forums, so props to those people!\nFirstly, I used Nuitka to convert .py file into a C-based standalone executable. Then, I passed a resulting .exe file through VMProtect to obfuscate the binaries.\nI've tested it on a few CS graduates, and they weren't able to crack or deobfuscate the program, so this is good enough for me.\nP.S. Those who said that \"it is impossible\" or \"your business model is wrong\", please do not share your opinions unless you have a reverse-engineering experience, thank you :)","Q_Score":5,"Tags":"python,c,compilation,exe,obfuscation","A_Id":60162002,"CreationDate":"2019-11-30T16:05:00.000","Title":"Best way to protect source code of .exe program running on Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"while installing anaconda suite, on running i faced these errors. the first one was ConfigurationLoadError: Unable to load the configuration file. and the second was error: condarc invalid yaml\nAdditional: Conda command is also not working.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3456,"Q_Id":59120566,"Users Score":0,"Answer":"Go to the C:\\Users\\User_name and search for the file .condarc. delete it from this location.\nand then restart the anaconda navigator.","Q_Score":0,"Tags":"python,pip,anaconda,conda,navigator","A_Id":59120567,"CreationDate":"2019-11-30T21:49:00.000","Title":"Is there any Solution for error: condarc invalid yaml and ConfigurationLoadError: Unable to load configuration file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"while installing anaconda suite, on running i faced these errors. the first one was ConfigurationLoadError: Unable to load the configuration file. and the second was error: condarc invalid yaml\nAdditional: Conda command is also not working.","AnswerCount":5,"Available Count":3,"Score":-0.0399786803,"is_accepted":false,"ViewCount":3456,"Q_Id":59120566,"Users Score":-1,"Answer":"Just search for \u201c.condarc\u201d on your computer.\nThe .condarc file is frequently found in:\nmacOS: \/Users\/Username\nLinux: ~\/.condarc\nWindows: C:\\Users\\Username\nDelete the file and restart your Navigator. Worked for me","Q_Score":0,"Tags":"python,pip,anaconda,conda,navigator","A_Id":65058093,"CreationDate":"2019-11-30T21:49:00.000","Title":"Is there any Solution for error: condarc invalid yaml and ConfigurationLoadError: Unable to load configuration file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"while installing anaconda suite, on running i faced these errors. the first one was ConfigurationLoadError: Unable to load the configuration file. and the second was error: condarc invalid yaml\nAdditional: Conda command is also not working.","AnswerCount":5,"Available Count":3,"Score":-0.0399786803,"is_accepted":false,"ViewCount":3456,"Q_Id":59120566,"Users Score":-1,"Answer":"If you're using windows, search for \".condarc\" in \"...\/users\/username\" and delete all its files.\nRestart your navigator and it should be up and running immediately.","Q_Score":0,"Tags":"python,pip,anaconda,conda,navigator","A_Id":66200272,"CreationDate":"2019-11-30T21:49:00.000","Title":"Is there any Solution for error: condarc invalid yaml and ConfigurationLoadError: Unable to load configuration file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed python and google cloud sdk. I'm trying to use:\ndev_appserver.py app.yaml\nWhen I go to my directory with my web app (using cd [directory]) and enter dev_appserver.py app.yaml into the command line nothing happens. The prompt shows the next line in CMD like I didn't enter anything... I indeed have an app.yaml file and this works perfectly on my MacBook running a local server.\nI also tried just typing \"dev_appserver.py\" and hitting enter and again nothing happens... It's as if I were to press enter in the command line without typing anything.\nOn MacBook when I type dev_appsever.py without pointing to an app.yaml file - it at least shows me all the potential commands associated with dev_appserver.py. Why doesn't the windows command prompt seem to understand this command? Nor tell me it doesn't understand it? Please help!!! I really want to run a local server for cloud engine on my Windows machine, but have no idea what's wrong. I google'd a bunch and haven't found someone else with this issue...","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":234,"Q_Id":59121625,"Users Score":1,"Answer":"Finally solved my issue.... turns out goodle cloud sdk requires python 2.7. I uninstalled python 3.8, installed python 2.7. dev_appserver then didn't run unless I went into the folder where it exists: \nuser\/name\/local\/google\/cloudsdk\/bin\nAnd then I run python dev_appserver.py and it works.\nI also had to make sure my python command worked by adding it into my path. Python3.8 makes it easy to do via install wizard, but 2.7 requires you to go into your environment vars yourself to add it. This is why my python command originally did nothing.\nNot related - but my Blender 2.81 stopped working after this. I found out blender requires Python3. So I installed Python3.8 again and got both cloud sdk and blender working. Took way too many hours to solve this.... damn...","Q_Score":0,"Tags":"python","A_Id":59128906,"CreationDate":"2019-12-01T00:47:00.000","Title":"dev_appserver.py does nothing in CMD on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have installed pyreadstat using the below comment\n\"pip install pyreadstat\", \nbut when I tried to import pyreadstat it says \"ModuleNotFoundError: No module named 'pyreadstat'\"\nPlease help me to sort out this issue.\nRegards,\nRam","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":713,"Q_Id":59122424,"Users Score":0,"Answer":"I would check these things:\n\nWhen you run pip, maybe that command exited with error so pyreadstat never got installed? Do pip list to check if the library is indeed installed.\n\nMaybe you have several versions of python installed and you are using pip with one of them and later another one when trying to import pyreadstat. Check where pip is installed with \"which pip\" or \"where pip\" if on windows, and check that the python interpreter is in the same location.\n\nMaybe pyreadstat was installed in a location that is not in sys.path for some reason. When installing with pip check carefully where it was installed and then check this folder is in sys.path. IF not, include it.","Q_Score":0,"Tags":"python","A_Id":62930173,"CreationDate":"2019-12-01T04:05:00.000","Title":"Issue in reading spss file in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know in conda I can use conda env list to get a list of all conda virtual environments, what's the corresponding command in python venv that can list all the virtual environments in a given venv? also, is there any way I can print\/check the directory of current venv? somehow I have many projects that have same name .venv for their virtual environment and I'd like to find a way to verify which venv I'm in. Thanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":6383,"Q_Id":59122466,"Users Score":1,"Answer":"I'm relatively new to python venv as well. I have found that if you created your virtual environment with python -m venv <yourvenvname> with in a project folder.\nI'm using windows, using cmd, for example, you have a Dash folder located in C:\\Dash, when you created a venv called testenv by\npython -m venv testenv,\nyou can activate the virtual environment by just input\nC:\\Dash\\testenv\\Scripts\\activate,\nthen you can deactivate it by just type in deactivate.\nIf you want to list the venv that you have, you go to the C:\\Dash folder. type\ndir\nin cmd, it will list the list of the virtual env you have, similar to conda env list. if you want to delete that virtual env, simply do\nrm -rf testenv\nyou can list the packages installed within that venv by doing\npip freeze.\nI hope this helps. please correct me if I'm wrong.","Q_Score":1,"Tags":"python-3.x","A_Id":66809704,"CreationDate":"2019-12-01T04:16:00.000","Title":"what's command to list all the virtual environments in venv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know in conda I can use conda env list to get a list of all conda virtual environments, what's the corresponding command in python venv that can list all the virtual environments in a given venv? also, is there any way I can print\/check the directory of current venv? somehow I have many projects that have same name .venv for their virtual environment and I'd like to find a way to verify which venv I'm in. Thanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6383,"Q_Id":59122466,"Users Score":0,"Answer":"Virtual environments are simple a set of files in a directory on your system. You can find them the same way you would find images or documents with a certain name. For example, if you are using Linux or macOS, you could run find \/ | grep bin\/activate in terminal. Not too sure about Windows but I suspect you can search for something similar in Windows Explorer.","Q_Score":1,"Tags":"python-3.x","A_Id":62103719,"CreationDate":"2019-12-01T04:16:00.000","Title":"what's command to list all the virtual environments in venv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ive been trying for a long time different commands but i always kept getting \n\nPlease SPecify --curl....\n\nI tried installing pycurl in a terminal, but it was not working","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":59123007,"Users Score":0,"Answer":"What's the python version you are using? PycURL is only supported for specific versions.\nPython 2.7 or 3.4 through 3.6.\nOther Python versions won't be able to install PycURL via pip or easy_install , you'll have to manually compile it.","Q_Score":0,"Tags":"python,pycurl","A_Id":59512774,"CreationDate":"2019-12-01T06:13:00.000","Title":"pycurl installation issue on windows using pip and easy_install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm really new to Python and I'm trying to do a tutorial on using flask. When I run the below code:\nfrom flask import Flask\napp = Flask(__name__)\n@app.route(\"\/\")\ndef home():\n    return \"Hello, World!\"\nI get the following error message:\nTraceback (most recent call last):\n  File \"\/Users\/myname\/Documents\/PycharmProjects\/flask\/test_webapp.py\", line 1, in <module>\n    from flask import Flask\nModuleNotFoundError: No module named 'flask\nThis doesn't make any sense to me as when I run:\npython -m pip list\nFlask 1.1.1 is on the list. \nI am using Python version 3.7.4.\nI realise this questions has been asked before but after carefully reading through I can't find the correct answer. I realise this is quite basic but any help would be really appreciated!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":232,"Q_Id":59125683,"Users Score":0,"Answer":"python -m pip list answers in terms of Python 2.x\nIf you're using Python 3.x, you need to do pip3 install flask","Q_Score":0,"Tags":"python,flask","A_Id":59132946,"CreationDate":"2019-12-01T12:53:00.000","Title":"Python error loading flask: ModuleNotFoundError: No module named 'flask'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm really new to Python and I'm trying to do a tutorial on using flask. When I run the below code:\nfrom flask import Flask\napp = Flask(__name__)\n@app.route(\"\/\")\ndef home():\n    return \"Hello, World!\"\nI get the following error message:\nTraceback (most recent call last):\n  File \"\/Users\/myname\/Documents\/PycharmProjects\/flask\/test_webapp.py\", line 1, in <module>\n    from flask import Flask\nModuleNotFoundError: No module named 'flask\nThis doesn't make any sense to me as when I run:\npython -m pip list\nFlask 1.1.1 is on the list. \nI am using Python version 3.7.4.\nI realise this questions has been asked before but after carefully reading through I can't find the correct answer. I realise this is quite basic but any help would be really appreciated!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":232,"Q_Id":59125683,"Users Score":0,"Answer":"Module Flask is installed for Python 2 (Python), but not for Python 3 (Python3) that you are using.\nSo, install it as pip3 install Flask","Q_Score":0,"Tags":"python,flask","A_Id":59139113,"CreationDate":"2019-12-01T12:53:00.000","Title":"Python error loading flask: ModuleNotFoundError: No module named 'flask'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"As the question says. Can I screenshot the second screen when my script is running on the first screen?\nI mean I have the code running on my first screen and I want to capture the second screen only. How do I do it? Of course all done with ImageGrab.grab() from PIL module.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1817,"Q_Id":59128882,"Users Score":4,"Answer":"Question solved!\nPIL.ImageGrab.grab(bbox=None, include_layered_windows=False, all_screens=True)\nAnd it captures every screen.","Q_Score":0,"Tags":"python,python-3.x,python-imaging-library","A_Id":60583004,"CreationDate":"2019-12-01T18:58:00.000","Title":"ImageGrab.grab() the second screen while running code on the first screen","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have manually installed the latest version of IdleX (1.18) and it is working fine. But I cannot access it the via the command window like I would with jupyter.\nHow do I add this functionality (it is already showing up on pip list)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":59129376,"Users Score":0,"Answer":"Just found out the reason, IdleX doesn't use a .exe in the Scripts file (like jupyter does with jupyter.exe). \nInstead it uses a .py file and thus to call it from the command prompt you would write \"idlex.py\" (without the commas)","Q_Score":0,"Tags":"python,package,python-idle","A_Id":59129707,"CreationDate":"2019-12-01T19:52:00.000","Title":"IdleX in \"pip list\" but I cannot access it from command window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"im trying to install splunklib but when i used pip to install it i get this error message: \"  Could not find a version that satisfies the requirement splunklib (from versions: )\nNo matching distribution found for splunklib\"\nMy python version is 3.6.0 on a Win7\ndoes anyone know whats causing it and workaround to fix this error>","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":723,"Q_Id":59132230,"Users Score":0,"Answer":"I am able to install with \"pip install splunklib\". Since you are getting error, please post more error information along wiht Screenshots","Q_Score":0,"Tags":"python-3.x","A_Id":59137543,"CreationDate":"2019-12-02T03:15:00.000","Title":"Im using PIP to install splunklib in python but it fails","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"My goal is to import a couple third party Python packages for use with my GIMP installation. This will allow me to use these packages when developing a GIMP plugin. I noticed a few directories that may be of use. They are as follows: \nC:\\Program Files\\GIMP 2\\32\\lib\\python2.7\nThis directory contains a site-packages folder which contains packages such as requests and pip.\nC:\\Program Files\\GIMP 2\\32\\bin\nThis directory contains a python.exe. When I run python --version in an elevated cmd at this directory path, the output is Python 2.7.16, which I assume is GIMP 2.10's version of Python. This is important because I have my own installation of Python 3.8.0 in my Program Files. If I'm anywhere outside of this path in the cmd, the version that outputs is 3.8.0.\nI have added these directories to my PATH system variable and tried running pip install but the output tells me I have already installed the requested third party packages. The problem is that they are installed to my Python 3.8.0 installation. I'm trying to run pip install in the context of GIMP's Python environment. \nAny advice would be much appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":896,"Q_Id":59132514,"Users Score":0,"Answer":"Turns out the package I was trying install had dependencies that required a higher version of Python than the one GIMP comes with. Thanks to those whom responded.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,gimp,gimpfu","A_Id":59163273,"CreationDate":"2019-12-02T04:04:00.000","Title":"Trouble importing third party Python packages to GIMP 2.10 so that they can be used to write GIMP plugins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I remember when I save my files in PHP language, it didn't need to restart or reload apache web server.\nIn Python, specialy Django, If I use django webserver with runserver command,it needs to restart django if I change my files. Question is, if I use WSGI in server, Does it behave such as php or runserver command?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":59139472,"Users Score":1,"Answer":"If you modify static files or html template, you should be fine without reloading your server.\n But you will need to reload your apache server if you change any of your python files.","Q_Score":0,"Tags":"php,python,django,mod-wsgi","A_Id":59164319,"CreationDate":"2019-12-02T13:01:00.000","Title":"Does WSGI behave dynamicly?","Data Science and Machine Learning":0,"Database and SQL":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 are currently messing around with an Slamtec RPLidar A1. We have a robot with the lidar mounted on it. \nOur aim is to retrieve a x and y position in the room. (it's a closed room, could have more than 4 corners but the whole room should be recognized once (it does not matter where the RPlidar stands).\nAnyway the floormap is not given.\nWe got so far a x and y position with BreezySLAM but we recognized, wherever the RPlidar stands, it always sees itself as center, so we do not really know how to retrieve correct x and y from this information.\nWe are new to this topic and maybe someone can give us a good hint or link to find a simple solution.\nPS: We are not intending to track the movement of the robot.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":512,"Q_Id":59140697,"Users Score":0,"Answer":"Any sensor sees itself in the center of the environment. The idea of recording map is good one, if not. You can presume that any of the corners can be your zero points, you your room is not square, you can measure length of the wall and and you down to 2 points. Unfortunately if you don't have any additional markers in the environment or you can't create map before actual use, I'm afraid there is no chance for robot to correctly understand where is desired (0,0) point is.","Q_Score":0,"Tags":"python,localization,slam","A_Id":59244149,"CreationDate":"2019-12-02T14:13:00.000","Title":"Localization with RPLider (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ok so I'm working with wxPython with a friend of mine, now it just so happened that he implemented a new picture into the script and its working just fine for him. But if he sends the project to me I get the error:\n\"wx._core.wxAssertionError: C++ assertion \"strcmp(setlocale(LC_ALL, NULL), \"C\") == 0\" failed at ....\\src\\common\\intl.cpp(1579) in wxLocale::GetInfo(): You probably called setlocale() directly instead of using wxLocale and now there is a mismatch between C\/C++ and Windows locale.\nThings are going to break, please only change locale by creating wxLocale objects to avoid this!\"\nThe code in the line that breaks is the following:png2 = wx.Image(\"BlackBorder.png\", wx.BITMAP_TYPE_ANY).ConvertToBitmap() this lies inside the __init__(self) method for wxPython\nIt doesnt really tell me what is wrong I feel like so I really appreciate any help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":337,"Q_Id":59142313,"Users Score":0,"Answer":"IIRC, there are some versions of the PNG library that call setlocale in some situations. Try explicitly creating and holding a wx.Locale object at the start of your application and see if that helps.","Q_Score":0,"Tags":"python-3.x,wxpython","A_Id":59218015,"CreationDate":"2019-12-02T15:44:00.000","Title":"wxPython \"Things are going to break\" error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the performance difference between two JSON loading methods into BigQuery:\nload_table_from_file(io.StringIO(json_data) vs create_rows_json\nThe first one loads the file as a whole and the second one streams the data. Does it mean that the first method will be faster to complete, but binary, and the second one slower, but discretionary?\nAny other concerns?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":59143310,"Users Score":3,"Answer":"It's for two different logics and they have their own limits.\n\nLoad from file is great if you can have your data placed in files. A file can be up to 5TB in size. This load is free. You can query data immediately after completion. \nThe streaming insert, is great if you have your data in form of events that you can stream to BigQuery. While a streaming insert single request is limited up to 10MB, it can be super parallelized up to 1 Million rows per second, that's a big scale. Streaming rows to BigQuery has it's own cost. You can query data immediately after streaming, but for some copy and export jobs data can be available later up to 90 minutes.","Q_Score":0,"Tags":"python,google-bigquery","A_Id":59144477,"CreationDate":"2019-12-02T16:47:00.000","Title":"Performance difference in json data into BigQuery loading methods","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I quickly check what are the possible inputs to a specific function? For example, I want to plot a histogram for a data frame: df.hist(). I know I can change the bin size, so I know probably there is a way to give the desired bin size as an input to the hist() function. If instead of bins = 10 I use df.hist(bin = 10), Python obviously gives me an error and says hist does not have property bin. \nI wonder how I can quickly check what are the possible inputs to a function.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":89,"Q_Id":59144026,"Users Score":3,"Answer":"Since your question tag contains jupyter notebook I am assuming you are trying on it. So in jupyter notebook 2.0 Shift+Tab would give you function arguments.","Q_Score":0,"Tags":"python,function,input,jupyter-notebook","A_Id":59144117,"CreationDate":"2019-12-02T17:35:00.000","Title":"A function possible inputs in PYTHON","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So after installing VSCode and Python 3.7.4 (64 bit) I really struggle to make the \"python interactive\" work.\nI have installed the Python extension in VScode, also jupyter and jupyter-lab but I keep getting the error \"Exception: Jupyter command jupyter-notebook not found.\" when I try to run a cell\/a line.\nI am running Windows 10, using pip3","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":10648,"Q_Id":59147353,"Users Score":0,"Answer":"I believe you have to install anaconda first and start your notebook from an anaconda terminal.","Q_Score":4,"Tags":"python,visual-studio-code,jupyter-notebook,jupyter-lab","A_Id":59147424,"CreationDate":"2019-12-02T22:07:00.000","Title":"Exception: Jupyter command `jupyter-notebook` not found, windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So after installing VSCode and Python 3.7.4 (64 bit) I really struggle to make the \"python interactive\" work.\nI have installed the Python extension in VScode, also jupyter and jupyter-lab but I keep getting the error \"Exception: Jupyter command jupyter-notebook not found.\" when I try to run a cell\/a line.\nI am running Windows 10, using pip3","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":10648,"Q_Id":59147353,"Users Score":5,"Answer":"What did the trick was, that a few packages were outdated.\nFirstly I had to uninstall pyzmq and install it again.\nThen I ran pip3 install --upgrade nbconvert.\nI also did pip install --upgrade pywin32==224 but I think the upper two solved the problem.\nLesson learned: Never use conda\/pip together!","Q_Score":4,"Tags":"python,visual-studio-code,jupyter-notebook,jupyter-lab","A_Id":59163668,"CreationDate":"2019-12-02T22:07:00.000","Title":"Exception: Jupyter command `jupyter-notebook` not found, windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using Keras in Python to create a CNN that pumps out the angle of rotation and zoom of an image. I am working on create the training data. I have a few questions though. \nI plan on using Keras Preprocessing as the tool to manipulate before I train, but is there a way to save what angle and zoom is used so that I can use those as the trainable parameters?\nIf not, is there something easier to use?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":59148940,"Users Score":0,"Answer":"You can use the method apply_transform of the ImageDataGenerator in which you can specify the parameters of the transformation you want while for example saving these parameters in a list or another structure, using them later as features.","Q_Score":0,"Tags":"python,machine-learning,keras","A_Id":59149250,"CreationDate":"2019-12-03T01:23:00.000","Title":"Multiple Labels as Training data for ML","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to make a calculator (with matrix calculation also). I want to make interface in JavaScript and calculation stuff in Python. But I don't know how to send parameters from python to JavaScript and from JavaScript to python.\nEdit: I want to send data via JSON (if possible).","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1401,"Q_Id":59149354,"Users Score":2,"Answer":"You would have to essentially set both of them up as API's and access them via endpoints. \nFor Javascript, you can use node to set up your API endpoint, and for Python use Flask.","Q_Score":1,"Tags":"javascript,python,json","A_Id":59149367,"CreationDate":"2019-12-03T02:24:00.000","Title":"How to send data from Python script to JavaScript and vice-versa?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that other languages like Javascript have \na == and ===  operator also they have a != and !== operator does Python also has a === and !== (ie. a single operator that checks the type and compares the value at the same time like === operator) and if not how can we implement it.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":1010,"Q_Id":59150676,"Users Score":1,"Answer":"No, and you can't really implement it yourself either.\nYou can check the type of an object with type, but if you just write a function that checks type(x) is type(y) and x == y, then you get results like [1] and [1.0] showing up as equivalent. While that may fulfill the requirements you stated, I've never seen a case where this wasn't an oversight in the requirements.\nYou can try to implement your own deep type-checking comparison, but that requires you to know how to dig into every type you might have to deal with to perform the comparison. That can be done for the built-in container types, but there's no way to make it general.\nAs an aside, is looks vaguely like what you want if you don't know what is does, but it's actually something entirely different. is checks object identity, not type and value, leading to results like x = 1000; x + 1 is not 1001.","Q_Score":0,"Tags":"javascript,python,python-3.x,python-2.7","A_Id":59151066,"CreationDate":"2019-12-03T05:29:00.000","Title":"Is there any operator in Python to check and compare the type and value?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to read a file in Python, close it and then read it again from the point where I stopped reading it. \nReal problem: I'm trying to process a Tomcat log file which is updated every hour. So when I read it from Python end, I get duplicate (old) logs as well as the new ones. \nEdit: Is there an efficient way to read the new logs from the common file?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":745,"Q_Id":59151195,"Users Score":0,"Answer":"If you have an option, make the Tomcat logs rotate every one hour. You just need to read the unread file in logs directory in that case.","Q_Score":1,"Tags":"python,python-3.x,tomcat9","A_Id":59151305,"CreationDate":"2019-12-03T06:19:00.000","Title":"Is there a way to read a file from where I left off in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to read a file in Python, close it and then read it again from the point where I stopped reading it. \nReal problem: I'm trying to process a Tomcat log file which is updated every hour. So when I read it from Python end, I get duplicate (old) logs as well as the new ones. \nEdit: Is there an efficient way to read the new logs from the common file?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":745,"Q_Id":59151195,"Users Score":1,"Answer":"Before closing the file save the line number from which you left off\nUse linecache module for getting that line as current line\nHere some code you can use\n\n# import linecache module\nimport linecache\n# define the name of the file to read from\nfilename = \"test.txt\"\n# define line_number\nline_number = 3\n# retrieve specific line\nline = linecache.getline(filename, line_number)\nprint (\"line %i of %s:\" % (line_number, filename))\nprint (line)","Q_Score":1,"Tags":"python,python-3.x,tomcat9","A_Id":59151324,"CreationDate":"2019-12-03T06:19:00.000","Title":"Is there a way to read a file from where I left off in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using SQL to get data from the SalesForce API using Python. The output is written to a CSV file.\nWhen I check the CSV file, there are several null values that are written to the CSV file as \"None\".\nIs there any way to force Python not to fill null values with None, or an option to treat nulls as empty strings instead of None.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":91,"Q_Id":59155586,"Users Score":-1,"Answer":"I'd suggest using pandas to read the CSV before writing and .fillna() as a way to replace all the None values.","Q_Score":0,"Tags":"python","A_Id":59155878,"CreationDate":"2019-12-03T11:00:00.000","Title":"How to force Python not to fill with None","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've defined a Django model which makes use of FilePathField(allow_files=False, allow_folders=True) which shall allow to define a required (not optional) file system directory in the model. If I try to add a new model in the admin interface I get a file not found error. All my other models registered the same way are just working fine. If I'd use CharField() instead of FilePathField() to hold the file system directory path I'd simply define a default value like CharField(default='').\nHow can I fix the model making use of the FilePathField field?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":378,"Q_Id":59158671,"Users Score":2,"Answer":"I have encountered same problem and the cause of the error is that django tries to scan the directory in order to get list of files that will be displayed as choices in html widget.\nThere are few solutions.\n\nIf you don't mind limiting what paths can be added by users just add path=\/some\/dir to FilePathField\nIf you don't want to limit paths but don't care about ability to update path trough admin just set editable=False in FilePathField\nIf you want both  you can replace widget in admin for this particular field to classic text input.","Q_Score":1,"Tags":"django,python-3.x,django-models","A_Id":66444575,"CreationDate":"2019-12-03T13:53:00.000","Title":"Django FilePathField raises file not found error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Trying to figure out why Pyinstaller does not make the .EXE in the \\Dist folder.\nWhat i'm running is pyinstaller --onefile FileName.py\nBut after this it fails:\n\n7758 INFO: Building PYZ (ZlibArchive) An error occurred, traceback follows:\n  Traceback (most recent call last):\n    File \"c:\\users\\marcu\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\auto_py_to_exe__main__.py\", line 269, in convert\n      pyi.run() # Execute PyInstaller\n    File \"c:\\users\\marcu\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller__main__.py\", line 111, in run\n      run_build(pyi_config, spec_file, **vars(args))\n    File \"c:\\users\\marcu\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller__main__.py\", line 63, in run_build\n      PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)\n    File \"c:\\users\\marcu\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\building\\build_main.py\", line 844, in main\n      build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))\n    File \"c:\\users\\marcu\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\building\\build_main.py\", line 791, in build\n      exec(code, spec_namespace)\n    File \"C:\\Users\\Marcu\\AppData\\Local\\Temp\\tmp2gf7vp4s\\File_Rename.spec\", line 18, in \n      pyz = PYZ(a.pure, a.zipped_data,\n    File \"c:\\users\\marcu\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\building\\api.py\", line 98, in init\n      self.postinit()\n    File \"c:\\users\\marcu\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\building\\datastruct.py\", line 158, in postinit\n      self.assemble()\n    File \"c:\\users\\marcu\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\building\\api.py\", line 128, in assemble\n      self.code_dict = {\n    File \"c:\\users\\marcu\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\building\\api.py\", line 129, in \n      key: strip_paths_in_code(code)\n    File \"c:\\users\\marcu\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\building\\utils.py\", line 652, in strip_paths_in_code\n      consts = tuple(\n    File \"c:\\users\\marcu\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\building\\utils.py\", line 653, in \n      strip_paths_in_code(const_co, new_filename)\n    File \"c:\\users\\marcu\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\building\\utils.py\", line 660, in strip_paths_in_code\n      return code_func(co.co_argcount, co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize,\n  TypeError: an integer is required (got type bytes)\n\nAnd so on.\n\nPath is set\nNewest versions\nScript is working as intended when run through Python\n\nThe idea is to make the .py an .exe so i can run it on a computer that does not have Python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1186,"Q_Id":59159180,"Users Score":1,"Answer":"I Found the answer.\nBy using pip install https:\/\/github.com\/pyinstaller\/pyinstaller\/archive\/develop.zip\nit uninstalled the version 3.5 and installed the 4.0 dev version.\nUsed pyinstaller xxxx.py and voil\u00e0\nThank you for everyone's participation","Q_Score":0,"Tags":"python,pip,exe,pyinstaller","A_Id":59189768,"CreationDate":"2019-12-03T14:20:00.000","Title":"Python Py to EXE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a tabular pytorch model that takes in cities and zipcodes as a categorical embeddings.  However, I can't stratify effectively based on those columns. \nHow can I get pytorch to run if it's missing a categorical value in the test set that's not in the train set, or has a categorical value in the holdout set that was not in the train\/test set?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":59159578,"Users Score":0,"Answer":"u can try to use one hot encoding instead\nPS: this is a suggestion not an answer","Q_Score":0,"Tags":"python,pytorch","A_Id":59160973,"CreationDate":"2019-12-03T14:42:00.000","Title":"How to deal with different categories in pytorch train, test, and holdout set","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script that computes 1000 integrals of a function defined in the script.\nThis is fairly long to run, so I want to start the script again with another function before the first script finished running.\nCan these simultaneous runs with different arguments interfere?\nOr is the code compiled once, and then the script can be modified while running?\nThanks a lot for your answer!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":204,"Q_Id":59160269,"Users Score":1,"Answer":"Can these simultaneous runs with different arguments interfere?\n\nNo.\n\nOr is the code compiled once, and then the script can be modified while running?\n\nYes.\nSource code is usually only relevant for things like debugging and tracebacks, it's forgotten once a file has been imported or started running.","Q_Score":1,"Tags":"python,compilation,simultaneous","A_Id":59160339,"CreationDate":"2019-12-03T15:22:00.000","Title":"Run same script with two different arguments simultaneously","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a lot of strings in a pandas dataframe, I want to assign every string a number for keras.\nthe string represent a location:\nCwmyNiVcURtyAf+o\/6wbAg==\nI want to turn it into a number and back again. I'm using keras, tensorflow and pandas. Does one of the modules contain a function which does that? Or do I have to write a hashtable?\nLike this:\nCwmyNiVcURtyAf+o\/6wbAg== => 1\nCwmyUSVcbBtiBQEkAN4bVbA= =>  2\nCwmypSVdCRNYBv4MAFUTSRY= =>  3\nCwnBoiVCjRNPBAAJ\/ysTHw== =>  4\nCwnBoiVCjRNfBv5QAEITCA== =>  5\nCwmyUSVcbBtiBQEkAN4bVbA= =>  2\nI have ~8000 locations and each location is 15 times in the Dataframe","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":373,"Q_Id":59160301,"Users Score":2,"Answer":"You should consider a one-hot encoding, which can be done easily with pandas via the get_dummies function. This will create binary columns for each \"category\" (i.e. unique string).","Q_Score":0,"Tags":"python,pandas,keras","A_Id":59160453,"CreationDate":"2019-12-03T15:24:00.000","Title":"Is there a function to convert a string into a number and back for machine learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on azure from past few months, and everything was working fine, and now I'm having issues, I cant import automlconfig and automlrun from azureml.train.automl. I have tried all possible solutions, even azure jupyter-vm which by default must have all these libraries but no success yet. I cant find this issue on there forums, any help or advice would be great.\nerror text:- (cannot import name 'AutoMLConfig',cannot import name 'AutoMLrun')","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":59162580,"Users Score":0,"Answer":"Could you please try following steps to see if it helps or not?\n\nCompletely uninstalled conda and reinstalled \nBuilt the azure_automl env using azure_automl.cmd \nGot from azureml.train.automl import AutoMLConfig to work.\n\nPlease let me know if you still have problem.\nRegards,\nYutong","Q_Score":0,"Tags":"python,azure,automl","A_Id":59164719,"CreationDate":"2019-12-03T17:39:00.000","Title":"Python can't find automlconfig and automlrun","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a cgi script to run on a server, and when I put #!\/bin\/python3 at the top of the file it works fine. The problem is that on my local machine, my Python installation is in \/opt\/local\/bin\/python (and macOS does not allow symlinks in \/bin. So to run the script on my local machine, I need to manually change the path in each cgi file, which is cumbersome.\nIs there a better way to specify my Python path (something like \"try this path first else try this path?\")","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":59162982,"Users Score":0,"Answer":"You can let your system environment choose the path using #!\/usr\/bin\/env python3","Q_Score":0,"Tags":"python,cgi","A_Id":59163022,"CreationDate":"2019-12-03T18:06:00.000","Title":"Specify Python location in 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need all video's ID between X to Y dates of specific subject. I used YouTube data API v3 and every thing was OK, until it returned empty item after 1000 result. I searched about this issue and figured out it's API limitation!!! Does anyone have any solution?\nIf it helps I code in python.I did test in php too and same result. It doesn't depend on languages.\nthanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":142,"Q_Id":59165991,"Users Score":0,"Answer":"Just split your date range into multiple requests, so each request < result limit.","Q_Score":0,"Tags":"python,youtube-api","A_Id":59167151,"CreationDate":"2019-12-03T21:58:00.000","Title":"How to Cross the 1000 Results Limit of youtube data API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using sqlite3 via sqlalchemy package in Python 3.7. The SQLite database file is stored on a USB 2.0 flash drive, plugged in a MacBook Pro.\nEven though many times I don't have problems, but sometimes I see a write operation (for example, a transaction of updating 2 tables in a commit) would be very slow, e.g. 8 seconds. This happens frequent enough that I have to debug it.  In good times, the same operation takes less than 0.5 second.\nMy question is: how can I distinguish where this slowness is in sqlalchemy or in sqlite3 or just the USB driver itself? I was not able to find an existing post with such problem.\n(I was wondering if I should replace USB 2.0 drive with USB 3.0 drive, maybe because USB 2.0 is half-duplex? But I'm not sure and wanted to see if any way to confirm).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":59167216,"Users Score":0,"Answer":"Finally I went out and bought a USB 3.1 drive (SanDisk), so with nothing else changed,  the performance is greatly improved:  the max latency is reduced from 12 seconds to 0.25 second. Looks like USB 2.0 drive was the main cause of the slowness. (Sqlite3 WAL mode helped a bit too). Thanks for comments from @Shawn and @Selcuk.","Q_Score":0,"Tags":"python,sqlite,sqlalchemy,usb-drive","A_Id":59183169,"CreationDate":"2019-12-04T00:12:00.000","Title":"sqlite3 via sqlalchemy write operation is slow on USB drive","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way of using pip to install an application instead of packages?  I like how easy it is to update\/install\/remove python packages. But I'm wondering if it's the right tool for having users download a python app that runs out of $HOME\/bin (or \/usr\/bin\/) instead of installing it like a python library.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":196,"Q_Id":59168112,"Users Score":1,"Answer":"It really depends on what you mean by application. But if your goal is to run a script without specifying it's precise location, then that's possible. You can do that in at least two ways:\n\nAfter you install some app via pip, you can create links from your preferred bin directory to the entry point where the app is installed. For example link \/usr\/bin\/the_app to \/opt\/long\/path\/.venv\/bin\/the_app.\nInstall in a common location which you add to your shell's PATH. If you don't necessarily care for full separation between apps, this can be easily achieved by installing them via pip install --user the_app, which will use some local path like $HOME\/.local\/bin or $HOME\/Library\/Python\/3.7\/bin or something else. (depending on your system)\n\nWhich way to go depends on whether this is a shared system, or you're the only user and some other constraints. Neither is wrong, but one may be more convenient.\nFor safety, I'd recommend solution 1. It's nice to have isolation between apps so dependencies don't conflict.","Q_Score":0,"Tags":"python,pip","A_Id":59168197,"CreationDate":"2019-12-04T02:29:00.000","Title":"Using pip to install application instead of packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to install jupyter notebook but error occurred and is \"Microsoft Visual C++ 14.0 is required\". And i already have Visual 2015-2019 installed on my PC and I am unable to find setup of Visual C++ 2014 particularly. Please assist how it can be resolved.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1219,"Q_Id":59170285,"Users Score":0,"Answer":"Are you installing it with Anaconda? I've had similar issues where I unknowingly try to install the old version of a package, and it asked me to have Microsoft Visual C++ 14. But I was able to fix it by finding an updated, compatible version of the same package. So maybe Anaconda would give you the latest version of Jupyter Notebook that works for you.","Q_Score":0,"Tags":"python,windows,visual-c++,jupyter-notebook","A_Id":59443356,"CreationDate":"2019-12-04T06:42:00.000","Title":"Getting error Microsoft Visual C++ 14.0 is required, but already have Microsoft Visual C++ 15-19 installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Everyone talks about advantages using generators in Python. It's really cool and useful thing. But no one speaks about their disadvantages. And interviewers usually use this gap. \nSo is there any other disadvantage of using generators besides these two?\n\nFor the generator's work, you need to keep in memory the variables of the generator function.\nEvery time you want to reuse the elements in a collection it must be regenerated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":971,"Q_Id":59172406,"Users Score":8,"Answer":"For the generator's work, you need to keep in memory the variables of the generator function.\n\n\nBut you don't have to keep the entire collection in memory, so usually this is EXACTLY the trade-off you want to make.\n\n\nEvery time you want to reuse the elements in a collection it must be regenerated.\n\n\nThe generator must be recreated, but the collection does not need to be though. So this may not be a problem.\nEssentially it boils down to a discussion about Lazy vs Eager evaluation. You trade-off CPU overhead for the capability of streaming processing (as opposed to bulk-processing with eager evaluation). The code can become a bit more tricky to read if using a lazy approach, so there could be a trade-off between performance and simplicity there as well.","Q_Score":4,"Tags":"python,generator","A_Id":59172592,"CreationDate":"2019-12-04T09:10:00.000","Title":"Disadvantages of Python generators?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some 360 odd features on which I am training my neural network model.\nThe accuracy I am getting is abysmally bad. There is one feature amongst the 360 that is more important than the others.\nRight now, it does not enjoy any special status amongst the other features.\nIs there a way to lay emphasis on one of the features while training the model? I believe this could improve my model's accuracy.\nI am using Python 3.5 with Keras and Scikit-learn.\nEDIT: I am attempting a regression problem\nAny help would be appreciated","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":59172607,"Users Score":0,"Answer":"First of all, I would make sure that this feature alone has a decent prediction probability, but I am assuming that you already made sure of it.\nThen, one approach that you could take, is to \"embed\" your 359 other features in a first layer, and only feed in your special feature once you have compressed the remaining information.\nContrary to what most tutorials make you believe, you do not have to add in all features already in the first layer, but can technically insert them at any point in time (or even multiple times).\nThe first layer that captures your other inputs is then some form of \"PCA approximator\", where you are embedding a high-dimensional feature space (359 dimensions) into something that is less dominant over your other feature (maybe 20-50 dimensions as a starting point?)\nOf course there is no guarantee that this will work, but you might have a much better chance of getting attention on your special feature, although I am fairly certain that in general you should still see an increase in performance if the single feature is strongly enough correlated with your output.\nThe other question that is still open is the kind of task you are training for, i.e., whether you are doing some form of classification (if so, how many classes?), or regression. This might also influence architectural choices, and the amount of focus you can\/should put on a single feature.","Q_Score":0,"Tags":"python-3.x,machine-learning,scikit-learn,neural-network,hyperparameters","A_Id":59172700,"CreationDate":"2019-12-04T09:22:00.000","Title":"Emphasis on a feature while training a vanilla nn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Basically i am trying to do text summarize using spacy and nltk in python. Now i want to summarize the normal 6-7 lines text and show the summarized text on the localhost:xxxx so whenever i run that python file it will show on the localhost. \nCan anyone tell is it possible or not and if it is possible how to do this. Since there would be no databse involved.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":156,"Q_Id":59175063,"Users Score":0,"Answer":"You have to create a RESTFUL Api using FLASK or DJAngo with some UI elements and call your model. Also you can use displacy( Spacy UI Bro) Directly on your system.","Q_Score":1,"Tags":"python,spacy","A_Id":59175275,"CreationDate":"2019-12-04T11:32:00.000","Title":"Using python and spacy text summarization","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset where each row represents the number of occurrences of certain behaviour. The columns represent a window of a set amount of time. It looks like this:\n\n+----------+----------+----------+----------+-----------+------+\n| Episode1 | Episode2 | Episode3 | Episode4 |  Episode5 |  ... |\n+----------+----------+----------+----------+-----------+------+\n|        2 |        0 |        1 |        3 |           |      |\n|        1 |        2 |        4 |        2 |         3 |      |\n|        0 |          |          |          |           |      |\n+----------+----------+----------+----------+-----------+------+\n\nThere are over 150 episodes. I want to find a way to represent each row as a trend, whether the occurrences are exhibiting more\/less.\nI have tried to first calculate the average\/median\/sum of every 3\/5\/10 cells of each row (because each row has different length and many 0 values), and use these to correlate with a horizontal line (which represent the time), the coefficients of these correlations should tell the trend (<0 means downward, >0 upward). The trends will be used in further analysis.\nI'm wondering if there is a better way to do this. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":192,"Q_Id":59180323,"Users Score":1,"Answer":"If you expect the trend to be linear, you could fit a linear regression to each row separately, using time to predict number of occurences of a behavior. Then store the slopes.\nThis slope represents the effect of increasing time by 1 episode on the behavior. It also naturally accounts for the difference in length of the time series.","Q_Score":1,"Tags":"python,pandas,math,regression,data-science","A_Id":59182082,"CreationDate":"2019-12-04T16:14:00.000","Title":"How to represent the trend (upward\/downward\/no change) of data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"On the  Linux Mint O.S. I used pip to install the CherryPy module.  However it installed it under python2.7 in :\n\n\/home\/jacslim\/.local\/lib\/python2.7\/site-packages\/cherrypy\n\nrather than under Python 3.6 which I found in \/usr\/bin\/python3.6,\n  I tried again in the Pyton3.6 directory but the same thing happened.\nIs there anyway I can direct pip to use the latest version of the Python interpreter?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":59180681,"Users Score":2,"Answer":"Use pip3 install to install for python 3","Q_Score":1,"Tags":"python,cherrypy,linux-mint","A_Id":59180744,"CreationDate":"2019-12-04T16:34:00.000","Title":"pip installs python library under wrong version of python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Fatal error in launcher: Unable to create process using '\"c:\\users\\owner\\appdata\\local\\programs\\python\\python37-32\\python.exe\"  \"C:\\Python37-32\\Scripts\\pip.exe\" install pygame'\nI have been trying to use pip installations in command prompt for the past while now and keep getting this issue. the first file location now no longer exists. Can anyone help me with this problem please ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6713,"Q_Id":59182083,"Users Score":0,"Answer":"Uninstall your current python and its launcher from control penal\nThen download new python version and install it\n\nWhile installing new one make sure you tick Add Launcher to all users(recommended) and ADD python to PATH both.\n\nNow click customized install and tick all the boxes and install it\n\nAfter install complete open powershell or cmd and type python to check it is\ninstalled properly if you see:\nPS C:\\Users\\Rohit> python\nPython 3.10.0 (tags\/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\n\n\n\n\nexit()\n\n\n\ntype exit() for quit python\nThis that means successfully installed\n4.Now let's type pip + ENTER\nif you see multiple pip commands congratulations your good to go\n5.Okay then try to install your required python library\ne.g : pip install pyttsx\nPS C:\\Users\\Rohit> pip install pyttsx3\nDefaulting to user installation because normal site-packages is not writeable\nCollecting pyttsx3\nUsing cached pyttsx3-2.90-py3-none-any.whl (39 kB)\nCollecting pywin32\nUsing cached pywin32-302-cp310-cp310-win_amd64.whl (9.2 MB)\nCollecting pypiwin32\nUsing cached pypiwin32-223-py3-none-any.whl (1.7 kB)\nCollecting comtypes\nUsing cached comtypes-1.1.10.tar.gz (145 kB)\nUsing legacy 'setup.py install' for comtypes, since package 'wheel' is not installed.\nInstalling collected packages: pywin32, pypiwin32, comtypes, pyttsx3\nIf your see this kind of stuff, your problem is solved.\nNOTE : In case it not solved go to Microsoft store and install python and launch it. Then press windows button and search for edit environment variable >> environment variable. Check if python is added to the PATH if not then add it.","Q_Score":1,"Tags":"python,command-prompt","A_Id":69690953,"CreationDate":"2019-12-04T17:53:00.000","Title":"Fatal error in launcher: Unable to create process using pip.exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been trying to infer a timeliness score (a score based on patients' waiting times) from patients' reviews in hospitals. The data available is patients' reviews and their ratings of the overall experience. The problem is I don't have labels for the timeliness scores of the patients but a rating of the whole experience.\nreviews like 'I have waited for a very long time but the experience was worth it' which has a good context with a good rating should return a somewhat bad timeliness score, same thing for 'The wait was short but it does not justify the bad service'. So the context\/ feeling of the person writing the review also matters. \nI've cleaned the reviews and took the part of the sentences that is relevant to the waiting time(if it exists) and used libraries like TextBlob or VaderSentiment to infer if the sentiment of the patient is positive or not. The problem with that is I had 20% of the cases where I got different results from different libraries and they do not always make the most sense (reviews that have long waiting times but within a good context return a good waiting time but it should at least be neutral ).\nI need some sort of way where I can correlate the context of the sentence and the actual rating to how much time they spent waiting and come up with a score, a sort of sentiment analysis that takes into account the whole sentence but looks for a specific context of talking about waiting time.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":59182579,"Users Score":0,"Answer":"A helpful solution would be:\n\nApplying Semantic Role Labeling in the given corpus to find your highlighted features\nUsing word embedding techniques like Word2Vec-SkipGram with negative sampling\n\n(Idea: the same words occur in the same contexts, so\n  it doesn't need to recalculate the similarities.)\n\nFind the sentiment of a feature by surrounded words (window size).\n\nNote: Using Sentiment dictionaries like SentiWordNet might help\n  you.\n\nDefine a method to get the overall aspect-level (highlighted features) sentiment analysis.\n\nE.g. In binary classification:\n  aggregation of pos\/neg polarities divide to number of features in a sentence\n\nTrain your model","Q_Score":0,"Tags":"python,machine-learning,nlp,unsupervised-learning","A_Id":59187494,"CreationDate":"2019-12-04T18:27:00.000","Title":"Sentiment analysis for waiting times in hospitals","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been teaching myself Python to automate some of our work processes. So far reading from Excel files (.xls, .xlsx) has gone great.\nCurrently I have hit a bit of a snag. Although I can output .xlsx files fine, the software system that we have to use for our primary work task can only take .xls files as an input - it cannot handle .xlsx files, and the vendor sees no reason to add .xlsx support at any point in the foreseeable future.\nWhen I try to output a .xls file using either Pandas or OpenPyXl, and open that file in Excel, I get a warning that the file format and extension of the file do not match, which leads me to think that attempting to open this file using our software could lead to some pretty unexpected consequences (because it's actually a .xlsx file, just not named as such)\nI've tried to search for how to fix this all on Google, but all I can find are guides for how to convert a .xls file to a .xlsx file (which is almost the opposite of what I need). So I was wondering if anybody could please help me on whether this can be achieved, and if it can, how.\nThank you very much for your time","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2236,"Q_Id":59187722,"Users Score":0,"Answer":"Felipe is right the filename extension will set the engine parameter.\nSo basically all it's saying is that the old Excel format \".xls\" extension is no longer supported in Pandas. So if you specify the output spreadsheet with the \".xlsx\" extension the warning message disappears.","Q_Score":2,"Tags":"python,excel,pandas,openpyxl,xls","A_Id":69641984,"CreationDate":"2019-12-05T03:19:00.000","Title":"Outputting A .xls File In Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am dealing with different datasets that have only Categorical variables\/features with only two values such as (temperature = 'low' and 'high') or (light = 'on' and 'off' or '0' and '1'). \nI am not really sure whether to use \"one-hot encoding\" or \"Label Encoding\" method to train my models. \nI am working on a classification problem and using some supervised machine learning algorithms. \nI used \"Label Encoding\" and I got a pretty good result. I feel there could be something that I did was wrong. I am not sure if I should use \"one-hot encoding\" or not.\nIn case of Categorical variables with only two values which method should I use to convert the variables?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":239,"Q_Id":59188318,"Users Score":0,"Answer":"There are only a few cases where LabelEncoder is useful because of the ordinality issue. If your categorial features are ordinal then use LabelEncoder otherwise use One-hot encoding. But, One-hot encoding increases dimension. In this case, I typically employ One-hot encoding followed by PCA for dimensionality reduction.","Q_Score":0,"Tags":"python-3.x,encoding,categorical-data,one-hot-encoding,labeling","A_Id":59188878,"CreationDate":"2019-12-05T04:34:00.000","Title":"Categorical variables with only two values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently I am working in big firm where we need to convert python2 old big Django project into python3 version so I have done lots of research related but still not able to find any perfect answer related to which version of Python and Django best suited for conversion.\nCurrently I am using Python : 2.7.16 & Django : 1.9.13 in my old version.\nAnyone can suggest me best suited version of Python & Django for above old version for python2 to python3 conversion.","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":1922,"Q_Id":59188902,"Users Score":2,"Answer":"I have same kind of issue with my project and I have tried python 3.7.5 with Django version 2.2.7.\nYou should not go with python latest version 3.8 or Django latest version 3.0 because you there may have been chances that for any kind of bug you may not able to get proper solution for latest versions.","Q_Score":11,"Tags":"python,django,python-3.x,python-2to3","A_Id":59583539,"CreationDate":"2019-12-05T05:38:00.000","Title":"For Python2 to Python3 code conversion, Which version of Python & Django best suited?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Currently I am working in big firm where we need to convert python2 old big Django project into python3 version so I have done lots of research related but still not able to find any perfect answer related to which version of Python and Django best suited for conversion.\nCurrently I am using Python : 2.7.16 & Django : 1.9.13 in my old version.\nAnyone can suggest me best suited version of Python & Django for above old version for python2 to python3 conversion.","AnswerCount":5,"Available Count":2,"Score":-0.0798297691,"is_accepted":false,"ViewCount":1922,"Q_Id":59188902,"Users Score":-2,"Answer":"You should try to shoot for the current versions. Python 3.8 and Django 3.0.The Six library will help with some convention changes. Either way you are going to have to do some refactoring so you might as well make it current.","Q_Score":11,"Tags":"python,django,python-3.x,python-2to3","A_Id":59189020,"CreationDate":"2019-12-05T05:38:00.000","Title":"For Python2 to Python3 code conversion, Which version of Python & Django best suited?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Given an array of integers, I need to reduce it to a single number by repeatedly replacing any two numbers with their difference, to produce the maximum possible result.\nExample1 - If I have array of [0,-1,-1,-1] then performing (0-(-1)) then (1-(-1)) and then (2-(-1)) will give 3 as maximum possible output\nExample2- [3,2,1,1] we can get maximum output as 5 { first (1-1) then (0-2) then (3-(-2)}\nCan someone tell me how to solve this question?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":59189207,"Users Score":0,"Answer":"The other answers are fine, but here's another way to think about it:\nIf you expand the result into individual terms, you want all the positive numbers to end up as additive terms, and all the negative numbers to end up as subtractive terms.\nIf you have both signs available, then this is easy:\n\nSubtract all but one of the positive numbers from a negative number\nSubtract all of the negative numbers from the remaining positive number\n\nIf all your numbers have the same sign, then pick the one with the smallest absolute value at treat it as having the opposite sign in the above procedure.  That works out to:\n\nIf you have only negative numbers, then subtract them all from the least negative one; or\nIf you have only positive numbers, then subtract all but one from the smallest, and then subtract the result from the remaining one.","Q_Score":3,"Tags":"python,arrays,algorithm","A_Id":59196692,"CreationDate":"2019-12-05T06:08:00.000","Title":"Find the maximum result after collapsing an array with subtractions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Locust and I am testing a website with different users. \nHow can I end end a user task ?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1398,"Q_Id":59190655,"Users Score":2,"Answer":"I'm not sure exactly what you are after, but you can stop a user\/locust by doing raise StopLocust()","Q_Score":1,"Tags":"python,testing,load-testing,locust","A_Id":59198017,"CreationDate":"2019-12-05T08:03:00.000","Title":"how can I terminate a specific thread in locust load-test","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Locust and I am testing a website with different users. \nHow can I end end a user task ?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1398,"Q_Id":59190655,"Users Score":0,"Answer":"If you are using the web version of locust, then to stop locust, you need to manually click on the Stop Button. OR you can call the on_stop\nmethod in locust after desired number of users.\nIf you are using the non-web option, then you can use the timeout option in the locust command:\nlocust -f --no-web -c 1000 -r 100 --run-time 1h30m\nThe locust will stop after the specified amount of time","Q_Score":1,"Tags":"python,testing,load-testing,locust","A_Id":59611483,"CreationDate":"2019-12-05T08:03:00.000","Title":"how can I terminate a specific thread in locust load-test","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"while trying to update the anaconda. I am getting the following error.\nI tried to update also, its not working.\nHow to fix this python error.\nCorruptedEnvironmentError: The target environment has been corrupted. Corrupted environments most commonly\noccur when the conda process is force-terminated while in an unlink-link\ntransaction.\n  environment location: D:\\vivek\\Learning\\Anaconda\n  corrupted file: D:\\vivek\\Learning\\Anaconda\\conda-meta\\python-3.7.1-h33f27b4_4.json","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":709,"Q_Id":59191647,"Users Score":0,"Answer":"Follow the steps below:\n\n\nRemove all the packages that are corrupt.\nTry to install them again(only using conda).\nUpdate your Conda and python if needed.\nTry again with different versions if needed.\n\nExtra step: If you have a new conda environment and you find the error is because of some installing issues then try installing Conda again.\n\nThis will fix all the errors","Q_Score":0,"Tags":"python,anaconda","A_Id":59192229,"CreationDate":"2019-12-05T09:09:00.000","Title":"Not able to update anaconda -Error Corrupted Environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having some struggles how does exactly django.admin.LogEntry objects are created.\nConsider the following scenario:\nI have a bunch of functions which take a csv file with data that allow me to create multiple objects at one call (just iterate through the file, use the data and if data in given row is correct: create a Model instance). I want to make sure that that each of that creation will be logged.\nThe question is: django docs are not very descriptive on how does LogEntry works and I am not sure if such actions (not taken in the admin panel itself) will be logged there. Also: will the LogEntries be created for the related objects or I have to trigger them manually?\nDoes anybody got any experience with such scenarios and can share thoughts about it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1032,"Q_Id":59191936,"Users Score":1,"Answer":"The LogEntry model is in the Admin package and only used by Django admin by default. It is used in the admin layer and not model layer when saving objects. if you want to use it outside the admin, then you will have to manually create the entries yourself. That also means the admin will likely display entries of changes made by normal users so you have to think about how you want the entries displayed","Q_Score":0,"Tags":"django,python-2.7,django-models,django-admin,django-1.11","A_Id":59192031,"CreationDate":"2019-12-05T09:28:00.000","Title":"Django Admin LogEntry: how it works in non admin actions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"SHAP values seem to be additive and e.g. the overall feature importance plot simply adds the absolute SHAP values per feature and compares them.  This allows us to use SHAP for global importance aswell as local importance. We could also get feature importance for a particular subset of data records the same way.  \nBy the same token, is it valid to get aggregate SHAP values for sets of variables? e.g. \"Height\", \"Weight\" and \"Eye Colour\" into \"HumanDescription\" or \"Temperature\", \"Humidity\" and \"Air-Pressure\" into \"Weather\"and rank them accordingly.\nTheoretically, I can't see why not but would appreciate feedback on this in case of any gotchas.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":1514,"Q_Id":59193277,"Users Score":4,"Answer":"From Lundberg, package author: \"The short answer is yes, you can add up SHAP values across the columns to get the importance of a whole group of features (just make sure you don't take the absolute value like we do when going across rows for global feature importance).\nThe long answer is that when Shapley values \"fairly\" allocate credit for interaction effects between features, they assume each feature in an interaction effect should get equal credit for the interaction. This means that for high order interaction terms you might get slightly different results when running Shapley values before (and summing) vs. after grouping features (since the new group just gets one chunk of the interaction pie so to speak, as opposed to multiple chunks when it was several features). These differences are typically small though so I wouldn't sweat it much since both ways are reasonable.\"","Q_Score":2,"Tags":"python,shap","A_Id":59281571,"CreationDate":"2019-12-05T10:37:00.000","Title":"Is it Valid to Aggregate SHAP values to Sets of of Features?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a project written in python2. Suppose if I want to deploy my project after the end of life of python2 support, am I able to pull specific versions of specific packages?\nFor example, I am using boto3==1.4.7 version. So, am I able to pull the same version of the package after python2 support ends?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":25,"Q_Id":59193941,"Users Score":1,"Answer":"That should be possible, but it is better to port your Project to Python 3 and use the newest versions of the packages.","Q_Score":0,"Tags":"python,boto3","A_Id":59194000,"CreationDate":"2019-12-05T11:17:00.000","Title":"Can I pull python2 packages after support for python2 ends","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Polygon (shapely) and the centroid of this Polygon (with longitude and latitude). Is there any way to count radius of the Polygon?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1145,"Q_Id":59195515,"Users Score":1,"Answer":"There are two cases:\n\nYou have a regular polygon, meaning all sides are equally long and the angles between sides is constant throughout the polygon. In this case you draw the smallest circle that touches all corner points of the polygon. The radius of this circle is said to also be the radius of your polygon.\nFor an irregular polygon it is a bit harder to get a grasp on the radius. Similar to the case above you could take the radius of the smallest circle in which the polygon fits.","Q_Score":0,"Tags":"python,polygon,shapely","A_Id":59195933,"CreationDate":"2019-12-05T12:46:00.000","Title":"How to count a radius of a polygon","Data Science and Machine Learning":0,"Database and SQL":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":"Models and Bounded-Context conceptually are:\nModel:\n\nA system of abstractions that describes selected aspects of a domain\n  and can be used to solve problems related to that domain.\n\nBounded-Context: \n\nThe setting in which a word or statement appears that determines its\n  meaning.\n\nBut I have to questions:\n\nIs the relationship between the two is containment relationship,\ni.e. Bounded-Context has one or more models?\nAs I understand DDD concepts should be identifiable (to some degree) through the codebase, this is clear for Aggregate, Entities, Event, Commands...etc, but how Models and Bounded-Context are mapped into the codebase? for example is a models just a set of one or more aggregates, or something else? is Bounded-context a namespace or something else?\n\nThanks in advance.\nNote: Feel free to state your answer in term of some framework, Django, Axon..etc.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":364,"Q_Id":59196817,"Users Score":0,"Answer":"This is based on my understanding of course... opinions may vary.\n\n\nModel is not one thing in your code but if done well, it is the code. It is what you come up with from the knowledge crunch of the business and try and capture in code. Coming up with one model for the whole business is usually a fool errand. So you have a context that the model is valid in...\nA bounded context is a context that a model is valid. This is valuable for a few reasons. It allows us to manage the scope and complexity of a model. A model is only useful insomuch as it helps us solve business problems. To do this we need to be able to keep some form of it in our heads so we can understand. This is where language comes in. The language, aggregates, etc. are valid for that context. I like to use an example here. A product in an eCommerce checkout is different from a product being picked from a warehouse. They may share some concepts but some are not relevant across contexts. How they relate should be captured in a context map.","Q_Score":0,"Tags":"python,domain-driven-design,implementation","A_Id":59203523,"CreationDate":"2019-12-05T13:59:00.000","Title":"How Models and Bounded-Contexts are mapped into the codebase DDD?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Models and Bounded-Context conceptually are:\nModel:\n\nA system of abstractions that describes selected aspects of a domain\n  and can be used to solve problems related to that domain.\n\nBounded-Context: \n\nThe setting in which a word or statement appears that determines its\n  meaning.\n\nBut I have to questions:\n\nIs the relationship between the two is containment relationship,\ni.e. Bounded-Context has one or more models?\nAs I understand DDD concepts should be identifiable (to some degree) through the codebase, this is clear for Aggregate, Entities, Event, Commands...etc, but how Models and Bounded-Context are mapped into the codebase? for example is a models just a set of one or more aggregates, or something else? is Bounded-context a namespace or something else?\n\nThanks in advance.\nNote: Feel free to state your answer in term of some framework, Django, Axon..etc.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":364,"Q_Id":59196817,"Users Score":2,"Answer":"Is the relationship between the two is containment relationship, i.e.\n  Bounded-Context has one or more models?\n\nI guess you could say it that way, but a bounded context (BC) has just one model, with objects named according to the ubiquitous language (UL) of the BC.\nBoth models and BCs belong to the solution space.\nIn the problem space you have the domain and sub-domains.\nIn the solution space you have BCs (ideally 1:1 related with sub-domains). You model a subdomain, and you have a BC for each sub-domain model.\nBut for example you could model the entire domain with just one model, so that you would have just a BC in the solution space for the entire domain. In this case you have one BC related to many subdomains. This BC would be a monolithic application.\nThe other example, one sub-domain related to many BCs, happens when you split the sub-domain into several \"parts\", and you model each \"part\". So you would have many models for the subdomain. This way in the solution space you have many BCs for the subdomain, i.e., many applications to solve a subdomain problem.\nThese cases of 1:N or N:1 relationships between subdomains and BCs happens when the division according to the UL terminology is fuzzy.\n\nAs I understand DDD concepts should be identifiable (to some degree)\n  through the codebase, this is clear for Aggregate, Entities, Event,\n  Commands...etc, but how Models and Bounded-Context are mapped into the\n  codebase? for example is a models just a set of one or more\n  aggregates, or something else? is Bounded-context a namespace or\n  something else?\n\nA BC is a software system, an autonomous application. And a model is the source code of the BC. But in DDD there exists another concept: the module, a cohesive group of domain objects. It is a thinner division than BCs.\nSo you have, from wider to smaller:\nSolution --> BC --> module --> aggregate --> entity & value objects","Q_Score":0,"Tags":"python,domain-driven-design,implementation","A_Id":59282666,"CreationDate":"2019-12-05T13:59:00.000","Title":"How Models and Bounded-Contexts are mapped into the codebase DDD?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm looking for a replacement of MySQL\/Connector for Python and was wondering if PyMySQL can be used as a direct replacement. If I go that way should I expect some different output formatting of the output. For it I run a SELECT query on table that contains text, numbers and date\/time fields, would  PyMySQL return the output formatted in the same way as MySQL\/Connector?\nAlso should I expect any issues running other type of queries like INSERT , DELETE etc.\nI'd appreciate if you share your experience.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":187,"Q_Id":59197601,"Users Score":0,"Answer":"Since, there are no other answers, I'm going to share my experience so far. \nI can say PyMySQL works fine as a replacement of MySQL\/Connector for Python. The query outputs are compatible and I had no issues updating the tables. \nOne thing that is worth noting is the slightly different error output. I didn't find much about error handling in PyMySQL documentation. Generally it returns a tuple consisting of the error number and error message. It looks slightly different than MySQL\/Connector's error output, so one should be careful when capturing them.\nAlso the list of .connect() arguments is different but these are well documented. \nHope that may be helpful.","Q_Score":0,"Tags":"mysql,pymysql,mysql-connector-python","A_Id":59282966,"CreationDate":"2019-12-05T14:45:00.000","Title":"Can PyMySQL be used as a drop-in replacement of MySQL\/Connector for Python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a gui in python to manipulate stored records and I have the mysql script to set up the database and enter all information. How do I get from the mysql script to the .db file so that python can access and manipulate it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":319,"Q_Id":59198212,"Users Score":0,"Answer":"db files are SQLite databases most of the time. What you are trying to do is converting a dumped MySQL database into an SQLite database. Doing this is not trivial, as I think both dialects are not compatible. If the input is simple enough, you can try running each part of it using an SQLite connection in your Python script. If it uses more complex features, you may want to actually connect to a (filled) MySQL database and fetch the data from there, inserting it back into a local SQLite file.","Q_Score":0,"Tags":"python,sql,database","A_Id":59198273,"CreationDate":"2019-12-05T15:19:00.000","Title":"How do I create a .db file from an sql script?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my dataset X I have two continuous variables a, b and two boolean variables c, d, making a total of 4 columns. \nI have a multidimensional target y consisting of two continuous variables A, B and one boolean variable C. \nI would like to train a model on the columns of X to predict the columns of y. However, having tried LinearRegression on X it didn't perform so well (my variables vary several orders of magnitude and I have to apply suitable transforms to get the logarithms, I won't go into too much detail here). \nI think I need to use LogisticRegression on the boolean columns. \nWhat I'd really like to do is combine both LinearRegression on the continuous variables and LogisticRegression on the boolean variables into a single pipeline. Note that all the columns of y depend on all the columns of X, so I can't simply train the continuous and boolean variables independently.\nIs this even possible, and if so how do I do it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":458,"Q_Id":59200594,"Users Score":0,"Answer":"If your target data Y has multiple columns you need to use multi-task learning approach. Scikit-learn contains some multi-task learning algorithms for regression like multi-task elastic-net but you cannot combine logistic regression with linear regression because these algorithms use different loss functions to optimize. Also, you may try neural networks for your problem.","Q_Score":2,"Tags":"python,machine-learning,scikit-learn,regression","A_Id":59200836,"CreationDate":"2019-12-05T17:41:00.000","Title":"Combining logistic and continuous regression with scikit-learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my dataset X I have two continuous variables a, b and two boolean variables c, d, making a total of 4 columns. \nI have a multidimensional target y consisting of two continuous variables A, B and one boolean variable C. \nI would like to train a model on the columns of X to predict the columns of y. However, having tried LinearRegression on X it didn't perform so well (my variables vary several orders of magnitude and I have to apply suitable transforms to get the logarithms, I won't go into too much detail here). \nI think I need to use LogisticRegression on the boolean columns. \nWhat I'd really like to do is combine both LinearRegression on the continuous variables and LogisticRegression on the boolean variables into a single pipeline. Note that all the columns of y depend on all the columns of X, so I can't simply train the continuous and boolean variables independently.\nIs this even possible, and if so how do I do it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":458,"Q_Id":59200594,"Users Score":0,"Answer":"What i understand you want to do is to is to train a single model that both predicts a continuous variable and a class. You would need to combine both loses into one single loss to be able to do that which I don't think is possible in scikit-learn. However I suggest you use a deep learning framework (tensorflow, pytorch, etc) to implement your own model with the required properties you need which would be more flexible. In addition you can also tinker with solving the above problem using neural networks which would improve your results.","Q_Score":2,"Tags":"python,machine-learning,scikit-learn,regression","A_Id":59203141,"CreationDate":"2019-12-05T17:41:00.000","Title":"Combining logistic and continuous regression with scikit-learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question so in telegram bot there is a InlineKeyboardMarkup that can have a callback, but its not persistent, does not stick to the botton of the screen, when you write a new message it will go up, like a normal message. And on the other hand there is ReplyKeyboardMarkup that does persist and stay at the botton, but does not have a callback. So is there a way to create a button that stays at the botton but allso accepts a callback that you can catch with callback_query_handler","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":329,"Q_Id":59201308,"Users Score":0,"Answer":"No, there is no way to create a button that you can capture with callback_query_handler in a ReplyKeyboardMarkup.\nWhen you press a KeyboardButton, it sends a message with its text. What you could do is put your bot's commands in the buttons or you can make a message handler that captures non-command messages and execute some code for each text of your buttons.","Q_Score":0,"Tags":"python,telegram","A_Id":59201831,"CreationDate":"2019-12-05T18:32:00.000","Title":"Fixed button for Telegram bot that accepts a callback","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 having an hard time figuring out how to solve a problem with a little project.\nBasically i have a Django application. On the other hand i have an external Python script running. I would like to create a system where, each time a form in my Django app is submitted, the data submitted in the form is sent to the external Python application.\nThe external Python service should receive the data, read it, and according to who is the user and what did he submit, it should perform some tasks, then send a response.\nHere is what i thought: 1) Connect the external Python app to the same database that Django is using. So that when the form is submitted, it is saved on the database and the data can be 'shared' with the second Python service. The problem with this solution is that i would need the second app to query the Database every second and perform a lot of queries, that would be a problem with performances. 2) Create an epi endpoint, so that the external python app would connect to the endpoint and fetch the data saved in the database from there. The problem is the same of the first solution. Would a service like Redis or RabbitMQ help in this case?\nImporting the external Python process in my Django app is not a solution, it needs to be separate from the Django app. An important requirement for this, is speed. When new data is submitted, it needs to be received by the second Python app in the shortest time possible.\nThat said, i'm open to any advice or possible solution to solve this problem, thanks in advance :)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":862,"Q_Id":59202971,"Users Score":1,"Answer":"You should build an API. The 2nd app would now be an application server and the 1st app, when it receives a form submission from the user, would persist its data to the DB and then make an API call to the 2nd app via this API. You would include key information in the API request that identifies the record in the DB.\nYou can use Django (e.g. DRF) or Flask to implement a simple API server in Python.\nNow, this requires your app server to be up and running all the time. What if it's down? What should the 1st app do? If you need this level of flexibility, then you need to decouple these apps in some way. Either the 1st app implements some kind of backoff\/retry if it can't send to the 2nd app. Or you use a reliable queueing mechanism (something like Amazon SQS).","Q_Score":2,"Tags":"python,django","A_Id":59203064,"CreationDate":"2019-12-05T20:42:00.000","Title":"How can two Python applications hosted in different servers communicate?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Some really odd behaviour I can\u2019t work out with what should be a simple regex in Python 3.7...\nI have a string msg_data which contains event=mynode+button+0.\nIf I use the pattern r'^event=(?P<node>[\\w-]{1,19})+(?P<interface>[\\w-]{1,19})+ it works as expected - if I run params = re.match(pattern, msg_data) then params.group('node') = \"mynode\", and params.group('interface') = \"button\".  All fine so far.\nHowever, I can't match the 0 at the end...\nIf I add (?P<duration>[\\d]+) to the end of my pattern, I get no matches and hence params = false.  Same if I try [0-9] in the regex.  And it won't match even if I put a literal 0 in the pattern.\nHowever, if I add (?P<duration>[\\w]+) to the end of my pattern, it matches - but gives params.group('duration') = \"s\"!!\nNote that if the 0 is a 1, then it matches the letter r instead.\nSo the obvious question... what's going on?  I've got loads of other regex patterns matching numbers fine.  The msg_data string is coming from a http POST event, but is created as a 0 and prints as a 0 at all points elsewhere in the code.\nAny thoughts on what could be causing this behaviour?  It's been driving me crazy for two days - a really simple regex that just doesn't match what it should.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":59203234,"Users Score":0,"Answer":"Thanks to @user2722968 for the answer - the basic error was not escaping the literal + in my pattern.\nThe impact was then slightly obscure, and I made a key mistake of not actually checking that params.group('node') and params.group('interface') were as expected.  Actually they weren't.  params.group('node') matched all except the last two characters in the first part of msg_data - then params.group('interface') matched the second-to-last, and params.group('duration') matched the last.  The reason for the s vs r distinction is that I had a number of buttons on the webpage, and tried different ones on various occasions (which all had different variations of mynode.  r and s corresponded to the last letter depending on which button I pressed - again, bad assumption on my part!\nSo great answer, thanks, but bad question on my part - too many assumptions of the \"obvious\", without checking.  My bad, lesson learnt  :(","Q_Score":0,"Tags":"python,regex","A_Id":59203431,"CreationDate":"2019-12-05T21:03:00.000","Title":"Python re.match - a successful match result for a digit is a letter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want packets to be sent immediately (and individually) but even when setting socket.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1) before socket.send(...), packets are still being received by the client (using socket.recv(1024)) in multiples.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":132,"Q_Id":59203296,"Users Score":2,"Answer":"Disabling the Nagle algorithm only makes sure that writing data does not get delayed at the sender side. It does not prevent accumulation of the payloads of multiple packets on the recipients side. A recv(1024) will try to get up to 1024 bytes from the read buffer and it does not care if these bytes were send within a single or within multiple packets.\nIn general, TCP is a byte stream and has no implicit message semantics. This does not change by invoking some socket options, it still has to be treated as a byte stream. Any message semantics you want to have must be implemented in the application on top of this byte stream.","Q_Score":0,"Tags":"python,sockets,tcp","A_Id":59203624,"CreationDate":"2019-12-05T21:09:00.000","Title":"Nagle not being disabled by TCP_NODELAY","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried this code but always return an empty query, and i don't know why.\nparent = MangaPage.objects.filter(title=Page.get_parent)","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":410,"Q_Id":59204717,"Users Score":2,"Answer":"get_parent is a method on a specific instance of the Page class, it's not a property. You should not call it from the Page class directly, but rather from a specific page.\nIt should look something like this:\nparent = MangaPage.objects.get(title='Some Title').specific().get_parent()\nEssentially what you are doing in your code example is searching for a MangaPage that has a title equal to the method Page.get_parent, which of course there are none. You need to get the parent of a specific page instance.","Q_Score":0,"Tags":"python,django,wagtail","A_Id":59204857,"CreationDate":"2019-12-05T23:28:00.000","Title":"I can't get parent page query in wagtail","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In Python 3.6, when I attempt to \"open('foobar', \"r+b\") with a file whose permissions are '-r--r--r--' (in CentOS7), I get a permission failure:\n\"builtins.PermissionError: [Errno 13] Permission denied: 'full\/path\/to\/foobar'\"\nIt opens just fine with \"r\", and the \"r+b\" works just fine if the permissions are '-rw-rw-rw-'.\nI do need to open these files read-only, I'd like them to have read-only protections in the directory (so that they aren't inadvertently changed by other code), and I do need to read them as binaries. Is this a feature\/bug of Python 3.6?\nI'd like to know if I'm doing something incorrect, or if there's some work-around if not. I'd really like to avoid upgrading to 3.8 right now.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":228,"Q_Id":59205618,"Users Score":2,"Answer":"You are using the + mode, which is trying to open the file for update. Try without the + and it should work.\nPer the help:\n\n'+'       open a disk file for updating (reading and writing)","Q_Score":1,"Tags":"python","A_Id":59205646,"CreationDate":"2019-12-06T01:31:00.000","Title":"Python 3.6 fails to open read-only file using \"r+b\" mode","Data Science and Machine Learning":0,"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":"There's a long list of languages that can be compiled into Wasm. Is there any performance gain from writing in something like C or Rust over Python? Or is it all the same since it is being compiled to Wasm?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":2072,"Q_Id":59206185,"Users Score":3,"Answer":"Compiling to WebAssembly is basically just simulating a special form of assembly targeting virtual hardware. When you read \"can compile language X\" into Wasm, it doesn't always mean the language literally compiles directly to Wasm. In the case of Python, to my knowledge, it means \"they compiled Python interpreters to Wasm\" (e.g. CPython, PyPy), so the whole Python interpreter is Wasm, but it still interprets Python source code files normally, it doesn't convert them to special Wasm modules or anything. Which means all the overhead of the Python interpreter is there, on top of the overhead of the Wasm engine, etc.\nSo yes, C and Rust (which can target Wasm directly by swapping out the compiler backend) will still run faster than Python code targeting CPython compiled to Wasm, for the same reasons. Tools that speed up Python when run natively (e.g. Cython, raw CPython C extensions, etc.) may also work in Wasm to get the same speed ups, but it's not a free \"Compile slow interpreted language to Wasm and become fast compiled language\"; computers aren't that smart yet.","Q_Score":4,"Tags":"python,c,webassembly","A_Id":59206299,"CreationDate":"2019-12-06T02:53:00.000","Title":"Does WebAssembly run faster if written in C as opposed to 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":"So I have trained a RandomForest model on a fairly simple customer data. The prediction is either 1 or 0 telling if a customer will churn or not. \nLet's say I have 10 features called 'f1', 'f2', 'f3' and so on... As the model has already been trained I took another period of the similar data to see how the model performs. But in this data the features could be shuffled in a different way. (for example 'f3', 'f10', 'f1', ...). Will the model look at the name of the features or it won't matter for it and it will think that 'f1' is 'f3'? Let's say the type of the data is the same in each column.\nThe reason I am asking this is because to check this theory I renamed 'f3' column name to 'a' and to my astonishment the model worked anyways. What are your thoughts?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":59209196,"Users Score":0,"Answer":"The algorithm works independent from your column names. You can name your columns whatever you want in most algorithms(except fbprophet etc.) \nBut there is one important point here:\nWhen you want to predict a dataset result you need to give your dataset columns respect to training model columns' order. \nIn your case you can rename your columns f1, f2, f3.. to abc1, abc2, def3..\nbut you cannot shuffle their order.","Q_Score":0,"Tags":"python,python-3.x,machine-learning,data-science,random-forest","A_Id":59209501,"CreationDate":"2019-12-06T08:07:00.000","Title":"The naming and the sorting of the trained RF model's features in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using opencv3.4 to stitch images with a lot of customization, but cv.detail_MultiBandBlender seems only avaiable in opencv 4.x but with 4.x surf is \"patented and is excluded\". Is there any hack so that I can use blender with opencv-python3.4?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":427,"Q_Id":59209586,"Users Score":0,"Answer":"Patented stuff is usually just moved to the contrib repository, so you have to clone the original OpenCV repo, then add the contrib over and maybe modify a few compile options to get all your required things back and running.","Q_Score":0,"Tags":"python,python-3.x,opencv","A_Id":59209729,"CreationDate":"2019-12-06T08:38:00.000","Title":"How to create blender with opencv-python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"One of the columns in my dataset has the same value for all observations\/rows. \nShould I remove that column while building a machine learning model?\nWill removing this column affect my model\/performance metric?\nIf I replace all the values with a different constant value, will it change the model\/performance metric?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1263,"Q_Id":59209830,"Users Score":1,"Answer":"A Machine Learning Model is nothing but a mathematical equation i.e.\ny = f(x)\nin which\ny = Target\/Dependent Variable\nf(x) = Independent Variables(In our case a DataFrame containing the Train\/Test Data)\nSo technically, ML models quantifies and estimates about for what value of X, what will the probable output y.\nAssuming a single whole column is constant. So, a relationship between y and f(x=constant) is meaningless because for whatever value of y, that x will remain same. No mathematical relationship is possible except for the only option that y is also an constant. Which we can safely assume isn't the case, else why else you will build a model to get a constant value.\nHence, we can safely drop any constant column, which doesn't add any variation in data to the DataFrame to save computational time, as that column won't affect y in any sense.","Q_Score":1,"Tags":"python,r,pandas,machine-learning,data-science","A_Id":59212992,"CreationDate":"2019-12-06T08:56:00.000","Title":"Will removing a column having same values for all observations affect my model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"One of the columns in my dataset has the same value for all observations\/rows. \nShould I remove that column while building a machine learning model?\nWill removing this column affect my model\/performance metric?\nIf I replace all the values with a different constant value, will it change the model\/performance metric?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1263,"Q_Id":59209830,"Users Score":2,"Answer":"If one of your column in the dataset is having the same values, you can drop this column as it will not do any help to your model to differentiate between two different labels while on the other hand, it can even negatively affect your model by creating a bias in the data.\nFor Example: Consider you have two different fruits, like one is Green Apple and one is Guava. Then, both of these fruits will have the same color i.e. \"Green\", so that basically means that you just can not differentiate both these fruits on the basis of their color, but if they have been two different colored fruits, you could have used this feature to differentiate between them.\nHope it helps clarifying what you should do with such a column with same set of observations.\nThanks.","Q_Score":1,"Tags":"python,r,pandas,machine-learning,data-science","A_Id":59210087,"CreationDate":"2019-12-06T08:56:00.000","Title":"Will removing a column having same values for all observations affect my model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a microservice application on Python. Can anyone help me the standard folder structure and the standard libraries used. An example with a two microservice would be helpful to understand.\nThanks a lot.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":764,"Q_Id":59211641,"Users Score":0,"Answer":"There is no folder structure for microservices. Every service can have a different structure with different intent and still work as long as the contracts between 2 or more services are consistent.","Q_Score":1,"Tags":"python-3.x,frameworks,microservices","A_Id":59235311,"CreationDate":"2019-12-06T10:47:00.000","Title":"Python Microservice Structure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to transform two datasets: x_train and x_test using tsne. I assume the way to do this is to fit tsne to x_train, and then transform x_test and x_train. But, I am not able to transform any of the datasets.\ntsne = TSNE(random_state = 420, n_components=2, verbose=1, perplexity=5, n_iter=350).fit(x_train)\nI assume that tsne has been fitted to x_train.\nBut, when I do this:\nx_train_tse = tsne.transform(x_subset)\nI get:\nAttributeError: 'TSNE' object has no attribute 'transform'\nAny help will be appreciated. (I know I could do fit_transform, but wouldn't I get the same error on x_test?)","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":6221,"Q_Id":59214232,"Users Score":5,"Answer":"As the accepted answer says, there is no separate transform method and it probably wouldn't work in a a train\/test setting.\nHowever, you can still use TSNE without information leakage.\nTraining Time\nCalculate the TSNE per record on the training set and use it as a feature in classification algorithm.\nTesting Time\nAppend your training and testing data and fit_transform the TSNE.  Now continue on processing your test set, using the TSNE as a feature on those records.\nDoes this cause information leakage? No.\nInference Time\nNew records arrive e.g. as images or table rows.\nAdd the new row(s) to the training table, calculate TSNE (i.e. where the new sample sits in the space relative to your trained samples). Perform any other processing and run your prediction against the row.\nIt works fine.  Sometimes, we worry too much about train\/test split because of Kaggle etc. But the main thing is can your method be replicated at inference time and with the same expected accuracy for live use.  In this case, yes it can!\nOnly drawback is you need your training database available at inference time and depending on size, the preprocessing might be costly.","Q_Score":12,"Tags":"python,machine-learning","A_Id":64245990,"CreationDate":"2019-12-06T13:36:00.000","Title":"python tsne.transform does not exist?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi I have a built up Python 2.7 environment with Ubuntu 19.10. \nI would like to build a whl package for pandas.\nI pip installed the pandas but do not know how to pack it into whl package.\nMay I ask what I should do to pack it.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":139,"Q_Id":59214739,"Users Score":0,"Answer":"You cannot pack back an installed wheel. Either you download a ready-made wheel with pip download or build from sources: python setup.py bdist_wheel (need to download the sources first).","Q_Score":0,"Tags":"python,pandas,python-wheel","A_Id":59246265,"CreationDate":"2019-12-06T14:08:00.000","Title":"How to build whl package for pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to load data from our cloud environment (pivotal cloud foundry) into SQL Server. Data is fetched from API and held in memory and we use tds to insert data to SQL Server, but only way in documentation I see to use bulk load is to load a file. I cannot use pyodbc because we dont have odbc connection in cloud env.\nHow can I do bulk insert directly from dictionary?\npytds does not offer bulk load directly, only from file","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":126,"Q_Id":59216350,"Users Score":0,"Answer":"The first thing that comes to mind is to convert the data into bulk insert sql.  Similar to how you migrate mysql.\nOr if you could export the data into cvs, you could import use SSMS (Sql Server Managment Studio).","Q_Score":0,"Tags":"python,sql-server","A_Id":59217041,"CreationDate":"2019-12-06T15:50:00.000","Title":"Best way for bulk load of data into SQL Server with Python without pyodbc","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Fairly new to ROS, but haven't been able to find this information searching around. \nWe're building an instrument where we need to transfer large data streams over the network on a 100Mbit limited cable. Preferably we need to transfer RAW images (~10MB a piece) or we can do some lossless compression resulting in about 5MB a piece. \nIs this perfectly fine for ROS with native image topics, or would a separate protocol such as ZeroMQ be better for this task? What are the limitations in ROS on large data streams?\nHope that someone with the knowledge could take a second to share some experience.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1161,"Q_Id":59224453,"Users Score":6,"Answer":"10E6 [B] over a private, 100% free 100E6 [b\/s] channel takes no less ~0.8 [s]\n_5E6 [B] over a private, 100% free 100E6 [b\/s] channel takes no less ~0.4 [s]\n\nQ : What are the limitations in <something> on large data streams?\n\nHere we always fight a three-fold Devil mix of:\nPower( for data processing, a 10[MB]->5[MB] compression + RAM-I\/O not being excluded )\n+\nTime( latency + jitter of the E2E data-transport across the series of transport-channels )\n+\nErrors( uncertainties of content delivery, completeness and authenticity over the E2E data-transport path )\nIn the ROS domain, being a system for coordinated control-loops' constrained sub-systems, there is one more problem - not meeting the \"in-time-ness\" causes the control to fail into principally unstable territory.\n\n Countless examples of what happens when this border has been crossed - from production line falling into panic, resulting in an immediate emergency total-stop state, to damaged tools, products, equipment and continued colliding, still crashing during still continued operations ( when collision-detection and emergency total-stops were not implemented safe ).\n\n\n\nQ : would a separate protocol such as ZeroMQ be better for this task?\n\nZeroMQ has excellent performance ( does not add much on the Time leg of the Devil-mix, yet it always depends on having (in-)sufficient resources ( the Power to smoothly process )\nZeroMQ has excellent performance scalability, sure, if the Power leg of the Devil-mix permits.\nZeroMQ has excellent properties for the Errors leg of the Devil-mix - we get warranty of Zero-Errors - it either delivers the message (the payload) as a bit-to-bit identical copy of the original content, or nothing at all. This warranty may look strange, a sure overkill for blurred or noisy images - yet, it is a fair strategy for not having additional Power and Time-uncertainty issues due to error-detection\/limited-recovery. Yet it leaves us free with choices, how to handle (if needed), within a given, constrained, Time- and Power-domains, the main duty - the ROS control-loops' stability - with missing or re-transmit requested payloads, given Errors were indirectly detected from time-stamping or monotonic-ordinal indexing et al.\nROS Topics, on the contrary, are limited to a single PUB\/SUB formal communication-pattern archetype only and fixed to use either a TCPROS transport-class ( ZeroMQ may use a faster, L3+protocol stack-less { inproc:\/\/ | ipc:\/\/ } or, if needed, even extended to a mil-std guaranteed-delivery or a distributed grid-computing tipc:\/\/ or hypervisor-orchestrated vmci:\/\/ transports ) or UDPROS, which is currently available in roscpp only and lossy, but having lower latency, compared to TCPROS.","Q_Score":3,"Tags":"python,zeromq,ros","A_Id":59226070,"CreationDate":"2019-12-07T08:56:00.000","Title":"ROS: Is ZeroMQ better for large data streams, e.g. raw images, than native image topic?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I understand in the case where custom behavior is required, e.g. an elaborately constructed and operated QGraphicsScene for example, subclassing the QObject in question is something of a no-brainer reasonable course of action.\nHowever, what if you want to subclass simply for the purpose of code cleanliness. For example, if I have a QDockWidget that requires say dozens of widgets and layouts to be added to it, I can certainly create the QDockWidget first and then execute all of the code on that instance necessary to gussy it up. Or, I could also provide all of that UI build code inside of a subclassed QDockWidget instance, so that in the main application code I simply need to only create an instance of my \"custom\" QDockWidget and move on. This makes the main application code much cleaner.\nIs this a misuse of the purpose of subclassing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":59224917,"Users Score":2,"Answer":"Definitely, it's not a misuse!\nLogically, subclassing is intended to be used to extend\/manipulate the functionality of the inherited class.\nSo, you are doing it right.","Q_Score":0,"Tags":"python,qt,subclass","A_Id":59225065,"CreationDate":"2019-12-07T10:07:00.000","Title":"When is it Pythonic\/good practice to subclass in Qt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a game with Pygame, and now I stuck on how to process collision between player and wall. This is 2D RPG with cells, where some of them are walls. You look on world from top, like in Pacman.\nSo, I know that i can get list of collisions by pygame.spritecollide() and it will return me list of objects that player collides. I can get \"collide rectangle\" by player.rect.clip(wall.rect), but how I can get player back from the wall?\nSo, I had many ideas. The first was push player back in opposite direction, but if player goes, as example, both right and bottom directions and collide with vertical wall right of itself, player stucks, because it is needed to push only left, but not up.\nThe second idea was implement diagonally moving like one left and one bottom. But in this way we don't now, how move first: left or bottom, and order becomes the most important factor.\nSo, I don't know what algorithm I should use.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":298,"Q_Id":59225511,"Users Score":0,"Answer":"If you know the location of the centre of the cell and the location of the player you can calculate the x distance and the y distance from the wall at that point in time. Would it be possible at that point to take the absolute value of each distance and then take the largest value as the direction to push the player in.\ne.g. The player collides with the right of the wall so the distance from the centre of the wall in the y direction should be less than the distance in x.\nTherefore you know that the player collided with the left or the right of the wall and not the top, this means the push should be to the right or the left.\nIf the player's movement is stored as in the form [x, y] then knowing whether to push left or right isn't important since flipping the direction of movement in the x axis gives the correct result.\nThe push should therefore be in the x direction in this example\ne.g. player.vel_x = -player.vel_x.\nThis would leave the movement in the y axis unchanged so hopefully wouldn't result in the problem you mentioned.\nDoes that help?","Q_Score":0,"Tags":"python,algorithm,pygame,collision","A_Id":59225861,"CreationDate":"2019-12-07T11:29:00.000","Title":"Walls logic in Pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i run a python program using beautifulsoup and requests to scrape embedded videos URL , but to download theses videos i need to bypass a  ads popups and javascript reload only then the m3u8 files start to appear in the network traffic;\nso i need to simulate the clicks to get to the javascript reload (if there's a method better than selenium, trying to reduce script dependencies) and then when the m3u8files appear i need to get their url.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1293,"Q_Id":59227170,"Users Score":-1,"Answer":"Blockquote\n  `i run a python program using beautifulsoup and requests to scrape embedded videos URL , but to download theses videos i need to bypass a ads popups and javascript reload only then the m3u8 files start to appear in the network traffic;\n\nso i need to simulate the clicks to get to the javascript reload (if there's a method better than selenium, trying to reduce script dependencies) and then when the m3u8files appear i need to get their url\n`Can I have your code please?","Q_Score":0,"Tags":"javascript,python-3.x,beautifulsoup,python-requests,m3u8","A_Id":59507440,"CreationDate":"2019-12-07T14:47:00.000","Title":"How to scrape m3u8 from Network-Stream after a js reload (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Thank you all for always willing to help.\nI have a Django app with countries and state choices fields. However, I have no idea whatsoever on how to load the related states for each country. What I mean here is, if I choose \"Nigeria\" in the list of countries, how can I make all Nigerian states to automatically load in the state choice field?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":59228446,"Users Score":0,"Answer":"You have to create many to many field state table, then you can multiple select state as per country.\nthis feature available on django- country package or django- cities package.","Q_Score":0,"Tags":"django,python-3.x,django-models","A_Id":59228702,"CreationDate":"2019-12-07T17:17:00.000","Title":"How to load values related to selected multiple options in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have created a program using python which moves goes through each file in my downloads directory, and moves that file to another directory based on the suffix at the end of the file (.mp3, .mp4, .txt, .jpg, ...). How would I go about automating this program so that it runs in the background of my computer every couple of hours?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":59228965,"Users Score":0,"Answer":"I do not know much about python, but in nodejs, there is a tool called cronjob. When you set routine, according to the time that you set, it calls scripts. Maybe there is an equivalent version in python.","Q_Score":1,"Tags":"python,python-3.x","A_Id":59229087,"CreationDate":"2019-12-07T18:19:00.000","Title":"How can I run my program in the background at certain times of the day?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanna run my opencv3.1 programs, but when i try to read a file using cv2.VideoCapture shows me the error:\nerror: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): .\/..\/images\/walking.avi in function 'icvExtractPattern'\nBut, when i using the camera with cv2.VideoCapture(0) it works perfectly. I verify the file path and using the relative and the absolute path, but still not working.\nI gonna wait for your answers.\nThanks a lot","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1168,"Q_Id":59230366,"Users Score":0,"Answer":"Originally I used cv2.VideoWriter_fourcc(*'XVID') getting the same error\nswitch the (*'XVID') to (*'MJPG')\nI am using a raspberry pi Gen. 4 (4GB) with image: Raspbian Buster Lite","Q_Score":0,"Tags":"python-3.x,opencv,artificial-intelligence,opencv3.1,opencv4","A_Id":60907594,"CreationDate":"2019-12-07T21:25:00.000","Title":"Can't read .avi files using Python OpenCV 4.1.2-dev","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list of very large numbers I need to round. \nFor example:\n6.624147027484989e+25 I need to round to 6.62e25.\nHowever, np.around, math.ceiling, round(), etc... are not working. I'm thinking because instead of round 6.624147027484989e+25 to 6.62e25, it's just making it an integer while I actually need to make the entire number much smaller... if that makes sense.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":179,"Q_Id":59231931,"Users Score":5,"Answer":"I think, if I understand your problem correctly, you could use float(\"%.2e\" % x)\nThis just converts the value to text, in exponential format, with two fractional places (so 'pi' would become \"3.14e+00\"), and then converts that back to float. It will work with your example, and with small numbers like 5.42242344e-30\nFor python 3.6+, it's better to use float(f\"{x:.2e}\") - thanks @gabriel-jablonski","Q_Score":1,"Tags":"python,python-3.x,rounding","A_Id":59231944,"CreationDate":"2019-12-08T02:25:00.000","Title":"Rounding large exponential numbers e.g. (6.624147...e+25 to 6.62e+25)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I copy my project (with flash driver) from one computer to another, and try to run the project in the second computer in the pycharm it says - Error running 'file.py': Cannot run program + \"The path of the interpreter that I had in my first computer\". How does it know the path of the interpreter that I had in the first computer and why does it search for it? Maybe somewhere in the project it saves the interpreter?\nIn some files it succeed to run.\nI Changed the interpreter and it still searching for the interpreter that I had in the first computer and from that reason I can't run the project from the other computer.\nI tried also to change the working directory and still it throws the exception \"No module named 'package_name'\" when I run the program.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":480,"Q_Id":59236335,"Users Score":0,"Answer":"You can try to modify the .idea\/workspace.xml file?","Q_Score":0,"Tags":"python,pycharm,project,interpreter","A_Id":59236474,"CreationDate":"2019-12-08T14:23:00.000","Title":"Copy Python project to other computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I trained a deep learning model to classify the given images into three classes. Now I want to add one more class to my model. I tried to check out \"Online learning\", but it seems to train on new data for existing classes. Do I need to train my whole model again on all four classes or is there any way I can just train my model on new class?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5204,"Q_Id":59236502,"Users Score":3,"Answer":"You probably have used a softmax after 3 neuron dense layer at the end of the architecture to classify into 3 classes. Adding a class will lead to doing a softmax over 4 neuron dense layer so there will be no way to accommodate that extra neuron in your current graph with frozen weights, basically you're modifying the graph and hence you'll have to train the whole model from scratch \n-----or-----\none way would be loading the model and removing the last layer , changing it to 4 neurons and training the network again! This will basically train the weights of the last layer from scratch . I don't think there is anyway to keep these(weights of the last layer) weights intact while adding a new class .","Q_Score":6,"Tags":"python,keras,deep-learning,multiclass-classification,online-machine-learning","A_Id":59236950,"CreationDate":"2019-12-08T14:39:00.000","Title":"How to add a new class to an existing classifier in deep learning?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I trained a deep learning model to classify the given images into three classes. Now I want to add one more class to my model. I tried to check out \"Online learning\", but it seems to train on new data for existing classes. Do I need to train my whole model again on all four classes or is there any way I can just train my model on new class?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":5204,"Q_Id":59236502,"Users Score":3,"Answer":"You have to remove the final fully-connected layer, freeze the weights in the feature extraction layers, add a new fully-connected layer with four outputs and retrain the model with images of the original three classes and the new fourth class.","Q_Score":6,"Tags":"python,keras,deep-learning,multiclass-classification,online-machine-learning","A_Id":60471776,"CreationDate":"2019-12-08T14:39:00.000","Title":"How to add a new class to an existing classifier in deep learning?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I type print \u201chello world\u201d in my atom text editor then in my Mac OS X terminal I run cd \/users\/my user\/myfolder then i run the file I was writingpython example.py\nAfter that my Mac does nothing. No error message, no nothing it just goes to a new line","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2372,"Q_Id":59236800,"Users Score":0,"Answer":"I was having the same issue. It's the text editor Atom. You have to add LFCR as the last line of the code. I spent an hour trying to figure this out too.","Q_Score":0,"Tags":"macos,python-2.7,command-line,terminal,atom-editor","A_Id":65130694,"CreationDate":"2019-12-08T15:16:00.000","Title":"Python Script not Running in Mac Terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I type print \u201chello world\u201d in my atom text editor then in my Mac OS X terminal I run cd \/users\/my user\/myfolder then i run the file I was writingpython example.py\nAfter that my Mac does nothing. No error message, no nothing it just goes to a new line","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2372,"Q_Id":59236800,"Users Score":0,"Answer":"I ran into this. The editor u used add only LF at the end of the line.\nTry to save it as Unix file or add LFCR for carrier return. It should solve the problem.\nOf course, run python first and see python is running correctly.","Q_Score":0,"Tags":"macos,python-2.7,command-line,terminal,atom-editor","A_Id":63652463,"CreationDate":"2019-12-08T15:16:00.000","Title":"Python Script not Running in Mac Terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I type print \u201chello world\u201d in my atom text editor then in my Mac OS X terminal I run cd \/users\/my user\/myfolder then i run the file I was writingpython example.py\nAfter that my Mac does nothing. No error message, no nothing it just goes to a new line","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2372,"Q_Id":59236800,"Users Score":0,"Answer":"If there is no error message and no printing, you probably did not include a output command in your python file, such as print. \nRun this command in your terminal and it will work:\necho \"print \\\"hello world\\\"\" >> example.py \nthen python example.py","Q_Score":0,"Tags":"macos,python-2.7,command-line,terminal,atom-editor","A_Id":59261433,"CreationDate":"2019-12-08T15:16:00.000","Title":"Python Script not Running in Mac Terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have to do the following but I don't fully get it.\nThe exercise:\nLet n be a tenfold bigger than 100. Construct only using the range-method and the concatenation-operator.\nThe list: [n+10, n+5, n, .., 10, 5, 0, 0, -5, -10, .., -n+10, -n+5, -n]\nWhat im thinking is writing something like:\nlist(range(n+10,0,-5) to cover n+10 till 0 and have list(range(0,-n,-5) to cover the second 0 till -n.\nBut this is incorrect, the answer is list(range(n+10,-5,-5)) + list(range(0,-n-1,-5)) but I don't understand how I could come up with some of the variables.\nDoes anyone have a clue how this works?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":59236850,"Users Score":0,"Answer":"Your answer skips the last value in the first component of the final list, because the range function does not include the stop value.\n\n[The] answer is list(range(n+10,-5,-5)) + list(range(0,-n-1,-5))\n\nThe former list is [n + 10, n + 5, ..., 5, 0] while the latter complements it (i.e. it is [0, 5, ..., -n + 5, -n]).","Q_Score":0,"Tags":"python,list,range","A_Id":59236947,"CreationDate":"2019-12-08T15:21:00.000","Title":"Using the range and list method to construct lists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a big dataset containing almost 0.5 billions of tweets. I'm doing some research about how firms are engaged in activism and so far, I have labelled tweets which can be clustered in an activism category according to the presence of certain hashtags within the tweets.\nNow, let's suppose firms are tweeting about an activism topic without inserting any hashtag in the tweet. My code won't categorized it and my idea was to run a SVM classifier with only one class.\nThis lead to the following question:\n\nIs this solution data-scientifically feasible?\nDoes exists any other one-class classifier?\n(Most important of all) Are there any other ways to find if a tweet is similar to the ensable of tweets containing activism hashtags?\n\nThanks in advance for your help!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":540,"Q_Id":59238140,"Users Score":1,"Answer":"Sam H has a great answer about using your dataset as-is, but I would strongly recommend annotating data so you have a few hundred negative examples, which should take less than an hour. Depending on how broad your definition of \"activism\" is that should be plenty to make a good classifier using standard methods.","Q_Score":1,"Tags":"python,twitter,nlp,classification,text-classification","A_Id":59395618,"CreationDate":"2019-12-08T17:44:00.000","Title":"Find how similar a text is - One Class Classifier (NLP)","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":"There are many posts detailing errors in psycopg2 installation and import when using PyCharm. Like many others, I believe I had installed Postgres (used pgAdmin 4) and psycopg2 (previous answers suggested using pip and homebrew) but could not get the latter to load through PyCharm. Although this seems to be a relatively common issue that has been discussed, I have yet to find straightforward instructions--not just retroactive troubleshooting--that pick up after installation of PyCharm and Postgres. I've seen some posts with screenshots that seem like they might be relevant but they look like a different version of PyCharm than mine (Community 2.2). What are the basic steps that should allow one to import psycopg2 when using PyCharm on a Mac?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":312,"Q_Id":59239106,"Users Score":0,"Answer":"I solve this problem by changing \nfrom:\n   include-system-site-packages = false\nto\n   include-system-site-packages = true\nin the file pyvenv.cfg from the folder venv\nHope it helps...","Q_Score":0,"Tags":"python,postgresql,pycharm,psycopg2","A_Id":59362065,"CreationDate":"2019-12-08T19:27:00.000","Title":"Installation instructions to import psycopg2 using PyCharm CE for Mac?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a webapp that I made using django that I need to deploy to many raspberry pi devices. I'm using ansible to automate the deployment to devices. While developing the app I used pipenv to manage my project dependencies in a virtual environment.\nMy question is, is it necessary to make a virtual environment on the actual raspberry pi devices when deploying or can I just install all my necessary packages on the system environment? What are the advantages of making a virtual environment on the device?\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":59239496,"Users Score":1,"Answer":"Separating your apps' dependencies from systems' is always a good idea. The overhead is minimal and may prevent issues in the future. It makes it much easier to tear down and rebuild your app if you ever need to, rather than potentially having to re-image the raspberry pi if anything goes wrong. It also means you have the ability to run separate apps on the pi that don't need to be running off the same package versions, should you ever want to do that.\nHowever, it's certainly possible not to use one and you might get away with it and not have any issues. But if you want to improve the reliability and maintainability of your app and pi, and considering how easy it is to setup and use, it seems like a poor design decision not to use it.","Q_Score":1,"Tags":"python,django,raspberry-pi,virtualenv","A_Id":59240818,"CreationDate":"2019-12-08T20:12:00.000","Title":"Python virtualenv when deploying webapp to 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":1},{"Question":"In one of my folders\/directories, I have a module named \"restaurant_class.py\" with a class that I am trying to import into a different module named \"restaurant_instance.py\" \nfrom restaurant_class import Restaurant\nIn the same directory I do have a blank file named __init__.py.\nEvery time I try to import the module and class, it keeps giving me the error \nno module named 'restaurant_class'\nHow do I import a module and\/or class from a module that I created?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":59242420,"Users Score":0,"Answer":"I figured out my problem. In my File Explorer to locate the directory, I was in the wrong directory. The files are placed correctly, just had the wrong directory pulled up in Spyder.","Q_Score":0,"Tags":"python,class,import,module","A_Id":59242675,"CreationDate":"2019-12-09T04:08:00.000","Title":"How do I import a module into a different file, in the same directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I found this note in Python multiprocessing Pool library docs:\n\nWorker processes within a Pool typically live for the complete\n  duration of the Pool\u2019s work queue. A frequent pattern found in other\n  systems (such as Apache, mod_wsgi, etc) to free resources held by\n  workers is to allow a worker within a pool to complete only a set\n  amount of work before being exiting, being cleaned up and a new\n  process spawned to replace the old one. The maxtasksperchild argument\n  to the Pool exposes this ability to the end user.\n\nIt says that Apache and others reinitialize multiprocess entities which makes it a good pattern. Is it about reinitializing objects (like \"OOP\" objects) to call garbage collector? Why is it important? GC can not be used while multiprocessing object exists?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":59243118,"Users Score":1,"Answer":"One of the main use case is to avoid small leaks (memory, fd, ...) to affect long running services. \nAs software is not perfect, it's often the case that some library is not cleaning up properly. As these issues are out of the developer's control, an easy fix is to periodically terminate the leaking processes and start anew.\nAnother use case is to control the memory consumption of your service. Python memory fragmentation for example often leads workers to eat much more memory than needed.","Q_Score":1,"Tags":"python,garbage-collection,multiprocessing","A_Id":59245720,"CreationDate":"2019-12-09T05:43:00.000","Title":"Why reinitialize multiprocess workers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I made a TensorFlow model without using CUDA, but it is very slow. Fortunately, I gained access to a Linux server (Ubuntu 18.04.3 LTS), which has a Geforce 1060, also the necessary components are installed - I could test it, the CUDA acceleration is working.\nThe tensorflow-gpu package is installed (only 1.14.0 is working due to my code) in my virtual environment.\nMy code does not contain any CUDA-related snippets. I was assuming that if I run it in a pc with CUDA-enabled environment, it will automatically use it.\nI tried the with tf.device('\/GPU:0'): then reorganizing my code below it, didn't work. I got a strange error, which said only XLA_CPU, CPU and XLA_GPU is there. I tried it with XLA_GPU but didn't work.\nIs there any guide about how to change existing code to take advantage of CUDA?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":59246985,"Users Score":0,"Answer":"Not enough to give exact answer.\nHave you installed tensorflow-gpu separately? Check using pip list.\nCause, initially, you were using tensorflow (default for CPU).\nOnce you use want to use Nvidia, make sure to install tensorflow-gpu. \nSometimes, I had problem having both installed at the same time. It would always go for the CPU. But, once I deleted the tensorflow using \"pip uninstall tensorflow\" and I kept only the GPU version, it worked for me.","Q_Score":0,"Tags":"python,tensorflow","A_Id":59262244,"CreationDate":"2019-12-09T10:34:00.000","Title":"Existing Tensorflow model to use GPU","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When using tensorflow to train a neural network I can set the loss function arbitrarily. Is there a way to do the same in sklearn when training a SVM? Let's say I want my classifier to only optimize sensitivity (regardless of the sense of it), how would I do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":396,"Q_Id":59248882,"Users Score":1,"Answer":"This is not possible with Support Vector Machines, as far as I know. With other models you might either change the loss that is optimized, or change the classification threshold on the predicted probability. \nSVMs however minimize the hinge loss, and they do not model the probability of classes but rather their separating hyperplane, so there is not much room for manual adjustements.\nIf you need to focus on Sensitivity or Specificity, use a different model that allows maximizing that function directly, or that allows predicting the class probabilities (thinking Logistic Regressions, Tree based methods, for example)","Q_Score":0,"Tags":"python,machine-learning,optimization,scikit-learn","A_Id":59253034,"CreationDate":"2019-12-09T12:23:00.000","Title":"how to select the metric to optimize in sklearn's fit function?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two images - the images are identical but of different sizes.\nCurrently I complete a Canny analysis of the smaller image using track bars in an interactive environment. \nI want to have this output created on the second (larger) image - when I apply the same parameters the output is different\nI've tried to use cv.resize however the output is blurred significantly\nAny help is appreciated\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":59249664,"Users Score":0,"Answer":"To archieve comparable results you should resize the bigger image to the size of the smaller one. Image upscaling is \"creating\" information which isn't contained in your image, that's why you see the blur. Using interpolation=cv2.INTER_AREA should deliver good results, if you used a camera for images acquisition.","Q_Score":0,"Tags":"python,opencv,canny-operator","A_Id":59252280,"CreationDate":"2019-12-09T13:11:00.000","Title":"Applying identical Canny to two different images","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python program in which I am trying to do a post sending file contents as a string.  I am doing the following:\nheader 'content-type':'multipart\/form-data'\ndata {file1: filedata}\nfiledata is a string I build by reading a file putting the contents in the string\nwhen I make the post call I get a 500 back and looking in the catalina log I see the error \"couldn't determine the boundary from the message\".\nthe thing is when I put this in insomnia it works properly and the catalina log shows the header had ; boundary=X-INSOMNIA-BOUNDARY appended to the content-type I defined\nWhy would this work for insomnia but not when I do it in python using requests?  This is my requests call (auth is set to None)\nresponse = requests.post(url, data=data, headers=headers, auth=auth, timeout=REQUEST_TIMEOUT, verify=False)\nheaders = 'content-type':'multipart\/form-data\ndata = {'timepunch': 'datastring'}","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":136,"Q_Id":59250063,"Users Score":0,"Answer":"I found my problem - when sending a file I need the request to be files-data instead of data=data - not sure exactly what happens in the background but this resolved my issue","Q_Score":1,"Tags":"python","A_Id":59251085,"CreationDate":"2019-12-09T13:36:00.000","Title":"Python Post Getting couldn't determine the boundary from the message","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on the project with the group and we have decided to make the project on the ' Automatic Attendance System by AI '\nI have learned the CNNs to categorize the objects i.e dogs and cats.\nWith that knowledge, we have decided to make the attendance system based on CNN. ( Please tell me if we shouldn't take this path or the technology if you find something bad here... )\nBut continuing it with CNN, let's say we have trained the model with 2 students, and on the last layer we put the two neurons as they are just two, right...?\nNow the third comes, now to train his face to the NN, I have to change the model's structure and retrain every faces again...\nIf we apply the project to the big institute, where hundreds of students are there and if we want to train the model for each individual student, the nthis is not the feasible solution to recreate the model..\nSo we thought, we will fix the model's output layer size to let's say 50.\nSo only 50 faces can be trained per model.\nBut it is not always possible that there will always be 50.\nThey may 40 or if one gets in with ne admission, then 41.\nSo how to re-train the network with existing weights ?\n( The same question is asked somewhere I know, but please direct me with my situation )\n\nOr is there any other technology to use... ?\n\nPlease Direct me...","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":99,"Q_Id":59250070,"Users Score":2,"Answer":"You don't need classification. Classification is not the solution for everywhere problem.\nYou should look into these: \n\nCosine Similarity\nSiamese Network\n\nYou can use existing models from FaceNet or OpenCV. \nSince they are already trained on a huge dataset of faces, you can extract feature vector easily. \nStore the feature vector for every new student. \nThen compute similarities(existing image, current image) based on distance or similarity score mark attendance.\nThis is scable and much faster approach. No training or retraining.","Q_Score":1,"Tags":"python,keras,neural-network,artificial-intelligence,conv-neural-network","A_Id":59268457,"CreationDate":"2019-12-09T13:36:00.000","Title":"How to add new Category in the CNN for Attendance by AI","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm reading the book Django 2 by Example and am getting confused at one point there's a line {% with comments.count as total_comments %} where the author goes on to explain \n\nWe are using the Django ORM in the template, executing the QuerySet comments.count()...The {% with %} template tag is useful to avoid\n  hitting the database or accessing expensive methods multiple times.\n\nI thought templates are using whatever context is passed to them and no database access occurs?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":433,"Q_Id":59250832,"Users Score":2,"Answer":"I thought templates are using whatever context is passed to them and no database access occurs?\n\nWell it uses what is passed through the context. But a QuerySet is performed lazily. That means that if you for example pass MyModel.objects.all() it will not make the query, or at least not immediately.\nIt is only when you \"consume\" the queryset, for example by iterating over it, or by calculating the length of the queryset, that you will make a query to the database. A template can thus trigger several database queries. In fact N+1 problems often are caused by templates that iterate over one QuerySet of objects, and then query over a  related manager as well.\nA .count() on a QuerySet is evaluated eagerly as well, so if you have somequeryset, and you call .count() that will trigger a database query. If that is done in a loop, or at different locations in the template, then it will thus reduce in more queries to the database. By using a {% with \u2026=\u2026 %} statement, you will make the query when the template evaluates the {% with \u2026=\u2026 %} part, and then you can reuse that variable multiple times.","Q_Score":2,"Tags":"python,django,django-models,django-templates,django-queryset","A_Id":59251029,"CreationDate":"2019-12-09T14:21:00.000","Title":"Does the use of Django template tags execute Querysets?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use ubuntu (through Windows Subsystem For Linux) and I created a new conda environment, I activated it and I installed a library in it (opencv). However, I couldn't import opencv in Jupyter lab till I created a new kernel that it uses the path of my new conda environment. So, my questions are:\n\nDo I need to create a new kernel every time I create a new conda environment in order for it to work? I read that in general we should use kernels for using different versions of python, but if this is the case, then how can I use a specific conda environment in jupyter lab? Note that browsing from Jupyter lab to my new env folder or using os.chdir to set up the directory didn't work.\nUsing the new kernel that it's connected to the path of my new environment, I couldn't import matplotlib and I had to activate the new env and install there again the matplotlib. However, matplotlib could be imported when I was using the default kernel Python3. \nIs it possible to have some standard libraries to use them with all my conda environments (i.e. install some libraries out of my conda environments, like matplotlib and use them in all my enviroments) and then have specific libraries in each of my environments? I have installed some libraries through the base environment in ubuntu but I can't import these in my new conda environment.\n\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1076,"Q_Id":59252973,"Users Score":1,"Answer":"To my best understanding:\nYou need ipykernel in each of the environments so that jupyter can import the other library.\nIn my case, I have a new environment called TensorFlow, then I activate it and install the ipykernel, and then add it to jupyter kernelspec. Finally I can access it in jupyter no matter the environment is activated or not.","Q_Score":3,"Tags":"python,anaconda,conda,windows-subsystem-for-linux,jupyter-lab","A_Id":68878419,"CreationDate":"2019-12-09T16:29:00.000","Title":"conda environment: does each new conda environment needs a new kernel to work? How can I have specific libraries for all my environments?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list of country ISO codes and a list of corresponding values. I would like to make a heatmap of the world where each country has a color representing a high or low value on some color scale. What is the best way to do this in python? For example the list of ISO codes might be ['GBR', 'USA'] and the value [0.1,0.2].","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":59256815,"Users Score":0,"Answer":"Try to master \"folium\" library, It will help you a lot with map things.","Q_Score":0,"Tags":"python,data-visualization","A_Id":59257065,"CreationDate":"2019-12-09T21:21:00.000","Title":"Given a list of country ISO codes and corresponding values, make a heatmap of a worldmap in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After updating to Spyder 4.0.0 (from Spyer 3.7) I get following error on scripts that worked fine before:\nFile \"C:\\Users\\Usuario\\Anaconda3\\lib\\zipfile.py\", line 1395, in getinfo\n    'There is no item named %r in the archive' % name)\nKeyError: \"There is no item named '[Content_Types].xml' in the archive\"\nWith python 3.7.4 I did not get this error. Now with 3.7.1 I have this issue. \nAny suggestion? where can I find the root of the issue?\nThank you.\nBest regards,","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":149,"Q_Id":59257452,"Users Score":1,"Answer":"Issue solved: the excel file was corrupted","Q_Score":0,"Tags":"python,spyder","A_Id":59272780,"CreationDate":"2019-12-09T22:15:00.000","Title":"Key error after updating Spider and Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on school's project about Outlier detecttion. I think i will create my own small dataset and use DBSCAN to work with it. I think i will try to create a dataset that about a click on ads on a website is cheat or not. Below is detail information of the dataset that i am gona create.\nDataset Name: Cheat Ads Click detection.\n\nColumn:value\nsource: \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 (categorical) url: 0, redirect: 1, search: 2 \nvisited_before:\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(categorical) no:1, few_time: 1, fan: 2 \ntime_on_site(seconds):\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (numerical) time user working on the site before leaving by seconds.\nactive_type:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (categorical) fake_active: 0 (like they just open website but don't do anythings but click ads), normal_active: 1, real_acive: 2 (Maybe i will let it become score of active: float value from 0 to 10.)\nCheat (label): \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(categorical) no: 0, yes: 1\nMaybe i will have some more other columns like number of times user click on ads,...\nMy question is do you think that DBSCAN can work well on this dataset? If yes, can you please give me some tips to make a great dataset or to create dataset faster? And if no, please suggest me some other datasets that DBSCAN can work well with theme.\nThank you so much.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1315,"Q_Id":59257864,"Users Score":0,"Answer":"Are describing a classification problem, not a clustering problem.\nAlso that data does not have a bottom of density, does it?\nLast but not least, (A) click fraud is heavily clustered, not outliers, (B) noise (low density) is not the same as outlier (rare) and (C) first get the data, then speculate about possible algorithms, because what if you can't get the data?","Q_Score":0,"Tags":"python,machine-learning,dataset,outliers,dbscan","A_Id":59259166,"CreationDate":"2019-12-09T22:58:00.000","Title":"Outlier detection DBSCAN","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've compiled a program I've made with Python using cx_Freeze. I want to upload this program to a GitHub repository and I'm aware that I should use the \"releases\" feature. However, my executable file comes with many other files. Additionally, GitHub doesn't process some of the files(which came with my executable) I try to upload.\nIs there even a way to do such a thing? Or is this not supposed to be done? If so, how else can I distribute my executable programs?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":223,"Q_Id":59258391,"Users Score":2,"Answer":"You should upload your \"distributables\" as a ZIP file. You should also consider building an installer that copies all of the files to their correct location on the user's file system.","Q_Score":1,"Tags":"python,exe,cx-freeze","A_Id":59258426,"CreationDate":"2019-12-10T00:03:00.000","Title":"How do I properly upload a Python executable file to 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":1,"Web Development":0},{"Question":"Does the Python formatting tool Black have an option for undoing the formatting changes it made after it's been run? Or does it assume I'm using source control and making my own backups? This is as of December 2019 and Black version 19.3b0.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":4920,"Q_Id":59258740,"Users Score":1,"Answer":"Using the --diff flag, it is possible to pipe the output to patch which then emits to stdout. A one-line shellscript can be used as a wrapper, where $1 is the file that is being formatted:\nblack --quiet --diff \"$1\" | patch --quiet -o - \"$1\"","Q_Score":13,"Tags":"python,python-black","A_Id":68121934,"CreationDate":"2019-12-10T00:57:00.000","Title":"Can I undo the formatting style changes that Black makes to my Python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently working on a program that uses a reverse geocoder and Google's street view metadata API to generate random coordinates and locate street view locations from these coordinates.  However, I only wish to obtain road cameras, not those produced from Google Trekker.  Is there a way to find or determine all Trekker locations so I can exclude them from my dataset?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":59259523,"Users Score":0,"Answer":"You could potentially check if there are any other points within a small radius (3 or so metres) as trekker locations will usually have a smaller distance between each panorama than road panoramas.\nDid some testing myself and found that the average for trekking panoramas is about 4 metres while for road panoramas the average is about 10 metres.\nThis is by no means a guaranteed solution but with tuning it could work with reasonable accuracy.","Q_Score":1,"Tags":"python,python-3.x,reverse-geocoding,google-street-view","A_Id":59344772,"CreationDate":"2019-12-10T02:53:00.000","Title":"Google Maps - How to find all Google Trekker Locations?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've compiled a Python program with cx_Freeze. The Python code itself is only 195 lines long. However, my compiled program is 500 MB. I use matplotlib, numpy, and pymsgbox and I don't know if my libraries affect my compiled program size that much.\nWhat is the reason for this unexpected file size and is there a way to reduce the size of my executable?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":892,"Q_Id":59259914,"Users Score":4,"Answer":"Part of the purpose of cx_Freeze is to bundle all the dependencies, so that the end user need not install them. numpy, matplotlib, etc. are not small dependencies, especially because they have large binary (non-Python) components. So what you are asking is not physically possible, not because of cx_Freeze limitations, but because of a contradiction between the following two requirements:\n\nend user should be able to run executable on essentially any Windows machine, including possibly one without Python, numpy, and matplotlib\ndistributed binary size should be small\n\nYou cannot satisfy both these requirements simultaneously. cx_Freeze is appropriate for the first, but not the second. If you can assume your end users already have Python, numpy, matplotlib installed (or can install seperately), and want to distribute your program such that the binary size be small, a wheel is more appropriate.","Q_Score":2,"Tags":"python,exe,cx-freeze","A_Id":59259990,"CreationDate":"2019-12-10T03:46:00.000","Title":"How to reduce cx_Freeze compiled Python executable 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running Pycharm 2019.3 on Linux Ubuntu 18.04 LTS.  I have created a virtual environment for my Pycharm project from within the IDE.  I am able to access the packages from the virtual environment when I run programs from within the IDE.  However, if I activate the virtual environment created from within Pycharm from the terminal (using source venv\/bin\/activate, resulting in the (venv) prefix on the command line), the packages I added to the virtual environment can no longer be found.  Why is this?  The (venv) prefix makes me think that I have successfully activated the virtual environment.  What can I do to use this virtual environment outside of Pycharm?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":213,"Q_Id":59260109,"Users Score":0,"Answer":"I think this is because pycharm has created a virtual environment in a different location. I think you can check both the locations with echo $VIRTUAL_ENV and check if they are the same.","Q_Score":0,"Tags":"python,pycharm,virtualenv","A_Id":59260311,"CreationDate":"2019-12-10T04:12:00.000","Title":"Cannot use virtual environment created within Pycharm from outside of the IDE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Seemingly out of the blue, I'm unable to access my datastore from my Google App Engine project.\nOne moment everything works, the next I'm getting \"StatusCode.PERMISSION_DENIED\" errors.\nI've properly installed the json key from a \"owner\" service account, set it up in my GOOGLE_APPLICATION_CREDENTIALS environment variable.\nI've even set up a new project, with the same results.\nSince yesterday, it just won't work.\nI raked the whole internet. Where shall I look?\nMost appreciated.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":85,"Q_Id":59264091,"Users Score":2,"Answer":"I found it: I was importing a third-party library that was setting the GOOGLE_APPLICATION_CREDENTIALS environment variable to its own json file, overwriting access of the main project to the owner account.","Q_Score":0,"Tags":"python,google-app-engine,google-cloud-datastore,google-iam","A_Id":59264953,"CreationDate":"2019-12-10T09:32:00.000","Title":"Google Cloud Datastore: StatusCode.PERMISSION_DENIED with owner service account","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Is there a way to do a numpy array comprehension in Python? The only way I have seen it does is by using list comprehension and then casting the results as a numpy array, e.g. np.array(list comprehension). I would have expected there to be a way to do it directly using numpy arrays, without using lists as an intermediate step.\nAlso, is it possible to overload list operators, i.e. [ and ], so that the results is a numpy array, not a list.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3420,"Q_Id":59265151,"Users Score":0,"Answer":"A fundamental problem here is that numpy arrays are of static size whereas python lists are dynamic. Since the list comprehension doesn't know a priori how long the returned list is going to be, one necessarily needs to maintain a dynamic list throughout the generation process.","Q_Score":2,"Tags":"python,numpy,list-comprehension","A_Id":59265331,"CreationDate":"2019-12-10T10:30:00.000","Title":"Numpy array comprehension","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing stock prediction using keras.While prediction i get only one possible result.I need to view all the probability value for example,\n    input 100 120 100 120, target while training 100\n    while prediction if i give the same input it returns 120 as a output\n    So that,is there any possibility of view prediction probability value?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":59266375,"Users Score":0,"Answer":"What i've done is include a randomized feature. This way the network won't be purely deterministic","Q_Score":0,"Tags":"python,keras","A_Id":59268849,"CreationDate":"2019-12-10T11:39:00.000","Title":"How can i get all the prediction probability value?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In previous versions of Spyder, you can select lines in the editor, and only run those selected lines.\nIn Spyder 4, when you select lines and press Ctrl+Enter it executes runcell(0, '\/your\/dir\/file.py') which runs the whole code.\nHow can I run just the lines which I have selected?","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":17254,"Q_Id":59266851,"Users Score":9,"Answer":"In Spyder 4.0.1, the keyboard shortcut for 'run cell' is set to Ctrl+Return but for 'run selection' it is set to F9. You can use F9 to run a selection or if you prefer to use Ctrl+Return, you can go to Tools -> Preferences -> Keyboard shortcuts. Search for 'run selection', double click and set Ctrl+Return as the 'New shortcut'","Q_Score":15,"Tags":"python,ide,spyder,customization","A_Id":60766267,"CreationDate":"2019-12-10T12:06:00.000","Title":"How can I run selected lines in Spyder 4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In previous versions of Spyder, you can select lines in the editor, and only run those selected lines.\nIn Spyder 4, when you select lines and press Ctrl+Enter it executes runcell(0, '\/your\/dir\/file.py') which runs the whole code.\nHow can I run just the lines which I have selected?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":17254,"Q_Id":59266851,"Users Score":2,"Answer":"In Spyder 4 the keyboard shortcut to run the highlighted lines of code is F9. and if you want to use any other shortcut then you can change it from TOOLS>>PREFERENCES>>KEYBOARD SHORTCUTS then double click on any shortcut you want to change and change with your shortcut. but be very careful if you used the same shortcut that is used for any other work then for that it will remove.","Q_Score":15,"Tags":"python,ide,spyder,customization","A_Id":61645475,"CreationDate":"2019-12-10T12:06:00.000","Title":"How can I run selected lines in Spyder 4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi i am trying to install locust on windows with python version 3.7.3, using pip install locustio but getting below error.\nERROR: Could not build wheels for gevent which use PEP 517 and cannot be installed directly","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":827,"Q_Id":59267401,"Users Score":0,"Answer":"I was getting above error because Visual Studio was not installed in my machine. When I did I was able to install locust, and its working fine now.","Q_Score":1,"Tags":"python-3.7,gevent,locust","A_Id":59298246,"CreationDate":"2019-12-10T12:37:00.000","Title":"Unable to install locust on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi i am trying to install locust on windows with python version 3.7.3, using pip install locustio but getting below error.\nERROR: Could not build wheels for gevent which use PEP 517 and cannot be installed directly","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":827,"Q_Id":59267401,"Users Score":0,"Answer":"Had faced a similiar issue on MacOS.\nThe MacOS Catalina update upgraded my system python was 3.8. (Gevent works with <3.7)\nInstalling a lower version with pyenv fixed it.","Q_Score":1,"Tags":"python-3.7,gevent,locust","A_Id":66236660,"CreationDate":"2019-12-10T12:37:00.000","Title":"Unable to install locust on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a countdown timer for a game in Python. My problem is I could only find code that uses time.sleep(), which pauses the entire code. Is there a way to make a countdown timer, for example, from 60 seconds. Is it possible to use millis()?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":546,"Q_Id":59268193,"Users Score":0,"Answer":"time.sleep() makes your program wait some time and not do anything.\nThe way it's usually done is to use something like time.time() to get the current time and as your title says: 'count down' from there using your loop and getting the difference between the start value and the current value of time.time(). If it's greater than your desired value, then just simply break out of the loop.","Q_Score":0,"Tags":"python","A_Id":59268251,"CreationDate":"2019-12-10T13:20:00.000","Title":"How do I make a countdown timer in Python without importing time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"It seems the paths are relative to the root package. Should I define the project folder as the source root of the Intellij module, instead of the package folder?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":166,"Q_Id":59269256,"Users Score":1,"Answer":"Yes, Setting the project folder as the root will change the paths to be relative to that folder","Q_Score":1,"Tags":"python-3.x,intellij-idea","A_Id":59269363,"CreationDate":"2019-12-10T14:16:00.000","Title":"How to make Intellij (19.3) to perform absolute auto imports for 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":"It seems the paths are relative to the root package. Should I define the project folder as the source root of the Intellij module, instead of the package folder?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":166,"Q_Id":59269256,"Users Score":1,"Answer":"Press Ctrl+Alt+Shift+S.\nClick on Proj. Settings \/ Modules\nClick on  \/ Sources tab\nSet as Source only the project root folder and mark as Excluded all folders that should not be considered as source or indexed.","Q_Score":1,"Tags":"python-3.x,intellij-idea","A_Id":59269367,"CreationDate":"2019-12-10T14:16:00.000","Title":"How to make Intellij (19.3) to perform absolute auto imports for 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":"You can specify the Python version with a flag (pip install --python-version 3.6 ...), but you can't seem to specify whether you want to install a module that is 32-bit or 64-bit.  I have some theories, but its behavior is unclear to me on this point.\nTo be more specific, I want to use PIP.exe to install a module in an embedded Python area (which does not have its own PIP.exe) using the -t flag to specify the location.\nUpdate:  What seems to be the case is that a 32-bit Pip installs to 32-bit Pythons, and a 64-bit Pip installs for 64-bit Pythons.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":805,"Q_Id":59271638,"Users Score":1,"Answer":"You can specify the Python version with a flag,\n\nYou cannot. Option -t for pip install sets the target directory, not Python version.\n\nbut you can't seem to specify whether you want to install a module that is 32-bit or 64-bit.\n\npip is a Python script, it runs under a Python interpreter and the interpreter certainly knows if it's 32- or 64-bit.\n\nTo be more specific, I want to use PIP.exe to install a module in an embedded Python area\n\nYou can download packages for a different (from the current Python\/pip) hardware platform, OS and Python version but you cannot install them. To install packages you must have a compatible pip. So first thing is to install pip for said embedded Python.","Q_Score":1,"Tags":"python,pip","A_Id":59272867,"CreationDate":"2019-12-10T16:27:00.000","Title":"If using the -t option, how does PIP know if the Python is 32-bit or 64-bit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tried to google it up but haven't found the exact thing I need and I got stuck.\nI have written a Python3.7 script (that uses some external libraries) on Linux. This is just a single module + dependencies.\nI need to pack it, preferably to a single .exe file and send it to a Windows user. The file is to be used on Windows system. The user won't have Python installed nor can I expect them to do a lot of setup work.\nWhat would be the simplest way to pack the code (preferably with a cross-compiling, so that I don't need to use Windows) and minimize the amount of setup the Windows user will have to do?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":762,"Q_Id":59271836,"Users Score":0,"Answer":"For example you have a file called index.py which is  a calculator program. Your question is how you can convert it to .exe file.\n\ngo to cmd and type command: pip install pyinstaller\nindex.py is in \"C:\\\" so type command:  cd \"C:\\\"\ncommand: pyinstaller index.py \n\nThere you can find a folder named dist. In that folder you can find a folder named index . So there is your programs .exe file.\nGood luck!","Q_Score":0,"Tags":"python-3.x,linux,windows,cross-platform","A_Id":59272192,"CreationDate":"2019-12-10T16:38:00.000","Title":"The simplest way to pack python3 script with dependencies into exe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've tried to google it up but haven't found the exact thing I need and I got stuck.\nI have written a Python3.7 script (that uses some external libraries) on Linux. This is just a single module + dependencies.\nI need to pack it, preferably to a single .exe file and send it to a Windows user. The file is to be used on Windows system. The user won't have Python installed nor can I expect them to do a lot of setup work.\nWhat would be the simplest way to pack the code (preferably with a cross-compiling, so that I don't need to use Windows) and minimize the amount of setup the Windows user will have to do?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":762,"Q_Id":59271836,"Users Score":3,"Answer":"Building on Artashes' answer, PyInstaller is in fact currently the best tool to compile Python scripts to exe.  \nBut it is not as simple, most of the time, as he says.\nShould you have external files used in your script, for example, there is more work to be provided to get a compilation to work. In the same manner, some third-party modules (such as PyQt5 or sounddevice) require a little more work.  \nI recommend you read the PyInstaller documentation carefully and make sure to read the part about specfiles. Any time I compile a script to an exe I first make a specfile using PyInstaller. I then fill out the specfile to add all problematic dependencies and external files.  \nAt this step you are rarely done. Most of the time one or more of your imports requires manual adding or modifying of the dist folder in order to make things work (for Qt you need to move the Qt5Core.dll to another folder for example).  \nIn other words the general steps are as follow:\n\nMake a specfile using PyInstaller  \nFill out the specfile  \nTry to compile.\nIf it works, create a script to automate the compilation. You are done.\n\nIf not:\n\nCheck to see what's not working (missing dll, files in the wrong place)  \nFix it in the automation script.\n\nHowever\nPyInstaller works on all platforms BUT it can only compile for the platform it is launched on. In other words using PyInstaller on Windows will create an exe and doing it on Linux will create a binary. Unfortunately there is only one workaround that I know of: Most people (me included) ressort to virtual machines to compile for specific platforms. If you are on linux, install Virtualbox, install a Windows OS and run PyInstaller from the VM to create an exe.","Q_Score":0,"Tags":"python-3.x,linux,windows,cross-platform","A_Id":59272768,"CreationDate":"2019-12-10T16:38:00.000","Title":"The simplest way to pack python3 script with dependencies into exe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Do you know if it's possible to create a role\/user for the Postgresql database from within Python code?\nI would prefer to use asyncpg library, since my program is based on asynchronous code, but if there are better libraries for this specific task, I don't mind using them.\nI already have a pre-installed database on my server machine, so another possibility would be to just run the Shell command from withing the Python program to create a role. However, I am not sure if you can create a role in just one Shell line.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":898,"Q_Id":59272516,"Users Score":1,"Answer":"After some digging, the answer appeared to be very straightforward: \npool.execute(\"CREATE ROLE name ...\")","Q_Score":2,"Tags":"python,postgresql,powershell,roles,asyncpg","A_Id":59272865,"CreationDate":"2019-12-10T17:23:00.000","Title":"Create PostgreSQL Role\/User from within Python program","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have downloaded Python 3.8 on my Ubuntu 16.04 and if i write python3.8 it shows it is present, but when I write python --version I am getting my old Python version which was 3.5","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":25784,"Q_Id":59272666,"Users Score":1,"Answer":"Everything depends on how you installed the python3.8.\nMany methods wouldn't update default symlinks for you.\nIf you do something like:\nsudo ln -s \/usr\/bin\/python3.8 \/usr\/local\/bin\/python and run python --version afterward it should solve your issue.\nIf you python3.8 binary is not in \/usr\/bin\/python3.8 update your symlink path accordingly.\nKeep in mind that some apps dependent on specific features of the lower python version might not work correctly. With Python3 the probability is low though.","Q_Score":10,"Tags":"python,python-3.x,ubuntu","A_Id":59272758,"CreationDate":"2019-12-10T17:34:00.000","Title":"Installed Python 3.8 on Ubuntu, but it's not the default","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am interested in porting some of my old fractal imaging programs over from Borland C to python.  In Borland C, the putpixel command would place a specified color pixel within a rasterized graphical field.  Is there a simple way to do this in matplotlib?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":59273850,"Users Score":0,"Answer":"After posting this I discovered that there is a putpixel command in PIL (Python Imaging Library), which has tools for dealing with pixel oriented graphics.  Matplotlib can also do the job as suggested by the answer above.","Q_Score":1,"Tags":"python,linux,windows,matplotlib,plot","A_Id":59314615,"CreationDate":"2019-12-10T19:08:00.000","Title":"Is there a Matplotlib equivalent to the Borland C command putpixel?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a hotkey ( or a command you can assign one to ) in vs code to switch the cursor between a python interactive window and an active editor widnow?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1469,"Q_Id":59276645,"Users Score":4,"Answer":"CTRL+1 and CTRL+2 will switch between groups. So if you have the interactive window in one group and your code in another, you can uses these shortcuts to switch between them.","Q_Score":5,"Tags":"python,visual-studio-code","A_Id":59294546,"CreationDate":"2019-12-10T23:06:00.000","Title":"Hotkey in vs code to switch between python interactive window and active editor?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I have a dataframe I sorted so the index is not in order so I want to reorder the index so that sorted values have an index that is sequential I have not been able to figure this out should I remove the index or is there a way to set the index? When I reindex it should sorts by the index which unsorts by index.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":762,"Q_Id":59276899,"Users Score":-1,"Answer":"df=df.reset_index(drop=True)? \u2013 ansev 1 min ago","Q_Score":0,"Tags":"python,pandas","A_Id":59276925,"CreationDate":"2019-12-10T23:36:00.000","Title":"Pandas set index or reindex without changing the order of the data frame","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python I have 2>3 == False which gives False. But I'm expecting True. If I use parenthesis i.e (2>3) == False then I'm getting True. What is the theory behind this?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":68,"Q_Id":59278084,"Users Score":1,"Answer":"In Python, 2 > 3 == False is evaluated as 2 > 3 and 3 == False.\nThis para from the Python reference should clarify:\n\nUnlike C, all comparison operations in Python have the same priority,\n  which is lower than that of any arithmetic, shifting or bitwise\n  operation.\nComparisons can be chained arbitrarily, e.g., x < y <= z is equivalent\n  to x < y and y <= z, except that y is evaluated only once (but in both\n  cases z is not evaluated at all when x < y is found to be false).","Q_Score":4,"Tags":"python,python-3.x,boolean-expression","A_Id":59278191,"CreationDate":"2019-12-11T02:31:00.000","Title":"Basic Boolean expression in Python producing surprising results","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to build a code that checks whether a given object is an np.array() in python. \nif isinstance(obj,np.array()) doesn't seem to work.\nI would truly appreciate any help.","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":3934,"Q_Id":59279803,"Users Score":8,"Answer":"isinstance(obj, numpy.ndarray) may work","Q_Score":2,"Tags":"python,arrays","A_Id":59279941,"CreationDate":"2019-12-11T06:13:00.000","Title":"How to check if an object is an np.array()?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to build a code that checks whether a given object is an np.array() in python. \nif isinstance(obj,np.array()) doesn't seem to work.\nI would truly appreciate any help.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3934,"Q_Id":59279803,"Users Score":0,"Answer":"The type of what numpy.array returns is numpy.ndarray.  You can determine that in the repl by calling type(numpy.array([])).  Note that this trick works even for things where the raw class is not publicly accessible.  It's generally better to use the direct reference, but storing the return from type(someobj) for later comparison does have its place.","Q_Score":2,"Tags":"python,arrays","A_Id":59279975,"CreationDate":"2019-12-11T06:13:00.000","Title":"How to check if an object is an np.array()?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Spyder 4.0 just released and I am not able to move the panels for my desired layout.\nHow can I do this?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":3310,"Q_Id":59280837,"Users Score":3,"Answer":"press CTRL+SHIFT+F5 or goto view => lock panes and toolbars & than turn it off... thn move ur panel","Q_Score":9,"Tags":"python,ide,spyder","A_Id":66821804,"CreationDate":"2019-12-11T07:36:00.000","Title":"How to move the panels in Spyder 4.0?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Spyder 4.0 just released and I am not able to move the panels for my desired layout.\nHow can I do this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3310,"Q_Id":59280837,"Users Score":12,"Answer":"You can enable panel moving by switching off the option in View > Lock panes and toolbars, or pressing Ctrl+Shift+F5. From there, you can drag around panes as you wish. \nWhen you're done, you can lock them again with the same process. If you want to save the current layout, you can use Alt+Shift+S. Also, in the View > Window Layouts menu, you can see and launch preset layouts that mirror other editors such as R Studio and Matlab.","Q_Score":9,"Tags":"python,ide,spyder","A_Id":59287311,"CreationDate":"2019-12-11T07:36:00.000","Title":"How to move the panels in Spyder 4.0?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Today I was trying to implement an object detection API in Tensorflow. After carrying out the training process, I was trying to run the program to detect objects in webcam. As I was running it, the following message was printed in the terminal:\n\nAllocator (GPU_0_bfc) ran out of memory trying to allocate 2.05GiB\n  with freed_by_count=0. The caller indicates that this is not a\n  failure, but may mean that there could be performance gains if more\n  memory were available\n\nDue to the performace issue it seems I am getting a lot of false positives.\nHow can we calculate beforehand the memory required to run this program, or any program?\nI am not asking how much memory it is using, which we can find out. I am using Python.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2441,"Q_Id":59282135,"Users Score":3,"Answer":"In Object Detection, most of the Layers used will be CNNs and the Calculation of Memory Consumption for CNN is explained below. You can follow the same approach for other layers of the Model.\n\nFor example,\n  consider a convolutional layer with 5 \u00d7 5 filters, outputting 200\n  feature maps of size 150 \u00d7 100, with stride 1 and SAME padding. If the\n  input is a 150 \u00d7 100 RGB image (three channels), then the number of\n  parameters is (5 \u00d7 5 \u00d7 3 + 1) \u00d7 200\n  = 15,200 (the +1 corresponds to the bias terms), which is fairly small compared to a fully connected layer.7 However, each of the 200 feature\n  maps contains 150 \u00d7 100 neurons, and each of these neurons needs to\n  compute a weighted sum of its 5 \u00d7 5 \u00d7 3 = 75 inputs: that\u2019s a total of\n  225 million float multiplications. Not as bad as a fully con\u2010nected\n  layer, but still quite computationally intensive. Moreover, if the\n  feature maps are represented using 32-bit floats, then the\n  convolutional layer\u2019s output will occupy 200 \u00d7 150 \u00d7 100 \u00d7 32 = 96\n  million bits (about 11.4 MB) of RAM.8  And that\u2019s just for one\n  instance! If a training batch contains 100 instances, then this layer\n  will use up over 1 GB of RAM!\n\nMore understanding about Memory Consumption can be found from the below Question and the respective Answer:\nQuestion: \n\nConsider a CNN composed of three convolutional layers, each with 3 \u00d7 3\n  kernels, a stride of 2, and SAME padding. The lowest layer outputs 100\n  feature maps, the middle one outputs 200, and the top one outputs 400.\n  The input images are RGB images of 200 \u00d7 300 pixels. What is the total\n  number of parameters in the CNN? If we are using 32-bit floats, at\n  least how much RAM will this network require when making a prediction\n  for a single instance? What about when training on a mini-batch of 50\n  images?\n\nAnswer is mentioned below:\n\nLet\u2019s compute how many parameters the CNN has. Since its first\n  convolutional layer has 3 \u00d7 3 kernels, and the input has three\n  channels (red, green, and blue), then each feature map has 3 \u00d7 3 \u00d7 3\n  weights, plus a bias term. That\u2019s 28 parame\u2010 ters per feature map.\n  Since this first convolutional layer has 100 feature maps, it has a\n  total of 2,800 parameters. The second convolutional layer has 3 \u00d7 3\n  kernels, and its input is the set of 100 feature maps of the previous\n  layer, so each feature map has 3 \u00d7 3 \u00d7 100 = 900 weights, plus a bias\n  term. Since it has 200 feature maps, this layer has 901 \u00d7 200 =\n  180,200 parameters. Finally, the third and last convolutional layer\n  also has 3 \u00d7 3 kernels, and its input is the set of 200 feature maps\n  of the previous layers, so each feature map has 3 \u00d7 3 \u00d7 200 = 1,800\n  weights, plus a bias term. Since it has 400 feature maps, this layer\n  has a total of 1,801 \u00d7 400\n  = 720,400 parameters. All in all, the CNN has 2,800 + 180,200 + 720,400 = 903,400 parameters. Now let\u2019s compute how much RAM this\n  neural network will require (at least) when making a prediction for a\n  single instance. First let\u2019s compute the feature map size for each\n  layer. Since we are using a stride of 2 and SAME padding, the\n  horizontal and vertical size of the feature maps are divided by 2 at\n  each layer (rounding up if necessary), so as the input channels are\n  200 \u00d7 300 pixels, the first layer\u2019s feature maps are 100 \u00d7 150, the\n  second layer\u2019s feature maps are 50 \u00d7 75, and the third layer\u2019s feature\n  maps are 25 \u00d7 38. Since 32 bits is 4 bytes and the first convolutional\n  layer has 100 feature maps, this first layer takes up 4 x 100 \u00d7 150 \u00d7\n  100 = 6 million bytes (about 5.7 MB, considering that 1 MB = 1,024 KB\n  and 1 KB\n  = 1,024 bytes). The second layer takes up 4 \u00d7 50 \u00d7 75 \u00d7 200 = 3 million bytes (about 2.9 MB). Finally, the third layer takes up 4 \u00d7 25\n  \u00d7 38 \u00d7 400 = 1,520,000 bytes (about 1.4 MB). However, once a layer has\n  been computed, the memory occupied by the previous layer can be\n  released, so if everything is well optimized, only 6 + 9 = 15 million\n  bytes (about 14.3 MB) of RAM will be required (when the second layer\n  has just been computed, but the memory occupied by the first layer is\n  not released yet). But wait, you also need to add the memory occupied\n  by the CNN\u2019s parameters. We computed earlier that it has 903,400\n  parameters, each using up 4 bytes, so this adds 3,613,600 bytes (about\n  3.4 MB). The total RAM required is (at least) 18,613,600 bytes (about 17.8 MB).\n\nFor more information, refer \"Memory Requirements\" Section of \"Chapter 13, Convolutional Neural Networks\" of the Book, \"Hands on Machine Learning with Scikit-Learn and Tensorflow\" (pdfs are availble online).","Q_Score":0,"Tags":"python,tensorflow,memory,memory-management","A_Id":59893011,"CreationDate":"2019-12-11T09:06:00.000","Title":"How do we approximately calculate how much memory is required to run a program?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello my fellow programmers,\nI am writing a program which reads 90GB of images into a python list. But my Hardware only has 8GB RAM, thus the program gets stuck. I was wondering if a python list can handle this problem itself by writing on the hard disk or something like that. Otherwise, how could I solve this problem without upgrading the RAM to 128GB?\nEDIT: I need to have all images in one list at one time\nBACKGROUND INFORMATION: I am making a neural network which colors black and white images","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":92,"Q_Id":59282415,"Users Score":0,"Answer":"Is it absolutely necessary to have all of the images in the memory at the same time? You could either process the images in batches or adjust the pipeline to use one image at a time.\nYou can also use a swap partition to supply additional memory for your process.","Q_Score":0,"Tags":"python","A_Id":59282755,"CreationDate":"2019-12-11T09:22:00.000","Title":"Python Memory Overflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm trying to build a bot to automate some actions in a mobile game that I'm running on my pc through Bluestacks.\nMy program takes a screenshot of the window, looks for certain button templates in the image and returns their coordinates.\nI would now like to be able to send a click event to the window at those coordinates, but since I would also like to do other things while the bot runs in the background I'm looking for a way to send the mouse event directly to the window (even if it's minimized\/in the background), without influencing the movement of the mouse while I'm doing other stuff or bringing the window to the foreground\/unminimizing it. Is this possible?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9394,"Q_Id":59285854,"Users Score":0,"Answer":"If you really want to automate bluestacks, you could use adb (which could do the assigned work like clicking a button, even when the window is minimized) you could use\nPpadb (pure Python adb module) for automating it. And ppadb could be used in mac and Linux also, but win32 is restricted to Windows.","Q_Score":4,"Tags":"python,android-emulator,mouseevent,bluestacks","A_Id":65160153,"CreationDate":"2019-12-11T12:28:00.000","Title":"Is there a way to send a click event to a window in the background in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running some test scripts and while it is running at the background I want to do my other jobs on excel or another web page? But sometimes I got same errors since the selenium can not find the specific field to click? What can be the reason? Is it not working well at the background?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":209,"Q_Id":59287278,"Users Score":0,"Answer":"To run selenium concurrently while i am working on other projects i just run it in a headless mode, that tends to work most of the time. \nThe thing is that you have to have completed the building of the script before you do this otherwise debugging could be a nightmare if you are new or fairly new to selenium web-driver","Q_Score":0,"Tags":"python,selenium,testing,automation,automated-tests","A_Id":59287821,"CreationDate":"2019-12-11T13:51:00.000","Title":"Can selenium python work good at background while I am doing other processes on main page?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been trying to install Pandas on my Azure App Service (running Flask) for a long time now but nothing seems to work.\nI tried to use wheel, created a wheelhouse directory manually and tried to install the relevant Pandas .whl file (along with its dependent packages) but it still doesn't work. This approach gives me the following error - \n\"Could not find a version that satisfies the requirement\"\n\"No matching distribution found for ...\"\nA simple \"pip install pandas\" also doesn't work - when I do this, in my Kudu Bash client the command gets stuck on \"Cleaning up..\" and nothing gets installed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":537,"Q_Id":59287420,"Users Score":0,"Answer":"I solved this by using the SSH terminal instead of the Kudu terminal. I find no reason why it was not working in the Kudu Remote Execution terminal, but using \"pip install pandas\" in Azure's SSH terminal solved it.","Q_Score":0,"Tags":"python,azure,azure-web-app-service","A_Id":59301763,"CreationDate":"2019-12-11T13:58:00.000","Title":"Azure Installing Pandas Module","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to connect a R Shiny app to a python Flask app, so that I can run my Shiny app on R studio connect and access my Flask app which in turn runs on localhost.\nMy initial attempt was a GET request from shiny to Flask to bring the html code onto my R site. This worked for displaying the html code, but sending elements back to the python side e.g. forms or pressed buttons are more complicated.\nI was wondering whether there are other solutions that do not involve interference with the underlying network system such as IP forwarding?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":274,"Q_Id":59287572,"Users Score":0,"Answer":"Just in case anyone will ever run into a similar question. In the end I put the url generated by Flask in an R shiny iframe.","Q_Score":0,"Tags":"python,html,r,flask,shiny","A_Id":59627760,"CreationDate":"2019-12-11T14:06:00.000","Title":"How to access a python Flask app through R shiny?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am running venv based kernel and I am getting trouble in returning a proper answer from which python statement from my JupyterLab notebook. When running this command from terminal where I have my venv activated it works (it returns a proper venv path ~\/venvs\/my_venv\/bin\/python), but it does not work in the notebook.\n!which python\nreturns the host path:\n\/usr\/bin\/python\nI have already tried with os.system() and subprocess, but with no luck.\nDoes anyone know how to execute this command from the Jupyter notebook?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":763,"Q_Id":59289259,"Users Score":2,"Answer":"It sounds like you are starting the virtual environment inside the notebook, so that process's PATH doesn't reflect the modifications made by the venv. Instead, you want the path of the kernel that's actually running: that's sys.executable.","Q_Score":0,"Tags":"python,python-3.x,jupyter-notebook,jupyter-lab","A_Id":59289563,"CreationDate":"2019-12-11T15:38:00.000","Title":"JupyterLab - how to find out which python venv is my session running on?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am running venv based kernel and I am getting trouble in returning a proper answer from which python statement from my JupyterLab notebook. When running this command from terminal where I have my venv activated it works (it returns a proper venv path ~\/venvs\/my_venv\/bin\/python), but it does not work in the notebook.\n!which python\nreturns the host path:\n\/usr\/bin\/python\nI have already tried with os.system() and subprocess, but with no luck.\nDoes anyone know how to execute this command from the Jupyter notebook?","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":763,"Q_Id":59289259,"Users Score":-1,"Answer":"maybe it's because you are trying to run the command outside venv\ntry source \/path\/to\/venv\/bin\/active first and then try which python","Q_Score":0,"Tags":"python,python-3.x,jupyter-notebook,jupyter-lab","A_Id":59290184,"CreationDate":"2019-12-11T15:38:00.000","Title":"JupyterLab - how to find out which python venv is my session running on?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to split characters in a string which contains alphabets made out of special characters. The Idea is to split the characters in the most logical manner.\nE.g. if the word is \"Football\" it can be written as F{}{}tball. The ideal setting should be that it is split as 'F','{}','{}'... but if I try to split it using each character then it will split like 'F','{','}'....Also there is the issue that '}{' also looks like an H, which is also a character and '{' also looks like a C.\nI have thought about defining a Dictionary for these kinds of symbolic alphabets but it does not solve the core problem. Any advice is appreciated. \ni am working on Python and need theses characters as part of string analysis.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":59290110,"Users Score":0,"Answer":"Yes, your first step is likely to define your allowable character replacements.  Your next problem is to write a parser that can convert any sequence of special characters into the various possible translations, which is not a deterministic process.  After that step, you need to compare the resulting \"words\" with your acceptable lexicon to figure out what word was intended by the special characters.\nThere are a lot of solutions floating around for doing this translation on digit strings, with a=1, b=2, ... z=26.  With this problem, 121 can parse as aba, av, or la.  You can take their principles and apply those to your problem.  The general idea is to use a bit of dynamic programming and backtracking to handle the ambiguities you'll have in the formal grammar.\nWhen I've done something this restricted, I've done it with a translation dict and recursion on the remaining string to walk through the input; if I work down to the empty string, I have a valid translation; if I get stuck before then, I return failure and let the backtracking look for the next option.  You could also do the equivalent with a state transition graph.","Q_Score":0,"Tags":"python,algorithm,split","A_Id":59294969,"CreationDate":"2019-12-11T16:24:00.000","Title":"Custom String Split Algorithm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am not sure how can I describe all the steps that I am taking but basically my question is simple:\nI use same code, same data from text file, gather some statistics about that data and then use umap for 2D reduction.\nIs it normal to have different graphs when I plot the result? \nI use scikit-learn, umap-learn, ggplot2.\nThe continuation of the problem is when I use hdbscan. Because every time I run the code, the plot is different, then cluster size and clusters become different and so on. I am wondering if this is something expected or not, basically.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1264,"Q_Id":59290251,"Users Score":3,"Answer":"Yes it is. Dimensions reduction algorithms like tSNE and uMAP are stochastic, so every time you run the clustering and values will be different. If you want to keep the same graph you need to set a common seed. You can achieve that in R by setting the seed (e.g. set.seed(123)) before calling uMAP (or set flag if the function allows that). np.random.seed(123) should work in python scikit.","Q_Score":1,"Tags":"python,r,ggplot2,scikit-learn","A_Id":59291330,"CreationDate":"2019-12-11T16:34:00.000","Title":"Is it normal to get different graphs for same data after umap","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a tensorflow model with my truth data in the shape (N, 32, 32, 5) ie. 32x32 images with 5 channels.\nInside the loss function I would like to calculate, for each pixel, the sum of the values of the neighboring pixels for each channel, generating a new (N, 32, 32, 5) tensor.\nThe tf.nn.pool function does something similar but not exactly what I need. I was trying to see if tf.nn.conv2d could get me there but I'm not sure what I'd need to use as the filter parameter in this case.\nIs there a specific function for this? Or can I use conv2d somehow?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":188,"Q_Id":59290785,"Users Score":0,"Answer":"A new convolutional layer with the filter size of 3x3 and filters initialized to 1 will do the job. Just be careful to declare this special filter as an untrainable variable otherwise your optimizer would change its contents. Additionally, set padding to \"SAME\" to get the same size output from that convolutional layer. The pixels at the edges will have zero neigbors in that case.","Q_Score":1,"Tags":"python,tensorflow","A_Id":59290915,"CreationDate":"2019-12-11T17:07:00.000","Title":"Sum of neighbors in tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I upgraded to Spyder 4 using Anaconda today, but I got an error saying \"You have missing dependencies! qtconsole >=4.6.0: 4.5.1. (NOK).\nI tried upgrading qtconsole and Spyder using conda, but neither of these solved the problem.\nNote: I'm on Python 3.7","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2030,"Q_Id":59295458,"Users Score":0,"Answer":"It is possible that the update broke something within Spyder.\nYou can uninstall Spyder through the Anaconda Navigator, then click the gear on Anaconda Navigator to install Spyder again using the previous version.","Q_Score":2,"Tags":"python,dependencies,anaconda,spyder","A_Id":66037783,"CreationDate":"2019-12-11T23:05:00.000","Title":"Missing Spyder Dependencies qtconsole >= 4.6.0: 4.5.1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been trying to look for ways to call my python script from my perl script and pass the database handle from there while calling it. I don't want to establish another connection in my python script and just use the db handle which is being used by the perl script. Is it even possible and if yes then how?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":59298237,"Users Score":0,"Answer":"There answer is that almost all databases (Oracle, MySQL, Postgresql) will NOT allow you to pass open DB connections between processes (even parent\/child). This is a limit on the databases connection, which will usually be associated with lot of state information.\nIf it was possible to 'share' such a connection, it will be a challenge for the system to know where to ship the results for queries sent to the database (will the result go to the parent, or to the child ?).\nEven if it is possible somehow to forward connection between processes, trying to pass a complex object (database connection is much more the socket) between Perl (usually DBI), and Python is close to impossible.\nThe 'proper' solution is to pass the database connection string, username, and password to the Python process, so that it can establish it's own connection.","Q_Score":0,"Tags":"python,database,perl","A_Id":59437378,"CreationDate":"2019-12-12T05:29:00.000","Title":"Can a db handle be passed from a perl script to a python script?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to write TCP SYN scan (half-open scanning) in python without using driver? I want to implement this kind of scanning in python without using scapy as I know it requires installing a driver.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":195,"Q_Id":59301532,"Users Score":0,"Answer":"If you're on Linux, BSD, OSX, yeah sure, using Raw sockets.\nI assume if you talk about a \"driver\" it means you're on Windows in which case you will be restricted (can't access layer 2), and will require administrative privileges anyways.\nIn any case, you can still use Scapy without any \"driver\" (libpcap-based) installed. Some functions will be disabled","Q_Score":0,"Tags":"python,scapy,nmap,port-scanning","A_Id":59310650,"CreationDate":"2019-12-12T09:35:00.000","Title":"Python-TCP SYN scan without using driver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to use mysql with python SQLAlchemy but while installing mysqlclient for python its giving error. kindly check details below:\n\nI'm running this on Windows 10 64 bit and Anaconda Python 3.7.4\nI have tried by installing another python version as well but no luck.\nTried to install MYSQL connector c++ as well. but still not working.\nIf I run code 'pip install mysqlclient'\n\nmysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":512,"Q_Id":59302008,"Users Score":0,"Answer":"I just got an answer by looking at other options mentioned here.\nActually mistake was that,\n\nI have installed Python 3.7.4 with 32 bits on 64bits machine.\nCode was looking for below path but it was going to the wrong path in program files instead of program files(x86)\n\nC:\\Program Files (x86)\\MySQL\\MySQL Connector C 6.1\\lib\nI have installed a new Python with 3.7 with 64 bits and also while installing MySQL connector I have changed the path of installation to the above-mentioned path and now it's working fine.\nThank you, everyone, for your time and help","Q_Score":0,"Tags":"python,mysql","A_Id":59384975,"CreationDate":"2019-12-12T10:01:00.000","Title":"pip install mysqlclient on win64 not working giving error 'Cannot open file: 'mysql.h'","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to programming and following a course where I must install Tensorflow. The issue is that I'm using Python 3.8 which I understand isn't supported by Tensorflow.\nI've downloaded Python 3.6 but I don't know how to switch this as my default version of python.\nWould it be best to set up a venv using python 3.6 for my program and install Tensorflow in this venv?\nAlso, I using Windows and Powershell.","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":25416,"Q_Id":59302043,"Users Score":0,"Answer":"it would have been nice if you would have the share the error screenshot\nthough as per i got the case \ntensorflow work in both 3.8 and 3.6 just you have to check that you have 64bit version not 32 bit\nyou can acess both version from thier respective folder no need to install a venv","Q_Score":11,"Tags":"python,tensorflow","A_Id":59302173,"CreationDate":"2019-12-12T10:03:00.000","Title":"Error when installing Tensorflow - Python 3.8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to programming and following a course where I must install Tensorflow. The issue is that I'm using Python 3.8 which I understand isn't supported by Tensorflow.\nI've downloaded Python 3.6 but I don't know how to switch this as my default version of python.\nWould it be best to set up a venv using python 3.6 for my program and install Tensorflow in this venv?\nAlso, I using Windows and Powershell.","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":25416,"Q_Id":59302043,"Users Score":0,"Answer":"If you don't want to use Anaconda or virtualenv, then actually multiple Python versions can live side by side. I use Python38 as my default and Python35 for TensorFlow until they release it for Python38. If you wish to use the \"non-default\" Python, just invoke with the full path of the python.exe (or create a shortcut\/batch file for it). Python then will take care of using the correct Python libs for that version.","Q_Score":11,"Tags":"python,tensorflow","A_Id":59314456,"CreationDate":"2019-12-12T10:03:00.000","Title":"Error when installing Tensorflow - Python 3.8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question regarding SSL verification within the requests library for Python, but I believe it to me more general than that.\nI am currently ignoring certificate verification because the third party API I need to connect to is using a self-signed certificate.\nWhat are the implications for turning SSL verification off in requests? And what are the implications for not verifying SSL certificates in the real-world. Can I gaurantee the data transported is secure\/encrypted?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1626,"Q_Id":59303814,"Users Score":2,"Answer":"Can I gaurantee the data transported is secure\/encrypted?\n\nThe data is encrypted (this is TLS confidentiality guarantee) but since you did not authenticate the remote part (if you disable certificate validation or bypass all errors) you could be as well sending the encrypted content to anyone, including an attacker, which of course on his side will read it in plain, as the TLS handshake succeeded if you do not validate the remote party.\nTLS provides multiple features, two major ones being authentication and confidentiality. They are orthogonal (you can have one without the other) but it may not be so useful to not have all of them.\nContrary to natural thinking, authentication is more important than confidentiality because if you have no insurance about who is the remote party, what do you gain by sending it encrypted? Nothing.","Q_Score":3,"Tags":"python-3.x,ssl,python-requests,ssl-certificate,urllib3","A_Id":59308892,"CreationDate":"2019-12-12T11:42:00.000","Title":"What are the implications of ignoring SSL certificate verification?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question regarding SSL verification within the requests library for Python, but I believe it to me more general than that.\nI am currently ignoring certificate verification because the third party API I need to connect to is using a self-signed certificate.\nWhat are the implications for turning SSL verification off in requests? And what are the implications for not verifying SSL certificates in the real-world. Can I gaurantee the data transported is secure\/encrypted?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1626,"Q_Id":59303814,"Users Score":3,"Answer":"This is a security sin, as anyone could spoof this certificate and intercept your traffic. You should just add the self-signed certificate to the trusted certificate chain of the machine which is using the API.\nHow you do that depends on the operating system and specific setup, but a quick google will guide you to the right solution.","Q_Score":3,"Tags":"python-3.x,ssl,python-requests,ssl-certificate,urllib3","A_Id":59303990,"CreationDate":"2019-12-12T11:42:00.000","Title":"What are the implications of ignoring SSL certificate verification?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm reading the book \"Learning Python Design Patterns\" written by Chetan Giridhar\nand I came across a design principle called the Liskov substitution principle, which states\nthat derived classes must be able to completely substitute the base (parent) class.\nI don't think I understand this, because what's the point of writing a derived class\nif it can completely replace the base class? Doesn't it make the base class redundant?\nFrom my understanding and experience derived classes extend functionality of the base class hence should be dependent on the base class.\nWhat the author is trying to help me understand?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":269,"Q_Id":59305705,"Users Score":1,"Answer":"Derived classes should extend without replacing the functionality of old classes. Which means derived classes should be substitutable for their parent\/base classes. Moreover, they can be usable in the place of their parent classes without any unexpected behavior.\nWe can't replace the parent class's functionality but we can re-write it in the child class and for modification extend that child class onwards. It will keep us from the chain reaction that might occur in complex software by changing the parent class so we opt to duplicate it in child class and then write our desired modifications.","Q_Score":0,"Tags":"python,oop,liskov-substitution-principle","A_Id":64624407,"CreationDate":"2019-12-12T13:27:00.000","Title":"The Liskov substitution principle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are calling postgres using psycopg2 2.7.5  this way that we perform a query then perform some operation on data that we received and then we open new connection and perform another query and so on. \nUsually the query takes between 15 s to 10 min. \nOccasinally after 2 h we receive error: Python Exception : connection already closed\nWhat may be the reason for that? Data is the same and query is the same and sometimes the same query gives results back in 3 min and sometimes it gets that timeout after 2 hrs. \nI wonder if it is possible that connection is broken earlier but in python we get that information for some reason after 2 hrs? \nI doubt that there are any locks on DB at the moment when we perform a query but it may be under huge load and max number of connections may be reached (not confirmed but this is an option).\nWhat would be the best way to track down the problem? Firewall is set to 30 min timeout.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":334,"Q_Id":59305899,"Users Score":2,"Answer":"We are calling postgres using psycopg2 2.7.5 this way that we perform a query then perform some operation on data that we received and then we open new connection and perform another query and so on.\n\nWhy do you keep opening new connections?  What do you do with the old one, and when do you do it?\n\nI wonder if it is possible that connection is broken earlier but in python we get that information for some reason after 2 hrs?\n\nIn general, a broken connection won't be detected until you try to use it.  If you are using a connection pooler, it is possible the pool manager checks up on the connection periodically in the background.","Q_Score":0,"Tags":"python,postgresql,psycopg2","A_Id":59306103,"CreationDate":"2019-12-12T13:38:00.000","Title":"postgres\/psycopg2 strange timeout after 2 hrs","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to listen to an existing SQS queue through Celery.\nI have already done publishing to Queue via celery and then consuming from that queue through workers and tasks bound to that queue.\nHowever, I am unable to figure out how to consume from an SQS queue if the publisher is a non-celery Django application. There is no such information available on the internet regarding this or at least I am unable to locate it. Can someone please guide me to some documentation for doing this?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":410,"Q_Id":59306628,"Users Score":1,"Answer":"If I understood correctly what you want to do I have bad news for you - it is not possible. Celery can only consume own messages. If your Django application needs to send some task to the Celery cluster using SQS as broker, it needs to instantiate a Celery application object, and use it to send tasks.","Q_Score":1,"Tags":"python,django,celery,amazon-sqs","A_Id":59307003,"CreationDate":"2019-12-12T14:21:00.000","Title":"How to listen to already existing SQS queue with Celery and Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I want to listen to an existing SQS queue through Celery.\nI have already done publishing to Queue via celery and then consuming from that queue through workers and tasks bound to that queue.\nHowever, I am unable to figure out how to consume from an SQS queue if the publisher is a non-celery Django application. There is no such information available on the internet regarding this or at least I am unable to locate it. Can someone please guide me to some documentation for doing this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":410,"Q_Id":59306628,"Users Score":0,"Answer":"I would not use Celery. I would use boto3 directly, in a custom Django management command, to long-poll the queue and parse \/ route the incoming messages.\nCelery would give you nothing, and would only increase the complexity of implementation.","Q_Score":1,"Tags":"python,django,celery,amazon-sqs","A_Id":72195151,"CreationDate":"2019-12-12T14:21:00.000","Title":"How to listen to already existing SQS queue with Celery and Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have several binary files, which are mostly bigger than 10GB.\nIn this files, I want to find patterns with Python, i.e. data between the pattern 0x01 0x02 0x03 and 0xF1 0xF2 0xF3.\nMy problem: I know how to handle binary data or how I use search algorithms, but due to the size of the files it is very inefficient to read the file completely first. That's why I thought it would be smart to read the file blockwise and search for the pattern inside a block.\nMy goal: I would like to have Python determine the positions (start and stop) of a found pattern. Is there a special algorithm or maybe even a Python library that I could use to solve the problem?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":367,"Q_Id":59307194,"Users Score":3,"Answer":"The common way when searching a pattern in a large file is to read the file by chunks into a buffer that has the size of the read buffer + the size of the pattern - 1.\nOn first read, you only search the pattern in the read buffer, then you repeatedly copy size_of_pattern-1 chars from the end of the buffer to the beginning, read a new chunk after that and search in the whole buffer. That way, you are sure to find any occurence of the pattern, even if it starts in one chunk and ends in next.","Q_Score":0,"Tags":"python,algorithm,search,binaryfiles","A_Id":59307725,"CreationDate":"2019-12-12T14:51:00.000","Title":"How to search pattern in big binary files efficiently","Data Science and Machine Learning":0,"Database and SQL":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 any way to implement color highlights for the logs in Airflow UI (stdout logs)?\nI want to mark some logs, for example Exceptions messages in red and Success messages in green.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":473,"Q_Id":59307210,"Users Score":2,"Answer":"There is no way to do this with the standard config available in Airflow. You'd have to contribute your own code to do this.","Q_Score":1,"Tags":"python,airflow","A_Id":59320137,"CreationDate":"2019-12-12T14:51:00.000","Title":"Airflow - colored logging","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm building a telegram bot using pyTelegramBotAPI libraries, I wanted to know if there is a way to know when a user deletes a chat with my bot, so the bot will not send more messages towards that specific id.\nreading the telegram API I found nothing, can you help me?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1203,"Q_Id":59311680,"Users Score":1,"Answer":"As I know, there is no way. When you chat with a friend, is there any way to know that he\/she has deleted the chat page of you? NO.\nTelegram bot is completely similar to simple chat in this case up to\n  this date. It doesn't have considered in Telegram Bot API up to this\n  date.","Q_Score":0,"Tags":"python,telegram-bot","A_Id":59360428,"CreationDate":"2019-12-12T19:40:00.000","Title":"How to delete a Telegram user id when user delete the chat of the 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 N samples of 2D features with variable dimensions along one axis. For example:\n\nSample 1 : (100,20)\n\nSample 2 : (150,20)\n\nSample 3 : (90,20)\nIs there a way to combine all N samples into a 3D array so that the first dimension (N,?,?) denotes the sample number?\n\n\nPS: I wish to avoid padding and reshaping, and want to find a way to input the features with their dimensions intact into an LSTM network in Keras. Any other suggestions to achieve the same are welcome.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":124,"Q_Id":59314807,"Users Score":1,"Answer":"Keras does allow for variable length input to an LSTM but within a single batch all inputs must have the same length. A way to reduce the padding needed would be to batch your input sequences together based on their length and only pad up to the maximum length within each batch. For example you could have one batch with sequence length 100 and another with sequence length 150. But I'm afraid there is no way to completely avoid padding. During inference you can use any sequence length.","Q_Score":0,"Tags":"python,numpy,keras,numpy-ndarray","A_Id":59318510,"CreationDate":"2019-12-13T01:06:00.000","Title":"Concatenating 'N' 2D arrays in NumPy with varying dimensions into one 3D array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I trained a XGBClassifier for my classification problem and did Hyper-parameter tuning over huge grid(probably tuned every possible parameter) using optuna. While testing, change of random_state changes model performance metrics (roc_auc\/recall\/precision), feature_importance and even model predictions (predict_prob).   \n\nWhat does this tell me about my data?\n\nSince I have to take this model in production, how should I tackle this for model to be more robust?\n\nStay with one random_state (say default 0) which we use during cross_validation and use it on out-of-sample as well.\nDuring cross_validation, on top of each param_combination, run few random_state(say 10) and take avg model performance.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":729,"Q_Id":59318853,"Users Score":0,"Answer":"random_state parameter just helps in replicating results every time you run your model.\nSince you are using cross_validation, assuming it is k-fold, then all your data will go into train and test and the CV score will be anyways average of the number of folds you decide. I believe you can set on any random_state and quote the results from CV.","Q_Score":1,"Tags":"python,xgboost,feature-selection,xgbclassifier","A_Id":59319017,"CreationDate":"2019-12-13T08:39:00.000","Title":"Changes to model performance by changing random_state of XGBClassifier","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I trained a XGBClassifier for my classification problem and did Hyper-parameter tuning over huge grid(probably tuned every possible parameter) using optuna. While testing, change of random_state changes model performance metrics (roc_auc\/recall\/precision), feature_importance and even model predictions (predict_prob).   \n\nWhat does this tell me about my data?\n\nSince I have to take this model in production, how should I tackle this for model to be more robust?\n\nStay with one random_state (say default 0) which we use during cross_validation and use it on out-of-sample as well.\nDuring cross_validation, on top of each param_combination, run few random_state(say 10) and take avg model performance.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":729,"Q_Id":59318853,"Users Score":1,"Answer":"These are my two cents. Take the answer with a grain of salt.\nThe XGB classifier is a boosting algorithm, which naturally depends on randomness (so is a Random Forest for example).\nHence, changing seed will inherently change the training of the model and its output.\nDifferent seeds will also change the CV splits and alter further the results.\nFurther, boosting aims to reduce variance as it uses multiple models (bagging) and at the same time it reduces bias as it trains each subsequent model based on the previous models' errors (the boosting part).\nHowever, boosting models can, in principle, overfit.\nIn fact, if your base learner is not weak it will easily overfits the data and there won't be any residuals or errors for the subsequent models to build upon.\nNow, for your problem, you should first verify that you are not overfitting your model to the data.\nThen you might want to fix a certain number of seeds (you still want to be able to reproduce the results so it's important to fix them) and average the results obtained across the seeds.","Q_Score":1,"Tags":"python,xgboost,feature-selection,xgbclassifier","A_Id":59320839,"CreationDate":"2019-12-13T08:39:00.000","Title":"Changes to model performance by changing random_state of XGBClassifier","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I trained a XGBClassifier for my classification problem and did Hyper-parameter tuning over huge grid(probably tuned every possible parameter) using optuna. While testing, change of random_state changes model performance metrics (roc_auc\/recall\/precision), feature_importance and even model predictions (predict_prob).   \n\nWhat does this tell me about my data?\n\nSince I have to take this model in production, how should I tackle this for model to be more robust?\n\nStay with one random_state (say default 0) which we use during cross_validation and use it on out-of-sample as well.\nDuring cross_validation, on top of each param_combination, run few random_state(say 10) and take avg model performance.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":729,"Q_Id":59318853,"Users Score":1,"Answer":"I tend to think if the model is sensitive to the random seed, it isn't a very good model. With XGB can try and add more estimators - that can help make it more stable.\nFor any model with a random seed, for each candidate set of parameter options (usually already filtered to a shortlist of candidate), I tend to run a bunch of repeats on the same data for different random seeds and measure the difference in the output. I expect the evaluation metric standard deviation to be small (relative to mean), and the overlap of the predictions in each class to be very high. If either of these is not the case I don't accept the model. If it is the case, I simply pick one of the candidate models at random - it should not matter what the random seed is! \nI still record the random seed used - this is still needed to recreate results!","Q_Score":1,"Tags":"python,xgboost,feature-selection,xgbclassifier","A_Id":59321064,"CreationDate":"2019-12-13T08:39:00.000","Title":"Changes to model performance by changing random_state of XGBClassifier","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using PyCharm. I try to install Selenium but I have a problem with proxy. I try to add packages manually to my project\/environment but I don't know how.\nI downloaded files with Selenium. Could you tell me how to add this package to Project without using pip?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2667,"Q_Id":59320019,"Users Score":0,"Answer":"open pycharm\nclick on settings (if u use mac click on preference )\nclick project\nthen click projecti nterpreter\nclick the + button on the bottom of the window you can see a new window search Selenium package and install","Q_Score":3,"Tags":"python,selenium,pip,pycharm","A_Id":59320231,"CreationDate":"2019-12-13T09:54:00.000","Title":"Add manually packages to PyCharm in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I first learned polymorphism in c++, in c++ we had types for every variable. So we used polymorphism to get a single pointer which can point to different type objects, and we could use them very nice.\nBut I don't get polymorphism and abstract classes in python. Here every variable can be everything. It could be an iterator, a list, a singe variable or a function. Every thing. So what makes a programmer to use an abstract class or use polymorphism here?\nIn c++ we used inheritance in many ways. But in python, it is just used to use another classes method or attribute. Am I right? what's the matter?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":450,"Q_Id":59323957,"Users Score":1,"Answer":"You don't understand what polymorphism is (OO polymorphic dispatch I mean). Polymorphism is the ability to have objects of different types understanding the same message, so you can use those objects the same way without worrying about their concrete type. \nC++ actually uses the same concept (class) to denote two slightly different semantics: the abstract type (interface) which is the set of messages an object of this type understand) and the concrete type (implementation) which defines how this type reacts to those messages.\nJava clearly distinguishes between abstract type (interface) and concrete type (class). \nPython, being dynamically typed, relies mostly on \"duck typing\" (if it walks like a duck and quack like duck, then it's a duck - or at least it's \"kind-of-a-duck\" enough). You'll often find terms like \"file-like\" or \"dict-like\" in Python docs, meaning \"anything that has the same interface as a file (or dict)\", and quite a few \"interfaces\" are (or at least have long been) more or less implicit. \nThe issue with those implicit interfaces is that they are seldom fully documented, and one sometimes have to get to a function source code to find out exactly what the object passed needs to support. That's one of the reasons why the abc module was introduced in python 2 and improved in python 3: as a way to better document those implicit interfaces by creating an abstract base type that clearly defines the interface.\nAnother reason for abstract base classes (whether using the abc module or not) is to provide a common base implementation for a set of  concrete subclasses. This is specially useful for frameworks, ie Django's models.Model (ORM) or forms.Form (user input collection and validation) classes - in both cases, just defining the database or form fields is enough to have something working.\nInheritance in C++ suffers from the same issue as classes: it serves both as defining the interface and implementation. This adds to the confusion... Java had the good idea (IMHO) to have separate abstract type from implementation, but failed to go all the way and restrict typing to interfaces - you can use either classes or interfaces for type declaration, so it still doesn't make the distinction clear.\nIn Python, since we don't have static typing, inheritance is mostly about implementation reuse indeed. The abc module allows you to register totally unrelated classes (no inheritance relationship) as also being subtypes of a defined abstract base case, but the point here is mostly to document that your class implements the same interface (and that it's not an accident...).","Q_Score":0,"Tags":"python,oop,inheritance,polymorphism","A_Id":59325453,"CreationDate":"2019-12-13T13:54:00.000","Title":"why we use polymorphism and abstract classes in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just trained my model successfully and I have some checkpoints from the training process. Can you explain to me how to use this data to recognize the objects live with the help of a webcam?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":59324845,"Users Score":0,"Answer":"Congratulations :) \nFirst of all, you use the model to recognize the objects, the model learned from the data, minor detail.\nIt really depends on what you are aiming for, as the comment suggest, you should probably provide a bit more information. \nThe simplest setup would probably be to take an image with your webcam, read the file, pass it to the model and get the predictions. If you want to do it live, you are gonna have the stream from the webcam and then pass the images to the model.","Q_Score":0,"Tags":"python,tensorflow","A_Id":59324955,"CreationDate":"2019-12-13T14:48:00.000","Title":"Implementing trained-model on camera","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"all!\nI'm struggling with this. I have a crawler that runs my network to retrieve all live IP addresses and stores them on a table. Another service runs all the records on the table to update the status of the machines. The read and write access might be simultaneous.\nThese are the fields that I need to store. As you can see, it's quite simple.\n1 - The IP address is the PRIMARY KEY, so I it won't duplicate machines. (I can change it to the MAC address)\n2 - Timestamp of first contact\n3 - Timestamp of last contact\n4 - Response of the last contact (boolean)\nI'm thinking about using MySQL, but then it might come with an overhead. Already thought about using a flat text file, but the parsing would add up to the python scripts I already have.\n\nIs there any database solution that can fit my problem?\n\nThank you all!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":59326531,"Users Score":0,"Answer":"Try taking a look at sqlite - it might be just what you're looking for and it's much lighter than mysql.","Q_Score":0,"Tags":"python,mysql,database,nosql","A_Id":59328344,"CreationDate":"2019-12-13T16:35:00.000","Title":"Quick store, lookup and retrieve database design","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using lambda function and agg() in python to perform some function on each element of the dataframe.\nI have following cases\n\nlambda x: (x==0).sum() - Question: Does this logically compute (x==0) as 1, if true, and 0, if false and then adds all ones and zeros? or is it doing something else?\nlambda x: x.sum() - Question: This is apparent, but still I'll ask. This adds all the elements or x passed to it. Is this correct?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":592,"Q_Id":59326882,"Users Score":2,"Answer":"(x == 0).sum() counts the number of rows where the condition x == 0 is true. x.sum() just computes the \"sum\" of x (the actual result depends on the type).","Q_Score":0,"Tags":"python,pandas","A_Id":59326907,"CreationDate":"2019-12-13T16:59:00.000","Title":"Pandas agg how to count rows where a condition is true","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm reading a file with numerical values. \ndata = pd.read_csv('data.dat', sep=' ', header=None)\nIn the text file, each row end with a space, So pandas wait for a value that is not there and add a \"nan\" at the end of each row.\nFor example:\n2.343 4.234 \nis read as: \n[2.343, 4.234, nan]\nI can avoid it using , usecols = [0 1] but I would prefer a more general solution","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3252,"Q_Id":59327525,"Users Score":0,"Answer":"Specifying which columns to read using usecols will be a cleaner approach or you can drop the column once you have read the data but this comes with an overhead of reading data that you don't need. The generic approach will require you the create a regex parser which will be more time consuming and more messy.","Q_Score":3,"Tags":"python,pandas,file","A_Id":59327644,"CreationDate":"2019-12-13T17:48:00.000","Title":"pandas read_csv. How to ignore delimiter before line break","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any logical difference between a = None and del a in python? \nThe None keyword is used to define a null variable or an object. In python, None keyword is an object, and it is a data type of the class NoneType .\nThe del keyword is used to delete objects.\nAre those identical to each other if I use the manual garbage collection?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":343,"Q_Id":59327665,"Users Score":1,"Answer":"No, None is still an object (of type NoneType) that takes memory and can be referenced whereas del deletes the object's name from the name space.\nSay, you create a variable a = None in the global scope. It will exists in globals(). Now if you were to delete it with del a, the reference to a ceases to exist.","Q_Score":3,"Tags":"python,collections,garbage","A_Id":59327696,"CreationDate":"2019-12-13T17:59:00.000","Title":"Garbage collection None - del difference","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 3D medical images and wanted to know if I have a CNN that uses Conv2D can I just change the Conv2D to a Conv3D? If not what would I need to change?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":721,"Q_Id":59327819,"Users Score":1,"Answer":"Yes, you can, but there are a few things to change. \nYour kernel will now need to be in 3D, so the argument kernel_size must be a 3 integer tuple. Same thing for strides. Note that the CNN you will modify will probably be in 3D already (e.g., 60, 60, 3) if it's designed to train on colored images. The only difference is that you want the neural net to not only detect features in 3 separate 60x60 windows, but through the three windows. In other words, not 3 times 2D, but 3D. \ntl;dr yes you can, just change kernel_size and strides. The default values of the keras.layers.Conv3D are adjusted accordingly anyway.","Q_Score":0,"Tags":"python,conv-neural-network,dicom,medical","A_Id":59327905,"CreationDate":"2019-12-13T18:10:00.000","Title":"Conv2D to Conv3D","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the best Python GloVe word embedding package that I can use? I want a package that can help modify the co-occurrence matrix weights. If someone can provide an example, I would really appreciate that.\nThanks,\nMohammed","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":213,"Q_Id":59328248,"Users Score":-1,"Answer":"If you are using python3, gensim would be the best choice.\nfor example:\nfrom gensim.scripts.glove2word2vec import glove2word2vec\nwill fetch the gloVe module.\nSaul","Q_Score":0,"Tags":"python-3.x,word-embedding,glove","A_Id":60968553,"CreationDate":"2019-12-13T18:48:00.000","Title":"Best Python GloVe word embedding package","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to export all the comments on a post with Facebook Graph.\nI can get all the comments fine along with the tags but I'm having some problems getting the user who actually commented.  I own the page and post that I'm doing this too. Is there a specific permission I need? I have manage_pages, pages_show_list, and public_profiles.\nAny help would be great, thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":59329025,"Users Score":0,"Answer":"It is important that you are using a Page Token. With a simpel App Token, you will not get the from field in the response.","Q_Score":0,"Tags":"python,facebook,facebook-graph-api","A_Id":59335735,"CreationDate":"2019-12-13T19:55:00.000","Title":"How can I View Who a Comment was From on Facebook API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For context:\n\nUsing a Azure cloud instance of a PostGRES database.\nUsing RHEL7 with openssl and openssl-dev installed.\nUsing python2.7.\nI can import SSL in python2.7 shell without issue.\nI can connect to a locally hosted PostGRES database using psycopg2 without issue.\n\nWhen I try connecting to the remote database using sslmode='require' I receive an OperationalError that sslmode value \"require\" invalid when SSL support is not compiled in. Looking at the SSL settings for the PostGRES instance in Azure, I see that the SSL mode is \"prefer\", however if I try to use that for the psycopg2 connection, I'm told that a SSL connection is required. \nFor the record, I have no issue connecting to this remote database using python3.7 from a Windows 10 machine. This leads me to believe that there isn't some configuration issue with the remote instance, and that the issue lies somewhere in RHEL7 and python2.7. Has anyone else ran into this issue?\nedit: Pyscopg2 was installed in a virtual environment using 'pip install psycopg2'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1201,"Q_Id":59329759,"Users Score":0,"Answer":"I can import SSL in python2.7 shell without issue.\n\nSSL support for a PostgreSQL connection needs to come from libpq (which is what psycopg2 uses to establish and manage the database connection).  Being able to load an SSL module at the python level won't help, as it can't stitch that module together with libpq. So it seems you somehow managed to install a libpq compiled without SSL support.  I don't know how you did that.  Can you show us how you installed psycopg2 and its dependencies?\n\nLooking at the SSL settings for the PostGRES instance in Azure, I see that the SSL mode is \"prefer\", \n\n\"prefer\" is a setting for clients.  There is no such setting on the server side.  The server can allow SSL, or can demand SSL.  If it allows but does not demand, then it is up to the client to decide what to do.\n\nhowever if I try to use that for the psycopg2 connection, I'm told that a SSL connection is required.\n\nThe server demands SSL.  The client is unable to comply, because it does not have support for it compiled in.","Q_Score":1,"Tags":"postgresql,python-2.7,redhat,psycopg2","A_Id":59330442,"CreationDate":"2019-12-13T21:00:00.000","Title":"Invalid SSL mode for remote PostgreSQL connection","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Every tutorial I have found about machine learning includes testing an algorithm on a dataset that has target values and then it finds how accurate the algorithm is by testing its predictions on the test set.\nWhat if you then receive all of the data except for the target value and you want to make target value predictions to see if they come true in the future?Every tutorial I have seen has been with data that they already know the future target value predictions.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27,"Q_Id":59332410,"Users Score":3,"Answer":"Decision tree is a supervised algorithm. That means you must use some target value(or lable) to build the tree(dividing node's value based on information gain rule).","Q_Score":0,"Tags":"python","A_Id":59332455,"CreationDate":"2019-12-14T04:54:00.000","Title":"How to make predictions with a decision tree on a dataset without a target value?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been working to create an OMR bubble sheet scanner using OpenCV from Python.\nI have created the bubble-sheets (using OpenCV) in PNG format. \nThen I am using OpenCV to read those files. OpenCV does a perfect job on PNG images, it works perfectly.... but when I use this on JPG files, it simply doesn't! Lists running out of indexes because it cannot detect all the proper contours.\nI know this doesn't make sense, but I tried saving the same PNG image directly into JPG (using Paint), and the same results. It works on PNG version, but doesn't work on JPG version. It also shows a different number of contours in the images even the images are exact same.\nAny help regarding this would be greatly appreciated, thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1643,"Q_Id":59333332,"Users Score":1,"Answer":"The problem is inherent to the image format you are using. There are majorly two type of compression techniques(all image formats: jpeg, png, webp are compression techniques):\n\nLossless Compression\nLossy compression\n\nAs the name suggests, Lossless compression technique do not change the underlying matrix data while compression, for example: PNG. And the Lossy compression technique may substitute the underlying data with some nearest round off values to save some space, for example: JPEG.\nIn your case while you are using JPEG format to save the image, it may distort some RGB pixel information, so if your threshold range are really tight then you will have different results as compared to PNG.","Q_Score":0,"Tags":"python-3.x,image,opencv,image-processing,computer-vision","A_Id":59333699,"CreationDate":"2019-12-14T07:57:00.000","Title":"OpenCV from Python shows different results for JPG and PNG images?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My server can run on either Python 3.6 or Python 3.8. The problem seems to be the client.\nIf I run the client on Python 3.6, I get TLSv1.2 working with no error. But if I run the same client code on Python 3.8, I get NO_SHARED_CIPHER on the server and SSLV3_ALERT_HANDSHAKE_FAILURE on the client.\nI suspect it has something to do with server or client certificate.\nUPDATE: I created some new server and client certificates to experiment around with: ed25519, rsa, and secp256k1. From what I've seen, the problem above only shows up when the server certificate is secp256k1 and both the client and server are running Python 3.8 (and therefore with TLSv1.3). The client can use any type of certificate.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":298,"Q_Id":59333458,"Users Score":0,"Answer":"... NO_SHARED_CIPHER ...\n  I suspect it has something to do with server or client certificate.\n\nThis is a problem of cipher selection and cipher selection has almost nothing to do with the certificate, at least if the the certificate type is still the same, i.e. ECC vs. RSA. And I assume that you are still using the same certificate or at least the same certificate type in the working and non-working cases.\nIt is more likely that your client tries to use some RC4 or 3DES based cipher which is today considered obsolete and thus is no longer supported  by a server when using a newer version of the software stack (i.e. Python+OpenSSL).","Q_Score":0,"Tags":"python-3.x,sockets,ssl,openssl","A_Id":59333535,"CreationDate":"2019-12-14T08:17:00.000","Title":"Python SSL\/TLS - no shared cipher on Python 3.8 but working on Python 3.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":"How can we do count() for firebase database in python ?\nas for example ..\ncount = db.child(\"users\").get().count()","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":759,"Q_Id":59334339,"Users Score":1,"Answer":"You can use the len function for this as:\nlen(db.child('users').get().val())","Q_Score":0,"Tags":"python,firebase,firebase-realtime-database,pyrebase","A_Id":59334461,"CreationDate":"2019-12-14T10:41:00.000","Title":"How to count firebase database in python using pyrebase?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I tried installing Jupyter through pip and it failed showing this.\n\nThe package setup script has attempted to modify files on your system\n  that are not within the EasyInstall build area, and has been\n  aborted.\nThis package cannot be safely installed by EasyInstall, and may not\n  support alternate installation locations even if you run its setup\n  script by hand.  Please, inform the package's author and the\n  EasyInstall maintainers to find out if a fix or workaround is\n  available.","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":4091,"Q_Id":59334356,"Users Score":5,"Answer":"Try to upgrade your packages:\npip install --upgrade setuptools\npip install --upgrade pip\nits seems like missmatch in your versions","Q_Score":1,"Tags":"python,pip,jupyter,easy-install,failed-installation","A_Id":59334393,"CreationDate":"2019-12-14T10:43:00.000","Title":"Error while installing Jupyter: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried installing Jupyter through pip and it failed showing this.\n\nThe package setup script has attempted to modify files on your system\n  that are not within the EasyInstall build area, and has been\n  aborted.\nThis package cannot be safely installed by EasyInstall, and may not\n  support alternate installation locations even if you run its setup\n  script by hand.  Please, inform the package's author and the\n  EasyInstall maintainers to find out if a fix or workaround is\n  available.","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":4091,"Q_Id":59334356,"Users Score":-1,"Answer":"simply follow this to install jupyter in windows :-\n1nd - Go to file manager and find python folder (like:-python,python37,python39 etc...) may be it's in (C:\\Python39) or (C:\\Users\\prade\\AppData\\Local\\Programs\\python39) .\n2rd - in python folder open Scripts folder (Ex:- C:\\......\\python39\\Scripts) and copy this path.\n3rd - run cmd as administrator and past above path using cd (like:- cd C:\\.....\\python39\\Scripts)\n4th - now simply use jupyter install command (like:- pip install jupyterlab)","Q_Score":1,"Tags":"python,pip,jupyter,easy-install,failed-installation","A_Id":67635442,"CreationDate":"2019-12-14T10:43:00.000","Title":"Error while installing Jupyter: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training a multi-label classification model for detecting attributes of clothes. I am using transfer learning in Keras, retraining the last few layers of the vgg-19 model.\nThe total number of attributes is 1000 and about 99% of them are 0s. Metrics like accuracy, precision, recall, etc., all fail, as the model can predict all zeroes and still achieve a very high score. Binary cross-entropy, hamming loss, etc., haven't worked in the case of loss functions.\nI am using the deep fashion dataset. \nSo, which metrics and loss functions can I use to measure my model correctly?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":23020,"Q_Id":59336899,"Users Score":24,"Answer":"What hassan has suggested is not correct - \nCategorical Cross-Entropy loss or Softmax Loss is a Softmax activation plus a Cross-Entropy loss. If we use this loss, we will train a CNN to output a probability over the C classes for each image. It is used for multi-class classification.\nWhat you want is multi-label classification, so you will use Binary Cross-Entropy Loss or Sigmoid Cross-Entropy loss. It is a Sigmoid activation plus a Cross-Entropy loss. Unlike Softmax loss it is independent for each vector component (class), meaning that the loss computed for every CNN output vector component is not affected by other component values. That\u2019s why it is used for multi-label classification, where the insight of an element belonging to a certain class should not influence the decision for another class.\nNow for handling class imbalance, you can use weighted Sigmoid Cross-Entropy loss. So you will penalize for wrong prediction based on the number\/ratio of positive examples.","Q_Score":17,"Tags":"python,machine-learning,keras,multilabel-classification,vgg-net","A_Id":59433454,"CreationDate":"2019-12-14T16:15:00.000","Title":"Which loss function and metrics to use for multi-label classification with very high ratio of negatives to positives?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training a multi-label classification model for detecting attributes of clothes. I am using transfer learning in Keras, retraining the last few layers of the vgg-19 model.\nThe total number of attributes is 1000 and about 99% of them are 0s. Metrics like accuracy, precision, recall, etc., all fail, as the model can predict all zeroes and still achieve a very high score. Binary cross-entropy, hamming loss, etc., haven't worked in the case of loss functions.\nI am using the deep fashion dataset. \nSo, which metrics and loss functions can I use to measure my model correctly?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":23020,"Q_Id":59336899,"Users Score":7,"Answer":"Actually you should use tf.nn.weighted_cross_entropy_with_logits.\nIt not only for multi label classification and also has a pos_weight can pay much attention at the positive classes as you would expected.","Q_Score":17,"Tags":"python,machine-learning,keras,multilabel-classification,vgg-net","A_Id":63974451,"CreationDate":"2019-12-14T16:15:00.000","Title":"Which loss function and metrics to use for multi-label classification with very high ratio of negatives to positives?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Ubuntu 19.10, in which there is python of version 3.7. After the release of python 3.8, which I have installed, now I want to uninstall python 3.7 so that whenever I would call python3 in my terminal, it would always call python3.8?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30234,"Q_Id":59337891,"Users Score":5,"Answer":"I suggest you do not touch your default OS python instalation. Other parts of the system may depend on it and there is no way to know if an upgrade can break something, even if it should not.\nI also suggest that you learn (if you haven't already, but I suppose you did not because of the question) about using a python virtual environment, like virtualenv. This allows you to setup specific python environments for each project you write. This means each environment can have its own python version, and, besides the standard python lib for that version, any other third-party python lib you would like to install with pip for that project. This isolates projects from each other. You won't break one because of an upgrade of another.\nThat said, if you want to keep cutting edge with Python versions, make an install from source, and then install it in the system with the altinstall parameter (see the README.rst of the Python distribution. This way all the installed versions are available with different names (the same for pip) and then you create each of your virtual environments with the wanted version. There is a parameter for virtualenv to apply a specific (older) version if you want. \nQuoting the README on the \"Installing multiple versions\" section:\n\nOn Unix and Mac systems if you intend to install multiple versions of Python\n  using the same installation prefix (--prefix argument to the configure\n  script) you must take care that your primary python executable is not\n  overwritten by the installation of a different version.  All files and\n  directories installed using make altinstall contain the major and minor\n  version and can thus live side-by-side.  make install also creates\n  ${prefix}\/bin\/python3 which refers to ${prefix}\/bin\/pythonX.Y.  If you\n  intend to install multiple versions using the same prefix you must decide which\n  version (if any) is your \"primary\" version.  Install that version using make\n  install.  Install all other versions using make altinstall.\n  For example, if you want to install Python 2.7, 3.6, and 3.8 with 3.8 being the\n  primary version, you would execute make install in your 3.8 build directory\n  and make altinstall in the others.\n\nFinally, the other answers are ok to do exactly what you asked, if you still want to.","Q_Score":3,"Tags":"python,python-3.x","A_Id":59346882,"CreationDate":"2019-12-14T18:18:00.000","Title":"How to uninstall python 3.7 from Ubuntu 19.10?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"my question is if I use a vpn and try to send a message on a python socket message, not of any protocol, will my socket traffic go through the vpn and my ip be hidden from the message receiver? I found that I can't see the traffic using wireshark because it's not of any protocol. THANKS FOR THE HELP!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2273,"Q_Id":59339029,"Users Score":2,"Answer":"To establish a socket connection with a vpn is possible but...\nI tried the same project and got this result:\n\nTo establish a socket connection in the VPN server, you need to connect your device in which you execute your code to the vpn.\n\nType in ipconfig and get the vpn's IP address and bind a socket in Python using the IP.\n\nNow if you execute the project within the same pc the project works.\n\n\nBut if you use a different Wi-Fi connection in another pc it doesn't but why?\nHere comes port forwarding:\nThe vpn allocates a private IP address to your computer. A private IP address can be used to communicate with devices within your LAN (modem). But if you try to connect private IP address from other network, it would fail to communicate with your pc. So, to solve this public IP address is used. Each modem (even vpn servers) have a public IP address. It is like a tool for communication of devices across any network. For example online game servers runs using public IP address. This is the reason Windows firewall pops up when you enter an online game in Windows. But even if you type the public IP the socket doesn't work.\nHere comes port forwarding. Think, many devices are connected to your network or vpn server. The modem or vpn does not know which device should it transmit the message. If you port forward the private IP address and the exact port number. It now finally works!\n\nNOTE: Public IP's are sensitive and hackers can enter any VPN server using public IP address. So most VPN providers do not provide public IP. Only with the main VPN server you can port forward. So you need to contact the VPN service provider and request for a port forwarding to your private IP and finally program you socket and your project may work.\n\n\nNOTE: You  need a TCP\/UDP protocol for a socket.","Q_Score":2,"Tags":"python,sockets,vpn","A_Id":64458547,"CreationDate":"2019-12-14T20:50:00.000","Title":"python socket and vpn","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running an heavy pytorch task on this VM(n1-standard, 2vCpu, 7.5 GB) and the statistics show that the cpu % is at 50%. On my PC(i7-8700) the cpu utilization is about 90\/100% when I run this script (deep learning model).\nI don't understand if there is some limit for the n1-standard machine(I have read in the documentation that only the f1 obtain 20% of cpu usage and the g1 the 50%).\nMaybe if I increase the max cpu usage, my script runs faster.\nIs there any setting I should change?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":75,"Q_Id":59339838,"Users Score":2,"Answer":"In this case, the task utilizes only one of the two processors that you have available so that's why you see only 50% of the CPU getting used. \nIf you allow pytorch to use all the CPUs of your VM by setting the number of threads, then it will see that the usage goes to 100%","Q_Score":1,"Tags":"python,multithreading","A_Id":59349161,"CreationDate":"2019-12-14T22:53:00.000","Title":"Compute Engine n1-standard only use 50% of CPU","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing a 8 Puzzle game solver in python lately and I need a bit of help\nSo far I finished coding the A* algorithm using Manhattan distance as a heuristic function.\nThe solver runs and find ~60% of the solutions in less than 2 seconds\nHowever, for the other ~40%, my solver can take up to 20-30 minutes, like it was running without heuristic.\nI started troubleshooting, and it seems that the openset I use is causing some problems :\n\nMy open set is an array\nEach iteration, I loop through the openset to find the lowest f(n) (complexity : O(n) )\n\nI have the feeling that O(n) is way too much to run a decent A* algorithm with such memory used so I wanted to know how should I manage to make the openset less \"time eater\"\nThank you for your help ! Have a good day\nEDIT: FIXED\nI solved my problem which was in fact a double problem.\nI tried to use a dictionary instead of an array, in which I stored the nodes by their f(n) value and that allowed me to run the solver and the ~181000 possibilities of the game in a few seconds\nThe second problem (I didn't know about it because of the first), is that I didn't know about the solvability of a puzzle game and as I randomised the initial node, 50% of the puzzles couldn't be solved. That's why it took so long with the openset as the array.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":59340795,"Users Score":0,"Answer":"The open set should be a priority queue. Typically these are implemented using a binary heap, though other implementations exist.\nNeither an array-list nor a dictionary would be efficient.\n\nThe closed set should be an efficient set, so usually a hash table or binary search tree, depending on what your language's standard library defaults to.\nA dictionary (aka \"map\") would technically work, but it's conceptually the wrong data-structure because you're not mapping to anything. An array-list would not be efficient.","Q_Score":0,"Tags":"python,algorithm,complexity-theory,a-star,sliding-tile-puzzle","A_Id":59342082,"CreationDate":"2019-12-15T02:32:00.000","Title":"8Puzzle game with A* : What structure for the open set?","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 try to install librosa in python. Then I got error with llvmlite lite.\nI solved with easy_install llvmlite command.\nAfter that the librosa package is installed successfully.\nThe issue starts when I importing librosa in Jupiter.\nThe errors is -\nOS Error: could not load shared object file libllvmlite.so\nI do not understand this error. The packages are successfully installed but got error when importing.\nAny help, thank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":207,"Q_Id":59341518,"Users Score":0,"Answer":"I think in Linux, .so are shared objects. Restart and try opening your jupyter notebook with super user.","Q_Score":0,"Tags":"python,python-import,librosa","A_Id":59341712,"CreationDate":"2019-12-15T05:48:00.000","Title":"Librosa installation 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 never did this before so I am sorry if my question is not very clear (I am not sure what the name of each step is). I have a code which is supposed to give me an interactive interface in a browser (similar to jupyter notebook I guess). After I run the code (I am using a remote machine, not my personal computer) one of the messages is: Running on http:\/\/127.0.0.1:5000\/ When I try to enter that in my browser I am getting a This site can\u2019t be reached error. Also the terminal window used to run this code isn't active anymore (it is similar to when I run a jupyter notebook). What should I do to get access to that interactive windows created? Thank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17,"Q_Id":59341519,"Users Score":0,"Answer":"http:\/\/127.0.0.1 is called loopback ip and is equivalent to localhost.\nThe remote machine is hosting the program on localhost, i.e., you cannot access it from other machine unless you host it on the machine's public ip.   \nEasiest way to do that is to host on 0.0.0.0:5000. where 5000 is just a port and can be almost anything. Now that would probably print Running on http:\/\/0.0.0.0:5000\/ but you need to access it with the machine's public ip.","Q_Score":0,"Tags":"python,browser","A_Id":59342467,"CreationDate":"2019-12-15T05:48:00.000","Title":"Get the output of a code on a remote machine in a browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My scripts don't work anymore and I can't figure it out.\nIt is a chrome version problem apparently... But I don't know how to switch to another version (not the latest?) Does exist another way?\nMy terminal indicates : \nTraceback (most recent call last):\nFile \"\/Users\/...\/Documents\/SCRIPTS\/PYTHON\/Scripts\/# -- coding: utf-8 --.py\", line 21, in \n    driver = webdriver.Chrome()\nFile \"\/opt\/anaconda3\/lib\/python3.7\/site-packages\/selenium\/webdriver\/chrome\/webdriver.py\", line 81, in init\n    desired_capabilities=desired_capabilities)\nFile \"\/opt\/anaconda3\/lib\/python3.7\/site-packages\/selenium\/webdriver\/remote\/webdriver.py\", line 157, in init\n    self.start_session(capabilities, browser_profile)\nFile \"\/opt\/anaconda3\/lib\/python3.7\/site-packages\/selenium\/webdriver\/remote\/webdriver.py\", line 252, in start_session\n    response = self.execute(Command.NEW_SESSION, parameters)\nFile \"\/opt\/anaconda3\/lib\/python3.7\/site-packages\/selenium\/webdriver\/remote\/webdriver.py\", line 321, in execute\n    self.error_handler.check_response(response)\nFile \"\/opt\/anaconda3\/lib\/python3.7\/site-packages\/selenium\/webdriver\/remote\/errorhandler.py\", line 242, in check_response\n    raise exception_class(message, screen, stacktrace)\nselenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome version must be between 71 and 75\n(Driver info: chromedriver=2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e),platform=Mac OS X 10.14.5 x86_64)\nAny idea?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":363,"Q_Id":59344813,"Users Score":0,"Answer":"This possibly happens, as your Chrome Browser or Chromium may be updated to newer versions automatically. But you still run your selenium scripts using the old version of the chromedriver.\nCheck the current version of your Google chrome or Chromium, then download the chromedriver for that specific version.\nThen your scripts may work fine!","Q_Score":0,"Tags":"python,google-chrome,selenium-webdriver,version","A_Id":63296566,"CreationDate":"2019-12-15T14:24:00.000","Title":"My python scripts using selenium don't work anymore. Chrome driver version problem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a newbie in programming and python (only 30 days). I've installed Anaconda and working in the Spyder IDE. Everything was going fine and have been adding packages as necessary while I was learning different things until now. Now, I'm getting an error when I'm trying to import Matplotlib. Can anyone advise me what to do in simple terms, please?\n\nError processing line 1 of\n  C:\\Anaconda\\lib\\site-packages\\matplotlib-3.1.2-py3.7-nspkg.pth:\nTraceback (most recent call last):\n      File \"C:\\Anaconda\\lib\\site.py\", line 168, in addpackage\n        exec(line)\n      File \"\", line 1, in \n      File \"\", line 580, in module_from_spec   AttributeError: 'NoneType' object has no attribute\n  'loader'\nRemainder of file ignored","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":59345149,"Users Score":0,"Answer":"It seems like your package uninstall did not finish properly and something of that google package has been left behind.\nYou need to either move some of your source files at correct destination or uninstall anaconda and reinstall again.","Q_Score":0,"Tags":"python,matplotlib","A_Id":59346258,"CreationDate":"2019-12-15T15:05:00.000","Title":"Matplotlib throw errors and doesn't work when I try to import it","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made models with sklearn, something like this:\nclf = SGDClassifier(loss=\"log\")\nclf.fit(X, Y)\nAnd then now I would like to add data to learn for this model, but with more important weight. I tried to use partial_fit with sample_weight bigger but not working. Maybe I don't use fit and partial_fit as good, sorry I'm beginner...\nIf someone know how to add new data I could be happy to know it :)\nThanks for help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":59347375,"Users Score":0,"Answer":"Do you think it has other way to do a first learning and then add new data more important for the model? Keras?\nThanks guys","Q_Score":0,"Tags":"python,scikit-learn","A_Id":59348501,"CreationDate":"2019-12-15T19:29:00.000","Title":"Add new data to model sklearn: SGD","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am planning a command line Python application that I intend to distribute through PyPi. \nWhen the application is installed with pip, I want to create a user-editable configuration file in the appropriate location on the user's filesystem.\nFor example, in Ubuntu, the file would be something like ~\/.config\/foo\/config.ini\nOn installation I want to create the file (if possible) and be able to specify another config file to use instead with a command line parameter.\nWhat is the usual scheme for getting this done?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":297,"Q_Id":59348090,"Users Score":1,"Answer":"I think appdirs package on PyPI is what you need, isn\u2019t it?","Q_Score":2,"Tags":"python,packaging,pypi","A_Id":59348304,"CreationDate":"2019-12-15T21:09:00.000","Title":"How should I create and read a user editable configuration file in ~\/.config or similar?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have struggled with what language formats I need to pass to translation.activate and I asked a detailed question but then I dug up the solution from the source. See it in my answer.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":85,"Q_Id":59348401,"Users Score":1,"Answer":"The format is: \n\nyou can supply a plain language ('hu', 'pt', 'en', 'de' etc.)\nyou can supply a language and a \"territory\" ('pt-pt', 'pt-br', 'en-gb')\nnote that django is buggy if you use other formats (eg. 'pt_br') since it does not properly recognise the language-territory relation. (I haven't tried but looking at the code I also think 'pt-BR' format\nshould work. It is too bad that we don't have a verbose option to see django's guesses.)\n\nDjango checks the directories in the following order (assuming you enter 'pt-br'):\n\nlanguage_territory.isoencoding ('pt_BR.ISO8859-1'), \nlanguage_territory ('pt_BR') -- but note that if a territory is longer than 2 characters, then only the first character gets capitalized (eg. 'zh_Hans')!\nlanguage.encoding ('pt.ISO8859-1')\nlanguage ('pt')\nfalling back to default language and trying its 4 possible directory (usually ['en_US.ISO8859-2', 'en_US', 'en.ISO8859-2', 'en'])\n\nThis was missing in Django documentation, now you can all find it here. Good luck.\nOne more thing:\nYou can put a locale directory into each app directory. I recommend you to break up the translation into smaller units - it is easier to track the translations later.","Q_Score":1,"Tags":"python,django,django-i18n","A_Id":59348777,"CreationDate":"2019-12-15T21:55:00.000","Title":"What language format does django translation.activate() accept?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Case 1: Class is coded in code.py. Say class contains a couple of instance variables and an instance method that does some processing and returns the result. In flask endpoint, I am importing the class from code.py module and instantiating the class and calling the object.mtdname()\nCase 2: in code.py, along with the same class as in case 1, I define a function (do_work) outside the class. The do_work function instantiates the class and calls object.mtdname() method. In flask endpoint, I import only the do_work function from code.py. when do_work is invoked it will create the object and return the result.\nWhat are pro and cons of using case 1 or 2?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":59351107,"Users Score":0,"Answer":"Generally speaking, I would prefer case 1 because case 2 requires an additional test that really doesn't test anything new.  So for the purposes of reducing code, I would go with Case 1 unless do_work did something other than just call the one method.","Q_Score":0,"Tags":"python,python-3.x","A_Id":59351193,"CreationDate":"2019-12-16T05:43:00.000","Title":"Instantiate class and call its functions via a function in the same module as class declaration?","Data 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 followed the official guide on using the google cloud sdk with python 3, and I was able to install the latest sdk (273.0.0) with the google app engine and python components. Now I'd like to use the launcher instead of the cli commands in the guide to run my project but I cannot find it anywhere. \nThe README file in my current installation of the app engine in my AppData\/local folder says that the App Engine Launcher should have a desktop shortcut and an executable at C:\\Program Files\\Google\\google_appengine\\launcher\\GoogleAppEngineLauncher.exe but neither shortcut nor executable path exist. I also looked through the AppData folder and didn't find it. \nWas the launcher never present\/removed from the app engine version I installed? Was it in the README by mistake? Or could the installation be incomplete?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":59352865,"Users Score":0,"Answer":"Yes, many years ago, to deploy GAE, Google provided an installable desktop app called GoogleAeppEngineLauncher.  I'm quite certain that it is no longer available and would not even function if you were somehow able to obtain a copy.\nYou now must use the gcloud commands to deploy your app.","Q_Score":1,"Tags":"python-3.x,google-app-engine,google-cloud-sdk","A_Id":59358062,"CreationDate":"2019-12-16T08:29:00.000","Title":"Is the App Engine Launcher still part of the GCloud SDK's App Engine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I built a neural network of the dimensions Layers = [203,100,100,100,2]. So I have 203 features and get two classes as a Result. I think, in my case, it would not be necessary to have two classes. My result is the prediction of a customer quitting his contract. So I guess one class would be sufficient (And 1 being quit, 0 being stay). I built the network with two classes to keep it flexible if I want to add more output-classes in the future.\nI put dropout,batch_normalization, and weight-decay. I am training with an Adam-optimizer. At the end of the day, I come up with\n\nprecision: 0.7826087, recall: 0.6624 on test-data.\nprecision: 0.8418698, recall: 0.72445 on training-data\n\nThis means if I predict a customer to quit, I can be 78% confident that he really quits.\nOn the opposite, if he quits his contract, I predicted with 66% that he will do so.\nSo my classifier doesn\u00b4t work too bad. One thing keeps nagging at me: How do I know if there is any chance to do better still? In other words: Is there a possibility to calculate the Bayes-error my setup determines? Or to say it clearer: If the difference of my training-error and test-error is high like this, can I conclude for sure, that I am having a variance problem? Or is it possible that I must cope with the fact the test-accuracy cannot be improved?\nWhat else can I try to train better?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":59353398,"Users Score":0,"Answer":"I put more training data. Now I use 70000 records instead of 45000.\nMy results:\n\nprecision: 0.81765974, recall: 0.65085715 on test-data\nprecision: 0.83833283, recall: 0.708 on training-data\n\nI am pretty confident that this result is as good as possible. Thanks for reading","Q_Score":0,"Tags":"python,tensorflow,neural-network,statistics,precision-recall","A_Id":59377401,"CreationDate":"2019-12-16T09:06:00.000","Title":"cope with high variance or keep training","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know how back-end automation is possible through RPA.\nI'd be interested in solving this scenario relative to an Incident Management Application, in which authentication is required. The app provide:\n\nAn option useful to download\/export the report to a csv file\nSort the csv as per the requirement\nSend an email with the updated csv to the team\n\nPlease let me know how this possible through RPA and what are those tools \navailable in RPA to automate this kind of scenario?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":442,"Q_Id":59360594,"Users Score":-1,"Answer":"There are several ways to do it. It is especially useful when your backed are 3rd party applications where you do not have lot of control. Many RPA products like Softomotive WinAutomation, Automation Anywhere, UiPath etc. provide file utilities, excel utilities, db utilities, ability to call apis, OCR capabilities etc., which you can use for backed automation.","Q_Score":1,"Tags":"python-3.x,rpa,automationanywhere","A_Id":60356275,"CreationDate":"2019-12-16T16:28:00.000","Title":"RPA : How to do back-end automation using RPA tools?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know how back-end automation is possible through RPA.\nI'd be interested in solving this scenario relative to an Incident Management Application, in which authentication is required. The app provide:\n\nAn option useful to download\/export the report to a csv file\nSort the csv as per the requirement\nSend an email with the updated csv to the team\n\nPlease let me know how this possible through RPA and what are those tools \navailable in RPA to automate this kind of scenario?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":442,"Q_Id":59360594,"Users Score":2,"Answer":"RPA tools are designed to automate mainly front-end activities by mimicing human actions. It can be done easily using any RPA tool.\nHowever, if you are interested in back-end automation the first question would be, if specific application has an option to interact in the way you want through the back-end\/API?\nIf yes, in theory you could develop RPA robot to run pre-developed back-end script. However, if all you need would be to run this script, creating robot for this case may be redundant.","Q_Score":1,"Tags":"python-3.x,rpa,automationanywhere","A_Id":59442056,"CreationDate":"2019-12-16T16:28:00.000","Title":"RPA : How to do back-end automation using RPA tools?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a model and I have two dataframes in Pandas. One is the training data and the other the testing data. One of the variables is the country. I was thinking about using OrdinalEncoder() to convert the country column to a categorical column. E.g.: \"USA\" will be 1 in the new column, \"Brazil\" will be 2 and so on. However, I want the same conversion for the two dataframes. If \"USA\" in the training data becomes 1 as a categorical column, I want that \"USA\" in the testing data also becomes 1.\nIs that possible? How so?\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":59362334,"Users Score":0,"Answer":"In general, it is recommended to use the OrdinalEncoder when you are sure or know that there exists an 'ordered' relationship between the categories. For example, the grades F, B-, B, A- and A : for each of these it makes sense to have the encoding as 1,2,3,4,5 where higher the grade, higher is the weight ( in the form of the encoded category). \nIn your current case, it would be better to use a OneHot encoder for the Country column before splitting into train\/test datasets.","Q_Score":0,"Tags":"python,pandas,scikit-learn","A_Id":59362487,"CreationDate":"2019-12-16T18:26:00.000","Title":"How can I transform a string variable to a categorical variable in two different datasets, keeping the same conversion?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The matplotlib.pyplot.hist() documentation describes the parameter \"density\" (its deprecated name was \"normed\") as:\n\n\ndensity : bool, optional\n\nIf True, the first element of the return tuple will be the counts normalized to form a probability density, i.e., the area (or integral) under the histogram will sum to 1. This is achieved by dividing the count by the number of observations times the bin width and not dividing by the total number of observations.\n\n\n\nWith the first element of the tuple it refers to the y-axis values. It says that it manages to get the area under the histogram to be 1 by: dividing the count by the number of observations times the bin width.\nWhat is the difference between count and number of observations? In my head they are the same thing: the number of instances (or number of counts or number of observations) the variable value falls into a certain bin. However, this would mean that the transformed number of counts for each bin is just one over the bin width (since # \/ #*bin_width = 1\/bin_width) which does not make any sense.\nCould someone clarify this for me? Thank you for your help and sorry for the probably stupid question.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1174,"Q_Id":59362968,"Users Score":2,"Answer":"I think the wording in the documentation is a bit confusing. The count is the number of entries in a given bin (height of the bin) and the number of observation is the total number of events that go into the histogram.\nThe documentation makes the distinction about how they normalized because there are generally two ways to do the normalization:\n\ncount \/ number of observations - in this case if you add up all the entries of the output array you would get 1.\ncount \/ (number of observations * bin width) - in this case the integral of the output array is 1 so it is a true probability density. This is what matplotlib does, and they just want to be clear in this distinction.","Q_Score":1,"Tags":"python,matplotlib,histogram","A_Id":59363215,"CreationDate":"2019-12-16T19:16:00.000","Title":"Difference between \"counts\" and \"number of observations\" in matplotlib histogram","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having slight issues when it comes to running a crawler through my s3 buckets. My folders have data that was dumped from redshift that was sliced into many different files. These files naming convention go as the following:\ndump_0000_part_00.gz,   dump_0001_part_01.gz ....\nHowever when my crawler fetches the metadata in this folder, it instead makes a few hundred tables, thinking each one of these sliced files is its own table. Is there a way to tell the crawler to group all these sliced files into ONE catalog table?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":130,"Q_Id":59363093,"Users Score":0,"Answer":"When configuring the Crawler (or editing an existing one), under the Output section, expand Grouping behavior for S3 data (optional) and select Create a single schema for each S3 path","Q_Score":0,"Tags":"python,database,amazon-web-services,amazon-s3,aws-glue","A_Id":59365512,"CreationDate":"2019-12-16T19:26:00.000","Title":"Adding only one of s3 partitioned files to AWS Glue","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm new to Django and curious how the authentication of Rest Framework works.\nSo as I understand, the flow of authentication is:\n    Frontend sends request with username and password > Backend (Django) sends back token > From then on frontend send this token in header to authenticate.\nBut because anyone can see the header I send, so how is this safe?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":48,"Q_Id":59363738,"Users Score":1,"Answer":"For this to be secure you should only ever authenticate over an https connection. When using an https connection the header\/token\/cookie\/whatever will be encrypted.","Q_Score":1,"Tags":"python,django,django-rest-framework","A_Id":59364017,"CreationDate":"2019-12-16T20:19:00.000","Title":"Authentication with REST Framework Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have installed python version 2 and 3 in windows 10 through anaconda package. Using python --version, CMD shows the version of python as 3, but Windows bash shell shows it as 2.\nHow can I activate python version 3 in Windows bash shell?\nI need to activate it because I want to run commands in shell, for instance pyinstaller. CMD does not recognize pyinstaller.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":741,"Q_Id":59365372,"Users Score":3,"Answer":"bash in Windows runs on the Windows Subsystem for Linux, which has a version of Ubuntu running on it. It has its own filesystem and its own libraries and binaries for Python, so it is not using the versions of Python you installed in Windows.  You can see this by typing which python in bash.  It will return \/usr\/bin\/python which is a location in the Subsystem for Linux filesystem, not in the normal Windows filesystem.\nIn bash (as in Ubuntu) you launch Python 2 with the command python and you launch Python 3 with the command python3.\nIf Python 3 is not present in your bash install, you can add it from the package repositories by running the command sudo apt install python3 in bash.","Q_Score":0,"Tags":"python,windows","A_Id":59365465,"CreationDate":"2019-12-16T22:53:00.000","Title":"Windows bash shell shows the wrong version of Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to run a file (an executable) in google colab  I mounted the drive and everything is ok however whenever i try to run it using :\n!  'gdrive\/My Drive\/path\/myfile' \nI get this output of the cell:\n\/bin\/bash: 'gdrive\/My Drive\/path\/myfile : Permission denied\nany ideas how to overcome the permissions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9920,"Q_Id":59365405,"Users Score":9,"Answer":"you first need to permit that file\/folder as:\n    chmod 755 file_name","Q_Score":6,"Tags":"python,bash,permissions,file-permissions,google-colaboratory","A_Id":59704683,"CreationDate":"2019-12-16T22:57:00.000","Title":"google colab \/bin\/bash: 'gdrive\/My Drive\/path\/myfile : Permission denied","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"We are doing a POC to see how to access SAS data sets from Anaconda \nAll documentation i find says only SASpy works with SAS 9.4 or higher\nOur SAS version is 9.04.01M3P062415\nCan this be done? If yes any documentation in this regard will be highly appreciated\nMany thanks in Advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":181,"Q_Id":59365941,"Users Score":0,"Answer":"SAS datasets are ODBC compliant. SasPy is for running SAS code. If the goal is to read SAS datasets, only, use ODBC or OleDb. I do not have Python code but SAS has a lot of documentation on doing this using C#. Install the free SAS ODBC drivers and read the sas7bdat. The drivers are on the SAS website.\nWriting it is different but reading should be fine. You will lose some aspects of the dataset but data will come through.","Q_Score":0,"Tags":"python,sas,anaconda,saspy","A_Id":59369038,"CreationDate":"2019-12-17T00:12:00.000","Title":"Accessing SAS(9.04) from Anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been searching all over internet for solution but couldn't find any. I am using captcha solving api to solve captcha in scrapy-splash but when captcha page appears, scrapy sends request to api while trying to scrape next page. This is happening due to concurrency. I have tried CONCURRENT_REQUESTS=1 but same result. I have tried setting wait and pausing engine but in most cases, two or more threads arrive exactly at same line and so while first thread pause engine, 2 or more thread also pauses engine and tries to solve captcha. Can anyone please suggest anything to solve this issue.\nsorry if you didn't understand, Please comment any questions you have, I reply in seconds","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":88,"Q_Id":59368079,"Users Score":-1,"Answer":"Use a blocking HTTP client library (e.g. Requests) for your API calls.","Q_Score":0,"Tags":"python,scrapy,scrapy-splash","A_Id":59377590,"CreationDate":"2019-12-17T05:27:00.000","Title":"I am having problem in scrapy concurrency with captcha","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wonder what does .build_vocab_from_freq() function from gensim actually do? What is the difference when I'm not using it? Thank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":397,"Q_Id":59368232,"Users Score":0,"Answer":"It \"builds a vocabulary from a dictionary of word frequencies\". You need a vocabulary for your gensim models. Usually you build it from your corpus. This is basically an alternative option to build your vocabulary from a word frequencies dictionary. Word frequencies for example are usually used to filter low or high frequent words which are meaningless for your model.","Q_Score":0,"Tags":"python,gensim,word2vec,fasttext","A_Id":59368454,"CreationDate":"2019-12-17T05:48:00.000","Title":"Gensim Word2Vec or FastText build vocab from frequency","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was hoping that just using something like\nwith open(file_name, \"w\") as f:\nwould not change ctime if the file already existed. Unfortunately it does.\nIs there a version which will leave the ctime intact?\nMotivation:\nI have a file that contains a list of events. I would like to know how old the oldest event is. It seems this should be the files ctime.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":476,"Q_Id":59371466,"Users Score":3,"Answer":"Beware, ctime is not the creation time but the inode change time. It is updated each time you write to the file, or change its meta-data, for example rename it. So we have:\n\natime : access time - each time the file is read\nmtime : modification time - each time file data is change (file is written to)\nctime : change time - each time something is changed in the file, either data or meta-data like name or (hard) links\n\nI know no way to reset the ctime field because even utimes and its variant can only set the atime and mtime (and birthtime for file systems that support it like BSD UFS2) - except of course changing the system time with all the involved caveats...","Q_Score":0,"Tags":"python,linux","A_Id":59372442,"CreationDate":"2019-12-17T09:45:00.000","Title":"How do you write to a file without changing its ctime?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was hoping that just using something like\nwith open(file_name, \"w\") as f:\nwould not change ctime if the file already existed. Unfortunately it does.\nIs there a version which will leave the ctime intact?\nMotivation:\nI have a file that contains a list of events. I would like to know how old the oldest event is. It seems this should be the files ctime.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":476,"Q_Id":59371466,"Users Score":1,"Answer":"Because fopen works that way when using 'w' as an option. From the manual:\n\n\"w\"   write: Create an empty file for output operations.\n  If a file with the same name already exists, its contents are discarded and the file is treated as a new empty file.\n\nIf you don't want to create a new file use a+ to append to the file. This leaves the create date intact.","Q_Score":0,"Tags":"python,linux","A_Id":59371703,"CreationDate":"2019-12-17T09:45:00.000","Title":"How do you write to a file without changing its ctime?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am solving a system of non-linear equations using the Newton Raphson Method in Python. This involves using the solve(Ax,b) function (spsolve in my case, which is for sparse matrices) iteratively until the error or update reduces below a certain threshold. My specific problem involves calculating functions such as x\/(e^x - 1) , which are badly calculated for small x by Python, even using np.expm1().\nDespite these difficulties, it seems like my solution converges, because the error becomes of the order of 10^-16. However, the dependent quantities, do not behave physically, and I suspect this is due to the precision of these calculations. For example, I am trying to calculate the current due to a small potential difference. When this potential difference becomes really small, this current begins to oscillate, which is wrong, because currents must be conserved.\nI would like to globally increase the precision of my code, but I'm not sure if that's a useful thing to do since I am not sure whether this increased precision would be reflected in functions such as spsolve. I feel the same about using the Decimal library, which would also be quite cumbersome. Can someone give me some general advice on how to go about this or point me towards a relevant post?\nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":59372579,"Users Score":0,"Answer":"You can try using mpmath, but YMMV. generally scipy uses double precision. For a vast majority of cases, analyzing the sources of numerical errors is more productive than just trying to reimplement everything with higher widths floats.","Q_Score":1,"Tags":"python,numpy,scipy","A_Id":59381955,"CreationDate":"2019-12-17T10:48:00.000","Title":"Can you change the precision globally of a piece of code in Python, as a way of debugging it?","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 an error, when I install google-cloud-video intelligence. ERROR: Could not install packages due to an Environment Error: [Errno 2] No such file or directory: \n\n'C:\\Users\\Supervisor\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\google\\cloud\\videointelligence_v1\\gapic\\transports\\__pycache__\\video_intelligence_service_grpc_transport.cpython-37.pyc'\n\nOn stackoverflow I found several comments that I should install virtualenv before.\nWhen I install virtualenv and after them I set virtualenv a error occured: OSError: [Errno 22] Invalid argument: \n\n'C:\\Users\\Supervisor\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\python.exe'.\n\nI don't know what I can do? I have test so much and investate so much time but I can't install google-cloud-videointelligence.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":59374897,"Users Score":0,"Answer":"Yes, the installation is on Windows. I think, I have set virtualenv on the correct path >c:\\users\\supervisor\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.7_qbz5n2kfra8p0\\localcache\\local-packages\\python37\\Scripts<\nThat are the first two lines as result when I start virtualenv with the path declaration:\nC:\\Program Files (x86)\\Google\\Cloud SDK>virtualenv c:\\users\\supervisor\\appdata\\local\\packages\\pythonsoftwarefoundation.python.3.7_qbz5n2kfra8p0\\localcache\\local-packages\\python37\\Scripts\nUsing base prefix 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_3.7.1520.0_x64__qbz5n2kfra8p0'\nIn the last line appears an error:\n[Errno 22] Invalid argument: 'C:\\Users\\Supervisor\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\python.exe'\nUsing base prefix 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_3.7.1520.0_x64__qbz5n2kfra8p0'\nI think the definition on >Using base prefix< is wrong, but I don't no how I can change this definition.","Q_Score":2,"Tags":"python,video-intelligence-api","A_Id":59379263,"CreationDate":"2019-12-17T13:06:00.000","Title":"Cannot install google-cloud-videointelligence","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an error, when I install google-cloud-video intelligence. ERROR: Could not install packages due to an Environment Error: [Errno 2] No such file or directory: \n\n'C:\\Users\\Supervisor\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\google\\cloud\\videointelligence_v1\\gapic\\transports\\__pycache__\\video_intelligence_service_grpc_transport.cpython-37.pyc'\n\nOn stackoverflow I found several comments that I should install virtualenv before.\nWhen I install virtualenv and after them I set virtualenv a error occured: OSError: [Errno 22] Invalid argument: \n\n'C:\\Users\\Supervisor\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\python.exe'.\n\nI don't know what I can do? I have test so much and investate so much time but I can't install google-cloud-videointelligence.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":73,"Q_Id":59374897,"Users Score":1,"Answer":"I'm pretty sure your path is messed up. I believe you are on windows. Make sure that your virtualenv is installing at the right spot and that the multiple version of python you have have the right ordering in your PATH variable.","Q_Score":2,"Tags":"python,video-intelligence-api","A_Id":59374937,"CreationDate":"2019-12-17T13:06:00.000","Title":"Cannot install google-cloud-videointelligence","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to package up our code base for deployment.  The package will also need to include all the dependency packages in requirements.txt.  In the past what I did was setup a virtualenv for the project and package up the code base along with the virtualenv site-packages.  I'm wondering if there's an easier way for me just to grab all the dependency in the requirements.txt and just package those along with theirs dependencies and my code base.\nThanks.\n\nThank you for all the comments and suggestions, I think I found what I'm looking for.  I ended creating a temporary folder (pip install --target .\/temp) where my script parses the requirements.txt and installs all the modules in there to the temporary folder.  This gives me the isolation of all the modules and their dependencies that I needed.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":912,"Q_Id":59377311,"Users Score":1,"Answer":"It's super simple, go into your virtualenv and do pip freeze -l > requirements.txt.\nThat will populate your requirements properly. At the other end the only thing you need to do to have all the right package is pip install -r requirements.txt.","Q_Score":4,"Tags":"python","A_Id":59377430,"CreationDate":"2019-12-17T15:24:00.000","Title":"package up all dependencies in requirements.txt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"import sklearn\nversion--3.8.0 64-bit\n\n\n\nTraceback (most recent call last):\n  File \"\", line 1, in \n    import sklearn\n  File \"C:\\Users\\SAI-PC\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\sklearn__init__.py\", line 75, in \n    from .utils._show_versions import show_versions\n  File \"C:\\Users\\SAI-PC\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\sklearn\\utils_show_versions.py\", line 12, in \n    from ._openmp_helpers import _openmp_parallelism_enabled\nImportError: DLL load failed while importing _openmp_helpers: The specified module could not be found.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1319,"Q_Id":59377573,"Users Score":0,"Answer":"Tried hard to solve it in IDLE but it didn't got rectified. Finally overcame it by installing anaconda IDE and using jupyter notebook.","Q_Score":1,"Tags":"python-3.x,scikit-learn,openmp,dllimport,sklearn-pandas","A_Id":59410610,"CreationDate":"2019-12-17T15:38:00.000","Title":"ImportError: dll load failed while importing _openmp_helpers: The specified module could not be found while importing sklearn package","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a multiclass, single label classifier which predicts some samples as \"-1\", which means that it is not confident enough to assign the sample a label. I would like to use sklearn.metrics.precision_recall_fscore_support to calculate the metrics for the model, however I am unable to prevent the \"-1\" classifications from being considered as false positives. \nThe only thing I can think of is to do this on a \"per class\" basis for the metrics then do a weighted-average over the metrics excluding the \"-1\" class (i.e. the micro option in precision_recall_fscore_support while excluding \"-1\" false positives).\nIs there any standardized way to do this in sklearn without having to compute the averages myself?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":20,"Q_Id":59381435,"Users Score":0,"Answer":"I believe I figured it out. The labels parameter of precision_recall_fscore_support allows you to specify which labels you desire to use. Therefore, by using labels=list(set(y_true).union(set(y_pred)).difference(set([\"-1\"])))\nI am able to obtain the desired behavior.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn","A_Id":59381734,"CreationDate":"2019-12-17T20:11:00.000","Title":"sklearn.metrics Prevent unlabeled predictions from being classified as false positives","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Presently, we send entire files to the Cloud (Google Cloud Storage) to be imported into BigQuery and do a simple drop\/replace. However, as the file sizes have grown, our network team doesn't particularly like the bandwidth we are taking while other ETLs are also trying to run. As a result, we are looking into sending up changed\/deleted rows only. \nTrying to find the path\/help docs on how to do this. Scope - I will start with a simple example. We have a large table with 300 million records. Rather than sending 300 million records every night, send over X million that have changed\/deleted. I then need to incorporate the change\/deleted records into the BigQuery tables. \nWe presently use Node JS to move from Storage to BigQuery and Python via Composer to schedule native table updates in BigQuery.\nHope to get pointed in the right direction for how to start down this path.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":284,"Q_Id":59381483,"Users Score":1,"Answer":"Stream the full row on every update to BigQuery.\nLet the table accommodate multiple rows for the same primary entity.\nWrite a view eg table_last that picks the most recent row. \nThis way you have all your queries near-realtime on real data. \nYou can deduplicate occasionally the table by running a query that rewrites self table with latest row only. \nAnother approach is if you have 1 final table, and 1 table which you stream into, and have a MERGE statement that runs scheduled every X minutes to write the updates from streamed table to final table.","Q_Score":0,"Tags":"python,node.js,google-bigquery","A_Id":59382310,"CreationDate":"2019-12-17T20:15:00.000","Title":"BigQuery - Update Tables With Changed\/Deleted Records","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been trying to pull out financial statements embedded in annual reports in pdf and export them in excel\/CSV format using python But I am encountering some problems:\n1. A specific Financial statement can be on any page in the report. If I were to process hundreds of pdfs, I would have to specify page numbers which takes alot of time. Is there any way through which the scraper knows where the exact statement is?\n2. Some reports span over multiple pages and the end result after scraping a pdf isnt what I want\n3. Different annual reports have different financial statement formats. Is there any way to process them and change them to a specific standard format?\nI would also appreciate if anyone have done something like this and can share examples.\nPs I am working with python and used tabula and Camelot","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2226,"Q_Id":59382641,"Users Score":0,"Answer":"I had a similar case where the problem was to extract specific form information from pdfs (name, date of birth and so on). I used the tesseract open source software with pytesseract to perform OCR on the files . Since I did not need the whole pdfs, but specific information from them, I designed an algorithm to find the information: In my case I used simple heuristics (specific fields, specific line number and some other domain specific stuff), but you can also use a machine-learning approach and train a classifier which can find the needed text-parts. You could use domain-specific heuristics as well, because I am sure that a financial statement has special vocabulary or some text markers which indicate its beginning\/its end. \nI hope I could at least give you some ideas how to approach the problem\nP.S.: With tesseract you can also process multipage pdfs. To 3) - Machine learning approach would need some samples to learn a good generalization of how a financial statement may look like.","Q_Score":0,"Tags":"python,pdf-scraping","A_Id":59383076,"CreationDate":"2019-12-17T21:52:00.000","Title":"Extraction of financial statements from pdf reports","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been working on image processing problem and I have preprocessed a bunch of images to find the most prominent horizontal lines in those images. Based on this data, I want to classify if the image has a good perspective angle or a bad angle. \nThe data points are angles of lines I was able to detect in a sequence of images. Based on the perspective of the image, I know this data sometimes represents a \"good-angle\" image, and in some other cases, it represents a \"bad-angle\" image.\nI tried np.polyfit, finding slopes of lines, finding derivatives of slopes, and several other methods but unable to find a simple metric that is so obvious by just looking at this data.\nThese are examples of \"Good angles\". You can notice they start from positive ones, and later ones are are negative. \nGood angle data\n[7.97, 7.99, 9.01, 5.07, 5.01, 14.81, 8.86, -2.11, -0.86, 1.06, 0.86, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.97, 0.92, -0.95, -2.05, -2.2, -2.78, -2.93, -2.8, -2.99, -2.88, -2.94, -2.81, -3.04, -3.07, -3.0]\n[3.96, 4.12, 6.04, 6.03, 6.08, 5.99, 6.99, 6.81, 6.81, 6.1, 6.1, 4.06, 3.98, 4.03, 3.92, 3.95, 3.84, 3.94, 4.07, 3.95, 3.87, 2.65, 1.88, 0.0, 0.0, -0.94, -1.06, -1.81, -1.81, -3.95, -4.09, -4.0, -3.93]\n[8.75, 10.06, 9.02, 9.96, 9.89, 10.08, 9.99, 10.0, 10.02, 9.95, 4.04, 4.03, 3.93, -1.18, -0.95, -1.12, -1.02, -1.76, -1.92, -2.06, -5.99, -5.83, -6.01, -4.96, -7.84, -7.67]\nThese are examples of \"Bad Angle\" images. You can notice they start from negative numbers, and later ones are positive. You can also notice that these are significantly larger numbers than 0.\nBad Angle Data\n[-13.92, -14.93, -4.11, -4.04, -2.18, 17.12, 18.01, 16.91, 15.95, 16.75, 14.16, 14.04]\n[-14.93, -14.93, -7.92, -4.04, -5.91, -4.98, 16.08, 16.26, 16.24]\n[11.81, -9.77, -10.2, -9.96, -10.09, -6.81, 2.13, 3.02, 2.77, 3.01, 2.78, 5.92, 5.96, 5.93, 2.96, 3.06, 1.03, 2.94, 6.2, 5.81, 5.04, 7.13, 5.89, 5.09, 4.89, 3.91, 4.15, 17.99, 6.04, 5.67, 7.24, 16.34, 17.02, 16.92, 15.99, 16.93, 15.76]\nAs this is based off of data captured from real images, we do have some irregularities in the dataset. I would like to avoid any glitches and use a metric that can classify my arrays as Good angle or bad angles.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":59385064,"Users Score":0,"Answer":"If my assumptions are true I don't see a reason for any complex classifier. I'd simply check if the angle always gets larger or always gets smaller. Everytime this rule is followed you add 1 to a quality counter. If the rule is broken you reduce the quality counter by 1. In the end you divide the quality counter by the total amount of measured angles -> and then you decide a threshold for a good quality ratio.\nSorry if I don't understand the issue any better - an actual image could help a lot.","Q_Score":1,"Tags":"python,numpy,opencv,statistics,regression","A_Id":59387758,"CreationDate":"2019-12-18T03:24:00.000","Title":"Best way to classify a series of data in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a script that can run the python django application. I run this script using pm2.\nI do pm2 start scripts.sh, it works properly but after some time my application doesn't work and displays an error like this\n\nthe runtime process for the instance running on port 37001 has unexpectedly quit**\n\nI show the log using pm2 logs, it displays an error like this\n\nscript.sh had too many unstable restarts (16). Stopped. \"errored\"\n\nHow to resolved it? Can anyone help me?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1539,"Q_Id":59385608,"Users Score":0,"Answer":"I had the same issue and resolved with:\npm2 kill\nrm -rf node_modules\nnpm i\npm2 start index.js\nsudo shutdown -r now","Q_Score":0,"Tags":"python-2.7,pm2,django-errors,pm2-logrotate","A_Id":72179224,"CreationDate":"2019-12-18T04:46:00.000","Title":"pm2 crash with too many unstable restarts (16). Stopped. \"errored\" in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I made a c# application that draw random point on the panel. I need to cluster this points according to euclidian distance. I already implement kruskal algorithm. Normally, there must be number of minimum spanning tree up to written number. For instance, when the user want to clusters drawn point for 3 clusters , end of the kruskal algorithm there must be 3 huge MST. \nBut I did it in a different way. I made a one huge  MST, now I have to divide this MST into written number of clusters.\nFor example, point number = 5 , cluster number 2  my kruskal output is = 0-3:57  1-2:99  1-4:102 \nfrom-to:euclidian distance \nProblem is I don't know in where I should cut these MST for create clusters","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":233,"Q_Id":59389090,"Users Score":2,"Answer":"In Kruskal's algorithm, MST edges are added in order of increasing weight.\nIf you're starting with an MST and you want to get the same effect as stopping Kruskal's algorithm when there are N connected components, then just delete the N-1 highest-weight edges in the MST.","Q_Score":0,"Tags":"python,algorithm,cluster-analysis","A_Id":59394538,"CreationDate":"2019-12-18T09:34:00.000","Title":"Dividing MST for kruskal clustering","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Django project with about 100 class-based views (to now) in a views.py file.\nNow managing the views is getting harder. If I put each view in a separate .py file and import all in views folder __init__.py, does it affect the performance?\nMy concern is performance, not code style.\nWhat about DRF class-based views and serializers?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":194,"Q_Id":59391431,"Users Score":2,"Answer":"Here are two points:\n\n1.does it have effect on the performance?\n\nNo, or only marginally. Also, It might take some extra time to load all these files into memory (since each file needs to be opened), hence writing these views in individual files indeed might take a few cycles extra. So first of all this is bad idea for increasing performance. \nBut that will only happen when you start the webserver. Once the files are loaded, it does not make much difference in what module the view is defined. The interpreter will simply call the function.\nThat being said, Python is not a language designed to take the absolute most of the CPU anyway. The idea of Python is, to some extent, Programmer convenience over machine performance. Due to Python's very dynamic nature, it will often not result in the fastest programs. The idea is to offer a programmer a convenient environment. Often if you need more processing power, you can buy an extra server, whereas hiring an extra developer is often more costly. Therefore developing a webserver in Django will likely not result in the fastest response times, but it will likely make your job simpler to implement such server.\n\n\nDjango's Architecture\n\n\nYou should also consider Django's architecture. It's a bad exercise to try to change this architecture. In this architecture, everything is designed to avoid duplication(DRY). And if another developer intends to deliver your project, he or she will be able to take it in as little time as possible. As a result, it seems better to keep this architecture and put all your CBVs in one views.py.","Q_Score":3,"Tags":"python,django,performance,django-rest-framework,django-views","A_Id":59393052,"CreationDate":"2019-12-18T11:51:00.000","Title":"Will it hurt performance if each view class is moved to a separate .py file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on jupyter notebook on a python assignment and \nI am trying to import  KNearestNeighbor from sklearn but I am getting the error:\n\nImportError: cannot import name 'KNearestNeighbor' from 'sklearn'\n  (C:\\Users\\michaelconway\\Anaconda3\\lib\\site-packages\\sklearn__init__.py)\n\nI have checked and I do have sklearn installed: version 0.22\nAny ideas please?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1512,"Q_Id":59393468,"Users Score":3,"Answer":"I have never seen KNearestNeighbor in sklearn. There is two thing you can do instead of KNearestNeighbor\n\nfrom sklearn.neighbors import KNeighborsClassifier\n\nor     \n\nfrom sklearn.neighbors import NearestNeighbors\n\nI think 1st option is the option which you want now","Q_Score":1,"Tags":"python,scikit-learn","A_Id":59394913,"CreationDate":"2019-12-18T13:50:00.000","Title":"Cannot import from sklearn import c","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have no idea what I messed up, but it seems like a lot.\nThe problem:\n(I am using Windows 10, and only using the \"normal\" black terminal you get when you type \"CMD\" into the search.)\nI have installed Python 3.8, and subsequently deleted all older versions (2.6,2.7,3.7) of Python, since I figured I don't need them anymore. Now Python will only work if I type 'py' into the terminal window, 'python' can not find an appropriate command. (Along the way I messed up pip, but this is a different story.)\nIs this the \"normal\" command for Python 3? Did I rename my commands some time in the past? How do I use 'python' again? or should I not?\nWhen I install Python it never asks me how I want to name the command, so I figure installing it one more time will not help.\n(Sorry for maybe dumb questions, but this problem seems like one I can solve, before moving on to fixing pip.)","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":97,"Q_Id":59393856,"Users Score":1,"Answer":"Try to check your symbolic links:\ndir \/AL \/S C:\\\n\n\/A displays all files with a specific attribute, and L specifies reparse points (symlinks and directory junctions)\n\/S makes the command recursive\n\nReplace C:\\ with the drive letter you want to scan, or with a path if you don't want to scan an entire drive.\nTo delete a symbolic link, you may treat it like any other directory or file. \n\nIf you created a symbolic link to a directory, use the rmdir command.\nIf you created a symbolic link to a file, use the del command.","Q_Score":1,"Tags":"python-3.x,windows,terminal","A_Id":59394110,"CreationDate":"2019-12-18T14:10:00.000","Title":"Python only reacts to 'py' command - How to revert to standard?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have no idea what I messed up, but it seems like a lot.\nThe problem:\n(I am using Windows 10, and only using the \"normal\" black terminal you get when you type \"CMD\" into the search.)\nI have installed Python 3.8, and subsequently deleted all older versions (2.6,2.7,3.7) of Python, since I figured I don't need them anymore. Now Python will only work if I type 'py' into the terminal window, 'python' can not find an appropriate command. (Along the way I messed up pip, but this is a different story.)\nIs this the \"normal\" command for Python 3? Did I rename my commands some time in the past? How do I use 'python' again? or should I not?\nWhen I install Python it never asks me how I want to name the command, so I figure installing it one more time will not help.\n(Sorry for maybe dumb questions, but this problem seems like one I can solve, before moving on to fixing pip.)","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":97,"Q_Id":59393856,"Users Score":1,"Answer":"As suggested by Andrew Morton in the first comment \"Turning it off and on again\" helped. I 'repaired' the Python 3.8 installation, and then closed and reopened the terminal window.\nNow:\n\nthe 'py' command is gone\nthe 'python' command uses python 3.8\nthe 'pip3' command finds python again (before it crashed looking for 3.7)\n\nThanks for the suggestion!","Q_Score":1,"Tags":"python-3.x,windows,terminal","A_Id":59394278,"CreationDate":"2019-12-18T14:10:00.000","Title":"Python only reacts to 'py' command - How to revert to standard?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I read something like this\n\nITK is distributed in binary Python packages. To install:\npip install itk\n\nWhat does \"binary Python packages\" mean, given that python is a script language (that is to be interpreted rather than compiled)?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":827,"Q_Id":59394213,"Users Score":2,"Answer":"A binary Python package is usually a packaged Python library that comes with one or more pre-compiled binary modules. Theses modules are usually .so or .dll libraries in binary (compiled) form. They are often written in C.\nSuch binary distributions of Python packages are in most cases very dependent on the platform they are created for.","Q_Score":2,"Tags":"python,binary","A_Id":59394464,"CreationDate":"2019-12-18T14:30:00.000","Title":"What does \"binary Python packages\" mean, given that python is a script language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I read something like this\n\nITK is distributed in binary Python packages. To install:\npip install itk\n\nWhat does \"binary Python packages\" mean, given that python is a script language (that is to be interpreted rather than compiled)?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":827,"Q_Id":59394213,"Users Score":1,"Answer":"ITK is primarily written in C++.  ITK-python provides a Python interface to the underlying C++ routines.  If ITK were pure Python code it would be orders of magnitude slower.\nTo create that Python interface SWIG is used to create the glue code, and that SWIG produced code is in C\/C++.  Therefore the ITK-python interface (and the ITK code underlying it) needs to be compiled for every platform (Linux, Mac, Windows and every version of Python).","Q_Score":2,"Tags":"python,binary","A_Id":59426848,"CreationDate":"2019-12-18T14:30:00.000","Title":"What does \"binary Python packages\" mean, given that python is a script language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently have a python project which basically reads data from an excel file, transforms and formats it, performs intensive calculations on the formatted data, and generates an output. This output is written back on the same excel file.\nThe script is run using a Pyinstaller EXE which basically is packing all the required libraries and the code itself, so every user is not required to prep the environment to run the script.\nBoth, the script EXE and the Excel file, sit on the user's machine.\nI need some suggestion on how this entire workflow could be achieved using AWS. Like what AWS services would be required etc.\nAny inputs would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":98,"Q_Id":59397424,"Users Score":1,"Answer":"One option would include using S3 to store the input and output files.  You could create a lambda function (or functions) that does the computing work and that writes the update back to S3.\nYou would need to include the Python dependencies in your deployment zip that you push to AWS Lambda or create a Lambda layer that has the dependencies.\nYou could build triggers to run on things like S3 events (a file being added to S3 triggers the Lambda), on a schedule (EventBridge rule invokes the Lambda according to a specific schedule), or on demand using an API (such as an API Gateway that users can invoke via a web browser or HTTP request).  It just depends on your need.","Q_Score":1,"Tags":"python,amazon-web-services","A_Id":59397565,"CreationDate":"2019-12-18T17:37:00.000","Title":"Suggestions to run a python script on AWS","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":1,"Web Development":0},{"Question":"I have a dataset with many different samples (numpy arrays). It is rather impractical to store everything in only one file, so I store many different 'npz' files (numpy arrays compressed in zip).\nNow I feel that if I could somehow exploit the fact that all the files are similar to one another I could achieve a much higher compression factor, meaning a much smaller footprint on my disk.\nIs it possible to store separately a 'zip basis'? I mean something which is calculated for all the files together and embodies their statistical features and is needed for decompression, but is shared between all the files.\nI would have said 'zip basis' file and a separate list of compressed files, which would be much smaller in size than each file zipped alone, and to decompress I would use the share 'zip basis' every time for each file.\nIs it technically possible? Is there something that works like this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":59397512,"Users Score":0,"Answer":"A 'zip-basis' is interesting but problematic. \nYou could preprocess the files instead. Take one file as a template and calculate the diff of each file compared to the template. Then compress the diffs.","Q_Score":1,"Tags":"python,zip,compression","A_Id":59445732,"CreationDate":"2019-12-18T17:43:00.000","Title":"I must compress many similar files, can I exploit the fact they are similar?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"To be very honest, I've played with matplotlib a little but iam new to django.\nI have wandered all over google to search to plot a line graph in django using csv.\nUnfortunately i couldnt find anything apart from 'bokeh' and 'chartit'. Although they arent very useful to help me make a start.\nMy Goal: I need to plot a line graph, where x-axis have dates, y-axis have some numbers.\nNow, what should my views.py look like? What thing should i include in template?\nAnyone please help me out, or send me some provide some video tutorial to start with","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":139,"Q_Id":59398219,"Users Score":0,"Answer":"as pointed out by @roganjosh, you'll render the graph using a js library.\nSo in the views.py you'll have to add your data to the context, and then render it in the template using a js library. I personally like plotly.js, they have a neat and easy to use interface. D3.js is also a very popular data visualisation library.","Q_Score":0,"Tags":"python,django","A_Id":59398539,"CreationDate":"2019-12-18T18:35:00.000","Title":"Line Graph in django template","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've read that .PNG, .JPEG, and other image file types can potentially contain malware.\nI am looking to remove potential malware embedded in user-uploaded images. Is there a way in Python to essentially \"flatten\" an image that would essentially remove any malicious content? Kind of like if you were to take a screenshot of the image then save the screenshot? Or maybe there is an image type that can't be corrupted as easily?\nI am already hosting all user uploaded content on a separate domain, but am wondering if I can take this a step further.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1130,"Q_Id":59399809,"Users Score":3,"Answer":"\"malicious\" content is contained in the image metadata.\nWhen you read the image data (pixels, colors) in a matrix (using pillow aka PIL library in python for instance), you just get the image data.\nWhen you save it back, the meta data is lost, keeping only the image data.\nSaving it back can have undesired side-effects, though:\n\nlossy compression alters the image\ndepending on the output format, transparency can be unsupported, and lost","Q_Score":3,"Tags":"python,python-imaging-library,malware","A_Id":59406394,"CreationDate":"2019-12-18T20:51:00.000","Title":"Removing potential malware in image in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just upgraded python and I cannot get pandas to run properly, please see below. Nothing appears to work.\n\nTraceback (most recent call last):   File\n  \"\/Library\/Frameworks\/Python.framework\/Versions\/3.8\/lib\/python3.8\/site-packages\/tqdm\/_tqdm.py\",\n  line 613, in pandas\n      from pandas.core.groupby.groupby import DataFrameGroupBy, \\ ImportError: cannot import name 'DataFrameGroupBy' from\n  'pandas.core.groupby.groupby'\n  (\/Library\/Frameworks\/Python.framework\/Versions\/3.8\/lib\/python3.8\/site-packages\/pandas\/core\/groupby\/groupby.py)\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):   File\n  \"code\/analysis\/get_cost_matrix.py\", line 23, in \n      tqdm.pandas() # Gives us nice progress bars   File \"\/Library\/Frameworks\/Python.framework\/Versions\/3.8\/lib\/python3.8\/site-packages\/tqdm\/_tqdm.py\",\n  line 616, in pandas\n      from pandas.core.groupby import DataFrameGroupBy, \\ ImportError: cannot import name 'PanelGroupBy' from 'pandas.core.groupby'\n  (\/Library\/Frameworks\/Python.framework\/Versions\/3.8\/lib\/python3.8\/site-packages\/pandas\/core\/groupby\/init.py)","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":2138,"Q_Id":59403256,"Users Score":3,"Answer":"I guess you are using an older version of tqdm. Try using a version above tqdm>=4.23.4. \nThe command using pip would be,\npip install tqdm --upgrade","Q_Score":3,"Tags":"python-3.x,pandas","A_Id":59403299,"CreationDate":"2019-12-19T04:20:00.000","Title":"Pandas not working: DataFrameGroupBy ; PanelGroupBy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some graph data with date type values.\nMy gremlin query for the date type property is working, but output value is not the date value.\nEnvironment:\n\nJanusgraph 0.3.1 \ngremlinpython 3.4.3\n\nBelow is my example:\n\nData (JanusGraph): {\"ID\": \"doc_1\", \"MY_DATE\": [Tue Jan 10 00:00:00 KST 1079]}\nQuery: g.V().has(\"ID\", \"doc_1\").valueMap(\"MY_DATE\")\nOutput (gremlinpython): datetime(1079, 1, 16)\n\nThe error is 6 days (1079.1.10 -> 1079.1.16).\nThis mismatch does not occur when the years are above 1600.\nDoes the timestamp have some serialization\/deserialization problems between janusgraph and gremlinpython?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":434,"Q_Id":59405888,"Users Score":1,"Answer":"After some try & search, I found that there are some difference between java Date and python datetime. (Julian vs. Gregorian Calendar)\nSo I have replaced SimpleDateFormat with JodaTime and got the expected result as below:\n\nData (Raw): {\"ID\": \"doc_1\", \"MY_DATE\": \"1079-1-29\"}\nData (JanusGraph): {\"ID\": \"doc_1\", \"MY_DATE\": [Wed Jan 23 00:32:08 KST 1079]}\n\n\n(I think the JanusGraph uses java Date object internally..)\n\nQuery: g.V().has(\"ID\", \"doc_1\").valueMap(\"MY_DATE\")\nOutput (gremlinpython): datetime(1079, 1, 29)\n\nThanks","Q_Score":1,"Tags":"gremlin,janusgraph,gremlinpython","A_Id":59463174,"CreationDate":"2019-12-19T08:33:00.000","Title":"Mismatch between janusgraph date value and gremlin query result","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to get focal length and\/or sensor size directly from the camera using GPhoto2?\nI've tried to look for it in camera object and in file info, but to no avail.\nI also know I can get\/set some parameters (speed, aperture and so on) using config.\nFocal length is not one of them for obvious reasons, but I was wondering if camera knows its current value. Same for the sensor size, of course it's not configurable, but I assume camera would know it internally.\nWhy do I need this? I need to know focal length in pixels and I intend to compute it from focal length, sensor size and image resolution.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":334,"Q_Id":59407082,"Users Score":1,"Answer":"The camera config can include read-only parameters, which might include focal length for some cameras. (The whole config is very camera dependent.)\nThe only solution I can suggest is to take a photo, copy it from the camera (or even just copy the first few kilobytes) then get the info you want from the photo's Exif data.","Q_Score":0,"Tags":"python-3.x,libgphoto2","A_Id":59408595,"CreationDate":"2019-12-19T09:48:00.000","Title":"GPhoto2 - get focal length and sensor size directly from the camera","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 .wav file, one contains the original audio (original.wav), while the other contains perturbation (attacked.wav)which is generated from an audio adversarial example attack code.\nHow can i extract the perturbation as a separate perturbation.wav file by comparing the original.wav files with attacked.wav preferably using python3","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":59407880,"Users Score":0,"Answer":"think of it this way ... you have a value 7 then you perturb this by an as of yet unknown force which results in changing your original value into a value 9 ... what arithmetic operation can you perform using these two values to identify the perturbation ?\nDo not over think this ... once you have solved this thought experiment the same principles apply to solving your question ... \n\nHint ...  this same approach is how noise cancelling headphones work\n\nnow back to your challenge ... audio is a curve over time ... your wav audio file can be opened up and parsed into this audio curve its called PCM format ... its just points along this curve ...  once you have opened up both of your files ( assume your recordings are both time aligned so beginning of the file on each represents the same instant in time ) then iterate across the audio curve of both files simultaneously and perform the same operation you discovered above to synthesize an output wav file of just the perturbation audio curve\n\nbefore touching any code it would behoove you to be able to grok the trick we are using here","Q_Score":1,"Tags":"python,audio,signal-processing,pcm,noise-reduction","A_Id":59410930,"CreationDate":"2019-12-19T10:34:00.000","Title":"Extracting perturbation from .wav file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have successfully trained a predictor model - so with no labels using ModelTraining class.\nCurrently, I can use CustomImagePrediction.predictImage() to return a value of what it thinks is in the picture.\nI want to be able to detect the location of the object in the image, not just what it thinks it is. This functionality is in CustomObjectDetection but this is obviously a different class (gives a no label error as it requires the other training method, with the labels).\nIs it possible to achieve this with a predictor model?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":135,"Q_Id":59409085,"Users Score":1,"Answer":"No, location of objects is only possible with detection because it works on coordinates (bounding box), label error means you have to annotate your dataset.","Q_Score":0,"Tags":"python,tensorflow,keras,imageai","A_Id":63578193,"CreationDate":"2019-12-19T11:42:00.000","Title":"ImageAI Object detection with prediction training","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing a work-related project in which I should study whether we could extract certain fields of information (e.g. contract parties, start and end dates) from contracts automatically.\nI am quite new to working with text data and am wondering if those pieces of information could be extracted with ML by having the whole contract as input and the information as output without tagging or annotating the whole text?\nI understand that the extraction should be ran separately for each targeted field.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":846,"Q_Id":59409984,"Users Score":0,"Answer":"First question - how are the contracts stored?  Are they PDFs or text-based?\nIf they're PDFs, there are a handful of packages that can extract text from a PDF (e.g. pdftotext).  \nSecond question - is the data you're looking for in the same place in every document?  \nIf so, you can extract the information you're looking for (like start and end dates) from a known location in the contract.  If not, you'll have to do something more sophisticated.  For example you may need to do a text search for \"start date\", if the same terminology is used in every contract.  If different terminology is used from contract to contract, you may need to work to extract meaning from the text, which can be done using some sophisticated natural language processing (NLP).  \nWithout more knowledge of your problem or a concrete example, it's hard to say what your best option may be.","Q_Score":0,"Tags":"python,machine-learning,nlp,information-extraction","A_Id":59414169,"CreationDate":"2019-12-19T12:38:00.000","Title":"Is there a way to extract information from contracts using ML with including contract files and targeted strings as inputs and outputs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Spyder and PyCharm.\nI would like to know if it is possible to debug on specific line? (Said Line 150)\nBecause I want to do machine learning, and because it takes a lot of time, I dont wat to repeat the training if I have problem on another line.\nThankyou","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":221,"Q_Id":59411328,"Users Score":1,"Answer":"For machine learning I recommend using Jupyter notebook since it makes your programming and debugging tasks much more modular in the sense that you don't have to execute your full script every time but rather cells. \nEspecially for data wrangling Jupyter notebook gives a much more structured overview. For debugging purposes, being able to run cells in any order works wonders.\nGetting used to Jupyter is worthwhile especially if you are working with data science.","Q_Score":0,"Tags":"python","A_Id":59411675,"CreationDate":"2019-12-19T14:03:00.000","Title":"Can python start debugging on specific line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Spyder and PyCharm.\nI would like to know if it is possible to debug on specific line? (Said Line 150)\nBecause I want to do machine learning, and because it takes a lot of time, I dont wat to repeat the training if I have problem on another line.\nThankyou","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":221,"Q_Id":59411328,"Users Score":1,"Answer":"Yes, it's possible, but all the code before has to be executed before. Maybe we have a missunderstand with the \"debug\" word but this isn't the point. What you can do, is save the weights and architecture of the network, and load them instead of trainning all again, and then make your debug.","Q_Score":0,"Tags":"python","A_Id":59411598,"CreationDate":"2019-12-19T14:03:00.000","Title":"Can python start debugging on specific line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I use a module such as tkinter, would somebody need to have that module installed as well in order for my code to run on their machine?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":42,"Q_Id":59411935,"Users Score":1,"Answer":"python comes with a number of standard modules pre-installed, if the other person is running python (the same version of you) then he\/she won't need to install anything, it will just work, that's the case of tkinter. But if you use external packages that you installed to run your code, for example celery, then he\/she will need to do the same thing.","Q_Score":0,"Tags":"python,module","A_Id":59411989,"CreationDate":"2019-12-19T14:40:00.000","Title":"Do others need to have the same modules installed to run my code in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I use a module such as tkinter, would somebody need to have that module installed as well in order for my code to run on their machine?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":59411935,"Users Score":0,"Answer":"In your running environment do a, this file you add to your repo\npip freeze > requirements.txt\nWhen people clone your repo, they only have to do a: \npip install -r requirements.txt\nand they will install exactly the same pypi modules you have.\nWith virtualenv you can isolate a python environment to each project, with pyenv you can use different pythonversions withing the various environment also.","Q_Score":0,"Tags":"python,module","A_Id":59412127,"CreationDate":"2019-12-19T14:40:00.000","Title":"Do others need to have the same modules installed to run my code in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I use a module such as tkinter, would somebody need to have that module installed as well in order for my code to run on their machine?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":42,"Q_Id":59411935,"Users Score":1,"Answer":"Definitely. You can use virtual environments or containers to deliver required packages or have a requrements.txt or similar to install the dependencies.","Q_Score":0,"Tags":"python,module","A_Id":59411983,"CreationDate":"2019-12-19T14:40:00.000","Title":"Do others need to have the same modules installed to run my code in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking to use Apache Superset and am considering if it will allow for me to connect to both POSTGres and MSSQL at the same time. \nThere might be instances of creating queries from both databases however, i cant figure out based on the API documentation if this can be done. \nnon-dev here.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2689,"Q_Id":59413246,"Users Score":2,"Answer":"You can indeed connect to both databases. Superset lets you connect many databases (and types thereof!) by adding various connection strings.\nHowever, you cannot do JOIN queries between the two databases. Superset takes your query and ships it down to the database to do the work. In order to join two databases in a query, Superset would have to basically do an ETL job pulling in both databases and doing the query there. That's not how it's built. \nBut again, you CAN have multiple data sources and have queries\/charts that call out to each of them, all rolled into one dashboard.","Q_Score":1,"Tags":"python,apache-superset","A_Id":59417376,"CreationDate":"2019-12-19T16:04:00.000","Title":"Multiple database access on Apache Superset?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to save the output of a task while it is running.\nI was able to save the output only after the task completion.\nI found in the C# azure sdk documentation that it has a SaveTrackedAsync function that enables to track a file and save it to a storage. Does the python SDK has a similar feature?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":88,"Q_Id":59414688,"Users Score":1,"Answer":"The Batch Python SDK does not have a built in similar feature. You should be able to create a storage BlobClient specified to create an append blob type.","Q_Score":0,"Tags":"python,azure-batch,azure-sdk,azure-sdk-python","A_Id":59415023,"CreationDate":"2019-12-19T17:54:00.000","Title":"Saving output while tasking is running in Azure Batch (using python SDK)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to install psycopg2-binary on Mac OS Catalina and Python 3.8. The build fails always when try to install using pip3. Is there any solution for this in Catalina ?\n\"ERROR: Failed building wheel for psycopg2-binary\"","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":1462,"Q_Id":59419819,"Users Score":5,"Answer":"I was able to compile psycopg2 on OS X 10.15.1 Catalina with $VENV\/bin\/pip install psycopg2 after doing a couple of things, first:\n\nRe-installed xcode command line headers (though it may have just been that I accepted the new terms of service) using xcode-select --install\nLinked homebrew ssl headers using export LDFLAGS=\"-L\/usr\/local\/opt\/openssl@1.1\/lib\" and export CPPFLAGS=\"-I\/usr\/local\/opt\/openssl@1.1\/include\"\ninstalling with $VENV\/bin\/pip install psycopg2 where VENV is the directory of my virtual environment\n\nIt looks like some others have had successes with just the xcode, but I also needed to add ssl things to the path.","Q_Score":1,"Tags":"python,django,postgresql,virtualenv,psycopg2","A_Id":59449573,"CreationDate":"2019-12-20T04:30:00.000","Title":"\u201cFailed building wheel for psycopg2-binary\u201d - Mac OS Catalina using virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"my code is very simple python, it stores a \"Hello World\" in a variable, and then calls by my email GMAIL and sends the data stored within the variable, until and all right\nthen I turned it into .exe (with cx_Freeze), and both the .py and .exe files were running perfectly on my computer, and sending me the message via email!\nhowever, after I tried to run the .exe file on another computer (I exported the entire executable folder and installed python on the other computer as a precaution), it simply stops running when it comes to sending the email, and closes the console by itself. ; -;\nit stops executing when calling by smtplib:\nimport smtplib\nHow can I solve this problem, I want to run my files on other machines!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":26,"Q_Id":59419937,"Users Score":0,"Answer":"The two machines may have different OS or CPUS, this could be an issue. Have you tried to transfer the source (python) code, and compile it on the other machine? That should fix the issue, and if you want to run it on many different machines, consider compiling it on the machine you would like to run it on, and then upload that file. Cheers!","Q_Score":0,"Tags":"python,exe,python-3.7,cx-freeze,smtplib","A_Id":59419983,"CreationDate":"2019-12-20T04:45:00.000","Title":"Error executing specific lines of a python library on another computer as exe 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":"A website has been developed on a local ubuntu machine using python flask. The website runs fine on ubuntu at 127.0.0.1:5000. This website is supposed to go live on a godaddy server for which there is cpanel access. How to do it?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":348,"Q_Id":59425136,"Users Score":1,"Answer":"If it's a shared hosting solution, Answer to your question is NO, you can't do it. In a shared hosting environment Godaddy using only a PHP Stack. so you won't be able to use python there. Either go with VPS and configure your server. or go with a cloud service provider like Digital ocean, AWS, Linode etc.,","Q_Score":0,"Tags":"python,flask,cpanel,godaddy-api","A_Id":59425216,"CreationDate":"2019-12-20T12:17:00.000","Title":"Flask cpanel godaddy 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":1},{"Question":"I have inserted data into table from postgresql directly. Now when I try to insert data from django application, it's generating primary key duplication error. How can I resolve this issue?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":59425728,"Users Score":0,"Answer":"I think problem is not in database. please check your django code probably you use get_or_create","Q_Score":0,"Tags":"python,django,database,postgresql","A_Id":59428772,"CreationDate":"2019-12-20T13:02:00.000","Title":"i have 600 records in my postgres database, now when i inserted from django it's generating primary duplication error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have inserted data into table from postgresql directly. Now when I try to insert data from django application, it's generating primary key duplication error. How can I resolve this issue?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":59425728,"Users Score":0,"Answer":"Run\npython manage.py sqlsequencereset [app_name]\nand execute all or just one for the required table SQL statements in the database to reset sequences.\n\nExplanation:\nYou probably inserted with primary keys already present in it, not letting postgresql to auto-generate ids. This is ok.\nThis means, internal Postgresql sequence used to get next available id has old value. You need to rest with sequence to start with maximum id present in the table.\nDjango manage.py has command intended just for that - print sql one can execute in db to reset sequences.","Q_Score":0,"Tags":"python,django,database,postgresql","A_Id":59425929,"CreationDate":"2019-12-20T13:02:00.000","Title":"i have 600 records in my postgres database, now when i inserted from django it's generating primary duplication error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What statistical techniques should I adopt when trying to determine how much my independent variables explain the variance of my dependent variable?\nFor further context - I have been asked to develop a model in Python with the aim of examining the extent to which the predictor variables impact upon the response variable. Having usually focused on developing models for predictive purposes, I am unsure of where to start here.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":59426564,"Users Score":0,"Answer":"I would begin analysis by finding the R-squared (R2) value of a model with all predictor variables, and then determine the change in R-squared when iteratively leaving out each predictor variable one at a time. Such an analysis should weed out the predictors with minimal impact on the regression, and give you a good idea of the impact for the remaining predictor variables. I would choose the R-squared fit statistic for this analysis as it is generally held to explain the amount of dependent data variance explained by the model, and I calculate R-squared by using numpy as \"R2 = 1.0 - (numpy.var(regression_error) \/ numpy.var(dependent_data))\"","Q_Score":1,"Tags":"python,machine-learning,statistics,regression","A_Id":59428792,"CreationDate":"2019-12-20T14:07:00.000","Title":"Examining explained and unexplained variance of the DV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem with Linux in PC. I installed python3.8. I want work with python 3. When I create a virtualenv file it gets created with python2, but I don't want work with python2. How can I enable python2?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7662,"Q_Id":59427704,"Users Score":0,"Answer":"Perhaps you can try to locate the location of the python version you want to use the interpreter of (eg. get its path through which python3). Once obtained the path you can create the enviroment specifying the location of the interpreter you want to use for that virtual environment virtualenv -p \/usr\/bin\/python3.6 venv","Q_Score":0,"Tags":"python,python-3.x,virtualenv","A_Id":59427830,"CreationDate":"2019-12-20T15:27:00.000","Title":"How to create a Virtualenv with Python 3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This might be a silly question to ask, however, it is for a specific task in a multi-step process to clean up some data. \nBasically, each column label is a location represented as a series of long numbers. Each column contains measurement values in each subsequent row for those locations. I do not need the measurements, only the locations (hence why I just need the column labels only). \nThe reason I need this is because I need to replace some mixed up column labels in one CSV file with the correct column labels from another CSV file. \nI cannot do this in Excel since there are too many columns to read in (over 300,000 columns). I am essentially looking for a way to do a coded \"Copy\" and \"Paste\" from one file to another using Pandas if it can be done. \nI had a considered just dropping the columns I do not need, however, because the columns are labelled as numbers, I'd be filtering based on a multiple set of a conditions. I thought this method would be easier. \nThank you for your help.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":702,"Q_Id":59429705,"Users Score":1,"Answer":"Just dodataframe.columns to get all column names","Q_Score":2,"Tags":"python,pandas","A_Id":59429840,"CreationDate":"2019-12-20T18:14:00.000","Title":"Is there a way to select only column labels using Pyhon Pandas library without any rows?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to open my python files with a double click. I normally open them in anaconda prompt which uses the powershell file found in C:\\Windows\\System32\\WindowsPowerShell\\v1.0. I tried using open with and navigating to this file, however then the promt window opens and immediately closes... the script should run continuously.\nI also tried opening it with the \"python (command line)\" file which I found in C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Python 2.7 I cannot open the location of that file for some reason using right click> open file location, however I tried to open my script using this but again the same thing happens.\nIt is frustrating as I need to close and open my scripts often. Each time I have to load up anaconda prompt, type in python and drag the file, and than press enter.\nAny help would be appreciated.\nI have installed Python 3.7 btw that I installed with ana and am trying to avoid reinstalling python as I have so many npm installs done that I did not keep a log of.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":240,"Q_Id":59429783,"Users Score":0,"Answer":"Try to open file\/folder in other IDE like vscode, pyCharm or text editor.\nOpen IDE first after that click on file menu and select open option.Browse the file\/folder and select it.","Q_Score":0,"Tags":"python,anaconda","A_Id":59429837,"CreationDate":"2019-12-20T18:22:00.000","Title":"Cannot open python files with double click","Data 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 unit prices in Purchases with 4 decimal places like 12.1234 LE, but in point of sale I use 2 decimal places like 12.12 LE.\nI tried to change \"Unit price\" and \"Account\" decimal accuracy to 4 in (Settings\\Database Structure\\Decimal Accuracy) expected behavior is 12.1234*1000=12123.4 but the line real subtotal was 12120.00 this is because Currency rounding factor is 2 decimal places (Invoicing\\Accounting\\Currencies\\LE).\nWhen I tried to change currency price rounding factor to 4 this causes issues in Point of sales orders payment, as I found a lot of draft payments \"Status: NEW\" this is because the user in Point of sales enter prices with 2 decimal point which is necessary for ease of usage and for the client view.\nI am trying to make a  different Price rounding factor for POS than accounting, is this is the right way? and is there any other ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":359,"Q_Id":59430213,"Users Score":0,"Answer":"Ok, I see no one made a comment!! May be my question is not clear enough.\nAny way I put this answer for any one who faces same problem, I made a work around, simply I created another currency with Rate=1 with price accuracy= 0.0001 I mean 4 decimal places, then I changed all partner to use this currency by changing (Supplier currency=\"this new currency\").\nThen when I make a PO and choose the vendor => currency changes to this currency and decimal places becomes 4 with no issues on POS as it uses the default currency which is 2 decimal places.\nBy the way this currency does not appear at all in the reports because out of the PO all the payment is automatically with the default currency.","Q_Score":0,"Tags":"python,odoo-11","A_Id":59451094,"CreationDate":"2019-12-20T19:05:00.000","Title":"Odoo 11: How to use different Price accuracy for POS and Purchasing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was doing numerical method in R and Python\nI have applied leapfrog method in python and it worked perfectly but I want to do the slimier thing in R. Here you can see my code \nPossibly I have tried doing u[2,2]=beta*(u[1,1]-2*u[2,1]+u[3,1]) this works, here I can see that the error is due to the bold statement means due to u[2,0] does not exist. But the same code worked in python, Please help to resolve the error while executing the loop\nu[i, j - 1] evaluates to u[2, 0], or numeric(0). This is what produces the error.\nIs there any solution.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":59430331,"Users Score":0,"Answer":"Keep in mind that R indexes are 1-based, while in Python they are 0-based. In your code, the first time through the for loop, u[i, j - 1] evaluates to u[2, 0], or numeric(0). This is what produces the error.","Q_Score":1,"Tags":"python,r,numerical-methods","A_Id":59431088,"CreationDate":"2019-12-20T19:18:00.000","Title":"replacement has length zero in R from a python code","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Note: I did research on this over web but all of them are pointing to the solution which works on prem\/desktops. This case is on databricks notebook, I referred databricks help guide but could not find the solution.\nDear all, \nIn my local desktop i used to import the objects from other python files by referring their absolute path such as \n\"from dir.dira.dir0.file1 import *\"\nBut in Databricks python notebook i'm finding it difficult to crack this step since 2 hours. Any help is appreciated.\nBelow is how my command shows,\nfrom dbfs.Shared.ABC.models.NJ_WrkDir.test_schdl import *\nalso tried below ways, none of them worked\nfrom dbfs\/Shared\/ABC\/models\/NJ_WrkDir\/test_schdl import *\nfrom \\Shared\\ABC\\models\\NJ_WrkDir\\test_schdl import *\nfrom Shared\/ABC\/models\/NJ_WrkDir\/test_schdl import *\nfrom Shared.ABC.models.NJ_WrkDir.test_schdl import *\nThe error messages shows:\nModuleNotFoundError: No module named 'Shared\nModuleNotFoundError: No module named 'dbfs\nSyntaxError: unexpected character after line continuation character\n  File \"\", line 2\n    from \\Shared\\ABC\\models\\NJ_WrkDir\\test_schdl import *\n                                                         ^\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":149,"Q_Id":59432534,"Users Score":0,"Answer":"The solution is, include the command in child databricks python notebook as \n\"%run \/path\/parentfile\"\n(from where we want to import the objects from)","Q_Score":0,"Tags":"python,jupyter-notebook,databricks","A_Id":59459080,"CreationDate":"2019-12-21T00:05:00.000","Title":"In Databricks python notebook, how to import a file1 objects resides in different directory than the file2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to use pycurl in my first python project on Raspbian but i have some difficulties installing it. During the installation procces (by pip) everything seemed to go well, nothing errored out but when i try to implement it the ide errors out. I've tried a lot of suggested solutions in other treads but I'm geting nowhere.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":59432583,"Users Score":0,"Answer":"If the error is no module named pycurl, then the most likely reason for that is the package is its not well installed.\nThe common reason for that is that your virtual environment is not well activated, so you didn't install it globally and its withing your environment.\nIf you don't have a virtual environment then you installed your package globally. The most common reason for a no module error is that you installed it in another version of python that you are using in your code.\nDouble check where you are installing the packages and which version your project is using!","Q_Score":0,"Tags":"python,raspbian,pycurl","A_Id":59432790,"CreationDate":"2019-12-21T00:14:00.000","Title":"No module named pycurl error even with pycurl instaled","Data 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":"Suppose I have one process which spawns two threads on a Two-Cores Machine.\nBecause of the GIL, \nIs it possible that thread-1 is bound to Core1 while thread-2 bound to Core2, thus they are waiting to get their lock on different CPU.\nOr all the threads constantly bound to a particular CPU, (even though 100 threads spawn on a 100-cores machine).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":18,"Q_Id":59432878,"Users Score":1,"Answer":"Threads by default are not bound to any CPU -- when a thread is ready-to-run, the OS will dynamically dispatch it to run on an available core using an algorithm of the OS's choosing.\nBecause the GIL is Global, however, only one thread in a given Python process can ever be executing Python byte-codes at any given time.  Any other threads in that process will be blocked waiting to acquire the GIL, and thus will not be associated with any core at all.","Q_Score":0,"Tags":"python-3.x,multithreading,cpu","A_Id":59432932,"CreationDate":"2019-12-21T01:23:00.000","Title":"One process which spawns two threads on a Two-Cores Machine under GIL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using university SSH, and I am trying to use Neovim.\nHowever, it keeps saying that E319: No \"python3\" provider found. whenever I am trying to edit my code using Neovim.\nI am not a sudoer.\nHow can I handle this problem?\nI've tried python3 -m pip install --user --upgrade pynvim, however, it says that module pip is not installed in \/usr\/bin\/python3 directory.","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":3086,"Q_Id":59433677,"Users Score":2,"Answer":"There are a lot of ways to install python modules, and using sudo to pip install things is NOT recommended.\nHowever, sometimes there are packages that are maintained by the community.  I would try: apt install python3-neovim\nThis should put the neovim python module in the place that neovim is expecting, as opposed to using --user or using pipx\nGood luck!","Q_Score":3,"Tags":"python-3.x,pip,neovim","A_Id":64623026,"CreationDate":"2019-12-21T05:19:00.000","Title":"E319: No \"python3\" provider found. How can I solve this problem on SSH environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a PyTorch video feature tensor of shape [66,7,7,1024] and I need to convert it to [1024,66,7,7]. How to rearrange a tensor shape? Also, how to perform mean across dimension=1? i.e., after performing mean of the dimension with size 66, I need the tensor to be [1024,1,7,7].\nI have tried to calculate the mean of dimension=1 but I failed to replace it with the mean value. And I could not imagine a 4D tensor in which one dimension is replaced by its mean. \nEdit:\n I tried torch.mean(my_tensor, dim=1). But this returns me a tensor of shape [1024,7,7]. The 4D tensor is being converted to 3D. But I want it to remain 4D with shape [1024,1,7,7].\nThank you very much.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4489,"Q_Id":59435653,"Users Score":2,"Answer":"The first part of the question has been answered in the comments section. So we can use tensor.transpose([3,0,1,2]) to convert the tensor to the shape [1024,66,7,7].\nNow mean over the temporal dimension can be taken by \ntorch.mean(my_tensor, dim=1)\nThis will give a 3D tensor of shape [1024,7,7].\nTo obtain a tensor of shape [1024,1,7,7], I had to unsqueeze in dimension=1:\ntensor = tensor.unsqueeze(1)","Q_Score":1,"Tags":"python,numpy,computer-vision,pytorch,tensor","A_Id":59441386,"CreationDate":"2019-12-21T11:10:00.000","Title":"Calculate mean across one specific dimension of a 4D tensor in Pytorch","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to retry a function if the exception is NOT of a certain type using Python's tenacity?\nretry_if_exception_type will retry if there is risen an exception of a certain type. not does not seems to work placed before the method nor before its arguments.\nretry_unless_exception_type, on the other side, loops forever, even if there is not risen error, until there is risen error of a certain type.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2790,"Q_Id":59435875,"Users Score":0,"Answer":"using retry_unless_exception_type() combined with stop_after_attempt() worked for me to accomplish this.  the stop_after_attempt() prevents the infinite looping.","Q_Score":4,"Tags":"python,python-3.x,exception,error-handling,python-tenacity","A_Id":59974154,"CreationDate":"2019-12-21T11:42:00.000","Title":"Python tenacity: How to retry if exception is NOT of a certain type?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to manually calculate TPR and FPR for the given data. But unfortunately I dont have any false positive cases in my dataset and even no true positive cases. \nSo I am getting divided by zero error in pandas. So I have an intuition that fpr=1-tpr. Please let me know my intuition is correct if not let know how to fix this issue.\nThank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":650,"Q_Id":59438262,"Users Score":0,"Answer":"It is possible to have FPR = 1 with TPR = 1 if your prediction is always positive no matter what your inputs are.\nTPR = 1 means we predict correctly all the positives. FPR = 1 is equivalent to predicting always positively when the condition is negative.\nAs a reminder:\n\nFPR = 1 - TNR = [False Positives] \/ [Negatives]\nTPR = 1 - FNR = [True Positives] \/ [Positives]","Q_Score":0,"Tags":"python,pandas","A_Id":59439160,"CreationDate":"2019-12-21T17:16:00.000","Title":"False Positive Rate in Confusion Matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting the following error: \n\nUnable to import module '': No module\n  named 'regex._regex'\n\nThe AWS Lambda deployment package runs just fine without import htmldate statement (the module I want to use) which in turn requires regex.\nAlso the code runs fine locally.  \nSo this seems to be a problem running regex on AWS Lambda.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1951,"Q_Id":59438843,"Users Score":1,"Answer":"A new version of htmldate makes some of the dependencies optional, regex is such a case. That should solve the problem. (FYI: I'm the main developer of the package.)","Q_Score":3,"Tags":"regex,python-3.x,amazon-web-services,aws-lambda","A_Id":59722099,"CreationDate":"2019-12-21T18:34:00.000","Title":"How can I import regex on AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Import yfinance as yf\nShould run normally on conda but get this message\n\nModuleNotFoundError Traceback (most recent call\n  last)  in \n        1 import pandas as pd\n  ----> 2 import yfinance as yf\n        3 import matplotlib.pyplot as plt\nModuleNotFoundError: No module named 'yfinance'\n\nStrange? As should be simple to install?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6906,"Q_Id":59440380,"Users Score":0,"Answer":"The best way to install a python library is to:\n\nOpen a terminal or cmd or powershell on your system.\nIf using a virtual environment, activate the environment in your terminal or cmd or powershell.\n\nFor e.g., A virtual environment named virtual_environment created using virtualenv in C:\/\/Users\/Admin\/VirtualEnvironments\/ directory can be activated by opening a terminal or cmd or powershell in that directory and running python -m virtualenv virtual_environment\/Scripts\/activate. For ubuntu users, python -m virtualenv virtual_environment\/bin\/activate.\n\nTo install a library named python-library, Run pip install python-library.\nTo install a specific version of that library, like a library named python-library with version 2.0.1 can be installed by Running the command pip install python-library==2.0.1\n\nSimilarly, you simply have to run pip install yfinance\nIf you want to install a specific version, like 0.1.70, then run command pip install yfinance==0.1.70.\nIf you have a .whl file of that library like python-library.whl, and want to install that wheel, then run command pip install python-library.whl.","Q_Score":0,"Tags":"python,conda,yahoo,yfinance","A_Id":70914645,"CreationDate":"2019-12-21T22:42:00.000","Title":"Import yfinance as yf","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Import yfinance as yf\nShould run normally on conda but get this message\n\nModuleNotFoundError Traceback (most recent call\n  last)  in \n        1 import pandas as pd\n  ----> 2 import yfinance as yf\n        3 import matplotlib.pyplot as plt\nModuleNotFoundError: No module named 'yfinance'\n\nStrange? As should be simple to install?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6906,"Q_Id":59440380,"Users Score":0,"Answer":"If you using anaconda, try downloan yfinance using Powershell Prompt.","Q_Score":0,"Tags":"python,conda,yahoo,yfinance","A_Id":68372729,"CreationDate":"2019-12-21T22:42:00.000","Title":"Import yfinance as yf","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using Python in Jupiter notebook in Anaconda and trying to access files on an external hard drive. I can access the hard drive using:\nos.chdir('\/Volumes')\nbut when I try to list the directories, I get the following error:\nOSError: [Errno 6] Device not configured\nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1410,"Q_Id":59440980,"Users Score":0,"Answer":"I got the same error, for me, the reason of the error, was a server connection lost. After the disconnection, the name of the path changed and the copy of the file failed.","Q_Score":1,"Tags":"python,macos,jupyter","A_Id":64680563,"CreationDate":"2019-12-22T01:06:00.000","Title":"OSError: [Errno 6] Device not configured","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am writing a script that automates the use of other scripts. I've set it up to automatically import other modules from .py files stored in a directory called dependencies using importlib.import_modules()\nOriginally, I had dependencies as a subdirectory of the root of my application, and this worked fine. However, it's my goal to have the dependencies folder stored potentially anywhere a user would like. In my personal example, it's located in my dropbox folder while my script is run from a different directory entirely.\nI cannot for the life of me seem to get the modules to be detected and imported anymore and I'm out of ideas.\nWould someone have a better idea of how to achieve this?\nThis is an example of the path structure:\n\nE:\n|_ Scripts:\n| |_ Mokha.py\n|\n|_ Dropbox:\n| |_ Dependencies:\n|   |_ utils.py\n\nHere's my code for importing: (I'm reading in a JSON file for the dependency names and looping over every item in the list)\n\ndef importPythonModules(pythonDependencies):\n    chdir(baseConfig[\"dependencies-path])\n    for dependency in pythonDependencies:\n        try:\n            moduleImport = dependency\n            module = importlib.import_module(moduleImport)\n            modules[dependency] = module\n            print(\"Loaded module: %s\" % (dependency))\n        except ModuleNotFoundError as e:\n            print(e)\n            raise Exception(\"Error importing python dependecies.\")\n    chdir(application_path)\n\nThe error I get is No module named 'utils'\nI've tried putting an init.py in both the dependencies folder, the root of my dropbox, and both at the same time to no avail.\nThis has got to be possible, right?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":59441152,"Users Score":0,"Answer":"UPDATE: I solved it.\nsys.path.append(baseConfig['dependencies-path'])\nNot super happy with the solution but it'll work for now.","Q_Score":2,"Tags":"python,python-import,python-importlib","A_Id":59441255,"CreationDate":"2019-12-22T01:56:00.000","Title":"Import python modules in a completely different directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't understand this message \/opt\/conda\/envs\/Python36\/lib\/python3.6\/site-packages\/sklearn\/preprocessing\/data.py:645: DataConversionWarning: Data with input dtype uint8, int64 were all converted to float64 by StandardScaler.\n  return self.partial_fit(X, y)\n\/opt\/conda\/envs\/Python36\/lib\/python3.6\/site-packages\/ipykernel\/__main__.py:2: DataConversionWarning: Data with input dtype uint8, int64 were all converted to float64 by StandardScaler.\n  from ipykernel import kernelapp as app \nMy code is :\nX = Feature_test\ntestX= preprocessing.StandardScaler().fit(X).transform(X)\nWhat does it mean??\nAnd how can I fix it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1496,"Q_Id":59441173,"Users Score":0,"Answer":"It means that you have columns in your dataset of type integer. It's a warning, so you are good to go if you need to scale your features for a regression or a neural network.","Q_Score":1,"Tags":"python-3.x","A_Id":59991016,"CreationDate":"2019-12-22T02:02:00.000","Title":"python: DataConversionWarning: Data with input dtype uint8, int64 were all converted to float64 by StandardScaler","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there an equivalent to expect's interpreter command for pexpect.\nIn expect interpreter gives the user access to a tcl repl with the current variable scopes.  I would like to give my user access to a python repl (preferably ipython) with the current variable scopes, it would be great for debugging.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":59441860,"Users Score":0,"Answer":"The best way I have found to do this so far is a clunky hack: \n\nbreakpoint() will put the user into a pdb debugging session\nuser enters p varname for user to check if the current variables are in scope (I typically find that they aren't, because I'm somewhere in the ipython internals).  If not in scope then press r and repeat.\nuser enters interact, opening the interactive session\n\nSteps 2 and 3 require the user to know quite a bit about the program, certainly not as elegant as interpreter.  I would like to see better ways of doing this.","Q_Score":0,"Tags":"python,expect,pexpect","A_Id":59441891,"CreationDate":"2019-12-22T05:34:00.000","Title":"expect interpreter equivalent for pexpect","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say I\u2019m working on a complex Python program for keeping track of shipment data along with Git for version control. On my local machine, is it best to create two different folder structures, one being the develop folder and the other being the production folder? \nSo, I push my final (develop) changes to the master branch, then pull those changes to production folder?","AnswerCount":1,"Available Count":1,"Score":-0.3799489623,"is_accepted":false,"ViewCount":75,"Q_Id":59441958,"Users Score":-2,"Answer":"I like that idea of keeping separate folders in order to prevent mistakes, but I think it totally depends on the standards\/conventions of your group\/environment. If you communicate this approach to them and they approve of it, then I would recommend it. But the way version control works is that it allows you to access remote versions from anywhere and by using the same folder location, you're optimizing space on your machine.","Q_Score":2,"Tags":"python,git","A_Id":59442167,"CreationDate":"2019-12-22T05:58:00.000","Title":"Separate folders for development and production?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a class Node having two data members: data and next.\nI have created another class LinkedList to having a data member: head\nNow I want to store an image in the node but I have no idea how to do it. The syntax for performing this operation would be very much helpful.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":59442002,"Users Score":0,"Answer":"PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities.\nUSE from PIL import Image after installing. \nWindows: Download the appropriate Pillow package according to your python version. Make sure to download according to the python version you have.\npip install Pillow for Linux users.\nThen u can easily add image to your linked list by assigning it to a variable","Q_Score":0,"Tags":"python,linked-list","A_Id":59442026,"CreationDate":"2019-12-22T06:06:00.000","Title":"How to put images in a linked list in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a bot with BotFather and got the access token. What I want is to add my bot to a number of groups(I will provide the invite link to it) and it should be able to join the group through an API. So, let's say I have a list of 100 public groups with their invite link, then my bot should be able to join them, this process should be automated. \nI tried searching the telegram API docs, but I wasn't able to find there. Also, the questions on StackOverflow mostly helpful when I want to add the bot to my own group, which I don't want. \nI just want a direction, maybe a function from telethon or any other client. I will then be able to do it by myself.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":59442068,"Users Score":0,"Answer":"You can't add bot to the group without corresponding admin permission, also what you're trying to do looks like a spam and leads to account restriction(or full deletion).","Q_Score":0,"Tags":"python,python-3.x,telegram,telegram-bot,telethon","A_Id":59442105,"CreationDate":"2019-12-22T06:18:00.000","Title":"How to add a telegram bot to different groups 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 have made a bot with BotFather and got the access token. What I want is to add my bot to a number of groups(I will provide the invite link to it) and it should be able to join the group through an API. So, let's say I have a list of 100 public groups with their invite link, then my bot should be able to join them, this process should be automated. \nI tried searching the telegram API docs, but I wasn't able to find there. Also, the questions on StackOverflow mostly helpful when I want to add the bot to my own group, which I don't want. \nI just want a direction, maybe a function from telethon or any other client. I will then be able to do it by myself.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":59442068,"Users Score":0,"Answer":"Only an admin of a group or channel can add the bot. The bot itself cannot add it anywhere. Even a user have to initiate the interaction with bot first.","Q_Score":0,"Tags":"python,python-3.x,telegram,telegram-bot,telethon","A_Id":59468608,"CreationDate":"2019-12-22T06:18:00.000","Title":"How to add a telegram bot to different groups 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":"Although all 3 are used for programming in python but what is difference between them?especially in their application?when we use ide and when we use idle and when we use  interpreter?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":888,"Q_Id":59444643,"Users Score":0,"Answer":"In interpreter is a program that runs programs written in a particular language.  The CPython interpreter in one interpreter for running Python programs.  An Itegrated Development Environment (IDE) is a program writing and running programs, possible with an interpreter, in one or more languages.  IDLE is an IDE specifically for Python that comes at least with CPython. (I don't know if it works with any other Python interpreters or compilation systems.)\nA web search should allow one to discover such basic definitions.","Q_Score":0,"Tags":"python,ide,python-idle","A_Id":59450907,"CreationDate":"2019-12-22T13:34:00.000","Title":"How we can differentiate between interpreter and ide and idle?in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently developing a piece of software on a Raspberry Pi. Because I have to control motors very precisely i developed a C script, that does that for me. My current problem is, that I didn't found any solid method to transfer a list of signed floats from a Python3 Script to a C script. It is really important, that the method is fast.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":59447345,"Users Score":0,"Answer":"You could use a socket to send data from one script to the another.","Q_Score":0,"Tags":"python,c,list,char,ipc","A_Id":59447373,"CreationDate":"2019-12-22T19:16:00.000","Title":"Python and C IPC","Data Science and Machine Learning":0,"Database and SQL":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 know if i retrain my saved model which i ran with 4 epochs, be faster with same image set at 10 epochs?\nMy data set consists of 2 folders of training and validation with 5 classes and 3000 training and 1000 validation images","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":150,"Q_Id":59447567,"Users Score":0,"Answer":"If you are using keras, basically calling fit will start from pre-existing weights and therefore the first epoch will consist of the 5th epochs. Therefore, the error will already be lower. However, beware that the processing time for each epoch will be equivalent. You will only start from a model which do not have random weights.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,keras,deep-learning","A_Id":59447620,"CreationDate":"2019-12-22T19:49:00.000","Title":"Re train a saved model with same Dataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had Python 3.7.4 in D:\\python3.7.4 before but for some reason, I uninstalled it today, then I changed the folder name to D:\\python3.7.5 and installed python 3.7.5 in it, then, when I try to use pip in cmd I got a fatal error saying \n\nUnable to create processing using '\"Unable to create process using '\"d:\\python3.7.4\\python.exe\"  \"D:\\Python3.7.5\\Scripts\\pip.exe\"' \n\nI tried to change all things contain python3.7.4 in environment variable to python3.7.5 but the same error still exists, does anyone know how to fix this? \nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":204,"Q_Id":59448857,"Users Score":0,"Answer":"Try to create a new folder and run the installation there.\nThis should work, as I did the same myself to go install 2 different versions before","Q_Score":0,"Tags":"python,pip,windows-10","A_Id":59448973,"CreationDate":"2019-12-22T23:43:00.000","Title":"What cause pip did not work after reinstall python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have an Airflow DAG which as one upstream task and around 40 downstream tasks from that one upstream (like 1 to 40 mapping). The upstream one finished successfully and for some reason I had to stop the downstream tasks. Now I want to execute all of them. Is there a way to do it by just executing one command (instead of clearing each individual downstream)?\nDoesn't matter if it is from the web UI or from the terminal.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":598,"Q_Id":59450849,"Users Score":0,"Answer":"If you want to re-execute all of the downstream tasks at the same time, click the 1 upstream task in the DAG UI and bring up it's Task UI. Press \"Downstream\", \"Clear\", and confirm you want to clear all tasks selected. Once that has been executed, mark the 1 upstream task as successful. All downstream tasks will then forget their previous state and re-execute.","Q_Score":0,"Tags":"python,airflow","A_Id":59459121,"CreationDate":"2019-12-23T06:12:00.000","Title":"run only downstream tasks not the current task - airflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have the logic for email verification, but I am not sure how to make it such that only after clicking the link on the verification email, the user is taken to the second page of the form, and only after filling the second part the user is saved.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":106,"Q_Id":59452271,"Users Score":1,"Answer":"I would say that much better idea is to save user to database anyway, but mark him as inactive (simple boolean field in model will be enough). Upon registration, before confirming email mark him as inactive and as soon as he confirms email and fills second part of your registration form that you mentioned change that boolean value to true. If you don't want to keep inactive users data in your database, you can set up for example cron, that will clean users that haven't confirmed their email for few days.","Q_Score":1,"Tags":"python,django,django-models,django-forms,django-authentication","A_Id":59452384,"CreationDate":"2019-12-23T08:37:00.000","Title":"How to create a registration form in Django that is divided into two parts, such that one call fill up the second part only after email verification?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was trying to study sphinx python documentation, i was struggling to make an html inside of my directory. I already try it to my cmd prompt but the error shows. \n$ make html\nP.s I already install Python and NodeJs and Git (incase)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1806,"Q_Id":59452797,"Users Score":0,"Answer":"I get my own answer on my own question.\nYou should locate your own directory and make sure you sphinx-build in your folder","Q_Score":0,"Tags":"python-sphinx","A_Id":59483114,"CreationDate":"2019-12-23T09:22:00.000","Title":"'make' is not recognized as an internal or external command, operable program or batch file. [Sphinx]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm getting this error when i use the tensorboard callback while training. \nI tried looking for answers from posts related to tensorboard errors but this exact error was not found in any stackoverflow posts or github issues.\nPlease let know.\nThe following versions are installed in my pc:\nTensorflow and Tensorflow GPU : 2.0.0\nTensorboard: 2.0.0","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5342,"Q_Id":59452858,"Users Score":0,"Answer":"This error mostly happens because of mixed imports from keras and tf.keras. Make sure that throughout the code exact referencing of libraries is maintained. For example instead of model.add(Conv2d()) try model.add(tf.keras.layers.Conv2D()) , applying this for all layers solved the problem for me.","Q_Score":8,"Tags":"python-3.x,tensorflow,deep-learning,tensorboard,tensorflow2.0","A_Id":61602101,"CreationDate":"2019-12-23T09:26:00.000","Title":"Tensorboard: AttributeError: 'Model' object has no attribute '_get_distribution_strategy'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"A Django-based service that I'm working on allows users to upload media files via REST API or Django admin but does not provide or use any static files (like css styles, js libraries, etc.).\nMedia files are stored in specific fields in database and use S3 bucket as storage backend so server itself does not directly serve any files at all.\nHaving such a case is running collectstatic command required every time application is being deployed?\nThought the concept of static and media files in Django application is rather simple I'm still confused about whether configurations for them should be somehow related?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":59452874,"Users Score":0,"Answer":"Your Django-based service does not need collectstatic at all.\nQuestion is about django admin - because admin app uses static content css\/img\/js.\nDo you use django admin in production? \n\nIf yes - then you need to run collectstatic command it, otherwise admin site will be unstyled or totally broken because of missing js files.\nIf no - then you collectstatic command has no use for you.","Q_Score":0,"Tags":"python,django","A_Id":59453418,"CreationDate":"2019-12-23T09:28:00.000","Title":"Is collectstatic command necessary if application only serves media files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"A Django-based service that I'm working on allows users to upload media files via REST API or Django admin but does not provide or use any static files (like css styles, js libraries, etc.).\nMedia files are stored in specific fields in database and use S3 bucket as storage backend so server itself does not directly serve any files at all.\nHaving such a case is running collectstatic command required every time application is being deployed?\nThought the concept of static and media files in Django application is rather simple I'm still confused about whether configurations for them should be somehow related?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":59452874,"Users Score":1,"Answer":"As Django won't serve the staticfiles when the DEBUG is False (through deployment), if you want the css, js and other static files (at least in the admin, in your case), you need to run collectstatic.\nSo if you want django admin to be like your development environment (with css and images), you need it.","Q_Score":0,"Tags":"python,django","A_Id":59452932,"CreationDate":"2019-12-23T09:28:00.000","Title":"Is collectstatic command necessary if application only serves media files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"it confused me long time.\nmy program has two process, both read data from disk, disk max read speed 10M\/s\n1. if two process both read 10M data, is two process spend time same with one process read twice?\n2. if two process both read 5M data, two process read data spend 1s, one process read twice spend 1s, i know multi process can save time from IO, but the spend same time in IO, multi process how to save time?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":473,"Q_Id":59453366,"Users Score":0,"Answer":"It's not possible to increase disk read speed by adding more threads. With 2 threads reading you will get at best 1\/2 the speed per thread (in practice even less), with 3 threads - 1\/3 the speed, etc.\nWith disk I\/O it is the difference between sequential and random access speed that is really important. For example, sequential read speed can be 10 MB\/s, and random read just 10 KB\/s. This is the case even with the latest SSD drives (although the ratio may be less pronounced).\nFor that reason you should prefer to read from disk sequentially from only one thread at a time. Reading the file in 2 threads in parallel will not only reduce the speed of each read by half, but will further reduce because of non-sequential (interleaved) disk access.\n\nNote however, that 10 MB is really not much; modern OSes will prefetch the entire file into the cache, and any subsequent reads will appear instantaneous.","Q_Score":0,"Tags":"python,c,multithreading,multiprocessing,disk","A_Id":59454325,"CreationDate":"2019-12-23T10:03:00.000","Title":"python multiprocess read data from disk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I get the left, top, width and heigth as an int value instead of the standard 'Box(left, top, width, height)'. I need these values to make if statements like: \"if left < 250\".\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":198,"Q_Id":59454458,"Users Score":0,"Answer":"Update:\nYou can just use x[0] for the left, x[1] for the top etc.\nNOTE: this doesn't work when x=\"None\". use 'try' to prevent the code from crashing when trying to call x[something].","Q_Score":0,"Tags":"python,automation,bots,pyautogui","A_Id":59459131,"CreationDate":"2019-12-23T11:21:00.000","Title":"Python: How to get the left or top in pyautogui.locateOnScreen as int?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can a tfrecords file(s) written using one version of TF be read by code written using a different version of TF? In particular can tfrecords files written using TF 2 be read by code written using TF1? Or is the serialization format TF version specific?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":258,"Q_Id":59455927,"Users Score":1,"Answer":"The tfrecords files use the protobuf format, which is used by both TF1 and TF2.\nSo yes, you can read tfrecord files from both versions of tensorflow.","Q_Score":0,"Tags":"python,tensorflow,tensorflow2.0,tfrecord","A_Id":64102937,"CreationDate":"2019-12-23T13:09:00.000","Title":"Can code from TF 1.x read a tfrecords file written using TF 2.x?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python so bear with me.\nI have recently download the pdblp module in a zip form. \nI then made some amendments that were needed to get through specific requests. So I have this folder, is there a way where I normally write Import pdblp that I can write import 'F:\\Sam\\project\\' as pdblp or should it not be done like this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":56,"Q_Id":59456241,"Users Score":1,"Answer":"You can import folder as package not module. *.py file is itself module. If you want to import folder, you need add init.py file inside the folder and then it will become package then you can import","Q_Score":0,"Tags":"python,module,pdblp","A_Id":59456304,"CreationDate":"2019-12-23T13:32:00.000","Title":"Python: How to Import a folder as a module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been testing some optimisations to a piece of code (specifically, whether elif n in [2,3] is faster than elif n == 2 or n == 3) and noticed something strange. \nUsing timeit.default_timer I did several runs of each version of the function, and the first run was always significantly slower than subsequent ones (values starting off around 0.01 of a second that trailed off to consistently around 0.003). \nIs python doing something behind the scenes to optimise the code on later runs? This isn't really a problem by any means, but I'd be interested to know what is happening (if anything)","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":467,"Q_Id":59457810,"Users Score":-1,"Answer":"Yes, python caches the pyc file after the first run, so if the code doesn't change it will run faster in next iterations because it won't need to compile it to byte code again. Remember python is an interpreted language, it's just skipping an interpretation step.","Q_Score":3,"Tags":"python,timeit","A_Id":59457857,"CreationDate":"2019-12-23T15:34:00.000","Title":"Why is the first run of timeit usually slower than subsequent ones?","Data 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 made a telegram bot, that sends a request to a certain API and returns the answer to the bot.\nwhen I run the app locally, it takes like 2-3 seconds to execute a request and send the answer to the user, but when its webhook to pythonanywhere, it takes 5-10 minutes to execute a request.\nis it really that slow? or something is wrong?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":80,"Q_Id":59458765,"Users Score":1,"Answer":"That really seems like something's wrong. Instrument your code with some timing information so you can see where it's spending it's time. Then you can start to try to work out why there's such a big difference.","Q_Score":0,"Tags":"python-3.x,telegram-bot,pythonanywhere,python-telegram-bot","A_Id":59481625,"CreationDate":"2019-12-23T16:51:00.000","Title":"pythonanywhere - SUPER SLOW?","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 find all builds which started some user by his username. Is it possible to do with the help of Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":59460430,"Users Score":1,"Answer":"Yes. you could use Python, if you have access to the jenkins master.\nThe userId is in build.xml which is usually in your jenkins jobs\/you_job_name\/builds\/your_build_number\/build.xml\nYou could iterate over all the jobs and their builds and get the answer from there.","Q_Score":1,"Tags":"python,jenkins","A_Id":59465979,"CreationDate":"2019-12-23T19:32:00.000","Title":"Get information about the Jenkins builds related to specified username","Data Science and Machine Learning":0,"Database and SQL":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 making a python 3 application (flask based) and for that I created a virtualenv in my development system, installed all packages via pip and my app worked fine.\nBut when I moved that virtualenv to a different system (python3 installed) and ran my application with the absolute path of my virtualenv python (c:\/.......\/myenv\/Scripts\/python.exe main.py) then it threw the errors that packages are not installed,\nI activated the virtualenv and used pip freeze and there were no packages were installed.\nBut under virtualenv there is 'Site-Packages' (myenv -> lib -> site-packages) , all my installed packages were persent there.\nMy Question is how to use the packages that are inside 'site-packages' even after moving the virtualenv to different system in Python 3.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5174,"Q_Id":59460798,"Users Score":0,"Answer":"You Must not copy & paste venv, even in the same system. \nIf you install new package in venv-copied, then it would installed in venv-original.  Becaus settings are bound to specific directory.","Q_Score":1,"Tags":"python,python-3.x,operating-system,virtualenv,site-packages","A_Id":69007534,"CreationDate":"2019-12-23T20:07:00.000","Title":"How to move Python virtualenv to different system (computer) and use packages present in Site-packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a python 3 application (flask based) and for that I created a virtualenv in my development system, installed all packages via pip and my app worked fine.\nBut when I moved that virtualenv to a different system (python3 installed) and ran my application with the absolute path of my virtualenv python (c:\/.......\/myenv\/Scripts\/python.exe main.py) then it threw the errors that packages are not installed,\nI activated the virtualenv and used pip freeze and there were no packages were installed.\nBut under virtualenv there is 'Site-Packages' (myenv -> lib -> site-packages) , all my installed packages were persent there.\nMy Question is how to use the packages that are inside 'site-packages' even after moving the virtualenv to different system in Python 3.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5174,"Q_Id":59460798,"Users Score":0,"Answer":"Maybe you can consider using pipenv to control the virtualenvs on different computer or environment.","Q_Score":1,"Tags":"python,python-3.x,operating-system,virtualenv,site-packages","A_Id":59469545,"CreationDate":"2019-12-23T20:07:00.000","Title":"How to move Python virtualenv to different system (computer) and use packages present in Site-packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Consider the following scenario:\nUser 1:\n\nFrom Address = \"sender@domain.com\"\nTo Address = \"Receiver_1@domain.com\"\nAttachment = \"common path --> file_1\"\n\nUser 2:\n\nFrom Address = \"sender@domain.com\"\nTo Address = \"Receiver_2@domain.com\"\nAttachment = \"common path --> file_2\"\n\nHow do i execute the above task if it is to be carried out for 500 unique users, with 500 unique attachments (1 unique attachment per unique user)?\nThanks in advance!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":59461888,"Users Score":0,"Answer":"You will need to loop over 500 recipients and send a separate message to each address.","Q_Score":0,"Tags":"python,python-3.x,outlook,win32com","A_Id":59461921,"CreationDate":"2019-12-23T22:26:00.000","Title":"Personalized Attachments to Each Recipient From Outlook using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a python program which is an interpreter, for a language that I have made. It is called cbc.py, and it is in a certain directory. Now, I want to know how I can call it, along with sys.argv arguments (like python3 cbc.py _FILENAME_TO_RUN_) in any directory. I have done research on the .bashrc file and on the PATH variable, but I can't find anything that really helps me with my problem. Could someone please show me how to resolve my problem?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":285,"Q_Id":59462584,"Users Score":0,"Answer":"You need to make your script executable first and then add it to your PATH.\nIf you have your python script at ~\/path\/to\/your\/script\/YOUR_SCRIPT_NAME:\n\nadd #!\/usr\/bin\/python3 at the top of you script,\ngive executable permision to your script using sudo chmod a+x YOUR_SCRIPT_NAME,\nedit ~\/.bashrc to add your script path, e.g. echo PATH=\"$HOME\/path\/to\/your\/script:$PATH\" >> ~\/.bashrc,\nrestart or re-login or run source ~\/.bashrc,\nnow you can access your script via YOUR_SCRIPT_NAME anywhere.","Q_Score":1,"Tags":"python,linux,bash,path","A_Id":59462690,"CreationDate":"2019-12-24T00:29:00.000","Title":"How do I allow a file to be accessible from all directories?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I got array list looks like  \n\n[array(99.75142857), array(99.79928571), array(99.82238095),\n  array(99.83857143), array(99.85), array(99.85738095),\n  array(99.86285714), array(99.86767857)]\n\nI'm not sure what is this array but I just want to ge a numbers \n[99.75142857,99.79928571....]\nthis array() means numpy array","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":59466258,"Users Score":0,"Answer":"A numpy array of rank 0 is a scalar (it's got shape ())  and will behave like a scalar everyone. You can treat it like that.\nYou're perhaps mixing it up with an array of rank 1, e.g., np.array([99.79928571]).\nYou can also wrap your list into np.array to get an array of float64. Perhaps that looks nicer to your eye.","Q_Score":1,"Tags":"python,numpy","A_Id":59467879,"CreationDate":"2019-12-24T08:58:00.000","Title":"numpy array to the just number in the array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had recently updated my Django version from 1.11 to 3.0. when I want to create a project using python-admin startproject mysite I am getting error as \n\nImportError: No module named django.core\n\nI tried importing the Django in python3 console it is working.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":350,"Q_Id":59466475,"Users Score":0,"Answer":"Try using django-admin instead of python-admin. I made a new virtual environment, downloaded django via pip and django-admin startproject myapp worked. Don't forget to activate the virtual environment","Q_Score":0,"Tags":"python,django","A_Id":59469108,"CreationDate":"2019-12-24T09:18:00.000","Title":"ImportError: No module named django.core even I getting when I am importing django in python console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying connect to internal Jira instance use my AWS lambda function. The lambda cannot connect to this web-resource because VPN is required. (all work properly on my local machine under VPN connection).\nPlease any suggestion regarding this issue ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":166,"Q_Id":59468906,"Users Score":0,"Answer":"Since there is an AWS Direct Connect connection between an Amazon VPC and your corporate network, the AWS Lambda function can be configured to connect to the VPC.\nThe Lambda function can then connect to the JIRA instance on the corporate network by using the private IP address of the JIRA instance.\nYou might be able to configure the VPC to defer to your corporate DNS server to resolve the DNS Name into the IP address, but I would recommend you start by using the private IP address itself to ensure that connectivity is working.","Q_Score":0,"Tags":"python,aws-lambda,python-jira","A_Id":59478372,"CreationDate":"2019-12-24T12:31:00.000","Title":"How connect to internal Jira instance via 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'm trying connect to internal Jira instance use my AWS lambda function. The lambda cannot connect to this web-resource because VPN is required. (all work properly on my local machine under VPN connection).\nPlease any suggestion regarding this issue ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":166,"Q_Id":59468906,"Users Score":0,"Answer":"It would be best to use SQS messaging.\n\nDefine a message format\nFrom your lambda function, publish a message when you want to query something\nHave an app\/worker running inside your network, which is listening to your SQS queue.\nYour app\/worker receives that message and can query to your Jira instance.\nWhen the result is ready, your app\/worker can publish it on other SQS queue\nYou can receive the message in another lambda function, or If you want to receive the response in a same lambda function, you can poll for messages and wait till you get your desired message.\nIf you have multiple such lambda functions, or many requests going on. You can put a request-id in messages. So, when receiving a message, you can come to know which is your desired message and delete that one only.","Q_Score":0,"Tags":"python,aws-lambda,python-jira","A_Id":61316127,"CreationDate":"2019-12-24T12:31:00.000","Title":"How connect to internal Jira instance via 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 really don't know what is the best practice fetching users with keycloak in an frotend application. I'm currently building an Vue.js frontend application which works with the keycloak.js lib. I also have a backend written in Python. \nDo I need to fetch users first by my backend and afterwards fetch them on the frontend? Or otherwise fetch them directly on the frontend. \nWhat should you do?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":254,"Q_Id":59469062,"Users Score":0,"Answer":"Best practice in my opinion is:\nCreate a CMS, Database or API-endpoint where to query the data from in your front-end.\nThis will only query data when needed.","Q_Score":0,"Tags":"python,vue.js,openid-connect,keycloak","A_Id":59469098,"CreationDate":"2019-12-24T12:47:00.000","Title":"Best practice fetching users keycloak","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I really don't know what is the best practice fetching users with keycloak in an frotend application. I'm currently building an Vue.js frontend application which works with the keycloak.js lib. I also have a backend written in Python. \nDo I need to fetch users first by my backend and afterwards fetch them on the frontend? Or otherwise fetch them directly on the frontend. \nWhat should you do?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":254,"Q_Id":59469062,"Users Score":3,"Answer":"There is no best practice in such a task. It depends on what kind of business logic you need. If you just need to list Keycloak users in a table go with frontend as it is faster to implement. If you need to hide some sensitive user data or do not want to give frontend users access to Keycloak API go with backend.\nAlso be aware that through the API you can do anything the same as through the admin console. Users of your frontend application can get access that they should not have.\nAs an example, in Keycloak admin console, all requests from the frontend are sent directly to the API.","Q_Score":0,"Tags":"python,vue.js,openid-connect,keycloak","A_Id":59469750,"CreationDate":"2019-12-24T12:47:00.000","Title":"Best practice fetching users keycloak","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Blueprism gives the possibility to spy elements (like buttons and textboxes) in both web-browsers and windows applications. How can I spy (windows-based only) applications using Python, R, Java, C++, C# or other, anything but not Blueprism, preferrably opensource.\n\nFor web-browsers, I know how to do this, without being an expert. Using Python or R, for example, I can use Selenium or RSelenium, to spy elements of a website using different ways such as CSS selector, xpath, ID, Class Name, Tag, Text etc.\nBut for Applications, I have no clue. BluePrism has mainly two different App spying modes which are WIN32 and Active Accessibility. How can I do this type of spying and interacting with an application outside of Blueprism, preferrably using an opensource language?\n\n(only interested in windows-based apps for now)\nThe aim is of course to create robots able to navigate the apps as a human would do.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":497,"Q_Id":59470191,"Users Score":0,"Answer":"There is a free version of Blue Prism now :) Also Blue Prism uses win32, active accessibility and UI Automation which is a newer for of the older active accessibility.\nTo do this yourself without looking into Blue Prism you would need to know how to use UIA with C#\/VB.new or C++. There are libraries however given that Blue Prism now has a free version I would recommend using that.  Anything specific can be developed withing a code stage within Blue Prism.","Q_Score":1,"Tags":"c#,python,windows,blueprism,rpa","A_Id":59556005,"CreationDate":"2019-12-24T14:27:00.000","Title":"Blueprism-like spying and bot development","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 know that the recommendation is not to use linalg.inv and use linalg.solve when inverting matrices. This makes sense when I have situation like Ax = b and I want to get x, but is there a way to compute something like: A - B * D^{-1} * C without using linalg.inv? Or what is the most numerically stable way to deal with the inverse in the expression?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":416,"Q_Id":59473735,"Users Score":0,"Answer":"Please don't inv\u2014it's not as bad as most people think, but there's easier ways: you mentioned how np.linalg.solve(A, b) equals A^{-1} . b, but there's no requirement on what b is. You can use solve to solve your question, A - np.dot(B, np.linalg.solve(D, C)).\n(Note, if you're doing blockwise matrix inversion, C is likely B.transpose(), right?)","Q_Score":0,"Tags":"python,linear-algebra,matrix-inverse","A_Id":59480515,"CreationDate":"2019-12-24T22:06:00.000","Title":"Numerically stable way to compute conditional covariance matrix using linalg.solve","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As part of a class project, I'm trying to write a word2vec implementation in Python and train it on a corpus of ~6GB. I'm trying to code a reasonably optimized solution so I don't have to let my PC sit for days.\nGoing through the C word2vec source code, I notice that there, each thread reads words from a file, and takes the time to look up the index of every word. At the end, it stores a \"sentence\" of word indexes.\nWouldn't it be logical to translate the whole corpus into one containing integer indexes of the appropriate words? That way, time isn't lost during training on hash-table lookups, while the translation process is a one-time expense.\nI understand that for extremely large corpuses, you are effectively doubling the amount it takes on disk, which you might want to avoid.\nHowever, if you do have the memory, wouldn't this offer a noticeable increase in efficiency? Or am I just overestimating the impact of a table lookup?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":59473926,"Users Score":1,"Answer":"Hashtable lookups can be very fast, and repeated lookups may not contribute much to the overall runtime.\nBut the only way to really know the potential speedup of your proposed optimization is to implement it, and profile it in comparison to the prior behavior. \nAlso, as you note, to be able to re-use a single-pass token-lookup, you'd need to store those results somewhere. Google's word2vec.c code, like many other implementations, seeks to work well with input corpuses that are far larger than addressable memory. Writing the interim tokenization to disk would require extra code complication, and extra working space on disk, compared to the baseline of repeated lookups. So: even if it did speed things a little, implementors might consider the extra complexity undesirable.","Q_Score":0,"Tags":"python,machine-learning,nlp,word2vec","A_Id":59474328,"CreationDate":"2019-12-24T22:42:00.000","Title":"Processing a Corpus For a word2vec Implementation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I have a matrix M of size 10x5, and a set of indices ix of size 4x3. I want to do tf.reduce_sum(tf.gather(M,ix),axis=1) which would give me a result of size 4x5. However, to do this, it creates an intermediate gather matrix of size 4x3x5. While at these small sizes this isn't a problem, if these sizes grow large enough, I get an OOM error. However, since I'm simply doing a sum over the 1st dimension, I never need to calculate the full matrix. So my question is, is there a way to calculate the end 4x5 matrix without going through the intermediate 4x3x5 matrix?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":145,"Q_Id":59474657,"Users Score":0,"Answer":"I think you can just multiply by sparse matrix -- I was searching if the two are internally equivalent then I landed on your post","Q_Score":1,"Tags":"python,tensorflow,neural-network","A_Id":71549947,"CreationDate":"2019-12-25T02:06:00.000","Title":"tensorflow gather then reduce_sum","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 120 samples and the shape of features for each sample is matrix of 15*17. how to use SVM to classify? Is it simply to reshape the matrix to long vector?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":59475835,"Users Score":0,"Answer":"Yes, that would be the approach I would recommend. It is essentially the same procedure that is used when utilizing images in image classification tasks, since each image can be seen as a matrix. \nSo what people do is to write the matrix as a long vector, consisting of every column concatenated to one another.\nSo you can do the same here.","Q_Score":1,"Tags":"python,svm","A_Id":60563891,"CreationDate":"2019-12-25T06:36:00.000","Title":"how to use SVM to classify if the shape of features for each sample is matrix? Is it simply to reshape the matrix to long vector?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a group project which entails generating many reports. We were thinking of using amazon echo. We would ask alexa to fetch the reports from a particular tine period or something like that.\nWe plan on doing so using Python.\nIt is possible using ASK(Alexa Skills Kit) SDK to achieve this goal ? Like, can alexa tap into our application and fetch all that we want. We do not want to use anything else other than Amazon echo.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":59476035,"Users Score":0,"Answer":"I think it's possible you need to create a custom skill for that, there are somethings that you might want to consider though,\n\nHow long is the report: it will work fine if reports are small and giving you some brief overview or some numbers. you don't wanna listen to long report on that robotic voice.\nName of reports: sometimes Alexa will not understand or misunderstood the name you're trying to say if it's complex one.\nmeaning of tap into your application: In Alexa skill you can write custom logic just like you write for a software so If there's API to fetch reports then It can be done. The skill will call API and pass the data that you say to that skill, data like to date, from date etc.","Q_Score":0,"Tags":"python,alexa-skills-kit","A_Id":59519917,"CreationDate":"2019-12-25T07:06:00.000","Title":"Using amazon alexa echo in my 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":1},{"Question":"I was suggested to conda create a new environment for installing tensorflow\nFirst question, in general:\nWhy do environment exist in conda or in Python ? (Why) is it preferable to install a new library in a new environment ? \nHere, in practice:\nAfter install conda shell says $conda activate test will activate the test environment. Does it mean i can't access the lib in Spyder unless i activate test in conda shell ? Do i need to restart python shell to see the lib ? I can't access the lib (no module named tensorflow) and I assume it has to do with python not finding the path.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":615,"Q_Id":59478341,"Users Score":2,"Answer":"After install conda shell says $conda activate test will activate the\n  test environment. Does it mean i can't access the lib in Spyder unless\n  i activate test in conda shell ? Do i need to restart python shell to\n  see the lib ? I can't access the lib (no module named tensorflow) and\n  I assume it has to do with python not finding the path.\n\nHave you installed TF within the environment?\nI haven't used Spyder in a while, but what usually happens is that you can start a program (like Spyder or Jupyter) from an environment if you have installed the application within it and the environment is active. (Some editors\/IDE like VS Code lets you choose the environment for a specific project, once it is able to discover all the environments.)\nAnd, also usually, though perhaps not always, you will not need to restart the shell to import a library, after installing it. It's best to refer to the specific library's installation instructions for details like this.","Q_Score":3,"Tags":"python,machine-learning,anaconda,installation,conda","A_Id":59479676,"CreationDate":"2019-12-25T12:20:00.000","Title":"conda why create new environment for install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is a linear pooling layer? \nWhat can be the maximum size of a linear pooling kernel? \nDo you use dense layers after linear layers?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":125,"Q_Id":59478941,"Users Score":2,"Answer":"Same as a normal pooling layer, but along one dimension. I.e., instead of selecting max response from a n x n window, select from 1 x n. Perhaps it makes sense mostly if the previous output is one-dimensional.\nSize of the previous output along the desired dimension\nNothing prevents you from doing so. Just do whatever makes sense.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":59479185,"CreationDate":"2019-12-25T13:40:00.000","Title":"What is a linear pooling layer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a (540, 960, 1) shaped image with values ranging from [0..255] which is black and white. I need to convert it to a \"heatmap\" representation. As an example, pixels with 255 should be of most heat and pixels with 0 should be with least heat. Others in-between. I also need to return the heat maps as Numpy arrays so I can later merge them to a video. Is there a way to achieve this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20273,"Q_Id":59478962,"Users Score":0,"Answer":"You need to convert the image to a proper grayscale representation. This can be done a few ways, particularly with imread(filename, cv2.IMREAD_GRAYSCALE). This reduces the shape of the image to (54,960) (hint, no third dimension).","Q_Score":10,"Tags":"python,image,opencv,image-processing,computer-vision","A_Id":59479125,"CreationDate":"2019-12-25T13:43:00.000","Title":"How to convert a grayscale image to heatmap image with Python OpenCV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am rather new to Django and I need to fetch some data from a website. For example I want the top ten posts of the day from Reddit. I know of a \"request\" module for the same.But I am not sure where and how should I implement it and will it be important to store the data in a model or not.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":638,"Q_Id":59479195,"Users Score":0,"Answer":"You can create a helper class named like network.py and implement functions to fetch the data.\nIf you want to store them in the database you can create appropriate models otherwise you can directly import and call the function and use the data returned from network.py in your view.","Q_Score":1,"Tags":"django,python-requests","A_Id":59480606,"CreationDate":"2019-12-25T14:11:00.000","Title":"How can I fetch data from a website to my local Django Website?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to build an app through react-native wherein I need to upload a JSON file to my account folder hosted on pythonanywhere.\nCan you please tell me how can I upload a JSON file to the pythonanywhere folder through react-native?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":136,"Q_Id":59479344,"Users Score":2,"Answer":"The web framework that you're using will have documentation about how to create a view that can accept filee uploads. Then you can use the fetch API in your javascript to send the file to it.","Q_Score":0,"Tags":"pythonanywhere","A_Id":59481639,"CreationDate":"2019-12-25T14:33:00.000","Title":"How to upload a file to pythonanywhere using react native?","Data 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 generate unique folder name to be created in an object storage. I don't care what the name will be, i just need to Ensure that it will be unique.\nI am using a python script with boto3 to create the folders and I need to run the script many different times. what is the best way to do that?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":35,"Q_Id":59479600,"Users Score":1,"Answer":"The key part is not how you generate the name. It is that you attempt to create the name and handle the failure if it already exists. Do not check for existence. If the creation succeeds then you have a unique name and that name is not in use by any concurrent process.","Q_Score":0,"Tags":"python,boto3,object-storage","A_Id":59481156,"CreationDate":"2019-12-25T15:09:00.000","Title":"Adding unique folder name to object storage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Kindly help to provide one sample usage of loop.call_exception_handler(context) with an example in asyncio. When loop.get_exception_handler() is already present, why do someone need to call the exception handler explicitly. Also if loop.get_exception_handler() is not set, then what do loop.call_exception_handler(context) call.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":281,"Q_Id":59480210,"Users Score":0,"Answer":"call_exception_handler is a convenience function that encapsulates the logic of invoking the custom exception handler or the default exception handler, and of falling back to the default exception handler if the custom one itself fails. It is designed to be called from code that encounters an exception but doesn't have a \"caller\" to propagate it to. For example:\n\nThe handle that implements call_soon and call_later catches exceptions while invoking the provided function and uses call_exception_handler to report it.\nThe server part of the event loop code that calls accept in a loop uses call_exception_handler to report exceptions raised by accept. It cannot propagate the exception to its caller because it is running in a background task, so it has no caller.\nVarious parts of transports use call_exception_handler to report errors.\n\n\nWhen loop.get_exception_handler() is already present, why do someone need to call the exception handler explicitly.\n\nBecause get_exception_handler() only invokes the custom exception handler, if one is set. If one is not set, the default exception handler is returned. And if one is set, and it raises an exception, the default exception handler is used to report that exception. And errors like SystemExit and KeyboardInterrupt are carefully ignored. It would be tedious and error-prone to repeat this logic in every place that needs to invoke the exception handler, so call_exception_handler was created.","Q_Score":0,"Tags":"python-asyncio","A_Id":59520811,"CreationDate":"2019-12-25T16:39:00.000","Title":"What is the use of loop.call_exception_handler(context)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here is my requirement.\n\nExternal program will get some signals from subprograms each min or specific intervals.\nI want that external program to call Alexa and pass this information\nwho connect with this skill set should hear automatically this output rather than asking Alexa what is the status","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":59485441,"Users Score":0,"Answer":"It's not possible to do that with Alexa. Alexa can be activated only using the voice and it's by design.","Q_Score":0,"Tags":"python,api,response,external,alexa","A_Id":60620377,"CreationDate":"2019-12-26T07:47:00.000","Title":"How to call Alexa intent from external python code and alexa device to announce","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am currently using AWS S3 as a storage for many json files (2 million and counting).\nI want to put all of these files inside a db, in a Postgres RDS.\nI am currently using AWS Lambda which is parsing the files, and it is significantly slower than running it locally. In addition, the work of running the script and installing external modules in Python is pretty terrible with lambda.\nIs there a quicker and more efficient way to work with S3 files, parse them and put them in Postgres without the need to download them? \nIt needs to run on every new file (that's why I chose lambda) and it needs to be divided to couple of tables, so it's not just putting the files as-is (the script already takes the file and parses it to the right tables).","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":78,"Q_Id":59485716,"Users Score":1,"Answer":"You can use aws glue. But that will cost you for each job run.","Q_Score":1,"Tags":"python,postgresql,amazon-web-services,amazon-s3,amazon-rds","A_Id":59486341,"CreationDate":"2019-12-26T08:20:00.000","Title":"Working with s3 files into Postgres effciently","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"New to Python. \nI get the following error on doing a python --version on my GitBash. ...Appdata\/Local\/Microsoft\/WindowsApps\/python3: Permission Denied\nBased on some answers on this forum I turned off the App execution aliases for python. Doing this deleted the two \"stubs\" python.exe and python3.exe from my Windows App folder and resulted in another error of No such file or directory to my python --version on GitBash.\nI am a novice to python so it gets annoying to be stuck at the installation itself. What am I missing here ???\nIt's December and all these updates from Microsoft I assume has still not fixed this issue. Or?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":14453,"Q_Id":59487242,"Users Score":1,"Answer":"Solved:\nPython commands won't work on mintty. \nI did a python -i to enter the python mode\nAnother option is to do a 'winpty python.exe'","Q_Score":4,"Tags":"python-3.x,windows,windows-store-apps,git-bash","A_Id":59536173,"CreationDate":"2019-12-26T10:42:00.000","Title":"Permission Denied error: Python 3.8 on Windows Gitbash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"New to Python. \nI get the following error on doing a python --version on my GitBash. ...Appdata\/Local\/Microsoft\/WindowsApps\/python3: Permission Denied\nBased on some answers on this forum I turned off the App execution aliases for python. Doing this deleted the two \"stubs\" python.exe and python3.exe from my Windows App folder and resulted in another error of No such file or directory to my python --version on GitBash.\nI am a novice to python so it gets annoying to be stuck at the installation itself. What am I missing here ???\nIt's December and all these updates from Microsoft I assume has still not fixed this issue. Or?","AnswerCount":3,"Available Count":2,"Score":-0.1325487884,"is_accepted":false,"ViewCount":14453,"Q_Id":59487242,"Users Score":-2,"Answer":"simply uninstall the old one and install the new one you just downloaded. git team has already solved the issue is the last option when installing just check it to use it with python and other programs.","Q_Score":4,"Tags":"python-3.x,windows,windows-store-apps,git-bash","A_Id":65545975,"CreationDate":"2019-12-26T10:42:00.000","Title":"Permission Denied error: Python 3.8 on Windows Gitbash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to check if a folder by the name \"Output Folder\" exists at the path\n\nD:\\LaptopData\\ISIS project\\test\\d0_63_b4_01_18_ba\\00_17_41_41_00_0e\n\nif the folder by the name \"Output Folder\" does not exist then create that folder there.\ncan anyone please help with providing a solution for this?","AnswerCount":7,"Available Count":1,"Score":0.057080742,"is_accepted":false,"ViewCount":38564,"Q_Id":59487696,"Users Score":2,"Answer":"Search for folder whether it exists or not, it will return true or false: os.path.exists('<folder-path>')\nCreate a new folder: os.mkdir('<folder-path>')\n\nNote: import os will be required to import the module.\nHope you can write the logic using above two functions as per your requirement.","Q_Score":27,"Tags":"python","A_Id":59487767,"CreationDate":"2019-12-26T11:20:00.000","Title":"check if a folder exists in a given path and if not then create a folder there","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to run a test case using the command below\npipenv run py.test --cov=src --cov-fail-under=85 -vv test\/unit --debug\nIt complains as below\n<CallInfo when='collect' excinfo=<ExceptionInfo CollectError(\"ImportError while importing test module '\/Users\/omsingh0\/Applications\/aws\/awspipeline\/examples\/ecommerce...in <module>\\n    from requests_aws4auth import AWS4Auth\\nE   ModuleNotFoundError: No module named 'requests_aws4auth'\") tblen=7>>\nWhen I run pip list I can notice that requests-aws4auth is there\nPackage           Version   \n\ncertifi           2019.11.28\nchardet           3.0.4\nelasticsearch     7.1.0\nidna              2.8\npip               19.2.3\npipenv            2018.11.26\nrequests          2.22.0\nrequests-aws4auth 0.9\nsetuptools        39.0.1\nurllib3           1.25.7\nvirtualenv        16.7.9\nvirtualenv-clone  0.5.3         \nPlease let me know in case you have any suggestion.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1259,"Q_Id":59488208,"Users Score":1,"Answer":"l was able to run the below command and after, it was successful.\n$ pip install requests\n$ sudo pip install requests-aws4auth\nGive it a try","Q_Score":1,"Tags":"python,python-unittest","A_Id":64043149,"CreationDate":"2019-12-26T12:04:00.000","Title":"python unit test - unable to import requests_aws4auth","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 let's say I have 10 custom entities to recognize how much annotated training sentences should I give (Any rough idea) ??\nThank You, in Advance!! :)\nI am new to this, please help","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1690,"Q_Id":59488470,"Users Score":1,"Answer":"For developing custom ner model at least 50-100 occurrences of each entity will be required along with their proper context. Otherwise if you have less data than your custom model will overfit on that. So, depending upon your data you will require atleast 200 to 300 sentences.","Q_Score":0,"Tags":"python,machine-learning,spacy,named-entity-recognition","A_Id":59488669,"CreationDate":"2019-12-26T12:25:00.000","Title":"How many training data(sentences) are required for custom NER using spacy python?[Just rought idea]","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know let's say I have 10 custom entities to recognize how much annotated training sentences should I give (Any rough idea) ??\nThank You, in Advance!! :)\nI am new to this, please help","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1690,"Q_Id":59488470,"Users Score":1,"Answer":"For the custom NER model from Spacy, you will definitely require around 100 samples for each entity that too without any biases in your dataset.\nAll this is as per my experience.\nSuggestion -:\nSpacy Custom model you can explore, but for production level or some good project, you can't be totally dependent on that only, You have to do some NLP\/ Relation Extraction, etc. along with this.\nHope this helps.","Q_Score":0,"Tags":"python,machine-learning,spacy,named-entity-recognition","A_Id":59490154,"CreationDate":"2019-12-26T12:25:00.000","Title":"How many training data(sentences) are required for custom NER using spacy python?[Just rought idea]","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently using Google ML notebooks to train a lot of my NLP projects. Lately, I wanted to use Kashgari, but there is an issue. The catch is Google notebooks run on Debian Stretch which contains Python <3.5. Kashgari, and hence I, need Python >3.6. One obvious way is to change from Stretch to Buster using debian's apt-get itself, and everything is good. Except, it overwrites grub settings and other side-effects which bricks the vc. The alternative would be to actually make update just the python without messing around with the rest of the system. What is the easiest way to do this? Note that I want the jupyter notebooks to use the new python3 version; so just a local venv will not be enough.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1030,"Q_Id":59488799,"Users Score":1,"Answer":"You can always just download python from the source and compile it, it only takes 2 commands.\nHowever you shouldn't replace the system's python installation, a lot of its utilities use it, you should install another interpreter alongside it","Q_Score":0,"Tags":"python,google-cloud-platform,python-packaging,debian-based","A_Id":59489050,"CreationDate":"2019-12-26T12:55:00.000","Title":"Is there a way to update Python 3.5 to 3.6 on a debian stretch without apt-get upgrade?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How do we really link the PyPDF2 to a different version of Python? I do have several version of Python installed in my Mac (Python 2.6, 2.7, 3.6 etc.,) \u2013 itsraghz May 24 at 5:09","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":59489812,"Users Score":0,"Answer":"best way to do it is creating virtual environments in python as part of project source folders.\nconventional folder name for a python virtual environment is .venv\nto create a virtual environment:\n\n\nfrom command shell cd to project source directory\nrun [python] -m venv .venv [python] should be the path of the executable file or python it self if referenced in environment variables.  since there are multiple\n  python versions installed, using python executable path with desired\n  version would be ideal.\n\n\nthis way there can be n number of working environments with different python versions even with different library versions[i.e. for testing purposes]","Q_Score":0,"Tags":"python-3.x","A_Id":59490068,"CreationDate":"2019-12-26T14:32:00.000","Title":"How do we really link the PyPDF2 to a different version of Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am writing a code to run a pi-based robot. It has several sensors and communicates with external computers over wifi as well. Some of the sensor and computer communication data is done over sockets (to other scripts) to keep things modular and simple (for me). As long as I stay at less than 10 sockets, will I come across any problems? I am mostly wondering if there is anything inherently wrong with this coding strategy.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":59490736,"Users Score":0,"Answer":"Q : As long as I stay at less than 10 sockets, will I come across any problems?\n\nMaybe yes, maybe not. The number of ZeroMQ Socket-instances does not matter in this, the configuration of the ZeroMQ Context()-instances and thereof of the underlying operating system's resources do matter.\n\nQ : anything inherently wrong with this coding strategy?\n\nNo, unless you do right things in a wrong way. Particularly \"this coding\" remains magically hidden as an unseen, so far, code, the less the MCVE-formulated code-example and the general answer for such a problem thus suffers from a principal undecidability, until an MCVE-code is let to run in the problem-specific eco-system, with known limits for the control-loops and the robot physical properties ( which is left to the kind readers to review ad-hoc ).\nZeroMQ will have Zero-problems in running on the RPi-platform, given due configuration does not suffocate the Context()-instance(s) by not providing adequate resources.","Q_Score":1,"Tags":"python,websocket,zeromq,pi,sensors","A_Id":59505155,"CreationDate":"2019-12-26T16:03:00.000","Title":"is there such a thing as too many python websockets?","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":"No Python at 'C:\\Users\\Mr_Le\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe'\nAny time I try to run my code it keeps prompting me this ^^^ but I had recently deleted Python 3.8 to downgrade to Python 3.6 and just installed Python 3.6 to run pytorch.\nDoes anyone know how to fix this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1413,"Q_Id":59491281,"Users Score":0,"Answer":"1.In your windows search bar find python 3.9.8.\n[Searching for Windows][1]\n[1]: https:\/\/i.stack.imgur.com\/vNMxT.png\n\nRight click on your the app\n\nClick on App Settings\n[Your settings will populate][2]\n[2]: https:\/\/i.stack.imgur.com\/E4yM3.png\n\nScroll down on this page\n[][3]\n[3]: https:\/\/i.stack.imgur.com\/HFc1J.png\n\nHit the Repair box\n\nTry to run your python script again after restarting all your programs","Q_Score":0,"Tags":"python,pycharm","A_Id":69969295,"CreationDate":"2019-12-26T16:59:00.000","Title":"Pycharm can't find python.exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"No Python at 'C:\\Users\\Mr_Le\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe'\nAny time I try to run my code it keeps prompting me this ^^^ but I had recently deleted Python 3.8 to downgrade to Python 3.6 and just installed Python 3.6 to run pytorch.\nDoes anyone know how to fix this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1413,"Q_Id":59491281,"Users Score":0,"Answer":"For other users: just check the \"C:\\Users<>\\AppData\\Local\\Programs\\Python\"  folder on your PC and remove any folders belonging to previous installations of Python. Also check if environmental variables are correct.","Q_Score":0,"Tags":"python,pycharm","A_Id":63930446,"CreationDate":"2019-12-26T16:59:00.000","Title":"Pycharm can't find python.exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"With VS Code, when I use a linter like Flake8 or Pylint, it will underline sections of the code, and when I hover it will tell me the code of the rule being broken and a description.\nI would like to have the same functionality but for formatters like pep8 or black. But it seems all they can do it format on save, or format as a command. I would like to have this information more visible so I can understand the rules more, and decide if I want to change the default formatter rules for my project. Right now I have to just save, and try to guess what's been changed or do a diff of the file before\/after.\nI don't see any options in the format settings to make this info visible for python code.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":51,"Q_Id":59492067,"Users Score":1,"Answer":"There isn't any such settings as the formatters themselves don't provide this sort of information. All they do is provide is a diff which then gets applied to your file. There isn't any information provided to say exactly which part of a line would be changed.","Q_Score":0,"Tags":"python,visual-studio-code,formatter,pep8,python-black","A_Id":59570917,"CreationDate":"2019-12-26T18:23:00.000","Title":"Is it possible to have VS Code display formatter rules in the editor, like linters do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"django.core.exceptions.ImproperlyConfigured: You\u2019re using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path. \nHaving this error despite me having set the STATIC_ROOT: \nSTATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":59492543,"Users Score":0,"Answer":"Check the static file root. If it's on correct location. For heroku try to put that file on git. I am assuming it's a blank directory so it's not being pushed to git repo. Put .keep kind of file and add\/commit and try. Hope it will solve your issue.","Q_Score":0,"Tags":"python,django,heroku","A_Id":59492596,"CreationDate":"2019-12-26T19:16:00.000","Title":"Having an Error with STATIC_ROOT when using heroku in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I updgraded from Spyder 3 to Spyder 4 and now when I execute a cell I need to wrap a print() around whatever variable is in the last line of the cell so that the contents are automatically printed \/ displayed in the console. What setting do I need to revert in order to get back to the prior set up. \nin case this is not clear: \ndisplay = \"1 2 3 4 5\"\ndisplay\n{Ctrl Enter}\nwould ouput:\n1 2 3 4 5\nto the console\nnow it does not display anything in the console\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1834,"Q_Id":59492823,"Users Score":12,"Answer":"What setting do I need to revert in order to get back to the prior set up?\n\nYou need to go to the menu\nTools > Preferences > Editor > Run Code\nand activate the option called\nCopy full cell contents to the console when running code cells.","Q_Score":2,"Tags":"python,settings,spyder","A_Id":59494870,"CreationDate":"2019-12-26T19:48:00.000","Title":"Automatically display results of last cell execution in Spyder 4 console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using a custom training loop. The loss that is returned by tf.keras.losses.categorical_crossentropy is an array of I'm assuming (1,batch_size). Is this what it is supposed to return or a single value?\nIn the latter case, any idea what I could be doing wrong?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":747,"Q_Id":59493127,"Users Score":2,"Answer":"Most usual losses return the original shape minus the last axis.\nSo, if your original y_pred shape was (samples, ..., ..., classes), then your resulting shape will be (samples, ..., ...).\nThis is probably because Keras may use this tensor in further calculations, for sample weights and maybe other things. \nIn a custom loop, if these dimensions are useless, you can simply take a K.mean(loss_result) before calculating the gradients. (Where K is either keras.backend or tensorflow.keras.backend)","Q_Score":3,"Tags":"python,tensorflow,keras,loss-function","A_Id":59493316,"CreationDate":"2019-12-26T20:22:00.000","Title":"Does tf.keras.losses.categorical_crossentropy return an array or a single value?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have CNN that I have built using on Tensor-flow 2.0. I need to access outputs of the intermediate layers. I was going over other stackoverflow questions that were similar but all had solutions involving Keras sequential model. \nI have tried using model.layers[index].output but I get \n\nLayer conv2d has no inbound nodes.\n\nI can post my code here (which is super long) but I am sure even without that someone can point to me how it can be done using just Tensorflow 2.0 in eager mode.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3974,"Q_Id":59493222,"Users Score":0,"Answer":"The most straightforward solution would go like this:\nmid_layer = model.get_layer(\"layer_name\")\nyou can now treat the \"mid_layer\" as a model, and for instance:\nmid_layer.predict(X)\nOh, also, to get the name of a hidden layer, you can use this:\nmodel.summary() \nthis will give you some insights about the layer input\/output as well.","Q_Score":2,"Tags":"python,tensorflow,deep-learning,tensorflow2.0","A_Id":63206321,"CreationDate":"2019-12-26T20:34:00.000","Title":"Access output of intermediate layers in Tensor-flow 2.0 in eager mode","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm am trying to build an .exe file with pyinstaller.\nWhen launching the build .exe file I have the following error :\n\nModuleNotFoundError: No module named 'img2pdf'\n\nI have already build some .exe with pyinstaller, which are working. So I guess the problem is not pyinstaller. I am also using Pycharm with a virtual environnement.\nThe code is working well when running on Pycharm.\nWith the --debug all option of pyinstaller, I can see the following lines :\n\n  img2pdf not found in PYZ Traceback (most recent call last):   File \"download_pdf.py\", line 7, in    File \"\n  \n  importlib._bootstrap>\", line 983, in _find_and_load   File \"\", line 965, in _find_and_load_unlocked\n  ModuleNotFoundError: No module named 'img2pdf' [4812] Failed to\n  execute script download_pdf\n\nI tried pip install img2pdf in the Terminal of pycharm (virtual environnement) and in the command prompt of my OS (windows 10).\nDoes anyone know what's wrong ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":682,"Q_Id":59493277,"Users Score":1,"Answer":"I had to use the following option of pyinstaller :\n--hidden-import=img2pdf\nIt now works.","Q_Score":0,"Tags":"python,pyinstaller,img2pdf","A_Id":59514685,"CreationDate":"2019-12-26T20:40:00.000","Title":"error No module named 'img2pdf' when executing .exe - pyinstaller","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use Cloud Shell Console to write python code that uses Google Speech to Text\nSteps taken:\n\nGoogle cloud shell console to write the code\n\ngcloud app deploy\n\nError message:\nFile \"\/home\/vmagent\/app\/main.py\", line 3, in <module> from google.cloud import speech_v1 ModuleNotFoundError: No module named 'google'\n\npip list run on the console shows that 'google' is included","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":217,"Q_Id":59494736,"Users Score":1,"Answer":"Try using pip3 instead of pip.\nIt took me hours to find out the files had been in another directory all along.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":62807529,"CreationDate":"2019-12-27T00:21:00.000","Title":"from google.cloud import speech_v1 ---- ModuleNotFoundError: No module named 'google'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with the dataset of size (500, 33). \nIn particular the data set contains 9 features say\n[X_High, X_medium, X_low, Y_High, Y_medium, Y_low, Z_High, Z_medium, Z_low]\nBoth visually & after correlation matrix calculation I observed that \n[X_High, Y_High, Z_High] & [ X_medium, Y_medium,  Z_medium ] & [X_low, Y_low, Z_low] are highly correlated (above 85%).\nI would like to perform a Clustering algorithm (say K means or GMM or DBSCAN).\nIn that case,\nIs it necessary to remove the correlated features for Unsupervised learning ?\nWhether removing correlation or modifying features creates any impact ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1456,"Q_Id":59494747,"Users Score":3,"Answer":"My assumption here is that you're asking this question because in cases of linear modeling, highly collinear variables can cause issues.\nThe short answer is no, you don't need to remove highly correlated variables from clustering for collinearity concerns.  Clustering doesn't rely on linear assumptions, and so collinearity wouldn't cause issues.\nThat doesn't mean that using a bunch of highly correlated variables is a good thing.  Your features may be overly redundant and you may be using more data than you need to reach the same patterns.  With your data size\/feature set that's probably not an issue, but for large data you could leverage the correlated variables via PCA\/dimensionality reduction to reduce your computation overhead.","Q_Score":1,"Tags":"python,machine-learning,correlation,unsupervised-learning,feature-engineering","A_Id":59494808,"CreationDate":"2019-12-27T00:23:00.000","Title":"Does correlation important factor in Unsupervised learning (Clustering)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to plot the endpoints of the line segment which is a tangent to a circle in Python.\nI know the circle has center of (A, B), and a radius of r. The point at which I want to find the tangent at is (a, b). I want the tangent to be a segment of length c. How do I write a code which allows me to restrict the length of the line?\nI have the equation of the tangent to be y = (-(B - b)\/(A - a))(x - a) + b. So I know how to plot the two endpoints if the length of the segment did not matter. But how would I determine the x-coordinates of the point? Is there some sort of command which allows me to limit the length of a line?\nThank you!!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":59495415,"Users Score":0,"Answer":"I don't know thonny, and it sounds like your implementation will depend a bit on the context of this computation. \nThat said, it sounds like what you're looking for is the two points of intersection of your tangent line and a (new, conceptual) cicle with a given radius centered on (a,b). You should be able to put together the algebraic expression for those points, and simplify it into something tidy. Watch out for special cases though, where the slope of the tangent is undefined (or where it's zero).","Q_Score":1,"Tags":"python,mathematical-expressions,thonny","A_Id":59504964,"CreationDate":"2019-12-27T02:38:00.000","Title":"Given a midpoint, gradient and length. How do I plot a line segment of specific length?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have this virtualenv called py3cv3 created using virtualwrapper. I am trying to set this enviromennt to be used with a Project  that I clone using GitHub. I am using Pycharm 2019.\nBut when I open the Project Settings, to set an Project Interpreter I can't select the default path where virtualenvs are installed(~\/.virtualenv\/).\nI also tried do set  py3cv3 path as a Project Structure but Pycharm doesnt accept it. It just display the box in red color. \nI already click at The option to show hidden folders and files,but Pycharm still not displaying the content from \/root\/ path.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":59495740,"Users Score":0,"Answer":"So,  i didnt find an answer. The only  way I found to get it right was removing everything related with envs and installing it again pointing to \/home\/username\/. virtualenv.","Q_Score":0,"Tags":"python,pycharm,virtualenv,ubuntu-18.04","A_Id":59507788,"CreationDate":"2019-12-27T03:45:00.000","Title":"Using virtualenv\/virtualwrapper in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large 1.5Gb data file with multiple fields separated by tabs. \nI need to do lookups in this file from a web interface\/ajax queries like an API, possibly large number of ajax requests coming in each second. So it needs to be fast in response.\nWhat is the fastest option for retrieving this data? Is there performance-tested info, benchmarking? \nConsidering the tab-separated CSV file is a flat file that will be loaded in the memory. But it cannot produce an index.\nJSON has more text because, but an 'indexed' JSON can be created, grouping entries for a certain field.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":676,"Q_Id":59496148,"Users Score":2,"Answer":"Neither. They are both horrible for your stated purpose. JSON cannot be partially loaded; TSV can be scanned without loading it in memory, but has sequential access. Use a proper database.\nIf, for some reason, you can't use a database, you can McGyver it by using TSV or JSONL (not JSON) with an additional index file that specifies the byte position of the start of the record for each ID (or another searchable field).","Q_Score":1,"Tags":"python,json,python-3.x,database,csv","A_Id":59496178,"CreationDate":"2019-12-27T04:53:00.000","Title":"CSV vs JSON vs DB - which is fastest and scalable to load in the memory and retrieve data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the list of APIs,\nInput  = [WriteConsoleA, WSAStartup, RegCloseKey, RegCloseKey, RegCloseKey, NtTerminateProces, RegCloseKey]\nexpected output = [WriteConsoleA, WSAStartup, RegCloseKey, NtTerminateProces, RegCloseKey]","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":59496859,"Users Score":0,"Answer":"you can simply convert set(list) i.e. set(Input) to remove all the duplicates.","Q_Score":0,"Tags":"python,python-3.x,portable-executable","A_Id":59496919,"CreationDate":"2019-12-27T06:26:00.000","Title":"How to match duplicates and if match how to remove second one in list in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Flask app development, i need some clarifications on using database with flask app. \nWe have a MySQL db which has some metrics, currently we generate some reports using python using MySQL.connector.\nWe have python modules\/functions to fetch the data from the db using mysql.connector and populate a dictionary which has data to be put in the report. \nMy question is can i use the same python module in the app.py (if this is where i create the app) and get the data as dictionary and pass it to some template html to render the report?\nIf i can do this, what is the advantage of using Flask-MySql or Flask-SqlAlchemy and doing the app.config[] things which are mentioned in many tutorials?\nI am trying to understand what should be used when.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":676,"Q_Id":59496972,"Users Score":0,"Answer":"well for ur case if ur have not much experience in sql i prefer u to use orm like Sqlalchemy. for flask there is an extension call flask-sqlalchemy.it uses python like syntax without using direct sql it is very easy to learn and well documented.but not recommended for advanced user cases.If u want to pass pure sql queries through flask and to have more capablities in database site better to use flask extension for mysql flask-mysql.It depend on ur requirement,capability and user case.","Q_Score":1,"Tags":"flask,mysql-connector-python,flask-mysql","A_Id":59499709,"CreationDate":"2019-12-27T06:38:00.000","Title":"what is the Difference between using mysql connector and Flask-Mysql in Flask app?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am doing a small project on sentiment analysis using TextBlob. I understand there are are 2 ways to check the sentiment of tweet:\n\nTweet polarity: Using it I can tell whether the tweet is positive, negative or neutral\nTraining a classifier: I am using this method where I am training a TextBlob Naive Bayes classifier on positive and negative tweets and using the classifier to classify tweet either as 'positive' or 'negative'.\n\nMy question is, using the Naive bayes classifier, can I also classify the tweet as 'neutral' ? In other words, can the 'sentiment polarity' defined in option 1 can somehow be used in option 2 ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":304,"Q_Id":59498416,"Users Score":0,"Answer":"If you have only two classes, Positive and Negative, and you want to predict if a tweet is Neutral, you can do so by predicting class probabilities.\nFor example, a tweet predicted as 80% Positive remains Postive. However, a tweet predicting as 50% Postive could be Neutral instead.","Q_Score":0,"Tags":"python,nltk,sentiment-analysis,naivebayes,textblob","A_Id":59678549,"CreationDate":"2019-12-27T09:10:00.000","Title":"TextBlob Naive Bayes classifier for neutral tweets","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 function F1 that loops continuously (while loop). I have set a condition, if met, calls another function F2 inside function F1. Once called, the function F2 shouldn't be called again for a few seconds, say 3 secs, even if the condition is met again within 3 seconds. But function F1 has to be looping continuously. How do I achieve it?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":82,"Q_Id":59499131,"Users Score":4,"Answer":"Save time when you call F2 (say time_f2). Next time the condition is met, compare now with time_f2 and call F2 only if the difference is more than 3 seconds.","Q_Score":2,"Tags":"python","A_Id":59499153,"CreationDate":"2019-12-27T10:11:00.000","Title":"Pausing a called function for a few seconds","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to use Dialogflow interface to create a voice assisted chatbot. \nStill, I would like to be able to add my own components to it. \nHow can this be done ? If I have a python script with an NLP technique I'd want to add to my chatbot.\nDialogflow is mainly about NER and let's say I want to add TFIDF and text simplification to what's retrieved in my document.\nI looked at the documentation and couldn't find anything on the subject.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":136,"Q_Id":59500951,"Users Score":0,"Answer":"you can use a Webhook: each intent is 'forwarded' to your webhook (ie custom app or script) and you have full access to the text provided by the user as well as the DialogFlow contexts\/entities.\nIn your webhook you can can do what you want, including modifying the response to the user.\nHope it helps.\nBeppe","Q_Score":0,"Tags":"python,dialogflow-es,chatbot","A_Id":59561247,"CreationDate":"2019-12-27T12:38:00.000","Title":"How to integrate an external NLP technique to Dialogflow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am confused as to how I can use Doc2Vec(using Gensim) for IMDB sentiment classification dataset. I have got the Doc2Vec embeddings after training on my corpus and built my Logistic Regression model using it. How do I use it to make predictions for new reviews? sklearn TF-IDF has a transform method that can be used on test data after training on training data, what is its equivalent in Gensim Doc2Vec?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":217,"Q_Id":59501121,"Users Score":1,"Answer":"To get a vector for an unseen document, use vector = model.infer_vector([\"new\", \"document\"])\nThen feed vectorinto your classifier: preds = clf.predict([vector]).","Q_Score":0,"Tags":"python,nlp,gensim,doc2vec","A_Id":59501847,"CreationDate":"2019-12-27T12:55:00.000","Title":"Sentiment Classification using Doc2Vec","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a python script that checks the trains for me from home to the office and vice versa. For now it accepts input like tomorrow, today, around X hour etc. and it works like a charm. However the problem is when I say: \"Hey Siri, check me a train from home to the office tomorrow around 7\" it opens the Pythonista app and shows the result in a console, so I have to read it myself.\nAs you can tell I'm lazy so I would prefer Siri to read it for me.\nHow can I get the Siri to read the output without the Pythonista app being opened? It should execute the code in a background, somehow pass the values back to the shortcut, which would allow Siri to read the output.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":225,"Q_Id":59501872,"Users Score":0,"Answer":"Pythonista has a speech module that you can use to speak your results aloud. Different languages and locales are availble, and as underneath Apple APIs are used you even get the same old Siri voice.","Q_Score":1,"Tags":"siri,sirishortcuts,pythonista","A_Id":63102722,"CreationDate":"2019-12-27T14:02:00.000","Title":"How to make Siri read the return value of a Pythonista script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have very sparse and huge rating data which I should find top k neighbors for each session. I need to compare approximate and exact nearest neighbor algorithms but since the data is very big and sparse the computation of the exact method is taking days to compute with brute force. I want to use KD Trees or Ball Trees but they are not supporting cosine distance. Is there a way to convert other distance measures to cosine similarity by math or is there any other way to compute exact neighborhood?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":302,"Q_Id":59503600,"Users Score":1,"Answer":"try to normalize your matrix and use euclidian metric.","Q_Score":0,"Tags":"python,scikit-learn,knn,nearest-neighbor,cosine-similarity","A_Id":59694232,"CreationDate":"2019-12-27T16:40:00.000","Title":"Is there a way find nearest neighbors with BallTree or KDTree using cosine similarity?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to solve a problem using python, and I need to calculate :\nr =(1^2|~4)**((5&9^3)|3*8**9)\nHowever, the computer is taking forever to finish that operation. Any clue on how to solve this?\nSimpler = -5**402653186\nSPECS :\nOS : Ubuntu 18.04\nRAM : 8 Gig\nCPU : Intel i5 8Gen","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":59505052,"Users Score":2,"Answer":"The number you're trying to calculate is very large. -1.45992917087860574535892544169158544350135939488 \u00d7 10^281442499 to be precise according to wolfram-alpha. While python longs can be of unlimited length and expand to fill memory it is just a calculation that would take a super long time, try using htop, it should show that ram usage is constantly increasing. You should reconsider on why you are calculating numbers so large.","Q_Score":0,"Tags":"python-3.x,ubuntu,calculus","A_Id":59505248,"CreationDate":"2019-12-27T19:08:00.000","Title":"Python Stuck Calculating","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am going through a Django tutorial but it's an old one. The videos were all made using Django 1.11 and Python 3.6. Problem is I have installed python3.8 in my machine. So I was trying to create virtualenv with python version 3.6. But as python 3.6 is not available in my machine, I couldn't do that. At this point I was wondering even if it is actually possible to have both python 3.6 and python 3.8 in a machine at same time. \nKindly someone help me with this problem or point me to the right resource to understand more on this problem.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2753,"Q_Id":59505322,"Users Score":1,"Answer":"Yes. You can have both versions installed on single machine. All u need to do is to download Python3.6 from its Official site, set your Interpreter to python3.6 and u r all set.","Q_Score":1,"Tags":"python","A_Id":59505439,"CreationDate":"2019-12-27T19:36:00.000","Title":"Is it possible to have both Python3.6 and Python3.8 versions installed at same time in windows machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am currently working on a project where get the top 10 most relevant words of set of document using tfidf in python. However, there are results where are get the same word and its plurial or adverb or so. To go around this problem, I decided to use stemming, but this leads to a problem where words and their antonyms can have the same root or by reducing a word to its root does not enable to go back and find that specific word in the document if a user was to search for it. Is there a nlp that might be better in this context than nlp? Any hint or link will be useful. I working on something that is very similar to youtube.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":281,"Q_Id":59505444,"Users Score":0,"Answer":"First you'd want to make a choice between Stems and Lemmas (neither are Roots, mind you). Google the difference for more on that. \nYou mention antonyms, but most are determined by prefix (e.g. important vs (un)important). So the Stemmer should leave most antonyms unchanged. \nAs for synonyms, let's assume you're thinking only about words with the exact same Stem, because if you want to relate synonyms with completely unrelated roots, you'd be thinking about semantics and something like wordnet but that would likely complicate your problem beyond reasonable...\nFrom your question, you already have a Stemmer working in Python...The simplest solution would be using two dictionaries: One dictionary mapping stems\/lemmas to the set\/list of inflected\/derived complete words (and\/or their frequency). And a second dictionary mapping those complete words to their various positions in the documents you are indexing.\nThat way you can stem the user input word, check for it in the top-k tf-idf\/stem dictionary, and afterwards map the complete word with the second dictionary to its occurrences in the document set.\n(It's hard to elaborate further given your question.)","Q_Score":1,"Tags":"python,nlp,tf-idf,cosine-similarity","A_Id":59507255,"CreationDate":"2019-12-27T19:50:00.000","Title":"Remove synonyms of TFIDF results in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have noticed that both of the instructions tk.Tk() and tk.Frame make a new window, so what is the difference between them? and what is the advantage of using one over the other ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":688,"Q_Id":59506238,"Users Score":2,"Answer":"I have noticed that both of the instructions tk.Tk() and tk.Frame make a new window\n\nThat is not correct. tk.Frame will not make a new window, except for the fact that any widget will force the creation of a root window if you haven't already created the root window.\nWidgets in a tkinter application exist in a hierarchy, and that hierarchy must have a root window. The root window is special in that it doesn't have a parent. All other widgets must have a parent. Every application must have an instance of tk.Tk, and except for very rare circumstances you should never have more than one instance of tk.Tk.\ntk.Frame is a frame: a widget with a border and not much else. Like all other widgets (except tk.Tk), it must have a parent. \nThe advantage to using tk.Tk is that your application must have an instance of it. If you don't create one, one will be created for you. The zen of python says explicit is better than implicit, so you should always explicitly create it.\nThe advantage to using tk.Frame is that it makes it easy to collect widgets into groups and be able to manage them as a group (add a border, lay them out as a group, etc).","Q_Score":0,"Tags":"python,tkinter","A_Id":59506289,"CreationDate":"2019-12-27T21:34:00.000","Title":"difference between tk.Tk() and tk.Frame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"using PCA (principle component analysis) to extract features from a set of 4K images giving me the memory error\nFile \"\/home\/paul90\/.local\/lib\/python3.6\/site-packages\/sklearn\/decomposition\/_pca.py\", line 369, in fit_transform\n    U, S, V = self._fit(X)\nMemoryError: Unable to allocate array with shape (23339520, 40) and data type float32\nI am trying to extract 30 features (# of components) from 4K images and getting this error.\n\nPseudocode:\n\nimmatrix = np.array([np.array(Image.open(im, 'r')).flatten() for im in file_list], 'f')\nx = StandardScaler().fit_transform(immatrix)\npc_train = pca.fit_transform(x)\nFilelist is list of images (currently I have 600 images)\nI can't reduce the number of images in the list and can't reduce the initial 4K resolution. In this context,how can I solve this memory allocation issue?\nIt will be a great help if anyone can tell me the steps to avoid the memory issues.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":323,"Q_Id":59506774,"Users Score":0,"Answer":"As this problem stated, you have to reconfigure your system to make more RAM available to the run-time system.\nHowever, I suspect that you can finesse the problem by iterating through the images, rather than loading all of them into one large NumPy array.  Rather than using the monolithic processing tools, you'll need to write code to perform the same computations serially.","Q_Score":0,"Tags":"python,image,pca,feature-extraction","A_Id":59506950,"CreationDate":"2019-12-27T22:57:00.000","Title":"PCA analysis incites memory allocation problem. How to solve this without reducing image resolution or number of images","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on an assignment and am stuck with the following problem:\nI have to connect to an oracle database in Python to get information about a table, and display this information for each row in an .html-file. Hence, I have created a python file with doctype HTML and many many \"print\" statements, but am unable to embed this to my main html file. In the next step, I have created a jinja2 template, however this passes the html template data (incl. \"{{ to be printed }}\") to python and not the other way round. I want to have the code, which is executed in python, to be implemented on my main .html file.\nI can't display my code here since it is an active assignment. I am just interested in general opinions on how to pass my statements from python (or the python file) into an html file. I can't find any information about this, only how to escape html with jinja. \nAny ideas how to achieve this?\nMany thanks.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":59508664,"Users Score":0,"Answer":"Thanks for the suggestions. What I have right now is a perfectly working python file containing jinja2 and the html output I want, but as a python file. When executing the corresponding html template, the curly expressions {{name}} are displayed like this, and not as the functions executed within the python file. Hence, I still have to somehow tell my main html file to execute this python script on my webpage, which I cannot manage so far.\nUnfortunately, it seems that we are not allowed to use flask, only jinja and django.","Q_Score":1,"Tags":"python,html,jinja2","A_Id":59509853,"CreationDate":"2019-12-28T06:27:00.000","Title":"How can I embed a python file or code in HTML?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on an assignment and am stuck with the following problem:\nI have to connect to an oracle database in Python to get information about a table, and display this information for each row in an .html-file. Hence, I have created a python file with doctype HTML and many many \"print\" statements, but am unable to embed this to my main html file. In the next step, I have created a jinja2 template, however this passes the html template data (incl. \"{{ to be printed }}\") to python and not the other way round. I want to have the code, which is executed in python, to be implemented on my main .html file.\nI can't display my code here since it is an active assignment. I am just interested in general opinions on how to pass my statements from python (or the python file) into an html file. I can't find any information about this, only how to escape html with jinja. \nAny ideas how to achieve this?\nMany thanks.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":59508664,"Users Score":0,"Answer":"You can't find information because that won't work. Browser cannot run python, meaning that they won't be able to run your code if you embed it into an html file. The setup that you need is a backend server that is running python (flask is a good framework for that) that will do some processing depending on the request that is being sent to it. It will then send some data to a template processor (jinja in this case work well with flask). This will in turn put the data right into the html page you want to generate. Then this html page will be returned to the client making the request, which is something the browser will understand and will show to the user. If you want to do some computation dynamically on the browser you will need to use javascript instead which is something a browser can run (since its in a sandbox mode).\nHope it helps!","Q_Score":1,"Tags":"python,html,jinja2","A_Id":59508694,"CreationDate":"2019-12-28T06:27:00.000","Title":"How can I embed a python file or code in HTML?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to use youtube-dl in a python script, not using commands. I installed youtube-dl using pip install youtube-dl and I also tried installing it using pip install --upgrade youtube-dl and also pip3 install youtube-dl. It keeps saying I have it installed so I'm guessing the installation is fine.\nWhen I try to use import youtube_dl it gives me the error: unresolved import 'youtube_dl'Python(unresolved-import)\nPlease help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1091,"Q_Id":59511510,"Users Score":1,"Answer":"This is a VS Code issue and not a youtube-dl issue. What you need to do is \n\nGo into the workspace folder (here workspaceRootFolder) and create a .env file\nIn this empty .env file add the line PYTHONPATH=codeFolder (replace codeFolder with your folder name)\nAdd \"python.envFile\": \"${workspaceFolder}\/.env\" to the settings.json\nRestart VS code","Q_Score":0,"Tags":"python,windows,visual-studio-code,pip,youtube-dl","A_Id":59511558,"CreationDate":"2019-12-28T13:53:00.000","Title":"Use Youtube-dl in python script using import youtube_dl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a sample project using Django but when I opened the file in IDE it shows error for importing path and include from django.urls module. \nThe error statement is Cannot find reference 'include' in '__init__.py' and Cannot find reference 'path' in '__init__.py'","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":328,"Q_Id":59511708,"Users Score":1,"Answer":"you must use manage.py script to run your project in the right way","Q_Score":0,"Tags":"python,django","A_Id":59517359,"CreationDate":"2019-12-28T14:19:00.000","Title":"Getting error in importing path and include from django.urls","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have created a sample project using Django but when I opened the file in IDE it shows error for importing path and include from django.urls module. \nThe error statement is Cannot find reference 'include' in '__init__.py' and Cannot find reference 'path' in '__init__.py'","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":328,"Q_Id":59511708,"Users Score":0,"Answer":"If IDE is Pycharm, try to add source directory in File -> Settings -> Project -> Project structure.","Q_Score":0,"Tags":"python,django","A_Id":59514030,"CreationDate":"2019-12-28T14:19:00.000","Title":"Getting error in importing path and include from django.urls","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have made a Python program that webscrapes IMDB with Beautifulsoup to make a mySQL database with tables of all the top rated movies in the different categories. So far so good. My problem is that I am doing this from Norway, and many of the movie titles are translated to Norwegian. For example, in the top list of IMDB opened from a Norwegian IP adress, \"The Shawshank Redemption\" is translated to \"Frihetens Regn\". I want all the titles in English. Are there maybe some free VPNs that you can activate from Python and that works with Beautifulsoup? Or do anyone have another solution to this?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":7622,"Q_Id":59511919,"Users Score":2,"Answer":"I agree that using proxies will work better rather than using a vpn. \nHowever, don't go with a free proxy, if you want results. If it's something you can invest in, get a decent paid provider, otherwise most likely nothing good will come out of this, as you will constantly get blocked.","Q_Score":2,"Tags":"python,web-scraping,beautifulsoup,ip,vpn","A_Id":59613310,"CreationDate":"2019-12-28T14:46:00.000","Title":"How to webscrape with VPN in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am attempting to verify version of my Sklearn to verify the proper installation, earlier I was having an issue where I had to change my registry value of Computer\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\FileSystem@LongPathEnabled value to 1.\nThen I was able to install the files how ever, now when I attempt to check the version of my skilearn I get the following:\nTraceback (most recent call last):\n  File \"C:\/Users\/terry\/pyversions.py\", line 11, in <module>\n    import sklearn\n  File \"C:\\Users\\terry\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\sklearn\\__init__.py\", line 74, in <module>\n    from .base import clone\n  File \"C:\\Users\\terry\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\sklearn\\base.py\", line 20, in <module>\n    from .utils import _IS_32BIT\n  File \"C:\\Users\\terry\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\sklearn\\utils\\__init__.py\", line 25, in <module>\n    from .fixes import np_version\n  File \"C:\\Users\\terry\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\sklearn\\utils\\fixes.py\", line 18, in <module>\n    import scipy.stats\n  File \"C:\\Users\\terry\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\scipy\\stats\\__init__.py\", line 384, in <module>\n    from .stats import *\n  File \"C:\\Users\\terry\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\scipy\\stats\\stats.py\", line 179, in <module>\n    from scipy.spatial.distance import cdist\n  File \"C:\\Users\\terry\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\scipy\\spatial\\__init__.py\", line 102, in <module>\n    from ._procrustes import procrustes\n  File \"C:\\Users\\terry\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\scipy\\spatial\\_procrustes.py\", line 11, in <module>\n    from scipy.linalg import orthogonal_procrustes\n  File \"C:\\Users\\terry\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\scipy\\linalg\\__init__.py\", line 195, in <module>\n    from .misc import *\n  File \"C:\\Users\\terry\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\scipy\\linalg\\misc.py\", line 5, in <module>\n    from .blas import get_blas_funcs\n  File \"C:\\Users\\terry\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\scipy\\linalg\\blas.py\", line 215, in <module>\n    from scipy.linalg import _fblas\nImportError: DLL load failed: The specified module could not be found.\nMy versions are as follows:\nPython: 3.7.6 (tags\/v3.7.6:43364a7ae0, Dec 19 2019, 01:54:44) [MSC v.1916 64 bit (AMD64)]\nscipy: 1.4.1\nnumpy: 1.18.0\nmatplotlib: 3.1.2\npandas: 0.25.3\nPlease what do I need to do to fix my errors?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":59512003,"Users Score":0,"Answer":"I am leaving this up to help others, I found the solution, had to unistall completely, reinstall and changing the reg file to allow long path download may have played a role in the beginning.","Q_Score":0,"Tags":"python,scikit-learn,scipy","A_Id":59512325,"CreationDate":"2019-12-28T14:59:00.000","Title":"Skilearn ImportError: DLL load failed: The specified module could not be found","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A friend said he was able to get multithreading in python (with Anaconda's default interpreter, probably cpython?) to utilise all cores on Google Cloud vCPUs. However, ordinarily, multithreading in python is limited to a single core on local machines. \nIs this possible? Does this have something to do with the way vCPUs share memory? I assumed that a vCPU looks like a logical core to the OS and the same GIL restrictions would apply.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1751,"Q_Id":59513336,"Users Score":-1,"Answer":"On Compute Engine, each virtual CPU (vCPU) is implemented as a single hardware hyper-thread on one of the available CPU Platforms. On Intel Xeon processors, Intel Hyper-Threading Technology allows multiple application threads to run on each physical processor core. You configure your Compute Engine virtual machine instances with one or more of these hyper-threads as vCPUs. The machine type specifies the number of vCPUs that your instance has.\nYou can identify the specific CPU platform for your instance using one of the following options:\n\nSee what CPU platforms are available in each of the available regions and zones.\nUse the compute.instances.get a method to obtain the CPU platform property for one of your existing instances.\nOn Linux instances, run cat \/proc\/cpuinfo.\n\nIf you want to change the CPU platform for your instance, you can specify a minimum CPU platform.","Q_Score":1,"Tags":"python,multithreading,gil","A_Id":59513395,"CreationDate":"2019-12-28T17:39:00.000","Title":"Does Multithreading work on Google Cloud CPU instances?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to build a client-Server Application where client is an android device and server is a windows Pc.it would be easy to do socket programming in java for building the complete application.At first, I tried to build the server side completely in python because of the image classifier I wrote in python. but it got me into problems when I started working on the socket.Now, I want to use python trained model in java.\nplease help me out.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":59514643,"Users Score":0,"Answer":"python trained model server serve http api ,accept the image , return classification result","Q_Score":0,"Tags":"java,python,android,sockets,tensorflow","A_Id":59518465,"CreationDate":"2019-12-28T20:33:00.000","Title":"How can i train a Image classifier model with tensorflow in Python and use the trained model in Java application?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am not able to run the command $ sudo ~\/mininet\/examples\/miniedit.py  in mininet.When I type that command to use miniedit the output comes as Traceback (most recent call last):\n  File \".\/mininet\/examples\/miniedit.py\", line 63, in \n    from mininet.log import info, debug, warn, setLogLevel\nImportError: No module named mininet.log","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2093,"Q_Id":59517716,"Users Score":0,"Answer":"you have to execute miniedit.py  from remote terminal \"that has visualization\" using ssh .","Q_Score":1,"Tags":"python,pip,sdn,mininet","A_Id":59662070,"CreationDate":"2019-12-29T07:55:00.000","Title":"How to use miniedit in mininet?. Can anyone suggest the 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":"Why do we need socket despite of request library in python?\nIf we wanna socket to connect to other server so what is request library for?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":43,"Q_Id":59518614,"Users Score":3,"Answer":"Request is a higher level API for handling HTTP requests (which uses socket internally). There are dozens of other network protocols not covered by it. Of course, you could handle HTTP by using socket directly, but unless you have an extremely good reason to do so, you'd just be reinventing the wheel.","Q_Score":1,"Tags":"python,socket.io,request","A_Id":59518647,"CreationDate":"2019-12-29T10:34:00.000","Title":"When do we need socket and when do we need request?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why do we need socket despite of request library in python?\nIf we wanna socket to connect to other server so what is request library for?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":59518614,"Users Score":2,"Answer":"Requests is a Python HTTP library, whereas sockets are used for sending or receiving data on a computer network. HTTP is an application layer protocol that specifies how request and replies from client and server should be made. In socket programming, you make connection by specifying destination IP\/Port and send your data to remote host.","Q_Score":1,"Tags":"python,socket.io,request","A_Id":59518810,"CreationDate":"2019-12-29T10:34:00.000","Title":"When do we need socket and when do we need request?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know there are thousands of similar topics but my pip command has suddenly stopped to work and, despite all my researchs, I can't figure out why. It has been a while since I last used pip and surprisingly my computer doesn't recognize the command anymore. I reinstalled pip and the prompt tells me that the PATH variable is not correctly updated. So I update it but that doesn't solve the problem, the prompt still tells me the PATH variable is not updated. I've tried uninstalling and reinstalling python and pip and nothing works.\nIn my environment variables, I have a user variable named PATH and a system variable named PATH, both of them have the value :\nC:\\Users\\mertz\\AppData\\Local\\Programs\\Python\\Python38\\Scripts\\\nThe user variable was already written by itself and I had to write the system variable myself.\nWhen I'm installing pip I get this warning : \n\nWARNING: The scripts pip.exe, pip3.6.exe and pip3.exe are installed in 'C:\\Users\\mertz\\AppData\\Local\\Programs\\Python\\Python36-32\\Scripts' which is not on PATH.\n    Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\n\nAnd when I type pip in the command prompt, it tells me that pip is not recognized.\nWhat did I do wrong ?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13307,"Q_Id":59519317,"Users Score":0,"Answer":"I had a similar problem, at one time: I could only use administrative privileges to use python cmd or pip easy_install.\nPLEASE follow these procedures:\n\nGet to your environmental variables by pressing window + r and type-in, sysdm.cpl and click ok.\nCopy the pip link directory to the script folder in python,\nbut first check for pip, pip3, easy_easy, etc. \nIf it doesn't contain pip, you have to uninstall python and delete the folder, and then reinstall python.\n\ni.e \n\nC:\\Users\\mickeymouse\\AppData\\Local\\Programs\\Python\\Python38-32\\Scripts. \n\n\nYou will see user variables and system variables.\n(user variables are applied for only that user's account; system variable are applied to all accounts on the pc).\n\nCreate a path for both, then restart cmd.","Q_Score":2,"Tags":"python,path,pip","A_Id":59519548,"CreationDate":"2019-12-29T12:16:00.000","Title":"Unable to update PATH variable for pip on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"We need to analyze an audio file so that we'll get it's properties like frequencies and amplitudes as float array ( not as curve or waveform ).\nIs there any library in programming langues, for example any function which gets sound file and sample rate as input and returns an array of floats representing its frequencies and amplitudes based on sample rate.\nOr any even software giving us such results.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":72,"Q_Id":59520487,"Users Score":1,"Answer":"very easy! use GetSpectrumData and GetOutputData in unity on audioSource component and based on the current time of AS it will give you float array","Q_Score":1,"Tags":"python,audio,signal-processing,frequency,frequency-analysis","A_Id":59520910,"CreationDate":"2019-12-29T14:56:00.000","Title":"Get audio frequencies and amplitudes as float array","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm given a TFile that contains two TTree objects, which contain track\/tower pT, eta and phi, divided by events. My goals is to extract each track and tower in the event and then cluster whole event using the FastJet package. Now, if I'm doing this task using pure ROOT my analysis takes 30 minutes at max (with ~100 GB TFile). In the meanwhile, uproot will process only 10,000 events in this time limit... \nIt is apparent that I'm doing something wrongly, so I wanted to ask, what would be the proper way to access track-by-track information to get the same speed as in ROOT?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":59520611,"Users Score":1,"Answer":"Uproot gets its efficiency from operating on many events per Python function call. The FastJet interface, last time I checked, would only accept one particle at a time: a Python function call for every particle in every event. Without even profiling it, I'd I suspect that this is the bottleneck.\nThere's another library called pyjet that improves upon this by feeding FastJet a whole event at a time. All the particles in one event are put into a large, contiguous NumPy array. Then, at least, there's only one Python function call per event.\nTo do multiple events per array would require jagged arrays (to indicate where one event stops and the next event begins). There have been some plans to link Awkward Array to FastJet to supply this functionality, but for now, pyjet is the best you can do. If you have many particles per event, like hundreds, this might be okay.","Q_Score":1,"Tags":"python,numpy,uproot","A_Id":59521505,"CreationDate":"2019-12-29T15:13:00.000","Title":"How to efficiently retrieve tracks in uproot?","Data Science and Machine Learning":0,"Database and SQL":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 today Python 3.8.1 (i had 3.7.* months ago, but don\u00b4t use it anymore) and I tried to write new code, but I have problems to import modules like matplotlib and so on. It will always mark the module name yellow and says: \n\nunresolved import \u2018matplotlib' Python(unresolved-import)\n\nI checked if python is in the PATH included, I installed\/reinstalled the matplotlib module but nothing works. I am using Win 10 64Bit, Python 3.8.1 64Bit and VS Code.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":59520794,"Users Score":0,"Answer":"I solved the problem by uninstalling python and deleting all existing files from python and installing a new clean version of the newest version of python. After this i used pip to install all required modules to code.\nThanks for the help!","Q_Score":0,"Tags":"python,import,visual-studio-code","A_Id":59521164,"CreationDate":"2019-12-29T15:39:00.000","Title":"Why does python give me an error when i am importing modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When flask g keep data on one request and another request follow almost simultaneously (race condition). Will flask g be replaced by new flask g?. And how i can handle if this situation happen. Thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":135,"Q_Id":59521098,"Users Score":0,"Answer":"This is no problem. In flask every simultaneous request will be handled in a separate process. There will be multiple g at a given time (depending on how you configure gunicorn) but every process will have it's own instance.","Q_Score":0,"Tags":"python,flask,gunicorn,race-condition","A_Id":59522177,"CreationDate":"2019-12-29T16:15:00.000","Title":"Can flask g be used with gunicorn?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm building a web-app with Flask and have an philosophical\/architecture related question for all you with more experience than I.\nThe user enters some basic search criteria in my app, my app then queries multiple 3rd-party APIs for information related to the criteria and aggregates the results. \nUltimately, my app will send the user a bi-weekly email with an HTML-formatted table containing the information gathered by the API queries (as rows in the table). The information doesn't need to be stored long term, it becomes obsolete after a week or so there is really no point in storing it. The 3rd party APIs will always be queried anew each week or so. \nInitially I was thinking that I would need to maintain a database table for each user which would aggregate and store the results of their specific API queries. I was planning to create the contents of the emailed table from the rows in the database. \nI'm now wondering if there is a way to accomplish all of this without using a database to temporarily  store the results of the API queries before emailing.\nMy question:  What is the most efficient or optimal means for accomplishing what I'm trying to do? Is it possible to do this without a database for storing the results of the API queries?\nTo recap here was the sequence of operation for the initial concept:\nApp queries API for info --> App stores data returned by APIs in DB Table --> App puts info from DB table into formatted HTML table --> App sends HTML table to user in email --> The next time the App queries the APIs the DB tables would be over-written.\nFor context here are the different packages I'm using:\nFlask 1.1.1\nwerkzeug 0.15.5\nApplication server for both development and production.\ngunicorn 19.9.0\nTesting and static analysis.\npytest 5.1.0\npytest-cov 2.7.1\nmock 3.0.5\nflake8 3.7.8\nData and workers.\npsycopg2-binary 2.8.3\nFlask-SQLAlchemy 2.4.0\nSQLAlchemy 1.3.7\nalembic 1.0.11\nredis 3.3.7\ncelery 4.3.0\nForms.\nFlask-WTF 0.14.2\nWTForms-Components 0.10.4\nWTForms-Alchemy 0.16.9\nPayments.\nstripe 2.35.0\nUtils.\nfaker 2.0.0\nExtensions.\nflask-debugtoolbar 0.10.1\nFlask-Mail 0.9.1\nFlask-Login 0.4.1\nFlask-Limiter 1.0.1\nFlask-Babel 0.12.2\nFlask-Static-Digest 0.1.2","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":59521728,"Users Score":0,"Answer":"If you don't need it in a DB, it seems like you could work with the pandas module, and just use it as a DataFrame. The dataframe offers a lot of the easy manipulation of a database without having to actually use a database.","Q_Score":0,"Tags":"python,database,flask,architecture,web-development-server","A_Id":59521810,"CreationDate":"2019-12-29T17:34:00.000","Title":"Can I avoid using a database in this scenario?","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":"Being new to django rest framework , I often get puzzled as what exactly is the use of viewset when we can overwrite crud methods in serializers too .Another thing is that how is overwriting crud methods in serializers different from overwriting crud  methods in viewsets ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":57,"Q_Id":59523199,"Users Score":1,"Answer":"Technically, you can overwrite whatever you like wherever you like. The whole thing is just a convention.\nThe main idea is separation of concerns.\nWhen you overwrite your views it's for the purpose of pre-processing the incoming request.\nWhen you overwrite your serializers - it's because you want to change how the incoming data is serialized to be stored in your system (or how it is deserialized to be shown to the front-end).","Q_Score":0,"Tags":"python,django,django-rest-framework","A_Id":59528427,"CreationDate":"2019-12-29T20:55:00.000","Title":"use of viewsets in django rest framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I made Pong using PyGame and I want to use genetic algorithms to have an AI learn to play the game. I want it to only know the location of its paddle and the ball and controls. I just don't know how to have the AI move the paddle on its own. I don't want to do like: \"If the ball is above you, go up.\" I want it to just try random stuff until it learns what to do.\nSo my question is, how do I get the AI to try controls and see what works?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":945,"Q_Id":59525215,"Users Score":0,"Answer":"So you'd want as the AI input the position of the paddle, and the position of the ball. The AI output is two boolean output whether the AI should press up or down button on the next simulation step.\nI'd also suggest adding another input value, the ball's velocity. Otherwise, you would've likely needed to add another input which is the location of the ball in the previous simulation step, and a much more complicated middle layer for the AI to learn the concept of velocity.","Q_Score":2,"Tags":"python,machine-learning,pygame,artificial-intelligence,genetic-algorithm","A_Id":59525463,"CreationDate":"2019-12-30T03:00:00.000","Title":"How to give an AI controls in a video game?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pygame project that crashes whenever I call pygame.mixer.music.load('.\/sounds\/background music.mp3').\nIt was working perfectly fine yesterday, please note that I have made no changes to the code.\nAny advice would be appreciated as I have tried everything that I could think of to fix this issue.\nI checked my pygame folder and there does exist a \"libmpg123.dll\" file.\n\nTraceback (most recent call last):\n    File \"C:\/Users\/ngtaw\/PycharmProjects\/snakeversus\/snakeversus.py\", line 291, in \n      pygame.mixer.music.load('.\/sounds\/background music.mp3')\n  pygame.error: Failed loading libmpg123.dll: Attempt to access invalid address.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":486,"Q_Id":59525541,"Users Score":0,"Answer":"Managed to solve this by updating pygame from pygame 1.9.6 to pygame 2.0.0.dev6.","Q_Score":1,"Tags":"python,pygame","A_Id":59526905,"CreationDate":"2019-12-30T03:53:00.000","Title":"I get an error even though no changes was made to my project. \"Attempt to access invalid address\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to get 50 latest data (based on timestamp) from BigTable.\nI get the data using read_row and filter using CellsRowLimitFilter(50). But it didn't return the latest data. It seems the data didn't sorted based on timestamp? how to get the latest data?\nThank you for your help.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2096,"Q_Id":59527152,"Users Score":1,"Answer":"Turns out the problem was on the schema. It wasn't designed for timeseries data. I should have create the rowkey with id#reverse_timestamp and the data will be sorted from the latest. Now I can use CellsRowLimitFilter(50) and get 50 latest data.","Q_Score":0,"Tags":"python,google-cloud-bigtable,bigtable","A_Id":60200365,"CreationDate":"2019-12-30T07:27:00.000","Title":"How to get recent data from bigtable?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with Colab, I have a very large column and I want to see the possible values that are in this column.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":164,"Q_Id":59529170,"Users Score":0,"Answer":"for numeric columns use: describe()\nfor categorical columns use : value_counts()","Q_Score":0,"Tags":"python,pandas,data-analysis","A_Id":59529321,"CreationDate":"2019-12-30T10:18:00.000","Title":"How can I see the possible values on a column","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a GUI software using PyQt5 and want to connect it with MySQL to store the data. \nIn my computer, it will work fine, but what if I transfer this software to other computer who doesn't have MySQL, and if it has, then it will not have the same password as I will add in my code (using MySQL-connector)a password which I know to be used to connect my software to MySQL on my PC. \nMy question is, how to handle this problem???","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":59530440,"Users Score":2,"Answer":"If you want your database to be installed with your application and NOT shared by different users using your application, then using SQLite is a better choice than MySQL. SQLite by default uses a file that you can bundle with your app. That file contains all the database tables including the connection username\/password.","Q_Score":0,"Tags":"python,mysql,python-3.x,mysql-python","A_Id":59538866,"CreationDate":"2019-12-30T11:55:00.000","Title":"Will pyqt5 connected with MySQL work on other computers without MySQL?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If we perform value_counts function on a column of a Data Frame, it gives us a Series which contains unique values' counts.\nThe type operation gives pandas.core.series.Series as a result. My question is that what is the basic difference between a Series & a Data Frame?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":819,"Q_Id":59534544,"Users Score":2,"Answer":"You can think of Series as a column in a DataFrame while the actual DataFrame is the table if you think of it in terms of sql","Q_Score":1,"Tags":"python,pandas,dataframe,series","A_Id":59534703,"CreationDate":"2019-12-30T17:22:00.000","Title":"Difference between Series & Data Frame","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using implicit library in python to implement a recommendation system. The model is ready, but the problem is my application is java based(spring boot). Now I've the model, matrices and everything setup in python. Basically the model has a offline component, where i perform the data feeding and matrix factorization stuff. After that I've a python method which returns the recommendation for a user. \nThe offline component will run once in a month. For the whole month I need to store the factorized matrix in some place and whenever required I need to call my python method from REST endpoint, which will utilize the stored matrix and return some results.\nSo I've two questions.\n1. My factorized matrix is a numpy.sparse_matrix. How can I store it, so that it will be reused again and again?\n2. How do i invoke a python method in java endpoint which will utilize the methods from implicit library then do the calculation based on the matrix and return the result?   \nAny insight would be appreciated. Thanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1206,"Q_Id":59534772,"Users Score":1,"Answer":"A recommended way would be to convert your Python code in a REST microservice and then use that in your Java program.","Q_Score":0,"Tags":"java,python,rest,spring-boot","A_Id":59534816,"CreationDate":"2019-12-30T17:41:00.000","Title":"How to call a python program from spring boot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can anyone tell me what is the difference between the pearson correlation method and the normal corr() method? I expect it to be the same output, is that right?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":59546892,"Users Score":0,"Answer":"no difference, if method='pearson'","Q_Score":0,"Tags":"python","A_Id":59546917,"CreationDate":"2019-12-31T17:17:00.000","Title":"Python data correlation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Running cplex\/pyomo the solver found a solution and it reported saved somewhere though I closed before taking note, can't find over the web where is it stored.\nrunning windows, anyone?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":174,"Q_Id":59547875,"Users Score":2,"Answer":"I don't know how exactly pyomo invokes CPLEX to store solutions on disk. The default behavior of CPLEX is to store solutions in the current working directory. The solution file will have a suffix of either .sol or .mst.","Q_Score":0,"Tags":"python,cplex,pyomo","A_Id":59607635,"CreationDate":"2019-12-31T19:34:00.000","Title":"What is the default location for saved cplex solutions","Data Science and Machine Learning":0,"Database and SQL":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 download PIP on windows and I apparently have to set up a path for python. It seems that I have the define the path within has the \"AppData\" folder, which I can't find.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":735,"Q_Id":59548953,"Users Score":0,"Answer":"App data file is hidden by default, it is normal so users cannot accidentally make changes important files, you can uncheck the hide files checkbox, as well as uncheck the hide system files","Q_Score":0,"Tags":"python,pip","A_Id":59549106,"CreationDate":"2019-12-31T22:47:00.000","Title":"Can't find the AppData file in order to set up properly the Python Set Path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my list, I had a mix of number and strings and the sort() doesn't not work on it, unfortunately. Any look around for this? \nPlease help.\nmyList = ['rohit', 'mandiwal', 32, 7701]\nTypeError: '<' not supported between instances of 'int' and 'str'","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":107,"Q_Id":59549478,"Users Score":1,"Answer":"If you want the list to sorted  alphabetically by treating each element as a string, then use sorted(myList, key=str).  The basic idea is to use a key function to transform each list element into a value whose type supports comparison while the transformation enables the required sort ordering.","Q_Score":0,"Tags":"python","A_Id":59549579,"CreationDate":"2020-01-01T01:29:00.000","Title":"Python : How to sort if the list contains the number and strings at the same time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This question has many related questions, but none answers what I want to know:\nI usually work like this:\n\ninstall python 3.5+\nsudo apt install virtualenv\nvirtualenv -p \/usr\/bin\/python3.* bla\n. bla\/bin\/activate\npip install & run python\n\nThis seems to work perfectly, and I've done so also with python2.7. Is there a difference between using apt install virtualenv and apt install python3-virtualenv?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1470,"Q_Id":59551286,"Users Score":1,"Answer":"apt install virtualenv shall install python3-virtualenv as well I am pretty sure about that but I think that depends on what appears when you enter python on your terminal it is supposed to be version dependent.","Q_Score":1,"Tags":"python,ubuntu,virtualenv,apt","A_Id":59551372,"CreationDate":"2020-01-01T09:23:00.000","Title":"apt install virtualenv vs apt install python3-virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"This question has many related questions, but none answers what I want to know:\nI usually work like this:\n\ninstall python 3.5+\nsudo apt install virtualenv\nvirtualenv -p \/usr\/bin\/python3.* bla\n. bla\/bin\/activate\npip install & run python\n\nThis seems to work perfectly, and I've done so also with python2.7. Is there a difference between using apt install virtualenv and apt install python3-virtualenv?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1470,"Q_Id":59551286,"Users Score":1,"Answer":"After some searching, I can say that package virtulenv is an overlay over python-virtualenv(Python 2 Virtual Env creator) and python3-virtualenv(Python 3 virtual Env creator). It is essential for command virtualenv to work (the one you type in terminal). Now, this command can internally use either of 2 versions provided by python.\nTherefore, if you do sudo apt install virtualenv it automatically installs python3-virtualenv along with it. However, you can install virtualenv with python2-virtualenv as well. \nSo, difference is that virtualenv package is the one which provides command line options(invokable via terminal) while python3-virtualenv(for python 3) does actual job of creating environment and is replaceable by python-virtualenv(for python 2).","Q_Score":1,"Tags":"python,ubuntu,virtualenv,apt","A_Id":59552020,"CreationDate":"2020-01-01T09:23:00.000","Title":"apt install virtualenv vs apt install python3-virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"how can I open the browser page without using chromedriver, for example, I want data to be saved in the main browser used by the user when executing the program, when data is not saved with the use of chromedriver.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":59551371,"Users Score":0,"Answer":"Use profile,\nfrom selenium import webdriver\noptions = webdriver.ChromeOptions() \noptions.add_argument(\"user-data-dir=C:\\Path\") #Path to your chrome profile\nw = webdriver.Chrome(executable_path=\"C:\\Users\\chromedriver.exe\", chrome_options=options)","Q_Score":0,"Tags":"python-3.x,selenium","A_Id":59554716,"CreationDate":"2020-01-01T09:37:00.000","Title":"another way to open the browser using the selenium module Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to upload files to Google Drive, but the < input type = \"file\"> tag does not exist in HTML. File selection window opens How can I select the file I want in this section?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":59553820,"Users Score":0,"Answer":"Pyautogui like so,\nhover over your position You want to click\nget coordinates\nImport pyautogui\nPyautogui.position()\nUse those coordinates to click\nPyautogui.click(x,y)","Q_Score":1,"Tags":"python,selenium","A_Id":59554690,"CreationDate":"2020-01-01T15:43:00.000","Title":"How to upload selected file with Selenium in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am currently working on a Django project with around 30 models and there are lots of relations(For example, foreign key relations) between the models.\nMy doubt is \"After 6 months, let's say I want to add a new field(s) in one of the model\/table(s) in models.py, and make migrations, the new migration files will get created without affecting the initial migration files which were created 6 months ago.\"\nWill the relations be maintained after adding new columns in different tables? (or) do I have to go to pgadmin console and tweak them accordingly?\nOne way is to erase all the migrations and start fresh, but this is not recommended often especially if there is production data (or) there are frequent changes in the database schema.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2209,"Q_Id":59553858,"Users Score":1,"Answer":"If you don't change Django version, adding new fields on models will not create any problem, even after many years. But, there are some situations this might create problems. For example, if Django is updated and you have installed the latest version.","Q_Score":1,"Tags":"django,python-3.x,foreign-keys,pgadmin-4,rdbms","A_Id":59554133,"CreationDate":"2020-01-01T15:48:00.000","Title":"Adding new field in Django model","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I hope you are doing great this new year,\nI am creating a GUI program (Python3 Tkinter) which displays the output of another python script into a big entry.\nSituation:\nMy GUI has only 1 button which execute this command:\npython external_python_script.py -h\nHowever I want the whole output of this command execution to be displayed into an entry, and not into the CMD.\nSo far this is my solution, but not effective:\ncommand_textbox = os.system(python external_python_script.py -h) #simply execute the code in brackets\nscript_output.insert('1.0',command_textbox) #the whole output of the script will be displayed in this entry\nWhat happened when I did this?\nIn the GUI program, when I pressed the button, into the Entry it is displayed only this 0\nAny help is greatly appreciated, thank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":93,"Q_Id":59554357,"Users Score":0,"Answer":"Thank you guys for helping me, Subprocess is the solution. So I put only these 2 lines of code and I got the solution I wanted:\nfinal_command = subprocess.run(command, capture_output=True)\noutput_box.insert('1.0',final_command)","Q_Score":0,"Tags":"python,python-3.x,user-interface,tkinter","A_Id":59567045,"CreationDate":"2020-01-01T16:55:00.000","Title":"Why the output of an external Python Script isn't displaying into my Python Tkinter GUI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on lake ice thickness in the northern hemisphere. My final data set is an xarray with dimensions [365,360,720] - (days,lat,lon) and a data varibale 'icethickness'. This data variable has 3 kinds of values. A finite value for ice thickness, zero for water and 'nan' for oceans.\nI want to convert all the finite values of this xarray to 1 and keep the zeros and nan as they are.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":73,"Q_Id":59554967,"Users Score":1,"Answer":"You can use the xr.where function.\nxr.where(data > 0, 1, data)","Q_Score":0,"Tags":"gis,python-xarray","A_Id":59571636,"CreationDate":"2020-01-01T18:18:00.000","Title":"Replace finite values with '1' in a 3 dimension xarray","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list of n functions: f1(),f2()..fn() etc and need to select n randomly and apply one\/more of those in sequence to an object. What's the Pythonic way to do this?  \nThe use-case is to generate augmentations for images (for training an ML model) from a set of images, and apply (one\/more) augmentation functions to an image.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":45,"Q_Id":59555146,"Users Score":1,"Answer":"How about this functools.reduce(lambda acc, f: f(acc), random.sample(funs, n), image)?","Q_Score":0,"Tags":"python,function","A_Id":59555564,"CreationDate":"2020-01-01T18:42:00.000","Title":"Randomly select one\/more functions from collection and apply combinations","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm beginner to django and got quite confused that what is the difference between register out models by admin.site.register and makemigrations in both cases we're mapping our tables to database, if i'm wrong kindly correct me.\nthank you","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":236,"Q_Id":59555442,"Users Score":1,"Answer":"They're not related at all.\nadmin.site.register(MyModel) just makes instances of that model editable via the admin page. Without it they won't appear on the admin.\nmakemigrations just auto-generates some Python files, inside the migrations directory of each app. These files are like a description, in Python code, of what changes you have made to your models. They do nothing in themselves, until you run migrate, which is the only command here which actually touches your database schema - it updates the schema so that it matches what's in your migration files.","Q_Score":0,"Tags":"python,django,interface,admin","A_Id":59555487,"CreationDate":"2020-01-01T19:24:00.000","Title":"Difference between admin.site.register and makemigrations in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm beginner to django and got quite confused that what is the difference between register out models by admin.site.register and makemigrations in both cases we're mapping our tables to database, if i'm wrong kindly correct me.\nthank you","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":236,"Q_Id":59555442,"Users Score":0,"Answer":"admin.site.register : This line of code \"create\" an admin interface for you when excecuted. This interface is intended for admin users.\nmakemigrations : This is a command to \"manage\" the changes of your model\/database.","Q_Score":0,"Tags":"python,django,interface,admin","A_Id":59555599,"CreationDate":"2020-01-01T19:24:00.000","Title":"Difference between admin.site.register and makemigrations in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I pulled a (seemingly popular, supported by Jupyter) jupyter-tensorflow Docker image using\ndocker pull jupyter\/tensorflow-notebook\nand started it successfully with \ndocker run -p 8888:8888 jupyter\/tensorflow-notebook\nHowever, upon navigating to http:\/\/127.0.0.1:8888\/?token=177a...., I am prompted for a password or token (despite the token already being present in the URL). \nI know of no password to use, and the token 177a... does not work. \nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1754,"Q_Id":59556013,"Users Score":5,"Answer":"The answer turned out to be quite easy: there was an other Jupyter notebook server I wasn't aware of running. Closing it did the trick.","Q_Score":0,"Tags":"python,docker,jupyter-notebook","A_Id":59556331,"CreationDate":"2020-01-01T20:51:00.000","Title":"Invalid token when trying to login into Jupyter notebook with Docker jupyter\/tensorflow-notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to install flair. It is throwing below error when executing below command:\npip install flair\nERROR: Packages installed from PyPI cannot depend on packages which are not also hosted on PyPI.\ntiny-tokenizer depends on SudachiDict_core@ https:\/\/object-storage.tyo2.conoha.io\/v1\/nc_2520839e1f9641b08211a5c85243124a\/sudachi\/SudachiDict_core-20190927.tar.gz\nI thought installing this package explicitly might fix the error but it doesn't. The error remains same. \nThe installed version of SudachiDict-core is below:\nSudachiDict-core   0.0.0\nBelow is the Environment:\n\nOS: Windows 10 \nPython: 3.6 (64 bit)\n\nAny hint is appreciated. Thank you!\nNote: \n\nFirst hurdle when installing flair was torch package. It was resolved simply when torch package is installed. The error looked like below:\nERROR: Could not find a version that satisfies the requirement torch>=1.1.0 (from flair) (from verERROR: No matching distribution found for torch>=1.1.0 (from flair)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2520,"Q_Id":59559294,"Users Score":0,"Answer":"It is strange running below command solved the problem.\npip install flair==0.4.3\nI assume that the problem is in a latest version 0.4.4 (and its dependencies). \nNote: I had torch==1.1.0 package already installed.","Q_Score":7,"Tags":"python,python-3.x,pip,flair","A_Id":59560165,"CreationDate":"2020-01-02T06:42:00.000","Title":"Error in installing python package Flair, about a dependent package not hosted in PyPI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am following the Obey the testing goat book and I try to automate some shell command server side using Fabric3\nI have an issue concerning thefab deploy:host=yyy@xxx\nyyy being username\nxxx being folder name of my domain name\nWhenever I run this command, I get Login password for 'xxx': and it just never seem to work even though I enter the correct one\nHere is what I did so far:\n1- did ssh-keygen locally and on the server\n2- added on local side a file named authorized_keys which contains id_rsa.pub generated on server side\n3- did the same operation on server side  \nBasically, both sides have a file named authorized_keys \nLocal side (resp. server side) have authorized_keys which is just a copy of id_rsa.pub generated by the ssh-keygen command on server side (resp. local side)\nCould anyone review what I did so far and tell me if I DID understand the problem (or not), and what should I do to resolve this issue\nThank vm","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":59561008,"Users Score":0,"Answer":"I have no clue how I managed to make it work...\nBasically, I deleted the old public key that I had linked to my user in my digitalocean droplet's settings, and generated a new one, on the local terminal using ssh-keygen, then I did the basic configuration by copying this public key server-side on following path ~\/.ssh\/authorized_keys ...\nNow, it does still asks for my password, but does proceed to the execution of my fabfile script after correct password input\nI'm thinking that the 'proper' way to setup a ssh with one's user is to do it manually through command-line ?\nAnyway, problem 'solved'","Q_Score":0,"Tags":"python,django,server,automated-tests,fabric","A_Id":59592322,"CreationDate":"2020-01-02T09:30:00.000","Title":"fabric3 : Intempestive Login for password when trying to run fab 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":1},{"Question":"i am trying to make a program were a user will input his phone. I want him to be able to write only numbers and if he writes a letter then it will either delete the character he just wrote or \"lock\" his keyboard to only numbers. I am currently using a try\/except in order to work but still i want to know if there is a library or a function that allows me to give access to only certain keys to the user.\nThank you in advance!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":333,"Q_Id":59561054,"Users Score":0,"Answer":"You cannot \"restrict\" the keys a user can type with the input() function itself. You could (as far as I can tell - I didn't try actually) get this result on unix-like systems using the curses module, but you'll need some external lib to make it work on Windows. And in all cases, it will requires much more coding (curses is not exactly a simple, modern UI lib).\nAs a side note, a phone number can contains non numeric characters (think of international phone numbers) ;-)","Q_Score":0,"Tags":"python,input,numbers","A_Id":59561495,"CreationDate":"2020-01-02T09:33:00.000","Title":"I want to take an input from a user but receive only numbers.in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have read that I can read pickles that were dumped in python 2.7 in python 3 using\ncontent = pickle.load(o, encoding='latin1')\nObviously, I can read pickles that were dumped in python 3 using \ncontent = pickle.load(o)\n\n\nMy problem is, I can't know the source of my pickle. It could be either one.\nHow can I test which type of pickle I am trying to read in order to use the correct method?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":72,"Q_Id":59562586,"Users Score":-1,"Answer":"use if else:\ntry to do normal load without encoding and do some reads, if success proceed else load with encoding='latin1'","Q_Score":2,"Tags":"python,pickle","A_Id":59562633,"CreationDate":"2020-01-02T11:29:00.000","Title":"How to read pickle that was dupmed in either python 2.7 or 3, in python 3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"we are training machine learning models offline and persist them in python pickle-files.\nWe were wondering about the best way to embedd those pickeled-models into a stream (e.g. sensorInputStream > PredictionJob > OutputStream.\nApache Flink ML seems to be the right choice to train a model with stream-data but not to reference an existing model. \nThanks for you response. \nKind Regards \nLomungo","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":825,"Q_Id":59563265,"Users Score":3,"Answer":"There are two possible solutions depending on the model You are using:\n\nPossibly the simples idea is to create external service that will call the model and return the results and then simply call the service with AsyncFunction\nUse some library, again depending on Your model to load the pre-trained model inside a ProcessFunction's open method. And then simply calling the model for each data that arrived. \n\nThe second solution has two disadvantages, first You need to have the Java version of the specific library available and the other is that You need to somehow externalize the metadata of the model if You want to be able to update it over time.","Q_Score":1,"Tags":"python,machine-learning,apache-flink,flinkml","A_Id":59563487,"CreationDate":"2020-01-02T12:21:00.000","Title":"Embedd existing ML model in apache flink","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I built a script that takes contact information from a Google sheet and updates\/inserts the contacts in SFDC. I am wondering what the default batch size might be when I am running a query to update or insert the contacts.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":883,"Q_Id":59565330,"Users Score":1,"Answer":"The default batch size is 10,000 and is the maximum you can send in a bulk request using simple_salesforce.\nFrom simple salesforce's documentation:\n\nYou can use this library to access Bulk API functions. The data element can be a list of records of any size and by default batch sizes are 10,000 records and run in parrallel concurrency mode.\n\nAlthough you can send batches of 10,000  records, Salesforce will process it 200 or 100 every 5 minutes depending on your Salesforce API version.\nFrom Salesforce's documentation:\n\nThe chunk size depends on the API version. In API version 20.0 and earlier, the chunk size is 100 records. In API version 21.0 and later, the chunk size is 200 records. There\u2019s a 5-minute limit for processing each chunk.","Q_Score":1,"Tags":"python,soql,simple-salesforce","A_Id":65842630,"CreationDate":"2020-01-02T14:51:00.000","Title":"What is the default batch size in simple salesforce?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I solved most of this assignment using Python, but not sure how to input (or even understand) the remaining information. Aren't you supposed to find the eigenvector given some eigenvalue, thus it appears in reverse in the following: \nLet the symmetric 3 \u00d7 3 matrix A be A = ((1 2 1), (2 5 0), (1 0 5))\nIf A has the following three eigenvectors, then find three corresponding eigenvalues:\nv1 = ((-5), (2), (1)); v2 = ((0), (-1), (2)); v3 = ((1), (2), (1))","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":196,"Q_Id":59568960,"Users Score":1,"Answer":"Think about the definition of an eigenvector. An eigenvector v of a linear transformation represented by matrix A is a vector that only changes in magnitude, not direction, when that linear transformation is applied to it. The scalar change in magnitude of the eigenvector is its eigenvalue. You have a linear transformation, and you've been given its eigenvectors - to find the eigenvalues, all you need to do is apply the transformation to the eigenvectors and determine by what scalar each eigenvector got scaled.","Q_Score":0,"Tags":"python,matrix,eigenvalue,eigenvector","A_Id":59569070,"CreationDate":"2020-01-02T19:29:00.000","Title":"Finding corresponding eigenvalues to a set of eigenvector","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The server currently has CentOS 6.9 with GLIBC 2.12 and tensorflow 1.14.\ntensorflow is throwing error saying that it needs GLIBC 2.15.\nNow I want to upgrade tensorflow to 2.0 but I want to know what's a working GLIBC version for tensorflow 2.0 on CentOS 6.9 before doing so.\nI didn't seem to find any source to state this compatibility issue. Does anyone here know?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":308,"Q_Id":59569722,"Users Score":0,"Answer":"Just tested and tensorflow 2.0 works fine with GLIBC 2.12.\nIt was tensorflow 1.14 that's not compatible with GLIBC 2.12.","Q_Score":0,"Tags":"python,tensorflow,python-3.6,centos6,tensorflow2.0","A_Id":59652333,"CreationDate":"2020-01-02T20:40:00.000","Title":"What's a compatible GLIBC version for tensorflow 2.0 for python3.6.8 on CentOS 6.9?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm running a application that I created using Python and KivyMD in the iPhone Simulator of Xcode. So far I do have a really bad performance. The animations, transistions, opening\/ widgets just perform very bad and laggy. It results in a delay of mouse click and instruction performance of about 1s. The app I developed is yet pretty simple, does contain several basic widgets like a button, textinput, spinners and does have a connection to a postgreSQL database. Not the functions in the app (select data from the database etc) cause the lag, it's just the performance in total.\nIs there anything that has to be set up in Xcode to make it run smooth? Already checked if I had accidentally enabled the slow-animations but didn't. Also curious if it is just the simulator or if it would also run as bad on my actual device.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":59570740,"Users Score":0,"Answer":"The iPhone simulator is runs super heavy on a system. I've experienced something similar and was able to fix it by closing applications running in the background to free up some CPU and RAM. You could also try the obvious restarting xcode.","Q_Score":0,"Tags":"python,iphone,xcode,kivy,ios-simulator","A_Id":59572249,"CreationDate":"2020-01-02T22:19:00.000","Title":"Bad Xcode iPhone simulator performance - Python Kivy app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running a application that I created using Python and KivyMD in the iPhone Simulator of Xcode. So far I do have a really bad performance. The animations, transistions, opening\/ widgets just perform very bad and laggy. It results in a delay of mouse click and instruction performance of about 1s. The app I developed is yet pretty simple, does contain several basic widgets like a button, textinput, spinners and does have a connection to a postgreSQL database. Not the functions in the app (select data from the database etc) cause the lag, it's just the performance in total.\nIs there anything that has to be set up in Xcode to make it run smooth? Already checked if I had accidentally enabled the slow-animations but didn't. Also curious if it is just the simulator or if it would also run as bad on my actual device.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":59570740,"Users Score":0,"Answer":"I've used Kivy to develop a number of iOS apps. The iPhone simulator from Xcode is just tremendously slow no matter what. Your program likely runs just fine on a physical device!","Q_Score":0,"Tags":"python,iphone,xcode,kivy,ios-simulator","A_Id":59581582,"CreationDate":"2020-01-02T22:19:00.000","Title":"Bad Xcode iPhone simulator performance - Python Kivy app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Assume you have lot of text sentences which may have (or not) similarities. Now you want to cluster similar sentences for finding centroids of each cluster. Which method is the prefered way for doing this kind of clustering? K-means with TF-IDF sounds promising. Nevertheless, are there more sophisticated algorithms or better ones? Data structure is tokenized and in a one-hot encoded format.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":59571031,"Users Score":0,"Answer":"in my view, You can use LDA(latent Dirichlet allocation, it is more flexible in comparison to other clustering techniques because of having Alpha and Beta vectors that can adjust to the contribution of each topic in a document and word in a topic. It can help if the documents are not of similar length or quality.","Q_Score":0,"Tags":"python,cluster-analysis,text-mining","A_Id":59575035,"CreationDate":"2020-01-02T22:49:00.000","Title":"Which clustering method is the standard way to go for text analytics?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just started learning TF and realized that if I create a model of a NN, and then if I were to create a seession to do something with the NN such as getting an output value given the input value,\nand then after the session close, if I were to do something else with the NN again, then create a session for that, then it re-initializes the weights into random, which makes it pointless.\nSo then is it a common practice to, say in the first session, I save the model, and then in the second session, I would load the weights do something else with the NN?\nI understand that TF is intended to be used with 1 session but when dealing with something more complex than a \"simple\" supervised classification problem, such as reinforcement learning, then I need to use the NN for various way for various reasons.\nSo coding all of these such that i can execute all the functionalities within 1 session is very tiring and confusing at times. where I would rather create 1 session each to do something with the NN. But is it a poor practice to do so?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":126,"Q_Id":59572172,"Users Score":0,"Answer":"Yes, of course this is common practice. If you're trying to work with a large net that takes hours to train, it would be totally impractical to do anything other than save weights for future use. In fact, if you're at all concerned about reproducibility of your results, you should save any noteworthy iterations of your net.","Q_Score":0,"Tags":"python,tensorflow,oop,neural-network","A_Id":59572241,"CreationDate":"2020-01-03T01:31:00.000","Title":"Is it a common practice to save and load NN models for multiple sessions in practice?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to do some ML on my computer with Python, I'm facing problem with the installation of tensorflow and I found that tensorflow could work with GPU, which is CUDA enabled. I've got a GPU Geforce gtx 1650, will tensorflow work on that.\nIf yes, then, how could I do so?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2593,"Q_Id":59572687,"Users Score":0,"Answer":"Here are the steps for installation of tensorflow:\n\nDownload and install the Visual Studio.\nInstall CUDA 10.1\nAdd lib, include and extras\/lib64 directory to the PATH variable.\nInstall cuDNN\nInstall tensorflow by pip install tensorflow","Q_Score":1,"Tags":"python,python-3.x,tensorflow","A_Id":59953057,"CreationDate":"2020-01-03T03:03:00.000","Title":"How could I run tensorflow on windows 10? I have the gpu Geforce gtx 1650. Can I run tensorflow on it? if yes, then how?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi i am new in Python.\nI've tried running this on cmd \/ powershell : python app.py \nbut it doesn't do anything.\nSince i am using python 3 i also tried: python3 app.py but it came out as \n'python3' is not recognized as an internal or external command,\noperable program or batch file.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":59572746,"Users Score":0,"Answer":"Add Python3 to your PATH.\nrun python3 -V\nIf it prints out the version.\nTest python3 app.py. Make sure you have installed required pip packages.\nelse\nsomething wrong with you python3 env\nIf nothing happens when test python3 app.py\ncheck you app.py","Q_Score":0,"Tags":"python","A_Id":59572825,"CreationDate":"2020-01-03T03:13:00.000","Title":"How do i run python flask and get the link of the localhost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Has anyone had this problem before? I get the below error message when I try to run a Python script in Spyder IDE while using NVIDIA Nsight Systems.\n\nCommError: Can't make a request to a closed comm","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":4854,"Q_Id":59573606,"Users Score":1,"Answer":"Restart the spyder app and run the program. This worked out for me","Q_Score":3,"Tags":"python,anaconda,nsight","A_Id":59979493,"CreationDate":"2020-01-03T05:28:00.000","Title":"Can't make a request to closed comm Python Spyder IDE error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Has anyone had this problem before? I get the below error message when I try to run a Python script in Spyder IDE while using NVIDIA Nsight Systems.\n\nCommError: Can't make a request to a closed comm","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":4854,"Q_Id":59573606,"Users Score":2,"Answer":"Does this error occurs when trying to generate plots? If so, I was also in such a situation and this works for me:\n\nPreference > IPython console > Graphic: Check \"Graphic Backend\" is set to Automatic\nView > Panes > Plots: Check that \"Mute inline plotting\" is checked and view your plots using this pane afterward.","Q_Score":3,"Tags":"python,anaconda,nsight","A_Id":59754708,"CreationDate":"2020-01-03T05:28:00.000","Title":"Can't make a request to closed comm Python Spyder IDE error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Has anyone had this problem before? I get the below error message when I try to run a Python script in Spyder IDE while using NVIDIA Nsight Systems.\n\nCommError: Can't make a request to a closed comm","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":4854,"Q_Id":59573606,"Users Score":1,"Answer":"Yep. Same here with Spyder 4.0. Downgrading to 3.3.6 resolves.","Q_Score":3,"Tags":"python,anaconda,nsight","A_Id":59711341,"CreationDate":"2020-01-03T05:28:00.000","Title":"Can't make a request to closed comm Python Spyder IDE error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Has anyone had this problem before? I get the below error message when I try to run a Python script in Spyder IDE while using NVIDIA Nsight Systems.\n\nCommError: Can't make a request to a closed comm","AnswerCount":4,"Available Count":4,"Score":0.1488850336,"is_accepted":false,"ViewCount":4854,"Q_Id":59573606,"Users Score":3,"Answer":"Apparently the restart kernel functionality doesn't work properly. You can stop that kernel and open up a new console, this triggers the init of a new kernel without restart the whole program (Spyder 4)","Q_Score":3,"Tags":"python,anaconda,nsight","A_Id":64241246,"CreationDate":"2020-01-03T05:28:00.000","Title":"Can't make a request to closed comm Python Spyder IDE error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is not a programming related question, but I've used python requests a lot of times. \nThe headers I usually use are:\n\naccept-encoding  \norigin  \nreferrer  \nuser-agent  \naccept-language  \naccept  \ncookie  \n\nWhile examining the requests sent to a server when performing a task such as logging in, you notice headers like:\n\nHost\ncontent-length\nTE\n\nIf I decided to add these headers to my requests, would it improve my chance of being recognized as a human since it tells the server information about the \"browser\".","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":44,"Q_Id":59574451,"Users Score":2,"Answer":"Not really.\nHost is a required header in HTTP v.1.1 protocol, so it is sent anyway. The requests module sets this header implicitly. You should not set it manually and in 99 cases of 100 you should never care about this header.\nAlthough Content-Length is an optional header, it is being used almost all the time, because it is the easiest way to tell the remote server where HTTP message actually ends. The most popular alternative is Transfer-Encoding: chunked. Any of these two headers do not disclose any information about the client, so you should not worry about them.\nFinally, by using TE header client tells the remote server the desired Transfer-Encoding format. Again, this header just negotiates data format between client and server, it will hardly improve your chances to be recognized as a human.","Q_Score":2,"Tags":"python,http,web-scraping,python-requests,http-headers","A_Id":59579490,"CreationDate":"2020-01-03T07:02:00.000","Title":"do more headers mean better chance the server thinks you're a human","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried importing numpy to carry out some array operations in Python:\nimport numpy *\nBut I got this error message:\n\nModuleNotFoundError: No module named 'numpy'\n\nWhat do i do??","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":14026,"Q_Id":59575113,"Users Score":3,"Answer":"If you are using PyCharm, open Pycharm Go to File->Setting->Project->Python Interpreter->Click on '+'->search and select required package->install package","Q_Score":1,"Tags":"python-3.x,numpy","A_Id":67939485,"CreationDate":"2020-01-03T08:08:00.000","Title":"ModuleNotFoundError: No module named 'numpy'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The information I got as follows.\n\n  Traceback (most recent call last):\n    File \"C:\\CocosCreator\\resources\\cocos2d-x\\tools\\cocos2d-console\\bin\\cocos.py\", line 983, in \n      run_plugin(command, argv, plugins)\n  File \"C:\\CocosCreator\\resources\\cocos2d-x\\tools\\cocos2d-console\\bin\\cocos.py\", line 875, in run_plugin\n    plugin.run(argv, dependencies_objects)\n  File \"C:\\CocosCreator\\resources\\cocos2d-x\\tools\\cocos2d-console\\plugins\\plugin_new\\project_new.py\", line 258, in run\n    self.parse_args(argv)\n  File \"C:\\CocosCreator\\resources\\cocos2d-x\\tools\\cocos2d-console\\plugins\\plugin_new\\project_new.py\", line 104, in parse_args\n    description=self.__class__.brief_description())\n  File \"C:\\CocosCreator\\resources\\cocos2d-x\\tools\\cocos2d-console\\plugins\\plugin_new\\project_new.py\", line 43, in brief_description\n    return MultiLanguage.get_string('NEW_BRIEF')\n  File \"C:\\CocosCreator\\resources\\cocos2d-x\\tools\\cocos2d-console\\bin\\MultiLanguage.py\", line 52, in get_string\n    fmt = cls.get_instance().get_current_string(key)\n  File \"C:\\CocosCreator\\resources\\cocos2d-x\\tools\\cocos2d-console\\bin\\MultiLanguage.py\", line 158, in get_current_string\n    ret = ret.encode(self.encoding)\n  File \"C:\\CocosCreator\\resources\\utils\\Python27\\lib\\encodings\\cp1252.py\", line 12, in encode\n    return codecs.charmap_encode(input,errors,encoding_table)\nUnicodeEncodeError: 'charmap' codec can't encode characters in position 0-8: character maps to <undefined>\n\nany one knows why this happened?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":59575574,"Users Score":0,"Answer":"Take a look at the versions of NDK and SDK, NDK. The recommended version is R17 - R19","Q_Score":1,"Tags":"python,android","A_Id":64781397,"CreationDate":"2020-01-03T08:54:00.000","Title":"cocos creator can not build for android platform","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a task in NLP to do a sentence segmentation, but I wonder, what are the advantages of using built-in NLP sentence segmentation algorithms, such as Spacy, NLTK, BERT etc, over Python '.' separator or similar algorithm?\nIs it the speed? or accuracy? or less line of code?\nHow different or strong these algorithms over the ones that we can build ourselves in Python?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":164,"Q_Id":59578665,"Users Score":1,"Answer":"The sentence segmentation routines from the NLP libraries like SpaCy, NLTK, etc. handle edge cases much better and are more robust to handling punctuation and context. For example, if you choose to split sentences by treating a '.' as a sentence boundary, how would you handle a sentence like - \"There are 0.5 liters of water in this bottle.\"?","Q_Score":1,"Tags":"python-3.x,nlp","A_Id":59582216,"CreationDate":"2020-01-03T12:28:00.000","Title":"What is the benefit of NLP sentence segmentation over Python algorithm?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If i defined a database schema where some field cannot contain a NULL field\nBut i enter a NULL value, would the validation occur on the database software?\nIf that database server where run on a different machine, would be sent through the network before receiving an error response?\nis this what the mean by Database validations and application validations?\nWhere application validations are enforced before data transmission?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":59579050,"Users Score":0,"Answer":"Application validation validate input filed value before the migrate the data in database.\nIn database validation such as datatype length (these are also validate in application side)but some validate likeunique relationship with other data and some null value are validate on database side.\nEg. like Django application unique username name validate in model label(database) validate.\nrequired filed validate on form label or say application label validate","Q_Score":0,"Tags":"python,database","A_Id":59579216,"CreationDate":"2020-01-03T12:57:00.000","Title":"Difference between applcation and database validations","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If i defined a database schema where some field cannot contain a NULL field\nBut i enter a NULL value, would the validation occur on the database software?\nIf that database server where run on a different machine, would be sent through the network before receiving an error response?\nis this what the mean by Database validations and application validations?\nWhere application validations are enforced before data transmission?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":59579050,"Users Score":0,"Answer":"It is better to have the database ensure data integrity.  After all, your application layer is not be the only way to change data -- someone could run explicit INSERT and UPDATE statements within the database.\nIn addition, the optimizers in some databases can make use of NOT NULL constraints for query optimization.","Q_Score":0,"Tags":"python,database","A_Id":59579109,"CreationDate":"2020-01-03T12:57:00.000","Title":"Difference between applcation and database validations","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I failed to phrase the question correctly online so I could not get an answer.\nWe have instance methods, static methods, and class methods.\nWhat are functions called when they don't belong to a class?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":385,"Q_Id":59587079,"Users Score":6,"Answer":"They're just called functions.\nIn python, \"function\" refers to a type of callable procedure\/block of code with its own localized namespace. \nIn contrast, \"method\" refers specifically to a kind of function that is bound to a class. We use \"instance methods\", \"static methods\", and \"class methods\" to differentiate between how those functions are bound to their respective classes, but in any case we call them methods because they are bound to their class.\nSo, we just call them functions, unless we have something more specific. If you must use some sort of qualifier, \"unbound function\" (alluding to the fact that it's not bound to any class) or \"module function\" (alluding to the fact that it's bound to the module it's defined in, though that's not a class), or even \"static function\" (but this could be confusing when trying to communicate to people who don't know the difference between functions and methods) or \"free function\" will probably work.","Q_Score":1,"Tags":"python","A_Id":59587111,"CreationDate":"2020-01-04T01:06:00.000","Title":"What are functions outside of a class called?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"GPT2 is an excellent OpenAI project for NLP. The developer requirement stated we need to use tensor Flow and GPU. I only want to use (not to train) the existing trained parameters. Is there any way to use GPT2 without the expensive hardware with GPU and without the need to install of Tensor Flow?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1003,"Q_Id":59588423,"Users Score":0,"Answer":"What I would do : \n\nsess.run([var for var in tf.trainable_variables]) to get trained parameters and save them as numpy array.\nrebuild a numpy only version of gpt2.  \n\nBut : \n\nThis will take a substantial amount of work to rebuild the model\nYou need to install tensorflow at least once to get the trained variables. \n\nAs for the gpu, you don't need it actually, the model will run with a cpu version of tensorflow (gpu are especially needed to speed up training time).","Q_Score":2,"Tags":"python,tensorflow,nlp,gpu","A_Id":59590347,"CreationDate":"2020-01-04T06:18:00.000","Title":"Is there anyway to run GPT2 without GPU and TensorFlow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are newbie in the field of programming and we want to learn more, or you could help us code, learn more about YOLO (real-time object detection) with distance measurement from the camera to the object. Also we want the output to be in the form of audio. For example, a car has been detected and there will be an audio recording saying \"A car has been detected at a distance of ...cm.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1434,"Q_Id":59589766,"Users Score":1,"Answer":"There are two different approaches. One would be to train the YOLO network to output the distance to the detected object along with the outher outputs. This might be well hard and time consuming, especially if you are new to this DNN stuff. Another, easier, way would be to get the bounding box size from the YOLO detections, and calculate the distance based on the known car size against the bounding box size (the smaller is the bounding box -- the farther is the car).\nDon't expect cm precision with all this, you'd be lucky if you get your precision within 10%, that's 10m for 100m distance.","Q_Score":0,"Tags":"python,opencv,tensorflow,yolo","A_Id":59590376,"CreationDate":"2020-01-04T10:16:00.000","Title":"YOLO Object Detection with distance measurement and audio feedback","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an image loaded with opencv with img.shape = (208, 117, 3). I also have a boolean numpy array with mask.shape = (208, 117). How to I make all pixels in the img (0,0,0) wherever the mask has False, otherwise leave the pixels as they are?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":696,"Q_Id":59593132,"Users Score":1,"Answer":"Answer is\nimg[~mask,:] = [0,0,0]\nThat ,: takes care of the other dimension so you don't get mismatch issues.","Q_Score":0,"Tags":"python,numpy,opencv","A_Id":59593303,"CreationDate":"2020-01-04T17:28:00.000","Title":"Most efficient way to mask an opencv bgr with a boolean array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed django and when I go to log onto the admin page the runserver stops running and the only error that pops up is ERR_CONNECTION_REFUSED. The virtual environment is active and running, and I can not find any answers online.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":59595758,"Users Score":0,"Answer":"I had the same issue using Django 3.0.5\nWhat is your current python version? I had 3.7 and had to upgrade to 3.8 to be able to load the admin page. Had this issue before and downgrading to an older version of Django also works. Keep in mind if you upgrade the python version you will need to update your virtual env.","Q_Score":0,"Tags":"python,django,django-3.0","A_Id":61167451,"CreationDate":"2020-01-04T23:33:00.000","Title":"Can not connect to admin page on django 3.0.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am researching on micropython to use for an IoT project for school using nodeMCU esp8266. one of the use cases requires the device to receive IR signal from an Aircon remote control and save it as well as being able to transmit this code using and IR LED. in circuitpython there is a library called pulseio that can do this function, but it is not available in micropython. can this library be imported into micropython?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":934,"Q_Id":59599062,"Users Score":4,"Answer":"In short No. \nIt is very unlikely any CircuitPython library willl work straight over in MicroPython on your board. The main reason for this is that once the library starts to use UART or I2C the underlying implementation in CircuitPython is very dependent on other CircuitPython libraries which do not have equivalents in MicroPython.\nIt may be possible to find all these and re-implement them using standard MicroPython.\nThe decision point is if you can do that faster than finding a MicroPython library or example for your board to do the same thing OR if you should buy a CircuitPython compatible board instead.","Q_Score":3,"Tags":"esp8266,micropython,adafruit-circuitpython","A_Id":60854293,"CreationDate":"2020-01-05T10:46:00.000","Title":"Can circuitpython libraries be imported and used in 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 learned about python script to shutdown the pc like: os.system(shutdown \/s \/t 0)\nBut what I was wondering about is to write a script using python which will start up the pc at a specific time after its been shutdown. The os I am using is Windows10.\nCan anyone help me please.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":477,"Q_Id":59600718,"Users Score":1,"Answer":"It is not possible directly. When your system is shut down no programs can run, including python. However it might be possible to set up Wake On Lan functionality and use python on another computer to send the WOL packet.\nAnorher solution would be to go into BIOS (UEFI on newer machines) and schedule wakeup times. No python needed. Or thereay be a way to use python on Win10 to modify UEFI settings in order to set up a wakeup event","Q_Score":0,"Tags":"python,python-3.x,windows","A_Id":59600767,"CreationDate":"2020-01-05T14:11:00.000","Title":"How to start up pc (windows) using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Im very new to coding and only know the very basics. I am using python and trying to print everything between two sentences in a text. I only want the content between, not before or after. It`s probably very easy, but i couldnt figure it out. \nEv 39 Fursetfjellet (Oppd\u00f8l - Batnfjords\u00f8ra)  No reports.  Ev 134 Haukelifjell (Liamyrane bom - Fjellstad bom) Ev 134  Haukelifjell  Hordaland  \/  Telemark  \u2014  Icy. 10 o'clock 1 degree. Valid from: 05.01.2020 13:53 Rv 3 Kvikne (Tynset (Motr\u00f8a) - Ulsberg)\nI want to collect the bold text to use in website later. Everything except the italic text(the sentence before and after) is dynamic if that has anything to say.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":59602232,"Users Score":0,"Answer":"It looks like a job for regular expressions, there is the re module in Python.\nYou should:\n\nOpen the file\nRead its content in a variable\nUse search or match function in the re module\n\nIn particular, in the last step you should use your \"surrounding\" strings as \"delimiters\" and capture everything between them. You can achieve this using a regex pattern like str1 + \"(.*)\" + str2.\nYou can give a look at regex documentation, but just to give you an idea:\n\n\".*\" captures everything\n\"()\" allows you actually capture the content inside them and access it later with an index (e.g. re.search(pattern, original_string).group(1))","Q_Score":1,"Tags":"python","A_Id":59602368,"CreationDate":"2020-01-05T17:08:00.000","Title":"How do I print everything between two sentences?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"if I press around my image button it clicks, I only want when the image is clicked that it opens not the surroundings can anybody help me with this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19,"Q_Id":59602594,"Users Score":0,"Answer":"Override on_touch_down to call super().on_touch_down only if the touch meets your collision requirements.","Q_Score":0,"Tags":"python,kivy","A_Id":59602813,"CreationDate":"2020-01-05T17:49:00.000","Title":"Image button in kivy is not concise","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've created a csv file with the column names and saved it using pandas library. This file will be used to create a historic record where the rows will be charged one by one in different moments... what I'm doing to add rows to this csv previously created is transform the record to a DataFrame and then using to_csv() I choose mode = 'a' as a parameter in order to append this record to the existing file. The problem here is that I would like to see and index automatically generated in the file everytime I add a new row. I already know when I import this file as a DF, an index is generated automatically, but this is within the idle interface...when I open the csv with Excel for example...the file doesn't have an index.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":59602713,"Users Score":0,"Answer":"While writing your files to csv, you can use set index = True in the to_csv method. This ensures that the index of your dataframe is written explicitly to the csv file","Q_Score":0,"Tags":"python,pandas,dataframe,indexing","A_Id":59603091,"CreationDate":"2020-01-05T18:01:00.000","Title":"exporting and indexing csv file with pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I updated to Spyder 4 (4.0.0?) to get the latest and greatest features. At this time I found out that Spyder now has the option of using Kite for autocompletion. After trying Kite for a bit I wanted to revert back to the previous autocompletion setup. I thought this was possible by unchecking to use Kite in the preferences, but then autocompletion seemed to be completely broken.\nIn conda I noticed my current version of Jedi was out of date, and I upgraded to the newest version. In the process I noticed that conda said it needed to downgrade Spyder for the Jedi upgrade. This gives me the impression that Spyder 4 just doesn't support Jedi. Is that the case?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1717,"Q_Id":59604624,"Users Score":2,"Answer":"(Spyder maintainer here) Spyder 4.0.0 and 4.0.1 only work with Jedi 0.14.1. Newer nor older versions are supported, so be sure to have that exact version installed.\nBy the way, although not required, Kite completions are better for scientific packages than Jedi ones.","Q_Score":1,"Tags":"python,spyder","A_Id":59613792,"CreationDate":"2020-01-05T22:07:00.000","Title":"jedi support in spyder 4","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I Have created a python based tool for my teammates, Where we group all the similar JIRA tickets and hence it becomes easier to pick the priority one first. But the problem is every time I make some changes I have to ask people to get the latest one from the Perforce server. So I am looking for a mechanism where whenever anyone uses the tool a pop up should come up as \"New version available\" please install.\nCan anyone help how to achieve that?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":60,"Q_Id":59606906,"Users Score":2,"Answer":"I have an idea,you can use requests module to crawl your website(put the number of version in the page) and get the newest version.\nAnd then,get the version in the user's computer and compare to the official version.If different or lower than official version,Pop a window to remind user to update","Q_Score":3,"Tags":"python,python-3.x","A_Id":59606974,"CreationDate":"2020-01-06T05:04:00.000","Title":"I want my python tool to have a mechanism like whenever anyone runs the tool a pop up should come up as New version available please use the latest","Data Science and Machine Learning":0,"Database and SQL":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 created a python based tool for my teammates, Where we group all the similar JIRA tickets and hence it becomes easier to pick the priority one first. But the problem is every time I make some changes I have to ask people to get the latest one from the Perforce server. So I am looking for a mechanism where whenever anyone uses the tool a pop up should come up as \"New version available\" please install.\nCan anyone help how to achieve that?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":60,"Q_Id":59606906,"Users Score":2,"Answer":"On startup, or periodically while running, you could have the tool query your Perforce server and check the latest version. If it doesn't match the version currently running, then you would show the popup, and maybe provide a download link.\nI'm not personally familiar with Perforce, but in Git for example you could check the hash of the most recent commit. You could even just include a file with a version number that you manually increment every time you push changes.","Q_Score":3,"Tags":"python,python-3.x","A_Id":59606944,"CreationDate":"2020-01-06T05:04:00.000","Title":"I want my python tool to have a mechanism like whenever anyone runs the tool a pop up should come up as New version available please use the latest","Data Science and Machine Learning":0,"Database and SQL":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 created a python based tool for my teammates, Where we group all the similar JIRA tickets and hence it becomes easier to pick the priority one first. But the problem is every time I make some changes I have to ask people to get the latest one from the Perforce server. So I am looking for a mechanism where whenever anyone uses the tool a pop up should come up as \"New version available\" please install.\nCan anyone help how to achieve that?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":60,"Q_Id":59606906,"Users Score":1,"Answer":"You could maintain the latest version code\/tool on your server and have your tool check it periodically against its own version code. If the version code is higher on the server, then your tool needs to be updated and you can tell the user accordingly or raise appropriate pop-up recommending for an update.","Q_Score":3,"Tags":"python,python-3.x","A_Id":59607089,"CreationDate":"2020-01-06T05:04:00.000","Title":"I want my python tool to have a mechanism like whenever anyone runs the tool a pop up should come up as New version available please use the latest","Data Science and Machine Learning":0,"Database and SQL":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 pip I installed PyPDF2. The first time i used all lowercase so pip install pypdf2, an application was downloaded and installed. However then I realized (by further reading the tutorial) that it is case sensitive. So then I installed PyPDF2 again in correct format. My questions would be: \n\nWhat did I install when I did pip install pypdf2?\nIs it the same program, or is it something else?\nAnd if it is something else how can I check what I installed?\nCould it be malware?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":233,"Q_Id":59609519,"Users Score":0,"Answer":"Yes, it is the same. Package names are case insensitive.\nAlso, You can use pip freeze to check what packages you have installed. It will give you the full list of packages which you have installed.\nAnd last one - You can relax. It isn't malware.","Q_Score":0,"Tags":"pip,pypi,pypdf2,python-packaging","A_Id":59646568,"CreationDate":"2020-01-06T09:24:00.000","Title":"Is pypdf2 the same as PyPDF2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Selenium with Python API and Chrome to do the followings:\n\nCollect the Performance Log;\nClick some <a, target='_blank'> tags to get into other pages;\n\nFor example, I click a href in Page 'A', which commands the browser opens a new window to load another URL 'B'.\nBut when I use driver.get_log('performance') to get the performance log, I can only get the log of Page 'A'. Even though I switch to the window of 'B' as soon as I click the href, some log entries of the page 'B' will be lost.\nSo how can I get the whole performance log of another page without setting the target of <a> to '_top'?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":59612799,"Users Score":0,"Answer":"I had the same problem and I think it is because the driver does not immediately switch to a new window.\nI switched to page \"B\" and reloaded this page, then uses get_log and it worked.","Q_Score":1,"Tags":"python,selenium,logging","A_Id":66257822,"CreationDate":"2020-01-06T13:14:00.000","Title":"How to get the Performance Log of another tab from Selenium using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using tensorflow 2.0 to train a model. I am deciding about whether I should put multiple examples in a batch along the rows or columns of a matrix. Obviously this will affect how I design the model as well. Is there any practical advice on which is better?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":59613281,"Users Score":1,"Answer":"Quoting @ShanqingCai\n\nPutting examples in a batch along the rows of a matrix (i.e., the first axis of the input tensor) is the prevailing way of training deep learning models. Virtually any tensorflow2 \/ keras example you can find follows that pattern. Putting them along any non-first axis is much rarer.\n\nAs said, the row dimension is the preferred way of storing samples. I can think of two reasons why this is the case,\n\nTF does a lot of matrix multiplications involving batches of data. Therefore, by keeping batch dimension as the first dimension, you are able to continuously produce tensors using matrix multiplication, which also has the batch dimension as the first dimension. (e.g. [batch size, 10] . [10, 2] produces [batch size, 2])\nThe other reason is that the row dimension is the slowest changing dimension. Therefore by you can access an individual sample by taking a single contiguous chunk of memory which is always preferred when it comes to disk reading\/ memory reading.","Q_Score":0,"Tags":"python-3.x,tensorflow2.0","A_Id":59617838,"CreationDate":"2020-01-06T13:48:00.000","Title":"Placing examples in a mini-batch on the rows or columns of a matrix?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been doing Applied Machine Learing in Python course on coursera and on Assignment of week 4 I`ve found something interesting. During my first attempt to complete the assignment I tried using RandomForestClassifier from sklearn to predict labels, but the model was overfitting and was showing poor test accuracy results. As an experiment I switched to RandomForestRegressor and, guess what, not only did it not overfit, but test accurary was also a lot higher. So, why does RandomForestRegressor perform a lot better on a binary classification problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":59614227,"Users Score":2,"Answer":"The Random Forest regressor does differ somewhat from the Random Forest classifier when it comes to ensembling the decision trees:\n\nThe classifier uses the mode of the predicted classes of the decision trees\nThe regressor uses the mean of the predicted values of the decision trees\n\nDue to this difference the models can have different results. And in some cases this might result in the regressor performing better than the classifier. \nIn addition to that I would say that if you tune your hyperparameters correctly, the classifier should perform better on a classification problem than the regressor.","Q_Score":0,"Tags":"python,scikit-learn,data-science,random-forest","A_Id":59617330,"CreationDate":"2020-01-06T14:54:00.000","Title":"RandomForestRegressor for classification problems","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way of converting a pptx file into png files for each slide using Python?\nI was thinking of converting pptx into pdf and then converting each pages into png but not sure if it is the optimal way.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1155,"Q_Id":59614611,"Users Score":0,"Answer":"To build on natter1's answer, two things that I had to do to get save_pptx_as_png to work on Windows:\n\nInstall the comptypes library (i.e. pip install comtypes)\nFormat my folder_to_save_pngs and pptx_filename paths with backslashes rather than the forward slashes common in Python coding. e.g. C:\\users\\me\\documents\\foo.pptx rather than C:\/users\/me\/documents\/foo.pptx\n\nIf you don't do this, you may run into errors such as \"Comptype module needed to save PNGs\" or COMError \"The system cannot find the path specified.\"","Q_Score":0,"Tags":"python,powerpoint,python-pptx","A_Id":70991315,"CreationDate":"2020-01-06T15:19:00.000","Title":"convert pptx into PNGs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am in the process of moving a site created in django to another server. I have packed all files into a zip package, created a new virtualenv environment on a second server, and dumpdate into a .json file. I already have all the files on the destination server, but unfortunately I don't know what to do next. \nHow to run django in the new virtualenv environment? Should I extract the files to a folder with the new virtualenv? If so, do I have to activate virtualenv first?\nI will also add that migration takes place from two different systems. From windows on ubuntu.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":959,"Q_Id":59616382,"Users Score":4,"Answer":"Save your env packages to a file with a command pip freeze > requirements.txt. \nAfterwards on your new server create virtualenv and install all packages with command pip install -r requirements.txt.\n\nDo not copy your virtualenv manually, packages might work differently on another system.\nactivate your virtualenv and run python -m django \u2014version to check that Django is installed correctly. \n\nCopy your code repository anywhere you like.\nThen create your database (empty database) if it\u2019s not SQLite.  cd into your project folder. Run python manage.py migrate to create the tables of your database. \nRun python manage.py loaddata dbdump.data to migrate all the data of your db. dbdump.data is the file created on the old system with python manage.py dumpdata. Note: if the previous project contained data migrations, loaddata will fail because the db will already contain data. In that case you\u2019ll need to manually delete all data in the database first using raw sql. \nIf you had uploaded files on your previous system, copy these files into the MEDIA_ROOT folder (create it if necessary). Check for MEDIA_ROOT in settings.py\nRun python manage.py collectstatic\n\nNow run manage.py runserver and check everything works: curl -v http:\/\/127.0.0.1:8000 will show you your project's response.","Q_Score":0,"Tags":"python,django,server,virtualenv","A_Id":59616453,"CreationDate":"2020-01-06T17:23:00.000","Title":"How to run django files in another virtualenv environment on another server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have python script, but my computer is closed. Is there any method which i can use task scheduler even though my computer closed, any cloud service?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":559,"Q_Id":59618430,"Users Score":0,"Answer":"All of the major cloud providers have some sort of cloud function.  On Azure it's called Function App, on AWS I believe it's called a lambda function.  You can essentially create a python function, deploy it to either service, and have it write the results to whatever the cheapest cloud db option they have on either service.","Q_Score":0,"Tags":"python,windows-task-scheduler","A_Id":59618921,"CreationDate":"2020-01-06T20:20:00.000","Title":"How to schedule tasks when computer is closed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have python script, but my computer is closed. Is there any method which i can use task scheduler even though my computer closed, any cloud service?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":559,"Q_Id":59618430,"Users Score":0,"Answer":"You can use AWS Lambda to deploy your code, AWS Cloudwatch events to trigger your application using a cron regex, and some database service. This will allow you to set the schedule to run your code on any schedule you should choose. Both cloudwatch and lambda of these services are mostly covered by the aws free tier and your usage should not cost anything.\nFor the database you have AWS dynamoDB for a nosql option and AWS RDS for a relation db option. I would suggest starting with dynamoDB because basic usage is covered by the free tier and it's pretty easily to get started. You could try rds, but if you are unfamiliar with it you may risk a high unintentional expense.","Q_Score":0,"Tags":"python,windows-task-scheduler","A_Id":59633240,"CreationDate":"2020-01-06T20:20:00.000","Title":"How to schedule tasks when computer is closed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using a Cloud function that is triggered by a bucket to process that file and save the result in another bucket. (more specfically using Pyinstaller to compile python files into executable). However it is cumbersome to operate with a read-only filesystem where I can only use the \/tmp folder also with an underlying operating system that lacks some system packages I need.\nUsing docker could solve my problem but not sure whether I should use in a cloud function or in another way.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":59619873,"Users Score":0,"Answer":"Cloud Run is best option if you want to use containerised application.","Q_Score":1,"Tags":"python-3.x,linux,docker,google-cloud-platform,google-cloud-functions","A_Id":59631101,"CreationDate":"2020-01-06T22:34:00.000","Title":"Is it good practice to use Docker in a Cloud Function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a python script, let's call it my_script.py. The script is supposed to generate simulated responses to an api call performed on the command line.\nWhat I am looking for is some way to have a custom command line command, e.g. run-my-script execute my_script.py while allowing for my_script.py to accept keyword arguments.\nIt would be great to have a solution that doesn't require external libraries and that allows for keyword arguments to be passed from the command line to that function.\nIs there a way to have a custom command on the command line, like run-my-script trigger my_script.py? \nThough it would be easiest to just run python my_script.py from the command line, for my use case I need to have the python script triggered just by run-my-script alone.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":369,"Q_Id":59620571,"Users Score":2,"Answer":"alias run-my-script=\"python my_script.py\"\nRun this command in terminal and run-my-script will execute my_script.py.\nYou can also add it in  ~\/.bashrc  so you can access it after you reboot.","Q_Score":0,"Tags":"python,bash,shell,command-line","A_Id":59620775,"CreationDate":"2020-01-07T00:11:00.000","Title":"Mapping a custom a CLI command 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":"My PC has HDD and SDD configuration. \nBy default, the SDD is selected as the C drive and when I installed Anaconda, it was installed in the C drive. When I open the Jupyter Notebook, it shows me the available paths to download, only in C drive.\nBut I wanted to create the notebook (.ipynb) in D drive and store it there. It is not showing me any paths related to D drive.\nHow do I save my notebook in D drive?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":170,"Q_Id":59621222,"Users Score":0,"Answer":"Anaconda's installer hard-codes many path names. This has impacted me many times. On a Unix box you can put in place a symlink. Although windows has symlinks, it's hard to create and maintain them. Your easiest solution is to reinstall on the D drive: Python doesn't really work well with C: and D: drives, since they are different filesystems in a different namespace.\nWith that said, you can also hunt around and change the Jupyter Notebook config file.","Q_Score":0,"Tags":"python,windows,jupyter-notebook,anaconda","A_Id":59621247,"CreationDate":"2020-01-07T01:52:00.000","Title":"Windows: Have Jupyter Notebook save on a drive other than the installation drive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using boto3's interface for AWS Comprehend for sentiment analysis.\nI have an issue with the 'DataAccessRoleArn' parameter. What kind of value is inserted in this? I am requesting for the format of it or some sample.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1228,"Q_Id":59622344,"Users Score":1,"Answer":"For DataAccessRoleArn you should add the arn of iam role you want to assign. You can find the arn in IAM page inside roles and after selecting the role you will find the role arn.\nThe format of the role arn is:\narn:aws:iam::<account_number>:role\/<role_name>","Q_Score":2,"Tags":"python,amazon-web-services,boto3,amazon-comprehend","A_Id":59622479,"CreationDate":"2020-01-07T04:52:00.000","Title":"What is the \"DataAccessRoleArn\" for Comprehend in boto 3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Tensorflow and I have used tensorflow.placeholder() in tensorflow 1.0. But is there any replacement of placeholder.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":4307,"Q_Id":59625668,"Users Score":4,"Answer":"There is no replacement for placeholder in Tf2 as its default mode is eager execution , if want to use placeholder in tf2 than use tf.compat.v1 syntax and disable v2 behavior","Q_Score":1,"Tags":"python,tensorflow2.0","A_Id":59625798,"CreationDate":"2020-01-07T09:36:00.000","Title":"What is the replacement of Placeholder in Tensorflow 2.0","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to send images (4000, 3000, 3) between two processes.\nMy first process acquires the image with a camera, attaches to it some metadata, another image and then sends the whole thing to the second process, which processes it.\nI want to have a maximal delay of 0.2 seconds between the moment the image is acquired and the moment the processing is over.\nLet's assume the way I acquire and process the image is optimal.\nI tried 2 methods to send the image, with a queue (mp.Queue) and with a shared array (mp.Array('i', 4000*3000*3))\nBoth took to much time. \nThe Queue.put() method takes about 0.5 seconds to send the package.\nCopying the image in a shared array like this:\nshared_array[:] = img.copy()\nTakes about 2 seconds.\nSo my question is, is anyone aware of a faster way to transit two images between two processes?\nThanks for your time!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":282,"Q_Id":59631595,"Users Score":0,"Answer":"EDIT: I found this question, which has been answered, and addressed my problem using sharedmem module","Q_Score":0,"Tags":"python-3.x,ipc,python-multiprocessing,opencv4","A_Id":59661270,"CreationDate":"2020-01-07T15:42:00.000","Title":"Image transmission between processes too slow in python's multiprocessing","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am moving the django page from the windows server to the ubuntu server. I get a utf8 error while executing the python manage.py loaddata command. Unfortunately, I don't know why. Below I send the message I receive.\n'utf8' codec can't decode byte 0xff in position 0: invalid start byte\nI will add that the site uses the MySQL database.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":59631971,"Users Score":0,"Answer":"I solved the problem by changing the encoding in the file I imported from. I did this using the notepad ++ code editor.","Q_Score":0,"Tags":"python,django,linux,windows","A_Id":59632406,"CreationDate":"2020-01-07T16:05:00.000","Title":"How to import django data from windows on ubuntu correctly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm tasked with creating a web app (I think?) for my job that will tracker something in our system. It'll be an internal tool that staff uses to keep track of the status of one of the things we do. It should look like trello, with cards that drag from step to step. That frontend exists, but my job is to make the system update when the cards are dragged. This requires using an API in Python and isn't that complicated to grab from\/update. I have no idea how to put all of this together. My job is almost completely nontechnical and there's no one internally who knows what I'm doing except for me. I'm in so over my head here and have no idea where to begin. Is this something I should deploy on Elastic Beanstalk? EC2? How do I tie this together and put it somewhere?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":59636606,"Users Score":0,"Answer":"Are you trying to pull in live data from Trello or from your companies own internal project management tool?\nAn EC2 might be useful, but honestly, it may be completely unnecessary if your company has its own servers. An EC2 is basically just a collection of rental computers to help with scaling. I have never used beanstalk so my input would be useless there. \nFrom what I can assume from the question, you could have a python script running to pull from the API and make the changes without an EC2.","Q_Score":1,"Tags":"python,amazon-web-services,deployment,web-applications","A_Id":59637887,"CreationDate":"2020-01-07T21:54:00.000","Title":"How do I deploy this app for my job: EC2, Elastic Beanstalk, something else entirely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm building my first ever web-app in python, haven't even decided on a framework yet,\ndoes it make sense to start out with a MySQL database to manage users and credentials?\nor is it a completely ridiculous way to approach it?\nwhat are some existing solutions and best practices for managing user credentials?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":133,"Q_Id":59637029,"Users Score":2,"Answer":"The answer is, as always, it depends. There are many ways to build a web app in Python so you'll first need to decide on what you want to build or what technology you want to learn. \nIf you just want to focus on a Python backend as a learning exercise then you could use Flask which can run as a server and includes many modules to help you get started including managing users. If you plan to expose your app publicly though it is generally recommended to use Apache or some other battle tested server which can route the requests to Flask.\nThere are other Python frameworks like bottle which I believe is meant to be even simpler than Flask and Django which is more complicated but has more features. It all depends on what you want to do. You can also look at things like dash if you're end goal has a data analysis flavor.\nOne thing to note though is that managing user credentials is not trivial. It can be a useful exercise if you like to learn and tinker, but to do it correctly youll need to learn about salting passwords, cryptographically secure hashing, session management, https (and ideally which ciphers should be deprecated), how to protect against sql injection (good to know how to do this anyway if you don't already), cross site scripting, CORS, etc. The list goes on. None of these things are exclusively just for managing user credentials but you should understand all the ways things can go south on you.","Q_Score":0,"Tags":"python,mysql,security,authentication","A_Id":59637223,"CreationDate":"2020-01-07T22:32:00.000","Title":"Managing User Authentication for a web-app with MySQL","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I recently began to teach myself how to program in python. At the moment I am struggling to structure my learning through projects like I had in my programming classes. I was wondering if anyone had a short list of projects that they feel best develop the skills they find most useful in python or somewhere I could find good projects to challenge myself to grow. \nThanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":59638779,"Users Score":0,"Answer":"Download your bank statement and write a parser to generate a spending report.","Q_Score":0,"Tags":"python","A_Id":59638820,"CreationDate":"2020-01-08T02:50:00.000","Title":"Could someone give me a good progression of projects to grow my skills in python from novice to intermediate at least?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried applying tesseract ocr on image but before applying OCR I want to improve the quality of the image so that OCR efficiency increase,\n\nHow to detect image brightness and increase or decrease the brightness of the image as per requirement.\n\nHow to detect image sharpness","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":328,"Q_Id":59639187,"Users Score":0,"Answer":"*Basic recommendation, using the gray images is better on OCR\nYou can use the BRISQUE image quality assessment for scoring the image quality, it's available as a library. check it out, a smaller score means good quality.","Q_Score":1,"Tags":"python-3.x,image-processing,ocr,python-tesseract","A_Id":65552040,"CreationDate":"2020-01-08T03:52:00.000","Title":"How to detect image brightness and sharpness in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have inherited a Python code base that has various classes with an 'id' attribute (example: Product.id; Service.id; User.id; ...). The code base has various instances of those classes (example: the Service class has instances named: service1, service2, company.service, etc.). We want to search \/ replace all occurrences of the 'id' attribute in the whole code base by a new attribute (for example: serv_id). But we also want to make sure that it does not replace the 'id' attributes of other class instances in the process. Is there a way to do that?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":115,"Q_Id":59639605,"Users Score":1,"Answer":"You can try a rename refactoring for those individual classes' id attribute (best option would be using the Microsoft Python Language Server).","Q_Score":1,"Tags":"python,visual-studio-code,vscode-settings","A_Id":59671357,"CreationDate":"2020-01-08T04:52:00.000","Title":"How to search \/ replace an attribute name in all instances of a *specific* class in VS Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was making an integer to Boolean program and was dealing with some large numbers\nThe test case was - 15921396743627894741911\nWhen I used \nr\/2 the output was 7.960698371813948e+21\nint(r\/2) gave me 7960698371813947736064\nand r\/\/2 gave me 7960698371813947370955\nWhy is the value for the last two cases so vastly different. Thank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":62,"Q_Id":59639995,"Users Score":0,"Answer":"In Python 3, \/ does \"true division\", which returns a float, but floats have limited precision.","Q_Score":2,"Tags":"python,python-3.x","A_Id":59640093,"CreationDate":"2020-01-08T05:41:00.000","Title":"Difference between int(r\/2) and r\/\/2 outputs","Data 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 LXML python library, how to iterate? and what is the difference between iterdescendants() and iterchildren() in lxml python ?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1508,"Q_Id":59640314,"Users Score":0,"Answer":"when you use iterchildren() you iterate over first level childs. When you use iterdescendants() you iterate over childs and childs of childs.","Q_Score":1,"Tags":"python,lxml","A_Id":59640404,"CreationDate":"2020-01-08T06:15:00.000","Title":"What is the difference between iterdescendants() and iterchildren() in lxml?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am migrating a piece of software from Python 2.7 to Python 3.\nOne problem that arises is:\n\nThe sklearn.neighbors.kde module is  deprecated in version 0.22 and\n  will be removed in version 0.24. The corresponding classes \/ functions\n  should instead be imported from sklearn.neighbors. Anything that\n  cannot be imported from sklearn.neighbors is now part of the private\n  API.\n\nI am not sure which line causes this, and not sure if it is an error or a warning, and what are the implications.\nOn python 2.7 everything works fine.\nHow do I get rid of this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":8393,"Q_Id":59643694,"Users Score":1,"Answer":"It's just a warning, for now -- until you upgrade sklearn to version 0.24. Then your code will need to be modified before it works. It's giving you a heads-up about this, so you can fix your code ahead of time. The modifications described below should work with your current version; you don't need to wait to upgrade before changing your code (at least, that's how these deprecation warnings usually work).\n\nThe corresponding classes \/ functions should instead be imported from sklearn.neighbors.\n\nIf I read this message correctly, it's saying that if you're using a function like sklearn.neighbours.kde.some_function() in your code now, you need to change it to sklearn.neighbours.some_function(). \n\nAnything that cannot be imported from sklearn.neighbors is now part of the private API.\n\nThis seems to be saying that there may be some functions that will no longer be available to you, even using the modification above.","Q_Score":5,"Tags":"python,scikit-learn,deprecation-warning","A_Id":59644182,"CreationDate":"2020-01-08T10:17:00.000","Title":"The sklearn.* module is deprecated in version 0.22 and will be removed in version 0.24","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello my dearest stackoverflow community,\nI want to run a .py file until a certain position. Certain IDEs might support the feature \"run all above\" but it seems like I am failing to use PyCharm properly, as I need the python console at all times to browse variables n stuff.\nSo - is there a way to stop the execution of the program in a proper manner? (edit: without shutting down the python console, such that further commands can be run to inspect \/ use obtained variables)\nObviously there are workarounds: throw exceptions, program the file into a while loop and break - but these cant be proper solutions, right?\nedit:\nA few answers are hinting already, that this could easily be solved while using debugging functions - however, using debugging functions might not always be possible as .py files could be executed remotely [without proper interface for debugging], loading a \"standard\" version, while a more \"advanced \/ experimental\" version could also run more chunks of code in that .py file.\n(Yes, I am aware that this actually might be considered shitty development - as running functions and having proper parameters would also solve this, I guess.)\nPlease educate me, I didn't find the information I was looking for using google, as everything that was shown showed loop-relevant actions.\nBest regards","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":59645930,"Users Score":0,"Answer":"The proper way of not facing such problems like this, is nesting code into functions and call them properly in order to control what part of the code should actually be executed.\nHowever, a solution for this might still be relevant, especially for applications in data science, as many solutions are presented in a single file (\/jupyter notebooks) in order to present all steps taken to obtain achieved results.","Q_Score":1,"Tags":"python,python-3.x,pycharm,python-3.6","A_Id":59646832,"CreationDate":"2020-01-08T12:30:00.000","Title":"How to run .py-file and stop at desired statement while developing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello my dearest stackoverflow community,\nI want to run a .py file until a certain position. Certain IDEs might support the feature \"run all above\" but it seems like I am failing to use PyCharm properly, as I need the python console at all times to browse variables n stuff.\nSo - is there a way to stop the execution of the program in a proper manner? (edit: without shutting down the python console, such that further commands can be run to inspect \/ use obtained variables)\nObviously there are workarounds: throw exceptions, program the file into a while loop and break - but these cant be proper solutions, right?\nedit:\nA few answers are hinting already, that this could easily be solved while using debugging functions - however, using debugging functions might not always be possible as .py files could be executed remotely [without proper interface for debugging], loading a \"standard\" version, while a more \"advanced \/ experimental\" version could also run more chunks of code in that .py file.\n(Yes, I am aware that this actually might be considered shitty development - as running functions and having proper parameters would also solve this, I guess.)\nPlease educate me, I didn't find the information I was looking for using google, as everything that was shown showed loop-relevant actions.\nBest regards","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":59645930,"Users Score":0,"Answer":"You can run the file in debug mode and set a breakpoint to stop the execution and inspect the variables. There is a shortcut in pycharm ^D to run a file in debug mode.","Q_Score":1,"Tags":"python,python-3.x,pycharm,python-3.6","A_Id":59653370,"CreationDate":"2020-01-08T12:30:00.000","Title":"How to run .py-file and stop at desired statement while developing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to python and working on a small code for flask webserver.\nI need a solution to achieve the below scenario.\nI have app.py which calls settings.py for flask user ID and password and also a route.py to handble the routes.\nNow I want users to be asked for authentication only for few routes and other routes should override authentication and perform operation based on specific users\/specific host.\nCan this be achieved?\nAs of now its asking for authentication for all the routes","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":413,"Q_Id":59646762,"Users Score":0,"Answer":"Although the above answer solves my query, I was looking for more specific scenario.\nHere's what I changed,\nI commented #app.config['BASIC_AUTH_FORCE'] = True in flask settings\nHere is what changed in routes.py\nAdded \nbasic_auth = BasicAuth(app)\nand I added this decorator\n@basic_auth.required for the routes which requires authentication.\nAs a security measure, I am allowing Unauthenticated requests only from a specific host using headers.","Q_Score":0,"Tags":"python,authentication,flask,overriding","A_Id":60638040,"CreationDate":"2020-01-08T13:19:00.000","Title":"Flask Authentication Override for one Route","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using an anaconda environment in VS code when suddenly the Run Python File in Terminal command bound to the green play-button in the top right corner stopped working. It used to input: python_path file_path\/file.py into the terminal and it worked perfectly fine. \nBut after running my code in the anaconda prompt program it has now changed to: \n& conda run -n env_name python file_path\/file.py and now I get a ModuleNotFoundError, that I don't have cv2 installed, which I do.\nI can still run the code if I simply input: python file_path\/file.py. My question is if it is possible to change the command that is bound to Run Python File in Terminal. I could not find a solution to this in a couple hours of searching. Thanks in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":861,"Q_Id":59646975,"Users Score":0,"Answer":"One solution I found was to reinstall the older python plugin and the \"conda run -n\" command would not be used at runtime.\nReinstallation method, Extension --> Python--manage--> install another version","Q_Score":0,"Tags":"python,opencv,visual-studio-code","A_Id":59659011,"CreationDate":"2020-01-08T13:30:00.000","Title":"Change Python:Run Python File in Terminal command in Visual Studio Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How to restream\\redirect incoming rtmp stream to several other services with python? Is it even possible with python?\nI know that there is a nginx solution, but I need to change links for restream without restarting, so I want to use Python.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":250,"Q_Id":59648916,"Users Score":1,"Answer":"Yes, or corse it possible in python (or any other language for that matter) but it\u2019s much harder. \nUse nginx. Nginx can call your python code with the \u201cexec\u201d options. The. You can then spin up ffmpeg instances in python to restream wherever you want.","Q_Score":0,"Tags":"python,rtmp","A_Id":59650185,"CreationDate":"2020-01-08T15:22:00.000","Title":"How to restream rtmp with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have included Python.h in my module header file and it was built successfully. \nSomehow when I enabled-examples configuration to compile the example.cc file, which includes the module header file. It reported the Python.h file can not be found - fatal error.\nI have no clue at the moment what is being wrong.\nCould anyone give a hint? It is for the NS3(Network Simulator 3) framework.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":59650272,"Users Score":0,"Answer":"thanks for writing back to me:).\nI solved the issue by adding the pyembed feature in the wscript within the same folder as my.cc file.\nThanks again:).\nJ.","Q_Score":0,"Tags":"python,c++,compiler-errors,header","A_Id":59666010,"CreationDate":"2020-01-08T16:40:00.000","Title":"NS3 - python.h file can not be located compilation 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":0,"Web Development":0},{"Question":"The question is simple, however I cannot find solution:\nHow to recognise cats and dogs and filter out everything other?\nAnother words: I have a big database with images of cats and dogs and all other photos mixed together, is there a way to say in output: cat -or- dog -or- something else?\nEither CNNs are not constructed to do such things efficiently?\nI'm using python \/ Keras \/ Tensorflow; solution with finding cats \/ dogs when I provide images of cats and dogs only - works fine.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":59653108,"Users Score":1,"Answer":"Labelling next class as 'other' or something like that is the simplest way to do that.\nWhat I found, that because of many different types of images in 'other' class, training sample should be much bigger than just when differing between cats and dogs.","Q_Score":0,"Tags":"python-3.x,tensorflow,keras,conv-neural-network","A_Id":59683042,"CreationDate":"2020-01-08T20:05:00.000","Title":"Neural network filtering out everything else than cats\/dogs","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to clone my device data and stream the device data to another IoThub in an entirely different organization, the organization here I mean a different vendor cloud. \nTrial:\nI have tried routing the messages to service bus topics from my IoThub and then written a container using the service bus SDK which can subscribe to these topics and push the data to Azure IoT hub in a different vendor cloud.  \nASK: \nIs there any other best way for sending the device stream to another vendor Azure IoThub other than the above using Azure alone. \nI can directly stream the device data from the data source, which is clearly not the use case.\nUsing IoT-device, not IoT-Edge.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":59655683,"Users Score":0,"Answer":"What you want to achieve is not possible out of the box. You need a processor in the middle that picks up messages from IoT Hub A - for instance on its built-in Event Hub endpoint. Then the processor would need to impersonate each device for which it got a message from A, and send the message to IoT Hub B, using the device credentials for the respective device.\nYou could for example build this with an Azure Function. But you need to build all this yourself.","Q_Score":0,"Tags":"azure-iot-hub,azure-eventhub,azure-servicebus-queues,azure-servicebus-topics,azure-sdk-python","A_Id":59682644,"CreationDate":"2020-01-09T00:31:00.000","Title":"Streaming device data from IoThub in one organization(Org\/Client A) to IoThub in entirely different organization(Org\/Client B)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have conda 4.8.1 running on windows 10 enterprise edition and it is showing me following error whenever I try to install notebook.\nInvalidArchiveError(\"Error with archive D:\\\\Miniconda3\\\\pkgs\\\\notebook-6.0.2-py37_0ujelie94\\\\pkg-notebook-6.0.2-py37_0.tar.zst.  You probably need to delete and re-download or re-create this file.  Message from libarchive was:\\n\\nCan't create '\\\\\\\\?\\\\D:\\\\Miniconda3\\\\pkgs\\\\notebook-6.0.2-py37_0\\\\Lib\\\\site-packages\\\\notebook\\\\static\\\\components\\\\MathJax\\\\extensions\\\\a11y\\\\invalid_keypress.mp3'\")\nI have tried different versions of notebook and reinstalled anaconda and miniconda many times. Nothing seems to work.","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":13228,"Q_Id":59657306,"Users Score":14,"Answer":"I had the same problem on Ubuntu 18.04, I used conda clean -a and then it works perfectly.\nActually what conda clean -a does is cleaning the compressed .bz files and deleting older versions of package folders and does nothing to the new ones.\nP.S.:  Make sure you installed Anaconda or Miniconda into a directory that contains only 7-bit ASCII characters and no spaces, such as C:\\anaconda!","Q_Score":9,"Tags":"python-3.x,jupyter-notebook,conda,miniconda","A_Id":61692544,"CreationDate":"2020-01-09T04:35:00.000","Title":"InvalidArchiveError when executing conda install notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I train a classification model using lightgbm, I usually use validation set and early stopping to determine the number of iterations. \nNow I want to combine training and validation set to train a model (so I have more training examples), and use the model to predict the test data, should I change the number of iterations derived from the validation process? \nThanks!","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":764,"Q_Id":59658070,"Users Score":0,"Answer":"In a similar problem in deep learning with Keras: I do it by using an early stopper and cross validation with train and validation data, and let the model optimize itself using validation data during trainings. \nAfter each training, I test the model with test data and examine the mean accuracies. In the mean time after each training I save the stopped_epoch from EarlyStopper. If CV scores are satisfying, I take the mean of stopped epochs and do a full training (including all data I have) with the number of mean stopped epochs, and save the model.","Q_Score":0,"Tags":"python,lightgbm","A_Id":59658376,"CreationDate":"2020-01-09T06:04:00.000","Title":"Is there any rules of thumb for the relation of number of iterations and training size for lightgbm?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I train a classification model using lightgbm, I usually use validation set and early stopping to determine the number of iterations. \nNow I want to combine training and validation set to train a model (so I have more training examples), and use the model to predict the test data, should I change the number of iterations derived from the validation process? \nThanks!","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":764,"Q_Id":59658070,"Users Score":1,"Answer":"As you said in your comment, this is not comparable to the Deep Learning number of epochs because deep learning is usually stochastic.\nWith LGBM, all parameters and features being equals, by adding 10% up to 15% more training points, we can expect the trees to look alike: as you have more information your split values will be better, but it is unlikely to drastically change your model (this is less true if you use parameters such as bagging_fraction or if the added points are from a different distribution).\nI saw people multiplying the number of iterations by 1.1 (can't find my sources sorry).  Intuitively this makes sense to add some trees as you potentially add information. Experimentally this value worked well but the optimal value will be dependent of your model and data.","Q_Score":0,"Tags":"python,lightgbm","A_Id":59661123,"CreationDate":"2020-01-09T06:04:00.000","Title":"Is there any rules of thumb for the relation of number of iterations and training size for lightgbm?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I train a classification model using lightgbm, I usually use validation set and early stopping to determine the number of iterations. \nNow I want to combine training and validation set to train a model (so I have more training examples), and use the model to predict the test data, should I change the number of iterations derived from the validation process? \nThanks!","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":764,"Q_Id":59658070,"Users Score":0,"Answer":"I'm not aware of a well-established rule of thumb to do such estimate. As Florian has pointed out, sometimes people rescale the number of iterations obtained from early stopping by a factor. If i remember correctly, typically the factor assumes a linear dependence of the data size and the optimal number of trees. I.e. in the 10-fold cv this would be a rescaling 1.1 factor. But there is no solid justification for this. As Florian also pointed out, the dependence around the optimum is typically reasonably flat, so +- a bit of trees will not have a dramatic effect.\nTwo suggestions:\n\ndo k-fold validation instead of a single train-validation split. This will allow to evaluate how stable the estimate of the optimal number of trees is. If this fluctuates a lot between folds- do not rely on such estimate :)\nfix the size of the validation sample and re-train your model with early stopping using gradually increasing training set. This will allow to evaluae the dependence of the number of trees on the sample size and approximate it to the full sample size.","Q_Score":0,"Tags":"python,lightgbm","A_Id":59810976,"CreationDate":"2020-01-09T06:04:00.000","Title":"Is there any rules of thumb for the relation of number of iterations and training size for lightgbm?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to find all tags that are either <h1> OR <div class='abc'>. I tried bs.find_all(['h1', 'div'], attrs={'class': 'abc'}), but this will ignore the <h1> tags: apparently, the attrs argument applies an AND condition to the search (meaning the tag must belong to the list of tag name AND have the given attribute, which the <h1> tags do not meet).\nCan anyone suggest a fix to this? Thank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":59658164,"Users Score":0,"Answer":"How about concatenate two results like bs.find_all('h1') + bs.find_all(['div', attrs={'class': 'abc'}) ?","Q_Score":1,"Tags":"python,beautifulsoup","A_Id":59658323,"CreationDate":"2020-01-09T06:14:00.000","Title":"BeautifulSoup: Find any tag that matches one tag by name, or another tag by attribute","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I had launched an EC2 with free trial (t2-micro)(WINDOWS SERVER 2019) in ap-south-2(Mumbai) . I am running a discord bot in python script. Running that script on the Mumbai server, I faced no problem.\nBut then due to ping issues i changed my region to us-west-1(N.California). But while running python file on California server (and any other at this point) I am having this problem with certification.\naiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discordapp.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')]\nAny help will be greatly appreciated","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1498,"Q_Id":59658986,"Users Score":1,"Answer":"So I recently faced the same problem. I found my way around that by terminating all the EC2 instances. Then giving it a rest for about 1-2 hours then making a new instance.\nAnd then by running code in that, I didn't face the problem. I don't know how it fixes the problem but I hope this helps.","Q_Score":3,"Tags":"python-3.x,amazon-web-services,amazon-ec2,discord.py","A_Id":59659016,"CreationDate":"2020-01-09T07:19:00.000","Title":"ClientConnectorCertificateError: Cannot connect to host discordapp.com:443, Certification error on AWS.(ec2)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Holoviews to construct a dashboard of charts. Some of these charts have percentages in the y axis where as others have sums\/counts etc. When I try to output all the charts I have created to a html file, all the charts change their y axis to match the axis of the first chart of my chart list. \nFor example:\n\nChart 1 is a sum, values go from 0 to 1000\nChart 2 is a %\nChart 3 is a %\n\nwhen I combine these charts in holoviews using:\n\nCharts = Chart 1 + Chart 2 + Chart 3\n\nThe y axis of charts 2 and 3 become the same as chart 1.\nDoes anyone know why this is happening and how I can fix it so all the charts keep their individual axis pertinent to what they are trying to represent. \nThank you!","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1953,"Q_Id":59661074,"Users Score":3,"Answer":"Sander's response is correct and will solve your specific problem, but in this case it may not be addressing the root cause. HoloViews only links axes that are the same, and it sounds like you're plotting different quantities on the y axis in each plot. In that case, the real fix is to put in a real name for the y axis of each plot, something that distinguishes it from other things that you might want to plot on the y axis in some other plot you're showing. Then not only will HoloViews no longer link the axes inappropriately, the viewer of your plot will be able to tell that each plot is showing different things.","Q_Score":8,"Tags":"python,holoviews,holoviz","A_Id":59674053,"CreationDate":"2020-01-09T09:41:00.000","Title":"Holoviews charts sharing axis when combined and outputted","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Everything has worked fine since this morning.\nI have some issues with vscode when I pass the python code to the jupyter interactive windows. \nIf I select only one line of the code, the line is sent to the interactive windows using the default key bind shift + enter or the right-click menu.\nHowever, when selecting multiple lines will not send to the interactive windows with any method and will not provide any feedback.\nAttempt to solve the problem :\n\nchange key binding\nremove similar key binding to ovoid conflict \nenable or disable python preference Data science allows input\nUninstall and install vscode \n\nAny ideas ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":59663212,"Users Score":0,"Answer":"The problem happen after the update of the python extension.\nSolution : install the previous version of the python extension in vscode","Q_Score":0,"Tags":"python,visual-studio-code,vscode-settings","A_Id":59681100,"CreationDate":"2020-01-09T11:41:00.000","Title":"vscode interractive windows jupyter won't pass muliple lines","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Python with the paho-mqtt library for an application where I'll have multiple devices connecting to a broker over 3G constantly sending data that will be stored in a database. For this data is quite important, I needed some kind of confirmation that the MQTT messages from the devices have been successfully delivered to the broker. Is there a way of doing that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":167,"Q_Id":59664359,"Users Score":0,"Answer":"On the publish method you can set the QoS 1 or 2. QoS level 1 guarantees that a message is delivered at least one time to the receiver. The sender stores the message until it gets a  PUBACK packet from the receiver that acknowledges receipt of the message. It is possible for a message to be sent or delivered multiple times. QoS 2 is the highest level of service in MQTT. This level guarantees that each message is received only once by the intended recipients. QoS 2 is the safest and slowest quality of service level. The guarantee is provided by at least two request\/response flows (a four-part handshake) between the sender and the receiver. The sender and receiver use the packet identifier of the original PUBLISH message to coordinate delivery of the message.","Q_Score":0,"Tags":"python,python-3.x,mqtt,mosquitto","A_Id":59664642,"CreationDate":"2020-01-09T12:49:00.000","Title":"Is there a way to assure a message's been delivered to the broker in MQTT with Paho MQTT for 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 using django transactions to work with my DB. The thing I am stuck on is that I have a DB and I want to replace the whole DB table with a new one created in the transaction block. The behavior of @transaction.atomic is that it will always update the DB table. So the old table entries will stay there. How to always remove the old entries? Am I missing something in the Django specs? Or do I need to clear the db table manually inside the transaction block?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":108,"Q_Id":59666373,"Users Score":0,"Answer":"Resolved - I deleted the table records in the transaction block.\nIt was a bug in the code.\nThanks for helpful comments","Q_Score":0,"Tags":"python,django,database,transactions","A_Id":59667284,"CreationDate":"2020-01-09T14:40:00.000","Title":"Python Django db transaction uses update","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Traditionally I've used Notepad ++ along with the Anaconda prompt to write and run scripts locally on my Windows PC.\nI had my PC upgraded and thought I'd give Virtual Studio Code a chance to see if I liked it.  \nNow, every time I try to execute a .py file in the Anaconda prompt Visual Studio 2017 launches.  I hate this and can't figure out how to stop it.\nI've tried the following:\n\nUninstalling Virtual Studio Code.\nChanging environments in Anaconda.\nReinstalling Anaconda.  I did not check the box for the %PATH option.\nReboots at every step.\n\nOn my Windows 10 laptop Visual Studio 2017 doesn't appear in my Apps and Features to uninstall.  I've tried Googling and am stuck.\nThe programs involved are:\nWindows 10 Professional\nVisual Studio 2017\nAnaconda version 2019.10 Build Channel py37_0\nCan someone help me figure out how to stop this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":59667456,"Users Score":1,"Answer":"How were you running the scripts before? python script.py or only script.py?\nIf it is the latter, what happened probably is that Windows has associated .py files to Visual Studio. Right click on the file, go to Open With, then select Python if you want to run them, or Notepad++ if you want to edit them.","Q_Score":0,"Tags":"python,visual-studio,anaconda","A_Id":59668150,"CreationDate":"2020-01-09T15:38:00.000","Title":"Anaconda prompt launches Visual Studio 2017 when run .py Files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently setting up Python on my new Windows 10 machine. I have installed Python 2.7.15 and 3.6.1 (both of which I currently still need for different applications, installing from installers that I have previously successfully used on my previous Windows7 machine) and some packages via pip. Both Python installations are 32 bit.\nOne of those packages is PyQt5 (which only exists for Python3, anyway).\nNow, I am trying to run one of my Python3 scripts which uses PyQt5 and I get \n\"ImportError: DLL load failed: %1 is not a valid Win32 application.\" on the first line importing PyQt5.\nI have tried using both pip install PyQt as well as py -3.6-32 -m pip install PyQt5 (after I found that this probably means an 32 bit\/64 bit incompatibility between Python and the package). Neither solved the problem.\nDoes anyone have an idea what else I can try?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1080,"Q_Id":59667538,"Users Score":0,"Answer":"Restarting the machine several times seems to have solved the issue. (There were no changes after the first reboot, but after the second reboot it worked.)","Q_Score":0,"Tags":"python,python-3.x,pyqt5,32bit-64bit","A_Id":59713870,"CreationDate":"2020-01-09T15:43:00.000","Title":"Installing PyQt5 in Windows10 32bit Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was just wondering if variables or names were objects or if the value is the object, if you could explain it in-depth I would appreciate it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":59669481,"Users Score":0,"Answer":"As far as I understand it, the values are objects, and the variables are just labels you use to refer to existing objects.\nAny value in python is an object, has it's type and attributes. If you want to see it for your self, try to invoke the function dir passing a constant, like:\ndir(1)\nyou will see all attributes associated with the int object 1\nAny variable in python can be assigned any object as it's value. You can look at the variable as something like a post it with a name inscribed in it. You can stick it to any object (your refrigerator, your TV, a chair), and it will still be the same label, but the object it's \"naming\" will be other. So, the variable is just a way to bind a name to an object.","Q_Score":0,"Tags":"python","A_Id":59669620,"CreationDate":"2020-01-09T17:40:00.000","Title":"Are variables in python objects or is the value considered an object?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My kivy\/python app works perfectly on windows but when I try to run the apk using buildozer I get an error that says: ModuleNotFoundError: No module named 'requests Where do I have to install the module?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":202,"Q_Id":59669557,"Users Score":1,"Answer":"Add it to your requirements line in buildozer.spec.","Q_Score":1,"Tags":"python,kivy,buildozer","A_Id":59670264,"CreationDate":"2020-01-09T17:46:00.000","Title":"How to use modules like request when making an android apk using kivy and python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python code on a server and if I upload a video from mobile to the server,so How can I provide path of that video to the python code if I want every video should prodceed by the python code","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":59671070,"Users Score":0,"Answer":"I have doubts that your explanation has truly reflects what you need. First of all servers accept every thing \"as it is\" as long as the input has the appropriate format for that specific \"server\". In your case, the video might be a stream, binary, or event encoded data in to a \"socket\" in your \"server\". the framework should not matter. So when you have a stream you should be able get it in to your \"server\" to be processed. If you have problem in that sense, you should try to look first how \"servers\" accept input. I assume you're knowledgable for that. Let's say you have a nginx server on a linux machine which also has a python included. So your web server should be configured to run in python (Django or something similar). Once you started to upload your file, the content can be passed as async, or sync process in python (I think I should not mention how RESTFull model work on http). When you have the data (stream or static\/bulk), you should be able to whatever you want to do with that data.","Q_Score":0,"Tags":"python,video,uploading","A_Id":59725643,"CreationDate":"2020-01-09T19:42:00.000","Title":"Uploaded video process by python code on 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":0,"Web Development":1},{"Question":"I have a xarray dataset, with data variables of:\nData variables:\n    hid      (particle) float32 ...\n    d        (particle) float32 ...\n    x        (particle) float32 ...\n    y        (particle) float32 ...\n    z        (particle) float32 ...\n    image    (hologram_number, xsize, ysize) uint8 ...\nI am wondering if there is a way to take all of the x values for my 10,000 data points, and pass them into a new one dimensional numpy array? Any sort of direction would be amazing. I have been reading the xarray.Dataset API and I'm not really getting anywhere.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":59671677,"Users Score":0,"Answer":"Try ds.x.values, where ds is the name of your dataset. .x (which is equivalent to ds[\"x\"]) gets the x dataarray from your dataset and .values returns the numpy array with its values.","Q_Score":0,"Tags":"python,numpy,python-xarray","A_Id":59682913,"CreationDate":"2020-01-09T20:33:00.000","Title":"Passing a specific Xarry Data Variable into a New Numpy Array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an AWS Lambda that uses 2 environment variables. I want to run this lambda up to several hundred times a day, however i need to change the environment variables between runs.\nIdeally, I would like something where I could a list a set of variables pairs and run the lambdas on a schedule\nThe only way I see of doing this, is have separate lambdas and setting the environment variables for each manually\nAny Ideas about how to achieve this","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":393,"Q_Id":59673456,"Users Score":2,"Answer":"You could use an SQS queue for this. Instead of your scheduler initiating the Lambda function directly, it could simply send a message with the two data values to an SQS queue, and the SQS queue could be configured to trigger the Lambda. When triggered, the Lambda will receive the data from the message. So, the Lambda function does not need to change.\nOf course, if you have complete control over the client that generates the two data values then that client could also simply invoke the Lambda function directly, passing the two data values in the payload.","Q_Score":1,"Tags":"python-3.x,amazon-web-services,aws-lambda","A_Id":59673562,"CreationDate":"2020-01-09T23:15:00.000","Title":"AWS Lambda - Run Lambda multiply times with different environment variables","Data 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 Tensorflow 2.0 for Python 3.\nSuppose I have two tensor variables, x and y, and I want to compute their element-wise sum x + y. Should I just write x + y, or tf.add(x, y)? If they are not equivalent, when should I use one or the other?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1972,"Q_Id":59673839,"Users Score":5,"Answer":"In my understanding they are equivalent and just executes the __add__ magic function.","Q_Score":3,"Tags":"python-3.x,tensorflow2.0","A_Id":59743781,"CreationDate":"2020-01-10T00:03:00.000","Title":"Should I use tf.add or + to add two tensors in Tensorflow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to import tensorflow_docs in a PyCharm python file. The I've installed it by\npip install git+https:\/\/github.com\/tensorflow\/docs\nIn PyCharm, the interpreter's install window does not contain tensorflow_docs as a package. I tried\nconda install git+https:\/\/github.com\/tensorflow\/docs\nAt first, attempting to install tensorflow_docs gave the readout: \n\n\"Requirement already installed in anaconda\/...\"\n\nI uninstalled with pip and reinstalled from github, but it still won't show up in PyCharm.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2203,"Q_Id":59674530,"Users Score":0,"Answer":"This may not be the exact solution and just an idea, but try creating a new environment so there is a fresh state to build on top.","Q_Score":0,"Tags":"python,pip,installation,conda,environment","A_Id":61042774,"CreationDate":"2020-01-10T01:48:00.000","Title":"Tensorflow_docs not showing up in environment's install window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"im trying to get the font size of text in an image, is there any library in python or can it be done using opencv? Thanks in advance","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1072,"Q_Id":59676639,"Users Score":1,"Answer":"You can first use a text detector or a contour detector to get the height of one line of text. That can be used to get the size of text in pixels. But after that, you need some reference to convert it to font size (which is usually defined in points). \nAll of this can be done in OpenCV. If you post an image with text, some of us will be able to provide more detailed answers.","Q_Score":1,"Tags":"python,opencv,image-processing","A_Id":59691150,"CreationDate":"2020-01-10T06:40:00.000","Title":"Get text size using opencv python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have imported excel file into python pandas. but when I display customer numbers I get in float64 format i.e \n\n7.500505e+09 , 7.503004e+09\n  how do convert the column containing these numbers","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":497,"Q_Id":59677058,"Users Score":0,"Answer":"int(yourVariable) will cast your float64 to a integer number.\nIs this what you are looking for?","Q_Score":1,"Tags":"python,pandas","A_Id":59677083,"CreationDate":"2020-01-10T07:19:00.000","Title":"convert float64 to int (excel to pandas)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"On a new install of VS Code on a new machine I have come across this error.\nThe send to python interactive window functionality is behaving exceptionally weirdly.\nIt will:\n- Send a single line of code to the interactive window using either shift+enter or right-click and select, when the cursor is on that line.\nIt will not:\n- Send any code to the interactive window when code is selected (by highlighting) either through shift+enter or right click and select.\nI have ticked the box is settings marked \"Python > Data Science: Send Selection To Interactive Window\".\nAnyone else experienced this problem or have suggestions to fix it?\nVS Code version: 1.14.1\nPython version: 3.7.4\nPython VS code extension: 2020.1.57204","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":6929,"Q_Id":59678010,"Users Score":2,"Answer":"After some searching I have found that there is an issue with the Python VS Code Extension version 202.1.57204.\nThe solution to this is to install the previous version in VS Code (209.11.50794).\nTo do this go to the extensions tab on the left side, right click on the \"Python\" extension and select \"Install another version...\". Any previous version should work, but I chose the most recent before 2020.1.507204.","Q_Score":6,"Tags":"python,visual-studio-code,python-interactive,vscode-python","A_Id":59678274,"CreationDate":"2020-01-10T08:34:00.000","Title":"VS Code \"Run selection\/line in Python interactive window\" not working at all","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am starting out with computer vision and opencv. I would like to try camera calibration for the images that I have to see how it works. I have a very basic doubt.\nShould I use the same camera from which the distorted images were captured or I can use any camera to perform my camera calibration?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":67,"Q_Id":59678398,"Users Score":1,"Answer":"Camera calibration is supposed to do for the same camera. Purpose of calibrating a camera is to understand how much distortion the image has and to correct it before we use it to take actual pics. Even if you do not have the original camera, If you have the checkerboard images taken from that camera it is sufficient. Otherwise, look for a similar camera with features as similar as possible (focal length etc.) to take checker board images for calibration and this will somewhat serve your purpose.","Q_Score":0,"Tags":"python,opencv,image-processing,camera,camera-calibration","A_Id":59678540,"CreationDate":"2020-01-10T09:01:00.000","Title":"Camera Calibration basic doubts","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install a 3.6 python version on a RHEL 4 Enterprise edition that already have a 2.3 python version, however, I have no internet access nor a root access?\nAlso I'd like to install some libraries the same conditions applied.\nI'm a beginner so please help me","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":59679970,"Users Score":0,"Answer":"My guess is that RHEL 4 is 16+ years old and Python 3 didn't exist then. Can you install a newer RHEL version via a usb\/other? The latest version is RHEL 8.","Q_Score":0,"Tags":"python,python-3.x,rhel","A_Id":59694312,"CreationDate":"2020-01-10T10:37:00.000","Title":"How to Install Python 3.6 on RHEL 4 Enterprise Edition without Internet Access and no root access?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to create a binary 16*15 matrix with certain conditions. I use binary strings to make the matrix. I want my matrix to be as described:\n-The first and last two elements of each row must be alternative.\n-the sum of each row must be 8 or 7.\n-in each row, there should not be consecutive 1s or 0s. (one couple(00 or 11) is allowed in each row) .\n-the sum of the columns must be 8.\nthere are 26 possible strings that can fulfill the first 3 conditions.how can I fulfill the last conditions? \nI have a code but it is not working because it takes so much time and it is almost impossible.is there any other way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":122,"Q_Id":59683287,"Users Score":1,"Answer":"I don't think you need any constraint to fulfill the last conditions. Columns = 8, which is just half of 16. You can just simply copy the first 8 rows to the last 8 rows and reverse all the 0 and 1, then the column sum would be 8 and the first three conditions are met.","Q_Score":0,"Tags":"python,constraints,binary-matrix","A_Id":59684408,"CreationDate":"2020-01-10T14:04:00.000","Title":"random binary matrix with restrictions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Looks like since 2020 elastalert fails when it's imported\nlog says: cannot import monotonic from time","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":199,"Q_Id":59684665,"Users Score":2,"Answer":"Elastalert doesn't pin \"stomp\" lib version and \"stomp\" has released a new version which doesn't support python2.\nYou can just add in your requirements.txt the \"stomp\" lib pinning the version 4.1.22 or lower.\nstomp.py==4.1.22","Q_Score":2,"Tags":"python,elasticsearch,python-2.x,elastalert","A_Id":59684666,"CreationDate":"2020-01-10T15:34:00.000","Title":"Elastalert fails importing monotonic from time in module stomp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed python 3.7.4 (64 bit) and oracle client 12.2.0 (64 bit) in my machine which is having windows 10 operating system. \nAnd I connect to database via robotframework-databaselibrary=1.2.4, but its displayed error as DatabaseError: DPI-1050: Oracle Client library is at version 0.0 but version 11.2 or higher is needed\nNote: I have the same setup in my local and am able to connect to database successfully but when I implement the same setup and try to execute in remote machine its throwing error","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":164,"Q_Id":59685699,"Users Score":2,"Answer":"The likely issue is that you have an Oracle Client library that is too old earlier in the PATH than your 12.2 Oracle Client. If you upgrade to cx_Oracle 7.3 you should get an error message that says as much. Search all of the directories in your PATH environment variable for oci.dll and check the version of each of them. Frequently older versions of the Oracle Client library were placed in C:\\Windows\\System32.","Q_Score":0,"Tags":"python-3.x,oracle,robotframework,cx-oracle,oracleclient","A_Id":59720970,"CreationDate":"2020-01-10T16:42:00.000","Title":"'DatabaseError: DPI-1050: Oracle Client library is at version 0.0 but version 11.2 or higher is needed' error is displayed in remote machine","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I was using pythonV3 for the past few months. But then I somehow messed up my Python installation.\nSo I decided to start from scratch: I uninstalled all Python from my computer and reinstalled Python3.8.1. Or at least I thought I did.\nWhen I try to check which version of Python I have by using the python --version or python3 --version commands, I get no message at all. No error message and no confirmation message.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6592,"Q_Id":59687025,"Users Score":4,"Answer":"I uninstalled Python one more time and then re-installed. But this time, I checked the box that \"Added Python to PATH\". \nNow, the command \"python --version\" returns the expected Python 3.8.1.\nThe only reason I did not check the box the first time around was because I thought it was better\/best practice to stick with whatever defaults the installation dialog box came with.","Q_Score":1,"Tags":"python,python-3.x,installation","A_Id":59687469,"CreationDate":"2020-01-10T18:18:00.000","Title":"`python --version` not returning any result","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a cyber security project wherein we have to prioritize vulnerabilities based on the existing features which are mostly categorical variables (also including couple of ordinal variables). \nThe objective here is to detect vulnerability that is most likely to be exploited, and thereby prioritizing it. Hence we have to predict a score of 0-10 . Whichever is the highest rating that we predict (in this case 10), will be the most critical vulnerability that needs immediate attention.\nAll that we have are the categorical variables (as input features).\nOnce again summarizing the problem here :\nCurrent Input features : All categorical variables (with couple of ordinal variables)\nCurrent Output feature : DOES NOT EXIST\nExpected Output : Predict a score in the range 0-10, with 10 being most critical vulnerability \nNever came across this kind of problem. It definitely looks like Regression is not the answer. Can you please share your thoughts on the same.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":59687810,"Users Score":0,"Answer":"I may be misunderstanding but it appears that you don't have the necessary information to make the prediction.\nMy understanding is that you have category information but no other associations. For some categories you might be able to hard code your prediction based on expert opinion. Predicting a ping sweep is basically benign, for example, just by knowing what it's called. For anything more dynamic you're going to need more information than you listed.","Q_Score":0,"Tags":"python,machine-learning,predict,continuous","A_Id":59687911,"CreationDate":"2020-01-10T19:21:00.000","Title":"How to predict a continuous variable without any output data ? All i have is Input data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install scikit learn on Pycharm but it always shows an error:\n\" numpy.distutils.system_info.NotFoundError: No lapack\/blas resources found. \"\nAlso, pycharm is not able to recognize pre-installed libraries(basically I installed some libraries  eg. numpy scikit learn using pip in cmd)\nit is not able to install other libraries such as matplotlib. \nThe only library it installed is numpy, pandas.\nthe project interpreter is correct, but still, i am getting an error while installing these libs.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1024,"Q_Id":59691800,"Users Score":0,"Answer":"In PyCharm go to File -> Settings -> Project -> Project Interpreter. Click on the + sign on the right hand side of the window. Type the name of the library you want to install and PyCharm will add it for you.\nWhen PyCharm is unable to make that installation, it usually has to do with your virtual environment not being set up correctly.","Q_Score":1,"Tags":"python,scikit-learn,pycharm","A_Id":59691992,"CreationDate":"2020-01-11T05:01:00.000","Title":"not able to install scikit-learn on pycharm on windows","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset of dialogues with various parameters (like if it is a question, an action, what emotion it conveys etc ). I have 4 different \"informations\" per sentence.\nlet s say A replys to B\nA has an additive parameter in a different list for its possible emotions (1.0.0.0) (angry.happy.sad.bored) - an another list for it s possible actions (1.0.0.0) (question.answer.inpulse.ending)\nI know how to build a regular RNN model (from the tutorials and papers I have seen here and there), but I can t seem to find a \"parameters\" architecture.\nShould I train multiple models ? (like sentence A --> emotions, then sentence B -->actions) then train the main RNN separately and predicting the result through all models ?\nor is there a way to build one single model with all the information stored right at the beginning ?\nI apologize for my approximate English, witch makes my search for answers even more difficult.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":59692913,"Users Score":0,"Answer":"From the way I understand your question, you want to find emotions\/actions based on a particular sentence. Sentence A has emotions as labels and Sentence B has actions as labels. Each of the labels has 4 different values with a total of 8 values. And you are confused about how to implement labels as input.\nNow, you can give all these labels their separate classes. Like emotions will have labels (1.2.3.4) and actions will have labels (5.6.7.8). Then concat both the datasets and run Classification through RNN.\nIf you need to pass emotions\/actions as input, then add them to vectorized matrix. Suppose you have Sentence A stating \"Today's environment is very good\" with happy emotion. Add the emotion with it's matrix row, like this:\nToday | Environment | very | good | health\n1     | 1           | 1    | 1    | 0  \nNow add emotion such that:\nToday | Environment | very | good | health | emotion\n1     | 1           | 1    | 1    | 0      | 2(for happy)\nI hope this answers your question.","Q_Score":2,"Tags":"python,tensorflow,keras,deep-learning,artificial-intelligence","A_Id":59693366,"CreationDate":"2020-01-11T08:50:00.000","Title":"NLP AI logic - dialogue sequences with multiple parameters per sequence architecture","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some data {x_i,y_i} and I want to fit a model function y=f(x,a,b,c) to find the best fitting values of the parameters (a,b,c); however, the three of them are not totally independent but constraints to 1<b , 0<=c<1 and g(a,b,c)>0, where g is a \"good\" function. How could I implement this in Python since with curve_fit one cannot put the parametric constraints directly?\nI have been reading with lmfit but I only see numerical constraints like 1<b, 0<=c<1 and not the one with g(a,b,c)>0, which is the most important.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":672,"Q_Id":59694481,"Users Score":-1,"Answer":"Like James Phillips, I was going to suggest SciPy's curve_fit.  But the way that you have defined your function, one of the constraints is on the function itself, and SciPy's bounds are defined only in terms of input variables.\nWhat, exactly, are the forms of your functions?  Can you transform them so that you can use a standard definition of bounds, and then reverse the transformation to give a function in the original form that you wanted?\nI have encountered a related problem when trying to fit exponential regressions using SciPy's curve_fit.  The parameter search algorithms vary in a linear fashion, and it's really easy to fail to establish a gradient.  If I write a function which fits the logarithm of the function I want, it's much easier to make curve_fit work.  Then, for my final work, I take the exponent of my fitted function.\nThis same strategy could work for you.  Predict ln(y).  The value of that function can be unbounded.  Then for your final result, output exp(ln(y)) = y.","Q_Score":0,"Tags":"python,curve-fitting,non-linear-regression","A_Id":59707606,"CreationDate":"2020-01-11T12:41:00.000","Title":"Fitting with funtional parameter constraints in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two pieces of code that require different versions of python and versions of packages. I have two conda environments that allow each piece of code to work separately. It seems impossible to create an environment that will support both of them. Is there a way to switch conda environment during the run (in python code), so that I could execute one part using one environment and the second part using the second environment in the same script? The form and format of the result of the first part is definitely supported by the second part, so I don't see a reason why it can't work.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":531,"Q_Id":59694852,"Users Score":0,"Answer":"If you want to change the environments in the same code at the same time, unfortunately as far as I know that will be painful, or just impossible with one word. In order to fix this issue, just add the libraries that your other environment has into the one that you use mainly.\nYou can achieve this by opening either your cmd (commnand line prompt), or just anaconda prompt:\n activate yourenvironment name\n pip\/pip3 install modulename","Q_Score":0,"Tags":"python,package,conda","A_Id":59695191,"CreationDate":"2020-01-11T13:28:00.000","Title":"Change conda environment during execution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"tf 2.0.0-gpu\nCUDA 10.0\nRTX2070super\nhi. i got a problem regarding allocating gmemory. The initial allocation of memory is 7GB like this.\nCreated TensorFlow device (\/job:localhost\/replica:0\/task:0\/device:GPU:0 with 6994 MB memory)\n2020-01-11 22:19:22.983048: I tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7\n2020-01-11 22:19:23.786225: I tensorflow\/stream_executor\/cuda\/cuda_driver.cc:830] failed to allocate 2.78G (2989634304 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY: out of memory\n2020-01-11 22:19:24.159338: I tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10.0\nLimit:                  7333884724\nInUse:                  5888382720\nMaxInUse:               6255411968\nNumAllocs:                    1264\nMaxAllocSize:           2372141056\nbut i can only use 5900MB memory and the rest of memory always fails to be allocated.\ni guess that if whole gpu memory is used in rtx 2070s, i use 2 types data typse(float16, float32). so i got a policy by using this codes\nopt = tf.keras.optimizers.Adam(1e-4)\nopt = tf.train.experimental.enable_mixed_precision_graph_rewrite(opt)\nStill, the allocation always fails.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1026,"Q_Id":59694874,"Users Score":0,"Answer":"Tensorflow memory management can be frustrating.\nMain takeaway: whenever you see OOM there is actually not enough memory and you either have to reduce your model size or batch size. TF would throw OOM when it tries to allocate sufficient memory, regardless of how much memory has been allocated before.\nOn the start, TF would try to allocate a reasonably large chunk of memory which would be equivalent to about 90-98% of the whole memory available - 5900MB in your case. Then, when actual data starts to take more than that, TF would additionally try to allocate sufficient amount of memory or a bit more -  2.78G. And if that does not fit it would throw OOM, like in your case. Your GPU could not fit 5.9+2.8Gb. The last chunk of 2.78G might actually be a little more than TF needs, but it would anyhow be used later if you have multiple training steps because maximum required memory can fluctuate a bit between identical Session.run's.","Q_Score":0,"Tags":"python,tensorflow","A_Id":59699915,"CreationDate":"2020-01-11T13:32:00.000","Title":"rtx 2070s failed to allocate gpu memory from device:CUDA_ERROR_OUT_OF_MEMORY: out of memory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was not able to solve this for days, so if you can give me any advice I would appreciate it!\nWhen I try to install any package from python I get this message (in this case lets take flask for example):\n\nRetrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': \/simple\/flask\/\n    Could not find a version that satisfies the requirement Flask (from versions: )\n  No matching distribution found for Flask \"\n\nI do not really understand what caused it because previously everything worked well and I was able to install packages. And, I did not install anything new in between. Also, I am really a beginner in python programming and I do not fully understand what exactly the message is trying to say. I definitely have an internet connection and I have installed e.g. Flask previously and have used it as well. The only thing that happened before everything got stack was that my internet provider has \"rebooted\" my internet connection (I am not sure that \"reboot\" is the right termini for that).\nI am using Windows subsystem for Linux, Visual studio code and python version: Python 3.6.8 (default, Oct  7 2019, 12:59:55) [GCC 8.3.0] on Linux.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":337,"Q_Id":59696225,"Users Score":0,"Answer":"I solved it by adding: \nnameserver 8.8.8.8\nnameserver 8.8.4.4\nto the file:\n\/etc\/resolv.conf \n(via $sudo nano \/etc\/resolv.conf and save)\nBUT I still do not understand fully why it worked? and Where came the problem from?","Q_Score":0,"Tags":"python,flask,windows-subsystem-for-linux","A_Id":59697800,"CreationDate":"2020-01-11T16:16:00.000","Title":"Installation of python packages from terminal started to fail, Failed to establish a new connection: [Errno -3] Temporary failure in name resolution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a C++ application which generates a stream of AVFrame objects and I want to pass them in realtime to a Python application for further processing, e.g. using OpenCV.\nWhat is the best way of doing this? Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":59696325,"Users Score":0,"Answer":"If you are in a Unix or Linux based system, you can use a pipe. You also can use the local socket to transmit the stream.","Q_Score":0,"Tags":"python,c++,ffmpeg,video-streaming","A_Id":59711018,"CreationDate":"2020-01-11T16:27:00.000","Title":"Best way to stream FFMpeg AVFrame objects from a C++ application to 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 launched a notebook with GCP AI Platform. Then, I tried to install tensorflow by:\nimport tensorflow as tf\nThere is an error message of \n\nNo module named 'tensorflow' \n\nI tried to install it by:\n!pip install -U --user tensorflow==1.14.0\nBut the same error message appeared. As it is a GCP platform, I wonder why I need to install tensorflow. During Coursera training, I can import tensorflow directly without installation. I wonder if I missed anything.\nGrateful if you can help.\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":358,"Q_Id":59697085,"Users Score":0,"Answer":"You have probably selected an instance type that doesn't have tensorflow pre-installed. \nAfter you install a Python dependency you will have to restart the Python Kernel for updates to take effect by clicking on Kernel->Restart Kernel....","Q_Score":0,"Tags":"tensorflow,google-cloud-platform,installation,python-import,gcp-ai-platform-notebook","A_Id":59703393,"CreationDate":"2020-01-11T17:50:00.000","Title":"error message of No module named 'tensorflow' in GCP AI Platform Notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to python and I'm having fun. So far I've only been on the road in VBA and SQL, but one thing bothers me. Is there no feature that goes through the code line by line like in VBA? This has always helped me a lot with VBA (F8), I could check the value of the variable on the fly (hold mouseover), i could check the whole code better and see where exactly it is running on a bug. Is this function not really available in python? I use PyCharm as IDE\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":423,"Q_Id":59697195,"Users Score":0,"Answer":"There is nothing like VBA\/VB6 IDE for python, unfortunately. Microsoft's IDE is simply unmatched in terms of debugging convenience. As a language, Python is more powerful, but good debugging solution is yet to come, you can't chance lines execution order or alter code on the fly in the debugger.","Q_Score":3,"Tags":"python,ide","A_Id":71236794,"CreationDate":"2020-01-11T18:04:00.000","Title":"Execute Python code line by line, like VBA?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a Speech Recognition System, which is a squence-to-sequence model. But I got confused about how to feed the extracted feature(fbank with the dimension of 40) to LSTM. As far as I have found, there are different methods to feed the data as input into LSTM. However, I have a doubt to fully understand them. I would be so thankful if someone tells me whether or not I am correct in the following cases.\nCase 1:\nIn the convenient format [Batch_Size, Time_Step, Feature_Dim], If I select [1, None, 40], the length of each sequence(utterance) can be varied? if so, in this case I do not need to pad each sequence, am I right?\nCase 2: \nIf all input sequences are padded to the same length, the Batch_Size can be any value like 64, 128 and etc?\nFinally, one more question, do I notice that the Time_Step in each Batch should be the same?\nI would be so thankful if someone can help me to get rid of my doubts or give me some suggestions.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":327,"Q_Id":59697342,"Users Score":0,"Answer":"it depends on how your system built is it end-to-end training or did u use hand-engineering features such MFCC? one more note the main use of RNN's is to have a variable-length input.","Q_Score":0,"Tags":"python,speech-recognition,lstm,recurrent-neural-network,speech-to-text","A_Id":59744476,"CreationDate":"2020-01-11T18:22:00.000","Title":"How to feed variable-length of speech feature to RNN(LSTM) for Speech Recognition?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recently started to learn python programming using Python Crash Course. I am stuck as I can't get matplotlib to work in pycharm. \nI have pip installed.\nI have installed matplotlib using pip via command prompt. \nNow, when I open pycharm and go file->settings->project interpreter->download packages and find and press install for matplotlib, I get an error: Command \"python setup.py egg_info\" failed with error code 1 in C:\\Users\\Tony\\AppData\\Local\\Temp\\pip-install-f2h0rvbb\\matplotlib\\ . When installing on pycharm it says its using cached file from website I didn't download my matplotlib from.\nI have tried \"pip install matplotlib\" from  pycharm terminal and get the same error.\nI have tried typing \"pip install matplotlib\" from cmd and it does so and says its already satisfied.\nAny help or guidance would be appreciated, thanks.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":13293,"Q_Id":59697580,"Users Score":5,"Answer":"Managed to get it to work by typing into pycharm terminal:\npip install updates\nThen I went to file->settings->project interpreter-> then found pip via search and updated it again to be more sure. Once pip version on left hand side of column in file->settings->project interpreter showed the version to be the newest 20.0.2 which was == to the right hand side(latest version) column it was 100% updated.  This can be done also by pressing the upgrade button just above the 'show early releases' button which looks like an eye just to the right of the right hand side column when you have already clicked on the package. \nTo finish I went file->settings->project interpreter-> found matplotlib and installed package successfully.\nOverall I think that not having an up to date version of pip being used for pycharm and having to update the one specifically for use in pycharm is responsible not being able to install matplotlib.\nAlthough it could have also been due to having downloaded pip separately elsewhere on my system trying to solve this problem and when I have updated pip before from cmd.exe it didn't update the correct version of pip which I am using for Pycharm.","Q_Score":4,"Tags":"python,matplotlib,pycharm","A_Id":60311161,"CreationDate":"2020-01-11T18:51:00.000","Title":"Can't install matplotlib to pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recently started to learn python programming using Python Crash Course. I am stuck as I can't get matplotlib to work in pycharm. \nI have pip installed.\nI have installed matplotlib using pip via command prompt. \nNow, when I open pycharm and go file->settings->project interpreter->download packages and find and press install for matplotlib, I get an error: Command \"python setup.py egg_info\" failed with error code 1 in C:\\Users\\Tony\\AppData\\Local\\Temp\\pip-install-f2h0rvbb\\matplotlib\\ . When installing on pycharm it says its using cached file from website I didn't download my matplotlib from.\nI have tried \"pip install matplotlib\" from  pycharm terminal and get the same error.\nI have tried typing \"pip install matplotlib\" from cmd and it does so and says its already satisfied.\nAny help or guidance would be appreciated, thanks.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":13293,"Q_Id":59697580,"Users Score":1,"Answer":"Although little late to answer but changing version for python from 3.8 to 3.7 worked for me.","Q_Score":4,"Tags":"python,matplotlib,pycharm","A_Id":62145398,"CreationDate":"2020-01-11T18:51:00.000","Title":"Can't install matplotlib to pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recently started to learn python programming using Python Crash Course. I am stuck as I can't get matplotlib to work in pycharm. \nI have pip installed.\nI have installed matplotlib using pip via command prompt. \nNow, when I open pycharm and go file->settings->project interpreter->download packages and find and press install for matplotlib, I get an error: Command \"python setup.py egg_info\" failed with error code 1 in C:\\Users\\Tony\\AppData\\Local\\Temp\\pip-install-f2h0rvbb\\matplotlib\\ . When installing on pycharm it says its using cached file from website I didn't download my matplotlib from.\nI have tried \"pip install matplotlib\" from  pycharm terminal and get the same error.\nI have tried typing \"pip install matplotlib\" from cmd and it does so and says its already satisfied.\nAny help or guidance would be appreciated, thanks.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":13293,"Q_Id":59697580,"Users Score":0,"Answer":"Other way this worked for me.\nCheck for pip version if it's latest the downgrade it and then install matplotlib","Q_Score":4,"Tags":"python,matplotlib,pycharm","A_Id":63669380,"CreationDate":"2020-01-11T18:51:00.000","Title":"Can't install matplotlib to pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Essentially , what I want to do is , press a button that I program in Flutter and when that button is pressed , a python script should start running on my Android device . \nI want to use youtube-dl (used to download Youtube videos) library in python but I wanna know if there is a way to run the library in flutter . \nAny Help is appreciated . Thanks in advance .","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":12878,"Q_Id":59697971,"Users Score":1,"Answer":"I think you should create a flask API in python and deploy it in the Heroku platform. After getting the endpoint of that API you can request that API in flutter easily.","Q_Score":13,"Tags":"python,android,android-studio,flutter,youtube-dl","A_Id":71706682,"CreationDate":"2020-01-11T19:33:00.000","Title":"Is there a way I can run a python Script when a button programmed in flutter is pressed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In pika, I have called channel.confirm_delivery(on_confirm_delivery) in order to be informed when messages are delivered successfully (or fail to be delivered). Then, I call channel.basic_publish to publish the messages. Everything is performed asynchronously.\nHow, when the on_confirm_delivery callback is called, do I find what the concerned message? In the parameters, The only information that changes in the object passed as a parameter to the callback is delivery_tag, which seems to be an auto-incremented number. However, basic_publish doesn't return any delivery tag.\nIn other words, if I call basic_publish twice, how do I know, when I receive an acknowledgement, whether it's the first or the second message which is acknowledged?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":59698487,"Users Score":1,"Answer":"From RabbitMQ document, I find: \n\nDelivery tags are monotonically growing positive integers and are presented as such by client libraries.\n\nSo you can keep a growing integer in your code per channel, set it to 0 when channel is open, increase it when you publish a message. Then this integer will be same as the delivery_tag.","Q_Score":0,"Tags":"python,rabbitmq,pika","A_Id":59702401,"CreationDate":"2020-01-11T20:43:00.000","Title":"How to identify the message in a delivery notification?","Data Science and Machine Learning":0,"Database and SQL":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":"trying to install jupyter. I tryied writing pip install jupyter in terminal. Tried doing it through settings, tried clicking notification that jupyter is not installed but I keep getting same error that in the end says:\n\nCould not find a version that satisfies the requirement pywin32>=1.0; sys_platform == \"win32\" (from jupyter-core>=4.6.0->notebook->jupyter) (from versions: )\nNo matching distribution found for pywin32>=1.0; sys_platform == \"win32\" (from jupyter-core>=4.6.0->notebook->jupyter)\n\nI appreciate any help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1718,"Q_Id":59699107,"Users Score":0,"Answer":"For now it seems that python 3.8 does not support jupyter or smth like that. So just install python 3.7.6","Q_Score":0,"Tags":"python,pip,jupyter-notebook","A_Id":59699538,"CreationDate":"2020-01-11T22:13:00.000","Title":"\"Could not find a version that satisfies the requirement pywin32>=1.0\" - Jupiter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let X be a variable I have stored in multiple files. In each files, X has dimension of (time, depth, latitude, longitude). I wish to do a yearly average, and each file store a year of data.\nTo be efficient, I open the data with X = xarray.open_mfdataset('path'+'year_*_X.nc').\nI do not want to average all the time axis, i.e.: X.mean(dim='time').\nI observe that X store 'chunks' since it gives the 'chunksize', so maybe it can be used to average the time dimension of each chunks?\nIn [1] : X\nOut[1] : <xarray.DataArray 'ty_trans_submeso' (time: 240, st_ocean: 50, yu_ocean: 200, xt_ocean: 360)>\ndask.array<shape=(240, 50, 200, 360), dtype=float32, chunksize=(12, 50, 200, 360)>","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":139,"Q_Id":59699168,"Users Score":1,"Answer":"X.groupby('time.year').mean(dim='time') should do the trick as long as time is a datetime64 object.","Q_Score":0,"Tags":"python-xarray","A_Id":59707182,"CreationDate":"2020-01-11T22:23:00.000","Title":"Average a dimension of a chunk (xarray)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using an HTML5 audio player to play audio content in a python\/flask web application. I can display the current time and duration just fine on my web page, but now I want to get the current time of playback when a submit button is clicked. I also want to get the duration of the audio file.\nHow do I get these two pieces of information into Python? Do I need to pass it into a form (e.g., DecimalField from WTForms)? Is it a task for Beautiful Soup? I'm not quite sure what to do. I have reviewed many other questions, but they all seem to be about displaying the data, not passing it into Python so it can be manipulated.\nFWIW, I am using Python, Flask, SQLAlchemy, HTML....\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":87,"Q_Id":59700594,"Users Score":0,"Answer":"I solved this issue. What I did was use javascript to obtain the currentTime of the html audio file upon click of a button and pass the value to a hidden html input field on a flask form. Then on another button click I submit the value to Python. I'm sure this solution is specific to my application, but I'm happy to answer questions if others have trouble.","Q_Score":1,"Tags":"python,html,flask,web-applications,html5-audio","A_Id":59736076,"CreationDate":"2020-01-12T03:05:00.000","Title":"Getting HTML5 audio \"currentTime\" and \"duration\" into Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"11am \u2013 4pm, 7:30pm \u2013 11:30pm (Mon-Sun)------(this is opening and closing time of restaurant)\n  [i have this kind of format in my TIME column and this is not converting into datetime format...so how to prepare the data so that i can apply linear regression???]\n\nValueError: ('Unknown string format:', '11am \u2013 4pm, 7:30pm \u2013 11:30pm (Mon-Sun)')","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":678,"Q_Id":59703260,"Users Score":0,"Answer":"From my understanding, datetime format requires the 24h format, or - 00:00:00\nSo instead of 7:30pm, it would be 19:30:00.","Q_Score":0,"Tags":"python,machine-learning","A_Id":59703309,"CreationDate":"2020-01-12T11:18:00.000","Title":"how to set the format for date time column in jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to set up a wx.dataview.DataViewListCtrl. I have multiple columns with text content. Some Entries of the first column are wider than the selected default width. They are cut off. I could set the column width by hand but I like to set it up automatically to the maximum content or header width. Is there an automated way to do so? If not, how can I calculate the ideal width. I'm on Ubuntu Linux. The used backend is gtk. A C++ answer using wxDataViewListCtrl could help, too. I'm able to translate it.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":598,"Q_Id":59703405,"Users Score":2,"Answer":"You can set the column width to wxCOL_WIDTH_AUTOSIZE (probably mapped to wx.COL_WIDTH_AUTOSIZE in Python) to make it fit its existing elements.","Q_Score":1,"Tags":"python,python-3.x,wxpython,wxwidgets","A_Id":59735996,"CreationDate":"2020-01-12T11:37:00.000","Title":"Set column width to maximum content or header width for a wx.dataview.DataViewListCtrl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm sorry, i know that this is a very basic question but since i'm still a beginner in machine learning, determining what model suits best for my problem is still confusing to me, lately i used linear regression model (causing the r2_score is so low) and a user mentioned i could use certain model according to the curve of the plot of my data and when i see another coder use random forest regressor (causing the r2_score 30% better than the linear regression model) and i do not know how the heck he\/she knows better model since he\/she doesn't mention about it. I mean in most sites that i read, they shoved the data to some models that they think would suit best for the problem (example: for regression problem, the models could be using linear regression or random forest regressor) but in some sites and some people said firstly we need to plot the data so we can predict what exact one of the models that suit the best. I really don't know which part of the data should i plot? I thought using seaborn pairplot would give me insight of the shape of the curve but i doubt that it is the right way, what should i actually plot? only the label itself or the features itself or both? and how can i get the insight of the curve to know the possible best model after that?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":59705218,"Users Score":0,"Answer":"If you are using off-the-shelf packages like sklearn, then many simple models like SVM, RF, etc, are just one-liners, so in practice, we usually try several such models at the same time.","Q_Score":0,"Tags":"python,machine-learning,plot,prediction","A_Id":59709870,"CreationDate":"2020-01-12T15:18:00.000","Title":"Which data to plot to know what model suits best for the problem?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm sorry, i know that this is a very basic question but since i'm still a beginner in machine learning, determining what model suits best for my problem is still confusing to me, lately i used linear regression model (causing the r2_score is so low) and a user mentioned i could use certain model according to the curve of the plot of my data and when i see another coder use random forest regressor (causing the r2_score 30% better than the linear regression model) and i do not know how the heck he\/she knows better model since he\/she doesn't mention about it. I mean in most sites that i read, they shoved the data to some models that they think would suit best for the problem (example: for regression problem, the models could be using linear regression or random forest regressor) but in some sites and some people said firstly we need to plot the data so we can predict what exact one of the models that suit the best. I really don't know which part of the data should i plot? I thought using seaborn pairplot would give me insight of the shape of the curve but i doubt that it is the right way, what should i actually plot? only the label itself or the features itself or both? and how can i get the insight of the curve to know the possible best model after that?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":56,"Q_Id":59705218,"Users Score":1,"Answer":"This question is too general, but I will try to give an overview of how to choose the model. First of all you should that there is no general rule to choose the family of models to use, it is more a choosen by experiminting different model and looking to which one gives better results. You should also now that in general you have multi-dimensional features, thus plotting the data will not give you a full insight of the dependance of your features with the target, however to check if you want to fit a linear model or not, you can start plotting the target vs each dimension of the input, and look if there is some kind of linear relation. However I would recommand that you to fit a linear model, and check if if this is relvant from a statistical point of view (student test, smirnov test, check the residuals...). Note that in real life applications, it is not likeley that linear regression will be the best model, unless you do a lot of featue engineering. So I would recommand you to use more advanced methods (RandomForests, XGboost...)","Q_Score":0,"Tags":"python,machine-learning,plot,prediction","A_Id":59706610,"CreationDate":"2020-01-12T15:18:00.000","Title":"Which data to plot to know what model suits best for the problem?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've config my new computer to python env. Now the latest version of python is 3.8, can I create python2 visual env by venv instruction in python 3.8?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":62,"Q_Id":59705457,"Users Score":0,"Answer":"Python3 cannot create a Python2 environment.\nPython2 is officially end of life anyway, so best to create a Python3 virtualenv","Q_Score":0,"Tags":"python","A_Id":59705512,"CreationDate":"2020-01-12T15:44:00.000","Title":"Can I create python visual env by python 3.8.1?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am not able to display the charts on jupyter notebook. The same code displays on chrome in one laptop but does not work on chrome on other laptop. \nI do not see any error or even a empty plot when I execute the code but get alt.Chart(...) in the output.\nThe version of altair and vega etc are same on both the laptops.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2841,"Q_Id":59705914,"Users Score":1,"Answer":"For 'altair' version of '4.1.0',\n'vega' version of '3.4.0'\njust do alt.renderers.enable('default') instead of\nalt.renderers.enable('notebook')","Q_Score":1,"Tags":"python,jupyter-notebook,altair","A_Id":63711303,"CreationDate":"2020-01-12T16:35:00.000","Title":"Not able to display altair charts in jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm getting server error(500) after I set DEBUG to False, both in local and after deploying to Heroku.\nEverything is Ok when DEBUG mode is True.\nThanks for help","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":59706099,"Users Score":0,"Answer":"Thanks for the answers, I have found the solution, the issue was with html template {% static %} tag.\nI had such line \n\nlink rel=\"shortcut icon\" href=\"{% static 'assets\/images\/39-1109688-140x140.png' type=\"image\/x-icon' %}\"\n\nbut the closing %} must be in front of type\n\nlink rel=\"shortcut icon\" href=\"{% static 'assets\/images\/39-1109688-140x140.png' %}\" type=\"image\/x-icon\"","Q_Score":0,"Tags":"python,django","A_Id":59707130,"CreationDate":"2020-01-12T16:57:00.000","Title":"Django DEBUG=False getting server 500 error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I tried to type pip install pipenv in Visual Studio Code, then i got 'pip' is not recognized as an internal or external command, operable program or batch file. So i was looking for some solution at the internet and there i found that i have to add path to windows enviroment variables. I found the pip file in location C:\\Users\\MyName\\AppData\\Local\\Programs\\Python\\Python38-32\\Scripts\\ and there are pip3.8, pip3, pip, pipenv and any other files. Also i found in location C:\\Users\\MyName\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts\\ files: pip, pip3.7, pip3(it is from older version of python i think). The current PATH in system enviroment variables is C:\\Users\\Patrik\\AppData\\Local\\Programs\\Python\\Python38-32\\Scripts\\pip3.8.exe. I tried to reinstall python, add pip during installation and nothing helped me to fix it.\nAny ideas guys?\nI'm using Windows 8.1 and Python 3.8","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":59706769,"Users Score":0,"Answer":"use use python -m pip install pipenv this will use your current system python pip version to install pipenv and you don't need to worry about the version","Q_Score":0,"Tags":"python,python-3.x,visual-studio-code,pip","A_Id":59706801,"CreationDate":"2020-01-12T18:14:00.000","Title":"many pip files, which is right?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've got 2 Python 3.6 pods currently running. They both used to run collectstatic upon redeployment, but then one wasn't working properly, so I deleted it and made a new 3.6 pod. Everything is working perfectly with it, except it no longer is running collectstatic on redeployment (so I'm doing it manually). Any thoughts on how I can get it running again? \nI checked the documentation, and for the 3.11 version of openshift still looks like it has a variable to disable collectstatic (which i haven't done), but the 4.* versions don't seem to have it. Don't know if that has anything to do with it. \nEdit: \nSo it turns out that I had also updated the django version to 2.2.7. \nAs it happens, the openshift infrastructure on openshift online is happy to collectstatic w\/ version 2.1.15 of Django, but not 2.2.7 (or 2.2.9). I'm not quite sure why that is yet. Still looking in to it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":59708655,"Users Score":0,"Answer":"Currently Openshift Online's python 3.6 module doesn't support Django 2.2.7 or 2.2.9.","Q_Score":0,"Tags":"django,openshift,python-3.6,openshift-3","A_Id":59978553,"CreationDate":"2020-01-12T22:30:00.000","Title":"Openshift online - no longer running collectstatic","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"my project run local on pycharm without error but when i deployed it on heroku\n error message appears :Importing the multiarray numpy extension module failed.\n i changed numpy version more than one but it does not work\nDjango Version:     2.2.5\nException Type:     ImportError\nException Value: Importing the multiarray numpy extension module failed.  Most\nlikely you are trying to import a failed build of numpy.\nIf you're working with a numpy git repo, try git clean -xdf (removes all\nfiles not under version control).  Otherwise reinstall numpy.\nOriginal error was: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory\nException Location:     \/app\/.heroku\/python\/lib\/python3.6\/site-packages\/numpy\/core\/init.py in , line 26\nPython Executable:  \/app\/.heroku\/python\/bin\/python\nPython Version:     3.6.10\nnumpy version : 1.18.1\nany solution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":322,"Q_Id":59709490,"Users Score":0,"Answer":"i solve it \nmy solution was\nRun locally   1- python -m pip install python-dev-tools\nthen  2- pip freeze > requirements.txt\n3-git add .\n4-git commit -m \"v5\"\n5- heroku git:remote -a \"your appname on heroku\"\n6-git push heroku master","Q_Score":0,"Tags":"python,numpy,heroku","A_Id":59742768,"CreationDate":"2020-01-13T00:59:00.000","Title":"Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"So an Entry widget's text can be retrieved using the .get method but my question is: \nCan you italicize the text that .get receives from the widget?\nAdding the font parameter to the Entry only changes the text displayed in the Entry and not its actual output that .get gives you, so I'm at a loss.\nWhat I'm actually trying to accomplish by doing this is italicizing only a certain part\/string of the text of an Entry field while keeping the other parts of the text unitalicized, so if you have any tips for doing that instead, I'd appreciate the help!\nThanks in advance for the advice!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":241,"Q_Id":59711487,"Users Score":1,"Answer":"What I'm actually trying to accomplish by doing this is italicizing only a certain part\/string of the text of an Entry field while keeping the other parts of the text unitalicized,\n\nThat is impossible. The Entry widget can only display text in a single font.\nIf you want to have multiple fonts, you will need to use either a Text or Canvas widget, with the Text widget being the easiest solution.","Q_Score":1,"Tags":"python,tkinter,tkinter-entry,text-formatting,italic","A_Id":59718311,"CreationDate":"2020-01-13T06:28:00.000","Title":"How can I italicize the resulting text from an Entry widget in tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a telegram to the bot.  I ran into such a problem.  I need the bot to send a message (text) when clicked on which it was copied (as a token from @BotFather)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":13652,"Q_Id":59713920,"Users Score":1,"Answer":"You can simply by editing the text in following manner\nWrite   ```   then write your text then again write that 3 character .\nBingo!!!","Q_Score":4,"Tags":"python,bots,telegram,telegram-bot,py-telegram-bot-api","A_Id":65958439,"CreationDate":"2020-01-13T09:40:00.000","Title":"How to make that when you click on the text it was copied pytelegrambotapi","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 anyway to do a one to one comparison between Pardot and Salesforce. I am aware that these two are synced, but I do not find the connected data very reliable. I am more interested in writing in a code in python by using Salesforce and Pardot API and do one to one comparison. Has anyone come across such situation?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":59716020,"Users Score":0,"Answer":"Yes, it is possible to write such code. You would need to be conscious of the limits both systems impost (governor limits of Salesforce, Pardot API record limits).\nAnother option for you is to check the Pardot field sync options for the mapping to see what is going on. If these are not set as you like, even the best script would not yield the results you are looking for and the data would just be overwritten.","Q_Score":0,"Tags":"python,api,salesforce,pardot","A_Id":60611151,"CreationDate":"2020-01-13T11:44:00.000","Title":"Comparing data in Salesforce and Pardot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to take an elf file and then based on the content add a section with data and add symbols.  Using objcopy --add-section I can add a section with the content that I would like. I cannot figure out how to add a symbol. \nRegardless, I would prefer not run a series of programs in order to do what I want but rather do it natively in c or python. In pyelftools I can view an elf, but I cannot figure out how to edit and elf. \nHow can I add custom sections and symbols in Python or C?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1560,"Q_Id":59717918,"Users Score":0,"Answer":"ELF has nothing to do with the symbols stored in it by programs.  It is just a format to encode everything.  Symbols are generated normally by compilers, like the C compiler, fortran compiler or an assembler, while sections are fixed by the programming language (e.g. the C compiler only uses a limited number of sections, depending on the kind of data you are using in your programs).  Some compilers have extensions to associate a variable to a section, so the linke will consider it special in some way.  The compiler\/assembler generates a symbol table in order for the linker to be able to use it to resolve dependencies.\nIf you want to add symbols to your program, the easiest way it to create an assembler module with the sections and symbols you want to add to the executable, then assemble it and link to the final executable.\nRead about ld(1) program (the linker), and how it uses the link scripts (special hidden files that direct the linker on how to organize the sections in the different modules at link time) to handle the sections in an object file.  ELF is just a format.  If you use a link script and the help of the assembler, you'll be able to add any section you want or modify the normal memory map that programs use to have.","Q_Score":3,"Tags":"python,c,elf","A_Id":59764024,"CreationDate":"2020-01-13T13:47:00.000","Title":"How to edit ELF by adding custom sections and symbols","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Recently I took over Django project whose one component is Scrapy scrapprs (a lot of - core functionality). It is worth adding that scrapers simply feed the database several times a day and django web app is using this data.\n__Scraper__s have direct access to Django model, but in my opinion is not the best idea (mixed responsibilities - django rather should act as a web app, not also scrapers, isn't it?). For example after such split scrapers could be run serverless, saving money and being spawned only when needed.\nI see it at least as separate component in the architecture. But if I would separate scrapers from Django website then I would need to populate DB there as well - and change in model either in Django webapp or in scraping app would require change in second app to adjust.\nI haven't seen really articles about splitting those apps.\nWhat are the best practices here? Is it worth splitting it? How would you organise deployment to cloud solution(e.g. AWS)?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":210,"Q_Id":59719318,"Users Score":1,"Answer":"Well, this is a big discussion and I have the same \"good problem\".\nShort answer: \nI suggest you that if you want to separate it, you can separate the logic from the data using different schemes. I did it before and is a good approach.\nLong answer:\nThe questions are: \n\nOnce you gather information from scrapers, are you doing something with them (Aggregation, treatment, or anything else)? \n\nIf the answer is yes, you can separate it in 2 DB. One with the raw information and the other with the treated one (which will be the shared with Django).\nIf the answer is no, I don't see any reason to separate it. At the end, Django is only the visualizer of the data.\n\nThe Django website is using a lot of stored data that for the Single Responsibility you want to separate it from the scraped data?\n\nIf the answer is yes, separate it by schemas or even DB.\nIf the answer is no, you can store it in the same DB of Django. At the end, the important data will be the extracted data. Django maybe will have a configuration's DB or other extra data to manage the web, but the big percentage of the DB will be the data crawled\/treated. Depends how much cost it will take you to separate it and maintain. If you are doing from the beginning, I would do it separately.","Q_Score":1,"Tags":"python,django,web-scraping,architecture,scrapy","A_Id":59731276,"CreationDate":"2020-01-13T15:15:00.000","Title":"Django + Scrapy multi scrapers architecture","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How should a beginner start learning Google Earth Engine coding with python using colab? I know python, but how do I come to know about the objects of images and image classification.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":652,"Q_Id":59721248,"Users Score":0,"Answer":"i use geemap package for convert shape file to earth engine variable without uploading file on assets","Q_Score":2,"Tags":"python,google-earth-engine","A_Id":62147312,"CreationDate":"2020-01-13T17:24:00.000","Title":"Google Earth Engine using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to predict the winner of the Australian Open 2020. My dataset has these features: Location \/ Tournament \/ Date \/ Series \/ Court \/ Surface \/ Round \/ Winner \/ Loser etc. \nI trained my model using just these features 'Victory','Series','Court','Surface','WinRank','LoseRank','WPts','LPts','Wsets','Lsets','Weather' and I have a 0.93 accuracy but now I have to predict the name of the winner and I don't have any idea how to do it based on the model that I trained. \nExample:  If I have Dimitrov G. vs Simion G using random forest the model has to give me one of them as the winner of the match. \nI transformed the names of the players in dummy variables but after that, I don't know what to do? \nCan anyone give me just an idea of how could I predict the winner? so I can create a Tournament, please?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":59722197,"Users Score":0,"Answer":"To address such a problem, I would suggest creation of a custom target variable. \nFirstly, the transformation of names of players into dummy variables seems reasonable (Just make sure, the unique player is identified with the same first and last name combinations thereby, avoiding duplications and thus, having the correct dummy code for the player name).\nNow, to create the target variable \"wins\" - \n\nUse the two player names - P1, P2 of the match as input features for your model.\nDefine the \"wins\" as 1 if P1 wins and 0 if P2 wins.\nRun your model with this set up. \nWhen you want to create a tournament and predict the winner, the inputs will be your 2 players and other match features. If, \"wins\" is close to 1, it means your P1 wins and output that player name.","Q_Score":0,"Tags":"python,machine-learning","A_Id":59722344,"CreationDate":"2020-01-13T18:30:00.000","Title":"How to predict the player using random forest ML","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing some code in a standard python 3.8 shell and I want to print('\\a') which plays a ding sound on your computer. This works in a thonny python shell but will not work in any other python shell. Does anyone know why?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":203,"Q_Id":59724935,"Users Score":2,"Answer":"Printing '\\a' is not supported by IDLE. (I think that '\\r' and '\\b' also do not work properly.)","Q_Score":1,"Tags":"python,printing","A_Id":59725031,"CreationDate":"2020-01-13T22:14:00.000","Title":"Why is print('\\a') not working in my python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sample Text:\n\n\"UNCKEV\\nPumpkins 10\/1\/20-2030\\nRunners\\nha\\nH[ 12 ]\\nA[ O\n  ]\\nKNOWLEDGI\\nPLA\\nDISTRIBUTION\\nHOME TEAM\\nPINK VISITING\n  TEAM\\nBLANCHE BUREAU NATIONAL\\nJAUNE \\u00c9C\\nALE\\nPR\\u00c9CISER LES\n  DE\\nSEULEMENT\\nOFF\\nSORTIE\\nSTART\\nD\\u00c9BUT\\nON\\nRETOUR\\nPER\\nP\\u00c9R.\\nMIN\\nSERV\\nPURG\\nOFFENCE\\nINFRACTION\\nDUR\\u00c9E\\nNo.\\nDU\\nNeinterferCACE\n  =\\n188 Cross clicak 3\\n1010hgh shicle\\n\"\n\nI'm trying to extract H[(wildcard)] and A[(wildcard)] from the sample text, separately.\nIf I use x = re.search('H\\[.*\\]', ocr[0]) it finds the whole string H[ 12 ]\\nA[ O ]\nIf I use 'A\\[.*\\]' it will find A[ O ] by itself - but I can't seem to just find H[ 12 ].","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":53,"Q_Id":59725803,"Users Score":-1,"Answer":"Try this:\nH\\[ (\\w+) \\](?:.|\\n)+A\\[ (\\w+) \\]\nIf you know that the H and A parameter will always be separated by a newline and nothing else, replace (?:.|\\n)+ with only \\n.\nI'm not sure what the contents of your H and A variables can be but \\w should capture most of them.","Q_Score":0,"Tags":"python,regex,search","A_Id":59725976,"CreationDate":"2020-01-13T23:51:00.000","Title":"Having trouble finding a specific string (with wildcards in the middle) using regex and python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently have a twisted webapp which relies on pyopenssl. We are trying to move away from pyopenssl, which is a 3rd party dependency, in favour of the built in SSL module. Would anyone know if this is possible with twisted?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":59728728,"Users Score":0,"Answer":"Twisted only supports TLS using pyOpenSSL.","Q_Score":0,"Tags":"python,twisted,pyopenssl","A_Id":59736071,"CreationDate":"2020-01-14T06:47:00.000","Title":"Use SSL module with twisted instead of Pyopenssl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to deploy a Deep Learning model on AWS Lambda which does object detection. It is triggered on addition of image in the S3 bucket.\nThe issue that I'm facing is that the Lambda function code uses a lot of libraries like Tensorflow, PIL, Numpy, Matplotlib, etc. and if I try adding all of them in the function code or as layers, it exceeds the 250 MB size limit. \nIs there any way I can deploy the libraries zip file on S3 bucket and use them from there in the function code (written in Python 3.6) instead of directly having them as a part of the code?\nI can also try some entirely different approach for this.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1106,"Q_Id":59729056,"Users Score":0,"Answer":"Ultimately, I changed my approach from using Lambda to using EC2.\nI deployed the whole code with libraries on an EC2 instance and then triggered it using Lambda. On EC2, it can also be deployed on Apache server to change port mapping.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-s3,deep-learning,aws-lambda","A_Id":59902346,"CreationDate":"2020-01-14T07:18:00.000","Title":"Importing libraries in AWS Lambda function code from S3 bucket","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I have 2 Python files: file1.py and file2.py. The latter needs a set of data generated by file1.py. However, when I start debugging file2.py (or any other Python file), all the data in the Variable Explorer disappear and only reappear when I stop the debugging mode. This doesn't happen in Spyder 3. Is it a bug in Spyder 4 or I miss something? How to solve this problem?\nNote: I don't check the Remove all variables before execution in the Preferences.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":583,"Q_Id":59729440,"Users Score":2,"Answer":"(Spyder maintainer here) To make the data generated by file1.py available to file2.py, you need to give focus to file2.py in the editor, then go to the menu\nRun > Configuration per file\nand finally activate the option called\nRun in console's namespace instead of an empty one","Q_Score":0,"Tags":"python,spyder","A_Id":59760733,"CreationDate":"2020-01-14T07:49:00.000","Title":"Data in Variable Explorer is not available for debugging in Spyder 4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to set socket.TCP_KEEPIDLE of a Pyro4 object for keeping heartbeat. Is there any way to do this? Or workaround is also welcome.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":59729555,"Users Score":0,"Answer":"If you really want, you can get to the actual socket object in the Proxy via proxy._pyroConnection.sock but then you're using an internal API, so no guarantees that your code keeps working.","Q_Score":0,"Tags":"python,sockets,pyro,pyro4","A_Id":61733366,"CreationDate":"2020-01-14T07:58:00.000","Title":"How to get\/config socket from Pyro Proxy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The documentation suggests that BytesIO is the new StringIO, because it supports current-relative seeks. \nHowever, this is incorrect. \nBytesIO cannot be used uniformly with TextIOWrappers as they are returned by open() calls. The former returns bytes the later returns text objects when reading. \nTextIOWrapper(BytesIO(...)) also, does not do work as desired, because again, it does not support relative seeks.\nSo what is the best construct to replace the python2 StringIO in python3?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":263,"Q_Id":59729620,"Users Score":1,"Answer":"There is no single uniform replacement, as string handling itself has changed in Python 3.\nThe class for in-memory text files in Python 3 is io.StringIO. Like other text files, it doesn't support current-relative seeks. While io.StringIO could theoretically support efficient current-relative seeks, for consistency with other text files (and to avoid constraining the implementation), it refuses to do so.\nThe class for in-memory binary files in Python 3 is io.BytesIO. There's a good chance that this is what you should be using (and if it is, then you should probably be opening your disk files in binary mode too).\nIf you really need the flexibility of Python 2's StringIO.StringIO.seek handling with an in-memory text file in Python 3, your best bet may be to write your own class.","Q_Score":0,"Tags":"python,stringio,bytesio","A_Id":59730503,"CreationDate":"2020-01-14T08:02:00.000","Title":"What uniformly replaces the StringIO of Python2 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":"This is the first time I am using pathos library in python under Visual Studio 2019 on windows 10. When the debugger encounters the line\nsolver.SetMapper(Pool(self.Config.NumberOfProcessors).map)\nI get error \nModuleNotFoundError: No module named 'multiprocess'\nI have the following statement at the beginning of my code\nfrom pathos.pools import ProcessPool as Pool\nI have C++ compilers(multiple version of Visual studios) and I have used latest version of pip to install the packages. I also see that the multiprocess package has been installed under pathos.\nI do see multiple question on the same topic on the web, but unable to resolve the issue\nActually I can reproduce the same situation with a simple example like:\n\n    def foo(x):\n        return x\n    def bar(x):\n        return foo(x)\n    x=Pool(4).map(bar, [0, 1])\n    print (x)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":59735272,"Users Score":0,"Answer":"A new installation of python 3.8.1 seems to make this issue go away","Q_Score":0,"Tags":"python,pool,multiprocess,pathos","A_Id":59752030,"CreationDate":"2020-01-14T13:58:00.000","Title":"Multiprocess not found with Pathos","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to retrieve the following (historical) information while using the \nek.get_data()\nfunction: ISIN, MSNR,MSNP, MSPI, NR, PI, NT\nfor some equity indices, take \".STOXX\" as an example. How do I do that? I want to specify I am using the get data function instead of the timeseries function because I need daily data and I would not respect the 3k rows limit in get.timeseries. \nIn general: how do I get to know the right names for the fields that I have to use inside the \nek.get_data()\nfunction? I tried with both the codes that the Excel Eikon program uses and also the names used in the Eikon browser but they differ quite a lot from the example I saw in some sample code on the web (eg. TR.TotalReturnYTD vs TR.PCTCHG_YTD. How do I get to understand what would be the right name for the data types  I need?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":695,"Q_Id":59735432,"Users Score":0,"Answer":"Considering the codes in your function (ISIN, MSNR,MSNP, MSPI, NR, PI, NT), I'd guess you are interested in the Datastream dataset. You are probably beter off using the DataStream WebServices (DSWS) API instead of the Eikon API. This will also relieve you off your 3k row limit.","Q_Score":0,"Tags":"python,refinitiv-eikon-api","A_Id":60455231,"CreationDate":"2020-01-14T14:08:00.000","Title":"Eikon API - ek.get_data for indices","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to check an entry boxes input:\nProductNameEntry.get() to check whether any of the inputted data contains any integers if so it should return an error message.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":59735569,"Users Score":0,"Answer":"Entry box data is a str.\nTo check if there are numbers in the string you can use any([char.isdigit() for char in your_string]) which returns True when there's a number in the your_string","Q_Score":0,"Tags":"python,validation,tkinter","A_Id":59735630,"CreationDate":"2020-01-14T14:15:00.000","Title":"Python Tkinter type check","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having a trouble while implementing a log-in system in an interface I'm creating:\nI want it to have two type of user: admin and user, so depending on what you choose you input your credentials and then if they're correct the system opens either the admin interface or the user interface.\nMy problem is that given the knowledge I have right now, I have to have a \"mother window\" while executing tkinter which is the first windows that opens when you run the program, in this case that mother window would be the log-in window, the thing is that if I close that log-in window once the user inputs his\/her credentials, then the whole program doesn't work.\nIs there a solution for this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":59735640,"Users Score":1,"Answer":"The simplest solution is to create two functions or two classes, one for the login window and one for the main window. Have these functions or classes return a single frame that contains everything needed for that part of the code.\nThen, call the first function or class to login in, then destroy it and call the second function or class. When you destroy a frame, all of its children are also automatically destroyed.","Q_Score":1,"Tags":"python-3.x,tkinter","A_Id":59737043,"CreationDate":"2020-01-14T14:19:00.000","Title":"Creating a log-in system using Tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've set up a service account using the GCP UI for a specific project Project X. Within Project X there are 3 datasets: \nDataset 1\nDataset 2\nDataset 3\nIf I assign the role BigQuery Admin to Project X this is currently being inherited by all 3 datasets. \nCurrently all of these datasets inherit the permissions assigned to the service account at the project level. Is there any way to modify the permissions for the service account such that it only has access to specified datasets? e.g. allow access to Dataset 1 but not Dataset 2 or Dataset 3.\nIs this type of configuration possible? \nI've tried to add a condition in the UI but when I use the Name resource type and set the value equal to Dataset 1 I'm not able to access any of the datasets - presumably the value is not correct. Or a dataset is not a valid name resource.\nUPDATE\nAdding some more detail regarding what I'd already tried before posting, as well as some more detail on what I'm doing.\nFor my particular use case, I'm trying to perform SQL queries as well as modifying tables in BigQuery through the API (using Python).\nCase A:\nI create a service account with the role 'BigQuery Admin'.\nThis role is propagated to all datasets within the project - the property is inherited and I can not delete this service account role from any of the datasets.\nIn this case I'm able to query all datasets and tables using the Python API - as you'd expect.\nCase B:\nI create a service account with no default role.\nNo role is propagated and I can assign roles to specific datasets by clicking on the 'Share dataset' option in the UI to assign the 'BigQuery Admin' role to them.\nIn this case I'm not able to query any of the datasets or tables and get the following error if I try:\n*Forbidden: 403 POST https:\/\/bigquery.googleapis.com\/bq\/projects\/project-x\/jobs: Access Denied: Project X: User does not have bigquery.jobs.create permission in project Project X.*\nEven though the permissions required (bigquery.jobs.create in this case) exist for the dataset I want, I can't query the data as it appears that the bigquery.jobs.create permission is also required at a project level to use the API.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2089,"Q_Id":59736056,"Users Score":3,"Answer":"I'm posting the solution that I found to the problem in case it is useful to anyone else trying to accomplish the same.\nAssign the role \"BigQuery Job User\" at a project level in order to have the permission bigquery.jobs.create assigned to the service account for that project. \nYou can then manually assign specific datasets the role of \"BigQuery Data Editor\" in order to query them through the API in Python. Do this by clciking on \"Share dataset\" in the BigQuery UI. So for this example, I've \"Shared\" Dataset 1 and Dataset 2 with the service account.\nYou should now be able to query the datasets for which you've assigned the BigQuery Data Editor role in Python.\nHowever, for Dataset 3, for which the \"BigQuery Data Editor\" role has not been assigned, if you attempt to query a table this should return the error:\nForbidden: 403 Access Denied: Table Project-x:dataset_1.table_1: User does not have permission to query table Project-x:dataset_1.table_1.\nAs described above, we now have sufficient permissions to access the project but not the table within Dataset 3 - by design.","Q_Score":4,"Tags":"python,google-cloud-platform,google-bigquery","A_Id":59753770,"CreationDate":"2020-01-14T14:43:00.000","Title":"Is it possible to limit a Google service account to specific BigQuery datasets within a project?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I only installed Python 3.8.1 on my Windows 10, from some instructions I started to use pip3 and installed all the requirements with pip3 but I was hit with numerous problems, especially the packages I just installed can't get imported by python error. Then I did this pip3 --version and pip --version, the results are different. Then I did pip --list and pip3 --list, the results are different too, of course, so I did all the requirements in pip, and that seems to fix my problem. \nSo now I have this question, why is there a pip and then a pip3 on the same Python 3.8.1?\nwhere pip and where pip3 both return the same folder, C:\\Python38\\Scripts\\pip3.exe","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":573,"Q_Id":59736251,"Users Score":0,"Answer":"Binaries like python and pip point to the default version of Python which was often 2.x, and pip3 and python3 point to the latest installed version of Python 3.x. This was necessary because a lot of software was written for Python 2 and not updated to work with py3. Now that python 2 has reached its end of life, this should hopefully go away in the future.","Q_Score":0,"Tags":"python,python-3.8","A_Id":59736401,"CreationDate":"2020-01-14T14:53:00.000","Title":"Why is there a pip and pip3 on my windows 10 when both point to the same Python 3.8.1 installation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python is installed for the root\/admin on the Windows desktop. So when I try to install using pip install boto3, I get the following error for not having write permissions to the below mentioned path.\nCould not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\program files\\python37\\Lib\\site-packages\\boto3'\nAs a workaround if I install the package only for the user using pip install --user <Package-Name>, I am able to install the package at c:\\users\\kgoyal\\appdata\\roaming\\python\\python37\\site-packages\\boto3\\.\nNow while importing the same package inside the python shell, I get a ModuleNotFoundError.\nHow can I import a user installed package in the python shell and also get it to work with python scripts being executed by the python executable installed for the root\/admin?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":59736578,"Users Score":0,"Answer":"Have you run the command using the \"Run as Manager\" option?","Q_Score":0,"Tags":"python,linux,windows,shell,pip","A_Id":59740223,"CreationDate":"2020-01-14T15:10:00.000","Title":"Import User Installed Pip Package in Python Shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install a package name cutdapt in a windows server. I'm trying to do it this way: \npip install --trusted-host pypi.org --trusted-host files.pythonhosted.org cutadapt\nBut every time I try to install it I get this error: Building wheel for cutadapt (PEP 517): finished with status 'error'\nAny ideas on how to pass this issue?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":59737604,"Users Score":0,"Answer":"Turns out, that I had some problems with python 3.5, so I switched to python 3.8 and managed to install the package.","Q_Score":0,"Tags":"windows,python-3.5","A_Id":59750888,"CreationDate":"2020-01-14T16:05:00.000","Title":"Installing cutadapat package in windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a website in Node.js. Though, as I am taking a course on how to use Artificial Intelligence and would like to implement such into my program. Therefore, I was wondering if it was feasible to connect Python Spyder to a Node.js based web application with somewhat ease.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1193,"Q_Id":59738972,"Users Score":1,"Answer":"Yes. That is possible. There are a few ways you can do this. You can use the child_process library, as mentioned above. Or, you can have a Python API that takes care of the AI stuff, which your Node app communicates with. \nThe latter example is what I prefer as most my projects run on containers as micro services on Kubernates.","Q_Score":1,"Tags":"python,node.js,artificial-intelligence,spyder","A_Id":59740436,"CreationDate":"2020-01-14T17:32:00.000","Title":"Can I use Node.js for the back end and Python for the AI calculations?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"My application is database heavy (full of very complex queries and stored procedures), it would be too hard and inefficient to write these queries in a lambda way, for this reason I'll have to stick with raw SQL.\nSo far I found these 2 'micro' ORMs but none are compatible with MSSQL:\nPonyORM\nSupports: SQLite, PostgreSQL, MySQL and Oracle\nPeewee\nSupports: SQLite, PostgreSQL, MySQL and CockroachDB\nI know SQLAlchemy supports MSSQL, however it would bee too big for what I need.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":638,"Q_Id":59741950,"Users Score":1,"Answer":"As of today - Jan 2020 - it seems that using pyodbc is still the way to go for SQL Server + Python if you are not using Django or any other big frameworks.","Q_Score":2,"Tags":"sql-server,python-3.x","A_Id":59856715,"CreationDate":"2020-01-14T21:20:00.000","Title":"Python 3.X micro ORM compatible with SQL Server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently testing out various denoising algorithms on noisy images. Is there a way of measuring the standard deviation of the noise in the images that I'm denoising (before and after) with OpenCV(python) or any easier method?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":565,"Q_Id":59742157,"Users Score":0,"Answer":"I would try to pursue this by taking the image before denoise and applying a bitwise_and to it from the denoised image. This would give you just the noise. Then you could take the standard deviation and compare between the denoising algorithms.","Q_Score":0,"Tags":"python,image,opencv,image-processing,noise","A_Id":59742877,"CreationDate":"2020-01-14T21:39:00.000","Title":"How to calculate the standard deviation of noise for an image?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python3:\n\nWhat is the difference between calling python path\/to\/file.py and\npython -m path.to.file ?\nHow does it affect the working directory ? ( os.getcwd() )\nDoes it have a link with the presence \/ absence of an __init__.py\nfile located in path\/to ?\n\nI have been surprised by how little information I found on these of questions. Maybe I am not searching with the correct terms? Thanks in advance!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":253,"Q_Id":59742835,"Users Score":2,"Answer":"What is the difference between calling python path\/to\/file.py and python -m path.to.file ?\n\nPython -m module_name is a shortcut to invoking a particular module. Often this is an installed package with a __main__.py module inside of it. (e.g. python -m pip invokes pip\/__main__.py\nSo python -m pip is equivalent to python path\/to\/my\/python\/lib\/site-packages\/pip\/__main__.py\n\nHow does it affect the working directory ? ( os.getcwd() )\n\nIt does not\n\nDoes it have a link with the presence \/ absence of an init.py file located in path\/to ?\n\nFirst: There might be some confusion worth clearing up: python -m doesn't take a path as an argument. It takes the name of a module to execute.\nSo, short answer: no.\nLong answer: how a module executed by name with python -m depends on whether or not it is a package. The presence of __init__.py can denote that the directory is the name of a package, like pip is, thusly it will look for __main__ inside of the package.","Q_Score":1,"Tags":"python,python-3.x,python-module","A_Id":59743293,"CreationDate":"2020-01-14T22:47:00.000","Title":"Difference between `python file.py` and `python -m file`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"While trying to set up PyCharm with a Conda environment, I looked into my environment, but pythonw.exe is not showing up. I am on OS X","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":320,"Q_Id":59744046,"Users Score":1,"Answer":"pythonw.exe is Windows specific. Windows has a strict segregation between command line applications and non-command line applications; pythonw.exe is just Python declared as a non-command line application so a command prompt isn't created for scripts it runs (typically you don't want one for GUI applications).\nOn any other system, including OSX, plain python (or python3, as appropriate) handles both command line and non-command line applications.","Q_Score":0,"Tags":"python,anaconda","A_Id":59744076,"CreationDate":"2020-01-15T01:33:00.000","Title":"in anaconda, pythonw.exe is not showing up inside my directory. what can i do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm very new to Data Science and using anaconda\/jupyter so please bear with me.\nMy instructor asked me to install anaconda, and to run the jupyter notebook to make sure everything was installed correctly. When I tried to do so, I am met with a prompt telling me that token authentication is enabled. My instructor said this is not supposed to happen, and I should've been able to move on directly to a page with a cell where I could run code. He couldn't help me.\nI think the problem might be due to the fact that I am somehow running Anaconda Cloud when I shouldn't be. Any idea on how I can fix this problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":596,"Q_Id":59745250,"Users Score":0,"Answer":"Token authentication is good for security purposes. I believe you would want it to just open directly locally. Switching the default browser from Safari to Chrome did it for me, another thing is you can set your own password in jupyter notebook in terminal.\njupyter notebook password","Q_Score":0,"Tags":"python,jupyter-notebook,jupyter","A_Id":59745285,"CreationDate":"2020-01-15T04:42:00.000","Title":"How do I use jupyter notebook without token authentication?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using catboost classifier for my binary classification model where I have a highly imbalance dataset of 0 -> 115000 & 1 -> 10000.\nCan someone please guide me in how to use the following parameters in catboostclassifier:\n1. class_weights \n2. scale_pos_weight ? \nFrom the documentation, I am under the impression that I can use\nRatio of sum of negative class by sum of positive class i.e. 115000\/10000=11.5 as the input for scale_pos_weight but I am not sure .\nPlease let me know what exact values to use for these two parameters and method to derive that value?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3731,"Q_Id":59746304,"Users Score":2,"Answer":"For scale_pos_weight you would use negative class \/\/ positive class. in your case it would be 11 (I prefer to use whole numbers).\nFor class weight you would provide a tuple of the class imbalance. in your case it would be: class_weights = (1, 11)\nclass_weights is more flexible so you could define it for multi-class targets. for example if you have 4 classes you can set it: class_weights = (0.5,1,5,25)\nand you need to use only one of the parameters. for a binary classification problem I would stick with scale_pos_weight.","Q_Score":1,"Tags":"python,classification,catboost","A_Id":59773204,"CreationDate":"2020-01-15T06:45:00.000","Title":"catboost classifier for class imbalance?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to import JSON data from an API to MySQL database using python. I can get the json data in python script but no idea how to insert this data to a mysql database.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1725,"Q_Id":59746712,"Users Score":0,"Answer":"finally, did it. Saved the JSON file locally first, then parsed it using key values in a for loop & lastly ran a query to insert into MySQL table.","Q_Score":0,"Tags":"python,mysql,json","A_Id":60133751,"CreationDate":"2020-01-15T07:21:00.000","Title":"import json data from an api to mysql database in python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When running code in Anaconda or IBM Watson Studio, is Anaconda and IBM Watson Studio using your local device\u2019s RAM or are they running the code in the \u201ccloud\u201d servers?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":507,"Q_Id":59748779,"Users Score":1,"Answer":"What services or dependencies you use in Anaconda? I think IBM Watson Studio use the cloud server. With the local dependencies Anaconda will choose the local but if they uses some external service on cloud like AWS or Azure , etc ... they will use cloud too.","Q_Score":3,"Tags":"python,anaconda,cloud,ibm-watson,watson-studio","A_Id":59748942,"CreationDate":"2020-01-15T09:48:00.000","Title":"Anaconda vs. IBM Watson Studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When running code in Anaconda or IBM Watson Studio, is Anaconda and IBM Watson Studio using your local device\u2019s RAM or are they running the code in the \u201ccloud\u201d servers?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":507,"Q_Id":59748779,"Users Score":2,"Answer":"It depends. Watson Studio Desktop uses the resources of your computer, and also an Anaconda installation on your computer.\nWatson Studio on Cloud (dataplatform.cloud.ibm.com) runs your code in the IBM Cloud. The browser renders the result on your screen, using your computer's resources only for that.\nWatson Studio Local can be installed by others in their data centers. Then your code would be running in that data center.\n\nIf you have installed Anaconda locally on your computer, your code will typically run on your computer. Unless you explicitly write code that sends requests elsewhere, for example to call Watson APIs in the cloud.","Q_Score":3,"Tags":"python,anaconda,cloud,ibm-watson,watson-studio","A_Id":59749353,"CreationDate":"2020-01-15T09:48:00.000","Title":"Anaconda vs. IBM Watson Studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have built a rest API using Django. I have tested the endpoints and everything seems to be working fine on localhost.However after deploying to digital ocean and trying to access the endpoint to register a new user. I get Error 401. What could be the problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":151,"Q_Id":59750798,"Users Score":0,"Answer":"Might be a long shot, but I've had similar issues happen to me if I used HTTP when calling the URLs instead of HTTPS and\/or forgetting to call routes with the slash at the end. What would end up happening is that the request would drop the token data for some reason.","Q_Score":0,"Tags":"python,django,django-rest-framework","A_Id":59758733,"CreationDate":"2020-01-15T11:47:00.000","Title":"Error 401 when trying to register a new user. Works fine on localhost (Django rest api)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to run the command mkvirtualenv virt from the Windows 10 command line and am getting the error ERROR: virtualenv \"virt\" already exists even though there is no content in the directory that I am running this command from. Any ideas what may be happening?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":15,"Q_Id":59755487,"Users Score":0,"Answer":"mkvirtualenv is a part of virtualenvwrapper \u2014 a virtualev manager that creates all environments not in the current directory but in ~\/.virtualenvs so you can only have one virt there. If you want a virtualev in the current directory use virtualev but then you loose all the power of virtualenvwrapper.","Q_Score":0,"Tags":"python-3.x,windows-10,virtualenv,virtualenvwrapper","A_Id":59755729,"CreationDate":"2020-01-15T16:16:00.000","Title":"mkvirtualenv virt command thinks virt directory already exists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"New to programming with python as my first language. \nI'm attempting to create a regex that would match 'lo0.0' or any other interface that presents in that position from the string below. I need the ip address '192.168.50.5' to be input as a variable so the regex can be reused dynamically as part of a loop which will ensure that the interface retrieved is the correct outgoing interface for that route. \nI've attempted to use positive lookbehind assertions but I haven't had much success in getting the script to take a variable at the start of the regex but within the lookbehind assertion using either dotall or multiline.\n'\\n\\ninet.0: 13 destinations, 14 routes (13 active, 0 holddown, 0 hidden)\\n+ = Active Route, - = Last Active, * = Both\\n\\n192.168.50.5\/32    *[Direct\/0] 1w2d 02:39:35\\n                    >  via lo0.0\\n'","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":461,"Q_Id":59755775,"Users Score":1,"Answer":"Using display xml solved my issue, the xml outputs with a match in the original junos command made it much easier to parse with a regex. Cheers Shashank","Q_Score":1,"Tags":"python,python-3.x,juniper,junos-automation,netmiko","A_Id":59774728,"CreationDate":"2020-01-15T16:31:00.000","Title":"Regex including variable to match juniper srx output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been having a problem in Visual Studio 2019 where the program enters tabs as four spaces. This is annoying, since I have to hit backspace 4 times to erase an indent, and I need to use arrow keys 4 times to navigate an indent.\nThis used to work fine, but I had to uninstall and re-install Visual Studio to fix another problem (it kept running old versions of my code and wouldn't run the new version), and ever since then, I haven't been able to get it to work.\nI went to settings, and selected 'keep tabs', but it still replaces it with four spaces every time i hit the Tab button. Interestingly, when I start a new line, I can navigate and backspace normally, but if I enter any more tabs, they are replaced with 4 spaces.\nI've tried looking around, but I can't seem to find anything that addresses my issue. Can anyone help?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":4144,"Q_Id":59756636,"Users Score":7,"Answer":"Disable the checkbox: Tools->Options->Text Editor->Advanced->Use Adaptive Formatting\nYou will still need to delete the spaces it inserted for you, but will retain tabs afterwards.","Q_Score":13,"Tags":"python-3.x,visual-studio-2019","A_Id":67326464,"CreationDate":"2020-01-15T17:24:00.000","Title":"\"Keep Tabs\" setting not working in Visual Studio 2019","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been having a problem in Visual Studio 2019 where the program enters tabs as four spaces. This is annoying, since I have to hit backspace 4 times to erase an indent, and I need to use arrow keys 4 times to navigate an indent.\nThis used to work fine, but I had to uninstall and re-install Visual Studio to fix another problem (it kept running old versions of my code and wouldn't run the new version), and ever since then, I haven't been able to get it to work.\nI went to settings, and selected 'keep tabs', but it still replaces it with four spaces every time i hit the Tab button. Interestingly, when I start a new line, I can navigate and backspace normally, but if I enter any more tabs, they are replaced with 4 spaces.\nI've tried looking around, but I can't seem to find anything that addresses my issue. Can anyone help?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4144,"Q_Id":59756636,"Users Score":11,"Answer":"How to fix problem in Visual Studio with \"Keep tabs\" not working.\nI also had this problem with tabs being converted to spaces.\nI checked Tools>Options>Text Editor> (All languasges as well as c\/c++) >Tabs> and assured that \"Keep tabs\" was selected.\nAfter some trouble shooting I found that only one file had this problem (file1.h).\nI created a new empty file (file2.h) that worked correctly.\nI took the statements from file1.h and divided them into small block. Then I moved the blocks to file2 and after each block I tested file2.\nAfter a few block suddenly file2.h failed. When I removed the last block from file2 the problem was solved.\nMy conclusion is, that the source code contained some invivisible code, that made the text editor turn off the \"Keep tabs\" setting.\nI have seen comments about a setting \"Use adaptive formatting\" that might be relevant. So far I have turned this setting off.\nMy setup is Visual Studio Community 2019 v 16.4.4 with an Arduino plug in from Visual Micro v 1912 28 2.\n\/Steen","Q_Score":13,"Tags":"python-3.x,visual-studio-2019","A_Id":60040351,"CreationDate":"2020-01-15T17:24:00.000","Title":"\"Keep Tabs\" setting not working in Visual Studio 2019","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I trained a neural network with google colab.\nI saved the neural network using joblib.dump()\nI then loaded the model on my PC using joblib.load()\nI made a prediction on the exact same sample, using the same model, on both colab and my PC.  On colab, it has an output of [[0.51]].  On my pc, it has an output of [[nan]].\nThe model summary reports that the architecture of the model is the same.\nI checked the weights of the model I loaded on my PC, and the model on colab, and the weights are the exact same.\nAny ideas as to what I can do?  Thank you.\nQuick update:  even if I change all of my inputs to zero, the prediction is still nan.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":358,"Q_Id":59760569,"Users Score":0,"Answer":"As far as I know keras has its own function to save the model such as model.save('file.h5'), and the joblib library is used to save sklearn models.","Q_Score":0,"Tags":"python,tensorflow,keras,google-colaboratory","A_Id":59761188,"CreationDate":"2020-01-15T22:40:00.000","Title":"keras model prediction is nan after saving and loading","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently on the steep part of the learning curve with a Linux server and running into a very frustrating issue.\nInitially, I was running python scripts from the root user, then I learned that this was bad and created a new user and am working on migrating everything over to this new user. For some reason, when I set up the new user in exactly the same way that I set up the root I can no longer run the active file. From the root user, I can either click 'run active file' or the small play button in the top right corner but that disappears when I log in as the new user. \nI receive the error message '''only files on disk can be run in the terminal'''\nAny ideas on where I'm going wrong? Like I said still learning this stuff so if any more detail is needed please let me know.\nThanks!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":292,"Q_Id":59760784,"Users Score":0,"Answer":"Well this was dumb, the Python extension was installed when running the root but had to separately install the extension for the additional user. Fixed the issue.","Q_Score":0,"Tags":"python,linux,visual-studio,linode","A_Id":59773887,"CreationDate":"2020-01-15T23:00:00.000","Title":"Cannot run active file in visual studio when connected to 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":"So I'm trying to write this exact string but I don't \\n to make a new line I want to actually print \\n on the screen. Any thoughts on how to go about this? (using python\nLanguages:\\npython\\nc\\njava","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":760,"Q_Id":59761760,"Users Score":0,"Answer":"adding a backslash will interpret the succeeding backslash character literally. print(\"\\\\n\").","Q_Score":0,"Tags":"python","A_Id":59761774,"CreationDate":"2020-01-16T01:15:00.000","Title":"How to write \\n without making a newline","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to automate certain tests daily using cron job. I specify my shell script in my cron job. First, I have to first start my spring-boot application. I do that using the java -jar spring-boot-app.jar command. Then I need to execute a python script after starting the spring-boot app. I've put both these 2 commands in a shell script. But the problem is the python script is not being run, after starting the spring-boot app from the shell script. How do I start the python script too? I tried opening a new terminal using gnome-terminal in my script, but this command doesn't work in a remote machine. How do I start both the spring-boot app and the python command?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":357,"Q_Id":59763543,"Users Score":1,"Answer":"I think the answer above by UtLox will resolve your problem, because the \"&\" at the end will run your Spring Boot application in the background","Q_Score":1,"Tags":"java,python,shell,cron","A_Id":59763697,"CreationDate":"2020-01-16T05:32:00.000","Title":"how to run both java and python command in a shell 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":1,"Web Development":1},{"Question":"The processes would be running 24*7 and will be re-started periodically (like once in a week).\nIn this case which is a better option :\n\nOpening a postgres connection per processes which will persist until the life of the process.\nOpening a postgres connection pool and sharing it among the processes.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":59766207,"Users Score":0,"Answer":"The main objective is that there are not too many PostgreSQL connections at the same time, otherwise the danger increases that toi many of them will become active at the same time, thereby overloading the database.\nSo as long as you have some 20 processes, you can keep things simple and have a persistent connection per process. With many processes, you need a  connection pool.","Q_Score":0,"Tags":"python,postgresql,psycopg2","A_Id":59766701,"CreationDate":"2020-01-16T09:08:00.000","Title":"I am executing n no. of processes where n is could be between 5 - 50. Each process is making multiple dml operations on postgres","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Dash app that was working just fine moments ago. After a few edits (notably adding some dcc.Store objects), the app got completely frozen: it launches, makes a few callbacks, but then becomes the callbacks don\u2019t work and the editable tables won\u2019t edit (though I can change tabs). \nSince I have no error message in the console, it\u2019s like some process is running in the back, but it seems that no callback is running in the back (I put some print calls at the beginning of each callback and can\u2019t see anything in the console).\nThe last callback edits some data in some dcc.Store ; could it be that there is too much data stored?\nAlso I am using Dash 1.7.0\nThank you for your help,\nBest,\nVincent","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":678,"Q_Id":59766523,"Users Score":2,"Answer":"As suggested on the plotly forum, the solution was to look at the JS console of chrome: ctrl+shift+j. I could see some error messages there.","Q_Score":1,"Tags":"python,plotly-dash","A_Id":59768638,"CreationDate":"2020-01-16T09:29:00.000","Title":"Dash app seems to be frozen due to some processes in the back","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How to distinguish between Dark images and Bright images using Python?? I am trying to filter images based on the brightness in them.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1178,"Q_Id":59766704,"Users Score":1,"Answer":"You can try with np.mean(cv2.imread(image_path))<50 to distinguish black(dark) colored images.","Q_Score":2,"Tags":"python,opencv","A_Id":59837754,"CreationDate":"2020-01-16T09:41:00.000","Title":"How to distinguish between Dark images and Bright images using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing with Python and commonly running code in an integrated terminal with Shift + Enter. However, when debugging the process seems to be more complicated. I need to copy the code, move focus to debug REPL (Ctrl + Shift + Y), paste, run and move focus back to the editor. Is there any easier way to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2557,"Q_Id":59768704,"Users Score":0,"Answer":"You can use \"Jump to Cursor\" and that will cause the debugger to jump to that line next for execution; think of it as a GOTO statement. It's not the same as highlighting the code and sending it to the Debug Console, but should get you a similar result.","Q_Score":13,"Tags":"python,debugging,visual-studio-code,keyboard-shortcuts,vscode-settings","A_Id":59831964,"CreationDate":"2020-01-16T11:28:00.000","Title":"Is there a shortcut in VSCode to execute current line or selection in debug REPL?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using python pandas and write a simple script to modify .xlsx files. I want to delivery it as a package that my friends can use by one click ( maybe can add some inputs like file's directory).\nI want to know is there any way to do it quickly? Please.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":59769460,"Users Score":0,"Answer":"You don't want to do it like that. Because it is conflicting the main idea of virtual environment. The other computer can have a different operating system, other packages or package versions installed, so copying the files will not work.\nThe point of a virtual environment is to be able to replicate it everywhere you need it. \nFor a solution, you can use pip freeze > requirements.txt to extract your virtual enviroment libraries to txt. Then you can easily type pip install -r requirements.txt\nIf you want the exact environment, including system packages, on another computer, use Docker.","Q_Score":0,"Tags":"python,pandas","A_Id":59769541,"CreationDate":"2020-01-16T12:12:00.000","Title":"How to packaging and run python script including venvs on another computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have trained tensorflow object detection model (for num_steps:50000) using SSD (mobilenet-v1) on custom dataset. I got mAP@.50IOU ~0.98 and loss ~1.17. The dataset consist of uno playing card images (skip, reverse, and draw four). On all these cards, model performs pretty well as I have trained model only on these 3 card (around 278 images with 829 bounding boxes (25% bounding box used for testing i.e. validation) collected using mobile phone).\nHowever, I haven\u2019t trained model on any other card but still it detects other cards (inference using webcam).\nHow can I fix this? Should I also collect other class images (anything other than skip, reverse and draw four cards) and ignore this class in operation? So that model sees this class i.e. Label: Other images during training and doesn\u2019t put any label during inference.\nI am not sure how to inform tensorflow object detection API that it should ignore images from Other class.\nCan anyone please provide pointer?\nPlease share your views!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":687,"Q_Id":59769698,"Users Score":1,"Answer":"Yes, you need to have another Class which is the object you don't want to detect. \nIf you don't have this Other Class which includes everything that is not to be detected. The model will compare it to the existing class which is almost identical to the cards of interest.\nSome of the factors are:\n\nSimilarity of Shape\nSimilarity of Color \nSimilarity of Symbols\n\nThis is why even though it is not the card of interest (Skip, Reverse, and Draw 4), it would somehow have high \"belongingness\" to these three classes.\nHaving another Class to dump all of these can significantly lessen the \"belongingness\" to the three classes of interest and as much as possible provide A LOT of Data during Training.\nIf you don't want to have another class.\nYou could overfit Skip, Reverse, and Draw 4 cards (close to 100%), then increase your threshold value of detection to (70-90%).\nHope this will help you.","Q_Score":2,"Tags":"python,tensorflow,object-detection,object-detection-api","A_Id":61222708,"CreationDate":"2020-01-16T12:26:00.000","Title":"How to use \"ignore\" class with tensorflow object detection API?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi guys was wondering if anyone could help me with what I would actually answer for this question on a upcoming exam I have on AI in Python. The question confuses me as I thought I would usually need more info to answer but it is not provided. the question asked is\n\nA Python class is used to represent a neural network and the feed forward operation is called as indicated below:\n' y_hat = NN.forward(X) '\nwhere y_hat is the output and X is the input matrix.\nThe neural network has an input size of 80, one hidden layer of size 40 and an output layer of size 1.\nWhat size will be the W1 and W2 matrices?\n\nIf anyone could help me with this as my lecturer is not replying to the classes emails.\nMany Thanks!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1373,"Q_Id":59770747,"Users Score":1,"Answer":"By your description I suppose that you have two layers, where the first layer outpits a tensor of batch x 40 and the second layer a batch x 1 tensor, meanwhile the input is a tensor of batch x 80.\nThen the weights dimentions are:\nW1: 80x40 -> first layer\nW2: 40x1-> out layer","Q_Score":0,"Tags":"python,neural-network","A_Id":59771196,"CreationDate":"2020-01-16T13:30:00.000","Title":"Neural Networks Weight matrices explained","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi guys was wondering if anyone could help me with what I would actually answer for this question on a upcoming exam I have on AI in Python. The question confuses me as I thought I would usually need more info to answer but it is not provided. the question asked is\n\nA Python class is used to represent a neural network and the feed forward operation is called as indicated below:\n' y_hat = NN.forward(X) '\nwhere y_hat is the output and X is the input matrix.\nThe neural network has an input size of 80, one hidden layer of size 40 and an output layer of size 1.\nWhat size will be the W1 and W2 matrices?\n\nIf anyone could help me with this as my lecturer is not replying to the classes emails.\nMany Thanks!","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1373,"Q_Id":59770747,"Users Score":2,"Answer":"Let's say :\n\nX input vector, (size 80*1)\nH hidden layer vector, (size 40*1)\nY output vector, (size 1*1)\n\nYou have :\n\nH = W1 * X\nY = W2 * H\n\nSo :\n\nW1 has size (40*80)\nW2 has size (1*40)\n\nNote : size (m*n) means m rows, n columns","Q_Score":0,"Tags":"python,neural-network","A_Id":59771216,"CreationDate":"2020-01-16T13:30:00.000","Title":"Neural Networks Weight matrices explained","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having the following error when importing TensorFlow:\n\nERROR:root:Internal Python error in the inspect module.\n      Below is the traceback from this internal error.\n\nI believe it is related to .dll \n\nImportError: DLL load failed: The specified module could not be found.\n\nI am using Python version 3.7.4. \nAny advice? Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":146,"Q_Id":59771753,"Users Score":1,"Answer":"try:\n$ conda install tensorflow==2.0.0","Q_Score":0,"Tags":"python,anaconda","A_Id":59771829,"CreationDate":"2020-01-16T14:25:00.000","Title":"Anaconda Jupyter shows eroor when importing tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"pre-commit hooks are run in a separate virtual environment (or Docker container). However our code is running on Docker and we're also developing using Docker.\nUp until now we didn't have to install any dependencies on our host systems, but when running mypy, isort and pylint they run into problems because they can't access the dependencies installed. \nOur first idea was to install the dependencies in a virtual environment on the host system, but\nthat also seems like a clumsy workaround.\nIs there a good way to run pre-commit with full access to the container?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1619,"Q_Id":59773666,"Users Score":0,"Answer":"How about creating a special container for code style checks?\nIt should have all needed linters installed and a bash file to check code directory.\nYour hook command will look something like docker run -v [mount code dir to container in RO mode] codestyle_check_container","Q_Score":6,"Tags":"python,python-3.x,docker,pylint,pre-commit","A_Id":59773792,"CreationDate":"2020-01-16T16:09:00.000","Title":"Running pre-commit hooks (e.g. pylint) when developing with docker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a dataset with 200000 rows and 201 columns. I want to have descriptive statistics of all the variables.\nI tried:\n        '''train.describe()'''\nBut this is only giving the output for the first and last 8 variables. This there any method I can use to get the statistics for all of the columns.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":678,"Q_Id":59773763,"Users Score":1,"Answer":"probably, some of your columns where in some  type other than numerical. Try train.apply(pd.to_numeric) then train.describe()","Q_Score":4,"Tags":"python-3.x,pandas,data-analysis","A_Id":59773876,"CreationDate":"2020-01-16T16:15:00.000","Title":"How to get descriptive statistics of all columns in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training a neural network, but the feature vectors do not have the same size. \nThis problem may be fixed by adding some zeros or removing some values, but the greater problem would be data loss or generating meaningless data.\nSo, is there any approach to make them equal size, without mentioned weaknesses? Maybe transformation to other dimensions?\nI do not want to use random values or \"NA\".","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":160,"Q_Id":59776583,"Users Score":0,"Answer":"Adding zeros or zero padding is the most common method of making very short audio signals longer as well as it can be used to match the lengths of audio data before feature extraction. \nIn my understanding, this does not affect the outcome of the analysis, specially as you are using a neural network.","Q_Score":0,"Tags":"python-3.x,wav,feature-extraction,mfcc","A_Id":59810718,"CreationDate":"2020-01-16T19:31:00.000","Title":"How to make feature vectors size equal for training neural networks?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just started learning Python, and my question is that is that is it better\/faster to divide my code into multiple small parts into separate files and then import them, or just put everything into one long file and call it a day?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":59777030,"Users Score":0,"Answer":"It depends on how you like to work and what the purpose of the code is. Personally, I like to divide my program into individual scripts that each do a specific thing. This allows me to keep track of everything better and isolate any potential issues. I have a teammate who does everything in one script, however, and I'll do this too if the script is short enough. \nIf you want to import your own code from other files, make sure they share a source directory and that the source directory is well specified, otherwise your Main script will not be able to locate the imports.","Q_Score":0,"Tags":"python","A_Id":59777081,"CreationDate":"2020-01-16T20:05:00.000","Title":"In Python, one long file or rather multiple small?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a use case where I need to poll the API every 1 sec (basically infinite while loop). The polling will be initiated dynamically by user through an external system. This means there can be multiple polling running at the same time. The polling will be completed when the API returns 400. Anyways, my current implementation looks something like:\n\nFlask APP deployed on heroku.\nFlask APP has an endpoint which external system calls to start polling.\nThat flask endpoint will add the message to queue and as soon as worker gets it, it will start polling. I am using Heroku Redis to Go addons. Under the hood it uses python-rq and redis. \n\nThe problem is when some polling process goes on for a long time, the other process just sits on the queue. I want to be able to do all of the polling in a concurrent process.\nWhat's the best approach to tackle this problem? Fire up multiple workers?\nWhat if there could be potentially more than 100 concurrent processes.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":242,"Q_Id":59781138,"Users Score":0,"Answer":"You could implement a \"weighted\"\/priority queue. There may be multiple ways of implementing this, but the simplest example that comes to my mind is using a min or max heap.\nYou shoud keep track of how many events are in the queue for each process, as the number of events for one process grows, the weight of the new inserted events should decrease. Everytime an event is processed, you start processing the following one with the greatest weight. \nPS More workers will also speed up the the work.","Q_Score":3,"Tags":"python,heroku,flask,worker,python-rq","A_Id":59791745,"CreationDate":"2020-01-17T04:19:00.000","Title":"Best approach to tackle long polling in server side","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Clients will like a standalone solution due to poor internet around so I want to know the difference using SDK and containers for cognitive services.\nIts clear about useage information being sent back for billing when using containers but whats seperates using containers and SDK?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":40,"Q_Id":59782992,"Users Score":1,"Answer":"Using SDK:\nThe SDK is an accelerator avoiding to implement the REST API calls to Microsoft backend, but it is what it is doing behind. So in that case, your payload (whether it is an image or an image Url) will be sent to the backend. In the scenario where you have a poor internet access, it can be blocking in the case of the image.\nIf you use an image Url, it's the backend which will get it so it's less blocking but if your access is really limited, it may be blocking.\nUsing containers:\nIn the case of containers, you have access to the same capabilities but they run locally where you deploy the container: everything is processed locally.\nSo if you bandwidth is limited (or don't want your images to be processed by Microsoft endpoint), it is interesting.\nBUT (yes, nothing is perfect!) you still need a (smaller) internet connectivity as the container will send small payload to Azure about the billing. Those items are not sent synchronously but if you cannot send them regularly (if I remember well, it is a 15min window maximum), the container will stop working","Q_Score":0,"Tags":"c#,python,azure,microsoft-cognitive","A_Id":59821150,"CreationDate":"2020-01-17T07:36:00.000","Title":"In Azure Cognitve Services [Face API] Whats the difference Between Using SDK and Containers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I developed an API which parses the data from PDF. I used tabula-py for developing this API but it takes 4-5 sec on localhost which is much longer. For reducing response time I thought to use Azure-Function but it is taking much longer than localhost (9-10 sec), which is not expected.\nFor deploying it I used docker image(ACR for Azure) which I thought it will help me in scalability. Can anyone suggest me possible methods for reducing response time? Why does it take this much longer time in Azure Function (which is not expected)?\nP.S. Azure Function is similar with AWS Lambda.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":161,"Q_Id":59783843,"Users Score":1,"Answer":"tabula-py is a wrapper around tabula-java, which is written in Java. The latency you are seeing is the startup time of the Java virtual machine, which is started by the Python wrapper.\nThe optimal solution would be to build the API server in a language that runs in the JVM, like Java or Kotlin.","Q_Score":0,"Tags":"python,amazon-web-services,azure,tabula,tabula-py","A_Id":59815108,"CreationDate":"2020-01-17T08:45:00.000","Title":"Improve Response Time of Tabula based API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a Flask project. My \"templates\" folder is a subdirectory of \"app\" folder. The code starts in styleprive.py which is in app with the line \"From app import app\". This triggers init.py inside app.\nWhen I run:\nos.path.abspath(app.template_folder)\nThe result is surprising I think: \/Users\/egarcialopez\/local_programming\/styleprive\/templates\nand not \/Users\/egarcialopez\/local_programming\/styleprive\/app\/templates\nWhy does app not show up?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":59785126,"Users Score":0,"Answer":"I think you should use os.path.abspath(\"app\/template_folder\")","Q_Score":0,"Tags":"python,flask","A_Id":59785230,"CreationDate":"2020-01-17T10:04:00.000","Title":"Abspath for templates folder in Flask is surprising?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Installing Python packages can be as frustrating as it can be. Maybe I am the only poor pathetic who still stucks in Windows and the world is living their world happily in Mac and Linux\nI am trying to install vaex in my venv environment in Windows. But I got the following unmovable enterprise obstacles:\n\npip install is not possible as I am unable to install the Visual C++ Build Tools which requires admin rights\nDirect Git download or clone do require Visual C++ Build Tool\nConda only up-to version 4.3 which I am not allow to set the proxy when I try to use the conda-forge channel to install\nConda 4.3 is not accepting proxy server settings via command line. There is no way I am able to make conda to use .condarc file. The solution I was proposed is to upgrade to 4.4 which I am not able to do that\nOther dependencies pop-up when I try to upgrade conda to 4.4. conda upgrade conda forces me into a whole list of packages that I need to upgrade\/install along where I was given no choice to select only conda\n\nOr alternatively, what can I do to compile all the required elsewhere and repackage the whole package for installation?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":451,"Q_Id":59785452,"Users Score":1,"Answer":"You could build the wheel distribution of this project (and all its dependencies) on another Windows machine of the same bitness (32 or 64 bits) and with same (minor) version of the Python interpreter. This wheel distribution can then be reused on the target machine.","Q_Score":1,"Tags":"python,pandas,pip,conda,vaex","A_Id":59788059,"CreationDate":"2020-01-17T10:23:00.000","Title":"vaex binary installation in windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a django project and external resource. The external resource has XML data which changes time to time but it still static if nothing happened. I need to collect new data if something happened.\nThe ways I see:\n1. Grab content one time in some period and check if it is different.\n2. Save content as file and check length (worse way).\nUnfortunately, I can't predict when content will change also I can't use WebSockets, Long Polling and WebHooks.\nPlease, describe me the ways that in modern WWW today may solve my problem!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":59791391,"Users Score":0,"Answer":"If you can add some hook, when external resource updated, you can use it.\nBut if it is impossible - on way to do it is create periodical task for checking external resources (Last-Modified header for example).","Q_Score":0,"Tags":"django,python-3.x,http,https","A_Id":59791479,"CreationDate":"2020-01-17T16:32:00.000","Title":"Whats the best way to add listener to external resource?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been unable to create django project via command prompt. Here is the path I set in the environment variable: C:\\Users\\Freddy\\AppData\\Local\\Programs\\Python\\Python38-32\\Scripts;C:\\Users\\Freddy\\AppData\\Roaming\\Python\\Python38\\site-packages\\django. I tried to run this \"django-admin\" in command prompt I got this message that \"\ndjango-admin is not recognized as an internal or external command,operable program or batch file\" What do I do?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":223,"Q_Id":59791628,"Users Score":1,"Answer":"I installed it using pip \"pip install django\" and it was successfully installed.Also I was able to check the version in the python shell. Here is the path it was automatically installed \"AppData\\Roaming\\Python\\Python38\\site-packages\\django\"C:\\Users\\Freddy\\AppData\\Roaming\\Python\\Python38\\site-packages\\django\\bin\nanother folder which contains django-admin \"C:\\Users\\Freddy\\AppData\\Roaming\\Python\\Python38\\Scripts\"","Q_Score":1,"Tags":"python,django","A_Id":59791880,"CreationDate":"2020-01-17T16:47:00.000","Title":"How to create django project in cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been unable to create django project via command prompt. Here is the path I set in the environment variable: C:\\Users\\Freddy\\AppData\\Local\\Programs\\Python\\Python38-32\\Scripts;C:\\Users\\Freddy\\AppData\\Roaming\\Python\\Python38\\site-packages\\django. I tried to run this \"django-admin\" in command prompt I got this message that \"\ndjango-admin is not recognized as an internal or external command,operable program or batch file\" What do I do?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":223,"Q_Id":59791628,"Users Score":2,"Answer":"As error is clearly saying that django-admin not installed to install it you can you pip.\nYou can use following command for window\n\npy -m pip install virtualenvwrapper-win\nmkvirtualenv myproject\nworkon myproject\npy -m pip install Django","Q_Score":1,"Tags":"python,django","A_Id":59792052,"CreationDate":"2020-01-17T16:47:00.000","Title":"How to create django project in cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am looking to send different data types to my arduino via a serial connection using python. I have already managed to send simple data such as strings over the serial line and I parse the data in my arduino code, but now I want to send something similar to a structure containing two integers and a string.\nI was thinking I should just build the data I want to send as strings, concatenate them with a separator token, and parse this long string in my arduino code. Is this the usual way to send more data types at once, or is it better to send the variables separately?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":177,"Q_Id":59794478,"Users Score":1,"Answer":"Yes there is always a risk of loosing bytes. \nBut how you do it is totally dependent on what kind of data you are sending. For example if the values you are sending is between 0 and 255 you can send the value as one byte.\nIf on the other hand you are sending multiple values and or strings it si a good practice to make use of the control characters in the ASCII table to mark the start of a sequence and seperation and identification of values. For example\n\nSTX \"value_id1\" US \"value\" RS \"value_id2\" US \"value\" ... ETX\n\nIf the integrity of the values are very important you could calculate a checksum \"CRC\" to send along the message so the receiver can check for errors.","Q_Score":1,"Tags":"python,arduino","A_Id":59809228,"CreationDate":"2020-01-17T20:33:00.000","Title":"If I want to send data to arduino via serial, should I send a long string at once, or send each variable separately?","Data Science and Machine Learning":0,"Database and SQL":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 made a python script into an executable file by turning it into a .command file and adding the #!\/usr\/bin\/env python3 on the first line of the file. \nWhen I double click to run the file, the file does run on the terminal, however the installed modules do not seem to be linked to the file. \nimport requests\nModuleNotFoundError: No module named 'requests'\nIs there a way to use external module such as the 'requests' module when running an executable form of a python script?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":59796078,"Users Score":0,"Answer":"By \".\" you mean \".\/\"?\nHow to you normaly run it?","Q_Score":0,"Tags":"python,python-3.x,python-requests,command,executable","A_Id":59796166,"CreationDate":"2020-01-17T23:29:00.000","Title":"How to use external python modules such as the module 'requests' when running executable python scripts such as .command files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When we execute the program print('a' > 'b') it gives us the answer False.\nWhen we execute the program print('a' > 'A') it gives us the answer True.\nPlease help me with a detailed explanation.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":5266,"Q_Id":59798047,"Users Score":1,"Answer":"This is because on the ASCII (American Standard Code For Information Interchange) CHART the letter \"a\" equates to 97 (in decimal values) while the letter \"b\" equates to 98 (in the decimal values).\nTherefore when you type in print('a' > 'b'), Python compares the aforementioned decimal values and replies \"FALSE\" because under the hood is just comparing literally 97 to 98. The same goes to print('a' > 'A'), it will be comparing 97 to 65; reason why you will get a \"TRUE.\"","Q_Score":3,"Tags":"python-3.x,output,ascii","A_Id":69042764,"CreationDate":"2020-01-18T06:19:00.000","Title":"Why is print('a' > 'b') False and print('a' > 'A') True?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a bot and instead of phrasing user facing communication the same way, I want to implement a certain degree of change in the language, while still maintaining the original intent. To do this, instead of a standard dictionary key-value pairs, such as \nuser_response [\"GREET\"] = \"Hello, how are you?\" \nis currently replaced such:\nuser_response [\"GREET\"] = [\"Hello, how are you?\", \"What's up?\", \"Hi, all good today?\"]\nand a random string is picked from the choices available.\nThe problem is, it'll take much too long to do this manually, for all the strings in the system.\nQuestion: Is there a way NLTK or other library can rephrase a given phrase?\nThere is a question from 2010 that is similar in intent, but didn't have much by way of responses or follow ups.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":59798373,"Users Score":0,"Answer":"NLTK won't help with generating rephrasing - you can use a natural language generation model like GPT-2 but that will require lot of time and compute resources and may not even deliver what you are looking for. Your best bet would be to use a \"parapharsing\" app. Even that will require manual entry of initial sentence to generate the rewrites. You may be able to find a paraphrasing API but I am not aware of one.","Q_Score":1,"Tags":"python,nlp,nltk","A_Id":59806966,"CreationDate":"2020-01-18T07:14:00.000","Title":"Phrase Rephraser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When trying to run simple python3 code via pycharm, I get following error\n\n\/Users\/slimerski\/PycharmProjects\/studia\/venv\/bin\/python \/Users\/slimerski\/PycharmProjects\/studia\/zadania_14.py\n      dyld: Library not loaded: \/usr\/local\/Cellar\/python\/3.7.4_1\/Frameworks\/Python.framework\/Versions\/3.7\/Python\n  Referenced from: \/Users\/slimerski\/PycharmProjects\/studia\/venv\/bin\/python\n  Reason: image not found\nProcess finished with exit code 134 (interrupted by signal 6: SIGABRT)\n\nEverything was working until recently I have installed zsh and updated xcode via brew.\nI have tried fixing it with otool -L exefile but instead I get another error \n\n\/Library\/Developer\/CommandLineTools\/usr\/bin\/objdump: error: 'exefile': No such file or directory.\n\nIs there anyway to fix it?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":9628,"Q_Id":59800501,"Users Score":1,"Answer":"Maybe you uninstall that version of python, in this case 3.7... You have to download it again and execute","Q_Score":6,"Tags":"python,xcode,macos,pycharm,dyld","A_Id":59860191,"CreationDate":"2020-01-18T12:17:00.000","Title":"dyld: Library not loaded: \/usr\/local\/Cellar\/python\/3.7.4_1\/Frameworks\/Python.framework\/Versions\/3.7\/Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to rank and unrank permutations with one cycle in lexicographical order with a given len.\nA permutation with one cycles is where you can visit in this cycle each element.\np:= (2,3,1) is a permutation with one cycle. Has rank 1.\np:= (3,1,2) has 1 cycle too, but rank 2, because the permutation is lexicographical greater the frist so it becomes a greater rank.\np:= (1,2,3) is a permutation with 3 cycles. (1),(2),(3)\nHow can I efficently rank (permutation with one cycle to rank) and unrank (rank + len to permutation with one cycle) in lexicographical order? I have no idea how to archive this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":145,"Q_Id":59800684,"Users Score":0,"Answer":"I discovered a solution for ranking. We know that a permutations of length n has n-1! permutations with one cycle. Due to this knowledge we can come to the following solution.\nRanking: example 2341\nWe start to calculating the rank with the 1 position this gives (n-1[position])! as tempvalue. Then we calculating the index of the 2 which is 0, because 1 is falling out through it creates the cycle (1). To complete the calculating for the first position we need to multiply the index of the element with the tempvalue, which leads to 0 as temprank_0. \nNow we continue this steps for the remaining positions to add temprank_0+temprank_1+temprank_2+temprank_4 = 0\nUnranking: 4 for permutation len 4:\nWe divide the rank through (n-2[postion+1])! which leads 2 which is the index of 1234 which dont create a cycle  so the 1 position of the permutation is 4 . Then we subtract 2 times (n-2)!from 4. \nThis we continue this twice. So we have 412. So in the end we add just the remaining value 3 end we get the permutation 4123 .","Q_Score":1,"Tags":"python,arrays,algorithm,permutation,ranking","A_Id":59909244,"CreationDate":"2020-01-18T12:41:00.000","Title":"Rank and unrank permutations with just one cycle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Other similar answers are out of date or focus on a particular error and not the whole process.\nWhat is the full installation process of mod_wsgi into an Apache installation on Windows 10?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":10474,"Q_Id":59801387,"Users Score":2,"Answer":"Also be sure to check that your Apache and Python got same architecture (32\/64bit) and MS Build Tools is compatible with Python version.\nBeen trying to compile mod_wsgi using different combinations of MS Build Tools for a few hours before I noticed that Python 3.8 is 32bit and Apache Lounge 2.4 is 64bit.","Q_Score":10,"Tags":"python,windows,apache,mod-wsgi,wsgi","A_Id":63749301,"CreationDate":"2020-01-18T14:11:00.000","Title":"How to install mod_wsgi into Apache on Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was hoping that this would be fixed in the newer version but I see the same thing.  Every time a file is executed the console displays the runfile() and wdir and it clutters the console.  Is there a way to hide this?\nrunfile('C:\/Users\/One\/Desktop\/Training\/Week1\/Files\/file1.py',wdir='C:\/Users\/One\/Desktop\/Training\/Week1\/Files\/file1.py'), wdir=\"\/directory\/","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":310,"Q_Id":59802264,"Users Score":1,"Answer":"(Spyder maintainer here) There's no way (and there's never going to be one) to hide that command because it's needed to evaluate your code in the console.\nHowever, we're thinking to remove the wdir part, unless users declare a specific working directory to run their files.","Q_Score":0,"Tags":"python-3.x,spyder","A_Id":59803297,"CreationDate":"2020-01-18T15:59:00.000","Title":"Hidding the runfile() command in Spyder 4.0","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a data frame with columns X Y temperature Label\nlabel is an integer between 1 and 9 \nI want to add an additional column my_label_mean_temperature which will contain for each row the mean of the temperatures of the rows that has the same label.\nI'm pretty sure i need to start with my_df.groupby('label') but not sure how to calculate the mean on temperature and propagate the values on all the rows of my original data frame","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":59803001,"Users Score":0,"Answer":"df['my_label_mean_temperature']= df.groupby('label', as_index=False)['temperature'].mean()","Q_Score":0,"Tags":"python,pandas","A_Id":59803137,"CreationDate":"2020-01-18T17:16:00.000","Title":"Set column value as the mean of a group in pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have learned Python long ago and when I was just installing Python (I might have done some mistakes on installing it), I have upgraded from 3.6 (32-bit) to 3.7.4 (64-bit). One day I have found that I have (by mistake?) installed 3.7 (64-bit), too.\nNow I am working on some problem and sometimes I need to install some new libraries, for example, OpenCV for detecting and processing images. But when I install something with 'pip', it installs it in the directory Python36-32. I have Python IDLE 3.7.4, so there are constantly appearing errors between different Pythons. I have also deleted Python 3.6 (32-bit), but then I couldn't use 'pip' command anymore. I have also tried to change environmental variables from Python36-32 to Python37-64. I was chroming a lot but without success.\nI am not very new in Python as programming, but I am just a newbie on a real understanding of how Python works (I mean there for example: what are the differences between different Pythons, what are environmental variables ...)\nIn general: When I was a newbie on Python programming, I have (by mistake) installed 3 Python versions: 3.6 (32-bit), 3.7 (64-bit), and 3.7.4 (64-bit). My IDLE works in 3.7.4 (64-bit) and my 'pip' installs all the libraries into Python 3.6 (32-bit). My computer is the battlefield for a lot of Pythons. I have no idea what to do. Should I delete some version, change something ...\nThank you very much for solving the problem!\nP.S. I have realized that for me this problem (battle of Pythons) is much harder than the problem on which I am doing.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":92,"Q_Id":59803606,"Users Score":1,"Answer":"I have a similar experience when I first using python before grad school. For me, it is because the OS I was using at the time, windows of course. Even now, I still feel windows is not a good OS for programming. One library management solution ana(conda) helped me a lot. Right now conda has GUI interface now, and it provides a much new-programmer friendly entry point for using python. Another huge leg-up during that time is the Jupyter notebook (used to called Ipython), it allows have a semi-console and WYSIWYG programming. Right now, we all use debuggers, but still it is a very intuitive way to programming.\nHope this helps.","Q_Score":0,"Tags":"python,python-3.x,pip,python-3.6,python-3.7","A_Id":59803747,"CreationDate":"2020-01-18T18:26:00.000","Title":"Battle of Pythons","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have learned Python long ago and when I was just installing Python (I might have done some mistakes on installing it), I have upgraded from 3.6 (32-bit) to 3.7.4 (64-bit). One day I have found that I have (by mistake?) installed 3.7 (64-bit), too.\nNow I am working on some problem and sometimes I need to install some new libraries, for example, OpenCV for detecting and processing images. But when I install something with 'pip', it installs it in the directory Python36-32. I have Python IDLE 3.7.4, so there are constantly appearing errors between different Pythons. I have also deleted Python 3.6 (32-bit), but then I couldn't use 'pip' command anymore. I have also tried to change environmental variables from Python36-32 to Python37-64. I was chroming a lot but without success.\nI am not very new in Python as programming, but I am just a newbie on a real understanding of how Python works (I mean there for example: what are the differences between different Pythons, what are environmental variables ...)\nIn general: When I was a newbie on Python programming, I have (by mistake) installed 3 Python versions: 3.6 (32-bit), 3.7 (64-bit), and 3.7.4 (64-bit). My IDLE works in 3.7.4 (64-bit) and my 'pip' installs all the libraries into Python 3.6 (32-bit). My computer is the battlefield for a lot of Pythons. I have no idea what to do. Should I delete some version, change something ...\nThank you very much for solving the problem!\nP.S. I have realized that for me this problem (battle of Pythons) is much harder than the problem on which I am doing.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":92,"Q_Id":59803606,"Users Score":1,"Answer":"Different versions of Python can coexist on your machine simultaneously.\nAlmost all operating systems include a system version of Python which is installed alongside the operating system and which should not be changed; if you run the command python in your terminal out of the box, this is the version of Python you will get. This system Python should not be modified, as doing so has the potential of breaking OS-installed tools and libraries that depend on it.\nInstalling Python on your machine (via the Python website) sets up a new Python on your machine which has priority over system Python. However, this is an \"prepend\" process, not a \"replace\" process. Each new version of Python installed will have priority over the previous versions. But, if you try to import a package, and that package doesn't exist in your highest priority Python version, your computer will rifle through the old Python's module file-paths to try to find them. This is bad because all of the sudden you are using packages from different versions of Python, which may break due to changes between language versions.\nBest practice is to only ever install a single version of Python on your machine (besides the system Python), and then use virtualenv or conda to manage setting up new work environment. So you should install all versions of Python except for latest, and then learn how to use these tools to avoid environment problems.","Q_Score":0,"Tags":"python,python-3.x,pip,python-3.6,python-3.7","A_Id":59803757,"CreationDate":"2020-01-18T18:26:00.000","Title":"Battle of Pythons","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"On the english keyboard 'y' is in the same place as 'z' on the slovenian keyboard (AZERTY). Is there a way a Python program can identify which physical key was pressed when you press the same key regardless of the language that is used?","AnswerCount":1,"Available Count":1,"Score":-0.3799489623,"is_accepted":false,"ViewCount":96,"Q_Id":59803828,"Users Score":-2,"Answer":"From what I understand you're asking about running commands in the Python REPL (AKA shell). AFAIK the Python REPL doesn't interact directly with hardware; instead it interacts with OS libraries. In this case that means it doesn't receive key scancodes but characters. So instead of trying to change Python, change the keyboard layout of  your OS. How to do that depends on the OS.","Q_Score":3,"Tags":"python,python-3.x,qwerty","A_Id":59804499,"CreationDate":"2020-01-18T18:56:00.000","Title":"Can python detect which key is used on keyboard regardless of keyboard layout?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I have a time series data that basically behaves in a sawtooth manner. After each maintenance period, the signal always goes up before going down until a maintenance happens which will cause the signal to increase again. I am trying to predict the signal and see what happens to the signal if I schedule future maintenance. \nI am new to time series and I am not sure which model should I use to predict the data. I have looked at cross correlation but it doesnt seem to take into account any events that will influence the signal like my problem.\nI just what what happens after each maintenance event and the signal follws a similar trend all the time after each maintenance period where it goes up and down. Any suggestions?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":58,"Q_Id":59807263,"Users Score":2,"Answer":"You are looking for a ML model for time-series data. \nThis is a huge field but I`ll try to write a few important notes:\n\nTry to generate a dataframe where each row is a timestamp and each column is a feature. \nNow you can generate rolling features - for example rolling mean\/std of your features, using a few different time windows.\nsplit your data to train and test - this is a very tricky part in time series data. You should be very careful with this. You have to split the data by time (not randomly), in order to simulate the real world where you learn from the past and predict the future. You must verify that you haven't a leakage - for example, if you use as a feature \"rolling mean of the last week\", you must verify that you didn't calculated your signal for validation using data from the train set. \nTrain a baseline model using classic ML methods - for example boosting trees etc.\nIn the next steps you can improve your baseline and then continue with more advanced models (LSTM etc)","Q_Score":1,"Tags":"python,machine-learning,time-series,prediction","A_Id":59807451,"CreationDate":"2020-01-19T04:55:00.000","Title":"How can I use machine learning for time series problem","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a data frame which contains multiple number sequences, i.e.:\n1324123\n1235324\n12342212\n4313423\n221231;\n...\nthese numbers met the following requirement: the number of each digit is from 1 - 4.\nWhat I want to do is find all unique sequences and their reads. Regarding the unique sequence, two-digit differences are allowed.\nFor example:\n12344\n12344\n12334\n1234\n123444\nare considered as the same sequence and the original sequence is 1234 and the associated read is 5.\nI want to accomplish this in python and only basic python packages are allowed: numpy, pandas, etc.\nEDIT\nthe real case is DNA sequence. For a simple DNA sequence ATGCTAGC, due to reading errors, the output of this actual sequence might be:\nATGCTAG(deleted), ATGCTAGG(altered), ATGCTAGCG(insertion), ATGCTAGC(unchanged).\nThese four sequences are considered the same sequence, and read is the time of appearance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":122,"Q_Id":59807333,"Users Score":0,"Answer":"As it is, the problem isn't defined well enough - it is underconstrained.\n(I'm going to be using case-sensitive sequences of [A-Za-z] for examples, since using unique characters makes the reasoning easier, but the same things apply to [1-4] and [ACGT] as well; For the same reason, I'm allowing only single-character differences in the examples. When I include a number in parenthesis after a sequence, it denotes the read)\nJust a few examples off the top of my head:\n\nFor {ABCD, ABCE}, which one should be selected as the real sequence? By random?\nWhat about {ABCD, ABCE, ABCE}? Is random still okay?\nFor {ABCD, ABCE, ABED}, should ABCD(3) be selected, since there's a single-letter difference between it and the other two, even though there's a two-letter difference between ABCE and ABED?\nFor {ABCE, ABED}, should ABCD(2) be selected, since there's a single-letter difference between it and the other two, even though the sequence doesn't exist in the input itself?\nFor {ABCD, ABCZ, ABYZ}, should ABCZ(3) be selected? Why not {ABCD(2), ABYZ(2)}?\nFor {ABCD, ABCZ, ABYZ, AXYZ}, should {ABCD(2), AXYZ(2)} be selected? Why not {ABCZ(3), ABYZ(3)}? (Or maybe you want it to chain, so you'd get a read of 4, even though the maximum difference is already 3 letters?)\n\nIn the comments, you said:\n\nI am just listing a very simple example, the real case is much longer.\n\nHow long? What's the minimum length? (What's the maximum?) It's relevant information.\nAnd finally - before I get to the meat of the problem - what are you doing this for? If it's just for learning - as a personal exercise - that's fine. But if you're actually doing some real research: For all that is good and holy, please research existing tools\/libraries for dealing with DNA sequences and\/or enlist the help of someone who is familiar with those. I'm sure there are heaps of tools available that can do better and faster, than what I'm about to present. That being said...\nLet's look at this logically. If you have a big collection of strings, and you want to quickly find if it contains a specific string, you'd use a set (or a dictionary, if there's associated data). The problem, of course, is that you don't want to find only exact matches. But since the number of allowed errors is constrained and extremely small, there are some easy workarounds.\nFor one, you could just generate all the possible sequences with the allowable amount of error, and try to lookup each of them - but that really only makes sense if the if the strings are short and there's only one allowable error, since the amount of possible error combinations scales up really fast.\nIf the strings are long enough, and aren't expected to generally share large chunks (unless they're within the allowable error, so the strings are considered same), you can make the observation that if there's a maximum of two modifications, and you cut a string into 3 parts (it doesn't matter if there's leftovers), then one of the parts must match the corresponding part of the original string. This can be extended to insertions and deletions by generating the 3 parts for 3 different shifts of the string (and choosing\/dealing with the part lengths suitably). So by generating 9 keys for each sequence, and using a dictionary, you can quickly find all sequences that are capable of matching the sequence with 2 errors. (Of course, as I said at the start, this doesn't work if a large part of unrelated strings share big chunks: If all of your strings only have differences at the beginning, and have the same end, you'll just end up with all the strings grouped together, and no closer to solving the problem) (Also: If the sequence you want to select doesn't necessarily exist in the input, like described in the 4th example, you need 5 parts with 5 shifts to guarantee a matching key, since the difference between the existing sequences can be up to 4)\nAn example:\n\nOriginal sequence:\nABCDEFGHIJKLMNOP\n\nGenerated parts: (Divided into 3 parts (of size 4), with 3 different shifts)\n[ABCD][EFGH][IJKL]MNOP\nA[BCDE][FGHI][JKLM]NOP\nAB[CDEF][GHIJ][KLMN]OP\n\nIf you now make any two modifications to the original sequence, and generate parts for it in the same manner, at least one of the parts will always match. If the sequences are all approximately the same size, the part size can just be statically set to a suitable value (there must be at least 2 characters left over after the shift, as shown here, so a string with two deletions can still generate the same keys). If not, eg. powers of two can be used, taking care to generate keys for both sides when the string length is such that matching sequences could fall into a neighbouring size bucket.\nBut those are in essence just examples of how you could approach coming up with solutions when presented with this kind of a problem; just random ad hoc methods. For a smarter, more general solution, you could look at eg. generalized suffix trees - they should allow you to find matching sequences with mismatches allowed very fast, though I'm not sure if that includes insertions\/deletions, or how easy that would be to do.","Q_Score":0,"Tags":"python","A_Id":60538738,"CreationDate":"2020-01-19T05:09:00.000","Title":"Find unique number of sequence and reads","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I try to install TensorFlow with pip on Python 3.8, I get the error that TensorFlow is not found. I have realized later on that it is not supported by Python 3.8.\nHow can I install TensorFlow on Python 3.8?","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":55356,"Q_Id":59809495,"Users Score":0,"Answer":"Currently it does support python 3.8 all we need to do is create a new environment ,select 'update index' , select uninstalled and one can find tensorflow for installing","Q_Score":13,"Tags":"python,python-3.x,tensorflow,python-3.8","A_Id":67048383,"CreationDate":"2020-01-19T11:16:00.000","Title":"How to install TensorFlow with Python 3.8","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I try to install TensorFlow with pip on Python 3.8, I get the error that TensorFlow is not found. I have realized later on that it is not supported by Python 3.8.\nHow can I install TensorFlow on Python 3.8?","AnswerCount":6,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":55356,"Q_Id":59809495,"Users Score":3,"Answer":"Tensorflow does not support Python 3.8 at the moment. The latest supported Python version is 3.7. A solution is to install Python 3.7, this will not affect your codes since Python 3.7 and 3.8 are very similar. Right now Python 3.7 is supported by more frameworks like TensorFlow. Soon Python 3.8 will have more supported frameworks, and that\u00b4s when you can install TensorFlow for Python 3.8.","Q_Score":13,"Tags":"python,python-3.x,tensorflow,python-3.8","A_Id":61622264,"CreationDate":"2020-01-19T11:16:00.000","Title":"How to install TensorFlow with Python 3.8","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I try to install TensorFlow with pip on Python 3.8, I get the error that TensorFlow is not found. I have realized later on that it is not supported by Python 3.8.\nHow can I install TensorFlow on Python 3.8?","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":55356,"Q_Id":59809495,"Users Score":0,"Answer":"Instead of pip or conda command, I used pip3 command and it worked.","Q_Score":13,"Tags":"python,python-3.x,tensorflow,python-3.8","A_Id":69379579,"CreationDate":"2020-01-19T11:16:00.000","Title":"How to install TensorFlow with Python 3.8","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a python script that is trying to stream a screen capture to my Facebook Page and to be able to retrieve all the comments from the Facebook Live stream real time so that I can do some processing in the middle of the stream.\nThe Facebook App was set up (in development mode) but when I tried to retrieve the comments from my live stream, I am only able to retrieve comments with their name and id (\"from\") that are made as the Facebook Page Admin, not comments that are made by other users. I need the user's id, user's name and their comments.\nI understand that I need to get Facebook App to be live mode in order to retrieve all the comments with their details tagged to it. When I tried to get it, it tells me that I need to get the permission approved. I tried to fill in most of the stuff and try to get the two permission (manage_page for the comments and live video API for the streaming) but I was unable to because I left the platform empty.\nBelow is the message I got:\n\nYou do not have any platforms eligible for review. Please configure a platform on your Settings page.\n\nThe problem is when I tried to choose a platform that was shown in the list, python script does not fall in the list of platform. \nDoes anyone know of a solution or a different way to achieve what I need to retrieve?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1082,"Q_Id":59810273,"Users Score":0,"Answer":"In order to get the \"from\" field when retrieving the comments, you need to have manage_pages permission from your Facebook App that is linked to your Facebook Page. You will need to submit an App review for your Facebook App that usually takes 1-3 days to process. If you are lucky, it will probably take about 6-8 hours. \nOnce it is approved, you can request the permission and get your application to go live.\nAlso use the Page Access token in your \"access_token\" field when invoking the API so that it will allow you to pull the \"from\" field, which contains the id and name of the user.","Q_Score":5,"Tags":"python,facebook,facebook-graph-api","A_Id":61137300,"CreationDate":"2020-01-19T13:05:00.000","Title":"Retrieving Facebook Page comments with python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to create a tool with Python and the Twitter API to be able to create lists of tweets that match certain criteria like \"contains the word Python\" or \"has at least 2 likes\". Or simple stats like top posters, most liked, etc.\nAll of my search pointed me to the Tweepy project. But for that I need 0Auth tokens. So I applied for a developer account and was denied with the comment \"we are unable to serve your use case\".\nDo I have any alternatives?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":59811949,"Users Score":0,"Answer":"Well, as a general answer for these situations, you can always use a web-based automation tool, which is basically a library that interacts with the remote feature of the browsers and replicates what would be you \"opening the website, logging in, etc\" and can subsequently parse all data from the rendered elements.\nTry looking at selenium, i've used that library in the past to raw scrap facebook and it worked flawless.\nEdit: Note that this isn't a twitter specific library, you will have to find the html tags in the login website and use them to log in, same for parsing data, etc.","Q_Score":3,"Tags":"python,twitter","A_Id":70450120,"CreationDate":"2020-01-19T16:16:00.000","Title":"using Python and the Twitter API without authentication 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 have installed the Anaconda 3 in my windows 10 and it has not installed the Scripts folder and the Anaconda Prompt or Navigator applications. \nI have come here and in other sources for an answer and tried to reinstall, use the cmd as adm to install with the conda commands, but the system does not recognize the conda command. I have seen answers with the Scripts folder, but it was not installed.\nI have also seen answers advising me to install miniconda and then update to anaconda, but again, miniconda has the same problem as anaconda: no scripts folder, no recognition of the conda command. \nI don't know what to do.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":316,"Q_Id":59812998,"Users Score":0,"Answer":"I work on a hp Probook with windows 10 and the problem was that the application hp Sure Sense Installer block the installation of anaconda. After uninstalling the hp Sure Sense Installer application and reinstalling anaconda, everything works fine !","Q_Score":0,"Tags":"cmd,anaconda,windows-10,python-3.7,miniconda","A_Id":72025624,"CreationDate":"2020-01-19T18:14:00.000","Title":"Anaconda installer not working - Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have installed the Anaconda 3 in my windows 10 and it has not installed the Scripts folder and the Anaconda Prompt or Navigator applications. \nI have come here and in other sources for an answer and tried to reinstall, use the cmd as adm to install with the conda commands, but the system does not recognize the conda command. I have seen answers with the Scripts folder, but it was not installed.\nI have also seen answers advising me to install miniconda and then update to anaconda, but again, miniconda has the same problem as anaconda: no scripts folder, no recognition of the conda command. \nI don't know what to do.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":316,"Q_Id":59812998,"Users Score":0,"Answer":"Dear all who may have had the same problem, what worked for me was to install the 32-bit version, I had heard it was more stable.\nI did not have to restart Windows after installing this version, It was already there, Anaconda Prompt and Navigator.","Q_Score":0,"Tags":"cmd,anaconda,windows-10,python-3.7,miniconda","A_Id":59847628,"CreationDate":"2020-01-19T18:14:00.000","Title":"Anaconda installer not working - Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Using VSC Python extension 'Run File in Terminal' has suddenly stopped working.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":59813702,"Users Score":0,"Answer":"Spent two days, trying every fix I could find on the net. Nothing worked. In desperation, turned off Malwarebytes (using Quit Malwarebytes from the sys tray icon). VSC Python 'Run File in Terminal' now works !!. Turns out to be the Ransomeware Protection layer causing the problem. VSC runs fine with this layer disabled. Hope this helps someone else. Cheers\nUpdate 09.03.20\nAfter constant badgering from Malwarebytes I installed their latest release, version 4.1.0.56, for my system (Win 7). Malwarebytes is still duff running VSC 'Run File in Terminal', until I turn off 'Ransomeware Protection'. So it looks like I will have to put up with Malwarebytes badgering me about this protection being turned off, or junk Malwarebytes, which I have paid for. Cheers Russ","Q_Score":0,"Tags":"python","A_Id":59829302,"CreationDate":"2020-01-19T19:37:00.000","Title":"Visual Studio Code Python extension 'Run File in Terminal' not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want python to click on a key on my keyboard for example the arrow down key when a specific word for example google is present somewhere in the browser or in the searh bar. Is it possible with selenium or the os module. Any suggestions?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3289,"Q_Id":59815209,"Users Score":1,"Answer":"you could search for the element with an xpath looking for the text you are searching e.g. $x('\/\/*[.=\"Text\"]') and then use sendKey() to press the key","Q_Score":0,"Tags":"python,selenium,automation,keyboard,arrow-keys","A_Id":59817029,"CreationDate":"2020-01-19T23:05:00.000","Title":"How to simulate pressing the arrow down key when a specific element is present in the HTML using Selenium and Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a way to find words with the exact number of the given character.\nFor example:\nIf we have this input: ['teststring1','strringrr','wow','strarirngr'] and we are looking for 4 r characters\nIt will return only ['strringrr','strarirngr'] because they are the words with 4 letters r in it. \nI decided to use regex and read the documentation and I can't find a function that satisfies my needs.\nI tried with [r{4}] but it apparently returns any word with letters r in it. \nPlease help","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":59815641,"Users Score":0,"Answer":"The square brackets are for matching any items in the set, e.g. [abc] matches any words with a,b or c. In your case, it evaluates to [rrrr], so any one r is a match. Try it without the brackets: r{4}","Q_Score":0,"Tags":"python","A_Id":59815691,"CreationDate":"2020-01-20T00:21:00.000","Title":"Finding exact number of characters in word","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have limited knowledge about sample_weights in the sklearn library, but from what I gather, it's generally used to help balance imbalanced datasets during training. What I'm wondering is, if I already have a perfectly balanced binary classification dataset (i.e. equal amounts of 1's and 0's in the label\/Y\/class column), could one add a sample weight to the 0's in order to put more importance on predicting the 1's correctly?\nFor example, let's say I really want my model to predict 1's well, and it's ok to predict 0's even though they turn out to be 1's. Would setting a sample_weight of 2 for 0's, and 1 for the 1's be the correct thing to do here in order to put more importance on correctly predicting the 1's? Or does that matter? And then I guess during training, is the f1 scoring function generally accepted as the best metric to use?\nThanks for the input!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":59816484,"Users Score":0,"Answer":"ANSWER\nAfter a couple rounds of testing and more research, I've discovered that yes, it does make sense to add more weight to the 0's with a balanced binary classification dataset, if your goal is to decrease the chance of over-predicting the 1's. I ran two separate training sessions using a weight of 2 for 0's and 1 for the 1's, and then again vice versa, and found that my model predicted less 1's when the weight was applied to the 0's, which was my ultimate goal.\nIn case that helps anyone. \nAlso, I'm using SKLearn's Balanced Accuracy scoring function for those tests, which takes an average of each separate class's accuracy.","Q_Score":1,"Tags":"python-3.x,scikit-learn,classification","A_Id":59871447,"CreationDate":"2020-01-20T02:58:00.000","Title":"Does it make sense to use sample_weights for balanced datasets?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My dataset has a column where upon printing the dataframe each entry in the column is like so:\n{\"Wireless Internet\",\"Air conditioning\",Kitchen}\nThere are multiple things wrong with this that I would like to correct\n\nUpon printing this in the console, python is printing this:'{\"Wireless Internet\",\"Air conditioning\",Kitchen}' Notice the quotations around the curly brackets, since python is printing a string. \nIdeally, I would like to find a way to convert this to a list like: [\"Wireless Internet\",\"Air conditioning\",\"Kitchen\"] but I do not know how. Further, notice how some words so not have quotations, such as Kitchen. I do not know how to go about correcting this. \n\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":59817518,"Users Score":0,"Answer":"what you have is a set of words, curly brackets are for Dictionary use such as {'Alex,'19',Marry','20'} its linking it as a key and value which in my case it name and age, rather than that you can use to_list command in python maybe it suits your needs.","Q_Score":3,"Tags":"python,string,list,dictionary,type-conversion","A_Id":59817648,"CreationDate":"2020-01-20T05:37:00.000","Title":"My Dataset is showing a string when it should be a curly bracket set\/dictionary","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Spyder with python 3.6.5, the debugger stops at the same line on the same file (line: 183) even if there is no breakpoint there. I have restarted the computer, spyder etc but its not fixed.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1255,"Q_Id":59820082,"Users Score":1,"Answer":"Personally, I use a tool named Rookout to avoid cases like this one. The breakpoint doesn't actually stop your code, so you can keep your sanity :)","Q_Score":3,"Tags":"python,debugging,spyder","A_Id":59838612,"CreationDate":"2020-01-20T09:15:00.000","Title":"Spyder debugger stops even if no breakpoint","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Spyder with python 3.6.5, the debugger stops at the same line on the same file (line: 183) even if there is no breakpoint there. I have restarted the computer, spyder etc but its not fixed.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1255,"Q_Id":59820082,"Users Score":1,"Answer":"The same happened to me, I followed what pam said but the List Breakpoints was empty. My project has several files with functions and subfunctions. And the debugger was stopping there even though there were no red bullet breakpoints\nin the menu Debug the Clear breakpoints in all files did the thing.","Q_Score":3,"Tags":"python,debugging,spyder","A_Id":65652226,"CreationDate":"2020-01-20T09:15:00.000","Title":"Spyder debugger stops even if no breakpoint","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Spyder with python 3.6.5, the debugger stops at the same line on the same file (line: 183) even if there is no breakpoint there. I have restarted the computer, spyder etc but its not fixed.","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":1255,"Q_Id":59820082,"Users Score":6,"Answer":"I found a solution. The breakpoint \"red bullet\" doesn't appear in the lines of code but you can use List breakpoints in the DEBUG menu. The breakpoint was showing in the list and i just did clear this breakpoint","Q_Score":3,"Tags":"python,debugging,spyder","A_Id":59820308,"CreationDate":"2020-01-20T09:15:00.000","Title":"Spyder debugger stops even if no breakpoint","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a task in which in have to create view.py, template, url.py and model.py in django, In which I have four Button D1, D2, D3, D4 in template.\nWhen I click on D1 it should redirect me to a page whose link is:\nhttp:\/\/127.0.0.1:8000\/uploads\/test\/**D1**\nAnd while clicking on D2 link redirects me one same page and link is http:\/\/127.0.0.1:8000\/uploads\/test\/**D2**\nSimilarly while clicking on D2 and D3 links are\nhttp:\/\/127.0.0.1:8000\/uploads\/test\/**D3** and http:\/\/127.0.0.1:8000\/uploads\/test\/**D4**","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":105,"Q_Id":59821470,"Users Score":2,"Answer":"You can pass parameters in Django URLs like this\npath('test\/<int:post_id>',views.index, name='index'),\nHere post_id is the parameter you can use yours.\n<int:> is for integers and <str:> is for strings","Q_Score":0,"Tags":"python,django,django-views","A_Id":59821836,"CreationDate":"2020-01-20T10:37:00.000","Title":"How to pass parameter in url?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using databases package in my fastapi app.  databases has execute and fetch functions, when I tried to return column values after inserting or updating using execute, it returns only the first value, how to get all the values without using fetch..\nThis is  my query\n\nINSERT INTO table (col1, col2, col3, col4)\n  VALUES ( val1, val2, val3, val4 ) RETURNING col1, col2;","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":59822148,"Users Score":0,"Answer":"I had trouble with this also, this was my query:\n\nINSERT INTO notes (text, completed) VALUES (:text, :completed) RETURNING notes.id, notes.text, notes.completed\n\nUsing database.execute(...) will only return the first column.\nBut.. using database.fetch_one(...) inserts the data and returns all the columns.\nHopes this helps","Q_Score":1,"Tags":"python,database,fastapi","A_Id":60306879,"CreationDate":"2020-01-20T11:17:00.000","Title":"Get whole row using database package execute function","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using databases package in my fastapi app.  databases has execute and fetch functions, when I tried to return column values after inserting or updating using execute, it returns only the first value, how to get all the values without using fetch..\nThis is  my query\n\nINSERT INTO table (col1, col2, col3, col4)\n  VALUES ( val1, val2, val3, val4 ) RETURNING col1, col2;","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":124,"Q_Id":59822148,"Users Score":1,"Answer":"INSERT INTO table (col1, col2, col3, col4) VALUES ( val1, val2, val3, val4 ) RETURNING (col1, col2);\n\nyou can use this query to get all columns","Q_Score":1,"Tags":"python,database,fastapi","A_Id":59823349,"CreationDate":"2020-01-20T11:17:00.000","Title":"Get whole row using database package execute function","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a project where I need to send device parameters to the server. I will be using Rasberry Pi for that and flask framework. \n1. I want to know is there any limitation of HTTPS POST requests per second. Also, I will be using PythonAnywhere for server-side and their SQL database. \nInitially, my objective was to send data over the HTTPS channel when the device is in sleep mode. But when the device (ex: car) wakes up I wanted to upgrade the HTTPS to WebSocket and transmit data in realtime. Later came to know PythonAnywhere doesn't support WebSocket.\nApart from answering the first question, can anyone put some light on the second part? I can just increase the number of HTTPS requests when the device is awake (ex: 1 per 60 min in sleep mode and 6 per 60sec when awake), but it will be unnecessary data consumption over the wake period for transmission of the overhead. It will be a consistent channel during the wake period.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":569,"Q_Id":59822489,"Users Score":2,"Answer":"PythonAnywhere developer here: from the server side, if you're running on our platform, there's no hard limit on the number of requests you can handle beyond the amount of time your Flask server takes to process each request.  In a free account you would have one worker process handling all of the requests, each one in turn, so if it takes (say) 0.2 seconds to handle a request, your theoretical maximum throughput would be five requests a second.  A paid \"Hacker\" plan would have two worker processes, and they would both be handling requests, to that would get you up to ten a second.  And you could customize a paid plan and get more worker processes to increase that.\nI don't know whether there would be any limits on the RPi side; perhaps someone else will be able to help with that.","Q_Score":1,"Tags":"python-3.x,http,flask,websocket,pythonanywhere","A_Id":59829441,"CreationDate":"2020-01-20T11:38:00.000","Title":"Limit of HTTPS request per 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 hope someone can help me as I would like to use PyCharm to develop in Python.\nI have looked around but do not seem to be able to find any solutions to my issue.\nI have Python 3 installed using the Windows msi.\nI am using Windows 10 . have downloaded PyCharm version 2019.3.1 (Community Edition).\nI create a new project using the Pure Python option.\nOn trying to pip install any package, I get the error \npip is configured with locations that require TLS\/SSL, however the ssl module in Python is not available\nIf I try this in VSCode using the terminal it works fine.\nCan anyone tell me how to resolve this issue. It would appear to be a problem with the virtual environment but I do not know enough to resolve the issue.\nThanks for your time.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2841,"Q_Id":59823170,"Users Score":2,"Answer":"Sorry guys, it appears the basic interpreter option was on Anaconda, that I had installed sometime ago , forgotten about and it defaulted to it . Changing my basic interpreter option to my Python install (Python.exe) solved the issue.  \nKeep on learning","Q_Score":1,"Tags":"python,pip,pycharm","A_Id":59837042,"CreationDate":"2020-01-20T12:19:00.000","Title":"PyCharm venv issue \"pip is configured with locations that require TLS\/SSL, however the ssl module in Python is not available\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed the latest version of Tensorflow via pip install tensorflow and whenever I run a program, I get the log message:\n\nW tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found\n\nIs this bad? How do I fix the error?","AnswerCount":16,"Available Count":5,"Score":0.024994793,"is_accepted":false,"ViewCount":357438,"Q_Id":59823283,"Users Score":2,"Answer":"download CUDA Toolkit 11.0 RC\nTo solve the issue,\nI just find cudart64_101.dll on my disk\n( C:\\Program Files\\NVIDIA Corporation\\NvStreamSrv) and add it as variable environment that is add value (C:\\Program Files\\NVIDIA\\Corporation\\NvStreamSrv)cudart64_101.dll to user's environment variable Path).","Q_Score":143,"Tags":"python,python-3.x,tensorflow,keras,tensorflow2.0","A_Id":68297432,"CreationDate":"2020-01-20T12:26:00.000","Title":"Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed the latest version of Tensorflow via pip install tensorflow and whenever I run a program, I get the log message:\n\nW tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found\n\nIs this bad? How do I fix the error?","AnswerCount":16,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":357438,"Q_Id":59823283,"Users Score":0,"Answer":"This could be caused by the version of python you are running as well, I was using the python 3.7 from the microsoft store and I run into this error, switching to python 3.10 fixed it.","Q_Score":143,"Tags":"python,python-3.x,tensorflow,keras,tensorflow2.0","A_Id":72103706,"CreationDate":"2020-01-20T12:26:00.000","Title":"Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed the latest version of Tensorflow via pip install tensorflow and whenever I run a program, I get the log message:\n\nW tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found\n\nIs this bad? How do I fix the error?","AnswerCount":16,"Available Count":5,"Score":0.024994793,"is_accepted":false,"ViewCount":357438,"Q_Id":59823283,"Users Score":2,"Answer":"Tensorflow gpu 2.2 and 2.3 nightly\n(along CUDA Toolkit 11.0 RC)\nTo solve the same issue as OP, I just had to find cudart64_101.dll on my disk (in my case C:\\Program Files\\NVIDIA Corporation\\NvStreamSrv) and add it as variable environment (that is add value C:\\Program Files\\NVIDIA\\Corporation\\NvStreamSrv)cudart64_101.dll to user's environment variable Path).","Q_Score":143,"Tags":"python,python-3.x,tensorflow,keras,tensorflow2.0","A_Id":62364379,"CreationDate":"2020-01-20T12:26:00.000","Title":"Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed the latest version of Tensorflow via pip install tensorflow and whenever I run a program, I get the log message:\n\nW tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found\n\nIs this bad? How do I fix the error?","AnswerCount":16,"Available Count":5,"Score":0.0374824318,"is_accepted":false,"ViewCount":357438,"Q_Id":59823283,"Users Score":3,"Answer":"I installed cudatoolkit 11 and copy dll\nC:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.1\\bin to C:\\Windows\\System32.\nIt fixed for PyCharm but not for Anaconda jupyter:\n\n[name: \"\/device:CPU:0\" device_type: \"CPU\" memory_limit: 268435456\nlocality { } incarnation: 6812190123916921346 , name: \"\/device:GPU:0\"\ndevice_type: \"GPU\" memory_limit: 13429637120 locality {   bus_id: 1\nlinks {   } } incarnation: 18025633343883307728 physical_device_desc:\n\"device: 0, name: Quadro P5000, pci bus id: 0000:02:00.0, compute\ncapability: 6.1\" ]","Q_Score":143,"Tags":"python,python-3.x,tensorflow,keras,tensorflow2.0","A_Id":65183422,"CreationDate":"2020-01-20T12:26:00.000","Title":"Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed the latest version of Tensorflow via pip install tensorflow and whenever I run a program, I get the log message:\n\nW tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found\n\nIs this bad? How do I fix the error?","AnswerCount":16,"Available Count":5,"Score":-1.0,"is_accepted":false,"ViewCount":357438,"Q_Id":59823283,"Users Score":-4,"Answer":"A simpler way would be to create a link called cudart64_101.dll to point to cudart64_102.dll. This is not very orthodox but since TensorFlow is looking for cudart64_101.dll exported symbols and the nvidia folks are not amateurs, they would most likely not remove symbols from 101 to 102. It works, based on this assumption (mileage may vary).","Q_Score":143,"Tags":"python,python-3.x,tensorflow,keras,tensorflow2.0","A_Id":60424108,"CreationDate":"2020-01-20T12:26:00.000","Title":"Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having problems with uninstalling TensorFlow.\nI have a Python script that uses TensorFlow. I want it to use TensorFlow1.15, but it is currently using TensorFlow 2.1.0. I deleted TensorFlow via my cmd: pip uninstall tensorflow and pip uninstall tensorflow-gpu. When I run these commands again it says that TensorFlow is not installed. However, I can see that my script says it is using TensorFlow 2.1.0 (I added the line:print(tf.__version__) in my script). Does anyone know where this TensorFlow 2.1.0 is installed and how I can delete it from my PC?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7509,"Q_Id":59824224,"Users Score":0,"Answer":"This problem means that you use different pythons in your terminal and your script.\nYou mentioned PyCharm. By default, it creates a virtual environment for a new project. It also can use your global python. In any case, open a terminal in PyCharm (it should be in the bottom of the window or View -> Tool Windows -> Terminal or Option + F12 on Mac, Alt + F12 on Windows). From there you should run pip uninstall tensorflow. PyCharm automatically activates the correct python environment in the terminal.","Q_Score":0,"Tags":"python,tensorflow","A_Id":59824522,"CreationDate":"2020-01-20T13:22:00.000","Title":"Uninstall tensorflow 2.1.0","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was using tesseract-ocr (pytesseract) for spanish and it achieves very high accuracy when you set the language to spanish and of course, the text is in spanish. If you do not set language to spanish this does not perform that good. So, I'm assuming that tesseract is using many postprocessing models for spellchecking and improving the performance, I was wondering if anybody knows some of those models (ie edit distance, noisy channel modeling) that tesseract is applying. \nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":583,"Q_Id":59825266,"Users Score":0,"Answer":"Your assumption is wrong: If you do not specify language, tesseract uses English model as default for OCR. That is why you got wrong result for Spanish input text. There is no spellchecking post processing.","Q_Score":0,"Tags":"ocr,tesseract,python-tesseract","A_Id":59855444,"CreationDate":"2020-01-20T14:24:00.000","Title":"Does anyone know how Tesseract - OCR postprocessing \/ spellchecking works?","Data Science and Machine Learning":0,"Database and SQL":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":"Blender 2,8\nWindows 10x64\nI would like to restrict an add-on via python to be attached to the Sculpting tab when it is selected.  I have looked through the docs and cannot find a setting to do this.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":84,"Q_Id":59826294,"Users Score":1,"Answer":"Found the solution.\nuse bl_context = \"sculpt_mode\"\n\nbl_context = \"mesh_edit\", \"curve_edit\", \"surface_edit\", \"text_edit\",\n  \"armature_edit\", \"mball_edit\", \"lattice_edit\", \"posemode\",\n  \"sculpt_mode\", \"weightpaint\", \"vertexpaint\", \"imagepaint\",\n  \"particlemode\", \"objectmode\"\nbl_space_type = \"EMPTY\", \"VIEW_3D\", \"TIMELINE\", \"GRAPH_EDITOR\",\n  \"DOPESHEET_EDITOR\", \"NLA_EDITOR\", \"IMAGE_EDITOR\", \"SEQUENCE_EDITOR\",\n  \"CLIP_EDITOR\", \"TEXT_EDITOR\", \"NODE_EDITOR\", \"LOGIC_EDITOR\",\n  \"PROPERTIES\", \"OUTLINER\", \"USER_PREFERENCES\", \"INFO\", \"FILE_BROWSER\",\n  \"CONSOLE\"\nbl_region_type = \"WINDOW\", \"HEADER\", \"CHANNELS\", \"TEMPORARY\", \"UI\",\n  \"TOOLS\", \"TOOL_PROPS\", \"PREVIEW\"","Q_Score":1,"Tags":"python,blender","A_Id":59826771,"CreationDate":"2020-01-20T15:22:00.000","Title":"How do you restrict a blender 2.8 add-on to a specific main tab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a solution to find the percentage area covered by a polygon inside another polygon, from geo coordinates using python. \nThe polygon can be either fully reside inside the other one or a portion of the second polygon.\nIs there a solution to this. \nPlease advice.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":232,"Q_Id":59827622,"Users Score":0,"Answer":"Percentage is just area of intersection over area of the (other) polygon:\narea(intersection)\/area(polygon2).\nBasically any of geometry packages should be able to compute this, as they all support area and intersection functions: I think Geopandas, SymPy, Shapely (and others I missed) should be able to do this. There might be differences in supported formats. \nYou did not specify what Geo coordinates you use though. I think Geopandas and SymPy support only 2D maps (flat map) - meaning you need to use appropriate projection to get exact result, and Shapely works with spherical Earth model.","Q_Score":0,"Tags":"python,geospatial","A_Id":59835207,"CreationDate":"2020-01-20T16:42:00.000","Title":"Python package\/function to get percentage area covered by one polygon in another polygon using geo coordinates","Data 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 Tesseract OCR for my program and I am going to convert it into a single .exe file using pyinstaller. The problem is that in order for Tesseract to work, I need to reference the path to the program installed on my computer, like this: pytesseract.pytesseract.tesseract_cmd = 'E:\\\\Tesseract-OCR\\\\tesseract'\nSince this is not just a separate library that can be imported, but a standalone program, I can't pass it to pyinstaller as an '--add_data' argument. How do I make a one-file executable then?","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4085,"Q_Id":59829470,"Users Score":0,"Answer":"since bundling everything up with pyinstaller could be a real pain, I did the following steps:\n\nImported Pytesseract in my script\ncreated the Exe file with pyinstaller (without defining anything in my spec file)\nbundled Tesseract-Ocr installer and my script.exe with an external installer creator. \n\nSo the final user will have both the tesseract installer and tesseract. \nWith the external installer you have a lot of freedom and you can also play with the path variable.","Q_Score":3,"Tags":"python,ocr,pyinstaller,tesseract,python-tesseract","A_Id":60913631,"CreationDate":"2020-01-20T19:05:00.000","Title":"Pyinstaller and Tesseract OCR","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The aim of the function is very simple. Using only one int-type argument, it recursively prints as many lines as the argument dictates. The first line contains one character, the second (assuming the argument is not one) two characters, and so on, until the nth line which contains n characters is printed.\nWith only one argument and no declaration of variables outside the function, I can't figure out how to properly establish a fluid frame of reference for my base case that is not pseudo-iteration. The \"counting down\" I can abstractly represent is the lessening of absence, which obviously requires something to replace it with. Because the output only has to be one character, I have considered making an absurdly long string and slicing it the proper amount of times using the parameter, but have since rejected the idea for its lack of creativity.\nIs there a solution to this problem that I'm just not seeing?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":477,"Q_Id":59829892,"Users Score":1,"Answer":"You can get locked into thinking that you must first print, and then make the recursive call. But in this case you need to first make the recursive call and then print, which changes the order.","Q_Score":0,"Tags":"python,python-3.x,recursion,tail-recursion","A_Id":59830305,"CreationDate":"2020-01-20T19:40:00.000","Title":"How does one \"count up\" using a recursive function using only one parameter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I make a step-by-step GUI Layout with Tkinter Python 3.7? What I mean is that I want to have the user enter some information, press the \"NEXT\" button and enter some more information, etc. I don't think there's really a feasible way to completely change the layout like this with Tkinter, so I'm hoping there's something I'm missing. How do I do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":59832178,"Users Score":0,"Answer":"I don't think there's really a feasible way to completely change the layout like this with Tkinter,\n\nThat is incorrect. This is trivially easy with Tkinter. Create a function or class for each step. All of the widgets for that step should be inside a single frame.\nYou then just need to call the first function or class to create the frame. When the user clicks \"next\", destroy the frame and create the next frame. And so on.","Q_Score":0,"Tags":"python,python-3.x,user-interface,tkinter","A_Id":59832246,"CreationDate":"2020-01-20T23:21:00.000","Title":"Step-by-step tkinter GUI layout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't run python scripts just by typing python nameofthescript.py on Windows 10 cmd. The only way to make it work is by typing python followed by space and C:\\script\\directory\\nameofthefile.py.\nI just would like to use a quick way to run python scripts. Already tried to type py instead of python.\nI've already added the directory to the PATH environment variable. Have not been able to find the answer online. If more information is needed to solve the problem, I can try to provide it.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4914,"Q_Id":59832392,"Users Score":0,"Answer":"Your command prompt should be in the folder with the file in it. Eg, if you cd C:\\script\\directory then you could  python nameofthescript.py","Q_Score":1,"Tags":"python,python-3.x,cmd,windows-10","A_Id":59832411,"CreationDate":"2020-01-20T23:49:00.000","Title":"Running python scripts on windows 10 cmd just by typing python nameofthescript.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I can't run python scripts just by typing python nameofthescript.py on Windows 10 cmd. The only way to make it work is by typing python followed by space and C:\\script\\directory\\nameofthefile.py.\nI just would like to use a quick way to run python scripts. Already tried to type py instead of python.\nI've already added the directory to the PATH environment variable. Have not been able to find the answer online. If more information is needed to solve the problem, I can try to provide it.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":4914,"Q_Id":59832392,"Users Score":-1,"Answer":"Check if your file has permission to be executed. I'm not familiar with Windows, but on Linux it's chmod +x name_of_file.py, or with sudo, if you need root privileges. Also, check your python default version, because in most cases python calls python2.7 and not python3...","Q_Score":1,"Tags":"python,python-3.x,cmd,windows-10","A_Id":59832496,"CreationDate":"2020-01-20T23:49:00.000","Title":"Running python scripts on windows 10 cmd just by typing python nameofthescript.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Basically my question is does saying not affect the whole if statement, even if I added an or or and in it, or does it affecting only the part that does not begin with an or or and? \nEDIT:\nSome people tried to send me another similar question(thanks for the help!), but it was talking about the hierarchy, while I was talking about whether or whether not the not affects the whole if-statement.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":144,"Q_Id":59834130,"Users Score":1,"Answer":"So the way python statements work is that the not will only effect the next true\/false statement it encounters. not a and b would look for a case where a is false and b is true, while not (a and b) would look for a case where both a and b are not true at the same time. You could even do b and not a and that would give an identical result to not a and b","Q_Score":2,"Tags":"python,python-3.x,if-statement,negation","A_Id":59834157,"CreationDate":"2020-01-21T04:20:00.000","Title":"Does ''not'' affect the whole if statement in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After a certain amount of time, my windows computer goes into sleep mode. I am currently using PowerShell to run multiple programs in succession. I do not want to change the settings so the computer doesn't go to sleep. I want to find a way in which when the computer goes to sleep, PowerShell continues to run the python codes in the background. This way, I can also keep my computer locked if I am not at home. The reason I want to do this is that I need to produce a lot of data and plots in a short amount of time.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5996,"Q_Id":59835279,"Users Score":2,"Answer":"Check your computers \"Power Options\" in the Control panel. \nYou don't need to worry about the screen locking because as long as the computer doesn't get put to sleep, your process should continue to run. However, if your system is set to sleep after a set amount of time you may need to change this to Never. Keep in mind there are separate settings depending on whether or not the system is plugged in.","Q_Score":1,"Tags":"python,sleep","A_Id":59835344,"CreationDate":"2020-01-21T06:24:00.000","Title":"When your computer is in sleep mode, can you make it so python runs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to determine what the expected type of a particular argument is from an argparse.ArgumentParser object. Is that possible?\nThe context is to reconstruct an argparse.Namespace object from string key, value pairs, however I don't know what type the values are supposed to be (I only have them as strings) and would prefer not to have to guess.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":38,"Q_Id":59835485,"Users Score":1,"Answer":"Built-in function type() could be used to check argument type.","Q_Score":0,"Tags":"python,argparse","A_Id":59835835,"CreationDate":"2020-01-21T06:42:00.000","Title":"How can query I the expected type of an argument from an argparse parser object?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm starting to work with the MapReduce paradigm with Pyspark, I'm stuck with a problem and I don't know if it a programming error or that I shouldn't do it this way.\nI have data from which I am extracting the following information with map for each line:\n(id, (date, length, counter)), I did it this way to extract all the info I need from the raw data file and filtering the noisy lines so I don't have to use the raw data file again. Btw: Counter is originally 1, and it is intended for addition in future reduceByKey.\nNow the data looks like this:\ndata = [('45', ('28\/5\/2010', 0.63, 1)), ('43', ('21\/2\/2012', 2.166, 1)), ('9', ('12\/1\/2009', 2.33, 1))]\nFirst, I am trying to count the number of key-value pairs, so it is a simple reduceByKey adding the counters, I tried to do it this way: data.reduceByKey(lambda a,b: a[2] + b[2]) which provides the following error TypeError: 'int' object is not subscriptable. \nIf a and b are supposed to get the value of the pair, the element 2 is supposed to have the counter of it, I cannot get my head around it. Is it better to map several times the raw data file extracting every-time a different needed value? Should I map this data variable extracting (key, value) pairs each time with the value needed from the tuple? Is it just that I'm making a programming error? \nAny guidance is welcome, thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":59837355,"Users Score":0,"Answer":"Ok, I found the issue. \nWhen reducing for example (id, (x, x, 1)), (id, (y, y, 1)), (id, (z, z, 1)), in the first reduce you would obtain (id, 2), (id, (z, z, 1)) so when trying to reducing again, the number 2 in the first element is non subscriptable, I must keep the data structure during the process.","Q_Score":0,"Tags":"python,pyspark,mapreduce","A_Id":59837712,"CreationDate":"2020-01-21T08:57:00.000","Title":"Reducing tuple values with reduceByKey in Pyspark","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to create a column in a table that is autoupdated if one or more columns (possibly in another table) are updated, but it also should be possible to edit this column directly (and value should be kept in sql unless said other cols are updated, in which case first logic is applied)\nI tried column_property but it seems that its merely a construction inside python and doesnt represent an actual column\nI also tried hybrid_property and default, both didnt accomplish this\nThis looks like insert\/update trigger, however i want to know \"elegant\" way to declare it if its even possible\nI use declarative style for tables on postgres\nI dont make any updates to sql outside of sqlalchemy","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":59837697,"Users Score":0,"Answer":"Definitely looks like insert\/update triggers. But if I were you, I would incapsulate this logic in python by using 2 queries , so it will be more clear","Q_Score":0,"Tags":"python,sql,python-3.x,postgresql,sqlalchemy","A_Id":59838713,"CreationDate":"2020-01-21T09:17:00.000","Title":"sqlalchemy create a column that is autoupdated depending on other columns","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to classify images of cells into N classes (\"cell 1\", \"cell 2\" ...) but some of the images are just noise and I would like to either not classify them or put them into a \"garbage\" class.\nI have tried the latter, but it is not very successful and I suspect it is because my \"garbage\" class is very heterogenous.\nAny suggestions on how to allow excluding some data from classification, or classify it as noise?\nI am using python and sklearn, but I would welcome either specific python\/sklearn tips or generic machine learning algorithms.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":59838018,"Users Score":0,"Answer":"I would recommend to \n\nmake a binary classifier that classifies into\n\"garbage\"\/\"non-garbage\" classes\nmake a regular N-classes classifier that classifies \"non-garbage\"\ninputs","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,classification,noise","A_Id":59838258,"CreationDate":"2020-01-21T09:34:00.000","Title":"How to classify data into N classes + one \"garbage\" class (or leave some data out)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'am using visual studio express 2017 and I'd like to use it to developp in python. The thing is that I find many installation tutorial to use it with Community (or upper) but not Express.\nI can't change for Community so, do you know if there is a solution ? the important point is that I have no workload to install via the installer. Actually, the installer is pretty empty as the only thing I have in it is the installed langages and the installation directory.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":59841067,"Users Score":0,"Answer":"Nobody can help ? I am currently with VSCode for my python code, but I found it less usefull thant Visual Studio","Q_Score":0,"Tags":"python,visual-studio,visual-studio-express,python-install","A_Id":59986664,"CreationDate":"2020-01-21T12:22:00.000","Title":"run python in visual studio express 2017","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Robot Framework. I came across a scenario where i just want to create Employee details and not assert, is there a way in Robot framework where i can run a file which has KeyWords section and not TestCases and still execute the operation?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":152,"Q_Id":59841252,"Users Score":0,"Answer":"No, you can\u2019t execute keyword without testcase.","Q_Score":2,"Tags":"python,robotframework","A_Id":59841374,"CreationDate":"2020-01-21T12:32:00.000","Title":"How to run Keywords directly instead of TestCases In 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":1},{"Question":"So, as part of an assignment, I am doing player suggestions for NBA draft picks using clustering algorithm. The clustering algorithm is made in python and I want to show the result in the form of a user interface HTML web page. Is it possible to display the python output in an HTML web page.\nIn other words, the python code should run in the background of the HTML web page.\nJust a note: I am not wanting to just import the matplotlib animations, but the whole algorithm from Python to HTML web  page such that when the user interacts with the interface the python algorithm must work in the background of the web page.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":59844683,"Users Score":0,"Answer":"Assuming you are using matplotlib to display the results of the clustering algorithm, I would suggest googling the \"mpld3\" package. It is easy to use, and the results generated by mpld3's convenience routines can be embedded on a web page. If you choose to try mpld3 out, I think the routine you want to try is fig_to_html(). Follow the instructions on the official website and the \"Quick Start Guide\" for more detail!","Q_Score":0,"Tags":"javascript,python,html,user-interface","A_Id":59844806,"CreationDate":"2020-01-21T15:49:00.000","Title":"Displaying Python Machine Learning Algorithm as HTML Web page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I plan to use NLTK, Gensim and Scikit Learn for some NLP\/text mining. But i will be using these libraries to work with my org data. The question is while using these libraries 'do they make API calls to process the data' or is the data taken out of the python shell to be processed. It is a security question, so was wondering if someone has any documentation for reference.\nAppreciate any help on this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":59845191,"Users Score":0,"Answer":"Generally with NLTK, gensim, and scikit-learn, algorithms are implemented in their source code, and run locally on your data, without sending data elsehwere for processing. \nI've never noticed any documentation\/functionality of these packages mentioning a reliance on an remote\/cloud service, nor seen users discussing the same. \nHowever, they're each large libraries, with many functions I've never reviewed, and with many contributors adding new options. And I don't know if the project leads have stated an explicit commitment to never rely on external services. \nSo a definitive, permanent answer may not be possible. To the extent such security is a concern for your project, you should carefully review the documentation, and even source code, for those functions\/classes\/methods you're using. (None of these projects would intentionally hide a reliance on outside services.)\nYou could also develop, test, and deploy the code on systems whose ability to contact outside services is limited by firewalls \u2013 so that you could detect and block any undisclosed or inadvertent communication with outside machines. \nNote also that each of these libraries in turn relies on other public libraries. If your concern also extends to the potential for either careless or intentionally, maliciously-inserted methods of private data exfiltration, you would want to do a deeper analysis of these libraries & all other libraries they bring-in. (Simply trusting the top-level documentation could be insufficient.) \nAlso, each of these libraries have utility functions which, on explicit user demand, download example datasets or shared non-code resources (like lists of stopwords or lexicons). Using such functions doesn't upload any of your data elsewhere, but may leak that you're using specific functionality. The firewall-based approach mentioned above could interfere with such download steps. Under a situation of maximum vigilance\/paranoia, you might want pay special attention to the use & behavior of such extra-download methods, to be sure they're not doing any more than they should to change the local environment or execute\/replace other library code. \nFinally, by sticking to widely-used packages\/functions, and somewhat older versions that have remained continuously available, you may benefit from a bit of \"community assurance\" that a package's behavior is well-understood, without surprising dependencies or vulnerabilities. That is, many other users will have already given those code-paths some attention, analysis, & real-usage \u2013 so any problems may have already been discovered, disclosed, and fixed.","Q_Score":1,"Tags":"python,api,nlp,nltk,gensim","A_Id":59847592,"CreationDate":"2020-01-21T16:17:00.000","Title":"API calls from NLTK, Gensim, Scikit Learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am habing trouble with xlwings and win32com.client, both xlwings and win32com.client have been working fine up until recently. \nWhen i try to import xlwings for example.\nimport xlwings\nI get an ERROR below:\n_pickle.UnpicklingError: invalid load key, '\\x00'\nI get a similar error when i run the code below:\nimport win32com.client, \nbut get no error when i run \nimport win32com\ni have tried uninstalling python and reinstalling it again but the issue still persist and reloading the modules.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":59848450,"Users Score":0,"Answer":"I managed to resolve the issue by just uninstalling python and re-installing it again. Then re-installing xlwings. note that i am using python 3.7.","Q_Score":2,"Tags":"python,pywin32,win32com,xlwings","A_Id":59861913,"CreationDate":"2020-01-21T20:06:00.000","Title":"error when running xlwings and win32com.client","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am habing trouble with xlwings and win32com.client, both xlwings and win32com.client have been working fine up until recently. \nWhen i try to import xlwings for example.\nimport xlwings\nI get an ERROR below:\n_pickle.UnpicklingError: invalid load key, '\\x00'\nI get a similar error when i run the code below:\nimport win32com.client, \nbut get no error when i run \nimport win32com\ni have tried uninstalling python and reinstalling it again but the issue still persist and reloading the modules.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":59848450,"Users Score":0,"Answer":"I resolved this issue uninstalling xlwings, erasing the content of this folder\nC:\\Users\\YOUR_USERNAME\\AppData\\Local\\Temp\\gen_py\\3.8\nand then reinstalling xlwings.\n(Anaconda 3 Python 3.8).","Q_Score":2,"Tags":"python,pywin32,win32com,xlwings","A_Id":72180306,"CreationDate":"2020-01-21T20:06:00.000","Title":"error when running xlwings and win32com.client","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to develop a system for trace and debugging an external device via COM port.\nMain service will be developed using python to receive, analyse & store logs data. \nWe decided to stream log data to web browser with gRPC protocol and draw live charts.\nHighest rate if data is 50K of signals per second and maximum size of every signal is just 10 bytes.\nSystem will be used in local network or same PC so we do not have bandwidth limits.\nWe want to make sure the web-grpc platform can cover this rate per second.\nThanks for your recommendations.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":93,"Q_Id":59849029,"Users Score":1,"Answer":"The throughput limit is mostly decided by the browser and the protobuf overhead. Since the latter is application specific, you should do a benchmark with real data on your preferred browsers.","Q_Score":0,"Tags":"benchmarking,grpc,rate,grpc-python","A_Id":59872414,"CreationDate":"2020-01-21T20:50:00.000","Title":"web-gRPC Performance Rate per second","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 clear concept on how to get the Erwin generated DDL objects with python ? I am aware Erwin API needs to be used. What i am looking if what Python Module and what API needs to used and how to use them  ? I would be thankful for some example !","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":604,"Q_Id":59850250,"Users Score":1,"Answer":"Here is a start:\nimport win32com.client\nERwin = win32com.client.Dispatch(\"erwin9.SCAPI\")\nI haven't been able to browse the scapi dll so what I know is from trial and error. Erwin publishes VB code that works, but it is not straightforward to convert.","Q_Score":0,"Tags":"python,api,erwin","A_Id":60781882,"CreationDate":"2020-01-21T22:38:00.000","Title":"Erwin API 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 have a requirement a parent python script calling multiple other python script along with the parameter. \nI have created a bat file calling the parent python script. When I run the parent python script\/bat file all the other python files called inside the parent python script gets executed but in scheduler those files get skipped. However with proper logging I'm able to see to commands before and after the call of child python files are getting executed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":59852490,"Users Score":0,"Answer":"Before calling any python code inside the another python code, the execute location goes to the windows default execute location and that was the reason child python files werent called.\nuse os.chdir() to change the working directory to the child python location","Q_Score":0,"Tags":"python","A_Id":60684925,"CreationDate":"2020-01-22T04:09:00.000","Title":"Windows scheduler isnt calling other python files from main python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Im trying to install a venv in python3 (on CentOS). However i get the following error:\n\nError: Command '['\/home\/cleared\/Develop\/test\/venv\/bin\/python3', '-Im',\n  'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit\n  status 1.\n\nI guess there is some problem with my ensurepip...\nRunning python3 -m ensurepip results in \n\nFileNotFoundError: [Errno 2] No such file or directory:\n  '\/usr\/lib64\/python3.6\/ensurepip\/_bundled\/pip-9.0.3-py2.py3-none-any.whl'\n\nLooking in the \/usr\/lib64\/python3.6\/ensurepip\/_bundled\/ I find pip-18.1-py2.py3-none-any.whl and setuptools-40.6.2-py2.py3-none-any.whl, however no pip-9.0.3-py2.py3-none-any.whl\nRunning pip3 --version gives\n\npip 20.0.1 from \/usr\/local\/lib\/python3.6\/site-packages\/pip (python\n  3.6)\n\nWhy is it looking for pip-9.0.3-py2.py3-none-any.whl when I'm running pip 20.0.1, and why to i have pip-18.1-py2.py3-none-any.whl? And how to I fix this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2273,"Q_Id":59855477,"Users Score":0,"Answer":"I would make a clean reinstall of Python (and maybe some of its dependencies as well) with your operating system's package manager (yum?).","Q_Score":1,"Tags":"python,python-3.x,pip,centos,python-venv","A_Id":60078378,"CreationDate":"2020-01-22T08:29:00.000","Title":"Venv fails in CentOS, ensurepip missing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Im trying to install a venv in python3 (on CentOS). However i get the following error:\n\nError: Command '['\/home\/cleared\/Develop\/test\/venv\/bin\/python3', '-Im',\n  'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit\n  status 1.\n\nI guess there is some problem with my ensurepip...\nRunning python3 -m ensurepip results in \n\nFileNotFoundError: [Errno 2] No such file or directory:\n  '\/usr\/lib64\/python3.6\/ensurepip\/_bundled\/pip-9.0.3-py2.py3-none-any.whl'\n\nLooking in the \/usr\/lib64\/python3.6\/ensurepip\/_bundled\/ I find pip-18.1-py2.py3-none-any.whl and setuptools-40.6.2-py2.py3-none-any.whl, however no pip-9.0.3-py2.py3-none-any.whl\nRunning pip3 --version gives\n\npip 20.0.1 from \/usr\/local\/lib\/python3.6\/site-packages\/pip (python\n  3.6)\n\nWhy is it looking for pip-9.0.3-py2.py3-none-any.whl when I'm running pip 20.0.1, and why to i have pip-18.1-py2.py3-none-any.whl? And how to I fix this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2273,"Q_Id":59855477,"Users Score":2,"Answer":"These versions are harcoded at the beginning of .\/lib\/python3.8\/ensurepip\/__init__.py. You can edit this file with the correct ones.\nRegarding the reason of this corruption, I can only guess. I would bet on a problem during the installtion of this interpreter.","Q_Score":1,"Tags":"python,python-3.x,pip,centos,python-venv","A_Id":60042378,"CreationDate":"2020-01-22T08:29:00.000","Title":"Venv fails in CentOS, ensurepip missing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I wanted to handle browser support. If the browser does not support the website, I would like to be redirected to a custom template. How do I find out if the browser supports it or not\ncan anyone help me.?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":59856669,"Users Score":1,"Answer":"The information about what the browser claims itself to be is available in request.META['HTTP_USER_AGENT'], which you can use to redirect to an error screen \"We do not support Internet Exploiter 5\" or whatever. Or, to conditionalize your template rendering for Edge cases (sorry MS, couldn't resist). \nYou can of course also write  more-or-less concealed Javascripts to test that the browser correctly handles some feature that you  absolutely require (for example, that JavaScript is not disabled, that cookies are accepted ... )","Q_Score":0,"Tags":"python,django,python-3.x,django-2.2","A_Id":59858084,"CreationDate":"2020-01-22T09:43:00.000","Title":"Django Error Handling for Browser Support","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to implement Speech-to-text using wav2letter. As far as I have researched the model uses the Arrayfire tensor library with dependency on flashlight ML library.\nNow, the flashlight library is built for Linux based system.\nIs there any way to run this model on the Windows-based system.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":626,"Q_Id":59857456,"Users Score":1,"Answer":"Wav2Letter has different train- and inference-time dependencies.\nI am assuming you will be performing training on CUDA backend. If so, you need ArrayFire and Flashlight.\nFor inference, besides basic dependancies (such as cereal for serialization, etc.) you don't need either. The FAIR team has provided their own implementations of neural network layers (linear, conv1d, etc.) based on FBGEMM (FB General Matrix Multiplication) backend. FBGEMM can both be compiled for CPU and CUDA backend - on intel-based CPUs, it can further be accelerated using intel's optimized MKL math library and on CUDA backend, using cuDNN.\nYou are free to add your own implementations of backend based on say, LibTorch or C++ TensorFlow and submit a PR.","Q_Score":1,"Tags":"python-3.x,deep-learning,speech-recognition,speech-to-text","A_Id":64513424,"CreationDate":"2020-01-22T10:21:00.000","Title":"Alternative way to run wav2letter Facebook AI Research Speech to Text model on Windows Machine","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running the API over a series of video frames to track objects through a scene and I'm extracting the bounding box coordinates for each object in order to calculate the centre of each bounding box. It would appear, however, that there is an offset in the ymin and ymax coordinates. \nThe scene is of a person walking the field of view with the bottom of the frame matched up to the persons feet (which would infer a very small value for ymin and a ymax value that would not extend to the stop of the frame. However the API gives the following normalised box coordinates [452.26962089538574, 197.93473720550537, 1073.7505388259888, 639.3438720703125]. The absolute coordinates are [0.41876816749572754, 0.10309100896120071, 0.9942134618759155, 0.3329916000366211] For reference the video is 1920 x 1080. \nThe same frame put into MATLABs video labler app (when translated into [ymin xmin ymax xmax]) returns [8.396575927734375, 57.50376892089844, 722.7988586425781, 431.51695251464844]. I'm aware they won't exactly match because I've manually drawn in the box as ground truth (this is especially true for the x coordinates), however the ymin and ymax should be pretty close and these results seem much more realistic.\nHas anyone come across this before? The bounding boxes are drawn correctly onto the image when the API runs the inference, so I'm at bit of a loss as to what's happening. As I'm taking data directly from boxes = detection_graph.get_tensor_by_name('detection_boxes:0') and storing it on each iteration.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":59858497,"Users Score":0,"Answer":"It turns out I'd over looked the fact that python's coordinate system has 0,0 in the top left and the API accounts for this by making top = ymin and bottom = ymax within visualization_utils.py. So a ymax = 1073 would indeed be near the bottom of the frame.","Q_Score":0,"Tags":"python,tensorflow,object-detection,bounding-box","A_Id":59859213,"CreationDate":"2020-01-22T11:17:00.000","Title":"Is Tensorflows object detection API producing incorrect ymin and ymax bounding box coordinates?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m way new to ML so I have a really rudimentary question. I would appreciate it if one clarifies it for me.\nSuppose I have a set of tweets which labeled as negative and positive. I want to perform some sentiment analysis. \nI extracted 3 basic features: \n\nEmotion icons \nExclamation marks \nIntensity words(very, really etc.). \n\nHow should I use these features with SVM or other ML algorithms? \nIn other words, how should I deploy the extracted features in SVM algorithm?\nI'm working with python and already know how should I run SVM or other algorithms, but I don't have any idea about the relation between extracted features and role of them in each algorithm!\nBased on the responses of some experts I update my question:\nAt first, I wanna appreciate your time and worthy explanations. I think my problem is solving\u2026 So in line with what you said, each ML algorithm may need some vectorized features and I should find a way to represent my features as vectors. I want to explain what I got from your explanation via a rudimentary example.\nSay I have emoticon icons (for example 3 icons) as one feature:\n1-Hence, I should represent this feature by a vector with 3 values. \n2-The vectorized feature can initial in this way : [0,0,0] (each value represents an icon = :) and :( and :P ). \n3-Next I should go through each tweet and check whether the tweet has an icon or not. For example [2,1,0] shows that the tweet has: :) 2 times, and :( 1 time, and :p no time.\n4-After I check all the tweets I will have a big vector with the size of n*3 (n is the total number of my tweets). \n5-Stages 1-4 should be done for other features.\n6-Then I should merge all those features by using m models of SVM (m is the number of my features) and then classify by majority vote or some other method.\nOr should create a long vector by concatenating all of the vectors, and feed it to the SVM.\nCould you please correct me if there is any misunderstanding? If it is not correct I will delete it otherwise I should let it stay cause It can be practical for any beginners such as me...\nThanks a bunch\u2026","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":83,"Q_Id":59858819,"Users Score":4,"Answer":"basically, to make things very \"simple\" and \"shallow\", all algorithm takes some sort of a numeric vector represent the features\nthe real work is to find how to represent the features as vector which yield the best result, this depends by the feature itself and on the algorithm using\nfor example to use SVM which basically find a separator plane, you need to project the features on some vectors set which yield a good enough separation, so for instance you can treat your features like this:\n\nEmotion icons - create a vector which represent all the icons present in that tweet, define each icon to an index from 1 to n so tweet represented by [0,0,0,2,1] means the 4th and 5th icons are appearing in his body 2 and 1 times respectively\nExclamation marks - you can simply count the number of occurrences (a better approach will be to represent some more information about it like the place in a sentence and such...)\nIntensity words - you can use the same approach as the Emotion icons\n\nbasically each feature can be used alone in the SVM model to classify good and bad\nyou can merge all those features by using 3 models of SVM and then classify by majority vote or some other method\nor\nyou can create a long vector by concatenating all of the vectors, and feed it to the SVM\n\nthis is just a one approach, you might tweak it or use some other one to fit your data, model and goal better","Q_Score":2,"Tags":"python,machine-learning,sentiment-analysis,feature-selection","A_Id":59859426,"CreationDate":"2020-01-22T11:33:00.000","Title":"How can I deploy my features in a Machine Learning algorithm?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using dataframes and CSV files to manipulate data. Most of the time, my dataframes, or the one provided by the API I'm using don't have indexes. If they have indexes, especially when writing and reading CSV files, I just remove them by using the name of the column, \"unnamed:0\".\nBut this time, to_CSV places indexes in my CSV file without naming the column. So I must use df.drop(df.columns[0], axis=1, inplace=True). But for pandas, the first column is the first named, not the real first one.\nI already used index=False, but it just removed an important column instead of not adding indexes.\nHow can I remove the first column which isn't named and haven't index to find it ?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1352,"Q_Id":59858908,"Users Score":0,"Answer":"Use this : df = pd.read_csv(\"nameOfFile.csv\", index_col=\"nameOfColToUseAsIndex\") and put the name of your first column in \"nameOfColToUseAsIndex\".","Q_Score":0,"Tags":"python,pandas,dataframe,indexing","A_Id":59859181,"CreationDate":"2020-01-22T11:37:00.000","Title":"How to avoid pandas from adding indexes in dataframes when using CSV files","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using dataframes and CSV files to manipulate data. Most of the time, my dataframes, or the one provided by the API I'm using don't have indexes. If they have indexes, especially when writing and reading CSV files, I just remove them by using the name of the column, \"unnamed:0\".\nBut this time, to_CSV places indexes in my CSV file without naming the column. So I must use df.drop(df.columns[0], axis=1, inplace=True). But for pandas, the first column is the first named, not the real first one.\nI already used index=False, but it just removed an important column instead of not adding indexes.\nHow can I remove the first column which isn't named and haven't index to find it ?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1352,"Q_Id":59858908,"Users Score":2,"Answer":"Writing pandas dataframes into file via to_csv() method has optional parameter index, which you can set to false to prevent it from writing its own index:\ndf.to_csv('filename.csv', index=False)","Q_Score":0,"Tags":"python,pandas,dataframe,indexing","A_Id":59859039,"CreationDate":"2020-01-22T11:37:00.000","Title":"How to avoid pandas from adding indexes in dataframes when using CSV files","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made GUI application with PyQt and wrapped it up with pyinstaller.\nAs you know, make it for onefile (sole exe file) is quite slow.\nSo, what I want to do is wrap it by using pyinstaller but not in onefile, but i still don't want to execute the exe file in the folder. I want to move the exe file to desktop directory so I can use it like onefile. I tried it but it says there is no .dll on desktop directory.\nI assume that there is quite simple solution.\nHow can I solve this problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":546,"Q_Id":59859582,"Users Score":4,"Answer":"Keep the file in the folder and create a shortcut on the desktop instead. You can have also shortcuts in the Start menu for example or pin the exe (create shortcut) in TaskBar. If you are going to distribute it a simple installer can automate the creation of the said shortcuts.","Q_Score":2,"Tags":"python,pyqt,pyinstaller","A_Id":59859685,"CreationDate":"2020-01-22T12:15:00.000","Title":"pyinstaller move .exe file to Desktop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write a Python script to search a (very large) SVN repository for specific files (ending with .mat). Usually I would use os.walk() to walk through a directory and then search for the files with a RegEx. Unfortunately I can't use os.walk() for a repository, since it is not a local directory. \nDoes anyone know how to do that? The repository is too large to download, so I need to search for it \"online\". \nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":85,"Q_Id":59859984,"Users Score":1,"Answer":"Something like\nsvn ls -R REPO-ROOT | grep PATTERN\nwill help","Q_Score":1,"Tags":"python,svn","A_Id":59866979,"CreationDate":"2020-01-22T12:40:00.000","Title":"Search SVN for specific files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to try an object detection model on a custom data set. I want it to recognize a specififc piece of metal from my garage. I took like 32 photos and labelled them. The training goes well, but up to 10% loss. After that it goes very slow, so I need to stop it. After that, I implemented the model on camera, but it has no accuracy. Could it be because of the fact that I have only 32 images of the object? I have tried with YoloV2 and Faster RCNN.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":59860042,"Users Score":0,"Answer":"It has low probability that your model implemented to a camera has no accuracy because you have only 32 images. \nAnyway before you've had about up to 10% loss (It seems to be about 90% accuracy), so it should work  I think the problem is not in the amount of images.\nAfter training your model you need to save the coefficients of model trained. \nMake sure that you implemented model trained, and not you don't use model from scratch","Q_Score":1,"Tags":"python,tensorflow","A_Id":59860211,"CreationDate":"2020-01-22T12:43:00.000","Title":"Training model on custom data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to try an object detection model on a custom data set. I want it to recognize a specififc piece of metal from my garage. I took like 32 photos and labelled them. The training goes well, but up to 10% loss. After that it goes very slow, so I need to stop it. After that, I implemented the model on camera, but it has no accuracy. Could it be because of the fact that I have only 32 images of the object? I have tried with YoloV2 and Faster RCNN.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":59860042,"Users Score":0,"Answer":"Just labeling will not help in object detection. What you are doing is image classification but expecting results of object detection. \nObject detection requires bounding box annotations and changes in the loss function which is to be fed to the model during each backpropagation step.\nYou need some tools to do data annotations first, then manipulate your Yolov2\/Fast-RCNN codes along with the loss function. Train it well and try using Image Augmentations to generate little more images because 32 images are less. In that case, you might end up in a pitfall of getting higher training accuracy but less test accuracy. Training models in fewer images sometimes lead to unexpected overfitting.\nOnly then you should try to implement using the camera.","Q_Score":1,"Tags":"python,tensorflow","A_Id":59860321,"CreationDate":"2020-01-22T12:43:00.000","Title":"Training model on custom data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"With Django 1.8 I used Django-celery to run asynchronous tasks and I was able to debug them in my IDE (either PyCharm or Eclipse+PyDev) just launching \"python celery worker\" in debug mode.\nDjango-celery doesn't support Django 2.2, so I have to run pure celery.exe.\nCelery docs say that I have to add pdb to my code and run debug via console.\nHow can I debug these tasks as I did before, adding breakpoints dynamically from my IDE?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":558,"Q_Id":59863762,"Users Score":0,"Answer":"Telnet solution doesn't work for me.\nBut I was able to debug my tasks with pdb.\nAdd breakpoint: pdb.set_trace().\nThen just run worker with -l warning, it will prevent printing of excessive info.","Q_Score":1,"Tags":"python,django,celery,django-celery,pdb","A_Id":72050714,"CreationDate":"2020-01-22T16:03:00.000","Title":"Celery + Django on Windows: debugging asynchronous tasks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"With Django 1.8 I used Django-celery to run asynchronous tasks and I was able to debug them in my IDE (either PyCharm or Eclipse+PyDev) just launching \"python celery worker\" in debug mode.\nDjango-celery doesn't support Django 2.2, so I have to run pure celery.exe.\nCelery docs say that I have to add pdb to my code and run debug via console.\nHow can I debug these tasks as I did before, adding breakpoints dynamically from my IDE?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":558,"Q_Id":59863762,"Users Score":3,"Answer":"You can use CELERY_ALWAYS_EAGER = True setting in you development env. If this is True, all tasks will be executed locally without sending it to a queue.","Q_Score":1,"Tags":"python,django,celery,django-celery,pdb","A_Id":59863960,"CreationDate":"2020-01-22T16:03:00.000","Title":"Celery + Django on Windows: debugging asynchronous tasks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to run a TensorFlow model that I estimate will take roughly 11 hours. As such, I would like to use nohup so I can exit my terminal keep the process running. I use the following command to do so:\nnohup python3 trainModel.py > log.txt &\nMy model appears to be running as normal, but gets hung up with the last message outputted being:\n2020-01-22 19:06:24.669183: I tensorflow\/core\/common_runtime\/gpu\/gpu_device.cc:1697] Adding visible gpu devices: 0\nIt is normal for my model to output this, however when I am not using nohup, the rest of the code still executes. What do I need to do to have this command run as it does when I am not using nohup?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":59866803,"Users Score":0,"Answer":"Try to use absolute paths in your execution instead of relative paths","Q_Score":1,"Tags":"python,tensorflow,google-compute-engine","A_Id":59940960,"CreationDate":"2020-01-22T19:16:00.000","Title":"Tensorflow Hanging on Google Compute Engine Using nohup","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run a TensorFlow model that I estimate will take roughly 11 hours. As such, I would like to use nohup so I can exit my terminal keep the process running. I use the following command to do so:\nnohup python3 trainModel.py > log.txt &\nMy model appears to be running as normal, but gets hung up with the last message outputted being:\n2020-01-22 19:06:24.669183: I tensorflow\/core\/common_runtime\/gpu\/gpu_device.cc:1697] Adding visible gpu devices: 0\nIt is normal for my model to output this, however when I am not using nohup, the rest of the code still executes. What do I need to do to have this command run as it does when I am not using nohup?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":59866803,"Users Score":0,"Answer":"could you send the exit status code of the execution?  echo $?\nThis will help to get an exact idea of the error\nFurthermore, can you try to send the standard error output to the log.txt file, for instance\nnohup python3 trainModel.py  2> log.txt &\nStandard output will be redirected to the nohup file and log.txt will contain the standard output error\nI Hope this helps","Q_Score":1,"Tags":"python,tensorflow,google-compute-engine","A_Id":59869881,"CreationDate":"2020-01-22T19:16:00.000","Title":"Tensorflow Hanging on Google Compute Engine Using nohup","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am wondering if there is a software library that enables opening a jpeg and converting a subset of it to an uncompressed array (such as Pillow). This would be in contrast to the more usual method which is to open the file, convert it fully to a bit array, then take a subset of the bit array. \nIn my case the subset that I have in mind is the upper left corner. The files decompress to 2544 \u00d7 4200 pixels, but I am only interested in the top left 150 x 900 pixels. \nThe background is below:\nI am hopeful that the JPEG format is a string of compressed subpanels and an algorithm could stop when it had processed enough subpanels to fulfill the required subset of the image.\nI have been searching for a while but have not found any mention of such an algorithm which, admittedly, is a special case.\nBackground\nI use pyzbar to capture a barcode from the top left corner of a JPEG image as produced a high-speed scanner. Generally this required about 250 msecs per image. The actual Pyzbar time is about 2.5 msecs while the other 99% of the time is spent reading the image from a file, having it decompressed using Pillow, extracting the upper left corner.\nThe non-profit where I do this work as a volunteer cannot really afford to replace the $25K scanner and the channel that this clunker has is the overall bottleneck. Telling the scanner to send uncompressed images would slow the whole process down by at least 90%","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":59868088,"Users Score":0,"Answer":"I don't know of an existing library that can do this, but it is possible to modify jpegtran.c and jdtrans.c from the IJG C library to only read as many MCU rows as necessary when cropping, and in your specific case the decode time should be reduced by ~75% (900 \/ 4200 lines).\nSince you are using Python, you could obtain a suitably cropped jpeg with:\nos.popen(\"jpegtran -crop 152x904 %s\" % inputfile).read()\nThis assumes the input jpeg is not progressive.","Q_Score":0,"Tags":"python-imaging-library,jpeg","A_Id":59870902,"CreationDate":"2020-01-22T20:53:00.000","Title":"Open only the top left corner of a JPEG?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The format of all of my files are as so...\n['PC-PC02@2019-01-18-00-00-00.mseed', 'PC-PC01@2019-01-19-00-00-00.mseed', 'PC-PC02@2019-01-19-00-00-00.mseed', 'PC-PC01@2019-01-20-00-00-00.mseed', 'PC-PC02@2019-01-20-00-00-00.mseed']\n(I will have a lot more files with a lot more days once I get this running, but just getting the code to work on a few, and I cannot change the format of my files).\nI need to be able to import files for an entire month, but can only run the code for one day at a time, say 2019-01-18, run the entire code, and then move on to 2019-01-19 and so on. \nIs there any way to extract just the day of the month from the file, and then loop over one day at a time? \nTo reiterate, I need to be able to import a months worth of files, but I want to run my code on day 18, then day 19, then day 20 and so. I am also open to any other suggestions that may work. I have tried googling and many other things to try to get this, but none of it seems to work, I am still learning Python too.\nThank you so much!","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":72,"Q_Id":59868419,"Users Score":-1,"Answer":"Assuming you are getting these in order from a location or some process is creating these files in order you can list out all the file objects in the directory and sort them according to their created time and then process them one by one.","Q_Score":0,"Tags":"python,date,for-loop,format,filenames","A_Id":59868610,"CreationDate":"2020-01-22T21:19:00.000","Title":"Is there a way to extract a specific part of a filename in Python to loop over it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say I have an trained RandomForestClassifier model from sklearn.  We're using gRPC to serve that model and provide predictions in real-time in a high traffic situation.  From what I understand, gRPC can support multiple threads run concurrently.  Can they all simultaneously make calls to RF's predict method without running into concurrency issues?  Is sklearn's predict thread-safe?\nIf this isn't the case, it sounds like you'd have to load individual copies of the model in each worker thread.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":59870409,"Users Score":0,"Answer":"I don't know anything about sklearn specifically, but in general, gRPC is thread-safe, and it's fine to make many concurrent calls to the same method.","Q_Score":0,"Tags":"python,scikit-learn,thread-safety,grpc,grpc-python","A_Id":59973866,"CreationDate":"2020-01-23T01:16:00.000","Title":"Model Serving with sklearn and gRPC","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"1) My goal is to create a sequence that is a list that contains ordered dictionaries. The only problem for me will be described below.\n\nI want the list to represent a bunch of \"points\" which are for all intents and purposes just an ordered dictionary. However, I notice that when I use OrderedDict class, when I print the dictionary it comes up as OrderedDict([key value pair 1, key value pair 2, ... etc)] For me, I would rather it behave like an ordered dictionary, BUT not having those DOUBLE \"messy\/ugly\" \"end marks\" which are the \"[( )]\". I don't mind if the points have ONE, and only one, type of \"end marks\". Also I would also like it if when I print this data type that stuff like OrderedDict() doesn't show up. However, I do not mind if it shows up in return values. Like you know how when you print a list it doesn't show up as list(index0, index1, ... etc) but instead it shows up as [index0, index1, ... etc]. That is what I mean. Inside the point, it would look like this\n\npoint = {'height': 1, 'weight': 3, 'age': 5, etc} <- It could be brackets or braces or parentheses. Just some type of \"end mark\", but I preferably would like it to be in {} and having key value pairs indicated by key: value and have them separated by commas.\nwhat_i_am_looking_for = [point0, point1, point2, point3, ... etc]","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":59870538,"Users Score":0,"Answer":"In Python 3.6, the ordinary dict implementation was re-written and maintains key insertion order like OrderedDict, but was considered an implementation detail. Python 3.7 made this feature an official part of the language spec, so if you use Python 3.6+ just use dict instead of OrderedDict if you don't care about backward-compatibility with Python 3.5 or earlier.","Q_Score":0,"Tags":"python","A_Id":59870780,"CreationDate":"2020-01-23T01:37:00.000","Title":"How do you create a class, or function in python that allows you to make a sequence type with specific characteristics","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a web page with data in different tables. I want to extract a particular table and compare with an excel sheet and see whether there are any differences. Note the web page is in a internal domain. I tried with requests and beautifulsoup but I got 401 error. Could anyone help how I can achieve this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":59871748,"Users Score":0,"Answer":"401 is an Unauthorized Error - which suggests your username and password may be getting rejected, or their format not accepted. Review your credentials and the exact format \/ data names expected by the page to ensure you're correctly trying to connect.","Q_Score":1,"Tags":"python,web-scraping,beautifulsoup","A_Id":59872815,"CreationDate":"2020-01-23T04:51:00.000","Title":"Scrape and compare and Web page data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"After upgrading Spyder in Anaconda from 3.3.6 to 4.0.1 using pip install --upgrade spyder the error message below popped up when I open the upgraded version of spyder:\nSpyder crashed during last session.\nIf Spyder does not start at all and before submitting a bug report, please try to reset setting to default by running Spyder with the command line option '--reset':\nWhat should I check? fix? do?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":857,"Q_Id":59872073,"Users Score":1,"Answer":"I had the same problem in win10 which I resolved by updating Spyder. Open Anaconda Prompt:\nconda install -c anaconda spyder\nIt might take several minutes to complete.","Q_Score":0,"Tags":"python,spyder","A_Id":66949734,"CreationDate":"2020-01-23T05:30:00.000","Title":"Spyder crashed during last session","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have started learning Django.I am following a tutorial series. Here after some tutorials they started class-based views.Should I give more focus on Function-based view or Class-based view for better learning.Thank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":44,"Q_Id":59872893,"Users Score":1,"Answer":"There was a period that function based programming was only there. They were made to address the basic use cases. However, the issue was that they were very basic, and was difficult to expand or customize them (other than utilizing arrangements parameters).\nTo address those issues, the class-based views was created.","Q_Score":0,"Tags":"python,django","A_Id":59873068,"CreationDate":"2020-01-23T06:42:00.000","Title":"Django Learning","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to create a multi-thread programming using python selenium.In my program i want to open 50+ different urls simultaneously, so my code is opening each url in different browsers.Whenever i ran my program my cpu utilization is reaching 100%.So sometime some of the urls are not opening.\nSo My question is if i open multiple tabs within single browser is it reduce my cpu utilization ?\nIf yes, please help me to open multiple tabs in single browser using python selenium.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1093,"Q_Id":59873157,"Users Score":0,"Answer":"Open Multiple Tabs in one browser will speed down your program, As webdriver will work only in one tab and then will move to the second tab. can't work simultaneously. its same as to reduce the number of URLs.","Q_Score":1,"Tags":"python,multithreading,selenium,cpu-usage","A_Id":59873602,"CreationDate":"2020-01-23T07:05:00.000","Title":"opening multiple chrome browser and multiple tabs in single browser is same?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any pre-trained doc2Vec models, trained in python 3 on news articles data. \nMost of the models that I am finding are in older versions. And, it's difficult to implement in python 3.7.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":59874635,"Users Score":1,"Answer":"The answer is, I'm afraid, no. Not at this time. Also, I think the python 2 models that are available are word2vec, not doc2vec","Q_Score":0,"Tags":"python,python-3.7","A_Id":59874911,"CreationDate":"2020-01-23T08:55:00.000","Title":"Is there pre-trained doc2vec model in Python 3.7?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create virtualenvs for my script. When I use pyinstaller without virtualenvs (just sudo pyinstaller myscript.spec) everything works fine. After that I activate virtualenvs and do same thing (pyinstaller myscript.spec) . When I try to execute this two files the standart one (first one) works but the one that I create with virtualenvs gives ImportError: No module named 'sip'. I did not use sip in my script and did not import it anywhere. I do pip3 install sip and compile script again but it did not change anything. What is this error and how can I fix it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":30,"Q_Id":59875084,"Users Score":1,"Answer":"Try sudo apt-get install python-sip to install Ubuntu's version","Q_Score":0,"Tags":"python,virtualenv,pyinstaller","A_Id":59875192,"CreationDate":"2020-01-23T09:21:00.000","Title":"pyinstaller on virtualenvs, No module named Import Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python module. i have different observations of RAM usage when run in different machines.\n\nIf i run it on Ubuntu PC, it runs with 8 MB of RAM\nIf i run the same program on an ARM processor, it runs with around 15 MB RAM. \n\ni would like to know, what are the parameters which are reasons for behavior and i would like to know if i can try to run it with 8 MB of RAM on the ARM processor too because i have only 32 MB of free RAM left there? \nIs it because of cross compiled python interpreter?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":59879658,"Users Score":0,"Answer":"Same program can have different RAM usage on different processors. It depends on the processor's instruction set. e.g RISC based processors use more number of instructions for the same task than CISC based processors, hence more lines of assembly code. More lines of code means more RAM usage. So the architecture of the processor and its instruction set can have impact on the RAM usage.","Q_Score":0,"Tags":"python,memory,memory-management","A_Id":64352431,"CreationDate":"2020-01-23T13:25:00.000","Title":"Is it possible that a program uses different sizes of RAM on two different processors?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am training a gan and I am the accuracy doesn't change over epoch meanwhile the loss is deacresing.\nIs there something wrong or it is normal because it's a gan?\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":59882584,"Users Score":0,"Answer":"In order to fully answer this question (specific to your case) we'd need to know what loss function you are using and how you measure accuracy.\nIn general, this can certainly happen for a variety of reasons.  The easiest reason to illustrate is with a simple classifier.  Suppose you have a 2-class classification problem (for simplicity) and an input $x$ and label (1, 0), i.e. the label says it belongs to class 1 and not class 2.  When you feed $x$ through your network you get an output: $y=(p_1, p_2)$.  If $p_1 > p_2$ then the prediction is correct (i.e. you chose the right class).  The loss function can continue to go down until $p_1=1$ and $p_2=0$ (the target).  So, you can have lots of correct predictions (high accuracy) but still have room to improve the output to better match the labels (room for improved loss).","Q_Score":0,"Tags":"python,tensorflow,machine-learning,deep-learning,artificial-intelligence","A_Id":59884342,"CreationDate":"2020-01-23T16:00:00.000","Title":"Constant accuracy over epochs","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I've several devices each having a temperature. All messages related to device temperature are published on topics device\/1\/temerature, device\/2\/temperature, etc. . I handle all messages published on this topic with Python paho-mqtt with a callback function which uses a wildcard expression client.message_on_callback_add(\"device\/+\/temperature\", ...). Is there a way to get the value of the wildcard expression, here + directly (w.o. need for parsing of msg.topic)?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2027,"Q_Id":59882816,"Users Score":2,"Answer":"No, the callback includes the topic the message was published to.\nIt is up to you to extract what ever information you need from the topic.","Q_Score":1,"Tags":"python,python-3.x,mqtt,paho","A_Id":59884314,"CreationDate":"2020-01-23T16:12:00.000","Title":"How to get wildcard value from mqtt topic?","Data Science and Machine Learning":0,"Database and SQL":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":"Why does Gunicorn send info message Handling signal: winch when application is idle?\nThere is no error, as the application continues to respond, but when it is idle, the above message is displayed.\nI could not find more information in Gunicorn handling signal documentation section except\nWINCH: Gracefully shutdown the worker processes when Gunicorn is daemonized.\n\nWhat is the meaning here, Gunicorn daemonized?\nHandling signal: winch info when idle, does one need to take some action for this?\nAny brief info on WINCH and all other signal meanings?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":8094,"Q_Id":59884188,"Users Score":23,"Answer":"A winch signal (or SIGWINCH, short for Signal Window Change) is normally sent to applications when the terminal window size changes, so that applications know to redraw on the screen. However, gunicorn interprets it to shutdown the worker processes, but only when the application is daemonized. Daemonized is just another way of saying an application is running in the background. This means that while gunicorn isn't running as a background process (i.e. it's on your screen), it handles the signal and doesn't shut down the worker processes.\nSo to answer your questions:\n\nDaemonized means an application is running in the background.\nYou don't have to take any action at all, when gunicorn is running in the background it won't be getting any Winch signals, so you don't have to worry about it shutting down.\nWinch is normally sent when a terminal window is resized (you can see this by resizing your terminal window while gunicorn is visible, you'll see a lot of handling signal messages).","Q_Score":25,"Tags":"python,gunicorn,uwsgi","A_Id":64144036,"CreationDate":"2020-01-23T17:30:00.000","Title":"Gunicorn sends info message Handling signal: winch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm building a dashboard in Data Studio and want to add a 'button' like feature that basically calls\/runs a python function that downloads some content locally(on the client machine). I have the python function almost ready. \nThe question I have is where do I host this function so that it is callable from Data Studio? \nIdeally, I wanted to create a Cloud function that would host the python function and get triggered when the button is clicked. This would work till this point but, will not download content locally. What options do I have to accomplish this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":526,"Q_Id":59884775,"Users Score":0,"Answer":"Currently it is not possible to trigger Cloud Function or something similar from the Data Studio Front end, especially when you are intending to download content locally.\nThe only thing I can think of is, you can create a custom connector which will call the Cloud Function (via URL trigger). Then use the connector to create a data source and attach that data source to a table or chart. That way, every time that page (with the table\/chart) is refreshed, the connector will call the Cloud Function and retrieve the associated data.","Q_Score":1,"Tags":"python,google-cloud-platform,google-cloud-functions,cloud,google-data-studio","A_Id":59889328,"CreationDate":"2020-01-23T18:12:00.000","Title":"How do I call a python function from a dashboard?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a dashboard in Data Studio and want to add a 'button' like feature that basically calls\/runs a python function that downloads some content locally(on the client machine). I have the python function almost ready. \nThe question I have is where do I host this function so that it is callable from Data Studio? \nIdeally, I wanted to create a Cloud function that would host the python function and get triggered when the button is clicked. This would work till this point but, will not download content locally. What options do I have to accomplish this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":526,"Q_Id":59884775,"Users Score":0,"Answer":"A function can be triggered by HTTP, so you can make it publicly available and just drop a link to it in a dashboard.\nJust add a gray square around this link and make it look like a button.  You may want to check the box to open the URL in a new tab, so your dashboard is not closed when the link is clicked.","Q_Score":1,"Tags":"python,google-cloud-platform,google-cloud-functions,cloud,google-data-studio","A_Id":67154973,"CreationDate":"2020-01-23T18:12:00.000","Title":"How do I call a python function from a dashboard?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I keep getting the following error when I try to execute the cell in a Jupyter notebook on VSCode\ncon = cx_Oracle.connect(\"\/@DB\")\nDatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: \"libclntsh.so: cannot open shared object file: No such file or directory\". See https:\/\/oracle.github.io\/odpi\/doc\/installation.html#linux for help\nBut the same works fine when I run it in Jupyter Lab.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":456,"Q_Id":59886075,"Users Score":0,"Answer":"Sometimes stuff just doesn't work in some IDEs, i am not sure what your question is, i suggest using anaconda (and maybe spyder specifically) it has worked for me with everything so far, but i don't know about cx_Oracle.","Q_Score":1,"Tags":"python-3.x,visual-studio-code,jupyter-notebook,vscode-settings","A_Id":59886122,"CreationDate":"2020-01-23T19:49:00.000","Title":"Unable to connect using cx_Oracle in a Jupyter notebook on VSCode","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to write a Python function which takes two sorted strings (the characters in each string are in increasing alphabetical order) containing only lowercase letters, and checks whether or not the strings are equal.\nThe function's time complexity needs to be O(log n), where n is the length of each string.\nI can't figure out how to check it without comparing each character in the first string with the parallel character of the second string.","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":558,"Q_Id":59887215,"Users Score":6,"Answer":"This is, in fact, possible in O(log n) time in the worst case, since the strings are formed from an alphabet of constant size.\nYou can do 26 binary searches on each string to find the left-most occurrence of each letter. If the strings are equal, then all 26 binary searches will give the same results; either that the letter exists in neither string, or that its left-most occurrence is the same in both strings.\nConversely, if all of the binary searches give the same result, then the strings must be equal, because (1) the alphabet is fixed, (2) the indices of the left-most occurrences determine the frequency of each letter in the string, and (3) the strings are sorted, so the letter frequencies uniquely determine the string.\nI'm assuming here that the strings have the same length. If they might not, then check that first and return False if the lengths are different. Getting the length of a string takes O(1) time.\n\nAs @wim notes in the comments, this solution cannot be generalised to lists of numbers; it specifically only works with strings. When you have an algorithmic problem involving strings, the alphabet size is usually a constant, and this fact can often be exploited to achieve a better time complexity than would otherwise be possible.","Q_Score":2,"Tags":"python,string,algorithm,time-complexity","A_Id":59888417,"CreationDate":"2020-01-23T21:19:00.000","Title":"Check if two sorted strings are equal in O(log n) time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just downloaded Sublime Text 3 for Mac and tried to run print(\"Hello world!\") as a test by clicking on \"build\".\nThe output says \n\n\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Resources\/Python.app\/Contents\/MacOS\/Python: can't find 'main' module in ''\n\nand some other stuff.\nI'm using Python 3 for several months now and I know the main differences between Python 2 and Python 3, but I have no idea what that output means.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2438,"Q_Id":59887286,"Users Score":1,"Answer":"Hi I also get the same problem in sublime text 3. And I am fixed.\n\nOpen command palette and install the install package.\nAfter completed install python3.\nAnd change like build system, syntax and others.\nFinally try to print('hello world')\nSave the file in .py extension is must otherwise you getting the same error","Q_Score":0,"Tags":"python-3.x,macos,python-2.7,error-handling,sublimetext3","A_Id":65827736,"CreationDate":"2020-01-23T21:24:00.000","Title":"Sublime Text 3 can't find '__main__' module in ''","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I previously created metrics for a TensorFlow Classifier referencing predictions['logits'] to calculate the metrics. I have changed the model from a Classifier to an Estimator in order to enable multi-objective learning (using MultiHead). However, this has caused Python to throw an error since now the elements of predictions are keyed by pairs of the head name and original key, e.g. ('label1','logits') for a head with name 'label1'.\nI'd like to allow for dynamic generation of metrics based on a configuration file in order to more easily train and test a variety of models with different label combinations. The problem now is that the metric_fn parameter to tf.estimator.add_metrics does not take any additional parameters to allow for dynamically determined or constructed metrics.\nHow can I generate an estimator with multiple heads and custom metrics for each head?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":373,"Q_Id":59888227,"Users Score":1,"Answer":"Build a class around the model creation that holds the model configuration and use a member function for the metric_fn parameter.\nclass ModelBuilder:\n  # constructor storing configuration options in self\n  def __init__(self, labels, other_config_args):\n    self.labels = labels\n    ...\n  # Function for building the estimator with multiple heads (multi-objective)\n  def build_estimator(self, func_args):\n    heads = []\n    for label in self.labels:\n      heads.append(tf.estimator.MultiClassHead(n_classes=self.nclasses[label], name=label))\n    head = tf.estimator.MultiHead(heads)\n    estimator = tf.estimator.DNNEstimator(head=heads,...) # or whatever type of estimator you want\n    estimator = tf.estimator.add_metrics(estimator, self.model_metrics)\n    return estimator\n  # Member function that adds metrics to the estimator based on the model configuration params\n  def model_metrics(self, labels, predictions, features):\n    metrics = {}\n    for label in self.labels: # generate a metric for each head name\n      metrics['metric_name'] = metric_func(features,labels,predictions[(label,'logits')])\n    return metrics","Q_Score":0,"Tags":"python,tensorflow,machine-learning,metrics","A_Id":59888228,"CreationDate":"2020-01-23T22:58:00.000","Title":"How should metrics be added to a multi-headed TensorFlow estimator?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to run workflows by not using celery or kubernetes. Doc specifies only two ways to run it in multi-cluster mode. Can't I just have another multiple EC2 instances to run my workers for computations. (Without using celery or kubernetes).","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":253,"Q_Id":59895455,"Users Score":1,"Answer":"The only way to accomplish what you want is to write your own Executor (EC2Executor?) that fulfils your requirements.","Q_Score":0,"Tags":"python,amazon-ec2,celery,airflow","A_Id":59899008,"CreationDate":"2020-01-24T11:22:00.000","Title":"Apache Airflow without celery or kubernetes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there any way to run workflows by not using celery or kubernetes. Doc specifies only two ways to run it in multi-cluster mode. Can't I just have another multiple EC2 instances to run my workers for computations. (Without using celery or kubernetes).","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":253,"Q_Id":59895455,"Users Score":1,"Answer":"Let's assume you have a number of EC2 instances. How would you manage them from Airflow? How would you distribute the load among those EC2 instances? Celery or Kubernetes take care exactly of these tasks.\nIf, for some reason, you cannot use Celery or Kubernetes, you can install Airflow on a single instance and scale up its resources as needed.","Q_Score":0,"Tags":"python,amazon-ec2,celery,airflow","A_Id":59896068,"CreationDate":"2020-01-24T11:22:00.000","Title":"Apache Airflow without celery or kubernetes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So for a while now I have been building my virtual assistant in python which has required the use of several external libraries. I have also been converting the scripts to an exe using pyinstaller. However only the other day, windows defender told me that there was something wrong which was only affecting the exe file I had created\nIt said Trojan: Win32\/Wacatac.C!ml\nI simply don't understand how this was only flagged up now and not before considering I have been working on this project for over a month now.\nHere is a list of the modules I have used:\nnewsapi, Wikipedia, threading, autocorrect, random, time,email, calendar, datetime, math, sys, webbrowser, pyttsx3, io, speech_recognition,imaplib, pickle, wmi, docx, comtypes, googletrans, qhue, pyowm, ast, pyaudio, pycaw, tkinter, smtplib, email, bs4, requests","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3325,"Q_Id":59900656,"Users Score":4,"Answer":"It's a false positive. There's nothing malicious about your third-party modules, the issue has to do with PyInstaller.\nPyInstaller comes with pre-compiled bootloader binaries. Since many actual amateur viruses are written in Python, and then converted to executables using PyInstaller, most anti-virus software will flag those pre-compiled bootloader binaries as being malicious. The only real solution is to compile your own bootloader.","Q_Score":1,"Tags":"python,python-3.x,python-3.6,libraries","A_Id":59900803,"CreationDate":"2020-01-24T16:49:00.000","Title":"Concerned about malicious libraries in my project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using GNU Radio's logging functionality in some custom python blocks I've built for a flowgraph.  Among other things, the logging methods are useful for recording the (rough) start time of the flowgraph to a log file.  I would also like to record the end time of the flowgraph (i.e., the rough time I kill the flowgraph in companion) in a log message written to the log file.  To be clear, I'm looking for a solution that will work when I run the flowgraph from GNU Radio Companion.  Is there an easy way to do this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":212,"Q_Id":59901161,"Users Score":1,"Answer":"In GNU Radio blocks, you can overload the stop method to do exactly that, execute code at flow graph stop time.\nGenerally, the \"stop\" button in GRC is a rather hardcore thing; if you instead have a finishing condition in your flowgraph itself (e.g. closing of the window if you're using Qt GUI, or finishing of any block), this could be approached from that logical \"I should be done\" point of view, rather than \"someone else tries to kill me\".","Q_Score":1,"Tags":"python,logging,gnuradio,gnuradio-companion","A_Id":59919568,"CreationDate":"2020-01-24T17:29:00.000","Title":"GNU Radio Companion -- logging a message just prior to flowgraph shutdown","Data Science and Machine Learning":0,"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":"The error code D401 for pydocstyle reads: First line should be in imperative mood.\nI often run into cases where I write a docstring, have this error thrown by my linter, and rewrite it -- but the two docstrings are semantically identical. Why is it important to have imperative mood for docstrings?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":10897,"Q_Id":59902102,"Users Score":2,"Answer":"For consistency. It might stem from the fact that the commit messages git automatically creates, like for merge commits, also uses the imperative mood.","Q_Score":15,"Tags":"python,static-analysis,pylint,docstring","A_Id":59902237,"CreationDate":"2020-01-24T18:48:00.000","Title":"Why is imperative mood important for docstrings?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to make a python script that gathers large amounts of information about vcenters.  I basically call every single diagnostic possible, one after the other, gathering this info into a database daily for machine learning.  This logs into the vcenter via python's pyvmomi and then calls for information about all resource centers, calls for information about all clusters, calls for the hosts on each cluster and information about them, and calls for information about every vm on every host. Where can I see the strain on vcenter?  Where is it hosted?  I guess the issue is I've been assigned a task, and I can gather documentation and get it done, but I dont want to cause strain on very important tools for our business.  How can I be sure this does not cause issues with bandwidth or slow important processes like CPU sharing, memory allocation, and host switching.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":59903835,"Users Score":0,"Answer":"You can see the overall stats of the vCenter in the VAMI (vCenter Appliance Management Interface), where you can monitor the CPU and RAM utilization. If you want deeper, more precise, info, it would require logging into the vCenter locally, which is generally not recommended. \nvCenter will, in general, handle your queries sequentially. They will queue up if the vCenter can't handle them immediately. The issue is that it will also queue up the other tasks being processed and there's no real way to give tasks a priority. \nIf you have vROps running in your environment, that might be a better place to pull all of those metrics... assuming they're available there.","Q_Score":0,"Tags":"python,vmware,stress-testing,vsphere,pyvmomi","A_Id":60078159,"CreationDate":"2020-01-24T21:21:00.000","Title":"How can I tell what strain is caused by pyvmomi on vmware?","Data Science and Machine Learning":0,"Database and SQL":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 found that range class defines a method named count that returns the number of occurrences of value.\nI think this should be replaced by a method exists returning True or False in case the value is or is not in the objet.\nIn fact, the number returned by count method is either O or 1, it cannot be greater in my opinion.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":47,"Q_Id":59905076,"Users Score":1,"Answer":"exists is already implemented as the in operator; you're welcome to use that for your desired application.\ncount is implemented because range is a Sequence, as are list, tuple, and str.  Thus, count must exist and be consistent with its functionality in the other Sequence types.","Q_Score":0,"Tags":"python,count,range","A_Id":59905128,"CreationDate":"2020-01-24T23:50:00.000","Title":"What is the purpose of count method of range class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A virtual environment is required when creating an application and now I am using 'virtualenv' for creating a virtual environment while developing my Django application. I heard of Docker about its virtual environment. Am I able to use Docker as an alternative to virtualenv?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1262,"Q_Id":59907326,"Users Score":1,"Answer":"Yes docker can be used as an alternative.\nvirtualenv just sets a fresh python installation in path which can be used to install dependencies particular to your project without polluting global python installation and thus managing versioning as well.\nDocker is a step further and gives a complete OS - linux image and OS level isolation. Not just one can have a isolated python installation but can also have other os specific dependencies installed like ffmpeg, lapack, arpack etc. A new developer can spin up a container from docker image having all dependencies (python and OS) installed.","Q_Score":2,"Tags":"python,django,docker,containers,virtualenv","A_Id":59907376,"CreationDate":"2020-01-25T07:47:00.000","Title":"Is Docker an alternative for 'virtualenv' while develping Django project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"A virtual environment is required when creating an application and now I am using 'virtualenv' for creating a virtual environment while developing my Django application. I heard of Docker about its virtual environment. Am I able to use Docker as an alternative to virtualenv?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1262,"Q_Id":59907326,"Users Score":1,"Answer":"The usage of virtualenv or docker depends on your requirement or use case.\nDocker container encapsulates an entire OS and provides isolation of OS whereas a virtualenv only encapsulates Python dependencies which enables switching between Python versions and dependencies, but you are dependent with your host OS. \nVirtualenv can be used in case if you have two different projects on your machine that require two different versions of the same package with python. Typically, the virtualenv provides abstraction from OS's use of python. \nDocker enables portability from one machine to another whereas with virtualenv you will have to do the installation in another place.  Docker isolates all of the additional system dependencies too and provides a completely isolated environment.  It is containerization platform which is used to package your application and all its dependencies together in the form of containers so to make sure that your application works seamlessly in any environment which can be development or test or production. It helps to ensure that the Dev and Production environment are completely same.","Q_Score":2,"Tags":"python,django,docker,containers,virtualenv","A_Id":59907834,"CreationDate":"2020-01-25T07:47:00.000","Title":"Is Docker an alternative for 'virtualenv' while develping Django project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a device with USB interface which I can connect to both my Ubuntu 18.04 machine and my Windows 10 machine. On Windows 10 I have to install the CP210x driver and manually attach it to the device (otherwise Windows tries to find the device manufacturer's driver - it's a CP210x serial chip), and in Linux write the vendorID and productID to the cp210x driver to allow it to attach to ttyUSB0. This works fine.  \nThe Windows driver is from SiliconLabs - the manufacturer of the UART-USB chip in the device.\nSo on Windows it is attached to COM5 and Linux to ttyUSB0 (Ubuntu, Raspbian)\nUsing Wireshark I can snoop the usb bus successfully on both operating systems.\nThe USB device sends data regularly over the USB bus and on Windows using Wireshark I can see this communication as \"URB_INTERRUPT in\" messages with the final few bytes actually containing the data I require.\nOn Linux it seems that the device connects but using Wireshark this time I can only see URB_BULK packets. Examining the endpoints using pyusb I see that there is no URB_Interrupt endpoint only the URB_Bulk.\nUsing the pyusb libraries on Linux it appears that the only endpoints available are URB_BULK.\nQuestion mainly is how do I tell Linux to get the device to send via the Interrupt transfer mechanism as Windows seems to do.  I don't see a method in pyusb's set_configuration to do this (as no Interrupt transfer endpoints appear) and haven't found anything in the manufacturer's specification.\nFailing that, of course, I could snoop the configuration messages on Windows, but there has to be something I'm missing here?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":288,"Q_Id":59907960,"Users Score":0,"Answer":"Disregard this, the answer was simple in the end: Windows was reassigning the device address on the bus to a different device.","Q_Score":1,"Tags":"python,linux,windows,usb,pyusb","A_Id":60025068,"CreationDate":"2020-01-25T09:25:00.000","Title":"USB Device\/PyUSB on Windows and LInux behaving differently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am having trouble importing and installing tensorflow. I can't install it via that Thonny manage package option nor via the command window for windows operators. I get the same error for both ways:\nERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none) Error: No matching distribution found for tensorflow\nI tried to convert back to python 3.6 but the issue still arises. This is annoying me because I cannot implement Machine Learning, which is something I am strongly passionate on. \nAny reasons or solutions would be appreciated","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1448,"Q_Id":59908131,"Users Score":0,"Answer":"Tensorflow can be installed in Thonny by\nTools -> Open System Shell\npip install --upgrade tensorflow","Q_Score":0,"Tags":"python,tensorflow,machine-learning,data-science,thonny","A_Id":61153120,"CreationDate":"2020-01-25T09:49:00.000","Title":"Thonny : installing tensorflow and importing it","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having trouble importing and installing tensorflow. I can't install it via that Thonny manage package option nor via the command window for windows operators. I get the same error for both ways:\nERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none) Error: No matching distribution found for tensorflow\nI tried to convert back to python 3.6 but the issue still arises. This is annoying me because I cannot implement Machine Learning, which is something I am strongly passionate on. \nAny reasons or solutions would be appreciated","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1448,"Q_Id":59908131,"Users Score":0,"Answer":"I use Thonny and the way to install it is\ntool>>Open system shell\nThen type in \"pip3.6 install --upgrade TensorFlow\"","Q_Score":0,"Tags":"python,tensorflow,machine-learning,data-science,thonny","A_Id":61500169,"CreationDate":"2020-01-25T09:49:00.000","Title":"Thonny : installing tensorflow and importing it","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having trouble importing and installing tensorflow. I can't install it via that Thonny manage package option nor via the command window for windows operators. I get the same error for both ways:\nERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none) Error: No matching distribution found for tensorflow\nI tried to convert back to python 3.6 but the issue still arises. This is annoying me because I cannot implement Machine Learning, which is something I am strongly passionate on. \nAny reasons or solutions would be appreciated","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1448,"Q_Id":59908131,"Users Score":0,"Answer":"Here is how I got Tensorflow version 2.5.0 to install and import using python version 3.6.8, with Thonny version 3.3.7, on a windows 10 laptop;-\nWhen I installed Thonny, the default python interpreter was set to python 3.7.9. I need to change that, as follows;-\nUsing Thonnys menus and options , use tools \/ options \/ interpreter . Use the pull down option selections to find the python 3.6.8 that must have been previously installed on your machine. On my machine it is located at C:\\Users\\XXXX\\ApplicationData\\Local\\Programs\\Python\\Python36\\python.exe\nHit Ok and Thonny will show that it is now using python 3.6.8 in the lower shell !\nThen install tensorflow using the Thonny menu tools \/ manage packages.\nI installed tensorflow version 2.5.0 without any problems !\nThen, in the interactive shell, I tested it ;-\nPython 3.6.8 (C:\\Users\\con_o\\AppData\\Local\\Programs\\Python\\Python36\\python.exe)\n\n\n\nimport tensorflow\n2021-05-20 09:06:01.231885: W tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found\n2021-05-20 09:06:01.258437: I tensorflow\/stream_executor\/cuda\/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.\n\n\n\n\n\n\nprint(tensorflow.version)\n<module 'tensorflow._api.v2.version' from 'C:\\Users\\XXX\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\_api\\v2\\version\\init.py'>\n\n\n\n\n\n\nprint(tensorflow.version)\n\n\n\n2.5.0\nNote;- The last command print(tensorflow.version) does NOT work without the previous command print(tensorflow.version) being run first !!\nNote;- I could only install version 2.5.o of tensorflow. Thonny could not install any earlier version of Tensorflow!\nI hope this helps the many folk struggling with the very difficult Tensorflow installations.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,data-science,thonny","A_Id":67617331,"CreationDate":"2020-01-25T09:49:00.000","Title":"Thonny : installing tensorflow and importing it","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was working on my game using pygame and I tried to implement a high score mechanism. But when I run my program it just crashed and it seems it deleted itself forever. Now when I open my code there is just 0 writen in. Is there a way to get my code back and why did it delete itself? (I tried to implement high score by making a new .txt file and by storing scores into it. I wrote it all in my same game script.)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":59911489,"Users Score":1,"Answer":"What you most likely did was open your file and override it with 0. Whenever you open files you have to consider the mode you open it in (and which file you open.). For example, opening a file with 'w' will remove all previous content in the file and fill it with whatever you write to it.\nIf this is what happened, then no, there's no way to get back your code (unless you've saved a copy somewhere else or are using a Version Control System like git or svn).\nIf you're using the editor Pycharm, then you can right-click your project and press Local history and then Show History to open saved versions. Then click revert to go back to the version where you had your code.","Q_Score":0,"Tags":"python,pygame","A_Id":59912637,"CreationDate":"2020-01-25T17:05:00.000","Title":"Deleted program by itself","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a software in python for windows which should be connected to a database. Using py2exe i want to make an executable file so that I don't have to install python in the machines the software is running. The problem is that I want the user to define where the database is located the very first time the software starts, but I don't know how to store this information so that the user doesn't have to tell everytime where is the database. I have no idea how to deal with it. (the code cannot be changed because it's just a .exe file). How would you do that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":272,"Q_Id":59913646,"Users Score":0,"Answer":"I can think of some solutions:\n\nYou can assume the DB is in a fixed location - bad idea, might move or change name and then your program stop working\nYou can assume the DB is in the same folder as the .exe file and guide the user to run it in the same folder - better but still not perfect\nAsk the user for the DB location and save the path in a configuration file. If the file doesn't exist or path doesn't lead to the file, the user should tell the program where is the DB, otherwise, read it from the config file - I think this is the best option.","Q_Score":0,"Tags":"python,windows,py2exe","A_Id":59913693,"CreationDate":"2020-01-25T21:41:00.000","Title":"How can I define an absolute path saved in one exe file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been going around but was not able to find a definitive answer...\nSo here's my question.. \nI come from javascript background. I'm trying to pickup python now.\nIn javascript, the basic practice would be to npm install (or use yarn)\nThis would install some required module in a specific project.\nNow, for python, I've figured out that pip install is the module manager. \nI can't seem to figure out how to install this specific to a project (like how javascript does it)\nInstead, it's all global.. I've found --user flag, but that's not really I'm looking for.\nI've come to conclusion that this is just a complete different schema and I shouldn't try to approach as I have when using javascript.\nHowever, I can't really find a good document why this method was favored.\nIt may be just my problem but I just can't not think about how I'm consistently bloating my pip global folder with modules that I'm only ever gonna use once for some single project.\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":91,"Q_Id":59914217,"Users Score":0,"Answer":"A.) Anaconda (the simplest) Just download \u201cAnaconda\u201d that contains a lots of python modules pre installed just use them and it also has code editors. You can creat multiple module collections with the GUI.\nB.) Venv = virtual environments (if you need something light and specific that contains specific packages for every project\nmacOS terminal commands:\n\nInstall venv\npip install virtualenv\nSetup Venve (INSIDE BASE Project folder)\npython3 -m venv thenameofyourvirtualenvironment\nStart Venve\nsource thenameofyourvirtualenvironment\/bin\/activate\nStop Venve\ndeactivate\nwhile it is activated you can install specific packages ex.: \npip -q install bcrypt\n\nC.) Use \u201cDocker\u201d it is great if you want to go in depth and have a solide experience, but it can get complicated.","Q_Score":2,"Tags":"python,pip","A_Id":59914286,"CreationDate":"2020-01-25T23:13:00.000","Title":"How to install python module local to a single project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to build a web app (SPA) that send the schema (not necessarily the raw db schema, but a representation of the data potentially in a JSON format) to the view, so in the view we can:\n\nGenerate grids based on that schema instead of wiring columns\nHandle additional information from these fields, such as if it is editable or not, and the like.\n\nThis web app will allow users to see tabular information in a grid, and potentially do CRUD operations.\nI see a lot of benefits on using the schema (We can implement validators based on the schema, forms generation should be very simple, and best, the impact of adding a simple field to the web app should be easily handled)\nMy question is: Is it a good strategy? Could you help me identify some drawbacks with this approach? (The stack I am using for this is not very important, but just for the sake of clarity, I am using Bottle (python) in the backend, and React in frontend)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":30,"Q_Id":59914460,"Users Score":1,"Answer":"One drawback I see is the time consumed to maintain this addition that you mention: schema generation, sending, interpreting in the view. But of course this is for you to decide, if this overhead is compensated by the advantages you mentioned. If it is, then go for it. \nOne other thing I would mention is: you want to do validation based on this schema. How many of the validations in your application can be done this way? Are there many cases in which validation will not fit in this pattern? Same question for grid generation, form generation, etc. If there are a lot, then maybe it is not worth it. I have more then once found a automatic solution like this that got me excited only to see later that it does exceptions for this pattern are many and overall I did not gain to much :). \nOverall, you decide. One last thing: try to think long term. 90% of the lifetime of an application is spent in maintenance. Try to understand what  happens after you release the application and bugs\/small features requests are starting to come up.","Q_Score":0,"Tags":"python,design-patterns,model,schema","A_Id":59927836,"CreationDate":"2020-01-26T00:02:00.000","Title":"Is it a good practice to send schema in web application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm aware of Decimal, however I am working with a lot of code written by someone else, and I don't want to go through a large amount of code to change every initialization of a floating point number to Decimal.  It would be more convenient if there was some kind of package where I could put SetPrecision(128) or such at the top of my scripts and be off to the races.  I suspect no such thing exists but I figured I would ask just in case I'm wrong.\nTo head off XY Problem comments, I'm solving differential equations which are supposed to be positive invariant, and one quantity which has an equilibrium on the order of 1e-12 goes negative regardless of the error tolerance I specify (using scipy's interface to LSODA).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":384,"Q_Id":59914993,"Users Score":0,"Answer":"LSODA exposed through scipy.integrate is double precision only.\nYou might want to look into some rescaling of variables, so that that thing which is 1e-12 becomes closer to unity.\nEDIT. In the comments, you indicated\n\nAs I've stated three times, I am open to rewriting to avoid LSODA\n\nThen what you can try doing is to look over the code of solve_ivp, which is pure python. Feed it with decimals or mpmath high-precision floats. Observe where it fails, look for where it assumes double precision. Rewrite, remove this assumption. Rinse and repeat. Whether it'll work in the end, I don't know. Whether it's worth it, I suspect not, but YMMV.","Q_Score":0,"Tags":"python,scipy,precision","A_Id":59921768,"CreationDate":"2020-01-26T02:03:00.000","Title":"Is there a way of setting a default precision that differs from double in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install pyldavis in a conda env using the command conda install -c conda-forge pyldavis but I get the following errors:\nERROR conda.core.link:_execute(700): An error occurred while installing package 'conda-forge::openssl-1.1.1d-hfa6e2cd_0'\n[Errno 13] Permission denied: 'C:\\<Path>\\Library\\bin\\libssl-1_1-x64.dll'","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1655,"Q_Id":59915357,"Users Score":0,"Answer":"Run as Administrator doesn't work.  I was able to fix it by grabbing the same file from another environment and replacing it (kept a backup though).  Hopefully, there are no unintended consequences.","Q_Score":2,"Tags":"python,installation,conda,libssl,pyldavis","A_Id":67188089,"CreationDate":"2020-01-26T03:36:00.000","Title":"Permession denied error while installing pyldavis in conda env [Errorno 13]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to install pyldavis in a conda env using the command conda install -c conda-forge pyldavis but I get the following errors:\nERROR conda.core.link:_execute(700): An error occurred while installing package 'conda-forge::openssl-1.1.1d-hfa6e2cd_0'\n[Errno 13] Permission denied: 'C:\\<Path>\\Library\\bin\\libssl-1_1-x64.dll'","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1655,"Q_Id":59915357,"Users Score":0,"Answer":"I had the same issue installing python-dotenv. Running the command prompt (or in my case, simply running VSCode through which I normally access the terminal) as administrator fixed the issue.","Q_Score":2,"Tags":"python,installation,conda,libssl,pyldavis","A_Id":69333526,"CreationDate":"2020-01-26T03:36:00.000","Title":"Permession denied error while installing pyldavis in conda env [Errorno 13]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to install pyldavis in a conda env using the command conda install -c conda-forge pyldavis but I get the following errors:\nERROR conda.core.link:_execute(700): An error occurred while installing package 'conda-forge::openssl-1.1.1d-hfa6e2cd_0'\n[Errno 13] Permission denied: 'C:\\<Path>\\Library\\bin\\libssl-1_1-x64.dll'","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1655,"Q_Id":59915357,"Users Score":0,"Answer":"I had a similar issue when installing the sentence-transformers package with a particular file causing the issue: libssl-1_1-x64.dll\nSimply tracking down the file and deleting it fixed the problem. When I tried again the install worked with no hitches. I suspect the problem came up when the version needed to be downgraded or upgraded from whatever I have in my base or what some other package had installed. It also makes sense that a security related .dll would cause some extra heartburn.\nIn my case it was located at: D:\\installed_software\\anaconda3\\envs\\nlp-intents\\Library\\bin where \"nlp-intents\" is the environment name.","Q_Score":2,"Tags":"python,installation,conda,libssl,pyldavis","A_Id":69692613,"CreationDate":"2020-01-26T03:36:00.000","Title":"Permession denied error while installing pyldavis in conda env [Errorno 13]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to make a function that takes a picture of a table and converts that into a csv. The picture of the table could contain commas if it was say a bank statement i.e. $3,000. So what separator should I use when creating arbitrary csv document since the standard comma seperator would be confused with the commas in the contents of the csv when excel tries to read it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17,"Q_Id":59915542,"Users Score":0,"Answer":"As Tim already stated, a correct CSV file should quote any field that contains characters which are used as field (mostly comma or semikolon) or line separaters (mostly \\n or \\r\\n) in the CSV file.\nIf you don't want to check the contens you can just quote all fields. Any good CSV import engine should be alright with that.","Q_Score":0,"Tags":"excel,python-3.x,csv,ocr","A_Id":60014615,"CreationDate":"2020-01-26T04:25:00.000","Title":"What seperator to use when creating csv of unknown contents","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi so basically my question is I have a matrix which I've SVD decomposed and have it in the variables u, s, and v. I've made some alterations to the s matrix to make it diagonal, as well as altered some of the numbers. Now I'm basically trying to reconstruct it into a regular matrix from the 3 matrices back into the original matrix. Does anyone know of any functions that do this? I can't seem to find any examples of this within numpy.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3020,"Q_Id":59916150,"Users Score":1,"Answer":"I figured it out, just using the np.matmul() function and then just multiplying the 3 matrices of u s and v together was enough to get them back into an original matrix.","Q_Score":0,"Tags":"python-3.x,numpy,matrix,linear-algebra,svd","A_Id":59939869,"CreationDate":"2020-01-26T06:43:00.000","Title":"Reconstructing a matrix from an SVD in python 3","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i try do cluster words into the same category. Therfore i wanted to use Spacy Word2Vec.\nIts already working with easy words like banana apple and car. It shows the nearly same word.\nIf the words gets more specific like car, battery, accumulator, accu and so on, if the were more technical, Spacy sends Zero vectos. So these words were not included into the bibliothek. \nDo you have some input for me?\nFurthermore, i have to do it in german. \nThank you very much\nJokulema","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":59916393,"Users Score":0,"Answer":"If you need word-vectors for words not in the model you're using, you'll have to either:\n\nfind & use a different model that contains those words\ntrain your own model from your own training data, that contains many examples of those words' usages in context","Q_Score":1,"Tags":"python,spacy,word2vec","A_Id":59926374,"CreationDate":"2020-01-26T07:28:00.000","Title":"Word To Vec with Spacy, words into same categorie","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have set up the entire environment to run mininet using an Ubuntu image on VirtualBox. I also found a JSON graph topology which I run with Python to simulate it in mininet (I use PuTTy for remote access from Windows..)\nI read before that using the command sudo mn --controller=none \ncreates a non-SDN simulation. This is not bad for a start, but is there another way of doing that? And if so, how is it possible to remove a specific node and replace it with an SDN switch to test the network performance?\nMany thanks in advance.\nSet up used:\nWindows 10, Oracle VM Virtual Machine, Ubuntu, Mininet, NetworkX, Python, WinTCP..PuTTy..","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":59917211,"Users Score":0,"Answer":"Yes, it is possible. You start a normal SDN network with the desired topology, and you:\n\nset the forwarding-rules on the 'non' SDN-nodes to live forever (so the controller is never asked for new\/expired rules), and\nleave the rest of the node under the control of the controller.","Q_Score":0,"Tags":"python,networking,hybrid,sdn,mininet","A_Id":61058427,"CreationDate":"2020-01-26T09:53:00.000","Title":"Is there a way to create a traditional network with mininet then replace some of its nodes with SDN?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So yesterday evening I was lucky enough to get an invitation to the Google foobar challenge. Ironically, I wasn't looking up anything particularly advanced (just the basics of list comprehensions). Anyways, so I'm on level 3 now, and I'm running into an issue where my personal computer's compiler is providing an output that matches a test case, but Google's system fails it. Unfortunately, Google's system does not print out what the actual output is, so troubleshooting is a bit of a challenge.\nCurrently, I am running on python 3.6 in Spyder. I have no clue what version of python Google is using or whether there are any differences in how they are running theirs in comparison to mine. \nThe question is looking for something called a \"lucky triple\" in a list of positive integers. A lucky triple is one such that, for x, y, and z, y can divide into z, and x can divide into y. \nMy issue is basically this: One of the test cases is [1, 2, 3, 4, 5, 6], which is supposed to output the integer 3 (the three triplets are [1, 2, 4], [1, 2, 6], and [1, 3, 6]). When I run my program, it outputs 3 for this list, which is what the test case is supposed to equal, but I fail this test when I run it in Google's system.\nA couple things I've noticed\/tried:\n\nI fail 4 of 5 tests in Google's system. The one I pass is an input of [1, 1, 1], which outputs 1. Three of those five tests are hidden, so I cannot practice on them. The other failure is the [1, 2, 3, 4, 5, 6], which should output a 3.\nIf I force the code to return 3 in all cases, then it passes that one test (and obviously fails the others). To me this means that my code is not returning 3 in Google's system, even though it is returning 3 in mine. It also means that the test case is correctly set to 3.\nThis is not the first time something like this has happened. On the very first level, I used __ne__, which worked on my system, but not on Googles. I ended up changing things around because I suspected something like that was the case, and when I switched the __ne__ with a lambda function, all my test cases passed.\nI saw someone else had a similar issue with the foobar challenge, but their problem was they didn't make their variable a static variable so it was changing every time it was run. This should be a problem here, because I reset the count_of_numbers variable to 0 at every run.\n\nI would rather not spoil the solution if I can help it, so instead of providing my whole code, I'm going to provide some of the functions I used. If this isn't enough to go on, please let me know, and I can provide the whole code. Remember, I'm not asking whether my program works - if my program doesn't work in all cases, that's a separate issue entirely. But I know that it works in the first two cases (at least on my machine). I'm asking why my program outputs 3 for my system but not 3 for Google's.\n\nI use %, which I believe works in both systems because I can force \"3\" using if 2%1 == 0: return 3.\nI create my own function, is_lucky_triple, that returns a Boolean. \nI use the len() function. \nI use reversed(range()). \nI use pop().\n\nOverall, the program is really simple: only 16 lines of code and just a few functions. The basic logic is run through every possible combination of the numbers (maintaining the order of the original list), and increase a counter every time you find a lucky triple.\nI really appreciate any help you can give. Any tips for troubleshooting when you can't see the output or error messages would be appreciated as well. Thanks!\nEdit: thanks to Tane's answer below, I was able to find out the version is 2.7.13, which uses the unforgivable 3\/2 = 1 kind of division. Based on this, I was able to fix the issue, so now I'm passing the first two tests. Sadly, I am still failing the last three . . . But I appreciate the help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4716,"Q_Id":59920345,"Users Score":4,"Answer":"When I did foobar a while back there was a constraints.txt file you could access by typing cat constraints.txt at the prompt, that contained information about the Java and Python versions used (at the time, 7 and 2.7.6) as well as the supported and restricted libraries -- I would suggest checking that so that you can run your code using the same version of Python. Try typing ls at the prompt to see what files are available to you.","Q_Score":0,"Tags":"python,testing","A_Id":59921148,"CreationDate":"2020-01-26T16:29:00.000","Title":"Google Foobar Question - Python Test Case Failures","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am tring to excetute a GitHub pyton script on my Android smartphon using Termux.\nI knew that this script doesn't run on Python 3.8.1 (which is the default version installed when typed \"pkg install python\" but it runs very well on previous versions of linux. I have to mention that I know this since I was running this script on my laptop and I have different version of python installed.\nHowever, I've looked for a couple of days in a row on google and I didn't find a way to install an older python version on my Termux. Could you please help me out on this?\nThanks in advance,\nLorenzo","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6696,"Q_Id":59921715,"Users Score":0,"Answer":"pkg i python==[version]\nyou specify the version you want just after the package name. That is\npkg i python==3.6 -y\nconsidering 3.6 is the version then the -y simply means yes","Q_Score":0,"Tags":"python,termux","A_Id":64649042,"CreationDate":"2020-01-26T19:04:00.000","Title":"Install python3.6 on Termux android terminal emulator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am tring to excetute a GitHub pyton script on my Android smartphon using Termux.\nI knew that this script doesn't run on Python 3.8.1 (which is the default version installed when typed \"pkg install python\" but it runs very well on previous versions of linux. I have to mention that I know this since I was running this script on my laptop and I have different version of python installed.\nHowever, I've looked for a couple of days in a row on google and I didn't find a way to install an older python version on my Termux. Could you please help me out on this?\nThanks in advance,\nLorenzo","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":6696,"Q_Id":59921715,"Users Score":-1,"Answer":"its actually pkg i python=3.6 and termux don't have that python version","Q_Score":0,"Tags":"python,termux","A_Id":67241693,"CreationDate":"2020-01-26T19:04:00.000","Title":"Install python3.6 on Termux android terminal emulator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to write text that was scraped from a German website into a CSV file. I tried using UTF-8 encoding as such:\nwith open('\/Users\/filepath\/result.csv', 'a', encoding='utf8') as f:\nf.write(text)\nBut this is what appeared in the CSV file instead of with an \u00fc:\nProjekt f\u00c3\u00bcr Alleinerziehende mit mehreren (behinderten) Kindern","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":59921723,"Users Score":1,"Answer":"Try using ISO-8859-15 encoding. Also make sure that when you open the file in an editor, it's encoding is set to same encoding.","Q_Score":0,"Tags":"python,selenium,file,web-scraping,utf","A_Id":59921966,"CreationDate":"2020-01-26T19:05:00.000","Title":"How do you write German text into a CSV file?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to classify text data into a few categories. But in the data set, there can be data that does not belong to any of the defined categories. \nAnd after deploying the final product, the product should be deal with text data that does not belong to the predefined category.\nTo implement that solution I am currently using the SVM text classifier. And I am planning to define another category as \n\n\"non\"\n\nto deal with the data that does not belong to predefined categories.\nIs this a correct approach?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":59922367,"Users Score":0,"Answer":"Yes, that would work. It is essentially an additional class called \"non\", for which the classifier will learn to classify all the documents into, that are labeled as that class.\nSo when you use your final product, it will try to classify the new text data into the classes, including \"non\".","Q_Score":1,"Tags":"python,svm,text-classification","A_Id":60563844,"CreationDate":"2020-01-26T20:20:00.000","Title":"Text classification into predefined categories","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been given a data set that has two rows with dates in the format xsd:duration which python accounts for as a string.\nThe format looks like PT3H20M (for 3h20min), or PT3H (for 3h) or PT30M (for 30m). How do you convert this format to date so that I can add the times and perform comparisons on them ?\nThanks for any help\nEDIT : I'm specifically looking for any built-in package\/function that I don't know about that would do that relatively easily.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":59922813,"Users Score":0,"Answer":"I would suggest that:\n\nYou extract the numbers of hours and minutes using regular\nexpression in python.\nUse a datetime function to convert to UNIX time or another format.\nMake a comparison or sum.","Q_Score":0,"Tags":"python,pandas,date,format","A_Id":59922943,"CreationDate":"2020-01-26T21:15:00.000","Title":"How do I convert a xsd:duration in date format in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python using \/\/ for division forces the result to be an integer. Is there an equivalent for multiplication? \nFor example, assume I have an integer W which I scale by a float f. It could be nice to have an operator such as .*, so that:\nint(W*f)==W.*f \nWould be True.","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":3683,"Q_Id":59927319,"Users Score":5,"Answer":"No, and there is unlikely to be one added, for two reasons.\n\nThe current options are short and built-in\nThere is no ambiguity to be resolved\n\nWhen you take 12\/5 you can reasonably want a integer, quotient, or real, all of which are well defined, take different values in python (without infinite floating precision) and behave differently.\nWhen you multiply 12*5, you could also want those three, but the value will be identical.\nFor something like pi * 100000, you would need to know the type to end up with as well as the resolution technique for e.g. float to integer (floor, ceiling, round closest, round .5 up, round .5 down, bankers rounding).  Without strong types this becomes a mess to hand down from above, and easier to delegate to the user and their own needs or preferences.","Q_Score":6,"Tags":"python,integer-division,syntactic-sugar","A_Id":59927618,"CreationDate":"2020-01-27T08:22:00.000","Title":"Python multiplication equivalent to integer division","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"All the FreeSwitch documentations are given assuming you have installed Debian. So for CentOs or any RHEL distribution users are having a problem.\nWhen I tried to follow the  mod_python documentation given by FreeSwitch, I am getting errors.\nNow, How can I install mod_python or any other modules?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":361,"Q_Id":59928304,"Users Score":0,"Answer":"In CentOs for installing any software, search the yum repo.\nLike here,\nI ran\nyum search freeswitch\nI got all the FreeSwitch modules. Now find your required modules and install.\nLike here for mod_python module, I typed\nyum install freeswitch-python.x86_64\n\nNow, type  cd \/etc\/freeswitch\/autoload_configs\/ and edit modules.conf.xml\nAdd <load module=\"mod_python\"\/> and save the file and exit.\nNow, use fs_cli command and type reloadxml.\nAfter this restart your linux system and again type fs_cli and type module_exists mod_python.\nThis should show true. If so, that means mod_python installation is successful.","Q_Score":0,"Tags":"centos7,python-module,freeswitch","A_Id":59928305,"CreationDate":"2020-01-27T09:33:00.000","Title":"FreeSwitch mod_python(or any other modules) installation on CentOs 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"For reference, I'm trying to re-learn programming and python basics after years away.\nI recently downloaded Anaconda as part of an online Python Course. However, every time I open Spyder or the Navigator they instantly create folders for what I assume are all the relevant libraries in  C:Users\/Myself. These include .conda, .anaconda, .ipython, .matplotlib, .config and .spyder-py3.\nMy goal is to figure out how change where these files are placed so I can clean things up and have more control. However, I am not entirely sure why this occurs. My assumption is it's due to that being the default location for the Working Directory, thought the solutions I've seen to that are currently above me. I'm hoping this is a separate issue with a simpler solution, and any light that can be shed on this would be appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":405,"Q_Id":59929158,"Users Score":0,"Answer":"Go to:\n~\\anaconda3\\Lib\\site-packages\\jupyter_core\\paths.py\nin def get_home_dir():\nYou can specify your preferred path directly.\nOther anaconda applications can be mortified by this way but you have to find out in which scripts you can change the homedir, and sometimes it has different names.","Q_Score":0,"Tags":"python,directory,anaconda,spyder,libraries","A_Id":62635063,"CreationDate":"2020-01-27T10:22:00.000","Title":"How to stop Anaconda Navigator and Spyder from dropping libraries into User folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For reference, I'm trying to re-learn programming and python basics after years away.\nI recently downloaded Anaconda as part of an online Python Course. However, every time I open Spyder or the Navigator they instantly create folders for what I assume are all the relevant libraries in  C:Users\/Myself. These include .conda, .anaconda, .ipython, .matplotlib, .config and .spyder-py3.\nMy goal is to figure out how change where these files are placed so I can clean things up and have more control. However, I am not entirely sure why this occurs. My assumption is it's due to that being the default location for the Working Directory, thought the solutions I've seen to that are currently above me. I'm hoping this is a separate issue with a simpler solution, and any light that can be shed on this would be appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":405,"Q_Id":59929158,"Users Score":0,"Answer":"They are automatically created to store configuration changes for those related tools.  They are created in %USERPROFILE% under Windows.  \nThe following is NOT recommended:\nYou can change this either via the setx command or by opening the Start Menu search for variables.\n- This opens the System Properties menu on the Advanced tab\n- Click on Environmental Variables\n- Under the user section, add a new variable called USERPROFILE and set the value to a location of your choice.","Q_Score":0,"Tags":"python,directory,anaconda,spyder,libraries","A_Id":59929423,"CreationDate":"2020-01-27T10:22:00.000","Title":"How to stop Anaconda Navigator and Spyder from dropping libraries into User folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to insert many image in one field of same table. For example one user created a profile and that user have to post some pictures in one field. Most user use another table for store image. Need your help","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":114,"Q_Id":59929178,"Users Score":1,"Answer":"you have to create  different model for that task. Or may be you have to declare array field. I think array field won't work to solve your problem","Q_Score":2,"Tags":"python-3.x,django-models,django-rest-framework","A_Id":59998150,"CreationDate":"2020-01-27T10:23:00.000","Title":"Storing multiple image in one field django rest framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to intercept the documents printed through OPOS driver. I have successfully intercepted data with windows printer but not able to intercept OPOS. Is there anyway to create spool file of OPOS.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":101,"Q_Id":59930294,"Users Score":0,"Answer":"The spool function is not defined in the OPOS specification.\nAlso, the function to monitor or hook the print contents is not defined.\nEven if there is an OPOS control with such features, it will be specific to a particular vendor.\nPlease ask the printer vendor you are using for such features.\nAlternatively, data can be obtained by hardware such as a line monitor such as USB or serial, but it is for investigations when problems occur and it is not practical to use it at store operation.","Q_Score":0,"Tags":"c#,python,thermal-printer,pos,opos","A_Id":59941957,"CreationDate":"2020-01-27T11:31:00.000","Title":"Spool documents printed from OPOS Driver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to make 2 business-like reports about media. Therefore I have to analyze data and give colleagues an excel file with multiple custom formatted tables. \nIs there a way to make custom formatted tables in R or python and export them to excel? \nThis way I can automate formatting the 3000+ tables :) \nThanks in advance!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":178,"Q_Id":59931829,"Users Score":0,"Answer":"Have you tried using pandas ? In python.","Q_Score":0,"Tags":"python,r,excel,python-3.x","A_Id":59931906,"CreationDate":"2020-01-27T13:09:00.000","Title":"How to export custom tables from R\/Python to Excel?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can I use scipy.optimize.minimize to only restrict its answer to for example 2, 3, 4, 6, 8, 10? Just those values and not float values?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":59932915,"Users Score":0,"Answer":"If the question is, if you can use discrete\/integer\/categorical design variables in scipy.optimize.minimize, the answer is no. It is mainly focused on gradient-based optimization, and it assumes continues design variables and continuous objective function. You can implement some continuous approximation, or branch-and-bound or similar methods to solve for discrete design variables.","Q_Score":1,"Tags":"python,scipy-optimize-minimize","A_Id":60004958,"CreationDate":"2020-01-27T14:17:00.000","Title":"Using scipy.optimize.minimize with a quantized integer range","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 4.5 million rows to process, so I need to speed this up so bad. \nI don't understand how regex works pretty well, so other answers are so hard for me to understand.\nI have a column that contains IDs, e.g.:\n\nELI-123456789\n\nThis numeric part of this ID is contained in this string in a columnm bk_name started with a \"@\":\n\nAAAAA@123456789_BBBBB;CCCCC;\n\nNow my goal is to change that string into this string, throw the ID at the end, started with a \"#\", save it in new_name:\n\nAAAAA_BBBBB;CCCCC;#123456789\n\nHere's what I tried:\n\nTake the ID and replace \"ELI-\" with \"@\", save as ID2:\n\ndf[\"ID2\"] = df[\"ID\"].str.replace(\"ELI-\", \"@\")\n\nFind ID2 in the string of bk_name and replace it with \"\":\n\ndf[\"new_name\"] = df[\"bk_name\"].replace(regex = r'(?i)' + df[\"ID2\"].astype(str), value = \"\")\n\nTake the ID again, replace \"ELI-\" with \"#\", add it at the end of the string of new_name:\n\ndf[\"new_name\"] = df[\"new_name\"] + df[\"ID\"].str.replace(\"ELI-\", \"#\") \nNow the problem is that step 2 is the line that takes most of the time, it took 6.5 second to process 6700 rows.\nBut now I have 4.6 millions rows to process, it's been 7 hours and it's still running and I have no idea why.\nIn my opinions, regex slows down my code. But I have no deeper understanding.\nSo thanks for your help in advance, any suggestions would be appreciated :)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":59935416,"Users Score":0,"Answer":"I don't understand what caused the problem but I solved it.\nThe only thing I changed is in step 2. I used apply\/lambda function and it suddenly works and I have no idea why.\n\nTake the ID and replace \"ELI-\" with \"@\", save as ID2:\n\ndf[\"ID2\"] = df[\"ID\"].str.replace(\"ELI-\", \"@\")\n\nFind ID2 in the string of bk_name and replace it with \"\":\n\ndf[\"new_name\"] = df[[\"bk_name\", \"ID2\"]].astype(str).apply(lambda x: x[\"bk_name\"].replace(x[\"ID2\"], \"\"), axis=1)\n\nTake the ID again, replace \"ELI-\" with \"#\", add it at the end of the string of new_name:\n\ndf[\"new_name\"] = df[\"new_name\"] + df[\"ID\"].str.replace(\"ELI-\", \"#\")","Q_Score":0,"Tags":"python,regex,replace","A_Id":59953332,"CreationDate":"2020-01-27T16:43:00.000","Title":"How to speed up this Regular Expression in .Replace function?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering if it were possible to iterate over a pandas column and replace strings if a particular condition was met.  Essentialy I have a dataframe column with 100s of strings all in the general format GCA_XXXXX.X_MMXXXX.X, although some are in the XXXX_MMXXXX.X format, and I need to remove one of that dashes and replace with '|' and only if it is followed by MM, if it is AFTER GCA then I need it to be replaced form '_' to ''.  Is there any way in python that I can set this conditions and iterate a function over the column? thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":20,"Q_Id":59937062,"Users Score":0,"Answer":"Maybe try something like this:\ndf['column'] = df['column'].astype(str).replace('_MM','|MM')\ndf['column'] = df['column'].astype(str).replace('GCA_','GCA')","Q_Score":0,"Tags":"python-3.x,pandas","A_Id":59937589,"CreationDate":"2020-01-27T18:44:00.000","Title":"Specific conditions for string replacement?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with the python pandas_dedupe package, specifically with pandas_dedupe.dedupe_dataframe.\nI have trained the dedupe_dataframe module via the interactive prompts. But now I need to retrain the dedupe_dataframe module. How can I erase the training set and start from scratch?\nI have tried deleting the dedupe_dataframe_learned_settings and dedupe_dataframe_training.json files, but then then the python script throws an error.\nI work with PyCharm as my IDE.\nAny hint would be much appreciated.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":258,"Q_Id":59937320,"Users Score":0,"Answer":"pandas-dedupe v1.3.1, you simply need to do the following:\n\ndelete dedupe_dataframe_learned_settings and dedupe_dataframe_training.json;\nrun dedupe_dataframe setting update_model=False [note: this is the default].\n\nThis is the standard procedure.\nIf it does not work, please provide more info related to the error you get.","Q_Score":1,"Tags":"python,pandas,python-dedupe","A_Id":62744734,"CreationDate":"2020-01-27T19:02:00.000","Title":"How to erase pandas_dedupe.dedupe_dataframe training set?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to tokenize the following sentence type: \n\"The item at issue is no. 3553.\"\nEvery tokenizer I've tried so far returns the following (including a Punkt tokenizer trained on my corpus):\n[[\"the\", \"item\", \"at\", \"issue\", \"is\", \"no.\"], [\"3553.\"]]\nAdding a \"no\" abbreviation to the tokenizer would be a problem for sentences ending in \"no.\"","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":531,"Q_Id":59938853,"Users Score":1,"Answer":"Im afraid the only way for the system to understand the difference between no. the abbreviation and no. the end of sentence, is to understand the full context of the sentence.  And that is beyond the scope for basic tokenizers, and starts wandering into Machine Learning (ML) or Natural Language Processing (NLP).   \nThat said, it might be possible with forward-looking patterns to see no. followed by digits.","Q_Score":1,"Tags":"python,nlp,nltk,gensim","A_Id":59939026,"CreationDate":"2020-01-27T21:01:00.000","Title":"Stop sentence tokenizer from splitting sentence on \"no.\" abbreviation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that takes some inputs from the user & then executes the code based on the input. The code takes some time to complete; during this code runtime the user can close the terminal(the code is run from a Linux machine)\nAs soon as the user closes the terminal the script stops as well. I know there are options like nohup but it wouldn't accept any input(where input is required in my script).\nHow can I fix this? \nRequirement is -\n\nRun the script, enter the inputs\nLet the code run in the background even if the terminal is closed\nAlso is there a way to write whatever is being printed in the terminal(during the script runtime) to some file","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":356,"Q_Id":59941299,"Users Score":1,"Answer":"Linux's screen tmux served my purpose.","Q_Score":0,"Tags":"python-3.x,nohup","A_Id":59989619,"CreationDate":"2020-01-28T02:06:00.000","Title":"How to run python scipt in the background(after user input) even if the terminal is closed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I currently have a larger problem at hand so I started by trying to match the smaller differences to see if that'll fix my issue.\nIn my program, I was using a pipe and iterating through that input through sys.stdin. I noticed it's type is <class '_io.TextIOWrapper'>. I'm trying to avoid using a pipe and replaced my code to use subprocess.run() instead and noticed that the result has the type <class 'str'> instead.\nThis could be a really stupid question but I'm wondering why they're different and if I can get the subprocess stdout to be the same type as sys.stdin.\nUsing Python 3.7.5","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":132,"Q_Id":59942154,"Users Score":0,"Answer":"subprocess.run returns a CompletedProcess instance, with the collected stdout\/stderr captured all at once.\nIf you want a stream, create a Popen instance, which will have stdout and stderr attributes that act like sys.stdin, and a stdin attribute that acts like sys.stdout. But beware pipe buffering\/deadlock problems if you do anything fancy.","Q_Score":0,"Tags":"python,types,subprocess,stdout,stdin","A_Id":59942779,"CreationDate":"2020-01-28T04:31:00.000","Title":"Python sys.stdin and subprocess stdout difference","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"The computer on which I want to install pip and modules is a secure offline environment.\nOnly Python 2.7 is installed on this computers(centos and ubuntu).\nTo run the source code I coded, I need another module.\nBut neither pip nor module is installed.\nIt looks like i need pip to install all of dependency files.\nBut I don't know how to install pip offline.\nand i have no idea how to install the module offline without pip.\nThe only network connected is pypi from the my nexus3 repository.\nIs there a good way?\nWould it be better to install pip and install modules?\nWould it be better to just install the module without installing pip?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":59944008,"Users Score":0,"Answer":"using pip it is easier to install the packages as it manages certian things on its own. You can install modules manually by downloading its source code and then compiling it yourself. The choice is upto you, how you want to do things.","Q_Score":0,"Tags":"python,pip","A_Id":59944100,"CreationDate":"2020-01-28T07:32:00.000","Title":"Is there an effective way to install 'pip', 'modules' and 'dependencies' in an offline environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I want to upload a temporary table, populate it using a csv file and then run a bunch of other queries with the same connection. Currently I'm uploading a normal table, doing my queries and then dropping it. But I want to make it temporary to avoid confusion and to avoid large amounts of data being left in the db if the code stops for some reason (exception\/debugging etc.) before it gets a chance to drop the table. I'm doing all this in python using psycopg2. \nFirstly, I've assumed the temporary table will hang around as long as the connection is alive. Is this true? But more importantly, does a psycopg2 db connection ever automatically handle a momentary connection drop out by reestablishing a connection? The queries I'm running are very time consuming so I worry that this could happen. In which case is there some way of knowing when the connection refreshes so I can reupload the temporary table?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":434,"Q_Id":59947300,"Users Score":1,"Answer":"does a psycopg2 db connection ever automatically handle a momentary connection drop out by reestablishing a connection?\n\nDo you mean does it get impatient, kill a live but \"stalled\" (e.g. network congestion) connection, and replace it with a new one?  No.  You could probably write code to do that if you wanted (but why would you?) but psycopg2 itself won't do that.","Q_Score":1,"Tags":"python,database,postgresql,psycopg2,temp-tables","A_Id":59953360,"CreationDate":"2020-01-28T11:04:00.000","Title":"Do I need to recreate a temp table if a postgres connection refreshes?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let suppose I Have a webhook that will request to my python server and I want to allow that request to process without applying any middleware authorization of python.\nI don't want to make more costly process of request\/response by processing all the requests in my custom middleware.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":59953583,"Users Score":1,"Answer":"You could create a separate settings file for a different web server instance where it would use that settings file. You'd also likely need to create a separate urls.py so that you don't grant access to other views.","Q_Score":0,"Tags":"python,django","A_Id":59953775,"CreationDate":"2020-01-28T16:56:00.000","Title":"how to exclude specific api from applying all the authorization of python middleware","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I've been racking my brain trying to implement a system in which computers on a network (where there are always three or more computers on the network) are able to asynchronously communicate with each other by sending each other data.\nSo far, all I've been able to find as far as solutions go is sockets--which, to my knowledge, requires a client and a server script. My first problem is that I'd like to remove any client or server roles since all of the computers on the network are decentralized and running the same script concurrently without a server. Secondly, all of the computers are sending other nodes (chosen at random) sensor data from a specific point in time. If, for example, I have 4 computers on the network and--since they're all running the same script--they decide to send their data to another computer at the same time, wouldn't that cause a wait lock since all of the nodes are trying to communicate with another computer, but those computers are unable to accept the connection because they're also trying to send data?\nI've considered using multithreading to run my begin_sync and wait_sync functions concurrently, but I'm not sure whether or not that would work. Does anyone have any suggestions or ideas for solutions that I could look into?\nThanks for your time!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":106,"Q_Id":59954817,"Users Score":0,"Answer":"As per NotTheBatman's response, I was able to get this to work using sockets on multiple ports. As far as how I handled being able to wait for sensor data and query other nodes, I simply used multithreading with great success.","Q_Score":0,"Tags":"python,network-programming,gossip","A_Id":60660334,"CreationDate":"2020-01-28T18:20:00.000","Title":"Is decentralized communication between 3+ computers in a network possible in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I came across a Python source code \"minifier\" called pyminifier. Is it safe to run this against the Python3.8.1 core .py files?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":59955524,"Users Score":0,"Answer":"It's not safe. I ran python3.8 -m compileall . to check if python produces different .pyc files, but I get many build errors. The command works on the original source. The utility broke the source code.","Q_Score":0,"Tags":"python,python-3.x,minify","A_Id":59995677,"CreationDate":"2020-01-28T19:11:00.000","Title":"Is it safe to use Python3.8.1 core py files that have been minified using PyMinifier","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to use some feature extraction techniques in Xcode using Swift. How can I import Python, librosa or any such thing in Xcode? What exactly I need to do?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":326,"Q_Id":59957547,"Users Score":0,"Answer":"I partially ported it to Swift. It's early version but you can try use it.\nplease try find RosaKit in GitHub","Q_Score":0,"Tags":"python,xcode,librosa","A_Id":62583926,"CreationDate":"2020-01-28T21:48:00.000","Title":"How do I use librosa in Xcode for audio feature extraction?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two same python file in different location and these scripts will be invoked and executed in random time. If one script is executing, I want other script to wait until that job is finished. How can I get it done?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":148,"Q_Id":59958145,"Users Score":0,"Answer":"you can have a global Flag in somewhere like DB and change your code in a way that script1 only runs when flag is True and script2 only runs when flag is set to false. you should change the value of flag in both scripts.\nOr you can use Trigger. Trigger script2 from script1 after his work is finished.","Q_Score":0,"Tags":"python-3.x,parallel-processing,singleton,semaphore","A_Id":59963099,"CreationDate":"2020-01-28T22:37:00.000","Title":"Avoid duplicate execution of same python script in different location when invoked by 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'm working on an algorithm that analizes the shape of a continent in a simple black and white map, and returns the ouline of its perimeter.\nAn example would be as follows:\n[(1,0), (2,0), (2,1), (2,2), (3,2)...]\nSo far, the algorithm produces the correct list, but as you can see, it produces redundant points.\nIn the example, the 3 points after the first form a straight line, from 2,0 to 2,2. (2,1), the redundant point, should be eliminated, but i'm not sure how.\nFYI: I'm working in a pure python application, the only library I'm using is pygame. I've looked into similar questions with no luck.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":519,"Q_Id":59959454,"Users Score":1,"Answer":"3 points (x1,y1), (x2,y2), and (x3,y3) are colinear (in a line) if:\n(x2-x1)(y3-y2) - (y2-y1)(x3-x2) = 0\nWhenever 3 consecutive points in the outline are colinear, the middle one is redundant and can be removed.\nYou can do this incrementally as you add points to the list.  If there are at least 2 points in the list, then before adding another one, check to see if its colinear with the last 2.  If it is, then remove the last one before adding the new one.\nWhen you're done, check the start and end points to see if they're redundant, and remove them if they are.","Q_Score":3,"Tags":"python,arrays,list,pygame","A_Id":59959861,"CreationDate":"2020-01-29T01:35:00.000","Title":"Remove redundant points in a line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't get windows to use python 3 as default. \nI have both versions of python (2.7 & 3.6) installed on my windows 10 pc. I installed python 3 from python.org and ticked the add to PATH box. I've spent a week on and off looking for solutions to getting Bash and Atom to use python 3 as default, including: \n\nchanging the environmental path order, \nreinstalling python3 (so far three times!),\nusing $ python3.6 (or variations of this text I've found online) in git, \nconfiguring atom-python-run to run python3 (this just flashes a python window, nothing further happens),\nBash out put: \n$ python --version\nPython 2.7.17\nI downloaded the ubuntu for windows app. This displays the following: \npython3 --version\nPython 3.6.7. \n\nI'm struggling to come up with other ideas that could work (even with the hours of Googling). If anyone could help I'd be grateful. \nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":59959573,"Users Score":1,"Answer":"My question is why do you have both versions. Then here is your anwser for your question. You can simply just uninstall 2.7, and use 3.6 for the project. When you need 2.7 just simply reinstall it. \nYou could also try to find a software that will just turn off python 2.7, but sadly I dont know of such software. \nAnother thing is just right your python file, change dir into the project. Then do the command python3 pythonFileName.py in your console, and it would run the project using python3.\nHope this helps! If you have any questions feel free to comment on this anwser.","Q_Score":0,"Tags":"python,python-3.x,windows,bash,atom-editor","A_Id":59959850,"CreationDate":"2020-01-29T01:53:00.000","Title":"Windows using python 2.7 rather than 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I see that there's a built-in I\/O connector for BigQuery, but a lot of our data is stored in Snowflake. Is there a workaround for connecting to Snowflake? The only thing I can think of doing is to use sqlalchemy to run the query and then dump the output to Cloud Storage Buckets, and then Apache-Beam can get the input data from the files stored in the Bucket.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":924,"Q_Id":59960706,"Users Score":1,"Answer":"Google Cloud Support here!\nThere's no direct connector from Snowflake to Cloud Dataflow, but one workaround would be what you've mentioned. First dump the output to Cloud Storage, and then connect Cloud Storage to Cloud Dataflow.\nI hope that helps.","Q_Score":3,"Tags":"python,google-cloud-dataflow,pipeline,apache-beam,snowflake-cloud-data-platform","A_Id":59965614,"CreationDate":"2020-01-29T04:59:00.000","Title":"Python: How to Connect to Snowflake Using Apache Beam?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Recently I've been trying to use RGB Colours, i.e.\n166, 245, 255.\nHowever I'm stuck in here:\ndiscord.Colour()\nwhere I can only input ONE value in the brackets. How can I solve it?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1813,"Q_Id":59961455,"Users Score":2,"Answer":"For 0-255 RGB range: discord.Colour.from_rgb(r, g, b)\nFor hexa: discord.Colour(0xff55ff)","Q_Score":1,"Tags":"python,colors,discord.py","A_Id":59962161,"CreationDate":"2020-01-29T06:18:00.000","Title":"How can I use RGB codes in discord.Colour in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have found that there are a lot of similarities between both modules in the area of creating temp files using io.BytesIO() or io.StringIo() and tempfile.TemporaryFile()\nWhat is the purpose of each one ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1099,"Q_Id":59967774,"Users Score":4,"Answer":"io.BytesIO() create a file-like object linked to a memory area, and should be used to store binary data (like data used to represent an image, a music, a MS Word document, etc.).\nio.StringIO() create a file-like object linked to a memory area, and should be used to store text data (like a html page, a php script, etc).\ntempfile.TemporaryFile() create a temp file on the disk (not in memory). Use first argument mode to specify or not the b flag to determine if the file should store binary data or only text.","Q_Score":3,"Tags":"python-3.x,temporary-files,stringio,bytesio","A_Id":59967841,"CreationDate":"2020-01-29T13:05:00.000","Title":"What are the differences between tempfile module and IO file-like objects","Data 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 a GUI by using QtDesigner and PyQt5. There are 60 push buttons and I want to disable\/enable 50 of them by pushing 61th push button. How it can be achieved?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":398,"Q_Id":59968959,"Users Score":2,"Answer":"One option is to add the buttons you want to enable\/disable to a button group. In QtDesigner this can be done by selecting the buttons, right-clicking on the selection and choosing \"Assign to button group\" in the popup menu. You can then iterate over buttongroup.buttons() to enable\/disable them.","Q_Score":1,"Tags":"python,qt,pyqt,pyqt5","A_Id":59972099,"CreationDate":"2020-01-29T14:13:00.000","Title":"How to enable\/disable many controls including push buttons simultaneously in PyQt5?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a package that uses the Google Analytics API for Python.\nBut, in severous cases when I have multiple dimensions the extraction by day is sampled.\nI know that if I use sampling_level = LARGE will use a sample more accurate.\nBut, somebody knows if has a way to reduce a request that you can extract one day without sampling?\nGrateful","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":840,"Q_Id":59969386,"Users Score":0,"Answer":"setting sampling to LARGE is the only method we have to decide the amount of sampling but as you already know this doesn't prevent it.\nThe only way to reduce the chances of sampling is to request less data. A reduced number of dimensions and metrics as well as a shorter date range are the best ways to ensure that you dont get sampled data","Q_Score":0,"Tags":"python-3.x,google-analytics,google-analytics-api","A_Id":59969860,"CreationDate":"2020-01-29T14:33:00.000","Title":"How to get unsampled data from Google Analytics API in a specific day","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've a python application in which I'm using print() method tho show text to a user.  When I interact with this application manually using kubectl exec ... command I can see the output of prints. \nHowever, when script is executed automatically on container startup with CMD python3 \/src\/my_app.py (last entry in Dockerfile) then, the prints are gone (not shown in kubectl logs). Ayn suggestin on how to fix it?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":2612,"Q_Id":59969871,"Users Score":3,"Answer":"It turned out to be a problem of python environment. Setting, these two environment variables PYTHONUNBUFFERED=1 and PYTHONIOENCODING=UTF-8 fixed the issue.","Q_Score":1,"Tags":"python,docker,kubernetes","A_Id":59969872,"CreationDate":"2020-01-29T15:00:00.000","Title":"Kubernetes log not showing output of python print method","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"We developed web apps in django framework. We have an enterprise Identity Provider which is PingFederate. The main home page (which is different from our site) from chrome browser and edge browser directly recognizes the user and logs them in all the internal websites. We are also on the same network share same domain. We also want to integrate SSO and want to authenticate our users directly with asking password. I researched every where and got to know the authentication is happening by kerbose authentication. Somehow the edge or chrome  is sending some token or id or some TGT ticket to the Identity Provider then they will authenticate and send the username back to the client browser. Can any one please help me how to solve this.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":774,"Q_Id":59976813,"Users Score":1,"Answer":"It sounds like you want to integrate with the PingFederate solution to use it as the identity provider and allow the users of your web apps to login through SSO. If that is the case, you would need to work with whoever responsible for PingFedereate if it is another team.\nChecklist with the PingFederate Admin\n\nYou would need to know if you need to choose the directory will be used to log the users in. \nWhich user attributes you would need to get back in the SAML response.\nWill you sign the SAML request using your app or not.\nWill you start the SSO cycle from your app, which I believe you would, and you will be using SP initiated in this case. \n\nOtherwise, it will be the other way around and will be using IDP Initiated. \n\nSP Initiated - User will call the app URL first and then redirected\nto Ping URL and be sent back to the app.\nIDP Initiated - User will call PingFederate URL and will be sent to the app after authentication. \n\nI will list the steps in here in case it is your team who is also responsible for PingFederate solution:\n\nChanges in PingFederate as SP (service provider) connection\n\nCreate a new IDP (Identity Provider) Adapter for the login page if needed.\n\n\nIDP adapter will be using a Password Credential Validator to do the authentication and also has the configuration for which HTML pages to present to the user. \nCreate the SP connection in Ping with the stuff in the check list.\n\n\nThe connection here will use the adapter in the step above to present the login page\nThen check the user credentials and establish the SSO session if successful.\nAssemble the SAML response with all the required attributes.\nSign the response and send it to the application endpoint configured inside the connection.\n\n\n\nChanges in the web app as the service provider for the user\n\nThe application will need to send the SAML request to the endpoint of the new connection in Ping.\nWait for the response on the dedicated endpoint.\nVerify the SAML response signature using the PingFederate server's public key.\nCreate the local app session and move on.\n\n\nIf you will be using OpenToken, this will change to have another interaction of Adapter-to-Adapter. Just reply with that if this is the case.","Q_Score":0,"Tags":"python,django,saml-2.0,pingfederate","A_Id":60384457,"CreationDate":"2020-01-29T22:56:00.000","Title":"Integrate Django authentication with Enterprise Identity Provider PingFederate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a python code that visulizes a driving scenario in python. The code uses pyglet. Lets say the code is \nvis_traj(input_A)\nI need to visualize two scenarios at the same time. And I am trying to run them on separate processor using multiprocessing library. \np1 = Process(target = vis_traj, args=(input_A))\np2 = Process(target = vis_traj, args=(input_B))\np1.start()\np2.start()\nBut I get an error and it seems like they can't use X server at the same time:\nXIO:  fatal IO error 25 (Inappropriate ioctl for device) on X server \":1\"\n      after 228 requests (228 known processed) with 0 events remaining.\nXIO:  fatal IO error 11 (Resource temporarily unavailable) on X server \":1\"\n      after 230 requests (230 known processed) with 18 events remaining.\nXIO:  fatal IO error 11 (Resource temporarily unavailable) on X server \":1\"\n      after 228 requests (228 known processed) with 0 events remaining.\nIs there anyway to circumvent this error?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":277,"Q_Id":59978363,"Users Score":0,"Answer":"I happened upon this question while struggling for an answer. I was able to get my code to work by moving all the pyglet related classes and imports into the function that I run in Process(). I suspect that the pyglet library has global state that has to be unique for each process.\nI was hinted to this by another answer that I can't now find that pointed me in the right direction.","Q_Score":0,"Tags":"python,python-multiprocessing,pyglet,xserver","A_Id":62725189,"CreationDate":"2020-01-30T02:38:00.000","Title":"running multiple instances of pyglet with multiprocessing library in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to python, about a month.\nI know installing python modules can be done by using pip or easy_install. But when I was trying to install the regex module it gave me an error.\nTyping pip install re in cmd gave me the following errors;\n\nERROR: Could not find a version that satisfies the requirement re (from versions: none)\nERROR: No matching distribution found for re\n\nSo I went to PyPI and downloaded a file there and now PyCharm doesn't give error when I import the module anymore.\nSo are there any difference between these ways of downloading Python modules or it doesn't matter ?\nI'm using Windows 10 and have Python 3.8 and 3.8.1.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":247,"Q_Id":59978611,"Users Score":0,"Answer":"re is part of the Python standard library so there is no need to install it separately. There are many ways to 'install' a package, e.g. using easy_install, pipx, venv, poetry, etc., but pip install --user is likely the way you're going to want to go to get started until you run into a compelling reason to explore other options. Either way, all these tools are essentially just various ways to move packages into PYTHONPATH, the place that Python looks for packages by default.","Q_Score":0,"Tags":"python,module","A_Id":59978696,"CreationDate":"2020-01-30T03:16:00.000","Title":"Ways of installing python module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the MLPClassifier using the lbfgs solver.\nIf I calculate the expected value using the predict_proba() method and the classes_ attribute, it does not match what the predict() method returns.\nWhich one is more accurate?\nDoes the value returned by predict() have to be one of the classes? Will it not interpolate between the classes? I have a continuously varying variable I want to predict.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":251,"Q_Id":59980207,"Users Score":1,"Answer":"Definition\npredict - classifies your input into a label. \npredict_proba - returns the predicted probability for each class in your model.\nExample\nIf this were a binary problem, and your classes labelled 0 and 1. Then for some input you are testing, predict will return a class, let's say 1.\nHowever, predict_proba is going to give you the predicted probability that this input maps to class 1, which could, in this example, be 0.8. This is why their values do not match.\nWhich is more accurate?\nYou can't really compare their accuracy. However, you can treat the predict_proba as the confidence of your model for a particular class. For example, if you have three classes, and you tested one sample. Then you would receive an output of three real numbers:\n[0.11, 0.01, 0.88]\nYou could treat this as your model having a high confidence that this input maps to the third class, as it has the highest probability of 0.88. \nIn contrast, for some other input value, your model might spit out the following:\n[0.33, 0.32, 0.34]\nYour model still predicts the third class, as this has the highest probability. However, there is a low confidence that the third class is the true class.","Q_Score":0,"Tags":"python,scikit-learn,neural-network,classification","A_Id":59980630,"CreationDate":"2020-01-30T06:26:00.000","Title":"MLPClassfier predict and predict_proba seem inconsistent","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm pretty new to coding, I've done more with HTML and CSS than anything, but now I'm trying to learn a new language because I have an idea for something I want to build. I'm not exactly sure what language would be the best for this. I've been trying to learn a little python, but I want to make sure I'm on the right road. What I'm trying to build is a program that would let me have a form that we would fill out anytime we have an accident at my job, the form would have questions like, type of injury, department associate was working in, time of injury, day of the week, etc.. It would also keep track of our Non-Meds, Medicals and osha reportables by shift and in total for the week, month, year or whatever time span you want to see and show it in graphs or pie charts, so the information could be used to determine where our weaknesses are in terms of safety. So the form would basically take the information you input, and store it in the correct category and automatically update the charts. I know I'm probably trying to take on something kind of big, being as I don't know a whole lot about coding, but I feel like working on this would give me a good starting point. I've already made a spreadsheet in excel to get us by for now, but I would like to make something thats more user friendly to update anytime an accident occurs. So what language do you guys think would being a good one to learn to tackle this?\nThanks for any help in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":59981985,"Users Score":0,"Answer":"I think I would use C# and WPF for creating the input form, because it is pretty easy to build GUIs for windows with C# and Visual Studio. Then I would store the input information into a SQL database for easy querying of the data. To analyze the data I would use python with MatPlot lib to make graphs and visualize the data in an understandable way. Then the C# GUI could display the graphs generated by python in a classical GUI with dropdowns or tabs or whatever fits the purpose.","Q_Score":1,"Tags":"python,statistics","A_Id":59982177,"CreationDate":"2020-01-30T08:43:00.000","Title":"Trying to build a program to organize safety data and display it in graphs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating a mobile app, I want to access a web server that is implemented in Python Django. I found that there is Retrofit in android to communicate with a web server. My question is that whether I have to write Client REST API and Server REST API both. \nAs I am considering that I will write REST API using Retrofit (Client REST API).\nAnd then write a REST API for my server in python Django (Server API).\nI am really confused about what will be the way to communicate with my server that is developed in python Django. And up to what limit I have control on server i.e how much an android app can control(create a database in web server, perform CRUD operations)\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":753,"Q_Id":59982739,"Users Score":0,"Answer":"Actually, it is quite simply, independent of the language of your server, basically if your server can respond with a json, you can use Retrofit2 and POST, GET, UPDATE, DELETE, etc...","Q_Score":0,"Tags":"python,android,django-rest-framework,retrofit","A_Id":59983013,"CreationDate":"2020-01-30T09:28:00.000","Title":"Communicate Android app with python Django web server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there any option to load a pickle file in chunks?\nI know we can save the data in CSV and load it in chunks.\nBut other than CSV, is there any option to load a pickle file or any python native file in chunks?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3192,"Q_Id":59983073,"Users Score":0,"Answer":"I had a similar issue, where I wrote a barrel file descriptor pool, and noticed that my pickle files were getting corrupt when I closed a file descriptor. Although you may do multiple dump() operations to an open file descriptor, it's not possible to subsequently do an open('file', 'ab') to start saving a new set of objects.\nI got around this by doing a pickler.dump(None) as a session terminator right before I had to close the file descriptor, and upon re-opening, I instantiated a new Pickler instance to resume writing to the file.\nWhen loading from this file, a None object signified an end-of-session, at which point I instantiated a new Pickler instance with the file descriptor to continue reading the remainder of the multi-session pickle file.\nThis only applies if for some reason you have to close the file descriptor, though. Otherwise, any number of dump() calls can be performed for load() later.","Q_Score":10,"Tags":"python,file,csv,pickle,chunks","A_Id":67877414,"CreationDate":"2020-01-30T09:45:00.000","Title":"How to load Pickle file in chunks?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my Python 3 script I am starting another program that normally prints out what its doing as its doing if I don't capture the output with PIPE such as below:\nproc = subprocess.run(\"program\")\nBut when I do capture the output for saving to a text file with:\nproc = subprocess.run(\"program\", stdout=subprocess.PIPE, stderr=subprocess.STDOUT)\nit no longer prints out as the subprocess is running but does capture the output for saving to a text file. Is there a way to have the program print to the screen and capture that output. I have read through subprocess but I cannot figure out a way to do so.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":216,"Q_Id":59985818,"Users Score":2,"Answer":"Is there a way to have the program print to the screen and capture that output.\n\nCapture it and print it yourself.\nIf you want to print the output as it's going, use subprocess.Popen, then stdout and stderr will be streams, you can read their content in a loop and print that as it gets output (though beware that the process's stdout will most likely be fully buffered while stderr is unbuffered).","Q_Score":2,"Tags":"python,subprocess","A_Id":59986087,"CreationDate":"2020-01-30T12:14:00.000","Title":"How to use subprocess to capture output & allow for the output to print to screen?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm aware that we can manage db transaction to maintain transaction.atomic(), it works really well with SQL, just wanted to understand if I use mongoengine as ODM then will it work or if not\nwhat option do I have to maintain atomicity?\nAny help will be useful","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":287,"Q_Id":59986210,"Users Score":0,"Answer":"django's atomic feature only applies to django's ORM which applies to sql databases. MongoEngine currently has no support for transactions and to my knowledge no python ORM currently supports them.\nIf atomicity is a hard requirement and you need to use mongoDB, I guess you need to go with the underlying driver pymongo","Q_Score":0,"Tags":"django,python-3.x,mongoengine","A_Id":60012311,"CreationDate":"2020-01-30T12:36:00.000","Title":"Does transaction.atomic works with mongoengine as well","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just started looking into deep learning and started to build a CNN with Keras. \nSo I've noticed that oftentimes when the Dataset MNIST is used, after importing the images, they are getting converted to float32-Datatype. \nSo my question is, why is that the case? It seems like it should work fine with uint8-Data. What am I missing here? Why is float32 needed?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1654,"Q_Id":59986353,"Users Score":7,"Answer":"Well the reason is simple, the whole math for neural networks is continuous, not discrete, and this is best approximated with floating point numbers. The inputs, outputs, and weights of a neural network are continuous numbers.\nIf you had integer outputs, they will still be converted to floating point at some point in the pipeline, in order to have compatible types where operations can be made. This might happen explicitly or implicitly, its better to be explicit about types.\nIn some frameworks you might get errors if you do not cast the inputs to the expected types.","Q_Score":2,"Tags":"python,keras,deep-learning,mnist","A_Id":59986740,"CreationDate":"2020-01-30T12:45:00.000","Title":"Why do i have to convert \"uint8\" into \"float32\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just started looking into deep learning and started to build a CNN with Keras. \nSo I've noticed that oftentimes when the Dataset MNIST is used, after importing the images, they are getting converted to float32-Datatype. \nSo my question is, why is that the case? It seems like it should work fine with uint8-Data. What am I missing here? Why is float32 needed?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1654,"Q_Id":59986353,"Users Score":0,"Answer":"The answer is:\nWe should perform a lot of data augmentation and training as well in CNN. This will lead to a faster training experience!","Q_Score":2,"Tags":"python,keras,deep-learning,mnist","A_Id":70925908,"CreationDate":"2020-01-30T12:45:00.000","Title":"Why do i have to convert \"uint8\" into \"float32\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We want to export data from dynamo db to a file. We have around 150,000 records each record is of 430 bytes. It would be a periodic activity once a week. Can we do that with lambda? Is it possible as lambda has a maximum execution time of 15 minutes?\nIf there is a better option using python or via UI as I'm unable to export more than 100 records from UI?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10670,"Q_Id":59988635,"Users Score":1,"Answer":"Guys we resolved it using AWS lambda, 150,000 records (each record is of 430 bytes) are processed to csv file in 2.2 minutes using maximum available memory (3008 mb). Created an event rule for that to run on periodic basis. Time and size is written so that anyone can calculate how much they can do with lambda","Q_Score":1,"Tags":"python,amazon-web-services,aws-lambda,amazon-dynamodb","A_Id":60053826,"CreationDate":"2020-01-30T14:50:00.000","Title":"Exporting data from dynamo db to a csv file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In Spotfire I have a dashboard that uses both filtering (only one filtering scheme) and multiple markings to show the resulting data in a table.\nI have created a data function which takes a column and outputs the data in the column after the active filtering scheme and markings are applied. \nHowever, this output column is only calculated if I have something marked in every marking. \nI want the output column to be calculated no matter how many of the markings are being used. Is there a way to do this? \nI was thinking I could use an IronPython script to edit the data function parameters for my input column to only check the boxes for markings that are actively being used. However, I can't find how to access those parameters with IronPython. \nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":156,"Q_Id":59989115,"Users Score":0,"Answer":"I think it would be a combination of visuals being set to OR instead of AND for markings (if you have a set of markings that are being set from others). \nAlso are all the input parameters set to required parameter perhaps unchecking that option would still run the script. In the r script you may want to replace null values as well. \nNot too sure without some example.","Q_Score":0,"Tags":"output,filtering,ironpython,spotfire","A_Id":59990189,"CreationDate":"2020-01-30T15:17:00.000","Title":"Spotfire: Using Multiple Markings in a Data Function Without Needing Something Marked in Each","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I currently work in an offline environment. \nI have Anaconda installed along with VS Code. \nI have downloaded and installed the MS Python Extension and the Python-autopep8 extension. \nHowever, when I go to save a document and auto-format I am told that autopep8 is not installed. \nIs there any way to get the auto-formatting to work with autopep8?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":321,"Q_Id":59989790,"Users Score":0,"Answer":"I'm working on VS Code for Windows, and I think this might work:\n\nMake sure you have it installed (in the Extension Manager).\nRight-click your code and select Format Document. If a dialogue pops up that asks to install autopep8 click yes.","Q_Score":1,"Tags":"python,visual-studio-code,autopep8","A_Id":63362056,"CreationDate":"2020-01-30T15:52:00.000","Title":"Python autopep8 and VS Code integration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is data being automatically sent with POST request to the address I'm developing on, in format of JSON string.\nHow should I properly fetch this data in my function based view, so I can manipulate with it?\ndata = requests.get(url).json() did not work for me, it gives me back this error:\ndjango.urls.exceptions.Resolver404: {'tried': [[<URLResolver <URLResolver list> (None:None) 'en\/'>]], 'path': ''}\nAt least, how can I test if there is any data being sent to the url?\nI'm developing in production env.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":47,"Q_Id":59989908,"Users Score":1,"Answer":"Depending on how the data is posted you will be able to find the data with \n\nrequest.POST.get('url')\n\nor if it is not sent as JSON body it will be found within, which will need to be decoded manually\n\nrequest.body","Q_Score":0,"Tags":"python,json,django,python-requests,fetch","A_Id":59990204,"CreationDate":"2020-01-30T15:59:00.000","Title":"What is the right way to fetch data that is being automatically posted to the URL that I'm developing the app on in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have implemented python code that is listening my db and continuously stores data in pandas DataFrame (inserts new rows and updates old as infinite loop). The data comes to python as it appears in db (updates come on average every 1-5 seconds). \nThe second part of my python code should do some stuff with this DataFrame. So what I want to do is to split my code into separate threads. \nThe first thread will store data in DataFrame and the other thread (or more than one) will use the DataFrame to do some stuff and return results via plots, variables and so on. \nI have done some reaserch on threading, but I have not found the solution yet. Any help on this issue and\/or example code is highly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":59990330,"Users Score":0,"Answer":"After all I have created a table in my db that is countinuously updated via trigger-function functionality. On python side I have done Threads that call to this table asynchronously, get data and do their stuff.\nPerhaps, this is not the ideal solution, but it works and covers my current needs.","Q_Score":1,"Tags":"python,multithreading","A_Id":60012708,"CreationDate":"2020-01-30T16:24:00.000","Title":"Python getting\/posting data in threads","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I should do it wiht only import os\nI have problem, that i don't know how to make program after checking the specific folder for folders to do the same for folders in these folders and so on.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":59991335,"Users Score":0,"Answer":"You can use os.walk(directory)","Q_Score":1,"Tags":"python,printing,directory,subdirectory,names","A_Id":59991437,"CreationDate":"2020-01-30T17:22:00.000","Title":"Program to print all folder and subfolder names in specific folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I stored the smart contract instance which written in Solidity inside the MySQL database. \ncontract_instance = eth_provider.contract(\n                    abi=contract_abi,\n                    address=contract_address,\n                    ContractFactoryClass=ConciseContract)\nThe value stored is liked Ex: web3.contract.ConciseContract object at 0x00000187148C9F98\nWhen I retrieve the value in Python flask and access the smart contract function, the error shown AttributeError: 'str' object has no attribute 'getCustomerList'\n. \nHow to convert the value from str back to smart contract instance?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":108,"Q_Id":59991820,"Users Score":0,"Answer":"Only contract_address are different in all the contracts. Store the address only and compiled the contract each time the user needs to use it","Q_Score":0,"Tags":"python,flask,solidity","A_Id":60219499,"CreationDate":"2020-01-30T17:54:00.000","Title":"I had stored a smart contract instance in MySQL as string. How to convert it back to solidity instance?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a PDF with form fields created with Acrobat DC by my customer. Using Python pikepdf I'm filling those fields programmatically. The strange issue is that some fields are filled, others not. I checked and double-checked with Acrobat DC: All fields have the exact same Text Field Properties, with the names obviously being unique. The Python code addresses the fields with their correct name. So I suspect that the problem might be related to the way my customer created the fields. Using Acrobat DC I deleted the offending fields and created brand new ones with the same Text Field Properties as the fields that show up as filled in  -- to no avail.\nNow I checked the pikepdf-generated PDF with Acrobat Reader, and all filled-in fields display their value, sigh! However, none of the Linux PDF viewers displays the content of the offending fields while displaying the content of some other fields. I tried Okular, Atril, the document viewer of XFCE4, and LibreOffice Draw. This seems to indicate that the issue on the Acrobat side of things. Any ideas?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":542,"Q_Id":59992748,"Users Score":0,"Answer":"Solution\nI stupidly passed an INT to pikepdf when filling the fields; passing a string solved the problem. What is more: The Linux viewers do not require the 'NeedAppearances' flag to display the filled-in values, while Acrobat Reader does need this flag.","Q_Score":1,"Tags":"python,pdf,acrobat,pikepdf","A_Id":60061344,"CreationDate":"2020-01-30T18:57:00.000","Title":"Why does pikepdf fill-in some PDF fields but not others on a PDF created with Acrobat DC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here is my problem: I am currently using Jupyter notebook with my conda environment.\nI wanted to update it to the latest version (6.0.3 atm) to have access to the NotebookApp.use_redirect_file tag in the config file (because Jupyter doesn't want to open the URL).\nWhen I type jupyter notebook --version it shows 5.7.8 but when I type conda list, notebook is 6.0.3.\nI have tried to uninstall and install anaconda again but it didn't fix it. I don't have other ideas. \nThanks in advance!\nEdit: I just realised my problem is not what I thought. I just need to use anaconda3\/bin\/jupyter-notebook instead of the actual notebook. Maybe it's a problem with the PATH or I need to create an alias. I'm not really got with these things. If someone could tell me what to put in my .bashrc or provide me an other solution, I would be thankful.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":808,"Q_Id":59992785,"Users Score":0,"Answer":"Ok, finally I fixed my problem,\nIt seems that the problem was due to anaconda using the wrong version of Python. So the Jupyter version that I wanted was installed but Anaconda couln't use it. Now everything is working.","Q_Score":0,"Tags":"python,jupyter-notebook,version","A_Id":60036885,"CreationDate":"2020-01-30T19:00:00.000","Title":"Jupyter notebook version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a python web app using the Django framework. I wanted to deploy it online using my domain name. However, I am using the same domain name for my Wordpress site which I have deployed using shared hosting. Is there any way I can deploy my app under the same domain name keeping my website up and running.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":263,"Q_Id":59993764,"Users Score":0,"Answer":"With shared hosting, it might be tricky -- it really depends on the specific way the shared hosting company works.  \nHowever, one alternative that might be worth considering is to use a different subdomain of your domain name.   For example, right now you might have a Wordpress site on www.yourdomain.com.  You could put the Django app on somethingelse.yourdomain.com, and then they could be hosted with completely different providers -- the shared hosting for the Wordpress site, and the Django site somewhere else.  \nIf you made the name of the subdomain match the purpose of the Django site, then it would look pretty good to visitors.  For example, a hotel might have the main site on www.joeshotel.com, using Wordpress, and then a system where people can reserve rooms using Django on reservations.joeshotel.com.","Q_Score":0,"Tags":"python-3.x,wordpress,web-applications,django-deployment","A_Id":60039271,"CreationDate":"2020-01-30T20:09:00.000","Title":"Deploying python web app for wordpress site?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I installed the keyboard module for python with pip3 and after I runned my code the terminal shows me this message: \"ImportError: You must be root to use this library on linux.\" Can anybody help me how to run it well? I tried to run it by switching to \"su -\" and tried it on this place as well.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":196,"Q_Id":59994662,"Users Score":2,"Answer":"Can you please post your script?\nIf you are just starting the program without a shebang it probably should not run and probably throw an ImportError\nTry adding a shebang (#!) at the first line of you script.\nA shebang is used in unix to select the interpreter you want to run your script.\nWrite this in the first line: #!\/usr\/bin\/env python3\nIf this doesn't help try running it from the terminal using a precending dot like this:\npython3 .\/{file's_name}.py","Q_Score":0,"Tags":"python,module,root","A_Id":59994858,"CreationDate":"2020-01-30T21:18:00.000","Title":"Cannot import module from linux-ubuntu 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When i load data, these errors show up:\n....\nFile \"\/Users\/Georg\/PycharmProjects\/990-xml-database\/venv\/lib\/python3.6\/site-packages\/urllib3\/contrib\/pyopenssl.py\", line 318, in recv_into\nraise SocketError(str(e)) \nOSError: (54, 'ECONNRESET')\nDuring handling of the above exception, another exception occurred:\n...\nraise SocketError(str(e))\nurllib3.exceptions.ProtocolError: ('Connection aborted.', OSError(\"(54, 'ECONNRESET')\",))\nDuring handling of the above exception, another exception occurred:\n...\nraise ConnectionError(err, request=request)\nrequests.exceptions.ConnectionError: ('Connection aborted.', OSError(\"(54, 'ECONNRESET')\",))\nAny idea what's wrong \/ how I can solve this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":912,"Q_Id":59994700,"Users Score":0,"Answer":"I solved it adding import urllib3.contrib.pyopenssl in the code","Q_Score":0,"Tags":"python,download,pycharm,connection","A_Id":59996007,"CreationDate":"2020-01-30T21:21:00.000","Title":"OSError 54 - when loading data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have gone into the cmd and found where my file I want to run is located. It is called 3.py and my teacher had told us just to write \"python 3.py\" to run it. I did this and it doesn't say that there is anything wrong, it just does nothing. Almost like there is nothing to be read in the file 3.py. But I open it just to make sure I'm not just trying to run an empty file. My file has something simple in it like print(\"Hello there, this program is working\") so I know it isn't not running because of an error in the code.\nI am using spider from anaconda to write my code into.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":59996419,"Users Score":0,"Answer":"I have found out how to do it now. You have to use Anaconda prompt rather than cmd.","Q_Score":0,"Tags":"python","A_Id":60008204,"CreationDate":"2020-01-31T00:23:00.000","Title":"How do I use the cmd to run a python program written in Spider","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I across a line of code : 'if type(x) == type(()):', I am not sure what this means.. It is comparing the type of 'x' to exactly what? Any answers are much appreciated,thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":55,"Q_Id":59996473,"Users Score":1,"Answer":"() is an empty tuple.\ntype(()) will give you the type tuple.\nIts checking to see if x is of type tuple.","Q_Score":1,"Tags":"python","A_Id":59996487,"CreationDate":"2020-01-31T00:31:00.000","Title":"What does 'if type(x) == type(()):' mean?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a new Macbook - a user installed it, and then I installed a new user (mine), granted admin privileges and deleted the old one. I am on OS Catalina.\nSince the installation I've been having several permission problems.\nVSCode can't find Jupyter Notebook, pip installs packages at ~\/Library\/Python\/3.7\/site-packages.\nWhen I do which python3 I get usr\/bin\/python3.\nWhen I do pip3 install <package> I get: Defaulting to user installation because normal site-packages is not writeable And then it says it has already been installed, even though I can't access it when I do import <package>.\nIt's seems clear that this is a permission problem, pip can't install to the \"base\" python, and them python can't find what I've installed into ~\/Library\/Python\/3.7\/site-packages.\nI've tried reinstalling the OS, but since I haven't done a clean install, it didn't change anything.\nWhat am I missing?\nHow exactly can I fix permissions? Where do I want packages to be installed (venv sure, but some packages I want global (like jupyter).","AnswerCount":13,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":233590,"Q_Id":59997065,"Users Score":21,"Answer":"It's best to not use the system-provided Python directly. Leave that one alone since the OS can change it in undesired ways, as you experienced.\nThe best practice is to configure your own Python version(s) and manage them on a per-project basis using virtualenv (for Python 2) or venv, possibly via poetry, (for Python 3). This eliminates all dependency on the system-provided Python version, and also isolates each project from other projects on the machine.\nEach project can have a different Python point version if needed, and gets its own site_packages directory so pip-installed libraries can also have different versions by project. This approach is a major problem-avoider.","Q_Score":81,"Tags":"python,pip","A_Id":60283625,"CreationDate":"2020-01-31T02:16:00.000","Title":"pip\/python: normal site-packages is not writeable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a new Macbook - a user installed it, and then I installed a new user (mine), granted admin privileges and deleted the old one. I am on OS Catalina.\nSince the installation I've been having several permission problems.\nVSCode can't find Jupyter Notebook, pip installs packages at ~\/Library\/Python\/3.7\/site-packages.\nWhen I do which python3 I get usr\/bin\/python3.\nWhen I do pip3 install <package> I get: Defaulting to user installation because normal site-packages is not writeable And then it says it has already been installed, even though I can't access it when I do import <package>.\nIt's seems clear that this is a permission problem, pip can't install to the \"base\" python, and them python can't find what I've installed into ~\/Library\/Python\/3.7\/site-packages.\nI've tried reinstalling the OS, but since I haven't done a clean install, it didn't change anything.\nWhat am I missing?\nHow exactly can I fix permissions? Where do I want packages to be installed (venv sure, but some packages I want global (like jupyter).","AnswerCount":13,"Available Count":8,"Score":0.0153834017,"is_accepted":false,"ViewCount":233590,"Q_Id":59997065,"Users Score":1,"Answer":"Had this same issue on a fresh install of Debian 9.12. \nRebooting my server solved the issue.","Q_Score":81,"Tags":"python,pip","A_Id":60152134,"CreationDate":"2020-01-31T02:16:00.000","Title":"pip\/python: normal site-packages is not writeable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a new Macbook - a user installed it, and then I installed a new user (mine), granted admin privileges and deleted the old one. I am on OS Catalina.\nSince the installation I've been having several permission problems.\nVSCode can't find Jupyter Notebook, pip installs packages at ~\/Library\/Python\/3.7\/site-packages.\nWhen I do which python3 I get usr\/bin\/python3.\nWhen I do pip3 install <package> I get: Defaulting to user installation because normal site-packages is not writeable And then it says it has already been installed, even though I can't access it when I do import <package>.\nIt's seems clear that this is a permission problem, pip can't install to the \"base\" python, and them python can't find what I've installed into ~\/Library\/Python\/3.7\/site-packages.\nI've tried reinstalling the OS, but since I haven't done a clean install, it didn't change anything.\nWhat am I missing?\nHow exactly can I fix permissions? Where do I want packages to be installed (venv sure, but some packages I want global (like jupyter).","AnswerCount":13,"Available Count":8,"Score":0.0307595242,"is_accepted":false,"ViewCount":233590,"Q_Id":59997065,"Users Score":2,"Answer":"It occurs with me when I the virtual enviroment folder name was : venv.\nin this case, It gives errors like :\nNo module pip\nDefault folder is unwritable\nrenaming the folder solve the proplem.","Q_Score":81,"Tags":"python,pip","A_Id":64319028,"CreationDate":"2020-01-31T02:16:00.000","Title":"pip\/python: normal site-packages is not writeable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a new Macbook - a user installed it, and then I installed a new user (mine), granted admin privileges and deleted the old one. I am on OS Catalina.\nSince the installation I've been having several permission problems.\nVSCode can't find Jupyter Notebook, pip installs packages at ~\/Library\/Python\/3.7\/site-packages.\nWhen I do which python3 I get usr\/bin\/python3.\nWhen I do pip3 install <package> I get: Defaulting to user installation because normal site-packages is not writeable And then it says it has already been installed, even though I can't access it when I do import <package>.\nIt's seems clear that this is a permission problem, pip can't install to the \"base\" python, and them python can't find what I've installed into ~\/Library\/Python\/3.7\/site-packages.\nI've tried reinstalling the OS, but since I haven't done a clean install, it didn't change anything.\nWhat am I missing?\nHow exactly can I fix permissions? Where do I want packages to be installed (venv sure, but some packages I want global (like jupyter).","AnswerCount":13,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":233590,"Q_Id":59997065,"Users Score":0,"Answer":"in my case python3 -m pip install [package_name] did not solve that.\nin my case, it was a problem related to other processes occupying the directory.\nI restart Pycharm and close any other program that might occupy this folder, and reinstalled the package in site-packages directory successfully.","Q_Score":81,"Tags":"python,pip","A_Id":65609657,"CreationDate":"2020-01-31T02:16:00.000","Title":"pip\/python: normal site-packages is not writeable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a new Macbook - a user installed it, and then I installed a new user (mine), granted admin privileges and deleted the old one. I am on OS Catalina.\nSince the installation I've been having several permission problems.\nVSCode can't find Jupyter Notebook, pip installs packages at ~\/Library\/Python\/3.7\/site-packages.\nWhen I do which python3 I get usr\/bin\/python3.\nWhen I do pip3 install <package> I get: Defaulting to user installation because normal site-packages is not writeable And then it says it has already been installed, even though I can't access it when I do import <package>.\nIt's seems clear that this is a permission problem, pip can't install to the \"base\" python, and them python can't find what I've installed into ~\/Library\/Python\/3.7\/site-packages.\nI've tried reinstalling the OS, but since I haven't done a clean install, it didn't change anything.\nWhat am I missing?\nHow exactly can I fix permissions? Where do I want packages to be installed (venv sure, but some packages I want global (like jupyter).","AnswerCount":13,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":233590,"Q_Id":59997065,"Users Score":0,"Answer":"When this problem occurred to me I have tried all the mentioned approaches but they don't seem to work.\nInstead, restarting Python language server in my VSCode did the job - my SimPy package is now found. On Mac it is Cmd+Shift+P and select \"Python: Restart Language Server\".","Q_Score":81,"Tags":"python,pip","A_Id":68265093,"CreationDate":"2020-01-31T02:16:00.000","Title":"pip\/python: normal site-packages is not writeable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a new Macbook - a user installed it, and then I installed a new user (mine), granted admin privileges and deleted the old one. I am on OS Catalina.\nSince the installation I've been having several permission problems.\nVSCode can't find Jupyter Notebook, pip installs packages at ~\/Library\/Python\/3.7\/site-packages.\nWhen I do which python3 I get usr\/bin\/python3.\nWhen I do pip3 install <package> I get: Defaulting to user installation because normal site-packages is not writeable And then it says it has already been installed, even though I can't access it when I do import <package>.\nIt's seems clear that this is a permission problem, pip can't install to the \"base\" python, and them python can't find what I've installed into ~\/Library\/Python\/3.7\/site-packages.\nI've tried reinstalling the OS, but since I haven't done a clean install, it didn't change anything.\nWhat am I missing?\nHow exactly can I fix permissions? Where do I want packages to be installed (venv sure, but some packages I want global (like jupyter).","AnswerCount":13,"Available Count":8,"Score":0.0614608973,"is_accepted":false,"ViewCount":233590,"Q_Id":59997065,"Users Score":4,"Answer":"sudo pip install\n\nWorked for me. But pip install is not recommended to be run with sudo. The issue I was facing on BIGSUR was, it was using system python. Once I Installed python 3.9 using\n\nbrew install python@3.9\n\nThen pip worked fine","Q_Score":81,"Tags":"python,pip","A_Id":68391177,"CreationDate":"2020-01-31T02:16:00.000","Title":"pip\/python: normal site-packages is not writeable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a new Macbook - a user installed it, and then I installed a new user (mine), granted admin privileges and deleted the old one. I am on OS Catalina.\nSince the installation I've been having several permission problems.\nVSCode can't find Jupyter Notebook, pip installs packages at ~\/Library\/Python\/3.7\/site-packages.\nWhen I do which python3 I get usr\/bin\/python3.\nWhen I do pip3 install <package> I get: Defaulting to user installation because normal site-packages is not writeable And then it says it has already been installed, even though I can't access it when I do import <package>.\nIt's seems clear that this is a permission problem, pip can't install to the \"base\" python, and them python can't find what I've installed into ~\/Library\/Python\/3.7\/site-packages.\nI've tried reinstalling the OS, but since I haven't done a clean install, it didn't change anything.\nWhat am I missing?\nHow exactly can I fix permissions? Where do I want packages to be installed (venv sure, but some packages I want global (like jupyter).","AnswerCount":13,"Available Count":8,"Score":0.0153834017,"is_accepted":false,"ViewCount":233590,"Q_Id":59997065,"Users Score":1,"Answer":"In my case on Linux, the ownership of the conda env directory had changed to another Linux user (long story), and so the the normal site-packages was not writeable due to a permissions issue.\nThe solution was to change ownership back to the user doing pip install.","Q_Score":81,"Tags":"python,pip","A_Id":70248657,"CreationDate":"2020-01-31T02:16:00.000","Title":"pip\/python: normal site-packages is not writeable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a new Macbook - a user installed it, and then I installed a new user (mine), granted admin privileges and deleted the old one. I am on OS Catalina.\nSince the installation I've been having several permission problems.\nVSCode can't find Jupyter Notebook, pip installs packages at ~\/Library\/Python\/3.7\/site-packages.\nWhen I do which python3 I get usr\/bin\/python3.\nWhen I do pip3 install <package> I get: Defaulting to user installation because normal site-packages is not writeable And then it says it has already been installed, even though I can't access it when I do import <package>.\nIt's seems clear that this is a permission problem, pip can't install to the \"base\" python, and them python can't find what I've installed into ~\/Library\/Python\/3.7\/site-packages.\nI've tried reinstalling the OS, but since I haven't done a clean install, it didn't change anything.\nWhat am I missing?\nHow exactly can I fix permissions? Where do I want packages to be installed (venv sure, but some packages I want global (like jupyter).","AnswerCount":13,"Available Count":8,"Score":0.0153834017,"is_accepted":false,"ViewCount":233590,"Q_Id":59997065,"Users Score":1,"Answer":"I met exactly the same issue.\nI just type sudo python3.8 -m pip install .... and the error disappeared.\nIf I remove the sudo, issue remains.","Q_Score":81,"Tags":"python,pip","A_Id":71003733,"CreationDate":"2020-01-31T02:16:00.000","Title":"pip\/python: normal site-packages is not writeable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to help someone put a python text game to be displayed with the inputs and output on his html website. What's the easiest way to do this, regarding the many outputs and inputs? Would it be to make it a flask app? I don't really know how else to describe the situation. Answers would be much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":59997131,"Users Score":0,"Answer":"I am developing a website with python3.8 and Sanic. It was pretty to use async, await and := ~","Q_Score":1,"Tags":"python,html","A_Id":59997280,"CreationDate":"2020-01-31T02:27:00.000","Title":"Easiest way to put python text game in html?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to learn python for a class. we're using jupyter notebooks where the import torch command works fine but using spyder I keep getting this error and I have no idea how to fix it. I'm a complete newbie at this and I really don't know what to do.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3670,"Q_Id":59998286,"Users Score":0,"Answer":"Open Spyder terminal and try running conda install torch if using Anaconda, or pip install torch otherwise.","Q_Score":0,"Tags":"python,jupyter,spyder","A_Id":59998318,"CreationDate":"2020-01-31T05:19:00.000","Title":"Error: ModuleNotFoundError: No module named 'torch' in spyder, works fine in jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a PDF File with about 500 pages with a lot of duplicates.\nBefore I made PNG Thumbnails, then I made MD5-hashs to compare everything. That worked fine.\nNow I don't use png thumbnails anymore but tif-files because I have to use \"tiffsep\" to remove some spotcolors.\nIf I compare the hashes of the tif-files or even the hashes of the png-files I made from the tif-files its completly different, even if it visually is the same.\nI tried to remove the datetimefield and the paging-information from the tiff-metadata but it is still the same.\nWhat can I do?\nThats the code how the thumbnails are generated\n    inputpdf = PdfFileReader(path)\n    count_pages = inputpdf.getNumPages()\n    command = \"gs -sDEVICE=tiffsep -dNoSeparationFiles -dLastPage=\"+str(count_pages)+\" -sOutputFile=\"\/home....\/page_%d.tif\"\n    subprocess.Popen(command,shell=True,stdin....)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":60000785,"Users Score":0,"Answer":"Did solve the problem.\nFirst I made the Tiff-Files to exclude the spotcolors.\nThen I had to convert to JPG and then build the hashes.\nThe hashes of the PNG from the Tiffs weren't the same.","Q_Score":0,"Tags":"python,hash,thumbnails","A_Id":60144366,"CreationDate":"2020-01-31T09:06:00.000","Title":"Compare Tif File Made from PDF pages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to know if it's possible to 'Activate' and 'Deactivate' the admin site using a custom management command and what i mean by deactivating is commenting the line containing the path of admin.site.urls in the main urls.py file.\nOr if there is a better way to do this.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":128,"Q_Id":60005680,"Users Score":0,"Answer":"I think the best way to do it - write custom middleware.\nYou can detect if current request is request to admin site (for example request.path.startswith('\/admin')) and return 404 error if you disable you admin page.","Q_Score":0,"Tags":"django,python-3.x,django-admin","A_Id":60006268,"CreationDate":"2020-01-31T14:20:00.000","Title":"Django Management command for Activating\/Deactivating admin site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm new to Pandas and Dask, Dask dataframes wrap pandas dataframes and share most of the same function calls.\nI using Dask to sort(set_index) a largeish csv file ~1,000,000 rows ~100columns.\nOnce it's sorted I use itertuples() to grab each dataframe row, to compare with a row from a database with ~1,000,000 rows ~100 columns. \nBut it's running slowly (takes around 8 hours), is there a faster way to do this? \nI used dask because it can sort very large csv files and has a flexible csv parsing engine. It'll also let me run more advanced operations on the dataset, and parse more data formats in the future\nI could presort the csv but I want to see if Dask can be fast enough for my use case, it would make things alot more hands off in the long run.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":412,"Q_Id":60007843,"Users Score":1,"Answer":"By using iter_tuples, you are bringing each row back to the client, one by one. Please read up on map_partitions or map to see how you can apply function to rows or blocks of the dataframe without pulling data to the client. \nNote that each worker should write to a different file, since they operate in parallel.","Q_Score":0,"Tags":"python-3.x,pandas,dask","A_Id":60028390,"CreationDate":"2020-01-31T16:34:00.000","Title":"Whats the fastest way to loop through sorted dask dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried installing numpy using the command 'pip install numpy' and ran 'import numpy' but I received the error ModuleNotFoundError: No module named 'numpy' when I tried to re-run the code. After reading similar questions on SO, I ran pip3 install numpy, but since i already installed it, I received the message Requirement already satisfied.\nNOTE: I have read other similar questions on SO, but none of them solve my problem.\n\nPossible solution for future readers:\nLike @Sampath mentioned in his answer, I had two versions of python installed. To solve the issue, I manually deleted all the installation files of the older version.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1294,"Q_Id":60012193,"Users Score":1,"Answer":"Welcome to SO!\n\nIt is likely that there are 2 python versions(Python2.X and Python3.X) are installed in your system.\npip is likely pointing to your Python2.X and so if you want to used libraries installed in this version ===> use python to run\npip3 is pointing to your Python3.X, so use Python3 in your terminal to use this.\n\nNote:\n\nTo know installed libraries in your python2 use pip freeze or pip3 freeze for Python3\nIn case, if you are getting error for Python3 as not then this is like to be system path issues.\n\nIf you are still having trouble, you learn more about Anaconda-Python which has a curated list of steps and guidelines that are easy for beginners too. Hope this helps!","Q_Score":1,"Tags":"python,numpy,pip","A_Id":60019415,"CreationDate":"2020-01-31T22:37:00.000","Title":"ModuleNotFoundError: No module named 'numpy' after using 'pip install numpy'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am on OS Mojave and just used homebrew to install geos and proj and python3 disappeared. I had two versions and now I only have the 2.7 version. I did brew install python3 and it says its already installed but not linked, I then did brew link python as it suggested but it returned an Error: Could not symlink Frameworks\/Python.framework\/Headers Target \/usr\/local\/Frameworks\/Python.framework\/Headers is a symlink belonging to python@2.. \nHow can I go back to having both versions?. I am not 100% installing geos and proj was what caused it but I used python3 3 days ago.  I have also installed phantomjs via homebrew since the last time I used python3.\nI need to have both versions of python installed. What would be the appropriate way of handling this since I seem to have all the files still on my computer?\nThanks in advance!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1488,"Q_Id":60014044,"Users Score":0,"Answer":"Install Virtual Environment so you can use many and different versions of Python.","Q_Score":1,"Tags":"python,homebrew","A_Id":60014116,"CreationDate":"2020-02-01T04:39:00.000","Title":"Python 3 disappeared from computer - MacOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am on OS Mojave and just used homebrew to install geos and proj and python3 disappeared. I had two versions and now I only have the 2.7 version. I did brew install python3 and it says its already installed but not linked, I then did brew link python as it suggested but it returned an Error: Could not symlink Frameworks\/Python.framework\/Headers Target \/usr\/local\/Frameworks\/Python.framework\/Headers is a symlink belonging to python@2.. \nHow can I go back to having both versions?. I am not 100% installing geos and proj was what caused it but I used python3 3 days ago.  I have also installed phantomjs via homebrew since the last time I used python3.\nI need to have both versions of python installed. What would be the appropriate way of handling this since I seem to have all the files still on my computer?\nThanks in advance!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1488,"Q_Id":60014044,"Users Score":1,"Answer":"use anaconda python distribution which better for python.","Q_Score":1,"Tags":"python,homebrew","A_Id":60014185,"CreationDate":"2020-02-01T04:39:00.000","Title":"Python 3 disappeared from computer - MacOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I wrote a web scraping programming a couple of months ago, which I had python -m venv venv did a bunch of pip install, checked and doubled check with pip list, everything looks fine.\nAnd today I wanna scrape again so I did my source venv\/bin\/activate checked with pip list, everything looks fine, and just keep having no module of this and that...\nBut when I deactivated it, it falls back to my global installed modules, my program runs perfectly fine. I could't believe it so i did :\nrm -rf venv and\npython -m venv  source venv\/bin\/activate pip install -r requirements.txt\neverything installed, check with pip list, and no module of this or that.\nAnyone, please tell me what's happening?\nthank you!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":148,"Q_Id":60015290,"Users Score":1,"Answer":"To ensure what python is being used and which python is linked to current pip:\n\nwhich python to see where is the python executable (alternatively which python3, which python3.7, etc...)\nrunning python show the version of python\npip -V shows the python to which it is linked\nuse python -m pip list to ensure the pip is linked to the python\npython -m site shows were is the site-package located\nwriting python and hitting TAB multiple times shows what pythons are available in the path (os dependent)\n\nThis is more of a way to debug which python is being used.","Q_Score":2,"Tags":"python,virtualenv,python-venv,python-3.8","A_Id":66209449,"CreationDate":"2020-02-01T08:39:00.000","Title":"frustrations over python venv and global modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have a virtualenv called alpha but after upgrading my ubuntu 18 to ubuntu 19, now i cant install any python package into my virtualenv, basically i cant use pip3 command. whenever i use pip3 command i got this error: ImportError: cannot import name 'dist' (i have tried: sudo apt install python3-dist-utils but its not working). Now because i cant use pip3 command i cant create requirements.txt file. i want to remove my old alpha virtualenv and want to install new one and install all the dependencies using requirements.txt file, but i can't do that because i can't create requirements.txt. How do i solve this problem ?\nEdit\nBecause i have so many libraries installed in my virtualenv(i cant even remember them). first i want to recover all the dependency information's and then want to install new one. I CANT JUST REMOVE THE VIRTUALENV FIRST.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":639,"Q_Id":60017983,"Users Score":0,"Answer":"There's no package like dist-utils, you are looking for python3-dist-utils.","Q_Score":0,"Tags":"python-3.x,virtualenv,requirements.txt","A_Id":60018012,"CreationDate":"2020-02-01T14:50:00.000","Title":"can not create requirements.txt file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know you can disable both warnings and error flags from Tools > Preferences > Completion and linting > disable basic linting but is it possible to disable only the warnings?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":60018449,"Users Score":0,"Answer":"(Spyder maintainer here) Sorry, that's not possible.","Q_Score":0,"Tags":"python,spyder","A_Id":60021170,"CreationDate":"2020-02-01T15:42:00.000","Title":"Can you disable warnings in Spyder 4.0?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to push a python app to Heroku using the command:  \"git push heroku master\" I get the error, \"No matching distribution found for cloud-init==19.3.\"  I tried a suggestion I found on here that said to remove that item from the registration.txt file, run commit and then push again, and keep doing this with the registration.txt list until getting a successful result. However, I continue to get this error regarding the cloud-init version and can't get beyond it.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":171,"Q_Id":60019341,"Users Score":1,"Answer":"I found the solution for this issue. I emptied the requirements.txt file to only two items, flask & gunicorn. Then realized that while I ran commit & push again after the changes I wasn't running add.","Q_Score":0,"Tags":"python,git,heroku","A_Id":60027175,"CreationDate":"2020-02-01T17:24:00.000","Title":"Get error when attempting to push app to Heroku","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I made a gui programm with Tkinter. In the program are several buttons which open new main tkinter windows but when i click on the 'x' of one of these windows all the other ones close too although they are different windows. Only the Buttons, which cause the new tkinter main windows, are in the same main window.\nplease help :))","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":60019993,"Users Score":0,"Answer":"This is how tkinter is designed to work. When you destroy a window, all of its children are destroyed. Since everything is a child of the root window or one of its children, when you destroy the root window all other widgets are destroyed along with it.","Q_Score":0,"Tags":"python,tkinter","A_Id":60020316,"CreationDate":"2020-02-01T18:36:00.000","Title":"Python tkinter main window closes all other windows too, why?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a complete beginner and a relative of mine asked me to build a simple 'contact us' website for them. It should include some information about his company and a form in which people that visit the website are able to send mails to my relative. I have been playing around with vue.js in order to build the frontend. I now want to know how to put the form to send mails and I read it has to be done with backend, so I thought I could use django as I have played with it in the past and I am confident using python. Is it too much for the work that I have to do? Should I use something simpler? I accept any suggestions please, Thanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":60021283,"Users Score":0,"Answer":"Flask\nYou can use Flask. it is simpler than Django and easy to learn. you can build a simple website like the one you want in less than 50 line.\n\nWordpress\nIf you want you can use Wordpress. it's easy to install and many hosting services support it already. Wordpress has so many plugins and templates to build contact us website in 10 minutes.\n\nWix\nwix is easy, drag-n-drop website builder with many pre-build templates that you can use, check them out and you will find what you need.","Q_Score":1,"Tags":"python,django,vue.js,web","A_Id":60021443,"CreationDate":"2020-02-01T21:35:00.000","Title":"is django overkill for a contact us website?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm a complete beginner and a relative of mine asked me to build a simple 'contact us' website for them. It should include some information about his company and a form in which people that visit the website are able to send mails to my relative. I have been playing around with vue.js in order to build the frontend. I now want to know how to put the form to send mails and I read it has to be done with backend, so I thought I could use django as I have played with it in the past and I am confident using python. Is it too much for the work that I have to do? Should I use something simpler? I accept any suggestions please, Thanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":60021283,"Users Score":0,"Answer":"You will probably should use something ready like Wix or Wordpress if want to do it fast if you prefer to learn in the process you can do it with Django and Vue, but this is indeed little bit overkill","Q_Score":1,"Tags":"python,django,vue.js,web","A_Id":60021392,"CreationDate":"2020-02-01T21:35:00.000","Title":"is django overkill for a contact us website?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm currently trying to implement a neural network in Python to play the game of Snake that is trained using a genetic algorithm (although that's a separate matter right now).\nEvery network that plays the game does the same movement over and over (e.g. continues in a straight line, keeps turning left). There are 5 inputs to the network: the distance to an object (food, a boundary, its own tail) in all four directions, and the angle between the food and the direction the snake is facing. The three outputs represent turning left, continuing straight, and turning right.\nI've never worked with anything like this before so I have a fairly basic understanding at this point. The number of hidden layers and the number of nodes per layer is variable, and is something I have been altering a lot to test, but the snakes continue to each repeat the exact same motion.\nAny advice on why this is happening would be greatly appreciated, and how to fix it. I can show my code if it's useful.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":60022144,"Users Score":0,"Answer":"You may have weights initialized to zero and if they aren't trained properly and stay zero for some reason, neural network will be producing bias as an output always.","Q_Score":0,"Tags":"python,machine-learning,neural-network","A_Id":60022224,"CreationDate":"2020-02-01T23:55:00.000","Title":"Neural network produing same output regardless of input","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently rendering an simple HTML table using Flask\/Pandas Dataframe (to_html) using rows from a table in an SQLite3 DB. \nHow do I add checkboxes to the table?\nAfter selections are made dump all the values from the Name column to a text file?\nExample:\n\nID  Name    Manager \n1   server1 manager1\n2   server2 manager2\n\nAny help would be appreciated.\nP.S. This is my first question on Stack overflow. If you need more information please let me know.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":451,"Q_Id":60023407,"Users Score":0,"Answer":"I would do it by workaround here.\n\nCreate html combo box in template.html\nPopulate combobox with values from database in routes.py\nAlso in routes.py read combobox selected value and according to that value change sql request to database - e.g. value 1 - sql query without where condition else add where condition name = (in) selected value(s)\nWhen you send request you can in routes.py choose if you want render_template with different data or if you submit to another route which will export you data to text file (you can stay in pandas and use to_csv)\n\nAlso your question contain multiple problems. It would be better to be more specific.\nIf you would like only to add checkboxes as another column in table then you can, do the filtering by javascript but to pass the selection to flask route by javascript is another much harder thing. Also I would do selection on distinct values rather than all rows values.","Q_Score":5,"Tags":"python,html,pandas,sqlite,flask","A_Id":72276049,"CreationDate":"2020-02-02T05:11:00.000","Title":"How to add checkboxes to a Pandas Dataframe table using Flask?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it in memory?\nIf so, then it doesn't matter if I import chunk by chunk or not because eventually, when I concatenate them, they'll all be stored in memory. \nDoes that mean for a large data set, there is no way to use pandas?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":114,"Q_Id":60023966,"Users Score":1,"Answer":"Yes it is in memory, and yes when the dataset gets too large you have to use other tools.\nOf course you can load data in chucks, process one chunk at a time and write down the results (and so free memory for the next chunk).\nThat works fine for some type of process like filtering and annotating while if you need sorting or grouping you need to use some other tool, personally I like bigquery from google cloud.","Q_Score":1,"Tags":"python,pandas","A_Id":60024009,"CreationDate":"2020-02-02T07:08:00.000","Title":"Where does pandas store the DataFrame while the program is running?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to make a PyTorch model that takes the outer product of the input with itself and then does a linear regression on that. As an example, consider the input vector [1,2,3], then I would like to compute w and b to optimize [1*1, 1*2, 1*3, 2*1, 2*2, 2*3, 3*1, 3*2, 3*3] @ w + b.\nFor a batch input with r rows and c columns, I can do this in PyTorch with\n(input.reshape(r,c,1) @ input.reshape(r,1,c)).reshape(r,c**2) @ weigts + b\nMy problem is that it is extraordinarily slow. Like a factor 1000 times slower and more memory consumptious than Adding a fully connected c*c RELU layer, even though it has the same number of weights.\nMy question is why this happens?\nIs reshape a very expensive operation for PyTorch? Could I reformulate it in a different way that would make things more efficient?\nAnother equivalent formulation I know is torch.diag(input @ weights @ input.T) + b, but now we are computing way more values than we need (r*r) just to throw them away again.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":233,"Q_Id":60025695,"Users Score":1,"Answer":"It turns out that PyTorch has torch.bilinear, which is backed up by CUDA and does exactly what I need. That's neat and very fast. It still leaves the case of higher-order tensorings. I don't see any torch.trilinear and so forth, but for now it's great.","Q_Score":1,"Tags":"python,neural-network,pytorch,linear-algebra,tensor","A_Id":60031030,"CreationDate":"2020-02-02T11:37:00.000","Title":"Computing Linear Layer in Tensor\/Outer-Product space in PyTorch is Very Slow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run my python3 code through the kivy launcher on my android device but it crashes on launch, pointing towards the requests module in the error log. Is there any way to get the requests module to work on my android device? \nAs a side note, I am not using buildozer for this as I do not have a Linux machine, its strictly through the kivy launcher.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":474,"Q_Id":60026650,"Users Score":0,"Answer":"@Mark.97\nCopy the modules required into the \"kivy\" folder on the mobile.\nI was able to run the application successfully with kivy launcher after copying the following modules.\n- requests\n- idna\n- certifi\n- chardet\n- urllib3","Q_Score":0,"Tags":"python,android,kivy","A_Id":62085035,"CreationDate":"2020-02-02T13:39:00.000","Title":"ImportError: No module named requests on android kivy launcher","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new in Django, recently I have created several project directories under several virtual-environments. Now I have reopened my recent project directory, but forgot which virtual environment I was using for this project. How to find it out?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":60030114,"Users Score":0,"Answer":"Provided that you have requirements.txt files for your Django projects (which you really should), it should be as easy as comparing the output of pip freeze under your virtual environments with the contents of your requirements files.","Q_Score":0,"Tags":"python,django,virtualenv","A_Id":60030133,"CreationDate":"2020-02-02T20:08:00.000","Title":"How to know my current Django project was created under which virtual environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"new user of mitmproxy here. I've figured out how to edit a request and replay it, and I'm wondering how to undo my edit.\nMore specifically, I go to a request's flow, hit 'e', then '8' to edit the request headers. Then I press 'd' to delete one of the headers. What do I press to undo this change? 'u' doesn't work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":60031716,"Users Score":0,"Answer":"It's possible to revoke changes to a flow, but not while editing. In your case, 'e' -> '8' -> 'd' headers, now press 'q' to go back to the flow -> press 'V' to revoke changes to the flow.","Q_Score":0,"Tags":"python,mitmproxy","A_Id":60541411,"CreationDate":"2020-02-02T23:55:00.000","Title":"mitmproxy: shortcut for undoing edit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For my first project in reinforcement learning I'm trying to train an agent to play a real time game. This means that the environment constantly moves and makes changes, so the agent needs to be precise about its timing. In order to have a correct sequence, I figured the agent will have to work in certain frequency. By that I mean if the agent has 10Hz frequency, it will have to take inputs every 0.1 secs and make a decision. However, I couldn't find any sources on this problem\/matter, but it's probably due to not using correct terminology on my searches. Is this a valid way to approach this matter? If so, what can I use? I'm working with python3 in windows (the game is only ran in windows), are there any libraries that could be used? I'm guessing time.sleep() is not a viable way out, since it isn't very precise (when using high frequencies) and since it just freezes the agent.\nEDIT: So my main questions are:\na) Should I use a certain frequency, is this a normal way to operate a reinforcement learning agent? \nb) If so what libraries do you suggest?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":268,"Q_Id":60031847,"Users Score":2,"Answer":"There isn't a clear answer to this question, as it is influenced by a variety of factors, such as inference time for your model, maximum accepted control rate by the environment and required control rate to solve the environment.\nAs you are trying to play a game, I am assuming that your eventual goal might be to compare the performance of the agent with the performance of a human.\nIf so, a good approach would be to select a control rate that is similar to what humans might use in the same game, which is most likely lower than 10 Hertz.\nYou could try to measure how many actions you use when playing to get a good estimate, \nHowever, any reasonable frequency, such as the 10Hz you suggested, should be a good starting point to begin working on your agent.","Q_Score":0,"Tags":"python,python-3.x,time,reinforcement-learning","A_Id":60036570,"CreationDate":"2020-02-03T00:21:00.000","Title":"Time step in reinforcement learning","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a problem that I can not use cv2.imshow() because of following error message\n\nqt.qpa.plugin: Could not find the Qt platform plugin \"cocoa\" in \"\"\nThis application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.\n\nLast Macbook I was using initially did not have QT so I have no idea how should I deal with it.\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8481,"Q_Id":60032540,"Users Score":43,"Answer":"I had the same issue after updating opencv - python to 4.2.0.32.\nUninstall opencv-python and install the lower version (e.g pip install opencv-python==4.1.0.25) solves this issue.","Q_Score":10,"Tags":"python,python-3.x,qt,opencv","A_Id":60032783,"CreationDate":"2020-02-03T02:50:00.000","Title":"OpenCV cv2.imshow is not working because of the qt","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Postgres\nI have USE_TZ=True\nI have TIME_ZONE='America\/Los Angeles'\nI am about to switch TIME_ZONE to UTC.\n\nWill there be negative effects, gotchas, or anything I need to consider? Or will it just work since the date time is standardized? (I notice in my db rows that dates are stored with +08, which is indeed America\/Los Angeles.)\nThe documentation mentions that if I use Postgres, I can swap USE_TZ freely, but doesn't mention changing TIME_ZONE.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":60033438,"Users Score":0,"Answer":"Django always stores date time in UTC and now() always returns time in UTC or according to db.\nso if you convert it using localtime() it will not affect how the value is stored.\nThe thing which matters is how it is presented to user.","Q_Score":0,"Tags":"python,django,time","A_Id":60033519,"CreationDate":"2020-02-03T05:16:00.000","Title":"Does changing Django's TIME_ZONE have any negative effects?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been using Connect To DataBase Keyword in Robot Framework. Is it possible to add a custom parameter to the keyword?\nFor ex : i want to add dictionary=true to cursor instance below is the keyword that i have used -\n\nEMPDB.Connect To Database    pymysql  ${EMPNAME}  ${EMPUSER}   ${PWD}   ${HOST}   ${PORT}\n\nTo Above Keyword statement can i use dictionary=true? So that when i select query the result i want is along with the column and the values.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":100,"Q_Id":60034232,"Users Score":2,"Answer":"That's is not possible using the library as is, so you need to implement that feature yourself. Usually DB queries return lists and they do not include column names.","Q_Score":0,"Tags":"python,robotframework","A_Id":60034844,"CreationDate":"2020-02-03T06:40:00.000","Title":"How to pass a custom parameter to Connect To DataBase Keyword in Robot Framework","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a multi-sheet excel file saved in a .xlsb format that I wish to covert to .xlsx to utilize the openpyxl library - code already written to support the same workbook that used to be .xlsx until macro-enabled, and wouldn't save in .xlsm.\nI have managed to convert from .xlsb to .csv, but cannot convert any further and have hit roadblocks with various libraries due to various formatting errors.\nAs my file has multiple sheets (all tables) I only need to copy and paste the text on every sheet (keeping the sheet names) and get it to a .xlsx format.\nFor simplicity sake, imagine all I need to do is: get sheet names, access a sheet, determine max row\/column, loop: copy and paste cell values, write to .xlsx with sheet name. With the starting file being .xlsb.\nAny suggestion would be much appreciated.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10994,"Q_Id":60036199,"Users Score":0,"Answer":"I got copy code to test run,but that return error,above error .\nValueError                                Traceback (most recent call last)\n in ()\n----> 1 df = pd.read_excel(r'C:\\Users\\l84193928\\Desktop\\test.xlsb', engine='pyxlsb')\nD:\\Users\\l84193928\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\pandas\\util_decorators.py in wrapper(*args, **kwargs)\n176                 else:\n177                     kwargs[new_arg_name] = new_arg_value\n--> 178             return func(*args, **kwargs)\n179         return wrapper\n180     return _deprecate_kwarg\nD:\\Users\\l84193928\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\pandas\\util_decorators.py in wrapper(*args, **kwargs)\n176                 else:\n177                     kwargs[new_arg_name] = new_arg_value\n--> 178             return func(*args, **kwargs)\n179         return wrapper\n180     return _deprecate_kwarg\nD:\\Users\\l84193928\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\pandas\\io\\excel.py in read_excel(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, parse_dates, date_parser, thousands, comment, skipfooter, convert_float, **kwds)\n305\n306     if not isinstance(io, ExcelFile):\n--> 307         io = ExcelFile(io, engine=engine)\n308\n309     return io.parse(\nD:\\Users\\l84193928\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\pandas\\io\\excel.py in init(self, io, **kwds)\n367\n368         if engine is not None and engine != 'xlrd':\n--> 369             raise ValueError(\"Unknown engine: {engine}\".format(engine=engine))\n370\n371         # If io is a url, want to keep the data as bytes so can't pass\nValueError: Unknown engine: pyxlsb","Q_Score":2,"Tags":"python","A_Id":69023706,"CreationDate":"2020-02-03T09:18:00.000","Title":"Convert .xlsb to .xlsx - Multi-sheet Microsoft Excel File","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Anaconda3 and PyCharm.\nWhen I go in PyCharm to File - Settings - Project Interpreter I see that Python 3.6 is used and its path goes to Anaconda.\nBut when I go this path (C:\\ProgramData\\Anaconda3) and start python.exe I see Python is 3.7.3 version.\nWhy the Python versions are different when there is the same Python?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":173,"Q_Id":60037540,"Users Score":2,"Answer":"This is because what you see in PyCharm is just a name, that usually originates from the python executable. If you change the executable (python path), the name is not updated. You can edit it with the pencil icon. The same goes for the virtualenv between brackets.\nHope this helps!","Q_Score":0,"Tags":"python,pycharm,anaconda","A_Id":60037720,"CreationDate":"2020-02-03T10:40:00.000","Title":"Different Python versions from PyCharm and python.exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This problem has been reported earlier but I couldn't find the exact solution for it. I installed ActiveTCL and downloaded tktable.py by  \"Guilherme Polo <ggpolo@gmail.com>\" to my site-packages, also added Tktable.dll, pkgindex.tcl, and tktable.tcl from ActiveTCL\\lib\\Tktable2.11 to my python38-32\\tcl and dlls . I also tried setting the env variable for TCL_LIBRARY and TK_LIBRARY to tcl8.6 and tk8.6 respectively. But I am still getting invalid command name \"table\".\nWhat is that I am missing? Those who made tktable work on windows 10 and python 3 , how did you do it? I am out of ideas and would be grateful for some tips on it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":60038092,"Users Score":0,"Answer":"Seems like there was problem running the Tktable dlls in python38-32 bit version. It worked in 64 bit version. \nThanks @Donal Fellows for your input.","Q_Score":0,"Tags":"python-3.x,tkinter,tcl,python-module,tktable","A_Id":60208713,"CreationDate":"2020-02-03T11:14:00.000","Title":"Tktable module installation problem. _tkinter.TclError: invalid command name \"table\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently , successfully, importing stock information from Yahoo using pandas-datareader. However, before the extracted data, I always get the following message: \n\nFutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.\n\nWould anyone have an idea of what it means and how to fix it?","AnswerCount":6,"Available Count":3,"Score":-0.0665680765,"is_accepted":false,"ViewCount":7121,"Q_Id":60039161,"Users Score":-2,"Answer":"For mac OS open \/Library\/Frameworks\/Python.framework\/Versions\/3.8\/lib\/python3.8\/site-packages\/pandas_datareader\/compat\/__init__.py\nchange: from pandas.util.testing import assert_frame_equal\nto: from pandas.testing import assert_frame_equal","Q_Score":2,"Tags":"python,pandas-datareader","A_Id":61034041,"CreationDate":"2020-02-03T12:22:00.000","Title":"Getting a \"Future Warning\" when importing for Yahoo with Pandas-Datareader","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently , successfully, importing stock information from Yahoo using pandas-datareader. However, before the extracted data, I always get the following message: \n\nFutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.\n\nWould anyone have an idea of what it means and how to fix it?","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":7121,"Q_Id":60039161,"Users Score":0,"Answer":"Cause: The cause of this warning is that, basically, the pandas_datareader is importing a module from the pandas library that will be deprecated. Specifically, it is importing pandas.util.testing whereas the new preferred module will be pandas.testing.\nSolution: First off this is a warning, and not an outright error, so it won't necessarily break your program. So depending on your exact use case, you may be able to ignore it for now.\nThat being said, there are a few options you can consider:\n\nOption 1: Change the code yourself -- Go into the pandas_datareader module and modify the line of code in compat_init.py that currently says from pandas.util.testing import assert_frame_equal simply to from pandas.testing import assert_frame_equal. This will import the same function from the correct module.\nOption 2: Wait for pandas-datareader to update --You can also wait for the library to be upgraded to import correctly and then run pip3 install --upgrade pandas-datareader. You can go to the Github repo for pandas-datareader and raise an issue.\nOption 3: Ignore it -- Just ignore the warning for now since it doesn't break your program.","Q_Score":2,"Tags":"python,pandas-datareader","A_Id":62805935,"CreationDate":"2020-02-03T12:22:00.000","Title":"Getting a \"Future Warning\" when importing for Yahoo with Pandas-Datareader","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently , successfully, importing stock information from Yahoo using pandas-datareader. However, before the extracted data, I always get the following message: \n\nFutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.\n\nWould anyone have an idea of what it means and how to fix it?","AnswerCount":6,"Available Count":3,"Score":-0.0333209931,"is_accepted":false,"ViewCount":7121,"Q_Id":60039161,"Users Score":-1,"Answer":"You may find the 'util.testing' code in pandas_datareader, which is separate from pandas.","Q_Score":2,"Tags":"python,pandas-datareader","A_Id":60122268,"CreationDate":"2020-02-03T12:22:00.000","Title":"Getting a \"Future Warning\" when importing for Yahoo with Pandas-Datareader","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In VSCode, I have the hovers enabled that show me the docstrings of the functions (etc.) I use. I appreciate that functionality. However, some of the hovers get annoying with time. First and foremost, the one for print. I never need it, and it is huge. It is particularly annoying in Jupyter notebooks, where I use print quite often.\nHence, my question: Is there a way to disable the hover for certain functions specifically?\nI have looked through the VSCode documentation but haven't found anything.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":330,"Q_Id":60039310,"Users Score":2,"Answer":"No, there is no way to turn off hovers on select items.","Q_Score":1,"Tags":"python,visual-studio-code,jupyter-notebook,vscode-settings","A_Id":60067485,"CreationDate":"2020-02-03T12:31:00.000","Title":"Is there a way to turn off hover for certain functions in VSCode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm training Yolov3 on my dataset. I'm training it on different resolutions of the image, trying to find the best speed\/quality ratio. I started wondering if I can compare the loss function of Yolo between different resolutions. Anchor sizes are proportional to resolution. \nSo does same loss on different resolutions mean I'd get approximately the same results on my test dataset?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":435,"Q_Id":60041695,"Users Score":0,"Answer":"In general input size changes the size of the final grid and so the number of predicted boxes. Depending on the implementation you use this can change the loss. If e.g. the loss values for one parameter are all summed up, more boxes would mean higher loss. If loss values are averaged over all boxes you can probably compare it.\nYou might wanna use some other form of evaluation besides just the loss. Depending on the task have a look at benchmarks and the metrics they are using. For object detection the IoU is often used to assign predictions to ground truth and calculate a precision out of it.","Q_Score":0,"Tags":"python,keras,deep-learning,conv-neural-network,yolo","A_Id":60046061,"CreationDate":"2020-02-03T14:53:00.000","Title":"How does Yolov3 loss function change with resolution of the image?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a developed segment of code that links back up to an existing website to cross ref multiple images - the issue I am encountering seems simple enough but now I feel that I went down a rabbit hole.\nI should be able to run this code on my Mac but get the error: \n\nurlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify\n  failed: unable to get local issuer certificate (_ssl.c:1076)\n\nOkay simple - I went to applications and tried to run the Install Certificates.command but then get the error: \n\nERROR: Could not install packages due to an EnvironmentError: [Errno\n  13] Permission denied:\n  '\/Library\/Frameworks\/Python.framework\/Versions\/3.8\/lib\/python3.8\/site-packages\/certifi'\n  Consider using the --user option or check the permissions.\n\nFor both Python 3.7 & 3.8\nOkay - I then tried pip(pip, pip3, pip3.7, & pip3.8) install on Certi and Certificates which all worked.\nBut I still get the error when running my code stating that my certification verification failed. I then did the something again this time with --user and still the same result.\nAm I missing something to this - I feel very foolish trying to get this to work when it should be pretty simple.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1323,"Q_Id":60042050,"Users Score":0,"Answer":"after taking some time away I went with sudo - and that was the correct move - should mention I was on work comp hence the issue - used admin rights and got cert verification.","Q_Score":0,"Tags":"python,python-3.x,macos,openssl,ssl-certificate","A_Id":60042360,"CreationDate":"2020-02-03T15:14:00.000","Title":"Python certification error - Certificate.command install not working\/ permission denied?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have unsigned 16-bit grayscale tiff images as numpy arrays. I want to do some image processing on these images using OpenCV. I am converting the numpy array to Mat format using cv2.cvtColor(src, code). As far as the documentation goes, I am having a hard time finding the right code argument to correctly convert 16-bit grayscale images without losing any information.\nPreviously, I read the images directly using cv2.imread(src, cv2.IMREAD_UNCHANGED). However, I don't have the original image files now, only the pickled numpy array. I am looking for the code in cvtColor which does a similar thing as cv2.IMREAD_UNCHANGED","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":318,"Q_Id":60044041,"Users Score":1,"Answer":"Your question is tough to follow. All you appear to have are some files containing pickled Numpy arrays, correct?\nIf so, you don't need any imread(), you just need to unpickle the files and you will have Numpy arrays of the type that OpenCV uses to hold images. Check their dtype is np.uint16 and their shape appears correct.","Q_Score":0,"Tags":"python,python-3.x,opencv,tiff","A_Id":60044639,"CreationDate":"2020-02-03T17:14:00.000","Title":"cvtColor \"code\" for 16-bit grayscale images","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used a random forest classifier and now I want to see how good my classification was. Maybe even perform a grid search. My test data has no labels, meaning I only have x_train, y_train and x_test. Is there a way to calculate the error rate without having the accuracy?\nThank you in advance!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":148,"Q_Id":60045062,"Users Score":0,"Answer":"It's not possible since you don't have a ground truth. If you don't know what the test data is labeled, how do you want to know how often you predicted the correct label? \nI would suggest you split your training data set into a training and a test data set and go from there.","Q_Score":0,"Tags":"python,classification","A_Id":60045177,"CreationDate":"2020-02-03T18:26:00.000","Title":"Find error rate of a classifier without having y_test","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used a random forest classifier and now I want to see how good my classification was. Maybe even perform a grid search. My test data has no labels, meaning I only have x_train, y_train and x_test. Is there a way to calculate the error rate without having the accuracy?\nThank you in advance!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":148,"Q_Id":60045062,"Users Score":0,"Answer":"unsupervised techniques can work better in this case,and no there is no way to evaluate your algorithm performance unless you cut a part of you training data if it's big enough","Q_Score":0,"Tags":"python,classification","A_Id":60045730,"CreationDate":"2020-02-03T18:26:00.000","Title":"Find error rate of a classifier without having y_test","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I run the whole think on a RP4 so i wont have matlab installed on it. Its more likely that the Simulink model will be complied to C or C++.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":127,"Q_Id":60045354,"Users Score":-1,"Answer":"I am looking for Simulink soultions only. Running Simulink or the engine is not an option for me on RP4, as i mentioned.","Q_Score":2,"Tags":"python,matlab,simulink","A_Id":60080758,"CreationDate":"2020-02-03T18:48:00.000","Title":"Is there a way to use a Python script output as Simulink model input?","Data Science and Machine Learning":0,"Database and SQL":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":"This could be more of a theoretical question than a code-related one. In my current job I find myself estimating\/ predicting (this last is more opportunistic) the water level for a given river in Africa.\nThe point is that I am developing a simplistic multiple regression model that takes more than 15 years of historical water levels and precipitation (from different locations) to generate water level estimates. \nI am not that used to work with Machine Learning or whatever the correct name is. I am more used to model data and generate fittings (the current data can be perfectly defined with asymetric gaussians and sigmoids functions combined with low order polynomials.\nSo the point is; once I have a multiple regression model, my colleagues advised me not to use fitted data for the estimation but all the raw data instead. Since they couldn't explain to me the reason of that, I attempted to use the fitted data as raw inputs (in my defense, a median of all the fitting models has a very low deviation error == nice fittings). But what I don't understand is why should I use just the raw data, which cold be noisy, innacurate, taking into account factors that are not directly related (biasing the regression?). What is the advantage of that?\nMy lack of theoretical knowledge in the field is what makes me wonder about that. Should I always use all the raw data to determine the variables of my multiple regression or can I use the fitted values (i.e. get a median of the different fitting models of each historical year)?\nThanks a lot!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":60046724,"Users Score":1,"Answer":"here is my 2 cents\nI think your colleagues are saying that because it would be better for the model to learn the correlations between the raw data and the actual rain fall.\nIn the field you will start with the raw data so being able to predict directly from it is very useful. The more work you do after the raw data is work you will have to do every time you want to make a prediction.\nHowever, if a simpler model work perfectly defined with asymetric gaussians and sigmoids functions combined with low order polynomials then I would recommend doing that. As long as your (y_pred - t_true) ** 2 is very small","Q_Score":1,"Tags":"python,machine-learning,linear-regression,data-fitting,model-fitting","A_Id":60046810,"CreationDate":"2020-02-03T20:29:00.000","Title":"Input data necessary for forecasting\/ estimating trends for a given variable","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python's urllib.parse.urlencode to encode a request body to make a 'get' request for a url. I am running into trouble when encoding a UTC datetime string. \nThe endpoints expects the date to look like: \nbegin=2004-01-01T00:00:00&end=2019-04-21T00:00:00\nbut after using urlencode, the date payload looks like: \nbegin=2020-02-04T17%3A00%3A00&end=2020-02-04T20%3A00%3A00\nThe format of the first half of the UTC datetime looks okay, (YYYY-MM-DDT), but second half is screwed up. It SHOULD look like T00:00:00 but does not. \nI am passing a dictionary of parameters into the urlencode function:\nparams = {\n        'begin':'2020-02-04T17:00:00',\n        'end':'2020-02-04T20:00:00',\n}\nreturn urlencode(params, doseq=True)\n\nHow can I encode the date in the correct format? Please let me know if there is anything else I can provide to help you all. Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3417,"Q_Id":60048889,"Users Score":3,"Answer":"%3A is : when urlencoded.\nHence begin=2020-02-04T17:00:00&end=2020-02-04T20:00:00 when encoded will be begin=2020-02-04T17%3A00%3A00&end=2020-02-04T20%3A00%3A00, as stated in your question.\nThe format is correct and there is nothing wrong with your code.","Q_Score":1,"Tags":"python-3.x,http,datetime,python-requests,urllib","A_Id":60296370,"CreationDate":"2020-02-04T00:15:00.000","Title":"How to urlencode UTC datetime strings?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As an example, I have a set of records in a 2D numpy.array and I would like to select all records where value in the 3rd column equal 10. Is there a way to do that apart from looping through the array and build a list of the selected records?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":60050503,"Users Score":0,"Answer":"Here I have created a numpy array.\nprint(df)\no\/p is: array([['A', 'car'],['B', 'bike'],['C', 'car'],['D', 'truck']], dtype=object)\nNow to select all rows with car, you can just filter that value from the array\ndf[df == \"car\"] \no\/p is: array(['car', 'car'], dtype=object)\nIf you want it to be converted to python list, wrap the statement in list, i.e \nlist(df[df == \"car])","Q_Score":0,"Tags":"arrays,python-3.x,numpy,select","A_Id":60050625,"CreationDate":"2020-02-04T04:16:00.000","Title":"How to select from a 2D numpy.array where column == condition","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to pandas and I was wondering if there was a way I could run formulas on two dataframes. \nI have two dfs that have the same columns and same index. example each df looks like this\nx y z\na  2 4 5\nb  7 9 0\n\nI want to take df1, df2 and find the absolute difference for x ,y, z something like (df1[n]-df2[n] \/ df1[n]) * 100 for each n element of columns, and store the result in a new df.\nNote: I just want the difference to be positive. (Misunderstood the meaning of absolute)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2376,"Q_Id":60050512,"Users Score":1,"Answer":"Yes run them as you wrote them\nabsolute\n(df1 - df2).abs()\nor \n(df1 -df2).div(df2) * 100","Q_Score":1,"Tags":"python,pandas,dataframe","A_Id":60050580,"CreationDate":"2020-02-04T04:17:00.000","Title":"Computing absolute difference between two dataframes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to make a program which takes in an image and looks throughout the image to find a colour, lets say blue, and give out the coordinates of that point in the image which has that colour.","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":9895,"Q_Id":60051941,"Users Score":-1,"Answer":"Just noting a problem on the answer by Mark Setchell.\nThe X and Y coords are returned the other way around so  X,Y = np.where(np.all(im==blue,axis=2)) changes to  Y,X = np.where(np.all(im==blue,axis=2)), this may just be a glitch I have though.","Q_Score":1,"Tags":"python,image-processing,colors","A_Id":64548431,"CreationDate":"2020-02-04T06:45:00.000","Title":"Find the coordinates in an image where a specified colour is detected","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"During development it's often happens to me that i have pretty long script execution (which doesn't depend on me), and when error occurs at the late steps it is really annoying to rerun whole script again.\nIs there an option to repeat last line execution after correcting an error?\nOr i need to rerun file from beginning again?\nTo my understanding of scripting language Python should allow that","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1993,"Q_Id":60053046,"Users Score":1,"Answer":"You can use the -i flag on the command line if you simply want to drop into a REPL just before exiting your script.\nOtherwise you are basically looking for setting a breakpoint at the end of execution with a way to jump back to a set point after most of the execution has already occurred. You can try using \"Jump to Cursor\" to jump back to where you want to start execution from.","Q_Score":2,"Tags":"python,debugging,visual-studio-code","A_Id":60082548,"CreationDate":"2020-02-04T08:08:00.000","Title":"VS Code Python debugging. How to continue from error. Repeat fromline after changes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing an NLP task, where I have a distribution of word occurrence in the texts grouped by day. I want to find Pearson correlation between a given word and all other words in the database. Is there possibly some algorithmic solution rather than just manually iterating over all other words in database and calculating correlation. May be something to do with graphs?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":60053797,"Users Score":0,"Answer":"You can use numpy or pandas (vectorised version instead of iterating over all records).","Q_Score":0,"Tags":"python,algorithm,graph,nlp","A_Id":60054120,"CreationDate":"2020-02-04T09:00:00.000","Title":"Finding Pearson correlation for millions of records","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking to handle a case where I need to read from the file, count the number of people (duplicates) only once, and then write the output in a separate file. I'm confused as to which data structure to use for counting people only once for a single class that they are in. The input and output is mentioned below:\nInput:\n10  \n4  \nA-Class Midoriya  \nB-Class Monoma  \nA-Class Todoroki  \nA-Class Midoriya  \n11  \n2  \nA-Class Aizawa  \nB-Class All Might  \nOutput \nCase: 10  \nA-Class 2  \nB-Class 1  \nCase: 11  \nA-Class 1  \nB-Class 1","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":60055093,"Users Score":0,"Answer":"What you want is a set, possibly a dict of sets: a set keeps a single occurrence of duplicate inputs and so is a good way to treat items as unique, a dict is useful if you need multiple \"categories\" each with their own unique list. Although you could alternatively use a set of (category, item) tuples.\nYour input and output make no sense though, case 10 has 2 unique Class A individuals and 1 unique Class B, not 3 and 2.","Q_Score":0,"Tags":"python-3.x","A_Id":60055164,"CreationDate":"2020-02-04T10:11:00.000","Title":"Python File Handling and Counting Duplicates One Time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using tf.random.set_seed to assure the reproducibility of my experiments but getting different results in terms of loss after training my model multiple times. I am monitoring the learning curve of each experiment using Tensorboard but I am getting different values of Loss and accuracy.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2511,"Q_Id":60058588,"Users Score":0,"Answer":"for tensorflow 2, use tf.random.set_seed(seed) instead","Q_Score":3,"Tags":"python,tensorflow,keras,tensorflow2.0","A_Id":70132670,"CreationDate":"2020-02-04T13:35:00.000","Title":"Tesnorflow 2.0 tf.random.set_seed not working since I am getting different results","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Brief introduction:\nI'm trying to get certain texts from an image of a lot of texts.\nBy just thinking, there should be at least two ways to handle this problem: \nOne way is first segmenting the images by text areas \u2014 for example, train the neural network with a bunch of sample images that contain the sample texts, and then let the trained model locate corresponding text areas in the real image, then crop that area out from the image, save it \u2014 and secondly use, for instance, pytesseract to convert image to string.\nThe other way is to reverse the processes. First convert the image into strings, then train the neural network with sample real texts, then let the trained model find corresponding texts in texts converted from images.\n\nSo, my questions are listed below:\n\nCan this problem be solved without training a neural network? Will it be more efficient than NN, in terms of time taken to run the program and accuracy of results?\nAmong the two methods above I wrote, which one is better, in terms of time taken to run the program and accuracy of results?\nAny other experienced suggestions?\n\n\nAdditional background information if needed:\nSo, I have a number of groups of screenshots of different web pages, each of which has a lot of texts on it. And I want to extract certain paragraphs from that large volume of texts. The paragraphs I want to extract express similar things but under different contexts.\nFor example, on a large mixed online forum platform, many comments are made on different things, some on landscapes of mountains, some politics, some sciences, etc... As that platform cannot only have one page, there must be hundreds of pages where countless of users make their comments. Now I want to extract the comments on politics specifically from the entire forum, i.e. from all the pages that platform has. So I would use Python + Selenium to scrape the pages and save the screenshots. Now we need to go back to the questions asked above. What to do now? \n\nUpdate:\nJust a thought went by. Probably a NN trained by images that contain texts cannot give a very accurate location of wanted texts, as the NN might be only looking for arrangements of pixels instead of the words, or even meaning, that compose the sentences or paragraphs. So maybe the second method, text processing, may be better in this case? (like NLP?)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":169,"Q_Id":60058636,"Users Score":0,"Answer":"So, you decided not to parse text, but save it as an image and then detect text from this image.  \nText -> Image -> Text\nIt is worst scenario for parsing webpages.  \nWhile dealing with OCR you must expect many problems, such as:\n\nHigh CPU consumption;\nDifferent fonts;\nHidden elements (like 'See full text');\nAnd the main one - you can't OCR with 100% accuracy. \n\nIf you try to create common parser, that should crawl only required text from any page given without any \"garbage\" - it is almost utopic idea.\nAs far as i know, something about this is 'HTML Readability' technology (Browsers like Safari and Firefox uses it). But how it will work with forums i can't say. Forums is very special format of pages.","Q_Score":0,"Tags":"python-3.x,image-processing,web-scraping,neural-network,nlp","A_Id":60061871,"CreationDate":"2020-02-04T13:38:00.000","Title":"Text\/Image processing in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a tkinter app and I would like to use the pycurl module in my project but without being installed on any host machine... Like a portable version into my package.\nI didn't see any topic on the web speaking about it but still keeping hope to have a sort of workaround for it.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":60058971,"Users Score":0,"Answer":"You could create a binary file of your project using pyinstaller. It will bundle all the dependencies that are required by your application, users can just run the binary file without worrying about installing or setting up dependencies.","Q_Score":0,"Tags":"python,pycurl","A_Id":60059827,"CreationDate":"2020-02-04T13:57:00.000","Title":"Use pycurl without installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've installed Python 3.7, and since installed python 3.8.\nI've added both their folders and script folders to PATH, and made sure 3.8 is first as I'd like that to be default.\nI see that the Python scripts folder has pip, pip3 and pip3.8 and the python 3.7 folder has the same (but with pip3.7 of course), so in cmd typing pip or pip3 will default to version 3.8 as I have that first in PATH.\nThis is great, as I can explicitly decide which pip version to run. However I don't know how to do to the same for Python. ie. run Python3.7 from cmd.\nAnd things like Jupyter Notebooks only see a \"Python 3\" kernel and don't have an option for both.\nHow can I configure the PATH variables so I can specify which version of python3 to run?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":603,"Q_Id":60061675,"Users Score":1,"Answer":"What OS are you running? If you are running linux and used the system package panager to install python 3.8 you should be able to invoke python 3.8 by typing python3.8. Having multiple binaries named python3 in your PATH is problematic, and having python3 in your PATH point to python 3.8 instead of the system version (which is likely a lower version for your OS) will break your system's package manager. It is advisable to keep python3 in your PATH pointing to whatever the system defaults to, and use python3.8 to invoke python 3.8.\nThe python version that Jupyter sees will be the version from which you installed it. If you want to be able to use Jupyter with multiple python versions, create a virtual environment with your desired python version and install Jupyter in that environment. Once you activate that specific virtual env you will be sure that the jupyter command that you invoke will activate the currect python runtime.","Q_Score":0,"Tags":"python,python-3.x,environment-variables","A_Id":60061994,"CreationDate":"2020-02-04T16:27:00.000","Title":"Multiple versions of Python in PATH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python code which takes as input an Excel file and the output is a picture (for example a graph). \nThis works really well and I'm happy with that.\nA friend of mine, who is unfamiliar with coding, would like to use this tool as well. Therefore I would like to make it easy for him and create a shortcut (Windows command) which can execute the script. \nIs this possible, and if yes, how??","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":248,"Q_Id":60061726,"Users Score":-1,"Answer":"You could create an exe with a tool such as Pyinstaller","Q_Score":0,"Tags":"python","A_Id":60061821,"CreationDate":"2020-02-04T16:31:00.000","Title":"Execute python file with windows shortcut","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python code which takes as input an Excel file and the output is a picture (for example a graph). \nThis works really well and I'm happy with that.\nA friend of mine, who is unfamiliar with coding, would like to use this tool as well. Therefore I would like to make it easy for him and create a shortcut (Windows command) which can execute the script. \nIs this possible, and if yes, how??","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":248,"Q_Id":60061726,"Users Score":0,"Answer":"You can try to create a shortcut to c:\/...Python.exe path\/to\/your\/script.py","Q_Score":0,"Tags":"python","A_Id":60062921,"CreationDate":"2020-02-04T16:31:00.000","Title":"Execute python file with windows shortcut","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on obtaining data from a nested JSON response called \"Result\"\nNow after reviewing the API documentation, they say that they only return 100 records per request, so which means if we have 425 records I would have to pass the request. get at least 4 times with:\n\n\/example\n\/example?$skip=100 \n\/example?$skip=200\n\/example?$skip=400\n\nAfter that is done it should write the response list in a csv file.I have parsed the response from the get to json.loads, I have converted the dictionary to list and created a for loop that writes whatever is in the \"Result\" dictionary. \nMy question is how can I create that it loops also the request.get and increments the url value to skip 100,200,300,400. Hope this makes sense","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":326,"Q_Id":60062887,"Users Score":0,"Answer":"So after searching and searching the best way that worked for me was.\n\nCreating a for loop with the number of times that it needs to loop over.\ntoSkip = (i+1) * 100\nConcatenate the string with 'url string' + '?$Skip=' + str(toSkip)\nCreate a request with passing the authorization header\nParse it with json.loads\nWrite the result to a csv file or google sheets API","Q_Score":0,"Tags":"python-3.x,api","A_Id":60080377,"CreationDate":"2020-02-04T17:44:00.000","Title":"Python - API multiple responses","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to switch over to VS Code. I did the following to enable python with the packages I typically use, including a local utilities package on this machine:\n\nSearched for the setting python.pythonPath and made it PycharmProjects\/Project\/venv\/Scripts\/python.exe for both this workspace and for my user\nChanged my Windows user PYTHONPATH to PycharmProjects\/Project\/venv\/Scripts\/python.exe\nTried PycharmProjects\/python.exe;local-utilities-directory\n\nHowever, the folder I'm trying to manually set won't show up as a possible option when I click on my interpreter in the bottom right. Instead I'm defaulting to an older interpreter that doesn't have all the packages I've amassed.\nWhile I can access some packages, while trying to pull in my personal utilities library, pip fails (the term pip is not recognized...)\nI see that there are a few other ways to change the python path, however, to my understanding, whether you do it in a .json or via the IDE UI, shouldn't actually matter.\nAny help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":652,"Q_Id":60064102,"Users Score":0,"Answer":"So, I think I messed things up by offering too many paths.\nI had to double check that the exact same path showed up first in:\n\nWork setting pythonPath\nUser setting pythonPath\nWindows profile path\nWindows profile PYTHONPATH\n\nI deleted the other \"backup\" paths, and it ended up working.","Q_Score":0,"Tags":"python,visual-studio,pycharm","A_Id":60066150,"CreationDate":"2020-02-04T19:11:00.000","Title":"Migrating from PyCharm to VS Code: setting paths","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a program that outputs data in several CSV files from Maya 2018. It reads an object name from a setting file, then creates an array of every keyframe that object has, then exports a column of keyframes and a column of values of the different axes associated with the object.\nThis unfortunately causes a problem when using cubic interpolation to connect the dots, so I'm trying to find a better way to collect the data. My current idea is to capture not only the keyframes, but also the frames immediately before and after the keys as well as the midpoints between the keys, but this seems clunky.\nAny recommendations?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":60064675,"Users Score":0,"Answer":"Interpolating maya anim curves is not the easiest task in the world (effectively you need to solve the cubic equation to find the correct 't' value to then pass to the cubic interpolation function. It's probably that first step you're missing).\nMy advice though, would be to simply output samples for the frame values you need from Maya directly, and skip the interpolation entirely (be aware that any transform driven by IK, expressions, etc, will not have anim curves, so you'll get bad data in those cases)","Q_Score":0,"Tags":"python,maya","A_Id":60068296,"CreationDate":"2020-02-04T19:55:00.000","Title":"How can I create a dynamic sample rate for increased accuracy in reading from a Maya animation with Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to remove pymssql and migrate to pyodbc on a python 3.6 project that I'm currently on. The network topology involves two machines that are both on the same LAN and same subnet. The client is an ARM debian based machine and the server is a windows box. Port 1433 is closed on the MSSQL box but port 32001 is open and pymssql is still able to remotely connect to the server as it somehow falls back to using the named pipe port (32001). \nMy question is how is pymssql able to fall back onto this other port and communicate with the server? pyodbc is unable to do this as if I try using port 1433 it fails and doesn't try to locate the named pipe port. I've tried digging through the pymssql source code to see how it works but all I see is a call to dbopen which ends up in freetds library land. Also just to clarify, tsql -LH  returns the named pip information and open port which falls in line with what I've seen using netstat and nmap.  I'm 100% sure pymssql falls back to using the named pipe port as the connection to the named pipe port is established after connecting with pymssql.\nAny insight or guidance as to how pymssql can do this but pyodbc can't would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":113,"Q_Id":60065942,"Users Score":1,"Answer":"Removing the PORT= parameter and using the SERVER=ip\\instance in the connection string uses the named pipes to do the connection instead of port 1433.  I'm still not sure how the driver itself knows to do this but it works and resolved my problem.","Q_Score":1,"Tags":"python,port,pyodbc,pymssql","A_Id":60189562,"CreationDate":"2020-02-04T21:42:00.000","Title":"How does the pymssql library fall back on the named pipe port when port 1433 is closed?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't find any example on how to make a convertcurrency request using the paypal API in python, can you give me some examples for this simple request?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":60066232,"Users Score":0,"Answer":"Is this an existing integration for which you have an Adaptive APP ID? If not, the Adaptive Payments APIs are very old and deprecated, so you would not have permissions to use this, regardless of whether you can find ready-made code samples for Python.","Q_Score":1,"Tags":"python,paypal,request,paypal-adaptive-payments","A_Id":60066533,"CreationDate":"2020-02-04T22:07:00.000","Title":"PayPal Adaptive Payments ConvertCurrency Request (deprecated API) in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So out of nowhere I seemingly cannot autocomplete methods using . + Tab in Jupyter Notebook.\nCurrently running Jupyter 6.0.1\nI've tried the following with no success:\n$ sudo easy_install readline\nconda install -c anaconda jedi & updated conda\nand the following\npip install pyreadline\nthanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1557,"Q_Id":60066265,"Users Score":1,"Answer":"pip install jedi --upgrade (taking it from 0.17.0 to 0.18.0) and restarting the kernel did the trick for me.","Q_Score":5,"Tags":"python,methods,pip,jupyter-notebook,libraries","A_Id":67243384,"CreationDate":"2020-02-04T22:10:00.000","Title":". + tab AutoComplete not working in Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just installed python3.8 and sublime text editor. I am attempting to run the python build on sublime text but I am met with \"Python was not found but can be installed\" error.\nBoth python and sublime are installed on E:\\\nWhen opening cmd prompt I can change dir and am able to run py from there without an issue.\nI'm assuming that my sublime is not pointing to the correct dir but don't know how to resolve this issue.","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":5706,"Q_Id":60066455,"Users Score":-2,"Answer":"i had the same problem, so i went to the microsoft store (windos 10) and simply installed \"python 3.9\" and problem was gone!\nsorry for bad english btw","Q_Score":0,"Tags":"python-3.x,sublimetext","A_Id":65723885,"CreationDate":"2020-02-04T22:26:00.000","Title":"Python was not found but can be 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'm trying to install eel library for python and I keep getting this message. I have tried upgrading pip but still no luck please help using windows 10, python 3.8 on visualstudio.\n\ndistutils.errors.DistutilsError: Command '['c:\\program files\n  (x86)\\python38-32\\python.exe', '-m', 'pip',\n  '--disable-pip-version-check', 'wheel', '--no-deps', '-w',\n  'C:\\Users\\inamu\\AppData\\Local\\Temp\\tmpp16m1lcg', '--quiet',\n  'pycparser']' returned non-zero exit status 1.\n      ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for\n  full command output.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1368,"Q_Id":60067549,"Users Score":1,"Answer":"I had the same problem and I'm guessing it has to do with gevent, which was the case for me. To solve it I did \"pip install gevent==1.5a3\"\nIf this doesn't fix it then I would try to troubleshoot which individual library is causing this issue then install a different release version using the library name then ==library update","Q_Score":1,"Tags":"python,pip,eel","A_Id":60101876,"CreationDate":"2020-02-05T00:45:00.000","Title":"not able to pip install eel . - Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"72.0.2 (64-bit) on MacOS 10.14.6 (18G3020)\nRan a python selenium script for automation and after that FF still shows the orange stripes bar and an icon which says \"Browser is under remote control\"\nRebooted machine but no luck.\nIs there way to take out FF in normal mode now?\n(Not able to access saved logins in this mode)\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":181,"Q_Id":60067833,"Users Score":0,"Answer":"This did the trick.\n\nSetup FireFox sync account\nCreate a new empty profile and make it default\nRestart FF with that profile\nLogin to FF sync and get back bookmarks\/saved logins etc.\n\nNow FF is auto-filling passwords again.\nStrange thing is that address bar still shows slanted orange\/light orange stripes and \"Browser is under remote control\" but works like regular browser.","Q_Score":0,"Tags":"python,macos,selenium,firefox","A_Id":60314201,"CreationDate":"2020-02-05T01:28:00.000","Title":"FireFox 72.0.2 on Mac Stuck in \"Remote Control\" mode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm studying BCP for export large amount of data (one time for initial and plan to do it in day-to-day job).\nSource data are in SQL Server tables, which consist of some small tables to larger ones (10M+ rows). Destination is in another machine (export to files).\nCurrently, I'm implementing it using python subprocess. \nBy using BCP command without specified batchsize (queryout, -U, -P, -S, -c).\nAnd the query is super straightforward (SELECT <column_names> FROM <table_name>). Maybe adding WHERE dates in day-to-day job.\nI have tried with 100k data, it took around 2 minutes. However, I haven't tried with 10M+ data, due to my company's restriction to use production data in development environment. Also, I couldn't insert any data into the source SQL Server (only read access).\nCould anyone please suggest that is there any ways to optimize the BCP export process?\nMy understanding is that it should be able to make it better, since I did it in very straightforward way.\nThank you so much.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":428,"Q_Id":60068714,"Users Score":2,"Answer":"If you are moving data from one SQL Server to another MS SQL Server, then using the -N option to copy data to your files in native format will help reduce time to convert data types to text.\nUsing the -a option to specify network packet size. I cannot suggest a proper value here as this will depend on your network (is the file going to disk that is distributed from the server? if so, then try some different values here... if not, don't bother... not network involved).\nUse the -b option when importing data into your destination. I cannot suggest a proper value here as this will depend on your system architecture, but play with this value in testing to get a refined value. This does not work with export.\nWhen exporting a large table, thread out the copy to multiple files. Hopefully your large tables have a numeric key or some numeric value that has a high selectivity. This value can be used to partition your data into 10 or 100 threads. This will allow you to execute multiple bcp commands at the same time pulling from the same table. Use the \"queryout\" option and a command like:\n\"select * from db.dbo.mytable where key % 10 = 0\"\nto get 1\/10th of the data and:\n\"select * from db.dbo.mytable where key % 10 = 1\"\nto get the next or another 1\/10th of the data.\nExecute as many at the same time as your source server can withstand. This is great for speeding up a copy out, but be careful on loading into the destination. You wont be able to run as many together. This will likely be your biggest gain in performance. To get as many BCP commands running as your source server can withstand.","Q_Score":0,"Tags":"python,sql,sql-server,bcp,sqlbulkcopy","A_Id":60081589,"CreationDate":"2020-02-05T03:41:00.000","Title":"Any suggestion for optimizing BCP export from SQL Server using Python Subprocess","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I'm working with a dataset where I have ~100,000 training images and ~20,000 validation images, each of size 32 x 32 x 3, how does the size and the dimensions of my dataset affect the number of Conv2d layers I have in my CNN? My intuition is to use fewer Conv2d layers, 2-3, because any more than 3 layers will be working with parts of the image that are too small to gain relevant data from. \nIn addition, does it make sense to have layers with a large number of filters, >128? My thought is that when dealing with small images, it doesn't make sense to have a large number of parameters.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":189,"Q_Id":60069035,"Users Score":0,"Answer":"Since you have the exact input size like the images in Cifar10 and Cifar100 just have a look what people tried out.\nIn general you can start with something like a ResNet18. Also I don't quite understand why you say \n\nbecause any more than 3 layers will be working with parts of the image that are too small to gain relevant data from.  \n\nAs long as you don't downsample using something like max pooling or a conv with padding 1 and stride 2. The size of 32x32 will be the same and only the number of channels will change depending on the network.\nDesigning networks is almost always at looking what did other people do and what worked for them and starting from there. You almost never want to do it from scratch on your own, since the iteration cycles are just to long and models released by researches from Google, Facebook ... had way more resources then you will ever have to find something good.","Q_Score":4,"Tags":"python,deep-learning,neural-network,pytorch,conv-neural-network","A_Id":60074178,"CreationDate":"2020-02-05T04:27:00.000","Title":"Number of Conv2d Layers and Filters for Small Image Classification Task","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python file that takes an image and a pdf as input, computes and prints the Levenshtein distance between the OCR and data extracted from pdf. \nThe image name and pdf name are as follows -\nImage - 'foo_1.png', 'foo_2.png', etc. (One png per page of pdf)\npdf - 'foo.pdf'  \nDirectory structure\nDir\n|\n|__ Images\n |\n |__ foo_1.png\n |__ foo_2.png\n|\n|__ Documents\n |\n |__ foo.pdf\n|\n|__myScript.py  \nI call the script from terminal like ~\/Dir$ python myScript.py foo\nThe files 'foo_1.png', 'foo_2.png' and 'foo.pdf' are called, processed and the result is printed as follows.  \nCurrent output in terminal -  \n\nfield1 -\n  L Dist - 61 L Ratio - 0.47\n  field2 -\n  L Dist - 54 L Ratio - 0.37\n\nIs there a way to call the script from terminal to process several such files in a directory?\nExpected output in terminal -  \n\nfield1 -\n  L Dist - 61 L Ratio - 0.47\n  field2 -\n  L Dist - 54 L Ratio - 0.37\nfield1 -\n  L Dist - 30 L Ratio - 0.07\n  field2 -\n  L Dist - 84 L Ratio - 0.87\n\nI already have python script to achieve the batch processing. I wanted to know if there is a way to achieve this from terminal by calling only to the 'myScript.py'.\nThanks!","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":90,"Q_Id":60069462,"Users Score":-2,"Answer":"First download the python package with its help we can execute the task.\nafter downloading launch the application and in terminal open the python normal and text file to check whether the specified file available or not.\nafter that provide full path of text file and press enter it executed successfully.","Q_Score":0,"Tags":"python,bash,terminal,batch-processing","A_Id":60069615,"CreationDate":"2020-02-05T05:24:00.000","Title":"How to process multiple files using a python script 'from the terminal' and not using another script or loops?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"In some programs that could potentially use lots of RAM the program is terminated by signal sigkill \nI know it is possible to prevent the sigkill process using a local editor but just wondering about when the editor is online? Say, grok for example?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":256,"Q_Id":60072437,"Users Score":0,"Answer":"There isn't generally any way to increase RAM in online editors. Online editors are generally meant to run small snippets of code. The only way to not use lot of memory is to optimize your program to not hog memory when it does not need to, but of-course this is not always possible.","Q_Score":1,"Tags":"python","A_Id":60073297,"CreationDate":"2020-02-05T09:13:00.000","Title":"Prevent SIGKILL of a process in python on grok","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to automate a situation wherein I need to close internet connection of device and then resume it again. Can anyone help me out?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":60072604,"Users Score":0,"Answer":"If it operating system is ubuntu :\n1. Launch terminal using 'os' module in python and shut down networking interface\n    command : os.system(\"gnome-terminal -e 'sudo ifconfig eth0 down'\")\n2. Do your required task\n3. Again, make network interface up and running\n    command : os.system(\"gnome-terminal -e 'sudo ifconfig eth0 up'\")","Q_Score":0,"Tags":"python,selenium","A_Id":60088874,"CreationDate":"2020-02-05T09:22:00.000","Title":"Is there any function in selenium that closes internet connection and resumes after specific amount of time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My python project is organised as one big file right now. The code is organised with def functions and I have a good overview. I like that because it enables me to work in one file only and i can look for code snippets that i have already done easily via the search function. \nHowever, I keep reading and people keep telling me that an organisation of python code in modules and importing them is best practice. \nCan you please point out why organising python code in modules is better than having one large script.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":60073849,"Users Score":0,"Answer":"It's mainly a matter of preference while planning maintainability. Some people can manage 10 thousand lines of codes in a single file without even flinching. However, when you are putting so much in a single file, problems like separating namespaces, naming variables, functions and even classes start to occur. \nIntroducing Module-level separation is a good practice when your application\/library starts to get bigger. But when even module-level separation is not enough, you know it's time to create packages.","Q_Score":0,"Tags":"python","A_Id":60074041,"CreationDate":"2020-02-05T10:33:00.000","Title":"Organisation of Python code. One big file versus multiple modules, packages","Data 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 many rows I can insert in single time with execute_values command in Postgres database? I am using latest PostgreSQL (version 12) and executing this command in python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":381,"Q_Id":60074813,"Users Score":0,"Answer":"It probably is limited by the amount of RAM. But rather than creating huge statements, use COPY and stream the data to the server.","Q_Score":0,"Tags":"python,python-3.x,database,postgresql","A_Id":60074908,"CreationDate":"2020-02-05T11:29:00.000","Title":"Maximum row insert limit | execute_values Command | Postgres","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When we use the == operator on 2 dictionaries, then it checks that each dictionary has the same key\/values irrespective of order since dict is inherently unordered\nHowever, for a value inside the dict, if it is a mutable type - example: list, then how does the == work in terms of order of elements in the list value?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":60074824,"Users Score":0,"Answer":"since dict is inherently unordered\n\nNote that they aren't since 3.7 (they are insertion ordered, like lists).\n\nhow does the == work in terms of order of elements in the list value?\n\nYou compare element by element, in the given order. If any differs, then it is different.\n\nif the value is a mutable type\n\nBeing mutable or not is irrelevant, the same that applies to a tuple applies to a list.","Q_Score":0,"Tags":"python,python-3.8","A_Id":60074892,"CreationDate":"2020-02-05T11:30:00.000","Title":"How does == comparison of 2 dictionaries work when the value is a mutable type like list (does order matter)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have data in nifti format, these are 3 axial images of an animal\u2019s brain, how to create a dataset for training a convolutional neural network, for segmenting brain regions, by python 3?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":507,"Q_Id":60074950,"Users Score":0,"Answer":"You can use nibabel library for loading nifti files using nibabel.load(path). And from that, you can get numpy array and combine all arrays to form a dataset in numpy arrays or convert it to H5py format as your choice.","Q_Score":1,"Tags":"python-3.x,tensorflow,conv-neural-network,tensorflow-datasets,faster-rcnn","A_Id":62447534,"CreationDate":"2020-02-05T11:37:00.000","Title":"How to create a dataset for CNN from Mri Nifti files?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have main thread which block waits for the items in the priority queue (PQ) to processed by the consumer thread. The consumer thread receives items from a different populator thread. Whenever the consumer thread receives a high priority 'TERMINATOR' item, it dies. But since the main thread is waiting on the queue elements to be processed it never exits. Is there a way for me to notify the PQ.join() to return without using a while loop to empty my queue(large number of items in the queue is causing a lot of delay if I use a while loop)","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":447,"Q_Id":60075835,"Users Score":2,"Answer":"You could wait for the consumer thread instead of the priority queue, it seems like that is the thing you want to wait on, i.e. consumer_thread.join() instead of PQ.join().","Q_Score":1,"Tags":"python,multithreading,queue,priority-queue,blocking","A_Id":60076047,"CreationDate":"2020-02-05T12:27:00.000","Title":"How do I notify queue.join() in python to stop blocking even if the current queue contains unprocessed elements?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been working with facial embeddings but I think Word2Vec is a more common example.\nEach entry in that matrix is a number that came from some prediction program\/algorithm, but what are they? Are they learned features?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":60076497,"Users Score":2,"Answer":"Those numbers are learned vectors that each represents a dimension that best separates each word from each other, given some limiting number of dimensions (normally ~200). So if one group of words tends to appear in the same context, then they'd likely share a similar score on one or more dimensions. \nFor example, words like North, South, East, West are likely to be very close since they are interchangeable in many contexts. \nThe dimensions are chosen by algorithm to maximize the variance they encode, and what they mean is not necessarily something we can talk about in words. But imagine a bag of fridge-magnets each representing a letter of the alphabet - if you shine a light on them so as to cast a shadow, there will be some orientations of the letters that yield more discriminatory information in the shadows than for other orientations. \nThe dimensions in a word-embedding represent the best \"orientations\" that give light to the most discriminatory \"shadows\". Sometimes these dimensions might approximate things we recognise as having direct meaning, but very often, they wont.\nThat being said, if you collect words that do have similar functions, and find the vectors from those words to other words that are the endpoint of some kind of fixed relationship - say England, France, Germany as one set of words consisting of Countries, and London, Paris, Berlin as another set of words consisting of the respective Capital-Cities, you will find that the relative vectors between each country and its capital are often very, very similar in both direction and magnitude. \nThis has an application for search because you can start with a new word location, say \"Argentina\" and by looking in the location arrived at by applying the relative \"has_capital_city\" vector, you should arrive at the word \"Buenos Aires\".\nSo the raw dimensions probably have little meaning of their own, but by performing these A is to B as X is to Y comparisons, it is possible to derive relative vectors that do have a meaning of sorts.","Q_Score":0,"Tags":"python,word2vec,feature-extraction,embedding,word-embedding","A_Id":60076869,"CreationDate":"2020-02-05T13:05:00.000","Title":"What does each element in an embedding mean?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project to display sensor data on Python GUI. Sensor data is coming at a rate of 2kHz on serial port using Arduino. I was using pyserial (using readline()) to read the sensor data on my laptop. After hours of debugging I found that python was able to read around 400 samples\/sec i.e. reading frequency is around 400Hz. \nIs there any way to read the serial data at higher rate with the help of python?\nThanks in Advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":473,"Q_Id":60077770,"Users Score":0,"Answer":"Assuming the sensor is designed to transmit 2kHz data and is doing so properly, my guess is that the time your Python code is taking to read a data sample, process the data, update a plot, etc is the limiting factor. Are you reading and processing samples one at a time?  Is there a smart way to read all of the available in a big chunk reducing the number of individual read\/process steps?\nAre you plotting the data in \"real time\"? If so, plot updates are slow.","Q_Score":0,"Tags":"python,arduino,pyserial","A_Id":60291573,"CreationDate":"2020-02-05T14:15:00.000","Title":"How to read highspeed Serial-data 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 want to improve my understanding of how to use logging correctly in Python. I want to use .ini file to configure it and what I want to do:\n\ndefine basic logger config through .fileConfig(...) in some .py file\nimport logger, call logger = logging.getLogger(__name__) across the app and be sure that it uses my config file that I was loaded recently in different .py file\n\nI read few resources over Internet ofc but they are describing tricks of how to configure it etc, but want I to understand is that .fileConfig works across all app or works only for file\/module where it was declared.\nLooks like I missed some small tip or smth like that.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":60077817,"Users Score":1,"Answer":"It works across the whole app. Be sure to configure the correct loggers in the config. logger = logging.getLogger(__name__) works well if you know how to handle having a different logger in every module, otherwise you might be happier just calling logger = logging.getLogger(\"mylogger\") which always gives you the same logger. If you only configure the root logger you might even skip that and simply use logging.info(\"message\") directly.","Q_Score":0,"Tags":"python,logging","A_Id":60078738,"CreationDate":"2020-02-05T14:18:00.000","Title":"How to use logger with one basic config across app in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing server using python and ZMQ. REQ-REP pattern. Sometimes, if the server crashes or restarts, then it stops seeing any messages sent to it at all. What could be the problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":60078021,"Users Score":1,"Answer":"Q : What could be the problem?\n\nThe nature of a principally unsafe, mutual-deadlock prone distributed-Finite-State-Automaton is.\nGiven the REP dies during the REQ waiting for a response, deadlock\nGiven the REQ dies during the REP waiting for a request, chances are to restore REQ\/REP quickstep\nGiven the REQ dies before the REP sends the response, deadlock\nGiven the REQ dies during the REP sending the response, deadlock\nGiven the REP dies before the REQ sending a request, chances are to restore REQ\/REP quickstep","Q_Score":0,"Tags":"python,zeromq,pyzmq","A_Id":60081226,"CreationDate":"2020-02-05T14:29:00.000","Title":"ZMQ server doesn't see any 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":"As I get, tf.layers.conv1d uses pipeline like this: BatchToSpaceND -> conv1d -> SpaceToBatchND. So the question is how to remove (or disable) BatchToSpaceND and SpaceToBatchND from the pipeline?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":60080700,"Users Score":0,"Answer":"As I've investigated it's impossible to remove BatchToSpaceND and SpaceToBatchND from tf.layers.conv1d without changing and rebuilding tensorflow source code. One of the solutions is to replace layers to tf.nn.conv1d, which is low-level representation of convolutional layers (in fact tf.layers.conv1d is a wrapper around tf.nn.conv1d). These low-level implementations doesn't include BatchToSpaceND and SpaceToBatchND.","Q_Score":0,"Tags":"python,tensorflow,conv-neural-network","A_Id":60151192,"CreationDate":"2020-02-05T17:03:00.000","Title":"Is there any way to remove BatchToSpaceND from tf.layers.conv1d?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an API built using flask which dumps data to s3 using kinesis firehose. So far it is only in one region with load balancer and auto-scaling group containing multiple instances. Now I want to have the flask application in multiple region in order to reduce latency. However, I could find a way to configure Kinesis Firehose stream for different regions. That means, even if I put my application in different regions, Kinesis Firehose will become the bottleneck. \nIs it possible to support multiple regions for kinesis firehose and channel the data based on the closest region?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":782,"Q_Id":60084475,"Users Score":0,"Answer":"When creating the stream using boto3 specify the region. Keep the same stream name but pick different regions each time. If you want to manually do it from the AWS web console then change the region at the top and then create the stream. Keep repeating the process for each region.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-kinesis,amazon-kinesis-firehose","A_Id":64980631,"CreationDate":"2020-02-05T21:36:00.000","Title":"Kinesis Firehose same stream in multiple regions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a multiplayer game written in python and uses TCP, So when I send two packets at the same time they get mixed up example if I send \"Hello there\" and \"man\" the client receives \"hello thereman\".\nWhat should I do to prevent them from getting mixed?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":279,"Q_Id":60087125,"Users Score":3,"Answer":"That's the way TCP works.  It is a byte stream.  It is not message-based.\nConsider if you write \"Hello there\" and \"man\" to a file.  If you read the file, you see \"hello thereman\".  A socket works the same way.\nIf you want to make sense of the byte stream, you need other information.  For example, add line feeds to the stream to indicate end of line.  For a binary file, include data structures such as \"2-byte length (big-endian) followed by <length> bytes of data\" so you can read the stream and break it into decipherable messages.\nNote that socket methods send() and recv() must have their return values checked.  recv(1024) for example can return '' (socket closed) or 1-1024 bytes of data.  The size is a maximum to be returned.  send() can send less than requested and you'll have to re-send the part that didn't send (or use sendall() in the first place).\nOr, use a framework that does all this for you...","Q_Score":0,"Tags":"python-3.x,sockets","A_Id":60087186,"CreationDate":"2020-02-06T03:05:00.000","Title":"Python TCP packets getting mixed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So here is the problem, I'm trying to import a DF from a file downloaded from COGNOS. In cognos I select .CSV format but always is downloaded the format is .xls\nIt will be very easy to open the .xls file and save as CVS but the problem with that is that the file has more rows than excel so I will lose a lot of data in the process. Also when I open the file in excel it is a warning that the file could be corrupted.\nWhen I'm trying to open the data with df = pd.read_excel(\"Time Series 2018-1.xls\") it shows the following problem.\nXLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'\\xff\\xfeP\\x00r\\x00o\\x00'\nPlease HELP","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1157,"Q_Id":60087450,"Users Score":0,"Answer":"I already resolve it. Just open the file in sublime and save with encoding UTF-8. Then just open it with df = pd.read_csv(\"Prueba1.xls\", sep = \"\\t\", encoding = 'utf8') because as @dougp said, is just a csv file save with the extension xls.\nI guess there is a way to change the encoding in PYTHON but that's for another question.","Q_Score":0,"Tags":"python-3.x,pandas,xls,cognos","A_Id":60118432,"CreationDate":"2020-02-06T03:47:00.000","Title":"Open with Pandas in Python a .xls file that is corrupted","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For the below line of code to get the metrics, I'm getting the ValueError mentioned\nf1_test.append(f1_score(y_test, y_pred_test, pos_label=\"str\"))\nValueError: pos_label='str' is not a valid label: array([' <=50K', ' >50K'], dtype='\nMy data has Income vlaue <=50k or >50k.\nPlease advise.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":349,"Q_Id":60087814,"Users Score":0,"Answer":"The parameter pos_label is used to indicate the positive class. In your data, your labels are string based '<=50K' and '>50K'.\nYou can do one of the following:\n\nLeave pos_label to the default value, set pos_label = 1.\nSet pos_label = '>50K' or '<=50K', based on what your +ve class. The positive class is normally attributed to the best outcome, for example, the income that you are trying to predict, is it better if its more than 50K or less than <=50K?","Q_Score":1,"Tags":"python-3.x,scikit-learn","A_Id":60088681,"CreationDate":"2020-02-06T04:36:00.000","Title":"sklearn metrics f1_score : pos_label valueError","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a PyCharm project containing several Python scripts, it's using virtual environment. All is set-up and it's up and running. Windows 10. \nI would now like to run the same Python scripts from within Cygwin command line. Is there a way to reuse the virtual environment created by PyCharm (C:\\Users\\joe_doe\\\\.virtualenvs\\prj_name)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":102,"Q_Id":60091774,"Users Score":1,"Answer":"I would say: no, I don't believe it is possible, and even if it were it is not worth the trouble.\nVirtual environments should probably be considered as throwaway things. Use something like pip freeze > requirements.txt to save the list of projects installed in the virtual environment. And then pip install --requirement requirements.txt to install these projects in a new environment. It is a good habit to curate the list of requirements and one should be comfortable with deleting and recreating virtual environments on a whim without fear of losing any information.","Q_Score":1,"Tags":"python,windows,pycharm,cygwin,virtualenv","A_Id":60093104,"CreationDate":"2020-02-06T09:37:00.000","Title":"Reuse PyCharm Python virtual environment in Cygwin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a relatively small dataset consisting of x, y coordinates and organic matter content. I perform a simple multi-linear regression in Python using statsmodels.api ordinary least square (OLS) with organic matter content being the dependent variable and the others predictors. Firstly, I find the total sum of squares of my model (called mreg) with the built-in method 'mreg.centered_tss'. Now I have to find the sum of squares for my predictors, the x and y variable. Is it possible to do with the statsmodels.api or should I use a for loop instead?\nI have used the .ess and the .centered_tss to determine the sum of squares of the model. I only need to know the sum of squares of my modelled variables x and y coordinates compared to the mean. \nedit: I think what I am asking for is the residual sum of squares of my x coordinates and y coordinates from the model. \nThomas","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1053,"Q_Id":60091784,"Users Score":2,"Answer":"there should be a .ssr method for the regression sum of squares","Q_Score":1,"Tags":"python,statistics,statsmodels","A_Id":64764107,"CreationDate":"2020-02-06T09:38:00.000","Title":"How do I find the sum of squares of my predicting variables with statsmodels linear model OLS?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.\n  Did you install mysqlclient?\n\nGetting this error even installed the mysqlclient\npython version: Python 3.6.9","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":60092294,"Users Score":0,"Answer":"You have to install mysqlclient in the virtual environment using pip install mysqlclient.","Q_Score":1,"Tags":"python,django","A_Id":60092363,"CreationDate":"2020-02-06T10:02:00.000","Title":"Database error in django while running local sever?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I had a issue with tesseract version.\nError log: \n\nraise TSVNotSupported() pytesseract.pytesseract.TSVNotSupported: TSV\n  output not supported. Tesseract >=3.05 required\n\nHow do I install tesseract 3.05 ?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1300,"Q_Id":60092896,"Users Score":-1,"Answer":"To you tesseract, you must have Tesseract OCR (the program not the library) installed. This will then enable the python library to work as expected. Additionally, you need to add it to your path.","Q_Score":1,"Tags":"python,python-3.x,tesseract,python-tesseract,pytesser","A_Id":60093156,"CreationDate":"2020-02-06T10:31:00.000","Title":"TSV output not supported. Tesseract >=3.05 required","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using google vision API for retrieving the text from images, the output json file just contains the text and the coordinates of the text. Is there any way we can get key value pairs from google vision ocr?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":688,"Q_Id":60094111,"Users Score":0,"Answer":"The way google vision ocr works is that it detects texts in blocks and in paragraphs inside these blocks. Provided your tables are in the same format, you can just manipulate the json output to give you key and value pairs. Aside from this, I do not think google vision ocr can do explicitly, what you're asking for.","Q_Score":1,"Tags":"python,ocr,image-recognition,google-vision","A_Id":60224121,"CreationDate":"2020-02-06T11:38:00.000","Title":"How to get key value pairs in google vision ocr?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to modify files inside docker container with PyCharm. Is there possibility of doing such thing?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":723,"Q_Id":60096680,"Users Score":1,"Answer":"Yes. There are multiple ways to do this, and you will need to have PyCharm installed inside the container.\nFollowing set of instructions should work -\n\ndocker ps - This will show you details of running containers\ndocker exec -it *<name of container>* \/bin\/bash\n\nAt this point you will oh shell inside the container. If PyCharm is not installed, you will need to install. Following should work -\nsudo apt-get install pycharm-community\nGood to go!\nNote: The installation is not persistence across Docker image builds. You should add the installation step of PyCharm on DockerFile if you need to access it regularly.","Q_Score":3,"Tags":"python,docker,pycharm","A_Id":60097118,"CreationDate":"2020-02-06T13:59:00.000","Title":"Is there a way to modify files inside docker via PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I using selennium with python to crawl webpage. But I want to pause and resume everytime when scrolling webpage. Is it possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":60097213,"Users Score":0,"Answer":"You could use an explicit wait or poll for certain elements every time you scroll. I would be interested to know if you are dealing with some lazy loading, where the elements you are looking for are not already in the DOM.","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,web-crawler","A_Id":60100509,"CreationDate":"2020-02-06T14:27:00.000","Title":"Is it possible to pause and resume like event when scrolling webpage using selenium python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to install certain library in Visual Studio Code terminal using pip install *library* command and I am getting error: \n\npip : The term 'pip' is not recognized as the name of a cmdlet,\n  function, script file, or operable    program. Check the spelling of\n  the name, or if a path was included, verify that the path is correct\n  and try again.\n\nI tried with pip3 command as well and got same message. I am executing python files with py -3 command.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":60097770,"Users Score":1,"Answer":"you can install library like this\npython -m pip install numpy","Q_Score":1,"Tags":"python-3.x","A_Id":60097811,"CreationDate":"2020-02-06T14:54:00.000","Title":"How to install specific library using \"pip\" command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a coverage report that may be lying or distorted.  It says that I have coverage for a line in my Django model code.  I can't see where that line is being exercised.  I can see that the module is imported, that the class is imported, but not that it's being invoked\/instantiated.\nThus, coverage report says I have Line A covered.  Presumably that means Line B, somewhere, is exercising it.  I'd like to know where Line B is.  Is there a way to find the set of Line-B's (one or more) that are calling Line A, in my tests?  \nIt seems this could be an annotation in the coverage report somehow\/somewhere.  It's definitely knowable, since coverage has to keep track of a thing being used.  \nI'm not seeing it.\nIf this isn't implemented, I'd like to suggest it.  I know, it may be too complex as a full stack trace for each line of execution.  But, maybe just the inspect of the immediate calling frame would be a good start, and helpful.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":387,"Q_Id":60100319,"Users Score":1,"Answer":"Here's a fun way to discover what covers that line:\nInsert a bug in the line.\nIf you then run the tests, the ones truly covering the line will fail. The stacktraces should include Line B.","Q_Score":2,"Tags":"python,unit-testing,pytest,code-coverage,agile","A_Id":66437126,"CreationDate":"2020-02-06T17:15:00.000","Title":"Python Coverage Says Line A is Covered, Need to Know From Where","Data Science and Machine Learning":0,"Database and SQL":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 python code that I wrote and have just installed vscode and starting to work with it.\nthe code is in home\/user\/code\/dlS3BMC folder which has a env folder with my virtual environment.\nI am using Linux Mint 19.3 Tricia cinnamon desktop, vscode 1.41.1\nI open this folder in vscode.  ctrl+ shft+p and I see my virtual environment, I select it, but when I do which python in the terminal window it is still pointing to the system python \/usr\/bin\/python\nIf I . env\/bin\/activate in the terminal everything works fine - I don't mind doing that but it would be nice if I didn't have to.\nFrom the microsoft docs I think it is supposed to automatically activate the env, but it does not.  I have tried saving project after I activate, but when I close and open again, it is not activated.  Sorry I am very new to vscode at this stage and have just used sublime text editor to write my python code in the past.\nThanks\nBill","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":937,"Q_Id":60101325,"Users Score":0,"Answer":"ok, it seems it does not activate the virtual environment until you run the code either debug or simply run... when you run the code, I can see it activate the env.  \nTIL this.\nRegards\nBill","Q_Score":1,"Tags":"python,visual-studio-code,python-venv","A_Id":60102510,"CreationDate":"2020-02-06T18:23:00.000","Title":"vscode doesn't seem to activate my virtual python environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there a way to get values of a dask dataframe without using compute function as pandas? \n\nPandas: df.values\nDask using compute function: ddf.compute().values\n\nDask using compute function is slow and I have to transform the dask dataframe to json format and to do that I should get the values.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":877,"Q_Id":60102700,"Users Score":0,"Answer":"I have to transform the dask dataframe to json format and \n\nYou may be interested in the .to_json method of Dask dataframes\n\nand to do that I should get the values.\n\nThis may not be true","Q_Score":0,"Tags":"python,pandas,function,dataframe,dask","A_Id":60243760,"CreationDate":"2020-02-06T20:04:00.000","Title":"Values of a Dask Dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to get values of a dask dataframe without using compute function as pandas? \n\nPandas: df.values\nDask using compute function: ddf.compute().values\n\nDask using compute function is slow and I have to transform the dask dataframe to json format and to do that I should get the values.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":877,"Q_Id":60102700,"Users Score":1,"Answer":"Because Dask is suited for large datasets, performing compute on the full data source does not make sense.\nI think you should generate your json file by iterating on partitions.\ndf.npartitions gives you the number of partitions.\nYou can get a specific partition (for example n) with df.get_partition(n).","Q_Score":0,"Tags":"python,pandas,function,dataframe,dask","A_Id":60111095,"CreationDate":"2020-02-06T20:04:00.000","Title":"Values of a Dask Dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When installed and then opened, both platforms create the following folders in the %UserProfile% directory...\n(e.g.: \"C:\\Users\\[username]):\n\n\".spyder-py3\"\n\".anaconda\"\n\".conda\"\n\".config\"\n\".ipython\"\n\".matplotlib\"\n\nI've got my working folder in, say, the following path: \"B:\\Python\". I want to have the aforementioned folders stored in said path, and the Anaconda and Spyder platforms to still be able to find them. Where do I modify the paths from the default one (user profile) to the new one (\"B:\\Python\")?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":459,"Q_Id":60107627,"Users Score":1,"Answer":"(Spyder maintainer here) No, there isn't, sorry.","Q_Score":1,"Tags":"python,anaconda,spyder","A_Id":60138657,"CreationDate":"2020-02-07T05:31:00.000","Title":"Is there a way to change directory of config files in Anaconda\/Spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What exactly does this error mean and how can i fix it, am running server on port 8000 of local host.\nConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2412,"Q_Id":60110234,"Users Score":0,"Answer":"Is firewall running on the server? If so, that may be blocking connections. You could disable firewall or add an exception on the server side to allow connections on port 8000.","Q_Score":0,"Tags":"python,django,localhost","A_Id":60110521,"CreationDate":"2020-02-07T09:05:00.000","Title":"ConnectionRefusedError: [WinError 10061][WinError 10061] No connection could be made because the target machine actively refused it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I applied a linear regression on some features to predict the target with 10 folds cross validation.\nMinMax scale was applied for both the features and the target.\nThen the features standardized.\nWhen I run the model, the r2 equal to 0.65 and MSE is 0.02.\nBut when I use the target as they are without MinMax scaling, I got r2 same but the MSE increase a lot to 18.\nMy question is,  do we have to deal with targets as same we do with features in terms of data preprocessing? and which of the values above is correct? because the mse got quit bigger with out scaling the target.\nSome people say we have to scale the targets too while others say no.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":697,"Q_Id":60111980,"Users Score":2,"Answer":"Whether you scale your target or not will change the 'meaning' of your error. For example, consider 2 different targets, one ranged [0, 100] and another one [0, 10000]. If you run models against them (with no scaling), MSE of 20 would mean different things for the two models. In the former case it will be disastrous, while in the latter case it will be pretty decent.\nSo the fact that you get lower MSE with target range [0, 1] than the original is not surprising.\nAt the same time, r2 value is independent of the range since it is calculated using variances.\nScaling allows you to compare model performance for different targets, among other things.\nAlso for some model types (like NNs) scaling would be more important.\nHope it helps!","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,linear-regression","A_Id":60114625,"CreationDate":"2020-02-07T10:51:00.000","Title":"MinMax scaling the target","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Change time from UTC to the local timezone\nI have to write a script where the user will enter a tuple of hours and minutes t(h,m) in IST(Indian).\nThe entered time should be changed to the local time zone of the PC. Is there a library to do so in python. The time should also be returned in a tuple of hour and minutes.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":60114883,"Users Score":0,"Answer":"The time module provides you with some constants including time.timezone, which gives the offset of the local (non-DST) timezone in seconds west of UTC. Subtracting India's timezone from user's timezone will give you the time difference in hours, which you can use to calculate your result.","Q_Score":0,"Tags":"python,time,pip","A_Id":60115305,"CreationDate":"2020-02-07T13:55:00.000","Title":"To convert Time from one timezone to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the advantages of ViewSet, ModelViewSet and APIView. In the django-rest-framework documents it is not clear, it does not say when to use ViewSet, ModelViewSet and APIView. I want to implement an API that will have a business logic in there, a great business logic with data processing as well, what should be used for this case?\nI researched a lot and managed to understand a little about routers and urlpatterns but I didn't understand which one about views.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5761,"Q_Id":60115855,"Users Score":11,"Answer":"Summarizing: on one hand you have the APIView, which is the most generic of the three, but also in which you must do almost all business logic 'manually'. You have the class methods mapping http methods (get, post, ...) plus some class attributes to configure things like authentication, rendering, etc.\nOften you'll be developing endpoints to interact with resources (entities, like Users, Products, Orders, etc.) via CRUD operations, and that is what ViewSet is for: they have more semantic class methods like list, create, retrieve ... that the router can then automatically map to urls and http methods at the expense of making some assumptions: for example, the retrieve assumes the http call to be GET \/you_resource\/<pk>. It is more rigid than a generic APIView but it takes away from you some boilerplate\/manual config that you would have to repeat again and again in most cases.\nOne step further is the ModelViewSet, which is an extension of the ViewSet for when you are working with Django models. Just specifying a serializer_class and a queryset you have all the CRUD operations of the ViewSet ready to go. Obviously, you can also add your own methods to a ViewSet or customize the behavior of its default methods.\nIn my experience, it pays off to use ViewSets. The code looks cleaner and you avoid some boilerplate code. The assumptions it makes are reasonable, and I would even say that you probably will end up with a cleaner API design following them.","Q_Score":5,"Tags":"python,django,serialization,django-rest-framework","A_Id":60121034,"CreationDate":"2020-02-07T14:55:00.000","Title":"Difference between ViewSet, ModelViewSet and APIView","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a large macro enabled workbook that processes data and exports it in a usable format. Some of the data that it processes can be large and take a while to run through the workbook. I'd like to be able to open this workbook multiple times to process multiple data sets at once. Is there any way that this can be done? \nI am using a python 3 app that I developed to manage the books and am more than open to using other languages and software.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":165,"Q_Id":60116133,"Users Score":1,"Answer":"Think about your problem here.\nAssuming the workbook that processes the data is essentially a model, with input and output, what you could simply do is make copies of that workbook ahead of i\/o model run.\nSo you've gout 1-10,000 rows of data for Model1.xlsm 10,001-20,000 rows of data for Model2.xlsm.\nObviously this is hackneyed, but the fact that you have to do this with Excel and not just use python for calculation means this is probably the easiest way to overcome the problem.","Q_Score":0,"Tags":"python,excel,vba","A_Id":60116365,"CreationDate":"2020-02-07T15:11:00.000","Title":"Any way to run multiple instances of the same excel workbook with macros?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am appending different dataframes to make one set. Occasionally, some values have the same index, so it stores the value as a series. Is there a quick way within Pandas to just overwrite the value instead of storing all the values as a series?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":245,"Q_Id":60116827,"Users Score":0,"Answer":"You weren't very clear guy. If you want to resolve the duplicated indexes problem, probably the pd.Dataframe.reset_index() method will be enough. But, if you have duplicate rows when you concat the Dataframes, just use the pd.DataFrame.drop_duplicates() method. Else, share a bit of your code with or be clearer.","Q_Score":0,"Tags":"python,pandas","A_Id":60117514,"CreationDate":"2020-02-07T15:51:00.000","Title":"How to append rows to a Pandas dataframe, and have it turn multiple overlapping cells (with the same index) into a single value, instead of a series?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For ray remote jobs, I can see stderr gets printed to the driver session.\nHowever, is there a way to get the stdout for remote jobs? Checking individual job logs can be very useful for debugging.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":560,"Q_Id":60118071,"Users Score":3,"Answer":"If you are using Mac, try checking the path\n\/tmp\/ray\/session_latest\/logs\/*.\nThis should contain stdout and stderr of the Ray cluster. \nNote that the ray directory is probably removed if your cluster is shut down.","Q_Score":2,"Tags":"python-3.x,ray","A_Id":60130355,"CreationDate":"2020-02-07T17:09:00.000","Title":"Where does ray stdout go?","Data Science and Machine Learning":0,"Database and SQL":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":"For example if I have 10 indices with similar names and they all alias to test-index, how would I get test-index-1 test-index-2 test-index-3 test-index-4, test-index-5, test-index-6, test-index-7, test-index-8, test-index-9, and test-index-10 to all point to the mapping in use currently when you to a GET \/test-index\/_mapping?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":60118420,"Users Score":0,"Answer":"Not sure what you define as  'unified' mapping - but you can always use wildcards in mapping request. For example : \/test-inde*\/_mapping would give mapping of all indices in that pattern .","Q_Score":1,"Tags":"javascript,python,elasticsearch,curl,elasticsearch-py","A_Id":60120743,"CreationDate":"2020-02-07T17:33:00.000","Title":"Is there a way to get one, unified, mapping from all indices under one alias?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write a large dask array (46 GB with 124 --  370 MB chunks) to a zarr file using dask. If my dask array was named dask_data, then a simple dask_data.to_zarr(\"my_zarr.zarr\") would work. But from what I understand, this is a synchronous, CPU bound process.\nWhat I would like to do is to use parallelism with much of the work allocated to a Quadro GV100 GPU. I tried to convert the numpy.ndarray to a cupy.ndarray via dask_data_cupy = dask_data.map_blocks(cupy.asarray) and write this out to a zarr file, but I receive: ValueError: object __array__ method not producing an array (and frankly, I do not see a performance boost either).\nHow could I go about using a GPU to parallelize writing a dask array to a zarr file?\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":634,"Q_Id":60119406,"Users Score":1,"Answer":"I think you would need to add dask_data.map_blocks(cupy.asnumpy) before calling to_zarr.\nCuPy tries to make sure that the user intended to do a device to host transfer (as these can be expensive). So intentionally raises when numpy.asarray is called on a CuPy array (as would happen during this write).","Q_Score":1,"Tags":"python,python-3.x,dask,cupy,zarr","A_Id":60121331,"CreationDate":"2020-02-07T18:49:00.000","Title":"How to write a large dask array (numpy.ndarray) to a Zarr file leveraging GPUs?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write a large dask array (46 GB with 124 --  370 MB chunks) to a zarr file using dask. If my dask array was named dask_data, then a simple dask_data.to_zarr(\"my_zarr.zarr\") would work. But from what I understand, this is a synchronous, CPU bound process.\nWhat I would like to do is to use parallelism with much of the work allocated to a Quadro GV100 GPU. I tried to convert the numpy.ndarray to a cupy.ndarray via dask_data_cupy = dask_data.map_blocks(cupy.asarray) and write this out to a zarr file, but I receive: ValueError: object __array__ method not producing an array (and frankly, I do not see a performance boost either).\nHow could I go about using a GPU to parallelize writing a dask array to a zarr file?\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":634,"Q_Id":60119406,"Users Score":2,"Answer":"But from what I understand, this is a synchronous, CPU bound process.\n\nThis is probably not true, your bottleneck is likely the storage device. In any case, each chunk is written to a separate file, and in parallel across threads and\/or processes (depending on your setup). That is the whole point of the design of zarr, that an application can interact with each chunk independently. \nYou may be CPU bound if you choose to use various encodings of compression; however these do not necessarily lend themselves to GPU operation. \nIn short, unless your data is already generated on the GPU, I would be surprised if transferring it to the GPU for processing before writing it to files is worth the while. If there were a function to directly read\/write cupy arrays to zarr, and your were also processing on the GPU, it would be different - but I don't believe there is.","Q_Score":1,"Tags":"python,python-3.x,dask,cupy,zarr","A_Id":60121482,"CreationDate":"2020-02-07T18:49:00.000","Title":"How to write a large dask array (numpy.ndarray) to a Zarr file leveraging GPUs?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating an app with Django as the backend and React as the front-end. I already have the back-end built out, and now I'm trying to build out the React components. \nMy problem is this- right now I have my static files hosted on AWS. So every time I make a change to a component, I need to run collectstatic through django in order for my Django template to read the updated Main.js file.\nHas anyone encountered this issue before? I am new to React, so I may be missing a very simple solution.\nThanks!!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":137,"Q_Id":60120899,"Users Score":1,"Answer":"Its a necessity.\nInstead I would recommend only pushing to the AWS after you have tested and need the change(s) to be live.","Q_Score":0,"Tags":"python,django,reactjs,amazon-web-services","A_Id":60128382,"CreationDate":"2020-02-07T20:50:00.000","Title":"Django\/React - Static Main.js file with AWS hosting staticfiles","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am receiving a string as an input, and that will determine the file associated with the function needed.\ni.e. If I receive \"File1\" I want to use File1.function(), if I receive \"File2\" I want to use File2.function.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":60121173,"Users Score":0,"Answer":"You may use the execfile() or os.system() but this is dangerous if the filename comes from an untrusted source. Do never do this in public internet!","Q_Score":0,"Tags":"python,string,filenames","A_Id":60121241,"CreationDate":"2020-02-07T21:16:00.000","Title":"How can I use a string input to determine file name?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I blit surfaces in my pygame file but the problem is they just stay there. My (hopefully temporary) solution was to just move them far off the window when they aren't in use (i.e. (-5000,0) ), but this decreases performance every time I blit a new surface. Is there any way to delete them? del doesn't seem to do it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":219,"Q_Id":60121997,"Users Score":1,"Answer":"The memory of a Surface is freed when there is no reference to it anymore, when Python's garbage collection cleans it.\nYou don't need to use del, just make your program so that you don't refer to unused surfaces anywhere. You can assign None to it if not else.\nSometimes you don't need to keep creating new surfaces all the time but can just use the ones that you already have. But it works fine also to create new and have Python clear the old. I've written some screensaver like Pygame visualizers for VJing and installations way back and have had them running for days, constantly adding new images to the screen and removing old, no memory leaks. And never needed del.","Q_Score":0,"Tags":"python,pygame,pygame-surface","A_Id":60122104,"CreationDate":"2020-02-07T22:30:00.000","Title":"Is there a way to delete Pygame Surfaces? Or any way to remove them from memory to increase performance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"PC features:\nOS: Debian 10 x64\nProcessor: AMD Ryzen 7 2700x\nmotherboard: Rogstrix b450-f\nRam: 16gb \nGPU: ZotaGaming 2070 super.\nI try to run a program,ANFIS whit data set IRIS.\nbut from one moment to another, the processor stops or something similar, also the peripherals stop working, and the ram warning LED turns on.\nI don't understand why, since in Windows this doesn't happen to me. At first I thought it was because run on anaconda virtual environment in Windows, however in Linux even with Dockers, the same problem still occurs to me.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":60123514,"Users Score":0,"Answer":"The problem was in the processor voltage, the configuration of the bios. Change 0.02v to 0.01v,In offset mode. \nIf you keep crashing, Reduce the chipset clock frequency","Q_Score":0,"Tags":"python,process,linux-kernel,out-of-memory,ram","A_Id":60123585,"CreationDate":"2020-02-08T02:52:00.000","Title":"Why a python process in linux shuttdown my Pc and not in Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm writing a short application in python using tkinter. Everything works except for an unexpected pause - it should be generating an event twice a second, but frequently it will pause for 5 or 6 seconds between signals. I've put print statements to find where the delay is, and found it is the following statement:\n\nself.frame.after(ms, self.tick_handler)\n\nms is 500 so this should send the event at around .5 seconds. Usually it does, but frequently it hangs for as much as 5 or 6 seconds before tick_handler() gets the signal. The program is pretty simple, with a single worker thread receiving all input from a single queue, events coming from a single tkinter frame. The after() statement is in the worker thread. I've tried shutting off gc (gc.disable()) but that makes no difference. There is minimal activity outside this on my computer.\nIf I send other input during the pause using mouse or keys it is handled immediately, so the worker thread is not blocked. It looks as if the signal request is received but not fired for some time. I know I can't expect real time performance so .6 seconds wouldn't be noteworthy, but 6.0 seconds?\nThis is the first time I've worked with tkinter. Is there something I am missing about event handling?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":60123791,"Users Score":0,"Answer":"I Think You Did Not Include tkinter.mainloop() At The End\nPS: I'm Not Sure...","Q_Score":0,"Tags":"python,events,tkinter","A_Id":60125600,"CreationDate":"2020-02-08T03:55:00.000","Title":"delay in setting 'after' function in python tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a chat server in python. I have been creating threads fine so far, but when I try to create one, with the argument of a username, it fails with the above error - but only when the username is more than 1 character.\nIf I give it the username \"A\", it works fine, but the username \"Alex\" gives the error. How do I fix this?\nThey are in the same class.\nI create the thread with\nThread(target=Main.ManageClientHighLevel, args=(Username)).start()\nAnd the start of that function is:\ndef ManageClientHighLevel(Username):\nHow do I fix this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":166,"Q_Id":60125933,"Users Score":1,"Answer":"You must convert Username to a tuple: (Username,) since a string is an interable, which means that \"username\" would actually be considered as \"(u,s,e,r,n,a,m,e)\".","Q_Score":0,"Tags":"python,python-3.x,multithreading,python-multithreading","A_Id":60125964,"CreationDate":"2020-02-08T10:33:00.000","Title":"Can't create thread because \"Takes 1 positional argument but 4 given\" only when I give it a string longer than 1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a seq2seq neural network which I use for translating text. I need the sentences to remain the same during batches, more exactly, a sentence should be like an inseparable block of tokens. However, it looks like the iterators provided by Torchtext (BucketIterator and Iterator) do not keep the initial order of the tokens. Is there a solution to this, except of writing my own padding and batching functions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":164,"Q_Id":60127422,"Users Score":0,"Answer":"Both Iterator and BucketIterator should keep the order of tokens and only shuffle the sentences in the dataset.\nYou very likely have your input tensors in an incorrect shape. The default shapes in TorchText are: length \u00d7 batch_size \u00d7 features. If you have the batch first and sequence length the second, your sentences got shuffled.","Q_Score":0,"Tags":"python,deep-learning,dataset,recurrent-neural-network,torchtext","A_Id":60147116,"CreationDate":"2020-02-08T13:50:00.000","Title":"Torchtext keep tokens in the same order","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a webmap which is made in python using Folium.  I am adding various geojson layers from an underlying database.  I would like to do spatial analysis based on the user's location and their position relative to the various map overlays.  As part of this I want to display a marker on the map which indicates the user's current position, and which updates regularly as they move around.\nI know how to add markers to the map from within python, using Folium.\nI know how to get a constantly updating latitude \/ longitude of the user using JS \nnavigator.geolocation.watchPosition(showPosition)\nwhich then passes a position variable to the function showPosition.\nI am currently just displaying this as text on the website for now.\nWhat I have not been able to do is to add a marker to the Folium map from inside the webpage, using JS\/Leaflet (as Folium is just a wrapper for Leaflet, i think I should be able to do this).  \nThe Folium map object seems to be assigned a new variable name every time the webpage is loaded, and I don't know how to \"get\" the map element and add a marker using the Leaflet syntax \nL.marker([lat, lon]).addTo(name_of_map_variable_which_keeps_changing)\nAlternatively there might be a way to \"send\" the constantly changing lat\/lon variables from the webpage back to the python script so that I can just use folium to add the marker.  \nBut I have been unable to figure this out or find the right assistance online and would appreciate any help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1042,"Q_Id":60127471,"Users Score":0,"Answer":"OK, I have figured out a main part of the question - how to add a user location marker to the Folium map.  It is actually very simple:\nhttps:\/\/python-visualization.github.io\/folium\/plugins.html#folium.plugins.LocateControl\nI am still unable to pass the user's lat\/lon through to my python script so that I can perform spatial queries using that location.  So am looking forward to anyone being able to answer that part.  Though I may have to post that as a separate question perhaps...","Q_Score":0,"Tags":"javascript,python,geolocation,leaflet,folium","A_Id":60205173,"CreationDate":"2020-02-08T13:56:00.000","Title":"How do I add a mobile geolocation marker into a Folium webmap that automatically updates position?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to periodically clear the output of a cell in Google Colab, which runs a local python file with !python file.py\nI've tried the answers to this question on stackoverflow:\nfrom google.colab import output\n output.clear()\nand\nfrom IPython.display import clear_output\nclear_output()\nBoth of those work if i run them in a cell directly and not via a local file.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13621,"Q_Id":60127913,"Users Score":0,"Answer":"IPython is for Jupyter mainly and it should work in Colab for a local file if implemented correctly. Don't forget to import the library in the main python code.","Q_Score":7,"Tags":"python,jupyter-notebook,ipython,google-colaboratory","A_Id":62492820,"CreationDate":"2020-02-08T14:49:00.000","Title":"How to clear the output in Google Colab via code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to activate a virtual environment using pip virtualenv package. However, when type the following line on cmd (windows 10) it says that activate command is not recognized. virtualenv package is already installed, but for some reason I can only use it when I open the cmd as an administrator.\nC:\\Users\\dequi\\Desktop\\servidor\\venv\\Scripts>activate\n\"activate\" no se reconoce como un comando interno o externo,\nprograma o archivo por lotes ejecutable.\nC:\\Users\\dequi\\Desktop\\servidor\\venv\\Scripts>\nI appreciate any help with this issue. Thank you!","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":2019,"Q_Id":60130431,"Users Score":-2,"Answer":"Have you tried: source \/path\/to\/my\/venv\/bin\/activate ?","Q_Score":2,"Tags":"python,virtualenv","A_Id":60130535,"CreationDate":"2020-02-08T19:32:00.000","Title":"activate virtualenv command not recognized","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"import cx_Freeze\nTraceback (most recent call last):\n  File \"\", line 1, in \n    import cx_Freeze\nModuleNotFoundError: No module named 'cx_Freeze'","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":198,"Q_Id":60130439,"Users Score":1,"Answer":"Have you installed cx_freeze with pip ?\nIf yes please try to upgrade cx_freeze\npip install --upgrade cx_freeze\nIf none of this not working, please try the following:\nRun python.exe cxfreeze-postinstall from the command prompt, two batch files are being created in the Python scripts directory:\ncxfreeze.bat\ncxfreeze-quickstart.bat\nFrom that moment on, you should be able to run cx_freeze.","Q_Score":0,"Tags":"python","A_Id":60130475,"CreationDate":"2020-02-08T19:33:00.000","Title":"error import cx_Freeze how i can resolve?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried the following steps after the installation of Anaconda's latest version. I am not able to get the autocomplete feature working...\nAny suggestions on what else I need to try...\nStep 1\n 1) pip install jupyter_contrib_nbextensions\n 2) pip install jupyter_nbextensions_configurator\n 3) jupyter contrib nbextension install --user \n 4) jupyter nbextensions_configurator enable --user\nStep 2: Open jupyter notebook\n - click on nbextensions tab\n - unckeck disable configuration for nbextensions without explicit compatibility\n - put a check on Hinterland","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":11450,"Q_Id":60131686,"Users Score":1,"Answer":"Out of frustration,\nI moved to Spyder 4.0.1 and installed Kite.\nBeen quite frustrating...","Q_Score":7,"Tags":"python,jupyter-notebook,anaconda","A_Id":60324373,"CreationDate":"2020-02-08T22:09:00.000","Title":"Autocomplete in Jupyter notebook not working","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried the following steps after the installation of Anaconda's latest version. I am not able to get the autocomplete feature working...\nAny suggestions on what else I need to try...\nStep 1\n 1) pip install jupyter_contrib_nbextensions\n 2) pip install jupyter_nbextensions_configurator\n 3) jupyter contrib nbextension install --user \n 4) jupyter nbextensions_configurator enable --user\nStep 2: Open jupyter notebook\n - click on nbextensions tab\n - unckeck disable configuration for nbextensions without explicit compatibility\n - put a check on Hinterland","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":11450,"Q_Id":60131686,"Users Score":6,"Answer":"One of the reasons behind this issue can be the crashes of kernel when you try to use the autocompletion. I faced this issue and by observing the logs generated in the terminal used to open jupyter found that every time I try to use the autocompleter, kernel crashes. with the following solution, I resolved the issue in macOs 11.1 Big Sur.\nYou can just set the Ipython to use something else rather than jedi to do the completion task like pyreadline which can be installed by pip3 install pyreadline . But first you have to disable jedi in the Ipython kernel with the following command:\n\n%config IPCompleter.use_jedi = False\n\nThis command will resolve the issue in the current session and if you want to change this configuration in the config file of Ipython kernel you can use the following commands:\n\nipython profile create\n\nmaking a new config file for the ipython in the following directory:\n\/Users\/zhivarsourati\/.ipython\/profile_default\nand you can append the following line to the file ipython_kernel_config.py generated with the previous command:\n\nc.IPCompleter.use_jedi = False","Q_Score":7,"Tags":"python,jupyter-notebook,anaconda","A_Id":65773234,"CreationDate":"2020-02-08T22:09:00.000","Title":"Autocomplete in Jupyter notebook not working","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a database that is made of (3862900,19), each column is a different parameter and includes outliers, is it possible to detect outliers in each column simultaneously, or do I have to repeat it 19 times for each column?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":60132600,"Users Score":1,"Answer":"Yes, It is possible to detect outliers in each column simultaneously","Q_Score":0,"Tags":"python,pandas,jupyter-notebook,random-forest,outliers","A_Id":60132922,"CreationDate":"2020-02-09T00:48:00.000","Title":"Isolation Forest large dataset","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Getting below error when trying to launch jupyter notebook. Any help to address this error is appreciated. \n\n_cffi_ext.c C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\zmq\\backend\\cffi__pycache___cffi_ext.c(213):\n  fatal error C1083: Cannot open include file: 'sys\/un.h': No such file\n  or directory Traceback (most recent call last):   File\n  \"C:\\Users\\emathew004\\anaconda3\\Scripts\\jupyter-notebook-script.py\",\n  line 6, in \n      from notebook.notebookapp import main   File \"C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\notebook\\notebookapp.py\",\n  line 47, in \n      from zmq.eventloop import ioloop   File \"C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\zmq__init__.py\",\n  line 47, in \n      from zmq import backend   File \"C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\zmq\\backend__init__.py\",\n  line 40, in \n      reraise(*exc_info)   File \"C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\zmq\\utils\\sixcerpt.py\",\n  line 34, in reraise\n      raise value   File \"C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\zmq\\backend__init__.py\",\n  line 27, in \n      _ns = select_backend(first)   File \"C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\zmq\\backend\\select.py\",\n  line 28, in select_backend\n      mod = import(name, fromlist=public_api)   File \"C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\zmq\\backend\\cython__init__.py\",\n  line 6, in \n      from . import (constants, error, message, context, ImportError: DLL load failed: The specified module could not be found","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1093,"Q_Id":60132755,"Users Score":0,"Answer":"I've also had this problem,  which I solved as follows.\n\nconda uninstall pyzmq (uninstall pyzmq)\nconda install pyzmq (reinstall pyzmq)\nconda install jupyter (reinstall jupyter)","Q_Score":0,"Tags":"python,jupyter-notebook,anaconda","A_Id":60132798,"CreationDate":"2020-02-09T01:24:00.000","Title":"DLL Error when trying to launch Jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Getting below error when trying to launch jupyter notebook. Any help to address this error is appreciated. \n\n_cffi_ext.c C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\zmq\\backend\\cffi__pycache___cffi_ext.c(213):\n  fatal error C1083: Cannot open include file: 'sys\/un.h': No such file\n  or directory Traceback (most recent call last):   File\n  \"C:\\Users\\emathew004\\anaconda3\\Scripts\\jupyter-notebook-script.py\",\n  line 6, in \n      from notebook.notebookapp import main   File \"C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\notebook\\notebookapp.py\",\n  line 47, in \n      from zmq.eventloop import ioloop   File \"C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\zmq__init__.py\",\n  line 47, in \n      from zmq import backend   File \"C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\zmq\\backend__init__.py\",\n  line 40, in \n      reraise(*exc_info)   File \"C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\zmq\\utils\\sixcerpt.py\",\n  line 34, in reraise\n      raise value   File \"C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\zmq\\backend__init__.py\",\n  line 27, in \n      _ns = select_backend(first)   File \"C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\zmq\\backend\\select.py\",\n  line 28, in select_backend\n      mod = import(name, fromlist=public_api)   File \"C:\\Users\\emathew004\\anaconda3\\lib\\site-packages\\zmq\\backend\\cython__init__.py\",\n  line 6, in \n      from . import (constants, error, message, context, ImportError: DLL load failed: The specified module could not be found","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1093,"Q_Id":60132755,"Users Score":0,"Answer":"You need a corresponding version of visual c++ redistribution.","Q_Score":0,"Tags":"python,jupyter-notebook,anaconda","A_Id":65622837,"CreationDate":"2020-02-09T01:24:00.000","Title":"DLL Error when trying to launch Jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been searching for a long time for a method to pull the p-value for LDA and QDA models without success.\nI know I can use the summary function from statsmodel for linear and logistic regression but I think this does not apply to the above regressions.\nWould appreciate your help with this\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":338,"Q_Id":60135064,"Users Score":1,"Answer":"Summary shows how statistically significant the model coefficients are. Actually, LDA and QDA don't estimate any coefficients as logictic regression does. Therefore, it's impossible to measure the coefficients performance of LDA and QDA.","Q_Score":1,"Tags":"python,python-3.x","A_Id":65026134,"CreationDate":"2020-02-09T09:14:00.000","Title":"p-values for Linear Discriminant and Quadratic Discriminant analyses (LDA, QDA)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a Client with Java and a Server with Python. The Java client receive data using readUTF() of the class DataInputStream. My problem is that the function readUTF() expects a modified version of 'utf-8' that I don't know how to generate in the (Python) server side.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":60135995,"Users Score":0,"Answer":"I got it!. Using the function read() of the class DataInputStream do work. The problem was that I initialized the destination buffer like this: byte[] ans = {}, instead of allocating some bytes. Thanks for everyone!","Q_Score":0,"Tags":"java,python,sockets,utf-8","A_Id":60140280,"CreationDate":"2020-02-09T11:13:00.000","Title":"Convert String into the format that readUTF() expects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Node project that's bundled and added to Github as releases.  At the moment, it checks my Github for a new release via the API and lets the user download it.  The user must then stop the Node server, unzip the release.zip to the folder and overwrite everything to update the project.\nWhat I'm trying to do is write a Python script that I can execute in Node by spawning a new process.  This will then kill the Node server using PM2, and then Python script will then check the Github API, grab the download url, downloads it, unzips the contents to the current folder, deletes the zip and then starts up the Node server again.\nWhat I'm struggling with though is checking the Github API and downloading the latest release file.  Can anyone point me in the right direction?  I've read that wget shouldn't be used in Python, and instead use urlopen","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":60137429,"Users Score":0,"Answer":"You need to map out your workflow and dataflow better.  You can do it in words or pictures.  If you can express your problem clearly and completely in words step by step in list format in words, then translate it to pseudocode.  Python is great because you can go almost immediately from a good written description, to pseudocode, to a working implementation.  Then at least you have something that works, and you can optimize performance, simplify functionality or usability from there.  This is the process of translating a problem into a solution.     \nWhen asking questions on SO, you need to show your current thinking, what you've already tried, preferably with your code that doesn't yet work, or work the way you need it to work.  People can vote you down and give you negative reputation points if you ask a question with just a vague description, a question that is an obvious cry for help with homework (yours is not that), or a muse or a vague question with not even an attempt at a solution, because it does not contribute back to the community in any way. \nDo you have any code or detailed pseudocode steps for checking the GitHub API and checking for the \"latest release\" of file(s) you are trying to update?","Q_Score":0,"Tags":"python,python-3.x","A_Id":60137925,"CreationDate":"2020-02-09T14:05:00.000","Title":"Download latest version from Github, unzip to folder and overwrite contents?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently uninstalled Anaconda 3 as it was giving me issues but after installing it and trying to use the latest Anaconda3-2019.10 for Windows I got the \"Failed to create Anaconda menus\" error each time i installed.   I check PATHs, checked and cleaned registry and still not hope.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":133,"Q_Id":60138608,"Users Score":0,"Answer":"SOLUTION: Some how re-installing the exact same old version of Anaconda3-5.2.0-Windows-x86_64 worked!\nI cannot explain it.","Q_Score":0,"Tags":"python,anaconda","A_Id":60138609,"CreationDate":"2020-02-09T16:10:00.000","Title":"(Alternative solution) Issues with Anaconda install - Failed to create Anaconda menus","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create Skype patcher with replaced font (stock is incorrectly displaying japanese kanji as chinese equivalent) for Windows. Maybe Python is not the best options, but current problem is not related with Python itself: asar utility produces output with readonly permissions, and changing permission attempt can't do anything. But, maybe, os.chmod is just not working on Windows?\n\n\nimport tkinter as tk\nfrom tkinter import filedialog\nimport subprocess\nimport os\nimport shutil\n\n\ndef change_permissions_recursive(path, mode):\n    for root, dirs, files in os.walk(path, topdown=False):\n        for dir in [os.path.join(root,d) for d in dirs]:\n            os.chmod(dir, mode)\n    for file in [os.path.join(root, f) for f in files]:\n            os.chmod(file, mode)\n\n\nroot = tk.Tk()\nroot.withdraw()\ndir_path = filedialog.askdirectory(initialdir=\"C:\\Program Files (x86)\\Microsoft\\Skype for Desktop\")\ncmd = \"asar.cmd extract \\\"\" + dir_path + \"\/resources\/app.asar\\\" tmp\/app\"\nprocess = subprocess.Popen(cmd, stdout=subprocess.PIPE, creationflags=0x08000000, cwd=\"utils\")\nprocess.wait()\nchange_permissions_recursive(\"utils\/tmp\/app\/fonts\", 0o777)\nshutil.copyfile(\"utils\/meiryo.ttf\", \"utils\/tmp\/app\/fonts\")","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":487,"Q_Id":60139536,"Users Score":0,"Answer":"Something wrong with shutil.copy itself: when rewrite same logic with powershell, all works as expected","Q_Score":0,"Tags":"python,file-permissions","A_Id":60140996,"CreationDate":"2020-02-09T17:48:00.000","Title":"Python chmod for windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am creating a file input.txt to store my input and while running my py script file from cmd. I want it to take input from that file, just like we can do something like that in c++.\na.exe < input.txt\nHow can we do something similar in python?","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1309,"Q_Id":60140166,"Users Score":2,"Answer":"Python works the same way. a.py < input.txt and python a.py < input.txt both work. You can read the file with sys.stdin or the input() function.","Q_Score":1,"Tags":"python","A_Id":60140205,"CreationDate":"2020-02-09T18:54:00.000","Title":"Provide stdin input from file in cmd?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I just installed ubuntu 18.04 and I really don't know how does everything work yet. I use the last version of python in my windows system (3.8.1) and would like to use that version as well in ubuntu, but the \"pre-installed\" version of python is 2.7. Is there a way to uninstall that old version of python instead of changin the alias of the python command to match the version I want to use? Can you do that or does ubuntu need to have that version? If you could help me or explain this to me I would appreciate it.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1368,"Q_Id":60141248,"Users Score":0,"Answer":"Some services and application in Ubuntu use Python 2.x to run. It is not advisable to remove it. Rather, virtual environments maybe a good practice. There, you can work on Python 3.x, as per your needs, without messing up with the system's dependencies.","Q_Score":0,"Tags":"python,linux,ubuntu,version","A_Id":60146024,"CreationDate":"2020-02-09T20:57:00.000","Title":"Change default version of python in ubuntu 18.04","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When i install (upgrade) to the new version of Python (3.8.1 in this case) i need to install the packages again such as:\n\nrequests\npandas\nsklearn\nmatplotlib\n\netc...\n(i have to do pip install moduleName for each one).\nThis is not the first time such has happenned.\nHow does one execute the installation of a new version without having to re-install the packages ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":60141866,"Users Score":0,"Answer":"Before you upgrade in a terminal run, \npip freeze > requirements.txt\nThis will store the names and versions of all your downloaded modules in a requirements.txt file in the current directory. Then after your new version of python is downloaded cd back into that directory and run \npip install -r requirements.txt\nThis will re-install all of your modules without having to enter them in one by one.","Q_Score":0,"Tags":"python-3.x,pip","A_Id":60142317,"CreationDate":"2020-02-09T22:15:00.000","Title":"When i install a new version of python i need to install the packages again","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am fairly new to the programming world so I downloaded the latest version of python (3.8.1) and and Pycharm as my IDE.\nRecently I wanted to add some packages (for example numpy) but found out im not able to. For some reason it wont recognize my pip (in the cmd) but for some weird reason Pycharm shows that there is a version of it (19.0.3). \nThat doesnt makes sence since in the cmd I cant find a version of it and even when I try to upgrade it from pycharm it still shows a warning that I might have the wrong version of it (I know the latest is 20.0.2). Thus I am unable to install any python package whatsoever (from cmd or pycharm). \nI have tried reseting my python installation and my pycharm's configuration but I havent made any progress. Are there any posible solutions for an amateur like me?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":60142872,"Users Score":0,"Answer":"Brother that is great progress. I had issues like yours too, first learn how to set up a virtual environment for your project. You can install any package there for your project which will not interfere with other projects. Next set your pycharm's base interpreter to that environments bin\/python. Hopefully it will resolve your issues.","Q_Score":1,"Tags":"python,pip,pycharm","A_Id":60143677,"CreationDate":"2020-02-10T01:01:00.000","Title":"Problem with installing any package in Pycharm Community Edition 2019.3.3 64 bit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to DB\/postgres SQL.\nScenario: \nNeed to load an csv file into postgres DB. This CSV data needs to loaded into multiple tables according DB schema. I'm looking for better design using python script.\nMy thought:\n1. Load CSV file to intermediate table in postgres\n2. Write a trigger on intermediate table to insert data into multiple tables on event of insert\n3. Trigger includes truncate data at end\nAny suggestions for better design\/other ways without any ETL tools, and also any info on modules in Python 3.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":743,"Q_Id":60143750,"Users Score":1,"Answer":"Rather than using a trigger, use an explicit INSERT or UPDATE statement. That is probably faster, since it is not invoked per row.\nApart from that, your procedure is fine.","Q_Score":0,"Tags":"sql,python-3.x,postgresql,database-design,triggers","A_Id":60145699,"CreationDate":"2020-02-10T03:33:00.000","Title":"How to load csv file to multiple tables in postgres (mainly concerned about best practice)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training an text generation model with Generative adversarial networks.\nAs a common method, I used tf.clip_by_global_norm() to avoid gradient problems. However, even I used gradient clipping, I am still facing gradient exploding problem with error caused by tf.clip_by_global_norm() function.\nThe document says: If global_norm == infinity then the entries in t_list are all set to NaN to signal that an error occurred.\nI can hardly find the origin of problem with this situation since I believed that tf.clip_by_global_norm definitely avoid the gradient problem.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":60145905,"Users Score":0,"Answer":"Have you tried tf.clip_by_value? You could set clip_value_min to be -1 and the max to be 1.\nIf you're using an embedding matrix for your text, the embedding values shouldn't get larger than 1\nAlso as an aside, people have tried using GAN's for text generation, and the results aren't very good","Q_Score":0,"Tags":"python,tensorflow,deep-learning","A_Id":60146528,"CreationDate":"2020-02-10T07:34:00.000","Title":"Adversarial text generation with gradient clipping, still facing gradient explosion","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Django web app which currently uses HTML templates with CSS styling. Fairly typical for a Django app. I've been looking to create a more animated GUI for this app and was looking to Kivy to do this. Is it possible to combine these two frameworks to coexist in the same app?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":972,"Q_Id":60146791,"Users Score":0,"Answer":"This can be achieved using Django Serializing, Where you can connect asynchronously with Django models. As per my understanding you want use Django models to fetch data right? Django Serializing will convert models into required format xml, json","Q_Score":1,"Tags":"python,django,kivy","A_Id":63215065,"CreationDate":"2020-02-10T08:44:00.000","Title":"Can I create a Kivy GUI for my Django Web App?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Why is it standard in Python to have the main() function and the if __name__ == '__main__' check at the end of the block of code? It also seems standard for the abstraction of the functions to follow the same pattern upwards. What I mean is that the definition of the function to be executed by main() is above the main() and the definition of the functions inside that are above and so on..\nThat seems odd because when one opens the module to read the code, it ends up starting with low-level code and moves up to higher level functions. Isn't it hard to grasp what the module is doing that way?\nWhy not do the alternative? Have the if __name__ check at the top followed by the main() function, and so on. This way, one quickly glances at what the main() function does and understands what the code is about.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2503,"Q_Id":60146902,"Users Score":0,"Answer":"The purpose of an if __name__ == '__main__': guard is to prevent a module from having side-effects when it's imported.\nThe fact that it is a module rather than a script implies that it will normally be used by other code importing the definitions from it, not executed directly. So given that, it makes sense that the functions, classes and constants appear first in the source code, since those are what users of the module will be importing (and hence, what they might want to see the source of).\nSo even if the code guarded by if __name__ == '__main__': doesn't rely on the definitions in the module already having been evaluated (which would be unusual), this part of the code is usually the least important to the users of the module, so it doesn't belong at the start of the file.","Q_Score":3,"Tags":"python,python-3.x","A_Id":60146980,"CreationDate":"2020-02-10T08:52:00.000","Title":"Why not place if __name__ == '__main__' at the beginning of the module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to write a short python script which fetches data from Google Places API and exports it as a .csv file. \nUnfortunately I'm stuck right at the beginning. \nI want to use requests package but my machine cannot find it. \nI've installed Python 3.5 on my Mac and when I use pip to install requests it says: \n\nRequirement already satisfied: requests in \/Library\/Frameworks\/Python.framework\/Versions\/3.5\/lib\/python3.5\/site-packages\n\nBut when I run the program I get an import error which says: \n\nImportError: No module named requests\n\nDo you have any ideas how i can fix this issue? \nThanks in advance. \nMuch love.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":57,"Q_Id":60147769,"Users Score":1,"Answer":"Use python -m pip install requests instead. Your pip installation was probably for a different version.","Q_Score":0,"Tags":"google-api,python-requests","A_Id":60185360,"CreationDate":"2020-02-10T09:52:00.000","Title":"Fetch Google Places Data using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with responder the python web framework and trying to get remote_addr.\nI looked req.header but there's no data. No client or remote_addr field in req.\nAnd I googled for a while but I didn't get any information.\nHow can I solve this problem?\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":60148527,"Users Score":0,"Answer":"First argument of the handler (declare it req commonly) stores starlette.requests.Request in req._starlette.\nSo we can get remote_addr by looking at req._starlette.client.host.\nAdditionally, we can get remote_addr from WebSocket object by ws.scope[\"client\"][0] (index 1 is the port).","Q_Score":0,"Tags":"python,web,server,frameworks,web-frameworks","A_Id":60149603,"CreationDate":"2020-02-10T10:34:00.000","Title":"How to get remote_addr with responder?","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 my own 3d engine, I need to import 3d models into it, but I don't know how to do it.\nI wonder if it is possible to convert a 3d model into an array of points; if it is possible, how do you do it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":966,"Q_Id":60148560,"Users Score":0,"Answer":"This isn't something I've done before; but the premise is interesting so I thought I'd share my idea as I have worked with grids (pretty much an array) in 3D space during my time at university.\nIf you consider 3D space, you could represent that space as a three dimensional array quite simply with each dimension representing an axis. You could then treat each element in that array as a point in space and populate that with a value (say a Boolean of true\/false, 1\/0) to identify the points of your model within that three dimensional space.\nAll you'd need is the Height, Width and Depth of your model, with each one of these being the dimensions in your array. Populate the values with 0\/false if the model does not have a point in that space, or 1\/true if it does. This would then give you a representation of your model as a 3D array.","Q_Score":1,"Tags":"python,arrays,3d","A_Id":60148809,"CreationDate":"2020-02-10T10:36:00.000","Title":"How to convert a 3d model into an array of points","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to add someone to a specific server and then DM said person with just the discord ID.\nThe way it works is that someone is logging himself in using discord OAuth2 on a website and after he is logged in he should be added to a specific server and then the bot should DM saying something like Welcome to the server! \nHas anyone an idea how to do that?\nThanks for any help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":60149133,"Users Score":0,"Answer":"It is not possible to leave or join servers with OAuth2. Nor is it possible to DM a user on Discord with a bot unless they share a mutual server.","Q_Score":1,"Tags":"python,oauth-2.0,discord,discord.py","A_Id":60342379,"CreationDate":"2020-02-10T11:09:00.000","Title":"Discord.py: Adding someone to a discord server with just the discord 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":"My model (called magazine) has a string field that refers to the location of the image on the hard drive. In flask-admin however, I would like to upload an image to the magazine object instead of a string. Is there a way to specify an image in the model instead of a string?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":124,"Q_Id":60149487,"Users Score":-1,"Answer":"Don't use flask-admin, create the routes and templates yourself so you will have much more freedom with forms","Q_Score":0,"Tags":"python,flask,flask-sqlalchemy,flask-wtforms,flask-admin","A_Id":60149907,"CreationDate":"2020-02-10T11:31:00.000","Title":"How to override the admin model creation form in flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm building a Flask App that analyzes data. I want to use Numba to speed up the algorithm. I have tried on the algorithm with Numba and it works perfectly in the Jupyter Notebook.\nHowever, when I try the code in the Flask app, it fails. It seem likes it cannot access to the function that binds with @numba.jit. Is that means that we cannot use Numba in a Flask app?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":943,"Q_Id":60151595,"Users Score":0,"Answer":"It depends on the operations you perform on the functions. you can perform array and other computation operations which was supported by Numba. Structure your code accordingly to utilize Numba functions.","Q_Score":2,"Tags":"python,flask,numba","A_Id":61823371,"CreationDate":"2020-02-10T13:35:00.000","Title":"Can we use Numba in Flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm building a Flask App that analyzes data. I want to use Numba to speed up the algorithm. I have tried on the algorithm with Numba and it works perfectly in the Jupyter Notebook.\nHowever, when I try the code in the Flask app, it fails. It seem likes it cannot access to the function that binds with @numba.jit. Is that means that we cannot use Numba in a Flask app?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":943,"Q_Id":60151595,"Users Score":1,"Answer":"You should be able to use Numba within a Flask application (I do). The issue sounds like the environment that you are launching Flask from is different than the environment that you are running your Jupyter Notebook from. From within your Flask app, you could try printing the sys.path.","Q_Score":2,"Tags":"python,flask,numba","A_Id":60151756,"CreationDate":"2020-02-10T13:35:00.000","Title":"Can we use Numba in Flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"How can I use 'serializer.initial_data' in Django Rest-API. \nWhat is the difference between using request.data and serializer.initial_data.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2850,"Q_Id":60153223,"Users Score":2,"Answer":"Requests.data contains the data that comes in from the frontend. Arguably, you should leave requests.data alone and use a serializer to convert said data into more complex types. The use cases for serializers are pretty vast ranging, but the most common is translation of data into database model instances.","Q_Score":1,"Tags":"python,django,python-3.x,django-rest-framework","A_Id":60153652,"CreationDate":"2020-02-10T15:12:00.000","Title":"What does 'serializer.initial_data' mean?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on an intelligent embedded system that implemented with an alexnet (kind of shallow cnn) while training my model on colab, I realized that RAM usage is about 10 GB. Does FPGA Support this? How can I reduce RAM usage?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":60155132,"Users Score":2,"Answer":"There are no FPGAs with 10 GB of RAM built-in, but many of them will let you connect that much RAM externally.","Q_Score":0,"Tags":"python,neural-network,fpga,xilinx","A_Id":60162363,"CreationDate":"2020-02-10T17:09:00.000","Title":"Reduce RAM Usage for AlexNet implementation on FPGA","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I have a batch with shape [n, h, w, c] as well as a list of n indices in range of 0-9 and 10 Conv2D convs, that I want to apply to the data depending on the index in the list. The indices list changes with every batch.\nEg. with input x, batch size 4 and indices l=[1,5,1,9] I would like to compute [convs[l[0]](x[0]), convs[l[1]](x[1]), convs[l[2]](x[2]), convs[l[3]](x[3])]\nA naive solution would be to compute every combination and gather based on l. However, this requires 10 times the amount of memory. Is there a better solution to this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":126,"Q_Id":60157547,"Users Score":0,"Answer":"One \"hacky\" solution would be to expand the dimension of the input from [n, h, w, c] to [1, n, h, w, c], then use Conv3D instead with kernel shape [1, x, y]\nIf you have the weights defined separately (weights can also be obtained using layer.weights), you could similarly stack them in the 0th dimension and use them through tf.nn.conv3d.","Q_Score":1,"Tags":"python,tensorflow,keras,tf.keras","A_Id":60165121,"CreationDate":"2020-02-10T20:00:00.000","Title":"Tensorflow switch case in batch dimension with Conv2d","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am an absolute beginner in AWS: I have created a key and an instance, the python script I want to run in the EC2 environment needs to loop through around 80,000 filings, tokenize the sentences in them, and use these sentences for some unsupervised learning. \nThis might be a duplicate; but I can't find a way to copy these filings to the EC2 environment and run the python script in EC2, I am also not very sure as to how I can use boto3. I am using Mac OS.  I am just looking for any way to speed things up. Thank you so so much! I am forever grateful!!!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":136,"Q_Id":60158883,"Users Score":0,"Answer":"Here's one way that might help:\n\ncreate a simple IAM role that allows S3 access to the bucket holding your files\napply that IAM role to the running EC2 instance (or launch a new instance with the IAM role)\ninstall the awscli on the EC2 instance\nSSH to the instance and sync the S3 files to the EC2 instance using aws s3 sync\nrun your app\n\nI'm assuming you've launched EC2 with enough diskspace to hold the files.","Q_Score":0,"Tags":"python,amazon-web-services,machine-learning,amazon-ec2,boto3","A_Id":60159170,"CreationDate":"2020-02-10T21:41:00.000","Title":"Run Python Script on AWS and transfer 5GB of files to EC2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am an absolute beginner in AWS: I have created a key and an instance, the python script I want to run in the EC2 environment needs to loop through around 80,000 filings, tokenize the sentences in them, and use these sentences for some unsupervised learning. \nThis might be a duplicate; but I can't find a way to copy these filings to the EC2 environment and run the python script in EC2, I am also not very sure as to how I can use boto3. I am using Mac OS.  I am just looking for any way to speed things up. Thank you so so much! I am forever grateful!!!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":136,"Q_Id":60158883,"Users Score":0,"Answer":"Here's what I tried recently:\n\nCreate the bucket and keep the bucket accessible for public.\nCreate the role and add HTTP option.\nUpload all the files and make sure the files are public accessible.\nGet the HTTP link of the S3 file.\nConnect the instance through putty.\nwget  copies the file into EC2\ninstance.\n\nIf your files are in zip format, one time copy enough to move all the files into instance.","Q_Score":0,"Tags":"python,amazon-web-services,machine-learning,amazon-ec2,boto3","A_Id":60161528,"CreationDate":"2020-02-10T21:41:00.000","Title":"Run Python Script on AWS and transfer 5GB of files to EC2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":": 1495 : 2020-02-11 11:55:00 (1, 0)\nHere is my sample result but then when I'm trying to split it gives me error\nProcess terminate : 'Attendance' object has no attribute 'split'\nIn the documentation it says \nprint (attendance) # Attendance object\nHow to access it?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":379,"Q_Id":60161858,"Users Score":0,"Answer":"found the solution\ni check in the github repository of pyzk and look for the attendance class and found all the object being return by the live_capture thank you :)","Q_Score":0,"Tags":"python-3.x,zkteco","A_Id":60180951,"CreationDate":"2020-02-11T04:04:00.000","Title":"pyzk how to get the result of live capture","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python and couldn't find this answer online.\nWhen creating a Python Flask application, what exactly determines the Python version used? I inherited an existing Python Flask application that is currently version 3.6 and wanted to upgrade it to a newer version. \nIs this as simple as changing the Python version that is installed on the environment that runs the Python application or is the specific version defined in a project file?\nI have tried updating the version of Python in my local environment but the project version did not change.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":474,"Q_Id":60162744,"Users Score":0,"Answer":"what exactly determines the Python version used? \n\nYou can write whichever Python style you want in the project (2.x or 3.x) as long as it is supported for the version of Flask you are using. \nWhat \"determines\" the version it executes with is which version of Python you specify when you start Flask. As in \"python app.py\" or \"python3 app.py\" will start with either version etc.","Q_Score":1,"Tags":"python,flask","A_Id":60167551,"CreationDate":"2020-02-11T05:51:00.000","Title":"What determines a Python Flask project version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm currently stuyind TensorFlow 2.0 and Keras. I know that the activation functions are used to calculate the output of each layer of a neural network, based on mathematical functions. However, when searching about layers, I can't find synthetic and easy-to-read information for a beginner in deep learning. \nThere's a keras documentation, but I would like to know synthetically:\n\nwhat are the most common layers used to create a model (Dense, Flatten, MaxPooling2D, Dropout, ...).\nIn which case to use each of them? (Classification, regression, other)\nwhat is the appropriate way to use each layer depending on each case?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":60162973,"Users Score":1,"Answer":"Depending on the problem you want to solve, there are different activation functions and loss functions that you can use.\n\nRegression problem: You want to predict the price of a building. You have N features. Of course, the price of the building is a real number, therefore you need to have mean_squared_error as a loss function and a linear activation for your last node. In this case, you can have a couple of Dense() layers with relu activation, while your last layer is a Dense(1,activation='linear').\nIn between the Dense() layers, you can add Dropout() so as to mitigate the overfitting effect(if present).\nClassification problem: You want to detect whether or not someone is diabetic while taking into account several factors\/features. In this case, you can use again stacked Dense() layers but your last layer will be a Dense(1,activation='sigmoid'), since you want to detect whether a patient is or not diabetic. The loss function in this case is 'binary_crossentropy'. In between the Dense() layers, you can add Dropout() so as to mitigate the overfitting effect(if present).\nImage processing problems: Here you surely have stacks of [Conv2D(),MaxPool2D(),Dropout()]. MaxPooling2D is an operation which is typical for image processing and also some natural language processing(not going to expand upon here). Sometimes, in convolutional neural network architectures, the Flatten() layer is used. Its purpose is to reduce the dimensionality of the feature maps into 1D vector whose dimension is equal to the total number of elements within the entire feature map depth. For example, if you had a matrix of [28,28], flattening it would reduce it to (1,784), where 784=28*28.\n\nAlthough the question is quite broad and maybe some people will vote to close it, I tried to provide you a short overview over what you asked. I recommend that your start learning the basics behind neural networks and then delve deeper into using a framework, such as TensorFlow or PyTorch.","Q_Score":0,"Tags":"python,tensorflow,keras,neural-network,tensorflow2.0","A_Id":60164132,"CreationDate":"2020-02-11T06:15:00.000","Title":"Which layer should I use when I build a Neural Network with Tensorflow 2.x?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have project on Google Cloud App Engine. I have set up a cloud Scheduler to make a GET request every 24 hours to a certain endpoint on the app engine which invokes a simple Python script. The script simply reads a Google Sheet and updates the Cloud Firestore with the data from the sheet. It was working perfectly but for the past couple of days it fails to update the Database on scheduled time and gives an error. But when I trigger it manually from the console it works just fine. So that means the problem is not with my script. Can anyone have an idea what could be causing the problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":60164299,"Users Score":0,"Answer":"I don't think there is enough information in your question, but I think you should analyze logs. In Cloud Scheduler\/ Jobs you can find column \"Logs\" which contain links for every job. You can access Stockdriver Logging for this particular job directly from there.\nI hope this will help!","Q_Score":0,"Tags":"python,gcloud,google-cloud-scheduler","A_Id":60206867,"CreationDate":"2020-02-11T07:59:00.000","Title":"A Python function being triggered by Google Cloud Scheduler fails to work on scheduled time but executes perfectly fine when I run it manually","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to escape a python interactive shell within an ssh server without closing the ssh connection, using exit(), quit() ctrl D closes the ssh connection","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":530,"Q_Id":60164650,"Users Score":0,"Answer":"ssh -t\n-t flag forces use of ptty. Control sequences will be sent directly to remote process","Q_Score":0,"Tags":"python,ssh,server,command,escaping","A_Id":71054810,"CreationDate":"2020-02-11T08:28:00.000","Title":"How to escape a python interactive shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to escape a python interactive shell within an ssh server without closing the ssh connection, using exit(), quit() ctrl D closes the ssh connection","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":530,"Q_Id":60164650,"Users Score":1,"Answer":"I'm assuming your connection is to a Linux\/Unix server. If it's Windows, this won't help.\nIf you only close the python interpreter (ctrl-c for instance) it shouldn't close the SSH connection, since the python interpreter is running on top of the unix shell, which you are actually connected to.\nThe best way (or at least the easiest) to keep your SSH connection and keep any program running after you leave is to use a tool like tmux or screen (if your linux machine does not have tmux installed). \nIn order to do so, you can either start your program with $ screen python or start screen before you run anything, and it will start a screen session with bash running.\nThen you can safely close the ssh connection, and, when you ssh back into the machine, use screen -r to return to where you leave.","Q_Score":0,"Tags":"python,ssh,server,command,escaping","A_Id":60164987,"CreationDate":"2020-02-11T08:28:00.000","Title":"How to escape a python interactive shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I type in which python I get: \/home\/USER\/anaconda3\/bin\/python\nIf I type in echo $PYTHONPATH I get: \/home\/USER\/terrain_planning\/devel\/lib\/python2.7\/dist-packages:\/opt\/ros\/melodic\/lib\/python2.7\/dist-packages\nShould that not be the same? And is it not better to set it: usr\/lib\/python\/\nHow would I do that? Add it to the PYTHONPATH or set the PYTHONPATH to that? But how to set which python?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1577,"Q_Id":60164658,"Users Score":4,"Answer":"You're mixing 2 environment variables:\n\nPATH where which looks up for executables when they're accessed by name only. This variable is a list (colon\/semi-colon separated depending on the platform) of directories containing executables. Not python specific. which python just looks in this variable and prints the full path\nPYTHONPATH is python-specific list of directories (colon\/semi-colon separated like PATH) where python looks for packages that aren't installed directly in the python distribution. The name & format is very close to system\/shell PATH variable on purpose, but it's not used by the operating system at all, just by python.","Q_Score":6,"Tags":"python,linux,python-requests,environment,pythonpath","A_Id":60165035,"CreationDate":"2020-02-11T08:29:00.000","Title":"which python vs PYTHONPATH","Data 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 new in python and I have a folder with 15 excel files  and I am trying to rename a specific column in each file to a standard name, for instance I have a columns named \"name, and server\" on different files but they entail of the same information so I need to rename them to a standard name like \" server name\" and I don't know how to start","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":754,"Q_Id":60164763,"Users Score":0,"Answer":"If the position of the columns are the same across all excel file, you can iterate all the 15 excel files, locate the position of the column and replace the text directly. \nAlternatively, you can iterate all the files via read_xls (or read_csv depending on your context), reading them as dataframe and replace the necessary column name, and overwrite the file. Below is a reference syntax for your reference. \ndf.rename(columns={ df.columns[1]: \"your value\" }, inplace = True)","Q_Score":1,"Tags":"python,python-3.x","A_Id":60165113,"CreationDate":"2020-02-11T08:37:00.000","Title":"Add a new column to multiple .csv and populate with filename","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"def runjob(joblist):\n        server = Jenkins('http:\/\/localhost:8080', username='',password='' )\n        for x in joblist:\n                server.build_job(name=x,token=\"NRT\")\nThis used to run and trigger the job but started throwing this error now, I have unistalled py2.7 might this be the cause?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":208,"Q_Id":60166860,"Users Score":0,"Answer":"Solved it, there is a jenkins package and jenkinsapi package in python.\nBoth of them has .build_job() method but jenkinsapi doesnt allow to pass it in the above format. It was running as should when I removed the jenkinsapi import and added a jenkins. after the = in the code.","Q_Score":0,"Tags":"python,jenkins-api","A_Id":60167107,"CreationDate":"2020-02-11T10:31:00.000","Title":"\"build_job() got an unexpected keyword argument\" Error when jenkins jobs triggered through jenkins API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was developing a calculator UI in python and wanted the period to only be inputted once. I was able to disable the button after it was used once, but what if they use the keyboard. How do I block the \".\" Key in the keyboard after being used once?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":60166997,"Users Score":0,"Answer":"You have an event listener somewhere in your code which handles the keypresses. Check in that function whether the key is the \".\" or not. And if it is the \".\" button, check if it has been pressed already before showing it on the display.","Q_Score":0,"Tags":"python,keyboard","A_Id":60167096,"CreationDate":"2020-02-11T10:39:00.000","Title":"Python how to control keyboard input","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the equivalent of options(scipen=999) for setting scientific notation off in Python.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1008,"Q_Id":60167796,"Users Score":2,"Answer":"If I understand your question correctly, it's np.set_printoptions(suppress=True)\nIf you want to do it without NumPy, '%f' % your_number\nPlease provide more info on when and why you need this so that people can help you accordingly and this didn't help.","Q_Score":1,"Tags":"python,r,python-3.x,scientific-notation","A_Id":60168334,"CreationDate":"2020-02-11T11:26:00.000","Title":"What is the equivalent of options(scipen=999) in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have multiple Producers which are feeding data into Kafka. I wish to run a Consumer every hour to get all the accumulated data in at once and process it further.\n\nThe options which I thought of are:\n\nUse a python thread and use an equivalent of setInterval to call a Consumer\nSetting the max_poll_interval_ms variable: (as mentioned in a few other answers). However, the official document states \n\n\nThis places an upper bound on the amount of time that the consumer can\n  be idle before fetching more records. If poll() is not called before\n  expiration of this timeout, then the consumer is considered failed and\n  the group will rebalance\n   This does not sound like that it's responsible for putting a consumer to sleep and then firing it again.\n\n\nInstead of polling every hour, I track the Consumer Offset and poll after 10,000 records have been appended to Kafka\n\nHowever, I want to manage the same within the Consumer itself. What is the best way of the same\n?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1746,"Q_Id":60169515,"Users Score":1,"Answer":"Use Cron or your OS scheduler to call a script every hour.\nIf you need to wait until 10k records are on the topic to do anything useful, then I'm not entirely sure Kafka is a good fit in that architecture. Plus, the consumer lag would practically, constantly be falling behind","Q_Score":4,"Tags":"apache-kafka,kafka-consumer-api,polling,kafka-python","A_Id":60170414,"CreationDate":"2020-02-11T13:04:00.000","Title":"What is the best way of polling at regular intervals a Kafka Consumer while using kafka-python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have multiple Producers which are feeding data into Kafka. I wish to run a Consumer every hour to get all the accumulated data in at once and process it further.\n\nThe options which I thought of are:\n\nUse a python thread and use an equivalent of setInterval to call a Consumer\nSetting the max_poll_interval_ms variable: (as mentioned in a few other answers). However, the official document states \n\n\nThis places an upper bound on the amount of time that the consumer can\n  be idle before fetching more records. If poll() is not called before\n  expiration of this timeout, then the consumer is considered failed and\n  the group will rebalance\n   This does not sound like that it's responsible for putting a consumer to sleep and then firing it again.\n\n\nInstead of polling every hour, I track the Consumer Offset and poll after 10,000 records have been appended to Kafka\n\nHowever, I want to manage the same within the Consumer itself. What is the best way of the same\n?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1746,"Q_Id":60169515,"Users Score":0,"Answer":"If you read the official document for max_poll_interval_ms, it is an maximum interval for which the consumer can be idle. After that the consumer is considered as dead and consumer group rebalance occurs.\nThis is why I would advise that you shouldn't close consumer after 10k. Even though using offset for polling is a good strategy, there is a problem with that. Every new consumer offset doesn't mean it is a new message. Depending on your auto.offset.reset config you might be having duplicate messages.\nTo save costs of running pod, I would suggest that you should create a topic with less partitions. This might save you on data transfer + storage cost. Although the instance should be kept running.","Q_Score":4,"Tags":"apache-kafka,kafka-consumer-api,polling,kafka-python","A_Id":60192911,"CreationDate":"2020-02-11T13:04:00.000","Title":"What is the best way of polling at regular intervals a Kafka Consumer while using kafka-python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a question about coding best practice. I am developing an application with heavy computation that is continuously working on many objects in parallel. \nat the end of each object life cycle through the pipeline, i want to json parse this object and post it through a restful service call. \nshould i save those objects locally and have a separate simple application to take care of posting those objects through the restful service or should i integrate calling the service through creating a new thread in my main application?\ni want to know what is the best practice in terms of robustness and code cleanness.\nthanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":60169583,"Users Score":1,"Answer":"It is not possible to give a general answer for this question. In term of robustness and code cleanness it is important to observe the principle of separation of concerns.\nThat means that the part that produces the object must be independant of the part that posts it: they should be separately tested, and only communicate through a well defined interface.\nBut the interface can be as loose as a different process and a disk spool, or as tight as another thread in the same application recieving a Python object. Only the context (from the developper proficiency to the deployment concern and eventually containing performance questions) may give elements to chose.","Q_Score":0,"Tags":"python,rest,api","A_Id":60169900,"CreationDate":"2020-02-11T13:07:00.000","Title":"python best practice, combining core application with rest service calls","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a beginner and I've tried using with ZMQ monitor queue but I'm not getting expected result","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":249,"Q_Id":60169702,"Users Score":0,"Answer":"Q : How to know socket status(connected or not) in python?\n\na ) By exception(s) :thrown in common in situations, when the requested call to API ( API service ) was asked in such a moment, the socket-object was not in a state to execute it( for this, see the native-API documentation for details on reporting failed state via zmq_errno() et al )\nb ) By introspection : ZeroMQ API reports the rc ( Return Code detecting the { PASS | FAIL } result of a native-API call )\n\nPython wrappers ( pyzmq vX.Y ), the more the recent efforts to re-wrap this already wrapper-re-formulated native-API tools, complicate the way, how to learn intrinsic details about the { PASS | FAIL } result of the most recent re-wrapped call to native-API.\nBest read first the original ZeroMQ native API documentation, so as to see what gets when reported via the native zmq_errno() and all the rest about the internal state(s) of the system is to be deducted from FSA-events ( reported via the native-API socket_monitor tool ( having this again re-wrapped by a wrapper-mediated counterparty in pyzmq - so test its suitability for your use-case ) ).","Q_Score":1,"Tags":"python-3.x,zeromq,pyzmq","A_Id":60171966,"CreationDate":"2020-02-11T13:14:00.000","Title":"In ZMQ PUSH\/PULL How to know socket status(connected or not) in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Basically, I'm fighting with the age-old problem that Python's default json encoder does not support datetime. However all the solutions I can find call to json.dumps and manually pass the \"proper\" encoder on each invocation. And honestly, that can't be the best way to do it. Especially if you want to use a wrapper like jsonify to set up your response object properly, where you can't even specify these parameters. \nSo: long story short: how to override the global default encoder in Python's JSON implementation to a custom one, that actually does support the features I want?\nEDIT: ok so I figured out how to do this for my specific use case (inside Flask). You can do app.json_encoder = MyCustomJSONEncoder there. However how to do this outside of flask would still be an interesting question.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":240,"Q_Id":60170355,"Users Score":0,"Answer":"Unfortunately, I could not find a way to set default encoders or decoders for the json module.\nSo the best way is to do what flask do, that is wrapping the calls to dump or dumps, and provide a default in that wrapper.","Q_Score":1,"Tags":"python","A_Id":60171236,"CreationDate":"2020-02-11T13:48:00.000","Title":"Setting global JsonEncoder in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Note : radish is a \"Gherkin-plus\" framework\u2014it adds Scenario Loops and Preconditions to the standard Gherkin language, which makes it more friendly to programmers.\nSo how i can use it or use an other method to use Gherkin step autocomplete with Pycharm.\nThank's","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":60171484,"Users Score":0,"Answer":"I have solve this problem by buying a professional version of PyCharm, autocomplete is not available for Community version :(","Q_Score":0,"Tags":"python,pycharm,bdd,gherkin,python-behave","A_Id":60197644,"CreationDate":"2020-02-11T14:46:00.000","Title":"How can I use radish with Pycharm to have behave step autocomplete","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python 3.6.7 installed, launching a program that needs it works, but trying to use any pip command fails as if Python is not installed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":60172760,"Users Score":0,"Answer":"It turned out that when altering Path in System Environmental variables I had accidentally overwritten everything instead of adding. \nSo the path to the python install was lost and pip could not find it. \nIt was fixed by adding the Python path back into Environmental variables.","Q_Score":0,"Tags":"python","A_Id":60172761,"CreationDate":"2020-02-11T15:51:00.000","Title":"Using Pip commands does not work, pip cannot find python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning and building a Python application within a docker container.  My editor is visual studio code.  Whilst learning, I like to click around to see what other code is doing, to help understand it best, but am unsure the best process whilst working with Python.\nFor example, I am importing the 'os' library, but in that library there are lots of capabilities, and it would be good to be able to delve in and see what they are.\nAny process recommendations would be greatly appreciated to help with my learning here.\nThanks,\nDan","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":60173994,"Users Score":0,"Answer":"To help clarify the solution from the comments above, this is what I needed to do to get intellisense working for me in the way I needed.\n\nEnsure your host machine has all the modules\/libraries installed you are going to do (this is on top of your docker container having them, as VS Code cannot see them).  To do this on the site I am working on was python3 -m pip install -r requirements.txt.\n\nNote: This did come up with some bugs, but a quick google helped with these, and were generally around installing python3.6-dev and libmysqlclient-dev.\n\nEnsure VS Code is pointing to the python version you are using (for example, I set mine to python3.6).  This can be done in the bottom-left menu options\n\nOnce these steps are done, you should be able to hover over all imports and classes to get some info, and also ctrl+click will take you into the code to look around it.","Q_Score":0,"Tags":"python,visual-studio","A_Id":60186795,"CreationDate":"2020-02-11T17:04:00.000","Title":"How to view code from 'import' easily (eg. Django code) in visual studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"If I have a list of files in a directory is it possible to estimate a memory use number that would be taken up by reading or concatenating the files using pd.read_csv(file) or pd.concat([df1, df2])?\nI would like to break these files up into concatenation 'batches' where each batch will not exceed a certain memory usage so I do not run into local memory errors.\nUsing os.path.getsize() will allow me to obtain the file sizes  and df.memory_usage() will tell me how much memory the dataframe will use once it's already read in but is there a way to estimate this with just the files themselves?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":60175436,"Users Score":0,"Answer":"You could open each CSV, read first 1000 lines only into DataFrame, and then check memory usage. Then scale estimated memory usage by number of lines in the file.\nNote that memory_usage() isn't accurate with default arguments, because it won't count strings' memory usage. You need memory_usage(deep=True), although that might overestimate memory usage in some cases. But better to overestimate than underestimate.","Q_Score":0,"Tags":"python,python-3.x,pandas,dataframe,operating-system","A_Id":60191632,"CreationDate":"2020-02-11T18:40:00.000","Title":"Estimating Dataframe memory usage from file sizes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m currently working on my first chatbot and I need nltk for this bot to install. So I opened my terminal on my Mac and type pip install nltk and it successfully installs. \nSo I opened VisualStudioCode and I type import nltk but it replies: \"Unable to import 'nltk\u2018 \"\nWhy is this?\nThanks a lot","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3375,"Q_Id":60175550,"Users Score":0,"Answer":"Did you select a python interpreter?\nIf this is not working you could try to install it from the command line in vscode","Q_Score":0,"Tags":"python,visual-studio-code,import,nltk,chatbot","A_Id":60176154,"CreationDate":"2020-02-11T18:49:00.000","Title":"unable to import \u2019NLTK'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m currently working on my first chatbot and I need nltk for this bot to install. So I opened my terminal on my Mac and type pip install nltk and it successfully installs. \nSo I opened VisualStudioCode and I type import nltk but it replies: \"Unable to import 'nltk\u2018 \"\nWhy is this?\nThanks a lot","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3375,"Q_Id":60175550,"Users Score":0,"Answer":"try pip3 install nltk if you are using python3","Q_Score":0,"Tags":"python,visual-studio-code,import,nltk,chatbot","A_Id":60179759,"CreationDate":"2020-02-11T18:49:00.000","Title":"unable to import \u2019NLTK'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m currently working on my first chatbot and I need nltk for this bot to install. So I opened my terminal on my Mac and type pip install nltk and it successfully installs. \nSo I opened VisualStudioCode and I type import nltk but it replies: \"Unable to import 'nltk\u2018 \"\nWhy is this?\nThanks a lot","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3375,"Q_Id":60175550,"Users Score":0,"Answer":"It was bc I got the wrong version of python in vscose","Q_Score":0,"Tags":"python,visual-studio-code,import,nltk,chatbot","A_Id":60187480,"CreationDate":"2020-02-11T18:49:00.000","Title":"unable to import \u2019NLTK'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When trying to install the opencv-python package I get the following error\nError occurred when installing package 'opencv-python'. \nI already did the pip install opencv-python in the commmand prompt. When I try to do it again I get 'Requirement already satisfied'. And yet I cannot add it in PyCharm.. any ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":60175646,"Users Score":0,"Answer":"When you installed opencv you installed it in  a certain environment. Make sure that you are using that same environment in pycharm. Go to File-Settings-Project Name-Project Interpreter. Look at what interpreter it displays and if it is not in the same environment\nin which you installed opencv, then click on the small down arrow and a list of interpreters will drop down. Select the one for the environment in which you installed opencv.","Q_Score":0,"Tags":"python,windows,opencv,pycharm,opencv-python","A_Id":60175952,"CreationDate":"2020-02-11T18:56:00.000","Title":"Why do I get an error in PyCharm when trying to add the opencv module despite being already installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed a pycharm application and did configure interpreter. After i installed spark-nlp package via pip inside pycharm, and tried to run programm, it showed that it missing dependecy in form of pyspark package. When I installed pyspark it complained about bunch of packages that are being missing. Shouldn't venv resolve all requirements automatically?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":60176527,"Users Score":0,"Answer":"For this to work \"pip\" should be associated with the Python interpreter you have specified in Pycharm.\nCan you check if the interpreter specified in Pycharm and \"pip\" on the terminal are pointing to same virtualenv which was created?\nI believe \"pip\" on pycharm-terminal is different and not pointing to virtualenv used by Pyharm.","Q_Score":0,"Tags":"python,pycharm,virtualenv,johnsnowlabs-spark-nlp","A_Id":60277773,"CreationDate":"2020-02-11T20:03:00.000","Title":"Pycharm doesnt reslove package dependencies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I never really used pycharm before, but have used other JetBrains products and I expect the autocomplete to work. \nWhen used on modules likes tkinter, after writing tk. I'll get the autocomplete, with methods like tk.Tk(). However, when used on another module (also included in python by default), ctypes, I don't get that kind of autocomplete. \nIf I start writing windll, I'll get an autocomplete for it, but won't get one after that, so if I write windll.user32, which is a perfectly valid code that runs just fine, I have no way of knowing whether user32 exists or not, ctrl+space shows nothing. \nThe variable is then successfully created, but using myVar. shows nothing. I'm using anaconda (but also tried on default python) and have the interpreter setup just fine.      \nAm I missing something?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":60179800,"Users Score":0,"Answer":"PyCharm uses static analysis to provide completions, inspections, code insight features and so on.\nStatic analysis means reading project files and extracting knowledge from expected definitions of classes, function, attributes.\nDue to dynamic nature of Python, some of these members could be declared dynamically via assignments, functions with side-effects, etc.\nThis is a possible reason why there could be no completion in some cases.","Q_Score":0,"Tags":"python,pycharm","A_Id":61002058,"CreationDate":"2020-02-12T01:26:00.000","Title":"Pycharm autocomplete not working for some packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"(venv) C:\\Users\\Inter-Wave\\PycharmProjects\\PyShop>python3 manage.py runserver\n'python3' is not recognized as an internal or external command,\noperable program or batch file.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2921,"Q_Id":60181927,"Users Score":1,"Answer":"For anyone for whom the answer above does not work. You can try this one(For windows only). Find the folder where python 3 installed in your computer. You will see that there is a python.exe. Just copy-paste that file inside that folder once and rename that file as python3.exe. Now all Python commands which starts with python3 .... will work for you in Windows command line. It works because windows installation of Python does not expect commands starting with in \"python3 ....\" format. But with just doing this you can use all commands starting with \"python3\" hassle-free. Enjoy! Remember that, this solution  considers that you added python 3 path to the system variables of windows system beforehand.","Q_Score":0,"Tags":"django,python-3.x","A_Id":60597491,"CreationDate":"2020-02-12T05:50:00.000","Title":"python3 is not recognized as an internal or external command, operable program or batch file showing for creating django runserver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know raw string, like r'hello world', prevents escaping.\nIs it a good practice to always prepend the r symbol even if the string doesn't have any escaping sequences?\nSay my exception needs some string literal explanation, I need to connect to a website whose url is a string literal. They don't have backslash. Are there any performance differences between raw string and regular string?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":151,"Q_Id":60182320,"Users Score":0,"Answer":"You can do that in Python. But I don't recommend that because if you add something like '\\n', it won't work well. You can use that in Regex and paths on Windows.","Q_Score":2,"Tags":"python,python-3.x,escaping","A_Id":60182438,"CreationDate":"2020-02-12T06:25:00.000","Title":"Should I use raw string by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two different excel files. One of them is including time series data (268943 accident time rows) as below\nThe other file is value of 14 workers measured daily from 8 to 17 and during 4 months(all data merged in one file) \nI am trying to understand correlation between accident times and  values (hourly from 8 to 17 per one hour and daily from Monday to Friday and monthly)\nWhich statistical method is fit(Normalized Auto or cross correlation) and how can I do that?\nGenerally, in the questions, the correlation analysis are performed between two time series based values, but I think this is a little bit different. Also, here times are different.\nThank your advance..","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":798,"Q_Id":60182894,"Users Score":2,"Answer":"I think the accident times and the bloodsugar levels are not coming from the same source, and so I think it is not possible to draw a correlation between these two separate datasets. If you would like to assume that the blood sugar levels of all 14 workers reflect that of the workers accident dataset, that is a different story. But what if those who had accidents had a significantly different blood sugar level profile than the rest, and what if your tiny dataset of 14 workers does not comprise such examples? I think the best you may do is to graph the blood sugar level of your 14 worker dataset and also similarly analyze the accident dataset separately, and try to see visually whether there is any correlation here.","Q_Score":2,"Tags":"python,time","A_Id":60760032,"CreationDate":"2020-02-12T07:09:00.000","Title":"How do find correlation between time events and time series data in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently i am working on an object detection problem which involves detecting faces in an images  and creating boxes around them.\nTo address this issue , i have created a yolov2 model as described in the paper with loss function as mentioned in the paper itlself. At earlier stages i was facing the issue of Nan losses for localization loss and hence unstable training. Hence  found a workaround by making some small changes in loss function. Presently the issue i am facing is with very low object confidence score, as i am dealing with face-no_face dataset ,the class score during inference is 1.0 but the object confidence score is very lesss for many of the instances which contain only one face , let alone multiple faces in an image. Though while training the cummulative loss is saturating around 0.06 , but while inference , there is whole new picture of very less confidence score.\nLoss function : The loss function i am using for calculating confidence score is cummumative loss of two terms : no_object_loss and object_loss and both are MSE losses for grid cells which has object (object_loss) and rest contribute to no_object_loss.\nNote : My dataset contains 4996 instances of multi face images and ONLY 4 INSTANCES OF NO FACE. and so i was wondering if this is the issue as i why i am getting low object confidence scores.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":885,"Q_Id":60183423,"Users Score":2,"Answer":"i am posting the answer here , in case if someone goes through same issue they can follow the same debugging steps , \nSo first i figured what was the cause of low combined scores , and it turned out that it was the object scores which were very less , \nSo i looked at the distribution of the activations after each loss and also the behaviour of object loss , seemed like it was fluctuating a lot , which suggested that the loss from this particular term was not according to the desired pattern . \nhence i recursed back to the loss function and fortunately the mistake was in the IOU calculation of the loss function . \nThe problem was basically with the bounds of the iou calculation , i.e there was no bounds on what the intersection of two boxes can be , so the range  of the intersection can from -inf to +inf. Hence the iou was coming to be huge lot of times , but intuitively iou can be only from 0 to 1 and . \nthe solution to it was to truncate the localisation of predictions from 0 to image height and image width during preprocessing for iou calculation. also, while calculating the iou which is intersection \/ union , i made sure that intersection is greater or equal to 0 (not less than which means that there is not intersection at all).\nDoing this helped the model learn in a lot correct and better way to predict boxes whenever it can .","Q_Score":1,"Tags":"python,deep-learning,computer-vision,object-detection,yolo","A_Id":60207612,"CreationDate":"2020-02-12T07:47:00.000","Title":"low object confidence scores while training yolov2 for face-non face dataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install Anaconda3-2019.10-Windows-x86_64.exe on window 8.1. During installation, I checked details and there seemed have many issues. \n\nNo Scripts folder or Conda Command prompt or shortcuts were created.\nOnly conda-meta, Lib, pkgs,_conda.exe and Uninstall-Anaconda3.exe are created.\n\nI tried 32 bits also and miniconda versions. All of them don't work for me. I already tried multiple uninstallation and installation. But the result is the same.\nany inputs will be very helpful.\n\nExtract: anaconda-2019.10-py37_0.tar.bz2 [7424] Failed to execute\n  script conda.exe\nTraceback (most recent call last):   File\n  \"site-packages\\PyInstaller\\loader\\pyiboot01_bootstrap.py\", line 149,\n  in init   File \"ctypes__init__.py\", line 348, in init\n  OSError: [WinError 126] The specified module could not be found\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File \"conda.exe.py\", line 45, in\n  \nFile \"site-packages\\PyInstaller\\loader\\pyiboot01_bootstrap.py\", line\n  151, in init\nmain.PyInstallerImportError: Failed to load dynlib\/dll 'C:\\Users\\USERNAME\\AppData\\Local\\Temp\\_MEI77242\\archive.dll'.\n  Most probably this dynlib\/dll was not found when the application was\n  frozen.\nTraceback (most recent call last):   File\n  \"site-packages\\PyInstaller\\loader\\pyiboot01_bootstrap.py\", line 149,\n  in init   File \"ctypes__init__.py\", line 348, in init\n  OSError: [WinError 126] The specified module could not be found","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":4976,"Q_Id":60183699,"Users Score":2,"Answer":"For me, it's the opposite. When i used the installers from 2020, Anaconda is installed in C:\\Users\\username\\Anaconda3. This gives me the same problem as you with no Scripts folder, no command prompt, no Anaconda Navigator. I tried the 2019 version and now Anaconda is installed in C:\\Users\\username\\AppData\\Local\\Continuum\\anaconda3 and it works.\nMaybe changing the install path for the 2020 versions would have worked too. I didnt try it though. I have Windows 10 and used the x86_64 files.","Q_Score":3,"Tags":"python,anaconda","A_Id":65795041,"CreationDate":"2020-02-12T08:05:00.000","Title":"Anaconda 3 installation error - no scripts folder and no conda command prompt and shortcuts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to install Anaconda3-2019.10-Windows-x86_64.exe on window 8.1. During installation, I checked details and there seemed have many issues. \n\nNo Scripts folder or Conda Command prompt or shortcuts were created.\nOnly conda-meta, Lib, pkgs,_conda.exe and Uninstall-Anaconda3.exe are created.\n\nI tried 32 bits also and miniconda versions. All of them don't work for me. I already tried multiple uninstallation and installation. But the result is the same.\nany inputs will be very helpful.\n\nExtract: anaconda-2019.10-py37_0.tar.bz2 [7424] Failed to execute\n  script conda.exe\nTraceback (most recent call last):   File\n  \"site-packages\\PyInstaller\\loader\\pyiboot01_bootstrap.py\", line 149,\n  in init   File \"ctypes__init__.py\", line 348, in init\n  OSError: [WinError 126] The specified module could not be found\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File \"conda.exe.py\", line 45, in\n  \nFile \"site-packages\\PyInstaller\\loader\\pyiboot01_bootstrap.py\", line\n  151, in init\nmain.PyInstallerImportError: Failed to load dynlib\/dll 'C:\\Users\\USERNAME\\AppData\\Local\\Temp\\_MEI77242\\archive.dll'.\n  Most probably this dynlib\/dll was not found when the application was\n  frozen.\nTraceback (most recent call last):   File\n  \"site-packages\\PyInstaller\\loader\\pyiboot01_bootstrap.py\", line 149,\n  in init   File \"ctypes__init__.py\", line 348, in init\n  OSError: [WinError 126] The specified module could not be found","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4976,"Q_Id":60183699,"Users Score":0,"Answer":"This problem still exists in  Anaconda3 2021.11. I suspect the problem is in the username (might be that this occurs only with certain localizations). If the username has special characters or space the AppData\/Local\/Continuum folder will simply be missing. What is unacceptable is the installer telling the installation was a success.\nIf you install it globally you will still not be able to use it when you create a new enviroment (It tries to put it in the user folder, succeeds, then doesn't find anything when eg. you try to install new packages to this env). (This might be dependent on other localization settings too)\nSolution is to create a simple user folder like instead of Kov\u00e1cs Xavi\u00e9r make it KovacsXavier (I'm sure the Caps doesn't bother it). Now you will be able to install it.\nIf you have a new windows installation you can trick windows into creating such a short username by adding this as your \"UserName\" first and later renaming yourself. The directory created will remain the same but you can rename your displayed name later. I really doesn't recommend anyone letting Windows create a fancy named home folder. Not anaconda is the only software that has problems with this.\nAnother notable observation that you better leash your antivirus software when installing Anaconda.\nBut it is obvious Anaconda doesn't check software integrity after install. Which is sad.","Q_Score":3,"Tags":"python,anaconda","A_Id":70756149,"CreationDate":"2020-02-12T08:05:00.000","Title":"Anaconda 3 installation error - no scripts folder and no conda command prompt and shortcuts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to install Anaconda3-2019.10-Windows-x86_64.exe on window 8.1. During installation, I checked details and there seemed have many issues. \n\nNo Scripts folder or Conda Command prompt or shortcuts were created.\nOnly conda-meta, Lib, pkgs,_conda.exe and Uninstall-Anaconda3.exe are created.\n\nI tried 32 bits also and miniconda versions. All of them don't work for me. I already tried multiple uninstallation and installation. But the result is the same.\nany inputs will be very helpful.\n\nExtract: anaconda-2019.10-py37_0.tar.bz2 [7424] Failed to execute\n  script conda.exe\nTraceback (most recent call last):   File\n  \"site-packages\\PyInstaller\\loader\\pyiboot01_bootstrap.py\", line 149,\n  in init   File \"ctypes__init__.py\", line 348, in init\n  OSError: [WinError 126] The specified module could not be found\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File \"conda.exe.py\", line 45, in\n  \nFile \"site-packages\\PyInstaller\\loader\\pyiboot01_bootstrap.py\", line\n  151, in init\nmain.PyInstallerImportError: Failed to load dynlib\/dll 'C:\\Users\\USERNAME\\AppData\\Local\\Temp\\_MEI77242\\archive.dll'.\n  Most probably this dynlib\/dll was not found when the application was\n  frozen.\nTraceback (most recent call last):   File\n  \"site-packages\\PyInstaller\\loader\\pyiboot01_bootstrap.py\", line 149,\n  in init   File \"ctypes__init__.py\", line 348, in init\n  OSError: [WinError 126] The specified module could not be found","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4976,"Q_Id":60183699,"Users Score":0,"Answer":"Global search for the file .condarc in the drive you installed in. Uninstall anaconda and delete .condarc file. Reinstall Anaconda and you should be good to go. Was stuck with this problem for hours, hope this helps!","Q_Score":3,"Tags":"python,anaconda","A_Id":71327656,"CreationDate":"2020-02-12T08:05:00.000","Title":"Anaconda 3 installation error - no scripts folder and no conda command prompt and shortcuts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a problem with conversion from string to an integer.\nI have function which return variable a = 00007fff`90492630. This variable has type Unicode. This is the address of the function that I will use to install breakpoints via pykd (plugin for windbg).\nAt the next function, I would like to convert this variable to int, using int(a,16).\nBut i have this error: \n\nValueError: invalid literal for int() with base 16: '00007fff`90492630'\n\nThanks for your help!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2495,"Q_Id":60185339,"Users Score":0,"Answer":"Try to use pykd.expr it converts any windbg constant \/ symbols \/ expression to 64 bit long value\nIf you want to get offset of a function, use pykd.getOffset(func_name) instead of dbgCommand('x ' + func_name )","Q_Score":1,"Tags":"python","A_Id":60195976,"CreationDate":"2020-02-12T09:43:00.000","Title":"ValueError: invalid literal for int() with base 16","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a beginner, I apologize in advance for any ambiguity in my explanation\nPython: Python 3.7.4\nConsole used: Anaconda Command Prompt\nInfo: I am using a work computer and work network, which has a firewall preventing me from using \"pip\" commands to install anything. I downloaded Selenium from their webpage\nDescription of the problem\nI have a python script that utilizes Selenium to web-scrape a website. Every time I restart my computer and I launch the script, I get ImportError: No module named 'selenium' \nThe temporary solution I have found for this problem is running the setup.py script within the Selenium folder, and then running the install command.\nHowever, this temporary solution is problematic as I wish to start the script at a predetermined time using TASK SCHEDULER. From my futile attempts, when I try to run the original script via TASK SCHEDULER (no .bat file, but the .py file), I get the problem stated in the title, despite having \"installed\" the setup.py previously.\nDoes anyone know what this problem is due to? I have tried changing the location of the Selenium Folder to no avail.\nFYI: The file path where I have saved all Selenium related files is ('X's used for confidentiality reasons):\nF:\\DEFI-TAU-CLI-XXX-FCE-XXX\\XXX_XX_XXXX\\XX XXXXX XXXXXXXX\\Scraping Python\\PYTHON - Code XXXX\\Selenium\\selenium-3.141.0","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":70,"Q_Id":60185831,"Users Score":1,"Answer":"You could update the path environment variable by getting into the advanced system settings > environment variables \nOr you could uninstall the anaconda navigator and while reinstalling check the first box which says Add anaconda to PATH environment variable.","Q_Score":0,"Tags":"python,selenium,web-scraping","A_Id":60187255,"CreationDate":"2020-02-12T10:10:00.000","Title":"ImportError: No module named 'selenium' - need to run setup.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a beginner, I apologize in advance for any ambiguity in my explanation\nPython: Python 3.7.4\nConsole used: Anaconda Command Prompt\nInfo: I am using a work computer and work network, which has a firewall preventing me from using \"pip\" commands to install anything. I downloaded Selenium from their webpage\nDescription of the problem\nI have a python script that utilizes Selenium to web-scrape a website. Every time I restart my computer and I launch the script, I get ImportError: No module named 'selenium' \nThe temporary solution I have found for this problem is running the setup.py script within the Selenium folder, and then running the install command.\nHowever, this temporary solution is problematic as I wish to start the script at a predetermined time using TASK SCHEDULER. From my futile attempts, when I try to run the original script via TASK SCHEDULER (no .bat file, but the .py file), I get the problem stated in the title, despite having \"installed\" the setup.py previously.\nDoes anyone know what this problem is due to? I have tried changing the location of the Selenium Folder to no avail.\nFYI: The file path where I have saved all Selenium related files is ('X's used for confidentiality reasons):\nF:\\DEFI-TAU-CLI-XXX-FCE-XXX\\XXX_XX_XXXX\\XX XXXXX XXXXXXXX\\Scraping Python\\PYTHON - Code XXXX\\Selenium\\selenium-3.141.0","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":70,"Q_Id":60185831,"Users Score":1,"Answer":"Python is not able to find the selenium files that you have in your F drive.\nUpdate the PATH environment variable to include your selenium file directory.","Q_Score":0,"Tags":"python,selenium,web-scraping","A_Id":60185952,"CreationDate":"2020-02-12T10:10:00.000","Title":"ImportError: No module named 'selenium' - need to run setup.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I gone through lots of tutorial but not getting proper solution for this error\n\nTypeError: maximize_window() missing 1 required positional argument: 'self'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":60186333,"Users Score":0,"Answer":"from selenium import webdriver\ndriver = webdriver.Chrome()\n driver.maximize_window()\nThis works just fine, assuming you have downloaded chromedriver.\nYou can also download geckodriver and work with Firefox, personally i prefer this.","Q_Score":0,"Tags":"python-3.x,selenium-webdriver,python-requests,pycharm,selenium-chromedriver","A_Id":60186679,"CreationDate":"2020-02-12T10:34:00.000","Title":"how to maximize browser window in selenium webdriver 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed tensorflow using sudo pip3.6 install tensorflow==1.7 (I already had tensorflow 1.6 but wanted to upgrade) however I am unable to uninstall it. I tried sudo pip3.6 uninstall tensorflow and it said that tensorflow is successfully uninstalled but I don't think that's true. I get the following error when I try to run a tensorflow python code (which ideally should say import error I guess)\n\nAttributeError: module 'tensorflow.python.training.checkpointable' has no attribute 'CheckpointableBase'\n\nUsing sudo pip3.6 uninstall tensorflow again only shows\n\nSkipping tensorflow as it is not installed.\n\nI looked around a little and found the following folders in usr\/local\/lib\/python3.6\/dist-packages\/\n\ntensorboard\ntensorboard-1.7.0.dist-info\ntensorflow\ntensorflow_datasets\ntensorflow_datasets-1.3.2.dist-info\ntensorflow_estimator\ntensorflow_estimator-1.13.0.dist-info\ntensorflow_metadata\ntensorflow_metadata-0.21.0.dist-info\ntensorflow_tensorboard-0.4.0.dist-info\n\nIt seems to be a mess. Can I go ahead and simply delete these folders? What is the correct way to removing these?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":282,"Q_Id":60189194,"Users Score":0,"Answer":"Yes, you need to delete it manually, you can follow the below steps to do it.\n\nGo to the site-packages directory where pip is installing your packages in your case usr\/local\/lib\/python3.6\/dist-packages\/.\nYou should see the file that corresponds to the package you want to uninstall. Delete the file for your case rm -rf tensor*.\nInstall your required Tensorflow version pip install tensorflow==1.7\n\nI hope this solves your issue.","Q_Score":2,"Tags":"python,tensorflow,ubuntu-16.04,uninstallation,tensorflow-estimator","A_Id":61746088,"CreationDate":"2020-02-12T13:12:00.000","Title":"Unable to uninstall Tensorflow - Folders still remain in dist-packages","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"f\"{f.__module__}.{f.__name__}\" doesn't work because function f can be local, eg inside another function. We need to add some kind of marked (.<local>.) in the path to specify that this function is local. But how to determine when we need to add this marker?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":60189420,"Users Score":1,"Answer":"Use f.__qualname__ instead of __name__.","Q_Score":0,"Tags":"python,function,reflection,inspect","A_Id":60189445,"CreationDate":"2020-02-12T13:25:00.000","Title":"How to get full path for any (including local) function in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been working on an algorithm trading project where I used R to fit a random forest using historical data while the real-time trading system is in Python. \nI have fitted a model I'd like to use in R and am now wondering how can I use this model for prediction purposes in the Python system.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":777,"Q_Id":60190695,"Users Score":1,"Answer":"There are several options:\n(1) Random Forest is a well researched algorithm and is available in Python through sci-kit learn. Consider implementing it natively in Python if that is the end goal.\n(2) If that is not an option, you can call R from within Python using the Rpy2 library. There is plenty of online help available for this library, so just do a google search for it.\nHope this helps.","Q_Score":0,"Tags":"python,r,random-forest,modeling","A_Id":60191260,"CreationDate":"2020-02-12T14:33:00.000","Title":"How to use R models in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"following docusign documentations I have written code to send and downloaded signed docs from docusign this was done using the OAuth token generator for development provided by docusign, now I am getting application token using api_client.request_jwt_application_token which hits \/oauth\/token end point, I am using the access_token provided by this to create and send envelop but I get the following error\nerrorCode\": \"USER_AUTHENTICATION_FAILED\",\\r\\n  \"message\": \"One or both of Username and Password are invalid. invalid_request\nI've tried different solutions but so far nothing worked for me","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":142,"Q_Id":60191700,"Users Score":0,"Answer":"Here are the things that you must ensure:\n\nYou have an Integration key (clientID) that is configured correctly.\nYou have an RSA Private key. that key was copied\/pasted exactly as given to your configuration file. New lines must be preserved\nYour URLs are matching the environment. Meaning you use account-d and demo.docusign.net for the sandbox env endpoints.\nYou need the userId which is a GUid for the user that would be impersonated. That user must consent to the application. You have to ensure you pass userId and not accountId and that it is for the same account that you would be using.\n\nIf you confirm all of this and still get an error - I would consider to use our code example to start. I don't see code in your question, but our code example should be a good way to start.","Q_Score":0,"Tags":"python-3.x,jwt,docusignapi","A_Id":60459358,"CreationDate":"2020-02-12T15:26:00.000","Title":"Docusign JWT application access token fails when creating and sending envelop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python script that generates a web page. The script does not generate any output at all for at least three minutes, so the browser stops before the page loads.\nWhere is this timeout occurring? Is it the browser giving up? Is it Apache serving the page timing out?\nMore importantly, is there a way to control this timeout to allow the page to load?\nMy workaround is to have a space character sent to the browser every 30 seconds or so to keep the page alive, but that is an ugly hack.\nRunning Apache 2.4.6 on Red Hat Enterprise 7.6 with Python 3.7.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":18,"Q_Id":60194794,"Users Score":0,"Answer":"Thank you.  \nIt was as simple as adding a TimeOut value to the httpd.conf file and restarting the httpd service.","Q_Score":0,"Tags":"python,apache,timeout","A_Id":60195377,"CreationDate":"2020-02-12T18:25:00.000","Title":"Web page doesn't generate output for three minutes and dies. Where is the connection dying?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Django application, which I hosted on pythonanywhere. For the database, I have used SQLite(default).\nSo I want to know how many users my applications can handle?\nAnd what if two user register form or make post at same time, will my application will crash?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":490,"Q_Id":60197134,"Users Score":0,"Answer":"SQLite supports multiple users, however it locks the database when write operations is being executed.\nIn other words,concurrent writes cannot be treated with this database, so is not recommended.\nYou can use PostgreSQL or MySQL as an alternative.","Q_Score":3,"Tags":"python,django,database,sqlite","A_Id":66449913,"CreationDate":"2020-02-12T21:27:00.000","Title":"How many users can Sqlite can handle , Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My distributed application consists of many producers that push tasks into several FIFO queues, and multiple consumers for every one of these queues. All these components live on a single node, so no networking involved.\nThis pattern is perfectly supported by Python's built-in multiprocessing.Queue, however when I am scaling up my application the queue implementation seems to be a bottleneck. I am not sending large amounts of data, so memory sharing does not solve the problem. What I need is fast guaranteed delivery of 10^4-10^5 small messages per second. Each message is about 100 bytes.\nI am new to the world of fast distributed computing and I am very confused by the sheer amount of options. There is RabbitMQ, Redis, Kafka, etc.\nZeroMQ is a more focused and compact alternative, which also has successors such as nanomsg and nng. Also, implementing something like a many-to-many queue with a guaranteed delivery seems nontrivial without a broker.\nI would really appreciate if someone could point me to a \"standard\" way of doing something like this with one of the faster frameworks.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1950,"Q_Id":60197392,"Users Score":4,"Answer":"I think that a lot of it depends partly on what sort of importance you place on individual messages. \nIf each and every one is vital, and you have to consider what happens to them in the event of some failure somewhere, then frameworks like RabbitMQ can be useful. RabbitMQ has a broker, and it's possible to configure this for some sort of high availability, high reliability mode. With the right queue settings, RabbitMQ will look after your messages up until some part of your system consumes them.\nTo do all this, RabbitMQ needs a broker. This makes it fairly slow. Though at one point there was talk about reimplementing RabbitMQ on top of ZeroMQ's underlying protocols (zmtp) and doing away with the broker, implementing all the functionality in the endpoints instead.\nIn contrast, ZeroMQ does far less to guarantee that, in the event of failures, your messages will actually, eventually, get through to the intended destination. If a process dies, or a network connection fails, then there's a high chance that messages have got lost. More recent versions can be set up to actively monitor connections, so that if a network cable breaks or a process dies somewhere, the endpoints at the other end of the sockets can be informed about this pretty quickly. If one then implements a communicating sequential processes framework on top of ZMQ's actor framework (think: message acknowledgements, etc. This will slow it down) you can end up with a system whereby endpoints can know for sure that messages have been transfered to intended destinations.\nBeing brokerless allows zmq to be pretty fast. And it's efficient across a number of different transports, ranging from inproc to tcp, all of which can be blended together. If you're not worried about processes crashing or network connections failing, ZMQ gives you a guarantee to deliver messages right out of the box.\nSo, deciding what it is that's important in your application helps choose what technology you're doing to use as part of it - RabbitMQ, ZeroMQ, etc. Once you've decided that, then the problem of \"how to get the patterns I need\" is reduced to \"what patterns does that technology support\". RabbitMQ is, AFAIK, purely pub\/sub (there can be a lot of each), whereas ZeroMQ has many more.","Q_Score":5,"Tags":"python,message-queue,zeromq","A_Id":60247531,"CreationDate":"2020-02-12T21:49:00.000","Title":"High-performance replacement for multiprocessing.Queue","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"My distributed application consists of many producers that push tasks into several FIFO queues, and multiple consumers for every one of these queues. All these components live on a single node, so no networking involved.\nThis pattern is perfectly supported by Python's built-in multiprocessing.Queue, however when I am scaling up my application the queue implementation seems to be a bottleneck. I am not sending large amounts of data, so memory sharing does not solve the problem. What I need is fast guaranteed delivery of 10^4-10^5 small messages per second. Each message is about 100 bytes.\nI am new to the world of fast distributed computing and I am very confused by the sheer amount of options. There is RabbitMQ, Redis, Kafka, etc.\nZeroMQ is a more focused and compact alternative, which also has successors such as nanomsg and nng. Also, implementing something like a many-to-many queue with a guaranteed delivery seems nontrivial without a broker.\nI would really appreciate if someone could point me to a \"standard\" way of doing something like this with one of the faster frameworks.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1950,"Q_Id":60197392,"Users Score":0,"Answer":"I have tried Redis Server queuing in order to replace Python standard multiprocessing Queue. It is s NO GO for Redis ! Python is best, fastest and can accept any kind of data type you throw at it, where with Redis and complex datatype such as dict with lot of numpy array etc... you have to pickle or json dumps\/loads which add up overhead to the process.\nCheers,\nSteve","Q_Score":5,"Tags":"python,message-queue,zeromq","A_Id":67898234,"CreationDate":"2020-02-12T21:49:00.000","Title":"High-performance replacement for multiprocessing.Queue","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I use MacOS. With other editors I've used, I can hold down Control+Shift followed by a combination of p or n to select multiple lines above or below the current point.  I've read through the keybindings under Preferences -> Keyboard shortcuts but I can't figure it out.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":60197696,"Users Score":1,"Answer":"(Spyder maintainer here) Sorry but it's not possible to do what you want in Spyder.","Q_Score":0,"Tags":"python,spyder","A_Id":60215094,"CreationDate":"2020-02-12T22:15:00.000","Title":"Select mulitple lines without mouse in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to implement Multiclass Perceptron in python. I have fully understood the concept of perceptron algorithm when it comes to multiclassification, but still get puzzled by the feature vectors that we should provide out of training data. \nThe problem is simply a text (document) classification problem. I'm trying to use unigram term frequencies as features for the perceptron in text preprocessing stage. When I'm constructing features for each document based on term (i.e., unigram) frequencies in each training document, the constructed feature happens to be very sparse (term frequencies for each token that occurs in the document, and 0 for those that do not occur). \nMy question is about an alternative schema for this. Is there a better solution for constructing feature vectors? \nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":495,"Q_Id":60198443,"Users Score":0,"Answer":"I approached this problem by utilizing ID for each unigram that occurs in the training set; specifically, each instance within the training set. \nAs such, first I create a distinct vocab dictionary by iterating through each document in, giving incremental id to each term that is newly seen. When performing perceptron, I iterate through the vocab ids with their count in the document and multiply them with the associated entry in perceptron weight matrices. In this sense, I would not need to do dot product, ignoring those sparse entries (0 * 0).","Q_Score":0,"Tags":"python,machine-learning,perceptron","A_Id":61425231,"CreationDate":"2020-02-12T23:33:00.000","Title":"Feature vectors for multiclass perceptron","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Abaqus scripting and to Python. \nI am trying to write the code on PyCharm editor but it does not recognize the Abaqus libraries. \nIs there any way to run the code on PyCharm or other editors and to visualize the data afterward? \nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":361,"Q_Id":60200061,"Users Score":0,"Answer":"Unfortunately you can't, you will have to write your code first in any editor and use 'Run Script' option in Abaqus to run this file. You can use kernel command line interface to test lines in your code.\nhope this help","Q_Score":1,"Tags":"python,pycharm,ide,editor,abaqus","A_Id":60201497,"CreationDate":"2020-02-13T03:34:00.000","Title":"How to run abaqus python script in IDE editor PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I cycle through items in a DynamoDB table?\nThat is, if I have a table containing [A,B,C], how can I efficiently get item A with my first call, item B with my second call, item C with my third call and item A again with my fourth call, repeat?\nThis table could in the future expand to include D, E, F etc and I would like to incorporate the new elements into the cycle. \nThe current way I am doing it is giving each item an attribute \"seen\". We scan the whole table, find an element that's not \"seen\" and put it back as \"seen\". When everything has been \"seen\", make all elements not \"seen\" again. This is very expensive.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":171,"Q_Id":60200081,"Users Score":0,"Answer":"The efficient way to return items that haven't been seen would be to have an attribute of seen=no included when inserted.  Then you could have a global secondary index over that attribute which you could then Query().\nThere isn't an efficient way to reset all the seen=yes attributes back to no.  Scan() and Query() would both end up returning the entire table and you'd end up updating records one by one.  That will not be fast nor cheap with a large table. \nEDIT\nOnce all the records have seen=\"yes\" and you want to reset them back to seen=\"no\"  A query on the GSI suggested above will work exactly like a scan...every record will have to be read and then updated.  \nIf you have 1M records, each about 1K, and you want to reset them...you're going to need\n250K reads (since you can read 4 records with a single 4KB RCU)\n1M writes","Q_Score":0,"Tags":"python-3.x,database,amazon-web-services,amazon-dynamodb,boto3","A_Id":60211532,"CreationDate":"2020-02-13T03:37:00.000","Title":"How can I cycle through items in a DynamoDB table?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How can I cycle through items in a DynamoDB table?\nThat is, if I have a table containing [A,B,C], how can I efficiently get item A with my first call, item B with my second call, item C with my third call and item A again with my fourth call, repeat?\nThis table could in the future expand to include D, E, F etc and I would like to incorporate the new elements into the cycle. \nThe current way I am doing it is giving each item an attribute \"seen\". We scan the whole table, find an element that's not \"seen\" and put it back as \"seen\". When everything has been \"seen\", make all elements not \"seen\" again. This is very expensive.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":171,"Q_Id":60200081,"Users Score":2,"Answer":"I think the simplest option is probably:\n\nuse scan with Limit=1 and do not supply ExclusiveStartKey, this will get the first item\nif an item was returned and LastEvaluatedKey is present in the response, then re-run scan with ExclusiveStartKey set to the LastEvaluatedKey of the prior response and again Limit=1, repeat step 2 until no item returned or LastEvaluatedKey is absent\nwhen you get zero items returned, you've hit the end of the table, goto step 1\n\nThis is an unusual pattern and probably not super-efficient, so if you can share any more about what you're actually trying to do here, then we might be able to propose better options.","Q_Score":0,"Tags":"python-3.x,database,amazon-web-services,amazon-dynamodb,boto3","A_Id":60200395,"CreationDate":"2020-02-13T03:37:00.000","Title":"How can I cycle through items in a DynamoDB table?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've been training a model using just tensorflow on my GPU with the help of tf.device(), it was working fine until now. I am making another NN model in Keras and while using model.fit it is giving me OOM error.\nCan anyone guide me how to solve this issue?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1046,"Q_Id":60201977,"Users Score":0,"Answer":"It is solved now. I switched to google.colab for a while, but after sometime, i used it on my  device and it ran perfectly, i did cleaned up some files in between, and was experimenting with my GPU, i guess something in  that triggered the solution. Thank You anyway.","Q_Score":0,"Tags":"python-3.x,tensorflow,keras,out-of-memory,gpu","A_Id":60617770,"CreationDate":"2020-02-13T06:49:00.000","Title":"Out of Memory Error while training model using Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been training a model using just tensorflow on my GPU with the help of tf.device(), it was working fine until now. I am making another NN model in Keras and while using model.fit it is giving me OOM error.\nCan anyone guide me how to solve this issue?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1046,"Q_Id":60201977,"Users Score":1,"Answer":"OOM(Out of memory) error comes when your model want to use more memory then available memory. Check your GPU memory whether memory is occupied by some process before training. In nvidia GPU you can check with memory by command nvidia-smi in cmd before starting the training.\nIf no memory is occupied by any process or model before starting of training and you still getting OOM error then you have to optimize your model by Changing batch size or reducing data size or image size or by reducing trainable parameters of model(number of neurons).","Q_Score":0,"Tags":"python-3.x,tensorflow,keras,out-of-memory,gpu","A_Id":60203364,"CreationDate":"2020-02-13T06:49:00.000","Title":"Out of Memory Error while training model using Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on a project, where I need to be able to dynamically classify incoming documents. These documents can come in text PDF files as well as scanned PDF files.\nI have the following labels:\n\nInvoice\nPacking list\nCertificate\n\nI am trying to figure out how I should approach this problem. \nMy initial thoughts\nI was thinking the best way to solve this issue would be to perform text classification, based on the document text.\nStep 1 - Train a model\n\nFirst convert the PDF files to text.\nThen label the text content by one of the three labels. (Do this for a large dataset)\n\nStep 2 - Use the model\n\nOnce the model is trained, for new incoming documents, convert it to text.\nRun the text content through the model to get the text classification.\n\nIs there another way to do this? My concerns are that I am not sure if you can perform NLP on entire text documents? Maybe object detection (Computer Vision) is needed instead?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":351,"Q_Id":60207272,"Users Score":1,"Answer":"Computer vision would be faster and my first choice in your use case. Are the three types of documents visually different when you look at them in terms of layout? Certificates probably have a different \"look\" and \"layout\" but packing lists and invoices may look similar. You would want to convert PDF into page images and train and run an image classification model first. You should use transfer learning on a pre-trained image classification model like ResNet.\nYou can perform NLP on \"entire documents\" but it works best on prose text and not text on invoices or packing list. You can look up sentence embedding models (Infersent, Google USE, BERT) that can actually be used to classify full page text and not just sentences. Although some of them can be computationally expensive.","Q_Score":0,"Tags":"python,machine-learning,nlp,computer-vision","A_Id":60232186,"CreationDate":"2020-02-13T11:55:00.000","Title":"Document classification using machine learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on a project, where I need to be able to dynamically classify incoming documents. These documents can come in text PDF files as well as scanned PDF files.\nI have the following labels:\n\nInvoice\nPacking list\nCertificate\n\nI am trying to figure out how I should approach this problem. \nMy initial thoughts\nI was thinking the best way to solve this issue would be to perform text classification, based on the document text.\nStep 1 - Train a model\n\nFirst convert the PDF files to text.\nThen label the text content by one of the three labels. (Do this for a large dataset)\n\nStep 2 - Use the model\n\nOnce the model is trained, for new incoming documents, convert it to text.\nRun the text content through the model to get the text classification.\n\nIs there another way to do this? My concerns are that I am not sure if you can perform NLP on entire text documents? Maybe object detection (Computer Vision) is needed instead?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":351,"Q_Id":60207272,"Users Score":0,"Answer":"I understand your problem.\nSome key point about it\na) First do pre-processing of input data. i.e ( for e.g. how many pages have in invoice or Certificate in pdf ). Then, convert pdf into TiFF images.\nb) Trained Model using Image, Visual\\layout and text. You will get good accuracy.\nc) You can used Computer vison and deep learning (Keras and tensorflow)","Q_Score":0,"Tags":"python,machine-learning,nlp,computer-vision","A_Id":68312501,"CreationDate":"2020-02-13T11:55:00.000","Title":"Document classification using machine learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm on Debian using python3.7. I have a network drive that I typically mount to \/media\/N_drive with dir_mode=0777 and file_mode=0777. I generally have no issues with reading\/writing files in this network drive.\nOccasionally, especially soon after mounting the drive, if I try to run any Python script with os.getcwd() (including any imported libraries like pandas) I get the error FileNotFoundError: [Errno 2] No such file or directory. If I cd up to the local drive (cd \/media\/) the script runs fine.\nDoing some reading, it sounds like this error indicates that the working directory has been deleted. Yet I can still navigate to the directory, create files, etc. when I'm in the shell. It only seems to be Python's os.getcwd() that has problems.\nWhat is more strange is that this behavior is not predictable. Typically if I wait ~1 hour after mounting the drive the same script will run just fine. \nI suspect this has something to do with the way the drive is mounted maybe? Any ideas how to troubleshoot it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":181,"Q_Id":60207347,"Users Score":1,"Answer":"To me, it seems a problem with the mount, e.g. the network disk will be disconnected, and reconnected. So your cwd is not more valid. Note: cwd is pointing to a disk+inode, it is not a name (which you will see). So \/media\/a is different to \/media\/a after a reconnection.\nIf you are looking on how to solve the mounting, you are in the wrong place. Try Unix&Linux sister site, or Serverfault (also a sister site).\nIf you are looking how to solve programmatically: save cwd at beginning of the script and use os.path.join() at every path access, so that you forcing absolute paths, and not relative paths, and so you should be on the correct location.  This is not save, if you happen to read a file during disconnection.","Q_Score":1,"Tags":"python,debian,getcwd","A_Id":60213141,"CreationDate":"2020-02-13T12:00:00.000","Title":"Python: os.getcwd() randomly fails in mounted network drive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been told it is 'bad practice' to return data from a Django view and use those returned items in Javascript that is loaded on the page.\nFor example: if I was writing an app that needed some extra data to load\/display a javascript based graph, I was told it's wrong to pass that data directly into the javascript on the page from a template variable passed from the Django view.\nMy first thought: \n\nJust get the data the graph needs in the django view and return it in a context variable to be used in the template. Then just reference that context variable directly in the javascript in the template. \n\nIt should load the data fine - but I was told that is the wrong way.\nSo how is it best achieved?\nMy second thought: \n\nSpin up Django Rest Framework and create an endpoint where you pass any required data to and make an AJAX request when the page loads - then load the data and do the JS stuff needed. \n\nThis works, except for one thing, how do I get the variables required for the AJAX request into the AJAX request itself? \nI'd have to get them either from the context (which is the 'wrong way') or get the parameters from the URL. Is there any easy way to parse the data out of the URL in JS? It seems like a pain in the neck just to get around not utilizing the view for the data needed and accessing those variables directly in the JS.\nSo, is it really 'bad practice' to pass data from the Django view and use it directly in the Javascript? \nAre both methods acceptable?\nWhat is the Django appropriate way to get data like that into the Javascript on a given page\/template?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":285,"Q_Id":60209990,"Users Score":2,"Answer":"Passing data directly is not always the wrong way to go. JS is there so you can execute code when everything else is ready. So when they tell you it's the wrong way to pass data directly, it's because there is no point in making the page and data heavier than it should be before JS kicks in. \nBUT it's okay to pass the essential data so your JS codes knows what it has to do. To make it more clear, let's look into your case:\nYou want to render a graph. And graphs are sometimes heavy to render and it can make the first render slow. And most of the time, graphs are not so useful without the extra context that your page provides. So in order to make your web page load faster, you let JS load your graph after your webpage has been rendered. And if you're going to wait, then there is no point in passing the extra data needed because it makes the page heavier and slows down the initial render and it takes time to parse and convert those data to JSON objects. \nBy removing the data and letting JS load them in the background, you make your page smaller and faster to render. So while a user is reading the context needed for your graph, JS will fetch the data needed and renders the graph. This will cause your web page to have a faster initial render.\nSo in general:\nWhen to pass data directly:\n\nWhen the initial data is necessary for JS to do what it has to (configs, defaults, etc).\nWhen the time difference matters a lot and you can't wait too much for an extra request to complete the render.\nWhen data is very small.\n\nWhen not to pass data directly:\n\nWhen rendering the extra data takes time anyway, so why not get the data latter too?\nWhen the data size is big.\nWhen you need to render something as fast as possible.\nWhen there are some heavy processes needed for those data.\nWhen JS can make your data size smaller (Decide what kind of data should be passed exactly using options that are only accessible by JS.)","Q_Score":0,"Tags":"javascript,python,django,django-templates,django-views","A_Id":60210737,"CreationDate":"2020-02-13T14:20:00.000","Title":"Best practice for getting data from Django view into JS to execute on page?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"help me please \n\nTraceback (most recent call last): File\n  \"E:\/Speaker-Identification-Python-master\/Speaker-Identification-Python-master\/modeltraining.py\", line 49, in  cPickle.dump(gmm, open(dest + picklefile, 'w'))\n  TypeError: write() argument must be str, not bytes","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":60210030,"Users Score":0,"Answer":"Simple. You are using the wrong file mode for pickling. Pickling converts objects to bytes, not string. The 'w' or 'write' mode will open the file in string mode. Change it to 'wb' to open the file in the 'write-binary' mode. Change cPickle.dump(gmm, open(dest + picklefile, 'w')) to cPickle.dump(gmm, open(dest + picklefile, 'wb'))","Q_Score":0,"Tags":"python","A_Id":60210370,"CreationDate":"2020-02-13T14:23:00.000","Title":"cPickle.dump(gmm, open(dest + picklefile, 'w')) TypeError: write() argument must be str, not bytes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just started learning Python. I came across del instruction. I could not understand difference between an instruction and a function like len().  I googled it but could not find the answer. Apologies if this question sounds childish.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":463,"Q_Id":60212136,"Users Score":0,"Answer":"Things like del, def, class, lambda, with, for, while, etc. are all similar in that they are essentially special cases. They all have specifically-defined behavior, but that behavior is hardcoded into the python interpreter.\nIn the case of def, that behavior is to parse the following text in a certain way - as a function. Similar for lambda, as a lambda function, and for class, as a class. \nIn the case of with, the behavior is to take an argument, call .__enter__() on it, and assign the result to a name that's given after the as keyword. With for, it's the opposite - define the name before the in keyword, and then call .__iter__() on whatever's after, assigning each item in turn to the name.\ndel is similar, in that it has a built-in function - it removes the object from the current namespace. That's just what it does, hardcoded behavior of the interpreter. There are a couple of special cases baked in for iterable objects, in which case (IIRC) the compiler calls .__delitem__() on it.\n\nFunctions are a specific type of object with a specific programmer-defined behavior. They're defined with the def instruction.","Q_Score":1,"Tags":"python-3.x","A_Id":60212407,"CreationDate":"2020-02-13T16:09:00.000","Title":"What's the difference between an instruction and a function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A computational scientist where I work wrote a program that scores inputs using a machine learning model built with scikit-learn. My task is to make this ML scorer available as a microservice.\nSo I wrote a few lines of code using Flask to accomplish this. Mission achieved!\nWell, not quite. Because this service is going to be beaten on pretty heavily at times, it needs to be able to crunch on several requests in parallel. (I.e., on multiple cores. We have about 20 on our server.) A solution that I can achieve with about ten minutes of effort is to just spin up ten or twenty of these little REST servers on different ports and round-robin to them using nginx as a reverse proxy.\nAlthough this will work fine, I am sure, I think it would be more elegant to have a single Python server handling all the requests, rather than having twenty Python servers. So I started reading up on WSGI and uWSGI and a bunch of other things. But all that I have accomplished with all this reading and web surfing is ending up very confused.\nSo I'll ask here instead of trying to unravel this on my own: Should I just stick with the brute force approach I described above? Or is there something better that I might be doing?\nBut if doing something \"better\" is going to require days of effort wading through incomprehensible documentation, doing frustrating experimentation, and pulling out all of my hair, then I'd rather just stick with the dumb brute force approach that I already understand and that I know for sure will work.\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1334,"Q_Id":60215028,"Users Score":3,"Answer":"I'd suggest migrating so FastAPI for this. It is significantly faster, really easy to use (especially if you're migrating from Flask), and is used by a lot of people for ML inference.\nFastAPI uses the newer async functionality in python, which allows it to handle significantly more requests with the same amount of resources. \nYou can also use existing docker containers for either flask or fastapi rather than configuring yourself.","Q_Score":0,"Tags":"python,nginx,flask,wsgi","A_Id":60215547,"CreationDate":"2020-02-13T19:17:00.000","Title":"Using Flask with CPU-bound requests that need to be parallelized onto multiple cores","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm doing a school project and we ask the user for a population in millions and we also ask for a growth rate.  The rate is a percentage, for example if the number is 0.9 the population should go up by 0.9 percent or if it was 4.31, it would go up by 4.31 percent. I am having trouble converting 0.9(decimal) to 0.9(percent).","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":60216759,"Users Score":0,"Answer":"This is more a maths question but just divide it by 100 so 0.9 becomes 0.009 then multiply your number by (1+0.009) to increment by .9 %","Q_Score":0,"Tags":"python,percentage","A_Id":60216815,"CreationDate":"2020-02-13T21:30:00.000","Title":"SOLVED:How can i get a decimal like 0.9 to be a percentage so the number i have goes up by 0.9 percent?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a binary file encrypted via Vigenere cipher. I need to carry out a known plaintext attack. I know that the encrypted plaintext starts with phrase Attack at Dawn. \nHow exactly would I go about doing it. \nDo I keep the encrypted data in binary or do I somehow convert it to string?\nAlso, my idea is to brute force all possible keywords up to length 14(len(Attack at Dawn)) but that seems like it might take a while. Is there a more optimal solution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":426,"Q_Id":60217192,"Users Score":1,"Answer":"You want to build a plain text attack to get the key. The first letter of the key can be found by the amount of shifting between the initial A of Attack and the first letter of the encrypted text. Then you will get the second letter of the key from the shift amount of the second letter of the message.\nYou can then iterate on all the letters of the initial part that you know.\nBut without more info I cannot say whether upper and lower case letters matter, not if the spaces are encrypted or left apart...","Q_Score":0,"Tags":"python,encryption,vigenere","A_Id":60217777,"CreationDate":"2020-02-13T22:06:00.000","Title":"Vigenere decryption of binary file without knowing the key 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'm currently doing a project in python that requires a lot of processing. The script reads a local textfile and does a couple of calculations on every line. Every textfile contains about 200 000 lines of data (every line contains a 7 element long, comma separated list with a date and floats) and there are a total of 66 files. On every line i convert the date string to a datetime object and parse the numbers and add them to lists in the script. The data is stored in .txt files in local folders and parsed every time (but my uneducated guess would be something like sql is much more efficient). I want to run calculations on these files over and over again and I was wondering what the best way would be to do this would be.\nThanks for any help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":60218011,"Users Score":0,"Answer":"How big is the total file size? My guess would be to read them into a string and then convert it to a numpy array and do the calculation. Likely you can read them directly into the numpy from the text file, just google \"numpy from text\". \nNumpy is definitaly better than the normal lists because it's way faster.","Q_Score":0,"Tags":"python,sql","A_Id":60218071,"CreationDate":"2020-02-13T23:29:00.000","Title":"Python: reading a lot of data quickly over and over again","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently downloaded python for the first time and when I load into pycharm to create a new project and it asks to select an interpreter python doesn't show up even when I click the plus sign and search through all my files it doesn't show even though I have the latest python version installed and I have windows 10 I tried deleting both programs and redownloading them but that doesn't seem to work either please if possible and the answer may be obvious but sorry I'm a beginner and also looking at videos didn't help either.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":115,"Q_Id":60218141,"Users Score":2,"Answer":"You have no navigate to the folder where python is downloaded and just select there.\nTry the following path C:\\Users\\YourName\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe","Q_Score":1,"Tags":"python,pycharm,interpreter","A_Id":60218185,"CreationDate":"2020-02-13T23:49:00.000","Title":"Interpreter won't show in Python 3.8.1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a program written in python 2.7.5 scipy 0.18.1 that is able to run scipy.interpolate.UnivariateSpline with arrays that are non-sequential. When I try to run the same program in python 2.7.14 \/ scipy 1.0.0 I get the following error:\nFile \"\/usr\/local\/lib\/python2.7\/site-packages\/scipy\/interpolate\/fitpack2.py\", line 176, in init\n    raise ValueError('x must be strictly increasing')\nUsually I would just fix the arrays to remove the non-sequential values. But in this case I need to reproduce the exact same solution produced by the earlier version of python\/scipy. Can anyone tell me how the earlier code dealt with the situation where the values were not sequential?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":96,"Q_Id":60218883,"Users Score":1,"Answer":"IIRC this was whatever the FITPACK (the fortran library the univariatespline class wraps) was doing. So the first stop would be to remove the check from your local scipy install and see if this does the trick","Q_Score":0,"Tags":"python,scipy,version,interpolation","A_Id":60234277,"CreationDate":"2020-02-14T01:43:00.000","Title":"How did scipy ver 0.18 scipy.interpolate.UnivariateSpline deal with values not strictly increasing?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting the error when using pdf2image module:\nfrom pdf2image import convert_from_path\npages = convert_from_path('mypdf', 500)\nfor page in pages:\n    page.save('out.jpg', 'JPEG')","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":5259,"Q_Id":60220545,"Users Score":7,"Answer":"I'm going out on a limb and guessing your python file is called pdf2image.py. Try naming it something else.","Q_Score":2,"Tags":"python-3.x,image,pypdf2","A_Id":61492692,"CreationDate":"2020-02-14T05:34:00.000","Title":"\"ImportError: cannot import name 'convert_from_path' from partially initialized module 'pdf2image' (most likely due to a circular import)\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"while there are multiple versions of Python installed on a Linux machine, is there a way to mention in the script to be open with a specific version, say, 3.8 even if we issue the #python script.py as opposed to python3.8 script.py ?\nI don't want to use Linux alias command. I wanna know if that is possible to be accomplished within the script","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":57,"Q_Id":60221083,"Users Score":1,"Answer":"Use shebang. #!\/usr\/bin\/python\nIn the first line of the code with the serial number of Python you want at the end.\nYou'll need to then run your script like .\/my_script.py","Q_Score":0,"Tags":"python","A_Id":60221218,"CreationDate":"2020-02-14T06:21:00.000","Title":"Opening Python code with a specific version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using below version\npython 3.7.4\nDjango 2.0.5\nMySQL 5.5\nrestframework 3.0 \nwhile running getting error as below, please help me\nFile \"C:\\Users\\Imbesat Anwar\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\rest_framework\\settings.py\", line 22, in \n    from django.utils import importlib, six\nImportError: cannot import name 'importlib' from 'django.utils' (C:\\Users\\Imbesat Anwar\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\django\\utils__init__.py)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":424,"Q_Id":60221210,"Users Score":0,"Answer":"You need to upgrade your djangorestframework to 3.1 or higher.","Q_Score":0,"Tags":"python-3.x,django-rest-framework","A_Id":60296834,"CreationDate":"2020-02-14T06:34:00.000","Title":"from django.utils import importlib, six ImportError: cannot import name 'importlib' from 'django.utils'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've a conceptual doubt, I don't know if it's even possible.\nAssume I log on a Windows equipment with an account (let's call it AccountA from UserA). However, this account has access to the mail account (Outlook) of the UserA and another fictional user (UserX, without any password, you logg in thanks to Windows authentication), shared by UserA, UserB and UserC.\nCan I send a mail from User A using the account of User X via Python? If so, how shall I do the log in?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":539,"Q_Id":60223039,"Users Score":1,"Answer":"A interesting feature with Windows Authentication is that is uses the well known Kerberos protocol under the hood. In a private environment, that means if a server trusts the Active Directory domain, you can pass the authentication of a client machine to that server provided the service is Kerberized, even if the server is a Linux or Unix box and is not a domain member.\nIt is mainly used for Web servers in corporate environment, but could be used for any kerberized service. Postfix for example is know to accept this kind of authentication.\n\nIf you want to access an external mail server, you will have to store the credential in plain text on the client machine, which is bad. An acceptable way would be to use a file only readable by the current user (live protection) in an encrypted folder (at rest protection).","Q_Score":0,"Tags":"python,email,outlook,windows-authentication","A_Id":60223473,"CreationDate":"2020-02-14T09:01:00.000","Title":"Send mail via Python logging in with Windows Authentication","Data Science and Machine Learning":0,"Database and SQL":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 Anaconda Navigator 1.9.7 with Python 3.7.4 and accoding to conda list I have pillow 6.2.0 installed, which should be fine. However I cannot import it in a project, neither using import pillow, nor import PIL. I tried to update it to no avail, I did a conda update pillow, but this didn't help. Now I'm trying to conda uninstall pillow, however it tells me then that another 161 (!) packages will be removed, among which anaconda-navigator-1.9.7-py37_0, anaconda-client-1.7.2-py37_0, matplotlib-3.1.3-py37_0,jupyter-1.0.0-py37_7 etc... \nThis does not sound right! What shall I do? Completely uninstall Anaconda or trying to force removing only the specific pillow package?\nEDIT: When trying to remove the pillow package via the Anaconda GUI, it throws the error: \"Downgrading\/removing these packages will modify Anaconda Navigator dependencies.\"\nEDIT: help('modules') returns that package pil is installed, indeed import pil works. matplotlib though seems to not recognize it??","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":731,"Q_Id":60224550,"Users Score":0,"Answer":"I created a workaround: Since apparently the module is installed as pil and matplotlib is looking for PIL, I modified the image.py file in the matplotlib folder of the package. Instead of import PIL I changed it to import pil. Now the code runs without errors!","Q_Score":3,"Tags":"python,anaconda,python-imaging-library","A_Id":60226445,"CreationDate":"2020-02-14T10:31:00.000","Title":"Uninstalling pillow requires another 161 packages to be removed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have this data set with 78 columns and 5707 rows. Almost every column has missing values and I would like to impute them with IterativeImputer. If I understood it correctly, it will make a \"smarter\" imputation on each column based on the information from other columns.\nHowever, when imputing, I do not want the imputed values to be less than the observed minimum or more than the observed maximum. I realize there are max_value and min_value parameters, but I do not want to impose a \"global\" limit to the imputations, instead, I want each column to have its own max_value and min_value (which is the already observed maximum and minimum values). Because otherwise, the values in the columns do not make sense (negative values for headcounts, negative values for rates, etc.)\nIs there a way to implement that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":419,"Q_Id":60228714,"Users Score":0,"Answer":"So if you want to set max and min different for each column then you can go in a loop and in each iteration select the column using sklearn.compose.make_column_selector or sklearn.compose.make_column_transformer and then apply iterative imputer to that column giving max and min of that column as parameter.","Q_Score":1,"Tags":"python,pandas,scikit-learn,sklearn-pandas,imputation","A_Id":60229197,"CreationDate":"2020-02-14T14:58:00.000","Title":"max_value and min_value for each column in scikit IterativeImputer","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't import pygame inside pycharm.\nI've been using Linux Mint 19, Anaconda 3, Pycharm 2019.3.1.\nI've created a conda environment and install pygame: conda install pygame -c cogsci\nThen I ran (my_env) tiago@tiago-XPS-8700:~$ python3 mycode.py. And I got the following error:  \n\nteste.py:3: RuntimeWarning: use mixer: libSDL_mixer-1.2.so.0: cannot\n  open shared object file: No such file or directory (ImportError:\n  libSDL_mixer-1.2.so.0: cannot open shared object file: No such file or\n  directory)   pygame.mixer.music.load('bat.mp3') Traceback (most recent\n  call last):   File \"teste.py\", line 3, in \n      pygame.mixer.music.load('bat.mp3')   File \"\/home\/tiago\/anaconda3\/envs\/pycharm\/lib\/python3.5\/site-packages\/pygame\/init.py\",\n  line 105, in getattr\n      raise NotImplementedError(MissingPygameModule) NotImplementedError: mixer module not available (ImportError:\n  libSDL_mixer-1.2.so.0: cannot open shared object file: No such file or\n  directory)\n\nAfter reading some blog at internet I installed sudo apt install libsdl-mixer1.2.\nAfter that if I run (my_env) tiago@tiago-XPS-8700:~$ python3 mycode.py at Linux terminal at my conda environment, my code run successfully.\nBut If I try to run the same code inside Pycharm I get the following error:\n\n\/home\/tiago\/anaconda3\/envs\/pycharm\/bin\/python\n  \/home\/tiago\/Documentos\/PYTHON\/cursoemvideo\/exercicios\/ex_021.py\n  Traceback (most recent call last):   File\n  \"\/home\/tiago\/Documentos\/PYTHON\/cursoemvideo\/exercicios\/ex_021.py\",\n  line 3, in \n      import pygame   File \"\/home\/tiago\/anaconda3\/envs\/pycharm\/lib\/python3.5\/site-packages\/pygame\/init.py\",\n  line 133, in \n      from pygame.base import * ImportError: libSDL-1.2.so.0: cannot open shared object file: No such file or directory\nProcess finished with exit code 1\n\nWhat am I missing?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":440,"Q_Id":60230571,"Users Score":0,"Answer":"In conda environment  they have pre installed packages and libraries which u can easily use by importing them but in pycharm u additionally need to intall that package so that u can use it in pycharm","Q_Score":0,"Tags":"python,pygame,pycharm,linux-mint","A_Id":60230717,"CreationDate":"2020-02-14T16:55:00.000","Title":"I can't import pygame inside pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering how to switch two words around in a file document in python. Example: I want to switch the words motorcycle to car, and car to motorcycle.\nThe way I'm doing it is making it have all the words motorcycle change to car, and because car is being switched to motorcycle, it get's switched back to car. Hopefully that makes sense.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":41,"Q_Id":60230871,"Users Score":2,"Answer":"First, replace all the motocycle to carholder\nSecond, replace all car to motocycle\nThird, replace all carholder to car\nThat's it","Q_Score":0,"Tags":"python,python-3.x","A_Id":60230954,"CreationDate":"2020-02-14T17:19:00.000","Title":"How to switch two words around in file document in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to convert a simple python code (any sample code) into an executable file but on opening the application all I can see is a blank black screen.\nI am using:\n\nPython 3.7\nPyInstaller 3.6\nOne file output\n\nI am able to convert the file to .exe using auto-py-to-exe but I don't see any output when I try to run the application.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":779,"Q_Id":60231537,"Users Score":0,"Answer":"Pyinstaller is much easier than other things, you need to install with pip:\npip install pyinstaller\nAnd then go to the path of your Python file and then:\npyinstaller -w -F my_file.py","Q_Score":0,"Tags":"python,pyinstaller","A_Id":60231580,"CreationDate":"2020-02-14T18:11:00.000","Title":".py to .exe file conversion issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to convert a simple python code (any sample code) into an executable file but on opening the application all I can see is a blank black screen.\nI am using:\n\nPython 3.7\nPyInstaller 3.6\nOne file output\n\nI am able to convert the file to .exe using auto-py-to-exe but I don't see any output when I try to run the application.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":779,"Q_Id":60231537,"Users Score":0,"Answer":"Try doing this in order:\n\npy -3.7 -m pip uninstall pyinstaller\npy -3.7 -m pip install pyinstaller\npyinstaller --onefile test.py","Q_Score":0,"Tags":"python,pyinstaller","A_Id":60231706,"CreationDate":"2020-02-14T18:11:00.000","Title":".py to .exe file conversion issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python Flask app that seems to be otherwise working on the AWS Elastic Beanstalk platform. The one thing I can't figure out is where to save files that my web app allows users to upload. When run locally, I simply provide a path where the files are to be saved but once deployed to AWS EB, I am confused what I should change this path to. I assume I am missing something in this process and if someone could provide some guidance, I would greatly appreciate it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":354,"Q_Id":60233266,"Users Score":0,"Answer":"Try using Amazon S3 to store files with your Flask Application. Explore Flask Boto3 Module. This module can be interface between your Flask Application and File Storage Service at Amazon.","Q_Score":0,"Tags":"python,flask,amazon-elastic-beanstalk","A_Id":60236985,"CreationDate":"2020-02-14T20:43:00.000","Title":"Upload folder path for AWS Elastic Beanstalk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Flask-SQLAlchmey app running in Gunicorn connected to a PostgreSQL database, and I'm having trouble finding out what the pool_size value should be and how many database connections I should expect.\nThis is my understanding of how things work:\n\nProcesses in Python 3.7 DON'T share memory\nEach Gunicorn worker is it's own process\nTherefore, each Gunicorn worker will get it's own copy of the database connection pool and it won't be shared with any other worker\nThreads in Python DO share memory\nTherefore, any threads within a Gunicorn worker WILL share a database connection pool\n\nIs that correct so far? If that is correct, then for a synchronous Flask app running in Gunicorn: \n\nIs the maximum number of database connections = (number of workers) * (number of threads per worker)?\nAnd within a worker, will it ever use more connections from a pool than there are workers?\n\nIs there a reason why pool_size should be larger than the number of threads? So, for a gunicorn app launched with gunicorn --workers=5 --threads=2 main:app should pool_size be 2? And if I am only using workers, and not using threads, is there any reason to have a pool_size greater than 1?","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":4431,"Q_Id":60233495,"Users Score":5,"Answer":"Adding my 2 cents. Your understanding is correct but some thoughts to consider:\n\nin case your application is IO bound (e.g. talking to the database) you really want to have more than 1 thread. Otherwise your CPU wont ever reach 100% of utilization. You need to experiment with number of threads to get the right amout, usually with load test tool and comparing requests per second and CPU utilization.\nHaving in mind the relation between number of workers and connections, you can see that when changing the number of workers, you will need to adjust the max pool size. This can be easy to forget, so maybe a good idea is to set the pool size a little above the number of workers e.g. twice of that number.\npostgresql creates a process per connection and might not scale well, when you will have lots of gunicorn processes. I would go with some connection pool that sits between your app and the database (pgbouncer being the most popular I guess).","Q_Score":19,"Tags":"python,database,sqlalchemy,flask-sqlalchemy,gunicorn","A_Id":60371314,"CreationDate":"2020-02-14T21:03:00.000","Title":"Choosing DB pool_size for a Flask-SQLAlchemy app running on Gunicorn","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to use boost library on Python. In C++ I include boost\\python.hpp but it says it cannot open pyconfig.h. How should I do that? I have a Mac with Parallels installed and my C++ code is in Visual Studio on Parallels. I installed homebrew and boost from the terminal, I already had boost on the Parallels side which I have used different times in C++. In short, I did a mess. How can I fix this?\nThanks!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":60234341,"Users Score":0,"Answer":"You need to find pyconfig.h on your machine, then add its directory to your build like -I\/some\/path.  Often it will be in a directory called python3.7 or whatever version you have.","Q_Score":0,"Tags":"c++,python-3.x,boost","A_Id":60235385,"CreationDate":"2020-02-14T22:36:00.000","Title":"boost on python on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have two dictionaries d1 = {'string1': number1, ..., 'string5 000 000': number5000000} which does not change and many small dictionaries d_i = {'str1': num1, ..., 'str50': num50} (i = 2, 3, ..., a few million). I want to do a dot product between these dictionaries i.e. for every key in dictionary d_i that exists also in d_1 I would like their numbers multiplied and then added to the sum. \nThe problem is that first dictionary is extremely big and there are millions of small dictionaries. \nHow do I do that fast? Can I use some big data techniques for that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":60235321,"Users Score":0,"Answer":"You can put your data to pandas dataframe and then do dot product between series in dataframe. It can be faster but in you case I would measure how much time it takes in case of python implementation and pandas.","Q_Score":0,"Tags":"python-3.x,bigdata","A_Id":60235368,"CreationDate":"2020-02-15T01:34:00.000","Title":"Calculate dot product between two dictionaries millions of times","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are there any caveats to it? I have a few questions related to it.\nHow costly is it to create more GILs? Is it any different from creating a separate python runtime? Once a new GIL is created, will it create everything (objects, variables, stack, heap) from scratch as required in that process or a copy of everything in the present heap and the stack is created? (Garbage collection would malfunction if they are working on same objects.) Are the pieces of code being executed also copied to new CPU cores? Also can i relate one GIL to one CPU core?\nNow copying things is a fairly CPU intensive task (correct me if I am wrong), what would be the threshold to decide whether to go for multiprocessing?\nPS: I am talking about CPython but please feel free to extend the answer to whatever you feel is necessary.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":816,"Q_Id":60236745,"Users Score":3,"Answer":"Looking back at this question after 6 months, I feel I can clarify the doubts of my younger self. I hope this would be helpful to people who stumble upon it.\nYes, It is true that in multiprocessing module, each process has a separate GIL and there are no caveats to it. But the understanding of the runtime and GIL is flawed in the question which needs to be corrected.\nI will clear the doubts\/ answer the questions with a series of statements.\n\nPython code is ran (compiled to Cpython bytecode and then this bytecode interpreted) by CPython virtual machine. This is what constitutes the python runtime.\nWhen we create a new process, an entire new python virtual machine is launched (which we call the python process) with the stack and the heap memory.\nYes this is a costly process but not too costly. Because python virtual machine is piece of C code precompiled to machine code. To put in perspective, the reason that in java they do not use multiprocessing is that it will create multiple JVMs which would be terrible as JVM needs a lot of memory and also, JVM is not precompiled machine code like CPython.\nGIL is just a piece of code within the python virtual machine which lets the CPython interpreter execute only one line of CPython bytecode (or one instruction) at a time. So, all questions related to GIL creation and cost are dumb. Basically the intention was to ask about CPython Virtual Machine.\nCan I relate 1 GIL to 1 CPU core? : Better to ask if 1 Python process can be related to 1 CPU core? : No. That's Kernel's job to decide what core the process is running (and which will keep changing from time to time and the process would have no control over it). The only thing is that at any give point of time, one python process cannot be running on multiple cores and one python process will execute only one instruction in CPython bytecode (due to the GIL).\n\nWhat's copied in cores and how the OS tries to keep a process hold the Core it is working on is a separate ans very deep topic in itself.\nThe final question is a subjective one but with all this understanding, it's basically a cost to benefit ratio that may vary from program to program and might depend on how CPU intensive a process is and how many cores does the machine has etc. So that cannot be generalised.","Q_Score":7,"Tags":"python,multiprocessing,cpu,cpython,gil","A_Id":63428096,"CreationDate":"2020-02-15T07:26:00.000","Title":"Is it true that in multiprocessing, each process gets it's own GIL in CPython? How different is that from creating new runtimes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a problem since im new at the opencv python language, any idea when the camera capture the stepper motor will rotate in 90 degrees.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":93,"Q_Id":60237558,"Users Score":1,"Answer":"I guess you are using opencv 4. In opencv 3 in cv2.findContours writting _, contours, hierarchy was correct because three arguments were returned. However, in opencv 4 only two arguments are returned so change your statement to contours, hierarchy","Q_Score":0,"Tags":"python,opencv,raspberry-pi","A_Id":60238535,"CreationDate":"2020-02-15T09:43:00.000","Title":"Camera Capture + Stepper Motor","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 3 questions:\n1. What is the meaning of environment of Anaconda? What is the difference between the usage of enviroment and normal python? \n2. When I use pip install xxx, can I import xxx under a conda environment? When I use conda install xxx, can I import xxx under the normal python interpreter?\n3. If I use conda install xxx in env A, can I import xxx when I programme in env B?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":197,"Q_Id":60237883,"Users Score":0,"Answer":"Anaconda helps you with your virtual environment, makes it easier to use. There is no big differnce between vanila python. But you can use only Anacoda without vanila python installed on your computer and by using virtual environment, you avoid trash files that can interrupt your future programms.","Q_Score":0,"Tags":"python,anaconda,conda","A_Id":60239675,"CreationDate":"2020-02-15T10:32:00.000","Title":"What is the meaning of environment of Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install micropython-umqtt.robust on my Wemos D1 mini.\nThe way i tried this is as follow.\nI use the Thonny editor\n\nI have connected the wemos to the internet.\nin wrepl type:\nimport upip\nupip.install('micropython-umqtt.simple')\nI get the folowing error: Installing to: \/lib\/\nError installing 'micropython-umqtt.simple': Package not found, packages may be partially        installed\nupip.install('micropython-umqtt.robust')\nI get the folowing error: Error installing 'micropython-umqtt.robust': Package not found,   packages may be partially installed\n\nCan umqtt be installed on Wemos D1 mini ? if yes how do I do this ?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":747,"Q_Id":60238513,"Users Score":0,"Answer":"I think the MicroPython build available from micropython.org already bundles MQTT so no need to install it with upip. Try this directly from the REPL:\nfrom umqtt.robust import MQTTClient\nor\nfrom umqtt.simple import MQTTClient\nand start using it from there\nmqtt = MQTTClient(id, server, user, password)","Q_Score":2,"Tags":"mqtt,esp8266,micropython","A_Id":60254287,"CreationDate":"2020-02-15T11:54:00.000","Title":"umqtt.robust on Wemos","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install micropython-umqtt.robust on my Wemos D1 mini.\nThe way i tried this is as follow.\nI use the Thonny editor\n\nI have connected the wemos to the internet.\nin wrepl type:\nimport upip\nupip.install('micropython-umqtt.simple')\nI get the folowing error: Installing to: \/lib\/\nError installing 'micropython-umqtt.simple': Package not found, packages may be partially        installed\nupip.install('micropython-umqtt.robust')\nI get the folowing error: Error installing 'micropython-umqtt.robust': Package not found,   packages may be partially installed\n\nCan umqtt be installed on Wemos D1 mini ? if yes how do I do this ?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":747,"Q_Id":60238513,"Users Score":2,"Answer":"Thanks for your help Reilly, \nThe way I solved it is as follow. With a bit more understanding of mqtt and micropython I found that the only thing that happens when you try to install umqtt simple and umqtt robust,is that it makes in de lib directory of your wemos a new directory umqtt. Inside this directory it installs two files robust.py and simple.py. While trying to install them I kept having error messages. But I found a GitHub page for these two files, so I copied these files. Made the umqtt directory within the lib directory and in this umqtt directory I pasted the two copied files. Now I can use mqtt on my wemos.","Q_Score":2,"Tags":"mqtt,esp8266,micropython","A_Id":60473411,"CreationDate":"2020-02-15T11:54:00.000","Title":"umqtt.robust on Wemos","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python to extract Arabic tweets from twitter and save it as a CSV file, but when I open the saved file in excel the Arabic language displays as symbols. However, inside python and notepad or word, it looks good. May I know where is the problem?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":38869,"Q_Id":60239099,"Users Score":0,"Answer":"Excel is known to have an awful csv import sytem. Long story short if on same system you import a csv file that you have just exported, it will work smoothly. Else, the csv file is expected to use the Windows system encoding and delimiter.\nA rather awkward but robust system is to use LibreOffice or Oracle OpenOffice. Both are far beyond Excel on any feature but the csv module: they will allow you to specify the delimiters and optional quoting characters along with the encoding of the csv file and you will be able to save the resulting file in xslx.","Q_Score":13,"Tags":"python,excel,csv,arabic,arabic-support","A_Id":60239351,"CreationDate":"2020-02-15T13:13:00.000","Title":"CSV file with Arabic characters is displayed as symbols in Excel","Data 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 python to extract Arabic tweets from twitter and save it as a CSV file, but when I open the saved file in excel the Arabic language displays as symbols. However, inside python and notepad or word, it looks good. May I know where is the problem?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":38869,"Q_Id":60239099,"Users Score":33,"Answer":"This is a problem I face frequently with Microsoft Excel when opening CSV files that contain Arabic characters. Try the following workaround that I tested on latest versions of Microsoft Excel on both Windows and MacOS:\n\nOpen Excel on a blank workbook\nWithin the Data tab, click on From Text button (if not\n    activated, make  sure an empty cell is selected)\nBrowse and select the CSV file\nIn the Text Import Wizard, change the File_origin to \"Unicode (UTF-8)\"\nGo next and from the Delimiters, select the delimiter used in your file e.g. comma\nFinish and select where to import the data\n\nThe Arabic characters should show correctly.","Q_Score":13,"Tags":"python,excel,csv,arabic,arabic-support","A_Id":60243234,"CreationDate":"2020-02-15T13:13:00.000","Title":"CSV file with Arabic characters is displayed as symbols in Excel","Data 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 code that uses a deap library.  This code has been running in a virtual environment without issue without any issue for a while.  I then copy the whole environment to a new virtual envronemnt and run the code and I start getting a run time error:\n\n\/usr\/local\/lib\/python3.6\/dist-packages\/deap\/creator.py:141: RuntimeWarning: A class named 'Individual' has already been created and it will be overwritten. Consider deleting previous creation of that class or rename it.\nRuntimeWarning)\n\nThe data used in the old and new environments is exactly the same and the results returned look the same looks the same as well.  I can't find anything that suitably describes why this run time error occurs - why might be happening?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":867,"Q_Id":60240412,"Users Score":0,"Answer":"The DEAP library creates an Individual class when you run it. If you run it twice, then it will overwrite the previously defined Individual class. In your new environment, somewhere along the way, you are running DEAP twice. \nThe different behaviour with respect to print out demonstrates that your environments are not in fact identical. Probably version of DEAP is different. You can check the deap.__version__ variable and compare.","Q_Score":4,"Tags":"python","A_Id":60461319,"CreationDate":"2020-02-15T15:55:00.000","Title":"RuntimeWarning: A class named 'Individual' has already been created and it will be overwritten","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on emulating MATLAB code in Python. The problems is Matlab vpasolve's exact implementation is not available in Python. I have used fsolve to solve the equation but the solution is different in MATLAB and Python.\nI would like to know if there is any other solver available in Python which can work same as vpasolve.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1266,"Q_Id":60243243,"Users Score":0,"Answer":"vpasolve is not exact, instead it allows you to solve with a higher precision, defined by digits. While MATLAB calls it variable precisions, other areas mostly call it arbitrary precision. You closest equivalent to vpasolve would be using mpmath in python.\nIf you instead aim for an exact solution using symbolic computation, sympy would be your choice.","Q_Score":2,"Tags":"python,matlab,solver","A_Id":60351888,"CreationDate":"2020-02-15T21:21:00.000","Title":"Is there an equaivalent solver like MATLAB's vpasolve in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've come across this:\n\nThe core information stored by a search engine is a dictionary, called an inverted\n  index or inverted file, storing key-value pairs (w,L), where w is a word and L is\n  a collection of pages containing word w. The keys (words) in this dictionary are\n  called index terms and should be a set of vocabulary entries and proper nouns as\n  large as possible. The elements in this dictionary are called occurrence lists and\n  should cover as many Web pages as possible.\nWe can efficiently implement an inverted index with a data structure consisting\n  of the following:\n\nAn array storing the occurrence lists of the terms (in no particular order).\nA compressed trie for the set of index terms, where each leaf stores the index\n  of the occurrence list of the associated term.\n  The reason for storing the occurrence lists outside the trie is to keep the size of the\n  trie data structure sufficiently small to fit in internal memory. Instead, because of\n  their large total size, the occurrence lists have to be stored on disk.\n\n\nand I don't understand it. If a dictionary is used to store occurence lists, what's the purpose of the trie? If I'm going to have to search for the word in the dictionary anyway, why bother with the trie?\nEdit: The quote is from Data Structures and Algorithms in Python by Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":764,"Q_Id":60243441,"Users Score":0,"Answer":"Putting each word w into a Trie data structure reduces the memory needed to store the words and speeds up a search for a specific word. At the end of each word in the Trie, you'll find a list of pointers to documents that contain the word for which you searched.","Q_Score":0,"Tags":"python,tree,search-engine,trie,inverted-index","A_Id":62144197,"CreationDate":"2020-02-15T21:50:00.000","Title":"How can a trie be used in a search engine(not for autocomplete)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ubuntu 19.10,\nVScode 1.42.0,\npython 3.7.6,\nanaconda 4.8.2,\nmatplotlib 3.1.3\nIt seems that plt.show() doesn't work, because the current matplotlib backend is agg.\nRunning from the terminal, I can use Qt4Agg, but from the integrated terminal inside VScode I cannot change from agg.\nTried the following:\n\nadd backend: Qt4Agg at matplotlibrc\n__import__(\"matplotlib\").use(\"Qt4Agg\")\n__import__(\"matplotlib\").use(\"Qt4Agg\", warn=False, force=True)\nImportError: Cannot load backend 'Qt4Agg' which requires the 'qt4' interactive framework, as 'headless' is currently running\nplt.switch_backend('Qt4Agg')\nsame ImportError\nexport MPLBACKEND=Qt4Agg before running the command\n\nBut, nothing worked. Any suggestions?\nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":864,"Q_Id":60243974,"Users Score":1,"Answer":"Not sure if this is still relevant, but it looks like your integrated terminal is running in headless mode. Changing terminal.integrated.inheritEnv to true in settings should fix it.","Q_Score":3,"Tags":"python,matplotlib,visual-studio-code","A_Id":67500071,"CreationDate":"2020-02-15T23:07:00.000","Title":"How to set matplotlib backend at vscode","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was just learning about the datetime module, and noticed that when you use .month it provides the month in a range of 1 to 12, where 1 is January. When using .weekday, however, it provides the weekday in a range of 0 to 6. \nMost list indexes start at 0, so why wouldn't January, from the list of months also be 0, not 1? I looked at the python datetime docs, but didn't see an explanation. Thanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1077,"Q_Id":60245060,"Users Score":3,"Answer":"When you write out the date you will write it out with the month, day, and year. Today is 2\/15\/20 (I am not sure how it work in places other than America.) This establishes a standard that the number 2 corresponds to Febuary. There is no standard setting days of the week to any number so it treats them as 7 items and starts counting at 0 as normal","Q_Score":2,"Tags":"python","A_Id":60245144,"CreationDate":"2020-02-16T03:03:00.000","Title":"In the python datetime why is the first month, 'January', = 1, but 'Monday', the first day of the week = 0?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have implemented a Zynq ZCU102 board in vivado and I want to use final \".XSA\" file into VITIS, but after creating a new platform, its languages are C and C++, While in the documentation was told that vitis supports python.\nMy question is how can I add python to my vitis platform?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":440,"Q_Id":60245542,"Users Score":0,"Answer":"Running Python in FPGA needs an Operating System. I had to run Linux OS on my FPGA using petaLinux and then run python code on it.","Q_Score":3,"Tags":"python,fpga,xilinx","A_Id":60378725,"CreationDate":"2020-02-16T04:54:00.000","Title":"how to add python in xilinx vitis","Data 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 just can\u2019t find any information about the implementation of the system of adding to favorites for registered users.\nThe model has a Post model. It has a couple of fields of format String. The author field, which indicates which user made the POST request, etc.\nBut how to make it so that the user can add this Post to his \u201cfavorites\u201d, so that later you can get a JSON response with all the posts that he added to himself. Well, respectively, so that you can remove from favorites.\nAre there any ideas?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":507,"Q_Id":60249656,"Users Score":-1,"Answer":"You can add a favorite_posts field (many-to-many) in your Author model.","Q_Score":0,"Tags":"python,django,django-rest-framework","A_Id":60252462,"CreationDate":"2020-02-16T14:44:00.000","Title":"How to create \"add to favorites\" functional using Django Rest Framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a django app that allows user to login but I want to have only one user for one device.After some research getting the mac address of device from which users login and then storing the mac address in database seems to be good logic.How can I do so?Any python packages or so??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":293,"Q_Id":60250187,"Users Score":0,"Answer":"You can't get this information on your host server because MAC address uniquely identifies the running computer so it would be a security vulnerability.\nThere are more user identification options such as local storage or just cookies.","Q_Score":0,"Tags":"python,django,database,mac-address","A_Id":60250280,"CreationDate":"2020-02-16T15:42:00.000","Title":"How to add Mac-address in Django framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to use the terminal command find path -print0 | xargs -0 stat -f '%m %N' in a Python project. Obviously I need to supply the path so I've been splitting up the expression inside an array as suggested elsewhere. Currently I have subprocess.call(['find', path, '| xargs -0 stat -f \"%m %N\"']).\nThe code runs but everything after path is ignored. In fact it throws an error find: | xargs -0 stat -f \"%m %N\": No such file or directory so clearly I don't understand the way the command is being made up.\nAny help would be great\nEDIT:\nActually I think supplying the argument from a variable might be better. So i tried command = 'find ' + src_dir + ' -print0 | xargs -0 stat -f \\'%m %N\\''\nLooks OK with print but again when plugged into subprocess.call(osx_command) I get [Errno 2] No such file or directory:","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":19,"Q_Id":60250884,"Users Score":1,"Answer":"Try adding shell=True\nsubprocess.call(['find', path, '| xargs -0 stat -f \"%m %N\"'], shell=True)\nshell=True means executing programs through the shell, all user input passed to the program is interpreted according to the syntax and semantic rules of the invoked shell.","Q_Score":0,"Tags":"python-3.x","A_Id":60251096,"CreationDate":"2020-02-16T16:56:00.000","Title":"Using subprocess.call with variables and single quotes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"As soon as I click on anaconda navigator it does not respond. There are no warnings or errors.  I did not click on anything. Please help. I just purchased a python course from an online platform and they asked me to use anaconda navigator. Please help.\nI am on Windows 10.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":202,"Q_Id":60250955,"Users Score":0,"Answer":"First try launching anaconda-navigator from the anaconda prompt. If that works, do the below.\nThis happened to me and this is how I resolved it.\n\nI uninstalled all python versions (Anaconda and Normal Python).\nReinstall the 64 bit version of anaconda (if you also want the normal python, install the normal python 64 bit first and then the anaconda).\nTry launching the anaconda-navigator now.","Q_Score":1,"Tags":"python,anaconda,navigator","A_Id":63277054,"CreationDate":"2020-02-16T17:04:00.000","Title":"ANACONDA NAVIGATOR not lauching","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have a process that is writing large number of lines on a file and the process got killed in the middle before the file handler is closed. Do I get the content of the lines written successfully?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":127,"Q_Id":60252414,"Users Score":1,"Answer":"It depends on what you mean by \"got killed\" and \"successfully\". If its a python-raised exception then the file is closed (which flushes it to the operating system) because it exited a with clause or because the final reference to the object was removed and its __del__ method was called. This last bit isn't always guaranteed, which is why with clauses are usually used.\nIf the program was killed by an external unhandled exception or crashed because some c library has a bug, then the file isn't closed and whatever data was still in the local process cache is lost. Whatever had already been flushed to the operating system by clib will be there, but not the latest data. And it may be truncated on a memory block boundary. You can call flush often to reduce the amount of lost data. Or perhaps use a memory mapped file and direct io.\nNow to the question of success. Depending on what you're doing, a partially written file may be the worst choice. In fact, I'd wager that's the case more often than not. I'm guilty of this as much as anybody but it makes sense to write to a temporary file and move it on success. Or alternately, deleting the file on failure. Parially written faulty data is a curse.","Q_Score":0,"Tags":"python","A_Id":60253445,"CreationDate":"2020-02-16T19:33:00.000","Title":"Python write files process crashed before closing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can i customize hrs,days,months of date time module in python?\nday of 5 hrs only, a month of 20 days only, and a year of 10 months only.\nusing date time module.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":60255954,"Users Score":0,"Answer":"I agree with @TimPeters . This just doesn't fit in what datetime does.  \nFor your needs, I would be inclined to start my own class from scratch, as that is pretty far from datetime. \nThat said...you could look into monkeypatching datetime...but I would recommend against it. It's a pretty complex beast, and changing something as fundamental as the number of hours in a day will blow away unknown assumptions within the code, and would certainly turn its unit tests upside down. \nBuild your own from scratch is my advice.","Q_Score":0,"Tags":"python,datetime","A_Id":60256263,"CreationDate":"2020-02-17T04:26:00.000","Title":"how to customized hr,month,year in python date time module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an custom Python library function that takes a csv flat file as input that is read using data = open('file.csv', 'r').read(). But currently I've the data processed in Python as a Pandas DataFrame. How can I pass this DataFrame as a flat file object that my custom library function accepts? \nAs a work around I'm writing the DataFrame to disk and reading it back using the read function which is causing adding a second or two for each iteration. I want to avoid using this process.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":60256207,"Users Score":0,"Answer":"In the to_csv method of pandas DataFrame, if you don't provide any argument you get the CSV output returned as a string. So you can use the to_csv method on your DataFrame, that produces the same output as you are getting by storing and reading the DataFrame again.","Q_Score":0,"Tags":"python,pandas","A_Id":60256310,"CreationDate":"2020-02-17T05:04:00.000","Title":"Read Pandas DataFrame object like a flatfile","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I run a flask command in my project, I get an error of the form zsh: (correct file path)\/venv\/bin\/flask: bad interpreter: (incorrect, old file path)\/venv\/bin\/python3. I believe the error is due to the file paths not matching, and the second file path no longer existing. I changed the name of the directory for my project when I changed the name of the project, but I don't know how to change the path that flask searches for the interpreter in.\nThanks in advance.\nEdit: I just tried going into the flask file at (correct file path)\/venv\/bin. I saw that it still had #!(incorrect, old file path)\/venv\/bin\/python3 at the top. I tried changing this to #!(correct file path)\/venv\/bin\/python3, but the same error as before persisted, as well as the flask app not being able to find the flask_login module, which it was not having issues with before.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":264,"Q_Id":60257235,"Users Score":0,"Answer":"Ok, I figured out how to fix it. I had to go into my (correct file path)\/venv\/bin\/flask file and change the file path after the #! to the correct file path. I had to do the same for pip, pip3, and pip3.7 which were all in the same location as the flask file. Then I had to reinstall the flask_login package. This fixed everything.","Q_Score":1,"Tags":"python,unix,flask","A_Id":60271799,"CreationDate":"2020-02-17T06:51:00.000","Title":"Bad interpreter file not found error when running flask commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"All the articles about web scraping in Python I came across quoted BeautifulSoup and Selenium as the main tools to use to retrieve HTML and JavaScript content from a webpage.\nHowever, I have not found a way to automatically update the data received from this same webpage without the need to send it a new request.\nIs it impossible to do in Python what you would do with Google Chrome, that is, simply opening a webpage and looking at it being automatically updated by the host itself?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":259,"Q_Id":60257740,"Users Score":0,"Answer":"Yes, it is possible. For example, you can download elements of the DOM tree in a loop if the content is dynamically modified using JavaScript. You can also call your own JavaScript to perform a specific action. Alternatively, you can even write and upload your own browser plugin. In general, in selenium you can control the browser to a large extent, just like a normal user, without the need to refresh the page again.","Q_Score":0,"Tags":"javascript,python,selenium,beautifulsoup,screen-scraping","A_Id":60258897,"CreationDate":"2020-02-17T07:30:00.000","Title":"Web scraping: update data like in Chrome?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm looking for a conceptual answer on this question.\nI'm wondering whether using ThreadPool in python to perform concurrent tasks, guarantees that data is not corrupted; I mean multiple threads don't access the critical data at the same time.\nIf so, how does this ThreadPoolExecutor internally works to ensure that critical data is accessed by only one thread at a time?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":496,"Q_Id":60257856,"Users Score":2,"Answer":"If so, how does this ThreadPoolExecutor internally works to ensure that critical data is accessed by only one thread at a time?\n\nIt doesn't, that's your job.\nThe high-level methods like map will use a safe work queue and not share work items between threads, but if you've got other resources which can be shared then the pool does not know or care, it's your problem as the developer.","Q_Score":6,"Tags":"python","A_Id":60258080,"CreationDate":"2020-02-17T07:41:00.000","Title":"Is data safety guaranteed while using `ThreadPoolExecutor` from python's `future` module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a library that has to support several Python versions starting from 2.6. E.g., one of my requirements is requests. I know that the last version supporting Python 2.6 is 2.19.1 (the latest version 2.20.0 supports any Python >= 2.7).\nSo my question is whether pip understands that the line requests~=2.19 in requirements should install 2.19.1 for Python 2.6 and 2.20.0 for any higher version of Python?\nUpdate. The question is not about the syntax, I'm curious whether pip is smart enough and in a Python 2.6 environment will be able not to go beyond 0.19.1.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":194,"Q_Id":60260983,"Users Score":1,"Answer":"I believe yes, pip does take into account the version of the currently running Python interpreter, to choose an appropriate version (or distribution of a version) of a project to install. So since pip install 'requests~=2.19' is the equivalent of pip install 'requests>=2.19,requests==2.*', it should give as of today (2020-02-18):\n\nrequests 2.19.1 on Python 2.6; and\nrequests 2.22.0 on Python 2.7.","Q_Score":2,"Tags":"python,pip","A_Id":60280596,"CreationDate":"2020-02-17T10:57:00.000","Title":"Does pip take into account the actual Python version when installing compatible package versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python regression model that predicts one's level of happiness based on user-input data, i have trained and tested it using Python.\nBut I'm using React Native to create my mobile application. \nMy mobile application will take in the user-input data needed and will output a prediction on their level of happiness. Anyone has an idea on how to implement this? Any advice would be appreciated! I lack the experience, but have an interest in this area, Im still learning so please help me out :)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":117,"Q_Id":60263706,"Users Score":1,"Answer":"You need to create python API and call it from the mobile application by passing the input features. Python API will return you the forecasted value. This API will load the regression model and make a forecast on given input features. I hope It will help.","Q_Score":0,"Tags":"python,react-native,linear-regression,mobile-application","A_Id":60264105,"CreationDate":"2020-02-17T13:37:00.000","Title":"Implementing saved python regression model to react expo application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to make smaller size of this lib?\nCurrently in python.36\/site-packages\/spacy lang is 380MiB folder, where I see a lot of unused languages by me. I use only en, and is it possible to install with pip somehow spacy and load to this folder only needed language?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":134,"Q_Id":60264464,"Users Score":0,"Answer":"This is improved in v2.2+, where the language-specific data has been moved out of the main library into a separate package. The size depends a bit on your OS, but should be closer to ~50 MB.","Q_Score":0,"Tags":"pip,python-3.6,spacy","A_Id":60296744,"CreationDate":"2020-02-17T14:20:00.000","Title":"Spacy - making smaller size of library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Pandas DataFrame with a few columns, but I want to manipulate all of values in a single column (conditionally), like this:\ndf[my_column] = df[my_column].apply(lambda x: -float(x))\nThis works, but Pandas gives me a SettingWithCopyWarning.\n\nSettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame.\n  Try using .loc[row_indexer,col_indexer] = value instead\n\nIs there a problem with the way I'm going about manipulating this column?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":60270430,"Users Score":1,"Answer":"The problem occurs earlier in your code.  df is probably a slice of another dataframe and pandas is warning you not to make a modification of df because it is a copy of that other dataframe.\nThe easiest solution when you want to subset a dataframe and manipulate further is to use the .copy() method.\ndf = df_original.copy()\nnow you can apply code like:\ndf[my_column] = xxx \nwithout a SettingWithCopyWarning.","Q_Score":0,"Tags":"python,pandas,python-3.7","A_Id":60270555,"CreationDate":"2020-02-17T21:10:00.000","Title":"Pandas: SettingWithCopyWarning when calling apply on a slice","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing the Pig Latin text conversion:\nOne of the requirements is putting qu together.\nWhat I did  re.findall(r'^qu', token)\nbut it only accepts qu together if the word\/token starts with qu\nIf the word\/token starts with aqu then it does not recognize qu together.\nWhat I want is to recognize qu no matter the placement, including if it starts with Qu.\nHow do I fix this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":60270641,"Users Score":2,"Answer":"Remove the ^ from it, that cause this. The caret mean basically \"start the matching from the beginning of the line (token in your case)\".","Q_Score":0,"Tags":"python,regex,python-3.x,nltk,nltk-book","A_Id":60270659,"CreationDate":"2020-02-17T21:28:00.000","Title":"Regular expression to match characters inside a word","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have used VegaLite.jl to plot a choropleth map in Julia. And Geopandas to plot the same in Python.\nAs I want to make a benchmark between both I would like to know if Geopandas has been fully written in Python or if it is just a wrapper?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":60271109,"Users Score":2,"Answer":"GeoPandas itself is written in pure python, but it depends on fiona, rtree, pyproj and shapely. All of them are using C libraries to do the work. Fiona GDAL, rtree libspatialindex, pyproj PROJ6 and shapely GEOS.\nRegarding plotting, GeoPandas uses matplotlib. I see that matplotlib has some C code, but not sure if it is used in this case.","Q_Score":1,"Tags":"python-3.x,visualization,geopandas","A_Id":60278880,"CreationDate":"2020-02-17T22:12:00.000","Title":"Is Geopandas fully written in python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting a response from an API as a json response. \nI am coding in python for backend. \nThe frontend team needs information from the raw json response for populating a UI so we have to order the json and make it more easier for them to fetch information.\nNow I can order the json in a specific format and push to the frontend team or I can pass the raw json response*to the frontend team and let them handle ordering the json and further use for their UI.\nRemember my json file size is 15MB.\nWhich is faster and a better design principle? \nProcess in the backend then push to frontend or process in the frontend?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":3678,"Q_Id":60274287,"Users Score":1,"Answer":"As others have noted, there are quite a few good reasons to prefer processing on the back end:\n\nif you can remove all unnecessary data from the JSON being sent to the front-end, it will reduce load on the end-user device both in terms of transfer but also in parsing time\nit may be possible to cache the remote API call, so you don't need to make as many calls out to the remote APIs (which will usually be very slow compared to cache retrieval). You can also potentially cache the after-processing data, so you can just serve that up repeatedly\nYou can detect errors that happen in processing the JSON, whereas that is less visible if it is happening on the client device\n\nOne other big advantage to processing the API response on the back-end is that you can choose the structure you send to the front end. That way, if the API you are consuming changes over time (or you change which service you're using to retrieve data) you can handle that change on the back end without it ever affecting the front-end code.","Q_Score":14,"Tags":"javascript,python-3.x,data-structures","A_Id":60274696,"CreationDate":"2020-02-18T05:29:00.000","Title":"Should I process a JSON in the frontend or Backend, which is faster?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting a response from an API as a json response. \nI am coding in python for backend. \nThe frontend team needs information from the raw json response for populating a UI so we have to order the json and make it more easier for them to fetch information.\nNow I can order the json in a specific format and push to the frontend team or I can pass the raw json response*to the frontend team and let them handle ordering the json and further use for their UI.\nRemember my json file size is 15MB.\nWhich is faster and a better design principle? \nProcess in the backend then push to frontend or process in the frontend?","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":3678,"Q_Id":60274287,"Users Score":3,"Answer":"I would suggest to perform this on the backend, some key reasons I would suggest this is:\n\nProcessing on mobile devices leads to massive battery drain\nIf your frontend is web, javascript will block while the processing is occurring (which could lead to bad experiences)\nServer response can be cached to speed up response times and lower duplicate processing\nYour backend language may be able to perform the task more optimally then the frontend device can","Q_Score":14,"Tags":"javascript,python-3.x,data-structures","A_Id":60274543,"CreationDate":"2020-02-18T05:29:00.000","Title":"Should I process a JSON in the frontend or Backend, which is faster?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting a response from an API as a json response. \nI am coding in python for backend. \nThe frontend team needs information from the raw json response for populating a UI so we have to order the json and make it more easier for them to fetch information.\nNow I can order the json in a specific format and push to the frontend team or I can pass the raw json response*to the frontend team and let them handle ordering the json and further use for their UI.\nRemember my json file size is 15MB.\nWhich is faster and a better design principle? \nProcess in the backend then push to frontend or process in the frontend?","AnswerCount":4,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":3678,"Q_Id":60274287,"Users Score":4,"Answer":"It's always better to process the data in backend itself.","Q_Score":14,"Tags":"javascript,python-3.x,data-structures","A_Id":60274510,"CreationDate":"2020-02-18T05:29:00.000","Title":"Should I process a JSON in the frontend or Backend, which is faster?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying different python libraries like pdftotree, pdfminer, tabula etc. But could not get the exact results. I mean I can get text from PDF, Images and Tabular data in HTML, but not as maintained and organized as original PDF file. Can someone help me with something regarding this? I would be thankful.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":464,"Q_Id":60282551,"Users Score":0,"Answer":"Mostly yes.  Translate the PDF to SVG, and embed the SVG in your web page.\nSVG's image model (what it can represent and how) is a near-superset of the PDF image model (which is itself a superset of PostScript), though SVG lacks some of the print-specific features of PDF.  There are probably quite a few PDF->SVG converters out there already.  Googling \"Pdf to SVG\" turned up quite a few promising hits\nThere will be some complications:\n\nMany PDF files are longer than 1 page.  You might need to generate 10 SVG files for a single 10 page PDF file, and then build a web page around those 10 SVGs.  Throw in some dynamic HTML to \"turn pages\" and you've got a good web-based PDF viewer.\nThere are parts of PDF that aren't within its image model at all... bookmarks, annotations (form fields, digital signatures), document metadata (author, creation date, etc), and so forth.  Some of the non-image-model stuff is common enough that a PDF to SVG utility might handle it directly (links), while other stuff doesn't have an HTML equivalent and would be lost.\n\nYou could preserve the appearance of a digital signature, but the actual security represented by those visuals would be gone.  Preserving that signature's appearance could be considered lying about the security.","Q_Score":1,"Tags":"python,html,pdf,file-conversion,pdf-conversion","A_Id":60284486,"CreationDate":"2020-02-18T13:56:00.000","Title":"Is there any way of generating exact HTML page from a PDF file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Apart from Binary search - do we have any other algorithm having lesser number of comparisons.\nFurther Binary search would work on a Sorted list. what if the elements are unsorted ?\nif Number of elements (= n) is a big number. Then the run time would be high, if I opt to sort it and then run a binary search on the same.\nis there any other alternative.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":562,"Q_Id":60283051,"Users Score":0,"Answer":"Sorting has a cost of O(n*log(n)) in the mean case if you use Timsort, Python's default sorting algorithm, so it's only worth ordering if you are gonna perform many searches and the array is not gonna have new elements since you'll have to reorder which has cost O(n).\nOn the other hand, since you have to look every value individually, I don't think there are better ways unless you use parallel programing, that way several threads could look in different values at the same time.","Q_Score":1,"Tags":"python,search","A_Id":60283166,"CreationDate":"2020-02-18T14:22:00.000","Title":"searching an unsorted list of elements in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have set up a small flask webpage but in only runs on localhost  while I would like to make it run on my local network, how do I do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":60283309,"Users Score":1,"Answer":"Just my 2 cents on this, I just did some research, there are many suggestions online...\nAdding a parameter to your app.run(), by default it runs on localhost, so change it to app.run(host= '0.0.0.0') to run on your machines IP address.\nFew other things you could do is to use the flask executable to start up your local server, and then you can use flask run --host=0.0.0.0 to change the default IP which is 127.0.0.1 and open it up to non local connections.\nThe thing is you should use the app.run() method which is much better than any other methods.\nHope it helps a little, if not good luck :)","Q_Score":0,"Tags":"python,flask,localhost,wifi,python-3.7","A_Id":60283756,"CreationDate":"2020-02-18T14:37:00.000","Title":"I have set up a small flask webpage but in only runs on localhost while I would like to make it run on my local network python3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on a project which i receive some EMG data from Myo Arm Band\nI need to clasify them, what machine learning algorithm can be good for this?","AnswerCount":1,"Available Count":1,"Score":-0.3799489623,"is_accepted":false,"ViewCount":47,"Q_Id":60285744,"Users Score":-2,"Answer":"you can use svm. kernels can be varied depending on number of movements to classify and it has high accuracy. i would recommend you to read some research paper related to this.","Q_Score":0,"Tags":"python,classification","A_Id":60763352,"CreationDate":"2020-02-18T16:47:00.000","Title":"What machine learning i can use for classifing EMG data from MyoArm Band?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed tkcalendar using pip3 install tkcalendar and it says that it has installed successfully. However, when i run the line from tkcalendar import * in my program, it gives me this error ModuleNotFoundError: No module named 'tkcalendar'. Can anybody help?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1592,"Q_Id":60286026,"Users Score":1,"Answer":"Make sure that when you're running your file you use python3. I was having the same issue because I just used python and it reverted to python2","Q_Score":3,"Tags":"python,tkinter,pip,python-3.7,tkcalendar","A_Id":68108929,"CreationDate":"2020-02-18T17:04:00.000","Title":"ModuleNotFoundError: No module named 'tkcalendar'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed tkcalendar using pip3 install tkcalendar and it says that it has installed successfully. However, when i run the line from tkcalendar import * in my program, it gives me this error ModuleNotFoundError: No module named 'tkcalendar'. Can anybody help?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1592,"Q_Id":60286026,"Users Score":0,"Answer":"I had this same problem and since I was new to this I searched everywhere and couldn't find a solution that worked. Finally I moved the cursor to line 'from tkcalendar import *' (right over tkcalendar)  and a pop-up gave me a link to install tkcalendar. That seemed to be all there was to it. I tried pip install tkcalendar several times and even pip3 to see what it would do. Nothing worked except for what I just mentioned above.","Q_Score":3,"Tags":"python,tkinter,pip,python-3.7,tkcalendar","A_Id":68108891,"CreationDate":"2020-02-18T17:04:00.000","Title":"ModuleNotFoundError: No module named 'tkcalendar'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to make sure that the package which was allowed for a secure system will remain static if installed again in the future.  Can a bad actor (the package owner) trick user into downloading insecure\/unvetted source code?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":60288380,"Users Score":0,"Answer":"PyPI prohibits users from uploading a file with the same name.  So if the user uploads a package which has a wheel file that looks like foo-1.0.0-py2py3-none-any.whl they cannot update that file to contain other source code. However, what they can do is delete v1.0.0 from PyPI change the source code and then upload both: foo-1.0.0-py2-none-any.whl and foo-1.0.0-py3-none-any.whl effectively tricking the user into downloading a potentially malicious wheel.","Q_Score":2,"Tags":"python,security,pypi","A_Id":60288445,"CreationDate":"2020-02-18T19:46:00.000","Title":"Can `pip install foo-package==1.0.0` download different code today than it did yesterday","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just need to build an executable using pyinstaller, with the default windows .exe icon.\nOr a way to remove\/set default windows icon after compiling.\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":60290427,"Users Score":0,"Answer":"I don't think you can just use windows default .exe icon, but you can set your own.\nUse pyinstaller --onefile --icon=myicon.ico yourapp.py for the command, and have myicon.ico in that directory or specify which directory.","Q_Score":0,"Tags":"python,icons,pyinstaller","A_Id":60290743,"CreationDate":"2020-02-18T22:35:00.000","Title":"Building an executable using pyinstaller, with windows default executable icon","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got the following link for a app\nhttps:\/\/www.facebook.com\/dialog\/oauth?client_id=SOME_NUMER_I_HAVE&redirect_uri=https:\/\/someSITE.com\/fblogin&state=SOME_VALID_STATE\nI want to send the name and password, and get the cookie.\nDoes anyone know what the request would look like? \n(Or a library that takes care of this)\nMy setup, I'm trying to crawl a website, i need to login to this website to do so.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":60290799,"Users Score":0,"Answer":"a bit more info about your setup would be helpful. \nIf you are using Django I would recommend using django-allauth for social authentication.","Q_Score":0,"Tags":"python,urllib3","A_Id":60290895,"CreationDate":"2020-02-18T23:14:00.000","Title":"Login into facebook using oauth in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run my Python code within ATOM  in Win10\nI have installed all packeges like: atom-python-run, script but anyway the program is not runnig.\nIn official page written to press F5 ,F6  to run script but doing that tries to compile the script with the gpp package (which I had installed before) as if it were C\/C++ code.\nIs it possible to change button for running a python script?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1763,"Q_Id":60290921,"Users Score":0,"Answer":"You just need to press additional fn key along with f5 or f6.","Q_Score":0,"Tags":"python,windows-runtime,atom-editor","A_Id":68616582,"CreationDate":"2020-02-18T23:30:00.000","Title":"How to run python scripts in Atom if F5 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":1,"Web Development":0},{"Question":".doc files, .pdf files, and some image formats all contain metadata about the file, such as the author.\nIs a .py file just a plain text file whose contents are all visible once opened with a code editor like Sublime, or does it also contain metadata? If so, how does one access this metadata?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":277,"Q_Id":60290971,"Users Score":2,"Answer":"On Linux and most Unixes, .py's are just text (sometimes unicode text).\nOn Windows and Mac, there are cubbyholes where you can stash data, but I doubt Python uses them.\n.pyc's, on the other hand, have at least a little metadata stuff in them - or so I've heard.  Specifically: there's supposed to be a timestamp in them, so that if you copy a filesystem hierarchy, python won't automatically recreate all the .pyc's on import.  There may or may not be more.","Q_Score":0,"Tags":"python,metadata","A_Id":60291005,"CreationDate":"2020-02-18T23:36:00.000","Title":"Do .py Python files contain metadata?","Data 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 use Flask-SQLAlchemy with Celery. The two play poorly together if the Celery task takes a long time, as when it is done when the commit occurs, the MySQL connection will have timed out and \"gone away\".\nIs it possible to make changes to a SQLAlchemy object, attempt a commit, and when that fails, open a new session, attach the objects to the new session, and commit them? If so, how? What kind of SQLAlchemy function can do this? Or now that the commit failed as the session is gone, are the SQLAlchemy objects invalidated and all the work on them must be done again?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":60291093,"Users Score":0,"Answer":"The answer is merge. merge is what can be used to attach objects to different sessions.","Q_Score":0,"Tags":"python,sqlalchemy,celery,flask-sqlalchemy","A_Id":60444294,"CreationDate":"2020-02-18T23:53:00.000","Title":"How to recover from a failed SQLAlchemy commit?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Multiple issues arise when I try to run tests in parallel.\nAccording to the docs, \"test_\" is prepended to the database name specified in DATABASES. I used the name \"postgres\", so the database created when running tests is called test_postgres. When running tests in parallel, the following databases are created (which is expected): test_postgres_1, test_postgres_2, test_postgres_3, and test_postgres_4. When running all tests with the --parallel=4 option, however, every test fails with the following message: django.db.utils.OperationalError: FATAL:  database \"postgres_x\" does not exist where x can be 1, 2, 3 or 4. I can see that the following databases have been created: test_postgres_x where x can be 1, 2, 3 or 4. Where's \"postgres_x\" coming from? Why isn't \"test_\" being prepended to these?\nFurthermore, if I manually create the expected databases postgres_x (x = 1 to 4), the migrations applied to the \"main\" database aren't applied to the clones. This results in errors like this: django.db.utils.ProgrammingError: relation \"users_user\" does not exist. Roughly 1\/4 tests pass when using 4 cores.\nLastly, if I try to migrate postgres_x by using migrate --database=postgres_x, I get: django.db.utils.ConnectionDoesNotExist: The connection postgres_x doesn't exist.\nI have ensured that all tests are isolated just so I can run them in parallel. What am I supposed to do?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":881,"Q_Id":60291234,"Users Score":1,"Answer":"Instead of building your test harness yourself I suggest using pytest and pytest-django and pytest-xdist this will handle the db creation and migration for each parallel worker. (pytest can run Django UnitTest tests without modification)","Q_Score":3,"Tags":"python,django,django-rest-framework,postgresql-11,django-tests","A_Id":60291722,"CreationDate":"2020-02-19T00:11:00.000","Title":"Errors when running tests in parallel","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a base app which is used by sub-apps.\nI have an AbstractUser defined in the base app and I need to add a relation to a sub-app model if the sub-app is installed.\nI understand that my new field will be present in the user table in the database, but with a null value if the sub-app is note installed.\nMy problem is to reference the foreign key I had to a model that does not exists if the sub-apps is not installed.\nDoes I need to transfer the model from the sub-apps to the base app or is there another solution like a conditionnal foreign key constraint in my AbstractUser model.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":60298233,"Users Score":0,"Answer":"I think you need a stub sub-app to plug the hole if it's \"not installed\". All it does is declare the model so that there's a table in the database (but no records). You could later replace it with the real sub-app and populate the table through it.","Q_Score":1,"Tags":"python,django","A_Id":60301859,"CreationDate":"2020-02-19T10:30:00.000","Title":"How to define a foreign key in an Django app model which is ignored if a sub-app is not installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I tried to install the fbprophet library for Python, I faced the following error: \n\nname 'HolidayBase' is not defined\n\nand it took me a while to get the solution. That's why I'm answering my own question, in case it helps someone.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":60300351,"Users Score":0,"Answer":"The solution I found is to downgrade my Python version from 3.7.3 to 3.6.7.\nI did not do an extensive analysis on to which other versions work - maybe all 3.6 do.","Q_Score":0,"Tags":"python,time-series","A_Id":60300352,"CreationDate":"2020-02-19T12:25:00.000","Title":"fbprophet library error while installing: name 'HolidayBase' is not defined","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with spyder - python. I want to test my codes. I have followed the pip install spyder-unittest and pip install pytest. I have restarted the kernel and restarted my MAC as well. Yet, Unit Testing tab does not appear. Even when I drop down Run cannot find the Run Unit test. Does someone know how to do this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":21439,"Q_Id":60300787,"Users Score":18,"Answer":"So, I solved the issue by running the command:\nconda config --set channel_priority false. \nAnd then proceeded with the unittest download with the command run:\nconda install -c spyder-ide spyder-unittest. \nThe first command run conda config --set channel_priority false may solve other issues such as:\nSolving environment: failed with initial frozen solve. Retrying with flexible solve","Q_Score":5,"Tags":"tabs,spyder,python-unittest","A_Id":60338462,"CreationDate":"2020-02-19T12:51:00.000","Title":"Errors such as: 'Solving environment: failed with initial frozen solve. Retrying with flexible solve' & 'unittest' tab","Data 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 my database I have a bunch of images of the same class - which means I do have only one class of images. \nAfter implementing a CBIR (feature extraction by histograms and calculating distance by euclidean - very naive approach, nothing fancy), I get the 25 best matched results. And now I would like to evaluate them. \nAll evaluation metrics like mean average precision and precision recall need ground truth data, which I don't have. Right now I'm just taking one image and calculate the similarity. \nHow can I evaluate without having any ground truth data?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":188,"Q_Id":60304192,"Users Score":0,"Answer":"Late reply, but I am working on a similar project. You can't really evaluate your approach as you don't have ground truth. What you can do is to run it for various images and calculate the mean of how many images you think are relevant each time. Even better would be to use human judges instead of your own judgement since one could say it would be highly biased.","Q_Score":0,"Tags":"python,opencv,evaluation,precision-recall,cbir","A_Id":61664504,"CreationDate":"2020-02-19T15:49:00.000","Title":"How to evaluate CBIR system without having a ground truth?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a saved model with h5 format created using keras with tensorflow v1.x backend. I can no longer load this model in keras with tensorflow v2.x backend using keras.models.load_model. Is there anyway to migrate the saved model to make it compatible with newer keras with tensorflow v2.x backend?\nSo far I have found tools \/ tutorials to migrate the code but I could not find any useful way to upgrade the saved models. I know there is tf.compat.v1.saved_model.load method for tensorflow but I cannot really use that as I saved the model using keras.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":937,"Q_Id":60304558,"Users Score":3,"Answer":"You should be able to load the same model in TensorFlow 1.x and 2.x, but for this you need to use a version of Keras that supports both, for example, Keras 2.3.1","Q_Score":2,"Tags":"python,tensorflow,keras","A_Id":60372531,"CreationDate":"2020-02-19T16:07:00.000","Title":"How to load keras model with tensorflow v1.x backend in keras with tensorflow v2.x backend?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to open an existing file in a subfolder of the current working directory. This is my command:\nfyle = open('\/SPAdes\/default\/{}'.format(file), 'r')\nThe filevariable contains the correct filename, the folder structure is correct (working on macOS), and the file exists.\nThis command, however, results if this error message:\nFileNotFoundError: [Errno 2] No such file or directory: [filename]\nDoes it have anything to do with the way JupyterLab works? How am I supposed to specify the folder srtucture on Jupyter? I am able to create a new file in the current folder, but I am not able to create one in a subfolder of the current one (results in the same error message).\nThe folder structure is recognized on the same Jupyter notebook by bash commands, but I am somehow not able to access subfolders using python code.\nAny idea as to what is wrong with the way I specified the folder structure?\nThanks a lot in advance.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":489,"Q_Id":60306048,"Users Score":2,"Answer":"There shouldn\u2019t be a forward slash in front of SPAdes. \nPaths starting with a slash exist high up in file hierarchy. You said this is a sub-directory of your current working directory.","Q_Score":0,"Tags":"python,jupyter-notebook,jupyter,directory-structure,jupyter-lab","A_Id":60311780,"CreationDate":"2020-02-19T17:27:00.000","Title":"JupyterLab - python open() function results in FileNotFoundError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know how to do a few things already:\n\nSummarise a model with model.summary(). But this actually doesn't print everything about the model, just the coarse details.\nSave model with model.save() and load model with keras.models.load_model()\nGet weights with model.get_weights()\nGet the training history from model.fit()\n\nBut none of these seem to give me a catch all solution for saving everything from end to end so that I can 100% reproduce a model architecture, training setup, and results.\nAny help filling in the gaps would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":60306789,"Users Score":0,"Answer":"model.to_json() can be used to convert model config into json format and save it as a json. \nYou can recreate the model from json using model_from_json found in keras.models\nWeights can be saved separately using model.save_weights.\nUseful in checkpointing your model. Note that model.save saves both of these together. Saving only the weights and loading them back useful when you need to work with the variables used in defining the model. In that case create the model using the code and do model.load_weights.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":60307146,"CreationDate":"2020-02-19T18:16:00.000","Title":"What's a good way to save all data related to a training run in Keras?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with a steadily growing corpus. I train my Document Vector with Doc2Vec which is implemented in Python. \nIs it possible to update a Document Vector?\nI want to use the Document Vector for Document recommendations.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":60307249,"Users Score":0,"Answer":"Individual vectors can be updated, but the gensim Doc2Vec model class doesn't have much support for adding more doc-vectors to itself. \nIt can, however, return individual vectors for new texts that are compatible (comparable) with the existing vectors, via the .infer_vector(words) method. You can retain these vectors in your own data structures for lookup. \nWhen enough new documents have arrived that you think your core model would be better, if trained on all documents, you can re-train the model with all available data, using it as the new base for .infer_vector(). (Note that vectors from the retrained model won't usually be compatible\/comparable with those from the prior model: each training session bootstraps a different self-consistent coordinate space.)","Q_Score":1,"Tags":"python,gensim,doc2vec","A_Id":60309760,"CreationDate":"2020-02-19T18:46:00.000","Title":"Is it possible to update a Doc2Vec Vector?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im testing out someones code and I can't import win32gui its really annoying.\nI have tried in cmd pip install win32gui and it comes up with \n\nModuleNotFoundError: No module named 'win32gui'\n\nI am using pycharm, python 3.8 on windows 10","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6318,"Q_Id":60309475,"Users Score":1,"Answer":"Enter this at the command prompt\npip install pywin32==300\nThen import win32gui will work with python 3.8.","Q_Score":2,"Tags":"python,win32gui","A_Id":68415707,"CreationDate":"2020-02-19T21:25:00.000","Title":"How to install 'win32gui' with `pip`?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a REST API service that I want to call on at scheduled times. Currently, I call the API using a basic cronjob on a server every day at 8:00am.\nI want to scale up and allow my users to schedule a time they would like to receive the notification from my API call. How could I go about doing this? I know I would need to keep a database of user requests and their associated times, however I am not sure if continuing to use cron is the best way about this... (I would prefer not to use third party services in order to keep costs down)\nI am having trouble wrapping my head this, if anybody has any advice that would be much appreciated!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":42,"Q_Id":60309869,"Users Score":1,"Answer":"If the time frame is going to be something simple, like one-per-day, once-per-week, etc., using the cron.d folder is a fairly trivial and in my opinion appropriate solution. \nThe simplest way would be each user having their own file with a simple one-line cron statement that reflects their selected time. When the user selects their time, part of your service creates the correct file for that user. You can go on from there. \nWhether or not you put them in a database is really a question of your own system design; given a proper file naming scheme, you could feasibly do this without having to keep that requested time in persistent storage.","Q_Score":0,"Tags":"python,rest,api,automation,cron","A_Id":60329310,"CreationDate":"2020-02-19T21:55:00.000","Title":"How could I schedule an API call that users sign up for?","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 to analyze a log file which will generate continuously 24*7. So, the data will be huge. I will have credentials to where log file is generating. But how can I get that streaming data ( I mean like any free tools or processes) so that I can use it in my python code to extract some required information from that log stream and will have to prepare a real time dashboard with that data. please tell some possibilities to achieve above task.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3205,"Q_Id":60314765,"Users Score":0,"Answer":"Just a suggestion\nYou could try with ELK:\nELK, short for Elasticsearch (ES), Logstash, and Kibana, is the most popular open source log aggregation tool. Es is a NoSQL. Logstash is a log pipeline system that can ingest data, transform it, and load it into a store like Elasticsearch. Kibana is a visualization layer on top of Elasticsearch.\nor \nyou could use Mongo DB to handle such huge amount of data:\nMongoDB is an open-source document database and leading NoSQL. Mongo DB stores data in a json format. Process the logs and store it in a json format and retrieve it for any further use. \nBasically its not a simple question to explain, it depends on the scenarios.","Q_Score":1,"Tags":"python,logging,bigdata","A_Id":60322239,"CreationDate":"2020-02-20T07:22:00.000","Title":"continuous log file processing and extract required data using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a function on Azure Function Apps that is given back a PDF and uses the python tika library to parse it.\nThis setup works fine locally, and I have the python function set up in Azure as well, however I cannot figure out how to include Java in the environment? \nAt the moment, when I try to run the code on the server I get the error message \n\nUnable to run java; is it installed?\n  Failed to receive startup confirmation from startServer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":268,"Q_Id":60320171,"Users Score":0,"Answer":"So this isnt possible at this time. To solve it, I abstracted out the tika code into a Java Function app and used that instead.","Q_Score":1,"Tags":"java,python,azure,apache-tika","A_Id":60635648,"CreationDate":"2020-02-20T12:40:00.000","Title":"Tika in Python Azure Function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I followed the example to branch using make_branch() in the control(branch) callback of the MIP. But I noticed that the solving processes differ surprisingly under different settings of the variable select strategy. How was it possible since I replace all the CPLEX's decisions with my decisions?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":62,"Q_Id":60321573,"Users Score":1,"Answer":"CPLEX cannot tell whether you are going to query its branching decisions from the callback or not. So before invoking the callback, CPLEX computes what variables it would branch on, so that this information can be reported to the callback.\nEven if you never query this information, it is still computed and computing that information may change the rest of the execution, thus resulting in different search trees.","Q_Score":1,"Tags":"python,cplex,mixed-integer-programming,branch-and-bound","A_Id":60321958,"CreationDate":"2020-02-20T13:54:00.000","Title":"Why does the variable select strategy of CPLEX influence the user branch decisions? (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been doing Node programming for a while and one thing I'm just very tired of is having to worry about blocking the event loop with anything that requires lots of cpu time. I'd also like to expand my language skills to something more focused on machine learning, so python seemed like a good choice based on what I've read.\nHowever, I keep seeing that python is also single threaded, but I get the feeling this wording is being used in a different way than how it's usually used in node. Python is the go to language for a lot of heavy data manipulation so I can't imagine it blocks the same way node does. Can someone with more familiarity with python (and some with node) explain how their processing of concurrent requests differs when 1 request is cpu intensive?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":26,"Q_Id":60321781,"Users Score":1,"Answer":"First of all Python is not single-threaded, but its standard library contains everything required to manage threads. It works fine for IO bound tasks, but does not for CPU bound tasks because of the Global Interpretor Lock which prevents more than one thread to execute Python code at the same time.\nFor data processing tasks, several modules exist that add low level (C code level) processing and internally manage the GIL to be able to use multi-core processing. The most used modules here are scipy and numpy (scientific and numeric processing) and pandas which is an efficient data frame processing tools using numpy arrays for its underlying containers.\nLong story short: For io bound tasks, Python is great. If your problem is vectorizable through numpy or pandas, Python is great. If your problem is CPU  intensive and neither numpy nor pandas will be used, Python is not at its best.","Q_Score":0,"Tags":"python,list","A_Id":60322022,"CreationDate":"2020-02-20T14:06:00.000","Title":"When python is referred to as single threaded why does in not have the same pitfalls in processing as something like node.js?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a sign in page for my blog, using bootstrap and django. I recently imported crispy forms and when I try and go to the page I get the following error: TemplateDoesNotExist at \/register\/. However all my redirects and URLs are setup correctly.\nOn the Django debug it says that the error is in my base HTML file, under the head section where I imported bootstrap CSS. I can provide any code necessary. It says this on my server: django.template.exceptions.TemplateDoesNotExist: bootsrap4.4.1\/uni_form.html.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":873,"Q_Id":60322513,"Users Score":2,"Answer":"set CRISPY_TEMPLATE_PACK = 'bootstrap4'. Looks like you have it currently set to the full version number.","Q_Score":0,"Tags":"python,html,django,django-crispy-forms","A_Id":60359339,"CreationDate":"2020-02-20T14:45:00.000","Title":"Error when using crispy forms with Django and bootstrap","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My python version = 3.7.4\ncv2 version= 4.2.0\nThese are my version on python and open cv, Im trying to use SIFT function and I got the famous error module cv2.cv2' has no attribute 'SIFT', so I tried pip install opencv-contrib-python and also python -m pip install --user opencv-contrib-python, and I changed  detector=cv2.SIFT() to detector=cv2.xfeatures2d.SIFT_create() and the error just changed to AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d'\nI Tried with similar questions that I found, but are not working for me, I dont find a recent question, thats why Im opening this new because maybe as the version were different it could be the reason doesnt work for me\nWhat else could I do?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3506,"Q_Id":60323159,"Users Score":1,"Answer":"SIFT and SURF are proprietary, patented algorithms.  You'd need to compile OpenCV and OpenCV-contrib from source, with non-free packages enabled, building the python libraries.  I wasn't able to get this working so I used pip to find an older version (3.4.2) that did not remove the non-free libraries.  I may have had to roll back python but I'm not sure.  I am using python 3.6.8","Q_Score":0,"Tags":"python,python-3.x,opencv","A_Id":60329148,"CreationDate":"2020-02-20T15:18:00.000","Title":"module 'cv2.cv2' has no attribute 'xfeatures2d' and module 'cv2.cv2' has no attribute 'SIFT'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I imagine this is a classic floating point precision question, but I am trying to wrap my head around this result, running 1\/\/0.01 in Python 3.7.5 yields 99. \nI imagine it is an expected result, but is there any way to decide when it is safer to use int(1\/f) rather than 1\/\/f ?","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3365,"Q_Id":60323392,"Users Score":25,"Answer":"If this were division with real numbers, 1\/\/0.01 would be exactly 100. Since they are floating-point approximations, though, 0.01 is slightly larger than 1\/100, meaning the quotient is slightly smaller than 100. It's this 99.something value that is then floored to 99.","Q_Score":33,"Tags":"python","A_Id":60323477,"CreationDate":"2020-02-20T15:30:00.000","Title":"Why 1\/\/0.01 == 99 in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am pretty new in Python and I have the following doubt related publishing a Python project on a GIT repository: have I to avoid to publish also the venv folder on my GIT repository or is it good to put also this folder into the repository?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":774,"Q_Id":60323868,"Users Score":2,"Answer":"Most projects I have seen usually put all the venv files in the .gitignore, as, to my understanding, virtual environments are unique to each machine, so if you grab a venv in a specific computer, it won't work in another. Instead, each machine should have its own venv created locally.","Q_Score":3,"Tags":"python,python-3.x,git,virtualenv","A_Id":60323982,"CreationDate":"2020-02-20T15:54:00.000","Title":"Is it ok to publish \"venv\" folder of a Python project into my GIT repository?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am pretty new in Python and I have the following doubt related publishing a Python project on a GIT repository: have I to avoid to publish also the venv folder on my GIT repository or is it good to put also this folder into the repository?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":774,"Q_Id":60323868,"Users Score":3,"Answer":"Generally you want to avoid publishing the virtual environment containing the installed dependencies for your project. The dependencies might not be cross-platform compatible. \nEspecially for projects that need to compile some C extensions generally each platform requires a separate binary ( or compilation).\nIt is more common to enumerate your dependencies in a requirements.txt file. The requirements.txt file should contain all the dependencies that are necessary to run your project.\nIn order not to publish your local venv to git, two approaches are possible:\n\nKeep your virtual environments in a location that is not inside the git root of your project\nAdd the virtual environment to the .gitignore file","Q_Score":3,"Tags":"python,python-3.x,git,virtualenv","A_Id":60323988,"CreationDate":"2020-02-20T15:54:00.000","Title":"Is it ok to publish \"venv\" folder of a Python project into my GIT repository?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a project for a friend of mine. \nI want to find one specific keyword that is on multiple pages, and it has duplicates on other places on a large PDF file (40-60 pages and above) then save in memory in what page the keyword was found, and then split those pages from the original PDF File and lastly, merge them together.\nI'm thinking about using PDFMiner or PyPDF2 (i'm open to other suggestions as well)\nI'm already writing the code for the most part of it, but i can't figure out a good and efficient way to search the file and find that keyword, because this keyword is located in other places in the same file, and make sure that the data i want to extract from the original file isn't duplicate and all the data was extracted.\nThanks in Advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":60326946,"Users Score":1,"Answer":"Did you try to split pdf file on couple of blocks and search keyword on each block with multithreading? This should be faster.","Q_Score":2,"Tags":"python,python-3.x,pdf,pdf-manipulation","A_Id":60327003,"CreationDate":"2020-02-20T19:06:00.000","Title":"PDF File Manipulation (open a large pdf file, find a keyword, then save in which page was found, and then split those pages and merge them in one pdf)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Auto-Sklearn and have a dataset with 42 classes that are heavily imbalanced. What is the best way to handle this imbalance? As far as I know, two approaches to handle imbalanced data within machine learning exist. Either using a resampling mechanism such as over- or under-sampling (or a combination of both) or to solve it on an algorithmic-level by choosing an inductive bias that would require in-depth knowledge about the algorithms used within Auto-Sklearn. I'm not quite sure on how to handle this problem. Is it anyhow possible to solve the imbalance directly within Auto-Sklearn or do I need to use resampling strategies as offered by e.g. imbalanced-learn? Which evaluation metric should be used after the models have been computed? The roc_auc_score for multiple classes is available since sklearn==0.22.1. However, Auto-Sklearn only supports sklearn up to version 0.21.3. Thanks in advance!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5508,"Q_Id":60327063,"Users Score":0,"Answer":"For those interested and as an addition to the answers given, I can highly recommend the following paper: \nLemnaru, C., & Potolea, R. (2011, June). Imbalanced classification problems: systematic study, issues and best practices. In International Conference on Enterprise Information Systems (pp. 35-50). Springer, Berlin, Heidelberg.\nThe authors argue that: \n\nIn terms of solutions, since the performance is not expected to improve\n  significantly with a more sophisticated sampling strategy, more focus should be\n  allocated to algorithm related improvements, rather than to data improvements.\n\nAs e.g. the ChaLearn AutoML Challenge 2015 used the balanced accuracy, sklearn argues that it is a fitting metric for imbalanced data and Auto-Sklearn was able to compute well-fitting models, I'm going to have a try. Even without resampling, the results were much \"better\" (in terms of prediction quality) than just using the accuracy.","Q_Score":2,"Tags":"python,machine-learning,scikit-learn,multiclass-classification","A_Id":60352461,"CreationDate":"2020-02-20T19:15:00.000","Title":"Best way to handle imbalanced dataset for multi-class classification in Auto-Sklearn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a health score system for my company\u2019s clients. There is a lot of data that I am pulling from through my API. I was crunching data through g-scripts but it is taking a really long time, so I thought using Numpy's vectorization would make things much faster. I was thinking of creating a new web application using the MERN stack but I would like to crunch the data using python. Any suggestions on what to do?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":456,"Q_Id":60330478,"Users Score":1,"Answer":"A MERN stack is essentially javascript, so there's a ceiling to the amount of calculation you can realistically do on the backend with a vanilla implementation. \nI would build a native daemon that runs your Python code, place it in a docker container, and choosing your favorite messaging\/transportation system to communicate with your backend API. There are plenty of choices there:\n\nWebsockets (raw)\nMessaging Queue Libraries (IE ZeroMQ)\nMongoDB change streams (Since you are using MERN)\n\nSo a classic life cycle would of a data crunch event would be:\n\nIssue a rest-ful command to backend API\nBackend API issues a message to daemon using your messaging system\nDaemon awakes and crunches data\nDaemon sends back result via messaging system to rest-ful api\nBackend API reads the message back and send result to front-end","Q_Score":2,"Tags":"python,amazon-web-services,numpy,data-science,mern","A_Id":60330638,"CreationDate":"2020-02-21T00:21:00.000","Title":"How to crunch data in python but add to MERN Stack Application","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Bottom Line: \nI can get everything to work by configuring two separate virtual environments, one for pyCharm and one for the CLI.  Is this really necessary or should I be able to use 1 virtual environment for both as I expected?\nMore Detailed explanation:\nI'm very new so this is probably a facepalm type of question so i'll try to be terse.\nI'm using Linux Mint, Python 3.6, django 3.0.3, and pyCharm 2019.3.1.\nI can create a virtual env using venv in the cli and it works.\nI can also create a NEW virtual env in pyCharm through the settings: Project: Interpreter interface, and it works, however it doesn't have venv as an option, it only has virtualenv.\nBut if I try to activate the virtual env i created in pyCharm from the cli (using virtualenv of course, not venv), it fails hard and thinks i'm using python 2.7 which isn't even installed on my system.  If it try to point pyCharm at the virtual env I setup on the cli, I get an error 134.\nIs this just a known\/expected issue?  Must I have two virtual environments for every project I want to access via both pyCharm AND the cli?  And I assume this is unrelated but I also find it odd that pyCharm lists my interpreter as python 3.7, which also is not installed on my system.   I'm using 3.6 alone.  \nThanks for your time.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":60330966,"Users Score":0,"Answer":"At this time, I'm going to just answer this as: you need a separate virtual env for each (pyCharm and CLI) as this approach is not difficult or time-consuming and I have not had any issues working in this way.","Q_Score":0,"Tags":"python,django,pycharm,virtualenv","A_Id":60713090,"CreationDate":"2020-02-21T01:36:00.000","Title":"Fundamentals question: Django + Python Virtual Env + pyCharm and CLI -- are two separate virtual environments required?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sorry in advance if this question has been asked before,\nSo after some time, I wanted to start a new python project. My previous computer (on which my python files were) died. I had saved my projects in my Dropbox. Now I installed python (3.8, there is also an anaconda installation, but it should not interfere with the python installation) on my new PC, and I cannot import any library to those files.\nThe python shell can find the imported packages (imported using pip), but even when I move the files to C:\\Users\\Username\\AppData\\Local\\Programs\\Python\\Python38-32\\Scripts (single user installation). It doesn't work.\nI have tried uninstalling and re-installing pygame (in this example. Any library is unusable) using pip, pip3 and even pip3.8, I have added the .whl file by hand, it all didn't work. I have tried a virtual environment, but I can't get that to work either.\nI run Windows 10 on a 64-bit computer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":331,"Q_Id":60334676,"Users Score":0,"Answer":"first be sure you know which python installation you use with which import files etc.\nyou can copy your files not in scripts, but in lib somewhere in site-packages dir.\nadd your scripts to the python path! sys.path.add(.....) Otherwise python is blind and can't see them","Q_Score":1,"Tags":"python,pip","A_Id":60335559,"CreationDate":"2020-02-21T08:23:00.000","Title":"How do my python files get access to installed libraries (Pip)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My java code generates Python file from XML input. In order to validate this translation, I would like to go through Python output file and check its content. Right now I am just using String contains method but I think if I could parse Python code into Java POJO, that would make this testing easy. If you think, there is another way to perform this unit testing. Kindly suggest. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":274,"Q_Id":60335154,"Users Score":1,"Answer":"You can parse python code using antlr library. Via antlr you can build AST (Abstract Syntax Trees) and validate it","Q_Score":0,"Tags":"java,python,unit-testing,parsing,junit","A_Id":60335610,"CreationDate":"2020-02-21T08:57:00.000","Title":"How do I parse Python Script(py) file into Java POJOs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Good Morning everyone,\nHopefully some may help, I am new to visual code transferring over from thonny since im using C# I ust decided to start using visual code for both python and C#. When I code in Visual code and than close the program the text editor is blank as if nothing is there but I can still run the code as if there was. Does anyone happen to know where this problem stems from ir a solution?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":60338644,"Users Score":0,"Answer":"Fixed it, turns out I was using python and its not like C# so I had to open the .py file rather than the .sln file","Q_Score":2,"Tags":"c#,python-3.x,ide,text-editor","A_Id":60353527,"CreationDate":"2020-02-21T12:26:00.000","Title":"Visual Code Does not show any text, any suggestions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Good Morning everyone,\nHopefully some may help, I am new to visual code transferring over from thonny since im using C# I ust decided to start using visual code for both python and C#. When I code in Visual code and than close the program the text editor is blank as if nothing is there but I can still run the code as if there was. Does anyone happen to know where this problem stems from ir a solution?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":60338644,"Users Score":0,"Answer":"I had something like that with visual studio 2019.\nWhen ever i was copying nuget packages to offline system. \nBecause winrar lock files when it copies visual studio couldn't access packages and couldn't rendered text.","Q_Score":2,"Tags":"c#,python-3.x,ide,text-editor","A_Id":60339279,"CreationDate":"2020-02-21T12:26:00.000","Title":"Visual Code Does not show any text, any suggestions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whether it is dynamic time warping or some sort of Euclidean k-means clustering of a time series, it is (nearly?) always required to consider irregular spacing of data, unequal lengths of data and\/or missing-ness of data.\nWhile realizing that each of these issues have considerations unto themselves, is there a general reason why pre-processing each time series with a spline to interpolate (or very minimally extrapolate) the data to ameliorate these issues cannot be done?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":357,"Q_Id":60343442,"Users Score":1,"Answer":"I don't see why not. I think the main thing to consider is what assumption(s) you are making. The assumptions that come to mind for such a procedure, to me at least, are\n\nThe splines can adequately describe (smooth) each time series, and capture differences between them.\nThe inputs into the clustering procedure describe true differences between the splines, and hence the time series.\n\nThe input into the clustering procedure could be the estimated spline function, or the coefficients of the spline. Certainly, the estimated coefficients would be easier to use, but you'd want to ensure that differences between them truly represent differences in the spline function. This might boil down to orthogonality of the basis function of the splines, but I'm not sure if there is theory existing to back that up or not.","Q_Score":2,"Tags":"python,r,time-series,cluster-analysis,spline","A_Id":60348199,"CreationDate":"2020-02-21T17:14:00.000","Title":"Irregular\/missing data when clustering time series","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I deleted every instance of python, versions, off my computer then re-installed it and when I type\npython -V in cmd, it says No Python at C:\\(insert file path that does not exist). I went to my environment variables and added a new location in Path and it still shows the No python message. How do I fix this so I can use my new\nC:\\(new destination) for python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":60346843,"Users Score":0,"Answer":"The issue that happened was that pycharms would not change the outdated path even tho I deleted \/ re-installed it countless times. I un-checked the add to path option and it worked","Q_Score":0,"Tags":"python,python-3.x","A_Id":60404044,"CreationDate":"2020-02-21T22:08:00.000","Title":"Why is my python path pointing to a non existent file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a trained model and I need to run inference on a large directory of images. I know I can make a generator using ImageDataGenerator.flow_from_directory but it is not obvious how to associate predicted results with file names. Ideally given a keras model + directory of images i'd like to have an array of file names and predicted probabilities. How do I accomplish this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":220,"Q_Id":60350353,"Users Score":0,"Answer":"What you need to do is to separate the images into a different folder, corresponding to the class. The name of the folder should be the name of the class, by using the ImageDataGenerator.flow_from_directory() Keras will automatically infer the class names based on the directories. \nAs an example, you should have a folder named \"data\" that contains 2 folders named \"cat\" and \"dog\". \nThen you can call the method ImageDataGenerator.flow_from_directory(\"path\/to\/folder\/data\") and Keras will produce a dataset with the two classes, \"cat\" and \"dog\".\nDepending on the name of the files, the separation might be easy for you with a simple program, If not, I recommend using a program that groups together similar images, and based on that you can manually create the folders.","Q_Score":2,"Tags":"python-3.x,tensorflow,keras","A_Id":60354477,"CreationDate":"2020-02-22T08:29:00.000","Title":"Streaming images from directory and associating prediction with file name in tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need have MultipleChoiceField field in a form that should have over 50000 choices, therefore I cannot render it properly; I emptied the choices and went through an Ajax call to filter the options depending on the user inputs. Problem is that Django is obviously complaining that the choice is not part of the empty choices I provided.\nI think of three solutions to fix this but would like to know which one is 'best practice' or if there was a better one :\n\nCreate a second form which I check when the request is POST, same as the first one but with the choices initialized at the server starts\nDefine the __init__ of the form where if passed a parameter it would set choices to a variable initialized outside the form at the server starts\nFind a way to display the input without displaying the options in the template","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":55,"Q_Id":60350681,"Users Score":0,"Answer":"I went through the second option:\n\nin the class object the queryset \/ choices is set to the full list \nin the init it is set to empty\n\nThis show nothing in the template (and I add through Ajax) but allow everything in the cleaning","Q_Score":0,"Tags":"python,django,django-forms","A_Id":60361934,"CreationDate":"2020-02-22T09:17:00.000","Title":"MultipleChoiceField with massive choices best practice","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I work for a big global company (100 000 employees) and we have an internal software (its a database), this service\/softwareh can be accessed from all employes via their internet browsers. \nI need to change about 200 names in this databas and it is a VERY repetative work which takes time due to the cloud service is sometimes very slow. It usually takes 20 minutes to change one name... and I need to do 200 names!!\nI have asked if its possible to just write a script that picks up my information from an excel sheet, then open ups the internet explorer, go to the site, click on all the correct buttons and paste the correct values.\nThe answer I got was \"It is not possible to write a script to alter the database, you would need to go via IT department and via the correct programmers\". But I assume that is if I want to superbig mass-update the database? I just want to get rid of the repetative task so I dont need to sit and wait 20 minutes x 200 names. \nI guess my question is: Is it possible to write a script that performs actions via internet explorer EVEN IF ITS AN INTERNAL SOFTWARE\/CLOUD SERVICE we are visiting?\nPlease - Im very very new to coding, as you might tell.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":60352597,"Users Score":0,"Answer":"Welcome to stack overflow! It's definitely possible to automate those sorts of tasks using scripts, but if you're going down that route I would suggest that automating via internet explorer isn't the best option. Perhaps your IT team could look into creating a tool to access and modify the database directly instead? That would likely be much faster and less convoluted to set up than automating via a web interface.\nHowever, if you're set on using a web browser to automate tasks I would suggest that you start by looking into basic javaScript tutorials and jquery to get started with web manipulation (jquery is an addon library for javascript that lets you set up interactions with web page elements in a friendlier way)! Using javascript you can write scripts to simulate button clicks and enter text values, which sounds like what you're looking for.","Q_Score":0,"Tags":"java,python","A_Id":60352740,"CreationDate":"2020-02-22T13:24:00.000","Title":"Rookie question - Can I write a script that executes actions for our internal cloud software?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to develop a code between two python program where I pass a command line argument for the second program to execute from the first program.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":248,"Q_Id":60353274,"Users Score":0,"Answer":"One approach would be to call a function from the second program instead of using command-line arguments. You can do this by importing the said function.\nAnother approach would be to use command-line arguments as you said, with the command System or the Subprocess module.","Q_Score":1,"Tags":"python,command-line-arguments","A_Id":60353326,"CreationDate":"2020-02-22T14:43:00.000","Title":"How do I pass any file path as a command line argument from one program to another program in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have already disabled the selected choice by clicking on Tools > Preferences > Editor > Advanced Tab and then unchecking the \u201csave files after each run\u201d radio button, but whenever I run a file it still shows up.\nThere\u2019s no other relevant question addressing this issue on here or any major Anaconda-related forum, so I would appreciate advice to solve the bug.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":381,"Q_Id":60354254,"Users Score":1,"Answer":"You cannot run a *.py file without saving it first. So, while you try to run the file, it implicitly saves the file first and then runs. That is true regardless of your editor \/ IDE of choice.","Q_Score":0,"Tags":"python,anaconda,spyder","A_Id":60354564,"CreationDate":"2020-02-22T16:30:00.000","Title":"Why do .py files always save before running in Spyder despite disabling the option?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"This month, I learnt Python. I compiled the code and am able to run it on my laptop.  A simple code that asks the user yes\/no responses to questions that helps them traverse through a flowchart and end up with a final choice\/result.  \nHow do I turn this into a Python Web Application that can be accessed by others over a URL and not be dependent on my laptop to run it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":208,"Q_Id":60354832,"Users Score":1,"Answer":"You need to separate the parts of your app that have its logic from the ones which react to and update window content.\nThen you need to rewrite the window management part for the web. From the scratch. Also other parts if they rely on things that are not available in a browser (usually local filesystem access).\nIt is doable, but not that trivial as web apps have different architecture from desktop apps, there are issues with concurrency, preserving app state, and browser limitations, to name few.\nAnything more detailed requires you to describe what it is that your app does and how.","Q_Score":0,"Tags":"python,saas","A_Id":60354901,"CreationDate":"2020-02-22T17:29:00.000","Title":"How to move my Python application to the web?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So i am new to programming, and i am having trouble with index out of range errors.  Quick example:\nI have a list, lst = (5,7,8,9,10). \nI want to remove every even number, and every number to the right of an even number.\nI would approach this problem by getting the index of every even number, 'i' , and removing lst[i] and lst [i+1].  That will not work when the last number is even because there is no lst [i+1] after the last element in the list.  \nI have run into this issue on several basic problems i have been working on.  My approach to solving this is probably wrong, so i would like to know:\n\nHow can i\/Can i solve the problem this way, whether it is efficient or not?\nWhat would be the most efficient way to solve this problem?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":60355872,"Users Score":0,"Answer":"You can check if i+1 is greater than (Edit: or equal to) the length of the list, and if it is, not execute the code. \nYou can also handle this in a try\/except block. \nAs to the efficiency of this method of solving, seems fine to me. One gotcha in this approach is that people try to iterate over the list while modifying it, which can lead to unknown errors. If you're using the remove() function, you probably want to do it with a copy of the list.","Q_Score":0,"Tags":"python,indexing,range,logic","A_Id":60355948,"CreationDate":"2020-02-22T19:17:00.000","Title":"Index out of range confusion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've built myself a flask web server, and am deploying it with Gunicorn. It works perfectly well with the default flask app.run(), but this isn't meant for production, so up until now I've had my flask app running on gunicorn.\nHowever, since adding my TensorFlow program to my site, when I go to run a prediction it runs forever, I have timeout set to like 5 minutes. I tested with a print statement before and a print statement after my predict. Second print never shows up.\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":60356414,"Users Score":0,"Answer":"If you are running heavy calculations inside the route, you better change your program design.\nAt your route start the job on some other thread or process and return the status of the process start and ID to query its progress.\nThen you call query with polling [or web sockets] your heavy task with your ID, and return its status till the process is done and you can return the results","Q_Score":3,"Tags":"python,tensorflow,gunicorn,tensorflow2.0","A_Id":60356594,"CreationDate":"2020-02-22T20:20:00.000","Title":"Tensorflow getting stuck on prediction when deploying with gunicorn","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm running the following command using subprocess.check_call \n['\/home\/user\/anaconda3\/envs\/hum2\/bin\/bowtie2-build', '-f', '\/media\/user\/extra\/tmp\/subhm\/sub_humann2_temp\/sub_custom_chocophlan_database.ffn', '\/media\/user\/extra\/tmp\/subhm\/sub_humann2_temp\/sub_bowtie2_index', ' --threads 8']\nBut for some reason, it ignores the --threads argument and runs on one thread only. I've checked outside of python with the same command that the threads are launched. This only happens when calling from subprocess, any idea on how to fix this? \nthanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":18,"Q_Id":60358475,"Users Score":1,"Answer":"You are passing '--threads 8' and not '--threads',  '8'. Although it could be '--threads=8' but I don't know the command.","Q_Score":0,"Tags":"python,multithreading,shell","A_Id":60358498,"CreationDate":"2020-02-23T01:42:00.000","Title":"subprocess.check_call command called not using threads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I im trying to insert data read from a raspberry pi into a database hosted on another raspberry pi, i used mysql as database and my code is writtin in python on the \"client\" pi, this operation is all done on local network. \ni did all the config in order to connect as \"RaspberryPi\" user that i created and granted all permissions on the specific database and table on ip: 192.168.0.20 which is the client pi, i created and granted that user from root user of mysql which i granted all permission just before in case it needed to.\nmy mysql server is at 192.168.0.14. when i run my python program it shows this error:  Failed to insert record into HumiditySensor table 2003: Can't connect to MySQL server on '192.168.0.14:3306' (111 Connection refused)\nThe thing is that i used all the correct infos regarding host,database,user,password in my mysql.connector.connect() \nI veryfied if the server was using the right port to communicate and it was port 3306 which is what i expected.\nI saw online that the problem might be caused by tcp\/ip skipping, i looked at my my.cnf file and all i have is: \n[client-server]\n!includedir \/etc\/mysql\/conf.d\/\n!includedir \/etc\/mysql\/mariadb.conf.d\/\nThe rest is commented.\ni couldnt see bind-address nor tcp\/ip skipping so i dont believe it's because of an ip binding or wtv \nI also looked if my mysql server was running by looking if the mysql.sock file was in \/var\/run\/mysqld folder and it was... \ni did this command to see if the grant permission worked on my RaspberrPi user by typing: \nSELECT * from information_schema.user_privileges where grantee like \"'RaspberryPi'%\"; \nin mysql shell on host raspberry pi and it showed me in the \"IS_GRANTABLE\" section that everything was at \"YES\" instead of \"NO\" which means that this user has all permissions. \nI've been trying to solve this for days i really wish someone can help me on this, thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":759,"Q_Id":60359505,"Users Score":0,"Answer":"thanks for the answer! But i found it! if anybody encounters the same error i had, to solve that problem, you need to modify the \/etc\/mysql\/mariadb.conf.d\/50-server.cnf file since today when you install mysql, it install mariadb instead and i guess the config files are different. then once you get into 50-server.cnf you just need to comment \"bind-address = 127.0.0.1\" and it will now listen to other IPs requests.","Q_Score":0,"Tags":"python,mysql,raspberry-pi","A_Id":60367326,"CreationDate":"2020-02-23T05:36:00.000","Title":"2003: Can't connect to MySQL server on '192.168.0.14:3306' (111 Connection refused)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset which contains english statements. Each statement has been assigned a number of topics that the statement is about. The topics could be economy, sports, politics, business, science, etc. Each statement can have more than 1 topic. Some statements can have 1 topic, some can have 2 topics, so on and so forth. For the statement itself I am using TF-IDF vectors to convert statement into a feature vector. However, I am confused how to convert topics into a feature vector for machine learning training.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":60361601,"Users Score":0,"Answer":"You can create a binary column for each topic which will show whether the statement has this topic.","Q_Score":1,"Tags":"python,machine-learning,feature-extraction,feature-selection,feature-engineering","A_Id":60363881,"CreationDate":"2020-02-23T11:13:00.000","Title":"How do I convert topics for each item in the dataset into a feature vector, considering that each item can have more than 1 topic","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using selenium to collect cookies, and here's the question: does cookies store information about selenium?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":162,"Q_Id":60362601,"Users Score":0,"Answer":"You can check the cookies list by driver.manage().getCookies();\nReturn type is  Set <Cookies>.\nHope this will help.","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,cookies,pickle","A_Id":60363564,"CreationDate":"2020-02-23T13:20:00.000","Title":"What information about device does cookie store?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am given X RabbitMQ queues. Some of the queues contain duplicate messages (message is stored in queue A as well as in queue B for example).\nI am trying to achiveve one thing: process all the messages from \"input\" queues (I made a consumer that connects to these queues), remove duplicate messages on the go and send the result data to one output queue.\nWhat would be the fastest and most efficient way to do this? \nAs far as I know AMQP message_id property is optional, so I have to implement some kind of comparing \"seen\" messages to the newly arrived ones to achieve my goal.\nHashing message bodies came to my mind, but as I am relatively new to algorithms I am not sure which function to use and what to focus on.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":160,"Q_Id":60363070,"Users Score":1,"Answer":"I ended up hashing the message body using SHA1 and storing hash of seen messages.\nMessages that have not been seen are forwarded to result queue, already seen are discarded.","Q_Score":0,"Tags":"python,rabbitmq,amqp,pika","A_Id":60410605,"CreationDate":"2020-02-23T14:14:00.000","Title":"What is the best way to merge RabbitMQ queues using Python pika 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":1},{"Question":"I just want to know how can I change the name of mp4 video using python. I tried looking on the internet but could not find it. I am a beginner in python","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":447,"Q_Id":60363335,"Users Score":0,"Answer":"you can use os module to rename as follows...\n\nimport os\nos.rename('full_file_path_old','new_file_name_path)","Q_Score":0,"Tags":"python","A_Id":60363559,"CreationDate":"2020-02-23T14:42:00.000","Title":"How to change the name of a mp4 video using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why the result of \u201cbag\u201d > \u201capple\u201d is True in Python?\nI tried this code below i don't know why it show this result and how? Please some one explain it.\nprint(\"bag\" > \"apple\")\nTrue","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1309,"Q_Id":60363672,"Users Score":2,"Answer":"I believe this is True because Python compares the first letter of each word. And b is greater than a in Python.","Q_Score":0,"Tags":"python,python-3.6","A_Id":60363731,"CreationDate":"2020-02-23T15:18:00.000","Title":"Why the result of \u201cbag\u201d > \u201capple\u201d is True in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Which script is executed if a directory is passed as argument to python (e.g. if python is called in this way: $ python3 Domoticz-Google-Assistant\/)?\nBest regards,\nwewa","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":60363746,"Users Score":1,"Answer":"If you execute a directory as an argument to python, the file named __main__.py will be executed.","Q_Score":1,"Tags":"python,command-line,debian,command-line-arguments","A_Id":60363890,"CreationDate":"2020-02-23T15:25:00.000","Title":"Which python script is executed if directory path is passed as command line argument to 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 have a Django Project and want to connect to SQL Server 2019. But I have a problem when doing migration. Here is the error message:\n\ndjango.db.utils.NotSupportedError: SQL Server v15 is not supported.\n\nI'm using Django 2.1.15 and SQL Server Microsoft SQL Server 2019 (RTM) - 15.0.2000.5 \nDoes it mean this Django version cannot using SQL Server 2019?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":3906,"Q_Id":60364005,"Users Score":1,"Answer":"I just create an account to answer thi question. I lost a lot of time until can fix that. \nTo work with SQL Server 2019 i nedded to update the Django to actual version, 3.x and installed django-mssql-backend, django-pyodbc, pyodbc\nIn youd DATABASE definitions, add this line to work:\n'OPTIONS': {\n            'driver': 'ODBC Driver 17 for SQL Server',\n        },","Q_Score":2,"Tags":"python,sql,sql-server,django","A_Id":60697994,"CreationDate":"2020-02-23T15:50:00.000","Title":"Django Cannot Connect to SQL Server 2019","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am developing a robot based on StereoPI. I have successfully calibrated the cameras and obtained a fairly accurate depth map. However, I am unable to convert my depth map to point cloud so that I can obtain the actual distance of an object. I have been trying to use cv2.reprojectImageTo3D, but see no success. May I ask if there is a tutorial or guide which teaches how to convert disparity map to point cloud? \nI am trying very hard to learn and find reliable sources but see on avail. So, Thank you very much in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":60364209,"Users Score":0,"Answer":"By calibrating your cameras you compute their interior orientation parameters (IOP - or intrinsic parameters). To compute the XYZ coordinates from the disparity you need also the exterior orientation parameters (EOP).\nIf you want your point cloud relative to the robot position, the EOP can be simplified, otherwise, you need to take into account the robot's position and rotation, which can be retrieved with a GNSS receiver and intertial measurement unit (IMU). Note that is very likely that such data need to be processed with a Kalman filter.\nThen, assuming you got both (i) the IOP and EOP of your cameras, and (ii) the disparity map, you can generate the point cloud by intersection. There are several ways to accomplish this, I suggest using the collinearity equations.","Q_Score":0,"Tags":"python,image-processing,raspberry-pi3,point-clouds,stereo-3d","A_Id":60409243,"CreationDate":"2020-02-23T16:13:00.000","Title":"Converting depth map to pointcloud on Raspberry PI for realtime application","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"By using print(\"\"\"{{1}} {}\"\"\".format(\"x\")) I want to print this:\n\n{{1}} x\n\nBut I get this:\n\n{1} x\n\nBut after using print(\"\"\"{{{1}}} {}\"\"\".format(\"x\"))(three brackets rather than two) I get IndexError: tuple index out of range\nSo how can I print double brackets using .format on it?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":301,"Q_Id":60366849,"Users Score":1,"Answer":"Quadruple brackets print(\"\"\"{{{{1}}}} {}\"\"\".format(\"x\")) as double bracket prints one bracket in output so 4 prints two","Q_Score":0,"Tags":"python,string,printing,string.format","A_Id":60366871,"CreationDate":"2020-02-23T21:06:00.000","Title":"python print double Bracket \"{{}}\" using .format on it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need help in python 3.8. When I right-click on a Python script and select \"Edit with Idle\", it never opens, yet it makes a folder named _pycache_. Am using Windows 10.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":365,"Q_Id":60367206,"Users Score":1,"Answer":"If your file is named with a Python keyterm (eg print.py) then it will create the pycache folder when it attempts to link and interpret the code in the file. (Then crash and fail to run, as your file is now replacing the Python library file).","Q_Score":0,"Tags":"python,windows-10,python-idle,python-3.8","A_Id":60367311,"CreationDate":"2020-02-23T21:50:00.000","Title":"\"Edit with Idle\" doesn't open the file as expected","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm fairly new to programming and need help I've installed pip and I have installed NumPy using\npip install numpy\nand when I try to import it in my code I get \nModuleNotFoundError: No module named 'numpy'' (also the same for cv2)\nif this is any help\nI've installed pip, anaconda, and tensor flow 2.0 GPU\nMy os is Windows 10\nany help is good thank you!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":60368738,"Users Score":0,"Answer":"If you're running through anaconda, you should strictly use conda to install packages instead of pip. Using both will confuse python and give a 'module not found' error.","Q_Score":0,"Tags":"python,numpy,new-operator","A_Id":60368756,"CreationDate":"2020-02-24T02:12:00.000","Title":"Numpy and open cv not importing","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to do MLE regression using AR(p) by importing the module from statsmodels.tsa.ar_model import AutoReg, ar_select_order, but this ImportError keeps coming. How to solve this? Is there any other way I can do Autoregression in Python?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":9341,"Q_Id":60369122,"Users Score":2,"Answer":"do pip install statsmodels --upgrade and restart the environment.","Q_Score":6,"Tags":"python,time-series,statsmodels,mle,vector-auto-regression","A_Id":67997654,"CreationDate":"2020-02-24T03:19:00.000","Title":"Why ImportError: cannot import name 'AutoReg' from 'statsmodels.tsa.ar_model' occuring?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I built regression data model to predict house price upon several independent variables. And I got regression equation with coefficient. I used StandardScaler()to scale my variables before split the data set. And now I want to predict house price when given new values for independent variables using my regression model for that thing can I directly use values for independent variables and calculate price? or before include values for independent variables should I pass the values through StandardScaler() method??","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":107,"Q_Id":60370388,"Users Score":1,"Answer":"To answer your question, yes you have to process your test input as well but consider the following explanation.\nStandardScaler() standardize features by removing the mean and scaling to unit variance\nIf you fit the scaler on whole dataset and then split, Scaler would consider all values while computing mean and Variance.\nThe test set should ideally not be preprocessed with the training data. This will ensure no 'peeking ahead'. Train data should be preprocessed separately and once the model is created we can apply the same preprocessing parameters used for the train set, onto the test set as though the test set didn't exist before.","Q_Score":0,"Tags":"python,machine-learning,regression,data-science,data-modeling","A_Id":60370498,"CreationDate":"2020-02-24T06:07:00.000","Title":"Predicting price using regression data model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a way to boot an unattended diagnostic on HPE Proliant G10 units and to execute a specified test within embedded diagnostics (in this case extensive system test).\nSo far i understand you can boot directly to embedded diagnostics through redfish however i can't find a way to attach more instructions to the boot command in order to when booted into embedded diagnostics, continue and execute extensive system test.\nDoes anyone know of any possible workaround to achieve this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":60372592,"Users Score":0,"Answer":"After i have been in contact with HPE regarding this issue and after they have checked internally it turns out that there really is not a built in way to do this. Once the embedded diagnostics is booted it no longer have any active connection to the iLO itself and can't take commands such as what to do once booted.\nIf anyone would find some innovative solution to this, please contact me :)!\nBest regards,\nNuzvee","Q_Score":0,"Tags":"python,python-3.x,rest,boot,diagnostics","A_Id":60505084,"CreationDate":"2020-02-24T09:10:00.000","Title":"HPE redfish - boot unattended embedded diagnostics","Data Science and Machine Learning":0,"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 relatively new to data science and machine learning and I am currently working on my first project with a very large data set, with over a million rows and 88 columns`.\nI am currently in the process of cleaning the data and trying to use features like data.isnull(), .sum() and data[data.isnull().values.any(axis=1)].head() but my Jupiter notebook file will only show the first ten and last ten columns. \nJust looking for the best way to view the data or to be directed to any resources that may help.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":718,"Q_Id":60383131,"Users Score":0,"Answer":"You are using .head() in your code,\ndata[data.isnull().values.any(axis=1)].head().\nThis will give you first 10 columns by default. You can specify number of columns you want to see as argument to .head(). \nIf you remove .head() from above line you will see the full dataframe.\nSimilarly, check if you are using .tail() somewhere. That will give you last 10 columns.","Q_Score":0,"Tags":"python,python-3.x,pandas,dataframe,data-cleaning","A_Id":60383203,"CreationDate":"2020-02-24T20:04:00.000","Title":"Python\/Pandas only showing the first 10 and last 10 columns in a data frame","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am brand new to python and programming more generally so 1) I'm an ignorant noob and I apologize and 2) I'm really just using IDLE for very basic learning. I'm running python 3.7.6 on Mac OS Catalina 10.15.3\nMy problem is bizarre: When I go to save a new .py file, IDLE freezes and becomes unresponsive. I'll hit CMD+S on a new\/'Untitled.py' file, the save folder will pop open, and I can name the new file\/navigate folders, but once I hit \"Save\", the program freezes with the save folder still open, except now the Save\/Cancel buttons are greyed out and the entire application becomes unresponsive. My only recourse is to Force Quit and relaunch IDLE, and the new file I was trying to save never saved. You can imagine how fun this is.\nWhat's weird is it doesn't happen every time. If I open IDLE, open a new file and very quickly\/immediately save (which I try to do by default), then the file will save. Once I've saved it once, I have no problems saving the existing file as I work on it. That is, the issue is only with the creation\/save of new files. I'm also not sure why sometimes I can Save a new file and other times (especially if IDLE has been open for a while) it crashes.\nTo be clear: I can open files, save existing files, and run programs I've written without incident. I am not getting any warnings, crash notifications, or notices of any kind that even acknowledge that IDLE is acting up. \nI had 3.8, which I replaced for 3.7.6 thinking a more stable version might solve my problems, but no dice. I only have python 3.7.6 on my computer: No python 2, nothing else. I have no idea what's going on but this is super frustrating and I just want to be able to learn Python without these weird roadblocks.\nPlease help!","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":3766,"Q_Id":60384798,"Users Score":0,"Answer":"I had the same problem, and as Aadi suggested, I was able to fix it by changing the location of where the file was saved. Possibly, this relates to very long paths, at least in Windows 10.\nThe path that didn't work was 114 characters long. The path that did work was 93 characters long. The paths are the same up to character 80 and use underscore (_) but no unusual characters.","Q_Score":3,"Tags":"python,macos,tkinter,freeze,python-idle","A_Id":63677364,"CreationDate":"2020-02-24T22:24:00.000","Title":"IDLE freezing\/unresponsive when saving new file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am brand new to python and programming more generally so 1) I'm an ignorant noob and I apologize and 2) I'm really just using IDLE for very basic learning. I'm running python 3.7.6 on Mac OS Catalina 10.15.3\nMy problem is bizarre: When I go to save a new .py file, IDLE freezes and becomes unresponsive. I'll hit CMD+S on a new\/'Untitled.py' file, the save folder will pop open, and I can name the new file\/navigate folders, but once I hit \"Save\", the program freezes with the save folder still open, except now the Save\/Cancel buttons are greyed out and the entire application becomes unresponsive. My only recourse is to Force Quit and relaunch IDLE, and the new file I was trying to save never saved. You can imagine how fun this is.\nWhat's weird is it doesn't happen every time. If I open IDLE, open a new file and very quickly\/immediately save (which I try to do by default), then the file will save. Once I've saved it once, I have no problems saving the existing file as I work on it. That is, the issue is only with the creation\/save of new files. I'm also not sure why sometimes I can Save a new file and other times (especially if IDLE has been open for a while) it crashes.\nTo be clear: I can open files, save existing files, and run programs I've written without incident. I am not getting any warnings, crash notifications, or notices of any kind that even acknowledge that IDLE is acting up. \nI had 3.8, which I replaced for 3.7.6 thinking a more stable version might solve my problems, but no dice. I only have python 3.7.6 on my computer: No python 2, nothing else. I have no idea what's going on but this is super frustrating and I just want to be able to learn Python without these weird roadblocks.\nPlease help!","AnswerCount":5,"Available Count":5,"Score":-0.0399786803,"is_accepted":false,"ViewCount":3766,"Q_Id":60384798,"Users Score":-1,"Answer":"I also came across with same issue, this is only issue of currupt file,please delete recent python IDLE file that you have created,this will definately work","Q_Score":3,"Tags":"python,macos,tkinter,freeze,python-idle","A_Id":64229624,"CreationDate":"2020-02-24T22:24:00.000","Title":"IDLE freezing\/unresponsive when saving new file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am brand new to python and programming more generally so 1) I'm an ignorant noob and I apologize and 2) I'm really just using IDLE for very basic learning. I'm running python 3.7.6 on Mac OS Catalina 10.15.3\nMy problem is bizarre: When I go to save a new .py file, IDLE freezes and becomes unresponsive. I'll hit CMD+S on a new\/'Untitled.py' file, the save folder will pop open, and I can name the new file\/navigate folders, but once I hit \"Save\", the program freezes with the save folder still open, except now the Save\/Cancel buttons are greyed out and the entire application becomes unresponsive. My only recourse is to Force Quit and relaunch IDLE, and the new file I was trying to save never saved. You can imagine how fun this is.\nWhat's weird is it doesn't happen every time. If I open IDLE, open a new file and very quickly\/immediately save (which I try to do by default), then the file will save. Once I've saved it once, I have no problems saving the existing file as I work on it. That is, the issue is only with the creation\/save of new files. I'm also not sure why sometimes I can Save a new file and other times (especially if IDLE has been open for a while) it crashes.\nTo be clear: I can open files, save existing files, and run programs I've written without incident. I am not getting any warnings, crash notifications, or notices of any kind that even acknowledge that IDLE is acting up. \nI had 3.8, which I replaced for 3.7.6 thinking a more stable version might solve my problems, but no dice. I only have python 3.7.6 on my computer: No python 2, nothing else. I have no idea what's going on but this is super frustrating and I just want to be able to learn Python without these weird roadblocks.\nPlease help!","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":3766,"Q_Id":60384798,"Users Score":0,"Answer":"You don't have to make\/save python files in IDLE. You can open any text editor, type the code, and save as name.py. Then you can open that in IDLE. I would use that for now.","Q_Score":3,"Tags":"python,macos,tkinter,freeze,python-idle","A_Id":64082478,"CreationDate":"2020-02-24T22:24:00.000","Title":"IDLE freezing\/unresponsive when saving new file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am brand new to python and programming more generally so 1) I'm an ignorant noob and I apologize and 2) I'm really just using IDLE for very basic learning. I'm running python 3.7.6 on Mac OS Catalina 10.15.3\nMy problem is bizarre: When I go to save a new .py file, IDLE freezes and becomes unresponsive. I'll hit CMD+S on a new\/'Untitled.py' file, the save folder will pop open, and I can name the new file\/navigate folders, but once I hit \"Save\", the program freezes with the save folder still open, except now the Save\/Cancel buttons are greyed out and the entire application becomes unresponsive. My only recourse is to Force Quit and relaunch IDLE, and the new file I was trying to save never saved. You can imagine how fun this is.\nWhat's weird is it doesn't happen every time. If I open IDLE, open a new file and very quickly\/immediately save (which I try to do by default), then the file will save. Once I've saved it once, I have no problems saving the existing file as I work on it. That is, the issue is only with the creation\/save of new files. I'm also not sure why sometimes I can Save a new file and other times (especially if IDLE has been open for a while) it crashes.\nTo be clear: I can open files, save existing files, and run programs I've written without incident. I am not getting any warnings, crash notifications, or notices of any kind that even acknowledge that IDLE is acting up. \nI had 3.8, which I replaced for 3.7.6 thinking a more stable version might solve my problems, but no dice. I only have python 3.7.6 on my computer: No python 2, nothing else. I have no idea what's going on but this is super frustrating and I just want to be able to learn Python without these weird roadblocks.\nPlease help!","AnswerCount":5,"Available Count":5,"Score":0.0399786803,"is_accepted":false,"ViewCount":3766,"Q_Id":60384798,"Users Score":1,"Answer":"I've also had this problem, and what I did was change the location of where the file would save. I suggest trying this to help.","Q_Score":3,"Tags":"python,macos,tkinter,freeze,python-idle","A_Id":63419425,"CreationDate":"2020-02-24T22:24:00.000","Title":"IDLE freezing\/unresponsive when saving new file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am brand new to python and programming more generally so 1) I'm an ignorant noob and I apologize and 2) I'm really just using IDLE for very basic learning. I'm running python 3.7.6 on Mac OS Catalina 10.15.3\nMy problem is bizarre: When I go to save a new .py file, IDLE freezes and becomes unresponsive. I'll hit CMD+S on a new\/'Untitled.py' file, the save folder will pop open, and I can name the new file\/navigate folders, but once I hit \"Save\", the program freezes with the save folder still open, except now the Save\/Cancel buttons are greyed out and the entire application becomes unresponsive. My only recourse is to Force Quit and relaunch IDLE, and the new file I was trying to save never saved. You can imagine how fun this is.\nWhat's weird is it doesn't happen every time. If I open IDLE, open a new file and very quickly\/immediately save (which I try to do by default), then the file will save. Once I've saved it once, I have no problems saving the existing file as I work on it. That is, the issue is only with the creation\/save of new files. I'm also not sure why sometimes I can Save a new file and other times (especially if IDLE has been open for a while) it crashes.\nTo be clear: I can open files, save existing files, and run programs I've written without incident. I am not getting any warnings, crash notifications, or notices of any kind that even acknowledge that IDLE is acting up. \nI had 3.8, which I replaced for 3.7.6 thinking a more stable version might solve my problems, but no dice. I only have python 3.7.6 on my computer: No python 2, nothing else. I have no idea what's going on but this is super frustrating and I just want to be able to learn Python without these weird roadblocks.\nPlease help!","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":3766,"Q_Id":60384798,"Users Score":0,"Answer":"I'd suggest reinstalling python idle (your programs will be saved). If this doesn't work then maybe it has something to do with your security on the mac.","Q_Score":3,"Tags":"python,macos,tkinter,freeze,python-idle","A_Id":60671970,"CreationDate":"2020-02-24T22:24:00.000","Title":"IDLE freezing\/unresponsive when saving new file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I made a Python GUI application using tkinter.\nThe problem I have is that you can run as many instances as you want.\nBut I only want one instance to be running, if the application is already running and I click again EXE or shortcut, instead it should bring existing running application to the focus.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":591,"Q_Id":60386033,"Users Score":1,"Answer":"A simple cross-platform trick is to write the process id (pid) of the first instance to a file in a known location (eg: my_program.pid in the system temporary directory). Each time you start up, check to see if that file exists. If it exists, read the pid and check if the process is running. If the process is still running, exit. If not, keep running and write your process id to the file. When the program that wrote the file exits, it should delete the file. \nThere are possible race conditions (eg: the running program could quit in the brief moment after checking but before your program decides to quit), but unless you're building a commercial-grade application, this is usually good enough.","Q_Score":2,"Tags":"python,tkinter","A_Id":60387370,"CreationDate":"2020-02-25T00:44:00.000","Title":"How to tell tkinter application to run only one instance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"It makes sense that pooled output is used for sentence level analysis (e.g classification). I am wondering, is the token level embedding better for named entity recongition? I would've thought so, but am unsure how to take the sequence output and manipulate for NER. Do I just take a slice [:, :, -1] for [batch_size, num_tokens, 768]?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":669,"Q_Id":60386576,"Users Score":2,"Answer":"If we talk about bert, there we get two output\no1, o2 = self.bert(ids, attention_mask=mask)\n\no1-Sequential output: Each and every token will receive its own embedding  (can be used in NER Pooled output.)\no2-Pooled output: Whole Sentence receives an embedding. (can be used in classification problem )\n\nIn the forward pass, you can further modify the bert output according to your use case.","Q_Score":3,"Tags":"python,nlp","A_Id":64402117,"CreationDate":"2020-02-25T02:11:00.000","Title":"pooled output vs sequence output for NER with BERT","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I appreciate it if somebody gives the main idea of how to handle submission\/retrieval form implementation in Bootstrap modals. I saw many examples on google but it is still ambiguous for me. Why it is required to have a separate Html file for modal-forms template? Where SQL commands will be written? What is the flow in submission\/retrieval forms (I mean steps)? What is the best practice to implement these kind of forms? I'm fairly new to Django, please be nice and helpful.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":60387127,"Users Score":0,"Answer":"No need for separate file for modal-form. Here MVT structure following, whenever forms are used. Easy interaction to template. Moreover if you go through Django documentation, you will get to know easily. \nSubmission - mention the form action url. It will call that and check the django forms","Q_Score":0,"Tags":"python,jquery,django,forms,twitter-bootstrap","A_Id":60387291,"CreationDate":"2020-02-25T03:32:00.000","Title":"What is the best way to implement Django 3 Modal forms?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When the outputs (prediction) are the probabilities coming from a Softmax function, and the training target is one-hot type, how do we compare those two different kinds of data to calculate the accuracy? \n(the number of training data classified correctly) \/ (the number of the total training data) *100%","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":365,"Q_Id":60387266,"Users Score":0,"Answer":"Usually, we assign the class label with highest probability in the output of the soft max function as the label.","Q_Score":1,"Tags":"python,neural-network,multiclass-classification","A_Id":60387487,"CreationDate":"2020-02-25T03:53:00.000","Title":"How do we calculate the accuracy of a multi-class classifier using neural network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We know that the default threshold for success in a Binary Classification of the Logistic Regression model is > 0.5.\nI'm curious to know the output of this model if the predicted probability is exactly 0.5 for both Success and Failure. Can someone clarify me?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":178,"Q_Id":60387801,"Users Score":1,"Answer":"To simply put, the model is not confident in making the decision. You can choose either of the class labels based on your problem -- do you want high precision or high recall ? However a more systematic way is to use ROC curve to find the optimal threshold value.","Q_Score":1,"Tags":"python,machine-learning,data-science,logistic-regression","A_Id":60387875,"CreationDate":"2020-02-25T05:04:00.000","Title":"How a Logistic Regression model reacts if the probability of success and failure are exactly 0.5?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem, I have an Excel file (.xlsx) and this file have some buttons in it to help to change the language and a button that make a raport based of the data.\nThe problem is...If I write something in the file and then I save it with openpyxl the file will lose those buttons and looks like a normal excel.\nWhat can I use to save that file with the same format?\nI installed an addin to see those buttons.\nWhat can I do?\nEDIT: I tried to save it .xlsm but it doesn't open if I do that","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":60390029,"Users Score":0,"Answer":".xlsx dose not have macros. Save it as .xlsm instead.","Q_Score":1,"Tags":"python,excel","A_Id":60390105,"CreationDate":"2020-02-25T08:06:00.000","Title":"Saving Excel file with Python (Openpyxl)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the training data, I did feature engineering and clean my data. Is this important to do the same with test data?\nI know some basic modifications like label encoding, dependent\/independent feature split, etc.. are required in test data as well. But do we really need to CLEAN the test data before we do the predictions?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1188,"Q_Id":60392255,"Users Score":1,"Answer":"It depends:\nNormalizing the data: If you normalized your training data, then yes, normalize the test data in exactly the way you normalized the training data. But be careful that you do not re-tune any parameters you tuned on the training data.\nFilling missing values: idem. Treat the test data as the training data but do not re-tune any of the parameters.\nRemoving outliers: probably not. The aim of the test set is to make an estimate about how well your model will perform on unseen data. So removing outliers will probably not be a good idea.\nIn general: only do things to your test data that you can\/will also do on unseen data upon applying your model.","Q_Score":0,"Tags":"python,machine-learning,data-science,data-cleaning","A_Id":60392572,"CreationDate":"2020-02-25T10:18:00.000","Title":"Is this important to clean test data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Mac has recently updated its terminal shell to Zsh from bash. As a python programmer, I'd like to have a consistency in python versions across all the systems that includes terminals, & IDE.\nOn a bash shell, to update the python version in the terminal to 3.8.1, I had followed the below process\nnano ~\/.bash_profile\nalias python=python3\nctrl + x\ny\nenter\nThis enabled me to update the python version from 2.7.6 to 3.8.1. However, repeating the same steps for zsh shell didn't work out. Tried a tweak of the above process, and somehow stuck with 3.7.3\nsteps followed\nwhich python3 #Location of the python3.8.1 terminal command file is found. Installed it.\npython --version #returned python 3.7.3\nPS: I am an absolute beginner in python, so please consider that in your response. I hope i am not wasting your time.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1124,"Q_Id":60399694,"Users Score":1,"Answer":"it is actually not recommendet to update the default Python executable system-wide because some applications are depending on it.\nAlthough, you can use venv (virtual environment) or for using another version of Python within your ZSH you can also put an alias like python='python3' in  your ~\/.zsh_profile and source it.\nHope that helps.\nGreetings","Q_Score":0,"Tags":"python,bash,shell,terminal,zsh","A_Id":60399819,"CreationDate":"2020-02-25T16:58:00.000","Title":"When switching to zsh shell on mac terminal from bash, how do you update the base python version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on a project written in python and using django to build a website as well. I have a function which is pulling the information from a website and putting that information into a dictionary. When the users refresh the browser, the website will show the latest update of that dictionary, so far I am doing the updates being triggered by the browser but this is only for testing.\nSo, after several headaches I could finally install celery and make it work, so I have my website running with \"python manage.py runserver\", and at the same time I have two celery processes running: \"celery -A tasks worker -l info pool=solo\" and \"celery -A tasks beat --loglevel=info\". So far everything seems to be working until I realized that the dictionary is being updated but not for all users who access the website, looks like each user has his own instance of the dictionary. \nSo the idea is to have celery updating the dictionary with the information pulled from the website and all users just seeing what is inside the dictionary variable. Can I do this without a database or a file being written every time the update function is called?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":60399772,"Users Score":0,"Answer":"Coming back on this, it seems my problem was Celery. Looks like Celery was running its own instance of my program when I ran the commands mentioned above. Then when I started the webserver using \"python manager.py runserver\" that had nothing to do with celery tasks. I stopped using celery and now I am using a background scheduler for doing the same, everything works now.","Q_Score":0,"Tags":"python,django,celery","A_Id":60460825,"CreationDate":"2020-02-25T17:02:00.000","Title":"Python Django - Variables shared between multiple users","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"is there a way to copy a cell with code and its output in Google Colab or in jupyter notebooks in general and paste it into another notebook?\nMany thanks","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4533,"Q_Id":60401975,"Users Score":2,"Answer":"Select the cell by drag selecting or command-clicking. Then, Control-C \/ Control-V keyboard shortcuts will copy\/paste the cell between notebooks.","Q_Score":1,"Tags":"python-3.x,jupyter-notebook,google-colaboratory","A_Id":60403383,"CreationDate":"2020-02-25T19:36:00.000","Title":"Copy cells including output from one notebook to another?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"is there a way to copy a cell with code and its output in Google Colab or in jupyter notebooks in general and paste it into another notebook?\nMany thanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4533,"Q_Id":60401975,"Users Score":1,"Answer":"In windows, hold Ctrl button and now with your mouse select all the cells that you want to copy. After selecting, press Ctrl+C to copy and Ctrl+V to paste.","Q_Score":1,"Tags":"python-3.x,jupyter-notebook,google-colaboratory","A_Id":65128719,"CreationDate":"2020-02-25T19:36:00.000","Title":"Copy cells including output from one notebook to another?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm trying to make a color gradient, from a color to completely black, as well as from a color to completely white.\nSo say I have (175, 250, 255) and I want to darken that color exactly 10 times to end at (0, 0, 0), how could I do this?\nI'd also like to brighten the color, so I'd like to brighten it exactly 10 times and end at (255, 255, 255).","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":517,"Q_Id":60402063,"Users Score":0,"Answer":"Many ways to solve this one. One idea would be to find the difference between your current value to the target value and divide that by 10. \nSo (175, 250, 255) to (0, 0, 0) difference is (175, 250, 255), then divide that by ten to have what you would subtract each of the ten steps. So subtract (-17.5, -25, -25.5) every step, rounding when needed.","Q_Score":1,"Tags":"python,colors","A_Id":60402144,"CreationDate":"2020-02-25T19:43:00.000","Title":"How can I darken\/lighten a RGB color","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"so basically I'm trying to make a command line interface using python and I have text area where commands are being entered.\nwhat I wanted to achieve is each command is executing without pressing the button at all( simply on pressing enter)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":200,"Q_Id":60402442,"Users Score":0,"Answer":"You can bind the Enter key to a function with .bind('<Return>', function).","Q_Score":0,"Tags":"python,user-interface,tkinter,tkinter-text","A_Id":60404029,"CreationDate":"2020-02-25T20:11:00.000","Title":"can I run a command in Tkinter without Button","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a docker image that consists of a python script, which takes some arbitrary source code and eval()'s it\nLet's say the code was rm -rf. Would this delete anything on the host's file system? \nI think the answer is \"no\", but I just want to confirm before trying it out.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":841,"Q_Id":60403970,"Users Score":1,"Answer":"So on the one hand, yes, Docker's filesystem isolation means that commands like rm -rf by default can't do more than corrupt the container's filesystem.\nThere's a fairly wide variety of things people do routinely that weaken this.  Do you bind-mount your host's source code into the container to simplify development?  Malicious code could corrupt your development tree, or surreptitiously slip commits into your .git directory.  Bind-mount the Docker socket into the container so you can launch other containers?  It's trivial to take advantage of that to root the whole host.\nThis is also just a narrow slice of what's possible with eval().  Linux kernel exploits happen fairly regularly, and since Docker containers share the host kernel, eval()ed code could take advantage of this.  There are also things like cryptocurrency miners that aren't dangerous per se but you still don't want to be running them for other people.\nAs far as your narrow question goes, yes, Docker gives you protection from malicious code corrupting the host filesystem, but there are still a lot of other things malicious code could do and I would not try to use a Docker container as a sandbox for truly untrusted code.","Q_Score":0,"Tags":"python,docker,file","A_Id":60405371,"CreationDate":"2020-02-25T22:14:00.000","Title":"Can \"rm -rf\" on a docker container delete files on the host?","Data Science and Machine Learning":0,"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 unable to find the pylogit package in python, when I run this \"import pylogit as pl\", I get back the error saying no module called pylogit. can you please advise.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":118,"Q_Id":60404205,"Users Score":3,"Answer":"pylogit is not a standard Python module. It is not installed by default. You need to install the library on your machine with a package manager like pip or conda.","Q_Score":0,"Tags":"python,installation,package,python-import","A_Id":60404234,"CreationDate":"2020-02-25T22:38:00.000","Title":"No module called pylogit","Data 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 have a series of strings of dates and want to make all of them into datetime objects for a searchable database. I'm really having trouble understanding the time zone. \nIn the applications I'm working with, sometimes the time zone is expressed as three letters (\"EST\") and sometimes it's \"-5:00\". \npytz.timezone('EST') is okay. pytz.timezone('UTC+05:00') does not seem to work. However, I CAN get it pytz to output UTC as a string. For the utc times we have datetime.timezone(datetime.timedetla(hours=-5), 'UTC') but that won't be consistent with pytz.timezone. I would like to use pytz.timezone for all the time zones. How do I do it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":34,"Q_Id":60404444,"Users Score":1,"Answer":"Since some of your strings have only abbreviations, sorry but you're out of luck.  There is no solution.\nThe problem is that time zone abbreviations are not unique.  Some common examples: CST has 3 different interpretations (Central (US), China, or Cuba), and IST has 3 different interpretations (Israel, Ireland, and India).  Which should your program pick?\nIt's not a problem just for Python.  It's the nature of time zone abbreviations.  You'd need some other information to disambiguate.","Q_Score":0,"Tags":"python,string,datetime,parsing,pytz","A_Id":60406440,"CreationDate":"2020-02-25T23:01:00.000","Title":"Reading time zone strings in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to access the database configured in the setting via a shell command in Flask. Is there any equivalent command in Flask to python manage.py dbshell in Django?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":361,"Q_Id":60405637,"Users Score":0,"Answer":"No there is no such command exists for flask , but you can access your db with normal db clients","Q_Score":0,"Tags":"python,database,flask","A_Id":60406419,"CreationDate":"2020-02-26T01:45:00.000","Title":"Shell command to access db in Flask","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am unable to recover files and folders deleted from spyder 4.\nAnd the deleted files are not in the trash also. Anyone help me here. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2260,"Q_Id":60405780,"Users Score":0,"Answer":"(Spyder maintainer here) I'm sorry but files deleted through our Files or Project panes are permanently deleted from your hard drive. That's why we show a warning message about that before proceeding.\nWe understand this is a serious problem and we'll try to fix it in Spyder 5. Sorry for the inconvenience.","Q_Score":0,"Tags":"python-3.x,ide,spyder,recovery,data-recovery","A_Id":60405902,"CreationDate":"2020-02-26T02:07:00.000","Title":"Recover deleted files in spyder 4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am aware that in python, integers from -5 to 256 can have the same ID. However, what are the consequences in the case where two immutable objects have the same ID? How about the consequences when two mutable objects have the same ID?\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":93,"Q_Id":60406091,"Users Score":5,"Answer":"An id is definitionally unique at a given point in time (only one object can have a given id at once). If you see the same id on two names at the same time, it means it's two names referring to the same object. There are no \"consequences\" to this for immutable types like int, because it's impossible to modify the object through either alias (x = y = 5 aliases both x and y to the same 5 object, but x += 1 is roughly equivalent to x = x + 1 for immutable objects, rebinding x to a new object, 6, not modifying the 5 object in place); that's why optimizations like the small int cache you've observed are safe.","Q_Score":1,"Tags":"python,object,immutability,mutable","A_Id":60406161,"CreationDate":"2020-02-26T02:56:00.000","Title":"Mutable and immutable objects in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to list the packages for which I specified the version number. For example, if I specified scipy version but not numpy version by installing them like this: conda install scipy=0.15.0 numpy, I would like to be able to know that I specified version 0.15.0 for scipy. Furthermore, how can I unspecify a package version if I do not want to specifically use that version but I would rather like to get the latest possible version?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":347,"Q_Id":60407724,"Users Score":1,"Answer":"There is no any programmatic way to extract the information you are looking for. The only way I could think of is by extracting the history of the commands you typed while installing your packages through your terminal (in case of mac or linux machines) or command prompt (in case of windows machine).\n\nFor checking the history of typed commands in MAC or LINUX:\nType history in your terminal window\nFor checking the history of typed commands in Windows:\nType doskey \/history or press F7 key inside your command\nprompt\n\nAfter extracting this history of commands you typed, you can create a piece of code to check for commands in which you have specified version numbers. \nHow can I unspecify a package version if I do not want to specifically use that version but I would rather like to get the latest possible version? You can just do pip install [package_name] --upgrade in case of pip or conda update [package_name] in case of conda to upgrade a package to its latest version","Q_Score":2,"Tags":"python,version-control,anaconda","A_Id":60408388,"CreationDate":"2020-02-26T06:05:00.000","Title":"list anaconda packages for which I specified version number","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a table named tableA with columns \"name\" and \"age\" built using model.py. \nNow I wanted to add another column like \"gender\" but this time not by changing model.py but directly through admin panel.\nI know that admin panel allows to add values to the existing table but i wanted to add a feature where we can add columns too through the admin panel and not by hardcoding in model.py\nSo is it possible?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":387,"Q_Id":60408667,"Users Score":0,"Answer":"Actually you can create a view, which one connects to DB and you can write there a creating of any column for this table using raw SQL. \nBut it's an awful way. In future, you will get an enormous count of different troubles. \nI'd better say: it's not possible.","Q_Score":0,"Tags":"python,django,admin","A_Id":60409826,"CreationDate":"2020-02-26T07:19:00.000","Title":"How to add columns through django admin panel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How do I add python to path? Whenever I type 'python' in cmd, it opens Python in the Microsoft Store even though I have previously installed Python through their website. However, when I type 'py' in cmd, python starts.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":200,"Q_Id":60410835,"Users Score":0,"Answer":"You can go to Control Panel ->System and Security->System -> Advanced System Settings\nThis opens a SystemPropertyDialogBox(Advanced) -> Environment Variables -> Add the Python Path in Path Environment variable\nAnd then use another Command Prompt.","Q_Score":0,"Tags":"python","A_Id":60410958,"CreationDate":"2020-02-26T09:39:00.000","Title":"How do I add Python to path in Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a bash script to deploy some code to AWS.  It mostly works but I'm having issues activating my virtual environment.   It seems it might be to do with line endings because I'm trying to activate a windows venv using Scripts\/activate.\nI see these types of errors in the logs:\nScripts\/activate: line 3: $'\\r': command not found\nScripts\/activate: line 4: $'\\r': command not found\nScripts\/activate: line 10: syntax error near unexpected token `$'{\\r''\nMy script creates, installs packages then destroys the venv.  If I comment out the creating and destroy and change the line endings of the activate script to 'LF' it works.   So How can I force LF endings instead of CRLF on virtual env creation?\nThis is the line that is creating the env at the moment:\nvirtualenv $VENV","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":179,"Q_Id":60410921,"Users Score":1,"Answer":"fixed with dos2unix command\ndos2unix Scripts\/activate","Q_Score":1,"Tags":"python,bash,amazon-web-services,aws-lambda,virtualenv","A_Id":60411524,"CreationDate":"2020-02-26T09:43:00.000","Title":"activating python venv from bash in Windows. How to resolve problem with line endings?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Firstly,I know that -w is no-console when I use pyinstaller.\nDue to some reasons,I have to use console.Is it possible to close the CMD window(without exiting this exe file) and can show it again when I need it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":187,"Q_Id":60410985,"Users Score":0,"Answer":"No it isn't. If you want to have a window like that, you'll have to write a custom shell window using wxPython or PyQt5.","Q_Score":0,"Tags":"python,python-3.x,pyinstaller","A_Id":60462413,"CreationDate":"2020-02-26T09:47:00.000","Title":"Close the cmd window after using pyinstaller","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a supervised multi-label ML model which for now works by predicting a \"tag\" (label) for an input from the user, based on the dataset it was trained with. The training dataset had two columns - posts & tags. \nWhenever I give anything as an input, the prediction is a relevant tag for it. But when the input is something which is not in the dataset, the output is again some random tag. I'm looking for a solution in the context of creating a chatbot, which would return something like \"Sorry, I couldn't understand that\" if the input is something different from what the machine has been trained for. How do I do that? Is there any way to get an \"empty label\" in such a case so that I can simply map my responses accordingly for that condition?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":60412386,"Users Score":0,"Answer":"You can use a softmax in your last layer and create a treshold for your prediction. \nIf the score of your maximum prediction is under the treshold, the chatbot can answer \"Sorry, I couldn't understand that\". \nAs you didn't give any code, I can't show you how yo add a treshold but it is quite easy to find it on Stack Overflow.","Q_Score":0,"Tags":"python,machine-learning,nlp,chatbot,multilabel-classification","A_Id":60412548,"CreationDate":"2020-02-26T10:58:00.000","Title":"How to get \"no label\" from a supervised multi-label machine learning model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a table field with entries such as e.g. 02-65-04-12-88-55.\nEach position (separated by -) represents something. (There is no '-' in the database, that's how it's displayed to the user).\nUsers would like to search by the entry's specific position. I am trying to create a queryset to do this but cannot figure it out. I could handle startswith, endswith but the rest - I have no idea.\nOther thoughs would be to split the string at '-' and then query at each specific part of the field (if this is possible).\nHow can a user search the field's entry at say positions 0-1, 6-7, 10-11 and have the rest wildcarded and returned?\nIs this possible? I may be approaching this wrong? Thoughts?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":209,"Q_Id":60412412,"Users Score":0,"Answer":"You could use a something__like='__-__-__-__-88-__' query, but it's likely to not be very efficient (since the database will have to scan through all rows to find a match).\nIf you need to lots of these queries, it'd be better to split these out to actual fields (something_1, something_2, etc.)","Q_Score":0,"Tags":"python,django,django-queryset","A_Id":60412471,"CreationDate":"2020-02-26T11:00:00.000","Title":"Django Queryset - Can I query at specific positions in a string for a field?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"It seems like all ok for desktop interface but doesn't work correctly for mobile devices. This trouble is appear only when i put my custom base.html.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":60412574,"Users Score":0,"Answer":"try clearing you browser cache by CONT + Shift + R\nit is some time your browser cache problem that your admin interface didn't load correctly.","Q_Score":1,"Tags":"python,django,django-forms,django-templates,django-admin","A_Id":60412707,"CreationDate":"2020-02-26T11:09:00.000","Title":"Why when i overriding base.html django-admin has been disable responsive interface?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to Python unit testing and I am not sure how i can create a unit test of this function that returns a connection make sure that it always returns something?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":275,"Q_Id":60415665,"Users Score":0,"Answer":"For unit testing any SQL connection, you can use the command SELECT 1 which will always return 1 if the command executed successfully. You can specify more columns, column names, and types by just specifying the values in the query.\nExample: SELECT 1 as NUMBER, 'hello world' as TEXT","Q_Score":0,"Tags":"python,python-3.x,python-2.7,unit-testing,amazon-redshift","A_Id":60443580,"CreationDate":"2020-02-26T14:03:00.000","Title":"Redshift connection unit testing 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":"was just wondering whether anyone had any thoughts on best practices when working in databricks. It is financially costing a lot to develop within databricks, hence would like to know where else it would be best to develop python code in. With thought also to collaborative work, is there a similar set up to databricks for collaborative work that is free or of little cost to use. \nAny suggestions, greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":284,"Q_Id":60415762,"Users Score":0,"Answer":"The cost of Databricks is really related to the size of the clusters you are running (1 worker, 1 driver or 1 driver 32 workers?), the spec of the machines in the cluster (low RAM and CPU or high RAM and CPU), and how long you leave them running (always running or short time to live, aka \"Terminate after x minutes of inactivity\".  I am also assuming you are not running the always on High Concurrency cluster mode.\nSome general recommendations would be:\n\nwork with smaller datasets in dev, eg representative samples which would enable you to...\nwork with smaller clusters in dev, eg instead of working with large 32 node clusters, work with 2 node small clusters\nset time to live as short eg 15 mins\nwhich together would reduce your cost\n\nObviously there is a trade-off in assembling representative samples and making sure your outputs are still accurate and useful but that's up to you.","Q_Score":2,"Tags":"python,amazon-web-services,azure,databricks,cost-management","A_Id":60417809,"CreationDate":"2020-02-26T14:08:00.000","Title":"How can I reduce the financial cost of working in databricks?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recently deleted python 3.8.1 and decided to keep using python 3.7.4\nHowever, I am speculating that the python launcher keeps crashing because it is using the deleted python version. When I try to open the file with python 3.7.4 by right clicking then going to the python idle and running the file using it, it doesn't crash. But, when I double click the file to run it, the python launcher crashes.\nHow can I fix that problem ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2484,"Q_Id":60416112,"Users Score":1,"Answer":"After installing python and the py.exe launcher with the installer from python.org, double clicking a .py file should run the file with py.exe, which will run the file with python.exe in a new console window.  If there is more than one python.exe (say 3.7.u and 3.8.v), py.exe selects the last one with 'make this default' checked during installation.  Or it selects the most recent version.  One can determine the current default by running 'py' at a Command Prompt command line and checking the first line of the interactive message.\nWhen python finishes executing the file, it exits and the new window closes.  For a typical beginner file, this takes less than a second, especially if there is an error and traceback on startup.  In any case, one likely will never see any output.  I suspect that this is what you are calling a 'crash'.  If so, everything is working as designed.\nTo prevent the window from closing, prevent python from existing by adding a blocking function call such as input('Hit return to exit: ') at or near the end.  For a tkinter program, root.mainloop() blocks until the tkinter window is closed.  \nTo see what the program outputs without editing it, run it in Command Prompt.  py path-to-something.py.","Q_Score":0,"Tags":"python,python-3.x,windows,launcher","A_Id":60423949,"CreationDate":"2020-02-26T14:27:00.000","Title":"Python launcher keeps crashing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have messed up with my whole programming environment and I would like to delete \/Users\/Solal\/Library\/Caches\/pip\/ so I am sure not reinstall bad versions of package. \nIs it safe to do so?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5397,"Q_Id":60420564,"Users Score":0,"Answer":"It is safe to delete it.   \nBut it's better to close all applications to prevent any confusion of the programs accessing the cache.\nso if you want to free up disk space, you can do it.","Q_Score":0,"Tags":"python,pip","A_Id":60420655,"CreationDate":"2020-02-26T18:45:00.000","Title":"Is it safe to delete folder Cache\/pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have messed up with my whole programming environment and I would like to delete \/Users\/Solal\/Library\/Caches\/pip\/ so I am sure not reinstall bad versions of package. \nIs it safe to do so?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":5397,"Q_Id":60420564,"Users Score":1,"Answer":"It is safe to delete the user cache directory. It will simply cause pip to re-download all packages from PyPI. Do try pip install --no-cache-dir ... before you delete it to isolate your problem.","Q_Score":0,"Tags":"python,pip","A_Id":60420720,"CreationDate":"2020-02-26T18:45:00.000","Title":"Is it safe to delete folder Cache\/pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a SQL query which contains date formatting on one of the columns as shown below:\n%Y-%m-%d %h:%m:%s \nHere %d and %s are creating problem since they are used for formatting in Python just like C.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":17,"Q_Id":60420752,"Users Score":1,"Answer":"If this is a format string (used on the LHS of a %), then use %% to have a format that \"expands\" to a single %.  In your case that would be %%Y-%%m-%%d %%h:%%m:%%s","Q_Score":0,"Tags":"python-3.x","A_Id":60421115,"CreationDate":"2020-02-26T19:00:00.000","Title":"How do I use %s and %d as a string literal rather than formatter in Python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have more than 2000 unittests\/pytests in my project. Many of them ask API, but API can be lagged. Is there a way to expect APILagError in every single test and throw SKIP\/XFAIL for any test if this error occurs?\nCurrent:\n\ntest_1: ok\ntest_2: fail\ntest_3: ok\n\nresult: 1 fail, 2 ok => tests failed\nWanted:\n\ntest_1: ok\ntest_2: skip\/xfail\ntest_3: ok\n\nresult: 2 ok, 1 skipped\/xfailed => tests passed","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":158,"Q_Id":60421489,"Users Score":3,"Answer":"I feel your pain. I'm going to do that annoying SO thing where I don't actually answer your question as you posed it, but suggest you change directions. You should choose one of:\n\nmock that API so it doesn't time out any more and your tests aren't flakey\ntreat your API lag as normal behavior and increase the allowed duration of API calls so typical lag time doesn't result in a failed test\ntreat your API lag as a bug and go fix it so your tests pass \n\nWhy are flakey tests bad?\nFlakey tests mean you can't tell the difference between broken code and a slow API call. So your tests aren't helping you catch bugs. So what's the point?\nWhy would I ever mock the API? It's not \"real\"!\nYou'd do this if you want to test anything outside of the API. Decouple your logic from the API's behavior to eliminate flakiness and make your code more maintainable.\nYou might also be able to get a similarly-behaved but much faster API to test against as your mock. Like check out the API's code locally and populate it with a small set of data. Hit that in your tests instead of the production API. That would let you check its logic separate from its lagginess.","Q_Score":0,"Tags":"python,pytest,python-unittest","A_Id":60422050,"CreationDate":"2020-02-26T19:48:00.000","Title":"Allow failure for all tests if specific Error is thrown","Data Science and Machine Learning":0,"Database and SQL":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 problem using Airtable module for python\nWhile I'm using my IDE in my local computer the documentation works fine but when I use the same code on any site like repl.it or host it on pythonanywhere it gives me errors\nsome  attributes I found it's replacement such as insert will be create, get_all will be get...etc, but I couldn't find a replacement for the argument 'sort' which is used in get_all attribute, and that makes my code unable to work as I want it to work","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":60424837,"Users Score":0,"Answer":"Make sure you're using the same version of Airtable in all of the places where you're trying to run it.","Q_Score":0,"Tags":"python,wrapper,airtable","A_Id":60433136,"CreationDate":"2020-02-27T00:57:00.000","Title":"Airtable Python Wrapper documentation problem while using it online","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How could I or would it be appropriate to integrate Python code with HTML\/CSS\/JS as the user interface in creating desktop applications. A simple example; if I wanted to created a function with Python that prints \"Hello World!\" and use HTML\/CSS\/JS to create a user interface (make it fancy, perhaps add some images), so I can use it as a desktop application. How would I go about this?\nI understand I could use libraries such as Tkinter, but it doesn't allow the flexibility of customising user interface. \nI've read about using Electron, but I haven't seen many people using Python as the back-end. Any help or information in relation to using Python as a back-end with HTML\/CSS\/JS as the user interface will be greatly appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1975,"Q_Id":60426276,"Users Score":0,"Answer":"Yes you can. You need to choose framework of python. like Django etc. Then you can make own desktop application as you can.","Q_Score":1,"Tags":"javascript,python,html,css,user-interface","A_Id":60426303,"CreationDate":"2020-02-27T04:31:00.000","Title":"Integrating Python back-end with HTML\/CSS\/JS User Interface for desktop applications?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How could I or would it be appropriate to integrate Python code with HTML\/CSS\/JS as the user interface in creating desktop applications. A simple example; if I wanted to created a function with Python that prints \"Hello World!\" and use HTML\/CSS\/JS to create a user interface (make it fancy, perhaps add some images), so I can use it as a desktop application. How would I go about this?\nI understand I could use libraries such as Tkinter, but it doesn't allow the flexibility of customising user interface. \nI've read about using Electron, but I haven't seen many people using Python as the back-end. Any help or information in relation to using Python as a back-end with HTML\/CSS\/JS as the user interface will be greatly appreciated.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1975,"Q_Id":60426276,"Users Score":2,"Answer":"You're best option is to look at Flask (Almost no learning curve) as a backend and you can continue using HTML\/CSS\/JS as frontend. \nHowever to create a desktop application you will need to integrate (Your frontend) with tools like electron.","Q_Score":1,"Tags":"javascript,python,html,css,user-interface","A_Id":60426336,"CreationDate":"2020-02-27T04:31:00.000","Title":"Integrating Python back-end with HTML\/CSS\/JS User Interface for desktop applications?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a large amount of simulation files. \nThese are to be executed and run in a specific software. I know I can use python to instruct my software to run one specific file.\nI would like to know if I can use python force my computer to dedicate one core per simulation.\nFor instance, let's say that I have 10 simulations to run and 3 cores. I want something like that\n\nRun Simulation1 on core 1 only\nRun Simulation2 on core 2 only\nRun Simulation3 on core 3 only\n\n-- wait one of the simulation to be finished --\n...\n-- Simulation 2 finished --\n\nRun Simulation4 on core 2 only\n\netc.\nIn essence, I sort of want python to instruct my OS to associate a specific core to a task.\nDo you know if something is possible?\nThanks a lot\nE","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":60426982,"Users Score":0,"Answer":"From the python3.8 docs:\n\nos.sched_setaffinity(pid, mask)\n  Restrict the process with PID pid (or the current process if zero) to a set of CPUs. mask is an iterable of integers representing the set of CPUs to which the process should be restricted.\n\nIn the end though the OS's scheduler will make an executive decision on where each process goes.","Q_Score":0,"Tags":"python,multicore","A_Id":60427234,"CreationDate":"2020-02-27T05:48:00.000","Title":"Launching an application on a dedicated core","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My Company is using JIRA.\nAnd My task is need to use API get data in Service Desk.\nCurrent we are exporting csv file from JIRA. and we want to improve use api get data instead of export file csv.\nSome Field im csv file is \" Summary, Issue key, Issue id, Issue Type, Status, Priority, Resolution, Assignee, Reporter, Creator, Created, Updated, Last Viewed, Resolved, Comment ..... \"\nI have learned about jira's api ,\nEx : \/rest\/servicedeskapi\/request.\nIt only retrieves requests made by the user or assigned to the user (Ex user is me).\nI need to get all the requests in that project.\nI need to your help with api ( python ) get data in Service Desk Jira.\nThanks All.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":207,"Q_Id":60427303,"Users Score":0,"Answer":"The API should return all the requests the user making the request has access to. Are you able to view all the requests when you log in through the JIRA UI? If the permissions are set up to restrict your account from viewing all the requests, you won't be able to access those tickets via the API. Make sure your account is a Project Administrator for the Service Desk project you're working in, and if it's not have your account added to that role.","Q_Score":0,"Tags":"python,api,jira","A_Id":60571330,"CreationDate":"2020-02-27T06:19:00.000","Title":"Use API get data in Service Desk JIRA","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I come from .NET world.\nIn python code I have database connection string. Is there any way to keep these connection strings encrypted within python code?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":877,"Q_Id":60431929,"Users Score":1,"Answer":"Securing the DB configuration or any sensitive configurations can be done by keeping configs encrypted. In python you can do it using packages like secureconfig or encrypted-config or DIY with some standard encryption techniques. \nKeeping the encryption keys outside is the next challenge, which you can tackle by making it a injected config via environmental variables or a command-line-parameter.","Q_Score":2,"Tags":"python,python-3.x,python-cryptography","A_Id":60447102,"CreationDate":"2020-02-27T11:10:00.000","Title":"Encrypting db connection string","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a function that takes in a couple of large multi-dimension float arrays as input. As a result, I crash the stack.\nI'm a beginner to C\/C++ so I will apologize in advance if this question is dumb. Anyways, after looking around the net, this problem is not particularly new and the general solution is either make it as a global variable or use vector (instead of array).\nHowever, this piece of C++ code was intended to be used as a shared library and takes input from a Python script and returns (or modifies) the value (also in arrays). Therefore I don't think it would be possible to declare as global (correct me if I am wrong).\nSo, apart from using vector, is there any other way to do so? The reason that put me off from using C++ vector is there is no equivalent data type in Python. I'm using ctypes for communication between Python and C++ if that matters.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":455,"Q_Id":60432331,"Users Score":1,"Answer":"There is no way in C\/C++ to pass an array as a function argument by value. You can pass a pointer to the array and the size of the array. In C++, you also can pass a reference to the array and the size of the array (in template parameters). In either case, the array is not copied and the called function accesses the array in-place, where the caller allocated it.\nNote that the array can be wrapped in a structure, in which case it can be passed by value. In C++, std::array is an example of such. But the caller has to initialize that structure instead of the raw array. std::vector is similar in that it is a structure and it automatically copies elements when the vector is copied, but unlike C arrays and std::array it dynamically allocates memory for the elements.\nHowever, if you're integrating with C API, you are most likely limited to a pointer+size or pointer+size wrapped in a C structure solutions. The rules of working with the array (e.g. who allocates and frees the array, are writes to the array allowed, etc.) are specific to the particular API you're working with. Often, there is a dedicated set of functions for working with arrays provided by the library. You should read the API documentation about conventions taken in Python.","Q_Score":2,"Tags":"python,c++,shared-libraries,ctypes","A_Id":60432874,"CreationDate":"2020-02-27T11:33:00.000","Title":"C++ - How to take a large array as input for a function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've installed pygame on vscode but vscode can't import pygame showing this error ModuleNotFoundError: No module named 'pygame'\nAny help?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1134,"Q_Id":60432460,"Users Score":1,"Answer":"If you are working with virtual environments make sure you are on the environment where pygame is installed when you run your code.","Q_Score":0,"Tags":"python,visual-studio-code,pygame,vscode-python","A_Id":60432561,"CreationDate":"2020-02-27T11:41:00.000","Title":"How can I import pygame in vscode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've installed pygame on vscode but vscode can't import pygame showing this error ModuleNotFoundError: No module named 'pygame'\nAny help?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1134,"Q_Id":60432460,"Users Score":0,"Answer":"1) open terminal in visual code\n2) run command \n\n\npip install pygame\n\n\n3)import pygame in your code","Q_Score":0,"Tags":"python,visual-studio-code,pygame,vscode-python","A_Id":60432644,"CreationDate":"2020-02-27T11:41:00.000","Title":"How can I import pygame in vscode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a DLL (Windows, MS VS 17) in C++ which requires to call a Python script at some point - it should read a json-encoded string, process it and give back the json-encoded result. There is no need for asynchronous mode or \"speed of light\", but I need more or less fast response - i. e. within 1-5 seconds max. Here are the approaches I considered and the comments:\n\nPass the string as a command line argument. This is, obviously, not the best choice - let alone string length limit.\nUse a temporary file. It will be the best to avoid such practice in my case, because although I need to run the Python-part generally once per launch, the number of launches may be quite big.\nUse a TCP\/IP socket (for localhost) \/ pipe. Both seem to be an overkill for such a task - I do not have a continuous flow of data which changes constantly. Besides, in Windows it might be a pain.\nUse shared memory. Shared memory would be a nice option but I couldn't find a way to use the same segment both in C++ and Python.\nEmbed Python part into C++. I have 2 concerns here: a) Python env should be installed on the target machine, shouldn't it? b) A python script has an import, which imports a package, installed from pip and, unfortunately, I cannot avoid it. Is there a proper way to work with imports when embedding?\n\nIs there a simple way to interoperate between C++ and Python in my case?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":102,"Q_Id":60432637,"Users Score":2,"Answer":"Since you're targeting Windows, option (2) is the best, but use a temporary file  CreateFile(...FILE_ATTRIBUTE_TEMPORARY). That's effectively shared memory (at the OS level, both are managed by the Virtual Memory Manager) but you get file semantics.","Q_Score":0,"Tags":"c++,python-3.x,windows,ipc","A_Id":60433212,"CreationDate":"2020-02-27T11:52:00.000","Title":"The most basic IPC between Python and C++","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So as the title suggests, my question is whether feature selection algorithms are independent of the regression\/classification model chosen. Maybe some feature selection algorithms are independent and some are not? If so can you name a few of each kind? Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":60434250,"Users Score":2,"Answer":"It depends on the algorithm you use to select features.  Filter methods that are done prior to modeling are of course agnostic, as they're using statistical methods like chi-squared or correlation coefficient to get rid of unnecessary features.\nIf you use embedded methods where features are selected during model creation, it is possible that different models will find value in different feature sets.  Lasso, Elastic Net, Ridge Regression are a few examples of these. \nIt's worth noting that some model types perform well with sparse data or missing values while others do not.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,regression","A_Id":60434515,"CreationDate":"2020-02-27T13:23:00.000","Title":"Is feature selection agnostic to regression\/classification model chosen?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using inclusion tag in sidebar of html page. If I hide the sidebar using css for mobile view. Will Django process the inclusion tag in backend when visited from mobile","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":60434559,"Users Score":0,"Answer":"Yes it will process and include it. But if your css hides it it wont be displayed. \nYou can use developer tools (Inspect) in your browser to see the included code.","Q_Score":0,"Tags":"python,css,django","A_Id":60434620,"CreationDate":"2020-02-27T13:39:00.000","Title":"Will Django process inclusion tag if I hide it in html template using css","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The title pretty much sums it up already.\nI have a piece of code that calls os.getenv to get both a URL as well as a token in order to connect to a service. The code lives in a module and will only be imported from there, i.e. it's not a script. \nIt's not a huge issue at all, since I really only need to crash and display the message saying that there are unset values, but it got me thinking about which of Python's built-in exceptions would be the best fit.\nI found the EnvironmentError, but that seems to function as base class from which IOError and other OS related exceptions inherit.\nWould it be as simple as a ValueError, as it's really just a value that's missing?\nThanks!","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8365,"Q_Id":60435406,"Users Score":4,"Answer":"Well most built in concrete exception classes are for specific use cases, and this one does not really fit in any but RuntimeError. But I would advise you to use a custom Exception subclass.","Q_Score":16,"Tags":"python,python-3.x,exception","A_Id":60435527,"CreationDate":"2020-02-27T14:25:00.000","Title":"Which exception should be raised when a required environment variable is missing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to train a Masked RCNN neural network to be able to segment different parts of the seedlings. We have images of the seedlings with black and white background, would it be best to train the CNN with only one background or both of them combined, to get good segmentation results?\nWe will only acquire images with black background in the final pipeline.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":60435868,"Users Score":1,"Answer":"It\u2019s best to have your training data match your production inputs.  If you are always going to have your seedlings on a black background during inferencing, you don\u2019t need to have them on a white background during training.","Q_Score":0,"Tags":"python,machine-learning,image-processing,deep-learning,faster-rcnn","A_Id":60451748,"CreationDate":"2020-02-27T14:50:00.000","Title":"Training instance segmentation of seedlings. Better results with different backgrounds?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 different kind of list in python:\n\n1. test1 = ['abc', 'cde', 'fgh']\n\n2. test2 = [{'name': 'me', 'address': 'usa'}]\nBoth appear to be a list when i check the type:\nif test1 is list: --> true\n\nif test2 is list: --> true\nis there any way i can check if it is a list of string or list of dictionary?","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":60435920,"Users Score":0,"Answer":"I would check the first element of each list to determine what kind of list it is. For example:\nlist1_type = typeof(list1[0])\nlist2_type = typeof(list2[0])\nOf course, a list doesn't have to have all the same type, so without checking every element, you can't know for sure.","Q_Score":0,"Tags":"python,types","A_Id":60436200,"CreationDate":"2020-02-27T14:52:00.000","Title":"Python differentiate data type","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For example I have a bunch of objects, say Cars. I need to keep track of a fleet of cars in the company. Obviously, cars are unique (VIN number), so they can be formed into a Set. \nBut I need everyday to change the state of some cars in the fleet, say to fill them with gas. \nWhich construct now makes sense? Why?\n\nA dictionary with the VIN number as key and Car instance as value.\nA Set of cars and then match on the Car.vin attribute.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":60436162,"Users Score":1,"Answer":"Remember that things that both sets and maps\/dicts work using hashes. Hashed elements need to be immutable and preferably small (faster hash calculation).\nIn your case, we don't know what is in the car instance and whether it changes. Maybe you can replace some parts or change the owner? If those are stored inside the instance, the car will have to be mutable.\nSo the obvious choice for the hash will be to go for a short VIN number that doesn't change. -> You should use a map (dict).\n+In Python classes are by default mutable, so it's just easier to use some kind of (alpha)numerical id or a pair (tuple) of such elements.","Q_Score":1,"Tags":"python,dictionary,oop,set","A_Id":60436320,"CreationDate":"2020-02-27T15:04:00.000","Title":"When is it more logical to use Set as compared to Map?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For example I have a bunch of objects, say Cars. I need to keep track of a fleet of cars in the company. Obviously, cars are unique (VIN number), so they can be formed into a Set. \nBut I need everyday to change the state of some cars in the fleet, say to fill them with gas. \nWhich construct now makes sense? Why?\n\nA dictionary with the VIN number as key and Car instance as value.\nA Set of cars and then match on the Car.vin attribute.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":30,"Q_Id":60436162,"Users Score":1,"Answer":"from what I can see keeping the data in a dictionary is a more suitable approach\nif you have to change the state of your Car objects this means you have to search for that car (by the VIN number) and a dict can do this job in O(1) time complexity, I do not see how you can search by the VIN number for a Car object in a set (you can't)","Q_Score":1,"Tags":"python,dictionary,oop,set","A_Id":60436341,"CreationDate":"2020-02-27T15:04:00.000","Title":"When is it more logical to use Set as compared to Map?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to unit testing and wanted to perform some tests on the below listed functions. Thanks for the help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1034,"Q_Id":60436442,"Users Score":0,"Answer":"Indent the class body.\nYou need to mark your tests as tests. If you are using  unittest, your class should subclass  unittest.TestCase\nIt's not officially a unit test if you access databases, but in practice it is fine.\nThe test doesn't test much. It just inserts objects. That actually has value, but it would be better if you tested a meaningful sequence of behavior. Maybe retrieve the objects and compare input to output.\nYou call to_db twice. Are you sure the first param ( batch ) as passed into_dynamo_db_in_batchesis really aboto` object?","Q_Score":0,"Tags":"python,python-3.x,unit-testing,mocking,amazon-dynamodb","A_Id":60436904,"CreationDate":"2020-02-27T15:18:00.000","Title":"Performing unit test for dynamo db 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a flask based app, when I run coverage on the pytests in windows using python 3.8 it runs very slowly. It performs much better in python 3.7. The following are the test completion times using a the same laptop, the Ubuntu times are the same machine running as a VM.\n\npython 3.8.2 - Windows 10 - coverage - **199** seconds\npython 3.8.2 - Windows 10 - pytest - 15 seconds\npython 3.8.2 - Ubuntu - coverage -  26 seconds\npython 3.8.2 - Ubuntu - pytest - 15 seconds\npython 3.7.5 - Windows 10 - coverage - **30** seconds\npython 3.7.5 - Windows 10 - pytest - 15 seconds\npython 3.7.5 - Ubuntu - coverage -  26 seconds\npython 3.7.5 - Ubuntu - pytest - 15 seconds\n\nDoes anyone have any idea why 3.8 on windows running coverage is so slow?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":308,"Q_Id":60437839,"Users Score":3,"Answer":"The cause is that with python 3.8 coverage is installing without C extensions, but with 3.7 it is installing with c extensions. \nNow I need to find out why this is the case.","Q_Score":2,"Tags":"python,windows,ubuntu","A_Id":60451563,"CreationDate":"2020-02-27T16:35:00.000","Title":"coverage runs very slowly on windows with python 3.8, but not 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Today in class my teacher told me that I shouldn't use global variables in python, as the function should be able to exist on its own. I thought I might be able to do this with parameters and returning a value? Any help would be great, thanks.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":384,"Q_Id":60439743,"Users Score":2,"Answer":"Not only in Python, But We should also avoid using global variables in any language. These are some of the reasons why global variables are considered bad \u2212\n(1) Global variables can be altered by any part of the code, making it difficult to remember or reason about every possible use.\n(2) A global variable can have no access control. It can not be limited to some parts of the program.\n(3) Using global variables causes very tight coupling of code.\n(4) Using global variables causes namespace pollution. This may lead to unnecessarily reassigning a global value.\n(5) Testing in programs using global variables can be a huge pain as it is difficult to decouple them during testing.","Q_Score":0,"Tags":"python","A_Id":60439889,"CreationDate":"2020-02-27T18:38:00.000","Title":"Why shouldn't I use global variables in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning how to execute adb commands using python And I noticed that to execute adb command\nwe can use cmd : Adb.cmd(\"shell\",\"ls\")\nit's clear that the result will be : adb shell ls \nBut I want to understand the use of \"cmd\". Can someone explain that to me . thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":108,"Q_Id":60440094,"Users Score":0,"Answer":"cmd is a method of the Adb Python class, which allows you to execute commands on the previously selected device.","Q_Score":0,"Tags":"python,android,adb","A_Id":60440228,"CreationDate":"2020-02-27T19:03:00.000","Title":"Using python to execute adb commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to count the number of numbers in s string.\nIn this string:\n\n\"2019 was a great year for 10 fortunate people in ages 20 to 60.\"\n\nThe result should be 4 (2019, 10, 20, 60)\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":60440270,"Users Score":0,"Answer":"I would split the string into tokens using s.split(' ') and iterate over each and use a regex like \\d+ to test that each character is a digit, and accumulate good test responses in an int.","Q_Score":0,"Tags":"python,string,tokenize","A_Id":60440336,"CreationDate":"2020-02-27T19:15:00.000","Title":"How can I count the number of numbers in a string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pandas dataframe and using:\nfiltered = dataframe[dataframe[\"x\"] == \"y\"] returns results.   \nHowever, this does not:\nfiltered = dataframe.query('x == \"y\"', inplace=True) does not.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":119,"Q_Id":60440413,"Users Score":0,"Answer":"As ifly6 and Yuca pointed out, removing inplace=True resolved this.","Q_Score":2,"Tags":"python,pandas","A_Id":60440495,"CreationDate":"2020-02-27T19:25:00.000","Title":"Pandas: df.query() method returns 0 results","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to integrate pivotal tracker manually because I want some extra options, but I'm getting a \"failed to open TCP connection\" error.\nI'm working from localhost and gitlab is in an intranet. I've tried both the example in ruby in the docs and a similar script in python, but both give me the same error.\nWould appreciate any help to resolve it. Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1199,"Q_Id":60441326,"Users Score":0,"Answer":"add the IP address to the HOSTS file.","Q_Score":0,"Tags":"gitlab,webhooks,gitlab-api,git-webhooks,python-gitlab","A_Id":67804914,"CreationDate":"2020-02-27T20:32:00.000","Title":"Hook execution failed: Failed to open TCP connection to ::1:8000 (Connection refused - connect(2) for \"::1\" port 8000)","Data Science and Machine Learning":0,"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 switched to my new laptop and tried to install VirtualEnv on the latest version of Python. Even though it is successfully installed, when I create a new virtual environment and try to activate it, it switches to a new line as nothing has happened. I checked the folder, I'm entering the right path, it's not in \"bin\" folder. I'm not sure what's causing the problem. I have to note that I'm on Windows and I'm not using PowerShell. any ideas? \nP.S. Please note that I know that it must show the VirtualEnv's name in parenthesis but unfortunately, it doesn't.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1471,"Q_Id":60442828,"Users Score":5,"Answer":"I had this issue earlier today. What solved it for me was running the \\scripts\\activate.ps1 command in Powershell as Admin","Q_Score":2,"Tags":"python,django,virtualenv","A_Id":60442960,"CreationDate":"2020-02-27T22:45:00.000","Title":"Virtual Environment's Activate Does Nothing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I switched to my new laptop and tried to install VirtualEnv on the latest version of Python. Even though it is successfully installed, when I create a new virtual environment and try to activate it, it switches to a new line as nothing has happened. I checked the folder, I'm entering the right path, it's not in \"bin\" folder. I'm not sure what's causing the problem. I have to note that I'm on Windows and I'm not using PowerShell. any ideas? \nP.S. Please note that I know that it must show the VirtualEnv's name in parenthesis but unfortunately, it doesn't.","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":1471,"Q_Id":60442828,"Users Score":4,"Answer":"1)Run Powershell as Administrator\n2) Run the following command in powershell: Set-ExecutionPolicy Unrestricted\n3) Rerun the activation command: > venv\\Scripts\\activate.ps1","Q_Score":2,"Tags":"python,django,virtualenv","A_Id":60443626,"CreationDate":"2020-02-27T22:45:00.000","Title":"Virtual Environment's Activate Does Nothing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to draw two graphs are almost same, the only difference is that the second one will have some edges grayed out. And I want nodes in the second graph stay exactly where they are in the first graph.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":131,"Q_Id":60443607,"Users Score":1,"Answer":"You need to define the optional pos argument.\nIn your case using circular layout pos = nx.circular_layout(G).  Then you call the plotting commands like nx.draw(G, pos, other_arguments...).","Q_Score":0,"Tags":"python,networkx","A_Id":60443882,"CreationDate":"2020-02-28T00:18:00.000","Title":"How to fix position of nodes when using draw_circular in networkx?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Machine learning module which uses Google Colab's free GPU for NLP tasks, and I want to make a web app out of it. I've been thinking of using React js for frontend and spring boot for the back end and was wondering whether there is a way to connect the code at Google Colab with the backend.\nWant to know other alternative suggestions to building a web app incorporating the ML module in Colab as well. Any sort of help is appriciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2835,"Q_Id":60443948,"Users Score":1,"Answer":"It's possible. But there's no good examples of it.\nThere's an example of serving local resources, using http-server. Flask examples used to work too. But not much else.","Q_Score":2,"Tags":"python,api,machine-learning,nlp,google-colaboratory","A_Id":60452454,"CreationDate":"2020-02-28T01:10:00.000","Title":"Is there a way to turn Google Colab code into web services or rest APIs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using fetch_20newsgroups_vectorized data:\nimport numpy as np\nfrom scipy.sparse import csr_matrix\nfrom sklearn.datasets import fetch_20newsgroups\nfrom sklearn.datasets import fetch_20newsgroups_vectorized\nnewsgroups = fetch_20newsgroups(subset='all')\nlabels = newsgroups.target_names\nnews_data, news_labels = fetch_20newsgroups_vectorized(subset='all', normalize=False, return_X_y=True)\nnews_labels = [labels[i] for i in news_labels] ### converting integer list to str list\nwhen I try to subset matrix news_data based on groups of news_label (exstract all rows that have label i into a new matrix), it returns the same subset for each label level (there are 20 different levels and news_data is csr_matrix):\nfor i in set(news_labels):\n    print(i)\n    subset = news_data[news_labels == i]\nHow can I subset news_data for every level of news_label?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":279,"Q_Id":60445662,"Users Score":1,"Answer":"I tried: \nfor i in set(news_labels):\n     indices = [element for element, x in enumerate(news_labels) if x == i]\n     subset = news_data[indices]\nand it worked!","Q_Score":1,"Tags":"python,list,subset,sparse-matrix","A_Id":60446694,"CreationDate":"2020-02-28T05:19:00.000","Title":"How to subset sparse matrix by value of a label list?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on odoo11. I want to redirect to Invoicing menu from Odoo website on button click. How can I achieve it through code?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":246,"Q_Id":60446222,"Users Score":0,"Answer":"You can use controller to redirect website page to backend but make sure on your controller you use auth=user for security reason so public user can not go to backend.","Q_Score":0,"Tags":"python-3.x,odoo,odoo-11","A_Id":60969021,"CreationDate":"2020-02-28T06:15:00.000","Title":"How to redirect to invoice menu from Odoo website?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm currently doing an exercise on algorithms, this egg question confused me:\n\"You have an N-floor building and plenty of eggs. Suppose that an egg is broken if it is thrown from floor F or higher, and unhurt otherwise.\"\nA simple solution is by using binary search, which would lead to the throws of at most logN\nHowever, \"Find a new strategy to reduce the number of throws to at most 2 log F.\"\nI saw some previous posts saying we start from 1, 2,...2^i, until we find the egg broken, and we do binary search in the smaller range of (2^i-1,2^i). I'm confused, that where do we get that TWO, and the LogN? \nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":60447113,"Users Score":2,"Answer":"Complexity for the new strategy is log F + log F which results in 2*log F. First log F is for determining the range in which F lies which is a variation of binary search. Second log F finding the exact F using binary search in that particular range.","Q_Score":1,"Tags":"python,algorithm","A_Id":60447216,"CreationDate":"2020-02-28T07:29:00.000","Title":"Egg-Dropping Problem, with K floors and plenty of eggs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As part of a larger project, I'm currently writing a python script that runs Linux commands in a vApp.\nI'm currently facing an issue where after working with a mounted iso, it may or may not unmount as expected.\nTo check the mount status, I want to run the df -hk \/directory and du -sch \/directory commands respectively, and compare the outputs.\nIf the iso is not unmounted, the result for the df command should return a larger value than the du command as the df command includes the mount size in the result, while du does not.\nI'm just wondering how can i compare these values or if there is a better way for me to run this check in the first place.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":154,"Q_Id":60450774,"Users Score":1,"Answer":"why don't you use \/proc\/mounts ?\nFirst column is you blockdevice, second is the mountpoint.\nIf you mountpoint is not in \/proc\/mounts you have nothing mounted here.","Q_Score":0,"Tags":"python,linux,command-line-interface,mount,linux-disk-free","A_Id":60450845,"CreationDate":"2020-02-28T11:26:00.000","Title":"Python Script to compare du and df console outputs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using matplotlib.pyplot module imported as plt for plots. \nIn the plt.plot() statement, if I pass the arguments as \"x= array1, \"y= array2\", I get \"TypeError: plot got an unexpected keyword argument 'x' \".  \nThe code gets executed correctly if I simple pass \"array1 and array2\", without explicitly saying they correspond to x and y axes. \nWhy is that?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":7480,"Q_Id":60452488,"Users Score":3,"Answer":"It has to do with the concepts of *args and **kwargs in Python. Both of these let you to use a variable number of parameters within your function, but the difference comes in the fact that while *args takes only the values, **kwargs also takes the keywords as the name \"kw\" implies.\nSince matplotlib.pyplot.plot() function uses *args instead of **kwargs, these functions do not accept keywords within the parameters.","Q_Score":8,"Tags":"python,matplotlib","A_Id":66302239,"CreationDate":"2020-02-28T08:54:00.000","Title":"Why can't arguments be passed explicitly as x and y in pyplot?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to train a custom ner model using spacy. Currently, I have more than 2k records for training and each text consists of more than 100 words, at least more than 2 entities for each record. I running it for 50 iterations.\nIt is taking more than 2 hours to train completely. \nIs there any way to train using multiprocessing? Will it improve the training time?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1329,"Q_Id":60453073,"Users Score":0,"Answer":"Hi I did same project where I created custom NER Model using spacy3 and extracted 26 entities on large data. See it really depends like how are you passing your data. Follow the steps I am mentioning below might it could work on CPU:\n\nAnnotate your text files and save into JSON\n\nConvert your JSON files into .spacy format because this is the format spacy accepts.\n\nNow, here is the point to be noted that how are you passing and serializing your .spacy format in spacy doc object.\n\n\nPassing all your JSON text will take more time in training. So you can split your data and pass iterating it. Don't pass consolidated data. Split it.","Q_Score":2,"Tags":"python,nlp,python-multiprocessing,spacy,named-entity-recognition","A_Id":72028293,"CreationDate":"2020-02-28T13:47:00.000","Title":"Spacy train ner using multiprocessing","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In order to ease adoption of the CDK toolkit in my company's cloud department, I'd like to write some diagnostics tools to test the architecture described in a CDK app before deploying it. Specifically whether the Security Group rules and IAM policies allow for communication between instances on the correct ports. \nHowever I can't seem to access security group rules created between instances in the stack. Is there any way to do so that doesn't involve wrapping the SecurityGroup construct or Connections class to store all rules as you add them(because that means no backwards compatibility among other concerns)? Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":60454196,"Users Score":0,"Answer":"CDK just does not seem to expose very many attributes. I can't piece together the topology in any practical way for now.","Q_Score":0,"Tags":"python,aws-cdk,infrastructure-as-code","A_Id":60486009,"CreationDate":"2020-02-28T14:56:00.000","Title":"Retrieving attributes from a CDK stack or app construct tree for offline 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 writing a custom module, and I need to use inventory_hostname from playbook as variable for my module. I looked into module.params for host but I get null \nI am using connection: network_cli as I am working with network device.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":139,"Q_Id":60455154,"Users Score":0,"Answer":"For reference: hostname is stored in AnsibleModule and can be retrieved with  module.params.get('hostname')","Q_Score":0,"Tags":"python,ansible","A_Id":60455421,"CreationDate":"2020-02-28T15:51:00.000","Title":"ansible inventory_hostname in module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning how to use VS code and in the process, I learnt about linting and formatting with \"pylint\" and \"black\" respectively.\nImportantly, I have Anaconda installed as I often use conda environments for my different projects. I have therefore installed \"pylint\" and \"black\" into my conda environment.\nMy questions are as follows:\n\nIf \"pylint\" and \"black\" are Python packages, why do they not need to be imported into your script when you use them? (i.e. \"import pylint\" and \"import black\" at the top of a Python script you want to run). I am very new to VS code, linting and formatting so maybe I'm missing something obvious but how does VS code know what to do when I select \"Run Linting\" or \"Format document\" in the command palette? Or is this nothing to do with VS code ?\n\nI guess I am just suprised at the fact we don't need to import these packages to use them. In contrast you would always be using import for other packages (sys, os, or any other).\n\nI'm assuming if I used a different conda environment, I then need to install pylint and black again in it right?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":618,"Q_Id":60455962,"Users Score":0,"Answer":"Yes, black and pylint are only available in the conda environment you installed them in. You can find them in the \"Scripts\"-folder of your environment.\nVS Code knows where to look for those scripts, I guess you can set which package is used for \"Run Linting\" or \"Format document\".\nYou only need to import python modules or functions that you want to use inside your python module. But that's not what you do.","Q_Score":0,"Tags":"python,import,vscode-settings,pylint","A_Id":63281440,"CreationDate":"2020-02-28T16:42:00.000","Title":"Why no need to load Python formatter (black) and linter (pylint) and vs code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In image processing, in which cases do we use spatial filtering and in which cases do we use frequency domain filtering?\nWhat filters do we use in frequency filtering? Can we perform blurring and edge detection using both spatial filtering and frequency filtering?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":194,"Q_Id":60457129,"Users Score":4,"Answer":"For any linear filter (convolution) you can obtain the same result using spatial domain and frequency domain computations. The convolution with a large kernel is usually more efficient to implement by multiplication in the frequency domain. The convolution with a small kernel is likely more efficient to implement directly in the spatial domain, unless one already has the frequency-domain representation (FFT) of the image available.\nFor any non-linear filter (everything else) you cannot use the frequency domain at all. Fourier analysis is limited to linear systems.","Q_Score":1,"Tags":"python,image,opencv,image-processing,computer-vision","A_Id":60457193,"CreationDate":"2020-02-28T18:08:00.000","Title":"Do we use spatial filtering or frequency filtering for blurring, edge detection?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"when I do a pip install jupyter notebook, which it seems to install and then I run \"jupyter notebook\" it tells me that \"zsh: command not found: jupyter\"\nAlso does it matter using zsh on macOS?\nAny suggestions too fix this issue?\nThanks!\nJohnny","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":293,"Q_Id":60457784,"Users Score":0,"Answer":"I faced a similar problem. If you've installed it using --user try to add to your path variable in .zshrc a path like this \/Users\/<name_of_your_user>\/Library\/Python\/3.8\/bin. Replace <name_of_your_user> with name of the user and maybe you have another version of python and the folder 3.8 should be replaced with the corresponding version. It helped me. Please check if that works for you and mark the question as solved if it did.","Q_Score":1,"Tags":"python,macos,pip,jupyter","A_Id":63859520,"CreationDate":"2020-02-28T19:03:00.000","Title":"installing jupyter notebooks on macOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Hello!\n\nI am working on my first program with Python. It is a window made with tkinter which displays 7 listboxes. I am using a sqlite database to store some info like date, order number and status. So the first listbox displays orders from today's date. Then the next box displays orders from tomorrow and so on. I created an .exe with pyinstaller. Everything works fine except that if i leave the program open for more than one day, when the system date changes(i'm on windows 10) it does not also change in my program. My program \"thinks\" the date is the same as when i executed it last time.\nI get the date for each boxlike this:\nday2_date=(date.today()+timedelta(days=1)) #e.g date for second box\n\nIs there a way to refresh this or anyway to fix this?\nThank you very much!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":118,"Q_Id":60457942,"Users Score":0,"Answer":"It could be a matter of the flow of your program.\nIf day2_date=(date.today()+timedelta(days=1)) is only invoked when reading the database at startup, it is not going to change.\nThis might be internal to Tk event handling, if nothing invokes the method that refresh the variable, it is not going to refresh on its own.","Q_Score":0,"Tags":"python,date","A_Id":60458034,"CreationDate":"2020-02-28T19:15:00.000","Title":"Date not updating when system date changes Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am publishing same data (Topic, Key & Value) from python confluent_kafka library based Producer v\/s Java apache library based producer but when messages checked on Kafka then they are published to different \nKafka Partition.\nI was expecting by default both these library will use same hash method (murmur2) on Key and will determine same partition when publishing message to Kafka, but looks like that is is not happening.\nIs there flag or option that needs to be set on Python library so that it will use same algorithm and generate same (as Java library) Kafka partition OR is there any other python library that should be used to achieve this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":218,"Q_Id":60457993,"Users Score":0,"Answer":"I found a way to force confluent_kafka Producer to use murmur2 algorithm to determine partition. You can set below parameter with value:\n'partitioner': 'murmur2_random'","Q_Score":0,"Tags":"python,apache-kafka,confluent-platform","A_Id":60458635,"CreationDate":"2020-02-28T19:18:00.000","Title":"Kafka different partitions are selected python confluent_kafka library v\/s apache kafka Java","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on a django project that requires me to import code from another package. For exmaple, in my \"home\" app, I'm import from the \"users\" app. In my index.py view in the home app, I'm using from project.users import services. Running this from a python shell works fine, however, if I try to run python3 manage.py runserver, I get the error ModuleNotFoundError: No module named 'project.users'. I tried adding my project directory and its parent to my sys.path, however, nothing changes. I also tried using a different machine and a venv with no success. How would I be able to fix this?\nEdit: I also tried running from project.users import services from the django shell (python3 manage.py shell) and I get the same import error.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":722,"Q_Id":60460033,"Users Score":1,"Answer":"I solved the problem by changing my imports from from project.users import services to from users.import services.\nAlso, to fix the red underlines in pycharm, just mark your project root (\"project\" folder in my example) as sources root (Right click > Mark directory as.. > Sources root). \n(@BearBrown's answer, credit to him)","Q_Score":2,"Tags":"python,django,python-3.x,importerror","A_Id":60460427,"CreationDate":"2020-02-28T22:25:00.000","Title":"Can't import top level packages in django project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have 20 symbols for which I need to record tick data continuously for 6 hours a day every week.\nSo I want 20 excel files to be created automatically by the module (if files don't exist) and a excel writer which stores tick data (row by row). Then I need to resample the data to 5 minutes timeframe after reading them through dataframe. Dataframe should be able to read the tick data created by the module.\nWhat best excel writer can be used for this function. I want to write to the files when they are closed.\nwhich of them will work better?\n\nIn built open function\nOpenpyxl\nXlwt","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":60462134,"Users Score":0,"Answer":"hello i would recommed you xlwings. as it is the best module to stream the tick data to excel when file is opened.","Q_Score":0,"Tags":"python","A_Id":60650847,"CreationDate":"2020-02-29T05:02:00.000","Title":"How to create excel files and then read the files through dataframe?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created two DocTypes inside the education module. I've unchecked the \"custom\" checkbox to build the js and py files. However, the two DocTypes have not listed inside the education module. \nIf I check the custom they return to list under setup so how I can list him inside the education module while the custom is unchecked?\nanother question: I have created a custom script for one of these DocTypes, will I lose the script after unchecked custom !!!\nNote: I can find them in the global search","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":392,"Q_Id":60464004,"Users Score":-1,"Answer":"Try Bench Migrate First for Standard DocType","Q_Score":0,"Tags":"python,doctype,erpnext,frappe","A_Id":60703541,"CreationDate":"2020-02-29T10:14:00.000","Title":"DocType not visible under Module view","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've tried to import opencv to Pycharm, but this error pops up:\nCollecting cv2\nCould not find a version that satisfies the requirement cv2 (from versions: )\nNo matching distribution found for cv2\nCan you please help me?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":60465368,"Users Score":0,"Answer":"Install opencv with:\npip3 install opencv-python\nMake sure you are using the correct interpreter for your project in PyCharm. Go to File\\Settings...\\Project\\Project Interpreter and ensure opencv is listed under the Python interpreter you wish to use.","Q_Score":0,"Tags":"python,opencv,pycharm","A_Id":60465423,"CreationDate":"2020-02-29T12:56:00.000","Title":"can't import opencv in PyCharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm not sure when this began, but it was recently...\nI installed modules via pip on CMD, it all went smoothly until I went to IDE and attempted to import them, each time i get the same error \n'ModuleNotFoundError: No module named x'\nI have checked that I have Python in my PATH and have reinstalled with different version with no avail.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":60466390,"Users Score":0,"Answer":"Try to uninstall everything and even delete the folders where the modules are stored and then try to install it again; this happened to me a while ago and that's how I solved it","Q_Score":0,"Tags":"python,module,pip","A_Id":60466499,"CreationDate":"2020-02-29T14:56:00.000","Title":"Python can't find any modules, even though they are already installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"With dask dataframe using\ndf = dask.dataframe.from_pandas(df, npartitions=5)\nseries = df.apply(func) \nfuture = client.compute(series)\nprogress(future)\nIn a jupyter notebook I can see progress bar for how many apply() calls completed per partition (e.g  2\/5).\nIs there a way for dask to report progress inside each partition?\nSomething like tqdm progress_apply() for pandas.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":474,"Q_Id":60467807,"Users Score":0,"Answer":"If you mean, how complete each call of func() is, then no, there is no way for Dask to know that. Dask calls python functions which run in their own python thread (python threads cannot be interrupted by another thread), and Dask only knows whether the call is done or not.\nYou could perhaps conceive of calling a function which has some internal callbacks or other reporting system, but I don't think I've seen anything like that.","Q_Score":0,"Tags":"python,pandas,dask,tqdm,dask-dataframe","A_Id":60491327,"CreationDate":"2020-02-29T17:31:00.000","Title":"Dask progress during task","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install python 3 and jupyter on Catalina.\nI installed the latest version (3.7) from Anaconda distribution, but if I type\npython --version in the command line I get \"Python 2.7.16\"\nIf I type jupyter notebook, i get zsh: command not found: jupyter\nI have also installed python 3.8.2 from python.org, I thought this might help.\nWhat can I do now to get it running?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":130,"Q_Id":60468497,"Users Score":0,"Answer":"This is the solution for the jupyter problem:\n\ncd into your installation directory of anaconda in terminal\nGo into bin folder and drag the binary named conda into the terminal and type init zsh","Q_Score":1,"Tags":"python,jupyter-notebook","A_Id":60469234,"CreationDate":"2020-02-29T18:50:00.000","Title":"Can't install Python 3 \/ Jupyter on Catalina properly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to process images(most probably in big sizes) on Hadoop platform but I am confused about which one to choose from the aforementioned 2 interfaces, especially for someone who is still a beginner in Hadoop. Considering the need to split the images into blocks to distribute processing among working machines and merge the blocks after processing is completed.\nIt's known that Pydoop has better access to the Hadoop API while mrjob has powerful utilities for executing the jobs, which one is suitable to be used with this kind of work?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":121,"Q_Id":60469567,"Users Score":1,"Answer":"I would actually suggest pyspark because it natively supports binary files.\nFor image processing, you can try TensorFlowOnSpark","Q_Score":0,"Tags":"python,hadoop,image-processing","A_Id":60476719,"CreationDate":"2020-02-29T21:00:00.000","Title":"Pydoop vs Mrjob for image processing on Hadoop","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a workbook sheet that shows the first 3 rows with data when opened with LibreOffice Calc.  If I use conditional formatting to set cell background color to red if a cell is blank, all cells in rows 4 and following show red.  When I read the spreadsheet with Pandas, I get 20 rows with rows 4 through 20 all blank.  When I read the spreadsheet with openpyxl, I also get 20 rows and  here is the interesting part: rows 4 through 20 have values in column AC (29).  That column has a data validation drop-down.  While no data shows up in LibrOffice Calc or Pandas, data shows up in openpyxl.  This appears to be a ghost of data that has been deleted.\nI can delete blank rows in Pandas after I read the worksheet but the read_excel method throws up data validation errors for rows 4 through 20 before I can delete them. I would like to detect and remove the rows before read_excel.  Is there a way to detect this and remove the spurious rows using openpyxl?  I could then use openpyxl.load_workbook, delete the bad rows, and then use read_excel giving it the openpyxl workbook.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":285,"Q_Id":60470936,"Users Score":0,"Answer":"I found the problem.  The items for the data validation were in a hidden column (AD) on the same sheet.","Q_Score":0,"Tags":"python,pandas,validation,openpyxl,libreoffice-calc","A_Id":60471515,"CreationDate":"2020-03-01T00:29:00.000","Title":"Excel (LibreOffice Calc) show blank cells but openpyxl shows values","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install cartoPy on macOS using pip, but always run into errors, can anybody help me with this?\nI use pip install cartoPy (no syntax errors, it's just to get the test to display here.)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":60472086,"Users Score":0,"Answer":"I had to install Anaconda (didn't want to ) and now I have it. It seems like the only way to get the mapping lib, ...","Q_Score":1,"Tags":"python,cartopy","A_Id":60480877,"CreationDate":"2020-03-01T04:51:00.000","Title":"has anybody installed CartoPY on macOS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to solve a modified version of the TSP. In my version, multiple visits to a city are allowed, as long as the path is the shortest, and also, only subset of the cities are compulsory to visit, as in, you can go through other cities to visit all the subset cities if path is shorter, but if not, the other cities can be ignored. NetworkX has approx. solution for the traditional TSP using the dwave_networkx.algorithms.tsp.traveling_salesperson, but I have trouble solving this one. A naive approach can be to find all possible combinations of the subset cities and check which has the shortest total path length, but that solution will have a n^2 complexity for trying each combination, plus the complexity for finding shortest path for each two cities. So, what should I use to solve this problem using NetworkX.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":706,"Q_Id":60473238,"Users Score":0,"Answer":"You can select a path randomly and optimize the way on it. Basically, randomly assign a way between two nodes. Than on nodes, try to find optimal way for n+2 nodes. A --> B --> C if there is a path between shortest then try A--> D --> C---E if there is path between D and E shortest than D --> K --> E then again iterate A--> D --> F --> E simply that sound to me a good idea. I don't have proof now but it can give you the possible shortest path. I hope that will be helpful. Good luck.","Q_Score":0,"Tags":"python,algorithm,graph,networkx,traveling-salesman","A_Id":60486146,"CreationDate":"2020-03-01T08:18:00.000","Title":"Solving a modified Travelling Salesman Problem(TSP) using networkx","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I have a list A of size 285.\nThe first sub-list must have elements of A with size 228 (80% of 285).\nThe second, of size 10% of A.\nThe third, of size 10% of A.\nThere should not be any common element at all. \nThe entire process is randomized. \nI'm aware of random.choices() and random.sample() but I en dup having common elements.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":46,"Q_Id":60475857,"Users Score":1,"Answer":"Depending on the type of elements you can kind of put them in a hash map with a hashing algo of what you define.\nNext iterate through the keys, and try to put them in your required sublists based on the count.","Q_Score":1,"Tags":"python","A_Id":60475902,"CreationDate":"2020-03-01T13:57:00.000","Title":"Creating sub-lists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I have a list A of size 285.\nThe first sub-list must have elements of A with size 228 (80% of 285).\nThe second, of size 10% of A.\nThe third, of size 10% of A.\nThere should not be any common element at all. \nThe entire process is randomized. \nI'm aware of random.choices() and random.sample() but I en dup having common elements.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":46,"Q_Id":60475857,"Users Score":1,"Answer":"If the order doesn't matter, it's simple: random.shuffle the entire list, and then take slices of the needed sizes.\nIf you need to pick out some elements and keep them in order, it gets trickier. The best I can think of is to just go through it mechanically: use random.sample to get the indices of the elements you want for the first sub-list; make that list; then remove those index positions and repeat for more sub-lists. To separate out the elements cleanly and avoid logic errors, we can use list comprehensions to build the sub-list as well as the new \"remaining\" pool. If you're using numpy, this can probably be done better with masks.","Q_Score":1,"Tags":"python","A_Id":60476027,"CreationDate":"2020-03-01T13:57:00.000","Title":"Creating sub-lists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am struggling with the basics.\nI have just one column with names in pandas dataframe and I want to compare strings for potential duplicates using 3-4 functions from fuzzywuzzy library. \nSo first name I want to check against the rest of the column content, then 2nd name and so on. Column will have hundreds if not thousands of names.\nI want to create a df with combination of names for which at least one of the values is above 80.\nDo I need to create a list out of that df?\nApologies, I know it is very basic I just can't seem to find a solution myself.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":60475903,"Users Score":0,"Answer":"So in the end I found a different approach to my issue. Instead of doing 80k vs 80k list I have used a function called itertools.combinations which gives you unique combinations which is perfect in this scenario.","Q_Score":2,"Tags":"python,pandas,fuzzywuzzy","A_Id":60828461,"CreationDate":"2020-03-01T14:02:00.000","Title":"Basic question - iterating through pandas dataframe column using a function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"will it be possible to use CNN weights on an RNN model \nlike can you use the weights of a CNN learning what each letter looks like and using the weights from that CNN to translate a whole sentence?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":31,"Q_Id":60476253,"Users Score":1,"Answer":"It is possible. For an RNN you have to define what is the hidden state so you may set it to be the output of the CNN on the previous element in the sequence. There are several models with state-of-the-art performance on sentence translation. One of them is the Transformer which is makes use of convolutions, as in CNNs, and self-attention. However, it doesn't do so in an RNN scheme, as RNNs are slower to train and evaluate due to their sequential nature. Also note that RNNs are inferior (mainly) due to their problem of short-term memory. You may want to read on LSTMs (that became their successor).","Q_Score":0,"Tags":"python","A_Id":60476585,"CreationDate":"2020-03-01T14:43:00.000","Title":"CNN weights on RNN model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an assignment that is requiring us to create a dot grid along with a curser that moves up, down, right, left, on the grid when given the command. I can't get my move functions to work along with the grid showing with the updated coordinate. This is what I have so far.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":60477495,"Users Score":1,"Answer":"It looks like it might be an import issue or you need to define method for show_grid(x,y). Let me know if this helps!","Q_Score":0,"Tags":"python,grid,dot","A_Id":60477561,"CreationDate":"2020-03-01T16:58:00.000","Title":"Update: mesh grid project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a React Application and I'm looking to run a CMD Command-Line function from a button click.\nWhat is the best way of doing this?\nI am able to run the cmd command through a python script of my own however how could I run this python from React as React is hosted on localhost and security permissions limit access to cmd from there.\nShould I be looking to set up a python server to host the python script?\nAlternatively, I have been looking at Node.js would that be a better way of running this python script and ultimately connect to cmd?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1769,"Q_Id":60477750,"Users Score":0,"Answer":"React is working in the browser so it's impossible to directly access command line.","Q_Score":2,"Tags":"javascript,python,node.js,reactjs,command-line","A_Id":60477818,"CreationDate":"2020-03-01T17:23:00.000","Title":"Calling CMD command line from ReactJS application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a React Application and I'm looking to run a CMD Command-Line function from a button click.\nWhat is the best way of doing this?\nI am able to run the cmd command through a python script of my own however how could I run this python from React as React is hosted on localhost and security permissions limit access to cmd from there.\nShould I be looking to set up a python server to host the python script?\nAlternatively, I have been looking at Node.js would that be a better way of running this python script and ultimately connect to cmd?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1769,"Q_Id":60477750,"Users Score":0,"Answer":"You need to configure a server side and  use the child-process module\nimport * as child from 'child_process'; \nthen in your function use :\nchild.exec(\"your command line\")","Q_Score":2,"Tags":"javascript,python,node.js,reactjs,command-line","A_Id":70127199,"CreationDate":"2020-03-01T17:23:00.000","Title":"Calling CMD command line from ReactJS application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I know in Numpy, if it is divided by 0, it could become -inf or inf. In DolphinDB, if dividing by 0, it will turn into NULL, it is hard for me to tell if the value is just NULL or caused by 0 division.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":16,"Q_Id":60478113,"Users Score":0,"Answer":"The current version of DolphinDB doesn't support INF.","Q_Score":1,"Tags":"python,database,numpy,time-series,dolphindb","A_Id":62103341,"CreationDate":"2020-03-01T17:59:00.000","Title":"Does DolphinDB support -inf and inf when dividing by 0 like numpy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question. I am not looking for the answer to this exercise, just a pointer. My question is: will this be easier to solve if the two-word string is converted to a List?\n\nANIMAL CRACKERS: Write a function takes a two-word string and returns True if both words begin with same letter\nanimal_crackers('Levelheaded Llama') --> True\nanimal_crackers('Crazy Kangaroo') --> False","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":140,"Q_Id":60479037,"Users Score":-1,"Answer":"Do a split on the string input myListOfTwoSriting = stringInput.split(\" \"), next split the 2 string link that : firstletter = myListOfTwoSriting [0].split(\"\")[0] then firstletterOfSeconde = myListOfTwoSriting [1].split(\"\")[0] for the seconde.\nnext:\n\nif firstletter == firstletterOfSeconde :\n    return True\nelse:\n    return False","Q_Score":0,"Tags":"python-3.x","A_Id":60479150,"CreationDate":"2020-03-01T19:40:00.000","Title":"Will it help in this problem to convert the string into a list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"First of all, my apologies if I am not following some of the best practices of this site, as you will see, my home is mostly MSE (math stack exchange).\nI am currently working on a project where I build a vacation recommendation system. The initial idea was somewhat akin to 20 questions: We ask the user certain questions, such as \"Do you like museums?\", \"Do you like architecture\", \"Do you like nightlife\" etc., and then based on these answers decide for the user their best vacation destination. We answer these questions based on keywords scraped from websites, and the decision tree we would implement would allow us to effectively determine the next question to ask a user. However, we are having some difficulties with the implementation. Some examples of our difficulties are as follows:\nThere are issues with granularity of questions. For example, to say that a city is good for \"nature-lovers\" is great, but this does not mean much. Nature could involve say, hot, sunny and wet vacations for some, whereas for others, nature could involve a brisk hike in cool woods. Fortunately, the API we are currently using provides us with a list of attractions in a city, down to a fairly granular level (for example, it distinguishes between different watersport activities such as jet skiing, or white water rafting). My question is: do we need to create some sort of hiearchy like:\n\nnature-> (Ocean,Mountain,Plains) (Mountain->Hiking,Skiing,...)\n\nor would it be best to simply include the bottom level results (the activities themselves) and just ask questions regarding those? I only ask because I am unfamiliar with exactly how the classification is done and the final output produced. Is there a better sort of structure that should be used?\nThank you very much for your help.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":60481819,"Users Score":0,"Answer":"Bins and sub bins are a good idea, as is the nature, ocean_nature thing.\nI was thinking more about your problem last night, TripAdvisor would be a good idea.  What I would do is, take the top 10 items in trip advisor and categorize them by type.  \nOr, maybe your tree narrows it down to 10 cities.  You would rank those cities according to popularity or distance from the user.\nI\u2019m not sure how to decide which city would be best for watersports, etc.  You could even have cities pay to be top of the list.","Q_Score":1,"Tags":"python,machine-learning,decision-tree","A_Id":60517774,"CreationDate":"2020-03-02T02:33:00.000","Title":"Using a Decision Tree to build a Recommendations Application","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"First of all, my apologies if I am not following some of the best practices of this site, as you will see, my home is mostly MSE (math stack exchange).\nI am currently working on a project where I build a vacation recommendation system. The initial idea was somewhat akin to 20 questions: We ask the user certain questions, such as \"Do you like museums?\", \"Do you like architecture\", \"Do you like nightlife\" etc., and then based on these answers decide for the user their best vacation destination. We answer these questions based on keywords scraped from websites, and the decision tree we would implement would allow us to effectively determine the next question to ask a user. However, we are having some difficulties with the implementation. Some examples of our difficulties are as follows:\nThere are issues with granularity of questions. For example, to say that a city is good for \"nature-lovers\" is great, but this does not mean much. Nature could involve say, hot, sunny and wet vacations for some, whereas for others, nature could involve a brisk hike in cool woods. Fortunately, the API we are currently using provides us with a list of attractions in a city, down to a fairly granular level (for example, it distinguishes between different watersport activities such as jet skiing, or white water rafting). My question is: do we need to create some sort of hiearchy like:\n\nnature-> (Ocean,Mountain,Plains) (Mountain->Hiking,Skiing,...)\n\nor would it be best to simply include the bottom level results (the activities themselves) and just ask questions regarding those? I only ask because I am unfamiliar with exactly how the classification is done and the final output produced. Is there a better sort of structure that should be used?\nThank you very much for your help.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":60481819,"Users Score":0,"Answer":"I think using a decision tree is a great idea for this problem.  It might be an idea to group your granular activities, and for the \"nature lovers\" category list a number of different climate types: Dry and sunny, coastal, forests, etc and have subcategories within them.\nFor the activities, you could make a category called watersports, sightseeing, etc.  It sounds like your dataset is more granular than you want your decision tree to be, but you can just keep dividing that granularity down into more categories on the tree until you reach a level you're happy with.  It might be an idea to include images too, of each place and activity.  Maybe even without descriptive text.","Q_Score":1,"Tags":"python,machine-learning,decision-tree","A_Id":60483055,"CreationDate":"2020-03-02T02:33:00.000","Title":"Using a Decision Tree to build a Recommendations Application","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to perform some background advanced calculations on my data after it is collected in InfluxDb which is stored on the edge server, which means I have limited resources for the calculations.\nAlso I cannot block the data collection while I do calculations.\nI am weighing using Kapacitor UDF streams vs custom Python scripts.\nPlease note I need to make the scripts configurable so that I can easily deply them to different environments with different sensors","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":60482622,"Users Score":1,"Answer":"It probably makes little difference, in general, especially for 'simple' usecases, though I lean towards standalone python scripts. (It may be better to use Kapacitor if you can cover your usecase using the kapacitor language for this instead of python based UDFs, but I found it insufficient since I needed to retrieve additional data from other databases)\n\nStandalone python scripts could be a bit lighter, since you don't need to run the Kapacitor service.  \nStandalone python scripts could be a bit more configurable. Kapacitor is also pretty configurable but you'd have to spend a bit of time learning how to use it.  \nStandalone python scripts could be a bit more stable. I've experimented with python UDF's a couple of years ago and found them unstable and buggy. While this may have improved by now, you'd still be relying on this being supported and if go is not your language you might have trouble debugging and fixing issues yourself.","Q_Score":0,"Tags":"python,user-defined-functions,influxdb,kapacitor","A_Id":60491850,"CreationDate":"2020-03-02T04:40:00.000","Title":"Python cron job vs Kapacitor UDF","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a LSTM Keras Tensorflow model trained and exported in .h5  (HDF5) format. \nMy local machine does not support keras tensorflow. I have tried installing. But does not work.\nTherefore, i used google colabs and exported the model. \nI would like to know, how i can use the exported model in pycharm\nEdit : I just now installed tensorflow on my machine\nThanks in Advance","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1484,"Q_Id":60482956,"Users Score":0,"Answer":"You still need keras and tensorflow to use the model.","Q_Score":2,"Tags":"python,tensorflow,keras,pycharm,google-colaboratory","A_Id":60483561,"CreationDate":"2020-03-02T05:24:00.000","Title":"How to use an exported model from google colab in Pycharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having 3 test classes in a single file.\nEach Class has its own setup and teardown methods. I want to make config in pytest where I can parallelize the run of 3 test classes in separately in 3 threads. How do I achieve this?\nPlease help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":259,"Q_Id":60483136,"Users Score":1,"Answer":"Install xdist plugin and use -n=count_of_threads. If the tests have to be run in parallel then we can use --dist=loadscope to group all the tests in the same test class.\n--dist=loadscope: tests will be grouped by the module for test functions and by class for test methods, then each group will be sent to an available worker.\n\npytest filename -n=thread_count --dist=loadscope","Q_Score":1,"Tags":"python,testing,automation,automated-tests,pytest","A_Id":60520291,"CreationDate":"2020-03-02T05:44:00.000","Title":"Running Parallel tests Class wise in pytest","Data 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 the title says i want to know how to make PyQt5 program starts like pycharm\/spyder\/photoshop\/etc so when i open the program an image shows with progress bar(or without) like spyder,etc","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":60485134,"Users Score":2,"Answer":"Sounds like you want a splash screen. QSplashScreen will probably be your friend.","Q_Score":0,"Tags":"python,python-3.x,pyqt5","A_Id":60485172,"CreationDate":"2020-03-02T08:41:00.000","Title":"How to make PyQt5 program starts like pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"8.2 \nWhen I install a new module with pip install PyNaCl it says it downloaded successfully, then I check with pip list and its there and when I run my python code I get \"No Module Named \"PyNaCl\" error. It's not from the module because I tried with different ones and I get the same error.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4390,"Q_Id":60485258,"Users Score":0,"Answer":"PyNaCl's runtime module name is nacl, so it must be imported by import nacl.","Q_Score":1,"Tags":"python,python-3.x,pynacl","A_Id":60485341,"CreationDate":"2020-03-02T08:49:00.000","Title":"ModuleNotFoundError: No module named error python 3.8.2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have build a real time face detection using OPENCV in python now i am expanding my project to fyp and making a iot based smart home automation using AI.I am implementing a door lock as a initial state which will be opened if it detect a face which will be in dataset.\nI don't want it to detect or opened if someone show a picture from mobile of same person which is a security concern\nplease Help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":49,"Q_Id":60485783,"Users Score":1,"Answer":"An idea to improve security is asking people to perform something like: \n\nblink one or both eyes\nopen mouth\nturn left or right... \n\nProbably choose one or two of these randomly... This will improve security, but it is not really safe. It may be useful to overcome some accessibility issues.\nSome other ideas I've read eslewhere:\n\ncheck background of the image (if the camera is fixed) \nuse infrared camera to detect heat patterns\nuse two cameras to get a stereoscopic image","Q_Score":1,"Tags":"python,opencv,security,iot","A_Id":60490783,"CreationDate":"2020-03-02T09:23:00.000","Title":"How to overcome face detection security issues so it cannot detect a face if someone shows a picture?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used cmake to build my project. I tried sudo apt-get install libboost-all-dev, but it didn't solve my issue. Is there a way to solve this problem? Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1081,"Q_Id":60485840,"Users Score":0,"Answer":"I had a similar problem, and found that the needed library was installed under the name \/usr\/lib\/<arch>\/libboost_python38.so (for x86_64 in my case that's \/usr\/lib\/x86_64-linux-gnu\/libboost_python38.so).\nSo I ran sudo ln -s \/usr\/lib\/x86_64-linux-gnu\/libboost_python38.so \/usr\/lib\/x86_64-linux-gnu\/libboost_python-py38.so and was able to link OK.\nI ran into this specifically when trying to install pygattlib under python 3.8.","Q_Score":1,"Tags":"boost-python","A_Id":68330070,"CreationDate":"2020-03-02T09:26:00.000","Title":"how to install boost_python-py38 on ubuntu 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 have a kubernetes multi-resource file which contains different resources that are to be applied for e.g. deployment-definition, service-defintion, pv, pvc etc. Is there any way to use this single file through kubernetes python client to deploy all these resources at once ?\nThough my scenario is a bit different. I have a file which use CRDs alongwith custom kubernetes resource objects for e.g. Deployment + ambassador's Mapping. How to achieve this using kubernetes python client?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1409,"Q_Id":60486407,"Users Score":0,"Answer":"With the client, you have to do them all separately. When you have multiple documents in a YAML file, kubectl just splits them for you and makes an API call for each.","Q_Score":0,"Tags":"kubernetes,kubectl,kubernetes-python-client,ambassador","A_Id":60486524,"CreationDate":"2020-03-02T10:01:00.000","Title":"How to use a multiple kubernetes resource file through kubernetes python client similar to kubectl apply -f","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I CTRL + F5, the terminal output shows verbosity that I would like to hide:\n\ncd \/home\/ ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 \/usr\/bin\/python3 \/home\/.vscode\/extensions\/ms-python.python-2020.2.64397\/pythonFiles\/ptvsd_launcher.py --default --nodebug --client --host localhost --port 33907 \/home\/hello.py\nHello\n\nJust print Hello...","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":440,"Q_Id":60487986,"Users Score":1,"Answer":"There is unfortunately no way to hide this output as it's required to execute the debugger.","Q_Score":2,"Tags":"python,visual-studio-code,vscode-settings","A_Id":60514004,"CreationDate":"2020-03-02T11:32:00.000","Title":"How to make vscode debugging in the terminal less verbose?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"This question is not about how to use sys.exit (or raising SystemExit directly), but rather about why you would want to use it.\n\nIf a program terminates successfully, I see no point in explicitly exiting at the end.\nIf a program terminates with an error, just raise that error. Why would you need to explicitly exit the program or why would you need an exit code?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":93,"Q_Id":60488920,"Users Score":3,"Answer":"Letting the program exit with an Exception is not user friendly. More exactly, it is perfectly fine when the user is a Python programmer, but if you provide a program to end users, they will expect nice error messages instead of a Python stacktrace which they will not understand.\nIn addition, if you use a GUI application (through tkinter or pyQt for example), the backtrace is likely to be lost, specially on Windows system. In that case, you will setup error processing which will provide the user with the relevant information and then terminate the application from inside the error processing routine. sys.exit is appropriate in that use case.","Q_Score":1,"Tags":"python","A_Id":60489216,"CreationDate":"2020-03-02T12:31:00.000","Title":"What is the point of using sys.exit (or raising SystemExit)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am quite new to Tensor Flow \/ Edge TPU usage.\nWhile I mange to run an image classification with the classify_image.py script \nit has a very poor performance on the Edge TPU USB module because it always loads the model and kind of reboots the device (you see the Win10 device manager reinstalling it at every run of the script).\nIs there any way to run a python script that classifies an image with the last loaded model in the USB dongle, avoiding the 3-5 seconds of device configuration time ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":60490009,"Users Score":0,"Answer":"Normally, you should load the model first and store it. Then when you use it for invoking, you just need to allocate tensor, then pass to it the input. You can keep your script in while loop waiting for your input (ie sending through websocket,... or loading a directory). But according to what I see, you will have to self load the image to the model,so there is really hard to self-allocate a fixed part of TPU to your model.","Q_Score":0,"Tags":"python,image,classification,tpu","A_Id":63877839,"CreationDate":"2020-03-02T13:37:00.000","Title":"Running classification inference on EDge TPU USB without reloading model every time","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using openpyxl module, but now it turns out that it doesnot support csv format. So, How can I differentiate whether the file incoming is .xlsx or .csv format","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1664,"Q_Id":60491746,"Users Score":0,"Answer":"Load it in try:..except:.. At least in case of xlsx you can be quite confident that if it's failing, then it's not xlsx. CSV is so primitive a format, that almost everything can be treated as such, but I think that's the maximum that you can squeeze out of it.","Q_Score":1,"Tags":"python","A_Id":60492038,"CreationDate":"2020-03-02T15:14:00.000","Title":"How to check if the browsed file is .xlsx or .csv?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Spyder 4.0.1 and Python 3.7 and trying to:\npip install ta-lib\nhowever, after a few cmdwindows pop open and auto-close very quickly at the beginning, nothing seems to be happening and the iPython console is just stick on \"pip install ta-lib\" with no new In[]: box showing.  \nI have tried manually stopping and restarting the kernel and then retrying but the same thing happens.  Can someone help troubleshoot?\nMany thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":381,"Q_Id":60491840,"Users Score":0,"Answer":"I don't know which OS you are using, but in MacOS what I did was: \n1) Installed ta-lib using brew.\nbrew install ta-lib\n2) Then Ran the pip install TA-Lib command.\nThe above step should work in most of the cases, but one of my friend was facing some issue with gcc, if you are facing any issue related to gcc, try installing gcc. For installing gcc you can use the command: \nbrew install gcc\nHope this helps.","Q_Score":0,"Tags":"python-3.x,pip,installation,spyder,ta-lib","A_Id":62233390,"CreationDate":"2020-03-02T15:20:00.000","Title":"Can't install TA-LIB?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a little big problem, we created a Jupyter Notebook on windows os, but when I try to run it on a linux server, the following line of code runs without errors: pandas.read_csv(\"file.csv\", encoding='utf-8'), but the NaN values are not replaced like in windows. Do you know any solution to this issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":60492332,"Users Score":0,"Answer":"i find the solution on colab:\npandas.read_csv(\"file.csv\", delimiter='\\t', header=None, names=['colNamesHere'])\nthe solution was import like normali CSV file but in the method you need to add: delimiter='\\t'","Q_Score":0,"Tags":"python,pandas","A_Id":60530554,"CreationDate":"2020-03-02T15:48:00.000","Title":"Python Encoding CSV from Windows to linux","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Nipyapi version: latest version\nNiFi version: 1.9\nNiFi-Registry version: None\nPython version: 2.7\nOperating System: ubuntu\n\nDescription\nI want to get all process group but just from the root canvas, when I call canvas.list_all_process_group(pg_id) I got all pg from all nifi. I am asking if there is any solution to get just from root canvas.\nWhat I Did\nplayground_pg=canvas.list_all_process_groups(pg_id=root_pg.id)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":297,"Q_Id":60492557,"Users Score":0,"Answer":"You want nipyapi.nifi.ProcessGroupsApi().get_process_groups(pg_id), which only returns the Process Groups from the target, and not from all descendants.\nThe canvas.list_all_process_group(pg_id) is designed to get everything everywhere quickly.","Q_Score":0,"Tags":"python,apache-nifi,nipyapi","A_Id":60580633,"CreationDate":"2020-03-02T16:01:00.000","Title":"List all process group from root canvas","Data Science and Machine Learning":0,"Database and SQL":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":"Nipyapi version: latest version\nNiFi version: 1.9\nNiFi-Registry version: None\nPython version: 2.7\nOperating System: ubuntu\n\nDescription\nI want to get all process group but just from the root canvas, when I call canvas.list_all_process_group(pg_id) I got all pg from all nifi. I am asking if there is any solution to get just from root canvas.\nWhat I Did\nplayground_pg=canvas.list_all_process_groups(pg_id=root_pg.id)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":297,"Q_Id":60492557,"Users Score":0,"Answer":"There are canvas.get_process_group and canvas.get_process_group_status function, do either of those return what you're looking for?","Q_Score":0,"Tags":"python,apache-nifi,nipyapi","A_Id":60532742,"CreationDate":"2020-03-02T16:01:00.000","Title":"List all process group from root canvas","Data Science and Machine Learning":0,"Database and SQL":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 document classification problem using CNN\/LSTM and embeddings generated from universal sentence encoder. I have 10,000 records and each record has about 100~600 sentences. I save all the document matrices into one json file before I feed them into the neural network models. The overall json file is about 20GB which will take too much memory.\nI'm not sure if I should save documents in text format and convert them into sentence embeddings during the training process. What's the potential solution?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":60493576,"Users Score":0,"Answer":"Providing the Solution in this section (even though it is present in Comments section), for the benefit of the Community.\nSaving the Embeddings in a Separate Pickle File has resolved the problem.","Q_Score":0,"Tags":"python,deep-learning,pytorch,tensorflow-hub","A_Id":60633021,"CreationDate":"2020-03-02T17:08:00.000","Title":"Handle large dense vectors generated from universal sentence encoder","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know if is possible to use the linear assignment solver to solve a generalized assignment problem. If it's possible, there is a parameter that I have to configure in the solver?\nI took a look in the Google OR-Tools documentation, but I didn't found nothing mentioning that.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":113,"Q_Id":60494328,"Users Score":1,"Answer":"No. You need to use the linear wrapper or the CP-SAT solver for this.","Q_Score":0,"Tags":"python,or-tools","A_Id":60508837,"CreationDate":"2020-03-02T18:04:00.000","Title":"Can I use the linear assignment solver to solve a generalized assignment problem?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"At my work they have installed Python 3.4 and I have created virtual environments using that version but now I need Python 3.8 to work on a personal project on my spare time. Is it possible to create a venv using Python 3.8 without having admin privileges?\nWe use CentOS for OS.\nMany thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":350,"Q_Id":60495966,"Users Score":1,"Answer":"Afaik the python3.8 binary is needed. So you would need to compile it from sources (meaning download source, compile, put result somwhere in your home). Then you can do venv normally.","Q_Score":0,"Tags":"python,python-3.x,centos,virtualenv","A_Id":60496034,"CreationDate":"2020-03-02T20:13:00.000","Title":"Is it possible to create a Python 3.8 virtual environment without admin privileges if there is only Python 3.4 installed? CentOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Trying to deploy Azure Functions written in Python and looks like the only option to do that is through VS Code.\nI have Python and Azure Functions extensions, and normally use PyCharm with Anaconda interpreter.\nI also have azure-functions-core-tools installed and calling \"func\" in PS works.\nIn the VS Code I create a virtual environment as it suggests. But when tyring to debug  any Azure Function (using one of their templates for now) I get the error above.\nAs far as I understand it tries to install \"azure-functions\" module as specified in the \"requirements.txt\" file and tries to do that with pip. pip works normally if I use it through Anaconda prompt or with my global env python, but I have to use the virtual environment created by VS Code for this one.\nAny suggestions on how to get through this? Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1230,"Q_Id":60497854,"Users Score":1,"Answer":"Just solved the problem after wasting my valuable whole afternoon. The problem lies on the side of Anaconda.\nAs you described in your question, pip works normally (only) in your Anaconda prompt. Which means, it doesn't work anywhere outside, no matter in a CMD or a PowerShell (although pip and conda seem work outside of the prompt, SSL requests get somehow always refused). However, VS Code, when you simply press F5 instead of using func start command, uses an external PowerShell to call pip. No wonder it'll fail.\nThe problem can be solved, when you install Anaconda on Windows 10, by choosing to add Anaconda's root folder to PATH. This being said, Anaconda's installer strongly doesn't recommend choosing this option (conflicts with other apps blabla)... And if you try to install Anaconda through some package manager such as scoop, it'll install it without asking you for this detail, which is logical.\nThe \"fun\" part is philosophically Anaconda itself doesn't suggest using conda or pip command outside Anaconda Prompt, while other apps want and may have to do it the other way. Very very confusing and annoying.","Q_Score":1,"Tags":"python,visual-studio-code,pip,azure-functions","A_Id":62578489,"CreationDate":"2020-03-02T23:01:00.000","Title":"VS Code Azure Functions: pip is configured with locations that require TLS\/SSL, however the ssl module in Python is not available","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an array as below.\nX1=np.array([[0,0],[0,0]])\nX1[:,0].shape gives me (2,).\nHow do I convert X1[:,0] to a shape of (2,1).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":272,"Q_Id":60499238,"Users Score":0,"Answer":"thanks for asking. what you have is a two by two matrix, so turning one part of the array to a two dimensional array will cause an error. I think you should create a new array from the sub array and then reshape it. you can do it like this new_x = X[:,0]\nnew_x.reshape(2,1). I hope this works","Q_Score":0,"Tags":"python-3.x,numpy-ndarray","A_Id":60499587,"CreationDate":"2020-03-03T02:26:00.000","Title":"How to reshape an array of shape (m,) to (m,1)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am following a tutorial in keras but i am getting the error which i could not find the\ndocumentation online \n\nModuleNotFoundError: No module named 'data_engine'\n\nWhat is the problem here does that mean this library is not exist or what?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":502,"Q_Id":60501538,"Users Score":0,"Answer":"It means you didn't include the module named 'data_engine', you need to include it at the header of your python script.","Q_Score":0,"Tags":"python,python-3.x,tensorflow,keras,module","A_Id":60501613,"CreationDate":"2020-03-03T06:48:00.000","Title":"ModuleNotFoundError: No module named 'data_engine'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I encountered an error when I was importing the module pyttsx. Does anyone have an idea how we can solve this. I have turned on virtuavenv and have pyttsx in my pip, i checked that with pip freeze\nthe error is: Error: No module found","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":60501993,"Users Score":0,"Answer":"You have to install that module firstly and then you can import it successfully.\nTry pip install pyttsx\nNote: before running the above command check that the module name is correct or not? Hopefully this will work for you.","Q_Score":1,"Tags":"python","A_Id":60502406,"CreationDate":"2020-03-03T07:22:00.000","Title":"Why is there an error when I tried to import pyttsx","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've seen 2 ways of installing OpenCV (there might be more ways which I don't know): \n\nInstalling from the source\nInstalling with pip: pip install opencv-python\n\nMy question is, why we need to install OpenCV from the source while we can simply install it using pip? Since people are using both of them, both must be useful. If so, there are any conditions for selecting one of them?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1253,"Q_Id":60503042,"Users Score":3,"Answer":"I will list out the differences between both\n1.\nInstallation using pip\nInstallation is done at the default location where all the python packages resides.\nInstallation from Source\nInstallation location is provided by the developer.\n2.\nInstallation using pip\nIn terms of performance, the packages installed might run slower because of the hidden conflicts between features.\nInstallation from Source\nThe developer can select the optimization flags during the compilation of packages which are responsible for the fast performance of library.\n3.\nInstallation using pip\nThe developers can neither add nor remove features provided in the installation done by pip.\nInstallation from Source\nThe developer has all the rights to add or remove the features during the installation of library.\n4.\nInstallation using pip\nThe package manager will do the work on behalf of developer. Package Manager is also responsible for taking care of library updation.\nInstallation from Source\nThe developers are responsible for  feature selection and updation of library. They must be aware of new package updates, latest security patches etc, to keep themselves updated about  the library.\nHope this helps you!","Q_Score":0,"Tags":"python,opencv,deep-learning,computer-vision","A_Id":60503293,"CreationDate":"2020-03-03T08:32:00.000","Title":"Install OpenCV from source or via Pip?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've seen 2 ways of installing OpenCV (there might be more ways which I don't know): \n\nInstalling from the source\nInstalling with pip: pip install opencv-python\n\nMy question is, why we need to install OpenCV from the source while we can simply install it using pip? Since people are using both of them, both must be useful. If so, there are any conditions for selecting one of them?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1253,"Q_Id":60503042,"Users Score":1,"Answer":"OpenCV is always under development, and the thing is some parts of the library is not going to published, due to compatibility and copyright issues, but if you use the source then you can have all the capabilities that you need. SURF & SIFT are examples of this problem.","Q_Score":0,"Tags":"python,opencv,deep-learning,computer-vision","A_Id":60504817,"CreationDate":"2020-03-03T08:32:00.000","Title":"Install OpenCV from source or via Pip?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"total beginner here.\nI'm trying to understand how to compare user input data to preset class data. Let's say class = Person, with the age, weight, and name.\nAnd I've got two people, johnsmith = Person(50, 200, \"John Smith\")\ntomjones = Person(40, 220, \"Tom Jones\")\nI want to prompt the user to input the name Tom, and have check all \"name\" attributes for the Person class. So something like, \nperson = input(print(\"Insert the person's name: \")) entering \"Tom\" and then returning a list of all Toms for the user to select, or if there's only one, confirm that the user in fact did mean Tom Jones.\nShould I create an array like people = [tomjones, johnsmith, (etc)], and somehow search inside that?\nPlease point me in the right direction on this, thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":60503659,"Users Score":0,"Answer":"Should I create an array-like people = [tomjones, johnsmith, (etc)], and somehow search inside that?\n\nYes. \nAlthough ihough if you expect a very large number of \"people\" and frequent queries always on the same field (e.g. you're always searching for a specific person by its name) you may also want to create an index to speed up searches e.g. create a dict (possibly a WeakValueDictionary) which maps whatever your search key is to the proper person.\nThis is because iterating a list is cheap and efficient but going through the entire list is linear time (O(n)) so if your list is very long and you go through it a lot, it adds up. Building an index is expensive (and requires going through the entire list at least once) and there is more setup to the lookup but setup aside the lookup is constant time (O(1)).","Q_Score":0,"Tags":"python","A_Id":60503783,"CreationDate":"2020-03-03T09:08:00.000","Title":"How to compare user input to class object data?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"TBH I'm beginner in learning python but I'm working well when it's come to reading the man page of Linux and the notation\/conventin of it \nSuch as \n-- bold text is type exactly as shown in synopsis\n-- italic text replaced with the appropriate argument \n-- [-abc] all of this are optional \n.... Etc are in man man command \nBut how I can read the synopsis that return from help('smething')","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17,"Q_Id":60504225,"Users Score":0,"Answer":"Just type help(), then enter and type 'smething'","Q_Score":0,"Tags":"python,python-2.7","A_Id":60504402,"CreationDate":"2020-03-03T09:40:00.000","Title":"I can't read the return of built-in help() in python... Because the notation of documentation can't be understood","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I work with wxpython and threads in my project. I think that I didn't understand well how to use wx.CallAfter and when to us it. I read few thing but I still didn't got the point. Someone can explain it to me?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":636,"Q_Id":60506389,"Users Score":2,"Answer":"In a nutshell, wx.CallAfter simply takes a callable and the parameters that should be passed to it, bundles that up into a custom event, and then posts that event to the application's pending event queue. When that event is dispatched the handler calls the given callable, passing the given parameters to it.\nOriginally wx.CallAfter was added in order to have an easy way to invoke code after the current and any other pending events have been processed. Since the event is always processed in the main UI thread, then it turns out that wx.CallAfter is also a convenient and safe way for a worker thread to cause some code to be run in the UI thread.","Q_Score":1,"Tags":"python,python-3.x,multithreading,wxpython","A_Id":60511961,"CreationDate":"2020-03-03T11:36:00.000","Title":"wxPython wx.CallAfter()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I run chrome driver from selenium the browser opens in minimized windows. but I want it to open by default as maximized","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":378,"Q_Id":60507053,"Users Score":1,"Answer":"You can either use \ndriver.maximize_window() or \nchrome_options.add_argument(\"--start-maximized\") which will maximize the browser when ever it opens.","Q_Score":0,"Tags":"python","A_Id":60507125,"CreationDate":"2020-03-03T12:15:00.000","Title":"How to maximize chrome browser in default when using selenium in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an ExecuteStreamCommand processor which executes a Python script. This takes a long time to execute ~ 5 mins. So I increased the number of concurrent tasks from 1, 4 and 8 but this had. no impact on the performance. I have an 8 core Intel i9 Mac machine with 32 GB RAM. I read that typically the number of concurrent tasks is roughly equal to\u00a0 2 or 4 times the cores. Could you let me know why there is no improvement? How can I improve the performance?\nThanks\nGanesh","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":339,"Q_Id":60508640,"Users Score":0,"Answer":"No it does not run slowly. It takes the same amount of time ~5mins for (1,4,8 concurrent tasks) \u2013 Tinniam V. Ganesh Mar 3 at 16:07\n\nThat is to be expected because NiFi and the Java VM cannot loan out threads to your Python script to use. The concurrency settings there are for how many threads NiFi is allowed to assign to the processor. Each thread will fire up a new instance of your process. The only way to make your script run faster is to work on the script itself.","Q_Score":0,"Tags":"python,apache-nifi","A_Id":64930685,"CreationDate":"2020-03-03T13:46:00.000","Title":"Increasing number of concurrent tasks in NIFI not improving performance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I import Tensorflow, Python crashes with the following output: \n\nC:\\Anaconda\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:516:\n  FutureWarning: Passing (type, 1) or '1type' as a synonym of type is\n  deprecated; in a future version of numpy, it will be understood as\n  (type, (1,)) \/ '(1,)type'.   _np_qint8 = np.dtype([(\"qint8\", np.int8,\n  1)])\n  C:\\Anaconda\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:517:\n  FutureWarning: Passing (type, 1) or '1type' as a synonym of type is\n  deprecated; in a future version of numpy, it will be understood as\n  (type, (1,)) \/ '(1,)type'.   _np_quint8 = np.dtype([(\"quint8\",\n  np.uint8, 1)])\n  C:\\Anaconda\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:518:\n  FutureWarning: Passing (type, 1) or '1type' as a synonym of type is\n  deprecated; in a future version of numpy, it will be understood as\n  (type, (1,)) \/ '(1,)type'.   _np_qint16 = np.dtype([(\"qint16\",\n  np.int16, 1)])\n  C:\\Anaconda\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:519:\n  FutureWarning: Passing (type, 1) or '1type' as a synonym of type is\n  deprecated; in a future version of numpy, it will be understood as\n  (type, (1,)) \/ '(1,)type'.   _np_quint16 = np.dtype([(\"quint16\",\n  np.uint16, 1)])\n  C:\\Anaconda\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:520:\n  FutureWarning: Passing (type, 1) or '1type' as a synonym of type is\n  deprecated; in a future version of numpy, it will be understood as\n  (type, (1,)) \/ '(1,)type'.   _np_qint32 = np.dtype([(\"qint32\",\n  np.int32, 1)])\n  C:\\Anaconda\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:525:\n  FutureWarning: Passing (type, 1) or '1type' as a synonym of type is\n  deprecated; in a future version of numpy, it will be understood as\n  (type, (1,)) \/ '(1,)type'.   np_resource = np.dtype([(\"resource\",\n  np.ubyte, 1)])\n\nCan anyone help me ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":60511386,"Users Score":0,"Answer":"i solved my problem : \ndon't try uptade , uninstall tensorflow (i tried everything)\ndelete (if u use anaconda ) anaconda  and install again , mark \"add Python to my PATH\" during installation.\nhave a nice day.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,jupyter-notebook","A_Id":60527516,"CreationDate":"2020-03-03T16:12:00.000","Title":"Python crashed when I try to import Tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I import Tensorflow, Python crashes with the following output: \n\nC:\\Anaconda\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:516:\n  FutureWarning: Passing (type, 1) or '1type' as a synonym of type is\n  deprecated; in a future version of numpy, it will be understood as\n  (type, (1,)) \/ '(1,)type'.   _np_qint8 = np.dtype([(\"qint8\", np.int8,\n  1)])\n  C:\\Anaconda\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:517:\n  FutureWarning: Passing (type, 1) or '1type' as a synonym of type is\n  deprecated; in a future version of numpy, it will be understood as\n  (type, (1,)) \/ '(1,)type'.   _np_quint8 = np.dtype([(\"quint8\",\n  np.uint8, 1)])\n  C:\\Anaconda\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:518:\n  FutureWarning: Passing (type, 1) or '1type' as a synonym of type is\n  deprecated; in a future version of numpy, it will be understood as\n  (type, (1,)) \/ '(1,)type'.   _np_qint16 = np.dtype([(\"qint16\",\n  np.int16, 1)])\n  C:\\Anaconda\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:519:\n  FutureWarning: Passing (type, 1) or '1type' as a synonym of type is\n  deprecated; in a future version of numpy, it will be understood as\n  (type, (1,)) \/ '(1,)type'.   _np_quint16 = np.dtype([(\"quint16\",\n  np.uint16, 1)])\n  C:\\Anaconda\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:520:\n  FutureWarning: Passing (type, 1) or '1type' as a synonym of type is\n  deprecated; in a future version of numpy, it will be understood as\n  (type, (1,)) \/ '(1,)type'.   _np_qint32 = np.dtype([(\"qint32\",\n  np.int32, 1)])\n  C:\\Anaconda\\lib\\site-packages\\tensorflow\\python\\framework\\dtypes.py:525:\n  FutureWarning: Passing (type, 1) or '1type' as a synonym of type is\n  deprecated; in a future version of numpy, it will be understood as\n  (type, (1,)) \/ '(1,)type'.   np_resource = np.dtype([(\"resource\",\n  np.ubyte, 1)])\n\nCan anyone help me ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":60511386,"Users Score":0,"Answer":"FutureWarning= a warning about a future (not currently existing) version of numpy. As tensorflow will definitely address this warning when numpy updates,  you can ignore this. It's only a warning, I also get this warning, you can ignore it.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,jupyter-notebook","A_Id":60511446,"CreationDate":"2020-03-03T16:12:00.000","Title":"Python crashed when I try to import Tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Building a shared (.so) library with nvcc for a small C++ project. When I load this library in python with ctypes.CDLL(), the operation seems to succeed.  But when I look at the resulting object with dir(libc), all I see are built-in methods, not any of my C++ functions from the library. \nWhat am I doing wrong?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":60512631,"Users Score":0,"Answer":"Ok... I needed to have extern \"C\" preceeding the function declarations in my .h file.","Q_Score":0,"Tags":"python,c++,dll,ctypes,nvcc","A_Id":60513191,"CreationDate":"2020-03-03T17:29:00.000","Title":"Python ctypes.CDLL loads my shared library successfully, but I can't see any of my C++ 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":0,"Web Development":0},{"Question":"I use Python and Spotipy lib.\nIs there any way to list all songs from spotify playlist? \nMethod playlist_tracks() has limit to print only 100 songs.\nSame question about other methods eg. current_user_saved_tracks() with its 20 limits.\nWhy spotify api have these limits? \nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":380,"Q_Id":60513415,"Users Score":0,"Answer":"In order to get all songs in a playlist you use the first request to determine the total song count which is part of the spotify response.\nDividing the total count by the max song limit per request (100) and rounding up the result will give you the necessary amount of api calls needed to get all song.\nWith this information in mind you simply loop from 0 to call count and request the next 100 song.\nInside the loop you have to set the offset property of the request to x * 100.\nFurthermore your have to add the requested songs to a temporary array to get the entire list at the end.\nI can only assume that the general limit of 100 songs per request is a technical need at spotify.","Q_Score":0,"Tags":"python,api,spotify,spotipy","A_Id":60513747,"CreationDate":"2020-03-03T18:24:00.000","Title":"spotify api playlist_tracks() limits","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I see there exits two configs of the T5model - T5Model and TFT5WithLMHeadModel. I want to test this for translation tasks (eg. en-de) as they have shown in the google's original repo. Is there a way I can use this model from hugging face to test out translation tasks. I did not see any examples related to this on the documentation side and was wondering how to provide the input and get the results. \nAny help appreciated","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4046,"Q_Id":60513592,"Users Score":1,"Answer":"T5 is a pre-trained model, which can be fine-tuned on downstream tasks such as Machine Translation. So it is expected that we get gibberish when asking it to translate -- it hasn't learned how to do that yet.","Q_Score":2,"Tags":"python-3.x,tensorflow2.0,huggingface-transformers","A_Id":60905909,"CreationDate":"2020-03-03T18:37:00.000","Title":"How to use huggingface T5 model to test translation task?","Data Science and Machine Learning":0,"Database and SQL":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 writing a little program with optparse. It should format shellcode.\nThe problem is, that python doesn't accept e.g \"\\x31\" as argument and interpret it as \"x31\".\nOf course it is possible to build a workarround.\nBut is there a way to work with an input like so?:\npython prog.py -t \\x31\\xCA\nprint(args) => '\\x31\\xCA'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":75,"Q_Id":60513835,"Users Score":0,"Answer":"Use quotation marks: python prog.py -t \"\\x31\\xCA\"","Q_Score":0,"Tags":"python,optparse","A_Id":60513988,"CreationDate":"2020-03-03T18:55:00.000","Title":"How to accept backslashes in raw input","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know how to create a list called \"my_list\" in Python starting with a value in a variable \"begin\" and containing 10 successive integers starting with \"begin\". \nFor example, if begin = 2, I want my_list = [2,3,4,5,6,7,8,9,10,11]","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":420,"Q_Id":60513967,"Users Score":0,"Answer":"Simply you can use extend method of list and range function.\nstart = 5\nmy_list = []\nmy_list.extend(range(start,start+11))\nprint(my_list)","Q_Score":0,"Tags":"python,list,integer","A_Id":60514174,"CreationDate":"2020-03-03T19:05:00.000","Title":"Python: Create List Containing 10 Successive Integers Starting with a Number","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Python 3.7 in Ubuntu 18.04. Now as Ubuntu is written in Python 3.6, there are many applications that explicitly point to Python3 (which in my case is now 3.7). Is there any way I can explicitly make them point to 3.6 instead of default Python3\nNote - I was facing same issue in my terminal. It wasn't opening. So I opened it's config file and changed python 3 to python 3.6","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":60515860,"Users Score":0,"Answer":"Make an alias, put it in your ~\/.bashrc file or some other alias file you have. \nalias python = python3.7","Q_Score":0,"Tags":"python-3.x,ubuntu-18.04","A_Id":60515931,"CreationDate":"2020-03-03T21:33:00.000","Title":"Pointing Python in Ubutnu to 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"First of all thanks, I'm no expert in programming.\nI work with jupyter notebooks and with my boss we use a Dropbox folder where he is able to run all my codes( including exporting and importing files within the folder), since it is possible to run jupyter notebook from within a desired folder( in this case, the Dropbox one). Based on this, when importing files I can just type a path like this one: \"Dropxboxsharedfolder\/some-otherfolder\/jdjd.csv\" and it will find the file in both of our computers. \nNow we are running SQL scripts through Jupyter, of course, the .SQL file is within the Dropbox folder, but the script has within itself a code where I import a CSV file located inside the Dropbox folder. Nevertheless (of course, it won't) it won't let me just type the path as \"dropboxsharedfolder\/somefolder\/djdhjd.csv\" I have to type \"User\/username\/dropboxsharedfolder\/...\/jdjd.csv\". At the end, when my boss runs the notebook it won't work cause it won't find the file.\nIs there a solution for this situation?\nThank you so much for your time!\nPd: we use postgresSQL","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":60517828,"Users Score":0,"Answer":"You could use an environment variable to point to the shared dropbox folder on each computer (the value of the variable would be set accordingly on each computer) and use the environment variable in your script instead of hardcoded paths","Q_Score":0,"Tags":"python,postgresql,csv,path,jupyter-notebook","A_Id":60518145,"CreationDate":"2020-03-04T01:23:00.000","Title":"Importing a csv file to a Postgres table from different computers ( hence, different paths)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm on windows, and pip was working just fine, but now it's giving this error message, unclear what changed.\n\"Fatal error in launcher: Unable to create process using '\"c:\\python.exe\"  \"C:\\Scripts\\pip.exe\" ': The system cannot find the file specified.\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":60518503,"Users Score":0,"Answer":"It seems to be that your system is not able to find 'c:\\python.exe', try looking at this location if the file is present.\n\nTry creating environment variables by name \"python\" which runs your python executable present at 'c:\\python.exe'\n\nEasy way if you struggle in step 1\n\nRe-install python and add path of python","Q_Score":0,"Tags":"python,windows,pip","A_Id":60518618,"CreationDate":"2020-03-04T03:07:00.000","Title":"pip is giving an error and i can't find an explanation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am learning to use django and my question is if it is possible to change the system to reset the users' password, the default system of sending a link by mail I do not want to use it, my idea is to send a code to reset the password , but I don't know how it should be done and if possible, I would also need to know if it's safe.\nWhat I want is for the user who wants to recover his password to go to the recovery section, fill in his email and choose to send and enable a field to put the code that was sent to the mail.\nI don't know how I should do it or is there a package for this?\nThank you very much people greetings.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":60519088,"Users Score":0,"Answer":"You can do this, when user clicks on reset password ask for users email id, verify that email id provided is same as what you have in DB. If the email id matches you can generate a OTP and save it in DB(for specific time duration like 3 mins) and send it to user's Email id. Now User enters the OTP. If the OTP provided by user matches the one you have in DB, open the page where user can enter new password.","Q_Score":0,"Tags":"python,django","A_Id":60519448,"CreationDate":"2020-03-04T04:29:00.000","Title":"How to change resetting password of django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to dynamically change (increase) max size of asyncio.Queue object when there are already items in the queue?\nWhat side effects are expected if it is done by manipulating internal properties?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":322,"Q_Id":60521594,"Users Score":3,"Answer":"No, it is not possible. There is no method of asyncio.Queue to do this.\nTo get a queue with a different size you need to create a new one and possibly transfer all items, or you could for example create a setup where you can alternate between two queues, allowing you to replace the one that is currently not in use.\n\nIf you decide to manipulate the internal state of the queue that is not accessible through its interface, you might get it to work now, but you can not rely on it to not break when there are any Python updates.","Q_Score":3,"Tags":"python,python-3.x,python-asyncio","A_Id":60521662,"CreationDate":"2020-03-04T08:12:00.000","Title":"Dynamically increase size of asyncio.Queue?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently learning MongoDb and creating an app on python. I need to select one random document from user collection using uMongo, I have tried aggregate but it says that umongo have no this function. How can i do that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":60521822,"Users Score":0,"Answer":"Indeed, you need to use the aggregation framework.\nTo do so, you must circumvent umongo to call the underlying driver (e.g. pymongo) directly.","Q_Score":0,"Tags":"python,mongodb,umongo","A_Id":64908144,"CreationDate":"2020-03-04T08:27:00.000","Title":"uMongo get random document from collection","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to implement a backend server that can read (to perform some action) users gmail every time a new mail is received. I am able to figure out that using gmail API users.watch, my server can be notified every time a new email is received. Now, for fetching new mails from gmail my server needs User credentials (Auth token) that are provided by the user at the time of opting in to be watched. Is there anyway these credentials can be sent to my server along with the push notification (maybe using users.watch API). \nOne method I came across to achieve the same is to store auth and refresh token in a DB, that will be accessible only by my server. But it will be better if the purpose can be achieved without storing credentials in the DB.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":137,"Q_Id":60525479,"Users Score":2,"Answer":"When the user authenticates your application you are given a refresh token assuming that you requested offline access. You should store this in a secure place associated with the user on your server.\nWhen you get a push notification you should then retrieve the refresh token that you have stored on your server and use that to request a new access token that you can use to access the users data.\nThe push notification system has no way of sending you the authorization nor would it be a very wise idea if it was storing your authorization.","Q_Score":2,"Tags":"gmail-api,google-cloud-pubsub,google-api-python-client,google-cloud-python","A_Id":60528026,"CreationDate":"2020-03-04T11:55:00.000","Title":"How to read users gmail after receiving push notification from gmail users.watch 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 trying to get some specific values given a dataframe using pandas and numpy.\nMy process right now is as it follows:\n\nIn[1]: df = pd.read_csv(file)\nIn[2]: a = df[df.columns[1]].values\n\nRight now a has the following shape:\n\nIn[3]: a.shape\nOut[4]: (8640, 1)\n\nWhen I filter it out to get the values that match a given condition I don't get the same shape in the axis 1:\n\nIn[5]: b = a[a>100]\nIn[6]: b.shape\nOut[7]: (3834,)\n\nRight now I'm reshaping the new arrays everytime I filter them, however this is making my code look really messy and uncomfortable: \n\nIn[8]: (b.reshape(b.size,1)).shape\nOut[9]: (3834, 1)\n\nI really need it to have the shape (x, 1) in order to use some other functions, so is it any way of getting that shape everytime I filter out the values without having to reshape it constantly?\nEDIT:\nThe main reason I need to do this reshaping is that I need to get the minimum value in every row for two arrays with the same number of rows. What I use is np.min and np.concatenate.\nFor example:\nav is the mean of 5 different columns in my dataframe:\n\nav = np.mean(myColumns,axis=1)\n\nWhich has shape (8640, )\nmed is the median for the same columns:\n\nmed = np.median(myColumns,axis=1)\n\nAnd when I try to get the minimum values I have the next error:\n\nnp.min(np.concatenate((av,med),axis=1),axis=1) Traceback (most recent\n  call last):\nFile \"\", line 1, in \n      np.min(np.concatenate((av,med),axis=1),axis=1)\nAxisError: axis 1 is out of bounds for array of dimension 1\n\nHowever, if I reshape av and med it works fine:\n\nnp.min(np.concatenate((av.reshape(av.size,1),med.reshape(av.size,1)),axis=1),axis=1)\n  Out[232]: array([0., 0., 0., ..., 0., 0., 0.])","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":385,"Q_Id":60526861,"Users Score":0,"Answer":"you can use np.take(a, np.where(a>100)[0], axis=0) for keeping the same shape as original","Q_Score":0,"Tags":"python,pandas,numpy","A_Id":60527161,"CreationDate":"2020-03-04T13:09:00.000","Title":"Filtering data in arrays and keeping the same shape in axis 1","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently have an Anaconda distribution of Python 3.6.8 running on a windows 10 machine.\nMy projects reside in conda virtual environments and each have their own requirements.txt to specify\npackages and versions. I wish to achieve better dependency resolution by utilizing pipfile and pipfile.loc\nwhich is made possible by pipenv. Is it possible to combine conda and pipenv to achieve this?\nAnd is this the best or recommended way to resolve package versioning dependencies?\nBut is it the best solution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1603,"Q_Id":60528774,"Users Score":2,"Answer":"It's subjective. I have Anaconda, but only out of necessity. I find that it is unreliable at times. I use virtualenv for my projects and I have never had an issue with them. They are reliable and I haven't seen a need to jump ship for a fad.\nMy advise is to experiment, but if you need something to work reliably, virtualenv is a strong contender. The old adage comes to mind, if it ain't broke, don't fix it.","Q_Score":0,"Tags":"python,anaconda,conda,dependency-management,pipenv","A_Id":60529192,"CreationDate":"2020-03-04T14:53:00.000","Title":"Using pipenv with conda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering how the threads are executed on hardware level, like a process would run on a single processing core and make a context switch on the processor and the MMU in order to switch between processes. How do threads switch? Secondly when we create\/spawn a new thread will it be seen as a new process would for the processor and be scheduled as a process would?\nAlso when should one use threads and when a new process?\nI know I probably am sounding dumb right now, that's because I have massive gaps in my knowledge that I would like fill. Thanks in advance for taking the time and explaining things to me. :)","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":142,"Q_Id":60529511,"Users Score":1,"Answer":"Think of it this way:  \"a thread is part of a process.\"\nA \"process\" owns resources such as memory, open file-handles and network ports, and so on.  All of these resources are then available to every \"thread\" which the process owns.  (By definition, every \"process\" always contains at least one (\"main\") \"thread.\")\nCPUs and cores, then, execute these \"threads,\" in the context of the \"process\" which they belong to.\nOn a multi-CPU\/multi-core system, it is therefore possible that more than one thread belonging to a particular process really is executing in parallel.  Although you can never be sure.\nAlso:  in the context of an interpreter-based programming language system like Python, the actual situation is a little bit more complicated \"behind the scenes,\" because the Python interpreter context does exist and will be seen by all of the Python threads.  This does add a slight amount of additional overhead so that it all \"just works.\"","Q_Score":0,"Tags":"python,multithreading,multiprocessing","A_Id":60529738,"CreationDate":"2020-03-04T15:31:00.000","Title":"How are threads different from process in terms of how they are executed on hardware level?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering how the threads are executed on hardware level, like a process would run on a single processing core and make a context switch on the processor and the MMU in order to switch between processes. How do threads switch? Secondly when we create\/spawn a new thread will it be seen as a new process would for the processor and be scheduled as a process would?\nAlso when should one use threads and when a new process?\nI know I probably am sounding dumb right now, that's because I have massive gaps in my knowledge that I would like fill. Thanks in advance for taking the time and explaining things to me. :)","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":142,"Q_Id":60529511,"Users Score":2,"Answer":"There are a few different methods for concurrency. The threading module creates threads within the same Python process and switches between them, this means they're not really running at the same time. The same happens with the Asyncio module, however this has the additional feature of setting when a thread can be switched. \nThen there is the multiprocessing module which creates a separate Python process per thread. This means that the threads will not have access to shared memory but can mean that the processes run on different CPU cores and therefore can provide a performance improvement for CPU bound tasks. \nRegarding when to use new threads a good rule of thumb would be:\n\nFor I\/O bound problems, use threading or async I\/O. This is because you're waiting on responses from something external, like a database or browser, and this waiting time can instead be filled by another thread running it's task. \nFor CPU bound problems use multiprocessing. This can run multiple Python processes on separate cores at the same time. \n\nDisclaimer: Threading is not always a solution and you should first determine whether it is necessary and then look to implement the solution.","Q_Score":0,"Tags":"python,multithreading,multiprocessing","A_Id":60530223,"CreationDate":"2020-03-04T15:31:00.000","Title":"How are threads different from process in terms of how they are executed on hardware level?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been tasked with creating a (python) script that will disable a feature in our source code. The code is generated via third party configure software, through which a gui allows changes in settings to disable this feature. These changes take effort, and time to generate, hence the script. \nTheoretically, there are a bunch of flags in the header files (i.e #define thisFeature STD_ON) which I can flip easily with the script. \nThe part that is more difficult is changes in the source files, for which some functions are added\/removed by the third party configuring software. These may change in the future, so I need to think of a solution that will remain usable. I cannot change the code for the third party application, as I need  to avoid the generation process which takes time. I need to make changes so that when we build the product, the required changes are made and compile. Any suggestions would be great.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":60529668,"Users Score":0,"Answer":"You will either introduce assumptions, which turn into future errors when they fail, or end up reimplemeting the AUTOSAR generator. Their point is to allow a implementation of a configured system under complete control of the supplier of the combination of the static code and the generated code.  \nEither way, when you need an update of the supplied component you will have much more trouble than when using what is delivered.\nSo I am afraid the answer is \"There is none.\" (i.e. no alternative).\nYou can make assumptions on your system and create something which within those assumptions achieves your goal short term.\nBut long term, whoever decided on using AUTOSAR in your project did that for the reasons which fail when you go around the official generator.\nSo in sooner or maybe later, the effort you spend now is lost and might finally cause more damage than the benefits you might harvest short term.","Q_Score":1,"Tags":"python,c,embedded,autosar","A_Id":60530012,"CreationDate":"2020-03-04T15:41:00.000","Title":"Another approach to making changes in C source code with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement Classification algorithm for Iris Dataset (Downloaded from Kaggle). In the Species column the classes (Iris-setosa, Iris-versicolor , Iris-virginica) are in sorted order. How can I stratify the train and test data using Scikit-Learn?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":1171,"Q_Id":60530673,"Users Score":-1,"Answer":"use sklearn.model_selection.train_test_split and play around with Shuffle parameter.\nshuffle: boolean, optional (default=True)\nWhether or not to shuffle the data before splitting. If shuffle=False then stratify must be None.","Q_Score":1,"Tags":"python,pandas,machine-learning,scikit-learn,multiclass-classification","A_Id":60530952,"CreationDate":"2020-03-04T16:32:00.000","Title":"How to stratify the training and testing data in Scikit-Learn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a Python project for school, and am using the Tkinter canvas object as the main interface, because of the visuals. I desperately need a way to hide an object on the canvas, and am not sure how.\nI know this is probably a dumb question, but I really need an answer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":466,"Q_Id":60531841,"Users Score":1,"Answer":"To hide a canvas object, you can use canvas.itemconfig(item, state='hidden') where item is the item ID returned by canvas.create_xxxx(...).\nTo show the hidden item, use canvas.itemconfig(item, state='normal').","Q_Score":0,"Tags":"python,tkinter,tkinter-canvas","A_Id":60532072,"CreationDate":"2020-03-04T17:44:00.000","Title":"How do you hide an image on a Tkinter canvas?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have trained my CNN in Tensorflow using MNIST data set; when I tested it, it worked very well using the test data. Even, to prove my model in a better way, I made another set taking images from train and test set randomly. All the images that I took from those set, at the same time, I deleted and I didn't give them to my model. It worked very well too, but with a dowloaded image from Google, it doesn't classify well, so my question is: should I have to apply any filter to that image before I give it to the prediction part? \nI resized the image and converted it to gray scale before.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":60532922,"Users Score":0,"Answer":"MNIST is an easy dataset. Your model (CNN) structure may do quite well for MNIST, but there is no guarantee that it does well for more complex images too. You can add some more layers and check different activation functions (like Relu, Elu, etc.). Normalizing your image pixel values for small values like between -1 and 1 may help too.","Q_Score":0,"Tags":"python,tensorflow","A_Id":60533907,"CreationDate":"2020-03-04T18:55:00.000","Title":"How do I have to process an image to test it in a CNN?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am curious about the difference in functionality between \"Restart and Run all\", under Kernel, and \"Run all\" under 'cell'. \nI feel less comfortable with the \"restart\" aspect and it is more time consuming since Jupyter asks for confirmation. \nIs there any practical difference? Any reason to chose one over the other?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":552,"Q_Id":60533312,"Users Score":0,"Answer":"A notebook kernel is a computational engine that executes the code contained in a notebook. The kernel consumes significant CPU and RAM. I think the difference is that the RAM is not release until the kernel is restarted by 'Restart and run' command under kernel.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":60533563,"CreationDate":"2020-03-04T19:22:00.000","Title":"Difference between \"Restart & Run All\" and \"Run All\" in Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am curious about the difference in functionality between \"Restart and Run all\", under Kernel, and \"Run all\" under 'cell'. \nI feel less comfortable with the \"restart\" aspect and it is more time consuming since Jupyter asks for confirmation. \nIs there any practical difference? Any reason to chose one over the other?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":552,"Q_Id":60533312,"Users Score":2,"Answer":"Restart pertains mainly to the kernel - restarting it will mean you lose any variables in memory and any imports you've done. In some scenarios, you may not need to restart, or it may be undesirable, for example if you are loading a large dataset.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":60533350,"CreationDate":"2020-03-04T19:22:00.000","Title":"Difference between \"Restart & Run All\" and \"Run All\" in Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am curious about the difference in functionality between \"Restart and Run all\", under Kernel, and \"Run all\" under 'cell'. \nI feel less comfortable with the \"restart\" aspect and it is more time consuming since Jupyter asks for confirmation. \nIs there any practical difference? Any reason to chose one over the other?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":552,"Q_Id":60533312,"Users Score":0,"Answer":"\"Restart and Run all\" will restart the kernel, that means that you will lose all the variables and computations you have in your memory and after that It'll run all cells. \"Run All\" will run all cells with all existing variables in memory.\nYou use \"Restart and Run all\" can be useful is some cases, for example, when you need to import again a library because you updated. Sometimes, It's  good to be sure that your code can run entirely without problems, because it's possible that you have defined variables in your environment, that You don't need anymore, but affect your program.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":60533453,"CreationDate":"2020-03-04T19:22:00.000","Title":"Difference between \"Restart & Run All\" and \"Run All\" in Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using sets in python, I want to add many items to my set, some of which probably already exist in that set.\nIs it faster to add items to a set without checking if it's already there, or is it faster to check if each item exists in the set already and only add if it isn't there?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1405,"Q_Id":60534604,"Users Score":1,"Answer":"It's faster to add without checking. Every time you add an item to a set it needs to check that the item isn't there - Checking before is not saving you any time if the item is there, but it is wasting time if it isn't there as it will be checked twice.","Q_Score":1,"Tags":"python,duplicates,set","A_Id":60534676,"CreationDate":"2020-03-04T20:59:00.000","Title":"Add duplicates to a set or check if the elements exists then add","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had a small question, I have 3 of the same dataset, but one has been filtered assuming 10% outlier fraction, then 15% then 20%. I need to compare the mean squared error for each. I was thinking of building the same keras model 3 times in the same script, and run each individiually. I wanted to do so because I wanted to produce a graph at the end with epochs number on the x-axis, and the mse values of each dataset on y-axis, all in the same figure. is that possible?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":31,"Q_Id":60538166,"Users Score":3,"Answer":"Yes, this is absolutely possible, just name your models accordingly i.e. instead of model.fit() use model_1.fit() for dataset 1, model_2.fit() for dataset 2 etc","Q_Score":0,"Tags":"python,keras","A_Id":60538314,"CreationDate":"2020-03-05T04:21:00.000","Title":"Can i build three keras models in same script?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm training an LSTM model on GPU using Tensorflow Keras. Before training starts when calling model.fit() it takes about 30 minutes to start training process. I think in this period its preparing data using one core of CPU. Am I correct? and if yes how can I parallelize this data preparation process, using multiple cores?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":140,"Q_Id":60539413,"Users Score":3,"Answer":"If you use tf.data.Dataset() for preparing your data, you can exploit  some parameters while preparing the dataset.\n\nFor example, in your .map() function, set the num_parallel_calls parameter to num_parallel_calls=tf.data.experimental.AUTOTUNE; in this way it will allow your program to automatically choose the number of CPU cores for the dataset preparation.\nThe speed can also be improved if you use the .batch().shuffle()\nin this order, rather than shuffle().batch() in this order. In the first situation, you take a batch of your dataset and shuffle the elements inside it; in the second case, you batch() on your dataset after the entire dataset is shuffled. One can easily see that shuffling an enormous dataset would lead to much more time spent rather than batching and shuffling in this order. \nLet us see another case(related to the actual training process)(not your case as the dataset preparation is\nvery time-consuming in your situation): the prefetch() operation.\nIn this case, the GPU is not idling while waiting for the CPU to\nfetch another batch of data. Practically, when the backpropagation\nhas finished updating the weights after a batch, the GPU immediately\nconsumes another batch of data. For simplicity purposes, also set its value to tf.data.experimental.AUTOTUNE.","Q_Score":0,"Tags":"python-3.x,tensorflow,keras,training-data,tensorflow2.x","A_Id":60539743,"CreationDate":"2020-03-05T06:32:00.000","Title":"Parallelize data preparation with tensorflow and keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I converted a python script to an exe using pyinstaller. I want to know how I can change the icon it gave me to the default icon. In case you don't know what I mean, look at C:\\Windows\\System32\\alg.exe. There are many more files with that icon, but that is one of them. Sorry if this is the wrong place to ask this, and let me know if you have any questions","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":516,"Q_Id":60540092,"Users Score":-1,"Answer":"I would suggest to use auto-py-to-exe module for conversion of python script to exe. At first install using command pip install auto-py-to-exe after that run it through python command line just by typing auto-py-to-exe, you'll get an window where you'll get the icon option.\nPlease vote if you find your solution.","Q_Score":0,"Tags":"python,exe,pyinstaller","A_Id":60540688,"CreationDate":"2020-03-05T07:24:00.000","Title":"How can I replace an EXE's icon to the \"default\" icon?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I converted a python script to an exe using pyinstaller. I want to know how I can change the icon it gave me to the default icon. In case you don't know what I mean, look at C:\\Windows\\System32\\alg.exe. There are many more files with that icon, but that is one of them. Sorry if this is the wrong place to ask this, and let me know if you have any questions","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":516,"Q_Id":60540092,"Users Score":0,"Answer":"You'll need to extract the icon from the exe, and set that as the icon file with pyinstaller -i extracted.ico myscript.py. You can extract the icon with tools available online or you can use pywin32 to extract the icons.","Q_Score":0,"Tags":"python,exe,pyinstaller","A_Id":60555543,"CreationDate":"2020-03-05T07:24:00.000","Title":"How can I replace an EXE's icon to the \"default\" icon?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using CentOS 8. I'm trying to install Python 3. Command: sudo dnf install python3. Error:\n\nFailed to synchronize cache for repo 'BaseOS'\n\nHow can I fix this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3438,"Q_Id":60540892,"Users Score":0,"Answer":"Change the baseurl from mirror.centos.org to vault.centos.org in the appropriate repo file here:\n\/etc\/yum.repos.d\/","Q_Score":1,"Tags":"python,linux,centos","A_Id":71877953,"CreationDate":"2020-03-05T08:20:00.000","Title":"Install Python 3 on Centos 8 returns \"Failed to synchronize cache for repo 'BaseOS'\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Our IDs look something like this \"CS0000001\" which stands for Customer with the ID 1. Is this possible to to with SQL and Auto Increment or do i need to to that in my GUI ?\nI need the leading zeroes but with auto incrementing to prevent double usage if am constructing the ID in Python and Insert them into the DB.\nIs that possible?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":705,"Q_Id":60541482,"Users Score":1,"Answer":"You have few choices:\n\nConstruct the CustomerID in your code which inserts the data into\nthe Customer table (=application side, requires change in your code)\nCreate a view on top of the Customer-table that contains the logic\nand use that when you need the CustomerID (=database side, requires change in your code)\nUse a procedure to do the inserts and construct the CustomerID in\nthe procedure (=database side, requires change in your code)","Q_Score":0,"Tags":"python,mysql,sql,python-3.x","A_Id":60542261,"CreationDate":"2020-03-05T08:58:00.000","Title":"SQL - Possible to Auto Increment Number but with leading zeros?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have every library installed using pip;\nwhen I write the code, IDE doesn't show any errors; but when I want to run the code, IDE has ImportError for every function;\nI think The Problem is sth about my terminal, but I'm not Really Sure.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":60546747,"Users Score":0,"Answer":"Go to the \"terminal\"(for PyCharm)\/\"console\"(for Spyder) of the IDE you are using, and install the packages using pip in that terminal, it should work!\nProblem is the packages you have installed using pip is not being mapped to the IDE","Q_Score":0,"Tags":"python,terminal,pip,ide,importerror","A_Id":60546824,"CreationDate":"2020-03-05T13:43:00.000","Title":"I can't run any project using libraries?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use RUN conda install -c conda-forge tesseract in my dockerfile to install the tesseract-ocr package.  All my other conda install packages have worked fine using that method.  I've looked at the GIT for tesseractocr https:\/\/github.com\/sirfz\/tesserocr\/blob\/master\/Dockerfile and it seems that the references they have in their docker example are out of date since the links to some of the dependencies return 'not found'. \nMy base image is continuumio\/anaconda3\nHow can I get this library to install in this docker container?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":334,"Q_Id":60547269,"Users Score":0,"Answer":"Just wanted to close this out.  I used conda install -y -c conda-forge tesseract\nwith the -y being the operative function that allowed the process to complete.","Q_Score":0,"Tags":"python,docker,tesseract,anaconda3","A_Id":60554895,"CreationDate":"2020-03-05T14:10:00.000","Title":"I can't Conda install Tesseract in a continuumio\/anaconda3 Docker container","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Context\nHey I am developing an android app that can detect objects of 5 classes. I used SSD mobilenet architecture for transfer learning to train the model on my own dataset. In the python code I was able to generate the inference quite well but when it came to integrating the model with app, everything went to hell and I failed miserably.\nStrategy\nSo in order to use the model, I came up with an idea to host the model on a cloud server and whenever I take an image from android app camera, It sends the image to the cloud, performs the inference and returns the result back to android app.\nResearch done so far...\nSo far I have researched about REST APIs, specifically Retrofit which help communication b\/w client and server using HTTP protocol. Its CRUD architecture and the GET, POST, PUT and DELETE methods.\nMain Question\nSo before I get lost and fail miserably again like I did with trying to integrate tflite with android, I need a solid answer that if it is even possible, and if it is guide me in the right direction so that I don't get stuck again. basically I just need to understand the steps involved in this approach.\nYour help will be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":38,"Q_Id":60550098,"Users Score":1,"Answer":"Having a cloud endpoint to take a picture from your android app as input and give back inference results to the phone is what you are looking for. Amazon and Google cloud solutions let you run inference for each api call you make and they charge you for each api call.","Q_Score":0,"Tags":"python,android,cloud,retrofit,object-detection","A_Id":60586858,"CreationDate":"2020-03-05T16:35:00.000","Title":"Is it possible to host an object detection model on cloud, generate inference and retrieve results back to Android app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am moving common functions shared between a couple of Python files in to a third common_commands.py file. To test the functions I imported a couple of functions using:\nfrom common_commands import func_one, func_two\nBut got this error:\nImportError: cannot import name 'func_two'\nSo I tried only importing func_one and that worked fine but then importing just func_two gives me the same error again! Why?! And to make things even confusing, the exact same import line from above works perfectly fine when I put it in the scripts I am refactoring.\nWhat is causing this odd behavior?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":60550214,"Users Score":1,"Answer":"TL;DR:\nI had renamed func_twosince starting my interactive shell. Starting a new shell got things working.\nWhat I learned:\nI don't understand all the inner workings of the interactive shell and what happens when you call import, but after quitting and starting a new shell the exact same import call worked.\nWhen I started the shell func_two was old_func_two but then I decided to rename it, and then I tried to import it with the new name, and that failed. After scratching my head and doing some google foo I found nothing that helped in my case and tried starting a new shell and it worked!\nSo I decided to do a little more experimenting before asking this question and learned that I could rename the function as much as I wanted after starting the shell but only until I first imported the file in some way.\nThat is to say, as soon as I called from common_commands import func_one I can no longer rename any functions and import them with the new name, since the file has already been imported. I can, however, still import old_func_two. I also tried changing the 'guts' of func_two after importing it and then importing it again and it kept the original behavior. So from what I can tell, the first time you import a file (not a function or class, but the whole file) it is cached and all future imports are run on the cached version, not the real file on disk.\nSo, even if you only import func_one i.e. from common_commands import func_one and then rename or change func_two and then import it, you'll have to use the original name of func_two and you'll get the original functionality as well, even though you didn't explicitly import it earlier.","Q_Score":0,"Tags":"python,python-import,python-interactive","A_Id":60550352,"CreationDate":"2020-03-05T16:41:00.000","Title":"Why does 'from file import function_name' fail in my interactive Python session but works in a script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write to an SQS Queue that I create in the same SAM template as my lambda. To send a message to the queue I need the URL. \nclient.send_message(QueueUrl='string', MessageBody='string', ...)\nI can get the URL if I have the name of the queue (client.get_queue_url(QueueName='string', QueueOwnerAWSAccountId='string')), but this is randomly generated when deployed by SAM. For a Function you can specify FunctionName in the template.yaml, but I haven't found an example of this for a Queue. \nI know that in the template.yaml I can use !Ref MyQueue but I don't know of an equivalent to use in the lambda. I assume there is a trick, I just don't know that trick :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":310,"Q_Id":60550330,"Users Score":1,"Answer":"You can pass in the queue URL as an environment variable to the lambda. That allows you use the !Ref MyQueue in the template to reference the queue. Just add that to the Environment -> Variables section of the lambda configuration.","Q_Score":1,"Tags":"python,aws-lambda,aws-serverless","A_Id":60551023,"CreationDate":"2020-03-05T16:48:00.000","Title":"How to reference an AWS resource created via SAM in a Lambda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Whats the difference between two LSTM models A and B that are trained on same data, but the batches are shuffled randomly for each epoch, that A has 14 steps per epoch and B has 132 steps per epoch?\nWhich one will perform better in validation?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1345,"Q_Id":60553285,"Users Score":0,"Answer":"An epoch consists of going through all your training samples once. And one step\/iteration refers to training over a single minibatch. So if you have 1,000,000 training samples and use a batch size of 100, one epoch will be equivalent to 10,000 steps, with 100 samples per step.\nA high-level neural network framework may let you set either the number of epochs or total number of training steps. But you can't set them both since one directly determines the value of the other.\nEffect of Batch Size on Model Behavior: Small batch results generally in rapid learning but a volatile learning process with higher variance. Larger batch sizes slow down the learning process but the final stages result in a convergence to a more stable model exemplified by lower variance.","Q_Score":1,"Tags":"python,tensorflow,machine-learning,keras,deep-learning","A_Id":60565279,"CreationDate":"2020-03-05T20:15:00.000","Title":"Importance of number of steps in an epoch for LSTM model training in Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to calculate a simple linear regression where I need to force a particular value for one point. Namely, I have x and y arrays, and I want my regression f(x) to force f(x[-1]) == y[-1] - that is, the prediction over the last element of x should be equal to the last element of y.\nIs there a way to do it using Python and scikit-learn?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1297,"Q_Id":60553680,"Users Score":2,"Answer":"Here's a slightly roundabout trick that will do it.\nTry re-centering your data, i.e. subtract x[-1], y[-1] from all datapoints so that x[-1], y[-1] is now the origin.\nNow fit your data using sklearn.linear_model.LinearRegression with fit_intercept set to False. This way, the data is fit so that the line is forced to pass through the origin. Because we've re-centered the data, the origin corresponds to x[-1], y[-1].\nWhen you use the model to make predictions, subtract x[-1] from any datapoint for which you are making a prediction, then add y[-1] to the resulting prediction, and this will give you the same results as forcing your model to pass through x[-1], y[-1].\nThis is a little roundabout but it's the simplest way that occurs to me to do it using the sklearn linear regression function (without writing your own).","Q_Score":0,"Tags":"python,scikit-learn,conditional-statements,regression","A_Id":60553912,"CreationDate":"2020-03-05T20:45:00.000","Title":"Linear regression forcing one specific value","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to develop a windows gui app with python and i will distribute that later. I don't know how to set the app for some future releasing updates or bug fix from a server\/remotely. How can I handle this problem? Can I add some auto-update future to app? What should write for that in my code and what framework or library should I use? \nDo pyinstaller\/ inno setup have some futures for this?\nThanks for your help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":637,"Q_Id":60554861,"Users Score":1,"Answer":"How about this approach:\n\nYou can use a version control service like github to version control your code. \nThen checkout the repository on your windows machine. \nWrite a batch\/bash script to checkout the latest version of your code and restart the app. \nThen use the Windows task scheduler to periodically run this script.","Q_Score":1,"Tags":"python,server,remote-access,auto-update","A_Id":60555326,"CreationDate":"2020-03-05T22:26:00.000","Title":"How to update python script\/application remotely","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a AWS lambda function running some code and then saving a json to a s3 bucket.\nCurrently, my formatting is using the datetime package to grab the current date.\nnow = str(datetime.today())\nI am then formatting the csv to \n'payrollcompensation_streams\/{}_{}.json'.format('pega_payrollcompensation_raw',now))\nWhat I want to do is everytime this AWS Lambda function runs generate an unique key of an integer instead of a datetime.\nInstead of this: pega_payrollcompensation_raw_2020-03-05 00:00:00.0000\nThis: pega_payrollcompensation_raw_1\nThen the next time\npega_payrollcompensation_raw_2","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":178,"Q_Id":60554992,"Users Score":1,"Answer":"In case of using Lambda for this task you need to save state somewhere. Best fit for your case is DynamoDB. You need to set some sort of counter there and receive value from counter  first. Be careful with concurrency.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda","A_Id":60555255,"CreationDate":"2020-03-05T22:38:00.000","Title":"AWS Lambda: Unique Key generator for s3 files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I go to Settings>Project: Python Projects>Project Interpreter and click in Install but Cufflinks is not listed. (I use Anaconda Interpreter)\nI already used \npip install cufflinks\nconda install -c conda-forge cufflinks-py\nconda install -c conda-forge\/label\/gcc7 cufflinks-py\nconda install -c conda-forge\/label\/cf201901 cufflinks-py\nbut none works when I import the package in Pycharm.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":533,"Q_Id":60555669,"Users Score":0,"Answer":"The solution is simple.\nYou need to go to File>Settings>Project: Python Projects>Project Interpreter and click on Settings>Add...\nAfter that, you will choose Virtualenv, System Interpreter or Pipenv and then choose the interpreter that is already installed on your computer. \nIn my case, I changed to one System Interpreter (C:\\Users\\'USER'\\AppData\\Local\\Programs\\Python\\Python37-32\\python.exe)\nIf you never used this interpreter you will need re-install your packages.","Q_Score":1,"Tags":"python,pycharm,anaconda,conda,cufflinks","A_Id":60562837,"CreationDate":"2020-03-05T23:56:00.000","Title":"How can I install Cufflinks in Pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing python using jupyter notebook and I have two cells that can influence each other.\nI'm wondering is it possible to leave some certain cells out after I click Restart & Run All so that I can test the two cells independently?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":401,"Q_Id":60556163,"Users Score":1,"Answer":"If you put those two cells at the end of the page, you can run all cells above a certain cell with a single click.\nThat or you can put a triple-quote at the beginning and end of the two cells, then un-quote the cells to test them.","Q_Score":1,"Tags":"python,jupyter-notebook","A_Id":60556197,"CreationDate":"2020-03-06T01:03:00.000","Title":"Jupyter notebook: how to leave one cell out while 'run all'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Word2vec model to extract similar words, but I want to know if it is possible to get words while using unseen words for input. \nFor example, I have a model trained with a corpus [melon, vehicle, giraffe, apple, frog, banana]. \"orange\" is unseen word in this corpus, but when I put it as input, I want [melon, apple, banana] for result. \nIs this a possible situation?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":208,"Q_Id":60556328,"Users Score":2,"Answer":"The original word2vec algorithm can offer nothing for words that weren't in its training data.\nFacebook's 'FastText' descendent of the word2vec algorithm can offer better-than-random vectors for unseen words \u2013 but it builds such vectors from word fragments (character n-gram vectors), so it does best where shared word roots exist, or where the out-of-vocabulary word is just a typo of a trained word.\nThat is, it won't help in your example, if no other words morphologically similar to 'orange' (like 'orangey', 'orangade', 'orangish', etc) were present. \nThe only way to learn or guess a vector for 'orange' is to have some training examples with it or related words. (If all else failed, you could scrape some examples from other large corpora or the web to mix with your other training data.)","Q_Score":0,"Tags":"python,word2vec","A_Id":60556657,"CreationDate":"2020-03-06T01:25:00.000","Title":"While using Word2vec, how can I get a result from unseen words corpus?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pytesseract is not recognized. I have tried all fixes documented online, including adding Tesseract-OCR to my Path variables, incorporating the pytesseract.pytesseract.tesseract_cmd = r'C:\\Program Files\\Tesseract-OCR\\tesseract.exe' command path in my script, uninstalling and reinstalling pytesseract and tesseract.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4258,"Q_Id":60556661,"Users Score":0,"Answer":"In the line 23 \n    vpnbookpassword = pytesseract.image_to_string(pwdi)\nthere you have mentioned pytesseract.image_to_string but you have imported image_to_string \nfrom pytesseract import image_to_string and not pytesseract so it could not find pytesseract.\nSo writing it as vpnbookpassword = image_to_string(pwdi) would solve the issue","Q_Score":2,"Tags":"python-3.x,path,tesseract,python-tesseract,pytesser","A_Id":60562319,"CreationDate":"2020-03-06T02:16:00.000","Title":"NameError: name 'pytesseract' is not defined","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a little tough time importing the xmltodict module into my visual studio code. \nI setup the module in my windows using pip. it should be working on my visual studio as per the guidelines and relevant posts I found here. \nbut for some reasons it isn't working in the visual studio. \nPlease advise on how can I get the xmltodict module installed or imported on visual studio code \nThanks in Advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":425,"Q_Id":60557938,"Users Score":0,"Answer":"I had the same issue and it turned out that it wasn't installed in that virtual environment even though that was what I had done. Try:\nvenv\/Scripts\/python.exe -m pip install xmltodict","Q_Score":0,"Tags":"python,windows,visual-studio,xmltodict","A_Id":60617030,"CreationDate":"2020-03-06T05:12:00.000","Title":"import xmltodict module into visual studio code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new with python and Django. I know a lot about the Codeigniter framework and there if you want to create a project like an eCommerce you must create an admin panel with template and function for the backend. when I was creating backend I was adding functions for the admin panel where all functions were for adding some informations in the database. so when I start with Django I saw that there was an integrated admin panel which can be modified but I have a question can I create app for Django which will be admin panel of my project","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":60558267,"Users Score":0,"Answer":"Yes, definitely man. Django provides its own admin panel and it is really very helpful, you can customize it also as per yours need.\nBut if you want to make your own admin panel then you can do it. You can create a separate app for that. And then you have to manage templates as per your admin panel design and apply all functionality in views.py. And all URLs which will be used for the admin panel, should be mentioned in urls.py.","Q_Score":0,"Tags":"python,django,python-3.x,django-admin,django-3.0","A_Id":60558403,"CreationDate":"2020-03-06T05:48:00.000","Title":"please give me advice with django admin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to make four drop down button(like country state city and location)each field we want to make it based on the selection like when country select its state related to country we get and when state is s selected then city related to these state gets populated when city get slelected then its loctation related to these city we get","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":60558402,"Users Score":0,"Answer":"One of approach you can take is :\n\nUser go to page\nBack End get the list of country and pass it to front end\nUser select 1 country from drop-down\nFront end java-script use ajax call to pass country to back-end and get all states\nFront end show all states in second drop-down\nUser select 1 state from drop-down \nFront end java-script use ajax call to pass state to back-end and get all district\nFront end show all district in third drop-down\n\nbut this kind of slow, so choose wisly","Q_Score":0,"Tags":"python,django,dropdown","A_Id":60558638,"CreationDate":"2020-03-06T06:02:00.000","Title":"delendent dropdown in django(DJango,Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i have one AWS Batch-Job which is working fine, the scenario is when we want to run the Job we are submitting Batch-Job using python BOTO3 SDK.\nNow I want to schedule the Batch-Job in which I can specify the time and it needs to submit Batch-Job on the specified time. I'm using cloud watch right now but, I want to specify some parameters while submitting the Batch-Job. \nAny one have idea about any AWS service where i can make schedule event with some parameter and it need to submit Batch-Job with those parameter as a environment variable.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":173,"Q_Id":60558674,"Users Score":0,"Answer":"You could use a Lambda function. You can set up a Lambda function on a schedule, and it can use boto3 to submit a Batch job with the necessary parameters.","Q_Score":0,"Tags":"python-2.7,amazon-web-services,amazon-cloudwatch,aws-batch","A_Id":61377131,"CreationDate":"2020-03-06T06:29:00.000","Title":"AWS Schedule Batch-Job via Boto3 SDK with pass some environment variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I couldn't install Scrapy on my system after I upgraded pip to 20.0.2.\nAnd what file do I have to install manually in order to make it work?\nPlease help me out.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":471,"Q_Id":60559095,"Users Score":1,"Answer":"sudo apt-get install python3 python3-dev python3-pip libxml2-dev libxslt1-dev zlib1g-dev libffi-dev libssl-dev","Q_Score":1,"Tags":"python,git,scrapy","A_Id":60562015,"CreationDate":"2020-03-06T07:05:00.000","Title":"Failed building wheel for cryptography. Could not build wheels for cryptography which use PEP 517 and cannot be installed directly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to solve a problem with SVM and my X_train features are 2D with shapes of (256,1).\nIs there any way to train a SVM model on a dataset with such features?\nThese features are histograms of gray-scale images.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":125,"Q_Id":60561895,"Users Score":1,"Answer":"Yes, its possible to train a SVM with histograms of gray-scale images but you need to transform them into representations with numerical values.\nI would suggest to reshape the 2D array into a 1D array\/list with 256 entries, so that the SVM can use it as a feature vector with 256 different numerical features, each representing a value of your histogram.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,histogram,svm","A_Id":60565738,"CreationDate":"2020-03-06T10:13:00.000","Title":"Does Support Vector Machine takes vectors as features?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to open a python file in cmder terminal quickly. Currently, the fastest way i know how is to navigate to the directory of the python file in cmder terminal and then run it by calling \"python file.py\". This is slow and cumbersome. Is there a way for me to have a file or exe, that, when i run it (or drag the program onto it), automatically makes the program run in cmder straight away.\nWindows 10\nClarification: I'm using cmder terminal specifically because it supports text coloring. Windows terminal and powershell do not support this.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1398,"Q_Id":60562184,"Users Score":0,"Answer":"Answer: The escape codes just weren't properly configured for the windows terminals. You can get around this by using colorama's colorama.init(). It should work after that.","Q_Score":1,"Tags":"python","A_Id":61590232,"CreationDate":"2020-03-06T10:30:00.000","Title":"How to open a python file in Cmder Terminal Quicker?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to open a python file in cmder terminal quickly. Currently, the fastest way i know how is to navigate to the directory of the python file in cmder terminal and then run it by calling \"python file.py\". This is slow and cumbersome. Is there a way for me to have a file or exe, that, when i run it (or drag the program onto it), automatically makes the program run in cmder straight away.\nWindows 10\nClarification: I'm using cmder terminal specifically because it supports text coloring. Windows terminal and powershell do not support this.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1398,"Q_Id":60562184,"Users Score":0,"Answer":"On windows you can go to the directory with the file in the explorer and then simply hold shift as you right click at the same time. This will open the menu and there you will have the option to use the command shell\/powershell and then you don't have to navigate to the directory inside the shell anymore and can just execute the python file.\nI hope that helps.","Q_Score":1,"Tags":"python","A_Id":60562358,"CreationDate":"2020-03-06T10:30:00.000","Title":"How to open a python file in Cmder Terminal Quicker?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am looking for a way, to invoke simple python one-liners directly from Windows cmd without the need to store a .py file somewhere.\nSomething like\npython print('Test').\nIs this possible?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":57,"Q_Id":60562593,"Users Score":-1,"Answer":"you could just type python3 on your cmd and you'll get a sort of python debugger in which you can type and test your code.\nso let's just type, print('Test') and it will execute","Q_Score":1,"Tags":"python,windows,cmd,command-line-interface","A_Id":60562685,"CreationDate":"2020-03-06T10:54:00.000","Title":"Run python command directly on cmd in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"This is what needs to be achieved: we create a driver instance. start two threads\/processes - one will execute the signup (or any other) testcase and the second will execute another testcase (a trigger, change network to slow, or otherwise)","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":605,"Q_Id":60566508,"Users Score":1,"Answer":"I've read that python itself wasn't really built with multi-threading in mind like other languages (although there are packages that claim to do this), so I would lean towards multi-processing. You should be able to pass necessary data to corresponding parts of the code (the different processes) to do what you wish. If you're doing things that involve the same driver in both tests, you may want to consider either not running the tests at the same time (order them), or make two driver instances and pass one to each process (although I've seen some problems trying to do this with the requests package trying to make too many simultaneous connections, this was without multi-processing though). If this is a problem you run into with multi-processing, it would be interesting to see if multi-threading handles this, but you may have to run the tests simultaneously on different machines or VM's if neither provides a solution. Hope this helps","Q_Score":2,"Tags":"java,python,selenium,selenium-webdriver,selenium-chromedriver","A_Id":60566775,"CreationDate":"2020-03-06T14:52:00.000","Title":"If we want to have one driver instance and execute two parallel test cases. What we will use multithreading or multiprocessing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is this: If I were to make a command with a loop (for example \"start\") where it would say something like:\"It has been 3 hours since...\" and it loops for 10800 seconds (3 hours) and then says:\"It has been 6 hours since...\" , so the part where I'm stuck is: If I were to make a command called \"stop\" how would I implement it in the command \"start\" where it would check if the command \"stop\" has been used. If yes the loop is cancelled, if it hasn't been used the loop continues.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":962,"Q_Id":60566712,"Users Score":0,"Answer":"but if you run the command several times or on different servers, one stop command stops them all. Is there not a way to stop just one loop with one command","Q_Score":0,"Tags":"python,discord.py","A_Id":64687007,"CreationDate":"2020-03-06T15:03:00.000","Title":"discord py: canceling a loop using a command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Problem\nI am not able to setup the path variables such that my scripts work by double clicking them in windows 10. I was able to do this perfectly fine until I uninstalled and reinstalled Anaconda (Python 3.7.4). After trouble shooting this issue with many forums and online articles, I am no more closer to the solution. I understand that my user path variables need to be set to locate python and such but that is about it. I have put in all of my path variables in C:\\Users\\name\\Anaconda3 also with the specified folders of \\Scripts, \\envs, \\Lib, \\libs, \\pkgs, etc. \nMy scripts work fine in IDE like Spyder, the scripts are set to open with python.exe in the Anaconda3 folder, the Anaconda shell recognizes python, and I have read all of the other stackoverflow posts about this to no avail.\nAfter clicking the script a terminal opens but closes immediately in which the script is supposed to run and print results in the terminal.\nI ask that someone to (1) please explain to me the important aspects of setting this up so I can understand what is going on and (2) please give me some useful trouble shooting advise to solve this issue. \nThank you\n\nUpdate with my solution\nLooks like the single only important path to specific is:\nC:\\Users\\Killian\\Anaconda3\\Library\\bin\nand now the scripts run by double clicking.\nIf anyone has a good explanation for this to help me and others understand this issue better, that would be great.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":60567397,"Users Score":0,"Answer":"By the sound of it, you have set up everything correctly. You must remember that the terminal will close once it has done executing the commands in your script. It is likely that that is the reason for the terminal closing. Add a line input() to the end of your script to hold the terminal from closing.\nE.g.\nA script with the one line:\nprint('hello world')\nwill cause the terminal to close immediately one the command is executed.\nHowever, the script with two lines:\nprint('hello world')\ninput()\nwill cause the terminal to be held by the input command","Q_Score":0,"Tags":"python,windows,anaconda","A_Id":60568573,"CreationDate":"2020-03-06T15:45:00.000","Title":"Python scripts do not work by double clicking on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to running the appserver with python manage.py runserver with python 3.8.2 and django 3.0.3. I've setup a mysql database connection and inserted my \"myApp.apps.myAppConfig\" into INSTALLED_APPS, declared a couple of database-view based models, a form and a view. Nothing that seems too out of the way for the tutorials i've found. When i run the python manage.py runserver command, this is the output:\n\nWatching for file changes with StatReloader Performing system\n  checks...\nException in thread django-main-thread: Traceback (most recent call\n  last):   File\n  \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\apps\\registry.py\",\n  line 155, in get_app_config\n      return self.app_configs[app_label] KeyError: 'admin'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\threading.py\",\n  line 932, in _bootstrap_inner\n      self.run()   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\threading.py\",\n  line 870, in run\n      self._target(*self._args, **self._kwargs)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\utils\\autoreload.py\",\n  line 53, in wrapper\n      fn(*args, **kwargs)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\core\\management\\commands\\runserver.py\",\n  line 117, in inner_run\n      self.check(display_num_errors=True)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\core\\management\\base.py\",\n  line 392, in check\n      all_issues = self._run_checks(   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\core\\management\\base.py\",\n  line 382, in _run_checks\n      return checks.run_checks(**kwargs)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\core\\checks\\registry.py\",\n  line 72, in run_checks\n      new_errors = check(app_configs=app_configs)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\core\\checks\\urls.py\",\n  line 13, in check_url_config\n      return check_resolver(resolver)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\core\\checks\\urls.py\",\n  line 23, in check_resolver\n      return check_method()   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\urls\\resolvers.py\",\n  line 407, in check\n      for pattern in self.url_patterns:   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\utils\\functional.py\",\n  line 48, in get\n      res = instance.dict[self.name] = self.func(instance)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\urls\\resolvers.py\",\n  line 588, in url_patterns\n      patterns = getattr(self.urlconf_module, \"urlpatterns\", self.urlconf_module)   File\n  \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\utils\\functional.py\",\n  line 48, in get\n      res = instance.dict[self.name] = self.func(instance)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\urls\\resolvers.py\",\n  line 581, in urlconf_module\n      return import_module(self.urlconf_name)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\importlib__init__.py\",\n  line 127, in import_module\n      return _bootstrap._gcd_import(name[level:], package, level)   File \"\", line 1014, in _gcd_import   File\n  \"\", line 991, in _find_and_load   File\n  \"\", line 975, in _find_and_load_unlocked \n  File \"\", line 671, in _load_unlocked\n  File \"\", line 783, in\n  exec_module   File \"\", line 219, in\n  _call_with_frames_removed   File \"C:\\Users\\celli\\Desktop\\Interventi Comuni\\Python\\django-projects\\zabbixPyFace\\zabbixPyFace\\urls.py\", line\n  21, in \n      path('admin\/', admin.site.urls),   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\utils\\functional.py\",\n  line 224, in inner\n      self._setup()   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\contrib\\admin\\sites.py\",\n  line 537, in _setup\n      AdminSiteClass = import_string(apps.get_app_config('admin').default_site)   File\n  \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\apps\\registry.py\",\n  line 162, in get_app_config\n      raise LookupError(message) LookupError: No installed app with label 'admin'.\n\nI tried searching big G for answers but there's many sources that can cause this problem, could any of you gurus provide some insight?\nUpdate:\nI've already checked the INSTALLED_APPS and django.contrib.admin is present: \nINSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # jupyter notebook plugin 'django_extensions', ]","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":8213,"Q_Id":60567760,"Users Score":1,"Answer":"You need to add \"django.contrib.admin\" to your INSTALLED_APPS setting.","Q_Score":0,"Tags":"python,django,python-3.x","A_Id":60567873,"CreationDate":"2020-03-06T16:07:00.000","Title":"Django LookupError: No installed app with label 'admin'","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to running the appserver with python manage.py runserver with python 3.8.2 and django 3.0.3. I've setup a mysql database connection and inserted my \"myApp.apps.myAppConfig\" into INSTALLED_APPS, declared a couple of database-view based models, a form and a view. Nothing that seems too out of the way for the tutorials i've found. When i run the python manage.py runserver command, this is the output:\n\nWatching for file changes with StatReloader Performing system\n  checks...\nException in thread django-main-thread: Traceback (most recent call\n  last):   File\n  \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\apps\\registry.py\",\n  line 155, in get_app_config\n      return self.app_configs[app_label] KeyError: 'admin'\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):   File\n  \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\threading.py\",\n  line 932, in _bootstrap_inner\n      self.run()   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\threading.py\",\n  line 870, in run\n      self._target(*self._args, **self._kwargs)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\utils\\autoreload.py\",\n  line 53, in wrapper\n      fn(*args, **kwargs)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\core\\management\\commands\\runserver.py\",\n  line 117, in inner_run\n      self.check(display_num_errors=True)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\core\\management\\base.py\",\n  line 392, in check\n      all_issues = self._run_checks(   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\core\\management\\base.py\",\n  line 382, in _run_checks\n      return checks.run_checks(**kwargs)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\core\\checks\\registry.py\",\n  line 72, in run_checks\n      new_errors = check(app_configs=app_configs)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\core\\checks\\urls.py\",\n  line 13, in check_url_config\n      return check_resolver(resolver)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\core\\checks\\urls.py\",\n  line 23, in check_resolver\n      return check_method()   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\urls\\resolvers.py\",\n  line 407, in check\n      for pattern in self.url_patterns:   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\utils\\functional.py\",\n  line 48, in get\n      res = instance.dict[self.name] = self.func(instance)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\urls\\resolvers.py\",\n  line 588, in url_patterns\n      patterns = getattr(self.urlconf_module, \"urlpatterns\", self.urlconf_module)   File\n  \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\utils\\functional.py\",\n  line 48, in get\n      res = instance.dict[self.name] = self.func(instance)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\urls\\resolvers.py\",\n  line 581, in urlconf_module\n      return import_module(self.urlconf_name)   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\importlib__init__.py\",\n  line 127, in import_module\n      return _bootstrap._gcd_import(name[level:], package, level)   File \"\", line 1014, in _gcd_import   File\n  \"\", line 991, in _find_and_load   File\n  \"\", line 975, in _find_and_load_unlocked \n  File \"\", line 671, in _load_unlocked\n  File \"\", line 783, in\n  exec_module   File \"\", line 219, in\n  _call_with_frames_removed   File \"C:\\Users\\celli\\Desktop\\Interventi Comuni\\Python\\django-projects\\zabbixPyFace\\zabbixPyFace\\urls.py\", line\n  21, in \n      path('admin\/', admin.site.urls),   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\utils\\functional.py\",\n  line 224, in inner\n      self._setup()   File \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\contrib\\admin\\sites.py\",\n  line 537, in _setup\n      AdminSiteClass = import_string(apps.get_app_config('admin').default_site)   File\n  \"C:\\Users\\celli\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\django\\apps\\registry.py\",\n  line 162, in get_app_config\n      raise LookupError(message) LookupError: No installed app with label 'admin'.\n\nI tried searching big G for answers but there's many sources that can cause this problem, could any of you gurus provide some insight?\nUpdate:\nI've already checked the INSTALLED_APPS and django.contrib.admin is present: \nINSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # jupyter notebook plugin 'django_extensions', ]","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":8213,"Q_Id":60567760,"Users Score":3,"Answer":"Answering my own question, searching the net for informations regarding this error leads to many ambigous results, since this error seems to be fired even if the root cause was of another nature. In my case i forgot to apply the python manage.py makemigrations directive.","Q_Score":0,"Tags":"python,django,python-3.x","A_Id":60576410,"CreationDate":"2020-03-06T16:07:00.000","Title":"Django LookupError: No installed app with label 'admin'","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a problem with the Spyder software of Python(version 4.0.1) regarding the running kernels in the IPython Console. Accordingly, I have tried many ways to resolve the issue like running some commands in Anaconda prompt or set the settings to the default mode. I even updated the version of my anaconda and the spyder. Nevertheless, nothing has been changed and the issue still exists. \nThis is the error I am receiving:\n\nTraceback (most recent call last): File\n  \"C:\\ProgramData\\Anaconda3\\lib\\runpy.py\", line 193, in\n  _run_module_as_main \"main\", mod_spec) File \"C:\\ProgramData\\Anaconda3\\lib\\runpy.py\", line 85, in _run_code\n  exec(code, run_globals) File\n  \"C:\\ProgramData\\Anaconda3\\lib\\site\u2011packages\\spyder_kernels\\console__main__.py\",\n  line 11, in  start.main() File\n  \"C:\\ProgramData\\Anaconda3\\lib\\site\u2011packages\\spyder_kernels\\console\\start.py\",\n  line 287, in main import_spydercustomize() File\n  \"C:\\ProgramData\\Anaconda3\\lib\\site\u2011packages\\spyder_kernels\\console\\start.py\",\n  line 39, in import_spydercustomize import spydercustomize File\n  \"C:\\ProgramData\\Anaconda3\\lib\\site\u2011packages\\spyder_kernels\\customize\\spydercustomize.py\",\n  line 24, in  from IPython.core.getipython import get_ipython File\n  \"C:\\ProgramData\\Anaconda3\\lib\\site\u2011packages\\IPython__init__.py\", line\n  56, in  from .terminal.embed import embed File\n  \"C:\\ProgramData\\Anaconda3\\lib\\site\u2011packages\\IPython\\terminal\\embed.py\",\n  line 14, in  from IPython.core.magic import Magics, magics_class,\n  line_magic File\n  \"C:\\ProgramData\\Anaconda3\\lib\\site\u2011packages\\IPython\\core\\magic.py\",\n  line 20, in  from . import oinspect File\n  \"C:\\ProgramData\\Anaconda3\\lib\\site\u2011packages\\IPython\\core\\oinspect.py\",\n  line 30, in  from IPython.lib.pretty import pretty File\n  \"C:\\ProgramData\\Anaconda3\\lib\\site\u2011packages\\IPython\\lib\\pretty.py\",\n  line 82, in  import datetime File \"C:\\Users\\mahkam\\datetime.py\", line\n  4 ^ SyntaxError: EOF while scanning triple\u2011quoted string literal","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1231,"Q_Id":60568931,"Users Score":0,"Answer":"(Spyder maintainer here) You need to rename or remove this file\nC:\\Users\\mahkam\\datetime.py\nThat's because that file is using the same name of Python internal module and that confuses other modules that depend on it.","Q_Score":0,"Tags":"python,ipython,spyder","A_Id":60570084,"CreationDate":"2020-03-06T17:28:00.000","Title":"Problem with running Kernel in IPython console","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a django app running in a docker container. I bashed into the container and used python manage.py startapp. However, the created directories and files appear to be read-only. From within intellij, I am unable to edit the files. I get a popup offering to clear the readonly status, but that just gives me an error unable to clear readonly status on the following files. \nHow can I edit my files outside of the container?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":427,"Q_Id":60570483,"Users Score":2,"Answer":"You are probably running your container as root user. Hence you do not have the permission to edit them via your editor.\nTry running your container with a regular user (for example docker run  --user 1000:1000 whatever-you-need).","Q_Score":0,"Tags":"python,django,docker","A_Id":60571741,"CreationDate":"2020-03-06T19:32:00.000","Title":"manage.py startapp creates read-only files from within docker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Recently I was trying to test my model which i already trained. Initially I was using Google colab notebook to write code because of it's interactive features, once I was done writing code and I was getting satisfactory results, it took around 2.5 hr to give final output. After that what I wanted was to transfer the notebook code to .py script, I did that with little bit of modification, saved it in gdrive, and then used command !python test.py. now it took me more than 4.5 hr to get the final output, can any one explain why does colab take so much time when trying to run the python script from gdrive while compared to the same code as used in notebook","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":60572161,"Users Score":0,"Answer":"Well it can be because of the fact that colab is retrieving the data from gdrive and then might be again writing in gdrive which will of ofcourse take time i guess","Q_Score":0,"Tags":"python-3.x,google-colaboratory","A_Id":61006480,"CreationDate":"2020-03-06T21:59:00.000","Title":"Running python script in colab very slow as compared to same code run on directly colab in notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"[qt.qpa.plugin] Could not find the Qt platform plugin \"cocoa\" in \"\"\nThis application failed to start because no Qt platform plugin could be initialized. Reinstall application may fix this problem.\nProcess finished with exit code 134 (interrupted by signal 6: SIGABRT)\nPlease help me fix this. I am doing a school project so helping me would be very nice. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":144,"Q_Id":60574601,"Users Score":1,"Answer":"The error is that you are missing a plugin and you will have to install it on your mac. \npip3 install opencv-python-headless from your terminal should do the job assuming you are on python3","Q_Score":0,"Tags":"python,qt","A_Id":60574627,"CreationDate":"2020-03-07T05:10:00.000","Title":"How can I fix a sigabrt error on my macOS Hight Sierra?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For instance,\nI have 1000 rows and 10 columns,\nbatch size is 25,\nsteps per epoch =1000\/25 ==> 40\nepoch = 10\nEpoch 1:\n|----------------------|40 iterations # so in this only 40 samples are propagated right? or wrong?\nso , 10* 40 = 400 so 400 values are only propagated ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":246,"Q_Id":60576323,"Users Score":0,"Answer":"With a batch size of 25 and steps per epoch=40 you will go through 1000 samples. It works like this. For EACH step 25 samples are provided. So after 40 steps you have gone through 25 X 40 samples. If you run for 10 epochs the total training samples processed will be 10 X 1000=10,000. I haven't tried it but I think if you set the steps per epoch say to 50 it will run 25 X 50 samples. I get this from the Keras documentation from model.fit.\n\nsteps_per_epoch: Integer or None. Total number of steps (batches of samples) before declaring one epoch finished and starting the next epoch. When training with input tensors such as TensorFlow data tensors, the default None is equal to the number of samples in your dataset divided by the batch size, or 1 if that cannot be determined.\n\nSo I believe this leads to the definition of an epoch as being completed when samples of batch_size X steps per epoch is completed. The generator will just keep cycling as more batches are called for.","Q_Score":0,"Tags":"python,tensorflow,keras,deep-learning,neural-network","A_Id":60579866,"CreationDate":"2020-03-07T09:53:00.000","Title":"what is really happening in the single epoch forward or backward pass or both?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For instance,\nI have 1000 rows and 10 columns,\nbatch size is 25,\nsteps per epoch =1000\/25 ==> 40\nepoch = 10\nEpoch 1:\n|----------------------|40 iterations # so in this only 40 samples are propagated right? or wrong?\nso , 10* 40 = 400 so 400 values are only propagated ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":246,"Q_Id":60576323,"Users Score":0,"Answer":"25 steps_per_epoch means that there are 25 iterations to be completed during your epoch.\nOne iteration implies both a forward and a backward pass.\nIf you have 1000 elements, a batch_size of 10, you have 100 steps_per_epoch(1000\/10),i.e. 100 iterations.\nThis means that after each batch of 10 elements, a forward and a backward pass are performed.","Q_Score":0,"Tags":"python,tensorflow,keras,deep-learning,neural-network","A_Id":60576359,"CreationDate":"2020-03-07T09:53:00.000","Title":"what is really happening in the single epoch forward or backward pass or both?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large input file of numerical data (22000) columns and at the moment when I use\ndf = pd.read_csv(path_to_file), it uses the first line of numbers as the column values. \nIs there any way to replace the column value with random variables or load the data in a way that the first line is not used as a column name?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":60577051,"Users Score":0,"Answer":"Use pd.read_csv(\"path_to_file\", header=0).\nIf you also want to assign names to the columns you can pass a list in the names parameter of pd.read_csv.","Q_Score":1,"Tags":"python,python-3.x,pandas,dataframe","A_Id":60577094,"CreationDate":"2020-03-07T11:28:00.000","Title":"Replace column values in large Pandas dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm pretty new to python and would like to have autocompletion using vs code inside my project.\nFor external modules it works fine but I dont get autocompletion for my own files\/modules.\nFor example, I have a main.py file inside my src folder and a roboter.py next to it.\nI import a Roboter class via from roboter import Roboter and it runs fine but I dont get any autocompletion on it.\nAlso, I'm using no virtual env but have all other packages global on which I do get autocompletion.\nWhat am I missing here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":429,"Q_Id":60577660,"Users Score":0,"Answer":"Okay, installing a 64 bit version of python instead of a 32 bit version did the job.","Q_Score":0,"Tags":"python,visual-studio-code,autocomplete","A_Id":60577812,"CreationDate":"2020-03-07T12:45:00.000","Title":"VS Code Autocomplete 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 write a function which is passed a position as a variable.\nThe function needs to use OCC gp_Pnt(). How can I pass variable values to gp_Pnt.\nI know that gp_Pnt wants a constant but python does not have a constant as far as I know.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":60579168,"Users Score":0,"Answer":"Okay fixed, Had a typo which is why it was not working","Q_Score":0,"Tags":"python,cad","A_Id":60579802,"CreationDate":"2020-03-07T15:30:00.000","Title":"OCC gp_Pnt with passed variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't know much about that topic so I'm asking for your understanding...\nThis is not question about Bluetooth connection!\nI have WIRELESS headphones and I want to detect the connection between the 2.4GHz receiver and the headphones (Steelseries Arctis 7, if that helps). The receiver is connected via USB to the PC. \nHow do I do it in Python? I tried trackerjacker module but it's on linux only and I'm on Windows 10.\nAlso, gamesense module is not for this stuff I guess so I'm really clueless if it's even possible to this...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":60580667,"Users Score":0,"Answer":"You can try \"winwifi\" package of python for windows env.","Q_Score":0,"Tags":"python,python-3.x,detection,wireless,headphones","A_Id":60580735,"CreationDate":"2020-03-07T18:04:00.000","Title":"How to detect a WIRELESS (not Bluetooth) connection?","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 an application which extracts some data from HTML using BeautifoulSoup4. These are search results of some kind, to be more specific. I thought it would be a good a idea to have a Parser class, storing default values like URL prefixes, request headers etc. After configuring those parameters, the public method would return a list of objects, each of them containing a single result or maybe even an object with a list composed into it alongside with some other parameters. I'm struggling to decouple small pieces of logic that build that parser implementation from the parser class itself. I want to write dozens of parser private utility methods like: _is_next_page_available, _are_there_any_results, _is_did_you_mean_available etc. However, these are the perfect candidates for writing unit tests! And since I want to make them private, I have a feeling that I'm missing something...\nMy other idea was to write that parser as a function, calling bunch of other utility functions, but that would be just equal to making all of those methods public, which doesn't make sense, since they're implementation details.\nCould you please advice me how to design this properly?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":59,"Q_Id":60581669,"Users Score":2,"Answer":"I think you're interpreting the Single-Responsibility Principle (SRP) a little differently. It's actual meaning is a little off from 'a class should do only one thing'. It actually states that a class should have one and only one reason to change.\nTo employ the SRP you have to ask yourself to what\/who would your parser module methods be responsible, what\/who might make them change. If the answer for each method is the same, then your Parser class employs the SRP correctly. If there are methods that are responsible to different things (business-rule givers, groups of users etc.) then those methods should be taken out and be placed elsewhere.\nYour overall objective with the SRP is to protect your class from changes coming from different directions.","Q_Score":1,"Tags":"python,unit-testing,oop,solid-principles","A_Id":60603232,"CreationDate":"2020-03-07T19:56:00.000","Title":"How to design a HTML parser that would follow the Single Responsibility Principle?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using Django 2.2.10 for my app. I am trying to bump it up to Django 3.0.4. But it's throwing me this error:\nImportError: cannot import name 'six' from 'django.utils' (C:\\Users\\hkhatri\\Desktop\\capstone\\fitgirl-inc\\env\\lib\\site-packages\\django\\utils__init__.py)\nI already have six==1.14.0 installed. Can someone please help on how to upgrade my Django version from 2.2.10 to 3.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":400,"Q_Id":60582969,"Users Score":0,"Answer":"I haven't seen the rest of your code and not sure how you're using six but this is how I'm using six in Django 3:\n\nYou want to install Six with pip \nAdd it to your apps in settings\nThen import it in your model import six\n...six.PY3......","Q_Score":0,"Tags":"python,django,six","A_Id":61757611,"CreationDate":"2020-03-07T22:56:00.000","Title":"Django 3.0.4 compatibility with Six package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Currently, I have a class which stores a dictionary of Card elements, each of which is unique. The class can also generate these cards and append them to the dictionary or remove a card from a dictionary. However, I am not sure how to best allow for this action through a callback function since the ID for a card doesn't exist until the card is made, and the functionality isn't directly within the Dash framework since a dictionary object acts as an intermediary where the objects are stored.\nBasically, I am wondering what the best way to dynamically create and destroy objects with a callback is?\nThank you!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":433,"Q_Id":60583933,"Users Score":0,"Answer":"Just on the basis of your question, I have some immediate suggestions (since there is no working code that you have posted). \n1. Generate all card elements by default. They can be generated, but not 'displayed'\n2. Add your callbacks to toggle the display\/rendering of the cards dynamically based on the use case. That way you will have card element ids to play around with in the callbacks. \nHope this helps.","Q_Score":0,"Tags":"python,flask,callback,dashboard,plotly-dash","A_Id":60595465,"CreationDate":"2020-03-08T02:12:00.000","Title":"What is the best way for allowing for dynamic object creation and removal in a Plotly Dash dashboard?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When creating a new Python project, why would I want to select this option? If I don't select it, what functionality am I missing out on? Would I not be able to import certain Python modules?","AnswerCount":4,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":10587,"Q_Id":60585818,"Users Score":4,"Answer":"PyCharm uses virtualenv to give your project its own set of packages that is separate from the rest of your system. \u201cInherit global site packages\u201d means that the packages installed on your computer (outside of the virtual environment) will be added to the virtual environment.","Q_Score":8,"Tags":"python,pycharm,site-packages","A_Id":60585992,"CreationDate":"2020-03-08T08:40:00.000","Title":"What does it mean to \"Inherit global site-packages\" in PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When creating a new Python project, why would I want to select this option? If I don't select it, what functionality am I missing out on? Would I not be able to import certain Python modules?","AnswerCount":4,"Available Count":3,"Score":-0.049958375,"is_accepted":false,"ViewCount":10587,"Q_Id":60585818,"Users Score":-1,"Answer":"You must understand what is inherit first.\nInheritance allow you to use the method field of your parents.\nSo in this case, you are allowed to use the package of your root python environment.","Q_Score":8,"Tags":"python,pycharm,site-packages","A_Id":70477349,"CreationDate":"2020-03-08T08:40:00.000","Title":"What does it mean to \"Inherit global site-packages\" in PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When creating a new Python project, why would I want to select this option? If I don't select it, what functionality am I missing out on? Would I not be able to import certain Python modules?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":10587,"Q_Id":60585818,"Users Score":8,"Answer":"It's just an option to pre-install some packages that you're using everytime, or if it doesn't bother you to have extra packages in your local python interpreted \n\nselect it :  all packages installed in the global python of your machine will be installed for the interpreter you're going to create in the virtualenv.\ndo not select it :  the interpreter you're going to create in the virtualenv will just have the basic, like pip, and setuptools, then you can install just what you need \n\n\nPython global and venv : \n\nThe global python, is the one in \/usr\/bin in Linux, or wherever in Windows, this is the main installation of the program, and you can add extra packages using pip\nWhen you're working on something, you may need only some packages, or specific version so not using the global Python. You can create a virtualenv, or pyenv, that will link a local python to the global one, for the main python functionnality, but the packages will be installed only in the virtualenv (and when using Pycharm, it can install for you the main package into the virtualenv you're creating)","Q_Score":8,"Tags":"python,pycharm,site-packages","A_Id":60585885,"CreationDate":"2020-03-08T08:40:00.000","Title":"What does it mean to \"Inherit global site-packages\" in PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make an GUI application using Kivy framework in Python. I am using Kivy for interface i.e. GUI design and Selenium, BeautifulSoup, CSV libraries for background purpose. Can anybody confirm that does Kivy work with other libraries too?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":55,"Q_Id":60587355,"Users Score":1,"Answer":"Yes, of course, Kivy is just a library providing window drawing and manipulation. What else your Python code does is not limited.","Q_Score":0,"Tags":"python,selenium,beautifulsoup,kivy","A_Id":60588214,"CreationDate":"2020-03-08T12:13:00.000","Title":"Can I build GUI application, using kivy, which is dependent on other libraries?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a application in python using wxpython library with multiple windows which will be inter-related to each other using buttons, i.e. we can go from one window to other and again come back to the previous window using buttons just like an app.\nThere should be one window on the screen at any time if possible. Is this possible using wxpython library. If so then can you suggest me how.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":60588206,"Users Score":0,"Answer":"It is really simple. Normally you create one window (usually a frame or a dialog). If you want more windows, you will just create more frames or dialogs.","Q_Score":0,"Tags":"python-3.x,user-interface,wxpython","A_Id":60596374,"CreationDate":"2020-03-08T13:55:00.000","Title":"Multi-window application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset with an upper numerical limit of 50, none of the samples go above this figure or below zero. \nAfter running a deepAREstimator in GluonTS I get predictions way above 50 and also in the minuses. How can\/could I fix this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":60590137,"Users Score":0,"Answer":"I would probably try to train the model slightly longer, and if possible on a larger dataset.\nTo prevent getting negative values just try a different distribution:\ndistr_output=gluonts.distribution.NegativeBinomial\nBut other than that its hard to tell without additional information what the problem is.","Q_Score":0,"Tags":"python,tensorflow,mxnet,gluon,probability-distribution","A_Id":61350714,"CreationDate":"2020-03-08T17:25:00.000","Title":"Probabilistic time series returning results above thresholds (GluonTS)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm helping out a newly formed startup build a social media following, and I have a csv file of thousands of email addresses of people I need to follow. From looking at the twitter API, I see its possible to follow the accounts if I knew their usernames, but its unclear how to look them up by email. Any ideas?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":65,"Q_Id":60590628,"Users Score":1,"Answer":"This does not appear to be an option with their API, you can use either user_id or screen name with their GET users\/show or GET users\/lookup options.","Q_Score":0,"Tags":"python,api,twitter,twitter-oauth","A_Id":60590725,"CreationDate":"2020-03-08T18:20:00.000","Title":"How can I use the Twitter API to look up accounts from email addresses?","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 helping out a newly formed startup build a social media following, and I have a csv file of thousands of email addresses of people I need to follow. From looking at the twitter API, I see its possible to follow the accounts if I knew their usernames, but its unclear how to look them up by email. Any ideas?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":60590628,"Users Score":0,"Answer":"There is no way to do a lookup based on email address in the Twitter API.","Q_Score":0,"Tags":"python,api,twitter,twitter-oauth","A_Id":60601136,"CreationDate":"2020-03-08T18:20:00.000","Title":"How can I use the Twitter API to look up accounts from email addresses?","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 latest python debugging workflow appears extremely slow to me, and little satifying. How can I improve?\nSetting: I work with some third-party python packages from github.\nWorkflow:\n\nrun into error after entering some command to the terminal (Ubuntu WSL, python 3.7)\nread terminal error message output, most likely the first or last one is helpful \nfrom the last message i take the code reference (ctrl+left mouse in vscode) and look at the code\ni find some function call in the third party module that looks very unrelated to the problem\ni add import pdb to the module, and a pdb.set_trace() before that function call\ni run the program again, and it stops at the breakpoint\nusing n,r,u,d i try to navigate closer to the source of the error\ni eventually find some error raise condition in some other module, where some property of a certain variable is checked. the variable itself is defined some levels up in the stack\nre-running the program and stopping at the same breakpoint as before, i try to navigate to the point where the variable is set. I don't know on which level of the stack it is set, so i miss it sometimes. I set intermediate breakpoints to save me some work when re-running\ni finally find the actual cause of the error. I can check out the workspace and eventually fix the error.\ni go through all the modules and remove the import pdb and the pdb.set_trace\n\nThanks for any suggestions","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":104,"Q_Id":60590748,"Users Score":1,"Answer":"are you using an IDE, not fully clear in your question?\nthey tend to have graphic ways of setting breakpoints and stepping,\nand it saves the hassle of changing the source.\nnot going into ide opinions, but examples of ide's with debuggers are spyder, thonny and others.\nyou can also run the debugger via commandline to avoid changing source, but I don't think that's the way to go if you are looking to simplify the cognotive load.","Q_Score":0,"Tags":"python,debugging,workflow,pdb","A_Id":60592011,"CreationDate":"2020-03-08T18:32:00.000","Title":"How does a good python debugging workflow look like?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"My latest python debugging workflow appears extremely slow to me, and little satifying. How can I improve?\nSetting: I work with some third-party python packages from github.\nWorkflow:\n\nrun into error after entering some command to the terminal (Ubuntu WSL, python 3.7)\nread terminal error message output, most likely the first or last one is helpful \nfrom the last message i take the code reference (ctrl+left mouse in vscode) and look at the code\ni find some function call in the third party module that looks very unrelated to the problem\ni add import pdb to the module, and a pdb.set_trace() before that function call\ni run the program again, and it stops at the breakpoint\nusing n,r,u,d i try to navigate closer to the source of the error\ni eventually find some error raise condition in some other module, where some property of a certain variable is checked. the variable itself is defined some levels up in the stack\nre-running the program and stopping at the same breakpoint as before, i try to navigate to the point where the variable is set. I don't know on which level of the stack it is set, so i miss it sometimes. I set intermediate breakpoints to save me some work when re-running\ni finally find the actual cause of the error. I can check out the workspace and eventually fix the error.\ni go through all the modules and remove the import pdb and the pdb.set_trace\n\nThanks for any suggestions","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":60590748,"Users Score":0,"Answer":"Yes these things you have to do and in extra you can do include logging everywhere as applicable to get exact point where it got occurred.","Q_Score":0,"Tags":"python,debugging,workflow,pdb","A_Id":60591076,"CreationDate":"2020-03-08T18:32:00.000","Title":"How does a good python debugging workflow look like?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to run an idle file in python 3.8.2... An error keeps popping up and says \"No module named 'discord'\". I'm trying to make a discord bot, but IDLE can't seem to find a module called discord. It keeps highlighting the import discord statement on line 1.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":635,"Q_Id":60590764,"Users Score":1,"Answer":"I guess you didn't installed discord module. Please install it using \"pip install discord\"","Q_Score":0,"Tags":"python","A_Id":60590934,"CreationDate":"2020-03-08T18:33:00.000","Title":"Error message in IDLE 3.8.2: No module named '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 am trying to read txt file containing the table with pandas.read_table by executing the following code.\nI added import pandas as pd and the problematic code is pstttable=read_table(\"pstttable.txt\").\nObviously, the location of the txt file is correct and the same code works when working with Jupyter notebook from Windows.\nHowever, I want to compile the code with .py file edited by vi editor from Linux terminal and the following error will occur.\nFile \"Global_Repeater_Search.py\", line 22\n    pstttable=pd.read_table(\"\/Users\/sgtsnu02\/2019-2020_Intern\/EQcorrscan\/pstttable.txt\")\n            ^\nSyntaxError: invalid syntax\nI have no idea why this kind of error occurs. Is this problem inherent to pandas when working in Linux terminal?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":103,"Q_Id":60594897,"Users Score":0,"Answer":"This was really stupid question.\nI forgot to close parentheses of the line before pstttable=pd.read_table(\"\/Users\/sgtsnu02\/2019-2020_Intern\/EQcorrscan\/pstttable.txt\").\nThis caused SyntaxError: invalid syntax.\nNothing is wrong with vi nor pandas.read_table.","Q_Score":0,"Tags":"python,pandas,jupyter-notebook,text-files,vi","A_Id":60666086,"CreationDate":"2020-03-09T04:54:00.000","Title":"pandas.read_table working in Jupyter notebook but would not work in vi editor","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Plese help me with below question\nsample_list = ['Ironman.mdc.googlesuite.net', 'Hulk.nba.abc.googlekey.net',\n    'Thor.web.gg.hh.googlestream.net', 'Antman.googled.net',\n 'Loki.media.googlesuite.net','Captain.googlekey.net']\n\nI would want everything preceeding 'googlesuite.net', 'googlekey.net','googlestream.net' and 'googled.net' in list1 and corresponding prefixes in another list as:\n\nresult_list1=['Ironman.mdc', 'Hulk.nba.abc', 'Thor.web.gg.hh', 'Antman',\n 'Loki.media', 'Captain']\n\n\nresult_list2=['googlesuite.net', 'googlekey.net', 'googlestream.net', 'googled.net',\n 'googlesuite.net', 'googlekey.net']","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":60595247,"Users Score":0,"Answer":"thank you for the answers, it does help but what if I have list like this:\nsample_list = ['Ironman.mdc.googlesuite.net', 'Hulk.nba.abc.googlekey.net',\n    'Thor.web.gg.hh.googlestream.net', 'Antman.googled.net', 'Loki.media.googlesuite.net','Captain.googlekey.net']\n\nI would want everything preceeding 'googlesuite.net', 'googlekey.net','googlestream.net' and 'googled.net'  in list1 and corresponding prefixes in another list as:\nresult_list1=['Ironman.mdc', 'Hulk.nba.abc', 'Thor.web.gg.hh', 'Antman', 'Loki.media', 'Captain']\nresult_list2=['googlesuite.net', 'googlekey.net', 'googlestream.net', 'googled.net',\n 'googlesuite.net', 'googlekey.net']","Q_Score":0,"Tags":"python,string","A_Id":60595969,"CreationDate":"2020-03-09T05:43:00.000","Title":"How to split parts of a string in a list based on predefined part of in the string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I applied batch normalization technique to increase the accuracy of my cnn model.The accuracy of model without batch Normalization was only 46 % but after applying batch normalization it crossed 83% but a here arisen a bif overfitting problem that the model was giving validation Accuracy only 15%. Also please tell me how to decide no of filters strides in convolution layer and no of units in dence layer","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":60595671,"Users Score":0,"Answer":"Batch normalization has been shown to help in many cases but is not always optimal. I found that it depends where it resides in your model architecture and what you are trying to achieve. I have done a lot with different GAN CNNs and found that often BN is not needed and can even degrade performance. It's purpose is to help the model generalize faster but sometimes it increases training times. If I am trying to replicate images, I skip BN entirely. I don't understand what you mean with regards to the accuracy. Do you mean it achieved 83% accuracy with the training data but dropped to 15% accuracy on the validation data? What was the validation accuracy without the BN? In general, the validation accuracy is the more important metric. If you have a high training accuracy and a low validation accuracy, you are indeed overfitting. If you have several convolution layers, you may want to apply BN after each. If you still over-fit, try increasing your strides and kernel size. If that doesn't work you might need to look at the data again and make sure you have enough and that it is somewhat diverse. Assuming you are working with image data, are you creating samples where you rotate your images, crop them, etc. Consider synthetic data to augment your real data to help combat overfiiting.","Q_Score":1,"Tags":"python-3.x,deep-learning,conv-neural-network","A_Id":60716359,"CreationDate":"2020-03-09T06:36:00.000","Title":"Overfitting problem in convolutional neural Network and deciding the parameters of convolution and dence layer","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've installed a new app thorough pip (it's called django-sitetree).\nI want to know if I can connect my models (like Category model) to this app with Foreignkey our something else?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":60596493,"Users Score":0,"Answer":"No this django-sitetree is the module and you can not connect it with your app model to any Foreignkey.\nBecause you only give model field or model as Foreignkey.","Q_Score":0,"Tags":"python,django","A_Id":60596532,"CreationDate":"2020-03-09T07:51:00.000","Title":"Can I connect my model to an external app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In my company, I have got task to create dash board using python whose complete look and feel should be like qlicksense. I am fresher in data science field I don't know how to do this. I did lots of R & D and plotly and dash is the best option as much according to R & D on internet dash table is also a good option but I am not able to create the things what it should look like. If any one know how to start plz help me ..","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":247,"Q_Id":60597337,"Users Score":0,"Answer":"you can use django or other web framework to develop the solution, \nkeep in mind that you probably will need to handle lots of front end stuff like builiding the UI of the system, \nFlask also is very lightweight option, but it needs lots of customization.\nDjango comes with pretty much everything you might need out of the box.","Q_Score":0,"Tags":"python,python-requests,python-3.6,shinydashboard,flexdashboard","A_Id":60649474,"CreationDate":"2020-03-09T09:01:00.000","Title":"How to create Dashboard using Python or R","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python2.7.12 right now and I want to switch it to python3. \nTried sudo apt-get install python3.6 and it gives me this:\n\nReading package lists... Done\n  Building dependency tree\n  Reading state information... Done\n  E: Unable to locate package python3.6\n  E: Couldn't find any package by glob 'python3.6'\n  E: Couldn't find any package by regex 'python3.6'\n\nand tried sudo apt-get install python3 and it gives me this:\n\nReading package lists... Done\n  Building dependency tree\n  Reading state information... Done\n  python3 is already the newest version (3.5.1-3).\n  0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":360,"Q_Id":60598772,"Users Score":1,"Answer":"It depends on your distribution and version (and ultimately the distro's package maintainers). Do sudo apt-get update to get the newest package information, then retry your commands. If 3.6 is still not available, you will either have to resign to using 3.5, wait for the maintainers to package 3.6, or compile it yourself from source.\nIn my personal opinion, there's very small difference between 3.5 and 3.6 (and 3.7), basically no difference at all when compared to the jump between 2.7 and 3.5. Given that Python 2 is officially dead, and the many improvements available in Python 3, you should absolutely start using at least 3.5 that you already have available, and not worry about 3.6 unless you specifically have a package or application that requires it.","Q_Score":0,"Tags":"python-3.6","A_Id":60598895,"CreationDate":"2020-03-09T10:36:00.000","Title":"update from python2.7 to python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I have created a speech to text model 'A' which recognizes 20 speech commands and model 'B'  which recognizes other 20 commands .Is there a way so that i can join both models so that it recognizes  total 40 words.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":60598788,"Users Score":1,"Answer":"I think it depends on your model. If you are using a deep learning model like and LSTM or RNN, and depending on what libraries you use, it might be possible. Many people use pre-trained CNNs to then train their image recognition and generation models. I am not sure how you would join the weights of the two already trained models. Starting from scratch, and using Keras I would train one model, save the weights, load the weights into the other model (assuming they have the same architecture and parameters, and then train the second model on the other 20 words. Also, it might be worth looking into some of the distributed learning solutions out there. I only know of vendor with products (no open source that I have heard of) that offer products that centralize model weights and allow you train data on different data in different locations and then merge those weights centrally. For instance, different hospitals can share model training without sharing data, which is very beneficial when you think about privacy.","Q_Score":2,"Tags":"python,tensorflow,speech-recognition,conv-neural-network","A_Id":60716288,"CreationDate":"2020-03-09T10:37:00.000","Title":"Tensorflow joining two models","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a text file . I need to identify specific paragraph headings and if true i need to extract relevant tables and paragraph wrt that heading using python.  can we do this by nlp or machine learning?. if so please help me out in gathering basics as i am new to this field.I was thinking of using a rule like:\nif (capitalized) and heading_length <50:\n    return heading_text\nhow do i parse through the entire document and pick  only the header names ? this is like automating human intervention of clicking document,scrolling to relevant subject and picking it up.\nplease help me out in this","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":467,"Q_Id":60605461,"Users Score":0,"Answer":"I agree with lorg. Although you could use NLP, but that might just complicate the problem. This problem could be an optimization problem if performance is a concern.","Q_Score":0,"Tags":"python,machine-learning,nlp,data-science,information-extraction","A_Id":60607335,"CreationDate":"2020-03-09T17:18:00.000","Title":"is there any function or module in nlp that would find a specific paragraph headings","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a text file . I need to identify specific paragraph headings and if true i need to extract relevant tables and paragraph wrt that heading using python.  can we do this by nlp or machine learning?. if so please help me out in gathering basics as i am new to this field.I was thinking of using a rule like:\nif (capitalized) and heading_length <50:\n    return heading_text\nhow do i parse through the entire document and pick  only the header names ? this is like automating human intervention of clicking document,scrolling to relevant subject and picking it up.\nplease help me out in this","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":467,"Q_Id":60605461,"Users Score":1,"Answer":"You probably don't need NLP or machine learning to detect these headings. Figure out the rule you actually want and if indeed it is such a simple rule as the one you wrote, a regexp will be sufficient. If your text is formatted (e.g. using HTML) it might be even simpler.\nIf however, you can't find a rule, and your text isn't really formatted consistently, your problem will be hard to solve.","Q_Score":0,"Tags":"python,machine-learning,nlp,data-science,information-extraction","A_Id":60606666,"CreationDate":"2020-03-09T17:18:00.000","Title":"is there any function or module in nlp that would find a specific paragraph headings","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to be sure that my model is not overfitting. I checked the overfitting using cross validation. Results of all folds are close.But at the same time I checked the train and test predictions. Test size is 0.25. And train and test predictions are so different. It shows that my model is overfitting. Which result should I believe? Cross validation or test\/train prediction.Is my model overfitting?\nNote:I used python. Sklearn for cross validation, train test split and modelling","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":187,"Q_Id":60606697,"Users Score":0,"Answer":"From the accuracies you've given, both methods say you have overfitting. Cross validation is just a more accurate way to test how well the model generalises, so don't compare folds, compare the average cross validation accuracy with the training accuracy, since these are very different you have overfitting","Q_Score":0,"Tags":"python,scikit-learn,data-science,cross-validation,training-data","A_Id":60607530,"CreationDate":"2020-03-09T18:53:00.000","Title":"Checking Overfitting","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a content creation tool, updating files in perforce. \nThese files have been inconsistently created as binary or text.\nI would like to get the file type of an existing depot file so when the user saves a new revision, it will export the correct type from the tool.\nIt seems too hacky to just always export as text to avoid file corruption of those p4 type files. Aside from larger file sizes, are there other issues with checking in a text file as Binary in perforce?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":638,"Q_Id":60606894,"Users Score":0,"Answer":"I would like to get the file type of an existing depot file \n\nMost Perforce commands that report on files will include the filetype as part of the output.  The simplest one is p4 files; if you run p4 files FILENAME there will be a filetype like (text) at the end of the output.\n\nso when the user saves a new revision, it will export the correct type from the tool.\n\nBe aware that Perforce's filetype is not the same as your tool's concept of filetype!  To Perforce, .PNG and .PDF are both just binary.\n\nAside from larger file sizes, are there other issues with checking in a text file as Binary in perforce?\n\nA binary file is essentially \"not text\" and will disable all of the Perforce features that depend on the concept of line breaks and textual characters -- RCS delta storage is one, but you also won't get line ending format conversion, diff\/merge, p4 annotate, p4 grep, et cetera.\nIf the text files generated by this tool aren't diffable or human-readable, and if they aren't expected to obey native line ending conventions (or if they aren't portable across platforms in the first place), then binary sounds like the right choice across the board.","Q_Score":1,"Tags":"python,perforce","A_Id":60608298,"CreationDate":"2020-03-09T19:09:00.000","Title":"How do I get the Perforce file type, of a given depot path, through 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 very new to Python and have loads of experience with Matlab. As the code runs, how can I view what is stored in what variable like in Matlab's workspace and Spyder IDE?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":697,"Q_Id":60607620,"Users Score":1,"Answer":"Unfortunately, Sublime is a text editor, not an IDE. Sublime does not do any code execution, it quite literally just edits text. Viewing variable values during runtime is one of the many features found in programs like Spyder that make them IDEs, not just text editors. \nIf you're just using Sublime, you'll need to judiciously use print statements to help you debug. \nAlso, running Python in interactive mode is very helpful. python -i my_script.py will load the Python interpreter after executing your script, allowing you to access variables and interact with your live script.\nHope that helps!","Q_Score":1,"Tags":"python,variables,spyder,workspace","A_Id":60608048,"CreationDate":"2020-03-09T20:05:00.000","Title":"Sublime 3 - How do I view stored variables in Sublime like in Matlab's \"Workspace\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having trouble getting my Azure Function (python, timer trigger) to work in a docker container. Outside of the docker container, everything works just fine. But as soon as I start my container, I get an error saying: \n\nfail: Host.Startup[515] A host error has occurred\n  System.InvalidOperationException: Unable to find an Azure Storage connection string to use for this binding.\n\nMy connection string is defined in my local.settings.json. I have no clue as to why this isn't working in the docker container, has anyone dealt with this? I appreciate any direction, thank you.\nEdit: Just a clarification, this is happening on my local machine. I have not deployed yet.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":906,"Q_Id":60610206,"Users Score":0,"Answer":"The explanation is in this github issue.\nBasically local.settings.json is only used by the local CLI, it's totally ignored by the runtime","Q_Score":5,"Tags":"python,azure,docker,azure-functions","A_Id":62175869,"CreationDate":"2020-03-10T00:48:00.000","Title":"Azure Function Python docker container: Unable to find an Azure Storage connection string to use for this binding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm having trouble getting my Azure Function (python, timer trigger) to work in a docker container. Outside of the docker container, everything works just fine. But as soon as I start my container, I get an error saying: \n\nfail: Host.Startup[515] A host error has occurred\n  System.InvalidOperationException: Unable to find an Azure Storage connection string to use for this binding.\n\nMy connection string is defined in my local.settings.json. I have no clue as to why this isn't working in the docker container, has anyone dealt with this? I appreciate any direction, thank you.\nEdit: Just a clarification, this is happening on my local machine. I have not deployed yet.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":906,"Q_Id":60610206,"Users Score":6,"Answer":"As I said before, I defined my connection string in my local.settings.json. I ended up accessing the file system of the container, and verified that my local.settings.json was in fact in there. I ended up adding my connection string as an env variable in my docker file (AzureWebJobsStorage={YOURCONNNECTIONSTRINGHERE}) and got it working. Hopefully this helps someone who comes across this issue.","Q_Score":5,"Tags":"python,azure,docker,azure-functions","A_Id":60623147,"CreationDate":"2020-03-10T00:48:00.000","Title":"Azure Function Python docker container: Unable to find an Azure Storage connection string to use for this binding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm looking for a way to convert a list to a dictionary as shown below. Is this possible? Thanks in advance.\nlist = [\"1\/a\", \"2\/b\", \"3\/c\"]\ndict = {\"1\": \"a\", \"2\": \"b\", \"3\": \"c\"}","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":60612811,"Users Score":0,"Answer":"Yes you can.\nIf you want to have everything after the '\/' (i.e. 2nd char), you can do:\ndict = {c[0]:c[2:] for c in list}\nIf you want to have everything after the '\/' (but may not be the 2nd char), you can do:\ndict = {c[0]:c.split('\/')[1] for c in list}\nIt really dependes on the input you have and what output you want","Q_Score":0,"Tags":"python-3.x","A_Id":60612958,"CreationDate":"2020-03-10T07:01:00.000","Title":"Convert elements in ONE list to keys and values in a dictionary","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I initialize a list of length n using df_list = [None] * n. Then I have a for loop where I fill each element of df_list with a dataframe. Then, when I concat all these dataframes together using df = pd.concat(df_list, axis=0) I end up with fewer rows than expected, and upon further inspection I find that some elements of df_list are None type while others are dataframes. This is strange to me because in my for loop, I print the type of each value before filling it into df_list and they are all dataframes of the desired shape and columns as well. \nWondering how, after running the loop, I can have None values in df_list when each value I filled in is a dataframe and not None. \nAny help here is appreciated - quite puzzled by this!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":187,"Q_Id":60612985,"Users Score":1,"Answer":"Why do you even need to initialize the list with None values. Just create empty list and append your dataframes to it.","Q_Score":2,"Tags":"python,pandas,dataframe,concat,nonetype","A_Id":60613053,"CreationDate":"2020-03-10T07:16:00.000","Title":"Python list has none type elements even though filled with dataframe elements","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know how much time has been taken by the whole test suite to complete the execution. How can I get it in Pytest framework. I can get the each test case execution result using pytest <filename> --durations=0 cmd. But, How to get whole suite execution time>","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":650,"Q_Id":60613155,"Users Score":1,"Answer":"Use pytest-sugar\npip install pytest-sugar\nRun your tests after it,\nYou could something like Results (10.00s) after finishing the tests","Q_Score":3,"Tags":"python,pytest","A_Id":60613797,"CreationDate":"2020-03-10T07:31:00.000","Title":"How to find time take by whole test suite to complete in Pytest","Data Science and Machine Learning":0,"Database and SQL":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 struggling on a simple problem where i need to check whether customer location has effect on number of defects.\nDataset is like. Location has 50 values and categorical in nature and defects is continuous.\n\nlocation  defects\na            20\nb            30\nc            40\nd            50\ne            60\nf            70\ng            80","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":558,"Q_Id":60614236,"Users Score":-2,"Answer":"So you basically wanna calculate (ratio_for_location) = (number_of_defects_for_location) \/ (total_number_of_whatever_for_location) and check for outliers \/ find the function defect_ratio(location)?","Q_Score":1,"Tags":"python,anova","A_Id":60614285,"CreationDate":"2020-03-10T08:56:00.000","Title":"correlation between two variables(categorical and continuous) in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use the built-in function enumerate() to label some points or vertices where each point is represented by its coordinates in a list(or set) of tuples which essentially looks like {(4,5), (6,8), (1,2)}\nI want to assign a letter starting from \"a\" in ascending order to each tuple in this set, using enumerate() does exactly the same but It's written in a way that it returns the value of the index of each item so that it's a number starting from 0.\nis there any way to do it other than writing my own enumerate()?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":312,"Q_Id":60618698,"Users Score":0,"Answer":"The enumerate function is defined as follow :\nenumerate(iterable, start=0)\nI think just have to write your own enumerate or an wrapper around enumerate.","Q_Score":3,"Tags":"python,python-3.x,list,indexing,enumerate","A_Id":60618815,"CreationDate":"2020-03-10T13:32:00.000","Title":"Using enumerate() to enumerate items with letters rather than numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"First time programming in python and I guess you will notice it after reading my question:\n  + How can I remove the message \"cryptography is not installed, use of crypto disabled\" when running the application?\nI have created a basic console application using the pyinstaller tool and the code is written in python.\nWhen I run the executable, I am getting the message \"cryptography is not installed, use of crypto disabled\". The program still runs, but I would prefer to get rid off the message.\nCan someone help me?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2345,"Q_Id":60621653,"Users Score":6,"Answer":"cryptography and crypto are 2 different modules.\ntry:\npip install cryptography\npip install crypto","Q_Score":1,"Tags":"python,cryptography","A_Id":60646460,"CreationDate":"2020-03-10T16:13:00.000","Title":"python + how to remove the message \"cryptography is not installed, use of crypto disabled\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a huge file. I've tried with other software, and it didn't work. So I want to make a custom script.\nHowever, I just cannot work it out myself.\nI want to delete every line in a file with the following condition: if \"[\" in line:\nFile in question is a .txt file with about 14,000,000 lines. I would prefer something fast.\nI've tried other similar functions on this page, but I couldn't find any that would fit my requirements.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":588,"Q_Id":60627360,"Users Score":0,"Answer":"Use the readline method of the file object inside a while loop. So while you are in the loop get all lines that do not fit the if condition and store into into a data structure. \nLater open a new file and write th entire structure to the new file","Q_Score":0,"Tags":"python","A_Id":60627415,"CreationDate":"2020-03-10T23:37:00.000","Title":"How do I loop through a file and remove all lines that fit the condition?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Which unit of measurement has the accuracy, mean absolut error and mean squared error of the sklearn metrics? and are they used for regression problems? \nFor example i have a regressor.score(X_test,y_test)) of about 0.99469. So the tested Model is 0.99469 in comparison to the real data? or do you say percent of 99%? \nThe same with the MAE and MSE. \nThe other question is, i red about the confusion matrix for classification problems and the accuracy is the value calculated out of the confusion matrix. I use a multiple linear regression, so can i use these metrics for my regression?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":752,"Q_Id":60627942,"Users Score":0,"Answer":"To answer your first question, the metric such as accuracy can't be used for regression problems. And yes, you are right. The accuracy is calculated using the confusion matrix, but since you have a regression problem, you can't get the confusion matrix as it is an output of the classification problem but you have a regression problem in place.\nMoreover, the right metrics for the regression problem are mean squared error, mean absolute error and the R squared value. By default the regressor.score(X_test,y_test)) function gives out the R squared value.\nTo make it easy, the closer the value is to 1 (0.99469 in your case), the better is your model. And it seems like your model is performing really well.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,metrics,confusion-matrix","A_Id":60629372,"CreationDate":"2020-03-11T01:03:00.000","Title":"sklearn metrics units of Measurement of accuracy, mean absolut error, mean squared error for regression problems?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to find out if there is an easy way or like a one line code to plot the basic statistics (like mean, std dev, min, max etc) of any dataframe in python using plotly or any such graphing library. Right now I made a few functions to manipulate the dataframe, to transform it into a desired form containing basic stats so I can plot it using cufflinks. And I get the basic stats of all columns in a dataframe, in one place.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":66,"Q_Id":60629052,"Users Score":-1,"Answer":"You should be able to use the .plot() method on a dataframe you're working with and be returned a collection of different types of graphs.","Q_Score":0,"Tags":"python,dataframe,plot,jupyter-notebook,plotly","A_Id":60629097,"CreationDate":"2020-03-11T03:54:00.000","Title":"Is there an easy\/shortcut way to obtain visualizations of basic stats of any dataframe in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need select all objects in Maya with name \"shd\" and after that I need assigned to them specific material.\nI don't know how to do that because when I wrote: select -r \"shd\"; it send me the message: More than one object matches name: shd \/\/ \nSo maybe I should select them one by one in some for loop or something. I am 3D artist so sorry for the lame question.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2500,"Q_Id":60634469,"Users Score":0,"Answer":"You can use select -r \"shd*\" to select all objects with a name stating with \"shd\".","Q_Score":0,"Tags":"python,loops,select,maya,mel","A_Id":60634765,"CreationDate":"2020-03-11T11:00:00.000","Title":"Maya python (or MEL) select objects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there anyway I can list all resources\/components under a sub-net using boto-3?\nI'm unable to find a method which gives me result I'm looking for","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":60635513,"Users Score":1,"Answer":"There is no single method that lists everything, but there are API calls to list each type of component.\nFor example, you could list EC2 instances, ENIs, Load Balancers, etc.\nActually, everything in a subnet will have an ENI associated with it, so you could start there. However, it's often not easy to determine the component that is linked to the ENI.","Q_Score":0,"Tags":"python,amazon-web-services,aws-sdk,boto3","A_Id":60646170,"CreationDate":"2020-03-11T11:58:00.000","Title":"List all components under a subnet AWS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How can I match all occurrences of \"an Upper and Lower case\" or vice versa of the same letter following each other in a string using regex? e.g: \"aADFfGcCgs\", I want to match aA, Ff and cC\nI am doing the following re.findall('[a-Z][A-Z]', string) which can only match two characters which are not necessarily the opposite case of the other letter.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":60636273,"Users Score":0,"Answer":"I dont think regex can check relations in patterns. \nI would iterate through each char and see if the char is between 97 and 122 or 65 and 90 to see if the char is upper or lower and then check the neighboring char - or + 32.","Q_Score":3,"Tags":"python,regex","A_Id":60636403,"CreationDate":"2020-03-11T12:40:00.000","Title":"How do I use Regex to find a letter and its opposite case one following the other in a string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have image-like data. And I wont to perform Image cropping, squishing and zooming, on one or both axis. The problem is that the data is not in between 0-255, and normalizing it to 0-255, would mean loosing a lot of the information I want to preserve. So unfortunately I can\u2019t use PIL or cv2. Is there a easy way to do it with numpy or scipy?\nThanks for the help","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":60636391,"Users Score":0,"Answer":"Check ImageChops function of Image Librart","Q_Score":0,"Tags":"python,image,numpy,scikit-learn,scipy","A_Id":60640599,"CreationDate":"2020-03-11T12:46:00.000","Title":"perform Image cropping on Image like data using Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The whole project is as follows:\nI'm trying to build a Django based web-app for my college library. This app when idle will be showing a slideshow of pictures on the screen. However when an input is received from the barcode scanner, it is supposed to redirect it to a different age containing information related to that barcode. I'm not able to figure out how to get an input from the scanner and only then redirect it to the page for 3 seconds containing the relevant information, after the interval, it should redirect back to the page containing the slideshow.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":60638584,"Users Score":0,"Answer":"you should communicate with the bar-code scanner to receive scanning-done event which has nothing to do with django but only javascript or even an interface software which the user must install, like a driver, so you can detect the bar-code scanner from javascript(web browser) then you can get your event in javascript and redirect the page on the event or do whatever you want","Q_Score":2,"Tags":"python,django,redirect,image-processing,web-applications","A_Id":60640111,"CreationDate":"2020-03-11T14:39:00.000","Title":"How to redirect to a different page in Django when I receive an input from a barcode scanner?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to create just a python file (.py) in mac.\nWithout using Pycharm or other IDE.\nI tried using 'TextEdit' but it didn't work.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9361,"Q_Id":60639775,"Users Score":3,"Answer":"Press Save \nSave file as myname.py\nUnless I'm missing something?\nEDIT\nTextEdit has separate plain text and rich text modes. You'll have to select Format > Make Plain Text or set the default format to plain text first.","Q_Score":0,"Tags":"python,macos,file","A_Id":60639861,"CreationDate":"2020-03-11T15:45:00.000","Title":"How to create '.py' file in Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I apologize in advance for my lack of data-structure education.\nFrom my understanding:\n\na fixed sized deque that serves as a memory can have its oldest value replaced (although we an remove new values)\na circular buffer that serves as memory can also have its oldest values replaced\n\nWhat is the difference between the two concepts? Are they the same thing? Is one a subset of another?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":869,"Q_Id":60643379,"Users Score":4,"Answer":"A good related question would be this one: what's the difference between a queue and a linked list with a tail pointer? A queue adds to the end and removes from the front, which is the same thing you can do with a linked list with a tail pointer.\nThe difference is that one of these is an abstraction and one of these is a concrete way of implementing that abstraction. There are several ways to implement a queue, including a linked list with a tail pointer, a circular buffer, or even a splay tree. Similarly, there are things you can do to a linked list with a tail pointer that you wouldn't do to a deque, such as splicing large sections into or out of the list.\nIn your case, \"deque\" is the abstraction. You can think of a deque as \"something where you can add and remove from both ends,\" and it could be implemented with a circular buffer, or a linked list, or a splay tree, etc. A circular buffer is one of many ways you can implement a deque, and there are other things you can do with a circular buffer beyond just implementing a deque.\nHope this helps!","Q_Score":1,"Tags":"python,algorithm,data-structures,buffer,deque","A_Id":60643423,"CreationDate":"2020-03-11T19:38:00.000","Title":"What's the difference between a deque and circular buffer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python-docx to convert Word docx files into a proprietary XML format.\nI'm having trouble with bullet\/enumerated lists.\nIn a number of Word documents when I open them with python-docx and look at the paragraph style of the bullet\/enumerated lists, some of the items in the list will be 'List Paragraph' but many of them will be 'Normal'. \nAssuming they should all be 'List Paragraph', is there a way I can verify if this is an issue with the Word document or with the python-docx package?\nAlso, is there a way to identify these bullets\/numbers when the paragraph style isn't what it should be?\nEg. using paragraph_format?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":549,"Q_Id":60645596,"Users Score":0,"Answer":"A bullet-point can appear on a paragraph in Word at least two different ways:\n\nThe user applies a paragraph style, like \"List Paragraph\"\nThe user applies a bullet directly to the paragraph, probably using the bullet button on the toolbar.\n\nI suspect users tend to fall into one of these two habits. Using styles consistently allows you to adjust the formatting of all those paragraphs just by modifying the style. But I suspect 98%+ of users cultivate the \"click the bullet button\" habit.\nIn any case, it's not surprising to find a document that's a mixed bag that way.\nUnfortunately, python-docx doesn't currently have support for directly-applied bullets, either for applying them or detecting them.\nIf you have the skills to inspect the XML of the paragraph (print(paragraph._p.xml) is a start), then you can probably use an XPath expression on paragraph._p (the XML element underlying the paragraph) to detect if it has what I believe is a <w:bu> element, which would indicate it had a directly-applied bullet. Inspecting the XML of a paragraph known to have a directly applied bullet should give you the details of what you'd be looking for there.","Q_Score":0,"Tags":"docx,python-docx","A_Id":60648739,"CreationDate":"2020-03-11T23:14:00.000","Title":"python-docx style error with 'List Paragraph'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to pull data from an external API and dump it on S3 . I was thinking on writing and Airflow Operator rest-to-s3.py which would pull in data from external Rest API .\nMy concerns are :\n\nThis would be a long running task , how do i keep track of failures ?\nIs there a better alternative than writing an operator ?\nIs it advisable to do a task that would probably run for a couple of hours and wait on it ?\n\nI am fairly new to Airflow so it would be helpful.","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":2262,"Q_Id":60645797,"Users Score":5,"Answer":"Errors - one of the benefits of using a tool like airflow is error tracking. Any failed task is subject to rerun (based on configuration) will persist its state in task history etc..\nAlso, you can branch based on the task status to decide if you want to report error e.g. to email\nAn operator sounds like a valid option, another option is the built-in PythonOperator and writing a python function.\nLong-running tasks are problematic with any design and tool. You better break it down to small tasks (and maybe parallelize their execution to reduce the run time?) Does the API take long time to respond? Or do you send many calls? maybe split based on the resulting s3 files? i.e. each file is a different DAG\/branch?","Q_Score":0,"Tags":"python,airflow-scheduler,airflow","A_Id":60651388,"CreationDate":"2020-03-11T23:42:00.000","Title":"Airflow Operator to pull data from external Rest API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Running python 3.7.7 on Windows 7 x64.  I've just upgraded from python 2.7 and I'm trying to install the module emcee using pip install emcee.  Pip threw the error ModuleNotFoundError: No module named 'enum'.  I've also tried installing modules matplotlib, enum34, and numpy, but all threw the same error.  I've also tried to upgrade pip with pip install --upgrade pip , which again threw the same error.  I've looked into my \\python37\\lib folder, and enum.py is present right where it's supposed to be, but it's still not working.  \nPlease help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":321,"Q_Id":60646549,"Users Score":0,"Answer":"Could you please confirm that you have python installed ie it\u2019s upgraded and in existence. You can do this by typing python in the cmd or terminal window. This should push you into a python shell. If it does not do so. Trying reinstalling python. May be the upgrade did not work so well.","Q_Score":0,"Tags":"python,python-3.x,pip","A_Id":60646862,"CreationDate":"2020-03-12T01:42:00.000","Title":"pip giving error ModuleNotFoundError: No module named 'enum'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had received format like this in python \n\ndatetime.datetime(2020, 3, 5, 18, 55, tzinfo=tzoffset(None, 19800))\n\nneed to convert like this  \n\n2020-3-5 18:55:00.000000\n\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":60647530,"Users Score":0,"Answer":"import arrow\narrow.get(str(date_str)).shift(hours=-5, minutes=-30).datetime","Q_Score":0,"Tags":"python-3.x","A_Id":60648855,"CreationDate":"2020-03-12T04:11:00.000","Title":"how to convert datetime.datetime(2020, 3, 5, 18, 55, tzinfo=tzoffset(None, 19800)) to 2019-01-08 11:49:00.000000 in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python3.7.2 and idle installed on my mac, both of them came from the official installation package, run without problem for months, until recently I changed my terminal shell to zsh and also installed another version of python when homebrew is trying to have it as a dependency.\nThen today any .py file cannot be opened by the idle app, I uninstalled the homebrew version of python, removed the frameworks and the links in \/usr\/local\/bin, but the idle app still cannot be opened. Although the app version cannot be opened, it can be opened by \"idle3\" in my command line. What's more the python launcher works just fine.\nThen I removed all the versions of python3 installed, used app cleaner to clean the saved state stuff and cleaned all the links used by python3 in \/usr\/local\/bin. Later I installed the python3.7.7 and idle using official .pkg installer. Still idle cannot be opened by double clicking on it. But this time things get even worse, the idle can be opened indirectly sometimes at a nearly random probability if I try to double click on .py files. And even python launcher cannot open .py files in terminal. Now I have no idea how things are going. Can anyone help to analyze how this kind of weird problem occurred?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10905,"Q_Id":60648250,"Users Score":0,"Answer":"Control-Click on the Python file and open with a different version of Idle via \"Open With\".","Q_Score":2,"Tags":"python,macos,python-idle","A_Id":67995588,"CreationDate":"2020-03-12T05:46:00.000","Title":"Cannot open idle on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was running into a lot of file not found for webpack in my static folder, and I later realized that for some reason this particular project (which I'm using docker with) keeps trying to check another project folder's static folder for the files I would want. I'm not sure where this could've gone wrong other than the base_dir, but I never changed that setting. There was a while I was going between the projects and trying to run each one (the other project is basically the same thing but not on docker), was that possibly what's confusing the program? How can I solve it?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":613,"Q_Id":60648661,"Users Score":1,"Answer":"BASE_DIR is written in settings.py file you can use that by importing it.","Q_Score":2,"Tags":"python,django,webpack","A_Id":60648708,"CreationDate":"2020-03-12T06:27:00.000","Title":"How to check BASE_DIR in django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"It works for the huber and log, however only the logarithm has a predict_proba? How it works? I used roc_auc_score.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":105,"Q_Id":60649581,"Users Score":1,"Answer":"Grid Search CV has both the predict and the predict_proba functions.\nIf you consider a binary classification problem, predict will have the values of 0 or 1. While, Predict_proba will have the probability values of it being 0 or 1.\npredict_proba will have an array output like [0.23 0.77]","Q_Score":0,"Tags":"python-3.x,machine-learning,scikit-learn,gridsearchcv","A_Id":63290682,"CreationDate":"2020-03-12T07:44:00.000","Title":"GridSearchCV uses predict or predict_proba?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have checked five different methods for face detection.\n     1. Haar cascade \n     2. Dlib HOG \n     3. Python face_recognition module \n     4. DLib_CNN \n     5. OpenCV CNN \nAll these methods have some advantages and disadvantages and i found out that openCV_CNN works better out of these five algorithm. But for my application i need to detect faces from people on far distance and for this purpose even OpenCV_CNN is not working well (it detects faces of people closer to camera and not the people on far distance). Is there any other algorithm which detects faces of people on far distance?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":90,"Q_Id":60651983,"Users Score":1,"Answer":"One of the ways is to do instance segmentation in order to get all the classes in the environment including distant objects. \nOnce you get all the classes, you can draw a bounding box around the required far off face class, upsample it and send it to your face detection NN. suppose your image is of 54x54x3, it will be upsampled to 224x224x3 and sent to your trained NN.","Q_Score":0,"Tags":"python-3.x,machine-learning,deep-learning,computer-vision,data-science","A_Id":61311705,"CreationDate":"2020-03-12T10:20:00.000","Title":"Which face detection method suitable for detecting faces of people at a long distance?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to data science\/Machine Learning.\nI have to write a web crawler and extract features out of each blog. These features in the form of Tags tell about the industry, specific products, tools, and similar things like these.\nI have done part of scraping but now I am stuck with entities identification. \nI did Data processing (Tokenization, data cleaning, removing stop words\/punctuation, stemming\/lemmatization).\nfor now, what I have to do for feature extractions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":19,"Q_Id":60653333,"Users Score":0,"Answer":"Ok so what you need to do is set up a pandas dataframe.\nIn the first column, you need to have the entire text of the website or blog, processes as you mentioned.  In the following columns, you need to have one column for each tag you want to apply to the dataset, one-hot encoded.\nThen you will need to fill out the rows by labeling, by hand, several thousand of the website or blog posts using that one-hot encoding.\nWhen you are done,  you can train your machine.  Then any new article you put into it, the machine will output a probability for the tags belonging to that article.  There are probably a lot of repositories on github with pretrained models you can use.","Q_Score":0,"Tags":"python,machine-learning,deep-learning,web-crawler,data-science","A_Id":60655309,"CreationDate":"2020-03-12T11:35:00.000","Title":"Features Extraction from News Blog","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing plugin Nrpe in Python.\nWhen i try to execute my code it works well on my machine. But when the NRPE execute it, an error occurs : 'No Module named pycurl'\nI'm working on CentOs6.10 with Python 3.4 and i've installed pycurl with easy-install, the path to pycurl.py is \/usr\/lib\/python3.4\/site-packages\/\/usr\/lib\/python3.4\/site-packages\/pycurl.py\nAnd my PYTHONPATH = ['\/usr\/local\/bin', '\/usr\/lib64\/python34.zip', '\/usr\/lib64\/python3.4', '\/usr\/lib64\/python3.4\/plat-linux', '\/usr\/lib64\/python3.4\/lib-dynload', '\/usr\/lib64\/python3.4\/site-packages', '\/usr\/lib\/python3.4\/site-packages']\nI hope somebody could help me ?\nThanks !","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":60656331,"Users Score":0,"Answer":"You probably need something like:\npython3 -m pip install pycurl\nYou may want to use: python3 -m pip install --user pycurl\nor a virtual environment.\npycurl doesn't come with python.  You have to install it with pip from pypi.","Q_Score":0,"Tags":"python,linux,centos6,nrpe,centreon-api","A_Id":60659262,"CreationDate":"2020-03-12T14:36:00.000","Title":"Why Python library import doesn't work via NRPE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a basic MQTT question: If I have a broker that I can't configure myself but publish or subscribe anonymous, is it possible for the publisher to define the allowed clients on the topic?\nE.g. with mosquitto I can define a ACL file but only at the broker site.\nIf it is not possible, what would be the best way to encrypt the published data with python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":121,"Q_Id":60656367,"Users Score":0,"Answer":"No, a MQTT publisher has absolutely no knowledge or control over which clients can subscribe to the topic it publishes messages.\nMQTT is a pub\/sub protocol, one of it's key tenets is to totally decouple the publisher from the subscriber. The may be anything from 0 to n subscribers when a message is published.\nThe only option of control is as mentioned in the comments by @GDagger is that you  could encrypt the payload so only authorised subscribers could decrypt it. Since MQTT payloads are just a collection of bytes you can send anything you want (with in the 256mb size limit)\nOn the other hand the broker has complete control, it can use ACLs to decide which clients can publish or subscribe to which topics.","Q_Score":0,"Tags":"python,security,mqtt","A_Id":60660698,"CreationDate":"2020-03-12T14:39:00.000","Title":"MQTT is it possible for publisher to define allowed subscribers on topic?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to get data for a certain period of time by es api and use python to do some customized analysis of these data and display the result on dashboard.\nThere are about two hundred thousand records every 15 minutes,indexed by date.\nNow I use scroll-scan to get data,But it takes nearly a minute to get 200000 records\uff0cIt seems to be too slow.\nIs there any way to process these data more quickly?and can I use something like redis to save the results and avoid repetitive work?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":248,"Q_Id":60656675,"Users Score":1,"Answer":"Is it possible to do the analysis on the Elasticsearch side using aggregations?\nAssuming you're not doing it already, you should use _source to only download the absolute minimum data required.  You could also try increasing the size parameter to scan() from the default of 1000.  I would expect only modest speed improvements from that, however.\nIf the historical data doesn't change, then a cache like Redis (or even just a local file) could be a good solution.  If the historical data can change, then you'd have to manage cache invalidation.","Q_Score":1,"Tags":"python,elasticsearch","A_Id":60656985,"CreationDate":"2020-03-12T14:56:00.000","Title":"How to speed up Elasticsearch scroll in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I read a lot of tutorial about BPE but I am still confuse how it works.\nfor example.\nIn a tutorial online, they said the folowing : \nAlgorithm\nPrepare a large enough training data (i.e. corpus)\nDefine a desired subword vocabulary size\nSplit word to sequence of characters and appending suffix \u201c\u201d to end of\nword with word frequency. So the basic unit is character in this stage. For example, the frequency of \u201clow\u201d is 5, then we rephrase it to \u201cl o w \u201d: 5\n    Generating a new subword according to the high frequency occurrence.\n    Repeating step 4 until reaching subword vocabulary size which is defined in step 2 or the next highest frequency pair is 1.\nTaking \u201clow: 5\u201d, \u201clower: 2\u201d, \u201cnewest: 6\u201d and \u201cwidest: 3\u201d as an example, the highest frequency subword pair is e and s. It is because we get 6 count from newest and 3 count from widest. Then new subword (es) is formed and it will become a candidate in next iteration.\nIn the second iteration, the next high frequency subword pair is es (generated from previous iteration )and t. It is because we get 6count \nfrom newest and 3 count from widest.\nI do not understand why low is 5   and lower is  2:\ndoes this meand  l , o, w , lo, ow +  = 6 and then lower  equal two but why is not e, r, er which gives three ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1056,"Q_Id":60659868,"Users Score":0,"Answer":"The numbers you are asking about are the frequencies of the words in the corpus. The word \"low\" was seen in the corpus 5 times and the word \"lower\" 2 times (they just assume this for the example).\nIn the first iteration we see that the character pair \"es\" is the most frequent one because it appears 6 times in the 6 occurrences of \"newest\" and 3 times in the 3 occurrences of the word \"widest\".\nIn the second iteration we have \"es\" as a unit in our vocabulary the same way we have single characters. Then we see that \"est\" is the most common character combination (\"newest\" and \"widest\").","Q_Score":4,"Tags":"python,scikit-learn,nlp,vectorization","A_Id":60804237,"CreationDate":"2020-03-12T18:21:00.000","Title":"How to understand byte pair encoding?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on simple machine learning problems and I trying to build a classifier that can differentiate between spam and non-spam SMS. I'm confused as to whether I need to generate the document-term matrix before splitting into test and train sets or should I generate the document-term matrix after splitting into test and train? \nI tried it both ways and found that the accuracy is slightly higher when the I split the data before generating the document-term matrix. But to me, this makes no sense. Shouldn't the accuracy be the same? Does the order of these operations make any difference?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":356,"Q_Id":60661508,"Users Score":2,"Answer":"Qualitatively, you don't need to do it either way.  However, proper procedure requires that you keep your training and test data entirely separate.  The overall concept is that the test data are not directly represented in the training; this helps reduce over-fitting.  The test data (and later validation data) are samples that the trained model has never encountered during training.\nTherefore, the test data should not be included in your pre-processing -- the document-term matrix.  This breaks the separation, in that the model has, in one respect, \"seen\" the test data during training.\nQuantitatively, you need to do the split first, because that matrix is to be used for training the model against only the training set.  When you included the test data in the matrix, you obtained a matrix that is slightly inaccurate in representing the training data: it no longer properly represents the data you're actually training against.  This is why your model isn't quite as good as the one that followed proper separation procedures.\nIt's a subtle difference, most of all because the training and test sets are supposed to be random samples of the same population of possible inputs.  Random differences provide the small surprise you encountered.","Q_Score":2,"Tags":"python,machine-learning,nlp,data-science","A_Id":60662708,"CreationDate":"2020-03-12T20:33:00.000","Title":"Split into test and train set before or after generating document term matrix?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to use Google Colab to accelerate the process of calculation of my deep learning model. However, I cannot run the model directly from the .ipynb file in the Google Colaboratory, since it has several .py functions written separately and then the main program will call them together in another .py file.\nOne of the proposed solutions consisted of following three steps:\n\nCommit the code on Github\nClone on collab\nrun this command: !python model_Trainer.py on Colab\n\nI have done steps 1 and 2 successfully, however, I still cannot run the third step. And I am getting the following error:  python3: can't open file 'model_trainer.py': [Errno 2] No such file or directory.\nDoes anyone have a solution to this problem?\nI look forward to hearing from you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3503,"Q_Id":60664979,"Users Score":0,"Answer":"I have the same problem.\nyou can use !pwd to see the current dictionary and cd to change the dictionary which your python files locate.\nIf you wanna run the .py file, you can just use !python example.py to run.","Q_Score":2,"Tags":"python,machine-learning,github,deep-learning,data-science","A_Id":63242095,"CreationDate":"2020-03-13T04:44:00.000","Title":"How to use Google Colab to run .py files from Github repositories?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a barcode scanner, scandit 5.14.2 on Linux with a trial license. I am trying to run a python module sample i.e. CommandLineBarcodeScannerImageProcessingSample.py but I am getting the following error\n\nProcessing frame failed with code 15: The Scandit SDK license\n  validation failed. Your app ID does not match the license key's app\n  ID.\n\nI have tried creating a new license key with Application ID \/ Bundle ID as the name of the file i.e. CommandLineBarcodeScannerImageProcessingSample.py but still getting the same error.\nSame goes with CommandLineBarcodeScannerCameraSample.py but all c scripts run fine.\nIn FAQs of scandit it is mentioned that I should use program_invocation_name as bundle id. Is there something I am missing? Any suggestion would be very helpful","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":621,"Q_Id":60665224,"Users Score":0,"Answer":"One does not need to create a new license ID for sample code from Scandit. One needs do the following:\n\nlogin to your dashboard\ngo to the License Keys tab. There is a default license key already made. Use that.","Q_Score":0,"Tags":"python,barcode-scanner","A_Id":63200079,"CreationDate":"2020-03-13T05:22:00.000","Title":"Scandit python code 15 Your app ID does not match the license key's app ID","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a barcode scanner, scandit 5.14.2 on Linux with a trial license. I am trying to run a python module sample i.e. CommandLineBarcodeScannerImageProcessingSample.py but I am getting the following error\n\nProcessing frame failed with code 15: The Scandit SDK license\n  validation failed. Your app ID does not match the license key's app\n  ID.\n\nI have tried creating a new license key with Application ID \/ Bundle ID as the name of the file i.e. CommandLineBarcodeScannerImageProcessingSample.py but still getting the same error.\nSame goes with CommandLineBarcodeScannerCameraSample.py but all c scripts run fine.\nIn FAQs of scandit it is mentioned that I should use program_invocation_name as bundle id. Is there something I am missing? Any suggestion would be very helpful","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":621,"Q_Id":60665224,"Users Score":0,"Answer":"if you use android app, you need to check the app id inside the object defaultConfig on key androindId. That value must match with the bundle ID in scandist dashboard.","Q_Score":0,"Tags":"python,barcode-scanner","A_Id":65236543,"CreationDate":"2020-03-13T05:22:00.000","Title":"Scandit python code 15 Your app ID does not match the license key's app ID","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a barcode scanner, scandit 5.14.2 on Linux with a trial license. I am trying to run a python module sample i.e. CommandLineBarcodeScannerImageProcessingSample.py but I am getting the following error\n\nProcessing frame failed with code 15: The Scandit SDK license\n  validation failed. Your app ID does not match the license key's app\n  ID.\n\nI have tried creating a new license key with Application ID \/ Bundle ID as the name of the file i.e. CommandLineBarcodeScannerImageProcessingSample.py but still getting the same error.\nSame goes with CommandLineBarcodeScannerCameraSample.py but all c scripts run fine.\nIn FAQs of scandit it is mentioned that I should use program_invocation_name as bundle id. Is there something I am missing? Any suggestion would be very helpful","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":621,"Q_Id":60665224,"Users Score":1,"Answer":"I know it\u00b4s a little bit late, but I think I found a solution for the problem.\nI experienced exactly the same issues and could fix it with creating a new licencse key with the Bundle ID 'python3'. Then you have to use the generated license key in your python samples.\nLet me know if that worked.","Q_Score":0,"Tags":"python,barcode-scanner","A_Id":61222436,"CreationDate":"2020-03-13T05:22:00.000","Title":"Scandit python code 15 Your app ID does not match the license key's app ID","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using VScode with python code and I have a folder with sub-directories (2-levels deep) containing python tests. \nWhen I try \"Python: Discover Tests\" it asks for a test framework (selected pytest) and the directory in which tests exist. At this option, it shows only the top-level directories and does not allow to select a sub-directory. \nI tried to type the directory path but it does not accept it. \nCan someone please help on how to achieve this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2111,"Q_Id":60665350,"Users Score":0,"Answer":"Try opening the \"Output\" log (Ctrl+Shift+U) and run \"Python: Discover Tests\". Alternatively, you may type pytest --collect-only into the console. Maybe you are experiencing some errors with the tests themselves (such as importing errors).\nAlso, make sure to keep __init__.py file in your \"tests\" folder.\nI am keeping the pytest \"tests\" folder within a subdirectory, and there are no issues with VS Code discovering the tests.","Q_Score":11,"Tags":"python,visual-studio-code","A_Id":68447227,"CreationDate":"2020-03-13T05:38:00.000","Title":"How do I select a sub-folder as a directory containing tests in Python extension for Visual studio 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 am using VScode with python code and I have a folder with sub-directories (2-levels deep) containing python tests. \nWhen I try \"Python: Discover Tests\" it asks for a test framework (selected pytest) and the directory in which tests exist. At this option, it shows only the top-level directories and does not allow to select a sub-directory. \nI tried to type the directory path but it does not accept it. \nCan someone please help on how to achieve this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2111,"Q_Id":60665350,"Users Score":0,"Answer":"There are two options. One is to leave the selection as-is and make sure your directories are packages by adding __init__.py files as appropriate. The other is you can go into your workspace settings and adjust the \"python.testing.pytestArgs\" setting as appropriate to point to your tests.","Q_Score":11,"Tags":"python,visual-studio-code","A_Id":60713976,"CreationDate":"2020-03-13T05:38:00.000","Title":"How do I select a sub-folder as a directory containing tests in Python extension for Visual studio 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 have a data set of 1500 records with two classes which are imbalanced. Class 0 is 1300 records while Class 1 is 200 records, hence a ratio of ard 6.5:1.\nI built a random forest with this data set for classification. I know from past experience, if I use the whole data set, the recall is pretty low, which is probably due to the imbalanced class.\nSo I decided to undersample Class 0. My steps are as follows:\n\nRandomly split the data set into train & test set of ratio 7:3 (hence 1050 for training and 450 for test.)\nNow the train set has ~900 data of Class 0 ~100 for Class 1. I clustered ~900 data of Class 0, and undersample it (proportionally) to ~100 records.\n\nSo now train set ~100 Class 0 + ~100 Class 1 = ~200 records in total while the test set is 70 Class 0 + 380 Class 1 = 450 records in total.\nHere comes my questions:\n1) Are my steps valid? I split the train\/test first and then undersample the majority class of the train set.\n2) Now my train set (~200) < test set (450). Does it make sense?\n3) The performance is still not very good. Precision is 0.34, recall is 0.72 and the f1 score is 0.46. Is there any way to improve? Should I use CV?\nMany thanks for helping!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":243,"Q_Id":60667970,"Users Score":0,"Answer":"1) Are my steps valid? I split the train\/test first and then\n  undersample the majority class of the train set.\n\nYou should split train and test so the class balance is preserved in both. If in your whole dataset ratio is 6.5:1 it should be the same both in train and test. \nYes, you should split it before undersampling (no need to undersample test cases), just remember to monitor multiple metrics (e.g. f1 score, recall, precision were already mentioned and you should be fine with those) as you are training on different distribution than test.\n\n2) Now my train set (~200) < test set (450). Does it make sense?\n\nYes it does. You may also go for oversampling on training dataset (e.g. minority class is repeated at random to match the number of examples from majority). In this case you have to split before as well otherwise you may spoil your test set with training samples which is even more disastrous.\n\n3) The performance is still not very good. Precision is 0.34, recall is 0.72 and the f1 score is 0.46. Is there any way to improve? Should I use CV?\n\nIt depends on specific problem, what I would do:\n\noversampling instead of undersampling - neural networks need a lot of data, you don't have many samples right now\ntry other non-DL algorithms (maybe SVM if you have a lot of features? RandomForest otherwise might be a good bet as well)\notherwise fine tune your neural network (focus especially on learning rate, use CV or related methods if you got the time) \ntry to use some pretrained neural networks if available for the task at hand","Q_Score":1,"Tags":"python,tensorflow,machine-learning,data-science,imbalanced-data","A_Id":60670419,"CreationDate":"2020-03-13T09:33:00.000","Title":"Is it feasible to have the training set < the test set after undersampling the majority class?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am facing issue with SQLite vulnerability which fixed in SQLite version 3.31.1.\nI am using the python3.7.4-alpine3.10 image, but this image uses a previous version of SQLite that isn't patched.\nThe patch is available in python3.8.2-r1 with alpine edge branch but this image is not available in docker hub.\nPlease help how can i fix this issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":60668371,"Users Score":0,"Answer":"Your choices are limited to two options:\n\nWait for the official patched release\nPatch it yourself\n\nOption 1 is easy, just wait and the patch will eventually propagate through to docker hub. Option 2 is also easy, just get the code for the image from github, update the versions, and run the build yourself to produce the image.","Q_Score":1,"Tags":"python-3.x,sqlite,docker,security","A_Id":60668536,"CreationDate":"2020-03-13T10:02:00.000","Title":"how to fix CVE-2019-19646 Sqlite Vulnerability in python3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 1 dimensions scatter plot that marks the value of my data. How should I find the centroid from my graph","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":60669901,"Users Score":0,"Answer":"If it's one dimension then just take the average.","Q_Score":0,"Tags":"python-3.x,data-analysis","A_Id":60669917,"CreationDate":"2020-03-13T11:45:00.000","Title":"How do find the centroid from the 1 dimension scatter plot graph","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an AttributeError: module 'tensorflow_core.python.keras.api._v2.keras.losses' has no attribute 'softmax_cross_entropy' error when using tf.losses.softmax_cross_entropy. Could someone help me?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5641,"Q_Id":60670924,"Users Score":0,"Answer":"The tf.losses now point to tf.keras.losses. You can get identical behavior by using\ntf.losses.categorical_crossentropy with from_logits set to True","Q_Score":1,"Tags":"python,tensorflow,keras,cross-entropy","A_Id":60676246,"CreationDate":"2020-03-13T12:58:00.000","Title":"AttributeError: module 'tensorflow_core.python.keras.api._v2.keras.losses' has no attribute 'softmax_cross_entropy'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an image of shape (32, 3, 32, 32). I know it's of the form (batch_size, Channel, Height, Width).\nQ. How do I convert it to be (32, 32, 32) overriding the Channel?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":142,"Q_Id":60671971,"Users Score":0,"Answer":"If you want to convert to grayscale you could do this:\nimage.mean(dim=1)","Q_Score":0,"Tags":"python,image-processing,dataset,pytorch","A_Id":60672798,"CreationDate":"2020-03-13T14:09:00.000","Title":"How to reshape an Image in pytorch","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Both views.py and xyz.py are in app folder.But when I import xyz.py\ndjango says \"ModuleNotFound\"","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":60672732,"Users Score":0,"Answer":"Try using from . import xyz this should fix that error","Q_Score":0,"Tags":"python,django","A_Id":60672892,"CreationDate":"2020-03-13T15:00:00.000","Title":"Windows-Django- can't import own modules-says module not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to define a field in my Model, which is supposed to host a valid dir path on server-side.\nBasically just a string which should be:\n1) a formally valid unix-like dir path\n2) an existing dir path\nTried with FilePathField with options allow_files=False, allow_folders=True . \nBut when I try to create a new instance of the model from the django admin CRUD, I'm getting an error claiming that the initial value of the field (which is by default an empty string) is a not existing path...\nI have a feeling this is not the right way. Maybe another field type could be more suitable? Maybe it should be just a simple string? (in this case, shall I be able to define correctly the required validators?)\nThanks for any hint,\nThomas","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":351,"Q_Id":60674719,"Users Score":0,"Answer":"Maybe try to loop through those file-systems and specify them under a function path and also loop through the sub-paths separately, this should show u the entire subtree as it would run every single one at a time separately. I think u r hving problem because Django is not running all the possible sub-file-systems.\nHope that helps","Q_Score":0,"Tags":"python,django,django-admin,django-model-field","A_Id":60683256,"CreationDate":"2020-03-13T17:16:00.000","Title":"Django - Which model field for dir path?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to define a field in my Model, which is supposed to host a valid dir path on server-side.\nBasically just a string which should be:\n1) a formally valid unix-like dir path\n2) an existing dir path\nTried with FilePathField with options allow_files=False, allow_folders=True . \nBut when I try to create a new instance of the model from the django admin CRUD, I'm getting an error claiming that the initial value of the field (which is by default an empty string) is a not existing path...\nI have a feeling this is not the right way. Maybe another field type could be more suitable? Maybe it should be just a simple string? (in this case, shall I be able to define correctly the required validators?)\nThanks for any hint,\nThomas","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":351,"Q_Id":60674719,"Users Score":0,"Answer":"After some tests, I realized this model field type actually is used for fields which are assigned a value by browsing among files\/dirs that already exist in the filesystem. Hence, the error was due to the path parameter I used (which I chose randomly) that didn't exist in the filesystem.\nHowever, this Model field still fits my purposes, because having to choose a directory that already exists, certainly forces the user to assign a value which satisfies both validation points above mentioned.\nThere is even the possibility to make a \"deep browsing\", by including the entire sub dir tree. Just use the recursive=True  option.\nSo\nrepository = models.FilePathField(\"repo_root\/\", allow_files=False, allow_folders=True, recursive=True)\nwill do the trick.\nFor sub trees with many directories the page might become unresponsive.\nThomas","Q_Score":0,"Tags":"python,django,django-admin,django-model-field","A_Id":60678042,"CreationDate":"2020-03-13T17:16:00.000","Title":"Django - Which model field for dir path?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to define a field in my Model, which is supposed to host a valid dir path on server-side.\nBasically just a string which should be:\n1) a formally valid unix-like dir path\n2) an existing dir path\nTried with FilePathField with options allow_files=False, allow_folders=True . \nBut when I try to create a new instance of the model from the django admin CRUD, I'm getting an error claiming that the initial value of the field (which is by default an empty string) is a not existing path...\nI have a feeling this is not the right way. Maybe another field type could be more suitable? Maybe it should be just a simple string? (in this case, shall I be able to define correctly the required validators?)\nThanks for any hint,\nThomas","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":351,"Q_Id":60674719,"Users Score":0,"Answer":"try saving the path(the string) in a dictionary first as it is a path, then saving it in the server as a dictionary it would work and would be a whole lot easier.","Q_Score":0,"Tags":"python,django,django-admin,django-model-field","A_Id":60675416,"CreationDate":"2020-03-13T17:16:00.000","Title":"Django - Which model field for dir path?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am doing performance\/memory analysis on a certain method that is wrapped with the functools.lru_cache decorator. I want to see how to inspect the current size of my cache without doing some crazy inspect magic to get to the underlying cache.\nDoes anyone know how to see the current cache size of method decorated with functools.lru_cache?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":756,"Q_Id":60675832,"Users Score":6,"Answer":"Digging around in the docs showed the answer is calling .cache_info() on the method.\n\nTo help measure the effectiveness of the cache and tune the maxsize parameter, the wrapped function is instrumented with a cache_info() function that returns a named tuple showing hits, misses, maxsize and currsize. In a multi-threaded environment, the hits and misses are approximate.","Q_Score":3,"Tags":"python","A_Id":60675833,"CreationDate":"2020-03-13T18:51:00.000","Title":"How to see current cache size when using functools.lru_cache?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to import a Python module (fiasco). I cloned it from GitHub and everything appeared to be working fine. Importing it works, but when I try to type, for example iron = fiasco.Element('iron', [1e4, 1e6, 1e8]*u.K), I get the error module 'fiasco' has no attribute 'Element'. I am using Spyder's iPython console. This also fails if I start iPython from the terminal, but works if I start python3 from the terminal. \nI had done this on two different computers - on one, it worked at first, but started giving me the same error after I restarted the kernel. On the other, it never worked at all. \nIf it helps: after importing, I tried typing fiasco. When I did this on the computer where it originally worked, the output was <module 'fiasco' from '\/Users\/shirman\/fiasco\/fiasco\/__init__.py'>. Now, and on the computer it never worked on, it just says <module 'fiasco' (namespace)>. So maybe this has something to do with paths? \nAddition: sys.path points to \/Users\/shirman, and several paths within \/Users\/shirman\/anaconda3. The fiasco folder is in \/Users\/shirman.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":101,"Q_Id":60677713,"Users Score":2,"Answer":"You have inadvertently created a namespace package due to your sys.path setting. Namespace packages are directories without an __init__.py in the Python search path and allow loading of submodules or -packages from different paths (e.g. path1\/foo\/a.py and path2\/foo\/b.py can be imported as foo.a and foo.b).\nThe problem is that import fiasco finds \/Users\/shirman\/fiasco first and imports it as a namespace package. If you set sys.path such that \/Users\/shirman\/fiasco comes before \/Users\/shirman, the importer finds the actual package \/Users\/shirman\/fiasco\/fiasco first.\nNamespace packages are a Python 3.3 feature, so either the other machine had a different sys.path setting, a really old Python 3 installation, or you were using Python 2.","Q_Score":1,"Tags":"python","A_Id":60678229,"CreationDate":"2020-03-13T21:56:00.000","Title":"Module imports, but doesn't have any attributes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to integrate Stripe into a Django project and I noticed that there's a stripe-python package. This runs entirely synchronously though. Is it a bad idea to make these types of call from the main web server? Since it makes external calls, this presumably means the webserver will be blocked while we wait for a response, which seems bad.\nSo, should I be running this from something like Celery? Or is it fine to run on the main thread?  Anyone have experience with this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":269,"Q_Id":60678409,"Users Score":1,"Answer":"Based on a previous project, I think using it synchronously is much better from a design prospective. WIth most payments, you want to keep the user on the page until the payment goes through so they know for certain that there was no issue with the payment and you can handle any issues with the payment right there rather than taking the task from the queue and handling it. If you think about most payments you have done online, these all are happening in the main thread for this reason","Q_Score":2,"Tags":"python,django,stripe-payments","A_Id":60710043,"CreationDate":"2020-03-13T23:32:00.000","Title":"stripe-python, should it be async?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have read lots of documentation and articles about using signals in Django, but I cannot understand the concept.  \n\nWhat is the purpose of using signals in Django?\nHow does it work?\n\nPlease explain the concept of signals and how to use it in Django code.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":406,"Q_Id":60679719,"Users Score":2,"Answer":"The Django Signals is a strategy to allow decoupled applications to get notified when certain events occur. Let\u2019s say you want to invalidate a cached page everytime a given model instance is updated, but there are several places in your code base that this model can be updated. You can do that using signals, hooking some pieces of code to be executed everytime this specific model\u2019s save method is trigged.\nAnother common use case is when you have extended the Custom Django User by using the Profile strategy through a one-to-one relationship. What we usually do is use a \u201csignal dispatcher\u201d to listen for the User\u2019s post_save event to also update the Profile instance as well.","Q_Score":2,"Tags":"django,python-3.x,django-models,django-signals","A_Id":60679829,"CreationDate":"2020-03-14T04:25:00.000","Title":"Why use signals in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Gated Reccurent unit (GRU) model and I made two versions of it each are slightly different. When I ran both, Version 1 gave me a  validation mean squared error (MSE) of 0.0013, while Version 2 gave me 0.0015. This means Version 1 is a better model. But when I ran model.evaluate(X_test,y_test) with the test dataframe, Version gave me an MSE value of 0.0027 while Version 2 gave me 0.0018.\nMy question is which version is considered better, the version which gives a better Validation MSE or the model that gave a lower MSE when using the Test dataframe for predicting\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":60679791,"Users Score":1,"Answer":"First of all, you can not cheat on the test set, and choose the model so that it gives the best results on the test. Validation is meant to be used for that intention, and the test is only there to check validation and test are getting along each other.\nYou did not mention the size of the training, validation, and test. The size of the data you use is very important to be as big enough to represent the real distribution of the data, in training, validation, and the test.\nOn the other hand, the way you sample the data should be done in a way, that three sets have the same distribution. \nLast, by not least, you are comparing two results which differ about 0.0002 in MSE. I do not believe it gives you good judgment on which one is better.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,keras","A_Id":60680248,"CreationDate":"2020-03-14T04:40:00.000","Title":"Validation loss or model evaluate","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Windows10 and wants to run my python script by cmd\nThe command:\npython file.py\nreturn the message: \npython: can't open file 'file.py': [Errno 2] No such file or directory\nbut when I run \n python C:\\Python37\\projects\\file.py\nit's run properly\nalso, I added  C:\\Python37\\projects to the PATH, but it doesn't help","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":14545,"Q_Id":60682364,"Users Score":0,"Answer":"Open your script in another code editor like VS and check extension. It usually keeps txt behind py and that is why you get an error. Or in Options, if you use Windows, Hide extensions for known file types.","Q_Score":0,"Tags":"python","A_Id":71170792,"CreationDate":"2020-03-14T11:46:00.000","Title":"Can't open file 'file.py': [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":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using Windows10 and wants to run my python script by cmd\nThe command:\npython file.py\nreturn the message: \npython: can't open file 'file.py': [Errno 2] No such file or directory\nbut when I run \n python C:\\Python37\\projects\\file.py\nit's run properly\nalso, I added  C:\\Python37\\projects to the PATH, but it doesn't help","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":14545,"Q_Id":60682364,"Users Score":0,"Answer":"Check out the environment you have done your installation. Then call the path of your  directory rightly.\n\ncd C:\\Python37\\projects\n\n\npython file.py","Q_Score":0,"Tags":"python","A_Id":71456835,"CreationDate":"2020-03-14T11:46:00.000","Title":"Can't open file 'file.py': [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":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am coding a PyQt5 based GUI application needs to be able to create and run arbitrary Python scripts at runtime. If I convert this application to  a .exe, the main GUI Window will run properly. However, I do not know how I can run the short .py scripts that my application creates. Is it possible to runs these without a system wide Python installation?\n\nI don't want ways to compile my python application to exe. This problem relates to generated .py scripts","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":58,"Q_Id":60684325,"Users Score":2,"Answer":"No, to run a Python file you need an interpreter.\nIt is possible that your main application can contain a Python interpreter so that you don't need to depend on a system-wide Python installation.","Q_Score":1,"Tags":"python,python-3.x","A_Id":60684407,"CreationDate":"2020-03-14T15:27:00.000","Title":"Run generated .py files without python installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to write my first Python code in Lambda function that will check whether i'm able to SSH (port 22) in to an EC2 instance.\nI have created an EC2 instance with Security Group 22 CidrIP my public IP\n then, created a Lambda function with python 3.8 as runtime in the same account\nNow, through code i,m trying to SSH into EC2 by passing EC2 Public IP, Username, Key pair\nand execute one command, example: sudo su\nQuestion:\n\nWhere should i place my keypair?\nWhat is the code to SSH in to EC2 from lambda funtion?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":4179,"Q_Id":60686223,"Users Score":6,"Answer":"The first thing I would say is that you should almost never SSH from Lambda into EC2. There are much better ways to remotely run scripts on EC2, including:\n\nSSM Run Manager\nExpose an API on the EC2 instance and call that API\n\nIf you really want to do this, perhaps for some academic reason, then:\n\nstore the keypair in Secrets Manager and give the Lambda permission to read it\nuse a Python package such as Fabric or Paramiko\n\n[Update: it seems that you're trying to validate that SSH access is blocked]\nThe best way to validate security groups is to use the EC2 API, describe the instance(s), enumerate the security groups and their inbound rules. If you don't trust that approach then you could try to SSH to the instance using the method I proposed above (though you only need to try to connect for the test to be useful, presumably).\nThe problem you're going to have is that the security groups could potentially have been set up to block all SSH access (which is the default, by the way) with the exception of a single 'attacker' IP address which is allowed. Your Lambda SSH connection attempt will fail, because it's not coming from that one 'attacker' IP, yet your Lambda test will report \"I cannot access the web server over SSH, test is successful\". That's an invalid test.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-ec2,ssh,aws-lambda","A_Id":60686978,"CreationDate":"2020-03-14T18:50:00.000","Title":"How to ssh into EC2 instance from lambda function","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 plot a graph for the data set which has only categorical data(no numeric data) so what library I can use to plot the graph for categorical data on both axes.  I have used seaborn.stripplot() but it also requires one numeric data for an axis.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":729,"Q_Id":60690585,"Users Score":0,"Answer":"I have not tried it - but could you create a Enum with the Categorical data for 1 of the axis's. Obviously it can not be dynamic values.\nYou may be able get that to work.\nJust a thought however - I HAVE NOT tried this.","Q_Score":0,"Tags":"python,data-science,data-analysis","A_Id":60690847,"CreationDate":"2020-03-15T07:19:00.000","Title":"Is there a graph to plot non numeric data (categorical data) on both axes in Jupyter Notebook(Python)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I was training my neural network there is a sudden drop in validation accuracy during the 8th epoch what does this mean?\nTrain for 281 steps, validate for 24 steps\nEpoch 1\/10\n281\/281 [==============================] - 106s 378ms\/step - loss: 1.5758 - accuracy: 0.8089 - val_loss: 1.8909 - val_accuracy: 0.4766\nEpoch 2\/10\n281\/281 [==============================] - 99s 353ms\/step - loss: 1.5057 - accuracy: 0.8715 - val_loss: 1.7364 - val_accuracy: 0.6276\nEpoch 3\/10\n281\/281 [==============================] - 99s 353ms\/step - loss: 1.4829 - accuracy: 0.8929 - val_loss: 1.5347 - val_accuracy: 0.8398\nEpoch 4\/10\n281\/281 [==============================] - 99s 353ms\/step - loss: 1.4445 - accuracy: 0.9301 - val_loss: 1.5551 - val_accuracy: 0.8047\nEpoch 5\/10\n281\/281 [==============================] - 99s 353ms\/step - loss: 1.4331 - accuracy: 0.9412 - val_loss: 1.5043 - val_accuracy: 0.8659\nEpoch 6\/10\n281\/281 [==============================] - 97s 344ms\/step - loss: 1.4100 - accuracy: 0.9639 - val_loss: 1.5562 - val_accuracy: 0.8151\nEpoch 7\/10\n281\/281 [==============================] - 96s 342ms\/step - loss: 1.4140 - accuracy: 0.9585 - val_loss: 1.4935 - val_accuracy: 0.8737\nEpoch 8\/10\n281\/281 [==============================] - 96s 341ms\/step - loss: 1.4173 - accuracy: 0.9567 - val_loss: 1.7569 - val_accuracy: 0.6055\nEpoch 9\/10\n281\/281 [==============================] - 96s 340ms\/step - loss: 1.4241 - accuracy: 0.9490 - val_loss: 1.4756 - val_accuracy: 0.9023\nEpoch 10\/10\n281\/281 [==============================] - 96s 340ms\/step - loss: 1.4067 - accuracy: 0.9662 - val_loss: 1.4167 - val_accuracy: 0.9648","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1163,"Q_Id":60691599,"Users Score":3,"Answer":"Sudden drops in validation loss and training loss occur due to the batch training; in essence, the convergence would be smooth only if we trained with the entire dataset, not with batches. Therefore, it is normal to see such drops (both for training and for validation).\n\nval_loss: 1.4935 - val_accuracy: 0.8737 (Previous epoch)\nval_loss: 1.7569 - val_accuracy: 0.6055 (Epoch with drop)\nval_loss: 1.4756 - val_accuracy: 0.9023 (Next epoch)\n\nIf you take a look at the validation loss, it merely increased with 0.26; however, this resulted in a 27% decrease in your accuracy. In this case, it is due to the fact that your model is not certain when it makes a prediction (at least at this stage of training).\nImagine that you have a binary classification model(between apples and oranges). At each prediction, when the ground truth is an apple, the network is 51% confident that the image is of an apple. We have the ground_truth apple, and as Keras does behind the curtains, the default confidence threshold is 50%. Then all the predictions are good and you have a good accuracy.\nHowever, now comes the 'problematic' epoch. Due to the changed values of the weights of your neural network after another epoch of training, when you predict on your validation dataset, you get a confidence of 48-49% for each ground_truth apple, and again, since the threshold is 50%, you get much poorer accuracy than the previous epoch.\nThis particular case that you are experiencing, as you can now infer from the previous explanation, does not affect the loss so much, but the accuracy. It does not affect the loss that much during backpropagation, because a difference in the confidence prediction between 49% and 51% when computing the loss is not a very significant difference in the overall loss(as you see in your case, only a 0.26%). In the end, even at the 'previous epoch', when the model predicted correctly an apple, the neural network was not that extremely confident, by yielding only 51% confidence for an apple, not 95% for instance.","Q_Score":2,"Tags":"python,tensorflow,machine-learning,keras,neural-network","A_Id":60691955,"CreationDate":"2020-03-15T09:50:00.000","Title":"Sudden drop in validation accuracy during training","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been programming with python for about half a year, and I would like to try manim ( the animation programme of 3blue1brown from youtube), but I am not sure where to start. I have not installed it, but I have tried to read up on it. And to be honest I do not understand much of the requirements of the program, and how to run it.\nGoogle has left me without much help, so I decided to check here to see if anyone here is able to help.\nFrom what I understand, you run manim directly in python and the animations are based on a textfile with code i assume is LaTex. I have almost no experience with python itself, but I have learned to use it through Thonny, and later Pycharm.\nMy main questions are: (Good sources to how to do this without being a wizard would be really helpful if they exist\u263a\ufe0f)\n\nIs it possible to install manim in pycharm, and how? Do i need some extra stuff installed to pycharm in order to run it? (I run a windows 64-bit computer)\nIf i manage to do this in pycharm, Will I then be able to code the animations directly in pycharm (in .py or .txt files), or is it harder to use in pycharm?\n\nAll help or insights is very appreciated As I said I am not extremely knowledgeable in computers, but I am enjoying learning how to code and applications of coding","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2286,"Q_Id":60691915,"Users Score":0,"Answer":"Yes, you can\n1.Write your code in pycharm\n2.save it\n3.copy that .py file to where you installed manim. In my case, it is\n\nThis pc>> C drive >> manim-master >> manim-master\n\n4.select on the path and type \"cmd\" to open terminal from there\n\nType this on the terminal\n\npython -m manim -pql projectname.py\nThis will do.\nTo play back the animation or image, open the media folder.","Q_Score":3,"Tags":"python,pycharm,manim","A_Id":68372616,"CreationDate":"2020-03-15T10:28:00.000","Title":"Can manim be used in pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"FFmpeg is installed in C:\\FFmpeg, and I put C:\\FFmpeg\\bin in the path. Does anyone know how to fix?\nThanks!","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":2107,"Q_Id":60693223,"Users Score":-1,"Answer":"You added C:\\FFmpeg\\bin\\ffmpeg.exe to your path, instead, you need to add only the directory:\nC:\\FFmpeg\\bin\\","Q_Score":0,"Tags":"python,ffmpeg,path","A_Id":60694382,"CreationDate":"2020-03-15T13:08:00.000","Title":"FFmpeg is in Path, but running in the CMD results in \"FFmpeg not recognized as internal or external command\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am writing a program which I will send to someone as a single .py file. \nI want to be able to include sound in this program which the person can hear without requiring extra wav\/mp3 files as well. Is this possible? I'm open to using external modules, etc, just as long as it can all be included in one file when I send it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":889,"Q_Id":60693983,"Users Score":0,"Answer":"You could use the library winsound to include your audio as a string of bytes in your .py file.","Q_Score":1,"Tags":"python,python-3.x,audio","A_Id":60694104,"CreationDate":"2020-03-15T14:33:00.000","Title":"How to play any kind of sound in python without using 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":0,"Web Development":0},{"Question":"I made an android app using python-kivy (Buildozer make it to apk file)\nNow I want to put an image for the icon of the application. I mean the picture for the app-icon on your phone.\nhow can I do this? I cannot find any code in kv","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":867,"Q_Id":60695079,"Users Score":1,"Answer":"Just uncomment icon.filename: in the buildozer spec file and write a path to your icon image.","Q_Score":0,"Tags":"python,kivy,buildozer,appicon","A_Id":60695266,"CreationDate":"2020-03-15T16:27:00.000","Title":"How to put an icon for my android app using kivy-buildozer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to format an SQL query, and it looks like this:\ns += \" t{}.{} = '{}' and\".format(t_c, filter_c, filter_value)\nbut when the filter_value is something like m's it will result in \npsycopg2.errors.SyntaxError: syntax error\nif I use the double quote, it will say there's no such column\nAny way I can resolve this problem, please?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":210,"Q_Id":60696210,"Users Score":0,"Answer":"Caused by injection vulnerability. Use parameters for filter_value and let the database API handle it.\nIf the table\/schema names are coming from user input, whitelist those too. Parameters aren't possible for table names).","Q_Score":0,"Tags":"python,python-3.x,postgresql,psycopg2","A_Id":60696279,"CreationDate":"2020-03-15T18:23:00.000","Title":"How to template sql with python and deal with sql composition problem?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a huge database of over 20 million rows. I can export the whole database (which takes hours), but when I try to filter the data using python (pandas) pycharm fails (due to memory issues).\nIs there a way to export the database in batches of 2 million rows for an example? Export 2mil, then other 2mil and have 10 files of 2 million rows at the end? This way I can filter every file using python (pandas) and I won't have memory issues.\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1609,"Q_Id":60696669,"Users Score":0,"Answer":"You can use pg_dump to only extract one or more tables or exclude tables if that is going to help","Q_Score":0,"Tags":"python,sql,database,postgresql,csv","A_Id":60696938,"CreationDate":"2020-03-15T19:15:00.000","Title":"How to export huge postgresql database in batches?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to google colab.\nI'm trying to do deep learning there.\nI have written a class to create and train a LSTM net using just python - not any specific deep learning library as tensorflow, pytorch, etc.\nI thought I was using a gpu because I had chosen the runtime type properly in colab.\nDuring the code execution, however, I was sometimes getting the message to quit gpu mode because I was not making use of it.\nSo, my question: how can one use google colab gpu, using just plain python, without special ai libraries? Is there something like \"decorator code\" to put in my original code so that the gpu get activated?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1746,"Q_Id":60696987,"Users Score":1,"Answer":"It's just easier to use frameworks like PyTorch or Tensorflow.\nIf not, you can try pycuda or numba, which are closer to \"pure\" GPU programming. That's even harder than just using PyTorch.","Q_Score":4,"Tags":"python,deep-learning,gpu,google-colaboratory","A_Id":60701833,"CreationDate":"2020-03-15T19:50:00.000","Title":"How to activate google colab gpu using just plain python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"QUESTION DELETED.QUESTION DELETED.QUESTION DELETED.QUESTION DELETED.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":60698227,"Users Score":0,"Answer":"Another thing: Since your'e using a list view, you might want to post a portion of your template code here in your question. As a list view, you have to ensure that you're properly looping through the object you're sending to the template as context.\nIs everything else showing up in your template rendering as you intend? Is it just the image that isn't showing properly?","Q_Score":0,"Tags":"python,django,django-models","A_Id":60698325,"CreationDate":"2020-03-15T22:17:00.000","Title":"Django load an imageField in a template","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm looking for a way to simulate an active session on a website using Python. What I mean by that, is I want to create a software, which makes the website think that an actual user with an actual browser has the website open. I've found urllib3 and it's request.urlopen methon, but it seems that this only reads the content provided from url and closes the connection. Thanks for any suggestions","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":60698928,"Users Score":0,"Answer":"You can try simulate browser requests to get necessary cookies for authentication. Google Chrome Dev Tools and requests python lib will do the job.\nSome websites have another way to handle sessions, but I believe the majority is using cookies set through post requests.","Q_Score":0,"Tags":"python,url,connection,simulate","A_Id":60699011,"CreationDate":"2020-03-16T00:07:00.000","Title":"Simulate active session on a website with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When updating Conda, I am getting the below error:\n\nPreparing transaction: done\n  Verifying transaction: done\n  Executing transaction: failed\n  ERROR conda.core.link:_execute(502): An error occurred while uninstalling package 'defaults::conda-4.5.4-py36_0'.\n  PermissionError(13, 'Access is denied')\n  Attempting to roll back.\nRolling back transaction: done\nPermissionError(13, 'Access is denied')","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":60703096,"Users Score":0,"Answer":"try to update in 'run as administrator'","Q_Score":0,"Tags":"python,anaconda,conda","A_Id":60706847,"CreationDate":"2020-03-16T09:09:00.000","Title":"Access Denied When Updating Conda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a button that generates a report in two variables: one has a short version of the information and the other contains a detailed version on it.\nThe view renders the information of the short one with a template, let's call it template one. I need to place a button in template one that allows to see the content of the second variable in a different template and also in a new browser tab.\nSince the information is not stored in the database (so I cant' address it with ids) how can I pass the variable that contains the detailed report information (hundreds of rows)?\nIs it okay to try to pass it using the template tag 'url'...? (It feels like a wrong approach)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":86,"Q_Id":60703115,"Users Score":1,"Answer":"I think your challenge will be in storing the data client-side until the client wants to view it. There are plenty of ways to do this with Javascript (Vue JS is a good option), but you'll have to get creative if you're trying to do it completely in a template. I can think of a few of options:\n\nAvoid a Second Template: Would it be possible for you to populate a hidden DIV element with the second set of data, then simply have a button to toggle the visibility of that DIV? That would be the easiest, but perhaps it would not look nice for what you want to achieve. If you use Bootstrap to make your template highly responsive, you can certainly achieve this.\nI'm not sure where your data is coming from, but it might be simpler to just re-compute in Python to generate the second template. Unless the data is in the megabytes, your client likely won't notice a huge lag, especially if it's opening into a new tab.\nAPI - If you aren't already using Django Rest Framework, it will add a whole other layer of complication to the project. However, this will allow you to get far more creative with how you display your information. You can always take a hybrid approach where most of your stuff is still rendered by Django, then build a few API endpoints for that stuff which really needs them.\n\nI'm quite the novice at Python, Django, Javascript, Postgres, and Vue JS, but by learning just enough about each of them I can see how I'll be able to accomplish most of my design goals, even if I have to constantly look up the code. I love how straight-forward Django's templates are, but when I shifted to DRF and Vue, I gained far more flexibility (albeit with far more complexity).","Q_Score":0,"Tags":"python,django","A_Id":60703646,"CreationDate":"2020-03-16T09:11:00.000","Title":"How to render the content of a variable in a different template with Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a dataset of 1.2mil single sentence descriptions (5-50 words) and I want to cluster these into n clusters. For vector conversion, I want to use doc2vec to get 1.2mil equal size vectors. However, I'm not sure what should be the size parameter. I've read, it should be between 100-300 however since each document, in this case, has fewer tokens (words) should the vector be small?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":286,"Q_Id":60704127,"Users Score":0,"Answer":"Your data \u2013 over a million texts, and perhaps tens-of-millions of words \u2013 is certainly large enough to try a default vector-size of 100 dimensions. \nPeople with smaller datasets may need to try even smaller vector-sizes, but that's getting far from the cases where Doc2Vec ('Paragraph Vectors') works well. \nBut the actual best size for your dataset & goals is something you have to find out via experimentation. (If your dataset is dominated by 5-word texts, and if your vocabulary of unique words is quite small, maybe you'll need to try lower sizes, too.) \nThere's no one answer \u2013 the variety of your texts\/vocabulary, & the patterns in your data, will affect the best choice. Only having your own project-specific repeatable evaluation, which you can use to compare alternate choices, can guid you to what's best.","Q_Score":0,"Tags":"python,cluster-analysis,gensim,doc2vec","A_Id":60709966,"CreationDate":"2020-03-16T10:21:00.000","Title":"tuning size parameter for doc2vec","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a socket program to create a simple server. \nWhen I write ip = socket.gethostbyname(socket.gethostname()) and then I print ip it prints 127.0.1.1\nWhy does this keep happening?\nMy device is connected to a mobile hotspot connection still the ip address remains of a local host.\nI am using ubuntu 19.04 OS","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1395,"Q_Id":60707849,"Users Score":0,"Answer":"The problem is that a host has multiple interfaces. It is not a problem is you use a true DNS or a carefully handwritten \/etc\/host file because then the system will look there to find the translation. But depending on the configuration, the host name can be bound to all the available interfaces, including the loopback one. And gethostbyname returns the address of the first of those interfaces in its own order.\nTo make sure of that, you should use gethostbyname_ex which returns a list of all the interfaces, and you should find the hostspot connected one, in addition to the loopback one.","Q_Score":0,"Tags":"python,sockets,ubuntu,localhost,ip-address","A_Id":60708187,"CreationDate":"2020-03-16T14:32:00.000","Title":"Why does socket.gethostbyname(socket.gethostname) binds only to local ip address?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently I am making a very simple interface which asks user to input parameters for a test and then run the test. The test is running brushless dc motor for several minutes. So when the run button is pressed the button is engaged for the time period till the function is finished executing. I have another stop button which should kill the test but currently cant use it since the run button is kept pressed till the function is finished executing and stop button cant be used during the test. I want to stop the test with pressing the stop button even if the run button function is currently being executed. The run button should release and the function should continuously check the stop function for stopping the test. Let me know how this can be executed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":60709906,"Users Score":0,"Answer":"Your problem is that all your code it taking place sequentially in a single thread. Once your first button is pressed, all of the results of that pressing are followed through before anything else can happen.\nYou can avoid this by running the motor stuff in a separate thread. Your stop button will then need to interrupt that thread.","Q_Score":0,"Tags":"python,kivy,kivy-language","A_Id":60711486,"CreationDate":"2020-03-16T16:42:00.000","Title":"Overriding button functionality in kivy using an another button","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently have a python script that updates certain CSV files when ran (it web scrapes and updates the information of a CSV file). In my HTML page (index.html), I have a script tag inside index.html that reads the CSV file and displays it as a table on the webpage. However, what I now need to do is update the CSV file by pressing an HTML button on the webpage. This will update the CSV file so when I run the button to run the JS script, it will have updated values from the file.\nI searched and found it very hard to understand what they meant by using flask and Django (I don't know anything about setting up servers). I don't want to set up a Django webpage because I want to work with my current pure HTML webpage I wrote.\nI would appreciate it if the answer is up to date with the current standard solutions for running python scripts in HTML.\nPlease ask if you need more information. Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":581,"Q_Id":60712353,"Users Score":0,"Answer":"You can't run python in html. You can just use javascript. but you can pass the information as json and then use javascript if you don't want to change the language or using python frameworks.","Q_Score":0,"Tags":"javascript,python,html,django","A_Id":60712434,"CreationDate":"2020-03-16T19:49:00.000","Title":"How to run a python script from clicking a button on a HTML webpage?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to pick up programming and I'm stuck with this one how should I resolve it - any good hints?\nI need to create a program that checks if the candidate fits into the team. The age must be between 16 and 18 and only male is allowed.\nUpgrade the program so that if the candidate is a female, no age will be asked at all","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":60716526,"Users Score":0,"Answer":"First things first, one of those questions clearly needs to be asked immediately, since it doesn't rely on anything else. You'll have to figure that out. After that question has been answered, then a follow-up question needs to be answered. Try ordering the questions in different ways to figure out how to do it correctly.\nIt might also help to think of how you would sort through a small group of random people.","Q_Score":2,"Tags":"python","A_Id":60716613,"CreationDate":"2020-03-17T05:06:00.000","Title":"How should I approach this program? I tried first part with AND and wrote 3 if statements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have prepared a draft email in Gmail that I need to send to several people but Gmail does not allow me to. The draft email has text, an image in it, and formatting.\nI'd ideally want to send the draft to my list of contacts one by one just changing who it's addressed to. I can put the list of contacts in one column of excel and the name in another. \nI could also just make the draft start with \"Dear sir\/madam\" and send the same draft to my contacts without any modification.\nIf the body of my email was just text I guess I'd just use SMTP, but with all the formatting, and image in it I don't know what to do.\nWhat is the easiest way to do this? Would using Selenium make sense? Anything else that's better?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":60716815,"Users Score":0,"Answer":"You could use a JavaMail API to send email. \nFor formatting you can use the html formatting inside your code, which serves like your draft. \nRead the contacts from a file and replace the variable in \"Dear\" $varName. \nAnd to trigger it multiple times you could use java.util.Timer class. \n\nHope it helps.","Q_Score":0,"Tags":"python,selenium,automation,smtp,gmail","A_Id":60717386,"CreationDate":"2020-03-17T05:44:00.000","Title":"How to send a draft email that I've prepared in several to several contacts in gmail one by one?","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 been trying to install sent2vec on Amazon EC2. However, I think there's something wrong in what I am doing.\nCould you please give me some guidance.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1033,"Q_Id":60718059,"Users Score":1,"Answer":"I found it out myself.\nDownload the zipped version from github.\n\nwget https:\/\/github.com\/epfml\/sent2vec\/archive\/master.zip\n\nunzip master.zip\n\nmake\n\nsudo python3.7 -m pip install . ( I am using python3.7, hence mentioned. you can try sudo pip install . also. )\n\n\n(if you fail at step 4, try this as well sudo apt-get install python3.7-dev)\nThat's it!","Q_Score":1,"Tags":"python-3.x","A_Id":60718117,"CreationDate":"2020-03-17T07:36:00.000","Title":"How to install sent2vec 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 have an Gtk.ComboBox which calls a function on changed. This helps me figuring out if the user selected something from the dropdown (trigger a loading function) or types something in (don't trigger a loading function) Now when I update\/refresh the combobox entries which are available, the combobox signals changed gets triggered really often. So my idea was to disable its signals, update the combobox entries, enable signals again. How can I achieve this in Python 3, GTK 3? I'm also using Glade because I have a big amount of signals, so I don't want to connect them manually if possible.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":345,"Q_Id":60719873,"Users Score":0,"Answer":"Just ignore any None values when retrieving combo.get_active_id()\nThen hook up to the changed signal of the internal entry of the combo to see what the user changes in the entry","Q_Score":0,"Tags":"python,gtk,signals","A_Id":60795333,"CreationDate":"2020-03-17T09:51:00.000","Title":"Disable GTK Widget signals and callback function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write a function in python that takes as input two matrices X and Y and computes for every pair of rows x in X and y in  Y, the norm ||x - y|| . I would like to do it without using for loops.\nDo you have an idea about how to do it ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":60723670,"Users Score":0,"Answer":"I just solve it :D\ninstead of len(np.trnspose(y)) i had to do len(y) and it perfectly worked with a for loop.","Q_Score":0,"Tags":"python,numpy","A_Id":60727470,"CreationDate":"2020-03-17T13:45:00.000","Title":"how to compute the sum for each pair of rows x in matrice X and y in matrice Y?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset like\n\n+--------------------------------------------------\n|    |entity    |individual_name  |investor_name  |\n---------------------------------------------------\n|  0 |Null      |Null             | Mark Wurtzel  |\n|  1 |entity    |Al Ihne          | Ihne LLC      |\n|  2 |entity    |Al Ihne          | Ihne LLC      |\n|  3 |entity    |Myles Lewis      | JMFM INC      |\n|  4 |entity    |Myles Lewis      | JMFM INC      |\n|  4 |entity    |Myles Lewis      | JMFM INC      |\n+--------------------------------------------------\n\nIf my individual_name and investor_name same then first take investor_name and split into first_name and last_name and isSelf is 1 and then take individual_name and split into first_name and last_name and isSelf is would be 0.\nand my dataframe look like\n\n+------------------------------------------------------------------------------------------+\n|    |entity    |individual_name  |investor_name  | first_name | last_name       | isSelf  |\n--------------------------------------------------------------------------------------------\n|  0 |Null      |Null             | Mark Wurtzel  |  Mark      | Wurtzel         |     1   |\n|  1 |entity    |Al Ihne          | Ihne LLC      |  Ihne      | LLC             |     1   |\n|  2 |entity    |Al Ihne          | Ihne LLC      |  AL        | Ihne            |     0   |\n|  3 |entity    |Myles Lewis      | JMFM INC      |  JMFM      | INC             |     1   |\n|  4 |entity    |Myles Lewis      | JMFM INC      |  Myles     | Lewis           |     0   |\n|  5 |entity    |Myles Lewis      | JMFM INC      |  Myles     | Lewis           |     0   |\n+------------------------------------------------------------------------------------------+\n\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":60727673,"Users Score":0,"Answer":"Filter your database based on your condition using loops, if condition and group_by method that is available in pandas library this will create you a new object that contains only the filtered values.\nFrom this, you can easily split up the names using regex or using some string functions.","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":60728176,"CreationDate":"2020-03-17T17:49:00.000","Title":"Split first name and last name if there is common matching in another column","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to update the module vpython to the most current version. I run:\npip3 install --user vpython --upgrade\nin a Jupyter terminal. This gives the error:\nERROR: jupyter-server-proxy requires Python '>=3.5' but the running Python is 3.4.2\nBut when I run:\npython3 --version\nit returns:\nPython 3.5.2 :: Anaconda 4.1.1 (64-bit)\nIs there something going wrong with the installed Python3 kernel for Jupyter?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":324,"Q_Id":60727807,"Users Score":0,"Answer":"Change the environmental variable in your control panel just a simple conflict between python 3.4 and 3.5 this will surely solve your issue.","Q_Score":1,"Tags":"python,python-3.x,jupyter","A_Id":60728086,"CreationDate":"2020-03-17T17:58:00.000","Title":"Error says the running Python is 3.4, but 3.5 is installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've installed Anaconda 3, version 2020.02 (current version straight from the website, 64 bit), and cannot figure out how to run it. When I search (on Windows) for Anaconda prompt or Anaconda navigator, I cannot find either. When I try to run any commands like conda init or anaconda-navigator on the command line, it says 'conda is not recognized as an internal or external command'. Yet it did install successfully (supposedly); the installed Anaconda3 files are where they should be. I have added the proper filepath to my system PATH variable, and added Anaconda3\/Scripts to the PATH variable as well; neither of these make a difference. Typing 'where conda' on command line results in 'INFO: Could not find files for the given patterns'. I have uninstalled Anaconda and reinstalled an earlier version, and this does not work either. What next steps should I take to try to get Anaconda to run?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":243,"Q_Id":60728707,"Users Score":0,"Answer":"Install Anaconda and don't change any of the default settings. This will install Anaconda in your user profile and add the c:\\users\\user_name\\AppData\\Anaconda3\\condabin folder to your system path. But before you can actually use Anaconda, you'll need to activate an environment. Either use the Anaconda prompt shortcut or open a cmd shell and type conda activate. If the the prompt doesn't change to (base) C:\\users\\user_name> Anaconda won't work. Adding ..\/Anaconda3\/Scripts to the PATH simply isn't sufficient. If necessary go to the c:\\users\\user_name\\AppData\\Anaconda3\\condabin folder and run conda init again.","Q_Score":0,"Tags":"python,anaconda","A_Id":60920426,"CreationDate":"2020-03-17T19:01:00.000","Title":"Anaconda will not run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have different shape files which contain polygons on a different coordinate system. When I merge them into a GeoDataFrame the crs attribute is not set. It is a way to set for each row in my GeoDataFrame a different crs? \nI have found a postgis way SRID=312;POINTM(-126.4 45.32 15) but I'm not sure if it works on GeoPandas","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":105,"Q_Id":60728875,"Users Score":1,"Answer":"GeoPandas does not support different CRS for different rows. The geometry column of a GeoDataFrame can only have a single CRS.","Q_Score":0,"Tags":"python,geopandas","A_Id":60729068,"CreationDate":"2020-03-17T19:15:00.000","Title":"Geopandas each row different crs?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a python script that logs into a webpage and the script itself stores my credentials. I am trying to determine whether running this script could somehow expose my credentials? Or is it just as secure as opening my browser myself and typing in my credentials? I would have presumed it would be no different to doing it manually, but I don't necessarily understand how my script communicates with the webdriver and if in that process my credentials could possibly be exposed. The Selenium documentation refers to a Selenium Server, but exactly sure how that works. An official reference would be appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":211,"Q_Id":60728992,"Users Score":1,"Answer":"your credentials is safe. selenium server acts as http proxy and sends your script http data , pass through selenium server before running in browser.","Q_Score":0,"Tags":"python,security,webdriver","A_Id":60729149,"CreationDate":"2020-03-17T19:25:00.000","Title":"Selenium Chrome Webdriver Security","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've read the Airflow documatation and I realized the backfill command will run my dags for each day of the date range that I provided. But is there a way to run my dags once per month using backfill? E.g. I provide the range 2020-01-01 to 2020-12-01 and I need to run once on January, once on February, and so.\nThanks for your help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":150,"Q_Id":60730551,"Users Score":1,"Answer":"backfill will rerun failed previous runs of a specified dag given its dag_id.\nIt will not run for each day unless your dag identified by dag_id is run each day.\nIf the dag identified by dag_id is run once eevry month, backfill will follow that frequency.\nA dag can easily be scheduled to run every day using a cron.","Q_Score":0,"Tags":"python,airflow","A_Id":60731159,"CreationDate":"2020-03-17T21:35:00.000","Title":"Airflow - Run backfill command month by month","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I updated spyder to 4.1 in anaconda through (conda update spyder), and it doesn't  work unless I open it from the anaconda prompt, otherwise it shows this error: \nAn error ocurred while starting the kernel\nThe error is:\n\nTraceback (most recent call last):\nFile \"C:\\Users\\anwar\\Anaconda3\\lib\\site\u2011packages\\spyder\\plugins\\ipythonconsole\\plugin.py\", line 1209, in create_kernel_manager_and_kernel_client\n  kernel_manager.start_kernel(stderr=stderr_handle, **kwargs)\nFile \"C:\\Users\\anwar\\Anaconda3\\lib\\site\u2011packages\\jupyter_client\\manager.py\", line 267, in start_kernel\n  self.kernel = self._launch_kernel(kernel_cmd, env=env, **kw)\nFile \"C:\\Users\\anwar\\Anaconda3\\lib\\site\u2011packages\\jupyter_client\\manager.py\", line 211, in _launch_kernel\n  return launch_kernel(kernel_cmd, **kw)\nFile \"C:\\Users\\anwar\\Anaconda3\\lib\\site\u2011packages\\jupyter_client\\launcher.py\", line 135, in launch_kernel\n  proc = Popen(cmd, **kwargs)\nFile \"C:\\Users\\anwar\\Anaconda3\\lib\\subprocess.py\", line 775, in init\n  restore_signals, start_new_session)\nFile \"C:\\Users\\anwar\\Anaconda3\\lib\\subprocess.py\", line 1178, in _execute_child\n  startupinfo)\nFileNotFoundError: [WinError 2] The system cannot find the file specified\n\nand in the corner, it still shows spyder 3.7","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1236,"Q_Id":60731255,"Users Score":0,"Answer":"Rollback Spyder 4.0.1 in python 3.7 environment and that should do the trick.","Q_Score":2,"Tags":"python,anaconda,spyder","A_Id":60791570,"CreationDate":"2020-03-17T22:44:00.000","Title":"Kernel error after updating to Spyder 4.1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When loading the output of query into a DataFrame using pandas, the standard behavior was to convert integer fields containing NULLs to float so that NULLs would became NaN. \nStarting with pandas 1.0.0, they included a new type called pandas.NA to deal with integer columns having NULLs. However, when using pandas.read_sql(), the integer columns are still being transformed in float instead of integer when NULLs are present. Added to that, the read_sql() method doesn't support the dtype parameter to coerce fields, like read_csv().\nIs there a way to load integer columns from a query directly into a Int64 dtype instead of first coercing it first to float and then having to manually covert it to Int64?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":284,"Q_Id":60731612,"Users Score":1,"Answer":"Have you tried using \nselect isnull(col_name,0) from table_name. This converts all null values to 0.\nIntegers are automatically cast to float values just as boolean values are cast to objects when some values are n\/a.","Q_Score":2,"Tags":"python,pandas","A_Id":60731768,"CreationDate":"2020-03-17T23:29:00.000","Title":"Is there a way to load a sql query in a pandas >= 1.0.0 dataframe using Int64 instead of float?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I am trying to make a video game in Tkinter (no, I don't want to use PyGame), but I have ran into a bit of a problem.\nI have realized that sometimes you may want to have two widgets overlap (e.g. sprite on top of background) but have the contents of both widgets to be visible. For example, I might have a sprite with transparent sections.\nHow do I set the \"background\" option of a widget so that there is no visible background?\nNote: \"you can't do this\" answers are acceptable.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":60732275,"Users Score":1,"Answer":"This is not really posible in Tkinter. But you can set the transparency of the whole window with root.attributes('-alpha', 0.5)\nFor windows, you can do root.attributes(\"-transparentcolor\", \"red\"), but again it will be applied to the whole window, not just the single widget.","Q_Score":1,"Tags":"python-3.x,tkinter,sprite,alpha-transparency","A_Id":60732523,"CreationDate":"2020-03-18T01:15:00.000","Title":"Tkinter contents of both widgets visible when overlapping","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Because of tight time constraints and good parallelization possibilities, my server backend needs to process a single query in multiple independent worker processes. To this end, I provided a set of n worker processes that communicate with the main process over multiprocessing queues. The main thread puts data into the input queue and each worker thread takes an item from it and processes it.\nFor clarification, an example: Suppose, this is a system that checks which numbers in [0, 100) are divisible by x. A user submits a number x to the REST API. Thus, the main process puts tuples (i, x) for i in range(100) into a queue. Each worker process then takes one tuple out of the queue and puts (i, i % n == 0) into the result queue. Once the main process got 100 results back, it'll respond to the user.\nAlthough this works fine on a stand-alone system, this makes problems once I put it behind a gunicorn server, namely, the information in the queues is lost and the main process hangs up. I need gunicorn because I want to make this service available via a REST API on the Web.\n(1) Is there any possibility to make this compatible with gunicorn? \nAccording to my previous research, gunicorn is incompatible with the multiprocessing module of Python. Hence, (2) are there any alternatives to the above described approach in this case?\nFor example, as an alternative, I thought about multiple independent service processes that are not spawned within the Python application, but are rather stand-alone. However, I cannot think of a simple and efficient possibility to implement that. If I'd implement another REST API for those worker processes, I'd lost a lot time with sending messages through the network stack. Thus, I'd need a more low-level approach, such as pipes or shared memory. (3) Do you have suggestions for me?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":60732500,"Users Score":0,"Answer":"I solved this issue now by separating the Web server and the query processing into separate processes that communicate over UNIX sockets. It seems that sockets only add a tiny overhead, which is likely acceptable in this case.\nIf there is a better solution, I'm still open for further suggestions.","Q_Score":0,"Tags":"python,multithreading,rest,multiprocessing,gunicorn","A_Id":60735107,"CreationDate":"2020-03-18T01:51:00.000","Title":"Processing queries concurrently in gunicorn-powered Python Web server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"recently doing a course on numpy, I encountered this problem and am finding difficulty understanding some concepts therefore if someone could help me.Some websites state that it interchanges the axis but what does that actually mean?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":60734756,"Users Score":0,"Answer":"If you have two 2D np.arrays - A and B - where B was created by transposing A, then for every i, j being legal indices for A: A[i][j] == B[j][i] does holds True.","Q_Score":0,"Tags":"python,arrays,numpy,axis","A_Id":60735079,"CreationDate":"2020-03-18T06:57:00.000","Title":"what does the np.transpose function do?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to connect to RDS with python with IAM Database Authentication.\nI can find how to connect to RDS with IAM SSL certification or how to connect to RDS with psycopg2.\nBut I cannot find how to connect to RDS with python with IAM Database Authentication.\nIs there any way to do that?\nthanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":60735695,"Users Score":0,"Answer":"I can do that just only to use psycopg2 with sslrootsert.\nThanks!","Q_Score":0,"Tags":"python,amazon-iam,rds","A_Id":60749502,"CreationDate":"2020-03-18T08:16:00.000","Title":"Connect to AWS RDS with python with IAM Database Authentication","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 used to create a Texture with gradient color and set to the background of Label, Button and etc. But I  am wondering how to set this to color of Label?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1136,"Q_Id":60736027,"Users Score":0,"Answer":"You can't set the color property to a gradient, that just isn't what it does. Gradients should be achieved using images or textures directly applied to canvas vertex instructions.","Q_Score":0,"Tags":"python,kivy","A_Id":60746769,"CreationDate":"2020-03-18T08:43:00.000","Title":"How to set text color to gradient texture in kivy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Spyder crashed at the last minute and I had force quit the programme as it wasn't responding at all. After reopening it, I am not able to find my file that I was working on, i hadn't saved it and had quite a bit of code written in it. It will be a huge help if someone knows a way to recover it, and can guide me through it. \nThanks alot!","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":15469,"Q_Id":60736231,"Users Score":7,"Answer":"I experienced a similar situation where I had added code to existing script that later wasn't saved as I expected it to be. I was able to recover my code from the history log (copy and paste). Not a perfect solution, but much better than having to re-write the code.\nI am on Spyder 3.3.4","Q_Score":3,"Tags":"python,spyder,recover","A_Id":63192116,"CreationDate":"2020-03-18T08:58:00.000","Title":"How to recover unsaved file in spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Spyder crashed at the last minute and I had force quit the programme as it wasn't responding at all. After reopening it, I am not able to find my file that I was working on, i hadn't saved it and had quite a bit of code written in it. It will be a huge help if someone knows a way to recover it, and can guide me through it. \nThanks alot!","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":15469,"Q_Id":60736231,"Users Score":0,"Answer":"I'll comment to help in case (someone crazy like me) clicked the discard button when Spyder asked if you wanted to restore the file.\nI found the following solution:\n\nopen a new terminal\ncd \/home\/pc\/.config\/spyder-py3\/\ncode .\nopen the history.py file\nHeart attack stopped successfully!\n\nAnyway, you will no longer find the file you discarded in the autosave folder, however, in the history.py file are saved the last 1000 lines that you executed, in my case the last 30 were enough.\nI hope it helps","Q_Score":3,"Tags":"python,spyder,recover","A_Id":72297973,"CreationDate":"2020-03-18T08:58:00.000","Title":"How to recover unsaved file in spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Spyder crashed at the last minute and I had force quit the programme as it wasn't responding at all. After reopening it, I am not able to find my file that I was working on, i hadn't saved it and had quite a bit of code written in it. It will be a huge help if someone knows a way to recover it, and can guide me through it. \nThanks alot!","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":15469,"Q_Id":60736231,"Users Score":1,"Answer":"Just for the people who still want to know the solution, close and open again Spyder application. It will ask you to recover the file. This worked for me today.","Q_Score":3,"Tags":"python,spyder,recover","A_Id":68310573,"CreationDate":"2020-03-18T08:58:00.000","Title":"How to recover unsaved file in spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Spyder crashed at the last minute and I had force quit the programme as it wasn't responding at all. After reopening it, I am not able to find my file that I was working on, i hadn't saved it and had quite a bit of code written in it. It will be a huge help if someone knows a way to recover it, and can guide me through it. \nThanks alot!","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":15469,"Q_Id":60736231,"Users Score":13,"Answer":"hist -g will show console history logs. You can recover your code from history if you had run your code earlier.","Q_Score":3,"Tags":"python,spyder,recover","A_Id":66318289,"CreationDate":"2020-03-18T08:58:00.000","Title":"How to recover unsaved file in spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tried to run this code on Jupyter notebook python 3:\nclass CSRNet(nn.Module):\n    def __init__(self, load_weights=False):\n        super(CSRNet, self).__init__()\n        self.frontend_feat = [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', 512, 512, 512]\n        self.backend_feat  = [512, 512, 512,256,128,64]\n        self.frontend = make_layers(self.frontend_feat)\n        self.backend = make_layers(self.backend_feat,in_channels = 512,dilation = True)\n        self.output_layer = nn.Conv2d(64, 1, kernel_size=1)\n        if not load_weights:\n            mod = models.vgg16(pretrained = True)\n            self._initialize_weights()\n            for i in range(len(self.frontend.state_dict().items())):\n                self.frontend.state_dict().items()[i][1].data[:] = mod.state_dict().items()[i][1].data[:]\nit displays 'odict_items' object is not subscriptable as an error in the last line of code!!how to deal with this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1196,"Q_Id":60740451,"Users Score":1,"Answer":"In python3, items() returns a dict_keys object, you should try to convert it to a list:\n\nlist(self.frontend.state_dict().items())[i][1].data[:] =\nlist(mod.state_dict().items())[i][1].data[:]","Q_Score":1,"Tags":"python-3.x,conv-neural-network","A_Id":67223193,"CreationDate":"2020-03-18T13:18:00.000","Title":"'odict_items' object is not subscriptable how to deal with this?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently trying to create a website that displays a python file (that is in the same folder as the html file) on the website, but I'm not sure how to do so.\nSo I just wanted to ask if anyone could describe the process of doing so (or if its even possible at all).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":60741595,"Users Score":0,"Answer":"Displaying \"a python file\" and displaying \"the output\" (implied \"of a python script's execution) are totally different things. For the second one, you need to configure your server to run Python code. There are many ways to do so, but the two main options are \n1\/ plain old cgi (slow, outdated and ugly as f..k but rather easy to setup - if your hosting provides support for it at least - and possibly ok for one single script in an otherwise static site)\nand\n2\/ a modern web framework (flask comes to mind) - much cleaner, but possibly a bit overkill for one simple script.\nIn both cases you'll have to learn about the HTTP protocol.","Q_Score":0,"Tags":"python,html","A_Id":60742166,"CreationDate":"2020-03-18T14:26:00.000","Title":"Is there any way that I can insert a python file into a html page?","Data Science and Machine Learning":0,"Database and SQL":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":".execute(\"copy into tmp_cdp_score_feature from @cdp_json_acpt\/data\/1 file_format = (type=json)\"\nas the last value will be varying from 1 to 100 like data\/2, data\/3, so I  need to pass as variable .\nsomething like \n.execute(\"copy into tmp_cdp_score_feature from @cdp_json_acpt\/data\/(%s) file_format = (type=json),(2)\"","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":976,"Q_Id":60743574,"Users Score":0,"Answer":"copy into tmp_stg from @stg_json_acpt\/\"'%s'\" file_format = (type=json), Force=True\" %(des1)\ndes1= path of the s3 object file\nIt works fine, tested","Q_Score":0,"Tags":"python,snowflake-cloud-data-platform","A_Id":60808996,"CreationDate":"2020-03-18T16:22:00.000","Title":"How to pass the bind variable to the copy into statement in snowflake from python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know if there is a way in Google Colab that can collate outputs nicely, just like Markdown in R and how IPython Notebook can be converted to pdf and html format? \nMy output consists of multiple tables, graphs etc. I would like to preferably pretty print them into one file, of which some part are presentable enough to be used in a report.If there's no such method, what is the best alternative?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":17150,"Q_Id":60748816,"Users Score":3,"Answer":"You can save \/ export an IPython notebook (menu: File \/ Download .ipynb) and then use Jupyter to save to PDF.","Q_Score":4,"Tags":"python,pandas,jupyter-notebook,google-colaboratory","A_Id":60748897,"CreationDate":"2020-03-18T23:20:00.000","Title":"Convert Google Colab notebook to PDF \/ HTML?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have 2 dataframes: \nFinalFrame:\nTime | Monday | Tuesday | Wednesday | ...\nand df (Where weekday is the current day, whether it be monday tuesday etc):\nWEEKDAY\nI want to append the weekday's data to the correct column. I will need to constantly keep appending weekdays data as weeks go by. Any ideas on how to tackle this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":60749292,"Users Score":0,"Answer":"You can add index of week days instead of their name. For example, \nweekdays = ['Mon', Tue', 'Wed', 'Thu', 'Fri','Sat', 'Sun']\nTime | 0 | 1 | 2 ....","Q_Score":0,"Tags":"python,pandas","A_Id":60749473,"CreationDate":"2020-03-19T00:25:00.000","Title":"How to append data to specific column Pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 dataframes: \nFinalFrame:\nTime | Monday | Tuesday | Wednesday | ...\nand df (Where weekday is the current day, whether it be monday tuesday etc):\nWEEKDAY\nI want to append the weekday's data to the correct column. I will need to constantly keep appending weekdays data as weeks go by. Any ideas on how to tackle this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":60749292,"Users Score":0,"Answer":"So the way you could do it isolates the series by saying weekday[whatever day you are looking at .append.","Q_Score":0,"Tags":"python,pandas","A_Id":60749625,"CreationDate":"2020-03-19T00:25:00.000","Title":"How to append data to specific column Pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is probably a dumb question, but does it matter if you're running pip3? I ask as when I try to install something with pip install {package name} it tells me I don't have pip, but I am able to install packages with pip3.\nI am confused where everything gets installed on macOS.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":2419,"Q_Id":60749607,"Users Score":4,"Answer":"It depends on your OS. For OSes where python means Python 2, pip typically (but not always) means \"pip for Python 2\", while pip3 means \"pip for Python 3\".\nIf you want to avoid ambiguity over which Python you're running pip with, don't run pip or pip3. Run python -mpip (replacing python with the name of the Python interpreter you want to use), which will run the pip module installed for that interpreter, rather than hoping pip3 is for what you run as python3, when it might be that python3 is for Python 3.8, while pip3 is installed for Python 3.7 or the like.\nIf you're looking for where stuff is being pulled from, running a script that just does print(sys.path) should show you where it looks for stuff. Individual installed modules typically have a __file__ attribute you can inspect after importing them.","Q_Score":0,"Tags":"python,python-3.x,pip","A_Id":60749629,"CreationDate":"2020-03-19T01:11:00.000","Title":"pip or pip3 for Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm starting a project on a dataset that contains over 5k unique values for a category.  \nMy question is, after using label encoder, to \"enumerate\" the categories, does it make sense to use Standard Scaler to make the data a little more \"manageable\" for my Machine Learning model?  \nKeep in mind I have over 500k entries in total and 5k unique categories for this particular column.\nThis is more about the intuition behind it rather than how to code it, but I figured this should be the place to ask.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1168,"Q_Id":60750375,"Users Score":0,"Answer":"If you use LabelEncoder for a category, you need to make sure that your category can be comparable. For example, for category ['high', 'med', 'low'], items are comparable, so it makes sense to LabelEncoding it and standard scaling it.\nHowever, when your category cannot be compared to each other, label encoding it would not make any sense. For example, you cannot compare 'Monday' to 'Tuesday'.\nTL;DR \nIf your category is comparable (ordinal), it makes sense. If not, try to find ways to reduce your category, there are a lot of methods to do so.","Q_Score":0,"Tags":"python,machine-learning,label-encoding","A_Id":60750707,"CreationDate":"2020-03-19T03:07:00.000","Title":"Does it make sense to user Standard Scaler after applying Label Encoder?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm starting a project on a dataset that contains over 5k unique values for a category.  \nMy question is, after using label encoder, to \"enumerate\" the categories, does it make sense to use Standard Scaler to make the data a little more \"manageable\" for my Machine Learning model?  \nKeep in mind I have over 500k entries in total and 5k unique categories for this particular column.\nThis is more about the intuition behind it rather than how to code it, but I figured this should be the place to ask.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1168,"Q_Id":60750375,"Users Score":0,"Answer":"LabelEncoder should be used for the labels, in order to have labels for n categories replaced with integers from 1 to n. You should do this if it is not already done.\nStandardScaler is meant to be used, eventually, for the training and test data but nor for the labels. It outputs positive or negative float.\nYou should certainly not apply this to the label column, as the label column must be a positive Integer.","Q_Score":0,"Tags":"python,machine-learning,label-encoding","A_Id":60769398,"CreationDate":"2020-03-19T03:07:00.000","Title":"Does it make sense to user Standard Scaler after applying Label Encoder?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im new at this discord.py thing. I've just done a discord.py bot, it works ok, but sometimes the bot repeats constantly the command messages.\nI googled this problem and found out that maybe is for running the script over and over again (like when you save and run after edited or added functions).\nSo I want to stop running the process, just like when I restart windows, the bot is offline (if I run the script after restarting windows, the bot acts normaly).\nPls help\nIf someone needs the code, I can paste it here then.\nPD: I made the bot exact as a tutorial...","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":21516,"Q_Id":60750793,"Users Score":0,"Answer":"just type exit in visual studio code output terminal and your bot will be disconnected. Enjoy the day","Q_Score":3,"Tags":"python,sublimetext3,discord.py","A_Id":70487529,"CreationDate":"2020-03-19T04:08:00.000","Title":"How to stop running discord bot process (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":"Im new at this discord.py thing. I've just done a discord.py bot, it works ok, but sometimes the bot repeats constantly the command messages.\nI googled this problem and found out that maybe is for running the script over and over again (like when you save and run after edited or added functions).\nSo I want to stop running the process, just like when I restart windows, the bot is offline (if I run the script after restarting windows, the bot acts normaly).\nPls help\nIf someone needs the code, I can paste it here then.\nPD: I made the bot exact as a tutorial...","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":21516,"Q_Id":60750793,"Users Score":0,"Answer":"Easy way to solve this is by regenerating your bot token. Doing so will shutdown all active scripts. For anyone new to the Discord API, if you ever get an error that says something on the lines of 'Access Denied,' this solution should also help you.","Q_Score":3,"Tags":"python,sublimetext3,discord.py","A_Id":66404102,"CreationDate":"2020-03-19T04:08:00.000","Title":"How to stop running discord bot process (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":"Im new at this discord.py thing. I've just done a discord.py bot, it works ok, but sometimes the bot repeats constantly the command messages.\nI googled this problem and found out that maybe is for running the script over and over again (like when you save and run after edited or added functions).\nSo I want to stop running the process, just like when I restart windows, the bot is offline (if I run the script after restarting windows, the bot acts normaly).\nPls help\nIf someone needs the code, I can paste it here then.\nPD: I made the bot exact as a tutorial...","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":21516,"Q_Id":60750793,"Users Score":1,"Answer":"This message really is not discord.py specific and applies to every script which runs indefinetely.\nYou are running multiple instances of your bot. If you run it in an IDE envoirment, then there should be a stop button somewhere. If you are running it in console, closing the console window will close the bot.\nEdit: If you are running it in sublime3 like your tags suggest, every time you want to close your bot, go to \"Tools\" and then \"Cancel Build\" (hotkey: CTRL + Break). As soon as you run another instance of your bot, sublime \"decouples\" the current script in favour of the new one and this method does not work anymore. Then you have to manually go through your running processes (command line or Task Manager) and search for any \"Python\" processes.\nIn general I reccomend running the script in the commandline instead as you have more control over it.","Q_Score":3,"Tags":"python,sublimetext3,discord.py","A_Id":60756179,"CreationDate":"2020-03-19T04:08:00.000","Title":"How to stop running discord bot process (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 had configured VSCode for python, it was working fine, linter , autopep all the things were working fine. After some days I installed Anaconda, from here problems started, after this I got error that Select Python Interpreter at the bottom of VSCode, I added python path to the settings,then it works fine but \"Select Python Interpreter\" error was still coming. Some days before I installed Javascript extension, after this linter,autopep nothing is working,only using python command line python program is getting run.\nI removed javascript extension,again installed VSCode, now the things are worst,nothing is working now.Please anyone help me to how to reconfigure VSCode to work properly.Even I removed Anaconda installation too, still problems not solved. I searched online but did not get any proper inforamtion.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":60751725,"Users Score":0,"Answer":"I had a similar issue, I think you have both Python 3.7  and Anaconda installed separately, Use any one them , remove the other. When both of them is together it was throwing lot of issues. I would prefer to remove Anaconda(pure personal choice).If you don't have much customized settings in VScode, delete its user configuration files and set it up again. it will work","Q_Score":0,"Tags":"python-3.x,vscode-settings","A_Id":60752626,"CreationDate":"2020-03-19T06:05:00.000","Title":"How to reconfigure VSCode for python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After i did a lot of research about AI and sentiment analysis i found 2 ways to do text analysis.\nAfter the pre-processing for text is done we must create a classification in order to get the positive and negative, so my question is it better to have example:\nfirst way:\n\n100 records of text to train that includes 2 fields text &\nstatus filed that indicate if its positive 1 or negative 0.\n\nsecond way:\n100 records of text to train and make a vocabulary for bag of word in order to train and compare the tested records based on this bag of word.\nif i am mistaking in my question please tel me and correct my question.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":60752016,"Users Score":0,"Answer":"I think you might miss something here, so to train a sentiment analysis model, you will have a train data which every row has label (positive or negative) and a raw text. In order to make computer can understand or \"see\" the text is by representing the text as number (since computer cannot understand text), so one of the way to represent text as number is by using bag of words (there are other methods to represent text like TF\/IDF, WORD2VEC, etc.). So when you train the model using data train, the program should preprocess the raw text, then it should make (in this case) a bag of words map where every element position represent one vocabulary, and it will become 1 or more if the word exist in the text and 0 if it doesn't exist.\nNow suppose the training has finished, then the program produce a model, this model is what you save, so whenever you want to test a data, you don't need to re-train the program again. Now when you want to test, yes, you will use the bag of words mapping of the train data, suppose there is a word in the test dataset that never occurred in train dataset, then just map it as 0.\nin short:\nwhen you want to test, you have to use the bag of words mapping from the data train","Q_Score":0,"Tags":"python,nltk,sentiment-analysis","A_Id":60752756,"CreationDate":"2020-03-19T06:35:00.000","Title":"best practice to start a sentiment analysis project?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have MS Access File with a file size of 1.7GB. I have already tried to compact and repair, but the file size remains the same.\nThis is what I did. I download about 29 files from jupyter python to excel and csv files. The total amount of data is about 934MB.\nI need to update the data everyday, therefore I linked the Access file to all the exported files under linked table and create another table to have a relationship with each other. So I have 2 tables for each exported file, for example: customer_linked and customer.\nAnd this is the step by step of query:\n1. Delete query for all data in non-linked table\n2. Append query to append the linked-table to non-linked table\nI have no idea that this way, it will make the file super bloated to 1.7GB. Is there any way to make it smaller?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":60,"Q_Id":60752859,"Users Score":1,"Answer":"You can look into converting the excel files into csvs if you're looking to try and save space. Depending on how large the files are, there might be a lot of bloat in the excel files, full of extra stuff you don't need. If you're not using the excel files for images\/graphs\/formatting of some kind then you're best off just converting them all to csvs.","Q_Score":1,"Tags":"python,vba,ms-access","A_Id":60753022,"CreationDate":"2020-03-19T07:48:00.000","Title":"MS Access Big File Size Problem with exported file from Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have MS Access File with a file size of 1.7GB. I have already tried to compact and repair, but the file size remains the same.\nThis is what I did. I download about 29 files from jupyter python to excel and csv files. The total amount of data is about 934MB.\nI need to update the data everyday, therefore I linked the Access file to all the exported files under linked table and create another table to have a relationship with each other. So I have 2 tables for each exported file, for example: customer_linked and customer.\nAnd this is the step by step of query:\n1. Delete query for all data in non-linked table\n2. Append query to append the linked-table to non-linked table\nI have no idea that this way, it will make the file super bloated to 1.7GB. Is there any way to make it smaller?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":60752859,"Users Score":0,"Answer":"Surprisingly the file in csv take more space than the file in excel.\n\nNo surprise if that is an .xlsx file, as these are zip files. Try renaming it to .zip and unpack it to see the real size.\nIf you have compacted it, that is the size - Nothing to worry about.\nThe only concern could be, that you are approaching the size limit of 2GB for an Access file. If that could hit you, consider moving data to, say, the free SQL Server Express edition which allows for 10GB.","Q_Score":1,"Tags":"python,vba,ms-access","A_Id":60753727,"CreationDate":"2020-03-19T07:48:00.000","Title":"MS Access Big File Size Problem with exported file from Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python and I'm following a tutorial using python3. I installed plotly and I can see it in the pip list and pip3 list and python help(\"modules\"). However, when I tried to import the module (from plotly import offline) I got the error: \n\nModuleNotFoundError: No module named 'plotly'.\n\nTried to reinstall but it did not work.\nI can import other modules in the list, like pygame or matplotlib without a problem.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":516,"Q_Id":60752993,"Users Score":0,"Answer":"I had the same problem; after uninstalling\/installing plotly, use venv, I realised (after 2h) that my script name was \"plotly.py\" => that was the cause of the error","Q_Score":0,"Tags":"python,plotly","A_Id":65022022,"CreationDate":"2020-03-19T07:58:00.000","Title":"No module named 'plotly'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a folder containing a lot of files with similar names and I want to open two of them with xarray so I get one array (with the time axis consistent).\nI know that I can open multiple files with the *\nExample:\nxarray.open_mfdataset('folder\/*.nc') would open all netcdf files in the folder.\nNow, say I have file_01, file_02 and file_03 in folder.\nHow can I open file_01 & file_02, but not file_03 ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":474,"Q_Id":60758026,"Users Score":3,"Answer":"xr.open_mfdataset() can accept wildcards, as you said, but it can also accept an explicit list of files if you want to specify them. \nSo in your case, you could use:\nxr.open_mfdataset(['folder\/file1.nc','folder\/file2.nc'])","Q_Score":2,"Tags":"python,python-xarray","A_Id":60758940,"CreationDate":"2020-03-19T13:16:00.000","Title":"Open selected files with open_mfdataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install Pygame, but this doesn't work..\nI'm on Mac, using MacOs Mojave, and SublimeText.\nI tried python3.8 -m pip install Pygame and python3 -m pip install -U pygame in the terminal, which is given on Pygame.org, but it prints:\nerror: command 'gcc' failed with exit status 1","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":60760196,"Users Score":0,"Answer":"It appears that you have an issue where macOS Mojave doesn't install all Mac SDK headers by default. Try installing them with the following command:\nsudo installer -pkg \/Library\/Developer\/CommandLineTools\/Packages\/macOS_SDK_headers_for_macOS_10.14.pkg -target \/\nIt's only an issue with Mac versions above 10.14 (included) please let me know if this fixes it","Q_Score":0,"Tags":"python,macos,gcc,pygame,macos-mojave","A_Id":60792126,"CreationDate":"2020-03-19T15:23:00.000","Title":"How to install Pygame on MacOS Mojave?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the purpose of the \"!\" in !pip?  example !pip install tensorflow-gpu==2.0.0.  While this seems to work I do not understand the use of the \"!\".","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":396,"Q_Id":60762417,"Users Score":1,"Answer":"It means run it as a shell command rather than a notebook command\nTry !ls or !pwd\nIt's the same as if you opened up a terminal and typed it without the !\nIt's very convenient and you can pass variables between the terminal and your notebook","Q_Score":0,"Tags":"python,pip","A_Id":60762456,"CreationDate":"2020-03-19T17:39:00.000","Title":"Practical difference between pip and !pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am installing kaldi in ubuntu 18.04. python2.7 is one of the dependencies to install kaldi. I have installed python2.7 by sudo apt-get install pytho2.7. Then to check the prerequisites run\nextras\/check_dependencies.sh. The result showing - \"python2.7 is installed, but the python2 binary does not exit. Creating a symlink and adding this to tools\/env.sh\"\nWhat is the next step to do?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":787,"Q_Id":60769739,"Users Score":0,"Answer":"i just input 'ln -fs \/usr\/bin\/python2.7'","Q_Score":2,"Tags":"python-2.7,binary,symlink,kaldi","A_Id":69186659,"CreationDate":"2020-03-20T06:52:00.000","Title":"kaldi python2 binary 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":"ImportError: cannot import name 'EntityRecognizer' from 'spacy.language'. \ngetting the when try importing the packages in spyder,\nimport spacy \nfrom spacy.gold import GoldParse \nfrom spacy.language import EntityRecognizer \nspyder version: 3.3.6\nconda version: 4.8.3","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":999,"Q_Id":60772650,"Users Score":4,"Answer":"Try:\nfrom spacy.pipeline import EntityRecognizer","Q_Score":1,"Tags":"python,nlp,spacy","A_Id":61442185,"CreationDate":"2020-03-20T10:46:00.000","Title":"Getting the Import error when trying to import EntityRecognizer from spacy.language package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a flask app that has one route and nothing complex going on, running in a docker container. I cannot for the life of me get print statements to show up in the logs (docker-compose logs -f <containername>). So far, I have tried various answers that supposedly have fixed this problem for others including:\n\nCalling print(\"test\", flush=True)\nSetting PYTHONUNBUFFERED=1 and verifying it is set in the actual container with echo\nSetting PYTHONUNBUFFERED=0\nRunning python with the -u flag\nUsing the logging module (logger.warning, logger.info, etc)\n\nSo far nothing has worked. The flask app is starting perfectly fine, but no output from my print statements is shown. I have sanity checked that i'm editing the correct file by adding random syntax errors and watching the app brick itself. I'm using python 3.8 and docker-compose 2","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2316,"Q_Id":60773195,"Users Score":1,"Answer":"I found this question while looking for answers to a similar problem. I was running a flask app in a conda environment in a container and wasn't getting any log output even though the flask app itself was working fine. I added the following lines to my Dockerfile and it starting logging as expected -\nENV PYTHONUNBUFFERED=1\nRUN echo \"source activate my_env\" > ~\/.bashrc\nENV PATH \/opt\/conda\/envs\/my_env\/bin:$PATH\nCMD [\"python\", \"api.py\"]","Q_Score":1,"Tags":"python,docker,flask","A_Id":64772818,"CreationDate":"2020-03-20T11:23:00.000","Title":"Docker-compose flask app not printing output from 'print'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have created my own Anaconda environment. I needed to use the 'comtypes' package to connect to the software ETABS, so I first downloaded it with the conda installation command and then I tried the next command line:\nhelper = comtypes.client.CreateObject('ETABSv17.Helper')\nBut, I received the next error:\nAttributeError: module 'comtypes.gen.ETABSv17' has no attribute 'cHelper'\nHowever, I realized that if a try the same command line with the base environment coming with Anaconda, that includes a pre-installed 'comtypes' package, there is no problem. In fact, if I check comtypes.gen.ETABSv17 with my customized environment and with the one from Conda, there is a huge difference between available attributes, even when they have the same version number: comtypes 1.1.7. \nHow can I get the exactly same 'comtypes' package that comes with Anaconda in order to have all the associated attributes working?  Maybe, could there be some package dependence that I am missing?\nPd: I am using Windows10 and I have tried it in Pycharm and Spyder with Python 3.7\nThank you all !","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":60773684,"Users Score":0,"Answer":"I  had this issue and i was using python 32 bit version. So uninstalled and installed a 64 bit version and now its working fine. May be this helps","Q_Score":0,"Tags":"anaconda,python-3.7,comtypes","A_Id":64986234,"CreationDate":"2020-03-20T11:59:00.000","Title":"comtypes.gen attributes are different from self download and conda pre-installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a speaker recognition machine learning. \nCurrently i'm using the following scheme:\n\ntaking my audio files data set and computing for each 0.15 seconds of the audio file 13 mel freaquency coeffs \neach 13 coeffs I input to a neural network that based on 3 blocks of [conv, pool, norm]\nfor the test files i use a majority over all the outpus for each 13 coeffs vector\n\nI usually get about 85% recognition rate for 3 speakers which is not amazing and therefore I decided that I want to add some features, but I don't know what to add...\nSomeone has a recommendations to what feature should I add\/ what should I do in order to increase my precentage?\nI tried to use a module that call - \"pitch\" which give me the pitch of a wav file but it gave me very randomic values ( for example for the same speaker it gave me 360, 80, 440 for the 3 first audios ) \nThanks alot for any help","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":86,"Q_Id":60774064,"Users Score":0,"Answer":"You should be processing longer chunks at once, in 0.15 seconds is almost impossible identify speaker identity.\nThe general rule is the longer audio you process, the more accurate recognition you will have. Something like 1-3 seconds is good and you need to input them to neural network as a whole.\nYou can google for x-vector on github, there are many implementation, you can find one in kaldi for example.","Q_Score":1,"Tags":"python,neural-network,voice-recognition,mfcc,pitch","A_Id":60786263,"CreationDate":"2020-03-20T12:22:00.000","Title":"Features for speaker recognition that can be added to mfcc features\/ Things that I can do in order to improve my speaker recognition neural network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing 6 datasets to a new hdf5 with h5py.  3 of them are of one format and 3 of the other.  For 3 of the first set, I use dt=\"s103\" which perfectly captures the datatype.  For the other set of 3, I need the datatype to be H5T_STD_U8LE to match what another hdf5 file on disc has.  How would I accomplish this when creating a dataset to write out?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":60774568,"Users Score":0,"Answer":"In my situation it was dt='uint8'.  This would give me the above type","Q_Score":0,"Tags":"python,hdf5,h5py","A_Id":60774693,"CreationDate":"2020-03-20T12:52:00.000","Title":"In H5PY, what would be the equivalent of datatype H5T_STD_U8LE?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I have trained the doc2vec model with 50000 documents and I want to infer vectors for a separate dataset containing 36000 documents. In this case will the inferred vectors be effective for the downstream task of classification, becasue my assumption is that the inferred vectors depend on the size of documents with which the model is trained. \nNote: Both dataset i.e one used for training doc2vec and other for inferring vectors are unique but from the same domain of US supreme court.\nPlease correct me if I am wrong with valid reason.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":135,"Q_Id":60774762,"Users Score":1,"Answer":"With such a tiny dataset, no answer I can give will be as useful as just trying it to see if it works. \n50000 is smallish for a training set, but some useful Doc2Vec results have been based on similar corpuses. \nVector inference, like training, reduces documents of any length to a fixed-size vector. (But note: gensim silently limits any text fed to a 2Vec model to 10000 tokens.) \nBut, if you've trained a model on documents that are all about 1000 words, then try inference on 10-word fragments, those doc-vectors might not be as useful, or useful in the same way, as inferred vectors on documents more similar to the training set. But you'd still need to try it to find out. (Also note: words not learned during training are completely ignored during inference, so later inferences on docs with many\/all unknown words will be weak or meaningless.)\nIs that the the case with your inference docs \u2013 they are very different from training docs in size & vocabulary? And if so, why? (Can you train with more representative documents?)\nIf the set of 36000 documents is fixed before training begins, it may also be valid\/defensible to include them in the unsupervised Doc2Vec training. They're data, they help learn the domain lingo, and they don't have in them any form of the \"right\" answers for classification.","Q_Score":0,"Tags":"python,nlp,word-embedding,doc2vec,pre-trained-model","A_Id":60778723,"CreationDate":"2020-03-20T13:04:00.000","Title":"Doc2Vec Pre training and Inferring vectors","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying the typical hololens tutorial to use Tensorflow, Keras, and ImageAI to be able to train a new custom object detection.\nThe training is running, but it is always returning something like: \nloss: 0.0000e+00 - yolo_layer_1_loss: 0.0000e+00 - yolo_layer_2_loss: 0.0000e+00 \nAnd when I try to use the outcome of the model, it fails.\nI am using Python 3.7.7\ntensorflow           1.14.0\nimageai              2.1.5\nKeras                2.3.1","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":97,"Q_Id":60776218,"Users Score":1,"Answer":"For me, what solved the issue was using batch size > 1.","Q_Score":1,"Tags":"python,tensorflow,keras,imageai","A_Id":60804572,"CreationDate":"2020-03-20T14:36:00.000","Title":"Running an ImageAI training returns always 0 loss","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have my university project and i'm given a dataset which almost all features have a very weak (only 1 feature has moderate correlation with the target) correlation with the target. It's distribution is not normal too. I already tried to apply simple model linear regression it caused underfitting, then i applied simple random forest regressor but it caused overfitting but when i applied random forest regressor with optimization with randomsearchcv it took time so long. Is there any way to get decent model with not-so-good dataset without underfitting or overfitting? or it's just not possible at all?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":207,"Q_Id":60776759,"Users Score":3,"Answer":"Well, to be blunt, if you could fit a model without underfitting or overfitting you would have solved AI completely.\nSome suggestions, though:\nOverfitting on random forests\n\nPersonally, I'd try to hack this route since you mention that your data is not strongly correlated. It's typically easier to fix overfitting than underfitting so that helps, too.\nTry looking at your tree outputs. If you are using python, sci-kit learn's export_graphviz can be helpful. \nTry reducing the maximum depth of the trees. \nTry increasing the maximum number of a samples a tree must have in order to split (or similarly, the minimum number of samples a leaf should have). \nTry increasing the number of trees in the RF.\n\nUnderfitting on linear regression\n\nAdd more parameters. If you have variables a, b, ... etc. adding their polynomial features, i.e. a^2, a^3 ... b^2, b^3 ... etc. may help. If you add enough polynomial features you should be able to overfit -- although that doesn't necessarily mean it will have a good fit on the train set (RMSE value).\nTry plotting some of the variables against the value to predict (y). Perhaps you may be able to see a non-linear pattern (i.e. a logarithmic relationship).  \nDo you know anything about the data? Perhaps a variable that is the multiple, or the division between two variables may be a good indicator. \nIf you are regularizing (or if the software is automatically applying) your regression, try reducing the regularization parameter.","Q_Score":0,"Tags":"python,machine-learning,data-science","A_Id":60777051,"CreationDate":"2020-03-20T15:09:00.000","Title":"How to achieve regression model without underfitting or overfitting","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My case: \nI want to display the meal plan from my University on my own online \"Dashboard\". I've written my python script to scrape that data and I get the data I need (plain Text). Now I need to put it on my website but I don't know how to start. On my first searching sessions, I have found something with CGI but I have no clue how to use it:( Is there maybe an even easier way to solve my problem? \nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":400,"Q_Id":60778980,"Users Score":0,"Answer":"I suggest you to use the Django, if you don't want to use django, you can edit your output in HTML formate and publish html page, directly.","Q_Score":0,"Tags":"python,html,cgi","A_Id":60779048,"CreationDate":"2020-03-20T17:35:00.000","Title":"Displaying data from my python script on a webpage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to determine which schedulers to trigger depending on the branch name, from inside the build factory - if that's possible. \nEssentially I have a builder that is doing all the common build steps to compile package etc, and then has a bunch of trigger steps that trigger a bunch of tests (via triggerable schedulers).\nHowever, I would like to configure the type of tests that get started (eg which schedulers are triggered) to depend on the branch name. So far I've tried to add the change_filter arg to my Triggerable scheduler, but it seems that it doesn't accept that argument. I guess that makes sense because it supposed to be Triggered, so maybe it doesn't care about using a change filter. That seems a bit strange though because Dependent schedulers do accept this kwarg. \nSo far the correct way to set this up is not clear to me.\nI guess my questions are really: \n\nIs there a way to use renderables \/ properties to decide which schedulers to trigger (based on the branch name for example)?\nIs there a better way to do this? Perhaps create separate schedulers for the build that apply the change filter I need and have a build factory that triggers the correct tests, but that's not very DRY.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":60779621,"Users Score":1,"Answer":"I came back to leave this here in case it might help someone with a tricky buildbot setup.\nI solved this by making all of the dependent schedulers (for specific types of tests) into triggerable schedulers. Then I created main build schedulers for each subset of tests, each with a change filter and regex for the branches that should undergo that subset of tests. Finally, I created the buildfactory for each main scheduler by passing it only the triggerable schedulers for the test that that specific type of main scheduler should run. \nFor my current use case, this works great!","Q_Score":1,"Tags":"python-3.x,buildbot","A_Id":61101334,"CreationDate":"2020-03-20T18:19:00.000","Title":"Can a Triggerable Scheduler use a change filter, or can a Trigger build step be conditional on a property?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Our codebase is checking high cyclomatic complexity using Radon. I have a function which is triggering this linter error, but I would like for it to pass the linter, similar to something like a pylint disable. Is there a way to do that with radon?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":527,"Q_Id":60779674,"Users Score":3,"Answer":"If you are using Radon as a flake8 plugin, you can append #  noqa R701 to the line with the function definition.\nIf you are using Radon standalone, there is no mechanism to skip a function or code block based on comments or any other markup - so, it is not possible.","Q_Score":1,"Tags":"python,static-analysis,cyclomatic-complexity","A_Id":60780794,"CreationDate":"2020-03-20T18:23:00.000","Title":"How to disable radon high cyclomatic complexity check?","Data 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":"Lets say I have a training sample (with their corresponding training labels) for a defined neural network (the architecture of the neural network does not matter for answering this question). Lets call the neural network 'model'.\nIn order to not create any missunderstandings, lets say that I introduce the initial weights and biases for 'model'.\nExperiment 1.\nI use the training sample and the training labels to train the 'model' for 40 epochs. After the training, the neural network will have a specific set of weights and biases for the entire neural network, lets call it WB_Final_experiment1.\nExperiment 2\nI use the training sample and the training labels to train 'model' for 20 epochs. After the training, the neural network will have a specific set of weights and biases for the entire neural network, lets call it WB_Intermediate.\nNow I introduce WB_Intermediate in 'model' and train for another 20 epochs. After the training, the neural network will have a specific set of weights and biases for the entire neural network, lets call it WB__Final_experiment2.\nConsiderations. Every single parameter, hyperparameter, activation functions, loss functions....is exactly the same for both experiments, except the epochs.\nQuestion: Are WB_Final_experiment1 and WB__Final_experiment2 exactly the same?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":153,"Q_Id":60780523,"Users Score":0,"Answer":"If the operations you are doing are entirely deterministic, then yes. Epochs are implemented as an iteration number for a for loop around your training algorithm. You can see this in implementations in PyTorch.","Q_Score":3,"Tags":"python,machine-learning,keras,neural-network,epoch","A_Id":60780565,"CreationDate":"2020-03-20T19:31:00.000","Title":"I am trying to understand 'epochs' in neural network training. Are the next experiments equivalent?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have currently an issue with debugging with visual studio code . I want to attach GDB to a C (.so) shared library module that is called via a main python program that interfaces with the C shared library with F2PY.\nHow do I procede to create a launch configuration in vscode for gdb to debug that C shared library?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":124,"Q_Id":60780829,"Users Score":1,"Answer":"Cross-language debugging from Python to C is only available in Visual Studio, not in VS Code.","Q_Score":0,"Tags":"python,c,visual-studio-code,vscode-debugger,f2py","A_Id":60839981,"CreationDate":"2020-03-20T19:54:00.000","Title":"How do I debug in visual studio code a python program that calls c functions in a shared library from a f2py interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I will try and make my question clear. \nI have two buttons, the first one is on top of the second one.\nWhen I press the first one, it receives the touch but the second one also receives the touch because the touch occurs within its boundary box.\nWhat do i do in the on_touch_down or on_touch_up function to make the second button below the \nfirst one not to receive the touch or to do nothing with the touch.\nAny help will be appreciated thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":60782703,"Users Score":0,"Answer":"What do i do in the on_touch_down or on_touch_up function to make the second button below the\nfirst one not to receive the touch or to do nothing with the touch.\n\nReturn True to indicate that you have consumed the touch and it shouldn't keep being passed on.\nThis should be the default behaviour for buttons, it sounds like you may have broken it by overriding on_touch_down without correctly passing out the return value.","Q_Score":0,"Tags":"python,events,kivy,touch","A_Id":60782854,"CreationDate":"2020-03-20T23:06:00.000","Title":"How do you make a button in kivy receive a touch without the one below it receiving the touch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I always use pip install (which I think is equivalent to pip3 install since I only have python3 in my env) to install packages. But I recently heard python3 -m pip install is better. Why?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3072,"Q_Id":60782785,"Users Score":1,"Answer":"It's the same thing. \npython3 -m pip install calls pip as a module in python, while pip install calls pip directly.\nThe only reason to prefer the first is that in order to use the second you need to have set pip in your environmental variables (for Windows). In older versions of python this was not done automatically during installation, rather you had to do this manually. That's why in a lot of guides you might see them using the first syntax for their instructions (because it works always, as long as you have python3 in your environmental variables. For Linux\/Mac operating systems there isn't any difference.","Q_Score":6,"Tags":"python,python-3.x,pip","A_Id":60782848,"CreationDate":"2020-03-20T23:15:00.000","Title":"python3 -m pip install VS pip3 install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"trying to open a .csv file within my script, have the .csv file UTF-8 and yet I can't work out where to save it in order to be able to open it within python, I keep getting FileNotFoundError: [Errno 2] No such file or directory: 'billing_profile_test.csv'\nAny help would be greatly appreciated, thank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12,"Q_Id":60782925,"Users Score":0,"Answer":"Hello are you working with Idle? If so you should be able to save as (ctrl + shift + s) to prompt a save menu to pop up. From there you will know the working directory where you should put your file, other than that a good place to look is \nC:\\Users\\{Your User}\\AppData\\Local\\Programs\\Python\\Python37-32","Q_Score":0,"Tags":"python-3.x,csv,import,path","A_Id":60784266,"CreationDate":"2020-03-20T23:31:00.000","Title":"Python PATH unable to be located","Data 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 an excel and create a dataframe using pandas read_excel function.\nThe thing is I only need to use columns C to F and rows 17 onward from the excel. How can I select only that part of the excel file and transform it to a dataframe in pandas???\nThank you!!!!!","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":37,"Q_Id":60783110,"Users Score":3,"Answer":"You can use the usecols parameter to select the columns of interest in your spreadsheet, and skiprows to select everything below row 17. \nimport pandas as pd\n pd.read_excel('my_spreadsheet.xlsx', usecols='C:F', skiprows=16)","Q_Score":0,"Tags":"python,pandas","A_Id":60783157,"CreationDate":"2020-03-20T23:58:00.000","Title":"Creating a Dataframe from an excel","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently we are pulling database tables from Hadoop server through AMBARI or PUTTY connections. But I would like to know is there any efficient way to pull database tables through python jupyter directly without using AMBARI or PUTTY.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":60783782,"Users Score":0,"Answer":"It's not clear what you mean by Hadoop database because neither Hive nor Hadoop are databases.\nYes, Jupyter works fine. So do libraries like pyhive \nIf you specifically want to use sql only, look at HUE or Apache Superset. \nOf course, JDBC\/ODBC clients like DBVisualizer and Tableau work too","Q_Score":0,"Tags":"python,database,hadoop,ssh","A_Id":60785330,"CreationDate":"2020-03-21T02:02:00.000","Title":"connecting to hadoop database tables","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using windows 10\n\npython version: 3.7.1 \nktrain version: 0.11.3\ntensorflow downgrade to 2.0\n\nerror log::\n\nTraceback (most recent call last):\n    File \"text_classifier.py\", line 3, in \n      import ktrain\n    File \"C:\\Users\\user\\PycharmProjects\\ai\\env\\lib\\site-packages\\ktrain__init__.py\", line 2, in \n      from .imports import *\n    File \"C:\\Users\\user\\PycharmProjects\\ai\\env\\lib\\site-packages\\ktrain\\imports.py\", line 209, in \n      import cchardet as chardet\n    File \"C:\\Users\\user\\PycharmProjects\\ai\\env\\lib\\site-packages\\cchardet__init__.py\", line 1, in \n      from cchardet import _cchardet\n  ImportError: DLL load failed: The specified module could not be found.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1408,"Q_Id":60784527,"Users Score":2,"Answer":"I was working on virtualenv\n\nI moved to conda env\npip install ktrain\npip install tensorflow=2.0\npip uninstall h5py\npip install h5py\n\nNow it's working fine, thanks for the idea conda install -c conda-forge cchardet","Q_Score":0,"Tags":"python,windows,tensorflow,dll","A_Id":60861776,"CreationDate":"2020-03-21T04:40:00.000","Title":"ktrain ImportError: DLL load failed: The specified module could not be found","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I solved an MIP problem, with making the solving process sleep for 1 second every branch using BranchCallback (single thread). I noticed from the log that the system time measured in seconds changed every run, while the deterministic time measured in ticks didn't. However, the problem was that the latter didn't even change whether the 1-second sleep was applied or not. On the contrary, The system time did record the sleep time.\nI also tried to get the deterministic time using the callback api, but it only counted 0.0 ticks for the 1-second sleep. It's not a problem about the sleep mode, because a simple piece of code counting for a large number also showed 0.0 ticks. I thought it might not record the code running time.\nWhat exactly does the determministic time measure in CPLEX? Is there any method to measure the real running time (especially the real callback running time) as the system time did, but in a deterministic way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":151,"Q_Id":60785497,"Users Score":2,"Answer":"The deterministic time is an approximation for the work that CPLEX does (you can think of it as number of instructions executed inside CPLEX). Doing nothing does not execute any instructions so does not count towards deterministic time.\nMoreover, deterministic time is only measured inside CPLEX. It does not account for time spent in user code like callbacks.\nIf you want to measure the time spent in your callback then you have to do that yourself (there is no point for CPLEX to track this): just take a time stamp at the beginning of your callback, one at the end of your callback and then compute the difference. The CPLEX callbacks have functions to take time stamps, see the reference documentation.\nIn case you want to have a determinstic time for code you wrote then you have to roll your own and first of all define what deterministic time means for your code.","Q_Score":0,"Tags":"python,cplex,deterministic","A_Id":60809454,"CreationDate":"2020-03-21T07:36:00.000","Title":"CPLEX: How to get the real running time in a deterministic way? (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 recently got started with pythonanywhere but was bummed out to notice there is no web socket support. My question today isn't about possible hacks but instead possible alternatives. Is there a solutions I could use for free or close to free specifically for carrying out my socketio microservice? It would only need to setup the socket since I would be using socketio P2P functionality, therefore this server would only be a fallback in the eventuality the client's browser does not support WebRTC. All replies are greatly appreciated. Thanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":357,"Q_Id":60786244,"Users Score":1,"Answer":"According to the socketio docs, it uses websockets when they're available, but uses long polling when websockets are not available. If you only need the connection for a short time, then long polling is fine on PythonAnywhere.","Q_Score":0,"Tags":"socket.io,webrtc,pythonanywhere","A_Id":60791135,"CreationDate":"2020-03-21T09:24:00.000","Title":"Pythonanywhere socketio alternative","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use the python googleads module in a script on Spyder.\nI have run pip install googleads and the installation has succeeded.\nHowever, when I try to import googleads in the script on Spyder, it gives me the below error:\nModuleNotFoundError: No module named 'googleads'\nI have uninstalled the package and run pip install googleads again. The installation succeeds this time as well but the above error persists.\nI have tried using conda install as well. That does not install the package.\nHowever, when I run the script on the command prompt, it works fine. The issue is only with Spyder.\nI have also Googled and looked up StackOverflow and most other communities for a solution to this but haven't been able to find one :( \nLooking forward to some help here, to fix the issue.\nThank you in advance!\nPS: I have run the pip install on the Anaconda prompt as well and that succeeds too. The error on Spyder still exists.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":564,"Q_Id":60786660,"Users Score":2,"Answer":"So I hired a freelancer with considerable experience in Anaconda and Spyder to help me fix this issue. Sharing the solution here for the benefit of everyone else.\nThere was an issue with the installation of pip in the environment I was working in. This is how we found and fixed the issue:\nOn the Anaconda prompt, we used the command conda list and checked if pip was installed. It was.\nWe then typed the command where pip and received the response below:\nC:\\Users\\Rohit\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts\\pip.exe\nWe then created a new test environment in anaconda, navigated to it and ran the same where pip command. It returned the below response:\nC:\\Users\\Rohit\\Anaconda3\\Scripts\\pip.exe\nC:\\Users\\Rohit\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts\\pip.exe\nWe figured that there was an issue with the pip installation on the environment, which is why it was installing the packages on the global environment and not the project environment.\nWe then re-installed pip on the project environment using the conda install and re-ran the where pip command. It now returned the below response:\nC:\\Users\\Rohit\\Anaconda3\\Scripts\\pip.exe\nC:\\Users\\Rohit\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts\\pip.exe\nAfter this, we installed the package using pip install googleads and then ran import googleads in Spyder. It worked perfectly fine.\nWorks fine now with all the other project packages.","Q_Score":0,"Tags":"python,anaconda,conda,spyder,google-ads-api","A_Id":60812401,"CreationDate":"2020-03-21T10:21:00.000","Title":"Unable to install the googleads module for python in anaconda (Spyder)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For example, \n int(x)\nfloat(x)\nstr(x)\nWhat is time complexity of them?","AnswerCount":2,"Available Count":2,"Score":-0.1973753202,"is_accepted":false,"ViewCount":4229,"Q_Id":60788680,"Users Score":-2,"Answer":"Float(x) is more complex among these, as it has a very long range. At the same time it depends on how much of the value you are using.","Q_Score":12,"Tags":"python,python-3.x,time-complexity","A_Id":60788794,"CreationDate":"2020-03-21T13:58:00.000","Title":"What is the time complexity of type casting function in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For example, \n int(x)\nfloat(x)\nstr(x)\nWhat is time complexity of them?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4229,"Q_Id":60788680,"Users Score":9,"Answer":"There is no definite answer to this because it depends not just what type you're converting to, but also what type you're converting from.\nLet's consider just numbers and strings. To avoid writing \"log\" everywhere, we'll measure the size of an int by saying n is how many bits or digits it takes to represent it. (Asymptotically it doesn't matter if you count bits or digits.) For strings, obviously we should let n be the length of the string. There is no meaningful way to measure the \"input size\" of a float object, since floating-point numbers all take the same amount of space.\n\nConverting an int, float or str to its own type ought to take \u0398(1) time because they are immutable objects, so it's not even necessary to make a copy.\nConverting an int to a float ought to take \u0398(1) time because you only need to read at most a fixed constant number of bits from the int object to find the mantissa, and the bit length to find the exponent.\nConverting an int to a str ought to take \u0398(n2) time, because you have to do \u0398(n) division and remainder operations to find n digits, and each arithmetic operation takes \u0398(n) time because of the size of the integers involved.\nConverting a str to an int ought to take \u0398(n2) time because you need to do \u0398(n) multiplications and additions on integers of size \u0398(n).\nConverting a str to a float ought to take \u0398(n) time. The algorithm only needs to read a fixed number of characters from the string to do the conversion, and floating-point arithmetic operations (or operations on bounded int values to avoid intermediate rounding errors) for each character take \u0398(1) time; but the algorithm needs to look at the rest of the characters anyway in order to raise a ValueError if the format is wrong.\nConverting a float to any type takes \u0398(1) time because there are only finitely many distinct float values.\n\nI've said \"ought to\" because I haven't checked the actual source code; this is based on what the conversion algorithms need to do, and the assumption that the algorithms actually used aren't asymptotically worse than they need to be.\nThere could be special cases to optimise the str-to-int conversion when the base is a power of 2, like int('11001010', 2) or int('AC5F', 16), since this can be done without arithmetic. If those cases are optimised then they should take \u0398(n) time instead of \u0398(n2). Likewise, converting an int to a str in a base which is a power of 2 (e.g. using the bin or hex functions) should take \u0398(n) time.","Q_Score":12,"Tags":"python,python-3.x,time-complexity","A_Id":60789050,"CreationDate":"2020-03-21T13:58:00.000","Title":"What is the time complexity of type casting function in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script running on my raspberry, these script is started from a command from an php page. I\u2019ve multiple if stetements, now I would like to pass new arguments to the script whithout stopping it. I found lots of information by passing arguments to the python script, but not if its possible while the svpcript is already running to pass new arguments. Thanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":42,"Q_Id":60788782,"Users Score":1,"Answer":"The best option for me is to use a configuration file input for your script.\nSome simple yaml will do. Then in a separate thread you must observe the hash of the file, if it gets changed that \nmeans somebody has updated your file and you must re\/adjust your inputs.\nBasically you have that constant observer running all the time.","Q_Score":1,"Tags":"python,raspberry-pi3","A_Id":60788836,"CreationDate":"2020-03-21T14:09:00.000","Title":"Passing arguments to a running 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":"Is it possible to replace text in label with an image in kivy?\nI have a label containing a text but i want to replace the text with an image. \nIs this possible in kivy?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":60788785,"Users Score":0,"Answer":"The answer is technically yes, but this isn't something exposed by the label api so you'd have to mess about doing stuff manually. It would probably be a better idea to put an Image on top of (or behind) the Label, and use this to display the imgae when necessary.","Q_Score":0,"Tags":"python,image,label,kivy","A_Id":60789147,"CreationDate":"2020-03-21T14:09:00.000","Title":"How to replace text in label with an image in kivy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a live Django website I need to make changes on and I want to know what's the best \/ most correct way of updating the code of the website, I have access to the remote server and access to the git.\nThanks in advance!!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":60789293,"Users Score":2,"Answer":"I would recommend that you keep an updated git repository of your project on GitHub and commit to it often. \nThen, when you are ready to publish your changes, pull your git repository down to your remote server. GitHub also allows you to keep a private repository for free now so no need to worry about confidentiality.","Q_Score":1,"Tags":"python,html,django,server,mapbox","A_Id":60789457,"CreationDate":"2020-03-21T14:56:00.000","Title":"How do I make changes on a live Django website?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm currently learning Django using python. I'm using the Django website as my reference and there is one line of code that I am supposed to enter \" python manage.py migrate'. I'm wondering what does migrate means and what does it do?\nThank You!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":60789772,"Users Score":0,"Answer":"Essentially, it syncs changes you make to the Database.  When you are just starting out on a project, you will need to enter \"python manage.py migrate\" to initially create the DB.  Later, when you add models and update them, you will need to push these changes to your DB and \"python manage.py migrate\" will do the trick.  Although you will need to enter \"python manage.py makemigrations\" first to get ready for the DB changes.","Q_Score":0,"Tags":"python,django,pycharm","A_Id":60790049,"CreationDate":"2020-03-21T15:38:00.000","Title":"What does migrate mean in django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've just finished my course of Python, so now I can write my own script. So to do that I started to write a script with the module Scapy, but the problem is, the documentation of Scapy is used for the interpreter Scapy, so I don't know how to use it, find the functions, etc. \nI've found a few tutorials in Internet with a few examples but it's pretty hard. For example, I've found in a script the function \"set_payload\" to inject some code in the layer but I really don't know where he found this function. \nWhat's your suggestion for finding how a module works and how to write correctly with it? Because I don't really like to check and pick through other scripts on Internet.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":113,"Q_Id":60790792,"Users Score":0,"Answer":"If I have understood the question correctly, roughly what you are asking is how to find the best source to understand a module. \nIf you are using an inbuilt python module, the best source is the python documentation.\nScapy is not a built-in python module. So you may have some issues with some of the external modules (by external I mean the ones you need to explicitly install).\nFor those, if the docs aren't enough, I prefer to look at some of the github projects that may use that module one way or the other and most of the times it works out. If it doesn't, then I go to some blogs or some third party tutorials. There is no right way to do it, You will have to put in the effort where its needed.","Q_Score":0,"Tags":"python,function,module,documentation,scapy","A_Id":60791154,"CreationDate":"2020-03-21T17:11:00.000","Title":"How to read the documentation of a certain 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 have a Discord bot I use on a server with friends.\nThe problem is some commands use web scraping to retrieve the bot response, so until the bot is finished retrieving the answer, the bot is out of commission\/can't handle new commands.\nI want to run multiple instances of the same bot on my host server to handle this, but don't know how to tell my code \"if bot 1 is busy with a command, use bot 2 to answer the command\"\nAny help would be appreciated!","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":4363,"Q_Id":60790811,"Users Score":-1,"Answer":"async function myFunction () {}\nthis should fix your problem\nhaving multiple instances could be possible with threads,\nbut this is just a much more easy way","Q_Score":2,"Tags":"python,bots,discord","A_Id":67353378,"CreationDate":"2020-03-21T17:12:00.000","Title":"Efficient Way to Run Multiple Instances of the Same Discord Bot (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've created a script using selenium and chromedriver on pycharm that works absolutely fine. I want to create an exe of that script so that I can run it on other PCs without installing python or the other dependencies. I've tried using pyinstaller but it is not working. Can someone guide me how can I convert that script into exe.\nThanks!!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":60791397,"Users Score":0,"Answer":"You are getting any error ? as pyinstaller is the best option to turn your script in to executables.","Q_Score":1,"Tags":"python-3.x,selenium-webdriver,pycharm,selenium-chromedriver","A_Id":62485901,"CreationDate":"2020-03-21T18:01:00.000","Title":"How to convert a selenium webscraping script to exe file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If got the following problem:\nGiven a series of rectangles defined by {x_min, height and x_max}, I want to efficiently compute their intersection and union, creating a new series.\nFor instance, if I got S1 = [{1,3,3}] and S2 = [{2,3,5}], the union would result in S3 = [{1,3,5}] and intersection in S3 = [{2,3,3}]. This would be a fairly simple case, but when S1 and S2 are a list of rectangles (unordered) It get's a little bit tricky.\nMy idea is trying some divide and conquer strategy, like using a modificated mergesort, and in the merge phase try to also merge those buildings. But I'm a little bit unsure about how to express this.\nBasically I can't write down how to compare two rectangles with those coordinates and decide if they have to be in S3, or if I have to create a new one (for the intersection).\nFor the union I think the idea has to be fairly similar, but the negation (i.e. if they don't interesct).\nThis has to be O(nlogn) for sure, given this is in a 2D plane I surely have to sort it. Currently my first approach is O(n^2).\nAny help how to reduce the complexity?\nPD: The implementation I'm doing is in Python","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":60791535,"Users Score":0,"Answer":"I tried to write the whole thing out in psudo-code, and found that it was too psudo-y to be useful and too code-y to be readable. Here's the basic idea:\nYou can sort each of your input lists in O(n*log(n)). \nBecause we assume there's no overlap within each series, we can now replace each of those lists with lists of the form {start, height}. We can drop the \"end\" attribute by having a height-0 element start where the last element should have ended. (or not, if two elements were already abutting.) \nNow you can walk\/recurse\/pop your way through both lists in a single pass, building a new list of {start, height} outputs as you go. I see no reason you couldn't be building both your union and intersection lists at the same time.\nCleanup (conversion to a minimal representation in the original format) will be another pass, but still O(n).\nSo the problem is O(n*log(n)), and could be O(n) if you could finagle a way to get your input pre-sorted.","Q_Score":0,"Tags":"python,algorithm","A_Id":60795389,"CreationDate":"2020-03-21T18:13:00.000","Title":"Efficient unions and intersections in 2D plane when y_min = 0","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need a suggestion in unsupervised training of Doc2Vec for the 2 options I have. The scenario is I have N documents each of size greater than 3000 tokens. So now for training which alternative is better:\n\nTraining with whole document as such.\nBreaking the documents into chunks of 1000 tokens and then training it.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":60,"Q_Id":60792362,"Users Score":1,"Answer":"You should watch out for docs with more than 10000 tokens \u2013 that's an internal implementation limit of gensim, and tokens beyond the 10000th position in a single document will be ignored.\nBut whether you should split documents into 1000-token chunks is entirely dependent on what works best for your specific data and goals. If you have reason to consider it \u2013 perhaps you want to get back results of subdocument ranges? \u2013 then you should try it, compare the results to the alternative, and use whichever works better. There is no general answer.","Q_Score":0,"Tags":"python,gensim,doc2vec","A_Id":60796323,"CreationDate":"2020-03-21T19:29:00.000","Title":"Doc2Vec Unsupervised training","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a document term matrix. In my case it is not like documents x words but it is sentences x words so the sentences will act as the documents. I am using 'l2' normalization post doc-term matrix creation.\nThe term count is important for me to create summarization using SVD in further steps.\nMy query is which axis will be appropriate to apply 'l2' normalization. With sufficient research I understood:\n\nAxis=1 : Will give me the importance of the word in a sentence (column wise normalization)\nAxis=0 : Importance of the word in a document (row wise normalization).\n\nEven after knowing the theory I am not able to decide which alternative to choose because the choice will greatly affect my summarization results. So kindly guide me a solution along with a reason for the same.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":60793533,"Users Score":1,"Answer":"By L2 normalization, do you mean division by the total count?\nIf you normalize along axis=0, then the value of x_{i,j} is the probability of the word j over all sentences i (division by the global word count), which is dependent on the length of the sentence, as longer ones can repeat some words over and over again and will have a much higher probability for this word, as they contribute a lot to the global word count.\nIf you normalize along axis=1, then you're asking whether sentences have the same composition of words, as you normalize along the lenght of the sentence.","Q_Score":1,"Tags":"python,normalization,countvectorizer,lsa","A_Id":60798114,"CreationDate":"2020-03-21T21:35:00.000","Title":"In count vectorizer which axis to use?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am going to save a list of arrays into a file that can be read in Matlab. The arrays in the list are of 3-dimensional but varied shapes, so I cannot put them into a single large array. \nOriginally I thought I could save the list in to a pickle file and then read the file in Matlab. Later I found Matlab does not support reading the pickle file. I also tried using scipy.io.savemat to save the list to a mat file. The inconsistencies of array dimensions causes saving problems. \nAnyone has ideas of how to solve the problem? It should be noted that the list file is very large in memory (>4 G).","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":567,"Q_Id":60794727,"Users Score":1,"Answer":"If you don't need a single file, you can iterate through the list and savemat each entry into a separate file. Then iterate through that directory and load each file into a cell array element. \nYou can also zip the directory you store these in, to get one file to pass around.","Q_Score":0,"Tags":"python,matlab,numpy,scipy","A_Id":60795163,"CreationDate":"2020-03-22T00:26:00.000","Title":"How to save a Python list of arrays of varied dimensions to mat file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I get the width and height of a cell in pixels? excel, openpyxl, python\nI need to fit the picture by cell size","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":126,"Q_Id":60800789,"Users Score":0,"Answer":"for VBA you just need call cells(row,col).width","Q_Score":0,"Tags":"python,excel,openpyxl","A_Id":60808097,"CreationDate":"2020-03-22T14:50:00.000","Title":"How do I get the width and height of a cell in pixels? excel, openpyxl, python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m interested in and researching how to build an indeed bot that applies to applications for me as well as all the other application job sites. so I can work a lot smarter and have more leads and clients coming in.\nI want to automate this process as it takes personal time to apply to each application. and I want to create a bot that goes to all the job sites for me and apply for me.\nsuch as:\nIndeed\nGlassdoor\nMonster\nLinkedin\netc\u2026\nI see there is a lot of great web developers and coders in this forum. and I know you guys have the skills and knowledge to give amazing information on this subject!\nHow should I go about doing this?\nHow do I get started on this project?\nWhat are the steps I need to make to make this happen?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":212,"Q_Id":60801161,"Users Score":0,"Answer":"The only other recommendation I can make would be to pick a tool set (e.g., a programming language, database, operating system) and ask specific questions about those around a bit more detail about how you would do things.  Otherwise, good work.","Q_Score":0,"Tags":"python,automation,project,build-automation","A_Id":60804048,"CreationDate":"2020-03-22T15:24:00.000","Title":"How to Build | Code an Indeed Bot to Automate Applying to 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":"How can I get my first statement, when my value is N","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":60801324,"Users Score":0,"Answer":"Hope this helps!\nI think during the parametrization those inputs becomes somewhat like this\ntest_func(stringg='red=4,..', keyy='red', valuee=None, expected_result='green=7')\nsame as \ntest_func(stringg='red=4,..', keyy='red', valuee, expected_result='green=7')\nIf you are not passing a value then, its default values are None.\nWhen passing arguments, keyValue arguments should be last and default arguments must be first.\nSuggestion: try to pass the inputs as key-value pairs. If you are not passing a value then its value is None.","Q_Score":1,"Tags":"python,testing,pytest","A_Id":60801442,"CreationDate":"2020-03-22T15:38:00.000","Title":"How can I pass None value in my test part?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently trying to light up a 32x60 led matrix made of single WS2812B led strips. With the node-red-node-pi-neopixel node, i have to write 10 different msgs if I want to light up 10 leds that are not next to each other. Since the node uses a csv, it there another way to pass a more complex csv that uses ';' to light up more than one array?\nLike '1,255,255,0;5;2550,255'.\nOr if there are other ways, I'm more than happy to here from you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":60802661,"Users Score":0,"Answer":"The node can't take an array, but you can achieve the same thing using a split node.\nIf you create and array of values representing the whole string of LEDS using n,r,g,b for each element in the array then pass this to the split node and then on to the neopixel node, it will break the array up into individual messages and send them in sequence.\nYou can use n,0,0,0 for any LEDs you want to be off.","Q_Score":0,"Tags":"python,node-red,led,neopixel","A_Id":60803822,"CreationDate":"2020-03-22T17:30:00.000","Title":"How to pass a csv to light more single leds in one msg payload with node-red-node-pi-neopixel library","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im trying to selenium in python 3.8.0 but it doesn't work I get this error: Fatal error in launcher: \n\nUnable to create process using '\"c:\\program files (x86)\\python37-32\\python.exe\"  \"C:\\Program Files (x86)\\Python37-32\\Scripts\\pip.exe\" install selenium'","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":68,"Q_Id":60803447,"Users Score":-1,"Answer":"Try including your pip into your environmental variables and also your Scripts directory","Q_Score":0,"Tags":"python,selenium","A_Id":64872393,"CreationDate":"2020-03-22T18:37:00.000","Title":"Cant install selenium in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to automate a process in which a python file is uploaded to a web portal by the user(let's say the code is math formula) ,in the back-end the code in the file is computed through different input values that already exists in the back-end and the outputs of the computation will be returned on web-page of the user.?If this is possible then what will be the approach to do this? If possible can we also provide the graphical representation of the different outputs to the user?Or if not then can anyone provide any resource or references or any help that will help me to solve this problem?\n!THANKS IN ADVANCE!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":60803694,"Users Score":0,"Answer":"In order to execute the uploaded Python file by the user you have to spawn a Python process from your backend server and pass it the name of file. Pass the arguments the the script also here. Save the output on your server and expose it to the user via a HTTP request.","Q_Score":0,"Tags":"javascript,python-3.x,frontend,backend,server-side-rendering","A_Id":60805204,"CreationDate":"2020-03-22T19:01:00.000","Title":"How to Automate the process of reading code, computing it and providing the output on web page to the user?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a relatively large queryset and i want to export it into excel file i was useing the XLWT library and django streaming response with csv file.\nwhen i export very large queryset of a table in sqldeveloper or navicat, the export operation is very fast but django's libraries is relatively slow. i think the excel write by row and column, or csv streaming response, write row by row in file but i looking for a way to write whole of queryset to excel.\nis there a way to export whole of queryset to excel in python django?\nSomething that comes to my mind is call os command in python code to run export command in database but i not tested it.\nthanks everybody","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":320,"Q_Id":60803795,"Users Score":0,"Answer":"I should have used pandas.\nadjust and add my queryset in data frame and to_excel or to_csv.\nthanks anyway","Q_Score":0,"Tags":"python,django,excel","A_Id":60824753,"CreationDate":"2020-03-22T19:13:00.000","Title":"django export large excel queryset","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am learning Python by reading books, and I have a question about methods. Basically, all of the books that I am reading touch on methods and act like they just come out of thin air. For example, where can I find a list of all methods that can be applied? I can't find any documentation that lists all methods. \nThe books are using things like .uppercase and .lowercase but is not saying where to find other methods to use, or how to see which ones are available and where. I would just like to know what I am missing. Thanks. Do I need to dig into Python documentation to find all of the methods?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19,"Q_Id":60804755,"Users Score":0,"Answer":"There is a lot of function in Python's modules. If you want to learn were you can find them, you should ask what you want. For example there is a random module and you can find some functions like random.randint.","Q_Score":0,"Tags":"python,function,methods,attributes","A_Id":60805056,"CreationDate":"2020-03-22T20:43:00.000","Title":"Python Methods (where to find additional resources)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I updated Anaconda-Navigator to 1.9.12 on ubuntu and now my environments dont work. \nI can still start a jupyter notebook from the environment but all my installed packages are not available even though they are displayed in the anaconda-navigator gui under installed packages for this env. \nbut when I import a package in a notebook : ModuleNotFoundError: No module named ....\nThe standard packages like numpy are available though...\nPlease help me... why did I update!!!!????\nmaybe a path problem? Please help me in simple terms \nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":348,"Q_Id":60805199,"Users Score":0,"Answer":"I think this is a bug. My experiance is that when you upgrade to Navigator to 1.9.12.\nthe enviroment variables in GUI(Navigator UI), are taken from base enviroment not from second enviroment and if you work from console it work, so it looks like it not executes conda activate new_environment in gui. When you work from terminal everythings works fine.\nTo be honest it has the same behaviour if fresh install last anaconda too. This was the reason i have downgraded conda isntallation, and than i found out that last version of navigator was making the issues . Or you can downgrade:\nconda install anaconda-navigator=1.9.7.","Q_Score":0,"Tags":"python,anaconda,conda","A_Id":61206708,"CreationDate":"2020-03-22T21:31:00.000","Title":"After updating Anaconda-Navigator environments dont work","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi so I'm new with running an open source project. Currently, I want to let other people contribute to my project, but I'm running into a problem right now. How would I share my environment variables which other users to make sure that their app runs locally. Is there a way to have contributors run my project locally without having all of their environment variables configured? I thought of having the person make their own environment variables, but since I have quite a bit of environment variables, I would like to avoid that. \nNote: I'm running a Flask App for my backend.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":60807171,"Users Score":1,"Answer":"I generally include a \"run\" script, which is in charge of:\n\nsetting the right environment variables\ncheck the PATH for execution environment dependencies (making sure you have the right minimum version of some executable required to run your project)\nrunning the actual project.","Q_Score":3,"Tags":"python,flask,github,backend","A_Id":60808413,"CreationDate":"2020-03-23T02:18:00.000","Title":"How to share my environment variables with open source projects?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have read through serval tutorials about concurrency in python and I also know the differences between concurrency and Parallelism, but I am still a little bit confused about the definition of concurrency. \nMany people define concurrency as executing multiple tasks at the same time. I am wondering what are tasks in python. Are they functions? Can I say concurrency in Python is executing multiple functions at the same time?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":60807416,"Users Score":1,"Answer":"Many people define concurrency as executing multiple tasks at the same time\n\nThe tasks here is not defined from the computer's view, but we human's view. As long as we can confirm things are not being served strictly in order(no one is blocking another), we can say they are happening concurrently.\n\nCan I say concurrency in Python is executing multiple functions at the same time?\n\nThere are plenty of ways to support concurrency in Python, executing multiple functions(via multi-threads or multi-processes) at the same time is absolutely one of them(actually this is parallelism), but not the only one.","Q_Score":0,"Tags":"python,concurrency","A_Id":60807742,"CreationDate":"2020-03-23T02:57:00.000","Title":"Does concurrency in Python mean executing multiple functions at the same time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can i connect to multiple websockets in a loop using websocket_client module in python. I tried with to connect under a loop it just connect first of them.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":60807880,"Users Score":0,"Answer":"If are you using websocket_client you can use threading for connecting multiple websockets at a time.","Q_Score":0,"Tags":"python,websocket","A_Id":60882962,"CreationDate":"2020-03-23T04:16:00.000","Title":"Connecting to multiple Websockets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a more or less complex kivy app. When I run it on my pc (which isn't the best but also isn't the worst) the CPU needs about 40% power for running it. I thought it was the fault of my code, but it needs even a bit more power when running the pong example in the kivy_venv. So my question is will this issue solve when creating an apk for play store or will it still need this much power?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":97,"Q_Id":60812697,"Users Score":0,"Answer":"There's nothing about making an APK that is expected to reduce cpu usage, but that much cpu usage shouldn't be necessary. I wonder if there's something you're doing to cause it, or perhaps you have found a bug.","Q_Score":1,"Tags":"python,android,kivy,cpu,game-development","A_Id":60821758,"CreationDate":"2020-03-23T11:28:00.000","Title":"Does the CPU Usage of a kivy app drop when creating an apk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"what does ahead of any installs of python or git mean? does it mean something like making a copy of the git files to a new folder at the end of \"C:\\src\\depot_tools\\\"?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":60813273,"Users Score":0,"Answer":"PATH is the environment variable consisting of directories searched for program names. \u201cAhead of\u201d usually means before; i.e., the directory where depot_tools is should be earlier on PATH (more to the left) than any python or git. (Why? I have no idea... I\u2019m not familiar with the tool.)","Q_Score":0,"Tags":"python,git,visual-studio,environment-variables,chromium","A_Id":60813633,"CreationDate":"2020-03-23T12:07:00.000","Title":"Add depot_tools to the start of your PATH (must be ahead of any installs of Python and or 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":0,"Web Development":0},{"Question":"Im using visual studio community and i cant collapse \/ expand parts of my code anymore. The plus \/ minus symbol is just gone. So now i cant collapse functions, loops etc.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":149,"Q_Id":60815973,"Users Score":0,"Answer":"Go to Settings and set \n\n\"editor.folding\": true\n\"editor.foldingStrategy\": \"auto\"\n\"editor.showFoldingControls\": \"always\"","Q_Score":1,"Tags":"c#,python,visual-studio,visual-studio-2019","A_Id":60816336,"CreationDate":"2020-03-23T14:54:00.000","Title":"Visual studio no collapse \/ expand option","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm generating .docx files from Word documents that have changed Fonts but maintain the same format, style and information content. All has been done via the python-docx API.\nThere are still working-arounds not within the scope of the API (such as duplicating numeric bullets from source and inserting non-strings into Headers\/Footers). I'm approaching these via lxml.\nThe XML of the original file and the generated file, while similar, are not identical irrespective of the lack of <w:numPr> tags.  Why is that? The output .docx files look as expected.\nThis complicates working with low level lxml fixes.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":60817879,"Users Score":1,"Answer":"Your assumption that there would be only a single way to represent a document in as complicated of a format as OOXML, especially generated from independently written code bases, is very much invalid.\nSo the answer to your question is that multiple OOXML representations can yield the same appearance in Microsoft Word (or any other DOCX application); it is not safe to assume that any given library will write any given OOXML exactly the same as any given DOCX application would.","Q_Score":0,"Tags":"python,xml,lxml,openxml,python-docx","A_Id":60818319,"CreationDate":"2020-03-23T16:42:00.000","Title":"Why a Word file duplicated with python-docx has different XML than the original","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a web server which has Django framework and I am struggling with outer world access to server. While saying outer world I am trying to say a python program that created out of Django framework and only connects it from local PC which has only Internet connection. I can't figured it out how can I do this.\nI am building this project in my local host, so I create the \"outer world python program\" outside of the project file. I think this simulation is proper.\nI am so new in this web server\/Django field. So maybe I am missing an essential part. If this happened here  I'm sorry but I need an answer and I think it is possible to do.\nThanks in advance...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":25,"Q_Id":60819967,"Users Score":0,"Answer":"Django generated fields in database are just standard fields. The tables are named like 'applicationname'_'modelname', you are free to do requests to the database directly, without django.\nIf you want to do it through django, your outer program can request a web page from your web server, and deal with it. (You may want to take a look at RESTs frameworks)","Q_Score":1,"Tags":"python,django,database,django-models,webserver","A_Id":60820292,"CreationDate":"2020-03-23T18:58:00.000","Title":"How to reach and add new row to web server database which made in Django framework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I used turtle.write to write something on the screen. How do I hide it completely. Not the turtle icon thing, but what's written.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":86,"Q_Id":60820902,"Users Score":2,"Answer":"@penny12 use turtle.clear() to hide text created with turtle.write()","Q_Score":3,"Tags":"python,turtle-graphics,python-turtle","A_Id":60820966,"CreationDate":"2020-03-23T20:11:00.000","Title":"How do I hide something a turtle drew previously?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After using the pyintaller to transfer the py file to exe file, the exe file throws the error: \"Failed to load dynlib\/dll\". Here is the error line: \n\nmain.PyInstallerImportError: Failed to load dynlib\/dll 'C:\\Users\\YANGYI~1\\AppData\\Local\\Temp\\_MEI215362\\sklearn\\.libs\\vcomp140.dll'.\n  Most probably this dynlib\/dll was not found when the application was\n  frozen. [1772] Failed to execute script 2\n\nafter get this, I did check the path and I did not find a folder called \"_MEI215362\" in my Temp folder, I have already made all files visible. Also, I have re-download the VC but and retransferring the file to exe, but it didn't work. Any ideas how to fix the issue? Thank you in advance!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3961,"Q_Id":60822141,"Users Score":0,"Answer":"I also encountered a similar problem like Martin.\nIn my case, however, it was the ANSI64.dll missing...\nSo, I simply put the particular dll file into the dist directory.\nLastly, I keep the exe and related raw data files (e.g. xlsx, csv) inside the \"dist\" folder and to run the compiled program. It works well for me.","Q_Score":2,"Tags":"python,python-3.x,terminal,pyinstaller","A_Id":67855772,"CreationDate":"2020-03-23T22:03:00.000","Title":"Failed to load dynlib\/dll (Pyintaller)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get some data using API calls in my Python script. I am currently using the requests library which takes about 47 mins for 5K rows. Is there any other library in python faster than requests?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":60822609,"Users Score":0,"Answer":"For synchronous calls, pycurl is the fastest.","Q_Score":0,"Tags":"python-2.7,api,python-requests","A_Id":62533345,"CreationDate":"2020-03-23T22:48:00.000","Title":"Python library for API call which is faster than requests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to delete drawn objects with OpenCV in Python ?\n\nI draw objects on click (cv2.rectangle, cv2.circle) ...\nThen I would like to delete only drawn objects.\nI know that i need to make a layer in behind of the real image and to draw on another one.\nBut I do not know how to implement this in code.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1279,"Q_Id":60823140,"Users Score":0,"Answer":"Have a method or something that when it's executed, will replace the image with stuff drawn on it with an original unaltered image. It's best to create a clone of your original image to draw on.","Q_Score":0,"Tags":"python,opencv,computer-vision","A_Id":60823211,"CreationDate":"2020-03-23T23:50:00.000","Title":"How to delete drawn objects with OpenCV in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have files with functions which I've already compiled with pyinstaller. How would I import these files' functions into a new python file? Is this even possible?\n(The idea is for them to be somewhat of an equivalent to a Windows dll. Ideally I would like to dynamically import functions from these files.)\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":60824850,"Users Score":0,"Answer":"As far as I know,no.The pyinstaller basicly creates a compiled .pyc file plus the interpter.\nIf you want to have something like the DLL, you may turn to the .pyd files.","Q_Score":0,"Tags":"python,python-3.x,pyinstaller","A_Id":60824972,"CreationDate":"2020-03-24T04:10:00.000","Title":"How to import pyinstaller modules\/files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I executed an AWS Glue Job via API Gateway to start the job run. The job run is successful. But the result of the Script (print of a result) has not gotten through the execution. Only job run ID comes as the response. Is there any way to get the result of the job through an API?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":253,"Q_Id":60825670,"Users Score":1,"Answer":"For glue anything you print or log goes into cloud watch\nYou have an option of adding a handler in your logger that writes to a stream and push that stream to a file in s3. Or better yet, create a StringIO object , store your result to it and then send that to s3","Q_Score":0,"Tags":"python-3.x,amazon-web-services,aws-api-gateway,aws-glue","A_Id":60843757,"CreationDate":"2020-03-24T05:59:00.000","Title":"How to get results of AWS Glue Job when executing via API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on a python script so as you can imagine I have variables, I have data frames ecc ecc. I create these data frames importing files from excel. \nAt the same time, I am working with another person and this person asked me to send the python script and all the environment to send him the variables (data frames ecc ecc) instead of sending him all the excel file that I used to create the aforementioned df.\nI do not understand the way I am supposed to do it. How can I send the entire environment to allow him to see the df that i see in my spyder script without sending the excel file to upload into the script??\nThanks!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":60827117,"Users Score":0,"Answer":"\"The environment\" refers to all the environment variables you need to run your script. If you don't need any edit to environment variables in order to run your script, you can just ignore that.\nYou'll need to send him your Python script (file with .py extension) and excel files. You cannot deliver him pandas dataframes, as they are in memory of your script when running.","Q_Score":0,"Tags":"python","A_Id":60827178,"CreationDate":"2020-03-24T08:13:00.000","Title":"share python script \/ environmental variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pylint missing-docstring seems to ignore some functions and private methods in classes.\nHow can I make pylint enforce that all functions and methods have to have docstrings in a certain repository?\none option I've found is to disable ignoring of private functions:\nno-docstring-rgx='a^'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":559,"Q_Id":60827287,"Users Score":5,"Answer":"Try to use: no-docstring-rgx=__.*__\nthis should take into account all functions.\nBy default is: no-docstring-rgx=^_\nWhich skips private methods","Q_Score":2,"Tags":"python-3.x,pylint,pylintrc","A_Id":61207094,"CreationDate":"2020-03-24T08:25:00.000","Title":"How to make pylint enforce docstrings for all functions and methods in a repository","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering if there is any way to use selection_glyph as the renderer of HoverTool in bokeh, i am using python and tried to add a name label to the selected glyph and then using plot.hover.names, but it does not work. \nBasically i have a plot with many glyphs and i want the tooltip to appear when a glyph is selected (single click), and not when a mouse is just hovered over it? is it possible at all? thanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":60828308,"Users Score":0,"Answer":"I'm afraid that's not possible with the vanilla HoverTool and without creating additional renderers.\nThe tool works with renderers, not with glyphs, and it doesn't know anything about selection. So you can either create a glyph that's rendered only when something is selected (which is finicky at best), or you can create a custom version of HoverTool.","Q_Score":0,"Tags":"python-3.x,bokeh","A_Id":60829103,"CreationDate":"2020-03-24T09:35:00.000","Title":"Using selection_glyph as renderer for hovertool","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My problem: I am composing a data source that I pass to the constControl(..., ds=ds, ...) that will be updated iteratively. It is the result of a series of calculations at every timestep coming from a model that I built. After passing the results of my model (loads) at every timestep, I want to call run_timeseries and store the results before going to the next iteration.\nTrying to store some results (e.g. net.res_bus.vm_pu, ...) into a list fails to update the values after every iteration as if the data source object had constant values throughout the iterations, which it doesn't.\nMy solution: I found that calling OutputWriter() before the run_timeseries() and letting it output an excel file at every iteration successfully updates the results I am simultaneously storing in that empty list. So it works now!\nMy question: I don't want to be forced to output excel files every time I run_timeseries() in order for the results to be stored and\/or successfully updated in the next iteration. I do not even need excel files at the moment. Is there any way to not having to call OutputWriter() but store net's result values in an empty list?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":60838667,"Users Score":0,"Answer":"You don't neet to use OutputWriter(). It depends in what you're trying to do, if you create a loop that make the same as run_timeseries() that might work.\nIn my case I wanted to change the load and make a new power flow calculation every time the change was made.\nA overview of the steps taken:\n\nCreate a loop\n\nEach step change the load using map to go through all item in net.load.p_mw for example.\n\nCall the run_control(net) to make the new power flow calculation.\n\n\nThen you can create a list to collect the data and convert it in JSON.\n\ndata = all bus data\njson = { dataBuses: data }\n\nOnce it's in JSON format you can even send to a database by a post request or whatever you desire.","Q_Score":0,"Tags":"python,iteration,pandapower","A_Id":62493799,"CreationDate":"2020-03-24T20:18:00.000","Title":"pandapower python: need OutputWriter before run_timeseries for updating net result","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"is there something i can do to use NumPy in IBM quantum experience? I have searched on google but i couldn't find anything. I thought about coping the source code, any suggestion?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":60839687,"Users Score":0,"Answer":"NumPy is one of the pre-installed packages (it's a pre-requisite for Qiskit, for one thing). You should be able to just do import numpy from your Jupyter notebook.","Q_Score":0,"Tags":"python,quantum-computing","A_Id":60848813,"CreationDate":"2020-03-24T21:34:00.000","Title":"using third part modules in IBM quantum experience","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been unable to find any way to add a box annotation to a bokeh plot between the same set of hours for each day on a graph. For example, if I had a line graph of hourly data for an entire month, is it possible to add a box annotation between the hours of 5 and 10 each day without explicitly coding the left\/right bounds of the box for each day in the dataset?\nDoes anyone know of any other solution in order to highlight on the graph the same time frame each day?\nX-axis is in datetime format","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":159,"Q_Id":60839898,"Users Score":1,"Answer":"Box annotations don't accept neither a data source nor an array of values.\nYou have 3 options:\n\nJust as you said, explicitly specify the bounds\nIf it's possible, replace them with rect glyphs that accept data sources and\/or arrays\nCreate a custom annotation class that renders multiple boxes","Q_Score":1,"Tags":"python,pandas,bokeh,pandas-bokeh","A_Id":60840033,"CreationDate":"2020-03-24T21:51:00.000","Title":"Is there a way to use bokeh box annotation to highlight the same time frame each day?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a python script that connects to a remote Oracle database and inserts some data into its tables.\nIn the process I had to first import cx_Oracle package and install Oracle InstantClient on my local computer for the script to execute properly.\nWhat I don't understand is why did I have to install InstantClient?\nI tried to read through the docs but I believe I am missing some fundamental understanding of how databases work and communicate.\nWhy do I need all the external drivers, dlls, libraries for a python script to be able to communicate with a remote db? I believe this makes packaging and distribution of a python executable much harder.\nAlso what is InstantClient anyway?\nIs it a driver? What is a driver? Is it simply a collection of \"programs\" that know how to communicate with Oracle databases? If so, why couldn't that be accomplished with a simple import of a python package?\nThis may sound like I did not do my own research beforehand, but I'm sorry, I tried, and like I said, I believe I am missing some underlying fundamental knowledge.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":71,"Q_Id":60840650,"Users Score":1,"Answer":"We have a collection of drivers that allow you to communicate with an Oracle Database. Most of these are 'wrappers' of a sort that piggyback on the Oracle Client. Compiled C binaries that use something we call 'Oracle Net' (not to be confused with .NET) to work with Oracle.\nSo our python, php, perl, odbc, etc drivers are small programs written such that they can be used to take advantage of the Oracle Client on your system. \nThe Oracle Client is much more than a driver. It can include user interfaces such as SQL*Plus, SQL*Loader, etc. Or it can be JUST a set of drivers - it depends on which exact package you choose to download and install. And speaking of 'install' - if you grab the Instant Client, there's nothing to install. You just unzip it and update your environment path bits appropriately so the drivers can be loaded.","Q_Score":0,"Tags":"python,sql,database,oracle,database-connection","A_Id":60840804,"CreationDate":"2020-03-24T23:04:00.000","Title":"Explain the necessity of database drivers, libraries, dlls in a python application that interacts with a remote database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python\/pycharm and AWS SAM applications. My company has created a few AWS SAM apps and they have worked previously on my machine. Now I am unable to get even the example hello world AWS SAM solution to run on my machine. I'm not sure if this is a docker or pycharm issue. When I try to debug the application, this is the error I receive:\nFetching lambci\/lambda:python3.8 Docker container image...............\nMounting C:\\Dev\\git\\ULServices\\TestRun.aws-sam\\build\\HelloWorldFunction as \/var\/task:ro,delegated inside runtime container\n\/var\/lang\/bin\/python3.8: can't open file '\/tmp\/lambci_debug_files\/pydevd.py': [Errno 1] Operation not permitted\nI am on Windows 10 and have the latest version of Docker\/PyCharm\/AWS SAM CLI","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":479,"Q_Id":60840846,"Users Score":1,"Answer":"This was a Docker issue. Release 2.2.0.5 on Apr 2, 2020 fixed the issue. From their release notes: \nFixed a bug where opening a read-only file would fail with an Operation not permitted error. Fixes docker\/for-win#6016 and docker\/for-win#6017.\nI have turned off automatic updates since this is what initially caused the issue for me since it was working in a previous version.","Q_Score":2,"Tags":"python,docker,pycharm,aws-sam","A_Id":60995639,"CreationDate":"2020-03-24T23:23:00.000","Title":"Not able to debug AWS SAM hello world application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"while scr_1 <= 4   or scr_2 <= 4 :#scr stands for score\nThe thing happening here is that my while loop ends only when BOTH scores have reached 5! I want it to end when only one of the above reaches 5! Please help me.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":237,"Q_Id":60842315,"Users Score":1,"Answer":"turn your 'or' to an 'and'\nthe reason for this is because you want the loop to only continue if both scr_1 and scr_2 is less than or equal to 4.","Q_Score":0,"Tags":"python,while-loop,or-operator","A_Id":60842350,"CreationDate":"2020-03-25T02:46:00.000","Title":"Why is my OR operator not working in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running multiple ipython consoles on spyder. I am wondering if all these ipython processes run on the same core or in different cores for each process.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":426,"Q_Id":60843489,"Users Score":0,"Answer":"It seems so. From task manager ---> performance ---> logical process,  we can have the idea about which processers are used by how much.","Q_Score":1,"Tags":"ipython,spyder,multicore","A_Id":60843591,"CreationDate":"2020-03-25T05:37:00.000","Title":"Does each Spyder ipython console run on a different core\/processor or on the same core\/processor?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is a Twitter user who posts valuable stuff and I want to save his tweets not as text but as images (screenshots) just as you see it on your phone or computer.\nI installed python-twitter and tweepy but I didn't find a solution in the docs and neither in communities so far. \nAlternatively: Is there another way to save tweets in a kind of pretty, visually appealing way? \nThank you in advance.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":622,"Q_Id":60844601,"Users Score":1,"Answer":"I usually use this site called tweetcyborg.com It converts any tweet into an image.","Q_Score":0,"Tags":"twitter,tweepy,python-twitter","A_Id":60850782,"CreationDate":"2020-03-25T07:39:00.000","Title":"How can I save tweets of a user as images?","Data Science and Machine Learning":0,"Database and SQL":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":"There is a Twitter user who posts valuable stuff and I want to save his tweets not as text but as images (screenshots) just as you see it on your phone or computer.\nI installed python-twitter and tweepy but I didn't find a solution in the docs and neither in communities so far. \nAlternatively: Is there another way to save tweets in a kind of pretty, visually appealing way? \nThank you in advance.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":622,"Q_Id":60844601,"Users Score":0,"Answer":"I figured it out. Using Selenium Webdriver to open the Twitter account page in the browser, then scrape the tweets and use a screenshot tool to make an image. This looping through all tweets.","Q_Score":0,"Tags":"twitter,tweepy,python-twitter","A_Id":65981671,"CreationDate":"2020-03-25T07:39:00.000","Title":"How can I save tweets of a user as images?","Data Science and Machine Learning":0,"Database and SQL":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":"Let's assume there are two networks called A and B.\nI want to train the network A to get the output which is also the input of network B. \nNetwork B can be considered as a trained network by other people. My work is to train the network A and the weights of network B would be fixed.\nCan it work?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":60844997,"Users Score":0,"Answer":"It surely works, you just don't apply backpropagation to the weights of B.","Q_Score":0,"Tags":"python,tensorflow","A_Id":60848964,"CreationDate":"2020-03-25T08:14:00.000","Title":"Can I train a network to get the output for the other network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having issues with importing my modules into jupyter. I did the following:\n\nCreate virtual env\nActivate it (everything below is in the context of my venv)\ninstall yahoo finance module: pip install yfinance\nopen python console and import it to test if working > OK!\nopen jupyter notebook\nimport yfinance throws ModuleNotFoundError: No module named 'yfinance'\n\nAny suggestions on how to fix this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3551,"Q_Id":60846894,"Users Score":0,"Answer":"try this one in your jupyter and the run it\n!pip install yfinance","Q_Score":3,"Tags":"python,jupyter-notebook,anaconda,jupyter,python-import","A_Id":72197390,"CreationDate":"2020-03-25T10:26:00.000","Title":"Module not appearing in jupyter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to install Anaconda 2020.02 under Windows 10 and it hangs during the installation process at the point when it tries to extract \u201canaconda-2020.02-py37_0.tar.bz2\u201d. \nThe only peculiarity of my machine is that I have Windows Subsystem for Linux activated (on which I installed Ubuntu with it\u2019s own copy of Anaconda). \nAny idea if this could be the problem?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":653,"Q_Id":60849811,"Users Score":0,"Answer":"I waited for a long time until the installation passed that point that looked like it hung. It doesn't really hang. It just takes a really long time.","Q_Score":2,"Tags":"python,anaconda,windows-subsystem-for-linux","A_Id":64019781,"CreationDate":"2020-03-25T13:25:00.000","Title":"Installation of Anaconda 2020.02 fails under Windows with activated WSL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"im working on a new project where by i wish to be able to build a django project around an existing SAPB1 application that is in production. My goal of doing so is to be able to extract certain information from SAP database and sync them with my django database as well as write certain things into the SAP database from my django program. An example is , i would wish to generate a payment voucher from my program , and write it into the SAP data base. \nIs there a suitable API for such a task? I have done certain research and it seems like my client's SAPB1 does not have python RFC feature. A possible alternative would be the DI API , however most materials are written in c# which is not my expertise , therefore would love to hear your advise! \nthanks!","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":745,"Q_Id":60850140,"Users Score":0,"Answer":"you can load the DI API dll with pywin32 to python.\nYou can get the company object and query, add, and modify whatever you need.\nIssue with Django (and Flask) might be, that it is loading multiple threads, and therefore be not very efficient (compared to DI Server). Be sure to share one connection.","Q_Score":1,"Tags":"python,django,sapb1,sap-business-one-di-api","A_Id":66844468,"CreationDate":"2020-03-25T13:44:00.000","Title":"SAPB1 and django integration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"im working on a new project where by i wish to be able to build a django project around an existing SAPB1 application that is in production. My goal of doing so is to be able to extract certain information from SAP database and sync them with my django database as well as write certain things into the SAP database from my django program. An example is , i would wish to generate a payment voucher from my program , and write it into the SAP data base. \nIs there a suitable API for such a task? I have done certain research and it seems like my client's SAPB1 does not have python RFC feature. A possible alternative would be the DI API , however most materials are written in c# which is not my expertise , therefore would love to hear your advise! \nthanks!","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":745,"Q_Id":60850140,"Users Score":1,"Answer":"I will vote to the Service Layer which is a RESTFul API that allows you to build your strong extension platform.  It builds on core protocols such as HTTP and OData, and provides a uniform way to expose full-featured business objects on top of a highly scalable and high-availability Web server.","Q_Score":1,"Tags":"python,django,sapb1,sap-business-one-di-api","A_Id":68366030,"CreationDate":"2020-03-25T13:44:00.000","Title":"SAPB1 and django integration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to evaluate a home-made topic model. For this, I'm using the list of topics (represented by keywords), and want to use a gensim.models.coherencemodel.CoherenceModel, and call it on a corpus, which is a list of strings (each one being a document).\nThe CoherenceModel requires a Dictionary, but I don't understand what this corresponds to, and how I can get it.\nI'm using the TfidfVectorizer from sklearn to vectorize the text, and glove embeddings from gensim to compute similarities within my model.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":60850956,"Users Score":0,"Answer":"From the docs, a Dictionary can be created from a corpus where the corpus is a list of lists of str. This same corpus should be passed in the text argument of the CoherenceModel.","Q_Score":0,"Tags":"python,gensim","A_Id":60852969,"CreationDate":"2020-03-25T14:31:00.000","Title":"Topic Coherence with Dictionary from Glove (gensim)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning python3 by using cs1robots library.\nSo I typed \"from cs1robots import*\"\nThis code works at python IDLE but not works at Pycharm saying \"No module named 'PIL' \"\nI hope to find answer for it!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":114,"Q_Id":60851676,"Users Score":1,"Answer":"You have to install PIL in Pycharm separately. You can do the following\n1) Write your code in Pycharm\n2) File > Setting > \"Your Opened Project\" > Click on the add sign (+)\n3) Then search for the relevant package in the search bar","Q_Score":0,"Tags":"python-3.x","A_Id":60852329,"CreationDate":"2020-03-25T15:11:00.000","Title":"No module named 'PIL' only in pycharm (works well at IDLE)","Data 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 learning python3 by using cs1robots library.\nSo I typed \"from cs1robots import*\"\nThis code works at python IDLE but not works at Pycharm saying \"No module named 'PIL' \"\nI hope to find answer for it!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":60851676,"Users Score":0,"Answer":"I solved this by changing new environment to existing environment in Pycharm setting.","Q_Score":0,"Tags":"python-3.x","A_Id":60861025,"CreationDate":"2020-03-25T15:11:00.000","Title":"No module named 'PIL' only in pycharm (works well at IDLE)","Data 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 question is simple\nIs there a way of implementing either a callback function, either a javascript function, or a curl postdata to url once the notebook crashes \/ restarts \/ becomes idle ?\nThat would be hyper convenient for my purposes\nThanks a lot for any clue, enlightment, comment, notice ;)\nRegards","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":60852610,"Users Score":0,"Answer":"Very unlikely in Javascript, as that will require to read from the Operating System(OS) and that is not allowed due to security. \nNot sure in other languages.","Q_Score":0,"Tags":"python,jupyter-notebook,google-colaboratory","A_Id":60852947,"CreationDate":"2020-03-25T16:03:00.000","Title":"Call function on notebook crash \/ shutdown \/ reset","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement a data structure that would make it easy to build a questionnaire. What I mean is the following:\nLet's say the first question is \"Which country are you from?\" You answer \"United States\" and thus, the next question is \"Which state are you from?\" \nIf you were to answer, say, \"China\" for the first question, it might ask a different question next. What kind of data structure would I need to implement to do something like this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":266,"Q_Id":60855230,"Users Score":1,"Answer":"I believe an tree with any natural number n nodes from every node, with each node representing a question, would work. Use a function ask to get the answer, and decide which node to go to next. This would be a long process for you to code, but it's good enough. You can create this tree by a list of lists of lists, etc. or a dictionary of dictionaries of dictionaries (in this case I would choose the dictionaries).\nExample:\ntree = {\"United States\": {\"Pizza\": {}, \"Taco\": {}}, \"China\": {\"Books\": {}, \"Movies\", {}}}, and so on until the end.\nEach \"layer\" of dictionaries represents the answers to one question.","Q_Score":1,"Tags":"python,data-structures","A_Id":60855445,"CreationDate":"2020-03-25T18:35:00.000","Title":"Questionnaire Data Structure","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"To perform a binary prediction, I have 5 features which I want to use for my random forest classifier and two are them are not being utilized at all. I understand that this is the whole point of Machine Learning to select the useful features only, but the other three features might have biased data and I want to make sure that all my features are being used at equal weightage to run my classifier. I can't find a straight forward answer to this question. I use sklearn in python for this work. Any comments\/suggestions would be greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":605,"Q_Id":60856374,"Users Score":1,"Answer":"What it can help you is setting the parameter max_feature = 1, so each node will take a (uniform distributed) random feature, and it will be forced to use it. Nevertheless, you need to set the depth of the tree too, because it will be infinitely adding nods till receiving one of the main features.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,classification,random-forest","A_Id":63169771,"CreationDate":"2020-03-25T19:51:00.000","Title":"Force the random forest classifier to use all the input features?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use multiprocessing.Process in Win10 Python to create multiple sub-processes to run a function in parallel, where each sub-process waits for the data from main-process the complete the whole task.\nI know that using multiprocessing.Queue() can realize the communication between main process and sub-process. However, it doesn't specify which sub-process can get the data. It happens that sub-process-7 gets the data, which I intend to send to sub-process-2. Is there a way to specify sending data to a specific sub-process?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":75,"Q_Id":60856854,"Users Score":0,"Answer":"If you want to control which process should get a message use dedicated queues. Create a queue queue2 and pass that to sub-process-2.","Q_Score":0,"Tags":"python","A_Id":60856950,"CreationDate":"2020-03-25T20:24:00.000","Title":"How to send data from main process to a specific sub-process in Python Multiprocess","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"origin2 = pd.to_datetime([1,2,3],unit='D',origin='julian')\norigin2\non the above command getting the following issue :\nOutOfBoundsDatetime                       Traceback (most recent call last)\n in \n----> 1 origin2 = pd.to_datetime([1,2,3],unit='D',origin='julian')\n      2 origin2\n~\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\pandas\\util_decorators.py in wrapper(*args, **kwargs)\n    206                 else:\n    207                     kwargs[new_arg_name] = new_arg_value\n--> 208             return func(*args, **kwargs)\n    209 \n    210         return wrapper\n~\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\pandas\\core\\tools\\datetimes.py in to_datetime(arg, errors, dayfirst, yearfirst, utc, box, format, exact, unit, infer_datetime_format, origin, cache)\n    750 \n    751     if origin != \"unix\":\n--> 752         arg = _adjust_to_origin(arg, origin, unit)\n    753 \n    754     tz = \"utc\" if utc else None\n~\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\pandas\\core\\tools\\datetimes.py in _adjust_to_origin(arg, origin, unit)\n    515             raise tslibs.OutOfBoundsDatetime(\n.......\nOutOfBoundsDatetime: [1, 2, 3] is Out of Bounds for origin='julian'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":60859244,"Users Score":0,"Answer":"The range for Julian calendar is from 2333836 to 2547339 (from Timestamp('1677-09-21 12:00:00') to Timestamp('2262-04-11 12:00:00')), so [1, 2, 3] are OutOfBoundsDatetime, like error said.","Q_Score":0,"Tags":"python,pandas,datetime,python-datetime","A_Id":63436649,"CreationDate":"2020-03-26T00:12:00.000","Title":"Getting OutofBoundSDateTime on pandas to_datetime origin Parameter when origin='julian'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to do a tutorial through FreeCodeCamp using Python's Flask Framework to create a web app in PyCharm and I am stuck on a section where it says 'Flask looks for HTML files in a folder called template. You need to create a template folder and put all your HTML files in there.' I am confused on how to make this template folder; is it just a regular folder or are there steps to create it and drag\/drop the HTML files to it? Any tips or info would be of great help!!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":363,"Q_Id":60861038,"Users Score":0,"Answer":"As the tutorial ask you, you have to create a folder call \"templates\" (not \"template\"). In PyCharm you can do this by right-clicking on the left panel and select New I Directory. In this folder you can then create your template files (right click on the newly created folder and select New I File, then enter the name of your file with the .html extension).\nBy default, flask looks in the \"templates\" folder to find your template when you call render_template(\"index.html\").  Notice that you don\u2019t put the full path of your file at the first parameter but just the relative path to the \"templates\" folder.","Q_Score":0,"Tags":"python,html,flask,pycharm","A_Id":60861283,"CreationDate":"2020-03-26T04:29:00.000","Title":"How do I create a template to store my HTML file when creating a web app with Python's Flask Framework in the PyCharm IDE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know that environments are used for backward-compatibility and to create a box where we can download packages without affecting the rest of the computer.\nI am working on a couple of django projects and I was wondering if I need to create a new conda environment for each new project or can I use the same one? What might go wrong if I use the same environment for similar web-development project?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":147,"Q_Id":60862106,"Users Score":1,"Answer":"You can use same conda environment for 2 or more projects , it is ok for local setup but when you deploy you will have to filter all the unwanted requirements","Q_Score":0,"Tags":"python,django,conda","A_Id":60862295,"CreationDate":"2020-03-26T06:40:00.000","Title":"Can I use the same conda environment for different Django projects?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know that there are somethings like virtualenv and pyenv to manage python versions in a single machine. But what happens if I change the default python version using update-alternatives? AFAIK, it will make system-wise change while virtualenv or pyenv can manage version for each project (or directory). Then when I only works for a single project at once, is it OK to simply use update-alternatives instead? Since somethings like pip are run as python -m pip ... so it seems safe for me to manage pip packages in this way also. What should I consider further when I only works for one project at once?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":578,"Q_Id":60862335,"Users Score":0,"Answer":"OK. Now I understand what I misunderstood. \nBy using \n\nupdate-alternatives, I can change the default python version. \npyenv or virtualenv, I can isolate environments of projects.\n\nLet's assume that I have project A, B for python3.7 and C for python3.8. \nAnd Project A and B require pip package X-1.0 and X-1.3, respectively. \nIn that case I can use pyenv or virtualenv, but update-alternatives cannot handle the situation though it can change python version to 3.7 (and load corresponding packages for it) for project A and B.","Q_Score":0,"Tags":"python,python-3.x,virtualenv,pyenv","A_Id":60862648,"CreationDate":"2020-03-26T07:03:00.000","Title":"What happens if I use update-alternatives to manage python versions instead of virtualenv or pyenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I learned that if one needs to implement dct on a image of size (H, W), one needs a matrix A that is of size (8, 8), and one needs to use this A to compute with a (8, 8) region F on the image. That means if the image array is m, one needs to compute m[:8, :8] first, and then m[8:16, 8:16], and so on. \nHow could I implement this dct when input image size is not a scale of 8. For example, when image size is (12, 12) that cannot hold two (8, 8) windows, how could I implement dct ? I tried opencv and found that opencv can cope with this scenario, but I do not know how it implemented it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":62,"Q_Id":60863664,"Users Score":1,"Answer":"The 8x8 is called a \"Minimum Coded Unit\" (MCU) in the specification, though video enthusiasts call them \"macroblocks\".\nPoorer implementations will pad to fill with zeroes - which can cause nasty effects.\nBetter implementations pad to fill by repeating the previous pixel from the left if padding to the right, or from above if padding downwards.\nNote that only the right side and bottom of an image can be padded.","Q_Score":2,"Tags":"python,opencv,image-processing,dct","A_Id":60864848,"CreationDate":"2020-03-26T08:51:00.000","Title":"How to implement dct when the input image size is not a scale of 8?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i just started playing with python on the last version of visual studio 2019. I added a new project flask web project. by adding `\n\nfrom flask import Flask`\n\nI get unresolved import flask. what else tool, or modules should I import to my solution? any help would be greatly appreciated","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":388,"Q_Id":60864323,"Users Score":0,"Answer":"By adding flask env inside of the solution it has been compiled and run in the localhostf","Q_Score":0,"Tags":"python,flask,visual-studio-2019","A_Id":60886270,"CreationDate":"2020-03-26T09:33:00.000","Title":"unresolved import flask visual studio 2019","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible in Python to re-assign the backslash character to something else, like to the three dots?\nI hate the backslash character. It looks ugly.\nThere\u2019s a long line in my code I really need to use the \\ character. But I\u2019d rather use the ... character.\nI just need a simple yes\/no answer. Is it possible? And in the case of yes, tell me how to re-assign that ugly thing.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":60865206,"Users Score":0,"Answer":"Python syntactically uses the backslash to represent the escape character, as do other languages such as Java and C. As far as I am aware this cannot be overwritten unless you want to change the language itself.","Q_Score":0,"Tags":"python","A_Id":60865260,"CreationDate":"2020-03-26T10:29:00.000","Title":"Re-assign backslash to three dots in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I opened a number of tabs at the same time. I think that's why Google Colab was not able to support the heavy load. The message stated:\n\nSave failed\nThis file could not be saved. Please use the File menu to download the .ipynb and upload the notebook to make a copy that includes your recent changes.\n\nIs downloading the file and uploading again the only solution?","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":10317,"Q_Id":60867546,"Users Score":1,"Answer":"I deleted (heavy) outputs and it worked out, it started saving without fail notifications","Q_Score":3,"Tags":"python,google-colaboratory","A_Id":70929705,"CreationDate":"2020-03-26T12:42:00.000","Title":"Save failed in Google Colab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I opened a number of tabs at the same time. I think that's why Google Colab was not able to support the heavy load. The message stated:\n\nSave failed\nThis file could not be saved. Please use the File menu to download the .ipynb and upload the notebook to make a copy that includes your recent changes.\n\nIs downloading the file and uploading again the only solution?","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":10317,"Q_Id":60867546,"Users Score":1,"Answer":"This can happen if you open the same notebook in multiple tabs and make incompatible edits to the notebook. At this point, the only way to save your work is to follow the advice in the dialog. To prevent this in the future, avoid simultaneously editing the same notebook in multiple browser windows.","Q_Score":3,"Tags":"python,google-colaboratory","A_Id":60867677,"CreationDate":"2020-03-26T12:42:00.000","Title":"Save failed in Google Colab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I opened a number of tabs at the same time. I think that's why Google Colab was not able to support the heavy load. The message stated:\n\nSave failed\nThis file could not be saved. Please use the File menu to download the .ipynb and upload the notebook to make a copy that includes your recent changes.\n\nIs downloading the file and uploading again the only solution?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":10317,"Q_Id":60867546,"Users Score":0,"Answer":"I got the same issue and eventually I found it's because I set up the hardware accelerator.\nThis would be fixed if reseting the 'Runtime\/Change runtime type' to 'None'.","Q_Score":3,"Tags":"python,google-colaboratory","A_Id":65241405,"CreationDate":"2020-03-26T12:42:00.000","Title":"Save failed in Google Colab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I opened a number of tabs at the same time. I think that's why Google Colab was not able to support the heavy load. The message stated:\n\nSave failed\nThis file could not be saved. Please use the File menu to download the .ipynb and upload the notebook to make a copy that includes your recent changes.\n\nIs downloading the file and uploading again the only solution?","AnswerCount":5,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":10317,"Q_Id":60867546,"Users Score":16,"Answer":"It turned out to be a network issue. Output is heavy and colab is not able to save it is not able to make a handshake because internet speed is poor. So just switch the internet source and see it working.","Q_Score":3,"Tags":"python,google-colaboratory","A_Id":60880046,"CreationDate":"2020-03-26T12:42:00.000","Title":"Save failed in Google Colab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using PDB to debug python code, I wonder is there a way to save all the info appeared on the terminal during the whole debugging process to a file? copy-paste is not realistic here.\nHelp me edit the tags or move this question to a more appropriate place if this question is not proper on stackoverflow. \nI guess I need to write a script to track the info on the terminal form the beginning to the end of the debugging process. \nAny suggestion is appreciated.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1259,"Q_Id":60869069,"Users Score":3,"Answer":"The script command is the most convenient way of doing this in unix based OSes, it lets you save everything that appeared in your terminal to a file. You stop recording with exit or C-d so it can go as long as you want.","Q_Score":3,"Tags":"python,pdb","A_Id":60911737,"CreationDate":"2020-03-26T14:03:00.000","Title":"How to save the debugging info to a file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am able to run a text file that has queries delimited by ';' in the impala-shell. However, I have some queries that require the results of another query. For example, if Query1 gives me name | age | birthday and then the following query is something like SELECT * FROM table1 WHERE age in (...), and those ages are from the age column from the first query. \nI know you can specify with --vars option, but that seems to be for inserting specific values. Is there a way to create Python script to handle something like this that would run in the impala-shell?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":737,"Q_Id":60869209,"Users Score":0,"Answer":"I think creating temp tables will help here. \nImpala Only solution -\nstep 0 - load the table from file.\nstep 1 - create temp table tmp_table as Query 1.\nstep 2 SELECT * FROM table1 WHERE age in (tmp_table).\nstep 3 - Drop table tmp_table.\nYou can use subquery as well in case all are in impala tables.\nSELECT * FROM table1 WHERE age in (select age from Query1)  \nYes, you can always use python to run impala-shell queries. But they will be like call scripts one after another and for your requirement you can do them entirely in impala.","Q_Score":1,"Tags":"python,sql,variables,impala","A_Id":61185489,"CreationDate":"2020-03-26T14:11:00.000","Title":"Run Python script in impala-shell","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have fetched data from a CSV file, and it is held and manipulated in my Dask dataframe. From there I need to write the data into a data table. I have not really come across any solutions for this. Pandas have built-in functionality for this with its to_sql function, so I am unsure whether I need to convert to Pandas first? I currently think that converting the Dask dataframe to Pandas will cause it to be loaded fully into memory, which may defeat the purpose of using Dask in the first place. \nWhat would the best and fastest approach be to write a Dask dataframe to a datatable?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1297,"Q_Id":60871938,"Users Score":0,"Answer":"I have no problem with @kfk's answer, as I also investigated that, but my solution was as follows.\nI drop the DASK dataframe to a csv, and from there pick the CSV up with a Golang application that shoves the data into Mongo using multi-threading. For 4.5 million rows, the speed went from 38 minutes using \"load local infile\" to 2 minutes using a multi-threaded app.","Q_Score":1,"Tags":"python,dask,dask-dataframe","A_Id":61123236,"CreationDate":"2020-03-26T16:37:00.000","Title":"How do I get a DASK dataframe into a MySQL datatable?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The question is about generic views, and their use in practice. They are presented  as a better, cleaner, alternative for writing custom views, however they didn't seem to simply the view code much, and seemed very case specific. So in practice, are these generic views used extensively, with custom ones written only for very specific cases? Or is it the opposite, and generic views only exist for minimalists\/case specific needs?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":60872054,"Users Score":0,"Answer":"The most common operations for any backend application, are create, read, update and delete - more commonly known as CRUD operations. These will cover almost all use-cases for your API. Generic views provide methods for these operations and much more, meaning that you don't have to repeat the same code over and over again throughout your application. These classes and methods provided by the DRF are also extensible, allowing you to alter them to your needs, when required.","Q_Score":0,"Tags":"python,django,view,django-views","A_Id":60875624,"CreationDate":"2020-03-26T16:43:00.000","Title":"Custom vs Generic Views in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've seen how to make a post request from JavaScript to get data from the server, but how would I do this flipped. I want to trigger a function in the flask server that will then dynamically update the variable on the JavaScript side to display. Is there a way of doing this in a efficient manner that does not involve a periodic iteration. I'm using an api and I only want to the api to be called once to update.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":60872081,"Users Score":1,"Answer":"There are three basic options for you:\n\nPolling - With this method, you would periodically send a request to the server (maybe every 5 seconds for example) and ask for an update. The upside is that it is easy to implement. The downside is that many requests will be unnecessary. It sounds like this isn't a great option for you. \nLong Polling - This method means you would open a request up with the server and leave the request open for a long period of time. When the server gets new information it will send a response and close the request - after which the client will immediately open up a new \"long poll\" request. This eliminates some of the unnecessary requests with regular polling, but it is a bit of a hack as HTTP was meant for a reasonably short request response cycle. Some PaaS providers only allow a 30 second window for this to occur for example. \nWeb Sockets - This is somewhat harder to setup, but ultimately is the best solution for real time server to client (and vice versa) communication. A socket connection is opened between the server and client and data is passed back and forth whenever either party would like to do so. Javascript has full web socket support now and Flask has some extensions that can help you get this working. There are even great third party managed solutions like Pusher.com that can give you a working concept very quickly.","Q_Score":0,"Tags":"javascript,python,flask","A_Id":60872227,"CreationDate":"2020-03-26T16:45:00.000","Title":"How do I receive a variable from python flask to JavaScript?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying for the first time to use mongo, and I choose mongoengine.\nAfter defining the Document structure if I try to change it (adding a field, removing a field, renaming ecc..) the reading operations still works, but any other operation on previously stored document fail since they're note compliant anymore with the document structure.\nIs there any way to manage this situation? should I only user Dynamic documents with Dictionaries instead of EmbeddedDocuments?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":148,"Q_Id":60873361,"Users Score":1,"Answer":"Using DynamicDocument or setting meta = {'strict': False} on your Document may help in some cases but the only proper solution to this is running a migration script.\nI'd recommend doing this using pymongo but you could also do that from the mongo shell. Every time your model change in a way that is not compatible, you should run a migration on the existing data so that it fits the new model. Otherwise mongoengine will complain at some point (mongoengine contributor here)","Q_Score":0,"Tags":"python,mongodb,mongoengine,flask-mongoengine","A_Id":60968246,"CreationDate":"2020-03-26T17:56:00.000","Title":"Mongoengine change document structure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need your opinion on a challenge that I'm facing. I'm building a website that uses Django as a backend, PostgreSQL as my DB, GraphQL as my API layer and React as my frontend framework. Website is hosted on Heroku. I wrote a python script that logs me in to my gmail account and parse few emails, based on pre-defined conditions, and store the parsed data into Google Sheet. Now, I want the script to be part of my website in which user will specify what exactly need to be parsed (i.e. filters) and then display the parsed data in a table to review accuracy of the parsing task.\nThe part that I need some help with is how to architect such workflow. Below are few ideas that I managed to come up with after some googling:\n\ngenerate a graphQL mutation that stores a 'task' into a task model. Once a new task entry is stored, a Django Signal will trigger the script. Not sure yet if Signal can run custom python functions, but from what i read so far, it seems doable.\nUse Celery to run this task asynchronously. But i'm not sure if asynchronous tasks is what i'm after here as I need this task to run immediately after the user trigger the feature from the frontend. But i'm might be wrong here. I'm also not sure if I need Redis to store the task details or I can do that on PostgreSQL.\n\nWhat is the best practice in implementing this feature? The task can be anything, not necessarily parsing emails; it can also be importing data from excel. Any task that is user generated rather than scheduled or repeated task.\nI'm sorry in advance if this question seems trivial to some of you. I'm not a professional developer and the above project is a way for me to sharpen my technical skills and learn new techniques. \nLooking forward to learn from your experiences.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":156,"Q_Id":60874753,"Users Score":1,"Answer":"You can dissect your problem into the following steps:\n\nUser specifies task parameters\nSystem executes task\nSystem displays result to the User\n\nYou can either do all of these:\n\nSequentially and synchronously in one swoop; or\nStep by step asynchronously.\n\nSynchronously\nYou can run your script when generating a response, but it will come with the following downsides:\n\nThe process in the server processing your request will block until the script is finished. This may or may not affect the processing of other requests by that same server (this will depend on the number of simultaneous requests being processed, workload of the script, etc.)\nThe client (e.g. your browser) and even the server might time out if the script takes too long. You can fix this to some extent by configuring your server appropriately.\n\nThe beauty of this approach however is it's simplicity. For you to do this, you can just pass the parameters through the request, server parses and does the script, then returns you the result.\nNo setting up of a message queue, task scheduler, or whatever needed.\nAsynchronously\nIdeally though, for long-running tasks, it is best to have this executed outside of the usual request-response loop for the following advantages:\n\nThe server responding to the requests can actually serve other requests.\nSome scripts can take a while, some you don't even know if it's going to finish\nScript is no longer dependent on the reliability of the network (imagine running an expensive task, then your internet connection skips or is just plain intermittent; you won't be able to do anything)\n\nThe downside of this is now you have to set more things up, which increases the project's complexity and points of failure.\nProducer-Consumer\nWhatever you choose, it's usually best to follow the producer-consumer pattern:\n\nProducer creates tasks and puts them in a queue\nConsumer takes a task from the queue and executes it\n\nThe producer is basically you, the user. You specify the task and the parameters involved in that task.\nThis queue could be any datastore: in-memory datastore like Redis; a messaging queue like RabbitMQ; or an relational database management system like PostgreSQL.\nThe consumer is your script executing these tasks. There are multiple ways of running the consumer\/script: via Celery like you mentioned which runs multiple workers to execute the tasks passed through the queue; via a simple time-based job scheduler like crontab; or even you manually triggering the script\nThe question is actually not trivial, as the solution depends on what task you are actually trying to do. It is best to evaluate the constraints, parameters, and actual tasks to decide which approach you will choose.\nBut just to give you a more relevant guideline:\nJust keep it simple, unless you have a compelling reason to do so (e.g. server is being  bogged down, or internet connection is not reliable in practice), there's really no reason to be fancy.\nThe more blocking the task is, or the longer the task takes or the more dependent it is to third party APIs via the network, the more it makes sense to push this to a background process add reliability and resiliency.\nIn your email import script, I'll most likely push that to the background:\n\nHave a page where you can add a task to the database\nIn the task details page, display the task details, and the result below if it exists or \"Processing...\"  otherwise\nHave a script that executes tasks (import emails from gmail given the task parameters) and save the results to the database\nSchedule this script to run every few minutes via crontab\n\nYes the above has side effects, like crontab running the script in multiple times at the same time and such, but I won't go into detail without knowing more about the specifics of the task.","Q_Score":0,"Tags":"python,django,graphql,django-celery","A_Id":60877018,"CreationDate":"2020-03-26T19:28:00.000","Title":"Best Way to Handle user triggered task (like import data) in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python script that generates a heightmap depending on parameters, that will be given in HTML forms. How do I display the resulting image on a website? I suppose that the form submit button will hit an endpoint with the given parameters and the script that computes the heightmap runs then, but how do I get the resulting image and display it in the website? Also, the computation takes a few seconds, so I suppose I need some type of task queue to not make the server hang in the meanwhile. Tell me if I'm wrong.\nIt's a bit of a general question because I myself don't know the specifics of what I need to use to accomplish this. I'm using Flask in the backend but it's a framework-agnostic question.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":60875763,"Users Score":1,"Answer":"Save the image to a file. Return a webpage that contains an <IMG SRC=...> element. The SRC should be a URL pointing at the file.\nFor example, suppose you save the image to a file called \"temp2.png\" in a subdirectory called \"scratch\" under your document root. Then the IMG element would be <IMG SRC=\"\/scratch\/temp2.png\"> .\nIf you create and save the image in the same program that generates the webpage that refers to it, your server won't return the page until the image has been saved. If that only takes a few seconds, the server is unlikely to hang. Many applications would take that long to calculate a result, so the people who coded the server would make sure it can handle such delays. I've done this under Apache, Tomcat, and GoServe (an OS\/2 server), and never had a problem.\nThis method does have the disadvantage that you'll need to arrange for each temporary file to be deleted after an expiry period such as 12 hours or whenever you think the user won't need it any more. On the webpage you return, if the image is something serious that the user might want to keep, you could warn them that this will happen. They can always download it.\nTo delete the old files, write a script that checks when they were last updated, compares that with the current date and time, and deletes those files that are older than your expiry period. \nYou'll need a way to automatically run it repeatedly. On Unix systems, if you have shell access, the \"cron\" command is one way to do this. Googling \"cron job to delete files older than 1 hour on web server\" finds a lot of discussion of methods.\nBe very careful when coding any automatic-deletion script, and test it thoroughly to make sure it deletes the right files! If you make your expiry period a variable, you can set it to e.g. 1 minute or 5 minutes when testing, so that you don't need to wait for ages.\nThere are ways to stream your image back without saving it to a file, but what I'm recommending is (apart possibly from the file deleter) easy to code and debug. I've used it in many different projects.","Q_Score":0,"Tags":"javascript,python,html,web","A_Id":60879854,"CreationDate":"2020-03-26T20:40:00.000","Title":"Display result (image) of computation in website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to create a website where I show some text but mainly dynamic data in tables and plots. Let us assume that the user can choose whether he wants to see the DAX or the DOW JONES prices for a specific timeframe. I guess these data I have to store in a database. As I am not experienced with creating websites, I have no idea what the most reasonable setup for this website would be. \n\nWould it be reasonable for this example to choose a database where every row corresponds of 9 fields, where the first column is the timestamp (lets say data for every minute), the next four columns correspond  to the high, low, open, close price of DAX for this timestamp and columns 5 to 9 correspond to high, low, open, close price for DOW JONES?\nCould this be scaled to hundreds of columns with a reasonable speed\nof the database?\nIs this an efficient implementation?\nWhen this website is online, you can choose whether you want to see DAX or DOW JONES prices for a specific timeframe. The corresponding data would be chosen via python from the database and plotted in the graph. Is this the general idea how this will be implemented?\nTo get the data, I can run another python script on the webserver to dynamically collect the desired data and write them in the database?\n\nAs a total beginner with webhosting (is this even the right term?) it is very hard for me to ask precise questions. I would be happy if I could find out whats the general structure I need to create the website, the database and the connection between both. I was thinking about amazon web services.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":60876970,"Users Score":0,"Answer":"You could use a database, but that doesn't seem necessary for what you described.\nIt would be reasonable to build the database as you described.  Look into SQL for doing so.  You can download a package XAMPP that will give you pretty much everything you need for that.  This is easily scalable to hundreds of thousands of entries - that's what databases are for.\nIf your example of stock prices is actually what you are trying to show, however, this is completely unnecessary as there are already plenty of databases that have this data and will allow you to query them.  What you would really want in this scenario is an API.  Alpha Vantage is a free service that will serve you data on stock prices, and has plenty of documentation to help you get it set up with python.\nI would structure the project like this:\nUse the python library Flask to set up the back end.\nIn addition to instantiating the Flask app, instantiate the Alpha Vantage class as well (you will need to pip install both of these).\nIn one of the routes you declare under Flask, use the Alpha Vantage api to get the data you need and simply display it to the screen.\nIf I am assuming you are a complete beginner, one or more of those steps may not make sense to you, in which case take them one at a time.  Start by learning how to build a basic Flask app, then look at the API.\nYouTube is your friend for both of these things.","Q_Score":1,"Tags":"python,database,amazon-web-services,web-hosting","A_Id":60877086,"CreationDate":"2020-03-26T22:11:00.000","Title":"How to create a dynamic website using python connected to a database","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've been working on PyTorch and wanted to use Cuda tensors but I've been having trouble getting it to work.\nWhen I use the line torch.cuda.is_available(), it returns false.\nBut when I use the same line on the anaconda command prompt, it returns true. What gives? Do I need to set the device somehow? Or maybe have the interpreter include my GPU? All I want is my GPU to be recognized as CUDA usable and can use in code.\nI use:\npython 3.7\nCUDA 10.1\nGPU: GTX 1070","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":60877680,"Users Score":0,"Answer":"I found the issue, My interpreter was wrong and I changed it to match my anaconda prompt interpreter. Works like a charm","Q_Score":0,"Tags":"python-3.x,pytorch","A_Id":60877942,"CreationDate":"2020-03-26T23:20:00.000","Title":"Trying to use Cuda in pyTorch","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The following I had with Python 3.8.1 (on macOS Mojave, 10.14.6, as\nwell as Python 3.7 (or some older) on some other platforms).  I'm new\nto computing and don't know how to request an improvement of a\nlanguage, but I think I've found a strange behaviour of the built-in\nfunction map.\nAs the code next(iter(())) raises StopIteration, I expected to\nget StopIteration from the following code:\ntuple(map(next, [iter(())]))\nTo my surprise, this silently returned the tuple ()!\nSo it appears the unpacking of the map object stopped when\nStopIteration came from next hitting the \"empty\" iterator\nreturned by iter(()).  However, I don't think the exception was\nhandled right, as StopIteration was not raised before the \"empty\"\niterator was picked from the list (to be hit by next).\n\nDid I understand the behaviour correctly?\nIs this behaviour somehow intended?\nWill this be changed in a near future?  Or how can I get it?\n\nEdit: The behaviour is similar if I unpack the map object in different ways, such as by list, for for-loop, unpacking within a list, unpacking for function arguments, by set, dict.  So I believe it's not tuple but map that's wrong.\nEdit: Actually, in Python 2 (2.7.10), the \"same\" code raises\nStopIteration.  I think this is the desirable result (except that map in this case does not return an iterator).","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":318,"Q_Id":60878604,"Users Score":1,"Answer":"Did I understand the behavior correctly?\n\n\nNot quite. map takes its first argument, a function, and applies it to every item in some iterable, its second argument, until it catches the StopIteration exception. This is an internal exception raised to tell the function that it has reached the end of the object. If you're manually raising StopIteration, it sees that and stops before it has the chance to process any of the (nonexistent) objects inside the list.","Q_Score":4,"Tags":"python,python-3.x,behavior,built-in,map-function","A_Id":60878677,"CreationDate":"2020-03-27T01:17:00.000","Title":"Python3: Does the built-in function \"map\" have a bug?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an autoencoder model using keras, input and output shape is (BATCH_SIZE, 20). In the middle there is a Lambda layer that filters the data. In other words, if the batch size is 1000, there might be only 700 that comes out from the Lambda layer. Then I want to update the weights based on just these 700 samples. Is there any way to tackle this in Keras?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":60878915,"Users Score":0,"Answer":"I recently dealt with such a situation and the way I handled was by keeping the batch dimension flexible. For example: if you are using TensorFlow define the placeholder as [None, w, h, 3] (in case of image) and develop your model. The weights have nothing to do with the batch dimensions. So,  when you decrease the size of the computations on axis = 0, the rest of the change will happen accordingly. Basically don't define any concrete batch size, keep it flexible.","Q_Score":0,"Tags":"python,tensorflow,keras,lambda,model","A_Id":60879155,"CreationDate":"2020-03-27T01:58:00.000","Title":"Update weights of keras model only based on samples that meet a condition while training","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had a different question here, but realized it simplifies to this:\nHow do you detect when a client disconnects (closes their page or clicks a link) from a page (in other words, the socket connection closes)? I want to make a chat app with an updating user list, and I\u2019m using Flask on Python. When the user connects, the browser sends a socket.emit() with an event and username passed in order to tell the server a new user exists, after which the server will message all clients with socket.emit(), so that all clients will append this new user to their user list. However, I want the clients to also send a message containing their username to the server on Disconnect. I couldn\u2019t figure out how to get the triggers right. Note: I\u2019m just using a simple html file with script tags for the page, I\u2019m not sure how to add a JS file to go along with the page, though I can figure it out if it\u2019s necessary for this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2837,"Q_Id":60879701,"Users Score":6,"Answer":"Figured it out. socket.on('disconnect') did turn out to be right, however by default it pings each user only once a minute or so, meaning it took a long time to see the event.","Q_Score":6,"Tags":"python,python-3.x,sockets,flask,socket.io","A_Id":61133214,"CreationDate":"2020-03-27T03:41:00.000","Title":"SocketIO + Flask Detect Disconnect","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I recently convert my model to tensorflow lite but I only got the .tflite file and not a labels.txt for my Android project. So is it possible to create my own labels.txt using the classes that I used to classify? If not, then how to generate labels.txt?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4062,"Q_Id":60880310,"Users Score":2,"Answer":"You should be able to generate and use your own labels.txt. The file needs to include the label names in the order you provided them in training, with one name per line.","Q_Score":1,"Tags":"python,tensorflow,model,tensorflow2.0,tensorflow-lite","A_Id":60896637,"CreationDate":"2020-03-27T05:09:00.000","Title":"Is it possible to create labels.txt manually?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to insert a formula into Excel using Python.  I am creating a dataframe and adding a column containing the formulas and then writing it into an Excel.\nThe formula has the format '=HYPERLINK(\"#'\"&F2&\"'!A1\",F2)'\nF2 is a variable and all other characters are constant.  I need to dynamically generate this string. \nI tried doing =HYPERLINK(\"#'\"&F2&\"'!A1\",F2) but it is not working and I got '=HYPERLINK(\"#\\'\"&F2&\"\\'!A1\",F2)' which includes the back slash and the formula does not work.\nHow do I create a string like '=HYPERLINK(\"#'\"&F2&\"'!A1\",F2)' ?\nAny help would be highly appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":60881008,"Users Score":0,"Answer":"Since you are making string dynamically. There are two things you can do.\n\nr'=HYPERLINK(\"#'\"&F2&\"'!A1\",F2)' r signifies raw string (if you are not using any variable).\nIf you are making string dynamically using other variables. Use formatted string.\nvar1= '\"#'\"&F2&\"'!A1\"'\nvar2= 'F2'\nformula= f'=HYPERLINK({var1},{var2} )'\n\n\nprint(formula)\n'=HYPERLINK(\"#&F2&!A1\",F2 )'","Q_Score":0,"Tags":"python,excel,string,dataframe,formula","A_Id":60881203,"CreationDate":"2020-03-27T06:32:00.000","Title":"Create a string with single and double quotes","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Because of the size of the installed pip packages , I moved the ~\/.local\/lib\/python3.6 directory to another partition and then made a symlink(a.k.a shortcut for windows users) to it , and that had been worked fine.\nBut recently I installed a newer linux distribution which has python3.8 pre-installed and I want to re-use those python3.6 packages(since the minor version is the same) to obviate the need of re-installing them.(almost 3.5 GB)\nI made a symlink (~\/.local\/lib\/python3.8\/ which is the exact name that pip creates itself) to \/path\/to\/external\/lib\/python3.6 , but now python shell is unable to recognize those packages.\nAny ideas?\nDo I need to re-install them?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":30,"Q_Id":60882650,"Users Score":1,"Answer":"These projects have to be reinstalled. There is no compatibility guarantee between minor versions (or major obviously), only between maintenance versions.","Q_Score":1,"Tags":"python-3.x,pip","A_Id":60882859,"CreationDate":"2020-03-27T08:50:00.000","Title":"Using installed pip packages in a newer release of Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"zenPython = ''' \nThe Zen of Python, by Tim Peters \nBeautiful is better than ugly. \nExplicit is better than implicit. \nSimple is better than complex. \nComplex is better than complicated. \nFlat is better than nested.\nSparse is better than dense. \nReadability counts. \nSpecial cases aren't special enough to break the rules. \nAlthough practicality beats purity. \nErrors should never pass silently. \nUnless explicitly silenced. \nIn the face of ambiguity, refuse the temptation to guess. \nThere should be one-- and preferably only one --obvious way to do it. \nAlthough that way may not be obvious at first unless you're Dutch. \nNow is better than never. \nAlthough never is often better than right now. \nIf the implementation is hard to explain, it's a bad idea. \nIf the implementation is easy to explain, it may be a good idea.\n'''\nHow to remove unnecessary character like --,*,! in this zenpython string using list comprehension and split??\nI have made solution using replace, and normal looping in python but I need an optimal solution for this.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":550,"Q_Id":60883558,"Users Score":0,"Answer":"Use the maketrans() function where ur first parameter is list of \"--, *,!\" and second list constisting of empty strings - \" \"","Q_Score":1,"Tags":"python,string,list,character,solution","A_Id":60883636,"CreationDate":"2020-03-27T09:51:00.000","Title":"Remove unnecessary character from string in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My worker is run with:\ncelery worker -A workerTasks -n Worker%h --concurrency=1 --loglevel=info -Q $QUEUE_NAME -f $WORKER_LOG_FILE --pidfile=\/logs\/worker_pid%h.pid\nI'm wondering if I can make a python\/celery call within the process to find which queue(s) this worker is \"subscribed\" to?\n(I do NOT want to find the value of $QUEUE_NAME directly)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":60888115,"Users Score":0,"Answer":"celery -A workerTasks inspect active_queues -d <worker name>, where worker name is the name of that particular node. If you omit -w <worker name> each node will send you report about which queue it is subscribed to.","Q_Score":1,"Tags":"python,django,celery","A_Id":60890077,"CreationDate":"2020-03-27T14:33:00.000","Title":"How to get list of subscribed queue names in Celery\/Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am using Python 3.7 (Activestate) on a windows 10 laptop. All works well until I try to use pip to install a package (any package). From command prompt, when entering \"pip install anyPackage\" I get an error - \"The system cannot find the path specified.\" no other explanation or detail. \nPython is installed in \"C:\\Python37\" and this location is listed in the Control Panel > System > Environment Variables > User Variables. \nIn the Environment Variables > System Variables I have:\nC:\\Python37\\\nC:\\Python37\\DLLs\\\nC:\\Python37\\Script\\\nC:\\Python37\\Tools\\\nC:\\Python37\\Tools\\ninja\\\nAny suggestions on how to get rid of that error, and make pip work?\nMany thanks to all","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":4214,"Q_Id":60890894,"Users Score":3,"Answer":"Short : make sure that pip.exe and python.exe are running from the same location. If they don't (perhaps due to PATH environment variable), just delete the one that you don't need.\nLonger:\nwhen running pip install, check out where it tries to get python\nFor instance, in my own computer, it was:\n\npip install\nFatal error in launcher: Unable to create process using '\"c:\\program files\\python39\\python.exe\"  \"C:\\Program Files\\Python39\\Scripts\\pip.exe\" ': The system cannot find the file specified.\n\nThen I ran:\n'where python.exe' \/\/ got several paths.\n'where pip.exe' \/\/ got different paths.\nremoved the one that I don't use. Voila.","Q_Score":2,"Tags":"python,windows,pip","A_Id":66355174,"CreationDate":"2020-03-27T17:12:00.000","Title":"Python 3.7 pip install - The system cannot find the path specified","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to understand how the learning algorithms used by TensorFlow work.\nI have read papers on these methods in the past (a few years ago now, so apologies for my poor terminology) and they seem to claim to be able to differentiate the loss function with respect to each value within the AI's weights and biases. This would tell the learning algorithm which direction to move the AI's parameters in to reduce the loss. \nTo differentiate the AI's parameters with respect to the loss function, the learning algorithm would first need to generate an equation describing this relationship. My question is: how is this equation generated?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":60895421,"Users Score":0,"Answer":"When training a dense network with a single hidden layer (with $m$ hidden nodes) to do binary classification, we minimize the cost function \n$$L(W_1,W_2) = \\sum_{i=1}^N \\ell(y_i, \\sigma(W_2 a(W_1 \\hat x_i)),$$ \nwhere $x_i \\in \\mathbb R^d$ is the $i$th feature vector in the training dataset, $\\hat x_i \\in \\mathbb R^{d+1}$ is the augmented feature vector obtained by prepending a $1$ to $x_i$, $W_1$ is an $m \\times (d+1)$ matrix containing the weights and biases for the hidden layer, $a$ is a function that applies the ReLU activation function to each of its inputs (and also has an additional output which is equal to $1$), and $W_2$ is a $1 \\times m$ matrix containing the weights and bias of the output layer. Here $\\sigma$ is the logistic function and $\\ell$ is the binary cross-entropy loss function.\nEdit: Does mathjax not work on this website?","Q_Score":0,"Tags":"python,tensorflow,machine-learning,artificial-intelligence","A_Id":60896964,"CreationDate":"2020-03-27T23:20:00.000","Title":"How do TensorFlow learning algorithms work?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've installed selenium in vscode but when I try to run the program I get an error saying module isn't found. Also, when using from selenium import webdriver, I get messages saying that it is unable to import. I have installed selenium using pip. Is anyone able to help me understand what I'm doing wrong?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1700,"Q_Id":60895455,"Users Score":0,"Answer":"This happened to me, searching for a fix I found that there is a bug that gives you the \"Module Isn't Found\" message.  After checking your path and you have the proper interpreter selected close VS Code and re-open it.  This fixed it for me.","Q_Score":1,"Tags":"python,selenium,visual-studio-code","A_Id":64273734,"CreationDate":"2020-03-27T23:25:00.000","Title":"Selenium installed in visual studio code but module isn't found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to do a topic labeling problem on a large dataset of research papers. The idea is that I can give each paper a few relevant labels.\nI have 2 questions.\nI know you can do topic modeling in a variety of ways like using LDA and NMF, but what can you do to later extract possible labels from those topics?\nAlso, assuming I have extracted a bunch of labels, how can I mathematically estimate their accuracy? Is there some kind of metric available that can determine say, the variance of the information explained by a label in a document, or something along those lines? How would I evaluate my labels without a large group of humans doing qualitative analysis?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":423,"Q_Id":60895874,"Users Score":1,"Answer":"The most simple way is to use the top k words as the labels. More complicated methods include candidate label generation and candidate label ranking. Many related papers talking about this topic: \n\nAletras, Nikolaos, and Mark Stevenson. \"Labelling topics using unsupervised graph-based methods.\" ACL. 2014\nBhatia, Shraey, Jey Han Lau, and Timothy Baldwin. \"Automatic labelling of topics with neural embeddings.\"\u00a0COLING\u00a0(2016).\nHingmire, Swapnil, et al. \"Document classification by topic labeling.\"\u00a0SIGIR. 2013\n\nAll the above papers have sections discussing how to evaluate the labels.","Q_Score":2,"Tags":"python,nlp,topic-modeling","A_Id":61099208,"CreationDate":"2020-03-28T00:25:00.000","Title":"Automatic Topic Labeling Evaluation metric","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"First of all, im really new at Machine Learning and Anaconda\nRecently I\u00b4ve Installed Anaconda for MachineLearning but now when i try to run my old scripts from my terminal, all my packages are not there, even pip or numpy or pygame y don\u00b4t know how to change to my old python directory, I really don\u00b4t know how this works, please help me. I\u00b4m on MacOs Catalina","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":69,"Q_Id":60897172,"Users Score":3,"Answer":"First of all, Python 3 is integrated in macOS X Catalina, just type python3. For pip, you can use pip3. Personally, I would prefer native over conda when using mac.\nNext, you need to get all the modules up from your previous machine by pip freeze > requirements.txt or pip3 freeze > requirements.txt\nIf you have the list already, either it's from your previous machine or from a GitHub project repo, just install it via pip3 in your terminal: pip3 install -r requirements.txt\nIf not, you have to manually install via pip3, for example: pip3 install pygame etc.\nAfter all dependencies are done installed, just run your .py file as usual.\nLast, but not least, welcome to the macOS X family!","Q_Score":0,"Tags":"python,macos,terminal,anaconda","A_Id":60902188,"CreationDate":"2020-03-28T04:17:00.000","Title":"Change which python im using in terminal MacOs Catalina","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am a beginner in python 3. I want to locate where the time module is in PyCharm to study it's aspects\/functions further. I can't seem to find it in the library. Can someone show me an example on how to find it ?\nI know there are commands to find files, but I am not advanced enough to use them.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":60897467,"Users Score":0,"Answer":"I think you may have a misconception - the time module is part of your Python installation, which PyCharm makes use of when you run files. Depending on your setup, you may be able to view the Python files under \"external libraries\" in your project viewer, but you could also view them from your file system, wherever Python is installed.","Q_Score":1,"Tags":"python,module,navigation,pycharm","A_Id":60902628,"CreationDate":"2020-03-28T05:07:00.000","Title":"How to locate module inside PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a chat application using flask socketio and I want to send to a specific singular client and I'm wondering how to go about this. \nI get that emit has broadcast and include_self arguments to send to all and avoid sending oneself, but how exactly would I go about maybe emitting to a single sid?\nI've built this application using standard TCP\/UDP socket connection where upon client connecting, there socket info was stored in a dictionary mapped to their user object with attributes that determined what would be sent and when I wanted to emit something to the clients I would iterate through this and be able to control what was being sent.  \nI'm hoping some mastermind could help me figure out how to do this in flask socket io","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":45,"Q_Id":60897681,"Users Score":1,"Answer":"I ended up figuring it out.  Using the flask request module, you can obtain the users sid using request.sid, which can be stored and emitted to within the room parameter emit(..... room=usersid","Q_Score":0,"Tags":"python,flask,socket.io","A_Id":60908544,"CreationDate":"2020-03-28T05:40:00.000","Title":"How to emit different messages to different users based on certain criteria","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"this is my very first stackoverflow question. \nI'm not a native speaker, but I study mainly in english, and I've tried to search this around the internet with different approaches to my text but I couldn't find anything.\nAnd i'm having trouble to find some directions to write a simple code that follows something like this:\nexample:\n\nWe have a set of values, for example, characters from a game, or flags from a country, etc.\n\nSuposing we have three flags: Japan, Usa and Israel.\n\nWe inform to the user these values, so then he knows what are the possible picks, and choose one.\nThen, the algorithm make questions like: \"Is the blue color present in this flag? yes or no?\" \n(if the answer is yes, than the algorithm eliminates Japan, for example)\nThen the algorithm make some more pertinent questions until just one flag is left.\n\"You chose the flag of United States.\"\n\nI know stackoverflow maybe it's not intended for such simple and beginner questions, but if I could have any clue on how to develop this simple algorithm maybe it would help me on how to apply if statements and things like that into my codes and my current ideas. I'm learning Python and Math by myself currently, and every small step is very enlightening. \n\nIf someone could fill me in with some Python structure for this or, or pseudocode, or even what phrase should I google,  it would mean a lot to me.\n\nSorry for my bad english!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":60898160,"Users Score":0,"Answer":"I think you have to prepare a list of questions first, then with each question, you will have a list of remaining answers. After asking a bunch of questions, you will get the final answer as you wish.\nFor example, I will have a dictionary storing questions for the flag examples above:\nlist_options = [{'q': 'does the blue present in the flag?', 'y':['israel'], 'n': ['japan', 'usa']}, {'q': 'is the circle in the flag?', 'y': ['japan'], 'n': ['usa']}]\nSo at each step, you throw a question to the user and eliminate some answers until you get the last one.\nHope this could help","Q_Score":0,"Tags":"python,algorithm,logic","A_Id":60898270,"CreationDate":"2020-03-28T06:53:00.000","Title":"How can I write this simple algorithm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Looking for some tips here. I did a quiet a bit of coding and research using python3 and lambda. However, timeout is the biggest issue I am struggling with atm. I am trying to read a very large csv file (3GB) from S3 and push the rows into DynamoDB. I am currently reading about 1024 * 32 bytes at a time, then pushing the rows into dynamo DB (batch write with asyncio) using a pub\/sub pattern, and it works great for small files, i.e. ~500K rows. It times out when I have millions of rows. I\u2019m trying NOT to use AWS glue and\/or EMR. I have some constraints\/limitations with those.\nDoes anyone know if this can be done using Lambda or step functions? If so, could you please share your ideas? Thanks!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":334,"Q_Id":60898702,"Users Score":2,"Answer":"Besides lambda time constraint you might run into lambda memory constraint while you are reading file in AWS Lambda as lambda has just \/tmp directory storage of 512 MB and that again depends on how you are reading the file in lambda.\nIf you don't want to go via AWS Glue or EMR, another thing you can do is by provisioning an EC2 and run your same code you are running in lambda from there. To make it cost effective, you can make EC2 transient i.e. provision it when you need to run S3 to DynamoDB job and shut it down once the job is completed. This transient nature can be achieved by Lambda function. You can also orchestrate the same with Step Functions also. Another option that you can look into is via AWS Datapipeline.","Q_Score":0,"Tags":"python-3.x,aws-lambda,aws-step-functions","A_Id":61392536,"CreationDate":"2020-03-28T08:02:00.000","Title":"How to ETL very large csv from AWS S3 to Dynamo","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"let us say I have a python 3.7+ module\/script A which does extensive computations. Furthermore, module A is being used inside another module B, where module A is fully encapsulated and module B doesn't know a lot of module's A internal implementation, just that it somehow outputs the progress of its computation.\nConsider me as the responsible person (person A) for module A, and anyone else (person B) that doesn't know me, is writing module B. So person A is writing basically an open library.\nWhat would be the best way of module A to output its progress? I guess it's a design decision.\n\nWould a getter in module A make sense so that module B has to always call this getter (maybe in a loop) in order to retrieve the progress of A?\nWould it possible to somehow use a callback function which is implemented in module A in such a way that this function is called every time the progress updates? So that this callback returns the current progress of A.\nIs there maybe any other approach to this that could be used?\n\nPointing me towards already existing solutions would be very helpful!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":60900639,"Users Score":0,"Answer":"Essentially module B want to observe module A as it goes though extensive computation steps. And it is up to module A to decide how to compute progress and share this with module B. Module B can't compute progress as it doesn't know details of computation. So its is good use of observer pattern. Module A keeps notifying B about its progress. Form of progress update is also important. It can in terms of percentage, or \"step 5 of 10\" or time. It will actually define the notification payload structure with which module A will notify module B.","Q_Score":0,"Tags":"python,python-3.x,design-patterns,progress","A_Id":60915414,"CreationDate":"2020-03-28T11:38:00.000","Title":"How to populate module internal progress status to another 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":"For a school project I need to evaluate a neural network with different learning rates. I chose sklearn to implement the neural network (using the MLPRegressor class). Since the training data is pretty small (20 instances, 2 inputs and 1 output each) I decided to use the lbfgs solver, since stochastic solvers like sgd and adam for this size of data don't make sense.\nThe project mandates testing the neural network with different learning rates. That, however, is not possible with the lbfgs solver according to the documentation:\n\nlearning_rate_init double, default=0.001\n  The initial learning rate used. It controls the step-size in updating the weights. Only used when solver=\u2019sgd\u2019 or \u2018adam\u2019.\n\nIs there a way I can access the learning rate of the lbfgs solver somehow and modify it or that question doesn't even make sense?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1876,"Q_Id":60902315,"Users Score":4,"Answer":"LBFGS is an optimization algorithm that simply does not use a learning rate. For the purpose of your school project, you should use either sgd or adam. Regarding whether it makes more sense or not, I would say that training a neural network on 20 data points doesn't make a lot of sense anyway, except for learning the basics.\nLBFGS is a quasi-newton optimization method. It is based on the hypothesis that the function you seek to optimize can be approximated locally by a second order Taylor development. It roughly proceeds like this:\n\nStart from an initial guess\nUse the Jacobian matrix to compute the direction of steepest descent\nUse the Hessian matrix to compute the descent step and reach the next point\nrepeat until convergence\n\nThe difference with Newton methods is that quasi Newton methods use approximates for the Jacobian and\/or Hessian matrices.\nNewton and quasi-newton methods requires more smoothness from the function to optimize than the gradient descent, but converge faster. Indeed, computing the descent step with the Hessian matrix is more efficient because it can foresee the distance to the local optimum, thus not ending up oscillating around it or converging very slowly. On the other side, the gradient descent only use the Jacobian matrix (first order derivatives) to compute the direction of steepest descent and use the learning rate as the descent step.\nPractically the gradient descent is used in deep learning because computing the Hessian matrix would be too expensive.\nHere it makes no sense to talk about a learning rate for Newton methods (or Quasi-Newton methods), it is just not applicable.","Q_Score":1,"Tags":"python,scikit-learn,neural-network","A_Id":61059397,"CreationDate":"2020-03-28T14:58:00.000","Title":"MLPRegressor learning_rate_init for lbfgs solver in sklearn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a kivy app, where I use JsonStorage. Where does kivy save the json files, so how can I find it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":60902776,"Users Score":1,"Answer":"I just found out the json file is on the same level as the kivy_venv folder","Q_Score":1,"Tags":"python,json,kivy","A_Id":60902873,"CreationDate":"2020-03-28T15:31:00.000","Title":"Where does kivy.storage.jsonstore saves its files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My .kv file is not supported by VScode. VScode suggested two extensions to work with .kv files which are Kivy and KVlang. I installed them both but I still get an error: Kivy files require #:kivy !ex.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":342,"Q_Id":60903888,"Users Score":1,"Answer":"You need to declare #:kivy 1.x at the top of your .kv file. Replace the 1.x with whatver version you are using for example I am using 2.0 so mine looks like #:kivy 2.0","Q_Score":1,"Tags":"python-3.x,visual-studio-code,kivy-language","A_Id":66583902,"CreationDate":"2020-03-28T16:54:00.000","Title":".kv file is not supported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My python version is Python 3.7.7 and scrapy requires Python 3.5 or above, yet in Atom I'm getting the following error:\n\n\"scrapy 2.0.1 requires Python 3.5\"\n\nI have previously had trouble with Atom defaulting to Python2, so have already updated python.coffee command to 'python3'.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":60908044,"Users Score":0,"Answer":"uninstall python 2.x can solve this problem","Q_Score":0,"Tags":"python-3.x,scrapy,atom-editor","A_Id":61201076,"CreationDate":"2020-03-28T22:58:00.000","Title":"Scrapy error: \"scrapy 2.0.1 requires Python 3.5\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I press run, does it suppose to give me an output? Or does it only show error 0? I am taking a course in which the instructor gets an output when he presses the run option.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":60909630,"Users Score":0,"Answer":"When you run a program in Pycharm (under a normal run configuration) it will display the command used to run the program (grayed out at the top), followed by the program output in the run tab. When the program ends it will display the exit code (0 indicates it finished without any errors).\nIf it shows the exist code without any other output then the program just didn't print or use stdin\/stderr while running. It doesn't sound like you have done anything wrong, you just need to modify your code to provide output. Your instructor was likely just running a different python script than the one you ran.","Q_Score":0,"Tags":"python,pycharm,anaconda,conda","A_Id":60909766,"CreationDate":"2020-03-29T02:55:00.000","Title":"Run configuration in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are building an AI enabled web application that uses huge memory models that ideally should be loaded only once in memory as global variables.\nThese variables are to be used by different management commands which run as individual processes and make use of the Django framework. And of course, the runserver command too accesses these global variables.\nThese models are loaded inside a single module commons but since we are spawning different processes, let us assume two for now - runserver and process_tasks, these models are essentially loaded twice in memory via the commons module.\nIs there a way to load these models centrally and share the variables between independently spawned processes. I'm aware of the multiprocessing module in python and the Manager API, but can't figure out a way for incorporating it with the current scenario.\nIs there a way to run a standalone python process that holds these variables and be able to access them from multiple other processes?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":60911430,"Users Score":0,"Answer":"I know there isn't a 'proper' solution to this. I used a crude approach of writing a temp file after having these models loaded in the \\schema.py and then import the object model into my 'business_logic.py' checking if the file is there, then don't initialize the model again.\nHope it helps others.","Q_Score":0,"Tags":"python,django,shared-memory","A_Id":61681070,"CreationDate":"2020-03-29T07:47:00.000","Title":"Access variables without re-loading them between management commands in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So, i had a working report, using bokeh and some Select buttons with callbacks using CustomJS.\n(if its important, I have a simple DataTable, which I change the data according to the selected value in the Select button)\nMy bokeh version was 0.12.5 and everything worked ok.\nSince upgrading to 1.3.0, the report is broken.\nLooking at the source, this is the error I'm seeing:\nbokeh-tables-1.3.0.min.js:86 Uncaught Error: SlickGrid's 'enableColumnReorder = true' option requires jquery-ui.sortable module to be loaded\nTried looking for solutions online, couldn't find anything.\nAnyone have any idea? Do I need to load sortable module somehow?\nthanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":384,"Q_Id":60912991,"Users Score":0,"Answer":"In the JavaScript console, you should've received this warning: jquery-ui is required to enable DataTable.reorderable. So yes, you have to load jquery-ui yourself.","Q_Score":0,"Tags":"javascript,python,bokeh","A_Id":60913577,"CreationDate":"2020-03-29T10:38:00.000","Title":"bokeh issue - Uncaught Error: SlickGrid's 'enableColumnReorder = true' option requires jquery-ui.sortable module to be loaded","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i have the following error when i run the command  java -mx4g -cp \"*\" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000 in folder of stanford core nlp\ni have installed java runtime environment:\nInvalid maximum heap size: -Xmx4g\nThe specified size exceeds the maximum representable size.\nError: Could not create the Java Virtual Machine.\nError: A fatal exception has occurred. Program will exit.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":60913934,"Users Score":0,"Answer":"Do you use 64-bit Java? \nIt depends on the OS you are using, but with 32-bit Java, you can't usually give all 4g for the heap.","Q_Score":0,"Tags":"java,python,nlp,heap-size","A_Id":60927341,"CreationDate":"2020-03-29T12:00:00.000","Title":"Stanfordcore Nlp invalid maximum heap size error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python. I am installing Anaconda 3 2020.02 (64-bit) on my windows 7 laptop. It get stuck at file name as anaconda-2020.02-py37_tar.bz2 \nI tried multiple time but it's happening everytime","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":14732,"Q_Id":60915224,"Users Score":1,"Answer":"I just did it. It does not get stuck, it just takes a veeeeery long time to extract (like 10-15 mins). the final size of the Anaconda folder is 5.4 GB, that is probably the reason why.","Q_Score":5,"Tags":"python,anaconda3","A_Id":66193941,"CreationDate":"2020-03-29T13:57:00.000","Title":"Anaconda installation get stuck at extract: anaconda-2020.02-py37_0.tar.bz2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python. I am installing Anaconda 3 2020.02 (64-bit) on my windows 7 laptop. It get stuck at file name as anaconda-2020.02-py37_tar.bz2 \nI tried multiple time but it's happening everytime","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":14732,"Q_Id":60915224,"Users Score":1,"Answer":"I had this issue for a while and just tried @wizu recommendation. It worked. I was able to install Anaconda3 2019.10 successfully. I think this is specifically a issue with the 2020.02 release.","Q_Score":5,"Tags":"python,anaconda3","A_Id":61412029,"CreationDate":"2020-03-29T13:57:00.000","Title":"Anaconda installation get stuck at extract: anaconda-2020.02-py37_0.tar.bz2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python. I am installing Anaconda 3 2020.02 (64-bit) on my windows 7 laptop. It get stuck at file name as anaconda-2020.02-py37_tar.bz2 \nI tried multiple time but it's happening everytime","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":14732,"Q_Id":60915224,"Users Score":0,"Answer":"I had faced the same issue as well on my Windows 10 desktop. All I see is lots of idle conda processes in Task Manager and the installer stuck on anaconda-2020.02-py37_0.tar.bz2. Extracting the anaconda-2020.02-py37_0.tar.bz2 file with 7zip while the installer was stuck did not help.  \nI solved the problem by running the installer on a separate Windows 10 machine which does not have trouble running the installer. I then moved the Anaconda3 installation folder to my problematic machine.\nNow this does not normally work and anaconda highly recommends installing by running the installer instead of transplanting the folder. But we can hack it to work (as far as I have tested) by doing the following:\n1) Using a program, search through every text file (.cmake, .txt, .sh, ..py, .pc, .prl, .conf) for string instances of the old full path to Anaconda3 on the original installation directory and replace them with the full path to the new Anaconda3 installation directory.\nSome paths may use  double backslash \\\\, single backslash \\, forward slash \/ \nor even a mix of them. Be careful to handle all these cases. \n2) Some numpy related text files may contain paths to C:\\Program Files(x86)\\IntelSWTools\\compilers_and_libraries_2020.X.XXX\\.... Be sure to change this path to the available intel accelerated libraries on the new machine.\nAdditionally, copy over the start menu program shortcuts (found in C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Anaconda3(64 bit)) to the same location on the new machine. Right click on each shortcut file to change the target path. \nIf the transplanting worked, on the problematic machine you should be able to launch Anaconda prompt from the Start Menu, launch spyder, and subsequently run numpy functions. \nThis is a hackish solution. But until we can find the root cause of the installation issue this is the only way I can install Anaconda-2020.02. I am waiting to see if there are better ways to fix this problem.","Q_Score":5,"Tags":"python,anaconda3","A_Id":61201321,"CreationDate":"2020-03-29T13:57:00.000","Title":"Anaconda installation get stuck at extract: anaconda-2020.02-py37_0.tar.bz2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I'd like to look at the code of the built-in 'math' module.\nWhere would I find this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":22,"Q_Id":60916019,"Users Score":1,"Answer":"You can search like this: \"your module\" + documentation. For example: Pygame documentation. You will get all the info you need from there. Otherwise you can use google. Python is a very popular language and there's information of all kind out there. Hope this helps!","Q_Score":0,"Tags":"python-3.x","A_Id":60916081,"CreationDate":"2020-03-29T14:55:00.000","Title":"Where can I find the .py files of built-in modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to ask about deploying a bot in 2 different servers. Is there any way to differentiate the two bot instances? For example, I would like to run a bot for serverA and another instance of the same bot in serverB (testing server). I would like to have it so that the bot would respond to a command like \"!ping\" only once in serverB when testing even if serverA and serverB both have running instances of my bot (meaning there are 2 different running scripts of the same code). My dilemma is that if I have two of the same code running in 2 different terminals, when I try to call for !ping command in serverB, it performs the action twice since there are 2 instances.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":60921774,"Users Score":0,"Answer":"Running a bot in 2 terminals is not the same as having your bot join 2 servers. You'll only have 1 instance of the bot running but it's basically listening to both servers.\nDifferentiating between different servers is generally not needed because the bot will be responding in the context of the server it got a command from. However, if you want to keep track of certain data with files you can do so by including the server name in the file name. This way you can store data for each server separately.","Q_Score":1,"Tags":"python-3.x,client,discord.py","A_Id":60932793,"CreationDate":"2020-03-29T22:54:00.000","Title":"Discord.py differentiating between two different 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 had this error while I was working on my assignment using python 3.7 in Visual Studio Code. I tried to comment in some previous stackoverflow posts but it doesn't allow me to comment. So I'm sharing the solution I found in this post.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1354,"Q_Id":60922896,"Users Score":0,"Answer":"In my case it was a bit different. My vscode's interpreter was pointing to another version of python.\nTo change the python3 interpreter, open command palette(ctrl+shift+p) and search for, Python : Select Interpreter. Now change that to the correct path and it is good to go.","Q_Score":1,"Tags":"python,selenium,pylint","A_Id":64180272,"CreationDate":"2020-03-30T01:32:00.000","Title":"Unable to import 'selenium' pylint(import-error) (solution)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python. I had a line of code to print strings along with variables. I decided to instead, assign what I had in the print statement to a variable, so I could print that information elsewhere. Once I assigned it to a variable it won't concatenate the string with the other variables.\nfin = 'Wins:' , str(wins) + '\/' + runtime , '\\nWin Percentage:' , str(winperc) + '%\\n'\nNormally this would print out something like this:\nWins: 308\/1000\nWin Percentage: 30.8%\nHowever when print that as a variable it comes out like this:\n('wins:', '311\/1000', '\\nWin Percentage:', '31.1%\\n')\nI tried printing the variable as a string,but it did not work.\nI can't think of anything else or find a solution for this. If you need to see the rest of the code I can paste it.","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":718,"Q_Id":60922955,"Users Score":-1,"Answer":"String concatenation is always with +, not with comas. So it would be like this:\nfin = 'Wins:' + str(wins) + str(runtime) + '\\nWin Percentage:' + str(winperc) + '%\\n'\nAlso make sure that you're running python 3. In python 2 the print() function is without parenthesis.","Q_Score":0,"Tags":"python,python-3.x","A_Id":60922987,"CreationDate":"2020-03-30T01:44:00.000","Title":"Python3: Assign Concatenated String to a Variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wish to place a python program on GitHub and have other people download and run it on their computers with assorted operating systems. I am relatively new to python but have used it enough to have noticed that getting the assorted versions of all the included modules to work together can be problematic. I just discovered the use of requirements.txt (generated with pipreqs and deployed with the command pip install -r \/path\/to\/requirements.txt) but was very surprised to notice that requirements.txt does not actually state what version of python is being used so obviously it is not the complete solution on its own. So my question is: what set of specifications\/files\/something-else is needed to ensure that someone downloading my project will actually be able to run it with the fewest possible problems.\nEDIT: My plan was to be guided by whichever answer got the most upvotes. But so far, after 4 answers and 127 views, not a single answer has even one upvote. If some of the answers are no good, it would be useful to see some comments as to why they are no good.","AnswerCount":8,"Available Count":1,"Score":-0.024994793,"is_accepted":false,"ViewCount":3085,"Q_Id":60928734,"Users Score":-1,"Answer":"Because it is missing from the other answers, I would like to add one completely different aspect: \nUnit testing. Or testing in general.\nUsually, it is good to have one known good configuration. Depending on what the dependencies of the program are, you might have to test different combinations of packages. You can do that in an automated fashion with e.g. tox or as part of a CI\/CD pipeline.\nThere is no general rule of what combination of packages should be tested, but usually python2\/3 compatability is a major issue. If you have strong dependencies on packages with major version differences, you might want to consider testing against these different versions.","Q_Score":17,"Tags":"python,requirements.txt","A_Id":61082573,"CreationDate":"2020-03-30T10:39:00.000","Title":"Robust way to ensure other people can run my python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to submit a job to EMR cluster via Livy. My Python script (to submit job) requires importing a few packages. I have installed all those packages on the master node of EMR. The main script resides on S3 which is being called by the script to submit job to Livy from EC2. Everytime I try to run the job on a remote machine (EC2), it dies stating Import Errors(no module named [mod name] )\nI have been stuck on it for more than a week and unable to find a possible solution. Any help would be highly appreciated.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1096,"Q_Id":60931595,"Users Score":1,"Answer":"These packages that you are trying to import. Are they custom packages ? if so how did you package them. Did you create a wheel file or zip file and specify them as --py-files in your spark submit via livy ?\nPossible problem.\nYou installed the packages only on the master node. You will need to log into your worker nodes and install the packages there too. Else when u provision the emr , install the packages using bootstrap actions\nYou should be able to add libraries via \u2014py-files option, but it\u2019s safer to just download the wheel files and use them rather than zipping anything yourself.","Q_Score":1,"Tags":"python,python-3.x,amazon-emr,livy","A_Id":60941345,"CreationDate":"2020-03-30T13:26:00.000","Title":"Python packages not importing in AWS EMR","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 the following setup:\n\nOne thread which runs a directory crawler and parses documents \nAnother thread which processes database requests it gets in a queue - there are two basic database requests that come through - mark document processed (write operation) and is document already\nprocessed (select operation)\n\nI understand that an sqlite connection object cannot be shared across threads, so the connection is maintained in the database thread. I am new to threading though and in my parser thread I want to check first if a document has been processed which means a database call, but obviously cannot do this call directly and have to send the request to the database thread which is fine.\nHowever, where I am stuck is I am not sure how to make the parser thread wait for the result of the \"has document been processed\" request in the database thread. Is this where a threading event would come in?\nThanks in advance for your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":60931619,"Users Score":0,"Answer":"Thanks to stovfl, used a threading event to realise this. Thanks again!","Q_Score":0,"Tags":"python,multithreading,queue","A_Id":60938620,"CreationDate":"2020-03-30T13:27:00.000","Title":"Python wait for request to be processed by queue and continue processing based on response","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Do you know if it's possible to use a very small subset of my training data (100 or 500 instances only for example), to train very rough CNN network quickly in order to compare different architectures, then select the best performing one ?\nWhen I say \"possible\", I mean is there evidence that applying that kind of selection strategy works, and that the selected network will consistently outperform the other to for this specific task. \nThank you,\nFor information, the project in question would constist of two stages CNNs to classify multichannel timeseries. The first CNN would forecast the inputs data over the next period of time, then the second CNN would use this forecast and classify the results in two categories.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":109,"Q_Id":60931794,"Users Score":1,"Answer":"The procedure you are talking about is actually used in practice. When tuning hyperparameters, a lot of people select a subset of the whole dataset to do this.\nIs the best architecture on the subset necessarily the best on the full dataset? NO! However, it's the best guess you have and that's why it's useful.\n\nA couple of things to note on your question:\n\n100-500 instances is extremely low! The CNN still needs to be trained. When we say subset we usually mean tens of thousands of images (out of the millions of the dataset). If your dataset is under 50000 images then why do you need a subset?  Train on the whole dataset.\nContrary to what a lot of people believe, the details of the architecture are of little importance to the classification performance. Some of the hyperparameters you mention (e.g. kernel size) are of secondary importance. The key things you should focus on is depth, size of layers, use of pooling\/skip connections\/batch norm\/dropout, etc.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,conv-neural-network","A_Id":60931976,"CreationDate":"2020-03-30T13:37:00.000","Title":"Training CNN on small subsets to select architecture","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to delete a particular row from a given user input that matches with a column.\nLet's say I get an employee ID and delete all it's corresponding values in the row. \nNot sure how to approach this problem and other sources suggest using a temporary csv file to copy all values and re-iterate.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":60933352,"Users Score":0,"Answer":"Since these are very primitive requirements, I would just do it manually.\nRead it line by line - if you want to delete the current line, just don't write it back.\nIf you want to delete a column, for each line, parse it as csv (using the module csv - do not use .split(',')!) and discard the correct column.\nThe upside of these solutions is that it's very light on the memory and as fast as it can be runtime-wise.","Q_Score":0,"Tags":"python-3.x,csv","A_Id":60933565,"CreationDate":"2020-03-30T14:57:00.000","Title":"Deleting a particular column\/row from a CSV file using python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using tensorflow-2 gpu with tf.data.Dataset.\nTraining on small models works.\nWhen training a bigger model, everything works at first : gpu is used, the first epoch works with no trouble (but I am using most of my gpu memory).\nAt validation time, I run into a CUDA_ERROR_OUT_OF_MEMORY with various allocation with a smaller and smaller amount of bytes that could not be allocated (ranging from 922Mb to 337Mb).\nI currently have no metrics and no callbacks and am using tf.keras.Model.fit.\nIf I remove the validation data, the training continues.\nWhat is my issue ? how can I debug this ?\nIn tf1, I could use RunOptions(report_tensor_allocations_upon_oom=True), does any equivalent exist in tf2 ? \nThis occurs with tensorflow==2.1.0 .","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":509,"Q_Id":60933768,"Users Score":0,"Answer":"These did not occur in \n2.0 alpha TensorFlow but in 2.0. \nPip installs tensorflow-gpu==2.0.0: has \nleaked memory!\nPip install tensorflow-gpu==2.0.0-alpha: \nit's all right!\nTry it out","Q_Score":5,"Tags":"python,gpu,tensorflow2.x","A_Id":60934498,"CreationDate":"2020-03-30T15:19:00.000","Title":"How to debug out of memory in tensorflow2-gpu","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently facing a weird problem when trying to access a server via Python Requests:\nThis server is using a certificate generated by a CA and the client uses a certificate signed by that same CA. The CA is signed by a self-signed root CA. When accessing a server using a hostname like this\nrequests.get(\"https:\/\/example.com\/\", verify=\"root.pem\", timeout=3)\nit works without any problems whatsoever. When the same code is running against a server that is only accessible via a public IP and also has a certificate with the common name and subject alternative name set to this IP, then this code fails with the error message\nrequests.get(\"https:\/\/<IP>\/\", verify=\"root.pem\", timeout=3)\nrequests.exceptions.SSLError: HTTPSConnectionPool(host='<IP>', port=443): Max retries exceeded with url: \/test\/ (Caused by SSLError(SSLCertVerificationError(\"hostname '<IP>' doesn't match '<IP>'\")))\neven though for example the OpenSSL s_client does not report any errors when connecting. \nOnline I could not find anyone else reporting or solving this issue where there were no hostnames involved but only plain IPs. The certificates themselves are also not at issue, since checking them against one another produces no errors. Especially the error message confuses me, since the IPs are clearly the same.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":473,"Q_Id":60934651,"Users Score":1,"Answer":"I actually found the error now, it stemmed from a wrong assumptions, that an IP address should also be documented in the certificate using the DNS name extension. I was unaware that there is an IP address extension available for such purposes. Using this resolved the issue for me.","Q_Score":1,"Tags":"ssl,https,python-requests","A_Id":60938094,"CreationDate":"2020-03-30T16:06:00.000","Title":"Problem when accessing hosts using Python Requests via HTTPS via their IP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a django webapp where i need to stream some stock market trades on a webpage in real time. In order to do that, i'm searching for various approaches, and i found about Pusher and RabbitMQ.\nWith RabbitMQ i would just send the message to RMQ and consume them from Django, in order to get them on the web page. While looking for other solutions, i've also found about Pusher. What it's not clear, to me, is the difference between the two, technically. I don't understand where would i use Rabbit and where would i use Pusher, can someone explain to me how are they different? Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":741,"Q_Id":60935742,"Users Score":4,"Answer":"You may be thinking of data delivery, non-blocking operations or push\nnotifications. Or you want to use publish \/ subscribe, asynchronous\nprocessing, or work queues. All these are patterns, and they form\npart of messaging.\nRabbitMQ is a messaging broker - an intermediary for messaging. It\ngives your applications a common platform to send and receive\nmessages, and your messages a safe place to live until received.\nPusher is a hosted service that makes it super-easy to add real-time data and functionality to web and mobile applications.\nPusher sits as a real-time layer between your servers and your\nclients. Pusher maintains persistent connections to the clients -\nover WebSocket if possible and falling back to HTTP-based\nconnectivity - so that as soon as your servers have new data that\nthey want to push to the clients they can do, instantly via Pusher.\nPusher offers libraries to integrate into all the main runtimes and\nframeworks. PHP, Ruby, Python, Java, .NET, Go and Node on the server\nand JavaScript, Objective-C (iOS) and Java (Android) on the client.","Q_Score":0,"Tags":"python,django,rabbitmq,pusher","A_Id":60935979,"CreationDate":"2020-03-30T17:08:00.000","Title":"What's the difference between RabbitMQ and Pusher?","Data Science and Machine Learning":0,"Database and SQL":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 opened a virtual enviroment and accidentally closed the command prompt window in Windows. \nI wanted to delete the virtual enviroment folder, but when I tried, it says program is running which still uses the files. \nSo how do I get back to the virtual enviroment, without opening a new one?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17,"Q_Id":60937113,"Users Score":0,"Answer":"Just kill the daemon-process by command in Ctrl+Alt+Del interface. Then you can delete a folder","Q_Score":0,"Tags":"python,windows,virtualenv","A_Id":60937164,"CreationDate":"2020-03-30T18:29:00.000","Title":"How to accesss a python virtual enviroment when the command prompt is accidentally closed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Does sample= 0 in Gensim word2vec mean that no downsampling is being used during my training? The documentation says just that \n\n\"useful range is (0, 1e-5)\"\n\nHowever putting the threshold to 0 would cause P(wi) to be equal to 1, meaning that no word would be discarded, am I understanding it right or not? \nI'm working on a relatively small dataset of 7597 Facebook posts (18945 words) and my embeddings perform far better using sample= 0rather than anything else within the recommended range. Is there any particular reason? Text size?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":653,"Q_Id":60938299,"Users Score":2,"Answer":"That seems an incredibly tiny dataset for Word2Vec training. (Is that only 18945 unique words, or 18945 words total, so hardly more than 2 words per post?) \nSampling is most useful on larger datasets - where there are so many examples of common words, more training examples of them aren't adding much \u2013 but they are stealing time from, and overwieghting those words' examples compared to, other less-frequent words. \nYes, sample=0 means no down-sampling.","Q_Score":0,"Tags":"python,math,gensim,word-embedding,subsampling","A_Id":60940902,"CreationDate":"2020-03-30T19:42:00.000","Title":"Gensim word2vec downsampling sample=0","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have scheduled a python web-scraper to run everyday at specified time. This puts load on spyder memory after a while results in system crash. Is there a way to solve this issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":322,"Q_Id":60938355,"Users Score":0,"Answer":"I had the same problem with using Spyder IDE for a process that I was running.\nThings like deleting variables and using gc.collect() didn't work to free memory within a loop for my script on Ubuntu 20.04.\nThe way I got around having memory crash problems in long loops inside of Spyder was to run the script in terminal instead of Spyder using python my_script.py.  This worked for me and my loops or long processes aren't crashing my memory anymore!  Goodluck!","Q_Score":1,"Tags":"python,memory,web-scraping,spyder,scheduler","A_Id":63410519,"CreationDate":"2020-03-30T19:46:00.000","Title":"Is there a way to free used memory in Spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"It's past time for me to move from my custom scientific workflow management (python) to some group effort.  In brief, my workflow involves long running (days) processes with a large number of shared parameters.  As a dependency graph, nodes are tasks that produce output or do some other work. That seems fairly universal in workflow tools.\nHowever, key to my needs is that each task is defined by the parameters it requires.   Tasks are instantiated with respect to the state of those parameters and all parameters of its dependencies.  Thus if a task has completed its job according to a given parameter state, it is complete and not rerun.  This parameter state is NOT the global parameter state but only what is relevant to that part of the DAG. This reliance on parameter state rather than time completed appears to be the essential difference between my needs and existing tools (at least what I have gathered from a quick look at Luigi and Airflow).  Time completed might be one such parameter, but in general it is not the time that determines a (re)run of the DAG, but whether the parameter state is congruent with the parameter state of the calling task. There are non-trivial issues (to me) with 'parameter explosion' and the relationship to parameter state and the DAG, but those are not my question here.\nMy question -- which existing python tool would more readily allow defining 'complete' with respect to this parameter state?  It's been suggested that Luigi is compatible with my needs by writing a custom complete method that would compare the metadata of built data ('targets') with the needed parameter state.\nHow about Airflow? I don't see any mention of this issue but have only briefly perused the docs.  Since adding this functionality is a significant effort that takes away from my 'scientific' work, I would like to start out with the better tool. Airflow definitely has momentum but my needs may be too far from its purpose.\nDefining the complete parameter state is needed for two reasons -- 1) with complex, long running tasks, I can't just re-run the DAG every time I change some parameter in the very large global parameter state, and 2) I need to know how the intermediate and final results have been produced for scientific and data integrity reasons.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":208,"Q_Id":60938401,"Users Score":1,"Answer":"I looked further into Luigi and Airflow and as far as I could discern neither of these is suitable for modification for my needs.  The primary incompatibility is that these tools are fundamentally based on predetermined DAGs\/workflows.  My existing framework operates on instantiated and fully specified DAGs that are discovered at run-time rather than concisely described externally -- necessary because knowing whether each task is complete, for a given request, is dependent on many combinations of parameter values that define the output of that task and the utilized output of all upstream tasks. By instantiated, I mean the 'intermediate' results of individual runs each described by the full parameter state (variable values) necessary to reproduce (withstanding any stochastic element) identical output from that task.\nSo a 'Scheduler' that operates on a DAG ahead of time is not useful.\nIn general, most existing workflow frameworks, at least in python, that I've glanced at appear more to be designed to automate many relatively simple tasks in an easily scalable and robust manner with parallelization, with little emphasis put on the incremental building up of more complex analyses with results that must be reused when possible designed to link complex and expensive computational tasks the output of which may likely in turn be used as input for an additional unforeseen analysis.\nI just discovered the 'Prefect' workflow this morning, and am intrigued to learn more -- at least it is clearly well funded ;-).  My initial sense is that it may be less reliant on pre-scheduling and thus more fluid and more readily adapted to my needs, but that's just a hunch.  In many ways some of my more complex 'single' tasks might be well suited to wrap an entire Prefect Flow if they played nicely together.  It seems my needs are on the far end of the spectrum of deep complicated DAGs (I will not try to write mine out!) with never ending downstream additions. \nI'm going to look into Prefect and Luigi more closely and see what I can borrow to make my framework more robust and less baroque.  Or maybe I can add a layer of full data description to Prefect...\nUPDATE -- discussing with Prefect folks, clear that I need to start with the underlying Dask and see if it is flexible enough -- perhaps using Dask delayed or futures.  Clearly Dask is extraordinary.  Graphchain built on top of Dask is a move in the right direction by facilitating permanent storage of 'intermediate' output computed over a dependency 'chain' identified by hash of code base and parameters.  Pretty close to what I need, though with more explicit handling of those parameters that deterministically define the outputs.","Q_Score":2,"Tags":"python,workflow,airflow,scientific-computing,luigi","A_Id":61064713,"CreationDate":"2020-03-30T19:49:00.000","Title":"Recommended python scientific workflow management tool that defines dependency completeness on parameter state rather than time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Tried using Python\nOption with document.body.style.zoom= '150%', not suitable.\nAnd with document.body.style.zoom= '1.5' also doesn't work.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":435,"Q_Id":60941346,"Users Score":1,"Answer":"I'm sorry I almost immediately found a solution after the post of the question)\nwebdriver.execute_script(\"document.body.style.MozTransform='scale(1)';\")","Q_Score":1,"Tags":"python-3.x,selenium,geckodriver","A_Id":60941355,"CreationDate":"2020-03-30T23:52:00.000","Title":"How to zoom in Firefox-geckodriver by selenium?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to using Spyder. \nWhile using breakpoints to debug, is there any way to check the stack-trace of the algorithm?\nI want to check through which function calls did I land on the breakpoint.\n[Similar to what we get when errors crop up].","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":217,"Q_Id":60942831,"Users Score":1,"Answer":"(Spyder maintainer here) That's not possible at the moment, sorry.","Q_Score":0,"Tags":"python,windows-10,ide,spyder","A_Id":60958274,"CreationDate":"2020-03-31T03:06:00.000","Title":"Stacktrace in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have looked at similar posts but could not find the solution to my problem.  I had installed mySQL 8.0 version using homebrew on MacOS but then needed to downgrade it to mySql 5.6. I uninstalled the 8.0 version completely and deleted any left over files.I then installed the 5.6.1 using the native mySQL dmg package for Mac. On running my python project I get the Library not loaded error for \/usr\/local\/opt\/mysql\/lib\/libmysqlclient.21.dylib referenced from the _mysql.cpython-36m-darwin.so. I am not sure why this location is getting referenced as I have only libmysqlclient.18.dylib on my system under a different folder usr\/local\/mysql\/lib . How can I fix the issue ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":489,"Q_Id":60943218,"Users Score":0,"Answer":"My project with Python 3.6 was lookin for libmysqlclient.21.dylib.\nI installed brew install mysql-client. It installed mysql-client 8.0. it has libmysqlclient.21.dylib. Where as i wanted to use mysql@5.6.\nSo I copied the libmysqlclient.21.dylib from \/usr\/local\/Cellar\/mysql-client\/8.0.19\/lib to  \/usr\/local\/lib\/ \nsudo ln -s \/usr\/local\/Cellar\/mysql-client\/8.0.19\/lib\/libmysqlclient.21.dylib \/usr\/local\/lib\/libmysqlclient.21.dylib","Q_Score":0,"Tags":"mysql,mysql-python","A_Id":61588197,"CreationDate":"2020-03-31T03:56:00.000","Title":"Library not loaded: \/usr\/local\/opt\/mysql\/lib\/libmysqlclient.21.dylib error when it does not exist","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need a python scripts to load the multiple excel sheet data into hive table using python. Any one helping on this.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":251,"Q_Id":60943498,"Users Score":0,"Answer":"Yes, it is very easy!!\nYou should have pandas library installed or install it using pip if you don't have by typing this in the command prompt -     py -m pip install pandas\nThen, use the following code -\nimport pandas as pd\ndf = pd.read_excel('', '')\nprint(df)\nYou will see that the table is available in excel.","Q_Score":0,"Tags":"python,python-3.x","A_Id":60943912,"CreationDate":"2020-03-31T04:31:00.000","Title":"How to load the excel data into hive using python script?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are migrating a project from python 2 to 3 that uses com server. Previously we use py2exe which works pretty well in python 2, but it is no longer maintained in the recent Python 3 release. We also tried Pyinstaller, unfortunately, it is not supporting com server from like 5 years ago. The last resort for us could be use python 3.4 which is the latest version py2exe support. But before that, just asking the question here if anyone has a similar situation and has a proper solution.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":106,"Q_Id":60943627,"Users Score":1,"Answer":"You can't deploy a win32 COM server with PyInstaller, due to the fact that the bootloader doesn't provide that.\nIf you'd like to have COM support, you'll need to program it yourself; in other words, create a python script which runs a COM server, serving your DLL\/exe. You could base this off the py2exe code.","Q_Score":1,"Tags":"python,pyinstaller,py2exe,python-2to3","A_Id":60984156,"CreationDate":"2020-03-31T04:46:00.000","Title":"Pyinstaller does not support Com Server and py2exe does not maintained in recent python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was reading about different techniques to load large data efficiently. The tf.data seems to perform well as compared to tf.keras.preprocessing.imageImageDataGenerator.  \nTo what I know is, tf.data uses CPU pipelining to efficiently load the data and process it so that model training is continuous and fast. But I did not understand how these two techniques are different and in what way. If anybody can explain this I would highly appreciate it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":60946027,"Users Score":0,"Answer":"the main difference is that ImageDataGenerator uses Pillow library for loading and preprocessing image and tf.data uses tf.image pre-processing technique. ImageDataGenerator returns a batches of tensor Images.Also tf.data uses functions like prefetch,cache to improve the efficiency of preparing the dataset.","Q_Score":3,"Tags":"python,tensorflow,keras,distributed-computing,distributed-training","A_Id":69767805,"CreationDate":"2020-03-31T08:11:00.000","Title":"tf.data vs tf.keras.preprocessing.image.ImageDataGenerator","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Stack Overflow has many questions about\n\nHow to give someone else a python script protecting the source code\nHow to compile python files\nHow to create packages and deploy the code\n\nBut I could not find the answer to my problem:\nI want to give someone else my python script, without giving him the source code. My current attempt is compiling the file and giving away the .pyc file. \nThis is for sure not the best solution. Moreover, my code is made by different files. To offer a single executable pyc file, I put the code all together in a single file before compiling it: a true hell for a developer\nHow can I obtain my goal in a cleaner way?\nSide-notes\nI know .pyc files are not going to hide so much, but it is for sure better compared to giving .py files\nStill, .pyc files can be incredibly problematic (as they can be system-dependant)","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2699,"Q_Id":60946171,"Users Score":1,"Answer":"using \"pyinstaller sroucecode.py --onefile\" command will generate an executable file on Windows. This can be a way should it be desired to ship the functionality but hide the code.","Q_Score":6,"Tags":"python,deployment","A_Id":60949697,"CreationDate":"2020-03-31T08:21:00.000","Title":"Python: How to offer a single executable file without showing the code in 2020","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to write a program for Windows using python and python frameworks (pandas, numpy etc.), which I want to use to replace several engineering excel spreadsheets (which are repetitive). Please point me in the right direction regarding which python frameworks to use.\nThe program should contain and be able to do the following:\n- Have a GUI to input variables\n- Compute excel formulas using said variables\n- Create graphs\n- Export information to excel spreadsheets\n- Create PDFs\nI know I can set up a single excel spreadsheet to do the above, but I'm using this as a way to learn programming...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":60946507,"Users Score":0,"Answer":"A good way to learn, maybe a less good way to solve the said problem.\nGUI - ?\nMatplotlib can be used for the graphs.\nExporting to excel can be done easily in pandas with df.to_excel()\nweasyprint library can be used to export to pdf.","Q_Score":0,"Tags":"python,excel,frameworks","A_Id":60947622,"CreationDate":"2020-03-31T08:41:00.000","Title":"Writing a Windows program to replace several engineering excel spreadsheets","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to resize images from 28*28 to 32*32,used tf.image.resize_images(x_train, (32, 32)).It returns AttributeError: module 'tensorflow_core._api.v2.image' has no attribute 'resize_images'.The version of tersorflow is 2.0.0. How can I fix it?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":15405,"Q_Id":60948568,"Users Score":0,"Answer":"The function has been renamed into resize.\nThe code can be changed as follows;\nimport tensorflow as tf\nimg_A=tf.image.resize(................)","Q_Score":5,"Tags":"python,tensorflow2.0","A_Id":71160984,"CreationDate":"2020-03-31T10:35:00.000","Title":"AttributeError: module 'tensorflow_core._api.v2.image' has no attribute 'resize_images'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to resize images from 28*28 to 32*32,used tf.image.resize_images(x_train, (32, 32)).It returns AttributeError: module 'tensorflow_core._api.v2.image' has no attribute 'resize_images'.The version of tersorflow is 2.0.0. How can I fix it?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":15405,"Q_Id":60948568,"Users Score":0,"Answer":"The function has been renamed to resize. You should change your code like it was done below. It worked for me.\nimport tensorflow as tf\nimg_final = tf.image.resize(img_tensor, [192, 192])","Q_Score":5,"Tags":"python,tensorflow2.0","A_Id":71145565,"CreationDate":"2020-03-31T10:35:00.000","Title":"AttributeError: module 'tensorflow_core._api.v2.image' has no attribute 'resize_images'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have list of RGB images I would like to take each channel from a image in the list and reshape it.\nHowever, I am having an issue extracting the channels from the list of arrays.\nPlease refer the below code;\ndifference[0].shape\nOutput;\n(1280,720,3)\nTo get the first channel width and height in the first image in the list I tried;\ndifference[0][0].shape\nBut I get the answer; (720,3) which is the width and the number of channels. What I want is to get  is (1280,720) as the output.\nWould anyone be able to help me regarding this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":139,"Q_Id":60948836,"Users Score":2,"Answer":"Assuming difference[0] is a numpy array of shape (1280,720,3), you can use difference[0][:,:,0] to access all the data for the first dimension.\ndifference[0][:,:,0].shape will give you (1280, 720).\ndifference[0][:,:,0].shape will give you the red data.\n\ndifference[0][:,:,1].shape will give you the green data.\n\ndifference[0][:,:,2].shape will give you the blue data.","Q_Score":0,"Tags":"python,arrays,python-3.x,list,numpy","A_Id":60949046,"CreationDate":"2020-03-31T10:51:00.000","Title":"Get RGB channels from a list of arrays","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a beginner at coding and am facing a problem regarding installation of Pillow module. I firstly installed pip from PyCharm itself. Then I installed Pillow from cmd using following code:\npython -m pip install pip\nand then\npython -m pip install Pillow\nBoth times i got a message Requirement already satisfied. So that means the modules i want to install are already installed on my PC. However when i try to import the module in PyCharm, it gives me a ModuleNotFoundError: No module named 'PIL'\nwhen i import\nfrom PIL import ImageTk, Image\nWhat do I do now to use the module in my code?\nP.S. The path directory shown in cmd when i install Pillow is actually not available in my PC.\nc:\/Users\/< My name >\/appdata\/....\nThere is no folder named 'appdata' in there.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":847,"Q_Id":60950039,"Users Score":2,"Answer":"Go to File > Settings > Project Settings > Project Interpreter > Python Interpreters\nClick on the + sign on the right side. set your python path for PyCharm","Q_Score":0,"Tags":"python,pycharm,python-imaging-library","A_Id":60950171,"CreationDate":"2020-03-31T11:58:00.000","Title":"Problem regarding Installation of Pillow for PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"this has weighed me down for a week now. seems like there's no straight-forward solution anywhere, I'm really devastated.\nI have hosted my python flask webapp and it's postgres database successfully. Now I only need to link it with any cloud (not Google pls!) service that would enable the webapp to save images, and retrieve these images on request. \nI plan to use redis for caching these images, greatly reducing the rate of requests sent to the cloud storage. \nPlease help!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":446,"Q_Id":60951615,"Users Score":1,"Answer":"when you talk about save or retrieve on cloud storage what kind of storage that you have in mind? because there's few approach:\nA. Store image \/ video as Binary\nUsing this approach it means all uploaded file or image will be written into db and all requested file will be read from db.\nB. Store image \/ video as path \nUsing this approach it means if its local path then it all uploaded file will stored as local file in the server where the code is hosted.\nif its remote path then it will stored on some cloud (Google Cloud Storage, AWS S3)\nAlso in your question you mention about redis as cache. I want to clarify some few things about redis. In approach A if you want to reduce query sent to db you can utilize redis to store binary of frequent accessed file, so on the next request it will be fetch from cache instead from db. In approach B redis doesn't really reduce 'requests sent to the cloud storage' because client still fetch the file  from cloud storage and your app just return where it stored. if you want to reduce no of request sent to cloud storage then maybe you looking about client-side cache or CDN.","Q_Score":0,"Tags":"python,cloud","A_Id":60962425,"CreationDate":"2020-03-31T13:21:00.000","Title":"save and retrieve images\/videos on cloud storage linked to python flask server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am learning Django and the tutorial requires downloading Pycharm, which looks almost similar to my android studio IDE. So, can I do the same with android studio or I will have to download Pycharm ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":373,"Q_Id":60954673,"Users Score":1,"Answer":"Yes you have to download it. All the programs of Jetbrains are apparently identical. In the background, each program contains rules for the programming language. The rules of java do not follow python. So you should download the language-specific IDE you use.","Q_Score":0,"Tags":"python,django,android-studio,pycharm","A_Id":60954774,"CreationDate":"2020-03-31T15:53:00.000","Title":"Can I use android studio in place of Pycharm for learning Django .. If No.. why? and if Yes ..how?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What is a secure way to save multiple credentials needed by an API developed in Python Flask?\nIs it ok to encrypt\/hash and save credentials in a database or configuration file? As storing data this way seems to be insecure and also when password changes, we'll have to update the database somehow.\nIs there any better way available?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":97,"Q_Id":60957303,"Users Score":1,"Answer":"For production environments, secrets are usually kept in something designed to keep secrets, such as Hashicorp secrets vault, Azure Key Vault or AWS Secrets Manager. These are securely kept in the environments and are only available there.\nDeveloping locally you could use Keybase as a place to keep your secrets in files and mount the secrets directory.\nJust remember that encrypting your credentials is pointless if you hardcode the decryption key in the source code, which brings you back to the same question, where do you keep your decryption key? The answer; secrets manager \/ vaults.","Q_Score":0,"Tags":"python,api,flask","A_Id":60959522,"CreationDate":"2020-03-31T18:19:00.000","Title":"How to save multiple credentials securely for an API in Python Flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"How to open a pickled file in both read and write simultaneously in python?\nIs there any way to do this or is it imposible.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1549,"Q_Id":60957649,"Users Score":0,"Answer":"you should more informatin on what you want to achieve.\nIt would be tricky to correctly read from a pickle file with more than one object  - you'd have to keep a side structure with the indexes on the start and end of objects. \nAll in all, it is easier to use sqlite3, create a database file with it, with a single table (name it \"pickles\") that may contain just two columns: one id for your pickled objects, and the serialized object itself.","Q_Score":1,"Tags":"python,python-3.x,pickle","A_Id":60957812,"CreationDate":"2020-03-31T18:40:00.000","Title":"How to open a pickled file in both read and write simultaneously in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"(ll_env) C:\\learning_log>python manage.py test  Traceback (most recent call last):   File \"manage.py\", line 21, in \n      main()   File \"manage.py\", line 17, in main\n      execute_from_command_line(sys.argv)   File \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\django\\core\\management__init__.py\",\n  line 381, in execute_from_command_line\n      utility.execute()   File \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\django\\core\\management__init__.py\",\n  line 375, in execute\n      self.fetch_command(subcommand).run_from_argv(self.argv)   File \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\django\\core\\management\\commands\\test.py\",\n  line 23, in run_from_argv\n      super().run_from_argv(argv)   File \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\django\\core\\management\\base.py\",\n  line 315, in run_from_argv\n      parser = self.create_parser(argv[0], argv[1])   File \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\django\\core\\management\\base.py\",\n  line 289, in create_parser\n      self.add_arguments(parser)   File \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\django\\core\\management\\commands\\test.py\",\n  line 44, in add_arguments\n      test_runner_class = get_runner(settings, self.test_runner)   File\n  \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\django\\test\\utils.py\",\n  line 303, in get_runner\n      test_runner_class = test_runner_class or settings.TEST_RUNNER   File\n  \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\django\\conf__init__.py\",\n  line 79, in getattr\n      self._setup(name)   File \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\django\\conf__init__.py\",\n  line 66, in _setup\n      self._wrapped = Settings(settings_module)   File \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\django\\conf__init__.py\",\n  line 157, in init\n      mod = importlib.import_module(self.SETTINGS_MODULE)   File \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\importlib__init__.py\",\n  line 127, in import_module\n      return _bootstrap._gcd_import(name[level:], package, level)   File \"\", line 1006, in _gcd_import\n  File \"\", line 983, in _find_and_load\n  File \"\", line 967, in\n  _find_and_load_unlocked   File \"\", line 677, in _load_unlocked   File \"\", line 728, in exec_module   File\n  \"\", line 219, in\n  _call_with_frames_removed   File \"C:\\learning_log\\learning_log\\settings.py\", line 16, in \n      django.setup()   File \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\django__init__.py\",\n  line 19, in setup\n      configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)   File\n  \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\django\\conf__init__.py\",\n  line 79, in getattr\n      self._setup(name)   File \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\django\\conf__init__.py\",\n  line 66, in _setup\n      self._wrapped = Settings(settings_module)   File \"C:\\Users\\Allen\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\django\\conf__init__.py\",\n  line 176, in init\n      raise ImproperlyConfigured(\"The SECRET_KEY setting must not be empty.\")django.core.exceptions.ImproperlyConfigured: The SECRET_KEY\n  setting must not be empty.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":60958698,"Users Score":0,"Answer":"Error has nothing to do with your model or admin site. You are running your Django Program  with a settings file that doesn't have a SECRET_KEY","Q_Score":0,"Tags":"python,django","A_Id":60958736,"CreationDate":"2020-03-31T19:47:00.000","Title":"registering a model with the admin site, Once I try to define the entry Model system shows unproperly configured exception","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on building a UNET semantic segmentation network, to detect the iris in eye images we are using DICE loss function and we achieved over 90% train mean IOU and around 87% on validation data but the validation loss and mean IOU showed fluctuation during the 200 epochs, and when we tested our network it showed really poor results, the output image was nothing close to the ground truth even when we used images from the training set it still performed poorly, any suggestions on what we can do to overcome this.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":258,"Q_Id":60959200,"Users Score":0,"Answer":"Is the dataset public? You can find some good resources and guidance here: https:\/\/github.com\/NVIDIA\/DeepLearningExamples\/tree\/master\/TensorFlow2\/Segmentation\/UNet_Medical you will find also benchmark results. I think they are usinf ADAM optimizer with 0.0001 learning rate. More details in the training process section.","Q_Score":0,"Tags":"python,keras,computer-vision","A_Id":60959502,"CreationDate":"2020-03-31T20:19:00.000","Title":"CNN Semantic segmentation network (UNET) performing poorly when tested with images","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can I change the core functionality of Python, for example, rewrite it to use say(\"Hello world\") instead of print(\"Hello world\")?\nIf this is possible, how can this be done?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":60961811,"Users Score":0,"Answer":"yes you can just write \nsay = print\nsay(\"hello\")","Q_Score":1,"Tags":"python-3.x","A_Id":60962074,"CreationDate":"2020-04-01T00:12:00.000","Title":"Is it possible to \"customize\" python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to import a lower triangular matrix into pandas (or numpy) in Python in order to convert it into a symmetrical square matrix but I am stuck at the import step.\nThe matrix has the first column with names but the rest of the columns are numbers in a tab delimited format like this:\n\n A\n B   1 \n C  10  20\n D  21  25  45\n\nI get error when I try to import it using numpy:\n\nmyfile = np.genfromtxt(\"trimatrix.txt\", delimiter=\"\\t\")\n\nand also when I use pandas:\n\nmyfile = pd.read_table(\"trimatrix.txt\")\n\nIn both cases, the errors are because there is only one column after reading the first row but the other rows have more columns.\nThank you for your time and help!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":196,"Q_Id":60961957,"Users Score":1,"Answer":"The straightforward answer is that you don't simply import the triangle: its shape is, by definition, incompatible with the rectangular format required by the built-in readers of NumPy and PANDAS.  You have to write your own code to read the input file, stuff the values into the corresponding rows of your chosen data structure, and fill the missing columns with your default value: zeroes, I assume.  This needs only a simple loop.\nGiven that what you want is not a built-in method, can you handle the coding from here?","Q_Score":1,"Tags":"python,python-3.x,pandas,numpy","A_Id":60962111,"CreationDate":"2020-04-01T00:33:00.000","Title":"How do I import a lower triangular matrix using pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Once you run the regression model with the module 'statsmodels' in Python, you can get the prediction with these confidence intervals:\nmean_ci_lower   mean_ci_upper   obs_ci_lower    obs_ci_upper\nI know what mean_ci means but I have no idea what obs stands for.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":1606,"Q_Id":60963178,"Users Score":3,"Answer":"obs_ci is the prediction interval, i.e. a confidence interval for a new observation. \nIt combines the uncertainty about the mean estimate with the randomness of a new observation for given mean. It assumes that residuals are distributed close to normal distribution, uses either normal or t distribution for the prediction interval and is therefore only approximate.","Q_Score":4,"Tags":"python","A_Id":60974902,"CreationDate":"2020-04-01T03:21:00.000","Title":"What does obs confidence interval in statsmodels linear regression in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to process an excel file with ~600k rows and ~10 columns.\nI want to execute some program line by line (or row by row) as if it is an iterator (like txt\/csv files). However, if I use xlrd or pandas to read the excel file, it takes ~2-3min for opening the file.\nI wonder if it is possible to read the excel file line by line efficiently so that, for example, I can verify my program with the first 10 rows without waiting for a long time for every trial.\nEdit: Thank you for suggesting to convert the excel file to a csv before processing. However, I have to create an one-click program to the user. So, I still hope to find out a way to directly read the excel file efficiently, if possible.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":943,"Q_Id":60966543,"Users Score":0,"Answer":"Excel files are zip folder with xml file for each worksheet, maybe it's more efficient to open this file has a zip and read your line with a xml library ?","Q_Score":3,"Tags":"python,pandas","A_Id":60966649,"CreationDate":"2020-04-01T08:27:00.000","Title":"Read Excel file line by line efficiently","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have trained a spacy textcat model but then I realized that there were some incorrect training data: data from one category happened to be labeled with another category. My question is: is it possible to remove these training examples from the model without retraining it? Something like nlp.update() but in reverse? Would appreciate any help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":162,"Q_Id":60970109,"Users Score":1,"Answer":"You mean to revert specific cases? As far as I know, that's not currently possible in spaCy. \nI would suggest to either retrain from scratch with the corrected annotations, or continue training with the updated annotations. If you continue training, make sure that you keep feeding a representative set to your model, so that it doesn't \"forget\" cases it was already predicting correctly before.","Q_Score":1,"Tags":"python,spacy,text-classification","A_Id":60970636,"CreationDate":"2020-04-01T11:44:00.000","Title":"Remove training data from spacy model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working right now on project (not mine to clarify) which scraps some sites using urllib3 to make requests and some of them are under CF protection. I found some cfscrape (etc etc list of similar names) library that is a wrapper of requests.Session which may help with circumventing antibot measures of CF but there is a catch, I need proxies which are fetched by API and put into ProxyManager objects. In devenv I have no access to those proxies because of policy. Is there an easy way to get proxy url and auth from ProxyManager or do I need to add some square wheels (aka save them somewhere else as second copy) to integrate that library into project with little work as possible without degrading performance by that much? Don't really want to rewrite urllib3 usage to requests.Session","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":60972361,"Users Score":0,"Answer":"To close the question - ProxyManager does have easy access tho it's kinda strange that I couldn't find anything in the docs (maybe I overlooked it)","Q_Score":0,"Tags":"python,urllib3","A_Id":61211372,"CreationDate":"2020-04-01T13:47:00.000","Title":"How to access proxy_url\\auth in urllib3.ProxyManager","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made an Amazon Web Scraper and I want it work as an extension. What will happen is that it will  display the price if it is lower than the previously recorded price. I don't know Javascript. I went through things like Transcrypt but didn't understand much","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":406,"Q_Id":60972721,"Users Score":0,"Answer":"You cannot. Chrome extensions are written in JS.\nThe only way to accomplish what you want is to use the extension as a bridge from users browser to your script. You'll need to convert the script into a server of some kind that can accept requests from the extension and respond.","Q_Score":1,"Tags":"python,selenium-webdriver,google-chrome-extension","A_Id":60976107,"CreationDate":"2020-04-01T14:04:00.000","Title":"How do I package a Python web scraper as a Chrome Extension?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on wind power and speed\nu and vare zonal and meridional wind. (I have the values of these 2 vectors)\nThe wind speed is calculated by V = np.sqrt(u2*v2)\nWind direction is given by \u03b1 between 0 and 360 degree \nI know this relation holds - u \/ V = sin( abs(\u03b1)) and - v \/ V = cos( abs(\u03b1)) \nIn python I am using np.arccos and np.arcsin to try to find \u03b1 between 0 and 360 with the 2 equation above. For the first one, it returns the radian so I convert with np.rad2deg(...) but it gives me a value between 0 and 180 degree for the second one, I also try to convert but it returns me a valus between 0 and 90. \nAnyone knows how to code it? I am lost :(","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":453,"Q_Id":60973244,"Users Score":1,"Answer":"The underlying problem is mathematics: cos(-x) == cos(x), so the function acos has only values in the [0,pi] interval. And for equivalent reasons asin has values in [-pi\/2,pi\/2] one.\nBut trigonometric library designers know about that, and provide a special function (atan2) which uses both coordinates (and not a ratio) to give a value in the [-pi, pi] interval.\nThat being said, be careful when processing wind values. A 360 wind is a wind coming from the North, and 90 is a wind coming from the East. Which is not the way mathematicians count angles...","Q_Score":0,"Tags":"python,degrees,radians","A_Id":60973486,"CreationDate":"2020-04-01T14:28:00.000","Title":"Python Arcsin Arccos radian and degree","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new in python venv, so sorry for possible stupid question.\nI am developing a small library. I've created dev virtual environment with all packages which is necessary for the library usage and freeze all versions of requirements to requirements.txt. \nI also would like to create requirements_test.txt with all packages needed for development and tests. So the user will install requirements from requirements.txt while the developer from requirements_test.txt with all nessesary libs (e.g. pytest, asv, sphinx).\nNow I've created dev venv and now I want to create test venv, of course I don't want to install the same libs twice. Is it possible to share some libs from one venv to another?","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":422,"Q_Id":60973272,"Users Score":-1,"Answer":"Even with virtual environments, there are many libraries that come preinstalled with python and are not necessary in the package that you are developing, when I run pip freeze in a brand new virtual environment it dumps 30 packages, and surely they are not needed for my project.\nI recommend you to do the dependency maintenance manually (at least the production ones), this way you won't include useless libraries and you will keep your dependency file clean.","Q_Score":3,"Tags":"python,virtualenv","A_Id":60974193,"CreationDate":"2020-04-01T14:29:00.000","Title":"Python vitual environment (venv): Share libraries in usage and dev\/test venvs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new in python venv, so sorry for possible stupid question.\nI am developing a small library. I've created dev virtual environment with all packages which is necessary for the library usage and freeze all versions of requirements to requirements.txt. \nI also would like to create requirements_test.txt with all packages needed for development and tests. So the user will install requirements from requirements.txt while the developer from requirements_test.txt with all nessesary libs (e.g. pytest, asv, sphinx).\nNow I've created dev venv and now I want to create test venv, of course I don't want to install the same libs twice. Is it possible to share some libs from one venv to another?","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":422,"Q_Id":60973272,"Users Score":-1,"Answer":"I think it is recommended and advised to have multiple venvs, and multiple environments, be it on the same machine. so just have another venv. Its okay to have same library being present in both venvs.","Q_Score":3,"Tags":"python,virtualenv","A_Id":60973865,"CreationDate":"2020-04-01T14:29:00.000","Title":"Python vitual environment (venv): Share libraries in usage and dev\/test venvs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose there's a ppt file containing multiple slides, say 8 slides in one pptx file. Is there any way of splitting this pptx file into 8 separate pptx files by #python-pptx#?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":816,"Q_Id":60974724,"Users Score":0,"Answer":"python-pptx does not have direct API support for this. You can find some solutions that might work for you if you search on \"python-pptx copy slide\" or \"python-pptx duplicate slide\".\nIn general, the idea is to create a duplicate of each slide one-by-one in a new presentation. A slide is a collection of shapes, so the duplicate-slide operation comes down to a set of duplicate-shape operations.\nDuplicating a shape is easy for simple shapes, but becomes more difficult when the shape is a picture and more difficult still when it is a chart or smart-art.\nThe various approaches you'll find address these challenges in different ways with varying levels of success, but depending on how complex the shapes are on your particular presentation, you may be able to get the job done.","Q_Score":0,"Tags":"split,powerpoint,python-pptx","A_Id":60977627,"CreationDate":"2020-04-01T15:36:00.000","Title":"How to split a multiple-slides pptx file into separate ones by python-pptx?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using SQLAlchemy's Column(default=) when I really wanted Column(server_default=), so that the default would be in the schema and work in raw SQL. Is there a reason to use both when they are the same value, or should I switch over to using server_default= only?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":60975696,"Users Score":0,"Answer":"If you have server_default then there's no reason that I'm aware of to be inserting the same value via default.\nI haven't tested this but logically sending a default as well seems like it would preempt the server default from being used at all since the value would no longer be null from the database's perspective. Thus the database wouldn't need to step in to fill it, except in the case of using raw SQL when default doesn't apply anyway.","Q_Score":1,"Tags":"python,sqlalchemy","A_Id":69110131,"CreationDate":"2020-04-01T16:26:00.000","Title":"In a SQLAlchemy Column(), is it necessary to define both default= and server_default?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I finished making Snake in Pygame and I wanted to convert it into an app in pyinstaller. I'm working on a Mac. Even though I clearly installed the pygame module, and I even to installed it on the files path, when I run the .exe app after I converted it, it still gives me the ImportError: no module named pygame.\nYou can obviously tell, I DO have pygame because I made my program in it. Happily, when I run the code from an editor, the program works fine. Can you please help?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":181,"Q_Id":60977235,"Users Score":0,"Answer":"If you used a virtual environment to develop your game then the module will not be installed to your main python path. Just do a pip install for the modules you are missing then try running pyinstaller again. Or run the pyinstaller in your virtual environment which might work but I have not tested.","Q_Score":0,"Tags":"python,python-3.x,pygame,pyinstaller,importerror","A_Id":60977386,"CreationDate":"2020-04-01T17:53:00.000","Title":"PyInstaller doesn't read libraries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I looked everywhere, I don't find a way to properly play Ogg files, they all play wav!\nMy question is: Does somebody knows how to play Ogg files in python?\nIf somebody knows how I'll be very thankful :)\n(I am on windows)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2097,"Q_Id":60978465,"Users Score":0,"Answer":"The easiest way is probably to start a media player application to play the file using subprocess.Popen.\nIf you already have a media player associated with Ogg files installed, using the start command should work.","Q_Score":2,"Tags":"python","A_Id":60979861,"CreationDate":"2020-04-01T19:04:00.000","Title":"How to play ogg files on python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a tkinter script that I usually use in the terminal and it runs fine. However, I want to be able to put it on Jupyter server, so that my non-technical customers don't have to have Python on their computer to use the GUI.\nI've been trying to do this but I keep getting the common display error. But I don't have any admin rights to this Jupyter server, so I'm not sure I can change any settings or anything. \nDoes this mean its not possible for me to use tkinter in this scenario? Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":284,"Q_Id":60979055,"Users Score":0,"Answer":"You should not use tkinter in this situation. For a python\/tkinter application to work, the people who want to run it need to have Python.\nSince your users can interact with a Jupyter server, it is probably better to deploy your script as a Jupyter notebook. In that case everybody with a relatively recent web browser can use it.\nIf it is not a good fit for a notebook, then maybe some other kind of web application.","Q_Score":0,"Tags":"python,tkinter,jupyter-notebook","A_Id":60979378,"CreationDate":"2020-04-01T19:42:00.000","Title":"Possible to use tkinter GUI in Jupyter server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am pretty new to Pyvmomi and vsphere automation.\nI have been trying to automate the user and group creation in vsphere but could not locate the method in Pyvmomi which could help me automate the process of user creation.\nI already have a user created in vcenter (abc@xyz.local)\nThis user has administrative privileges\nNow, I want to create a session with user abc@xyz.local and add new users in Vcenter 'users and groups'. Once the new users are created, I have to add these users to different groups.\nAll these has to be done via automation using python.\nIs there a way to automate this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":750,"Q_Id":60980474,"Users Score":0,"Answer":"Unfortunately, the SSO API is all private and unavailable through pyvmomi and the rest of the SDKs.","Q_Score":0,"Tags":"python,automation,vsphere,vcenter,pyvmomi","A_Id":60981943,"CreationDate":"2020-04-01T21:16:00.000","Title":"How to automate the user creation in vcenter 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am evaluating python memory profiling. I would like to automate memory leak profiling with Jenkins and publish the report to Sonarqube. The current memory tool I am using is memory_profiler. Does Jenkins & Sonarqube support this integration? Or are there any python memory tools which I should consider which can integrate well into Jenkins & Sonarqube? Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":60983567,"Users Score":0,"Answer":"Well, I don't think Sonarqube supports that. \nThe only thing that I see you could do, is to run the memory profiler as you are doing, but instead of uploading to sonarqube as per your approach, you could create a html report from the memory profiler results and attach it to your Jenkins build.","Q_Score":3,"Tags":"python,jenkins,testing,memory,sonarqube","A_Id":61457197,"CreationDate":"2020-04-02T02:56:00.000","Title":"Python memory profiler with Sonarqube & Jenkins","Data Science and Machine Learning":0,"Database and SQL":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 column named timestamp in dataframe which extends for 30000 rows\nI want to change the unit value of the column to time and date.\nThe first value is 1590000000000 and is going down with same or different values. I want to have the new df to have the timestamp depicted as time and date.\nHow do we do this this in python?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":60984977,"Users Score":0,"Answer":"You could try using pd.to_datetime(df['mydates']).apply(lambda x: x.date())","Q_Score":0,"Tags":"python,datetime,timestamp","A_Id":60985010,"CreationDate":"2020-04-02T05:50:00.000","Title":"chnage a unix base timestamp column into time","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im using ProcessPoolExecutor to execute external command is there any way to capture stderr when the process is finished (similar to subprocess)? Im capturing executor.submit() future result but that returns 0 or 1.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":60985394,"Users Score":0,"Answer":"This might not be an answer but it is of that direction and far too long for a comment, so here goes. \nI would say no to that. You might be able to achieve this by tinkering with stderr file descriptors, redirecting that to a stream of your own and returning this as the worker result but I am wondering if ProcessPoolExecutor is suitable for your task - of course not knowing what it is. \nA subprocess created by a process pool does not finish like a subprocess created by yourself. It stays alive waiting for more work to arrive until you close the pool. If your worker produces stdout or stderr, they go to the same place where your main process directs its stdout and stderr. \nYour workers will also process many different tasks. If your pool size is four and you submit ten tasks, how do you then decipher from a plain stderr capture which task created what message?\nI have a hunch this needs to be redesigned. You would be able to raise exceptions in your workers and then later capture those from your future objects.  Or it might be that your task is something where a pool is just not suitable. If subprocesses do what you want them to do, why not use them instead?  \nPools are good for parallelising repetitive tasks that return and receive modest amount of data (implemented as queues that are not miracle performers), with a standard interface and standardised output\/error handling.  Pools simplify your code by providing the routine part. If your subtasks require different inputs, their outputs and error handling vary greatly or there is a lot of data to be transmitted, you might be better off by building the parallel processing part yourself.","Q_Score":1,"Tags":"python","A_Id":60988387,"CreationDate":"2020-04-02T06:25:00.000","Title":"Capture stderr in ProcessPoolExecutor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am a new joiner to the platform of Python programming and I am learning its basics but before I start the real code I have a question. My friend suggested to should use Jupyter Notebook for coding so can it help me to code in Python?\nThank You!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":121,"Q_Id":60989442,"Users Score":0,"Answer":"Jupiter Notebook is a web based IDE used mostly for data science, ML etc.\nSo in short the answer is: yes\nBut it really depends on what you are working on","Q_Score":0,"Tags":"python","A_Id":60989526,"CreationDate":"2020-04-02T10:27:00.000","Title":"Can Jupyter Notebooks be used to write Python codes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"for my GUI I want to use a grid with 6 columns. The size of the table is set. How do I fill the width of the grid with the columns? Can you set the size of the columns? I only found padx to change the padding, but not the actual size of the columns.\nFor now, this is supposed to work on a canvas. Is that even possible?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":476,"Q_Id":60989909,"Users Score":0,"Answer":"With only the information you passed i would recommend you following:\nGrid layouts your objects. Its not a table. \nIf you work with grid here. The simplest thing should be to set the width of the object you put on the wanted grid. For example:\n\nIf you add a Label set the label to the width you want it to be. This label will then\n  be displayed in the grid with its width and height.\n\nIf you want to display a table. Or even better load a table from a database. I would recommend a Treeview. Its good for design allows multiselect and its easy to fill and you dont have the layout problems :)","Q_Score":1,"Tags":"python,tkinter","A_Id":60990158,"CreationDate":"2020-04-02T10:54:00.000","Title":"Column width using tkinter in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a python script that accesses system features which require root privileges. \nThis \"master\" script is configured by running another Python script file, \"config.py\", using exec, that the user of my script would write and which configures some state variables in my script.\nThe master script file is root-owned while the config file is user owned (since my script users would want to modify this file).\nObviously this is not ideal, since the users of my script could run root-level commands in the config script. Is there a way to run the config file in user-level even if the master file was run in root?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":133,"Q_Id":60993916,"Users Score":0,"Answer":"Since it\u2019s a config file, you might be better off making it something non-executable like a plain ini \/ yaml etc. I\u2019m assuming you want to include it to access some constants. Sometimes it requires a little more work to set up, but ultimately, if the only code that runs is yours, you can be safe(er).","Q_Score":0,"Tags":"python,linux,scripting,sudo","A_Id":61003260,"CreationDate":"2020-04-02T14:26:00.000","Title":"Run python file in sudo but config file in user space","Data 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 was modifying the layout in Spyder 4.1.1 and somehow lost the filename tabs (names of opened .py files) that used to appear above the central editor window.  These were the tabs that had the 'X' button in them that allowed you to quickly close them.  I've been toggling options in the View and Tools menus but can't seem to get it back.  Anyone know how to restore this?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":505,"Q_Id":60993927,"Users Score":1,"Answer":"Try it. From menu View --> Panes --> Editor. Clicking on Editor and putting a tick there should bring that back if I understand your question properly","Q_Score":1,"Tags":"python,anaconda,spyder","A_Id":60996039,"CreationDate":"2020-04-02T14:27:00.000","Title":"Restore file tabs above main editor in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was modifying the layout in Spyder 4.1.1 and somehow lost the filename tabs (names of opened .py files) that used to appear above the central editor window.  These were the tabs that had the 'X' button in them that allowed you to quickly close them.  I've been toggling options in the View and Tools menus but can't seem to get it back.  Anyone know how to restore this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":505,"Q_Id":60993927,"Users Score":1,"Answer":"(Spyder maintainer here) You can restore the tab bar in our editor by going to the menu\nTools > Preferences > Editor > Display\nand selecting the option called Show tab bar.","Q_Score":1,"Tags":"python,anaconda,spyder","A_Id":60997276,"CreationDate":"2020-04-02T14:27:00.000","Title":"Restore file tabs above main editor in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a executable python script that I want to run using apache. A simple print('hello') works fine, however it fails if the script imports some package. In this case it fails at 'import pandas'. \nI'm using python version 3.5.2\nI have installed pandas with pip3 install pandas, and the installation is successful. If I try again, I get:\nRequirement already satisfied: six>=1.5 in \/usr\/lib\/python3\/dist-packages (from python-dateutil>=2.5.0->pandas) (1.10.0)\nI have tried to start the script with both #! \/usr\/bin\/python and #! \/usr\/bin\/env python\nWhy could it be that it doesn't work? Is there some sort of step by step guide to manage this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":224,"Q_Id":60994419,"Users Score":1,"Answer":"These two optiones worked for me:\nsudo apt-get install python3-pandas\nor\nsudo -H python3 -m pip install pandas","Q_Score":1,"Tags":"python,apache,server","A_Id":61014094,"CreationDate":"2020-04-02T14:50:00.000","Title":"Python\/Apache\/Server - Can't import modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Jenkins setup is on Ubuntu.\nLocal: Created a virtual environment using python 3.6, running tests through command line using pythom -m pytest - .\/{test.py} which is successful\nJenkins job:\nIn the Build > Shell script, creating a virtual environment the same way done locally and running the commands.\npython3.6 -m venv jenkins-venv\nsource ${WORKSPACE}\/jenkins-venv\/bin\/activate \npip install --no-cache-dir -r ${WORKSPACE}\/project\/requirements.txt\npython -m pytest -v ${WORKSPACE}\/project\/test_day1.py \nError:\n ERROR collecting scripts\/\nImportError while importing test module '\/var\/lib\/jenkins\/workspace\/job_name\/project\/test_Login.py'.\nHint: make sure your test modules\/packages have valid Python names.\nModuleNotFoundError: No module named","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":619,"Q_Id":60994459,"Users Score":0,"Answer":"This happens if your PATH variable includes that module's directory on your machine but not on Jenkins.","Q_Score":0,"Tags":"python,jenkins","A_Id":60994553,"CreationDate":"2020-04-02T14:52:00.000","Title":"Python tests run locally on ubuntu but fails when run through Jenkins with error \"ImportError while importing test module '\/var\/lib\/jenkins\/workspace\"","Data Science and Machine Learning":0,"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 get the instance of a parent widget from within the child widget in kivy? This is so that I can remove the child widget from within the child widget class from the parent widget.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":60994891,"Users Score":0,"Answer":"use parent.<attribute> or root.ids.<id-of-the-widget-you-need>","Q_Score":0,"Tags":"python,widget,kivy,instance","A_Id":60995063,"CreationDate":"2020-04-02T15:13:00.000","Title":"In a child widget, how do I get the instance of a parent widget in kivy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My debugging is setup in VS code, I can hit break points in the file I'm running via the launch.json config, but I can't get breakpoints in packages that are installed with PIP. How do I get breakpoints in these package files?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1038,"Q_Id":60995830,"Users Score":4,"Answer":"If you know where you python installation is on your computer do this:\n\nKnow where you python packets were installed.\nFile -> add folder to workspace\nAdd the breakpoints where necessary.\n\nAs an alternative i would advise to create a virtual environment and do the same thing but with the safety of virtual environment. Hope that helps.","Q_Score":5,"Tags":"python,visual-studio-code","A_Id":60996004,"CreationDate":"2020-04-02T15:57:00.000","Title":"Debug Python code thats in a PIP package in VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the process of writing code using python and pandas, I have opened many dataframes to inspect their contents by double clicking on their object names in the variable explorer. I was wondering if there is an option to \"Close all\", instead of \"X\"-ing out of each one individually.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":60997610,"Users Score":1,"Answer":"(Spyder maintainer here) Unfortunately this is not possible at the moment, sorry.","Q_Score":0,"Tags":"python,spyder","A_Id":61031282,"CreationDate":"2020-04-02T17:34:00.000","Title":"How can I close all dataframes that I've opened using the variable explorer?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Very New to this but I would essentially like to read my counter value from my CLICK PLC into my python.\nMy Click Series PLC only has a RS232 Port with Modbus protocal . Can I use pymodbus for this?\nIs there another way to do this?\nAny help would be greatly appreciated","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":295,"Q_Id":61001472,"Users Score":0,"Answer":"After more research. yes it is possible to use pymodbus.\nRS 232 is an older serial communication protocol that can use Modbus ASCII and Modbus RTU software protocols(Binary).\npymodbus supports both these .\nYou just need to direct pymodbus to the com port your \"Slave devices\" are connected \/ daisy-chained to.\nremember there can only be one master to 247 nodes.","Q_Score":0,"Tags":"python,serial-port,modbus,plc,pymodbus","A_Id":61019632,"CreationDate":"2020-04-02T21:30:00.000","Title":"Read Counter value From CLICK PLC to python using pymodbus with RS232 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":0,"Web Development":0},{"Question":"In Python, when you write x=10, it reserves a memory location and essentially stores 10, right?  Then, if you write x=20 will 20 replace the value of 10 (like C\/C++ does) or will it write 20 to a new memory location and consider the old 10 as garbage?\nThanks in advance ;)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":61001711,"Users Score":0,"Answer":"You don't know. The Python Language Specification does not talk about things like \"memory location\" or \"address\".\nIt simply specifies the semantics of the code. Implementors are free to implement those semantics however they may wish.\nFor GraalPython, for example, I would guess that the compiler would completely optimize away the variable.","Q_Score":1,"Tags":"python,memory-management","A_Id":61001770,"CreationDate":"2020-04-02T21:46:00.000","Title":"Will making a new assignment for a variable in Python will change the old address of the variable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a 3D grid for representing shapes\/meshes which is represented in python using an ndarray(20,20,20) of type bool. Each element in the grid represents the presence or absence of material. I want to be able to check if a given grid represents a shape that is connected all the way from the top of the grid to the bottom. I want to be able to discard those that are either disconnected or not occupying continuous series of cells from top of the grid to the bottom. \nAt a later stage I convert the grids into meshes using trimesh. Is there any way to identify the above either directly in python or through trimesh?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":61002532,"Users Score":0,"Answer":"I'd first write a helper function bucket_fill_2d() that takes a slice with material info and, given a starting index (i,j), bucket fills the material like in any old drawing program.\n\nIntroduce an empty Boolean array connected of the shape. \nSet the bottom slice True wherever the material array's bottom slice is True.\nThen go up one step up and bucket_fill_2d(), starting with every connected (i,j) from the previous step.\nRepeat (3) until you reach the top.\nCheck if anything is connected at the top slice.\n\nNote that trimesh, as the name suggests, only supports triangular cells.","Q_Score":0,"Tags":"python,mesh,voxel,trimesh","A_Id":61014997,"CreationDate":"2020-04-02T23:00:00.000","Title":"Check if 3D grid is filled from top to bottom","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have set the interpreter to 3.8.2 but when I type in the console python --version it gives me the python 2.7.2. Why is that and how to change the console version so I can run my files with Python 3? In windows console I have of course python 3 when I type the --version.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":61003057,"Users Score":0,"Answer":"(Assuming you use Visual Studio Code with the Python Extension)\nThe interpreter set in visual studio has nothing to do with the terminal python version when you run python --version.  \npython --version is bound to what python version is bound to 'python' in your environment variables. \nTry python3 --version in the visual studio console to see what version is bound to python3.\nIf this is the right version, use python3 in the visual studio console from now on.","Q_Score":0,"Tags":"python,visual-studio,console,interpreter","A_Id":61003131,"CreationDate":"2020-04-02T23:53:00.000","Title":"Python version in Visual Studio console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have set the interpreter to 3.8.2 but when I type in the console python --version it gives me the python 2.7.2. Why is that and how to change the console version so I can run my files with Python 3? In windows console I have of course python 3 when I type the --version.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":86,"Q_Id":61003057,"Users Score":1,"Answer":"The console displayed by VSCode is basically an ordinary terminal. When you run the python file from VSCode using the green arrow at the top, it will call the appropriate python version displayed at the bottom of the VSCode window. You can also see what VSCode executes in the terminal seeing to which python its pointing to.","Q_Score":0,"Tags":"python,visual-studio,console,interpreter","A_Id":61003306,"CreationDate":"2020-04-02T23:53:00.000","Title":"Python version in Visual Studio console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"df=pd.read_excel(filename)\nWhat attributes should I add to exclude header and footer?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":7545,"Q_Id":61004648,"Users Score":7,"Answer":"Head over here: https:\/\/pandas.pydata.org\/pandas-docs\/stable\/reference\/api\/pandas.read_excel.html\nyou will find\npandas.read_excel(io, sheet_name=0, header=0, names=None, index_col=None, usecols=None, squeeze=False, dtype=None, engine=None, converters=None, true_values=None, false_values=None, skiprows=None, nrows=None, na_values=None, keep_default_na=True, verbose=False, parse_dates=False, date_parser=None, thousands=None, comment=None, skipfooter=0, convert_float=True, mangle_dupe_cols=True, **kwds)\nOut of which ones which are useful to you are:\npandas.read_excel(skiprows=None, skipfooter=0)\nyou can specify the value in integer to skiprows=1 to skip header and skipfooter=1 to skip footer you can add as many rows are you want to skip\nHope it helps","Q_Score":2,"Tags":"python-3.x,pandas","A_Id":61005552,"CreationDate":"2020-04-03T03:25:00.000","Title":"How do I exclude header and footer from an excel file in pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"df=pd.read_excel(filename)\nWhat attributes should I add to exclude header and footer?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7545,"Q_Id":61004648,"Users Score":0,"Answer":"you should create a sun dataframe from previous data frame which doesn't contain the header and footer attribute.\nfor example,\nif you excel file contains 500 rows, in which first three rows are header and last 10 rows are footers then you can do as below:\ndf = df[4:491]","Q_Score":2,"Tags":"python-3.x,pandas","A_Id":63516219,"CreationDate":"2020-04-03T03:25:00.000","Title":"How do I exclude header and footer from an excel file in pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a complete application intended to be compiled to .exe (via Py2EXE). I would love to use the DAO object for working with an Access database. I would like to have as little dependencies as possible (for the user - no office install, etc).\nMost of the sources I have reviewed claim that the bitness of the Engine\/Driver\/Office Installation, must all align. This confuses me as to what the user will require on their machine if i compile my working code. \nWill they just need Access Run-time for the bitness of the engine I develop the app in?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":162,"Q_Id":61005720,"Users Score":0,"Answer":"I wouldn't recommend Acess with Python.\nPython and Access are two completely different \"worlds\", Python does have the necessary drivers to \"speak\" to Access but is not a good match especially when it has built in support for SQLite and i reckon far better support for other Database engines.\nI am an Access expert and i do Python but i wouldn't mix them unless its for convenience like using the report engine of Access.","Q_Score":0,"Tags":"python,windows,ms-access,dao","A_Id":61059022,"CreationDate":"2020-04-03T05:43:00.000","Title":"What is the easiest way to use DAO Engine (Access) in Python for a complete application?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"While i run python script to scrape new data and add to database then mysql server is down.\nAny Suggestion","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":61005885,"Users Score":0,"Answer":"I think need more information to solve this for example sql log.\nIn my opinion, your statement is insert a huge data and server has not a correct configuration or your query should be split to solve this issue.","Q_Score":0,"Tags":"mysql,python-3.x","A_Id":61008408,"CreationDate":"2020-04-03T05:58:00.000","Title":"Mysql Server is down When Python Script is run","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to open a .dat file using f1= open('rec_1.dat') I get <_io.TextIOWrapper name='rec_1.dat' mode='r' encoding='cp1252'>. I then change the instruction to f1= open('rec_1.dat', encoding = 'cp1252) and I get the following error 'charmap' codec can't decode byte 0x81 in position 1396: character maps to .\nIf I change the encoding to 'ISO-8859-1' I can then use file_contents = f1.read() But I get complete garbage like \u00ef\u00ff\u00e9\u00ff\u00f0\u00ff\u00e9\u00ff\u00f2\u00ff\u00e8\u00ff\u00f1\u00ff\u00e8\u00ff\u00ed\u00ff\u00e8\u00ff and so on. Is there anything I'm missing?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":488,"Q_Id":61006629,"Users Score":0,"Answer":"The file in question is not using the\u00a0CP1252\u00a0encoding. It's using another encoding. Which one you have to figure out yourself.\nOpen the file in Notepad++ if you are using that editor. In the bottom right it will tell you the current file encoding. In the top menu, next to \"View\" locate \"Encoding\". In \"Encoding\" go to \"character sets\" and there look for the encoding that you need.","Q_Score":1,"Tags":"python","A_Id":61006709,"CreationDate":"2020-04-03T07:02:00.000","Title":"How to read the _io.TextIOWrapper data?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've built a couple threaded server projects with Python, and synchronization is always an annoying worry to address.\nOften times when work is passed from thread to another there is a need to find associated objects and information from data structures that are accessed from multiple threads. Synchronization with locks etc is the canonical approach but it is often hard to have any certainty that your synchronization is in fact accurate. This could be circumvented by carrying associated objects along the processing pipeline even where they are not needed. \nAs these are usually object references, how much would it increase overhead? By all logic it shouldn't really, so is this a common practice?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":61007488,"Users Score":0,"Answer":"This question would be easier to answer with more context. But in general, there's no appreciable time cost to passing a few object references in the job payload. The amount of memory overhead associated with each OS thread is probably greater than all of the memory consumed by thread-local references. The main risk is that holding needless references will prevent garbage collection from occurring, but this would also happen if you stored these objects in a global data structure.\n\nSynchronization with locks etc is the canonical approach but it is often hard to have any certainty that your synchronization is in fact accurate.\n\nMaking sure a single data structure is free from data races is usually easy with locks. You just need to wrap every read and write operation with a lock-unlock call. Though this will decrease performance under contention, which will make thread-local storage even faster in comparison.\nAs long as you aren't making deep copies of huge data structures for every single thread, you'll be fine. Keeping job context in thread-local storage where it can be accessed without contention against other threads is usually encouraged.","Q_Score":0,"Tags":"python,multithreading,asynchronous","A_Id":61007895,"CreationDate":"2020-04-03T08:04:00.000","Title":"Python argument passing overhead and object reference","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"slides=prs1.slides\n    for slide in prs1.slides:\n        ImageData.insert(1, \"Slide \"+str(slides.index(slide)+1))\n        TextData.insert(1, \"Slide \"+str(slides.index(slide)+1))\n        for shape in slide.shapes:\n            if 'Picture' in shape.name:\n                write_image(shape, ImageData)\n            elif shape.has_table:\n                table_data(shape, TextData)\n            elif shape.has_text_frame:\n                s=\"\"\n                for paragraph in shape.text_frame.paragraphs:\n                    for run in paragraph.runs:\n                        s+= \" \"+run.text\n                TextData.append(s)\n            elif shape.shape_type == MSO_SHAPE_TYPE.GROUP:\n                group_data(shape, ImageData, TextData)\n\ndef group_data(group_shape, ImageData, TextData):\n    #for group_shape in group_shapes:\n    for shape in group_shape.shapes:\n        if 'Picture' in shape.name:\n            if (ImageData == []):\n                ImageData.append(\"Slide \"+str(slides.index(slide)+1))\n            write_image(shape, ImageData)\n        elif shape.has_table:\n            TextData.append(\"Slide \"+str(slides.index(slide)+1))\n            table_data(shape, TextData)\n        elif shape.has_text_frame:\n            if (TextData == []):\n                TextData.append(\"Slide \"+str(slides.index(slide)+1))\n            s=\"\"\n            for paragraph in shape.text_frame.paragraphs:\n                for run in paragraph.runs:\n                    s+= \" \"+run.text\n                    TextData.append(s)\n        elif shape.shape_type == MSO_SHAPE_TYPE.GROUP:\n            group_data(shape, ImageData, TextData)\nI'm not able to read SmartArt data from slides. This is the above code through which i'm able to get 80% of pptx file data. I want to fetch 100% data and store it in a csv file. Even i want to save ppt file as pptx file using python code.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":449,"Q_Id":61013161,"Users Score":1,"Answer":"python-pptx has no API-support for SmartArt. The schema and semantics for the XML of SmartArt are unpublished (the last time I went looking) so it's not likely to be added anytime soon.\nIf you want to interpret SmartArt objects you'll have to dig into the XML yourself and do the best you can.\nLike a chart or a table, SmartArt is enclosed in a GraphicFrame shape. Like a chart, its contents are stored as a separate part.\nNot really an answer, but at least some background to get you started. I recommend you look for an alternative because this direction is going to be a lot of frustrating work that probably ends up in brittle code because you're reverse-engineering rather that working from a spec.","Q_Score":0,"Tags":"python-pptx","A_Id":61016223,"CreationDate":"2020-04-03T13:36:00.000","Title":"How to read PowerPoint SmartArt Data using python ? Python-PPTX","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wrote a simple Python program 'guessing_game.py'. When I try to run this code in the command prompt using python -m guessing_game.py, the program runs fine, but in the end, it says:\n\nError while finding module specification for 'guessing_game.py'\n(ModuleNotFoundError: path attribute not found on 'guessing_game'\nwhile trying to find 'guessing_game.py').\n\nWhen I run the same program using python -guessing_game.py, it runs fine, and it doesn't show that message as well.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1791,"Q_Id":61013491,"Users Score":1,"Answer":"Because you're trying to run it as a module?\n\n-m  Search sys.path for the named module and execute its contents as the main module.\nSince the argument is a module name, you must not give a file\n  extension (.py). The module-name should be a valid Python module name,\n  but the implementation may not always enforce this (e.g. it may allow\n  you to use a name that includes a hyphen).","Q_Score":0,"Tags":"python,modulenotfounderror","A_Id":61013537,"CreationDate":"2020-04-03T13:55:00.000","Title":"ModuleNotFoundError: __path__ attribute not found on 'guessing_game' while trying to find 'guessing_game.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":"My application records status changes in discord. (Online, offline, idle and DND) This is achieved using discord.py and an SQL server (MariaDB).\nSpecifically, if I receive hundreds of of status updates per second (all with the same Unix timestamp since they happened within a second of each other), should I Store each Unix timestamp in a separate table with an ID for each?\nI am asking this question in hopes of saving disk space in the long run.\nMy hypothesis is that if a smaller number is stored with less digits (the ID that points to a timestamp), it would take up less space as the large Unix timestamp wouldn't need to be repeated hundreds of times.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":61014008,"Users Score":2,"Answer":"A few questions\/remarks are raised by your post...\n\nDo you really need to store timestamps with up-to-the-second accuracy ? SToring with a bigger interval would mean less space usage.\nYou could use a smaller int to store timestamps with an epoch closer to the present, so you could use less space overall, without needing a new table.\nYou should maybe consider dropping events that happen too frequently. If a user change status 10 times in a minute, maybe it's not worth it recording them all ?\nFinaly, an enum (smallint) and a timestamp is not that big in a database. They can usualy handle thousand of gigabytes \"just fine\"","Q_Score":3,"Tags":"python,python-3.x,database,mariadb,diskspace","A_Id":61014524,"CreationDate":"2020-04-03T14:22:00.000","Title":"Should I Store Unix Time In A Separate Table","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While solving competitive programming questions, sometimes it is asked to compute the final answer as \n\" Since this number may be large, compute it modulo 1,000,000,007 (10^9+7) \".\nAlso, it is the fact that in python3 plain int type is unbounded.\nSo, it is necessary to compute modulo 10^9+7 if I am solving my programming question in python 3 ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":61014336,"Users Score":0,"Answer":"It doesn't matter what anyone here believes is fair or warranted. What matters is what the automated system or human in charge expects as an answer.\nOf course, since doing modular operations can slow down a possible solution within a given time frame, it would be best to find an optimum alternative, if permitted.","Q_Score":0,"Tags":"python-3.6,modulo","A_Id":61016225,"CreationDate":"2020-04-03T14:40:00.000","Title":"Is it necessary to compute modulo 1,000,000,007 (10^9+7) in python3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm still trying to migrate an old app from wx2.8 to wx4.\nAfter several different styling adjustments, i got a very similar app under normal conditions (we want to support wx28 and wx4 until we're done, but we currently only have to change the imports).\nWe also have to support the 125% windows GUI scaling, though. And with these settings, components with a \"defaultSize\" (i.e. (-1,-1) ) do get very different scalings between the two versions, especially in the y directions.\nUnfortunately, this destroys our layout (sadly, a wild mix between fixed size and default size components).\nIs ther any way to set the behavior on different Window scalings? I know that one can get the scaling by checking ScreenDC.GetPPI, but i hesitate to change every component separately and would rather like some kind ob global setting. \nSo, is there a way to change the defaultSize behavior globally? Or is there at least some kind of reference about what changed, so i won't miss anything?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":61014878,"Users Score":0,"Answer":"Usually the best thing to do is to always use sizers for layout, and when you do need to specify specific values for size and position, then use values based on font sizes. To help with this there are the wx.Window.GetCharWidth and GetCharHeight methods. \nThere is also the concept of \"Dialog Units\", where each unit is a fraction of the average character sizes. See wx.Window methods ConvertDialogToPixels and ConvertPixelsToDialog.","Q_Score":0,"Tags":"wxpython","A_Id":61377260,"CreationDate":"2020-04-03T15:08:00.000","Title":"wxPython 2.8 to wxPython 4 - default size difference","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing an ReactionRoles-Discord-Bot in Python (discord.py).\nThis Bot saves the ReactionRoles-Smileys as UFT8-Encoded. \nThe type of the encoded is bytes but it's converted to str to save it.\nThe string looks something like \"b'\\\\xf0\\\\x9f\\\\x98\\\\x82'\".\nI am using EMOJI_ENCODED = str(EMOJI.encode('utf8')) to encode it, but bytes(EMOJI_ENCODED).decode('utf8') isn't working.\nDo you know how to decode it or how to save it in a better way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":387,"Q_Id":61015025,"Users Score":0,"Answer":"The output of str() is a Unicode string.  EMOJI is a Unicode string.  str(EMOJI.encode('utf8')) just makes a mangled Unicode string.\nThe purpose of encoding is to make a byte string that can be saved to a file\/database\/socket.  Simply do b = EMOJI.encode() (default is UTF-8) to get a byte string and s = b.decode() to get the Unicode string back.","Q_Score":0,"Tags":"utf-8,python-3.7,discord.py,decoding","A_Id":61015149,"CreationDate":"2020-04-03T15:17:00.000","Title":"Print an UTF8-encoded smiley","Data Science and Machine Learning":0,"Database and SQL":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 my Django server via 'python manage.py runserver' on a github repository i cloned and always get this runtime error message:\n\nclass AbstractBaseUser(models.Model):\nRuntimeError: ____class____ not set defining 'AbstractBaseUser' as <'class 'django.contrib.auth.base_user.AbstractBaseUser'>. Was ____classcell____ propagated to type.____new____?\n\nDetails of installed packages in my virtual environment are:\nDjango               1.9 |\ndjango-crispy-forms  1.6.0 |\ndjango-markdown-deux 1.0.5 |\ndjango-pagedown      0.1.1 |\nmarkdown2            2.3.1 |\nolefile              0.46 |\nPillow               7.1.1 |\npip                  19.2.3 |\nsetuptools           41.2.0 |\nI am using python version 3.8.1\nplease does anyone have any suggestions on how to solve this error. Thank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":175,"Q_Id":61017033,"Users Score":0,"Answer":"RuntimeError at \/save\nYou called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to 127.0.0.1:8000\/save\/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.","Q_Score":0,"Tags":"python,django,django-rest-framework","A_Id":71867046,"CreationDate":"2020-04-03T17:12:00.000","Title":"Django Runtime Error while trying to run server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was working on an app with Tkinter and everything was working fine, but after modifying a function (that has nothing to do with the Tkinter environment) all of a sudden I started getting the following error:\nfrom tkinter import *\nImportError: No module named tkinter\nI tried opening another Tkinter file to see if it had something to do with my app, but on the other file, I'm also seeing the same error. So I'm guessing it doesn't have to do with my app. Is there any way that Tkinter uninstalled itself if it was working before? I'm also getting the same error when importing Pandas. It's weird because it was all working before.\nHas anyone encountered this problem before? What could be the problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":245,"Q_Id":61017063,"Users Score":0,"Answer":"No python module can uninstall itself. You can type pip install tkinter again in cmd.","Q_Score":0,"Tags":"python,pandas,tkinter","A_Id":65972771,"CreationDate":"2020-04-03T17:14:00.000","Title":"Can Tkinter \"uninstall\" itself?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have the word india \nMATCHES\n\"india!\" \"india!\" \"india.\" \"india\"\nNON MATCHES \"indian\" \"indiana\"\nBasically, I want to match the string but not when its contained within another string. \nAfter doing some research, I started with \n\nexp = \"(?<!\\S)india(?!\\S)\" \nnum_matches = len(re.findall(exp))\n\nbut that doesn't match the punctuation and I'm not sure where to add that in.","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":885,"Q_Id":61017760,"Users Score":1,"Answer":"Try this\n^india[^a-zA-Z0-9]$\n^ - Regex starts with India\n[^a-zA-Z0-9] - not a-z, A-Z, 0-9\n$ - End Regex","Q_Score":1,"Tags":"python,regex","A_Id":61017961,"CreationDate":"2020-04-03T17:56:00.000","Title":"Regex to match words followed by whitespace or punctuation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to using CloudFormation \/ CDK and am having trouble figuring out to deploy my stacks without error.  Currently I am using the python CDK to create a bucket.  This bucket will hold model files and I need to ensure that the bucket deployed in this stack retains data over time \/ new deployments.  From my initial tests, it seems that if bucket_name is not specified, the CDK will randomly generate a new bucket name on deployment, which is not ideal.  \nHere is the snippet used to create the bucket:\nbucket = aws_s3.Bucket(self, \"smartsearch-bucket\", bucket_name= 'mybucketname')\nThe first time I run cdk deploy, there are no problems and the bucket is created.  The second time I run cdk deploy, I get an error stating that my S3 bucket already exists. What else is needed so that I can redeploy my stack using a predetermined S3 bucket name?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4090,"Q_Id":61021252,"Users Score":1,"Answer":"The S3 bucket names are global, it means that if someone else on a different account has chosen this name, it wont work, you should provide a very unique name for your bucket.","Q_Score":4,"Tags":"python,amazon-web-services,amazon-s3,amazon-cloudformation,aws-cdk","A_Id":70900366,"CreationDate":"2020-04-03T22:18:00.000","Title":"AWS CDK S3 Bucket Creation Error - Bucket_Name already exisits","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I love Colab. There are free TPUs there!\nI also love vim, and use vim mode on Colab editor.\nAnd I also love Vimium, and I simple cannot browse without it.\nThe problem is:\nAlthough the vim editor on Colab is almost good enough, there is no way to navigate the outputs without reaching for the mouse, which defeats all the purpose of vim style edition, really. But if I try to use Vimium on Colab, the Esc and some other keys gets captured and there is no way to use the editor.\nI can unbind some of the keys, but it seems to be no way of unbinding the Esc key, making it impossible to integrate both tools.\nIs there a way to make vimium behave well with colab, or anyway for scrolling the page in a more fluid manner than just jumping from cell to cell expecting your output is not big enough to get out of the screen?\nCheers!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":130,"Q_Id":61022032,"Users Score":1,"Answer":"I came across this question while searching for the solution to the same problem I had myself. This is probably not a complete solution, but as a workaround, I was able to mitigate the problem by excluding <esc> from Vimium keybindings on the Google Colab domain address and reassigning the \"Unfocus current cell\" functionality in Colab from <esc> to another keybinding. You can access the Colab keybindings with Ctrl+M H, and the Vimium keybinding rules can be accessed in the Vimium extension settings.","Q_Score":1,"Tags":"python,vim,jupyter,google-colaboratory,vimium","A_Id":68069723,"CreationDate":"2020-04-03T23:46:00.000","Title":"Vimium and Colab Integration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Please consider a matrix \nA= torch.tensor([[1,2,3,4], [1,2,3,4], [1,2,3,4], [1,2,3,4]] \nand vectors of indexes \nind_1= [0,1] and ind_2= [2,3]. \nIs it possible to access the top-right sub-matrix of the matrix A ([[3,4], [3,4]]) without using any for loops?  Naively using A[ind_1, ind_2] merely returns the elements 3 and 4 (the diagonal of the required sub-matrix).","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":897,"Q_Id":61022347,"Users Score":0,"Answer":"PyTorch tensors support python slicing so you can use A[:2, 2:] to access the first two rows and the last two columns as a 2x2 tensor.","Q_Score":0,"Tags":"python-3.x,pytorch","A_Id":61022568,"CreationDate":"2020-04-04T00:31:00.000","Title":"How can I access a submatrix specified by row and column index vectors from a matrix (2D tensor) in pytorch?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Please consider a matrix \nA= torch.tensor([[1,2,3,4], [1,2,3,4], [1,2,3,4], [1,2,3,4]] \nand vectors of indexes \nind_1= [0,1] and ind_2= [2,3]. \nIs it possible to access the top-right sub-matrix of the matrix A ([[3,4], [3,4]]) without using any for loops?  Naively using A[ind_1, ind_2] merely returns the elements 3 and 4 (the diagonal of the required sub-matrix).","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":897,"Q_Id":61022347,"Users Score":0,"Answer":"WithA[ind_1,:][:,ind_2] you can slice first on the rows, then on the columns. This allows accessing also sub-matrices with non-consecutive indices.","Q_Score":0,"Tags":"python-3.x,pytorch","A_Id":72249080,"CreationDate":"2020-04-04T00:31:00.000","Title":"How can I access a submatrix specified by row and column index vectors from a matrix (2D tensor) in pytorch?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The string is INITIAL.\nINITIAL = '~~~~~~~~~~~'\nI want to replace the 4th value of INITIAL with a '+'. I do this:\nINITIAL.replace(INITIAL[3], '+')\nHowever, this replaces all of the values of INITIAL with '+'. Please help.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":61024548,"Users Score":0,"Answer":"its a little bit annoying, one way of doing it is INITIAL = INITIAL[:3] + \"+\" + INITIAL[4:]","Q_Score":3,"Tags":"python","A_Id":61024582,"CreationDate":"2020-04-04T06:30:00.000","Title":"How to Replace a Character in a Specific Position of a String With Another Character","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am just learning python and have started making a game using pygame.\nIn my game I have a list that contains all of the obstacles that the player must over come in each of the levels. Although this list quickly became very big and has started to take up many lines of my project. \nI was wondering if I should have a dedicated text file that contains this list and import it into my project or if there is a better way of doing this. I know this is a kind of vague questions but I was just wondering if importing a long list into my project could be a good way about going with this problem.\nI really hope someone knows what to do because I am not quite sure and I would really appreciate someone else's opinion on the matter.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":61024759,"Users Score":1,"Answer":"I guess it depends on how many obstacles you got or if you want it to look neat and tidy then yeah. if your not doing obstacles = [obstacle(100,100,24,50), obstacle(100,100,24,50), obstacle(100,100,24,50), obstacle(100,100,24,50), obstacle(100,100,24,50)...] then do that and see if it still looks like a lot. its no better or worse. Completely up to you","Q_Score":0,"Tags":"python,list,pygame","A_Id":61024923,"CreationDate":"2020-04-04T06:56:00.000","Title":"Dealing with long lists of number in pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm collaborating with a group for an assignment we decided to use Django for, however, it seems that if one individual used upercase characters instead of lowercase characters (MyProject vs myproject) for example and therefore I often times get an error indicating\nModuleNotFoundError: No module named 'MyProject'\nI've changed it before & resolved it and then pushed it up to GitHub.. but every so often we encounter the same issue.\nHow can I fix this permanently so that it's no longer an issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":271,"Q_Id":61028354,"Users Score":0,"Answer":"I was able to fix this issue by renaming MyProject to myproject within the settings.py file\nThanks!","Q_Score":0,"Tags":"python,django,github","A_Id":61028512,"CreationDate":"2020-04-04T12:51:00.000","Title":"ModuleNotFoundError: No module named 'MyProject'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"When zip is applied on two lists:\nx = zip([1,2,3,4], [6,7,8,9])\nprint(list(x))\nyields\n[(1, 6), (2, 7), (3, 8), (4, 9)]\nBut when I use sets in zip\nx = zip({1,2,3,4}, {6,7,8,9})\nprint(list(x))\ngives me\n[(1, 8), (2, 9), (3, 6), (4, 7)]\nWhy?\nAnd I also observed\nx = zip({1,2,3,4}, {6,7,8,9}, {12,13,14,15})\nprint(list(x))\ngives me \n[(1, 8, 12), (2, 9, 13), (3, 6, 14), (4, 7, 15)]","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":28,"Q_Id":61028906,"Users Score":2,"Answer":"Sets aren't ordered, so when zip iterates over them it may process its elements in a different order.","Q_Score":0,"Tags":"python,set","A_Id":61028950,"CreationDate":"2020-04-04T13:35:00.000","Title":"Using Zip on set","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 120,000 csv inside my AWS EC2 instance, each containing 120,000 rows. I can't insert each of them as is into my AWS RDS postgresql DB, that will be 120,000^2 = 14,400,000,000 records. Each csv is about 2 MB.\nMy approach is:\n\nPython script that converts 120,000 records into just 1 record (list of dictionary) for each csv (now 5 MB after condensing the data) with the help of pandas library\nThe python script then insert each csv's 1 record into AWS postgresql database via pandas.to_sql (which uses sqlalchemy\nI use python multiprocessing module to fully utilize my AWS EC2 to speed up data insertion\nI did not create additional indexes in order to speed up my data insertion\nI use AWS EC2 instance with up to 25GB of network connection\n\nMy observation is:\n\nAt the beginning, my code will insert 50 csv per min, which is decent speed\nHowever, right now, with 50k csv being inserted, it only insert 1k csv in 5 hours, about 3.33 csv per min\nI tried using psql \\copy and realized that it takes between 30-50 sec to insert 1 csv, that's slower than my script that converts the data and insert into the DB directly\n\nI am not sure how I can speed up things up.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":180,"Q_Id":61028971,"Users Score":2,"Answer":"The reason the database performance drop from 50 to 3.33 csv per min is because of the AWS RDS instance class.\nI am using db.t2.micro class, which I just learnt that it's limited by CPU credits. After I change the instance class to t3, my code is back to 50 csv per min.\n\nAmazon RDS T3 DB instances run in Unlimited mode, which means that you will be charged if your average CPU utilization over a rolling 24-hour period exceeds the baseline of the instance. CPU Credits are charged at $0.075 per vCPU-Hour. The CPU Credit pricing is the same for all T3 instance sizes across all regions and is not covered by Reserved Instances.\n\nConsidering that my code takes <1 sec to execute, and only 1 record to insert each time. pandas.to_sql shouldn't be the bottleneck. Though I do believe using SQLAlchemy will perform better than pandas.to_sql. For the same reason psycopg2 performs better than SQLAlchemy.\nIn short, this is an issue due to hardware rather than software. Fix it by upgrading to a more powerful instance. Thanks.","Q_Score":1,"Tags":"python,database,postgresql,amazon-web-services,multiprocessing","A_Id":61039956,"CreationDate":"2020-04-04T13:40:00.000","Title":"Speed up AWS PostgreSQL insertion via Python script","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im new to regexes. Im having a hard time understanding everything and I wanted to write a not so simple program about e-mails but then decided on barcodes. The barcode is valid if it:\n\nIs surrounded with a \"@\" followed by one or more \"#\"\nIs at least 6  characters long (without the surrounding \"@\" or \"#\")\nStarts with a capital letter\nContains only letters (lower and upper case) and digits\nEnds with a capital letter\n\nI tried a couple of things and achieved absolutely nothing. I even watched a detailed explanation of regexes but still can't come up with anything.\nSample input: @#GoodCodE@# would be valid but @Invalid_CodE@ \/ @#InvalidTry@# would not.\n(@#+)([A-Z][A-Za-z0-9]{4,}[A-Z])(?:@#+) Thank you for all the help! ?= didn't include the @#+ so I replaced it with ?: which does apparently.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":151,"Q_Id":61029167,"Users Score":1,"Answer":"You could use the following expression: ^@#+[A-Z][A-Za-z0-9]{4,}[A-Z]@#+$\nBroken down it means:\n\n^ requires beginning of string (line)\n@ match a @ character\n#+ match one or more of # characters\n[A-Z] match an uppercase letter  (counts as 1st of the 6)\n@[A-Za-z0-9]{4,} match 4 or more of upper\/lowercase letters and digits\n[A-Z] match an uppercase letter  (counts as last of the 6)\n@ match a @ character\n#+ match one or more of # characters\n$ requires end of string (line)","Q_Score":0,"Tags":"python,regex","A_Id":61029360,"CreationDate":"2020-04-04T13:55:00.000","Title":"Regex for validating barcodes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently created an environment in PyCharm using anaconda and i'm using Python version 3.6. I want to import tensorflow but unfortunately i keep getting the error message \"ModuleNotFoundError: No module named 'tensorflow'\". I installed tensorflow versions (1.20 & 1.15) on my environment with no major issues, i also tried and added both in the Project Interpreter window successfully but when i run my program i keep getting that error. Anyone know a good way to fix this?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":325,"Q_Id":61030730,"Users Score":2,"Answer":"If you get this error, you have installed everything in one environment but you work in another. \nTry installing tensorflow from another command line (in another shell).","Q_Score":0,"Tags":"python,tensorflow,pycharm","A_Id":61030822,"CreationDate":"2020-04-04T15:54:00.000","Title":"Installed tensorflow in an anaconda env but cannot import (Tensorflow 1.15, Python 3.6, PyCharm)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to auto-run python script made by me when the system is booted on jetson nano?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4006,"Q_Id":61031032,"Users Score":0,"Answer":"Step 1: Create a shell file.\nsudo nano \/usr\/local\/bin\/startup.sh: Type this on the terminal. A new sh file is created. This file consists of the python file that is to be executed. I gave the name startup.sh. It can be any name XYZ.sh\n#! \/bin\/sh: This is called the shebang. This would execute our script using a Bourne shell. This tells the system that the commands in this file should be fed to the interpreter.\nsleep 10: This pauses a script for a certain amount of time. He re we pause it for 10 seconds.\nIn the next line, we insert the code that we use to run the program on the terminal.\nOPENBLAS_CORETYPE=ARMV8 \/usr\/bin\/python3 path\/of\/the\/python\/code.py\nIt looks like this:\n#! \/bin\/sh\nsleep 10\nOPENBLAS_CORETYPE=ARMV8 \/usr\/bin\/python3 \/home\/sooraj\/Downloads\/incabin-monitoring-system-main\/netstreamfeb17.py\nNow we close the file using Ctrl+X. and save it.\nStep 2: Create a service file\nsudo nano \/etc\/systemd\/system\/startup.service\nThings to write inside it.\n[Unit]\nDescription = INTU_IPC start-uo specific script\n[Service]\nType= idle\nExecStartPre = \/bin\/sleep 10\nExecStart = \/usr\/local\/bin\/startup.sh\nUser=sooraj# write your user name here\n[Install]\nWantedBy = multi-user.target\nNow we close the file using Ctrl+X. and save it.\nstep 3: Give permission.\nsudo chmod +x \/usr\/local\/bin\/startup.sh\nstep 4: enable, start and stop\nsudo systemctl enable startup.service\nsudo systemctl start startup.service\nsudo systemctl stop.service\nAfter starting, to view if it works, we can observe it in the terminal by\njournalctl -u startup.service -f\nIf we edit the service file for the next time, we need to reload it before enabling and starting.\nsudo systemctl daemon-reload\nsudo systemctl enable startup.service\nsudo systemctl start startup.service\nAdditional information.\nsystemctl is-enabled startup.service #checks if the service file is enabled.\nsystemctl is-failed startup.service #checks if the service file failed to start.\nsystemctl is-active startup.service #checks if the service file is active.\nsudo systemctl list-unit-files \u2014 type=service #display the list of service files.","Q_Score":0,"Tags":"python-3.x,nvidia-jetson,startupscript,nvidia-jetson-nano","A_Id":72109493,"CreationDate":"2020-04-04T16:17:00.000","Title":"Auto-run python script when system is booted on jetson nano","Data Science and Machine Learning":0,"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 created a web scraping project in python with the help of beautiful soup but i want my project to work as a desktop application.\nSo, that i can run that application and can perform web scraping on a specific url.\nIs it possible using python and beautiful soup or i have to make the project in different language?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":757,"Q_Id":61031816,"Users Score":0,"Answer":"I highly suggest using ElectronJS (check out electronjs.org). \nIf you are proficient enough in HTML\/CSS and some Javascript, you can use those markup languages to easily create a UI (which you would do on a normal website), which would look much better than any interface made using Python GUI libraries (such as tkinter, pygame etc.). \nThe Electron app itself is a browser but it works as a desktop application. It is also cross-platform.","Q_Score":0,"Tags":"python,web-scraping,beautifulsoup","A_Id":61032465,"CreationDate":"2020-04-04T17:13:00.000","Title":"How to convert web scraping python project into desktop application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i have created a web scraping project in python with the help of beautiful soup but i want my project to work as a desktop application.\nSo, that i can run that application and can perform web scraping on a specific url.\nIs it possible using python and beautiful soup or i have to make the project in different language?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":757,"Q_Id":61031816,"Users Score":0,"Answer":"If your intention is how to turn it into an executable you can download pyinstaller.\nIf you want to build a GUI you have a few options:\n\nUse a python module like: pygame, tkinter, PyQt5, wxPython, BeeWare.\nUse an JavaScript framework like electron.js.\nMake a Web-App and use python as a back end with a framework like Flask or Django.","Q_Score":0,"Tags":"python,web-scraping,beautifulsoup","A_Id":61032223,"CreationDate":"2020-04-04T17:13:00.000","Title":"How to convert web scraping python project into desktop application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've seen a lot of other questions here about this topic however none have helped. I am coding on Jupyter Notebook using Python 3, to organize my code I am trying to use 2 different modules for my program. Thus I have 1 module called let's for simplicity call it abc.ipynb and now created a different module called for simplicity edf.ipynb (Both on Jupyter Notebook) \nAt first i wasn't able to import abc to edf but after importing the import_ipynb package and fixing the PYTHONPATH it worked. \nHowever, now I just want to import variables from abc to edf, I am trying:\n\nfrom abc import x\nimport abc        print(abc.x)\nI even tried calling a function\n\nAll give 1 of below errors:\n\ncannot import name 'x' from 'abc'\nmodule 'abc' has no attribute 'function'\n\nAny advice? I already created an init.py in my folder however I think it is of no use since I am working with .ipynb","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":870,"Q_Id":61032792,"Users Score":2,"Answer":"Try changing the name of the file other than \"abc\". Python already has a module called abc","Q_Score":2,"Tags":"python,jupyter-notebook","A_Id":61035073,"CreationDate":"2020-04-04T18:23:00.000","Title":"How to import variables from other .ipynb on Jupyter Notebook?","Data 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":"Cannot find anything in the documentation about this.\nGiven the following conditional example:\nif val == 2 or val == 10 or val == 11: ....\nIs there a way to condense this statement without repeating val == ?\nIs there something along the lines of : \nif val == 2 or 10 or 11: ....\nWould this be the same time complexity as the original? : if val in [2,10,11]","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":61033196,"Users Score":0,"Answer":"The variant with the in operator (if val in [2, 10, 11]) is as condensed as you'll get. It has the same time complexity as a series of == operators.","Q_Score":1,"Tags":"python-3.x,conditional-statements","A_Id":61033224,"CreationDate":"2020-04-04T18:52:00.000","Title":"Is there a way to do a condensed conditional statement in python 3.6?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running Spyder 4.0.1 (installed via Anaconda) on Max OS and I have an issue with the keyboard shortcuts.\nI customized some of the shortcuts for the editor (e.g. \"cmd + ->\" for \"skip to end of line\") and they work nicely in the editor window. But the same shortcuts don't work in the command window (there the shortcut is \"fn + ->\"). \nIs there any way to customize the shortcuts for the command window?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":100,"Q_Id":61033551,"Users Score":2,"Answer":"(Spyder maintainer here) The shortcuts in the IPython console are not configurable at the moment, sorry.","Q_Score":0,"Tags":"python,keyboard-shortcuts,spyder","A_Id":61036052,"CreationDate":"2020-04-04T19:21:00.000","Title":"Editor keyboard shortcuts in Spyder don't work in command window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a python project that uses pipenv  I now want to create a second project and reuse that pipfile from the first project, such that the pipfile of the second project is initialised with the pipfile of the first project. The pipfiles of the two projects may diverge. \nI have looked at the pipenv help menus for install and update, and googled about for documentation and answers. \nIt isn't clear how to import the pipfile. There is a reference to importing a requirements.txt , but I would expect that I wouldn't' have to export the pipfile to a requirements.txt from one project and then import that file into the second project.\nHow do I import it that pipfile when creating the pipfile for the second project ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":537,"Q_Id":61036050,"Users Score":0,"Answer":"Just open a terminal in your new project directory, and if it already has a pipfile just type pipenv install\nIf there's no pipfile.lock present a new one will be created with all dependencies, if there is, the pipenv install will use that instead to install all packages.\nIf you want to also install dev packages, just type pipenv install --dev instead","Q_Score":3,"Tags":"python,pipenv","A_Id":66199882,"CreationDate":"2020-04-04T23:20:00.000","Title":"Create new pipenv project with imported pipfile","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project, which requires me to build a UI for a search engine. Elasticsearch is my choice. After indexing data and doing search queries, I also implement a function so that, if the user ticks on a result that is not relevant, I will reduce the score of that specific data in elasticsearch. However, when doing the second search with the same query, the order of search results remained the same. The reason is that even though the score is updated, the order of the data in elasticsearch index remained unchanged.\nHow do I reflect the score changes without having to reindex the whole thing again?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":162,"Q_Id":61036904,"Users Score":0,"Answer":"You could add a bool \/ should query. There you perform a term query with a boosting.\nThis is how you change the order depending on the search.","Q_Score":1,"Tags":"python,elasticsearch,scoring,relevance","A_Id":61065640,"CreationDate":"2020-04-05T01:21:00.000","Title":"Update Score based on interactive feedback for Elasticsearch","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I heard from one guy that you should not use magic methods directly. and I think in some use cases I would have to use magic methods directly. So experienced devs, should I use python magic methods directly?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":582,"Q_Id":61038373,"Users Score":1,"Answer":"No you shouldn't.\nit's ok to be used in quick code problems like in hackerrank but not in production code. when I asked this question I used them as first class functions. what I mean is, I used xlen = x.__mod__ instead of xlen = lamda y: x % y which was more convenient. it's ok to use these kinda snippets in simple programs but not in any other case.","Q_Score":7,"Tags":"python,magic-methods","A_Id":64906265,"CreationDate":"2020-04-05T05:16:00.000","Title":"Should I use python magic methods directly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As raw data we have measurements m_{i,j}, measured every 30 seconds (i=0, 30, 60, 90,...720,..) for every subject j in the dataset.\nI wish use TSFRESH (package) to extract time-series features, such that for a point of interest at time i, features are calculated based on symmetric rolling window. \nWe wish to calculate the feature vector of time point i,j based on measurements of 3 hours of context before i and 3 hours after i. \nThus, the 721-dim feature vector represents a point of interest surrounded by 6 hours \u201ccontext\u201d, i.e. 360  measurements before and 360 measurements after the point of interest.\nFor every point of interest, features should be extracted based on 721 measurements of m_{i,j}.\nI've tried using rolling_direction param in roll_time_series(), but the only options are either roll backwards or forwards in \u201ctime\u201d - I'm looking for a way to include both \"past\" and \"future\" data in features calculation.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":995,"Q_Id":61041024,"Users Score":1,"Answer":"If I understand your idea correctly, it is even possible to do this with only one-sided rolling. Let's try with one example:\nYou want to predict for the time 8:00 - and you need for this the data from 5:00 until 11:00.\n If you roll through the data with a size of 6h and positive rolling direction, you will end up with a dataset, which also includes exactly this part of the data (5:00 to 11:00). Normally, it would be used to train for the value at 11:00 (or 12:00) - but nothing prevents you to use it for predicting the value at 8:00.\nBasically, it is just a matter of re-indexing.\n(Same is actually true for negative rolling direction)","Q_Score":0,"Tags":"python,pandas,time-series,feature-extraction,tsfresh","A_Id":61195646,"CreationDate":"2020-04-05T10:15:00.000","Title":"TSFRESH - features extracted by a symmetric sliding window","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying some question task was to find the number of times a substring appears in a given string.\nGiven string was \"ABCDCDC\" and substring \"CDC\"\nI used the .count() method for string with gives me answer 1, which is wrong. So Please let me know the reason.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":61042066,"Users Score":0,"Answer":"But if the example is \"ABCDCDC\" , then count is right... if you search for \"CDC\" explicitly.\n\"AB cdc DC\" so CDC is just once in a string.","Q_Score":0,"Tags":"python-3.x,string,methods","A_Id":61042116,"CreationDate":"2020-04-05T11:45:00.000","Title":"Trying to undertsand .count() method in Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to set up a Windows 64-bit PC Virtual Environment with Python 2.7 to run a script that I didn't write, \nand I'm not entirely sure the usage it has, but it imports pythoncom (a .NET communication module as far as I could understand). \nIt seems that the module exists in pywin32 and pypiwin32 (installed both),\nI can see the module is installed in the environment when typing \"pydoc modules\" and \"pydoc pythoncom\", but it still fails to import the module when running the script.\nI can only use pywin32-244,\nit has a .dll named pythoncom27.dll inside its wheel file,\nI can't seem to find a workaround, \nanyone knows why it might happen?\n(all of the versions I gave are not optional (for python, the package) - I cannot change them they has to remain the same)\nFurthermore - In newer versions of python3.x it's running fine. \nfrom the python CommandLine I can actually import it! \nany reason for me to be able to import it and see it in all of the mentioned ways and still not to be able to import it via a script? maybe something wrong with the script or the way im running it?\nAlso might be important - the script that gives the error is just imported through another script,\nso I'm actually running T1.py which then imports T2.py which gives the error when trying to import pythoncom...\nThanks in Advance!\nOren","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":61043139,"Users Score":0,"Answer":"The problem was that I wasn't using the virtualenv to run the script,\nafter activating the virtualenv, typing in the cli \"script.py\"\nwill execture the script from the system's default python env, even though it says (Venv) in the cli,\nTo run it in the Venv's python environment you need to type in 'python script.py'\nOren","Q_Score":0,"Tags":"python,import,module,pythoncom","A_Id":61058034,"CreationDate":"2020-04-05T13:11:00.000","Title":"pythoncom module not found (pywin32 is installed) - with a Python2.7 virtual 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question related to the data.describe() method in pandas. It gives you the relevant descriptive statistics of your dataset such as standard deviation. How does it tell if your data is from a population or a sample?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":61043180,"Users Score":0,"Answer":"As far as I know, the .describe() method gives you always the stats for your specific sample (drawn in the dataframe). It doesn't make inference about the population","Q_Score":0,"Tags":"python,pandas,python-2.7,dataframe,statistics","A_Id":61043236,"CreationDate":"2020-04-05T13:14:00.000","Title":"How does the data.describe() method in pandas differentiate between population and sample data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to sum the elements in my list with a certain condition.\nFor example;\nmyList = [1,8,12,17,3,26,5]\nI would like to sum numbers greater than or equal to 10   in this list.\noutput: 55\nsum(myList> = 10) I tried this function but it didn't work\nHow can I solve this problem?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2571,"Q_Id":61043794,"Users Score":0,"Answer":"initialize a variable with zero and sot you list with the given condition and add the sorted number in the variable\nyou can simply us\n\nmyList = [1,8,12,17,3,26,5]\na=0\nfor i in myList:\n    if i<=10:\n       a+=i\nprint(a)\nOut will be 17","Q_Score":0,"Tags":"python,arrays,list,sum","A_Id":61043890,"CreationDate":"2020-04-05T14:00:00.000","Title":"Python sum of elements in list greater than any number","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to understand what kind of image preprocessing is required when using one of the base networks provided by keras.application whith tensorflow compat.v1 module\nIn particular, I'm interested about the functions that converts each pixel channel value in the range [-1,1] or similar. I have digged in the code and it seems Tensorflow relies on Keras which, on other hand, should have 3 differents functions: one for tf, one for caffe and the last for torch, meaning not specific ones for each base network\nUp until now I have just re-implemented the function for tensorflow (value = value\/127.5 - 1) but I also read about others discussing something else (e.g. value = value\/255), nothing \"official\" tho. I have started to have some doubts regarding what I'm doing because, after switching to ResNet50, I can't seem to obtain decent results in contrast to several papers I'm following. I would like to have a definitive idea about the topic, any help would be much appreciated","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":61047716,"Users Score":0,"Answer":"Tensorflow provides the preprocessing function for models in keras.applications, called preprocess_input. For example, an image can be preprocessed for InceptionV3 using tf.keras.applications.inception_v3.preprocess_input.","Q_Score":0,"Tags":"python,tensorflow,tf.keras","A_Id":61049604,"CreationDate":"2020-04-05T18:46:00.000","Title":"Does Tensorflow use specific image preprocessing normalization for each keras.application network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"is there any pretrained vector for particular topic only? for example \"java\", so i want vectors related java in file. mean if i give input inheritance then cosine similarity show me polymorphism and other related stuff only! \ni am using corpus as GoogleNews-vectors-negative300.bin and Glove vectors. still not getting related words.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":320,"Q_Id":61048035,"Users Score":0,"Answer":"Yes, you can occasionally find other groups' pre-trained vectors for download, which may have better coverage of whatever problem domains they've been trained on: both more specialized words, and word-vectors matching the word sense in that domain. \nFor example, the GoogleNews word-vectors were trained on news articles circa 2012, so its vector for 'Java' may be dominated by stories of the Java island of Indosnesia as much as the programming language. And many other vector-sets are trained on Wikipedia text, which will be dominated by usages in that particular reference-style of writing. But there could be other sets that better emphasize the word-senses you need. \nHowever, the best approach is often to train your own word-vectors, from a training corpus that closely matches the topics\/documents you are concerned about. Then, the word-vectors are well-tuned to your domain-of-concern. As long as you have \"enough\" varied examples of a word used in context, the resulting vector will likely be better than generic vectors from someone else's corpus. (\"Enough\" has no firm definition, but is usually at least 5, and ideally dozens to hundreds, of representative, diverse uses.)\nLet's consider your example goal \u2013 showing some similarity between the ideas of 'polymorphism' and 'input inheritance'. For that, you'd need a training corpus that discusses those concepts, ideally many times, from many authors, in many problem-contexts. (Textbooks, online articles, and Stack Overflow pages might be possible sources.) \nYou'd further need a tokenization strategy that manages to create a single word-token for the two-word concept 'input_inheritance' - which is a separate challenge, and might be tackled via (1) a hand-crafted glossary of multi-word-phrases that should be combined; (2) statistical analysis of word-pairs that seem to occur so often together, they should be combined; (3) more sophisticated grammar-aware phrase- and entity-detection preprocessing. \n(The multiword phrases in the GoogleNews set were created via a statistical algorithm which is also available in the gensim Python library as the Phrases class. But, the exact parameters Google used have not, as far as I know, been revealed.And, good results from this algorithm can require a lot of data and tuning, and still result in some combinations that a person would consider nonsense, and missing others that a person would consider natural.)","Q_Score":0,"Tags":"java,python,nlp,word2vec,glove","A_Id":61065738,"CreationDate":"2020-04-05T19:09:00.000","Title":"Pre trained vectors, nlp, word2vec, word embedding for particular topic?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I run two line code, can you let me know what is the issue in importing the scipy in jupyter notebook\nPython Version is 3.7.7\n! pip install scipy\nRequirement already satisfied: scipy in c:\\users\\user\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (1.4.1)\nRequirement already satisfied: numpy>=1.13.3 in c:\\users\\user\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from scipy) (1.18.2)\nimport scipy\nImportError                               Traceback (most recent call last)\n in \n----> 1 import scipy\nc:\\users\\user\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\scipy__init__.py in \n    154     # This makes \"from scipy import fft\" return scipy.fft, not np.fft\n    155     del fft\n--> 156     from . import fft\nc:\\users\\user\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\scipy\\fft__init__.py in \n     74 from future import division, print_function, absolute_import\n     75 \n---> 76 from ._basic import (\n     77     fft, ifft, fft2, ifft2, fftn, ifftn,\n     78     rfft, irfft, rfft2, irfft2, rfftn, irfftn,\nc:\\users\\user\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\scipy\\fft_basic.py in \n----> 1 from scipy._lib.uarray import generate_multimethod, Dispatchable\n      2 import numpy as np\n      3 \n      4 \n      5 def _x_replacer(args, kwargs, dispatchables):\nc:\\users\\user\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\scipy_lib\\uarray.py in \n     25     from uarray import _Function\n     26 else:\n---> 27     from ._uarray import *\n     28     from ._uarray import _Function\n     29 \nc:\\users\\user\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\scipy_lib_uarray__init__.py in \n    112 \"\"\"\n    113 \n--> 114 from ._backend import *\n    115 \n    116 version = '0.5.1+5.ga864a57.scipy'\nc:\\users\\user\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\scipy_lib_uarray_backend.py in \n     13 import inspect\n     14 import functools\n---> 15 from . import _uarray  # type: ignore\n     16 import copyreg  # type: ignore\n     17 import atexit\nImportError: DLL load failed: The specified module could not be found.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":702,"Q_Id":61049268,"Users Score":0,"Answer":"check to see if you are pip installing it with the right version and distribution of python that Jupiter is using.\nVisual Studio Code, Anaconda\/Jupyter, etc sometimes has their own installation of python that is not the one you might have downloaded at some point from the python website.\nIf you are using pip to install things, pip might be installed for another version you are using and adding it to the package list of another python installation.","Q_Score":0,"Tags":"python,scipy,jupyter-notebook","A_Id":61049319,"CreationDate":"2020-04-05T20:45:00.000","Title":"Cannot Import scipy in Jupyter Notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a python script that runs on startup of Windows 10 due to a shortcut of it being in the startup folder. This script is checking constantly for requirements on whether or not to open a web-page. If a page is launched and chrome has not previously been closed (yes closed, not just opened), the program just \"dies\" and freezes. After debugging my program the loop is no longer running, reading and writing to files stops, and even if another web-page should open ... it doesn't. I'm guessing this is a Chrome issue or a problem with this code windowsChromePath = 'C:\/Program Files (x86)\/Google\/Chrome\/Application\/chrome.exe %s'\nwebbrowser.get(windowsChromePath).open(url)\nAnyone know why this could be?\nEdit: Forgot to mention I have had problems in this same project with read and write. Debugging leads me to believe it's not this, however if you think it could be a read\/write problem it might be","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":61052115,"Users Score":0,"Answer":"Turns out webbrowser \"blocks\" waiting for an exit response from the browser. There is no way to make a non-block call. Use multi threading to run the open as a separate task.\nEdit: Make sure to use try on webbrowser since it returns a connect timeout error by default if the windows is not closed. Except then raise if you really want to see the error.","Q_Score":0,"Tags":"python,windows,google-chrome","A_Id":61070619,"CreationDate":"2020-04-06T02:27:00.000","Title":"~~Running Python Script on Startup That Opens Chrome Causing Unexpected Problems~~ SOLVED Multi-threading","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on a credit card fraud detection model and have labeled data containing orders for an online store. The columns I am working with is: Customer Full Name, Shipping Address and Billing Address (city, state, zip, street), Order \nQuantity, Total Cost, and an indicator on whether or not the order was discovered to be fraud. \nThe problem is the fact that 98%+ of the transactions are not fraudulent- the data set is highly imbalanced. I understand this is a classification problem, however I am unsure where to start with the columns I am working with and the imbalance of the data. \nI would appreciate any suggestions of appropriate classification algorithms for this use case and how to deal with the imbalanced data. There are several articles I found when searching for how to solve this, however most are working with a Kaggle dataset that has very different columns (due to security reasons for not allowing the information to be public). \nThanks!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":519,"Q_Id":61052293,"Users Score":2,"Answer":"In my mind, there are 2 directions for deal with the imbalanced dataset for anti-fraud cases:\n\nUsing Supervised ML algorithms for Fraud prediction: try to predict a class (fraud\/not fraud) of sample\nUsing Unsupervised ML algorithms Anomaly detection: try to detect unusual customer\/merchant behavior or payments activity.\n\nSupervised Learning (SL) approach\nIf you use Supervised ML algorithms (e.g. Logistic regression, Random forest, Gradient Boosted Trees) then you need to apply one or more tricks:\n\nBefore training ML model:\n\nOversampling - adding more samples of the minority class: RandomOverSampler, SMOTE (generate synthetic samples) methods in imblearn package\nUndersampling - removing some observations of the majority class:\nRandomUnderSampler method in imblearn package\nCombine Oversampling and Undersampling methods.\n\n\nWhile training ML model:\n\nPass weights parameter in the train model method (set higher weights to minor class samples).\n\n\nAfter training ML model:\n\nDo not use accuracy to estimate the trained model\nUse recall, precision, F1 score, or\/and AUC PR (precision-recall curve ) to robust model evaluation.\n\n\n\nUnsupervised Learning (UL) approach\nUnsupervised algorithms don't require the label in dataset. That's a reason why there is no imbalanced classes problem.\nBut unlike the SL-based models, UL-based models haven't prediction as output. You need additional actions to interpret output of UL-based models.\nThe following algorithms most probably will be useful:\n\nAnomaly detection methods:\n\nOne-class SVM\nIsolation forest or iForest\nLocal Outlier Factor\n\n\nNeural Networks methods:\n\nAutoencoder-based networks, e.g. AE, VAE\nDBN or Deep Belief Network,\nGAN or Generative Adversarial Networks\nSelf-organized Maps.","Q_Score":1,"Tags":"python,machine-learning,classification,data-science,fraud-prevention","A_Id":68881403,"CreationDate":"2020-04-06T02:54:00.000","Title":"Python Fraud Detection Classification Algorithms","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My device send to serial port every 5 seconds. So, I have two situations for using.\nThe first one, port is open-close every 5 secs, after send data.\nAnd open once time, and use it persistence (Try to check port is opened before using).\nWhich use-case is better?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":54,"Q_Id":61055120,"Users Score":1,"Answer":"You should not open \/ close your serial device every n seconds, because time drifting might make you loose data written to your serial port.\nIn order to keep your program running smootly, why don't you create a new thread which opens the serial port and keeps reading in a while loop ?","Q_Score":0,"Tags":"python,python-3.x,pyserial","A_Id":61055977,"CreationDate":"2020-04-06T07:45:00.000","Title":"Open device with pyserial","Data Science and Machine Learning":0,"Database and SQL":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 OS is Linux Mint 19. I have several versions of Python 3.6, 3.7. My Pillow version is 5.1. I am trying to do from PIL import _imaging but I am getting a problem at 3.7 showing that I can not import it. As follow:\nImportError: cannot import name '_imaging' from 'PIL' (\/usr\/lib\/python3\/dist-packages\/PIL\/__init__.py)\nIf I run from the terminal with Python 3.6 I am not getting this kind of problem.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":96,"Q_Id":61058725,"Users Score":1,"Answer":"Did you install Pillow for the newer Python version?\npython3.7 -m pip install Pillow","Q_Score":0,"Tags":"python-3.6,python-3.7","A_Id":61058822,"CreationDate":"2020-04-06T11:27:00.000","Title":"from PIL import _imaging problem, 3.6 running well and 3.7 not 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":0,"Web Development":0},{"Question":"I have installed a Python library from the PyPI. However, I want to add some codes inside it and work with it while editing it. How can I do this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":213,"Q_Id":61058752,"Users Score":0,"Answer":"You can find all your installed libraries in YourPythonDirectory\\Lib\\site-packages","Q_Score":0,"Tags":"python,pip","A_Id":61058797,"CreationDate":"2020-04-06T11:29:00.000","Title":"how can I edit a python library installed with pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed a Python library from the PyPI. However, I want to add some codes inside it and work with it while editing it. How can I do this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":213,"Q_Id":61058752,"Users Score":0,"Answer":"Import the library in any Editor(say PyCharm). Then, press Ctrl + Enter. or else Right Click on Library Name and Select Go to Definition. There you will be able to edit that library. Or else edit in site-packages in your Explorer.","Q_Score":0,"Tags":"python,pip","A_Id":61058821,"CreationDate":"2020-04-06T11:29:00.000","Title":"how can I edit a python library installed with pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I making a application, in this application you can watch movies and songs. \nFor this i'm using angular for frontend and python\/flask for backend.\nEventually this application will run on a raspberry pi 4, to store the mp4 and mp3 files i'm using a simple usb flash drive. For now i just want it to work on my laptop. So the program needs to know where to get the files from and render them in de html.\nWhat is the best approach to load in the mp3 and mp4 files from that usb to display them in the application?\nOn first hand I just thought to give the path where the usb drive is located and then put that in de audio or video tag. Bu i'm not sure this is the right way.\nDoes anyone know what would be the best approach to do this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":61060180,"Users Score":0,"Answer":"Hi Ronny here is a simple way to get the path and play using it:\n{{{  import easygui, vlc\nmedia = easygui.fileopenbox(title=\"Choose media to open\") \nplayer = vlc.MediaPlayer(media)\nplayer.play()   }}} \nthis program will ask the path of the folder to you and play the file to you in vlc media player.","Q_Score":0,"Tags":"python,html,angular,typescript,flask","A_Id":61060318,"CreationDate":"2020-04-06T12:45:00.000","Title":"Taking content (mp4 and mp3) from usb drive and use it in a 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":1},{"Question":"I making a application, in this application you can watch movies and songs. \nFor this i'm using angular for frontend and python\/flask for backend.\nEventually this application will run on a raspberry pi 4, to store the mp4 and mp3 files i'm using a simple usb flash drive. For now i just want it to work on my laptop. So the program needs to know where to get the files from and render them in de html.\nWhat is the best approach to load in the mp3 and mp4 files from that usb to display them in the application?\nOn first hand I just thought to give the path where the usb drive is located and then put that in de audio or video tag. Bu i'm not sure this is the right way.\nDoes anyone know what would be the best approach to do this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":61060180,"Users Score":0,"Answer":"Various methods and it depends on how you want it done. You can:  \n\nRun a CLI command finding .mp3 files through regex. E.g. find \/media | grep *\\.mp3:\nThis will automatically find all .mp3 files in the folder and subfolders.\nYou can run a CLI command inside your Python script e.g. with the subprocess module. Save all the available paths to a mp3 file in an array and process them further from here.\nYou can code a relative path in your program and mount your USB into your working directory's subfolder audio. mount -o remount,ro \/dev\/sda1 ~\/path\/to\/your\/project\/audio:\nAll the audio files are then located in your audio folder which is part of your project. You can have dummy files in there and when you mount your USB into that folder the USB mp3 files are shown.\nThis approach requires you to manually mount before executing your Python program. It is also in my opinion the cleanest approach.\n\nThe manual mounting on the second approach might become a concern for you but for this there are also solution out there where you can define automatic mount points. However these aren't solved in Python.","Q_Score":0,"Tags":"python,html,angular,typescript,flask","A_Id":61060545,"CreationDate":"2020-04-06T12:45:00.000","Title":"Taking content (mp4 and mp3) from usb drive and use it in a 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":1},{"Question":"I am trying to use pygubu designer to make some interfaces. I am using Anaconda and my Python version is 3.7.6. The pygubu-designer.exe file is in the Scripts directory (C:\\Users\\user\\Anaconda3\\Scripts) but when I want to execute the application, an error code shows up saying the file is not found. Do you have any idea of what is causing this error ? \nI installed pygubu via pip before... Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":834,"Q_Id":61061551,"Users Score":0,"Answer":"With a little thinking I re intalled the pygubu module, and now it's working fine... Sorry for the inconvenience. Have a good day !","Q_Score":0,"Tags":"python,tkinter,pygubu","A_Id":61062387,"CreationDate":"2020-04-06T14:00:00.000","Title":"How do I launch Pygubu with Anaconda 3 (Spyder)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"CLion was working fine with my python files. Then I added one .cc and created a CMakeLists.txt for it, now when I tab to a python file all the imports and built-in functions like open or int are counted as errors.\nI've looked into Settings -> Editor -> File Types and everything looks okay.\nHow can I fix this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":61062140,"Users Score":0,"Answer":"The problem was the cmakelists was in a subdirectory, when I moved it to the root folder the .py files are treated as expected","Q_Score":0,"Tags":"python,clion","A_Id":61079321,"CreationDate":"2020-04-06T14:29:00.000","Title":"Clion is not recognizing .py files as python files when I added a CMakeLists for one cc file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently find myself using the bs4\/BeautifulSoup library a lot in python, and have recently been wondering how it works. I would love to see the source code for the library and don't know how. Does anyone know how to do this? Thanks.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":205,"Q_Id":61062983,"Users Score":1,"Answer":"If you are using any IDE, you can right click on imported line and goto Implementation.\nOtherwise you can find the source code in <python_installtion_path>\\Lib\\site-packages directory.","Q_Score":0,"Tags":"python,beautifulsoup","A_Id":61063107,"CreationDate":"2020-04-06T15:12:00.000","Title":"How can I see the source code for a python library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I currently find myself using the bs4\/BeautifulSoup library a lot in python, and have recently been wondering how it works. I would love to see the source code for the library and don't know how. Does anyone know how to do this? Thanks.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":61062983,"Users Score":0,"Answer":"Go to the location where python is installed and inside the python folder, you will have a folder called Lib you can find all the packages there open the required python file you will get the code.\nexample location: C:\\Python38\\Lib","Q_Score":0,"Tags":"python,beautifulsoup","A_Id":61063151,"CreationDate":"2020-04-06T15:12:00.000","Title":"How can I see the source code for a python library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm in the middle of a school project on computer vision that consists on two parts. The first part is the semantic segmentation of a ground picture (small picture) and the second part consists in being able to locate that small picture in a pre-loaded and pre-segmented map (big picture) with the output being the coordinates and the orientation of the small picture inside the big one.\nThe first part is already done and working fine, but I have no idea how to approach the second part of the project. When the small picture's orientation is the same as in the original map, I can easily find it using brute force, but problems start when the small image is rotated respect to the original map.\nI have no idea how to approach this problem, any word, topic or algorithms I could use to look for more information online would be appreciated :)\nI'm working on Matlab with the Deep learning and computer vision toolboxes, but I could easily change to Python if needed or if it could be substantially easier.\nThanks to everyone reading this!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":271,"Q_Id":61067512,"Users Score":1,"Answer":"By the word \"brute force\", I don't understand what you mean. If you provide more detail may be I be able to provide more details or more alogrithms. However if you want to find search image in side same or another image you can use these algorithms: \n- SIFT \n- SURF \n- ORB \n- BRISK \n- FREAK \n- Siamese networks  \nMost of these algorithms (expect last one) try to find some key points that are robust against rotations, noise, brightness variations, blur, ... and finally match them using distance measurement such as hamming, euclidean, manhatan, ....  \nI my self the prefer last one in terms of accuracy and not needing playing with too many hyper-parameters. For Siamese networks you need training. It means labeling and GPU. SIFT and SURF are famous for image matching. For more details you can read their main articles. I wrote a paper on copy-move forgery that finds copy-pasting an part of image for fraud\/forgery purpose. You can find a lot of approaches for your purpose from papers of this field.","Q_Score":0,"Tags":"python,matlab,computer-vision,slam","A_Id":61110494,"CreationDate":"2020-04-06T19:29:00.000","Title":"locating a picture inside a bigger picture","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use Python3 in VS code and for some reason, the VS terminal only will read my macOS system installed version of Python 2.7. I have several other interpreters for python3 installed, but I cannot get the VS terminal to access them to install modules and run my program. \nI am using the command palette to select the interpreter and it says \"current: \/path\/to\/python3\".\nThat is all good, but when I go to terminal to update my packages for I get this error that to me indicates that terminal is trying to install the package in the default python 2.7 environment. How do I access my python3 environments from this terminal? Any help is greatly appreciated!","AnswerCount":3,"Available Count":2,"Score":-0.1325487884,"is_accepted":false,"ViewCount":101,"Q_Id":61068257,"Users Score":-2,"Answer":"I also find the same problem when I was working on python 3. I Deleted the directory in which python 2.7 was installed. System automatically refer to Python 3 after that.","Q_Score":0,"Tags":"python,visual-studio-code,virtualenv","A_Id":61068342,"CreationDate":"2020-04-06T20:17:00.000","Title":"Python in VSCode: What is the easiest way to switch to the correct environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use Python3 in VS code and for some reason, the VS terminal only will read my macOS system installed version of Python 2.7. I have several other interpreters for python3 installed, but I cannot get the VS terminal to access them to install modules and run my program. \nI am using the command palette to select the interpreter and it says \"current: \/path\/to\/python3\".\nThat is all good, but when I go to terminal to update my packages for I get this error that to me indicates that terminal is trying to install the package in the default python 2.7 environment. How do I access my python3 environments from this terminal? Any help is greatly appreciated!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":61068257,"Users Score":0,"Answer":"The issue is that when you select a globally-installed interpreter it doesn't change what python points at in the terminal. You still need to specify either the full path to the interpreter or at least the major.minor version, e.g. python3.7 to get the interpreter you want.\nOtherwise you can use the advice provided by @paltaa and create a virtual environment to work from to isolate your work and put it all directly under your control.","Q_Score":0,"Tags":"python,visual-studio-code,virtualenv","A_Id":61090026,"CreationDate":"2020-04-06T20:17:00.000","Title":"Python in VSCode: What is the easiest way to switch to the correct environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Django is there a way to save mobile no, otp and created_time to DB and let DB remove row when the time created_time is more than 10 sec.\n(like time to live)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":61068585,"Users Score":0,"Answer":"At this time, SQLite does not support that. You best bet would be to implement a background worker, which would delete all the records created more than 10 seconds ago.","Q_Score":0,"Tags":"python,django,database,sqlite","A_Id":61068955,"CreationDate":"2020-04-06T20:38:00.000","Title":"in django delete a row in sqlite3 when the time exceeds","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What is the difference between: from datetime import datetime and import datetime\nI often just do from datetime import datetime, but what is the difference, and why do some people use one over the other?\nLanguage:Python3.7","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":321,"Q_Id":61071335,"Users Score":0,"Answer":"When you use import datetime, you're importing the datetime module, which contains the datetime class. When you use from datetime import datetime, you're importing just the datetime class from the datetime module. So, if you're only using the datetime class from the datetime module, then from datetime import datetime is fine. Otherwise, if you use import datetime, you'll have to use datetime.datetime to access the datetime class.","Q_Score":0,"Tags":"python,datetime,import,python-3.7","A_Id":61071356,"CreationDate":"2020-04-07T01:17:00.000","Title":"from datetime import datetime VS import datetime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After we have converted our categorical variables to dummy variables for training the model. We tend to find feature importance. But sklearn's model.feature_importance_ object returns feature impotance for every dummy variable, rather than the original categorical variable. How to fix this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":61072251,"Users Score":0,"Answer":"Because the dummy variables are used to train the model, you cannot find the importance of the original categorical variable. It is mathematically impossible thing.","Q_Score":0,"Tags":"python,pandas,machine-learning,scikit-learn,data-science","A_Id":61072337,"CreationDate":"2020-04-07T03:16:00.000","Title":"How can I find Feature importance from sklearn api, after I have converted my categorical variables into dummy variables?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a mess out of my self. \nI wanted to add python3.6 in my system so I decided to uninstall the existing one in my Ubuntu 19.10 . But now everytime I want to install something I get error like this:\n\ndpkg: error while cleaning up:\n   installed python3-virtualenv package post-installation script subprocess returned error exit \n   status 127\nErrors were encountered while processing:python3-virtualenv\nProcessing was halted because there were too many errors.\n  E: Sub-process \/usr\/bin\/dpkg returned an error code (1)\n\nI can't open my terminal by clicking on icon and I can't even install any apps from ubuntu sofware.Any suggestion to follow\nSystem\nUbunutu 19.10","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":4600,"Q_Id":61076632,"Users Score":2,"Answer":"I have found the answer. Just wrote the line in the terminal \n\nsudo apt install python3-minimal python3 --reinstall","Q_Score":1,"Tags":"python,python-3.x,linux,ubuntu","A_Id":61096937,"CreationDate":"2020-04-07T09:17:00.000","Title":"Errors were encountered while processing:","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm a pretty new dev in the docker world and at this point I really need help.\nI have a python script inside a docker container.  When python exits with sys.exit(-1) the docker container still exits with success and consequently mark success in airflow too, omitting real errors and trace-backs.\nHow can I exit from container with error ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":400,"Q_Id":61081796,"Users Score":0,"Answer":"I know this question is old, but I just figured out the answer myself.\nFirst, remove any old images that airflow might be using. List them with docker images, and then remove with docker rmi <image_id>\nNow, in your code add a sys.exit(1) in a try\/except for the main part of the code that is getting called by the DAG.","Q_Score":4,"Tags":"python,docker,containers,airflow","A_Id":65431136,"CreationDate":"2020-04-07T14:00:00.000","Title":"Airflow Docker Operator returning sucess when python code inside fail","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have pygame installed and pip3 installed. \nhowever, when I import pygame into the idle I am prompted with an unknown module. \nI am trying to learn python but this situation is giving me a headache. \nis there a way for my computer to find python files easier...\nthe path is all over the place. \nin the terminal \npip3 search pygame prompts me with the pygame content but when i go to import the module isn't there?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":61084554,"Users Score":0,"Answer":"Try these:\n\nIs your file called pygame.py?\nIf you type python3 -m pygame does it say Hello from the pygame community. https:\/\/www.pygame.org\/contribute.html?\nHave you tried installing it again (sudo pip3 install pygame)?\nMaybe try install it by sudo pip3 install pygame --user","Q_Score":0,"Tags":"python,python-3.x,macos,pip,pygame","A_Id":61138924,"CreationDate":"2020-04-07T16:15:00.000","Title":"pygame unknown module macOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A Django web application usually has login required, however there is a url or view that does not need to have a login_required. How to make it work?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":197,"Q_Id":61085966,"Users Score":0,"Answer":"re_path(r'^admin\/', admin.site.urls),\npath('about\/',views.about,name=\"about\"),\nBy default all the admin urls are login protected and if you do not use admin site and if you do not use any login_required decorator in views.py then that url will not be login required just like the \"about\/\" url here.","Q_Score":0,"Tags":"python,django,django-views","A_Id":61086255,"CreationDate":"2020-04-07T17:34:00.000","Title":"How to escape the required login or protection ensured by the middleware in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I followed a udacity tutorial to download python and I'm having some trouble. I downloaded python and I can see that I have when I type in python --version in the terminal. It's version 3.8.2. When I type in python3 --version, I get: \/appData\/Local\/Microsoft\/WindowsApps\/python3: Permission Denied.\nWhy does python --version work but not python 3 --version? What permission is denied?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":748,"Q_Id":61086459,"Users Score":1,"Answer":"It looks like this added two \"stubs\" called python.exe and python3.exe into the %USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps folder, it's inserted before existing Python executable's entry in the PATH.\nMoving this entry below the correct Python folder (partially) corrected the issue.\nType manage app execution aliases into the Windows search prompt and disable the store versions of Python altogether.","Q_Score":0,"Tags":"python,python-3.x,terminal","A_Id":61086634,"CreationDate":"2020-04-07T18:01:00.000","Title":"Trouble finding python in terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I currently have installed Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32. I also have Anaconda installed with its own python version.\nI am trying to install tensorflow with below code (also tried pip install tensorflow). I have successfully installed nltk, numpy and tflearn. I am now trying to install tensorflow and the following message is what I get. I have trying several times over the past hour but I keep getting the same error at different points (percentage completed).\nC:\\Windows\\system32>pip3 install --upgrade tensorflow\nCollecting tensorflow\nDownloading tensorflow-2.1.0-cp36-cp36m-win_amd64.whl (355.9 MB)\n|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588  | 336.2 MB 251 kB\/s eta 0:01:19\nERROR: Exception:\nTraceback (most recent call last):\nFile.....\n....\nsocket.timeout: The read operation timed out\nDuring handling of the above exception, another exception occurred:\n....\nraise ReadTimeoutError(self._pool, None, \"Read timed out.\") \npip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', \nport=443): Read timed out.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":248,"Q_Id":61086647,"Users Score":0,"Answer":"I discovered that issue was indeed the speed of my internet. I downloaded it when the internet was much faster and it downloaded completely.","Q_Score":2,"Tags":"python,tensorflow,pip,installation,command-prompt","A_Id":61092921,"CreationDate":"2020-04-07T18:12:00.000","Title":"How can I resolve Time Out Error when installing Tensorflow in Command Prompt","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Someone can help me\nimpossible to catch csv in my PyCharm \nit tells me :\"an error occured: could not a find a version that satisfies the requirement csv (from version:none)\ni succeed to get numpy matplotlib pandas but no csv.\nit warns me about \"to use the correct version of 'pip' installed for my Python interpreter located.\"\nIf someone can help me, bless him(her)\nthks :)\nVersions installed:\npython 3 8 1 \/\npycharm 11 0 5 + 10 b520 38 \/\npandas 1 0 3 \/\npip 20 0 2","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":130,"Q_Id":61087407,"Users Score":0,"Answer":"Hi guys first thank you for your answer :)\nI am using Pycharm\nI do this to install csv:\nFile>Settings>MyProject>Project Interpreter>Clic Add + Enter 'csv'> Install Packages\nand it tells me:   an Error Occured \nImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source' (C:\\Users\\admin\\AppData\\Roaming\\Python\\Python38\\site-packages\\pip_internal\\distributions\\source__init__.py)","Q_Score":0,"Tags":"python,csv","A_Id":61118207,"CreationDate":"2020-04-07T18:57:00.000","Title":"I can't get (install\/import) csv from my Pycharm Setting Packages","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to disable MLFlow temporarily for debugging code or adding new features? If it is not disabled it saves a bunch of executions not actually usefull or unfinished executions.\nOr is the best strategy to use similar code that doesn't call mlflow.start_run()?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":496,"Q_Id":61088651,"Users Score":1,"Answer":"Not sure if there is an explicit way to disable mlflow_start_run() but one strategy is to use a debug flag that only calls part of that starts an mlflow_startu_run().","Q_Score":1,"Tags":"python,machine-learning,mlflow","A_Id":61128368,"CreationDate":"2020-04-07T20:14:00.000","Title":"How to disable MLFlow temporarily?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So working on some research on nursing homes which are often owned by a chain. We have a list of 9,000 + nursing homes corporate ownership. Now, if I was MERGING this data into anything I think this would not be too much of a challenge, but I am being asked to group the facilities that are associated with each other for another analysis. \nFor example:\nABCM\nABCM CORP\nABCM CORPORATION\nABCM CORPORATE\nI have already removed all the extra spaces, non-alphanumeric, and upcased everything. Just trying to think of a way within like a 90% accuracy I can do this. The within the same variable is the part that is throwing me off. I do have some other details such as ownership, state, zip, etc. I use STATA, SAS, and Python if that helps!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":56,"Q_Id":61090085,"Users Score":1,"Answer":"welcome to SO. \nString matching is - broadly speaking - a pain, whatever the software you are using, and in most cases need a human intervention to yield satisfactory results. \nIn Stata you may want to try matchit (ssc install matchit) for fuzzy string merge. I won't go into the details (I suggest you to look at the helpfile, which is pretty well-outlined), but the command returns each string matched with multiple similar entries - where \"similar\" depends on the chosen method, and you can specify a threshold for the level of similarities kept or discarded. \nEven with all the above options, though, the final step is up to you: my personal experience tells me that no matter how restrictive you are, you'll always end up with several \"false positives\" that you'll have to work yourself!\nGood luck!","Q_Score":1,"Tags":"python,sas,stata","A_Id":61097693,"CreationDate":"2020-04-07T22:02:00.000","Title":"Data Cleanse: Grouping within variable company names","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Our software stack currently requires python-rosdep 0.18.0-1, but his package has been upgraded to 0.19.0-1, and therefore removed 0.18.0-1.  In our jfrog artifactory repo I can still find 0.18.0-1 in the remote-cache, but I am not able force the version.  When I do sudo apt install python-rosdep=0.18.0-1, I got E: Version '0.18.0-1' for 'python-rosdep' was not found.  Searching for the package apt search python-rosdep gives me the newest version only.  Is there a way I can still install the older version cached in our jfrog artifactory repo?  Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":480,"Q_Id":61090329,"Users Score":1,"Answer":"The behavior you got is expected as Remote Repository in Artifactory tries to mirror the original repository.\nYou have couple of options to resolve the package that is already cached although expired from the remote:\n\nCopy it to a local repository & pull from there.\nNot 100% sure about this one, but setting the remote repository\n\"offline\" may work as a quick workaround.","Q_Score":0,"Tags":"python,artifactory,apt,downgrade","A_Id":61121227,"CreationDate":"2020-04-07T22:22:00.000","Title":"Not able to apt install a package remote cached in Jfrog Artifactory after the it has been removed from the source","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have huge array objects that are pickled with the python pickler.\nI am trying to unpickle them and reading out the data in a for loop.\nEvery time I am done reading and assesing, I delete all the references to those objects.\nAfter deletion, I even call gc.collect() along with time.sleep() to see if the heap memory reduces.\nThe heap memory doesn't reduce pointing to the fact that, the data is still referenced somewhere within the pickle loading. After 15 datafiles(I got 250+ files to process, 1.6GB each) I hit the memory error.\nI have seen many other questions here, pointing out a memory leak issue which was supposedly solved.\nI don't understand what is exactly happening in my case.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":61091634,"Users Score":0,"Answer":"Python memory management does not free memory to OS till the process is running.\nRunning the for loop with a subprocess to call the script helped me solved the issue.\nThanks for the feedbacks.","Q_Score":0,"Tags":"python,memory-leaks,garbage-collection,pickle,heap-memory","A_Id":61114512,"CreationDate":"2020-04-08T00:45:00.000","Title":"Memory leak on pickle inside a for loop forcing a memory error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am analyzing histology tissue images stained with a specific protein marker which I would like to identify the positive pixels for that marker. My problem is that thresholding on the image gives too much false positives which I'd like to exclude.\nI am using color deconvolution (separate_stains from skimage.color) to get the AEC channel (corresponding to the red marker), separating it from the background (Hematoxylin blue color) and applying cv2 Otsu thresholding to identify the positive pixels using cv2.threshold(blur,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU), but it is also picking up the tissue boundaries (see white lines in the example picture, sometimes it even has random colors other than white) and sometimes even non positive cells (blue regions in the example picture). It's also missing some faint positive pixels which I'd like to capture.\nOverall: (1) how do I filter the false positive tissue boundaries and blue pixels? and (2) how do I adjust the Otsu thresholding to capture the faint red positives?\nAdding a revised example image -\n\ntop left the original image after using HistoQC to identify tissue regions and apply the mask it identified on the tissue such that all of the non-tissue regions are black. I should tru to adjust its parameters to exclude the folded tissue regions which appear more dark (towards the bottom left of this image). Suggestions for other tools to identify tissue regions are welcome.\ntop right hematoxylin after the deconvolution\nbottom left AEC after the deconvolution\nbottom right Otsu thresholding applied not the original RGB image trying to capture only the AEC positives pixels but showing also false positives and false negatives\n\nThanks","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":499,"Q_Id":61092050,"Users Score":1,"Answer":"I ended up incorporating some of the feedback given above by Chris into the following possible unconventional solution for which I would appreciate getting feedback (to the specific questions below but also general suggestions for improvement or more effective\/accurate tools or strategy):\n\nDefine (but not apply yet) tissue mask (HistoQC) after optimizing HistoQC script to remove as much of the tissue folds as possible without removing normal tissue area\nApply deconvolution on the original RGB image using hax_from_rgb\nUsing the second channel which should correspond to the red stain pixels, and subtract from it the third channel which as far as I see corresponds to the background non-red\/blue pixels of the image. This step removes the high values in the second channel that which up because of tissue folds or other artifacts that weren't removed in the first step (what does the third channel correspond to? The Green element of RGB?)\nBlur the adjusted image and threshold based on the median of the image plus 20 (Semi-arbitrary but it works. Are there better alternatives? Otsu doesn't work here at all)\nApply the tissue regions mask on the thresholded image yielding only positive red\/red-ish pixels without the non-tissue areas\nCount the % of positive pixels relative to the tissue mask area\n\nI have been trying to apply, as suggested above, the tissue mask on the deconvolution red channel output and then use Otsu thresholding. But it failed since the black background generated by the applying the tissue regions mask makes the Otsu threshold detect the entire tissue as positive. So I have proceeded instead to apply the threshold on the adjusted red channel and then apply the tissue mask before counting positive pixels. I am interested in learning what am I doing wrong here.\nOther than that, the LoG transformation didn't seem to work well because it produced a lot of stretched bright segments rather than just circular blobs where cells are located. I'm not sure why this is happening.","Q_Score":2,"Tags":"python,opencv,image-processing,computer-vision,scikit-image","A_Id":61293526,"CreationDate":"2020-04-08T01:37:00.000","Title":"Identifying positive pixels after color deconvolution ignoring boundaries","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have legacy code which uses tensorflow 1.0.1 version in my ipython notebook.\nI have a requirements.txt file to install dependencies.\nSo I run the cell -!pip3 install -r requirements.txt in my Colab notebook to run this legacy code.\nrequirements.txt has following dependencies,\n\ntensorflow-gpu==1.0.1\nnltk==3.2.5\nmatplotlib==2.0.2\nscipy==0.19.1\nscikit-learn==0.19.0\njupyter==1.0.0\n\nAfter running the above cell in my notebook I get a message to restart the runtime to setup the environment for TensorFlow 1.0.1. \nAfter restarting the kernel I always get the runtime in the \"Busy\" state.\nEven though I tried terminating the session to start again. It does not help because I have to restart the kernel in new session too.\nCan anyone clarify what should I do to avoid \"staying Busy state\" after kernel restart?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1742,"Q_Id":61093037,"Users Score":1,"Answer":"Try dropping the jupyter install. It's likely that's installing deps that are incompatible with Colab, which results in your backend becoming wedged.\nWhen in this state, you can reset your runtime using the Runtime -> Factory reset runtime menu.","Q_Score":0,"Tags":"python,tensorflow,google-colaboratory","A_Id":61093101,"CreationDate":"2020-04-08T03:50:00.000","Title":"Colab run time stays \"Busy\" state after restarting the run time","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have code contains many files and many functions.\nIn Pycharm 2019 IDE, the debugger stop on breakpoints in most of the files correctly, but in some files, the debugger crossed the breakpoints and absolutely deny it.\nIt should be noted that I checked the running details and I added some print lines near breakpoints and I can see my prints in the console.\nIn these files, The debugger runs the code instead of debugging!!!\nHow can I solve this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":61096150,"Users Score":0,"Answer":"This could happen for many reasons and impossible to state a direct answer. It's also hard to identify the problem without the relevant code. \nHere are some possibilities.\n\nAn unhandled exception was raised by code long before we ever got to the code containing a breakpoint. That is, the code which gets executed before the code containing a break-point contains an error.\nThe code containing a break-point is never executed, even when the script runs from start to finish. For example, if the break-point is inside an if-block and the condition of the if-statement is never true, then the breakpoint will never be reached.\nYou are not running the script you think you are running. Look in the upper right corner of the UI. What is the name of the file next to the run button (green triangle)?\nCheck that thr suspend options are ticked in. Follow these steps: Go to Run->View breakpoints and check if the Suspend option is\nticked in.","Q_Score":0,"Tags":"python,python-3.x,debugging,pycharm,breakpoints","A_Id":61114267,"CreationDate":"2020-04-08T08:11:00.000","Title":"Pycharm debugger does not work properly on breakpoints","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm not sure about the difference between apply_async() and send_task() in Celery library in Python, specially when using Tasks pools.\nWhat I'm mainly looking for is having a centralized server with all tasks defined in there, and using some Redis queues, the other physical instances are able to publish\/send events to the different queues targetting different tasks using Pools, without the need to define all the list of the tasks in each publisher script to be able to use.\nI've looked into the documentation and didn't find much to answer my question actually.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1540,"Q_Id":61096293,"Users Score":3,"Answer":"They both do the same thing (request particular task to be executed). However for apply_async() to work you need the definition of the task. send_task() is extremely convenient in the case you really do not want to distribute the code just so that you can trigger particular task (sure, you must use the same serialization, and know name of the task, but if you are codebase owner this is not an issue).","Q_Score":3,"Tags":"python,python-3.x,celery,celery-task","A_Id":61097959,"CreationDate":"2020-04-08T08:19:00.000","Title":"Difference between send_task() and apply_async()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on tiny program to capture screen print, I want to do it in a similar fashion that Win Snipping Tool is working. First I need to overlay all screens with a 50% opacity layer and then, using the mouse, draw a rectangle and read vertices coordinates. Honestly, I have no idea how to bite this. I tried with win32api \/ gui and it is great to get mouse coordinates, but still was unable to draw a rectangle. My idea (one of many) is to (using PIL \/ ImageGrab) take shots of both displays, put an overlay and print them as a full screen on all windows, but I failed while doing this. Other idea is to take img grab and create two new windows using BeeWare \/ Toga (that is GUI framework I am using) in full screen, but I was unable to find any method to open window on second display. Any ideas and hints will be greatly appreciated, I am really counting on you, as I feel I reached dead end.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":575,"Q_Id":61096325,"Users Score":0,"Answer":"Well,It is very easy to use tkinter.\nOk,It is the principle when I make my screenshot application:\n\nUser presses the button to start.\nMake a new window whose width and height should full cover all the screens,and hide the title bar(If it is had to achieve,maybe use width=9999 and height=9999).\nTake a screenshot of all the desktop(You can use ImageGrab.grab((),all_screens=True)) to do that.\nMake the screenshot showed in a Canvas(I know that toga have this widget).\nStart your mouse listener thread and save the position of pressed.\nWhen user moves his mouse,create a rectangle(toga's Canvas have a function rect()).Maybe use this rect(pressed_x,pressed_y,move_x,move_y).And delete the last rectangle(Then it will always show only one rectangle).\nWhen user released his mouse,save the position of released.And use ImageGrab.grab((pressed_x,pressed_y,released_x,released_y),all_screens=True) to crop the selected area.\nIf you want to show it in application interface.toga has a widget called ImageView.You can put the image in it.","Q_Score":0,"Tags":"python,user-interface,python-imaging-library,pywin32,beeware","A_Id":61097779,"CreationDate":"2020-04-08T08:21:00.000","Title":"Overlay all screens and draw rectangle with a mouse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a discord bot for educational purposes and out of boredom. In many tutorials command functionality is realized through on_message() but I found some that use @bot.command too. I don't have enough experience to tell which will be better in the long run and I didn't find any such information in discord.py docs. Which one should I use and why?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":61096498,"Users Score":2,"Answer":"Which one should I use and why?\n\nI would depend what you want to do specifically. on_message is completely open-ended, so if you need to process arbitrary messages and have your bot react then that's the one to use e.g. maybe you want to reply to people using words of more than 4 syllables and tell them their long words hurt or something.\nCommands are much more structured and used for explicitly interacting with bots.\nSo by default you'd use commands, and if your use case doesn't fit commands, then you'd use the more freeform on_message.","Q_Score":0,"Tags":"python,discord.py","A_Id":61096913,"CreationDate":"2020-04-08T08:32:00.000","Title":"Should I use on_message() or @bot.command?","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 where I need to open a \".txt\" folder and analyse the text in there. \nI have saved this \".txt\" document in the same folder as my Python script. \nBut, when I go to open the file; file = open(\"words.txt\",'r')\nI get the error: No such file or directory: 'words.txt'.\nI don't understand why this is happening?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":12480,"Q_Id":61097665,"Users Score":5,"Answer":"Maby it's because your current working directory is different from the directory your files are stored. Try giving the full path to the file\nfile = open(\"<full_path>\\words.txt\",'r')","Q_Score":3,"Tags":"python,file,directory","A_Id":61097774,"CreationDate":"2020-04-08T09:39:00.000","Title":"No such file or directory but file exists?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a python script where I need to open a \".txt\" folder and analyse the text in there. \nI have saved this \".txt\" document in the same folder as my Python script. \nBut, when I go to open the file; file = open(\"words.txt\",'r')\nI get the error: No such file or directory: 'words.txt'.\nI don't understand why this is happening?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":12480,"Q_Id":61097665,"Users Score":1,"Answer":"Check if there's a typo in the code or in the filename of the file\nMake sure the file is really under the current working directory. Sometimes similar filenames or info shown in your IDE cause confusions\nMake sure your are editing the correct script. Sometimes people copy and paste a script into different places and immediately forgot which one they are actually editing\n\nHope it helps.","Q_Score":3,"Tags":"python,file,directory","A_Id":61097907,"CreationDate":"2020-04-08T09:39:00.000","Title":"No such file or directory but file exists?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"so I am working with angular at the moment and I wanted to know if its possible to use Web scraping and providing the information I get to my Angular Webpage.Is there a way to do that and if so is there any good practice you could recommend? Can I combine my Python code or more specific the outcome with my Angular Project? \nThank you very much for helping guys.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1068,"Q_Id":61099132,"Users Score":1,"Answer":"There are many ways to do this, what I'd recommend for smaller projects is:\n\nSet up lambda functions in AWS that runs your scraping. On lambda you can choose to run node.js, python, and plenty of other languages and frameworks. I prefer selenium with python.\nWith cloudwatch events, set this lambda to scrape every X minutes.\nPut the scraped data into a mongoDB database, made simple with pymongo.\nIn angular, use a server to connect to the mongodb database.\n\nYou can set up your website on heroku.com for free, and add a DB from there. I have used this setup for hittavaran.com","Q_Score":1,"Tags":"python,angular,web-scraping","A_Id":61099326,"CreationDate":"2020-04-08T11:00:00.000","Title":"Web crawling and providing the data to my Angular Webpage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"so I am working with angular at the moment and I wanted to know if its possible to use Web scraping and providing the information I get to my Angular Webpage.Is there a way to do that and if so is there any good practice you could recommend? Can I combine my Python code or more specific the outcome with my Angular Project? \nThank you very much for helping guys.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1068,"Q_Id":61099132,"Users Score":0,"Answer":"Angular is a front-end framework.\nIf you want to display the same scraped data to all users, you should use a back-end framework that your angular app can request the data from.\nThere are many options for frameworks in python, such as flask, to start up an interface that any front-end application can request data from.","Q_Score":1,"Tags":"python,angular,web-scraping","A_Id":61099218,"CreationDate":"2020-04-08T11:00:00.000","Title":"Web crawling and providing the data to my Angular Webpage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm making my first steps in macOS app development.\nI'm trying to write an app on Swift that would keep python interactive console open.\nSometimes I would like to send to python commands and return the results back to swift, but not closing python to keep all variables for the next command I will send.\nIs there any way to do that?\nAs far as I understand, I can't use the Process() because the input pipe automatically closes when I run the task.\nI probably need to use pseudo terminals with pty and tty, but I don't fully understand the idea and where to learn about it. (or, maybe, I'm wrong and there is another way)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":61099485,"Users Score":0,"Answer":"If you actually want to use python code from swift, I would strongly advise you to avoid using this method. It is very bug prone and potentially limiting and inefficient. You better use some wrapper of the python-c-api, or write some small server in python to receive requests from swift.\nIf you still want to do that, an easy way to go about it would be to use python itself to spawn python inside a pty:\npython -c \"import pty, sys; pty.spawn(sys.argv[1:])\" python\nThis will start a python console that reads and writes to stdio instead of of \/dev\/tty.","Q_Score":0,"Tags":"python,swift,macos,tty,pty","A_Id":62534243,"CreationDate":"2020-04-08T11:22:00.000","Title":"Run python interactive console as a subprocess in swift with sending commands and receiving results after launched","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I can use \ncc = message.CC to display the list of Carbon copy names for a mail item. However they are just names. How can I display full mailadress for cc list?\nfor sender mail address\uff0cI can use message.sender.GetExchangeUser().PrimarySmtpAddress to get. but message.CC cannot use this because the output data type is \u201cstr\u201d. message.sender output data type is win32com.client.CDispatch.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":272,"Q_Id":61101159,"Users Score":0,"Answer":"Loop through the MailItem.Recipients collection, check for the items with Recipient.Type == olCC. use Recipeint.AddressEntry property to retrieve the corresponding AddressEntry object. Check if AddressEntry.Type == \"EX\". If yes, use AddressEntry.GetExchangeUser().PrimarySmtpAddress, otherwise use AddressEntry.Address.","Q_Score":0,"Tags":"python-3.x,outlook","A_Id":61148410,"CreationDate":"2020-04-08T12:53:00.000","Title":"Extract CC list full mail address from outlook mail","Data Science and Machine Learning":0,"Database and SQL":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 goal is to compare the power of Python metaclasses with metaprogramming systems of other languages such as Groovy, Xtend, Nemerle, CLOS, OpenJava, BSJ (BackStage Java), Iguana\/J, compiler plugins for Scala, Cyan, etc.\nAssume class MyMeta is the metaclass of class MyClass. \nCan MyMeta generate code in MyClass that intercepts get and set of MyClass instance attributes?\nCan a method of MyMeta be called when MyClass is inherited, even if the subclass metaclass is not MyMeta?\nCan a method of MyMeta be called when a MyClass method is overridden in a subclass, even if the subclass metaclass is not MyMeta?\nCan a method of MyMeta be called when a method of MyClass uses an attribute that has not been declared?\nCan MyMeta handle the AST of MyClass or another equivalent representation?\nFor example, can MyMeta check if each class method has at most 20 statements? Or add a statement after the second method statement? Or rename a method?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":61103185,"Users Score":0,"Answer":"Can MyMeta generate code in MyClass that intercepts get and set of\n  MyClass instance attributes?\n\nYes. That can be done by injecting a __getattribute__ and a __setattr__ methods in the class. But if the attributes are declared in some other form (like, with annotations), it can also create descriptors for each attribute to handle only changes to those attributes. However, it can't trivially guess what are individual  \"instance attributes\" if those are just defined in the classic way, of being set in code, inside the class' __init__ (but the first approach covers all attributes anyway); \n\nCan a method of MyMeta be called when MyClass is inherited, even if\n  the subclass metaclass is not MyMeta?\n\nA subclass will automatically inherit the MyMeta as their metaclasses. If there is a conflict due to other bases, when using multiple inheritance, having other metaclasses, the subclass can't be created at all. (Unless one creates a suitable metaclass that inherits from both metaclasses, that is). _TL;DR: yes. and no,there is no subclass with a different metaclass than its parents'.\n\nCan a method of MyMeta be called when a MyClass method is overridden\n  in a subclass, even if the subclass metaclass is not MyMeta?\n\nThere is no such a thing as \"subclass's metaclass not being MyMeta\". And then, \nthe metaclass acts on the subclass creation and can detect method overrides. And, it can even be made to detect method overrides by monkey-patching after the class is created (by having the metaclass implement __setattr__)\n\nCan a method of MyMeta be called when a method of MyClass uses an\n  attribute that has not been declared?\n\nYes, by setting suitable __getattribute__ and __setattr__ methods as given earlier. There is no ready-made functionality for this (and no need for a metaclass as well, just a mixin implementing both methods would work)\n\nCan MyMeta handle the AST of MyClass or another equivalent\n  representation? For example, can MyMeta check if each class method has\n  at most 20 statements? Or add a statement after the second method\n  statement? Or rename a method?\n\nThe metaclass is called way after the AST has been created and baked into bytecode. But it can introspect into the methods bytecode to check anything it wants, and it can fetch their source code (if available), and re-generate the AST, and it can recreate other methods to replace the original ones - the substitutes having all-new bytecode. \nThat kind of thing, however is rarely, if ever used and sounds like overkill.\nA more pythonic approach would be to use decorators, and use the metaclass to auto-apply decorators on methods. These decorators can provide wrapper functions to run preamble and post-call code for each of the methods if needed.","Q_Score":1,"Tags":"python,reflection,metaprogramming,metaclass","A_Id":61110449,"CreationDate":"2020-04-08T14:30:00.000","Title":"If MyMeta is the MyClass metaclass in Python 3.x, what types of manipulation can MyMeta do with MyClass?","Data 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 written a Python desktop application using PyQt5 for the UI. I create the exe file using PyInstaller from inside PyCharm with the following options: --onefile --windowed --icon=QRev.ico QRev.py \nThe resulting exe has the QRev.ico icon when viewed in Windows Explorer but when executed a generic or perhaps the PyInstaller icon appears in the Windows 10 taskbar rather than the QRev Icon.\nIf I pin QRev.exe to the taskbar the icon works as expected. The problem occurs when the exe is executed from anywhere other than the taskbar, the icon in the taskbar is not correct. How can I fix this so that the QRev icon is shown in the taskbar?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1215,"Q_Id":61104261,"Users Score":2,"Answer":"Finally figure it out after a friend found a similar post for Tkinter. \nThe icon in the taskbar comes from inside the code not from PyInstaller. For pyqt5 I simply added the command: self.setWindowIcon(QtGui.QIcon('QRev.ico'))","Q_Score":0,"Tags":"python,windows,icons,pyinstaller","A_Id":61122645,"CreationDate":"2020-04-08T15:23:00.000","Title":"Python exe created with PyInstaller shows custom icon in Windows Explorer but not in Taskbar when executed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a video that needs to be rotated n degrees (not just 90 or 180 which I can do using ffmpeg but for instance 1 or 10). How can do this?\nI've googled and no such tools seem to be freely available.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":61104303,"Users Score":0,"Answer":"You can use the rotate filter.\nFor example rotate 10 degree.\nffmpeg.exe -i input.mp4 -vf 'rotate=10\/180*PI\/2' output.mp4\n\nOr you can use a dynamic degree.\n\nffprobe.exe -v quiet -show_entries format=duration -print_format json -i input.mp4 to get the video lenght as T.\nThen rotate it with ffmpeg.exe -i input.mp4 -vf 'rotate=t\/T*PI\/2' output.mp4","Q_Score":1,"Tags":"python,video","A_Id":61150942,"CreationDate":"2020-04-08T15:26:00.000","Title":"How to turn a video n degrees","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have two listbox filters Filter 1 : Employee Filter 2: Project , There is a cross tab visualization of the data. Now i dont want cross tab visualization data to be changed when user selects only the name, only when user selects employee name and a project only then the data in the cross tab visualization should change. How can I achieve this ?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":61107098,"Users Score":0,"Answer":"Instead of using two filters create a hierarchy filter or a calculated column with Employee + Project so that the user is interacting with only one visual. \nOther option would be to create document properties for both filters and using python scripts attached to the document property to update the filters only when both document properties have values. This is a lot of coding though since you'll have to pass document properties values to a filter.","Q_Score":0,"Tags":"visualization,ironpython,spotfire","A_Id":61668856,"CreationDate":"2020-04-08T18:02:00.000","Title":"Is there a way to force the user to select values from two different filters and visualization data changes accordingly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When using dask.to_parquet(df, filename) a subfolder filename is created and several files are written to that folder, whereas pandas.to_parquet(df, filename) writes exactly one file.\nCan I use dask's to_parquet (without using compute() to create a pandas df) to just write a single file?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3082,"Q_Id":61108376,"Users Score":2,"Answer":"Writing to a single file is very hard within a parallelism system. Sorry, such an option is not offered by Dask (nor probably any other parallel processing library).\nYou could in theory perform the operation with a non-trivial amount of work on your part: you would need to iterate through the partitions of your dataframe, write to the target file (which you keep open) and accumulate the output row-groups into the final metadata footer of the file. I would know how to go about this with fastparquet, but that library is not being much developed any more.","Q_Score":4,"Tags":"python,pandas,dask,parquet","A_Id":61109619,"CreationDate":"2020-04-08T19:19:00.000","Title":"Force dask to_parquet to write single file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to pass the entire dataset to Keras fit function using batch_size parameter equals to length of the dataset, but it seems that process only 1 sample because under the Epoch 1\/50 print of the fit function I see 1\/1 and not, for example, 500\/500, where 500 is the dataset length. How could I do?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":61111263,"Users Score":0,"Answer":"The progress displayed in the terminal output is for batches, so what you see is expected: in that epoch you are processing batch 1 of 1, where that batch has 500 samples in it. You can of course recover the number of samples processed by multiplying by your batch size.","Q_Score":0,"Tags":"python,keras","A_Id":61114180,"CreationDate":"2020-04-08T22:48:00.000","Title":"Pass entire dataset to Keras fit","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This question has been asked in different ways many times, many people approach this problem in different ways. Which is why I am unsure of my methodology, it would be good if someone could tell me if I am doing things correctly.\nThe steps that I follow are -\n\nSet up stereo camera pair.\nCalibrate both the cameras individually to get their camera\nmatrices, distortion coefficients, using calibrateCamera\nThen we calculate R, T, E, F\n    using stereoCalibrate\nCalculate R1,R2,P1,P2 and Q using stereoRectify\nSince I want to find the 3D coordinates of a specific point in my\nscene, I extract the coordinates of that point in both the images,\nand after that I use triangulatePoints to get the 3D points in\nhomogenous coordinates.\n\nAre the steps that I'm following correct? I've been having problems with the OpenCV documentation so it took me a while to formulate the steps, digging through the documentation. People have approached this problem in OpenCV in different ways, some have even constructed the Fundamental and Essential Matrices using some of the helper functions in the OpenCV documentation, but I think the stereoCalibrate and stereoRectify use these helper functions themselves.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":233,"Q_Id":61111435,"Users Score":1,"Answer":"The steps are theoretically correct. You won't get any good results using them.\nMy advice would be to get a ready-made stereo camera (ZED or RealSense comes to mind), it already has everything you need, so you don't have to calibrate or calculate, just use their libraries and get some results. Which won't be perfect, but it will give you a good start.\nOnce you played enough with the stereo camera, you'll have a better understanding where the most problems are, and how to approach them.","Q_Score":0,"Tags":"python,opencv,computer-vision,stereo-3d","A_Id":61112081,"CreationDate":"2020-04-08T23:07:00.000","Title":"Steps for 3D Reconstruction?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This question has been asked in different ways many times, many people approach this problem in different ways. Which is why I am unsure of my methodology, it would be good if someone could tell me if I am doing things correctly.\nThe steps that I follow are -\n\nSet up stereo camera pair.\nCalibrate both the cameras individually to get their camera\nmatrices, distortion coefficients, using calibrateCamera\nThen we calculate R, T, E, F\n    using stereoCalibrate\nCalculate R1,R2,P1,P2 and Q using stereoRectify\nSince I want to find the 3D coordinates of a specific point in my\nscene, I extract the coordinates of that point in both the images,\nand after that I use triangulatePoints to get the 3D points in\nhomogenous coordinates.\n\nAre the steps that I'm following correct? I've been having problems with the OpenCV documentation so it took me a while to formulate the steps, digging through the documentation. People have approached this problem in OpenCV in different ways, some have even constructed the Fundamental and Essential Matrices using some of the helper functions in the OpenCV documentation, but I think the stereoCalibrate and stereoRectify use these helper functions themselves.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":233,"Q_Id":61111435,"Users Score":1,"Answer":"As you said, everyone has their own way. The way I tried is, the first 4 steps were the same, but for calculating the 3d point I used the stereo matching algorithms that are present in OpenCV. Algorithms like StereoBM, StereoSGBM are implemented in OpenCV and it has provided an easy to use APIs. \nSo Once we get the disparity map from the stereo matching funciton, we can get the 3d coordinates by using reprojectImageTo3D API. It requires disparity map and Q matrix as inputs.","Q_Score":0,"Tags":"python,opencv,computer-vision,stereo-3d","A_Id":61368544,"CreationDate":"2020-04-08T23:07:00.000","Title":"Steps for 3D Reconstruction?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have trained the model and save this model to a file [ cats_and_dogs_small_1.h5 ]. How can I apply this model to a separate test data (Own created picture from my mobile phone)?\nCan you please help me with this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":61113360,"Users Score":0,"Answer":"Please provide more info. e.g Which framework are you using? Also, what do you mean by \"apply\" ? Do you wish to evaluate a new image using the trained model?","Q_Score":0,"Tags":"python,deep-learning,computer-vision,conv-neural-network","A_Id":61113468,"CreationDate":"2020-04-09T03:12:00.000","Title":"apply a CNN .h5 format model on the new data set","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I looked through the documentation but I was not able to find how to retrieve submissions based on flair from a particular subreddit for a given time period, without using BigQuery.\nJust using the API.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":290,"Q_Id":61113994,"Users Score":0,"Answer":"It is not possible at this time according to the documentation.","Q_Score":0,"Tags":"python,reddit,praw,data-collection,flair","A_Id":61168645,"CreationDate":"2020-04-09T04:29:00.000","Title":"Is there a way to get submissions or a subreddit based on the flair using pushshift API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am converting a dictionary to pandas object with to_csv. I have both way of doing this \n1 - by writing file in disk(with open statement)\n2 - by writing in memory (StringIO,BytesIO) \nI have used it in both way creating file in disk and using StringIO to convert to pandas object. I tried to read comparisons between these three, but bit confused which one is faster so i can use it in production to process tons of data.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":453,"Q_Id":61114188,"Users Score":2,"Answer":"Writing and reading from memory is fast. But keep in mind that you have tons of data. So storing all that in-memory might take up all your memory and might make the system slow or might throw errors due to Out of Memory. So, analyze and understand which all data to be put in memory and which all to be written to files.","Q_Score":0,"Tags":"python,python-3.x","A_Id":61114220,"CreationDate":"2020-04-09T04:49:00.000","Title":"Which one is faster in production? file on disk vs file in memory(StringIO,BytesIO)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm still pretty new to this web dev. I have been having trouble accessing the django admin site. I'm able to do localhost:8000 just fine.\nIf I do localhost:8000\/admin, I'm directed to the admin login page. I have already created id\/pw through createsuperuser. \nAnyway, once I type in my id and pw, I noticed my dev server (localhost or 127.0.0.1) terminates and the login page will throw me an error saying \"this site can't be reached\" with ERR_CONNECTION_REFUSED.\nI've tried turning off my internet\/firewall, but it still gave me the same result. \nI would greatly appreciate your help. I've been having so much trouble with this because I can't access the django admin site...\n(i'm using macOS Catalina, if that's any useful. Also I'm just following the basic Django tutorials, so i'm not using anything like gunicorn or nginx either.\n)\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":828,"Q_Id":61115228,"Users Score":0,"Answer":"Based on the limited info:\n\nTry to access 127.0.0.1:8000\/admin instead of localhost:8000\/admin.\nIn django's settings set ALLOWED_HOSTS = ['*'] (NOTE: This is only for development).\nCheck if something else is not already runnning on that port. You can use the following command on Mac lsof -Pn -i4 | grep -i \"listen\".","Q_Score":1,"Tags":"python,django,web,localhost","A_Id":61115349,"CreationDate":"2020-04-09T06:31:00.000","Title":"Can't log into localhost:8000\/admin ... ERR_CONNECTION_REFUSED","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm a 17-year-old, and I am new to programming. I installed anaconda and python on my laptop however every time that I run code in Sublime Text it gives this error before printing whatever I want it to print: \n\/Users\/eyan\/.bash_profile: line 20: conda: command not found\nIt's really annoying so is there a way to get rid of it.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":15188,"Q_Id":61117358,"Users Score":3,"Answer":"The difference between bash and zshell are minimal. They are both a \"shell\" that run in the terminal. A shell is what allows you to run commands in the terminal. It has its own language called bash or alternatively shell scripting. If you have ever typed ls or cd in a terminal, you are using bash commands to move around or look at things in the terminal. (The terminal itself is just the little oftentimes black square you type into.) It doesn't really matter which one you pick at this point, but you should just go with one.\nIf you pick bash, the files that interact with it will be under your home directory, the error tells you exactly where. \/Users\/eyan\/.bash_profile the .bash_profile sets some configurations for bash. \nIf you pick zshell, the files will instead of starting with '.bash_ they'll start with .zsh the most common one will be .zshrc and it will be in the same home directory. So \/Users\/eyan\/.zshrc will be the config file for zshell. \nPick one and just stay with it for now. \nIn either case, you want to initialize conda. \nIn your terminal, if you type:\nwhich conda\nIt should tell you where your conda is installed. If you get a bunch of nonsense running that, try which python. One of them should give you something like this output:\n\/Users\/eyan\/opt\/anaconda3\/bin\/python\nChange the python in that line to activate and add the command source to the front. So type:\nsource \/Users\/eyan\/opt\/anaconda3\/bin\/activate\nOnce you've done that type:\nconda init\nAll of this is done in the terminal. And that should add a bunch of stuff to your shell profiles. (That's those files in your home directory like .bash and .zshrc.)\nIf you close and reopen your terminal or type EXEC $SHELL in the same terminal window, you should be able to use conda.\nYou can also see what was added to your bash (or zsh) profiles by typing:\ncat \/Users\/eyan\/.bash_profile\n(Or if you've chosen zshell, run cat \/Users\/eyan\/.zshrc)\nYou'll see that conda added quite a few lines to it. Don't worry about what those lines do for now, but you can see them there.","Q_Score":2,"Tags":"python,anaconda,conda","A_Id":61120323,"CreationDate":"2020-04-09T08:53:00.000","Title":"Conda: Command not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want a function to be run as if it was written in the main program, i.e. all the variables defined therein can be accessed from the main program. I don't know if there's a way to do that, but I thought a wrapper that gives this behaviour would be cool. It's just hacky and I don't know how to start writing it.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":61117455,"Users Score":1,"Answer":"I have pieces of code written inside functions, and I really want to run them and have all the variables defined therein after run without having to write the lengthy return statements. How can I do that? \n\nThat's what classes are for. Write a class with all your functions as methods, and use instance attributes to store the shared state. Problem solved, no global required.","Q_Score":0,"Tags":"python","A_Id":61118661,"CreationDate":"2020-04-09T08:59:00.000","Title":"Python: how to write a wrapper to make all variables decalared inside a function globals?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on logistic regression project where I have 850 observations and 8 variables and in this, I found 150 missing values and I have decided to use these values as test data. How can I take only missing values as test data in python?\nI am still learning data science if there's a mistake in this approach please let me know.\nThank you :)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":61119977,"Users Score":0,"Answer":"You could use the pd.isna() from pandas library.\nIt will return a boolean array that you can use for filtering your data.","Q_Score":0,"Tags":"python,regression,logistic-regression","A_Id":61120126,"CreationDate":"2020-04-09T11:20:00.000","Title":"How to select only missing values for testing the model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to fit a horizontal line into my matplotlib plot in python, couldn't find any simple method. so, was wondering if there is any simple way to fit a line of specific slope in matplotlib.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":92,"Q_Id":61122713,"Users Score":1,"Answer":"horizontal line: plt.axhline(.5)\nTo fit a scatter plot, you can use seaborn.regplot","Q_Score":1,"Tags":"python,matplotlib,curve-fitting,data-fitting","A_Id":61122915,"CreationDate":"2020-04-09T13:50:00.000","Title":"Fitting a line of specific slope in matplotlib","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been having a problem with opening programes with python. I've been using os.system(\"file\") and os.startfile(\"file\"), but the problem is, that it uses direction of the app, and when this code goes to the other computer, the direction is not the same, as on my computer. Is it possible to open an app without writing its direction just by a name?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":61122859,"Users Score":1,"Answer":"Maybe subprocess.call is what you're looking for (assuming the path to the executable is in your global $PATH variable).","Q_Score":0,"Tags":"python,operating-system,direction","A_Id":61122972,"CreationDate":"2020-04-09T13:58:00.000","Title":"How to open an os app with python without direction?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"so i had this problem where i generated numbers from 0-1 with a step of 0.01 but the numbers have so many decimals like 0.010101010101.I only need it in the form 0.01 with two decimals.\nHow do i remove the rest of decimals ?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":61122900,"Users Score":0,"Answer":"Round num to digits places. round(num, digits)","Q_Score":0,"Tags":"python,math,decimal","A_Id":61123060,"CreationDate":"2020-04-09T14:00:00.000","Title":"Python: How do i Remove a CERTAIN amount of decimal in a float","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed anaconda on a user account under username ubuntu on a linux server running Ubuntu.\nI then created new users in my ubuntu server, called let's say ubuntu1, ubuntu2, etc.\nWhen I login as ubuntu I can do:\nconda activate <env_name> and it will activate the python environment for the user called ubuntu.\nThe environment was installed under \/home\/ubuntu\/anaconda3.  I.e., in the user local directory.\nIs there a way to make this conda environment global for all users so when I login as a different user, let's say username ubuntu1, the conda activate works and the new user is also able to use the desired anaconda and python version?\nIMPORTANT NOTE: I do not want to re-install anaconda, or create a yml file of existing anaconda and then re-install it as admin.  I would want to just use the current configuration\/installation by making it widely available to the new users.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":635,"Q_Id":61123009,"Users Score":2,"Answer":"What you can do is to set the appropriate permissions to your environment path from the existing user, and change the .bashrc file (or .profile, or whatever you use as init script in the shell) of the new user to have the conda binaries available in your $PATH.\nOf course, this may be a security risk for the user under which anaconda is installed to.","Q_Score":1,"Tags":"python,linux,ubuntu,anaconda","A_Id":61209159,"CreationDate":"2020-04-09T14:04:00.000","Title":"make local installation of anaconda available to all users w\/o having to install all again","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have prepared a time series model using FB Prophet for making forecasts. The model forecasts for the coming 30 days and my data ranges from Jan 2019 until Mar 2020 both months inclusive with all the dates filled in. The model has been built specifically for the UK market\nI have already taken care of the following:\n\nSeasonality\nHolidaying Effect\n\nMy question is, that how do I take care of the current COVID-19 situation into the same model? The cases that I am trying to forecast are also dependent on the previous data at least from Jan 2020. So in order to forecast I need to take into account the current coronavirus situation as well that would impact my forecasts apart from seasonality and holidaying effect.\nHow should I achieve this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1115,"Q_Id":61125123,"Users Score":0,"Answer":"I have had the same issue with COVID at my work with sales forecasting. The easy solution for me was to make an additional regressor which indicates the COVID period, and use that in my model. Then my future is not affected by COVID, unless I tell it that it should be.","Q_Score":1,"Tags":"python-3.x,prediction,forecasting,facebook-prophet","A_Id":68980927,"CreationDate":"2020-04-09T15:52:00.000","Title":"Python time series using FB Prophet with covid-19","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to ML and currently using Python.  If I am testing a set of interventions  on a certain outcome .  What kind of tools\/Python programs should I start learning to begin to determine which intervention (or combination of interventions) is most likely to predict a certain outcome.  \nHere is an example: I want to test which interventions promote recycling behavior most effectively (outcome is 'yes' or 'no' recycling)...different combinations of interventions will be used (i.e phone call, email reminder, text prompt, etc). I want to determine which of these interventions (or which combination of interventions) was most successful at promoting recycling \nThanks everyone and stay healthy!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":31,"Q_Id":61125226,"Users Score":1,"Answer":"\"Dimensionality reduction\" is the ML topic of reducing the number of features used to predict a response.\nFinding correlation with pandas.DataFrame.corr helps.","Q_Score":0,"Tags":"python,modeling,predictive","A_Id":61125414,"CreationDate":"2020-04-09T15:57:00.000","Title":"Determining which intervention is most predictive of outcome in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are in development of route optimization software which uses HERE Maps and we need to make the following: \n\nSome trucks can pass through all countries (they have all the licences required to pass through)\nSome need to go around specific countries, meaning, to find secondary, maybe tertiary path to reach the  destination\n\nI have two questions:\n\nIs it possible to specify which truck has what permission, so they can be passed to the solver \ncombined?\nIf not, what is the optimal way to achieve this result? Any other way around?\n\nSo far, we have tried restricting a country by blacklisting it in the HERE Maps API key, but that won't be taken in consideration by the solver. \nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":61125405,"Users Score":0,"Answer":"If I didn't misunderstand the question, I don't know if the problem is VRP or routing. \n\nIf the problem is VRP, the indication of Mizux is the correct one,\nyou just have to return in the callback the valid vehicle list for that pickup and delivery.  \nIf the problem is about routing, that is from where you are passing through, you can solve it in Nokia Here with the routing restrictions.","Q_Score":0,"Tags":"python,routing,or-tools,restrict,here-maps-rest","A_Id":62216704,"CreationDate":"2020-04-09T16:06:00.000","Title":"Setting different constrains per truck in ORTools","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are in development of route optimization software which uses HERE Maps and we need to make the following: \n\nSome trucks can pass through all countries (they have all the licences required to pass through)\nSome need to go around specific countries, meaning, to find secondary, maybe tertiary path to reach the  destination\n\nI have two questions:\n\nIs it possible to specify which truck has what permission, so they can be passed to the solver \ncombined?\nIf not, what is the optimal way to achieve this result? Any other way around?\n\nSo far, we have tried restricting a country by blacklisting it in the HERE Maps API key, but that won't be taken in consideration by the solver. \nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":61125405,"Users Score":0,"Answer":"In OR-Tools you can provide a transit callback index per vehicles so if a bunch of vehicles can't reach few locations simply return MAX_INT64 in the callback associated to these vehicles...","Q_Score":0,"Tags":"python,routing,or-tools,restrict,here-maps-rest","A_Id":61136837,"CreationDate":"2020-04-09T16:06:00.000","Title":"Setting different constrains per truck in ORTools","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python algorithm that can be parallelized fairly easily.\nI don't have the resources locally to run the whole thing in an acceptable time frame.\nFor each work unit, I would like to be able to:\n\nLaunch an AWS instance (EC2?)\nSend input data to the instance\nRun the Python code with the data as input\nReturn the result and aggregate it when all instances are done\n\nWhat is the best way to do this?\nIs AWS Lambda used for this purpose? Can this be done only with Boto3?\nI am completely lost here.\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":729,"Q_Id":61126183,"Users Score":0,"Answer":"A common architecture for running tasks in parallel is:\n\nPut inputs into an Amazon SQS queue\nRun workers on multiple Amazon EC2 instances that:\n\n\nRetrieve a message from the SQS queue\nProcess the data\nWrite results to Amazon S3\nDelete the message from the SQS queue (to signify that the job is complete)\n\n\nYou can then retrieve all the results from Amazon S3. Depending on their format, you could even use Amazon Athena to run SQL queries against all the output files simultaneously.\nYou could even run multiple workers on the same instance if each worker is single-threaded and there is spare CPU available.","Q_Score":1,"Tags":"python,multithreading,amazon-web-services,parallel-processing,cloud","A_Id":61132717,"CreationDate":"2020-04-09T16:49:00.000","Title":"Run parallel Python code on multiple AWS instances","Data Science and Machine Learning":0,"Database and SQL":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 an Google App Engine Standard (Python 3) application that I've secured behind Google IAP. This works great! But now I need a handful of web hook urls to be public, so other services can hit them, like SendGrid. Is there a solution to this that I am not seeing?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":96,"Q_Id":61127248,"Users Score":2,"Answer":"As Ahmad suggested, the solution is to have a separate App Engine service that is publicly accessible.","Q_Score":1,"Tags":"google-app-engine,google-app-engine-python,google-iap","A_Id":61191098,"CreationDate":"2020-04-09T17:54:00.000","Title":"Is it possible to protect an App Engine application with IAP while having a few public URLs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I know I can output the contents of the sklearn classification_report as a dict and extract micro\/macro averaged scores along with scores for individual labels. \nHow can I get the counts for the associated confusion matrix inputs, specifically, TP, FN, and FP that go into the computations for the macro averaged measures? I have my vectors for y_pred and y_true, so I assume there is a way to get the desired parameters I want.\nThis is for a binary classification problem, but I will also need it for a multiclass task, as well.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":181,"Q_Id":61130759,"Users Score":0,"Answer":"Got it: \ntn, fp, fn, tp = confusion_matrix([0, 1, 0, 1], [1, 1, 1, 0]).ravel()\nand sklearn.metrics.multilabel_confusion_matrix","Q_Score":0,"Tags":"python,scikit-learn,confusion-matrix","A_Id":61131420,"CreationDate":"2020-04-09T21:49:00.000","Title":"How can I extract TP, FN, FP from classification_report","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python and I am trying to import pandas but I'm getting \n\n\"ModuleNotFoundError: No module named 'pandas'\"\n\nHow can I fix this? I tried on both Python 3.8 and 3.7 and they're giving me the same error. I have Anaconda installed and I'm pretty sure pandas come with it? I have also tried pip install pandas and it gives me \n\n\"Requirement already satisfied\"\n\nPlease help me!!\nUpdate: I just got mad and deleted Anaconda. I found another way to use pandas which is by doing pip install pandas in cmd.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":402,"Q_Id":61131562,"Users Score":0,"Answer":"use python -m pip install pandas this will install the pandas with the python environment you are running your code. \none done, you can do run your program using python <program>.py\nit is better if you maintain different python version in separate virtual environments","Q_Score":0,"Tags":"python,pandas,anaconda,python-idle","A_Id":61131729,"CreationDate":"2020-04-09T22:57:00.000","Title":"Importing pandas in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This executable generation is on raspbian linux, on my raspberry-pi:\nInstall pyinstaller: (I had to try this several times, as I got the error \"http.client.RemoteDisconnected: Remote end closed connection without response\" but it suddenly worked):\n$ pip3 install pyinstaller \nIn directory with my tiny_test.py file:\n$ pyinstaller -F tiny_test.py\nThen, in the created dist folder, I tried to run the compiled executable:\n$ tiny_test\nThis gave the error:\n\"tiny_test: tiny_test: cannot execute binary file\"","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":673,"Q_Id":61131998,"Users Score":0,"Answer":"short answer:\n$ .\/tiny_test\nlong anser:\nCheck the executable file properties:\n$ file tiny_test\n\"tiny_test: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter \/lib\/ld-linux-armhf.so.3, for GNU\/Linux 3.2.0, BuildID[sha1]=ad32521ad141d04ca4fc066798301621367c7964, stripped\"\nLSB executable files need to be run like this:\n$ .\/tiny_test\nThis worked for me!","Q_Score":0,"Tags":"python,raspberry-pi,pyinstaller,executable","A_Id":61131999,"CreationDate":"2020-04-09T23:47:00.000","Title":"pyinstaller raspberry pi compiling, how to execute program from 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When opening a .hdf5 file, one can explore the levels, keys and names of the file\nin different ways. I wonder if there is a way or a function that displays all the available paths to explore in the .hdf5. Ultimately showing the whole tree.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1681,"Q_Id":61133916,"Users Score":1,"Answer":"You can also get the file schema\/contents without writing any Python code or installing additional packages. If you just want to see the entire schema, take a look at the h5dump utility from The HDF Group. There are options to control the amount of detail that is dumped. Note: the default option is dump everything. To get a quick\/small dump, use :h5dump -n 1 --contents=1 h5filename.h5.\nAnother Python pakcage is PyTables. It has a utility ptdump that is a command line tool to interrogate a HDF file (similar  to h5dump above).\nFinally, here are some tips if you want to programmatically access groups and datasets recursively in Python. h5py and tables (PyTables) each have methods to do this:\nIn h5py:\nUse the object.visititems(callable) method. It calls the callable function for each object in the tree. \nIn PyTables:\nPyTables has multiple ways to recursively access groups, datasets and nodes. There are methods that return an iterable (object.walk_nodes), or return a list (object.list_nodes). There is also a method that returns an iterable that is not recursive (object.iter_nodes).","Q_Score":2,"Tags":"python,hdf5","A_Id":61141591,"CreationDate":"2020-04-10T04:10:00.000","Title":"Is there in python a single function that shows the full structure of a .hdf5 file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Windows 7 64 bit and when I attempt to run the executable installer for Python 3.8.2 I get an error stating that I need to install windows service pack 1 to continue. I already have windows service pack 1 installed on this drive, I've double checked and reinstalled it but this has not fixed the issue.\nThis is what's in the error log:\n\n[1B0C:1AAC][2020-04-10T05:16:05]i001: Burn v3.11.1.2318, Windows v6.1\n  (Build 7601: Service Pack 1), path:\n  C:\\Users\\Admin\\AppData\\Local\\Temp{4C6C4ED2-212B-4FA8-BD34-C5891FEA4006}.cr\\python-3.8.2-amd64.exe\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'ActionLikeInstalling' to value 'Installing'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'ActionLikeInstallation' to value 'Setup'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'ShortVersion' to value '3.8'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'ShortVersionNoDot' to value '38'\n  [1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'WinVer' to value '3.8'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'WinVerNoDot' to value '38'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'InstallAllUsers' to value '0'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'InstallLauncherAllUsers' to value '1'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'TargetDir' to value ''\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'DefaultAllUsersTargetDir' to value\n  '[ProgramFiles64Folder]Python[WinVerNoDot]'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'TargetPlatform' to value 'x64'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'DefaultJustForMeTargetDir' to  value\n  '[LocalAppDataFolder]Programs\\Python\\Python[WinVerNoDot]'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'OptionalFeaturesRegistryKey' to value\n  'Software\\Python\\PythonCore[WinVer]\\InstalledFeatures'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'TargetDirRegistryKey' to value\n  'Software\\Python\\PythonCore[WinVer]\\InstallPath'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'DefaultCustomTargetDir' to value ''\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'InstallAllUsersState' to value 'enabled'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'InstallLauncherAllUsersState' to value 'enabled'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'CustomInstallLauncherAllUsersState' to value\n  '[InstallLauncherAllUsersState]'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'TargetDirState' to value 'enabled'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'CustomBrowseButtonState' to value 'enabled'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'Include_core' to value '1'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'Include_exe' to value '1'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'Include_dev' to value '1'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'Include_lib' to value '1'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'Include_test' to value '1'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'Include_doc' to value '1'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'Include_tools' to value '1'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'Include_tcltk' to value '1'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'Include_pip' to value '1'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'Include_launcher' to value '-1 '\n  [1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'Include_launcherState' to value 'enabled'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'Include_symbols' to value '0'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'Include_debug' to value '0'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'LauncherOnly' to value '0'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'DetectedLauncher' to value '0'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'DetectedOldLauncher' to value '0'\n  [1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'AssociateFiles' to value '1'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'Shortcuts' to value '1'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'PrependPath' to value '0'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'CompileAll' to value '0'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing numeric variable\n  'SimpleInstall' to value '0'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Initializing string variable\n  'SimpleInstallDescription' to value ''\n  [1B0C:1AAC][2020-04-10T05:16:05]i009: Command Line:\n  '-burn.clean.room=C:\\Users\\Admin\\Downloads\\python-3.8.2-amd64.exe\n  -burn.filehandle.attached=180 -burn.filehandle.self=188'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Setting string variable\n  'WixBundleOriginalSource' to value\n  'C:\\Users\\Admin\\Downloads\\python-3.8.2-amd64.exe'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Setting string variable\n  'WixBundleOriginalSourceFolder' to value 'C:\\Users\\Admin\\Downloads\\'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Setting string variable\n  'WixBundleLog' to value 'C:\\Users\\Admin\\AppData\\Local\\Temp\\Python\n  3.8.2 (64-bit)_20200410051605.log'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Setting string variable\n  'WixBundleName' to value 'Python 3.8.2 (64-bit)'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Setting string variable\n  'WixBundleManufacturer' to value 'Python Software Foundation'\n[1B0C:1AAC][2020-04-10T05:16:05]i000: Setting numeric variable\n  'CRTInstalled' to value 1\n[1B0C:1D88][2020-04-10T05:16:05]i000: Did not find\n  C:\\Users\\Admin\\Downloads\\unattend.xml\n[1B0C:1D88][2020-04-10T05:16:05]i000: Setting string variable\n  'ActionLikeInstalling' to value  'Installing'\n[1B0C:1D88][2020-04-10T05:16:05]i000: Setting string variable\n  'ActionLikeInstallation' to value 'Setup'\n[1B0C:1D88][2020-04-10T05:16:05]i000: Setting version variable\n  'WixBundleFileVersion' to value '3.8.2150.0'\n[1B0C:1D88][2020-04-10T05:16:05]e000: Detected Windows 7 SP1 without\n  KB2533623\n[1B0C:1D88][2020-04-10T05:16:05]e000: KB2533623 update is required to\n  continue.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1437,"Q_Id":61134051,"Users Score":0,"Answer":"I have observed that versions above 3.7.2 require more that just the SP1 update. Looking at your log files, you will find that it requires you to install the update KB2533623. Unless you fulfill the all the prerequisites for the installation, you wouldn't be able to continue with it. Install the appropriate updates as referred to by the setup\/log-file and try again. \nIt is probable that the Service Pack 1 update might have not installed properly into the system. You would need to retry installing the updates. I am afraid to tell you that official free support and updates to Windows 7 have been discontinued since the onset of 2020, so you might have a hard time finding the correct update. \nSometimes, the update unexpectedly fails to install properly. If nothings else works, the service pack version may be fixed through the registry, but at one's own risk as it might lead to consequences. \nHandling the registry is dangerous, so proceed at your own risk.\n\nOpen the registry editor.\nNavigate to HKEY_LOCAL_MACHINE\/SYSTEM\/CurrentControlSet\/Control\/Windows.\nModify the hexadecimal value of CSDVersion to 100 for SP1, 200 for SP2, and 300 to SP3.\nRestart the PC.","Q_Score":0,"Tags":"python,python-3.x,windows","A_Id":61146905,"CreationDate":"2020-04-10T04:26:00.000","Title":"Error while attempting to install Python 3.8.2 on Windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to find all the possible unique combinations out of n elements, taken m at a time. I have used itertools.combinations for the same and I have n=85.\nSo when I'm finding combinations for m=5, the number of combinations produced are about 3 cr and it is taking a lot of time, since as of now, the elements are a list of strings, or more precisely, they're columns in the alphabetical fashion, not numerical indices. I am currently working with pandas and itertools.combinations, would like to know if the process of finding combinations could be parallelised, to give same results every time upon further calculations that I perform on the columns further, or whether GPU dataframes, like cuDF might optimise this, although it doesn't look like it. Also, could converting the column names into numbers and then converting it into a numpy array to work on while finding combinations work faster? \nPlease also suggest solutions where this could be done faster in some other programming language as well. \nNot a very good programmer. Would love to see some mathematical and programmatic solutions with a complexity analysis.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":147,"Q_Id":61134347,"Users Score":1,"Answer":"This is exactly a complexity analysis problem, and there's no way to parallelize it in a way that will be satisfying. With n=85 and m=5, there are 85^5 = 4437053125 possible combinations, including reversals and duplicates.\nThe fastest way that I know of using a GPU to explore this space is with cuGraph. Exploring all 4437053125 combinations is simply a breadth first search, though even with a GPU I expect it to take a very long time. \nArtificial Intelligence is the study of methods of finding useful solutions inside of problem spaces that are too big to fully explore. A* or greedy search could give you a good solution, quickly, assuming that there is some metric that you are trying to optimize among the 85^5 total combinations.","Q_Score":0,"Tags":"python,parallel-processing,multiprocessing,combinations,cudf","A_Id":61236526,"CreationDate":"2020-04-10T05:05:00.000","Title":"Is there a faster\/optimisable way to find unique combinations from a set\/list of unique elements in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I want to run a game I programmed, I get the error message:\nModuleNotFoundError: No module named 'pygame'\nI had problems installing pygame on my iMac (OSX Catalina). I have python 3.8.\nFrom the command line I achieved installing pygame with:\npip3 install --user pygame\nSo what to next:\nCheck if I have the correct pygame version installed?\nDoes it matter where I install pygame?\nWhat could be the reason of the error message?\nMy game worked on my MacBookPro but I had to give it away because of a damage. I remember, that I had to install some different version of pygame (some development version), because I couldn't install the normal one.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":61137170,"Users Score":0,"Answer":"I could solve the problem now. python3 -m pip install --user --pre pygame=2.0.0-dev6 worked for me.","Q_Score":0,"Tags":"python-3.x,pygame,macos-catalina","A_Id":61138555,"CreationDate":"2020-04-10T09:09:00.000","Title":"wrong version of pygame installed or not installed correctly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on a introductory project for kivy. I got an error while trying to understand the concept by playing around with the codes. I would like to know what is the difference between the 2 codes below. Thank you.\nOrginal:\nsm = WindowManager(),\nsm.current = \"second\"\nCurrent:\nWindowsManager().current = \"second\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":61137960,"Users Score":0,"Answer":"method 1: you create a WindowManager instance and call it sm, then you assign the attribute current with \"second\".\nmethod 2: you create a temp WindowManager instance and assign the attribute current with \"second\". Then the temp instance will be removed by garbage collection. (i.e. nothing really happens.)","Q_Score":1,"Tags":"python,class,kivy","A_Id":61138040,"CreationDate":"2020-04-10T10:02:00.000","Title":"Difference in instantiating a Class in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use a config.py file in which I will be declaring some constants to be used in mainFile.py.\nI'll be defining these \"constant variables\" using Capital letters.\nI want to make it easier to configure the mainFile.py parameters by defining the constants only in config.py.\nOfcourse, in mainFile.py, the values of these constant are by no means altered.\nSo, my question is :\nIf in mainFile.py I use \"From config.py import *\", are the \"constant variables\" defined in config.py used as global variables in mainFile.py?\nE.g. inn functions defined within mainFile.py, do I need to re-define these variables as global in order to use them?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":61142100,"Users Score":0,"Answer":"global is required if you are modifying the imported variable in some case and you need to reflect that value on all other places where the variable is being accessed. \nsince you are just reading the value of the imported variable here, global is no required. also inside functions if any variable is read first it searches on local scope then on global scope. So no global required inside function for reading purpose.","Q_Score":0,"Tags":"python,constants","A_Id":61144139,"CreationDate":"2020-04-10T14:11:00.000","Title":"Python 3: Importing file containing variables to be used as constants","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use a config.py file in which I will be declaring some constants to be used in mainFile.py.\nI'll be defining these \"constant variables\" using Capital letters.\nI want to make it easier to configure the mainFile.py parameters by defining the constants only in config.py.\nOfcourse, in mainFile.py, the values of these constant are by no means altered.\nSo, my question is :\nIf in mainFile.py I use \"From config.py import *\", are the \"constant variables\" defined in config.py used as global variables in mainFile.py?\nE.g. inn functions defined within mainFile.py, do I need to re-define these variables as global in order to use them?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":104,"Q_Id":61142100,"Users Score":1,"Answer":"You can simply write import config, and all of your constants will be accessible to your code in mainFile.py.","Q_Score":0,"Tags":"python,constants","A_Id":61142170,"CreationDate":"2020-04-10T14:11:00.000","Title":"Python 3: Importing file containing variables to be used as constants","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my Blender script, I want to save a rendered image with bpy.ops.render.render(write_still=True). This rendered image is supposed to have a transparent background I try to set with scene.render.film_transparent=True, but it's desesperately black...\nAny idea about what I could be missing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":970,"Q_Id":61142585,"Users Score":0,"Answer":"Works much better when color mode is set to \"RGBA\" instead of \"RGB\"...","Q_Score":0,"Tags":"python,blender","A_Id":61158423,"CreationDate":"2020-04-10T14:37:00.000","Title":"Saving a rendered image with a transparent background thanks to a Python script in Blender 2.8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My program is saying that clientsocket doesn't exist. Even though it has be defined in a different subprogram (that the user has to go through). So my question is do I have to have multiple sockets?\nFrom what I can see, people usually close their sockets then make a new one, but I am wondering if I can just disconnect my socket and then connect it to a different server, this is so I can just define one socket at the start of my program.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":28,"Q_Id":61142732,"Users Score":1,"Answer":"...  but I am wondering if I can just disconnect my socket and then connect it to a different server,\n\nThis is not possible with a TCP socket. You can only connect a socket once.","Q_Score":0,"Tags":"python,sockets","A_Id":61144017,"CreationDate":"2020-04-10T14:44:00.000","Title":"Can I use one socket for the client?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In some point of debugging PyCharm, it would be useful to me to skip some lines, e.g. some lines that slows terribly my code... but I haven't found anything about this.\nDoes it exists an option in PyCharm debugger (or python debugger) to do such thing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":61143204,"Users Score":1,"Answer":"Assuming the program is paused on a breakpoint somewhere before those \"heavy lines\" - right click after them and select \"Jump To Cursor\".\nPlease note there are some limitations to this feature, e.g. one can't jump out of a function scope.","Q_Score":1,"Tags":"python,python-3.x,debugging,pycharm,ide","A_Id":61155891,"CreationDate":"2020-04-10T15:10:00.000","Title":"Skipping lines while debugging Python with PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'n new to django and I'm practicing through Django's Documentation on setting up my first project. \nAll worked well until it asked to invoke the Python shell with the command python manage.py shell\nAs a result, nothing really happens apart from showing the following text:\nPython 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n(InteractiveConsole)\nCould someone please help? I tried finding an answer in very different sources but no one has really answered it. Thank you in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":440,"Q_Id":61144697,"Users Score":1,"Answer":"That is what exactly happens. Just start typing in shell you can see the result.\nDo not expect any other screen to open.\nIf you want to exit from shell use exit() command.\nI hope that helps.\nThank you.","Q_Score":0,"Tags":"python,django","A_Id":61144874,"CreationDate":"2020-04-10T16:39:00.000","Title":"python manage.py shell nothing happening","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've searched about this but found nothing. Only opening images has documented. Maybe I can open a page as an image but I want full access on text like copy\/paste and highlighting. \nIs there any way to open a pdf within a kivy app?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1234,"Q_Id":61145384,"Users Score":1,"Answer":"This is not supported by Kivy. PDF rendering and interaction is quite complicated, I don't know how difficult it would be to implement.","Q_Score":1,"Tags":"python,pdf,kivy,kivy-language","A_Id":61146981,"CreationDate":"2020-04-10T17:22:00.000","Title":"How to open a pdf within Python Kivy app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with IBM Watson studio and am a beginner, How can I create a dashboard in Watson Studio using Python? I need some help, thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":61148549,"Users Score":0,"Answer":"You would use a Python notebook to prepare your data, i.e. create data assets in your project suitable for dashboarding, with reduced volumes.\nThen the easiest way to create a dashboard is to use the Cognos Dashboard Embedded (CDE) service.","Q_Score":0,"Tags":"python,python-3.x,ibm-watson,watson-studio","A_Id":61205992,"CreationDate":"2020-04-10T20:54:00.000","Title":"Dashboard on IBM Watson Studio for GDP Data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python language programming. I found that we can have auto completion on Jupyter notebook. I found this suggestion:\n\"The auto-completion with Jupyter Notebook is so weak, even with hinterland extension. Thanks for the idea of deep-learning-based code auto-completion. I developed a Jupyter Notebook Extension based on TabNine which provides code auto-completion based on Deep Learning. Here's the Github link of my work: jupyter-tabnine.\nIt's available on pypi index now. Simply issue following commands, then enjoy it:)\npip3 install jupyter-tabnine,\njupyter nbextension install --py jupyter_tabnine,\njupyter nbextension enable --py jupyter_tabnine,\njupyter serverextension enable --py jupyter_tabnine\"\nI did 4 steps installation and it looked installed well. However, when I tried using Jupyter notebook its auto completion didn't work. Basically my question is please help how to get auto completion on Jupiter notebook? Thank you very much.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7721,"Q_Id":61149238,"Users Score":1,"Answer":"After installing Nbextensions, go to Nbextensions in jupyter notebook, tick on Hinterland. Then reopen your jupyter notebook.","Q_Score":2,"Tags":"python,jupyter-notebook,jupyter","A_Id":69249186,"CreationDate":"2020-04-10T21:53:00.000","Title":"How to get auto completion on jupyter notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python language programming. I found that we can have auto completion on Jupyter notebook. I found this suggestion:\n\"The auto-completion with Jupyter Notebook is so weak, even with hinterland extension. Thanks for the idea of deep-learning-based code auto-completion. I developed a Jupyter Notebook Extension based on TabNine which provides code auto-completion based on Deep Learning. Here's the Github link of my work: jupyter-tabnine.\nIt's available on pypi index now. Simply issue following commands, then enjoy it:)\npip3 install jupyter-tabnine,\njupyter nbextension install --py jupyter_tabnine,\njupyter nbextension enable --py jupyter_tabnine,\njupyter serverextension enable --py jupyter_tabnine\"\nI did 4 steps installation and it looked installed well. However, when I tried using Jupyter notebook its auto completion didn't work. Basically my question is please help how to get auto completion on Jupiter notebook? Thank you very much.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":7721,"Q_Id":61149238,"Users Score":3,"Answer":"Press tab twice while you are writing your code and the autocomplete tab will show for you. Just select one and press enter","Q_Score":2,"Tags":"python,jupyter-notebook,jupyter","A_Id":61149391,"CreationDate":"2020-04-10T21:53:00.000","Title":"How to get auto completion on jupyter notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a binary image containing a single contiguous blob, with no holes. I would like create a polygon object based on the exterior edges of the edge pixels. I know how to get the edge pixels themselves, but I want the actual coordinates of the pixel boundaries, sorted clockwise or counter-clockwise. All of the pixels have integer coordinates. \nFor example, say I have a single pixel at (2,2). The vertices of the polygon would be:\n(2.5, 2.5)\n(2.5, 1.5)\n(1.5, 1.5)\n(1.5, 2.5)\n(2.5, 2.5)\nIs there an exact, non-approximate way to do this? Preferably in Python?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2436,"Q_Id":61149402,"Users Score":0,"Answer":"Based on the comments, here is the approach that I implemented:\n\nmultiply all pixel coordinates by 10, so that we'll only deal with integers.\n\nFor each pixel, generate the 4 corners by adding +\/- 5. For example, for (20,20), the corners are (25, 25) (25, 15) (15, 15) (15, 25) (25, 25). And store all the corners in a list.\n\nCount the occurrences of each corner. If the count is odd, it is a corner to the blob. Making the coordinates integers makes this step easy. Counting floats has issues.\n\nDivide the blob corner coordinates by 10, getting back the original resolution.\n\nSort the corners clockwise using a standard algorithm.","Q_Score":1,"Tags":"python,image,image-processing,polygon,scikit-image","A_Id":63367126,"CreationDate":"2020-04-10T22:10:00.000","Title":"Get pixel boundary coordinates from binary image in Python (not edges)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing something that essentially refines and reports various strings out of an enormous python dictionary (the source file for the dictionary is XML over a million lines long).\nI found mongodb yesterday and was delighted to see that it accepts python dictionaries easy as you please... until it refused mine because the dict object is larger than the BSON size limit of 16MB.\nI looked at GridFS for a sec, but that won't accept any python object that doesn't have a .read attribute.\nOver time, this program will acquire many of these mega dictionaries; I'd like to dump each into a database so that at some point I can compare values between them.\nWhat's the best way to handle this?  I'm awfully new to all of this but that's fine with me :) It seems that a NoSQL approach is best; the structure of these is generally known but can change without notice. Schemas would be nightmarish here.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":61149473,"Users Score":0,"Answer":"Have your considered using Pandas? Yes Pandas does not natively accept xmls but if you use ElementTree from xml (standard library) you should be able to read it into a Pandas data frame and do what you need with it including refining strings and adding more data to the data frame as you get it.","Q_Score":2,"Tags":"python,database","A_Id":61149842,"CreationDate":"2020-04-10T22:16:00.000","Title":"What's the best strategy for dumping very large python dictionaries to a database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing something that essentially refines and reports various strings out of an enormous python dictionary (the source file for the dictionary is XML over a million lines long).\nI found mongodb yesterday and was delighted to see that it accepts python dictionaries easy as you please... until it refused mine because the dict object is larger than the BSON size limit of 16MB.\nI looked at GridFS for a sec, but that won't accept any python object that doesn't have a .read attribute.\nOver time, this program will acquire many of these mega dictionaries; I'd like to dump each into a database so that at some point I can compare values between them.\nWhat's the best way to handle this?  I'm awfully new to all of this but that's fine with me :) It seems that a NoSQL approach is best; the structure of these is generally known but can change without notice. Schemas would be nightmarish here.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":61149473,"Users Score":0,"Answer":"So I've decided that this problem is more of a data design problem than a python situation.  I'm trying to load a lot of unstructured data into a database when I probably only need 10% of it.  I've decided to save the refined xml dictionary as a pickle on a shared filesystem for cool storage and use mongo to store the refined queries I want from the dictionary.  \nThat'll reduce their size from 22MB to 100K.\nThanks for chatting with me about this :)","Q_Score":2,"Tags":"python,database","A_Id":61218273,"CreationDate":"2020-04-10T22:16:00.000","Title":"What's the best strategy for dumping very large python dictionaries to a database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i've got selenium to run and hit 2 sub categories via the X PATH already which are buttons and now i keep receiving the error above here again - \nole=\"button\">... is not clickable at point (555, 55). Other element would receive the click: ...\n  (Session info: chrome=80.0.3987.163)\nmy code looks like this \n\"#More Faq page sub-categories\ntime.sleep(3)\nWaysToWatch = driver.find_element_by_xpath('\/\/*[@id=\"main\"]\/div\/div\/section\/div\/div[2]\/a')\nWaysToWatch.click()\n\"#Set-pin - THIS ONE DOESN'T WANT TO WORK \ntime.sleep(5)\nSetPin = driver.find_element_by_xpath('\/\/*[@id=\"main\"]\/div\/div\/section\/div\/div[3]\/a')\nSetPin.click()\nI would appreciate a fix as I have quite a few of these I need to run through","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":61149695,"Users Score":0,"Answer":"driver.find_element_by_tag_name('body').send_keys(Keys.HOME) \nUse send_keys(Keys.HOME) to scroll up to the top of page","Q_Score":1,"Tags":"python,selenium-webdriver","A_Id":61247397,"CreationDate":"2020-04-10T22:40:00.000","Title":"Python how to click multiple sub categories, get this error button\">... is not clickable at point (555, 55) Other element would receive the click","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i have a question when using the Button widget in tkinter. I am new to this.\nI noticed that when we use the command in the Button widget, sometimes we call a simple function just like that and sometimes we use lambda function and then we call it. What is the difference?\nFor example: tk.Button(window, text = \"Click Me!\", command = myfunction)\ntk.Button(win,text=\"Result\",command=lambda: result(en1.get())\nCant we just use it without lambda?\nTHank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":936,"Q_Id":61150428,"Users Score":1,"Answer":"Use of lambda:\n\nThe parentheses are the main reason that the function gets executed when given as command to a Button without lambda. If the function(which you are passing to the Button as a command) has no parameters(to be passed to itself), then you can simply pass it as a command avoiding the parentheses(). And hence you don't need to use lambda in this case. Like in this Example:command=func.\n\nSo using lambda is only necessary when the function has its own parameters(to be passed to itself).Like in this  Example:command=lambda:func(a,b,c)\n\n\nWhat lambda Does:\n\nWhen you have to pass arguments to the function itself you have cannot avoid parentheses().\nSo in the case of buttons, lambda basically delays the execution of the function until the user clicks the button, by creating another function on the spot, which does not get called until the button is actually clicked. Hence the function does not get executed, where it is given as command to the Button.\n\nAny Questions will be answered.","Q_Score":1,"Tags":"python,button,tkinter","A_Id":61156251,"CreationDate":"2020-04-11T00:02:00.000","Title":"Difference between using or not lambda function in python tkinter button command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed opencv 4.3.0 from the source. It was installed sucessfully. \npkg-config --modversion opencv4 gives the output 4.3.0 . But when i try to import cv2 module in pythone it says cv2 module not found. I have Linux(Debian) in my system with python 3.8.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":187,"Q_Id":61152549,"Users Score":0,"Answer":"Likely has to do with where the package was installed. If you used apt-get, I would recommend removing and trying with pip install opencv-python. Aside from that, you can also try running sudo python3 and then importing.\nhope that helps!","Q_Score":0,"Tags":"python,linux,opencv","A_Id":61152598,"CreationDate":"2020-04-11T05:34:00.000","Title":"Python could not detect OpenCv installed in my system","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm looking for a command to pick the last element of my matrix that is nonzero. Not the index of the value, but the actual value.\nIt's a (1001,50001) matrix where the last value of each column isn't the same.\nIt is not a dataframe, so preferably a numpy command.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":61153359,"Users Score":0,"Answer":"I have a suggestion for that. Replace all non-zero values of your column with 1. Then find the last element that is equal to 1. That would be easy even using Unix using grep '1' file | tail -1 , etc. If however you are not allowed to modify the matrix values then you need to just extract this column and run the scripts for this column only. Good luck.","Q_Score":2,"Tags":"python,numpy","A_Id":61153604,"CreationDate":"2020-04-11T07:23:00.000","Title":"Python: Select last value of each column that is nonzero in a matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Windows10 and my python version 3.6.5\nIts giving me error 'win32api'\nimport win32com.client\nTraceback (most recent call last):\nFile \"\", line 1, in \nimport win32com.client\nFile \\Programs\\Python\\Python36-32\\lib\\site-packages\\win32com__init__.py\", line 5, in \nimport win32api, sys, os\nModuleNotFoundError: No module named 'win32api'\npypiwin32 is already installed","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":130,"Q_Id":61153515,"Users Score":0,"Answer":"It seems we need to restart the Python shell after installing the package pypiwin32. After restarting the shell, it worked.","Q_Score":0,"Tags":"python,python-3.x","A_Id":61154944,"CreationDate":"2020-04-11T07:39:00.000","Title":"ModuleNotFoundError for 'win32api' even pypiwin32 is installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I finished writing the code for a simple game using Kivy. I am having a problem converting it to Android APK, since I am using a windows computer. From some earlier research I got to know that using a Virtual machine is recommended, but I have no idea on how to download and use one :(, and if my slow PC can handle it... please help me. If possible, kindly recommend another  way to  convert to APK.\nI am a beginner at coding as a whole, please excuse me if my question is stupid.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":61156256,"Users Score":0,"Answer":"you could just try downloading a virtual box and installing linux operating system or you could directly install it and keep it a drive called F or E and you could just install python on that and all the required pakages and start the build using buildozer as it is not available for windows. So try doing it. But I need to do it just now. Tell me after you have tried that cuz there are a lot of people online on youtube who would heloo you doing that work","Q_Score":0,"Tags":"python,android,kivy,virtual-machine","A_Id":63098290,"CreationDate":"2020-04-11T11:45:00.000","Title":"Packaging Kivy application to Android - Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a CSV file containing multiple columns(almost 100). How can I filter multiple columns at once using certain criteria in Python? To be more precise, many of the columns are of no use to me. How can the file be filtered?\nPS: I am a beginner user.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1168,"Q_Id":61156308,"Users Score":0,"Answer":"You can parse the csv file as pandas dataframe and then play around. Please have a look at the pandas documentation on how to read csv files. You can extract the column you want based on their header names. Also you can apply mathematical operations in a fast way. Though, for large scale calculations, note that python is not suitable since each time you import your libraries.","Q_Score":1,"Tags":"python,pandas,dataframe","A_Id":61156355,"CreationDate":"2020-04-11T11:49:00.000","Title":"Deleting multiple columns of CSV files based on certain conditions on Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Normally, I know tuple can be used as\n(email, username) = ('hello', 'user')\nthat email will be equal to hello\nBut I am wondering if I can do something like\n(email, username) = request.user so I do  not have to keep on typing request.user and instead just use email and username like how javascript works.\nif I did the above, I would get an error saying TypeError: object is not iterable\nThanks in advance for any suggestions and advices.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":56,"Q_Id":61156904,"Users Score":1,"Answer":"The destructuring mechanism in python works with a \"positional\" manner (as you have used it in (email, username) = ('hello', 'user').\nIt does not work in a \"named\" manner, as you have tried in (email, username) = request.user, as javascript do.","Q_Score":1,"Tags":"javascript,python,django,destructuring","A_Id":61158166,"CreationDate":"2020-04-11T12:35:00.000","Title":"possible to use tuple, deconstruct with request.user, django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've a dataframe in-memory which has certain identifiers, using those identifiers i want to fetch only relevant data from a very large(500M rows) table persisted in a RDBMS(Sql server).\nWhat's the best way to do this? Definitely don't want to bring the entire table in-memory. And can't loop through either. If it was single column key to lookup, I could still think of building a comma-separated string and doing IN clause against that list but I've multiple fields that are identifiers.\nOnly option I see is saving dataframe into db, doing join on db server and bringing in data back. But seems so clunky. \nI've read about dask as an option, but not really sure about that one because bringing  entire table in-memory\/disk still doesnt seem like an efficient technique to me","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":85,"Q_Id":61157467,"Users Score":1,"Answer":"Only option I see is saving dataframe into db, doing join on db server and bringing in data back. But seems so clunky.\n\nThis sounds like the most efficient option in terms of compute time.\n\nI've read about dask as an option, but not really sure about that one because bringing entire table in-memory\/disk still doesnt seem like an efficient technique to me\n\nIf your dataframe with the entries that you care about is small then Dask Dataframe probably won't read everything into memory at once.  It will likely scan through your database intelligently in small space.  The real cost of using Dask here is that you need to move data in and out of the database, which will be slow or fast depending on your database connector.\nI would try it out, and see how it performs.","Q_Score":0,"Tags":"python,sql,sql-server,pandas,dask","A_Id":61164672,"CreationDate":"2020-04-11T13:23:00.000","Title":"Joining in-memory dataframe with very large persisted table in a db?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"when clicking \"Run Python file in terminal\" how do I stop the script? the only way that I found is by clicking the trashcan which deletes the log in the terminal.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":250,"Q_Id":61158465,"Users Score":0,"Answer":"When a Python file is running in the terminal you can hit Ctrl-C to try and interrupt it.","Q_Score":0,"Tags":"python,python-3.x,visual-studio,visual-studio-code,vscode-settings","A_Id":61239622,"CreationDate":"2020-04-11T14:36:00.000","Title":"How to stop vscode python terminal without deleting the log?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Following is the configuration:\n1.Python - Python 3.8.1 (tags\/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32\n2.MS Access 2016 MSO(16.0.12624.20348) 64 bit\n3.Microsoft Access Driver (*.mdb, *.accdb) 16.00.4513.1000\n4.Installed Microsoft Access Database Engine 2016 Redistributable\nFacing the error while trying to create a connection:\nimport pyodbc\nconn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\\Users\\tejas\\Documents\\First.accdb;')\ncursor = conn.cursor()\nError:\nTraceback (most recent call last):\n  File \"C:\\Users\\tejas\\eclipse-workspace\\HelloWorld\\DB\\Insert.py\", line 3, in \n    conn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\\Users\\tejas\\Documents\\First.accdb;')\npyodbc.Error: ('HY000', '[HY000] [Microsoft][ODBC Microsoft Access Driver] The database you are trying to open requires a newer version of Microsoft Access. (-1073) (SQLDriverConnect); [HY000] [Microsoft][ODBC Microsoft Access Driver] The database you are trying to open requires a newer version of Microsoft Access. (-1073)')\nI have gone through other similar questions and tried various options but no luck so far. Any help would be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":696,"Q_Id":61158715,"Users Score":0,"Answer":"I found this because I added a table to a MS Access database and set one of the fields to \"Large Number\".  This broke my connection with pyodbc, and consequently my python scripts which write to this database.  I had no way to revert the file.\nI fixed it by creating a new database and importing all the old tables that didn't have any Large Number fields.  I then was able to simply copy and paste the queries and forms over to the new database file.  It seems to work fine now with the new file.  I've learned by lesson and won't be assigning \"large number\" to anything soon in MS Access.\nThanks!","Q_Score":0,"Tags":"python,python-3.x,ms-access,odbc,pyodbc","A_Id":62536343,"CreationDate":"2020-04-11T14:52:00.000","Title":"Connect Python to Access 2016: \"database ... requires a newer version of Microsoft Access\"","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning object detection using R-CNN...\nI have the images and the annotation file which gives the bounding box for the object\nI understand these steps in R-CNN,\nUsing selective search to get the proposed regions\nMake all the region same size\nFeed those images in CNN \nSave the feature maps and feed to SVM for classification\n\nIn training, I took all the objects (only the objects from images not the background) and feed to the CNN and then train the feature maps in SVM for classification.\nIn every blogs, all are saying in R-CNN, there are three parts, \n1st -selective search\n2nd -CNN\n3rd -BBox Regression\nBut, I don't get the deep explanation of the BBox Regression.\nI understand the IOU(Intercept over Union) to check the BBox accuracy.\nCould you please help me to learn how this BBox Regression is used to get the coordinates of the object.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":93,"Q_Id":61161451,"Users Score":0,"Answer":"To explain about the BBox regression working which is as mentioned below.  \nLike you mentioned it happens in multiple stages.\n\nSelective Search:\n\nGenerate initial sub-segmentation, we generate many candidates or part regions.\nUse greedy algorithm to recursively combine similar regions into larger ones.\nUse the generated regions to produce the final candidate region proposals.  \n\nCNN and BBox Regression:  \nThe regressor is a CNN with convolutional layers, and fully connected layers, but in the last fully connected layer, it does not apply sigmoid or softmax, which is what is typically used in classification, as the values correspond to probabilities. Instead, what this CNN outputs are four values (,,\u210e,), where (,) specify the values of the position of the left corner and (\u210e,) the height and width of the window. In order to train this NN, the loss function will penalize when the outputs of the NN are very different from the labelled (,,\u210e,) in the training set.","Q_Score":0,"Tags":"python,tensorflow,keras,conv-neural-network","A_Id":61714240,"CreationDate":"2020-04-11T18:04:00.000","Title":"Clarification in R-CNN","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was just wondering how to go from mvnrnd([4 3], [.4 1.2], 300); in MATLAB code to np.random.multivariate_normal([4,3], [[x_1 x_2],[x_3 x_4]], 300) in Python. \nMy doubt namely lays on the sigma parameter, since, in MATLAB, a 2D vector is used to specify the covariance; whereas, in Python, a matrix must be used. \nWhat is the theoretical meaning on that and what is the practical approach to go from one to another, for instance, in this case? Also, is there a rapid, mechanical way?\nThanks for reading.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1622,"Q_Id":61163753,"Users Score":0,"Answer":"Although python expects a matrix, it is essentially a symmetric covariance matrix. So it has to be a square matrix. \nIn 2x2 case, a symmetric matrix will have mirrored non diagonal elements.\nI believe in python, it should look like [[.4 1.2],[1.2 .4]]","Q_Score":1,"Tags":"python,matlab,covariance,normal-distribution","A_Id":61163964,"CreationDate":"2020-04-11T21:09:00.000","Title":"python equivalent to matlab mvnrnd?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When i am trying to attach results using create_test_result_attachment api, getting error message \"msrest.exceptions.ClientRequestError: Error occurred in request., RetryError: HTTPSConnectionPool(host='dev.azure.com', port=443): Max retries exceeded with url: \/itron\/4fc412f1-9337-4c85-8aaf-7955d066a31c\/_apis\/test\/Runs\/3878830\/Results\/100000\/Attachments (Caused by ResponseError('too many 500 error responses',))\"\ncode:\nreport ='\/\/home\/\/shweta\/\/Desktop\/\/test.html'\nwith open(report, 'rb') as f:\nencoded_string = base64.b64encode(f.read()).decode('ascii') test_client = self.connection.get_client(TEST_CLIENT)\nTest_Attachment_Request_Model={\n'attachment_type': 'GeneralAttachment',\n'comment': 'attach report',\n'file_name': report,\n'stream': encoded_string\n}\nres = test_client.create_test_result_attachment(Test_Attachment_Request_Model, project, run_id, test_case_result_id)\nprint(res)\nError: msrest.exceptions.ClientRequestError: Error occurred in request., RetryError: HTTPSConnectionPool(host='dev.azure.com', port=443): Max retries exceeded with url: \/itron\/4fc412f1-9337-4c85-8aaf-7955d066a31c\/_apis\/test\/Runs\/3878830\/Results\/100000\/Attachments (Caused by ResponseError('too many 500 error responses',))","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":61164468,"Users Score":0,"Answer":"Able to resolve it.. Issue was with file_name. Instead of passing report, needed to extract the html file and it worked. Added code: filename = Path(report).name with open(report, 'rb') as f: encoded_string = base64.b64encode(f.read()).decode('ascii') test_client = self.connection.get_client(TEST_CLIENT) Test_Attachment_Request_Model={ 'attachment_type': 'GeneralAttachment', 'comment': 'attach report', 'file_name': filename, 'stream': encoded_string }","Q_Score":0,"Tags":"azure-devops,automated-tests,python-3.6,azure-devops-rest-api","A_Id":61169513,"CreationDate":"2020-04-11T22:22:00.000","Title":"Can't add an attachment in a result of run using create_test_result_attachment for v6.0 api","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to implement a UDF through xlwings, from an existent python script which implements win32com.client.\nThe script is successful if ran from shell, but fails with an \"Automation error\" if called from the correspondent UDF.\nThrough debug I found that the error arises from trying to set a new value for sel_range.Interior.Color, where sel_range is a Range object from the active worksheet (from win32com.client).\nIn particular the exception is raised from Python38-32\\Lib\\site-packages\\win32com\\client\\__init__.py, line 482, when trying to call self._oleobj_.Invoke(*(args + (value,) + defArgs)).\nComparing the run from shell and the one from UDF, all the objects and arguments are the same.\nUnfortunately I can not debug further within the Invoke, and I am just starting with COM objects.\nDoes anyone has an idea what the issue could be?\nWhy the Invoke of the oleobj has such a different behavior?\nThe base script is entirely based on win32com, and from xlwings I use just the add in with the xw.func decorator.\nEDIT\nI found out that this is indeed a desired behavior of xlwings, and ranges are not settable within UDF.\nIs there any workaround? Something equivalent.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":144,"Q_Id":61164971,"Users Score":1,"Answer":"Since it seems to be a major Excel design, I moved the logic of my function to be a macro, and assign it to a button.","Q_Score":0,"Tags":"python-3.x,excel,com,xlwings","A_Id":61202429,"CreationDate":"2020-04-11T23:29:00.000","Title":"python within excel with xlwings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I did the pip install through the terminal but when I import TensorFlow in IDLE or any .py file It  can't find the tf module.. How do I download TF such that I can use it in IDLE to code?\nIf it makes a difference I'm using a MacBook Air","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":61168042,"Users Score":0,"Answer":"I am assuming IDLE means IDE here.\nGenerally you should able to use teansorflow as soon as you have executed pip install tensorflow.\nCan you provide detail of IDE, and what error you are getting while importing tensorflow in IDE.\nPlease check below:\n-> Have you run command pip install tensorflow and it was executed successfully.\n-> Have you imported tensorflow in .py file with import tensorflow as tf.","Q_Score":0,"Tags":"python,tensorflow","A_Id":63203006,"CreationDate":"2020-04-12T07:18:00.000","Title":"Unable to use TensorFlow in python IDE","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written my code in python3 and solved it using Gekko solver.\nAfter 10000 iterations, I am getting the error maximum iteration reached and solution not found.\nSo can I get the value of decision variables after the 10000th iteration?\nI mean even when the maximum iteration is reached the solver must have a value of decision variable in the last iteration. so I want to access that values. how can I do that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":607,"Q_Id":61173168,"Users Score":0,"Answer":"Question:\n1) I am solving an MINLP problem with APOPT Solver. And my decision variables are defined as integer. I have retrieved the result of 10,000th iteration as you suggested. but the Decision variables values are non-integer. So why APOPT Solver is calculating a non-integer solution? \nAnswer:\nThere is an option on what is classified as an integer. The default tolerance is any number within 0.05 of an integer value. \nyou can change this by:\nm.solver_options = ['minlp_integer_tol 1']\n2) I am running the code for \"m.options.MAX_ITER=100\" and using m = GEKKO() i.e. using remote server. But my code is still running for 10000th iterations.\nAnswer: Can do it alternatively by:\nm.solver_options = ['minlp_maximum_iterations 100']\nThanks a lot to Prof. John Hedengren for the prompt replies.\nGekko","Q_Score":2,"Tags":"python,python-3.x,nonlinear-optimization,gekko","A_Id":61247855,"CreationDate":"2020-04-12T14:40:00.000","Title":"how to get value of decision variable after maximum iteration limit in gekko","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to download pygame, but knowing I am running on Anaconda, I tried to pass by their site.\nI saw that I had to use the command \"conda install -c pygame\", it didn't work.\nI tried conda install -c Jo_Byr cogsci pygame (Jo_Byr is my username on Anaconda), didn't work either.\nThen it was turn of conda install -c jonat cogsci pygame (jonat is my computer username), and all variants with jonat, Jo_Byr or none as username and pygame or cogsci pygame for the package, but nothing worked.\nI can send screenshots of the anaconda prompt cmd if necessary, just tell me which one.\nThanks in advance, sorry if someone already spoke of this issue, I didn't find anything about it.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":61174858,"Users Score":0,"Answer":"I have had this problem before. I tried many commands but no results I got. then I downloaded pygame file separately and install it via cmd or terminal.these files are usually with an extension of .whl or wheel. just google it and find all the libraries u need.","Q_Score":0,"Tags":"python,pygame,anaconda","A_Id":61175036,"CreationDate":"2020-04-12T16:43:00.000","Title":"Pygame and Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use Keras EarlyStopping however whenever I try to use restore_best_weights it comes up with an error:\n_init_() got an unexpected keyword argument 'restore_best_weights'\nI am using the most up to date Keras so I'm really unsure why this is happening.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":61174910,"Users Score":0,"Answer":"What version of Keras are you using?\nIf you still do use Keras 2.3.1, please do ensure that your are not mixing keras and tensorflow versions.\nMore precisely, avoid using imports like from keras.layers import Conv2D and from tensorflow.keras.layers import MaxPool2D.\nIf the problem still persists after this issue, please use all the imports from tensorflow, i.e. from tensorflow.keras import .....\nAvoid using the plain Keras package, as it will become obsolete in the foreseeable future; the additional problem is that is nowhere near as well maintained as keras inside tensorflow.\nYou can uninstall it altogether from your environment.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,keras,early-stopping","A_Id":61184943,"CreationDate":"2020-04-12T16:46:00.000","Title":"restore_best_weights issue Keras EarlyStopping","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The main question is to find which leaf node each sample is classified. There are thousands of posts on using tree.apply. I am well aware of this function, which returns the index of the leaf node.\nNow, I would like to add the leaf index in the nodes of the graph (which I generate by using Graphviz).\nDrawing the enumeration technique used for the indexes won't work. The decision tree that I am developing is quite big. Therefore, I need to be able to print the leaf index in the graph.\nAnother option that I am open to is to generate an array with all the leaf indexes (in the same order) of the leaf nodes of the decision tree. Any hint on how to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":455,"Q_Id":61175533,"Users Score":0,"Answer":"There is a parameter node_ids of the command export_graphviz. When this parameter is set to True, then the indexes are added on the label of the decision tree.","Q_Score":0,"Tags":"python,scikit-learn,decision-tree","A_Id":61177431,"CreationDate":"2020-04-12T17:33:00.000","Title":"How to find the index of each leaf or node in a Decision Tree?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using classes and such to make a calculator in Tkinter, however I want to be able to be able to reuse widgets for multiple windows. How can I do this if this is possible?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":124,"Q_Id":61176189,"Users Score":0,"Answer":"As you commented:\n\nI'm making a calculator, as mentioned and I want to have a drop down menu on the window, that when selected it closes the root window and opens another, and I want to have the drop down menu on all the different pages, 5 or 6 in all\n\nIn this case, just write a function that creates the menu.\nThen call that function when creating each of the windows.","Q_Score":0,"Tags":"python-3.x,tkinter","A_Id":61181898,"CreationDate":"2020-04-12T18:23:00.000","Title":"Is it possible to reuse a widget in Tkinter? If so, how can I do it using classes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using classes and such to make a calculator in Tkinter, however I want to be able to be able to reuse widgets for multiple windows. How can I do this if this is possible?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":124,"Q_Id":61176189,"Users Score":1,"Answer":"A widget may only exist in one window at a time, and cannot be moved between windows (the root window and instances of Toplevel).","Q_Score":0,"Tags":"python-3.x,tkinter","A_Id":61176580,"CreationDate":"2020-04-12T18:23:00.000","Title":"Is it possible to reuse a widget in Tkinter? If so, how can I do it using classes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed the module alpha_vantage using pip. In CMD writing import alpha_vantage does not show an error message, so I assume it is installed properly. \nHowever, when trying to import alpha_vantage in a python program I get this error: \"ModuleNotFoundError: No module named 'requests'\". I assume the issue is due to the location of the module.\nThe project is located here:\nC:\\Users\\M\\Documents\\Python\\Investering.\nI tried placing the module here by pip: C:\\Users\\M\\Documents\\Python\\Investering\\modules\\alpha_vantage\nNote pip did not install the module there I simply copied the module folder and placed them in the project folder. \nIs it possible to simply copy and paste module folders in other projects? Or how am I supposed to make python acknowledge the module? \nThe module was installed here:\nC:\\Users\\M\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\site-packages\\alpha_vantage\nI'm quite new to python. I have tried adding to sys.path the folder where the module was installed, but it did not seem to help. \nThanks for any help. \nEdit: I tried pip install requests and it produced this: \nRequirement already satisfied: requests in c:\\users\\martin\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\nSomeone mentioned running: \"pip install foo\"\nIt, however, produces this error message: \nERROR: Could not find a version that satisfies the requirement foo (from versions: none) ERROR: No matching distribution found for foo\nI am using PyCharm.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":225,"Q_Id":61177266,"Users Score":0,"Answer":"I found my error. I had installed python from the website, but had unknowningly installed the 32 bit version, and a 64 bit version. I uninstalled all my python versions and pycharm. Then I reinstalled everything. Now I could easily make the module work. Thanks for the pointers.","Q_Score":0,"Tags":"python,module","A_Id":61190478,"CreationDate":"2020-04-12T19:51:00.000","Title":"ModuleNotFoundError using pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am facing an unusual use-case with React and Django. My process starts with a POST request initiated by an app running on user's system to my Django server(The response is displayed on the browser). The POST request contains the data required for authenticating the user. Once authenticated, the server returns a simple HTML page customized for that user, including the details necessary to authenticate subsequent requests(like form submissions). Now I need to replace that simple HTML page with a react application. The problem is how can I embed the user specific info into the react app when returning the react app from server, so that I don't have to ask user to provide authentication information again once application loads on browser. Is this even possible while using react?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":61177747,"Users Score":0,"Answer":"Considering that you returns properties of user from server side, you could use React to render the components into the page conditionally, based on the properties that was received from server side.","Q_Score":1,"Tags":"python,django,reactjs,single-page-application,server-side-rendering","A_Id":61178387,"CreationDate":"2020-04-12T20:30:00.000","Title":"React SPA with initial state\/route, served from Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can you show me how I can multiply two integers which are M bits long using at most O(N^1.63) processors in O(N) parallel time in python.\nI think that karatsuba algorithm would work but I don't understand how can I implement it parallely.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":53,"Q_Id":61179665,"Users Score":-1,"Answer":"Yes, It is parallel karatsuba algorithm.","Q_Score":0,"Tags":"python,multithreading,parallel-processing,distributed-computing","A_Id":61179928,"CreationDate":"2020-04-12T23:48:00.000","Title":"Distributed computing for multiplying numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to generate a connected, undirected graph that contains n vertices and m edges. In particular, I want to generate a graph with nodes that contain exactly one of each integer from 0 to n - 1.\nI've looked somewhat deeply on this site and could not find what I was looking for. I will appreciate any help offered. Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":116,"Q_Id":61181627,"Users Score":2,"Answer":"I don't know about existing libraries but this is a solution from scratch. Suppose you have n nodes and m edges. To generate a simple (no duplicate edge), connected graph, m, n must satisfy this condition: \nn - 1 <= m <= n * (n - 1) \/ 2\nProcess (nodes are indexed from 0 to n - 1):\n\nGenerate a spanning tree to make sure the graph is connected. There are many ways (for example, Prufer sequence), but here is a simple way:\n\nfor i = 1 to n - 1:\n     add_edge(i, randint(0, i - 1))\n\nTo make it look more random, you can shuffle the order of nodes first.\n\nAdd more edges until you have m edges.\n\nwhile there are less than m edges:\n     a, b = randint(0, n - 1), randint(0, n - 1)\n     if (a != b and edge(a, b) has not existed):\n        add_edge(a, b)\n\nNote: randint(a, b) = a random integer in range [a, b].\nThe codes look simple but work very fast in practice. You can calculate expected number of iterations to see why.","Q_Score":0,"Tags":"python,algorithm,graph-algorithm","A_Id":61198390,"CreationDate":"2020-04-13T04:40:00.000","Title":"How do I make a function that accepts numVertices and numEdges then ALWAYS generates a connected graph?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The environment variables are cleared when you exit the terminal and it is required that we need to set them again when we launch the terminal.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":45,"Q_Id":61182525,"Users Score":1,"Answer":"In vs code using bash in Ubuntu, if that is the case, look for setting the env variables in the .bash_profile so that it remembers the variables even after the terminal program is closed.","Q_Score":0,"Tags":"python,flask,visual-studio-code,terminal","A_Id":61182557,"CreationDate":"2020-04-13T06:24:00.000","Title":"Set environment variables in FLASK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I entered '''idle''' on terminal\nand it only shows me python2 that has already been here.\nHow can i see python3 idle on my mac \nwhile i installed python3 with pip?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":61183792,"Users Score":0,"Answer":"you can specify the version\nidle3","Q_Score":0,"Tags":"python,pip,python-idle","A_Id":61184026,"CreationDate":"2020-04-13T08:07:00.000","Title":"how can i find IDLE in my mac though i installed my python3 with pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"What is actually the difference between using unit tests and normal tests? \nBy normal tests I mean, using the if statement for example to determine if the calculation is equal to the desired answer if it returns false, we can raise AssertionError","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1683,"Q_Id":61183855,"Users Score":0,"Answer":"For quality control. If you are coding an app called \"app1\" with a function f1 and an other function f2 (f2 is using f1) inside you own library\nWithout unit test:\nYou can make a change in function f1 test it, it will work in f2 but you will not notice that in you program \"app0\" you wrote 2 weeks ago it will make you app crash because in your old app \"app0\" you  have a function f3 and f3 is also using f1....\nWith unit test:\nYou can catch that type of nasty bug because the test for the function f3 will not pass anymore and you IDE will tell you that when you change the function f1 in \"app1\"\nI hope it make sense (english is not my native language)","Q_Score":0,"Tags":"python,python-3.x,unit-testing,python-unittest","A_Id":61185695,"CreationDate":"2020-04-13T08:12:00.000","Title":"Difference between using unit test and doing tests normally 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 have some text data for which I need to do sentiment classification. I don't have positive or negative labels on this data (unlabelled). I want to use the Gensim word2vec model for sentiment classification.\nIs it possible to do this? Because till now I couldn't find anything which does that?\nEvery blog and article are using some kind of labelled dataset (such as imdb dataset)to train and test the word2vec model. No one going further and predicting their own unlabelled data.\nCan someone tell me the possibility of this (at least theoretically)?\nThanks in Advance!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6071,"Q_Id":61185290,"Users Score":0,"Answer":"as Lahiru mention if we downloaded any data, it dont have labelled data. so we need to label it. Either manually one by one by a person and than verify it else use some other library like sentiwordnet or textblob to level it.","Q_Score":6,"Tags":"python-3.7,gensim,word2vec,sentiment-analysis","A_Id":63155902,"CreationDate":"2020-04-13T09:52:00.000","Title":"Is it possible to do sentiment analysis of unlabelled text using word2vec model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get input from the user and send this input to all bot subscribers.\nso I need to save his input in variable and use it after this in send_message method but I don't know how to make my bot wait for user input and what method I should use to receive user input \nthanks :]","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":61185980,"Users Score":0,"Answer":"If you want to get an user input, the logic is a bit different. I suppose you are using longpolling.\nWhen the bot asks the user for input, you can just save a boolean\/string in a global variable, let's suppose the variable is user_input:\nYou receive the update, and ask the user for input, then you set user_input[user's id]['input'] = true\nThen when you receive another update you just check that variable with an if (if user_input[userid]['input']: # do something).\n\nIf your problem is 403 Forbidden for \"user has blocked the bot\", you can't do anything about it.","Q_Score":1,"Tags":"python,input,telegram,chatbot,telegram-bot","A_Id":61230604,"CreationDate":"2020-04-13T10:32:00.000","Title":"how i ask for input in my telegram chat bot python 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":"Using Python 3.7 with IDLE, on Mac.  I want to be able to monitor key presses and immediately return either the character or its ASCII or Unicode value.  I can't see how to use pynput with Idle.  Any ideas please?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":61186084,"Users Score":0,"Answer":"You can't.  IDLE uses the tkinter interface to the tcl\/tk GUI framework.  The IDLE doc has a section currently title 'Running user code' with this paragraph.\n\nWhen Shell has the focus, it controls the keyboard and screen.  This is normally transparent, but functions that directly access the keyboard and screen will not work.  These include system-specific functions that determine whether a key has been pressed and if so, which.","Q_Score":0,"Tags":"macos,python-3.7,keypress,python-idle,getch","A_Id":61891827,"CreationDate":"2020-04-13T10:39:00.000","Title":"How to monitor key presses in Python 3.7 using IDLE on Mac OSX","Data 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":"working on self driving car cnn model to compute the steer with the speed by taking the pervous speed sequences.when we implemented the model the first loss is huge but it decreases.So does matter the start of the loss is huge.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":61187990,"Users Score":0,"Answer":"It does not. If you are starting training your net from scratch then the network will predict pretty poorly so it's normal that the loss will be very high.","Q_Score":1,"Tags":"python,keras,carla","A_Id":61188055,"CreationDate":"2020-04-13T12:33:00.000","Title":"Does it matter if i started training of my keras model with a big value of the loss function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install OpenCV into my python environment (Windows), and I'm almost all of the way there, but still having some issues with autocomplete and Pycharm itself importing the library. I've been through countless other related threads, but it seems like most of them are either outdated, for prebuilt versions, or unanswered.\nI'm using Anaconda and have several environments, and unfortunately installing it through pip install opencv-contrib-python doesn't include everything I need. So, I've built it from source, and the library itself seem to be working fine. The build process installed some things into .\/Anaconda3\/envs\/cv\/Lib\/site-packages\/cv2\/: __init__.py, some config py files, and ...\/cv2\/python-3.8\/cv2.cp38-win_amd64.pyd. I'm not sure if it did anything else.\nBut here's where I'm at:\n\nIn a separate environment, a pip install opencv-contrib-python both runs and has autocomplete working\nIn this environment, OpenCV actually runs just fine, but the autocomplete doesn't work and Pycharm complains about everything, eg: Cannot find reference 'imread' in '__init__.py'\nInvalidate Caches \/ Restart doesn't help\nRemoving and re-adding the environment doesn't help\nDeleting the user preferences folder for Pycharm doesn't help\nRebuilding\/Installing OpenCV doesn't help\nFile->Settings->Project->Project Interpreter is set correctly\nRun->Edit Configuration->Python Interpreter is set correctly\n\nSo my question is: how does Pycharm get or generate that autocomplete information? It looks like the pyd file is just a dll in disguise, and looking through the other environment's site-packages\/cv2 folder, I don't see anything interesting. I've read that __init__.py has something to do with it, but again the pip version doesn't contain anything (except there's a from .cv2 import *, but I'm not sure how that factors in). The .whl file you can download is a zip that only contains the same as what 'pip install' gets.\nWhere does the autocomplete information get stored? Maybe there's some way to copy it from one environment to another? It would get me almost all the way there, which at this point would be good enough I think. Maybe I need to rebuild it with another flag I missed?","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":835,"Q_Id":61190224,"Users Score":4,"Answer":"Alternatively add the directory containing the .pyd file to the interpreter paths.\nI had exactly this problem with OpenCV 4.2.0 compiled from sources, installed in my Conda environment and PyCharm 2020.1.\nI solved this way:\n\nSelect project interpreter\nClick on the settings button next to it and then clicking on the Show paths for selected interpreter\nadding the directory containing the cv2 library (in my case in the Conda Python library path - e.g. miniconda3\/lib\/python3.7\/site-packages\/cv2\/python-3.7). In general check the site-packages\/cv2\/python-X.X directory)","Q_Score":1,"Tags":"python,opencv,pycharm,anaconda,conda","A_Id":61281004,"CreationDate":"2020-04-13T14:37:00.000","Title":"OpenCV built from source: Pycharm doesn't get autocomplete information","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install OpenCV into my python environment (Windows), and I'm almost all of the way there, but still having some issues with autocomplete and Pycharm itself importing the library. I've been through countless other related threads, but it seems like most of them are either outdated, for prebuilt versions, or unanswered.\nI'm using Anaconda and have several environments, and unfortunately installing it through pip install opencv-contrib-python doesn't include everything I need. So, I've built it from source, and the library itself seem to be working fine. The build process installed some things into .\/Anaconda3\/envs\/cv\/Lib\/site-packages\/cv2\/: __init__.py, some config py files, and ...\/cv2\/python-3.8\/cv2.cp38-win_amd64.pyd. I'm not sure if it did anything else.\nBut here's where I'm at:\n\nIn a separate environment, a pip install opencv-contrib-python both runs and has autocomplete working\nIn this environment, OpenCV actually runs just fine, but the autocomplete doesn't work and Pycharm complains about everything, eg: Cannot find reference 'imread' in '__init__.py'\nInvalidate Caches \/ Restart doesn't help\nRemoving and re-adding the environment doesn't help\nDeleting the user preferences folder for Pycharm doesn't help\nRebuilding\/Installing OpenCV doesn't help\nFile->Settings->Project->Project Interpreter is set correctly\nRun->Edit Configuration->Python Interpreter is set correctly\n\nSo my question is: how does Pycharm get or generate that autocomplete information? It looks like the pyd file is just a dll in disguise, and looking through the other environment's site-packages\/cv2 folder, I don't see anything interesting. I've read that __init__.py has something to do with it, but again the pip version doesn't contain anything (except there's a from .cv2 import *, but I'm not sure how that factors in). The .whl file you can download is a zip that only contains the same as what 'pip install' gets.\nWhere does the autocomplete information get stored? Maybe there's some way to copy it from one environment to another? It would get me almost all the way there, which at this point would be good enough I think. Maybe I need to rebuild it with another flag I missed?","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":835,"Q_Id":61190224,"Users Score":4,"Answer":"Got it finally! Figures that would happen just after posting the question...\nTurns out ...\/envs\/cv\/site-packages\/cv2\/python-3.8\/cv2.cp38-win_amd64.pyd needed to be copied to ...\/envs\/cv\/DLLs\/. Then PyCharm did it's magic and is now all good.","Q_Score":1,"Tags":"python,opencv,pycharm,anaconda,conda","A_Id":61192749,"CreationDate":"2020-04-13T14:37:00.000","Title":"OpenCV built from source: Pycharm doesn't get autocomplete information","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I built a CNN audio classifier with 3 classes. My problem is that their are more than 3 classes, e.g. a fourth could be \"noise\". \nSo when I call be prediction the sum of these 3 classes is always 1.\nprediction = model.predict([X])\nIs it somehow possible to extract the accuracy of each class so the sum of these accuracies is less then 1?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":61196194,"Users Score":1,"Answer":"If you use a softmax activation function you are forcing the outputs to sum to 1, thereby making a relative confidence score between your classes. Perhaps, without knowing more about your data and application, a \"1 vs all\" type scheme would work better for your purposes. For example, each class could have a sigmoid activation function and you could pick the highest prediction but if that prediction doesn't score high enough on a sensitivity threshold then none of the classes are predicted and as such is empty or implicitly \"noise.\"","Q_Score":1,"Tags":"python,keras,classification,conv-neural-network","A_Id":61196438,"CreationDate":"2020-04-13T20:28:00.000","Title":"CNN audio classifier trained with 3 classes and the sum of the prediction should be less than one","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to coding, and I think I messed up with pip... Can someone help me with this?\nI am using Macbook, version 10.15.2.\nI think I tried alias? I can't remember... \nBut I don't have trouble with pip with bash.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":426,"Q_Id":61196768,"Users Score":0,"Answer":"I came across the same problem I spent weeks trying to solve it and refused to reinstall macOS.\n1) The cause of the problem\n\nYou have installed different distribution of python\n\n2) Solution\n\nOpen Terminal\nWrite cd ~\nThen write 'vim .zshrc'\nPress i set the pip and python alias and remove any-other alias (in my case I set it to be conda)\n\n***NOTE I HAVE REMOVED EVERY PYTHON DISTRIBUTION EXCEPT FOR PYTHON 2.7 AND ANACONDA ***","Q_Score":0,"Tags":"python,macos,pip","A_Id":66581591,"CreationDate":"2020-04-13T21:06:00.000","Title":"pip --version zsh: no such file or directory: usr\/local\/bin\/pip3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have encrypted my text files using AES encryption in Python using Crypto. When I open the encrypted file in notepad, I see a bunch of Chinese characters and a few weird symbols.\nWhy does the encryption keep producing Chinese characters?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":766,"Q_Id":61198234,"Users Score":1,"Answer":"It probably is interpreting the data as UTF-8. UTF-8 can contain any character or code point defined by the Unicode consortium. That you are getting manny \"Chinese\" characters is because you are pretty likely to create an UTF-8 escape for using multiple bytes per character, and because there are many more Asian characters than Western characters.\nIf you want to see \"text\" then you should encode using base 64. However, files are perfectly fine as binary containing any value of byte. So for the computer \/ for decryption you're better off leaving the file binary. Ciphertext is meant to be unreadable; there is absolutely no reason to try and \"read\" it anyway.","Q_Score":0,"Tags":"python,encryption,pycrypto","A_Id":61198909,"CreationDate":"2020-04-13T23:09:00.000","Title":"Why does AES encryption in Crypto produce chinese characters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Someone was reviewing my code and told me to use the .copy() function when copying a pandas dataframe into another variable. My code was like this:\ndata1 = pd.DataFrame()\ndata1[['Country\/Region','Province\/State','Lat','Long']]=confirmed[['Country\/Region','Province\/State','Lat','Long']]\nI copied the dataframe into another dataframe like this:\ndata2 = data1 and was working alright. Alright means, data1 is not being changed when I work on the data2. So, I am guessing it is ok. I am using Jupyter Notebook.\nShould I stick to using it in the future or use .copy()?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":970,"Q_Id":61199216,"Users Score":0,"Answer":"toking, normally if you say data2=data1 it passes to data2 the reference (a pointer) to data1. Thus when you make changes to data2 you really making them on data1. In your case, however, you already allocated memory to your data2, thus data1[['Country\/Region','Province\/State','Lat','Long']]=confirmed[['Country\/Region','Province\/State','Lat','Long']] code copies the content to the allocated memory. But it is generally a good practice to use .copy(deep=True) if you want to avoid confusion. Cheers","Q_Score":0,"Tags":"python,pandas","A_Id":61199445,"CreationDate":"2020-04-14T01:08:00.000","Title":"How to properly copy a pandas dataframe into another variable?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering if there was an algorithm I could find or a data structure that I could use that would enable me to efficiently randomly pair two sets of data with each other. \nInitially, I searched for an algorithm\/data structure that would do this for me, but it was to no avail, most likely because I do not know the exact terms to search for. Currently, I'm using the randint() function from the random library in python to implement my own type of algorithm, however, I'm worried if there may be issues with it not being random enough.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":130,"Q_Id":61200425,"Users Score":0,"Answer":"With the information you have provided in the question, my approaches would be as follows:\nApproach 1:\nLets say you have 2 datasets A and B and an indexing operator [], you could use randint to generate 2 random numbers a and b and pair A[a] with B[b]. Here the advantage is you can bootstrap as many times you want to generate a dataset as big as you want.\nApproach 2:\nAs @Mark Meyer suggested in the comments, shuffle the 2 datasets separately, and then pair each data point.","Q_Score":0,"Tags":"python,random","A_Id":61200595,"CreationDate":"2020-04-14T03:49:00.000","Title":"Randomly match items in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to classify English words according to topics with python? Such as  THE COUNTRY AND GOVERNMENT:  regime, politically, politician, official, democracy......besides, there are other topics: education\/family\/economy\/subjects and so on.\nI want to sort out The Economist magazine vocabularies and classify these according to frequency and topic. \nAt present, I have completed the words frequency statistics, the next step is how to classify these words automatically with python?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":61203802,"Users Score":0,"Answer":"It sounds quite tough to handle it. Also it is not a simple task. If I were you, I consider 2 ways to do what you ask.\n\nMake your own rule for it\n\nIf you complete counting the words, then you should match those word to topic. There is no free lunch. Make own your rule for classifying category. e.g. Entertainment has many \"TV\" and \"drama\" so If some text has it, then we can guess it belongs to Entertainment.\n\nMachine learning.\n\nIf you can't afford to make rules, let machine do it. But even in this case, you should label the article with your desired class(topics).\nUnsupervised pre-training(e.g. clustering) can also be used here. but at last, we need supervised data set with topics.\nYou should decide taxonomy of topics.\n\n\nWelcome to ML world.\nHope it helps to get the right starting point.","Q_Score":0,"Tags":"python","A_Id":61204040,"CreationDate":"2020-04-14T08:45:00.000","Title":"How to classify English words according to topics with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is 5000 vectors in 1x721 dimension. These vectors are transformed by wavelet transformation to 5000 images with 9x721 dimension in MATLAB. The question is in which format these images should be saved in MATLAB to be used in Keras Python (Spyder) as a two dimension CNN?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":61209722,"Users Score":0,"Answer":"PNG is a lossless image format so it would be perfect for storing your data in images, which can then be read into Python and used by Keras for your CNN","Q_Score":0,"Tags":"python,image,matlab,keras,format","A_Id":61229943,"CreationDate":"2020-04-14T14:09:00.000","Title":"Which format should I use to save my images in MATLAB?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What would be the bast way to make a GUI for Sudoku? I already made a GUI in Pygame with: buttons, number input to cell, grid display; but it doesn't feel right to draw grid and buttons 30 times per second even when nothing is changing. Is there any better way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":61209811,"Users Score":0,"Answer":"The safest course is to re-paint the screen, even at 30fps\/when nothing is changing. \nSecondly, will modifying the code actually make a difference to the load on the PC?\nThe theme seems to be: if the Sudoku board hasn't changed, why bother? So, put the screen-update 'behind' the same condition which examines input. If the user instructs that a digit is to be inserted in a chosen-square (for example), and thus the appearance of the board is to be changed, then after updating the graphic(s)\/sprite positions, the logic must call for a screen-update! \nThis will be slightly more complicated if you have also changed the mouse-pointer and must update the mouse's appearance as it is moved!\nBefore you do this, monitor the PC's performance graphs, then perform a Before-After analysis. It'll be interesting to read the results...\nRegards =dn","Q_Score":0,"Tags":"python-3.x,user-interface,pygame","A_Id":61219365,"CreationDate":"2020-04-14T14:13:00.000","Title":"Python GUI for sudoku","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using python 3.8.1 and now been coding for a bit with PyCharm and wanted to download PyGames and the problem that I'm facing is that with command prompt \"pip\" command I get error: No Python at 'C:...\\PYTHON\\python.exe'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":61210447,"Users Score":1,"Answer":"A short explanation: \nin Pycharm you need first to configure your python path in order to both run your code and both for use any python command (i.e. pip which is actually python.exe -m pip <your command> ).\nSeem like you configured it under 'C:...\\PYTHON\\python.exe'\nYou need to change it  in the following way: \nGo to File | Settings | Project: <your_project_name> | Project Interpreter\nand there:\nin setting icon pick \"add\" -> and add your python env.","Q_Score":0,"Tags":"python,python-3.x,pycharm,command-prompt","A_Id":61211817,"CreationDate":"2020-04-14T14:44:00.000","Title":"Command prompt having trouble finding python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a very short python-function (using pyautogui) which entails the following:\n\nMove the mouse to the taskbar and click on a certain location within that taskbar, this \"reopens\" a certain program. \nThen, within the opened program go to some location (moveTo...)\n\nNow, I have noticed the following odd behavior: The first step always works, i.e. the specific program window is appears on the screen. However, depending on the specific program the second step either works or goes wrong. More specifically, I noticed that for notepad it works (i.e. the cursor moves to the specified location), whereas for a different program the mouse does not move at all.\nCan anyone shed some light onto this behavior?\nThank you very much for your help!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2397,"Q_Id":61211006,"Users Score":0,"Answer":"it seems like the program is overwriting the script as a security method.\ncould you try and convert the code into exe file and run as an admin. this should overwrite the program.","Q_Score":1,"Tags":"python,pyautogui","A_Id":61537741,"CreationDate":"2020-04-14T15:08:00.000","Title":"pyautogui mouse click not working in certain programs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sorry for answering my own question, but I've seen this crop up in multiple forums, so I wanted to post this in hope it helps someone else.  \nThe basic problem occurs when trying to run Ansible against older Python interpreters -- particularly Python 2.6 on RedHat 5 -- and getting error messages about 'libselinux bindings not available' or similar errors. \nWhile this could happen for any Python-based application, I see it most commonly on Ansible.  Ansible presumes the selinux module is available and will always attempt to import it at runtime.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3398,"Q_Id":61211678,"Users Score":1,"Answer":"I would have liked to post this as a comment to the @crankyeldergod's answer (as his response lead me to figure out my fix to this issues) but I don't have enough posts to comment yet.\nI also kept receiving the \"Aborting, target uses selinux but python bindings (libselinux-python) aren't installed!\" error despite having the libselinux-python packages installed.  I went into \/usr\/lib64 and checked the python directories I found there until I located the one with selinux files present.  I made note of that version of python and declared it explicitly in my inventory file, ie - ansible_python_interpreter=\/usr\/bin\/python3.6 in my case and that resolved the issue.","Q_Score":0,"Tags":"python,ansible,libselinux","A_Id":70644703,"CreationDate":"2020-04-14T15:42:00.000","Title":"libselinux-python bindings and ansible","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've installed the package Pillow outside the virtual environment created using pipenv. But when I try to make migrations for my django project in this environment, it says Pillow is not installed and asks to install it. I think I installed pillow globally but it is not accessible by the pipenv virtual environment. I'm using python 3.8 and use sublime3 as editor.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1118,"Q_Id":61211746,"Users Score":1,"Answer":"Packages installed globally are not available in a virtual environment.\nYou can install django using command python -m pip install Django.\nList all installed packages available using pip list.","Q_Score":3,"Tags":"python,django,sublimetext3,pipenv,virtual-environment","A_Id":61350103,"CreationDate":"2020-04-14T15:45:00.000","Title":"I installed a package outside virtual environment but cannot use it in the virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am building an ensemble of models and need to do hyperparameter selection on 126 different models ranging from linear models to keras model with each taking 4-18 hours to run.\nI plan to do that on google colab as i do not have enough computing resources. \nShould i open 126 google accounts and train all of the models in parallel using 126 colab CPUs \/ GPUs. Or should i open 126 colab notebooks on the same account and run the models there. Will the 126 notebooks share the same resources or will each notebook have access to separate CPUs.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2805,"Q_Id":61211864,"Users Score":2,"Answer":"The amount of usable GPU and RAM on Colab is limited on Colab. You can try out how many scripts you can run at the same time and could start using other accounts after that. Note that inactive sessions in Colab will be closed.\nI personally would try to find a way involving less computational power. Google Colab has got a limited amount of hardware available, and using it too much might result in other users not being able to use a GPU. Also, abusing its capacities could result in a ban for you.","Q_Score":2,"Tags":"python,google-colaboratory","A_Id":61212062,"CreationDate":"2020-04-14T15:52:00.000","Title":"Training Multiple Models in Google Colab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building an ensemble of models and need to do hyperparameter selection on 126 different models ranging from linear models to keras model with each taking 4-18 hours to run.\nI plan to do that on google colab as i do not have enough computing resources. \nShould i open 126 google accounts and train all of the models in parallel using 126 colab CPUs \/ GPUs. Or should i open 126 colab notebooks on the same account and run the models there. Will the 126 notebooks share the same resources or will each notebook have access to separate CPUs.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2805,"Q_Id":61211864,"Users Score":0,"Answer":"Please note that even if Google Colab is free to use it does not provide you full access to resources with the base plan. For this reason, the second approach would not work since you got just a single high-end GPU and a single CPU-core.\nYou could try creating multiple Google accounts but pay attention that according to Colab's policy, they encourage interactive sessions over batch ones, so you could end up with your training stopped after a few hours.\nI personally suggest you try a different approach, maybe trying to use less computational power changing the model or introducing new factors (in this case I suspect that weight decay should help you to merge similar models into single ones).","Q_Score":2,"Tags":"python,google-colaboratory","A_Id":61212108,"CreationDate":"2020-04-14T15:52:00.000","Title":"Training Multiple Models in Google Colab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose we're writing a CPython extension module in C.\nWhen defining an extension, we are required to supply a PyMODINIT_FUNC PyInit_<module_name>(void). Nowhere in this declaration is a native calling convention specified.\nWhether on Linux or on Windows, how can the extension developer ensure that the PyInit_ function is compiled using the correct calling convention, so that the interpreter calls it successfuly during runtime? Is there some magic in the Python headers that takes care of this for us? Or something else?\nThe same question applies to native functions contained in the extension module, and exposed to Python wrapped as function objects. How do we ensure that these are compiled in a manner compatible with the Python interpreter calling convention?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":219,"Q_Id":61213535,"Users Score":2,"Answer":"The default calling convention is automatically made by the compiler. PyMODINIT_FUNC is either void (in Python 2) or PyObject * (in Python 3), nothing more.\nThe Python dynamic module loader uses the default convention of the platform (not that it has any jurisdiction over that; it's to the platform).","Q_Score":1,"Tags":"c,cpython,calling-convention","A_Id":61213901,"CreationDate":"2020-04-14T17:19:00.000","Title":"How is a C extension compiled with the correct native calling convention?","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 currently working on computer vision program that will stitch images together. I use KAZE algorithm for finding keypoints and describe them. Than I use Brute-force matcher to match them. From this stage I am ready to stitch them I think because I know which point belongs where right? Because I am studing some literature etc. I see they always match keypoints and then use RANSAC which is random? Why use Ransac when I already know which keypoint belong to which done through brute-force matching?\nThank you for answers and have a nice day","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":368,"Q_Id":61214309,"Users Score":0,"Answer":"RANSAC (and variants) is an algorithm used to robustly fit to the matched keypoints to a mathematical model of the transformation (\"warp\") from one image to the other, for example, a homography. The keyword here is \"robustly\": the algorithm tries really hard to identify a large (ideally, the largest) set of matching keypoints that are acceptable, in the sense they agree with each other on supporting a particular value of the model. \nThis is done because matched pair of keypoints may be \"wrong\", either because the matching algorithm screws up (think left eye matched to right eye), or because the matching is correct, but it does not conform to the model (think matches on the same point of a moving car when the two images are taken some time apart). These wrong matches, or \"outliers\", can (and usually do) throw off the model estimate when the estimation procedure is not robust.","Q_Score":0,"Tags":"python,computer-vision,image-stitching,keypoint,ransac","A_Id":61236312,"CreationDate":"2020-04-14T18:06:00.000","Title":"Why we need to use RANSAC when we already match keypoints?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am finding a TemplateDoesNotExist at\/ error when running a Django project in local host using python manage.py runserver). The django app works perfectly in my development machine (Windows 10). The error is in the deployment server machine (Windows Server 2016).  \nAny idea of what can be wrong having same Project code, Django and Python versions?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":61216939,"Users Score":0,"Answer":"Changed Python version from Python 3.6.7 to Python 3.6.8 and it worked OK!","Q_Score":0,"Tags":"python,windows,django-templates","A_Id":61236141,"CreationDate":"2020-04-14T20:46:00.000","Title":"Django Template does not exist: Same code and software in different machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My objective is to produce a Sankey diagram in plotly (in Python) that does not have all terminal nodes justified on the right. My data is such that certain flows have only one or two intermediate nodes and others have many intermediate nodes. I would like for short flows to be highlighted by visibly terminating before reaching the right edge of the graph. As far as I can tell, there is not currently a way to do this. \nHowever, I thought that a workaround might be to just include dummy nodes and links in my data as needed and either set their visibility to False or make them completely transparent. But so far I have only found visibility and transparency\/opacity approaches that apply to the entire graph.\nSo, is there any way to do any of the following:\n\nleft-justify a Sankey diagram (best option)\nchange visibility of individual nodes\/links (good enough)\nchange transparency of individual nodes\/links (also good enough)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":564,"Q_Id":61217749,"Users Score":0,"Answer":"For any nodes that you want to be \"left-aligned\" (i.e. end before reaching the farthest left of the page)....\nGive these nodes a path to the most \"right-aligned\" terminal node, but set the color of the path to fully transparent #00000000. This should do the trick.","Q_Score":0,"Tags":"python,graph,plotly,data-visualization,sankey-diagram","A_Id":63867476,"CreationDate":"2020-04-14T21:43:00.000","Title":"Possible to hide specific nodes in plotly Sankey diagram?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My favourite editor by far is PyCharm, mainly because I am most comfortable with Python.\nI am subscribed to the professional package, but I am interested in picking up some C \/ C++.\nCLion by default is paid, except for a 30 day trial. This is for personal use at the moment and picking up several suites could be too costly for me.\nI have had a look around the net for information of the real differences between the Jetbrains ides, but cannot find anything concise (maybe I am just struggling to summarise my search with the correct keywords).\nAnyway, how different are the various Jetbrains ides?\nIs it just a matter of the same ide, different default settings and plugins?\nCan i replace PyCharm with CLion altogether?\nAny advice would be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":132,"Q_Id":61219918,"Users Score":1,"Answer":"The different JetBrains IDEs are very similar and have the same look and basic features(Live Templates, code completion, etc.). You can even export your pycharm settings to CLion so that you retain your keymaps, color scheme, and other settings. There is a PyCharm Community Edition plugin which is available for CLion.","Q_Score":1,"Tags":"python,c++,c,pycharm,clion","A_Id":61275800,"CreationDate":"2020-04-15T01:35:00.000","Title":"Can substitute PyCharm Professional for CLion - primarily for python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have a CSV file of weather stations that have a class (class 1 being the most reliable data to class 3 being the worst). I then have distances from the closest weather station to each county. I am attempting to eliminate station-county relationships that might have unreliable data i.e(class 3 station far from a county). \nI am struggling to come up with a very general way to do this. \nI tried assigned weight to the classes i.e (class 1 = 1, class 2 = .5, class 3 = .1) and then multiplying by distance but that then brings the issue of a close station to a low class give an unreliable read.\nIf anyone has any thoughts or suggestions on this it would be much appreciated!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":61220291,"Users Score":0,"Answer":"I don\u2019t think you want to use weights here. Unless you have a robust statistic for reliability that applies to all stations, just assigning arbitrary weightings based on class does not sound reasonable.\nHow about using a simpler approach? Break the distances from the counties to their weather stations into three categories:\n\nNear, say < 50 mi \/ 80 km\nMedium distance, say 50 mi to 100 mi\nFar, say > 100 mi\n\n(Note, these distances are most likely not right for your data set. You\u2019ll have to play around with them to get something appropriate.)\nThen, have a matrix of class x distance and discard whichever combinations make sense. It might be that Medium x Class 3 is bad but Far x Class 2 is okay.","Q_Score":0,"Tags":"python,algorithm","A_Id":61220514,"CreationDate":"2020-04-15T02:23:00.000","Title":"How to weight a piece of data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have a CSV file of weather stations that have a class (class 1 being the most reliable data to class 3 being the worst). I then have distances from the closest weather station to each county. I am attempting to eliminate station-county relationships that might have unreliable data i.e(class 3 station far from a county). \nI am struggling to come up with a very general way to do this. \nI tried assigned weight to the classes i.e (class 1 = 1, class 2 = .5, class 3 = .1) and then multiplying by distance but that then brings the issue of a close station to a low class give an unreliable read.\nIf anyone has any thoughts or suggestions on this it would be much appreciated!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":29,"Q_Id":61220291,"Users Score":1,"Answer":"If you want higher weights to have higher significance, and you want longer distance to be associated with a lower weight you should use a decreasing function of the distance as a weight, not an increasing one, as you indicated.\nIn Physics, a fair share of quantities decreases with the inverse of the squared distance, so I would recommend you use that as a weighting: divide by the distance squared instead of multiplying by the distance.\nThe decreasing weighting for decreasing class of reliability is just fine.\nOf course, the actual scaling and the choice of the weighting function could be investigated further. For example, would: dividing by the cube of the distance, using different values for weighting the classe, etc. be better for your problem? This is something that we cannot easily investigate without further information.","Q_Score":0,"Tags":"python,algorithm","A_Id":61220419,"CreationDate":"2020-04-15T02:23:00.000","Title":"How to weight a piece of data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my login First place I wanted to send OTP and second place I wanted to verify the OTP and then return the token.\nI am using rest_framework_simplejwt JWTAuthentication. First place I am verifying the user and sending the OTP, not returning the token and second place I am verifying the OTP and returning the token.\nLet me know If this is the correct way to use? If not how can I implement this using JWTAuthentication.\nOR If this is not correct way to use, can I implement like first place use Basic authentication to verify the user and second place jwt authentication to verify the OTP and send the tokens. Let me know your solution.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":231,"Q_Id":61222312,"Users Score":0,"Answer":"What I understood?\nYou need to send an OTP to the current user who is hitting your send_otp route after checking if the user exists or not in your system and then verify_otp route which will verify the OTP that the user has sent in the API alongwith it's corresponding mobile_number\/email_id.\nHow to do it?\n\nsend_otp - Keep this route open, you don't need an authentication for this, not even Basic Auth (that's how it works in industry), just get the mobile_number from the user in the request, check whether it exists in the DB, and send the OTP to this number, and set the OTP to the corresponding user in your cache maybe for rechecking (redis\/memcache). Use throttling for this route so that nobody will be able to exploit this API of yours.\nverify_otp - This route will also be open (no authentication_class\/permission_classes), get the mobile_number\/email id + OTP from the user, verify it in cache, if verified, generate the token using TokenObtainPairSerializer and send the refresh + access token in the response, if the OTP is incorrect, send 401.","Q_Score":1,"Tags":"django,python-3.x,django-rest-framework,jwt,django-rest-framework-jwt","A_Id":61266385,"CreationDate":"2020-04-15T06:06:00.000","Title":"Can I use JWTAuthentication twice for a login authentication?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to do build in Developer Command Prompt of VS 2019 using Python script.\nHere is piece of code i'm using:\nimport os\nos.system('start \/wait C:\/Windows\/System32\/cmd.exe  \"msbuild C:\/Users\/Desktop\/Project\/Project.sln\"')\nos.system(\"pause\") \nBut it is not working.Developer command prompt is appearing for just 1sec and disappearing .\nWhen i took variable to check if command was succesful or not ,it is giving variable result as zero,which means command is successful but i'm not able to see it in Developer command prompt.\nresult= os.system('start \/wait C:\/Windows\/System32\/cmd.exe \/k ipconfig')\nprint (result)\nWhereas when i'm trying the same command in windows command prompt it's working fine.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2327,"Q_Id":61225873,"Users Score":0,"Answer":"How to run a command in Developer command prompt 2019 using Python\n\nDeveloper command prompt 2019 is a tool which is integrated into VS2019 IDE and provides environment parameters for various development modules.\nHowever, the CMD.exe does not have these environment variables for these, so you cannot just use CMD.exe directly. Sorry that I am not familiar with python code and script. I suggest you could configure Developer command prompt 2019 into System environment variable PATHand then call cmd.exe which integrates the related variables to build your projects without any errors.\nSuggestion\nFirst, if you build your project on another new agent, you should install one of tool from step 1.\n1) If you install VS2019 IDE in your local agent,please make sure that your local agent has VS2019 IDE and install the related workload about your project type.\nBesides, if you install Build Tool for VS2019, please also install the related workload.\n2) set the below path under System environment variable PATH \nVS2019 IDE: \nC:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\nBuild Tool for VS2019:\nC:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\MSBuild\\Current\\Bin\n3) Then you can call your python script as you described to build your projects.\nAny feedback and concern will be expected.","Q_Score":0,"Tags":"python-3.x,visual-studio-code,msbuild,visual-studio-2019","A_Id":61242030,"CreationDate":"2020-04-15T09:53:00.000","Title":"How to run a command in Developer command prompt 2019 using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am relatively new to Python so please pardon my ignorance. I want to know answer to following questions\n\nHow does pip know the location to install packages that it installs? After a built of trial and error \nI suspect that it maybe hardcoded at time of installation.\nAre executables like pip.exe what they call frozen binaries? In essence, does it mean that pip.exe will run without python. Again after a bit of trial and error i suspect that it requires a python installation to execute.\n\nP.S: I know about sys.prefix,sys.executable and sys.exec_prefix. If there is anything else on which the questions i asked on depends, pls link me to same.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":164,"Q_Id":61226690,"Users Score":1,"Answer":"PIP is a package manager for Python packages, or modules if you like.\npip when used with virtualenv will generally install packages in the path \/lib\/\/site-packages.\nFor example, I created a test virtualenv named test, and the django folder is in test\/lib\/python3.7\/site-packages\/django.\nAt the time of installation, you must have set up environment variables, and that is how pip recognizes directories.","Q_Score":1,"Tags":"python,pip,python-packaging,pythoninterpreter","A_Id":61226876,"CreationDate":"2020-04-15T10:38:00.000","Title":"Do executables like pip.exe require python to work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on coding a Python IDE in Python. I have set up my program to be able to open files when the user clicks on the 'open' button in my 'file' menu. This allows the user to edit files once they have opened the IDE program.\nHowever, I am wondering if it is possible to give python and text files the option to \"open with\" or \"edit with\" my application when they are right clicked in file explorer instead of from my program.\nI hope this question makes sense; it is quite difficult to phrase.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":20,"Q_Id":61226835,"Users Score":0,"Answer":"No you can't. The function \"open with\" is managed by the OS so you can not change this setting without run some code before or asking the user to modify this setting before.","Q_Score":0,"Tags":"python,file,ide,file-handling,text-editor","A_Id":61231388,"CreationDate":"2020-04-15T10:45:00.000","Title":"Giving files the option to be opened with a python-coded application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run pytype on a project but I keep getting the error CRITICAL Could not find a valid python3.5 interpreter in path (found Python 2.7.17). However, I have python3 installed. I also have an alias alias python=\"python3\".\n\npython -V - Python 3.6.9\npython3 -V - Python 3.6.9\npython2 -V - Python 2.7.17\n\nHow can I run pytype?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":286,"Q_Id":61227414,"Users Score":0,"Answer":"I got this error when running pytype in a directory with a setup.cfg containing python_version = 3.5. Temporarily removing setup.cfg fixed it for me.","Q_Score":0,"Tags":"python,python-3.x,pytype","A_Id":65509444,"CreationDate":"2020-04-15T11:19:00.000","Title":"Pytype can't find python3 interpreter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python script that use selenium to login website, you should insert the username and password and captcha for submit button to login.after this login webpage have send button  for send form information with post request, how can i bypass this clicking in button and  send the post request without  clicking on the button ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":61227582,"Users Score":0,"Answer":"If you mean that you want to try and bypass the captcha and go straight to the send button, I doubt that's possible. If you need to solve recaptchas, check out 2captcha.com and use their API to solve it - which will unlock the send button, theoretically.","Q_Score":0,"Tags":"python,selenium-webdriver","A_Id":61233892,"CreationDate":"2020-04-15T11:29:00.000","Title":"send request in selenium without clicking on the send button in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have developed a basic app with Kivy but on_release does not work properly on my button bind.  I can get on_press to work every time but on_release works sporadically (maybe one in ten to twenty times) and sometimes on a different part of the screen than you've touched.\nI'm pretty confident it's not a coding issue and one of the Kivy devs said it is not a known issue and should work but they haven't said where I might dig deeper.  \nIn tandem with this, I have been receiving an SDL error in terminal:\nINFO: The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums\/mailing list <https:\/\/discourse.libsdl.org\/> EVDEV KeyCode 330\nThis appears on both touch and release.  EVDEV advised to upgrade to SDL2, which I did and it has not solved the error which could just apparently be ignored if not for the spam it creates.\nI'm not sure if these two issues are linked but don't know where to start with troubleshooting.\nCan anyone please help with what steps I could follow to try and get this resolved?\nI mostly want to fix on_release but if we fix the other error in the process then that would be great too.\nI am running a Raspberry Pi Zero W, Raspbian Buster w\/Desktop and a Hyperpixel 4.0 square screen\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":746,"Q_Id":61227587,"Users Score":1,"Answer":"I have been having the same problem.  I am using Kivy 1.11.1 with SDL reporting as 2.0.9+dfsg1-1+rpt1 in dpkg.  I have read that this is fixed in a later SDL version but I've not worked out how to upgrade this.  Take care if you extract the SDL RPI tarball, as on my system it trashed the \/usr permissions (and didn't upgrade the version as reported by dpkg).\nIf I run mtdev-test (see google), the touchscreen events come through smoothly.  When running kivy apps, the touchscreen events seem to be laggy, coinciding with the 330 error report.  Press\/release seems to work, but motion events are erratic.\nWith my touchscreen, the error problem can be demonstrated really well with the kivy example demo\/touchtracer, which works great with a USB mouse but is terrible with the touchscreen.","Q_Score":0,"Tags":"python,raspberry-pi,kivy,sdl,touchscreen","A_Id":61318083,"CreationDate":"2020-04-15T11:29:00.000","Title":"Kivy on_release not working on touchscreen - SDL issue?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm programming a Telegram bot. I want to search for a specific message in a telegram channel and get its message id. Is it possible? Thx in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1011,"Q_Id":61228148,"Users Score":3,"Answer":"As far as I know, you aren't able to search though messages (in a specific chat) by just using Telegram's bot API. You need an MTProto client to do that. You can use pyrogram or telethon to interface with MTProto then use messages.search.\nBut, there is a catch. If the message you're searching is in a channel, you can webscrape https:\/\/t.me\/s\/CHANNELUSERNAME with a library like BeautifulSoup.","Q_Score":1,"Tags":"python,api,bots,telegram,py-telegram-bot-api","A_Id":61230228,"CreationDate":"2020-04-15T11:58:00.000","Title":"How can i search for a specific message in a chat in python? (pyTelegramBotAPI)","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 instances of Odoo 13 Enterprise in the same server under linux. The first instance is production instance. The customers can connect with it with his mobiles with Odoo app. This instance works fine. The second instance is used to try new modules before put it in production instance. The problem is when I send notifications on development instance the customer get this notifications on his mobiles, and this notifications seems like production instance notification. \nImportant notes: Production instance is under Nginx proxy and have domain, but development instance haven't.\nI'm looking for some forgoten setting, but I didn't see any mistake.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":61229361,"Users Score":0,"Answer":"I fixed this issue uninstalling module ocn_client. This module cache some dependencies and send gosth notifications.","Q_Score":0,"Tags":"python,linux,odoo,odoo-13,odoo-enterprise","A_Id":61253677,"CreationDate":"2020-04-15T12:58:00.000","Title":"Gosth notifications in Odoo 13 EE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a python module which is really big (more than 1 Gigabyte) and I'm importing a class from this module in another python script with the command from module import class. The thing is, when I firt launch my python script, the memory consumption is really high and the script takes a very long time to execute (few minutes!). When launching it after that, it takes significantly less time (a few seconds) and uses less memory but still a lot for me.\nWhat I think my script does is that it loads all the data from the module when I first launch it into memory which is why it takes so much time and memory. \nIs there a way to change that and not have my script import the whole module but only specific parts which I would like ?\nThanks  for taking the time to answer :)","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1385,"Q_Id":61230840,"Users Score":3,"Answer":"Short answer: no, there's no way to avoid this. The first time a module is imported in a gien process, all it's top-level statements (imports, def, class, and of course assignment) are executed to build the runtime module object. That's how Python work, and there are very valid reasons for it to work that way.\nNow the solution here is quite simple: 1\/ split your gigantic module into proper (high cohesion \/ low coupling) modules and only import the parts you need, and 2\/ instead of defining gigabytes of data at the top-level, encapsulate this part in functions with some caching system to avoid useless re-computations.","Q_Score":4,"Tags":"python,performance,memory-management","A_Id":61231439,"CreationDate":"2020-04-15T14:08:00.000","Title":"How to import a class from a module without importing the whole 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 am currently working on an SGE cluster and have code which submits many jobs, written in python, in parallel. \nThe output at the end of my code is a set of files containing numerical data. Each python job performs some calculation and then outputs to each file in turn. To output to a file, my code reads in the data in the file, adds what it has computed to the data, and then outputs back to the file.\nMy problem is this; as all of the jobs are run in parallel, and all of the jobs contribute to each of the output files; my jobs are conflicting with one another. I am often getting errors concerning incompatible file sizes and such. The cause I believe is that sometimes two jobs will try and read in the file around the same time and conflict.\nMy question is this: When running (potentially many) multiple jobs in parallel that are each contributing to the same file multiple times, is there a good practice way of ensuring that they don't try to write to the file concurrently? Are there any pythonic or SGE solutions to this problem?\nMy niave idea was to have a txt file, which contains a 1 or 0 indicating whether a file is currently being accessed, and that a job will only write to a file when the value is set to 0, and will change the value to 1 whilst it is outputting. Is this a bad practice?\/dumb idea?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":549,"Q_Id":61231805,"Users Score":0,"Answer":"You can keep the design simple by having each parallel process write to a separate file. Then when all the processes are finished, have a final process gather all the results and combine them into a single output file. This is a common pattern for HPC processing pipelines.","Q_Score":0,"Tags":"python,file,file-io,sungridengine","A_Id":61250389,"CreationDate":"2020-04-15T14:52:00.000","Title":"Multiple parallel processes writing to the same file on SGE cluster","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using flask security to login to my admin panel. It was using the email and password just fine, but recently the login is requiring the id instead of the email. As far as I know the default behavior is to use the email column. When investigating I found that the SQL query is trying to use the id in the where clause instead of the email. My models are set up correctly with peewee so I am confused as to what is going on.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":33,"Q_Id":61232849,"Users Score":1,"Answer":"It was a peewee version problem. The newest version breaks flask-security.","Q_Score":2,"Tags":"python,flask-admin,flask-peewee","A_Id":61238305,"CreationDate":"2020-04-15T15:43:00.000","Title":"Flask Security Is using id instead of email in where clause","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I cannot get a satisfying answer to this question. As I understand it, TensorFlow is a library for numerical computations, often used in deep learning applications, and Scikit-learn is a framework for general machine learning. \nBut what is the exact difference between them, what is the purpose and function of TensorFlow? Can I use them together, and does it make any sense?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":33511,"Q_Id":61233004,"Users Score":2,"Answer":"Both are 3rd party machine learning modules, and both are good at it.\nTensorflow is the more popular of the two.\nTensorflow is typically used more in Deep Learning and Neural Networks.\nSciKit learn is more general Machine Learning.\nAnd although I don't think I've come across anyone using both simultaneously, no one is saying you can't.","Q_Score":47,"Tags":"python,tensorflow,machine-learning,scikit-learn","A_Id":61233138,"CreationDate":"2020-04-15T15:50:00.000","Title":"What's the difference between scikit-learn and tensorflow? Is it possible to use them together?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've built the image successfully, but when I run docker run <xxxx:latest> it returns nothing.\nI also have a bash script that contains AWS crendential (because a Python script within the container requires credential to log into AWS to perform something), when I tried to run that script it also returns nothing, has anyone encountered this issue? Many thanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1379,"Q_Id":61233802,"Users Score":1,"Answer":"Did you do: docker run -it xxxx?\n-i flag, connects your terminal to STDIN\n-t flag, provides a better visualization of what you see on the screen\n-it is a syntactic coating for -i -t flags used separately\nAlso, what does it show on doing docker ps --all? Does it show that the container is running?","Q_Score":1,"Tags":"python,bash,amazon-web-services,docker,containers","A_Id":61238369,"CreationDate":"2020-04-15T16:29:00.000","Title":"docker run command returns 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a mix of labeled and unlabeled data, this last one I would like to classify it by using semi-supervised learning. Suppose I have already an algorithm that gives me the best accuracy at predicting the labels of the training subsample. I want to use that algorithm to predict the labels of the unlabeled subsample. In semi-supervised learning, the pseudo-labeled data is added to the labeled (training) one. I would like to select from the pseudo-labeled data only those points that the probability of being well classified is higher than, let's say, 0.8, and repeat the procedure till all the unlabeled data is pseudo-labeled with high probability.\nHow could I achieve this? Is there a code or built-in function that helps me to compute such a probability?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":61235951,"Users Score":0,"Answer":"All these algorithms \nAdaBoostClassifier, BaggingClassifier, BayesianGaussianMixture, BernoulliNB, CalibratedClassifierCV, ComplementNB, DecisionTreeClassifier, ExtraTreeClassifier, ExtraTreesClassifier, GaussianMixture, GaussianNB, GaussianProcessClassifier,\nGradientBoostingClassifier, KNeighborsClassifier, LabelPropagation, LabelSpreading, LinearDiscriminantAnalysis, LogisticRegression, LogisticRegressionCV, MLPClassifier, MultinomialNB, NuSVC, QuadraticDiscriminantAnalysis, RandomForestClassifier, SGDClassifier, SVC, _BinaryGaussianProcessClassifierLaplace, _ConstantPredictor\nsupport a method called predict_proba(self, X), that doest precisely that.","Q_Score":0,"Tags":"python,sklearn-pandas,unsupervised-learning,supervised-learning","A_Id":61239576,"CreationDate":"2020-04-15T18:26:00.000","Title":"Probability of a data point being well classified","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between django rest framework's Serializer vs ModelSerializer? When do you one or the other? Can I use ModelSerializer for Auth? Thanks a lot for the help.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3017,"Q_Id":61237790,"Users Score":4,"Answer":"the Django rest framework serializer is the normal serializer that will be used when building an API with Django. It simply parses data from complex types into JSON or XML. \nThe model serializer is just the same as the above serializer in the sense that it does the same job, only that it builds the serializer based on the model, making the creation of the serializer easier than building it normally.","Q_Score":3,"Tags":"python,django,django-rest-framework","A_Id":61266030,"CreationDate":"2020-04-15T20:11:00.000","Title":"What is the difference between Serializer and ModelSerializer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What is the difference between django rest framework's Serializer vs ModelSerializer? When do you one or the other? Can I use ModelSerializer for Auth? Thanks a lot for the help.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3017,"Q_Id":61237790,"Users Score":0,"Answer":"When you are dealing with Microservice and web services if you want to connect your web services with clients so then you have to use a serializer with whatever the data you mentioned in the model in microservices, so it makes it easy for us to carry the data from client-side. In Microservice you used Modelserializer to create serializer but in Webservice you only use serializer.","Q_Score":3,"Tags":"python,django,django-rest-framework","A_Id":70077436,"CreationDate":"2020-04-15T20:11:00.000","Title":"What is the difference between Serializer and ModelSerializer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am just getting started on a web2py tutorial. I have downloaded the web2py Windows binaries, extracted the files and am simply trying to start by opening web2py.exe\nWhen i double click the icon a black command prompt looking window opens up but then closes immediately, and the web2py Web Framework window does not open as it is supposed to.\nNot sure if this is important but I have Python 3.7 installed, do not have any 2.x version installed, but web2py.com does not mention that any of this is needed, it should load up right out of the box. I have searched extensively and do not see anyone else with the same issue. I have tried restarting my computer, deleting and re-downloading the web2py zip folder, but nothing changes.\nEdit: Tried opening application from command prompt, same result.\nAlso I have now tried it on two different Windows machines (one work, one personal) and had the same issue.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":298,"Q_Id":61238173,"Users Score":0,"Answer":"i recommend you to use source code version. It's more flexible to use across any platforms.","Q_Score":0,"Tags":"python,web2py","A_Id":61647264,"CreationDate":"2020-04-15T20:36:00.000","Title":"Web2Py.exe Will Not Open","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am using DBT (data build tool) as an ETL tool for data analytics . \nThe command \ndbt test\nResuts in the test cases being pass\/fail on the output terminal but need to export this result into JSON\/HTML\/XML format for reporting.\nAny help in this regard ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2389,"Q_Id":61238395,"Users Score":2,"Answer":"If you are executing this on an UNIX shell like Mac or Linux, you can try with tee like this.\ndbt run | tee -a your_log_file.txt\nThis will create and append there on the a log file of your choosing for whatever results of the dbt run command.","Q_Score":1,"Tags":"python,json,reporting,dbt","A_Id":61239586,"CreationDate":"2020-04-15T20:51:00.000","Title":"Can the results of dbt test be converted to 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am reading in a csv in batches and each batch has nulls in various place. I dont want to use tensorflow transform as it requires loading the entire data in memory. Currently i cannot ignore the NaNs present in each column while computing means if i am to try to do it for the entire batch at once. I can loop through each column and then find the mean per columns that way but that seems to be an inelegant solution. \nCan somebody help in finding the right way to compute the mean per column of a csv batch that has NaNs present in multiple columns. Also, [1,2,np.nan] should produce 1.5 not 1.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":116,"Q_Id":61239100,"Users Score":1,"Answer":"I am currently doing this: given tensor a of rank 2 tf.math.divide_no_nan(tf.reduce_sum(tf.where(tf.math.is_finite(a),a,0.),axis=0),tf.reduce_sum(tf.cast(tf.math.is_finite(a),tf.float32),axis=0))\nLet me know somebody has a better option","Q_Score":1,"Tags":"python-3.x,tensorflow,tensorflow2.0,tensorflow-datasets","A_Id":61244390,"CreationDate":"2020-04-15T21:40:00.000","Title":"In tensorflow, How to compute mean for each columns of a batch generated from a csv that has NaNs in multiple columns?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to python and I'm using PyCharm as my IDE. I've been able to successfully install other packages like numpy, pandas etc. However, when I'm installing matplotlib, I keep getting the error:\nsrc\/checkdep_freetype2.c(5): fatal error C1189: #error:  \"FreeType version 2.3 or higher is required. You may set the MPLLOCALFREETYPE environment variable to 1 to let Matplotlib download it.\"\nI installed it through the command prompt and it installed correctly but (I believe) PyCharm creates it's own environment and does not recognize packages installed through command prompt even though I tried to install them in the same path as other packages in PyCharm. Can you please help?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":918,"Q_Id":61239246,"Users Score":0,"Answer":"I had to run the command \"pip install updates\" and after that I could install the matplotlib package. It turns out that my pip wasn't of the latest version.","Q_Score":0,"Tags":"python,matplotlib,pycharm","A_Id":61239625,"CreationDate":"2020-04-15T21:50:00.000","Title":"How do I install matplotlib on pyCharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am confused in celery.Example i want to load a data file and it takes 10 seconds to load without celery.With celery how will the user be benefited? Will it take same time to load data?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":61240266,"Users Score":0,"Answer":"Normally, the user has to wait to load the data file to be done on the server. But with the help of celery, the operation will be performed on the server and the user will not be involved. Even if the app crashes, that task will be queued.\n\nCelery will keep track of the work you send to it in a database\n  back-end such as Redis or RabbitMQ. This keeps the state out of your\n  app server's process which means even if your app server crashes your\n  job queue will still remain. Celery also allows you to track tasks\n  that fail.","Q_Score":1,"Tags":"python,django,flask,celery","A_Id":61240414,"CreationDate":"2020-04-15T23:29:00.000","Title":"What is the use of Celery in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am confused in celery.Example i want to load a data file and it takes 10 seconds to load without celery.With celery how will the user be benefited? Will it take same time to load data?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":61240266,"Users Score":0,"Answer":"Celery, and similar systems like Huey are made to help us distribute (offload) the amount of processes that normally can't execute concurrently on a single machine, or it would lead to significant performance degradation if you do so. The key word here is DISTRIBUTED.\nYou mentioned downloading of a file. If it is a single file you need to download, and that is all, then you do not need Celery. How about more complex scenario - you need to download 100000 files? How about even more complex - these 100000 files need to be parsed and the parsing process is CPU intensive?\nMoreover, Celery will help you with retrying of failed tasks, logging, monitoring, etc.","Q_Score":1,"Tags":"python,django,flask,celery","A_Id":61245388,"CreationDate":"2020-04-15T23:29:00.000","Title":"What is the use of Celery in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am building my first Django app and using the Django templating engine in my html files. I have the html and Django html plugin in VSCode.\nSo far, it autocompletes html elements and colorizes the Django templates. \nIs there a way to autocomplete {% %} when using the Django HTML language mode in VSCode?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":436,"Q_Id":61240473,"Users Score":0,"Answer":"You can you the django-Intellisense VSCode extension to provide autocomplete for all dynamic properties generated by Django.","Q_Score":1,"Tags":"python,django,python-3.x,django-templates,jinja2","A_Id":61240537,"CreationDate":"2020-04-15T23:53:00.000","Title":"Keyboard shortcut for {% %} in VSCode using Django HTML","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm having the following numerical issue while using SCIP solver as a callable library via PySCIPOpt:\n\ntwo equivalent and almost identical models for the same problem yield different optimal\n  values and optimal solutions, with optimal values having a relative difference of order 1e-6\n\nAn independent piece of software verified that the solutions yielded by both models are feasible for the original problem and that their true values agree with the optimal values reported by SCIP for each model. Until the appearance of this instance a bunch of instances of the same problem had been solved, with both models always agreeing on their optimal solutions and values.\nIs it possible to modify the numerical precision of SCIP for comparing the values of primal solutions among them and against dual bounds? Which parameters should be modified to overcome this numerical difficulty?\nWhat I tried\nI've tried the following things and the problem persisted:\n\nTurning presolving off with model.setPresolve(SCIP_PARAMSETTING.OFF).\nSetting model.setParam('numerics\/feastol', epsilon) with different values of epsilon.\n\nSince feasible sets and objective functions agree (see description below), I've checked that the actual coefficients of the objective functions agree by calling model.getObjective() and comparing coefficients for equality for each variable appearing in the objective function.\nThe only thing that seemed to help was to add some noise (multiplying by numbers of the form 1+eps with small eps) to the coefficients in the objective function of the model yielding the worst solution. This makes SCIP to yield the same (and the better) solution for both models if eps is within certain range.\nJust in case, this is what I get with scip -v in the terminal:\n\nSCIP version 6.0.2 [precision: 8 byte] [memory: block] [mode:\n  optimized] [LP solver: SoPlex 4.0.2] [GitHash: e639a0059d]\n\nDescription of the models\nModel (I) has approximately 30K binary variables, say X[i] for i in some index set I. It's feasible and not a hard MIP.\nModel (II) is has the same variables of model (I) plus ~100 continuous variables, say Y[j] for j in some index set J. Also model (II) has some constraints like this X[i_1] + X[i_2] + ... + X[i_n] <= Y[j].\nBoth objective functions agree and depend only on X[i] variables, the sense is minimization. Note that variables Y[j] are essentially free in model (II), since they are continuous and  they do not appear in the objective function. Obviously, there is no point in including the Y[j] variables, but the optimal values shouldn't be different.\nModel (II) is the one yielding the better (i.e. smaller) value.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":148,"Q_Id":61241817,"Users Score":0,"Answer":"sorry for the late answer.\nSo, in general, it can definitely happen that any MIP solver reports different optimal solutions for formulations that are slightly perturbed (even if they are mathematically the same), due to the use of floating-point arithmetic.\nYour problem does seem a bit weird though. You say the Y-variables are free, i.e. they do not have any variable bounds attached to them? If this is the case, I would be very surprised if they don't get presolved away.\nIf you are still interested in this problem, could you provide your instance files to me and I will look at them?","Q_Score":0,"Tags":"python,precision,solver,scip","A_Id":62596604,"CreationDate":"2020-04-16T02:40:00.000","Title":"Numerical issue with SCIP: same problem, different optimal values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using subprocess.Popen() in a Python script to run an executable of C++ program. I need to return a value from the C++ program which can be used in the Python script.\nI have lots of printf statements in the C++ program, so I can't use PIPE and get the output.\nCan I return a single value which is received by the script?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":406,"Q_Id":61244258,"Users Score":0,"Answer":"Check the returncode attribute of the object returned by Popen.\nNote that it is only filled if you have called poll() or wait() first on the Popen object.","Q_Score":0,"Tags":"python,c++,subprocess,return-value","A_Id":61244394,"CreationDate":"2020-04-16T06:46:00.000","Title":"Get a return value from C++ program to a Python script using subprocess","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using subprocess.Popen() in a Python script to run an executable of C++ program. I need to return a value from the C++ program which can be used in the Python script.\nI have lots of printf statements in the C++ program, so I can't use PIPE and get the output.\nCan I return a single value which is received by the script?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":406,"Q_Id":61244258,"Users Score":0,"Answer":"This issue is solved. Basically python script subprocess can recieve exit code. cpp file can return that code from int main() which can be used as exit code of the prog in python script.","Q_Score":0,"Tags":"python,c++,subprocess,return-value","A_Id":61248560,"CreationDate":"2020-04-16T06:46:00.000","Title":"Get a return value from C++ program to a Python script using subprocess","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using VSCode for the first time and I have a problem to import anything. When I originally installed (yesterday), I could import built in module like the os. But I am using for data science purposes so I have Anaconda. I have changed python path on VSCode to the Ananconda one and now it shows Ananconda3: conda at the bottom.\nBut every time I am trying to import anything I have the following message:\nProgram 'python.exe' failed to run: Access is deniedAt line:1","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1480,"Q_Id":61245176,"Users Score":0,"Answer":"I could not access the python from the conda location. However, the normal python worked well. That could have been a problem with the work computer configuration or internet security or maybe something else. I changed the conda location to ProgramData and it worked fine.","Q_Score":1,"Tags":"python,visual-studio-code,anaconda,conda","A_Id":61342587,"CreationDate":"2020-04-16T07:50:00.000","Title":"Program 'python.exe' failed to run: Access is deniedAt line:1 VSCode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently developing a Python tool for Windows that is able to lookup all devices connected to a windows pc. It already supports ethernet devices and by now I'm trying to add support for USB and serial devices. For those devices I want to read out their vendor id, product id, serial number and of course the address\/port which is needed to connect to the device.\nSimple USB devices can be easily detected with PyUSB or PyWin32. Unfortunately, many devices say that its vendor is FTDI, which is not the case. As far as I know, FTDI just provides the USB adapter\/converter.\nSo, how can I lookup the device behind the FTDI adapter? I already tried PyUSB, PyWin32 and PySerial, but all of them just say, that there is a FTDI-device connected; but I want to know the actual device behind the FTDI adapter... Is there a way to find that out?\nI hope that you can help me... Thank you for that in advance.\nUpdate\nSince there seems to be no universal solution, is there at least a way to uniquely identify one of those FTDI devices? Some of them provide serial numbers, but unfortunately not all of them. For example there are devices, with a device id like \"USB\\VID_0403&PID_FAF0\\7&5E2426C&0&2\", where \"7&5E2426C&0&2\" should be the serial number. But these serial numbers with ampersands in it are not the real serial numbers (maybe it is something from Windows or so). PySerial even recognizes this serial number only as \"7\".\nIf I had at least the possibility to get the real serial number of that device, this would be very helpful. So I could uniquely identify that device, even if it got a new port or device id after disconnecting and reconnecting. Or are those ampersand-serials always the same for one device?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":669,"Q_Id":61245593,"Users Score":1,"Answer":"Af far as company using FTDI is not interested in buying own vendor ID you are out of luck.\nThere is no standard protocol behind FTDI so no universal way to detect device behind it.","Q_Score":1,"Tags":"python,windows,serial-port,usb,ftdi","A_Id":61245727,"CreationDate":"2020-04-16T08:13:00.000","Title":"How to find out what instruments is behind a FTDI adapter on Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently developing a Python tool for Windows that is able to lookup all devices connected to a windows pc. It already supports ethernet devices and by now I'm trying to add support for USB and serial devices. For those devices I want to read out their vendor id, product id, serial number and of course the address\/port which is needed to connect to the device.\nSimple USB devices can be easily detected with PyUSB or PyWin32. Unfortunately, many devices say that its vendor is FTDI, which is not the case. As far as I know, FTDI just provides the USB adapter\/converter.\nSo, how can I lookup the device behind the FTDI adapter? I already tried PyUSB, PyWin32 and PySerial, but all of them just say, that there is a FTDI-device connected; but I want to know the actual device behind the FTDI adapter... Is there a way to find that out?\nI hope that you can help me... Thank you for that in advance.\nUpdate\nSince there seems to be no universal solution, is there at least a way to uniquely identify one of those FTDI devices? Some of them provide serial numbers, but unfortunately not all of them. For example there are devices, with a device id like \"USB\\VID_0403&PID_FAF0\\7&5E2426C&0&2\", where \"7&5E2426C&0&2\" should be the serial number. But these serial numbers with ampersands in it are not the real serial numbers (maybe it is something from Windows or so). PySerial even recognizes this serial number only as \"7\".\nIf I had at least the possibility to get the real serial number of that device, this would be very helpful. So I could uniquely identify that device, even if it got a new port or device id after disconnecting and reconnecting. Or are those ampersand-serials always the same for one device?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":669,"Q_Id":61245593,"Users Score":1,"Answer":"FTDI is typically allow the use of an EEPROM (actually it is in most cases a simple flash memory) to store specific information about the product in it. E.g. one can assign a specific vendorID, ProductID, SerialNo, Manufacturer Desc., Product Desc. BUT it is only optional (For details search for FT_Prog). So every product designer has the freedom, but does not need to fill in whatever he\/she wants. \nIf you have a set of devices you want to support you could check if the either support a SCPI compliant interface. In this case you can ask them using *IDN? about their identity. If not you can hope that the product has properly written ROM to supply further information. In any other case you can only guess.","Q_Score":1,"Tags":"python,windows,serial-port,usb,ftdi","A_Id":61247913,"CreationDate":"2020-04-16T08:13:00.000","Title":"How to find out what instruments is behind a FTDI adapter on Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Apologies, I know this question has been asked a bunch, but none of those solutions seem to work for me.\nWindows 10\nPython 3.7.7\nC:\\Python7 is my directory\nPATH variables are set\npython -m ensure pip states requirements satisfied\nThere are no .py scripts in the scripts folder to add a line to, only .exe files\nI'm so lost","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":61247592,"Users Score":0,"Answer":"Both C:\\Python7 and C:\\Python7\\Scripts needed to be in path apparently, I only had the Scripts one.","Q_Score":0,"Tags":"python,windows,pip","A_Id":61259525,"CreationDate":"2020-04-16T10:04:00.000","Title":"pip: failed to create process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Jenkins job that executes a python script. I would like to return a png of a figure so that I can see it in the Jenkins Build information. Is this possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":61249556,"Users Score":0,"Answer":"I imagine this to be possible in the following way:\n\nEnable (safe) HTML for Jenkins Build descriptions\nEnter some html that performs a GET request to a path (let's call this X)\nSet up a mini (Python, Flask?) server that serves this path X, and returns the png image from the correct workspace","Q_Score":0,"Tags":"python,jenkins","A_Id":61249643,"CreationDate":"2020-04-16T11:52:00.000","Title":"Return png. file from a Jenkins Build","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to download songs from youtube using python 3.8 and youtube_dl 2020.3.24.\nBut the weird thing is that most songs I try to download don't get downloaded. I'm talking 99% of them.\nThe ones that do get downloaded get the following Error from youtube_dl:\nERROR: unable to download video data: HTTP Error 403: Forbidden\nIt is worth saying that this happened overnight and I did not change any code.\nbefore this everything worked fine.\nI have friends who ran the same code and they did not get this Error","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10705,"Q_Id":61249612,"Users Score":29,"Answer":"Same problem many times ..\nsolution: youtube-dl --rm-cache-dir\nCause of the problem: Sometimes I download playlists of large videos and I force it to stop downloading, the next time I run the command to resume the download, the 403 problem arises\nAt the moment, the cache directory is used only to store youtube players for obfuscated signatures. Since all videos in playlist use simple signatures\nPlaylist caching is an obvious way to detect changed titles or changed playlists in general","Q_Score":19,"Tags":"python,youtube-dl","A_Id":61264406,"CreationDate":"2020-04-16T11:55:00.000","Title":"ERROR: unable to download video data: HTTP Error 403: Forbidden while using youtube_dl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a application, where it would be cool to change the Status of your Discord User you are currently logged in to. For example when i start the appplication then the Status should change to something like \"Playing Program\" and when you click on the User's Status then it should display the Image of the Program. \nNow i wanted to ask if this is somehow possible to make and in which programming Languages is it makeable?\nEDIT: Solved the Problem with pypresence","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1942,"Q_Id":61250120,"Users Score":0,"Answer":"In your startup, where DiscordSocketClient is available, you can use SetGameAsync(). This is for C# using Discord.NET.\nTo answer your question, I think any wrapper for Discord's API allows you to set the current playing game.","Q_Score":1,"Tags":"python,c#,file,discord,status","A_Id":61250409,"CreationDate":"2020-04-16T12:20:00.000","Title":"Set Custom Discord Status when running\/starting a 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":0},{"Question":"I tried to use bert-tensorflow in Google Colab, but I got the following error:\n\n--------------------------------------------------------------------------- AttributeError                            Traceback (most recent call\n  last)  in ()\n        1 import  bert\n  ----> 2 from bert import run_classifier_with_tfhub # run_classifier\n        3 from bert import optimization\n        4 from bert import tokenization\n1 frames \/usr\/local\/lib\/python3.6\/dist-packages\/bert\/optimization.py\n  in ()\n       85 \n       86 \n  ---> 87 class AdamWeightDecayOptimizer(tf.train.Optimizer):\n       88   \"\"\"A basic Adam optimizer that includes \"correct\" L2 weight decay.\"\"\"\n       89 \nAttributeError: module 'tensorflow._api.v2.train' has no attribute\n  'Optimizer'\n\nHere is the code I tried:\n\nInstall the libraries:\n\n!pip install --upgrade --force-reinstall tensorflow\n!pip install --upgrade --force-reinstall tensorflow-gpu\n!pip install tensorflow_hub\n!pip install sentencepiece\n!pip install bert-tensorflow\n\nRun this code:\n\nfrom sklearn.model_selection import train_test_split\nimport pandas as pd\nfrom datetime import datetime\nfrom tensorflow.keras import optimizers\nimport  bert\nfrom bert import run_classifier\nfrom bert import optimization\nfrom bert import tokenization\n\nI've also tried \nimport tensorflow.compat.v1 as tf\ntf.disable_v2_behavior()\nBut got the same error.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":9846,"Q_Id":61250311,"Users Score":3,"Answer":"import tensorflow as tf\nprint(tf.__version__)\n!pip uninstall tensorflow==2.2.0\n!pip install tensorflow==1.15.0\n!pip install bert-tensorflow\ntry this. it worked for me for the same issue","Q_Score":5,"Tags":"python,tensorflow,classification,bert-language-model","A_Id":61692936,"CreationDate":"2020-04-16T12:30:00.000","Title":"Error importing BERT: module 'tensorflow._api.v2.train' has no attribute 'Optimizer'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am kinda new to TensorFlow world but have written some programs in Keras. Since TensorFlow 2 is officially similar to Keras, I am quite confused about what is the difference between tf.keras.callbacks.ModelCheckpoint and tf.train.Checkpoint. If anybody can shed light on this, I would appreciate it.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":1916,"Q_Id":61250353,"Users Score":4,"Answer":"It depends on whether a custom training loop is required. In most cases, it's not and you can just call model.fit() and pass tf.keras.callbacks.ModelCheckpoint. If you do need to write your custom training loop, then you have to use tf.train.Checkpoint (and tf.train.CheckpointManager) since there's no callback mechanism.","Q_Score":2,"Tags":"python,tensorflow,keras,checkpoint","A_Id":63366977,"CreationDate":"2020-04-16T12:33:00.000","Title":"tf.keras.callbacks.ModelCheckpoint vs tf.train.Checkpoint","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm training my DQN and it often happens that I want to change a setting in the middle of the training. I know there is the option to terminate the running code via the terminal with CTRL+C but I'd like to intervene only after the currently running epoch has finished. Is there a way to implement that. (I'm using VS-Code)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":61253514,"Users Score":0,"Answer":"You could insert a input() after every epoch and use this.. But that means that you have to sit in front of the computer the whole execution time to make the program execute without long pauses","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":61253543,"CreationDate":"2020-04-16T15:02:00.000","Title":"How to interactively (e.g. using the terminal) intervene a for loop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python face recognition where I am using open-face model and SVM to detect and recognize faces. The general steps I am following to recognize image is below:\n\nDetect face using face detection model: Reason for using open face model instead of HAAR cascase is that cascade is not able to detect side face\nExtracting face embedding: Extracting the 128 d face embedding using open face model\nTraining: Using SVM I am training the face embedding with appropriate label like below:\nparams = {\"C\": [0.001, 0.01, 0.1, 1.0, 10.0, 100.0, 1000.0], \"gamma\": [1e-1, 1e-2, 1e-3, 1e-4, 1e-5]}\nmodel = GridSearchCV(SVC(kernel=\"rbf\", gamma=\"auto\", probability=True), params, cv=3, n_jobs=-1)\nmodel.fit(data[\"embeddings\"], labels)\nTesting: Extracting the face embedding of the test image, and predicting the results like below:\n\nmodel.predict_proba()\nI have unknown random face dataset and known person face dataset. The problem here is that if I add around 30 known person image and if I have around 10 unknown person image, it is recognizing the known person fine but if any unknown person comes in, it is also recognizing that unknown person as known person with high confidence which in actual should be unknown.\nIf I add more random  person in unknown data set lets say around 50 images and if I have 30 known person image. It is recognizing known person image fine but confidence is low and if any unknown person comes in, it is now recognized as unknown\nIt looks like for good face recognition results we need to have appox same number of known and unknown person image which is practically not possible as known person images can increase to 100 or more than that for each known person we add. I am very confused here and not sure what to do. Is there any other way of recognizing known\/unknown persons. Please help. Thanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1477,"Q_Id":61253604,"Users Score":1,"Answer":"I don't think svm will work well here. It is binary classifier by native. It will try to compute the border between two 128D points sets (known and unknown classes), but these classes are not internally connected with any relations. Known may be similar to unknown more than to another known in embedding space. That will be a problem for generalization for SVM. SVM may be used on closed sets, but you have open set for unknown faces.\nIt is more practical to use non-parametric methods, and use Bayesian approach, computing likelihoods as function of distance for known data in embedding space. Like in your previous question.","Q_Score":1,"Tags":"python,opencv,face-recognition","A_Id":61254102,"CreationDate":"2020-04-16T15:06:00.000","Title":"How to create unknown face dataset for face recognition python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python face recognition where I am using open-face model and SVM to detect and recognize faces. The general steps I am following to recognize image is below:\n\nDetect face using face detection model: Reason for using open face model instead of HAAR cascase is that cascade is not able to detect side face\nExtracting face embedding: Extracting the 128 d face embedding using open face model\nTraining: Using SVM I am training the face embedding with appropriate label like below:\nparams = {\"C\": [0.001, 0.01, 0.1, 1.0, 10.0, 100.0, 1000.0], \"gamma\": [1e-1, 1e-2, 1e-3, 1e-4, 1e-5]}\nmodel = GridSearchCV(SVC(kernel=\"rbf\", gamma=\"auto\", probability=True), params, cv=3, n_jobs=-1)\nmodel.fit(data[\"embeddings\"], labels)\nTesting: Extracting the face embedding of the test image, and predicting the results like below:\n\nmodel.predict_proba()\nI have unknown random face dataset and known person face dataset. The problem here is that if I add around 30 known person image and if I have around 10 unknown person image, it is recognizing the known person fine but if any unknown person comes in, it is also recognizing that unknown person as known person with high confidence which in actual should be unknown.\nIf I add more random  person in unknown data set lets say around 50 images and if I have 30 known person image. It is recognizing known person image fine but confidence is low and if any unknown person comes in, it is now recognized as unknown\nIt looks like for good face recognition results we need to have appox same number of known and unknown person image which is practically not possible as known person images can increase to 100 or more than that for each known person we add. I am very confused here and not sure what to do. Is there any other way of recognizing known\/unknown persons. Please help. Thanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1477,"Q_Id":61253604,"Users Score":1,"Answer":"It is normal that confidence decreases as the number of possible persons (number of labels) increases, as there are more possibilities. I'm trying to understand what you meant: you have a label for each person and then an additional label for unknown? That is not the way to go, as unknown is treated as any other person embedding. You should use a cutoff probability, and everything that falls below that is considered unknown. \nRemember that there is a trade-off between the size of your prediction (more persons, more possibilities) and accuracy","Q_Score":1,"Tags":"python,opencv,face-recognition","A_Id":61253938,"CreationDate":"2020-04-16T15:06:00.000","Title":"How to create unknown face dataset for face recognition python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to distinguish when a variable is 0.0 specifically, so a == 0 will not work because it will fail when a is equal to False. What's the best way to accomplish this?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":248,"Q_Id":61255025,"Users Score":0,"Answer":"You can check for the variables type, to specify its the correct data-type that you want. The type(a) function will return a class, and then type(a).__name__ will give you the string form.","Q_Score":0,"Tags":"python","A_Id":61255114,"CreationDate":"2020-04-16T16:18:00.000","Title":"How can I check that a variable is 0.0 and not False?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm quite new to colab. I run my notebook for few hours. I mounted the google drive and I upload data directly there, but the colab disk space is decreasing even though I am not saving anything there, I move it to google drive where I have much bigger space. Does anyone know why is the disk space filling up?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":445,"Q_Id":61257625,"Users Score":1,"Answer":"Colab gives you the illusion of having your Google Drive mounted to it as a filesystem. But behind the scenes, it is really a remote disk that is mounted as a virtual filesystem.\nSo, when you upload the data through your Colab instance, it first gets uploaded to Colab. Then it starts transferring the data to Drive. This causes the Colab space to be used, until the data is completely uploaded to the Drive. Also, Colab might take some time to refelct the changes.","Q_Score":0,"Tags":"python,google-colaboratory","A_Id":61271125,"CreationDate":"2020-04-16T18:39:00.000","Title":"Google colab drive space decreasing even I save data on google drive","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script for fetching graph api data within power bi. Occasionally it gives the following error on refresh - \nA problem occurred while processing your Python script. \nHere are the technical details: Process must exit before requested information can be determined.\nDetails:\nDataSourceKind=Python\nDataSourcePath=Python\nA problem occurred while processing your Python script.\nHere are the technical details: Process must exit before requested information can be determined.\nErrorCode=-2147467259\nExceptionType=Microsoft.PowerBI.Scripting.Python.Exceptions.PythonUnexpectedException\nEven after extensive search haven't been able to find the reason for the same.\nSteps already tried - \n    1. I have tried switching between anaconda and normal python installed.\n    2. All the libraries are updated with the latest version.\n    3. I have tried clearing the cache of internal power bi desktop version.\n    4. The python script runs perfectly outside power bi.\n    5. Used privacy level for the data source as public.\n    6. I even uninstalled everything and reinstalled powerbi desktop version and also python and anaconda but the issue remains the same.\n    7. Tried on a different system but the issue remains the same.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":348,"Q_Id":61259101,"Users Score":1,"Answer":"As of today the error does not appear for Python v3.6 but for higher version. Seems there has to be a fix from Microsoft's end. This is a workaround solution that I have found and also raised the concern with the microsoft team but haven't received a reply from their end as of now.","Q_Score":0,"Tags":"python,powerbi","A_Id":62301097,"CreationDate":"2020-04-16T20:05:00.000","Title":"Python script for graph api gives error on refresh in power bi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a Django project with a postgresql in it. This databasa has to be populated from an API. This database doesn't have to be updated.\nAs I understood, the tables inside my database have to be created in my Django models. But where should I populate it? \nIn a script outside Django or inside my app views?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":681,"Q_Id":61260062,"Users Score":3,"Answer":"I did find a way to populate my DataBase from Django itself. I added a custom populate_db command in managment\/command that runs a scritp that populate my DataBase from an external API.\nThen I just have to run  python3 manage.py populate_db","Q_Score":2,"Tags":"python,django,postgresql,django-models","A_Id":61300803,"CreationDate":"2020-04-16T21:07:00.000","Title":"Populate a DataBase from an API in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to pythonOcc, I want to thicken a Bezier Curve (or make a pipe) unevenly: for example, the resulting thickened curve at the start point of the curve should be thicker than at the endpoint of the curve. \nCould you let me know what is the most efficient way to do that? I've tried functions like BRepOffsetAPI_ThruSections, but I don't think there are useful for this purpose.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":61260338,"Users Score":0,"Answer":"I have solved it, it can easily be done using the module: BRepOffsetAPI_MakePipeShell. \nWires can be added as profiles and the \"setlaw\" method can be used to vary the thickness of the profile.","Q_Score":0,"Tags":"python,python-3.x,graphics,computational-geometry,opencascade","A_Id":61534391,"CreationDate":"2020-04-16T21:30:00.000","Title":"PythonOcc: Thicken a curve with variable radius","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I periodically receive data (every 15 minutes) and have them in an array (numpy array to be precise) in python, that is roughly 50 columns, the number of rows varies, usually is somewhere around 100-200.\nBefore, I only analyzed this data and tossed it, but now I'd like to start saving it, so that I can create statistics later.\nI have considered saving it in a csv file, but it did not seem right to me to save high amounts of such big 2D arrays to a csv file.\nI've looked at serialization options, particularly pickle and numpy's .tobytes(), but in both cases I run into an issue - I have to track the amount of arrays stored. I've seen people write the number as the first thing in the file, but I don't know how I would be able to keep incrementing the number while having the file still opened (the program that gathers the data runs practically non-stop). Constantly opening the file, reading the number, rewriting it, seeking to the end to write new data and closing the file again doesn't seem very efficient.\nI feel like I'm missing some vital information and have not been able to find it. I'd love it if someone could show me something I can not see and help me solve the problem.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":96,"Q_Id":61261541,"Users Score":1,"Answer":"Saving on a csv file might not be a good idea in this case, think about the accessibility and availability of your data. Using a database will be better, you can easily update your data and control the size amount of data you store.","Q_Score":1,"Tags":"python,numpy,csv,serialization,pickle","A_Id":61261755,"CreationDate":"2020-04-16T23:05:00.000","Title":"Save periodically gathered data with python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I currently am trying to use yfinance in Visual Studio Code on Mac. I downloaded pip through 'sudo easy_install pip' and downloaded yfinance via pip install. When I try to run my code I get ModuleNotFoundError: No module named 'yfinance'. What can I do??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2793,"Q_Id":61261795,"Users Score":0,"Answer":"Visual Studio will be running a different instance of python to the rest of your system if you did your pip install using the Mac Terminal, it would probably have installed it for a different instance. You'll have to either issue the command in VS (In windows, it's under Tools > Command line) or you'll have to specify that instance in you command from the terminal.","Q_Score":0,"Tags":"python,yfinance","A_Id":61261848,"CreationDate":"2020-04-16T23:27:00.000","Title":"ModuleNotFoundError: No module named 'yfinance', what can I do on Mac, using VC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a web application that uses Google Sheets as a database. I want to upload my project on github. But since it uses google sheets API  for fetching data, I was wondering if is it safe to upload because I will also have to upload API credentials as well?\nI have seen a lot of questions like this on Stack Overflow but none of them addressed this question clearly. Also, my application\/database is nothing confidential or anything like that. My only concern is if uploading API credentials can cause any harm to my google account?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":61262038,"Users Score":2,"Answer":"You should never upload private\/secret credentials to a public forum like GitHub.\nThere will always be people looking to exploit free credentials like that and it's impossible to know the damage that could be caused.  What if someone deletes data on your account? What if they spam calls and get your account suspended?  \nThe best practice is to put some kind of placeholder in the code that you put on GitHub and add a section to the ReadMe explaining where the credentials need to be provided.","Q_Score":1,"Tags":"python,django,github,google-sheets-api","A_Id":61262110,"CreationDate":"2020-04-16T23:56:00.000","Title":"Can we upload google sheets api credentials on github?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have Cython code that wraps C++ code, which needs compiled before running. To do this, I use the following line: \npython setup.py build_ext --inplace\nHowever, a great thing about python is the setup.py file and the ability to install packages to pip. All previous version of my code were able to be installed to pip and then called without being moved to a local directory for whoever was using it. Just like numpy, scipy, etc. \nIs there any way to pip install a package and have the Cython files compiled at the same time?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1259,"Q_Id":61262414,"Users Score":0,"Answer":"If you have the ability to run python setup.py build_ext --inplace, and it works. A pip install is essentially a build not inplace. Therefore, if you run pip install path\/to\/folder.zip and everything is properly defined in setup.py, then the necessary files with be compiled and able to be called in the package.","Q_Score":5,"Tags":"python,pip,cython","A_Id":61328764,"CreationDate":"2020-04-17T00:48:00.000","Title":"How to pip install a package that needs cython code built?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question related to an annoying behavior I have observed recently in tkinter. When there's no fixed window size defined, the main window is expanded when adding new frames, which is great. However, if prior to adding a new widget the user only so much as touches the resizing handles, resizing the main window manually, then the window does not expand to fit the new widget. Why is that so and is there a way to prevent this behavior?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":84,"Q_Id":61262515,"Users Score":1,"Answer":"The why is because tkinter was designed to let the user ultimately control the size of the window. If the user sets the window size, tkinter assumes it was for a reason and thus honors the requested size. \nTo get the resize behavior back, pass an empty string to the geometry method of the window.","Q_Score":0,"Tags":"python-3.x,tkinter","A_Id":61262980,"CreationDate":"2020-04-17T01:04:00.000","Title":"Tkinter - how to prevent user window resize from disabling autoresize?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I force the user to complete a form before allowing them to move to other routes in Flask.\nI wanted to avoid creating user logins as I didn't want to create a database for individual users. I just wanted to force any user to complete a form before getting access to other urls in the flask applications.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":61262698,"Users Score":0,"Answer":"You can use sessions to store data from the form. Then in each route check if the sessions contains data. If it doesn't it means that the user hasn't completed the form. If so then redirect the user to the form route","Q_Score":0,"Tags":"python,flask","A_Id":61263503,"CreationDate":"2020-04-17T01:25:00.000","Title":"Forcing users to complete form in Flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My question is short.\nWhen do I want to define a class as this:\nclass test:\nas opposed to\nclass test():\nIn other words, what difference does it make to put parenthesis or not?\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":61262996,"Users Score":2,"Answer":"The \"class test():\" is used when subclassing it, else if inheritence is not employed, use \"class test:\"","Q_Score":0,"Tags":"python,class","A_Id":61263015,"CreationDate":"2020-04-17T02:05:00.000","Title":"Using parenthesis or not when defining a python class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a beginner to Python, and I am having trouble importing a list into my other Python file. I have two files. One is article_analyzer.py and the other is keywords.py. Both are in the same directory. I have tried importing a list called keywords_list from keywords.py. But it is not working. I have tried typing import keywords and then printing print(keywords_list), but this just results in this error: NameError: name 'keywords_list' is not defined. I have also tried from keywords import * but it results in the same thing.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":52,"Q_Id":61265185,"Users Score":1,"Answer":"I am not sure what I did, but I played around with the keywords.py file and it appears to be working now.","Q_Score":2,"Tags":"python,list,import","A_Id":61265551,"CreationDate":"2020-04-17T06:12:00.000","Title":"I am having difficulty importing a list from another file in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use python boto3\nwhen I upload file to s3,aws lambda will move the file to other bucket,I can get object url by lambda event,like\nhttps:\/\/xxx.s3.amazonaws.com\/xxx\/xxx\/xxxx\/xxxx\/diamond+white.side.jpg\nThe object key is xxx\/xxx\/xxxx\/xxxx\/diamond+white.side.jpg \nThis is a simple example,I can replace \"+\" get object key, there are other complicated situations,I need to get object key by object url,How can I do it?\nthanks!!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":984,"Q_Id":61265226,"Users Score":1,"Answer":"You should use urllib.parse.unquote and then replace + with space.\nFrom my knowledge, + is the only exception from URL parsing, so you should be safe if you do that by hand.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda,boto3","A_Id":61267789,"CreationDate":"2020-04-17T06:16:00.000","Title":"how to get s3 object key by object url when I use aws lambda python?or How to get object by url?","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":"Can i set the path in the anaconda installer to $ \/home\/.anaconda ?\nWhen it will get added to the PATH will it lauch ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":61266293,"Users Score":0,"Answer":"Yes, it is possible. \nBut you may have to manually run:\n$ source <path to conda>\/bin\/activate\n$ conda init\nand after that it worked.","Q_Score":0,"Tags":"python,anaconda,data-science","A_Id":61267226,"CreationDate":"2020-04-17T07:35:00.000","Title":"Can I install anaconda on linux in a hidden folder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to send some data from the server to the client. I thought about a socket connection but is this really save? What do I have to consider with the socket connection? I mean when the client is connected to the server he could also send a virus to the server. Is there a way to avoid this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":61266902,"Users Score":0,"Answer":"That depends on what type of data a client wants to send. During the socket connection server and client sending each other bytes data. If you know exactly what should these bytes include you can discard other that not match your app.","Q_Score":0,"Tags":"python,sockets,virus","A_Id":61266962,"CreationDate":"2020-04-17T08:10:00.000","Title":"Python send data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I access a specific webpage, it sends a specific POST request, the response to which I want to parse. How do I make my script, receiving only the webpage's URL, parse that specific request's response?\n(Ideally, in Python.)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":61268171,"Users Score":0,"Answer":"So, I've found out that the 'seleniumwire' library for Python is one way to access requests made by a browser when loading a page.","Q_Score":0,"Tags":"python,web-scraping","A_Id":61516105,"CreationDate":"2020-04-17T09:25:00.000","Title":"How do I make my script, receiving only the webpage's URL, parse its POST request's response?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Am working on a project where i need to gather information from different websites ( Internal to company) and also few information from an windows  application developed in Java.\nI was able to pull all the information from websites using Selenium\/Python, now I have an Window application where i need to fetch some information. Since selenium is not supporting Window application am not able to continue with that. I tried using AutoIt but my application is developed on JAVA and autoit windows spy is not able to detect many buttons on the application.\nAny suggestion\/Idea based on your experience how to proceed further ?\nI have 80% of my information in websites which I have already scripted to pull only pending is this applications.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":212,"Q_Id":61269426,"Users Score":1,"Answer":"If the Java application is using DB (it almost certainly does) you can try getting the data from there directly instead of extracting it from the GUI.","Q_Score":0,"Tags":"python,selenium,user-interface,autoit","A_Id":61285451,"CreationDate":"2020-04-17T10:29:00.000","Title":"Python\/Selenium code to open an application and login ( GUI Automation)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This is probably a really dumb question.\nI have a dataframe that has a column containing scores of a soccer game (e.g. 1-2). When I save the dataframe using df.to_csv, and open the .csv file in Excel afterwards, the scores are given as date (e.g. 1-2 is now 1st Feb).\nI realize this is an issue within Excel probably, since when I open the file in Notepad, the scores are as they should be.\nSo my question is, how best to handle it? Is there an option in Python where I can save the .csv in such a format that the score isn't converted to a date? Or is it something to be tackled in Excel?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":61270822,"Users Score":0,"Answer":"If you save your file as text (.txt) instead of .csv, Excel shouldn't re-format it. \nThis might go against your specific needs, if .csv is necessary. But if not, you can achieve the same result (in the sense of delimitation and headers) by opening the text file from Excel's File Menu, selecting 'Delimited'. \nThen, if in python you are saving your .txt file with a comma delimitation, de-select the 'Tab' option and select 'Comma'..","Q_Score":0,"Tags":"python,excel","A_Id":61271239,"CreationDate":"2020-04-17T11:43:00.000","Title":"Saving pandas dataframe as .csv, converts score to date","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was reading regarding the memory allocation in python and was wondering if I have java and python installed in the same computer system then does java and python use the same stack and heap or they have different stack and heaps allocated for them in the RAM? \nCan anyone please help me to clear my doubt.\nThanks in Advance.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":61271540,"Users Score":0,"Answer":"Two different programs never use the same heap. They each, get a portion of virtual address space, that can overlap in numbers somehow, but these are independent. When a program actually needs pages to be in RAM - it allocates them, in a lazy fashion, usually by 4KB ( might be bigger ). This is done via a Page Table, which is able to map virtual address space to phisycal one ( potentially swap too ). \nYou probably need to understand that you do not require everything, all the time in RAM. Your code can do a little portion, then give that space in RAM to someone else, or even swap out.","Q_Score":0,"Tags":"java,python,memory-management,stack,heap-memory","A_Id":62001513,"CreationDate":"2020-04-17T12:20:00.000","Title":"Does two languages use the same stack and heap on the ram?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was reading regarding the memory allocation in python and was wondering if I have java and python installed in the same computer system then does java and python use the same stack and heap or they have different stack and heaps allocated for them in the RAM? \nCan anyone please help me to clear my doubt.\nThanks in Advance.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":58,"Q_Id":61271540,"Users Score":1,"Answer":"Even if it is an implementation detail, each thread on a system has its own stack. The heap is an image from the 70's segmented model and has no sense on any process except Java ones on a modern OS: when a process requires more memory it just asks the kernel for it and has no preallocated heap. In a sense all processes in a system (except for Java ones) share the same available memory pool, but it not what was called a heap.\nJava is different, because a Java program executes in a JVM, and the JVM has its allocated memory and the process cannot require memory from the system. So in a JVM, the whole process has a heap, and each thread has a stack. And if you launch 2 independant Java programs, you will have 2 independant JVM each with its own heap.","Q_Score":0,"Tags":"java,python,memory-management,stack,heap-memory","A_Id":61271918,"CreationDate":"2020-04-17T12:20:00.000","Title":"Does two languages use the same stack and heap on the ram?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to install OpenCV on Raspbian Buster. I've followed a guide but when I try to import cv2 in Python 3.8.0 it says No module named 'cv2'. Python 3.8.0 is set to my default Python installation, but when I navigate to \/usr\/local\/lib\/python2.7\/dist-packages, that's where I see the cv2 module. It is also installed under python3.7, but not under 3.8. Is there a way I can use it with Python 3.8? \nEDIT: I seem to have fixed it by creating a symbolic link between the Python3.8 and 3.7 site-packages folder.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":415,"Q_Id":61271567,"Users Score":0,"Answer":"You can install current opencv for python3 with sudo pip3 install opencv-python. Note the use of pip3 to install for python3.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,opencv","A_Id":61271698,"CreationDate":"2020-04-17T12:22:00.000","Title":"Installing OpenCV on Raspbian 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working for the first time with a relatively large dataset (50gb). \nThere are 30,000 classes, and 100,000 labels (skewed data).\nI'm trying to train my CNN model on 10% of the data for testing. \nI have a problem for one hot encoding the labels.\nThe labels go from 0 to 29,999 (integers), so in my 10% dataset, I have an array of 10,000 labels with random values from 0 to 29,999. \nWhat happens is that keras to categorical creates a matrix of vectors with length = max(labels). \nFor example, if in my 10% dataset, the largest label is 25,000 then the one encoding will result in a shape (10000, 250000) which is wrong. Because I only have 20 labels in this sub dataset.\nHow can I do to one hot encode this labels ?\nI'm not sure if I was clear enough, first time working on large data got me a bit confused.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":61271987,"Users Score":1,"Answer":"You should definitely one-hot encode the target before you take a smaller sample. Then it won't be a problem.","Q_Score":0,"Tags":"python,keras,data-science,one-hot-encoding","A_Id":61272254,"CreationDate":"2020-04-17T12:43:00.000","Title":"One-hot encode before or after taking a small sample?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use Selenium via Python on a desktopless server. When I try to open chromium it says:\nWebDriverException: Message: unknown error: Chrome failed to start: exited abnormally\n  (Driver info: chromedriver=2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881),platform=Linux 4.15.0 x86_64)\nWhat can I do to make it work, without using a desktop?\nThanks to all of you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":781,"Q_Id":61275429,"Users Score":0,"Answer":"I'm running selenium remotely without issues.\nAre the versions of the browser and the chromedriver compatible? You can check this from the command line with which chromium-browser for instance. \nYour driver should also be set to run without a window: options.add_argument('--headless')","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,python-webbrowser","A_Id":61278491,"CreationDate":"2020-04-17T15:38:00.000","Title":"How to use Python Selenium via SSH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a 64 bit version of my python code using pyinstaller. However, I would like to create a 32 bit version. It seems like I would need to download a 32 bit version of python and redo my entire code in that version which seems like a lot of work. Is there no simple method of achieving my goal without having to redo everything?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":198,"Q_Id":61275674,"Users Score":1,"Answer":"The code you actually have to run in 64 bit should work in a 32 bit environment. What you should make sure is that dependencies you are using in your code also work in 32 bit.","Q_Score":1,"Tags":"python,pyinstaller,32bit-64bit","A_Id":61275870,"CreationDate":"2020-04-17T15:52:00.000","Title":"How to create 32 bit version of Python code from 64 bit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This question doesn't involve any code. I just want to know a way to run multiple instances of a django app and if it is really possible in the first place.\nI make django apps and host them on Apache. With the apps, I noticed a conflict between multiple users accessing the web app. \nLet us assume it is a web scraping app. If one user visits the app and run the scraper, the other user accessing the site from a different location doesn't seem to be able to visit the app or run the scraper unless the scraping that the first user started finishes. \nIs it really possibe to make it independent for all different users accessing the app?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":483,"Q_Id":61276070,"Users Score":0,"Answer":"There are a few ways you could approach this. You might consider putting your app into a container (Google search: docker {your stack}) \nThen implement something like Docker Swarm or Kubernetes to allocate multiple instances of your app. \nThat being said, you might consider how to refactor your app to allow multiple users. It sounds like your scraping process locks things. But in reality, there's no reason your server should lock up during this. \nIt might be better to create your app so that when it received a request, like someone visiting the site, the server pays out the requested web page. When a user asks for a scrape\/task to run, the server calls your scaper service or script asynchronously. \nThat way your app can still function while a scrape is in progress. This would be MUCH more resource efficient (and likely simpler) than spinning up tens or hundreds of instances of your entire app.\ntl;Dr: containerization for multiple instances \nRefactor app so a single user can't threadlock it.","Q_Score":1,"Tags":"django,python-3.x","A_Id":61276150,"CreationDate":"2020-04-17T16:15:00.000","Title":"How to run multiple instances of a Django app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I use yolov3 to train my dataset and there are more than 60 objects in a picture,and these objects are very dense, the final train-loss is 16.4,do I need to change yolov3.cfg or other parameters?or what can I do to reduce the train-loss?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":417,"Q_Id":61276651,"Users Score":0,"Answer":"From your question I understand that there are many small objects in your images. You could do a few things to improve your training-loss:\n\nset flag random=1 in your .cfg-file - it will increase precision by training Yolo for different resolutions.\nincrease network resolution in your .cfg-file (height=608, width=608 or any value multiple of 32) - it will increase precision.\n\nAlso I'd suggest you to have some test images and check your mAP while training to if the model's detection accuracy is increasing as the loss goes down.","Q_Score":0,"Tags":"python,tensorflow,computer-vision,yolo,darknet","A_Id":61335793,"CreationDate":"2020-04-17T16:48:00.000","Title":"When I use yolov3 to train my dataset and there are more than 60 objects in a picture,do I need to change yolov3.cfg or other parameters?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Django project and API view implemented with the Rest framework. I'm caching it using the @cache_page decorator but I need to implement a cache invalidation and I'm not seeing how to do that - do I need a custom decorator? \nThe problem: \nThe view checks the access of the API KEY and it caches it from the previous access check but, if the user changes the API KEY before the cache expires, the view will return an OK status of the key that no longer exists.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":465,"Q_Id":61277009,"Users Score":0,"Answer":"Yes, you'll need a cache decorator that takes the authentication\/user context into account. cache_page() only works for GET requests, and keys based on the URL alone.\nBetter yet, though, \n\nDon't use a cache until you're sure you need one\nIf you do need it (think about why; cache invalidation is one of the two hard things), use a more granular cache within your view, not cache_page().","Q_Score":0,"Tags":"python,django,api,django-rest-framework","A_Id":61277084,"CreationDate":"2020-04-17T17:10:00.000","Title":"Django REST Cache Invalidation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I am new to Kali Linux and I have installed the infamous Sherlock, nonetheless when I used the command to search for usernames it didn't work (Python3: can't open file 'sherlock.py' [Errno 2] No such file or directory). Naturally I tried to look up at similiar problems and have found that maybe the problem is located on my python path. \nWhich is currently located in \/usr\/bin\/python\/ and my pip is in \/usr\/local\/bin\/pip. Is my python and pip installed correctly in the path? If not, how do I set a correct path?\nHowever if it is right and has no correlation with the issue, then what is the problem?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6390,"Q_Id":61277217,"Users Score":1,"Answer":"You have to change directory to sherlock twice. (it works for me)","Q_Score":1,"Tags":"python,linux,path,pip,errno","A_Id":61730646,"CreationDate":"2020-04-17T17:23:00.000","Title":"Python3: can't open file 'sherlock.py' [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":0,"Web Development":0},{"Question":"Let me explain with an example.\nLike when we first open www.coursera.org we get to their homepage. Then we login. After we login the session starts and we are redirected to main course dashboard. but if we see URl it is www.coursera.org so now the home route has chanmged from homepage to say dashboard. \nNow in django i can redirect to project.com\/dashboard from project.com\/login but what i want is after login the user should not have access to homepage at any route.\nSo i want to change project.com\/   which before login showed homepage to now showing the dashboard view simply change the view function linked to project.com\/ route\nI hope I explained my question correctly. \nThank you for help in advance","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":219,"Q_Id":61279541,"Users Score":0,"Answer":"I don't think its easily doable in urlconf. If you use function based views, just check if user is authenticated and if he is, then call the view function for dashboard, if not then display the front page. \nFor CBVs probably use UserPassesTestMixin and set the test_func to redirect authenticated users to dashboard.","Q_Score":0,"Tags":"python,django,web,web-applications","A_Id":61280310,"CreationDate":"2020-04-17T19:48:00.000","Title":"How do I change some routes in Django Project after login?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm running Catalina 10.15.3 at the moment. Prior to upgrading, my python build in Sublime Text was accessing the environment variables no problem  with os.environ.get('A'). However, since the upgrade this is no longer true.\nI've moved everything from my previous .bash_profile to my .zprofile. Additionally, if I launch python from zsh directly there is no issue. \nAny help would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":61280450,"Users Score":0,"Answer":"I was able to solve this by launching Sublime Text 3 from a zsh shell.","Q_Score":0,"Tags":"python,environment-variables,sublimetext3","A_Id":61446859,"CreationDate":"2020-04-17T20:50:00.000","Title":"Sublime Text 3 no longer accessing environment variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am new to Python scripting in Abaqus. I am aware how to use the GUI but not really familiar with the scripting interface. However, I would like to know one specific thing. I would like to know how to assign a set to each individual node on a geometry's edges. I have thought about referencing the node numbers assigned to the geometry edges but don't know how I will do it. \nThe reason for creating a set for each node is that I would like to apply Periodic Boundary Conditions (PBC). Currently my model is a 2D Repeating Unit Cell (RUC) and I would like to apply a constraint equation between the opposite nodes on the opposite edges. To do that, I need to create a set for each node and then apply an equation on the corresponding set of nodes.\nJust to add that the reason why I would like to use the Python scripting interface is because through the GUI, I can only make sets of nodes and create constraint equations for a simple mesh. But for a refined mesh, there will be a lot more constraint equations and a whole lot more sets. \nAny suggestion of any kind would be really helpful.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1022,"Q_Id":61281853,"Users Score":0,"Answer":"One of the way would be with the help of getByBoundingBox(...) method available for selecting nodes inside of a particular bounding box.\n\nallNodes = mdb.models[name].parts[name].nodes\n  allNodes.getByBoundingBox(xMin, yMin, zMin, xMax, yMax, zMax)\n  mdb.models[name].parts[name].Set(name=<name_i>, region=<regionObject_corresponding_to_node_i>)\n\nOne could always look for pointers in the replay file *.rpy of the current current session, which is mostly machine generated python code of the manual steps done in CAE.\nAbaqus > Scripting Reference > Python commands > Mesh commands > MeshNodeArray object and Abaqus > Scripting Reference > Python commands > Region commands > Set object contains the relevant information.","Q_Score":0,"Tags":"python,abaqus","A_Id":61371966,"CreationDate":"2020-04-17T22:40:00.000","Title":"How to create individual node sets using abaqus python scripting?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm very begginer with python and I have task to parse xsd schema to python code, fill nodes with values and create final XML file from it. Is it possible with generateDS tool? I can't find clear anwser in documentation. Maybe theres another way to do it? Thanks for anwsers","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":310,"Q_Id":61282235,"Users Score":0,"Answer":"Maybe someone in future will have same problem as I had, so there's a tip: to create objects from Schema use generateDStool, it's a way easier to use rather than pyxb","Q_Score":0,"Tags":"python,xml,xsd,xml-parsing,python-generateds","A_Id":61291165,"CreationDate":"2020-04-17T23:17:00.000","Title":"How to parse xsd and create XML's from it with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pyspark dataframe that I want to write to HDFS. I am using the following command:\ndf.write.mode(\"overwrite\").option(\"header\", \"true\").option(\"sep\", \"|\").csv(outfile, compression=\"bzip2\")\nI am observing a weird thing. The dataframe has 366,000 rows which I obtained using the df.count() function. However, the output of the write command only has 72, 557 lines (wc -l command). Ideally each row should have a corresponding line in the output. Is there anything wrong with the write command I have been using?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":61283147,"Users Score":0,"Answer":"It turns out that there were some rows with all elements as null. And this led to the discrepancy in the line count. \nAnd the rows were null because while reading the dataframe, I was passing a manually-defined schema. The rows that did not follow the schema got inserted as null rows in the dataframe.","Q_Score":0,"Tags":"python,apache-spark,pyspark,hdfs","A_Id":61807348,"CreationDate":"2020-04-18T01:21:00.000","Title":"Line count discrepancy in pyspark write csv","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a program which reads a text file line by line containing links to pdf files which then downloads the file, split all the pages into another pdf and then covert it to jpeg format. I am now asked to add a pause\/resume functionality to the same. The sequence is it first reads one line then download from the link then split the pdf to pdf of pages then makes images of all the pages then go to another loop, the problem is we don't know the data size and have to further work on the images so we have to pause the program in-between and have to resume after sometime, it can be an hour, 4 hours or even more, please help. It has to start and stop on user command at any point and time when user like.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":61283518,"Users Score":0,"Answer":"A quick update:- Haven't found the exact way for integrating pause\/resume functionality to the script. But did a workaround i.e., Created a log file after downloading pdf file creating images of all the pages of the file and wrote the link in the log file. In the starting of the program, I am comparing the two files i.e., log file and the file containing links and then looping through the difference and downloading file. So, when I stop the function and start it again it will compare links which are in log file(For which the process is completed i.e., images of all the pages is created) and in the file containing all the links and start downloading from the link for which the process was interrupted. Please do let me know if there is a better approach or the pause\/resume functionality is present.","Q_Score":0,"Tags":"python,python-3.x,image,pdf,jupyter-lab","A_Id":61306714,"CreationDate":"2020-04-18T02:27:00.000","Title":"How to integrate a user command-based Pause\/Resume script in Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"How to create json schema required for spark structured streaming? \nTried to generate using \"from_json\" But it's not compatible with pyspark. \nI'm using spark version 2.3.0","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":113,"Q_Id":61284624,"Users Score":0,"Answer":"the method from_json requires that you provide the schema as StructType([StructField(...)]) as its second argument. For your data-stream create a StructType schema and pass it to the function as from_json(datastream,your_msg_schema) and you should be golden.\nIf you need any specific help on the above case, please share the code that you have tried.","Q_Score":0,"Tags":"python-2.7,pyspark,pyspark-sql,jsonschema,pyspark-dataframes","A_Id":63539795,"CreationDate":"2020-04-18T05:29:00.000","Title":"Pyspark Structured Streaming Json Schema","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently seem to have two different directories, one listed under Local\\AppData\\Programs and one under the PyCharm library (the IDE I started using). I was downloading a gmail APK (ezgmail), and I noticed the actions I took in the default IDLE and PyCharm shells had different results when trying to import the module. \nAre these two instances of Python files different? If so, how should I combat installations in the future?\nNote: \n\nI originally used pip to download ezgmail in the shell, but later clicked on the \"download ezgmail\" hyperlink suggestion by PyCharm.)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":61284847,"Users Score":1,"Answer":"PyCharm creates a virtual environment in which you install python packages. The IDLE uses the global python interpreter. \nThe two prgrams are looking for the libraries in different locations. PyCharm creates a virtual environment for every project you create (if you specify but its on by default)","Q_Score":0,"Tags":"python-3.x,pycharm","A_Id":61284961,"CreationDate":"2020-04-18T06:01:00.000","Title":"Two different directories for python files (Default + PyCharm)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am new in python learning.after learning python basics i have moved to learn python web framework Django. for this \n\ni followed these steps for installing django on my windows after installing python 3.7\n\nfirst i opens cmd command prompt (C:\\users\\mypcname)\nthen i  created virtual environment wrapper with command pip install virtualenvironmentwrapper-win\nthen i created virtual environment with command mkvirtualenv test \nthen i entered command workon test to enable virtual environment \nthen tried to install django with command pip install django and its successfully installed \nthen i created projects directory with command mkdir djangoprojects\nthen i created app directory in djangoprojects(which i created in last step) with command django-admin startproject firstproject\nthen i moved to firstproject with command cd..\nthere i tried to run server with command python manage.py runserver and got error \n\n\nTraceback (most recent call last):   File \"manage.py\", line 10, in\n  main\n      from django.core.management import execute_from_command_line ModuleNotFoundError: No module named 'django'\nThe above exception was the direct cause of the following exception:\nTraceback (most recent call last):   File \"manage.py\", line 21, in\n  \n      main()   File \"manage.py\", line 12, in main\n      raise ImportError( ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment\n  variable? Did you forget to activate a virtual environment?\n\n\ncan anyone guide me what i have done here wrong  ? why its showing error","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1858,"Q_Id":61286746,"Users Score":1,"Answer":"i got solution by myself. actually i had downloaded python twice with different versions also i had downloaded python   with anaconda package. i uninstalled all python versions and anaconda from my computer then i reinstalled python from his official website. then i tried above method which works fine.thanks to myself","Q_Score":3,"Tags":"python,django","A_Id":61327856,"CreationDate":"2020-04-18T09:12:00.000","Title":"ModuleNotFoundError: No module named 'django' while running server in virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am creating a Neural Network from scratch for MNIST data, so I have 10 classes in the output layer. I need to perform backpropagation and for that, I need to calculate dA*dZ for the last layer where dA is the derivative of the loss function L wrt the softmax activation function A and dZ is the derivative of the softmax activation functionA wrt to z where z=wx+b. The size obtained for dA is 10*1 whereas the size obtained for dZ is 10*10. \nIs it correct? If yes, who do I multiply dA*dZ as they have different dimension.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":174,"Q_Id":61287179,"Users Score":2,"Answer":"You are almost there. However, you need to transpose dA, e.g. with numpy.transpose(dA).\nThen you will have the right dimensions of dA and dZ to perform matrix multiplication.","Q_Score":1,"Tags":"python,python-3.x,math,neural-network,backpropagation","A_Id":61288488,"CreationDate":"2020-04-18T09:51:00.000","Title":"Working with backpropagation algorithm using softmax function in the neural network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm compiling my kivy app to an apk with buildozer.\nThe first apk bugged, so now I want to change some code.\nIs it sufficient just to delete the apk in the bin folder, or do I have to delete the whole .buildozer folder, in order to make my changes apply?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":61287341,"Users Score":1,"Answer":"If you only change your python code, you don't need to delete anything.","Q_Score":1,"Tags":"python,kivy,apk,buildozer","A_Id":61288821,"CreationDate":"2020-04-18T10:03:00.000","Title":"changing code in kivy app while compiling with buildozer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to make a word game that initially, it has a label and a textinput, after keying input into the textinput and hit enter, i want it to remove the that textinput widget and add 2 things (1) Label with the text (2) A new textinput widget. \nI have been trying to think what should i put for the callback function (fix_it) as the only way i know to remove widgets is by their names i.e. self.layout.remove_widget(self.new_inp), this will remove any subsequent textinput widgets, which i would not be able to see any textinput widgets. \nI would appreciate any help from this community. thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":61288024,"Users Score":0,"Answer":"Not exactly sure what you are asking, but the inp argument of your fix_it method is the TextInput instance. So you can remove it with self.layout.remove_widget(inp).","Q_Score":0,"Tags":"python,kivy","A_Id":61289829,"CreationDate":"2020-04-18T11:01:00.000","Title":"What other ways are there to remove widgets from kivy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a two different python programs. How can I run one program in another when I need it (e.g if a certain condition is met)? \nI heard that I can do that with import <program name>, but when I do this, the program starts immediately and not when I need it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":61288619,"Users Score":0,"Answer":"You can just call the import wherever you need it (not necessarily at the top of the file but in the middle of your code) and wrap it inside an if statement so the import will be called when that condition is fulfilled.","Q_Score":0,"Tags":"python","A_Id":61288669,"CreationDate":"2020-04-18T11:52:00.000","Title":"How can I run a python program in another python program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a library which i can use for faster way to calculate implied volatility in python. I have options data about 1+ million rows for which i want to calculate implied volatility. what would be the fastest way i can calculate IV's. I have tried using py_vollib but it doesnt support vectorization. It takes about 5 mins approx. to calculate. Are there any other libraries which can help in faster calculation. What do people use in real time volatility calculations where there are millions of rows coming in every second?","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17709,"Q_Id":61289020,"Users Score":0,"Answer":"please use py_vollib.black_scholes.greeks.numerical instead of analytical for back testing purpose.  Analytical throwing errors when option strike prices are deep out or in the money as well as illiquid contract, for this case use historical volatility instead of implied volatility to calculate option greeks. try: with iv and except: with hv","Q_Score":7,"Tags":"python,pandas,quantitative-finance,quantlib,volatility","A_Id":72374537,"CreationDate":"2020-04-18T12:23:00.000","Title":"Fast Implied Volatility Calculation in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pointcloud of which I have calculated all present planes. I have the mathematical formula that best describes the planes that contain the points in the point cloud like this: ax+by+cz+d=0. In this formula, a, b, c describe the normal vector of those planes. I know that all planes that I have calculated are either perpendicular to each other or parallel to each other. But due to noise in the point cloud, the resulting normal vectors are not perfectly parallel and perpendicular.\nHow would I calculate the best normal vectors for these planes so they still fit the points as best as possible, but that they are also perfectly perpendicular or parallel to each other? I have some ideas for this that would provide a suboptimal solution, however, I was wondering if there is a method to find the best possible solution to this problem.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":37,"Q_Id":61289573,"Users Score":1,"Answer":"I suggest to distribute the error between normals.\nYou have to types of normals: to one group of planes (parallel) or to the other group (perpendicular to the first group).\nNormals can be weighted-averaged by the number of points in each plane and\/or by the error you get for each plane.\nNow you have only two \"main\" normals, 'A' and 'B'. After normalizing them (divide by its length) their dot product allows to know the angle between both.\nThe difference between the result of the dot product and a 90-degrees angle can be distributed, again with some number-of-points or total-error criteria.\n The two normals form a plane and the difference is applied in this plane, you end rotating the normals a bit around the normal to this plane, each normal with its distributed angle.","Q_Score":1,"Tags":"python,numpy,geometry,plane","A_Id":61294670,"CreationDate":"2020-04-18T13:04:00.000","Title":"Straightening perpendicular planes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pandas MultiIndexed pandas dataframe.  I would like to find the maximum value of one of the (numerical, integer) indices.  \nThat is, the index runs from 1 to 5844.  I want to be able to find the scalar value 5844.  \nI realize that I could just set the scalar variable as I know the values which the index takes, but I'd like to be able to find the maximum value in the case when I don't know it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":61290514,"Users Score":0,"Answer":"If you know that indices go from 1 to 5844 with none missing, df.shape[0] works.","Q_Score":0,"Tags":"python,pandas,multi-index","A_Id":61290688,"CreationDate":"2020-04-18T14:11:00.000","Title":"find the maximum value of a pandas dataframe index","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My friend and I are working on a project. We both setup our vitualenvs but I use python 3.6.9 while my friend is using python 3.7.4. Will this cause issues during development?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":440,"Q_Id":61290847,"Users Score":0,"Answer":"Will this cause issues during development?\n\nIt depends. If you agree to stick to the features that are available in 3.6 it will probably be fine.\nBut it means for example you can't use dataclasses, and you'd have to be careful when using asyncio.\nI would advise you both to use the Python documentation for 3.6. That would lessen the chance of introducing an incompatible feature.","Q_Score":0,"Tags":"python","A_Id":61291609,"CreationDate":"2020-04-18T14:33:00.000","Title":"Are python 3.6.9 and python 3.7.4 compatible?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have downloaded the Anaconda python 3.7 version on my Windows.\nWhen I am writing the \"python\" command on anaconda prompt its opening new window of Microsoft soft to install python 3.8.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":545,"Q_Id":61292133,"Users Score":0,"Answer":"If \"python\" doesn't work, it's usually \"py\" or \"python3\".","Q_Score":0,"Tags":"python,windows,conda","A_Id":61292283,"CreationDate":"2020-04-18T16:01:00.000","Title":"Python command in anaconda prompt not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have downloaded the Anaconda python 3.7 version on my Windows.\nWhen I am writing the \"python\" command on anaconda prompt its opening new window of Microsoft soft to install python 3.8.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":545,"Q_Id":61292133,"Users Score":0,"Answer":"Make sure you are in your environment. Open anaconda prompt and type conda activate [name of your environment] and then try to run python, pip, python3 or pip3","Q_Score":0,"Tags":"python,windows,conda","A_Id":61292504,"CreationDate":"2020-04-18T16:01:00.000","Title":"Python command in anaconda prompt not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm planning on using Django with ReactJS to build a GUI for a complicated database. In order to have features such as auto-completing searching for particular fields, etc, I suppose that using JavaScript is necessary. Is there a way to reuse the models that I made in Python so I don't have to repeat a bunch of code in writing the Django serializers for a REST API and in the models in ReactJS?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":61294273,"Users Score":0,"Answer":"So, as far as I understand, you should create an API, so that your front-end can communicate with your backend. If that is the case, then you do not have to use again any of your models, you will just send a response with the data that you want for each endpoint.\nI hope that helps, please let me know if I misunderstood your question.","Q_Score":0,"Tags":"python,django,reactjs,database,rest","A_Id":61294418,"CreationDate":"2020-04-18T18:34:00.000","Title":"Does Full-Stack Web Development Violate DRY?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm planning on using Django with ReactJS to build a GUI for a complicated database. In order to have features such as auto-completing searching for particular fields, etc, I suppose that using JavaScript is necessary. Is there a way to reuse the models that I made in Python so I don't have to repeat a bunch of code in writing the Django serializers for a REST API and in the models in ReactJS?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":61294273,"Users Score":0,"Answer":"After talking with others who know more than I, I am letting the React frontend be fairly minimal: it will know how to display the data sent to it via Django Channels json packets. The Django backend will handle all the rest (including much of the logic of knowing which pages are accessible from various parts of the database). Thus, the frontend will need minimal knowledge of the structure of the database, and that will preserve the DRY principle.","Q_Score":0,"Tags":"python,django,reactjs,database,rest","A_Id":61414895,"CreationDate":"2020-04-18T18:34:00.000","Title":"Does Full-Stack Web Development Violate DRY?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have Python 3.7 installed (system-wide) along with packages like Numpy, Pandas, pptx, xlsxwriter, and some more. Recently, I learned about virtual environments (yes I am very late to the party), and clearly see the benefits. But I am confused about a few things. Hopefully I can get answers here.\n\nIn most of my projects, I use common packages like Numpy, Pandas, Matplotlib, mysql.connector, etc. Should I install these system-wide? Or should I install them in each virtual environment that I create for each project, which, for example, amounts to installing Pandas 10 times in 10 different virtual environments?\nIf I install packages (system wide) that are not part of the Python Standard Library, for example, pptx and mysql.connector, AND I create a virtual environment, will I have access to these packages from within a virtual environment, or should I install them in the virtual environment as well?\nWhat about a module like jupyter notebook, where it is not part of any project specifically, but I love using it for simple code development and testing (simple plots, etc.). Should this be installed system wide? \n\nI am considering un-installing Python 3.7 and all the packages from my computer, and doing a fresh install of Python 3.8. I want to approach this the \"right\" way. I would think packages like Numpy and Pandas (I do quite a bit of data manipulation\/plotting) should be installed system wide, and each virtual environment should have access to it automatically, and a more specialized package (for me at least) like pptx should be installed in a particular virtual environment for a particular project. Is my assumption correct about this?\nPlease advise on how to best approach package installation in the context of having virtual environments.\nEDIT: based on Ni's reply, I would ask one more question: Are there modules (for example, python-dateutil, that might be used in many projects) and\/or circumstances where it makes sense to install a module system-wide?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":590,"Q_Id":61294775,"Users Score":3,"Answer":"In general, I never install packages system wide.\n\nYou might install packages which require specific versions of Numpy, in your environments. In those cases, if you update the system wide version of Numpy, the package in the environment might break and you won't know that happened.\nYes, you can access them from virtual environment. But in general, don't install packages system wide\nAgain, I wouldn't install that system wide. For e.g., you might have environments running different python versions, which might not be compatible with the same version of Jupyter\n\nSeems like you're doing a lot of data science work - you might want to use Anaconda to help you manage your virtual environments and package installations","Q_Score":0,"Tags":"python-3.x,package,virtualenv","A_Id":61294925,"CreationDate":"2020-04-18T19:08:00.000","Title":"Where to install a Python package - system wide or in a virtual env?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can anyone advise the status of the Sql-Alchemy project for Informix?\nI am relatively new to Python.  I have worked with Dbi and SQL-Alchemy for postgres and made both of those work.\nI have spend many hours trying to make Informix work.  I find the instructions on GitHub for sql-alchemy difficult to follow and I am put off by the comment that says it not yet \"ready\".\nI have made the IfxPy module work and I have also made IfxPyDbi work.  I would be happy to work with IFxPyDbi if the execute method returned a dictionary (like IfxPy.fetch_assoc) but I can only make it return tuples.\nDoes anyone have any advice about the best approach to start working on a python project with Informix.  What is the best place to start?  Am I on the right track with these modules?  Am I missing something on SQL-Alchemy for Informix?\nAny advice would be appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":317,"Q_Id":61296078,"Users Score":1,"Answer":"The Infomix Python driver (IfxPy and IfxPyDbi) is reasonably well tested and Informix team is happy to help you if you face problem. At the same time the Python SQL Alchemy adapter for Informix database it is work in progress and not ready for use; we still need to complete the metadata mapping for the Informix database to produce right output. Unfortunately, we don\u2019t have an ETA yet for this task.","Q_Score":1,"Tags":"python,sqlalchemy,informix","A_Id":61329161,"CreationDate":"2020-04-18T20:51:00.000","Title":"SqlAlchemy Informix Status","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can anyone advise the status of the Sql-Alchemy project for Informix?\nI am relatively new to Python.  I have worked with Dbi and SQL-Alchemy for postgres and made both of those work.\nI have spend many hours trying to make Informix work.  I find the instructions on GitHub for sql-alchemy difficult to follow and I am put off by the comment that says it not yet \"ready\".\nI have made the IfxPy module work and I have also made IfxPyDbi work.  I would be happy to work with IFxPyDbi if the execute method returned a dictionary (like IfxPy.fetch_assoc) but I can only make it return tuples.\nDoes anyone have any advice about the best approach to start working on a python project with Informix.  What is the best place to start?  Am I on the right track with these modules?  Am I missing something on SQL-Alchemy for Informix?\nAny advice would be appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":317,"Q_Id":61296078,"Users Score":0,"Answer":"It should be noted that I\u2019ve found reasonable success using the windows 64-bit informix odbc driver, and pyodbc.\nPython 3.8, informix 12.\nA bit of advice getting it into a data frame.\npd.DataFrame.from_records() is your friend.","Q_Score":1,"Tags":"python,sqlalchemy,informix","A_Id":63759400,"CreationDate":"2020-04-18T20:51:00.000","Title":"SqlAlchemy Informix Status","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently running jupyter notebooks on a Raspberry Pi Zero W. I was trying to download textblob through terminal. The \"pip install -U textblob\" downloaded. However, I received the following:\n\"WARNING: The script tqdm is installed in '\/home\/pi\/.local\/bin' which is not on PATH...\" for each script.\nWhen I went to execute the second line \"python -m textblob.download_corpora\" - I just get \"No module named textblob\"\nAs you can probably guess, I'm quite new to all of this and trying to learn as I go. Please help! :)\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":276,"Q_Id":61296438,"Users Score":0,"Answer":"just put python3 -m textblob.download_corpora in terminal\nWorks for me.","Q_Score":0,"Tags":"python","A_Id":70622138,"CreationDate":"2020-04-18T21:24:00.000","Title":"python -m textblob.download_corpora => No module named textblob","Data 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 somewhat complicated html file and some css styling for it, for example I need to use display: flex and I have some custom fonts, font sizes and font styles.\nAll of this styling stuff is done with css classes.\nCan I convert this html\/xhtml file to a pdf\/epub file with the same formatting? I would prefer a python\/node package or a command line tool.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":255,"Q_Id":61298098,"Users Score":0,"Answer":"You can only use CSS2 styles for pdf\/epub","Q_Score":0,"Tags":"python,html,css,node.js,pdf","A_Id":61298282,"CreationDate":"2020-04-19T00:34:00.000","Title":"Converting a html\/xhtml file with css to pdf\/epub without loosing any of the styling","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a numpy array of size (100, 2, 15, 27) (these are 100 images, with 2 channels of size 15x27). I want to separate the 2 channels in order to get 2 separate arrays of size (100, 1, 15, 27) (I do need that 1 there). How can I do that? I usually pick column using a[:,i], but this higher dimensionality confuses me. Thank you!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":61298595,"Users Score":0,"Answer":"a[:,i] works again. If you need to, you can add dimensions with .reshape(100,1,15,27) or a nicer way, np.expand_dims(a, axis=1).","Q_Score":0,"Tags":"python,numpy","A_Id":61298642,"CreationDate":"2020-04-19T01:52:00.000","Title":"Pick a certain axis from a numpy array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to figure out the best way about how we can use local IDE such as microsoft visual studio code to use distributed computing power. Currently, we are brining data locally but it doesn't seem like sustainable solution because of reasons like in future scale of data will grow, cloud data security, etc. One workaround we thought of is to tunnel into EC2 instances but would like to hear what's best way to solve this in machine learning\/data science environment (we are using databricks and AWS services).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":61300336,"Users Score":0,"Answer":"Not sure why you are connecting IDE to ccomputer . I have used VS Code for running scripts against HDInsight cluster . Before I fire by scripts I do configure the clusters against which it is going to run . The same is true on the Databricks also.","Q_Score":0,"Tags":"python-3.x,visual-studio,amazon-web-services,data-science,databricks","A_Id":61549880,"CreationDate":"2020-04-19T06:18:00.000","Title":"Use local IDE such as Microsoft visual code to use additional compute","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want the user to be able to key into the textinput widget, without the person moving the mouse and click on the textinput widget. Is it possible ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":61300649,"Users Score":0,"Answer":"Try focus:True and it should take focus to the textinput field","Q_Score":0,"Tags":"python,kivy","A_Id":61302723,"CreationDate":"2020-04-19T06:54:00.000","Title":"Running a kivy app, at one screen, for any keyboard button pressed, am i able to key into TextInput widget?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on dataset in which almost every feature has missiong values. I want to impute missing values with KNN method. But as KNN works on distance metrics so it is advised to perform normalization of dataset before its use. Iam using scikit-learn library for this.\nBut how can I perform normalization with missing values.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":769,"Q_Id":61301834,"Users Score":1,"Answer":"For classification algorithms like KNN, we measure the distances between pairs of samples and these distances are influenced by the measurement units also. \nFor example: Let\u2019s say, we are applying KNN on a data set having 3 features. \n1st feature : Range from 1 to 100\n2nd feature : Range from 1 to 200\n3rd feature : Range from 1 to 10000\nThis will led to generated clusters based on 3rd feature. Since, the difference between  1st and 2nd are smaller as compared to 3rd one. To avoid this wrong clustering, we need to have normalization in place.","Q_Score":0,"Tags":"python,scikit-learn,normalization,knn","A_Id":61301846,"CreationDate":"2020-04-19T09:01:00.000","Title":"Why perform normalization of data before KNN Imputation?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to take an excel file, which contains different cell types like dates, currency ETC and parse it with Python including the cell types.\nI have tried using Pandas, but when I open it with Python using pd.read_excel, all of these cell types are disappearing.\nFor Example - a cell containing '50 USD' (Cell containing currency type) will be shown as '50'.\nIs there a method in Python that is able to read these cells with their cell types saved?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":61302777,"Users Score":0,"Answer":"I think you may be confusing cell values and cell formatting. For example, with 50 USD, Excel stores the numeric value and then applies a currency format for display. So it is correct to read it into pandas as an integer if you want to sum, average, or otherwise analyze that column. \nDates should be automatically parsed and, if they aren't, read_excel has a parse_dates parameter that allows you to do so.\nNow, depending on how you want to output the data after you've manipulated it in pandas, you could have a function that outputs a new dataframe that converts all values to string and applies formats to different columns. Or, if you are working in a notebook, you can use the pandas styling API. You could also write the file back to excel with pandas and then apply styles programatically with openpyxl.","Q_Score":0,"Tags":"python-3.x,excel,pandas","A_Id":61309931,"CreationDate":"2020-04-19T10:21:00.000","Title":"Save Excel values while parsing in Python","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install scrot package by apt-get using python on jupyter. The server that I'm trying to make install is an online access jupyter, I don't have direct shell access. So I have to use python for this installation.\nI used:\nimport os\nstream = os.popen('apt-get install -y scrot')\noutput = stream.read()\noutput\nAnd:\nfrom subprocess import check_call, CalledProcessError\nimport os\ntry:\n\u00a0\u00a0\u00a0 check_call(['apt-get', 'install', '-y', 'scrot'], stdout=open(os.devnull,'wb')) \nexcept CalledProcessError as e: \n\u00a0\u00a0\u00a0 print(e.output)\nI used those and codes like them. But they just don't work. No errors, nothing. So I can't determine the problem. Can you help please ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":89,"Q_Id":61302947,"Users Score":0,"Answer":"When you execute a command in OS you use the user that is running the jupyter server.\nFor apt-get something you will need root access, and it's very improbable that the jupyter server is running with that permissions.","Q_Score":0,"Tags":"python,jupyter","A_Id":61303202,"CreationDate":"2020-04-19T10:36:00.000","Title":"Can't use shell commands using python (jupyter)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a very limited dataset having variety of columns having missing values. I can not prune the rows having missing values as it will reduce the size drastically. Can anyone suggest, standard procedure for it ?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":112,"Q_Id":61303255,"Users Score":1,"Answer":"To fill the missing values, you can do one of the following:\n1) Compute the mean of the feature using the available values and then fill the missing values with the mean. If the values are discrete (categorical), then use the most frequent value (mode) to fill the missing ones.\n2) Find the most similar example(s) to the one that has a missing value given that these examples have a value for the particular feature. Then use their mean\/mode along the feature you\u2019re interested in to fill the missing values.","Q_Score":0,"Tags":"python,missing-data","A_Id":61303391,"CreationDate":"2020-04-19T11:03:00.000","Title":"What are the standard ways of filling missing values in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently made a script that allow me to create multiple Browser sessions targeting one URL. I would like to add proxy support to it in order to not get banned when running it. I tried to use the Proxy lib from selenium but it just get ignored. \nMy Question : How can I add proxy support into this script while using Selenium in python ? (each session will get a random proxy) \nHere is my code","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":653,"Q_Id":61306701,"Users Score":0,"Answer":"Here is an updated version of my code including the new proxy support elements, I want it to use proxies form a txt file via a  proxies = read_from_txt(\"proxies.txt\") and randomly rotate between them using random lib :\nThank you for quick replies, really appreciate it.","Q_Score":1,"Tags":"python,python-3.x,selenium,proxy,selenium-chromedriver","A_Id":61308104,"CreationDate":"2020-04-19T15:14:00.000","Title":"Adding proxy support to Selenium multi session opening script in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to have a list which my main process will add data to and this seperate thread will see the data added, wait a set amount of eg 1 minute then remove it from the list. Im not very experience with multi-threading in python so i dont know how to do this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":61307818,"Users Score":0,"Answer":"The way you could achieve this is by using a global variable as your list, as your thread will be able to access data from it. You can use a deque from the collections library, and each time you add something in the queue, you spawn a new thread that will just pop from the front after waiting that set amount of time. \nAlthough, you have to be careful with the race conditions. It may happen that you try to write something at one end in your main thread and at the same time erase something from the beginning in one of your new threads, and this will cause unexpected behavior.\nBest way to avoid this is by using a lock.","Q_Score":0,"Tags":"python,python-3.x,multithreading","A_Id":61311738,"CreationDate":"2020-04-19T16:28:00.000","Title":"Python Seperate thread for list which automatically removes after time limit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Spyder after VS Code and now want to open my Django project folder. I'm following these steps:\nProjects > New project > Existing directory > Create but Spyder opens some temp.py which after closing opens untitled0.py,untitled1.py,untitled2.py and so on. How can I see my project structure, files as in VS Code ?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":7665,"Q_Id":61309159,"Users Score":7,"Answer":"On the right side of IDE there is a window containing some subwindows like IPython console, Variable explorer, Help and so on. We are clicking on Files and see our project folder.","Q_Score":9,"Tags":"python,django,spyder","A_Id":61312353,"CreationDate":"2020-04-19T17:59:00.000","Title":"How to open a project folder in Spyder IDE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"How to run keras.model.fit() in graph not with eager execution...??\nI tried to run my model in graph by using tf.compat.v1.disable_eager_execution(), but the code return error: numpy must be run with eager execution \nThe error appear after checkpoint model\nI\u2019m using tensorflow GpU 2.1.0 and keras 2.3.1","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1203,"Q_Id":61309661,"Users Score":1,"Answer":"In tensorflow2.x, model.fit() runs in graph mode by default, you can control this behavior by using the run_eagerly argument in the model.compile(...) method, which defaults to False.","Q_Score":2,"Tags":"python-3.x,tensorflow,keras","A_Id":61310421,"CreationDate":"2020-04-19T18:37:00.000","Title":"Run keras.Models.fit() in graph","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I receive API data every 5 minutes and run a Python code to check if the incoming data fulfills certain conditions. The data is in JSON format, but I convert it to a data frame and perform my checks there.\nIn case one of the checks generates a hit, I'd like to get notified. I'd like to find a fast and resource-preserving way for Python to notify me.\n\nI think I can't use \"print()\" as I won't be watching Python all the time. \nI could use \"data.to_excel\", but I'd still have to have a window of my folder open and check manually if a new excel file appears.\nI read that Tkinter is widely used to generate a new window so I guess that's the way to go.\n\nWhat would be the most efficient (minimalistic) code to generate a window (preferably one with an audio sound when it appears) with one line of text, e.g. \"Condition1\/2\/3\/4 fulfilled, timestamp, string\"\nThank you for your kind help","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":77,"Q_Id":61311388,"Users Score":1,"Answer":"You can do something even easier than that to help you notify when you got something. You can use the os library to just open the file whenever something gets printed to it. Let's say you use the data.to_excel. Afterwards, you can just open it.\nTo do that, you can just import os, and the function is os.system(path_of_excel_file). In the path tho you have to be careful and use backslashes for spaces or other special characters.","Q_Score":2,"Tags":"python,audio,tkinter,window,memory-efficient","A_Id":61311475,"CreationDate":"2020-04-19T20:43:00.000","Title":"Python - notify user every time a loop yields an output Tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating an array of surfaces (Pre-Rotated or pre-effect treated) and its working nicely and extremely fast for python anyhow.  However I notice there is a massive amount of memory being used and I tracked it down to the fundamental loading of the original image or creating a surface copy.  \nThe image i'm testing with is 65kb png file on disk.  Loading the image or copying a surface with this same image resuls in 1.2mb additional memory usage.  I could understand 2,3,4x but 20x?   So preloading a solid number of small images to make things faster sounds good until I understood this memory impact.  The net is if I pre-rotated this image by 5 degrees aka 72 images (360\/5) python image memory is sitting at 100mb not including the routine overhead of the modules etc...  This seems quite unbelievable actually. \nAnyone got any ideas as to why\/how\/tips\/tricks etc... ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":61311402,"Users Score":0,"Answer":"Found kind of an answer that helps drastically.  It looks like the image load routine bit depth is tied directly to the display.set_mode bit depth which on my system is 32bit default basically forcing 32bit depth on all images uploaded.  Considering I only need max 16 bit depth on the display as well as the images this got the bloat down to about 7x or so.  Still larger than I think is reasonable but makes what i'm trying to do within the realm of possibility.","Q_Score":2,"Tags":"python,pygame","A_Id":61313493,"CreationDate":"2020-04-19T20:45:00.000","Title":"How to reduce the impact of large memory usage on small images loaded?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been writing games in the pygame library for a while on my computer. I have been wanting to begin writing games for iOS that could potentially be put on the App Store. If I were to want to do this in Python, what is the best library to use?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":322,"Q_Id":61313771,"Users Score":0,"Answer":"There's a few options that you can try, such as Kivy, Pymob and maybe BeeWare, but I wouldn't recommend this language to do app development and even less for IOS. My suggestion is to start to learn Dart and use Flutter or React Native that also provides a large variety of options. As far as gamedev, the best and most well-known platform is Unity, using C#.","Q_Score":2,"Tags":"python,ios,python-3.x,pygame","A_Id":61314082,"CreationDate":"2020-04-20T01:20:00.000","Title":"What is the best library to write iOS games in Python 3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the  sklearn.impute.IterativeImputer with extra tree regressor and it is taking too much time, it's almost been an hour and it is still running. Is there a way I can check how much has been executed and estimated time left?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":885,"Q_Id":61314216,"Users Score":1,"Answer":"I don't you can tell estimated time as a direct measure or so. But use verbose=2 as a paramter to sklearn.impute.IterativeImputer. That will give you some idea about how what it is doing and every step. So You can estimate may be rough estimated time, if you have knowledge on algorithm.","Q_Score":0,"Tags":"python,scikit-learn,iteration,imputation","A_Id":61314263,"CreationDate":"2020-04-20T02:25:00.000","Title":"Execution time for sklearn.impute.IterativeImputer","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My model aims to predict radio listening in hours (on a given day at a given time for 1 specific radio station. Each row of my training set represents 1 hour blocks for each day of the year and has a little under 30,000 records going back 3.5 years. My features include parametric information such as date, station, day of week, start time as well as weather information. \nRecently I added 2 binary features which I expected would help the accuracy of the model but they don't. They are whether a station is running a contest at a given time (contests help to pull more audiences) and if the station is playing Christmas music or not (X-Mas music tends to also pull audiences). When I run a Pearson correlation of all my features vs. my dependent variable (amount of listening hours), these 2 features are in the top 4 of the most correlated features (0.16 for X-Mas music and 0.20 for contests) with the highest correlated feature sitting at 0.31. When there is a contest listening hours tend to double and when X_mas music is playing, hours tend to increase by about 50%. Interestingly, my predictions are also proportionately higher when these 2 features are True (1's).\nThe way I know that these features are not adding predictive value is that when I remove them from my dataset to train the model and make predictions, the model accuracy does not improve. I am measuring Mean Absolute Error, MSE and R2 to evaluate the model performance.\nAny ideas as to why important features to the dependant variable, not very correlated with other features, are not helping to reduce errors?\nI am running a RF with 100 trees. The issue is there if I only run a single tree as well.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":61314925,"Users Score":0,"Answer":"It could be that the other features that you are using as input are already enough to give accurate predictions. Thus including the two binary features does not improve the model accuracy. Id estimate variable importance to see how important the two binary features are relevant to overall predictions.","Q_Score":0,"Tags":"python-3.x,random-forest,feature-selection","A_Id":61361896,"CreationDate":"2020-04-20T04:01:00.000","Title":"Correlated features to the dependent variable don't improve the accuracy of a Random Forest regression model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a function change_weight() that modifies weights in any given model. This function resides in a different python file.\nSo if I have a simple neural network that classifies MNIST images, I test the accuracy before and after calling this function and I see that it works. This was easy to do in TensorFlow v1, as I just had to pass the Session sess object in the function call, and I could get the weights of this session in the other file.\nWith eager execution in TensorFlow v2, how do I do this? I don't have a Session object anymore. What do I pass?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":61315403,"Users Score":0,"Answer":"I was able to do this by passing the Model object instead and getting the weights by model.trainable_variables in the other function.","Q_Score":0,"Tags":"python,tensorflow,tensorflow2.0,eager-execution","A_Id":61327591,"CreationDate":"2020-04-20T05:00:00.000","Title":"How do you pass session object in TensorFlow v2?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get response from lambda in AWS API Gateway. I always get no data message with 200. But I return different message in lambda. Gateway and Lambda connected with non-proxy, because I have to add X-AMZ-Invocation-Type : event for async response. How can I change body of response using lambda?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":811,"Q_Id":61316870,"Users Score":1,"Answer":"The message you see is not coming from lambda. At async invocation; api gateway returns the response first, then make a request to lambda \"asynchronously\". it is normal you to see different messages between lambda and api gateway test. You can't change response the body of response using lambda. \nNo response will be return with async integration (couldn't find it documentation to support this - but tried several times)","Q_Score":2,"Tags":"python-3.x,amazon-web-services,aws-lambda,async-await,aws-api-gateway","A_Id":61317826,"CreationDate":"2020-04-20T07:09:00.000","Title":"Always getting \"no data\" response in AWS Gateway with success code 200","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got an error downloading Anaconda. Let me explain step by step :\n\nI download windows 64 bits installer (I'm on win 10)\nI launch the exe\nI follow the steps, don't do anything, just accept and run it\nIt says \"space required : 3Gb, space disponible : 41Gb\"\nIt installs Anaconda really fast\nWhen I start _conda.exe, the only exe (with the uninstaller), a cmd appears,writes some lines and closes. Just that, nothing else.\n\nMy Anaconda 3 folder says \"466Mb\", not 3Gb at all... Coincidence ?\nMy installer weights also 466Mb... Did it just extract the installer or something ?\nGuys on other forums that have Anaconda told me I got less than half of the files. How could I download it properly ? Where is the problem located ? The computer ? The installer ? Something else ?\nI already got python and Sublime Text, and in the installer, there are options with path etc... I didn't touch that but maybe the error comes from here ?\nThank you so much if you can help, have a nice day !","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":61317942,"Users Score":0,"Answer":"Oooooh it worked ! Thanks to John Coleman that gave me the link ^^\nIt was said inside that a guy had the same problem, installed the 32-bits version and it worked... So I did same and now I got way more files and it works !\nThanks to all who answered !","Q_Score":1,"Tags":"python,python-3.x,anaconda","A_Id":61323537,"CreationDate":"2020-04-20T08:18:00.000","Title":"Anaconda doesn't install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"error code: \nclient = pymongo.MongoClient(\"mongodb+srv:\/\/********?retryWrites=true&w=majority\")\nFile \"\/home\/ubuntu\/.local\/lib\/python3.6\/site-packages\/pymongo\/mongo_client.py\", line 621, in init\nconnect_timeout=timeout)\nFile \"\/home\/ubuntu\/.local\/lib\/python3.6\/site-packages\/pymongo\/uri_parser.py\", line 463, in parse_uri\nnodes = dns_resolver.get_hosts()\nFile \"\/home\/ubuntu\/.local\/lib\/python3.6\/site-packages\/pymongo\/srv_resolver.py\", line 102, in get_hosts\n_, nodes = self._get_srv_response_and_hosts(True)\nFile \"\/home\/ubuntu\/.local\/lib\/python3.6\/site-packages\/pymongo\/srv_resolver.py\", line 83, in _get_srv_response_and_hosts\nresults = self._resolve_uri(encapsulate_errors)\nFile \"\/home\/ubuntu\/.local\/lib\/python3.6\/site-packages\/pymongo\/srv_resolver.py\", line 79, in _resolve_uri\nraise ConfigurationError(str(exc))\npymongo.errors.ConfigurationError: query() got an unexpected keyword argument 'lifetime'\nversions: \npython 3\npymongo: 3.10.1","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":61320226,"Users Score":0,"Answer":"In my case was solution to use older type of URL:\nclient = pymongo.MongoClient(\"mongodb:\/\/:@...\nSW:\n\nUbuntu 18.04\nPython 2.7.17 \/ 2.7.12\nPymongo 3.11.1\nGoogle Cloud SDK 319.0.0\n\nConnection from test file directly for os was OK, but same code run from Google SDK dev appserver2 failed.\nAfter change URL generated by cloud.mongodb.com Atlas\nin section Cluster -> Connect -> Choose a connection method -> Python - 3.4 or later\nIt finally (after 4 days searching) started working.","Q_Score":0,"Tags":"python,pymongo","A_Id":64961308,"CreationDate":"2020-04-20T10:27:00.000","Title":"pymongo error on ec2 but working on VM on laptop","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm writing a tool to update my bigquery tables to reflect my locally defined schemas. Let's say I'm updating the table users. The steps for doing this are:\n\nCreate a new table with the new schema, called users_update.\nCreate a SELECT query where values are cast (e.g. TIMESTAMP to DATETIME), and new columns added (e.g. CURRENT_TIMESTAMP() as date_updated)\nRun a QueryJob (python) to execute the query with the new table as the destination.\nDelete the table users\nCopy users_update to users\nDelete the table users_update\n\nThe problem is that this query converts every field in the new table to NULLABLE. I've stepped through my script, and I've verified that the new table has correct modes before the QueryJob. I also provide the new schema (with correct modes) to the QueryJob.\nAre there some parameters to the QueryJob I need to set, or what am I missing here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":61320473,"Users Score":1,"Answer":"I had set the job_config.write_disposition to WRITE_TRUNCATE. Removing this solved my issue.","Q_Score":1,"Tags":"python,google-bigquery","A_Id":61322170,"CreationDate":"2020-04-20T10:39:00.000","Title":"Google BigQuery: SELECT with destination table overrides field modes to NULLABLE","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My use case is the following: i developed a small python script which does some time-series analysis and then writes the output into a database table where it's used by an Oracle application. The script resides on the server and is run from the Oracle interface. All is working good but i want to be able to retrieve any potential errors from the script into a database table. Is this possible?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":13,"Q_Id":61323099,"Users Score":1,"Answer":"Yes, you can either:\n\nwrap all of the script's main logic in a try: except Exception as exc: block, and then use the exception handler to post the traceback (traceback.format_traceback()) to your database\nuse a separate wrapper script that runs your script, and in case it fails (returncode != 0), post the stderr output to your database","Q_Score":1,"Tags":"python,linux,database,oracle","A_Id":61323158,"CreationDate":"2020-04-20T12:58:00.000","Title":"Retrieving Python errors into an Oracle database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i run this command sudo apt install python3.7.\nE: The package libglu1-mesa:i386 needs to be reinstalled, but I can't find an archive for it.\nthis error massage still showing.\nReading package lists... Done\nBuilding dependency tree\nReading state information... Done\nSuggested packages:\n  python3.7-venv python3.7-doc\nThe following NEW packages will be installed:\n  python3.7\n0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.\n1 not fully installed or removed.\nNeed to get 0 B\/528 kB of archives.\nAfter this operation, 439 kB of additional disk space will be used.\nSelecting previously unselected package python3.7.\n(Reading database ... 199040 files and directories currently installed.)\nPreparing to unpack ...\/python3.7_3.7.7-1+bionic1_amd64.deb ...\nUnpacking python3.7 (3.7.7-1+bionic1) ...\nProcessing triggers for mime-support (3.60ubuntu1) ...\nProcessing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...\nSetting up python3.7 (3.7.7-1+bionic1) ...\nProcessing triggers for man-db (2.8.3-2ubuntu0.1) ...\ndpkg: error processing package libglu1-mesa:i386 (--configure):\n package is in a very bad inconsistent state; you should\n reinstall it before attempting configuration\nProcessing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...\nErrors were encountered while processing:\n libglu1-mesa:i386\nE: Sub-process \/usr\/bin\/dpkg returned an error code (1)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":394,"Q_Id":61323869,"Users Score":0,"Answer":"use sudo apt-get install software-properties-gtk","Q_Score":0,"Tags":"python-3.x","A_Id":61323947,"CreationDate":"2020-04-20T13:39:00.000","Title":"How to install software-properties-gtk package in python? on ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am writing a test using Stateful Testing feature of hypothesis.\nI am finding out that after a certain number of state changes, the testing restarts from the beginning.\nHow can I make it continue along existing path?\nI have set max_examples=1 and stateful_step_count=999999 but that does not seem to help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":61324716,"Users Score":0,"Answer":"Occasional restarts are an intentional feature of stateful tests, and must be possible for us to present a minimal (fewest steps) counterexample if your test fails.\nIn your specific case, I suspect that the statemachine is 'getting stuck' and having to retry some steps.  Because it could not complete max_step steps, it may not count as an example for max_examples!\nFor more detailed comments, I'd have to see your actual code and an example output :-)","Q_Score":0,"Tags":"python,python-hypothesis","A_Id":61377574,"CreationDate":"2020-04-20T14:18:00.000","Title":"Stateful Testing gives up halfway and restarts from the beginning","Data Science and Machine Learning":0,"Database and SQL":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 problem with PyQt5 Designer. I install PyQt with -pip install PyQt5 and then -pip install PyQt5-tools\neverything OK. But when i try to run Designer it open messagebox with error: This application failed to start because no Qt platform plugin could be initialized!\nhow to deal with it?","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":16045,"Q_Id":61324972,"Users Score":10,"Answer":"Try running it using command: pyqt5designer\nIt should set all the paths for libraries.\nWorks on Python 3.8, pyqt5-tool 5.15","Q_Score":11,"Tags":"python,qt,user-interface,pyqt,pyqt5","A_Id":62589185,"CreationDate":"2020-04-20T14:29:00.000","Title":"PyQt5 Designer is not working: This application failed to start because no Qt platform plugin could be initialized","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have a problem with PyQt5 Designer. I install PyQt with -pip install PyQt5 and then -pip install PyQt5-tools\neverything OK. But when i try to run Designer it open messagebox with error: This application failed to start because no Qt platform plugin could be initialized!\nhow to deal with it?","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":16045,"Q_Id":61324972,"Users Score":4,"Answer":"I found a way of solving this:\nGo to you python instalation folder Python38\\Lib\\site-packages\\PyQt5\\Qt\\bin\nThen copy all of that files to your clipboard and paste them at Python38\\Lib\\site-packages\\pyqt5_tools\\Qt\\bin\nThen open the designer.exe and it should work.","Q_Score":11,"Tags":"python,qt,user-interface,pyqt,pyqt5","A_Id":61577871,"CreationDate":"2020-04-20T14:29:00.000","Title":"PyQt5 Designer is not working: This application failed to start because no Qt platform plugin could be initialized","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have a problem with PyQt5 Designer. I install PyQt with -pip install PyQt5 and then -pip install PyQt5-tools\neverything OK. But when i try to run Designer it open messagebox with error: This application failed to start because no Qt platform plugin could be initialized!\nhow to deal with it?","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":16045,"Q_Id":61324972,"Users Score":26,"Answer":"Go to => \nPython38>lib>site-packages>PyQt5>Qt>plugins\nIn plugins copy platform folder\nAfter that go to\nPython38>lib>site-packages>PyQt5_tools>Qt>bin\npaste folder here .  Do copy and replace.\n\nThis will surely work..\nNow you can use designer tool go and do some fun with python...","Q_Score":11,"Tags":"python,qt,user-interface,pyqt,pyqt5","A_Id":62443116,"CreationDate":"2020-04-20T14:29:00.000","Title":"PyQt5 Designer is not working: This application failed to start because no Qt platform plugin could be initialized","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would want to implement the following logic in pandas:\nif df['xxx'] <= 0 then df['xyz']== 'a'\nif df['xxx'] between 0.5 and 10.97 then df['xyz']== 'b'\nif df['xxx'] between 11 and 89.57 then df['xyz']== 'c'\nif df['xxx'] > 100 then df['xyz']== 'd'\nHow can I do this in the simplest way?\nMuch thanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":84,"Q_Id":61328489,"Users Score":1,"Answer":"df['xyz'] = df.apply(lambda x: 'a' if x['xxx'] <=0 else ('b' if x['xxx'] < 1000 else 'c' ))\nthere might be syntax errors","Q_Score":0,"Tags":"python,pandas","A_Id":61328786,"CreationDate":"2020-04-20T17:32:00.000","Title":"Assigning values based on existing numeric values in a column in pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to develop a monolithic Django application with Uncle Bob's clean architecture. The problem is I don't want to miss the powerful abilities of Django ORM but this will make a confusion at the same time. The ORM will handle the repository and data layer of application but at the same time makes problem in DTO because I don't want to transfer objects of type Django model.\nShould I create a port to convert Django model objects into plain old Python objects? I think Django is not much suitable for integrating with clean architecture. I mean for a monolithic large scale application Django will have many down sides.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1561,"Q_Id":61330495,"Users Score":2,"Answer":"When you talk about Clean architecture, are you talking about hexagonal architecture ? If yes, your question is not only related to Django but to all languages.\nThe fundamental principle about the domain is that it should not have any dependencies. Given this principle, if a DTO is used by the ORM, it is very likely that you will have to do the mapping ORM Entities <-> Domain Model\nWhatever the framework, and therefore the ORM that you use, it must not be imported into the domain which must remain agnostic in relation to everything and must therefore be coded in plain old language objects.","Q_Score":3,"Tags":"python,django,oop,clean-architecture","A_Id":61545006,"CreationDate":"2020-04-20T19:28:00.000","Title":"integrating clean architecture with ORM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am currently trying to get a voice assistant kinda thing going for which i need to test for a variable in a Sentence, for example \n\n\"What will the weather be in 'cityname'\"\n\n. The basic thing i kind of figured out with this: \nif 'What' in Sinput and ... Sinput is a list with the Input words, better ways are welcome.\nBut the only problem is that when i do a second if statement which goes for \n\n\"What will the weather be in 'cityname' tomorrow\"\n\n, both statements will be run and i have yet to find the workaround for this!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":61330996,"Users Score":1,"Answer":"This is simply because two if statements can't work together. You need to do your first if statement and then do an elif statement as many times as you have commands.","Q_Score":0,"Tags":"python,python-3.x,if-statement,speech-recognition","A_Id":61927410,"CreationDate":"2020-04-20T19:57:00.000","Title":"Python if input statements with similar sentences","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know whether there is a difference between defining the same function as given bellow: \nf=lambda t,y: -y  and f=lambda y:-y \nI'm learning how to solve ODEs in python and they are using this simple function in examples.\nI get that y depends on t for the differential equation to make sense.\nSo when we define a function using lambda with t and y in the left hand side but the right hand side actually contains only y, does it says y depends on t?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":111,"Q_Id":61334517,"Users Score":3,"Answer":"The difference is that f=lambda t, y: -y takes two arguments but the t is unused, and f=lambda y: -y only takes one. To put it in mathematical terms:\n\nf=lambda t, y: -y  = f(t, y) = -y\nf=lambda y: -y  = f(y) = -y","Q_Score":0,"Tags":"python","A_Id":61334554,"CreationDate":"2020-04-21T01:20:00.000","Title":"Difference between `f=lambda t,y: -y` and `f=lambda y:-y`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use dmatrices() function from patsy package in pycharm, but I get following error when impoting:\nfrom patsy import dmatrices\nCannot find reference 'dmatrices' in 'init.py' \nmy python version is 3.8","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":296,"Q_Id":61334977,"Users Score":1,"Answer":"I know this is SUPER old at this point but from patsy.highlevel import dmatrices actually solved the issue for me. I just ran into this exact issue","Q_Score":2,"Tags":"python,patsy","A_Id":66617297,"CreationDate":"2020-04-21T02:23:00.000","Title":"cannot import dmatrices from patsy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am exploring the Jupiter notebook for Python. While calling this method \"Access OutbreakLocation data\" I get this exception in Python 3.6:\ngetting AttributeError: module 'pandas' has no attribute 'json_normalize'\nAny ideas how can we fix this issue?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28052,"Q_Id":61336238,"Users Score":15,"Answer":"Make sure to update to Pandas 1.0.3. Pandas prior to version 1 doesn't have json_normalize.","Q_Score":16,"Tags":"python","A_Id":61347947,"CreationDate":"2020-04-21T04:58:00.000","Title":"Getting AttributeError: module 'pandas' has no attribute 'json_normalize' while calling method \"Access OutbreakLocation data\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I have two branches of a Python application, threads that uses the threading module, and process that uses the multiprocessing module. These two branches differ only with respect to how they execute concurrent tasks.\nNow, say I create another branch feature. How can I add the commits of feature to both threads and process, so that threads and process stay up-to-date and include the same features?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":28,"Q_Id":61336452,"Users Score":1,"Answer":"Thanks for clarifying @Shuzheng. I am writing what I understood from your question and my response after that.\nWhat I understood from your question :\n\nI have a branch thread.\nI have a branch process.\nNow I create a new branch feature that I am going to use for development.\n\n--> It is not clear feature branch was created from what source\/base.\nHere is how I would deal with this issue -\n\nDevelop on feature branch and make code changes there.\nOnce the feature is developed I would git merge branch feature into thread and process. \nThere could be some merge-conflicts arising when I do it for the first time. But from 2nd time onwards if we maintain this process, it would be very simple 1 minute job.\n\nThis is like pulling the changes done in feature branch into other 2 branches.\nAlso, I would suggest to use some IDE for doing this as it makes visualization very easy during merging.","Q_Score":1,"Tags":"python,git","A_Id":61336752,"CreationDate":"2020-04-21T05:20:00.000","Title":"How can I add the commits of a branch (e.g. rebase) onto two other primary branches?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I run an app and from the app it directs me to chrome for login. After which I give my email and password and then after successful login I get redirected to app. Now the question is in case I need to run it again I need to manually clear the cache and free up space every time login happens and this does not allow me to run all codes in one stretch. Can you please let me know is there a way to automate clearing cache and free up space using python and appium.I run my code on ubuntu os platform.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":208,"Q_Id":61337086,"Users Score":0,"Answer":"Add adb shell pm clear packageName to your test file wherever you need and try","Q_Score":0,"Tags":"browser-cache,appium-android,python-appium,appium-desktop,android-chrome","A_Id":61352803,"CreationDate":"2020-04-21T06:17:00.000","Title":"Is there any way of clearing cache and free up space from android using appium 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 working on Django and I know to create a account to log in into admin page I have to create a superuser.And for that we have to pass the command python manage.py createsuperuser.\nBut my question is when we pass this command what happens first and because of what in the background and after that what happens?? Which all methods and classes are called to create a superuser??\nI know its a weird question but I wanted to know how this mechanism works..\nThanks in advance!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":114,"Q_Id":61337176,"Users Score":0,"Answer":"Other people will answer this in detail but let me tell you in short what happens.\nFirst when you pass the command python manage.py createsuperuser you will be prompted to fill the fields mentioned in USERNAME_FIELD and REQUIERD_FIELDS, when you will fill those fields then django will call your user model manager to access your create_superuser function and then code in that will execute to return a superuser.\nI hope this will help you.","Q_Score":0,"Tags":"python,django","A_Id":61337362,"CreationDate":"2020-04-21T06:23:00.000","Title":"What happens in background when we pass the command python manage.py createsuperuser in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was wondering if there is any function\/tool in Python which allows me to get the absolute path of a file directly from the computer, instead of having to manually search for the absolute path of the particular file, or having to shift the file to the same folder as the script. I am trying to access a .csv file stored in another folder different from my python script.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":61337235,"Users Score":0,"Answer":"You can use the os.path module. See the join method which will accept relative path fragments and the abspath method which will give you the absolute path.","Q_Score":0,"Tags":"python,file,directory,path,absolute","A_Id":61337473,"CreationDate":"2020-04-21T06:27:00.000","Title":"Is there a way to get an absolute path of a file which is not in the current working directory (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 Django server running which utilizes files in a directory \/PROCESSING_DOCS\/*.json. An API call dynamically adds more files to this folder. Now I need to maintain a queue which updates the files added into that folder dynamically.\nHow can I implement this? I don't have any idea.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":61337273,"Users Score":1,"Answer":"Here are a few suggestions right off the top of my head:\nIf you just need to keep a log of what files were added, processing status, etc:\n\nsince you're doing a lot of I\/O you can add another file (ex: named files_queue) and append the filenames one per line. Later you may add additional details (CSV style) about each file (would be a bit of a challenge to search through it if this file grows big).\nrelated to the first idea, if the number of files is not an issue you may create a file (like a .lock file for example) for each file processed and maybe store all processing details in it (and it will be easy to search).  \nif your application is connected to a database, create a table (ex: named files_queue) and insert one row per each file. Late you may add additional columns to the table to store additional details about each file. \n\nIf you're looking for queue manager there are a few solutions just a \"python queue\" google search away. I personally have used RabbitMQ.\nHope this helps,\nCheers!","Q_Score":1,"Tags":"django,python-3.x","A_Id":61337497,"CreationDate":"2020-04-21T06:31:00.000","Title":"How to synchronously add files in a queue?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"When we visualize the LDA using pyLDAvis, we can see topic overlap. I want know the word that is causing this topic overlap. Or I want to know the words that are at the intersection of the topic bubbles. Any guidance is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":407,"Q_Id":61337315,"Users Score":0,"Answer":"Select topic 2\nCopy a list of words from the right (the ones with bars)\nSelect topic 5\nCopy the list as in 2.\nCompare the copied lists on your own.\n\nI am not sure there is any better method there...","Q_Score":0,"Tags":"python-3.x,gensim,lda,topic-modeling,pyldavis","A_Id":61344214,"CreationDate":"2020-04-21T06:34:00.000","Title":"Common words that cause topic overlap in gensim LDA","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im trying to apply infersent embed-dings on 400k records and the kernel dies every-time i run. i wanted to understand the CPU utilisation, but not able to find any commands which can do it in Jupyter notebook","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":228,"Q_Id":61338082,"Users Score":0,"Answer":"400k records are too many, maybe your machine does not support them, you can check the processes in:\nMac: Activity Monitor\nWindows: Task Manager\nLinux: htop in terminal\nA way to fix it is create a sample and run the process or run it on a more powerfull server.","Q_Score":0,"Tags":"python,jupyter-notebook,word-embedding","A_Id":65604624,"CreationDate":"2020-04-21T07:26:00.000","Title":"Check CPU utilisation of command in Jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am reading over 100 million records from mongodb and creating nodes and relationships in neo4j. \nwhenever I run this after executing certain records I am getting pymongo.errors.CursorNotFound: cursor id \"...\" not found\nearlier when I was executing it without \"no_cursor_timeout=True\" in the mongodb query then at every 64179 records I was getting the same error but after looking for this on StackOverflow I had tried this adding no_cursor_timeout=True but now also at 2691734 value I am getting the same error.  HOW CAN I GET RID OF THIS ERROR I had also tried by defining the batch size.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1292,"Q_Id":61338852,"Users Score":0,"Answer":"Per the ticket Belly Buster mentioned you should try:\n\nmanually specifying the session to use with all your operations, and\nperiodically pinging the server using that session id to keep it alive on the server","Q_Score":0,"Tags":"python,mongodb,pymongo,pymongo-3.x","A_Id":61355353,"CreationDate":"2020-04-21T08:13:00.000","Title":"getting pymongo.errors.CursorNotFound: cursor id \"...\" not found","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I want to convert this list:\n[[[1,2]],[[1,2],[3,4]]]\nto a numpy array. \nHowever it gives me:\n[list([[1,2]]),list([[1,2],[3,4]])]","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27,"Q_Id":61341079,"Users Score":0,"Answer":"The list is not rectangular, it wont work","Q_Score":0,"Tags":"python,numpy","A_Id":61341156,"CreationDate":"2020-04-21T10:15:00.000","Title":"3D list to Numpy array conversion not working, it gives me list object instead","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to install a newer version of Anaconda (Individual Edition) on an offline Windows PC at work. Can I just transfer the 64-Bit Graphical Installer (466 MB) to the PC and complete the installation without internet connection? (I am asking because I would like to be sure about this before I deinstall the old version that is currently installed)\nedit: Simply running the Installer worked. No need for console commands or anything. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":589,"Q_Id":61341189,"Users Score":0,"Answer":"of course you can, if you are using Anaconda's offline install packge, it doesn't need internet connection when you installing","Q_Score":0,"Tags":"python,anaconda","A_Id":61342025,"CreationDate":"2020-04-21T10:21:00.000","Title":"Can I install Anaconda on an offline Windows PC?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using the stripe subscription API to provide multi tier accounts for my users. but about 50% of the transactions that i get in stripe are declined and flagged as fraudulent. how can i diagnose this issue knowing that i'm using the default base code provided in the stripe documentation (front end) and using the stripe python module (backend).\nI know that i haven't provided much information, but that is only because there isn't much to provide. the code is known to anyone who has used stripe before, and there isn't any issue with it as there are transaction that work normally.\nThank you !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":284,"Q_Id":61343164,"Users Score":0,"Answer":"After contacting stripe support, i found that many payments were done by people from an IP address that belongs to a certain location with a card that is registered to a different location.\nfor example if someone uses a French debit card from England. i did ask stripe to look into this issue.","Q_Score":0,"Tags":"python,stripe-payments","A_Id":61781112,"CreationDate":"2020-04-21T12:05:00.000","Title":"Stripe too many high risk payments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've made a python program using Tkinter(GUI) and I would like to enter it by creating a dedicated icon on my desktop (I want to send the file to my friend, without him having to install python or any interpreter).\nThe file is a some-what game that I want to share with friends and family, which are not familiar with coding.\nI am using Ubuntu OS.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":61344451,"Users Score":-1,"Answer":"you can use pip3 install pyinstaller then use pyinstaller to convert your file to a .exe file than can run on windows using this command pyninstaller --onefile -w yourfile.\nit can now run without installing anything on windows. and you can use wine to run it on ubuntu","Q_Score":1,"Tags":"python,deployment,pyinstaller","A_Id":61344731,"CreationDate":"2020-04-21T13:14:00.000","Title":"how to make my python project as a software in ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering why it is possible that the following command works: \nairflow test [dag_id] [task_id] 20200421\nbut that the same task fails if I trigger the dag manually in the UI. \nThe task itself is quite easy, it is basically: \ncmd = 'ls' # other command\nos.system(cmd)\nthe os library is imported, and like said above, in testing it does work, but in running it does not. My code is in python, and this specific dag needs to run a specific command in the terminal. \nHave you got any idea how this is possible? \nIf you need more info, let me know in the comments!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":582,"Q_Id":61347143,"Users Score":0,"Answer":"One possible reason for this behaviour could be, your task that was executed earlier cached in the DB.\nSo the test works but when you call airflow to run the DAG it fails as it already running in the background or the state is cached in database. Try running $ airflow resetdb","Q_Score":1,"Tags":"python-3.x,airflow","A_Id":61353370,"CreationDate":"2020-04-21T15:26:00.000","Title":"Airflow test task works, but in dag run fails","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm wondering why it is possible that the following command works: \nairflow test [dag_id] [task_id] 20200421\nbut that the same task fails if I trigger the dag manually in the UI. \nThe task itself is quite easy, it is basically: \ncmd = 'ls' # other command\nos.system(cmd)\nthe os library is imported, and like said above, in testing it does work, but in running it does not. My code is in python, and this specific dag needs to run a specific command in the terminal. \nHave you got any idea how this is possible? \nIf you need more info, let me know in the comments!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":582,"Q_Id":61347143,"Users Score":0,"Answer":"Answer: \nThis problem is due to the different user that runs the script. \nairflow run uses a different user (and (sub-) processes) as airflow test. Switching to the airflow user does not work, but providing the airflow user with more rights (in linux) should work.","Q_Score":1,"Tags":"python-3.x,airflow","A_Id":62060639,"CreationDate":"2020-04-21T15:26:00.000","Title":"Airflow test task works, but in dag run fails","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am developing a login validator in Python 3 using selenium webdriver. I have a CSV with 10 username and passwords that the program will validate. Now, the website on which I have to validate is protected by reCAPTCHA. So after two or three entries, I am considered a bot and asked to \"prove I am human\". I am using Chrome browser.\nCan someone suggest me ways of performing this task smoothly. Are there other options compared to selenium webdriver?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":120,"Q_Id":61348816,"Users Score":1,"Answer":"One of reCAPTCHA's purposes for existing is to prevent Selenium and similar programs from doing exactly what you're trying to do. My best advice would be to test against a development instance of your website without the reCAPTCHA protection feature enabled.","Q_Score":1,"Tags":"python,selenium,selenium-webdriver","A_Id":61350903,"CreationDate":"2020-04-21T16:52:00.000","Title":"Python - Selenium Webdriver and reCAPTCHA","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm just setting up a firebase database for my kivy app and the first thing I need to do is \"add an app to get started\", the choices being IOS, Android, Web or Unity. Is this saying that I need to set up and maintain code for an Android-Kivy app and an IOS-Kivy app? The idea behind Kivy is that it is write once, use everywhere so I'm hoping to just have one version.\nOr have I misunderstood this part?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":134,"Q_Id":61350876,"Users Score":1,"Answer":"If you want to target both Android and iOS for any cross-platform development tool (not just Kivy), you will need to add both an Android and iOS app to your Firebase project.  Firebase doesn't know anything about Kivy (or Flutter, or Unity), so you have to tell it which OS is being targeted.","Q_Score":0,"Tags":"python,google-cloud-firestore,firebase-authentication,kivy,kivy-language","A_Id":61351245,"CreationDate":"2020-04-21T18:46:00.000","Title":"Firestore authentication asking to select \"android\/ios\" or \"web\" for kivy app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How to set properties (attribute) in nifi processor using pure Python in ExecuteStreamCommand processor\nI don't want to use Jython, I know it can be done using pinyapi. But don't know how to do it. I just want to create an attribute using Python script.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":136,"Q_Id":61351887,"Users Score":0,"Answer":"How to set properties(attribute) in nifi processor using pure python in ExecuteStreamCommand processor I don't want to use Jython\n\nYou can't do it from ExecuteStreamCommand. The Python script doesn't have the ability to interact with the ProcessSession, which is what it would need to set an attribute. You'd need to set up some operations after it to add the attributes like an UpdateAttribute instance.","Q_Score":0,"Tags":"python,apache-nifi,nipyapi","A_Id":64930455,"CreationDate":"2020-04-21T19:42:00.000","Title":"How to set attribute in nifi processor using pure Python not jython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 9 boxplots organized in 3 groups: \n\nA1,B1,C1 \nA2,B2,C2\nA3,B3,C3\n\nHow is it possible with seaborn to plot all A in red, all B in green, and all C in blue? \nI create boxplots with bplot = sns.boxplot(data=[d for d in data], width=0.5) and am aware of the existence of bplot.artists. Could anyone provide a hint on this?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":96,"Q_Id":61352900,"Users Score":-1,"Answer":"color is an optional parameter that gets passed into the underlying matplotlib object so just specify it in the initialization parameters: sns.boxplot(data, color='blue') and use a for loop to hit A, B, and C","Q_Score":1,"Tags":"python,seaborn,boxplot","A_Id":61352967,"CreationDate":"2020-04-21T20:43:00.000","Title":"Boxplot color grouping in seaborn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having major trouble right now trying to use numpy in my jupyter notebook.\nWhen I first tried to simply \"import numpy\", it came back with the error: \"ModuleNotFoundError: No module named 'numpy'\"\nI then read somewhere that I probably needed to install numpy. \nSo I did this: \"import sys\n!conda install --yes --prefix {sys.prefix} numpy\"\nto which it came back saying: \"EnvironmentLocationNotFound: Not a conda environment\"\nNow when it comes to understanding environments or packages or ANYTHING along those lines, I just have no idea what I'm doing. I am in a very beginner course and just following along. \nI wish I could understand all of this environment and versioning stuff. \nI have no idea where to go from here.\nAny insight here would be GREATLY appreciated!!\nEdit: I am in fact using Anaconda to launch Jupyter Notebook. Not sure if that means anything to your understanding of my problem or a potential solution.\nMark","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2804,"Q_Id":61353010,"Users Score":0,"Answer":"In my case, inside Jupyter notebook, you need to change Kernel (Anaconda environment). I thought you changed environment using conda activate myEnv, but when launching Jupyter, it defaults to the root environment.\nI hope this is in fact true- I am a noob in Anaconda.","Q_Score":1,"Tags":"python,numpy,jupyter-notebook","A_Id":70735920,"CreationDate":"2020-04-21T20:51:00.000","Title":"Problem importing (and installing) NumPy in Jupyter Notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need help.\nI'm doing a UI automation, and it works properly.\nHowever, it waits for all controls get done, but for example, the textbox I want to send keys is activated.\nBecause of that, my automation is very slow, and I couldn't find any helpful information in module documentation.\nThank you all","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":289,"Q_Id":61354217,"Users Score":1,"Answer":"I find out the solution. If you have the same problem, you should always search for controls, with child_window function. \nIf you use the bracket notation, pywiauto will search all controls from root window, and depending the application, it takes a long time.\nHowever, using child window, you can filter by control type, title and automation id","Q_Score":0,"Tags":"python,user-interface,automation,pywinauto","A_Id":61492419,"CreationDate":"2020-04-21T22:20:00.000","Title":"Pywinauto waiting too long to do an action","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been teaching myself Python3\/API\/PyQt5 and OOP for the last few weeks and I have finally made an app that works, yay!\nI've been working on Ubuntu 19 and the app works fine when I run it from the terminal. The problem is trying to compile it (correct term?) to make it an executable for Linux and Windows.\nI used pyinstaller app.py --onefile -w --icon=\"app.ico\" to make the files and I get no errors that I can see. \nI used Windows 10 to compire the exe.\nHere is the problem: On Linux I get a \"shared library\" file that doesn't execute and on windows the exe is just broken. All I get is an error saying \"this program cannot run on your system\", or something similar to that.\nThis is a very simple, 1 script app with a PyQt5 GUI. I'm pretty new to all of this and this has by far been the hardest part. I've been stuck on this for days and I can't get it to work.\nI can give you guys the app code if it will help, I just don't think I have enough rep to post links so it might have to be a code block.\nI will be grateful for any help you guys can give as I'm out of ideas.\nCheers!\nEditing to add: windows 8.1 gives the error message \"Error -3 from inflate: invalid block lengths\" when the app.exe is run","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2355,"Q_Id":61354226,"Users Score":0,"Answer":"After a lot more tinkering I finally have a working exe. \nI used -D to make a directory rather than the --onefile as that doesn't work. It makes an exe that doesn't work. Windows complains that it can't unpack the app.\nThe exe that is inside the dist directory works on Windows 8.1 and Windows 10. Didn't test on Win 7.\nI also included the png and ico files and used a clean env with python 3.8 instead of my working env with 3.7 installed. I'm not sure if any of these things made a difference but if anyone else is looking for an answer, this might help.\nMy final command: \n    pyinstaller -y -D -w -i \"FULL PATH TO ICON .ico\" --add-data \"FULL PATH TO IMAGE .png\";\".\"  \"FULL PATH TO PY FILE \/app.py\"","Q_Score":0,"Tags":"python,pyqt5,pyinstaller","A_Id":61393568,"CreationDate":"2020-04-21T22:20:00.000","Title":"Executables made with pyinstaller not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've been teaching myself Python3\/API\/PyQt5 and OOP for the last few weeks and I have finally made an app that works, yay!\nI've been working on Ubuntu 19 and the app works fine when I run it from the terminal. The problem is trying to compile it (correct term?) to make it an executable for Linux and Windows.\nI used pyinstaller app.py --onefile -w --icon=\"app.ico\" to make the files and I get no errors that I can see. \nI used Windows 10 to compire the exe.\nHere is the problem: On Linux I get a \"shared library\" file that doesn't execute and on windows the exe is just broken. All I get is an error saying \"this program cannot run on your system\", or something similar to that.\nThis is a very simple, 1 script app with a PyQt5 GUI. I'm pretty new to all of this and this has by far been the hardest part. I've been stuck on this for days and I can't get it to work.\nI can give you guys the app code if it will help, I just don't think I have enough rep to post links so it might have to be a code block.\nI will be grateful for any help you guys can give as I'm out of ideas.\nCheers!\nEditing to add: windows 8.1 gives the error message \"Error -3 from inflate: invalid block lengths\" when the app.exe is run","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2355,"Q_Id":61354226,"Users Score":-1,"Answer":"To make it work on Unix systems you will probably have to use dos2unix \"appname\" in Terminal, since windows adds some weird endings to any files containing text. That's how it works for me","Q_Score":0,"Tags":"python,pyqt5,pyinstaller","A_Id":68509604,"CreationDate":"2020-04-21T22:20:00.000","Title":"Executables made with pyinstaller not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When i press my enter key, it runs the code instead of allowing me to write another line of code","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":457,"Q_Id":61358356,"Users Score":0,"Answer":"No you cannot . but you can write loops functions this way. create a new file in your ide. save that file and run your code","Q_Score":0,"Tags":"python-3.x,windows","A_Id":61358415,"CreationDate":"2020-04-22T06:08:00.000","Title":"How do i write more than 1 line of code on python idle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a uwsgi web app with python and came across a requirement where I have to limit the no. of requests that the server should accept. Here , I came across the uwsgi option  max-requests. But the help says  help: reload workers after the specified amount of managed requests.\nSince I am not an native english speaker , I could not understand what that meant exactly.\nMy current understanding is :\nSuppose I set max-requests to 100 , the 10 workers.\nI get 150 requests , 100 requests are served and the rest are put in some queue . (?)\nAfter the 1st request is done , the 101st request is accepted by the worker. (?)\nPlease clarify\/help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1464,"Q_Id":61359392,"Users Score":1,"Answer":"So your Python code is run in workers. There are usually several of them in parallel. The max-requests specifies that, after a certain number of requests per worker, it is reloaded. Basically, your Python code is restarted every max-requests.\nIn you example, if you have 150 requests with 10 workers, nothing will happen (because 150\/10 < 100).\nBut after 1000 requests, workers will be reloaded (which will take some time, but it's probably fine because there are 10 workers so they won't be all reloaded at the same time). There are no queues there.","Q_Score":1,"Tags":"python,nginx,server,uwsgi","A_Id":61359757,"CreationDate":"2020-04-22T07:20:00.000","Title":"How does max-requests in uwsgi actually work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using a tool-A, which is written in python, to analyse an input. Another external tool ET1 produces an output, which is than used as an input for tool-A. The whole process occurs in real time.\nSuppose that I have two external tools (ET1 and ET2) that sent inputs to tool-A at the same time, is there a way that tool-A could process both inputs at the same time? \nUnfortunately, I am not familiar with paralel processing in general.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":61359439,"Users Score":0,"Answer":"If you can create another instance of tool-A then you can assign ET1 and ET2 to seperate threads so ET1 and ET2 will put their output to their own instance of tool-A. If tool-A must be a singleton object then you can only run ET1 and ET2 in parallel but you have to wait for tool-A to consume their outputs in the order which tool finishes first. You should probably checkout concept of mutex.","Q_Score":0,"Tags":"python-3.x,multithreading,multiprocessing","A_Id":61362463,"CreationDate":"2020-04-22T07:24:00.000","Title":"Can 2 or more inputs be processed at the same time in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have a code that is running well, the code loop over a bunch of stock symbols and pulling data from this API: https:\/\/www.alphavantage.co\/query?function=TIME_SERIES_DAILY&symbol=IBM&apikey=demo\n(i got an apikey this is just a demo).\nonce the loop hit the sixth symbol I get an error like this:\nKeyError: 'Time Series (Daily)'.\nthe strange thing is if I run it again from the sixth symbol (so the sixth become the first symbol) I don't get this error for the symbol but I will get it for the new sixth symbol in the loop.\nfor example, I got [AAPL, NFLX, NTES, RXN, VRTU, ZTO, BABA, BEST, BAM, FB, AMZN,TSLA] as my symbol list. then it would show me error for ZTO, after I got my info for the first five in my list the list would look like this [ZTO, BABA, BEST, BAM, FB, AMZN, TSLA] then i will get my error on AMZN.  \nIt seems to that it isn't related to the error that it is showing and something to do with the api.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":133,"Q_Id":61359515,"Users Score":0,"Answer":"You need to add a time delay to your code since on the free key you can only do 5 requests per minute than it times you out.","Q_Score":0,"Tags":"python,api","A_Id":63854014,"CreationDate":"2020-04-22T07:28:00.000","Title":"Error from alpha vantage api after requesting data for a few times","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently trying to find end-to-end speech recognition solutions to implement in python (I am a data science student btw). I have searched for projects on github and find it very hard to comprehend how these repositories work and how I can use them for my own project.\nI am mainly confused with the following:\n\nhow do repositories usually get used by other developers and how can I use them best for my specific issue?\nHow do I know if the proposed solution is working in python?\nWhat is the usual process in installing the project from the repo?\n\nSorry for the newbie question but I am fairly new to this. \nThank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":61362361,"Users Score":0,"Answer":"You can read the documentation(README.md) there you can have all the information you need.\nYou can install the project from a repo by cloning or by downloading zip.","Q_Score":0,"Tags":"python,github","A_Id":61362808,"CreationDate":"2020-04-22T10:04:00.000","Title":"Navigating through Github repos","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The tutorial writes in source env\/bin\/activate\nWhen I write it in this is what comes out:\n\n(venv) C:\\Users\\user\\PycharmProjects\\FirstProject>source env\/bin\/activate\n  'source' is not recognized as an internal or external command,\n  operable program or batch file.\n\nHe uses a mac and I use Windows 10, do I need a different line of code?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":61363163,"Users Score":0,"Answer":"just run: env\\Scripts\\activate. You do not need to use source on Windows.","Q_Score":0,"Tags":"python,django,python-venv","A_Id":61363536,"CreationDate":"2020-04-22T10:43:00.000","Title":"I'm trying to complete the Django website tutorial, following the youtube tutorial - and at the beginning I have this \"error\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"The tutorial writes in source env\/bin\/activate\nWhen I write it in this is what comes out:\n\n(venv) C:\\Users\\user\\PycharmProjects\\FirstProject>source env\/bin\/activate\n  'source' is not recognized as an internal or external command,\n  operable program or batch file.\n\nHe uses a mac and I use Windows 10, do I need a different line of code?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":61363163,"Users Score":0,"Answer":"don't use source, instead just type in your_env_name\\Scripts\\activate.bat\nRemember to use backward slashes.","Q_Score":0,"Tags":"python,django,python-venv","A_Id":64153540,"CreationDate":"2020-04-22T10:43:00.000","Title":"I'm trying to complete the Django website tutorial, following the youtube tutorial - and at the beginning I have this \"error\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I tried to install the mysqlclient-module for python 3.8. I ran into several problems while doing so that are described in other posts. I then tried to install it on another pc where it worked. On the first one it downloaded the mysql.tar.gz file and tried to build the file by itself(failed due to another error). But on the other pc it instead downloaded the 1.4.6-cp38-cp38-win_amd64.whl file and installed it correctly. Both machines run Windows 10 and when running platform.architecture() i receive the same result on both. I even tried installing the wheel manually on the first machine where i got the \"not supported wheel on this plattform\". The only difference i found in the systemversions is the build which is 17763 on the one it worked and 18363 on the one it didnt work (although i believe this shouldnt be the source)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":61363303,"Users Score":0,"Answer":"After trying around a bit i realized this error only occurs while beeing in the virtual enviroment in pycharm on the first machine. I was able to install it outside of the virtual enviroment and then copy the created files manually to the virtual enviroment.","Q_Score":0,"Tags":"python","A_Id":61365161,"CreationDate":"2020-04-22T10:51:00.000","Title":"Python wheel not supported on this plattform","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to write Python code that takes a word as an input (e.g. book), and outputs the most similar word with similarity score. \nI have tried different off-the-shelf edit-distance algorithms like cosine, Levenshtein and others, but these cannot tell the degree of differences. For example, (book, bouk) and (book,bo0k). I am looking for an algorithm that can gives different scores for these two examples. I am thinking about using fastText or BPE, however they use cosine distance. \nIs there any algorithm that can solve this?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":281,"Q_Id":61364975,"Users Score":1,"Answer":"The problem is that both \"bo0k\" and \"bouk\" are one character different from \"book\", and no other metric will give you a way to distinguish between them.\nWhat you will need to do is change the scoring: Instead of counting a different character as an edit distance of 1, you could give it a higher score if it's a different character class (ie a digit instead of a letter). That way you will get a different score for your examples.\nYou might have to adapt the other scores as well, though, so that replacement \/ insertion \/ deletion are still consistent.","Q_Score":1,"Tags":"python-3.x,nlp,text-classification,fasttext,edit-distance","A_Id":61365061,"CreationDate":"2020-04-22T12:20:00.000","Title":"An algorithm for computing the edit-distance between two words","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can you prevent the agent from non-stop repeating the same action circle?\nOf course, somehow with changes in the reward system. But are there general rules you could follow or try to include in your code to prevent such a problem?\n\nTo be more precise, my actual problem is this one:\nI'm trying to teach an ANN to learn Doodle Jump using Q-Learning. After only a few generations the agent keeps jumping on one and the same platform\/stone over and over again, non-stop. It doesn't help to increase the length of the random-exploration-time. \nMy reward system is the following:\n\n+1 when the agent is living\n+2 when the agent jumps on a platform\n-1000 when it dies\n\nAn idea would be to reward it negative or at least with 0 when the agent hits the same platform as it did before. But to do so, I'd have to pass a lot of new input-parameters to the ANN: x,y coordinates of the agent and x,y coordinates of the last visited platform.\nFurthermore, the ANN then would also have to learn that a platform is 4 blocks thick, and so on. \nTherefore, I'm sure that this idea I just mentioned wouldn't solve the problem, contrarily I believe that the ANN would in general simply not learn well anymore, because there are too many unuseful and complex-to-understand inputs.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":417,"Q_Id":61367054,"Users Score":0,"Answer":"This is not a direct answer to the very generally asked question.\n\nI found a workaround for my particular DoodleJump example, probably someone does something similar and needs help:\n\nWhile training: Let every platform the agent jumped on disappear after that, and spawn a new one somewhere else.\nWhile testing\/presenting: You can disable the new \"disappear-feature\" (so that it's like it was before again) and the player will play well and won't hop on one and the same platform all the time.","Q_Score":1,"Tags":"python,tensorflow,reinforcement-learning,q-learning","A_Id":61428048,"CreationDate":"2020-04-22T14:02:00.000","Title":"Agent repeats the same action circle non stop, Q learning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't understand how what each value represents, would someone be able to explain?\nimg_left[:,0:150,:] = np.clip(img_left[:,:150,:]*1.5,0, 255)","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":55,"Q_Id":61367541,"Users Score":1,"Answer":"It takes the first 150 columns of image (first dimension in image being rows, second being columns, and third usually RGB). when you call a dimension by : you are selecting all elements along that axis. And calling a dimension by i:j select all the elements between i-th and j-th (including i and excluding j) along that dimension. It then multiplies all those selected values to 1.5 and clips the values to be between 0 and 255.","Q_Score":0,"Tags":"python,numpy,vision","A_Id":61367630,"CreationDate":"2020-04-22T14:24:00.000","Title":"Can someone explain how they are splitting the image here?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't understand how what each value represents, would someone be able to explain?\nimg_left[:,0:150,:] = np.clip(img_left[:,:150,:]*1.5,0, 255)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":61367541,"Users Score":0,"Answer":"I'm assuming this is using open-cv, but either way the numpy array is being indexed by [:,0:150:,:], where : means to take all values when by itself, and x:y is all values from x to y. So that'd mean that all of the y values (open-cv works with y first, then x), the x values from 0 to 149, and all 3 color channels.","Q_Score":0,"Tags":"python,numpy,vision","A_Id":61367657,"CreationDate":"2020-04-22T14:24:00.000","Title":"Can someone explain how they are splitting the image here?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Sentry integrated in a Django project with the aiohttp integration, the app is running with gunicorn. The problem is that the logs in the Sentry are duplicated, one is being sent by gunicorn and the other by the aiohttp logger, can i disable the gunicorn log to prevent this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":136,"Q_Id":61370376,"Users Score":1,"Answer":"Solved, before the init of the sdk\nfrom sentry_sdk.integrations.logging import ignore_logger\nignore_logger('gunicorn.error')","Q_Score":1,"Tags":"python,gunicorn,sentry","A_Id":61371779,"CreationDate":"2020-04-22T16:39:00.000","Title":"Is there a way to deactivate gunicorn log from sentry?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Trying to decide on the best route for generating server-side pdf reports within my app currently deployed on Heroku. I've read several posts that say both require installation external libraries- but haven't found anything describing functionality & ease of install on Heroku.\nDoes anyone here have experience installing either to an app on Heroku? Is it a difficult process- is one easier to setup on Heroku than the other? Or if I am able to install on my local system and run PIP Freeze, will that take care of any installs necessary on Heroku?\nThanks!!","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1412,"Q_Id":61370630,"Users Score":2,"Answer":"WeasyPrint is much easier to use than ReportLab, the only issue with weasyprint is it doesn't handle page breaks correctly (since you're converting an HTML page to PDF) which can be a deal breaker if your reports extend on more than 1 page (for example tables)","Q_Score":3,"Tags":"python,django,heroku,reportlab,weasyprint","A_Id":63359829,"CreationDate":"2020-04-22T16:52:00.000","Title":"Weasyprint or Reportlab for generating Django reports on Heroku","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Trying to decide on the best route for generating server-side pdf reports within my app currently deployed on Heroku. I've read several posts that say both require installation external libraries- but haven't found anything describing functionality & ease of install on Heroku.\nDoes anyone here have experience installing either to an app on Heroku? Is it a difficult process- is one easier to setup on Heroku than the other? Or if I am able to install on my local system and run PIP Freeze, will that take care of any installs necessary on Heroku?\nThanks!!","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1412,"Q_Id":61370630,"Users Score":1,"Answer":"I have foremost experience of Reportlab. To get it up and running requires quite lot of effort from your side, it does not work \"out of the box\" and involves lot of programming (you need to create templates, build logic around text, build routines around batch jobs etc.). It installs as a normal PIP package, but then you need to start programming to get it working.\nHowever, it looks like Weasyprint uses another technology to generate pdf (CSS for print) which might be a more readily accessible solution if you already have pages formatted with CSS.","Q_Score":3,"Tags":"python,django,heroku,reportlab,weasyprint","A_Id":61377605,"CreationDate":"2020-04-22T16:52:00.000","Title":"Weasyprint or Reportlab for generating Django reports on Heroku","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Just a quick little question about coding in general.\nSay you're using a try-catch block, but all you do with the exception is print it to stderr. In this case, are you better off simply letting the error happen and letting it print on its own? Or is it still better to catch the exception so that it is documented for other coders? \nIn languages like Java, there is a \"throws exception\", but as far as I can tell Python has nothing of that kind. \nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":245,"Q_Id":61371385,"Users Score":0,"Answer":"If we don't catch exception, then the normal flow of control will break where the exception occurred and will jump to the point where the exception is caught or the program will just terminate after printing the exception.\nNot catching exception might be ok for simple programs, but for complex applications where we have multiple methods and libraries, we would wish to catch the exception where in the part of the program where it occurs and handle it according to our need. In web applications we may handle the exception and display user understandable error message.\nIn general, its always better to handle the exception even if we just print it to the logs.","Q_Score":0,"Tags":"python,exception,try-catch","A_Id":61371597,"CreationDate":"2020-04-22T17:30:00.000","Title":"Is it bad to \"catch\" exceptions if all you do is print it to error?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to wrap my head around vectorization (for numerical computing), and I'm coming across seemingly contradictory explanations:\n\nMy understanding is that it is a feature built into low-level libraries that takes advantage of parallel processing capabilities of a given processor to perform operations against multiple data points simultaneously.\nBut several tutorials seem to be describing it as a coding practice that one incorporates into their code for more efficiency. How is it a coding practice, if it is also a feature you have or you don't have in the framework you are using. \n\nA more concrete explanation of my dilemma: \n\nLet's say I have a loop to calculate an operation on a list of numbers in Python. To vectorize it, I just import Numpy and then use an array function to do the calculation in one step instead of having to write a time consuming loop. The low level C routines used by Numpy will do all the heavy lifting on my behalf. \n\nKnowing about Numpy and how to import it and use it is not a coding practice, as far as I can tell. It's just good knowledge of tools and frameworks, that's all. \nSo why do people keep referring to vectorization as a coding practice that good coders leverage in their code?","AnswerCount":3,"Available Count":2,"Score":0.3215127375,"is_accepted":false,"ViewCount":123,"Q_Id":61373860,"Users Score":5,"Answer":"Vectorization can mean different things in different contexts.  In numpy we usually mean using the compiled numpy methods to work on whole arrays.  In effect it means moving any loops out of interpreted Python and into compiled code.  It's very specific to numpy.\nI came to numpy from MATLAB years ago, and APL before that (and physics\/math as a student).  Thus I've been used to thinking in terms of whole arrays\/vectors\/matrices for a long time.\nMATLAB now has a lot just-in-time compiling, so programmers can write iterative code without a performance penalty.  numba (and cython) lets numpy users do some of the same, though there are still a lot of rough edges - as can be seen in numpa tagged questions.\nParallelization and other means of taking advantage of modern multi-core computers is a different topic.  That usually requires using additional packages.\nI took issue with a comment that loops are not Pythonic.  I should qualify that a bit.  Python does have tools for avoiding large, hard to read loops, things like list comprehensions, generators and other comprehensions. Performing a complex task by stringing together comprehensions and generators is good Python practice, but that's not 'vectorization' (in the numpy sense).","Q_Score":1,"Tags":"python,performance,numpy,parallel-processing,vectorization","A_Id":61374101,"CreationDate":"2020-04-22T19:47:00.000","Title":"Is vectorization a hardware\/framework specific feature or is it a good coding practice?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to wrap my head around vectorization (for numerical computing), and I'm coming across seemingly contradictory explanations:\n\nMy understanding is that it is a feature built into low-level libraries that takes advantage of parallel processing capabilities of a given processor to perform operations against multiple data points simultaneously.\nBut several tutorials seem to be describing it as a coding practice that one incorporates into their code for more efficiency. How is it a coding practice, if it is also a feature you have or you don't have in the framework you are using. \n\nA more concrete explanation of my dilemma: \n\nLet's say I have a loop to calculate an operation on a list of numbers in Python. To vectorize it, I just import Numpy and then use an array function to do the calculation in one step instead of having to write a time consuming loop. The low level C routines used by Numpy will do all the heavy lifting on my behalf. \n\nKnowing about Numpy and how to import it and use it is not a coding practice, as far as I can tell. It's just good knowledge of tools and frameworks, that's all. \nSo why do people keep referring to vectorization as a coding practice that good coders leverage in their code?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":123,"Q_Id":61373860,"Users Score":2,"Answer":"Vectorization leverage the SIMD (Single Instruction Multiple Data) instruction set of modern processors. For example, assume your data is 32 bits, back in the old days one addition would cost one instruction (say 4 clock cycles depending on the architecture). Intel's latest SIMD instructions now process 512 bits of data all at once with one instruction, enabling you to make 16 additions in parallel.\nUnless you are writing assembly code, you better make sure that your code is efficiently compiled to leverage the SIMD instruction set. This is being taking care of with the standard packages. \nYour next speed up opportunities are in writing code to leverage multicore processors and to move your loops out of the interpreted python. Again, this is being taking care of with libraries and frameworks.\nIf you are a data scientist, you should only care about calling the right packages\/frameworks, avoid reimplementing logic already offered by the libraries (with loops being a major example) and just focus on your application. If you are a framework\/low-level code developer, you better learn the good coding practices or your package will never fly.","Q_Score":1,"Tags":"python,performance,numpy,parallel-processing,vectorization","A_Id":61375476,"CreationDate":"2020-04-22T19:47:00.000","Title":"Is vectorization a hardware\/framework specific feature or is it a good coding practice?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need my discord bot to send a message whenever a specific youtube channel uploads a video.  How would I do this in python?  I just want examples of the different ways it can be done.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1093,"Q_Id":61375754,"Users Score":-1,"Answer":"For this you need to use the Google data api, aka the youtube api, and combine it with the discord api. the discord api is pretty easy to understand, but the youtube one is pretty hard. so i sugesst you dig deep in how apis work and how the youtube data api functions","Q_Score":1,"Tags":"python,discord,discord.py","A_Id":62121296,"CreationDate":"2020-04-22T21:55:00.000","Title":"How to make a discord bot send a message in a channel when a video is uploaded by a specific youtuber","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":"Maybe I wasn't searching the right key words, but I couldn't find anything on printing to another application's dialogue box. Most of my searches came to filling a web page, but I want to print a string to dialogue boxes of other applications like you would for logging into game launchers.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":16,"Q_Id":61376038,"Users Score":0,"Answer":"The operating system will usually not allow you to write into the memory of other application. So if the other application is unwilling to take your input, it's practically not possible.\nIf it is willing to take your input, there are several ways:\n\nAccepting input through the standard input - This means you need to open it as a process and write into the output pipe\nHaving an open web API - the application is listening on a network port and accepting connections (e.g. HTTP) so you can send HTTP requests to it (even from the same machine)\nListening for any other inter-process communication method - either subscribed to a broker you can publish on, or directly listening for connections (let's say on UNIX-domain socket). \n\nIf the application is not listening to anything, nor using any shared resource\/memory piece, then there's effectively no way.\nUnless...\nYou wrap the application up in an application of yours. The same way the most game launchers and even game cheats do. Then your application will be completely responsible to proxy the output of the other application to the end-user. Your can take its output, augment it a little bit (e.g. add some texts to a rectangle) and then render it to the user.","Q_Score":0,"Tags":"java,python","A_Id":61376260,"CreationDate":"2020-04-22T22:19:00.000","Title":"How to print a string to another application's dialogue box?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some data concerning the 2020 Australian bush fires I'm trying to work with.\nI have some data in numpy arrays: lat (for latitude), lon (for longitude), and time.\nThe array size of lat is: 350 with the shape: (350,)\nThe array size of lon is: 500 with the shape: (500,)\nThe array size of time is: 31 with the shape: (31,) - this makes sense as it's days of the month in Jan 2020.\nI have another array, total_combustion_rate:\nThe array size of total_combustion_rate is: 5425000 with the shape: (31, 350, 500) - so it's made up of days in the month, lat and lon values.\nI have a final array called area_array:\nThe array size of area_array is: 175000 with the shape: (350, 500). It contains the area of each grid square in km2.\nI have been asked to work out what percentage of Australia experienced fire during January 2020.\nI'm unsure how to go about this problem though.\nThere are a lot of values in total_combustion_rate that are zero. Getting rid of them should just leave me with entries that mean there is a fire of some description burning in each grid square. I can see that I need to then sum the same lon and lat values in area_array that have a value that isn't zero in total_combustion_rate and that should give me the total area of grid squares that were on fire.\nConverting to a percentage should then just be: (total on fire \/ total area contained in area_array) * 100.\nI'm totally lost on how I'd go about doing this though as I get a bit confused with 3D numpy arrays. Can anyone help?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":61377584,"Users Score":0,"Answer":"I am assuming numpy is imported under the name np, and all arrays are numpy arrays.\nYou have to start by summing total_combustion_rate along the time dimension. This way, you will get a 2-D array for which each entry represents an integrated value over time for each location of your dataset.\ntotal_combustion_rate.sum(axis=0)\nNow, this array is the exact place where you can look for 0 values. The idea is to determine where the non-zero entries are so that you can use their index to probe into area_array and get the relevant areas you need. A masked array makes the task extremely easy as it will \"hide\" these entries you do not want, meaning the ones that sum up to 0.\nnp.ma.MaskedArray(area_array, total_combustion_rate.sum(axis=0) == 0)\nWhen you have the masked array, all you need to do is to compare the sum of the un-masked areas to the sum of all areas. Again, this is achieved effortlessly.\n(np.ma.MaskedArray(area_array, total_combustion_rate.sum(axis=0) == 0).sum()\n \/ area_array.sum())\nAll in one (long) line. :)","Q_Score":0,"Tags":"python,arrays,numpy,multidimensional-array,data-science","A_Id":61377805,"CreationDate":"2020-04-23T00:58:00.000","Title":"3D numpy array woes and extracting data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some python scripts on PythonAnywhere.com that I am trying to download into my computer. Whenever I click the download icon next to the file, it opens into another web tab (Chrome) instead. I'm not sure what I did that caused this because I've been able to download files to my computer for the last couple of weeks but suddenly I cannot. Any help would be appreciated - thank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":78,"Q_Id":61377853,"Users Score":1,"Answer":"Use your browser right-click menu on the download link to save the file to your disk.","Q_Score":0,"Tags":"pythonanywhere","A_Id":61384071,"CreationDate":"2020-04-23T01:30:00.000","Title":"Trying to download some python scripts from PythonAnywhere to my computer but it keeps opening another browser tab instead","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I install OpenCV package by pip in Ubuntu 18.04\nit pauses and shows this message:\n\"\ndefaulting to user installation because normal site-packages is not writeable\n\"","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":264,"Q_Id":61378713,"Users Score":0,"Answer":"Rebooting the PC is an effective way to solve this issue.","Q_Score":0,"Tags":"python,pip,package","A_Id":61378730,"CreationDate":"2020-04-23T03:11:00.000","Title":"I cannot install a python package (opencv)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Please accept my apology if this is a dumb question.\nI want to make a regex expression that can make the two following changes in Python.\n\n$12345.67890 to 12345.67\n$12345 to 12345\n\nWhat would be an appropriate regex expression to make both changes?\nThank you in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":489,"Q_Id":61379982,"Users Score":1,"Answer":"in notepad++ style i would do something like \nfind        \\$(\\d+\\.)(\\d\\d)\\d+\nReplace     \\1\\2 \nhope that helps","Q_Score":0,"Tags":"python,regex","A_Id":61380092,"CreationDate":"2020-04-23T05:31:00.000","Title":"How to keep a captured group only in Python regex?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How trigger the coral dev board camera from opencv  \n\ncv.VideoCapture(0)\ni am using this command to trigger the camera in opencv python. unfortunately it is giving error. not triggering the camera.\nplease let me know code for opencv python in coral dev board.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":696,"Q_Id":61381067,"Users Score":0,"Answer":"I'm from the coral team, just wanted to update on the issue here so that other can reference.\n\nThis is not caused by OpenCV, I have a full code with errors and it looks fine.\nThe usage of the library is correct.\n\nThe error is due to cv not able to read any data off from \/dev\/video0. At this stage I believe it's just bad connection between the camera sensors and the camera board. A command to take a picture from the camera failed.","Q_Score":0,"Tags":"python,opencv,google-coral","A_Id":61462857,"CreationDate":"2020-04-23T06:55:00.000","Title":"How to get video in coral dev board using OPENCV?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to run a python cobra sdk script to do a query in cisco aci apic database for class\u00a0l1PhysIf to obtain a port inventory, code seems to be ok, but when I execute code I get error:\ncobra.mit.request.QueryError: Unable to process the query, result dataset is too big\nin my code I use a for loop for append query's obtained data to a empty list\nmy fabric has about 6900 ports so query results can be big, how can handle the code for obtain the data?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":159,"Q_Id":61381917,"Users Score":-1,"Answer":"use paging \/ pagination to reduce the size of query results","Q_Score":0,"Tags":"python-2.7,sdk,cisco,apic,cobra","A_Id":61382691,"CreationDate":"2020-04-23T07:47:00.000","Title":"cobra.mit.request.QueryError: Unable to process the query, result dataset is too big","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cant seem to write something like : \"C:\\Users\\alon4\\Desktop\\Learning Material\\Odyssey\\Lab a2\\Magnetism\\data\"\nAs a string to print or otherwise, i think its something to do with the slashes","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":61381957,"Users Score":0,"Answer":"There can be 3 ways : \n1) Either use r (raw strings) before the actual string : \nFor example : r\"C:\\Users\\alon4\\Desktop\\Learning Material\\Odyssey\\Lab a2\\Magnetism\\data\"\n2) Or use \/\/ like:\nFor example : \"C:\\\\Users\\\\alon4\\\\Desktop\\\\Learning Material\\\\Odyssey\\\\Lab a2\\\\Magnetism\\data\"\n3) Use slashes: \"C:\/Users\/alon4\/Desktop\/Learning Material\/Odyssey\/Lab a2\/Magnetism\/data\"\n(As suggested by \u00d3scar L\u00f3pez)","Q_Score":0,"Tags":"python","A_Id":61382025,"CreationDate":"2020-04-23T07:49:00.000","Title":"How to write file locations as string in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"ok; I wrote a code and use python selenium and then with pyqt5 made it graphical.\nbut when I push the button start webdriver opened and I can't access to my windows's code any more, It got frozen , but I should input some valuable or click on some button as the code running.\nwhat should I do ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":61382216,"Users Score":0,"Answer":"What I did was using a Process, so it would seperate the GUI-Loop and everything what is being done by selenium in a Process. By doing so you'll be able to use your GUI parallel to running Selenium in the Background by your process.","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,webdriver,pyqt5","A_Id":61382538,"CreationDate":"2020-04-23T08:04:00.000","Title":"how to work with code when web driver is open","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"ok; I wrote a code and use python selenium and then with pyqt5 made it graphical.\nbut when I push the button start webdriver opened and I can't access to my windows's code any more, It got frozen , but I should input some valuable or click on some button as the code running.\nwhat should I do ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":61382216,"Users Score":0,"Answer":"I've faced the same problem before. My solution was to use the time.sleep(duration) when the web driver opened the Window. For your specific situation, I think that you can use javascript on the page to check the user input is complete or not. Once the input fields are filled then trigger the process behind.","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,webdriver,pyqt5","A_Id":61382460,"CreationDate":"2020-04-23T08:04:00.000","Title":"how to work with code when web driver is open","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So when you make changes to your CSS or JS static file and run the server, sometimes what happens is that the browser skips the static file you updated and loads the page using its cache memory, how to avoid this problem?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":185,"Q_Id":61383900,"Users Score":0,"Answer":"Well there are multiple ways to avoid this problem\n\nthe simplest way is by:\n\nif you are using Mac: Command+Option+R\nif you are using Windows: Ctrl+F5\n\n\nWhat it does is that it re-downloads the cache files enabling the update of the static files in the browser.\n\nAnother way is by:\n\nmaking a new static file and pasting the existing code of the previously used static file and then \nrunning the server\n\n\nWhat happens, in this case, is that the browser doesn't use the cache memory for rendering the page as it assumes it is a different file.","Q_Score":0,"Tags":"javascript,python,css,django,static-files","A_Id":61383901,"CreationDate":"2020-04-23T09:33:00.000","Title":"How to fix not updating problem with static files in Django port 8000","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So when you make changes to your CSS or JS static file and run the server, sometimes what happens is that the browser skips the static file you updated and loads the page using its cache memory, how to avoid this problem?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":185,"Q_Id":61383900,"Users Score":0,"Answer":"U have DEBUG = False in your settings.py. Switch on DEBUG = True and have fun","Q_Score":0,"Tags":"javascript,python,css,django,static-files","A_Id":69756851,"CreationDate":"2020-04-23T09:33:00.000","Title":"How to fix not updating problem with static files in Django port 8000","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i ask if Django make database indexes for ManyToMany Field ... and if yes is it do this for the model i provide in through ? \ni just want to make sure that database will go fast when it have a lot of data","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":540,"Q_Id":61384298,"Users Score":0,"Answer":"It does for plain m2m fields - can't tell for sure for \"through\" tables since I don't have any in my current project and don't have access to other projects ATM, but it still should be the case since this index is necessary for the UNIQUE constraint. \nFWIW you can easily check it by yourself by looking at the tables definitions in your database (in MySQL \/ mariadb using the show create table yourtablename).\nThis being said, db index are only useful when there are mainly distinct values, and can actually degrade performances (depending on your db vendor etc) if that's not the case - for example, if you have a field with like 3 or 4 possible values (ie \"gender\" or something similar), indexing it might not yield the expected results. Should not be an issue for m2m tables since the (table1_id, table2_id) pair is supposed to be unique, but the point is that you should not believe that just adding indexes will automagically boost your performances - tuning SQL database performances is a trade in and by itself, and actually depends a lot of how you actually use your data.","Q_Score":1,"Tags":"python,django,python-3.x,database,django-models","A_Id":61388221,"CreationDate":"2020-04-23T09:55:00.000","Title":"Is Django Make Indexes for ManyToMany field?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am fairly new in Python. I have two pandas data frames ak12_01 and T01\nak12_01\n  objectid, coordID, year, doy\n0 495395    5497     2001  120\nand\nT01\n  coordID, year,  1,  2,  3, ...\n0 5497     2001  249 251 231 ...\n1 5498     2001  239 231 251 ...\nI want to add a given value from T01 to ak12_01 on two conditions:\n1) if T01['coordID'] == ak12_01['coordID']\n2) if T01(column name) == ak12_01['doy'].\nIn the T01 dataset, the column names represent the doy (day of the year)\nI get an error when comparing the 'coordID' from the two dataset as they are not equally long (Can only compare identically-labeled Series objects). Is there a smart way of adding the given value from T01 to ak_12_01 based on these to conditions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":61384849,"Users Score":1,"Answer":"I found out that it is possible to do by doing the following merge.\n\nI transposed the doy data, so it is all in 1 column.\nmerge_ID_doy = ak2012_1.merge(T01, how='inner', left_on=['coordID', 'doy'], right_on=['coordID', 'doy']).\n\nThen it merges all the data with similar doy and coordID with each other.","Q_Score":1,"Tags":"python-3.x,pandas,if-statement","A_Id":61524106,"CreationDate":"2020-04-23T10:22:00.000","Title":"Conditional appending of data to a pandas dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using GaussianNB for classification problem\nall the features are numerical and they represent marks about something  (every mark is between 1 and 8 and they are results to exams)\n\nThe algorithm seems to work enough well in my case: I got 0,85 as an accuracy score.\nBut I read that Gaussian should have mean 0 and variance 1 but they don't.\nShould I use a scaler such as Standard Scaler before?\nIs it compulsory in my case?\nI tried it but performances didn't go up","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":61387135,"Users Score":0,"Answer":"The 'standard Gaussian'- which is the basic\/hypothetical Gaussian distribution - has its mean at 0 and its variance at 1. For example people's height around the world has mean of 175cm and variance of 10cm, yet it is still Gaussian (bell shaped).","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,naivebayes","A_Id":65453710,"CreationDate":"2020-04-23T12:23:00.000","Title":"preprocessing data before GaussianNB for categorical for numerical features","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to scrape data within the iFrame.\nI have tried webdriver in Chrome as well as PhantomJS with no success. There are source links contained within the iframe where I assume its data is being pulled from, however, when using these links an error is generated saying \"You can't render widget content without a correct InstanceId parameter.\" \nIs it possible to access this data using python (PhantomJS)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27,"Q_Id":61387511,"Users Score":0,"Answer":"Go to network tools in your browser and investigate what data go to the server and just scrape via simple requests.","Q_Score":0,"Tags":"python,iframe,selenium-chromedriver,phantomjs,forex","A_Id":61387643,"CreationDate":"2020-04-23T12:42:00.000","Title":"Python Scrape Financial Data From iFrame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to know the max memory usage of a celery task, but from the documentations none of the celery monitoring tools provide the memory usage feature. How can one know how much memory a task is taking up? I've tried to get the pid with billiard.current_process and use that with memory_profiler.memory_usage but it looks like the current_process is the worker, not the task.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":595,"Q_Id":61388299,"Users Score":0,"Answer":"Celery does not give this information unfortunately. With little bit of work it should not be difficult to implement own inspect command that actually samples each worker-process. Then you have all necessary data for what you need. If you do this, please share the code around as other people may need it...","Q_Score":1,"Tags":"celery,python-multiprocessing,celery-task,celeryd","A_Id":61393652,"CreationDate":"2020-04-23T13:21:00.000","Title":"How to monitor memory usage of individual celery tasks?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Example: I have the main folder named \"alphabets\" under this i have 'n' number of subfolders. I want to extract the 'n' subfolder names into excel\/or any file using python.\nalphabets #main folder\n  abc #subfolder1\n  def #subfolder2\n  . \n  .\n  . \n  xyz #subfoldern\nI want the output as :\nabc\ndef\n.\n.\n.\nxyz","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":61388896,"Users Score":0,"Answer":"Please take a look a python pathlib module and consider again Jan Koci answer. It should help you to get a directory name from a directory path. \nos.path module can help you too by providing the method basename to a string representing a path. \nTake a look also at os.path.split.\nRegards.","Q_Score":0,"Tags":"python-3.x","A_Id":61391537,"CreationDate":"2020-04-23T13:51:00.000","Title":"How to get the names of the Subfolders that exist under the main folder using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have simple .py files that run fine in my IDE (IDLE), however when I execute from terminal it just gets weird.\nI have a folder with a dozen or so .py scripts. I change the directory, then execute python3 script.py from terminal but it runs a completely different script. It's very odd. And it's always the same script that is run. They are all independent scripts and don't import anything from each other.\nI executed cat python3 script.py and it looks exactly as it should. Is there something wrong with my Python installation?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":61389241,"Users Score":0,"Answer":"Try Some Solutions:\n1: Double Check if Python is included in the System Environment.\n2: Run the command from a console to directly check and upgrade the pip; \n\npython -m pip install --upgrade pip\n\nin case you have different version of Python Installed \n\npython3 -m pip install --upgrade pip\n\n3: You can locate your Script with Python by creating .bat file for your script and then just double click the bat file to run your script from any directory after locating properly.\n4: Check if the script need any requirements to run in console without IDE.","Q_Score":1,"Tags":"python,terminal","A_Id":61389437,"CreationDate":"2020-04-23T14:09:00.000","Title":"Python scripts not running properly from terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I use the VS Code for my Python scripts, and I like to put a semicolon after every line, but the editor always emphasizes the semicolon and it distracts me a lot. \nQ: How do I disable this warning in the VS Code?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1468,"Q_Id":61391472,"Users Score":0,"Answer":"Put a space after each semicolon. You can also put a tab after it.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":68345270,"CreationDate":"2020-04-23T15:50:00.000","Title":"How to remove warning about Unnecessary semicolon in Visual Studio Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to to do this  \nfrom bleu import evaluate  But I get the following error:  \nImportError: cannot import name 'evaluate' from 'bleu' (\/opt\/conda\/lib\/python3.7\/site-packages\/bleu\/init.py)   Version I'm using pip install bleu==0.1.0  I'm trying to run a code which has this so please help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":456,"Q_Id":61392120,"Users Score":0,"Answer":"According to the documentation, the evaluate() method was deprecated in version 1.0.5 (functionally replaced by model_selection.cross_validate()) and was removed in version 1.1.0.","Q_Score":0,"Tags":"python,bleu","A_Id":61392199,"CreationDate":"2020-04-23T16:23:00.000","Title":"Cannot import name 'evaluate' from 'bleu'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a simple flask app that talks to Google Cloud Storage.\nWhen I run it normally with python -m api.py it inherits Google Cloud access from my cli tools.\nHowever, when I run it with the PyCharm debugger it can no longer access any Google Services.\nI've been trying to find a way to have the PyCharm debugger inherit the permissions of my usual shell but I'm not seeing any way to do that.\nAny tips on how I can use the PyCharm debugger with apps that require access to Google Cloud?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":270,"Q_Id":61392695,"Users Score":1,"Answer":"I usually download the credentials file and set GOOGLE_APPLICATION_CREDENTIALS=\"\/home\/user\/Downloads\/[FILE_NAME].json environment variable in PyCharm. \nI usually create a directory called auth and place the credential file there and add that directory to .gitignore\nI don't know if it is a best practice or not but it gives me an opportunity to limit what my program can do. So if I write something that may have disrupting effect, I don't have to worry about it. Works great for me. I later use the same service account and attach it to the Cloud Function and it works out just fine for me.","Q_Score":0,"Tags":"python,google-cloud-platform,pycharm","A_Id":61395962,"CreationDate":"2020-04-23T16:53:00.000","Title":"How can I use the PyCharm debugger with Google Cloud permissions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"when I created .py to .exe with pyinstaller my .exe file is not working can anyone one suggest some other ways to convert .py to .exe.\nmy file is Notepad.py.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":38,"Q_Id":61393165,"Users Score":-1,"Answer":"If your .py contant any image or database file than you have to tranfer into folder 'dist'.","Q_Score":1,"Tags":"python,tkinter,pyinstaller,py2exe","A_Id":61393550,"CreationDate":"2020-04-23T17:18:00.000","Title":"pyinstaller is not going well can I know some other ways to convert .py file to .exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset of face images which were captured with a uniform gray background. Because of the lighting variations during collection, the images no longer have same color tone. The backgrounds color looks different for all the images.\nI want to find the exact skin color and wanted to implement color correction using the fact that all images had uniform gray background. How can I implement this using python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":61395195,"Users Score":0,"Answer":"Assuming your pixels are converted to floats in the range 0,0,0 (black) to 1,1,1 (white). You have a vector in 3D (RGB) space from the picture background to the known value.  To correct, calculate a correction by multiplying each component by the magnitude of the correction needed.  So if you have dR, dG, dB as the differences, all between 0.0 and 1.0, and R,G,B is a pixel, Rnew = R * (1.0 + dR) clipping max at 1.0.  This will keep black pixels black.","Q_Score":0,"Tags":"python,algorithm,opencv,image-processing","A_Id":61395865,"CreationDate":"2020-04-23T19:12:00.000","Title":"How to implement color correction based on known background color?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i'am building a simple desktop application in python(PyQt5) and using the mongodb as my database.\nnow i want to package this script into executable to distribute, here i'm in confusion that how to package database with it so user don't need to install mongodb server in their machine. can i use mongodb or there is different approach for desktop app","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":121,"Q_Id":61395408,"Users Score":0,"Answer":"The license allows you to distribute MongoDB server binaries, you still need to manage the process lifetime (start\/stop).","Q_Score":0,"Tags":"database,mongodb,desktop-application,python-packaging","A_Id":61395832,"CreationDate":"2020-04-23T19:27:00.000","Title":"packaging mongodb database with desktop app without installing mongodb server at users machine","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The background for this question is that I am trying to debug a TensorFlow pipeline. I manually computed the loss for each example based on the network's current prediction and averaged the error terms. The number I get is different from what Keras is reporting, so the question is if I found my bug, or if I am computing the wrong thing to compare to the value reported as \"loss\".\nWhat exactly is Keras computing here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":298,"Q_Id":61395449,"Users Score":2,"Answer":"The training loss is a running mean of the loss values across batches, during training, after each batch update. The weights are changing during training so you cannot compare this loss to to making predictions with fixed weights and then computing a loss.\nThis means that if you compute the average (or even running mean) over batches, you will get a different result.","Q_Score":1,"Tags":"python,tensorflow,keras","A_Id":61397113,"CreationDate":"2020-04-23T19:30:00.000","Title":"In keras, is the loss value of model.fit the average over batches or over samples?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to compile my Python project to a Windows executable (.exe) using Nuitka. I get no errors\/warnings during the compilation process, but when I'm trying to run the resulting executable I get the \"C:\\Python34\\test.exe is not a valid win32 application\" error on Windows XP and a similar one on Windows 10, too). The problem persists even when I compile a \"Hello, World!\" program. Interesting, that I can easily build and run C++ projects from the Visual Studio IDE on the same PC.\nI'm using Windows XP (x32 bits), Python 3.4.0 and Microsoft Visual C++ 2008 Professional.\nHow can I solve this problem?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":599,"Q_Id":61398507,"Users Score":0,"Answer":"I used tried the first steps from the Nuitka website and had the same with example 1. What I found: example 1 uses --mingw64 as option.\npython -m nuitka --mingw64 hello.py\nIn example 2\/Use Case 1 there is another option introduced:\npython -m nuitka --follow-imports program.py\nI only copied my hello-code from example 1 (working) and renamed it to program.py (failed - even no executable!). So I am shure, the cause will be the call and not the code.\nWhen I entered --mingw64 to the second call it worked.\nMy first thought (I am new to this and no expert for nuitka) is that the second example call implicitly uses gcc. At the first time it asks for installing it and then it seems to use it. The first call seems to force mingw64 as compiler. Could also be that the sequence of path entries makes a difference. Just the first entry will be executed unless you force it via an explicit option.","Q_Score":1,"Tags":"python,c++,compilation,nuitka","A_Id":67637799,"CreationDate":"2020-04-23T23:14:00.000","Title":"After compilation of any Python program with Nuitka I get \"is not a valid win32 application\" error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to compile my Python project to a Windows executable (.exe) using Nuitka. I get no errors\/warnings during the compilation process, but when I'm trying to run the resulting executable I get the \"C:\\Python34\\test.exe is not a valid win32 application\" error on Windows XP and a similar one on Windows 10, too). The problem persists even when I compile a \"Hello, World!\" program. Interesting, that I can easily build and run C++ projects from the Visual Studio IDE on the same PC.\nI'm using Windows XP (x32 bits), Python 3.4.0 and Microsoft Visual C++ 2008 Professional.\nHow can I solve this problem?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":599,"Q_Id":61398507,"Users Score":1,"Answer":"I have installed Microsoft Visual Studio 2010 Express instead of Microsoft Visual Studio 2008 Professional, and the problem disappeared. It looks like Nuitka just can't work with the previous version of the compiler. They even say in the docs, that Nuitka is designed for Visual Studio 2017+ (but I can't install recent versions on Windows XP), and that other versions may not work correctly.","Q_Score":1,"Tags":"python,c++,compilation,nuitka","A_Id":61424824,"CreationDate":"2020-04-23T23:14:00.000","Title":"After compilation of any Python program with Nuitka I get \"is not a valid win32 application\" error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So the data structure in question is a doubly linked list.\nLet's say that we needed to compare the data of node next to the header and data of the node next to the trailer. Then, depending on which node's data was bigger, we remove the node with bigger data. \nDoes this entire process take up \u0398(1) time, or is it more complex than that?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":61398557,"Users Score":1,"Answer":"Yes, it is O(1) because you access the head and tail directly.","Q_Score":1,"Tags":"python,data-structures,time-complexity,runtime,doubly-linked-list","A_Id":61400269,"CreationDate":"2020-04-23T23:20:00.000","Title":"Is the runtime of comparing two nodes and then removing \u0398(1)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install feature-engine module on anaconda \nthis is the error i am getting\nPackage is not available from current channels\nrepo.anaconda win 64 , noarch etc. \nCan you please help me with the problem?\nThanks,\nRD","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2468,"Q_Id":61399007,"Users Score":1,"Answer":"I believe that feature-engine is not available through anaconda channels for installation with conda install. I was able to install it via pip. Here is how I did it (in Windows):\n\nopen a CMD and run conda activate <<VIRTUALENV>>. This is the environment you create for your project. If you have not created one, then use base, the default one.\ncd to the location of your pip installation within that activated conda Virtual environment (mine was within my user folder in \\AppData\\Local\\Continuum\\anaconda3\\envs\\<<VIRTUALENV>>\\Scripts).\nin there, run pip install feature-engine\nyou should now be able to see it listed under pip freeze or pip list, but not under conda list.\nFinally, go to your code location and run the code. remember to activate that same <> each time you open a new CMD to run it.\n\nHope it helps.","Q_Score":0,"Tags":"python-3.7","A_Id":62325318,"CreationDate":"2020-04-24T00:13:00.000","Title":"Not able to install feature -Engine Module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Working on a python project and using pycharm . Have installed all the packages using requirements.txt. Is it a good practice to  run it in the beginning of every sprint or how often should i run the requirements.txt file ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":338,"Q_Id":61400132,"Users Score":0,"Answer":"The answer is NO.\nLet's say you're working on your project, already installed all the packages in the requirements.txt into your virtual environment, etc etc, at this point your environment is already setup.\nKeep working on the project and installed a new package with pip or whatever, now your environment is ok but you're requirements.txt is not up to date, you need to update it adding the new package, but you don't need to reinstall all the packages in it every time this happens.\nYou only runs pip install -r requirements.txt when you want to run your project on a different virtual environment","Q_Score":0,"Tags":"python,pycharm,requirements.txt","A_Id":61400334,"CreationDate":"2020-04-24T02:29:00.000","Title":"How often should i run requirements.txt file in my python project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any different between Nearest Neighbor and KNN or both of them are refereing to the same algorithm?\nIf both of them are in a different type. what is the different use cases to use n_neighbor to find a correlation using nearest neighbor .","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":61400713,"Users Score":0,"Answer":"They're the same thing. If I want to refer to it as an abbreviation I use KNN. If I want to say it, I just say nearest neighbor.\nKNN is used in supervised machine learning, like classification. Using the common Iris example, I would show you a flower, and you would say \"This is an Iris\" or \"This is not an Iris\". We repeat that to build a model, then throw a whole bunch at the model, and we get our results.","Q_Score":0,"Tags":"python","A_Id":61400891,"CreationDate":"2020-04-24T03:39:00.000","Title":"Difference between NearestNeighbours and KNearestNeighbour","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to convert a column in my python dataframe. The column is of type object.\nFrom\nDec-21-20 09:20PM\nto This\n2020-12-21 21:20:00:00.000","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":61400779,"Users Score":0,"Answer":"df[\"column\"] = pd.to_datetime(df[\"column\"])\nIf you need more specific formatting, edit your question and comment back so I can adjust my answer accordingly.","Q_Score":0,"Tags":"python,datetime,date-conversion","A_Id":61400821,"CreationDate":"2020-04-24T03:46:00.000","Title":"Python convert datetime to another format","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a student and I am learning to create a Twitter bot using PyCharm. When I used the command: pip install tweepy\nthe terminal displays this statement (after some other lines) :\nInstalling collected packages: idna, urllib3, chardet, certifi, requests, six, PySocks, oauthlib, requests-oauthlib, tweepy\nfollowed by this error:\nERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\\\users\\\\name\\\\desktop\\\n\\folder1\\\\folder2\\\\folder3\\\\folder4\\\\our first twitter bot\\\\venv\\\\L\nib\\\\site-packages\\\\oauthlib\\\\oauth2\\\\rfc6749\\\\grant_types\\\\__pycache__\\\\resource_owner_password_credentials.cpython-37.pyc'\nI cannot import tweepy in my program now. Please help me solve this problem. Thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":61400938,"Users Score":0,"Answer":"You have to enable long file names in windows.\nOpen Regedit and change HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\FileSystem\\LongPathsEnabled to 1. Restart or sign out to apply for new settings.","Q_Score":1,"Tags":"python-3.x,pycharm,tweepy","A_Id":65447755,"CreationDate":"2020-04-24T04:03:00.000","Title":"How to fix Environment Error while installing tweepy in PyCharm","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 using airflow to orchestrate my ETL.\nFor ingestion from certain sources like APIs I am using custom Airflow Plugins(with hooks and operators)\nMy question is why to use Airflow Plugins , we can achieve the same result by using a Bash Operator to trigger simple python script to achieve the same result.\nIs there a distinct advantage of using the Airflow Plugins vs using a external python script","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":183,"Q_Id":61401688,"Users Score":1,"Answer":"You use the plugins provided because they are much easier to use and are built to perform a specific task. For example, I built an operator that extracts data from a database (Snowflake) and writes it to Slack as an ASCII table. How would you perform the same task using the bash operator? Sure you could do it but it's ugly and not the \"airflow way\". \nWhat ends up happening if you only use the bash operator is that you'll eventually come across a task that is much easier to do in Python and you'll start calling python code from your bash operator which is when things really get messy. Then someone who understands how Airflow works ends up asking: \"Why didn't you just write a new operator to do this?\"","Q_Score":2,"Tags":"python,airflow-scheduler,airflow","A_Id":61484243,"CreationDate":"2020-04-24T05:22:00.000","Title":"Why use Airflow Plugins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried to run the telegram API through my Jupyter Notebook but while importing it showed the following error\nfrom telethon import TelegramClient\n----> 2 from telethon.errors.rpc_errors_401 import SessionPasswordNeededError\n      3 \n      4 # (1) Use your own values here\n      5 api_id = 11111\nModuleNotFoundError: No module named 'telethon.errors.rpc_errors_401'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":922,"Q_Id":61403979,"Users Score":0,"Answer":"The module to be used for SessionPasswordNeededError is telethon.errors.rpcerrorlist. Try using from telethon.errors.rpcerrorlist import SessionPasswordNeededError","Q_Score":0,"Tags":"python,api,jupyter-notebook,telegram,telethon","A_Id":66260235,"CreationDate":"2020-04-24T08:14:00.000","Title":"Telegram API (ModuleNotFoundError: No module named 'telethon.errors.rpc_errors_401')","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":"root@kali:~\/xerosploit# pip3 install DoubleTable\nERROR: Could not find a version that satisfies the requirement DoubleTable (from versions: none)\nERROR: No matching distribution found for DoubleTable","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":577,"Q_Id":61407067,"Users Score":0,"Answer":"after installing xerosploit you just download gedit\nand install terminaltables and tabulate using pip3\nsudo apt install gedit\npip3 install terminaltables\npip3 install tabulate\nafter that go to xerosploit folder and edit xerosploit.py\nby writing the following command as:\ngedit xerosploit.py\nand replace all the raw_input to input\nand then save and then run the file as:\npython3 xerosploit.py\nand then it will work","Q_Score":1,"Tags":"python","A_Id":66422536,"CreationDate":"2020-04-24T11:14:00.000","Title":"Could not find a version that satisfies the requirement DoubleTable (from versions: none)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to makemigrations of my models on my new project with Django, I receive an error message,>No installed app with label 'app_name', what could be the issue and how can I fix it.?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":61408654,"Users Score":0,"Answer":"Go to Django settings.py and put your app: \"app_name\" into INSTALLED_APPS.\nIf it doesn't work still, then check your syntax in models.py.","Q_Score":0,"Tags":"python-3.x,django-3.0","A_Id":65653480,"CreationDate":"2020-04-24T12:44:00.000","Title":"No installed app with label 'app_name' error message","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using Linear Regression in scikit-learn and my dataset contains some cateogorical but numerical features.\nI mean that there are features such as the value of the district where the house is that are expressed by an integer number between 1 and 7: the more this number is high, the more the house is of value.\nShould I preprocess a feature that expresses a category (the district of the city) using numbers before Linear Regression with encoders such as OneHotEncoder? Or is it compulsory only when the category is expressed by characters?\nThank you in advance..","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":107,"Q_Id":61410222,"Users Score":0,"Answer":"If I understand correctly, you don't need to one hot encode these since they are ordinal, i.e. there is meaning in the order. If the numbers were product codes, for example, and there was no sense of 7 being \"better than\" or \"more than\" 4, then you would want to one-hot encode those variables, but in this case you would be losing information by one-hot encoding.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,linear-regression","A_Id":61410477,"CreationDate":"2020-04-24T14:03:00.000","Title":"scikit-learn, categorical (but numerical) features in Linear Regression","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For context, I trained two separate autoencoders in Keras: one with a standard MSE loss function and one with a customized MSE loss function. When evaluating both models at a given point in training, they have very similar performance but the losses are very different.\nMy metric for performance is mean percent error. Both models are recreating the original image with mean error on the order of 3%. However, when these models were saved, the standard Keras MSE model had a loss less than 1.0 while the model with the customized MSE cost function had a loss on the order of 30.\nIf they perform on such a consistent level, why are the losses so drastically different?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":148,"Q_Id":61410625,"Users Score":1,"Answer":"Loss is just a scalar that says to model train which direction take to adjust weights. If you multiply a loss by a scalar, the result will be almost the same. \nIm not saying that the absolute value doesnt matter, it matters. But it's not the central point.\nProbably the difference in your case happens because Keras MSE do some normalizations that you dont.","Q_Score":0,"Tags":"python,tensorflow,keras,loss-function","A_Id":61411830,"CreationDate":"2020-04-24T14:23:00.000","Title":"What does it mean for the loss in Keras to be different by orders of magnitude between models?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a numpy array X with shape (100,3) and a numpy array sub_res with shape (100,). How can I multiply sub_res element-wise with X so that I can get the resultant shape (100,3)? I want to avoid loop usage.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1013,"Q_Id":61414152,"Users Score":0,"Answer":"You can transpose X and then multiply it by sub_res using numpy.dot and finally transpose the final result.","Q_Score":0,"Tags":"python,numpy,numpy-ndarray,array-broadcasting","A_Id":61414263,"CreationDate":"2020-04-24T17:33:00.000","Title":"How can I multiply a column vector with a matrix element wise in Numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying the past 40 minutes to delete a specific column (Name) from my data frame but no method seems to work. I am using jupyter notebook by the way, not sure if that may be an issue. I am also 100% sure that the column name is named Name and that it is not the index of the data frame -- I am using the Titanic data set. \n\nWhat I have tried:\n\ndel df['Name']\ndf.drop('Name', axis=1, inplace=True)\ndf = df.drop('Name', 1)\n\nAll the above seem to delete the column, but when re-reading the csv the column appears back. Any clue on why this is happening?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":61414234,"Users Score":0,"Answer":"With reading a csv file and loading its content in a dataframe, you create a python object called df.\nThen, with the three methods you showed us, you only delete some content of this object, not the csv's content.\nI would recommend you to use the first method, del, keep working with the dataframe and not reading the csv again.\nLet me know if anything is unclear, please.","Q_Score":0,"Tags":"python,pandas","A_Id":61414340,"CreationDate":"2020-04-24T17:38:00.000","Title":"Deleting a column in a pandas frame","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know I can use relativedelta to calculate difference between two dates in the calendar. However, it doesn't feet my needs.\nI must consider 1 year = 365 days and\/or 12 months; and 1 month = 30 days.\nTo transform 3 years, 2 months and 20 days into days, all I need is this formula: (365x3)+(30x2)+20, which is equal to 1175.\nHowever, how can I transform days into years, months and days, considering that the amount of days may or may not be higher than 1 month or 1 year? Is there a method on Python that I can use?\nMathemacally, I could divide 1175 by 365, multiply the decimals of the result by 365, divide the result by 30 and multiply the decimals of the result by 30. But how could I do that in Python?","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1157,"Q_Id":61414929,"Users Score":-2,"Answer":"You can use days%365 to get number of years from days.","Q_Score":0,"Tags":"python","A_Id":61414983,"CreationDate":"2020-04-24T18:18:00.000","Title":"Converting days into years, months and days","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to find a way to edit and run a sequence of python scripts in a less manual way.\nFor context, I am running a series of simulations, which consist in running three codes in order 10 times, making minor changes to each code every time. The problem I am encountering is that this process leads to easy mistakes and chaotic work.\nThese are the type of edits I have to make to each code.\n- Modify input\/output file name\n- Change value of a parameter\nWhat is the best practice to deal with this? I imagine that the best idea would be to write another python script that does all this. Is there a way to edit other python codes, from within a code, and run them?\nI don't intend or want anyone to write a code for me. I just need to be pointed in a general direction. I have searched for ways to 'automatize' codes, but haven't yet been successful in finding a solution to my query (mainly the editing part).\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":27,"Q_Id":61415027,"Users Score":1,"Answer":"The thing that can change (files or parameter values) should be able to be either passed in or injected. Could be from a command line parameter, configuration file, or method argument. This is the \"general direction\" I offer.","Q_Score":1,"Tags":"python,python-3.x,ubuntu,automation,automated-tests","A_Id":61415081,"CreationDate":"2020-04-24T18:23:00.000","Title":"Edit and run a sequence of scripts in a less-manual way [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 use androguard to analyze a malware apk file but am facing the following error.\n\nIn [1]: a,d,dx = AnalyzeAPK(\"malware.apk\", decompiler=\"dad\")\nNameError                                 Traceback (most recent call last)\n\/usr\/local\/lib\/python3.7\/site-packages\/androguard\/cli\/main.py in  1 a,d,dx = AnalyzeAPK(\"malware.apk\", decompiler=\"dad\")\nNameError: name 'AnalyzeAPK' is not defined\n\nI have tried re installing androguard but no change. How can i fix this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1418,"Q_Id":61419165,"Users Score":0,"Answer":"You can try to update to the latest version of androguard. Also, it might be helpful to include the absolute path to the .apk file","Q_Score":0,"Tags":"python,android,malware-detection,androguard","A_Id":62263999,"CreationDate":"2020-04-24T23:50:00.000","Title":"Androguard: 'NameError: name 'AnalyzeAPK' is not defined' error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there an easy way to extract a list of all variables with start attribute from a Modelica model? The ultimate goal is to run a simulation until it reaches steady-state, then run a python script that compares the values of start attribute against the steady-state value, so that I can identify start values that were chosen badly.  \nIn the Dymola Python interface I could not find such a functionality. Another approach could be to generate the modelDescription.xml and parse it, I assume the information is available somewhere in there, but for that approach I also feel I need help to get started.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":303,"Q_Id":61423053,"Users Score":3,"Answer":"The files dsin.txt and dsfinal.txt might help you around with this. They have the same structure, with values at the start and at the end of the simulation; by renaming dsfinal.txt to dsin.txt you can start your simulation from the (e.g. steady-state) values you computed in a previous run.  \n\nIt might be worthy working with these two files if you have in mind already to use such values for running other simulations.\nThey give you information about solvers\/simulation settings, that you won't find in the .mat result files (if they're of any interest for your case)\n\nHowever, if it is only a comparison between start and final values of variables that are present in the result files anyway, a better choice might be to use python and a library to read the result.mat file (dymat, modelicares, etc). It is then a matter of comparing start-end values of the signals of interest.","Q_Score":2,"Tags":"python,attributes,modelica","A_Id":61455275,"CreationDate":"2020-04-25T08:38:00.000","Title":"Extract list of variables with start attribute from Modelica model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to pip install netfilterqueue module with my Windows 7 system, in python 3.8\nIt returned an error \"Microsoft Visual C++ 14.0 is required\"\nMy system already has got a Microsoft Visual C++ 14.25. Do I still need to install the 14.0, or is there a way that I can get out of this error?\nIf no, how do I install a lower version without uninstalling or replacing the higher version?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":153,"Q_Id":61424712,"Users Score":1,"Answer":"Alright, try uninstalling the higher version and go for the lower version making sure you download it with the same computer not with another, remembering that windows 7 no longer support some operations, and i will advice you upgrade to windows 10","Q_Score":1,"Tags":"python,visual-studio,visual-c++,visual-studio-2015,python-3.8","A_Id":61424811,"CreationDate":"2020-04-25T11:10:00.000","Title":"Microsoft Visual C++ 14.0 is required error while installing a python module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an idea to make something similar to Workflowy but with some new features. \n(Workflowy is basically a note-taking app which beautifully organises all your notes as an endless tree)\nAt first, I implemented the logic in Python. It works in a terminal by printing notes line-by-line and then waiting for the command. \nIs this a good idea to keep all the logic at the server and use JS only to render items and to send commands to the server? \nFor instance, if I want to move the entire folder into another folder, there are two ways of doing this:\n\nWay 1: With Python which receives a command from JS 'move folder x to folder y', processes it and sends back a result to render.\nWay 2: With JS which then has to understand all the folder structure and logic. In this case, the app will use a server only for storing data. \n\nI have a feeling that way 2 (using JS to understand all the logic and Python only for saving data) is more appropriate, but this means that I have to rewrite everything from scratch. \nIs the way 1 also reasonable? \nMany thanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":264,"Q_Id":61425765,"Users Score":1,"Answer":"It depends on the application you are making.\nLike if you want to display thousands of data in html file, and data are stored in a json file. If you send html file and json file to the client from the server, then on the client side, you run a script that reads json file and displays it in html, then it will be slower, because client device may not be that powerful as the server is.\nSo for performance, use heavy tasks on server side, this may cause little more internet usage because as the client has no data in formatted manner, whenever new task on data is to be performed, you have to request the server again.\nBut for opposite case, you can save internet and little low performance. Here you can do some heavy tasks on client side.\nIt also depends on which device is used at client side.","Q_Score":1,"Tags":"javascript,python,vue.js,frontend,backend","A_Id":61425859,"CreationDate":"2020-04-25T12:38:00.000","Title":"How do I divide tasks between frontend and backend properly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I changed the database from SQLite3 to PostgreSQL in my Django project. Is it possible to store my new database in the GitHub repository so that after cloning and running by the command\npython manage.py runserver\nthe project has started with the whole database?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":586,"Q_Id":61426399,"Users Score":1,"Answer":"You cannot save the database as such, you can instead create fixtures to be run. Whenever someone will clone the project, he\/she can simple run those fixtures to populate the database.","Q_Score":1,"Tags":"python,django,git,postgresql,github","A_Id":61426459,"CreationDate":"2020-04-25T13:29:00.000","Title":"Storing the Django project with the PostgreSQL database on GitHub","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In Django when I set my date\/time to default \n default=datetime.now()\nIt automatically migrated in models.py. Why I do not need to do migration for it?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":25,"Q_Id":61427665,"Users Score":2,"Answer":"just change default=datetime.now() to default=datetime.now\nNow I really think, you meant why there is always a new migrations for this model ?\nIt is beacuse you are changing the model structure by doing \n\ndefault=datetime.now() this, actually calls the function whenever\n  this line is read,\n\nwhereas what you want to do is : \n\ndefault=datetime.now this will be called when a new instance is\n  created.","Q_Score":0,"Tags":"python,django,sqlite","A_Id":61427962,"CreationDate":"2020-04-25T15:00:00.000","Title":"why does date time function don't need migration when I set it to default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i installed pyenv and switched to python 3.6.9 (using pyenv global 3.6.9). How do i go back to my system python? Running pyenv global system didnt work","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":4990,"Q_Id":61428792,"Users Score":1,"Answer":"pyenv sets the python used according to ~\/.pyenv\/version. For a temporary fix, you can write system in it. Afterwards, you'll need to fiddle through your ~\/.*rc files and make sure eval \"$(pyenv init -)\" is called after any changes to PATH made by other programs (such as zsh).","Q_Score":4,"Tags":"python,pyenv","A_Id":61429475,"CreationDate":"2020-04-25T16:20:00.000","Title":"how do i go back to my system python using pyenv in Ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've been working on a game for a month and it's quite awesome. I'm not very new to game developing.\nThere are no sprites and no images, only primitive drawn circles and rectangles.\nEverything works well except that the FPS gets slow the more I work on it, and every now and then the computer starts accelerating and heating up.\nMy steps every frame (besides input handling):\n\nupdating every object state (physics, collision, etc), around 50 objects some more complex than the other\ndrawing the world, every pixel on (1024,512) map.\ndrawing every object, only pygame.draw.circle or similar functions\n\nThere is some text drawing but font.render is used once and all the text surfaces are cached.\nIs there any information on how to increase the speed of the game?\nIs it mainly complexity or is there something wrong with the way I'm doing it? There are far more complex games (not in pygame) that I play with ease and high FPS on my computer. \nShould I move to different module like pyglet or openGL?\nEDIT: thank you all for the quick response. and sorry for the low information. I have tried so many things but in my clumsiness I heavent tried to solve the \"draw every pixel every single frame proccess\" I changed that to be drawn for changes only and now it runs so fast I have to change parameters in order to make it reasonably slow again. thank you :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":500,"Q_Id":61429445,"Users Score":2,"Answer":"Without looking at the code its hard to say something helpful.\nIts possible that you got unnecessary loops\/checks when updating objects.\nHave you tried increasing\/decreasing the amount of objects? \nHow does the performance change when you do that?\nHave you tried playing other games made with pygame? \nIs your pc just bad?\nI dont think that pygame should have a problem with 50 simple shapes. I got some badly optimized games with 300+ objects and 60+ fps (with physics(collision, gravity, etc.)) so i think pygame can easily handle 50 simple shapes. You should probably post a code example of how you iterate your objects and what your objects look like.","Q_Score":0,"Tags":"python,pygame,frame-rate,game-development","A_Id":61430100,"CreationDate":"2020-04-25T17:06:00.000","Title":"Advanced game made in pygame is too slow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"what does, train_data = scaled_data[0:training_data_len  , : ] in python\ndoes it mean from 0 to training data length and then up to end\nI tried to use it on Jupiter notebook\nit is a code from machine learning problem","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":327,"Q_Id":61430560,"Users Score":1,"Answer":"you need to select rows starting from zero till training_data_len and all the columns from your scaled_data.","Q_Score":0,"Tags":"python","A_Id":61430649,"CreationDate":"2020-04-25T18:28:00.000","Title":"what does [ 0 : training_data_len , : ] meant here","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create web form that stays on forever on a single computer. Users can come to the computer fill out the form and submit it. After submitting, it will record the responses in an excel file and send emails. The next user can then come and fill out a new form automatically. I was planning on using Flask for this task since it is simple to create, but since I am not doing this on some production server, I will just have it running locally in development on the single computer.\nI have never seen anyone do something like this with Flask so I was wondering if my idea is possible or if I should avoid it. I am also new to web development so I was wondering what problems there could be with keeping a flask application stay on 24\/7 on a local development computer.\nThanks","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1043,"Q_Id":61431307,"Users Score":2,"Answer":"Your idea is possible and while there are many ways to do this kind of thing, what you are suggesting is not necessarily to be avoided. \nAll apps that run on a computer over a long period of time start a process and keep it going until closed. That is essentially what you are doing. \nHaving done this myself (and still currently doing it) at my business, I can say that it works great. \nThe only caveat is that to ensure that it will always be available, you need to have the process monitored by some tool to make sure that it gets restarted if it ever closes due to a variety of reasons. \nIn linux, supervisor is a great tool for doing that. In windows you could register it as a service. But you could also just create an easy way to restart and make it easy for the user to do so if it is down when they need it.","Q_Score":2,"Tags":"python,flask,web-development-server","A_Id":61431632,"CreationDate":"2020-04-25T19:23:00.000","Title":"Advice on running flask app ONLY locally forever","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to create web form that stays on forever on a single computer. Users can come to the computer fill out the form and submit it. After submitting, it will record the responses in an excel file and send emails. The next user can then come and fill out a new form automatically. I was planning on using Flask for this task since it is simple to create, but since I am not doing this on some production server, I will just have it running locally in development on the single computer.\nI have never seen anyone do something like this with Flask so I was wondering if my idea is possible or if I should avoid it. I am also new to web development so I was wondering what problems there could be with keeping a flask application stay on 24\/7 on a local development computer.\nThanks","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1043,"Q_Id":61431307,"Users Score":2,"Answer":"There is nothing wrong with doing this in principle however, it is likely not the best solution for the time-to-reward payoff.\nFirst, to answer your question, this could easily be done, even for a beginner, completing this in a few hours with minimal Python and HTML experience could definitely be done. Your app could crash in the background for many reasons (running out of space, bad memory addresses, etc) but most likely you will be fine.\nAs for specifically building it, it is all possible, there are libraries you can use to add the results to an excel file, or you can easily just append to a CSV (which is what I would recommend). Creating and sending an email, similarly is relatively simple, but again, doing it without python would be much easier.\nIf you are not set on flask\/python, you could check out Google Forms but if you are set on python, or want to use it as a learning experience, it can definitely be done.","Q_Score":2,"Tags":"python,flask,web-development-server","A_Id":61431729,"CreationDate":"2020-04-25T19:23:00.000","Title":"Advice on running flask app ONLY locally forever","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have an issue, when using Visual Studio Code, and when I'm choosing the interpreter of Python to use within a code, I realize there are two different installations or Python 3, besides the two Python2 installations.\n\nPython 3.7.3 on \/usr\/bin\/python3\nPython 3.8.2 on \/usr\/local\/bin\/python3\nPython 2.7.16 on \/usr\/bin\/python (I guess this is the Apple version)\nPython 2.7.17 on \/usr\/local\/bin\/python\n\nThe problem comes when I'm trying to use the 'Extract Method' on the 3.8.2 and it tells me to update pip. How do I choose the installation to update pip?\nWhen I run \"sudo pip install --upgrade pip\" it only goes to the python 2 apple version. But I can't update the pip on the other installations. \nThanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":847,"Q_Id":61434147,"Users Score":1,"Answer":"First new version of MacOs are built in python2 and python3 in usr\/bin\n\njust leave them and install newest python\n\nthen edit path which in \/etc\/paths put 'usr\/local\/bin' on the first line\n\nenjoy! now all your python3 is run in usr\/local\/bin which is newest and installed by yourself. Also pip is work too. if you wanna upgrade your python just run brew upgrade. It's best way to use python on mac and DONT DELETE default python2 and 3 just leave them","Q_Score":4,"Tags":"python,python-3.x,macos,python-2.7,pip","A_Id":63864726,"CreationDate":"2020-04-25T23:57:00.000","Title":"Two different Python3 and Two different Python2 installations on MacOS Catalina","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to upload a js file in the root directory of my flask application such that I can access it on the url localhost:5000\/file.js\nI tried to put the js file on the same directory as app.py, but that didn't work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":158,"Q_Id":61435905,"Users Score":0,"Answer":"It won't work like that, your app.py is running the server, so though it can access the js file, it would have to be on a route to shown. I would suggest you bring the js code to .html file in the  tags and then return render_template on this @app.route('\/') .  This should display the html page whenever you visit 127.0.0.1:5000\/ and run the JavaScript consequently.","Q_Score":2,"Tags":"python,flask,web-applications","A_Id":61436080,"CreationDate":"2020-04-26T04:43:00.000","Title":"How to add a file in root directory of a flask app such that it can be accessed on localhost:5000\/file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Skyfield currently offers a way to calculate rising and setting times of bodies. Does it offer a way to calculate the transit time of bodies?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":138,"Q_Id":61438048,"Users Score":0,"Answer":"You could look for local maximums in altitude of a topographically observed body.","Q_Score":1,"Tags":"python,astronomy,skyfield","A_Id":63886942,"CreationDate":"2020-04-26T08:46:00.000","Title":"Is there a way to calculate transit times in Skyfield?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to load Amazon fine food data set using SQlite3 in juptyer notebooks but when i try to select it throws an error: Execution failed on sql \nSELECT * FROM Reviews WHERE Score != 3 LIMIT 1000\n\nDatabaseError: no such table: Reviews","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":61438055,"Users Score":0,"Answer":"Check your db connection and db file path...","Q_Score":0,"Tags":"python,sql,amazon","A_Id":61439012,"CreationDate":"2020-04-26T08:47:00.000","Title":"Amazon fine food reviews dataset SQL error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can add custom style using NamedStyle from openpyxl.\nIs there any way to get existing custom styles and remove using openpyxl?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":579,"Q_Id":61439429,"Users Score":0,"Answer":"Hi it seems like you can use workbook.named_styles to get style list.\nThis will return a list including all style exist.","Q_Score":2,"Tags":"python,excel,openpyxl","A_Id":62791625,"CreationDate":"2020-04-26T10:48:00.000","Title":"Way to remove custom style with openpyxl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I use tabs I receive \nTabError: inconsistent use of tabs and spaces in indentation\nHowever when I replace it with 4 spaces it resolves the issue. Can someone explain why there is an error when tab and 4 spaces look visually the same.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":435,"Q_Id":61439998,"Users Score":4,"Answer":"Tabs and spaces are two different characters, rendered the same on screen. Tab has no agreement on how wide a tab character can be, it may occupy width of 8,4 2 and it is configurable as well.\nPython expects the indentation in all the lines to be same as the first line, be it 1 space, 4 spaces or 1 tab etc. Use of tab won't give you an error, inconsistency in different lines will.","Q_Score":4,"Tags":"python,text-editor","A_Id":61440090,"CreationDate":"2020-04-26T11:34:00.000","Title":"Why is it recommended to use 4 spaces instead of tab in Ubuntu's Text Editor?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I visit a particular website from my main browser, I don't get any captcha but when I do it from selenium, I'm getting ReCaptcha.\nIs there a way to make the website think that selenium is my main browser or something like that? \nI asked the same question previously but it was closed. However, I found a similar question that suggests changing the user agent. I tried implementing that but in my case, it doesn't work.\nYour help would be much appreciated.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":271,"Q_Id":61440889,"Users Score":-1,"Answer":"Try passing cookie of that website to selenium driver. Selenium always creates a fresh browser instance so it would not keep any trackers\/cookies, that's why captcha is appearing.\nSince I do not know how the website tracks that so above solution may not work. If so try creating a new firefox profile and login to that website manually. Then make sure captcha is not appearing for that profile. After that try using the same firefox profile for the automation. \nHope this will help you.","Q_Score":1,"Tags":"python,selenium,selenium-webdriver,selenium-chromedriver","A_Id":61450737,"CreationDate":"2020-04-26T12:35:00.000","Title":"Is there a way to not encounter captcha in selenium in python (changing user agent doesn't work)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a code for printing calendar according to  Gregorian calendar. But I have a problem, I need to calculate the current number of week in order to print my calendar with help of array[5][7]. I need formula or program to find number of week for ex. year:2020 month:4 day:26 and I should find number of week and it's 4. is there any formula ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":107,"Q_Id":61440936,"Users Score":0,"Answer":"Can't you just get the number of days since January 1st, divide this number by 7 and add 1 (so it starts with week 1 and not 0)\nFor example:\nJanuary 17th: 17 \/ 7 = 2 -> 2+1 = Week 3\nFor the 7th, 14th, 21st, 28th etc day, you could check the remainder. If remainder is 0, week should be week-1. So day 14 is week 2 and not week 3.","Q_Score":0,"Tags":"python,c,printing,calendar,formula","A_Id":61441050,"CreationDate":"2020-04-26T12:39:00.000","Title":"Making calendar in c","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Kivy and I have built a simple app with 2 screens. The first screen is also the login screen and the second screen just shows a simple label. I want to use Twitter\/Google authentication to login and move on to the second screen.\nShould I use a button (with image) and use the on_release function call or should I use a plain image file and hook it up with an on_touch_down event to call the authentication process?\nWhat is the standard way to do it? Please advise.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":61444508,"Users Score":0,"Answer":"i'd suggest you dive into kivyMD( a kivy frameworks that makes the job easier) adding beautiful interface to the program. what you want is just a 4 line code in KivyMD","Q_Score":0,"Tags":"python-3.x,authentication,kivy,kivy-language","A_Id":61447961,"CreationDate":"2020-04-26T16:48:00.000","Title":"Kivy application login","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Kivy and I have built a simple app with 2 screens. The first screen is also the login screen and the second screen just shows a simple label. I want to use Twitter\/Google authentication to login and move on to the second screen.\nShould I use a button (with image) and use the on_release function call or should I use a plain image file and hook it up with an on_touch_down event to call the authentication process?\nWhat is the standard way to do it? Please advise.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":61444508,"Users Score":0,"Answer":"It's entirely up to you, but in the absence of other concerns default to the Button.","Q_Score":0,"Tags":"python-3.x,authentication,kivy,kivy-language","A_Id":61446092,"CreationDate":"2020-04-26T16:48:00.000","Title":"Kivy application login","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an exe file that I made with pyinstaller and when I try to run it it gives me this error:\n\nModuleNotFoundError: No module named 'pkg_resources.py2_warn' [50728]\nFailed to execute script pyi_rth_pkgres\n\nthe python script contains a scheduler using BlockingScheduler from apscheduler.schedulers.blocking that works when I execute it as a python script, but return this error as an exe file.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1225,"Q_Id":61445102,"Users Score":2,"Answer":"Saw this answer on stackoverflow (can't remember the url):\nHere's what you need to do:\nStep:1 pip uninstall pyinstaller\nStep:2 pip install https:\/\/github.com\/pyinstaller\/pyinstaller\/archive\/develop.zip\nGoodLuck","Q_Score":1,"Tags":"python,exe,pyinstaller,scheduler","A_Id":61541553,"CreationDate":"2020-04-26T17:28:00.000","Title":"pyinstaller failed to execute script pyi rth pkgres","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How to I use \"on_key_down\" event within .kv file?\nI have a text input box and I want to detect when a key is pressed down to block user from deleting the first word of the \"text\" property of my text input to simulate a \"bash console\" if you will","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":42,"Q_Id":61445391,"Users Score":1,"Answer":"use the event on_text instead.. i don't think on_key_down exists as an event on the input widget","Q_Score":0,"Tags":"python,events,kivy,kivy-language","A_Id":61448015,"CreationDate":"2020-04-26T17:48:00.000","Title":"Kivy lenguage: on_key_down","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I successfully deployed my dash app with Heroku.\nMy app has many tabs and saves the state for each tab. Meaning if the user changed the table in one tab and then switch to another tab and comeback to the tab then the table has the same content as before. \nThe problem is that I don't want the state to be saved if the user exit the site and then entered again. \nSo far during the development I achieved this by running the python command for running the app again, but now I can't do this (I launched the app with Docker container and it's seems that one image is shared between all the sessions).\nIs there a way in Heroku to solve this problem? maybe create a new image for each new sessions?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":153,"Q_Id":61445664,"Users Score":0,"Answer":"you create an image to release your application (say v1.0) and run it on Docker env (Heroku or other platforms). The application runs in a container and serves all users: every restart or redeploying a new image would need a downtime which impacts everyone.\nThe solution (for what I can understand) is that you want to clear the session data for a given user, so the saved state wont be used at the next access.\nI think you should look at doing that in your app: for example when accessing the home url (ie entrypoint of your app) clear any setting related to the user (which you would typically recognised with a cookie).\nNot if it help, if not share more details on how you save the user state.","Q_Score":1,"Tags":"python,docker,heroku,plotly-dash","A_Id":61446982,"CreationDate":"2020-04-26T18:10:00.000","Title":"How to deploy dash app with states using Heroku?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I just created a simple script with selenium that automates the login for my University's portal. The first reaction I got from a friend was: ah nice, you can put that on my pc as well. That would be rather hard as he'd have to install python and run it through an IDE or through his terminal or something like that and the user friendliness wouldn't be optimal.\nIs there a way that I could like wrap it in a nicer user interface, maybe create an app or something so that I could just share that program? All they'd have to do is then fill in their login details once and the program then logs them in every time they want. I have no clue what the possibilities for that are, therefore I'm asking this question. \nAnd more in general, how do I get to use my python code outside of my IDE? Thusfar, I've created some small projects and ran them in PyCharm and that's it. Once again, I have no clue what the possibilities are so I also don't really know what I'm asking. If anyone gets what I mean by using my code further than only in my IDE, I'd love to hear your suggestions!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":45,"Q_Id":61445838,"Users Score":1,"Answer":"The IDE running you program is the same as you running your program in the console. But if you dont want them to have python installed (and they have windows) you can maybe convert them to exe with py2exe. But if they have linux, they probably have python installed and can run you program with \"python script.py\". But tell your friends to install python, if they program or not, it will always come in handy","Q_Score":1,"Tags":"python,ide,share","A_Id":61445921,"CreationDate":"2020-04-26T18:20:00.000","Title":"Are there any other ways to share \/ run code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So my questions is, are there functions within basic python libaries(such as pandas, numpy, matplotlib) to backtest without using backtesting liabries(such as pyalgotrade, backtesting.py and zipline). So could you backtest by just using basic libraries or do you have to use the backtesting liabries if you already had the historical data? Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":200,"Q_Id":61446028,"Users Score":5,"Answer":"There is no magic in programming. If a library implements it, you can do it as well.\nThe question is whether it is worth the amount of effort to re-do someone else's efforts, and whether you can do it better or not.","Q_Score":2,"Tags":"python,pandas,numpy,trading,back-testing","A_Id":61446088,"CreationDate":"2020-04-26T18:33:00.000","Title":"Is it possible to backtest trading algorithms without using backtesting libaries?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I started programming 1 -2 months ago with python and I am using Sublime Text3. I tried to read about it but I don't seem to understand how to link my virtualenv to my python project. \nWhen I create my virtualenv in the terminal (I am on macOS) and I open a new project in sublime I can't import my installed modules. How do I add the env to my python project?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":61446825,"Users Score":0,"Answer":"I would suggest taking a look at PyCharm (instead of sublime). It's a great IDE for python.\nI'm not sure how sublime works, but on PyCharm you can set an interpreter for a project and give it the path to your virtual env. Maybe there's something similar in sublime as well..?\nMy venv paths are usually something like wherever_you_store_your_project\/project_name\/venv\/bin\/python \nEDIT\nThe venv in the path is how I name my virtual environments","Q_Score":0,"Tags":"python,virtualenv,sublimetext3,python-venv","A_Id":61447578,"CreationDate":"2020-04-26T19:29:00.000","Title":"Using Virtual environments in Sublime. Cant import modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can you suggest a module function from numpy\/scipy that can find local maxima\/minima in a text file? I was trying to use the nearest neighbours approach, but the data fluctuations cause false identification. Is it possible to use the neighbour's approach but use 20 data points as the sample_len.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":61448975,"Users Score":0,"Answer":"scipy.signal.argrelmax looks for relative maxima in an array (there is also argrelmin for minima). It has the order keyword argument which allows you to compare eg. 20 neighbours.","Q_Score":0,"Tags":"python,python-3.x","A_Id":61457159,"CreationDate":"2020-04-26T22:32:00.000","Title":"Finding Local Minimum In 1d array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Installing \u201cplatformio-ide-terminal@2.10.0\u201d failed.Hide output\u2026\n\nnode-pty-prebuilt-multiarch@0.9.0-beta21.legacy install C:\\Users\\saqib\\AppData\\Local\\Temp\\apm-install-dir-120327-4684-1n45eei.2yxd\\node_modules\\platformio-ide-terminal\\node_modules\\node-pty-prebuilt-multiarch\n  prebuild-install || node scripts\/install.js\n\nC:\\Users\\saqib\\AppData\\Local\\Temp\\apm-install-dir-120327-4684-1n45eei.2yxd\\node_modules\\platformio-ide-terminal\\node_modules\\node-pty-prebuilt-multiarch>if not defined npm_config_node_gyp (node \"C:\\Users\\saqib\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\node_modules\\npm\\node_modules\\npm-lifecycle\\node-gyp-bin\\....\\node_modules\\node-gyp\\bin\\node-gyp.js\" rebuild )  else (node \"C:\\Users\\saqib\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js\" rebuild ) \nprebuild-install WARN install unexpected end of file\ngyp ERR! configure error \ngyp ERR! stack Error: Can't find Python executable \"C:\\Users\\saqib\\AppData\\Local\\Programs\\Python\\Python38-32\\python.EXE\", you can set the PYTHON env variable.\ngyp ERR! stack     at PythonFinder.failNoPython (C:\\Users\\saqib\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\node_modules\\npm\\node_modules\\node-gyp\\lib\\configure.js:492:19)\ngyp ERR! stack     at PythonFinder. (C:\\Users\\saqib\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\node_modules\\npm\\node_modules\\node-gyp\\lib\\configure.js:517:16)\ngyp ERR! stack     at C:\\Users\\saqib\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\node_modules\\npm\\node_modules\\graceful-fs\\polyfills.js:284:29\ngyp ERR! stack     at FSReqWrap.oncomplete (fs.js:182:21)\ngyp ERR! System Windows_NT 10.0.16299\ngyp ERR! command \"C:\\Users\\saqib\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\bin\\node.exe\" \"C:\\Users\\saqib\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js\" \"rebuild\"\ngyp ERR! cwd C:\\Users\\saqib\\AppData\\Local\\Temp\\apm-install-dir-120327-4684-1n45eei.2yxd\\node_modules\\platformio-ide-terminal\\node_modules\\node-pty-prebuilt-multiarch\ngyp ERR! node -v v10.2.1\ngyp ERR! node-gyp -v v3.7.0\ngyp ERR! not ok \nnpm WARN enoent ENOENT: no such file or directory, open 'C:\\Users\\saqib\\AppData\\Local\\Temp\\apm-install-dir-120327-4684-1n45eei.2yxd\\package.json'\nnpm WARN apm-install-dir-120327-4684-1n45eei.2yxd No description\nnpm WARN apm-install-dir-120327-4684-1n45eei.2yxd No repository field.\nnpm WARN apm-install-dir-120327-4684-1n45eei.2yxd No README data\nnpm WARN apm-install-dir-120327-4684-1n45eei.2yxd No license field.\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! node-pty-prebuilt-multiarch@0.9.0-beta21.legacy install: prebuild-install || node scripts\/install.js\nnpm ERR! Exit status 1\nnpm ERR! \nnpm ERR! Failed at the node-pty-prebuilt-multiarch@0.9.0-beta21.legacy install script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     C:\\Users\\saqib.atom.apm_logs\\2020-04-27T04_37_34_189Z-debug.log","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":1170,"Q_Id":61451860,"Users Score":-1,"Answer":"I have had similar problem befor..\nSOLUTION: Just uninstall the current version of your Atom and Install the latest Version..then try re-install the plugin (platformio-ide-terminal) this should work","Q_Score":0,"Tags":"python,atom-editor","A_Id":64240238,"CreationDate":"2020-04-27T04:43:00.000","Title":"i am not able to install platfomio-ide-terminal in ATOM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Installing \u201cplatformio-ide-terminal@2.10.0\u201d failed.Hide output\u2026\n\nnode-pty-prebuilt-multiarch@0.9.0-beta21.legacy install C:\\Users\\saqib\\AppData\\Local\\Temp\\apm-install-dir-120327-4684-1n45eei.2yxd\\node_modules\\platformio-ide-terminal\\node_modules\\node-pty-prebuilt-multiarch\n  prebuild-install || node scripts\/install.js\n\nC:\\Users\\saqib\\AppData\\Local\\Temp\\apm-install-dir-120327-4684-1n45eei.2yxd\\node_modules\\platformio-ide-terminal\\node_modules\\node-pty-prebuilt-multiarch>if not defined npm_config_node_gyp (node \"C:\\Users\\saqib\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\node_modules\\npm\\node_modules\\npm-lifecycle\\node-gyp-bin\\....\\node_modules\\node-gyp\\bin\\node-gyp.js\" rebuild )  else (node \"C:\\Users\\saqib\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js\" rebuild ) \nprebuild-install WARN install unexpected end of file\ngyp ERR! configure error \ngyp ERR! stack Error: Can't find Python executable \"C:\\Users\\saqib\\AppData\\Local\\Programs\\Python\\Python38-32\\python.EXE\", you can set the PYTHON env variable.\ngyp ERR! stack     at PythonFinder.failNoPython (C:\\Users\\saqib\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\node_modules\\npm\\node_modules\\node-gyp\\lib\\configure.js:492:19)\ngyp ERR! stack     at PythonFinder. (C:\\Users\\saqib\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\node_modules\\npm\\node_modules\\node-gyp\\lib\\configure.js:517:16)\ngyp ERR! stack     at C:\\Users\\saqib\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\node_modules\\npm\\node_modules\\graceful-fs\\polyfills.js:284:29\ngyp ERR! stack     at FSReqWrap.oncomplete (fs.js:182:21)\ngyp ERR! System Windows_NT 10.0.16299\ngyp ERR! command \"C:\\Users\\saqib\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\bin\\node.exe\" \"C:\\Users\\saqib\\AppData\\Local\\atom\\app-1.45.0\\resources\\app\\apm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js\" \"rebuild\"\ngyp ERR! cwd C:\\Users\\saqib\\AppData\\Local\\Temp\\apm-install-dir-120327-4684-1n45eei.2yxd\\node_modules\\platformio-ide-terminal\\node_modules\\node-pty-prebuilt-multiarch\ngyp ERR! node -v v10.2.1\ngyp ERR! node-gyp -v v3.7.0\ngyp ERR! not ok \nnpm WARN enoent ENOENT: no such file or directory, open 'C:\\Users\\saqib\\AppData\\Local\\Temp\\apm-install-dir-120327-4684-1n45eei.2yxd\\package.json'\nnpm WARN apm-install-dir-120327-4684-1n45eei.2yxd No description\nnpm WARN apm-install-dir-120327-4684-1n45eei.2yxd No repository field.\nnpm WARN apm-install-dir-120327-4684-1n45eei.2yxd No README data\nnpm WARN apm-install-dir-120327-4684-1n45eei.2yxd No license field.\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! node-pty-prebuilt-multiarch@0.9.0-beta21.legacy install: prebuild-install || node scripts\/install.js\nnpm ERR! Exit status 1\nnpm ERR! \nnpm ERR! Failed at the node-pty-prebuilt-multiarch@0.9.0-beta21.legacy install script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     C:\\Users\\saqib.atom.apm_logs\\2020-04-27T04_37_34_189Z-debug.log","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1170,"Q_Id":61451860,"Users Score":0,"Answer":"Reset your atom to default setting by deleting .atom directory in your \/username folder. Then try to install.","Q_Score":0,"Tags":"python,atom-editor","A_Id":66188307,"CreationDate":"2020-04-27T04:43:00.000","Title":"i am not able to install platfomio-ide-terminal in ATOM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am fetching AD data via ldap3 connections to domain controllers using python.\nOne group has many users in member field.\nBut, when I search the users directly, few of them have no entry.\nHence, my question is as below.\nIf a group object is deleted, does it get removed from the member field of its parent group and memberOf field of its user?\nAnd, if a user object is deleted, does it get removed from the member field of its parent group?\nNote:\nI am checking all available domain controllers and looking for latest entry of any object.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":61453242,"Users Score":0,"Answer":"Yes, as long as the user and group is in the same AD forest, then the user is removed from the groups when the user is deleted.\nThe only exception is users on an external, trusted domain.\nIf you update your question with your code, we might be able to spot something wrong.","Q_Score":0,"Tags":"python,linux,active-directory","A_Id":61464908,"CreationDate":"2020-04-27T06:56:00.000","Title":"Do the member and memberOf fields in Active Directory get updated when object in its value is deleted?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a web app with Django and integration of Selenium and Python-Docker API.\nWhere inside the Django project is the correct place to put the Selenium scripts so users will be able the run it by a puse of a button?\nI've seen some thred saying inside a 'view', but is is a lot of logic that I've sprated into multipale .py files.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":226,"Q_Id":61457373,"Users Score":1,"Answer":"You must import Selenium package inside another file such as sel-functions.py inside your app. \nThen you define your class or functions inside this file. Finally you can import all those functionality to your views.py file. \nThis is best and cleanest way to work with another package or functionality in Django project. \nAlso if multiple apps of your project need to sel-functions.py  you can put that in your project directory beside settings.py. \n\nAlso, if your code has grown so much that it has multiple files, you\n  need to define a package for your intended work and define it as an\n  application in your project.","Q_Score":1,"Tags":"python,django,selenium","A_Id":61458639,"CreationDate":"2020-04-27T11:00:00.000","Title":"Django and pure Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a large dump file created by mongodump utility, for example \"test.dump\". I want get one exact collection from this dump, and manually read it into memory for further processing as valid BSON documents. I cannot load full dump in memory due to it's size. \nI do not need physically restore anything to mongo instances! I basically even have none of them up and running. So mongorestore utility could be a solution only if can help me to read my collection from a dump file to memory.\nI'm using Python 3 and pymongo, but can import another third-party libs if necessary or launch any CLI utilities with stdout results.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":596,"Q_Id":61458371,"Users Score":1,"Answer":"I am unfamiliar with any off-the-shelf tools that would extract a collection out of a dump file. That said:\n\nAWS offers x1e.32xlarge instance type with almost 4 TB of memory. How big is your dump exactly?\nSurely the easiest solution is to just load the dump into a MongoDB deployment (which doesn't need much memory or other resources, if you are going to dump one collection back). Hardware is very cheap these days.\nThe BSON format is not that complicated. I expect you'd need to write the tooling for this yourself but if the dump is in fact valid BSON you can manually traverse it using BSON reading code that is part of every MongoDB driver.","Q_Score":0,"Tags":"python,mongodb,pymongo,mongodump,mongorestore","A_Id":61465519,"CreationDate":"2020-04-27T11:58:00.000","Title":"Read mongodump manually","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use pipenv in PyCharm with Python 3.8 but cannot locate the pipenv executable.\nCurrent situation :\nI have installed Python 3.8.2 on a Debian platform (actually LMDE 3), where Python 2.7 and 3.5 were already installed globally (in \/usr\/bin). I want to use Python 3.8 for development and leave th other two untouched. Python 3.8 is hence now installed in \/usr\/local\/bin.\nI have used the which command to locate the binaries and confirm the aforementioned locations.\nI have installed pip and pipenv in Python 3.8 and left untouched Python 2.7 and 3.5.\nThe python command still refers to Python 2.7 and python3 to Python 3.5. The command python3.8 refers to Python 3.8.2.\nSimilarly :\n\nwhich pip points to nowhere (pip not installed by default with Python 2.7).\nwhich pip3 points to \/usr\/bin\/pip3\nwhich pip3.8 points to \/usr\/bin\/pip3.8\n\nPipenv is installed for Python 3.5 and 3.8.2 as it is my development environment. \nI located the python module in \/home\/user_name\/.local\/lib\/python3.8\/site-packages\/pipenv\/pyenv.py\n(similar path for Python 3.5)\nThe command pipenv does not work as such. What works is python3.8 -m pipenv <something> or python3.5 -m pipenv <something>.\nHowever, running the same 'which' command for pipenv (or pipenv3, pipenv3.5, pipenv3.8) returns nothing. \nI have also found pip files (binaries ?) in \/home\/user_name\/.local\/bin\/ : pip, pip3, pip3.5, pip3.8, pipenv, pipenv-resolver . I have no idea what these are for.\nCan anybody explain me what is this mess and how I configure PyCharm correctly ?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":5057,"Q_Id":61458704,"Users Score":6,"Answer":"This does not answer the OP, but for those using Windows 10 who end up here based on the question title:\nFor a per-user installation of python 3.9, I found the executable here:\nC:\\Users\\<your username>\\AppData\\Local\\Programs\\Python\\Python39\\Scripts\\pipenv.exe","Q_Score":6,"Tags":"python,pip,pycharm,pipenv","A_Id":66871452,"CreationDate":"2020-04-27T12:15:00.000","Title":"Pycharm : locating pipenv executable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to use pipenv in PyCharm with Python 3.8 but cannot locate the pipenv executable.\nCurrent situation :\nI have installed Python 3.8.2 on a Debian platform (actually LMDE 3), where Python 2.7 and 3.5 were already installed globally (in \/usr\/bin). I want to use Python 3.8 for development and leave th other two untouched. Python 3.8 is hence now installed in \/usr\/local\/bin.\nI have used the which command to locate the binaries and confirm the aforementioned locations.\nI have installed pip and pipenv in Python 3.8 and left untouched Python 2.7 and 3.5.\nThe python command still refers to Python 2.7 and python3 to Python 3.5. The command python3.8 refers to Python 3.8.2.\nSimilarly :\n\nwhich pip points to nowhere (pip not installed by default with Python 2.7).\nwhich pip3 points to \/usr\/bin\/pip3\nwhich pip3.8 points to \/usr\/bin\/pip3.8\n\nPipenv is installed for Python 3.5 and 3.8.2 as it is my development environment. \nI located the python module in \/home\/user_name\/.local\/lib\/python3.8\/site-packages\/pipenv\/pyenv.py\n(similar path for Python 3.5)\nThe command pipenv does not work as such. What works is python3.8 -m pipenv <something> or python3.5 -m pipenv <something>.\nHowever, running the same 'which' command for pipenv (or pipenv3, pipenv3.5, pipenv3.8) returns nothing. \nI have also found pip files (binaries ?) in \/home\/user_name\/.local\/bin\/ : pip, pip3, pip3.5, pip3.8, pipenv, pipenv-resolver . I have no idea what these are for.\nCan anybody explain me what is this mess and how I configure PyCharm correctly ?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":5057,"Q_Id":61458704,"Users Score":1,"Answer":"After verifying that path was correct by using type pipenv. I was able to get it to work by clicking the file path selector in the pycharm configuration setup and selecting the path that was already selected \/home\/user_name\/.local\/bin\/pipenv. After manually selecting the already selected file location, the message went away.","Q_Score":6,"Tags":"python,pip,pycharm,pipenv","A_Id":63294262,"CreationDate":"2020-04-27T12:15:00.000","Title":"Pycharm : locating pipenv executable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a network which takes in an input image and outputs 37 values that are essentially the features. For e.g. the entire output class is a series of questions whose values are the percentage of people who agreed upon the said feature. 0.60 for class1 and 0.4 for class12. \nNow, there are some conditions such that the output of the model can't have one class that is higher than the other. E.g. class1.1 must be higher than class3.2 as it is a higher question in the decision tree. \nIs there any way we can implement this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":20,"Q_Id":61460373,"Users Score":1,"Answer":"Instead of directly outputting a, b from your neural network you can output a, a + ReLU(b) which ensures the second output is higher than or equal to the first.","Q_Score":0,"Tags":"python,tensorflow,keras,conv-neural-network","A_Id":61460629,"CreationDate":"2020-04-27T13:46:00.000","Title":"Is there any way to ensure that your CNN model predicts outputs following certain thresholds?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new on Linux, OpenCV and deep learning, in fact I just started with these things a couple weeks ago.\nIn my reserches I found a lot of people saying that is much better use OpenCV on Linux than on Windows, so, that is what I am doing. I installed an Ubuntu distro on a VM and I am using it to study.\nBut today a doubt came up into my mind. It would be possible to write an OpenCV app on Linux and use it on Windows? I've read a lot and I couldn't find a satisfatory answer. \nMaybe this is a silly question, but as I said, I am very new on all of that stuff.\nFor now, I am just studying and I am really feeling like learning Linux, but when I'll really start to build my applications it will be important to being able to run them on Windows.\nSo, if this is possible, is there some specific things that I should do to make the trasition easier?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":93,"Q_Id":61461250,"Users Score":1,"Answer":"There is absolutely no difference in the syntaxes of opencv between different operating systems. (Well, I used both and didn't bother me.) So it should be fine as long as you have the same version of Opencv installed as there are differences between opencv 3x and opencv 4x.","Q_Score":0,"Tags":"python,linux,windows,opencv,deep-learning","A_Id":61486912,"CreationDate":"2020-04-27T14:33:00.000","Title":"Is it possible to build an OpenCV app on Linux and execute it on Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"First of all, I have no background and I am new to this kind of science.\nHere is my problem. I have a list of books with reviews by readers (let's say that the user can give 1 to 5 stars to the books).\nNow I would like to sort the books from the best to the worst, according to the reviews, but doing the average of the reviews seems wrong, because a book with a single review of 5 stars would be considered better than a book with many reviews of 4 and 5 stars.\nWhat are my options here and is there any python specific librairies to do that ?\nThank you !","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":107,"Q_Id":61461316,"Users Score":1,"Answer":"Rather than average customer review, you could also have a more abstract option of \"most popular\"? Amazon gets round the issue you describe by having an \"Amazon's Choice\" for what one must assume to be the product with the best average reviews AND having sold many units\nOne way to look at it is to think about how many \"points\" something has, and how many \"points\" it has had the opportunity to score. If an item has been reviewed ten times, and the max score was 5, then it has had the opportunity to score 50 points. You could set a threshold in this way, to say that only items that have had to opportunity to score e.g. 100 points are included in the sorting method for \"most popular\". This can be an abstract concept to the end-user, after all we have no idea exactly why something is \"Amazon's Pick\" but it seems to make sense when you use their website.\nIn terms of coding this, the simplest way would be to only include books in your \"most popular\" sorting method that have at least x reviews","Q_Score":0,"Tags":"python,sorting","A_Id":61461646,"CreationDate":"2020-04-27T14:36:00.000","Title":"How can I sort books by review, but not by average review?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have a data of 100 nodes and 165 relations to be inserted into one keyspace. My grakn image have 4 core CPU and 3 GB Memory. While i try to insert the data i am getting an error [grpc-request-handler-4] ERROR grakn.core.server.Grakn - Uncaught exception at thread [grpc-request-handler-4] java.lang.OutOfMemoryError: Java heap space. It was noticed that the image used 346 % CPU and 1.46 GB RAM only. Also a finding for the issue in log was Caused by: com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1, use getErrors() for more: Node(endPoint=\/127.0.0.1:9042, hostId=null, hashCode=3cb85440): io.netty.channel.ChannelException: Unable to create Channel from class class io.netty.channel.socket.nio.NioSocketChannel)\nCould you please help me with this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":173,"Q_Id":61461481,"Users Score":0,"Answer":"It sounds like Cassandra ran out of memory - currently, Grakn spawns to processes: one for Cassandra and one for Grakn server. You can increase your memory limit with the following flags (unix):\nSERVER_JAVAOPTS=-Xms1G STORAGE_JAVAOPTS=-Xms2G .\/grakn server start\nthis would give the server 1GB, and the storage engine (cassandra) 2gb of memory, for instance. 3 GB may be a bit on the low end once your data grows so keep these flags in mind :)","Q_Score":4,"Tags":"python-3.x,vaticle-typedb","A_Id":61476936,"CreationDate":"2020-04-27T14:42:00.000","Title":"Java Heap Space issue in Grakn 1.6.0","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to transfer an app from server 1 to server 2 (size of the app 700Mb)\nfirst test : try to pack to build a w2p package --> internal error  (it works for app 400 Mb)\nSecond test : i create a tar from server 1 and i transfer to server 2 --> the app tells me no function (note that she works very well on server 1)\nServer 1 : debian jessie\nServer 2 : debian buster\nAny idea ?\nthank you very much","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":61462836,"Users Score":0,"Answer":"what i would suggest is compile the app and then transfer however you would like to another server. that will solve 700mb issue and keeps integrity of app files.","Q_Score":0,"Tags":"python,web2py","A_Id":61647174,"CreationDate":"2020-04-27T15:50:00.000","Title":"Transfer a big app web2py to a new server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a neural network which classify 3 output.My dataset is very small, I have 340 images for train, and 60 images for test. I build a model and when I compile at my result is this:\nEpoch 97\/100\n306\/306 [==============================] - 46s 151ms\/step - loss: 0.2453 - accuracy: 0.8824 - val_loss: 0.3557 - val_accuracy: 0.8922\nEpoch 98\/100\n306\/306 [==============================] - 47s 152ms\/step - loss: 0.2096 - accuracy: 0.9031 - val_loss: 0.3795 - val_accuracy: 0.8824\nEpoch 99\/100\n306\/306 [==============================] - 47s 153ms\/step - loss: 0.2885 - accuracy: 0.8627 - val_loss: 0.4501 - val_accuracy: 0.7745\nEpoch 100\/100\n306\/306 [==============================] - 46s 152ms\/step - loss: 0.1998 - accuracy: 0.9150 - val_loss: 0.4586 - val_accuracy: 0.8627\nwhen I predict the test images, test accuracy is poor.\nWhat should I do ? I also use ImageDatagenerator for data augmentation  but the result is same.Is it because I have small dataset.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":61464796,"Users Score":0,"Answer":"You can use Regularization on fully connected layers. But the fact that you already have high validation accuracy it's probably your data. your train data might not fully represent your test data. try to analyze that and make sure you do all the pre processing on the test data before testing as you did for the train data.","Q_Score":1,"Tags":"python,conv-neural-network","A_Id":61478761,"CreationDate":"2020-04-27T17:31:00.000","Title":"High train accuracy poor test accuracy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My client has provided me with a Python console application which performs some work and writes the result into a .txt file. My task is to write a Windows service which reads that particular .txt file and performs further actions.\nI used C# on .NET to write the service. My solution contains 3 projects:\n\nThe logic layer project.\nThe Windows service layer project.\nA test app layer project, used for debugging and other purposes.\n\nBoth the Windows service layer and test app layer are using the logic layer for core functionality. When I run the application through the test layer, everything works perfectly, but whenever I try to run the application through the service, the Python standalone application that the service launches doesn't write any output files. I could see that the Python app runs in the task manager, but there's no output anywhere. I believe the Python code is crashing but I couldn't get the exact reason.\nI've tried the following ways to debug the issue:\n\nSearched the Windows and System32 directories for any related output files, just to consider the possibility of the service having these directories as the default working directory.\nUsed absolute paths in the service code to make sure that the Python part is not writing output files to some unknown location.\nHad the client implement passing the output directory to the Python code through command line arguments.\nWrote a mock console app in C# which writes a file, tried to call it through the service, but it worked fine and wrote the file as expected.\nSuspected the standard IO could be causing the Python application to crash and thus used the standard IO in my mock program, but it worked without any issues.\nTried giving a long task to the Python code, which should've taken about 30 minutes to execute completely, but the Python script ran and closed immediately, which essentially is reliable proof of the theory that it crashes at some point.\nTried running the service with my unelevated Windows user instead of the Local System pseudouser.\nTried configuring the service to be able to interact with the desktop.\n\nI am all out of ideas here. Any direction I should also search in?\nJust a note, if that matters: I am using System.Diagnostics.Process to launch the Python script.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":288,"Q_Id":61464820,"Users Score":0,"Answer":"If it works from your test app, it sounds like a permissions issue. What security context \/ user is the windows service running as, and does that user have permission to write to the filesystem where you are expecting it? Have you tried using a full path to the output file to be sure where it is expected? \nI'd be inclined to write a tiny python app that just saves \"hello world\" to a file, and get that to work from a windows service, then build up from there.","Q_Score":0,"Tags":"python,c#,.net,windows-services","A_Id":61465997,"CreationDate":"2020-04-27T17:32:00.000","Title":"Python program crashes when run through a Windows service","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My client has provided me with a Python console application which performs some work and writes the result into a .txt file. My task is to write a Windows service which reads that particular .txt file and performs further actions.\nI used C# on .NET to write the service. My solution contains 3 projects:\n\nThe logic layer project.\nThe Windows service layer project.\nA test app layer project, used for debugging and other purposes.\n\nBoth the Windows service layer and test app layer are using the logic layer for core functionality. When I run the application through the test layer, everything works perfectly, but whenever I try to run the application through the service, the Python standalone application that the service launches doesn't write any output files. I could see that the Python app runs in the task manager, but there's no output anywhere. I believe the Python code is crashing but I couldn't get the exact reason.\nI've tried the following ways to debug the issue:\n\nSearched the Windows and System32 directories for any related output files, just to consider the possibility of the service having these directories as the default working directory.\nUsed absolute paths in the service code to make sure that the Python part is not writing output files to some unknown location.\nHad the client implement passing the output directory to the Python code through command line arguments.\nWrote a mock console app in C# which writes a file, tried to call it through the service, but it worked fine and wrote the file as expected.\nSuspected the standard IO could be causing the Python application to crash and thus used the standard IO in my mock program, but it worked without any issues.\nTried giving a long task to the Python code, which should've taken about 30 minutes to execute completely, but the Python script ran and closed immediately, which essentially is reliable proof of the theory that it crashes at some point.\nTried running the service with my unelevated Windows user instead of the Local System pseudouser.\nTried configuring the service to be able to interact with the desktop.\n\nI am all out of ideas here. Any direction I should also search in?\nJust a note, if that matters: I am using System.Diagnostics.Process to launch the Python script.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":288,"Q_Id":61464820,"Users Score":0,"Answer":"Thanks to the help from timhowarduk, I finally was able to get to the root cause of the problem. The python script was looking for a configuration file, and when it was running from the Windows Service, it was looking for that config file in System32. \n\nAll the windows services are run from System32.\n\nThe above caused the python script to search in System32 since it was running as part of the windows service. I guess I might just ask the client to edit the python script to read config from the windows service application directory.","Q_Score":0,"Tags":"python,c#,.net,windows-services","A_Id":61488405,"CreationDate":"2020-04-27T17:32:00.000","Title":"Python program crashes when run through a Windows service","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm building a personal website that I need to apply modularity to it for purpose of learning. What it means is that there is a model that contains x number of classes with variations, as an example a button is a module that you can modify as much depending on provided attributes. I also have a pages model that need to select any of created modules and render it. I can't find any documentation of how to access multiple classes from one field to reference to. \nModel structure is as below:\n\nModules, contains module A and module B\nPages should be able to select any of module A and order its structure.\n\nPlease let me know if not clear, this is the simplest form I could describe. Am I confusing this with meta classes? How one to achieve what I'm trying to achieve?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":18,"Q_Id":61464967,"Users Score":0,"Answer":"I ended up using Proxy models but will also try polymorphic approach. This is exactly what is designed to do, inherit models from a parent model in both one to many and many to many relationships.","Q_Score":0,"Tags":"python,django,django-models","A_Id":61470153,"CreationDate":"2020-04-27T17:40:00.000","Title":"Modular python admin pages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to git and Pythonanywhere. So, I have a live Django website which is hosted with the help of Pythonanywhere. I have made some improvements to it. I have committed and pushed that changes to my Github repository. But, now I don't know that how to further push that changes to my Pythonanywhere website. I am so confused. Please help!!! Forgive me, I am new to it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":145,"Q_Id":61465874,"Users Score":1,"Answer":"You need to go to the repo on PythonAnywhere in a bash console, run git pull (You may need to run .\/mange.py migrate if you made changes to your models) and then reload the app on \"Web\" configuration page on PythonAnywhere. .","Q_Score":0,"Tags":"python,django,web-deployment","A_Id":61477904,"CreationDate":"2020-04-27T18:30:00.000","Title":"How to deploy changes made to my django project, which is hosted on pythonanywhere?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am setting a variable with String which has some special characters.\nHere's below the code snippet for the same\n${message}    Set variable      < & Hi, how can I help? > \" '\nAlso the same message is being sent in logs and it is being validated using the grep command.\nBut I'm facing issue while validating the same. I tried escaping few characters in set variable. Also tried to match the number of double quotes and single quote. But no help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1461,"Q_Id":61472559,"Users Score":0,"Answer":"You can try this syntax\n${escaped} =    Regexp Escape   ${original}","Q_Score":0,"Tags":"python,python-2.7,robotframework,special-characters","A_Id":61472720,"CreationDate":"2020-04-28T04:20:00.000","Title":"How to set variable with special characters in Robot Framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have noticed that yum install python3 or apt-get install python3 python 3.6 but I am unable to understand why it installs this specific version; 3.8 is the latest version of python. Why does it pick 3.6 in specific ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2469,"Q_Id":61474288,"Users Score":1,"Answer":"This just depends on the OS you are using. Each OS packages a certain version of python and sticks with it. For example:\n\nCentOS 7: python 3.6\nCentOS 8: python 3.6\nUbuntu 16.04: python 3.5\nUbuntu 18.04: python 3.6\nUbuntu 20.04: python 3.8\n\nNOTE: There are some OS that use rolling releases and that thus will update their default python version, but that is more rare.","Q_Score":1,"Tags":"python,linux,yum","A_Id":61475027,"CreationDate":"2020-04-28T06:50:00.000","Title":"Why does yum install python3 install python3.6","Data 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 encoder decoder network with : 3 BLSTMs in the encoder and 2 vanilla LSTMs in the decoder connected with a mutli head attention with 4 nodes. Latent dimension is 32 and my total sample looks like (10000,400,128). The encoder network has a dropout of 0.2 and the decoder has a dropout of 0.3. I'm using an adam optimizer with a learning rate of 0.001 and Mean Squared error loss. Finally I have a validation split of 0.3. I rented an Nvidia Titan V (with Core\u2122 i9-9820X,  5.0\/20 cores and 16\/64 GB total effective shared RAM) on Vast.ai and it takes ~6 minutes for each epoch when I train it all together (7000 train and 3000 validation samples).\nI was hoping to find ways of reducing the total train timing. Any suggestions would be great.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":689,"Q_Id":61474472,"Users Score":1,"Answer":"The first things that pop into mind are early stopping callbacks and change the batch size.\nAlthough I haven't tried that on my own, batch normalization is considered to also make the training more efficient.\nIn my (not so relevant) case, I saw a great improvement in training speed and quality after normalizing the data. So, maybe data normalization\/standardization could help a bit.\nLast but not least, GRU networks tend to train faster, but in some cases they under-perform in relation to LSTM networks. I don't know if you are willing to change your model, but I thought I should mention this.","Q_Score":0,"Tags":"python,tensorflow,keras,lstm,encoder-decoder","A_Id":61476847,"CreationDate":"2020-04-28T07:03:00.000","Title":"Strategies to speed up LSTM training","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I use the earlier version of Python i.e version 2.x?\nUnder the 'change runtime' option - I can see the option for selecting hardware accelerator.","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":26745,"Q_Id":61475248,"Users Score":-1,"Answer":"If you are running some python program, you can use\n!python2.7 your_program.py instead of !python your_program.py\nBut if you want to execute some python2.7 code, I think that as mentioned in the previous answers, it is not possible.","Q_Score":13,"Tags":"google-colaboratory,python-2.x","A_Id":71063393,"CreationDate":"2020-04-28T07:53:00.000","Title":"How can I use Python 2 on Google Colab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I use the earlier version of Python i.e version 2.x?\nUnder the 'change runtime' option - I can see the option for selecting hardware accelerator.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":26745,"Q_Id":61475248,"Users Score":0,"Answer":"Python2 is deprecated now and is no longer available as a runtime in colab","Q_Score":13,"Tags":"google-colaboratory,python-2.x","A_Id":72044613,"CreationDate":"2020-04-28T07:53:00.000","Title":"How can I use Python 2 on Google Colab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tried to run code on the cmd but it isn't working. I'm using windows7 and I changed the path from the default but I wrote the directory on the cmd. Can anyone help me?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":31,"Q_Id":61477754,"Users Score":1,"Answer":"python3 yourfilename.py\nThe above command can run your code, makesure you are at the project directory.","Q_Score":0,"Tags":"python","A_Id":61477795,"CreationDate":"2020-04-28T10:13:00.000","Title":"How can I run Python program on cmd?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've tried to run code on the cmd but it isn't working. I'm using windows7 and I changed the path from the default but I wrote the directory on the cmd. Can anyone help me?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":61477754,"Users Score":0,"Answer":"make sure python in your system path;\nset python root path to system environment variable\uff1bthen you can run 'python filename.py' ex","Q_Score":0,"Tags":"python","A_Id":61478015,"CreationDate":"2020-04-28T10:13:00.000","Title":"How can I run Python program on cmd?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to make a program in python to learn Morse code, I've been trying to use a 2D array to store the letters and their Morse version.\nIt is quite long so I will just show you what it looks like with a and b:\nmorse_letters =[['a','b']['.-','-...']]\nI understand that I cannot use those characters because they are not an integer,  is there any way I can do this with the 2D array or is there another method that would work better? \nSorry if I'm missing anything obvious I'm quite new to learning python, but would love to learn more.\nThank you so much!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":61,"Q_Id":61477985,"Users Score":1,"Answer":"I am not sure what you wanna program but if you are looking for 'array' like structure in python it's List,Dictionary and so on, but for the morse code program i suggest using Dictionary, they are sort of like a 2-D array, with key-value pair.\ndict = {'a': '.-','b':'-...', 'c': '-.-.'}\nkind of like this....","Q_Score":0,"Tags":"python,arrays,multidimensional-array,python-3.7,morse-code","A_Id":61478613,"CreationDate":"2020-04-28T10:26:00.000","Title":"My Morse code program won't work in a 2D array, is there another way to do it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can i directly use the command numpy.ndarray.ndim(arr) to get the no. of dimensions for an array ?? without importing numpy. Is it possible ??","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":61478187,"Users Score":0,"Answer":"No, without importing a module you can't use anything defined in that module.","Q_Score":0,"Tags":"python,arrays,numpy","A_Id":61478558,"CreationDate":"2020-04-28T10:38:00.000","Title":"Using numpy.ndarray.ndim(arr) directly get the number of dimensions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently trying to host my first discord bot on heroku. In order to get the bot up and running I have to pass several tokens for discord authentication such as authentication for some APIs I'm using. \nDuring development I was using a config.json file which contains all the information I need for the bot to work. This works fine when hosted on my local machine, however I'm not sure if I should upload a file which contains passwords to a remote server like Heroku. \nWhat would be a proper and secure way for me to pass my API credentials to Heroku?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":61480468,"Users Score":0,"Answer":"the way to provide credentials\/tokens\/pwd is to use Config Vars.\nOnly the application admin has access to this info (in the Heroku Dashboard).\nIt is acceptable to trust the hosting infrastructure with this data as your applications are running on it and require it. For top security applications you would probably use a different hosting solution (private cloud) or run your own server.","Q_Score":1,"Tags":"python-3.x,heroku,discord","A_Id":61481664,"CreationDate":"2020-04-28T12:43:00.000","Title":"How do I securely pass API credentials to a remote Heroku server that my python script is hosted on?","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 just starting a new project on my pycharm i start a new project and run my server but am getting this error message couldn't import django, Must i install django for every project am creating?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":310,"Q_Id":61481481,"Users Score":0,"Answer":"If you are using virtual environment for every new project then you need to install django each time. Other wise you can use single virtual environment for all the project. It depends on you how you prefer. But I highly recommend you to use separate virtual environment for new project.","Q_Score":0,"Tags":"python,django","A_Id":61481656,"CreationDate":"2020-04-28T13:33:00.000","Title":"Must i install django every time am starting a project in pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"There is a problem, there is a Book model and in it title is the name of the book, and author is the ForeignKey of the Author model where there is a name field.\nI need to get a Python list and for this I do\nbooks = list(Book.objects.values('title', 'author'),\nbut the result is a list [{'title': 'Harry Potter', 'author': 1}]. How do I make sure that the author is instead of the unit?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":46,"Q_Id":61481996,"Users Score":1,"Answer":"The quickest fix for you is books = list(Book.objects.values('title', 'author__name'). In the assumption that author model has name field.","Q_Score":1,"Tags":"python,django,django-models","A_Id":61482095,"CreationDate":"2020-04-28T13:56:00.000","Title":"Django Model Foreign Key to text","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"File \"\/Users\/zineb\/.local\/lib\/python2.7\/site-packages\/nltk\/probability.py\", line 333\nprint(\"%*s\" % (width, samples[i]), end=\" \")\n                                          ^\nSyntaxError: invalid syntax","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":4152,"Q_Id":61483027,"Users Score":3,"Answer":"You shouldn't be developing using python 2.7 anymore, 3.xx has been out for a long time and 2.x was EOL'd recently. Mac OS X has python3 installed as \/usr\/bin\/python3.\nTo fix this error, you'll need to add from future import print_function at the top of \/Users\/zineb\/.local\/lib\/python2.7\/site-packages\/nltk\/probability.py.","Q_Score":5,"Tags":"python,jupyter-notebook","A_Id":61483116,"CreationDate":"2020-04-28T14:45:00.000","Title":"when running import nltk, Syntax Error is displayed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't import statsmodels.api in Jupyter Notebook anymore. I thought that it requires updating statsmodels.api. Then I typed \"Conda update statsmodels.api\". Then, the message comes up below. \nPackageNotInstalledError: Package is not installed in prefix.\n  prefix: XXX\n  package name: statsmodels.api\nNote: you may need to restart the kernel to use updated packages.\nIn order to update statsmodels.api, it seems that it would require restarting the kernel. But when trying to restart kernel, the warning came up as below. \n\"Do you want to restart the current kernel? All variables will be lost.\"\nWhat does \"all variable will be lost\" mean? Will I lose all the things saved at Jupyter notebook? If so, how can I restart the Kernel safely without losing all the things I\u00a0keep in my Jupyter notebook?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":4689,"Q_Id":61483515,"Users Score":3,"Answer":"Restarting your kernel will reset your Jupyter notebook and remove all variables or methods you have defined. \nYou will not lose the code written by you. Just that, you have to run all the code cell again to set the variables and methods.\nOR, \nYou can do \"Restart & Run All\"\nIt will show the message--\nAre you sure you want to restart the current kernel and re-execute the whole notebook? All variables and outputs will be lost.\nHowever, after selecting the above option, all the variables and methods will be set again. You don't have to manually execute all the code cells.","Q_Score":4,"Tags":"python,jupyter-notebook,kernel,restart","A_Id":61485680,"CreationDate":"2020-04-28T15:06:00.000","Title":"Is there any way of restarting the kernel safely without losing things saved in Python Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Where are the standard python modules located?  I'm talking about the random, turtle, etc. modules.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":61483964,"Users Score":0,"Answer":"These are located under the Lib sub directory in Main Python installation directory.\nfor example: if you have installed Python in C:\\Program Files\\Python37.\nThe standard packages will be in C:\\Program Files\\Python37\\Lib.","Q_Score":1,"Tags":"python,module","A_Id":61484097,"CreationDate":"2020-04-28T15:28:00.000","Title":"Where are the standard python modules located?","Data 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 with selenium for the first time, and I'm trying to play a video on another website.\nI've already managed to play the video, but now I'm stuck trying to make it full-screen. The full-screen button is hidden unless I hover with my mouse over it.\nSo I searched for a solution and everybody suggests to use switch_to.frame() and then access the button, but it seems like no frame surrounds the video in my case. I'm not an expert in HTML so maybe I am getting this wrong, but is there a way to click that full-screen button when there's no frame surrounding the video?\nThanks in advance for any help :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":628,"Q_Id":61485665,"Users Score":1,"Answer":"If there isn't an iframe containing the video, you should be able to click the button like you would any other on the screen. To get the hover menu to appear you can use ActionChains(driver).move_to_element(element).perform(). \nIf you're having issues finding the button, you may also be able to video_player.send_keys(\"f\"). Many players will use that shortcut to switch to fullscreen.","Q_Score":0,"Tags":"javascript,python,html,selenium,selenium-webdriver","A_Id":61486320,"CreationDate":"2020-04-28T16:56:00.000","Title":"Python Selenium - how to click full screen button of a video without a frame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to find what values of k gives a linear time complexity for an algorithm that sorts numbers in a list in ascending order. I have found that O(1) values of k makes the algorithm O(n), but I have heard that other values of k exist that I can't find. The Pseudocode is pasted below. Any help would be appreciated! \n\"\"\" PSEUDOCODE\n    Function sort(a)\n    A <- new dict\n    K <- new array\n    M <- new array\n    For i in a\n        A.add {i:0}\n    For i in a\n        A[i] <- A[i]+1\n    For key in A.keys\n        K <- add key\n    K <- Quicksort (K)\n    For k in K\n    M = M + [k]*A.value(k)\n    return M\n\"\"\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":61488041,"Users Score":0,"Answer":"Your first 3 loops are O(a) so O(3a) so far\nQuicksort is O(alog(a)) at best\/average, O(a^2) worst (represent as QS)\nThe fourth loop is O(a)\nAll together:\nO(3a) + O(QS) + O(a)\n= O(4a) + O(QS)\n= O(a) + O(QS)\n= O(QS)","Q_Score":0,"Tags":"python,time","A_Id":61488195,"CreationDate":"2020-04-28T14:02:00.000","Title":"Time complexity for sorting algorithm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a progress bar in React by calling a Flask microservice with Python.\nI don't have problems to display the component in the frontend but I don't know if:\n\nIs possible to get a response with the progress of a script done in a\nFlask microservice?\nCan a socket communication be established between Javascript and Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":325,"Q_Id":61489667,"Users Score":0,"Answer":"You have broadly speaking three choices:  \n\nWebsockets with flask-websockets\nhttps:\/\/flask-socketio.readthedocs.io\/en\/latest\/ \nServerSentEvents\nhttps:\/\/en.wikipedia.org\/wiki\/Server-sent_events \nHaving the process update an in-memory cache that you can poll through another ingress route.\n\nThe first and second are difficult if you run Flask properly with WSGI.","Q_Score":0,"Tags":"javascript,python,reactjs,sockets,flask","A_Id":61491873,"CreationDate":"2020-04-28T20:45:00.000","Title":"Creating a React JS progress bar based on progress of Flask microservice?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i've been looking for answers in stackoverflow and over all the web but still don't get it, i started a new project and upload it to a repository in github, all this i did it from a MAC computer, everything fine until here, but... i tried cloning my project in an Windows computer and i can not activate my venv, to activate the venv in MAC there is a bin file, so i type the following commands in the terminal, 'source bin\/activate' and it works fine, but i understand that in windows there is a Script folder which i dont have because i created and activated my project for the first time in MAC, there is a way which is deleting the venv directory everytime i clone my project in a different OS but i dont think that's a good pratice, so i would like to know which is the correct way of doing this, which are your recommendations? Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":186,"Q_Id":61491080,"Users Score":1,"Answer":"A virtual environment still has references back to the host machine's python installation. Since Macs and PCs have different locations for where python is located\/installed, besides the fact that a virtualenv is much different on a PC than on a Mac (even though they accomplish the same task), a virtualenv created on a Mac will not work out of the box if you transfer the files to a PC. \nI recommend adding your virtualenv's folder to your gitignore, then just creating separate environments on your Mac and PC.","Q_Score":0,"Tags":"python,django","A_Id":61491136,"CreationDate":"2020-04-28T22:29:00.000","Title":"virtual env problems while cloning projects from github in different os","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Say I have a django app called App1 and a django app called App2.\nApp1 has an endpoint called getJson() which returns a json object.\nNow, in App2, I have an endpoint which renders an html template. In the html template I have a button and when the button is clicked, I want to call App1's getJson function. Is there a better way to do this than doing a get request in the JS of the template? If so, how?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":61492512,"Users Score":0,"Answer":"Short answer, no. That's the basic flow of a Django App, you get requests and you respond.\nThe Django apps are running on a server machine. When you say App2 renders an html template, what it is doing is sending an HttpResponse with the given template, rendered, as payload to whoever requested it. This will be received in another machine, by another process.\nSo, if that other process (in another machine or the same) renders the text as an html, loads a website and shows a button, its not at all linked to your Django App. App2 ends its job when it renders and sends an HttpResponse. So if you want to control what ever happens when you press that button, you will need to communicate back with your server. And we do that sending http requests.","Q_Score":0,"Tags":"python,django","A_Id":61493186,"CreationDate":"2020-04-29T01:02:00.000","Title":"Calling Django JSON API from Template","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was going through some solutions for an online code for sorting a series . In this case, why is pd.Series called twice ? what is the point when it seems to create the same series?\nimport pandas as pd\ns = pd.Series(['100', '200', 'python', '300.12', '400'])\nprint(\"Original Data Series:\")\nnew_s = pd.Series(s).sort_values()\nprint(new_s)\nalso, why does pd.apply(pd.Series) create a Dataframe? Thank you!!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":61494223,"Users Score":0,"Answer":"I think you could simply write it this way:\ns = pd.Series(['100', '200', 'python', '300.12', '400'])\nnew_s = s.sort_values()\nprint(new_s)","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":61494279,"CreationDate":"2020-04-29T04:26:00.000","Title":"Why is pd.Series called twice?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was thinking in how to include some metadata in my script files in a way that other scripts could process this information without interfering in its .\/ execution.\nYAML Front Matter came to my mind, but obviously its --- syntax produce error either in #!\/bin\/bash as in #!\/usr\/bin\/python3, for example.\n\nIs there some simple way to allow a non-comment block (as Front Metter's one) to be ignored by script .\/ execution?\nOr any other known way to make a file carry some metadatas possible to be accessed anyway without interfer in its generic execution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":61494337,"Users Score":1,"Answer":"If you can't use a comment, you could use a Python object of some kind.\nThis is a bit like the way doctstrings work in Python: The string is an expression but it's evaluation doesn't have side effects and Python uses it as metadata.\nHowever if you need a shebang (#!...) that does have to come first. Your metadata processor will have to skip that line.","Q_Score":0,"Tags":"python-3.x,file,scripting,metadata,yaml-front-matter","A_Id":61494413,"CreationDate":"2020-04-29T04:38:00.000","Title":"Is possible to have a Front Matter header in a 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":1,"Web Development":0},{"Question":"Python is not installed and The terminal shell path \"cmd.exe\" does not exist. (+select python interpreter, as an addition to the first mistake)\nThis 2 errors appeared in my vscode...Could somebody help me, please. I am desperate\u2026\nFirst things first:I have already worked in python using pycharm and vscode. Then by mistake I made some incorrect changes in the path variable. After that everything stopped working. \nThings that I have already tried so far\n-> complete deletion of python and vscode and reinstallation both of it; \n-> using anaconda; working with paths, made changes like \/ -> \\ -> and vice versa; \n-> When i installed python and the VScode editior, i checked the box on the first window asking to add to the path.\nNothing worked\u2026\nMy path variable values are:\n(Path for user):\u00a0\nC:\/Users\/name\/AppData\/Local\/Programs\/Python\/Python38-32\/;C:\/Users\/name\/AppData\/Local\/Programs\/Microsoft VS Code\/bin; C:\/Users\/name\/AppData\/Local\/Programs\/Python\/Python38-32\/python.exe; C:\/Users\/name\/AppData\/Local\/Programs\/Microsoft VS Code\/Code.exe; C:\/Windows\/System32\/cmd.exe;\n(Path variable values for System):\nC:\/Users\/name\/AppData\/Local\/Programs\/Microsoft VS Code\/Code.exe; C:\/Windows\/System32\/cmd.exe;C:\/Users\/name\/AppData\/Local\/Programs\/Microsoft VS Code\/bin\nI crave for all advices, you can share with!\u00a0\nI would like to work out with my paths again. For it, I ask somebody who also works in Windows, to copy his\/her paths and send it to me. I will try to find mistakes or missing stuffs. If it is also doesn't work\u2026Well, I have no idea. I will thankfully read all your advises. Looking forward for your answers. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":234,"Q_Id":61499735,"Users Score":0,"Answer":"It looks like you specified the path to specific files in your PATH variable. Instead, change those to point to the directories where those files exist.","Q_Score":0,"Tags":"python,visual-studio-code,path","A_Id":61531052,"CreationDate":"2020-04-29T10:33:00.000","Title":"Python is not installed and The terminal shell path \"cmd.exe\" does not exist","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using tensorflow to train a RNN with more than 200k of data , the training process takes up to 2 hours for every epoch. I save the model for every epoch with custom callback and this function:\nmodel.save_weights()\ncan I stop the training and resume it later from last epoch like this? Does it make a diffrence in the result?\nmodel.load_wieghts(last_epoch_dir)\nmodel.fit()","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":61500035,"Users Score":2,"Answer":"Yes, you can retrain from the last epoch but the problem is that you might loose your optimiser state but it\u2019s no problem because optimiser will go back to its original state or even better within a few epochs.","Q_Score":0,"Tags":"python,tensorflow,keras,neural-network,recurrent-neural-network","A_Id":61500188,"CreationDate":"2020-04-29T10:49:00.000","Title":"Tensorflow train on a saved model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm implementing a pytorch neural network (regression) and want to identify the best network topology, optimizer etc.. I use cross validation, because I have x databases of measurements and I want to evaluate whether I can train a neural network with a subset of the x databases and apply the neural network to the unseen databases. Therefore, I also introduce a test database, which I doesn't use in the phase of the hyperparameter identification.\nI am confused on how to treat the number of epochs in cross validation, e.g. I have a number of epochs = 100. There are two options:\n\nThe number of epochs is a hyperparameter to tune. In each epoch, the mean error across all cross validation iterations is determined. After models are trained with all network topologies, optimizers etc. the model with the smallest mean error is determined and has parameters like: -network topology: 1\n-optimizer: SGD\n-number of epochs: 54\nTo calculate the performance on the test set, a model is trained with exactly these parameters (number of epochs = 54) on the training and the validation data. Then it is applied and evaluated on the test set.\nThe number of epochs is NOT a hyperparameter to tune. Models are trained with all the network topologies, optimizers etc. For each model, the number of epochs, where the error is the smallest, is used. The models are compared and the best model can be determined with parameters like:\n-network topology: 1 \n-optimizer: SGD\nTo calculate the performance on the test data, a \u201csimple\u201d training and validation split is used (e.g. 80-20). The model is trained with the above parameters and 100 epochs on the training and validation data. Finally, a model with a number of epochs yielding the smallest validation error, is evaluated on the test data.\n\nWhich option is the correct or the better one?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":523,"Q_Id":61504356,"Users Score":0,"Answer":"The number of epochs is better not to be fine-tuned.\nOption 2 is a better option.\nActually, if the # of epochs is fixed, you need not to have validation set. Validation set gives you the optimal epoch of the saved model.","Q_Score":1,"Tags":"python,neural-network,pytorch,cross-validation","A_Id":64492698,"CreationDate":"2020-04-29T14:33:00.000","Title":"Cross-validation of neural network: How to treat the number of epochs?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a time-series data frame with 27 different variables. In reality, they are all different instruments recording the same measurand every 5 minutes.\nI want to know if there is a way of determining which (say top 5 most similar) of the variables are numerically most similar.\nIf I was to calculate this, I would calculate the average difference between the recorded values for every possible instrument pair for every 5 minutes and then find the 5 instrument pairs with the smallest average difference. Doing this manually would take a long time, as I would need to calculate approximately 27*27=729 pairs and then find the pairs with the smallest average difference.\nIs there a better\/simpler way of doing this?\nI have looked into correlation, but this will not yield the result I want - this will show how correlated the variables are, not which ones are most similar numerically.\nHopefully, this makes sense.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":61504969,"Users Score":0,"Answer":"Since it is a measurement problem, maybe what you want to look at is how similarly the instruments mismeasure the ground truth or actual phenomenon. That is, look at the correlation of the measurement error (defined as the measurement minus the ground truth) between pairs of instruments. \nIf you create a matrix X which has 1 column for each instrument and 1 row for each set of measurement errors at a given time, then the correlation is just transpose(X) times X. If you don't have ground truth, maybe the mean of the measurements is a workable substitute. If you aren't measuring the instruments all at the same time, calculating the correlation between errors will be more involved.\nSince this is mostly a discussion question, it's really more suitable for stats.stackexchange.com. Good luck and have fun, it's an interesting problem.","Q_Score":1,"Tags":"python,statistics,time-series","A_Id":61505972,"CreationDate":"2020-04-29T15:01:00.000","Title":"Is there a way to determine the most similar variables from a number of different time-series?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having issues installing Anaconda on my Raspberry Pi.\nWhen I attempt to install Anaconda I get this message:\nAnaconda3-20.02-Linux-x86_64.sh: line 404:\/home\/ubuntu\/anaconda3\/conda.exe: cannot execute binary file: Exec format error\nWhen I try installing installing mini conda i get this:\nERROR:\ncannot execute native linux-armv7l binary, output from 'unman -a' is:\nLinux user 5.4.0-1008-raspi #8-Ubuntu SMP Wed Apr 8 11:13:06 UTC 2020 aarch64 aarch64 aaarch64 GNU\/Linux","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":23567,"Q_Id":61508312,"Users Score":3,"Answer":"The problem is it looks like you're using the wrong shell script to install:\nAnaconda3-20.02-Linux-x86_64.sh\nThe Raspberry PI 4 has ARM architecture and is capable of running ARM-64 instructions if you have the 64-bit version of Ubuntu installed.  You can check with uname -a and if you see aarch64 you can run the 64-bit instruction set.\nIt looks like your distribution is for 32-bit ARM, due to the armv7l output from uname so you would want to look for packages with the armv7l suffix.\nThere is not very good ARM support right now with a lot of software but hopefully that will change now that Apple is moving to ARM-64.\nIf Anaconda offers a shell script it should look like this:\nFor 32-bit ARM:\n\nAnaconda3-20.02-Linux-armv7l.sh\nAnaconda3-20.02-Linux-aarch32.sh\n\nFor 64-bit ARM:\n\nAnaconda3-20.02-Linux-arm64.sh\nAnaconda3-20.02-Linux-aarch64.sh","Q_Score":5,"Tags":"python-3.x,ubuntu,anaconda,raspberry-pi4","A_Id":63864100,"CreationDate":"2020-04-29T17:49:00.000","Title":"Installing Anaconda on Raspberry Pi 4 with 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":"I have a few python projects, that I am the only one working on. The environment is setup via venv. However, I cannot use the remote Python venv environment locally. I am newer to python. Locally, I am mounting the remote directory via ExpanDrive, connecting via SFTP on my mac.\nReason for this setup is some scripts are running via CRON periodically and, centralization. Appreciate any suggestions!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":61508766,"Users Score":0,"Answer":"Figured it out.\nInstalled remote-ssh in vscode and that solved the problem.","Q_Score":0,"Tags":"python-3.x,remote-server","A_Id":61512602,"CreationDate":"2020-04-29T18:12:00.000","Title":"How to work on a Python project, on a remote linux server, locally on a macbook?","Data Science and Machine Learning":0,"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 return the index of my DataFrame as a string.  I am using this commandp_h = peak_hour_df.index.astype(str).str.zfill(4) It is not working, I am getting this result: Index(['1645'], dtype='object', name  I need it to return the string '1645'  How do I accomplish this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":161,"Q_Id":61508867,"Users Score":2,"Answer":"In short:\ndo p_h = list(peak_hour_df.index.astype(str).str.zfill(4)). This will return a list and then you can index it.\nIn more detail:\nWhen you do peak_hour_df.index.astype(str), as you see, the dtype is already an object (string), so that job is done. Note this is the type of the contents; not of the object itself. Also I am removing .str.zfill(4) as this is additional and does not change the nature of the problem or the retuning type.\nThen the type of the whole objet you are returning is pandas.core.indexes.base.Index. You can check this like so: type(peak_hour_df.index.astype(str)). If you want to return a single value from it in type str (e.g. the first value), then you can either index the pandas object directly like so:\npeak_hour_df.index.astype(str)[0]\nor (as I show above) you can covert to list and then index that list (for some reason, most people find it more intuitive):\n\npeak_hour_df.index.astype(str).to_list()[0]\nlist(peak_hour_df.index.astype(str))[0]","Q_Score":2,"Tags":"python-3.x,pandas,dataframe","A_Id":61509026,"CreationDate":"2020-04-29T18:17:00.000","Title":"Returning a Pandas DataFrame Index as a String","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Django I need to run a shell command at some point. The command takes 6-10 minutes so I like to get live stdout from the command in my Django View in order to live track the command.\nI now how to run the command and get live output with subprocess but I have no clue of how to pass the live output to the views.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":87,"Q_Id":61511376,"Users Score":1,"Answer":"I would suggest running the sub process into cron and storing the output to a file\/db where you can get the progress from the view. Another option is to go for threading using celery. \nThe problem is that the view is not persistent, so you can not keep the hook to the output pipe across http requests.","Q_Score":2,"Tags":"python,django,subprocess","A_Id":61511557,"CreationDate":"2020-04-29T20:47:00.000","Title":"Get live output of subprocess command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a group of excel files in a directory.  I put the list of file names in a list and iterate over them to concatenate certain columns into a single file.  Periodically, one of the files does not have the proper sheet name, and the my notebook throws an error.  \nI get it that I could first open the file another way and then query the file to see if it contains the sheet_name.  I just want to be Pythonic: I am asking if file lacks sheet_name='Unbilled' go to next file. \n...\nfor file in files_to_process:\n    df = pd.read_excel(file, usecols=colNames, sheet_name='Unbilled', index=0, header=4)\n...\nI am doing this in a Jupyter notebook, just FYI","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":61511574,"Users Score":0,"Answer":"As I thought about my question while working on my question in stackoverflow and reading not on point questions, an answer came to me.  This works and seems Pythonic to me:\n...\nfor file in files_to_process:\n    try:\n        df = pd.read_excel(file, usecols=colNames, sheet_name='Unbilled', index=0, header=4)\n    except:\n        print('The following file lacks sheet_name=Unbilled: ', file)\n        pass\n...","Q_Score":0,"Tags":"python,excel,pandas,iterator,try-catch","A_Id":61511575,"CreationDate":"2020-04-29T20:59:00.000","Title":"iterating through list of excel files; how to skip opening file if excel file lacks sheet_name criteria","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When logging out a user with Flask-Login, is there a way to log out all sessions that user may have (Ex: in different browsers, different devices, etc)?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1332,"Q_Id":61514401,"Users Score":1,"Answer":"As Artiom said in his answer, Flask-Login by default uses Flask session which is client side, and you won't be able to delete all those cookies from other clients.\nHowever, there is a way to prevent other clients from logging in. Flask-Login relies on user_loader callback function to fetch the user from your cache, this function gets called on every HTTP request coming from the user's client. \nWhat you can do is on logout, you delete this particular user from this cache. That way when any client (phone, other browser,etc..) used by this user try to access your page. Flask-Login won't find the user in the cache and will redirect them to the login page.","Q_Score":0,"Tags":"python,session,flask,session-cookies,flask-login","A_Id":61529812,"CreationDate":"2020-04-30T01:25:00.000","Title":"Flask Logout All Sessions of a Specific User","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to create a textfsm template with the Netmiko library. While it works for most of the commands, it does not work when I try performing \"inc\" operation in the network device. The textfsm index file seems like it is not recognizing the same command for 2 different templates; for instance:\n\nIf I am giving the command - show running | inc syscontact\nAnd give another command - show running | inc syslocation\n\nin textfsm index; the textfsm template seems like it is recognizing only the first command; and not the second command.\nI understand that I can get the necessary data by the regex expression for syscontact and syslocation for the commands( via the template ), however I want to achieve this by the \"inc\" command from the device itself. Is there a way this can be done?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":61515453,"Users Score":0,"Answer":"you need to escape the pipe in the index file. e.g. sh[[ow]] ru[[nning]] \\| inc syslocation","Q_Score":0,"Tags":"netmiko,python-textfsm","A_Id":62872404,"CreationDate":"2020-04-30T03:30:00.000","Title":"TextFSM Template for Netmiko for \"inc\" phrase","Data Science and Machine Learning":0,"Database and SQL":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  know that variables in Python are really just references\/pointers to some underlying object(s). And since they're pointers, I guess they somehow \"store\" or are otherwise associated with the address of the objects they refer to.\nSuch an \"address storage\" probably happens at a low level in the CPython implementation. But \nmy knowledge of C isn't good enough to infer this from the source code, nor do I know where in the source to begin looking.\nSo, my question is:\nIn the implementation of CPython, how are object addresses stored in, or otherwise associated with, the variables which point to them?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":222,"Q_Id":61516096,"Users Score":4,"Answer":"In module scope or class scope, variables are implemented as entries in a Python dict. The pointer to the object is stored in the dict. In older CPython versions, the pointer was stored directly in the dict's underlying hash table, but since CPython 3.6, the hash table now stores an index into a dense array of dict entries, and the pointer is in that array. (There are also split-key dicts that work a bit differently. They're used for optimizing object attributes, which you might or might not consider to be variables.)\nIn function scope, Python creates a stack frame object to store data for a given execution of a function, and the stack frame object includes an array of pointers to variable values. Variables are implemented as entries in this array, and the pointer to the value is stored in the array, at a fixed index for each variable. (The bytecode compiler is responsible for determining these indices.)","Q_Score":2,"Tags":"python,c,python-3.x,cpython,python-internals","A_Id":61516209,"CreationDate":"2020-04-30T04:45:00.000","Title":"How is variable assignment implemented in CPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My understanding is that on a normal React website all the media will be served from the same server than the front-end files (HTML, CSS and Javascript).\nThe REST API backend will only provide links to where those images are stored, and it will be served and displayed by the front end.\nThe problem is if those images are private and only one user should be able to see them. If someone gets a hold of the image URL and opens it they would be able to see the image.\nHow do modern websites get around this problem? What would be the workflow between Django and React to keep the user's images safe and private?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1382,"Q_Id":61516203,"Users Score":0,"Answer":"Actually, before the REST API endpoint serves the URL of images, the request and response of the endpoint can be properly authorized using the Django REST frameworks authorization framework. \nAdditionally, you can write your own custom Django middlewares [HTTP hooks] for your desired end goal.\nThe middlewares can custom the HTTP request-response behaviors based on your needs.","Q_Score":2,"Tags":"javascript,python,django,reactjs,django-rest-framework","A_Id":61613804,"CreationDate":"2020-04-30T04:57:00.000","Title":"Django Rest Framework and React Front End: How to prevent unauthorized users from viewing private images if they get a hold of the image URL?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have list a = [[1,2,3],[4,5,6],[7,8,9]] and want to convert that into list b = [[1,4,7],[2,5,8],[3,6,9]]. Is it possible to do that?\ni.e. take all the value in the first element spot and combine into a new list, same for 2nd, 3rd etc... \nAssume the initial list has an unknown amount of elements and each element has unknown length, i.e. there could be 40 elements in a and each element contains 14 numbers. Thanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":61517455,"Users Score":2,"Answer":"There are a couple of ways to do it.\nThe first one is as follows:\nprint(list(map(list, zip(*a))))\nanother option is using numpy as follows:\nprint(np.array(a).T.tolist())\nAnother option is to use list comprehension as follows:\nprint([[row[i] for row in a] for i in range(len(a[0]))])","Q_Score":0,"Tags":"python","A_Id":61517519,"CreationDate":"2020-04-30T06:49:00.000","Title":"Transposing Lists - Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Blueprints to create two separate modules, one for api and one for website. My APIs have a route prefix of api. Now, I am having a route in my website called easy and it will be fetching a JSON from a route in api called easy and it's route is \/api\/easy.\nSo, how can i call \/api\/easy from \/easy.\nI have tried using requests to call http:localhost:5000\/api\/easy and it works fine in development server but when I am deploying it on Nginx server, it fails probably because I am exposing port 80 there.\nWhen I deploy my webapp on nginx, it show up perfectly just that route \/easy throws Internal Server Error.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":61520470,"Users Score":0,"Answer":"Okay so what worked for me is I simply ended up calling the api function from the frontend rather than doing the POST requests. Obviously, it makes no sense creating backend routes for flask seperately when you are using Flask too in frontend. Simply, a seperate utility function would be fine.","Q_Score":0,"Tags":"python-3.x,nginx,flask,wsgi","A_Id":62313062,"CreationDate":"2020-04-30T09:44:00.000","Title":"How to access Flask API from Flask Frontend?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I read through the descriptions of each command, but the descriptions for each command were exactly the same, so I didn't understand how those two commands work differently in Unix-like systems.\nCould anyone explain the difference?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5294,"Q_Id":61521156,"Users Score":6,"Answer":"The Python3 command was introduced because the python command pointed to python2. Since then, Python3 has become the default and thus python points to python3 on most but not all systems. So, most developers explicitly use python2 and python3 as to not run into issues on other systems.","Q_Score":3,"Tags":"python,python-3.x,unix,command","A_Id":61521213,"CreationDate":"2020-04-30T10:21:00.000","Title":"What is the difference between the python and python3 commands in unix-like systems?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm new to APIs creation in django.\nI checked DRF serializers and I found them useful when manipulating models in DB. My APIs don't use models they are based on forms. \nSo my question is : what can I get more from using DRF validators then using django forms validators in my views ? maybe the content type is more convenient  (application\/x-www-form-urlencoded vs application\/json) ?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":771,"Q_Id":61522954,"Users Score":3,"Answer":"DRF's serializers are nicely integrated within the framework. Whether they are models based or not, you will have a nice browsable UI to play with for free and you can get OpenAPI schema generation. There are probably other things I did not think of.\nWhat serializers can do that forms can't:\n\nNested data - although you can get some results with formsets.\nHyperlinked relational fields\nDifference between an empty field and a blank field - HTML forms can't do that\nout of the box integration with generic class based views or viewsets\n\nPlease note that your can still benefit from DRF even if you are not using serializers. DRF parts are loosely coupled.","Q_Score":2,"Tags":"python,django,django-rest-framework,django-forms","A_Id":61523213,"CreationDate":"2020-04-30T12:03:00.000","Title":"Django form validation vs DRF serializer validation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm analysing a big graph - 30M nodes and 350M+ edges - using the python interface of igraph. I can load the edges without any issue but executing a function like transitivity_local_undirected to compute the clustering coefficient of each node returns the error \"Transitivity works on simple graphs only, Invalid value\".\nI can't find anything online - any help would be much appreciated, thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":247,"Q_Id":61525978,"Users Score":0,"Answer":"A simple graph is a graph with no loops or multiple edges -- it sounds like the computer thinks your graph is non-simple for some reason.\nAre you sure your nodes have no loops or multiple edges between them?","Q_Score":0,"Tags":"python,igraph","A_Id":61526091,"CreationDate":"2020-04-30T14:38:00.000","Title":"\"Transitivity works on simple graphs only\" InternalError in igraph","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone have or know of any tutorials \/ courses that teach q learning without the use of open ai gym.\nI'm trying to make a convolutional q learning model and I have no problem doing this with pytorch and open ai gym, easy! but when I try and apply it all to an environment that isn't in open ai gym its a whole different story, trying to apply this to other games that aren't Atari so I don't have access to the env.reset and all those other nice options, it becomes a whole new ball game. If someone knows of a place to learn this or who is willing to teach me \/ help me with it I am more than willing to pay for any help as well.\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1305,"Q_Id":61526437,"Users Score":0,"Answer":"You can take a code of an environnement such as a game and then you implement your algorithms. \nBut think to be explicit in your code for the rewards and the actions. Return a reward for each action. \nIf you want to start RL without Gym. Try to do a simple game and implement NEAT algorithm. And then try to implement Q-learning and modify your code to add a reward for each action.","Q_Score":2,"Tags":"python,reinforcement-learning,q-learning","A_Id":62005390,"CreationDate":"2020-04-30T14:58:00.000","Title":"Deep Q Learning **WITHOUT** OpenAI Gym","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to create an automated process where a script (could be Python) could grab a Data Studio template, replicate it and then connect to a different data source?\nMy concern about using 1 dashboard for all 300 clients is the load time to filter and update the dashboard, plus restricting access to the client to only see their data.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":468,"Q_Id":61527041,"Users Score":0,"Answer":"This is currently not supported.\nThere is no API to programmatically copy reports or reconnect data sources.","Q_Score":1,"Tags":"python,automation,google-data-studio","A_Id":61552273,"CreationDate":"2020-04-30T15:26:00.000","Title":"Automated process Data Studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Say I have N numpy arrays, each of size (x, y, z), where y and z are the same for all but x differs for each. How would I combine these to a numpy array of size (w, y, z) where w is the sum of all x.\nOr, for a numerical example: I have a list of 3 numpy array with sizes (14, 32, 32), (7, 32, 32), (50, 32, 32). How do I turn these into a (71, 32, 32) sized numpy array efficiently?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":94,"Q_Id":61534749,"Users Score":3,"Answer":"You can just concatenate them along the first axis. If your 3 numpy arrays are named x1, x2, and x3, your new array would be defined as x_combined = np.concatenate((x1,x2,x3),axis=0)","Q_Score":1,"Tags":"python,numpy,numpy-ndarray","A_Id":61534786,"CreationDate":"2020-04-30T23:54:00.000","Title":"List of numpy arrays to one numpy array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a program that uses ImageGrab in Pillow. I am getting the error mentioned in the title. I notice in the documentation that it says the generic pip install Pillow doesn't come with libxcb. I tried installing libxcb with pip install libxcb, but it apparently doesn't exist as that. I tried looking around on Google for it, but none of it helped.\nIf anybody could point me to the specific library that I need to install and commands to run, I'd appreciate it!\nI should mention that the python that I'm running is the Windows Store v3.8. I am trying to keep a minimal amount on my SSD and didn't want a large overhead of stuff I won't use.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3619,"Q_Id":61537007,"Users Score":0,"Answer":"I had the same error while I was using the Ubuntu terminal for Windows 10. Figured that was the issue because it sometimes has weird errors when its executing more os orientated stuff. \nIf anyone else has this error and they're using the Ubuntu terminal, try running it with the Windows CMD.","Q_Score":6,"Tags":"python,python-3.x,pip,python-imaging-library","A_Id":61744033,"CreationDate":"2020-05-01T04:53:00.000","Title":"\"Pillow was built without XCB support\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a simple kivy app for mobiles \/ desktops which uses Twitter to authenticate users at the login screen. I am using Tweepy with Python to authenticate the users.\nThe authentication process works fine when I run the code from command line.  It generates a redirect url which I open in a browser to authenticate the user and then it generates a pin. The pin is copied and entered into the command line interface of the parent Python program as an input and the authentication process completes successfully.\nIs there a way to copy the generated pin from the browser's html content and directly use it as an input in the program without any human intervention? This would enhance the user experience and people would not get confused as to what to do with the PIN. I was playing around with the weburl, urllib and htmlparser libraries in Python and was wondering if there any way to achieve this behaviour?\nPlease help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":61538233,"Users Score":2,"Answer":"You need to create an intermediate web app which runs on a server with a static ip address. The authentication code \/ PIN should be returned by Twitter to this intermediate app, which in turn can exchange it with your mobile\/desktop app.","Q_Score":0,"Tags":"python-3.x,kivy,tweepy,kivy-language","A_Id":62116704,"CreationDate":"2020-05-01T07:05:00.000","Title":"How to achieve authentication with Twitter in Kivy App without manual intervention","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 installed Python 3.8 an Pycharm. Now I would like to install Anaconda which has python 3.7. Can I keep my Python and Pycharm and install Anaconda? Will they not interfere?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":61538713,"Users Score":3,"Answer":"No this will not interfere as Anaconda will be installed in a virtual environment. So no worries you can keep multiple version at any point of time.","Q_Score":1,"Tags":"python,anaconda,conda","A_Id":61538909,"CreationDate":"2020-05-01T07:52:00.000","Title":"Is it possible to Install Anaconda while keeping preinstalled Python and PyCharm intact?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Camelot in a Python script, which we package as an executable using pyinstaller.\nThis works fine on: a Windows 10 desktop, a Windows Server, even in a Docker container using mcr.microsoft.com\/windows:1909.\nWe are trying to get this working in a Docker container just using Windows Server Core 2019 (mcr.microsoft.com\/windows\/servercore:ltsc2019) but we are getting the dreaded missing DLL problem which seems to affect some uses of OpenCV.\n\\pyimod03_importers.py\", line 627, in exec_module\n  File \"lib\\site-packages\\cv2__init__.py\", line 9, in \nImportError: DLL load failed: The specified module could not be found.\nI gather that this is because the Windows Media Feature Pack is not part of the server core, and I don't think is available as an add-on option.\nOur question is this: will it be possible to run this script on Windows Server Core (plus a few other components) or do we need to run an image based on a full windows install?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":231,"Q_Id":61540133,"Users Score":1,"Answer":"I have reached the same problem running ffmpeg on windows core. It says mfplat.dll is missing. That file is a part of Media Feature Pack, which is absent for windows core installation.\nI just extracted that file from windows server 2019 full version and putted near ffmpeg.exe. It solved problem.\nI guess, you can go the same way. Identify required dll files first, then just copy from full version.","Q_Score":0,"Tags":"python,docker,opencv,server-core","A_Id":66291258,"CreationDate":"2020-05-01T09:45:00.000","Title":"Is it possible to run the Python Camelot library on Windows Server Core?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"This may be an opinionated question but sorry I am too curious.\nI learned to develop Django Model-View-Template websites ( multi page websites) and Django Rest Framework.\nFrom the same Django Model can I create Rest API's and MVC templates together ?\nI wanted to develop a Blog website that use session authentication and  based on MVC architecture. The same server should create API's because the Mobile app for the Blog may consume the API's and use Token Authentication (using Djoser). \nIf I use same User model for session and token authentication, Can mobile blog app users use their username and password to access website version ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":103,"Q_Id":61540356,"Users Score":2,"Answer":"Django REST Framework is just a collection of helpers to easily create HTTP endpoints that conform to REST behaviour, which mostly means conventions around GET, POST, PUT and DELETE. You could code all this behaviour by hand using default Django, DRF just makes it a lot easier. The end result are simply specific routes which accept input and return output in specific formats to\/from models.\nOf course you can use that in addition to normal Django Views. It's just a different interface to your models and other business logic. Authentication can be the same, but typically you use some sort of token authentication for the API; that ultimately depends on how the API is supposed to be used exactly.","Q_Score":1,"Tags":"python,django,django-rest-framework","A_Id":61540601,"CreationDate":"2020-05-01T10:02:00.000","Title":"Serving Django MVC and Django Rest Framework from same Model","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to get into C++-extensions for python, with boost\/python.\nI've downloaded boost 1_73 and installed it by calling bootstrap and then b2 --with-python\nIn Visual Studio, i've included the compiler include path (the boost directory) and linker library paths (\/stage\/lib\/) that the output of b2 tells me to.\nNow I get the compiler error LNK1104 cannot open file 'boost_python37-vc141-mt-x64-1_73.lib'. I can't find any information about this specific error. For everything similar there is only the suggestion to add the above mentioned paths.\nThe code I'm trying to compile is just the hello world example supplied with boost.\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":219,"Q_Id":61541062,"Users Score":0,"Answer":"First check that file exists somewhere in your filesystem. If it doesn't, you may have accidentally built it against a different version (i.e. not 141) of the VC runtime. (This has happened to me when I've had multiple runtimes installed.) \nIf you do have the file, then you just need to ensure that the path is in the link settings section of your project config.","Q_Score":0,"Tags":"c++,visual-studio,boost-python","A_Id":61542648,"CreationDate":"2020-05-01T10:52:00.000","Title":"Using boost\/python on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've just upgraded to Ubuntu 20.04. I was working with a python 3.7 project using Django inside a virtual environment, so I was confident even with the upgraded distro (which involved the installation of python 3.8) my venv would still worked. Unfortunately, that's not the case: when I activate my venv, the interpreter of python is still the 3.8 version, and nothing works. python 3.7 is completely missing. What can I do to restore my project?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4777,"Q_Id":61541281,"Users Score":1,"Answer":"In my case, it was solved just by deleting and recreating the virtual env, and reinstalling Django, of course. After that, just reloaded Apache and everything worked again.","Q_Score":11,"Tags":"python-3.x,operating-system,upgrade,python-venv,linux-distro","A_Id":64431823,"CreationDate":"2020-05-01T11:07:00.000","Title":"python 3.7 venv broken after upgrade to Ubuntu 20.04","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"like i write above, i'm running a python script that has an ETA of 37 hours, and I need to continue working. Is there any problem if I start another Pycharm session in another window and I for example run another script? wuould it create problems like crash, memory limit or something like that?\nMy laptop has an i7 4710HQ, dedicated Gforce GTX850M and 8gb of RAM\nthe script is just a simple scrape of a website, but having ban problem i set a 5 second sleep after every request. but i have to made 20,000 requests...\nthanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":61541404,"Users Score":0,"Answer":"If you have two instances of PyCharm running, unless the 2nd instance actually crashes the O\/S (Blue Screen or equivalent), that shouldn't impact the 1st instance in anyway.\nThey run in seaprate processes which are almost sandboxes the only common thing they share is the initial executable file, and the file system and the O\/S. If they are in different projects then they only share the PyCharm system settings.\nYou could even cause Python to segfault (rare but it does happen) and that wont effect your long running PyCharm application - also remember that your applications were started by PyCharm, but they aren't running in the PyCharm process. So in fact what you have is two Pycharm processes each one with at least one child process which is your running application.","Q_Score":0,"Tags":"python,pycharm","A_Id":66700683,"CreationDate":"2020-05-01T11:15:00.000","Title":"Can create problems ( like crashes) to work on a Pycharm project while another project has a script running?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So my problem started when in Spyder I wanted to import library from python (wget). Even though module was clearly installed (through both pip and conda) Spyder couldn't see it.\nI tried to resolve the issue.\nFirstly I reinstalled python - still same issue.\nNow I try to reinstall whole conda environment.\nBut even though I removed conda after uninstalling modules for example numpy pip3 uninstall numpy, then installing pip3 install numpy I still get Error: ModuleNotFoundError: No module named 'numpy'\nHonestly guys I have no clue now how can I resolve my issue and setup my python environment once again.\nI'm running everything on macOS terminal.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":61542624,"Users Score":0,"Answer":"So apparently reinstalling conda helped me to solve the problem. \nThe environment seems to be working fine.\nFor macOS I removed:\n\nrm -rf .\/anaconda3 from opt folder in users\nremoved anaconda3 from PATH\nremoved all anaconda3 dependencies\n\nI leave the post, because maybe someone has the same issue.","Q_Score":0,"Tags":"python,python-3.x,macos,numpy,pip","A_Id":61542901,"CreationDate":"2020-05-01T12:35:00.000","Title":"Pip3 and python are not synchronized | ModuleNotFoundError: No module named 'numpy'`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make a chatbot in python 3 that can learn on its own. I want it to be able to store data from the users input. How could I do this and keep it in a list so whenever i check back on it it will have new variables stored inside from different users.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":224,"Q_Id":61543578,"Users Score":0,"Answer":"For data to persist outside the program life-cycle you will need some form of permanent storage. Plain text files are an easy way to do this, as answered by Elodin. You can use JSON formatting to associate the data with each user, for example: [{\"username\":\"John\",\"input\":\"data entered by user 1\"},{\"username\":\"Mary\",\"input\":\"data entered by user 2\"}]. A better way, however, would be to use something like SQL\/SQLite to store your data.","Q_Score":0,"Tags":"python,python-3.x,chatbot","A_Id":61543720,"CreationDate":"2020-05-01T13:38:00.000","Title":"Is there a way to save user input into a permanent list that is saved even after the python program is closed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have DJI M600 Drone and I'm using ROS DJI SDK on Raspberry PI to communicate with it. \nI can successfully send waypoint commands and execute them. However, I don't know how to acknowledge that the waypoints are finished. What comes to my mind is that I can check where the drone is in order to compare it with the coordinates I sent. The second solution might be to check how many waypoints are left (haven't tried it yet). \nI wonder if there is a topic that I can subscribe to so that I can ask if the waypoints are completed. What is the proper way to do that?\nThanks in advance,\nCheers","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":151,"Q_Id":61543931,"Users Score":0,"Answer":"I use a different SDK so can't help with code example but I think you need to look into:\nthe wayPointEventCallback and wayPointCallback.","Q_Score":0,"Tags":"python,ros,dji-sdk","A_Id":61795008,"CreationDate":"2020-05-01T14:00:00.000","Title":"How to acknowledge the waypoints are done [DJI ROS Python]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to return the True value when writing the statement:\nlist = [[],[],[],[]]\nlist == []\nInstead it returns False\nMy nested list consists of a variable number of empty lists.\nHow do I write a single statement that could apply to nested list of [1\/2\/3...] empty lists?","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":513,"Q_Id":61544078,"Users Score":0,"Answer":"I do not completely understand your problem but if you want to detect an empty list or a nested list of empty list try by getting keeping only unique elements (say your list is l)\nif l ==[] or list(set(l))==[[]]:","Q_Score":3,"Tags":"python,list,if-statement,empty-list","A_Id":61544197,"CreationDate":"2020-05-01T14:10:00.000","Title":"How to return True when detecting a nested list of empty lists?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using nsepy for data analysis since more than one year.But its not working now days. i did all possible try to fix this ,uninstall and reinstall .tried with both python 2.7 and 3.7 but nothing is working it seems . all the time same timeout error while connecting to server. So it it NSE india has stopped data service via API?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":456,"Q_Id":61546532,"Users Score":0,"Answer":"It was required me to upgrade request package . Now its working fine.","Q_Score":0,"Tags":"python,stock,algorithmic-trading,nsepy","A_Id":61710124,"CreationDate":"2020-05-01T16:28:00.000","Title":"NSEPY is not working.Timeout error while connecting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a specialized text editor using Tkinter Text widgets. Some of the files that will be edited are fairly large (300K-500K lines). Some of the functions in the editor affect the whole file (e.g., tagging certain lines based on content, etc.). I'm using autoseparators to handle these situations where an undo essentially resets the entire Text widget contents to the previous state. In other words, I get the entire Text widget contents, process it, and then delete the existing Text widget contents and then insert the edited contents. The problem is, memory usage could potentially be a problem. For example, a 295K line file (about 6.8MB) may cause a memory increase of about 25MB when a document-wide function is performed (not sure where the 3-4X comes from). During a session a user might execute numerous document-wide functions. \nI would at least like to \"clear\" the undo\/redo stack when the user opens a new file or simply creates a new blank file. I know there are lots of arguments about keeping undo\/redo across files, but for my user community this is not an issue. Clearing the stack would not affect their workflow.\nI did try turning off the Text widget undo (via configure) and then turning it back on, but that didn't seem to have any effect. \nI would appreciate any thoughts on this question or guidance on a better approach to handling this type of situation. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":180,"Q_Id":61547176,"Users Score":2,"Answer":"The edit_reset method clears the undo stack.","Q_Score":1,"Tags":"python,tkinter,text,widget","A_Id":61549445,"CreationDate":"2020-05-01T17:08:00.000","Title":"Is there a way to clear the undo\/redo stack for the Text widget in Tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there an elegant way to pull one message off the broker without having to:\n\nsubscribe\ncreate an on_message()\nreceive the message\nunsubscribe\n\nI ask because we are using a json message which has multiple fields.  When new data comes in I want to ONLY update that particular field in the json message but not remove the rest of the data.  Since we have a TON of these json topics, we don't really want to keep all of them in program memory (also in case the program has to be relaunched).  On top of that, this program could be running for months without supervision.\nSo ideally, I'd like to post the json message to an ID'd topic with the retain flag set to True.  Then when new data comes in for that ID, I do a pull of the info on that topic, update that particular field in the json message and repost to the same topic.\nI can post example code but I'm hoping there is a simple function that I am unaware of.\nThanks, in advance, for any suggestions.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2372,"Q_Id":61547969,"Users Score":0,"Answer":"I don't think that is possible. You say \"When new data comes in...\" That's exacty why you need to subscribe and use the callback function. That's basically a \"pull when something is actually there\".\nJust to get an idea of how it should work: you are sending that json message via MQTT, right? And you are re-sending it when it changes? \nBut you don't have to keep them all in the RAM. You could use a retained message in combination with a fixed topic (not ID'ed) and send the ID in the message.\nIf you use retained messages with ID'ed topics, that might fill the memory.\nWhat does the ID stand for? A uniqie number? Something like a timestamp? A hash? The sender?\nI think you can solve that problem by clearly separating your things, e.g. say in data and message, where data is something you maintain in Python (e.g. a database or something in RAM) and message is something that you acually send \/ receive via MQTT. \nThen you can add \/ send \/ update data depending on what is received in MQTT and you don't have to send \/ update the complete set.","Q_Score":2,"Tags":"python,json,mqtt,subscribe","A_Id":61548823,"CreationDate":"2020-05-01T17:57:00.000","Title":"Paho-mqtt subscribe one-time message","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to Python, so my question may be very basic, sorry\/\/ \nI'm struggling to create one dummy variable on two columns in Python. I have a column(died) which is a dummy on its own with 1 corresponding to a death, 0 - no death. The second column is 'Age' that tells the age of death in months. What i need is to create a dummy for children who died before 5  years ('died'==1 & 'Age' < 60) and a dummy for children who died before 1 year ('died' == 1 & Age' < 12). I usually work in Stata in which this is very easy, but in Python I am struggling. I've been trying to use get_dummies function from pandas:\n dummy= pd.get_dummies(df['died']) & (df.aad < 60.).astype('int') \nbut it returns an error that it can't perform add, my guess is that it can't add indicator variable'died' with a continuous variable 'aad'.  Is there a straightforward (beginner friendly) way to combine information from two columns to generate a new dummy variable? Thanks a lot!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":144,"Q_Id":61550532,"Users Score":1,"Answer":"import numpy as np\ndf['dummy'] = np.where((df['died']==1) & (df['aad']<60), 1, 0)","Q_Score":0,"Tags":"python,pandas,dummy-variable","A_Id":61551121,"CreationDate":"2020-05-01T20:44:00.000","Title":"Dummy variable from two columns in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking at a hackerrank solution in python about converting to military time. But i do not understand one of the lines in the code. It reads:\nh = h % 12 + (p.upper() == 'PM') * 12\nI understand the first part where it gets the remainder, but I am not sure how the conditional statement after the plus sign does not throw an error","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":61551416,"Users Score":0,"Answer":"The conditional returns 0 or 1. If condition is true, then it adds 12 to the hour, else it adds 0","Q_Score":0,"Tags":"python","A_Id":61551450,"CreationDate":"2020-05-01T21:56:00.000","Title":"Python * operator after a conditional statement?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking at a hackerrank solution in python about converting to military time. But i do not understand one of the lines in the code. It reads:\nh = h % 12 + (p.upper() == 'PM') * 12\nI understand the first part where it gets the remainder, but I am not sure how the conditional statement after the plus sign does not throw an error","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":61551416,"Users Score":0,"Answer":"This is treated as three separate operations,\n(p.upper() == 'PM')\nthen\n* 12\nthen\nh % 12\nAs (p.upper() == 'PM') returns a boolean 1 or 0","Q_Score":0,"Tags":"python","A_Id":61551473,"CreationDate":"2020-05-01T21:56:00.000","Title":"Python * operator after a conditional statement?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There has got to be someone on this website with the same problem as me, so I apologize in advance; I couldn't find an answer to this anywhere on stack overflow even though I'm sure it's there somewhere.\nWhen I run my Python 3.8 program, it opens my game with pygame like I'd expect. However, it also opens an empty command line window. How can I prevent the command line window from appearing? I have no use for it, as all user interaction will be through the pygame window.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":366,"Q_Id":61551881,"Users Score":0,"Answer":"I've found a solution, thanks to Mofi. \nOn Windows, right click your .py file and set the default app to pythonw, instead of python. You should be able to find it in C:\\Users\\ ######## \\AppData\\Local\\Programs\\Python\\Python##.\nNow, opening your program will open without a terminal.","Q_Score":0,"Tags":"python-3.x,cmd","A_Id":61571024,"CreationDate":"2020-05-01T22:37:00.000","Title":"Prevent Command Line From Opening in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a single developer that creates python programs to automate my work. I often update the code as work duties change or I find improvements.  I want to have a cloud-based version control like Github but I don't want all of the other capabilities that the tutorials seem to push me through.  I want to write code on my computer, save a copy to github, update code on computer, update the copy on Github, etc.  I don't need to clone, fork, pull, work in teams, develop on multiple computers, etc.  Is there a simple way to push changes directly to a Github repository without Git?\nI am using PyCharm Community Edition with Python 3.7 Windows 10","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1211,"Q_Id":61552001,"Users Score":1,"Answer":"Just because you want simplicity, install GitHub desktop.\n1) Create a repository in GitHub.\n2) Enter the repo link in GitHub desktop and press the clone button to download it.\n3) Write your code\n4) To upload, just click commit and push button\nNothing else that you need to know and worry about","Q_Score":0,"Tags":"python,github,save","A_Id":61552116,"CreationDate":"2020-05-01T22:49:00.000","Title":"How can I only use Github to save versions of my code as I continuously develop?","Data 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 I start jupyter notebook, it loads on internet explorer, but I want to open jupyter notebook on my desirable browser, please provide a general solution for all browsers. I am using windows 7.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":178,"Q_Id":61552018,"Users Score":0,"Answer":"You can also copy the link from your Jupyter terminal and then paste it to your desirable browse.","Q_Score":0,"Tags":"python,browser,jupyter-notebook,jupyter","A_Id":61552165,"CreationDate":"2020-05-01T22:50:00.000","Title":"how to open jupyter notebook on desirable browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I start jupyter notebook, it loads on internet explorer, but I want to open jupyter notebook on my desirable browser, please provide a general solution for all browsers. I am using windows 7.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":178,"Q_Id":61552018,"Users Score":0,"Answer":"go to \n\nC:\\Users\\username\\AppData\\Roaming\\jupyter\\runtime\n\nand then rightclick on any .html file and then go to change and then select any browser you want to an click on apply. Then run Jupyter notebook.","Q_Score":0,"Tags":"python,browser,jupyter-notebook,jupyter","A_Id":61552036,"CreationDate":"2020-05-01T22:50:00.000","Title":"how to open jupyter notebook on desirable browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I recently installed pywin32 at a client site and after this occurred, they started experiencing MAPI errors. I cannot see how the install would have had any effect on their emails. pywin32 was simply installed with no errors. I am a novice with Python so I apologise if there is not enough detail or for the lack of understanding on my part.\nPywin32 was installed on remote desktop and the error they were receiving around this time was \"241938E error - can't open default message store (MAPI)\". The actual python script using win32.com makes no use of MAPI (simply used for word application tasks) and worked without any issues.\nThe IT firm for the client wants to know if pywin32 causes any changes to registry settings that could have impacted them and caused this error? Incidentally, they had an office365 change around the same time. I think the 'finger pointing' is more in that direction but I do need to rule out any related registry setting changes that pywin32 may make on install that could have caused or contributed to the problem they were experiencing.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":32,"Q_Id":61552391,"Users Score":1,"Answer":"SOLVED: Problem found to be a Microsoft error - reported April 27","Q_Score":1,"Tags":"pywin32,python-2.4","A_Id":61569366,"CreationDate":"2020-05-01T23:28:00.000","Title":"Does pywin32 install cause any changes to registry settings that could affect MAPI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"can someone give me a hint on how I can load a model, trained and exported in python with keras, with the C++ API of tensorflow 2.0?\nI can't find information about that, only with tensorflow version < 2.\nKind regards","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4107,"Q_Id":61552420,"Users Score":0,"Answer":"You have to check the inputs and output names. Use tensorboard option for show the model structure. It is in Graph tab. Or some net viewer like Netron, etc.","Q_Score":7,"Tags":"python,c++,keras,load,tensorflow2.0","A_Id":69650057,"CreationDate":"2020-05-01T23:31:00.000","Title":"TensorFlow 2.0 C++ - Load pre-trained model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a text and want to find e.g.\n\nAll Animals\nAll Superlatives\n\nIs there a \"simple\" way to do this?\nIm completely new to NLP.\nIm not even sure if this is a NLP Problem in the first place.\nOr does this just sound simple and is actually very complex?\nIf you have a tip for adding\/removing tags on this question all feedback is welcome.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":177,"Q_Id":61553401,"Users Score":2,"Answer":"You don't need anything sophisticated to do this. It can be achieved with simple string matching, with a few caveats:\n\nAnimals - simply create a list of animals you want to recognise. You can probably find lists of animals on the web, Wikipedia, or similar. The complication is that you might need to trim a plural marker (horse\/horses \u2014 I'm assuming English here). You could simply look up each word in the list, and if it's not in there and ends in -s, look again with the final s trimmed off. Irregular plurals exist (ox\/oxen), but there are very few of those.\nSuperlatives - again you can create a list. Superlative forms usually end in -est, so just get an English word list, throw away everything that doesn't end in -est, and then go through the remaining words removing false positives like nest etc. There will also be some irregular ones. How do you want to treat combined ones, such as most beautiful? In that case you might check for most followed by an adjective.\n\nFor superlatives there would be a second, more complicated, option, and that is using a part-of-speech tagger. Tag your text, and then get all words that have been tagged as superlative adjective. In most English tagsets that will be JJS. But taggers are not necessarily better than a word-list in terms of accuracy, so it depends on how much effort you want to spend on it.\nYou gave those as examples. For many other categories of words there are similar ways of just extracting them fairly easily, without needing complicated machine learning systems. But don't forget that creating lists might be a low-tech solution that might be quickest and most easy, with the best accuracy.","Q_Score":1,"Tags":"python,nlp,nltk,spacy","A_Id":61558948,"CreationDate":"2020-05-02T01:38:00.000","Title":"Finding words with specific criteria in a text in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to make a stopwatch where I use os to clear the terminal for the ticking numbers, but os.system('cls') does not work on idle or on mac. Are there any alternatives I can use? I usually use repl because I am doing this for class.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":611,"Q_Id":61553654,"Users Score":0,"Answer":"os.system('clear') is the alternative for macOS and repl, however on repl you could also import replit and then call replit.clear() to clear the terminal.","Q_Score":0,"Tags":"python","A_Id":61553765,"CreationDate":"2020-05-02T02:17:00.000","Title":"Alternative for os.system('cls') for python on mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Recently, I've come across more and more problems regarding VScode. Mainly it has to do with importing things, linting working incorrectly, and so much more. Is there any way to sort of reinstall the anaconda version of VScode so that its kind of a factory default? I'd really appreciate any guidance with this. Thank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1536,"Q_Id":61554148,"Users Score":0,"Answer":"The easiest way to reset VS Code from the Python extension's perspective is to erase your user settings and any relevant workspace settings related to the extension. You can then uninstall the Python extension, restart VS Code, and then install the Python extension again.","Q_Score":0,"Tags":"python,visual-studio-code,anaconda","A_Id":61647703,"CreationDate":"2020-05-02T03:35:00.000","Title":"Is there a way to uninstall VScode from the anaconda distribution and then reinstall it as a \"fresh start\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to implement a function interpolate(x, y, X_new) that computes the linear interpolation of the unknown function f at a new point x_new. The sample is given in the form of two sequences x and y. Both sequences have the same length, and their elements are numbers. The x sequence contains the points where the function has been sampled, and the y sequence contains the function value at the corresponding point. (without using import statement).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":388,"Q_Id":61554543,"Users Score":0,"Answer":"As I understand your question, you want to write some function y = interpolate(x_values, y_values, x), which will give you the y value at some x? The basic idea then follows these steps:\n\nFind the indices of the values in x_values which define an interval containing x. For instance, for x=3 with your example lists, the containing interval would be [x1,x2]=[2.5,3.4], and the indices would be i1=1, i2=2 \nCalculate the slope on this interval by (y_values[i2]-y_values[i1])\/(x_values[i2]-x_values[i1]) (ie dy\/dx).\nThe value at x is now the value at x1 plus the slope multiplied by the distance from x1.\n\nYou will additionally need to decide what happens if x is outside the interval of x_values, either it's an error, or you could interpolate \"backwards\", assuming the slope is the same as the first\/last interval.\nDid this help, or did you need more specific advice?","Q_Score":1,"Tags":"python","A_Id":61554695,"CreationDate":"2020-05-02T04:38:00.000","Title":"How to implement linear interpolation in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way we can find what kind of encoding is used in bytes string with codecs in python. There is a method in chardet chardet.detect(string)['encoding'] Is there any method similar to this in codecs python","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":61556170,"Users Score":0,"Answer":"There isn't a built-in method, because it wouldn't be possible to reliably determine this for arbitrary values and arbitrary encodings. (For example, any text containing only ASCII characters is valid in most other encodings.)\nThe best you could do is a series of try-catch blocks where you guess a series of encodings (eg UTF8, UTF16) and go to the next if there is an invalid character.","Q_Score":0,"Tags":"python,codec","A_Id":61556375,"CreationDate":"2020-05-02T08:00:00.000","Title":"Codec find bytes string 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 have around 10 websites I need to scrape some data off from. I'm using Scrapy, and I need to know if I have to make 10 separate projects (one for each website) or 10 spiders in a single project?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":61556851,"Users Score":0,"Answer":"In theory both is possible, you can have multiple spiders in one project or set up multiple projects. However with 10 websites chances are quite high that you need distinct pipelines, middleware-settings and so on. For that reason I would generally suggest using multiple projects. Also your items.py might grow very large with multiple spiders and so you might loose track.","Q_Score":2,"Tags":"python-3.x,scrapy","A_Id":61563582,"CreationDate":"2020-05-02T09:02:00.000","Title":"Is there a way to have more than 2 spiders crawling different websites in one project using Scrapy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have around 10 websites I need to scrape some data off from. I'm using Scrapy, and I need to know if I have to make 10 separate projects (one for each website) or 10 spiders in a single project?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":61556851,"Users Score":0,"Answer":"If you can share any code between spiders (item base class, middleware, etc.), I would go for a single project.\nIf you have spider-specific items, pipelines or middleware, you can always define those on the spider Python files themselves.","Q_Score":2,"Tags":"python-3.x,scrapy","A_Id":61632248,"CreationDate":"2020-05-02T09:02:00.000","Title":"Is there a way to have more than 2 spiders crawling different websites in one project using Scrapy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My requirement is to call tutorial popup in Odoo10 website moudule to be appear on dashboard module once user login","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":61557180,"Users Score":0,"Answer":"Please check with auth_signup module of odoo it will redirect after login.\nCheck the template and modified it.","Q_Score":0,"Tags":"javascript,python,odoo,odoo-10","A_Id":62232007,"CreationDate":"2020-05-02T09:32:00.000","Title":"How to show Odoo tutorial pop up when user loggins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I spend each month a lot of time extracting numbers from an application into an Excel-spreadsheet where our company saves numbers, prices, etc. This application is not open-source or so, so unfortunately, sharing the link might not help.\nNow, I was wondering whether I could write a Python program that would do this for me instead? But I'm not sure how to do this, particularly the part with extracting the numbers. Once this is done, transfering this to an Excel spreadsheet is particularly trivial.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":61559710,"Users Score":0,"Answer":"1)For this you can create a general function like getApplicationError(),\n2)in this method you can get the text of the Application Error(create xpath of the application error, and check that if that element is visible than get text) and throw an exception to terminate the Script and you can send that got message into Exception constructor and print that message with Exception.\nAs you are creating this method for general use so you need to call this method every posible place from where the chances are to get Application Error. like just after click(Create,Save,Submit,Delet,Edit, also just entering value in mendatory Fields)","Q_Score":0,"Tags":"python,text,extract","A_Id":61560410,"CreationDate":"2020-05-02T12:55:00.000","Title":"Python: Extracting Text from Applications?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created model dogs and cats classifier using CNN using tensorflow.Its accuracy is around 90% and validation accuracy is 80%.But when I input my own downloaded images of cats and dogs it gives wrong results.I make sure that the input images are of the same size as that when used in training.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":61560918,"Users Score":0,"Answer":"I had same problems when I started some tutorial. Please check that you have the same color channels (like RGB). In my case the training and validation set had other color channels than the images I downloaded.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,classification,conv-neural-network","A_Id":61563183,"CreationDate":"2020-05-02T14:25:00.000","Title":"Created model in CNN doesnt give the expected result","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to do the following, but I'm getting errors on my ExecuteStreamCommand:\nCannot run program \"C:\\Python36\\pythonscript.py\" error=193 not a valid Win32 application\"\nThis is being run on my home Windows work station.\n\nGetFile (Get my PDF)\nExecuteStreamCommand (Call Python script to parse PDF with Tika, and create JSON file)\nPutFile (Output file contains JSON that I will use later)\n\nDoes NiFi have a built in PDF parser? Is there something more NiFi compatible that Tika?\nIf not, how do I call one from ExecuteStreamCommand?\nRegards and thanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":171,"Q_Id":61561123,"Users Score":0,"Answer":"Cannot run program \"C:\\Python36\\pythonscript.py\" error=193 not a valid Win32 application\"\n\nYou need to add a reference to your Python executable to the command to run with ExecuteStreamCommand as you cannot run Python scripts on Windows with the shebang (#!\/usr\/bin\/python for example on Linux).","Q_Score":0,"Tags":"python,apache-nifi,apache-tika,tika-server","A_Id":64930368,"CreationDate":"2020-05-02T14:39:00.000","Title":"NiFi Parse PDF using Python Tika error: ExecuteStreamCommand","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"say you have a dataset of relatively similar images and for each image, the first half of the image is the input and the second half would be the output of the model. In other word you want to teach the model the first half of a single image, and have it generate the second half. which framework would best suit this issue?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":61561316,"Users Score":2,"Answer":"You can read about Generative Adversarial Networks (GANs). Then use either PyTorch \n or Tensorflow on Python, though PyTorch is pretty famous for GANs.","Q_Score":0,"Tags":"python,tensorflow,deep-learning","A_Id":61561395,"CreationDate":"2020-05-02T14:51:00.000","Title":"which deep learning framework to use for generating predictive images","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi everyone i want to create a new telegram bot similar to @usinifobot.\nthis is how it works:\nyou just send someone username to this bot and it will give you back his\/her chat id.\ni want to do same thing but i dont khow how to do it with python-telegram-bot.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":943,"Q_Id":61562744,"Users Score":0,"Answer":"python-telegram-bot can't help with this, because telegram bot api can't provide ids of unrelated entities to the bot - only ones with which bot iteracts\nyou need telegram client api for this and to hold a real account (not a bot) online to make checks by another library\nand with bot library like python-telegram-bot you could only get ids of users who write to bot, channels and groups bot is in and reposted messages from other users\nI created similar bot @username_to_id_bot for getting ids of any entity and faced all these moments","Q_Score":0,"Tags":"python,bots,telegram,telegram-bot","A_Id":61562993,"CreationDate":"2020-05-02T16:30:00.000","Title":"How can i get someone telegram chat id 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 have an app that includes some images, however when I package for my android phone the images are blank. Right now in my kv file, the images are being loaded from my D drive, so how would I get them to load on my phone?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":162,"Q_Id":61562892,"Users Score":0,"Answer":"Include the images during the packaging and then load them using a file path relative to your main.py.","Q_Score":0,"Tags":"python,python-3.x,image,package,kivy","A_Id":61563690,"CreationDate":"2020-05-02T16:39:00.000","Title":"Image not loading on mobile device","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm fairly new to python and I'm beginning to work with python virtual environments. When I create a virtual environment, I have to reinstall all the modules that I need for the current project that I'm working on. \nI'm wondering if the virtual environment somehow avoids redundancies in installation of modules if the same version of the module had already been installed in another project or on a system-wide level?\nAlso, would there be any point in installing modules on a system-wide level rather than just in virtual environments, since I would need to install the modules in the virtual environment anyway?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1337,"Q_Id":61564609,"Users Score":0,"Answer":"Virtual environments segregate modules for an application. This means that upgrading modules in one application does not impact another application. Since modules occasionally have breaking changes, this can be important. \nAre you using the requirements.txt file to help manage the dependencies? It makes installing them easier when you need to reset a virtual environment.","Q_Score":11,"Tags":"python","A_Id":61564710,"CreationDate":"2020-05-02T18:44:00.000","Title":"Does a python virtual environment avoid redundant installs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm fairly new to python and I'm beginning to work with python virtual environments. When I create a virtual environment, I have to reinstall all the modules that I need for the current project that I'm working on. \nI'm wondering if the virtual environment somehow avoids redundancies in installation of modules if the same version of the module had already been installed in another project or on a system-wide level?\nAlso, would there be any point in installing modules on a system-wide level rather than just in virtual environments, since I would need to install the modules in the virtual environment anyway?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1337,"Q_Id":61564609,"Users Score":0,"Answer":"No it does not but that is the main point of having virtual environments because libraries depend on another and thus upgrading or modifying a library in one environment does not affect other environments.","Q_Score":11,"Tags":"python","A_Id":61564764,"CreationDate":"2020-05-02T18:44:00.000","Title":"Does a python virtual environment avoid redundant installs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to see the vectors I got per paragraphs and not per each word in the vocabulary with doc2vec. By using model.wv.vectors I get all the vectors per words. Now, I would need this in order to apply a clusterization algorithm on the embedded paragraphs which I can hopefully obtain. I am not sure though if this approach is good. This is how the paragraphs look:\n[TaggedDocument(words=['this', 'is', 'the', 'effect', 'of', 'those', 'states', 'that', 'went', 'into', 'lockdown', 'much', 'later', 'they', 'are', 'just', 'starting', 'to', 'see', 'the', 'large', 'increase', 'now', 'they', 'have', 'to', 'ride', 'it', 'out', 'and', 'hope', 'for', 'the', 'best'], tags=[0])\nTaggedDocument(words=['so', 'see', 'the', 'headline', 'is', 'died', 'not', 'revised', 'predictions', 'show', 'more', 'hopeful', 'situation', 'or', 'new', 'york', 'reaching', 'apex', 'long', 'before', 'experts', 'predicted', 'or', 'any', 'such', 'thing', 'got', 'to', 'keep', 'the', 'panic', 'train', 'rolling', 'see'], tags=[1])]","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":19,"Q_Id":61565514,"Users Score":0,"Answer":"model.docvecs.vectors will contain all the trained-up document vectors.","Q_Score":0,"Tags":"python,doc2vec","A_Id":61565956,"CreationDate":"2020-05-02T20:00:00.000","Title":"Is there a way in which I can get the equivalent list of vectors per paragraph in doc2vec?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am starting to learn about the hash table data structure in C, and I've noticed (if I understand the concept correctly) that hash tables are awfully similar to python dictionaries. If I am incorrect and they are two completely different things, could someone explain to me what a hash table is without getting too technical? Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":855,"Q_Id":61566044,"Users Score":2,"Answer":"There is not really any difference between them. That's why python's dicts don't support duplicates. That is also why python has the function hash which python's dictionaries use by default.","Q_Score":5,"Tags":"python,c,dictionary,hashtable","A_Id":61566104,"CreationDate":"2020-05-02T20:43:00.000","Title":"What's the difference between a hash table and a Python dictionary?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using elastic beanstalk and apscheduler to run Pandas reports everyday automatically on it. The data set is getting larger and i've already increased the memory size 3x. \nElastic Beanstalk is running Dash - dashboard application and runs the automated Pandas reports once every night. \nI've tried setting up AWS Lambda to run Pandas reports on there but I couldn't figure out how to use it. \nI'm looking for the most cost-effective way to run my reports without having to increase memory usage on Beanstalk. When I run it locally it takes 1gb but running it on beanstalk, it's using more than 16gb. \nCurious if someone else has a better option or process how they automatically run their Pandas reports.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":61566053,"Users Score":0,"Answer":"Create an .exe using Pyinstaller\nSchedule .exe on Task Scheduler on computer\nCheaper than scaling AWS Beanstalk resources which use more resources calculating pandas than your computer locally at least for my case.","Q_Score":0,"Tags":"python,pandas,amazon-web-services,amazon-elastic-beanstalk","A_Id":63367773,"CreationDate":"2020-05-02T20:44:00.000","Title":"What options are there to setup automatic reporting processes for Pandas on AWS?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"On my Pi (with the lite text only Linux on it) a Python-Program is started through rc.local! When I log in the (headless) Pi then I do not see the output of the program (simple print-commands). I can see that Python3 is running when I use \"pa -S\" and \"top\", but I cannot switch to the output from the program.\nHow can I make the output visible in the terminal-window like it is when I start the program straight from the command line? \nThanks and cheers, \nUlrich","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":61566441,"Users Score":0,"Answer":"You can not do that, you must write the output into a file with redirection.\nIn the rc.local, you can write: your_program  >> logfile_name  2>&1\nBut the logfile must be sometimes deleted.\nSearch for [linux] redirection!","Q_Score":0,"Tags":"python,terminal,process,visible","A_Id":61566935,"CreationDate":"2020-05-02T21:19:00.000","Title":"How to watch an automatically startet python script on raspberry \/ raspian?","Data Science and Machine Learning":0,"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":"A python script I write generates IDs that I need to add to a list, while another script checks, if the ID already exists in the list. There are no other tables, relations or anything, just a huge, growing list of 6-letter strings. I need to add and read values as fast as possible at the same time. What would be the database of choice in that case? A NoSQL database like redis?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":61567858,"Users Score":0,"Answer":"Yes, MongoDB or Redis, can do the work","Q_Score":0,"Tags":"python,database,redis,nosql","A_Id":61567870,"CreationDate":"2020-05-02T23:51:00.000","Title":"Which database for a huge list of one type of data?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I updated my python from python2.7 to python3.7 and My robot framework is also 3. I am getting error while list comparison. I also tried  \nLists Should Be Equal   ${a}    ${b}    ignore_order=True \nbut I am getting below issue - \nLists are different:\nIndex 0: max != min\nIndex 1: min != max","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":667,"Q_Id":61568302,"Users Score":0,"Answer":"So i was digging it and i found that the test was comparing dictionaries. So if i m testing it with python3 then i have to give Dictionaries should be equal, but with python2 it also works with Lists should be equal","Q_Score":1,"Tags":"robotframework,python-3.7","A_Id":61597001,"CreationDate":"2020-05-03T00:52:00.000","Title":"Lists Should Be Equal in robot framework is not working with python3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently bombed a coding interview because I wasn't able to generate all possible sublists of a list fast enough. More specifically: (using python)\n\nWe're given a list of string numbers [\"1\", \"3\", \"2\", ...]\nHow many sublists of this list of size 6, concateanted, are dividable by 16?\nNote that though the elements in the original list may not be unique, you should treat them as unique when constructing your sublists. E.g. for [1, 1, 1] a sublist of the first two 1's and the last two 1's are different sublists.\n\nUsing itertools.combinations I was able to generate all my sublists fast enough, but then looping through all those sublists to determine which one's were \"dividable\" by 16 was too slow. \nSo is there a way to create the sublists at the same speed (or faster) than itertools.combations, checking while each sublist as I'm creating it to see if they're divisable by 16?\nAny insight would be very appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":157,"Q_Id":61568605,"Users Score":0,"Answer":"Sort the list.\nfind the smallest list (by length)having sum at least 16 and divisible by it(say s).\nthen check all size list from s to 6.\nThat should reduce the number of size exponentially since bigger the length of sublist the lesser the number of sublists","Q_Score":0,"Tags":"python,optimization,combinations","A_Id":61568675,"CreationDate":"2020-05-03T01:43:00.000","Title":"Fast way of getting all sublists of a list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"pi@Clone:~$ lsb_release -a\nNo LSB modules are available.\nDistributor ID: Raspbian\nDescription:    Raspbian GNU\/Linux 9.4 (stretch)\nRelease:        9.4\nCodename:       stretch\nI had Python 2.7.13 and was trying this bit of code. Then after much searching there were some discussions about this version of Python, and those pre 3.5, did not support f functions so I upgraded and am now using Python3.7. Rather than getting the f something error, now it says \nModuleNotFoundError: No module named 'netmiko'\nI even tried this from the >>> prompt: typing import netmiko, but get the same annoying ModuleNotFound error.\n'''\npi@Clone:~$ python3.7\nPython 3.7.4 (default, May  2 2020, 09:56:22) \n[GCC 6.3.0 20170516] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\n\n\nimport netmiko\n      Traceback (most recent call last):\n        File \"\", line 1, in \n      ModuleNotFoundError: No module named 'netmiko'\n\n\n\nTried the below from the cli prompt using python3.7 finename.py\nBut it never got past the fist command: from netmiko import ConnectHandler. I get the same old error:\nModuleNotFoundError: No module named 'netmiko'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":281,"Q_Id":61568915,"Users Score":0,"Answer":"i'm not an expert in python, i've faced the same issue doing my network automation stuff \nand i solved concluding that every instance of python3.x needs its own modules so you need to reinstall netmiko for the new python3.x you got there !!\nand you may need to install setuptools and ez_install  for pip and python before installing netmiko.\nI hope some expert see this and try to explain in more details for you.","Q_Score":0,"Tags":"python","A_Id":61850117,"CreationDate":"2020-05-03T02:30:00.000","Title":"I'm not able to launch use paramiko or netmiko in my Debian Pi 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have a question just for a general case. So i am working with the poker-hand-dataset, which has 10 possible outputs from 0-9, each number gives a poker-hand, for example royal flush.\nSo i read in the internet, that it is necessary to use OHE in a multiclass problem because if not there would be like a artificial order, for example if you work with cities. But in my case with the poker hands there is a order from one pair over flush and straight to royal flush, right?\nEven though my nn performs better with OHE, but it works also (but bad) without.\nSo why does it work better with the OHE? I did a Dense Network with 2 hidden layer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":61572297,"Users Score":1,"Answer":"Short answer - depending on the use of the feature in the classification and according to the implementation of the classifier you use, you decide if to use OHE or not. If the feature is a category, such that the rank has no meaning (for example, the suit of the card 1=clubs, 2=hearts...) then you should use OHE (for frameworks that require categorical distinction), because ranking it has no meaning. If the feature has a ranking meaning, with regards to the classification, then keep it as-is (for example, the probability of getting a certain winnig hand).\nAs you did not specify to what task you are using the NN nor the loss function and a lot of other things - I can only assume that when you say \"...my nn performs better with OHE\" you want to classify a combination to a class of poker hands and in this scenario the data just presents for the learner the classes to distinguish between them (as a category not as a rank). You can add a feature of the probability and\/or strength of the hand etc. which will be a ranking feature - as for the resulted classifier, that's a whole other topic if adding it will improve or not (meaning the number of features to classification performance).\nHope I understood you correctly.\nNote - this is a big question and there is a lot of hand waving, but this is the scope.","Q_Score":0,"Tags":"python,neural-network,one-hot-encoding","A_Id":61572776,"CreationDate":"2020-05-03T09:32:00.000","Title":"Why performs the NN better with OneHotEncoding?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is django 3 backward compatible with django 2? Are there any syntax changes in django 3 compared to django 2? Will i be able to follow django 2 tutorial on YouTube and be okay to apply it in django 3 as there are not many django 3 tutorials available?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":17561,"Q_Id":61572949,"Users Score":6,"Answer":"Django 3 is just an evolutionary step from Django 2.\nIt is not like Python 3 and Python 2.\nSome amount of work may be required to port from Django 2 to 3 but much less than needed to port from Python 2 to 3.","Q_Score":11,"Tags":"django,python-3.x","A_Id":61573270,"CreationDate":"2020-05-03T10:28:00.000","Title":"Django 3 vs Django 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Suppose I run the GC-test:\ngrangercausalitytests(np.vstack((df['target'], df['feature'])).T, maxlag=5)\nI can pick the lag of the \"feature\" variable, which most likely Granger-causes the \"target\" variable. \n\nBut what number of lags does the \"target\" variable have in this model? \nFurther, how do I estimate this ADL model (some autoregressive lags + some lags of the independent variable)? I've seen somewhere, that ADL should be substituted with OLS\/FGLS in Python, since there is no package for ADL. Yet I do not understand how to do that","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":61573582,"Users Score":0,"Answer":"I found out that the model, corresponding to each particular number\nof lags in the GC-test has already been fit and is contained in the\ntest return. The output looks messy, but it's there.  \nUnfortunately,\nthere seems to be no capacity to estimate ADL models in Python yet\n:(","Q_Score":0,"Tags":"python,statistics,statsmodels","A_Id":61598835,"CreationDate":"2020-05-03T11:20:00.000","Title":"How to estimate the optimal model, following from the granger causality test?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Problem statement\nI doing 3D reconstruction using Logitech webcam with fixed lens before. Every time I change distance between scene and camera I need to manually adjust lens focus by hand. (Open the cover and turn lens knob) which very inconvenience. So I decide to by new webcam with auto focus feature (Logitech C922) and gonna use it in project. than I notice then when focus change, The image change a bit not only blur and  sharpness and also scaling.\n    I've read the article about camera calibration, it said I must fixed focus length when calibrating and and use same focus length while running application. which means I need to re-calibrate every time I use camera in new environment (distance changed cause focus length to change).\nThe question\n\nThe focus length only move the lens form image sensor, is it possible to find relation of camera focus value to camera matrix (intrinsic and extrinsic) and how?\nHow to use camera in vary distant without re-calibration?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":417,"Q_Id":61575873,"Users Score":1,"Answer":"With a cheap webcam? No.\nGet yourself a better lens with longer depth-of-field and\/or an iris that can be closed\n\nEdited\nBy \"cheap webcam\" above I mean any autofocus camera\/lens combination without (a) highly repeatable focusing geartrain and (b) programmatic access to the lens focus control setting. Point (a) is - of course - required for any form of calibration. Point (b) allows one to build a table of calibration parameters keyed on the focus setting.  I have seen this done in some applications where dynamical focusing was an unavoidable requirement, but the necessary gear tends to be very expensive and fragile.","Q_Score":0,"Tags":"python,opencv,autofocus","A_Id":61583268,"CreationDate":"2020-05-03T14:12:00.000","Title":"How to use auto focus along side with 3d reconstruction using python opencv","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to develop a IoT application using Python that runs on ships and sends data occasionally when a network connection is available. This is the case in about 10% of the time.\nIs there any pattern \/ implementation available who handles exactly this use case? I already read about MQTT and RabbitMQ\/AMQP but the implementations expect that the client reaches the broker at the time of sending the message. What I need is some type of local persistance that builds up a local queue and sends the messages when a connection is detected. \nI know that I could handle that for myself and us a SQLite DB but I think that this is no rare use case so I am sure there must be a solution for this and I just used the wrong search terms.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":61576742,"Users Score":0,"Answer":"The pattern you're looking for is already implemented in the standard PAHO MQTT Client, as part of the Quality Of Service (QOS) flow.\nAll you need to do, is to call the method 'publish' with the parameter 'qos' being equal to 2. The framework will take care of everything else for you, and automatically buffer the messages till a connection is available.\nThere are 2 points to notice however:\n- the buffer is an in-memory buffer, that is in a case of a power outage, all messages will be lost. If the messages cannot be lost in such a scenario, you have to implement persistent storage of messages into a local file \/ database.\n\nAs an in-memory buffer it is limited by the total available memory for your python code. So for very large number of messages or message size, possibly exceeding available memory, you would also have to implement persistent local storage.","Q_Score":0,"Tags":"python,rabbitmq,mqtt,iot","A_Id":61641332,"CreationDate":"2020-05-03T15:09:00.000","Title":"Pattern for handling message delivery in IoT applications when not online 24\/7","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":"Okay so I've been trying to show time in my website, and i was successful in it, but then after the time changes in real-time it does change in the site, we will have to reload the page and then time would b updated. Is there a way to update the time without reloading the page using django templates (html).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":61577101,"Users Score":1,"Answer":"You can use ajax.  Because ajax can reload specific portion of template without reload whole page.","Q_Score":0,"Tags":"python,html,django","A_Id":61577175,"CreationDate":"2020-05-03T15:35:00.000","Title":"Is there a way to dynamically edit value in django template?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I\u2019m creating a bot app in python using selenium, for people, but I would need to change the xpath code every week, how do I do this once I distribute the app to people?\nThanks In advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":61580812,"Users Score":0,"Answer":"I think the best approach is to locate selectors using Id rather than XPath since there won't be any change to Id selector once a new feature(adding a table\/div to the HTML)is added. Also, this reduces the rework effort to a large extend.","Q_Score":1,"Tags":"python,selenium,selenium-webdriver,pycharm","A_Id":61584978,"CreationDate":"2020-05-03T19:56:00.000","Title":"Updating code for my application every week","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In examples, I saw of socket programming projects (most of which were chat projects), they often saved all the clients in one array, and when a message was received from a client, in addition to saving it in the database, to all clients also was sent.\nThe question that comes to my mind is: How can this message received from the client  and saved in the database and send to clients when number of clients is very large? (I mean, the number of customers is so large that a single server can't meet their demand alone, and several servers are needed to connect sockets).\nIn this case, not all clients can be managed through the array. So how do you transfer a message that is now stored on another server (by another customer) to a customer on this server? (Speed \u200b\u200bis important).\nIs there a way to quickly become aware of database changes and provide them to the customer? (For example, Telegram.)\nI'm looking for a perspective, not a code.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":217,"Q_Id":61581434,"Users Score":0,"Answer":"You should use your database as your messaging center.  Have other servers watch for changes in the database either by subscription or by pulling on a time interval.  Obviously subscription would be fastest possible.  \nWhen a message is inserted, each server picks this up and sends to their list of clients.  This should be quite fast for broadcasting messages.","Q_Score":0,"Tags":"python,sockets,serversocket","A_Id":61584872,"CreationDate":"2020-05-03T20:50:00.000","Title":"How to managing a large number of clients in the socket programming","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When trying to import tensorflow I keep on getting this error. I have tried reinstalling tensorflow but I still revive this problem on this statement:\nimport tensorflow as tf\nDoes anyone have advice? Tensorflow worked on my system before I originally reinstalled it but now I have no luck. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":459,"Q_Id":61581658,"Users Score":0,"Answer":"I ended up deleting my python and re downloading it","Q_Score":0,"Tags":"python,tensorflow","A_Id":63651632,"CreationDate":"2020-05-03T21:09:00.000","Title":"module 'tensorflow.python.keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am confused about how to realize the data validation in event sourced micro-service architecture.  \nLet sum up some aspects that related to the micro-services.\n1. Micro-services must be low coupled.\n2. Micro-services better to be domain oriented  \nThen due to tons of materials in the internet and the books in DDD (Domain Driven Design)\nI create the next event sourced micro-service architecture.\nComponents\n1. API getaway to receive the REST calls from the clients and transform them into the commands.\n2 Command handler as a service. Receive the commands from API getaway make the validations. Save the events to the event store and publish events to the event bus.\n3. Event store is the storage for all events in the system. Allows us to recreate the state of the app. The main state of truth.\n4. Micro-services is small services responsible to handle the related to its domain event. Make some projections to the local private databases. Make some events too.\nAnd I have questions that I could not answer both by myself and the internet.\n1. What is actually aggregates. They are the class objects\/records in databases as I think or what?\n2. Who carry about aggregates. I found example that is some cases command handler use them. But in that way if aggregates stored in the private micro-services databases then we will have very high coupling between the command handler and the each of micro-services and it is wrong due to micro-service concept.  \nTo sum up.\nI am confused about how to implement aggregation in event source micro service architecture.\nFor example let focus on the user registration implementation in event source micro-service architecture.  \nWe have the user domain so the architecture will be next.\nAPI getaway\nCommand handler\nAuth micro-service\nUser micro-service \nPlease explain me the realization of command validation due to example above.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":317,"Q_Id":61583047,"Users Score":1,"Answer":"Command handler as a service\n\nI think this is the main source of your confusion.\nThe command handler isn't normally a service in itself.  It is a pattern.  It will normally be running in the same process as the \"microservice\" itself.\nIE: the command handler reads a message from so storage, and itself invokes the microservice logic that computes how to integrate the information in this message into its own view of the world.\n\nWhat is actually aggregates\n\n\"Aggregate\" is a lifecycle management pattern; an aggregate is a graph of one or more domain entities that together will establish and maintain some interesting invariant.  It's one of three patterns described in detail in the Domain Driven Design book written by Eric Evans.\nThe command handler plus your aggregate is, in a sense, your microservice.  The microservice will typically handle messages for several instances of a single aggregate - it will subscribe to all of the input messages for that kind of aggregate.  The \"handler\" part just reads the next message, loads the appropriate instance of the aggregate, then executes the domain logic (defined within the aggregate entities) and stores the results.","Q_Score":2,"Tags":"python,architecture,domain-driven-design,microservices,event-sourcing","A_Id":61585106,"CreationDate":"2020-05-03T23:39:00.000","Title":"Command payload validation in event sourced micro-service architecture","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am working on measuring the projected area of a cube facing the sun for my spacecraft coursework. The cube is of 1x1x1 dimensions, and constantly rotates due to its orbit. Using a program called \"STK\", data for the angle shift according to a reference was obtained. So now I have the shift of orientation of the cube every 30 minutes but now I need to calculate how much of the projected area will be exposed to the sun (I can assume the Sunlight is coming from a single direction).\nI need to be able to translate the coordinate shift in orientation of the cube to how much of a projected area will be facing the sun at each interval of time. Let me give you an example:\nAt the initial time, the cube is facing you (you are the sun...because you are my sunshine ;) ) and no shift has occurred, hence the projected area will be 1 m^2.\nAfter 30 mins, there has been a shift only on the x axis of 45 degrees. Now the projected area is 1.4142 m^2 (since cos 45 * 1 = 0.7071 and now you have 2 faces facing you).\nAfter 60 mins, only a shift in the y axis occurs (45 degrees). Now you have 3 partial faces of the cube facing you and possess a projected area of 1.707 m^2.\nThis isn't to hard to do with little shifts, but I need to do this for multiple (more than a 100 shifts). I am thinking of writing a python program that rotates a 3D object and measures the projected area at each interval. Any recommendations on libraries that allow 3D body definition and rotation? libraries that can measure areas of projected surfaces?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":389,"Q_Id":61583787,"Users Score":1,"Answer":"Establish a unit vector perpendicular to each face of the cube.  Depending on the output of your rotation program, you may be using angular rotations from the base axes or you can take vector cross product of 2 edges of face (be careful w\/ right hand rule to ensure result faces outward)\ntake the dot product of each of the resultant 6 vectors individually with a vector \"pointing to the sun\"\ndrop any negative results (facing away from sun)\nsum the remainder\n\nUnit vectors will suffice because the surface area of each face is 1 sq unit.","Q_Score":0,"Tags":"python,image-processing,vector","A_Id":61584119,"CreationDate":"2020-05-04T01:21:00.000","Title":"Projected Area calculation of a cube","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Basically, I recently started Python. I'm working on a project where I need audio to play. I searched up some libraries that can play audio and tried simpleaudio. I'm using Windows and sucessfull installed simpleaudio using: pip3 install simpleaudio.\nHowever, when I tried to use simpleaudio in my project with import simpleaudio as sa, it gives me this error: \nTraceback (most recent call last):\n  File \"d:\\coding\\python\\python projects\\random tests\\soundtest.py\", line 1, in \n    import simpleaudio as sa\nModuleNotFoundError: No module named 'simpleaudio'\nAny idea what is wrong?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2216,"Q_Id":61583989,"Users Score":0,"Answer":"It's possible you installed the library for python2 instead of python3. In ubuntu pip is python2 and pip3 is python3- I'm not sure if that's the case on windows or not.","Q_Score":1,"Tags":"python,simpleaudioengine","A_Id":61584322,"CreationDate":"2020-05-04T01:49:00.000","Title":"ModuleNotFoundError: No module named 'simpleaudio'","Data 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, I recently started Python. I'm working on a project where I need audio to play. I searched up some libraries that can play audio and tried simpleaudio. I'm using Windows and sucessfull installed simpleaudio using: pip3 install simpleaudio.\nHowever, when I tried to use simpleaudio in my project with import simpleaudio as sa, it gives me this error: \nTraceback (most recent call last):\n  File \"d:\\coding\\python\\python projects\\random tests\\soundtest.py\", line 1, in \n    import simpleaudio as sa\nModuleNotFoundError: No module named 'simpleaudio'\nAny idea what is wrong?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2216,"Q_Id":61583989,"Users Score":0,"Answer":"After I installed simpleaudio, import simpleaudio as sa worked with no errors.  I've run into similar errors before, and it was always because the version of pip I was using and the Python interpreter I was using didn't match.  You probably need to either switch to using the same interpreter as pip3 or install the package for whatever interpreter you're using","Q_Score":1,"Tags":"python,simpleaudioengine","A_Id":61584048,"CreationDate":"2020-05-04T01:49:00.000","Title":"ModuleNotFoundError: No module named 'simpleaudio'","Data 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 was creating a program to encrypt every file in a directory, and it worked, but I encrypted my working directory. I lost all my programs and the key itself. I used cryptography.fernet. Is there any way to get my files back?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":421,"Q_Id":61585325,"Users Score":2,"Answer":"No, it's not. Fernet (like any good encryption algorithm) is designed so there's no way to decrypt the data without the key.\nYour only hope (such as it is) would be that you'd generated the key poorly (e.g. not using Fernet.generate_key()).","Q_Score":1,"Tags":"python,encryption,cryptography,key","A_Id":61599671,"CreationDate":"2020-05-04T04:43:00.000","Title":"Can I decrypt the files that I made using cryptography.fernet without my key?","Data 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 response from sending request to the AWS. I have the secretkey\/AccessKey of AWS.\nWhat is the method\/syntax to access the aws APi, for example GetCredentialReport is an API of AWS, How to access this api?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":969,"Q_Id":61586015,"Users Score":1,"Answer":"You can use get_credential_report() API in boto3 for credential repot\nget_credential_report()\nRetrieves a credential report for the AWS account. For more information about the credential report, see Getting Credential Reports in the IAM User Guide .\nSee also: AWS API Documentation\nRequest Syntax\nresponse = client.get_credential_report()\nResponse Structure\n(dict) --\nContains the response to a successful GetCredentialReport request.\nContent (bytes) --\nContains the credential report. The report is Base64-encoded.\nReportFormat (string) --\nThe format (MIME type) of the credential report.\nGeneratedTime (datetime) --\nThe date and time when the credential report was created, in ISO 8601 date-time format.\nTry this code\nimport os\nimport boto3\nfrom dotenv import load_dotenv\nload_dotenv()\nAWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID')\nAWS_SECRET_ACCESS_KEY = os.getenv('AWS_SECRET_ACCESS_KEY')\nclient = boto3.client(\n    'iam',\n    aws_access_key_id=AWS_ACCESS_KEY_ID,\n    aws_secret_access_key=AWS_SECRET_ACCESS_KEY\n)\nresponse = client.generate_credential_report()","Q_Score":1,"Tags":"python,amazon-web-services,amazon-iam,rest","A_Id":61586228,"CreationDate":"2020-05-04T06:00:00.000","Title":"How to get response and access the AWS Api 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 Python 3. I am trying to remove certain lists from a list of lists. I found an excellent article that explained how to do that using list comprehension. It appears to work as expected, but it got me thinking ... In my original efforts I was appending any list object that was to be deleted to a new list. I could then actually look at these objects and assure myself the right ones were being removed. With the comprehension method I can only \"see\" the ones that remain. Is there a way of \"seeing\" what's \"failed\" the list comprehension condition? It would be reassuring to know that only the correct objects gave been removed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":61586851,"Users Score":0,"Answer":"I actually managed to answer my own question by making a mistake. To see what will be removed from a list by the list comprehension, simply temporarily invert the condition logic. This will allow you to look at all the elements that will be removed. If you're happy that the removals are as you expect, then simply re-invert the logic again, back to original and execute.","Q_Score":0,"Tags":"python,list,validation,list-comprehension","A_Id":61629663,"CreationDate":"2020-05-04T07:09:00.000","Title":"List Comprehension to remove unwanted objects. Validating it works as expected","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to this, so apologize if the step is easy.\nI have a Device which I am programming, which uses a raspberry pi (Debian). I have connected via SSH using PuTTY.\nI wish to create a virtual environment, and test a program on the device to search the WiFi network SSIDs and pick them up. I found that a great package to use is wpa_supplicant.\nHowever, here is the problem:\nThe device currently has Python 2.7.9 on it. When ever I create a virtual environment using python3, it creates a venv with python 3.4. Unfortunately, wpa_supplicantm requires python 3.5 or higher to work.\nWhen I run sudo apt-get install python3-venv, I can see in the prompt that it automatically starts installing packages for python3.4. \nDoes anyone know how I can specify that I wish to install python 3.5 or 3.7?\nAny help would be greatly appreciated.\nRegards\nScott","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":218,"Q_Id":61587277,"Users Score":0,"Answer":"Does it not have the python3.7 command?\nI just checked a venv I have running on a 3b+ and it seems to have it.","Q_Score":0,"Tags":"python,python-3.x,raspberry-pi,debian,wpa-supplicant","A_Id":61587349,"CreationDate":"2020-05-04T07:38:00.000","Title":"Installing python 3.5 or higher in a virtual environment on a 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 installed Python 3.8.2 in my Windows 10 laptop\nWhen I run the command 'python' in the command prompt, it gives me a blank response and goes back to the command prompt.\nHowever when I run the command 'py -3' in the command prompt, python is launched.\nWhat can be the reason for this. Is there anyway I can launch python using the 'python' command in cmd?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":61587421,"Users Score":0,"Answer":"why does it need to be python? py is basically the same thing. Looks like you didn't check ambient variable in python installation. Just add python folder in PATH ambient variable  and you're ready to go","Q_Score":0,"Tags":"python","A_Id":61589148,"CreationDate":"2020-05-04T07:48:00.000","Title":"Not able to run python from command prompt using 'python' command; it only takes 'py -3'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have created some code for sending alerts, for now only by emails. I was wondering if there is an easy way to send push notifications to iOS and Android mobiles using Python. Thanks a lot.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5163,"Q_Id":61587817,"Users Score":0,"Answer":"Without getting device tokens from the devices (iOS \/ Android), and without a valid APNS certificate for the iOS app, there is no way to send push notification to any app.\nFor iOS, device token and certificate is must.\nFor Android, a Firebase project has to be setup, and the device token has to be fetched from the app.\nIf you are the owner of the backend that the mobile apps are using, it is easy to send device tokens from the apps provided you have access to the Firebase project (for Android) and the certificate used (for iOS).","Q_Score":3,"Tags":"python-3.x,push-notification","A_Id":61588623,"CreationDate":"2020-05-04T08:14:00.000","Title":"How to send notifications to iOS and Android 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":"How can I have a string like \"'1'\"? I have tried:\n\na = str(str(1))\n\nbut result still is '1'.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":79,"Q_Id":61589550,"Users Score":1,"Answer":"You can add those characters to your string using placeholders, doing so:\na = '\"%s\"'% a","Q_Score":1,"Tags":"python","A_Id":61589652,"CreationDate":"2020-05-04T09:58:00.000","Title":"Having a string with two quotes around it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am on 4th chapter the book Django 3 by example and I noticed one thing that we are only creating views from Django's authentication framework but we are not telling those views which template to render when.\nFor example, how does my application would know that it needs to only render the logged_out.html template when we try to access the logout view? If I try to change the name of the file from logged_out.html to loggedout.html then it takes me to the Django's admin logout page.\nWhy?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":61591257,"Users Score":0,"Answer":"In django views, for each view we write at the end\nreturn render(request, 'your template location')\nThat is how django knows which template to render for which view.","Q_Score":1,"Tags":"django,python-3.x,django-views","A_Id":61591785,"CreationDate":"2020-05-04T11:32:00.000","Title":"How does Django knows which template to render when?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I new to python but how do I import the sqlite3.dll file from a custom file location as I can't find anything about it. I can accept any option including building a new pyd,dll,etc file.\nEdit:\nI need it to be in a separate location.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":236,"Q_Id":61592052,"Users Score":0,"Answer":"Note: The following answers the above question with more thorough steps.\nI had the same issue as administrative rights to the default python library is blocked in a corporate environment and its extremely troublesome to perform installations.\nWhat works for me:\n\nDuplicate the sqlite3 library in a new location\nPut in the latest sqlite3.dll (version you want from sqlite3 web) and the old _sqlite3.pyd into the new location or the new sqlite3 library. The old _sqlite3.pyd can be found in the default python library lib\/DLLs folder.\nGo to the new sqlite3 library and amend the dbapi2.py as follows: Change \"from _sqlite3 import *\" to \"from sqlite3._sqlite3 import *\"\nMake sure python loads this new sqlite3 library first. Add the path to this library if you must.","Q_Score":1,"Tags":"python,c,python-3.x,sqlite","A_Id":68524888,"CreationDate":"2020-05-04T12:17:00.000","Title":"import sqlite3.dll from from another file location python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u00b4m new to Python and I\u00b4m having a problem. I have 2 lists containing the names of the columns of a dataset: one has all the columns names (columnas = total.columns.values.tolist()); and the other one has a subset of them ( in the form of \"c = [a,b,c,d,c,e,...]\".\nI would like to know how could I check if each element in \"c\" is contained in the longer list \"columnas\". The result i have been trying to get is as it follows ( this is just an example):\na: True \nb: True\nc: False\n...\nLooking forward to your answers, Santiago","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":45,"Q_Id":61593044,"Users Score":1,"Answer":"a=[ ]\nfor i in c:\n  if i in columns:\n     a.append(true)\n  else:\n     a.append(false)\na=[ ]\nfor i in c:\n  if i in columns:\n     a.append(true)\n  else:\n     a.append(false)","Q_Score":1,"Tags":"python,string,list,contains,exists","A_Id":61593126,"CreationDate":"2020-05-04T13:11:00.000","Title":"How do i check if the elements in a list are contained in other list?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For initializing arrays in python we need type code for that .I need to store strings in that array.So what type code i should use ? \nimport array\narray.array(typecode,['abc','fes','fsfs'])","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1211,"Q_Id":61593059,"Users Score":0,"Answer":"for a shortcut, you used the one-line code\n\narray.array(str('u'), ['abc','fes','fsfs']\n\nthis code will help you out","Q_Score":1,"Tags":"arrays,python-3.x,data-structures","A_Id":67329836,"CreationDate":"2020-05-04T13:12:00.000","Title":"what is the type code for strings in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is the usage of escaped characters such as \\t allowed by PEP8 in something like print statements?\nIs there a more idiomatic way to left indent some of the printout without importing non standard libraries?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":81,"Q_Id":61593283,"Users Score":1,"Answer":"Yeah that's fine, it is a fundamental ASCII character - PEP would not deny its use as it may be fundamental to your end result (say an API needed tabs or something) - PEP is all about styling your source code, I wouldn't consider a character in a string to be something that can be decreed by a style guide (PEP8).","Q_Score":2,"Tags":"python,python-3.x,pep8","A_Id":61593337,"CreationDate":"2020-05-04T13:23:00.000","Title":"Does pep8 allow the usage of \\t in a print","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to identify the fittings of the transmission line first, and then the micro parts such as bolt and pin. I may have to train a model using tensorflow and will apply in UAV inspection. Any suggestions?(existed or related algorithm\/paper\/idea) Thanks!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":61593698,"Users Score":0,"Answer":"You can you instance segmentation. Annotate at pixel level the bolts and pins, you can then train Mask RCNN. Hope it helps?","Q_Score":0,"Tags":"python,tensorflow,deep-learning,computer-vision,object-detection","A_Id":61599248,"CreationDate":"2020-05-04T13:43:00.000","Title":"How to recognize a larger object and then some tiny ones in it in a picture?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"we have some COBOL Caller Handlers which are executed\/called by external applications built in VB\/Java. what we are looking is instead of going through other applications, is there way to call those caller handlers directly from Python so we can test them directly from Python automation framework","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":469,"Q_Id":61594290,"Users Score":1,"Answer":"I have a CICS program\/transaction bound to a web interface in CICS, so that i can drive my transaction via http post\/put\/get, maybe you are looking for a tighter bind though?","Q_Score":0,"Tags":"python,cobol,cics","A_Id":61598057,"CreationDate":"2020-05-04T14:13:00.000","Title":"what are my chances to call CICS Transactions or COBOL programs 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":"we have some COBOL Caller Handlers which are executed\/called by external applications built in VB\/Java. what we are looking is instead of going through other applications, is there way to call those caller handlers directly from Python so we can test them directly from Python automation framework","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":469,"Q_Id":61594290,"Users Score":0,"Answer":"For the Java APIs I would recommend, ditching python and wrting the tests in Groovy.\nThis is a scripting language that runs on a JVM, which means it can call all java APIs natively.\nAs well as support the normal builtin scripting stuff like dictionarys, currying functions, regex support -- all valid java code is also valid Groovy code. So you can cut and paste your java API calls into your testing scripts.","Q_Score":0,"Tags":"python,cobol,cics","A_Id":61608297,"CreationDate":"2020-05-04T14:13:00.000","Title":"what are my chances to call CICS Transactions or COBOL programs 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":"In Python3 I created a socket with s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) in order to send UDP to a certain destination in the network. Now the classical way would be to s.sendto(my_data, (ip, port)). But I would like to handle the socket as an io file object. Therefore I created one by f = s.makefile(mode='wb'). Now I can use f.write(my_data) to send data. But wait ... I never had to specify IP and port. Needless to say, the data does not arrive at the destination. With TCP there is no problem because with s.connect((ip, port)) I can specify ip and port before I create a file object.\nIs it possible, and if yes how, to send UDP with a socket as file object?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":208,"Q_Id":61594796,"Users Score":0,"Answer":"okey...as I was writing the question it occurred to me that I could try calling s.connect((ip, port)) on the UDP socket although there is no connection to establish. Voil\u00e0 it works. Maybe this helps somebody.","Q_Score":1,"Tags":"python-3.x,sockets,makefile,udp","A_Id":61645036,"CreationDate":"2020-05-04T14:38:00.000","Title":"Python3: Is a write to UDP socket as file object even possible?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I do li = [1,2,3], and then do a = li, a is assigned to li, right? However, when I do del li and then print a, it still shows [1,2,3]. When I do li.append(4) and print a then, why does it show [1,2,3,4]? \nI understand that a didn't make a copy of li (as the .copy() method is used for that), but why would a still show the value li used to have?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":45,"Q_Id":61595782,"Users Score":1,"Answer":"del does not delete the variable. del only deletes the name, and the garbage collector will (on its own time) search for variables that aren't referenced by anything, and properly deallocate their memory.\nIn this case, you're assigning the name a to reference the same variable that the name li is referencing. When you use .append(), it modifies the variable, and all names referencing the variable will be able to see the change. And when you do del li to remove the name li, it doesn't remove the name a, which is still referencing the variable. Thus, the variable doesn't get deallocated and removed.","Q_Score":2,"Tags":"python,variables","A_Id":61595870,"CreationDate":"2020-05-04T15:25:00.000","Title":"Why does deleting a variable assigned to another variable not influence the new variable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a biomedical image segmentation task. The data I got from the hospital has been split into training set, validation set, test set. But I'm confused about the splitting. \nThe data consists of images from different patients, each patient has 2 ~ 3 2D slices taken from the 3D image. For one patient, his or her 2 ~ 3 slices are adjacent or close to each other, which means that these slices have only very small differences that are barely visible to the naked eye. These 2~3 slices are split into training set, test set and validation set. So the proportion of training set, test set and validation set is close to 1:1:1. \nHowever, the splitting of medical image datasets I found is mostly based on patients. Three sets are slices of different patients, instead of distributing the slices of the same patient into three sets like the hospital's way. I'll give an example.\nExample\nLet i_j be the j-th slice of the i-th patient, and i_j & i_j+1 are adjacent slices. All slice numbers are as follows:\n\n1_1 1_2 1_3 \/ 2_1 2_2 2_3 \/ 3_1 3_2 3_3 \/ 4_1 4_2 \/ 5_1 5_2\n\nA possible splitting in the hospital's way:\n\nTrain: 1_1 2_1 3_1 4_1 5_1 Val: 1_2 2_2 3_2 4_2 Test: 1_3 2_3 3_3 5_2\n\nA possible splitting in my way:\n\nTrain: 1_1 1_2 1_3 2_1 2_2 2_3 4_1 4_2 Val: 3_1 3_2 3_3 Test: 5_1 5_2\n\nI think in the first way, the training set, validation set and test set are actually too similar. This will make the accuracy rate of the validation set and training set higher, but the generalization ability of the model will be worse. So which splitting method is correct? Or both are OK?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":459,"Q_Id":61596143,"Users Score":1,"Answer":"Your way is definitely the right way to go. The hospital's method will lead to massive overfitting for exactly the reasons you specified.","Q_Score":1,"Tags":"python,dataset,semantic-segmentation","A_Id":67388911,"CreationDate":"2020-05-04T15:44:00.000","Title":"Dataset spliting in semantic segmentation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The work I do requires some level of security so that only intended parties have access to the data that would be displayed in the dashboards\/maps. I just want to make sure Bokeh and Folium are secured choices. So are the HTML files containing the Bokeh dashboards and Folium maps self-contained?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":61598526,"Users Score":0,"Answer":"I assume you are speaking about standalone Bokeh content, e.g. created with output_file and show or embedded in web pages with components or json_items, and not speaking about Bokeh server applications. \nIn that case, all data for the Bokeh data sources, etc. resides purely in the HTML page that is loaded by the browser. Depending on how you configure BokehJS resources, the page may load the BokehJS runtime externally from the Bokeh CDN at cdn.bokeh.org. This is the default configuration. If you prefer, it is possible to create completely self-contained HTML that includes the BokehJS scripts directly in the page. One way to do that is to specify the environment variable BOKEH_RESOURCES=inline. \nIt should probably go without saying that whatever Python process of yours generates the Bokeh content also necessarily has access to the data, but securing that would be your responsibility. Also, of course, limiting the distribution or access to the resulting generated HTML is also your responsibility. \nFolium is a completely separate question that can't comment on. Presumably it will always need to call out to some remote service to load the map tiles, at least.","Q_Score":0,"Tags":"python,bokeh,folium,data-security","A_Id":61599558,"CreationDate":"2020-05-04T17:51:00.000","Title":"Are dashboards\/maps created with Python's Bokeh and Folium modules secured? Is the data uploaded to any external server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi I am going to start a pretty big project in python. I need to use virtual environment for my packages.\nWhere should I create it? \nIf my project is in D:\\my_project directory should I create env in the same directory?\nOr should it be on the same drive instance?\nOr it completely doesn't matter where I create that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":61598876,"Users Score":0,"Answer":"It doesn't really matter, the virtual environment is just somewhere to keep everything together and have all the parts of the program in one place for referencing purposes. You can move it about between drives and systems and it should still work. Whether you want to then put that virtual environment directory inside a parent folder that holds other stuff like unused assets, notes, your own personal work materials pertaining to the project is up to you, that's what I tend to do!","Q_Score":0,"Tags":"python,virtualenv,new-project","A_Id":61598994,"CreationDate":"2020-05-04T18:14:00.000","Title":"Creating virtual env","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a newbie and currently developing a Django website, I want to know whether I should implement REST framework now for each app or should I do it after completing the whole website? Which is the easiest or the most proffered way and is it easy to implement?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":61599060,"Users Score":0,"Answer":"This may get closed for being an opinion-oriented question, but I will try to answer regardless.\nYour best bet would be to fully develop and test the website first, and then implement the Rest Framework. Your database design, models and functionality will likely change drastically from what you expected, so it would cause many alterations if you were to develop the REST API alongside the initial development.","Q_Score":0,"Tags":"python,django,rest,api,django-rest-framework","A_Id":61599191,"CreationDate":"2020-05-04T18:25:00.000","Title":"Django REST Framework: Is it possible to implement after the complete development of a website?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am a newbie and currently developing a Django website, I want to know whether I should implement REST framework now for each app or should I do it after completing the whole website? Which is the easiest or the most proffered way and is it easy to implement?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":42,"Q_Id":61599060,"Users Score":1,"Answer":"This is going to depend on the project and the methodology you use. If you are going to need pages that hit the API, you will have to create at least some methods before finishing the website, but if you just want to provide an API to third-party applications or whatever, it is up to you when you want to do this.\nSometimes I think it would be better to complete an APP including the serializers and API views before starting another one, as you will have every fresher and it could take time more time to do it when you have finished the whole website, as you might not remember some of your implementations.","Q_Score":0,"Tags":"python,django,rest,api,django-rest-framework","A_Id":61599346,"CreationDate":"2020-05-04T18:25:00.000","Title":"Django REST Framework: Is it possible to implement after the complete development of a website?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have developed a NLTK based flask app. Now I have deployed it in Heorku. While deploying it I am getting an error: remote: \/app\/.heroku\/python\/lib\/python3.6\/runpy.py:125: RuntimeWarning: 'nltk.downloader' found in sys.modules after import of package 'nltk', but prior to execution of 'nltk.downloader'; this may result in unpredictable behaviour. And also some pages and functions are not working properly. Please suggest me something to solve this problem.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":815,"Q_Id":61599380,"Users Score":0,"Answer":"You need to follow the below steps.\n\nnltk.txt needs to present at the root folder\nAdd the modules you want to download like punkt, stopwords as separate row items\nChange the line ending from windows to UNIX.\n\nChanging the line ending is a very important step. Can be easily done through Sublime Text or Notepad++.\nIn Sublime Text, it can done from the View menu, then Line Endings.\nHope this helps","Q_Score":0,"Tags":"python,flask,heroku,nltk","A_Id":62639049,"CreationDate":"2020-05-04T18:44:00.000","Title":"'nltk.downloader' found in sys.modules after import of package 'nltk', but prior to execution of 'nltk.downloader';","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am quite confused by Tensorflow's reduce axis function. For example, reduce_max(). Suppose I have a four dimension variable a with a shape of a = [x, y, z, w] where x, y, z, and w are the length that dimension. I have a command like b = tf.reduce_max(a, axis=(1, 3)), in this case, what will be the shape of b? b = [x, z] or b=[y, w]? Basically, I am just wondering which axis is the reduce_max() operating on. If the axis is defined from 0, then b = [x, z]. Otherwise, b = [y, w].","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":275,"Q_Id":61599630,"Users Score":1,"Answer":"So you have a tensor a, with shape [x, y, z, w]. When using a function which expects the axis parameter, the axis numbering for a will be [0, 1, 2, 3]. Reducing axes 1 and 3 results in those axes \"disappearing\" (because you are reducing those axes), so the output will consist of original axes [0, 2] which means the resulting shape is [x, z].","Q_Score":0,"Tags":"python,numpy,tensorflow","A_Id":61599838,"CreationDate":"2020-05-04T18:59:00.000","Title":"tensorflow axis definition starts from 0 or 1?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having an issue with SciPy not importing properly in my DM script. The script will get stuck on the \"import scipy\" line. I installed scipy using miniconda, have tried reinstalling with no success. \nThank you","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":61602031,"Users Score":0,"Answer":"DM uses C:\\ProgramData\\Miniconda3\\envs\\GMS_VENV_PYTHON for Phyton environment, so you should install scipy there, I don't know how select that location to install, so I\n\ninstall Miniconda3 in a folder \"user\\Miniconda3\"\nRun AnacondaPromt(miniconda3) and install scipy by run \"conda install scipy\"\ncopy content of \"user\\Miniconda3\" folder to \"C:\\ProgramData\\Miniconda3\\envs\\GMS_VENV_PYTHON\"","Q_Score":0,"Tags":"python,scipy,dm-script","A_Id":64543507,"CreationDate":"2020-05-04T21:34:00.000","Title":"SciPy will not import while trying to run DM script","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having an issue with SciPy not importing properly in my DM script. The script will get stuck on the \"import scipy\" line. I installed scipy using miniconda, have tried reinstalling with no success. \nThank you","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":61602031,"Users Score":0,"Answer":"(Windows) I have found that on my system using pip as recommended (via pip install x) does not work for any package, however using conda as not recommended (via conda install) in the command prompt allowed me to install scipy for GMS.\nAlso make sure you start the command prompt in administrator mode.","Q_Score":0,"Tags":"python,scipy,dm-script","A_Id":62766482,"CreationDate":"2020-05-04T21:34:00.000","Title":"SciPy will not import while trying to run DM script","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Single file spider which crawls only a site. Which informations can the owner of the site can see? \nHere, I am not using custom settings. (So that's default setting).\nExample: \n1.Spider name\n2.IP\n3.OS","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":61602294,"Users Score":1,"Answer":"The site owner can see this info.\n\nSpider name. You can change the to anything you want\nIP address you can use a VPN or proxies to change it.\nBrowser you are using. To change this go to settings and go look for USER_AGENT\nremove the comment and you can easily go on google to search for other user-agents.\nCookies. Scrapy has cookies enables by default. Go to settings and look for COOKIES_ENABLED Remove the comment so it is set to False. This would make the scraping job more stealthy.\nConcurrent_Requests. This is so also in the settings. It is how many requests you make simultaneously. It is better to lower the number so it is more friendly to the website.","Q_Score":0,"Tags":"python,scrapy,web-crawler","A_Id":61603285,"CreationDate":"2020-05-04T21:54:00.000","Title":"Which information a site can get when scraped by a scrapy spider?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"List comprehension looks more pythonic to me. It is also faster than for loops.\nAre ALL for loops in python convertible into list comprehension?\nI am using python 3.7\nEDIT: It seems like it's a bad idea to use list comprehension when the for loop is long and complicated. It makes the code much less readable.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":61604229,"Users Score":1,"Answer":"Yes, sort of.\nYou can convert nested for loops to list comprehensions, and even use variable assignment with :=.\nIt is true that list comprehensions are slighly faster than for loops, but the difference is so negligible that it is not worth trying to cram a complicated loop into a list comprehension.","Q_Score":0,"Tags":"python,for-loop,list-comprehension","A_Id":61604246,"CreationDate":"2020-05-05T01:18:00.000","Title":"Can all for loops in python be converted into list comprehension equivalent?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using OneHotEncoding to generate dummies for a classification problem. When used on the training data, I get ~300 dummy columns, which is fine. However, when I input new data (which is fewer rows), the OneHotEncoding only generates ~250 dummies, which isn't surprising considering the smaller dataset, but then I can't use the new data with the model because the features don't align.\nIs there a way to retain the OneHotEncoding schema to use on new incoming data?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":61604255,"Users Score":1,"Answer":"I think you are using fit_transform on both training and test dataset, which is not the right approach because the encoding schema has to be consistent on both the dataset for the model to understand the information from the features. \nThe correct way is do \n\nfit_transform on training data\ntransform on test data\n\nBy doing this way, you will get consistent number of columns.","Q_Score":0,"Tags":"python,scikit-learn,one-hot-encoding","A_Id":61613724,"CreationDate":"2020-05-05T01:23:00.000","Title":"How to retain Scikit-learn OneHotEncoding from model generation to use on new data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My primary issue is to somehow localize the range of k-values to perform the elbow-analysis on. At present, I can only think of a range between 2 to min(num_rows, num_columns). Is there any other optimal method that might be more suitable, especially if you have a dataset that has an extremely large number of rows and columns?\nP.S., also, is there some way to automate it so that we do not have to look at the elbow-plot? At present, I'm using the KneeLocator function of the Kneed library but I wanted to consider more options. \nThank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":24,"Q_Id":61604365,"Users Score":1,"Answer":"As you might know, there is not always an \"elbow\". Even if there is one, that does not necessarily represent the best number of clusters.\nThe KneeLocator function of Kneed is probably your best bet, because it finds the K with maximum curvature.","Q_Score":0,"Tags":"python,cluster-analysis,k-means","A_Id":61604427,"CreationDate":"2020-05-05T01:39:00.000","Title":"Is there any study on what the optimal range will be k-values in the elbow method?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an 8 GB file with text lines (each line has a carriage return) in S3. This file is custom formatted and does NOT follow any common format like CSV, pipe, JSON ... \nI need to split that file into smaller files based on the number of lines, such that each file will contains 100,000 lines or less \n(assuming the last file can have the remainder of the lines and thus may have less than 100,000 lines).\n\nI need a method that is not based on the file size (i.e. bytes), but the number of lines. Files can't have a single line split across the two.\nI need to use Python.\nI need to use server-less AWS service like Lambda, Glue ... I can't spin up instances like EC2 or EMR.\n\nSo far I found a lot of posts showing how to split by byte size but not by number of lines. \nAlso, I do not want to read that file line by line as it will be just too slow an not efficient. \nCould someone show me a starter code or method that could accomplish splitting this 6 GB file that would \nrun fast and not require more than 10 GB of available memory (RAM), at any point?\nI am looking for all possible options, as long as the basic requirements above are met...\nBIG thank you!\nMichael","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":785,"Q_Id":61604448,"Users Score":1,"Answer":"boto3.S3.Client.get_object() method provides object of type StreamingBody as a response. \nStreamingBody.iter_lines() method documentation states:\n\nReturn an iterator to yield lines from the raw stream.\nThis is achieved by reading chunk of bytes (of size chunk_size) at a\n  time from the raw stream, and then yielding lines from there.\n\nThis might suit your use case. General idea is to get that huge file streaming and process its contents as they come. I cannot think of a way to do this without reading the file in some way.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda,aws-glue","A_Id":61608849,"CreationDate":"2020-05-05T01:52:00.000","Title":"Splitting a Large S3 File into Lines per File (not bytes per file)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on making a terminal in a pygame window. This is for an interpreter I'm working on. I've tried all the things where you run it to see the output with multiprocess, but is there a way to execute the line of code once and see the terminal output? Preferably while also executing the line of code (eg. a = 5 a can be referenced later).\n--edit--\nI'm trying to make a virtual terminal in the pygame window, and need to be able to see the terminal output of a python command.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":92,"Q_Id":61604838,"Users Score":0,"Answer":"Here are 2 ways that I think will help the most:\n1 Debug\nYou can try to use the debug function that most IDEs have to step over and execute one line at a time. So you would add a breakpoint at 'a' and then step over.\n2 Print\nYou can use the print statements and print your values as the code runs. So you would print(a)","Q_Score":0,"Tags":"python,python-3.x,pygame","A_Id":61605709,"CreationDate":"2020-05-05T02:42:00.000","Title":"Is there a way to see the output of a line of python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Planning to build an end to end IOT application. I know that we can do it using Django and Flask. Which one is a better choice and how it is better?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":433,"Q_Id":61604978,"Users Score":1,"Answer":"I was in your position 2 months ago. Let me save you some trouble. \nFlask may seem the more flexible or direct path as it is easy to have something up and running in moments. Whereas Django, at times, can feel like an entirely different language, and takes much more time and effort to get running. Still, the problem lies in getting everything to play nicely with flask and other packages. This will be tricky and Django shines in this area. Once the project is rolling, it just works, and generally continues to do so unless the packages utilized in your app become deprecated or you break it.\nBoth are viable but any project of scale will be better off being maintained by Django while you focus on implementation. Good luck.","Q_Score":0,"Tags":"python,django,flask","A_Id":62110417,"CreationDate":"2020-05-05T02:57:00.000","Title":"Django vs Flask - Which framework is more powerful considering I want to design an end to end IOT solution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am writing a program in Python to scan articles for topics that I am interested in. I want to filter out sentences related to the topic from many articles, then create a summary.\nI have been using regex but often missing the sentence if it is not using the keywords. Worse than that, I often only get the questions regarding my keywords, leaving out the answers that matter the most.\nFor example, if I am interested in \"Trump\" in the article below:\n\"..... What's your view on Trump's foreign policy? I don't think anyone can give a clear answer but I think he is likely to do whatever it takes to contain the public health issue first.\n.....\"\nBy using \"Trump\" as the keywords via Regex, I only get the question highlighted, not the answer in the following sentence.\nWhat techniques that I can use to select all relevant info? Open for natural language processing techniques, ideally available from open source packages can help me to do this? \nNeed not to be a perfect solution. Thank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":61605217,"Users Score":0,"Answer":"I'd start with the selenium package or requests\/urllib + beautifulsoup4.\nIf you're trying to compare multiple sites, you'll have to have a tailored parser for each site.\nIf you need help with a specific site, let me know.","Q_Score":0,"Tags":"python,regex,text,nlp","A_Id":61605398,"CreationDate":"2020-05-05T03:24:00.000","Title":"How to extract relevant information from article using Python? NLP+RegEX?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a string '1a1b1c1d3e3e3e1f1g2h2h1i1j1k1l1m1n4o4o4o4o1p1q2r2r1s2t2t2u2u1v1w1x1y1z'\nand I want to remove all of the duplicates of these charterers: 3e, 4o, 2r etc.\nHow can I do that in Python?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":61607809,"Users Score":0,"Answer":"You can use list comprehension and set to do this in the following way:\ns = '1a1b1c1d3e3e3e1f1g2h2h1i1j1k1l1m1n4o4o4o4o1p1q2r2r1s2t2t2u2u1v1w1x1y1z'\ns = [s[i:i+2] for i in range(0, len(s) - 1, 2)]\ns = set(s)\nHope it helps","Q_Score":0,"Tags":"python,string","A_Id":61608164,"CreationDate":"2020-05-05T07:20:00.000","Title":"Remove duplicates of set of characters in string - Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have big excel with lot of sheets and formulas interlinked within the sheets. I need to populate input in one sheet using the code and recalculate all the formulas to get my output from another sheet.\nI am able to do this with apache POI using Java but it is too slow in formula recalculation. Looking for libraries in Python to do the same.","AnswerCount":3,"Available Count":2,"Score":0.3215127375,"is_accepted":false,"ViewCount":12509,"Q_Id":61609377,"Users Score":5,"Answer":"The best ones as I worked with them are XlsxWriter and Xlwings.\nBoth of them are working smoothly and efficiently, and they have good compatibility between Python and Excel.\nXlwings has two versions, Free and Pro (paid version). Free version has the complete ability and can do almost anything you need to work with an Excel file. With the paid version, you can get more functionality and support, which developers (not regular users) do not need most of the time.\nOn the other hand, XlsxWriter is also an excellent choice, and its users' community is growing fast recently. It supports all you need to work with an excel file.\nBoth of them can be installed simply with pip and conda.\nThe other libraries, such as xlrd, xlwt are designed in the past for handling the old version (.xls) files. They are not comparable with the other two libraries that I mentioned.\nOpenPyXl also is a decent library that can handle most of your needs. The library needs more support to grow. In my opinion, it is not well mature yet.\nPandas and pyexcel libraries are also suitable for reading and writing data to an Excel file. I prefer Pandas because it is a mature and fast library that can handle big data. pyexcel is a wrapper API that is not capable as Pandas, and working with it is more complicated.\nPyXLL is a professional library that can handle almost everything a user wants in Excel with Python. One of the famous companies working on Python distributions, Enthought, is supporting the library. Unfortunately, there is no free or community version of it, and you can only choose a 30 days trial of the pro version. After that, you must pay at least $29 per month. It is powerful, but it is an expensive choice for a single developer.\nOf course, there are more Libraries, Wrapers and APIs for handling excel files, but I mentioned the most mature and popular libraries.","Q_Score":7,"Tags":"java,python,excel,apache-poi,openpyxl","A_Id":69057019,"CreationDate":"2020-05-05T08:56:00.000","Title":"What is the best library in python to deal with excel files?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have big excel with lot of sheets and formulas interlinked within the sheets. I need to populate input in one sheet using the code and recalculate all the formulas to get my output from another sheet.\nI am able to do this with apache POI using Java but it is too slow in formula recalculation. Looking for libraries in Python to do the same.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":12509,"Q_Id":61609377,"Users Score":1,"Answer":"I would like to add some more libraries to Mayanks\n\nmatplotlib for data visualisation\nNumpy\nOpenpyXl\nxlrd\nxlwt\nXlsxWriter\n\nYou can go through each and choose what suits best to your needs","Q_Score":7,"Tags":"java,python,excel,apache-poi,openpyxl","A_Id":61609928,"CreationDate":"2020-05-05T08:56:00.000","Title":"What is the best library in python to deal with excel files?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was programming python in Visual Studio Code and every time that I ran something it would use the integrated terminal (logically, because I have not changed any settings) and I was wondering, how could I get it to use the Python IDLE's shell instead of the integrated terminal (which for me is useless)?\nI have also got Python IDLE installed in my mac but due to Visual Studio Code having \"intellisense\", it is way easier.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":782,"Q_Id":61609885,"Users Score":0,"Answer":"In VS Code you should be able to select the file which is supposed to be used in the terminal.\nUnder :\nPreferences -> Settings -> Terminal","Q_Score":1,"Tags":"python,macos,visual-studio-code,python-idle","A_Id":61610291,"CreationDate":"2020-05-05T09:27:00.000","Title":"Is there any way to use the python IDLE Shell in visual studio code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a vector with the size 10^15 with numpy and fill it with random numbers, but I get the following error:\nMaximum allowed dimension exceeded.\nCan it help if i use MPI? \nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":61611256,"Users Score":0,"Answer":"The Message Passing Interface (MPI) is mainly used to do parallel computations across multiple machines (nodes). Large arrays can be split into smaller arrays and stored on different machines. However, while it's of course possible to distribute the data to different nodes, you should carefully think about the necessity of doing this for your particular task. Additionally, if you are able to split your array, you could also do this on one machine. If performance is not an issue, avoid parallel computing.","Q_Score":0,"Tags":"python,arrays,numpy","A_Id":61611674,"CreationDate":"2020-05-05T10:44:00.000","Title":"Create big Vector with numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So let's say I have 10 lists named a-j:\nI can check which list is empty\n\nif a.empty:\ndo something\n\nBut in what way can I print only the non empty lists:\n\nfor all lists in a-j :\nprint(non-empty lists)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":316,"Q_Id":61612418,"Users Score":0,"Answer":"let's suppose that you regrouped your 10 lists in a list L so L is now a list of your 10 lists,so this sample of code print the non empty lists which means those who have more than one element:\n\nfor l in L:\n    if (len(l)>0):\n        print(l)","Q_Score":0,"Tags":"python,list","A_Id":61612550,"CreationDate":"2020-05-05T11:49:00.000","Title":"Python: Print non empty lists when multiple lists are present","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am extracting data from a collection in mongodb. my question is: can I somehow know a document that have no been extracted, or eve, this can happen? because I am writing every document into a file and i want to be sure that everything is there, another doubt is... Is the process of extracing data fail in a certain point can I continue the process in the point of failure? I have been checking \"natural order\" to manage to know where i should be continuing the process but it seems it is not an reliable order.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":61612775,"Users Score":0,"Answer":"I am writing every document into a file and i want to be sure that everything is there\n\nOne way of doing this is to compare the number of documents in the collection in MongoDB with the number of entries in the file (or the number of files produced), after your process is complete.\n\nIs the process of extracing data fail in a certain point can I continue the process in the point of failure?\n\nYour application submits a query, MongoDB returns the data for the query. How the data is processed is entirely up to your application. You can certainly continue processing the next document from MongoDB if your application encounters an error in processing the previous document.","Q_Score":0,"Tags":"python,mongodb,pymongo","A_Id":61616049,"CreationDate":"2020-05-05T12:07:00.000","Title":"How to know if some data have no been extracted","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a virtual environment named knowhere and I activate it in cmd using code .\\knowhere\\Scripts\\activate. I have installed some libraries into this environment.\nI have some python scripts stored on my pc. When I try to run them they are not working since they are not running in this virtual environment. Now how to make these scripts run.\nAlso is there any way to make \"knowhere\" as my default environment.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":55,"Q_Id":61613723,"Users Score":-3,"Answer":"Virtual environments are only necessary when you want to work on two projects that use different versions of the same external dependency, e.g. Django 1.9 and Django 1.10 and so on. In such situations virtual environment can be really useful to maintain dependencies of both projects.\nIf you simply want your scripts to use Python libraries just install them on your system and you won't have that problem.","Q_Score":0,"Tags":"python,virtualenv","A_Id":61614442,"CreationDate":"2020-05-05T12:56:00.000","Title":"How to work with virtual environment and make it default","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe that with an index of magic card names. The columns are the same index, resulting in a 1081 x 1081 dataframe of each card in my collection paired with each other card in my collection.\nI have code that identifies combos of cards that go well together. For example \"Whenever you draw a card\" pairs well with \"Draw a card\" cards. I find the junction of those two cards and increase its value by 1. \nNow, I need to find the maximum value for 36 cards.\nBut, how?\nRandomly selecting cards is useless, there are 1.717391336 E+74 potential combinations. I've tried pulling out the lowest values and that reduces the set of potential combinations, but even at 100 cards you're talking about 1.977204582 E+27 potentials. \nThis has to have been solved by someone smarter than me - can ya'll point me in the right direction?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":61614686,"Users Score":1,"Answer":"As you pointed out already, the combinatorics are not on your side here. There are 1081 choose 36 possible sets (binomial coefficient), so it is out of question to check all of them.\nI am not aware of any practicable solution to find the optimal set for the general problem, that is without knowing the 1081x1081 matrix.\nFor an approximate solution for the general problem, you might want to try a greedy approach, while keeping a history of n sets after each step, with e.g. n = 1000.\nSo you would start with going through all sets with 2 cards, which is 1081 * 1080 \/ 2 combinations, look up the value in the matrix for each and pick the n max ones.\nIn the second step, for each of the n kept sets, go through all possible combinations with a third card (and check for duplicate sets), i.e. checking n * 1079 sets, and keep the n max ones.\nIn the third step, check n * 1078 sets with a fourth card, and so on, and so forth.\nOf course, this won't give you the optimal solution for the general case, but maybe it's good enough for your given situation. You can also take a look at the history, to get a feeling for how often it happens that the best set from step x is caught up by another set in a step y > x. Depending on your matrix, it might not happen that often or even never.","Q_Score":0,"Tags":"python,pandas,math,matrix","A_Id":61746981,"CreationDate":"2020-05-05T13:45:00.000","Title":"Matrix Math - Maximizing","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a few files. The big one is ~87 million rows. I have others that are ~500K rows. Part of what I am doing is joining them, and when I try to do it with Pandas, I get memory issues. So I have been using Dask. It is super fast to do all the joins\/applies, but then it takes 5 hours to write out to a csv, even if I know the resulting dataframe is only 26 rows. \nI've read that some joins\/applies are not the best for Dask, but does that mean it is slower using Dask? Because mine have been very quick. It takes seconds to do all of my computations\/manipulations on the millions of rows. But it takes forever to write out. Any ideas how to speed this up\/why this is happening?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":362,"Q_Id":61615480,"Users Score":0,"Answer":"You can use Dask Parallel Processing or try writing into Parquet file instead of CSV as Parquet operation is very fast with Dask","Q_Score":0,"Tags":"python,pandas,csv,dask","A_Id":61615572,"CreationDate":"2020-05-05T14:28:00.000","Title":"Pandas\/Dask - Very long time to write to file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the following:\n1.  AWS (lambda) layer of runtime python 3.6.\n2. A lambda function of runtime python 3.7 that uses the above layer.\nThe layer packages it's modules in a zip with the required hierarhcy of \"python\/lib\/python3.6\/site-packages\".\nThe problem is that the lambda function does not find (i.e. fails to import) the layer modules, unless I explicitly do something like: sys.path.append('\/opt\/python\/lib\/python3.6\/site-packages'), which I feel is a workaround.\n\nI would expect aws lambda framework to smoothly allow a 3.7 runtime to import modules from a layer with version < 3.7. (by adding the matching python path or by some other way).\nIs there such a way that I missed?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":420,"Q_Id":61616494,"Users Score":0,"Answer":"This layer hierarchy python\/lib\/python3.6\/site-packages is not needed. You could just do pip install xxx -t folder, zip it, upload it, and set an PYTHONPATH=\/opt environment variable.","Q_Score":0,"Tags":"python,aws-lambda,aws-lambda-layers","A_Id":61616808,"CreationDate":"2020-05-05T15:13:00.000","Title":"AWS lambda of python runtime 3.7 using layer of runtime 3.6","Data 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 useful would it be running code from the ide Visual studio code 24\/7 on a Raspberry pi? I'm trying to have this project send texts at certain times a day and running it on my computer all day seems like a bad idea I've read. So how plausible would it be to get a raspberry pi and run this code on it all day?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":130,"Q_Id":61616842,"Users Score":0,"Answer":"Well, the 24\/7 isn't a problem.  The nice thing about Rasberry PI they all run under 10 watts.  The problem will be running Visual Studio.  I don't think you can bring VStudio up on a RPI; it is way too big.  Running the application itself, shouldn't be an issue though, depending on size and complexity of course.  Create and debug the application someplace else, then running the python on RPI should not be an issue.","Q_Score":0,"Tags":"python,windows,raspberry-pi","A_Id":61617009,"CreationDate":"2020-05-05T15:29:00.000","Title":"How plausible is it running code on a Raspberry Pi 24\/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":"I'd like to mix C code with Python GUI libraries. I thought about creating C library and using it with ctypes. How to create library for both Linux and Windows at the same time? On Linux, I simply use gcc -fPIC -shared -o lib.so main.c, but how to do that for Windows?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":426,"Q_Id":61617538,"Users Score":-1,"Answer":"Many IDE for C\/C++ already prepared DLL program template,such as Visual Studio,Code::Blocks,VC++6.0 etc.. Using DLL files is similar to using SO files","Q_Score":0,"Tags":"python,c,python-3.x","A_Id":61617752,"CreationDate":"2020-05-05T16:01:00.000","Title":"Combining C with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a pandas dataframe and I want to select the maximum and minimum values across certain columns to use those values to plot a graph. \nExample: \nA | B | C\n1 | 2 | 3\n5 | 6 | 4\n9 | -2 | -1\nI want to take the columns A B C and find the maximum value out of the 3 columns and use that as my maximum point (which would be 9 in column A). Then I would like to take the smallest value out of the 3 columns and use that as my minimum point(in this case it would be -2 in column B).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":394,"Q_Id":61621077,"Users Score":0,"Answer":"Maybe you could try this for the maximum value. df.loc[df['A'].idxmax()]","Q_Score":0,"Tags":"python,python-3.x,pandas,dataframe","A_Id":61621174,"CreationDate":"2020-05-05T19:08:00.000","Title":"How to pick the maximum and minimum value across a number of columns in pandas dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Django dashboard application I wish to view from my browser. Django is running in a Docker container on one of Google's Compute Engine instances. The GCE instance is on a Google VPC, on which I've added firewall rules to open Django's port 8000. I've added my IP to Django's ALLOWED_HOSTS in settings.py. The container's logs indicate that it is running fine, yet when I access the GCE instance's IP from my browser, I am immediately unable to connect. I can ping the instance from my command line just fine. Is there something I'm missing here? Been stuck on this for a few hours now.\nNote: I have the Django container running on a \"Docker network\" in order for Celery to communicate with a RabbitMQ container. This was recommended to me somewhere, but I am unfamiliar with Docker networks or if they are causing the issue.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":471,"Q_Id":61621434,"Users Score":2,"Answer":"I have found the solution after a bit more trial-and-error. It was not very intuitive so I'll post here in case I can help anyone else.\nWhat fixed the issue for me was exposing the port (8000) on the command line when running the app's container:\ndocker run -p 8000:8000 ...\nThe reason this eluded me for so long was because I already expose the port in the Dockerfile: EXPOSE 8000, and when I run docker ps to list the ports exposed on each container, the container appeared to already be port-exposed: 8000\/tcp. However, what I didn't know is that it is supposed to look like: 0.0.0.0:8000->8000\/tcp.\nAnyways, hope this helps someone else out.","Q_Score":2,"Tags":"python,django,docker,google-cloud-platform,google-compute-engine","A_Id":61622310,"CreationDate":"2020-05-05T19:29:00.000","Title":"How do I access Django running on a Google Compute Engine VM from my browser?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"is there any solution to start a Windows PC with a Python program at a certain time?\nI can't find any answer but I heard of a program with this function, but the thing is that i want to program mine myself.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":33,"Q_Id":61622659,"Users Score":1,"Answer":"No. Python runs within your operating system, so it can't run when your computer is turned off (barring a really odd BMC or something). The normal way of doing this is by configuring it in your BIOS\/UEFI settings.","Q_Score":0,"Tags":"python,python-3.x,windows,python-2.7,startup","A_Id":61622702,"CreationDate":"2020-05-05T20:39:00.000","Title":"How to start Windows with a Python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a problem that i can't install tensorflow 2.1.0 version using pip\nevery time i try , i have this message:\nERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)\nERROR: No matching distribution found for tensorflow \nmy machine specs:  windows 10 , 64 bit , python 3.7 pip 20.1","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1084,"Q_Id":61623355,"Users Score":0,"Answer":"I got the problem resolved by upgrading the pip.\npip3 install --upgrade pip","Q_Score":0,"Tags":"python,tensorflow2.0","A_Id":65691855,"CreationDate":"2020-05-05T21:25:00.000","Title":"I can't install tensorflow 2.1.0 version","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem that i can't install tensorflow 2.1.0 version using pip\nevery time i try , i have this message:\nERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)\nERROR: No matching distribution found for tensorflow \nmy machine specs:  windows 10 , 64 bit , python 3.7 pip 20.1","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1084,"Q_Id":61623355,"Users Score":1,"Answer":"Yep this is an issue with that version of python, try using python 3.6, it solved the issue for me","Q_Score":0,"Tags":"python,tensorflow2.0","A_Id":61623460,"CreationDate":"2020-05-05T21:25:00.000","Title":"I can't install tensorflow 2.1.0 version","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose we have various .ipynb files in different directories.\nI know that I wrote some specific code lines in one of these ipynbs.\nHow can I search in which .ipynb this code was written from Jupyter notebook interface?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":61626549,"Users Score":0,"Answer":"Try opening notebooks in visual code and Ctrl+shift+f for searching multiple files.","Q_Score":1,"Tags":"python,jupyter-notebook","A_Id":61626803,"CreationDate":"2020-05-06T02:50:00.000","Title":"How to find specific code lines in Jupyter notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Automation of Smart Home devices \nTo verify smart home devices like end-to-end (from mobile App to smart home devices).\nwhat are the automation framework you suggests.\n\nMobile App - developed Appium with python and Robot\nProduct - REST\nAPI calls.  Smart Devices - Verification of lights ON\/OFF, color\nchange, etc\n\nCan you please suggest or add any better methods to verify end-to-end.\nEG: Image comparison, any other method.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":61626998,"Users Score":0,"Answer":"Actually it depends on two things:\n1- How the devices are calling each other. And whats is the main controller.\n2- Whats you purpose of testing? Testing the devices themselves or testing the functionality of the control panel and softwares?\nAbout CP and softwares:\nIf the system using API > Of course api-testing is required\nIf there are a panel and you can access it with browser> Using selenium for desktop and chromedriver for mobile browser\nIf there are a mobile app, using Appium\netc.\nFor the system itself, it is completely another field and responsibility of the electronic and robot engineers. And depends on hardwares. But the general way is I\/O checking. Means that engineers check the input signal with device actions and vice-versa.\nHope this helps.","Q_Score":0,"Tags":"python,automation,appium,robotframework","A_Id":61628161,"CreationDate":"2020-05-06T03:40:00.000","Title":"how to automate or verify smart home devices","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on project which deals with calculation of halsted matrix and mccabe cyclomatic complexity for the codes in various languages. I found this library multimeric but its documentation is not intuitive. Please explain to me how to use this library for finding code metrics.\nif you know any other library which does this work then please suggest.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":204,"Q_Id":61627907,"Users Score":1,"Answer":"install multimetric follow the instruction from PyPI. go to the code(example.py) location. e.g. cd \/user\/Desktop\/code\nThen type these in terminal:\nmultimetric example.py\nthen you can see the result.","Q_Score":0,"Tags":"python,code-metrics","A_Id":64200291,"CreationDate":"2020-05-06T05:20:00.000","Title":"How to use multimetric python library for calculating code parameters?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to program a python OpenCV app for my own use because I can't go to gyms for some time. I would like to do the following:\n\nCapture frames from a video flow using OpenCV [ done ]\nHave OpenCV track a yellow soccer and return the coordinate of this soccer in the frame [done]\nCome up with an algorithm to detect when a soccer juggling failed, for example the soccer went out of frame and so on [ done ]\n\nNow my question is: let's say I want to save the \"10 seconds right before this event\" of video into a mp4 file. How should I do it? Is there any good template that I can follow?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":307,"Q_Id":61628371,"Users Score":2,"Answer":"You may create a memory buffer worth of 10sec of video (~about 300 frames for most web-cameras), then save frames to that buffer, removing the old ones while adding the new ones.\nOnce your ball is out of the frame -- open a video file, and save your frames from the buffer.","Q_Score":0,"Tags":"python,opencv","A_Id":61629736,"CreationDate":"2020-05-06T05:57:00.000","Title":"how to let OpenCV save the last few seconds of analyzed video","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to add a new column named CleanedText in a csv file in jupyter. The variable name for the file is e_data_raw.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14,"Q_Id":61628781,"Users Score":0,"Answer":"The code will be : \ne_data_raw.append(['CleanedText'])","Q_Score":0,"Tags":"python,csv,jupyter-notebook","A_Id":61628879,"CreationDate":"2020-05-06T06:30:00.000","Title":"Add a new column named CleanedText to a csv file in jupyter","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As I am trying to connect to Google's BigQuery environment from a Python notebook using the google.cloud library, the response from the server is to visit a link that generates a code and to \"Enter the authorization code:\" . However, as this response is just text, I do not know how to pass the code back to the server response. I am running this notebook in a Databricks environment.\nDoes anyone know how I can push this code back to the server and complete the authorization?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":61629225,"Users Score":0,"Answer":"It doesnn't look like you are using the correct . The flow which you mentioned will work on a UI not not with any automation . I suggest you to share more dtails here and also check for more documenataion on the same .","Q_Score":0,"Tags":"python,api,google-cloud-platform,databricks","A_Id":62095168,"CreationDate":"2020-05-06T07:01:00.000","Title":"Passing authorization code to Python Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I change the UE_PYTHON_DIR to \"E:\\python3.7Installer\\python-3.7.7-amd64.exe\"\nThis is a python installer, and I rebuild the engine, but it is not working - my project is still using 2.7.\nHoping for an answer\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":318,"Q_Id":61631906,"Users Score":0,"Answer":"I solved this problem myself\nit is a silly question\nthe UE_PYTHON_DIR should point to installed position\nsuch as \"C:\\Users\\xxxx\\AppData\\Local\\Programs\\Python\\Python37-32\"\nand rebulid engine\nrebuild myProject\nsolved","Q_Score":0,"Tags":"python-3.x,python-2.7,python-3.7,unreal-engine4","A_Id":61772664,"CreationDate":"2020-05-06T09:35:00.000","Title":"How to switch Python version from 2.7 into 3.7 in unreal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I had a good python environment, which got wrecked by MacOS updated which broke Anaconda. I reinstalled Anaconda, but it's still a bit of a mess, where some python kernels for Jupyter Notebooks aren't found, and the system tries to find Python in anaconda3 folders which no longer exist. I tried to fix it which might have made it even messier. \nIs there a way I can uninstall everything related to anaconda\/python, so that I can just reinstall python3 from scratch?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":61634855,"Users Score":0,"Answer":"First look into your .bash_profile and .bashrc and remove all traces of Anaconda from there (and check the paths).\nCheck where which python leads and if its softlink, check to what it points.","Q_Score":0,"Tags":"python,macos,installation,anaconda","A_Id":61635286,"CreationDate":"2020-05-06T12:08:00.000","Title":"How to completely remove all traces of python\/conda and reinstall it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a project at school I need to run a python file using powershell. I tried installing the interpreter and using the command python pythonTest.py but nothing happened.\nDo i need to import something in powershell?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":61636522,"Users Score":0,"Answer":"You have to check the box add python to path when you install python. So first uninstall then reinstall making sure you ticked the checkbox and proceed then you can run python files in powershell.","Q_Score":0,"Tags":"python,powershell","A_Id":61636582,"CreationDate":"2020-05-06T13:32:00.000","Title":"running python files in powershell","Data 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 a project at school I need to run a python file using powershell. I tried installing the interpreter and using the command python pythonTest.py but nothing happened.\nDo i need to import something in powershell?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":61636522,"Users Score":0,"Answer":"FIXED\nI was running it in admin mode and apparently it doesn't work when you're in adminmode","Q_Score":0,"Tags":"python,powershell","A_Id":61659815,"CreationDate":"2020-05-06T13:32:00.000","Title":"running python files in powershell","Data 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 string with html tags and I would like to pass formatting to power point.\nThe only idea I have now is to split it using some xml library and add bunch of ifs adding formatting to run depending on a tag.\nDid you encounter similar problem or have better idea how to approach it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":680,"Q_Id":61636863,"Users Score":1,"Answer":"I don't think there is a method of doing this. For a start, some HTML elements and attributes aren't likely to translate.\nI've done a very limited amount of this - and actually it was mostly Markdown I was translating. (The HTML relevance is that I did work with entity references and also <br\/>.)\nI'm sorry to say my code is useless to you.\nMy advice would be to support a small subset of HTML. Perhaps <span> with some limited styling and things like <br\/>.","Q_Score":1,"Tags":"python,python-pptx","A_Id":61922406,"CreationDate":"2020-05-06T13:48:00.000","Title":"Python pptx - pass html formatted text to paragraph in powerpoint","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I try to switch from pytorch to tensorflow and since the model now seems to be a fixed thing in tensorflow, i stumble upon a problem when working with Convolutional Neural Networks.\nI have a very simple model, just one Conv1D layer and a kernel with size 2.\nI want to train it on a small Configuration, say 16 input size and then export the training results on a 32 input size.\nHow can i access the 3 parameters in this network? (2 kernel, 1 bias) I want to do so to apply them for the higher size case. I struggle because i need to pre-define a input size of the model, this was not the case with pytorch.\nThanks for answering, I've only found outdated answers to this question","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":61638155,"Users Score":2,"Answer":"model.layers[0].get_weights() yields the weights of the first layer, assuming model is a tf.keras.Model object.","Q_Score":0,"Tags":"python,tensorflow,neural-network,conv-neural-network","A_Id":61638348,"CreationDate":"2020-05-06T14:45:00.000","Title":"Access Convolutional Neural Network Parameters","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"import cv2\nTraceback (most recent call last):\nFile \"\", line 1, in \n    import cv2\nImportError: DLL load failed: The specified module could not be found.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":193,"Q_Id":61639233,"Users Score":0,"Answer":"Install Anaconda\nInstall OpenCV-Python to Anaconda\nThe following instruction works for me is inspired by this OpenCV Youtub video. So far I have got it working on both my Desktop and Laptop. Both 64-bit machines and Windows 8.1.\nDownload OpenCV Package\nFirstly, go to the official OpenCV site to download the complete OpenCV package. Pick a version you like (2.x or 3.x). I am on Python 2.x and OpenCV 3.x - mainly because this is how the OpenCV-Python Tutorials are setup\/based on.\nCopy and Paste the cv2.pyd file\nThe Anaconda Site-packages directory (e.g. C:\\Users\\Johnny\\Anaconda\\Lib\\site-packages in my case) contains the Python packages that you may import. Our goal is to copy and paste the cv2.pyd file to this directory (so that we can use the import cv2 in our Python codes.).\nTo do this, copy the cv2.pyd file...\nFrom this OpenCV directory (the beginning part might be slightly different on your machine):\nPython 2.7 and 32-bit machine:\nC:\\opencv\\build\\python\\2.7\\x84\nPython 2.7 and 64-bit machine:\nC:\\opencv\\build\\python\\2.7\\x64\nTo this Anaconda directory (the beginning part might be slightly different on your machine):\nC:\\Users\\Johnny\\Anaconda\\Lib\\site-packages\nAfter performing this step we shall now be able to use import cv2 in Python code. BUT, we still need to do a little bit more work to get FFMPEG (video codec) to work (to enable us to do things like processing videos.)\nSet Enviromental Variables\nRight-click on \"My Computer\" (or \"This PC\" on Windows 8.1) -> left-click Properties -> left-click \"Advanced\" tab -> left-click \"Environment Variables...\" button.\nAdd a new User Variable to point to the OpenCV (either x86 for 32-bit system or x64 for 64-bit system.) I am currently on a 64-bit machine.\n32-BIT OR 64 BIT MACHINE?   VARIABLE    VALUE\n32-bit  OPENCV_DIR  C:\\opencv\\build\\x86\\vc12\n64-bit  OPENCV_DIR  C:\\opencv\\build\\x64\\vc12\nAppend %OPENCV_DIR%\\bin to the User Variable PATH.\nFor example, my PATH user variable looks like this...\nBefore:\nC:\\Users\\Johnny\\Anaconda;C:\\Users\\Johnny\\Anaconda\\Scripts\nAfter:\nC:\\Users\\Johnny\\Anaconda;C:\\Users\\Johnny\\Anaconda\\Scripts;%OPENCV_DIR%\\bin\nThis is it we are done! FFMPEG is ready to be used!\nTest to confirm\nWe need to test whether we can now do these in Anaconda (via Spyder IDE):\nImport OpenCV package\nUse the FFMPEG utility (to read\/write\/process videos)\nTest 1: Can we import OpenCV?\nTo confrim that Anaconda is now able to import the OpenCV-Python package (namely, cv2), issue these in the IPython Console:\nimport cv2\nprint cv2.version\nIf the package cv2 is imported ok with no errors, and the cv2 version is printed out, then we are all good! Here is a snapshot:\nimport-cv2-ok-in-anaconda-python-2.png\nTest 2: Can we Use the FFMPEG codec?\nPlace a sample input_video.mp4 video file in a directory. We want to test whether we can:\nread this .mp4 video file, and\nwrite out a new video file (can be .avi or .mp4 etc.)\nTo do this we need to have a test python code, call it test.py. Place it in the same directory as the sample input_video.mp4 file.\nThis is what test.py may look like (Note: many thanks to Pete's and Warren's suggestions in the comment field - I have replaced my original test code with his - please test it yourself and let us know if this works better):\nimport cv2\ncap = cv2.VideoCapture(\"input_video.mp4\")\nprint cap.isOpened()   # True = read video successfully. False - fail to read video.\nfourcc = cv2.VideoWriter_fourcc(*'XVID')\nout = cv2.VideoWriter(\"output_video.avi\", fourcc, 20.0, (640, 360))\nprint out.isOpened()  # True = write out video successfully. False - fail to write out video.\ncap.release()\nout.release()\nThis test is VERY IMPORTANT. If you'd like to process video files, you'd need to ensure that Anaconda \/ Spyder IDE can use the FFMPEG (video codec). It took me days to have got it working. But I hope it would take you much less time! :)\nNote: one more very important tip when using the Anaconda Spyder IDE. Make sure you check the Current Working Directory (CWD)!!!\nNext step\nNow that we have the OpenCV-Python package (cv2), a potential good next step may be to checkout the OpenCV-Python Tutorials.","Q_Score":0,"Tags":"python,opencv,anaconda,conda","A_Id":61639719,"CreationDate":"2020-05-06T15:37:00.000","Title":"Does any one has idea to install Opencv in spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I updated my code, saved it and then when I try to run it I keep getting old code that isn't there anymore. I restarted the session and deleted the old file and created a new one...still happening. Any ideas?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":321,"Q_Id":61643118,"Users Score":1,"Answer":"Try selecting  : Execute in a dedicated console under Run --> Configure will start a new IPython Console every time the Demo.py program is executed. \nMain use of this mode over Execute in current console is that we can be certain that there are no global objects defined in this Console which originate from debugging and repeated execution of our code. Every time we run the code in the Editor, the IPython Console in which the code runs is restarted.\nIf it related to some existing values you can clear by : \ndef clear_all()","Q_Score":0,"Tags":"python,spyder,reverse","A_Id":61643460,"CreationDate":"2020-05-06T18:55:00.000","Title":"Spyder keeps displaying old code when Run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I just need to update code to python 3 since python 2.7 will soon stop being supported. Want to know if I can install Python 3 without screwing up my current 2.7 code?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":124,"Q_Id":61643485,"Users Score":1,"Answer":"You can install python3, and change the interpreter in VS Code to be whatever version that you want, so 2.7 or 3.x","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":61643609,"CreationDate":"2020-05-06T19:15:00.000","Title":"Can I use both Python 2 and Python3 interchangeably in Visual Studio Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just need to update code to python 3 since python 2.7 will soon stop being supported. Want to know if I can install Python 3 without screwing up my current 2.7 code?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":124,"Q_Id":61643485,"Users Score":3,"Answer":"Yes, you can have more than one version of python on your machine and you can even use any one of them whenever you need it. (In case you need Python2 for some old projects)\nIn order to that, first you need to have both python version installed and added to PATH variable, then you can go to the root folder of your python2.7 and there you will see a python.exe file which is used as the interpreter, you can just change that file's name to python2 or something and you now you can compile by using python2 somefile.py","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":61643642,"CreationDate":"2020-05-06T19:15:00.000","Title":"Can I use both Python 2 and Python3 interchangeably in Visual Studio Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just need to update code to python 3 since python 2.7 will soon stop being supported. Want to know if I can install Python 3 without screwing up my current 2.7 code?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":61643485,"Users Score":0,"Answer":"Yes, you can. Python 2 and Python 3 are very similar, and you can delete python 2 and install python 3. Then reformat your code a little.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":61643514,"CreationDate":"2020-05-06T19:15:00.000","Title":"Can I use both Python 2 and Python3 interchangeably in Visual Studio Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a very simple batch file that works when I double click the file, but if I try to launch it by typing in the name of the batch file into Windows Run, Windows is unable to find it. If I type in the name of the folder containing the batch file, the folder opens up. \nFairly new to coding. I'm going through \"Automate the Boring Stuff\" book","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":599,"Q_Id":61644177,"Users Score":2,"Answer":"Run searches the folders in your global %PATH% variable for your file. It's unlikely that your script is in one of the directories mentioned in %PATH%.\nTo see the contents of PATH, type ECHO %PATH% into a command prompt. You can then move your script to one of the directories.\nAlternatively, to temporarily (for the current CMD session) add a directory to PATH, run SET PATH=%PATH%;C:\\path in your command prompt. A permanent change in PATH requires use of the registry.\nI recommend you reconsider this approach however, as launching CMD then navigating to the script's location (CD C:\\path) to then run the script is generally preferable to changing global variables.","Q_Score":1,"Tags":"python,windows,batch-file","A_Id":61644411,"CreationDate":"2020-05-06T19:55:00.000","Title":"Windows Run can't find batch file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I detect this? Currently I can only do_something if the user clicks a back button and I manually disconnect from the websocket under consideration. Sometimes Websocket DISCONNECT fires, but much of the time it doesn't.\nIf a user refreshes or leaves a page, the disconnect code cannot run. How can I detect when a user leaves\/refreshes?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":160,"Q_Id":61646084,"Users Score":0,"Answer":"there is not perfect way to do this. The main issue is due to TCP the server will not always know that the connection has been dropped until it times out.\nhowever Daphne has 2 options you can configure to help with this --ping-interval and --ping-timeout if you want rapid disconnects then I suggest you set these values to be nice and low.","Q_Score":0,"Tags":"python,django,django-channels","A_Id":61646997,"CreationDate":"2020-05-06T21:53:00.000","Title":"django-channels 1.x detect when user leaves\/refreshes page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to separate a white animation from a black background. The results were poor (black pixelation around edges of animation) when using: mask_color(clip, color=[0,0,0]). I know the function's optional parameters thr=SomeNumber and s=SomeNumber will fix this but I'm unsure what they mean and how they can be chosen in the interests of good quality results and quick rendering times.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":126,"Q_Id":61646853,"Users Score":1,"Answer":"hi thanks for posting the question. First let's quickly go through the meaning of these parameters;\n\nthr: threshold. Only well beyond this threshold is the masking effective, ie transparent\ns: stiffness. How strong the effect will be.\n\nSo as you can imagine, the values that you would feed into these arguments are highly dependent with your inputs and your desired outputs. So maybe you can let the s be its default, and slowly increase thr from 0 to 100 in a linear manner and inspect its output every steps of 10. then choose the best one. then if this is not satisfactory per your requirement, then you can try fine-tuning the stiffness if this would help you get the output that you need.","Q_Score":0,"Tags":"python,mask,moviepy,video-editing","A_Id":61696834,"CreationDate":"2020-05-06T22:55:00.000","Title":"How can the \"thr\" and \"s\" parameters in MoviePy's mask_color function be optimized for maximum quality and minimum rendering time?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to extract entities from the pdf and mark it back to pdf using pdf annotation. \nIs there any way I can annotate specific text using ghostscript?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":93,"Q_Id":61652829,"Users Score":1,"Answer":"You're going to have to be more specific. What do you mean by 'annotate specific text' ? Are you talking about;\n\nAltering a FreeText annotation ?\nFinding text in a content stream and altering it ?\nAdding an annotation at a specific point on the page ?\nSomething else ?\n\nGhostscript is not intended as a general purpose PDF editing tool, and so it's quite limited in what you can do with it. You might be better advised to use something like MuPDF, but so much depends on exactly what you are trying to do, it's not really possible to make any specific recommendations.","Q_Score":0,"Tags":"python,ghostscript","A_Id":61654499,"CreationDate":"2020-05-07T08:07:00.000","Title":"Annotate specific text in pdf using ghost script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm getting the error shown below when running Python script from SQL Server. I already installed ML services and reconfigured parameter external scripts enabled  to 1.\nThis is a SQL Server Developer edition installed on Windows 10.\n\nMsg 39111, Level 16, State 1, Procedure sp_execute_external_script, Line 1 [Batch Start Line 28]\n  The SQL Server Machine Learning Services End-User License Agreement (EULA) has not been accepted.\n\nHow can I accept it? Can't find any information. I've found only accepting EULA on docker containers, but it's not the same within this situation.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1707,"Q_Id":61653555,"Users Score":0,"Answer":"Had the same issue, was solved with a system restart.","Q_Score":2,"Tags":"python,sql-server,sql-server-ml-services","A_Id":65905492,"CreationDate":"2020-05-07T08:46:00.000","Title":"Accept EULA error when running Python script in SQL Server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm getting the error shown below when running Python script from SQL Server. I already installed ML services and reconfigured parameter external scripts enabled  to 1.\nThis is a SQL Server Developer edition installed on Windows 10.\n\nMsg 39111, Level 16, State 1, Procedure sp_execute_external_script, Line 1 [Batch Start Line 28]\n  The SQL Server Machine Learning Services End-User License Agreement (EULA) has not been accepted.\n\nHow can I accept it? Can't find any information. I've found only accepting EULA on docker containers, but it's not the same within this situation.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1707,"Q_Id":61653555,"Users Score":1,"Answer":"We can face with this kind of error if we haven't restarted services after installing ML services. \nActually I've clicked on restart after installation in Configuration Manager several times, but I think due to local account permission it didn't restarted and didn't gave me any error messages. After restart with administrative account error is gone.","Q_Score":2,"Tags":"python,sql-server,sql-server-ml-services","A_Id":61678764,"CreationDate":"2020-05-07T08:46:00.000","Title":"Accept EULA error when running Python script in SQL Server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm automating WhatsApp messaging on WhatsApp Web using selenium in python.\nThe code is working all fine. It's sending out messages.\nBut is there any way, i can use it to send Bulk messages using WhatsApp.\nI tried, but I ended up whatsapp blocking my number.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":571,"Q_Id":61655531,"Users Score":0,"Answer":"For sending the bulk message you can use a loop and can use a time delay for sending the messages in a specific time delay.\nOr for getting help with code you have to share your code.\nYou can use any virtual number to use for your bot, So you not have to worried for getting blocked by whatsapp. There are some apps which are providing free virtual numbers.\nBy the way I have also created a whatsapp bot for automate whatsapp messaging and I have used that number for 1 year to test the working and progress of automation and have used much and still that number is not get blocked by whatsapp.","Q_Score":1,"Tags":"python,selenium,automation,block,whatsapp","A_Id":70091979,"CreationDate":"2020-05-07T10:28:00.000","Title":"WhatsApp Automation using Selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know if it is possible to convert the user selected excel file to CSV using django pre_save signals. Suppose a user uploads 'test.xlsx', I would like to convert that file automatically using the pre_save signal. Once the user uploads the file, it should actually be 'test.csv' in my FileField.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":76,"Q_Id":61655929,"Users Score":0,"Answer":"Yes, you could do it in pre_save, but preferably just do this in the Django form or DRF serializer that handles the upload. That way you can bubble up conversion errors to the user as validation errors, etc.\nAssuming the field in your model is upload, you'd use\n\nclean_upload(self, file) in Django forms.\nvalidate_upload(self, file) in DRF serializers.\n\nJust return a new ContentFile() with your converted content from one of those.","Q_Score":0,"Tags":"python,django,python-3.x,django-rest-framework","A_Id":61655978,"CreationDate":"2020-05-07T10:49:00.000","Title":"Is there a way to convert the uploaded excel file to CSV using django pre_save signal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can you help me help my son with python homework?\nHis homework this week is on iteration. We've worked through most of it, but we can't make much headway with the following:\n\"\u2022  Write a program that will ask a user to enter a number between 1 and 100.  The program should keep dividing the number by 2 until it reaches a number less than 2.  The program should tell the user how many times it had to divide by 2. \"\nCan you help us with this, and preferably include some # lines in the code so we can better understand what's happening?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":2403,"Q_Id":61659143,"Users Score":5,"Answer":"Great that you're helping your son with his homework! Very exciting!\nIf I summarize the question, it is:\n\ntake a number n\ndivide it by 2\nrepeat step 2 until your number is less than 2\noutput how often it had to be divided\n\nLet's do this by hand:\n\nI take a number, 15:\nI divide once, I get 7.5\nit's not less than 2, so I continue\nI divide by 2 again (2 times total), I get 3.75\nit's not less than 2, so I continue\nI divide by 2 again (3 times total), I get 1.875\nit's less than 2, so I stop\n\nI had to divide by three times total.\nIf you were to take these steps and write it in code, how would you do this? (Hint: use a while loop!)","Q_Score":0,"Tags":"python","A_Id":61659290,"CreationDate":"2020-05-07T13:35:00.000","Title":"how do i divide a number by two multiple times","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run a Python script to request some webpages from a server. I'm using the requests library and pretty much using default arguments except for custom headers.\nI've tested this in my main computer (lets call it A), which is running Ubuntu 18.04 desktop. Everything works fine and the responses from the server are correct.\nNow, I've been trying to execute the same script in an old laptop at home that I use for this kind of stuff (lets call it B). I've replicated the same environment: same Python version, same packages. This laptop is running Debian 10.3 without a desktop environment.\nBoth A and B share the same public IP address because they are connected to the local network.\nThe issue is, requests sent by computer B are systematically identified as a bot and get blocked. I've tried this for several days and it's consistent: all requests from A work fine, all requests from B don't. I can even run both of them simultaneously and the behavior remains the same.\nNow, this has me puzzled because:\n\nI understand that, from the webserver point of view, the requests from both A and B are identical: same request, same headers, same IP.\nThe workload is clearly not a problem: I'm launching about one request every 10 minutes.\n\nWhat could be the reason B is getting blocked but A is not?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":61662211,"Users Score":0,"Answer":"You may want to check the 'requests' versions on both the machines and try out different versions.\nI had the exact same problem. My local machine had requests 2.22.0 installed and it worked okay, but my VM had 2.24.0 installed, and the requests sent from there were unsuccessful.\nLater I downgraded to 2.22.0 (on VM) and it worked like charm.","Q_Score":1,"Tags":"python,web-scraping,python-requests,webserver","A_Id":68950214,"CreationDate":"2020-05-07T15:55:00.000","Title":"Same HTTP requests, different responses?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I changed my index.html template so that it would extend base.html. And also changed the content of index.html a little. But Flask keeps loading unchanged version of index.html\nI've tried following:\n\nDeleted index.html temporarily. Flask started to complain jinja2.exceptions.TemplateNotFound: index.html\nThe same happens if I change the name of file to be used here return render_template('index.html')\nTo make sure that Atom editor really applies changes to the file on my server, I opened the file with nano over ssh. Changes are really there.\nCleared browser cache. Tried different browsers. Old version of html template is loaded.\n\nI have no more ideas. \nDo you have any idea what else should be checked?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":382,"Q_Id":61662872,"Users Score":1,"Answer":"This is very strange but it was solved by RESAVING base.html. \nThough base.html was on server, when I did some changes to it and resaved, Flask started to load the new version of index.html.\nI have no idea how this worked.","Q_Score":0,"Tags":"python,flask,jinja2","A_Id":61663345,"CreationDate":"2020-05-07T16:26:00.000","Title":"Flask keeps loading old version of HTML template","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Eventually, every single time I install a new Linux distribution I do sudo apt-get install python3. \nHowever, once installed I always get confused. python is Python 2.7 and python3 is Python 3.x. But also it appears that pip is for Python 2 and pip3 for Python 3. That said most tutorials I see on Internet always use the traditional pip install even though it is about Python 3. \nHow should I deal with this? Should I simply continue to put this annoying 3 every time I use Python (pip3, ipython3, python3...)? In most of my lectures I read that creating a symlink python->python3 is a bad practice. Is that correct?","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4110,"Q_Id":61664673,"Users Score":0,"Answer":"Pip is for python version less than 3. and pip3 is used when you want to install packages for python version 3 or higher.","Q_Score":2,"Tags":"python","A_Id":65379679,"CreationDate":"2020-05-07T18:03:00.000","Title":"Should I use pip or pip3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am receiving this error from command prompt: ModuleNotFoundError: No module named 'pickle' running in python 3.7,\nI have it setup like this:\nimport pickle as thisPickle\nWhat can be the reason why I having this import issue, appreciate any help. Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":308,"Q_Id":61664852,"Users Score":1,"Answer":"pickle is a part of the Standard Library and is pre-included in the Python package. There should not be a reason that it does not work. Make sure that no other versions of python exist on your computer. The command prompt may be using outdated versions that still exist. Also, see if other modules install correctly on your machine.","Q_Score":1,"Tags":"python-3.x,import,pickle","A_Id":61666940,"CreationDate":"2020-05-07T18:14:00.000","Title":"ModuleNotFoundError: No module named pickle for py3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a few test classes using \"unittest\" package to my Python app.\nIn this app, there is a step that the user inserts a path to excel file (from the GUI) and I want to test some cases about this input file. \nIn my test class, I want to kill the program if the user inserts the wrong input (and verifies that exception was thrown).\nThe problem begins because:\nThe behavior of the program is to open a pop-up window (represents the error) and return to the main menu.\nSo, what is the way to stop my program (from test class) after the pop-up window was opened?\nI'm thinking to use tearDown, but I need some advice to kill the program and not continue to the main menu.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":61664939,"Users Score":0,"Answer":"Correct me if i'm wrong, I dont know much about this, but I believe exit() will work if you put it within the exception condition. Hope I was able to help!","Q_Score":0,"Tags":"python,unit-testing,testing,mocking,automated-tests","A_Id":61665450,"CreationDate":"2020-05-07T18:18:00.000","Title":"How to kill Python program from Test class using '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 am new to Python and programming in general and have been using Spyder IDE from the Anaconda distribution for the past few months on Windows 10. It has been really simple and easy to download and use, and I can run all of my code within the IDE, so it has easy for me to begin learning Python.\nI have now become more interested in Python and learning to code and am looking to try other text editors like VS Code or Sublime Text. I was wondering, however, if I need to download and install python to be able to run my code in a terminal or will my current Anaconda install be fine to run the code?\nIf I do need to download Python, will there be any conflicts by having Anaconda installed?\nSorry if I've used the wrong terminology or it's not clear.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6717,"Q_Id":61665557,"Users Score":0,"Answer":"The answer for you will be No. \nif you already had anaconda installed in your laptop, once you open it up you will realized you can install Python within the software. \nAnaconda will not only included Python, R also will be included. \nSpider or Jupiter notebook can be used for edit your Python scripts.","Q_Score":2,"Tags":"python,anaconda,python-install","A_Id":61677001,"CreationDate":"2020-05-07T18:52:00.000","Title":"Do I need to install Python if I already have the Anaconda distribution installed and want to use other text editors?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've created a Flask app and am trying to deploy it for testing on an EC2 machine using Flask's micro web framework (just for testing purposes). I'm serving the app on host=0.0.0.0  and port=80 yet everytime I try and run the app it throws this error PermissionError: [Errno 13] Permission denied on all ports . The weird thing is when I use app.run() without any arguments meaning that it serves the app on the localhost address of the machine and the default port 5000, it runs without a problem. I have opened access to all incoming HTTP requests to port 80 in the AWS console. Can anyone help?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":587,"Q_Id":61665649,"Users Score":0,"Answer":"Port 80 and 443 requires special permission. Try running your flask application with sudo in front of your command.\nExample: sudo python3 main.py.","Q_Score":1,"Tags":"python,amazon-web-services,flask,amazon-ec2","A_Id":61666397,"CreationDate":"2020-05-07T18:56:00.000","Title":"Permission denied when trying to deploy Flask app on AWS EC2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to figure out whether it's safe to let a payed software check its own license date validity using the client's computer\nthe way this is done is by invoking time.time() function from python and comparing it to the hashed license expiry date. if the time.time() returns anything after the expiry date than the software throws a license expired error.\nThe concern I have is whether it's possible for someone to change some system variables and get time.time() function return a different difference since epoch than the real actual one.\nthanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":61666775,"Users Score":0,"Answer":"The time.time() value is returning in python by the operating system time that is getting and setting by GetSystemTime and SetSystemTime of the C library so it can be altered by the user with the right privileges. To ask a web API will be a better approach of checking expiration date that not depending on the operating system time.","Q_Score":0,"Tags":"python","A_Id":61667204,"CreationDate":"2020-05-07T20:05:00.000","Title":"python time since epoch hacking system variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A bit of background,\n\nI have a dotnet windows service that needs some data from a Python script (main.py)  \nmain.py, which uses multiple modules including numpy, scipy and other 3rd party modules,\nis responsible for doing some logic calculations which currently are impossible to be done in C#\nmain.py accepts few parameters and return some results which they are then consumed by our dotnet windows service.\nI am using Python v3.8\n\nNow, I am struggling to come up with a solution to have both dotnet windows service and python script to work together. There are suggestions to use IronPython but I believe it has limitation on importing 3rd party modules which might not work in this scenario.\nI was thinking of using this main.py as a microservice ie a restful API using Flask probably by doing this my dotnet windows service will can make requests whenever it needs the python script to carry out the calculations, and it's scalable when it comes to using it elsewhere\nOtherwise please advice if you believe this can be done differently\nI would love and welcome any suggestions, recommendations or questions.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":524,"Q_Id":61667712,"Users Score":1,"Answer":"Ironpython is compatible with Python 2.7. Python3 support is a long way off. If you are using numpy and scipy, I'd definitely go the microservice route so that you can be using current, supported versions.\nSo now that your C# is calling a REST API does the python service need to run on Windows?  Can you run on a linux box or Windows running WSL?","Q_Score":0,"Tags":"python,c#,.net-core,microservices,ironpython","A_Id":61669507,"CreationDate":"2020-05-07T21:03:00.000","Title":"How can I get my Python script to run from my dotnet core windows service?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a torch tensor of size torch.Size([1, 128, 56, 128])\n1 is channel, 128 is the width, and height. 56 are the stacks of images.\nHow can I resize it to torch.Size([1, 56, 128, 128]) ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4683,"Q_Id":61667967,"Users Score":3,"Answer":"You could simply use permute or transpose.","Q_Score":3,"Tags":"python,pytorch,permutation","A_Id":61674341,"CreationDate":"2020-05-07T21:22:00.000","Title":"How can I swap axis in a torch tensor?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using VSCode. When I enable Django Template, HTML autocomplete doesn't work. I want to code Python and HTML at the same time. How can I solve this problem? Any ideas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1715,"Q_Id":61669007,"Users Score":8,"Answer":"in VSCode's settings.json, add the following : emmet.includeLanguages\": {\"django-html\": \"html\"}","Q_Score":3,"Tags":"python,html,django,visual-studio-code","A_Id":61669093,"CreationDate":"2020-05-07T22:41:00.000","Title":"Why does Django template prevent HTML autocomplete from functioning?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I saw this online and I'm confused on what the second argument would do:\ndefaultdict(list, {})\nLooking at what I get on the console, it seems to simply create a defaultdict where values are lists by default. If so, is this exactly equivalent to running defaultdict(list)? \nFrom I read online:\n\nThe first argument provides the initial value for the default_factory attribute; it defaults to None. All remaining arguments are treated the same as if they were passed to the dict constructor, including keyword arguments.\n\nwhich also makes me wonder about the difference between:\n\nmy_dict = dict({})\nmy_dict = dict()","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":46,"Q_Id":61669611,"Users Score":1,"Answer":"the argument to the dict class in python is the instantiation values.. so passing an {} creates an empty dictionary.\nIts the same case with defaultdict, except that the first argument is the default type of the values for every key.","Q_Score":1,"Tags":"python,python-3.x,dictionary","A_Id":61669710,"CreationDate":"2020-05-07T23:41:00.000","Title":"What does defaultdict(list, {}) or dict({}) do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to come up with a way to scrape information on houses on Zillow and I am currently using xpath to look at data such as rent price, principal and mortgage costs, insurance costs. \nI was able to find the information using xpath but I wanted to make it automatic and put it inside a for loop but I realized as I was using xpath, not all the data for each listing has the same xpath information. for some it would be off by 1 of a list or div. See code below for what I mean. How do I get it more specific? Is there a way to look up for a string like \"principal and interest\" and select the next value which would be the numerical value that I am looking for?\nworks for one listing:\ndriver.find_element_by_xpath(\"\/html\/body\/div[1]\/div[6]\/div\/div[1]\/div[1]\/div[1]\/ul\/li[1]\/article\/div[1]\/div[2]\/div\")\na different listing would contain this:\ndriver.find_element_by_xpath(\"\/html\/body\/div[1]\/div[6]\/div\/div[1]\/div[1]\/div[2]\/ul\/li[1]\/article\/div[1]\/div[2]\/div\")","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":61672860,"Users Score":0,"Answer":"selecting multiple elements using xpath is not a good idea. You can look into \"css selector\". Using this you can get similar elements.","Q_Score":0,"Tags":"python,selenium","A_Id":61673109,"CreationDate":"2020-05-08T05:52:00.000","Title":"Selenium scraping","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a DataFrame with shape 330000, 70, when I try to save it as csv a got the following error:\nUnicodeEncodeError: 'charmap' codec can't encode character '\\uff91' in position 110: character maps to \nIs there any way to locate the character at position 110 in the DataFrame?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":61674479,"Users Score":0,"Answer":"If you google what \\uff91 is, you may be able to filter on it, or replace it with something else\nAnother option - export it to excel and locate it that way. \nNot elegant but it will probably get you the answer","Q_Score":1,"Tags":"python,pandas","A_Id":61674697,"CreationDate":"2020-05-08T07:48:00.000","Title":"DataFrame.to_csv Error, is there any way to locate the character causing error in the DataFrame?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently have a ManytoManyField in Django where I can Select multiple Users with strg and mouseclick.\nWith much more Users it gets heavily complicated to search the User I want to select.\nIs there a possibility to have a ManytoManyField, but also have a search_field for Users, so I can search and pick.\nThank you for your help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":61675368,"Users Score":0,"Answer":"I found the answer. What I was searching for was filter_horizontal = '# put ManytoManyField reference name here'","Q_Score":0,"Tags":"python,django,python-3.x,django-models,django-admin","A_Id":61726630,"CreationDate":"2020-05-08T08:46:00.000","Title":"Implement Search field in ManytoManyField(Django Admin) models.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I\u2019ve looked through this forum and couldn\u2019t find a clear answer to helping my situation. \nTo explain: I\u2019m currently trying to develop an IOT device that mainly consists of a raspberry pi 3. As it\u2019s for a start up business idea I want to reduce costs and not have a server on the cloud. \nI thought it would be a good idea to have flask run with gunicorn on the pi and this would be accessed by a desktop app or mobile app that would know the IP address of the pi as well as it\u2019s flask endpoints. \nI wanted the pi to be accessible from any other network (not just its local one). I have host on \u201c0.0.0.0\u201d and port 5000 for development but can\u2019t access it through my mobile network. \nI have seen similar posts mentioning ngrok (which might make data less secure?). I\u2019ve seen that I might have to forward the port of the pi to the router. But I think this might involve accessing the router set up. And I don\u2019t want to have to do this for every new client. \nI have checked other posts on the forum but can\u2019t seem to find what I\u2019m looking for. \nCan I ask this forum if my understanding is correct? Can anyone help me out? \nAny advice would be greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":595,"Q_Id":61675492,"Users Score":0,"Answer":"If I understood the problem correctly,\nIf you want to connect to your raspberry pi remotely you should know the IP address of your raspberry pi and need port forwarding. After that, you can connect to your raspberry pi with a public ip address. For example publicraspberrypiaddress:5555 (which port are you using)\nNgrok gives a random subdomain for connection so I don't know how you recognize the ngrok url when device is not near of you.\nAlternatively, you can use cotunnel. It gives static url and the device appears on the cotunnel dashboard so you can manage your raspberry pi remotely with ssh terminal too. \nOr you should develop your own tunnel-like service, or change your project structure. I don't know another way.","Q_Score":0,"Tags":"python,flask,raspberry-pi3,ip-address","A_Id":61699730,"CreationDate":"2020-05-08T08:54:00.000","Title":"Accessing IOT raspberry pi outside of network using flask with Gunicorn","Data Science and Machine Learning":0,"Database and SQL":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":"What does it mean to \"render a template\" or to \"render a form\" in Django?\nExample 1: \"Generally a view retrieves data according to the parameters, loads a template and renders the template with the retrieved data.\nExample 2: \"Rendering a form in a template involves nearly the same work as rendering any other kind of object\"\nWould the meaning of render in the above two examples be to \"provide\" or give\"?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":121,"Q_Id":61677483,"Users Score":1,"Answer":"Rendering a template is indeed always about producing content, but for a slightly wider description of content. It could be a chunk of html, for example an ajax call to get new items might produce some html describing the new items, but it doesn't have to be.\ncreds. Frederick Cheung","Q_Score":0,"Tags":"python,django","A_Id":61677603,"CreationDate":"2020-05-08T10:52:00.000","Title":"What does \"render\" mean in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So, I have a project tested using pytest and using the pytest-cov module to report coverage.\nSome of the code involves bootstrapping and configuration and the canonical way of running this is starting via a shell script. The current unit tests use the subprocess module to test running this shell script on mocked data. I would like the code report against the coverage and I am trying specifically to avoid\n1) Heavily modifying the wrapper to support the test scenario. Also, this runs the risk of doing 2).\n2) Running the boostrap code outside the wrapper (e.g. by forking the process and running the code directly), since I want these tests to be as realistic as possible.\nIs there any (canoical, Pythonic) way of propagating the coverage collection to all subproceses, even when launched using subprocess.Popen? I can easily solve the problem using a hack, so this is not something I am looking for.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":339,"Q_Id":61678372,"Users Score":0,"Answer":"This actually works out of the box. The reason for me thinking this did not work was that the path mappings w.r.t. the Docker volumes were incorrect, as the modules loaded by the subprocess were bind mounted in the container. Coverage is only reported when the paths match up exactly.","Q_Score":0,"Tags":"python,pytest,coverage.py","A_Id":62195477,"CreationDate":"2020-05-08T11:42:00.000","Title":"Measure coverage across subprocesses","Data Science and Machine Learning":0,"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":"Some people were using my bot on a server I am a part of, and for some reason, the bot suddenly started duplicating responses to commands. Basically, instead of doing an action once, it would do it twice. I tried restarting it multiple times which didn't work, and I know it isn't a problem with my code because it was working perfectly well a few seconds ago. It probably wasn't lag either, because only a couple of people were using it. Any ideas on why this may be and how to fix it? I am also hosting it on repl.it, just so you know what ide Im using","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":280,"Q_Id":61683552,"Users Score":0,"Answer":"Its probably because you run the script and run the host at them same time so it sends the command thorught host and code. If you dont run the code but just the host and it still dupliactes it might be an error with the host or it runs somewhere else in the backround.","Q_Score":0,"Tags":"python,discord.py","A_Id":61711270,"CreationDate":"2020-05-08T16:25:00.000","Title":"Why is my python discord bot suddenly duplicating responses to 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 have a quite complex software system which was developed in ruby and has been now all \"translated\" and transported into python. The last thing which is left is a series of *.txt.erb templates. I would like to leave them as they are but have a python library which does what the old ruby routine was doing, that is creating a series of *.txt files which follow the *.erb templates structure. I have looked a lot around but I cannot find an answer. \nProbably for a more expert python programmer this might be a simple question.\nThanks a lot for your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":61683706,"Users Score":0,"Answer":"I've solved the problem changing the *txt.erb templates into *.txt files and I've coded a python script which reads the file and substitute the general variable into the specific variable I want to, for both file content and file name.\nThank you for the help!","Q_Score":0,"Tags":"python,ruby,erb,templating","A_Id":61770422,"CreationDate":"2020-05-08T16:33:00.000","Title":"How to read\/translate *txt.erb template (ruby) with 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":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a generator object that checks a certain condition on a list. This program works fine for all my cases. \nBut I just want to clarify some key points. \nIn my program Whenever the generator yield the values 'No' or 'Done' the controlling iteration stops and calls the generator with another argument.\nThis may be a silly question, anyway that is, whenever the generator object is yielded and we stops calling next to it, does that object is settled for garbage collecting? Or is that yielded object is being settled to garbage collecting when we call that generator again with another argument.\nPlease clarify this to me what happens to a generator object if we stops calling next() on it before it raise a StopIteration exception. What happens to the persevered execution points and variables of the current generator object, when we again call the generator with a new argument.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":145,"Q_Id":61685623,"Users Score":2,"Answer":"I debated making this a comment because I'm not an expert on the GC implementation details in Python, but decided on an answer since it seems like it might be helpful.\nI think it only gets garbage collected when you lose all references to it, but it shouldn't matter, as generators are usually used to avoid storing stuff in memory, so they aren't usually very large. I think it's fine to stop using it before it hits StopIteration. In fact, many generators never call StopIteration (e.g., if they are enumerating some infinite series), so it's expected that you stop calling next on it before hitting the \"end\" in many cases.","Q_Score":5,"Tags":"python,generator","A_Id":61685718,"CreationDate":"2020-05-08T18:24:00.000","Title":"What happens if we stop iteration before a generator object raises a 'StopIteration' exception","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a beginner in pygame and I'd like to develop a game simple game where the screen moves along with the character.\nWhat is the best method to do so?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":447,"Q_Id":61685894,"Users Score":2,"Answer":"One method would be to move the backround without moving the character so it looks like the character is moving.","Q_Score":2,"Tags":"python,python-3.x,pygame,game-physics","A_Id":61685926,"CreationDate":"2020-05-08T18:41:00.000","Title":"How to make screen move with the character in pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am stuck at this error while importing from ldap3 import Server, Connection, ALL.\nPlease help","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2695,"Q_Id":61686948,"Users Score":0,"Answer":"I stumbled above the same error. In my case my executed python file was named like the ldap3 python library (ldap3.py). So i renamed my file and it worked.","Q_Score":1,"Tags":"python-3.x,ldap3","A_Id":66463764,"CreationDate":"2020-05-08T19:47:00.000","Title":"How to resolve ImportError: cannot import name 'PyAsn1UnicodeDecodeError' in ldap3 connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset that keeps a record of customer's activities on a website in a sequence. I have to predict whether the customer makes a purchase or not given his sequence of interactions with the site with LSTM network. However, I also have to incorporate some static info(like whether he is a prior client or not, his nationality,his gender etc.) about customer in the same LSTM network. How should I incorporate these static info. in my model?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":61687646,"Users Score":0,"Answer":"You can add those data as feature to each activity. If you consider data as a table, basically you add more columns (features) to it. For this, you should consider also using one hot encoding as well.","Q_Score":0,"Tags":"python,tensorflow,keras,deep-learning,lstm","A_Id":61689055,"CreationDate":"2020-05-08T20:33:00.000","Title":"How to incorporate static information(time independent) to sequential(time dependent) data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"'''model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=10, verbose=2)'''\nin the above line of code model is a sequential keras model having layers and is compiled.\nwhat is the use of the parameter validaiton_data. the model is going to train on X_train and y_train data. so based on y_train the parameters would be adjusted and back propagation is done.\nwhat is the use of validation_data and why is a different data in this case testing data provided.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":607,"Q_Id":61688767,"Users Score":1,"Answer":"During training, (x_train, y_train) data is used to adjust trainable parameters of the model. However, we don't know whether model is overfit or under fit, whether model is going to do well when new data is provided. So, that is the reason why we have validation data (x_test, y_test) to test the accuracy of model on any unseen data.\nDepending on training and validation accuracy, we can decide.\n- Whether the model is overfit\/underfit,\n- whether to collect more data,\n- do we need to implement regularization technique,\n- do we need to use data augmentation techniques,.\n- whether we need to do tune hyper parameters etc.","Q_Score":0,"Tags":"python,tensorflow,keras,deep-learning,neural-network","A_Id":61689769,"CreationDate":"2020-05-08T21:58:00.000","Title":"how does validation_split work in training a neural network model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to compare data from  different csv files on Python that consist of 84 columns and about 40.000 ~ 50.000 rows. This is a process that I need to do several times for several files. Which library should I use to have good performance? Should I use the regular csv library from python or would it be better to use something like Pandas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":61689527,"Users Score":0,"Answer":"Working with csvs usually will import the data in table formats. Typically R is a great language to manipulate columns and data in table (data frames) format, but when doing this in python, pandas is the go to library.","Q_Score":0,"Tags":"python-3.x,csv","A_Id":61689562,"CreationDate":"2020-05-08T23:04:00.000","Title":"Handling csv files on Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a Python3 library which will determine if we are running on GCP or another cloud architecture as opposed to a native architecture?\nSomething like platform.platform() or jaraco.docker.is_docker(), but for the cloud?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":119,"Q_Id":61690480,"Users Score":0,"Answer":"No, simply because the Python codes actually running in a virtual machine in the cloud.","Q_Score":0,"Tags":"python-3.x,google-cloud-platform,architecture,cloud","A_Id":61690531,"CreationDate":"2020-05-09T01:05:00.000","Title":"Python3 Determine if a Program is Running on GCP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Every time i try to upload a code or erase flash it gets me \"A fatal error occurred: Timed out waiting for packet content\"\nC:\\esptool>python esptool.py --port com4 erase_flash\nesptool.py v3.0-dev\nSerial port com4\nConnecting........_\nDetecting chip type... ESP32\nChip is ESP32D0WDQ6 (revision 1)\nFeatures: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None\nCrystal is 40MHz\nMAC: 24:6f:28:a2:5a:7c\nUploading stub...\nRunning stub...\nStub running...\nErasing flash (this may take a while)...\nA fatal error occurred: Timed out waiting for packet content","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1328,"Q_Id":61691037,"Users Score":0,"Answer":"is your USB cable a charger cable only? This happens a lot. Charger cables look almost the same as charge\/data cables. Though the heads look the same, sometimes a charger cable is slightly thinner b\/c it only has two conductors in the jacket. Charger\/Data cables however have at least 4 wires, Data +, Data -, Power and Ground. Test your cable with another data device, or try a slightly thicker cable.","Q_Score":0,"Tags":"python,arduino,esp8266,esp32,esptool","A_Id":61754602,"CreationDate":"2020-05-09T02:29:00.000","Title":"Can't upload my code to esp32 and not able able to erase flash","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 load a CUDA library compiled from source into a Python program. On my Windows machine, it successfully loads the code. However, on my university's Unix computer cluster, it fails with the error:\n\nImportError: dynamic module does not define module export function\n  (PyInit_deform_conv_cuda)\n\nI have located the actual *.so file that was produced by the compilation process and discovered that grep finds an instance of 'PyInit_deform_conv_cuda' in it.\nThat makes me think that maybe the loader is loading the wrong file or something. I was hoping to debug the loader, but my trace statements never execute.\nI am running Python 3.7 on both machines.\nCan anybody tell what might be going wrong? Either with the loading of the module or with my debugging efforts?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":61691643,"Users Score":0,"Answer":"I would never have guessed this and I feel kind of stupid. \nThe problem was that I installed the library into one Python environment and tried to run it from another. \nI'm posting this in case someone else makes this mistake. The error message wasn't at all helpful int this case.","Q_Score":0,"Tags":"python,c++","A_Id":61749295,"CreationDate":"2020-05-09T04:03:00.000","Title":"Python fails to load C++ library even though PyInit_ entry exists","Data Science and Machine Learning":0,"Database and SQL":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 call an api on a running jupyter notebook to create or edit an existing cell, and to run it. When this is done, the browser page should also update, to show both the contents of the cell, and the output. \nThe intended use case for this api is a plugin for the vim editor that will take highlighted lines and execute them. The motivation for using jupyter notebook is that will allow visualization of plots and images using matplotlib, even though both vim and the notebook will be running on a remote server. The user would have a browser page open to the notebook, and separately a terminal open potentially that is ssh'ed to the machine and editing python code. \nVSCode does exactly this in its python interactive mode, but I prefer to use the vim editor natively than switch to vscode simply to be able to do this.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":469,"Q_Id":61692423,"Users Score":0,"Answer":"You could use vscode's built in jupyter notebook support to convert the notebook into a python file","Q_Score":3,"Tags":"python,matplotlib,vim,visual-studio-code,jupyter-notebook","A_Id":61948000,"CreationDate":"2020-05-09T05:52:00.000","Title":"How can I create and execute a cell in Jupyter Notebook server from a separate process (e.g., an editor, vim)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a training set containing 272 images.\n\nbatch size = 8, steps per epoch = 1 > train the model for just 8 images and jumps to next epoch?\nbatch size = 8, steps per epoch = 34 (no shuffle) > train the model for all 272 images and jumps to the next epoch?\nAt the end of each steps per epoch does it update the weights of the model?\nIf so, by increasing the number of steps per epoch does it gives a better result?\nIs there a convention in selecting batch size & steps per epoch?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":654,"Q_Id":61693941,"Users Score":1,"Answer":"If I provide the definition using the 272 images as the training dataset and 8 as batch size,\n\nbatch size - the number of images that will be feed together to the neural network.\nepoch - an iteration over all the dataset images\nsteps - usually the batch size and number of epochs determine the steps. By default, here, steps = 272\/8 = 34 per epoch. In total, if you want 10 epochs, you get 10 x 34 = 340 steps. \n\nNow, if your dataset is very large, or if there are many possible ways to augment your images, which can again lead to a dataset of infinite or dynamic length, so how do you set the epoch in this case? You simply use steps per epoch to set a boundary. You pick an arbitrary value like say 100 and you assume your total dataset length to be 800. Now, it is another thing on how you do the augmentation. Normally, you can rotate, crop, or scale by random values each time.\nAnyway, coming to the answers to your questions -\n\nYes\nYes\nYes if you are using Mini-batch gradient descent\nWell, yes unless it overfits or your data is very small or ... there are a lot of other things to consider.\nI am not aware of any. But for a ballpark figure, you can check on the training mechanism of high accuracy open source trained models in your domain.\n\n(Note: I am not actively working in this field any more. So some things may have changed or I may be mistaken.)","Q_Score":0,"Tags":"python,tensorflow,machine-learning,keras,deep-learning","A_Id":61694526,"CreationDate":"2020-05-09T08:36:00.000","Title":"Can someone explain the relationship between batch size and steps per epoch?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to open an .ipynb file on a Mac and use it?\nWhich apps is needed for that or what are your recommendations?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":21558,"Q_Id":61695073,"Users Score":4,"Answer":"you need to install jupyter you can do it using: pip install jupyter\nand run it in terminal with the command jupyter notebook this will open a browser window where you can view and run juputer notebooks\nYou can also open these notebooks in pyCharm and Visual Studio Code (after installing the python extension from microsoft)","Q_Score":0,"Tags":"python,macos,visual-studio-code,jupyter-notebook","A_Id":61695277,"CreationDate":"2020-05-09T10:12:00.000","Title":"How to open ipynb files on a Mac?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Python Django web application.\nIn Get method how to prevent the user from entering url and access the Data.\nHow do i know weather the url accessed by Code or Browser.\nI tried with sessionid in Cookie, But if session exist's it allow to access the data.\nThanks.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":61695188,"Users Score":0,"Answer":"To detect if request is from browser, you can check HTTP_USER_AGENT header\nrequest.META.get(\"HTTP_USER_AGENT\")","Q_Score":0,"Tags":"django,python-3.x","A_Id":61699310,"CreationDate":"2020-05-09T10:23:00.000","Title":"Prevent the user with session from entering the URL in browser and access the data in Python Django Application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python Django web application.\nIn Get method how to prevent the user from entering url and access the Data.\nHow do i know weather the url accessed by Code or Browser.\nI tried with sessionid in Cookie, But if session exist's it allow to access the data.\nThanks.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":61695188,"Users Score":0,"Answer":"I achieve it by \nif 'HTTP_REFERER' not in request.META:\nit not exist's when hit directly from browser url.","Q_Score":0,"Tags":"django,python-3.x","A_Id":61700613,"CreationDate":"2020-05-09T10:23:00.000","Title":"Prevent the user with session from entering the URL in browser and access the data in Python Django Application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have some excel files that I want to modify, the modification is just regarding cells. In these excel files are vba macros that I have to preserve after the modification. I was playing with xlwt library, after to make the modifications and save the files I lost the macros. I just wondering if I can do with pyxl. I would like to know if with one of these libraries could preserve this info or I should ise another one.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":16,"Q_Id":61698555,"Users Score":0,"Answer":"I found a way using the library pywin32 to use excel trough windows as a com object.","Q_Score":0,"Tags":"python-3.x,openpyxl,xlwt","A_Id":61822530,"CreationDate":"2020-05-09T14:45:00.000","Title":"Is there a way in pyxl to keep existing macros?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"so I am trying to do some background job to run in my flask app , and in order to run the worker, I needed to use cygwin instead of my windows terminal. My application use MongoDb Atlas for documents storage and it works perfectly fine when I \"flask run\" it from my cmd . But I got the error once I run it or run the worker from cygwin. It is to note that I whitelisted my IP adress and installed the dnspython package , and still got the error. \nAny suggestions about what could be the problem? I don't seem to find any answer in previous asked questions . Thank you.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1520,"Q_Id":61700528,"Users Score":0,"Answer":"I hit and resolved this same issue hit today w\/ cygwin, python3.8, dnspython 1.16.0 by updating to dnspython 2.0.0 and ensuring there was a valid \/etc\/resolv.conf in place.","Q_Score":0,"Tags":"python,cygwin,mongodb-atlas,python-rq","A_Id":63003420,"CreationDate":"2020-05-09T16:59:00.000","Title":"I am getting this error The DNS operation timed out after 20.000144004821777 seconds when running my app in cygwin instead of my windows terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"so I am trying to do some background job to run in my flask app , and in order to run the worker, I needed to use cygwin instead of my windows terminal. My application use MongoDb Atlas for documents storage and it works perfectly fine when I \"flask run\" it from my cmd . But I got the error once I run it or run the worker from cygwin. It is to note that I whitelisted my IP adress and installed the dnspython package , and still got the error. \nAny suggestions about what could be the problem? I don't seem to find any answer in previous asked questions . Thank you.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1520,"Q_Id":61700528,"Users Score":1,"Answer":"It's because of your dynamic DNS configuration from your ISP. make it static or you can use googleDNS server which is 8.8.8.8 or 8.8.4.4 as your DNS servers.","Q_Score":0,"Tags":"python,cygwin,mongodb-atlas,python-rq","A_Id":65537656,"CreationDate":"2020-05-09T16:59:00.000","Title":"I am getting this error The DNS operation timed out after 20.000144004821777 seconds when running my app in cygwin instead of my windows terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have this list lst = ['GS-1', 'GS-2', 'GS-3']\nHow can I delete the \"-\" and every thing before it to get something like this? ['1, '2', '3']","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":204,"Q_Id":61700791,"Users Score":1,"Answer":"In a simple one line you can do something like this: \n numbers = [ item.split(\"-\")[-1] for item in lst]\nThis code iterate every items split it with \"-\" and takes anything after \"-\".","Q_Score":0,"Tags":"python-3.x","A_Id":61700872,"CreationDate":"2020-05-09T17:19:00.000","Title":"Split values of a list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an app that uses the Spacy model \"en_core_web_sm\". I have tested the app on my local machine and it works fine.\nHowever when I deploy it to Heroku, it gives me this error:\n\"Can't find model 'en_core_web_sm'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.\"\nMy requirements file contains spacy==2.2.4.\nI have been doing some research on this error and found that the model needs to be downloaded separately using this command:\npython -m spacy download en_core_web_sm\nI have been looking for ways to add the same to my requirements.txt file but haven't been able to find one that works!\nI tried this as well - added the below to the requirements file:\n-e git:\/\/github.com\/explosion\/spacy-models\/releases\/download\/en_core_web_sm-2.2.0\/en_core_web_sm-2.2.0.tar.gz#egg=en_core_web_sm==2.2.0\nbut it gave this error:\n\"Cloning git:\/\/github.com\/explosion\/spacy-models\/releases\/download\/en_core_web_sm-2.2.0\/en_core_web_sm-2.2.0.tar.gz to \/app\/.heroku\/src\/en-core-web-sm\nRunning command git clone -q git:\/\/github.com\/explosion\/spacy-models\/releases\/download\/en_core_web_sm-2.2.0\/en_core_web_sm-2.2.0.tar.gz \/app\/.heroku\/src\/en-core-web-sm\nfatal: remote error:\n           explosion\/spacy-models\/releases\/download\/en_core_web_sm-2.2.0\/en_core_web_sm-2.2.0.tar.gz is not a valid repository name\"\nIs there a way to get this Spacy model to load from the requirements file? Or any other fix that is possible?\nThank you.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7657,"Q_Id":61702357,"Users Score":4,"Answer":"Ok, so after some more Googling and hunting for a solution, I found this solution that worked:\nI downloaded the tarball from the url that @tausif shared in his answer, to my local system.\nSaved it in the directory which had my requirements.txt file.\nThen I added this line to my requirements.txt file: .\/en_core_web_sm-2.2.5.tar.gz\nProceeded with deploying to Heroku - it succeeded and the app works perfectly now.","Q_Score":16,"Tags":"python,git,heroku,spacy","A_Id":61708393,"CreationDate":"2020-05-09T19:15:00.000","Title":"How to add a Spacy model to a requirements.txt file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a fairly old website running Django 1.11 and Python 2.7. I am not sure why it doesn't seem to be updating. \nI upgraded Python3.5 to Python3.7 just now. Deleted the old virtualenv (by deleting app\/bin and creating a new virtualenv with virtualenv --python=\/usr\/bin\/python3 . ) \nWhen in the virtualenv, if I do a python -V I get Python 3.7.7. If I run django-admin --version I see 3.0.6. \nBut when I try to run the server, my Traceback says: \nFile \"\/usr\/local\/lib\/python2.7\/dist-packages\/django\/core\/handlers\/exception.py\" in inner\n 41.             response = get_response(request)\nSo it's still pointing at apparently an old global install? How can I point it to the new version in the virtualenv I've created?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":61703296,"Users Score":0,"Answer":"Okay, I figured it out. I was using sudo to install virtualenv, python and django because the folder in the root directory, \/webapps was root owned. Even in virtualenv, sudo is a global installer, and so my installs were going to the main \/usr folder, where there were now two django installs, 1.11 in the python2.7 folder, and 3.06 in the python3.7 folder. \nI deleted the virtualenv, ran CHMOD 777 on my \/webapps folder so my regular account could create a virtualenv without sudo, and could run pip3 without sudo, which installed my software locally and now everything is working.","Q_Score":0,"Tags":"python,django","A_Id":61713305,"CreationDate":"2020-05-09T20:29:00.000","Title":"Upgrading Django 1.11 to 3.X\/Python2.7 to 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using Redis with Python to store my per second ticker data (price and volume of an instrument). I am performing r.hget(instrument,key) and facing the following issue.\nMy key (string) looks like 01\/01\/2020-09:32:01 and goes on incrementing per second till the user specified interval. \nFor example 01\/01\/2020-09:32:01\n01\/01\/2020-09:32:02 01\/01\/2020-09:32:03 ....\nMy r.hget(instrument,key) result looks likeb'672.2,432'(price and volume separated by a comma).\nThe issue am facing is that a user can specify a long time interval, like 2 years, that is, he\/she wants the data from 01\/01\/2020 to 31\/12\/2020 (d\/m\/y format).So to perform the get operation I have to first generate timestamps for that period and then perform the get operation to form a panda dataframe. The generation of this datastamp to use as key for get operation is slowing down my process terribly (but it also ensures that the data is in strict ordering. For example 01\/01\/2020-09:32:01 will definitely be before 01\/01\/2020-09:32:02). Is there another way to achieve the same?\nIf I simply do r.hgetall(...) I wont be able to satisfy the time interval condition of user.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":447,"Q_Id":61703506,"Users Score":0,"Answer":"So to perform the get operation I have to first generate timestamps for that period and then perform the get operation...\nNo. This is the problem.\nMake a function that calculates the timestamps and yield a smaller set of values, for a smaller time span (one week or one month).\nSo the new workflow will be in batches, see this loop:\n\ngenerate a small set of timestamps\nfetch items from redis\n\nPros:\n\nminimize the memory usage\neasy to change your current code to this new algo.\n\nI don't know about redis specific functions, so other specific solutions can be better. My idea is a general approach, I used it with success for other problems.","Q_Score":0,"Tags":"python,pandas,redis","A_Id":61705153,"CreationDate":"2020-05-09T20:45:00.000","Title":"Extract data faster from Redis and store in Panda Dataframe by avoiding key generation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a 4D data np.array consisting of 150 images 50X70 decomposed to 3 channels.\nThe shape of the data is (150, 50, 70, 3). \nI need the average of those 150 images by channel, with the shape (50, 70, 3) \n(where R channel of average would be the average of 150 R channels, etc.)\nI've tried:\naverage = data.mean(axis=0)\naverageimage = Image.fromarray(average, 'RGB')\naverageimage.show()\nbut even tho it gives correct shape, the image looks like random color noise. \nEDIT: I've tried \ndef average_image(a_lot_of_images):\n    avg = np.zeros((a_lot_of_images.shape[1], a_lot_of_images.shape[2], a_lot_of_images.shape[3]))\n    for i in range(a_lot_of_images.shape[0]):\n        avg[:,:,0] += a_lot_of_images[i,:,:,0]\n        avg[:,:,1] += a_lot_of_images[i,:,:,1]\n        avg[:,:,2] += a_lot_of_images[i,:,:,2]\n    for i in [0,1,2]:\n        avg[:,:,i] = avg[:,:,i]\/a_lot_of_images.shape[0]\n    return avg\nand the output still looks like color noise.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":61705427,"Users Score":0,"Answer":"def average_image(a_lot_of_images):\n    avg = np.zeros((a_lot_of_images.shape[1], a_lot_of_images.shape[2], a_lot_of_images.shape[3]), dtype=float)\n    for i in range(a_lot_of_images.shape[0]):\n        avg[:, :, 0] += a_lot_of_images[i, :, :, 0]\n        avg[:, :, 1] += a_lot_of_images[i, :, :, 1]\n        avg[:, :, 2] += a_lot_of_images[i, :, :, 2]\n    for i in [0,1,2]:\n        avg[:, :, i] = avg[:, :, i]\/a_lot_of_images.shape[0]\n    avg = np.array(np.round(avg), dtype=np.uint8)\n    return avg\nworks! Is there a way to do this in a more elegant way?","Q_Score":0,"Tags":"python-imaging-library,rgb,mean,numpy-ndarray,tensor","A_Id":61706774,"CreationDate":"2020-05-10T00:00:00.000","Title":"Mean RGB image out of 4D np.array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python and Visual Studio code to develop my code.  I can run my scripts successfully (Using Run Python File in Terminal). However, this is very inconvenient since after each run I go back to the terminal window and do not have access to python, therefore, I will lose the variables in the previous run so I have three options: 1- Print all the variables I want to screen (This is clearly not scalable). 2- Run the file again. 3- Run the Python file in an interactive window(Ipython). \nOption 3 is exactly like running the file in a Jupyter Notebook which is very convenient since you can create a cell below the current cell and keep using the variables after one run. \nI would like to know what is the best method to run the python script from the terminal (Pycharm, VS code,...) and can work with variables after (not like every time you forgot to print something you run the file again?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1510,"Q_Id":61707404,"Users Score":0,"Answer":"If you set a breakpoint then debug your code (f5), on the bottom of VSCode there is a Debug Console, you can type in debug command there (print(), type(), etc). That seems like it might be what you are looking for.","Q_Score":2,"Tags":"python,terminal,jupyter-notebook,save","A_Id":65228562,"CreationDate":"2020-05-10T05:01:00.000","Title":"save Python variables after running it from terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python and Visual Studio code to develop my code.  I can run my scripts successfully (Using Run Python File in Terminal). However, this is very inconvenient since after each run I go back to the terminal window and do not have access to python, therefore, I will lose the variables in the previous run so I have three options: 1- Print all the variables I want to screen (This is clearly not scalable). 2- Run the file again. 3- Run the Python file in an interactive window(Ipython). \nOption 3 is exactly like running the file in a Jupyter Notebook which is very convenient since you can create a cell below the current cell and keep using the variables after one run. \nI would like to know what is the best method to run the python script from the terminal (Pycharm, VS code,...) and can work with variables after (not like every time you forgot to print something you run the file again?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1510,"Q_Id":61707404,"Users Score":0,"Answer":"Try shift + enter on each line this will open the terminal with python\nOr try to run .ipynb files instead of .py files in vscode","Q_Score":2,"Tags":"python,terminal,jupyter-notebook,save","A_Id":69054154,"CreationDate":"2020-05-10T05:01:00.000","Title":"save Python variables after running it from terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've created an API using Flask-RESTFUL package for Python 3.7.\nI'd like to know what the proper approach would be for returning data to a user based on which columns he should have access to.\nFor example, if I have an \"orders\" table with (order_id, order_date, price, ebay_name, revenue), but want User A and User B to have access to different data. Let's say that on route \/get_data, I return all fields, but User A should have access to all data, while User B only can see the revenue field.\nMy current approach:\nWhile building the JWT token when a user logins in and authenticates, would it be acceptable to store the column names of the \"orders\" table in the actual token? Then, when the user goes to the \/get_data route, I would basically check the column names stored in the JWT and build the MySQL query with the column names found in the token (select all_columns_in_jwt from orders). I worry that exposing the table columns in the JWT token is not the best approach.\nAnother idea would be to check within a user permissions table each time the \/get_data route is hit.\nDoes anyone have a suggestion for implementing this in a more efficient way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":300,"Q_Id":61707553,"Users Score":0,"Answer":"I would do it using user permissions but you could also create separate procedures for either each individual user or groups of users based on their roles\/permissions which create\/replace specific views of the tables allowing the user to see only what you want them to see. For example, upon any changes to the table (or alternatively, upon login for a user\/member of a user group) you could run the procedure to generate (or replace if it already exists) a view on the table for either each user or each user group which you want to restrict access to, and then your API would select data from the view rather than directly from the table\nWith user permissions (this is very similar to how I implement it in my own apps) you could create a permissions table and then a table of the permissions which users possess. Then, on using an API, you could query the user's permissions and using a map which you store somewhere in your code base you could look up the columns based on a combination of the relevant user permission and the relevant table and use the resulting column set as what you select in your query","Q_Score":0,"Tags":"python,mysql,flask,jwt,flask-restful","A_Id":61708552,"CreationDate":"2020-05-10T05:22:00.000","Title":"proper way to grant permissions to specific data JWT MySQL Flask-Restful Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've got the following list, which is stored in a variable called 'mylist'.\nmylist = (('', 'Select Square Feet'), ('100', '100 Square Feet'), ('200', '200 Square Feet'))\nHow would I change 'Select Square Feet' to be 'Select' using python?\nThanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":61707636,"Users Score":2,"Answer":"That isn't a list. It's a tuple. Tuples are immutable and can't be changed. It is also a tuple of tuples so the inner tuples must also be lists if you want to change one of their elements. Tuples are created with parentheses (actually the parentheses are optional its the comma that really does it) use brackets:\nmylist = [['', 'Select Square Feet'], ['100', '100 Square Feet'], ['200', '200 Square Feet']] \nNow with this the way you would change 'Select Square Feet' to 'Select' is by using indexing: \nmylist[0][1] = 'Select' \nHere the 0 refers to the first element of the outer list and the 1 refers to the second element of the inner list.","Q_Score":0,"Tags":"python","A_Id":61707696,"CreationDate":"2020-05-10T05:35:00.000","Title":"Replacing value in list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've already seen multiple posts on Stackoverflow regarding this. However, some of the answers are outdated (such as using PhantomJS) and others didn't work for me.\nI'm using selenium to scrape a few sports websites for their data.  However, every time I try to scrape these sites, a few of them block me because they know I'm using chromedriver.  I'm not sending very many requests at all, and I'm also using a VPN.  I know the issue is with chromedriver because anytime I stop running my code but try opening these sites on chromedriver, I'm still blocked.  However, when I open them in my default web browser, I can access them perfectly fine.  \nSo, I wanted to know if anyone has any suggestions of how to avoid getting blocked from these sites when scraping them in selenium.  I've already tried changing the '$cdc...' variable within the chromedriver, but that didn't work.  I would greatly appreciate any ideas, thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":164,"Q_Id":61707706,"Users Score":1,"Answer":"Obviously they can tell you're not using a common browser. Could it have something to do with the User Agent?\nTry it out with something like Postman. See what the responses are. Try messing with the user agent and other request fields. Look at the request headers when you access the site with a regular browser (like chrome) and try to spoof those.\nEdit: just remembered this and realized the page might be performing some checks in JS and whatnot. It's worth looking into what happens when you block JS on the site with a regular browser.","Q_Score":2,"Tags":"python,selenium,web-scraping,webdriver,selenium-chromedriver","A_Id":61708614,"CreationDate":"2020-05-10T05:44:00.000","Title":"How to be undetectable with chrome webdriver?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there anything that someone could point me towards (a package, an example, a strategy, etc) of how I could implement the ability for an end user of my app to create a new field in a model, then add that model field to a model form and template? I\u2019m thinking of the way that Salesforce allows users to add Custom fields.\nI don\u2019t really have any start point here I am only looking to learn if\/how this might be possible in Django.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":61711629,"Users Score":0,"Answer":"I'm also looking for same type of solution. But with some research, I came to know that we have this using ContentTypes framework.\nHow to do it? We can utilize ContentType's GenericForeignKeys and GenericRelations.","Q_Score":0,"Tags":"python,django","A_Id":67532664,"CreationDate":"2020-05-10T12:01:00.000","Title":"Allow End User To Add To Model, Form, and Template Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I read that it is possible to convert a TensorFlow Model (.pb) file to CoreML (.mlmodel) to run it on iOS platforms. But I have some .mlmodel files that I want to run on tensorflow. So I want to know if there is any way I could convert them to .pb files or any other way I could use them in Tensorflow.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1543,"Q_Id":61712399,"Users Score":1,"Answer":"The good news: Yes, you can do this.\nThe bad news: You'll have to do it by hand. There are no tools for doing this automatically.\nThe easiest solution is to define the model in TensorFlow, then copy the weights from the Core ML model into the TF model.","Q_Score":2,"Tags":"python,tensorflow,coreml","A_Id":61717136,"CreationDate":"2020-05-10T12:58:00.000","Title":"How to convert a CoreML Model to a TensorFlow Model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi i am using checkmarx for static code analysis. The checkmarx document says it only supports Django framework from python. May i know if checkmarx supports python's cherrypy framework ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":61712540,"Users Score":1,"Answer":"The problem with checkmarx is the version of Python. Checkmarx support Python 2.6, 2.7 and 3.4 . \nPython version more recent that 3.4 are not supported and you may experience parsing or analyse issues","Q_Score":0,"Tags":"python-3.x,cherrypy,checkmarx","A_Id":61723328,"CreationDate":"2020-05-10T13:08:00.000","Title":"Does checkmarx support python's cherrypy framework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know that this question has been asked and answered many times but the answers to those questions aren't really assuaging. Each person has given a different definition of both which is really confusing. Being a novice, I really don't know whom to trust. Can someone please clarify the difference between them?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1155,"Q_Id":61713990,"Users Score":1,"Answer":"instance and object are effectively the same thing. When you create an instance of a class, that instance is an object. \nPut another way, every instance is an object. That is the literal definition of an object: an instance of a class.","Q_Score":3,"Tags":"python,class,object,instance","A_Id":61714157,"CreationDate":"2020-05-10T14:55:00.000","Title":"What is the difference between an instance and an object in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that this question has been asked and answered many times but the answers to those questions aren't really assuaging. Each person has given a different definition of both which is really confusing. Being a novice, I really don't know whom to trust. Can someone please clarify the difference between them?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1155,"Q_Id":61713990,"Users Score":3,"Answer":"In Python, everything is an object.  Moreover in Python objects are instances of classes, so it follows that every object is also an instance of some class*.\nHowever, we generally use the term instance in preference to object when we want to discuss the behaviour of instances of a specific class or classes\n\nInstances of Foo provide the following operations ...\nNo two instances of Bar may compare as equal ...\n\nSo we might say that object is the most general term, whereas instances refers to the set of objects which are instances of a particular class or classes, and instance to a specific object which is an instance of a particular class.\nIn short, they are the same thing, but we use these terms in different contexts.\n*Python enables this circular definition by making object an instance of type, and type an instance of object, and both object and type are instances of themselves.","Q_Score":3,"Tags":"python,class,object,instance","A_Id":61716167,"CreationDate":"2020-05-10T14:55:00.000","Title":"What is the difference between an instance and an object in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with Django right now and when I installed it through the command prompt I made a virtualenv called test, now I went into vs code and I am trying to open it up by saying workon test but it's not going into the virutalenv. I am on windows and I am using visual studio code.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":369,"Q_Id":61714931,"Users Score":0,"Answer":"In cmd typing test\/Scripts\/activate worked, but in vscode terminal, I had to cd till the Scripts and then type .\\activate.","Q_Score":0,"Tags":"python,virtualenv","A_Id":71579493,"CreationDate":"2020-05-10T16:04:00.000","Title":"Why isn't my virtualenv opening up in visual studio code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working with Django right now and when I installed it through the command prompt I made a virtualenv called test, now I went into vs code and I am trying to open it up by saying workon test but it's not going into the virutalenv. I am on windows and I am using visual studio code.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":369,"Q_Id":61714931,"Users Score":0,"Answer":"just go to the left below corner where your python version is written click it, it will open the command palette where select the virtual env. (with its name) that's is test and press ok.\nAfter that open new terminal and you will get what you want","Q_Score":0,"Tags":"python,virtualenv","A_Id":70324944,"CreationDate":"2020-05-10T16:04:00.000","Title":"Why isn't my virtualenv opening up in visual studio code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I understand that tuples are immutable objects. Therefore I cannot change an element of a tuple (unless I create a new tuple). However, if I have:\nmy_tuple = (1, 2, [3, 4])\nand then I try to modify the 3rd element only with the extend() method: \nmy_tuple[2].extend([5, 6])\nI see that my tuple is now (1, 2, [3, 4, 5, 6]) and python doesn't throw an error. I understand I have modified a list, which is mutable. But the list is inside the tuple, so it should be immutable. Doesn't this behaviour violate the immutability of tuples?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":706,"Q_Id":61715900,"Users Score":-1,"Answer":"List is mutable and tuple is immutable.\nIn the above extend method, you modify the list.\nTo better understand this: \niIf you define a dictionary, like so:\na={} a[my_tuple]=0 \nyou will get error because of immutable object, i.e tuple, contains a mutable object that is list.\nSo a dictionary key is not hashable but if you define: \nmy_tuple=(1,2,3) \nthen a[my_tuple] will not give an error.","Q_Score":0,"Tags":"python","A_Id":61716019,"CreationDate":"2020-05-10T17:16:00.000","Title":"Python tuples and extend() method","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use MariaDb for my flask app. \nSo I try to make connection like in documentation, are any orm which support this db?\nDoes peewee support MariaDb. How can i use peewee orm for connection to MariaDb?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":443,"Q_Id":61716850,"Users Score":3,"Answer":"Yes, it supports MariaDB in the same way that it supports MySQL. MariaDB speaks the mysql protocol and uses the mysql drivers. So just use MySQLDatabase.","Q_Score":0,"Tags":"python,mariadb,peewee","A_Id":61738558,"CreationDate":"2020-05-10T18:27:00.000","Title":"MariaDb and Peewee","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So, I want to be able to write Python code in my Visual Studio Code on my Windows PC. On my network is a raspberry pi 4, which I would like to execute said code on and receive any errors or output from. \nIs it possible for me to write some python code on my Windows PC, \"run\" it on the Raspberry pi, and receive any outputs of the program on my Windows PC? \nThe reason I wish to do this is that Visual Studio Code generally helps me write any code, and it is more time consuming for me to use other IDE's, and my code uses PyBluez, something I can't just test on my Windows PC (which has no Bluetooth module)\nI hope my question is in the right format and such! This is my first time posting! Any comments appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":218,"Q_Id":61717230,"Users Score":1,"Answer":"It seems that my answer was to use the Remote Development pack on Visual Studio Code (it's an extension) to ssh into my raspberry pi. It's worked well for me for the past few days, and I highly recommend it. It allowed me to access the entire sd card and access any files I need to, while also giving me an SSH terminal and run the program ON the other machine.\nFor anyone who does this; set up the whole ssh key thing, to stop having to give the password to the pi so often. \nThe scp command would also work, I think, but is more complex than what I want to do.\nThank you so much for the answer, JL Peyret!","Q_Score":2,"Tags":"python,bluetooth,raspberry-pi,ide","A_Id":61798111,"CreationDate":"2020-05-10T18:57:00.000","Title":"Can I run and develop a python program from 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 use pdb.runcall to check if a function behaves as I expected. However, it does not have the visual component as IDE debuggers like Pycharm's. Can I do the same thing with Pycharm debugger without running the whole program from the beginning? I want to debug a specific function by using my current environment.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":61717387,"Users Score":0,"Answer":"Apparently, we can attach a debugger to the console with a button on the console menu (green bug to the left of the console). If we place a breakpoint in the module or function we want to step into and call the function normally the debugger lands on the breakpoint like the normal debugger. But, with the console debugger, I was able to use the variables in my environment without running the whole application.","Q_Score":0,"Tags":"python,debugging,pycharm","A_Id":61732584,"CreationDate":"2020-05-10T19:09:00.000","Title":"Equivalent of pdb.runcall in Pycharm debugger","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a sequence of (x, y) points approximating a road segment, and I would like to identify and split them into groups of two types: \n\nStraight line segments\nNon-straight line segments. At the moment I am not concerned about the parametrization of these. They may be constant curvature arcs, changing curvature clothoids... anything (but simplicity is preferred)\n\nAny hints about how to solve this problem in Python? I can find some academic publications about it, by searching for terms like \"curve decomposition into lines and arcs\" or similar, but they do not provide any example code, and implementing the entire method from scratch is not feasible for me. Any help is appreciated!\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":879,"Q_Id":61717945,"Users Score":0,"Answer":"Use triplets P1,P2,P3  or  P3,P4,P5 or P100,P101,P102  etc.\nWith three points you can find the circumference going through them. If its radious is too big (say 100 km) it's probably a straight, although it may be also the beginning of a clothoid (R is infinite where a clothoid joins a straight).\nSo you must test also the fourth point, telling if it belongs to that cicumference or it's in the clothoid. The parameter A of this clothoid knowing 4 points can be calculated by consecutive iterarions.\nIf you are given with an axis that is not the road axis, but a parallel to it, then remember that the curve parallel to a clothoid is not another clothoid.\nOnce you have all segments type-defined, you need a fine adjust so all segments are tangent at their end-points. This job can be done by working with triplets of segments, divide the tangent-error value rotating the middle segment or some other method you can think of.","Q_Score":0,"Tags":"python,geometry,line,curve,decomposition","A_Id":61719626,"CreationDate":"2020-05-10T19:55:00.000","Title":"How to split arbitrary curve into line and arc segments in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm in this problem for hours, because I can't find a method that can remove the edges from a adjacency map graph in O(1) time.\nIf anyone has any idea, it would be very helpful.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":556,"Q_Id":61718579,"Users Score":1,"Answer":"You should have HashMap (or dict in python) with Keys some kind of Node-index and Values to be for example HashSet (or set in python) of Node-indexes, edges from given Key node reach to.\nFor example {1: {2, 3}, 2: {1, 3}, 3: {1}} means, you have 3 nodes: 1, 2, 3 and eges are: [1, 2], [1, 3], [2, 1], [2, 3], [3, 1] - assuming it's directed graph. If you want to remove edge let's say 2, 3, obtain key (starting node of the edge) from your hashmap in O(1) time:\nsomething like graph.get(2) which will return you your value - hashSet of Nodes edges lead to, in this case {1, 3}. From this set, you can remove 3 (end node) again in O(1) time.\nRepeat this process for all edges you may have.","Q_Score":0,"Tags":"python,algorithm,data-structures,graph","A_Id":61718889,"CreationDate":"2020-05-10T20:52:00.000","Title":"Adjacency Map - How to remove a edge from a Graph","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to build a model that's able to classify the author of a book (just fiction books for the moment) by looking at its text. At first, I just worked with authors that had at least 30 books. In my dataset, that was ~2000 books written by ~30 authors in total, and that went pretty great, so I decided to raise the stakes. By lowering the threshold to 10 books, the database grew to ~400 authors and ~9000 books.\nThe way I classified the books is as follows: I removed punctuation, newlines, extra spaces, and stopwords from every text, then I extracted the features with sklearn CountVectorizer and TfidfVectorizer. With this approach, the F1 score was 0.95 for the 2000 books db and 0.62 for the 9000 books db. In both cases I used the SGD model from scikit learn.\nThe training with the larger dataset was much slower, so I decided to get 5000 random words from each book and use only those. This decreased the training time from 20 minutes to only 2 minutes, and enabled me to try something different. There wasn't a big difference in the various metrics, so I decided to try and remove the tfidf features. Using only CountVectorizer I got a 0.87 F1 score.\nI'm not sure why this is happening, my expectation was that the tfidf would make things easier and therefore better my score. In theory, tfidf should help with the sparsity of the matrix. Do you have any clue on why removing it improved the score instead?\nAre there other strategies, maybe better suited to work with long texts? Should I consider trimming the dataset in a certain way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":61718786,"Users Score":0,"Answer":"There might be 2 problems here:\n\nYou have not tuned the parameters for TFIDF and hence it is giving low scores. Try to do a grid search and parameters such as min_df, max_df, max_features etc. This might increase the scores. CountVectorizer might be preforming good because the classifier might be associating some unique words with a certain author. \nThe data imbalance problem. You can try to use SMOTE on the TFIDF features, or if you are using Logistic Regression you can set class_weights='balanced' and that might also increase scores.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,nlp","A_Id":61718856,"CreationDate":"2020-05-10T21:10:00.000","Title":"Literary author classification from book content","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my module I have an entity \"Person\" with two fields \"date_of_birth\" (Date)  and \"age\" (Integer). How can I get the age of a Person from the date of birth and give that value to the age field?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":854,"Q_Id":61719266,"Users Score":0,"Answer":"The datetime.timedelta() function will do it.","Q_Score":1,"Tags":"python,odoo","A_Id":61720512,"CreationDate":"2020-05-10T21:58:00.000","Title":"How to get a person's age from his date of birth in Odoo?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am enquiring about assistance regarding regression testing. I have a continuous time series that fluctuates between positive and negative integers. I also have events occurring throughout this time series at seemingly random time points. Essentially, when an event occurs I grab the respective integer. I then want to test whether this integer influences the event at all. As in, are there more positive\/negative integers. \nI originally thought logistic regression with the positive\/negative number but that would require at least two distinct groups. Whereas, I only have info on events that have occurred. I can't really include that amount of events that don't occur as it's somewhat continuous and random. The amount of times an event doesn't occur is impossible to measure. \nSo my distinct group is all true in a sense as I don't have any results from something that didn't occur. What I am trying to classify is: \nWhen an outcome occurs, does the positive or negative integer influence this outcome.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":61721366,"Users Score":0,"Answer":"Although, the question is quite difficult to understand after first paragraph. Let me help from what I could understand from this question.\nAssuming you want to understand if there is relationship between the events happening and the integers in the data.\n1st approach: Plot the data on a 2d scale and check visually if there is a relationship between data.\n2nd approach: make the data from the events continuous and remove the events from other data and using rolling window smooth out the data and then compare both trends.\nAbove given approach only works well if I am understanding your problem correctly. \nThere is also one more thing known as Survivorship bias. You might be missing data, please also check that part also.","Q_Score":1,"Tags":"python,pandas,regression","A_Id":61868967,"CreationDate":"2020-05-11T02:28:00.000","Title":"Statistical test for time series where outcome occurs - python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to figure out how to most efficiently search for lines ins a ~23 million line CSV file in python.\nThe file is a list of ZIP+4 codes, and some information about each, mainly their FIPS ID, state abbreviation and county.\nFor example line 1 is {02468,1405,25,017,25017,MA,MIDDLESEX} those values are {5_Dig_Zip,+4_Dig_Zip,StateFIPS,CountyFIPS,TotalFIPS,State_Abbrev,County}.\nI'd like to build a dictionary, or some other data structure to be able to query:\ndata[\"02468\"] --> and return all of the lines where the 5 digit ZIP is 02468, or data[\"02468\"][\"1405\"], and return just that line. \nThe data currently sits in a large list of lists. It seems like I might want to use nested dictionaries, but I'm not quite sure where to head.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":24,"Q_Id":61721574,"Users Score":1,"Answer":"Pythonic: make a pandas dataframe with a multi-index (first level: 5 digit zip, second level - 4 digit extension).\nLess pythonic, but easy: make an sqlite database and query in the usual way.","Q_Score":1,"Tags":"python,csv,processing","A_Id":61721715,"CreationDate":"2020-05-11T02:56:00.000","Title":"Python: Building Dictionary With Multiple Responses (Nested Dictionaries?)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to install Python 3.7.6 in windows 10. All went well until when in the cmd prompt of the computer as soon as I entered python to check the cmd prompt took me to microsoft app store and asked me to download python 3.7.7. It is not recognizing the python 3.7.6 that I had downloaded. Can any one help me with this","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":61723562,"Users Score":0,"Answer":"it's just a case, i encountered the similar problem just download the app to get rid of the redirect to the store and it will be all ok.","Q_Score":0,"Tags":"python,installation","A_Id":61723638,"CreationDate":"2020-05-11T06:32:00.000","Title":"Python installation in Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried to install Python 3.7.6 in windows 10. All went well until when in the cmd prompt of the computer as soon as I entered python to check the cmd prompt took me to microsoft app store and asked me to download python 3.7.7. It is not recognizing the python 3.7.6 that I had downloaded. Can any one help me with this","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":61723562,"Users Score":0,"Answer":"Yeah i have experienced the same issue .\nBut i have found an alternative solution to this problem.\nDownload Anaconda and then type \"conda install python 3.7.6\" in the anaconda prompt or u can also create a custom environment by typing \"conda create -n py376 python=3.7.6 anaconda\" in the anaconda prompt and then u shall see the version of python installed on ur environment by typing \"python --version\"","Q_Score":0,"Tags":"python,installation","A_Id":61725377,"CreationDate":"2020-05-11T06:32:00.000","Title":"Python installation in Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I recently learn about Pyqt5 and have some confusion about it. I have finished designing my GUI using Designer and I convert it using the pyuic5 command to start writing function for it, lets say it generate a mainwindow.py. So my question is, is it a best practice to directly write a code on mainwindow.py or should I create a new python file that import it? I want to avoid problem of fixing this in the future. Thank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":61724549,"Users Score":0,"Answer":"It is generally better to import it and extend it, since you can iterate design process and generate new file when design changes.","Q_Score":0,"Tags":"python,pyqt5","A_Id":61724602,"CreationDate":"2020-05-11T07:39:00.000","Title":"Is it a good idea to directly write function on pyuic5 generated py file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"command= {'SEL': 'band','LATOR': '27.05','RAMP' : 'disabled'}\nfor key in command:\nprint(key, command[key])\no\/p:-\nSEL band\nLATOR 27.05\nRAMP disabled\nExpected O\/P:-\nI want to add GHZ in LATOR:-\nSEL band\nLATOR 27.05GHz\nRAMP disabled","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":36,"Q_Id":61724936,"Users Score":1,"Answer":"If you just want to add GHz to your 'LATOR' key, you can use command[\"LATOR\"] += \"GHz\"","Q_Score":0,"Tags":"python,python-2.7,dictionary","A_Id":61725187,"CreationDate":"2020-05-11T08:04:00.000","Title":"Python2:I want to add some string in dict o\/p","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"InvalidArchiveError('Error with archive C:\\Users\\Sahaja Reddy\\Anaconda3\\pkgs\\openssl-1.1.1g-he774522_0.conda.  You probably need to delete and re-download or re-create this file.  Message from libarchive was:\\n\\nCould not unlink (errno=22, retcode=-25, archive_p=1873471744752)')","AnswerCount":5,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":23794,"Q_Id":61726576,"Users Score":5,"Answer":"InvalidArchiveError when trying to install with conda can happen if you don't have enough free space on the hard disk. Make sure you have enough free space.","Q_Score":16,"Tags":"python,anaconda,spacy","A_Id":63716148,"CreationDate":"2020-05-11T09:38:00.000","Title":"I am getting an InvalidArchiveError in anaconda prompt when I am trying to install spacy. How to solve it?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose one classroom contains 40 students.\nThen I trained model for all images of 40 students and then try to detect all 40 students in one picture.\nBut not getting good accuracy.\nWhy this is happing? Is any other measure criteria other than just measuring the accuracy of the model?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":61726951,"Users Score":0,"Answer":"A little improvement can be achieved through data augmentation. For every image (in your case, every student), you could say that an object rotated by 10 percent, is still the same object for the observer. The same goes for mirroring the image. By adding a couple of new data points this way, you would probably get better results.","Q_Score":0,"Tags":"python,tensorflow,image-processing,keras,deep-learning","A_Id":61728954,"CreationDate":"2020-05-11T09:57:00.000","Title":"How to Train model in which number of classes is equal to number of instances in particular image used for prediction","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have a seasonal time-series with 2 variable \"Time\" and \"Sensor mesure\" and I want to predict the date when that measure would reach a certain value . Can anyone suggest models\/Algos that can help (I'm a beginner)\nPS : Using python","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":61727130,"Users Score":0,"Answer":"For time series data, you can use LSTM or GRU neural networks. They would be the easiest to solve your problem.","Q_Score":0,"Tags":"python,time-series,forecasting,sensor-fusion","A_Id":61727264,"CreationDate":"2020-05-11T10:06:00.000","Title":"Time series : Predicting when a variable will reach a certain value (seasonal sensor data) python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to run my discord python bot:\nqbasty@cody-discord-bot:~\/matrixcraft-cody$ pm2 start Cody.py --interpreter=python\n[PM2][ERROR] Interpreter python is NOT AVAILABLE in PATH. (type 'which python' to double check.)\nI get that error.\nUbuntu 20 on DigitalOcean.","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3701,"Q_Id":61728462,"Users Score":10,"Answer":"Here is what worked for me :\npm2 start bot.py --name bot --interpreter python3","Q_Score":4,"Tags":"python,discord","A_Id":64982779,"CreationDate":"2020-05-11T11:19:00.000","Title":"[PM2][ERROR] Interpreter python is NOT AVAILABLE in PATH. (type 'which python' to double check.)","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 store a license key database for my paid software in python and then when users has the license key the software key will check the license key in server's database and if it find ones then the software opens and then when one year is past by then the license key will expire\nI have looked at some examples on the net have come to the conclusion that python is not a great programming language to build software such as this so i am going to do that in JAVA.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":405,"Q_Id":61730238,"Users Score":0,"Answer":"Well as far as I know you have one possibilty to do this well with python, and that would be having a server store keys, because python code is very open so you cannot save it locally. especially storing locally that it is valid for one year will pretty easily be 'hacked', so just do so on database on a server.","Q_Score":0,"Tags":"python,tkinter,random,license-key","A_Id":61730897,"CreationDate":"2020-05-11T12:54:00.000","Title":"How can I store licence key in server database and take that in python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have teh need to interact with our customers AD from Jira in order to handle automatically user onboarding.\nFor that we have 2 deifferent approach :\n\nUsing Microsoft Graph API\nWe call directly from Jira Script Runner plugin using groovy script POST and GEt methods, this directly within Jira environment\nUsing Microsoft Azure SDk for python\n\nUsing this approach will need to build a python script which is store in the dedicated location on the VM and calling that scrip from Jira using Groovy script\nIn the first approach we are using only 4 API call only for how request and we are all time scripting within Jira environement.\nON the second approach we need to deal with 2 types of script ( python and groovy)\nBased on your advise, do you see what could be the best based on your experience in order to help me chose one or the other ?\nThanks for help\nregards","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":61730467,"Users Score":0,"Answer":"I would follow up to Laurent, and say, the better solution is the solution that has the least amount of complexity while accomplishing everything you need to do. \nIn this case according to your own post, that is clearly just calling graph API directly from your groovy scripting in Jira.","Q_Score":0,"Tags":"groovy,azure-active-directory,jira,azure-sdk-python","A_Id":61735494,"CreationDate":"2020-05-11T13:07:00.000","Title":"What is the main Ad's and Con's using MS Graph API vs MS Azure SDK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Im trying to figure out how ansible executes the commands on the remote host, I get that it uses ssh\/winrm to connect to the remote host but from there it would have to assume the remote host has python\/powershell (depends on the os) and all the libraries their code need to run.\nso basically what im asking is :\n\ndoes ansible require the remote host to have python in the right version on it.\ndoes it require the remote host to have the libraries their code uses.\nif not does it transfer the modules when it connects and removes them afterwards.\nelse it may \"compile\" the modules and transfer them","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":61731191,"Users Score":0,"Answer":"Ansible works by connecting to your nodes and pushing out small programs, called \"Ansible modules\" to them. These programs are written to be resource models of the desired state of the system. Ansible then executes these modules (over SSH by default), and removes them when finished.","Q_Score":0,"Tags":"python,ansible,infrastructure","A_Id":61731574,"CreationDate":"2020-05-11T13:43:00.000","Title":"how does ansible executes on a remote host?","Data Science and Machine Learning":0,"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 my Az Function app, I have some ubuntu packages like Azure CLI and Kubectl that I need to install on the AZ Host whenever it starts a new container. I have already tried Start-up Commands and also going into the Bash. The former doesnt work and the latter tells me permission is denied and resource is locked.  Is there any way to install these packages on function start-up in Azure Functions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":61734028,"Users Score":0,"Answer":"If you try to install the package via bash, it is impossible and will not be dealt with at all. The reason is because when you use python to write functions and deploy them to linux os on azure, in fact it installs various packages according to requirements.txt, and finally merges these packages into a whole. When you run the function on azure, you are based on this whole package. Therefore, if it is incorrect to try to install the package after deployment, you should specify the package to be installed in requirements.txt before deployment and then deploy to azure.","Q_Score":0,"Tags":"python,azure,azure-functions,azure-web-app-service","A_Id":61745587,"CreationDate":"2020-05-11T16:00:00.000","Title":"Is there anyway to run and deploy ubuntu packages on Azure functions Startup?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I am trying to create a binary file and save it into my database. I am using REDIS and SQLALCHEMY as a framework for my database. I can use send_file to send the actual file whenever the user accesses a URL but how do I make sure that the file is saved in the route and it could stay there every time a user accesses the URL.\n\nI am sending the file from a client-python it's not in my\n  directory\n\nwhat I need in a nutshell is to save the file from the client-python to a database to \"downloadable\" it to the browser-client so it would actually be available for the browser-client is there any way of doing this? Maybe a different way that I didn't think about","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":500,"Q_Id":61735124,"Users Score":0,"Answer":"I had to encode the data with base64, send it to the database and then decode it and send the file as binary data.","Q_Score":0,"Tags":"python,database,flask,redis,sendfile","A_Id":61975147,"CreationDate":"2020-05-11T16:59:00.000","Title":"Python - save BytesIO in database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I ve tried ever IDE so far.\nDownloaded Python and now trying to download some modules and libraries.\nTrying to download Pillow with PIP.\nWhatever I try, seems that i am totally dumb.\nI type: \"python3 -m pip install --upgrade pip\" its \"invalid syntax\".\nSame whatever I type.\nCan someone help me out?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":61735639,"Users Score":1,"Answer":"The command you are trying to use to upgrade pip doesn't work for me either. I would recommend trying this one: pip install --upgrade pip\nAfter doing that you may freely use commands like\npip install library_name on whatever you want.\nThe other possible problem may be that you have to specify the version of pip you are trying to use. This is done by typing pip3 or pip3.7 (depending on the version of python) instead of just pip.\nYou may use python --version to check which version are you on.\nIf none of the commands involving pip work for you, you should reinstall\/update python without removing a tick from \"install pip\" or make sure that it is installed in the proper place, because I sometimes had a problem, when pip worked in PowerShell, but did not in CMD.","Q_Score":0,"Tags":"python,syntax,pip,installation","A_Id":61735778,"CreationDate":"2020-05-11T17:29:00.000","Title":"pip install or any other directory doesn't work, no matter what I try","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing a program in python that plays audio files from various websites, mostly mp3s. My first thought to play these files was to try streaming them with requests then decoding the chunks, seeking would be some sort of range in the request header.\nSo I've tried doing some tests with this and ran into some problems converting small chunks of data to the playable form. Before I dig in and try to fix them, I was wondering if streaming is even necessary. Is that how programs like vlc deal with it? How would you go about dealing with it?\nI did a lot of google searching and didn't come up with anything useful.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":61736687,"Users Score":1,"Answer":"Yes, if you're playing back as you're downloading, streaming is the way to go.\nThis generally doesn't require any special requests on your part.  Simply make a request, decode the data as it comes in, buffer it, and put backpressure on the stream if your buffers are getting full.\nWhat ends up happening is that the TCP window size will be reduced, slowing the speed at which the server transmits to you, until it matches the rate of playback.  (In practice, this means that the window slams to zero pretty quickly, then spurts open for a few packets and back to zero again, since internet connections these days are typically much faster than required.)\nNow, you still may want to handle ranged requests if you lose your connection.  That is, if I'm listening to audio for several minutes and then lose my connection (such as when changing from WiFi to LTE for example), your app can reconnect and request all bytes from the point at which it left off.  Browsers do this.  It becomes more important when using common HTTP CDNs which are less tolerant of connections that stay open for long periods of time.  Typically, if the TCP window size stays at zero for 2 minutes, expect that TCP connection to close.\nYou might download a copy of Wireshark or some other packet sniffer and watch what happens over the wire while you play one of these HTTP streams in VLC.  You'll get a better idea of what's going on under-the-hood.","Q_Score":0,"Tags":"python,audio-streaming","A_Id":61736925,"CreationDate":"2020-05-11T18:28:00.000","Title":"Should I Try to be Streaming mp3s","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python program and it seems that whenever I open it with this line of code active:\ncontent = open('Word_list.txt').read().splitlines() it just closes itself (by open I mean double clicking it from file explorer, works fine every other way). I tried with a small list variable and my program works file when it's like that so I need to convert a 4MB file (4,250,000 lines) into a python list variable. Is there any way to do that and will there be any slowdowns because of what i'm doing here?\nOh, and I should mention that I tried other ways of importing the text file (for loops and whatnot) and that seemed to crash instantly too. Thanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":61740822,"Users Score":0,"Answer":"I managed to use Notepad++ and their macro system to put the required \" \",'s over all of the words, completing my objecting using another program instead of python.","Q_Score":0,"Tags":"python-3.x","A_Id":61741310,"CreationDate":"2020-05-11T22:55:00.000","Title":"How do I convert a file from plain text to a list variable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently got a new PC, and was messing around with Python. I tried editing a module in the Site Packages folder, and needed to change permission on the Python folder to do so. However, after doing this, whenever I try to import a module, I get a ModuleNotFoundError. I check the sys.path list, and the path is still in there. Any suggestions as to what I could change to solve this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":61741867,"Users Score":0,"Answer":"You can always uninstall and reinstall Python.\nAlso make sure you are running your computer as an admin.","Q_Score":0,"Tags":"python,windows,module,permissions","A_Id":61741900,"CreationDate":"2020-05-12T00:43:00.000","Title":"Python not finding modules after changing permissions on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently got a new PC, and was messing around with Python. I tried editing a module in the Site Packages folder, and needed to change permission on the Python folder to do so. However, after doing this, whenever I try to import a module, I get a ModuleNotFoundError. I check the sys.path list, and the path is still in there. Any suggestions as to what I could change to solve this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":61741867,"Users Score":0,"Answer":"It happens because some of the installation packages have already left in your home directory which you tried to install python from there. They are n the form of '.package' (e.g. '.matplotlib') and as they left in the home directory python first goes there when you call the package which needs permission. You need to delete them (the ones that are NOT in the python directory!). And then each time that you call the package, Python will search for at your given PATH.","Q_Score":0,"Tags":"python,windows,module,permissions","A_Id":61741942,"CreationDate":"2020-05-12T00:43:00.000","Title":"Python not finding modules after changing permissions on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have downloaded odoo9 source code from https:\/\/www.github.com\/odoo\/odoo --depth 1 --branch 9.0 --single-branch .\n and started the odoo server but i see \"ImportError: No module named werkzeug.utils\" error.\nI tried installing with \nsudo apt-get install -y python3-werkzeug and could see it is installed successfully.\nAgain when I run the server I still see the same import issue.\nhow could I fix this import errors when I already installed them.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2913,"Q_Id":61745614,"Users Score":0,"Answer":"Odoo 9.0 is no longer supported since long ago, and it only works with Python 2, so you'd have to install python2-werkzeug instead (if available).\nOnly Odoo 11.0 and newer run under Python 3.","Q_Score":1,"Tags":"python,odoo","A_Id":61748697,"CreationDate":"2020-05-12T06:56:00.000","Title":"ImportError: No module named werkzeug.utils","Data Science and Machine Learning":0,"Database and SQL":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":"Not really a coding related question.\nI am trying to install tensorflow on Intel Xeon(R) CPU E5620 which has Ubuntu 19.10. I can't install it with pip( could someone please explain why). It does gets installed using pip but it just says,\nillegal instruction (core dumped)\nI have tried building it from the source, but that was a pretty painful process, takes way too much time. \nMy question is, is their any easier way to install tensorflow on my PC?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1396,"Q_Id":61745843,"Users Score":1,"Answer":"Try using conda environment. I have no problem installing and using tensorflow on my machine. I am using tensorflow 1.15 btw and as far as I recall I installed it using pip install tensorflow-gpu==1.15\nCpu model: Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz\nOS: Ubuntu 18.04\nconda environment python version: 3.5.6","Q_Score":0,"Tags":"python,tensorflow","A_Id":61748069,"CreationDate":"2020-05-12T07:13:00.000","Title":"How to install Tensorflow on Intel Xeon Processor based PC?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 data sets of images, one is perfect square, so resizing to 224x224 for CNN will not result in any distortion, the other dataset is not square so resizing to 224x224 will result in image distortion.\nI will split the sets to train and validation, is this a good way to train the model? will there be any bias in the model?\nI am afraid the model will identify distortion rather than the real differences between the 2 sets..","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":61746181,"Users Score":0,"Answer":"In case you want to preserve your data, you can crop it randomly and use it to transform to square. That way your model will look on the cropped part of the image. Doing so can increase your data but this is one good data if you save the transformed image. However using random crop function from from the dataloader will stream line the process. Cropping is a good augmentation technique for preprocessing the data.","Q_Score":0,"Tags":"python,machine-learning,deep-learning,neural-network,conv-neural-network","A_Id":61746227,"CreationDate":"2020-05-12T07:35:00.000","Title":"convolution neural network image size distortion","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Each morning we receive 15-20 separate emails from different sites with data attached in excel format.\nOne person then cleans the data, collates and inputs into a single spreadsheet.\nThis is a daily and very time consuming task.\nIs there a way to automate this process using python\/sql?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":61746439,"Users Score":0,"Answer":"It depends on how the Excels are formatted. Are they all the same or does actual transformation need to happen to get them into a common format? Are they actual .xls(x) files or rather .csv?\nExcel itself should have enough tools to transform the data to the desired format in an automated way, at least if the actions are the same all the time.\nFrom what I understand of your question, it's not actually needed to have the data in a database, but just combine them into a new file? Excel has the option to import data from several different formats under the \"Data\" menu option.","Q_Score":0,"Tags":"python,sql,excel","A_Id":61746698,"CreationDate":"2020-05-12T07:51:00.000","Title":"How to automate data in email\/excel to SQL?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The pretty straight forward way to do this is to upload the google-provided.html file to the root folder of your app on the server. But how to do it for a flask application?\nFor example, I have a flask app running on heroku and I want to do the site verification for my app using html file upload method(though alternative methods are available). I tried uploading the google-provided.html in the templates folder. Verification failed!\nI have searched the internet but found no relevant answers.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":414,"Q_Id":61750262,"Users Score":-1,"Answer":"Everything mentioned in the above answer is correct. But, just make sure that you don't rename the file given from google search console. Use the same name as it is.","Q_Score":0,"Tags":"python-3.x,flask,heroku,google-search-console","A_Id":68856563,"CreationDate":"2020-05-12T11:13:00.000","Title":"How to use html file upload method for google site verification for a flask app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"while programming on jupyter notebook, i keep getting an unexpected EOF line. What ist strange is that I deleted that line and still get that error for the same line.\nAny help would be greatly appreciated","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":61752743,"Users Score":0,"Answer":"@tianlinhe rightfully suggested to try \"restart and clear output\" which worked perfectly.\nI just still dont know, why craeting a new notebook didnt work.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":61758415,"CreationDate":"2020-05-12T13:18:00.000","Title":"keep getting error on line that doesnt exist anymore","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"\u0131m using pip for install a module. So working usually. But I tried install snowboy module today. I got a error. I looked up internet but didnt find solutions. \nMy ide: Pycharm 2020 with anaconda\nMy os: windows 10 x64\ncodes:\n\n(kurs) C:\\Users\\Turkmen\\Desktop\\isil>pip install snowboy\nCollecting snowboy\n  Using cached https:\/\/files.pythonhosted.org\/packages\/86\/fc\/3a13408cb3b32abff1b0539f44fca02ca378d9077b11f0c95674f278f\n3de\/snowboy-1.2.0b1.tar.gz\n    ERROR: Complete output from command python setup.py egg_info:\n    ERROR: Traceback (most recent call last):\n      File \"\", line 1, in \n      File \"C:\\Users\\Turkmen\\AppData\\Local\\Temp\\pip-install-gifo0vzi\\snowboy\\setup.py\", line 45, in \n        packages=find_packages('examples\/Python\/'),\n      File \"C:\\Anaconda3\\envs\\kurs\\lib\\site-packages\\setuptools\\__init__.py\", line 71, in find\n        convert_path(where),\n      File \"C:\\Anaconda3\\envs\\kurs\\lib\\distutils\\util.py\", line 112, in convert_path\n        raise ValueError(\"path '%s' cannot end with '\/'\" % pathname)\n    ValueError: path 'examples\/Python\/' cannot end with '\/'\n    ----------------------------------------\nERROR: Command \"python setup.py egg_info\" failed with error code 1 in C:\\Users\\Turkmen\\AppData\\Local\\Temp\\pip-install-gifo0vzi\\snowboy\\","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":351,"Q_Id":61752813,"Users Score":0,"Answer":"windows version of this module is not supported for now.","Q_Score":0,"Tags":"python,module,pycharm,installation,snowboy","A_Id":61782560,"CreationDate":"2020-05-12T13:21:00.000","Title":"Snowboy module installation error on windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm experiencing an issue while using VS Code to debug Python files. It seems that since last updating VS Code  matplotlib figures have stopped being displayed after calls of plt.show(). There are no errors reported, and the script continues to execute as though the call had been successful, so I'm not sure what the cause is.\nInitially I thought it was perhaps something to do with the backend, so I tried running in various Python environments with different matplotlib.plot backends and Python versions but no success.\nMy only though is that it's possible VS Code settings are overriding the backend or environment somehow and might be causing this behaviour?","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":7888,"Q_Id":61757455,"Users Score":-1,"Answer":"set\n\"terminal.integrated.inheritEnv\": true,\nin your user settings\n#and# then don't forget to put\nplt.show()\nat the end of your python file. Without plt.show() your images will not be dispayed.","Q_Score":8,"Tags":"python,matplotlib,visual-studio-code,vscode-settings","A_Id":68928356,"CreationDate":"2020-05-12T16:55:00.000","Title":"matplotlib figure won't show when Python is run from VS Code integrated terminal","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm experiencing an issue while using VS Code to debug Python files. It seems that since last updating VS Code  matplotlib figures have stopped being displayed after calls of plt.show(). There are no errors reported, and the script continues to execute as though the call had been successful, so I'm not sure what the cause is.\nInitially I thought it was perhaps something to do with the backend, so I tried running in various Python environments with different matplotlib.plot backends and Python versions but no success.\nMy only though is that it's possible VS Code settings are overriding the backend or environment somehow and might be causing this behaviour?","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":7888,"Q_Id":61757455,"Users Score":-1,"Answer":"while accessing the file from terminal in VSCode, Save the plot, then it will be visible\nplt.savefig('file_name.png')","Q_Score":8,"Tags":"python,matplotlib,visual-studio-code,vscode-settings","A_Id":66433583,"CreationDate":"2020-05-12T16:55:00.000","Title":"matplotlib figure won't show when Python is run from VS Code integrated terminal","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Django 3.0.5 under Kalilinux2020.1 launched from a virtual machine on VMWARE ESXI.\nI want to make my project public but it's not working.\nI modified the settings.py and add :\nALLOWED_HOSTS = ['*']\nThe django server is launched using \npyhton3 manage.py runserver 0.0.0.0:8080\nI allowed the port 8080 in the firewall using \nfirewall-cmd --zone=public --add-port=8080\/tcp \nand I forwarded the port 8080 in the router\nP.S: I can access to my server from the other machines in the VMWare (LAN) but i can't get access from outside.\nAnyone has faced this problem?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":99,"Q_Id":61759180,"Users Score":0,"Answer":"I just find out the solution,\nI changed the port to be forwarded from 8080 to 9001 and it works like charm now.\nThank you.","Q_Score":0,"Tags":"django,python-3.x,networking,firewall","A_Id":61759896,"CreationDate":"2020-05-12T18:21:00.000","Title":"Django access from outside VMWARE (Public access)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using Django 3.0.5 under Kalilinux2020.1 launched from a virtual machine on VMWARE ESXI.\nI want to make my project public but it's not working.\nI modified the settings.py and add :\nALLOWED_HOSTS = ['*']\nThe django server is launched using \npyhton3 manage.py runserver 0.0.0.0:8080\nI allowed the port 8080 in the firewall using \nfirewall-cmd --zone=public --add-port=8080\/tcp \nand I forwarded the port 8080 in the router\nP.S: I can access to my server from the other machines in the VMWare (LAN) but i can't get access from outside.\nAnyone has faced this problem?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":61759180,"Users Score":0,"Answer":"The network adapter in your VM, it should be either Brigde or NAT either way it can't be accessible other hosts","Q_Score":0,"Tags":"django,python-3.x,networking,firewall","A_Id":61759797,"CreationDate":"2020-05-12T18:21:00.000","Title":"Django access from outside VMWARE (Public access)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm connecting to teradata in python using the pyodbc module, and I keep getting this error. Anyone knows why? I'm using the below code:\nimport textwrap\nimport pyodbc\nimport teradata\nimport pandas as pd\ncnx_tera = ('DRIVER={\/Library\/Application Support\/teradata\/client\/16.20\/lib\/tdataodbc_sbu.dylib};'\n....)\ncnx = pyodbc.connect(cnx_tera)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":585,"Q_Id":61761307,"Users Score":0,"Answer":"I was facing a similar problem. Did resolve this problem using the Teradatasql package instead of ODBC, it's very simple to connect using teradatasql. Just put in the right parameters while setting up the connection for teradatasql.\nP.S.= Comment for future reference.","Q_Score":0,"Tags":"python-3.x,macos,odbc,teradata,pyodbc","A_Id":71101821,"CreationDate":"2020-05-12T20:27:00.000","Title":"pyodbc.Error: ('HY000', '[HY000] [Teradata][ODBC] (11560) Unable to locate SQLGetPrivateProfileString function. (11560) (SQLDriverConnect)')","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I optimized my code to process images with pillow. It uses all the sources to get as fast as possible. Just the GPU would make it faster. I don't find any solution beside CUDA and that wont't work on Catalina. Is there any way to use my GPU(NVIDIA GeForce GT 750M 2 GB\nIntel Iris Pro 1536 MB) to make the process more efficient?\nThanks for your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":705,"Q_Id":61761582,"Users Score":0,"Answer":"Actually there is no way to use pillow to do that! If you need a better speed, you can use ImageMagick (Wand as python wrapper) or GraphicsMagick (pgmagick as Python wrapper). If you need to use GPU, ImageMagick gives some option to use it if possible (I am not sure about GM) but it is not neither as efficient nor complete as you use CUDA or OpenCL. I recommend you to use Vulkan if you need better result and cross platform (Nvidia and AMD, MacOS, Linux Windows...).","Q_Score":1,"Tags":"python,macos,gpu,python-imaging-library,macos-catalina","A_Id":61761902,"CreationDate":"2020-05-12T20:45:00.000","Title":"Use GPU for PIL in python on mac (macOS Catalina)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a new programmer that started learning Python, but there's something bothering me which I'd like to change.\nAs I've seen that it is possible to remove the unwanted path from the terminal when executing code, I cannot figure out how to access the Visual Studio Code launch.json file and all of the explanations on Google are quite confusing.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":19824,"Q_Id":61761968,"Users Score":2,"Answer":"Note that if Visual Studio Code hasn't created a launch.json file for your project yet, do the following:\n\nClick the Run | Add Configuration menu option, and one will automatically be generated for you, and opened in the editor.","Q_Score":5,"Tags":"python","A_Id":71313275,"CreationDate":"2020-05-12T21:08:00.000","Title":"How do I open the 'launch.json' file in Visual Studio Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've created a Python simple server.py and client.py chat.\nI was wondering if it is possible to deploy server.py on heroku so that it's always running and I can access the server from any client.py at any time.\nI've tried deploying the simple server.py to heroku but it doesn't print anything in the logs section and it seems like it didn't even start the code as it should print \"server on\" but it doesn't.\nI think that I'm missing something in the Procfile or in the requirements.txt file.\nIs there another way to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":61762007,"Users Score":0,"Answer":"Try heroku ps:scale web=1 so your dyno can work","Q_Score":0,"Tags":"python,sockets,heroku,server","A_Id":61807922,"CreationDate":"2020-05-12T21:11:00.000","Title":"python heroku socket 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":0,"Web Development":1},{"Question":"Thank you everybody for the help but I deleted the program for my project. I didn't want anyone using this. Again, Thank you for your help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":61763927,"Users Score":1,"Answer":"If you pay close attention to the error message you will see that the error is actually being thrown by the vlc code. Which implies that the output from the TTS speech is not what vlc is expecting. \nYou need to break up your code and first verify what output you are getting from TTS. If it is audio, then you can work out how the vlc code expects it. I suspect it not in the format that the TTS is outputting.\n\nUpdated answer\n\nThe output from TTS is a data stream of audio content, in Python this will be a byte array. It looks as though VLC is looking for a string. This makes no sense if VLC is looking for audio data. If however, it was looking for a string, then that string could be a file destination. So I think you need to write the file, and give the file destination to VLC.\n\n\nIMHO based on the question you are asking and the code you have cobbled together, your coding skills are not up to the challenge, and you maybe better off spending a couple of weeks going through some Python coding tutorials. You may find the investment in training time pays off without you struggling with what are quite fundamental coding issues here.","Q_Score":0,"Tags":"python,string,byte,text-to-speech,vlc","A_Id":61772255,"CreationDate":"2020-05-12T23:44:00.000","Title":"Creating a simple IBM Assistant using their TTS and STT. I get a Bytes and Strings error. I am using VLC to play audio. How can I fix this?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to install Beautiful Soup 4, but every tutorial or list of instructions seems to assume I know more than I do. I am here after a number of unsuccessful attempts and at this point I am afraid of damaging something internally.\nApparently I need something called pip. I have Python 3.8, so everyone says I should have pip. Great. I have found no less than 14 different ways to check if I actually have pip and am using it. They all say to type something. One of them said to type pip --version. We are already assuming too much. Where do I type it? IDLE? The Cmd prompt? The Python shell? What folder do I need to be in? Etc Etc. I need someone to assume I am a complete beginner.\nThen, how do I use it to install bs4? Again, I am supposed to type things, but no one says where. One person said to go to the folder where python is installed in the command line. So, I did, and surprise surprise, pip is not \"valid syntax\". How can I proceed with this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":239,"Q_Id":61765096,"Users Score":0,"Answer":"With a little help from the kind user Tenacious B, I have solved my problem, I think. In the command prompt, I needed to type \ncd C:\\Users\\%userprofilenamegoeshere%\\AppData\\Local\\Programs\\Python\\Python38-32\\scripts \nNo source that I found in my initial search included that last bit: \\scripts. From here, the common suggestion of pip install beautifulsoup4 seems to have worked.","Q_Score":0,"Tags":"python,beautifulsoup,pip","A_Id":61765420,"CreationDate":"2020-05-13T01:59:00.000","Title":"How to install Beautiful Soup 4 without *any* assumptions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using sublime text 3 and I want to run ipynb files. I have installed helium. In the document, it says to execute a block I should execute Helium: Execute Block in the command palette. But can't seem to find that command.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":798,"Q_Id":61766361,"Users Score":1,"Answer":"Step 1.) run %connect_info in a localhosted jupyter notebook and copy the json output\nStep 2.) In sublime text editor, press \"Ctrl+shift+P\" and type hermes: start kernel and copy paste this json you copied from step 1.\nYou should see a blank page popout.\nStep 3.) Open your py file you want to execute, and select the lines you want to execute using mouse and again press \"Ctrl+shift+P\" and type hermes: execute cell (you will see an option now), click on that and your output should run on the black page which popped out in step 2.\nNote : If your localhost jupyter notebook is running in a specific folder, make sure that the py file you want to run using helium\/hermes is under that jupyter notebook access, basically the py file has to be under the same folder you ran jupyter from.","Q_Score":1,"Tags":"ipython,sublimetext3,helium","A_Id":63818323,"CreationDate":"2020-05-13T04:18:00.000","Title":"Unable to run helium with sublime 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to classify a list of documents. I'm using CountVectorizer and TfidfVectorizer to vectorize the documents before the classification. The results are good but I think that they could be better if we will consider not only the existence of specific words in the document but also the order of these words. I know that it is possible to consider also pairs and triples of words but I'm looking for something more inclusive.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":61767647,"Users Score":0,"Answer":"Believe it or not, but bag of words approaches work quite well on a wide range of text datasets. You've already thought of bi-grams or tri-grams. Let's say you had 10-grams. You have information about the order of your words, but it turns out there are rarely more than one instance of each 10-gram, so there would be few examples for your classification model to learn from. You could try some other custom feature engineering based on the text, but it would be a good amount of work that rarely help much. There are other successful approaches in Natural Language Processing, especially in the last few years, but they usually focus on more than word ordering.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn","A_Id":61783485,"CreationDate":"2020-05-13T06:17:00.000","Title":"classification of documents considering the order of words","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to run multiple Python versions on SQL Sever 2017?\nIt is possible to do on Windows (2 Python folders, 2 shortcuts, 2 environment paths). But how to launch another Python version if I run Python via sp_execute_external_script in SQL Management Studio 18?\nIn SQL server\\Launchpad\\properties\\Binary path there is the parameter -launcher Pythonlauncher. Probably, by changing this, it is possible to run another Python version.\nOther guess: to create multiple Python folders C:\\Program Files\\Microsoft SQL Server\\MSSQL14.MSSQLSERVER\\PYTHON_SERVICES. But how to switch them?\nOther guess: in C:\\Program Files\\Microsoft SQL Server\\MSSQL14.MSSQLSERVER\\MSSQL\\Binn\\pythonlauncher.config - in PYTHONHOME and ENV_ExaMpiCommDllPath parameters substitute the folder C:\\Program Files\\Microsoft SQL Server\\MSSQL14.MSSQLSERVER\\PYTHON_SERVICES\\ with the folder with new Python version.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":250,"Q_Id":61768356,"Users Score":1,"Answer":"The answer is:\n\nCopy in \n\n\nC:\\Program Files\\Microsoft SQL Server\\MSSQL14.MSSQLSERVER\\\n\nfolder as many Python versions as you want (Python version = folder with Python like PYTHON_SERVICES)\n\nStop Launchpad\nChange in \n\n\nC:\\Program Files\\Microsoft SQL\n  Server\\MSSQL14.MSSQLSERVER\\MSSQL\\Binn\\pythonlauncher.config\n\nfile: in PYTHONHOME and ENV_ExaMpiCommDllPath parameters substitute the folder \n\nC:\\Program Files\\Microsoft SQL\n  Server\\MSSQL14.MSSQLSERVER\\PYTHON_SERVICES\\\n\nwith the folder with new Python version.\n\nStart Launchpad","Q_Score":1,"Tags":"python,sql-server,microsoft-machine-learning-server","A_Id":61793948,"CreationDate":"2020-05-13T07:06:00.000","Title":"Run multiple python version on SQL Server (2017)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to import \nimport tensorflow.python.keras.applications.MobileNetV2\nbut it gives the bellow error:\nModuleNotFoundError: No module named 'tensorflow.python.keras.applications.MobileNetV2'\nmy tensorflow version is 1.8.0\nand keras version is 2.2.0","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":6144,"Q_Id":61768883,"Users Score":-1,"Answer":"Try using the following:\nfrom tensorflow.keras.applications.mobilenet_v2 import preprocess_input","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":69853083,"CreationDate":"2020-05-13T07:37:00.000","Title":"ModuleNotFoundError: No module named 'tensorflow.python.keras.applications.MobileNetV2'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to combine gcloud VMs and Google Colab using the local runtime connection.\ngcloud compute ssh [Instance] --zone [ZONE] -- -L 8080:localhost:8080 -N -T\nConnection is established but the runtime appears as \"busy\" on colab. I am pretty sure that nothing is running on the VM.\nAny ideas ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":199,"Q_Id":61769565,"Users Score":0,"Answer":"You can mount GDrive and access files from both sides.","Q_Score":0,"Tags":"python,ssh,google-colaboratory,gcloud","A_Id":61834075,"CreationDate":"2020-05-13T08:17:00.000","Title":"How do I connect a Gcloud Virtual Machine to Colab using a local connection?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have the file EnergyIndicators.xls, which I want to read into python so I can manipulate it.\nHow can I obtain the file path so I can read the file in using the:\npd.read_excel() function?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":426,"Q_Id":61773893,"Users Score":0,"Answer":"Firstly you need to know the path to the file in your file system.\nThen you just simply pass the path to xls file to read_excel function.\n\npd.read_excel('path\/to\/direct\/EnergyIndicators.xls')","Q_Score":1,"Tags":"python,pandas,file,filepath,xls","A_Id":61774139,"CreationDate":"2020-05-13T11:51:00.000","Title":"File path for excel file","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried crontab -e.\n@reboot python3 \/home\/hyebin\/project\/tensorrt_demos\/trt_ssd.py --model ssd_mobilenet_v2_face --usb --vid 1 --width 1280 --height 780\n1.Do I just have to add it to the bottom line of the crontab -e?\n2. Is it okay to have additions, such as '--model'?\n3. What should I do if we have such additions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":169,"Q_Id":61774546,"Users Score":1,"Answer":"it's better to use absolute paths in crontab rather that just python3.\nexample:\n@reboot  \/path\/to\/command arg1 arg2\nit should work fine with arguments such as --model\nto find your absolute path to python3 you can run which python3 and use that","Q_Score":0,"Tags":"python,nvidia-jetson","A_Id":61774949,"CreationDate":"2020-05-13T12:22:00.000","Title":"How do I run Python scripts automatically on Jetson TX2?","Data Science and Machine Learning":0,"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 DAHUA Thermal Camera\nCamera can provide two streams (Color_Stream + Thermal_Stream).\nI am getting the color stream from my thermal camera in python through the given URL with cv2.VideoCapture() function (keeping channel=1 in the URL)\n\nrtsp:\/\/admin:admin@10.7.6.67:554\/cam\/realmonitor?channel=1&subtype=0\n\nand thermal stream with the given URL (keeping channel=2 in the URL)\n\nrtsp:\/\/admin:admin@10.7.6.67:554\/cam\/realmonitor?channel=2&subtype=0\n\nIs there a way that I can get both of the streams together? (by calling only one function)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":318,"Q_Id":61775836,"Users Score":0,"Answer":"I have not tried this with an IP camera. But perhaps what you can try is using 2 threads to open the 2 streams. Then you may be able to fetch both streams. If that does not work, you can try switching between streams alternately, if it helps","Q_Score":0,"Tags":"python,opencv,video-capture,ip-camera,opencv-python","A_Id":66982485,"CreationDate":"2020-05-13T13:24:00.000","Title":"Is there a way to get the both main stream and sub stream together in opencv python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've recently started exploring for myself features columns by TensorFlow. \nIf I understood documentation right, feature columns are just a 'frame' for further transformations just before fitting data to the model. So, if I want to use it, I define some feature columns, create DenseFeatures layer from them, and when I fit data into a model, all features go through that DenseFeatures layer, transforms and then fits into first Dense layer of my NN.\nMy question is that is it possible at all somehow check correlations of transformed features to my target variable? \nFor example, I have a categorical feature, which corresponds to a day of a week (Mon\/Tue...\/Sun) (say, I change it to 1\/2..7). Correlation of it to my target feature will not be the same as correlation of categorical feature column (f.e. indicator),  as a model don't understand that 7 is the maximum of the possible sequence, but in case of categories, it will be a one-hot encoded feature with precise borders.\nLet me know if all is clear.\nWill be grateful for the help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":181,"Q_Id":61776353,"Users Score":0,"Answer":"Tensorflow does not provide the feature_importance feature with the way Sklearn provides for XGBoost.\nHowever, you could do this to test the importance or correlation of your feature with the target feature in TensorFlow as follows.\n1) Shuffle the values of the particular feature whose correlation with the target feature you want to test. As in, if your feature is say fea1,the value at df['fea1'][0] becomes the value df['fea1'][4], the value at df['fea1'][2] becomes the value df['fea1'][3] and so on.\n2) Now fit the model to your modified training data and check the accuracy with validation data.\n3) Now if your accuracy goes down drastically, it means your feature had a high correlation with the target feature, else if the accuracy didn't vary much, it means the feature isn't of great importance (high error = high importance).\nYou can do the same with other features you introduced to your training data.\nThis could take some time and effort.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,tensorflow2.0","A_Id":61776929,"CreationDate":"2020-05-13T13:46:00.000","Title":"Correlations of feature columns in TensorFlow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was able to train a model with the python TensorFlow API following some tutorials. \nI also managed to freeze the model from the latest checkpoints.\nHowever, I wanted to have the best instead of the latest model, so I checked to get the best models written to the disc. At last, I found it in a \"saved model\" format and now I want to convert it to a frozen model. I think this should be something straight forward. \nIt might be a stupid question but I already spent some hours looking for a simple way.\nYour help would be much appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":61776651,"Users Score":0,"Answer":"When you save a model, it is done i.e. it is frozen. Its weight won't change. Usually, during testing, you will instantiate your model and then load the saved i.e. frozen model and run predictions on it.\nIf you don't want the network to learn after you load your frozen model weights, then, go to model.layers and set the trainable false for every layer.\nmodel.load_weights(checkpoint_path) is used for loading weights.","Q_Score":0,"Tags":"python,tensorflow","A_Id":61778281,"CreationDate":"2020-05-13T13:59:00.000","Title":"Freezing a saved tensorflow model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I type pip install pygame or pip3 install pygame on terminal, it says \"check the logs for full command output\". I already upgraded pip and it still says that. Can you tell me what this means and how to fix it?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2261,"Q_Id":61776771,"Users Score":2,"Answer":"You can try running the pip command by adding the --verbose flag. This will print out the logs in the Terminal, which you then can inspect. These logs often help you indicate the cause of the error.\nFor example:\npip install --verbose pygame\nor\npip3 install --verbose pygame","Q_Score":4,"Tags":"python,python-3.x,pip","A_Id":69160098,"CreationDate":"2020-05-13T14:06:00.000","Title":"What do I do when the terminal says \"Check the logs for full command output\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I type pip install pygame or pip3 install pygame on terminal, it says \"check the logs for full command output\". I already upgraded pip and it still says that. Can you tell me what this means and how to fix it?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2261,"Q_Id":61776771,"Users Score":0,"Answer":"When you get this message, there will be a few lines above it which tell you where the log file is and some more details about what went wrong.","Q_Score":4,"Tags":"python,python-3.x,pip","A_Id":69160187,"CreationDate":"2020-05-13T14:06:00.000","Title":"What do I do when the terminal says \"Check the logs for full command output\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to write a python script using cx_oracle module for perform oracle database connection. But during the execution, I found it needs oracle instant client to establish a connection. Currently, I'm developing the script in ubuntu but there is a chance to run the same in windows. So I'm confused about the implementation. Could someone please suggest the best way to connect oracle database irrespective the platform","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":59,"Q_Id":61778052,"Users Score":1,"Answer":"You will always need an OS-specific library or client of some kind. Either the Oracle Instant Client or a Java JDK\/JDBC library or both. If you want OS-independence then you would need to interact with the DB through REST calls or something like that instead of making a persistent connection. Otherwise you have to interact with the OS networking stack at some point, which requires OS-specific libraries.","Q_Score":0,"Tags":"python,oracle,cx-oracle","A_Id":61778880,"CreationDate":"2020-05-13T15:03:00.000","Title":"How to connect oracle database in python irrespective of operating system","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is a bit of Matlab code id like to automate with an existing Python Project (through their supplied API which only runs on python v3.4 for my particular Matlab version). The Project im trying to build it into uses python 3.6.\nIs there a way in which a Python 3.6 process can call a Python 3.4 process and intercommunicate with it in a relatively non hacky way?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":46,"Q_Id":61779481,"Users Score":-1,"Answer":"If you don't need Python 3.6, you can just downgrade your version to match the 3.4 needed by Matlab.  Other parts of the Python project might be affected though too, but this depends on how big the existing project is and what it's doing.","Q_Score":0,"Tags":"python,matlab-engine","A_Id":68492750,"CreationDate":"2020-05-13T16:08:00.000","Title":"Python 3.6 <-> Python 3.4 intercommunication","Data 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 could I force vscode to always find and prefer pipenv's virtual environment for python instead of the python's global settings?\nWhen I create a pipenv environment on my workspace, it keeps using the global python version at \/usr\/bin\/python (as defined in settings as \"python.pythonPath\": \"\/usr\/bin\/python\") but I wonder how could I switch to something like ~\/.local\/share\/virtualenvs\/Selenium-10eAXqZ4\/bin\/python automatically when there is Pipenv environment detected.\nIs this even possible? If this is how can I configure it?\n(I'm not talking about simply overriding the python.pythonPath with local .vscode\/settings.json I need this to detect the path from pipenv automatically when it exists for the current project)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1455,"Q_Id":61779730,"Users Score":4,"Answer":"Add PIPENV_VENV_IN_PROJECT=1 to your environment and the .venv folder will be added to your project root. VSCode has zero problems picking up Python from there. (I find it also very convenient to have everything in one place and not spread around on the entire disk.)","Q_Score":5,"Tags":"python,visual-studio-code,vscode-settings,pipenv","A_Id":61782422,"CreationDate":"2020-05-13T16:21:00.000","Title":"Use pipenv whenever possible in vscode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python and I am currently trying to install the Bloomberg python blpapi package.\nTo do so I first need to install the Bloomberg C++ SDK. In order to do so I have:\n\nDownloaded the Windows experimental package from [bloomberg.com\/professional\/support\/api-library][1]\nI also set up the environment variables accordingly\nExtracted the package to C:\\blp\\API\nI then opened command prompt (CMD.exe) and set BLPAPI_ROOT=C:\\blp\\API\nChanged directory to package folder: C:\\blp\\API\\blpapi_cpp_3.14.3.1\n\nThe problem arises when I now have to run the command to install the package: python setup.py install\nI get the error \"python can't open file 'setup.py': [Errno 2] No such file or directory\"\nI googled the error and found out that each package has to have a setup.py file in order to be installed\nWhat does one do in this case?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":48,"Q_Id":61779744,"Users Score":1,"Answer":"You might have set up your BLPAPI_ROOT to the right path which is the folder containing C++API but you must run python setup.py install in the Python API folder.\nThese are 2 different steps.","Q_Score":0,"Tags":"python,bloomberg","A_Id":64361789,"CreationDate":"2020-05-13T16:21:00.000","Title":"setup.py file not included with package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have 2 dataframes in Spark 2.4, they are close to the same size. Each has about 40 million records. One is generated simply by loading the dataframe from S3, the other loads a bunch of dataframes and uses sparkSQL to generate a big dataframe. Then I join these 2 dataframes together multiple times into multiple dataframes and try to write them as CSV to S3... However I am seeing my write times upwards of 30 minutes, I am not sure if it is re-evaluating the dataframe or if perhaps I need more CPUs for this task. Nonetheless, I was hoping someone may have some advice on how to optimize these write times.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1337,"Q_Id":61780798,"Users Score":0,"Answer":"So when a dataframe is created from other dataframes it seems an execution plan is what is first created. Then when executing a write operation that plan gets evaluated. \nThe best way to take care of this particular situation is to take advantage of the spark lazy-loading caching (I have not seen an eager-loading solution for spark but if that exists it could be even better). \nBy doing:\ndataframe1.cache()\nAnd\ndataframe2.cache()\nwhen you join these 2 dataframes the first time both dataframes are evaluated and loaded into cache. Then when joining and writing again the 2 dataframe execution plans are already evaluated and the join and write becomes much faster.\nThis means the first write still takes over 30 minutes but the other 2 writes are much quicker.\nAdditionally, you can increase performance with additional CPUs and proper paritioning and coalesce of the dataframes. That could help with the evaluation of the first join and write operation.\nHope this helps.","Q_Score":0,"Tags":"python,scala,apache-spark","A_Id":61780799,"CreationDate":"2020-05-13T17:15:00.000","Title":"How to speed up large data frame joins in Spark","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Mid-last year bitbucket released support for automated aws lambda deployments. However, it seems that it only works for the most rudimentary of use cases.\nMy use case:\n1) My lambda functions are too big to update the lambda function directly with a zip, I need to upload that zip to an s3 bucket first and then update the lambda function\n2) I require quite a few python dependencies (numpy pandas etc) that need to be compiled on an awslinux docker image for them to work on lambda.\nHow are others managing automated deployment from bitbucket to aws lambda with a similar use case?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":61782640,"Users Score":0,"Answer":"I would suggest taking a look at the Serverless Framework. It has a CLI tool that allows you to compose an entire Serverless service by configuring various managed services and Lambda together and then easily deploy with a single command: serverless deploy. This can then be used in something BitBucket Pipelines to automate deployment when changes to configuration have been made. \nAlternatively, I know the Serverless Framework has a CI\/CD feature built into their Serverless Framework Pro dashboard that supports GitHub and will soon support BitBucket as well. \nIf you need some help getting started they have a tone of learning materials and documentation at serverless.com","Q_Score":0,"Tags":"python,deployment,aws-lambda,bitbucket-pipelines,docker-image","A_Id":61790744,"CreationDate":"2020-05-13T18:54:00.000","Title":"Bitbucket deployments no support for s3-based lambda 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using Nifi, I want to:\n\nrun a Python script that exports a pandas dataframe\nsend it e.g. through ExecuteStreamCommand to a variety of plug-and-play Python scripts that both input and output pandas dataframes, not knowing they are running via Nifi and which I cannot modify to use STDIN\/STDOUT instead of pandas.\npass the output dataframe on for further processing.\n\nIs this possible? If so, how?\nPut another way:\n\nFirst Script: flowfile -> pandas\nMany Scripts: do stuff with pandas\nLast Script: pandas -> flowfile","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":823,"Q_Id":61785013,"Users Score":6,"Answer":"NiFi's ExecuteScript supports Jython, which does not allow Python native libraries (pandas is a native library), so you cannot perform this action directly in NiFi. I'd recommend you write an encompassing Python shell script which performs the following actions and invoke it from NiFi using the ExecuteStreamCommand processor:\nPython wrapper script:\n\nAccept input from STDIN (this will be the flowfile content)\n\n\nYou can also put flowfile attributes on the command line as arguments using the \"Command Arguments\" property of the ESC processor\n\nConvert the STDIN input to a pandas dataframe\nPass the dataframe between the arbitrary Python scripts which will have no knowledge of NiFi\nOutput the final dataframe as STDOUT\n\nThis will allow the incoming flowfile content to be sent to this wrapper script, all the internal modifications made using the included scripts, and then the output to be translated from STDOUT back to flowfile content.","Q_Score":2,"Tags":"python,pandas,dataframe,apache-nifi","A_Id":61786176,"CreationDate":"2020-05-13T21:16:00.000","Title":"How can I pass a pandas dataframe in Nifi from processor to processor?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using discord.py to make a bot, and there are more commands than can fit on one page for my custom help command. I want the bot to add 2 reactions, back and forward, then the user that sent the help message can pick one, and go onto different pages of the help command. I want the bot to be able to edit the message to show the second page, and if they go back, then edit back to the original first page. Could anyone help with this? This is similar to the owobot definitions, where you can scroll back and forth between definitions.","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":9726,"Q_Id":61787520,"Users Score":-2,"Answer":"If you're using client.command() instead of bot.command() replace the two variables bot to client.","Q_Score":7,"Tags":"python,discord.py","A_Id":65416751,"CreationDate":"2020-05-14T01:08:00.000","Title":"I want to make a multi-page help command using discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sorry if this is worded badly or has a simple solution but I'm completely new to all this. So I was working on a GitHub pages site in pycharm and used terminal to push to files to GitHub, but I think I messed up something with the directory, and my files in other pycharm projects in separate folders are now highlighted in red. I also get prompted to push to GitHub when creating a new file which didn't happen before.\nTo clarify, inside a \"pycharm projects\" folder are separate \"git hub pages\" and \"some project\" folders. Anyone know where I can begin to fix this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":61789073,"Users Score":0,"Answer":"Try first and clone your GitHub page repository again, and import it in PyCharm.\nThen modify a file, and check the push is working again as expected.\nFinally, report the modifications you were doing in your original cloned repository into this new clone.","Q_Score":1,"Tags":"python,git,github,terminal,pycharm","A_Id":61790004,"CreationDate":"2020-05-14T03:58:00.000","Title":"Remove unrelated files from Git?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am implementing a MultiLayer Perceptron , I am extracting the features of images using SIFT algorithm of image processing and I pass those features to the neural network , the features of images that I am considering are descriptors ,every image has different length of descriptors , some image has 200 descriptors and some image has 240 descriptors , means it's varying . But neural networks accepts fixed size of input data .\nHow can I pass this type of input to it if it accept varied input then how ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":61790496,"Users Score":0,"Answer":"I think you could try to pad your data to a fixed size(like the maximum length of your descriptors) vector with all 0 or mean value of this vector.","Q_Score":0,"Tags":"python,machine-learning,image-processing,deep-learning,computer-vision","A_Id":61790560,"CreationDate":"2020-05-14T06:11:00.000","Title":"Do neural networks accepts other than fixed size of input data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suddenly the navigator stop working, I reinstalled it several times but each time when I double click it, it again goes to the installing process. I have even tried the older versions of python as well as the python 3.8 to build a supportive environment for navigator but it doesn't help. Anaconda prompt also not responding to any command.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":466,"Q_Id":61790748,"Users Score":1,"Answer":"You need to provide more details such as your OS (Linux, Mac or Windows) and your Anaconda Navigator version.","Q_Score":0,"Tags":"python,installation,anaconda,python-module,anaconda3","A_Id":61790825,"CreationDate":"2020-05-14T06:32:00.000","Title":"Anaconda navigator is not responding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are trying to fetch event and calendar information for user through Graph API. User is present on Azure Active directory and has active o365 subscription. \/events or \/calendar APIs  are not working. Is it possible to do so through non work premium Microsoft accounts?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":61790857,"Users Score":0,"Answer":"you mention its a personal premium account, then you say user is present in azure ad.. there are a few conflicting statements here, if you could clarify, \nthere are no such thing as a personal premium account. Microsoft 365 is either business premium, personal or family. there is no personal premium.. \nIf it is a personal office 365 account, then it does not have Azure ad. and you can only grab limited data for that user through graph, by using the \/me endpoint. i would highly doubt that you could access a personal account's calendar.\nif you are talking about a business premium account, then that comes with azure ad, and you should be able to interact with the users through graph as per documentation. but you would still need to grant more permissions for calendar for example to read someone elses calendar. \nIf it is a personal o365 account that you added to a different o365 business tenant, that user still does not belong to your tenant, because at its base its still a personal account with no real azure ad tenant. \nhopefully that clarifies a bit.","Q_Score":0,"Tags":"python,graph,microsoft-graph-api,azure-ad-graph-api","A_Id":61798846,"CreationDate":"2020-05-14T06:37:00.000","Title":"Is it possible to fetch user event data using Graph API for personal premium Microsoft accounts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am creating a python system that needs to handle many files. Each of the file has more than 10 thousand lines of text data. \nBecause DB (like mysql) can not be used in that environment, when file is uploaded by a user, I think I will save all the data of the uploaded file in in-memory-SQLite so that I can use SQL to fetch specific data from there. \nThen, when all operations by program are finished, save the processed data in a file. This is the file users will receive from the system.\nBut some websites say SQLite shouldn't be used in production. But in my case, I just save them temporarily in memory to use SQL for the data. Is there any problem for using SQLite in production even in this scenario?\nEdit:\nThe data in in-memory-DB doesn't need to be shared between processes. It just creates tables, process data, then discard all data and tables after saving the processed data in file. I just think saving everything in list makes search difficult and slow. So using SQLite is still a problem?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":360,"Q_Id":61791427,"Users Score":0,"Answer":"I'm not familiar with the specific context of your system, but if what you're looking for is a SQL database that is \n\nlight\nAccess is from a single process and a single thread. \nIf the system crashes in the middle, you have a good way to recover from it (either backing up the last stable version of the database or just create it from scratch). \n\nIf you meet all these criteria, using SQLite is production is fine. OSX, for example, uses sqlite for a few purposes (e.g. .\/var\/db\/auth.db).","Q_Score":0,"Tags":"python,sqlite","A_Id":61792249,"CreationDate":"2020-05-14T07:14:00.000","Title":"in-memory sqlite in production with python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating a python system that needs to handle many files. Each of the file has more than 10 thousand lines of text data. \nBecause DB (like mysql) can not be used in that environment, when file is uploaded by a user, I think I will save all the data of the uploaded file in in-memory-SQLite so that I can use SQL to fetch specific data from there. \nThen, when all operations by program are finished, save the processed data in a file. This is the file users will receive from the system.\nBut some websites say SQLite shouldn't be used in production. But in my case, I just save them temporarily in memory to use SQL for the data. Is there any problem for using SQLite in production even in this scenario?\nEdit:\nThe data in in-memory-DB doesn't need to be shared between processes. It just creates tables, process data, then discard all data and tables after saving the processed data in file. I just think saving everything in list makes search difficult and slow. So using SQLite is still a problem?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":360,"Q_Id":61791427,"Users Score":2,"Answer":"SQLite shouldn't be used in production is not a one-for-all rule, it's more of a rule of thumb. Of course there are appliances where one could think of reasonable use of SQLite even in production environments.\nHowever your case doesn't seem to be one of them. While SQLite supports multi-threaded and multi-process environments, it will lock all tables when it opens a write transaction. You need to ask yourself whether this is a problem for your particular case, but if you're uncertain go for \"yes, it's a problem for me\". \nYou'd be probably okay with in-memory structures alone, unless there are some details you haven't uncovered.","Q_Score":0,"Tags":"python,sqlite","A_Id":61791554,"CreationDate":"2020-05-14T07:14:00.000","Title":"in-memory sqlite in production with python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python bot which I'm hosting on digital ocean. \nRight now to run it persistently I'm using virtual terminal screen and I see that this way is far from stable. \nHow I can schedule my bot script to run forever and being re-run if it crashes ? \nAnd also how I can schedule some other python scripts to run once in an hour ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1287,"Q_Id":61792661,"Users Score":1,"Answer":"You can use crontab to schedule process.\nTo run hourly, you can use like this\n\n0 * * * * \/my\/program\/path\n\n(minute, hour, day of month, month, day of week)","Q_Score":1,"Tags":"python,ubuntu,telegram-bot","A_Id":61793989,"CreationDate":"2020-05-14T08:26:00.000","Title":"Run Python script persistently on 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 recently installed Kite for Spyder 4. I think I wanted to give it a try for several weeks and see how it performs.\nOne feature called Kite-copilot annoys me, it pops up whenever I opened spyder. I don't really use that feature much since it is in the new window (it would cover my workspace if it is always on top, and it would be covered by spyder if it didn't).\nSo is there a way to disable this particular feature? I know I can just close it right away whenever it pops out, but it is kinda annoying that I always need to close it first whenever I opened spyder.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1206,"Q_Id":61794077,"Users Score":0,"Answer":"On MacBook switch off kite for current session: at the top right of the screen (top menu bar where your wifi shows etc) locate the kite icon. Right click on it and select 'quit kite'. You will see in Spyder at the bottom (just below Console) the Kite status should switch to 'Kite: not running'.","Q_Score":1,"Tags":"python,spyder,kite","A_Id":71847942,"CreationDate":"2020-05-14T09:38:00.000","Title":"How to Disable Kite Copilot Feature?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I understand List use square brackets, but what does it mean when [] is inside a ()?\nWould be great if someone could clarify for me. Thanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":61794474,"Users Score":1,"Answer":"It's a passing of [1, 3, 3] list to whatever has_3 is (could be any callable - function, class, lambda) as a first argument.","Q_Score":0,"Tags":"python","A_Id":61794549,"CreationDate":"2020-05-14T09:59:00.000","Title":"What does 'has_3([1, 3, 3])' mean in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've only started doing python3 for a paper at university. I don't plan on continuing after this semester is over but I want to do the best I can in this class. However, I am having difficulties with seemingly a basic task.\nI've opened a file using f = open() and I've accessed it in the terminal using less. It displays everything out nicely but it doesn't let me close the file or even continuing to code past the printed text. \nIt just repeats ~ on separate lines and finishes with a highlighted (END)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":173,"Q_Id":61794840,"Users Score":0,"Answer":"By typing q, you will be able to exit it","Q_Score":0,"Tags":"python-3.x,file","A_Id":61797574,"CreationDate":"2020-05-14T10:17:00.000","Title":"How do I close a file in the terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have downloded python 3.8 and idle want to execute the full code at single time. I also tried copying and then pasting and executing then it is saying syntax error \"found multiple statements when trying to execute single statement\".","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":17,"Q_Id":61796254,"Users Score":0,"Answer":"I think your are trying to execute in the console with multiple lines, please run in terminal after saving the file. Locate your terminal in python file path and give python  in terminal","Q_Score":1,"Tags":"python,python-3.x,python-3.8","A_Id":61796355,"CreationDate":"2020-05-14T11:29:00.000","Title":"It is not running statements at one time. like the runtime in sololearn","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I finally got to the point where I can build, error-free, a Python Kivy APK with Buildozer 1.0.\nI build 2 sample apps, one with basic Python code, another with additional Python package (paho-mqtt).\nI can install the APK with mqtt but when run, it closes immediatelly. \nThe basic Python app will not even install.\nThe smartphone is a Nokia 6.1 with Android 10.\nAs said I am using buildozer 1.0, Python 3.8.2, openjdk 1.8.0_252, Android NDK r19c running on Ubuntu 20.04 Desktop 64bit (in VirtualBox 6.1).\nAre compatibility issues among above? Can it be solved? How?\nNB: As my smartphone is not recognised by Buildozer when hooked up with USB to VM, I download the APK using 'buildozer' serve and the Chrome browser on my smartphone.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":347,"Q_Id":61797187,"Users Score":0,"Answer":"Have you tried running it on android 9?\nI also have similar issue where app working on 9 but failing on android 10.","Q_Score":1,"Tags":"python,android,kivy,apk,buildozer","A_Id":62112323,"CreationDate":"2020-05-14T12:19:00.000","Title":"Python Kivy-Buildozer APK not installing - running on Android 10?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a json file with over 16k urls of images, which I parse using a python script and use urllib.request.urlretrieve in it to retrieve images. I uploaded the json file to google drive and run the python script in google Colab.\nThough the files were downloaded (I checked this using a print line in the try block of urlretrieve) and it took substantial time to download them, I am unable to see where it has stored these files. When I had run the same script on my local machine, it stored the files in the current folder.\nAs an answer to this question suggests, the files may be downloaded to some temporary location, say, on some cloud. Is there a way to dump these temporary files to google drive?\n(*Note I had mounted the drive in the colab notebook, still the files don't appear to be stored in google drive)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1309,"Q_Id":61798141,"Users Score":1,"Answer":"Colab stores files in some temp location which is new every time you run the notebook. If you want your data to persist across sessions you need to store it in GDrive. For that you need to map some GDrive folder in your notebook and use it as path. Also, you need to give the Colab permissions to access your GDrive","Q_Score":0,"Tags":"python,url,google-colaboratory","A_Id":61798564,"CreationDate":"2020-05-14T13:07:00.000","Title":"dump files downloaded by google Colab in temporary location to google drive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"how adjacency list and adjacency matrix are able to logically present a non-linear data structure, even though they are themselves linear. Someone Pls explain","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":199,"Q_Id":61798347,"Users Score":0,"Answer":"Stacks, queues, lists, vectors\/arrays: they all store data linearly in the sense that items are stored one after the other. There is the notion of \"item A comes before item B\", and \"item C comes after item B\". One before, one after. They only differ in how items can be accessed (FIFO, LIFO, by rank, by position).\nTrees (a type of graph) store data hierarchically. There's not really a before\/after relation. Instead, items are stored based on a parent\/child relationship. Then, we can say \"the parent of item A is B\", and \"the children of item A are B, C, D, and E\".\nGraphs store any type of relation between elements. An item can be related to any other item, as expressed by an edge. We can say \"item A is related to B, C, D, E\" and \"item B is related to A and F\". It is in this sense that they are nonlinear. An adjacency list and adjacency matrix accomplish this by, effectively, maintaining a (linear) list of these relationships.","Q_Score":1,"Tags":"python,algorithm,data-structures","A_Id":61798980,"CreationDate":"2020-05-14T13:17:00.000","Title":"adjacency list and adjacency matrix are able to logically present a non-linear data structure","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"hope you are all doing well.\nIm working on api project using python and flask.\nThe question I have to ask is, how can I get the values of multiple query string parameter?\nThe api client is built in PHP, and when a form is submitted, if some of the parameters are  multiple the query string is built like filter[]=1&filter[]=2&filter[]=3... and so on.\nWhen I dump flask request, it shows something like (filter[], 1), (filter[], 2), (filter[], 3), it seems ok, but then when I do request.args.get('filter[]') it returns only the first item in the args ImmutableDict, filter[]=1, and I can't access the other values provided.\nAny help regarding this issue would be aprreciated.\nHappy programming!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":397,"Q_Id":61800268,"Users Score":0,"Answer":"try this request.args.to_dict(flat=False) to convert","Q_Score":0,"Tags":"python,flask","A_Id":61800722,"CreationDate":"2020-05-14T14:44:00.000","Title":"Flask Python - multiple URL parameter with brackets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Basically my questions is how list and matrix can be used to represent the graph, as list and matrix is linear data structure and graph is a non-linear data structure","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":61801650,"Users Score":0,"Answer":"So in matrix representation, we only change the value of a particular cell when the vertex represented by column and row number are connected. And list is simply the list for all the neighbors of a particular vertex. In matrix, we store zeroes for pair of vertices not connected and is extra space.","Q_Score":0,"Tags":"python,algorithm,data-structures,graph","A_Id":61801948,"CreationDate":"2020-05-14T15:46:00.000","Title":"How a linear datastructure can be used to implement a non linear datastructure","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's assume that a Grakn KG contains entities of type 'product' and that they are uniquely identified by the key 'id_prod'. As I understand it, the attempt to insert an instance of product with a repeated id_prod will generate an error.\nAssuming that the insertion is being done through a console script, how could the previous existence of the instance be checked with graql during the insertion? And via the python client, are there any special recommendations or patterns to follow?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":141,"Q_Id":61802152,"Users Score":2,"Answer":"Your assertion is correct. At present Graql doesn't have a PUT behaviour built-in that would check for existence and insert only if not present. This is a feature that should be included in the future (I work at Grakn).\nInstead, you have broadly two options: \n\nYou match for concepts by their keys. If there are no results then you insert them. Then you can match insert for the keyed concepts to add relations to them etc.\nYou first ensure that you've inserted all of the keyed concepts into the KB (may not be possible). You then make the match insert queries directly, matching for the keyed concepts, with no need for checking the keys exist","Q_Score":4,"Tags":"python,database,vaticle-typedb,vaticle-typeql,knowledge-graph","A_Id":62089331,"CreationDate":"2020-05-14T16:12:00.000","Title":"How to check if an specific Grakn instance already exists before trying to insert it into the KG?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pyramid API which has basically three layers. \n\nView -> validates the request and response\nController -> Does business logic and retrieves things from the DB.\nServices -> Makes calls to external third party services. \n\nThe services are a class for each external API which will have things like authentication data. This should be a class attribute as it does not change per instance. However, I cannot work out how to make it a class attribute. \nInstead I extract the settings in the view request.registry.settings pass it to the controller which then passes it down in the init() for the service. This seems unnecessary. \nObviously I could hard code them in code but that's an awful idea. \nIs there a better way?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":102,"Q_Id":61802722,"Users Score":2,"Answer":"Pyramid itself does not use global variables, which is what you are asking for when you ask for settings to be available in class-level or module-level attributes. For instance-level stuff, you can just pass the settings from Pyramid into the instance either from the view or from the config.\nTo get around this, you can always pass data into your models at config-time for your Pyramid app. For example, in your main just pull settings = config.get_settings() and pass some of them to where they need to be. As a general rule, you want to try to pass things around at config-time once, instead of from the view layer all the time.\nFinally, a good way to do that without using class-level or module-level attributes is to register instances of your services with your app. pyramid_services library provides one approach to this, but the idea is basically to instantiate an instance of a service for your app, add it to your pyramid registry config.registry.foo = ... and when you do that you can pass in the settings. Later in your view code you can grab the service from there using request.registry.foo and it's already setup for you!","Q_Score":1,"Tags":"python,pyramid","A_Id":61937789,"CreationDate":"2020-05-14T16:41:00.000","Title":"Accessing Pyramid Settings throughout the program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How to use \"VideoPlayer\" widget to create \"segment-player\"?\nFor example: I have 10 segments: seg-1.mp4, seg2.mp4... seg10.mp4. How to create video player, as in sites, which allows play video by segments.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":726,"Q_Id":61803374,"Users Score":0,"Answer":"The best way to archive that, would to inherit the Videoplayer that has direct access to the kivy.core.video widget.\nThen from reading the source you could try to have the video on the RAM (as a file object) and parse it down to the video widget.\nThe video on the RAM could be an empty video file where you append the streams you have saved and as the video plays, the stream is shown in the video widget. But it's rather complex.\nOr you could do a sub routine that reloads the source every segment of the video in the order you wish with an event driven sequence. Instead of changing the videoplayer source, you would be changing the _video widget inside the player. And remember to change the video config to autoplay so the load times would be shorter between segments.","Q_Score":0,"Tags":"python,kivy,media-player,kivy-language","A_Id":63203939,"CreationDate":"2020-05-14T17:13:00.000","Title":"VideoPlayer kivymd python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If a chron schedule exists for a given Airflow DAG to launch every month on the 1st at 6am like this:\n0 6 * * 1\nAnd the start date is March 1st 2020, then in theory the DAG will only launch April 1st 2020 to cover the entire period as per the documentation. \n1) However, what if I wanted the DAG to launch on March 1st? Is there a way to set the DAG's start date to March 1st with an option to run as normal but to include the start date? \n2) If I manually launch the DAG on April 3rd, will the DAG still automatically launch as per the chron schedule on May 1st, or skip it, seeing as how an execution took place within the period that May is supposed to cover?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":214,"Q_Id":61803983,"Users Score":3,"Answer":"Option 1: Trigger the DAG manually on March 1. Option 2: Set the start date to February 1, then the first interval will end on March 1 and the DAG will be triggered on schedule. I am not aware of any option that will let you run the DAG on the start date as you described.\nManually triggering a run does not affect the run schedule, so the DAG will still run on May 1.\n\nBTW: The schedule \"0 6 * * 1\" that you mentioned means \"At 06:00 on Monday.\" \"At 06:00 on the first day of a month\" is \"0 6 1 * *\".","Q_Score":1,"Tags":"python,airflow","A_Id":61873042,"CreationDate":"2020-05-14T17:46:00.000","Title":"Manually starting DAG skips next scheduled run?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Traceback (most recent call last):\n  File \"C:\\Users\\George Adamopoulos\\Anaconda3\\envs\\Computer Vision Code\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow.py\", line 58, in \n    from tensorflow.python.pywrap_tensorflow_internal import *\n  File \"C:\\Users\\George Adamopoulos\\Anaconda3\\envs\\Computer Vision Code\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow_internal.py\", line 28, in \n    _pywrap_tensorflow_internal = swig_import_helper()\n  File \"C:\\Users\\George Adamopoulos\\Anaconda3\\envs\\Computer Vision Code\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow_internal.py\", line 24, in swig_import_helper\n    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)\n  File \"C:\\Users\\George Adamopoulos\\Anaconda3\\envs\\Computer Vision Code\\lib\\imp.py\", line 242, in load_module\n    return load_dynamic(name, filename, file)\n  File \"C:\\Users\\George Adamopoulos\\Anaconda3\\envs\\Computer Vision Code\\lib\\imp.py\", line 342, in load_dynamic\n    return _load(spec)\nImportError: DLL load failed: The specified module could not be found.\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):\n  File \"C:\/Users\/George Adamopoulos\/Desktop\/All My Files\/Fear Neural Net Project\/Computer Vision Code\/ML Zero to Hero\/Part_2.py\", line 1, in \n    import tensorflow as tf\n  File \"C:\\Users\\George Adamopoulos\\Anaconda3\\envs\\Computer Vision Code\\lib\\site-packages\\tensorflow__init__.py\", line 41, in \n    from tensorflow.python.tools import module_util as _module_util\n  File \"C:\\Users\\George Adamopoulos\\Anaconda3\\envs\\Computer Vision Code\\lib\\site-packages\\tensorflow\\python__init__.py\", line 50, in \n    from tensorflow.python import pywrap_tensorflow\n  File \"C:\\Users\\George Adamopoulos\\Anaconda3\\envs\\Computer Vision Code\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow.py\", line 69, in \n    raise ImportError(msg)\nImportError: Traceback (most recent call last):\n  File \"C:\\Users\\George Adamopoulos\\Anaconda3\\envs\\Computer Vision Code\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow.py\", line 58, in \n    from tensorflow.python.pywrap_tensorflow_internal import *\n  File \"C:\\Users\\George Adamopoulos\\Anaconda3\\envs\\Computer Vision Code\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow_internal.py\", line 28, in \n    _pywrap_tensorflow_internal = swig_import_helper()\n  File \"C:\\Users\\George Adamopoulos\\Anaconda3\\envs\\Computer Vision Code\\lib\\site-packages\\tensorflow\\python\\pywrap_tensorflow_internal.py\", line 24, in swig_import_helper\n    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)\n  File \"C:\\Users\\George Adamopoulos\\Anaconda3\\envs\\Computer Vision Code\\lib\\imp.py\", line 242, in load_module\n    return load_dynamic(name, filename, file)\n  File \"C:\\Users\\George Adamopoulos\\Anaconda3\\envs\\Computer Vision Code\\lib\\imp.py\", line 342, in load_dynamic\n    return _load(spec)\nImportError: DLL load failed: The specified module could not be found.\nFailed to load the native TensorFlow runtime.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":61804098,"Users Score":0,"Answer":"Delete it from the console and reinstall it and try adding it again.","Q_Score":0,"Tags":"python,tensorflow","A_Id":68278106,"CreationDate":"2020-05-14T17:53:00.000","Title":"Unable to import tensorflow into PyCharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't figure out how to post a question on the pyimagesearch.com blogs.  There are a number of topics, each of which has a trail of postings and responses, but I cannot see how to post a question to the topic.  The site does not have an open forum.  That is why I am asking here.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":61806955,"Users Score":0,"Answer":"they did respond that the questions are submitted to one email address. It appears that they put the questions and responses on different articles.  There is no way to post directly.","Q_Score":0,"Tags":"python,image-processing,deep-learning","A_Id":61940745,"CreationDate":"2020-05-14T20:35:00.000","Title":"Post on Pyimagesearch blog","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an endpoint that renders a template that has a list of movies\nOn the page, there is a button called \"Add movie\" and an input field to add the name of the movie. When the button is pressed, I want to add a movie of the name to the list of movies and re render the page.\nRight now, I am doing it all in JS, with a fetch request, but I can't re render the page like this.\nHow could I achieve the effect I want?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":61807125,"Users Score":0,"Answer":"You're rendering on the server-side, so in order to re-render, you need to send data back to the server. One way of doing this creating a form element which posts data to the same page when you click the button. And then on the server side, take the inputted movie, add it to the other movies, and then you can re-render and return.\nThis answer attempts to provide general guidance, since your question was general.","Q_Score":0,"Tags":"python,django","A_Id":61808132,"CreationDate":"2020-05-14T20:48:00.000","Title":"Re-render page from JS Django Template","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using the Turtle module for Python and am making a fairly simple game. I started to code for Border checking and am following a video to do it, but it doesn't seem to work. I had used the same code in the past and it was fine but now nothing happens.\nThe Code:\nBorder Limitations\nglobal player\nif player.xcor() > 600 or player.xcor() < -600:\n    player.right(180)   \nif player.ycor() > 400 or player.ycor() < -400:\n    player.right(180)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":61807315,"Users Score":0,"Answer":"I believe you should put that inside the main game-loop, instead of a function, cross out the global.","Q_Score":1,"Tags":"python-turtle","A_Id":61838428,"CreationDate":"2020-05-14T21:02:00.000","Title":"Why does xcor and ycor not work for my border check?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python winrm protocol to run a Powershell script in the windows server.When I run the script as standalone in the server, the script output is getting displayed fine whereas when i call the script from python, the output is empty. Suggestions please. \nPython : std_out, std_err, status_code = p.get_command_output(shell_id, command_id)\n         print(std_out.decode('utf-8'))\nPowershell : write-output - \"#START $output #END\"\nThe output returned from powershell is that of a Java Jar output.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":145,"Q_Id":61807376,"Users Score":0,"Answer":"Looks like there was errors being thrown in the jar output and hence the output was not capturing it. When std_err, status_code were decoded to utf-8(like i did with std_out print(std_out.decode('utf-8'))), i was able to see the results.","Q_Score":0,"Tags":"python,powershell,winrm","A_Id":61874264,"CreationDate":"2020-05-14T21:05:00.000","Title":"How to pass the output of a powershell script to a pythonscript","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been struggling with getting the bracket order to behave where I can pass an auto expire parameter (goodTillDate) for only the parent. When passing it in the bracket order code, it adds it to the limit and stop as well which defeats the purpose of a bracket order. I also want to be able to identify two limits for each bracket. Anyone have any code which mirrors the parent\/child relationship and OCO functions of a bracket order but with individual orders? One parent, and three children (two limits for our target profit takers, and one stop)?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1121,"Q_Id":61808519,"Users Score":0,"Answer":"First you submit the parent with the transmit flag as False, then specify parentId for each of the children and submit the last order with transmit as True. \nFor two limits, you just split the order and submit the legs. Alternatively you can experiment with conditional orders, specifying time.\nHow would the children stay alive when the parent has expired? Unless you mean partial fills.","Q_Score":0,"Tags":"python,interactive-brokers,ib-api","A_Id":61811246,"CreationDate":"2020-05-14T22:30:00.000","Title":"How to replicate bracket orders functionality using Interactive Brokers (IB) API (ib_insync) for Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"A lot of the languages I know of (like C++, C, Rust, etc.) print multiple error messages at a time. Then why does python print only one error message?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":324,"Q_Id":61808721,"Users Score":0,"Answer":"Difficult to answer the exact why. I cannot look into the head of the developers of the C-python, jython, pypy or others.\nMany errors will only be seen at run time as python is an interpreted language without strict typing.\nHowever each file is compiled to byte code if there is no syntax error. \nSo for syntax errors I cannot give you the reason, as it should have been technically possible. However I never had issues with this as I use tools like pylint or flake8 to check the code for me.\nThese tools can detect multiple errors and give a lot of warnings about coding style as well.\nSo I cannot tell you the why, but only what to do to get multiple errors in one go.\nThese tools can be configured to just display certain kinds of errors.\nto install one or the other tool, just type:\npip install flake8 or pip install pylint\nThen type just flake8 or pylint in the directory where all your code is located\nor type flake8 <filename> or pylint <filename> to check just one file.\nPlease note, that many IDEs like for example Microsoft Visual Studio Code, Pycharm, and others can be configured to run these tools automatically for you and signal any issues even before you execute your code.","Q_Score":1,"Tags":"python,error-messaging","A_Id":61809008,"CreationDate":"2020-05-14T22:49:00.000","Title":"Why does python print only one error 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 deleted the colab-jupyter.log file from var\/log\/ folder in google colab. Problem is now even if I manually created a colab-jupyter.log file, nothing is written over there.\nI deleted it to clear the content of it to better understand the log file messages. What is the possible solution now?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":159,"Q_Id":61809564,"Users Score":0,"Answer":"This is not a problem. I deleted it. And then created a new file colabjupyter.log. It was not writing any logs. So all I needed to do was to factory reset the runtime. And that did the trick. Nothing to panic about. Phew.","Q_Score":0,"Tags":"python,deep-learning,google-colaboratory","A_Id":61809871,"CreationDate":"2020-05-15T00:14:00.000","Title":"How to get back deleted colab-jupyter.log file in Google Colaboratory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For any defined valriable 'e', what's the difference b\/w:\nlogging.info(\"variable is : %s\" % e) and loggin.info(\"variable is : \", e)\nand when to use what?\nwhich one will be better for UTs ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":61812396,"Users Score":1,"Answer":"The second one will throw an exception if you have info logging enabled, you should use logging.info(\"variable is : %s\", e), this way you only format the string if the message is going to be logged.","Q_Score":0,"Tags":"python,python-3.x,logging,string-formatting","A_Id":61812437,"CreationDate":"2020-05-15T05:34:00.000","Title":"what's the difference in below two statements for string formatting?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have several geometry sets of my model and I want to make a set containing some of these sets. Is there any way I could do this with python? Thank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":464,"Q_Id":61812426,"Users Score":0,"Answer":"Yes, SetByBoolean exactly does that. For example, to create a set in assembly by combining two different sets created in part module,\n\na=mdb.models[partName].rootAssembly\n  a.SetByBoolean(name='Set-1+Set-2', sets=(\n      a.allInstances['partName'].sets['Set-1'], \n      a.allInstances['partName'].sets['Set-2'], ))","Q_Score":0,"Tags":"python,set,abaqus","A_Id":61877994,"CreationDate":"2020-05-15T05:37:00.000","Title":"ABAQUS scripting: Create a set out of sets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 10 microservices in django. I am running all microservices in different tab in terminal on localhost.So I want to run all microservices in single tab. I don't want to open multiple tab. Is there any way to do so?\nThanks in Advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":348,"Q_Id":61814630,"Users Score":0,"Answer":"I suggest to use docker for micro services.\nI have currently deployed my django application in production environment using docker I can manage them using docker-compose.\nAlternatively you can create shell script file for each micro service where you can define there own environment settings.","Q_Score":0,"Tags":"django,python-3.x,localhost,microservices","A_Id":61816975,"CreationDate":"2020-05-15T08:08:00.000","Title":"Run multiple microservices in single tab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"In my project which deals with SAS \nwe have risk binary files of extension .rskcdesc\nI have been looking but not able to find any python Java library which can read it.\n I need to automate data checks via Backend process, hence need a way to decode these files.\nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":61816784,"Users Score":0,"Answer":"Rohit,\nI don't have SAS Risk but SAS has been using zip for some of their files (like EG projects). Try renaming the file extension to .zip and open it. It may be comprised of XML files, similar to EG.","Q_Score":0,"Tags":"java,python,sas,risk-analysis","A_Id":61821507,"CreationDate":"2020-05-15T10:09:00.000","Title":"open SAS risk file extension of .rskcdesc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In my django application, I used to authenticate users exploiting base django rest framework authentication token. Now I've switched to Json Web Token, but browsing my psql database, I've noticed the table authtoken_token, which was used to store the DRF authentication token, is still there. I'm wondering how to get rid of it. I've thought about 2 options:\n\ndeleting it through migration: I think this is the correct and safer way to proceed, but in my migrations directory inside my project folder, I didn't find anything related to the tokens. Only stuff related to my models;\ndeleting it directly from the database could be another option, but I'm afraid of messing with django migrations (although it shoudn't have links with other tables anymore)\n\nI must clarify I've already removed rest_framework.authtoken from my INSTALLED_APPS","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1081,"Q_Id":61817823,"Users Score":1,"Answer":"You can choose the first option. There are 3 steps should you do to complete uninstall authtoken from your Django app\n\nRemove rest_framework.authtoken from INSTALLED_APPS, this action will tell your Django app to do not take any migrations file from that module\nRemove authtoken_token table, if you will\nFind the record with authtoken app name in table django_migrations, you can remove it.\n\nNote: There are several error occurs in your code, because authtoken module is removed from your INSTALLED_APPS. My advice, backup your existing database first before you do above step","Q_Score":2,"Tags":"python,django,django-rest-framework,django-migrations,django-database","A_Id":61818577,"CreationDate":"2020-05-15T11:10:00.000","Title":"Django: safely deleting an unused table from database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i've been trying djano project that include channels & redis. recently i recreated venv and i get following even after deleting mistaken line. is there a way to clear cache in django project and runserver again? \n''' line 52, in message\n    to = models.ForeignKey(to='user',on_delete='',related_name = 'to')\n  File \"\/home\/\/python-projects\/DjangoChannels\/.env\/lib\/python3.8\/site-packages\/django\/db\/models\/fields\/related.py\", line 801, in init\n    raise TypeError('on_delete must be callable.')\nTypeError: on_delete must be callable.'''","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":61818423,"Users Score":0,"Answer":"i've just reinstalled python from source and problem was gone!","Q_Score":0,"Tags":"python,django,redis,django-channels","A_Id":61819156,"CreationDate":"2020-05-15T11:45:00.000","Title":"Getting django error even after deleting mistake line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So, I recently started learning Django and found out about the two ways to create obejcts in database using their given API. Now, one of the methods is to use the create() methods that is provided by Manager class as follows :\njoe = Author.objects.create(name=\"joe\")\nNow, objects is the default manager given by Django but I could not find create() method inside the source code. Please tell me what am I missing?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":111,"Q_Id":61818472,"Users Score":-1,"Answer":"create(**kwargs) methods provided by QuerySet. That method allows you to create some object immediately and returning the created object itself. For the detail, you can find the create() method on the Django installation directory. Exactly in python-path\/site-packages\/django\/db\/models\/query.py","Q_Score":2,"Tags":"python,django,web,django-models","A_Id":61818803,"CreationDate":"2020-05-15T11:48:00.000","Title":"Is there a create() method in the Manager class of Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Context: I recently realized that YouTube has this new chapter thing feature, I listen to a lot of music mixes and such and those have the song name as chapters, and on linux I print the currently playing YouTube song anyway, so I tought that instead of displaying the name of the mix if I could display the song name in a mix using this new chapter feature.\nQuestion: My question would be, is there any way Python can communicate with a Chrome extension written in JS? Because I made this song name finding extension in JS, so only what it does is extract the name of the song with its Xpath then outputs it with console.log(X). I would need this output inside python where I could work with this given song name.\nUsing selenium and stuff like this, is not an option I think because those are completely separate from the browser","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":211,"Q_Id":61819396,"Users Score":0,"Answer":"You can either work on translating your Python code to JS and adding it to the extension, or running a web server built in Python that you can make requests to.","Q_Score":0,"Tags":"javascript,python,google-chrome","A_Id":61819420,"CreationDate":"2020-05-15T12:36:00.000","Title":"Is there a way that Python can communicate with a Chrome extension?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a request - can you help me access and manage django DB objects without using shell ?\nI have created my models, but now (for example) i want to make a login system. I store users and passes(again, only an example), and i want to get the info from the DB, but i dont want to use shell.\nWhat can i do in this case, im quite new to Django ?!\nBest Regards","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":61819741,"Users Score":0,"Answer":"In views.py you can import\nfrom .models import modelname\ndata = modelname.objects.all() - using this you can get all the data from the Database\nEg:-\nfor d in data:\n           print (d.email)\nWill give all emails in the database\nYou can also use\nt = modelname.objects.get(email='name@lk.com')\nBy this you can get the data of the person who's email is name@lk.com","Q_Score":0,"Tags":"python,sql,django","A_Id":61819931,"CreationDate":"2020-05-15T12:54:00.000","Title":"Access Django DB objects without shell?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I double-click on the IDLE to run it, nothing appears on my screen. I have tried reinstalling Python multiple times with multiple different versions. It works on different accounts on the same computer, but for some reason refuses to open. If anyone could give a solution I would be most grateful.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":61820375,"Users Score":0,"Answer":"Please consider adding python to your path.","Q_Score":0,"Tags":"python,python-3.x,python-idle,python-3.8","A_Id":61823624,"CreationDate":"2020-05-15T13:25:00.000","Title":"Python 3 IDLE won't run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an expression in regex, as follow:\nr\"(?:AND|OR|SUB|ADD)\\([^()]*\\)(?:\\]\\[|\\[|)(|\\s\\[|\\s)COIL\\(Seq\\[\\d+]\\.Bool\\[\\d+]\\.\\d+\"\nUsually I am using it to capturing from a sentence like that:\nAND(Seq[1].Mat)AND(Type_G012.WithData)[COIL(Seq[1].Bool[93].11),XIC(Seq[1].exp)RES(Seq[1].ita)]\nSo I want to extract the last \"AND\" or \"OR\" or \"SUB\"... also with Seq[1].Bool[93].11.\nAfter that I am doing an additional extraction. It was working with no problems with almost everything. The problem is that I have some patterns like that.\nAND(Seq[1].Mat)AND(Type_G014.WithData)AND(Type_G015.WithData)[SET(Seq[1].WaitStep)COIL(Seq[1].Seq[93].10),AND(Seq[1].exp)RES(Seq[1].ita)]\nThen I am not capturing the last AND, OR, SUB, etc. Because now I have the SET instruction in the middle of the AND and the COIL. So I want to exclude anything diferent of AND|OR|SUB|ADD Because I would like to extract from the last sentence as follow:\nAND(Type_G015.WithData)[SET(Seq[1].Wait)COIL(Seq[1].Seq[93].10\nThen is the last AND before the COIL. If something could help me I am testing several things and I am messing it.\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":61822828,"Users Score":0,"Answer":"Thanks.\nNow I have something like that:\nAND(Type_G015.WithData)[SET(Seq[1].Wait)COIL(Seq[1].Seq[93].10\nHow Can I extract just AND(Type_G015.WithData). Because my idea was as follow:\n(?:AND|OR|SUB|ADD)\\((.*)\\) But now I am extracting until the last parenthesis but I would like to extract everythin but only until the first closing parenthesis, just:\nAND(Type_G015.WithData)\nBetween parenthesis we could be whatever less more parenthesis.","Q_Score":0,"Tags":"python,regex","A_Id":61872424,"CreationDate":"2020-05-15T15:28:00.000","Title":"Modifying existing regex, excluding some parts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i want to install openStack on ubuntu 16.04 when i enter the command **.\/stack.sh** i get the following error   \nERROR: Package 'keystone' requires a different Python: 3.5.2 not in '>=3.6'\npython version  is 2.7.12 , i also read the openstack.org documentaion, it said in Prerequisites that use to up version 2.7.  \nEach time I get error, I re-enter the following commands:\n**.\/unstack.sh**\n **.\/clean.sh**\n**.\/stack.sh**\nBut I get the same error again","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":264,"Q_Id":61824869,"Users Score":1,"Answer":"You can try to add \"USE_PYTHON3=True\" parameter to your local.conf, it should work","Q_Score":0,"Tags":"python,python-2.7,openstack,devstack,openstack-keystone","A_Id":62029933,"CreationDate":"2020-05-15T17:16:00.000","Title":"openStack - Package : keyStone error requires a different python version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Using DynamoDB, I know I can specify a conditional expression to control updates, for example, using attribute_not_exists() to prevent overwriting an existing item. However, is there any way to check the result of this? I.e. if there was indeed an existing item and the create failed, I'd like to know that so I can return an error code in my HTTP response. However, looking at the documentation in Boto3, by default put_item returns nothing, so I'm unsure of how I'd be able to monitor the success of the operation. Anyone found a way to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":225,"Q_Id":61825481,"Users Score":0,"Answer":"Found it, ConditionalCheckFailedException is thrown. Disappointed the docs don't mention this, other kinds of exceptions are detailed in the boto3 docs, but not this one!","Q_Score":1,"Tags":"python,amazon-web-services,amazon-dynamodb","A_Id":61825683,"CreationDate":"2020-05-15T17:54:00.000","Title":"DynamoDB Python API: Way to check result of conditional expression?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"As someone who just got into data science (no prior coding history) I am new to using terminals, Python, and coding in general. While I do have some basic Python knowledge now, and I want to work on my first machine learning project, I am looking to use some packages that are not standard to python or jupyter lab, namely: TensorFlow.\nAfter much struggle I was able to download TensorFlow in my terminal (i'm on Mac). Yet when I try to import to module I come to the following problem:\nwhen I create a new file in jupyterlab (accessed via Anaconda) I have the option to create a python file using python 3 or python 3.7.2. When using python 3, I have access to packages to sklearn, SciPy, yet no TensorFlow. Then when I create a 3.7.2. file I can import the TensorFlow package, yet I cannot import the sklearn and SciPy packages anymore.... \nDid someone experience similar problems? Are there ways to solve this?\nP.s. Using the 'pip install ...' command in terminal only sees to work rarely. Or I must be something wrong.\nThanks in advance,\nJohn","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":212,"Q_Id":61825562,"Users Score":0,"Answer":"I know what you are going through as even I went through a similar problem when I started. It seems that there are two different environments. One with Python3 and one with Python 3.7.2. The problem is arising because the modules are installed in different environments. Your TensorFlow module in Python 3.7.2 environment and sklearn modules in another environment. \nIt will better if you install all your modules in the base environment for ease in use.\nI hope this helps.","Q_Score":0,"Tags":"python,pip,jupyter-notebook,python-import,jupyter-lab","A_Id":61825684,"CreationDate":"2020-05-15T17:59:00.000","Title":"Python packages not working in either python 3 or python 3.7.2. files","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script that can be executed both with a gui or without and it has some optional arguments such as -g for choosing to show gui, input path and output path, while this arguments are all optional i want them to be optional when gui is activated and non optional when executing the script without gui. How can i make this work?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":90,"Q_Id":61828123,"Users Score":0,"Answer":"What I suggest is the following: build an option processor function, based on argparse and processing sys.argv (the default). However, have that function receive a boolean argument, named, say, batch_mode, with a default value of False. Assign the value of batch_mode to all the places where you want conditional \"required-ness\" of arguments (depending on whether a GUI was invoked). Note that this function should both construct the parser and use it on sys.argv.\nNow, run the function once with the default value of batch_mode. Then, if -g was not specified, run the function again, only this time pass batch_mode=True, making all the non-GUI arguments required.\nGranted, this may entail two calls to the function, but the amount of extra coding required will be minimal.","Q_Score":0,"Tags":"python,arguments,command-line-arguments,argparse","A_Id":61828667,"CreationDate":"2020-05-15T20:50:00.000","Title":"Optional position arguments in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was experimenting with tuple in python and stumbled upon this problem\nt=tuple(\"2\",) # works \nbut\nt=tuple(1,) # fails \nwith error TypeError: 'int' object is not iterable\nwhereas\nt=(1,) # works\nCan anybody please explain why this is so?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":208,"Q_Id":61831138,"Users Score":0,"Answer":"As the TypeError also states, you can pass only iterables to a tuple.\nA simple int item is not iterable, so that cannot work.\n(1, ) works because 1, is already an iterable. Actually it is another tuple.\nIn a similar fashion, you can also adjust the failed tuple(1,) case to tuple((1, )) and it will also work.","Q_Score":0,"Tags":"python,python-3.x","A_Id":61831180,"CreationDate":"2020-05-16T02:28:00.000","Title":"Creating python tuple with one int item","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a XGBRegressor model and now I'm curious if there is a way to generate the final prediction equation in Python.\nP.S: I do not have mathematical background so if my question is considered basic, please understand.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":61831268,"Users Score":0,"Answer":"Depending on the problem, the final 'equation' could be arbitrarily complex.\nA good place to start is to inspect one or some of the decision trees:\nfrom xgboost import plot_tree\nWhich takes your trained model and the tree index as arguments.","Q_Score":0,"Tags":"python,math,data-science,xgboost","A_Id":61831414,"CreationDate":"2020-05-16T02:51:00.000","Title":"Python XGBoost Generate Prediction Mathematical Equation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My script opens Crome's page and presses \"down\" button. It occures in headless mode. If I open chrome window script focuses on it. How can I avoid that situation?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":61832958,"Users Score":0,"Answer":"For automalte your keyboard or mouse clicks you can use \"pyautogui\" module in python. You can find more about \"pyautogui\" module in it's docs and can contact me for more info.\nMail me on this address : gamingbomb911@gmail.com","Q_Score":0,"Tags":"python,selenium,google-chrome,keyboard,focus","A_Id":61833440,"CreationDate":"2020-05-16T06:46:00.000","Title":"How can I press keyboard buttons via selenium only for current Chrome session in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having an issue with Visual Studio Code live share - errno 2 No such file or directory to more exact.\nThe error happens when my friend, who is connected to my collaboration session, tries to run the code on his side. The same happens when I connect to his session and try to run his code.\nFrom what I understand from MS VS Code page and other websites, live share should allow us not only to work on the same code, but also run it on both machines.\nWe tried sharing a server but it also did not help - even though I had access to his other files, like a test HTML website which we created to check if sharing a localhost server works.\nI'm kinda running out of ideas and do not really know what else we could do to fix this issue.\nCould anybody help me out? Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":292,"Q_Id":61835563,"Users Score":0,"Answer":"Sorry, not a solution.\nI'm also experiencing the same. I hosted a collaboration session and remote collaborators can't execute the code. They get a: \"Not such file or directory\" error message.\nCould you resolve this?","Q_Score":0,"Tags":"python,visual-studio-code,visual-studio-liveshare,vscode-liveshare","A_Id":67059499,"CreationDate":"2020-05-16T10:48:00.000","Title":"VS Code Live Share - 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":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm just installed Visual Studio Code yesterday and am getting the error that Python is not installed.   I currently have Python 3.8 installed.  I have tried installed Python 3.7 and Python 3.5 and still am getting the same error that python is not installed and am unable to select a python interpreter even when I point it to directory of my python install.","AnswerCount":4,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":3567,"Q_Id":61837918,"Users Score":-2,"Answer":"It's simple just go to the extension tab and type \"Python\". Install the First one (By Microsoft) and restart vs code and your good to go.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":61838775,"CreationDate":"2020-05-16T13:54:00.000","Title":"Visual Studio code Python not intalled","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm just installed Visual Studio Code yesterday and am getting the error that Python is not installed.   I currently have Python 3.8 installed.  I have tried installed Python 3.7 and Python 3.5 and still am getting the same error that python is not installed and am unable to select a python interpreter even when I point it to directory of my python install.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3567,"Q_Id":61837918,"Users Score":0,"Answer":"I resolved this issue by uninstalling Python, then reinstalling to a simpler path.\nMy previous installation was located at: C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python38\\python.exe so I reinstalled Python to C:\\python and VS Code now recognizes the interpreter.\n\nIt also warned me that I was using an outdated version of PIP (even\nthough I installed the latest Python version - 3.8.5), but it was\neasily upgraded by typing the installation command provided in the\nerror message.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":63564309,"CreationDate":"2020-05-16T13:54:00.000","Title":"Visual Studio code Python not intalled","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can't find 'Scripts' folder or 'pip' file in Python 3.8.2 folder for Windows 10. Trying to install pip for python. Any ideas how I can get past this problem?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2722,"Q_Id":61838942,"Users Score":0,"Answer":"As others answered already you should have got pip already as you installed python. Well pip isnt the apllication. You use pip in the application: Command prompt. You have to search for command prompt on your computer (if you have python you already have it installed) and then in command prompt you install packages that you still son't have.\nFor example you wan't pygame you write: pip install pygame. If you have PyCharm then there is something else you need to do. If you have PyCharm tell me as a comment to this answer and I'll tell you what to do then because command prompt would almost be useless","Q_Score":2,"Tags":"python,pip,windows-10,python-3.8","A_Id":61857432,"CreationDate":"2020-05-16T15:11:00.000","Title":"Can't find 'Scripts' folder or 'pip' file in Python 3.8.2 folder for Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can't find 'Scripts' folder or 'pip' file in Python 3.8.2 folder for Windows 10. Trying to install pip for python. Any ideas how I can get past this problem?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2722,"Q_Id":61838942,"Users Score":0,"Answer":"Pip should have already been installed when you install your python, if you wanna check if you pip is install try typing pip in your command prompt or terminal and if you wanna see the file directory of the pip you have installed say pip show (here you put name of file like pygame)","Q_Score":2,"Tags":"python,pip,windows-10,python-3.8","A_Id":61839048,"CreationDate":"2020-05-16T15:11:00.000","Title":"Can't find 'Scripts' folder or 'pip' file in Python 3.8.2 folder for Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"From excel file i want to read each row and use it independently to process\nhere how the data looks like in excel file\n12  32  45  67  89  54  23  56  78  98\n34  76  34  89  34  3\n76  34  54  12  43  78  56\n76  56  45  23  43  45  67  76  67  8\n87  9   9   0   89  90  6   89\n23  90  90  32  23  34  56  9   56  87\n23  56  34  3   5   8   7   6   98\n32  23  34  6   65  78  67  87  89  87\n12  23  34  32  43  67  45\n343 76  56  7   8   9   4\nbut when i read it through pandas then the remaining columns are filled with NaN.\nthe data after reading from pandas looks like\n\n0 12  32  45  67  89  54  23.0    56.0    78.0    98.0\n1 34  76  34  89  34  3   NaN NaN NaN NaN\n2 76  34  54  12  43  78  56.0    NaN NaN NaN\n3 76  56  45  23  43  45  67.0    76.0    67.0    8.0\n4 87  9   9   0   89  90  6.0 89.0    NaN NaN\n5 23  90  90  32  23  34  56.0    9.0 56.0    87.0\n6 23  56  34  3   5   8   7.0 6.0 98.0    NaN\n7 32  23  34  6   65  78  67.0    87.0    89.0    87.0\n8 12  23  34  32  43  67  45.0    NaN NaN NaN\n9 343 76  56  7   8   9   4.0 5.0 8.0 68.0\n\nHere it can be seen the remaining columns of each row is filled with NaN which i don't want.\nNor i wanted to replace it with some other value or drop the whole rows contains NaN .\nHow can i read columns of each row till the first occurence of NaN. ? \n\nFor eg.The second row in pandas is 34 76  34  89  34  3   NaN NaN NaN NaN\nso my desired output will be that it reads only 34    76  34  89  34  3\n\nMy preference is pandas but if not possible then is their any other way of doing it like with some other libraries\nAny resource or reference will be helpful?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":61839733,"Users Score":0,"Answer":"While calling the pd.read_excel function, try setting keep_default_na = False. This will avoid default NaN values while reading.","Q_Score":0,"Tags":"python,python-3.x,pandas,dataframe,data-science","A_Id":61839989,"CreationDate":"2020-05-16T16:06:00.000","Title":"How can i read each row till the first occurence of NaN.?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've come across many such situations where I have used in built functions or modules where the syntax is sometimes \"X.func_name\" and other times (X.func_name()\".\nFor example : \nIn Pandas \"df.columns\" gives names of all columns and throws and throws error if written by mistake as \"df.columns()\"  #TypeError: 'Index' object is not callable.\nAlso in Pandas, \"count()\", \"min()\" etc are written as df.count() | df.min()\nI hope I have explained my question properly.\nI believe it has something to do with the OOP concept of Class and it's member functions but I'd like a more in-dept understanding.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":244,"Q_Id":61840466,"Users Score":1,"Answer":"The functions with parens are functions (actually class methods), which can take parameters and so on. Without parentheses, these are class variables.","Q_Score":0,"Tags":"python,pandas,oop","A_Id":61840582,"CreationDate":"2020-05-16T16:59:00.000","Title":"Difference between X.func and X.func( )","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've come across many such situations where I have used in built functions or modules where the syntax is sometimes \"X.func_name\" and other times (X.func_name()\".\nFor example : \nIn Pandas \"df.columns\" gives names of all columns and throws and throws error if written by mistake as \"df.columns()\"  #TypeError: 'Index' object is not callable.\nAlso in Pandas, \"count()\", \"min()\" etc are written as df.count() | df.min()\nI hope I have explained my question properly.\nI believe it has something to do with the OOP concept of Class and it's member functions but I'd like a more in-dept understanding.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":244,"Q_Id":61840466,"Users Score":2,"Answer":"The syntax to access an attribute foo of an object or module is always .foo.\nAn attribute may or may not be callable.  An int is not callable (it's just a number), but a function is callable.  To call a function foo, you use parentheses, possibly with parameters inside, e.g. foo() or foo(\"bar\").  Attempting to call something that is not callable will give you a TypeError.\nSo what syntax you use depends on whether the attribute is itself the value you want (e.g. an int or a str, or if it's a function that will return that value).  In your example, columns is itself an int, whereas count is a function that you need to call in order to get an int.\nNote that it's possible in Python to wrap any value in a function, or to turn a function into a property (i.e. make an attribute that automatically calls a function to produce its value), but in general the convention is that if something requires some kind of dynamic computation it will be a function, and values that are predetermined will not require a function invocation to retrieve.","Q_Score":0,"Tags":"python,pandas,oop","A_Id":61840680,"CreationDate":"2020-05-16T16:59:00.000","Title":"Difference between X.func and X.func( )","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't install matplotlib or other lib with terminal, is there any way to install matplotlib with PyCharm without using terminal?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":78,"Q_Id":61841091,"Users Score":1,"Answer":"If you just type 'import matplotlib' as normal Pycharm will detect that it isn't installed and offer to install it from the IDE if you hover over the text.","Q_Score":0,"Tags":"python,python-3.x,matplotlib,installation,data-science","A_Id":61841489,"CreationDate":"2020-05-16T17:45:00.000","Title":"How can install Matplotlib with PyCharm without use terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi i have a list with 15205 variables inside, im trying to find the relative frequency of each variable but python don't react with such a big size.\nif i try len(list) it works, but max(list) gives me '>' not supported between instances of 'list' and 'int', and set(list) gives me 'type' object is not utterable. If i try to work with it as a data frame it gives me TypeError: unhashable type: 'list'\nPlus, if i use a small sample of the list everything works fine.\nCan anyone explain me why does this happen and how can i work it out?\nthanks","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":44,"Q_Id":61841238,"Users Score":2,"Answer":"Firstly, you shouldn't name your list 'list', since this is a reserved word in Python referring to the type. This is the origin of your 'set(list)' error. \nAs for the other error, at least one of the items in your list appears to be itself a list, and you can't compare the magnitude of a list and an integer.","Q_Score":0,"Tags":"python,list,dataframe","A_Id":61841318,"CreationDate":"2020-05-16T17:56:00.000","Title":"Python not operating with super long list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my ubuntu, not performing well when I am going to install pystan and fbprophet, using pip3 command. So, my system hangs badly.\nI am tried so many logics still got errors, kindly please guide me how i can rectify this issues ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":61842222,"Users Score":0,"Answer":"Did you try this? PyStan requires a C++ compiler to be available to Python during installation and runtime and can be done by this command - \n\napt-get install build-essential","Q_Score":1,"Tags":"python,python-3.x,pystan,facebook-prophet","A_Id":61842474,"CreationDate":"2020-05-16T19:11:00.000","Title":"trouble installing pystan and fbprophet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a discord.py bot using the datetime and random libraries ( and discord.py of course ). My question  is how can i run it even when my computer is off. I think the answer is a rented server but i think there are cheeper options","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":61842467,"Users Score":0,"Answer":"You'll either have to run it on a machine you don't turn off. Or deploy it to a server. You can get cheap servers through Linode, Digital Ocean and others.","Q_Score":1,"Tags":"python","A_Id":61842486,"CreationDate":"2020-05-16T19:30:00.000","Title":"How do i run a python project nonstop ( even when i close the 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":"Error\ntensorflow.python.framework.errors_impl.UnknownError:  Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.\n     [[node conv2d_1\/Conv2D (defined at C:\\Users\\Rajshree\\Anaconda3\\lib\\site-packages\\tensorflow_core\\python\\framework\\ops.py:1751) ]] [Op:__inference_keras_scratch_graph_808]\nI'm running 2 programs . Both are using this and performing similar task of recognizing human expression. The difference only lies in the model of CNN they are using. One is working perfectly fine so what could be the possible problem with the other.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":667,"Q_Id":61842692,"Users Score":0,"Answer":"This could be due to a multitude of things. Are you running the two programs at the same time? Are you running this on a GPU? If so, it could be that one is already using the GPU, and the other finds that the GPU is already in use so it throws an error.","Q_Score":0,"Tags":"python,tensorflow,conv-neural-network","A_Id":61846743,"CreationDate":"2020-05-16T19:47:00.000","Title":"Failed to get convolution algorithm.This is probably because cuDNN failed to initialize.[{node conv2d_1\/Conv2D}]","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Python to_sql function to insert data in a database table from Pandas dataframe. \nI am able to insert data in database table but I want to know in my code how many records are inserted . \nHow to know record count of inserts ( i do not want to write one more query to access database table to get record count)?\nAlso, is there a way to see logs for this function execution. like what were the queries executed etc.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":816,"Q_Id":61842924,"Users Score":0,"Answer":"There is no way to do this, since python cannot know how many of the records being inserted were already in the table.","Q_Score":4,"Tags":"python,pandas,pandas-to-sql","A_Id":61843712,"CreationDate":"2020-05-16T20:10:00.000","Title":"Pandas :Record count inserted by Python TO_SQL funtion","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset in which each datapoint consists of 5 videos in two dimensions, as a numpy array with shape (48,128,42,5). (height, width, frames, video index). The multiple videos basically serve as \"slices\" to get some information about depth, although imperfect.\nI want to create a CNN using Keras\/Tensorflow for regression, but Keras only has built-in Convolutional layers for up to 3 dimensions. Is there a good way to perform convolution and max-pooling on 4 dimensional data? Or will I need to create my own layer using Tensorflow?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":135,"Q_Id":61843677,"Users Score":0,"Answer":"TL;DR - You still only need Conv3D\nDon't let the vector shape confuse you, the number of dimensions of the convolution layer refers to the dimensions on which the filter slides, not the input shape. \nFor example, if you'd want to process audio, you would still use Conv1D as you only slide the filter over time (1-D), even though the audio signal might have 2 channels and therefore shape e.g. (1,44100,2) (1 file, 44100 samples per second - assuming 1s audio lenght, 2 channels - left and right). \nSimilarly, for a 28x28 RBG image (1,28,28,3) you would still use Conv2D, as the filter slides vertically and horizontally across the image. \nFinally, for your video example, you need your convolutional filter to slide through the image (2D) PLUS the different frames. Therefore, you end up using Conv3D","Q_Score":1,"Tags":"python,tensorflow,keras","A_Id":61843999,"CreationDate":"2020-05-16T21:16:00.000","Title":"Using Keras for a CNN to perform regression on a set of videos","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to run adb commands in silent mode or something like that? For instance, whenever I pull a file, it returns 1 file pulled, 0 skipped. 11.3 MB\/s (705431 bytes in 0.059s), which may be annoying if your script is doing it very often.\nI'm not sure if it matter, but I'm using VSCode.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":338,"Q_Id":61844430,"Users Score":1,"Answer":"Try this if your using Linux adb pull source dest > \/dev\/null. For windows am not sure it should be $null or something","Q_Score":0,"Tags":"python,adb","A_Id":61844616,"CreationDate":"2020-05-16T22:28:00.000","Title":"Running adb commands in silent mode (without output)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I trained a time series model with LSTM (Shape is N, 20, 1).\nSuppose N is the last data.\nUsing model.predict gives the N + 1 th predicted value.\nHow do I predict data values after N + 2, N + 3, N + 4 .... etc.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":128,"Q_Id":61845462,"Users Score":0,"Answer":"In a time series model like LSTM, predicting a new datapoint depends on the previous datapoints. To predict n + 1, you use [N-19...N]. Now to predict n + 2, you need [N-18...N+1]. Repeat this process if you want to predict farther and farther in the future.\nOf course, the farther ahead you go, the less accurate your predictions will be. RNNs are good at predicting the next timestep, but not so good at predicting things far in the future. That's why if you look at books or sentences generated by neural nets, they don't make much sense.\nOnce you have the real value for n + 1, the n + 2 prediction will be more accurate than if you had to use your predicted value.","Q_Score":1,"Tags":"python,tensorflow,lstm,recurrent-neural-network","A_Id":61846716,"CreationDate":"2020-05-17T00:31:00.000","Title":"How can I predict the following values after RNN model training?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to do a runtime with llvmlite, and I would like to transpiler c to llvm.\nI want to know if in a way in llvmlite itself or in some python lib, I can't find it on the internet, so I came to ask you. Thank you very much in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":159,"Q_Id":61846090,"Users Score":2,"Answer":"If you want to transform C code to LLVM IR, no need to do it using llvmlite, which is a LLVM binding library. Just call clang -c -emit-llvm on a C source from your Python code.","Q_Score":1,"Tags":"python,llvm,llvmlite","A_Id":61848986,"CreationDate":"2020-05-17T02:07:00.000","Title":"how to transpiling c to llvm in llvmlite","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have recently started learning Python using PyCharm on Windows 10. I am trying to use PIP to install modules (I have tried Pillow, Pygame and randomword). When I try to install these, PIP says that I was successful and the module comes up when I use Pip freeze. However When I try to import them into Pycharm using the from import function. The module is not found. I cannot locate the module in the LIB folder as well. What do I need to do to have these modules appear in python,\nMany Thanks,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":61846899,"Users Score":0,"Answer":"Did you make sure you installed the module with the right pip?\nI mean, many people with have more than one python editor installed, and so, there will be multiple pips. If you installed a module with the pip from IDLE-3.8, the module will only be installed for that IDLE-3.8.","Q_Score":0,"Tags":"python,module,pip,python-module","A_Id":61857474,"CreationDate":"2020-05-17T04:13:00.000","Title":"Modules that Have been installed in PIP not appearing in PyCharm via the import function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to programming and learned a little bit of Python in the previous two weeks and wrote an automation script that scrapes Categories and articles in each category from a website. Now I want to test that script on my WordPress blog and post articles in their respective categories in the WordPress blog. Can someone direct me to any thorough guide to executing this process? I have done some research on this but there is very little information available on the internet.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":55,"Q_Id":61846902,"Users Score":1,"Answer":"The best way is to write a php code (in your site) where you will upload the json file. the script will then save data to your database .Modify the  python script to save the scraped data in json(many languages easily support it + has more usage and is faster) then upload it to the php file.From database you can display your data","Q_Score":0,"Tags":"python,php,wordpress,web-scraping","A_Id":61847623,"CreationDate":"2020-05-17T04:14:00.000","Title":"Can I post Python scraped articles to my wordpress site using XML-RPC?","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've made some changes directly on the code located in the PythonAnywhere files. In this way, some of them are a little bit different from the reppository GitHub files. \nAssuming the PyhonAnywhere files are correct, what is the best way to 'copy' them and move to the GitHub?\nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":118,"Q_Id":61847295,"Users Score":2,"Answer":"If your PythonAnywhere project already connected to GitHub:\n\nRun Bash console on PythonAnywhere\nMove to directory with your repository\nMake git push","Q_Score":1,"Tags":"python,django,pythonanywhere","A_Id":61848084,"CreationDate":"2020-05-17T05:13:00.000","Title":"Modifications PythonAnywhere -> 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":"Is it possible for 32-bit pyodbc and 32-bit Python to talk to 64-bit MS access database? i searched a lot but could be able to find a specific solution. I can neither change the 64 bit version of MS-ACCESS and nor change 32 bit version of Python and Pyodbc. Please help me..","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":204,"Q_Id":61848897,"Users Score":2,"Answer":"Nope.\nYou need to match bitness between the ODBC driver and application.\nA half-alternative would be an alternate driver, such as UCanAccess + JayDeBeApi","Q_Score":0,"Tags":"python,ms-access,pyodbc","A_Id":61849531,"CreationDate":"2020-05-17T08:21:00.000","Title":"Is it possible for 32-bit pyodbc and 32-bit Python to talk to 64-bit MS access database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python and pycharm tool. I have created a project and checked in Git hub. Now one of my friend pulled the changes and tried to run and he encountered with an error message stating \"No interpreters found\". When i revalidated the project structure i found that i have 'venv' folder in my project but the person who pulled the changes dosent have it.\nCan you please help me on this.\nThanks in Advance!\nPS: I am using Windows OS","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":741,"Q_Id":61849355,"Users Score":0,"Answer":"Usually, you don't check in your venv folder.\nSave the output of pip freeze in a file called requirements.txt and check that into your repo.\nOnce your friend gets the full code, they can install the dependencies using pip install -r requirements.txt","Q_Score":0,"Tags":"python,python-3.x,pycharm","A_Id":61849387,"CreationDate":"2020-05-17T09:04:00.000","Title":"How to export the virtual environment settings in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I plotted an image in jupyter notebook, and instead of 'loss' I typed 'accuracy' in the image title and saved it in 'svg' format, and notebook is saved in github repo. \nI want to know is there any way to edit it the image, without running the whole script again?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":16,"Q_Id":61852226,"Users Score":0,"Answer":"I think you can re-run the part of code for printing\/saving that image only in the new cell in the same jupyter file if you haven't closed that file yet","Q_Score":0,"Tags":"python,matplotlib,jupyter-notebook","A_Id":61852376,"CreationDate":"2020-05-17T13:02:00.000","Title":"Can i edit image created in jupyter notebook without re running","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making an RNN language model with Keras and in order to train the model (supervised learning) I have to create a numpy array y (with the labels of each observation for each sequence) of shape (num_of_training_sequences, size_of_vocabulary) containing one-hot vectors.\nWhen I have too many training sequences, this array is too big to fit in memory. However, it doesn't have to be! Since the number of possible one-hot vectors is only size_of_vocabulary, then y could just be a num_of_training_sequences sized array that contains references (aka pointers) to pre-allocated one-hot vectors. This way, if two sequences end in the same word and should have the same one-hot vector, then they would just reference the same address in memory of that one-hot vector. \nAnd everyone should be happy, except from numpy arrays. Because when I cast this magesticly efficient data structure to numpy array, it tries to allocate the whole array into memory, along with duplicate and reduntant one-hot vectors. \nIs there anything I can do to overcome this? Keras's code and documentation says fit() only accepts numpy arrays and tensors.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":61853084,"Users Score":0,"Answer":"The way I overcame my memory issue is by using fit_generator() instead of fit(). The generator function can take my more efficient list of lists structure and generate the (now much smaller) numpy array just-in-time for each batch, reducing the memory needed overall.\nAnother topic I ran into is sparse arrays. Because one-hot vector arrays contain a lot of zeros, they are sparse and it is much more efficient to store them as such e.g. with scipy's sparse matrix implementations. The generator function will again need to convert them to dense numpy arrays for fit_generator().\nThere is also a sparse tensor implemented in tf that should not require a generator to convert it to a dense array but I wasn't able to make it work.","Q_Score":0,"Tags":"python,arrays,numpy,keras","A_Id":61855086,"CreationDate":"2020-05-17T14:05:00.000","Title":"How do I use the same memory address for redundant rows of numpy array?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cannot install the PyCrypto module to use the AES method in Python 3.5.0. I tried the pip install PyCrypto command, but I get the following error: \"ERROR: The command failed with an exit state of 1:\". When I tried pip install pycryptodome and pip install pycryptodomex everything worked, but when I tried to import from Crypto.Cipher import AES in python, I had an error that Crypto did not detect.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":454,"Q_Id":61854110,"Users Score":0,"Answer":"i just upgrade pip and tried pip install pycryptodome. And all working! Thank's everyone!","Q_Score":0,"Tags":"python,module,cryptography","A_Id":61856874,"CreationDate":"2020-05-17T15:16:00.000","Title":"I can't install PyCrypto for use AES functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Thanks for your time.  Im an old programmer coming back to Python\nI have a new install of Anaconda3, Windows 10 and Microsoft Office 2010\nI tried install xlwings via pip straight into Python3 - didn't seem to work\nIve then installed anaconda3, spyder.\nIve installed inside anaconda at the command prompt \nxlwings addin install\nxlwings addin update\ninitially I got an error going into excel, saying 2 spreadsheets of the same name can not be open - I guess that was something to do with when I was trying to get the original python3 \/ pip\/ addin manager to work....\nIve spent all day trying to sort that. It no longer appears in the addin menu (developer), just in the ribbon - xlwings\nIve run a program as per the documentation spyder\/python and get Hello xlwings inside excel (created the python and excel spreadsheet with the xlwings quickstart myproject)\nBut when I try and use a fuction that sends data to python I get an error.  if I click on run main, import functions or restart UDF server I get a missing DLL error\nRun Time error 53 - file not found xlwings32.0.19.2.dll.\nive tried copying it to System32, removing the addin (xlwings addin remove) and reinstalling it\nI completely unsinstalled Microsoft office and reinstalled it - the addins was still there anyway !\nSorry a lot of explanation for what is actually a DLL issue, but ive been going around and around for hours.\nSo in summary, I don't had xlwings under the addins\/developer in excel, but it does appear on the ribbon.  I can run a python program that puts \"hello world\" into excel but excel does not recognise the python function and when I try and interact with excel I get a missing .dll error.\nWhat should I do ? rip out python \/ accoconda etc and start all over again ?\ncheers\nOlder and Greyer !","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":513,"Q_Id":61856637,"Users Score":0,"Answer":"I don't know if this will fix your problem, I was having the same error with Excel's \"sorry you can't have two workbooks of the same name open at the same time\" and solved it. The error only happened when the Excel add-in \"xlwings\" was checked. I fixed the error by moving the location of the xlwings add-in from C:\\Users\\MYNAME\\AppData\\Roaming\\Microsoft\\Excel\\XLSTART where it had automatically put itself to C:\\Users\\MYNAME\\AppData\\Roaming\\Microsoft\\AddIns.","Q_Score":0,"Tags":"python,excel,dll,anaconda,xlwings","A_Id":62094620,"CreationDate":"2020-05-17T18:21:00.000","Title":"Python XLWings Anaconda Newbie - Install \/ Basic issues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been working on a GUI and the results are displayed in a Treeview. I was wondering if it is possible to export this information as pdf, since I did not find anything on the internet.\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":459,"Q_Id":61856965,"Users Score":0,"Answer":"No, there is no support in tkinter to export treeview data to pdf.","Q_Score":0,"Tags":"python,tkinter","A_Id":61857350,"CreationDate":"2020-05-17T18:45:00.000","Title":"Is it possible to export ttk Treeview to pdf?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to install scikit-learn using PyCharm by going into the settings->Project Settings->Project Interpreter-> '+' button and serching for and installing scikit-learn, it gives me this error:\nCould not install packages due to an EnvironmentError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '\"C:'\nI installed numpy without any problems before this.\nIs there anything I am missing or another way I can try to install scikit-learn?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":358,"Q_Id":61859877,"Users Score":0,"Answer":"Update: I found the answer.\nFor anyone out there with the same problem as me, you should go to settings->Project Settings->Project Interpreter in Pycharm. There you will find pip, which for me was out dated. If this is the case, then click on pip and then the upgrade button that looks like an up arrow. After it finishes installing the latest version of pip, retry installing scikit-learn or any other package that would not previously install and gave the error \"Could not install packages due to an EnvironmentError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '\"C:'\"","Q_Score":0,"Tags":"python,python-3.x,scikit-learn,pip","A_Id":61881125,"CreationDate":"2020-05-17T22:57:00.000","Title":"Why is scikit-learn not installing on python 3.8 using pycharm on windows 10?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I updated from ubuntu 12.04 to ubuntu 12.10 and the python module I have written suddenly no longer works with the error message that the module scipy does not have the attribute 'misc'. This worked previously. I am still using python 2.7 after the update. Here is where the code crashes","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":289,"Q_Id":61860317,"Users Score":-1,"Answer":"it's very  easy\nu have to do  this step\n1-pip install imageio\n2-import imageio\n3-replace  scipy.misc.imsave(image_name,data)\nwith this code\nimageio.imwrite(image_name, data)\nenjoy............","Q_Score":1,"Tags":"python,scipy","A_Id":61860318,"CreationDate":"2020-05-17T23:51:00.000","Title":"how u can fix this problem AttributeError: 'scipy' object (scipy) has no attribute 'misc'?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wonder if it is possible to get client's IP address from http request header using Python? I was working on a weather project, it would be very good if I could show weather info of his own location.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4819,"Q_Id":61860592,"Users Score":0,"Answer":"If the request happens to contain X-Forwarded-For, X-Real-IP then you might get the client's actual IP address. However, most of the time, if a user doesn't want you to know their actual IP by using a proxy there is no way for a server to tell. And as the other comments pointed out, if you are only working on the HTTP layer it's impossible to get the IP address. The two headers I mentioned are usually only added to the request if you are using a reverse proxy\/load balancer.","Q_Score":1,"Tags":"python,http,python-requests,request-headers,python-requests-html","A_Id":61861079,"CreationDate":"2020-05-18T00:27:00.000","Title":"Is it possible to get a client's IP address from HTTP request header?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is my understanding of convolutional neural networks and my best practices. Please advise if my though-process is accurate.\n1) If input set has small details, have a smaller filter size.\n2) Qty is dependent on how many small details.\n3) Always have a maxpool layer for showing the output layers the most important parts of the image.\n4) if accuracy between the last few epochs is very small, and training time is long, consider increasing learning rate and\/or decreasing epochs\n5) if dropout is to be used, use it between two dense layers, preferably right before the output layer\nThanks for your expertise in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":62,"Q_Id":61861533,"Users Score":1,"Answer":"Let's evaluate point by point.\n1) If input set has small details, have a smaller filter size. -> Yes, you can use the most 3x3 common filter or if need be then 2x2. But, still you will have to go through a lot of prototyping. An added fact to this, the number of filters is directly proportional to the position of layers. So, in first layer, have 16, then next layers 32 and so on.\n2) Qty is dependent on how many small details. -> You don't know the number of small details. Neural networks are effectively a black-box, there is no rigorous mathematical way to define neural networks till now.\n3) Always have a maxpool layer for showing the output layers the most important parts of the image. -> By that logic, you would just put MaxPool at the end of the network. Usually, have a MaxPool, after 2-3 Conv layers. The point of MaxPool is to highlight the important features but also at the same time to reduce parameter space. Using it sparingly defeats it purpose.\n4) If accuracy between the last few epochs is very small, and training time is long, consider increasing learning rate and\/or decreasing epochs. -> Accuracy usually slows increases towards the end of training. Even in learning rate schedules, you decrease the learning rate w.r.t to increasing epochs. Don't expect big jumps in accuracy towards the end of training. Try to find a good learning rate and train till satisfaction w.r.t validation set.\n5) If dropout is to be used, use it between two dense layers, preferably right before the output layer. -> The point of dropout is to give a regularization effect. You can use dropout in Conv layers also. Use dropout to reduce overfitting, the place doesn't matter. The effectiveness of using dropout in Dense layers should be more as they are towards the end of network holding the weights that result into your prediction but dropout should be used throughout the network if possible. Or you can use regularizer on layer weights.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,neural-network,conv-neural-network","A_Id":61863256,"CreationDate":"2020-05-18T02:32:00.000","Title":"Are these advisable best practices for convolutional neural networks?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a project that requires training a PyTorch framework NN on a very large dataset of images. Some of these images are completely irrelevant to the problem, and but these irrelevant images are not labelled as such. However, there are some metrics I can use to calculate if they are irrelevant (e.g. summing all the pixel values would give me a good sense of which are the relevant images and which are not). What I would ideally like to do is have a Dataloader that can take in a Dataset class, and create batches only with the relevant images. The Dataset class would just know the list of images and their labels, and the Dataloader would interpret whether or not the image it is making a batch with is relevant or not, and would then only make batches with relevant images.\nTo apply this to an example, lets say I have a dataset of black and white images. The white images are irrelevant, but they are not labelled as such. I want to be able to load batches from a file location, and have these batches only contain the black images. I could filter at some point by summing all the pixels and finding it equals to 0. \nWhat I am wondering is if a custom Dataset, Dataloader, or Sampler would be able to solve this task for me? I already have written a custom Dataset that stores the directory of all the saved images, and a list of all the images in that directory, and can return an image with its label in the getitem function. Is there something more I should add there to filter out certain images? Or should that filter be applied in a custom Dataloader, or Sampler?\nThank you!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":178,"Q_Id":61863541,"Users Score":0,"Answer":"I'm assuming that your image dataset belongs to two classes (0 or 1) but it's unlabeled. As @PranayModukuru mentioned that you can determine the similarity by using some measure (e.g aggregating all the pixels intensity values of a image, as you mentioned) in the getitem function in tour custom Dataset class.\nHowever, determining the similarity in getitem function while training your model will make the training process very slow. So, i would recommend you to approximate the similarity before start training (not in the getitem function). Moreover if your image dataset is comprised of complex images (not black and white images) it's better to use a pretrained deep learning model (e.g. resnet or autoencoder) for dimentionality reduction followed by applying clustering approach (e.g. agglomerative clustering) to label your image.\nIn the second approach you only need to label your images for exactly one time and if you apply augmentation on images while training you don't need to re-determine the similarity (label) in the getitem funcion. On the other hand, in the first approach you need to determine the similarity (label) every time (after applying transformation on images) in the getitem function which is redundant, unnecessary and time consuming.\nHope this will help.","Q_Score":0,"Tags":"python,pytorch,dataloader","A_Id":61879851,"CreationDate":"2020-05-18T06:23:00.000","Title":"Custom Dataset, Dataloader, Sampler, or something else?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a project that requires training a PyTorch framework NN on a very large dataset of images. Some of these images are completely irrelevant to the problem, and but these irrelevant images are not labelled as such. However, there are some metrics I can use to calculate if they are irrelevant (e.g. summing all the pixel values would give me a good sense of which are the relevant images and which are not). What I would ideally like to do is have a Dataloader that can take in a Dataset class, and create batches only with the relevant images. The Dataset class would just know the list of images and their labels, and the Dataloader would interpret whether or not the image it is making a batch with is relevant or not, and would then only make batches with relevant images.\nTo apply this to an example, lets say I have a dataset of black and white images. The white images are irrelevant, but they are not labelled as such. I want to be able to load batches from a file location, and have these batches only contain the black images. I could filter at some point by summing all the pixels and finding it equals to 0. \nWhat I am wondering is if a custom Dataset, Dataloader, or Sampler would be able to solve this task for me? I already have written a custom Dataset that stores the directory of all the saved images, and a list of all the images in that directory, and can return an image with its label in the getitem function. Is there something more I should add there to filter out certain images? Or should that filter be applied in a custom Dataloader, or Sampler?\nThank you!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":178,"Q_Id":61863541,"Users Score":0,"Answer":"It sounds like your goal is to totally remove the irrelevant images from training.\nThe best way to deal with this would be to figure out the filenames of all the relevant images up front and save their filenames to a csv or something. Then pass only the good filenames to your dataset.\nThe reason is you will run through your dataset multiple times during training. This means you will be loading, analyzing and discarding irrelevant images over and over again, which is a waste of compute.\nIt's better to do this sort of preprocessing\/filtering once upfront.","Q_Score":0,"Tags":"python,pytorch,dataloader","A_Id":61880237,"CreationDate":"2020-05-18T06:23:00.000","Title":"Custom Dataset, Dataloader, Sampler, or something else?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get an convert my list into a particular format(expected output), but I'm getting a problem. so I'm trying to order exceptions according to a given time and in a lexicographical order.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":61863706,"Users Score":0,"Answer":"Instead of using str(), you can use f-string and padding:\nfinal_tuple = f\"{hour1:02}:{min1:02}-{hour2:02}:{min2:02} {data} {exception_count[data])},\"","Q_Score":0,"Tags":"python,django,python-3.x,list,django-views","A_Id":61863865,"CreationDate":"2020-05-18T06:36:00.000","Title":"Convert data inside a list into a given format in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made my project fine and when I run my server  through a normal shell it works but I am trying to run my project through git bash. All the commands seem to work fine but when I do python manage.py runserver it gets stuck on Watching for file changes with StatReloader. Apparently after that I go to localhost:8000\n\nbut that and my 127 port 8000 are not responding and show that theres nothing there, No errors or anything and like I said if I python manage.py runserver through shell it works","AnswerCount":4,"Available Count":4,"Score":0.1973753202,"is_accepted":false,"ViewCount":6488,"Q_Id":61863806,"Users Score":4,"Answer":"If you use django with Dockerfile, you won't miss that env var PYTHONUNBUFFERED set by 1.","Q_Score":10,"Tags":"python,django,git-bash","A_Id":67298558,"CreationDate":"2020-05-18T06:43:00.000","Title":"Stuck in Watching for file changes with StatReloader","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I made my project fine and when I run my server  through a normal shell it works but I am trying to run my project through git bash. All the commands seem to work fine but when I do python manage.py runserver it gets stuck on Watching for file changes with StatReloader. Apparently after that I go to localhost:8000\n\nbut that and my 127 port 8000 are not responding and show that theres nothing there, No errors or anything and like I said if I python manage.py runserver through shell it works","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":6488,"Q_Id":61863806,"Users Score":0,"Answer":"Using Git Bash run:\n$ python manage.py runserver 127.0.0.1:8000\nIn my case, it showed the same behavior ('Stuck in watching...').\nHowever, after that I opened a browser and I typed:\n127.0.01:8000.  The Django webpage works properly.","Q_Score":10,"Tags":"python,django,git-bash","A_Id":70822439,"CreationDate":"2020-05-18T06:43:00.000","Title":"Stuck in Watching for file changes with StatReloader","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I made my project fine and when I run my server  through a normal shell it works but I am trying to run my project through git bash. All the commands seem to work fine but when I do python manage.py runserver it gets stuck on Watching for file changes with StatReloader. Apparently after that I go to localhost:8000\n\nbut that and my 127 port 8000 are not responding and show that theres nothing there, No errors or anything and like I said if I python manage.py runserver through shell it works","AnswerCount":4,"Available Count":4,"Score":-0.049958375,"is_accepted":false,"ViewCount":6488,"Q_Id":61863806,"Users Score":-1,"Answer":"Probably autoreload does not work well in your environment, if you don't need it - better turn it off by starting django with --noreload arg.","Q_Score":10,"Tags":"python,django,git-bash","A_Id":63439371,"CreationDate":"2020-05-18T06:43:00.000","Title":"Stuck in Watching for file changes with StatReloader","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I made my project fine and when I run my server  through a normal shell it works but I am trying to run my project through git bash. All the commands seem to work fine but when I do python manage.py runserver it gets stuck on Watching for file changes with StatReloader. Apparently after that I go to localhost:8000\n\nbut that and my 127 port 8000 are not responding and show that theres nothing there, No errors or anything and like I said if I python manage.py runserver through shell it works","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":6488,"Q_Id":61863806,"Users Score":2,"Answer":"You may be missing the port binding, try to run python manage.py runserver 0.0.0.0:8000 to be sure that the app is running on localhost:8000","Q_Score":10,"Tags":"python,django,git-bash","A_Id":62662322,"CreationDate":"2020-05-18T06:43:00.000","Title":"Stuck in Watching for file changes with StatReloader","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am able to do that same thing with DataTable where clicking on a given row triggers callback using source.selected.on_change() however this doesnt seem to work for DataCube","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":61863824,"Users Score":0,"Answer":"As of Bokeh 2.0.2, this functionality is not implemented at all. Please feel free to create a feature request on Bokeh's GitHub page.","Q_Score":0,"Tags":"python-3.x,bokeh","A_Id":61864082,"CreationDate":"2020-05-18T06:44:00.000","Title":"Python- Bokeh - DataCube - Not able to select any row and extract information through callback","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running a server with Flask and gunicorn, using gevent workers. One of the endpoints in flask have to upload files to S3, which can take a lot of time. \nTo make the connection not being killed by gunicorn, I've increase the default timeout, which does not look as a nice implementation. \nIs there a way to communicate with gunicorn, while I send the S3 upload, to keep my worker alive?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":61864277,"Users Score":0,"Answer":"In this situation, i recommand to use celery","Q_Score":0,"Tags":"python,http,flask,gunicorn,gevent","A_Id":61865273,"CreationDate":"2020-05-18T07:15:00.000","Title":"How avoid Gunicorn kill the flask connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The python documentation says this about the sync method: \n\nWrite back all entries in the cache if the shelf was opened with\n  writeback set to True. Also empty the cache and synchronize the\n  persistent dictionary on disk, if feasible. This is called\n  automatically when the shelf is closed with close().\n\nI am really having a hard time understanding this.\nHow does accessing data from cache differ from accessing data from disk?\nAnd does emptying the cache affect how we can access the data stored \nin a shelve?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":425,"Q_Id":61865674,"Users Score":0,"Answer":"For whoever is using the data in the Shelve object, it is transparent whether the data is cached or is on disk. If it is not on the cache, the file is read, the cache filled, and the value returned. Otherwise, the value as it is on the cache is used.\nIf the cache is emptied on calling sync, that means only that on the next value fetched from the same Shelve instance, the file will be read again. Since it is all automatic, there is no difference. The documentation is mostly describing how it is implemented. \nIf you are trying to open the same \"shelve\" file with two concurrent apps, or even two instances of shelve on the same program, chances are you are bound to big problems. Other than that, it just behaves as a \"persistent dictionary\" and that is it.\nThis pattern of writing to disk and re-reading from a single file makes no difference for a workload of a single user in an interactive program. For a Python program running as a server with tens to thousands of clients, or even a single big-data processing script, where this could impact actual performance, Shelve is hardly a usable thing anyway.","Q_Score":2,"Tags":"python,shelve","A_Id":61871069,"CreationDate":"2020-05-18T08:41:00.000","Title":"Understanding the sync method from the python shelve library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im new to Javascript so I would like to keep it at the bare minimum. Is there a way that I can use the Electron to communicate with python script without having node.js? My app is just a basic app that takes some input from users from a html page and I need this text input to be processed in python and write an excel file. So there is not much happening in html so is there a simple way to transfer the input to python file? I want to use Electron because I need this html to be my UI and also I need to distribute this app.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1855,"Q_Id":61866120,"Users Score":1,"Answer":"Recently i have done it with some sort of trick hope it will help you and there are the following step which i followed- \n\nCreated a stand alone python exe using pyinstaller and the exe has flask server internally then i put the flask server inside my node application.\nNow we have to initiate our flask server and send a request to it for processing, i have done this with the help of \"execFile\" function as a child process, for which i have created a function and the code was something like that- \nasync function callFlask(){\n var child = require('child_process').execFile;\n child('path_to_python_exe ', function(err, data) {\n if(err){\n   console.error(err);\n   return;\n }\n });\n }\nNow we have initiated our flask server then will send the request with the help of fetch request like\nawait callFlask().then(\nawait fetch('host_ip_defined_in_flask'+encodeURIComponent('data'))\n\nNow further we can extend our then chain to get response from python if any and proceed further forexample - \n\nawait callFlask().then(\nawait fetch('host_ip_defined_in_flask'+encodeURIComponent('data'))\n.then(res => res.text())\n.then(body => console.log(body)))\n\nHere, your output data which python return will be printed in console then you can make your node application behave differently depending on output returned by it.\n\nAlso you can package your app with available packagers for electron like electron-packager it will work like a charm.\n\nAlso there is are some disadvantage for using python as like it will increase your package size and the process will be difficult to kill from electron after processing so it will increase burden on host machine.\nI am assuming that Explaining to create a flask server is not the scope of this question instead if you face any issues let me know, i hope it will help...","Q_Score":2,"Tags":"python,electron,electron-builder,electron-packager","A_Id":62085290,"CreationDate":"2020-05-18T09:08:00.000","Title":"Can I use Electron without node.js","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How to generate random 20 digit UID(Unique Id) in python. I want to generate UID for each row in my data frame. It should be exactly 20 digits and should be unique.\nI am using uuid4() but it generates 32 digits UID, would it be okay to slice it [:21]? I don't want the id to repeat in the future.\nAny suggestions would be appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":750,"Q_Id":61866295,"Users Score":0,"Answer":"I think uuid4() in python works, just slice it accordingly","Q_Score":2,"Tags":"python,pandas,numpy,uuid,uid","A_Id":61898840,"CreationDate":"2020-05-18T09:17:00.000","Title":"How to generate random 20 digit uid(Unique Id) in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Code is simple as follows:\nos.mkdir(\"Y:\\\\DirName\")\nthrow error:  \nWindowsError: [Error 3] : 'Y:\\\\' \nError is \"Y:\\\\\", not \"Y:\\\\DirName\". Y not a local disk, is a Network disk mapping. Use the Windows command 'mkdir' to succeed. Y drive can be accessed on the computer normally.\nI want know What could be the cause of the error, please.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":61866467,"Users Score":0,"Answer":"Might be the double slash? e.g. main C drive is C:\\ instead of C:\\\\","Q_Score":1,"Tags":"windows,python-2.7,mkdir,drive,mapped-drive","A_Id":61866650,"CreationDate":"2020-05-18T09:28:00.000","Title":"Python2.7, mkdir question. throw error : [WindowsError: [Error 3] : 'Y:\\\\'], but the path exists in PC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"previously we implemented one django application call it as \"x\" and it have own database and it have django default authentication system, now we need to create another related django application call it as \"y\", but y application did n't have database settings for y application authentication we should use x applications database and existing users in x application, so is it possible to implement like this?, if possible give the way how can we use same database for two separated django applications for authentication system.\nSorry for my english\nThanks for spending time for my query","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":186,"Q_Id":61866620,"Users Score":0,"Answer":"So, to achieve this. In your second application, add User model in the models.py and remember to keep managed=False in the User model's Meta class.\nInside your settings.py have the same DATABASES configuration as of your first application.\nBy doing this, you can achieve the User model related functionality with ease in your new application.","Q_Score":1,"Tags":"python,django,authentication","A_Id":61867227,"CreationDate":"2020-05-18T09:36:00.000","Title":"How two Django applications use same database for authentication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The real difference between MEDIA_ROOT and STATIC_ROOT in python django and how to use them correctly? \nI just was looking for the answer and i'm still confused about it, in the end of the day i got two different answers:\n- First is that the MEDIA_ROOT is for storing images and mp3 files maybe and the STATIC_ROOT for the css, js... and so on.\n-Second answer is that they were only using MEDIA_ROOT in the past for static files, and it caused some errors so eventually we are only using STATIC_ROOT.\nis one of them right if not be direct and simple please so everybody can understand and by how to use them correctly i mean what kind of files to put in them exactly","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":318,"Q_Id":61869169,"Users Score":0,"Answer":"Understanding the real difference between MEDIA_ROOT and STATIC_ROOT can be confusing sometimes as both of them are related to serving files.\nTo be clear about their differences, I could point out their uses and types of files they serve.\n\nSTATIC_ROOT, STATIC_URL and STATICFILES_DIRS are all used to serve the static files required for the website or application. Whereas, MEDIA_URL and MEDIA_ROOT are used to serve the media files uploaded by a user.\n\nAs you can see that the main difference lies between media and static files. So, let's differentiate them.\n\nStatic files are files like CSS, JS, JQuery, scss, and other images(PNG, JPG, SVG, etc. )etc. which are used in development, creation and rendering of your website or application. Whereas, media files are those files that are uploaded by the user while using the website.\n\nSo, if there is a JavaScript file named main.js which is used to give some functionalities like show popup on button click then it is a STATIC file. Similarly, images like website logo, or some static images displayed in the website that the user can't change by any action are also STATIC files. \nHence, files(as mentioned above) that are used during the development and rendering of the website are known as STATIC files and are served by STATIC_ROOT, STATIC_URL or STATICFILES_DIRS(during deployment) in Django.\nNow for the MEDIA files: any file that the user uploads, for example; a video, or image or excel file, etc. during the normal usage of the website or application are called MEDIA files in Django. \nMEDIA_ROOT and MEDIA_URL are used to point out the location of MEDIA files stored in your application.\nHope this makes you clear.","Q_Score":0,"Tags":"python,django,database,production-environment,django-staticfiles","A_Id":61869821,"CreationDate":"2020-05-18T12:02:00.000","Title":"The real difference between MEDIA_ROOT (media files) and STATIC_ROOT (static files) in python django and how to use them correctly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on a Supervised ML classification use case and I have 5 features and a target variable. Suppose the 5 feature are A, B, C, D, E, F and the target variable being G. The E feature isn't a raw feature meaning it is predicted from some other features. I tried using that feature for model building and the classification metrics were pretty good. But now my boss said that the we cannot use Feature E as it isn't directly available, we need to predict that first and then use it for predicting target G.\nBelow are some of the things I tried:\n\nI tried building a model by removing feature E from my feature list, the metrics dropped meaning that the feature E is important.\nBoss says that the feature E is derived or dependent on feature A, B, C, D and F so we can use that to predict feature E and then use features  A, B, C, D, E, F to predict G.\n\nHere are my concerns:\n\nIf feature E is dependent on features A, B, C, D and F then not using feature E while building model should not affect my metrics much.\nIf I use features A, B, C, D and F to predict feature E and indeed use features A, B, C, D, E, F to predict G won't I be using correlated feature for model building because E is predicted using A, B, C, D and F. Using F won't add any extra information to my feature set.\n\nMy understanding is that if building model by removing feature E from my feature list dropped my metrics then it means that feature E comes from somewhere else i.e. other than features A, B, C, D, F.\nI am not an experienced person in ML and these are my thoughts are about the problem.\nPlease let me know whether my thought process is right?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":854,"Q_Id":61869533,"Users Score":1,"Answer":"If feature E is dependent on features A, B, C, D and F then not using feature E while building model should not affect my metrics\n  much.\n\n\nIt really depends on the model you're using, but a simple example, let's imagine you are using a linear regression model, and the value you're trying to predict is y=x\u00b2\nYou can't find a fitting model with a simple linear regressor (A*x+B). However, you can create a new feature x' = x\u00b2, and now you can fit y A*x'+b . So a feature dependant on a combination of the other features can help your model sometimes.\n\n\nIf I use features A, B, C, D and F to predict feature E and indeed use features A, B, C, D, E, F to predict G won't I be using correlated\n  feature for model building because E is predicted using A, B, C, D and\n  F. Using F won't add any extra information to my feature set.\n\n\nThis question is more tricky, because it all really depends on the model you use to predict E, and the model you use to predict y.\nIf you use a simple linear regressor for both, then yes, E will be a linear combination of the other variables and won't help predicting y. \nBut you could imagine predicting E using a non-linear model, like RandomForest, and that could help your final model.\nBottom line is : it doesn't cost much to try, just be careful using the same train\/test for both models to avoid any leakage.","Q_Score":0,"Tags":"python,machine-learning,supervised-learning","A_Id":61890247,"CreationDate":"2020-05-18T12:24:00.000","Title":"Predicting a feature and using the predicted feature to predict the target","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am kind of scared of filling billing information on the Heroku website because of the automatic billing option in case I forget to remove an account.\nHelp me with your experience.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":681,"Q_Id":61872601,"Users Score":0,"Answer":"If you're still on free tier, it will not charge you. When I upgraded to hobby, I was only charged for how often the service was used (often less than $7). They were very honest - I have had no problems with Heroku. If you elaborate on your concerns, maybe I can provide a more tailored response.\nYou can stop charging at any time. If you're looking for specific information on how to remove your card\/billing information, thus reducing down to the free tier you can change your dyno type in \"Resources\" on the Heroku web app.","Q_Score":0,"Tags":"python,flask,heroku,web-hosting,billing","A_Id":61872665,"CreationDate":"2020-05-18T15:03:00.000","Title":"How to stop automatically Billing in Heroku website?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on a maven project that has its source file in JAVA. I had to add some functionality in the project through some already written code. But these new files were written in PYTHON. Hence I decided to make a shell script that can run both the java and python files with desired args. But since my java source files are in the maven project, I am not able to write a shell script without exploiting the structure of the maven project.\nSo, how can I run the above files without ruining the structure of my maven project?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":61873458,"Users Score":0,"Answer":"As Andersen mentioned that Maven can compile and execute .java files, it means it is only specific to java. For python files, you need setup.py to build python based project. You can not directly call a function written in Python from Java class. Now coming back to your requirements, I can think that you have to build separately java project using Maven with the command mvn clean install and you have to run setup.py if available in python project. Since you cannot call a python function from java class, you have to create an exe file in python using pyinstaller or using py2exe and you invoke the exe file from java. The above I mentioned in one of the approaches. Another approach is to rewrite the python code in java and build using maven. This will be the good approach based upon the requirement. Besides, if you are interested to build java project using Maven and you want to build python project, you can write a .bat file.","Q_Score":0,"Tags":"java,python,shell,maven","A_Id":61873953,"CreationDate":"2020-05-18T15:41:00.000","Title":"Running a maven project and a python file through shell 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":1,"Web Development":1},{"Question":"I want to remove a frame from the main page so I tried to use frame.grid_forget() but it gives me this error: _tkinter.TclError: bad window path name \".!frame\" what to do ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":61874814,"Users Score":1,"Answer":"The problem is simple: When you call window.destroy(), the window doesn't exist any more. Therefore, you can't call grid or grid_forget(), because the widget's data is gone.\nOne suggestion I would make for you to avoid this annoying error would be to use .withdraw(). This way, you can still call the widget's functions, and it will only be minimized.\nTo bring it back up, use .deiconify().","Q_Score":1,"Tags":"python,tkinter","A_Id":61903778,"CreationDate":"2020-05-18T16:53:00.000","Title":"python tkinter why icant use frame.grid_forget()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a twitterbot for an honors project and have it almost completed. However, when I scrape the website for a specific URL, the href refers to a link that looks like this:\n?1dmy&urile=wcm%3apath%3a%2Fohio%2Bcontent%2Benglish%2Fcovid-19%2Fresources%2Fnews-releases-news-you-can-use%2Fnew-restartohio-opening-dates\nWhen inspecting the html and hovering over the href contents above, it shows that the above is actually the tail-end of the link. Is there any way to take this data and make it into a usable link? Other links within the same carousal provide full links on the same website, so I'm not sure why this is different than the others.\nI tried searching for answers to this question but came up short: sorry if this is a repeat.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":61876033,"Users Score":0,"Answer":"BeautifulSoup is showing you what the HTML of the page has. If the link is relative, you need the base URL for the page. That should come back in your request result, not in the HTML itself.","Q_Score":0,"Tags":"python,web-scraping,twitter,beautifulsoup,href","A_Id":61876137,"CreationDate":"2020-05-18T18:02:00.000","Title":"Beautifulsoup4: How do you extract a usable link from href when it only provides parameters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In a django project I have imported firebase_admin and it worked perfectly on local host, but when I used Heroku to host my web app it gave error no module named 'firbase-admin'. I cross-checked my requirements files and it has firbase-admin. I don't know what's that I did wrong as I made sure that requirements used in virtual environment is same to that in Heroku requirements files.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":138,"Q_Id":61876080,"Users Score":0,"Answer":"make sure firebase-admin==4.3.0 is in your requirements.txt file and try not to generate dependencies manually because you can missout on some libraries preferably use pip freeze > requirements.txt","Q_Score":0,"Tags":"python,django,firebase,heroku","A_Id":62207057,"CreationDate":"2020-05-18T18:05:00.000","Title":"Integrating Python Heroku with Firebase","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm new to Python so I'm doing everything by tutorials and codes I find online and I have this problem that I'm trying to solve for some time without any luck. I hope my description will be at least somewhat understandable because I really don't understand the problem much myself... \nI have 2 files, each has one class made with OOP.\nThe mainfile.py and its class is for taking user input and looking for and selecting song from mysql database, then it runs the music file and its music class as a new thread and passes the song name. The music file\/class sets up the vlc media player (python-vlc) and then plays the selected song.\nself.newInstance = vlc.Instance()\nself.player = self.newInstance.media_player_new()\nNow it returs to the main file which expects another user input, which is \"stop music\". This runs the music_stop method in the music file\/class.\nself.player.stop()\nThe problem is it has no effect. The music is still playing. My thought is that its because when it runs the music class again to run the music_stop method, it creates new instance and new mediaplayer (which isn't playing anything) and is trying to stop it.. not the first instance which is actually playing the song.\nI hope its not too confusing. Plase ask questions if you need to because I'm pretty sure there is something that I forgot to mention. I'll provide additional info as needed.\nThank you all very much!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":426,"Q_Id":61876416,"Users Score":0,"Answer":"I solved it literally in few minutes after I posted this question... and after 4 days of struggling with it.\nThe solution was to make the file without class and so without OOP. Now it works.","Q_Score":0,"Tags":"python,python-3.x,multithreading,vlc,libvlc","A_Id":61908098,"CreationDate":"2020-05-18T18:25:00.000","Title":"How can I control VLC instance with threading","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a network in TensorFlow which uses tf.nn.embedding_lookup because of that the input placeholder is self.input_x = tf.placeholder(tf.int32, [None, sequence_length], name=\"input_x\"), I want to add an MLP network to this current network such that input of the MLP network is the input of the current network. For the MLP network, I need a float input type, but the type of current input placeholder is tf.int32. so when I run the code it shows the error. How can I solve this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":61876856,"Users Score":0,"Answer":"Using with tf.variable_scope and with tf.name_scope for both networks solved the problem.","Q_Score":1,"Tags":"python,tensorflow","A_Id":62022858,"CreationDate":"2020-05-18T18:50:00.000","Title":"How to have two networks together in TensorFlow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm learning django and following a tutorial, the thing is that when I try to import a function in the file urls.py from views.py and when I run the server the cmd throws the error no module named \"views\", and the guy in the tutorial doesn\u00b4t get that error and doesn\u00b4t talk anything about it.\n(They\u00b4re in the same directory, I tried importing the function to the module __init__, but throws the exact same error","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":61878241,"Users Score":0,"Answer":"Have u added ur application to INSTALLED_APPS?","Q_Score":0,"Tags":"python,django,function,cmd,import","A_Id":61880271,"CreationDate":"2020-05-18T20:17:00.000","Title":"From file import function (django)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So pygame is definitely on my computer, and I can call it through the Python terminal that was installed when I downloaded Python 3.8. However, I can't get Spyder to import the pygame module. When I do, it gives me this error message:\nModuleNotFoundError: No module named 'pygame'\nCould someone please walk me through how I set up pygame so that Spyder can recognize the pygame module? Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":129,"Q_Id":61878567,"Users Score":0,"Answer":"You've only installed pygame into a different python editor. If you want it to work on spyder, you should install it via the pip that belongs to spyder.","Q_Score":0,"Tags":"python,pygame,spyder","A_Id":61878662,"CreationDate":"2020-05-18T20:37:00.000","Title":"pygame module not found (Windows 10, Spyder IDE version 4.1.3, Python 3.8)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a UNet Segmentation network implemented in Keras that simply maps all pixels in an RGB image to 4 categories which is trained on a heat map mask (Low, Low-Med, High-Med, High). Using CCE or categorical Dice loss I am able to get decent results.\nHowever, The mask in it's original form is a heat map image with 255 bits of resolution. It seems like a totally arbitrary introduction of error to shoehorn it into the Unet by reducing the 255 bits of resolution into 4 categories.\nI would like the network to output an image with each pixel having a value between (0,1), and train the network with masks that are produced by multiplying the heat map image by 1.\/255.\nWhere, in this case, the loss function would incorporate the mathematical difference between the mask and the prediction from the network. Can anyone point me in the direction of someone who has done something similar? I think I am just awful at describing what I'm looking for with relevant terminology because it seems like this would be a fairly common goal in computer vision..?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2534,"Q_Id":61878950,"Users Score":2,"Answer":"If I understand your question correctly - the \"ground truth\" mask is just a gray-scale image with values in range [0,255], meaning , there is a strong relation between it's values (for example - 25 is closer to 26 then to 70. this is not the case with regular segmentation, where you assign a different class to each pixel and the classes values may represent arbitrary objects such as \"bicycle\" or \"person\"). In other words, this is a regression problem, and to be more specific an image-to-image regression. You are trying to reconstruct a gray-scale image which should be identical to the ground truth mask, pixel-wise. \nIf I understood you correctly - you should look for regression losses. Common examples that can be used are Mean Squared Error (aka MSE, L2 norm) or Mean Absolute Error (aka MAE, L1 norm). Those are the \"usual suspects\" and I suggest you start with them, although many other losses exists.","Q_Score":1,"Tags":"python,keras,deep-learning,computer-vision,semantic-segmentation","A_Id":61988296,"CreationDate":"2020-05-18T21:02:00.000","Title":"UNet Loss function for non-categorical Mask?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a simple Flask app that has no sort of auth since it doesn't really require it. Today my database reached 100,000 users when it normally gets about 5 in a day. I looked at my analytics but saw no one has been on the site in the past hour. \nHow are they creating this many users so fast and how can I prevent it? I had to take my database offline since it's been happening all day.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":61879904,"Users Score":0,"Answer":"this is probably just a bot or your site really work, but in case what you can do is, do authentication of email, set up an SMTP server and send some code\/numbers\/link to the registered emails and once verified then add them in a database or just set a  certain time for email authentication and if time passed then deletes the data\/record for that email\/user login credential.\nor \nyou can record the ip from which it is registered, and see if all the emails are registered form that ip, the block it if too many ( just a filter)","Q_Score":0,"Tags":"python,flask","A_Id":61880131,"CreationDate":"2020-05-18T22:14:00.000","Title":"Preventing someone from creating thousands of users","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I made a simple Flask app that has no sort of auth since it doesn't really require it. Today my database reached 100,000 users when it normally gets about 5 in a day. I looked at my analytics but saw no one has been on the site in the past hour. \nHow are they creating this many users so fast and how can I prevent it? I had to take my database offline since it's been happening all day.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":61879904,"Users Score":0,"Answer":"How are they creating this many users so fast and how can I prevent it?\nYou should think about:\n\nAccount activation with email\nOr prevent too many api cals from one ip to your register route (maybe someone is just destroying your app with bot)","Q_Score":0,"Tags":"python,flask","A_Id":61880005,"CreationDate":"2020-05-18T22:14:00.000","Title":"Preventing someone from creating thousands of users","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I try to open Python it gives me an error saying:\nIDLE's subprocess didn't make connection. See the 'startup failure' section of the IDLE doc online\nI am not sure how to get it to start. I am on the most recent version of windows, and on the most recent version of python.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":711,"Q_Id":61880099,"Users Score":0,"Answer":"Open cmd and type python to see if python was installed. If so fix you IDE. If not download and reinstall python.","Q_Score":0,"Tags":"python","A_Id":61880601,"CreationDate":"2020-05-18T22:30:00.000","Title":"Python not starting: IDLE's subprocess didn't make connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I try to open Python it gives me an error saying:\nIDLE's subprocess didn't make connection. See the 'startup failure' section of the IDLE doc online\nI am not sure how to get it to start. I am on the most recent version of windows, and on the most recent version of python.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":711,"Q_Id":61880099,"Users Score":0,"Answer":"I figured it out, thanks. All I needed to do was uninstall random.py.","Q_Score":0,"Tags":"python","A_Id":61880823,"CreationDate":"2020-05-18T22:30:00.000","Title":"Python not starting: IDLE's subprocess didn't make connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to convert the following time format to a valid date time format for my graphs. \n2020-05-06T08:49:23.004+10:00\nSo far I've been removing the +10:00 in order to make it work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":61880376,"Users Score":1,"Answer":"Have you tried pandas.to_datetime(time), where time = 2020-05-06T08:49:23.004+10:00?","Q_Score":0,"Tags":"python,pandas","A_Id":61880571,"CreationDate":"2020-05-18T22:55:00.000","Title":"Pandas convert time format","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have a small website with API connected using AJAX.\nWe do not ask for usernames and passwords or any authentication like firebase auth.\nSo it's like open service and we want to avoid the service to be misused.\nOAuth 2 is really effective when we ask for credentials to the user.\nCan you suggest the security best practice and how it can be implemented in this context using python?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":63,"Q_Id":61883103,"Users Score":1,"Answer":"Use a firewall\nAllow for third-party identity providers if possible\n Separate the concept of user identity and user account","Q_Score":0,"Tags":"python,api,security,certificate,backend","A_Id":61883428,"CreationDate":"2020-05-19T04:10:00.000","Title":"Python backend -Securing REST APIs With Client Certificates","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"kpi_data_cnt = TKPI_DETAIL_RECORD.objects.raw('SELECT COUNT(*) FROM first_app_TKPI_DETAIL_RECORD where MONTH_KEY = \"202005\"')\nprint(kpi_data_cnt)\nI want to populate the total row count from the table first_app_TKPI_DETAIL_RECORD and store in the variable \"kpi_data_cnt\". But it is not working using the above code. I also put a display in my code to check the value of the variable \"kpi_data_cnt\". There is in the display, it is showing the total select query instead of providing me the row counts.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":22,"Q_Id":61883194,"Users Score":1,"Answer":"Try this\nkpi_data_cnt=TKPI_DETAIL_RECORD.objects.filter(MONTH_KEY = \"202005\"').count()","Q_Score":0,"Tags":"python,sqlite,django-models","A_Id":61883346,"CreationDate":"2020-05-19T04:20:00.000","Title":"SQL Lite total row count fetching not working with Django Models","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If python is it possible to change the name of a loop,\neg: w = while does not work.\nI know it is possible to change the name of print with p = print\njust wanted to know if you could do this with loops in any way.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":61883925,"Users Score":2,"Answer":"No. while is a keyword, not a name.","Q_Score":2,"Tags":"python,python-3.x,loops,while-loop","A_Id":61883958,"CreationDate":"2020-05-19T05:35:00.000","Title":"can you override loop names in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to deploy a simple user bot on Google App Engine Flexible Environment running python3.7, but I get the following error. Can anyone help me with suggestions of solving this?\n\"File \"\/env\/lib\/python3.7\/site-packages\/telethon\/client\/auth.py\", line 20, in  phone: typing.Callable[[], str] = lambda: input('Please enter your phone (or bot token): '), EOFError: EOF when reading a line\"\nThank you for your time","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":780,"Q_Id":61884537,"Users Score":0,"Answer":"Telethon (obviously) requires you to login and make a normal user session on your account, which natively requires you to input your number when asked and enter the code received but since Google App engine doesn't allow input as @Sashidhar mentioned, depending on your userbot implementation, you can try using the userbot.session method for authentication, it can be generated locally and placed in the Google App Engine.","Q_Score":0,"Tags":"google-app-engine-python,telethon","A_Id":62506639,"CreationDate":"2020-05-19T06:25:00.000","Title":"Hosting a Telethon User BOT on google-app-engine","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 directory with small parquet files(600), I wanted to do ETL on those parquet and merge those parquet to 128mb each file. what is the optimal way to process the data. \nshould I read each file in the parquet directory and concat as a single data frame and do groupBY ? or provide parquet directory name to dd.read_parquet and process it? \nI feel like, when I read the file by file, it creates a very large dask graph that cannot be fit as an image. \nI guess it will work with those many numbers of threads as well? which leads to a memory error.\nwhich way is best to read the parquet file to process as dask dataframe ? file by file or provide entire directory ??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":61884851,"Users Score":0,"Answer":"Unfortunately there is no single best eway to read a Parquet file for all situations.  In order to properly answer the question you will need to know more about your situation.","Q_Score":0,"Tags":"python,dask,parquet,pyarrow,dask-dataframe","A_Id":61976131,"CreationDate":"2020-05-19T06:49:00.000","Title":"which way is best to read the parquet file to process as dask dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for an Opencv method or a way to calculate a per-block motion vectors for two consecutive images.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":760,"Q_Id":61891430,"Users Score":2,"Answer":"Your comment on another answer\n\nThis contains a dense (per-pixel) motion estimation, and a per feature estimation. Nothing for a per-block estimation\n\nmakes me (perhaps mistakenly) think that you're looking for a function whose existence wouldn't really make sense: assuming you pre-define your blocks with some desired granularity, how are you going to compute the flow for each of the blocks? There are two possibilities:\n\nCompute sparse (cv.calcOpticalFlowPyrLK()) or dense (cv.calcOpticalFlowFarneback()) flow over the entire image, and average\/downsample the result over each block (with  some smoothing afterwards).\n\nCompute some sort of \"block flow\" (which seems to be what you had in mind), where you define higher level blocks or super-pixels that you express using some statistics (or features) and compute the flow over them. In that case you'll probably violate the brightness constancy assumptions that most flow methods rely on, and even if you don't, this will very probably be similar to computing dense flow on a very low-resolution image, which in this case, again, could be achieved with cv.calcOpticalFlowFarneback().\nUsing higher-level blocks would make sense if you were learning them in a flow estimation pipline, though, but that is not the case here as they're predefined.\n\n\nThe second solution doesn't make much sense here, and the first solution is just a simple post-processing that depends on the user's needs.","Q_Score":1,"Tags":"python,opencv,computer-vision","A_Id":61893875,"CreationDate":"2020-05-19T12:49:00.000","Title":"Is there any function in OpenCV to calculate per block motion vectors for two images?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a Django project in vscode. Generally, vscode automatically prompts me to install pylint but this time it did not (or i missed it). Even though everything is running smoothly, I am still shown import errors. How do I manually install pytlint for this project?\nAlso,in vscode i never really create a 'workspace'. I just create and open folders and that works just fine.\nps. Im using pipenv. dont know how much necessary that info was.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":315,"Q_Id":61892803,"Users Score":1,"Answer":"Hi you must active your venv at the first then install pylint (pip install pylint)\nIn vscode: ctrl+shift+P then type linter (choose \"python:select linter\") now you can choose your linter (pylint)\nI hope it helps you","Q_Score":0,"Tags":"python,django,visual-studio-code,pylint","A_Id":61899590,"CreationDate":"2020-05-19T13:54:00.000","Title":"How to add pylint for Django in vscode manually?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a HTML code having a div tag with class=\"some_class\". And there is a p tag inside this div tag:\n<div class=\"some_class\">\n<p>blah blah blah...<\/p>\n<\/div>\nI need to get the p tag's content and store it in a variable.\nI did it in two steps:\n1)Get the div tag using findAll('div', class_='some_class'),\n2)Using split at the p tag\nIs there any direct way of doing this without having to do the complex splitting?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1001,"Q_Id":61894438,"Users Score":1,"Answer":"If you have only one div tag and only one p tag in it, you can do this:\ncontent = soup.findAll('div', class_= 'some_class')[0].findAll('p')[0].contents[0]","Q_Score":2,"Tags":"python,html,web-scraping,beautifulsoup","A_Id":61895043,"CreationDate":"2020-05-19T15:11:00.000","Title":"Getting the content of a  tag inside a  class=\"some_class\"> tag using Beautiful Soup in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have created a lot of visualization for a transaction data set of my company using jupyter notebook. Now I want to make that code reusable so that after my internship other people from my company will be able to generate those visualizations on next quarter data set. Also, they don't know python. Hence I need to create something that grabs data and throws the visualization without much hassle. How can I do this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":61898274,"Users Score":0,"Answer":"On top of my head i could think of many ideas here are some of them.\n\nUsing python interface (tkinter) that accepts the data from the user and show visualization.\nAnother solution could be you can create a web app using flask and accept the data from the user and visualize it. \nIf all of this is not possible you could easily create a script that accepts user data and then separate in 2 categories or dataframe for eg. object datatypes and numerical datatype and then plot using for loops.","Q_Score":0,"Tags":"python,dataframe,automation,jupyter-notebook,visualization","A_Id":61898878,"CreationDate":"2020-05-19T18:33:00.000","Title":"Automating jupyter notebook visualizations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using RDS client of AWS Data API to insert data into AuroraDB through a lambda function.\nI have included all parameters into the query, so the query is not escaped.\nI know the parameterized query prevents SQL injection, but I cannot upgrade all my code.\nSo I just want to escape the parameters while making the query.\nIs there any method that the RDS client provides for escaping?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":249,"Q_Id":61898551,"Users Score":0,"Answer":"There is no boto3 method (via the RDS client or otherwise) to achieve this that I am aware of. There are however ways of achieving an escaped string in python by using native string replace calls, raw strings, etc.","Q_Score":0,"Tags":"python,aws-lambda,boto3,amazon-rds","A_Id":61902128,"CreationDate":"2020-05-19T18:50:00.000","Title":"Is there any function that generate escaped sql query for AWS RDS Data API?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've recently been working on a little project and I want to host it on the cloud so it can run all the time, rather than constantly on my local machine.  However I'm kind of stumped when it comes to choosing a hosting solution, and I was wondering if you guys could give me some advice.\nSome details about the project:\n\nIt's a Python script, not a web app, and should be running constantly (actions are scheduled once per day)\nIt uses a few fairly large external dependencies, namely Selenium and Chromedriver, which requires binaries to be installed on the machine and grabbable (not sure if that's a word) by path from the script\nIt uses a few static files (mp3) as assets, which need to be stored on a file system somehow and grabbed by the script\nIt writes video files to the local filesystem\n\nDo you guys have any recommendations for hosting solutions which satisfy these details? I've tried with Heroku, which satisfies details 1-2, but since Heroku has like a weird \"ephemeral file system\" I can't grab the static files nor write video files to the file system.  \nThanks for the help!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":151,"Q_Id":61899261,"Users Score":1,"Answer":"I suggest you to look at AWS (since is the only platform I've been working with).\nWith it's free acount you can use an EC2, where you can store your script and dependencies, and your output can be written in an S3 instance (free for 30GB if I remeber well).\nAs you are going to use Selenium, you will need a GUI for your system, so your choices are a Windows machine for EC2 or Linux (does not came with a graphical environment by default). It is not difficult to install a GUI on Linux machines and configure to acces by RDP, but I suggest to use instead a simulated graphical environment such as XVFB. I used it and is as simple as launching your script with xvfb run first. That way you are saving some processor load for your machine.\nI hope it helps,\nRegards.","Q_Score":1,"Tags":"python,selenium,filesystems,hosting","A_Id":61899537,"CreationDate":"2020-05-19T19:32:00.000","Title":"How to host selenium Python script with file system access?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I can't open a dot file on vscode in windows 10 even after I have installed in graphviz by Stephanvs extension.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1485,"Q_Id":61899892,"Users Score":2,"Answer":"Try to get Jo\u00e3o Pinto's Graphviz extension","Q_Score":1,"Tags":"python,visual-studio-code,graphviz,decision-tree,image-graphviz","A_Id":61899985,"CreationDate":"2020-05-19T20:09:00.000","Title":"How to open a graphviz(dot) file on vscode windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have situation in centos where 3 different\/Independent caller will try to execute same python script with respective command line args. eg: python main.py arg1, python main.py arg2, python main.py arg3 at same time.\nMy question is - Is it possible in the first place or I need to copy that python script, 3 times with 3 different names to be called by each process. \nIf it is possible then how it should be done so that these 3 processes will not interfare and python script execution will be independent from each other.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":18,"Q_Id":61900303,"Users Score":1,"Answer":"All the python processes will run entirely isolated from each other, even if executing the same source file.\nIf they interact with any external resource other than process memory (such as files on disk), then you may need to take measures to make sure the processes don't interfere (by making sure each instance uses a different filename, for example).","Q_Score":0,"Tags":"python-3.x,centos","A_Id":61900366,"CreationDate":"2020-05-19T20:35:00.000","Title":"Can I execute 1 python script by 3 different caller process at same time with respective arguments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"If I develop a REST service hosted in Apache and a Python plugin which services GET, PUT, DELETE, PATCH; and this service is consumed by an Angular client (or other REST interacting browser technology).  Then how do I make it scale-able with RabbitMQ (AMQP)?  \nPotential Solution #1\n\nMultiple Apache's still faces off against the browser's HTTP calls.\nEach Apache instance uses an AMQP plugin and then posts message to a queue\nPython microservices monitor a queue and pull a message, service it and return response\nResponse passed back to Apache plugin, in turn Apache generates the HTTP response \n\nDoes this mean the Python microservice no longer has any HTTP server code at all.  This will change that component a lot.  Perhaps best to decide upfront if you want to use this pattern as it seems it would be a task to rip out any HTTP server code.\nOther potential solutions?  I am genuinely puzzled as to how we're supposed to take a classic REST server component and upgrade it to be scale-able with RabbitMQ\/AMQP with minimal disruption.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":241,"Q_Id":61900319,"Users Score":2,"Answer":"I would recommend switching wsgi to asgi(nginx can help here), Im not sure why you think rabbitmq is the solution to your problem, as nothing you described seems like that would be solved by using this method.\nasgi is not supported by apache as far as I know, but it allows the server to go do work, and while its working it can continue to service new requests that come in. (gross over simplification)\nIf for whatever reason you really want to use job workers (rabbitmq, etc) then I would suggest returning to the user a \"token\" (really just the job_id) and then they can call with that token, and it will report back either the current job status or the result","Q_Score":0,"Tags":"python,rabbitmq,amqp","A_Id":61900432,"CreationDate":"2020-05-19T20:36:00.000","Title":"How to interpose RabbitMQ between REST client and (Python) REST server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to use spacy's pretrained BERT model for text classification but I'm a little confused about cased\/uncased models. I read somewhere that cased models should only be used when there is a chance that letter casing will be helpful for the task. In my specific case: I am working with German texts. And in German all nouns start with the capital letter. So, I think, (correct me if I'm wrong) that this is the exact situation where cased model must be used. (There is also no uncased model available for German in spacy). \nBut what must be done with data in this situation?\nShould I (while preprocessing train data) leave it as it is (by that I mean not using the .lower() function) or it doesn't make any difference?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":11834,"Q_Id":61902426,"Users Score":0,"Answer":"The difference between \"BERT cased\" and \"BERT uncased\" can to finded in different contexts. For example, in the dialogs system, the users rarely put the text in their correct form, so,  is ordinary to find the words in lower case. Maybe, in this case, the BERT in uncased have an advantage.","Q_Score":10,"Tags":"python,spacy,bert-language-model","A_Id":66482983,"CreationDate":"2020-05-19T23:20:00.000","Title":"Cased VS uncased BERT models in spacy and train data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use spacy's pretrained BERT model for text classification but I'm a little confused about cased\/uncased models. I read somewhere that cased models should only be used when there is a chance that letter casing will be helpful for the task. In my specific case: I am working with German texts. And in German all nouns start with the capital letter. So, I think, (correct me if I'm wrong) that this is the exact situation where cased model must be used. (There is also no uncased model available for German in spacy). \nBut what must be done with data in this situation?\nShould I (while preprocessing train data) leave it as it is (by that I mean not using the .lower() function) or it doesn't make any difference?","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":11834,"Q_Id":61902426,"Users Score":4,"Answer":"In simple terms, BERT cased doesn't lowercase the word starting with a capital letter for example in the case of Nouns in the German language.\nBERT cased is helpful where the accent plays an important role.\nFor example sch\u00f6n in German\nIf we convert sch\u00f6n to schon using BERT uncased, it will have a different meaning.\nsch\u00f6n means beautiful whereas schon means already","Q_Score":10,"Tags":"python,spacy,bert-language-model","A_Id":68660367,"CreationDate":"2020-05-19T23:20:00.000","Title":"Cased VS uncased BERT models in spacy and train data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use spacy's pretrained BERT model for text classification but I'm a little confused about cased\/uncased models. I read somewhere that cased models should only be used when there is a chance that letter casing will be helpful for the task. In my specific case: I am working with German texts. And in German all nouns start with the capital letter. So, I think, (correct me if I'm wrong) that this is the exact situation where cased model must be used. (There is also no uncased model available for German in spacy). \nBut what must be done with data in this situation?\nShould I (while preprocessing train data) leave it as it is (by that I mean not using the .lower() function) or it doesn't make any difference?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":11834,"Q_Id":61902426,"Users Score":12,"Answer":"As a non-German-speaker, your comment about nouns being uppercase does make it seem like case is more relevant for German than it might be for English, but that doesn't obviously mean that a cased model will give better performance on all tasks.\nFor something like part-of-speech detection, case would probably be enormously helpful for the reason you describe, but for something like sentiment analysis, it's less clear whether the added complexity of having a much larger vocabulary is worth the benefits. (As a human, you could probably imagine doing sentiment analysis with all lowercase text just as easily.)\nGiven that the only model available is the cased version, I would just go with that - I'm sure it will still be one of the best pretrained German models you can get your hands on. Cased models have separate vocab entries for differently-cased words (e.g. in english the and The will be different tokens). So yes, during preprocessing you wouldn't want to remove that information by calling .lower(), just leave the casing as-is.","Q_Score":10,"Tags":"python,spacy,bert-language-model","A_Id":61906361,"CreationDate":"2020-05-19T23:20:00.000","Title":"Cased VS uncased BERT models in spacy and train data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a triangular sparse matrix of dimension n where the only coefficients that appear are c_1, c_2,...c_n. There are at most n repetitions of a single coefficient in the matrix. Is there any way to use the fact that there are many elements of the matrix that are the same and use much less memory instead of assigning the same value to many different (row, column) and not exploiting the fact that many are the same. At the end of the day I want to apply the inverse of the said matrix to an arbitrary vector.\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":61903281,"Users Score":0,"Answer":"Definitely, you can use the sparse matrix data structures from 'scipy.sparse'. If you know the values tend to group in certain patterns you can use specific sparse matrix structures optimized for that pattern. If the values group along diagonals use 'dia_matrix', columns use 'csc_matrix', rows use 'csr_matrix', and blocks use 'bsr_matrix'.","Q_Score":0,"Tags":"python,scipy,sparse-matrix","A_Id":61903483,"CreationDate":"2020-05-20T00:53:00.000","Title":"Sparse matrices with lots of repeated elements in Scipy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I built my Django project on my local PC and then I 'uploaded' all the files to GitHub. For using PythonAnywhere as a clone to GitHub, I thought all the files wouldn't be transfered to PythonAnywhere server, but for my surprise they all gone there.\nIn this way, I have now 3 different locals to get my files stored: local PC, GitHub and PythonAnywhere.\nWhen I make changes in my code (PC), I'll have to commit to GitHub and then update to PythonAnywhere?\nIs that all right or I'm missing something?\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":65,"Q_Id":61904399,"Users Score":1,"Answer":"commit on your local machine\npush to github\npull on PythonAnywhere\nrun .\/manage.py migrate if needed\nreload your web app on PythonAnmywhere \"web\" page","Q_Score":0,"Tags":"python,django,github","A_Id":61910682,"CreationDate":"2020-05-20T03:09:00.000","Title":"Deploy PythonAnywhere","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"As the title suggests, I want to generate a random N x d matrix (N - number of examples, d - number of features) where each column is linearly independent of the other columns. How can I implement the same using numpy and python?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":801,"Q_Id":61905733,"Users Score":1,"Answer":"If you just generate the vectors at random, the chance that the column vectors will not be linearly independent is very very small (Assuming N >= d).\nLet A = [B | x] where A is a N x d matrix, B is an N x (d-1) matrix with independent column vectors, and x is a column vector with N elements. The set of all x with no constraints is a subspace with dimension N, while the set of all x such that x is NOT linearly independent with all column vectors in B would be a subspace with dimension d-1 (since every column vector in B serves as a basis vector for this set).\nSince you are dealing with bounded, discrete numbers (likely doubles, floats, or integers), the probability of the matrix not being linearly independent will not be exactly zero. The more possible values each element can take, in general, the more likely the matrix is to have independent column vectors.\nTherefore, I recommend you chose elements at random. You can always verify after the fact that the matrix has linearly independent column vectors by calculating it's column-echelon form. You could do this with np.random.rand(N,d).","Q_Score":4,"Tags":"python,numpy,scipy","A_Id":61906800,"CreationDate":"2020-05-20T05:28:00.000","Title":"Generating linearly independent columns for a matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking into the ways for comparing records from same table but on different databases. I just need to compare and find the missing records.\nI tried out a few methods.\nloading the records into a pandas data frame, I used read_sql. But it is taking more time and memory to complete the load and if the records are large, I am getting a memory error.\nTried setting up a standalone cluster of spark and run the comparison,  it is also throwing java heap space error. tuning the conf is not working as well.\nPlease let me know if there are other ways to handle this huge record comparison.\n--update\nDo we have a tool readily available for cross data source comparison","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":61906560,"Users Score":0,"Answer":"If your data size is huge you can use cloud services to run your spark job and get the results. Here you can use aws glue which is serverless and is charged as you go.\nOr if your data is not considerably large and is something one time job then you can use google colab which is free and run your comparision over it .","Q_Score":0,"Tags":"python-3.x,database,pyspark,apache-spark-sql","A_Id":61906771,"CreationDate":"2020-05-20T06:33:00.000","Title":"Possible ways of comparing large records from one table on a database and another table on another database","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Do you know how to create package from my python application to be installable on Windows without internet connection? I want, for example, to create tar.gz file with my python script and all dependencies. Then install such package on windows machine with python3.7 already installed. I tried setuptools but i don't see possibility to include dependencies. Can you help me?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":37,"Q_Id":61907614,"Users Score":-1,"Answer":"Their are several Java tutorials on how to make installers that are offline. You have your python project and just use a preprogrammed Java installer to then put all of the 'goodies' inside of. Then you have an installer for windows. And its an executable.","Q_Score":0,"Tags":"python,python-3.x","A_Id":61907790,"CreationDate":"2020-05-20T07:41:00.000","Title":"Create package with dependencies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a text file, which contains lines with data(key-values pairs):\n\"\\x80\\x80\\x13_@\\x80\":\"\\xff\\xff\\x80Sometext\\x56\\\"\\x64\\u0001(more bytes with unicode reprsentation and unicode and latin symbols)\\xfdg\\u0080moretext\\x30\u4e2d\\x52\\x23\\x24P\" \n(maybe \\U00000000 (not sure))\n(it is mixed actually and I have hard time understanding how to convert this to bytes format because I need data from the file.\nWhen I read as bytes I have hard time figuring how to deal with it.\nIf I read as text it has two \\ before.\n(it is a dump from golang\/leveldb, I wanted to split it to extract the wav data).","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":58,"Q_Id":61907725,"Users Score":1,"Answer":"if its a string (or unicode in py2) you can just call my_string.encode(\"utf8\") since I believe that all characters in unicode can be represented in utf8(take with a grain of salt) ... (note not all bytes necessarily so if you have weird random binary data in there too that probably would not work so well)\nif its already in bytes its harder... you really would need to know the appropriate encoding","Q_Score":0,"Tags":"python,unicode,byte","A_Id":61907791,"CreationDate":"2020-05-20T07:46:00.000","Title":"How do I convert text file with mixed unicode representation and unicode to bytes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new at learning Python and i am trying to trying to set up the environment on VS code. However, the Debug icon and function is not on the menu bar. Please how do I rectify this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":61908228,"Users Score":0,"Answer":"right click on the menu bar. you can select which menus are active. it's also called run i believe.","Q_Score":1,"Tags":"python,python-3.x,visual-studio-code,data-science","A_Id":61908256,"CreationDate":"2020-05-20T08:14:00.000","Title":"Debug function not appearing in the menu bar in VS Code. I am using it for Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know it's a very general question but I am open for different options.\nLet me clarify what my codes do:  \n\nThe C++ code produces multiple .png files as output as follows  \n.\/Debug\/mycpp input1path input2path output parameter1 parameter2  \nThe python code takes those png files to do image processing and returns them as png as well  \nmypython.py inputpath outputpath\n\nWhat I want to do:\n* To create an \"executor code\" that runs and links those 2 codes\n* The only criterion is that 'the executor code' should work on Ubuntu  \nAny suggestions will be appreciated.  \nAdditional notes:\n* I don't want to call c++ in python, I just want to create a 3rd code (e.g. shell script) that calls c++ first then calls python after c++ has finished it's task.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":61908313,"Users Score":1,"Answer":"Python is perfect for such scripts, it has a complete support for such scripts.\nYou should look at subprocess and os modules for the complete command set for it.","Q_Score":0,"Tags":"python,c++,linux","A_Id":61908438,"CreationDate":"2020-05-20T08:18:00.000","Title":"Running a C++ code and a Python code consecutively","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"What is an efficient way of doing it ?  \nI may have thousands of key:value pairs(which I am extracting from jsons) to add to an existing dict. \nShould I just loop through them, or is there a mass update option ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":20,"Q_Id":61909710,"Users Score":1,"Answer":"You can use the update functions for add all of the value from another dict\nyour_dict.update(all_value_to_add)\nElse you effectly can loop trough them","Q_Score":0,"Tags":"python-3.x,dictionary","A_Id":61909806,"CreationDate":"2020-05-20T09:33:00.000","Title":"Adding many keys to a dictionary","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for an entrypoint in DeepSecurity 12 to launch malware scan \"On Demand\".\nI only found a way to do it by creating a schedule task, but it is not conveniant for my needs.\nThanks a lot in advance guys,\nCheers !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":61910052,"Users Score":0,"Answer":"To the best of my knowledge, you do need to use the Scheduled Task API to launch a malware scan on demand. But do note that you can set the \"run now\" field of a scheduled task (new or existing) to \"true\" to trigger an immediate scan, which makes it more convenient.\nCheers,\nMorgan\nP.S. I work in R&D for Trend Micro.","Q_Score":0,"Tags":"python,api,deepsecurity","A_Id":61917501,"CreationDate":"2020-05-20T09:50:00.000","Title":"Is there an API entrypoint to launch malware scan immediately without scheduling it (On Demand) in DeepSecurity 12?","Data Science and Machine Learning":0,"Database and SQL":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 Windows 10 64bit alongside with Anaconda3 64bit. This yields a Python 64bit installation.\nWith that, I'm creating .exe files using PyInstaller, but obviously, it packs the Python 64bit version into the .exe, so this will NOT run on a 32bit machine. \nTo make an exe for a 32bit machine, I'd need to use Python 32bit. Is there a way to create a 32bit Python environment alongside my current Anaconda installation? Or would I need to download yet another Anaconda as second installation, which is kinda ugly IMHO?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":425,"Q_Id":61910294,"Users Score":1,"Answer":"init \"Anaconda Prompt\"\nexec set CONDA_FORCE_32BIT=1. This command set a temp env var for current terminal and switch the conda to 32-bit mode\nuse conda to create a new python env and it will be 32-bit","Q_Score":1,"Tags":"python,anaconda,64-bit","A_Id":61947484,"CreationDate":"2020-05-20T10:02:00.000","Title":"Anaconda 64bit and Pyinstaller: Create exe for 32bit system","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am trying implement from scipy.spatial import distance as dist library however it gives me   File \"\/home\/afeyzadogan\/anaconda3\/envs\/untitled\/lib\/python3.7\/inspect.py\", line 56, in \n    for k, v in dis.COMPILER_FLAG_NAMES.items():\nAttributeError: module 'dis' has no attribute 'COMPILER_FLAG_NAMES'\nerror how can i solve it?\n'''\nfor k, v in dis.COMPILER_FLAG_NAMES.items():\n    mod_dict[\"CO_\" + v] = k\n'''","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":641,"Q_Id":61910425,"Users Score":1,"Answer":"We ran across this issue in our code with the same exact AttributeError.\nTurns out it was a totally unrelated file in the current directory called dis.py.","Q_Score":0,"Tags":"python,inspect","A_Id":67427679,"CreationDate":"2020-05-20T10:08:00.000","Title":"How can i solve AttributeError: module 'dis' has no attribute 'COMPILER_FLAG_NAMES' in anaconda3\/envs\/untitled\/lib\/python3.7\/inspect.py","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wonder if there is a way to evaluate batches of individuals when running deap ? The classic implementations evaluate individuals one by one but my evaluation function requires me to evaluate the inidviduals with a surrogate model that is only accessible online and connecting to the server where this model is kept is time-consuming so I would prefer directly sending the whole population to the server for evaluation instead of having to connect for each individual.\n(It takes approx. 40 seconds to get my results whatever the number of evaluation I am asking and there is no way for me to change this as it is due to the software I am connecting to that can't be changed)\nEvaluation function is called with : fitnesses = toolbox.map(toolbox.evaluate, invalid_ind) and I have previously defined  toolbox.register(\"evaluate\", evaluation_fct)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":79,"Q_Id":61910667,"Users Score":1,"Answer":"By calling fitnesses = evaluation_fct(invalid_ind) I managed what I wanted to do (invalid_ind being a list of the individuals to evaluate) and therefore it becomes unnecesaary to call the toolbox.register(\"evaluate\", evaluation_fct)","Q_Score":1,"Tags":"python,python-3.x,deap","A_Id":61934052,"CreationDate":"2020-05-20T10:21:00.000","Title":"Evaluate batch of individuals in Deap instead of one-by-one evaluation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"when I try to check python version in Centos7 by typing  command \n1) python --version\n-bash: \/usr\/local\/bin\/python3.6: No such file or directory\n                 OR\n2) which python \n\"alias python='\/usr\/local\/bin\/python3.6'. \nCould anyone explain me why it shows like this instead of showing python version?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":40,"Q_Id":61911137,"Users Score":1,"Answer":"In order to sum up, for future people who will look in this question:\nwhen installing different versions of python on linux using package manager (in this case yum because you are using CentOS, but it might be apt or something else)  linux installs the side-by-side, meaning you have all of the versions installed together.  \nIf you want to use a specific version other than your linux distribution diffault one you need to call it explicitly (i.e. python3.6 or python3.8)\nMake sure you are looking for the wanted python version on the right path.  \nWhen you want to run some version of python after installing it I suggest you to just write python in the bash and just hit tab+tab and the bash will suggest all the installed versions in the $PATH.","Q_Score":2,"Tags":"python-3.x","A_Id":61996544,"CreationDate":"2020-05-20T10:46:00.000","Title":"how to verify whether latest python version installed properly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My login forms are working properly but are not connected to the html button. The page with this button is on another url different from the accounts page. How do i link it with the app for accounts or folder containing my html forms. Is there a way of inheriting the app folder into this main folder or inporting just to have a link.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":36,"Q_Id":61912608,"Users Score":1,"Answer":"in link just used {% url 'app_name:name' %}\nhere app_name = in urls.py file\nand name is path name.","Q_Score":0,"Tags":"python,html,css,django,forms","A_Id":61914185,"CreationDate":"2020-05-20T12:01:00.000","Title":"Link html buttons to user registration form","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How do I tell IDE like PyCharm that my libraries are installed on virtual environment ?\nExample : I have openCV libraries installed in a virtual environment.If I try to run the program on PyCharm IDE it will show import like ModuleNotFoundError: No module named 'cv2'","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":61913011,"Users Score":2,"Answer":"You should select your virtual environment in Pycharm settings: File->New Project Settings -> Preferences for New Projects -> Project Interpreter. \nFrom there you can select a found environment or click \"+\" in Project Interpreter list to add your own env from a path. This env will be added to the list. Also you are able to add new libs using \"+\" in the end of current libs list.","Q_Score":0,"Tags":"python,pycharm,ide,virtualenv","A_Id":61913495,"CreationDate":"2020-05-20T12:20:00.000","Title":"How to Run python program with libraries installed in virtual environment using IDE like PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that there are other questions like this but they don't answer what happens to the previous value after reassignment, that's why I decided to post a new question. So far I've learned that everything in python is an object, even the variables of type int, float, string, bool are objects, I've read somewhere that when we assign a variable num = 11 then num is not actually storing the value of \"11\" in it but instead it is a pointer which is pointing at a certain location in memory where \"11\" is stored, and if we tried to reassign a value to num num = 22 then it will just stop pointing at \"11\" and start pointing at that new value \"22\" which will be stored in a different location in the memory, So my question is that what happens to the previous value i.e 11 does that get free'd or deleted??","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":623,"Q_Id":61913056,"Users Score":3,"Answer":"Python keeps track of how many references a particular variable has. If there isn't any reference to a particular value it would be cleaned which is also known as Garbage Collection. So in your case 11 would be removed (garbage collected) by python as soon as it loses the reference.","Q_Score":3,"Tags":"python,object,variables,immutability","A_Id":61913229,"CreationDate":"2020-05-20T12:23:00.000","Title":"In python when we assign a new value to a variable what happens to the old one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use lasso regression in sklearn to run on my data.\nall my attributes in my dataframe is numeric type(by numeric, I mean they are all integer). \nbut some of them clearly should be categorical(for example, 'race' attribute in my dataframe is an attribute have three value 1,2,3 where each value represent one race).\nWhat I did is first set those columns as string type by using astype('str') then use code astype('categorical') to transform those column's data type to categorical.\nFinally, I used sklearn.linear_model.Lasso on those transformed features.\nMy question is can sklearn.linear_model.Lasso recognize those variables are categorical? Or the only way to deal with those type of categorical data is one hot encoding?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":380,"Q_Id":61914504,"Users Score":0,"Answer":"I would use OneHotEncoding to separate the categorical variables into different columns. However, make sure that you avoid the \"dummy variable trap\" by getting rid of the first column of your new dummy variables. \nYou want to use OneHotEncoding so that your program is able to recognize that no category of your categorical variables is numerically greater than the others. For example, let's say you have a column wherein 0 = Spain, 1 = Germany, and 2 = France. In this case, your program would assume that the column for geography is a continuous variable, wherein 2(France) is greater than 1(Germany). Thus, you must use OneHotEncoding to create three separate columns of 0's and 1's. \nI hope that answers your question.","Q_Score":1,"Tags":"python,pandas,scikit-learn","A_Id":61920131,"CreationDate":"2020-05-20T13:36:00.000","Title":"Can sklearn.linear_model.Lasso recognize the categorical data type in pandas dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I save a plot in a 750x750 px using savefig?\nThe only useful parameter is DPI, but I don't understand how can I use it for setting a precise size","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":262,"Q_Id":61914547,"Users Score":0,"Answer":"I added plt.tight_layout() before savefig(), and it solved the trimming issue I had. Maybe it will help yours as well.\nI also set the figure size at the begining rcParams['figure.figsize'] = 40, 12(you can set your own width and height)","Q_Score":0,"Tags":"python,matplotlib","A_Id":61914735,"CreationDate":"2020-05-20T13:37:00.000","Title":"save a figure with a precise pixels size with savefig","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a code for blackjack, using the classes and other oops concept. Currently I'm stuck on how to decide what classes it will have.\nFollowing are the rules of blackjack:\n1.Create a deck of 52 cards\n2.Shuffle the deck\n3.Ask the Player for their bet\n4.Make sure that the Player\u2019s bet does not exceed their available chips\n5.Deal two cards to the Dealer and two cards to the Player\n6.Show only one of the Dealer\u2019s cards, the other remains hidden\n7.Show both of the Player\u2019s cards\n8.Ask the Player if they wish to Hit, and take another card\n9.If the Player\u2019s hand doesn\u2019t Bust (go over 21), ask if they\u2019d like to Hit again.\n10.If a Player Stands, play the Dealer\u2019s hand. The dealer will always Hit until the Dealer\u2019s value meets or exceeds 17\n11.Determine the winner and adjust the Player\u2019s chips accordingly\n12.Ask the Player if they\u2019d like to play again\nI'm new to coding and oops, kindly help\nNOTE: this is not a homework problem, as there are many solution on github, which i can copy submit if required. I Just want to learn oops and classes. I don't seek a solution, I'm seeking a correct thought process","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":61915543,"Users Score":0,"Answer":"It is a difficult process; usually, the first step is to identify the nouns in the description of the project, that gives you a starting point from where to think about the shape you will give to your code, and how you see these objects interacting.\nFrom your description, we could list the following nouns: \nDeck, Player, Bet, Chips, Cards, Dealer, Hand, Winner, Player\u2019s stash.\nThey may, or may not represent a useful object in your representation of blackjack. Some may be obvious objects you need now (Deck, Card, Hand, Player, Dealer); some may be combined (Chip, Bet, Stash); some may not be needed in a modest application (Winner, Bet, Stash), and replaced by data structures, like Lists, Vectors, HashTables, etc.\n\n\nCreate a deck of 52 cards\nShuffle the deck\nAsk the Player for their bet\nMake sure that the Player\u2019s bet does not exceed their available chips\nDeal two cards to the Dealer and two cards to the Player\nShow only one of the Dealer\u2019s cards, the other remains hidden\nShow both of the Player\u2019s cards\nAsk the Player if they wish to Hit, and take another card\nIf the Player\u2019s hand doesn\u2019t Bust (go over 21), ask if they\u2019d like to Hit again.\nIf a Player Stands, play the Dealer\u2019s hand. The dealer will always Hit until the Dealer\u2019s value meets or exceeds 17\nDetermine the winner and adjust the Player\u2019s stash accordingly\nAsk the Player if they\u2019d like to play again","Q_Score":0,"Tags":"python,class,oop","A_Id":61926105,"CreationDate":"2020-05-20T14:22:00.000","Title":"How to decide the class that should be built for a problem statement?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given a matrix representing a video, where the rows represent video frames and the columns represent frame features, are there any techniques I can use to create a single feature vector from this without losing the spatio-temporal information from the matrix? i.e. 40 frame vectors with 36 features each converted to 1 vector with 36 features representing the entire 40 frames.\nI've already tried taking the mean for each feature but I'm wondering about other techniques.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":61919224,"Users Score":0,"Answer":"I have no experience on video data. But I had a sense that your problem is the same\/or very similar to text summarization problem. \nIn principle, what you want is to \"summarize\" all your different time frames into just only one frame. It is very much like you have many sentences in one article but you just want to have one sentence which can summarize all the sentences in one article. \nIn general there are two methods:\n1. Extract methods: :Evaluate the importance of each frame and put weights on different frames. Then simply use linear combination to have a summarize vector. In extreme case, you can just use the dominant frame as a representative frame if its weight is much bigger than the others. This method is very similar to TextRank or TextTeasing algorithm in NLP. \n2. Abstract methods: : In case of NLP, you need some knowledge of linguist and sentence semantic structures in order to develop this approach. In your case, I believe you need to do the same thing for your video data.","Q_Score":0,"Tags":"python,machine-learning","A_Id":61929407,"CreationDate":"2020-05-20T17:27:00.000","Title":"Converting matrix to spatio-temporal feature vector","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working my way to deploy my django app on a Linux Server. Encountered with various problems and want someone to clarify that for me. I searched for days but the answer I found are either too broad or faded away from topic.\n1) According to django docs, it is inefficient to serve static files locally. Does that means that all the static files including html,css,js files should be hosted on another server?\n2) I have an AWS S3 bucket hosting all my media files, can I use that same bucket (or create a new bucket) to host my static files if above answer is yes. If so, is that efficient?\n3) According to search, in order for django to scale horizontally, it should be a stateless app, does it means that I also have to host my database on a different location than my own Linux server ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":364,"Q_Id":61921135,"Users Score":1,"Answer":"1) It is completely fine to host your staticfiles on the same server as your django application however to serve said files you should use a web server such as NGINX or Apache. Django was not designed to serve static data in a production environment. Nginx and Apache on the other hand do great job at it.\n2) You can definitely host your static and media files inside an S3 bucket. This will scale a lot better than hosting them on a single server as they're provided by a separate entity, meaning that no matter how many application servers you're running behind a load balancer, all of them will be requesting staticfiles from the same source. To make it more efficient you can even configure AWS' CloudFront which is Amazons CDN (content delivery network).\n3) Ideally your database should be hosted on a separate server. Databases are heavy on resources therefore hosting your database on the same server as your application may lead to slowdowns and sometimes outright crashes. Scaling horizontally, you'd be connecting a lot of application servers to a single database instance; effectively increasing the load on that server.\nAll of the points above are relative to your use case and resources. If the application you are running doesn't deal with heavy traffic - say a few hundred hits a day - and your server has an adequate amount of resources (RAM, CPU, storage) it's acceptable to run everything off a single box.\nHowever if you're planning to accept tens of thousands of connections every day it's better to separate the responsibilities for optimum scalability. Not only it makes your application more efficient and responsive but it also makes your life easier in the long run when you need to scale further (database clustering, nearline content delivery, etc).\nTL;DR: you can run everything off a single server if it's beefy enough but in the long run it'll make your life harder.","Q_Score":1,"Tags":"python,django,django-deployment","A_Id":61921830,"CreationDate":"2020-05-20T19:15:00.000","Title":"Deployment of django app - Scaling, Static Files, Servers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"There is an API that I am using from another company that returns the ID-s of the last 100 purchases that have been made in their website.\nI have a function change_status(purchase_id) that I would like to call whenever a new purchase has been made. I know a workaround on how to do it, do a while True loop, keep an index last_modified_id for the last modified status of a purchase and loop all purchases from the latest to the earliest and stop once the current id is the same as last_modified_id and then put a sleeper for 10 seconds after each iteration. \nIs there a better way on how to do it using events in python? Like calling the function change_status(purchase_id) when the result of that API has been changed. I have been searching around for a few days but could not find about about an event and an API. Any suggestion or idea helps. Posting what I have done is usually good in stackoverflow, but I don't have anything about events. The loop solution is totally different from the events solution.\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":61921432,"Users Score":1,"Answer":"The only way to do this is to keep calling the API and watching for changes from the previous response, unless...\nThe API provider might have an option to call your API when something is updated on their side. It is a similar mechanism to push notifications. If they provide a method to do that, you can create an endpoint on your side to do whatever you need to do when a new purchase is made, and provide them the endpoint. However, as far as I know, most API providers do not do this, and the first method is your only option.\nHope this helps!","Q_Score":1,"Tags":"python,api,events","A_Id":61921484,"CreationDate":"2020-05-20T19:33:00.000","Title":"Call function when new result has been returned from API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been studying python for data science for about 5 months now. But I get really stucked when it comes to matplotlib. There's always so many options to do anything, and I can't see a well defined path to do anything. Does anyone have this problem too and knows how to deal with it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":61921792,"Users Score":0,"Answer":"I think your question is stating that you are bored and do not have any projects to make. If that is correct, there are many datasets available on sites like Kaggle that have open-source datasets for practice programmers.","Q_Score":0,"Tags":"python,matplotlib,data-science","A_Id":61922150,"CreationDate":"2020-05-20T19:55:00.000","Title":"Tips to practice matplotlib","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been studying python for data science for about 5 months now. But I get really stucked when it comes to matplotlib. There's always so many options to do anything, and I can't see a well defined path to do anything. Does anyone have this problem too and knows how to deal with it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":61921792,"Users Score":0,"Answer":"in programming in general \" There's always so many options to do anything\".\ni recommend to you that read library and understand their functions and classes in a glance, then go and solve some problems from websites or give a real project if you can. if your code works do not worry and go ahead. \nafter these try and error you have a lot of real idea about various problems and you recognize difference between these options and pros and cons of them. like me three years ago.","Q_Score":0,"Tags":"python,matplotlib,data-science","A_Id":61922191,"CreationDate":"2020-05-20T19:55:00.000","Title":"Tips to practice matplotlib","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My target is continuous value like house price. I am training a regression tree on it. I use Gradientboostregressor in scklearn, Python. \nMy target value(house price) has a L shape distribution: house price on high end is like 10 times higher than price on low end. My regression tree model under-predict high values, and over-predict low values. \nAnything I can do to improve model prediction? I tried to model log(price), then exp(prediction),but not work well. \nThank you very much.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":61922639,"Users Score":0,"Answer":"A single decision tree often does not work very well.  Of course you could try to optimize the tree. But I think it is better to change to random forest or gradient boosting if you want to work with trees.","Q_Score":1,"Tags":"python,regression,decision-tree","A_Id":61922711,"CreationDate":"2020-05-20T20:49:00.000","Title":"Regression tree does not perform well","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use PyGame for creating games, but I noticed that the programs ran a lot slower on macOS than on my Raspberry Pi. My original solution was to install Ubuntu alongside macOS on my computer, and that worked. However, I would rather only have one operating system on my computer. Does anyone know why PyGame is so much slower on my mac when running macOS?\nIf it would help, I can send code. However, I have multiple PyGame programs and they all do the exact same thing, so I figured that it was most likely not the fault of the code, but I could be wrong.\nAny help is appreciated, thanks.\nP.S. When I say slower, I mean that it is running at about 30% of the speed on macOS than it would on Ubuntu.","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":329,"Q_Id":61923965,"Users Score":-1,"Answer":"MacOS is generally slower\nUnless you can install a second RAM stick it will always be that way","Q_Score":6,"Tags":"python,python-3.x,macos,pygame","A_Id":62524732,"CreationDate":"2020-05-20T22:25:00.000","Title":"PyGame slower on macOS than on Ubuntu or Raspbian","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Attempting to use GCP Authorized Session get method in Python to query data in GCP.  The doc shows:\nget(url, **kwargs)\nSends a GET request. Returns Response object.\nParameters: \nurl \u2013 URL for the new Request object.\n**kwargs \u2013 Optional arguments that request takes.\nReturn type:\nrequests.Response\nI set up a kwarg dict as kwargs = {'page_size': 2000'}\nHowever, when I passed it to the call authsess.get('someurl', kwargs), I get the following error...\nTypeError: get() takes 2 positional arguments but 3 were given.\nIt works fine using just the url, but, I will need to add parms (specifically a nextPageToken as if one is returned)\nCan someone please give me a little guidance on what I am missing here?  Do I need to encode the url and parms together? or?  I have tried various options here, but, just can't get it to work and not sure yet just 'how' to interpret\/implement what I find in the doc for making http requests...\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":131,"Q_Id":61924362,"Users Score":1,"Answer":"OK, sorry if I wasted anyone's time.  The answer is that I needed to add 'params=' to the beginning of the parameters string...  i.e., authsess.get('someurl', params=kwargs)\nReally wish that had been mentioned in the doc....","Q_Score":0,"Tags":"python,google-cloud-platform,parameters,get,request","A_Id":61925609,"CreationDate":"2020-05-20T22:59:00.000","Title":"GCP authorized session get method using python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This should be pretty basic; I am not sure what the error I am making is. I am attempting to query a database using a Python variable in the query and I am able to query successfully with this:\nlocationIDSelectQuery = ('SELECT locationId FROM stateTemplate WHERE id = 1')\ncursor.execute(locationIDSelectQuery)\nand unsuccessfully with this:\nstateTableRowId = 1\ncursor.execute(\"SELECT locationId FROM stateTemplate WHERE id=?\", stateTableRowId)\nWhen I try this in the latter it doesn't work either (statetableRowID).\nSame error message in both instances:\nTraceback (most recent call last):\nline 29, in \n    cursor.execute(\"SELECT locationId FROM stateTemplate WHERE id=?\", (stateTableRowId))\nValueError: Could not process parameters\nHow can I use a Python variable in my SQL query?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":61924935,"Users Score":0,"Answer":"I combined the recommendations of @zealous and @juanpa.arrivillaga to arrive at a working solution:stateTableRowId = 1\ncursor.execute(\"SELECT locationId FROM stateTemplate WHERE id=%s\", (stateTableRowId,))\nMy understanding is that it may be preferable for security reasons to use ? instead of %s. I have yet to get that to work with the database to which I'm connecting.","Q_Score":0,"Tags":"python,sql,variables,parameters","A_Id":61944382,"CreationDate":"2020-05-21T00:01:00.000","Title":"How Can I Use A Python Variable In A SQL Query So That Parameters Are Processed?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed superset in python virtual env on GCP VM. I am running the superset using following command inside the virutal env.\ngunicorn -w 5 --timeout 120 -b 0.0.0.0:8088 \"superset.app:create_app()\"\nBut when i  terminate my SSH connection the server stops, How to run SupserSet forever irrespective of my SSH connection.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":532,"Q_Id":61928369,"Users Score":0,"Answer":"you can usually run commands as a daemon using:\nnohup <your command> &","Q_Score":1,"Tags":"python","A_Id":61928991,"CreationDate":"2020-05-21T06:13:00.000","Title":"Run the Server in the background","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a OnetoOne field  with primary_key=True in a model.\nNow I want to change that to a ForeignKey but cannot since there is no 'id'.\nFrom this:\n\nuser = models.OneToOneField(User, primary_key=True, on_delete=models.CASCADE)\n\nTo this:\n\nuser1 = models.ForeignKey(User, related_name='questionnaire', on_delete=models.CASCADE)\n\nShowing this while makemigrations:\n\nYou are trying to add a non-nullable field 'id' to historicaluserquestionnaire without a default; we can't do that (the database needs something to populate existing rows).\n  Please select a fix:\n   1) Provide a one-off default now (will be set on all existing rows with a null value for this column)\n   2) Quit, and let me add a default in models.py\n\nSo how to do that?\nThanks!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":640,"Q_Id":61930115,"Users Score":1,"Answer":"The problem is that your trying to remove the primary key, but Django is then going to add a new primary key called \"id\".  This is non-nullable and unique, so you can't really provide a one-off default.\nThe easiest solution is to just create a new model and copy your table over in a SQL migration, using the old user_id to populate the id field.  Be sure to reset your table sequence to avoid collisions.","Q_Score":0,"Tags":"python,django,django-models","A_Id":69903289,"CreationDate":"2020-05-21T08:14:00.000","Title":"OnetoOne (primary_key=Tue) to ForeignKey in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a trained model that determines if an image contains either cat or dog. I'm using SVM to classify. I want a new model that determines if an image is a mouse or not. It's different from the first model that classifies into 2 classes. This new model will return TRUE or FALSE only.\nI don't think I can use a classifier model since I have only 1 class; the mouse. I don't intend to use the first model or anything related to it in the 2nd model.\nWhat is the best way to approach this?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":891,"Q_Id":61930631,"Users Score":0,"Answer":"If you already have a mouse class, you can use supervised learning. \nwhen you train your model, let the model learn what is a mouse by defining him that this is a specific object is mouse and define him what is not a mouse...\nWith this approach you just need a class of mouse to define your model and \"teach\" him what is a mouse, after this, your model will classify \"mouse\" and \"not mouse\"","Q_Score":0,"Tags":"python-3.x,machine-learning,computer-vision","A_Id":61930765,"CreationDate":"2020-05-21T08:46:00.000","Title":"How to determine if image is something or not?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a trained model that determines if an image contains either cat or dog. I'm using SVM to classify. I want a new model that determines if an image is a mouse or not. It's different from the first model that classifies into 2 classes. This new model will return TRUE or FALSE only.\nI don't think I can use a classifier model since I have only 1 class; the mouse. I don't intend to use the first model or anything related to it in the 2nd model.\nWhat is the best way to approach this?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":891,"Q_Id":61930631,"Users Score":1,"Answer":"If you'd like to be able to predict if an image has a mouse, this is still a classification problem where you're classifying images into two classes -  Mouse and Not a Mouse. \nAny classifier you intend to use might need to learn a boundary to separate the mouse images from non mouse images in the n-dimensional input space. \nIn case you employ a neural network, you could make do with just one output neuron that will ideally give high probability when the image is a mouse and low when there isn't a mouse in the image.","Q_Score":0,"Tags":"python-3.x,machine-learning,computer-vision","A_Id":61930853,"CreationDate":"2020-05-21T08:46:00.000","Title":"How to determine if image is something or not?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a trained model that determines if an image contains either cat or dog. I'm using SVM to classify. I want a new model that determines if an image is a mouse or not. It's different from the first model that classifies into 2 classes. This new model will return TRUE or FALSE only.\nI don't think I can use a classifier model since I have only 1 class; the mouse. I don't intend to use the first model or anything related to it in the 2nd model.\nWhat is the best way to approach this?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":891,"Q_Id":61930631,"Users Score":1,"Answer":"The best approach, the one that seems to have better results in research and industry is to use a Neural Network, a CNN (convolutional network to be more precise, although a linear forward layer would also work).  \nNothing has changed from cats vs dogs to mouse vs not mouse. Still a classification problem.Since you are using an SVM I assume you don't have a lot of data, maybe try using transfer learning with resnet models ? It might yield good results. \nIf it's still not enough, you can still use SVM for classification 1-mouse 0- not a mouse.!\nHope it helped !\nBest!","Q_Score":0,"Tags":"python-3.x,machine-learning,computer-vision","A_Id":61932247,"CreationDate":"2020-05-21T08:46:00.000","Title":"How to determine if image is something or not?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want write code fetch data from teradata using python. The code should work while running using spark on cluster as well as local. While running using spark I don't want to open connections on executors. So the plan is to run code on driver using teradatasql package. Since teradatasql packages so library I thought I don't have install teradata library on cluster. \nI packaged the dependencies i.e. teradatasql as egg file and passed it as --py-files. But while running on code teradatasql is not able to read library from egg file. \nOs error: teradatasql.so cannot open shared object file. Not a directory.\nI followed the below steps to package the egg file.\n1. pip install teradatasql --target.\/src # note all my code is in src folder. Doing this step will install teradatasql package in my src folder. it contains teradatasql.so library\n2. In setup.py packages=find_packages('src'), package_data={'teradatasql':['teradatasql.so']}\n3. python setup.py bdist_eggg","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":61931878,"Users Score":0,"Answer":"The teradatasql driver uses a shared library to communicate with the Teradata Database.\nThe teradatasql driver will not work if you repackage just the Python file portion of the driver. The error will occur that you got.\nThe intended use of the teradatasql driver is that you install it into your Python environment with the command: pip install teradatasql\nWe will not be able to effectively support you if you take apart and repackage the teradatasql driver. That is not a supported use case.","Q_Score":0,"Tags":"python,apache-spark,teradata","A_Id":61960405,"CreationDate":"2020-05-21T09:58:00.000","Title":"Running Teradatasql driver for python code using spark","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been stuck with this problem since last night trying to solve and have tried all recommended solutions here and still didn't work. I am hoping to find a positive suggestion if there is actually any possible method I may not have tried yet. I started experiencing problems with my virtaulenv and virtualwrapper after downgrading my python version from 3.7 to 3.6.\n\"\/usr\/local\/opt\/python\/bin\/python3.6: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper')\nvirtualenvwrapper.sh: There was a problem running the initialization hooks\"\nwhen I tried 'sudo pip install virtualenv virtualenvwrapper' and 'sudo pip3 install virtualenv virtualenvwrapper' I received \"Requirements already satisfied\".\nI also tried \"brew unlink python && brew link python\" to link them with python3.6 but still it didn't work. Please I will appreciate your help and positiive suggestions.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1628,"Q_Id":61932022,"Users Score":1,"Answer":"I found that I was able to navigate through this using\nsudo pip3 install virtualenv virtualenvwrapper\nThen I created another virtual environment using \nsudo virtualenv-p python3 \nsource >target folder>\/bin\/activate\nThis worked for me","Q_Score":3,"Tags":"python","A_Id":61987524,"CreationDate":"2020-05-21T10:06:00.000","Title":"Error while finding module specification for 'virtualenvwrapper.hook_loader' when I downgrade python3.7 to python3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm working on the little project and the problem I ran to is... I can take a screenshot with custom size but I cannot save it to disk. What should I do?\nimport pyautogui as ImageGrab\nim = ImageGrab.screenshot(region=(0,0,300,400)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":61935323,"Users Score":0,"Answer":"Okay the solution is:\nim.save('test.png')","Q_Score":0,"Tags":"python","A_Id":61935324,"CreationDate":"2020-05-20T19:07:00.000","Title":"How do I save a custom size screenshot on python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i'm using odoo 10, python version 2.7 and pycharm 2019.3.2\ni set script path to odoo-bin, python interpreter to python.exe (2.7), environnement variables to PYTHONUNBUFFERED=1, everything works fine.\nNOW, i wanna work with odoo 13 in the same time, i've python version 3.7 and pycharm 2019.3.2\ni set script path to odoo-bin (odoo 13), python interpreter to python3.exe, environnment variables to PYTHONUNBUFFERED=1,  here when i'm getting this error in the log when i run odoo:\nProcess finished with exit code -1073740940 (0xC0000374) \ni don't know why i'm having this? can anyone help me plz!","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":5028,"Q_Id":61935980,"Users Score":4,"Answer":"after many research i found the solution: it's not a problem of odoo or pycharm, it's a windows 10 problem!.\nGo to panel control > Region > Administrative, and on Languages for non-unicode programs, change regional configuration, check 'Use UTF-8 to language support worldwide' then restart the computer.","Q_Score":3,"Tags":"python,odoo","A_Id":61937729,"CreationDate":"2020-05-21T13:47:00.000","Title":"Process finished with exit code -1073740940 (0xC0000374)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"How can I refresh my python file in every five minutes in django while running because every hour the data I'm webscraping is changing and I need to change the value of the variable?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":297,"Q_Id":61936282,"Users Score":0,"Answer":"I recommend using database like sqlite3 is better solution than restart django(web service) per hours.\nYou can store some datas in database and django can get them like using variables.","Q_Score":1,"Tags":"python,django","A_Id":61936725,"CreationDate":"2020-05-21T14:01:00.000","Title":"How can I refresh every five minutes my Python File in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How can I refresh my python file in every five minutes in django while running because every hour the data I'm webscraping is changing and I need to change the value of the variable?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":297,"Q_Id":61936282,"Users Score":0,"Answer":"The real problem here is that you're fetching the data at the start of the application and keeping it in memory. I see 2 possible better methods:\n\nmove the data scraping code to your view function. This means you'll re-scrape on every call ensuring you'll always have the freshest data but at the cost of speed (the time it takes to make the request to your target url).\nbetter yet: same as above except you cache the results locally. This could also be kept in memory (although I'd use a file or database if you're running multiple django app instances to ensure they're all using the same data). With the least amount of change to what you have already, an in memory cache could be achieved with simply adding a timestamp variable that gets the current time on each fetch. If last fetch was more than X minutes ago: refetch your data.","Q_Score":1,"Tags":"python,django","A_Id":61936962,"CreationDate":"2020-05-21T14:01:00.000","Title":"How can I refresh every five minutes my Python File in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am fairly new to Django and need some guidance\nI am looking for something in Django that allows me to run background tasks while my website continues to work, and probably I can check for the status of the task.\nSo basically I am working on a recon engine. This engine will run other python scripts and displays the results in a nice and fancy way. The python scripts and other tools have been already developed by other people. My website's job is to run those python & shell scripts and save the result back to the database. These tools will take a considerable amount of time to gather the result.\nSo, what is the best approach for this? I looked for celery and Django Q, looks like it's an overkill for my small task. There's a lot of setup for Celery and Django, though I am open to learning new things, for a simple task to run something in the background, I don't wish to use something that is really complex. \nCan you all please suggest what could be a better approach for doing something in background, and once the task is done, probably notify back to the Django and gather the result, or when task is running, I have an option to check the task's status, finished, killed or still running.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":235,"Q_Id":61937055,"Users Score":1,"Answer":"Celery is, afaik, the most common method to achieve this in the django ecosystem. A simpler and more hacky method would be to use the multiprocessing module to spawn off background tasks. This can work fine if the workload is confined to a single machine. As soon as you need a second machine you'll be back to looking at task\/job queues and distributed flows :)","Q_Score":0,"Tags":"python,django,asynchronous,django-rest-framework","A_Id":61937769,"CreationDate":"2020-05-21T14:41:00.000","Title":"Better approach for running background python script in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am doing web scraping with python in some pages and I have been blocked from some of them. When I have tried to check it also through the TOR Browser I have seen that I cannot access to the pages neither, so I think that these pages have been able to track all my IP or I dont have well configurated TOR (and I think not cause I have checked my IP address with Chrome and TOR and are different), so, any one knows why? \nAlso, I am trying to do a function or method in my python code to change mi IP automatically. What I have seen is that the best is to do it through the TOR browser (using it as the search engine to get data from pages) but I am not able to make it work. Do you have any recommendation to create this function?\nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1529,"Q_Id":61938512,"Users Score":3,"Answer":"I would expect anti scrape protection to also block visits from known Tor exit nodes. I dont think they know it is you. Some websites hire\/implement state of the art scrape protection services.\nYou could setup your own proxies at friends and family and use a very conservative crawl rate or maybe search for commercial residential proxy offerings.","Q_Score":2,"Tags":"python,web-scraping,ip,tor","A_Id":61940997,"CreationDate":"2020-05-21T15:53:00.000","Title":"How to hide my IP doing web scraping in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a sqlite3 db and in that, I have a static method that shows all the tables present in the sqlite3 file, but for that file to access the cursor object it needs the self.conn.cur, and if make the cur a global var all the other methods have to be changed so can I use the self arg in the static method?\nPls Help.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":22,"Q_Id":61939292,"Users Score":1,"Answer":"No, a static method will not get any reference to self - self is the object the method is being invoked on, and in a static method, there is no object. If the method isn't static - i.e. it requires an object with a connection set, don't define it as static and call it on an object instead.\nAnother option is to call the static method and provide the connection as an argument. That allows the calling code to determine which connection should be used to retrieve information when called.","Q_Score":0,"Tags":"python,python-3.x,class","A_Id":61940165,"CreationDate":"2020-05-21T16:32:00.000","Title":"Can you use the self argument in a static method in python class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to set up a ssh connection using python. I am using the pexpect module to which I need to pass user credentials.\nI keep my code in a Git repo. How can I handle the password?\nShould I - \n\nEncode it with baseurl64 or\nKeep it in the Jenkins password manager?\n\nWhat are the best standards you follow?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":61944947,"Users Score":3,"Answer":"You should not store secrets unencrypted in a Git repository.  Anyone who obtains a copy of that repository can get access to those secrets.  Even if the repository is private, sometimes unauthorized users get access to repositories, and you definitely want to limit the possible damage.\nBase64-encoding secrets does not hide them, so you should not use that option.  The best way to set up an SSH connection would be to generate a key without a passphrase and store it in your CI secret store, and then in your CI job saving it to a temporary file and using it with ssh -i.\nIf that's not possible, you can use a password with your pyexpect option and store that in your CI secret store.","Q_Score":1,"Tags":"python,python-3.x,git,python-2.7,github","A_Id":61945057,"CreationDate":"2020-05-21T22:38:00.000","Title":"How to handle application password in Git 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Before getting to the main question, I should first ask: When you're trying to check if a list is empty in Python, is there any case where the four cases below would yield a different boolean?\n\nif not []\nif not len([])\nif len([]) == 0\nif len([]) is 0\n\nIf not, which is the fastest way to check for this boolean and why? - i.e. what exactly is happening under the hood for each case? The difference may be trivial but I'm curious as to how these might differ during execution.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":324,"Q_Id":61945068,"Users Score":2,"Answer":"if not array\nThis is the most idiomatic way to check it. Caveat: it will not work on other iterables, e.g. numpy arrays.\nif not len(array)\nEquivalent to the expression above, but is not as idiomatic. It will work on numpy arrays, but still might fail on other iterables with custom __len__ (nonexistent threat, to be clear)\nif len(array) == 0\nSame as above, but eliminates the nonexistent threat from custom iterables\nif len(array) is 0\nDANGER ZONE: it will work in CPython because of implementation details, but generally there is no guarantee it won't break in the future, or that it'll work on other Python implementations. Avoid at all costs.","Q_Score":3,"Tags":"python,arrays,performance,boolean,cpython","A_Id":61945174,"CreationDate":"2020-05-21T22:49:00.000","Title":"Which of these is the fastest way to check if a list is empty in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to import and read SAS program files (.SAS) in python notebook.\nHow can I do that? I am trying with read_sas but it's not working.\nWhat is easiest way to do that?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":359,"Q_Id":61947083,"Users Score":3,"Answer":"A SAS program is merely a text file. Just open it up in any text editor. The sas7bdat data file is binary and contains the data (and metadata).","Q_Score":0,"Tags":"python,sas","A_Id":61947303,"CreationDate":"2020-05-22T02:54:00.000","Title":"How to read sas program files (.sas)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to import and read SAS program files (.SAS) in python notebook.\nHow can I do that? I am trying with read_sas but it's not working.\nWhat is easiest way to do that?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":359,"Q_Id":61947083,"Users Score":2,"Answer":"proc import datafile=\"filepath\" dbms=\"here type of file like csv or xlm etc...\"out=\"\"\nreplace;\ndelimiter='her delimiter like \",\" or \".\"or \":\"  ' ;\nrun;\n*you can open eny type  of file","Q_Score":0,"Tags":"python,sas","A_Id":63031538,"CreationDate":"2020-05-22T02:54:00.000","Title":"How to read sas program files (.sas)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement a stacked ensemble model for multiclass prediction. \nEach training example is a vector with 14 features.\nThere are a total of 12 possible classes.\nThe three base models (described below) each ingest a 14-dimensional feature vector training example and output a 12-dimensional vector of probabilities (1 probability \/ class).\nThe three base classification models were built from scratch (i.e. not built using sklearn so I can't simply use the sklearn ensemble methods) and are as follows:\n\nBayes Net: outputs a 12-dimensional vector of probabilities (1 probability \/ class) for each 14-dimensional training example\nOther graphical model: outputs a 12-dimensional vector of probabilities (1 probability \/ class) for each 14-dimensional training example\nMetric learning model: outputs a 12-dimensional vector of probabilities (1 probability \/ class) for each 14-dimensional training example\n\nI would like to stack the outputs from the base models for each training example (i.e. stack 3 x 12-d probability vectors) for each training example and feed this 3x12 array as an input to the multinomial logistic regression ensemble model to output a 12-dimensional vector of probabilities for the final multi-class predictions for each training example.\nI'm not sure, however, if this is possible using the sklearn multinomial regression model.  From my understanding, the sklearn model can only ingest a 1-d array of features rather than a 2-d array of features.\nAny advice would be welcome. Thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":61947232,"Users Score":0,"Answer":"So the ultimate workaround ended up being very simple: flattening the 3x12 vector outputs for each base model into a 1x36 feature vector that was then fed into the ensemble model. \nThe other option was to build a tensor out of the base model predictions and then use a different type of ensemble classifier i.e. a CNN, but that approach was rejected.","Q_Score":0,"Tags":"python,scikit-learn,logistic-regression,ensemble-learning","A_Id":62142782,"CreationDate":"2020-05-22T03:11:00.000","Title":"Multinomial logistic regression for stacked ensemble learning with 2d input into regression","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently installed Anaconda spyder 2020 version, resulting in Python 3.7.6 being installed.\nI previously had ffn installed and working.\nNow when I run code that tries to import ffn, it comes up with Module not found - No module named 'ffn'.\nHowever, when I issue pip freeze at the console, I can see ffn == 0.3.3 \nCan anybody shed any light on why I have having problems importing ffn?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":422,"Q_Id":61947416,"Users Score":0,"Answer":"If you install anaconda it will automatically install its own version of python with a specific directory for site-packages so either you need to find and use your old python binary or install ffn again this time with the newly installed anaconda since just syncing the two site-packages directories won't work because minor releases of python (e.g 3.7 and 3.5 ) aren't necessarily compatible.","Q_Score":0,"Tags":"python-3.x","A_Id":61947621,"CreationDate":"2020-05-22T03:32:00.000","Title":"Cannot import ffn after installing anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have upgraded my spyder to 4.0.1 , but now i get this error with matplotlib. The error:\nAttributeError: module 'sip' has no attribute 'setapi'\ncomplete error:\nNOTE: The following error appeared when setting your Matplotlib backend!!\nTraceback (most recent call last):\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\site-packages\\spyder_kernels\\console\\kernel.py\", line 568, in _set_mpl_backend\n    get_ipython().run_line_magic(magic, backend)\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\site-packages\\IPython\\core\\interactiveshell.py\", line 2317, in run_line_magic\n    result = fn(*args, **kwargs)\n  File \"\", line 2, in matplotlib\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\site-packages\\IPython\\core\\magic.py\", line 187, in \n    call = lambda f, *a, **k: f(*a, **k)\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\site-packages\\IPython\\core\\magics\\pylab.py\", line 99, in matplotlib\n    gui, backend = self.shell.enable_matplotlib(args.gui.lower() if isinstance(args.gui, str) else args.gui)\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\site-packages\\IPython\\core\\interactiveshell.py\", line 3419, in enable_matplotlib\n    pt.activate_matplotlib(backend)\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\site-packages\\IPython\\core\\pylabtools.py\", line 320, in activate_matplotlib\n    from matplotlib import pyplot as plt\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\site-packages\\matplotlib\\pyplot.py\", line 2282, in \n    switch_backend(rcParams[\"backend\"])\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\site-packages\\matplotlib\\pyplot.py\", line 221, in switch_backend\n    backend_mod = importlib.import_module(backend_name)\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\importlib__init__.py\", line 127, in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\site-packages\\matplotlib\\backends\\backend_qt5agg.py\", line 11, in \n    from .backend_qt5 import (\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\site-packages\\matplotlib\\backends\\backend_qt5.py\", line 15, in \n    import matplotlib.backends.qt_editor.figureoptions as figureoptions\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\site-packages\\matplotlib\\backends\\qt_editor\\figureoptions.py\", line 12, in \n    from matplotlib.backends.qt_compat import QtGui\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\site-packages\\matplotlib\\backends\\qt_compat.py\", line 163, in \n    _setup()\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\site-packages\\matplotlib\\backends\\qt_compat.py\", line 124, in _setup_pyqt4\n    _setup_pyqt4_internal(api=2)\n  File \"C:\\Users\\premp\\anaconda3\\envs\\tfcuda\\lib\\site-packages\\matplotlib\\backends\\qt_compat.py\", line 107, in _setup_pyqt4_internal\n    sip.setapi(_sip_api, api)\nAttributeError: module 'sip' has no attribute 'setapi'\nCurrently i have matplotlib 3.2.1 , i have tried downgrading and also tried changing the setting from automatic to inline. But not able to figure out the issue. Is this a bug?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":681,"Q_Id":61948243,"Users Score":1,"Answer":"I had a similar problem and fixed it by adding the sip module to my anaconda environment.","Q_Score":0,"Tags":"python-3.x,anaconda,spyder","A_Id":63556541,"CreationDate":"2020-05-22T05:09:00.000","Title":"Mtaplotlib issue with spyder 4.0.1","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to measure the coverage of my Python code which gets executed in the production system.\nI want an answer to this question:\n\nWhich lines get executed often (hot spots) and which lines are never used (dead code)?\n\nOf course this must not slow down my production site.\nI am not talking about measuring the coverage of tests.","AnswerCount":3,"Available Count":1,"Score":-0.1325487884,"is_accepted":false,"ViewCount":365,"Q_Id":61951275,"Users Score":-2,"Answer":"Maybe make a text file and through your every program method just append some text referenced to it like \"Method one executed\". Run the web application like 10 times thoroughly  as a viewer would and after this make a python program that reads the file and counts a specific parts of it or maybe even a pattern and adds it to a variable and outputs the variables.","Q_Score":5,"Tags":"python,code-coverage,performance-testing","A_Id":61951412,"CreationDate":"2020-05-22T08:56:00.000","Title":"How can I measure the coverage (in production 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":0,"Web Development":0},{"Question":"I am using a Mac and it is using Anaconda Python by default. How do I change my default Python enviroment to the standard version? And is there any difference between Anaconda Python and regular Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":61951762,"Users Score":0,"Answer":"Your \"regular python\" is a system-wide package visible via the $PATH environment variable and has nothing to do with anaconda. A \"conda python\" is a python interpreter specific to a conda environment.\nCalling python by default will trigger the system-wide package. First activating a conda environment and then calling python triggers the interpreter in that environment","Q_Score":0,"Tags":"python,terminal,anaconda","A_Id":61953418,"CreationDate":"2020-05-22T09:23:00.000","Title":"How to change default python enviroment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im creating a email system and discovered that I need to turn on access from less secure apps.\nIve heard that this can be dangerous to turn on and was wondering if there was a way to connect without turning it on?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":61953926,"Users Score":0,"Answer":"Nope, no way to use smtp without enabling less secure apps. Gmail sends you an alert every time there is a new login, including on less secure apps, so as long as you monitor that there's really no need to worry.","Q_Score":0,"Tags":"python,python-3.x,email,smtp,smtplib","A_Id":62186583,"CreationDate":"2020-05-22T11:25:00.000","Title":"Workaround for \"access from less secure 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to print a very small p-value to a plot (p-value = 4.3289045262877305e-11). I need to round it to have fewer digits after the decimal so it will fit (4.33e-11) but when I'm using round(,3) it returns 0.0. How can I return the number like this 4.33e-11?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":72,"Q_Id":61956532,"Users Score":-1,"Answer":"When using round(,3) you are rounding up the actual value to 0,00, not the displayed value.\nIf you actually need to round the value itself and not the displayed one, I would suggest you to multiply it by e11, then round (,3), then devide it by e11 to get the rounded number.","Q_Score":0,"Tags":"python,statistics,pearson-correlation,significant-digits","A_Id":61956601,"CreationDate":"2020-05-22T13:49:00.000","Title":"Rounding small fraction like 2.234556440301284e-100 to 2.23e-100 in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"TypeError: can\u2019t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.\nlearned_pred = euclidean_distances(answer.cpu().data.numpy(), predicates_emb).argmin(axis=1)\nThe type error is raised in the above line of code I used .cpu() so I cannot understand why..\nHow can I solve this problem?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":891,"Q_Id":61960705,"Users Score":0,"Answer":"The conversion from variable answer is true. Therefore, I think the problem may stay in the variable predicates_emb.\nCan you check if var predicates_emb is tensor or not. If it is, you should convert it to numpy array.","Q_Score":0,"Tags":"python","A_Id":63796282,"CreationDate":"2020-05-22T17:33:00.000","Title":"TypeError: can\u2019t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"TypeError: can\u2019t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.\nlearned_pred = euclidean_distances(answer.cpu().data.numpy(), predicates_emb).argmin(axis=1)\nThe type error is raised in the above line of code I used .cpu() so I cannot understand why..\nHow can I solve this problem?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":891,"Q_Id":61960705,"Users Score":0,"Answer":"I had the same issue, a answer.cpu() did not work for me but answer.to('cpu')... did work for me.","Q_Score":0,"Tags":"python","A_Id":67373990,"CreationDate":"2020-05-22T17:33:00.000","Title":"TypeError: can\u2019t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install pygame in my python 3.6.10 Conda venv. When I ran: conda install -c cogsci pygame\nit gave me an unsatisfiable error saying: - pip -> python[version='>=3.7,<3.8.0a0'] (I am on windows 10 btw). Does this mean that my version of pip requires python 3.7? How do I fix this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":33,"Q_Id":61960815,"Users Score":1,"Answer":"This seems like you need to upgrade your python to version 3.7.\nUpgrade your python to 3.7.x but not to 3.8 as it says >=3.7 , <3.8","Q_Score":0,"Tags":"python,pip,anaconda,conda","A_Id":61960858,"CreationDate":"2020-05-22T17:40:00.000","Title":"How do I resolve this error when installing packages in a Conda venv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"MemoryError: Unable to allocate 1.68 TiB for an array with shape (120000, 20, 95932) and data type float64\nand this is the line that is causing the problem : \nouts = np.zeros((context_1.shape[0], maxLen, vocab_size))\nis there a workaround for this error?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":258,"Q_Id":61962199,"Users Score":1,"Answer":"You are trying to create very large array. That's way too much data to store in memory. You should redesign your algorithm, may be use generators to reduce memory requirements.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":61963391,"CreationDate":"2020-05-22T19:07:00.000","Title":"Memory Error while trying to calculate np.zeros","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was looking through the architecture of EfficientnetB0 and noticed DepthwiseConv2D operation. Did some digging and found that there's also a SeparableConv2D. What exactly are these operations?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1644,"Q_Id":61967172,"Users Score":0,"Answer":"DepthwiseConv2d performs the first step in a depthwise spatial convolution, apply convolution operation on each input channel separately.","Q_Score":3,"Tags":"python,tensorflow,keras,conv-neural-network","A_Id":66944281,"CreationDate":"2020-05-23T03:46:00.000","Title":"What is DepthwiseConv2D and SeparableConv2D? How is it different from normal Conv2D layer in keras?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running some simulations in Python on my laptop, for my master degree project, and recently discovered that my desktop computer has almost the same performance of my laptop, when performing the same exact code. The problem is that my laptop has an i7 processor, while the desktop computer an i3. More specifically:\nLaptop:  i7-5500U @2.40 GHz (64bit, dual core)\nDesktop: i3-4150  @3.50 GHz (32bit, one core)\nI am not an expert on computer science, neither I study it, and this is quite surprising to me. I know that the number of cores should not affect the performance, since python only uses one, but does it really all rely on clock frequency? And if yes, what are the advantages of having an i7 with such clock frequency? Is there some other data I am missing? What data one has to take under consideration to forecast computer's performance?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":175,"Q_Id":61969577,"Users Score":0,"Answer":"There are really too many factors in determining why your performance is like that. Consider:\n\nIs your program memory-bound or calculation-bound?\nDoes your code really use multiple cores?\nIs your program slowed down by disk access?\nAre you using different language versions or performance settings?\n\nThere are really many factors like these; some of them are difficult to answer and impossible to guess.\nYou could try profiling this if important enough.","Q_Score":0,"Tags":"python,performance,processor","A_Id":61970421,"CreationDate":"2020-05-23T08:51:00.000","Title":"Comparing python performance from hardware specifics","Data 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 Python3 newbie, I made use of venv to create a project, and the created project directory structure is like this:\n\nbin\ninclude\nlib\nlib64 (link to lib)\npenv.cfg\nshare\n\nThe next step is to store this project into a version control system like git. As a Java programmer working on maven project, storing pom.xml to version control is enough. So I feel a bit unworthy to store all these subdirectories to the version control\nQuestion: Should I store all these files into the Version Control? If not, which of them to store in version control?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":61971594,"Users Score":1,"Answer":"To store them in .git is unnecessary, if someone wants to have the same environment as you for example, you just want to make sure that they get the same requirements.txt file (packages that were installed by Python packet manager pip) \nThe bottom line is that to throw virtual environment in the gitignore and just have requirements file which is generated by pip freeze >> requirements.txt (you can name whatever you want but it is a convention to name it requirements","Q_Score":0,"Tags":"python,python-3.x,version-control,python-venv","A_Id":61971673,"CreationDate":"2020-05-23T11:53:00.000","Title":"How to maintain a Python project made with venv in version control","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I apologize if this is a naive question as I'm a learning developer. I'm trying to come up a project to work on in the summer to build my portfolio as a Python developer and as of right now I'm in the planning stages and just want to know if I'm on the right track.\nBut without going into the specifics, I essentially want to get the meta data from one YouTube video every hour from the time it was uploaded and the current time and make a time vs views\/hour plot using the YouTube API and display it on a website\nI've looked into webscrapers, but from my understanding, those scripts can only take one instance at a time.\nWould I need to learn PHP as well in order to store the data from each instance the API is called? Or is there a way to do what I'm thinking of natively in Python?\nIf so would I need to know it extensively?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":126,"Q_Id":61973637,"Users Score":0,"Answer":"Part 1 - YouTube API only returns a total viewCount. You won't be able to ask for a video's viewCount from 6 hours ago, for example. However, you can call the API every hour for the video viewCount and store the numbers yourself going forward.\nPart 2 - PHP vs Python doesn't matter. You can store data with either code.","Q_Score":0,"Tags":"python,php,youtube,youtube-api,youtube-data-api","A_Id":61988971,"CreationDate":"2020-05-23T14:35:00.000","Title":"Trying to use YouTube API to check views of a video every hour. Can Python be used to store the data or is PHP needed?","Data 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 beginner in Python. I have installed the latest version of python -3.8.3 in my system. Now to have the editor to start working on python, i tried to install pycharm community edition-free-open source from the official site.While running it, I get the message as 'The installation has JetBrains Runtime 11 which does not support Microsoft Windows version 7 32-bit.\n Is there any other solution or alternative or IDE for python of windows 7 32-bit to work on?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":627,"Q_Id":61974576,"Users Score":0,"Answer":"There is no way, other than using an older version of PyCharm.","Q_Score":0,"Tags":"python,windows,pycharm","A_Id":61975626,"CreationDate":"2020-05-23T15:44:00.000","Title":"any solution to make pycharm work in windows 7 32-bit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I recently finished my python project, grabbing values from an API and put it into my website.\nNow I have no clue how I actually start the website (finding a host) and making it accessible to other people, I thought turning to here might find the solution.\nI have done a good amount of research, tried \"pythonanywhere\" and \"google app engine\" but seem to not really find a solution. \nI was hoping to be able to use \"hostinger\" as a host, as they have a good price and a good host. Contacted them but they said that they couldn't, though I could upload it to a VPS (which they have). Would it work for me to upload my files to this VPS and therefor get it to a website? or should I use another host?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":61975190,"Users Score":0,"Answer":"A VPS would work, but you'll need to understand basic linux server admin to get things setup properly.\nSounds like you don't have any experience with server admin, so something like App Engine would be great for you. There are a ton of tutorials on the internet for deploying flask to GAE.","Q_Score":0,"Tags":"python,web,flask,hosting","A_Id":62033529,"CreationDate":"2020-05-23T16:28:00.000","Title":"Deploy python flask project into a website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I work in Python. I have a problem with the categorical variable - \"city\". \nI'm building a predictive model on a large dataset-over 1 million rows. \nI have over 100 features. One of them is \"city\", consisting of 33 000 different cities.\nI use e.g. XGBoost where I need to convert categorical variables into numeric. Dummifying causes the number of features to increase strongly. XGBoost (and my 20 gb RAM) can't handle this.\nIs there any other way to deal with this variable than e.g. One Hot Encoding, dummies etc.?\n(When using One Hot Encoding e.g., I have performance problems, there are too many features in my model and I'm running out of memory.)\nIs there any way to deal with this?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1451,"Q_Id":61975690,"Users Score":0,"Answer":"You could use some kind of embeddings that reflect better those cities (and compress the number of total features by direct OHE), maybe using some features to describe the continet where each city belongs, then some other features to describe the country\/region, etc.\nNote that since you didn't provide any specific detail about this task, I've used only geographical data on my example, but you could use some other variables related to each city, like the mean temprature, the population, the area, etc, depending on the task you are trying to address here.\nAnother approach could be replacing the city name with its coordinates (latitude and longitude). Again, this may be helpful depending on the task for your model.\nHope this helps","Q_Score":1,"Tags":"python,xgboost,forecasting","A_Id":61978233,"CreationDate":"2020-05-23T17:06:00.000","Title":"How to deal with the categorical variable of more than 33 000 cities?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I work in Python. I have a problem with the categorical variable - \"city\". \nI'm building a predictive model on a large dataset-over 1 million rows. \nI have over 100 features. One of them is \"city\", consisting of 33 000 different cities.\nI use e.g. XGBoost where I need to convert categorical variables into numeric. Dummifying causes the number of features to increase strongly. XGBoost (and my 20 gb RAM) can't handle this.\nIs there any other way to deal with this variable than e.g. One Hot Encoding, dummies etc.?\n(When using One Hot Encoding e.g., I have performance problems, there are too many features in my model and I'm running out of memory.)\nIs there any way to deal with this?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1451,"Q_Id":61975690,"Users Score":0,"Answer":"Beside the models, you could also decrease the number of the features (cities) by grouping them in geographical regions. Another option is grouping them by population size.\nAnother option is grouping them by their frequency by using quantile bins. Target encoding might be another option for you.\nFeature engineering in many cases involves a lot of manual work, unfortunately you cannot always have everything sorted out automatically.","Q_Score":1,"Tags":"python,xgboost,forecasting","A_Id":69550804,"CreationDate":"2020-05-23T17:06:00.000","Title":"How to deal with the categorical variable of more than 33 000 cities?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new using pipenv and I would like to know why every time I create a virtual environment, the environment saves me with my username and not with the name of my project folder.\nSteps:\n\ncd project-01\/\nproject-01> pipenv --three\nls .local\/share\/virtualenvs\/\nresult: username-nQve7NT7\n\nand it always sets me \/home\/username\/ as the path of my project. I'm using Xubuntu 18.04.4 with Python 3.6.9 and pipenv 2018.11.26\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":61975870,"Users Score":0,"Answer":"I had this same problem and found that my issue was that there was a Pipfile and Pipfile.lock in my user directory.\nI must have mistakenly run pipenv shell there at some point, and while I may have removed the environment folder, the Pipfiles remained.\nI imagine pipenv must look up the file tree for a Pipfile and, if it finds one, assumes that is the project root. Removing the Pipfiles fixed the problem for me.","Q_Score":0,"Tags":"python,pipenv","A_Id":70562080,"CreationDate":"2020-05-23T17:20:00.000","Title":"problems creating virtual environments with pipenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to create a bitmap in python but I know:\n\nbitmap pixel values\nwidth\nheight\ncolor planes\nbits per pixel\n\nI've already tried using PIL.Image but it doesn't let you choose an arbitrary bpp value (for instance I need 4 bpp which is not present in the supported modes).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":306,"Q_Id":61976083,"Users Score":0,"Answer":"If this is for fitting a maximum of information into available memory and you do not need display, load or save in a 4 bpp format that other applications can handle you could just use 8 bpp with half the width and wrap the two functions getpixel() and putpixel() to access or modify the respective halves of the 8 bits at (x\/\/2, y), i.e. value >> 4 and value & 15, depending on whether x & 1 == 0. The function paste() can also easily be wrapped for x & 1 == 0 and even width. For other x or odd width, paste() takes a bit of effort to shift the bits into the right positions. Similarly, 2 bpp can use x\/\/4.\nFor bit depths that are not a power of 2, one will want to go with the greatest depth available, e.g. an 8 bpp pixel could only store 2 pixels with 3 bpp but 64 bpp could store 21 such pixels, improving efficiency by 31%.","Q_Score":1,"Tags":"python,bitmap","A_Id":70853054,"CreationDate":"2020-05-23T17:38:00.000","Title":"Create a Bitmap in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a simple questions that is really only a footnote in something I am writing:\nIs any valid JSON not also valid Python?\nI know the converse is true, i.e. Python data structures and scalars allow a variety of constructs that are not JSON.  But for the most part, JSON seems to be a subset of Python syntax for defining (some) data structures.\nThe obvious stuff is covered.  Strings are strings. Ints are ints. JSON \"numbers\" are read as Python floats (although RFC 8259 does not mandate that interpretation vs. fixed point, for example).  Dicts are dicts. Lists are lists.\nBut maybe something in some obscure corner violates the subset relationship.  For example, is there anything in the encoding of Unicode outside the BMP that is directly incompatible? Or maybe within Unicode surrogate pairs?\nOr maybe something with numbers where some large number of digits after the decimal would be technically valid JSON but not Python? (I don't think so, but just trying to think of scenarios).","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":866,"Q_Id":61977437,"Users Score":-1,"Answer":"Yes, you are correct, every valid JSON can be handled in Python. Python is a complete language, and JSON is a way of storing data (serialisation maybe?). Generally a language will support everything a JSON object can represent.\nThere would be different representation for sure like true in JSON is True in Python.\nSince, JSON is way of storing data, and we can also pass it around HTTP requests, which are always processed by some server side language, which is expected to handle the JSON object.","Q_Score":4,"Tags":"python,json","A_Id":61977518,"CreationDate":"2020-05-23T19:18:00.000","Title":"Can valid JSON be invalid Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I was trying to solve some code and I am stuck in this, I don't have any idea why print(int('100',2)) outputs 4, please explain it to me.","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":778,"Q_Id":61979090,"Users Score":3,"Answer":"When you call int(), you are giving it two parameters: '100', and 2. The first parameter it takes is the number as a string, and the second is the base. So, you are telling it to convert the string '100' into an integer of base 2. 100 in base 2 is four, so you are getting this output. Hope this helps!","Q_Score":1,"Tags":"python","A_Id":61979111,"CreationDate":"2020-05-23T21:58:00.000","Title":"Why does \"print (int('100',2))\" give output of 4 in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I was trying to solve some code and I am stuck in this, I don't have any idea why print(int('100',2)) outputs 4, please explain it to me.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":778,"Q_Id":61979090,"Users Score":2,"Answer":"100 in binary system is 1*2^2 *0*2^1 + 0 = 4","Q_Score":1,"Tags":"python","A_Id":61979106,"CreationDate":"2020-05-23T21:58:00.000","Title":"Why does \"print (int('100',2))\" give output of 4 in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've searched a while and haven't found an answer to this particular issue. \nbrew info python returns python: stable 3.7.7 (bottled), HEAD\nHowever, python -V and python3 -V return Python 3.6.1 :: Anaconda 4.4.0 (x86_64)\nWhy is my Mac python version different than what I've installed with HB, and how can I fix it? Thank you!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":61980277,"Users Score":0,"Answer":"Erg.  Yes\u2014this is a challenge sometimes.  macOS ships with python as part of its system.  Catalina 10.15.4 ships with \/usr\/bin\/python3 of 3.7.3.  brew (at the moment) has installed 3.7.7 as its stable branch, but it also offers a python@3.8 which installs 3.8.2. That's significant because there are other brew packages (notably vim) which specity python@3.8 as a dependency.  Yuck.\nI'm not running anaconda at the moment, but I'll take your word that it's yet-another version.\nWhichever appears first in your path is going to prevail unless you're operating inside a context like a virtual environment. You can arrange your path to set your preferred python3 to run.  You can always check which python3 is running by using \"which python3\" and that will give you the full path of the running program.\nWord of caution: Each distinct python3 will maintain its own packages library. Once you have your paths sorted out, you should manage your packages with \"python3 -m pip \" to be sure you're managing the libraries for your intended version.\nAnd yes\u2014eventually, it'd probably be good for us to work in virtual environments or skip straight to Docker containers.","Q_Score":1,"Tags":"python,python-3.x,macos","A_Id":61981016,"CreationDate":"2020-05-24T00:37:00.000","Title":"Homebrew python version different than Mac python version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've searched a while and haven't found an answer to this particular issue. \nbrew info python returns python: stable 3.7.7 (bottled), HEAD\nHowever, python -V and python3 -V return Python 3.6.1 :: Anaconda 4.4.0 (x86_64)\nWhy is my Mac python version different than what I've installed with HB, and how can I fix it? Thank you!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":85,"Q_Id":61980277,"Users Score":0,"Answer":"One version of python was installed using the Anaconda distribution. The other by Homebrew. It's not surprising that they are different versions. You should run in virtual environments and then you won't need to worry about 2 versions.  Using the Anaconda distribution it is easy to set up a virtual environment to run that version.","Q_Score":1,"Tags":"python,python-3.x,macos","A_Id":61980639,"CreationDate":"2020-05-24T00:37:00.000","Title":"Homebrew python version different than Mac python version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"So, I'm building a model and trying to use | for a new column and I'm confused as to what I'm doing wrong. It's supposed to make a new column and type 1 when the value is true.\n\nFor example, this worked : \nfeature_matrix[\"After 2016\"] = (feature_matrix.index.year > 2016).astype(int)\nHowever this does nothing :\nfeature_matrix[\"Summer\"] = (feature_matrix.index.month == 6|7|8|9).astype(int)\nSame thing goes for this when I try to do the weekend using the same method.\n\nI tried solving it using : \nfeature_matrix[\"Summer\"] = (feature_matrix.index.month == 6| feature_matrix.index.month == 7).astype(int)\nBut that gives me : unsupported operand type(s) for |: 'int' and 'Int64Index'","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":61980838,"Users Score":0,"Answer":"Yoben's answer is correct and complete, but a note: 6|7|8\\9 is always true, and unless you have True in your column, this will do nothing.","Q_Score":0,"Tags":"python,pandas,dataframe,datetime","A_Id":61980866,"CreationDate":"2020-05-24T02:15:00.000","Title":"How to use or in pandas and datetime","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My table is sqlite3 is created with the following:-\n'CREATE TABLE IF NOT EXISTS gig_program ( gig_program_id VARCHAR(20) PRIMARY KEY );'\nWhen I try to insert data into the table using python 3.8 with the following:-\nsql = 'INSERT INTO gig_program ( gig_program_id ) VALUES ( \"20200524120727\" );'\ncur.execute(sql)\nthe following exception was thrown:-\nnear \"gig_program\": syntax error\nWhen I cut and past the insert command to the sqlite3 console, it works.\nI have also tried using another editor for the program (thinking that there may be hidden characters) but the result is the same.\nI would appreciate help.  I have used similar methods in other parts of the program to insert data and they work without issue.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":61982167,"Users Score":0,"Answer":"Thank you for looking into my questions.\nI found that it was actually my mistake.  The exception was actually for a second sql statement which I missed out the \"FROM\" word.\nThank you everyone for your time.\nHope everyone is doing well.","Q_Score":0,"Tags":"python-3.x,sqlite,syntax","A_Id":61983985,"CreationDate":"2020-05-24T05:56:00.000","Title":"Why does sqlite throws a syntax error in the python program?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a admin form where users can upload files. I want this to be stored in a secure place where the public can't get it. I'm using a standard form with a FileField and no model. Is there a way I can store the files in a folder within the app folder?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":136,"Q_Id":61983925,"Users Score":1,"Answer":"Yes you can do that by specifying the path in your settings.py file eg.  MEDIA_ROOT = os.path.join(BASE_DIR, 'media')\nMEDIA_URL = '\/media\/'","Q_Score":0,"Tags":"python,django,admin","A_Id":61984086,"CreationDate":"2020-05-24T09:19:00.000","Title":"Upload file django admin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Hey I am training a CNN model , and was wondering what will happen if I use the same data for validation and test?\nDoes the model train on validation data as well? (Does my model see the validation data?) Or just the error and accuracy are calculatd and taken into account for training?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":772,"Q_Id":61985581,"Users Score":1,"Answer":"You use your validation_set to tune your model. It means that you don`t train on this data but the model takes it into account. For example, you use it to tune the model's hyperparameters. \nIn order to have a good evaluation - as test set you should use a data which is totally unknown to this model.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,conv-neural-network","A_Id":61985649,"CreationDate":"2020-05-24T11:55:00.000","Title":"Use same data for test and validation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hey I am training a CNN model , and was wondering what will happen if I use the same data for validation and test?\nDoes the model train on validation data as well? (Does my model see the validation data?) Or just the error and accuracy are calculatd and taken into account for training?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":772,"Q_Id":61985581,"Users Score":0,"Answer":"If you use the same set for validation and test, your model may overfit (since it has seen the test data before the final test stage).","Q_Score":0,"Tags":"python,tensorflow,deep-learning,conv-neural-network","A_Id":61985665,"CreationDate":"2020-05-24T11:55:00.000","Title":"Use same data for test and validation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with the librosa library, and\nI would like to know what information is returned by the librosa.load function when I read a audio (.wav) file.\nIs it the instantaneous sound pressure in pa, or the just the instantaneous amplitude of the sound signal with no units?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":9943,"Q_Id":61986490,"Users Score":3,"Answer":"To add to the above answer, you may also use librosa function\nlibrosa.get_duration(y,sr) to get the duration of the audio file in seconds.\nOr you may use len(y)\/sr to get the audio file duration in seconds","Q_Score":5,"Tags":"python,signal-processing,librosa,audio-analysis","A_Id":63709994,"CreationDate":"2020-05-24T13:12:00.000","Title":"What does librosa.load return?","Data Science and Machine Learning":0,"Database and SQL":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 write a function that returns a global variable (creating the variable inside the function and returning it outside, globally)? I can't assign the variable before the function call because I'm using it on tkinter, therefore, it's on a While loop.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1347,"Q_Id":61986499,"Users Score":0,"Answer":"No, a function can set a global variable but cannot return any local variable\/ value that can impact a global state.\nGenerally, global variables are bad and make it really hard to reason about your program. Try your best to use pure functions with only local state","Q_Score":0,"Tags":"python,function,scope,global-variables","A_Id":61986513,"CreationDate":"2020-05-24T13:13:00.000","Title":"A function that returns a global variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wonder if is there any way in Selenium to verify or check if item was saved to sql database via python language ? Thanks for help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":61987434,"Users Score":0,"Answer":"Not in Selenium itself - you would have to code it, using a Python library to connect to the SQL database you want, and perform the queries required for what you want.","Q_Score":0,"Tags":"python,sql,database,testing,web","A_Id":61988632,"CreationDate":"2020-05-24T14:28:00.000","Title":"Selenium, item sent do database, python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm pretty new to pandas and got an assignment asking me to compare & match two columns of 2 different .csv files. \ndtypes are strings\n1st df\nName     | Subjects \nStudent1 | Biology, Math, German\nStudent2 | Sport, Biology, English\nStudent3 | Chemistry, Math, Biology\n2nd df\nName     | Subjects\nTeacher1 | Biology, Sport, English\nTeacher2 | Chemistry, Math, Physics\nTeacher3 | Biology, Physics, Chemistry, English\n...\nNow, I should compare and find the best match between a Student & Teacher. \nMeaning, they should match at least 1 subject, but for a \"perfect match\" all of them.\nI tried different things already - pd.merge, iterrows, isin, etc. - but can't find a great performant solution.\nI'm not asking for a solution for my assignment, but for a small push in the right direction.\nThank you!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":203,"Q_Id":61988485,"Users Score":0,"Answer":"You can first pivot on subject column using pd.pivot_table and then do a ofpd.merge on subject columns of student and teacher tables to relate teachers and students based on subjects.","Q_Score":1,"Tags":"python,pandas,dataframe","A_Id":61988603,"CreationDate":"2020-05-24T15:53:00.000","Title":"pandas - comparing two columns of different dataframes with multiple strings","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The question says it all. If I have a cronjob that runs a python script, what will the value of __name__ be?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":61989210,"Users Score":2,"Answer":"The same as if you run it directly from your shell. There is no difference between running it from your shell or from the crontab.","Q_Score":0,"Tags":"python,cron,cron-task","A_Id":61989247,"CreationDate":"2020-05-24T16:48:00.000","Title":"What will __name__ be when python script run 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":"I am very new to this and trying to learn Docker\/Containers. I have created a user form using pyqt5 and now trying to containerize that using hyper v docker. Everything goes well until the image creation. However when I am trying to run the container, I came across the below error. Tried many an things but did not work. can some of you advise the best solution for this:\nDockerfile:\nFROM python\nRUN python -m pip install PyQT5\nRUN python -m pip install pyqt5-tools\nCOPY Test.py c:\/python_practice\/DTM\/\nCMD python c:\/python_practice\/DTM\/Test.py\nError code:\nPS C:\\Python_Practice\\DTM> docker run pydocker\nTraceback (most recent call last):\n  File \"c:\/python_practice\/DTM\/Test.py\", line 1, in \n    from PyQt5 import uic, QtWidgets\nImportError: libGL.so.1: cannot open shared object file: No such file or directory\nPlease note sudo apt install libgl1-mesa-glx is not working as this is windows not linux.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1281,"Q_Id":61990391,"Users Score":1,"Answer":"Try the following lines to your docker file:\nRUN apt-get update -y\nRUN apt install libgl1-mesa-glx -y","Q_Score":4,"Tags":"python,hyper-v","A_Id":65077737,"CreationDate":"2020-05-24T18:20:00.000","Title":"ImportError: libGL.so.1: cannot open shared object file: No such file or directory: HyperV Docker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am constantly getting the following error:\nAssertionError: \/Food-101\/images\/train is not a valid directory.\nFood-101 is in the same directory as the notebook.  They're the children of the same parent directory.  This is the absolute directory:\n\/home\/user\/Projects\/food-101\/Food-101, notebook","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":646,"Q_Id":61990895,"Users Score":1,"Answer":"try Food-101\/images\/train. The first slash means the path is not relative, but absolute.","Q_Score":0,"Tags":"python-3.x,jupyter","A_Id":61991066,"CreationDate":"2020-05-24T18:55:00.000","Title":"Not a valid directory error when the directory exists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I extracted some data from investing but columns values are all dtype = object, so i cant work with them...\nhow should i convert object to float?\n(2558    6.678,08 2557    6.897,23 2556    7.095,95 2555    7.151,21 2554    7.093,34 ...    4       4.050,38 3       4.042,63 2       4.181,13 1       4.219,56 0       4.223,33 Name: Alta, Length: 2559, dtype: object)\nWhat i want is :\n2558   6678.08 2557    6897.23 2556    7095.95 2555    7151.21 2554    7093.34 ...    4       4050.38 3       4042.63 2       4181.13 1       4219.56 0       4223.33 Name: Alta, Length: 2559, dtype: float\nTried to use the a function which would replace , for .\ndef clean(x): x = x.replace(\".\", \"\").replace(\",\",\".\")\nbut it doesnt work cause dtype is object\nThanks!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2019,"Q_Id":61991204,"Users Score":0,"Answer":"That is because there is a comma between the value\nBecause a float cannot have a comma, you need to first replace the comma and then convert it into float\nresult[col] = result[col].str.replace(\",\",\"\").astype(float)","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":71562110,"CreationDate":"2020-05-24T19:16:00.000","Title":"How can i change dtype from object to float64 in a column, using python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For example, let's say I have a function_1 and function_2. Would I be able to run function_1, stop mid-way, wait for function_2 to be done, and then run the rest of function_1 ?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":125,"Q_Id":61991352,"Users Score":2,"Answer":"Are both functions run under the same process, on the same thread? (if you don't know what this means, they probably are)\nIf so, there isn't really a good way to do this directly. My advice would be to refactor your code somehow so this isn't necessary, possibly by breaking up functions into smaller functions (so you could run a small function that does the first part of function 1, then run function 2, then run a small function that does the second part of function 1)\nAnother way would be to call function 2 from within function 1, which would transfer control to function 2 until function 2 returns. \nWhich one of these is the better choice will depend on the nature of your problem.\nEDIT: these of course are not the only ways to do this, (the asker could run the functions on seperate threads, and do explicit synchronization) but these are two fairly simple ways to do what they want.","Q_Score":1,"Tags":"python,python-3.x,function","A_Id":61991415,"CreationDate":"2020-05-24T19:29:00.000","Title":"How do I stop one piece of code to run another in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I see the following text when I type python in my Windows 8.1 console (cmd.exe)\n\nPython 2.7.16 (v2.7.16:413a49145e, Mar  4 2019, 01:37:19) [MSC v.1500 64 bit (AM\n  D64)] on win32\n\nI want to run python3.6 version when I type python.\nWhat I tried\n1) Entered python3 and python3.6, but I didn't work\n2) downloaded python3 and added it to the PATH variable\n\nC:\\Users\\alex\\AppData\\Local\\Programs\\Python\\Python38-32\\Scripts\\;C:\\Users\\alex\\AppData\\Local\\Programs\\Python\\Python38-32\\;C:\\Users\\alex\\AppData\\Local\\Programs\\Python\\Python36\\Scripts\\;C:\\Users\\alex\\AppData\\Local\\Programs\\Python\\Python36\\;C:\\Program Files\\Java\\jdk1.8.0_91\\bin; c:\\Go\\bin; ;%PyCharm%; C:\\Users\\alex\\Desktop\\Education\\5\\dev\\chrome;;C:\\Program Files\\gretl;C:\\chromedriver;C:\\chromium-automation;C:\\Users\\alex\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Python 3.6;","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":212,"Q_Id":61991665,"Users Score":1,"Answer":"You can use the python launcher with the py -3 or py -3.6 command to explicitly invoke python3.\nThe path you posted is not your complete path. It is just the user path. The system path takes precedence over it and has python2 in it.\nYou can uninstall python2 to fix this. Or if you want to keep it, uninstall and reinstall python 3.6 remembering to choose the Add Python to PATH checkbox in the installer.","Q_Score":0,"Tags":"python,path,windows-8.1","A_Id":64344813,"CreationDate":"2020-05-24T19:54:00.000","Title":"How to run python3 from cmd.exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I see the following text when I type python in my Windows 8.1 console (cmd.exe)\n\nPython 2.7.16 (v2.7.16:413a49145e, Mar  4 2019, 01:37:19) [MSC v.1500 64 bit (AM\n  D64)] on win32\n\nI want to run python3.6 version when I type python.\nWhat I tried\n1) Entered python3 and python3.6, but I didn't work\n2) downloaded python3 and added it to the PATH variable\n\nC:\\Users\\alex\\AppData\\Local\\Programs\\Python\\Python38-32\\Scripts\\;C:\\Users\\alex\\AppData\\Local\\Programs\\Python\\Python38-32\\;C:\\Users\\alex\\AppData\\Local\\Programs\\Python\\Python36\\Scripts\\;C:\\Users\\alex\\AppData\\Local\\Programs\\Python\\Python36\\;C:\\Program Files\\Java\\jdk1.8.0_91\\bin; c:\\Go\\bin; ;%PyCharm%; C:\\Users\\alex\\Desktop\\Education\\5\\dev\\chrome;;C:\\Program Files\\gretl;C:\\chromedriver;C:\\chromium-automation;C:\\Users\\alex\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Python 3.6;","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":212,"Q_Id":61991665,"Users Score":1,"Answer":"You need to remove python 2 installation directory from PATH before adding python 3 directory to PATH.","Q_Score":0,"Tags":"python,path,windows-8.1","A_Id":61991724,"CreationDate":"2020-05-24T19:54:00.000","Title":"How to run python3 from cmd.exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Recently I have started to model pandemics as a part of personal project work. I am trying to do this in Python\nOne of the requirements that I have come across is how to perform curve fitting in Python. I have come across some articles which explain how to perform curve fitting for exponential or linear functions using scipy library. But in pandemic the growth curve could be either exponential, or linear\nHow do I perform a curve fit for any random data in Python without knowing if it will be linear or exponential ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":61992008,"Users Score":0,"Answer":"Basically any model used for prediction\/extrapolate needs certain assumption(s).\nFor real world data as pandemic curve, I suggest you resort to more sophisticated methods such as LSTM, 1-D CNN, or Gaussian process with different combinations of kernels.","Q_Score":0,"Tags":"python,scipy","A_Id":61992498,"CreationDate":"2020-05-24T20:23:00.000","Title":"Fitting a random curve in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to integrate Python interpreter in C++ application in Visual Studio 2013, despite of adding INCLUDES and ENV VARIABLES such as LIB & LIBPATH, compilation is throwing an Error as\nLINK : fatal error LNK1104: cannot open file 'python37_d.lib'.\nI tried all possible google suggestions, but still I am not able get rid of this Error. Any help on this would be highly appreciated.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":6292,"Q_Id":61995649,"Users Score":6,"Answer":"This library is intended for debugging, and you simply don't have it if the Python was installed with default options. To obtain it, you are to (re)install Python with \"Download debug binaries\" option enabled in the installer. Then the python37_d.lib will be located in %PythonPath%\\Libs together with python3_d.lib.","Q_Score":3,"Tags":"python,c++","A_Id":62348475,"CreationDate":"2020-05-25T04:13:00.000","Title":"LINK : fatal error LNK1104: cannot open file 'python37_d.lib'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had old version catboost 0.23 or probably 0.22 don't remember , but sure one of these was on my machine. Somehow catboost new version 0.23.1 has been released and get installed in my machine. I noticed my model which was trained on old version had good performance , same old model with same old features\/data and data processing, everything same is giving a little bit off performance on catboost 0.23.1. Previously recall was 0.77 now it has been 0.74 , data is also same ,preprocessing is also same.\nI doubt there is some issue with new version want to double check ,for that what i want to uninstall catboost which i did but getting nowhere old version of catboost 0.22 , any body has any clue please?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":465,"Q_Id":61996230,"Users Score":1,"Answer":"You can explicitly specify package version using pip like this:\npip install catboost==0.23","Q_Score":0,"Tags":"python,catboost","A_Id":61996409,"CreationDate":"2020-05-25T05:17:00.000","Title":"Re installing Catboost 0.22 or 0.23","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to find argmax index in pd.DataFrame. I want exacly the same result, as pandas.DataFrame.idxmax does, but this function returns index of first occurrence of maximum over requested axis. I want find index of last occurrence of maximum. Thank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":887,"Q_Id":62001463,"Users Score":1,"Answer":"Run df[::-1].idxmax()\nThe trick is to process rows in reversed order.","Q_Score":0,"Tags":"python,pandas,pandas-groupby","A_Id":62001586,"CreationDate":"2020-05-25T11:26:00.000","Title":"Find index of the last occurence for maximal value in pd.DataFrame","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build an extension in C for python 3 and I am using Windows. This might be a duplicate question but all the answers for the other question were for linux and I can run sudo on windows.\nHow do I fix this problem ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":800,"Q_Id":62003710,"Users Score":0,"Answer":"If the problem is just the sudo-thing, you can have an admin-Terminal easily.\nOpen your start menu, search for PowerShell, right click -> run as admin\nWith Powershell you can use most important UNIX-commands.\nIf your IDE or Text Editor does not find a header file like  the reason most likely is that this cpp-Header is either not installed or the Path to  is not defined. Look for sth like \"include-path\" in your IDE\u00b4s Settings.","Q_Score":2,"Tags":"python,c,windows,header","A_Id":62003915,"CreationDate":"2020-05-25T13:45:00.000","Title":"#include  no such file or directory for windows 10 fix","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to build an extension in C for python 3 and I am using Windows. This might be a duplicate question but all the answers for the other question were for linux and I can run sudo on windows.\nHow do I fix this problem ?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":800,"Q_Id":62003710,"Users Score":1,"Answer":"Nevermind, I found the answer.\nYou must first search in your python directory for the 'include' folder, for example: \"C:\\Users\\David\\AppData\\Local\\Programs\\Python\\Python38-32\\include\", this is where mine is located and then search for Python.h and like that, you have the header.","Q_Score":2,"Tags":"python,c,windows,header","A_Id":62004410,"CreationDate":"2020-05-25T13:45:00.000","Title":"#include  no such file or directory for windows 10 fix","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to develope a python cgi script for a server run on Windows+IIS. The cgi script is run from a web page with Windows authentification. It means the script is run under different users from Windows active directory. \nI need to use login\/passwords in the script and see no idea how to store the passwords securely, because keyring stores data for a certain user only. Is there a way how to access password data from keyring for all active OS users?\nI also tried to use os.environ variables, but they are stored for one web session only.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":138,"Q_Id":62005012,"Users Score":1,"Answer":"The only thing I can think of here is to run your script as a service account (generic AD account that is used just for this service) instead of using windows authentication. Then you can log into the server as that service account and setup the Microsoft Credential Manager credentials that way.","Q_Score":0,"Tags":"python,environment-variables,python-keyring","A_Id":63603194,"CreationDate":"2020-05-25T14:54:00.000","Title":"Secure password store for Python CGI (Windows+IIS+Windows authentification)","Data Science and Machine Learning":0,"Database and SQL":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 dataset which includes socioeconomic indicators for students nationwide as well as their grades. More specifically, this dataset has 36 variables with about 30 million students as predictors and then the students grades as the responses.\nMy goal is to be able to predict whether a student will fail out (ie. be in the bottom 2%ile of the nation in terms of grades). I understand that classification with an imbalanced dataset (98% : 2%) will introduce a bias. Based on some research I planned to account for this by increasing the cost of an incorrect classification in the minority class.\nCan someone please confirm that this is the correct approach (and that there isn't a better one, I'm assuming there is)? And also, given the nature of this dataset, could someone please help me choose a machine learning algorithm to accomplish this? \nI am working with TensorFlow 2.0 in a Google Colab. I've compiled all the data together into a .feather file using pandas.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":126,"Q_Id":62007061,"Users Score":1,"Answer":"In case of having imbalanced dataset, using weighted class is the most common approach to do so, but having such large dataset (30M training example) for binary classification problem representing 2% for the first class and 98% for the second one, I can say it's too hard to prevent model to be unbiased against first class using weighted class as it's not too much differ from reducing the training set size to be balanced.\nHere some steps for the model accuracy evaluation.\n\n\nsplit your dataset set to train, evalution and test sets.\nFor evaluation metric I suggest these alternatives.\na. Make sure to have at least +20%, representing the first class for both \n evaluation and test sets.\nb. Set evalution metric to be precision and recall for your model accuracy \n     (rather than using f1 score).\nc. Set evalution metric to be Cohen's kapp score (coefficient).\nFrom my own perspective, I prefer using b.\n\n\nSince you are using tensorflow, I assume that you are familiar with deep learning. so use deep learning instead of machine learning, that's gives you the ability to have many additional alternatives, anyway, here some steps for both machine learning and deep learning approach.\nFor Machine Leaning Algorithms\n\n\nDecision Trees Algorithms (especially Random Forest).\nIf my features has no correlation, correlation approach to zero (i.e. 0.01),\nI am going to try Complement Naive Bayes classifiers for multinomial features \nor Gaussian Naive Bayes using weighted class for continuous features. \nTry some nonparametric learning algorithms. You may not able to fit this \ntraining set using Support Vector Machines (SVM) easily because of you \nhave somehow large data set but you could try.\nTry unsupervised learning algorithms \n(this sometimes gives you more generic model)\n\n\nFor Deep Leaning Algorithms\n\n\nEncoder and decoder architectures or simply generative adversarial \nnetworks (GANs).\nSiamese network.\nTrain model using 1D convolution Layers.\nUse weighted class.\nBalanced batches of the training set, randomly chosen.\n\nYou have many other alternatives, From my own perspective, I may try hard to get it with 1, 3 or 5.\nFor Deep learning 5th approach sometimes works very well and I recommend to try it with 1, 3.","Q_Score":2,"Tags":"python,tensorflow,machine-learning,classification,large-data","A_Id":62008911,"CreationDate":"2020-05-25T16:52:00.000","Title":"Advice for my plan - large dataset of students and grades, looking to classify bottom 2%","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a python newbie. I saw a code which had * inside a print function \/\/ print(*a) \/\/ in which 'a' was a list. I know * is multiplication operator in python, but don't know what's  it in a list","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":455,"Q_Id":62008351,"Users Score":1,"Answer":"(If you don't know about the variable number of argument methods, leave this topic and learn this after that)\nUnpacking elements in list\nConsider new_list = [1, 2, 3]. Now assume you have a function called addNum(*arguments) that expects 'n' number of arguments at different instances.\ncase 1:\nConsider calling our function with one parameter in the list. How will you call it? Will you do it by addNum(new_list[0])?\nCool! No problem.\ncase 2: Now consider calling our function with two parameters in the list. How will you call it? Will you do it by addNum(new_list[0], new_list[1])?\nSeems tricky!!\nCase 3: Now consider calling our function with all three parameters in the list. Will you call it by addNum(new_list[0], new_list[1], new_list[2])? Instead what if you can split the values like this with an operator?\nYes! addNum(new_list[0], new_list[1], new_list[2]) <=> addNum(*new_list)\nSimilarly, addNum(new_list[0], new_list[1]) <=> addNum(*new_list[:2])\nAlso, addNum(new_list[0]) <=> addNum(*new_list[:1])\nBy using this operator, you could achieve this!!","Q_Score":1,"Tags":"python-3.x,list,printing","A_Id":62008717,"CreationDate":"2020-05-25T18:18:00.000","Title":"what is the use of * in print(*a) where 'a' is a list in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running Python scripts in a Visual Studio Codespace (Azure) Linux machine, to achieve faster execution time compared to running these scripts in my laptop. \nThe problem is, the codespace is suspended after 2 hours unless I manually take other actions in the codespace within this time. 2 hours seems to be the maximum auto-suspend delay you can set, and then execution is stopped before completion.\nIs there any way to set a longer auto-suspend delay, or to introduce an action in my program which refreshes the auto-suspend countdown?\nWhen creating a Codespace or changing settings of an existing Codespace, three options pop up for \"Auto-Suspend Delay\" in the VS Code dialog box at the top:\n5 minutes\n30 minutes\n2 hours\nI have tried setting a different amount, both as a plain number and as a number followed by \"hours\" or \"minutes\". In both cases, an error is shown: \"Change Codespace Settings: Selection is invalid\".\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":253,"Q_Id":62008608,"Users Score":1,"Answer":"There is no option to run a codespace continuously at this time. You must select one of the auto-suspend options and the codespace will suspend if you're not actively using it, such as typing or interacting with it in some way.","Q_Score":0,"Tags":"python,visual-studio-code,azure-virtual-machine,vscode-remote,codespaces","A_Id":64164532,"CreationDate":"2020-05-25T18:35:00.000","Title":"Keeping Visual Studio Codespaces running on its own for longer than 2 hours?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When multiple containers are allocated on one node, theoretically, since these containers are residing on the same machine, it seems like I could make them share disk memory?\nMore specifically, can I write some data on the disk of the machine that the containers are residing, and have each container grab that piece of data, without having to write multiple copies of the same data for each container?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":62008760,"Users Score":0,"Answer":"I will answer my own question. It seems you can do this by writing the file on a directory that is one level above that of the specific container you are in. I.e.\n\/mnt\/yarn\/usercache\/hadoop\/appcache\/application_1590430074619_0007 for example, in which case you would be writing to a directory that is associated with the particular application you are running.","Q_Score":1,"Tags":"python,apache-spark,containers,hadoop-yarn,dask","A_Id":62009683,"CreationDate":"2020-05-25T18:46:00.000","Title":"Can multiple yarn containers inside same node share disk memory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to reclaim memory of an instance variable in a class denoted by self.x below.   \nShould I use the command del self.x; or self.x=None? What would be their difference? Assuming that the command is to be put in a __del__ or __exit___ function of the class.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":62011476,"Users Score":1,"Answer":"The first thing to understand is that neither del self.x nor self.x = None frees any many memory. What they both do is decrease the reference counter of the object referenced  by self.x by one. Then if the counter of this object has reached 0 when the garbage collector will run then the memory will be freed\nFor the difference between the two, you will not be able to read the value self.x since del self.x will remove x from the instance dictionary. self.x = None is simply reassigning self.x the object None.","Q_Score":0,"Tags":"python,memory-management,garbage-collection,del","A_Id":62012680,"CreationDate":"2020-05-25T22:05:00.000","Title":"Difference between del x and x=None for reclaiming the memory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having trouble getting the VS Code PyTest code runner to work the way I'd like. It seems pytest options may be an all-or-nothing situation.\nIs there any way to run different sets of PyTest options easily in the VS Code interface?\nFor example:\n\nBy default, run all tests not marked with @pytest.mark.slow.\n\nThis can be done with the argument -m \"not slow\"\nBut, if I put that in a pytest.ini file, then it will never run any tests marked slow, even if I pick that particular test in the interface and try to run it. The resulting output is collected 1 item... 1 item deselected.\n\nRun sometimes with coverage enabled, and sometimes without.\n\nThe only way I can see to do this is to run PyTest from the command line, which then loses the benefit of auto-discovery, running\/debugging individual tests from the in-line interface, etc.\nWhat am I missing?\nNote: Currently using VS Code 1.45.1, Python 3.7.6, and PyTest 5.3.5","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":838,"Q_Id":62012775,"Users Score":3,"Answer":"You're not missing anything. There currently isn't a way to provide per-execution arguments to get the integration you want with the Test Explorer.","Q_Score":1,"Tags":"python,visual-studio-code,pytest","A_Id":62053867,"CreationDate":"2020-05-26T00:24:00.000","Title":"How to run different Pytest arguments or marks from VS Code test runner interface?","Data Science and Machine Learning":0,"Database and SQL":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 windows 10 user and I uninstalled python 3.8.3 and then reinstalled it for the ultimate goal of downloading pygame on my computer (which I need pip for). When I tried using the command prompt to check what version of pip I currently have, it says that I have:\nNo Python at 'C:\\Users\\pc\\AppData\\Local\\Programs\\Python\\Python37\\python.exe'\nI have already added Python to my path variable but I do not know what to do next. Please help!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1579,"Q_Id":62013698,"Users Score":0,"Answer":"So, I was able to find a solution (somewhat). I downloaded an older version of python, moved my python installation folder to C:\\Users\\pc\\AppData\\Local\\Programs\\Python\\Python37, and installed pygame using pip. Thank you all!","Q_Score":0,"Tags":"pip,pygame,python-3.8","A_Id":62014090,"CreationDate":"2020-05-26T02:32:00.000","Title":"How do you check the pip version for python 3.8.3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I installed Anaconda on my computer, and use Jupiter notebook to write a script.\nI have some .py files I want to run from Windows or Anaconda Terminal, just out of curiosity.\nHere are the error message I got -\nC:\\Users\\xxx\\Documents>python ex1.py\n'python' is not recognized as an internal or external command,\noperable program or batch file.\nIs there a way that I can run python on Windows without messing up the path?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2984,"Q_Id":62014097,"Users Score":0,"Answer":"I guess you are using Command prompt to parse python files.\n\nOpen Anaconda Prompt, \nnavigate to the folder containing your python files cd c:\\path\\to\\python\\folder \nexecute using python ex1.py  where ex1.py is your filename \n\nin the anaconda terminal","Q_Score":0,"Tags":"python","A_Id":62014659,"CreationDate":"2020-05-26T03:19:00.000","Title":"How to run .py files on Windows\/Anaconda terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to be able to run a python script like a keyboard macro, just by pressing a certain combination of buttons. Is it possible, if yes, how?","AnswerCount":4,"Available Count":3,"Score":-0.0996679946,"is_accepted":false,"ViewCount":7326,"Q_Id":62014315,"Users Score":-2,"Answer":"you click f5 if you have windows","Q_Score":5,"Tags":"python,autohotkey","A_Id":62014390,"CreationDate":"2020-05-26T03:44:00.000","Title":"Can I run a python script from a keyboard shortcut?","Data Science and Machine Learning":0,"Database and SQL":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 be able to run a python script like a keyboard macro, just by pressing a certain combination of buttons. Is it possible, if yes, how?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":7326,"Q_Id":62014315,"Users Score":0,"Answer":"Yes, if you're on a Mac, you can create a 'quick action' in Automate using an apple script to tell Terminal to do something like 'tell application \"Terminal\" to do script \"python myscript.py\"'. Then, you can go into your keyboard shortcut preferences and add a hotkey to the action.","Q_Score":5,"Tags":"python,autohotkey","A_Id":69284433,"CreationDate":"2020-05-26T03:44:00.000","Title":"Can I run a python script from a keyboard shortcut?","Data Science and Machine Learning":0,"Database and SQL":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 be able to run a python script like a keyboard macro, just by pressing a certain combination of buttons. Is it possible, if yes, how?","AnswerCount":4,"Available Count":3,"Score":-0.049958375,"is_accepted":false,"ViewCount":7326,"Q_Id":62014315,"Users Score":-1,"Answer":"Try Ctrl + F5. It worked for me.","Q_Score":5,"Tags":"python,autohotkey","A_Id":66092644,"CreationDate":"2020-05-26T03:44:00.000","Title":"Can I run a python script from a keyboard shortcut?","Data Science and Machine Learning":0,"Database and SQL":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 Puppeteer to log into a bank website and scrape data of my transactions in a C# application, and it works fine.\nHowever, I am looking for a way to do the same in a simple Azure function.  I was able to get it working by wrapping it in a docker instance, but the expense of the Azure Premium Subscription in order to run it makes it not cost-effective.\nI have looked at trying to log into logging into the site and scraping the HTML, except it uses CryptoJS to alter the login credentials, as well as create some unique form properties on the POST message.  \nSo my question is, is it possible to pull out the JS from the website to replicate the encoding with python, so I don't require a full headless browser to log in?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":62014689,"Users Score":0,"Answer":"After further investigation, the site itself is a Javascript Renderable site, which requires requests-html to render, which in itself uses pyppeteer which is a headless chromium, which won't work in Azure anyway.  \nSo I'm just going to look at alternative hosting and build it as a web API instead of Azure Functions.","Q_Score":0,"Tags":"python-3.x,azure,cryptojs","A_Id":62032684,"CreationDate":"2020-05-26T04:29:00.000","Title":"Unable to log into encrypted Banking website with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a path variable in the system variables but how do i add a path variable in the user variables section since i don't have any at the moment.\nIf there isn't a path variable  in the user variables will it affect in any way?\nHow much will values of the path variables differ from the one in environment variables to the one in user variables if there is only one user present?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":62015008,"Users Score":0,"Answer":"to add a new variable in users variable\n\nclick one new button below the user variables.\n\n2.Then a pop window will appear asking you to type new variable name and its value, click ok after entering name and value.\nThats how you can add a new variable in user variables.\nYou should have a path variable in user variables also because ,for example while installing python you have a choice to add python path to variables here the path will be added in user variable 'path'.","Q_Score":0,"Tags":"python","A_Id":62015154,"CreationDate":"2020-05-26T05:06:00.000","Title":"How do i add a PATH variable in the user variables of the environment variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have the following setup:\n\nWindows 10\npython installed via Anaconda\nVirtual environment setup via Anaconda for running and testing my project with pytest\ngit version control via MINGW \n\nNow I'd like to set a githook that runs all my tests before I push. I have the following problem: I can't activate my virtual environment within the githook.\nI tried to activate my anaconda env in the githook script but I can't get it to work. activate as command is not available and calling the whole path ..\/Anaconda3\/Scripts\/activate.bat does nothing.\nI also tried to use python-githooks to configure the hook for me, but this doesn't seem to work in Windows (it can't read PWD from the environment...)\nI'm gratefull for any suggestions.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":62016261,"Users Score":0,"Answer":"The solution was to create a .bat-File at the root of the git repository, with:\ncall C:\\...\\Anaconda3\\Scripts\\activate.bat\ncall activate fs_env\npytest\nand to call this file within the pre-push file in .git\/hooks with:\n.\/runtests.bat","Q_Score":3,"Tags":"python,windows,git,githooks,anaconda3","A_Id":62023870,"CreationDate":"2020-05-26T06:54:00.000","Title":"pytest githook on Windows with Anaconda","Data 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 I change my project to another conda environment than base environment, python code completion doesn't work anymore for installed modules (like cv2).\nI have no problem detecting the environment or running my code though. How can I fix it ?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":563,"Q_Id":62018436,"Users Score":1,"Answer":"Open your Anaconda Prompt, activate the environment, and then launch VS Code from within the activated environment (i.e. code .).","Q_Score":2,"Tags":"python,visual-studio-code,anaconda,conda","A_Id":62053889,"CreationDate":"2020-05-26T09:06:00.000","Title":"vscode IntelliSense \/ code completion doesn't work when I am not in base conda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I change my project to another conda environment than base environment, python code completion doesn't work anymore for installed modules (like cv2).\nI have no problem detecting the environment or running my code though. How can I fix it ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":563,"Q_Id":62018436,"Users Score":0,"Answer":"I had the same problem in mac os. The problem was with the \"Language Server\" setting in the python extension, which is by default \"Jedi\". I changed it to \"pylance\" and it solved my problem. To use pylance you have to install the pylance extension.","Q_Score":2,"Tags":"python,visual-studio-code,anaconda,conda","A_Id":67252230,"CreationDate":"2020-05-26T09:06:00.000","Title":"vscode IntelliSense \/ code completion doesn't work when I am not in base conda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing image classification based on a CNN in tensorflow and Keras. I am classifying images of faces, into which emotion is being expressed (happy, sad, etc). This actually works pretty well, but there is something I don't really understand. \nFor each image, I also have the age of the person that is on the image. I want to add this information (age) to the CNN. So right now the CNN only uses the pixels of the image, but i want to make the CNN to take the age into account. Is this possible \/ what is the method for this? \nMy first thought was to add an extra dimension to the image, with the age, but then I'm kind of stuck... Because age is just 1 number, and of course each layer in the image is width x height. Can I just ad a layer that consists of a whole matrix with just the age as value of each pixel? \nAnyone who knows how such a thing usually is done...?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":62019558,"Users Score":0,"Answer":"I would add it to the CNN output, i.e. the last tensor before the dense layer.\nIn classification, a CNN is used as a feature extractor. The goal is, given an image, to find the best feature vector that should be passed to the dense layer. So each element represents something for your neural network, a feature.\nIf you have any other feature you want to add, put it there and let the dense layers do the work.","Q_Score":0,"Tags":"python,image,tensorflow,classification,conv-neural-network","A_Id":62022506,"CreationDate":"2020-05-26T10:03:00.000","Title":"Image classification with extra 'dimension'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've set up a neural network regression model using Keras with one target. This works fine,\nnow I'd like to include multiple targets. The dataset includes a total of 30 targets, and I'd rather train one neural network instead of 30 different ones.\nMy problem is that in the preprocessing of the data I have to remove some target values, for a given example, as they represent unphysical values that are not to be predicted.\nThis creates the issues that I have a varying number of targets\/output.\nFor example:\nTargets =\n\nNone, 0.007798, 0.012522\n0.261140, 2110.000000, 2440.000000\n0.048799, None, None\n\nHow would I go about creating a keras.Sequential model(or functional) with a varying number of outputs for a given input?\nedit: Could I perhaps first train a classification model that predicts the number of outputs given some test inputs, and then vary the number of outputs in the output layer according to this prediction? I guess I would have to use the functional API for something like that.\n\nThe \"classification\" edit here is unnecessary, i.e. ignore it. The number of outputs of the test targets is a known quantity.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":62019570,"Users Score":1,"Answer":"(Sorry, I don't have enough reputation to comment)\nFirst, do you know up front whether some of the output values will be invalid or is part of the problem predicting which outputs will actually be valid?\nIf you don't know up front which outputs to disregard, you could go with something like the 2-step approach you described in your comment. \nIf it is deterministic (and you know how so) which outputs will be valid for any given input and your problem is just how to set up a proper model, here's how I would do that in keras:\n\nUse the functional API\nCreate 30 named output layers (e.g. out_0, out_1, ... out_29)\n\n\nWhen creating the model, just use the outputs argument to list all 30 outputs\n\nWhen compiling the model, specify a loss for each separate output, you can do this by passing a dictionary to the loss argument where the keys are the names of your output layers and the values are the respective losses\n\n\nAssuming you'll use mean-squared error for all outputs, the dictionary will look something like {'out_0': 'mse', 'out_1': 'mse', ..., 'out_29': 'mse'}\n\nWhen passing inputs to the models, pass three things per input: x, y, loss-weights\n\n\ny has to be a dictionary where the key is the output layer name and the value is the target output value\nThe loss-weights are also a dictionary in the same format as y. The weights in your case can just be binary, 1 for each output that corresponds to a real value, 0 for each output that corresponds to unphysical values (so they are disregarded during training) for any given sample\nDon't pass None's for the unphysical value targets, use some kind of numeric filler, otherwise you'll get issues. It is completely irrelevant what you use for your filler as it will not affect gradients during training\n\n\nThis will give you a trainable model. BUT once you move on from training and try to predict on new data, YOU will have to decide which outputs to disregard for each sample, the network will likely still give you \"valid\"-looking outputs for those inputs.","Q_Score":1,"Tags":"python,tensorflow,keras,neural-network","A_Id":62020648,"CreationDate":"2020-05-26T10:03:00.000","Title":"How would I go about creating a keras model with a varying number of targets\/outputs?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been learning HTML and CSS for about a year, I\u2019m a massive noob at Python and I would like someone to clear some things up for me if possible.\nI'm wanting to use a browser extension to automate some work tasks, there's a few good ones that work with JS but I'd like to focus on Python.\nI understand that python would require a interpreter to work, I've ran some basic scripts on my PC but I don't understand how you'd execute scrips externally on the web.\nDo web browsers have a built in interpreter?\nAre there such extensions that exist?\nAnd if so do they have interpreters built in?\nPython is a brand new concept to me and I apologise if this is a stupid question. I aim to get the basics down first and then pick up a Raspberry Pi for some project work.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":62023510,"Users Score":1,"Answer":"Do web browsers have a built in interpreter?\n\nThey have a JavaScript console in dev tools instead of python","Q_Score":0,"Tags":"python,web,browser,automation,scripting","A_Id":68939635,"CreationDate":"2020-05-26T13:42:00.000","Title":"Noob Question About Python Web Automation","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":"Residual networks are always built with convolutional layers. I have never seen residual networks with only fully connected layers. Does it work to build a residual network with only fully connected layers?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1607,"Q_Id":62023882,"Users Score":1,"Answer":"As Tapio, I also disagree with Giuseppe's conclusion. Residual layers are said to help improving performance in multiple ways: They let the gradient flow better, they might help in localization etc.  My guess is that some of these advantages like gradient flow, hold also for networks consisting of fully connected layers.\nOther ideas like saying we learn residuals F(X)-X, where F is a residual block are more questionable due to absence of spatial correlation. That is, for CNNs, where residual connections are mostly used, we have some form of locality, that is if you have the feature map X of some layer (you can also think of X as the input) and the output of a residual block F(X) then both X and F(X) correlate. That is, oftentimes the map at location X[i,j] is similar to that of F(X)[i,j]. This does not hold for fully connected networks, since neurons do not contain spatial information. However, to what extent this matters is probably an open problem :-) .","Q_Score":6,"Tags":"python,machine-learning,neural-network,conv-neural-network,deep-residual-networks","A_Id":66249604,"CreationDate":"2020-05-26T14:00:00.000","Title":"Does it make sense to build a residual network with only fully connected layers (instedad of convolutional layers)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make a windows application from my python project. Since it is a machine learning project, lot of dependencies  are there.  How to convert the ML Project into a executable file.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":471,"Q_Id":62024281,"Users Score":0,"Answer":"I can highly recommend pyinstaller, it will include all necessary dependencies and is rather easy to use and well documented. I suggest you give it a try","Q_Score":0,"Tags":"python,windows,computer-vision,python-packaging","A_Id":62059732,"CreationDate":"2020-05-26T14:19:00.000","Title":"How to make a exe file from python ML project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running an ongoing command on a Windows Anaconda Powershell terminal to scrape Twitter data. I would like to be able to receive a notification if the code drops, preferably either email or SMS message. I've been able to find some packages that do this in OS but not Windows. Any ideas on how this could be set up?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":62026273,"Users Score":0,"Answer":"you can create a python script which call your code inside it and get notified using knockknock.","Q_Score":0,"Tags":"python,windows,terminal,conda","A_Id":62057477,"CreationDate":"2020-05-26T15:54:00.000","Title":"Terminal command to notify if code has stopped 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 used to work in IDLE. There, if I reran a program it automatically kills the previous instances of the program. \nBut recently I shifted to Sublime. If I rerun the same program here, all the previous instances do not die and keep on running. \nCan any one provide a method so that when I rebuild a program the previous instances automatically die.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":130,"Q_Id":62027872,"Users Score":1,"Answer":"If a build is still running, simply select Tools \u2192 Cancel Build and it will be killed. You can use CtrlBreak as a keyboard shortcut.","Q_Score":0,"Tags":"python-3.x,sublimetext3,python-idle","A_Id":62028118,"CreationDate":"2020-05-26T17:21:00.000","Title":"How to kill previous Python process when rebuilding a program in Sublime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I know it is some kind of basic question but I am not good at the fundamental things. I only know that for stack pop() method pops out the last element with O(1) time. \nIn python, it's allowed to pop any position in a list as well as to insert an element to any position, i.e. list.pop(index) and list.insert(index, item). If the length of a list is n, what's the average time complexity of them?\nBesides, is there a difference between list.insert(index, item) and list = list[:index] + [item] + list[index:]?\nThank you very much for the help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":62028924,"Users Score":0,"Answer":"While list.insert(index, item) does practically the same thing as list = list[:index] + [item] + list[index:], the python built-in function list.insert was made as a faster way to insert an item into a list. list.insert is more advanced and is not equivalent to list = list[:index] + [item] + list[index:] becuase it uses a different algorithim and is much faster.\nThe time complexity is O(n), which is approximately n\/2.","Q_Score":0,"Tags":"python,list,time-complexity","A_Id":62030330,"CreationDate":"2020-05-26T18:28:00.000","Title":"What's the time complexity for some python list operations?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a program that modifies PNG files with Python's Pillow library. I was wondering how I could load binary data into a PNG image from PIL's Image object. I receive the PNG over a network as binary data (e.g. the data looks like b'\\x89PNG\\r\\n\\x1a\\n\\x00\\x00\\x00\\rIHDR...'). What is the best way to accomplish this task?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":102,"Q_Id":62029177,"Users Score":1,"Answer":"I'd suggest receiving the data into a BytesIO object from the io standard library package. You can then treat that as a file-like object for the purposes of Pillow.","Q_Score":0,"Tags":"python,numpy,python-imaging-library,png","A_Id":62029274,"CreationDate":"2020-05-26T18:44:00.000","Title":"Best way to load a Pillow Image object from binary data in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why does this\n'''tensor_ques[1:3,1]=0'''\nwork \nand this\n'''tensor_ques[1:3,1] =[0,0]'''\ndoes not work\ntensor_ques is a torch.tensor()\nI know [0,0] is not a tensor then why does =0 work fine","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":62029416,"Users Score":0,"Answer":"It doesn't work because [0,0] is a list, and torch does not allow you to assign a list to a tensor. It'll only work if the item being assigned is also a tensor, i.e. tensor_ques[1:3,1] = torch.tensor([0,0]).","Q_Score":0,"Tags":"python,tensorflow,deep-learning,pytorch,tensor","A_Id":62030908,"CreationDate":"2020-05-26T18:59:00.000","Title":"Tensor slicing conditions for assignement","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"using pyodbc to query a MySQL database with SELECT. I need to determine if the query returned anything or not, the way I found that people were using is the rowcount, however this always returns -1 for me after some testing. I found this on the github wiki for cursor which I think describes my problem.\n\nrowcount\nThe number of rows modified by the last SQL statement.\nThis is -1 if no SQL has been executed or if the number of rows is unknown. Note that it is not uncommon for databases to report -1 immediately after a SQL select statement for performance reasons. (The exact number may not be known before the first records are returned to the application.)\n\nI am wondering if either there is a way around this or if there is another way to do it, thanks.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":3298,"Q_Id":62029789,"Users Score":4,"Answer":"I always check the length of the return results\nres=newcursor.fetchall()\nif len(res)==0:##means no results","Q_Score":2,"Tags":"python,pyodbc","A_Id":62134714,"CreationDate":"2020-05-26T19:22:00.000","Title":"How to check if pyodbc cursor is empty?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to webscraping, and I am unsure what is the most efficient way of going about this problem. This project is mostly in Python, but I am open to using other languages for the sake of efficiency.\nImagine some js driven value on a website, something like a real-time visitor count, or the price of some financial asset. that after the website is loaded, constantly updates as new information comes in. What I want is to sub-second sample one such value, but naturally, I don't want to bombard the server with requests, which would ruin accuracy anyway.\nI was thinking of something along the lines of loading a webpage with selenium, or the PyQt webkit, and then running a simple loop that monitors the value and updates a database as changes occur. I am not looking for code, that I can figure out on my own, but I'm unsure if that's the right way to go about solving this problem, or if there are more efficient ways.\nThank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":313,"Q_Id":62030579,"Users Score":0,"Answer":"I have done exactly what you are referring to by using Python and Selenium exclusively. I don't see why Python would not be the language to use for your specific use case. The only issue I could see would be if the webpage is constantly (or slowly) changing. \nI came across an issue where the webpage was redesigned and it through off my Xpath. All I had to do was correct the Xpath to reflect the new location and it still worked.\nAnother solution could be to check if their is already an existing API for the webpage you are trying to scrape. If this is the case, you may not have to do any web-scraping, and could just call the API and get your value. This would be the most efficient way, but obviously not possible if there is not API to call.\nSide-Note: I am most comfortable with Python and usually default to it when trying to automate a task. There may be more performant languages to use, but my choice would be Python.","Q_Score":1,"Tags":"javascript,python,web-scraping","A_Id":62030866,"CreationDate":"2020-05-26T20:09:00.000","Title":"How do I monitor a constantly updating value on a website?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm new to this, so I apologize if my question is uneducated:\nI have a USB device for which I know the ProductID and VendorID.  From what I understand, it should be a HID device which sends a serial stream to my computer.  I was to write a script in python in order to read that serial stream, but I am getting nowhere.  Is there a way for Python's serial library to find a device from a PID and VID?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11297,"Q_Id":62031686,"Users Score":0,"Answer":"You can also just do an 'ls \/dev\/tty*.*' and find the USB device rather than go through to voluminous amount of garbage dumped by 'ioreg'.","Q_Score":1,"Tags":"python,pyserial,libusb,usbserial","A_Id":72361824,"CreationDate":"2020-05-26T21:25:00.000","Title":"Reading a serial signal from a USB port 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":"I have made a Python program that uses output.to_csv('results.csv'). When I run it in Spyder it creates that CSV file. But when I double click on it nothing happens. Cmd appears and closes but nothing on the folder, no results.csv.\nWhat am I missing? What more do I have to do?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":881,"Q_Id":62031834,"Users Score":1,"Answer":"Run the program from the command line itself instead of double-clicking the .py file.\nI assume you are on Windows since you mention CMD. First, cd into the directory containing your program. Then, run python <program>.py or python3 <program>.py depending on your installation.\nThis time, you will see any output or error messages that appear in CMD without it immediately closing.","Q_Score":0,"Tags":"python,windows-10","A_Id":62031907,"CreationDate":"2020-05-26T21:37:00.000","Title":"How to make Windows execute my Python script files when I click them","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a Python program that uses output.to_csv('results.csv'). When I run it in Spyder it creates that CSV file. But when I double click on it nothing happens. Cmd appears and closes but nothing on the folder, no results.csv.\nWhat am I missing? What more do I have to do?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":881,"Q_Id":62031834,"Users Score":0,"Answer":"If the .csv file really exists, you should be able to go to your File Explorer and find the file at the top of the \"Quick Access\" section. Right-click the file and hover over \"Open With >\". Then select Notepad and a notepad will open up showing your results.\nIf you do not see the file, then try running your program on the command prompt (for Windows):\n\nPress the windows key and type \"cmd\" in the search bar.\nChoose \"Command Prompt\"\nGo to the dir of your program using the cd command\nType python <program name>.py\nIf there are no errors, follow the steps in the first paragraph.","Q_Score":0,"Tags":"python,windows-10","A_Id":62032006,"CreationDate":"2020-05-26T21:37:00.000","Title":"How to make Windows execute my Python script files when I click them","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a Python program that uses output.to_csv('results.csv'). When I run it in Spyder it creates that CSV file. But when I double click on it nothing happens. Cmd appears and closes but nothing on the folder, no results.csv.\nWhat am I missing? What more do I have to do?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":881,"Q_Id":62031834,"Users Score":0,"Answer":"Ok i guess windows is not recommended at all for this type of tasks. I mean running something simple as create such file is like trying to kill the Lernaean Hydra. \nWhat i did is i just runned it with anaconda prompt and it worked sweet! Thanks for help. Thanks to all!\nPS: I'm seriously considering changing to Linux after this\nFor anyone having the same problem, but have anaconda installed. 1) Open Anaconda Prompt, 2) use cd (1 space) then adress of the folder which contains your py program (eg. cd C:\\Users\\Bernie\\Desktop\\tasos) and hit enter, 3) on the next line that appears type: python program_name.py, 4)Hit enter, 5)success!","Q_Score":0,"Tags":"python,windows-10","A_Id":62043438,"CreationDate":"2020-05-26T21:37:00.000","Title":"How to make Windows execute my Python script files when I click them","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have started to learn text mining and natural language processing using R and Python. Recently, I was trying to perform some basics tasks such as: (1) the most frequent terms used within a set of documents (email documents) and (2) clustering. The \"problem\" comes with some repetitive paragraphs, such as disclaimers, signatures on emails, etc; because they are adding some noise to my results.... Is there a way to identify boilerplate or repetitive paragraphs within the set of documents? In order to remove them during the preprocessing tasks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":100,"Q_Id":62033609,"Users Score":1,"Answer":"Measuring the similarity of documents is a huge topic, and an active area of research. There are many ways of identifying boilerplate, none of them perfect.  \nBut check out the wydyr package functions.  Break documents into paragraph-size sections (or smaller.)  Use pairwise_count and pairwise_cor to get similarity measures between, e.g. the opening and closing sections of documents.\nAlso, get a copy of Text Mining with R by Silge and Robinson; pay attention to Chapter 4.","Q_Score":0,"Tags":"python,r,nlp,boilerplate","A_Id":62034429,"CreationDate":"2020-05-27T00:33:00.000","Title":"Identify duplicated paragraphs (boilerplate) within several email documents","Data Science and Machine Learning":0,"Database and SQL":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 know how to delete\/clear all text in a file inside another python file, I looked through stack overflow and could not find a answer, all help appreciated. Thanks!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":97,"Q_Id":62033858,"Users Score":1,"Answer":"Try: open('yourfile.txt', 'w').close()","Q_Score":2,"Tags":"python","A_Id":62033896,"CreationDate":"2020-05-27T01:06:00.000","Title":"Clear all text in separate file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to train a model for autonomous driving that converts input from the front camera, to a bird's eye view image.\nThe input and output, both are segmentation masks with shape (96, 144) where each pixel has a range from  0 to 12 (each number represents a different class).\nNow my question is how should i preprocess my data and which loss function should i use for the model (I am trying to use a Fully convolutional Network).\nI tried to convert input and outputs to shape (96, 144, 13) using keras' to_categorical utility so each channel has 0s and 1s of representing a specific mask of a category. I used binary_crossentropy ad sigmoid activation for last layer with this and the model seemed to learn and loss started reducing. \nBut i am still unsure if this is the correct way or if there are any better ways.\nwhat should be the:\n\ninput and ouptput data format\nactivation of last layer\nloss function","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":62038389,"Users Score":1,"Answer":"I found the solution, use categorical crossentropy with softmax activation at last layer. Use the same data format as specified in the question.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,keras,loss-function","A_Id":62104557,"CreationDate":"2020-05-27T08:12:00.000","Title":"Loss function and data format for training a ''categorical input' to 'categorical output' model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am migrating a python 2 code to python 3, then I am having problems with encode\/decode. First I have multiples sentence that I should convert in the following way:\nstring-->string in hexadecimal\nBefore, in python 2 I was using a code like that hex_message = message.encode(\"hex\"), then before to migrate was working perfectly. As an example, input->\"Hello world\", output ->\"48656c6c6f20776f726c64\". Then I have this problem LookupError: 'hex' is not a text encoding; use codecs.encode() to handle arbitrary codecs. I changed the expression to this hex_message = codecs.encode(message, 'hex') and I am getting this output b\"48656c6c6f20776f726c64\". So, not so many changes, the problem is that I have a multiples strings that they are not byte objects and I have to join them so I would like to encode but not as a byte object only as string. I would like to get them as before with an another function or with an additional function.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":62038411,"Users Score":0,"Answer":"I find a solution:\nmessage = \"Hello world\".encode('utf-8') then\nhex_message = message.hex(). It is working in python3.","Q_Score":0,"Tags":"python-3.x,hex","A_Id":62038620,"CreationDate":"2020-05-27T08:12:00.000","Title":"Byte hexadecimal object converting to string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i was trying to use average ensembling on a group of models i trained earlier (i'm creating a new model in the ensemble for each pre-trained model i'm using and then loading the trained weights onto it, it's inefficient this way i know but i'm just learning about it so it doesn't really matter). and I mistakenly changed some of the network's parameters when loading the models in the ensemble code like using Relu instead of leakyRelu which i used in training the models and a different value for an l2 regularizer in the dense layer in one of the models. this however gave me a better testing accuracy for the ensemble. can you please explain to me if\/how this is incorrect, and if it's normal can i use this method to further enhance the accuracy of the ensemble.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":62039819,"Users Score":0,"Answer":"Though you changed the network's parameters when loading the models. It is not incorrect to alter the hyper-parameters of your ensemble's underlying models. In some cases, the models that are used in an ensemble method require unique tunings which can, as you mentioned, give \"you a better testing accuracy for the ensemble model.\"\nTo answer your second question,  you can use this method to further enhance the accuracy of the ensemble, you can also use Bayesian optimization, GridSearch, and RandomSearch if you prefer more automated means of tuning your hyperparameters.","Q_Score":0,"Tags":"python,tensorflow,keras,deep-learning,ensemble-learning","A_Id":62052799,"CreationDate":"2020-05-27T09:29:00.000","Title":"is it incorrect to change a model's parameters after training it?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i was trying to use average ensembling on a group of models i trained earlier (i'm creating a new model in the ensemble for each pre-trained model i'm using and then loading the trained weights onto it, it's inefficient this way i know but i'm just learning about it so it doesn't really matter). and I mistakenly changed some of the network's parameters when loading the models in the ensemble code like using Relu instead of leakyRelu which i used in training the models and a different value for an l2 regularizer in the dense layer in one of the models. this however gave me a better testing accuracy for the ensemble. can you please explain to me if\/how this is incorrect, and if it's normal can i use this method to further enhance the accuracy of the ensemble.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":252,"Q_Id":62039819,"Users Score":0,"Answer":"I believe it is NOT correct to chnage model's parameters after training it. parameters here I mean the trainable-parameters like the weights in Dense node but not hyper-parameters like learning rate.\nWhat is training?\nTraining essentially is a loop that keeps changing, or update, the parameters. It updates the parameter in such a way that it believes it can reduce the loss. It is also like moving your point in a hyper-spaces that the loss function gives a small loss on that point. \nSmaller loss means higher accruacy in general.\nChanging Weights\nSo now, changing your parameters values, by mistake or by purpose, is like moving that point to somewhere BUT you have no logical reason behind that such move will give you a smaller loss. You are just randomly wandering around that hyper-space and in your case you are just lucky that you land to some point that so happened give you a smaller loss or a better testing accuracy. It is just purely luck.\nChanging activation function\nAlso, altering the activation function from leakyRelu to relu is similar you randomly alter the shape of your hype-space. Even though you are at the some point the landscape changes, you are still have no logical reason to believe by such change of landscape you can have a smaller loss staying at the same point\nWhen you change the model manually, you need to retrain.","Q_Score":0,"Tags":"python,tensorflow,keras,deep-learning,ensemble-learning","A_Id":62058898,"CreationDate":"2020-05-27T09:29:00.000","Title":"is it incorrect to change a model's parameters after training it?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"It says: Stable-Baselines supports Tensorflow versions from 1.8.0 to 1.15.0, and does not work on Tensorflow versions 2.0.0 and above.\nSo I tried to install \"sudo pip3 install tensorflow==1.15.0\"\nBut I get the message:\nERROR: Could not find a version that satisfies the requirement tensorflow==1.15.0 (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0)\nERROR: No matching distribution found for tensorflow==1.15.0\nI'm using:\nUbuntu 20.04 LTS\nPython 3.8.2\npip 20.1.1 from ...\/python3.8\/site-packages\/pip (python 3.8)\nHow can I install a tensorflow version that works with stable-baselines?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":868,"Q_Id":62042491,"Users Score":0,"Answer":"I solved the problem by using anaconda instead.\nThanks for the help!","Q_Score":2,"Tags":"python-3.x,tensorflow,ubuntu,pip,stable-baselines","A_Id":62470111,"CreationDate":"2020-05-27T11:53:00.000","Title":"stable-baseline with tensorflow issue","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I succesfully compiled app for android, and now I want to compile python kivy app for ios using buildozer. My operation system is Windows 10, so I don't know how to compile file for ios. I downloaded ubuntu console from microsoft store, that helped me to compile apk file. How to compile file for ios? I hope you help me...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":995,"Q_Id":62042752,"Users Score":0,"Answer":"You can only deploy to iOS if you're working on a MacOS machine.","Q_Score":0,"Tags":"python,ios,kivy,buildozer","A_Id":62052663,"CreationDate":"2020-05-27T12:05:00.000","Title":"how to compile python kivy app for ios on Windows 10 using buildozer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe with a single column \"Cntr_Number\" with x no of rows.\nWhat i trying to achieve is using selenium to copy and paste the data into the web page textarea.\nThe constraint is that the web page text area only accept 20 rows of data per submission.\nSo how can i impplment it using while loop or other method.\n\nCopy and paste the first 20 rows of data and click on the \"Submit\"\nbutton \nCopy and paste the next 20 rows of data and click on the\n\"Submit\" button\n\nrepeat the cycle until the last row.\nSorry i dont have any sample code to show but this is what I'm trying to achieve.\nAppreciate if could have some sample code on how to do the implmentation.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":93,"Q_Id":62042753,"Users Score":1,"Answer":"The better approach will be capture all the the data in a List, Later while pasting it you can check the length of the list, and later iterate through the list and paste the data 20 at a time in the text area. I hope this will solve your problem.","Q_Score":0,"Tags":"python-3.x,pandas,selenium,rpa","A_Id":62043005,"CreationDate":"2020-05-27T12:06:00.000","Title":"How to copy and paste dataframe rows into a web page textarea field","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"TLDR: This is not a question about how to change the way a date is converted to a string, but how to convert between the two format types - This being \"%Y\" and \"YYYY\", the first having a % and the second having 4 x Y.\nI have the following date format \"%Y-%M-%D\" that is used throughout an app. I now need to use this within a openpyxl NamedStyle as the number_format option. I cant use it directly as it doesn't like the format, it needs to be in \"YYYY-MM-DD\" (Excel) format.\n\nDo these two formats have names? (so I can Google a little more)\nShort of creating a lookup table for each combination of %Y or %M to Y and M is there a conversion method? Maybe in openpyxl? I'd prefer not to use an additional library just for this!\n\nTIA!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":226,"Q_Id":62042852,"Users Score":1,"Answer":"Sounds like you are looking for a mapping between printf-style and Excel formatting. Individual date formats don't have names. And, due to the way Excel implements number formats I can't think of an easy way of covering all the possibilities. NamedStyles generally refer to a collection of formatting options such as font, border and not just number format.","Q_Score":0,"Tags":"python,datetime,openpyxl","A_Id":62064090,"CreationDate":"2020-05-27T12:11:00.000","Title":"Convert the string \"%Y-%M-%D\" to \"YYYY-MM-DD\" for use in openpyxl NamedStyle number_format","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I writing an application that has a change control workflow.  Users retrieve data for a particular month and then they make edits to it and there is a review phase where they can approve records.  There are 2 identical tables a master and a staging table.  When the user loads up the application they load data from the master table and can edit it in a crud grid.  When they hit the stage button I want that data to get pushed inserted into the staging table.  How do i tell my view to do that.  The staging table doesnt have the associated records yet, i want the records that are sent back as part of the push  to get inserted there rather than doing an update to the master table?\nAny advice would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":134,"Q_Id":62043101,"Users Score":0,"Answer":"You can add new field name can be status in your master table which shows this record in staging process. \nFor example : \nYou inserted new record into master table so initial value of status will be 1 (new_created). \nWhen you want to process Master table record you must change the status to 2 (in_staging) which is showing thia record in already in staging process can't process further. \nUsing new field can manage your process easily and you can check how many records are in staging process at a given time.\nWhen you store the master record you can check which fields are changed or not in form. \nSave master record with status 2 and copy the master record and save them into staging table. \nAfter that when your staging completed you can use the same process to save your objects.","Q_Score":0,"Tags":"django,python-3.x,django-models,django-rest-framework,django-views","A_Id":62056357,"CreationDate":"2020-05-27T12:25:00.000","Title":"Push changes to data in one Django model to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to make a web application where a user can:\n\nclick a button on a webpage to create a **random video (with moviepy)\nplay that video back on the webpage\nclick the button again to create a new **random video that replaces the existing one\n\n** The random video will be created with a python\/moviepy script that downloads a bunch of random video clips from the internet to a directory on my computer. It then compiles them into one video (.mp4 file). \nI've done the python script bit already which successfully creates the video file. \nTo make the web app bit I have been recommended django and that's where I'm stuck! \nSo far I have installed django and got to grips with the basics .. I have a home page that says \"Hello world\". \nMy question is where do I go from here? \nHow do I connect my python\/moviepy script with django?\nWhat steps, apps, components etc, within django should I look into to make this thing?\nI'm new to coding and looking for some guidance. \nThanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":465,"Q_Id":62043703,"Users Score":0,"Answer":"As I see, Django is for complex sites, you should look for Flask instead.\n(I am learning Django and I know nothing about Flask, so I`ll go with it)\nHere is the needed setup:\n\ndefine the urlpatterns for handling the URLs\ncreate a model for storing your video\ncreate a django template for your page (html)\ndefine a view for rendering out the template (passing the video)\nmaybe some css to design it\n\nYou can run your video generator(in the view) at every reload and override existing video(in this case you don't even need a model) or you can save the generated videos and capture the IDs in the URLs (for example: https:\/\/yoursite.com\/1), in this case, the videos remain shareable.\nIf you go with the first option and sharing videos is not important for you then you could write a simple html page with a video and a button. The button can trigger a javascript function to run the video generator python script and refresh the page(the video is overridden), you may need to wait to the script otherwise the old video can load.\nRestful API is a more advanced way to refresh the video, without reloading the page.\nAfter these, you can deploy your page using an Apache server for example.\nI tried to give you some guidelines (I am learning this on my own)\nHope that it helped :) There are tutorials for these.","Q_Score":0,"Tags":"python,django,moviepy","A_Id":62048184,"CreationDate":"2020-05-27T12:58:00.000","Title":"Creating a web app in django that creates a video (with moviepy) and plays it: Where to start?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"As far as I understood it, iterators use lazy evaluation, meaning that they don't actually save each item in memory, but just contain the instructions on how to generate the next item. \nHowever, let's say I have some list [1,2,3,4,5] and convert it into an iterator doing a = iter([1,2,3,4,5]). \nNow, if iterators are supposed to save memory space because as said they contain the instructions on how to generate the next item that is requested, how do they do it in this example? How is the iterator a we created supposed to know what item comes next, without saving the entire list to memory?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":62045399,"Users Score":0,"Answer":"Just think for a moment about this scenario ... You have a file of over a million elements, loading the memory of the whole list of elements would be really expensive. By using an iterator, you can avoid making the program heavy by opening the file once and extracting only one element for the computation. You would save a lot of memory.","Q_Score":0,"Tags":"python,python-3.x,iterator","A_Id":62045929,"CreationDate":"2020-05-27T14:20:00.000","Title":"How do iterators know what item comes next?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run Command Prompt commands using Python, but running my command seems to do nothing. The full command I pass to os.system is:\n'cmd \/c \"apt.bat\"'\nThis should run apt.bat, opening another program in the process. However, nothing happens. When I pass that same command to the Command Prompt manually, it runs correctly. So to try to hone in on the problem, I have tried running:\nos.system('cmd')\nbut nothing happens. As far as I know, this should open the Command Prompt, but I could be wrong about that. To ensure that I have the correct syntax and that os.system isn't broken or something, I have also tried running:\nos.system('notepad')\nwhich opens notepad without issue. Is there something different about 'cmd' that would cause it to simply not open? Is there some syntax I am missing? Maybe permissions?\nFor reference, I am on Windows 10. Python 3.7, using Spyder 4.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2188,"Q_Id":62045916,"Users Score":-1,"Answer":"Your problem is that cmd is not a command. You should be using os.system('start cmd') or subprocess.run('start', shell = True) using the subprocess module.","Q_Score":0,"Tags":"python,command-prompt,os.system","A_Id":62046148,"CreationDate":"2020-05-27T14:44:00.000","Title":"Why does running \"os.system('cmd')\" do nothing in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"[On a mac] \nI know I can get packages doing pip install etc.\nBut I'm not entirely sure how all this works.\nDoes it matter which folder my terminal is in when I write this command? \nWhat happens if I write it in a specific folder?\nDoes it matter if I do pip\/pip3?\nI'm doing a project, which had a requirements file. \nSo I went to the folder the requirements txt was in and did pip install requirements, but there was a specific tensorflow version, which only works for python 3.7. So I did \"\"\"python3.7 -m pip install requirements\"\"\" and it worked (i'm not sure why). Then I got jupyter with brew and ran a notebook which used one of the modules in the requirements file, but it says there is no such module. \nI suspect packages are linked to specific versions of python and I need to be running that version of python with my notebook, but I'm really not sure how. Is there some better way to be setting up my environment than just blindley pip installing stuff in random folders? \nI'm sorry if this is not a well formed question, I will fix it if you let me know how.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":62046717,"Users Score":0,"Answer":"There may be a difference between pip and pip3, depending on what you have installed on your system.  pip is likely the pip used for python2 while pip3 is used for python3.  \nThe easiest way to tell is to simply  execute python and see what version starts.  python will run typically run the older version 2.x python and python3 is required to run python version 3.x.  If you install into the python2 environment (using pip install or python -m pip install the libraries will be available to the python version that runs when you execute python.  To install them into a python3 environment, use pip3 or python3 -m pip install.\nBasically, pip is writing module components into a library path, where import <module> can find them.  To do this for ALL users, use python3 or pip3 from the command line.  To test it out, or use it on an individual basis, use a virtual environment as @Abhishek Verma said.","Q_Score":0,"Tags":"python,installation,package,environment","A_Id":62046995,"CreationDate":"2020-05-27T15:21:00.000","Title":"How do modules installation work in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background: I'm using the gmaps package in Jupyter Python notebook. I have 2 points A (which is a marker) and B (which is a symbol) which is connected by a line.\nQuestion: I want to somehow display text on this line that represents the distance between A and B. I have already calculated the distance between A and B but cannot display the text on the map. Is there any way to display text on the line?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":62047816,"Users Score":0,"Answer":"I found that gmaps doesn't have this feature so I switched to folium package which has labels and popups to display text on hover and clicking the line.","Q_Score":0,"Tags":"python,google-maps,jupyter-notebook","A_Id":62392609,"CreationDate":"2020-05-27T16:15:00.000","Title":"How to display text on gmaps in Jupyter Python Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently uploaded my Django App to the server (Digital Ocean). The functionality is okay as in my local project on my computer, but the design (css style) of the Admin Interface has changed drastically in a lot of elements of the change_list and change_form templates. I\u2018ve checked and made sure that the templates of my local Django and Suit files are the same as they of the server, but it is still not the same design. \nDoes anyone has experience with that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":62049475,"Users Score":1,"Answer":"In deployment server just collect your static files from static folder by running command python manage.py collectstatic which will create a staticfiles folder in your Main project app in the project directory. May be this will help. Try it out.","Q_Score":0,"Tags":"python,css,django","A_Id":62049550,"CreationDate":"2020-05-27T17:40:00.000","Title":"Python Django App Design change on deploy to server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am currently learning nltk in Python where I am writing a program for sentiment analysis. While working on it, I found out that \"not, nor, never\" are considered stopping words. So my question is why that is because these kinds of words can change the entire meaning of sentences and could lead to failure in sentiment analysis.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":278,"Q_Id":62051187,"Users Score":0,"Answer":"Stop words are usually created based on analysis of the most common words in the language (that is the main reason \"not\" is in there). The idea behind them is to allow analysis (normally a bag of words approach) to focus on the more interesting words of the document.\nThey are used for multiple purposes: they were not designed specifically for sentiment analysis. That is another reason \"not\" is in there.\nA bag-of-words approach to sentiment analysis is always going to end up a bit crude, with or without stop words. E.g. It is not hard to create realistic-sounding positive movie reviews using negative words:\n\"This movie was not at all what I expected: I usually hate Tom Cruise but he made this movie work.\"\n\"I never watch chick-flicks, but as they say, never say never.\"\nAnyway try customizing your stopword list, removing \"not\" and \"never\" to see if it improves results. Then try again using no stopwords at all.","Q_Score":1,"Tags":"python,nltk,sentiment-analysis,stop-words","A_Id":62081378,"CreationDate":"2020-05-27T19:19:00.000","Title":"Why in NLTK \"not\" is considered as stopping word in English?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to apply spelling correction to some tweets. \nI have tried the following code: \ntrain.text.apply(lambda x: \" \".join([TextBlob(i).correct() for i in x.split()]))\nHowever, I get an error. Could you please advise? Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":445,"Q_Id":62051560,"Users Score":0,"Answer":"Could you try to update this code with \ntrain.apply(lambda x: \" \".join([TextBlob(i).correct() for i in x['text'].split()]))\nHope this helps!!","Q_Score":0,"Tags":"python,nlp,textblob,spelling","A_Id":62070191,"CreationDate":"2020-05-27T19:42:00.000","Title":"How to use TextBlob.correct() for a column in a dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe with 3,000,000 IDs. Each ID has the month range from 2015-01-01 \nt0 2018-12-01. Each ID has column \"A\" and \"B\" with numeric values. I need to create a new column \"C:. \nFor each ID, when Date == '2015-01-01' which is the first month for that ID, column C value equal to exp(column_A value).\n For the next month (Date == '2015-02-01'), column C value equal to exp(log(column_C_value in previous month) + column_B_value at this month), so here is exp(log(column C @ 2015-01-01) + column_B @ 2015-02-01). Each of the following months has the same pattern until it reaches 2018-12-01.\nIn Python, I can setup the loop for each ID and for each row\/month, such as:\nfor ID in range(xxx):\n    for month in range(xxxx):\nHowever, such calculation takes long time. Can anyone tell me a faster way to do this calculation? Very appreciated for your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":62052129,"Users Score":0,"Answer":"Consider that\n(1) exp(x+y) == exp(x)*exp(y).\nAnd\n(2) exp(log(x)) == x.\nSo exp(log(c1) + b2) == c1 * exp(b2).\nThe next value simplifies to c1 * exp(b2) * exp(b3), and so on.\nThat means, you have to multiply all exp(b) values, which can be turned\ninto adding all(b)-s and then applying exp() to the result.\nAnd don't forget to multiply it with a1, the initial value.\na1 * exp(b2 * b3 * ...)","Q_Score":0,"Tags":"python-2.7,dataframe","A_Id":62088543,"CreationDate":"2020-05-27T20:16:00.000","Title":"How to forecast the column value based on its previous value in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python when using plotly and sklearn I installed both packages and checked that their locations were added to my system environment variables but I still get the error \"No module named 'plotly'\" and same for sklearn and I don't know what else to do. I would really appreciate any help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":173,"Q_Id":62052780,"Users Score":0,"Answer":"Are you sure you are operating within the virtual environment?\nTry pip list to show what is installed in this environment. If plotly and sklearn are not listed, you are either not operating within the virtual environment when executing the script or you haven't installed the modules within the virtualenv","Q_Score":0,"Tags":"python,scikit-learn,plotly","A_Id":62052876,"CreationDate":"2020-05-27T21:00:00.000","Title":"How do I fix Module not found error in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to calculate the ridge regression B coefficients through this formula in Python:\n(X^T * X + \u03bb*I)^(\u22121) + X^T * y\nwhere:\nX^T = X transposed\nX^(-1) = inverse matrix of X\nQuestion: What shape should the identity matrix (I) take? X.shape or y.shape?\nThank you for your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":62053996,"Users Score":0,"Answer":"I should be the shape of X'X, only then will matrix addition be permitted. X is generally of shape [n,m], where n is the number of instances (rows) and m is the number of features (columns). Therefore, X'X is of shape [m,m], which should be the shape of I. \nAlso note that often when we formulate X, we have a column for the bias terms. Meaning, you might have m features, but X will have m+1 columns, including the bias. \nHope this helps.","Q_Score":0,"Tags":"python,statistics,regression","A_Id":62054145,"CreationDate":"2020-05-27T22:36:00.000","Title":"Ridge Regression B Coefficients Calculation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While my Jupyter Notebook is running, the terminal shows that it is saving files periodically. How to run \"pip install\" using command lines in the terminal while the Jupyter Notebook is running? I believe I need to find a way to get back to the \"~ username $:,\" from which I can type commands. I tried 'cd\/' but it didn't seem to work. \nSo far I've been closing out of Anaconda, finishing \"pip install\", and getting back into Anaconda.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":101,"Q_Id":62054568,"Users Score":1,"Answer":"It sounds like you are using a unix-type system. In that case you can \n\nIn the jupyter notebook do !pip install <whatever package it is>\nIn the terminal window, type ^Z and then bg, then type your pip install command.\nOpen another terminal window, and do your pip install.","Q_Score":1,"Tags":"python,command-line,terminal,pip,jupyter-notebook","A_Id":62055055,"CreationDate":"2020-05-27T23:34:00.000","Title":"Using Terminal Command while Running Anaconda on Macbook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I know that there was py2exe in which once it is run the executable can be run on any windows platform without python Interpreter. But now it being discontinued what are my alternatives for a all windows platform executable with a python interpreter? \nI tried pyInstaller in Windows 10 x64 but when I opened it in Windows 7 x64, it should a lot of errors. Is downgrading my python to 3.3 and running py2exe a good idea? Even if I did will py2exe support win 7, 8 and 10 with both x64 and x32 bit ? \nI know this was answered before here but there are people giving different opinions and most of the questions were a bit old, where everyone is recommending py2exe for windows which was answered before it was discontinued.\n(A one directory converter is recommended for me than a single exe file)\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":62056558,"Users Score":0,"Answer":"Have you tried using cx_Freeze 5.0?\nIt was recommended by a couple of users around Stack overflow and supposedly the project supports python 3.5 and higher. Unfortunately, I myself cannot assure you that it will work, as I haven't tried using it myself. \nIt really depends on how complex your code is and how much py2exe unsupported elements it contains.\nIf it isn't an unsurmountable or very time consuming task, maybe you could adjust the code to be convertable with py2exe, because that way the converter often works just fine. I cannot guarantee you that it will work for sure, but converting simpler code worked for me every time.\nI hope this helps. Have a great time!","Q_Score":0,"Tags":"python,pyinstaller,py2exe,cx-freeze","A_Id":62058320,"CreationDate":"2020-05-28T03:31:00.000","Title":"Executable on a windows platform with python interpreter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I wrote a python application and it works fine on my private network.\nThe application uses requests package and constantly fetching data from Yahoo.finance.\nHowever when my computer is connected to my work network (either through VPN or where i am actually @work),\nThe application is not working.\nIs there a way to make it work?\nAsaf","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":680,"Q_Id":62059849,"Users Score":0,"Answer":"Look into the firewall settings, or company list over blocked URLs.\nIt could be that your work has blocked the Yahoo.finance domain or specific applications from having outbound traffic as well.\nYou might also have success with privilege escalation to admin user which could grant you wider access.\nCheck if you can ping Yahoo.finance from a terminal or simply open it manually from a few different browsers (Edge, Chrome, Firefox etc.).\nThen try to see if you from inside your Python application can fetch any URL with the request module, just to troubleshoot.","Q_Score":2,"Tags":"python,python-requests","A_Id":62059901,"CreationDate":"2020-05-28T08:04:00.000","Title":"python application is not working where i use vpn or @work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a little flask webserver with just one route. The connection is kept open and streams data to the client for as long as the client doesn't stop the connection. \nI'm using waitress multiple threads, so it doesn't block.\nNow the problem. After some time, the CPU usage goes up to 100%. In the meantime in got some weird requests to \/admin.php, but they are all getting a 404. On idle or with a few connections I don't even see python3 under $ top. \nWhy is that and what can I do?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":738,"Q_Id":62061456,"Users Score":0,"Answer":"100% usage is for 1 core of CPU as you are using Flask and waitress ( GIL issue) -- Single processing multi threading , and your process seems to be primarily non CPU based like high IO , as a result  you do not see the python process using the CPU but the queue is increasing and after substantial queue , while allocating the CPU , it starts doing a context switching of all the queued threads and reaches a deadlock race condition . I had a similar problem where I moved out to Gunicorn kind of wsgi server which is capable of running it on multiprocessor with the workers and worker classes","Q_Score":0,"Tags":"python,flask,waitress","A_Id":64219770,"CreationDate":"2020-05-28T09:35:00.000","Title":"Flask \/ Waitress server randomly going to 100% CPU usage after time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've been trying to break a given date range into date range each week, but couldn't find any effective way to do it.\nLet's say I have input: 05\/05\/2020 (Tues) - 04\/06\/2020, and the out put would be like\n('05\/05\/2020', '10\/05\/2020'),\n('11\/05\/2020', '17\/05\/2020'),\n....\nAny help would be appreciated, thank you so much^","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":62062595,"Users Score":0,"Answer":"you should start a loop from the first date and run it till you find the first Sunday. When you hit the first Sunday, You get your first week. After that just keep adding 7 days to get the next week. While adding 7 days check if next Sunday date is falling within the provided range. if it is going outside the range, set the last date of the provided range as the ending date of last week instead of Sunday.","Q_Score":1,"Tags":"python","A_Id":62063270,"CreationDate":"2020-05-28T10:33:00.000","Title":"Get date range of week from a given date range","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The documentation for the Python extension for VS Code says that it supports environment variables being set in a .env file.\nI've read the documentation and various reports on GitHub, but I have not found any clarity on a few things:\n\nDo .env files work with tasks? My experience says they don't.\nDo .env files work with the integrated terminal? My experience says they don't.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":62062695,"Users Score":1,"Answer":".env files are a construct of the Python extension and so do not work in places that VS Code directly controls (e.g. tasks and the terminal). A lot of people use them with the debugger.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":62091555,"CreationDate":"2020-05-28T10:38:00.000","Title":"Can Someone Please Clarify Where .env Files Work in VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to Python and I want to create an array which has 0.00 has first element, and then adds 0.01 for its next elements until the last one is less than or equal to a given number (in my case 0.55).\nIn Matlab the code for it would be (0: 0.01: 0.55)\nAnd the result would be: [0.00, 0.01, 0.02, ... , 0.55]\nNow of course I think it can be done really easily in Python with a loop, but I'm wondering if there is a direct way to achieve this with a NumPy function\nI tried arange but failed, maybe it's not the right one.\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":62063085,"Users Score":1,"Answer":"Like Milan mentioned, my first thought was to use np.arange(0, 0.55, 0.01) but I just ran it, and it only goes from 0 to 0.54, which made me think it was treating the ending point as exclusive. To that end, i bumped it up to np.arange(0, 0.56, 0.01), but then that returned everything up to 0.56. \nFrankly, i'm not sure why that's happening (maybe a bug?), so here's an alternative that achieves the same result using np.linspace()\nnp.linspace(0, 0.55, 56)","Q_Score":2,"Tags":"python,numpy","A_Id":62063720,"CreationDate":"2020-05-28T11:00:00.000","Title":"How to build this simple vector in NumPy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to add the pygame and PIL modules as files in my project. My goal is to not have to install them by typing pip install in the console prompt. So I'm looking for a way to physically add them in the project directory. Thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":62063092,"Users Score":0,"Answer":"I'm quite sure you don't really want to do this, since both the modules you listed have binary components specific to Python and OS version\/architecture. You'd have to ship all of them, for all versions you expect to run your project on.\nJust add instructions on how to install them, instead.","Q_Score":1,"Tags":"python,python-module","A_Id":62063150,"CreationDate":"2020-05-28T11:01:00.000","Title":"How to include a python module in our project directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've just built a function that is working fine on my laptop (Mac, but I'm working on a Windows virtual machine of the office laptop), but when I pass it to a colleague o'mine, it raises a ValueError:\n\"You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.concat\"\nThe line of the code that raises the error is a simple merge that on my laptop works perfectly:\ndf = pd.merge(df1, df2, on = \"x\", how = \"outer)\nThe input files are exactly the same (taken directly from the same remote folder).\nI totally don't know how to fix the problem, and I don't understand why on my laptop it works (even if I open a new script or I restart the kernel, so no stored variables around) and in the one of my colleague it doesn't.\nThanks for your help!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":62063460,"Users Score":0,"Answer":"my guess (a wild guess) is that the data from the 2 tab-separated CSV files (i.e., TSV files) is somehow converted using different locales on your computer and your colleague's computer.\nCheck if you have locale-dependent operations that could cause a number with the \"wrong\" decimal separator not to be recognized as a number.\nThis should not happen in pd.read_csv() because the decimal parameter has a well-defined default value of \".\".\nBut from an experience I had with timestamps in another context, one timestamp with a \"bad\" format can cause the whole column to be of the wrong type. So if just one number of just one of the two files, in the column you are merging on, has a decimal separator, and this decimal separator is only recognized as such on your machine, only on your machine the join will succeed (I'm supposing that pandas can join numeric columns even if they are of different type).","Q_Score":1,"Tags":"python,pandas,merge,valueerror","A_Id":62064583,"CreationDate":"2020-05-28T11:22:00.000","Title":"Python ValueError if running on different laptop","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have large CSV files that represent weather data for the US at hourly resolution for a 5-km grid. The data was saved for each day, so I concatenated them together for a yearly file. The ultimate goal is to compute daily, weekly and monthly averages of the variables (wind speed, temperature, precipitation, pressure, etc) by latitude and longitude. There are no column headers so I add column names to the file when I read it in. \nWhen I tried reading in with Pandas in Python, it failed because it did not fit into memory. I can read in with Dask, but then I can't find a way to add the dimensions to the Dask dataframe or convert to xarray and do the same.  Is there a way to read in these too-large for memory files, add the lat, lon, datetime dimensions, compute daily, weekly and monthly averages for each lat\/lon and output the file? Or, do I need to convert the csv to netCDF or similar before reading in?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":62063819,"Users Score":0,"Answer":"As far as I know, you cannot load a CSV into xarray without going through pandas. So, yes, you will need to change the file format in order to use xarray. You might also consider breaking your data up into smaller files.","Q_Score":0,"Tags":"python,csv,multidimensional-array,dask,dask-dataframe","A_Id":62132433,"CreationDate":"2020-05-28T11:42:00.000","Title":"How to read in large CSV files, add multidimensions, and convert hourly to daily?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm learning Django and have I problem, I don't even know what I should search for to solve it. So maybe someone knows what I need.\nSo far I have two models in my project\n\nCustomUserModel with additional data\n\nRunningTrackModel which provides information about tracks like distance, location, etc.\n\n\nMy goal is now to save user specific Data for each object of the RunnningTrackModel like time, date, etc.\nWhenever a new RunningTrackObject is created, all users should get the possibility to sign up and save data to tracks they signed up for, but whats the right way to implement this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":62064069,"Users Score":0,"Answer":"save each object into an individual table in a relational database like MySQL\nlink them using the user ID as a foreign key.","Q_Score":0,"Tags":"python,django","A_Id":62064415,"CreationDate":"2020-05-28T11:54:00.000","Title":"How to save data related to two models","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know this question was already asked, but this is special:\nI am using Windows and I am trying to allocate a 250000*200 Array (via numpy.random.normal) out of float64 variables. Those add up to 50000000 float64 variables, which (when they each take 4 Byte) need 200.000.000 Bytes, which are approx. 190 MB. \nI have 8GB RAM and always AT LEAST 2 GB RAM free and I still get the same error. AND I actually allocated 10GB RAM from my SSD, that means that I should have at least 12GB RAM free.\nUsing Windows 10 64bit","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1332,"Q_Id":62066438,"Users Score":0,"Answer":"I got it working! I had the 32 Bit Version of Python (I should be ashamed of me :D) and now I installed the 64 bit version and it works fine.\nTHANKS for everyone who had liked to help me though!","Q_Score":1,"Tags":"python,numpy,ram","A_Id":62066916,"CreationDate":"2020-05-28T13:53:00.000","Title":"Python\/Windows doesn't let numpy allocate RAM \"numpy.core._exceptions.MemoryError\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How is this range function working here? It is generating an answer but I can't understand it it has created the resulted ndarray. \nnp.array([range(i, i + 3) for i in [2, 4, 6]])","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":29,"Q_Id":62066606,"Users Score":1,"Answer":"A range is a sequence of numbers. The function range normally accepts 1-3 params range(start, stop[, step]). In your case the step is ommited, thus the default 1 is applied. So it is creating ranges from a given number i to that number +3 \u2192 range(i, i + 3)\nThe list comprehension, makes that the given number i will iterate over the list [2,4,6], so you will create a list with 3 sublists: [range(2,2+3), range(4,4+3), range(6,6+3)] wich equals to [[2,3,4], [4,5,6], [6,7,8]].\nFinally, all is wrapped as a numpy array and the output is \u2192 array([[2, 3, 4],[4, 5, 6],[6, 7, 8]])","Q_Score":1,"Tags":"python,numpy","A_Id":62066833,"CreationDate":"2020-05-28T14:01:00.000","Title":"how range functions works in creating ndarray?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use additional data to 'update' an already trained Light Gradient Boosting Model (LGBM). Is there a way to do that?\nI am looking for an approach that uses the Skealrn API and thus can be used in a pipeline.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":747,"Q_Id":62069508,"Users Score":2,"Answer":"An LGBM model in python can be fitted both with the original model API and with the Sklearn API.\nI couldn't find any examples of using the Sklearn API for continuous learning.\nRegardless of that, you can fit a model either way and it is compatible with the .train() function from the original API.\nIt can be saved with save_model() or with joblib.dump().\nThis does not affect its compatibility with Python Pileline() - it is perfectly compatible.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,lightgbm","A_Id":62082407,"CreationDate":"2020-05-28T16:16:00.000","Title":"Updating an LGBM model with new data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I started a script that sends me an email if a specific condition occours and its running from vps, but since I've not yet received any emails, I'm wondering if the script is still running. I also forgot the name of the \"xxxxxx.py\" file thats running. \nWhat can I do??","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":343,"Q_Id":62070280,"Users Score":0,"Answer":"If your VPS is linux-based with a ssh server listening, you should be able to connect to it, opening a terminal. After that You can try using the ps ax or top or htop command to display all processes running.\nYou can then use a pipe to filter out the word \"py\" :\nps ax | grep \"py\"","Q_Score":1,"Tags":"python,pandas,server,putty,vps","A_Id":62070408,"CreationDate":"2020-05-28T16:54:00.000","Title":"How to check if a script is still running in my 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":0,"Web Development":0},{"Question":"How can I make a flask session work across multiple instances of containers using Kubernetes? Or does Kubernetes always maintain the same container for a given session?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":162,"Q_Id":62070868,"Users Score":1,"Answer":"Default Flask sessions are stored client-side (in the browser) as a cookie and cryptographically signed to prevent tampering. Every request to your Flask application is accompanied by this cookie. Therefore, if all running containers have the same app (at least the same secret key used for signing), then they should all have access to the same session data.\nNote:\n\nThis is cryptographically signed, but it is not encrypted, so don't store sensitive information in the session\nFlask-Session can be installed for server-side session support","Q_Score":2,"Tags":"python,authentication,session,flask,kubernetes","A_Id":71044140,"CreationDate":"2020-05-28T17:28:00.000","Title":"Python Flask session for multiple instances","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python application that accesses Youtube-Data-API v3.\nAfter the program runs for an hour, it throws an error suggesting the access token has expired.\nHow can I persist the token for a longer period?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":361,"Q_Id":62071059,"Users Score":0,"Answer":"When you create O-Auth2 credentials, you need to select \"Web App\" which is what I think you're trying to create. (A website, correct?).\nThe \"Desktop-App\" option is for if you want to make a desktop application, not a website.\nDesktop applications and web applications handle redirect uris differently, which is what's causing your issue.","Q_Score":0,"Tags":"python,youtube-data-api,refresh-token","A_Id":62071124,"CreationDate":"2020-05-28T17:39:00.000","Title":"Persist Youtube Data API access token in Python desktop app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script set to go off every minute in my crontab file:\n*\/1 * * * * ~\/ticker.py\nI've set permissions of ticker.py with chmod +x ticker.py to make the file executable.\nI am still getting \/bin\/sh: \/home\/ec2-user\/ticker.py: Permission denied in my \/var\/spool\/mail\/ec2-user mail file.\nI'm using an Amazon Linux EC2 instance. I appreciate any help with this. Thank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":424,"Q_Id":62071214,"Users Score":0,"Answer":"Found out the fix. Super simple but unsure why the #!\/usr\/bin\/env shebang didn't fix it in the first place.\nI replaced *\/1 * * * * ~\/ticker.py with *\/1 * * * * python ~\/ticker.py.\nThanks for the input.","Q_Score":0,"Tags":"python,unix,cron","A_Id":62075429,"CreationDate":"2020-05-28T17:47:00.000","Title":"Getting crontab \"permission denied\" on Python script even though it has executable 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":"I am working on a web app in which some content is generated in the form of text (and will soon include images as well). I want to add a share button which will allow the user to add this content to their Instagram story. \nSo the flow of this is going to be:\n\n\nUser does something on the website\nThe website generates some content based on user input\nUser clicks on \"Share on Instagram\" and posts it on his\/her story \n\n\nIs there a way to do this using Javascript or an API call like the Twitter share option directly from the HTML ?\nI am using Python on the backend (Flask) and JS on the frontend","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":7688,"Q_Id":62071327,"Users Score":10,"Answer":"OK, lets make this simple.\nThe direct answer as found on the official Facebook developers page is no. You can't trigger an API to create an instagram story, as for now only the \"read-mode\" is supported through API.\nBut as most things in life you can hack your way arround. Let's then copy a funcional method.\nYou create a button that says, \"share on your instagram stories\" and here's what it is gonna do:\n\nTrigger a function on the back-end that creates a screenshot\/image or a video of the content you want to share\nSend that content to the user so it's the last content they have in the gallery\nTrigger the open story camera in Instagram app with this link: instagram:\/\/story-camera. (the last content they have will be the content u sent and will be the first thing they see for posting a story)\n\nIt goes without saying that this will work when the website is opened in a phone and not in a desktop browser as in desktop you can't post stories.\nPS: I'm sure there is a way to send that content directly to the editing in the stories, so you don't have to select the image you sent to the client, but I didn't figure that out yet. Hope this works for you, cheers.","Q_Score":8,"Tags":"javascript,python,html,api,instagram","A_Id":65893635,"CreationDate":"2020-05-28T17:53:00.000","Title":"Share content of a webpage to Instagram story","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 visualize XGBoost's effects and I want to extract a single tree from it that has the highest accuracy on the test set. Is is built in in any way, or do I have to test by hand all of the trees? I'm using the Python version.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":62071417,"Users Score":0,"Answer":"If you'd like to inspect individual trees in a tree ensemble model, then you should consider switching from a boosting-type algorithm (eg. XGBoost, LightGBM, GBM) to a bagging-type algorithm (eg. Random Forest).\nBy definition, the bagging algorithm grows trees in decreasing \"smartness\" order. In this case, the highest accuracy tree model is probably the first one in the XGBoost tree ensemble.","Q_Score":0,"Tags":"python,decision-tree,xgboost","A_Id":62078974,"CreationDate":"2020-05-28T17:58:00.000","Title":"XGBoost - select tree with the highest accuracy","Data Science and Machine Learning":0,"Database and SQL":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":"On Linux Ubuntu with python 3.6.9\nWhen i try to download pip, it says i already have it. So when i try to pip install ... it gives me error \"bash: pip: command not found\".\nWhen i type \"which pip\" in the terminal it gives me nothing and creates a new line.\n(While also it doesn't work in the normal terminal) I should also say I'm trying to do this in a virualenv. It gives the same errors when  trying to install pip (I already have it) and when trying to use pip (\"bash: pip: command not found\")\necho $PATH output: \/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:\/usr\/games:\/usr\/local\/games:\/snap\/bin\nsorry if this doesn't make sense, kinda a noob","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2276,"Q_Id":62071515,"Users Score":1,"Answer":"Try the following:\n\npython -m pip install ....\npython3 -m pip install ....\npy3 -m pip install ....\n\nAs @S3DEV commented, there could be a problem with your path variables, so trying python before pip could solve. Those other variations (python3 and py) can also work.","Q_Score":2,"Tags":"python,bash,pip","A_Id":62071716,"CreationDate":"2020-05-28T18:03:00.000","Title":"\"bash: pip: command not found\" when using \"pip install ...\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm in Win10 and use vanilla Python 3.7.3 (e.g. not conda or anything). I had a successful pip install for the package, the package shows up in pip freeze, and the package is supposed to be compatible with my version of Python. I've seen several threads with similar issues on OS X and Linux, and have tried to emulate their solutions on Windows, but no luck. I'm guessing it could be an issue with my PATH variable, but I'm not quite sure. The error I get when trying to import is the \"No module named\" error.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1605,"Q_Id":62072938,"Users Score":0,"Answer":"Went into site-packages...for some reason the module was named Bio there (everywhere else it's named biopython, again, including pip freeze) and importing that worked. Not sure if this was just a bad dev choice or what.","Q_Score":2,"Tags":"python,windows,pip,python-3.7","A_Id":62073212,"CreationDate":"2020-05-28T19:24:00.000","Title":"Python module shows up in pip freeze, but cannot be imported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training a CNN model that has to classify 4 objects. 3 mugs (white, black, blue) and 1 glass. When I train my model for only 10 epochs, I get a validation accuracy of 25%, where everything is being labeled as the white mug. However when I would train the same model for longer, it eventually diverts from this 25% accuracy and climbs up to 80%, the only problem it has, is classifying the white mug.\nIn other words, if I am able to find why my classifier classifies the white mug wrongly, then I could potentially reach validation_accuracy of 90%. My question thus is, what are some things I could try to find out why it mispredicts, or things to improve. I have already used LIME to check why my model classifies something, but I could not get any wiser from it.\nSome specs of the model:\n\nNo data augmentation\n5 convolutional layers (32, 64, 128, 256, 512) -> into GlobalMaxPooling, Flatten, and 2 dense layers (128, 4)\nActivation layers (relu)\n2000 training images, 1000 validation images (classes are balanced)\n\nExtra: The model gets 100% accuracy on the training data after 2 epochs, and slowly climbs up to 80% on the validation data (after about 40-50 epochs).\nExtra 2: Sometimes the model gets 80%, sometimes only 74%","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":62073259,"Users Score":0,"Answer":"There could be multiple issues here. It looks like your network is overfitting, so first off you may want to add regularization or dropout to your training process. Secondly, you'll also want to make sure your images come from the same source, i.e. if your training\/test examples all come from Google images or have vastly different qualities, angles, colors, etc, this might harm the network's ability to classify the mug correctly.\nFinally, you might want to add a softmax layer at the end of your network since you're doing a multiclass classification. By doing this, you'll be able to see what the probability is for the white mug compared to the other objects, which can help you with debugging.","Q_Score":1,"Tags":"python,tensorflow,machine-learning,keras","A_Id":62074878,"CreationDate":"2020-05-28T19:44:00.000","Title":"How should I interpret or intuitively explain the following results for my CNN model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training a CNN model that has to classify 4 objects. 3 mugs (white, black, blue) and 1 glass. When I train my model for only 10 epochs, I get a validation accuracy of 25%, where everything is being labeled as the white mug. However when I would train the same model for longer, it eventually diverts from this 25% accuracy and climbs up to 80%, the only problem it has, is classifying the white mug.\nIn other words, if I am able to find why my classifier classifies the white mug wrongly, then I could potentially reach validation_accuracy of 90%. My question thus is, what are some things I could try to find out why it mispredicts, or things to improve. I have already used LIME to check why my model classifies something, but I could not get any wiser from it.\nSome specs of the model:\n\nNo data augmentation\n5 convolutional layers (32, 64, 128, 256, 512) -> into GlobalMaxPooling, Flatten, and 2 dense layers (128, 4)\nActivation layers (relu)\n2000 training images, 1000 validation images (classes are balanced)\n\nExtra: The model gets 100% accuracy on the training data after 2 epochs, and slowly climbs up to 80% on the validation data (after about 40-50 epochs).\nExtra 2: Sometimes the model gets 80%, sometimes only 74%","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":62073259,"Users Score":0,"Answer":"The model is reaching 100% training accuracy when validation accuracy is still only 25%. A 75% gap between training and validation accuracy is enormous and indicates the model is overfitting to the training data, likely due to the small size of the training data set (2000). Data augmentation would likely significantly reduce overfitting and improve validation accuracy - I would start with random cropping, brightness, and saturation. Collecting more training data with varied backgrounds, orientations, and lighting conditions would also help.","Q_Score":1,"Tags":"python,tensorflow,machine-learning,keras","A_Id":62074782,"CreationDate":"2020-05-28T19:44:00.000","Title":"How should I interpret or intuitively explain the following results for my CNN model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have one terraform instance and script which could create infra in azure. We would like to use same scripts to create\/update\/destroy isolated infra for each one of our customers on azure . We have achieved this by assigning one workspace for each client,different var files and using backend remote state files on azure.\nOur intend is to create a wrapper python program that could create multiple threads and trigger terraform apply in parallel for all workspaces. This seems to be not working as terraform runs for one workspace at a time. \nAny suggestions\/advice on how we can achieve parallel execution of terraform apply for different workspaces?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":2124,"Q_Id":62073438,"Users Score":3,"Answer":"It's safe to run multiple Terraform processes concurrently as long as:\n\nThey all have totally distinct backend configurations, both in terms of state storage and in terms of lock configuration. (If they have overlapping lock configuration then they'll mutex each other, effectively serializing the operations in spite of you running multiple copies.)\nThey work with an entirely disjoint set of remote objects, including those represented by both managed resources (resource blocks) and data resources (data blocks).\n\nMost remote APIs do not support any sort of transaction or mutex concept directly themselves, so Terraform cannot generally offer fine-grained mutual exclusion for individual objects. However, multiple runs that work with entirely separate remote objects will not interact with one another.\nRemoving a workspace (using terraform workspace delete) concurrently with an operation against that workspace will cause undefined behavior, because it is likely to delete the very objects Terraform is using to track the operation.\nThere is no built-in Terraform command for running multiple operations concurrently, so to do so will require custom automation that wraps Terraform.","Q_Score":5,"Tags":"python,azure,terraform,terraform0.12+","A_Id":62076451,"CreationDate":"2020-05-28T19:55:00.000","Title":"Can terraform run \"apply\" for multiple infrastructure\/workspace in parallel?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am wondering how can you get device connection string from IotHub using python in azure? any ideas? the device object produced by IoTHubRegisterManager.Create_device_with_sas(...) doesn't seem to contain the property connection string.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":342,"Q_Id":62074126,"Users Score":0,"Answer":"You can get a device connection string from the device registry. However, it is not recommended that you do that on a device. The reason being is that you will need the IoT hub connection string to authenticate with your hub so that you can read the device registry. If your device is doing that and it is compromised then the perpetrator now has your IoT hub connection string and could cause all kinds of mayhem. You should specifically provide each device instance with its connection string. \nAlternatively, you could research the Azure DPS service which will provide you with device authentication details in a secure manner.","Q_Score":0,"Tags":"python-3.x,azure,azure-iot-hub","A_Id":62141138,"CreationDate":"2020-05-28T20:40:00.000","Title":"How do you request device connection string in azure using python and iotHub library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I installed numpy package in PyCharm, following the default way: File->Settings->Project Interpreter->Click on '+' sign->Type numpy in the search baar->Install. Now, when I am working on a new project and trying to import numpy, it says: \"ModuleNotFoundError: No module named 'numpy'\". Please help! Thanks in advance :)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":621,"Q_Id":62076934,"Users Score":0,"Answer":"Depends. Your first numpy module likely installed in a virtual environment. Therefore, unless you specify that same virtual environment for your new project, your new project will be unable to access a module installed in a virtual environment it doesn't use.","Q_Score":1,"Tags":"python,numpy,module,pycharm,package","A_Id":62077208,"CreationDate":"2020-05-29T00:54:00.000","Title":"Do I have to install numpy in PyCharm everytime I create a new project? (install and not import)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed numpy package in PyCharm, following the default way: File->Settings->Project Interpreter->Click on '+' sign->Type numpy in the search baar->Install. Now, when I am working on a new project and trying to import numpy, it says: \"ModuleNotFoundError: No module named 'numpy'\". Please help! Thanks in advance :)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":621,"Q_Id":62076934,"Users Score":0,"Answer":"I wasn't able to find support for this feature in PyCharm or in any of the available plugins, but if you're not worried about keeping different dependencies isolated, you do have the option of using the same environment for all your projects.","Q_Score":1,"Tags":"python,numpy,module,pycharm,package","A_Id":62077909,"CreationDate":"2020-05-29T00:54:00.000","Title":"Do I have to install numpy in PyCharm everytime I create a new project? (install and not import)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a small Python project site where a visitor can practice writing SQL code.  This code actually runs and returns values.  I know that I need to prevent SQL injection, but I'm not sure the best approach since the purpose of the site is that users should be able to write and execute  arbitrary SQL code against a real database. \nWhat should I look to do to prevent malicious behavior?  I want to prevent statements such as DROP xyz;, but users should still be able to execute code.  I think maybe the ideal solution is that users can only \"read\" from the database, ie. they can only run SELECT statements (or variations).  But I'm not sure if \"read only\" captures all edge cases of malicious behavior.\n\nNeed to prevent malicious SQL querying, but also need to allow users to execute code\nUsing SQLite now but will probably move to postgres\nI'm strictly using SQL at this point but may want to add Python and other languages in the future\nThe site is built with Python (Flask) \n\nAny ideas or suggestions would be helpful","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":62077249,"Users Score":1,"Answer":"There is no way to prevent SQL injection for a site that takes SQL statements as user input and runs them verbatim. The purpose of the site is SQL injection. The only way you can prevent SQL injection is to not develop this site.\nIf you do develop the site, how can you prevent malicious SQL? Answer: don't let malicious users have access to this site. Only allow trusted users to use it.\nOkay, I assume you do want to develop the site and you do want to allow all users, without doing a lot of work to screen them.\nThen it becomes a task of limiting the potential damage they can do. Restrict their privileges carefully, so they only have access to create objects and run queries in a specific schema.\nOr better yet, launch a Docker container for each individual to have their own private database instance, and restrict the CPU and memory the container can use.","Q_Score":1,"Tags":"python,flask,sqlalchemy,sql-injection","A_Id":62090109,"CreationDate":"2020-05-29T01:34:00.000","Title":"Preventing SQL Injection for online SQL querying","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why does the code below return the error \"SyntaxError: invalid syntax\"\nIf(amount_paid==12):\nI know it's basic but just starting out learning Python in Visual Studio Code\nThanks for any help,\nPhil","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":48,"Q_Id":62077530,"Users Score":4,"Answer":"Most things in Python are case-sensitive. Here, that's the if construct -- If amount_paid == 12: is not well formed, but if amount_paid == 12: is.","Q_Score":0,"Tags":"python","A_Id":62077545,"CreationDate":"2020-05-29T02:05:00.000","Title":"Python invalid syntax questions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why does the code below return the error \"SyntaxError: invalid syntax\"\nIf(amount_paid==12):\nI know it's basic but just starting out learning Python in Visual Studio Code\nThanks for any help,\nPhil","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":62077530,"Users Score":0,"Answer":"Try making If lowercase (make the \"I\" lowercase)","Q_Score":0,"Tags":"python","A_Id":62077551,"CreationDate":"2020-05-29T02:05:00.000","Title":"Python invalid syntax questions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why does the code below return the error \"SyntaxError: invalid syntax\"\nIf(amount_paid==12):\nI know it's basic but just starting out learning Python in Visual Studio Code\nThanks for any help,\nPhil","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":62077530,"Users Score":0,"Answer":"The issue in the upper case \"If\". Change to \"if\"\nParentheses are not mandatory, although, they should not affect anything in your case: if amount_paid == 12:","Q_Score":0,"Tags":"python","A_Id":62077676,"CreationDate":"2020-05-29T02:05:00.000","Title":"Python invalid syntax questions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have had scores of servers running a Python script via Apache and mod_wsgi for years now. I recently am building on RHEL7 and have run into an issue where my Python script calling R procedures are bombing out only via Apache stating it cannot find my pip installed Python modules in my Apache log.\nimport pandas as pd\nModuleNotFoundError: No module named 'pandas'\nThis seems to only affect modules getting installed in \/usr\/local\/lib64\/python3.6\/site-packages which is where my custom modules are being installed with pip.\nEven if I append it, it ignores it.\nsys.path.append(r'\/usr\/local\/lib64\/python3.6\/site-packages')\nI manually built mod_wsgi from source.\nI'm ready to abandon mod_wsgi because I have to get my application deployed for my users.\nAny help is greatly appreciated.\nThanks,\nLou","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":169,"Q_Id":62078449,"Users Score":0,"Answer":"It was a file priv issue with \/usr\/lib64\/python3.6 and \/usr\/lib\/python3.6 directories and their child directories. Root ran fine, but running as Apache had no access. You had to chmod-R 755 on both directory trees. Worked fine with Apache after that. Sometimes it\u2019s the simple things we forget to check first.","Q_Score":0,"Tags":"python,python-3.x,apache,mod-wsgi","A_Id":62274064,"CreationDate":"2020-05-29T03:56:00.000","Title":"Running Python in mod_wsgi in Apache Cannot See Python Modules in \/usr\/local\/lib64\/python3.6\/site-packages","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 query string that will return data successfully if I run it in Postman but if I pull the data via Python3 (http.client.HTTPSConnection), the target returns 'bad request'.\nThe problem:\n\/v4_6_release\/apis\/3.0\/service\/tickets?customFieldConditions=caption=\"Escalated To\" AND value =\"Cloud Operations\"\nI have tried putting +AND+ or %20and%20 or %20AND%20 instead of AND but no success. For example:\n\/v4_6_release\/apis\/3.0\/service\/tickets?customFieldConditions=caption=\"Escalated To\"%20AND%20value=\"Cloud Operations\"\n^ This works fine in postman but returns <hr><p>HTTP Error 400. The request is badly formed.<\/p> when via Python3. \nIs there anything else wrong with the url encoding here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":62079936,"Users Score":1,"Answer":"You have to encode all whitespaces in you URL. So the URL should be \/v4_6_release\/apis\/3.0\/service\/tickets?customFieldConditions=caption=\"Escalated%20To\"%20AND%20value=\"Cloud%20Operations\"","Q_Score":0,"Tags":"python,python-3.x","A_Id":62080734,"CreationDate":"2020-05-29T06:30:00.000","Title":"Issue with URL encoding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use pyinstaller or cx_Freeze whenever I want my Python file to convert it into a .exe package, but the problem is, my PC is 64-bit, and if I make that application, it only runs on a 64-bit PC, that's why I want to know, is there a way to develop 32-bit applications on a 64-bit PC using any module or anything? Please I really need an answer!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1726,"Q_Id":62080861,"Users Score":3,"Answer":"Download, install a 32-bit version of python and use that instead of the 64 bit python that you are using.","Q_Score":0,"Tags":"python,pygame,32bit-64bit","A_Id":62081307,"CreationDate":"2020-05-29T07:31:00.000","Title":"How to make 32-bit applications in Python in a 64-bit PC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The default start of the weekday is Monday (0) in Pandas. Am trying to make this as Sunday instead on datetimeindex for getting weekly counts ending on Saturday to forecast a timeseries model.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":276,"Q_Id":62081229,"Users Score":0,"Answer":"I got a breakthrough, yes.\nFrom my previous code, I redefined W-SAT instead of the default W.\nPrevious code:\nweekreq = daysreq.resample('W').apply({'Numbers':'sum'})\nto \nNew code: \nweekreq = daysreq.resample('W-SAT').apply({'Numbers':'sum'})","Q_Score":0,"Tags":"python-3.x,pandas,time-series,weekday","A_Id":62098954,"CreationDate":"2020-05-29T07:56:00.000","Title":"Change start of weekday from monday to sunday in datetimeindex in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My goal is to evaluate model performance on test dataset for object detection task. Model was trained on dataset with 6 classes with Tensorflow Object Detection API. For some class there are 20 samples of objects and for some it can be only one sample. So data is imbalanced for both train and test sets. \nCan I use mean average precision (mAP) as metrics for evaluation?\nIt seems to me that it is not correct to use it for imbalanced data. Therefore I don't know which other metrics to use. So what kind of metrics is suitable for this case?\nI would appreciate any help on this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":408,"Q_Id":62081792,"Users Score":0,"Answer":"Mean average precision will still work. As you can see, it is mean average precision, so, since precision will be averaged over all classes their number won't matter.","Q_Score":0,"Tags":"python,tensorflow,object-detection,object-detection-api","A_Id":62081931,"CreationDate":"2020-05-29T08:30:00.000","Title":"Mean average precision metrics for evaluation multilabel object detection model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am more experienced in Java and Maven and a real beginner in Python, so I don't really have an idea about what possible to do and what not.\nIn Java, using Maven we can manage dependencies versions in a file (a pom parent \/ the aggregator module), then re-declare in pom.xml of the sub-modules the necessary dependencies while omitting their version being managed by the pom parent. This way, we can distribute the sub-modules physically separately (Ex: every module in a machine) and every module would package only its required dependencies, the libraries that are defined in its own pom file.\nNow back to Python, currently I use a setup.py file which, to my understanding, should be in the root module. But then it packages the whole modules as one library.\nIs there a way to manage better the modules and their dependencies and be able to deploy every (chosen) module separately as an independent package with its own needed libraires? I want to be able to choose the modules to package separately, I don't want that every folder containing __init__.py to be packaged seprately.\nCurrently I use Pipenv to manage my dependencies, but I am ready to drop it if it doesn't satisfy the design I have explained above.\nThank you","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":633,"Q_Id":62081927,"Users Score":1,"Answer":"There is nothing that does exactly what you want (as far as I know, at least). In python the way we manage dependencies of a project or a library is using requirements.txt and virtual environments. Both of which manages the dependencies of the project as a whole. \nTo separate the individual modules out of the project you'd treat them as separate projects and do what every project would need. Make the requirements.txt or if you need to install it using setup.py put them inside that.\nSo, for every 'sub-library' you want to 'separate' make a different requirements.txt or setup.py. \nThere's this library called pipreqs (and possibly others) which scans a folder and generates the requirements file automatically. I'd always recommend hand-crafting the requirements file right after you install any library.","Q_Score":4,"Tags":"java,python,maven,packaging,pipenv","A_Id":62465155,"CreationDate":"2020-05-29T08:39:00.000","Title":"How to do in order to package python modules separately when organized in the same project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I know that there are ways to convert web site to mobile application using directories and platforms, but it seems like all the examples were on JavaScript. Does it also work with python flask web application?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":465,"Q_Id":62082499,"Users Score":0,"Answer":"You won\u2019t be able to convert python django application into a native mobile application.\nFor web application, both the client side and server side code is rendered through web browser. For mobile, client side code sits in native inside the mobile and all the dynamic stuff gets loaded from server through http\/https. Python django app is generally written in MVT format, UI is closely tied with server side backend code.\nTo convert your present app into mobile app requires:\nImplement django rest framework to write rest apis\nA native mobile app which can consume those apis (this is full mobile app development)\nWorkarounds:\nThere is a way where you write a small mobile app which loads your website. This can be done but only requirement is your site needs to be responsive UI and compatible on mobile browser","Q_Score":0,"Tags":"python,web,flask,mobile","A_Id":62082870,"CreationDate":"2020-05-29T09:15:00.000","Title":"Is there way to convert web application in python flask to mobile?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on an image processing \/ computer vision \/ deep learning app which requires the use of old versions for some Python packages.\nI am new to the world of machine learning and software,it's been 6 months that I made a career change and I am not aware of the best practices when it comes to python projects that work for different platforms (Windows, Linux, MacOS).\nSo today, I am working on a linux, I did some conda installs and some pip installs and I am exporting my environment to a .yml file. How to make sure that creating a virtual environment on a Windows Machine using conda and my exported .yml file is going to work with no problems ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":385,"Q_Id":62082610,"Users Score":0,"Answer":"You just have to make sure your .yml file doesn't include platform dependent packages by adding the --from-history flag when creating the file. This exports only packages you intentionally installed. \nOn Windows conda will take care of the virtual environment by installing dependencies for the specified packages in the .yml file that are Windows compatible.","Q_Score":1,"Tags":"python,windows,anaconda","A_Id":62084338,"CreationDate":"2020-05-29T09:21:00.000","Title":"Conda environment from linux to windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I remove access to a Jupyter Notebook server to previous users? I did a quick setup of a Jupyter Notebook server and provided access to a few users. Now that it's no longer needed, how can I force the authentication cookies to expire and reset the authentication token?\nI think I should have used JupyterHub, but I didn't know about it then.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":640,"Q_Id":62083088,"Users Score":-1,"Answer":"Stop the server, run jupyter notebook password and set\/change your password.","Q_Score":1,"Tags":"python,jupyter-notebook,jupyter","A_Id":62083475,"CreationDate":"2020-05-29T09:46:00.000","Title":"Jupyter Notebook: Force cookie expiration and reset token","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently installed webdriver-manager 2.5.2 to work with chromedriver for selenium in python. It was working fine, but now suddenly i am getting the below error-\nPermissionError: [Errno 13] Permission denied: 'C:\\Users\\mrudu\\.wdm\\drivers\\chromedriver\\83.0.4103.39\\win32\\chromedriver.exe'\nHow to resolve this issue? I am new to programming so not sure how the permissions work in windows 10 and Pycharm.\nPlease help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1678,"Q_Id":62084879,"Users Score":0,"Answer":"It worked when i did this-\nThere is some process that is holding this driver. Close all Chrome drivers, and try to find all processes with name chromedriver.exe.\nSolution provided by SergeyPirogov github owner for webdriver-manager","Q_Score":1,"Tags":"python,selenium,selenium-webdriver,permissions,webdriver-manager","A_Id":62086147,"CreationDate":"2020-05-29T11:27:00.000","Title":"PermissionError: [Errno 13] Permission denied to access selenium python through webdriver-manager","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ok, so I decided to use selenium for some code, but it doesn't work. When I put the chromedriver in my path, manually, it still doesn't work. can anyone help. PS: I already pip installed selenium.\nAlso, I watch\/read the other article on stack overflow about this problem, but it didn't help me.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":325,"Q_Id":62086554,"Users Score":0,"Answer":"If you put chromedriver in the home directory of the user running it, that should work.  Would be helpful if you stated in your question what OS\/version you are using.","Q_Score":1,"Tags":"python","A_Id":62086589,"CreationDate":"2020-05-29T12:55:00.000","Title":"Message: 'chromedriver.exe' executable needs to be in PATH. Please see https:\/\/sites.google.com\/a\/chromium.org\/chromedriver\/home","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a small webpage that uses geospacial data. I did my initial analysis in Python using GeoPandas and Shapely and I am attempting to build a webpage from this. The problem is, when using Django, I can't seem to find a way to keep the shape file stored as a constant object. Each time a request is made to do operations on the shapefile, I need to load the data from source. This takes something like 6 seconds while a standard dataframe deep copy df.copy() would take fractions of a second. Is there a way I can store a dataframe in Django that can be accessed and deep copied by the views without re-reading the shapefile?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":327,"Q_Id":62087354,"Users Score":0,"Answer":"Due to the nature of Django, global variables to not really work that well. I solved this problem in two different ways. The first was to just use django sessions. This way, the object you wanted to store globally now only needs to be loaded once per session on your website. Second and more efficient option is to use a cache server, either Redis or memcached. This will allow you to store and get your objects very quickly across all of your sessions and will increase performance the most.","Q_Score":0,"Tags":"python,django,geopandas,shapely","A_Id":62291698,"CreationDate":"2020-05-29T13:41:00.000","Title":"Can you store a constant global object in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I had similar problems with pip that was fixed with \"python3 -m\" but now after install Django I want to make a new project.\nWhen I try to run \"django-admin startproject ...\" I get \"bash: django-admin: command not found\".\nI don't know if I should mention it but, this is in a virtualenv.\npython3 -m pip freeze: Django==3.0.6\necho $PATH: \/home\/alatimer\/Environments\/DjangoTutoria_env\/bin:\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:\/usr\/games:\/usr\/local\/games:\/snap\/bin","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":411,"Q_Id":62087513,"Users Score":0,"Answer":"My problem was i was using python version 2.7 in the venv instead of version 3.6.9.\nI assume the older python couldn't recognize the commands (this even includes pip commands).","Q_Score":0,"Tags":"python,django,bash","A_Id":62093778,"CreationDate":"2020-05-29T13:50:00.000","Title":"\"bash: django-admin: command not found\" after running django-admin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I had similar problems with pip that was fixed with \"python3 -m\" but now after install Django I want to make a new project.\nWhen I try to run \"django-admin startproject ...\" I get \"bash: django-admin: command not found\".\nI don't know if I should mention it but, this is in a virtualenv.\npython3 -m pip freeze: Django==3.0.6\necho $PATH: \/home\/alatimer\/Environments\/DjangoTutoria_env\/bin:\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:\/usr\/games:\/usr\/local\/games:\/snap\/bin","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":411,"Q_Id":62087513,"Users Score":1,"Answer":"Your problem is that your shell doesn't know where that program is, and the places it searches doesn't have it. \nNotably, the shell would look for a program specifically if the name were qualified some way, where you name a location at the start. So, you could use \"\/long\/path\/to\/django-admin\" or \".\/django-admin\" (if it's in the \".\" current directory).\nAlways qualify names that aren't standard programs. It isn't safe to mutate PATH to include a path relative to your current directory .. Instead, name your personal programs with location when you run them, .\/program .","Q_Score":0,"Tags":"python,django,bash","A_Id":62094051,"CreationDate":"2020-05-29T13:50:00.000","Title":"\"bash: django-admin: command not found\" after running django-admin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am facing an issue with pyspark while running this in local mode. And the tricky thing is when I open cmd and run pyspark it creates a session and then if I open the localhost:4040 I can see the UI. But, if I run some program from pycharm I am not able to access the UI (localhost:4040) also the URL is not generated. \nAnd in other case when I have the pyspark shell open in parallel with pycharm program and if I run the same program in pycharm I will get a warning saying cannot bind port 4040 so attempting 4041. which is a bit understandable as shell has occupied port 4040 so it is attempting 4041. So, ideally 4041 should be allocated but that is not the case. As the documentation says it attempts 16 times, to get the next free port number available, I have not been allocated with any. So, then if I see the services running currently on my PC, I could see none of them are using those ports.\nPlease help me with this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":273,"Q_Id":62088457,"Users Score":0,"Answer":"The warning \"port 4040 is unaviable, attempting 4041\" and forawrd..., is occures probably, because you open a a lot of SparkContext without close them.(SparkContext#close).\nYou can change the port if you want by the parameter spark.ui.port in configuration.\nFor your first issue, can you provide logs please of the running spark app? maybe you are running a fast program that close the web ui fast enough before you enter?","Q_Score":0,"Tags":"python,scala,apache-spark,pyspark","A_Id":62088572,"CreationDate":"2020-05-29T14:38:00.000","Title":"pyspark bind issue cannot generate the SPARK UI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am running a Django project on NGINX + UWSGI. It's working properly in LAN, but from outside it shows just the NGINX default page. What can be a problem here?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":121,"Q_Id":62090852,"Users Score":0,"Answer":"You should check if your router is redirecting the traffic to your nginx server, also check if your ISP is giving you an public IP, there is several scenarios that won't let you access to you nginx server please check if the you have a public IP and then we you can check your router in order to check if the http traffic is being redirected to your local server","Q_Score":0,"Tags":"python,nginx,uwsgi","A_Id":62091088,"CreationDate":"2020-05-29T16:48:00.000","Title":"NGINX server works normally in LAN, but doesn't work outside of it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"A function in Faker script to add data in my model Department.\n    \ndepartment = ['I.T.','C.S.E','M.E.','E.C.']\ndef add_dept():\n    d = Department.objects.get_or_create(dept_name=random.choice(depatment))[0]","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":683,"Q_Id":62091767,"Users Score":0,"Answer":"The function you're calling returns a list or a tuple. In either case, the [0] simply extracts the first element from the result, and throws any remaining results away.","Q_Score":3,"Tags":"python,django","A_Id":62091825,"CreationDate":"2020-05-29T17:43:00.000","Title":"Why do we write [0] after get_or_create in model_name.object.get_or_create() in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was doing a game in tkinter, then I make it executable with PyInstaller and sent it to my friends so they can run it and tell me how it feels.\nIt seems that they could download the file, but can't open it because windows forbade them telling that it's not secure and not letting them choose to assume the risk or something.\nThey tried to run as administrator and still nothing changed.\nWhat should I do or what I should add to my code so that windows can open it without problem and why windows opens other executable files without saying that(current error that my executable gets)?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":322,"Q_Id":62095008,"Users Score":0,"Answer":"compress it as a .zip file and then it will most probably work\nor install NSIS and create a windows installer for it.","Q_Score":0,"Tags":"python-3.x,windows,tkinter,pyinstaller","A_Id":62097592,"CreationDate":"2020-05-29T21:43:00.000","Title":"I am not allowed to run a python executable on other pcs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to upload a large file on google drive but I am getting a warning that my app is not verified by google.I am using pydrive.Give me a solution using pydrive or using another way.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":62097367,"Users Score":0,"Answer":"use the google cloud platform\nhave not used it much but pretty sure it works","Q_Score":0,"Tags":"python-3.x","A_Id":62097605,"CreationDate":"2020-05-30T03:18:00.000","Title":"How to upload a large file on Google drive using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have FLask web development server running on my Mac @ 127.0.0.1:5000\/. Both my mac and my android device are connected to the same WLAN. I am unable to access my flask website by entering the IP address of my mac(192.168.8.103:5000) into the browser of my android device. But I can access the webpage from my apache server running on my Mac by entering 192.168.8.103 into the browser of my android device. Can I access the flask webserver from my mobile?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3749,"Q_Id":62098072,"Users Score":6,"Answer":"You need to run the app with your IPv4 address \napp.run(debug=True, host= '192.168.8.103') assuming 192.168.8.103 is your IPv4 if not, replace it with your IPv4","Q_Score":2,"Tags":"python-3.x,web,flask","A_Id":62108443,"CreationDate":"2020-05-30T05:06:00.000","Title":"How to access Flask web server from mobile device?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In django, if I want to use csrf token, I need to imbed a form with csrf token in django template. However as a backend-engineer I am co-working with a front-end engineer whose code is not available for me. So I caanot use the template. In this case, if I want still the csrf function. what should I do?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":62098555,"Users Score":0,"Answer":"you should ask the coworker to embed the csrf token in the form he is sending you\nyou can get it from document.Cookies if he doesnt want to or cannot use the {% csrf %} tag","Q_Score":0,"Tags":"python,django","A_Id":62098568,"CreationDate":"2020-05-30T06:09:00.000","Title":"how to implement csrf without csrf token in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to get the list of telegram groups(name) which I am a part of. Like a text file or something else. How can I do that?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":8289,"Q_Id":62098696,"Users Score":1,"Answer":"Another way - use web-version of the telegram and parse HTML. Here are steps:\n\ncreate folder with only groups;\ngo to web-version, open this folder;\nrun code copy($$(\".dialog-title .peer-title\").map(function(e){return e.textContent})) in console, it will copy title of groups on screen into clipboard;\nif you have a lot groups on several screens, list groups below and make previous step again;\njoin all the groups into one big list;\nprofit!","Q_Score":3,"Tags":"telegram,python-telegram-bot","A_Id":69032852,"CreationDate":"2020-05-30T06:29:00.000","Title":"How to get a list of all the telegram groups I have joined?","Data Science and Machine Learning":0,"Database and SQL":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 django developement after making changes to my model i tried to run the command python manage.py makemigrations my_app \nit detects changes in my model and shows me the message \ntodoapp\/migrations\/0001_initial.py\n    - Create model confess\n    - Create model UserChoice\n    - Create model comment \nbut on executing  python manage.py migrate my_appcommand i've got this message \nNo migrations to apply.\ni usually do this after making changes in models, i don't know what happened now.\nplss help me.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":237,"Q_Id":62099242,"Users Score":-1,"Answer":"Delete all migrations files and __pychache__except__init__.py from your project and app. Also db.sqlite3 database then rerun makemigrations and migrate commands. It should solve your issue.","Q_Score":0,"Tags":"django,python-3.x","A_Id":62099352,"CreationDate":"2020-05-30T07:30:00.000","Title":"Django - Make migration command detects changes but on migrating says 'No migrations to apply'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I crawled and saved the user's website usage lists.\nI want to analyze the results of the crawl, but I wonder how there is a way.\nFirst of all, what I thought was Word Cloud.\nI am looking for a way to track user's personal preferences with user's computer history. \nI want a way to visualize personal tendencies, etc. at a glance. Or I'm looking for a way to find out if there's no risk of suicide or addiction as a result of the search.\nthank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":62100079,"Users Score":0,"Answer":"If you want to visualize data and make analysis on it matplotlib would be good start , again it depends a lot on your data. Matplotlib and seaborn are plotting libraries that are good for representing quantitative data and get some basic analysis at least.","Q_Score":0,"Tags":"python,word-cloud","A_Id":62100135,"CreationDate":"2020-05-30T08:51:00.000","Title":"How to analyze crawl results","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Many people use jinja template rendering for their web base apps.\nA high percentage of apps have a few templates but when the app gets popular,  templates will be processed many times.\nI wanna to know that is processing the templates a bottleneck as app gets more hits?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":24,"Q_Id":62105254,"Users Score":1,"Answer":"jinja2 is robust enough to render templates responsively but the problem is seen when you have a heavy\/blocking tasks to process (requesting database, bulk operations ..) before passing variables to jinja2 to render templates.\nso with a good application design comes a good performance.\n\nadd caching support, use 3rd Flask extensions like flask-caching\nuse Task Queues apps (like redis or celery ..) to handle asynchronously in  background a long-running jobs that would dramatically reduce the performance of an HTTP response\nuse an HTTP accelerator like varnish","Q_Score":0,"Tags":"python,templates,jinja2,jit","A_Id":62623271,"CreationDate":"2020-05-30T16:14:00.000","Title":"JITing html template files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Yesterday I made a bot and everything was working, today when I try to run my code I have this error:\n\nClientConnectorCertificateError(aiohttp.client_exceptions.ClientConnectorCertificateError:\n  Cannot connect to host discordapp.com:443 ssl:True\n  [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED]\n  certificate verify failed: certificate has expired (_ssl.c:1108)')]\n\nI am using win10, python 3.8, and pycharm. \nI saw a similar problem on StackOverflow but the solution Is not working for me.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":8071,"Q_Id":62108183,"Users Score":2,"Answer":"For Mac Users, If they are facing the same problem, You can do the following :-\n\nGo to MacintoshHD -> Applications -> Python3.x Folder.\nDouble click on the \"Install Certificates.command\".","Q_Score":1,"Tags":"python,bots,discord.py","A_Id":71559132,"CreationDate":"2020-05-30T20:17:00.000","Title":"Discord.py bot dont have certificate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"python request.get always throws status code 200 . This is coming even after adding an user agent in the request.get( ) .\nAs status_code is always 200 , a file from that website is downloaded even if doesn't exists there . \nHow to get correct atatus_code ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":62108533,"Users Score":0,"Answer":"200 - \"The HTTP 200 OK success status response code indicates that the request has succeeded.\"  This means it worked! Now, on to the next steps... :)","Q_Score":1,"Tags":"python","A_Id":62108608,"CreationDate":"2020-05-30T20:52:00.000","Title":"python request.get always throws status code 200","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install \/ run Head-Less Chrome in AWS Lambda but getting the following Error when I test it through Lambda.\n\"errorMessage\": \"Message: Service \/tmp\/bin\/chromedriver unexpectedly exited. Status code was: 127\\n\",\n  \"errorType\": \"WebDriverException\"\nI am using ChromeDriver 83.0.4103.39 for Linux.\nSteps performed in Python:\n\nCreated \/tmp\/bin in Lambda\nCopy Chrome Driver to \/tmp\/bin\nChanged the permission to 0777\n\nPython Code:\nThrowing error on the following line -\ndriver = webdriver.Chrome(chrome_options=chrome_options, executable_path= \"\/tmp\/bin\/\" + chrome_linux_driver)\nCode is working fine when I am running under windows with same windows Chrome driver.\nAny help is really appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1096,"Q_Id":62110569,"Users Score":0,"Answer":"The error might come from the fact that the chromedriver version and the headless chromium binary you are using aren't the same so make sure to download the same version for both\nanother reson could be that you are not using linux chromedriver and headless chromium and since lambda work on linux the code won't work\nhopefully this was useful.","Q_Score":8,"Tags":"python,selenium,aws-lambda,selenium-chromedriver","A_Id":68178317,"CreationDate":"2020-05-31T01:31:00.000","Title":"Headless Chrome Python 3.8 on AWS Lambda - unexpectedly exited. Status code was: 127","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For the normal BatchNorm, the least batch size per GPU is 2.\nI wonder if I use the SyncBatchNorm, can I use batch_size=1 for every GPU with more than a single GPU?\nI.e, the total_batch_size is more than 1 but batch_size_per_gpu is 1.\nI would appreciate answers for any deep learning framework, pytorch, tensorflow, mxnet, etc","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":109,"Q_Id":62110937,"Users Score":1,"Answer":"For PyTorch, using batch_size_per_gpu=1 and more than one GPU is fine.","Q_Score":1,"Tags":"python,tensorflow,pytorch,mxnet,batch-normalization","A_Id":62153083,"CreationDate":"2020-05-31T02:43:00.000","Title":"What is the least total batch size for SyncBatchNorm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ok so I was trying to make a script that would only activate if it was a week after installing and first running it.\nMy first thought was to make a new environment variable with the activation time, and making the program check if the current time is larger than that, but I found that using os.environ['activation-Time'] = str(time.time() + 604800) does not actually add a new environment variable that can be accessed at a later time. \nIs it possible to have a variable that gets saved each time you run the code? Or is it possible to create a new environment variable from within a python script?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":400,"Q_Id":62113605,"Users Score":2,"Answer":"I can think of a couple ways to do this, depending on your specific needs.\n\nYou can use the python-crontab package to manage cron jobs on your system. I don't know if you are on Windows, Mac OS X, or linux, and don't know if this works on windows. But on a mac or linux, this allows you to set jobs to run on a schedule, and you could decide when you want this script to be run again.\nYou could write the last (or first?) run-time to a sqlite database, and have a cron job check that at regular intervals, and decide when to run again based on whatever logic you want.\nI will say that environment variables are probably not the way to go, unless you write them into your shell .rc file, so that they are re-used by every shell you open. You still need something to try to run your script at a certain time, either manually or via a cron job.\n\nHope that helps, happy coding!","Q_Score":0,"Tags":"python,python-3.x,environment-variables","A_Id":62119311,"CreationDate":"2020-05-31T08:38:00.000","Title":"Is it possible to have permanent variables in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I ran into a problem where my python2 environment is conflicting with the included python and packages of 3rd party software. I get many Runtime Error's. One software I'm writing for has PySide2 already installed. So it complains when I run it under this environment, but I need PySide2 in my environment because there is also stand-alone tools as part of this environment.\nI assume the RuntimeError's are coming from the DLLs and other compiled stuff in my python env, so how should I approach this problem?\nWhat I tried initially is to create another conda environment, with just the libs that I need, no python interpreter. Then I would include the site-packages of this second environment to the PYTHONPATH of the first one. This way I can run the main one in stand-alone applications and IDE's, and for 3rd party software I just include site-packages in the PYTHONPATH without any conda environment. The problem with this is when I run conda install <mypackage> --no-deps (to avoid it from install python as a dependency), it defaults to python 3.8 packages, and also leaves me in the dark in terms of what packages dependencies I need and which I don't. I'm thinking for sure there a cleaner way to approach and manage this problem.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":62114219,"Users Score":0,"Answer":"I don't what is the actual error for your case, but I faced this type of conflict between 3rd party python based software and conda several times.I resolve my problem by reinstalling anaconda and check of the option \"use anaconda as your default python\" at that time. May be it will be helpful for you.","Q_Score":0,"Tags":"python,python-2.7,anaconda,conda","A_Id":62114619,"CreationDate":"2020-05-31T09:36:00.000","Title":"Conda environment conflicts with 3rd party software","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use dark mode in pycharm. When folders are enabled with git, the coloring of the files at the left-hand-side project folder looks dark in dark mode. How can I disable file colouring in git-enabled folder in pycharm? It is straining the eyes.\nI am using Pycharm community 2020.1","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":225,"Q_Id":62114437,"Users Score":1,"Answer":"You cannot disable dark mode for a portion of the PyCharm UI separately. The problem you are facing might be due to wrong installation or something like that. Reinstallation or update of PyCharm might help.","Q_Score":0,"Tags":"python,git,pycharm,ide","A_Id":62114805,"CreationDate":"2020-05-31T09:56:00.000","Title":"How to disable file colouring in git-enabled folder in pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use dark mode in pycharm. When folders are enabled with git, the coloring of the files at the left-hand-side project folder looks dark in dark mode. How can I disable file colouring in git-enabled folder in pycharm? It is straining the eyes.\nI am using Pycharm community 2020.1","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":225,"Q_Id":62114437,"Users Score":1,"Answer":"I will answer my own quesstion.\nGo to Settings > Version Control > File Status Colors and change the colors accordingly.","Q_Score":0,"Tags":"python,git,pycharm,ide","A_Id":62293928,"CreationDate":"2020-05-31T09:56:00.000","Title":"How to disable file colouring in git-enabled folder in pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got a question about splitting the data into a training and test set in Time Series tasks.\nI know that the data can't be shuffled because it's important to keep the time nature of the data, so we do not create scenarios where we are able to look into the future.\nHowever, when I shuffle the data (for experimenting), I get a ridiculously high R-Squared score.\nAnd yes, the R-squared is evaluated with the test set.\n\nCan someone maybe simply explain why this is the case?\nWhy does shuffling train and test data in time series produce a high R-Squared score? My guess is that it has something to the with the trend of the time series, but I am not sure. I am just asking out of curiosity, thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":62117759,"Users Score":0,"Answer":"It really depends upon your problem. If:\n\nif your model has no memory, and merely a mapping tasks then attached timestamp does not have any significance it is better in fact recommended to shuffle the data for better distribution. If this is the case and you are getting a higher R-squaed value you shoud definitely go for it. (I assume this is the case since R-squared is usually used for these types of tasks)\nIf your task is pattrn dependent and each prediction is affecting next in the sequence. This is where order matters. In this case you should never shuffle the data. Any metric which suggest that is lying. The best you can do is split train and test set based on a timestamp prior to which you have your train set and afterwards test set. Then divide train and test sets into fixed time windows. You can shuffle those windows now only if the window span is large enough for your case.\n\nHope this helps!","Q_Score":1,"Tags":"python,time-series","A_Id":62119424,"CreationDate":"2020-05-31T14:34:00.000","Title":"Why does shuffling train and test data in time series produce a high R-Squared score?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I bought a MAC and I use this system for the first time, I also recently started using python.\nI have a python project with a requirement.txt file which I opened with PyCharm which also contains a dependency on uvicorn. I installed all the dependencies, but when I try to run the command \"uvicorn main: app\" I get the error \"command not found: uvicorn\".\nI tried to look for guides on my problem and I read that it could concern the PATH variable and following what written in these guides I tried to add the PATH to python from my home directory. Now the content of my python PATH is the following:\n\n\/Library\/Python\/3.7\/bin:\/usr\/local\/bin:\/usr\/bin:\/bin:\/usr\/sbin:\/sbin\n\nI also read that I should have added the following line to my ~\/.profile file and that because my MAC is a new one I could not have it, so I created this file and write the line written below:\n\nexport PATH=\/usr\/local\/bin:\/usr\/local\/sbin:$PATH\n\nnothing has changed since my attempts so I am asking what I should do. I've also seen that pip3 installed my modules of the requirements.txt file on the following directory:\n\n\/usr\/local\/lib\/python3.7\/site-packages\/\n\nThank you in advance for your help","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3541,"Q_Id":62118964,"Users Score":0,"Answer":"I resolved setting a virtual environment in the project directory and installed the dependencies in it.","Q_Score":1,"Tags":"python,python-3.x,macos,path,uvicorn","A_Id":62250361,"CreationDate":"2020-05-31T16:08:00.000","Title":"macOS - command not found: uvicorn","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I created a table with an initial IntegerField primary key and later changed the id to a UUIDField. Now this raises a \"Badly formed hexadecimal UUID string\", I guess because a number such as \"1\" isn't a valid UUID value. Does anyone know a concise way to fix this in code when updating the models.py file for the django app?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":229,"Q_Id":62119274,"Users Score":0,"Answer":"Before everything, double check that you don't have any foreign key with Cascade uppon this model. Then, instead of changing the type of id = models.IntegerField() :\n\ncreate a new field uuid = models.UUIDField(default=uuid.uuid4, primary=True) (default will set the field for existing rows)\nmake migrations\nremove the id field\nmake migrations\nrename the uuid field to id\nmake migrations\nmigrate\n\nHowever, you should know that removing the id field, and \/ or naming the uuid is not mandatory, and it's often a good idea to keep both.","Q_Score":0,"Tags":"python,django,python-3.x,uuid,django-3.0","A_Id":62121735,"CreationDate":"2020-05-31T16:31:00.000","Title":"Fixing error \"Badly formed hexadecimal UUID string\" after converting existing id to uuid in Django (Django 3.0)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"pip install matplotlib \nsays requirement already satisfied. \nI'm on a Mac and have looked through tons of answers online but can't get matplotlib to work. I'd appreciate any suggestions.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":62120689,"Users Score":0,"Answer":"maybe your Interpreter is set to python not python3 ?\nif you using pip3 it'S working ?","Q_Score":0,"Tags":"python,matplotlib,pip,python-3.7","A_Id":62120799,"CreationDate":"2020-05-31T18:25:00.000","Title":"'import matplotlib' gives 'module not found error'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"pip install matplotlib \nsays requirement already satisfied. \nI'm on a Mac and have looked through tons of answers online but can't get matplotlib to work. I'd appreciate any suggestions.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":62120689,"Users Score":0,"Answer":"Maybe you install it in one venv and try to import in other one.","Q_Score":0,"Tags":"python,matplotlib,pip,python-3.7","A_Id":62120715,"CreationDate":"2020-05-31T18:25:00.000","Title":"'import matplotlib' gives 'module not found error'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to package up my python file into an .exe file using pyinstaller.\nI managed to install pyinstaller with pip but when trying to use pipinstaller in a command window it wouldn't work. I found online to use python -m PyInstaller instead which then worked. But after using cd to change the directory and then doing python -m PyInstaller filename.py it would always give a list of errors saying 1920, 'LoadLibraryExW', 'The file cannot be accessed by the system.'.\nI'm using windows 10, python 3.8.3 and the newest version of pip but I couldn't find a soloution. I ran command prompt as an operator but it still wouldn't help.\nAny soloutions?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2719,"Q_Id":62122077,"Users Score":0,"Answer":"I decided to try another one after failing to use pyinstaller. I used py2exe and shortly after trying managed to convert it into an .exe file along with moving my files inside of where my python was stored.","Q_Score":1,"Tags":"python,pyinstaller","A_Id":62264030,"CreationDate":"2020-05-31T20:28:00.000","Title":"How to make a .exe from python script with pyinstaller?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to package up my python file into an .exe file using pyinstaller.\nI managed to install pyinstaller with pip but when trying to use pipinstaller in a command window it wouldn't work. I found online to use python -m PyInstaller instead which then worked. But after using cd to change the directory and then doing python -m PyInstaller filename.py it would always give a list of errors saying 1920, 'LoadLibraryExW', 'The file cannot be accessed by the system.'.\nI'm using windows 10, python 3.8.3 and the newest version of pip but I couldn't find a soloution. I ran command prompt as an operator but it still wouldn't help.\nAny soloutions?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2719,"Q_Id":62122077,"Users Score":0,"Answer":"I encounter the same question, so I uninstall python which is installed from windows appstore, and reinstall it from the website, and it works fine now, hope it help","Q_Score":1,"Tags":"python,pyinstaller","A_Id":62240985,"CreationDate":"2020-05-31T20:28:00.000","Title":"How to make a .exe from python script with pyinstaller?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a small .py file that contains some classes to be imported later repetitively into other work. The mentioned .py file uses some small database (in order of KB) in the form of tables. Do you think it is better to store this data in the same .py file or is it better to keep it in a separate .csv file? What are the differences in terms of performance and convenience for later use? A point that I might have to mention is that this data is numerical and is not prone to any possible change in the future.\nSingle items are to be accessed from this data at a time.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":62122636,"Users Score":0,"Answer":"It's better practice to write into a csv file as it improves readability of the entire code. It won't hurt you performance and will really benefit you.","Q_Score":0,"Tags":"python,csv","A_Id":62122677,"CreationDate":"2020-05-31T21:19:00.000","Title":"Should I be saving my data in a .csv file?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a small .py file that contains some classes to be imported later repetitively into other work. The mentioned .py file uses some small database (in order of KB) in the form of tables. Do you think it is better to store this data in the same .py file or is it better to keep it in a separate .csv file? What are the differences in terms of performance and convenience for later use? A point that I might have to mention is that this data is numerical and is not prone to any possible change in the future.\nSingle items are to be accessed from this data at a time.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":71,"Q_Id":62122636,"Users Score":1,"Answer":"If readability of the python class is not a concern (although it's best practice to keep code as readable as possible), the big question here will be 'how much' data are we talking about? If you have gigabytes of data then you don't want to have this all sitting in memory at the same time (i.e. what would happen if you just kept it as a constant in a .py file). Instead, for such large data, you want to read it from disk (maybe as a csv) as and when you need it.\nOf course storing it in disk has a performance hit because reading from disk is slower than reading from memory. Whether or not the performance hit is okay for your application is up to you to decide.\nA good in-between to ensure readability and good performance might be (assuming you have enough memory) to store the data in a csv, read it all at once on start up and keep it in memory for repeated calls.","Q_Score":0,"Tags":"python,csv","A_Id":62122715,"CreationDate":"2020-05-31T21:19:00.000","Title":"Should I be saving my data in a .csv file?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a small .py file that contains some classes to be imported later repetitively into other work. The mentioned .py file uses some small database (in order of KB) in the form of tables. Do you think it is better to store this data in the same .py file or is it better to keep it in a separate .csv file? What are the differences in terms of performance and convenience for later use? A point that I might have to mention is that this data is numerical and is not prone to any possible change in the future.\nSingle items are to be accessed from this data at a time.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":62122636,"Users Score":0,"Answer":"My Suggestion is to store data in Json format. Like in MongoDb, by adapting No-Sql format. This will help you in easily manage and control over the data.","Q_Score":0,"Tags":"python,csv","A_Id":62122740,"CreationDate":"2020-05-31T21:19:00.000","Title":"Should I be saving my data in a .csv file?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I an a novice in Machine Learning and while going through the course I came across the \"Scoring Parameter\". I understood for Regression model evaluation, we consider the negatives of Mean Squared error, mean absolute error etc.\nWhen I wanted to know the reason, I went through SKLearn documentation which says \"All scorer objects follow the convention that higher return values are better than lower return values. Thus metrics which measure the distance between the model and the data, like metrics.mean_squared_error, are available as neg_mean_squared_error which return the negated value of the metric.\"\nThis explanation does not answer my why's completely and I am confused. So, why is the negatives taken more because logically if the difference in prediction is higher whether -ve or +ve, it makes our models equally bad. Then why is it that scoring parameter is focused on negative differences?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4661,"Q_Id":62125674,"Users Score":2,"Answer":"It's simple: minimizing MSE is equivalent to maximizing negative-MSE.\nAn objective function that the scorer can maximize is just by \"convention\" as the Sklearn documentation suggests.","Q_Score":2,"Tags":"python,machine-learning,scikit-learn,regression,scoring","A_Id":62125933,"CreationDate":"2020-06-01T04:23:00.000","Title":"Why is negative (MSE or MAS) Scoring parameter like- neg_mean_absolute_error in SKLEARN is considered for regression model evaluation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Django and trying to understand the model relationships, here is my use case:\nI have a Creator object which can create multiple Listing under a Category. Category can have multiple Listings from multiple Creators. \nCreator -- Creates a Listing about a service -- under a Category or multiple Category\nI am trying to find the thought process behind picking the correct relationship while defining this kind circular  relationship.  Which one of the model should go first? Is it Category which is first and Creator second and Listing at the end, is Creator, Category and Listing all belong to a Many to Many relationship, if then how are they linked?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":193,"Q_Id":62126391,"Users Score":-1,"Answer":"In Django Models there are three types of relationships.\none to one - when one entity is unique to other entity\nExample: A user model can be in one to one relationship to customer model.\nEvery customer is unique user\nmany to many - When one entity can has relationship with many other entities and vice versa.\nExample : pizza and toppings,\npizza can have many toppings, and same topping can be applied on various pizza\none to many - also called foreign key in Django  when a single entity is related to many other entities but vice versa is not true.\nExample: your Use case applies here.\nA creator can create multiple listings but a single listing can be mapped to single creator only, not multiple creator.","Q_Score":1,"Tags":"python,django,django-models","A_Id":62126542,"CreationDate":"2020-06-01T05:50:00.000","Title":"Django model relationship with circular relationship","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using pyomo for optimization modeling, including multiple continuous and discrete variables, but I am not clear how to define a discrete variable.The value of discrete variable is either 0 or 100.\nmy question is : how to define a discrete variable which value is either 0 or 100\nthans all!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":358,"Q_Id":62126655,"Users Score":1,"Answer":"You would have to declare a binary variable, e.g. y, in addition to your discrete variable, e.g. myvar.\nThen, you need a constraint that says: myvar = 100 * y\nIf y=0, then myvar will necessarily be 0 too. If y=1, then myvar will be equal to 100.\nI assume you would be able to express these in Pyomo syntax.","Q_Score":0,"Tags":"python,pyomo","A_Id":62130354,"CreationDate":"2020-06-01T06:14:00.000","Title":"python pyomo: declaration of discrete variable","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Bokeh callbacks with CustomJS: is there a way to trigger a callback with CustomJS from inside another callback with custom JS? Additionally and related to the first question: is there a way to prevent triggering a callback when modifying the property or producing the event that triggers that callback? I have been trying to find information or a way to do this from the Bokeh docs but I can't find anything.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":540,"Q_Id":62126663,"Users Score":0,"Answer":"Calling CustomJS from CustomJS - yes, absolutely. CustomJS is an object with an execute method that accepts cb_obj and cb_data. Just call it like a regular method and that's it.\nSetting a property without triggering callbacks - it's possible in JavaScript, but it's an implementation detail that you should not rely on. If you're interested, look up the source of the HasProps class in BokehJS source code, it has a setv method. And I don't think it's possible at all in Python.","Q_Score":1,"Tags":"javascript,python,callback,bokeh","A_Id":62130620,"CreationDate":"2020-06-01T06:15:00.000","Title":"Bokeh callbacks with CustomJS: is there a way to trigger a callback with CustomJS from inside another callback with custom JS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am creating a script that uses \n\npython 3.7.3  \npyserial 3.4 \npytest 5.4.2\n\nThe scripts run on a windows 10 machines that  communicates with another device. On some occasions I see that the string I pass into serial module write method is either  transmitted with a character missing or on rare occasions with one of the characters substituted. I have checked the baud rate to make sure the windows machine and the device are using the same baud rate, and have found the baud rates and all other serial port settings to be the same.\nI have drilled into the pyserial module into the file serialwin32.py in the write method. I can see that the string I pass in definitely is passed into this function.\nWhen I use Teraterm on the windows machine I do not incur this problem.\nAlso when I run the same python scripts on an ubuntu machine the problem does not occur.\nAny help on where the issue may be will be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":62126792,"Users Score":0,"Answer":"What baud rate are you using? Can it be increased? If not and it works on TeraTerm but not in Python, as you noted, it could be a flow control issue that is resolved by having your code mirror the flow control used in TeraTerm. If none of that pans out, could you describe in more detail the test you are doing in TeraTerm? When using TeraTerm, are you typing in the data or pasting it? Make sure to try pasting data (or maybe create a TeraTerm macro) that really hammers data through the interface so that you can be sure that TeraTerm really is working and not masking the same issue as the script.","Q_Score":0,"Tags":"python,windows,pyserial","A_Id":69170806,"CreationDate":"2020-06-01T06:27:00.000","Title":"Python Serial Port omitting characters in transmission","Data Science and Machine Learning":0,"Database and SQL":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 ran the revert command to undo my previous commit but then realized I had made a mistake. \nHow can I undo my revert action and restore to my previously committed state?\nExample: \n(1) In my project, I have two files A and B and then I committed the changes and push the changes to GitHub.\n(2) I added file C and committed changes but didn't push the changes to Github.\n(3) I ran the Revert which removed the file C from my project but it was a mistake.\nHow can I undo my last action of Revert to bring back the file C, which was committed and then reverted on my local repo but never pushed to Github?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":62129574,"Users Score":0,"Answer":"'git reflog' to list last few HEADS.\nChoose commit id of the change you wanted.\ngit reset to that commit id.","Q_Score":0,"Tags":"python,git,github","A_Id":62129632,"CreationDate":"2020-06-01T09:49:00.000","Title":"How to undo a revert action to move back to my previous commit 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":0,"Web Development":0},{"Question":"Getting below error while running this code in Python, If anyone could advise me on this that would be appreciated. Thanks\ndataframe = pandas.read_sql(sql,cnxn)\nDatabaseError: Execution failed on sql 'SELECT * FROM train_data': ('HY000', \"[HY000] [Dremio][Connector] (1040) Dremio failed to execute the query: SELECT * FROM train_data\\n[30038]Query execution error. Details:[ \\nVALIDATION ERROR: Table 'train_data' not found\\n\\nSQL Query SELECT * FROM train_data\\nstartLine 1\\nstartColumn 15\\nendLine 1\\nendColumn 24\\n\\n[Error Id: 24c7de0e-6e23-44c6-8cb6-b0a110bbd2fd on user:31010]\\n\\n  (org.apache.calcite.runtime.CalciteContextException) From line 1, column 15 to line 1, column 24: ...[see log] (1040) (SQLExecDirectW)\")","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":644,"Q_Id":62131393,"Users Score":0,"Answer":"this is being solved, it says that table does not exist, should give a valid table, in dremio it can be inside a specific space","Q_Score":0,"Tags":"python,sql,pyodbc,dremio","A_Id":62146385,"CreationDate":"2020-06-01T11:43:00.000","Title":"Dremio ODBC with Python","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently I am working on a Schoolproject and I need to send a Notification to a self written Xamarin Forms App from my API. It all runs on a local network and the App can already communicate with the Api, now i want my api to send a notification to my phone if a specific event turns true. How do I do this? (Oh and I am using Python flask for my API, if u need this Information)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":62132040,"Users Score":0,"Answer":"Use Push notification for it. As soon as there is a need to call\nmobile app from web server send a push notification. Handle the push\nnotification on application side to make a call to web api as soon as\nit receives the push notification with specific payload. \nUse Web Sockets if server events are too frequent.","Q_Score":0,"Tags":"python,c#,api,xamarin","A_Id":62133695,"CreationDate":"2020-06-01T12:20:00.000","Title":"How do I send a get request from my Api to a Xamarin forms app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Good evening, I'm making a platformer and would like to know when you should use one of the both.\nFor example for:\n1)The player controlled character\n2)The textured tiles that make up the level\n3)The background\nShould\/Could you make everything with sprites ?\nI just want to know how you would do it if you were to work on a pygame project.\nI ask this because I see lots of pygame tutorials that explain adding textures by using surfaces but then in other tutorials, they use sprite objects instead.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":55,"Q_Id":62136622,"Users Score":3,"Answer":"Yes you could make everything including the background with sprites. It usually does not make sense for the background though (unless you;re doing layers of some form).\nThe rest often make senses as sprite, but that depends on your situation.","Q_Score":0,"Tags":"python,pygame,sprite,surface","A_Id":62137930,"CreationDate":"2020-06-01T16:31:00.000","Title":"Surfaces or Sprites in Pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Pycharm, you can view the SonarLint issues in a single file by opening the file and clicking on the SonarLint tab on the bottom of the IDE. \nHowever, this only shows the issues for a single file.\nHow can you view all the SonarLint issues across all files within a single project?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1259,"Q_Id":62137196,"Users Score":1,"Answer":"In the project panel, right click on the root directory, then navigate through Sonar Lint>Analyze with Sonar Lint.","Q_Score":1,"Tags":"python,pycharm,sonarqube,sonarlint","A_Id":62163096,"CreationDate":"2020-06-01T17:02:00.000","Title":"PyCharm SonarLint How to view all issues across all files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does deleting a python virtual environment (venv) directory delete the modules installed in it?\nI see the installed modules both in the venv directory and also under Python3.7\/Scripts directory. I can access the installed modules even when I am outside the venv. If I delete the venv directory will I not be able to do so?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":107,"Q_Id":62137579,"Users Score":0,"Answer":"When you delete the venv directory the modules installed in it are deleted. \nWhere as you have those modules in your Python3.7\/Scripts directory also. \nSo, you can access them even if you delete venv directory.","Q_Score":1,"Tags":"python,python-3.x,virtualenv","A_Id":62137769,"CreationDate":"2020-06-01T17:25:00.000","Title":"Does deleting venv delete installed modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using pandas to read CSV file data, but the CSV module is also there to manage the CSV file.\nso my questions are :-\nwhat is the difference between these both?\nwhat are the cons of using pandas over the CSV module?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":10152,"Q_Id":62139040,"Users Score":3,"Answer":"csv is a built-in module but pandas not. if you want only reading csv file you should not install pandas because you must install it and increasing in dependencies of project is not a best practice.\nif you want to analyze data of csv file with pandas, pandas changes csv file to dataframe needed for manipulating data with pandas and you should not use csv module for these cases.\nif you have a big data or data with large volume you should consider libraries like numpy and pandas.","Q_Score":10,"Tags":"python,pandas,csv","A_Id":62139217,"CreationDate":"2020-06-01T18:55:00.000","Title":"python CSV module vs Pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using pandas to read CSV file data, but the CSV module is also there to manage the CSV file.\nso my questions are :-\nwhat is the difference between these both?\nwhat are the cons of using pandas over the CSV module?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":10152,"Q_Id":62139040,"Users Score":1,"Answer":"Pandas is better then csv for managing data and doing operations on the data. CSV doesn't provide you with the scientific data manipulation tools that Pandas does.\nIf you are talking only about the part of reading the file it depends. You may simply google both modules online but generally I find it more comfortable to work with Pandas. it provides easier readability as well since printing there is better too.","Q_Score":10,"Tags":"python,pandas,csv","A_Id":62139102,"CreationDate":"2020-06-01T18:55:00.000","Title":"python CSV module vs Pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im building tools for a business I am starting, and one of the tools I need is a live reader of scrap prices to put into my website as well as deciphering overhead\/profit. How would I take that information and then put it into a live data table?\nVery amateur programmer, but better to do it myself.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":62141465,"Users Score":0,"Answer":"You can use flask and Beautiful Soup. With the flask you will be able to save the data after obtaining the information from the site after manipulating the html with beautiful soup.","Q_Score":0,"Tags":"python,interpretation","A_Id":62142140,"CreationDate":"2020-06-01T21:44:00.000","Title":"How do I extract data from a website for a data table using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two functions: def is_updated_database(): is checking if database is updated and the other  onedef scrape_links(database): is scraping through set of links(that it downloaded from aforementioned database).  \nSo what I want do is when def is_updated_database(): finds that the updated is downloaded, I want to stop def scrape_links(database): and reload it with a new function parameter(database which would be a list of new links).\nMy attempt: I know how to run two threads, but I have no idea how to \"connect\" them, so that if something happens to one then something should happen to another one.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":62141771,"Users Score":0,"Answer":"Well, one way to solve this problem, may be the checking of database state, and if something new appears there, you could return the new database object, and after that scrape the links, probably this is losing it's multithreading functionality, but that's the way it works.\nI don't think that any code examples are required here for you to understand what I mean.","Q_Score":0,"Tags":"python,python-3.x,multithreading,web-scraping","A_Id":62141832,"CreationDate":"2020-06-01T22:09:00.000","Title":"Threading in Python, \"communication\" between threads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've to build an ML model to classify sentences into different categories. I have a dataset with 2 columns (sentence and label) and 350 rows i.e. with shape (350, 2). To convert the sentences into numeric representation I've used TfIdf vectorization, and so the transformed dataset now has 452 columns (451 columns were obtained using TfIdf, and 1 is the label) i.e. with shape (350, 452). More generally speaking, I have a dataset with a lot more features than training samples. In such a scenario what's the best classification algorithm to use? Logistic Regression, SVM (again what kernel?), neural networks (again which architecture?), naive Bayes or is there any other algorithm?\nHow about if I get more training samples in the future (but the number of columns doesn't increase much), say with a shape (10000, 750)?\nEdit: The sentences are actually narrations from bank statements. I have around 10 to 15 labels, all of which I have labelled manually. Eg. Tax, Bank Charges, Loan etc. In future I do plan to get more statements and I will be labelling them as well. I believe I may end up having around 20 labels at most.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":62145159,"Users Score":0,"Answer":"With such a small training set, I think you would only get any reasonable results by getting some pre-trained language model such as GPT-2 and fine tune to your problem. That probably is still true even for a larger dataset, a neural net would probably still do best even if you train your own from scratch. Btw, how many labels do you have? What kind of labels are those?","Q_Score":0,"Tags":"python,machine-learning,classification","A_Id":62145580,"CreationDate":"2020-06-02T05:00:00.000","Title":"Given the dataset, how to select the learning algorithm?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to write a bash script that will be executed on new users' linux machines. The script should make sure the machine is ready to compile and run several fortran and python scripts. My intent was to check for GCC and subsequently check for gfortran in GCC and then use homebrew to install the gfortran formula if not present. Similarly with python, I would use pip to install python3 if python isn't up to date. \nI would like some advice before I begin. What are some best practices for checking for programs and installing them through a behind the scenes bash script? What are things to be careful for? I realize this question is vague but literally any advice is greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":101,"Q_Id":62145515,"Users Score":0,"Answer":"A possible different approach to consider.\nIf the packages that you want are available for installation via the standard package manager for the Linux distribution that you are using, you could build a metapackage which, when installed, will force the installation of all of the components.  (A metapackage is one which does not directly contain any software itself but which lists a number of dependencies that the package manager will need to satisfy when installing it.)\nIf you also set up a repository on an http server containing your metapackage, and configure the package manager on the clients to point to it, then if you later decide to update the list of packages contained in your standard software suite across all the client machines, all you need to do is to publish a new version of your metapackage to the repository, and have the client machines rerun their operating system's software updater.  For the individual software components listed in the metapackage, the software update will pick up any updates to these in the ordinary way, provided that the dependency information in the metapackage does not specify an exact version (you could make the metapackage depend on >= some version number).\nThis is from experience where this approach has worked well in setting up and maintaining a common software platform across a large number of machines (including nodes of a compute cluster) -- although in cases where the required software components are not available in standard package repositories, it is then necessary to build a package for it locally and publish that to your repository; this can then be added as a requirement in your metapackage.\nThe above is in general terms, but taking the specific example on which this experience is based, if the client machines are running CentOS, then you would create a meta-RPM with dependencies on packages in standard repositories (e.g. base and EPEL) plus any other RPMs that you need to build locally, publish it to the repository on the http server and use createrepo to construct the necessary repository metadata, and create a config file in \/etc\/yum.repo.d on the clients to point to your repository and run yum install <your_meta_package>.  Any subsequent yum update on the clients will pick up any changes that you push to your repository.  The http server itself is simply serving static content, so does not need special configuration.\nFor Ubuntu etc, you could do similarly but with deb packages and APT.\nOne thing worth mentioning is that the above is aimed at a rather homogeneous environment, where the same operating system is in use on all the client machines.  If you want to cater for a more heterogeneous environment, then an alternative approach would be to use conda.  You could similarly maintain a conda channel containing a metapackage.","Q_Score":0,"Tags":"python,linux,bash,installation,homebrew","A_Id":62146458,"CreationDate":"2020-06-02T05:35:00.000","Title":"Automating the install of GFortran and Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"In Python how do I write code which shifts off the last element of a list and adds a new one to the beginning - to run as fast as possible at execution?\nThere are good solutions involving the use of append, rotate etc but not all may translate to fast execution.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":6905,"Q_Id":62146307,"Users Score":12,"Answer":"Don't use a list.\nA list can do fast inserts and removals of items only at its end. You'd use pop(-1) and append, and you'd end up with a stack.\nInstead, use collections.deque, which is designed for efficient addition and removal at both ends. Working on the \"front\" of a deque uses the popleft and appendleft methods. Note, \"deque\" means \"double ended queue\", and is pronounced \"deck\".","Q_Score":3,"Tags":"python,list,performance,shift","A_Id":62146408,"CreationDate":"2020-06-02T06:45:00.000","Title":"What is the most efficient way to push and pop a list in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that similar precision questions have been asked here however I am reading a code of a project that is doing an exact equality comparison among floats and is puzzling me. \nAssume that x1 and x2 are of type numpy.ndarray and of dtype np.float32. These two variables have been computed by the same code executed on the same data but x1 has been computed by one machine and x2 by another (this is done on an AWS cluster which communicates with MPI).\nThen the values are compared as follows\nnumpy.array_equal(x1, x2)\nHence, exact equality (no tolerance) is crucial for this program to work and it seems to work fine. This is confusing me. How can one compare two np.float32 computed on different machines and face no precision issues? When can these two (or more) floats can be equal?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":155,"Q_Id":62146800,"Users Score":1,"Answer":"The arithmetic specified by IEEE-754 is deterministic given certain constraints discussed in its clause 11 (2008 version), including suitable rules for expression evaluation (such as unambiguous translation from expressions in a programming language to IEEE-754 operations, such as a+b+c must give (a+b)+c, not a+(b+c)).\nIf parallelism is not used or is constructed suitably, such as always partitioning a job into the same pieces and combining their results in the same way regardless of order of completion of computations, then obtaining identical results is not surprising.\nSome factors that prevent reproducibility include varying parallelism, using different math libraries (with different implementations of functions such as pow), and using languages that are not strict about floating-point evaluation (such as permitting, but not requiring, extra precision).","Q_Score":2,"Tags":"python,numpy,floating-point,precision,equality","A_Id":62150052,"CreationDate":"2020-06-02T07:19:00.000","Title":"Numpy array_equal and float exact equality check","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My R squared score for Linear regression is -1.56 but my R squared score for Random Forest regressor is around 0.48. Is it okay to get scores like this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":192,"Q_Id":62147114,"Users Score":0,"Answer":"Is it okay to get scores like this?\n\nYes.\nExplanation - Linear Regression and Random Forest are two very different models. It is highly possible that the data on which you are trying to fit the model is so complicated that linear regression does not fit it well. \nRegarding the negative R squared score -  It simply means that the linear regression model fits worse than a horizontal line.","Q_Score":0,"Tags":"python,machine-learning,regression,linear-regression,random-forest","A_Id":62147427,"CreationDate":"2020-06-02T07:41:00.000","Title":"Negative r squared for linear regression but positive r squared with Random forest regressor","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want upload an asset to Earth Engine with Python and I don't want use Google Cloud Storage.\nIs there a way to upload a particular file (from my computer) directly to the Google Earth Engine using the command line (or using a Python script)?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":276,"Q_Id":62147243,"Users Score":-1,"Answer":"i use geemap module and bypass uploading file on googleEarthEngine","Q_Score":0,"Tags":"python,command-line,google-earth-engine","A_Id":62227503,"CreationDate":"2020-06-02T07:49:00.000","Title":"Upload asset in Google Earth Engine with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want upload an asset to Earth Engine with Python and I don't want use Google Cloud Storage.\nIs there a way to upload a particular file (from my computer) directly to the Google Earth Engine using the command line (or using a Python script)?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":276,"Q_Id":62147243,"Users Score":0,"Answer":"No. You can only upload from Google Cloud Storage via python. The only way to upload directly from your computer is via the playground.","Q_Score":0,"Tags":"python,command-line,google-earth-engine","A_Id":62155953,"CreationDate":"2020-06-02T07:49:00.000","Title":"Upload asset in Google Earth Engine with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on a VRP project using Google OR-Tools with Python.\nCurrently, I have a tight time windows constraints, high demands, and the capacity of the vehicles.\nWhen I run the solver, the solver always chooses to deploy the vehicle that has the biggest capacity.\nCan I make the solver deploy the smaller vehicle even though it will deploy more vehicles? Because in reality deploying bigger vehicles will cost higher.\nAnd is there any function inside that can allow re-departure of vehicle?\nThank you!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":535,"Q_Id":62147843,"Users Score":0,"Answer":"I found another strategy that we can do in the or-tools.\nIn my case, the or-tools will deploy the big vehicle first as the first solution and there is a minimum number of the biggest vehicle for some 'tight' problems (tight time windows or really high weight demands). So what if, we do not have enough resources which are the big vehicles?\nAs long as the resources still have a lot of smaller vehicles, I can use 'dummy vehicles' to reach the first solution. The cost for these 'dummy vehicle' should be really high compared to the real vehicle, I set it like 1000 times higher.\nAfter the solver reaches the first solution, you can give it a time to improve the solution. After a while, the solver will deploy the real smaller vehicle and will not use the 'dummy vehicle' anymore.","Q_Score":1,"Tags":"python,or-tools","A_Id":62588722,"CreationDate":"2020-06-02T08:27:00.000","Title":"How to make Google OR Tools Deploy More Vehicle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i want to import PCA from sklearn.decomposition, but following error occurs: \n\"ModuleNotFoundError: No module named 'sklearn.decomposition'\". (just import sklearn works)\nDoes someone know how i can solve this problem?\nI have installed the packages in Anaconda (conda version : 4.8.3)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3773,"Q_Id":62149948,"Users Score":1,"Answer":"If the module installed, uninstall and install Sklearn again.\npython -m pip install -U sklearn.","Q_Score":1,"Tags":"python,tensorflow,anaconda","A_Id":62150166,"CreationDate":"2020-06-02T10:29:00.000","Title":"ModuleNotFoundError: No module named 'sklearn.decomposition'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write a game in VS Code, but whenever I try to open an image using:\nhero.image = pygame.image.load(\"Character.jpeg\")\n(The images are in the game folder)\nI get varied error messages. One computer it says \"pygame.error: Couldn't open Character.png\" and on another, it says something to do with incorrect sRGB profile. I have tried running the program on different computers, tried it with different images in different image formats, .gif, .png, and .jpeg.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":62150133,"Users Score":0,"Answer":"Thank you for your answers, it turns out the problem was that the folder was stored on a cloud location, and the computer cannot do it from there. The way I fixed it was making a copy of the image on the actual PC, I didn't need to actually use that version of the image, but as long as it is there the program works.","Q_Score":0,"Tags":"python,pygame","A_Id":62226055,"CreationDate":"2020-06-02T10:39:00.000","Title":"Can't Open image files in pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The command 'jupyter lab' usually works fine in cmd. But today it isn't. I uninstall and reinstalled all jupyter components but no gain. Jupyter notebook seems to be working though.\n\nC:\\Users\\Sarth.choudhary>jupyter lab \n  Cannot open D:\\Programs\\Miniconda3\\Scripts\\jupyter-lab-script.py\n\nI looked into the miniconda directory, jupyter-lab-script.py is indeed missing. I don't have this file anywhere in the miniconda directory.\nAny help much appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1902,"Q_Id":62150298,"Users Score":0,"Answer":"I created another environment and installed jupyter lab in it. Ensured everything worked fine. Copied the missing file and pasted it in the base env folder. After making sure that I can launch Jupiter lab from base environment I removed the new environment.\nI think antivirus must have deleted that file so I created an exception in antivirus.","Q_Score":4,"Tags":"python-3.x,jupyter,jupyter-lab,miniconda","A_Id":62153353,"CreationDate":"2020-06-02T10:48:00.000","Title":"Unable to launch Jupyter lab from cmd in windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working with a company on a project to develop ML models for predictive maintenance. The data we have is a collection of log files. In each log file we have time series from sensors (Temperature, Pressure, MototSpeed,...) and a variable in which we record the faults occurred. The aim here is to build a model that will use the log files as its input (the time series) and to predict whether there will be a failure or not. For this I have some questions:\n1) What is the best model capable of doing this?\n2) What is the solution to deal with imbalanced data? In fact, for some kind of failures we don't have enough data. \nI tried to construct an RNN classifier using LSTM after transforming the time series to sub time series of a fixed length. The targets were 1 if there was a fault and 0 if not. The number of ones compared to the number of zeros is negligible. As a result, the model always predicted 0. What is the solution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":353,"Q_Id":62152465,"Users Score":0,"Answer":"Mohamed, for this problem you could actually start with traditional ML models (random forest, lightGBM, or anything of this nature). I recommend you focus on your features. For example you mentioned Pressure, MototSpeed. Look at some window of time going back. Calculate moving averages, min\/max values in that same window, st.dev. To tackle this problem you will need to have a set of healthy features. Take a look at featuretools package. You can either use it or get some ideas what features can be created using time series data. Back to your questions.\n1) What is the best model capable of doing this? Traditional ML methods as mentioned above. You could also use deep learning models, but I would first start with easy models. Also if you do not have a lot of data I probably would not touch RNN models.\n2) What is the solution to deal with imbalanced data? You may want to oversample or undersample your data. For oversampling look at the SMOTE package.\nGood luck","Q_Score":0,"Tags":"python,classification,lstm,recurrent-neural-network,prediction","A_Id":62153294,"CreationDate":"2020-06-02T12:52:00.000","Title":"Best model to predict failure using time series from sensors","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed pywikibot and set up the config as described in the instructions. However when I put \"importpywikibot\" at the top of my script it says \"No module named pywikibot\". Do I have to install pywikibot somewhere special?\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":62152681,"Users Score":0,"Answer":"First change \"importpywikibot\" to \"import pywikibot\"\nYou need to create your python file in the \"core\" directory otherwise it will say \"no module named pywikibot\".\nAfter installing pywikibot, you'll find core directory in C=> users=> your username => core\nAnd do it from your cmd prompt. It showed error when I used vs code but worked fine when I run the program in the cmd.","Q_Score":0,"Tags":"python,pywikibot","A_Id":63213503,"CreationDate":"2020-06-02T13:04:00.000","Title":"How to import pywikibot?","Data 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 customize axis titles in a Seaborn pairplot, e.g., I would like to use the formatted versions (r'$I_{bs}$') and (r'$k_{HL}$') instead of \"Ibs\" and \"kHL\" which are the column titles in the dataframe I use to generate the plot. How can I achieve this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":62154130,"Users Score":0,"Answer":"Problem solved. I named columns using formatted strings in defining the dataframe I used to create the pairplot:\ndf_red=pd.DataFrame(DataMatrix_red,columns=['shape',r'$d_n$',r'$\\nu_s$',r'$D_s$[%]',r'$I_{{bs}}$',r'$k_{{VssL}}$',r'$k_{{HL}}$'])","Q_Score":0,"Tags":"python,matplotlib,seaborn","A_Id":62332247,"CreationDate":"2020-06-02T14:18:00.000","Title":"Customizing axis titles in Seaborn pairplots","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a series ZigBee networks. Each network will be in close proximity to another, as such when all devices are turned on I need them to repeatedly look for their specified network and always join it. \nTo configure the network I have a coordinator device turned on and it will find up to 32 other devices. Once found I want the coordinator to set the remote devices Names (\"NI\") and PANID (\"ID\"). After using xbee.discover() I have a list of devices in my network. However I can not figure out how I can set the remote devices settings using MicroPython.\nCan you send AT Commands over MicroPython?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":62155423,"Users Score":0,"Answer":"Remote AT commands aren't currently supported via the MicroPython interface.  One would typically set ATNI and the PAN ID via the local serial interface (or BLE) during commissioning of the network.  But I can imagine scenarios where you'd want to interface with the I\/O pins of a remote device.\nYou'll need to put in a feature request to Digi International to include it in an upcoming release.","Q_Score":0,"Tags":"xbee,micropython","A_Id":62160573,"CreationDate":"2020-06-02T15:24:00.000","Title":"Send Remote AT Command to Xbee Device in MicroPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"This is my first question to here. I don't know how to set Border Radius for Tkinter Entry, Thanks for your Help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1050,"Q_Id":62156677,"Users Score":2,"Answer":"There is no option to set a border radius on the tkinter or ttk Entry widgets, or any of the other widgets in those modules. Tkinter doesn't support the concept of a border radius.","Q_Score":0,"Tags":"python,tkinter","A_Id":62158287,"CreationDate":"2020-06-02T16:26:00.000","Title":"How to set tkinter Entry Border Radius","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So as we know, Python doesn't have real threading because of the GIL (unless you go the Cython route and detach) but i can't seem to find info or documentation on a usecase.\nIf from my python script i run a Popen with the commands [dotnet test .....] and that code supports the native C# threads and processes and all of that, will my Python subprocess execute as native C# and handle as many threads as the script needs to or is it locked behind 1 process and 1 thread?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":62157808,"Users Score":1,"Answer":"Any sub-process you launch with Popen will behave as it normally does. Python's threading model won't be inherited by a non-Python process when you launch it from within a Python process.","Q_Score":0,"Tags":"python,subprocess,popen","A_Id":62158002,"CreationDate":"2020-06-02T17:27:00.000","Title":"Is a python subprocess allowed to use as many real threads as it can?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using Django 3.0 and I was wondering how to create a new database table linked to the creation of each user. In a practical sense: I want an app that lets users add certain stuff to a list but each user to have a different list where they can add their stuff. How should I approach this as I can't seem to find the right documentation... Thanks a lot !!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":90,"Q_Id":62159202,"Users Score":0,"Answer":"This is too long for a comment.\nCreating a new table for each user is almost never the right way to solve a problem.  Instead, you just have a userStuff table that maintains the lists.  It would have columns like:\n\nuserId\nstuffId\n\nAnd, if you want the stuff for a given user, just use a where clause.","Q_Score":0,"Tags":"python,sql,django,database","A_Id":62159631,"CreationDate":"2020-06-02T18:46:00.000","Title":"A new table for each user created","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How do I enable method autocompletion for discord.py in PyCharm? Until now I've been doing it the hard way by looking at the documentation and I didn't even know that autocomplete for a library existed. So how do I enable it?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1231,"Q_Id":62159638,"Users Score":1,"Answer":"The answer in my case was to first create a new interpreter as a new virtual environment, copy over all of the libraries I needed (there is an option to inherit all of the libraries from the previous interpreter while setting up the new one) and then follow method 3 from above. I hope this helps anyone in the future!","Q_Score":1,"Tags":"python,python-3.x,pycharm,discord,discord.py","A_Id":62162550,"CreationDate":"2020-06-02T19:12:00.000","Title":"How to enable PyCharm autocompletion for imported library (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":"One of the projects that I work on in Python is pretty big and uses a lot of libraries.\nI started developing it in Spyder then switched to VS Code.\nI also use conda environment.\nThe problem is with VS Code only: when I open VS Code itself and try to run the project - I get all kinds of import errors.\nHowever, if I open the conda terminal first and just type \"code\" in it and execute it - the VS Code opens, I can select my project and everything runs just fine, no errors.\nIn both cases the environment is the same, I did the Ctrl+Shift+P to select it, plus it shows as selected in the bottom left corner anyway. It's the default env.\nHow can I fix this so I don't have to start VS Code from conda terminal each time?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":62160037,"Users Score":0,"Answer":"at the conda the modules are installed by default.\nin vscode or any other of ides you have to install it manually.\nopen your terminal or cmd and type:\npip install module-name","Q_Score":0,"Tags":"python,visual-studio-code,conda","A_Id":62160420,"CreationDate":"2020-06-02T19:35:00.000","Title":"VS code runs python with no errors only if started from conda terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an API deployed on Cloud Run where each request results in a read + write to Cloud Datastore. A non-trivial amount of the requests are first timers (read from Datastore will return null), so adding caching in front of it may not be too helpful.\nOver the past month, the average wall time around calling Datastore and having the data (data = client.get(key, eventual=True)) is 48ms. The payloads are small (a list of dicts, with 10 elements on average, and each dict has two floats).\nI'm not sure if I should say that latency is high, but my API has a budget of 100ms to do all that it needs to do and return. If just the data fetching takes ~50% of that time, I'm looking for ways to optimize things.\nQuestions:\n\nIn general, how does 50ms sound for fairly small payloads, fetched by key, from within GCP?\nWhat should I expect (in terms of latency) from Memorystore within GCP?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":747,"Q_Id":62160701,"Users Score":4,"Answer":"Assuming you are using Cloud Run and Datastore on the same location, I would say that 50ms is around the expected latency you'd have for reading on datastore, the size of the payload does not matter as much for reads (10 - 1000 document reads do not make a big difference on time of processing\/propagating).\nSince you have such a small window for your API to operate, this could indeed be a problem if some unnexpected delays occur.\nI have never used Memorystore so I can't say what you could expect of actual latency but it might be a better option given that every ms to your app counts.","Q_Score":2,"Tags":"python,optimization,google-cloud-datastore,low-latency,google-cloud-memorystore","A_Id":62178198,"CreationDate":"2020-06-02T20:17:00.000","Title":"Google Cloud Datastore latency","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to make a list that adds dictionaries to it.\nI have done this many times but can't seem to find out why this happens. It should add the dictionary to the list and continue to the code but returns the error KeyError: '\"id\"'Here is my coderaid_damage.append(\"\"\"{\"id\":{}, \"damage\":{}, \"taken\":{}, \"streak\":{}}\"\"\".format(str(user), str(damage_dealt), str(damage_taken), \"1\"))\nI have tried using ' in place of \" (whilst removing the triple quotes) and using eval() but still the exact same error\nAny Ideas?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":431,"Q_Id":62161359,"Users Score":0,"Answer":"Welcome! Here is a solution with no ''' '''\nraid_damage.append({\"id\": user, \"damage\":damage_dealt, \"taken\":damage_taken, \"streak\":streak})","Q_Score":1,"Tags":"python,list,dictionary,append","A_Id":62161469,"CreationDate":"2020-06-02T21:02:00.000","Title":"python appending dictionaries to lists causes keyError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"\u2022   My script keeps running into \"Error 10182, reqID 1639:Failed to request live updates (disconnected)\u201d which is representative of the Historical Data Farm being inactive. \n\u2022   This error pops up during what is generally considered after hours (I'm trading FX). \n\u2022   I've tried adding print(util.globalErrorEvent). It prints everything 10s or so but no error was detected before or after the 10182 error.\n\u2022   I'm connected through Gateway and currently using a paper account to test. \n\u2022   After the error occurs if I look at my IB Gateway app \u2013 everything is green except Historical Data Farm. This line is yellow and the status is Inactive: cashhmds \n\u2022   If I then stop my program and restart it Gateway Historical Data Farm is switched to Green and everything starts working again (no Gateway restart needed).\nMy big question is how to flag that Historical Data Farm is inactive so that I can 'gracefully' disconnect and reconnect to reset the live updates? \nIf I could register that the Historical Data Farm was inactive then I could implement the logic to restart the connection. \n\u2022   If Historical Data Farm == inactive or if error = 10182 then I could implement a restart of the connection. \nOnce I hit this error real-time data updates stop forever until I stop my python script and restart it (basically restarting the connection process). The program doesn\u2019t exit or error out and other logic will continue (checking time to register when to close the program for the week for instance).","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":745,"Q_Id":62162127,"Users Score":1,"Answer":"What you are looking for is a reconciliation logic, which by definition differs from strategy to strategy. In a situation similar to what you mentioned, one of the approaches can be as follows:\n\nOn every iteration of the run, you should check whether you are connected to IB TWS or not using the app.isConnected() method. For example, if your trading frequency is 5 mins, you will check every 5 mins before your strategy logic executes.\n\nThe above point takes care of the connection between your client and IB TWS. Another check to implement is to see whether you are connected to the internet or not. In this case, you can ping to your broker's server (if they provide) or any public websites.\n\nIf you don't receive a response from the ping command, you set up a loop that keeps checking until your connection is restored.\n\nYou can run this check in a loop with some interval.\n\n\n\nIf you have a disconnection; upon reconnection:\n\n\n\nThe algorithm should check for all the open positions in the account. Ideally, those positions should be present in the account. If they are not, you need to define what to do based on your strategy logic. For example, adjust positions in your algorithm.\nFetch the historical data for whatever time the algorithm was disconnected. This is to ensure that your algorithm doesn't calculate incorrect technical or statistical indicators if any.\nSetup the streaming data again. TWS will do this by itself; you need to cancel your current subscription and subscribe again.","Q_Score":1,"Tags":"python,error-handling,interactive-brokers","A_Id":67615813,"CreationDate":"2020-06-02T22:08:00.000","Title":"How to set up an error handler for Interactive brokers using IB API or ib_insync? Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm fairly new to programming and need to write a program that will find the center of 4 discs (circles) that are located in each corner of a square image.\nI don't know the exact coordinates of the discs but have a very good approximation of them. How can I go about finding the location of the centers of each of the 4 discs?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2358,"Q_Id":62162318,"Users Score":0,"Answer":"The window will most likely draw images using the top left corner as X= 0, Y = 0. Circles tend to be drawn from the centre outwards, so the centre of the circle is most likely the (X,Y) coordinates used to draw the given circle. You can probably find a way to request the values for the circles coordinates depending how they're being drawn and what you're using to draw them. There are a number of ways of drawing to screen with python, so It depends how you are doing it. Can you provide a little more details?","Q_Score":1,"Tags":"python,image,detection","A_Id":62162417,"CreationDate":"2020-06-02T22:23:00.000","Title":"Finding the center of circles in an image","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently making a small hobby project where I use a Raspberry Pi Zero to control a set of RGB LED's.\nI've got a basic python app so far that is built on Flask that allows me to set up a web server so that the LED colours can be set remotely.\nMy main concern is that I'm self-taught as far as programming goes and I don't know squat about security.\nThe plan is essentially to be sending any port 80 traffic to the raspberry pi on my home network and give friends my IP. I may eventually get a domain name to simplify things.\nShould I have any security concerns when I set this up live full-time? I don't know if it's possible to access my private network via the raspberry pi or if I'm just being paranoid.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":199,"Q_Id":62162817,"Users Score":1,"Answer":"You can try putting your Raspberry PI on separate vlan and put your home devices on another vlan. Please note you need a router which supports vlan and configure it in a way that the both vlans cant talk to each other \nAlso, try using HTTPS for your webserver and don't run the webserver process as root user. If you want to go more crazy you can put a firewall.\nThese are generic suggestions for hardening the security for any web app.","Q_Score":1,"Tags":"python,security,flask,raspberry-pi","A_Id":62162893,"CreationDate":"2020-06-02T23:12:00.000","Title":"Raspberry Pi as a web server security","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 developing a mobile application using the react native library with the JavaScript language. On the other hand, I have an image processing code that I wrote in python. Is it possible to combine them? Can I put python in my React native code?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":62163119,"Users Score":0,"Answer":"No this is not possible. What are you trying to achieve? Why do you thing that embedding python in your React native code is the way to achieve it?","Q_Score":1,"Tags":"javascript,python,react-native","A_Id":62163782,"CreationDate":"2020-06-02T23:52:00.000","Title":"How to access python library in javascript react native library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python script that hits the \/v3\/surveys?pagenum end point. My plan was to calculate the number of responses in the Json and the number of pages (rounded up from 50\/page) and compare this with data already brought in from that endpoint. My thinking was if the number of responses in the DB and the Site differed, I could just bring in the last page or pages from the SurveyMonkey API\nThe code works but what I've found is the new Surveys don't necessarily appear on the last pages They can be on any page. How do I just bring in new Content without re downloading everything. Is this the case with every other endpoint as well? I've looked through the api on the Survey Monkey Site but didn't see anything geared towards getting new content\nI have a limited number of api calls and don't really want to download everything each time as this data changes frequently. Any guidance would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":229,"Q_Id":62163671,"Users Score":0,"Answer":"Register a webhook. It will tell you when there is a new response.","Q_Score":1,"Tags":"python,surveymonkey","A_Id":62272844,"CreationDate":"2020-06-03T01:09:00.000","Title":"Survey Monkey - Retrieve new Responses only via API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I don't have enough space on my C drive (PRIMARY) and can't install packages due to not having enough space, I have installed my python onto my D drive.\nhowever when i try to install i get this error\nerror: could not install packages due to an environmenterror: [errno 28] no space left on device\nI have even made a symlink (directory) to point the pip folder from my windows user profile appdata folder to a folder named pip on my d drive, even when doing this I still get the error listed above.\nThanks for the support and help <3\nEdit: I have tried using a virtual enviroment, but still without success","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":238,"Q_Id":62165923,"Users Score":1,"Answer":"Did you used the --target when installed the packages ?","Q_Score":0,"Tags":"python,windows,pip","A_Id":62166079,"CreationDate":"2020-06-03T05:37:00.000","Title":"Python PIP Install Cache Path [windows]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large CSV file with about 10000 rows of text information and each row of my dataset consists of a number of lines. However I just want to read say first 20 lines of each of the rows of my CSV file. \nI came across n_rows parameter in pandas read_csv method which helps us in limiting the number of rows of the dataset that we would like to load. Is there also a way where we could only read first 20 lines of data from each of the rows in pandas?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":632,"Q_Id":62168254,"Users Score":1,"Answer":"You can read in the csv with df = pd.read_csv('path\\file.csv') and than just select the first 20 rows by df_new = df.head(20). Is that what you where thinking of?","Q_Score":0,"Tags":"python,pandas,csv,dataframe","A_Id":62168448,"CreationDate":"2020-06-03T08:22:00.000","Title":"Pandas - Read only first few lines of each rows","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large CSV file with about 10000 rows of text information and each row of my dataset consists of a number of lines. However I just want to read say first 20 lines of each of the rows of my CSV file. \nI came across n_rows parameter in pandas read_csv method which helps us in limiting the number of rows of the dataset that we would like to load. Is there also a way where we could only read first 20 lines of data from each of the rows in pandas?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":632,"Q_Id":62168254,"Users Score":0,"Answer":"If TiTo's answer is not what you are looking for, maybe the iloc method is. You can store the first 20 rows by doing firstRows = df.iloc[:20].\nHowever, if you only ever need the first 20 rows, you shouldn't load the whole file into memory. As you mentioned, this can be achieved with the nrows parameter.","Q_Score":0,"Tags":"python,pandas,csv,dataframe","A_Id":62168592,"CreationDate":"2020-06-03T08:22:00.000","Title":"Pandas - Read only first few lines of each rows","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Should the inference model in a chatbot model with keras lstm, have the same amount of layers as the main model or it doesnt matter?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":62169402,"Users Score":1,"Answer":"I don't know what you exactly mean by inference model. \nThe number of layers of a model is an hyperparameter that you tune during training. Let's say that you train an LSTM model with 3 layers, then the model used for inference must have the same number of layers and use the weights resulting from the training.\nOtherwise, if you add non trained layer when inference, the results won't make any sense.\nHope this helps","Q_Score":1,"Tags":"python,keras,lstm","A_Id":62171243,"CreationDate":"2020-06-03T09:26:00.000","Title":"LSTM, Keras : How many layers should the inference model have?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know there is a lot of debate within this topic.\nI made some research, I looked into some of the questions here, but none was exactly it.\nI'm developing my app in Django, using Python 3.7 and I'm not looking to convert my app into a single .exe file, actually it wouldn't be reasonable to do so, if even possible.\nHowever, I have seen some apps developed in javascript that use bytenode to compile code to .jsc\nIs there such a thing for python? I know there is .pyc, but for all I know those are just runtime compiled files, not actually a bytecode precompiled script.\nI wanted to protect the source code on some files that can compromise the security of the app. After all, deploying my app means deploying a fully fledged python installation with a web port open and an app that works on it.\nWhat do you think, is there a way to do it, does it even make sense to you?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":62169485,"Users Score":0,"Answer":"The precompiled (.pyc) files are what you are looking for. They contain pre-optimized bytecode that can be run by the interpreter even when the original .py file is absent. \nYou can build the .pyc files directly using python -m py_compile <filename>. There is also a more optimized .pyo format that further reduces the file size by removing identifier names and docstrings. You can turn it on by using -OO.\nNote that it might still be possible to decompile the generated bytecode with enough effort, so don't use it as a security measure.","Q_Score":1,"Tags":"python,django","A_Id":62170274,"CreationDate":"2020-06-03T09:30:00.000","Title":"How to compile single python scripts (not 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":1},{"Question":"I am using Python's ProcessPoolExecutor to run multiple processes in parallel and process them as any of them finishes. Then I look at their output and as soon as at least one of them gives satisfying answer I want to exit the program.\nHowever, this is not possible since upon calling pool.shutdown(wait=False) I will have to wait for all active tasks in the pool to finish before I can exit my script.\nIs there a way to kill all the remaining active children and exit?\nAlso, is there a better way to stop as soon as at least one child returns the answer we are waiting for?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":368,"Q_Id":62170309,"Users Score":1,"Answer":"What you're doing is not quite clear, but executors strike me as the wrong tool entirely.\nmultiprocessing.Pool seems much more suitable, and allows doing exactly what you're asking for: you can iterate on imap_unordered (or apply_async and poll the results), and once you have what you were looking for just terminate() the pool then join() it.","Q_Score":1,"Tags":"python,multiprocessing,executor,process-pool","A_Id":62170459,"CreationDate":"2020-06-03T10:11:00.000","Title":"Killing processes in ProcessPoolExecutor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"For example, I want to split the string num, '123', by its characters (1, 2 and 3) and put it in a list, numlist. However, using num.split() it gives me ['123']when I want ['1','2','3']. Is this possible?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":62171817,"Users Score":0,"Answer":"num = '123'\nstring list\na = list(num); print(a)\nlist of integers\nx = [int(num) for num in a]; print(x)","Q_Score":0,"Tags":"python,list,split","A_Id":62172499,"CreationDate":"2020-06-03T11:33:00.000","Title":"How can I put a split string into a list where the items are the chars?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background: I'm using a Python script with os.system() to repeatedly call a command line program to run test cases. The program being tested returns zero for normal operation and a negative value for error conditions. I compare this value against what is expected (not always zero) as part of determining pass\/fail. \nThe problem is that a normally exiting test case is returning zero, but os.system() is returning -1073740940. So far, other non-zero returns are working as expected, though the sample is small. \nI'm fairly confident the called program is returning zero because I output the return value to std out just before I return.  Also, if run the program with the same inputs from the command line or a batch file, the return value is zero. \nPossibly related, the C++ program generates a log file using ofstream with the same content as the command line - the same buffer is sent to std::cout and the log file. When controlled by the os.system() call, the log file content stops about 80% of the way into the execution of the program even though the cout information continues normally. As with the return value if run with the same inputs from the command line or a batch file, the log file completes correctly and has the same content as the terminal. \nBehavior is the same under Python 2.7 and 3.8 for both the return value and log file issues. \nMy question is: How do I diagnose this?  I'm not sure what else to try.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":190,"Q_Id":62174199,"Users Score":1,"Answer":"So the short answer is that the value I'm getting is the exit code from the program, unless Windows feels it has something important to say. \nIn this case a DLL I was calling was corrupting the heap and cause windows to abort the execution. To get the actual 32 bit Windows return code and not a sign extended version I needed to AND it with 0xffffffff. I don't know if I can answer my own question, but gelonida set me on the right trail the answer.","Q_Score":1,"Tags":"python,c++,windows-10","A_Id":62472275,"CreationDate":"2020-06-03T13:36:00.000","Title":"Python os.system() returning bad value","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I identify a vector in Python?\nLike does it have a single dimension or is it n-dimensions, I got really confused when trying to understand this in NumPy.\nAlso, what's the difference between static memory allocation and a dynamic one in vectors?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":177,"Q_Id":62174437,"Users Score":0,"Answer":"A vector has a single dimension and is create with method such as numpy.array and numpylinspace. A n-dimension array would be a matrix created with methods such as zeros or numpy.random.uniform(...). You  dont have to use numpy to use vectors in python. You can simply use the basic array type.\nIn python you usually dont have to worry about memory allocation. A dynamic memory allocation means that elements can added or removed to the vector whereas in a static memory allocation, there would be a fixed number of elements in the vector.","Q_Score":0,"Tags":"python,numpy,memory,vector,dimension","A_Id":62174665,"CreationDate":"2020-06-03T13:46:00.000","Title":"Structure of a vector in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using pycharm in my mac but while importing pygame, there is no window popping up. I have copied some codes from google about pygames but it is also not working. I think there might some settings problem in mac os because in my pc the code is working perfectly. Another information is that no error is showing, which means no problem with code or interpreter.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":62174721,"Users Score":0,"Answer":"For me, and other people, Python 3.8 doesn't work with PyGame for some reason. Try using Python 3.7.","Q_Score":0,"Tags":"python,pygame,pycharm","A_Id":62175202,"CreationDate":"2020-06-03T13:58:00.000","Title":"No Windows popping up while using pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get the below  error while trying to fetch rows from Excel using as a data frame. Some of the columns have very big values like 1405668170987000000, while others are time stamp columns having values like 11:46:00.180630.\nI did convert the format of the above columns to text. However, I'm still getting the below error for a simple select statement (select * from df limit 5):\n\nOverflow Error: Python int too large to convert to SQLite INTEGER","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":62176746,"Users Score":0,"Answer":"SQLite INTEGERS are 64-bit, meaning the maximum value is 9,223,372,036,854,775,807.\nIt looks like some of your values are larger than that so they will not fit into the SQLite INTEGER type. You could try converting them to text in order to extract them.","Q_Score":0,"Tags":"python,python-3.x","A_Id":62176901,"CreationDate":"2020-06-03T15:32:00.000","Title":"overflow error in Python using dataframes","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get the below  error while trying to fetch rows from Excel using as a data frame. Some of the columns have very big values like 1405668170987000000, while others are time stamp columns having values like 11:46:00.180630.\nI did convert the format of the above columns to text. However, I'm still getting the below error for a simple select statement (select * from df limit 5):\n\nOverflow Error: Python int too large to convert to SQLite INTEGER","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":62176746,"Users Score":0,"Answer":"SQL integer values have a upper bound of 2**63 - 1. And the value provided in your case 1405668170987000000 is simply too large for SQL.\n\nTry converting them into string and then perform the required operation","Q_Score":0,"Tags":"python,python-3.x","A_Id":62176934,"CreationDate":"2020-06-03T15:32:00.000","Title":"overflow error in Python using dataframes","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am facing a problem of improving the training speed \/ efficiency of a Tensorflow implementation of point cloud object detection algorithm.\nThe input data is a [8000, 100, 9] float32 tensor, with a size roughly 27MB per sample. On a batch size of 5, data loading becomes a bottleneck in training as most of the time GPU utlization rate is 0% until data arrives.\nI have tried the following methods to increase data loading speed.\n\nUse num_parallel_calls in tf.Dataset .map API, and use multiple threads for reading this big tensor. The problem is .map wraps a py_fun which is subject to Global Interpreter Lock and thus multi-threading does not improve I\/O efficiency.\nUse tf.Dataset .interleave API. Since it's also multi-threading based, it has the same problem as 2.\nUse TFRecord format. This is even slower than method 1 and 2. Possibility is TFRecord will convert tensor to numpy, then serialize numpy to bytes, then wrap this bytes to tensorflow structure and write to disk. Numpy to Tensor takes a long time for my data as measured by tf.convert_to_tensor().\n\nAny suggestions how to move forward would be helpful. Thanks!\nFollow up on comments\n\nAm I using slow disks? Data is stored on a mounted disk. Could be a reason. \nCan the data be fit into GPU memory? Unfortunately no. There are ~70,000 samples. I tried cache a small dataset into RAM and GPU utlization rate is 30%~40%, which is probably the highest expectation for this particular network.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":710,"Q_Id":62178275,"Users Score":3,"Answer":"Some ideas: \n\nYou should use a combination of 1,2 and 3. If you save your files as TFRecords, you can read them in parallel, that's what they are designed for. Then, you will be able to use num_parallel_calls and interleave, because that way you don't have to wrap a py_func. \n.map doesn't have to wrap a .py_func, you could for example use tf.keras.utils.get_file. That way you also avoid using py_func and use num_parallel_calls efficiently. I still recommend using TFRecords, they are designed for this use case. \nAnother option is to use an SSD to store your data instead of a Hard Disk. \nYou can also look into the .cache function of the tf.Dataset API. Maybe you can try loading a random subset of the data, training multiple eopchs on that, and then in the mean time fetch another subset of the data (using tf.prefetch), and then train multiple epochs on that, and so on. This idea is more of a long shot as it might affect performance, but it just might work in your case.","Q_Score":2,"Tags":"python,tensorflow","A_Id":62179455,"CreationDate":"2020-06-03T16:50:00.000","Title":"Increase I\/O bound tensorflow training speed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can anyone tell me how to install turicreate on windows 7? I am using python of version 3.7. I have tried using pip install -U turicreate to install but failed.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":178,"Q_Id":62179984,"Users Score":0,"Answer":"I am quoting from Turicreate website:\nTuri Create supports:\n\nmacOS 10.12+\nLinux (with glibc 2.12+)\nWindows 10 (via WSL)\n\nSystem Requirements\n\nPython 2.7, 3.5, or 3.6\nPython 3.7 macOS only\nx86_64 architecture\n\nSo Windows 7 is not supported in this case.","Q_Score":0,"Tags":"python-3.x","A_Id":65681216,"CreationDate":"2020-06-03T18:20:00.000","Title":"How to install turicreate on windows 7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I created a aws windows instance (linux is sadly no option in this particular case) on which i deployd a python script using flask-restful. \nI added inbount traffic rules to allow http traffic on port 80. \nThe Flask api is being hostet on host=0.0.0.0, port=80 and debug is False. \nThe api is reachable via browser on the server running it.\nSadly im not able to reach the api from external servers. I thought it might be a internal issue between public and internal ip so i tryd reverse proxing that with nginx with no result as well. \nDoes somebody have an idea what i could do.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":62184248,"Users Score":1,"Answer":"Based on the comments, the issue was windows firewall. \nThe solution was to allow the connection in the firewall.","Q_Score":1,"Tags":"python,windows,amazon-web-services,flask,firewall","A_Id":62184660,"CreationDate":"2020-06-03T23:12:00.000","Title":"Allow traffic on AWS windows instance with flask restful","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I searched about this a lot but I could not find anything. I haven't tried much with python sockets, just made a system where a host and a client can message each other. What I want to know is when a client is connected to a host via python socket, does it make a connection outside the program too? Like can we play any lan game after being connected via sockets for example ??","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":212,"Q_Id":62184433,"Users Score":0,"Answer":"The sockets are not specific to any language; they are the logical endpoint offered by the underlying API to the userspace. You can create TCP\/IP sockets in any language which supports networking.\n\"What I want to know is when a client is connected to a host via python socket, does it make a connection outside the program too?\"\nThat depends on which layer you are looking at. Consider the first three layers of the TCP\/IP model from the top (Application, Transport, Network).\n\nApplication Layer:  All the underlying of the internet are abstracted from the Application layer. Now, if you see whether a connection is established outside your program, that purely depends on what protocol they are following. If you consider HTTP protocol, it is mostly stateless or connectionless (If cookies are ignored). But if you look at SSL, some handshakes happen, and the session state is maintained in both the client-side and server-side.\nTransport Layer: The two famous protocols in this layer are TCP and UDP. With TCP before any data transfer, a TCP connection is established by performing a three-way handshake. But in the case of UDP, no such term like a connection is defined. \nInternet Layer: Though the well known and most commonly used network architecture is the Internet, there are some other architectures like ATM CBR and ATM ABR. The Internet architecture falls under the category of datagram networks, meaning there is no state maintained, the link-layer switches, or routers just forward the packets. In contrast, ATM architecture falls under the category of Virtual-circuit networks. Each connection at the network layer is monitored to deliver the services. e.g., in the case of ATM CBR, the connections are monitored to deliver a constant bit rate service, and in the case of ATM ABR, the connections are monitored to deliver a minimum bit rate service.\n\nHere I just summarized the connection setup for the first three layers, and the same things can happen with the other layers as well. \nTo conclude, whether the connection is established outside your programs? It depends on all these above factors, what application layer protocol you are using, what transport layer protocol you are using, and what is the underlying network architecture... etc. And you can also see a scenario where the connection establishment happens at the network layer but not in the application layer, that's where all these network abstractions come. You can blissfully ignore the underlying details!","Q_Score":0,"Tags":"python,sockets,networking,connection,vpn","A_Id":62190050,"CreationDate":"2020-06-03T23:31:00.000","Title":"Does python socket basically connect host and client over internet like a computer to computer VPN?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am relatively new to the field of NLP\/text processing. I would like to know how to identify domain-related important keywords from a given text.\nFor example, if I have to build a Q&A chatbot that will be used in the Banking domain, the Q would be like: What is the maturity date for TRADE:12345 ? \nFrom the Q, I would like to extract the keywords: maturity date & TRADE:12345.\nFrom the extracted information, I would frame a SQL-like query, search the DB, retrieve the SQL output and provide the response back to the user.\nAny help would be appreciated.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":62187062,"Users Score":0,"Answer":"So, this is where the work comes in. \nNormally people start with a stop word list. There are several, choose wisely. But more than likely you'll experiment and\/or use a base list and then add more words to that list.\nDepending on the list it will take out \n\n\"what, is, the, for, ?\"\n\nSince this a pretty easy example, they'll all do that. But you'll notice that what is being done is just the opposite of what you wanted. You asked for domain-specific words but what is happening is the removal of all that other cruft (to the library).\nFrom here it will depend on what you use. NLTK or Spacy are common choices. Regardless of what you pick, get a real understanding of concepts or it can bite you (like pretty much anything in Data Science).\nExpect to start thinking in terms of linguistic patterns so, in your example:\n\nWhat is the maturity date for TRADE:12345 ? \n\n'What' is an interrogative, 'the' is a definite article, 'for' starts a prepositional phrase.\nThere may be other clues such as the ':' or that TRADE is in all caps. But, it might not be.\nThat should get you started but you might look at some of the other StackExchange sites for deeper expertise. \nFinally, you want to break a question like this into more than one question (assuming that you've done the research and determined the question hasn't already been asked -- repeatedly). So, NLTK and NLP are decently new, but SQL queries are usually a Google search.","Q_Score":0,"Tags":"python,nlp,nltk,chatbot,text-processing","A_Id":62187531,"CreationDate":"2020-06-04T04:50:00.000","Title":"Identify domain related important keywords from a given text","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So i installed both version 3.7.6 and 3.8.3 and i was trying to fix the \"pip is not recognized\" problem through YouTube,google etc.. but they all have the same similar step and it is to find the \"pip.exe\" file and add it to the system  yet i don't have a \"pip.exe\" file nor do i have a \"Scripts\" file i searched in the easy access (because that's where i find anything there) but i seemed to have no luck i also searched through the Python files but no luck whatsoever, am i doing something wrong?...maybe i installed a \"wrong version\" or something","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":318,"Q_Id":62189394,"Users Score":0,"Answer":"Upon installation of Python, the PATH environment variable is updated to point to the directory where Python is installed.\n1) Check PATH, if there exists no entry for Python, add the address pointing to your python.exe(Default path for Py3.7 is C:\\Program Files\\Python37 and for Py3.8 is C:\\Program Files\\Python38).\n2) Better yet just reinstall both of them, also please check the box which asks you to Disable the max PATH length and also the add to PATH checkbox.","Q_Score":0,"Tags":"python,python-3.x,pip","A_Id":62189609,"CreationDate":"2020-06-04T07:46:00.000","Title":"Cant find the pip.exe file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I ran over following problem:\nIf I try to split the ssh terminal in pycharm it just opens a local powershell instead of a second remote shell. Is this normal? Do I have to change a default or something like this?\nI found nothing to this problem.\nMy wish endresult is to see 2 ssh terminals next to each other and not to have to switch tabs all the time. Is this possible?`","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":62190539,"Users Score":0,"Answer":"Found a workaround which is not pretty nice but works.\nOpen ssh shells. Right click on them and select \"Move to Editor\" then you can put them one for one on the other screen and place each window as you like. \nIf there is a better way please let me know.","Q_Score":0,"Tags":"python,pycharm","A_Id":62190929,"CreationDate":"2020-06-04T08:51:00.000","Title":"PyCharm SSH Terminal split","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to retrieve versions of all packages from specific index. I'm trying to sending GET request with \/user\/index\/+api suffix but it not responding nothing intresting. I can't find docs about devpi rest api :( \nHas anyone idea how could I do this?\nBest regards, Matt.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":218,"Q_Id":62194793,"Users Score":2,"Answer":"Simply add header Accept: application\/json - it's working!","Q_Score":2,"Tags":"python,python-3.x,devpi","A_Id":62222635,"CreationDate":"2020-06-04T12:37:00.000","Title":"Devpi REST API - How to retrieve versions of packages","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 find out what the best tool is for my project.\nI have a lighttpd server running on a raspberry pi (RPi) and a Python3 module which controls the camera. I need a lot of custom control of the camera, and I need to be able to change modes on the fly. \nI would like to have a python script continuously running which waits for commands from the lighttpd server which will ultimately come from a user interacting with an HTML based webpage through an intranet (no outside connections). \nI have used Flask in the past to control a running script, and I have used FastCGI to execute scripts. I would like to continue using the lighttpd server over rather than switching entirely over to Flask, but I don't know how to interact with the script once it is actually running to execute individual functions. I can't separate them into multiple functions because only one script can control the camera at a time. \nIs the right solution to set up a Flask app and have the lighttpd send requests there, or is there a better tool for this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":62195974,"Users Score":0,"Answer":"You have several questions merged into one, and some of them are opion based questions as such I am going to avoid answering those. These are the opinion based questions.\n\nI am trying to find out what the best tool is for my project.\nIs the right solution to set up a Flask app and have the lighttpd send requests there\nIs there a better tool for this?\n\nThe reason I point this out is not because your question isnn't valid but because often times questions like these will get flagged and\/or closed. Take a look at this for future referece.\nNow to answer this question: \n\" I don't know how to interact with the script once it is actually running to execute individual functions\"\nTry doing it this way:\n\nModify your script to use threads and\/or processes.\nYou will have for example a continously running thread which would be the camera.\nYou would have another non blocking thread listening to IO commands.\nYour IO commands would be comming through command line arguments.\nYour IO thread upon recieving an IO command would redirect your running camera thread to a specific function as needed.\n\nHope that helps and good luck!!","Q_Score":0,"Tags":"python,flask,lighttpd,pi,picamera","A_Id":62197672,"CreationDate":"2020-06-04T13:32:00.000","Title":"Use HTML interface to control a running python script on a lighttpd 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":0,"Web Development":1},{"Question":"I am trying to find out what the best tool is for my project.\nI have a lighttpd server running on a raspberry pi (RPi) and a Python3 module which controls the camera. I need a lot of custom control of the camera, and I need to be able to change modes on the fly. \nI would like to have a python script continuously running which waits for commands from the lighttpd server which will ultimately come from a user interacting with an HTML based webpage through an intranet (no outside connections). \nI have used Flask in the past to control a running script, and I have used FastCGI to execute scripts. I would like to continue using the lighttpd server over rather than switching entirely over to Flask, but I don't know how to interact with the script once it is actually running to execute individual functions. I can't separate them into multiple functions because only one script can control the camera at a time. \nIs the right solution to set up a Flask app and have the lighttpd send requests there, or is there a better tool for this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":62195974,"Users Score":1,"Answer":"I have used Flask in the past to control a running script, and I have used FastCGI to execute scripts.\n\nGiven your experience, one solution is to do what you know.  lighttpd can execute your script via FastCGI.  Python3 supports FastCGI with Flask (or other frameworks).  A python3 app which serially processes requests will have one process issuing commands to the camera.\n\nI would like to continue using the lighttpd server over rather than switching entirely over to Flask, but I don't know how to interact with the script once it is actually running to execute individual functions.\n\nConfigure your Flask app to run as a FastCGI app instead of as a standalone webserver.","Q_Score":0,"Tags":"python,flask,lighttpd,pi,picamera","A_Id":62200945,"CreationDate":"2020-06-04T13:32:00.000","Title":"Use HTML interface to control a running python script on a lighttpd 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":0,"Web Development":1},{"Question":"please can anyone help me to sort out this issue. when i try to import pygame it's not working and giving me this error \n#\nimport pygame\nImportError: No module named pygame\ni'm using python 3.8 and os catalina \nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":405,"Q_Id":62196559,"Users Score":0,"Answer":"If your import statement is # import pygame then remove the # symbol\nOpen the terminal and run pip install pygame and then try to import pygame\nIf you are using any virtual environment first activate the virtual environment from the project location and then run the above command","Q_Score":0,"Tags":"python,pygame","A_Id":62196603,"CreationDate":"2020-06-04T14:01:00.000","Title":"pygame isn't working on visual studio code (I'm using mac os catalina)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe with similar schema, I need to append the data into the AVRO file. I don't like to add the avro file into folder as a part. For your information, my AVRO file is not into the folder as a part. Can you please help me to solve the task.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":478,"Q_Id":62197112,"Users Score":0,"Answer":"You can write the data by using mode overwrite while writing the dataframe.\nBut the part file is created as spark is distributed processing and each executor spits out a files based on the amount of data","Q_Score":1,"Tags":"python-3.x,dataframe,pyspark,avro,spark-avro","A_Id":62199635,"CreationDate":"2020-06-04T14:26:00.000","Title":"How to append data in existing AVRO file using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to search for multiple words using the Twint Python Library. However, I can only find guidance on searching for one word within tweets. So, for example, \"twint -s \"pregnant\" --since \"2020-03-01 13:13:59\" -o \"sample.csv\" --csv\" gathers tweets that contain the word pregnant. When I add ...-s \"pregnant -s \"COVID,\" the code runs, but gathers tweets containing the word pregnant or COVID. How do I search for multiple words? Even better would be the ability to search multiple words using and\/or.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2644,"Q_Id":62198077,"Users Score":-1,"Answer":"There are probably more elegant ways of doing this, but grep actually works.","Q_Score":0,"Tags":"python,web-scraping,twitter,twint","A_Id":63363015,"CreationDate":"2020-06-04T15:12:00.000","Title":"Search multiple words in Twint Python Library","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can I get the clarification for the below question?\nGiven that 2 nodes one is R\/W and another was a backup node, the backup node can have out of sync data, I have give few APIs like load, extract metadata, delete, update.\nCan any tell me that what is algorithm can be used that the end of the algorithm both nodes have the same data","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":108,"Q_Id":62198740,"Users Score":0,"Answer":"There are a few different ways you can do this.\n\nEvery write to the R\/W node you write to the backup node before returning.\n\nPros\n\nLow complexity\nGood if your application issues way more writes than reads.\nConsistent backup\n\nCons\n\nSlow writes\n\n\nWith every write to the to the R\/W node, asynchronously write to the backup  node (you can return the write to the R\/W node before the writing to the backup completes).\n\nPros\n\n\nFaster writes\n\nCons\n\n\nData on backup may be out of sync for a few miliseconds\/seconds.\n\n\n\nIt is normally okay for your backup to have out of sync data for a few seconds. Depending on your application requirements, it won't be a big deal if you miss the last few milliseconds of data. If strong consistency between the backup and your R\/W node is absolutely necessary then go for option 1.","Q_Score":0,"Tags":"python,algorithm,data-structures,distributed-system","A_Id":62289748,"CreationDate":"2020-06-04T15:45:00.000","Title":"How to sync data between master and slave node in distributed systems","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the pho MQTT client library successfully to connect to AWS. After the mqtt client is created, providing the necessary keys and certificates is done with a call to client.tls_set() This method requires file paths to root certificate, own certificate and private key file.\nAll is well and life is good except that I now need to provide this code to external contractors whom should not have direct access to these cert and key files. The contractors have a mix of PC and macOS systems. On macOS we have keychain I am familiar with but do not know how to approach this with python - examples\/library references would be great. On the PC I have no idea which is the prevalent mechanism to solve this.\nTo add to this, I have no control over the contractor PCs\/Macs - i.e., I have no ability to revoke an item in their keychain. How do I solve this?\nSorry for being such a noob in security aspects. No need to provide complete examples, just references to articles to read, courses to follow and keywords to search would be great - though code examples will be happily accepted also of course.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":22,"Q_Id":62201091,"Users Score":1,"Answer":"Short answer: you don't.\nLonger answer:\nIf you want them to be able connect then you have no choice but to give them the cert\/private key that identifies that device\/user.\nThe control you have is issue each contractor with their own unique key\/cert and if you believe key\/cert has been miss used, revoke the cert at the CA and have the broker check the revocation list.\nYou can protect the private key with a password, but again you have to either include this in the code or give it to the contractor.\nEven if the contractors were using a device with a hardware keystore (secure element) that you could securely store the private key in, all that would do is stop the user from extracting the key and moving it to a different machine, they would still be able to make use of the private key for what ever they want on that machine.\nThe best mitigation is to make sure the certificate has a short life and control renewing the certificate, this means if a certificate is leaked then it will stop working quickly even if you don't notice and explicitly revoke it.","Q_Score":0,"Tags":"python,security,mqtt,tls1.2","A_Id":62203164,"CreationDate":"2020-06-04T17:52:00.000","Title":"How to prevent direct access to cert files when connecting MQTT client 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":"Maps give O(1) look-up. Can't we go through the array once and build a map corresponding to its index (the opposite of array) and when we want to search something we can call map[VALUE] and it will return the index.\nIt might not work for large values in array but assuming a[i]<10^5, can't we do this instead of binary search? Then, each query will be O(1). \nP.S: i did mean unordered map..","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":342,"Q_Id":62201467,"Users Score":1,"Answer":"Here are the problems you might want to consider - \n\nYou can't store multiple elements of the same value in map\nThe lookup time is O(log(n)) and not O(1)\nIt's not magic that happens in map which allows us to access it in lesser time. There's an hashing process going on in the background in unordered_map which gives O(1)and that takes time as well. So, the big O hides a big constant time factor. Standard map gives you a O(logn) lookup, same time complexity as binary search in an array.\n\n\nThe average time complexity of searching you get is about the same. The main problem you will have using standard maps in C++ is that it won't be able to hold  multiple elements that have same values. One advantage that you might get using map is the deletion and insertion time will be O(logn).\nSo, if you know that the dataset you will be working on doesn't have duplicate elements and\/or there will be frequent addition\/deletion of elements, then you can surely consider map as the better alternative in this case","Q_Score":2,"Tags":"python,c++,algorithm,data-structures","A_Id":62201590,"CreationDate":"2020-06-04T18:13:00.000","Title":"Can we use maps for searching instead of binary search?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Maps give O(1) look-up. Can't we go through the array once and build a map corresponding to its index (the opposite of array) and when we want to search something we can call map[VALUE] and it will return the index.\nIt might not work for large values in array but assuming a[i]<10^5, can't we do this instead of binary search? Then, each query will be O(1). \nP.S: i did mean unordered map..","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":342,"Q_Id":62201467,"Users Score":0,"Answer":"As the exact running time will depend on the length and type of the keys, their distribution, their number, it is advisable to benchmark for your particular application.","Q_Score":2,"Tags":"python,c++,algorithm,data-structures","A_Id":62202384,"CreationDate":"2020-06-04T18:13:00.000","Title":"Can we use maps for searching instead of binary search?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a automation script, in which openpyxl writes some data into Excel file. \nAnd that Excel file has some Formulas.\nOn next step i want to fetch that formulated cell value in python using openpyxl or Pandas, but OpenpyXl return as None and pandas return as Nan .\nI know about Xlwings, but unfortunately xlwings doesn't work in Linux. \nIf there are any other workaround and working in Linux, please let me know. Thanks in Advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":379,"Q_Id":62201973,"Users Score":0,"Answer":"You probably need to save the document first and then reopen it. You could try using xlwings or the win32 module to save as.","Q_Score":0,"Tags":"python,pandas,excel-formula,openpyxl,xlwings","A_Id":62523683,"CreationDate":"2020-06-04T18:44:00.000","Title":"How to fetch Value from Excel cell with formula ? Openpyxl data_Only flag doesn't work properly","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"On the official Tensorflow Lite website they show the support for GPU acceleration for Android and iOS but they don't say anything about support for Raspberry Pi.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":3569,"Q_Id":62202550,"Users Score":-1,"Answer":"You cant use the raspberry Pi GPU for machine learning. First, it doesnt meet the hardware requirements for most DL models and second you probably need a Nvidia GPU. What you are looking for is a Jetson Nano from nvidia, which is like a RPi but has a GPU that supports cuda. These are made to deploy machine learning models, check it out!","Q_Score":5,"Tags":"python,deep-learning,gpu,tensorflow-lite,raspberry-pi4","A_Id":62202935,"CreationDate":"2020-06-04T19:20:00.000","Title":"Is there a way to get GPU acceleration on Raspberry Pi 4 for Deep Learning?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do you decide on denoting a member function in C++ and\/or python\nas static?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":62203286,"Users Score":0,"Answer":"When your member function doesn't use any of the member variables, and doesn't call any other nonstatic member functions (of the same class), it can be static itself.","Q_Score":0,"Tags":"python,c++","A_Id":62203381,"CreationDate":"2020-06-04T20:08:00.000","Title":"How do you decide on denoting a member function in C++ and\/or python as static?","Data 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":"Due to the company policy, I cannot upgrade the vs code version. My vs code version is 1.39.2. \nI want to the install python extension and got the error on title. I downloaded the vsix and tried to install it manually and got the same error. \nWhy not provide the old version of the extension to download?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3611,"Q_Id":62203296,"Users Score":2,"Answer":"I'm a developer on this extension. In the marketplace tab in VSCode you can right click the python extension and select \"Install another version\" when you do that it will pop up a list of all the old versions of the extension. This should allow you to go back and find the version that works for your VSCode.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":62203567,"CreationDate":"2020-06-04T20:08:00.000","Title":"Unable to install extension 'ms-python.python' as it is not compatible with VS Code '1.39.2'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"im very new in programming and i learn Python.\nI'm coding on mac btw.\nI'd like to know how can i import some modules in VS code. \nFor exemple, if i want to use the speedtest module i have to download it (what i did) and then import it to my code. But it never worked and i always have the error no module etc.\nI used pip to install each package, i have them on my computer but i really don't know to import them on VS code. Even with the terminal of the IDE. \nI know it must be something very common for u guys but i will help me a lot. \nThx","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":313,"Q_Id":62203714,"Users Score":0,"Answer":"Quick Summary\nThis might not be an issue with VS Code.\nProblem: The folder to which pip3 installs your packages is not on your $PATH.\nFix: Go to \/Applications\/Python 3.8 in Finder, and run the Update Shell Profile.command script. Also, if you are using pip install <package>, instead of pip3 install <package> that might be your problem.\nDetails\nYour Mac looks for installed packages in several different folders on your Mac. The list of folders it searches is stored in an environment variable called $PATH. Paths like \/Library\/Frameworks\/Python.framework\/Versions\/3.8\/bin should be in the $PATH environment variable, since that's where pip3 installs all  packages.","Q_Score":0,"Tags":"python,python-module","A_Id":62204055,"CreationDate":"2020-06-04T20:38:00.000","Title":"Importing module to VS code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a license that allows a user to use a Python program for a specific period of time. The program uses datetime.today() to check the current date and then compares it to the expiration date encrypted in the license. If the current date is past the expiration date, it fails to run.\nMy concern is, what if someone manipulates his PC's time to make the program think the license is still valid? Does Python datetime library use PC's time? If not, what's the source for it?\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":349,"Q_Id":62203810,"Users Score":0,"Answer":"The datetime class in python uses the configured time of the operating system.","Q_Score":1,"Tags":"python,datetime","A_Id":62204028,"CreationDate":"2020-06-04T20:46:00.000","Title":"What's the source for Python's datetime?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"On the web, the only solution I find to plot the values of a two-dimensional function is to have a file with the matrix A(nxm) of the function's values and use matplotlib imshow. This will produce a map, whose extent (dimension along axes) has to be known and explicitly indicated.\nNow, my concern arises from the fact that I need to plot two maps on the same axis, but one is slanted with respect to the other. So to say, I have a large main rectangular map and a smaller one that is oblique and superimposed.\nIn the end, the question is: is it possible to plot 2d maps starting from a file that is written as x, y, f(x,y) rather than just using f(x,y) so the plotting tool knows exactly where to draw?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":306,"Q_Id":62204411,"Users Score":0,"Answer":"I luckily found what I was looking for in pcolormesh that can draw a map given the coordinates of each point and its \"colour\"-value.","Q_Score":0,"Tags":"python,2d,colormap,color-mapping","A_Id":62349214,"CreationDate":"2020-06-04T21:27:00.000","Title":"In python, is it possible to plot colour map by giving coordinates and function value?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a slider beneath a ToggleButton and I'm trying to be able to re-toggle the button anytime the slider is moved. \nThe button has a gif image on it, and the button controls the gif speed by checking the current slider position once the button.state==\"down\" (is changed to down). It does this by setting the ToggleButton's gif.anim_delay property to the sliders position. However, when I move the slider I need to retoggle the button in order to update the delay. Can I toggle it automatically on_move when the slider is moved?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":62205093,"Users Score":0,"Answer":"I needed to directly set the animation delay from the slider in the .kv file","Q_Score":0,"Tags":"python,kivy,kivy-language","A_Id":62206572,"CreationDate":"2020-06-04T22:18:00.000","Title":"Kivy Slider Trigger Togglebutton","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a network composed of nodes and edges' weights. I know all of them. I get a \"packet\" which I know is travelling from A to B currently on node C. How to get minimal path it can be presently traversing (next and previous nodes)?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":78,"Q_Id":62205637,"Users Score":1,"Answer":"Update:\nDespite the claim in the accepted answer mine would work. Because\n\nIf there is only one shortest path from A to B, then C is on the shortest path. The accepted answer itself clearly claims it with the phrases:\n\nThe shortest path A -> C -> B must have the shortest A->C and C->B subpaths.\n\nand\n\nIt is trivial to prove.\n\nSo the only possibility for the C not to be on the shortest path is if there are several of them. The accepted answer doesn't address this issue at all. So it will give if not wrong but potentially misleading result. While here is clearly stated that\n\n\nyou need to find all shortest paths\n\nWhich approach is simplest or fastest is totally another matter. Because performance will depend on specific implementation of a specific algorithm and on the net topology. It's not necessary true that finding one long path is slower than finding two smaller ones (without caching... and cache will add complexity).\nAnyway, checking the fact that there are several shortest paths is more general approach as it allows to make predictions on the implementation of the algorithm used to calculate the packet path.\nAnd if, by any chance, @PakUula meant that the shortest path between three points A->C->B is not necessary the same as the shortest path between two points A->B then his answer is incorrect. Exactly because path A->C->B is not the shortest between two points, and as a result C did not travel the shortest path, so we have no idea about the algorithm used to construct the path of the packet and\/or our knowledge about net's weights is wrong. In that case see theoretical exercise and the end of this answer.\n\n\nThe answer itself:\nI suppose we assume that packets always trying to follow the shortest path.\nAs a packet, before it starts it's journey from A to B, needs to know how to make it first move it already needs to know the shortest path. So you just find this shortest path between A and B, and after that you can find where is the C node on it.\nShortest path can be found with, for example, the Dijkstra\u2019s algorithm, or some other. Them you can find on the internet with a request similar to \"graph shortest path\".\nAs you've said that edges' weights are known. Then there is nothing more to it. The C node will always be on the shortest path. Because there is only one shortest path... Well actually - no. There can be several paths with the same weight.\nSo you task is a little bit different - you need to find all shortest paths. And then you'll need to find which of then include C node. Again, there can be several paths with node C. So you can't answer your question with 100% certainty in these cases.\n\nAnd just as a theoretical exercise: what if there is no C node on any of the shortest paths? That means that maybe there were some \"obstacles\" on the way and the plan had to be changed.\nSo what can be done about it?\nIt's quite easy to find the next node(s): just find the shortest path(s) between C and B. But still the answer won't always be definitive, because of the possibility of several routes of same weight.\nBut it becomes impossible to find the previous node without info about \"obstacles\". Because depending on them the packet can come from any direction. That essentially means that weights of the graph have changed and you don't know them.","Q_Score":0,"Tags":"python,networking,path-finding","A_Id":62357716,"CreationDate":"2020-06-04T23:13:00.000","Title":"How to obtain a path we are currently \"on\" the graph while knowing all graph nodes and weights?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a network composed of nodes and edges' weights. I know all of them. I get a \"packet\" which I know is travelling from A to B currently on node C. How to get minimal path it can be presently traversing (next and previous nodes)?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":62205637,"Users Score":3,"Answer":"The shortest path A -> C -> B must have the shortest A->C and C->B subpaths. It is trivial to prove. Note. The shortest path A -> B might not traverse C. Therefore the answer by @x00 might fail if you don't have apriory guarantee that C is selected correctly from the shortest path.\nThe previous node is the last segment on the path A->C and the next node is the first segment of the path C->B.\nThe shortest paths could be computed using Dijkstra algorithm.","Q_Score":0,"Tags":"python,networking,path-finding","A_Id":62357953,"CreationDate":"2020-06-04T23:13:00.000","Title":"How to obtain a path we are currently \"on\" the graph while knowing all graph nodes and weights?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new in python. I am creating an API in python using flask-restful. I have created APIs in java.In java we have pom.xml file for dependencies...is there any for python and flask-restful","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2788,"Q_Id":62209131,"Users Score":0,"Answer":"I would recommend using pipenv.\nIn Java, you need to know where your library dependencies are located and they usually are downloaded once for each project as you need them. In other words, each project will have their own set of plugins. This is also the same for non-global NPM packages (package.json), Ruby gems (Gemfile), and so on.\nBut in Python, everything you install with pip is global. Anything you install with pip will make your system Python installation messy at best and at worst will not be portable between developer machines. We get around this problem with the concept of a virtual environment which more or less is a copy of whatever Python version you're using self-contained to a project.\npipenv works pretty similarly to npm.\nYou initialise with pipenv --three and use pipenv install Flask (for example) to install packages and keep track of them in Pipfile.toml and a lock file. You can then clone it on another computer and pipfile install to install all dependencies.\nIf this tool does not work for you, you may also want to try pyenv and virtualenv and use a requirements.txt file as suggested by Rahul.\nHope that helps!","Q_Score":1,"Tags":"python-3.x,flask-restful","A_Id":62209923,"CreationDate":"2020-06-05T06:06:00.000","Title":"Dependency file in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Some days ago a guy explained me that on ruby on rails the queries are done on models. Because it gets already saved at your data before be requested on views and the query.\nBy the way I've learned and had been working until now, I'm setting the query on views.py and passing, through a context variable. So I started to read about Model.Manager and still didn't find a answer to which way is better:\n\nqueries made on views\nqueries made by simple functions on models\nqueries made on models.Manager class for each model","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1140,"Q_Id":62209330,"Users Score":1,"Answer":"Use custom QuerySets and ModelManagers in your models\ncall your model's ModelManager custom methods from within your views\npass the returned values (querysets, instances or whatever) to the templates (or JSON serializer etc)\n\nIt's a matter of separation of concerns:\n\nthe template (or json serializer or whatever) doesn't have to know where data come from nor they were obtained - only what the data structure is\nviews don't have to know about how the query is implemented, only on how to get relevant data\nonly the model layer should know about it's implementation (encapsulation 101)","Q_Score":0,"Tags":"python,django,python-3.x,django-models,django-views","A_Id":62210858,"CreationDate":"2020-06-05T06:23:00.000","Title":"Querysets on views or on Model Managers DJANGO","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Some days ago a guy explained me that on ruby on rails the queries are done on models. Because it gets already saved at your data before be requested on views and the query.\nBy the way I've learned and had been working until now, I'm setting the query on views.py and passing, through a context variable. So I started to read about Model.Manager and still didn't find a answer to which way is better:\n\nqueries made on views\nqueries made by simple functions on models\nqueries made on models.Manager class for each model","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1140,"Q_Id":62209330,"Users Score":1,"Answer":"According to the Django idioms want to add some advice that can be useful:\n\nmodel managers it's a place for most common queries, not for all queries. Managers describe basic methods for working with models. If you have a widely-used logic for your model with queryset - put it to the manager's method. For example, my users split by domains, so I want to get the user by name and domain, so add the get_by_name_and_domain method to the user model manager. Also, you can access your model by the model attribute in the manager.\nmodels are the part of MTV (Model-View-Template) model on Django and the main purpose of the 'model' itself is to describe db-object but not related business logic. So put your custom queries to views and remember about DRY principle.","Q_Score":0,"Tags":"python,django,python-3.x,django-models,django-views","A_Id":62211170,"CreationDate":"2020-06-05T06:23:00.000","Title":"Querysets on views or on Model Managers DJANGO","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i'm working tkinter , python 3.7 on Windows , wondering if there way remove tk() window border frame , title bar without using overrideredirect(1).\ni have own close button , overrideredirect(1) presents me few issues can't accept:\n1.gui on top\n2.can't iconify deiconify properly\n\nno keyboard input can't type fields\nscreen disappers when out of focus\nthere is no icon at the taskbar when overideredirect(1) is used.\n\ni can't use attributes(\"-fullscreen\", true) titlebar , borders remain plus i want my window to be movable so fullscreen doesn't help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":152,"Q_Id":62211209,"Users Score":0,"Answer":"wondering if there way remove tk() window border frame , title bar without using overrideredirect(1)\n\nNo, there is not. Using overrideredirect is the only way to do it.","Q_Score":0,"Tags":"python,windows,tkinter,titlebar","A_Id":62220697,"CreationDate":"2020-06-05T08:31:00.000","Title":"Custom Title Bar Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Do you see any advantages in enabling the option? Now it's disabled by default and I don't see any benefits in the signatures readability or anything else.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":789,"Q_Id":62211237,"Users Score":4,"Answer":"Well, any kind of strict typing checks has its benefits. I always enable this check and annotate any variable that can take None with an Optional[T] annotation, because this enables mypy to catch missing null checks and prevent nasty 'NoneType' object has no attribute runtime errors.\nHowever, I also understand why people would not want to enable it. Quite a lot of code extensively exploited Python's dynamic nature and it would be tedious to annotate them. Some people might also dislike the verbosity of writing Optional[]. For me, the benefits of the check outweighs the nuances, but your mileage may vary.\nSince the Python type annotations aims to be \"gradual typing\", meaning types were not required and you can have partially annotated code, not having too strict default settings might be beneficial for the adoptation of such tools.","Q_Score":1,"Tags":"python,typing,mypy","A_Id":62602711,"CreationDate":"2020-06-05T08:33:00.000","Title":"Any advantages of enabled mypy `strict_optional?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I really don't understand how batch files work. But I made a python script for my father to use in his work. And I thought installing pip and necessary modules with a single batch file would make it a lot easier for him. So how can I do it? \nThe modules I'm using in script are: xlrd, xlsxwriter and tkinter.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":9737,"Q_Id":62211774,"Users Score":3,"Answer":"You can create a requirements.txt file then use pip install -r requirements.txt to download all modules, if you are working on a virtual environment and you only have the modules your project uses, you can use pip3 freeze >> requirements.txt This is not a batch file but it will work just fine and it is pretty easy","Q_Score":3,"Tags":"python,batch-file","A_Id":62212126,"CreationDate":"2020-06-05T09:05:00.000","Title":"How to install pip and python modules with a single batch file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset containing 1.3 Million records categorized into 109 classes. Obviously there is class imbalance with highest class being 18% in the data and lowest class being less than 1%\nNow, my task is to devise a general forumula\/technique\/code for sampling from these reords such that: What is the minimum number of records we need to select such that it contains records from K classes (where K can vary from 1 to 109) and is representetive of the original data for these classes. Obviuosly tehre cant be an exact solution so we can deal with 'high confidence' solution","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":62212049,"Users Score":0,"Answer":"It seems that you have a simple combinatorics problem.\nAssume you have M red marbles and N green marbles in a box. You pull out K marbles randomly. What is the expected values of a ratio of red to green in your sample? Furthermore, what is the variance? Lets define \"representative\" as extreme values in 95% confidence interval of the ratio (expected-2*std, expected+2*std) been no more than 10% wide relative to the expected value of the ratio. It as straightforward to express it as a function of K (in fact you can do it with pencil and paper for 2 classes). For three classes you can say that the highest variance of the ratio between any two classes should be no more than 10%.","Q_Score":0,"Tags":"python,scikit-learn,data-science,sampling","A_Id":62213036,"CreationDate":"2020-06-05T09:21:00.000","Title":"SubSampling data such that at least K classes are selected from a huge dataset containing N classes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For example\nprint(\"a\" + chr(8)) result is a, but when i run print(\"a\" + chr(8) + \"b\") result is b, even if I do\nprint(\"a\" + chr(8) + \"\") result is a why is that happening? Why my first line of code just don't simply delete this character?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":62213904,"Users Score":0,"Answer":"In the ascii table character 8 is backspace. Backspaces are handled by your operating system. The question to be asked is how does your operating system handle a backspace, because all python does is add \\x08 to the string.","Q_Score":2,"Tags":"python,python-3.x,character","A_Id":62214053,"CreationDate":"2020-06-05T11:06:00.000","Title":"I have a problem with deleting a character in python3 chr(8)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to receive data when clients are behind NAT e.g. router?\nI have simple app that can send data and receive data, it works great on LAN.\nI want it to be decentralized. Without need to manually configure the router.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":62214933,"Users Score":0,"Answer":"You should find some kind of setting in your router, that allows you to route incoming requests to specific ports, to chosen IPs in your local network.\nThe keyword you are looking for is Port Forwarding.\nSince you now specified, that you do not want change anything in the router, the only possibility is, that the person behind the NAT establishes a connection with the person not behind a NAT. The other way is not possible without accessing the router. If both, are behind a NAT, it is impossible.","Q_Score":0,"Tags":"python,networking","A_Id":62214965,"CreationDate":"2020-06-05T12:03:00.000","Title":"How to receive data when clients are behind NAT e.g. router - Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have x and y coordinates in a df  from LoL matches and i want to create a contour plot or heat map to show where the player normally moves in a match.\nDoes any one know how can I do it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1958,"Q_Id":62215345,"Users Score":0,"Answer":"A contour plot or heat map needs 3 values. You have to provide x, y and z values in order to plot a contour since x and y give the position and z gives the value of the variable you want to show the contour of as a variable of x and y.\nIf you want to show the movement of the players as a function of time you should look at matplotlib's animations. Or if you want to show the \"players density field\" you have to calculate it.","Q_Score":1,"Tags":"python,heatmap,contourf","A_Id":62215414,"CreationDate":"2020-06-05T12:25:00.000","Title":"Python Contour Plot\/HeatMap","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My python app (evernote-sdk-python3) worked fine until June, 3rd. Suddenly it breaks e.g. when I call \"client.get_user_store()\" or \"client.get_note_store()\". All calls to \"evernote.edam.userstore.UserStore.Client\" respond with HTTP status 400 (The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing)). I tried it in a sandbox and on the production server and I renewed the auth token. Nothing helped. Something on evernote's side must have changed. My app worked perfectly before.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":62217041,"Users Score":0,"Answer":"the Evernote python3 SDK just got a patch, please grab the latest and try again","Q_Score":0,"Tags":"python-3.x,api,evernote","A_Id":62314769,"CreationDate":"2020-06-05T13:57:00.000","Title":"evernote.edam.userstore.UserStore.Client: HTTP Status 400","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If I have x.shape = (n,) and y.shape = (n,), then x @ y returns their dot product, rather than their outer product. I was wondering if there was some underlying reason for this, or if its just for convenience.\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":188,"Q_Id":62219910,"Users Score":1,"Answer":"Function np.matmul was added when @ operator was introduced to Python.\nThe new function was designed to behave as similar to np.dot as reasonable.\nSo why np.dot(vector, vector) performs inner product?\nBefore @, the function np.dot was used to perform matrix algebra in numpy.\nActually, vectors in linear algebra are not 1D arrays but rather matrices with one of dimensions set to 1. In order to multiply 1D array by matrix, the former has to be somehow promoted to either row or column vector.\nWe have 3 cases here:\n\nvector by matrix, 1D array is promoted to row vector (1xN) to make operation valid\nmatrix by vector, 1D array is promoted to column vector (Nx1)\nvector by vector, left operand is promoted to row vector, right to column vector, as in previous both cases\n\nAs result in the last case we have a normal inner product between two vectors.\nThis policy is both logical and practical because inner products are used more often.","Q_Score":2,"Tags":"python,numpy","A_Id":62222800,"CreationDate":"2020-06-05T16:21:00.000","Title":"Why is the matrix @ product of two numpy (n,) vectors the dot product, rather than the outer product?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the current flow,\nQMainWindow -> QMdiArea -> QMdiSubWindow -> QTabWidget -> QWidget -> QGraphicsScene\/View\nNow I want to maintain a count of a certain item being added to the scene, in a mdi sub window, Now since there can be multiple subwindows, and each subwindow can have multiple tabs. I was interested if qt had a system of given child widgets access to variables in the parent class, instead of using a self.parent().parent().... chain.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":62220031,"Users Score":0,"Answer":"You could maybe set your QObject names with setObjectName. Then using a reference to one of the upper object like QMainWindow, you can get references to certain objects using findChild or findChildren with some expected names.","Q_Score":0,"Tags":"python,pyqt,pyqt5","A_Id":62222823,"CreationDate":"2020-06-05T16:28:00.000","Title":"PyQt5: Variables available and modifiable by all children widgets?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to string together lambda functions. The first lambda function is on a 30 minute timer to scrape and put the data in a S3 bucket, the next lambda function retrieves and parses that data and puts it in a seperate S3 bucket, and the last function performs analysis on that data and sends the user (in this case myself) an email of the results via pythons smtplib module.\nInstead of having the last two lambda functions running on timers, I want the second function to be triggered when the first function is done, and the last function to be triggered when the second function is done. As well as, deleting the two folders in the first S3 bucket and the contents in the second S3 bucket to save on memory and processing time.\nIs there a way to do this totally in the AWS web interface rather than rewrite the python code I already have?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":732,"Q_Id":62220738,"Users Score":0,"Answer":"All the answers here work. To summarize, you could:\n\nTrigger the lambdas when a file arrives in an S3 bucket\nUse Step Functions co-ordinate the 3 lambda functions, one after another\nUse Lambda destinations (on success) to orchestrate the workflow\n\nAll of these accomplish what you wish for, and here's some extra info.\n\nFor the S3 option you can specify which events trigger the lambda (e.g. PutObject), and even the prefix and suffix of the file(s).\nFor Step functions, this is my favorite options. It's an expensive option (typically 5-10x more than lambda) but, it actually orchestrate everything, and the view you get from the console is amazing. It's very easy to triage issues if they occur.\nFor Lambda destinations, you can also set a onFailure mode, so that the you can get alerted if the function fails. onSuccess will of course lead to the next function in question.\n\nHope that helps.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda","A_Id":62231258,"CreationDate":"2020-06-05T17:11:00.000","Title":"AWS Lambda function completion triggers another lambda function","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 got a single dask distributed script that reads a list of hosts from a file and deploys an SSH cluster for me (so far so good). I don't use the dask-worker command line tool as I would like everything to launch from one parent python script. I would like to use the cluster thus set up to run various jobs using subprocess.run or something similar on the worker nodes.\nThe processes that I want to run are python jobs that need to be started in an appropriate conda environment. This is where I come unstuck: attempting to activate a conda environment gets me Your shell has not been properly configured to use 'conda activate'. in stderr.\nI'm using subprocess.run with shell=True. Given that my normal shell is set up to use conda, I was slightly surprised by the error.\nThe dask distributed workers seem to have a very limited environment (my .bashrc isn't loaded) and I don't seem to be able to even source files to try to add to the environment. I have no problem activating the relevant conda env if I use a non-distributed set-up (distributed.Client()), so I guess it is something to do with the way that the dask distributed remote worker environment works. I know that conda and the relevant environments are available on the remote nodes (they all mount the same file system).\nSo, is there an easy way to say to a dask distributed remote worker: \"launch this python script using this conda environment\", preferably using subprocess.run?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":62223569,"Users Score":0,"Answer":"This turned out to be a bash usage issue rather than anything to do with dask.\nIf we force bash to be interactive then we get the environment we expect and can run the jobs. I looked for a more elegant solution, but you quickly get bogged down in the details of what your distribution thinks it should use as the shell environment for login vs non-login shells, interactive vs non-interactive etc etc.","Q_Score":0,"Tags":"python,subprocess,environment,dask-distributed","A_Id":62280338,"CreationDate":"2020-06-05T20:21:00.000","Title":"Farming out subprocess jobs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I wrote a function that fills any null values in 2 dataframe columns baded on a condition being met. I've written unit tests, they all work.\nWhen running it on actual data, it sometimes leads to a ValueError: cannot set using a list-like indexer with a different length than the value\nI'm confused because my unit tests pass. The code is essentially this:\ndf.loc[df['column'].isin(column_values_to_update), ['col2', 'col3']] = df[['col2', 'col3']].fillna(0)\nIt works when column_values_to_update is empty, it works when its full...yet when running on certain datasets, I get the ValueError and I'm not sure why....I've reset the index before getting to this point and no luck.\nAnyone have any idea why sometimes this error can arise, and sometimes it doesn't? Let me know if you need more info...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":62224335,"Users Score":0,"Answer":"in the end I solved the issue by adding an if clause where I use .loc only if column_values_to_update (which is a Set) is not empty.\nI'm still baffled because my unit tests where column_values_to_update was empty still passed.....\noh well","Q_Score":0,"Tags":"python-3.x,pandas","A_Id":62227676,"CreationDate":"2020-06-05T21:26:00.000","Title":"Filling null values in multiple dataframe columns based on condition","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a button where I have a project document open and a family document open. I'm trying to close the family document however I'm getting an error saying:\nAutodesk.Revit.Exceptions.InvalidOperationException: 'Close is not allowed when there is any open sub-transaction, transaction, or transaction group.'\nI've checked all of my transactions and they are all started and committed using transactionName.Start(document) and transactionName.Commit()\ndoes anyone know of a way to check for any ongoing active transactions?\nI have also tried using\n'RevitCommandId closeDoc = RevitCommandId.LookupPostableCommandId(PostableCommand.Close);\nuiapp.PostCommand(closeDoc);'\nhowever that tends to only want to close my project document.\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/UPDATE\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\nsoooo I just found out I didn't need to use uiapp.OpenAndActivateDocument(). I didn't know you could edit a family without opening the document. That solves my problem. I'm still curious if there's a way to check for open transactions though.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1613,"Q_Id":62224410,"Users Score":0,"Answer":"Afaik, the Revit API does not enable you to check from outside whether a transaction is started. You need access to the Transaction object itself to check its status. If you did not create it yourself, you have no access to it.\nHow did you open the two documents? \nWhat Revit commands did you execute in them?","Q_Score":1,"Tags":"revit-api,revit,revitpythonshell,pyrevit","A_Id":62237207,"CreationDate":"2020-06-05T21:32:00.000","Title":"Revit API - How to check for open Transactions, Sub-transactions, or Group Transactions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I run a python script from my command prompt once per day, but I want to automate this with task scheduler. I can only make it open Command Prompt, but I have to then run the python program manually. What am I missing?\n\nNew Folder myTasks\nCreate basic Task \nTask name, trigger, start a program\nProgram script\/ cmd.exe\nAdd Arguments: \"C:\\Users\\Matthew Olive\\PycharmProjects\\VOLALGO1\\scraper.py\"\nManually Run Task to test it\n\nAll I get is the command prompt opening up and it displays: C:\\WINDOWS\\system32>\nIt wont actually run the python script.\nIf I type python \"C:\\Users\\Matthew Olive\\PycharmProjects\\VOLALGO1\\scraper.py\"after C:\\WINDOWS\\system32> it will run just fine.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":868,"Q_Id":62226118,"Users Score":0,"Answer":"Thanks CaffeinatedCoder! I figured it out!\nI used exactly that for the program\/script and it worked. Turns out it was running in the python terminal, but it would disappear immediately, so I added input(\"Press Enter to Exit...\")to the end of the python script.","Q_Score":0,"Tags":"python,command-line,scheduled-tasks","A_Id":62238659,"CreationDate":"2020-06-06T01:04:00.000","Title":"Task Scheduler opens command prompt but does not run python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have this weird bug of No module named 'timeout_decorator' when trying to import timeout_decorator. I have timeout-decorator==0.4.1 installed in my virtual environment and I am able to import timeout_decorator in python interpreter. But when I ran pytest test.py, it threw this error. I have pytest version 5.4.2. Anyone has any ideas ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1203,"Q_Id":62226414,"Users Score":0,"Answer":"I think I have some problems with my virtual environment and the module probably did not point to the right system path. It works when the python packages are in the system path.","Q_Score":0,"Tags":"python,timeout,pytest","A_Id":62249288,"CreationDate":"2020-06-06T01:52:00.000","Title":"No module named 'timeout_decorator'","Data 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 California housing data, which has latitude and longitude. Is it good practice to remove them (latitude & longitude)before I continue to train my model?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":281,"Q_Id":62227841,"Users Score":0,"Answer":"If you are just using raw lat\/long information, then yes, you should remove them. That's because the values of lat\/long are not meaningful in and of themselves, conditional on your model not having any \"understanding\" of what a change in lat\/long means. For instance, what would a change in 1 degree in latitude mean in terms of a change in your target variable? If there is nothing related that way, then you introduce either noise or potentially spurious relationships. \nLat\/long are more often useful as a way to calculate a feature that does have a meaningful impact on your response variable: distance between points, area withing boundries, or anything where you can say \"the change in this feature that I calculate from spatial information correlates with a change in the response\". \nIn short: either take it out, or use it to calculate a feature you do want to include.","Q_Score":0,"Tags":"python,database,pandas,data-science,feature-engineering","A_Id":62267845,"CreationDate":"2020-06-06T05:40:00.000","Title":"Latitude and Longitude data in dataset while training the model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed using pip install cssselect but I am still not able to import it?? I am on Windows.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":62228385,"Users Score":0,"Answer":"The problem was that when installing via pip, it was not creating a directory structure inside site-packages.\nTo solve the problem we have to download cssselect from github, decompress and copy the dir cssselect that's inside cssselect-master to your python site-packages.\nIt worked!!!","Q_Score":0,"Tags":"python,lxml","A_Id":62228575,"CreationDate":"2020-06-06T06:54:00.000","Title":"ImportError: cssselect does not seem to be installed. See http:\/\/packages.python.org\/cssselect\/","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed using pip install cssselect but I am still not able to import it?? I am on Windows.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":62228385,"Users Score":0,"Answer":"Do you have multiple versions of python installed?\na scenario can be that you installed this package in pip for python 2.7 while you try to import it in python 3 --> that will not work. Try figuring out if you use the same python version for both pip install and the python shell you try to import on.\nfor python 3 you can use pip3 or something","Q_Score":0,"Tags":"python,lxml","A_Id":62228464,"CreationDate":"2020-06-06T06:54:00.000","Title":"ImportError: cssselect does not seem to be installed. See http:\/\/packages.python.org\/cssselect\/","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"MongoEngine is good for defining a document for data validation. Raw pymongo is lacking in this area. Can I use MongoEngine to define a document first, then use pymongo to insertMany documents into an empty collection? If yes, will pymongo's insertMany() do data validation based on the document definition set by mongoengine?\nCan pymongo and mongoengine code be mixed together in the same python script?\nI am using python 3.7, mongodb v4.2.7.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":373,"Q_Id":62228701,"Users Score":1,"Answer":"Your three questions:\n'Can I use MongoEngine to define a document first, then use pymongo to insertMany documents into an empty collection? '\nYes.\n'If yes, will pymongo's insertMany() do data validation based on the document definition set by mongoengine?'\nNo.\n'Can pymongo and mongoengine code be mixed together in the same python script?'\nYes.\nMongoengine based on pymongo. If you do not need very complex function that mongoengine not had. I suggest you just use mongoengine to complete your work. This will save your time most of the time.","Q_Score":1,"Tags":"python,python-3.x,mongodb,pymongo,mongoengine","A_Id":62297013,"CreationDate":"2020-06-06T07:32:00.000","Title":"Can one use mongoengine to define a document first, then use pymongo to insert many documents?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to combine two feature extraction methods and classify in python.I am using sklearn.But the accuracy is not improved.What is wrong?How to combine two numpy arrays of feature extraction methods to improve accuracy?Please answer the way to combine in order to improve accuracy.Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":62228734,"Users Score":0,"Answer":"It's not necessary that every time you add a new feature, the accuracy of your model increases. So, it is necessary that you set up local cross-validation. Data science is all about experimenting. The more you experiment, the better results you might get.","Q_Score":1,"Tags":"python,scikit-learn","A_Id":62228885,"CreationDate":"2020-06-06T07:36:00.000","Title":"How to combine two or three feature extraction methods?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing ecommerce website in django .\nI have view ( addToCart)\nI want sure before add to cart if user logged in or not \nso that i use @login_required('login') before view\nbut when click login it show error (can't access to page ).\nNote that: normal login is working","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":62232101,"Users Score":0,"Answer":"Please check the following\n1. Add login url on settings\n2. Add redirect url on login required decorator\n3. If you create a custom login view make sure to check next kwargs","Q_Score":0,"Tags":"python,django,django-views","A_Id":62232761,"CreationDate":"2020-06-06T13:00:00.000","Title":"Login required in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wonder and i've been trying everything to get my program with python sockets to work remotely. When I say remotely is like, I run the server in my computer and my friend at his house can run the client and connect to my server. Is this possible without using Hamachi? Pls let me know, because I'm already dying by trying so many things and installing and uninstalling programs.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":62232490,"Users Score":0,"Answer":"You have to activate port forwarding on your router so that everything that comes on the specific port is forwarded to your local IP (and the port should be open).","Q_Score":0,"Tags":"python,sockets,ip,remote-server,portforwarding","A_Id":62326793,"CreationDate":"2020-06-06T13:33:00.000","Title":"Socket ssh connections remotely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get the error:\n\nModuleNotFoundError: No module named 'PIL'\n\nI installed PIL using pip but get the error.\nI used the code below to import Pillow library:\nfrom PIL import ImageTk,Image\nAny help?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":192,"Q_Id":62233609,"Users Score":0,"Answer":"In my case I needed to install Pillow from my python terminal so that it is installed to the project virtual environment. That solved the problem from me","Q_Score":0,"Tags":"python,python-imaging-library","A_Id":63071712,"CreationDate":"2020-06-06T15:05:00.000","Title":"How to make Pillow recognisable by pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get the error:\n\nModuleNotFoundError: No module named 'PIL'\n\nI installed PIL using pip but get the error.\nI used the code below to import Pillow library:\nfrom PIL import ImageTk,Image\nAny help?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":192,"Q_Id":62233609,"Users Score":0,"Answer":"PyCharm uses a virtual environment for every project. You may have installed PIL outside of your venv. To install it inside, do this.\n\nOpen your project\nAt the bottom of your screen, hit Terminal\nFrom there, pip install -U pillow\n\nNote: When making the project, you may not have checked the button, Inherit global site-packages in the drop down under Project Interpreter. If you check it, all the packages on your machine will then be in the Virtual Environment.","Q_Score":0,"Tags":"python,python-imaging-library","A_Id":62234334,"CreationDate":"2020-06-06T15:05:00.000","Title":"How to make Pillow recognisable by pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently started experimenting with Poetry for package and dependency management, and I am still getting used to the differences between it and my experience with setuptools.  Specifically, I would appreciate help in understanding how to handle the following scenario.\nI have a data file that I want to bundle with my package stored in a package subdirectory.  Using setup.py I would specify the file and directory names in the setup.py file and then access the file in my code using the pkg_resources API.\nWhat is the equivalent approach using Poetry and pyproject.toml?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1691,"Q_Id":62233981,"Users Score":1,"Answer":"Unlike setuptools poetry bundles automatically all files within your package folder into your package, unless you haven't explicit excluded them in your .gitignore or the pyproject.toml.\nSo after the package is installed, you can access them with pkg_resources.","Q_Score":1,"Tags":"python-packaging,python-poetry,python-install","A_Id":62234498,"CreationDate":"2020-06-06T15:34:00.000","Title":"Accessing Data Resources for Python Poetry Based Packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So apparently when we are multi-threading in pyqt by using QThread, we will have to subclass QThread and it can not be directly instantiated. this implies that QThread is an abstract class.\nThat's fine, but the thing that i don't understand is that when we are subclassing QThread, we only override the run() method, but in order to actually get this multi-threading feature to work, we have to call the start() method of the QThread subclass which we did not override at all (AFAIK if we are subclassing an abstract class, we will have to override every method that it has in our child class otherwise it can not b instantiated).\nSo where does the start() and finish methods come from?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":62234183,"Users Score":3,"Answer":"Not every method of an abstract class is itself abstract.  In the case of a QThread, the methods start() and finish() will have the same behavior across all subclasses, so they have concrete implementations for you to use, but there is no base implementation of run() (since that defines what the thread does) so that is abstract and requires custom implementation.","Q_Score":0,"Tags":"python,multithreading,pyqt,qthread","A_Id":62234233,"CreationDate":"2020-06-06T15:48:00.000","Title":"(PyQt5) is QThread an abstract class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible in python to inspect and look at the string pool of interned strings?  I am familiar with the sys.intern() function, however is there a means to inspect the data there?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":62,"Q_Id":62234991,"Users Score":4,"Answer":"There is no mechanism for enumerating the interned string pool. See module Objects\/unicodeobject.c and Python\/sysmodule.c in the source code. Specifically, the definition of the var that holds interned strings: static PyObject *interned = NULL;.\nIn theory that information could be exposed but it isn't because it has very limited usefulness. In part because most interned strings are \"mortal\". That is, they are removed from the interned string cache when no longer referenced. The value of exposing the set of cached strings is very close to zero which makes it difficult to justify the code to do so. Especially since doing so would require holding the GIL for extended periods or making a copy of the interned string dictionary so it can be iterated over without affecting other, concurrent, manipulations of that cache.","Q_Score":4,"Tags":"python,python-3.x,string-interning","A_Id":62240577,"CreationDate":"2020-06-06T16:52:00.000","Title":"Is it possible to inspect the interned string pool directly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that this is (sort of) a duplicate question, however the original has no activity and remains unanswered.\nMy problem is that I have installed tensorflow for python 3.7.5 and upon installation (and reinstallation, including reinstallation without cache (pip install --no-cache-dir tensorflow)) it showed as successfuly installed every time. When I use the pip list command in cmd it also shows that tensorflow and all the modules it comes with are installed.\nHowever, when I open IDLE and type \nimport tensorflow\nit gives me the ModuleNotFoundError.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":62236531,"Users Score":2,"Answer":"Try to create a virtual environment for TensorFlow and then activate it.\nI hope it helps.","Q_Score":0,"Tags":"python,python-3.x,tensorflow,pip","A_Id":62236832,"CreationDate":"2020-06-06T18:51:00.000","Title":"pip list command shows tensorflow as installed, but it cannot be imported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My understanding is that in general the OS Kernel (e.g. Linux) does not really have visibility into any threads created in user space. Moreover, I believe in Linux specifically the OS kernel only sees \"tasks\" or processes, and not \"threads\" per se. \nAdditionally, I'm not sure if CPython would actually ever use multiple threads for anything unless one uses explicitly e.g. the threading package in Python or one of the C standard Python libraries chooses to create threads itself. I suppose the exception here is multiprocessing or any Python libraries that may also spawn multiple processes, in which case the OS Kernel sees them as separate.\nUnder what set of of circumstances would the OS Kernel be aware of any threads created by a Python script, including any of the modules it may use?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":62237543,"Users Score":1,"Answer":"In Linux:\ntask is a thread, process is an address space with one or more threads.\nUser-space threads are directly represented in the kernel. There is POSIX API to create threads pthread_create and there is Linux implementation of threading APIs called NPTL which maps one user-level thread to kernel-level task (task_struct).\nCPython multithreading module implements threads using pthread_create.","Q_Score":0,"Tags":"python,multithreading,kernel,cpython,gil","A_Id":62237746,"CreationDate":"2020-06-06T20:19:00.000","Title":"Under what circumstances would the OS be aware of threads created by Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to add a new table in existing database without affecting existing tables and its datas. After adding new model class into models.py, what are steps needs to follow to add new table?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1407,"Q_Id":62237970,"Users Score":1,"Answer":"Once you've added the new model in your models.py, you just need to run db.create_all(). You can add this in your code somewhere (probably directly) after you initialize your app\/database. Be sure to include with app.app_context() if you aren't calling create_all in a view. Hope this helps!","Q_Score":2,"Tags":"python,flask,flask-sqlalchemy","A_Id":62240624,"CreationDate":"2020-06-06T20:59:00.000","Title":"How to add new table in existing database of flask app using sqlalchemy?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm building a simple Django contact center app using Twilio, TaskRouter, Client JS SDK.\nI'm using the status_callback to save the calls log for each customer in db by listening to the request with complete status_callback_event. (not sure this is the best way but it does the job)\nHow would you go about saving the worker who received the incoming call?\nFor outgoing calls I'm passing the request.user in the url as a custom parameter and I'm getting it in the status_callback.\nFor incoming calls I'm getting the ParentCallSid in the status_callback, I assume I can use it to fetch the client who handled the call through the Rest API.\nAm I doing the right thing here? is there a simpler way to get this done?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":87,"Q_Id":62238996,"Users Score":0,"Answer":"I used in the end TaskRouterEvents to listen to reservations events (reservation.completed or reservation.canceled) I took the WorkerSid from the POST request and saved it in db. \nI think this is the easiest way to go about doing this. \nFor outgoing calls I'm passing the WorkerSid in the url as a custom parameter and I'm getting it in the status_callback.","Q_Score":0,"Tags":"javascript,python,django,twilio,twilio-taskrouter","A_Id":62341583,"CreationDate":"2020-06-06T23:01:00.000","Title":"How to get Twilio worker for incoming calls using TaskRouter? - Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a file structure that looks something like this:\nMaster:\n\nFirst\n\n\ntrain.py\nother1.py\n\nSecond\n\n\ntrain.py\nother2.py\n\nThird\n\n\ntrain.py\nother3.py\n\n\nI want to be able to have one Python script that lives in the Master directory that will do the following when executed:\n\nLoop through all the subdirectories (and their subdirectories if they exist)\nRun every Python script named train.py in each of them, in whatever order necessary\n\nI know how to execute a given python script from another file (given its name), but I want to create a script that will execute whatever train.py scripts it encounters. Because the train.py scripts are subject to being moved around and being duplicated\/deleted, I want to create an adaptable script that will run all those that it finds.\nHow can I do this?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":142,"Q_Id":62239031,"Users Score":1,"Answer":"If you are using Windows you could try running them from a PowerShell script. You can run two python scripts at once with just this:\npython Test1.py\npython Folder\/Test1.py\nAnd then add a loop and or a function that goes searching for the files. Because it's Windows Powershell, you have a lot of power when it comes to the filesystem and controlling Windows in general.","Q_Score":0,"Tags":"python,tensorflow,directory,subdirectory","A_Id":62239246,"CreationDate":"2020-06-06T23:06:00.000","Title":"Running all Python scripts with the same name across many directories","Data 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 file structure that looks something like this:\nMaster:\n\nFirst\n\n\ntrain.py\nother1.py\n\nSecond\n\n\ntrain.py\nother2.py\n\nThird\n\n\ntrain.py\nother3.py\n\n\nI want to be able to have one Python script that lives in the Master directory that will do the following when executed:\n\nLoop through all the subdirectories (and their subdirectories if they exist)\nRun every Python script named train.py in each of them, in whatever order necessary\n\nI know how to execute a given python script from another file (given its name), but I want to create a script that will execute whatever train.py scripts it encounters. Because the train.py scripts are subject to being moved around and being duplicated\/deleted, I want to create an adaptable script that will run all those that it finds.\nHow can I do this?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":142,"Q_Id":62239031,"Users Score":1,"Answer":"Which OS are you using ?\nIf Ubuntu\/CentOS try this combination:\nimport os\n\/\/put this in master and this lists every file in master + subdirectories and then after the pipe greps train.py \ntrain_scripts = os.system(\"find . -type d | grep train.py  \") \n\/\/next execute them\npython train_scripts","Q_Score":0,"Tags":"python,tensorflow,directory,subdirectory","A_Id":62239087,"CreationDate":"2020-06-06T23:06:00.000","Title":"Running all Python scripts with the same name across many directories","Data 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 2 almost identical projects on pycharm. I created each with it's own \"venv\", both venv have \"Pyinstaller\" module installed.\nWhen I use \"Pynstaller\" command inside Pycharm venv terminal, in the first proyect, it uses the \"Pyinstaller\" module that is installed in it's venv. \nIn the second proyect, the same command ignores it's installed module, and uses \"Pyinstaller\" that is inside C:\\Python38\\Lib\\site-packages\\PyInstaller\nWhat's the reason for this behavior?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":62239957,"Users Score":1,"Answer":"I deleted any files created by Pycharm, trashed the venv, and made a new one, installed the same modules and it worked.","Q_Score":0,"Tags":"python-3.x,pycharm,pyinstaller","A_Id":62240861,"CreationDate":"2020-06-07T01:39:00.000","Title":"When I use Pyinstaller, Pycharm ignores the \"Pyinstaller\" module installed, and uses instead the one installed in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to develop web pages locally (in Windows 10) and running in my local browser (chrome, vivaldi).  Right now I have 3 different ways to run simple servers locally:  php's built in server, python's http.server module, and vscode's LiveServer.  When I run the php server, I can execute php code properly, as one would expect.  But calling php urls using the other two, I get a \"Save File\" dialog!  Where is that coming from?   Instead of a simple \"not found\" I get the dialog.  So I have two questions:   (1) Why am I getting the save file dialog?  (2) Is it possible to process php files using LiveServer or python's http.server module (which I don't expect can ever support php)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":107,"Q_Id":62240144,"Users Score":1,"Answer":"if the save dialog is being shown it's cause the server can't interpret php code. You have to  check these servers configs to check their integration with PHP (if they they can do that).","Q_Score":0,"Tags":"php,visual-studio-code,server,python-server-pages","A_Id":62240208,"CreationDate":"2020-06-07T02:20:00.000","Title":"Why do local test servers open a \"save file\" dialog?","Data Science and Machine Learning":0,"Database and SQL":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 simulation with Sumo using TRACI in python as a way to perform some actions in the simulation. What I am doing is basically using netconvert to extract a portion of the map.\nnetconvert --keep-edges.in-boundary minX,minY,maxX,maxY -s large.net.xml -o small.net.xml\nSo basically I am trying to perform an evaluation in the original net(large.net.xml) and in some point of the simulation transfer a vehicle from the original simulation to my small network(small.net.xml) with the option:\nconn2.vehicle.add(vehID='0',routeID='R0',depart=time,departPos=conn1.vehicle.getLanePosition('0'),departSpeed=conn1.vehicle.getSpeed('0'))\nwhere time is the simulation time in my original simulation(conn1). This should take the vehicle in simulation conn1 and start that vehicle in conn2(Simulation with small.net.xml) in that exact same position that it was in conn1, but it seems that my cropped network has different sizes regarding that lane as the vehicle start in a position a little different. Is there a way to avoid these changes in the size of the lanes? I have tried this with transferring the vehicle to the same original network in conn2 and it appears in the desired position.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":62240620,"Users Score":0,"Answer":"The easiest solution is probably to make the cropped network a little larger (containing all edges directly adjacent to the current cropped network) in order to ensure that the edges of interest have still the same junction geometries on the beginning and the end node.","Q_Score":0,"Tags":"python,sumo,network-traffic,traffic-simulation","A_Id":62286901,"CreationDate":"2020-06-07T03:50:00.000","Title":"Simulation in SUMO with netconvert","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Consider I have done popping an arbitrary element from a list of n\/2 elements n\/2 times.Will the time overall time complexity be O(n2) or O(n)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":62241900,"Users Score":0,"Answer":"if you are popping an element whose index is unknown in your list then for each pop it takes n which is the size of the list.\nfor example, you have a list [1, 2, 3, 4, 5, 6, 7, 8, 9] here n = 9\nlet's say you want to remove 3 so to find 3 it takes 3 units of time and then we need to shift the elements after 3 it takes 6 units so in total 9 units of time.\nSo if you are popping n\/2 elements it takes O(n) for each element. as the last element takes n\/2 in big O notation we say it as O(n).\nSo for n\/2 elements, it will take O(n^2).","Q_Score":0,"Tags":"python-3.x,list,performance,time-complexity","A_Id":62242122,"CreationDate":"2020-06-07T06:53:00.000","Title":"Clarifying time complexity for a specific algorithm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to fetch Kafka topic's committed offset and end offset (position) using Pyhon and Kafka client, \nand I'm wondering why the offset is received by topic + consumer-group itself (KafkaAdminClient.list_consumer_group_offsets(consumer_group)) \nwhile the position is received by a consumer + topic's partitioned (KafkaConsumer.end_offsets(partitions)).\nDoes anyone have a clue?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1786,"Q_Id":62243258,"Users Score":0,"Answer":"The concept of committed comes only when there is a consumer group. So the very point that you are asking for the committed offsets means that there is a consumer group. The consumer group contains the details of the topics and its partitions.\nHowever, end offsets term is used regardless of whether there is a consumer group or not. This is the reason why the function is written to accept the list of topic partitions.\n\nSometimes it might not be needed to use a consumer group but we just want to see what is in the topic. In this case, we don't create a consumer group, we just rather assign the topic(s) to the consumer and just read them, like we use kafka-console-consumer for.\nFor example, we use the kafka-console-consumer for reading the last n messages or displaying the topic information.","Q_Score":0,"Tags":"python,apache-kafka,offset","A_Id":62325877,"CreationDate":"2020-06-07T09:13:00.000","Title":"understanding Kafka end offset and committed offset","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is safer and faster- to first delete entire dirs - with os.remove() and then kill empty dir with os.rmdir() \n-OR \njust use shutil.rmtree() and kill all in one step  ?\n(sorry, new to python)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":900,"Q_Id":62244556,"Users Score":5,"Answer":"os.remove() throws an exception if the file doesn't exist, while shutil.rmtree() doesn't care if the directory is empty or not. Therefore, it is easier to use the latter in one step, rather than the former in addition to os.rmdir()(which would ideally require a try-except block or os.path.isfile() to ensure the file exists).","Q_Score":2,"Tags":"python,python-3.x","A_Id":62244641,"CreationDate":"2020-06-07T11:22:00.000","Title":"Is os.remove()+os.rmdir() better then shutil.rmtree()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Anyone know how you get a dataframe from Quantopian to excel - I try - results.to_excel\nresults are the name of my dataframe","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":62246095,"Users Score":0,"Answer":"Try this :\nName of your DataFrame: Result.to_csv(\"result.csv\")\nhere Result is your DataFrame Name , while to_csv() is a function","Q_Score":0,"Tags":"python,quantopian","A_Id":65324001,"CreationDate":"2020-06-07T13:31:00.000","Title":"How to transfer data from Quantopian to Excel","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a probably very special question, but I would still be very happy about your help. First things first, I have basic Python and Dart\/Flutter skills. For days I have been trying in vain for a solution to connect a Raspbarry Pi (Python) and a smartphone (Flutter). I want to be able to control an LED using a flutter app, so I have to control the GPIO Pins via a Flutter application. I totally don't care whether the connection is established via Bluetooth or the Internet. I can't find any instructions or a tutorial on the internet, so my question is whether you might have found a good video or blog entry on this topic. I would be very happy if you could write me a link to a good explanation in the answer box. It would be even better if someone of you knows how to connect an Rpi and a smartphone and that person could explain it to me. Many many thanks in advance and greetings","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":422,"Q_Id":62246164,"Users Score":1,"Answer":"Why you don't create a Websocket\/Http_Server in Rpi Python that interacts with the GPIO and in other side create another Websocket\/Http_Client for your flutter mobile app and exchange data between them.","Q_Score":1,"Tags":"python,flutter,dart,bluetooth,raspberry-pi","A_Id":62246296,"CreationDate":"2020-06-07T13:37:00.000","Title":"How can you control the GPIO pins of an Rpi via flutter?","Data Science and Machine Learning":0,"Database and SQL":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 objective function for Revenue which is in the form of e^(beta1*log(P1) + beta2*log(P2) +....beta250*log(P250)) where P1,P2... P250 are price of certain items and beta1,beta2,... beta250.are elasticity coefficients from model. I would like to maximize Revenue and currently using SLSQP provided constraints on prices, units and guest count. The problem I am facing is optimizer is getting stuck at local minima (It return same o\/p when I relax bounds on price by 5% or 10% or even more). I tried using manually written gradient and using approx_fprime. In both the cases it is getting stuck at local. I could not go with global optimizers as they take lot of time and we are planning to deploy optimizer in real time so that store managers can use it. Can you suggest some algorithm which do not have local minima problem and should converge in less than 30 to 45 secs. \nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":527,"Q_Id":62246325,"Users Score":1,"Answer":"We don't have the whole model, so bring limited to work with partial information, here are some remarks:\n\nThe max Exp(sum()) objective can be replaced by max sum() (as exp() is monotonic). \nFor global optimization problems, I often use solvers like Baron, Couenne, and Antigone. The problem may be small enough to prove global optimality.\nYou can also try a multi-start approach: use multiple different starting points. This will at least prevent some really bad solutions. Some solvers have this built-in (e.g. Knitro) but it is not very difficult to implement this with a simple loop.\nSLSQP is a local solver. In theory, you could use basinhopping + SLSQP but I am not sure this works correctly with constraints.","Q_Score":0,"Tags":"python,optimization,scipy-optimize","A_Id":62252763,"CreationDate":"2020-06-07T13:49:00.000","Title":"Facing Local Minima Problem using SLSQP Optimizer","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My django app is containerized along side postgresql. The problem is that migrations do not seem to be persisting in the directory. Whenever I run docker exec -it <container_id> python manage.py makemigrations forum, the same migrations are detected. If I spin down the stack and spin it back up the and run makemigrations again, I see the same migrations detected. Changes to the fields, adding models, deleting models, none ever get detected. These migrations that do appear seem to be getting written to the database, as when I try to migrate, I get an error that there are existing fields already. But if I look at my migrations folder, only the init.py folder is present. All the migrate commands add no changes to the migrations folder.\nI also tried unregistered the post model from the admin and spinning up the stack, yet I still see it present in the admin. Same things with changes to the templates. No change I make sticks from inside docker seems to stick.\n*Note this problem started after I switched to wsl 2 and enabled it in docker desktop (windows)\n**Update migrations can be made from bash of docker container","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":62247294,"Users Score":0,"Answer":"I found out what the problem was. My docker-stack.yml file was pointed to a directory that did not exist in the dockerfile.","Q_Score":0,"Tags":"django,python-3.x,docker","A_Id":62267183,"CreationDate":"2020-06-07T15:03:00.000","Title":"Django migrations not persisting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"So in my case, I have a class Gnome for example and I want to destroy each object of this class when its variable health reaches 0. Is there a way for me to delete each instance of Gnome when its hp is 0 or should I \"mark it for death\" and delete everything that was marked? Either way, how can I do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":62247738,"Users Score":0,"Answer":"Unfortunately, there isn't a way to do what you're wanting.  Every Python object maintains a record of how many references there are to it.  Once the reference count reaches 0, the Python garbage collector will clean it up.\nAs long as you still have references to the instances, they will persist.","Q_Score":1,"Tags":"python,python-3.x","A_Id":62247789,"CreationDate":"2020-06-07T15:39:00.000","Title":"How do i delete instances of a class from within it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently working on a program that will react to the pressing of a key. I am currently using the module \"keyboard\". \n`import keyboard\nrk = keyboard.record(until='Esc')\nkeyboard.play(rk, speed_factor=1)\n`\nBut when I run it, it gives me:\n'Exception in thread Thread-1:\nTraceback (most recent call last):\n  File \"\/Library\/Frameworks\/Python.framework\/Versions\/3.8\/lib\/python3.8\/threading.py\", line 932, in _bootstrap_inner\n    self.run()\n  File \"\/Library\/Frameworks\/Python.framework\/Versions\/3.8\/lib\/python3.8\/threading.py\", line 870, in run\n    self._target(*self._args, **self._kwargs)\n  File \"\/Users\/user\/PycharmProject\/AUTOCLICKER\/venv\/lib\/python3.8\/site-packages\/keyboard\/init.py\", line 294, in listen\n    _os_keyboard.listen(self.direct_callback)\n  File \"\/Users\/user\/PycharmProject\/AUTOCLICKER\/venv\/lib\/python3.8\/site-packages\/keyboard\/_darwinkeyboard.py\", line 430, in listen\n    raise OSError(\"Error 13 - Must be run as administrator\")\nOSError: Error 13 - Must be run as administrator'\nWhat could I do to fix this? Is there any easier module to work with?\nthanks Triobro3","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":306,"Q_Id":62249140,"Users Score":0,"Answer":"Run your script with administrator privileges with \"sudo\" command and see if it fixes your problem.","Q_Score":0,"Tags":"python-3.x,macos,keyboard","A_Id":62249221,"CreationDate":"2020-06-07T17:30:00.000","Title":"Key board module not working (python3, MacOSX, pycharmCE)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to identify how many rows and columns are in a pandas Dataframe called df, I tried using the functions:\nlen(df) =>  I get only the number of rows\nlen(df.columns) => I get only the number of columns \nIs there a single command\/function that will reveal the rows and columns?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":600,"Q_Id":62250242,"Users Score":0,"Answer":"After quick research I found I can use:  \ndf.shape\nAnswer comes back as (# of rows, # of columns)  \nFor example if df has 421 rows and 33 columns then:\ndf.shape will respond\n(421,33)","Q_Score":0,"Tags":"python,pandas","A_Id":62250243,"CreationDate":"2020-06-07T19:00:00.000","Title":"How to determine how many rows and columns are in a pandas dataframe in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Recently i read this comment \nI like Spyder for interacting with my variables and PyCharm for editing my scripts. Alternative Solution: use both simultaneously. As I edit in PyCharm (on Mac OS), the script updates live in spyder. Best of both worlds!\ni want to understand how to use them together and live update the script in Spyder ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":307,"Q_Id":62250688,"Users Score":0,"Answer":"After some research, I find that there is no variable explorer like Sypder option in PyCharm. To work with PyCharm and Spyder together, we need to use the two IDEs parallelly i.e., to write the code we can use the PyCharm and to view the Spyder we can just alt tab to the Spyder window and re run the code in Spyder. It will not take much time to re run the code again. We just need to press Ctrl + A and Ctrl + Enter, then the variables will get updated in the variable explorer. Spyder variable view is amazing especially data frames.\nOnly thing we need to remember is, we need to install the packages in both PyCharm and Sypder. If we install the package in PyCharm, it will not reflect in Spyder. So we need to install through Conda Prompt.","Q_Score":1,"Tags":"python,pycharm,spyder","A_Id":67584202,"CreationDate":"2020-06-07T19:41:00.000","Title":"Use Pycharm and Spyder Together","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I type the line python3 --version into my mac terminal, it comes up as 3.7.6. If I type the same line in VSCode's terminal, I get 3.7.7. I wouldn't have thought it much an, except I can't import tensorflow on the 3.7.6 version which seems to also be causing issues with Jupyter since Anaconda runs it off Mac's terminal.\nbrew install python registers 3.7.7 as installed on the terminal, but even after re-installing and forcing the terminal closed and re-opened it still registers 3.7.6. Any insight into the problem would be helpful!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":810,"Q_Id":62250971,"Users Score":0,"Answer":"It's because you have 2 versions installed. One from IDE(VSCode-3.7.7) and one from your own install(from the terminal-3.7.6).\nJust uninstall  the 3.7.6 version, download and install a version that is compatible with tensorflow.\nOr you can create a new virtual environments for python with conda.","Q_Score":2,"Tags":"python,python-3.x,macos,terminal","A_Id":62251153,"CreationDate":"2020-06-07T20:05:00.000","Title":"Mac Terminals Shows Two Different Versions of Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm new to Kivy and am trying to make a game that will load and play horizontally on an android phone no matter which direction the phone is oriented. Is there an easy way to do that? I looked through the Kivy documentation as well as some other sites & didn't find much. Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":145,"Q_Id":62252282,"Users Score":2,"Answer":"You can set the landscape orientation in the buildozer.spec file.\n# (str) Supported orientation (one of landscape, sensorLandscape, portrait or all) orientation = landscape","Q_Score":1,"Tags":"python,kivy,game-development","A_Id":62253618,"CreationDate":"2020-06-07T22:05:00.000","Title":"Start Kivy app horizontally on android phone","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to connect to an existing network of devices communicating via RS485 (HMI + PLC, the communication protocol is Fatek's own protocol). I have no problem connecting directly to the PLC (I can read and write registers), but I have to leave the HMI<>PLC connection. When connecting directly to the line between HMI and PLC (via an FTDI USB<>RS485 adapter) I can't read or write registers from the PLC (I don't receive proper responses).\nFrom I've gathered, it's possible to connect multiple devices on one RS485 line, provided they have their addresses set. And here's the problem: I can't see where to set this address. Is it included in every \"frame\" sent? Is it set somewhere in the driver of the USB<>RS485 adapter? Is it hardcoded in the adapter?\nThank you in advance,\nMicha\u0142","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1017,"Q_Id":62252630,"Users Score":1,"Answer":"Usually in serial communications, either 1:1 or 1:N, there can only be one master (in your case the HMI is the master) and one or more slaves that respond to requests from the master, and the master must always wait to receive the response before submitting a new request.\nIf you connect a second master you are creating collisions on the network, RS-485 has no way to manage those collisions.\nOnly one master can exist on the serial network.\nIf you want to overcome these limitations think about replacing that network with Ethernet and TCP\/IP","Q_Score":1,"Tags":"python,serial-port,pyserial,plc,rs485","A_Id":62282054,"CreationDate":"2020-06-07T22:45:00.000","Title":"Setting RS485 device address in python under linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Collision Detection in Python OpenGl\nI'm working on breakout game by using python opengl and I want to make collision detection between the ball and the bricks (Without using pygame).\nI tried a lot but I couldn't and I didn't find any tutorials about it (using Python OpenGl).\nHow can I add collision detection in it?\nMy code until now:\ndeleted the code because the problem is solved and the whole project is changed (the code wasn't good)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":435,"Q_Id":62254263,"Users Score":0,"Answer":"I finally solved my problem.\nI used a different architecture for the whole project and I could link my data structure with the new architecture.\nThe idea was not using any library, just data structure.","Q_Score":0,"Tags":"python,opengl,collision-detection,breakout","A_Id":62338382,"CreationDate":"2020-06-08T02:50:00.000","Title":"Collision Detection in Python OpenGl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently, I am working on a map visualization project using Bokeh.\nBecause the legend of the map is too many, the legend crowded the map.\nIs there any way to make the legend into something like a dropdown menu in Bokeh?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":62254273,"Users Score":1,"Answer":"In Bokeh, the widget is called Select. There's no function like legend_to_select if that's what you want. But you can just avoid creating the legend at all and create the select widget manually. You will have to manually hook it up to the glyphs via a CustomJS callback and it won't support displaying glyphs since it supports only text. If you require displaying glyphs as well, you will have to create a custom Bokeh model that extends Select and overrides the item rendering mechanism.","Q_Score":0,"Tags":"python,bokeh","A_Id":62256596,"CreationDate":"2020-06-08T02:52:00.000","Title":"How to make legend into dropdown?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having trouble when migrating to Python from R. When I worked with data frame in R, using the dollar sign will let know all the name of the column and easily choose the one that i need from a suggestion list even though I don't remember exactly the column's name. Is there any way I can do that in Python?\nUpdate:\nThank you all for the quick respondes. I have looked around and figured out that using df. to bring up the auto complete box works only in the console, not in the editor. However, I have no idea whether it is a bug, or JetBrains just hasn't implemented the feature from R yet.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":395,"Q_Id":62254876,"Users Score":3,"Answer":"There are two parts to your question: there is a language part about what the equivalent syntax\/usage is and a platform part about how things are exposed to the user.\nThe language part is that indexing using df[\"colname\"] in on a Pandas Dataframe is the equivalent of df$colname in R. Depending on your column name, you might also be able to use df.colname although I discourage this usage.\nIf you would like to have completion of this, Jupyter Lab supports tab completion on dataframes, where you would type df[\"<tab> and see a list of possible column completions.","Q_Score":0,"Tags":"python,r,pandas,dataframe","A_Id":62255058,"CreationDate":"2020-06-08T04:10:00.000","Title":"Does Python have any equivalent to R's $ sign?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a project and i was wondering how can i make a button in my web that when it is being clicked it can display a string in my python terminal\nThank you in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":62255012,"Users Score":0,"Answer":"You need to create an http server in your Python, and call it with fetch in JavaScript. You can pass data in the query parameters.","Q_Score":0,"Tags":"python,html","A_Id":62255040,"CreationDate":"2020-06-08T04:26:00.000","Title":"How can i make a button in my web that when it is being clicked. it can send a data in my python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I used pycharm sometime after installing it for the first time on my windows 10(64 bit)..After some day i tried to open pycharm by double clicking(as usual we open softwares in our pc) but it is loading and after sometime the loading disappears..As this thing happens every time i tried opening pycharm i did the following things:\n\nRestarted my Pc.\nReinstalled Pycharm\nBut same problem is occurring.\nBadly need a help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1355,"Q_Id":62255523,"Users Score":0,"Answer":"I got the same problem after reinstalling PyCharm in my Windows 10 Laptop.\nActually, I had to reset my Laptop due to some Startup problems which removed my previously working PyCharm IDE. After finishing reset of my Laptop, I reinstalled PyCharm and tried to open by double-clicking on Shortcut of its exe file, but failed several times.\nFinally, I found a solution as follows:\nGo to C:\\Users\\<usrName> folder and delete or rename .PyCharm[Version.No] folder. Then try to open PyCharm.","Q_Score":1,"Tags":"python,pycharm","A_Id":64286796,"CreationDate":"2020-06-08T05:23:00.000","Title":"Pycharm IDE is not opening on my Windows 10..Badly need a Suggestion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I type jupyter notebook in cmd I get the following error :\n'jupyter' is not recognized as an internal or external command,\noperable program or batch file.\nwhereas when I type jupyter-notebook it successfully opens the notebook.\nWhy am I facing this error?\n(I have jupyter installed and I was able to open the notebook for the very first time after installation with jupyter notebook command but not from second times ownwards)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2303,"Q_Id":62255762,"Users Score":0,"Answer":"1.Open cmd.\n2.Type: pip install jupyter notebook, Use pip install jupyter.\n3.Now Type: python -m notebook.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":67761544,"CreationDate":"2020-06-08T05:48:00.000","Title":"'jupyter' 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":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to have a website where the landing page is a Flask app hosted through Heroku, connected to an online store that is hosted through Shopify?\nFor example, website.com is my Flask landing page. Then shop.website.com is a Shopify store selling my products.\nIf possible, what do I need to do?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":62256777,"Users Score":0,"Answer":"Yes that's possible, but has nothing to do with Flask.\nYou can set your A record of website.com to point to your Heroku server.\nFor the Shopify part, I am not familiar with how exactly you set this up on their site, but they have a documentation where you can learn how to set up a subdomain (e.g. shop.website.com) to use with your Shopify shop.","Q_Score":0,"Tags":"python,flask,shopify","A_Id":62260199,"CreationDate":"2020-06-08T07:10:00.000","Title":"Flask landing page with Shopify web store","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a shared flask web project I am working on with 2 other developers, one of the developers initialized the venv on his pc, uploaded his project structure to github from where I cloned his repo.\nNow I when I start vscode and open the project folder, python does not auto detect the venv and asks if it should set is as the interpreter, the only option I have is the default system wide python install, and not the venv python interpreter. \nI tried adding it to the list by using the command python:select interpreter and then finding the python.exe inside the venv\/scripts folder, but this does not work and vscode still asks for a interpreter. \nI also tried manually adding it inside of my workspace settings.json file like so \n\"python.pythonPath\": \"C:\\\\laragon\\\\www\\\\Proftaak\\\\venv\\\\Scripts\\\\python.exe\"\/\n\nBut vscode also gives an error on this saying the interpreter is not valid.\nHow would I fix this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":967,"Q_Id":62258658,"Users Score":1,"Answer":"This is not expected to work as virtual environments are not designed or meant to be movable. They are meant to be created on each machine you need a virtual environment on. As such, I suspect that the virtual environment does not work outside of VS Code which could prevent it from selecting it as a possible working environment.","Q_Score":0,"Tags":"python,visual-studio-code,python-venv","A_Id":62292929,"CreationDate":"2020-06-08T09:10:00.000","Title":"Python not showing existing venv in interpreter select","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I run Keras Tuner search, the code runs for some epochs and then says:\n'INFO:tensorflow:Oracle triggered exit'.\nWhat does this mean? I am still able to extract best hyperparameters. Is it due to early stopping? I have tried both randomsearch and hyperband.","AnswerCount":9,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":7326,"Q_Id":62258704,"Users Score":0,"Answer":"I had the same question and didn't find what I was looking for.\nIf the tuner have finished at trial, that is lower then your max_trial parameter, the most probable reason is that the tuner have already tried all the combinations possible for the field of hyperparameters that you set before.\nExample: I have 2 parameters for tuner to try, fist can optain 8 values, second 18. If you multiply these two it gives you 144 combinations and that is exactly the number of trials that the tuner stopped at.","Q_Score":7,"Tags":"python,tensorflow,keras,neural-network,keras-tuner","A_Id":71874696,"CreationDate":"2020-06-08T09:13:00.000","Title":"What does 'INFO:tensorflow:Oracle triggered exit' mean with keras tuner?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I run Keras Tuner search, the code runs for some epochs and then says:\n'INFO:tensorflow:Oracle triggered exit'.\nWhat does this mean? I am still able to extract best hyperparameters. Is it due to early stopping? I have tried both randomsearch and hyperband.","AnswerCount":9,"Available Count":7,"Score":0.022218565,"is_accepted":false,"ViewCount":7326,"Q_Id":62258704,"Users Score":1,"Answer":"I found the same issue and I found a very easy solution. It can be very easy if you just remove two files from the directory generated by the keras tunner. oracle.json and other .json files and Run it again it will work.","Q_Score":7,"Tags":"python,tensorflow,keras,neural-network,keras-tuner","A_Id":70181061,"CreationDate":"2020-06-08T09:13:00.000","Title":"What does 'INFO:tensorflow:Oracle triggered exit' mean with keras tuner?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I run Keras Tuner search, the code runs for some epochs and then says:\n'INFO:tensorflow:Oracle triggered exit'.\nWhat does this mean? I am still able to extract best hyperparameters. Is it due to early stopping? I have tried both randomsearch and hyperband.","AnswerCount":9,"Available Count":7,"Score":0.0665680765,"is_accepted":false,"ViewCount":7326,"Q_Id":62258704,"Users Score":3,"Answer":"Probably the reason is, directory is already created.\nTry following steps:\n\nChange the directory name.\nRestart the kernel.\nre-run all the codes.","Q_Score":7,"Tags":"python,tensorflow,keras,neural-network,keras-tuner","A_Id":67093410,"CreationDate":"2020-06-08T09:13:00.000","Title":"What does 'INFO:tensorflow:Oracle triggered exit' mean with keras tuner?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I run Keras Tuner search, the code runs for some epochs and then says:\n'INFO:tensorflow:Oracle triggered exit'.\nWhat does this mean? I am still able to extract best hyperparameters. Is it due to early stopping? I have tried both randomsearch and hyperband.","AnswerCount":9,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":7326,"Q_Id":62258704,"Users Score":0,"Answer":"For me i resolved this issue by removing the hp = HyperParameters() out of the build_model function. I mean, initialize the hp variable outside of the build model function.","Q_Score":7,"Tags":"python,tensorflow,keras,neural-network,keras-tuner","A_Id":67942570,"CreationDate":"2020-06-08T09:13:00.000","Title":"What does 'INFO:tensorflow:Oracle triggered exit' mean with keras tuner?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I run Keras Tuner search, the code runs for some epochs and then says:\n'INFO:tensorflow:Oracle triggered exit'.\nWhat does this mean? I am still able to extract best hyperparameters. Is it due to early stopping? I have tried both randomsearch and hyperband.","AnswerCount":9,"Available Count":7,"Score":0.022218565,"is_accepted":false,"ViewCount":7326,"Q_Id":62258704,"Users Score":1,"Answer":"I solved this issue by setting these two conditions in my Tuner:\n\noverwrite = False\na value for max_trials in the Oracle greater than the one I used until the error \"Oracle triggered exit\" occurred (I'm using kerastuner.oracles.BayesianOptimization Oracle)","Q_Score":7,"Tags":"python,tensorflow,keras,neural-network,keras-tuner","A_Id":67971100,"CreationDate":"2020-06-08T09:13:00.000","Title":"What does 'INFO:tensorflow:Oracle triggered exit' mean with keras tuner?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I run Keras Tuner search, the code runs for some epochs and then says:\n'INFO:tensorflow:Oracle triggered exit'.\nWhat does this mean? I am still able to extract best hyperparameters. Is it due to early stopping? I have tried both randomsearch and hyperband.","AnswerCount":9,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":7326,"Q_Id":62258704,"Users Score":0,"Answer":"I had the same issue with the Hyperband search.\nFor me the issue was solved by removing the \"Early Stopping\" callback from the tuner search.","Q_Score":7,"Tags":"python,tensorflow,keras,neural-network,keras-tuner","A_Id":63204590,"CreationDate":"2020-06-08T09:13:00.000","Title":"What does 'INFO:tensorflow:Oracle triggered exit' mean with keras tuner?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I run Keras Tuner search, the code runs for some epochs and then says:\n'INFO:tensorflow:Oracle triggered exit'.\nWhat does this mean? I am still able to extract best hyperparameters. Is it due to early stopping? I have tried both randomsearch and hyperband.","AnswerCount":9,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":7326,"Q_Id":62258704,"Users Score":0,"Answer":"I believe this is occuring because you are working on a small dataset which is resulting in a large number of collisions while performing random search.\nPlease try reducing the number of 'max-trials' in your random-search, that may fix the issue.","Q_Score":7,"Tags":"python,tensorflow,keras,neural-network,keras-tuner","A_Id":62258845,"CreationDate":"2020-06-08T09:13:00.000","Title":"What does 'INFO:tensorflow:Oracle triggered exit' mean with keras tuner?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using confluent-Kafka with python.\nI want to connect Kafka to Hdfs and store some particular data direct in Hdfs.\nI found the confluent HDFS connector, but I didn't get how to connect it with my python script.\nany idea ? or any alternative methods to store messages directly from Kafka to Hdfs?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":389,"Q_Id":62260047,"Users Score":1,"Answer":"I didn't get how to connect it with my python script\n\nKafka Connect is written in Java, so you cannot integrate with Python. If the documentation could be more clear on this, you should let somebody know. \nThat being said, it does have a REST API. You would use requests or urllib.request to interact with it from Python, just as any other HTTP service\n\nYou could also use PySpark \/ Flink \/ Beam to transfer data from Kafka to HDFS in Python","Q_Score":0,"Tags":"python,apache-kafka,hdfs,apache-kafka-connect,confluent-platform","A_Id":62274586,"CreationDate":"2020-06-08T10:31:00.000","Title":"store message from kafka to hdfs","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How map  defined in python is \n\nmap(function, iterable, ...)\n\nas can be seen function is the first parameter the same goes for filter,reduce \nbut when I am checking functions like sorted they are defined \n\nsorted(iterable, key=None, reverse=False)\n\nkey being the function that can be used while sorting. I don't know Python well to say if there are other examples like sorted. But for starters, this seems a little a bit unorganized. Since I am coming from C++\/D background in which I can almost all the time tell where the function parameter will go in the standard library it is a bit unorthodox for me. \nIs there any historical or hierarchical reason why the function parameter is expected in different orders?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":62,"Q_Id":62260388,"Users Score":1,"Answer":"The map() function design is different, the purpose of the design will surely determine the parameters that you pass into the function. The map() function executes a specified function for each item in an iterable, which is very different for the purpose of the sorted() function.","Q_Score":1,"Tags":"python","A_Id":62262921,"CreationDate":"2020-06-08T10:51:00.000","Title":"Why map,filter,reduce takes the function parameter as first argument meanwhile function like sorted expects it as second parameter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How map  defined in python is \n\nmap(function, iterable, ...)\n\nas can be seen function is the first parameter the same goes for filter,reduce \nbut when I am checking functions like sorted they are defined \n\nsorted(iterable, key=None, reverse=False)\n\nkey being the function that can be used while sorting. I don't know Python well to say if there are other examples like sorted. But for starters, this seems a little a bit unorganized. Since I am coming from C++\/D background in which I can almost all the time tell where the function parameter will go in the standard library it is a bit unorthodox for me. \nIs there any historical or hierarchical reason why the function parameter is expected in different orders?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":62,"Q_Id":62260388,"Users Score":1,"Answer":"Anyone can contribute a module into the python ecosystem. The lineage of any particular module is fairly unique (though I'm sure there are general families that share common lineages). While there will be attempts to standardise and agree on common conventions, there is a limit to what is possible. \nAs a result, some modules will have a set of paradigms that will differ vastly from other modules - they will have different focuses, and you just can't standardise down to the level you're looking for. \nThat being said, if you wanted to make that a priority, there's nothing stopping you from recasting all the non-standard things you find into a new suite of open source libraries and encouraging people to adopt them as the standard.","Q_Score":1,"Tags":"python","A_Id":62260480,"CreationDate":"2020-06-08T10:51:00.000","Title":"Why map,filter,reduce takes the function parameter as first argument meanwhile function like sorted expects it as second parameter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with properties dataset and I am trying to deal with missing values in Land Square Feet Column. There are almost 160000 records in the dataset. Out of which 70000 records have missing LandSquareFeet. I also have a feature which tells about the type of building. When the building types are CONDO\/Walkup I have many missing values in LandSquareFeet. There are 47k records of condo type which has 44k records with missing values in LandsquareFeet. Similarly for most of the properties of Elevator\/Walkup apartments. Other categories of buildings have a very small amount of records missing with LandSquareFeet. I am confused about how to deal with missing Landsquarefeet feature. If I remove the records with missing LandSquareFeet, I will lose almost half of my dataset. I don't know if it is wise to remove the feature for all the records. I did a Little's MCAR test to find if it is MCAR but I got a p-value of 0.000 so it is not MCAR. Is it MAR? Any leads on how to deal with this will be helpful.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":148,"Q_Id":62261268,"Users Score":0,"Answer":"First of all, it might be a good idea if you study the missingness in your data, as tools and methods of missingness resolving often are categorized with respect to these characteristics\n\nMissingness Pattern: if you only have 1 column with missingness, then your missingness pattern is nonresponse. it could have been otherwise monotone multivariate, general form, case matching etc... the pattern describes the distribution of missingness occurrence\nMissingness Mechanism: as you have already mentioned, we might have MCAR, MNAR, and MAR missingness. I don't know what you actually mean by MCAR test, basically, MNAR missingness happens if the missingness occurrence is correlated with other features, and MAR is when the missingness occurrence is correlated with the masked value of the feature itself. According to your description, your case is clearly a MNAR (predicted by type of the house). but it could also be MAR, suppose that small values are often unobserved or unrecorded for an arbitrary reason.\n\nMCAR missingness can be resolved by imputation techniques easily, you can search for MICE algorithm, or MissForest, as a special case of MICE.\nMNAR and MAR missingness mechanisms are called non-ignorable mechanism. there are techniques such as IP-weighting to deal with this types. Recently papers also have been published where they deal with missingness as a causal inference problem.\nBad News is in some special cases, MAR missingness is theoretically impossible to curate. Good news is that there are several really really complex cases studied and investigated, and hopefully your case is not more complex than those, thus you could apply the existing methods.\nI tried not to solve your problem, but to give you essential keywords, by which you might be able to find your material. If you are willing to spend a good deal of time on that, you can read a great book on the subject:\n\nR. J. Little and D. B. Rubin, Statistical analysis with missing data, vol. 793. John Wiley & Sons, 2019.\n\nMy final thought: I have a gut feeling that you can be able to solve your problem by IP-Weighting of all possible methods and approaches. look it up.","Q_Score":0,"Tags":"python,data-mining,data-analysis,missing-data,data-handling","A_Id":62261530,"CreationDate":"2020-06-08T11:41:00.000","Title":"How to deal with missing values in Real-Estate data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script which was written on Windows OS using Python 3.6.5.\nI tried to run the code on Unix OS which has Python 2.6.6 installed, but received an error for the different Syntax and the unrecognized libraries.\nIs there a way to use Python 3.X on my Unix server specifically for my code without upgrading the Python home version?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":62261615,"Users Score":0,"Answer":"No, there is no way to run Python3.X using Python2.x.","Q_Score":0,"Tags":"python,version","A_Id":62261922,"CreationDate":"2020-06-08T12:01:00.000","Title":"how to run python 3 script on Unix with python 2 installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to convert the pretrained ResNet50 model to be used on GPU using the Pytorch function resnet50.to().\nThe problem is that I am using an Intel Iris Plus Graphics 655 1536 MB GPU on Mac, and I don't know what argument to pass to the function as I only found the one for NVIDIA GPUs (resnet50.to('cuda:0')).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":186,"Q_Id":62262241,"Users Score":1,"Answer":"PyTorch uses Nvidia's CUDA API for all GPU interactions. Other GPUs that don't utilise the CUDA API (such as AMD or Intel GPUs) are therefore not supported.\nIf you don't have an Nvidia GPU, you cannot run PyTorch on the GPU.","Q_Score":0,"Tags":"python,deep-learning,pytorch,gpu,resnet","A_Id":62262509,"CreationDate":"2020-06-08T12:37:00.000","Title":"resnet50.to() function on a non-NVIDIA GPU","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to render a session of a bokeh plot on a flask server. The problem I have is, that the generated script tag of that session only produces the plot after I reload the flask server. \nThe reload takes place by saving the server file. \nIs there a way to force this event in the underlying python code? Something like Flask.reload()?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":62262970,"Users Score":0,"Answer":"My tip is: create a new route to process the information you want and make a request via javascript (jquery\/ajax) to get the data and popularize the charts.\nJavascript is responsible for performing this type of action. After a template is rendered, only JS can make changes in the DOM (no more python responsibility).","Q_Score":0,"Tags":"python,session,flask,server,bokeh","A_Id":62269368,"CreationDate":"2020-06-08T13:16:00.000","Title":"How to force auto reload of Flask in code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a question about a programm with Python.\nI must capture my Notebookcam with Pepper and show it on the Display from Pepper.\nNow I have the Problem, the programming with Choreograph is a little bit different and I don't know how I can handle this Programm. I would be happy if you could answer.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":62263349,"Users Score":0,"Answer":"You cannot use Choregraphe to retrieve the video remotely because the applications made using Choregraphe are run on the robot, not on your PC.\nYou need to write separate program on your PC to retrieve the video.","Q_Score":0,"Tags":"python,pepper,choregraphe","A_Id":62589453,"CreationDate":"2020-06-08T13:35:00.000","Title":"Camcapture on Notebook with showing the video on Pepper. (Choreographe, Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've implemented a function that uses Dijkstra's algorithm to find the shortest (lowest weight) path from a given source node to any given destination node in a weighted, undirected graph (positive weights).\nI've got two lists A and B which each hold at least one node location, and every node they hold is valid (is in the graph). A node in list A can also be in list B and vice versa.\nI need to extend my function so that it also takes lists A and B as input, and finds the shortest path from source node to the destination node that uses at least one node from both A and B. Also, while it can use A and B nodes at any point in the path, it must use a B node after it has used an A node (or use a node that is in both A and B).\nIf a node is in both A and B, it immediately satisfies this requirement.\nThe source node and destination node can both be in A and\/or B.\ne.g.\nValid paths (S is source, D is destination, N is node not in A or B):\n\nS > A > B > D \nS > B > A > B > D\nS > N > B > A > N > B > D\nS > (A&B) > D\nS(A) > D(B)\n\nInvalid path:\n\nS > B > A > D\n\nHow would I be able to extend it so that it keeps the complexity of Dijkstra's algorithm, O(Elog(V))? E being # of edges, V # of vertices. I'm thinking there must be a way I can do it using Dijkstra's algorithm a constant number of times, so the complexity doesn't change. Cheers for any help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":480,"Q_Id":62266288,"Users Score":1,"Answer":"I would recommend extending Dijkstra by keeping track of two more values per node. The shortest path with visiting A and shortest path visiting A>B (A and then B).\nUsually, you keep track of the shortest path to each node in Dijkstra. Now, you would keep track of three shortest paths. You would still process single steps and add new neighbors to the queue, but this time, there are three possibilities:\n\nReached node without visiting A: For all neighbors, that are not in A, update the tentative \"without A\" distance. For all neighbors, that are in A, update tentative \"with A\" distance. For all neighbors, that are in A and B, update tentative \"A>B\" distance. \nReached node visiting A but not B after that: For all neighbors, that are not in B, update tentative \"with A\" distance. For all neighbors, that are in B, update tentative \"A>B\" distance. \nReach node visiting A and then B If final node, found result. Otherwise update all neighbors tentative \"A>B\" distance.\n\nChoose always the node with the smallest tentative distance, as in the original algorithm. For this, it does not matter with which condition you reached the node.","Q_Score":2,"Tags":"python,python-3.x,dijkstra","A_Id":62267008,"CreationDate":"2020-06-08T16:02:00.000","Title":"Finding shortest path where any two nodes from two lists of nodes must be used","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to the Analytics field and I have few doubts.\nI hope I can get my answers here.\nI am in the middle of implementing Logistic regression using python.\nIf we need to apply the logistic on the categorical variables, I have implemented get_dummies for that. Suppose the column name is house type (Beach, Mountain and Plain).\nWhat we do here is create three dummy variables in this case and drop one of them, as we can infer the Plain using the other 2 dummy variables. \nBut when I implement RFE on the data. Do I need to include all the 3 variables?\n(I saw this in some blog where dummy was not dropped and got confused)\nAlso, I need to add an intercept column also, as I was using statsmodel (which does not add intercept on it's own). So, in that case if there are multiple categorical variables (and we have dropped a dummy for each) there won't be any issue right ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":692,"Q_Id":62267152,"Users Score":2,"Answer":"You should end up seeing multicolinearity as the third dummy column is always the opposite of the sum of the first two (1 if they sum to 0, and 0 if they sum to 1).  \nThis should be removed prior to feature selection, such as RFE.\nIf you don't, statsmodel is going to throw an warning in the summary and if you check the VIF of the features post fitting, you'll see unacceptable scores that are suggesting colinear features.\nIn any case once this is done, it is feasible that one of your dummy columns could actually be a constant, such as if you had no beach houses in your data set.  The default behavior of statsmodel ignore the add_constant statement when a constant exists.  To get around this you may consider  the has_constant parameter, passing 'add' to indicate you'd like to get an intercept even if there is already a constant column.\nX = sm.add_constant(X, has_constant='add')","Q_Score":1,"Tags":"python,logistic-regression,data-analysis,statsmodels,dummy-variable","A_Id":62267460,"CreationDate":"2020-06-08T16:47:00.000","Title":"Logistic Regression using Python statsmodel","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know this is a very basic question but I'm struggling. I'm at the point where I know what I'd like to do but don't know exactly what to Google to get there.\nI have a small python script that runs through a csv, using each row in an API call, and then adds rows to another csv when a certain response is given by the API. I'm currently just running it in the terminal.\nI want to start running it constantly but don't want to leave my computer on with it running in the background. I'm assuming there's a service that would let me 'host' the script along with the necessary csv files but I don't know what to search to find it.\nWhat is the best service to perform what I need for minimal cost?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":5805,"Q_Id":62269930,"Users Score":1,"Answer":"Depends. If you want a stable publicly available server you should indeed look for a hosting service, in which case I can't answer your question as I don't know any. However, if you are only interested in having the program constantly running and\/or you only need to serve a small amount of clients, I'd suggest buying a raspberry pi, they are quite cheap and flexible and you can easily set up a tiny server at home.","Q_Score":2,"Tags":"python,cloud","A_Id":62281993,"CreationDate":"2020-06-08T19:36:00.000","Title":"Where to host a Python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently switched to the new Pycharm version and in the contrary to the previous versions it seems like two underscores are no longer combined like this: __ \nDoes someone know how to switch it back, so the IDE combines them?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":62270665,"Users Score":1,"Answer":"Please try to enable: File - Settings - Editor - Font - Enable font ligatures","Q_Score":1,"Tags":"python,pycharm","A_Id":62289466,"CreationDate":"2020-06-08T20:28:00.000","Title":"Dunders no longer combined in Pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When installing the same Odoo app for multiple databases (tenants), say Sales App, does this mean Odoo will load the same App multiple times in memory, or the App will be loaded once in memory and shared across tenants\/DBs?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":62271693,"Users Score":1,"Answer":"Odoo loads the app in a worker (assuming you are using workers) so the app is loaded once per worker. A worker can handle multiple databases if configured. But if you have multiple workers the app might get loaded in each worker as requests are reaching the different workers.\nSome part of the memory consumtion of odoo is the ORM caches and those are per database per worker (and some per user) so that part of the App will be in memory multiple times per worker as you have multiple databases.","Q_Score":1,"Tags":"python,python-3.x,odoo,odoo-13","A_Id":62276211,"CreationDate":"2020-06-08T21:47:00.000","Title":"Odoo - Apps in-memory footprint for multiple databases","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I installed pipenv and python@3.8 a few months ago.\nIf I type \"brew info pipenv\", it shows me dependencies and whether or not they are satisfied (with the red X or the green check mark).\nToday, I ran \"brew update\", which updated the pipenv and python@3.8 formulae, along with updating Homebrew from 2.2.17 to 2.3.0.\nIf I didn't upgrade pipenv (not update) or python@3.8, why does a \"brew info pipenv\" under the dependencies section now show python@3.8 with a red check mark?\nI'm going all of this on Mac OS X. I also have a very limited understanding of Linux, so assume I don't know much at all. I'm just trying to understand a little more than I did before :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":62271901,"Users Score":0,"Answer":"If you found formula problem, you can always run brew reinstall <formula> to re-configure it. In my case, the brew info pipenv does show green though.","Q_Score":1,"Tags":"python,homebrew","A_Id":62749283,"CreationDate":"2020-06-08T22:03:00.000","Title":"Dependencies failed according to \"brew info pipenv\" after \"brew update\" on Mac OS X","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How should I save the path of a image uploaded in html page so that the path can be used as input to the python script","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":62274672,"Users Score":0,"Answer":"Using Local Storage (require HTML 5) or cookie will solve your problem","Q_Score":0,"Tags":"javascript,python,html","A_Id":62274748,"CreationDate":"2020-06-09T03:44:00.000","Title":"is there a way to save the path of the file uploaded in html page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i had installed python 3.6.5 and pycharm community version 2020.1.2 on windows 8.1 pro..it works completely fine on numpy but when i imported pandas,it shows error....please help me to get out of this problem.....\nit just show this...\nC:\\Users\\india\\Desktop\\final\\venv\\Scripts\\python.exe C:\/Users\/india\/Desktop\/final\/test.py\nTraceback (most recent call last):\n  File \"C:\/Users\/india\/Desktop\/final\/test.py\", line 1, in \n    import pandas\n  File \"C:\\Users\\india\\Desktop\\final\\venv\\lib\\site-packages\\pandas__init__.py\", line 55, in \n    from pandas.core.api import (\n  File \"C:\\Users\\india\\Desktop\\final\\venv\\lib\\site-packages\\pandas\\core\\api.py\", line 29, in \n    from pandas.core.groupby import Grouper, NamedAgg\n  File \"C:\\Users\\india\\Desktop\\final\\venv\\lib\\site-packages\\pandas\\core\\groupby__init__.py\", line 1, in \n    from pandas.core.groupby.generic import DataFrameGroupBy, NamedAgg, SeriesGroupBy\n  File \"C:\\Users\\india\\Desktop\\final\\venv\\lib\\site-packages\\pandas\\core\\groupby\\generic.py\", line 60, in \n    from pandas.core.frame import DataFrame\n  File \"C:\\Users\\india\\Desktop\\final\\venv\\lib\\site-packages\\pandas\\core\\frame.py\", line 124, in \n    from pandas.core.series import Series\n  File \"C:\\Users\\india\\Desktop\\final\\venv\\lib\\site-packages\\pandas\\core\\series.py\", line 4572, in \n    Series._add_series_or_dataframe_operations()\n  File \"C:\\Users\\india\\Desktop\\final\\venv\\lib\\site-packages\\pandas\\core\\generic.py\", line 10349, in _add_series_or_dataframe_operations\n    from pandas.core.window import EWM, Expanding, Rolling, Window\n  File \"C:\\Users\\india\\Desktop\\final\\venv\\lib\\site-packages\\pandas\\core\\window__init__.py\", line 1, in \n    from pandas.core.window.ewm import EWM  # noqa:F401\n  File \"C:\\Users\\india\\Desktop\\final\\venv\\lib\\site-packages\\pandas\\core\\window\\ewm.py\", line 5, in \n    import pandas._libs.window.aggregations as window_aggregations\nImportError: DLL load failed: The specified module could not be found.\nProcess finished with exit code 1","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4077,"Q_Id":62277970,"Users Score":0,"Answer":"Kindly Install all pending updates and retry.\nI experienced same error before where I couldn't import seaborn and train_test_split module from sklearn.model.\nI tried many fixes I found online but  didn't work,\nI discovered that I have many pending windows updates so I downloaded and installed all pending updates and everything was fine.","Q_Score":1,"Tags":"python,python-3.x,pandas","A_Id":64295894,"CreationDate":"2020-06-09T08:13:00.000","Title":"how to fix ImportError: DLL load failed: The specified module could not be found","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to enable Django debugging in a particular apps in the whole project because when the site is go to production if found something anything bug then I will fix by enabling the debug in the particular view in Django app without affecting the other modules\nThank in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":62281401,"Users Score":0,"Answer":"I don't know how this can be done- but it probably shouldn't be done. \nExposing even a single app in debug mode could potentially leak security keys and more likely just lead to unexpected behavior, especially because django tries its best to prevent you from enabling debug mode outside of the development webserver. \nUse proper logging within your app to report and replicate errors and avoid debug in production. There various 3rd party services that can be very easily installed on your webserver and handle most of the error and traceback logging for you- likely at no cost (assuming you don't have thousands of errors to process).","Q_Score":0,"Tags":"django,python-3.x,server","A_Id":62283703,"CreationDate":"2020-06-09T11:19:00.000","Title":"How to enable debugging in a particular app in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a dataflow job that reads from pubsub, transforms the PubsubMessage into a TableRow and writes this row to BQ using the FILE_LOAD-method (each 10 minutes, 1 shard). The job sometimes throws a ByteString would be too long-exception. This exception should be thrown when it concats the rows to the Google Cloud Storage (GCS) temp file as you cannot append to a GCS file. If I understand it correctly, it is ok to let this exception happen as the 'large' temp file will be used for loaded to BQ later on and appending will happen to a new file which should succeeded. I would however like to prevent this error from happening without increasing the number of load jobs as I'm getting close to my daily load jobs quota on the project.\nCan I:\n\nincrease the number of shards to 2? Or will that cause the writer to always use 2 shards even if it only needs to write a small number of rows?\nuse setMaxFileSize() along with the number of shards? Or will the writer still use 2 shards even if it doesn't really have too? \n\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":113,"Q_Id":62284178,"Users Score":1,"Answer":"Setting the number of shards to 2 will always use 2 shards.\nHowever, I don't think the \"ByteString would be too long\" error is coming from GCS.  That error usually happens when the total output size of a bundle in Dataflow is too large (>2GB), which can happen when a DoFn's output is much larger than its input.\nOne option to work around this would be to break apart the bundles coming in from Pubsub with a GroupByKey.  You can use a hash of the input or a random number as the key, and set your trigger to AfterPane.elementCountAtLeast(1) to allow elements to be output as soon as they arrive.","Q_Score":0,"Tags":"python,google-cloud-dataflow,apache-beam","A_Id":62288982,"CreationDate":"2020-06-09T13:47:00.000","Title":"BigqueryIO file loads: only use additional shard if required","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have received a link with .ipynb  link. I am new to Python and Jupyter and I need to open the link to work on the details inside.\nThe link opens in my internet browser and I couldn't properly see the contents and bring it in to a Jupyter notebook. \nCould anyone please give me a tip how to handle such links for Python\/Jupyter?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":100,"Q_Id":62285116,"Users Score":0,"Answer":"Adding to Vinzee's answer: jupyter notebook starts in your home folder and you can't move up from there; only down into subfolders.  Open jupyter to see what folder it starts in, and make sure that you put the .ipynb file in that folder or one of its subfolders.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":62285954,"CreationDate":"2020-06-09T14:36:00.000","Title":"How to bring a web browser with .ipybn link opened in my Jupyter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there any way to see whether a message forwarded to the telegram channel from another channel has been edited (and at what time)? \nVia API or some other tools.\nWebsite version of telegram at web.telegram.org shows what time the forwarded message has been originally posted, but it doesn't display whether that message has been edited afterwards.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1110,"Q_Id":62285883,"Users Score":0,"Answer":"No, that's not possible. When you forward a channel post to any sort of chat on Telegram, the label \"edited\" will be removed.","Q_Score":1,"Tags":"telegram,telegram-bot,python-telegram-bot,telegraf,node-telegram-bot-api","A_Id":64194389,"CreationDate":"2020-06-09T15:15:00.000","Title":"Can I see whether message forwarded to the group has been edited and at what 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":"To format strings in Python 3.6+, I usually use the lowercase \"f\" option to include variables. For example:\nresponse = requests.get(f'{base_url}\/{endpoint}?fields={field_list}')\nI've recently seen one of my coworkers who always uses capital \"F\", instead. Like this:\nresponse = requests.get(F'{base_url}\/{endpoint}?fields={field_list}')\n\nIs there a difference between the lowercase \"f\" and capital \"F\"? And if yes, when would you use each?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1139,"Q_Id":62286965,"Users Score":0,"Answer":"There is no difference between the two. For better understanding, you may go through string formatting.","Q_Score":5,"Tags":"python,string,string-formatting","A_Id":62287130,"CreationDate":"2020-06-09T16:08:00.000","Title":"Is there a difference between \"f\" and \"F\" in Python string formatting?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just started python. I am trying to web scrape a website to fetch the price and title from it. I have gone through multiple tutorial and blog, the most common libraries are beautiful soup and scrapy. My question is that is there any way to scrape a website without using any library?\nIf there is a way to scrape a website without using any 3rd party library like beautifulsoup and scrapy. It can use builtin libraries\nPlease suggest me a blog, article or tutorial so that I can learn","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":417,"Q_Id":62287967,"Users Score":2,"Answer":"Instead of using scrapy you can use urllib.\nInstead of beautifulsoup you can use regex.\nBut scrapy and beautifulsoup do your life easier.\nScrapy, not easy library so you can use requests or urllib.","Q_Score":1,"Tags":"python,web-scraping,beautifulsoup,scrapy,libraries","A_Id":62288047,"CreationDate":"2020-06-09T16:59:00.000","Title":"Scrape websites with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to know why we use from module import module?\nFor example from BeautifulSoup import BeautifulSoup instead of only import BeautifulSoup.\nAre both of those different?\nAnd if yes, then how?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":62289256,"Users Score":2,"Answer":"Yes, they are different.\nThere are several ways to import a module\n\nimport module\nThe module is imported, but all its functions, classes and variables remain within the name space of 'module . To reference them, they must be prepended with the module name:\nmodule.somefunction()   module.someclass()  module.somevariable = 1\nimport module as md\nThe module is imported, but given a new name space 'md'. To reference the functions, classes and variables, they must be prepended with the new namespace:\nmd.somefunction()       module.someclass()  module.somevariable = 1\nThis keeps the namespaces separated, but provides a shorthand notation which makes the code more readable.\nfrom module import *\nAll functions, classes and variabes from the module are imported into the current namespace as if they were defined in the current module. They can be called with their own name:\nsomefunction()   someclass()    somevariable = 1\nThe disadvantage is that there might be overlapping names!\nfrom module import something\nfrom module import something, somethingelse\nThis imports only 'something' (and 'somethingelse') a function, a class, a variable into the current namespace.\nThis is not only more efficient, but it also reduces the risk of overlapping names.\n\nA module name and a class inside the module may have the same name. Don't let that confuse you:\nimport BeautifulSoup        reference: BeautifulSoup.BeautifulSoup()\nfrom BeautifulSoup import BeautifulSoup     reference: BeautifulSoup()\nimport BeautifulSoup as bs  reference: bs.BeautifulSoup()","Q_Score":0,"Tags":"python,python-3.x,python-requests","A_Id":62289410,"CreationDate":"2020-06-09T18:12:00.000","Title":"Python packages import","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create an array with the following structure when printed: \n1: (10,20),\n2: (20,30),\n3: (30,40),\n4: (40,50),\nand so on...\nReally new to python so anything helps! Using python 3.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":393,"Q_Id":62290944,"Users Score":0,"Answer":"Let l be your list. It doesn't matter what is in it. Use zip to make a new list, with wanted feature. zip, matches elements of two list together. if you zip a list with itself, you'll have a new list that each element in first list is repeated twice in it.\n\nl = [1, 2, 5, 11, 12]\nfor element in zip(l, l):\n     print(element)\n\noutput:\n(1, 1)\n(2, 2)\n(5, 5)\n(11, 11)\n(12, 12)","Q_Score":0,"Tags":"python,arrays,python-3.x,sequence","A_Id":62291260,"CreationDate":"2020-06-09T20:03:00.000","Title":"How do I create an array that repeats every number twice?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been learning python in codeacademy and I like how for specific characters i.e. = , () they have a different colour to the rest of the text, however in IDLE it is all the same colour so it is a bit harder to follow. Is there a way to change this or is there a compiler out there similar to the codeacademy one?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":62292377,"Users Score":0,"Answer":"IDLE colors code in different roles: keyword, builtin, string, comment, and some others, but not specific characters.  You can customize the colors IDLE uses, but not the roles.  I suspect that the same is true for other Python IDEs, but don't really know.  If you want the codeacademy syntax units, you will have to look further.","Q_Score":0,"Tags":"python,python-idle","A_Id":62309171,"CreationDate":"2020-06-09T21:45:00.000","Title":"Is there a way to change the colour for specific characters for normal code or text","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't know how it happened, but my sys.path now apparently contains the path to my local Python project directory, let's call that \/home\/me\/my_project. (Ubuntu).\necho $PATH does not contain that path and echo $PYTHONPATH is empty.\nI am currently preparing distribution of the package and playing with setup.py, trying to always work in an virtualenv. Perhaps I messed something up while not having a virtualenv active. Though I trying to re-install using python3 setup.py --record (in case I did an accidental install) fails with insufficient privileges - so I probably didn't accidentally install it into the system python.\nDoes anyone have an idea how to track down how my module path got to the sys.path and how to remove that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":62292976,"Users Score":0,"Answer":"I had the same problem. I don't have the full understanding of my solution, but here it is nonetheless.\nMy solution\nRemove my package from site-packages\/easy-install.pth\n(An attempt at) explanation\nThe first hurdle is to understand that PYTHONPATH only gets added to sys.path, but is not necessarily equal to it. We are thus after what adds the package into sys.path.\nThe variable sys.path is defined by site.py.\nOne of the things site.py does is automatically add packages from site-packages into sys.path.\nIn my case, I incorrectly installed my package as a site-package, causing it to get added to easy-install.pth in site-packages and thus its path into sys.path.","Q_Score":0,"Tags":"python-3.x,setuptools","A_Id":64670582,"CreationDate":"2020-06-09T22:36:00.000","Title":"Project directory accidentally in sys.path - how to remove 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":1,"Web Development":0},{"Question":"So I am having an issue ever since I accidentally deleted python, when I reinstalled it VSCode kept giving me an issue saying \"You need to select a Python Interpreter before you start debugging. Tip: click on \"Select Python Interpreter\" in the status bar.\" When I go to the bar there are no interpreters available. When I try on my brothers laptop it shows the interpreters. Python is already in the Path.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":11177,"Q_Id":62293947,"Users Score":0,"Answer":"I was having same issue with python interpreter but when I completely uninstalled my python package and reinstalled the latest version which currently is 3.9.6  , and it perfectly worked.","Q_Score":1,"Tags":"python,visual-studio-code,interpreter","A_Id":68630616,"CreationDate":"2020-06-10T00:22:00.000","Title":"Python Interpreter Not Found VSCode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I am having an issue ever since I accidentally deleted python, when I reinstalled it VSCode kept giving me an issue saying \"You need to select a Python Interpreter before you start debugging. Tip: click on \"Select Python Interpreter\" in the status bar.\" When I go to the bar there are no interpreters available. When I try on my brothers laptop it shows the interpreters. Python is already in the Path.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":11177,"Q_Id":62293947,"Users Score":0,"Answer":"I uninstalled python latest version v3.10.2 and reinstalled v3.9.7 and its working perfectly without no issue.","Q_Score":1,"Tags":"python,visual-studio-code,interpreter","A_Id":71454271,"CreationDate":"2020-06-10T00:22:00.000","Title":"Python Interpreter Not Found VSCode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on an application with Bokeh server, which will be embedded into a Django app. The dataframe is quite large, and the application runs slow, especially when using the Select and Slider widgets and Bokeh tools. At the moment I can't understand the difference between Bokeh server (Python Callbacks) and Bokeh JS (CustomJS Callbacks). From your experience, is it possible for Bokeh JS to run faster? Thank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":117,"Q_Id":62296821,"Users Score":1,"Answer":"It is possible to make it run faster once the page and all the plots are loaded. The initial loading may as well be slower simply because you will have to load all the data so it could be used in JS without having to communicate with the server.\nWith that being said, it's absolutely possible to just combine two approaches. But it requires a deeper understanding of Bokeh's architecture and models.","Q_Score":0,"Tags":"python,bokeh","A_Id":62298955,"CreationDate":"2020-06-10T06:00:00.000","Title":"Is there any difference between Bokeh server and Bokeh JS in terms of speed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Adding UUID as an id column to the DataFrame and push to BigQuery using to_gbq maintains the uniqueness?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":240,"Q_Id":62298118,"Users Score":1,"Answer":"it is the same - UUID in Python generate such unique Id like UUID in BQ","Q_Score":0,"Tags":"python,google-bigquery","A_Id":62299551,"CreationDate":"2020-06-10T07:34:00.000","Title":"How safe to use Python UUID instead of BigQuery GENERATE_UUID() when inserting data?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to ask if it is possible to add more integerfields and charfields to a model if it has already been migrated to an SQLite database.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":62299206,"Users Score":0,"Answer":"Yes after every new addition\/deletion of fields to\/from your model you need to do makemigrations and migrate and Django will modify your sqlite database accordingly.\nIf there is existing data and you add a new field, it has to be either nullable or you need to provide a sensible default for existing data for that new column.\nIf you remove a field, that field will be removed but your data will remain intact without the removed column.","Q_Score":0,"Tags":"python,django","A_Id":62299258,"CreationDate":"2020-06-10T08:34:00.000","Title":"Is it possible to create more Data Fields after Migrations have taken place?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know it might be a bad design but since we are developing the django website on our laptops which runs Win7, I thought it would be better to run django on a Windows platform only in production.\n(Laptop is not powerful enough to run a Unix VM inside and our Unix team doesn't provide any Unix server with UI access (Only Putty) so using an IDE is impossible on Unix.)\nI have deployed django with gunicorn and nginx on a Linux server very easily, but this time I have to deploy django on a Windows server with Apache on another Unix server (I know it sucks).\nOur middleware team is asking(forcing) to run django components on a separate server so that they can manage their Apache (on Unix) instance comfortably. As far as I understand, Apache and django should reside on the same server for mod_wsgi to work.\nIs this possible to keep Apache on a Unix machine and make a django website run from a Windows machine?\nIf not, what are the best possible solutions in my case? (Switch django on Unix? Use waitress on Django windows? Do not separate Apache and Django? etc.)\nRegards,\nAditya","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":295,"Q_Id":62299359,"Users Score":0,"Answer":"The best thing in my modest point of view is to create a unix docker image of your project","Q_Score":1,"Tags":"python,django,windows,apache,waitress","A_Id":62312129,"CreationDate":"2020-06-10T08:43:00.000","Title":"Deploying django(windows) with apache(on unix)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I recently installed Pop!_OS on my laptop for development purposes, but i found out the version of python installed is 3.8.2, which unfortunately doesnt support versions of tensorflow below 2.0. I need to use tensorflow 1.14 for my work and this is not possible with python 3.8.\nIm willing to use python 3.6 in a virtual environment or have it alongside 3.8 in my laptop. Im rather new to linux so please excuse any mistakes. Thanks in advance!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3751,"Q_Id":62300705,"Users Score":0,"Answer":"easiest way is to create a virtual env with a specific python version\nvirtualenv envname --python=python3.6","Q_Score":2,"Tags":"python,debian-based","A_Id":64048270,"CreationDate":"2020-06-10T09:53:00.000","Title":"How to install python 3.6.10 alongside presinstalled 3.8.2","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Class \"Binary search tree\".\nComplete the class by including the division method\nobject of class \"Binary search tree\" on\ntwo objects of the class \"Binary tree\nsearch \". The key to division must be\nthe value of the item being requested\nsoftware and is passed as an argument\nmethod. Items smaller than the key in value,\nshould be placed in the first tree as well\nelements, and larger - in the second.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":151,"Q_Id":62302223,"Users Score":0,"Answer":"Just trying to put an algorithm around the question, may be it helps to get the requirement more clear\n\/\/your initial object is obj; you have [root,left,right] in your object; assign your left sub-tree to the new first object;\nobj1=obj.left;\n\/\/then set the left sub-tree of your initial object to NULL\nobj.left=NULL;\n\/\/assign remaining tree to new second object\nobj2=obj;\nWill that help?","Q_Score":0,"Tags":"python,c++","A_Id":62302549,"CreationDate":"2020-06-10T11:15:00.000","Title":"How to divide an object of class \"Binary Search Tree\" into two objects of class \"Binary Search Tree\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to gremlin, I'm trying to use python library gremlinpython to connect to Janus Graph\nand need to know if it is possible to rollback transaction.\nI've found that single traversal is equivalent to single transaction (tinkerPop docs), traversal is created after connecting to gremlin server:\ng = traversal().withRemote(...)\nand all operations with g are executed in a single transaction.\nBut I can't find what will happen if error occurs in any of operations.\nIs it possible to rollback all operations made with g?\ngremlin server allows to do smth like g.tx().rollback() or g.tx().commit() - to rollback or approve transaction, but is it possible to do this using gremlinpython?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":499,"Q_Id":62303567,"Users Score":3,"Answer":"If an error occurs then Gremlin Server will automatically rollback the transaction for you. If it is successful it will automatically commit for you. The semantics of \"rollback\" or \"commit\" are graph database dependent (i.e. some graphs may commit partial transactions even in the face of rollback) and in the case of JanusGraph will be further dependent upon the underlying storage engine (e.g. Cassandra, Hbase, etc).","Q_Score":1,"Tags":"transactions,gremlin,tinkerpop,janusgraph,gremlinpython","A_Id":62304384,"CreationDate":"2020-06-10T12:27:00.000","Title":"How to rollback gremlin transaction using gremlinpython?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'am pondering to make use of MariaDB as my new database (because MySQL is starting to ask money for some of the features). I will mainly use MariaDB to automatically update multiple tables, keep track of them, grab\/insert new info in them. I will most likely combine it with multiple other programs such as Python and SAS. \nNow I want to know. Which tools are really vital in using MariaDB? What GUI should I use for example, does MariaDB have her own workbench or should I use the MySQL workbench? I've read that the MySQL workbench is not 100% compatible with MariaDB. \nAny advice's please?\nI appreciate your help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":62305103,"Users Score":0,"Answer":"MySQL Workbench is mostly compatible with MariaDB, as are most tools. There is no separate MariaDB Workbench.\nFor more recent versions, you will need mariabackup instead of xtrabackup.\nJust out of interest, what features of MySQL do you need that require subscription but are free in community edition of MariaDB?","Q_Score":1,"Tags":"python,mysql,database,sas,mariadb","A_Id":62305759,"CreationDate":"2020-06-10T13:41:00.000","Title":"Vital tools for using MariaDB","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am supposed to run following command for an assignment to analyze the functions in rsa.py\npython -m cProfile -s time rsa.py < tests\/1verdict32.in\nI am assuming this file uses tests\/1verdict32.in as in the input file to rsa.py.\nbut I am not familiar with how cProfile works with a file as an input\ncan someone explain to me how this is supposed to work? especially what is the relevance of \"<\" character in the above line?\nps: the directory structure is\nWD\/\n -rsa.py\n -hello.py\n -tests\/\n      -1verdict_32.in\nalso when I run above command, it gives \"system cannot find the file specified\" error\nbut the profiler works when I use it on file hello.py\ni.e. for the command: python -m cProfile -s time hello.py","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":76,"Q_Id":62306414,"Users Score":1,"Answer":"You have a typo.\nYour file is 1verdict_32.in, and you're attempting to pass in 1verdict32.in, without the underscore. That's why your shell complains.\nBeyond that, < ... is a simple shell redirection operator; it means that the shell (bash, zsh, fish, cmd, ...) opens the file ... and writes it into the process's standard input (in Python, that's sys.stdin).","Q_Score":0,"Tags":"python,input,cmd,cprofile","A_Id":62306636,"CreationDate":"2020-06-10T14:44:00.000","Title":"using cprofile with input 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":0},{"Question":"TL;DR\nWhat's the fasted way to get near-zero loading time for a pandas dataset I have in memory, using ray?\nBackground\nI'm making an application which uses semi-large datasets (pandas dataframes between 100MB to 700MB) and are trying to reduce each query time. For a lot of my queries the data loading is the majority of the response times. The datasets are optimized parquet files (categories instead of strings, etc) which only reads the columns it needs. \nCurrently I use a naive approach that per-requests loads the require dataset (reading the 10-20 columns out of 1000 I need from the dataset) and then filter out the rows I need. \nA typical request:\n\nRead and parse the contract (~50-100ms)    \nLoad the dataset (10-20 columns) (400-1200ms)    \nExecute pandas operations (~50-100ms)\nSerialise the results (50-100ms)\n\nI'm now trying to speed this up (reduce or remove the load dataset step). \nThings I have tried:\n\nUse Arrow's new row-level filtering on the dataset to only read the rows I need as well. This is probably a good way in the future, but for now the new Arrow Dataset API which is relies on is significantly slower than reading the full file using the legacy loader. \nOptimize the hell out of the datasets. This works well to a point, where things are in categories, the data types is optimized. \nStore the dataframe in Ray. Using ray.put and ray.get. However this doesn't actually improve the situation since the time consuming part is deserialization of the dataframe. \nPut the dataset in ramfs. This doesn't actually improve the situation since the time consuming part is deserialization of the dataframe.\nStore the object in another Plasma store (outside of ray.put) but obviously the speed is the same (even though I might get some other benefits)\n\nThe datasets are parquet files, which is already pretty fast for serialization\/deserialization. I typically select about 10-20 columns (out of 1000) and about 30-60% of the rows. \nAny good ideas on how to speed up the loading? I haven't been able to find any near zero-copy operations for pandas dataframes (i.e without the serialization penalty). \nThings that I am thinking about:\n\nPlacing the dataset in an actor, and use one actor per thread. That would probably give the actor direct access to the dataframe without any serialization, but would require me to do a lot of handling of:\n\nMaking sure I have an actor per thread\nDistribute requests per threads\n\"Recycle\" the actors when the dataset gets updated\n\n\nRegards,\nNiklas","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":290,"Q_Id":62306438,"Users Score":1,"Answer":"After talking to Simon on Slack we found the culprit:\n\nsimon-mo: aha yes objects\/strings are not zero copy. categorical or fixed length string works. for fixed length you can try convert them to np.array first\n\nExperimenting with this (categorical values, fixed length strings etc) allows me not quite get zero-copy but at least fairly low latency (~300ms or less) when using Ray Objects or Plasma store.","Q_Score":0,"Tags":"python,pandas,parquet,pyarrow,ray","A_Id":62429365,"CreationDate":"2020-06-10T14:46:00.000","Title":"Low-latecy response with Ray on large(isch) dataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a CRM web application. I am planning to do its backend in python(because I only know that language better) and I have a friend who uses flutter for frontend. Is it possible to link these two things(flutter and python backend)? If yes how can it be done...and if no what are the alternatives I have?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1054,"Q_Id":62306900,"Users Score":0,"Answer":"I used  $.ajax() method in HTML pages and then used request.POST['variable_name_used_in_ajax()'] in the views.py","Q_Score":0,"Tags":"python,flutter,flutter-web","A_Id":63479644,"CreationDate":"2020-06-10T15:08:00.000","Title":"linking web application's backend in python and frontend in flutter","Data Science and Machine Learning":0,"Database and SQL":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 making a CRM web application. I am planning to do its backend in python(because I only know that language better) and I have a friend who uses flutter for frontend. Is it possible to link these two things(flutter and python backend)? If yes how can it be done...and if no what are the alternatives I have?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1054,"Q_Id":62306900,"Users Score":0,"Answer":"Yes you both can access same Django rest framework Backend. Try searching for rest API using Django rest framework and you are good to go.\nOther alternatives are Firebase or creating rest API with PHP.\nYou would need to define API endpoints for different functions of your app like login,register etc.\nDjango rest framework works well with Flutter. I have tried it. You could also host it in Heroku\nUse http package in flutter to communicate with the Django server.","Q_Score":0,"Tags":"python,flutter,flutter-web","A_Id":62307029,"CreationDate":"2020-06-10T15:08:00.000","Title":"linking web application's backend in python and frontend in flutter","Data Science and Machine Learning":0,"Database and SQL":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 an old Macbook Pro 3,1 running ubuntu 20.04 and python 3.8. The mac CPU doesn't have support for avx (Advanced Vector Extensions) which is needed for tensorflow 2.2 so whilst tensorflow installs, it fails to run with the error:\n\nillegal instruction (core dumped)\n\nI've surfed around and it seems that I need to use tensorflow 1.5 however there is no wheel for this for my configuration and I have the impression that I need to build one for myself.\nSo here's my question... how do I even start to do that? Does anyone have a URL to Building-Stuff-For-Dummies or something similar please? (Any other suggestions also welcome)\nThanks in advance for your help","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":62308415,"Users Score":0,"Answer":"Update: I installed python 3.6 alongside the default 3.8 and then installed tensorflow 1.5 and it looks like it works now (albeit with a few 'future warnings'.)","Q_Score":0,"Tags":"python,tensorflow,ubuntu","A_Id":62385426,"CreationDate":"2020-06-10T16:24:00.000","Title":"Building Tensorflow 1.5","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an old Macbook Pro 3,1 running ubuntu 20.04 and python 3.8. The mac CPU doesn't have support for avx (Advanced Vector Extensions) which is needed for tensorflow 2.2 so whilst tensorflow installs, it fails to run with the error:\n\nillegal instruction (core dumped)\n\nI've surfed around and it seems that I need to use tensorflow 1.5 however there is no wheel for this for my configuration and I have the impression that I need to build one for myself.\nSo here's my question... how do I even start to do that? Does anyone have a URL to Building-Stuff-For-Dummies or something similar please? (Any other suggestions also welcome)\nThanks in advance for your help","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":62308415,"Users Score":0,"Answer":"Usually there are instructions for building in the repository's README.md. Isn't there such for TensorFlow? It would be odd.","Q_Score":0,"Tags":"python,tensorflow,ubuntu","A_Id":62308529,"CreationDate":"2020-06-10T16:24:00.000","Title":"Building Tensorflow 1.5","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the xgboost documentation they refer to a copy() method, but I can't figure out how to use it since if foo is my model, neither bar = foo.copy() nor bar=xgb.copy(foo) works (xgboost can't find a copy() attribute of either the module or the model). Any suggestions?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":885,"Q_Id":62309466,"Users Score":1,"Answer":"It turns out that copy() is a method of the Booster object, but a (say) XGBClassifier is not one, so if using the sklearn front end, you do\nbar = foo.get_booster().copy()","Q_Score":2,"Tags":"python,xgboost","A_Id":62316164,"CreationDate":"2020-06-10T17:22:00.000","Title":"xgboost how to copy model","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm having some trouble hosting a django API on a separate server. When using localhost everything works, however when I log in to the server admin panel I get an \"invalid salt\" error.\nOriginally, I had my own login method that used bcrypt, but I decided to scrap that in favor of using facebook authentication. I've removed all references to bcrypt from my views. The problem lies with the built in admin interface. I haven't modified the code for that at all, but I am unable to log in. I can share my code, but I'm not even sure what files would be relevant to share, so I'm happy to update as needed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":62309930,"Users Score":0,"Answer":"Turns out this wasn't a code problem, it was a dependency problem. I had py-bcrypt installed on the server, but not bcrypt. It seems both libraries are necessary for the admin feature to work. I probably should have dockerized it.","Q_Score":0,"Tags":"python,django,bcrypt","A_Id":62310214,"CreationDate":"2020-06-10T17:49:00.000","Title":"Invalid salt when logging in via django admin panel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need the following pattern: Get string from \"number\" followed by any char NOT letter(except 'x'), followed keyword like (oz or g) followed by other keyword like (bags, boxes, pack). Here some string as example\n40497 frozen fi ench fried potatoes organic 12\/16 oz bags --> 12\/16 oz bags\napples 8x18x3.4 oz ( 96g ) boxes --> 8x18x3.4 oz (96g ) boxes\n8 red 12 green 15 - .1 oz (3g) pack --> 15 - .1 oz (3g) pack\nI have this pattern\n(\\d*\\.?\\d+)(\\W)((|)?)(oz.).*(bag.|boxe.|pack.) but the results are:\n16 oz bags\n3.4 oz (96g ) boxes\n.1 oz (3g) pack","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":62310304,"Users Score":1,"Answer":"Replace this part (\\d*\\.?\\d+) with [\\d\\.][\\d\\.x\\-\\s\\\/]+\n[\\d\\.]: to make sure that the matching result starts with a digit or a dot (one character)\n[\\d\\.x\\-\\s\\\/]+: then the remaining group of characters (one or more) before oz keyword could be any of: \n\ndigit\ndot\n\"x\" character\n\"-\" character\nspace\nslash","Q_Score":0,"Tags":"python,regex","A_Id":62310666,"CreationDate":"2020-06-10T18:11:00.000","Title":"Match string with number, unit and keyword python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Django, and the tutorial directly applied this command without explanation.\nAfter searching, I found out it's calling migrations in Django, but didn't understand it either as I am a complete newbie at this.\nWhat does the python manage.py migrate command do exactly?\nWhat are migrations?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":1266,"Q_Id":62311073,"Users Score":4,"Answer":"If your database doesn't exist yet, migrate creates all the necessary tables to match your model definitions.\nOtherwise if the database already exists, migrate brings the existing table definitions to be in sync with the model definitions -- i.e. maybe you added a field to one of your models, so migrate would add that column to the database table.","Q_Score":2,"Tags":"python,django,python-3.x","A_Id":62311166,"CreationDate":"2020-06-10T18:54:00.000","Title":"what does \" python manage.py migrate \" in django do exactly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a script that is throwing a CERTIFICATE_VERIFY_FAILED on one of the PCs available to me, but not the other. The certificate was updated last week. How do I check if there is a cached version of the certificate somewhere, and get it refreshed? \nI tried manually updating the .pem file in the lib\/site-packages\/certifi folder but that doesn't seem to make a difference.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":62313105,"Users Score":0,"Answer":"Try running command pip install certifi","Q_Score":0,"Tags":"python,certificate,urllib2","A_Id":62316490,"CreationDate":"2020-06-10T21:03:00.000","Title":"Python: CERTIFICATE_VERIFY_FAILED, Windows","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 6 real-time videos which are inference output from heavy deep learning calculation from python, and I've tried to display them to PyQt that lots of threading issues with ugly GUI!!. So, I want to use a framework only to display well and fancy GUI! There seem lots of frameworks based on my google search, and I have no idea \nwhich one is the best for my current project among Node js, Django, and Flask!\n\nI need to display 6 real-time videos with 10~15 FPS.\nCommunicating well with python.\nEasy to build GUI, I have some features like logging, displaying real-time graph(optional)","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1083,"Q_Id":62315216,"Users Score":3,"Answer":"For video streaming, you will require to setup a socket URL for listening to incoming packet. Definitely, you can dedicate a server just for this to handle high amount of traffic.\nNow, as such it dependents on your application, if you are just going to use it for streaming then Flask will do, it is lightweight. On the other hand, Django and NodeJS provides ready made function for socket programming and they are very useful.","Q_Score":1,"Tags":"python,node.js,django,opencv,flask","A_Id":62315330,"CreationDate":"2020-06-11T00:26:00.000","Title":"Node js vs Django vs Flask for multiple videos streaming from python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I got 6 real-time videos which are inference output from heavy deep learning calculation from python, and I've tried to display them to PyQt that lots of threading issues with ugly GUI!!. So, I want to use a framework only to display well and fancy GUI! There seem lots of frameworks based on my google search, and I have no idea \nwhich one is the best for my current project among Node js, Django, and Flask!\n\nI need to display 6 real-time videos with 10~15 FPS.\nCommunicating well with python.\nEasy to build GUI, I have some features like logging, displaying real-time graph(optional)","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1083,"Q_Id":62315216,"Users Score":0,"Answer":"I would say it doesn't really matter much as Django would be good because of its  pre built features... Plus data transfer is very reliable in django along with your expertise in python, django is preferred. NodeJs would be easier to implement tho. Really prefers upon you, but both django and nodeJs works pretty well.\nSorry, no idea on flask","Q_Score":1,"Tags":"python,node.js,django,opencv,flask","A_Id":63781694,"CreationDate":"2020-06-11T00:26:00.000","Title":"Node js vs Django vs Flask for multiple videos streaming from python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I installed the free version of PyCharm professional last week and have been encountering the problem where I am debugging code on a remote server and when I try to display variables, it simply says \"collecting data\" and then if I try to continue the debugging process PyCharm breaks.\nI have been researching solutions and I have Gevent compatible enabled as well as tried all 3 variable settings; Synchronously, Asynchronously, and On Demand. \nI should also note that I am running into a problem where the debugger is skipping all my break points as well and I have to restart my server connection in order to get the break points to hit (and sometimes it takes a couple of tries)\nI know that it is entirely possible to see the variables that are collecting data as one of my co-workers who recommended PyCharm has no problem, and there was 1 run where I was able to see the variables, but when I re-ran the commands (with absolutely no change), I was back at square one. \nI've been going through PyCharm forums and it seems as if this has been a reoccurring issue for a handful of years now, but knowing that it worked once for me, and it works for my coworker, am I simply missing something?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":813,"Q_Id":62315284,"Users Score":1,"Answer":"Just recently my PyCharm has started to behave this way as well.  I researched and tried the same solutions you did, to no avail.  On certain projects it simply hangs forever on \"collecting data\" - projects that used to work - where code hasn't changed.  Pls let me know if you find anything else; I will keep researching and testing as well\nEDIT: FWIW.  In my particular case I isolated the cause of this (at least I think).  I had a very large dataframe in memory and if this DF is not in memory, the debugger does not hang.  None of my watches were explicitly on this DF, but I guess the debugger needed to inspect it upon break and the object was just too big somehow.  Note that it hung even if \"variables loading policy\" was set to \"on demand\", so the debugger still must automatically investigate all variables somehow.","Q_Score":5,"Tags":"python,debugging,pycharm","A_Id":64688124,"CreationDate":"2020-06-11T00:39:00.000","Title":"PyCharm Debugger Stuck on \"Collecting Data\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get Python and selenium to store the \"1292\" in the following html script and cant figure out why it won't work. I've tried using find_element_by_xpath as well as placing a wait before it and I keep getting this error \"Message: no such element: Unable to locate element:\"\nAny ideas on how else I can accomplish this? Thanks\n<text x=\"76.76666666666667\" y=\"141.42345774407445\" style=\"font-family:&quot;Lucida Grande&quot;, &quot;Lucida Sans Unicode&quot;, Verdana, Arial, Helvetica, sans-serif;font-size:12px;color:#4572A7;font-size:11px;fill:#4572A7;\" text-anchor=\"middle\" zIndex=\"1\">\n     <tspan x=\"76.76666666666667\">1292<\/tspan>\n   <\/text>","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":62316046,"Users Score":0,"Answer":"You can try:\ndriver.find_element_by_xpath(\"\/\/tspan[text()='1292']\").text\nto obtain the string \"1292\".","Q_Score":0,"Tags":"python,html,selenium","A_Id":62316368,"CreationDate":"2020-06-11T02:21:00.000","Title":"Need help getting data using Selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am very interested in learning Azure cloud service in-depth and trying to do something awesome here, but not sure where to go or how to solve it. I tried my best to find any helpful resource online, but no luck. So I need some azure wizard to help me with this, please.\nWhat I am trying to do is that I have a python script that I wrote on my local and want to deploy in Azure. My python script is designed to clean messy data that must be fed into the machine learning model. So, I created an email address where I receive the data from clients, and using azure logic apps, I will extract the files attached to that email and save it to azure blob storage. Then I want my python script to extract the data from azure blob storage and clean it then save it back to azure blob storage. Basically I want to automate the data cleaning steps in azure. Can anyone help me with which activity or service I should use to achieve this? \nI really appreciate your help in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3119,"Q_Id":62316695,"Users Score":2,"Answer":"Here is what you can do \n1) Create a logic app to trigger on the email that you receive in your mail box. You can refine the way trigger is invoked meaning you have particular subject line, a particular folder etc\n2) You can extract the data from files and feed to the storage account (You can also look at using CosmosDb)\n3) Create an azure function which uses blob trigger or uses event gird trigger (To listen to Blob Creation event)\n4) Write the logic to clean the data","Q_Score":0,"Tags":"python,azure,azure-logic-apps,azure-blob-storage,azure-databricks","A_Id":62316822,"CreationDate":"2020-06-11T03:42:00.000","Title":"How to deploy python in Azure logic apps?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Training on tensorflow 1.15, python3.7.\nI am currently training stylegan2 on a custom dataset consisting of 30000 images, each 256 by 256. Since style gan creates different tf record files, each storing dataset with size 2^x. the 8th tf record (storign 256x256 images) is 5Gb just for context, the rest are super small (all less than a gb). \nMy current setup is a P100, 16 gigs VRam, 32 gb ram and abundance of storage . I also 2vCpus (training on gcp). \nI am running into this error as mentioned above. Initially my memory was 13 gigs, after seeing the exact error multiple times, i iteratively upped my memory to an eventual 32 gb. \nAny and all \"pointers\" would be helpful (Notice the pun on pointers haha)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":584,"Q_Id":62317096,"Users Score":0,"Answer":"OKAY I SOLVED IT. there was an issue with the .pkl file that I was using for transfer learning. use a pickle file that contains a model whos discriminator starts with input layer of your image shape (eg 256x256).","Q_Score":0,"Tags":"python,tensorflow","A_Id":62318366,"CreationDate":"2020-06-11T04:30:00.000","Title":"MemoryError: Unable to allocate 5.62 GiB for an array with shape (16384, 30720, 3) and data type float32 When training StyleGan2","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have a big C# application, would like to include an application written in python and cython inside the C#\nOperating system: Win 10\nPython: 2.7\n.NET: 4.5+\nI am looking at various options for implementation here.\n(1) pythonnet - embed the python inside the C# application, if I have abc.py and inside the C#, while the abc.py has a line of \"import numpy\", does it know how to include all python's dependencies inside C#?\n(2) Convert the python into .dll - Correct me if i am wrong, this seems to be an headache to include all python files and libraries inside clr.CompileModules. Is there any automatically solution? (and clr seems to be the only solution i have found so far for building dll from python.\n(3) Convert .exe to .dll for C# - I do not know if i can do that, all i have is the abc.exe constructed by pyinstaller\n(4) shared memory seems to be another option, but the setup will be more complicated and more unstable? (because one more component needs to be taken care of?)\n(5) Messaging - zeromq may be a candidate for that. \nRequirements:\nBoth C# and python have a lot of classes and objects and they need to be persistent\nC# application need to interact with Python Application\nThey run in real-time, so performance for communication does matter, in milliseconds space.\nI believe someone should have been through a similar situation and I am looking for advice to find the best suitable solution, as well as pros and cons for above solution.\nStability comes first, then the less complex solution the better it is.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":499,"Q_Id":62318896,"Users Score":0,"Answer":"For variant 1: in my TensorFlow binding I simply add the content of a conda environment to a NuGet package. Then you just have to point Python.NET to use that environment instead of the system Python installation.","Q_Score":1,"Tags":"c#,python-2.7,zeromq,shared-memory,python.net","A_Id":62543620,"CreationDate":"2020-06-11T07:07:00.000","Title":"Alternatives for interaction between C# and Python application -- Pythonnet vs DLL vs shared memory vs messaging","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 aws lambda running python 3 service.\nI am measuring my service duration(simple time -time) from the start of the lambda invocation(first invocation line) till the end(last invocation line).\nIm getting results that are pretty dramatically different than aws reported duration and billed duration.\nMost of the time my measures indicates on average of 730.9 ms\nAnd aws reported duration and billed duration reports on Duration: 1058.36 ms   Billed Duration: 1100 ms.\nWhere the difference can come from?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":483,"Q_Id":62320107,"Users Score":1,"Answer":"Prior to function invocation, the instance must be spun up. I believe AWS Lambda charges for the setup time of the function as part of the execution time.\nAny imports or other assets that must be loaded before your function is invoked count against the total execution time, and your timer doesn't start until after that inital loading time.","Q_Score":0,"Tags":"python,python-3.x,aws-lambda,duration","A_Id":62320296,"CreationDate":"2020-06-11T08:24:00.000","Title":"Difference between aws lambda duration and my measures duration","Data Science and Machine Learning":0,"Database and SQL":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 just started learning Python and have downloaded PyCharm and understand this is likely to be a very basic question but wanted to ask before I set off with a false sense of security. \nI'm interested to know whether:\na) Simply opening but not running a .py file as a project in PyCharm IDE could be malicious. \nb) Opening and running a .py file in the PyCharm IDE can be malicious\nIf not either, why not? Would the file need to be a .exe to do anything without PyCharm being involved?  \nAgain, appreciate any help\/insight you can provide.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":490,"Q_Id":62324779,"Users Score":0,"Answer":"So just opening a file in PyCharm will not harm any computer in any way.\nBut running code can do that, so I would be careful were you get the code which you want to execute. And it would be best if you understood the basic of the code you are running. Therefore you would be able to spot strange lines in your code.","Q_Score":0,"Tags":"python,pycharm","A_Id":62325107,"CreationDate":"2020-06-11T12:48:00.000","Title":"Can opening a .py file in PyCharm be harmful\/malicious?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed docker in my windows machine using 'pip install docker' command but system is unable to figure out the existence of docker though added in environment variables (pip docker path).\nAdded path (Environment variables): C:\\Users\\Name\\foo\\local\\boo\\python\\python38-32\\lib\\site-packages\\docker\n'docker' is not recognized as an internal or external command,\noperable program or batch file.\nThere are lots of similar questions posted in this forum but apparently they did not help my case so for.\nCould someone assist?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3316,"Q_Id":62325022,"Users Score":0,"Answer":"Try restarting windows and check if the error still continues. I had this error once and as incredible as it seems it solved my problem. I hope it helps, friend. Or try this command in CMD: refreshenv","Q_Score":0,"Tags":"python,docker","A_Id":62325171,"CreationDate":"2020-06-11T13:00:00.000","Title":"'docker' is not recognized as an internal or external command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to develop a python script to retrieve data from the Primavera API for my firm. I do not have any idea where to start.I saw a couple of articles where getting data from API's was fairly simple task using few lines of python code. However this doesn't seem to be the case here.\nCan anyone please help!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1383,"Q_Id":62326127,"Users Score":1,"Answer":"Primavera P6 API uses Java, so you have 3 choices:\n\nUse Python Java bridge\nWrite the code in Java\nUse Python to connect to Primavera P6 Web Services (another Primavera integration technology)","Q_Score":0,"Tags":"python-3.x,primavera,product-management","A_Id":62350601,"CreationDate":"2020-06-11T13:58:00.000","Title":"Accessing the Primavera data using Primavera Integration API and a python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a flask app that is intended to be hosted on multiple host. That is, the same app is running on different hosts. Each host can then send a request to the others host to take some action on the it's respective system. \nFor example, assume that there is systems A and B both running this flask app. A knows the IP address of B and the port number that the app is hosted on B. A gets a request via a POST intended for B. A then needs to forward this request to B. \nI have the forwarding being done in a route that simply checks the JSON attached to the POST to see if it is the intended host. If not is uses python's requests library to make a POST request to the other host. \nMy issue is how do I simulate this environment (two different instance of the same app with different ports) in a python unittest so I can confirm that the forwarding is done correctly?\nRight now I am using the app.test_client() to test most of the routes but as far as I can tell the app.test_client() does not contain a port number or IP address associated with it. So having the app POST to another app.test_client() seems unlikely. \nI tried hosting the apps in different threads but there does not seem to be a clean and easy way to kill the thread once app.run() starts, can't join as app.run() never exits. In addition, the internal state of the app (app.config) would be hidden. This makes verifying that A does not do the request and B does hard. \nIs there any way to run two flask app simultaneously on different port numbers and still get access to both app's app.config? Or am I stuck using the threads and finding some other way to make sure A does not execute the request and B does? \nNote: these app do not have any forums so there is no CSRF.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":62328279,"Users Score":0,"Answer":"I ended up doing two things. One, I started using patch decorator from the mock library to fake the response form systems B. More specifically I use the @patch('requests.post') then in my code I set the return value to \"< Response [200]>\". However this only makes sure that requests.post is called, not that the second system processed it correctly. The second thing I did was write a separate test that makes the request that should have been sent by A and sends it to the system to check if it processes it correctly. In this manner systems A and B are never running at the same time. Instead the tests just fake there responses\/requests.  \nIn summery, I needed to use @patch('requests.post') to fake the reply from B saying it got the request. Then, in a different test, I set up B and made a request to it.","Q_Score":0,"Tags":"python,flask,python-requests,python-unittest","A_Id":62338499,"CreationDate":"2020-06-11T15:48:00.000","Title":"Test interaction between flask 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"from selenium import webdriver\ndriver = webdriver.Firefox(executable_path=\"C:\\Users\\yhtiy\\Documents\\chromedriver_win32\\geckodriver.exe\")\ndriver.get(\"https:\/\/instagram.com\")\nAnd the output is: \n\nProcess finished with exit code 0\n\nI have tried to change the browser to Chrome and Firefox but the issue remains. I have checked that Selenium is installed.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":107,"Q_Id":62329117,"Users Score":0,"Answer":"webdriver.Firefox(executable_path=\"C:\/Users\/yhtiy\/Documents\/chromedriver_win32\/geckodriver.exe\")\nThis should work","Q_Score":0,"Tags":"python-3.x,selenium,selenium-webdriver","A_Id":62329403,"CreationDate":"2020-06-11T16:33:00.000","Title":"Selenium webdriver not opening neither Chrome nor Firefox browser, I downloaded chromedriver, geckodriver in pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"from selenium import webdriver\ndriver = webdriver.Firefox(executable_path=\"C:\\Users\\yhtiy\\Documents\\chromedriver_win32\\geckodriver.exe\")\ndriver.get(\"https:\/\/instagram.com\")\nAnd the output is: \n\nProcess finished with exit code 0\n\nI have tried to change the browser to Chrome and Firefox but the issue remains. I have checked that Selenium is installed.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":107,"Q_Id":62329117,"Users Score":0,"Answer":"You are probably running a script, when the script finishes, the process exits, nothing is wrong. If you want to see what's being obtained, save driver.page_source to a file or print it out.","Q_Score":0,"Tags":"python-3.x,selenium,selenium-webdriver","A_Id":62329526,"CreationDate":"2020-06-11T16:33:00.000","Title":"Selenium webdriver not opening neither Chrome nor Firefox browser, I downloaded chromedriver, geckodriver in pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use conda to set up one of my projects. I installed openCV by conda install -c conda-forge opencv. When I run conda list, I can see openCV in the list. Running python -i and then import cv2 works, but when I open up Jupyter Notebook and navigate to that folder (I have to do it this way because running jupyter notebook in the directory also pulls up an error), and open up a notebook which imports cv2, I get an error. Why is this happening, and how would I solve it? Any kind of help will be greatly appreciated.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":977,"Q_Id":62329185,"Users Score":0,"Answer":"Usually that indicates that the notebook is running with a different Python or in a different environment from Python in the command prompt. Check sys.executable to see which Python it's running in, and sys.path to see where it's looking for imports","Q_Score":1,"Tags":"python,jupyter-notebook,anaconda,conda","A_Id":62329248,"CreationDate":"2020-06-11T16:37:00.000","Title":"ModuleNotFoundError in jupyter notebook when importing a module after conda install","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use conda to set up one of my projects. I installed openCV by conda install -c conda-forge opencv. When I run conda list, I can see openCV in the list. Running python -i and then import cv2 works, but when I open up Jupyter Notebook and navigate to that folder (I have to do it this way because running jupyter notebook in the directory also pulls up an error), and open up a notebook which imports cv2, I get an error. Why is this happening, and how would I solve it? Any kind of help will be greatly appreciated.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":977,"Q_Id":62329185,"Users Score":1,"Answer":"So as I said before, I wasn't able to start Jupyter Notebook from the command line, I had to start it from the start menu and navigate to my folder. Because of that, my notebook wasn't working in the conda environment that I created. I fixed that by running python -m ipykernal install --user --name <env_name> --display-name \"<display_name>\". I had to conda install ipykernel. It works now. Thanks for the other answers.","Q_Score":1,"Tags":"python,jupyter-notebook,anaconda,conda","A_Id":62345858,"CreationDate":"2020-06-11T16:37:00.000","Title":"ModuleNotFoundError in jupyter notebook when importing a module after conda install","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just have finished the project with Python. I need to add requirements.txt. Is there a way in a command line to list all the dependencies I have been using along with their versions? \nI have researched but it looks like I need to go manually through every single one of them, I was wondering if there is a better way to accomplish this?\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":62329755,"Users Score":0,"Answer":"to do that you need to type the following command pip\/pip3 freeze\nafter that you can copy the dependencies into the requirements.txt file","Q_Score":1,"Tags":"python,import,dependencies,requirements","A_Id":62330296,"CreationDate":"2020-06-11T17:07:00.000","Title":"is there a way to list all dependancies that being used for the specific project 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":"Hii am using pycharm IDE, I wanted to use boto3 module and installed successfully. But my python program keep saying module boto3 not found ..I verified interpreter it all correct ...can some one suggest","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":62330988,"Users Score":0,"Answer":"Did you install it through pycharm or simply install it through your terimnal?","Q_Score":0,"Tags":"python,module,pycharm,boto3","A_Id":62332116,"CreationDate":"2020-06-11T18:21:00.000","Title":"Pycharm says no boto3 module even though I installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to be a good citizen and make sure my notebook session is terminated immediately after running even if I'm not sitting at my machine.\nIs there any code I can run in a notebook cell to achieve this?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":1360,"Q_Id":62331439,"Users Score":-1,"Answer":"!pkill --oldest\n!pkill is used to kill the program and --oldest is used to kill the oldest program","Q_Score":16,"Tags":"python,bash,google-colaboratory","A_Id":66281766,"CreationDate":"2020-06-11T18:49:00.000","Title":"How to terminate current colab session from notebook cell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Bitwise NOT is the first complement, for example: \n\nx = 1 (binary: 0001)\n~x = -2 (binary: 1110) \n\nHence, my question is why -2 in binary is (-0b10) as for the python compiler? \nWe know that 1110 represents (14) for unsigned integer and (-2) for signed integer.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":122,"Q_Id":62332193,"Users Score":3,"Answer":"Two's complement inherently depends on the size of a number. For example, -2 on signed 4-bit is 1110 but on signed 8-bit is 1111 1110.\nPython's integer type is arbitrary precision. That means there is no well-defined leading bit to indicate negative sign or well-defined length of the two's complement. A two's complement would be 1... 1110, where ... is an infinite repetition of 1.\nAs such, Python's integer are displayed as a separate sign (nothing or -) and the absolute number. Thus, -2 becomes - and 0b10 \u2013 i.e. - 2. Similarly, -5 becomes - and 0b101 \u2013 i.e. - 5.\nNote that this representation is merely the standard representation to be human-readable. It is not necessarily the internal representation, which is implementation defined.","Q_Score":3,"Tags":"python,binary","A_Id":62332673,"CreationDate":"2020-06-11T19:36:00.000","Title":"Why the binary representation is different from python compiler than what we know on paper?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two-time series datasets i.e. errors received and bookings received on a daily basis for three years (a few million rows). I wish to find if there is any relationship between them.As of now, I think that cross-correlation between these two series might help. I order to so, should I perform any transformations like stationarity, detrending, deseasonality, etc. If this is correct, I'm thinking of using \"scipy.signal.correlate\u00b6\" but really want to know how to interpret the result?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":704,"Q_Id":62335396,"Users Score":2,"Answer":"scipy.signal.correlate is for the correlation of time series. For series y1 and y2, correlate(y1, y2) returns a vector that represents the time-dependent correlation: the k-th value represents the correlation with a time lag of \"k - N + 1\", so that the N+1 th element is the similarity of the time series without time lag: close to one if y1 and y2 have similar trends (for normalized data), close to zero if the series are independent.\nnumpy.corrcoef takes two arrays and aggregates the correlation in a single value (the \"time 0\" of the other routine), the Pearson correlation, and does so for N rows, returning a NxN array of correlations. corrcoef normalizes the data (divides the results by their rms value), so that he diagonal is supposed to be 1 (average self correlation).\nThe questions about stationarity, detrending, and deseasonality depend on your specific problem. The routines above consider \"plain\" data without consideration for their signification.","Q_Score":3,"Tags":"python,scipy,time-series,cross-correlation","A_Id":62385883,"CreationDate":"2020-06-11T23:53:00.000","Title":"How do I perform crosscorelation between two time series and what transformations should I perform in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have gotten decent results using the default regression objective function with XGBoost and a random forest with early stopping. \nMy goal is to be able to predict the bottom decile of my data well, and I am wondering if there is an objective function that will allow me to do this? I am less concerned about the other deciles, so long as I can predict the bottom well.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":62335589,"Users Score":1,"Answer":"Well, you could define a categorical variable, equal to 0 in the bottom decile and 1 otherwise, and then use  XGBClassifier. This has the potential of working better (I have had some success with classifiers in regression problems).","Q_Score":1,"Tags":"python,regression,xgboost","A_Id":62335720,"CreationDate":"2020-06-12T00:20:00.000","Title":"XGBoost objective function for regression where I am most concerned about predicting bottom decile","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a website in node.js and I have used child process to run python scripts and use their results in my website. But when I host my application on heroku, heroku is unable to run the python scripts. \nI have noticed that heroku was able to run python scripts which only had inbuilt python packages like sys, json but it was failing for scripts which were using external packages like requests, beautifulsoup.\nAttempt-1\nI made a requirements.txt file inside the project folder and pushed my code to heroku again. But it was still not working. I noticed that heroku uses the requirements.txt file only for python based web applications but not for node.js applications. \nAttempt-2\nI made a python virtual env inside the project folder and imported the required python packages into the venv. I then removed gitignore from the venv and pushed the whole venv folder to heroku. It still didn't work.\nPlease let me know if anyone came across a way to handle this.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":423,"Q_Id":62338454,"Users Score":0,"Answer":"Solution:\nHave a requirements.txt file in your project folder. \nAfter you create a heroku app using \"heroku create\", heroku will identify your app as python based and will not download any of the node dependencies. \nNow, go to your heroku profile and go to your app's settings. There is an option named \"Add Buildpack\" in there. Click on that and add node.js as one of the buildpacks.\nGo back to your project and push it to heroku. This time heroku will identify your app as both python and node.js based and will download all the required files.","Q_Score":0,"Tags":"python,node.js,heroku,web-applications","A_Id":62344858,"CreationDate":"2020-06-12T06:05:00.000","Title":"Heroku not working for Node.js file with python scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"The result in one of my cells is truncated with the message: \"Output was trimmed for performance reasons.\nTo see the full output set the setting \"python.dataScience.textOutputLimit\" to 0.\"\nFrom researching answers to similar questions, I modified the settings.json to include the following line of code: \n\"python.dataScience.textOutputLimit\": 0. However, the same message keeps showing up in the output.\nWhat else could I be missing?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2323,"Q_Id":62339003,"Users Score":3,"Answer":"I'm a developer on this extension. That setting should be the correct one. I just tested it myself and it did correctly stop truncating after I changed it to zero. A couple of things to try.\n\nDid you re-execute that cell after changing the setting? It doesn't apply to an already executed cell, just one that is executed after the setting change.\nVSCode can apply settings either at the User or Workspace level. Could you possibly have that setting not applying to your current file? If you open the command > Preferences: Open Settings (UI) from the VSCode command palette you can search for textOutputLimit to check that it's set to 0 in the current context that you are working in. In that screen you can see both User (all workspaces) and Workspace (current workspace only) contexts for that setting.\n\nDoes that help to resolve it?","Q_Score":1,"Tags":"python,visual-studio-code,data-science,jupyter","A_Id":62418340,"CreationDate":"2020-06-12T06:52:00.000","Title":"Why is the output in my cell being truncated even though textOutputLimit is set to 0? (Jupyter Notebook, VSCode)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The result in one of my cells is truncated with the message: \"Output was trimmed for performance reasons.\nTo see the full output set the setting \"python.dataScience.textOutputLimit\" to 0.\"\nFrom researching answers to similar questions, I modified the settings.json to include the following line of code: \n\"python.dataScience.textOutputLimit\": 0. However, the same message keeps showing up in the output.\nWhat else could I be missing?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2323,"Q_Id":62339003,"Users Score":1,"Answer":"We need to ensure following  two conditions so the notebook output does not give 'show more (open the raw output data in a text editor) ...' message.\n\nset textOutputLimit to 0 in both user and workspace\nIn setting, search 'output', then look for features>Notebook>Output:Text Line Limit. set the limit to your choice, e.g. 2000\n\nThe above settings work for me in the following version\/platform:\nVersion: 1.59.1 (system setup)\nCommit: 3866c3553be8b268c8a7f8c0482c0c0177aa8bfa\nDate: 2021-08-19T11:56:46.957Z\nElectron: 13.1.7\nChrome: 91.0.4472.124\nNode.js: 14.16.0\nV8: 9.1.269.36-electron.0\nOS: Windows_NT x64 10.0.19042","Q_Score":1,"Tags":"python,visual-studio-code,data-science,jupyter","A_Id":68895002,"CreationDate":"2020-06-12T06:52:00.000","Title":"Why is the output in my cell being truncated even though textOutputLimit is set to 0? (Jupyter Notebook, VSCode)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a script which takes, say, an hour to generate the data I want. I want to be able to save all of the relevant variables to some external file so I can fiddle with them later without having to run the hour-long calculation over again. Is there an easy way I can save all of the variables I need into one convenient file?\nIn Matlab I would just contain all of the results of the calculation in a single structure so that later I could just load results.mat and I would have everything I need stored as results.output1, results.output2 or whatever. What is the Python equivalent of this?\nIn particular, the data that I would like to save includes arrays of complex numbers, which seems to present difficulties for using things like json.","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":661,"Q_Id":62339803,"Users Score":-1,"Answer":"You can use pickle function in Python and then use the dump function to dump all your data into a file. You can reuse the data later.I suggest you find more about pickle.","Q_Score":0,"Tags":"python,saving-data","A_Id":62339841,"CreationDate":"2020-06-12T07:46:00.000","Title":"How to save multiple data at once in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created an .exe file using auto-py-to-exe in windows 7 system and it doesn't work in windows 10 computer. How can I make this exe so generic hence should be executable to other windows version as well, specifically in windows 7 & 10.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":409,"Q_Id":62341016,"Users Score":0,"Answer":"We must use windows 10 for converting py to *.exe as somehow windows 7 converted file does not work in windows 10, whereas the reverse is not the case.","Q_Score":0,"Tags":"python,tkinter","A_Id":67549293,"CreationDate":"2020-06-12T09:03:00.000","Title":"auto-py-to-exe: Can't run exe created with windows 7 on windows 10 computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to create a price table by date, I tried to google this for python and django, but still have no idea for this. I don't want to create one to one relationship object like an options. but I would like to create the database associating date and price. Sorry that it may be simple question..\nWould it be solution to create a database by using PostgreSQL, and read by django? or any resource \/ reference can help get me in right direction to access this problem? \nThanks so much","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":62341966,"Users Score":0,"Answer":"Well there is more to it then assigning a price to a date. You will need one or more tables that hold the establishment(hotels) data. These would include the room information as all rooms will not have the same price. Also the price will probably change over time, so you will need to track that. Then there is the reservation information to track. This is just some of the basics. It is not a simple task by any means. I would try a simpler project to start with to learn Django and how to get data in and out of it.","Q_Score":0,"Tags":"python,django,database,postgresql","A_Id":62349333,"CreationDate":"2020-06-12T10:06:00.000","Title":"Any idea to create the price table which associate with date in Django(Python)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have two momentary switches called IR and IB. If I press just IR, then on my computer, the letter A is shown. If I press just IB, the letter B is shown. And if I press both of them, the letter C is shown.\nWhile the code seems obvious, the problem is, I would have to press both inputs at exactly the same time to register a keypress of C without accidentally registering a keypress of A or B.\nIf anyone one knows an algorithm or pseudo code to solve this problem, I would be down to hear it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":62344561,"Users Score":0,"Answer":"I don't know if this is what you were expecting but if you take pyinput module and make the thread wait like 0.35 second between two inputs and if both are A and B you display C","Q_Score":0,"Tags":"python,logic,fsm","A_Id":62344881,"CreationDate":"2020-06-12T12:46:00.000","Title":"Algorith to detect if two inputs are pressed in a loop without pressing them at exactly the same time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"this has been bugging me lately and I don't have a definitive answer for this.\nWhy python virtualenv is set at workspace level instead of project level.\nAt one time one can work on multiple projects and it's good to have all the projects in the single workspace and each project can have its own virtualenv.\nBut what happens if you have more than one virtualenv in one workspace. You have to manually select which  virtualenv to use.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":62345229,"Users Score":0,"Answer":"You can set the environment for a multi-root workspace in your multi-root workspace configuration, but the Python extension won't do it for you. It doesn't have any way to know that's what you mean as some people set different environment for different workspaces, so it takes the route of setting it per directory\/workspace.","Q_Score":0,"Tags":"python,visual-studio-code,virtualenv","A_Id":62398535,"CreationDate":"2020-06-12T13:26:00.000","Title":"Why does python virtualenv is set at workspace level instead of project level?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here is the thing.\nI build a trained network and save .meta and .data in ckpt. The optimizer is MomentumOptimizer:\ntf.train.MomentumOptimizer(learning_rate=lr, momentum=0.9, name='Momentum'), \nwhich is also saved in .meta.\nBut I forget to save paramters to do with Momentum, So when I load graph form .meta, there will be Error:\n\nAttempting to use uninitialized value fc.bias\/Momentum\n\nI know that I can use initializer() , but in this way how to set\nmomentum=0.9 ? would this initializer() just give a random values to momentum?\nI have trained the model for a long time, there is not way for me to train it from scratch again to save xx\/Momentum. So what can I do to fix it? That is, how can I set  momentum=0.9 in MomentumOptimizer when loading .meta ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":62345912,"Users Score":0,"Answer":"momentum=0.9is saved when saving the model, so don't worry about it.\n   Or you can make momentum a placeholder so you can load whatever you want when resotring models.","Q_Score":0,"Tags":"python,tensorflow,optimization,deep-learning,momentum","A_Id":62368990,"CreationDate":"2020-06-12T14:04:00.000","Title":"tensorflow Optimizer: Attempting to use uninitialized value fc.bias\/Momentum","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to change what happens in train_step when using a custom optimizer but I get this error message when trying to compile the model: \n\nraise ValueError('Could not interpret optimizer identifier:', identifier) ValueError: ('Could not interpret optimizer identifier:', <main.Optimizer_quazi_Newton object at 0x0000019CFCC2EF60>)\n\nThe problem I'm having is that I want to selectively be able to feed the same data during training depending on what happens in the optimizer. My optimizer has a variable which basically say \"I want the same data again\" and I want to modify the fit function so that when the optimizer needs it I can feed it the same data instead of going to the next batch.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":62346973,"Users Score":0,"Answer":"Ops, I was using different API's for my optimizer and my model, one was using keras, the other was using tensorflow.keras. If anyone runs into similar issues this might be the problem.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":62390245,"CreationDate":"2020-06-12T15:02:00.000","Title":"Keras customizing train_step when using a custom optimizer","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the with block to extract information from a file, and I am surprised that any variables declared in the with block are global. Shouldn't they be local to the with block, and shouldn't you need to use global myVar before changing global variables? After all, with defines a code block, right?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":62347051,"Users Score":0,"Answer":"A with statement does not create a scope (like if, for and while do not create a scope either).\nAs a result, Python will analyze the code and see that you made an assignment in the with statement, and thus that will make the variable assignment.\nInitialization before the with scope can be safer in the sense that after the with statement we can safely assume that the variable exists. If on the other hand the variable should be assigned in the with statement, not initializing it before the with statement actually results in an additional check: Python will error if somehow the assignment was skipped in the with statement.","Q_Score":1,"Tags":"python,python-3.x,global-variables,with-statement","A_Id":62347300,"CreationDate":"2020-06-12T15:07:00.000","Title":"Why doesn't the with block in Python need the global keyword?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am faced with a problem regarding a categorical variable. In my case, my variable may have varying number of levels. For example, suppose, my categorical variable represents type_of_cars. Initially, it had only three types (for argument's sake):gas,\ndiesel and hybrid. I have used an encoding to represent them. Now a new type of cars come to the market which is eV (for electric vehicle). I want to know if there is a way to accommodate EVs without retraining a model. \nIn my case, the categorical variable has roughly 50 different levels and new levels may be added as time goes on or old ones may be deleted. How do I go about modeling the data without retraining the entire model each time it happens, if it is at all possible?\nYour suggestions will be greatly appreciated.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":71,"Q_Id":62350752,"Users Score":1,"Answer":"The best way is to just retrain your model. \nThinking about how a categorical variable affects your model might be helpful. Categorical variables are generally treated a binary variables where each category is its own column, the row in that column is a 1 if that category is present and a 0 otherwise. Now imagine adding an additional column to your data for which your model has not been trained, as would be the case with a new category... this will result in sub-optimal performance. Most likely, this new column will have no affect on the model prediction. \nThere are examples of what you are suggesting, but they require a secondary model be fed into a primary model. We see this often in Natural Language Processing, where there is a model for how texts are similar (a word vector) and this model is then fed into another model that predicts things like text category and sentiment. \nSo basically, if you can model the similarities of your categorical variables (this is your secondary model), and feed that model into primary model, then you would only need update your secondary model when you get new data. But this approach has its issues...","Q_Score":2,"Tags":"python,data-science,statsmodels","A_Id":62351156,"CreationDate":"2020-06-12T18:57:00.000","Title":"How to handle modeling categorical variables where categories may change over time?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was doing some project by using django\nand I realized that I forgot to activate virtualenv.\nI already made some changes and applied it not on the venv,\nand created superuser on the system.\n\nHow to find any changes on the system?\nhow to remove superuser that I made on the system\nand what are the cmd commands for that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":629,"Q_Id":62351016,"Users Score":0,"Answer":"If you haven't setup an additional database for your project and you have used django-admin startproject you'll just have a standard django setup, and you will be using sqlite. With this setup, your database is stored in a file in your root directory (for the project) called db.sqlite3.\nThis is where the super-user you have created will be stored. So it does not matter if the virtualenv was activated or not. Your superuser will have been created in the right place. \nTLDR: No need to worry, the superuser you created will most likely be in the right place.","Q_Score":0,"Tags":"python,django,virtualenv","A_Id":62352165,"CreationDate":"2020-06-12T19:17:00.000","Title":"How to remove superuser on the system in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Okay please do not close this and send me to a similar question because I have been looking for hours at similar questions with no luck.\nPython can search for digits using re.search([0-9])\nHowever, I want to search for any whole number. It could be 547 or 2 or 16589425. I don't know how many digits there are going to be in each whole number.\nFurthermore I need it to specifically find and match numbers that are going to take a form similar to this: 1005.2.15 or 100.25.1 or 5.5.72 or 1102.170.24 etc.\nIt may be that there isn't a way to do this using re.search but any info on what identifier I could use would be amazing.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":62351077,"Users Score":0,"Answer":"Assuming that you're looking for whole numbers only, try re.search(r\"[0-9]+\")","Q_Score":0,"Tags":"python","A_Id":62351135,"CreationDate":"2020-06-12T19:21:00.000","Title":"How to get python to search for whole numbers in a string-not just digits","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I made python 3.x program that run on windows cmd and print some log.\nWill it consume all memory in RAN in long term? or CMD will delete old log by its self?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":25,"Q_Id":62351188,"Users Score":3,"Answer":"CMD will remove the old log\/output. So nothing will be broken.","Q_Score":1,"Tags":"python-3.x,cmd","A_Id":62351217,"CreationDate":"2020-06-12T19:29:00.000","Title":"Will Python print() broke CMD in long term?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to write a status bar module for dwm in python. I want the status bar to change to a specific string when pacman \/ apt or dnf is running. Is there a distribution independent way to check if some package manager is currently running and is it possible to extract information from it for example the download progress so it can be displayed in the status bar.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":439,"Q_Id":62351677,"Users Score":1,"Answer":"After some research and messing around the \/var\/lib\/pacman\/ folder I discovered that pacman and other package managers all create a file named db.lck file when running and I just checked if the files existed and it did the trick. I currently still can't find a way to access the output of the commands but it's better than nothing.","Q_Score":1,"Tags":"python,linux,archlinux,package-managers,debian-based","A_Id":62353240,"CreationDate":"2020-06-12T20:02:00.000","Title":"Is there a way to see if a package manager is currently running on linux?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to write a status bar module for dwm in python. I want the status bar to change to a specific string when pacman \/ apt or dnf is running. Is there a distribution independent way to check if some package manager is currently running and is it possible to extract information from it for example the download progress so it can be displayed in the status bar.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":439,"Q_Id":62351677,"Users Score":0,"Answer":"Just a thought - pacman seems to be fairly verbose in its logging to \/var\/log\/pacman.log, so tailing that file when the lock is active will at least tell you what's going on at the moment.","Q_Score":1,"Tags":"python,linux,archlinux,package-managers,debian-based","A_Id":64393047,"CreationDate":"2020-06-12T20:02:00.000","Title":"Is there a way to see if a package manager is currently running on linux?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using Python with cx_Oracle, and I'm trying to do an INSERT....SELECT.   Some of the items in the SELECT portion are variable values.   I'm not quite sure how to accomplish this.   Do I bind those variables in the SELECT part, or just concatenate a string?\n\n  v_insert = (\"\"\"\\\n    INSERT INTO editor_trades\n      SELECT \" + v_sequence + \", \" + issuer_id, UPPER(\" + p_name + \"), \" + p_quarter + \", \" + p_year +\n            \", date_traded, action, action_xref, SYSDATE\n      FROM \" + p_broker.lower() + \"_tmp\") \"\"\")\n\nMany thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":62351723,"Users Score":0,"Answer":"With Oracle DB, binding only works for data, not for SQL statement text (like column names) so you have to do concatenation. Make sure to allow-list or filter the variables (v_sequence etc) so there is no possibility of SQL injection security attacks.  You probably don't need to use lower() on the table name, but that's not 100% clear to me since your quoting currently isn't valid.","Q_Score":1,"Tags":"python,dynamic,insert","A_Id":62366734,"CreationDate":"2020-06-12T20:05:00.000","Title":"Dynamic Select Statement In Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Jupyter lab installed on Windows. I installed Jupyter Lab on WSL Ubuntu. I can lunch Jupyter Lab from Linux terminal.  This will open Jupyter Lab on Chrome browser from which I can start a new Jupyter Notebook with Python [conda env:root]*. However, it only shows the windows file system. I try to open my note book that is saved on the Linux file system using: \n$ jupyter lab my_linux_folder\/my_notebook.ipynb\nJupyter lab lunches successfully, but cannot open the notebook that is on the Linux file system and gives an error:\n\nCannot open \n  Could not find path: \/my_notebook.ipynb\n\nIs it possible to open a notebook that is on the Linux file system \"\\wsl$\\\" and how? \nHow to go to \"\\wsl$\\\" from JupyterLab file browser? \nOr more generally how to open a notebook that is saved under \"\\wsl$\\\"  ?","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10840,"Q_Id":62353890,"Users Score":0,"Answer":"Try going to \\\\wsl$\\{wsl distro name}\\home\\{user name}\\my_linux_folder\\\nLonger explanation: browse to \\\\wsl$\\ and see what you see there. There should be a distro name (Ubuntu, perhaps?) then you will have access to the root filesystem of your WSL. You can go to the home directory, then select your username, then your files should look familiar.\nYou could go the other way, and point Jupyter to a windows folder from Linux. However, assuming you might be using WSL2, the first method has much better performance.","Q_Score":5,"Tags":"python,jupyter-notebook,filesystems,windows-subsystem-for-linux,jupyter-lab","A_Id":62371488,"CreationDate":"2020-06-12T23:38:00.000","Title":"Windows Subsystem for Linux (WSL 2) and Jupyter Lab : How to open a Jupyter Notebook saved at the Linux file system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Wanting to expand my horizons I decided to pick up programming and I've read that python is very beginner-friendly, knowing this I downloaded the program in addition to the PyCharm text editor and started to write some small stuff like print commands and the like. However, I wanted to start doing more and embarked on a mission to replicate a game off the internet, more specifically snake just to see how it all functions together in a cohesive manner. Every tutorial begins with \"import\" commands in addition to something like \"math\" and \"random\" directly after, turning red every single time. But for me, it just turns grey with the original orange \"import\" text also turning grey with a help icon saying to optimize my imports but just deleting my text altogether when I click it. I can find anything on the web to help me with what I'm dealing with leading me to believe that its probably an easy fix that I, for whatever reason can't seem to find. I really don't have a clue as to what to do and im increasingly becoming more and more frustrated.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":50,"Q_Id":62355522,"Users Score":2,"Answer":"That is okay, PyCharm is only signaling you that you haven't used that module yet. This can help Developers in large programs to save code and memory. Don't worry about it just ignore it and continue.","Q_Score":1,"Tags":"python","A_Id":62356636,"CreationDate":"2020-06-13T04:27:00.000","Title":"How do I optimize imports in Python using 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":"thanks for reading! I've created a python program using selenium that uploads a file onto a website automatically. I've placed the .py file and chrome driver in a folder on my desktop and set my executable path to \"chromedriver.exe\". When I run the program from IDLE, the program runs without any issue. When I try to run it from the command line, however, the program cannot find the chromedriver. I've placed them in that folder because I'd like to share the thing with my co-workers and plan on using a VBA script from an Excel to call the python program and pass some variables. My assumption is that since all the files are in the same folder, path would not be an issue.\nHow do I make it so that all path dependencies are eliminated?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":62355838,"Users Score":0,"Answer":"You should try to specify full path to chromedriver.exe like C:\\users\\username\\Desktop\\projectfolder\\chromedriver.exe","Q_Score":0,"Tags":"python,selenium,selenium-chromedriver,filepath","A_Id":62359791,"CreationDate":"2020-06-13T05:17:00.000","Title":"Python program can't find chromedriver from when run from cmd prompt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I came across certain built-in functions such as zip and map.\nI tried printing these functions, they resulted as zip object at 0x1007a06c8 or <map object at 0x003AB2E0>.\nI understand that these functions return iterators, but I can also use a for loop to run through strings\/lists\/dicts as iterators. Thus, how are zip and map different, and how I am able to show them? What are some other examples that I should be aware of?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":163,"Q_Id":62357820,"Users Score":1,"Answer":"zip, map and also range are no collections like lists, strings, sets or dicts, because they are evaluated lazily. This means, that they do not explicitly contain all the values, but only generate the next value when asked to do that (e.g. in a loop or when unpacked in a list).\nSo lists and maps are iterable, because you can iterate over them, but maps are generators, while lists are containers.\nYou can unpack generators to a list with list(map(...)) (also works sets or tuples and others), or use the asterisk (*) to unpack them to individual arguments of a function (print(*map(...))).","Q_Score":2,"Tags":"python","A_Id":62357889,"CreationDate":"2020-06-13T09:27:00.000","Title":"Why are you unable to print certain iterators like zip or map?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say for example the values for a certain column is a dictionary which can be of different lengths. How do I subset the dataframe rows such that the length of the dictionary is more than 1? \nI tried,\nmore_than_1 = data[len(data[\"column_name\"]) > 1] \nBut it doesn't work?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":62359848,"Users Score":0,"Answer":"You can apply len to the column containing the dict, and boolean index on that.\ndf[df[\"column_name\"].apply(len)>1]","Q_Score":0,"Tags":"python-3.x,pandas,numpy","A_Id":62360707,"CreationDate":"2020-06-13T12:36:00.000","Title":"How do I subset a dataframe based on the length of the dictionary?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So basically, else block for if-else coupling only work when if condition is not met so it is kind of necessary. In for-else coupling and while-else coupling, its executed when the loop cannot be executed for some reason. So, what we can not accomplished by not using else in try-except-else coupling. I meant if the reason is to detect if no exception is raised, we can simply put a print statement in the end of try block to achieve it. What is the vital role of else in try-except-else coupling?\n(Hi all! I\u2019m very new to programming and StackOverflow too. But I\u2019ve tried to make the question as synced with decorum of site as possible)","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":62360862,"Users Score":0,"Answer":"There is no such thing as coupling in python for else. All the constructs you mentioned above coupled with else will work just fine without even using else. You can use if, for, while and try-except all without else. However, the role of else in python is: to execute a code instead of the code in block just above.\nNote that it is irrelevant to else that what block is above it or with whom it is coupled. It will only be executed if the block above is not. And resultant block maybe or may not be vital or something which cannot be achieved by other means.","Q_Score":3,"Tags":"python","A_Id":62360871,"CreationDate":"2020-06-13T14:05:00.000","Title":"What is the role of else in try-except-else coupling in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Stuck on a single step and doc searching isn't helping...\nIn Connect I have:\n\nStore customer input : \"What's your age?\"\nSet contact attribute: age -> system -> stored customer input\n\nI know the above works because I've had a Play Prompt read back the attribute. \nI want Lambda to handle somethings with the age. I setup a function, I attached it to the Connect instance. I added it to the flow with a simple value pair response and that works (the Play Prompt plays back the non-dynamic response from Lambda).\nWhen I try to make it dynamic breaks.\nMy understanding is that I should be able to get to this attribute in Lambda by using the passed JSON.... so I'm doing this:\nage = event[\"Details\"][\"ContactData\"][\"Attributes\"][\"age\"]\nConnect starts saying it has trouble accessing the attribute and ends the call. What am I doing wrong? The rest of the Python code is fine because if I hard set age (age = 24) the code runs fine.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":175,"Q_Id":62363320,"Users Score":0,"Answer":"There was nothing wrong my code as it pertains to the lambda \/ connect integration... it was with something that was just causing an error. I started monitoring the function in cloudwatch and that helped!","Q_Score":0,"Tags":"python-3.x,amazon-web-services,aws-lambda","A_Id":62411434,"CreationDate":"2020-06-13T17:22:00.000","Title":"Passing attribute from AWS Connect to Lambda using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"is a Linux based system needed for python hacking? I just watching my Udemy ethical hacking with python course and\nhe kept saying you need Linux based O.P system.\nWhy you need a Linux Operating System\nI didn't understand it because he didn't explain why we need to use it so I'm asking here can you explain?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":96,"Q_Id":62364149,"Users Score":1,"Answer":"In general, you don't need a GNU\/Linux system to learn Python, but since you are learning it with an online course the course's materials may be written for a certain GNU\/Linux distribution. So, it would be easier for you to follow the course if you have the software suggested for the course.\nIn the course you mentioned, they use Kali Linux, a distribution for security and forensic professionals. I suppose, it has a lot of tools for hacking preinstalled and working out of the box. In the introduction, the course also describes how to install the distribution in a virtual  machine, so you can use it on a Mac or Windows.","Q_Score":0,"Tags":"python,linux","A_Id":62364291,"CreationDate":"2020-06-13T18:38:00.000","Title":"is linux based system needed for python hacking?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"What I want to do is mimic an operating system without reinventing the wheel. When my Pi boots up I want it to have a custom bootup so it goes straight into my program.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":34,"Q_Id":62367259,"Users Score":1,"Answer":"What SO it have? Raspian? LibreElec? another one?\nIf you are on raspian you can edit \/etc\/rc.local and put over there the commands to start the programs","Q_Score":0,"Tags":"java,python,raspberry-pi","A_Id":62367377,"CreationDate":"2020-06-14T00:58:00.000","Title":"How to boot to program 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 use Heroku to host my discord.py bot, and since I've started using sublime merge to push to GitHub (I use Heroku GitHub for it), Heroku hasn't been running the latest file. The newest release is on GitHub, but Heroku runs an older version. I don't think it's anything to do with sublime merge, but it might be. I've already tried making a new application, but same problem. Anyone know how to fix this?\nEdit: I also tried running Heroku bash and running the python file again","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":62368748,"Users Score":1,"Answer":"1) Try to deploy branch (maybe another branch)\n2) Enable automatic deploy","Q_Score":1,"Tags":"python,heroku","A_Id":62368911,"CreationDate":"2020-06-14T05:35:00.000","Title":"Heroku won't run latest python 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":1},{"Question":"Say I had a PostgreSQL table with 5-6 columns and a few hundred rows. Would it be more effective to use psycopg2 to load the entire table into my Python program and use Python to select the rows I want and order the rows as I desire? Or would it be more effective to use SQL to select the required rows, order them, and only load those specific rows into my Python program.\nBy 'effective' I mean in terms of:\n\nMemory Usage.\nSpeed.\n\nAdditionally, how would these factors start to vary as the size of the table increases? Say, the table now has a few million rows?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":546,"Q_Id":62370940,"Users Score":3,"Answer":"Actually, if you are comparing data that is already loaded into memory to data being retrieved from a database, then the in-memory operations are often going to be faster.  Databases have overhead:\n\nThey are in separate processes on the same server or on a different server, so data and commands needs to move between them.\nQueries need to be parsed and optimized.\nDatabases support multiple users, so other work may be going on using up resources.\nDatabases maintain ACID properties and data integrity, which can add additional overhead.\n\nThe first two of these in particular add overhead compared to equivalent in-memory operations for every query.\nThat doesn't mean that databases do not have advantages, particularly for complex queries:\n\nThey implement multiple different algorithms and have an optimizer to choose the best one.\nThey can take advantage of more resources -- particularly by running in parallel.\nThey can (sometimes) cache results saving lots of time.\n\nThe advantage of databases is not that they provide the best performance all the time.  The advantage is that they provide good performance across a very wide range of requests with a simple interface (even if you don't like SQL, I think you need to admit that it is simpler, more concise, and more flexible that writing code in a 3rd generation language).\nIn addition, databases protect data, via ACID properties and other mechanisms to support data integrity.","Q_Score":4,"Tags":"python,sql,postgresql,psycopg2","A_Id":62371705,"CreationDate":"2020-06-14T09:54:00.000","Title":"Is it faster and more memory efficient to manipulate data in Python or PostgreSQL?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I declare a as ((5, 3)), I want a[0] to be equal to (5, 3). However, Python simpifies the expression to (5, 3).\nWhy are tuples simplified like that and do I have to use lists to express the same thing? ((5, 3), (3, 8)) works just fine.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":246,"Q_Id":62371026,"Users Score":4,"Answer":"Tuples with a single element must be declared with the syntax (x,). Otherwise, parentheses are interpreted as a means of clarifying computations (or changing priorities with respect to operations).","Q_Score":1,"Tags":"python,python-3.x","A_Id":62371058,"CreationDate":"2020-06-14T10:04:00.000","Title":"Why are double parentheses in tuples converted to single parentheses (Python)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know there are several ways to kill a process if I know the process id.\nBut similar to ctrl+C in keyboard interrupt, looking for such interrupt using a command.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":62373356,"Users Score":0,"Answer":"use this Command to kill the process(\nkillall -s 9 [process name]  )","Q_Score":0,"Tags":"python,linux,process,kill","A_Id":62373407,"CreationDate":"2020-06-14T13:44:00.000","Title":"How can I stop the running command in linux without knowing the pid?","Data Science and Machine Learning":0,"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 retrieve the file path of where a file was copied from. As in, let's say I have 'FileA' in dir1, and I copy it to dir2. Is there any way (preferably in Python) to examine the copied file in dir2 and retrieve the dir1 file path where the file was copied from?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":24,"Q_Id":62374579,"Users Score":2,"Answer":"No, you cannot do it by just examining the file in dir2. Such information can be in system or user logs or something like this but not in the destination file.","Q_Score":0,"Tags":"python,directory,copy,filepath","A_Id":62374742,"CreationDate":"2020-06-14T15:27:00.000","Title":"Python retrieve filepath of where file was copied from","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new with Angular and have no idea what I am supposed to do to resolve this problem. In my code, there is an HTML 5 video tag and a button. when the button is clicked, a python code is supposed to perform an operation on live video and stream it to the web API that I am supposed to develop. This streamed video is to be shown through the video tags.\nI must use angular for the front-end and I am supposed to tell the python developer what I need from him. If video tags are not right way of doing this, I could change that. For reference, I have posted my HTML code here. Also, the button click must pass an integer value to the python code, which I am assuming would be by calling a function with an argument. Please guide.\n`Start\n \n`","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":62374965,"Users Score":0,"Answer":"I have done similar things by using this, but in vanilla javascript. When the button is clicked my index function in python Flask get executed.\n<button type=\"button\" class=\"btn btn-primary\" onclick=\"window.location.href='\/'\">Home<\/button>","Q_Score":0,"Tags":"python,angular,video-streaming,integration","A_Id":62375081,"CreationDate":"2020-06-14T16:00:00.000","Title":"Calling Python function from angular button and displaying output video in video tag","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to append something on entity while it exists and do not append the entity if it doesn't exist. How will I be able to achieve it? I tried following but it doesn't work the way I want.\ntask = table_service.get_entity('datas', '..com','asss','Hello')\ntable_service.insert_or_replace_entity('tasktable', task)\nIf the entity exists :\nI want to append that hello with something as:\n('datas', '..com','asss','Hello;123')\nIf the entity doesnt exist :\nI want to insert as:\n('datas', '..com','asss','Hello')","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":211,"Q_Id":62375424,"Users Score":0,"Answer":"If you want to append something to one existing entity property's value, it is impossible. Because Azure table storage does not provide any operation to do that.  Azure Table storage just provides operations to manage entity and it does not provide operations to manage Azure table entity properties. So you just can set a new value for one existing entity property. \nRegarding how to do that, we can use update or merge operation. But please note that the two operations will cause  different result. The update operation replaces the entire entity. Those properties from the previous entity will be removed if the request does not define or include them. The merge operation does not replace the existing entity. Those properties from the previous entity will be retained if the request does not define or include them.","Q_Score":0,"Tags":"python-3.x,azure,azure-cosmosdb,azure-table-storage","A_Id":62441229,"CreationDate":"2020-06-14T16:39:00.000","Title":"Append Entity on Microsoft Azure Table Storage Insert or Replace","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a large dataset spanning many years and I want to subset this data frame by selecting data based on a specific day of the month using python.\nThis is simple enough and I have achieved with the following line of code:\ndf[df.index.day == 12]\nThis selects data from the 12th of each month for all years in the data set. Great.\nThe problem I have however is the original data set is based on working day data. Therefore the 12th might actually be a weekend or national holiday and thus doesnt appear in the data set. Nothing is returned for that month as such. \nWhat I would like to happen is to select the 12th where available, else select the next working day in the data set.\nAll help appreciated!","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":62376907,"Users Score":0,"Answer":"You can backfill the dataframe first to fill the missing values then select the date you want\ndf = df.asfreq('d', method='bfill')\nThen you can do df[df.index.day == 12]","Q_Score":0,"Tags":"python,pandas,date,datetime","A_Id":62376993,"CreationDate":"2020-06-14T18:53:00.000","Title":"select a specifc day from a data set, else the next working day if not available","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been trying to build a micropython for esp32-camera and I keep getting errors during the make process when building some of the drivers in the mp\/ports\/esp32\/modules directory.  The error I get is a syntax error.  For example there's a file named ntptime.py in this directory and it contains a single line:\n..\/..\/esp8266\/modules\/ntptime.py\nand that results in \"SyntaxError: invalid syntax\"\nI've programmed python for a while, but am not familiar with this concept and don't understand how it can work, but maybe it can?  I'm not familiar with doing that and since it's not working when I run make, maybe there's something setup-wise that I've missed or whatever.  Can anyone shed some light on this practice and explain under what circumstances this works to direct make (or the python compiler) to resolve this statement by loading the source from the directory specified in that single line of code.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":96,"Q_Id":62377346,"Users Score":1,"Answer":"Duh, can't believe I missed this:  there \"files\" are symbolic links;  I should've remembered that, but alas, I'm getting older by the minute!\nStill, it doesn't answer the question as to why they weren't being recognized during make but instead throwing a SyntaxError; but I'll leave that for another day.","Q_Score":0,"Tags":"makefile,build,esp32,micropython","A_Id":62430386,"CreationDate":"2020-06-14T19:36:00.000","Title":"Odd python driver files in micropython for esp32 and esp8266 cause make errors","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Has anyone successfully tried installing fbprophet on anaconda?\nWhen i try to install it, i get an incompatibility error.\nI'd be very surprised if there isn't fbprophet for python 3.7 +\nUnsatisfiableError: The following specifications were found\nto be incompatible with the existing python installation in your environment:\nSpecifications:\n\nfbprophet -> python[version='2.7.|3.5.|3.6.*']\n\nYour python: python=3.7\nIf python is on the left-most side of the chain, that's the version you've asked\n for.When python appears to the right, that indicates that the thing on the left is s\nomehow not available for the python version you are constrained to. Note that conda wil\nl not change your python version to a different minor version unless you explicitly sp\necify that.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":826,"Q_Id":62377962,"Users Score":0,"Answer":"I have managed to fix this. I downloaded the fbprophet zipped package for Windows from the github repo, extracted the contents and launched anaconda, cd to condabin, then ran pip install specifying the path to the package folder.\nHope this helps anyone stuck in the same situation !!!\nRegards,\nOchen","Q_Score":0,"Tags":"python,anaconda,data-science","A_Id":62599183,"CreationDate":"2020-06-14T20:41:00.000","Title":"module fbprophet incompatible for python 3.7.* and higher?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to figure out the position of the moon given an observer in a lunar orbit. I have searched the internet already, but cannot find if PyEphem has this capability. Any suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":26,"Q_Id":62379196,"Users Score":1,"Answer":"PyEphem does not, alas, have that capability.","Q_Score":0,"Tags":"python,astronomy,pyephem","A_Id":62387529,"CreationDate":"2020-06-14T23:05:00.000","Title":"PyEphem -- satellites with a lunar orbit?","Data Science and Machine Learning":0,"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 use custom dateset while using code of stylegan. \nwhen it building tensorflow graph the following error will come:\nValueError: Op type not registered 'MaxBytesInUse' in binary running on DESKTOP. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) tf.contrib.resampler should be done before importing the graph, as contrib ops are lazily registered when the module is first accessed. while building NodeDef 'MaxBytesInUse'\nI am new to deep learning \nyour help will be great favour for me.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":62379805,"Users Score":0,"Answer":"in stylgan repo, itst recommended to use TensorFlow 1.10.0 which led to the \"MaxByteinUse\" error,\nchanging to'tensorflow-gpu==1.11.0' worked for me","Q_Score":0,"Tags":"python,tensorflow","A_Id":67822262,"CreationDate":"2020-06-15T00:47:00.000","Title":"Op type not registered 'MaxBytesInUse' in binary running on DESKTOP","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want my flask server to do a certain task when its idle for some time lets say 5 mins, i.e after 5 mins it will do another job. For this i need something to check if a server is busy or idle. How can I achieve this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":429,"Q_Id":62380710,"Users Score":0,"Answer":"You can save the current datetime in a variable everytime a request is made via the @app.after_request annotation.\nThen you need a routine to periodically check if the time difference between now and the saved timestamp is greater than 5 miutes. If so then run your task.\nFor executing your check every 5 minutes you may need some kind of scheduler which will be started with your application.","Q_Score":0,"Tags":"python,flask","A_Id":62388338,"CreationDate":"2020-06-15T03:04:00.000","Title":"Checking if a flask server is busy or idle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I get this error in discord.py bot what this means - error details 400 Bad Request (error code: 50035): Invalid Form Body\nIn content: Must be 2000 or fewer in length.\nThe fun fact is that i get this sometimes and sometimes not in the same code .","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4698,"Q_Id":62381210,"Users Score":0,"Answer":"So, even if you have Nitro and can send 4k, that doesn't extend to your tuppers? Because I just sent a pretty long RP Post in a server and got this error code. I figured that was the issue. The message sent, just from me and not my tupper. It's not a big deal, I'm just new to the whole Nitro thing and am still not sure how everything words lol","Q_Score":1,"Tags":"python,discord.py","A_Id":69421980,"CreationDate":"2020-06-15T04:10:00.000","Title":"error details 400 Bad Request (error code: 50035): Invalid Form Body In content: Must be 2000 or fewer in length","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get this error in discord.py bot what this means - error details 400 Bad Request (error code: 50035): Invalid Form Body\nIn content: Must be 2000 or fewer in length.\nThe fun fact is that i get this sometimes and sometimes not in the same code .","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4698,"Q_Id":62381210,"Users Score":1,"Answer":"2K is the maximum length of characters you can send. It's the default restriction in the discord. It would be due to you are sending a list or dictionary containing more than the recommended limit.","Q_Score":1,"Tags":"python,discord.py","A_Id":62381721,"CreationDate":"2020-06-15T04:10:00.000","Title":"error details 400 Bad Request (error code: 50035): Invalid Form Body In content: Must be 2000 or fewer in length","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a code that is supposed to use a while loop to determine if the number inputted by the user is the same as the variable secret_number = 777.\nthe following criteria are: \nwill ask the user to enter an integer number;\nwill use a while loop;\nwill check whether the number entered by the user is the same as the number picked by the magician. If the number chosen by the user is different than the magician's secret number, the user should see the message \"Ha ha! You're stuck in my loop!\" and be prompted to enter a number again. \nIf the number entered by the user matches the number picked by the magician, the number should be printed to the screen, and the magician should say the following words: \"Well done, muggle! You are free now.\"\nif you also have any tips how to use the while loop that would be really helpful. Thank you!","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2651,"Q_Id":62381285,"Users Score":0,"Answer":"You can use while(true) to create a while loop.\nInside, set a if\/else to compare the value input and secret_number. If it's true, print(\"Well done, muggle! You are free now.\") and break. Unless, print(\"Ha ha! You're stuck in my loop\") and continue","Q_Score":0,"Tags":"python,while-loop","A_Id":62381367,"CreationDate":"2020-06-15T04:21:00.000","Title":"Creating a stop in a While loop - Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a beginner to Django and Python, and I've never used virtualenv before. However, I do know the exact commands to activate and deactivate virtual environments (online search). However, this learning course takes time and sometimes I need to split the work over 2 days.\nWhen I create a virtualenv today and do some work, I'm unable to access the same virtualenv tomorrow. Even when I navigate to that folder and type in .\\venv\\Scripts\\activate, it says \"system cannot find specific path\".\nHow can I open already existing virtual environments and the projects within them? Could it be that I need to end my previous session in a certain way for me to access it the next time?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3645,"Q_Id":62383619,"Users Score":0,"Answer":"Open the command prompt\nGo to the project directory, where you created virtual environment\nAnd type the same as error shows, as in my  case it was\n\nFile D:\\Coding files\\Python*recommendation-system\\venv\\Scripts\\activate.ps1* cannot be loaded because running scripts is disabled on this system.\n\nSo I typed recommendation-system\\venv\\Scripts\\activate.ps1\n\nAnd it resolved my problem.","Q_Score":0,"Tags":"python,django,windows,cmd","A_Id":72240811,"CreationDate":"2020-06-15T07:45:00.000","Title":"How to activate an existing virtualenv projects?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm a beginner to Django and Python, and I've never used virtualenv before. However, I do know the exact commands to activate and deactivate virtual environments (online search). However, this learning course takes time and sometimes I need to split the work over 2 days.\nWhen I create a virtualenv today and do some work, I'm unable to access the same virtualenv tomorrow. Even when I navigate to that folder and type in .\\venv\\Scripts\\activate, it says \"system cannot find specific path\".\nHow can I open already existing virtual environments and the projects within them? Could it be that I need to end my previous session in a certain way for me to access it the next time?","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":3645,"Q_Id":62383619,"Users Score":-1,"Answer":"Open your Windows Command Prompt.\n\nGo to your project directory, where you created your virtual environment for this project.\n\nrun this command->  .\\env_name\\Scripts\\activate","Q_Score":0,"Tags":"python,django,windows,cmd","A_Id":66047853,"CreationDate":"2020-06-15T07:45:00.000","Title":"How to activate an existing virtualenv projects?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Imagine the following problem: \nYour friend bought a brand new car with 20 wheels and this car is driving large distances. As the car drives the car consumes tires. Every time your friend needs a new tire, he calls you to send a new tire. And of course you do that. \nAfter 2 years you want to know what the lifetime of that particular tire actually is. But, the only thing you know is \n\nThat you send your friend 26 tires in the last 2 years\nThe dates you sent tires to your friend\nHis car has 20 wheels\nHis car was brand new to start with\nAll the tires were for the same car\n\nHow can we find the lifetime of this tire with only the data we have?\n\nThis problem is what I'm facing today. When a tier (or any other item) is replaced, the system will not track where in the machine it was replaced, only that it was replaced. For me this makes it difficult to come up with a method to find the lifetime. \nIs there anyone, who can guide me in the right direction? \nIs there a sort of python library which can be used?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":62385239,"Users Score":0,"Answer":"The easiest solution that comes in mind is the average duration between the sending events.\nThis can only applied if you send tire for tire and not in a batch. In this case you have additonal complexity.\n\nYou need a list of all dates\nSort the list by date\nIterate over the list and calculate the duration between two dates following each other\nSave the duration in another list\nCalculate the average duration from this list\n\nNow you have the average wheel lifetime for the whole vehicle. Multiply this duration by 20 to get the lifetime of the average tire.\nCorrect me if I am wrong or didnt understand the question.","Q_Score":0,"Tags":"python,statistics,data-science","A_Id":62388147,"CreationDate":"2020-06-15T09:28:00.000","Title":"How to find Item Lifetime based on Item Consumption?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am executing a python script from my terminal by python myscript.py. Then I am asked for the password as in my code I am using os.system(\"sudo some_command_here\"). But when I run the same code from the terminal by sudo python myscript.py. it shows me SyntaxError: invalid syntax. if I comment out that line just to check  if it resolves, but I still get the same error in some other line of code. Am I doing something wrong, why it gives me that error.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1344,"Q_Id":62385476,"Users Score":0,"Answer":"In case you are using a virtual environment for your python, it might be that your system's python version is different than the one you have in the venv and the sudo command always uses the system version. Using python3 instead of python for the sudo may solve the problem.","Q_Score":0,"Tags":"python,linux,terminal,syntax-error,sudo","A_Id":62752512,"CreationDate":"2020-06-15T09:42:00.000","Title":"Invalid Syntax error for running python script with sudo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am on the latest version of python and I have tried all the commands to install pyjama, but the error I get is: \n\nDefaulting to user installation because normal site-packages is not writeable\n  Requirement already satisfied: pygame in \/Library\/Python\/2.7\/site-packages (1.9.6)\n\nI don't know where to find this information or how to downgrade to a older version of python.\nCan anyone help??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":313,"Q_Id":62386303,"Users Score":0,"Answer":"could you provide the commands you used for installation which results in that error? \nSeems like you've already installed it on Python2 and are trying to install it there again. If you're using pip, maybe you could try using pip3 instead. Alternatively you can also use the following command:\n\npython3 -m pip install XXX","Q_Score":0,"Tags":"python,pygame,python-3.8","A_Id":62386386,"CreationDate":"2020-06-15T10:29:00.000","Title":"Can't install pygame on python 3.8.3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an Excel sheet where one column has XMLs (each row is a different xml). I am trying to use Pyspark and spark-xml to parse these, by doing df = spark.read.format('xml').options(rowTag = 'book').load(___). \nThe load works fine when you specify an xml file, but is it possible to read in the Excel sheet and loop in those xmls to be parsed without having to convert each one to its own xml file?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":128,"Q_Id":62388441,"Users Score":1,"Answer":"You need to first read the Excel file as a Spark DataFrame. Then you can further parse a String column containing XML with the from_xml function. That gives a new column with the parsed data from the XML column.","Q_Score":2,"Tags":"python,excel,xml,pyspark","A_Id":63676518,"CreationDate":"2020-06-15T12:41:00.000","Title":"Spark XML - Use XMLs from Excel","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Good day, \nI am trying to stick footer to bottom django template layout, flex box and grid doesn`t help. May be in Django template another way?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":161,"Q_Id":62388787,"Users Score":1,"Answer":"Consider using position: fixed in CSS","Q_Score":0,"Tags":"python,css,django,templates","A_Id":62405145,"CreationDate":"2020-06-15T13:02:00.000","Title":"stick footer to bottom django template","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This might be a simple one, but I couldn't figure it out. I couldn't connect to the database that I created 'clearview' in mysql through.\nPlease advise. Thanks!\nNameError                                 Traceback (most recent call last)\n in \n      3 try:\n----> 4     connection = mysql.connector.connect(host='localhost',\n      5                                          database='clearview',\nNameError: name 'mysql' is not defined","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":3168,"Q_Id":62390013,"Users Score":2,"Answer":"Have you installed the mysql-connector package? Try installing it first with pip install mysql-connector and then import the package import mysql.connector before running your script.","Q_Score":0,"Tags":"python,mysql,connect,nameerror,connector","A_Id":62390161,"CreationDate":"2020-06-15T14:11:00.000","Title":"how to connect using python to mysql server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This might be a simple one, but I couldn't figure it out. I couldn't connect to the database that I created 'clearview' in mysql through.\nPlease advise. Thanks!\nNameError                                 Traceback (most recent call last)\n in \n      3 try:\n----> 4     connection = mysql.connector.connect(host='localhost',\n      5                                          database='clearview',\nNameError: name 'mysql' is not defined","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3168,"Q_Id":62390013,"Users Score":0,"Answer":"Which version of python you are using???\na)first check you have import mysql.connector. If it is there and not working then can follow following steps.\nb) It may be that mysql is not properly installed .Check via pip search mysql-connector | grep --color mysql-connector-python .\nc) Install via : pip install mysql-connector-python-rf\nHope it will help.","Q_Score":0,"Tags":"python,mysql,connect,nameerror,connector","A_Id":62390227,"CreationDate":"2020-06-15T14:11:00.000","Title":"how to connect using python to mysql server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This might be a simple one, but I couldn't figure it out. I couldn't connect to the database that I created 'clearview' in mysql through.\nPlease advise. Thanks!\nNameError                                 Traceback (most recent call last)\n in \n      3 try:\n----> 4     connection = mysql.connector.connect(host='localhost',\n      5                                          database='clearview',\nNameError: name 'mysql' is not defined","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3168,"Q_Id":62390013,"Users Score":0,"Answer":"All comments & suggestions appreciated. I did everything suggested here. And yes, I basically have to install the mysql.connector to every environment I created to be sure. I think perhaps, that's why it indicated that mysql is not defined. Lesson learned>..\nAs follow up question... is there such thing as installing every Python extensions globally so I would not reinstall it in several environments. never tried it before, as I perhaps tinkering with different environments not knowing which one I'm currently using. :)\nThanks guys!!!","Q_Score":0,"Tags":"python,mysql,connect,nameerror,connector","A_Id":62398489,"CreationDate":"2020-06-15T14:11:00.000","Title":"how to connect using python to mysql server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Working for quite a while with a WxPython GUI. A very weird issue occurred when it opened as LTR on a windows PC. Some frames were really messed up because of that.\nHow can I prevent WxPython GUI from flipping?\nIt should be RTL only.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17,"Q_Id":62390677,"Users Score":0,"Answer":"Solved by going to \"Set Regional Format\" -> Region -> and changing to \"English(United States)\"","Q_Score":0,"Tags":"windows,wxpython","A_Id":64315254,"CreationDate":"2020-06-15T14:41:00.000","Title":"WxPython GUI is flipped to LTR","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pretty straightforward question, but I haven\u2019t found a very straightforward answer: When should I use start_background_task() over starting a Python thread \u201cnormally\u201d? Flask-SocketIO documentation states:\n\nThis function returns an object compatible with the Thread class in the Python standard library. The start() method on this object is already called by this function.\n\nIt doesn\u2019t say much about whether it\u2019s necessary to use this over initializing and starting a thread per the threading module.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3172,"Q_Id":62391514,"Users Score":6,"Answer":"The reason start_background_task() exists is that depending on what web server you use the threading model changes. For example, if you are using eventlet or gevent, then a background task needs to be started as a greenlet, not as a Thread instance.\nIf you use start_background_task() you will be guaranteed that a task object that is compatible with your environment will be used.","Q_Score":3,"Tags":"python,multithreading,flask,flask-socketio","A_Id":62414645,"CreationDate":"2020-06-15T15:22:00.000","Title":"Background Tasks in Flask-SocketIO","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a very small and unfinished game in python using pygame. Is there an easy way to convert this to an app which I can use and test on my iPhone without rewriting the whole code in things like kivvy?","AnswerCount":1,"Available Count":1,"Score":-0.3799489623,"is_accepted":false,"ViewCount":3116,"Q_Id":62392764,"Users Score":-2,"Answer":"There isn't an easy way, it's impossible transform the code.\nBut for an easy and not professional game, you can try to do this.\nUse a site for hosting the game like Python Anywhere (free).\nNow create an app without any coding skill.\nI never use IOS, for android MIT Inventor is a good framework for create apps.\nFor Ios, you can try Appypie or Appyourself, but you can find other better alternatives.\nThe app must contain a web-browser viewer with your site.\nThe app shows a web page with your game in it.\nI can't imagine another way, it's a bit difficult and the app require internet connection.\nGood luck!","Q_Score":3,"Tags":"python,ios,python-3.x,iphone,pygame","A_Id":62393468,"CreationDate":"2020-06-15T16:32:00.000","Title":"How to convert pygame application to iOS app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"thanks for reading this. I am using macOS High Sierra. I am not very familiar with terminal or environment variables, but am trying to learn more. From reading other threads and google, it seems like I either have multiple pythons installed, or have pythons running from different paths. However I am not able to find a solution to resolving this, either by re-pathing my IDLE or deleting it entirely. \nI do have python, python launcher, and anaconda (not very sure how anaconda works, have it installed a few years back and didn't touch it) installed. I am trying to install pandas (pip install pandas), which tells me that I have it installed, but when I run it on IDLE, it says module not found. Though if i run python3 on terminal and type my code in, it works (so pandas has indeed been installed).\nWhen i run which python on terminal, it returns\n\/Users\/myname\/anaconda3\/bin\/python\n(when i enter into this directory from terminal, it shows that in the bin folder, I have python, python.app, python3, python3-config, python3.7, python3.7-config, python3.7m, python3.7m-config)\nWhen i run which idle on terminal, it returns\n\/usr\/bin\/idle (im not even sure how to find this directory from the terminal) \nWhen i run import os; print(os.path) on IDLE, it returns module 'posixpath' from '\/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/posixpath.py'\nWould really appreciate some help to figure out how to ensure that when i install modules from terminal, it would be installed into the same python as the one IDLE is using. Also, I would like to know whether it is possible for me to work on VSCode instead of IDLE. I cant seem to find suitable extensions for data science and its related modules (like statsmodels, pandas etc). Thanks a lot!","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":904,"Q_Id":62392889,"Users Score":1,"Answer":"First: This would be a comment if I had enough reputation.\nSecond: I would just delete python. Everything. And reinstall it.","Q_Score":1,"Tags":"python,python-idle","A_Id":62393176,"CreationDate":"2020-06-15T16:39:00.000","Title":"IDLE and python is different, not able to install modules properly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"thanks for reading this. I am using macOS High Sierra. I am not very familiar with terminal or environment variables, but am trying to learn more. From reading other threads and google, it seems like I either have multiple pythons installed, or have pythons running from different paths. However I am not able to find a solution to resolving this, either by re-pathing my IDLE or deleting it entirely. \nI do have python, python launcher, and anaconda (not very sure how anaconda works, have it installed a few years back and didn't touch it) installed. I am trying to install pandas (pip install pandas), which tells me that I have it installed, but when I run it on IDLE, it says module not found. Though if i run python3 on terminal and type my code in, it works (so pandas has indeed been installed).\nWhen i run which python on terminal, it returns\n\/Users\/myname\/anaconda3\/bin\/python\n(when i enter into this directory from terminal, it shows that in the bin folder, I have python, python.app, python3, python3-config, python3.7, python3.7-config, python3.7m, python3.7m-config)\nWhen i run which idle on terminal, it returns\n\/usr\/bin\/idle (im not even sure how to find this directory from the terminal) \nWhen i run import os; print(os.path) on IDLE, it returns module 'posixpath' from '\/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/posixpath.py'\nWould really appreciate some help to figure out how to ensure that when i install modules from terminal, it would be installed into the same python as the one IDLE is using. Also, I would like to know whether it is possible for me to work on VSCode instead of IDLE. I cant seem to find suitable extensions for data science and its related modules (like statsmodels, pandas etc). Thanks a lot!","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":904,"Q_Id":62392889,"Users Score":1,"Answer":"First of all, a quick description of anaconda:\nAnaconda is meant to help you manage multiple python \"environments\", each one potentially having its own python version and installed packages (with their own respective versions). This is really useful in cases where you would like multiple python versions for different tasks or when there is some conflict in versions of packages, required by other ones. By default, anaconda creates a \"base\" environment with a specific python version, IDLE and pip. Also, anaconda provides an improved way (with respect to pip) of installing and managing packages via the command conda install <package-name>.\nFor the rest, I will be using the word \"vanilla\" to refer to the python\/installation that you manually set up, independent of anaconda.\nExplanation of the problem:\nNow, the problem arises since you also installed python independently. The details of the problem depend on how exactly you set up both python and anaconda, so I cannot tell you exactly what went wrong. Also, I am not an OSX user, so I have no idea how python is installed and what it downloads\/sets alongside.\nBy your description however, it seems that the \"vanilla\" python installation did not overwrite neither your anaconda python nor anaconda's pip, but it did install IDLE and set it up to use this new python.\nSo right now, when you are downloading something via pip, only the python from anaconda is able to see that and not IDLE's python.\nPossible solutions:\n1. Quick fix:\nJust run IDLE via \/Users\/myname\/anaconda3\/bin\/idle3 every time. This one uses anaconda's python and should be able to see all packages installed via conda install of pip install (*). I get this is tiresome, but you don't have to delete anything. You can also set an \"alias\" in your ~\/.bashrc file to make the command idle specifically linking you there. Let me know with a comment if you would like me to explain how to do that, as this answer will get too long and redundant.\n2. Remove conda altogether (not recommended)\nYou can search google on how to uninstall anaconda along with everything that it has installed. What I do not know at this point is whether your \"vanilla\" python will become the default, whether you will need to also manually install pip again and whether there is the need to reinstall python in order for everything to work properly.\n3. Remove your python \"vanilla\" installation and only use anaconda\nAgain, I do not know how python installation works in OSX, but it should be reasonably straightforward to uninstall it. The problem now is that probably you will not have a launcher for IDLE (since I am guessing anaconda doesn't provide one on OSX) but you will be able to use it via the terminal as described in 1..\n4. Last resort:\nIf everything fails, simply uninstall both your vanilla python (which I presume will also uninstall IDLE) and anaconda which will uninstall its own python, pip and idle versions. The relevant documentation should not be difficult to follow. Then, reinstall whichever you want anew.\nFinally:\nWhen you solve your problems, any IDE you choose, being VScode (I haven't use that either), pycharm or something else, will probably be able to integrate with your installed python. There is no need to install a new python \"bundle\" with every IDE.\n\n(*): Since you said that after typing pip install pandas your anaconda's python can import pandas while IDLE cannot, I am implying in my answer that pip is also the one that comes with anaconda. You can make sure this is the case by typing which pip which should point to an anaconda directory, probably \/Users\/myname\/anaconda3\/bin\/pip","Q_Score":1,"Tags":"python,python-idle","A_Id":62395898,"CreationDate":"2020-06-15T16:39:00.000","Title":"IDLE and python is different, not able to install modules properly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"thanks for reading this. I am using macOS High Sierra. I am not very familiar with terminal or environment variables, but am trying to learn more. From reading other threads and google, it seems like I either have multiple pythons installed, or have pythons running from different paths. However I am not able to find a solution to resolving this, either by re-pathing my IDLE or deleting it entirely. \nI do have python, python launcher, and anaconda (not very sure how anaconda works, have it installed a few years back and didn't touch it) installed. I am trying to install pandas (pip install pandas), which tells me that I have it installed, but when I run it on IDLE, it says module not found. Though if i run python3 on terminal and type my code in, it works (so pandas has indeed been installed).\nWhen i run which python on terminal, it returns\n\/Users\/myname\/anaconda3\/bin\/python\n(when i enter into this directory from terminal, it shows that in the bin folder, I have python, python.app, python3, python3-config, python3.7, python3.7-config, python3.7m, python3.7m-config)\nWhen i run which idle on terminal, it returns\n\/usr\/bin\/idle (im not even sure how to find this directory from the terminal) \nWhen i run import os; print(os.path) on IDLE, it returns module 'posixpath' from '\/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/posixpath.py'\nWould really appreciate some help to figure out how to ensure that when i install modules from terminal, it would be installed into the same python as the one IDLE is using. Also, I would like to know whether it is possible for me to work on VSCode instead of IDLE. I cant seem to find suitable extensions for data science and its related modules (like statsmodels, pandas etc). Thanks a lot!","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":904,"Q_Id":62392889,"Users Score":0,"Answer":"To repeat and summarized what has been said on various other question answers:\n1a. 3rd party packages are installed for a particular python(3).exe binary.\n1b. To install multiple packages to multiple binaries, see the option from python -m pip -h.\n\nTo find out which python binary is running, execute import sys; print(sys.executable).\n\n3a. For 3rd party package xyz usually installed in some_python\/Lib\/site-packages, IDLE itself has nothing to do with whether import xyz works.  It only matters whether xyz is installed for 'somepython' (see 1a).\n3b. To run IDLE with 'somepython', run somepython -m idlelib in a terminal or console.\nsomepython can be a name recognized by the OS or a path to a python executable.","Q_Score":1,"Tags":"python,python-idle","A_Id":62396210,"CreationDate":"2020-06-15T16:39:00.000","Title":"IDLE and python is different, not able to install modules properly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"hello before I say anything I would like to let you know that I tried searching for the answer but I found nothing.\nwhenever I use os.system('cls') it clears the screen but it prints out a zero.\nis this normal, if not how do I stop it from doing that?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":857,"Q_Id":62392991,"Users Score":1,"Answer":"I guess you running in inside an interpreter\nos.system will return:\n\na 16-bit number, whose low byte is the signal number that killed the process, and whose high byte is the exit status (if the signal number is zero)\n\nSo it just print the value it got, the return value of the command cls in the command line, which is 0 cause the command run successfully","Q_Score":0,"Tags":"python","A_Id":62393039,"CreationDate":"2020-06-15T16:46:00.000","Title":"Why does os.system('cls') print 0","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"what image classification to use for training? \nwe want to train a model with our own pictures for a school project. Can I use resnet50 or any other trainable model? I couldn't find Resnet50 trainable model and I found only pre-trained resnet50 model. We are using Tensorflow 2.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":62393326,"Users Score":1,"Answer":"You don't have to use the pre-trained Resnet. Load the keras version of resnet with weights=None and train the model yourself.","Q_Score":0,"Tags":"python,tensorflow,tensorflow2.0,training-data,resnet","A_Id":63254361,"CreationDate":"2020-06-15T17:06:00.000","Title":"Train an image classification model using Tesnsorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem. When writing the \"pip install pyowm\" command to the console, the module is installed, but the system doesn't see it. For example, Phyton, when executing the command \"impor pyowm\", gives an error, and when writing the command \"pyowm\" to the console, the error \"\" pyowm \" is not an external or internal command\".\nAll of the above apply to other modules as well.\nP.S. I use VS Code and Python v.3.8.3","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":62393397,"Users Score":0,"Answer":"You can't just use any tool just by name from the console.\nYou have to first enter python to the console and then try import pyowm again.\nIt should import pyowm. But later you may want to actually use pyowm. Then you use this import most of the time:\nfrom pyowm.owm import OWM","Q_Score":1,"Tags":"command-line,module,pypi,python-3.8","A_Id":62395686,"CreationDate":"2020-06-15T17:11:00.000","Title":"The inability to install the module on Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am running a python script on Heroku which runs every 10 minutes using the Heroku-Scheduler add-on.  The script needs to be able to access the last time it was run.  On my local machine I simply used a .txt file which I had update whenever the program was run with the \"last run time\".  The issue is that Heroku doesn't save any file changes when a program is run so the file doesn't update on Heroku.  I have looked into alternatives like Amazon S3 and Postgresql, but these seem like major overkill for storing one line of text.  Are there any simpler alternatives out there?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":62394659,"Users Score":0,"Answer":"If anyone has a similar problem, I ended up finding out about Heroku-redis which allows you to make key-value pairs and then access them. (Like a Cloud Based Python Dictionary)","Q_Score":0,"Tags":"python,heroku,amazon-s3,heroku-postgres","A_Id":62411106,"CreationDate":"2020-06-15T18:28:00.000","Title":"Way to store a single line of changing text on Heroku","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":"Is it possible to write a custom loss function in keras that says \"for all data from dataset A: calculate loss like this... And for all data from dataset B: calculate loss like this instead\"\nMy current implementation has 2 separate models with their own loss functions and then the 2 data feeds are given in separate train_on_batch calls.\nFor context, my system is a GAN that is tasked with creating a domain indistinguishable representation between two datasets, while also performing classification. However with my current method it feels as though the \"domain indistinguishability\" task is taking priority and my classification accuracy is not rising above random. (whereas if I turn off the domain task, the classification accuracy rises to approximately 80%). And one issue I'd like to rule out is multiple calls of train_on_batch with non-shuffled data per training loop.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":62395291,"Users Score":0,"Answer":"For anyone that might stumble upon this question later, I realise now that I worded the question poorly with respect to what the actual answer is. The question is actually answered by \"how to calculate gradients and apply them as separate operations in keras\"\nMy solution is to overwrite the Model class, create a new train_on_batch method that accepts more than one dataset.\nThen apply however many calculations and loss functions you want inside a gradientTape. Then finally use optimizer.apply_gradient() to actually apply the gradients to the model","Q_Score":0,"Tags":"python,tensorflow,keras,generative-adversarial-network","A_Id":62882571,"CreationDate":"2020-06-15T19:12:00.000","Title":"Splitting up types of data in a keras loss function (equivalent to if statements in loss functions?)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a workspace setup in VS Code where I do python development.  I have linting enabled, pylint enabled as the provider, and lint on save enabled, but I continue to see no errors in the Problems panel. When I run pylint via the command line in the virtual environment i see a bunch of issues - so I know pylint works.  I am also using black formatting(on save) which works without issue.  I have tried using both the default pylint path as well as updating it manually to the exact location and still no results.  When I look at the Output panel for python it looks like pylint is never even running (i.e. I see the commands for black running there but nothing for pylint).\nMy pylint version is 2.4.4 and VS Code version 1.46\nAny idea how to get this working?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5375,"Q_Id":62397982,"Users Score":0,"Answer":"Uninstall Python Extension\nReinstall Python Extension\nAnd with that there will will be one more extension of \"Python Extension\" named - \"PYLANCE\" don't forget to install that too.\nReload VS Code\n\nDONE !!","Q_Score":5,"Tags":"visual-studio-code,pylint,vscode-python","A_Id":67927118,"CreationDate":"2020-06-15T22:24:00.000","Title":"VS Code - pylint is not running","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm importing data from CSV file into Postgres table using copy from command like this\ncopy tbl_name(col1, col2, col3) from '\/sample.csv' delimiter ',';\nthe command is executed in a transaction(read-write).\nwhile this command is executing, I'm opening a new SQL session in the new terminal, but in this new session, I'm not able to perform select command. It will be stuck until the transaction is committed in the first session. \nThe same issue is happening when in python program I'm copying a file using copy_expert command of Psycopg2, even tho I have created connection_engine with pooling.\nIs it possible to prevent Postgres from blocking the er sessions while copy-ing data into the table?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":333,"Q_Id":62398551,"Users Score":0,"Answer":"That is impossible, unless you use SELECT ... FOR UPDATE, which tries to put a row lock on rows that are already locked by the COPY.\nIt is a principle in PostgreSQL that readers don't block writers and vice versa.","Q_Score":0,"Tags":"python,sql,postgresql,sqlalchemy,psycopg2","A_Id":62401805,"CreationDate":"2020-06-15T23:20:00.000","Title":"copy command blocks other sessions in postgres","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm importing data from CSV file into Postgres table using copy from command like this\ncopy tbl_name(col1, col2, col3) from '\/sample.csv' delimiter ',';\nthe command is executed in a transaction(read-write).\nwhile this command is executing, I'm opening a new SQL session in the new terminal, but in this new session, I'm not able to perform select command. It will be stuck until the transaction is committed in the first session. \nThe same issue is happening when in python program I'm copying a file using copy_expert command of Psycopg2, even tho I have created connection_engine with pooling.\nIs it possible to prevent Postgres from blocking the er sessions while copy-ing data into the table?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":333,"Q_Id":62398551,"Users Score":1,"Answer":"This is not a general phenomenon.  There is more going on here than you are telling us.\nMaybe the COPY is happening inside the same transaction as something else which acquires a strong lock (like TRUNCATE) on the same table that is being SELECTed from.  Or maybe your SELECT is invoking some user-defined-function (perhaps directly, perhaps through a trigger or something) which is acquiring a stronger lock than SELECT usually requires.\nIn the absence of special conditions such as those, I have no problem running COPY and SELECT at the same time.","Q_Score":0,"Tags":"python,sql,postgresql,sqlalchemy,psycopg2","A_Id":62409233,"CreationDate":"2020-06-15T23:20:00.000","Title":"copy command blocks other sessions in postgres","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My system has python 2.7 in usr\/bin\/python and python 3 in usr\/bin\/python3.\nI need to use pandas and it seems it was not installed. (I got the No module named pandas)\nso I did pip install pandas and it got installed. \nMy problem is that if I type python I can import pandas without problem but if I type python3 and I am in the python 3 environment, I cannot import pandas and I get a \"No module named pandas\"\nHow can I install pandas to be found by python3?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":62399552,"Users Score":2,"Answer":"which pip will probably tell you that pip by itself is the python2 installer. To explicitly install into python3 do \npip3 install pandas","Q_Score":1,"Tags":"python,python-3.x,pandas","A_Id":62399566,"CreationDate":"2020-06-16T01:23:00.000","Title":"After installing pandas it only gets recognized by python not python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"import tensorflow \nIt shows \n2020-06-16 07:15:04.362632: W tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found\n2020-06-16 07:15:04.394714: I tensorflow\/stream_executor\/cuda\/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":62399711,"Users Score":0,"Answer":"install everything what tensorflow needs \nand download everything still won't get the program","Q_Score":0,"Tags":"python,tensorflow,gpu","A_Id":62399712,"CreationDate":"2020-06-16T01:47:00.000","Title":"How to install tensorflow in windows 10 operating system after installed everything still got an error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed sublime text and when I select the build system as python, it doesn't work. The command prompt with pops up at the bottom of the frame says: \"can't find 'main' module in ' '\".","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":62400258,"Users Score":0,"Answer":"Follow these steps.\n\nyou need to SAVE your code file with the \u201c.py\u201d extension.\nThen, on the \u2018Tools\/Build System\u2019 menu, make sure your build system is set to either \u2018auto\u2019 or \u2018Python\u2019. If everything works fine, you are ready to go.\n\nOtherwise, simply type \" python \" (without the quotes) in a cmd terminal to make sure python is in your path.","Q_Score":0,"Tags":"python","A_Id":62400464,"CreationDate":"2020-06-16T03:01:00.000","Title":"Unable to execute python for sublimetext","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some questions about how to deal with 0 value in 2d array.\nI am planning to work on regression 1d CNN, but most of the data is made of 0.\nI would like to replace this 0 to other small values such as 0.000001 simply because, if I put 0, regression process would not take into account the dataset values and find what is optimized model for my data set.\nI have some instinct but, I need to prove it by referencing.\nWould you be kind enough as to recommend me some references or any idea of this?\nThank you for reading.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":42,"Q_Id":62400584,"Users Score":1,"Answer":"The easiest thing to do is to jitter your data by adding 0.0001 * numpy.raodom.randn(*your array shape*) to your data. Whether it will help you in your specific problem, no one can tell, of course.","Q_Score":1,"Tags":"python,deep-learning,regression,artificial-intelligence,image-preprocessing","A_Id":62401006,"CreationDate":"2020-06-16T03:43:00.000","Title":"Many values in the dataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Apparently it is supposed to be part of Python3 but it says \"bash: sqlite3: command not found\". \nI'm so new to all of this and I'm just trying to follow along with a tutorial on youtube. Any help would be much appreciated.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":5263,"Q_Id":62400753,"Users Score":3,"Answer":"On Linux (or in a Docker container running a Linux OS variant), you can install the command line interface via sudo apt-get install sqlite3 and then run sqlite3.","Q_Score":5,"Tags":"python,python-3.x,sqlite","A_Id":69657658,"CreationDate":"2020-06-16T04:05:00.000","Title":"bash: sqlite3: command not found","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"This is my first time on stack overflow. I am a beginner python coder and I use the Atom text editor. I am currently learning from a book called PythonCrashCourse by Eric Matthes (second edition) and is developing a practice-project called Alien Invasion. I am currently stuck on saving a file of a spaceship image into a folder named \"images\" within my text editor. I have an ASUS chromebook. The file I am trying to save is called ship.bmp and the book instructions say \"Make a folder called images inside your main alien_invasion project folder. Save the file ship.bmp in the images folder.\" I have the ship.bmp file saved but I just don't know how to transport it into a file within my text editor \"images\" folder. I have been stuck on this for quite a while and I would really appreciate it if someone could give me some advice. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":232,"Q_Id":62401983,"Users Score":0,"Answer":"First of all you need to have the ship.bmp file downloaded somewhere on your computer. You then would need to move it into your project folder. I think that the easiest way for you to navigate through the files you have is to go to your \"Files\" app in the Chromebook. You should look through your Downloads folder for the ship.bmp after you download it and manually move it into the project folder that you are working on. You should be able to open your project folder and place the ship.bmp file inside the \"images\" folder.","Q_Score":0,"Tags":"python,image,file-upload,atom-editor,chromebook","A_Id":62679574,"CreationDate":"2020-06-16T06:08:00.000","Title":"Saving a File in an Atom Text Editor Folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why do we have so many cells in jupyter notebook?\n To execute a piece of code, normally we have one large space like in eclipse, net beans or any other IDE.I want to know what all we can do with the cells in jupyter notebook?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":457,"Q_Id":62402328,"Users Score":1,"Answer":"The idea of Jupyter Notebook is that you can interleave code with explanatory text. This is why Jupyter offers two kinds of cells: code and markdown.\nAs an example, this is very useful for exploratory data analysis where you might want to write some prose in a markdown cell about where the dataset came from and what assumptions were made, then apply an algorithm in a code cell, plot the results in another code cell, and explain what it all means in another markdown cell. \nAnother advantage of cells is that you can execute them individually. Some algorithms might take a very long time (think machine learning) and don't have to be executed every time you make a change to another part of the notebook (e.g. plotting).","Q_Score":1,"Tags":"python,ide,jupyter","A_Id":62402405,"CreationDate":"2020-06-16T06:36:00.000","Title":"Why do we have so many cells in jupyter notebook instead of one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why do we have so many cells in jupyter notebook?\n To execute a piece of code, normally we have one large space like in eclipse, net beans or any other IDE.I want to know what all we can do with the cells in jupyter notebook?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":457,"Q_Id":62402328,"Users Score":0,"Answer":"Cells let you save states. Imagine you need to read a large dataset and perform some machine learning on it. You can use one cell to read the dataset\u2013only once\u2013and you can continue your data explorations down in the notebook. It saves a lot of time.","Q_Score":1,"Tags":"python,ide,jupyter","A_Id":62402397,"CreationDate":"2020-06-16T06:36:00.000","Title":"Why do we have so many cells in jupyter notebook instead of one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why do we have so many cells in jupyter notebook?\n To execute a piece of code, normally we have one large space like in eclipse, net beans or any other IDE.I want to know what all we can do with the cells in jupyter notebook?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":457,"Q_Id":62402328,"Users Score":0,"Answer":"The purpose it do be able to divide the code into several blocks.\nIf you just run \"Kernel -> Restart & Run All\" it doesn't matter.\nI prefer to use Notebooks to combine documentation and code, to explain the code. It is also useful to combine plots and regular output.\nIt is also useful when developing, you can divide the functionality into multiple chunks and don't need to run the code again.","Q_Score":1,"Tags":"python,ide,jupyter","A_Id":62402393,"CreationDate":"2020-06-16T06:36:00.000","Title":"Why do we have so many cells in jupyter notebook instead of one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Flask web app written in Python3. The issue I have though is, that all the variables are always shared between all users that access my website. \nFor example, if user1 during his time on my website clicks a button which in Python3 does var1 = \"aaa\" and then populates this variable into an HTML input field, then all of the other users accessing the website will see the input field with value aaa. \nI'm using gunicorn3 as my WSGI. I have also tried to gunicorn3 python-docx:app -k gevent --worker-connections 1000 but that didn't help at all.\n(python-docx is the name of my Python3 file)\nHow can I make sure, that the variables in my Python code are NOT shared between each sessions of different users? I want to make sure, that only the variables and their values are visible to each user specifically, not have them shared like now. \nIs it possible?\nThank you very much.\nEdit: I do not use database nor do I use a login system for my web app. My web app is public without any user management so anyone can use the web app's functionality for free.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":302,"Q_Id":62404389,"Users Score":0,"Answer":"The Issue is solved partially if you can identify Users(differentiate requests)\nI know you are not using any authentication, so instead you can use timestamp when user requests the page capture the time stamp for that user in dictionary\nInstead of using var1=\"aaa\"\nuse: dict['fixed_request_time_stamp']={var1:\"aaa\"}\nSo when user request page, a unique time_stamp will created and sent to user along with page, that will submitted back to server when user submit form along with data(\"aaa\") (\"timestamp\")","Q_Score":0,"Tags":"html,python-3.x,web,flask,gunicorn","A_Id":68587904,"CreationDate":"2020-06-16T08:39:00.000","Title":"Python Flask - web app to NOT share variables between multiple users","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am training a Support Vector Machine using sklearn. In the beginning, I did not encode the class labels in any form and left them as Strings (e.g. [\"A\", \"B\", \"C\"]). The resulting accuracy was comparable to when I used a LabelEncoder [0, 1, 2]. So is sklearn automatically converting the Strings into integers\/one-hot-representations in the background? Or am I missing something here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":526,"Q_Id":62405788,"Users Score":3,"Answer":"The labels have to be encoded only if the labels are part of the independent variables. So, if you have a list of labels that are used by the SVM to determine the dependent variable, you would have to encode them either using labelencoder or onehotencoder or however fits your dataset best. Scikit-learn encodes strings automatically, so you don't have to encode them manually by writing the code. This means that for text targets, Scikit-learn encodes them without you having to make the encoding. Hope this helped!","Q_Score":1,"Tags":"python,encoding,scikit-learn,svm","A_Id":62406309,"CreationDate":"2020-06-16T09:56:00.000","Title":"Is label encoding automatically done by sklearn SVC?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am aware of the following:\n\n[1,2,3]<[1,2,4] is True because Python does an element-wise comparison from left to right and 3 < 4\n[1,2,3]<[1,3,4] is True because 2 < 3 so Python never even bothers to compare 3 and 4\n\nMy question is how does Python's behavior change when I compare two lists of unequal length?  \n\n[1,2,3]<[1,2,3,0] is True\n[1,2,3]<[1,2,3,4] is True\n\nThis led me to believe that the longer list is always greater than the shorter list. But then:\n\n[1,2,3]<[0,0,0,0] is False\n\nCan someone please explain how these comparisons are being done by Python? \nMy hunch is that element-wise comparisons are first attempted and only if the first n elements are the same in both lists (where n is the number of elements in the shorter list) does Python consider the longer list to be greater. If someone could kindly confirm this or shed some light on the reason for this behavior, I'd be grateful.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":258,"Q_Id":62406227,"Users Score":1,"Answer":"The standard comparisons (<, <=, >, >=, ==, !=, in , not in ) work exactly the same among lists, tuples and strings. \nThe lists are compared element by element.\nIf they are of variable length, it happens till the last element of the shorter list\nIf they are same from start to the length of the smaller one, the length is compared i.e. shorter is smaller","Q_Score":2,"Tags":"python,python-3.x,list","A_Id":62406374,"CreationDate":"2020-06-16T10:20:00.000","Title":"How does Python compare two lists of unequal length?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to convert a string (like \"abcd123456\" ) into a guid and from that guid I want to extract the string from that guid is there any process to do that? (will be more helpful if the example is in python or c#)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":464,"Q_Id":62407310,"Users Score":0,"Answer":"A GUID is 128 bits.  You want to be able to reverse the GUID back to the originating string, so you need to use a 128 bit block cipher.  That means AES.\nTake your initial string.  Add cryptographic padding as needed to make it up to a 128 bits (16 bytes) and encrypt with your chosen key.  Use PKCS#7 padding unless you have reason not to.\nTo retrieve your initial string, decrypt with the same key and remove the padding if present.\nYou will not be able to do this with strings longer than 16 bytes because the encrypted string will not fit into a single GUID.  You would need multiple GUIDs for that.","Q_Score":1,"Tags":"python,c#,cryptography,guid","A_Id":62417068,"CreationDate":"2020-06-16T11:24:00.000","Title":"How to convert a string into GUID and vice versa","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In most compiled languages, the max value for an integer was around 2.147 billion. In Javascript, it is around 10^308. But what is it in Python? If, in the Javascript console, you ask 10 to the power of 309, it return Infinity. But, if you do that in the python shell, it returns a one with 309 zeros. I tried 10^500, 10^500, 10^1000, and even 10^10000 in the shell, and all of them returned a one with the respective number of zeroes. For the last one, I had to confirm the printing of the number, as it made the shell a tad bit slower. \nSo, do you know what the max value for a Python variable Is?\nThanks for your help!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":281,"Q_Id":62411952,"Users Score":0,"Answer":"Python uses a big number integer library in its implementation of an integer type.\nThis means the number is arbitrarily large.\nEventually you'll hit a limit such as memory. sys.int_info gives you information on the integer, including the largest it can be.","Q_Score":0,"Tags":"python,variables","A_Id":62412001,"CreationDate":"2020-06-16T15:21:00.000","Title":"What is the max number for a Python variable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"when i import XLUtils i am getting this error. Thank you\nimport XLUtils\nModuleNotFoundError: No module named 'XLUtils'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":179,"Q_Id":62412043,"Users Score":0,"Answer":"Package name is all lower case import xlutils. But before importing it make sure that it is added in your project interpreter in PyCharm settings. File -> Settings -> Project: (your project name) -> Project Interpreter, on the right top corner there is + sign, click on it and search for package name xlutils (all lower case), install the package and it should work.","Q_Score":0,"Tags":"python,selenium-webdriver","A_Id":62417105,"CreationDate":"2020-06-16T15:26:00.000","Title":"Getting ModuleNotFoundError error on importing XLUtils","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to install older versions of tensorflow to get the deepface library to work properly, however whenever I run pip install tensorflow==1.9.0, I get: ERROR: Could not find a version that satisfies the requirement tensorflow==1.9.0 (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0)\nAnyone else run into this issue\/know how to fix it? Thanks!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":407,"Q_Id":62415403,"Users Score":2,"Answer":"You can install TensorFlow 1.9.0 with the following Python versions: 2.7 and 3.4 to 3.6.","Q_Score":2,"Tags":"python,tensorflow,pip","A_Id":62415559,"CreationDate":"2020-06-16T18:37:00.000","Title":"Cannot install older versions of tensorflow: No matching distribution found for tensorflow==1.9.0","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"all!\nWe currently use MTPuTTY to SSH into a Red Hat Linux server to run Python programs on a compute cluster. I was wanting to implement read-only access to a PostgreSQL database into these programs using the current credentials used for SSH. I know you can't access the password via Linux and it would be (very) bad practice to store the passwords in plaintext (does this still count for folders only accessible by the users?, ie dedicated network storage folders? I suppose that would depend on if admins have access to those folders as well).\nI was hoping there would be some way to use the current SSH session credentials to authenticate with the database and fetch records into the Python program, but can't seem to find a way to do that. Is there a way? Is there an alternative?\nOther options I've thought of:\n\nCreate server to take requests using my credentials, fetch records,\nreturn records to program.\nRun service\/scheduled task to fetch values every [x] minutes, store\nin a file accessible only by my group (though not sure how to do\nthis without storing my password in an accessible manner).\n\nJust really not seeing a safe way to automate this access without exposing passwords... Any help is much appreciated! Thank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":62417506,"Users Score":0,"Answer":"You should be able to make both Linux and PostgreSQL use PAM.\nBut why not just keep it simple and use peer authentication?  The fact that you logged on to the linux account shows you knew the password to do that log on.  Isn't that enough?","Q_Score":0,"Tags":"python,linux,postgresql,security,passwords","A_Id":62419280,"CreationDate":"2020-06-16T20:59:00.000","Title":"Using current Linux SSH Credentials to authenticate for database access in python program","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"i wonder How to reload python package after pip install in Visual Studio Code?\n\npip install 'package-A'\npip list\nNot exist 'package-A'\nRestart 'Visual Studio Code'\n\nIs the only way restart?\nThank u.","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4278,"Q_Id":62419767,"Users Score":0,"Answer":"On MacOS, use command + shift + p and then choose \"Developer: Reload Window\". It is helpful to bind this to command + r. For Windows users, replace command with CTRL.","Q_Score":7,"Tags":"python-3.x,visual-studio-code,pip","A_Id":72317845,"CreationDate":"2020-06-17T00:49:00.000","Title":"How to reload python package after pip install in Visual Studio Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i wonder How to reload python package after pip install in Visual Studio Code?\n\npip install 'package-A'\npip list\nNot exist 'package-A'\nRestart 'Visual Studio Code'\n\nIs the only way restart?\nThank u.","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":4278,"Q_Id":62419767,"Users Score":1,"Answer":"ctrl+shift+p and choose \"Developer: Reload with extentions disabled\"","Q_Score":7,"Tags":"python-3.x,visual-studio-code,pip","A_Id":70564844,"CreationDate":"2020-06-17T00:49:00.000","Title":"How to reload python package after pip install in Visual Studio Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i wonder How to reload python package after pip install in Visual Studio Code?\n\npip install 'package-A'\npip list\nNot exist 'package-A'\nRestart 'Visual Studio Code'\n\nIs the only way restart?\nThank u.","AnswerCount":6,"Available Count":3,"Score":-0.0333209931,"is_accepted":false,"ViewCount":4278,"Q_Id":62419767,"Users Score":-1,"Answer":"Are you sure this is a vscode issue? What happens when you run pip install from a normal command prompt? I suspect you will have the same issue, if that proves true, I would entirely uninstall python and re-install python, then install\/upgrade pip to latest.\npython -m pip install \u2013upgrade pip","Q_Score":7,"Tags":"python-3.x,visual-studio-code,pip","A_Id":66333934,"CreationDate":"2020-06-17T00:49:00.000","Title":"How to reload python package after pip install in Visual Studio Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hellow Developer\nI made A.exe program with python, using pyinstaller \n1. A.exe is running on window by display\n2. i hope that control A.exe program is likely to debug mode\nex) Qwidget.information(self, \"Hellow World\") \nWhat should I do?\nit's mean commuication like sqlserver\nIf there is no way \ni think eval(\"Qwidget.information(self, 'Hellow World')\")\nbut it's vulnerable.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":62421511,"Users Score":0,"Answer":"It may need to something to communicate between two program. Create an interface for both program to interact. I think the most easy way is by setting file. A program set DEBUG mode in setting file to ON\/OFF, and B program check the setting file for DEBUG mode to decide what mode to go. :-)","Q_Score":0,"Tags":"python,controls","A_Id":62421613,"CreationDate":"2020-06-17T04:29:00.000","Title":"How to control A.exe file using B.exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make it impossible for a user to copy data to the clipboard as long as my program is running. How would I go about to do that in Python ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":62424363,"Users Score":0,"Answer":"You could simply render the text as a graphic.\nThis way selecting text would not be possible.\nI have to point out, that stuff like this is always a bad idea, and if the user wants to get the text, he will.\nIn the past I used screenshots with OCR to get texts. \nIt's not worth the effort, and in most cases doing stuff like this will just result in the user not wanting to use your program.","Q_Score":0,"Tags":"python,clipboard,pywin32,win32com,pyperclip","A_Id":62424463,"CreationDate":"2020-06-17T08:10:00.000","Title":"Block Windows clipboard from user with Python while Program running","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When a .py file is being edited in IDLE, it can be renamed or deleted while still being able to run, but in other file types such as word files this is not allowed. You can even create a script using the os module to delete itself and then do an action, and that action still works. How is this possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":62425048,"Users Score":0,"Answer":"When you run python scripts you scripts were loaded into memory. So you can edit your script files.","Q_Score":0,"Tags":"python,operating-system,python-module","A_Id":62425080,"CreationDate":"2020-06-17T08:48:00.000","Title":"Why can python files be modified while open in IDLE editor?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"the code (from googletrans import Translator) brings up the following error:\n\nTraceback (most recent call last):   File\n  \"\/Users\/cadeylange\/Documents\/python_work\/Personal\/frequently_used_words.py\",\n  line 2, in <module>\n      from googletrans import Translator ModuleNotFoundError: No module named 'googletrans' [Finished in 0.3s with exit code 1] [cmd:\n  ['\/usr\/local\/bin\/python3', '-u',\n  '\/Users\/cadeylange\/Documents\/python_work\/Personal\/frequently_used_words.py']]\n  [dir: \/Users\/cadeylange\/Documents\/python_work\/Personal] [path:\n  \/Library\/Frameworks\/Python.framework\/Versions\/3.8\/bin:\/Library\/Frameworks\/Python.framework\/Versions\/3.8\/bin:\/Library\/Frameworks\/Python.framework\/Versions\/3.7\/bin:\/Library\/Frameworks\/Python.framework\/Versions\/3.7\/bin:\/usr\/local\/bin:\/usr\/bin:\/bin:\/usr\/sbin:\/sbin]\n\nI've double-checked that the googletrans has been installed successfully using pip and it has. I cannot think of why the code won't work, I've tried importing it using different expressions including the basic \"import googletrans\" statement. Could anyone see the problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":830,"Q_Id":62425250,"Users Score":0,"Answer":"Reading the traceback shows, you're running Python 3 on a Linux box, right? Have you tried installing the module with pip3, what should make it availble for Python 3.","Q_Score":1,"Tags":"python,error-handling,module","A_Id":62425679,"CreationDate":"2020-06-17T08:59:00.000","Title":"ModuleNotFoundError: No module named 'googletrans'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"We have an android application, We need to schedule the below tasks on weekly once.\n\nHave to automatically log out from our application.\nThen have to log in automatically.\n\nI google it and found Automation Testing Framework - Android UI Automation Using Python Wrapper but I wish to run the above task by scheduling.\nI am not an Android developer, Kindly assist me to accomplish this task.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":62426581,"Users Score":0,"Answer":"In case of logout user after a perticular time, then you need to create a middle layer(like intercepter) while calling api through retrofit in mobile end.\nA logic follow in middle layer and your backend:\nyou need to send specific error code your from backend after a perticular time.\nAt mobile end we check that code in middle layer if error code is match then call logout user api and at same time call login api.\nIf you want only logout and not want to login again then send another error code for that.","Q_Score":0,"Tags":"android,python-3.x,scheduled-tasks","A_Id":62428198,"CreationDate":"2020-06-17T10:13:00.000","Title":"have to schedule UI task in Android: have to automatically log out from our application and login automatically","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 download utilities module with pip install utilities but i get this error\n\nERROR: Could not find a version that satisfies the requirement utilities (from versions: none)\nERROR: No matching distribution found for utilities\n\nPython Version : 3.8.2\nOS : Windows 10","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":82,"Q_Id":62427570,"Users Score":1,"Answer":"try with this command:\npython3 -m pip install utilities","Q_Score":0,"Tags":"python,python-3.x","A_Id":62427605,"CreationDate":"2020-06-17T11:08:00.000","Title":"I get error while downloading utilities module - Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I\u2019ve started using JavaScript recently and have noticed a resemblance between JavaScript object literals and python dictionaries. They are used in similar situations and have similar syntax. So are they basically the same thing but with different names?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":354,"Q_Id":62431352,"Users Score":0,"Answer":"it is totally not the same thing.\nin JS, object literals is a object, so you can combine them with data and function, and you can call the method by dot, just like x.xxx(), and you can deconstruction it with the same symbol {...}, just like other object.\nbut in python, dict is not a object, you can not use dot, and if you want deconstruction, you must use ** for it, by the way, you can deconstruction turple by *\nsummarize: their is nothing just like object literals in python...","Q_Score":1,"Tags":"javascript,python,dictionary,object-literal","A_Id":71422660,"CreationDate":"2020-06-17T14:26:00.000","Title":"Are JavaScript object literals the same thing as Python dictionaries?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an IPad that loads every email from my inbox immediately. Because of some spam in my mails I want to install an email cleaner\/filter. I already tried spamassassin and some other self written python code on my raspi that find and deletes all spam mails each second from the server. The problem is that the emails altough they are deleted from the server my IPad still gets most of them.\nMy question is if there's a easy solution to avoid my IPad loading some of the spam before my program deletes it. That means that my IPad wouldn't even see the mails because they're filtered by any device in the network.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":62431375,"Users Score":0,"Answer":"If anyone has the same problem...\nThis solution worked for me. I added a new email account to the mail server. On my IPad I use the IMAP server (for receiving) from the new account while the SMTP server (for sending) is the same as before. That means sending mails hasn't changed. I wrote a little python script that sends every non spam mail to the new account. It's running 24\/7 on my raspi. That means that I now only see the mails I want to see while I can send mails like I'm used to it.\nIf you also want to write a program like this you should start looking up how to receive and send emails in your favorite language. \nOf course this works for every email client.","Q_Score":0,"Tags":"python,email,networking","A_Id":62447395,"CreationDate":"2020-06-17T14:27:00.000","Title":"Deleting spam mails from inbox before mail client loads them","Data Science and Machine Learning":0,"Database and SQL":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 save all data which will get from model-derivative API. The problem is every time I export data from model-derivative-API, I will get updated data from the database.  I want to predict changes in data where later that will get connect to powerBi to see the changes in the model","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":176,"Q_Id":62433173,"Users Score":0,"Answer":"You used the tag autodesk-bim360, so I assume your files are stored in BIM 360 Docs.\nIn that case you could get the properties for each file version and then compare them yourself to find out what changed between the versions.","Q_Score":1,"Tags":"sql-server,sqlalchemy,python-requests,flask-sqlalchemy,autodesk-bim360","A_Id":62521612,"CreationDate":"2020-06-17T15:54:00.000","Title":"how to save updated data into sql server from model derivative api of autodesk forge","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"sorry, I am completely new to coding, and am trying to install Pygame on Mac. I have it installed, and on IDLE it works fine, however, when I try to import it on Atom, it says:\nImportError: No module named pygame\nI've been looking for a solution for a while now, and can't seem to find anything, was wondering if anyone on hear could help?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":62434188,"Users Score":0,"Answer":"I faced the same issue too below can be few of the reasons\/solutions:\n\nyou might be using pygame through anaconda instead pip, try doing \"pip install pygame\" in windows cmd to fix it.\nu must also add atom's bin folder through its directory to your path. you can easily find online how you can add stuff to path and you'll find the bin folder where you have installed atom.","Q_Score":0,"Tags":"python-3.x,pygame","A_Id":62441936,"CreationDate":"2020-06-17T16:48:00.000","Title":"I am trying, and failing to import Pygame on Atom, even though it works on IDLE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"trying to make a geojason map.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":62434630,"Users Score":0,"Answer":"In order to get a choropleth map your geojson should have data with \"geometry\" of \"type\" \"Polygon\" or \"MultiPolygon\", and a list of coordinates for each district. What you provided does not meet these requirements.","Q_Score":0,"Tags":"python,maps,folium","A_Id":62449604,"CreationDate":"2020-06-17T17:12:00.000","Title":"How to create a Folium Map","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My use case is fetching data from an external source. After fetching data.I'm mapping with multiple tables in MongoDb which has huge data and generating results. For this use-case which is faster Pymongo or MongoEngine?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":332,"Q_Id":62435850,"Users Score":0,"Answer":"pymongo is a driver. mongoengine is an ODM and it exists on top of the driver.\nAny operation going through mongoengine also goes through the driver. Therefore, execution time in pymongo is always going to be less than execution time in pymongo+mongoengine.\nWith that said:\n\nmongoengine provides functionality that pymongo does not implement (the object-data mapping). If you implement the equivalent functionality in your own application that uses pymongo directly, the result could be slower than using mongoengine.\nif a query you are sending is slow for the database to execute, the extra time that mongoengine spends doing its thing can be so small as to be irrelevant.","Q_Score":0,"Tags":"python,mongodb,pymongo,mongoengine","A_Id":62439621,"CreationDate":"2020-06-17T18:22:00.000","Title":"MongoDB : To run faster queries which is better Pymongo or MongoEngine","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The situation is:\nI developped a webapp using django (and especially \"django-simple-history\").\nI have a postgres database \"db01\" with a history model \"db01_history\" which is generated\/filled using \"django-simple-history\".\nI accidentally deleted everything from \"db01\"and, sadly, I don't have any db backup.\nMy question is:\nIs there some way to replay all historical records \"db01_history\" (up to a specific ID) onto original database \"db01\" ?\n(In other words, is there a way to restore a db using its historical model up to a specific date\/ID ?)\nGiving db0_history -> db01","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":242,"Q_Id":62436082,"Users Score":1,"Answer":"Fortunately, django-simple-history keeps using your own model's field names and types (but does not keep some constraints). \nThe difference is that there are multiple historical objects for each of your deleted objects. If you use Django default primary key (id) it would be easy for you to group your tables by id and use the latest record as of history_date (the time of recorded history).\nAn exception is that if you use more direct database operations like updates or bulk_creates from model managers you don't have their histories.\nSo you can just configure your project to use a copy of the historical database only having the latest record for each object and then try to do python manage.py dumpdata > dump.json and then revert the database settings to the new database you like and do python manage.py loaddata dump.json.\nTo be concise, yes you may have all your data in your historical database.","Q_Score":0,"Tags":"python,django,database,postgresql,django-models","A_Id":62436912,"CreationDate":"2020-06-17T18:37:00.000","Title":"Is it possible to replay django-simple-history up to a specific ID to restore a delete database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have two tables with same columns, and I concatenated them vertically. I want to remove duplicates based on col1 but keep records that have latest time_stamp","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":17,"Q_Id":62436315,"Users Score":1,"Answer":"sort the dataframe on the value of time stamp descending and the default behaviour of the pandas drop_duplicates method will keep the latest","Q_Score":0,"Tags":"python-3.x,pandas,dataframe,join,duplicates","A_Id":62436554,"CreationDate":"2020-06-17T18:52:00.000","Title":"drop dupliactes but keep records based on a condtion","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do you get the name of a property in python? Any suggestions welcome.\nFor functions and methods it is as simple as f.__name__.\nBut properties do not have the __name__ attribute.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":273,"Q_Id":62436382,"Users Score":0,"Answer":"If you know the parent class, dir(), vars(), and primarily __dict__() are what you are looking for. If you only have the attribute itself, outside of the context of a class, then I believe you can't.","Q_Score":1,"Tags":"python,properties,attributes","A_Id":62437194,"CreationDate":"2020-06-17T18:56:00.000","Title":"How to get the name of a property in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to remove the non-ASCII Character '\\xa0' while reading my CSV file using read_csv into a dataframe with python. Can someone tell me how to achieve this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":562,"Q_Id":62437622,"Users Score":0,"Answer":"You can use x = txt.replace(u'\\xa0', u'') for text you're reading.","Q_Score":0,"Tags":"python,csv,replace,encoding,character","A_Id":62437674,"CreationDate":"2020-06-17T20:14:00.000","Title":"Remove character '\\xa0' while reading CSV file in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I configure Elpy to use dev dependencies like Black, Jedi, and flake8 that are installed in a Poetry project virtual environment rather than those that are installed systemwide?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1158,"Q_Id":62438238,"Users Score":0,"Answer":"If you use emacs -nw, then another option is\n\nInstall virtualenvwrapper in poetry project. That is run poetry add -D virtualenvwrapper.\nInstall elpy dependencies you need. M-x elpy-config' to find dependencies. So poetry add -D jedi rope autopep8 yapf black flake8`. This can also be done when elpy prompts you, but then it will probably install as a normal dependency and not just dev dependency.\nAdd (setq elpy-rpc-virtualenv-path 'current) so that elpy uses the poetry virtual env for Virtualenv, Interactive Python, RPC virtual env.\nLaunch emacs through poetry poetry run emacs -nw\n\nYou need to do this for each poetry project. There should be way to install some of these globally in pyenv and have poetry and the project virtual env pick it up. However, doing it for each project keeps dependencies isolated, even for dev stuff.","Q_Score":2,"Tags":"emacs,python-poetry,elpy","A_Id":64164199,"CreationDate":"2020-06-17T20:56:00.000","Title":"Setting up Emacs Elpy with Poetry","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If you are looking for a simple script to do vector calculations in python, you can use this one. Enjoy ;) I didn't find some other easy to use scripts, so created my own. You can do these basic calculations with the vector class\n\nsum \nnorm\nscalar product\ncross product\netc","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":395,"Q_Id":62438309,"Users Score":1,"Answer":"I think your scalar product calculation is wrong\u2026scalar product should yield a real number, not a vector. Other calculations use this, so those are also broken.","Q_Score":0,"Tags":"python,vector","A_Id":71610959,"CreationDate":"2020-06-17T21:01:00.000","Title":"Vector Calculations in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using selenium python and was wondering how one effectively scrapes over 50,000 data points in under 24 hours. For example, when I search for products on the webpage 'insight.com' it takes about 3.5 seconds for the scraper to search for the product and grab its price, meaning that with large amounts of data it takes the scraper several days. A part from using threads to simultaneously look up several products at the same time, how else can I speed up this process?\nI only have one laptop and will have to simultaneously scrape six other similar websites so therefore do not want too many threads and the speed at which the computer operates will slow down significantly.\nHow do people achieve to scrape large amounts of data in such short periods of time?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":130,"Q_Id":62438727,"Users Score":2,"Answer":"If you stop using the selenium module, and rather work with a much more sleek and elegant module, like requests, you could get the job done in a matter of mere minutes.\nIf you manage to reverse engineer the requests being handled, and send them yourself, you could pair this with threading to scrape at some 50 'data points' per second, more or less (depending on some factors, like processing and internet connection speed).","Q_Score":2,"Tags":"python,selenium,web-scraping","A_Id":62438810,"CreationDate":"2020-06-17T21:33:00.000","Title":"How to scrape over 50,000 data points from dynamically loading webpage in under 24 hours?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using selenium python and was wondering how one effectively scrapes over 50,000 data points in under 24 hours. For example, when I search for products on the webpage 'insight.com' it takes about 3.5 seconds for the scraper to search for the product and grab its price, meaning that with large amounts of data it takes the scraper several days. A part from using threads to simultaneously look up several products at the same time, how else can I speed up this process?\nI only have one laptop and will have to simultaneously scrape six other similar websites so therefore do not want too many threads and the speed at which the computer operates will slow down significantly.\nHow do people achieve to scrape large amounts of data in such short periods of time?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":130,"Q_Id":62438727,"Users Score":1,"Answer":"Find an API and use that!!!  The goal of both web scraping and APIs is to access web data.\nWeb scraping allows you to extract data from any website through the use of web scraping software. On the other hand, APIs give you direct access to the data you\u2019d want.\nAs a result, you might find yourself in a scenario where there might not be an API to access the data you want, or the access to the API might be too limited or expensive.\nIn these scenarios, web scraping would allow you to access the data as long as it is available on a website.\nFor example, you could use a web scraper to extract product data information from Amazon since they do not provide an API for you to access this data.  However, if you had access to an API, you could grab all the data you want, super, super, super fast!!!  It's analogous to doing a query in a database on prem, which is very fast and very efficient, vs. refreshing a webpage, waiting for ALL elements to load, and you can't use the data until all elements have been loaded, and then.....do what you need to do.","Q_Score":2,"Tags":"python,selenium,web-scraping","A_Id":63663707,"CreationDate":"2020-06-17T21:33:00.000","Title":"How to scrape over 50,000 data points from dynamically loading webpage in under 24 hours?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm having trouble doing this and can't find a good way to select them all. I need to get the live updates as well as the normal headlines. Basically every bolded headline on the site. Also, I need to get the embedded link that activates when these are clicked. I have some basic knowledge of HTML and have webscraped a few things before, but am struggling with this for some reason. Can someone walk me through it?\nUpon further inspection, it seems I might want to find the children of all article classes?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":59,"Q_Id":62438887,"Users Score":-1,"Answer":"You could use the requests module to download the page's HTML code, then parse it by h3 tags, which I've noticed are used for headlines.\nYou can then use the .find(string) method to find such HTML tag, and when you do, find the next instance of <\/h3> from that index of the HTML code onward.\nI couldn't understand which and how many headlines you want to parse, but you can use a while loop to keep parsing for every h3 tag on the page, until you can't find a new one (the .find() method should return -1 if it doesn't locate the string).","Q_Score":1,"Tags":"python,web-scraping,beautifulsoup","A_Id":62439089,"CreationDate":"2020-06-17T21:46:00.000","Title":"Getting the headlines and headline links from NPR.org with Beautiful Soup","Data Science and Machine Learning":0,"Database and SQL":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 developing a Flask app using flask-socketio, running it with socketio.run(app, debug=True), but every time I update any of the app's Javascript code and then refresh the browser, the changes do not take effect. If I update any of the Python code and then refresh, the Python changes do take effect - the only problem is with Javascript changes. \nClearing my browser's data resolves the issue, but I don't want to have to do that every time I make changes to my JS code. Is there another way?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":272,"Q_Id":62439187,"Users Score":1,"Answer":"Try ctrl-clicking (or shift-clicking) the refresh button.\nWhat is likely happening is that the browser is \"caching\" your Javascript code. Clearing your browser's data clears the cache, and you get the newest updates...\nIn some browsers, you can avoid doing that by refreshing the page in a way that bypasses the cache. I think the shift-click trick works in Firefox, and ctrl-click is Chrome. Or, look up \"bypass cache refresh [browser_name]\".","Q_Score":1,"Tags":"javascript,python,flask,socket.io,flask-socketio","A_Id":62439345,"CreationDate":"2020-06-17T22:10:00.000","Title":"How to get Flask app to refresh after updating JS code without having to clear browsing data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm developing a Flask app using flask-socketio, running it with socketio.run(app, debug=True), but every time I update any of the app's Javascript code and then refresh the browser, the changes do not take effect. If I update any of the Python code and then refresh, the Python changes do take effect - the only problem is with Javascript changes. \nClearing my browser's data resolves the issue, but I don't want to have to do that every time I make changes to my JS code. Is there another way?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":272,"Q_Id":62439187,"Users Score":0,"Answer":"If clearing cache does work, then another method (which I always use) is to keep your developer tools opened and make sure you've checked \"Disable cache\" in the network tab.\nThe \"Disable cache\" feature only works when developer tools is opened as I said.","Q_Score":1,"Tags":"javascript,python,flask,socket.io,flask-socketio","A_Id":62439367,"CreationDate":"2020-06-17T22:10:00.000","Title":"How to get Flask app to refresh after updating JS code without having to clear browsing data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on a function within a project that could drop staging databases. I already use peewee throughout the project so it would make things easier to not have use pymysql . Is it possible? I've seen it i believe for dropping tables but not a db. \nJust double checking\nI did see  a ticket in github from 2014 regarding this issue but wanted to see if there was any new info on this as a possibility.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":303,"Q_Id":62439627,"Users Score":0,"Answer":"Peewee has no provisions for either creating or deleting databases, no will it ever be likely to support that. Check your db vendor for the appropriate methods for doing this.","Q_Score":0,"Tags":"python,peewee","A_Id":62456709,"CreationDate":"2020-06-17T22:51:00.000","Title":"Can peewee drop a database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is very specific. Given a k dimensional Gaussian distribution with mean and standard deviation, say I wish to sample 10 points from this distribution. But the 10 samples should be very different from each other. For example, I do not wish to sample 5 of those very close to the mean (By very close, we may assume for this example within 1 sigma) which may happen if I do random sampling. Let us also add an additional constraint that all the drawn samples should be at least 1 sigma away from each other. Is there a known way to sample in this fashion methodically? Is there any such module in PyTorch which can do so? \nSorry if this thought is ill posed but I am trying to understand if such a thing is possible.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":384,"Q_Id":62439852,"Users Score":0,"Answer":"To my knowledge there is no such library. The problem you are trying to solve is straightforward. Just check if the random number you get is 'far enough' from the mean. The complexity of that check is constant. The probability of a point not to be between one sigma from the mean is ~32%. It is not that unlikely.","Q_Score":0,"Tags":"python,pytorch,sampling,normal-distribution","A_Id":62440013,"CreationDate":"2020-06-17T23:15:00.000","Title":"Sampling from gaussian distribution","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Django. How do Pipefiles and Pipefile.lock files get created? \nI created them earlier, but I'm not sure what I did.\nThank you","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":796,"Q_Id":62440310,"Users Score":1,"Answer":"When you install Django in a new directory with \"pipenv install django\" you create two files in your new virtual environment and these files are Pipfile and Pipfile.lock\nHope this helps!","Q_Score":0,"Tags":"python-3.x,django","A_Id":62440400,"CreationDate":"2020-06-18T00:11:00.000","Title":"Django How to Create the Pip and Piplock file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to Django. How do Pipefiles and Pipefile.lock files get created? \nI created them earlier, but I'm not sure what I did.\nThank you","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":796,"Q_Id":62440310,"Users Score":0,"Answer":"Ah, figured it out, I needed to type python manage.py startapp name_of_app\nApp has already been created, how can I create the files mid app development?","Q_Score":0,"Tags":"python-3.x,django","A_Id":62440395,"CreationDate":"2020-06-18T00:11:00.000","Title":"Django How to Create the Pip and Piplock file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there some sort of bug when you use createsuperuser in Django?\nI am literally typing the following: python manage.py createsuperuser.\nHere is what happens:\n1) The first time I type this, it will say \n\nUsername (leave blank to use 'whatever')\n\n: so I typed 'batman'\nIt then says \n\n'batman' is not recognized as an internal or external command,\n  operable program or batch file.\n\nWhen I retype python manage.py createsuperuser, it accepts my answer of batman.\nI am on a Windows machine, has anyone seen this before?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":109,"Q_Id":62440620,"Users Score":1,"Answer":"don't use inverted comma(')\ntry this:\n\nUsername (leave blank to use 'whatever'):hello","Q_Score":0,"Tags":"python,python-3.x,django","A_Id":62449353,"CreationDate":"2020-06-18T00:51:00.000","Title":"Django Createsuperuser Bug?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So far I've found that Calibri, Courier, and Times New Roman can be used with pygame.font.SysFont(). It takes the name of a font as a string as an argument. Would it be possible to put any font name, as long as its a string, as the font argument? Or is there a select number of fonts you can use?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":850,"Q_Id":62440910,"Users Score":1,"Answer":"Any font in the list returned from pygame.font.get_fonts() can be used.  This is a list of all the system fonts (ones built into the running system).  If you have your own .ttf file you want to use, you can instead use pygame.font.Font.  The advantage of that is you know the font you want is available (since you are bundling it with your game).  With system fonts, you don't necessarily know what fonts will be available on the user's system.","Q_Score":1,"Tags":"python,fonts,pygame","A_Id":68568673,"CreationDate":"2020-06-18T01:29:00.000","Title":"What fonts can be used with pygame.font.SysFont()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background: I have a huge DataFrame with 40 million rows. I have to run some functions on some columns. The loops were taking too long, so I decided to go with Multiprocessing. \nCPU: 8 cores 16 threads\nRAM: 128 GB\nQuestion: How many chunks should I break the data into? And how many workers are properly for this dataset? \np.s. I found out that when I set the max_workers = 15, all threads are running 100%. But if I change the max_workers to 40, they dropped to 40%. \nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":62441519,"Users Score":0,"Answer":"There are three types of parallel computing. Those are  io-intensive, cpu-intensive and io-cpu intensive computing.\nIf your thread is runing on cpu-intensive  task, then You can increase your worker numbers as you want to get better performance.\nBut If it is runing on io-intensive, it willl no effect to increase them.\nYou seems to be working on io-cpu intensive task.\nSo If you increase worker numbers, you can get good result until there is no competition for using io resource(hard disk)\nso In local machine . it is not a good choice to increase worker numbers.\nYou can use Hadoop on GPS or AWS for this work.","Q_Score":0,"Tags":"python,multiprocessing,large-data","A_Id":62441716,"CreationDate":"2020-06-18T02:46:00.000","Title":"Python Multiprocessing: How to set up the number of max_workers properly?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background:\nI have multiple asset tables stored in a redshift database for each city, 8 cities in total. These asset tables display status updates on an hourly basis. 8 SQL tables and about 500 mil rows of data in a year.\n(I also have access to the server that updates this data every minute.)\n\nExample: One market can have 20k assets displaying 480k (20k*24 hrs) status updates a day.\n\nThese status updates are in a raw format and need to undergo a transformation process that is currently written in a SQL view. The end state is going into our BI tool (Tableau) for external stakeholders to look at.\nProblem:\nThe current way the data is processed is slow and inefficient, and probably not realistic to run this job on an hourly basis in Tableau. The status transformation requires that I look back at 30 days of data, so I do need to look back at the history throughout the query.\nPossible Solutions:\nHere are some solutions that I think might work, I would like to get feedback on what makes the most sense in my situation.\n\nRun a python script that looks at the most recent update and query the large history table 30 days as a cron job and send the result to a table in the redshift database.\nMaterialize the SQL view and run an incremental refresh every hour\nPut the view in Tableau as a datasource and run an incremental refresh every hour\n\nPlease let me know how you would approach this problem. My knowledge is in SQL, limited Data Engineering experience, Tableau (Prep & Desktop) and scripting in Python or R.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":215,"Q_Id":62441546,"Users Score":2,"Answer":"So first things first - you say that the data processing is \"slow and inefficient\" and ask how to efficiently query a large database.  First I'd look at how to improve this process.  You indicate that the process is based on the past 30 days of data - is the large tables time sorted, vacuumed and analyzed?  It is important to take maximum advantage of metadata when working with large tables.  Make sure your where clauses are effective at eliminating fact table block - don't rely on dimension table where clauses to select the date range.\nNext look at your distribution keys and how these are impacting the need for your critical query to move large amounts of data across the network.  The internode network has the lowest bandwidth in a Redshift cluster and needlessly pushing lots of data across it will make things slow and inefficient.  Using EVEN distribution can be a performance killer depending on your query pattern.  \nNow let me get to your question and let me paraphrase - \"is it better to use summary tables, materialized views, or external storage (tableau datasource) to store summary data updated hourly?\"  All 3 work and each has its own pros and cons.  \n\nSummary tables are good because you can select the distribution of the data storage and if this data needs to be combined with other database tables it can be done most efficiently.  However, there is more data management to be performed to keep this data up to data and in sync.\nMaterialized views are nice as there is a lot less management action to worry about - when the data changes, just refresh the view.  The data is still in the database so is is easy to combine with other data tables but since you don't have control over storage of the data these action may not be the most efficient.\nExternal storage is good in that the data is in your BI tool so if you need to refetch the results during the hour the data is local.  However, it is not locked into your BI tool and far less efficient to combine with other database tables.  \n\nSummary data usually isn't that large so how it is stored isn't a huge concern and I'm a bit lazy so I'd go with a materialized view.  Like I said at the beginning I'd first look at the \"slow and inefficient\" queries I'm running every hour first.\nHope this helps","Q_Score":1,"Tags":"python,r,amazon-redshift,database-administration","A_Id":62478268,"CreationDate":"2020-06-18T02:49:00.000","Title":"How to efficiently query a large database on a hourly basis?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I now have an HTML file and I want to send it as a table, not an attachment by using outlook. The code that I found online only sends the file as an attachment. Can anyone give me ideas on how to do it properly?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":62442067,"Users Score":0,"Answer":"You can use the HTMLBody property of the MailItem class to set up the message body.","Q_Score":0,"Tags":"python,html,email,outlook","A_Id":62479266,"CreationDate":"2020-06-18T03:50:00.000","Title":"How to send a HTML file as a table through outlook?","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've made a script\/code in python idle and want to run it on python.exe but whenever I do this the you can see the python window pop up briefly for a second before closing, and I want to run my code using python instead of idle, how can I do this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":241,"Q_Id":62442077,"Users Score":1,"Answer":"since I cant comment yet:\ngo to the command line and open the file location directory and type:   python filename.py","Q_Score":1,"Tags":"python,python-idle","A_Id":62442104,"CreationDate":"2020-06-18T03:51:00.000","Title":"Python idle to python.exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been trying to do web automation using selenium,Is there any way to use browser like chrome,firefox without actually installing then, like using some alternate options, or having portable versions of them.If I can use portable versions how do i tell selenium to use it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3184,"Q_Id":62442465,"Users Score":0,"Answer":"If you install pip install selenium\nit comes with the protable chrome browser, no need to install any browser for this.\nthe chrome has a tag \"chrome is controlled by automated test software\" near search bar","Q_Score":1,"Tags":"python,selenium,google-chrome,browser,automation","A_Id":62442630,"CreationDate":"2020-06-18T04:35:00.000","Title":"Using Selenium without using any browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have a menu with too many items to fit on the screen, how do I get one of those 'more' buttons with a downward arrow at the bottom of the menu? Is that supported?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":93,"Q_Id":62443369,"Users Score":-1,"Answer":"I solved my problem with cascading menus. I already had some, but I didn't want to use more for these particular menus items\u2014but after closer inspection, I think it's better this way.\nI'm still interested in other solutions, for scenarios where cascading menus are not a practical option, however (like if the screen is too narrow to cascade that far or something). So, I don't plan to mark this as the accepted answer anytime soon (even though in most circumstances, it's probably the best solution).","Q_Score":0,"Tags":"python,python-3.x,tkinter,tkinter-menu","A_Id":62445927,"CreationDate":"2020-06-18T06:04:00.000","Title":"Tkinter: How do I handle menus with many items?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As a Python intermediate learner, I made an 8 ball in Python.\nNow that I am starting on learning C, is there a way to simulate to the way random.choice can select a string from a list of strings , but in C ?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":2860,"Q_Id":62444974,"Users Score":3,"Answer":"You can write a function if you know the size of your array and use rand() % size to get a random index from your array. Then return the value of arr[randidx]","Q_Score":0,"Tags":"python,c","A_Id":62445160,"CreationDate":"2020-06-18T07:49:00.000","Title":"How to do random.choice in C","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an PyQt5 application to update database collections one by one using QThread and send updation signal to main thread as each collection gets updated to reflect it on GUI. It runs continuously 24X7. But somehow the data stops getting updated and also GUI stops getting signals. But the application is still running as other part are accessible and functioning properly. Also no errors are found in log file.\nMostly the application runs fine but after some random period this problem arises(first time after approximately a month, then after 2 weeks and now after 23 days). However restarting the application solves the problem.\nI tried using isRunning() method and isFinished() method but no change found.\nCan anyone tell what is the problem?? Thank you in advance.\nAlso tell how to check weather the QThread is stuck or killed?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":393,"Q_Id":62447718,"Users Score":0,"Answer":"If any exception occur in the thread, then thread can be finished soon.\nso You should use settimeout function to calling any third party library(data update) in the thread.\nThat will solve your problem.","Q_Score":1,"Tags":"python,pyqt5","A_Id":62447947,"CreationDate":"2020-06-18T10:18:00.000","Title":"How to check if a QThread is alive or killed and restart it if it is killed in PyQt5?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Lets say we have the next statement:\nunhexlify(format(0b11111111, 'x') the result will be b'\\xff' as expected but now if I do the same with the byte full of 0's unhexlify(format(0b00000000, 'x') will not work and I got an error:\nTraceback (most recent call last):\n  File \"\", line 1, in \nbinascii.Error: Odd-length string\nI need to get b'\\x00'. I see that the problem appears when I do the formating, it seems that if the first nibble are 0's the result is an unique number so the unhexlify function will complain, but:\nThere is a way to get that (00 instead of 0)? and why is not working? Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":62448233,"Users Score":0,"Answer":"Thanks! I just solved in my own :D\nunhexlify(\"{:02x}\".format(0b00000000))\nb'\\x00'","Q_Score":0,"Tags":"python,format,byte,bit","A_Id":62448454,"CreationDate":"2020-06-18T10:49:00.000","Title":"How to obtain the hexadecimal code 00 using format(0b00000000, 'x')","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a UDF in PySpark. The function takes in an input string which is an xml. It then uses lxml to parse it and returns a list of dictionaries with the attributes. I created the function parse_xml, but when I try the line spark.udf.register(\"parse_xml\", parse_xml) but this gives the error: PicklingError: Could not serialize object: TypeError: can't pickle lxml.etree.XMLParser objects. \nIt seems as if lxml objects are not serializable, but the input is a string and the output is a list\/dictionary -- is there any way to create a UDF like this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":382,"Q_Id":62449753,"Users Score":0,"Answer":"The library used by pyspark is cpickle which stands for cloud pickle and serializing libraries written in C is not supported by it yet.\nIf you want to parse xml use databricks XML parser instead and it'll be fast as well.","Q_Score":1,"Tags":"python,apache-spark,pyspark,lxml,user-defined-functions","A_Id":62455447,"CreationDate":"2020-06-18T12:15:00.000","Title":"Unable to serialize PySpark UDF","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a Flask API application, and I have an SSL Certificate.\nWhen I run flask server on localhost the certificate is applied from Flask successfully.\nBut when I use Ngrok to deploy the localhost on a custom domain, the certificate is changed to *.ngrok.com, how can I change that to my certificate?.\nEDIT #1:\nI already have a certificate for the new hostname and I have already applied it on Flask, but ngrok is changing it.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1392,"Q_Id":62449887,"Users Score":0,"Answer":"You expose your service through the URL *.ngrok.com. A browser or other client will make a request to *.ngrok.com. The certificate presented there must be valid for *.ngrok.com. If *.ngrok.com presents a certificate for example.com, any valid HTTPS client would reject it because the names do not match, which by definition makes it an invalid certificate and is a flag for a potential security problem, exactly what HTTPS is designed to mitigate.\nIf you want to present your certificate for example.com to the client, you need to actually host your site at example.com","Q_Score":0,"Tags":"python,ngrok,pyngrok","A_Id":62450179,"CreationDate":"2020-06-18T12:22:00.000","Title":"Ngrok hostname SSL Certificate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I just started learning ML and wondered why one would do .fit() and .transform() separately, when .fit_transform() exists. Also, I am generally confused on what exactly fitting\/.fit() does.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":27,"Q_Id":62450620,"Users Score":1,"Answer":"I assume you are talking about sklearn's scalers or sklearn's feature transformation algorithms in general.\nLet's say your dataset is splitted in 5 sub-sets and you want to scale each of them between -1 and 1:\n\nYou fit your scaler on each sub-set using fit, this basically searches for the maximum and minimum over all of your sets\nThen, you can scale your sub-sets using transform\n\nIf you had used fit_transform, on the first sub-set, then used it on the second one, it would have been scaled differently, and you don't want that.\nMoreover, instead of sub-sets, you can think of fitting once on your training set and keeping the transformation in memory to scale future samples you want to pass to your model.","Q_Score":0,"Tags":"python,python-3.x,scikit-learn","A_Id":62450696,"CreationDate":"2020-06-18T13:02:00.000","Title":"Is there any reason to do .fit() and .transform() instead of just .fit_transform()?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If you have a repository and you open it up from your command line with the bzr qlog there is a section for each revision number that returns branch: trunk or branch: xyz \nIf you use the bzr log in the command line there is a section for each revision number that returns branch nick: trunk or branch nick: xyz or branch nick: yougettheidea \nThe nick is short for nickname as I have discovered from actually reading into the log python script.\nMy thought is that since there is some code that is pulling out the location of the branch for each revision and displaying it in the log then I should be able to use that directly to just return the branch location by itself. So the code would run and return to me trunk or xyz.\nI would like to write this code using python and the bzrlib toolbox.\nLastly I found this within the log.py code directly from bzr.\nbranch_nick = revision.rev.properties.get('branch-nick', None)\n if branch_nick is not None:\n      lines.append('branch nick: %s' % (branch_nick,))\nHowever, when I try to use revision.rev.properties.get('branch-nick', None) it gives me an error message saying the rev has no attribute to revision module. Also I would not know what to put in place for None.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":36,"Q_Id":62452268,"Users Score":1,"Answer":"The branch nick does not necessarily refer to anything that exists on disk. You can manually set the branch nick with the bzr nick command, or it may be the last part of the path of the branch name on the machine where the revision was created.\nrevision is an object returned by Repository.get_revision, not the bzrlib.revision module.","Q_Score":0,"Tags":"python,linux,bazaar","A_Id":62454957,"CreationDate":"2020-06-18T14:25:00.000","Title":"What Bzr function can I use to return the Branch location if given the repository and revision # \/ revision ID?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a simple Python utility that shows the tempo of a song (BPM) that is playing. I record short fragments of a few seconds to calculate the tempo over. The problem is that now I want to show this on a display using a Pygame UI, but when I'm recording sound, the UI does not respond. I want to make it so that the UI will stay responsive during the recording of the sound, and then update the value on the screen once the tempo over a new fragment has been calculated. How can I implement this?\nI have looked at threading but I'm not sure this is the appropriate solution for this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":101,"Q_Id":62452758,"Users Score":1,"Answer":"I'd use the python threading library.\nUse the pygame module in the main thread (just the normal python shell, effectively) an create a separate thread for the function that determines BPM. \nThis BPM can then be saved to a global variable that can be accessed by PyGame for displaying.","Q_Score":0,"Tags":"python,audio,pygame,recording","A_Id":62453148,"CreationDate":"2020-06-18T14:48:00.000","Title":"Record sound without blocking Pygame UI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'll keep it short.\nUsing ZMQ to communicate between Python(server) and C ( client ). ( made a game ) \nThe goal is to get the server side running only when the client connects.\nIs there a way to detect something in ZeroMQ to start the program?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":62452921,"Users Score":0,"Answer":"Q : \"Is there a way to detect something in ZeroMQ to start the program?\"\n\nI'll keep it short.\nYes, there is.\n\n read all details in the published API about using the socket_monitor() for handling this and similar events. Definitely doable & easy to integrateYou will soon fall in love with the ZeroMQ's smart tools & the designed-in art of the Zen of ZeroDefinitely a good pick :o)","Q_Score":1,"Tags":"python,c,zeromq","A_Id":62455495,"CreationDate":"2020-06-18T14:56:00.000","Title":"Detecting a \"join\" ZMQ","Data Science and Machine Learning":0,"Database and SQL":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 setting up different Python interpreters on sublime text when using SFTP on the remote server and the local one.\nThe thing is, I would like to use anaconda's autocomplete function in both local and remote environments, but these two environments have different settings. The local one is Python 3.6 whereas the remote one is Python3.7 with totally different packages. How should I set up the anaconda on Sublime Text to make it work? For example, when it's not on SFTP, use the local virtual environment, but when it comes to the remote server, use the remote virtual environment accordingly.\nAny suggestions are appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":97,"Q_Id":62453166,"Users Score":1,"Answer":"Anaconda doesn't work that way. It needs to actually run the Python executable locally. Even over an SSH connection, the local instance of the plugin can't talk to the remote Python. The only way you could do this is if you install Sublime on the remote server and connect from your local computer using a terminal server or remote XWindows session.","Q_Score":0,"Tags":"python,sublimetext3,sublime-anaconda","A_Id":62457581,"CreationDate":"2020-06-18T15:07:00.000","Title":"How to setup different Python interpreters on Sublime Text with SFTP and local?","Data 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 beginner at coding and I wanted to start with Python.\nI am currently following a free tutorial to install Python 3.7 along with Visual Studio Code.\n\nI have installed VS Code.\nI have installed both Python 3.7 and 3.8 (the latest version available)\nI've installed the Python and Code Runner extensions.;\nI am 100% sure that I have added both of them to PATH.\n\nRight now I am trying to run a simple command which is \"print(\"Hello there\")\", for some reason it says on the output section:\n[Running] python -u \"c:\\Users---\\Desktop\\whatever.py\"\n[Done] exited with code=0 in 0.155 seconds\nAny recommendation would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":575,"Q_Id":62453203,"Users Score":0,"Answer":"Exit 0 means the successful execution of the program and a non zero exit code indicates an error. And it looks like the 'Code Runner' extension caused it. You can try to disable it in order to use the 'Python' extension.","Q_Score":0,"Tags":"python,python-3.x,windows,installation,visual-studio-code","A_Id":62509419,"CreationDate":"2020-06-18T15:08:00.000","Title":"Python 3.7 & 3.8 and VSCode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a small question on string conversion in python3.\ns = '\\x001\\x002\\x001\\x000\\x005\\x005\\x000\\x004\\x000\\x000\\x00'\nprint(s) -> gives the output : \n1 2 1 0 5 5 0 4 0 0\nHowever, when I try to convert the string using the following:\nbytes(s, 'utf16').decode('utf16') , I get '\\x001\\x002\\x001\\x000\\x005\\x005\\x000\\x004\\x000\\x000\\x00'.\nWhat is the way to get the same output as print(s) programmatically?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":142,"Q_Id":62453683,"Users Score":2,"Answer":"On first example, you print the string s, and console will ignore the \\x00. You do a print(s).\nOn you last line, you get the string from python prompt.  If you print it: print(bytes(s,'utf-16').decode('utf-16')), you get what you want.\nSo Python prompt show you to the variable, with context (e.g. you see also the ' signs), but not the real representation of the string (which do you have with print).\nADDENDUM:\nprint will print the string in its argument, eventually calling str() to convert the argument to string.  But python prompt will print the representation of the variable (given with repr(). So you can print(repr(bytes(s,'utf-16').decode('utf-16'))) to get the same string you get in python interactive session, but as string. Instead of printing, you can assign such function (r = repr(bytes(...).decode(...)), so you have r[0] is ', r[1] is \\, etc.","Q_Score":1,"Tags":"python,string,encoding,character-encoding","A_Id":62454148,"CreationDate":"2020-06-18T15:32:00.000","Title":"String Conversion python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Anyone knows keyboard shortcut to move cells up or down in Jupyter notebook?\nCannot find the shortcut, any clues?","AnswerCount":6,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":21273,"Q_Id":62453756,"Users Score":-2,"Answer":"Tab + arrow keys works for me in Windows.","Q_Score":23,"Tags":"python,jupyter-notebook","A_Id":68584222,"CreationDate":"2020-06-18T15:36:00.000","Title":"How to move Jupyter notebook cells up\/down using keyboard shortcut?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am in trouble to understand Word2Vec. I need to do a help desk text classification, based on what users complain in the help desk system. Each sentence has its own class.\nI've seen some pre-trained word2vec files in the internet, but I don't know if is the best way to work since my problem is very specific. And my dataset is in Portuguese.\nI'm considering that I will have to create my own model and I am in doubt on how to do that. Do I have to do it with the same words as the dataset I have with my sentences and classes?\nIn the frst line, the column titles. Below the first line, I have the sentence and the class. Could anyone help me? I saw Gensin to create vector models, and sounds me good. But I am completely lost. \n\n: chamado,classe 'Prezados n\u00e3o estou conseguindo gerar uma nota fiscal\n  do m\u00f3dulo de estoque e custos.','ERP GEST\u00c3O', 'N\u00e3o consigo acessar o\n  ERP com meu usu\u00e1rio e senha.','ERP GEST\u00c3O', 'M\u00e9dico n\u00e3o consegue gerar\n  receitu\u00e1rio no m\u00f3dulo de Medicina e seguran\u00e7a do trabalho.','ERP\n  GEST\u00c3O', 'O produto 4589658 tinta hologr\u00e1fica n\u00e3o est\u00e1 dispon\u00edvel no\n  EIC e n\u00e3o consigo gerar a PO.','ERP GEST\u00c3O',","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":62457316,"Users Score":0,"Answer":"Your inquiry is very general, and normally StackOverflow will be more able to help when you've tried specific things, and hit specific problems - so that you can provide exact code, errors, or shortfalls to ask about. \nBut in general:\n\nYou might not need word2vec at all: there are many text-classification approaches that, with sufficient training data, may assign your texts to helpful classes without using word-vectors. You will likely want to try those first, then consider word-vectors as a later improvement.\nFor word-vectors to be helpful, they need to be based on your actual language, and also ideally your particular domain-of-concern. Generic word-vectors from news articles or even Wikipedia may not include the important lingo, and word-senses for your problem. But it's not too hard to train your own word-vectors \u2013 you just need a lot of varied, relevant texts that use the words in realistic, relevant contexts. So yes, you'd ideally train your word-vectors on the same texts you eventually want to classify. \n\nBut mostly, if you're \"totally lost\", start with more simple text-classification examples. As you're using Python, examples based on scikit-learn may be most relevant. Adapt those to your data & goals, to familiarize yourself with all the steps & the ways of evaluating whether your changes are improving your end results or not. Then investigate techniques like word-vectors.","Q_Score":0,"Tags":"python,word2vec","A_Id":62458138,"CreationDate":"2020-06-18T18:48:00.000","Title":"Text classification using Word2Vec","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cannot access my Django app on an EC2 instance (host2) in my browser by typing its public DNS name with port number: ec2-public-dns-of-this-instance.compute-1.amazonaws.com:8000\n\nI'm using the same Security Group that my other EC2 instance (host1) is using which is working just fine (my other Django app hosted on this instance works perfectly fine), with HTTP\/TCP open on 0.0.0.0\/0 on port 8000\nI started my Django project this way: .\/manage.py runserver 0.0.0.0:8000\nI've added hosts into my ALLOWED_HOSTS file which has these now: ALLOWED_HOSTS = ['*', '127.0.0.1', 'ec2-public-dns-of-this-instance.compute-1.amazonaws.com', '0.0.0.0', 'localhost']\nI was able to curl localhost:8000 which returned me 200 and Django default HTML page when I'm ssh'ed into this instance.\nI was able to curl ec2-public-dns-of-this-instance.compute-1.amazonaws.com:8000 which also returned me 200 and Django default HTML page when I'm ssh'ed into this instance.\nboth host1 and host2 are using the exactly the same subnet, VPC, SG, AMI, in the same AZ.\nboth host1 and host2 are running on AMI Ubuntu 18.04 LTS\n\nAny ideas how to fix this would be greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":740,"Q_Id":62458709,"Users Score":2,"Answer":"Interestingly, it started working three hours later.\nI didn't change anything and all things remain the same as I described above.\nI have no clue why this is the case...","Q_Score":3,"Tags":"python,django,amazon-web-services,amazon-ec2,aws-security-group","A_Id":62463395,"CreationDate":"2020-06-18T20:18:00.000","Title":"Cannot access my Django page hosted on AWS EC2 instance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"ive updated to python3 and downloaded virtualenv using:\n sudo \/usr\/bin\/easy_install virtualenv\nwhen i go to start the virtualenv i got the following error message :\nvirtualenv project1\nTraceback (most recent call last):\n  File \"\/usr\/local\/bin\/virtualenv\", line 6, in <module>\n    from pkg_resources import load_entry_point\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 3241, in <module>\n    @_call_aside\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 3225, in _call_aside\n    f(*args, **kwargs)\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 3254, in _initialize_master_working_set\n    working_set = WorkingSet._build_master()\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 585, in _build_master\n    return cls._build_from_requirements(__requires__)\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 598, in _build_from_requirements\n    dists = ws.resolve(reqs, Environment())\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 786, in resolve\n    raise DistributionNotFound(req, requirers)\npkg_resources.DistributionNotFound: The 'zipp>=0.4' distribution was not found and is required by importlib-resources\ni looked around and realised the that 'zipp' had not been installed so i installed that also. when i went to run the virtualenv again i got the same error message again as above. and for some reason it keeps referencing python 2.7 even though ive upgraded to python3.","AnswerCount":4,"Available Count":3,"Score":-0.049958375,"is_accepted":false,"ViewCount":1488,"Q_Id":62459220,"Users Score":-1,"Answer":"Just try out.\nvirtualenv venv\nIt should create a venv directory in same directory if python 3.x is being used.","Q_Score":0,"Tags":"python,python-3.x,django,python-2.7,virtualenv","A_Id":62463497,"CreationDate":"2020-06-18T20:52:00.000","Title":"error with installing virtualenv with python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"ive updated to python3 and downloaded virtualenv using:\n sudo \/usr\/bin\/easy_install virtualenv\nwhen i go to start the virtualenv i got the following error message :\nvirtualenv project1\nTraceback (most recent call last):\n  File \"\/usr\/local\/bin\/virtualenv\", line 6, in <module>\n    from pkg_resources import load_entry_point\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 3241, in <module>\n    @_call_aside\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 3225, in _call_aside\n    f(*args, **kwargs)\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 3254, in _initialize_master_working_set\n    working_set = WorkingSet._build_master()\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 585, in _build_master\n    return cls._build_from_requirements(__requires__)\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 598, in _build_from_requirements\n    dists = ws.resolve(reqs, Environment())\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 786, in resolve\n    raise DistributionNotFound(req, requirers)\npkg_resources.DistributionNotFound: The 'zipp>=0.4' distribution was not found and is required by importlib-resources\ni looked around and realised the that 'zipp' had not been installed so i installed that also. when i went to run the virtualenv again i got the same error message again as above. and for some reason it keeps referencing python 2.7 even though ive upgraded to python3.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":1488,"Q_Id":62459220,"Users Score":2,"Answer":"please try this ..\nyou just follow Exactly the bellow Items :\nOpen your Command Prompt AS ADMINISTRATOR -> right click on CMD and RUN AS ADMINISTRATOR\ngo to which Folder to you want to create your VirtualENV : For example : > Cd C:\\Users...\\Documents\\python\\src\ntype it : PIP install Virtualenv\nmake sure your internet connection is Ok\n4.type : python -m venv env\nand then you can create your project inside this env folder..\nall Comment code should be write in Command Prompt AS Administrator","Q_Score":0,"Tags":"python,python-3.x,django,python-2.7,virtualenv","A_Id":62463879,"CreationDate":"2020-06-18T20:52:00.000","Title":"error with installing virtualenv with python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"ive updated to python3 and downloaded virtualenv using:\n sudo \/usr\/bin\/easy_install virtualenv\nwhen i go to start the virtualenv i got the following error message :\nvirtualenv project1\nTraceback (most recent call last):\n  File \"\/usr\/local\/bin\/virtualenv\", line 6, in <module>\n    from pkg_resources import load_entry_point\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 3241, in <module>\n    @_call_aside\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 3225, in _call_aside\n    f(*args, **kwargs)\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 3254, in _initialize_master_working_set\n    working_set = WorkingSet._build_master()\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 585, in _build_master\n    return cls._build_from_requirements(__requires__)\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 598, in _build_from_requirements\n    dists = ws.resolve(reqs, Environment())\n  File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/pkg_resources\/__init__.py\", line 786, in resolve\n    raise DistributionNotFound(req, requirers)\npkg_resources.DistributionNotFound: The 'zipp>=0.4' distribution was not found and is required by importlib-resources\ni looked around and realised the that 'zipp' had not been installed so i installed that also. when i went to run the virtualenv again i got the same error message again as above. and for some reason it keeps referencing python 2.7 even though ive upgraded to python3.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1488,"Q_Id":62459220,"Users Score":0,"Answer":"i ended up using the built in python 3 venv package. it works just as well and it was straight forward and simple. thank you for all the help\nstart the virtual environment: python3 -m venv project1\nactivate the virtual environment: source project1\/bin\/activate\ndeactivate the virtual environment: deactivate","Q_Score":0,"Tags":"python,python-3.x,django,python-2.7,virtualenv","A_Id":62474626,"CreationDate":"2020-06-18T20:52:00.000","Title":"error with installing virtualenv with python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I know that Python is platform independent, but I don't understand how that works for CPython. If the interpreter and some of the modules are written in C, aren't those going to be platform dependent?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5091,"Q_Id":62459242,"Users Score":3,"Answer":"C is platform independent in the sense that it can be compiled for any machine for which a compiler is made to target that machine. That's why the Python source code is platform independent, even if a Python binary can only work on one platform.","Q_Score":1,"Tags":"python,c,cross-platform,platform-independence","A_Id":62459341,"CreationDate":"2020-06-18T20:53:00.000","Title":"How is Python platform independent?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is known that the convolution has the associative property: (A*B)*C=A*(B*C), where (*) denotes the convolutional operator. In keras, perform a 2D Convolution + 2D Average Pooling (with strides=(2,2)) is less expensive that perform only one convolution with strides=(1,1). I think that this is possible applying the associative property and doing first the convolution of kernel B and C, but I'm trying achieve the same result that keras via A*(B*C) instead of (A*B)*C, where A is the image input and B and C are the kernels, but the result differs from keras. \nIt's really possible convolve first the kernel, K=B*C and finally convolve the input with K: A*K?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":62460763,"Users Score":0,"Answer":"(A * B) * C is not equal A * (B * C)\n(A * B) is matrix multiply but (B * C) isn't, you can't just reverse the process","Q_Score":0,"Tags":"python,tensorflow,keras,conv-neural-network,convolution","A_Id":62462118,"CreationDate":"2020-06-18T23:05:00.000","Title":"Perform convolution 2D + Average pooling in Tensorflow\/Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to plot a grid of 13 graphs. But due to the nature of the code, I have to say:\nfig, axes = plt.subplots(nrows=3, ncols=5, figsize=(16,10))\nThis creates a grid of 15 plots. While the last two remain unused. \nIs there a way to plot only 13 plots?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":62466702,"Users Score":0,"Answer":"Unfortunately 13 is a prime number, this means that you cannot find a grid shape that will fit all plots without any white space. The only way you can use is to plot a single row of 13 plots, otherwise you have to find a compromise like 4x4, 5x3 or 3x5","Q_Score":0,"Tags":"python,matplotlib,data-visualization,seaborn","A_Id":62467231,"CreationDate":"2020-06-19T08:54:00.000","Title":"Is there a way to get a specific number of plots in seaborn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to deploy react front end app and Django as back end app on pythonanyhere.com?\nI have django API as back end and React as Front app.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":1183,"Q_Id":62467086,"Users Score":4,"Answer":"Yes, it is. React is just Javascript, so as long as you are serving your react code and loading it into your Django pages, it will just work.","Q_Score":3,"Tags":"django,reactjs,pythonanywhere","A_Id":62470522,"CreationDate":"2020-06-19T09:18:00.000","Title":"Possible to have react + Django on pythonanywhere.com","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am a novice in using tensorflow and I built a CNN which is trained and tested both with 80-85% accuracy. I tried to save my trained model using model.save('example.h5'), and download the file using files.download('example.h5')\nAfterwards I tried to load it to my flask back-end using model = tf.keras.models.load_model('example.h5').\nWhen I tried using it with random images, it's like the model has never been trained before. Any solutions? thank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":62473334,"Users Score":0,"Answer":"A common reason to this might be that you are normalizing your data on training but not before predicting. Make sure you normalize the input data before you run predictions, if you have trained on normalized data.","Q_Score":0,"Tags":"python,tensorflow,flask,keras,backend","A_Id":62483847,"CreationDate":"2020-06-19T15:16:00.000","Title":"CNN trained model not saved properly","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my project, Automation anywhere setup is already in use.\nHence is there any way by which i can push and pull credentials using a Python script From 'AA'.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":62474198,"Users Score":0,"Answer":"You can use  oauthlib by installing it 'pip install oauthlib'\nYou can use it to store credential in local file system and even refresh credential and validate it.","Q_Score":0,"Tags":"python,automationanywhere","A_Id":62474291,"CreationDate":"2020-06-19T16:02:00.000","Title":"Is there any way where Automation anywhere can be used as a credentials vault to store and fetch credentials 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 large .doc file with ~140 images in various formats (but mostly PNG). \nI would like to swap all the PNG images with JPEG (which would save me ~20MB, allegedly). \nI have tried saving as a .docx and manipulating things with Python-docx and docxtpl, but can't really get anything to actually happen to the file. I am kinda at a standstill, and would rather not have to modify the doc manually. \nAny tips would be greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":145,"Q_Id":62474684,"Users Score":0,"Answer":"So I eventually figured out an \"analog\" solution in that I didn't really use a program...\n\nI converted the .doc into a .docx using TextMaker\nI unzipped the    docx into a separate directory unimaginatively called \"docx\"\nThe    picture files resided in docx\\word\\media where I used a program very\nsimilar to Ann's (above) to convert the PNG's to JPEG (same\nbasename, different extension)\nIn the docx\\word_rels dir, there is a file document.xml.rels that documents all     the relationships\nbetween rId#'s in the main document.xml and the media files (among\nother things)\nUsing my trusty text editor, I searched and replaced\nall the \".png\" for \".jpeg\"\nAfter some housekeeping, I zipped it back\ninto an actual docx, checked it in TextMaker, and saved it as a .doc\nfile.\nI fixed the minor formatting issues (99% bad numbering on\nlists), and the boss loves me. :D\n\nIf nothing else, this was a great introduction to the internal structure of docx's!","Q_Score":1,"Tags":"python,ms-word","A_Id":62493283,"CreationDate":"2020-06-19T16:29:00.000","Title":"Replacing images in Word 2000 doc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a qwidgets one with raised\/sunkin\/groove\/ridge relief similar to tkinter. I know how to do this in tkinter, but don't know the style sheet option in Pyqt5 for each one. Please find the tkinter option\nWidget = Tkinter.Button(top, text =\"FLAT\", relief=raised ). Hope you can help to translate to Pyqt5","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":62476141,"Users Score":0,"Answer":"You can do this with QFrame. you can set QFrame.setFrameShadow(QFrame.Sunken). But I couldn't find for a QWidget one.","Q_Score":0,"Tags":"python,pyqt,pyqt5","A_Id":62481971,"CreationDate":"2020-06-19T18:05:00.000","Title":"Pyqt5 widget style similar to tkinter style","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am trying to develop a web application using HTML, PHP, and java script and i will include the Traveling salesman problem. should i use python for implementation or stick to java script? and what is the difference between them? which one is less complicated?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":450,"Q_Id":62476487,"Users Score":0,"Answer":"Adding additional languages to your application adds more complexity to your project. You already have two programming languages and a markup language in your project. Use javascript if you want to solve the problem on the client, or use php if you want to solve the problem on the server. If python is your language of choice, you can serve webpages from a python framework like flask instead of apache\/php.","Q_Score":0,"Tags":"javascript,python,html,algorithm,traveling-salesman","A_Id":62476679,"CreationDate":"2020-06-19T18:30:00.000","Title":"Traveling Salesman Problem implementation 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":1},{"Question":"For example, let my class = object\nwhen i do print(object * int) everything goes well\nHowever, when i do print(int * object). i receive an error in which my class object cannot be added to the int object, is this a issue resolvable without changing the default data types?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":28,"Q_Id":62477605,"Users Score":1,"Answer":"If you override __mul__, you can call print(object*int).\nIf you override __rmul__, you can call print(int*object). \nWhen a*b is written, it prioritizes calling a.__mul__(b), and if that is not implemented, calls b.__rmul__(a)","Q_Score":0,"Tags":"python,python-3.x,class,oop,error-handling","A_Id":62477897,"CreationDate":"2020-06-19T19:48:00.000","Title":"Python - How do i perform operations on my own class in both directions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to search for an element in an android application page which has a count down animation, so the searching for the element does not finish until the count down ends.\nIs there any way Appium does not wait and return immediate results?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":62479426,"Users Score":0,"Answer":"Use threading while the one counts down other can help with the search and when the countdown ends the other thread can kill the searching thread.","Q_Score":2,"Tags":"appium,appium-android,python-appium","A_Id":62792815,"CreationDate":"2020-06-19T22:31:00.000","Title":"Search for an element immediately","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For example, I have a list [25, 64, 67, 81, 90].\nI want to find the numbers that has the number 6 in them, so the answer will be 64, 67.\nHow can I do this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":196,"Q_Id":62480384,"Users Score":0,"Answer":"You can also achieve the same using filter result = list(filter(lambda x: '6' in str(x), mylist)).","Q_Score":1,"Tags":"python,string","A_Id":62480462,"CreationDate":"2020-06-20T00:44:00.000","Title":"finding a specific number in a number list python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does it make sense to use numpy's memmap across multiple cores (MPI)?\nI have a file on disk.\nCan I create a separate memmap object on each core, and use it to read different slices from the file?\nWhat about writing to it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":297,"Q_Id":62480538,"Users Score":3,"Answer":"Q : \"Does it make sense to use numpy's memmap across multiple cores (MPI)?\"\n\nYes ( ... even without MPI, using just Python native { thread- | process-}-based forms of concurrent-processing )\n\nQ : \"Can I create a separate memmap-object on each core, and use it to read different slices from the file?\"\n\nYes.\n\nQ : \"What about writing to it?\"\n\nThe same ( sure, if having been opened in write-able mode ... )","Q_Score":2,"Tags":"python,numpy,parallel-processing,mpi,memmap","A_Id":62483960,"CreationDate":"2020-06-20T01:13:00.000","Title":"Python: numpy memmap in parallel","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement a private field feature using django.I saved the private fields in django MutliSelectField.After this is done  now a differnt API is used to fetch the data.Before sending the response I need to eliminate the fields specified in MultiSelectField.In the serializer we can use create and update method for modifying the results of a POST, PUT and PATCH requests. Similarly is there any method that I can override so as to remove the items specified in the django MultiSelectField.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":62484127,"Users Score":0,"Answer":"I found the way to achieve it. In the serializer there is a method called to_representation. overriding it gives the ability to modify the response data just before it is sent.","Q_Score":0,"Tags":"python-3.x,django,django-rest-framework","A_Id":62485079,"CreationDate":"2020-06-20T09:41:00.000","Title":"Modifying the GET request response in django rest framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I got some question. I would like to create an app to run some sql query(ill use sqlite3) and then show data with tkinter, but ill like to add 1 more column to the results where user can input some data and next save it to the xlsx. What is the problem? I can't figure out method to add that column for user input. I'll show query results as a data frame.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":75,"Q_Id":62485477,"Users Score":0,"Answer":"It will be better if you provide minimum reproducible example. You can create Entry widget to add extra column to tkinter. Get the data from .get() method and add it to sqlite database using Update. Then you can read whole database as pandas dataframe and export is to excel using to_excel method.","Q_Score":0,"Tags":"python,sql,excel,sqlite,tkinter","A_Id":62498724,"CreationDate":"2020-06-20T11:54:00.000","Title":"Python sqlite3 tkinter. Run query, add column and save to xlsx","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am interested in using the tensor cores from NVIDIA RTX GPUs in python to benefit from its speed up in some scientific computations. Numba is a great library that allows programming kernels for cuda, but I have not found how to use the tensor cores. Can it be done with Numba? If not, what should I use?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":838,"Q_Id":62486362,"Users Score":2,"Answer":".... I have not found how to use the tensor cores. Can it be done with Numba?\n\nNo. Numba presently doesn't have half precision support or tensor core intrinsic functions available in device code.\n\nIf not, what should I use?\n\nI think you are going to be stuck with writing kernel code in the native C++ dialect and then using something like PyCUDA to run device code compiled from that C++ dialect.","Q_Score":0,"Tags":"python,cuda,gpu,nvidia,numba","A_Id":62487175,"CreationDate":"2020-06-20T13:21:00.000","Title":"How to program NVIDIA's tensor cores in RTX GPU with python and numba?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a starter in the field of ML and wants to understand \"Multi Dimensional Array\". My current understanding is as follows. Please help me where i am wrong.\nSuppose I have data of customers, we can refer customers as items.\nNow suppose each item i.e. each individual has a Customer identification no (CIN) - we can call this as a one dimensional matrix.\nextending the same example,\nnow each item has list of attributes e.g. CIN, Gender, Height, weight, Eye colour. If i want to arrange them it will be a 2 dimensional matrix. Row representing students, columns representing their physical attributes \"Roll No, Gender, Height, weight, Eye colour\".\nNow suppose i add another list of different attributes - Past purchase history i.e. Last purchase date and invoice no.\nCan we call a matrix which has both phyical attributes \"Roll No, Gender, Height, weight, Eye colour\" and \"Last purchase date and invoice no.\" is this a 3 dimensional matrix ?\nIs it the grouping into physical and purchase history which will make it a 3 d matrix.\nI can still store it as a 2 d matrix (like a spread sheet) with physical and purchase history as columns or like 2 sheets with common link as CIN.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":62486844,"Users Score":1,"Answer":"I think you are getting confused between dimensions of an array and dimensions for a ML model also called features or independent variables.\nWhen you train a model each piece of information that you pass to the model is a feature or a dimension. So for example Roll No, Gender, Height are all features. If you add Last purchase date and invoice those are also features. If you add all of them in a dataframe, each row of the dataframe can be thought of as an 1-D array.\nThe grouping of physical attributes and purchase history which will not make it a 3-D matrix.\n3-D arrays or n-D arrays are called tensors. They are something completely different.","Q_Score":1,"Tags":"python,arrays,multidimensional-array","A_Id":62486969,"CreationDate":"2020-06-20T14:04:00.000","Title":"What are dimensions in multi dimensional array in practical sense","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would to create new Python project which include pipenv for manage my packages.\nBut when I try to install package with it, it throw me I exception :\n\nValueError: Not a valid python path:\n'C:\/dev\/Anaconda3\/Scripts\/python.exe'\n\nI try pipenv command with 2 differents emulation terminal (Cmder and Terminus) which produce same result.\nIn old time a try Anaconda solutions for work with Python. But now I don't want use this and I uninstall Anaconda in my OS.\nIt seems that my OS keep old reference to this python executable into Anaconda in your PATH... But I display my 2 PATH variables OS (PATH system OS and PATH user) and nothing has this location path into your string.\nThe directory c:\\dev\\Anaconda3 doesn't exist !\nI try to search uninstall Anaconda program in my tool application manager Windows but Anaconda is not diplayed in that listing. It seems to be good uninstalled.\nI install correctly pipenv executable :  pipenv --version\n\npipenv, version 2020.6.2\n\nI install correctly python executable :  python --version\n\nPython 3.8.3\n\nI added 3 differents PATH python for my OS PATH (system PATH and user PATH) :\n\nC:\\dev\\python\\Python38\nC:\\dev\\python\\Python38\\Scripts\\\nC:\\dev\\python\\Python38\\Scripts\\bin\n\nWhy I keep old reference to Anaconda program ?\nWhy many program search python in same old deleted path and PATH variable do not included this ?\nHow pipenv created his PATH environment variable ?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":756,"Q_Id":62487033,"Users Score":0,"Answer":"You need to delete the old path in the Windows Registry.\n\nHit win + r\nregedit\nfind folders with (Anaconda3 or Miniconda3).\n\nProbably two folders. Do not delete folders with the new path to Python.","Q_Score":3,"Tags":"python,windows,anaconda,pipenv,cmder","A_Id":63356807,"CreationDate":"2020-06-20T14:21:00.000","Title":"pipenv search python in old directory do not exist","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to write a script to automate a task I'd need to do. So I need this script to check if python is on the \/login page and if he is, to enter the username and password for logging in.\nFor username when logging in, in HTML, it is an input type=\"text\" name=\"username\" and for the password it is an input type=\"password\" name=\"password\". I did search and saw that I should use requests but I only saw them executing POST methods and I'm not sure if this is the case here as well.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":169,"Q_Id":62487636,"Users Score":1,"Answer":"I'd suggest considering using selenium Framework","Q_Score":0,"Tags":"python,python-3.x,python-requests","A_Id":62487663,"CreationDate":"2020-06-20T15:14:00.000","Title":"Python script to enter data in website inputs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to write a script to automate a task I'd need to do. So I need this script to check if python is on the \/login page and if he is, to enter the username and password for logging in.\nFor username when logging in, in HTML, it is an input type=\"text\" name=\"username\" and for the password it is an input type=\"password\" name=\"password\". I did search and saw that I should use requests but I only saw them executing POST methods and I'm not sure if this is the case here as well.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":169,"Q_Id":62487636,"Users Score":1,"Answer":"Yes selenium works well for this, just to give you some hints. I've done this type of program in the past:\nselenium allows you to click on buttons on a website (you can use this to navigate to the login page).\nThen it allows you to enter data into text fields (this is using a .send_keys() function which you will use to input your name\/password).\nLastly, to actually login you can use the click() function to click on the login button or use send_keys() to \"click\" enter on the keyboard.\nOnce you get it working its actually really fun to watch.","Q_Score":0,"Tags":"python,python-3.x,python-requests","A_Id":62487964,"CreationDate":"2020-06-20T15:14:00.000","Title":"Python script to enter data in website inputs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have 20k images that I want to compile into a video using Python. It takes unacceptably long to do this with a single process: having a for loop to load images one by one into RAM and finally writing them into a video.\nTherefore, I'm looking for a parallel approach that gets the job done faster.\nThis sounded impossible the first time I thought about this, because this would mean multiple processes simultaneously writing to a single file (i.e., the output video file).\nBut on a second thought, maybe there exist some tools in Python that allow me to create a \"placeholder video,\" and each frame of which can be safely written by one thread. That way I could create a video using all my cores much more quickly.\nIs this possible at all?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":178,"Q_Id":62489578,"Users Score":3,"Answer":"The issue with the idea of the \"placeholder video\" is that this video would inherently need to be uncompressed, since the compression of the video relies on using previous frames as a baseline to eliminate redundant information. Thus your resulting video would be quite large, though in theory it could be done (you might have to define a special file type though so probably not doable in python).\nDo you have an idea of which portion of this process is taking the longest?\nFor instance, if opening the files is the limiting factor, you could have worker processes open images simultaneously and pass the variables to a shared process that writes a single video.\nIf the encoding is the limiting factor and is happening on CPU, you may be able to divide the frames sequentially and write pieces of the video, combining them at the end. However, it's also possible that you're using special hardware (e.g. GPU) for encoding in which case you probably wouldn't be able to speed the process much this way.\nAll this being said, I will echo the sentiments that ffmpeg is a good tool for this sort of work, and you can easily call it using the python subprocess module if you want to run from python.","Q_Score":0,"Tags":"python","A_Id":62489671,"CreationDate":"2020-06-20T17:48:00.000","Title":"Write video frames from several Python processes into a single file concurrently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 20k images that I want to compile into a video using Python. It takes unacceptably long to do this with a single process: having a for loop to load images one by one into RAM and finally writing them into a video.\nTherefore, I'm looking for a parallel approach that gets the job done faster.\nThis sounded impossible the first time I thought about this, because this would mean multiple processes simultaneously writing to a single file (i.e., the output video file).\nBut on a second thought, maybe there exist some tools in Python that allow me to create a \"placeholder video,\" and each frame of which can be safely written by one thread. That way I could create a video using all my cores much more quickly.\nIs this possible at all?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":178,"Q_Id":62489578,"Users Score":1,"Answer":"This is impossible.\nA video file is composed with a video codec which typically uses a difference compression. I.e. only the data which differs from up to several preceeding, and possibly following, frames is recorded. The fact that resulting frame data are heavily interwined like this means that it's impossible for several processes to compete writing frames at the same time.\nIf Python is too slow for your task, you may want to use other tools like FFMpeg.","Q_Score":0,"Tags":"python","A_Id":62489663,"CreationDate":"2020-06-20T17:48:00.000","Title":"Write video frames from several Python processes into a single file concurrently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ok, so i want the python's random module to choose 10 random symbols from a string and print it into the console. random.choices returns a list but i want a string like \"1jF7Ud7oVj\". How can i do this?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":62489847,"Users Score":0,"Answer":"You can use ''.join(list_name) to conjoin items in a list together","Q_Score":1,"Tags":"python,python-3.x","A_Id":62490805,"CreationDate":"2020-06-20T18:10:00.000","Title":"How to generate a string of random symbols from a string using python's random module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Description:\n\nUsing the menu Script Library > iCloud in Pythonista 3 on iPad shows .py files created in Pythonista, but not files created in another IDE and saved to that iCloud folder\n\nSteps to reproduce:\n\ncreate .py file in an IDE on MacBook Pro\nsave the file on MacBook Pro in iCloud > Pythonista 3 > <subfolder>\nin Pythonista 3 on iPad, open the main menu (hamburger menu) and select `Script Library > iCloud > \n\nExpected:\n\nPythonista file navigator shows all files in the folder\n\nActual:\n\nPythonista file navigator shows only the files created in Pythonista\n\nQuestions:\n\nIs Pythonista caching an index of its iCloud folder separately? If so, is there a way to get Pythonista to reindex the folder?\nHow to see all the files in the Pythonista iCloud folder, and thus use that folder for syncing files between iPad and MacBook Pro?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1199,"Q_Id":62490043,"Users Score":0,"Answer":"Problem:\n\nPythonista does seem to be either a) relying on an outdated index of the iCloud > Pythonista folder itself, or b) not downloading the files from iCloud automatically. We need to force Pythonista to fetch the file details directly and\/or download the files.\n\nSolution:\n\nUnder the main menu (hamburger menu), click the +, then Import..., and select Files from the contextual menu. This will access the iCloud drive.\nSelect the Pythonista folder from iCloud.\n\nThis should trigger Pythonista to download the current files from iCloud. You won\u2019t need to actually complete the import procedure - it\u2019s enough to access the iCloud drive through the import menu.","Q_Score":1,"Tags":"python,icloud,pythonista","A_Id":62490044,"CreationDate":"2020-06-20T18:29:00.000","Title":"Pythonista 3 doesn\u2019t show iCloud files created on MacBook Pro","Data 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":"Description:\n\nUsing the menu Script Library > iCloud in Pythonista 3 on iPad shows .py files created in Pythonista, but not files created in another IDE and saved to that iCloud folder\n\nSteps to reproduce:\n\ncreate .py file in an IDE on MacBook Pro\nsave the file on MacBook Pro in iCloud > Pythonista 3 > <subfolder>\nin Pythonista 3 on iPad, open the main menu (hamburger menu) and select `Script Library > iCloud > \n\nExpected:\n\nPythonista file navigator shows all files in the folder\n\nActual:\n\nPythonista file navigator shows only the files created in Pythonista\n\nQuestions:\n\nIs Pythonista caching an index of its iCloud folder separately? If so, is there a way to get Pythonista to reindex the folder?\nHow to see all the files in the Pythonista iCloud folder, and thus use that folder for syncing files between iPad and MacBook Pro?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1199,"Q_Id":62490043,"Users Score":1,"Answer":"You can also open the files in Pythonista using the \"Files\" app from Apple on the same device. Once you opened them this way, they usually show up in Pythonista\u00b4s file browser\/open file menu just fine. That way you don't have to go through the hassle of doing this on another iOS device and the sharing... .","Q_Score":1,"Tags":"python,icloud,pythonista","A_Id":71858046,"CreationDate":"2020-06-20T18:29:00.000","Title":"Pythonista 3 doesn\u2019t show iCloud files created on MacBook Pro","Data 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 i run multiple python http servers on one machine to receive http post request from a webpage?\ncurrently i am running an http server on port 80 and on the web page there is a HTML form which sends the http post request to the python server and in the HTML form i am using the my server's address like this : \"http:\/\/123.123.123.123\" and i am receiving the requests\nbut i want to run multiple servers on the same machine with different ports for  each server.\nif i run 2 more servers on port 21200 and 21300 how do i send the post request from the HTML form on a specified port , so that the post request is received and processed by correct server??\ndo i need to define the server address like this : \"http:\/\/123.123.123.123:21200\" and \"http:\/\/123.123.123.123:21300\" ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":912,"Q_Id":62490441,"Users Score":3,"Answer":"Yes can run multiple webservers on one machine.\nuse following commands to run on different ports:\npython3 -m http.server 4000\n4000 is the port number, you can replace it with any port number here.","Q_Score":0,"Tags":"python,html,http-post","A_Id":62490625,"CreationDate":"2020-06-20T19:06:00.000","Title":"is it possible to run multiple http servers on one machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have created a script using Python 3.8 that I am looking to turn into an app using Py2App. I have created the Alias mode app. However, the app does not work. Clicking it brings an error with the options \"Open Console\" and \"Terminate\". However, if I go into the package contents and click the .exe, that exe works. Why doesn't the main app work, but the inside exe does?\nUsing Python 3.8 on a MacBook.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":62490829,"Users Score":0,"Answer":"The question does not contain enough information to be able to tell what's wrong.\nA good way to debug what's wrong is to start the application from the command-line. If your app bundle is named \"Hello.app\" you can start the app as \"dist\/Hello.app\/Contents\/MacOS\/Hello\" in the Terminal (in the same directory where you called py2app).\nUsually this shows an error message in the Terminal.","Q_Score":0,"Tags":"python,macos,python-3.8,py2app","A_Id":62559251,"CreationDate":"2020-06-20T19:41:00.000","Title":"Why doesn't Py2App work but the package content exe does","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I open a binary or text file in Python with the open and read() commands to be written somewhere else, will it be executed? Could this expose the computer to malware if the file contains malicious code?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":524,"Q_Id":62491329,"Users Score":2,"Answer":"No, read and open file does not execute the executable file in python. If you want you can read the executable file in binary by adding \"b\"\nopen(\"readfile.txt\", \"rb\")\nFor executing the py file you need to use \"exec\" function like\nexecfile('hello.py')\nFor executing external exe file there are several ways,where you need to import \"os\" or \"subprocess\".\nexample you can execute file by using the below function.\nimport os\nos.startfile(\"C:\\Documents and Settings\\flow_model\\flow.exe\")","Q_Score":3,"Tags":"python,file,malware","A_Id":62556375,"CreationDate":"2020-06-20T20:31:00.000","Title":"Do open() and read() in python execute the file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to deep learning and am currently researching a certain topic. I am looking for machine learning detection of anomalies in time series pattern and their implementation in python.\nFor example, I have a recording of the different CPU frequencies of my computer during a certain time interval. I would like to implement a supervised learning algorithm that takes a time series of CPU frequency as an input and decides, whether anything \"unusual\" happened during that time (unusual CPU usage etc).\nEDIT:\nMy data sets look the following way, every 10 seconds the current CPU frequency is measured. I have not specified an exact number of datapoints per set, the following is just for illustration. But I am expecting around 2500 datapoints per set:\nDataset_1: {1.2, 1.2, 1.6, 1.3, 1.5, 1.7, 1.6, 1.4, 1.5} -> Label: \"good\"\nDataset_2: {1.3, 1.2, 1.4, 1.3, 1.4, 1.5, 1.9, 2.1, 2.0} -> Label: \"good\"\nDataset_n: {1.3, 1.2, 3.6, 3.5, 1.4, 1.5, 3.3, 3.2,\n1.2} -> Label: \"bad\"\nMy understanding of a supervised ML algorithm is that i have training datasets. However, every tutorial that i have found so far always labels each value in a data set. In my case that would not be possible, as I could only tell my ML algorithm:\na) this time series data set is normal\n\nb) in this data set something is not normal\n\n\nbut i wouldn't be able to label each individual value, meaning i cannot say:\n1.2 -> good\n1.3 -> bad\n1.4 -> good\nAs there are many different ML algorithm, it is hard for a beginner to determine which is a good one to use. So my question is:\nWhich (python implemented) algorithm could i use as a start, that accepts labels for entire datasets and does not expect each value to be labeled.\nI hope this question makes sense, edits are highly welcome as much as your time! thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":62491406,"Users Score":0,"Answer":"For this application I would go with KNN(K - nearest neighbors). Tech with Tim has a great tutorial on KNN, explains it well and shows the implementation.\nHope this helps","Q_Score":0,"Tags":"python,deep-learning,pattern-matching","A_Id":62491620,"CreationDate":"2020-06-20T20:39:00.000","Title":"python supervised learning with data set classification","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"During the execution of my job I want to build a pandas DataFrame with its internal state at each step of execution. I want to do that because I want to be able to use the DataFrame later to do some analysis. So, that's the context: I start with an empty DataFrame and, after the job has finishing producing all its data, the final DataFrame size is 7GB (at most).\nThese are the approaches I've tried this far:\n\nI can maintain a list of lists, my job keeps appending new rows to that list. At the end I run something like: df = pd.DataFrame(rows, columns=list(\"abc\")). This is the fastest method, but it's very wasteful in terms of memory usage.\nI don't use the lists of lists anymore, but, instead I keep calling df = df.append([{\"a\": 1.0, \"b\": 1.0, \"c\": \"hello\"}]). This starts off ok, but as the DataFrame grows a lot of memory copying starts happening and it becomes really slow.\n\nSo, neither of them are ideal. I can estimate the final size of the DataFrame before my job runs (I think I can usually match the size precisely, to be honest), so I would like to tell pandas to allocate the entire memory ahead (or at least a large enough chunk to last for a while) and then, I'd like a method similar to df.append that will just add the new row at the end of the preallocated memory. Ideally, it would be smart enough to resize memory, if needed.\nI may be grossly missing something, but I sincerly couldn't find a way to do that anywhere I looked.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":276,"Q_Id":62492801,"Users Score":1,"Answer":"Use approach 1, but every time you get to (say) 10000 rows, convert the list of lists to a DataFrame, append the dataframe to a list of dataframes, and clear your list of lists (by setting it to []). At the end, take your list of df chunks and pd.concat them together.","Q_Score":1,"Tags":"python,pandas,dataframe","A_Id":62493142,"CreationDate":"2020-06-20T23:21:00.000","Title":"How to preallocate memory when creating pandas DataFrames","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My pip is not being recognized by my terminal and it says it's because I don't have \"C:\\Users\\dsmin\\AppData\\Local\\Programs\\Python\\Python38\\Scripts\" is not in PATH.\nHowever, when I go to environment variables -> system variables -> PATH -> new and add the above path in, it doesn't work. When I restart my computer, the variable is gone.\nWhat should I do? (I have windows 10 if that helps)\nEdit: I just gave up and downloaded conda for install, but that ended up fixing pip for some reason. thank you for all the help!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1280,"Q_Id":62493131,"Users Score":1,"Answer":"Manually add the path to the path-variable\nin Windows:\n\n\nRightClick on This PC\nGoto properties\nAdvanced system settings\nAdvance tab->Environment Variables\nIn system variables, section find for the path\nEdit path\nall path leave as it is.\nat the end  ';' as a separator paste path of python scripts","Q_Score":1,"Tags":"python,pip","A_Id":62493398,"CreationDate":"2020-06-21T00:14:00.000","Title":"Adding path to the PATH environment variable does not work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just finished my app and made a release version with buildozer and signed it but when I tried to upload my apk file to Google Play Console...It said that the API level of the app was 27 and it should be level 28. So how can I do this?\nThanks in advance","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":340,"Q_Id":62493617,"Users Score":0,"Answer":"It should be edited in buildozer.spec file.\nIf you scroll down it's default to 27, change it to specification","Q_Score":0,"Tags":"python,android,python-3.x,kivy,buildozer","A_Id":62495552,"CreationDate":"2020-06-21T01:52:00.000","Title":"How to change API level when using buildozer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I just finished my app and made a release version with buildozer and signed it but when I tried to upload my apk file to Google Play Console...It said that the API level of the app was 27 and it should be level 28. So how can I do this?\nThanks in advance","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":340,"Q_Id":62493617,"Users Score":0,"Answer":"Find the line that says android.api = 27 in your buildozer.spec file and change it to 28.","Q_Score":0,"Tags":"python,android,python-3.x,kivy,buildozer","A_Id":62494264,"CreationDate":"2020-06-21T01:52:00.000","Title":"How to change API level when using buildozer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am stuck about True\/False of x and not x,\nfor x = 0 where x is int, in Python.\nWhy does if not x allow execution of the following statement and why not for if x?\nPlease give explanation.","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":866,"Q_Id":62493898,"Users Score":0,"Answer":"Ultimately: because the language definition says so.\nPython has chosen to make almost any expression implicitly convertible to a boolean (True\/False) value. The conversion is defined in the language.\nFor integer types, the conversion is that 0 is False, other values are True.\nAnd, of course, if an expression X is False, then not X is True, by simple definition of the operator not.","Q_Score":0,"Tags":"python,integer,boolean-operations","A_Id":62494086,"CreationDate":"2020-06-21T02:49:00.000","Title":"Why, for x=0, 'not x' is True and 'x' is False in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am stuck about True\/False of x and not x,\nfor x = 0 where x is int, in Python.\nWhy does if not x allow execution of the following statement and why not for if x?\nPlease give explanation.","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":866,"Q_Id":62493898,"Users Score":1,"Answer":"Because in python 0 is considered false, so when you write (if x) it will execute only when x !=0 (so it will be evaluated as true).","Q_Score":0,"Tags":"python,integer,boolean-operations","A_Id":62494015,"CreationDate":"2020-06-21T02:49:00.000","Title":"Why, for x=0, 'not x' is True and 'x' is False in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am stuck about True\/False of x and not x,\nfor x = 0 where x is int, in Python.\nWhy does if not x allow execution of the following statement and why not for if x?\nPlease give explanation.","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":866,"Q_Id":62493898,"Users Score":0,"Answer":"If statements don't execute their contents if their condition evaluates to a \"false\" value, like 0, an empty string, False, or an empty list\/tuple.","Q_Score":0,"Tags":"python,integer,boolean-operations","A_Id":62493917,"CreationDate":"2020-06-21T02:49:00.000","Title":"Why, for x=0, 'not x' is True and 'x' is False in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a custom User model in django. Some other models are related to that user model like UserDetails, Prlofile etc.\nNow I need on around 100k users in my database for a testing purpose.\nI just wanna create users by changing tehir email address which is in User model.\nWhat is the best way to create suchc a large number of objects and save it to database also with corresponding related models.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":62496174,"Users Score":0,"Answer":"download a few thousand names in a file and code something, that will just add the name@gmail.com, name@email.com, name@whateveryouwant.com, and with the name, just make it nameRANDOMNUMBERS, same for the password. It will take time to get 100k, but I'm not sure, if there is an easier way to do it.","Q_Score":0,"Tags":"python,django,django-models","A_Id":62496258,"CreationDate":"2020-06-21T08:25:00.000","Title":"How to clone millions of copy of a database model in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know this question might already be asked but I have a serious problem with this\nevery time when I open my vscode and I want to code in python it shows me that Microsoft python language server is downloading and when I have no stable connection it will stack and I can't even code in python\nwhat should I do?\nI want this to stop downloading!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":630,"Q_Id":62497186,"Users Score":1,"Answer":"You can set \"python.languageServer\": \"Jedi\" to stop VS Code from trying to download the Microsoft language server.","Q_Score":2,"Tags":"python,python-3.x,visual-studio-code,ubuntu-18.04","A_Id":62523459,"CreationDate":"2020-06-21T10:18:00.000","Title":"Microsoft python language server doesn't stop downloading","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on multi-label image classification where some labels have very few images. How to handle these cases?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":148,"Q_Id":62497352,"Users Score":1,"Answer":"Data augmentation, which means making 'clones' (reverse image\/ set different angle\/ etc.)","Q_Score":0,"Tags":"python,deep-learning,multilabel-classification","A_Id":62497465,"CreationDate":"2020-06-21T10:35:00.000","Title":"Class Imbalance for image classification","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is very simple , as you read the title I want plugin similar to GitLens that I found in vscode. As you know with GitLens you can easily see the difference between two or multiple commits. I searched it up and I found GitToolBox but I don't know how to install it as well and I don't think that's like GitLens...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4584,"Q_Id":62497603,"Users Score":0,"Answer":"Open Settings on jetbrains IDE.\nGo to plugins and look for git toolbox.\nInstall it and boom, its done!","Q_Score":6,"Tags":"python,intellij-plugin","A_Id":68997644,"CreationDate":"2020-06-21T11:00:00.000","Title":"Is there a plugin similar to gitlens for pycharm or other products?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to do a 1\/3rd octave band analysis of a noise signal. I have got a time signal representing sound pressure(Pa). I have arrays of the central frequencies and of the lower and upper cutoffs.The final aim is to get a bar chart representing sound level versus the 1\/3rd octave bands.\nFrom a theory that I followed suggested to first do FFT of the signal. Then reconstruct the signal in the 1\/3rd octave bands. In each of the construction, compute the RMS values of the pressure. That's it. Convert these RMS values into sound level(dB) and plot against the central frequencies.\nThe issue I am facing is how to reconstruct the signal using IFFT function given that the new signal has less number of amplitude points. So, the reconstruction is essentially not possible because of dimension inconsistency between time and amplitude. I am stuck at this point.\nI have a very little experience in DSP. So, any help even if the approach is different from what I tried explaining above will be much appreciated. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":417,"Q_Id":62498174,"Users Score":0,"Answer":"To reconstruct the time-domain signal for a particular 1\/3 octave band, you set the amplitude to zero for all the frequencies outside of your band before you do the IFFT.  The IFFTs for each of those bands will be the same size as our original FFT, so you will end up with the same time resolution on output from each band.\nDoing a full-size IFFT for each band is obviously pretty expensive.  There are ways to optimize this, but really there is probably no reason for you to be reconstructing the time-domain signal in the first place.\nThe IFFT operation1 will not change the RMS value of signal, so just calculate this using the frequency-domain components and forget about the IFFT altogether.  Because of the way the RMS computation works, you don't even need to remember that the frequency-domain amplitudes are complex numbers -- you get a proportional answer if you treat the real and imaginary components the same way.  Just don't forget to include all the extra zeros in the RMS divisor, since there are a different number of them for each band.\n1 - This is true for a mathematically standard IFFT.  Some implementations will divide the outputs by the signal length.  This will be the same for all bands, so it won't affect their relative values and it's easy to correct for.","Q_Score":1,"Tags":"python,signal-processing,fft,noise,time-frequency","A_Id":62500207,"CreationDate":"2020-06-21T11:56:00.000","Title":"1\/3rd Octave Band analysis of a noise signal","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Impacted versions:\n12.0\nSteps to reproduce:\nI have made a customization to postpone the creation of pos order picking\nand delegate the task to a job\nsome time i get the error below\nCurrent behavior:\n2020-06-18 17:49:24,588 1370 ERROR cafe9.rabeh.io odoo.addons.base.models.ir_cron: Call from cron POS Orders: Process Pending Orders for server action #610 failed in Job #24\nTraceback (most recent call last):\nFile \"\/opt\/rabeh\/odoo\/odoo\/addons\/base\/models\/ir_cron.py\", line 102, in _callback\nself.env['ir.actions.server'].browse(server_action_id).run()\nFile \"\/opt\/rabeh\/odoo\/odoo\/addons\/base\/models\/ir_actions.py\", line 569, in run\nres = func(action, eval_context=eval_context)\nFile \"\/opt\/rabeh\/odoo\/odoo\/addons\/base\/models\/ir_actions.py\", line 445, in run_action_code_multi\nsafe_eval(action.sudo().code.strip(), eval_context, mode=\"exec\", nocopy=True)  # nocopy\nallows to return 'action'\nFile \"\/opt\/rabeh\/odoo\/odoo\/tools\/safe_eval.py\", line 350, in safe_eval\nreturn unsafe_eval(c, globals_dict, locals_dict)\nFile \"\/opt\/rabeh-12\/rabeh_addons\/pos_pending_session\/models\/pos_order.py\", line 68, in pending_picking_creation\npo_order.create_picking()\nFile \"\/opt\/rabeh-12\/rabeh_addons\/pos_pending_session\/models\/pos_order.py\", line 36, in\ncreate_picking\nres = super(PosOrder, orders).create_picking()\nFile \"\/opt\/rabeh\/odoo\/addons\/point_of_sale\/models\/pos_order.py\", line 841, in create_picking\norder._force_picking_done(order_picking)\nFile \"\/opt\/rabeh\/odoo\/addons\/point_of_sale\/models\/pos_order.py\", line 856, in _force_picking_done\npicking.action_done()\nFile \"\/opt\/rabeh\/odoo\/addons\/stock\/models\/stock_picking.py\", line 631, in action_done\ntodo_moves._action_done()\nFile \"\/opt\/rabeh\/odoo\/addons\/purchase_stock\/models\/stock.py\", line 96, in _action_done\nres = super(StockMove, self)._action_done()\nFile \"\/opt\/rabeh\/odoo\/addons\/stock_account\/models\/stock.py\", line 389, in _action_done\nres = super(StockMove, self)._action_done()\nFile \"\/opt\/rabeh\/odoo\/addons\/stock\/models\/stock_move.py\", line 1137, in _action_done\nmoves_todo.mapped('move_line_ids')._action_done()\nFile \"\/opt\/rabeh\/odoo\/addons\/stock\/models\/stock_move_line.py\", line 445, in _action_done\nQuant._update_available_quantity(ml.product_id, ml.location_dest_id, quantity, lot_id=ml.lot_id, package_id=ml.result_package_id, owner_id=ml.owner_id, in_date=in_date)\nFile \"\/opt\/rabeh\/odoo\/addons\/stock\/models\/stock_quant.py\", line 216, in _update_available_quantity\nself._cr.execute(\"SELECT 1 FROM stock_quant WHERE id = %s FOR UPDATE NOWAIT\", [quant.id], log_exceptions=False)\nFile \"\/opt\/rabeh\/odoo\/odoo\/sql_db.py\", line 148, in wrapper\nreturn f(self, *args, **kwargs)\nFile \"\/opt\/rabeh\/odoo\/odoo\/sql_db.py\", line 225, in execute\nres = self._obj.execute(query, params)\npsycopg2.errors.SerializationFailure: could not serialize access due to concurrent update\nExpected behavior:\ni think this line should generate could not obtain lock\ni was just wondering when it could generate \"could not serialize access due to concurrent update\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1122,"Q_Id":62498500,"Users Score":0,"Answer":"It could have obtained the lock, as the lock is currently available.  But it had been locked at some previous point which overlaps with the current transaction's snapshot.  So obtaining the lock is possible, but would create a serialization problem if it were to acquire it.  Reporting that as a serialization failure seems like the correct outcome.\nUsing FOR UPDATE NOWAIT in a transaction with elevated isolation level seems inconsistent, or at least unnecessary.  What are you hoping to accomplish by doing this?  Your description of \"while creating pos picking from a job\" doesn't elucidate this for me.  Is that some odoo-specific jargon?","Q_Score":0,"Tags":"python,postgresql,odoo,odoo-12","A_Id":62500903,"CreationDate":"2020-06-21T12:29:00.000","Title":"could not serialize access due to concurrent update while creating pos picking from a job","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm relatively new to exact-cover and similar problems, so please bear with me. Suppose I have a typical exact-cover problem, ie. given a set X and a collection of X's subsets S, I want to find S* (a subset of S) that exact-covers X. However, I want the solution S* to contain exactly k elements. Moreover, one solution is enough.\nI know that Knuth's Algorithm X is designed to return all possible solutions. Should I just run Knuth's Algorithm and iterate through the solutions until I find one with k elements, or is there (as I suspect) a much better way? I'm using Python btw.\nFor context, X's size is <100 but S's size can be 10^6. k is relatively small at <10.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":415,"Q_Id":62499338,"Users Score":2,"Answer":"If k is small, you might simply try adding k extra elements, and duplicate each subset k times with each duplicate including exactly one of the k extra elements.\nAnother approach would be to solve the exact cover problem as an integer linear program, and solve it with an ILP solver. Then you'll have 0-1 variables x_i that say whether the ith subset is included in a solution, with constraints that prevent overlapping sets being included in the solution. In this formulation, to provide a cover with exactly k subsets, you'll simply have the additional constraint that sum(x_i) = k.\nIt's also possible to modify algorithm X to deal directly with the constraint. Just count how many rows you've chosen so far, and if you've already chosen k, just fail without searching further. Similarly, ignore solutions that have fewer than k rows.","Q_Score":1,"Tags":"python,algorithm,performance,np-complete,knuth","A_Id":62500385,"CreationDate":"2020-06-21T13:38:00.000","Title":"Exact cover problem but with constraint on exact number of subsets in the solution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know how to perform the below mentioned task\nI want to upload a CSV file to a python script 1, then send file's path to another python script in file same folder which will perform the task and send the results to python script 1.\nA working code will be very helpful or any suggestion is also helpful.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":62499885,"Users Score":0,"Answer":"You can import the script editing the CSV to the python file and then do some sort of loop that edits the CSV file with your script 1 then does whatever else you want to do with script 2.\nThis is an advantage of OOP, makes these sorts of tasks very easy as you have functions set in a module python file and can create a main python file and run a bunch of functions editing CSV files this way.","Q_Score":0,"Tags":"python-3.x","A_Id":62500465,"CreationDate":"2020-06-21T14:24:00.000","Title":"Sending Information from one Python file 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":0,"Web Development":0},{"Question":"im new to python and i was trying to install \"time\" library on python, i typed\npip install time\nbut the compiler said this\nC:\\Users\\Giuseppe\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Python 3.6>pip install time ERROR: Could not find a version that satisfies the requirement time (from versions: none) ERROR: No matching distribution found for time\ni dont know how to resolve, can anyone help me? please be the more simple u can cause im not too good in py, as i said im new, thx to everyone!\nP.S.\nthe py version is 3.6\nthx everyone, im stupid xd","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1577,"Q_Id":62500265,"Users Score":1,"Answer":"Time is a module that comes built-in with python so no need to install anything, just import it :\nimport time","Q_Score":0,"Tags":"python,python-3.6","A_Id":62500304,"CreationDate":"2020-06-21T14:56:00.000","Title":"I'm trying to figure out how to install this lib on python (time)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"im just trying to use an vpn extension with selenium. I have the extension running , but i need to click in the button and enable the vpn so it can works, there's a way to do that with selenium? im thinking to use another similar option like scrapy or pyautogui...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":86,"Q_Id":62500391,"Users Score":0,"Answer":"No there is no way to enable the VPN on your extension\nIf you want to use your VPN extension you have to set a profile (otherwise selenium will create a new profile without installed extension)","Q_Score":0,"Tags":"python,selenium,google-chrome","A_Id":62502290,"CreationDate":"2020-06-21T15:07:00.000","Title":"how can i use an chrome extension in my selenium python program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Long story short, I messed with my Python environment too much (moving files around, creating new folders, trying to reinstall packages, deleting files etc.) My google package doesn't work anymore. Everytime I try to import the package, it says it can't find the module, even though I did a pip install.\nI was wondering how I could do a hard reset\/delete python off my computer and reinstall it.\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":99,"Q_Id":62500424,"Users Score":0,"Answer":"I figured it out. My pip was installing to a site packages folder inside a local folder, while my jupyter notebook was trying to pull from the anaconda site packages folder.","Q_Score":0,"Tags":"python-3.x","A_Id":62544827,"CreationDate":"2020-06-21T15:10:00.000","Title":"I have completely messed up my Python Env and need help to start fresh","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So far I wasn't aware that I should be creating a new venv for each project and so, I installed every package I needed globally.\nNow when I want to start using python -m venv env, my program runs fine, even though I have installed no packages at all.\nI assume it uses global packages, because when I do pip freeze I get no packages listed.\nI'm trying to create a requirements.txt file that'll list only the packages I need for this project, but it's empty, and my code runs fine!\nThe include-system-site-packages = false is also set in the pyvenv.cfg file, I really don't get this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":373,"Q_Id":62501501,"Users Score":0,"Answer":"Solved it. Apparently my app was using a global Flask package, which had access to other global packages.\nI uninstalled global Flask package, which forced my app to use the env Flask, along with other env packages.\nNow requirements.txt gets rendered properly.","Q_Score":0,"Tags":"python,package,python-venv,requirements.txt","A_Id":62502561,"CreationDate":"2020-06-21T16:38:00.000","Title":"New python venv is using global packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know passing iterable as an argument to iter() method returns an iterator. So why can't iterable be always an iterator. What is the purpose of having an iterable object if doesn't have __next__ method?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":281,"Q_Id":62502183,"Users Score":2,"Answer":"Think of iterable as an special talent of an object. It can be iterated over, e.g. when using for loop or using unpacking.\nAn iterator is an object which is responsible for delivering data from something. This means you can have several of these objects all delivering independent data from the same underlying object.","Q_Score":1,"Tags":"python,iterator,iterable","A_Id":62502244,"CreationDate":"2020-06-21T17:35:00.000","Title":"In python what is the purpose of having an iterable and an iterators, two separate objects?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I solve this problem in python.\ngiven a list of integers arr, write a function that returns true if and only if the number of occurrences of each value in the list is unique in python\nSo\na=[1, 2, 2, 3, 3, 3] True\nBecause number of 1s is 1, number of 2s are 2,,,\na=[1, 2, 3, 3] False\nBecause number of 1s is 1, number of 2s is 1","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":62502749,"Users Score":0,"Answer":"The problem is to write a function that returns true if the number of occurrences of each value in the list is unique. So, for example\na=[1, 2, 2, 3, 3, 3]\nTrue\nnumber of 1s is 1, number of 2s are 2,,,\na=[1, 2, 3, 3]\nFalse\nnumber of 1s is 1, number of 2s is 1","Q_Score":0,"Tags":"python,list,function","A_Id":62502911,"CreationDate":"2020-06-21T18:23:00.000","Title":"the number of occurrences of each value in the list is unique","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got the following warning when I was trying to run a ros launch file. I was not installing any packages. Just running a few .py files. So why did python give setuptools related warning. I know about the warning and what to do. I just wanna know if setuptools is being used for any purpose here or did python simply gave that warning:\nYou are running Setup-tools on Python 2, which is no longer\nsupported and\nSETUPTOOLS WILL STOP WORKING\nin a subsequent release (no sooner than 2020-04-20).\nPlease ensure you are installing\nSetuptools using pip 9.x or later or pin to setuptools<45\nin your environment.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":117,"Q_Id":62503636,"Users Score":0,"Answer":"This is expected, as Python 2 is EOL, and so a number of libraries have taken it upon themselves to warn their users about that.\nROS is dependent on many libraries and check their versions. They sometimes give warnings to promote user to upgrade.\nIn this case it's\u00a0setuptools. But you can run into the same thing with others.\nWhen I did on my different system, I didn't received this ?\nIt could be that a version of certain dependencies which start printing these warnings hasn't been installed on the system on which you did not see the error.\nIn any case:\u00a0ROS Noetic\u00a0will no longer support\/require Python 2 -- it'll exclusively depend on Python 3.\nYou will not see those warnings any more then.","Q_Score":0,"Tags":"python,installation,setuptools","A_Id":62505466,"CreationDate":"2020-06-21T19:46:00.000","Title":"Is the setuptools package or setup.py used for anything other than installing? like for finding a module to import in a package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any quicker way to physically transpose a large 2D numpy matrix than array.transpose.copy()? And are there any routines for doing it with efficient memory use?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":312,"Q_Id":62505938,"Users Score":1,"Answer":"Whatever you do will require O(n^2) time and memory. I would assume that .transpose and .copy (written in C) will be the most efficient choice for your application.\nEdit: this assumes you actually need to copy the matrix","Q_Score":1,"Tags":"python,numpy,matrix,linear-algebra,transpose","A_Id":62505960,"CreationDate":"2020-06-22T00:41:00.000","Title":"Physically transposing a large non-square numpy matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This post is part of the Color Meaning Blog Series, detailing the meanings associated with colors such as red, orange, yellow, green, blue, purple, grey, black, white, brown, pink, turquoise, gold, silver, and beige.\nYellow, the color of sunshine, hope, and happiness, has conflicting associations. On one hand yellow stands for freshness, happiness, positivity, clarity, energy, optimism, enlightenment, remembrance, intellect, honor, loyalty, and joy, but on the other, it represents cowardice and deceit. A dull or dingy yellow may represent caution, sickness, and jealousy.\nStudies show that the meaning of the color yellow can be warmth, cheerfulness, increased mental activity, increased muscle energy. The color yellow helps activate the memory, encourage communication, enhance vision, build confidence, and stimulate the nervous system.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":31,"Q_Id":62506119,"Users Score":2,"Answer":"i am no python programmer but just looking at your collide function\nassuming that your colliding base on distance between 2 points on a 2D plane\nafter getting the distance, you did a (distance mod the sqrt of 2).\na mod get your the remainder of a division, to be exactly 0 means that your number will be a multiple of sqrt2, and since in computer science a floating point 0 is almost impossible to get due to how floating points values is stored.\nand after your check whether formula is getting your 0 OR an negative number. since sqrt will never get a negative value from your distance formula for your collide to be true it has to be 0.\nsuggestion for change, after getting the distance,\nDo a check whether it falls within a RANGE with each, if it is true, else false.\ngoogle: circle to point collision, my syntax maybe wrong as i am a primarily c programmer\n,hope it helps","Q_Score":1,"Tags":"python,python-3.x","A_Id":62506270,"CreationDate":"2020-06-22T01:09:00.000","Title":"Why is my collision not working in pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wonder if there is any example or suggested solution to use BeautifulSoup to scrape the data on a site that could be accessed by clicking on a hyperlink on the main webpage.\nThank you so much!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":62507917,"Users Score":0,"Answer":"Sure. Can you inspect element to get the link and then scrape it? That could also be done programmatically.","Q_Score":0,"Tags":"python,web-scraping,beautifulsoup,hyperlink,jupyter-notebook","A_Id":62507932,"CreationDate":"2020-06-22T05:22:00.000","Title":"Scrape data from new site by following link","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to flask. I am developing a web application using flask and postgres. I have already designed database. I know sqlalchemy is orm. Do I still need to use sqlalchemy in flask if my database was already designed without sqlalchemy. I have to use that database for fetching and updating values. While going further will sqlalchemy is useful to me? or can I simply use db connector and proceed?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":658,"Q_Id":62509725,"Users Score":1,"Answer":"Using sqlalchemy will help you fetching\/inserting data very easy, no matter you designed your db manually, you just need to define your design and then instead of writing multiple lines, you write a line and everything done.\nIt also help you handle errors and a lot more.\nStrongly suggest you to use it.","Q_Score":1,"Tags":"python,postgresql,flask,sqlalchemy","A_Id":62509888,"CreationDate":"2020-06-22T07:50:00.000","Title":"Do I need to use sqlalchemy if my database was already designed manually?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to integrate allure report with python, so i have a single python class(Unit test)\nwhich contains three methods setup, test, tearDown\nIn test method i read a excel file[loop through it] and verify some content\nbut in allure report only 1 test is displayed, Is there any way to mark this looping method as a individual test case, so that in allure reported multiple test cases should be displayed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":62509767,"Users Score":0,"Answer":"A testcase is a function.\nSo you could turn to pytest.mark.parametrize.","Q_Score":2,"Tags":"python,python-3.x,allure","A_Id":68568522,"CreationDate":"2020-06-22T07:52:00.000","Title":"How to create multiple test case in Allure report 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 resolve a Linear Regression problem using TensorFlow & I came across this RuntimeError\n\"loss passed to Optimizer.compute_gradients should be a function when eager execution is enabled.\"\nafter execution of 'train = optimizer.minimize(loss)' in the below code :\na = tf.Variable(20.0)\nb = tf.Variable(30.2)\ny = a * train_x + b\nloss = tf.reduce_mean(tf.square(y - train_y))\noptimizer = tf.compat.v1.train.GradientDescentOptimizer(0.05)\ntrain = optimizer.minimize(loss)\nwhere train_x, train_y --> a set of array values from a column of data frame","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":500,"Q_Id":62510960,"Users Score":0,"Answer":"When eager execution is enabled, loss should be a Python function that takes no arguments and computes the value to be minimized.","Q_Score":0,"Tags":"python,tensorflow,linear-regression","A_Id":62510998,"CreationDate":"2020-06-22T09:09:00.000","Title":"`loss` passed to Optimizer.compute_gradients should be a function when eager execution is enabled. --> optimizer.minimize()","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have got three functions and i would like a button to call it.Is it possible to make a button do function 1 while it is clicked once...perform function 2 while the button is clicked twice and third function on third time when the button is clicked\nUSING python 3.7 and kivy 1.11","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":62511965,"Users Score":0,"Answer":"You can use on_touch_down function and create your own counter for these actions.Start after first touch_down to count clicks and record time together.\nFor an example,kivy supports on_double_tap function. But for thrice i think its only way to do it.You need to set mini click-wait second for keep counting these variables.If user don't click in time or click thrice , you have to set variables to '0'.","Q_Score":0,"Tags":"python,button,onclick,kivy","A_Id":62540168,"CreationDate":"2020-06-22T10:06:00.000","Title":"on click once..on click twice ,on click thrice are there any predefined functions in kivy which can do this","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to define whether pip uses TCP or UDP to make connections? Currently I observe that traffic is blocked by my firewall because only TCP is allowed but pip tries to use UDP.\nI am using pip inside of conda from the Windows Command Prompt.\nAny help would be much appreciated!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":120,"Q_Id":62512827,"Users Score":1,"Answer":"Pip always uses TCP, as http \/ https via UDP does not exist.\nTry to post the exact error message and the exact command that you type, that causes this error.\nThe cause must be something else, than you assume (perhaps a DNS setup issue, perhaps the need for an http proxy, ...)","Q_Score":0,"Tags":"python,pip","A_Id":62513415,"CreationDate":"2020-06-22T10:55:00.000","Title":"Installing Python Packages (pip) via TCP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making an app that collects such as time spent on application etc., and stores it in a folder, to make it neat I want create directories automatically with the date as the name of the directory and save file on that day to it.\nHow can I create folders daily automatically having name as the date","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":251,"Q_Id":62513534,"Users Score":0,"Answer":"You can use the os module to make a folder. And to make a folder everyday you can make a while loop and you can use the time module for it.\nAnd you can name it by saying -\ndate.today()\ninside the argument of the makedirs method\nHope it helped a bit :)","Q_Score":0,"Tags":"python,datetime,automation,directory","A_Id":62513634,"CreationDate":"2020-06-22T11:38:00.000","Title":"Create a folder automatically daily using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm making an app that collects such as time spent on application etc., and stores it in a folder, to make it neat I want create directories automatically with the date as the name of the directory and save file on that day to it.\nHow can I create folders daily automatically having name as the date","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":251,"Q_Id":62513534,"Users Score":2,"Answer":"Don't bother creating folders on certain times, just check if the required folder exists when you want to write the file into it. If it doesn't, create it right then and there.\nFormat the current date into the name of the folder.","Q_Score":0,"Tags":"python,datetime,automation,directory","A_Id":62514259,"CreationDate":"2020-06-22T11:38:00.000","Title":"Create a folder automatically daily using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I set up a systemctl service (Jupyter) as part of a bootstrap for a Hadoop cluster. After bootstrap actions are completed, Hadoop is installed. During that step a number of environment variables are set - and these are vital for my service, Jupyter. Problem is, Jupyter does not know these environment variables, as it is started earlier in the process.\nMy question: how can I reload environment variables for my user? At the moment the user is running Jupyter, all env variables are known - I just need them loaded into the Python interpreter.\nThis fails inside notebook: os.environ['JAVA_HOME'] but works fine in the interpreter (because JAVA_HOME was defined after Jupyter was started).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3718,"Q_Id":62514598,"Users Score":1,"Answer":"Environment variables are local to a process when it starts and inherited from the parent process I think you are not going to be able to set them from outside that process. You can set them in that process but you would need to establish some way to pass them in. (example put in file and have something on a thread periodically read and set them local to that process)","Q_Score":3,"Tags":"python,linux,jupyter-notebook","A_Id":62520726,"CreationDate":"2020-06-22T12:35:00.000","Title":"How to reload environment variables in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have two sequences (x_t, y_t) in time and would like to perform a perform rolling linear regression. The problem in my mind is that:\n\nGiven a window size w, compute y the time t based on the linear combination of x within time window (t-w,...,t,...t+w). That is, y_t = sum_{i=t-w}^{t+w} b_i x_{i} + b_0,\n\nSo I would like to fit the constants b_i using my data.\n\nIs statsmodels.regression.rolling.RollingOLS the correct package to do that?\nThe problem is that it only gives me the predict values and parameters along the same time axis, i.e., y_hat_i and b_i for each t. Instead, I would like to have a small set of b that I can use it for x data at other time t.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":553,"Q_Id":62520659,"Users Score":0,"Answer":"Yes, it is the right package. However, the regression coefficients will vary a lot, however you can smooth them by taking moving averages (of the coefficients), and then sampling from the moving averages.","Q_Score":1,"Tags":"python,time-series,regression,statsmodels,rolling-computation","A_Id":62521177,"CreationDate":"2020-06-22T17:59:00.000","Title":"How to make predictions from the rolling regression module in statsmodel?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using a for loop in python on Jupyter Notebook to turn a .png image into an array and add regions. When I have 5 arrays in the output, I can't figure out how to save them to a specific folder on my computer.\nI seriously have no clue what command I need to use to save them there, or where to find such a command. The only answers I can find online are specific to saving outputs to a .txt file, which is not what I need. I need the images in the outputs saved to a folder.\nI'm very new to programming, so forgive my lack of information as I don't know what you all need to know to help me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":411,"Q_Id":62522302,"Users Score":1,"Answer":"Everywhere I looked had options for \"save as text file\" or some variation, and finally I found a single, one-line command to save the outputs into a folder that I could specify.\nI used the cv2.imwrite() command:\ncv2.imwrite(output_dir, final_img.astype(np.uint8))\nwhere output_dir was defined as the folder-path I made for them to be saved to and final_img was the name of the variable given to the arrays after I had completed manipulating them. The last part (astype(np.uint8)) was to save it as an 8-bit image.\nHope this helps anyone else with this problem.","Q_Score":1,"Tags":"python,arrays,directory,jupyter-notebook","A_Id":62645731,"CreationDate":"2020-06-22T19:43:00.000","Title":"How can I save my output image arrays into a specific folder on my computer from my python code in JupyterLab workbook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I often delete code in Colab, by accident, and for some reason when I try to do undo code deletion it does not work. So basically when I do this I want to get my cells back somehow. Is there any way to do this, like take a look at the code that Colab is running, because my cells are probably still there. Another option would be to somehow see cells that have been previously deleted. Please help me. Any other solutions would be nice.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1853,"Q_Id":62522472,"Users Score":1,"Answer":"You can undo deleting cell in google colab simply by typing ctrl + M Z","Q_Score":2,"Tags":"ipython,google-colaboratory","A_Id":68068087,"CreationDate":"2020-06-22T19:54:00.000","Title":"Gettinng back cells after being deleted in Colab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a string where I am trying to replace [\"{\\\" with [{\" and all \\\" with \".\nI am struggling to find the right syntax in order to do this, does anyone have a solid understanding of how to do this?\nI am working with JSON, and I am inserting a string into the JSON properties. This caused it to put a single quotes around my inserted data from my variable, and I need those single quotes gone. I tried to do json.dumps() on the data and do a string replace, but it does not work.\nAny help is appreciated. Thank you.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":160,"Q_Id":62523838,"Users Score":0,"Answer":"if its two characters you want to replace then you have to first check for first character and then the second(which should be present just after the first one and so on) and shift(shorten the whole array by 3 elements in first case whenever the condition is satisfied and in the second case delete \\ from the array.\nYou can also find particular substring by using inbuilt function and replace it  by using replace() function to insert the string you want in its place","Q_Score":0,"Tags":"python,string","A_Id":62524040,"CreationDate":"2020-06-22T21:33:00.000","Title":"Replace string with quotes, brackets, braces, and slashes in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a string where I am trying to replace [\"{\\\" with [{\" and all \\\" with \".\nI am struggling to find the right syntax in order to do this, does anyone have a solid understanding of how to do this?\nI am working with JSON, and I am inserting a string into the JSON properties. This caused it to put a single quotes around my inserted data from my variable, and I need those single quotes gone. I tried to do json.dumps() on the data and do a string replace, but it does not work.\nAny help is appreciated. Thank you.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":160,"Q_Id":62523838,"Users Score":0,"Answer":"I would recommend maybe posting more of your code below so we can suggest a better answer. Just based on the information you have provided, I would say that what you are looking for are escape characters. I may be able to help more once you provide us with more info!","Q_Score":0,"Tags":"python,string","A_Id":62523899,"CreationDate":"2020-06-22T21:33:00.000","Title":"Replace string with quotes, brackets, braces, and slashes in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is do i have to install django every single time in my virtual environment in order to run my python files? and is this taking up bunch of space on my machine? My project also uses \"matplotlib\" and every virtual environment i create it also asks me to import the matplotlib module too. its getting annoying. do i have to do this every time?\nIm new to Django. I wanted to run some python files in django but they weren't working, so after some research i found out i needed to run my pycharm project in a virtual environment in order to run these python files.\nmy folders look like this pycharmProjects -> my project\nI enter pycharmProjects and I set up virtual environment using \"pienv shell\". Then i run \"python3 manage.py runserver\". It turns out i must install django in the virtual environment before the files run.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":146,"Q_Id":62524773,"Users Score":1,"Answer":"Short answer yes.\nIf you create a virualenv you have to install all packages, that your program needs.\nLong answer:\nYou could install django system wide and then create a virtualenv with the option\n--system-site-packages then django would be used from your globally installed python.\n(Or you install everything just in your global python, put I personally don't think this is good practice)\nIf you work with many different projects I think you will avoid a lot of trouble if you use one virtualenv per project.\nTrouble meaning that  one project breaks, because one pip install for another project changed the version of one package and one project can't handle the newer version.\nI would recommend to create a requirements.txt file for each project, that lists the dependencies then you can create the virtualenv with following command\npip install -r requirements.txt\nif you have requirement.txt files, then you can create virtualenvs rather quickly if going back to an old project and you can delete the virtualenvs whenever you run out of disk space. If you want to be an the safe side, type pip freeze > pipfreeze.txt prior to deleting the virtualenv and use pip install -r pipfreeze.txt if you want to create one with the same modules and the same versions.\nYou also might want to look at direnv or autoenv if working on a linux like system.\nThis will automatically switch to the required virtualenv when changing to a project's working directory.","Q_Score":0,"Tags":"python,django","A_Id":62525282,"CreationDate":"2020-06-22T22:56:00.000","Title":"Installing Django and modules in virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"My question is do i have to install django every single time in my virtual environment in order to run my python files? and is this taking up bunch of space on my machine? My project also uses \"matplotlib\" and every virtual environment i create it also asks me to import the matplotlib module too. its getting annoying. do i have to do this every time?\nIm new to Django. I wanted to run some python files in django but they weren't working, so after some research i found out i needed to run my pycharm project in a virtual environment in order to run these python files.\nmy folders look like this pycharmProjects -> my project\nI enter pycharmProjects and I set up virtual environment using \"pienv shell\". Then i run \"python3 manage.py runserver\". It turns out i must install django in the virtual environment before the files run.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":146,"Q_Id":62524773,"Users Score":2,"Answer":"Short answer is no, you don't have to use a virtual environment at all and can install your dependancies globally instead. However you will soon find that it will cause a lot of issues. The main reason you would create a virtual environment is to give control of your dependancies and prevent bugs that could be caused because of them having their wires crossed between projects.","Q_Score":0,"Tags":"python,django","A_Id":62524987,"CreationDate":"2020-06-22T22:56:00.000","Title":"Installing Django and modules in virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there a tool that can visualize (such as tree view) all python functions and classes in a program and which function calls other functions? Trying to find dependencies of some real messy code.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":62526432,"Users Score":2,"Answer":"Yes, there is. It is called pycallgraph.","Q_Score":3,"Tags":"python,python-3.x","A_Id":62526566,"CreationDate":"2020-06-23T02:36:00.000","Title":"Is there a tool for python that can visualize methods and classes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a locustfile, which is for generating load for a certain target website.\nIn my case i need to crate 1800 rps. but i am not able to generate that much in the single locustfile.\nSo i have created 4 locust file and generate 450 rps for each. but the rps not give as my expectation. It was dropped and became as very low.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":195,"Q_Id":62527624,"Users Score":0,"Answer":"You can run the same locustfile as master\/worker setup where you start a worker for each core you have on your machine.","Q_Score":0,"Tags":"python,load-testing,locust","A_Id":62528576,"CreationDate":"2020-06-23T04:59:00.000","Title":"How do i generate 1800 rps in locust, from one locustfile?","Data Science and Machine Learning":0,"Database and SQL":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 looking for the best solution for Python to autopost to instagram from a database of images. I have already made a script using instabot that does this but cant figure out how to post a carousel of images, instead of just one.\nI am wondering what the current best solution for Python Instagram coding is as there is quite a lot of outdated information floating around the web...","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":307,"Q_Id":62529675,"Users Score":1,"Answer":"You Can Use A Combination Of Selenium and PyAutoGUI And It Will Be Really Easy! :D\nHope It Helps,\nYash","Q_Score":1,"Tags":"python,instagram","A_Id":62529791,"CreationDate":"2020-06-23T07:39:00.000","Title":"Automatic Instagram Posting 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":1},{"Question":"In order to use the gensim.similarities.docsim.Similarity class to compute similarities between words, one need to provide the corpus and the size of the dictionary.\nIn my case, the corpus are the word vectors computed using a word2vec model.\nI wonder why gensim needs the size of the dictionary? And also, if it needs here the size of the dictionary used to create the word2vec model, or the size of the dictionary of the corpus, for which I want to compute the similarities.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":41,"Q_Id":62529967,"Users Score":1,"Answer":"Note that you don't need to use gensim.similarities.docsim.Similarity to calculate word-to-word similarities.\nThere are individual methods on the word-vector supporting objects for doing things like calculating similarity between 2 words (model.similarity(wordA, wordB)) or getting the list of most-similar 'neighbor' words (model.most_similar(target_word)).","Q_Score":0,"Tags":"python,nlp,gensim","A_Id":62540245,"CreationDate":"2020-06-23T07:55:00.000","Title":"Why computing similarity with gensim needs the size of the dictionary?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have been wracking my brain trying to figure this out for like 2 hours. As I understood it, when I define a module with functions, and move to a new file, I can import that module. Then to call a function from that module I can do something like module_name.function_name(inputs). Note that there is only one period!\nSo, there is a module called itertools. When I import itertools, I can call itertools.chain(list or list of lists) and it will create an iterator object for me. HOWEVER, now this is the part I don't get, I can ALSO call itertools.chain.from_iterable and it will ALSO create a different iterator object for me. I dont get how this is possible? How can itertools.chain and itertools.chain.from_iterable both be functions that return something, and how would I go about creating a module like that?\nHow can there be 2 periods in 1 function call when the stuff before the first period isnt a class?\n(I can also import classes from a module and then call methods defined within the class using Class_name.method_name(inputs). however I'm pretty sure chain is a function and not a class because it returns an output!!)","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":62530247,"Users Score":0,"Answer":"itertools.chain.from_iterable isn't a normal method, its a classmethod.\nWhen classmethod is called, it gets the class as the first argument instead of the instance of that class (as we normally do with methods). This means we can use the class and its properties inside that method rather than a particular instance. Class methods are useful when you need to have methods that aren\u2019t specific to any particular instance.","Q_Score":1,"Tags":"python,python-3.x,module,itertools","A_Id":62530518,"CreationDate":"2020-06-23T08:10:00.000","Title":"Question about python module and calling a function from it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to set the 'min_frequency' in tf.keras.preprocessing.text.tokenizer, just like the 'min_frequency' in tf.contrib.learn.preprocessing.VocabularyProcessor?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":62530401,"Users Score":0,"Answer":"The num_words actually helps in doing the same thing, here num_words will take the top num_words words with the highest frequency.\nSo, the functionality you got from min_frequency in tf.contrib.learn.preprocessing.VocabularyProcessor you can get the same but not in the same way though.","Q_Score":0,"Tags":"python-2.7,tensorflow","A_Id":62532368,"CreationDate":"2020-06-23T08:20:00.000","Title":"How to set the min_frequency while using tf.keras.preprocessing.text.tokenizer and ignore the words which are less then min_frequency?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe with one of the column as timedelta64 dtype. The values appear to be fine in IDE but when I export the dataframe to excel using ExcelWriter and to_excel(), the values in the Excel are all 0. (It's actually not 0 but a very small floating points.)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":62530983,"Users Score":0,"Answer":"If you export the values to an .xls file do you get the same issue? XLS is a binary file format, not a collection of XML files. This should allow you to check whether this is a file format issue or not.","Q_Score":0,"Tags":"python,pandas","A_Id":62531156,"CreationDate":"2020-06-23T08:57:00.000","Title":"Python - Why does timedelta64 values appear as 0 in excel","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a newbie to python. I have just installed Python and Pip.\nI need to install some packages for a personal project.\nI created a virtual environment using $ pipenv shell.\nI then ran $ pipenv install dlib.\nBut I received the following error:\nError text:\nPython path configuration:\n  PYTHONHOME = (not set)\n  PYTHONPATH = (not set)\n  program name = 'C:\\Users\\samya\\.virtualenvs\\py_img_recog-DAsXOW1h\\Scripts\\python.exe'\n  isolated = 0\n  environment = 1\n  user site = 1\n  import site = 1\n  sys._base_executable = 'C:\\\\Users\\\\samya\\\\.virtualenvs\\\\py_img_recog-DAsXOW1h\\\\Scripts\\\\python.exe'\n  sys.base_prefix = ''\n  sys.base_exec_prefix = ''\n  sys.executable = 'C:\\\\Users\\\\samya\\\\.virtualenvs\\\\py_img_recog-DAsXOW1h\\\\Scripts\\\\python.exe'\n  sys.prefix = ''\n  sys.exec_prefix = ''\n  sys.path = [\n    'C:\\\\Users\\\\samya\\\\.virtualenvs\\\\py_img_recog-DAsXOW1h\\\\Scripts\\\\python38.zip',\n    '.\\\\DLLs',\n    '.\\\\lib',\n    'c:\\\\users\\\\samya\\\\appdata\\\\local\\\\programs\\\\python\\\\python38-32',\n  ]\nFatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding\nPython runtime state: core initialized\nModuleNotFoundError: No module named 'encodings'\n\nCurrent thread 0x000042ec (most recent call first):\n<no Python frame>\n[   =] Installing dlib...\nInstallation Failed \n\nI am running Python 3.8.3 and Pip 20.1.1 on Windows 10 x64 bit system.\nThanks for your help in advance!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1994,"Q_Id":62532922,"Users Score":0,"Answer":"this means your pip command path is not set in the path variables of system\nYou can try doing the following:\n\ngo to This Pc>properties>Advanced Settings>environment variables\n\n..then click new\n\n..then select the path where your python pip command is available\n\n.. and simply give it a name python38 thats it\n\nthen it will create your venv","Q_Score":0,"Tags":"python,python-3.x,pip","A_Id":62533132,"CreationDate":"2020-06-23T10:43:00.000","Title":"pipenv can't install packages and throws an error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've seen similar questions but it's shocking that I didn't see the answer I was, in fact, looking for. So here they are, both the question and the answer:\nQ:\nHow to calculate simply the percentage in Python.\nSay you need a tax calculator. To put it very simple, the tax is 18% of earnings.\nSo how much tax do I have to pay if I earn, say, 18 342? The answer in math is that you divide by 100 and multiply the result by 18 (or  multiply with 18 divided by 100). But how do you put that  in code?\ntax = earnings \/ 100 * 18\nWould that be quite right?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":366,"Q_Id":62538415,"Users Score":0,"Answer":"The answer that best fitted me, especially as it implied no import, was this:\ntax = earnings * 0.18\nso if I earned 18 342, and the tax was 18%, I should write:\ntax = 18 342 * 0.18\nwhich would result in 3 301.56\nThis seems trivial, I know, and probably some code was expected, moreover this form might be applicable not only in Python, but again, I didn't see the answer anywhere and I thought that it is, after all, the simplest.","Q_Score":0,"Tags":"python,percentage","A_Id":62538416,"CreationDate":"2020-06-23T15:32:00.000","Title":"How to calculate percentage in Python with very simple formula","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using AzureML with pretty complex workflows involving large datasets etc. and I'm wondering what is the best way to manage the splitting resulting of preprocessing steps. All my projects are built as pipelines fed by registered Datasets. I want to be able to track the splitting in order to easily retrieve, for example, test and validation sets for integration testing purposes.\nWhat would be the best pattern to apply there ? Registering every intermediate set as different Dataset ? Directly retrieving the intermediate sets using the Run IDs ? ...\nThaanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":149,"Q_Id":62538688,"Users Score":1,"Answer":"Registration is to make sharing and reuse easier so that you can retrieve the dataset by its name. If you do expect to reuse the test\/validation sets in other experiments, then registering them make sense. However, if you are just trying to keep records of what you used for this particular experiment, you can always find those info via Run as you suggested.","Q_Score":2,"Tags":"python,azure,azure-machine-learning-service,azureml","A_Id":62539738,"CreationDate":"2020-06-23T15:46:00.000","Title":"Best way to manage train\/test\/val splits on AzureML","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to install numpy, nltk, etc packages for Python 2 to run a code. But I have Python3 as well and the path variable is set to it. When I try to use any pip install command it shows the package is available in Python3's directory.\nAlso, I am using VSCode, so I did not add the path variable.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":293,"Q_Id":62539010,"Users Score":0,"Answer":"After crating a virtual environment with python 2.7 you can install your required packages","Q_Score":0,"Tags":"python,python-3.x,python-2.7,installation","A_Id":62539129,"CreationDate":"2020-06-23T16:04:00.000","Title":"install packages in Python2 with Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to find out there is a p4 command that can find cl submitted in a depot branch from a cl submitted in another depot branch.\nlike -\nif CL 123 was submitted to branch \/\/code\/v1.0\/files\/...\nand same code changes were also submitted to another branch \/\/code\/v5.0\/files\/...\ncan i find out cl in 2nd branch from cl 123?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":745,"Q_Id":62540591,"Users Score":2,"Answer":"There are a few different methods; which one is easiest will depend on the exact context\/requirements of what you're doing.\nIf you're interested in the specific lines of code rather than the metadata, p4 annotate is the best way.  Use p4 describe 123 to see the lines of code changed in 123, and then p4 annotate -c v5.0\/(file) to locate the same lines of code in v5.0 and see which changelist(s) introduced them into that branch.  This method will work even if the changes were copied over manually instead of using Perforce's merge commands.\nIf you want to track the integration history (i.e. the metadata) rather than the exact lines of code (which may have been edited in the course of being merged between codelines, making the annotate method not work), the easiest method is to use the Revision Graph tool in P4V, which lets you visually inspect a file's branching history; you can select the revision from change 123 and use the \"highlight ancestors and descendants\" tool to see which revisions\/changelists it is connected to in other codelines.  This makes it easy to see the context of how many integration steps were involved, who did them, when they happened, whether there were edits in between, etc.\nIf you want to use the metadata but you're trying for a more automated solution, changes -i is a good tool.  This will show you which changelists are included in another changelist via integration, so you can do p4 changes -i @123,123 to see the list of all the changes that contributed to change 123.  On the other side (finding changelists in v5.0 that 123 contributed to), you could do this iteratively; run p4 changes -i @N,N for each changelist N in the v5.0 codeline, and see which of them include 123 in the output (it may be more than one).","Q_Score":0,"Tags":"python-3.x,perforce,changelist,p4python,perforce-integrate","A_Id":62540734,"CreationDate":"2020-06-23T17:34:00.000","Title":"In P4, how do i check if a change submitted to one branch is also submitted to another branch using 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":0,"Web Development":0},{"Question":"I'm implementing python an application to capture change on DocumentDB using Change Stream feature my design is watching change on all collections in the target database and publish to some message queue to do some processing.\nMy question is currently DocumentDB support MongoDB API version 3.6 which not support watch change on DB level. Is there a way to watch the change stream on the DB level on the current DocumentDB version.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":334,"Q_Id":62542385,"Users Score":2,"Answer":"You can enable change streams at the collection, database, and cluster level.\nHowever, at the moment to seek for the changes it happens at the collection level.\nYou need to setup your code to seek for changes in every collection that is being watched.","Q_Score":0,"Tags":"java,python,mongodb,aws-documentdb,changestream","A_Id":62543244,"CreationDate":"2020-06-23T19:29:00.000","Title":"Using DocumentDB change stream on multiple collections?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"im totally lost right now.\nI have a binomical function of a stock option. I have to plot the\nfunction for a given amount of times. I tried to plot it wi\nbh the help of a loop, but without success.\nAnyone got an idea how  to solve this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":62543722,"Users Score":0,"Answer":"I'm assuming you put the plt.show() inside the loop. This won't work, as it will only plot the plots of the first iteration.\nTry putting the plt.show() in the very bottom of your code.","Q_Score":1,"Tags":"python,loops,plot,options,stock","A_Id":62543788,"CreationDate":"2020-06-23T21:04:00.000","Title":"Plotting a graph of a function for n amount of times","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run all cells in Jupyter notebook with python.\nThere are 2 ways to do so: (1) click on \"cell\" then \"run all\". or (2) create a keyboard shortcut: \"Ctrl-E\" (or anything else). But both (1) and (2) don't work.\nIt looks line the cells are running because in the [] there is a [*] for a split second, so it is trying to run but doesn't run. there are no errors, it just doesn't run.\nWhen I run one cell at a time, it works but I obviously don't want to do that.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":62544213,"Users Score":0,"Answer":"I was facing the same problem. I think after hitting the run all cell or Ctrl-E, if any cell code have an error then jupyter notebook will not run below cell. So solving the error or markdown the cell can solve the issue.","Q_Score":0,"Tags":"python,jupyter-notebook,jupyter","A_Id":71333091,"CreationDate":"2020-06-23T21:41:00.000","Title":"I created the command Ctrl-E to run all cells in Jupyter notebook, but it doesn't work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a django project and I want to divide up my python code into separate files. At the moment I am running my functions from views.py. In my views.py I have a plot function. I have taken this plotting code and I have created python file called plotting.py which has this plot function in it. this plotting file lives in the same folder as my views.py\nMy problem is accessing this plotting.py file. I am trying to access it through from the urls.py by path('plot', plotting.plot),. it is not working. Or do I have to link back to a function in views.pyand from tat function go toplotting.py`?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":152,"Q_Id":62544466,"Users Score":1,"Answer":"Is this plot function a view where you are returning a response to the client or is this a helper function that you are trying to call from within a view? If it isn't a view, I would recommend adding from .plotting import plot to the top of your views.py file","Q_Score":0,"Tags":"python,python-3.x,django","A_Id":62544530,"CreationDate":"2020-06-23T22:06:00.000","Title":"Running a python file other than views.py in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am running a django project and I want to divide up my python code into separate files. At the moment I am running my functions from views.py. In my views.py I have a plot function. I have taken this plotting code and I have created python file called plotting.py which has this plot function in it. this plotting file lives in the same folder as my views.py\nMy problem is accessing this plotting.py file. I am trying to access it through from the urls.py by path('plot', plotting.plot),. it is not working. Or do I have to link back to a function in views.pyand from tat function go toplotting.py`?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":152,"Q_Id":62544466,"Users Score":0,"Answer":"should you not do from plotting.py import plot and then you can use plot in views.py?","Q_Score":0,"Tags":"python,python-3.x,django","A_Id":62544505,"CreationDate":"2020-06-23T22:06:00.000","Title":"Running a python file other than views.py in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My trial licence for xlwings PRO expired and now I get a license validation error.I tried reinstalling xlwings to no avail: it still installed PRO version and is asking for valid license. Conda installation here, Python 3.7.\nAny ideas?\nI cannot find any info in documentation.\nThanks!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":232,"Q_Id":62544555,"Users Score":1,"Answer":"Try to upgrade to the latest version - there was a bug with 0.19.0. A simple conda upgrade xlwings will fix this.","Q_Score":1,"Tags":"python-3.x,conda,xlwings","A_Id":62555164,"CreationDate":"2020-06-23T22:15:00.000","Title":"Downgrade xlWings PRO","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"My trial licence for xlwings PRO expired and now I get a license validation error.I tried reinstalling xlwings to no avail: it still installed PRO version and is asking for valid license. Conda installation here, Python 3.7.\nAny ideas?\nI cannot find any info in documentation.\nThanks!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":232,"Q_Id":62544555,"Users Score":1,"Answer":"I got it work with the awesomely quick help from xlwings themselves!\nWhen I was trying PRO version I added python code to excel sheets with .py ending and that was triggering to use .pro version of xlwings and therefore asking for license. I just needed to delete those sheets with python code.\nMaybe this will be useful for someone else...","Q_Score":1,"Tags":"python-3.x,conda,xlwings","A_Id":62556585,"CreationDate":"2020-06-23T22:15:00.000","Title":"Downgrade xlWings PRO","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've developed a game in python using Pygame. So far bundling it using pyinstaller has caused me zero issues when bundling it and running it on a different machine. Steam can install the game, and navigating to its local directory and launching the .exe will allow the game to run but anytime I attempt to run it through the steam launcher it tells me files are missing, even though I know they're in the local install directory.\nAny ideas on what may be causing such an issue?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":417,"Q_Id":62545080,"Users Score":0,"Answer":"So after taking user Kingsleys advice and using \"os.getcwd()\" to see where exactly Steam was launching the game from I noticed it was treating the directory 1-up from the location of the .exe as the actual working directory. To resolve this problem all I had to do was change my package layout so that my assets were stored in this folder.\nNo longer facing an issues with this.","Q_Score":0,"Tags":"python,pygame,pyinstaller,steam,file-not-found","A_Id":62633430,"CreationDate":"2020-06-23T23:04:00.000","Title":"Developed game in Python - Steam installs and can run locally but the game crashes when launched from Steam directly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am learning how to use Alpha_Vantage api and came across this line of code. I do not understand what is the purpose of [0].\nSATS = ts.get_daily('S58.SI', outputsize = \"full\")[0]","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":107,"Q_Id":62546248,"Users Score":0,"Answer":"ts.get_daily() appears to return an array.\nSATS is getting the 0 index of the array (first item in the array)","Q_Score":0,"Tags":"python,alpha-vantage","A_Id":63682164,"CreationDate":"2020-06-24T01:35:00.000","Title":"Alpha_Vantage ts.get_daily ending with [0]","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have three classification models as follows where the labels of my data is 1 or 0.\n\nlstm model with some timeseries data that has one node as the output (i.e. model.add(Dense(1, activation='sigmoid'))) so my output is similar to [0.1, 0.1, 0.6, 0.9, ...]\ntraditional random forest with features set 1 - I am using sklearn's predict_proba: so my output is similar to [[0.9, 0.1], [0.8, 0.2], ...]\ntraditional random forest with features set 2 - I am using sklearn's predict_proba: so my output is similar to [[0.8, 0.2], [0.9, 0.1], ...]\n\nI want to combine the predictions of my three models to get one probability list that reflects my classification. I searched this in SO, however the suggestions like bagging and stacking is not possible for me as I am also using a lstm model in to consideration.\nI am wondering if there is any other way that I can use to combine these prediction probabilities in python.\nI am happy to provide more details if needed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":451,"Q_Id":62547103,"Users Score":3,"Answer":"You can do one of two solutions, but first you need to make the representation of the output the same for the three models so for the second and third models\npred_2 = [y[0] for y in pred_2] to look like the first model. (y[0] or y[1] depending on the meaning of the probabilities in your first model).\nThe first solution is to make a majority voting by computing the average of the three lists\nmajority_voting = [v\/3.0 for v in[sum(x) for x in zip(pred_1, pred_2, pred_3)]]\nThe second solution is a little bit harder as you can use another deep learning model to make it choose the best result between the three models. You need to prepare the data_x as list that has three columns a column for each model output and data_y the same labels for your original data, by doing so you are letting the model to learn how to use the three models to predict the output instead of just majority voting.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,deep-learning,classification","A_Id":62547698,"CreationDate":"2020-06-24T03:24:00.000","Title":"How to combine the classification results of deep learning models and traditional machine learning models in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to use tensorflow with ROS and ROS 1 does only support python 2.7 at the moment.\nIs there a way to install tensorflow 1 or 2 for python 2.7?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":984,"Q_Id":62547864,"Users Score":0,"Answer":"The easiest way of using tensorflow is to download anaconda and then download the packages of anaconda!","Q_Score":0,"Tags":"python-2.7,tensorflow","A_Id":62547884,"CreationDate":"2020-06-24T04:49:00.000","Title":"How to install tensorflow for python 2?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I trained a deep learning-based detection network to detect and locate some objects. I also trained a deep learning-based classification network to classify the color of the detected objects. Now I want to combine these two networks to detect the object and also classify color. I have some problems with combining these two networks and running them together. How do I call classification while running detection?\nThey are in two different frameworks: the classifier is based on the Keras and TensorFlow backend, the detection is based on opencv DNN module.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":62549254,"Users Score":0,"Answer":"I have read your question and from that, I can infer that your classification network takes the input from the output of your first network(object locator). i.e the located object from your first network is passed to the second network which in turn classifies them into different colors. The entire Pipeline you are using seems to be a sequential one. Your best bet is to first supply input to the first network, get its output, apply some trigger to activate the second network, feed the output of the first net into the second net, and lastly get the output of the second net. You can run both of these networks in separate GPUs.\nThe Trigger that calls the second function can be something as simple as cropping the located object in local storage and have a function running that checks for any changes in the file structure(adding a new file). If this function returns true you can grab that cropped object and run the network with this image as input.","Q_Score":0,"Tags":"python,classification,detection,yolo","A_Id":62549592,"CreationDate":"2020-06-24T06:47:00.000","Title":"how do I run two separate deep learning based model together?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"could someone help me with one problem? I want to add a process bar when you waiting for a response from the server (Django 3.x).\nStep to reproduce:\n\nOn the page 'A' we have the form.\nEnter data to form.\nSubmit POST request by clicking to button on the page 'A'.\nWaiting for getting the result on the page 'A'.\nGet the result on the page 'A'.\n\nSo, I want to add process bar after 4th and before 5th points on the page 'A'. When you will get the result on the page 'A' it should disappear.\nPython 3.7\nDjango 3.x","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":412,"Q_Id":62549890,"Users Score":0,"Answer":"You can use nprogress, it's a library used for progress bars. Use this inside the interceptor where you can config it for displaying only when request is in progress until finished.","Q_Score":0,"Tags":"javascript,python-3.x,django","A_Id":62550133,"CreationDate":"2020-06-24T07:29:00.000","Title":"How to add a process bar when you waiting for a response from the server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a problem with a python code executed from Excel using  call from vba xlwing. Problem is that script takes a long time to execute the tasks (but it's normal due to amount of data).\nafter 90 secs excel shows a popup with error: excel is waiting for python complete ole action, and if click ok, after 10 secs message come back again. Is there any way to handle this error and fixed it? python code is running correctly, but it takes a long time to do all tasks.\nthanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":345,"Q_Id":62550707,"Users Score":0,"Answer":"My suggestion: read all data from excel into python, treat it, and create a new excel with the result, or overwrite the existing file. It will be much more smooth.","Q_Score":0,"Tags":"python-3.x,excel,vba,xlwings","A_Id":62550892,"CreationDate":"2020-06-24T08:22:00.000","Title":"vba call from excel to python code returns excel error waiting ole action","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Pytest, and having the following structure of tests :\nClassA.py\n\n\n---------------test_a\n---------------test_b\n---------------test_c\nAnd Also\nClassB.py\n\n\n---------------test_d\n---------------test_e\n---------------test_f\nI'm running my tests via terminal command\n(i.e.: pytest -v -s  ClassA.py)\nMy question:\nIs there a way to run ClassA & ClassB in parallel (2 instances you might say),\nwhile maintaining order on each class - separately?\nMeaning I want all tests from ClassA will run on 1st browser instance, and all tests from ClassB will run on a different instance.\nI'm also familiar with parallel test execution using the 'pytest-xdist' plug-in.\nBut once using it the test cases that are in ClassA and ClassB are executed in the mixed order, so that is not good for me.\nEDITED:\nMy main purpose is to avoid from test_a running on a separate browser instance of test_b.\nI would like the tests on each class to run on the same browser instance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":62551432,"Users Score":0,"Answer":"Yes, it is possible. Mark the test with order using pytest-order plugin and use pytest n 2 --dist loadfile. It will run Class A test in one browser and then initiate ClassB test in 2nd browser. Make sure you are passing the driver instance from conftest with  the scope set to class","Q_Score":1,"Tags":"python,pytest,xdist,pytest-xdist","A_Id":68718438,"CreationDate":"2020-06-24T09:04:00.000","Title":"Using Pytest, I can't find a way to run 2 test classes at once in parallel, while each class has several 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":"The web2py online book in Chapter 3 Overview says that in the scaffolding application, values for response.title, response.meta.author, etc, are set in the file models\/menu.py. While previous versions of Web2py did include the settings in menu.py, in v.2.18.5 the default values are not set in this file. While some of the settings, such as response.meta.author etc are defined in models\/db.py, response.title and response.subtitle could not be found in db.py also. The online book does say that these can be defined in any model file. Can someone advise where these settings are now defined?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":75,"Q_Id":62551646,"Users Score":1,"Answer":"It appears that those items are no longer defined in the scaffolding app. The default layout simply using request.application as the page title if request.title is not defined. Feel free to define those items wherever, or not at all.","Q_Score":0,"Tags":"python,layout,default,web2py","A_Id":62554510,"CreationDate":"2020-06-24T09:17:00.000","Title":"Web2py layout configuration settings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Currently, I am working on a Tkinter GUI. In this GUI, I would like to include an Entry field where users can only enter numbers between two boundaries (for instance, a number between 0.0 and 200.0). I have looked into the validatecommand option, but this still does not provide me a solution. Is there somebody who can help me to create a Tkinter Entry with boundaries?\nThank you in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":188,"Q_Id":62553669,"Users Score":2,"Answer":"You can get the value by .get() method and then write an if statement to generate an error or reset the value by .set() method when limits are exceeded.","Q_Score":0,"Tags":"python,tkinter,boundary","A_Id":62553860,"CreationDate":"2020-06-24T11:08:00.000","Title":"A Tkinter Entry with boundaries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to automate the process of importing XML file data in MS Excel using Python or any other programming language or by any other method which is possible. How can I achieve that?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":240,"Q_Id":62554581,"Users Score":1,"Answer":"The solution to your problem is mentioned in the steps below:\n\nImports required library\nread and parse XML file from the path\nextract the root element\nmake a map after finding the required elements from the root elements\ncreate Excel file from the created map object\nsave that file to the destined path\nclose all the stream if any remain opened.\n\nNow code the above steps in any prefer language python, java, or any other.","Q_Score":2,"Tags":"java,python,xml,automation,xlsx","A_Id":62554832,"CreationDate":"2020-06-24T12:00:00.000","Title":"Importing xml file in MS Excel - How can we automate this flow using Python or any other programming language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that there are 2 methods of multi-threading using QThreads, One is to subclass QThread and override the run() method, other is to create a QObject class and move it's instance to QThread. the latter is said to be a better practice.\nI found out that subclassing QThread does provide a finished method which can be used but when creating a separate QObject as a worker thread, QThread will no longer emit the finished signal. It seems that the QThrean run method creates an event loop which when is re-implemented, returns the function and emits a finished signal. but for in case of a worker class we will need to call a quit() method on the QThread object.\nIs this correct? Does it not make subclassing QThread more flexible to use?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":97,"Q_Id":62555486,"Users Score":2,"Answer":"When the run method is overridden then the logic is implemented there so you can know when it ends, but in the case of moving a QObject to a QThread there is no way to determine when the QObject logic is finished executing.\nAn alternative is to create a finished signal that you emit when you consider that the QObject logic ends.","Q_Score":2,"Tags":"python,multithreading,pyqt,signals,qthread","A_Id":62599324,"CreationDate":"2020-06-24T12:51:00.000","Title":"Why doesn't the QThread object have a finished signal when creating a worker QObject?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"im new with using openpyxl.\nI am trying to get value from cell, however value in that cell is linked from another sheet and value what i get is\n\n*=<nameOfSheet>t!U2:U1000*\n\ninstead of expected value\n\n*1000.2\u20ac*\n\nmy approach method  to value is\nws1.cell(row = i, column = j).value\nthanks for advice","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":78,"Q_Id":62556007,"Users Score":-1,"Answer":"Answer:\nwhile loading file is needed add to parameter data_only\n\nwb1 = xl.load_workbook(filename, data_only=True)\n\nThis solved my problem.","Q_Score":0,"Tags":"python,python-3.x,excel,excel-formula,openpyxl","A_Id":62556891,"CreationDate":"2020-06-24T13:17:00.000","Title":"How to get value from cell which is linked from another sheet, openpyxl","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I\u2019m working on a chat application right now.. let\u2019s say we have User1, User2, User3, ...UserN. I want to generate a unique port number for each pair. Like User1 and User2 will have 5000, User1 and User3 will have 5070, User2 and User3 will have 5500, etc etc.. basically every User should have a different port number for other users.. but both of the Users should have the same one for each of them.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":62556261,"Users Score":0,"Answer":"So if I understand correctly, you're looking for a way to map every pair\ni,j from User-i and User-j to a number between 0 and 65535 (or whichever your range is). By the way, this means that you're going to have a maximum of 65535 pairs of users, and since there are N * (N-1) \/ 2  pairs, that means about 362 users.\nBut which group to map to which port?\nLet's say User-0 gets ports 1 to N, next user N+1 to 2N, etc\nThis way you can map i,j to f(i,j) = N*i + j, which is a 1-1 function, however i,j gives a different result than j,i , which is not what you want.\nTherefore, we first need to map i,j to something which gives the same result for j,i but for no other inputs. One idea is g(i,j) = (i,j) if i<j else (j,i). In other words, sort the numbers first.\nNow User1, User2 are mapped to 1,2 -> 1,2 -> 360*1 + 2 = 362\nAnd also User2, User1 are mapped to 2,1 -> 1,2 -> 360*1 + 2 = 362","Q_Score":0,"Tags":"python,sockets,arraylist,logic","A_Id":62557136,"CreationDate":"2020-06-24T13:29:00.000","Title":"How to generate unique pairs of numbers on python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python project I wrote in python 2.7 with antlr3,\nnow, when python are killing python2 I want to convert it into a python3 project, which is easy using 2to3 library.\nwhen I try to run pip3 install antlr3-python-runtime I get an error because antlr3 does not support python3, so I need to install antlr4, which I did.\nthe problem is that now I need to change the code to be compatible with antlr4, but the code has thousands of lines, so I can't go line by line.\nIs there a way to convert antlr3 project to antlr4 project or to use antlr3 in python3?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":343,"Q_Id":62557746,"Users Score":0,"Answer":"Is there a way to convert antlr3 project to antlr4 project or to use antlr3 in python3?\n\nI know of no tool that does this. You'll have to do it manually.","Q_Score":0,"Tags":"python-3.x,python-2.7,antlr,antlr4,antlr3","A_Id":62559579,"CreationDate":"2020-06-24T14:45:00.000","Title":"Using antlr3 with python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run a python script through nodejs pythonshell but I keep getting a modulenotfound error when trying to import the libraries that I downloaded with pip. I installed pythonshell on my computer with npm, so I know that's not the problem.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":773,"Q_Id":62558303,"Users Score":1,"Answer":"When you install packages you will install them to a directory named site-packages\nIn your main directory this can be found from:\nyour-directory\/lib\/Python3.6\/site-packages\nIf you copy and paste the files you'd like to run into this folder, and change the script path accordingly, the file will find all imported modules.\nThis is because the python shell was looking in the current directory for your packages and not finding them.","Q_Score":0,"Tags":"python,node.js,npm,pip,frontend","A_Id":62558376,"CreationDate":"2020-06-24T15:13:00.000","Title":"Can't import python modules with Nodejs and Python shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a scraper built in RSelenium. A number of tasks are more easily accomplished using Python, so I've set up a .Rmd file with access to R and Python code chunks.\nThe R-side of the scraper opens a website in Chrome, logs in, and accesses and scrapes various pages behind the login wall. (This is being done with permission of the website owners, who would rather users scrape the data ourselves than put together a downloadable.)\nI also need to download files from these pages, a task which I keep trying in RSelenium but repeatedly come back to Python solutions.\nI don't want to take the time to rewrite the code in Python, as it's fairly robust, but my attempts to use Python result in opening a new driver, which starts a new session no longer logged in. Is there a way to have Python code chunks access an existing driver \/ session being driven by RSelenium?\n(I will open a separate question with my RSelenium download issues if this solution doesn't pan out.)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":62560581,"Users Score":0,"Answer":"As far as I can tell, and with help from user Jortega, Selenium does not support interaction with already open browsers, and Python cannot access an existing session created via R.\nMy solution has been to rewrite the scraper using Python.","Q_Score":0,"Tags":"python,r,selenium,web-scraping,selenium-chromedriver","A_Id":63379878,"CreationDate":"2020-06-24T17:15:00.000","Title":"Can a Python + R file share a webdriver session between the languages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I used auto-py-to-exe to convert a Python script into an executable file and it converts it to an executable without any problems, but when I launch the executable the following error happens:\nModuleNotFoundError: No module named 'pandas'\n[11084] Failed to execute script test1\nAny ideas on how to fix this? I've tried many libraries to convert the Python file to and Executable and all give me the same error. I've tried with cx_Freeze, PyInstaller, py2exe, and auto-py-to-exe. All give me a ModuleNotFoundError, but when I run the script on the IDE it runs perfectly.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":1862,"Q_Id":62561716,"Users Score":2,"Answer":"Are you trying pip install pandas?","Q_Score":0,"Tags":"python,exe,pyinstaller,py2exe,cx-freeze","A_Id":62561762,"CreationDate":"2020-06-24T18:24:00.000","Title":"ModuleNotFoundError: No module named 'pandas' when converting Python file to Executable using auto-py-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":"I used auto-py-to-exe to convert a Python script into an executable file and it converts it to an executable without any problems, but when I launch the executable the following error happens:\nModuleNotFoundError: No module named 'pandas'\n[11084] Failed to execute script test1\nAny ideas on how to fix this? I've tried many libraries to convert the Python file to and Executable and all give me the same error. I've tried with cx_Freeze, PyInstaller, py2exe, and auto-py-to-exe. All give me a ModuleNotFoundError, but when I run the script on the IDE it runs perfectly.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1862,"Q_Id":62561716,"Users Score":2,"Answer":"A script that runs in your IDE but not outside may mean you are actually working in a virtual environment. Pandas probably is not installed globally in your system. Try remembering if you had created a virtual environment and then installed pandas inside this virtual environment.\nHope it helped,\nVijay.","Q_Score":0,"Tags":"python,exe,pyinstaller,py2exe,cx-freeze","A_Id":62561815,"CreationDate":"2020-06-24T18:24:00.000","Title":"ModuleNotFoundError: No module named 'pandas' when converting Python file to Executable using auto-py-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":"I used auto-py-to-exe to convert a Python script into an executable file and it converts it to an executable without any problems, but when I launch the executable the following error happens:\nModuleNotFoundError: No module named 'pandas'\n[11084] Failed to execute script test1\nAny ideas on how to fix this? I've tried many libraries to convert the Python file to and Executable and all give me the same error. I've tried with cx_Freeze, PyInstaller, py2exe, and auto-py-to-exe. All give me a ModuleNotFoundError, but when I run the script on the IDE it runs perfectly.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1862,"Q_Id":62561716,"Users Score":1,"Answer":"For cx_freeze, inlcude pandas explicitly in the packages. Like in the example below -\nbuild_exe_options = {'packages': ['os', 'tkinter', 'pandas']}\nThis should include the pandas module in you build.","Q_Score":0,"Tags":"python,exe,pyinstaller,py2exe,cx-freeze","A_Id":62567997,"CreationDate":"2020-06-24T18:24:00.000","Title":"ModuleNotFoundError: No module named 'pandas' when converting Python file to Executable using auto-py-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":"I would like to send a HTML email formatted with Materialize CSS in Django, can any one help me?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":17,"Q_Id":62563660,"Users Score":1,"Answer":"HTML emailing does not support separate CSS. You have to define the style in the element.","Q_Score":0,"Tags":"python,django","A_Id":62563700,"CreationDate":"2020-06-24T20:34:00.000","Title":"Why do html rendared emails not recognize cdn based css?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've included this library as a layer to my lambda function but when I go to test it I get the error: cannot import name 'etree' from 'lxml'\nThere are multiple posts about people having this issue and some say to that I need to build it to compile some c libraries. Most posts say to look for another file or folder name 'lxml' which I've verified is not the issue.\nI'm able to run the same code I've deployed to my layer on my local linux workstation and it runs without an issue.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":146,"Q_Id":62564463,"Users Score":2,"Answer":"Turns out my lambda was running python version 3.8 and that version is not compatible with the version of lxml I am using 4.5.1. Changing the run time to 3.7 fixed the issue. Hope this helps someone.","Q_Score":0,"Tags":"python-3.x,aws-lambda,lxml","A_Id":62564464,"CreationDate":"2020-06-24T21:37:00.000","Title":"lxml library 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 created a PyQt application and then made it's .exe file using auto-py-to-exe. I am observing that it has created a base_library.zip file inside my directory. I want to know it's purpose and should I unzip this file or not?\nI am using Python 3, PyQt4 and windows 10.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":738,"Q_Id":62564715,"Users Score":1,"Answer":"Auto-py-to-exe creates a base_library.zip file when selected \"One Directory\". One shouldn't try to unzip this file. Just leave it as it is.","Q_Score":1,"Tags":"python,python-3.x,pyinstaller,autopy","A_Id":63243627,"CreationDate":"2020-06-24T21:59:00.000","Title":"Use of base_library.zip file in pyinstaller","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning Python and I heard all functions are objects. And classes are objects too, if I am not mistaken. Then methods within a class must be objects.\nThen I wonder, within __init__ method, which is an object, are the attributes objects, too? Objects within an object?\nThere is a phrase 'Everything is an object'. And my impression is that anything that holds a memory space is an object. What I don't quite grasp is to what extent the phrase 'everything is an object' applies. I wonder if it applies even to variables within __init__ method.","AnswerCount":1,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":65,"Q_Id":62565128,"Users Score":-4,"Answer":"Yes, it's quite similar to Java. Every Python variable hides a pointer to the right location of memory which contains the actual data. There are only four primitive types in Python: integers, floats, booleans and strings; anything else is an ADT.\nThe keyword self is the same of this in Java or C++, in other words the self-reference. Using self, you can invoke another method inside the class or access to an attribute. Syntax like self.var = 1 can also creates a new attribute (if it doesn't exist yet) with name \"var\", type \"int\" and value 1.","Q_Score":0,"Tags":"python,object","A_Id":62565221,"CreationDate":"2020-06-24T22:40:00.000","Title":"object and __init__ method","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new using Jupyter on Miniconda and I was having a problem while importing packages (ImportError: DLL load failed ), looking for answers the solution was to initialize a base environment in my bash.\nI used to initialize jupyter typing jupyter notebook in bash, but using the solution given, I have to activate conda activate bash and then type jupyter notebook. What is the difference between starting Jupyter the way I used to and this new way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":20,"Q_Id":62566539,"Users Score":1,"Answer":"conda activate command activates a virtual environment. It is an isolated environment so all packages you installed in the virtual environment cannot be used outside it. When you start bash, you are in the base environment and it seems that you installed your Jupiter in bash environment so you cannot use bash's Jupiter in base environment and vice versa. It may be a little annoying at the beginning, but it can let you use different environments for different purposes. For example, since pip only allows one version of a specific package to be installed, different environments can let you test a new version of a package without breaking the functionality of the original program.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":62566859,"CreationDate":"2020-06-25T01:35:00.000","Title":"Explanation about Miniconda environments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently, I have been scouring the internet for a code that will either add this program (something.exe) to the windows task scheduler or if that is not even an option how to add it to the windows reg key for a startup. I cannot find anything in terms of Python3, and I really hope it is not an answer that is right in front of my face. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":62568162,"Users Score":0,"Answer":"Open the windows scheduler -> select \"create basic task\" -> fill out the desired times -> input the path to the script you want to execute.","Q_Score":0,"Tags":"python,windows,scheduled-tasks","A_Id":62568265,"CreationDate":"2020-06-25T05:00:00.000","Title":"Is there a python code that I can add to my program that will add it to start in windows 10?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to use sunnyportal-py. Relatively new to python, I do not understand step 2 in the README:\nHow to run\n\nClone or download the repository.\nEnter the directory and run:\nPYTHONPATH=. .\/bin\/sunnyportal2pvoutput --dry-run sunnyportal.config\nEnter the requested information and verify that the script is able to connect to Sunny Portal.\nThe information is saved in sunnyportal.config and can be edited\/deleted if you misstype anything.\nOnce it works, replace --dry-run with e.g. --output to upload the last seven days output data to pvoutput or --status to upload data for the current day.\nAdd --quiet to silence the output.\n\nCould anyone help me? I have gone into a cmd.exe in the folder I have downloaded, I don't know how to correctly write the python path in the correct location. What should I paste into the command line? Thanks!\nEdit : I would like to be able to do this on Windows, do tell me if this is possible.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":62568970,"Users Score":0,"Answer":"The command at bullet 2 is to be typed at the commandline (You need to be in windows: cmd or powershell, Linux: bash, etc.. to be able to do this).\n\nPYTHONPATH=. .\/bin\/sunnyportal2pvoutput --dry-run sunnyportal.config\n\nThe first part of the command code above indicates where your program is located. Go to the specific folder via commandline (windows: cd:... ; where .. is your foldername) and type the command.\nThe second part is the command to be executed. Its behind the \"--\" dashes. The program knows what to do. In this case:\n\n--dry-run sunnyportal.config\n\nrunning a validation\/config file to see if the program code itself works; as indicated by \"dry run\".\nIn your case type at the location (while in cmd):\n\n\"sunnyportal2pvoutput --dry-run sunnyportal.config\"\n\nor\n\n\"sunnyportal2pvoutput.py --dry-run sunnyportal.config\" (without the environment variables (python path) set).\n\nNote: the pythonpath is an environment variable. This can be added via: Control Panel\\All Control Panel Items\\System\\ --> bullet Advanced System Settings --> button \"environment variables\". Then you can select to add it to \"Variables for user \"username\"\" or \"system variables\". Remember to reboot thereafter to make the change effective immediately.\nUpdate 1 (pip install sunnyportal):\n\ngo to cmd.\ntype \"pip search sunnyportal\"\n\nResult:\n\nMicrosoft Windows [Version 10.0.18363.836] (c) 2019 Microsoft\nCorporation. All rights reserved.\nC:\\Windows\\System32>pip search\nsunnyportal\nsunnyportal-py (0.0.4)  - A Python client for SMA sunny portal\nC:\\Windows\\System32>\n\nIf found, then type:\n\"pip install sunnyportal\"","Q_Score":0,"Tags":"python,python-3.x","A_Id":62569393,"CreationDate":"2020-06-25T06:15:00.000","Title":"How do I run a downloaded repository's config in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a few things that are calling the same lambda function and when called I need to know which group they are in. How can I obtain which IoT thing group they are in via a python lambda function? I've tried checking if there is anything I can work with in the client and context objects, but can't find anything.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":237,"Q_Id":62571223,"Users Score":1,"Answer":"There are provisions for creating a rule that can call a Lambda function and pass in data from the MQTT message that triggered the rule. In a typical architecture, the Lambda functions are invoked via a Rule and not directly by IoT client. The AWS IoT Rules Engine ( based on SQL-based language) enable to select data from message payloads and send the data to other services, such as AWS Lambda or S3 etc.\nThe Rule processes a JSON based message from the topic on which it is listening and by default passes the result to the Lambda function as event parameter of your handler without adding or removing any data. Accordingly, if the message has no data of interest , then that data might be unavailable for Lambda function.\nOne option can be embedding the Things group name inside message from the Thing. This data can be parsed at Lambda. The event parameters can be helpful at Lambda function for fetching the Thing related information provided the Thing information is conveyed inside the MQTT message or added by Rule's SQL to the result passed to the Lambda function.","Q_Score":1,"Tags":"python,amazon-web-services,aws-lambda,aws-iot","A_Id":62605704,"CreationDate":"2020-06-25T08:38:00.000","Title":"How to obtain thing group name from AWS lambda 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 am trying to run a contionus azure webjob for python.\ni have 6 files where main.py is the main file, other files internally importing each other and finally everything is being called from main.py, now when i am trying to run only the first python file is getting executed, but i want that when the webjob will start only main.py will be executed not anything else. how to achieve that ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":62571480,"Users Score":1,"Answer":"This is quite simple. In azure webjob, if the file name starts with run, then this file has the highest priority to execute.\nSo the most easiest way is just renaming the main.py to run.py.\nOr add an run.py, then call the main.py within it.","Q_Score":2,"Tags":"python,azure,azure-webjobs","A_Id":62587173,"CreationDate":"2020-06-25T08:51:00.000","Title":"Run one file among multiple files in azure webjobs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have VSCode installed and python 3.6.8\nI use tabs for my indentation. But when ever I save the file, all the tabs are being converted to spaces.\nThis might be because of the formatter I use, i.e. Black. How do I prevent the formatter from doing that(Do all your formatting except inter-changing indents with spaces)?\nThank you","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":2475,"Q_Id":62573039,"Users Score":1,"Answer":"Both autopep8 and black are very strict.\nThey don't just recommend spaces over tabs, but force the usage of space indentation.\nIf you really want to use tabs, you should use yapf, with style use_tabs=True.","Q_Score":7,"Tags":"python,visual-studio-code,vscode-settings","A_Id":67893928,"CreationDate":"2020-06-25T10:16:00.000","Title":"Prevent changing indentation from tabs to spaces","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have VSCode installed and python 3.6.8\nI use tabs for my indentation. But when ever I save the file, all the tabs are being converted to spaces.\nThis might be because of the formatter I use, i.e. Black. How do I prevent the formatter from doing that(Do all your formatting except inter-changing indents with spaces)?\nThank you","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2475,"Q_Id":62573039,"Users Score":0,"Answer":"Assuming you don't have VS Code set up to insert space into tabs, then Black will very likely replace them with spaces as that's the norm in the Python community and Black takes a very opinionated view on how to format Python code. You could try another formatter like yapf or autopep8 to see if they will leave physical tabs in.\nBut do note that the vast majority of the Python community uses spaces, so you are potentially facing an uphill battle.","Q_Score":7,"Tags":"python,visual-studio-code,vscode-settings","A_Id":62600540,"CreationDate":"2020-06-25T10:16:00.000","Title":"Prevent changing indentation from tabs to spaces","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have VSCode installed and python 3.6.8\nI use tabs for my indentation. But when ever I save the file, all the tabs are being converted to spaces.\nThis might be because of the formatter I use, i.e. Black. How do I prevent the formatter from doing that(Do all your formatting except inter-changing indents with spaces)?\nThank you","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":2475,"Q_Id":62573039,"Users Score":1,"Answer":"Not only 'black' but also 'autopep8' and 'yapf' will convert the tabs to spaces. And looks like both 'black', 'autopep8' and 'yapf' haven't provided args to change the format behavior of indent. And I agree with Brett Cannon, you'd better adapt to space indent.\nIf you really want a try of that, you can find the black.py in site-packages folder and at the lines of 1540 in black.py change the '    '(four spaces) to '    '(a tab, copy a tab, and you can choose any spaces of the tab contains). Then you can get what you want. But, I really don't recommend it.","Q_Score":7,"Tags":"python,visual-studio-code,vscode-settings","A_Id":62651770,"CreationDate":"2020-06-25T10:16:00.000","Title":"Prevent changing indentation from tabs to spaces","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to download youtube videos using python and for the code to work I need to install pytube3 library but I am very new to coding so I am not sure how to do it.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":41,"Q_Id":62573330,"Users Score":1,"Answer":"You could use\npython3 -m pip install pytube3","Q_Score":0,"Tags":"python","A_Id":62573608,"CreationDate":"2020-06-25T10:32:00.000","Title":"How do you download online libraries on python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a string that is 85k characters long. When I print it with python script VS code terminal displays only 21k characters of that string.\nIs this normal? How can I set up the VS code to display the whole string?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":638,"Q_Id":62573951,"Users Score":0,"Answer":"I suggest you to run your script(which prints that large string) in your system terminal.\nThe internal terminal of VS Code is not as powerful as systems default terminal.","Q_Score":1,"Tags":"python-3.x,visual-studio-code","A_Id":62574914,"CreationDate":"2020-06-25T11:09:00.000","Title":"VS code doesn't print full string inside terminal Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a query with respect to using external libraries like delta-core over AWS EMR notebooks. Currently there isn\u2019t any mechanism of installing the delta-core libraries through pypi packages. The available options include.\n\nLaunching out pyspark kernel with --packages option\nThe other option is to change the packages option in the python script through os configuration, but I don\u2019t see that it is able to download the packages and I still get import error on import delta.tables library.\nThird option is to download the JARs manually but it appears that there isn\u2019t any option on EMR notebooks.\n\nHas anyone tried this out before?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":516,"Q_Id":62574687,"Users Score":0,"Answer":"You can download the jars while creating EMR using bootstrap scripts.\nYou can place the jars in s3 and pass it to pyspark with --jars option","Q_Score":0,"Tags":"python,amazon-web-services,amazon-emr","A_Id":62586305,"CreationDate":"2020-06-25T11:52:00.000","Title":"Accessing delta lake through Pyspark on EMR notebooks","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"From Medium API docs I can see how to retrieve publications and create posts, but it doesn't mention retrieving reading list. Is retrieving reading list for a user currently possible using the Medium's API?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":702,"Q_Id":62576452,"Users Score":0,"Answer":"I don't think it is currently possible to retrieve reading list. According to the documentation api's it is not part of that list.","Q_Score":1,"Tags":"python,api,medium.com","A_Id":66298868,"CreationDate":"2020-06-25T13:25:00.000","Title":"How to retrieve Medium reading list for a user from the API using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a simple task but am struggling with the proper way to implement it:\n\nI want one shared QStandardItemModel containing a tree structure to be displayed in two different QTreeViews.\nThe first QTreeView shows the model as-is and allows the user to add, remove and rearrange the items. Clicking an item shows an item-associated QWidget within a QStackedWidget below the QTreeView. Some item types can also be renamed.\nThe second QTreeView shows the same tree model, however all items are greyed out by default. A Processor will then move along the tree structure and process each item. Whenever an item is processed, it should not longer be greyed out. Those items not greyed out should be clickable to display the item-corresponding processed image in a viewer. Whenever a change is made in the first QTreeView, the Processor starts processing from the changed position onwards again.\n\nHow do I implement the different look and functionality of the two QTreeViews? Do I assign custom QItemDelegates to each QTreeView? Should I use a QIdentityProxyModel for the second QTreeView?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":62577076,"Users Score":0,"Answer":"It is only necessary to use a QStandardItemModel for both models since they store the same information so if you want them to look different then you must use delegates.\nIf you want some action when the view is clicked then that does not depend on the model but you have to use the view clicked signal that is independent of the other view.\nFor the second view if a delegate is required to change the color, the logic is to use a role to indicate if that item has been processed or not, and then change the color based on that role. When you say \"a change in the first QTreeView\" you should actually say \"a change in the model\" so it is only necessary to use the dataChanged signal, process the item by changing the role status before and after processing.","Q_Score":0,"Tags":"python,pyqt,pyqt5,qtreeview,qstandarditemmodel","A_Id":62577885,"CreationDate":"2020-06-25T13:56:00.000","Title":"Two different QTreeViews with one shared QStandardItemModel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm an experienced developer, but not very familiar with Python and Pyramid.\nI'm trying to follow some (a bit old and unclear) instructions on deploying a Pyramid web application. My OS is Ubuntu 16.04.\nThe instructions say to install virtualenv and Pyramid - I do so with apt install virtualenv and apt install python-pyramid. Then they say I should run the app in a virtual environment, so I build that with virtualenv . -ppython3, and activate it with source bin\/activate. I install the application from a ready-to-run buildout from GitHub. The buildout includes a \"production.ini\" file with parameters to pserve.\nBut Pyramid is not included in the virtual environment built with virtualenv. (There is no \"pserve\" in the bin directory, e.g.) So I can't run the applications with bin\/pserve etc\/production.ini, as the instructions say. And if I try with only \"pserve\", I get errors when trying to access files like \"var\/waitress-%(process_num)s.sock\". Files that the app excepts to find in the virtual environment.\nI've looked for flags to tell virtualenv to include Pyramid, but couldn't find any. Am I overlooking something? I'd be most grateful for some help! :-)\n\/Anders from Sweden","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":62578228,"Users Score":0,"Answer":"You mentioned it's using buildout - I assume this is zc.buildout. buildout usually manages its own virtualenv and handles installing all of the necessary dependencies. It really depends on how that buildout is configured as there's no standard there for what to do or how to run your app. I would normally expect pserve to be exposed in the bin folder, but maybe another app-specific script is exposed instead.","Q_Score":0,"Tags":"python,virtualenv,pyramid","A_Id":62607113,"CreationDate":"2020-06-25T14:53:00.000","Title":"Pyramid not included in Python virtualenv","Data 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 have a video player application, with a graph display below it. My video player is fetching frames periodically, but when I move the mouse it freezes, and by printing what's happening I can see that the main loop didn't call anything\nI've tried printing some text for every widget on_mouse_pos event but none of them is triggered, so I really don't know where should I look. Using the recorder module, I can see that there is no mouse event, so I'm not even sure the mouse event is recorder\nI have several widgets now so I'm not sure posting them here would be useful, but I'd love to hear feeedback or any idea about this problem\nThanks a lot","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":62578991,"Users Score":0,"Answer":"So I was able to fix this, my frame pulling function was in a separate thread, moving it to a periodically triggered Clock event fixed this.\nI'm still not sure why this bug happened, my 2 cents is that opencv block the GIL while reading a frame, and this somehow interfered with how kivy manages its events","Q_Score":0,"Tags":"python,python-3.x,kivy,kivy-language","A_Id":62593957,"CreationDate":"2020-06-25T15:31:00.000","Title":"Kivy: Moving mouse freeze main loop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering if I can reset the training of Kite's AI that uses my code. I want to do this because I want to change my code style and there is some stuff that I quit doing.\nTake xrange for example; it's deprecated in python3 (I'm a python coder). So, I want to reset all of the data it learned from me as if I just got it again. I don't want to uninstall and reinstall it.\nIs uninstalling the Sublime Text\/Atom plugins and reinstalling them would do the trick? Or is it not possible?\nAnd for the specs, I got a MacOS Catalina (10.15.5 (19F96)), non-pro and no account for Kite, and Kite version 0.20200609.2.\nI want to know if there's an official way, not some file removing magic.\nBut if some file removing magic is necessary, then I'm fine.\nAlso, I wonder if just removing and reinstalling the plugins for editors would do the trick...\n\nI want a coniacal answer.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":425,"Q_Id":62580268,"Users Score":0,"Answer":"You can try creating a new account. I was in the same situation once and honestly, nothing seemed to help. I tried to uninstall and reinstall but as vague as that other answer is, it didn't work because they probably store the data and train a model for each individual user account unique to them without a kill-switch so probably the only way is to create a new account unless of course there's another workaround that they make us aware of which at the time being, I'm pretty sure does not exist.","Q_Score":4,"Tags":"python,python-3.x,machine-learning,autocomplete,artificial-intelligence","A_Id":62885001,"CreationDate":"2020-06-25T16:43:00.000","Title":"Is there a way to reset Kite Autocomplete's AI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given any image of a scanned document, I want to check if it's not empty page.\nI know I can send it to AWS Textract - but it will cost money for nothing.\nI know I can use pytesseract but maybe there is more elegant and simple solution?\nOr given a .html file that represents the text of the image - how to check it shows a blank page?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1208,"Q_Id":62580362,"Users Score":1,"Answer":"We can use pytesseract for this application by thresholding the image and passing it to tesseract. However if you have a .html file that represents text of image, you can use beautifulsoup for extracting text from it and check if it is empty.Still this is a round way approach.","Q_Score":0,"Tags":"python,opencv,ocr,python-tesseract","A_Id":62580455,"CreationDate":"2020-06-25T16:48:00.000","Title":"How to check if image contains text or not?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I installed two packages in Spyder through the IPython console using pip install <package name> , and the installed packages work fine in Spyder. However, when I run the same script in Sublime Text, it throws an error saying that the required packages are not installed. Can anyone please suggest a workaround so that I do not have to reinstall the same package.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":62580715,"Users Score":0,"Answer":"do you have multiple versions of python on your computer?\nIf so, make sure that you are using the same interpreter in Spyder which you also have installed your packages on using pip.","Q_Score":0,"Tags":"python,pip,sublimetext3,spyder","A_Id":62581042,"CreationDate":"2020-06-25T17:08:00.000","Title":"Packages installed in Spyder not showing up in Sublime text (OS High Sierra)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used pyinstaller to generate an executable for a python script, and when trying to run the executable I get the error ModuleNotFoundError: No module named 'scipy.special.cython_special'. I'm not sure where this is coming from, or how to fix it. My executable takes in one argument and returns a list. Any help is appreciated!","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":3965,"Q_Id":62581504,"Users Score":6,"Answer":"I had this error after freezing a program that used scipy  version 1.5.0  but I changed the version to 1.4.1 (which I had used with  an earlier virtual environment) and the error disappeared.","Q_Score":8,"Tags":"python,cython,executable","A_Id":62737264,"CreationDate":"2020-06-25T17:57:00.000","Title":"Why do I have \"ModuleNotFoundError: No module named 'scipy.special.cython_special'\" when I don't even use cython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used pyinstaller to generate an executable for a python script, and when trying to run the executable I get the error ModuleNotFoundError: No module named 'scipy.special.cython_special'. I'm not sure where this is coming from, or how to fix it. My executable takes in one argument and returns a list. Any help is appreciated!","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3965,"Q_Id":62581504,"Users Score":0,"Answer":"I just solved this problem by copying the cython_special.cp37-win_amd64.pyd file from MyEnv>Lib>site-packages>scipy>special into the same directory of the compiled pyinstaller program.","Q_Score":8,"Tags":"python,cython,executable","A_Id":62656085,"CreationDate":"2020-06-25T17:57:00.000","Title":"Why do I have \"ModuleNotFoundError: No module named 'scipy.special.cython_special'\" when I don't even use cython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used pyinstaller to generate an executable for a python script, and when trying to run the executable I get the error ModuleNotFoundError: No module named 'scipy.special.cython_special'. I'm not sure where this is coming from, or how to fix it. My executable takes in one argument and returns a list. Any help is appreciated!","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3965,"Q_Id":62581504,"Users Score":0,"Answer":"I had the same problem, turns out I was using Python 3.8 which isn't supported by Pyinstaller. Try using 3.7.","Q_Score":8,"Tags":"python,cython,executable","A_Id":62931033,"CreationDate":"2020-06-25T17:57:00.000","Title":"Why do I have \"ModuleNotFoundError: No module named 'scipy.special.cython_special'\" when I don't even use cython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used pyinstaller to generate an executable for a python script, and when trying to run the executable I get the error ModuleNotFoundError: No module named 'scipy.special.cython_special'. I'm not sure where this is coming from, or how to fix it. My executable takes in one argument and returns a list. Any help is appreciated!","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":3965,"Q_Id":62581504,"Users Score":1,"Answer":"Add --hidden-import=\"scipy.special.cython_special\" to your pyinstaller command.","Q_Score":8,"Tags":"python,cython,executable","A_Id":69028485,"CreationDate":"2020-06-25T17:57:00.000","Title":"Why do I have \"ModuleNotFoundError: No module named 'scipy.special.cython_special'\" when I don't even use cython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset, on which i am working on Data Cleaning part, where one of the attribute or feature is having the values with various units. for example some of the values are as follow.\n1 kg; 6 LB; 900 gms; 32 oz; etc.\nIf i use the standard scaler then it will not be fair as the values and their units are different, so cannot treat them as is.\nPlease do suggest how to handle such data.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":62585046,"Users Score":1,"Answer":"I will recommend to change the different value to same unit first of all. For example, you can make all the value to kg or whatever suits best for you, and then perform the standard scale.","Q_Score":0,"Tags":"python-3.x,pandas,data-manipulation","A_Id":62586121,"CreationDate":"2020-06-25T22:05:00.000","Title":"How to handle various units in a single attribute \/ feature using Pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to developing a website and because of my familiarity with Python and considering the complexity of the website, I chose Django.\nI want to know the best practice for developing a template through the Django framework. My question is two-fold.\n\nIs it best to have a bunch of for loops \/ if statements in the template\nusing template tags and other features of Django?\nOr is it passing the variables from Django to Javascript through JSON and then\nloading the page asynchronously?\n\nFor the first, I found the following merits: its fairly easy. I know what I want, I code the loops and I get the result that I expect. Plus giving IDs \/ names to HTML tags is super simple. Inline scripting also becomes simple, but I personally dont like it. But as objects start to get high in number, page load speed suffers.\nFor the second, and I am very new to this, the ease is gone. There is, I feel, another hoop to jump through Javascript, with JSON parsing and then the actual modeling.\nIf not either first or second, may be there is a balance between the two?\nAll help is appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":124,"Q_Id":62586513,"Users Score":1,"Answer":"If i got your question correctly then i think the answer is AJAX i.e, using the same page to load different content.You don't have to go to another page but on the same page, setting some links, you can pull newer data without loading a new page.\nHope this helped you!","Q_Score":1,"Tags":"javascript,python,django","A_Id":62587170,"CreationDate":"2020-06-26T01:10:00.000","Title":"Django project, pure javascript, html and template tags best practices","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We are ingesting data in Janusgraph on Kubernetes(GCP) using python. We are doing multithreading, node chaining, indexing but still we are able to ingest only 100k (Nodes) records in 60 minutes from bigquery.\nKubernetes spec - 1 Pod with 25 vCPUs and 150 GiB RAM\nids.block-size = 10 million\nthread pool - 16\nnode pool - 16\nheap size - 4 gb\nQuestions:\n\nAny more approach we can take to increase the ingestion performance, reducing the overall time.\n\nHow many multiple connections at a time we can create with Janusgraph via Python Driver. Currently we are able to create 30 threads(connections) but when we increase the number of threads the connection either stuck or performance goes down.\n\n\nAny details\/help will be highly appreciated\nGremlin Query: g.V().hasLabel(\"http:\/\/purl.uniprot.org\/core\/Helix_Annotation\").has(\"id\", \"http:\/\/purl.uniprot.org\/uniprot\/P06931#SIPC5C5063B7561AB45\").has(\"node_id\", \"http:\/\/purl.uniprot.org\/uniprot\/P06931#SIPC5C5063B7561AB45\").has(\"rdf_type\", \"http:\/\/purl.uniprot.org\/uniprot\/\").has(\"http:\/\/purl.uniprot.org\/core\/range\", \"http:\/\/purl.uniprot.org\/range\/22571007582875950tt125tt127\").fold().coalesce(unfold(), addV(\"http:\/\/purl.uniprot.org\/core\/Helix_Annotation\").property(\"id\", \"http:\/\/purl.uniprot.org\/uniprot\/P06931#SIPC5C5063B7561AB45\").property(\"node_id\", \"http:\/\/purl.uniprot.org\/uniprot\/P06931#SIPC5C5063B7561AB45\").property(\"rdf_type\", \"http:\/\/purl.uniprot.org\/uniprot\/\").property(\"http:\/\/purl.uniprot.org\/core\/range\", \"http:\/\/purl.uniprot.org\/range\/22571007582875950tt125tt127\")).V().hasLabel(\"http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#Statement\").has(\"id\", \"http:\/\/purl.uniprot.org\/uniprot\/#_kb.P06931_up.annotation_FA85AD309172A9A7\").has(\"node_id\", \"http:\/\/purl.uniprot.org\/uniprot\/#_kb.P06931_up.annotation_FA85AD309172A9A7\").has(\"rdf_type\", \"http:\/\/purl.uniprot.org\/uniprot\/\").has(\"http:\/\/purl.uniprot.org\/core\/attribution\", \"http:\/\/purl.uniprot.org\/uniprot\/P06931#attribution-AE0E09C5B47CC2714C9061D3806995B4\").fold().coalesce(unfold(), addV(\"http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#Statement\").property(\"id\", \"http:\/\/purl.uniprot.org\/uniprot\/#_kb.P06931_up.annotation_FA85AD309172A9A7\").property(\"node_id\", \"http:\/\/purl.uniprot.org\/uniprot\/#_kb.P06931_up.annotation_FA85AD309172A9A7\").property(\"rdf_type\", \"http:\/\/purl.uniprot.org\/uniprot\/\").property(\"http:\/\/purl.uniprot.org\/core\/attribution\", \"http:\/\/purl.uniprot.org\/uniprot\/P06931#attribution-AE0E09C5B47CC2714C9061D3806995B4\"))","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":62587526,"Users Score":0,"Answer":"Have you tried using groovy scripts? I was able to insert ~5K nodes in ~10 sec single threaded into a janusgraph that has much lesser RAM and CPU.","Q_Score":4,"Tags":"google-cloud-platform,gremlin,janusgraph,gremlinpython,knowledge-graph","A_Id":62702269,"CreationDate":"2020-06-26T03:21:00.000","Title":"JanusGraph Data Ingestion atscale","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"before i have never working with synthetic dataset, but in my project I do not have enough dataset, that is why I want use hull synthetic dataset to my network. It is posible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":62587882,"Users Score":0,"Answer":"Yes sure, it is possible and widely used in machine learning when there is lack of dataset.","Q_Score":0,"Tags":"python,generative-adversarial-network","A_Id":62588212,"CreationDate":"2020-06-26T04:09:00.000","Title":"Training network with synthetic dataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python 3.8.3, Scrapy 2.2.0 and Twisted-20.3.0-cp38-cp38-win_amd64.whl are installed on my computer. Everything works as expected.\nI can\u2019t install Scrapy without Twisted, so Twisted is also installed, but when I try to transfer the application to Heroku, an error appears. How do I use Scrapy on Heroku?\n-----> Found python-3.6.10, removing\n-----> Requirements file has been changed, clearing cached dependencies\n-----> Installing python-3.8.3\n-----> Installing pip\n-----> Installing SQLite3\n-----> Installing requirements with pip\n       ERROR: Twisted-20.3.0-cp38-cp38-win_amd64.whl is not a supported wheel on this platform.\n !     Push rejected, failed to compile Python app.\n !     Push failed```","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":922,"Q_Id":62594645,"Users Score":0,"Answer":"Remove Twisted-20.3.0-cp38-cp38-win_amd64.whl in your requirement.txt\nI don't think it's required because while installing scrapy it will be taken care of","Q_Score":0,"Tags":"python,heroku,twisted","A_Id":63981172,"CreationDate":"2020-06-26T12:20:00.000","Title":"ERROR: Twisted-20.3.0-cp38-cp38-win_amd64.whl is not a supported wheel on this platform","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm asking this question because I've noticed that a lot of (if not all) discord bots go offline every few hours, then come back 2 seconds later. After making my own bot, it does the exact same thing (and it's only in 4 servers). Every few hours, it goes offline for 2 seconds then comes back. Does anyone have an explanation as to why this happens?\nDebugging\nWhen the problem occurs, it also triggers on_ready(), which seems to me to mean that it isn't discord, but the client.\nOther Information\n\nI am using discord.py-rewrite library, but I've seen this happen with the discord.js library as well\nThis happens in active servers\nUnless most bot developers make the same mistake, this is not a problem with my code.\nThis is not a pressing issue for me. I am just mostly curious why and am not necessarily looking for a solution, though I would appreciate it if you had one.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":327,"Q_Id":62595104,"Users Score":1,"Answer":"It could be possible that the Raspberry Pi loses connection to the discord client if it's connected wirelessly to the internet. Mine does the same for other servers unless it's connected through ethernet.","Q_Score":0,"Tags":"python,python-3.x,discord.py,discord.py-rewrite","A_Id":62688949,"CreationDate":"2020-06-26T12:49:00.000","Title":"Discord.py bot goes offline repeatedly","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 installed PyObjC for using AppKit library in my virtual env I can able to import Appkit inside pytthon3 venv\nI have tried installing the pyobjc using pip3 outside venv and installed successfully but when I try to import Appkit outside venv there it shows the import error for AppKit\nThis is outside venv\nXXX_XXX_XXX:~ dreams$ python3.\nPython 3.7.6 (v3.7.6:43364a7ae0, Dec 18 2019, 14:18:50)\n[Clang 6.0 (clang-600.0.57)] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\n\n\nimport AppKit\n\n\n\nTraceback (most recent call last):\nFile \"\", line 1, in \nModuleNotFoundError: No module named 'AppKit'\nInside venv\nXXX_XXX_XX:~ dreamguys$ source activeWindowEnv\/bin\/activate\n(activeWindowEnv) XXX_XXX_XX:~ dreams$ python\nPython 3.7.6 (v3.7.6:43364a7ae0, Dec 18 2019, 14:18:50)\n[Clang 6.0 (clang-600.0.57)] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\n\n\nimport AppKit","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":62595253,"Users Score":0,"Answer":"There is a package named appkit in pip3 which has no relation to the AppKit in apple. So please check the package you need to install before importing the AppKit module.\nAppKit module provides you with the objective C classes of the apple mac system, from which we can able to get the current active window.\nIn my venv there is no problem because I have installed pyObjC only for getting the AppKit import. but in main env I have mistakenly installed the appkit library, thats where the problem arised\nComing back to my problem, I have uninstalled both appkit and pyobjc and reinstalled the same using pip3 and now my imports worked fine. Try reinstalling the pyObjC. It will solve the problem","Q_Score":0,"Tags":"ios,python-3.x,applescript,appkit","A_Id":62948693,"CreationDate":"2020-06-26T12:58:00.000","Title":"Appkit Working properly inside venv but not without using virtual env","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to calculate the inverse of a 2d array in python that holds fractions and cannot convert it to float because I need to maintain the ratio correctly between numerator and denominator.\nA = np.array([[Fraction(1), Fraction(-0.5)],\n[Fraction(-4\/9), Fraction(1)]])\nWhen I try np.linalg.inv(A) I get the following error:\n'TypeError: No loop matching the specified signature and casting was found for ufunc inv'","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":204,"Q_Id":62595267,"Users Score":1,"Answer":"Fraction is a Python type but not a native numpy dtype. Said differently, for a numpy point of view, Fractions are (opaque) objects. If you manage to do operations over them with numpy methods, chances are that they will be automatically converted to floating point types (which are native in numpy).\nLong story short, no numpy vectorized method will be able to process Fraction objects, so you should not use np.array to store them but stick to a plain old list, or to lists of lists if you want to process 2D arrays.","Q_Score":0,"Tags":"python,numpy,fractions","A_Id":62595697,"CreationDate":"2020-06-26T12:59:00.000","Title":"How to calculate the inverse of ndarray holding variables of type Fraction in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"tl;dr: If you manage hundreds of terraform files, is it worth writing a high level engine in a fully fledged programming language to manages those files ?\nI spend a lot of time, editing, copying, and changing terraform files for infrastructure changes. Although the cicd used to make changes to the infrastructure, deploying a new release, uses cp, and seds to change terraform files and create new ones.\nI find that a bit complicated to introduce changes to our cicd pipelines.\nI thought of having a set of template that I could manage using a python engine, to create files, plan and apply, ...\nIs it a good idea ? Do you have experience, or have you tried that too ?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":108,"Q_Id":62595446,"Users Score":2,"Answer":"Generic templating of Terraform HCL modules (.tf files) seems like an almost insurmountable goal and you would lose a lot of smart editor and IDE support in the process.\nYou would be better off moving the changing values into .tfvars or terragrunt.hcl files and sticking to you sed script or subscribing to Gruntwork and using their terraform-update-variable script which has a lot of testing and functionality that might prove useful.","Q_Score":0,"Tags":"python,automation,terraform,continuous-deployment,continuous-delivery","A_Id":62597927,"CreationDate":"2020-06-26T13:09:00.000","Title":"Is templating Terraform files a good idea?","Data Science and Machine Learning":0,"Database and SQL":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":"Basically title, is there anything like this? I googled around a bit but couldn't find anything relevant to Linux only... win32gui postcommand is what I'm looking for an equivalent on Linux","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":62595917,"Users Score":0,"Answer":"The module python-libxdo should be able to achieve what you wanted to do.\nIn particular, you can hardcode window id.","Q_Score":0,"Tags":"python-3.x,linux","A_Id":62607514,"CreationDate":"2020-06-26T13:34:00.000","Title":"Is there a python module in linux similar to win32gui for sending input to inactive windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to fit quantile regression with statsmodels. The same code that works in my laptop fails in the cloud and says it does not have fit method. But in the documentation, I see it has fit method. What is causing it? I am using it inside zeppelin notebook.\n from statsmodels.regression.quantile_regression import QuantReg\nfrom statsmodels.tools.tools import add_constant\nX = temp[['X']]\ny = temp['y']\nX = add_constant(X)\nmod = QuantReg(y, X)\nres = mod.fit(q = 0.5)\n \nThis is the error message I am getting:\n\nAttributeError: 'Interactive' object has no attribute 'fit'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":216,"Q_Id":62596493,"Users Score":1,"Answer":"It seems that the variable (mod) might have a namespace conflict internally within the statsmodel. Using a different name for mod variable to mod1 etc might help here.","Q_Score":0,"Tags":"python-3.x,statsmodels,quantile-regression","A_Id":62745865,"CreationDate":"2020-06-26T14:04:00.000","Title":"QuantReg:'Interactive' object has no attribute 'fit'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Scenario\nHi, I have a collection of APIs that I run on Postman using POST requests. The flask and redis servers are set up using docker.\nWhat I'm trying to do\nI need to profile my setup\/APIs in a high traffic environment. So,\n\nI need to create concurrent requests calling these APIs\n\nThe profiling aims to get the system conditions with respect to memory (total memory consumed by the application), time (total execution time taken to create and execute the requests) and CPU-time (or the percentage of CPU consumption)\n\n\nWhat I have tried\nI am familiar with some memory profilers like mprof and time profiler like line_profiler. But I could not get a profiler for the CPU consumption. I have run the above two profilers (mprof and line_profiler) on a single execution to get the line-by-line profiling results for my code. But this focuses on the function wise results.I have also created parallel requests earlier using asyncio,etc but that was for some simple API-like programs without POSTMAN. My current APIs work with a lot of data in the body section of POSTMAN\nWhere did I get stuck\nWith docker, this problem gets trickier for me.\n\nFirstly, I am unable to get concurrent requests\n\nI do not know how to profile my APIs when using POSTMAN (perhaps there is an option to do it without POSTMAN) with respect to the three parameters: time, memory and CPU consumption.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":247,"Q_Id":62597631,"Users Score":0,"Answer":"I suppose that you've been using the embbed flask server(dev server) that is NOT production ready and,by default, it supports only on request per time. For concurrent requests should be looking to use gunicorn or some other wsgi server like uWsgi.\nPostman is only a client of your API, i don't see it's importance here. If you want to do a stress test or somethin like that, you can write your own script or use known tools, like jmetter.\nHope it helps!","Q_Score":0,"Tags":"python,python-3.x,docker,postman,profiler","A_Id":62598094,"CreationDate":"2020-06-26T15:06:00.000","Title":"How to profile my APIs for concurrent requests?","Data Science and Machine Learning":0,"Database and SQL":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 get the sum of the digits of an integer, and found the solutions below:\n\nsum(map(int,list(str(123))))\n\nsum(int(digit) for digit in str(123))\n\n\nHowever, when I run this, I get the below error:\n\nTypeError: 'int' object is not callable","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":87,"Q_Id":62597880,"Users Score":2,"Answer":"Contrary to other answers, both your code works fine.\nI think you are shadowing something on your code. Perhaps you used int as a variable?","Q_Score":0,"Tags":"python,python-3.x,sum,int,typeerror","A_Id":62598281,"CreationDate":"2020-06-26T15:21:00.000","Title":"Sum of the digits","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm getting these weird errors in Google Colab when using TensorFlow, like:\n\nAttributeError: module 'tensorflow' has no attribute\n'reset_default_graph'\n\nor\n\nmodule 'tensorflow' has no attribute 'placeholder'\n\nHelp would appreciated.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2666,"Q_Id":62598537,"Users Score":1,"Answer":"Try using tf.compat.v1.placeholder and tf.compat.v1.reset_default_graph. If you have any more attribute errors, you can look at the tensorflow documentation.","Q_Score":0,"Tags":"python,tensorflow,google-colaboratory","A_Id":62598671,"CreationDate":"2020-06-26T16:00:00.000","Title":"module 'Tensorflow' has no atributte","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using chatterbot, I want to send clickable link and Mail as per message sent by the user. I cant find any link or reference on how to do this","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":72,"Q_Id":62599758,"Users Score":0,"Answer":"Try using linkify.... pip install autolink... linkify (bot.get_response(usr_text))","Q_Score":0,"Tags":"python,flask,bots,chatterbot","A_Id":62600578,"CreationDate":"2020-06-26T17:16:00.000","Title":"How to send clickable link and Mail in Chatterbot flask app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Ive got two separate models, one for mask recognition and another for face recognition. The problem now is that how do I combine these both models so that it performs in unison as  a single model which is able to :-\n\nRecognize whether or not a person is wearing mask\nSimultaneously recognize who that person is if he isn't wearing mask apart from warning about no mask.\n\nWhat are the possibilities I have to solve this problem!!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":42,"Q_Id":62600397,"Users Score":1,"Answer":"You don't have to combine the both models and train them you have to train them seprately. And after training the model first you have to check with the mask detection model what's the probability\/confidence score that there's a mask detected and if the probability is low say like 40%-45% then you have to use the other model that recognises the person.","Q_Score":0,"Tags":"python,machine-learning,deep-learning,computer-vision,face-recognition","A_Id":62601074,"CreationDate":"2020-06-26T17:58:00.000","Title":"How to train a model for recognizing two objects?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been attempting to create a model that given an image, can read the text from it. I am attempting to do this by implementing a cnn, rnn, and ctc. I am doing this with TensorFlow and Keras. There are a couple of things I am confused about. For reading single digits, I understand that your last layer in the model should have 9 nodes, since those are the options. However, for reading words, aren't there infinitely many options, so how many nodes should I have in my last layer. Also, I am confused as to how I should add my ctc to my Keras model. Is it as a loss function?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":62602511,"Users Score":0,"Answer":"I see two options here:\n\nYou can construct your model to recognize separate letters of those words, then there are as many nodes in the last layer as there are letters and symbols in the alphabet that your model will read.\nYou can make output of your model as a vector and then \"decode\" this vector using some other tool that can encode\/decode words as vectors. One such tool I can think of is word2vec. Or there's an option to download some database of possible words and create such a tool yourself.\nDescription of your model is very vague. If you want to get more specific help, then you should provide more info, e.g. some model architecture.","Q_Score":1,"Tags":"python,tensorflow,machine-learning,keras","A_Id":62602819,"CreationDate":"2020-06-26T20:38:00.000","Title":"model for hand written text recognition","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between using the pickle library and using with open()?\nBoth have the same functionality where you read and write into the file and I don't see any differences between them.\nAnd why do many people use pickle more than with open()  if it is so seemingly similar?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":795,"Q_Id":62603777,"Users Score":1,"Answer":"The difference is in what you put in the file, and who is responsible for the underlying file's format \/ serialization.\nWith the builtin open, you receive a raw file handle.  You can write whatever you want to it.  It doesn't have to be structured, it doesn't have to be consistent, hell it doesn't even have to make sense to an outside observer.  You are allowed to write whatever you want to a file.\nWith a pickle, the underlying module is responsible for what is written.  It serializes python objects (as much as possible, there are examples of classes that cannot be pickled) in a consistent, reproducible format that can the be re-loaded.  IE - you can save the state of actual python objects in a static file, and then reload them and end up with identical objects the next the the interpreter runs.  This has advantages when dealing with stateful programs.\nBonus:  The shelve module serves as a user-friendly frontend to pickle that behaves like a dictionary.  When you close the shelf, the contents are serialized to disk.  When you re-open the shelf, the objects are deserialized from the file and accessible the same way a dictionary would be.","Q_Score":3,"Tags":"python,pickle,with-statement","A_Id":62603894,"CreationDate":"2020-06-26T22:39:00.000","Title":"Difference between pickle and opening a file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between using the pickle library and using with open()?\nBoth have the same functionality where you read and write into the file and I don't see any differences between them.\nAnd why do many people use pickle more than with open()  if it is so seemingly similar?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":795,"Q_Id":62603777,"Users Score":2,"Answer":"Let me see if I can understand where the point of confusion is and give a useful explanation.\nopen is how you get a file object, which is the interface between your Python program and an actual file on disk. with is a tool used for ensuring that the file object is closed at the appropriate time.\nThe file object allows you to read and\/or write the file, depending on how it was opened. The built-in way to do this is with the object's own functionality. This lets you write whatever data you want, at the expense that you are responsible for figuring out what that data should be; alternately, it lets you read the data and gives you both the power and responsibility that comes from interpreting that data.\nThe pickle library builds on top of that functionality, to use the file's contents to represent native Python objects. It does the interpretation (parsing) and data-figuring-out (formatting) work for you, accomplishing something that would be difficult by hand. The trade-off is that it works in a specific way, and is fit for only a specific purpose - you won't, for example, be producing or interpreting plain text files, or images, or JSON data, etc. this way any time soon (which you could by writing the data yourself, or by using a different, special-purpose library - except of course for plain text, where there's no point in doing anything beyond using the built-in functionality).","Q_Score":3,"Tags":"python,pickle,with-statement","A_Id":62603882,"CreationDate":"2020-06-26T22:39:00.000","Title":"Difference between pickle and opening a file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to draw vector graphics on a canvas using Python's Tkinter and I was excited when I noticed that canvases have a postscript() method that can save the contents of the canvas to a Postscript file and it's fairly trivial to losslessly convert SVG to EPS.\nMy question is this: can it do the reverse?  Can I take a postscript file from the disk and unpack it onto the canvas?  Is Tk a powerful enough graphics toolkit for that?\nor would I be better off just rendering the svg down to a GIF image (or parsing the EPS file using PIL and converting it to a pixel array that way) and displaying that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":212,"Q_Id":62603968,"Users Score":0,"Answer":"Can a Tk canvas import a postscript file and display it?\n\nNo, it cannot.","Q_Score":0,"Tags":"python,tkinter,tk,tkinter-canvas,postscript","A_Id":62604416,"CreationDate":"2020-06-26T22:59:00.000","Title":"Can a Tk canvas import a postscript file and display it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use flask-Socketio. But the problem is that the sessionId (sid) is transmitted in the URL. Which means that anybody sniffing can steal the sessionId.\nHow can flask send the sessionId backin a Post?\nThanks in advance for any help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":187,"Q_Id":62605638,"Users Score":0,"Answer":"Your production server should use SSL so that nobody can see the contents of the requests and responses that are exchanged.\nThe session ID in the URL is part of the Socket.IO protocol, not a choice of the Flask-SocketIO package. To be accurate, the server sends the session id in a JSON response, and then the client adds it to the URL in follow-up requests. That's how the protocol works.\nData included in the JSON response can also be picked up by intermediaries if not encrypted, this isn't a problem specific to the URL. The solution is to use encryption.","Q_Score":0,"Tags":"security,socket.io,flask-socketio,flask-session,python-socketio","A_Id":62621757,"CreationDate":"2020-06-27T03:50:00.000","Title":"flask-SocketIO sessionId in URL not secure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I decided to ask this here after googling for hours. I want to create my own API endpoint on my own server.\nEssentially I want to be able to just send a yaml payload to my server, when received I want to kick off my python scripts to parse the data and update the database. I'd also like to be able to retrieve data with a different call. I can code the back-end stuff, I just don't know how to make that bridge between hitting the server from outside and having the server do the things in the back-end in python.\nIs django the right way? I've spent a couple days doing Django tutorials, really cool stuff, but I don't really need a website right now but whenever I search for web and python together, django pretty much always comes up. I don't need any python code help, just some direction on how to create that bridge.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":62605840,"Users Score":0,"Answer":"DRF was what I was looking for. As suggested.","Q_Score":0,"Tags":"python,django,api-design","A_Id":62650822,"CreationDate":"2020-06-27T04:24:00.000","Title":"creating an api to update postgres db with a json or yaml payload","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Requirements are:\n\nStarting of the sentences must be a word with its first letter in capitals ( As, The, In) ONLY and the end of the sentence should be a dot.\neg:\nInput: \"This is a new book. I like to read this book\" \nExpected Output: ['This is a new book.' , 'I like to read this book']\n\nHowever, if there is citation present at the end of the sentence, it should be included in the sentence. In this case, the dot might be after the citation (or) before and after the citation.\n\n\neg:\nInput: \"This is a new book.(Steve and Rasol 2014). I like to read this book (Rashi & Shabana 2015).\"\nExpected Output: ['This is a new book.(Steve and Rasol 2014)' , 'I like to read this book (Rashi & Shabana 2015).']","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":262,"Q_Id":62607996,"Users Score":0,"Answer":"Since the data you listed is seperated by .  you can split the data into an array with array = data.split('. ') command. Moreover for adding . at the end of each item you can iterate over the array and check if . exist at the end if not then append it.","Q_Score":0,"Tags":"python,text,split,nlp","A_Id":62608453,"CreationDate":"2020-06-27T09:08:00.000","Title":"How to split text to sentences when my text has many dots in-between sentences?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning about the Gradient Descent Algorithm and I implemented one such**(in python)** over the Boston Housing data set(in sklearn). I have implemented a cost function as well which takes in all the coefficients, the intercept and the training data and returns the cost for those coefficients and intercept. I ran the algorithm over the Boston data set for 1500 iterations and learning_rate = 0.000003202, and It converged successfully, giving the least cost as 61.840725406571245, but when I trained the sklearn's LinearRegression() algorithm over the same training data, and found the cost using .coef_ and .intercept_. It gave the least cost as 19.958219814238042. So My question is How can one say the a certain number of iterations, will give me the least\/optimal cost? Like say I run the algorithm for n times, and obtain a particular cost, then How will I know that this cost is good enough or do I need to reduce it further?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1157,"Q_Id":62608927,"Users Score":0,"Answer":"You can use validation sets in training. They will be a better indicator for the testing phase of your model performance than only the training error. Also, your learning_rate is quite small, which can cause the model to converge in large number of iterations. You can play with those parameters to see how it effects your training.","Q_Score":0,"Tags":"python,machine-learning,regression,gradient-descent","A_Id":62609207,"CreationDate":"2020-06-27T10:44:00.000","Title":"Number of Iterations (Gradient Descent)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The key strike work. Menu drops down. Shows nothing. Maybe files. This continue in all projects.\nIt also high-lights imports as if it\u2019s not there. But the project operates just the same.\nI don\u2019t know is this is a root\/path issue.\nShowed others and asked around and No One has any ideas. This has been hurting my productivity and learning. Tried uninstalling and reinstalling through Brew. Problem persists.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":39,"Q_Id":62609872,"Users Score":1,"Answer":"Uh, have you tried Ctrl+Shift+P ?","Q_Score":0,"Tags":"python,django,macos,visual-studio-code,macos-catalina","A_Id":62609947,"CreationDate":"2020-06-27T12:12:00.000","Title":"Why does the Vscode command pallet does not 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to use PyCharm Community Edition 2020.1.2 x64 on Windows 10 as IDE for writing QGIS plugins. I need to base on old version - QGIS 2.18, so I need python 2.7, qt4, and also core modules from QGIS 2.18. I downloaded QGIS 2.18 from official site. It provides a ready to use python environment as .bat script, that sets all needed python paths. So I used path D:\\Program Files\\QGIS 2.18\\bin\\python-qgis-ltr.bat to set main python interpreter for my project.\nAfter that I was able to run python console in PyCharm, import all QGIS modules, and any classes from QGIS standard collection like QgsFeature, QgsVectorLayer etc. Everything was fine untill I tried to import this classes from PyCharm editor in .py file as from qgis.core import QgsFeature. In editor PyCharm sees the package qgis.core and I'm able to import it, but PyCharm's code completion inside the module sees only classes that are saved in D:\\Program Files\\QGIS 2.18\\apps\\qgis-ltr\\python\\qgis\\core\\__init__.py e.g. QgsEditError class, but all standard QGIS class underlines on red.\nPython console ran on exactly the same interpreter see the same sources as are visible in \"External Libraries\" tab in PyCharm, so command:\n\nqgis.core.__path__ returns ['D:\\\\Program Files\\\\QGIS 2.18\\\\apps\\\\qgis-ltr\\\\python\\\\qgis\\\\core'],\nqgis.core.__file__ returns 'D:\\\\Program Files\\\\QGIS 2.18\\\\apps\\\\qgis-ltr\\\\python\\\\qgis\\\\core\\\\__init__.pyc,\ndir(qgis.core) returns full list of QGIS standard core classes.\n\nIf I run the .py script, in which PyCharm's code validator is showing incorrect import object by red underline, the script is executed without any error and I can easly print the imported QgsFeature object. Why my PyCharm's editor see different content of qgis.core module then console ran also from IDE on exactly the same interpreter?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":350,"Q_Id":62610799,"Users Score":0,"Answer":"Finally, the problem solved itself. It was something wrong with building a binary skeletons of C++ libraries, what PyCharm does every time the application is launched. My PyCharm didn't want to do it and I found many similar problems with other libraries (e.g. Qt) that people were struggling with. After two days my PyCharm just fixed itself and created all needed binary skeletons for my QGIS libraries.","Q_Score":0,"Tags":"python,import,module,pycharm,qgis","A_Id":62722097,"CreationDate":"2020-06-27T13:43:00.000","Title":"Missing classes from qgis.core module only in PyCharm's editor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to JavaScript and noticed when I install libraries using npm the node_modules folder is large and it's taking much time and that's not the case in python when I install Django or any library for example!\nso how NodeJs is different from Python at installing packages?\nI searched on Quora, YouTube, reddit and didn't found a clear comparison between both","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1268,"Q_Id":62610987,"Users Score":1,"Answer":"npm uses local dependencies, so the same module is installed over and over again for every project and every transitive dependency. pip uses global dependencies (at least global to the virtualenv, if used) which avoids this.\nApart from that, pythons standard library is much more larger than the one found in javascript. Thus, much more packages are needed in JS compared to python. Additionally, aspects like transpilation (Babel) are more prevalent in JS than in python.","Q_Score":0,"Tags":"python,node.js,npm,pip,node-modules","A_Id":62611148,"CreationDate":"2020-06-27T14:01:00.000","Title":"why node_modules are so heavy and python dependencies are light?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have this set:\noptimal = {(0,1),(2,1),(1,1)}\nI want to get the very first tuple from the set.\nThe desired output is:\n(0,1)\nHow can I do this?","AnswerCount":3,"Available Count":1,"Score":-0.1325487884,"is_accepted":false,"ViewCount":105,"Q_Id":62611688,"Users Score":-2,"Answer":"use optimal.pop() it returns the first value from the set.","Q_Score":0,"Tags":"python,set,tuples","A_Id":62611733,"CreationDate":"2020-06-27T15:05:00.000","Title":"Getting first tuple from a set","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an android app that consumes Django REST APIs. The app is capturing several parameters and has 50-60 images captured. The data is being sent to the server which then parses JSON, uploads all images to cdn server and inserts that data into PostgreSQL tables depending on some logic. I am generating a PDF report using WK-HTML fetching back the same data. This PDF needs to be sent as response to API call. This entire process is taking time while the user is waiting on the app for PDF file.\nOne thing I could do is use the JSON to generate PDF but I am not sure if all the images have been uploaded to CDN and can be used in PDF report.\nHow can I achieve better results? Any guidance will be really appreciated.\nTIA.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":62612393,"Users Score":0,"Answer":"You can run the generation in the background and send the user a notification with download link when it is ready.","Q_Score":0,"Tags":"python,django,multithreading,django-rest-framework,multitasking","A_Id":62613756,"CreationDate":"2020-06-27T16:07:00.000","Title":"Multiple Tasks in Serial Order Python Django Framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've been looking across the internet to find some sort of library that will connect an Oracle database to a Python script, but so far I have been unsuccessful. If anyone has found a great library for Oracle, preferably first party, then please give me documentation. I'm working on a project now that particularly needs this integration. I've already seen lots of documentation for MySQL, which is maintained by Oracle, but that's about it.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":62612782,"Users Score":0,"Answer":"Oracle provides the python library cx_Oracle. Like everything else produced by Oracle, the documentation leaves some to be desired and the drivers are an absolute pain in the ass, but it works.","Q_Score":0,"Tags":"python,sql,oracle","A_Id":62613581,"CreationDate":"2020-06-27T16:41:00.000","Title":"Is there a Python library for Oracle SQL?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to import matplotlib, here is how it looks.\nwhen i click run, it shows me nothing but the whole codeimport matplotlibturns to grey. It happened every module I load in. I want to know is it normal?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":24,"Q_Id":62614203,"Users Score":1,"Answer":"Pycharm does this whith the import statements that are not used, so you can keep control of which modules the code is actually using. It will be normal again once you use it in your code.","Q_Score":0,"Tags":"python,matplotlib,pycharm","A_Id":62614430,"CreationDate":"2020-06-27T18:47:00.000","Title":"How do I successfully load matplotlib on Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why would one use assert False, 'error' vs raise AssertionError('error')?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":62614678,"Users Score":0,"Answer":"Just this:\n\nYou can then disable the assertion, by running your Python scripts with the -O switch.\nUsing assert gives consistency with other uses of assert, in the more common cases where the assertion is non-constant rather than just  0. (But False should really be used instead.)","Q_Score":0,"Tags":"python,python-3.x","A_Id":62614696,"CreationDate":"2020-06-27T19:33:00.000","Title":"assert 0, 'error' vs raise AssertionError('error')","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a website using flask. One of the pages is a list of in-house guests populated from a linked database. I want the name of each guest to be a link that when clicked will redirect to a new page that has that guest's specific infromation. I can create a template called 'guest.html' as normal, but I'm struggling to figure out how to tell the new template which guest was selected.\nHow can I retain the information of which link was clicked if they all essentially lead to the same template?\nI hope this isn't a silly question, I've looked for a while with no results.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":62618058,"Users Score":0,"Answer":"Build a new route like '\/profile' which takes a dynamic component like a username. So when a person clicks the name of the guest's username, the username is sent to the profile route. Now in the profile route function get the details of the guest from the database using the username from the route and pass the details of the guest to the guest.html and render the page. I hope this helps.","Q_Score":0,"Tags":"python,html,flask,jinja2,flask-sqlalchemy","A_Id":62619040,"CreationDate":"2020-06-28T03:59:00.000","Title":"Create a list of links in flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i have a django project with 50 url (in 1 application).\ni would set a custom middleware for 20 urls.\nwhen add middleware to MIDDLEWARE_CLASSES , this set for all urls .\nHow should this be done?\n(i use last version of python and djnago)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1455,"Q_Id":62618099,"Users Score":0,"Answer":"you can either add a check condition to your middleware which is not recommended(since you cannot determine whether this middleware is working or not without reading it's code). or create a decorator for those views, decorator job is exactly this.","Q_Score":1,"Tags":"python,django","A_Id":62618505,"CreationDate":"2020-06-28T04:07:00.000","Title":"how i can set middleware for some views in django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm still new to AWS ecosystem and doing a POC on certain components of aws. I have to match CSVs data with Redshift table data - col to col match. Can anybody direct me to point where I can get an idea how to execute above. Thanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":251,"Q_Id":62618797,"Users Score":0,"Answer":"One way to do this can be like\n\nCreate a glue catalog (No cost)\nCreate external table using redshift query editor (Still no cost and no need to run crawler as well)\nNow you have the data as a table.\nCompare both the table one in your redshift cluster and another one is extenal table.\n\nThe only cost that will be incurred is of scanning the data while running query which is equal to 5$ per TB.","Q_Score":1,"Tags":"python,python-3.x,amazon-s3,amazon-redshift","A_Id":62636653,"CreationDate":"2020-06-28T05:57:00.000","Title":"Match CSV columns data sitting at S3 with Redshift table column data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed 64-bit Python and uninstalled 32-bit Python so that I can use tensorflow. Now when I try to use Jupyter I get:\nFatal error in launcher: Unable to create process using '\"c:\\users\\username\\appdata\\local\\programs\\python\\python38-32\\python.exe\"  \"C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python38-32\\Scripts\\jupyter.exe\" --runtime-dir': The system cannot find the file specified.\nWhat's the best way to fix this? Do I have to reinstall Jupyter or can I just change the specified executables?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":645,"Q_Id":62619115,"Users Score":0,"Answer":"Yes You should reinstall Juypter notebook It's best and easy way to fix it.","Q_Score":0,"Tags":"python,python-3.x,jupyter-notebook","A_Id":62619325,"CreationDate":"2020-06-28T06:42:00.000","Title":"How to get Jupyter working after Python change 32bit -> 64bit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a program running on Google Colab in which I need to monitor GPU usage while it is running.  I am aware that usually you would use nvidia-smi in a command line to display GPU usage, but since Colab only allows one cell to run at once at any one time, this isn't an option.  Currently, I am using GPUtil and monitoring GPU and VRAM usage with GPUtil.getGPUs()[0].load and GPUtil.getGPUs()[0].memoryUsed but I can't find a way for those pieces of code to execute at the same time as the rest of my code, thus the usage numbers are much lower than they actually should be.  Is there any way to print the GPU usage while other code is running?","AnswerCount":6,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":17260,"Q_Id":62620268,"Users Score":17,"Answer":"If you have Colab Pro, can open Terminal, located on the left side, indicated as '>_' with a black background.\nYou can run commands from there even when some cell is running\nWrite command to see GPU usage in real-time:\nwatch nvidia-smi","Q_Score":15,"Tags":"python,gpu,google-colaboratory","A_Id":65461405,"CreationDate":"2020-06-28T08:49:00.000","Title":"Display GPU Usage While Code is Running in Colab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a program running on Google Colab in which I need to monitor GPU usage while it is running.  I am aware that usually you would use nvidia-smi in a command line to display GPU usage, but since Colab only allows one cell to run at once at any one time, this isn't an option.  Currently, I am using GPUtil and monitoring GPU and VRAM usage with GPUtil.getGPUs()[0].load and GPUtil.getGPUs()[0].memoryUsed but I can't find a way for those pieces of code to execute at the same time as the rest of my code, thus the usage numbers are much lower than they actually should be.  Is there any way to print the GPU usage while other code is running?","AnswerCount":6,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":17260,"Q_Id":62620268,"Users Score":4,"Answer":"There is another way to see gpu usage but this method only works for seeing the memory usage. Go to click runtime -> manage sessions. This allows you to see how much memory it takes so that you can increase your batch size.","Q_Score":15,"Tags":"python,gpu,google-colaboratory","A_Id":68175628,"CreationDate":"2020-06-28T08:49:00.000","Title":"Display GPU Usage While Code is Running in Colab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Traceback (most recent call last): File \"\/usr\/lib\/python3.6\/site-packages\/pgadmin4-web\/setup.py\", line 17, in  import builtins ImportError: No module named builtins","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":817,"Q_Id":62622492,"Users Score":1,"Answer":"Execute it with python3.  IE:\npython3 \/usr\/lib\/python3.6\/site-packages\/pgadmin4-web\/setup.py","Q_Score":0,"Tags":"python,centos7","A_Id":62642940,"CreationDate":"2020-06-28T12:22:00.000","Title":"Facing import builtins ImportError during installation of pgadmin4 in centos7?","Data Science and Machine Learning":0,"Database and SQL":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 anyone please explain the difference between generalized linear model and logistic regression model table with statsmodels. Why do I get different results with both the models while performing logistic regression??","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":859,"Q_Id":62622779,"Users Score":1,"Answer":"GLM is a generalized linear model and Logit Model is specific to models with binary classification. While using GLM model you have to mention the parameter family which can be binomial (logit model), Poisson etc. This parameter is not required in Logit model as its only for binary output. The difference in the output can be because of regularization parameters.","Q_Score":3,"Tags":"python-3.x,machine-learning,logistic-regression,statsmodels,glm","A_Id":65565144,"CreationDate":"2020-06-28T12:50:00.000","Title":"What is the difference between GLM and Logit model with statsmodels?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can anyone please explain the difference between generalized linear model and logistic regression model table with statsmodels. Why do I get different results with both the models while performing logistic regression??","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":859,"Q_Id":62622779,"Users Score":0,"Answer":"GLM with Binomial family and Logit link and the discrete Logit model represent the same underlying model and both fit by maximum likelihood estimation\nImplementation, default optimization method, options for extensions and the availability of some results statistics differs between GLM and their discrete counterparts.\nFor regular, well defined cases and well behaved data, both model produce the same results, up to convergence tolerance in the optimization and numerical noise.\nHowever, the behavior of the estimation methods can differ in corner cases and for singular or near-singular data.\nRelated aside:\nFor models with non-canonical links using GLM there can be differences in the definitions used across optimization methods, e.g. whether standard errors are based on expected or observed information matrix. With canonical links like logit those two are the same.","Q_Score":3,"Tags":"python-3.x,machine-learning,logistic-regression,statsmodels,glm","A_Id":65572173,"CreationDate":"2020-06-28T12:50:00.000","Title":"What is the difference between GLM and Logit model with statsmodels?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When reading events from a simple button in PySimpleGui, spamming this button with mouseclicks will generate an event for each of the clicks.\nWhen you try to do the same with Listboxes (by setting enable_events to True for this element) it seems like there is a timeout after each generated event. If you click once every second, it will generate all the events. But if you spam-click it like before it will only generate the first event.\nI'm not sure if this behavior is intended (only started learning PySimpleGui today), but is there a way to get rid of this delay? I tried checking the docs but can't find it mentioned anywhere.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":62622840,"Users Score":0,"Answer":"I think the reason is that a Listbox reacts to click events, but also to double click events. A Button does not. This behavior looks like consistent.","Q_Score":0,"Tags":"python,pysimplegui","A_Id":63131833,"CreationDate":"2020-06-28T12:56:00.000","Title":"PySimpleGui: how to remove event-delay in Listboxes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've a dataset with 48 obs (monthly) and python have been able to fit the SARIMAX ((4, 1, 3), (3, 0, 5)) model... which to me seems quite odd. How does it calculates the B^(12*5) term and the subsequent ones since I have just 48 data points?\nI've also tried with ((0, 1, 4), (5, 0, 1)) and it works... Also, I've computed the MAPE agaist the next 12 periods and it's quite good (3% and 6%).\nThoughts?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":62623481,"Users Score":1,"Answer":"Basically, estimation is done using the assumption that pre-sample observations are drawn from the unconditional distribution of the implied SARIMA process.\nSARIMAX models are estimated using a state space approach, and if you are a frequentist the this process is referred to as the \"initialization\" of the first state vector, while if you are a Bayesian then you would think of this as putting a particular prior on the first state vector (the state vector contains all the required lags of the process, so the \"initialization\", or prior, describes enough pre-sample observations to allow the model to be fit).\nWhile this is a perfectly reasonable approach to setting up the model so that it can be estimated, it doesn't necessarily mean that it is a good idea to specify a model with so many parameters and so few observations. Your estimates will begin to depend more on the prior rather than on the data.","Q_Score":1,"Tags":"python,statsmodels","A_Id":62650104,"CreationDate":"2020-06-28T13:53:00.000","Title":"Strange SARMAX fit with python statsmodels","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently working on a Benchmark project, where I'm trying to stress the server out with zmq requests.\nI was wondering what would be the best way to approach this,  I was thinking of having a context to create a socket and push it into a thread, in which I would send request and wait for responses in each thread respectively, but I'm not too sure this is possible with python's limitations.\nMore over, would it be the same socket for all threads, that is, if I'm waiting for a response on one thread (With it's own socket), would it be possible for another thread to catch that response?\nThanks.\nEDIT:\nTest flow logic would be like this:\nClient socket would use zmq.REQ.\nClient sends message.\nClient waits for a response.\nIf no response, client reconnects and tries again until limit.\nI'd like to scale this operation up to any number of clients, preferring not to deal with Processes unless performance wise the difference is significant..\nHow would you do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":161,"Q_Id":62624686,"Users Score":0,"Answer":"Q : \"...can I have one context and use several sockets?\"\n\nOh sure you can.\nMoreover, you can have several Context()-instances, each one managing  ... almost...  any number of Socket()-instances, each Socket()-instance's methods may get called from one and only one python-thread ( a Zen-of-Zero rule: zero-sharing ).\nDue to known GIL-lock re-[SERIAL]-isation of all the thread-based code-execution flow, this still has to and will wait for acquiring the GIL-lock ownership, which in turn permits a GIL-lock owner ( and nobody else ) to execute a fixed amount of python instructions, before it re-releases the GIL-lock to some other thread...","Q_Score":0,"Tags":"python,message-queue,benchmarking,zeromq,pyzmq","A_Id":62626820,"CreationDate":"2020-06-28T15:37:00.000","Title":"pyzmq - zmq_req can I have one context and use several sockets?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to have two versions of TensorFlow (tf) installed on my PC. Some of my programs run on tf v1 and some on tf v2. So, I can separately create two virtual environments (venv) one for tf v1 and another for tf v2, and use --use-system-packages for each venv for the other (global) package requirements for my codes. Then, I would keep my programs in the corresponding venv that has the correct tf version installed.\nHowever, for some specific reasons, I want to be able to use both versions of TensorFlow in a global environment too (i.e. without entering \/ activating a venv).\nQuestions:\nIs there a way where I can just install 2 versions of TensorFlow (and\/or numpy) in 2 venvs, and then access either of them in a global environment, using an import statement (with the version \/ venv to import from specified)? If this is not possible using venvs, is there any other way around to achieve the same?\nExtending the same further, suppose I am in a venv. I want to know if I can import packages that are installed in some other venv? If yes, how?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1418,"Q_Id":62626314,"Users Score":0,"Answer":"Problem definition:\nwe need to import two different versions of a Python package. Both versions have dependencies and provide the same namespace (tensorflow).\nWhy it is not possible: when Python loads a module (import tensorflow as tf), it tries to avoid redundant work and skips modules that were loaded already.\nSo, it is not possible to load the same namespace from two different locations.\nFew fun facts:\n\nYou can manipulate paths where Python will look for a module at runtime. When loading a module for the first time, Python will go through a list of directoris in sys.path, looking for the requested namespace. Directories in sys.path are installation dependent, but usually go in this order: local directory, builtin modules, installed packages. The last one is a directory or a set of directories where your package manager (pip, easy_install, ...) stores installed packages. It is usually more than one location, including packages installed system-wide, user folder (e.g. ~\/.local\/lib\/pythonX.Y\/site-packages), and virtual environment-specific folder (e.g. xxx.venv\/lib\/pythonX.Y\/site-packages). Depending on the setup, you can have any combination of these. The fun part is that you can insert new directories: sys.path[6:6] = ['path\/to\/another\/venv\/lib\/pythonX.Y\/site-packages']. However, it won't help getting two instances of the same namespace because of caching.\nIn sys.path folders, Python will look for a module with matching name, which represents a namespace. Python package names are often the same as the namespace they provide, but they can also be different. For example, in pip install numpy the last portion is a package name, but in import numpy it is a namespace. Roughly 1\/3 of all PyPI packages' namespaces are different from the package name, for example package intel-numpy also provides namespace numpy. If you install intel-numpy, pip will silently overwrite the folder (and so, the content of the namespace) previously provided by numpy. Yep, Python package managers keep track of installed package names, but not namespaces. So, even if two versions of a package provide different namespaces, you cannot have them both. But if you have two different packages providing the same namespace, pip will be happy to install both, but will only keep the last installed.\nIf two versions of the same package provide different namespaces, you can install them different virtual environments, then manipulate sys.path to include packages from both and get both namespaces at the same time. Not our case, though.\nAnother option: repackage one version of the package, renaming the namespace. In this case, it's easier to also change the package name and install them in the same place\/venv. You might even reupload this repackaged version of the package to PyPI (I've seen people doing this), but it won't work with TF and any other non-trivial packages because of the diference in dependency versions. Fun fact: Python package managers don't resolve dependency versions; if package A requires C==1.0 and B requires C==2.0, after installing A and B you will get only one version of C, crippling either A or B.\n\nFinally, why you should not do that: it is against Python principles. Explicit is better than implicit, and manipulating library paths at runtime is not the most transparent and supportable approach. Still, the problem of maintaining a compatible set of dependencies is real, and this is why we have venv, pipenv etc.\nFrom the language design perspective, dealing with multiple versions of the same package does have its benefits and was adopted by several languages (e.g. JS). However, it makes imports a lot more expensive. Historically, this is a niche scenario for Python community, so it doesn't outweigh the performance penalty.","Q_Score":0,"Tags":"python,tensorflow,virtualenv","A_Id":62631218,"CreationDate":"2020-06-28T17:57:00.000","Title":"Can I import a package installed in one virtual environment in global or another virtual environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering how would I run my 2 discord bots at once from main, app.py, file.\nAnd after I kill that process (main file process), they both would stop.\nTried os.system, didn't work. Tried multiple subprocess.Popen, didn't work.\nAm I doing something wrong?\nHow would I do that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2390,"Q_Id":62627581,"Users Score":0,"Answer":"I think the good design is to have one bot per .py file. If they both need code that is in app.py then they should 'import' the common code. Doing that you can just run both bot1.py and bot2.py.","Q_Score":1,"Tags":"python,discord.py","A_Id":62627674,"CreationDate":"2020-06-28T19:56:00.000","Title":"How to start multiple py files (2 discord bots) from one file 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":0,"Web Development":0},{"Question":"I have tried all of the things here on stack and on other sites with no joy...\nI'd appreciate any suggestions please.\nI have installed Jupyter and Notebook using pip3 - please note that I have updated pip3 before doing so.\nHowever when trying to check the version of both jupyter --version and notebook --version my terminal is returning no command found. I have also tried to run jupyter, notebook and jupyter notebook and I am still getting the same message.\nI have spent nearly two days now trying to sort this out... I'm on the verge of giving up.\nI have a feeling it has something to do with my PATH variable maybe not pointing to where the jupyter executable is stored but I don't know how to find out where notebook and jupyter are stored on my system.\nmany thanks in advance\nBobby","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1681,"Q_Id":62628450,"Users Score":3,"Answer":"So to summarise this is what I have found on this issue (in my experience):\nto run the jupyter app you can use the jupyter-notebook command and this works,  but why? This is because, the jupyter-notebook is stored in usr\/local\/bin which is normally always stored in the PATH variable.\nI then discovered that the jupyter notebook or jupyter --version command will now work if I did the following:\n\nopen my .\/bash_profile file\nadd the following to the bottom of the file: export PATH=$PATH:\/Users\/your-home-directory\/Library\/Python\/3.7\/bin\n\nthis should add the location of where jupyter is located to your path variable.\nAlternatively, as suggested by @HackLab we can also do the following:\n\npython3 -m jupyter notebook\n\nHopefully, this will give anyone else having the same issues I had an easier time resolving this issue.","Q_Score":4,"Tags":"python,pip,jupyter-notebook,jupyter","A_Id":62786245,"CreationDate":"2020-06-28T21:34:00.000","Title":"pip3 install of Jupyter and Notebook problem when running","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried all of the things here on stack and on other sites with no joy...\nI'd appreciate any suggestions please.\nI have installed Jupyter and Notebook using pip3 - please note that I have updated pip3 before doing so.\nHowever when trying to check the version of both jupyter --version and notebook --version my terminal is returning no command found. I have also tried to run jupyter, notebook and jupyter notebook and I am still getting the same message.\nI have spent nearly two days now trying to sort this out... I'm on the verge of giving up.\nI have a feeling it has something to do with my PATH variable maybe not pointing to where the jupyter executable is stored but I don't know how to find out where notebook and jupyter are stored on my system.\nmany thanks in advance\nBobby","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":1681,"Q_Id":62628450,"Users Score":1,"Answer":"have you tried  locate Jupiter? It may tell you where jupyter is on your system.\nAlso, why not try installing jupyter via anaconda to avoid the hassle?","Q_Score":4,"Tags":"python,pip,jupyter-notebook,jupyter","A_Id":62651149,"CreationDate":"2020-06-28T21:34:00.000","Title":"pip3 install of Jupyter and Notebook problem when running","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What the difference between att_mask and key_padding_mask in MultiHeadAttnetion of pytorch:\n\nkey_padding_mask \u2013 if provided, specified padding elements in the key will be ignored by the attention. When given a binary mask and a value is True, the corresponding value on the attention layer will be ignored. When given a byte mask and a value is non-zero, the corresponding value on the attention layer will be ignored\n\n\nattn_mask \u2013 2D or 3D mask that prevents attention to certain positions. A 2D mask will be broadcasted for all the batches while a 3D mask allows to specify a different mask for the entries of each batch.\n\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3279,"Q_Id":62629644,"Users Score":16,"Answer":"The key_padding_mask is used to mask out positions that are padding, i.e., after the end of the input sequence. This is always specific to the input batch and depends on how long are the sequence in the batch compared to the longest one. It is a 2D tensor of shape batch size \u00d7 input length.\nOn the other hand, attn_mask says what key-value pairs are valid. In a Transformer decoder, a triangle mask is used to simulate the inference time and prevent the attending to the \"future\" positions. This is what att_mask is usually used for. If it is a 2D tensor, the shape is input length \u00d7 input length. You can also have a mask that is specific to every item in a batch. In that case, you can use a 3D tensor of shape (batch size \u00d7 num heads) \u00d7 input length \u00d7 input length. (So, in theory, you can simulate key_padding_mask with a 3D att_mask.)","Q_Score":12,"Tags":"python,deep-learning,pytorch,transformer,attention-model","A_Id":62633542,"CreationDate":"2020-06-29T00:31:00.000","Title":"what the difference between att_mask and key_padding_mask in MultiHeadAttnetion","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to upload a python lambda function via a zip file. I copied all of my python files into a directory called \"lambda\", installed all of the libraries directly into that directory, did chmod -R 755 . to make sure all of those files are executable, and then zipped the directory with zip -r ..\/analysis.zip .\nThe file that holds my lambda function is called \"main.py\" and the lambda function is called \"handler\", so by AWS Lambda convention, I set the file it should be looking for to main.handler in the AWS Lambda page. I check my cloudwatch logs for this lambda function and still get an error saying aws cannot find the main module and also cannot find some regex._regex module as well.\nThis is the official error:\n[ERROR] Runtime.ImportModuleError: Unable to import module 'main': No module named 'regex._regex'\nDoes anyone know what can be the problem? I have deployed aws lambda functions before using the same process and this is the first time I am getting this issue.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":612,"Q_Id":62630980,"Users Score":0,"Answer":"Lambda operates on a Python function\/method not at the file. So the function handler must point to a actual function\/method not a file.\nSo within your main.py file, there must be a function e.g. test_function, and your handler has to be main.test_function. The name of the function in AWS is irrelevant to the function.\nHope that helps.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda","A_Id":62635247,"CreationDate":"2020-06-29T03:56:00.000","Title":"Why does AWS Lambda not able to find my main.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":"I am trying to upload a python lambda function via a zip file. I copied all of my python files into a directory called \"lambda\", installed all of the libraries directly into that directory, did chmod -R 755 . to make sure all of those files are executable, and then zipped the directory with zip -r ..\/analysis.zip .\nThe file that holds my lambda function is called \"main.py\" and the lambda function is called \"handler\", so by AWS Lambda convention, I set the file it should be looking for to main.handler in the AWS Lambda page. I check my cloudwatch logs for this lambda function and still get an error saying aws cannot find the main module and also cannot find some regex._regex module as well.\nThis is the official error:\n[ERROR] Runtime.ImportModuleError: Unable to import module 'main': No module named 'regex._regex'\nDoes anyone know what can be the problem? I have deployed aws lambda functions before using the same process and this is the first time I am getting this issue.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":612,"Q_Id":62630980,"Users Score":0,"Answer":"By the description and error message your naming convention seems right.\nThe error message indicates that you're missing the regex module. However, from your description you seem to have packaged the dependancies correctly.\nUsually, it would then be a case of a runtime miss match. However, I have had struggles with regex and lambda when runtimes do match. By default now, I don't go above python 3.6 at the moment. I have struggled with other dependancies on lambda, such as pickle, on higher versions recently. Whilst everything seems to operate fine on 3.6.\nI got rid of the regex error on lambda with python 3.6 by downloading the taar.gz file from pypi and running setup.py... rather than pip3 install. It's a bit of pain, but it worked.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda","A_Id":62635592,"CreationDate":"2020-06-29T03:56:00.000","Title":"Why does AWS Lambda not able to find my main.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":"I am working on Audio Classification and using Spectrograms and MFCC plots im order to train CNN image classifier. Currently, I have two separate ConvNets trained on these features giving average ( 55-60% accuracy ). I have two separate weight files for each model.\nNow I want to combine the two models i.e. I want to extract Spectrograms and MFCC from each audio file and test on my already built models and get higher accuracy. How can I do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":146,"Q_Id":62631685,"Users Score":1,"Answer":"One way to combine already trained models would be to use a common fully-connected layer and train the network.\nYou can place this fully-connected layer at the end of both the convolutional models.\nSo, input will go into ConVModel-1 and ConvModel-2. You will get 2 output vectors. Combine these 2 output vectors (concatenate, average, etc.). Now pass this newly formed vector to the fully connected layer.\nYou can now train this network in 2 ways -\n\nUpdate weights for only the FC layer.\nUpdate weights for FC layer + both the ConvModels.","Q_Score":1,"Tags":"python,image,tensorflow,conv-neural-network,audio-processing","A_Id":62631893,"CreationDate":"2020-06-29T05:20:00.000","Title":"Combining Convolution Neural Network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"2 questions :\n\nWhen we delete\/drop a dataframe and use gc.collect(), Does the python empty the ram occupied?\n\nif we do df.to_csv(filename), will that df be referring to the file after that or the data still being referred from in-memory(RAM)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":62632339,"Users Score":0,"Answer":"When we delete\/drop a dataframe and use gc.collect(), Does the python empty the ram occupied?\n\n\nYes, it will be empty space in the RAM.\n\n\nIf we do df.to_csv(filename), will that df be referring to the file after that or the data still being referred from in-memory(RAM)?\nNo, it will be not refer from the file it will still refer to the df variable.","Q_Score":0,"Tags":"python,pandas,memory,ram","A_Id":62632853,"CreationDate":"2020-06-29T06:22:00.000","Title":"Python Pandas memory management","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are there any rules when it comes to determining the Order and the Seasonal Order in a SARIMA?\nI have noticed that when I use StatsModels in Python I can't choose a seasonal lag that is below or equal to the number of AR lags.\nExample:\nI am running a SARIMA with order (3,1,3) and seasonal order (3,1,3,3).\nThis generates an error: ValueError: Invalid model: autoregressive lag(s) {3} are in both the seasonal and non-seasonal autoregressive components.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":973,"Q_Id":62634182,"Users Score":4,"Answer":"Specifying an order of (3, *, *) includes lags 1, 2, and 3\nSpecifying a seasonal order of (3,,,3) includes lags 3, 6, 9, and 12.\n\nBy specifying this model, you would be including the third lag twice, which can cause numerical problems when estimating the parameters.\nInstead, you should specify: order=(2, 1, 3) and seasonal_order=(3, 1, 3, 3). Then you will include the third lag as you want, but you won't have a duplicate.","Q_Score":2,"Tags":"python,time-series,arima","A_Id":62650035,"CreationDate":"2020-06-29T08:34:00.000","Title":"Are there any rules when it comes to determining the Order and the Seasonal Order in a SARIMA?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to run Ansible tasks with python3 as the interpreter (there are lots of reasons for why to go to python3 ... one of them being that python2 will not be supported anymore by Ansible).\nUnfortunately, doing that on RedHat 7 is not possible as I can't install python3-dnf there (it seems this package is available only for RedHat 8).\nDoes anyone had that issue and founded a solution for it?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":6162,"Q_Id":62634946,"Users Score":1,"Answer":"I'm one if the Ansible maintainers for the yum and dnf modules. Python 2 will continue to be supported for the remote hosts (hosts in the inventory that you are automating tasks on) but not the controller node (where your are actually running the ansible-playbook command). You can safely continue to use Python 2 on the remote RHEL7 hosts so long as you are running Ansible from a control node that's on Python 3, and even that restriction doesn't exist for the current stable release of Ansible (2.9.10 at the time of this writing) but only for future releases. Hope this helps, happy automating!","Q_Score":3,"Tags":"python,ansible,redhat","A_Id":62650360,"CreationDate":"2020-06-29T09:16:00.000","Title":"Ansible with Python3 on RedHat\/CentOS 7 (python3-dnf issues)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have have installed VS Code and Python 3 using brew on my mac.\nAdded the Python extension from Microsoft.\nWorks fine.\nMy problem is that I don't see PYTHON as a possible format in the drop down list when I am trying to do a \"Save as\". Only MagicPython is shown as an option.\nI can force with an extension say test.py or I select the MagicPython option, but it gets saved as test.gyp\nNo Difference in functionality, but would like my files to get saved as .py\nIs this possible?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":953,"Q_Id":62636597,"Users Score":1,"Answer":"I am having the same problems on my Mac too.\nSave it as test.gyp first.\nThen open it again in VS Code and go to File -> Save As.\nNow it should be having a name of test.gyp, change this to test.py and click Save.\nIt should now be in the .py format, it worked for me.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":66251038,"CreationDate":"2020-06-29T10:56:00.000","Title":"MagicPython(.gyp) to Python(.py) in vscode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a game using pygame. Whenever I share it with my friends I also have to send them all the images, fonts, and audio files. Is there any way where I can only send the .exe file and not the media files?\n(I made the exe using auto-py-to-exe)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":62637392,"Users Score":0,"Answer":"Couldn't you make it a .zip or .rar and make your friends extract it?\nThat is the best solution, because or else you wouldn't just need to give them the images but they'd also have to download all the libraries and if you already have a .zip file just add the images into it\nI hope this helped you\nHappy coding - BSK - SK Studio","Q_Score":0,"Tags":"python,pygame","A_Id":62728324,"CreationDate":"2020-06-29T11:45:00.000","Title":"Made a game with pygame but i have to send all the images to my friends with the exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe which has 10 000 rows.\nI need to extract the rows into a new dataframe according to a condition (where name is in name_list)\nWhat is the easiest way to do this","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":62640558,"Users Score":1,"Answer":"Let's say this is your dataframe structure and name:\ndataframe = pd.DataFrame(record, columns = ['Name', 'Age', 'Stream', 'Percentage']\nAccordingly, the new dataframe can be created as :\nrslt_df = dataframe[dataframe['Name'].isin(name_list)]\nalternatively, you can use :\nrslt_df = dataframe.loc[dataframe['Name'].isin(name_list)]","Q_Score":0,"Tags":"python,dataframe","A_Id":62640912,"CreationDate":"2020-06-29T14:40:00.000","Title":"Python: Append from one dataframe to a new dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I install a specific version of tensorflow on windows ?(I'm using pip 20.1.1 and python 3.8)\nI've tried the command\npip install tensorflow==1.14.0 \nI get the following error\n\nERROR: Could not find a version that satisfies the requirement\ntensorflow==1.14.0 (from versions: none) ERROR: No matching\ndistribution found for tensorflow==1.14.0\n\nI've also tried using to install it by downloading the .whl file by running the command\npip install C:\\Users\\Admin\\Downloads\\tensorflow-1.14.0-cp37-cp37m-win_amd64.whl\nHere I get this error\n\nERROR: tensorflow-1.14.0-cp37-cp37m-win_amd64.whl is not a supported\nwheel on this platform.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":401,"Q_Id":62641686,"Users Score":-1,"Answer":"So far, Tensorflow isn't supported for Python v3.8\nTo make use of tensorflow, you need to download previous versions of python.\nAbout the wheel file you downloaded a file for v3.7 and trying to install with v3.8 which is why you get  is not a supported wheel on this platform.\nEDIT:\nPython 3.8 supports Tensorflow v2 but not v1.","Q_Score":0,"Tags":"python,tensorflow,pip","A_Id":62641979,"CreationDate":"2020-06-29T15:38:00.000","Title":"Installing previous version of tensorlfow on windows using pip","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building an app which has a feature for embedding expressions\/rules in a config yaml file. So for example user can reference a variable defined in yaml file like ${variables.name == 'John'} or ${is_equal(variables.name, 'John')}. I can probably get by with simple expressions but I want to support complex rules\/expressions such ${variables.name == 'John'} and (${variables.age > 18} OR ${variables.adult == true})\nI'm looking for a parsing\/dsl\/rules-engine library that can support these type of expressions and normalize it. I'm open using ruby, javascript, java, or python if anyone knows of a library for that languages.\nOne option I thought of was to just support javascript as conditons\/rules and basically pass it through eval with the right context setup with access to variables and other reference-able vars.","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":3639,"Q_Id":62643102,"Users Score":1,"Answer":"One option I thought of was to just support javascript as\nconditons\/rules and basically pass it through eval with the right\ncontext setup with access to variables and other reference-able vars.\n\nI would personally lean towards something like this. If you are getting into complexities such as logic comparisons, a DSL can become a beast since you are basically almost writing a compiler and a language at that point. You might want to just not have a config, and instead have the configurable file just be JavaScript (or whatever language) that can then be evaluated and then loaded. Then whoever your target audience is for this \"config\" file can just supplement logical expressions as needed.\nThe only reason I would not do this is if this configuration file was being exposed to the public or something, but in that case security for a parser would also be quite difficult.","Q_Score":7,"Tags":"javascript,java,python,dsl,rule-engine","A_Id":62706665,"CreationDate":"2020-06-29T16:58:00.000","Title":"Creating a DSL expressions parser \/ rules engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to split my dataset to training and validation sets I don't know whether I should split the dataset before applying pca dimensionality reduction or after pca to avoid leakage of data.\nAny help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":82,"Q_Id":62643565,"Users Score":1,"Answer":"The dataset should split before applying PCA to avoid leakage of data","Q_Score":2,"Tags":"python,validation,deep-learning,conv-neural-network,training-data","A_Id":62701465,"CreationDate":"2020-06-29T17:27:00.000","Title":"When I can split my dataset into training and validation set before PCA or after PCA?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So while I was working on an online project on Google Colab I had to run some model which was automatically saved on Colab (wherever that was). On looking it up (using !ls) it was being saved in the '\/content' directory which had some other files that were downloaded to Colab as a part of the project. Opening another notebook and running !ls on it showed the same but an empty '\/content' directory. I noticed '\/content' is also the default PWD and loading from google drive is through '\/content\/drive\/My Drive'. So what is '\/content' and the exact file structure working behind Google Colab and how? Can I transfer files from one notebook to another? Also any resources for more information on the same would be appreciated. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":282,"Q_Id":62645445,"Users Score":1,"Answer":"\/content on 2 notebooks are not the same. Because each notebook runs on a new computer in the cloud.\nBut if you mount drive, the directory \/content\/drive\/My Drive will be the same. You can use it to transfer files between 2 notebooks.","Q_Score":0,"Tags":"jupyter-notebook,filesystems,ipython,google-colaboratory,file-structure","A_Id":62648285,"CreationDate":"2020-06-29T19:30:00.000","Title":"What happens when you type !ls or !pwd or any shell command on Google Colab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is:  imagine you have a list of length 484 and each element of the list is also a list of length of 484. Basically these lists in the list are going to be the rows in my matrix. I was wandering how can I plot this matrix and the color it based on the values of the matrix.\nThank you in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":72,"Q_Id":62647761,"Users Score":1,"Answer":"You can use:\nplt.matshow(my_list)\nThis would work for your nested list but in general you can convert your nested list into a matrix by calling:\nmy_array = np.asarray(my_list)","Q_Score":0,"Tags":"python,matplotlib,matrix","A_Id":62648465,"CreationDate":"2020-06-29T22:47:00.000","Title":"How to create a matrix colored plot from a list of lists (Python)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a Python script that allows me to retrieve calendar events from an externally connected source and insert them into my Google Calendar thanks to the Google Calendar's API. It works locally when I execute the script from my command line, but I would like to make it happen automatically so that the externally added events pop up in my Google Calendar automatically.\nIt appears that a cron job is the best way to do this, and given I used Google Calendar's API, I thought it might be helpful to use Cloud Functions with Cloud Scheduler in order to make it happen. However, I really don't know where to start and if this is even possible because accessing the API requires OAuth with Google to my personal Google account which is something I don't think a service account (which I think I need) can do on my behalf.\nWhat are the steps I need to take in order to allow the script which I manually run and authenticates me with Google Calendar run every 60 seconds ideally in the cloud so that I don't need to have my computer on at all times?\nThings I\u2019ve tried to do:\nI created a service account with full permissions and tried to create an http-trigger event that would theoretically run the script when the created URL is hit. However, it just returns an HTTP 500 Error.\nI tried doing Pub\/Sub event targets to listen and execute the script, but that doesn\u2019t work either.\nSomething I\u2019m confused about:\nwith either account, there needs to be a credentials.json file in order to login; how does this file get \u201cdeployed\u201d alongside the main function? Along with the token.pickle file that gets created when the authentication happens for the first time.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":391,"Q_Id":62648913,"Users Score":2,"Answer":"The way a service account works is that it needs to be preauthorized.  You would take the service account email address and share a calendar with it like you would with any other user.  The catch here being that you should only be doing this with calendars you the developer control.  If these are calendars owned by others you shouldnt be using a service account.\nThe way Oauth2 works is that a user is displayed a consent screen to grant your application access to their data.  Once the user has granted you access and assuming you requested offline access you should have a refresh token for that users account.  Using the refresh token you can request a new access token at anytime.  So the trick here would be storing the users refresh tokens in a place that your script can access it then when the cron job runs the first thing it needs to do is request a new access token using its refresh token.\nSo the only way you will be able to do this as a cron job is if you have a refresh token stored for the account you want to access. Other wise it will require it to open a web browser to request the users consent and you cant do that with a cron job.","Q_Score":0,"Tags":"python,google-cloud-functions,google-calendar-api,google-oauth,google-cloud-scheduler","A_Id":62652102,"CreationDate":"2020-06-30T01:16:00.000","Title":"How do I use a cron job in order to insert events into google calendar?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a program which runs in thee background and monitors my keypresses so when I click a specific pattern of keys it runs another program\nNow the problem I am having is that if I press Ctrl+C the program terminates due to KeyboardInterrupt so\nis there a way in which the program just ignores the KeyboardInterrupt and continues executing","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":62649720,"Users Score":0,"Answer":"Catch the exception KeyboardInterruptError and do what you need to do.","Q_Score":0,"Tags":"python,keyboard,pynput","A_Id":62649797,"CreationDate":"2020-06-30T03:12:00.000","Title":"How to Manage Keyboard Interrupt Error in python pynput module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I imported some packages in a python program. But a lot of them only be called at the beginning of the program process. Are those packages saved in memory until the whole program finishes running? Can I delete them after they been called to release memory?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":244,"Q_Id":62649964,"Users Score":2,"Answer":"I don't think it is possible - but even if it is, the memory gained by erasing a loaded module is usually minimal.\nRunning del module in the code of some file will not remove it from memory: all loaded modules are available from the global  sys.modules dictionary. If you delete the module from sys.modules, you can gain some space, but I think  Python will still hold references to at least the classes that were defined in the module, (even if you have no instances of, or other references to those classes in your code.)\nall in all, most modules would get you a few kilobytes back. If you plan to \"unload\" modules that have a multi-megabyte impact in memory (think of Pandas\/matplotlib\/sqlalchemy), you will be even less likely to be successful as the complexity of these code bases mean they have a lot of internal cross references, and you'd need to delete everything they import internally from sys.modules.\nIf the setup is based on a multi-megabyte framework like these, and you are running on a very limited system (raspberry-class mini PC, with a few MB, for example) you could try to perform the initialisation in a subprocess, and kill that process when you are done - that would give you some guarantees the memory is freed up. But limited hardware apart you should simply not bother about it.","Q_Score":4,"Tags":"python,python-import,python-internals","A_Id":62650457,"CreationDate":"2020-06-30T03:45:00.000","Title":"can I release an imported package to save memory in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question. Suppose I run a python script on the server where my data are stored. What is the faster way to have a spark dataframe of my data between :\n\nMake a complex query with lot of conditions but it return me the exact dataframe I need or\nMake a simple query and make the dataframe I need with .filter \/ .select\n\nYou can also suppose that the dataframe I need is small enough to fit on my RAM.\nThanks","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":239,"Q_Id":62652101,"Users Score":0,"Answer":"First of all I think we should be careful when dealing with small data in our Spark programs. It was designed to give you parallel processing for big data.\nSecond, we have something like Catalyst query optimizer and lazy evaluation, which is a good tool for Spark to optimize everything what was put either in SQL query or API call transformations.","Q_Score":4,"Tags":"python,sql,apache-spark,pyspark","A_Id":62652604,"CreationDate":"2020-06-30T07:13:00.000","Title":"Do we must make a complex query in PySpark or a simple, and use .filter \/ .select?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question. Suppose I run a python script on the server where my data are stored. What is the faster way to have a spark dataframe of my data between :\n\nMake a complex query with lot of conditions but it return me the exact dataframe I need or\nMake a simple query and make the dataframe I need with .filter \/ .select\n\nYou can also suppose that the dataframe I need is small enough to fit on my RAM.\nThanks","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":239,"Q_Id":62652101,"Users Score":2,"Answer":"IIUC, everything depends on from where you are reading the data, So here are some scenarios\nDataSource: RDBMS(oracle, postgres, mysql....)\nIf you want to read data from RDBMS system then you have to establish a JDBC connection to the database then fetch the results.\nNow remember spark is slow when fetching data from relational databases over JDBC and it is recommended you filter most of your records on database side itself as it will allow the minimum data to be transferred over the network\nYou can control the read speed using some tuning parameters but it is still slow.\nDataSource: Redshift, Snowflake\nIn this scenario if your cluster is large and relatively free then pushdown the query to the cluster itself or if you want to read data using JDBC then it is also fast as BTS it unloads the data to a temp location and then spark reads it as file source.\nDataSource: Files\nAlways try to pushdown the filter as they are there for a reason, so that your cluster needs to do the minimum work as you are reading only the required data.\nBottom line is that you should always try to pushdown the filters on the source to make your spark jobs faster.","Q_Score":4,"Tags":"python,sql,apache-spark,pyspark","A_Id":62652857,"CreationDate":"2020-06-30T07:13:00.000","Title":"Do we must make a complex query in PySpark or a simple, and use .filter \/ .select?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question. Suppose I run a python script on the server where my data are stored. What is the faster way to have a spark dataframe of my data between :\n\nMake a complex query with lot of conditions but it return me the exact dataframe I need or\nMake a simple query and make the dataframe I need with .filter \/ .select\n\nYou can also suppose that the dataframe I need is small enough to fit on my RAM.\nThanks","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":239,"Q_Id":62652101,"Users Score":1,"Answer":"The key points to mind is\n\nRestrict\/filter data to maximum possible level while loading into dataframe, so as only needed data resides in dataframe\nfor non file sources: filtering data at source by using native filter and fetching only needed columns (aim for minimum data transfer).\nfor file sources: restricting\/modifying data in file source is not feasible. so the first operation is to filter data once loaded\n\nIn complex operations first perform narrow transformations (filters, selecting only needed columns) and then perform wide transformations(joins, ordering) which involves shuffle towards the end, so that less data will be shuffled between worker nodes.\n\n\nThe less the shuffles the faster your end dataframe would be.","Q_Score":4,"Tags":"python,sql,apache-spark,pyspark","A_Id":62655260,"CreationDate":"2020-06-30T07:13:00.000","Title":"Do we must make a complex query in PySpark or a simple, and use .filter \/ .select?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had a virtual environment setup for Django 3 with visual studio. However at some point it seems that this previous environment has been damaged - and therefore is no longer working (nothing appears on git to have changed).\nI therefore attempted to setup a new environment via the visual studio python environment options. I could setup a conda environment but it will not let me setup a python environment as \"you will need to install a python interpreter...\". However on the same page it states that the latest python 64 is installed.\nIt will not run with the conda environment that I have setup as it states \"The environment '....' is not available.\"\nI have tried creating a new solution with VS and this appears to work as intended. However it is not really an option to create a new solution as I will loose a lot of existing git commits along with this causing issues with existing servers.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":62652492,"Users Score":0,"Answer":"Edit - Found my own answer to this question.\nAs new projects were allowing virtual environments to be created I figured it must be something to do with visual studio storing some reference to an old interpreter.\nTherefore, Deleting the .vs folder inside my project allowed regeneration of the visual studio files and creation of a new virtual environment.","Q_Score":0,"Tags":"python,django,visual-studio,virtual-environment","A_Id":62769795,"CreationDate":"2020-06-30T07:38:00.000","Title":"Django Visual Studio The environment '....' is not available","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have woff2 files that I would like to convert to ttf using Python and the fonttools library. I have seen some methods on how to convert ttf fonts to woff2 but I can't use them to do the opposite.\nThanks in advance","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":879,"Q_Id":62652904,"Users Score":1,"Answer":"Here's the one-line command (on Windows):\npython -c \"from fontTools.ttLib import woff2; import brotli; woff2.decompress('path\/to\/your.woff2', 'path\/to\/output.ttf')\"\nMake sure you have installed brotli. Use forward slash (\/) for the file path instead of backslash (\\). The output can be either TTF or OTF.","Q_Score":2,"Tags":"python,fonts,truetype,woff2","A_Id":71043460,"CreationDate":"2020-06-30T08:05:00.000","Title":"How do I convert a woff2 font to ttf using fonttools in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have woff2 files that I would like to convert to ttf using Python and the fonttools library. I have seen some methods on how to convert ttf fonts to woff2 but I can't use them to do the opposite.\nThanks in advance","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":879,"Q_Id":62652904,"Users Score":1,"Answer":"I figured it out one can use fontTools.ttLib.woff2.decompress() to acheive this","Q_Score":2,"Tags":"python,fonts,truetype,woff2","A_Id":62711567,"CreationDate":"2020-06-30T08:05:00.000","Title":"How do I convert a woff2 font to ttf using fonttools in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Pycharm to code with Python FBX SDK, but I don't how to enable auto-complete. I have to look at the document for function members. It's very tedious. So, does anyone know how to enable auto-complete for Python FBX SDK in editor?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":369,"Q_Id":62653691,"Users Score":2,"Answer":"Copy these two files\n[PATH_TO_YOUR_MOBU]\\bin\\config\\Python\\pyfbsdk_gen_doc.py\n[PATH_TO_YOUR_MOBU]\\bin\\config\\Python\\pyfbsdk_additions.py\nto another folder like\nd:\\pyfbsdk_autocomplete for instance.\nrename the file pyfbsdk_gen_doc.py to pyfbsdk.py\nadd the folder to your interpreter paths in PyCharm. (Interpreter Settings, Show All, Show paths for interpreter)","Q_Score":3,"Tags":"python,pycharm,maya,fbx","A_Id":62880927,"CreationDate":"2020-06-30T08:51:00.000","Title":"Python FBX SDK \u2013 How to enable auto-complete?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using FB Prophet to do time-series forecast. I added two features--discount and promotion, and add holiday effect. The model fits well. But I want to get the feature importance to check how much contribution of 2 features. It seems FB Prophet does not have the feature importance function like other machine learning models \"model.feature_importances_\".\nIn FB Prophet, I can get the \"forecast\" dataframe, which contains :\ntrend\nyhat_lower\nyhat_upper\ntrend_lower\ntrend_upper\ndiscount_x\ndiscount_lower\ndiscount_upper\nextra_regressors_multiplicative\nextra_regressors_multiplicative_lower\nextra_regressors_multiplicative_upper\nholidays    holidays_lower\nholidays_upper\nmultiplicative_terms    multiplicative_terms_lower\nmultiplicative_terms_upper\npromotion_x\npromotion_lower\npromotion_upper\npromotion_Day\npromotion_Day_lower\npromotion_Day_upper\nweekly\nweekly_lower\nweekly_upper\nadditive_terms\nadditive_terms_lower\nadditive_terms_upper\nyhat\ny\nIn that case, how can I analyze the feature importance?\nTHANK YOU!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1345,"Q_Id":62654951,"Users Score":0,"Answer":"Use SHAP to get it. It will tell you what are the features and how much it is contributing on individual level as well.","Q_Score":3,"Tags":"python,machine-learning,time-series,facebook-prophet","A_Id":67316330,"CreationDate":"2020-06-30T10:04:00.000","Title":"How to get feature importance of FB prophet?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list of dispatch whose values are in decimals. Now I want to form two lists from this dispatch:\n\nCharge\n\nDischarge\ndispatch = [0.39, 0.81, 0.58, 0.19, 0.70, 0.75, 0.66, 0.10, 0.58, 0.65, 0.87, 0.86, 0.38, 0.31, 0.63,]\n\n\nNow there is condition for charge and discharge:\n\nCharge = If dispatch[0] is less than dispatch[1] then it means charge and its value will greater minus smaller value.\n\nDischarge = If dispatch[0] is greater than dispatch[1] then it means discharge and its value will be greater minus smaller value.\nMy attempt:\ndischarge = [(dispatch[i] - dispatch[i+1]) if dispatch[i] > dispatch[i+1] else 0 for i in range(0,  len(dispatch))]\ncharge = [(dispatch[i+1] - dispatch[i]) if dispatch[i] < dispatch[i+1] else 0 for i in range(0,  len(dispatch))]\n\n\nBut in this logic, there is an INCREMENTAL condition i+1, which will give the error of list out of index that I know of but I don't know the solution for this. Can anyone please help?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":33,"Q_Id":62656407,"Users Score":1,"Answer":"You need to change range(0,  len(dispatch)) to range(0,  len(dispatch) - 1)","Q_Score":1,"Tags":"python,list","A_Id":62656515,"CreationDate":"2020-06-30T11:27:00.000","Title":"how to resolve out of index error on incremental condition in a for loop?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement a way to know when a specific device has stopped publishing messages to an mqtt broker and in that case send an email to myself. I want to do this to be able to know if there is a problem with the device that is publishing the messages so I can check it and turn it back on. To try to accomplish this I created a mqtt client that subscribes to the topic that the device publishes e.g. test\/device_1 and then set as last will and testament for that device status\/device_1 where I put as payload=\"Offline\". Ideally, I want to be able to do this for more than 1 device, but let's assume I just want it for the simple case of one device.\nI created another script that implements another client that is subscribed to the topic status\/device_1 and then on the on_message function it checks if it gets the payload=\"Offline\" and if it does get it then I send an email to myself.\nThis approach however doesn't work as when I turn off my device, the mqtt client that is subscribed to the topic test\/device_1 keeps listening but gets no messages. In other words, it doesn't send its last will even when the topic is empty. However, it seems to work when I stop the script that is subscribed to the topic test\/device_1.\nAm I missing something or is it not possible to accomplish what I am trying to do? Any advice is appreciated!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1204,"Q_Id":62660177,"Users Score":2,"Answer":"First LWT messages are only published by the broker if the client goes offline unexpectedly, which means if it shuts down cleanly then it will not get published, you have to manually publish a message as part of shut down process.\nYou can set the retained flag on the LWT so that any client that subscribes after the device has gone offline it will still see the state message.\nYou should also clear that message on when the device starts up, either by publishing something like Online or a null payload to clear the retained message.","Q_Score":2,"Tags":"python,mqtt,mosquitto,paho","A_Id":62663512,"CreationDate":"2020-06-30T14:48:00.000","Title":"Mqtt check if subscribed topic has stopped publishing 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've been all over the site trying to find a solution for a problem i am running into with my virtual environment and the python version being used.\nI have installed mini conda\nI am on a Mac\nI have run the conda create myDjangoEnv python=3.6 conda commmand, and i have activated the env with the conda activate myDjangoEnv command.\nI have confirmed that django is installed in the venv and the version is 3.8.4\nThe problem I am running into is when trying to execute the command python manage.py runserver, I first get the from exc error. When checking python it says it is running 2.7 version in the atom terminal, however when i check my virenv in my normal terminal the python version returns with 3.6.\nIn the atom terminal, when i execute python3 manage.py runserver, the from exc error goes away but then I run into the ImportError: Django package cannot be found.\nHas anyone run into this issue specifically with the Atom server? Is there something I am doing wrong when creating the projects in atom that is tripping the virtual environment and resetting the python version to 2.7?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":62660187,"Users Score":0,"Answer":"Are you using the package \"script\" in Atom?","Q_Score":0,"Tags":"python,python-3.x,django,atom-editor","A_Id":62660238,"CreationDate":"2020-06-30T14:49:00.000","Title":"Django virtual env issues with Python and Atom","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've been all over the site trying to find a solution for a problem i am running into with my virtual environment and the python version being used.\nI have installed mini conda\nI am on a Mac\nI have run the conda create myDjangoEnv python=3.6 conda commmand, and i have activated the env with the conda activate myDjangoEnv command.\nI have confirmed that django is installed in the venv and the version is 3.8.4\nThe problem I am running into is when trying to execute the command python manage.py runserver, I first get the from exc error. When checking python it says it is running 2.7 version in the atom terminal, however when i check my virenv in my normal terminal the python version returns with 3.6.\nIn the atom terminal, when i execute python3 manage.py runserver, the from exc error goes away but then I run into the ImportError: Django package cannot be found.\nHas anyone run into this issue specifically with the Atom server? Is there something I am doing wrong when creating the projects in atom that is tripping the virtual environment and resetting the python version to 2.7?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":62660187,"Users Score":0,"Answer":"That issue may be related to you having multiple version of python installed and your terminal is pointing at the wrong one there. I recommend you switch to something like vscode, where you can ctrl shift P and select manually the venv and python interpreter used for the workspace and have your terminal there.","Q_Score":0,"Tags":"python,python-3.x,django,atom-editor","A_Id":62661178,"CreationDate":"2020-06-30T14:49:00.000","Title":"Django virtual env issues with Python and Atom","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"\"in Object-oriented programming, abstraction is a process of hiding the implementation details from the user, only the functionality will be provided to the user.\"\ni have been trying to understand abstraction, can someone tell how exactly are we are hiding implementation details?using a program","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":85,"Q_Id":62661208,"Users Score":-1,"Answer":"OOP Abstraction is used to facilitate tasks between multiples classes.  Let's say that we have a class A and a class B that both implement a method fruit() that works the same way for the two classes.\nYou could use an abstract class C that would define that method, class A and B will extend class C and you wouldn't have to repeat that method twice.\nThis is a small-case scenario, if you had hundreds of classes, it would be very worthwhile to save the data used to repeat that same methods.","Q_Score":0,"Tags":"java,python,oop,computer-science,abstraction","A_Id":62661584,"CreationDate":"2020-06-30T15:41:00.000","Title":"Abstraction in Object oriented programming","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a python script that would automatically generate a virtual environment with a specific version. As far as I know, you can only create a virtual environment of a python version already installed on the computer. Is there a way around this? For example, I would like to generate a python 3.7 virtual environment although it is not installed on my computer. Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1560,"Q_Id":62665730,"Users Score":1,"Answer":"The common way for doing this is by using anaconda, and creating conda environments which let you specify the python version. It is very popular among data scientists and it is used extensively in machine learning because of the many different versions of python and packages you need. Reading your comment about working with AI this is a popular solution to your problem.\nTo make an enviroment with a specific python after you install use\nconda create -n emvname python=3.4\nnote that you can use conda install package instead of pip for many packages and you should prefer it, pip still works as normal of course.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,python-venv","A_Id":62668257,"CreationDate":"2020-06-30T20:32:00.000","Title":"Create Python Virtual Environment with Specific Version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I have  trained a neural network that takes some inputs and accurately calculates their value. This neural network was used to approximate a function that was hard to solve analytically or to simulate using other methods. It is a very accurate function approximator. Now I would like to know what the best inputs are that will return the highest value. I was thinking that I could do this with a genetic algorithm but is there a neural network method of doing this? Also is it possible to train the neural network and find the optimal inputs simultaneously? What kind of network architecture could do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":196,"Q_Id":62666620,"Users Score":1,"Answer":"Well, a direct solution would be to apply calculus to each of the layers and solve for any local minimums or maximums (assuming that you don't have that many variables). But I don't think this solution (or similar optimization methods) would be a proper use of neural networks.\nNeural networks are designed to copy-cat. Give input X and expected output Y, optimize a function that guesses \"close\" to Y. This is the nature of a neural network. An isolated optimization problem asks a fundamentally different question. Given a body of data that approximates some underlying function, find the single \"best\" solution. Such problem is looking for a single case (or isolated discrete cases) amoungst a collection of data.\nIf you want to phrase an optimization problem in terms of a neural network solution it would look like this. Given a collection of approximated functions (millions of trained neural networks) and known optimized solutions (the expected solutions for each one), train a new neural network that mimics this behavior. This can certainly be done, but the collection of functions of interest would need some kind of bounds; it would certainly not be possible to train a single neural network that applies \"universally\" to all possible optimization problems. That would solve the entire field of optimization theory.\nFor example, given a collection of functions of the form Asin(Bx+C)+D for a random distribution of A, B, C, and D; find the maximum. Or count the number of maximum and minimum. These are great examples of something a neural network could learn to do, on unseen functions from the dataset. The neural network, might even learn the underlying behavior so well that it works with coefficients outside the initial dataset too.\nOf course, one could start building a massive collection of optimization neural networks that applies in millions of different cases for all kinds of different problems. Such \"neural network zoo\" could solve all of optimization theory.","Q_Score":2,"Tags":"python,tensorflow,keras,deep-learning,neural-network","A_Id":62668130,"CreationDate":"2020-06-30T21:47:00.000","Title":"Neural network for optimization problems","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using RASA NLU (open source), but I am concerned about data privacy. I want my data to be private, and wanted to ensure that none of my data ever leaves my machine, connects to Rasa's servers (or any servers other than my own \u2014- only running locally), and nothing goes to the cloud. I want all my data to be private and local until deployment. Is this true of Rasa NLU?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":62667655,"Users Score":0,"Answer":"Yes, this is true. If you spin up an NLU server on a machine you have control over, no NLU data will go to any cloud server. Rasa specifically supports deploying an assistant (or just an NLU server) either on premise, or in the cloud (which also, incidentally, will not share your data unless you choose to do so - it's just another place to spin up a server), so it is up to you. There are no \"Rasa servers\" in the sense of servers providing the Rasa service unless you bring one up.","Q_Score":0,"Tags":"python,nlp,artificial-intelligence,rasa-nlu","A_Id":62756008,"CreationDate":"2020-06-30T23:40:00.000","Title":"Data Privacy Rasa NLU","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hope everyone is doing well. I am new to nlp and I am trying to write a program that can tell me if the user's input is meant to talk one of my three models chatbots\n\ncovid-casual chatbot (A model trained on non-medical twitter data)\ncovid-medical chatbot (data from patient's visit to the doctor's office)\ncasual conversation chatbot (my last model is a casual agent)\n\nWhat would be the most reliable way to analyze the user's input to choose between the 3 categories?\nThank you in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":62668271,"Users Score":0,"Answer":"You can implement this through a supervised machine learning model. You need to train your model so it will know what category to assign in each prediction","Q_Score":0,"Tags":"python,model,nlp,classification,text-classification","A_Id":62668326,"CreationDate":"2020-07-01T01:18:00.000","Title":"Finding out if Input text is for corona virus or not","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When running some tests as part of building an application using pybuilder (pyb) getting this exception:\nBUILD FAILED - TypeError: () takes 0 positional arguments but 1 was given (pybuilder\/plugins\/python\/unittest_plugin.py:177)\nWhat could be possibly wrong ? I checked all the class functions, they have \"self\" as parameters in them. There are no lambda expressions.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":62668762,"Users Score":0,"Answer":"The problem was resolved by patching\nsite-packages\/pybuilder\/plugins\/python\/unittest_plugin.py.\nThe \"return runner_generator(stream=output_log_file)\" statement was replaced by\n\"return runner_generator()\" in \"_create_runner\" function.","Q_Score":0,"Tags":"python,pybuilder","A_Id":62958669,"CreationDate":"2020-07-01T02:31:00.000","Title":"Python TypeError when executing 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 am new to Python programming language and Django. I am learning about web development with Django, however, each time I create a new project in PyCharm, it doesn\u00b4t recognize django module, so i have to install it again. Is this normal? Because i\u00b4ve installed django like 5 times. It doesn\u00b4t seem correct to me, there must be a way to install Django once and for all and not have the necessity of using 'pip install django' for each new project I create, I am sure there must be a way but I totally ignore it, I think I have to add django to path but I really don\u00b4t know how (just guessing). I will be thankful if anyone can help me :)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":62668812,"Users Score":0,"Answer":"pycharm runs in a venv. A venv is an isolated duplicate (sort of) of python (interpreter) and other scripts. To use your main interpreter, change your interpreter location. The three folders (where your projects is, along with your other files) are just that. I think there is an option to inherit packages. I like to create a file called requirements.txt and put all my modules there. Comment for further help.\nIn conclusion, this is normal.","Q_Score":0,"Tags":"python,django,web","A_Id":62668864,"CreationDate":"2020-07-01T02:37:00.000","Title":"I must install django for every single project i make?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"os.system(r'cmd \/c \"for \/f %a in ('dir \/b \"C:\\Users\\file\\\"') do ren \"%a\" \"DRAWING_%a\"\")\nIt was throwing an error at dir \/b as invalid syntax.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":62669455,"Users Score":0,"Answer":"I got solution and solution is\nos.system(r'cmd \/c \"FOR \/r \"D:\\BACKUPS\\2018\\\" %a in (*) DO REN \"%~a\" \"Drawing_%~nxa\"\"')","Q_Score":0,"Tags":"python,windows,command","A_Id":63407998,"CreationDate":"2020-07-01T03:57:00.000","Title":"I use the command in (dir \/b) batch files but it is throwing an error invalid syntax","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I saved my trained machine learning model as pickle in github, but I can't find a way  to access it yet? Anyone have a suggestion?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":262,"Q_Id":62669501,"Users Score":0,"Answer":"Clone the github repository it's in and run pickle.load to load the pickle file.","Q_Score":0,"Tags":"python,machine-learning,github,pickle,github-pages","A_Id":62669532,"CreationDate":"2020-07-01T04:03:00.000","Title":"Accessing Saved Pickle Model in github","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been working on two scripts where one of the script (we can call generate_data.py) that generates the data (looks for new data 24\/7) and I have notifications.py that receives the data from generate_data , convert it to a json and post it to my server through a requests.\nThere is some problems that I have and one of them is that I need it to run simultaneously. That means whenever the generate_data.py is looking for new data, when it sends the data to notifications.py it should NOT wait for the notifications.py to be done. Instead it should work all the time and only send data to notifications.py when new found and continue looking for new data.\nScenario that can happen is that generate_data.py can get new 5 data at the same time and is needing to be send to notifications.py that needs to send the requests to my server as soon as possible without any delay\/stopping\/blocking.\nI got few suggestions such as using listener, queue, rcp, threading, multiprocessing but here I am. My question is, What would be my best option to use here where I have generate_data.py that is on 24\/7 and notifications.py should only post once it got the data from generate_data and post it to my server as fast as possible and without being blocked\/stopped and if there is any example would also be appreciated it! (Using python)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":62671632,"Users Score":1,"Answer":"so as generate_data script generates data and sends it to notification script, while notification script is in processing the data which has sent meanwhile the data generated by generate_data where you are storing it to push to the notification script later ?\nyou can do one thing as you asked only with python..\nyou can generate data in to a file always and notifications script read the content and delete only content which is read, so that you can do both parallel.","Q_Score":0,"Tags":"python,multithreading,queue,listener,rcp","A_Id":62671801,"CreationDate":"2020-07-01T07:22:00.000","Title":"What is the best option to send data to another script without be blocked","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was using the ConversationID of the mails in the Inbox and the mails in the Sent Items, assuming that the IDs will be same for the mails that we replied to, and it is same but the problem begins with Email Chains (or the Re: mails aka Conversations).\nSince the ID remains the same, and people keep replying even after days, performing a simple\ndatetime - datetime (with same ConversationIDs) results in outputs such as -1Day 20:05:01, -9Days etc.\nI just want to find the Response time of first reply to any mail, that enters the inbox.\n(Sorry, cannot share Code).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":62672490,"Users Score":0,"Answer":"To get the Response Time from a Chain of Mails which all have exactly the same ConversationID (generated automatically by Outlook), I did the following:\nI already had two Pandas DFs (let's say 'A' and 'B'), having the two columns each, namely:\nConversationID and Time (for received and sent mails).\nNow,\n\nCreated a Pandas DataFrame 'C' with an inner join of 'A' and 'B' on `ConversationID'.\n(This gave me all the mails that I had replied to).\n\nSort the both the Time columns as \"Ascending\".\n(This brings the First Mail received and the First Mail replied to the top).\n\nNow filter the new DataFrame 'C' on both Time columns with the condition,\nReplied Mail Time > Received Mail Time\n(Removes the -1 day outputs I was getting)\n\nGroupby on Received Mail Time and use .first()\n(Finally giving a genuine response time, after calculating Replied Mail Time - Received Mail Time)","Q_Score":0,"Tags":"python,outlook","A_Id":62834467,"CreationDate":"2020-07-01T08:14:00.000","Title":"Python Outlook (MAPI) Get Response Time of Mails Replied","Data Science and Machine Learning":0,"Database and SQL":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 got this number 1.12412 and I want to round it to 1.12415 or 1.12410 (muliple of 5 in last decimal)\nIf using the Round(X,4) function I get 1.1241 (4 decimals).\nIs there a function that can make that happen?\nThanks!\nThere is an answer in stack but using c# not python","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":62672775,"Users Score":0,"Answer":"You may:\n\nMultiply your number by 2\nUse Round(X,4)\nDivide the result by 2\nprofit!!!","Q_Score":1,"Tags":"python,rounding","A_Id":62672844,"CreationDate":"2020-07-01T08:31:00.000","Title":"How to round float in multiple of 5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can Python apps run on iOS devices such as iPad and iPhone, or is there a specific language in which iOS apps must be coded?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1761,"Q_Id":62674736,"Users Score":0,"Answer":"Python doesn't have built-in mobile development capabilities, but there are packages you can use to create mobile applications, like Kivy, PyQt, or even Beeware's Toga library. These libraries are all major players in the Python mobile space.\nIf you want a single Application to work on all devices then you have to use cross platforms like Flutter, react native xamarin and phone gap etc. that application never gives smooth use and also having some limitations.\nExcept that, you can use Xcode (native by Apple) to create iphone and ipad apps(using swift, objective C language). For android application development, you can use Android studio(Using jave) etc.","Q_Score":0,"Tags":"python,ios","A_Id":62674939,"CreationDate":"2020-07-01T10:24:00.000","Title":"Can Python apps run on iOS devices?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently doing Selenium testing with Pytest. There will be around 10 tests, however, a user may only have 70-80% of the data available to test (which is fine).\nIs there a way to then say, if 7\/10 tests have passed, pass the overall pytest, but still show the failing tests\nThis will interact with a CI\/CD pipeline, and it seems that if even 1 tests fails, that the Jenkins just sees red.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":62677374,"Users Score":0,"Answer":"As suggested, if there isn't enough data for tests. Then don't run them.\nI was able to find a database table which only contains the users with the relevant data. Now all tests are passing 100%.\nThanks everyone for the help.","Q_Score":0,"Tags":"python,selenium,jenkins,testing,pytest","A_Id":62699363,"CreationDate":"2020-07-01T12:56:00.000","Title":"Pytest pass overall if >50% of Selenium tests pass","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 scheduled a Cron job like below but it is not executing. Do I need to put command before or is it ok to write only path.\n\nWith Command in the cronjob: 0 4 * * 1 python \/app\/www\/html\/RegionSubregion\/ceeinca.py\nWithout command in the cronjob: 0 4 * * 1 \/app\/www\/html\/RegionSubregion\/ceeinca.py\n\nWhich one is correct here?\nI need to run this particular python script on 1st day (Monday) of everyweek at 4AM. Please guide. Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":62677624,"Users Score":0,"Answer":"Option 1 works if you give execute permission to the file.\nExecute Permission: chmod +x \/app\/www\/html\/RegionSubregion\/ceeinca.py","Q_Score":0,"Tags":"python,linux,cron","A_Id":62709173,"CreationDate":"2020-07-01T13:10:00.000","Title":"How to schedule Cron Job in 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 just installed Windows Server 2019 on Google Cloud Compute Engine, so I can host my python apps 24\/7 but I can't install python because of this error:\n0x80070659 - This installation is forbidden by system policy. Contact your system administrator.\nI was wondering if there's anything I can do to resolve this issue.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":503,"Q_Id":62678168,"Users Score":2,"Answer":"Solution:\nI just needed to run the setup file as administrator.","Q_Score":1,"Tags":"python","A_Id":62679415,"CreationDate":"2020-07-01T13:38:00.000","Title":"Using python on a Google Cloud Windows Server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I used pyinstaller to package my program using the command pyinstaller --onefile main.py --hidden-import jaraco.windows.api.memory, and the .exe generates just fine. However, when I try to launch it, it crashes immediately with an error message that says ImportError: No module named xlsxwriter.\nI saw a previous thread on here where someone had a similar error, however in that thread, the solution was to import it in the script, but I have already done that. On the first line.\nThe general structure of my program is as follows:\nThere is a homemade utils library, where some of the items import xlsxWriter.\nThe main method imports each file in the library","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":380,"Q_Id":62678182,"Users Score":0,"Answer":"Add --hidden-import xlsxwriter to your build command.","Q_Score":0,"Tags":"python,python-2.7,pyinstaller","A_Id":62687718,"CreationDate":"2020-07-01T13:39:00.000","Title":"Pyinstaller \"No module named xlsxwriter\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python, when I convert my set to a list, what is the algorithmic complexity of such a task? Is it merely type-casting the collection, or does it need to copy items into a different data structure? What's happening?\nI'd love to learn that the complexity was constant, like so many things in Python.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":852,"Q_Id":62679314,"Users Score":1,"Answer":"The complexity is linear because all references are copied to the new container. But only references and are and not objects - it can matter for big objects.","Q_Score":2,"Tags":"python,python-3.x,time-complexity,python-collections","A_Id":62679473,"CreationDate":"2020-07-01T14:38:00.000","Title":"Algorithmic complexity to convert a set to a list in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently following a tutorial for my project when it starts using the OneHotEncoder. When he inputs the following code:\ntype_one_hot = OneHotEncoder(sparse=False).fit_transform(\nreview_df.review_type.to_numpy().reshape(-1, 1))\nprint(type_one_hot[0])\nhe gets an output of:\narray([0., 1.])\nwhereas when I run the code I just get:\n[0. 1.]\nThis matters for later on as when I later input using this style it complains that my input is not a vector. Any ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":62680377,"Users Score":0,"Answer":"It is pretty clear that what you have is a list and the tutorial is producing an array but can you check what type the values in your list are and it would help to know what these variables hold: review_df.review_type","Q_Score":0,"Tags":"python,one-hot-encoding","A_Id":62681046,"CreationDate":"2020-07-01T15:37:00.000","Title":"OneHotEncoder input not working as an array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that I have converted into a attributable executable. This script uses selenium to look up a part number on my company website. My end goal is to integrate this into Power Bi so that any part number in a Power Bi list can be easily looked up. My idea is to make a URL that can be a clickable link in Power Bi. This URL would call the executable from a network drive as well as pass the part number to the script. To incorporate the part number I would like to add it onto the end of the URL and have the script pick it up from there.\nIs this just a dream or can a relatively new programmer do this? I have found a way to make a web-page that contains a python script, but not one that I can pass information to without user interaction. Is there a tool out there that will allow me to click a URL that launches a local .exe and passes information to it while running in the background?\nAny recommendations would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":62680494,"Users Score":0,"Answer":"You can create a simple flask app that has a GET view and pass information to it with GET or POST parameters, in the view you would then execute whatever you want.","Q_Score":0,"Tags":"python,powerbi,exe","A_Id":62680798,"CreationDate":"2020-07-01T15:43:00.000","Title":"How to Launch python EXE from URL and Pass Information Through the URL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Attempting to run a python 2.7 app engine app locally using PyCharm (which uses dev_appserver) my machine is python 3.7 but I have a python 2.7 virtual env setup as the project interpreter, which works fine when running the project.\nHowever when attempting to debug the same run config (which runs fine) I am getting the following error\nERROR: (dev_appserver) python2: command not found\nI can run the python2 command in my terminal both inside and outside the virtual environment so I am not sure what is wrong here.\nI am currently running Pop!_OS 20.04 LTS if that helps.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":224,"Q_Id":62680759,"Users Score":0,"Answer":"I had the same issue after starting new AppEngine projects on python 3. Initially, I thought the problem was with a new version of Google Cloud SDK. I spent a lot of time linking\/unlinking python versions and playing around the environment variables.\nBut eventually, update of PyCharm to 2021.1.2 fixed the issue.","Q_Score":1,"Tags":"python,google-app-engine,pycharm,dev-appserver","A_Id":68097544,"CreationDate":"2020-07-01T15:58:00.000","Title":"Unable to Debug Dev Appserver using pycharm, but able to run fine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I can't seem to force quit Anaconda-Navigator. It is apparently running on my Mac but when i try to force quit it nothing happens, and when i try to launch it also nothing happens. Any help is welcomed.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3088,"Q_Id":62681829,"Users Score":2,"Answer":"This problem only occurs when you first close the terminals and then 'Anaconda'. Do following steps:\n\nRestart your Mac.\nIt won't happen again if you always close the 'Anaconda' first and then the Terminals (The two small windows).\n\nHope it was helpful!","Q_Score":4,"Tags":"python,anaconda,anaconda3","A_Id":64726681,"CreationDate":"2020-07-01T17:00:00.000","Title":"Anaconda won't force quit in Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have an python daemon init script that has to get messages from other init script when they are starting.Since it is the initial boot stage of my raspberry Pi board\ni don't want to use any IPC for message passing.Is there any simple way that i can pass message from my other init scripts to python daemon.Thanks in advance for any great suggestions for this issue.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":173,"Q_Id":62681949,"Users Score":0,"Answer":"You can use named pipe. First you instantiate named pipe using mkfifo, which creates file representing the pipe. Then you open this file in both scripts - in one for writing and in another one for reading. After that you can just write some data to the opened file in one script and read it back in another.\nNote that pipes are unidirectional, which means that if you need to communicate in both directions, then you need to create two pipes.","Q_Score":1,"Tags":"linux-kernel,raspberry-pi,daemon,python-daemon","A_Id":62710334,"CreationDate":"2020-07-01T17:06:00.000","Title":"Send message to a Python daemon script from another init script without using IPC","Data Science and Machine Learning":0,"Database and SQL":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 text with Python and Qt that can be used by blind and visually impaired people.\nThe text editor should be suitable for screen readers.\nI do tests with the screen readers NVDA (Windows) and\nOrca (Ubuntu).\nTexts for screen readers should actually be saved in the \"AccessibleDescription\" property. The NVDA screen reader does not read the \"AccessibleDescription\" property. AccessibleName property only. The Orca screen reader reads the \"AccessibleDescription\" property.\nQuestion:\nWhat can I do so that my application is screen-readable on all operating systems?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":295,"Q_Id":62682288,"Users Score":0,"Answer":"Short answer\nSadly, there's probably no magic solution here.\nThe only reasonnable answer is just trying and testing a maximum of different combinations of OS, screen readers, GUI toolkits and components, as much as you can. That's the only way to discover what works well for your particular scope, and what doesn't.\nThere is no uniformity at all between OS, screen readers and GUI toolkits, and probably no combination working everywhere in all cases.\nLonger answer\nThis isn't a peasure to give this answer but in fact, if you want to make sure your app is 100% screen reader accessible, your only way is basicly to stop using GUI toolkits and exclusively use the native components offered by the OS for which accessibility is well documented; and therefore of course develop as many different apps as OS you intent to support.\nAs soon as you are using a GUI toolkit, you are adding a layer, and may lose some accessibility (and often more than less) in the process.\nThe gap between the features offered by the native OS components and those proposed in the toolkit is often closed by emulation, and some of the emulations aren't made accessible, or simply can't be made accessible for various (more or less excusable) reasons.\nThat's why some components are accessible while some others aren't; why a given component can be accessible under one OS but not at all under another; and why a component can be accessible in version N of the toolkit but not the same component in version N+1.\nIn short, you have understood, accessibility is extremely fragile.\nSadly, GUI toolkits rarely well document accessibility of their components under the different OS they support.\nThat's really a shame. It has to be addressed.\nAdditionally, accessibility is often presented as being  expert compicated features. It shouldn't be so. It should be easy for app developers to make accessible apps.\nSo, wwell, since there is often no documentation about accessibility, your only way is to try and test.\nThat's a lot of work, and there is no alternative. Try and test. That's all.\nDigging deeper\nThere's generally two foundamental ways to design a GUI toolkit, and depending on which has been chosen, this has a dramatic impact on natural accessibility, and what kind of accessibility the toolkit can hope to achieve.\n\nThe first way is to start from a blank page as far as the OS permits, and from there, decide literally everything: what components to provide, and how they should look and behave.\nBy doing so, you make sure that your app will look and behave exactly the same everywhere. An user might be surprised or confused the first time because look and behavior is often not 100% conform to OS conventions or user preferences, but in the long run, he\/she will always feel at home with your app regardless of the OS used.\nHowever, more importantly, create everything from a blank page also means that everything must be defined from scratch for accessibility. It requires of course a lot of work, whether for the GUI implementers, or the app developer. Different toolkits place the responsibility cursor at different places.\nSome toolkits perform better and\/or go further than others, but in general they are nowhere near what the native components of the OS can provide.\nThe second way is to use as much as possible the components proposed by the OS, and emulate only missing features when they are really needed.\nThis is excellent for accessibility, since almost all native OS components are naturally accessible or only require little effort. Users will have an app that conforms to the general look of their OS, and so won't be confused or surprised by the interface and its behavior.\nHowever, the app isn't going to look exactly the same in all computers. Sadly, for many designers and developers, this is a definitive stopper.\n\nAs the vaste majority of GUI toolkits I know of, QT is part of the first group, but isn't playing that bad in accessibility (at least under windows) if the app developer is also aware of accessibility.\nIn the second group, you have WXWidgets for example.","Q_Score":0,"Tags":"python,qt,accessibility,screen-readers","A_Id":62684147,"CreationDate":"2020-07-01T17:30:00.000","Title":"how can ensure that a Python qt application is screen readable on all operating systems","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am looking to execute shell command from node.js. I would like the stdout to be displayed to the terminal. In python I can do this with subprocess.run. In node.js I see child_process.exec, but this returns a buffer of stdout instead of automatically displaying to the terminal.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":487,"Q_Id":62683008,"Users Score":1,"Answer":"In my case I got it working using child_process.execAsync with the stdio option set  to inherit like this:\nchild_process.execAsync(\"git push --tags\", { stdio: \"inherit\" })\nI needed git to show the prompt for the passphrase and allow user to make the input.","Q_Score":4,"Tags":"python,node.js,terminal,subprocess,child-process","A_Id":66892397,"CreationDate":"2020-07-01T18:15:00.000","Title":"Is there a Node.js equivalent to Python's subprocess.run?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am training a neural network in parallel on 2 GPUs using the Tensorflow MirroredStrategy. With a single GPU, each epoch takes 19 seconds to complete whereas with 2 GPUs, each epoch takes 13 seconds to finish. I am not surprised at this since I know the scaling is not perfect due to the all_reduce overhead for updating the variables during training.\nHowever, after each epoch of the distributed training, there is a pause of about 8 seconds. When using a single GPU, this pause is less than 1 second. Does anyone know why there is such a long pause after each epoch when training distributed?\nAlternatively, can anyone explain what happens differently in distributed training at the end of an epoch?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":62683947,"Users Score":0,"Answer":"Apparently this had something to do with running TF in graph mode. By setting tf.compat.v1.enable_eager_execution() the problem went away. This also fixed a memory leak that was causing issues, so perhaps the pause was being caused by TF making copies of something that I wasn't expecting.","Q_Score":0,"Tags":"python,tensorflow2.0","A_Id":62717644,"CreationDate":"2020-07-01T19:17:00.000","Title":"Tensorflow distributed training pause after each epoch","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sorry if this was answered in another post.\nI am very new to python and learning about the virtual environment. I understand that I am supposed to have all the libraries installed in the virtual environment and create the requirement.txt, so others can install using that. However, I am not sure what the best practice to deploy to production?\nThe reason I ask is that no one supposes to have access to the production environment, the deployment is through a predefined pipeline, and my understanding is that it will zip all my code and deploy it to production, no one suppose to go into production to do any manual work. I can try to get the pipeline to run a script to install all the libraries base on the requirement.txt, but I am not sure if the firewall setting is the same. Should I package the libraries as well?\nalso, how should I trigger the python script? should I have a wrapper script to activate the vevn before calling python script and deactivate it after? or there is a easier way?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":5203,"Q_Id":62684491,"Users Score":1,"Answer":"For your program to work anywhere be it production or development, it needs the required library.\nGenerally what is done is, we create a new virtual environment (like Booboo said with 'python -m venv <env_name>'), on the server and install all the required packages (pip install -r requirements.txt) ('requirements.txt' should be created on your development machine with 'pip freeze > requirements.txt')\nSince you say, no one is allowed to access the production server directly, there must be some step, your system administrator wants you to follow. Only he\/she can help you in that case.\nAs for firewall, if your program serves to a certain port and if your program must be accessible from other computers apart from the localhost, than that particular port must be opened. That is something your server administrator shall do for you.","Q_Score":0,"Tags":"python-3.x,deployment,virtualenv","A_Id":62843807,"CreationDate":"2020-07-01T19:59:00.000","Title":"Best practice of python virtual environment deployment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sorry if this was answered in another post.\nI am very new to python and learning about the virtual environment. I understand that I am supposed to have all the libraries installed in the virtual environment and create the requirement.txt, so others can install using that. However, I am not sure what the best practice to deploy to production?\nThe reason I ask is that no one supposes to have access to the production environment, the deployment is through a predefined pipeline, and my understanding is that it will zip all my code and deploy it to production, no one suppose to go into production to do any manual work. I can try to get the pipeline to run a script to install all the libraries base on the requirement.txt, but I am not sure if the firewall setting is the same. Should I package the libraries as well?\nalso, how should I trigger the python script? should I have a wrapper script to activate the vevn before calling python script and deactivate it after? or there is a easier way?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5203,"Q_Id":62684491,"Users Score":0,"Answer":"When it comes to deploying applications on servers without internet. Consider deploying using PEX, Pants build system. Or as Booboo says you can just deploy and run using virtual environments(not really pythonic way) but it works. For our use case where i am we are actually do this.","Q_Score":0,"Tags":"python-3.x,deployment,virtualenv","A_Id":71320204,"CreationDate":"2020-07-01T19:59:00.000","Title":"Best practice of python virtual environment deployment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to implement aws presigned URL in python. but I want to make sure images are not greater than 2MB. but all new mobiles have images of around 8MB. How can I handle this? How can I compress the images without even uploading them to my server?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":62685036,"Users Score":0,"Answer":"Here is a simple solution.\nCreate a lambda function that will take images and compress them to <2MB and then uploads them to the client-side.\nYou have to do processing on your side also for this plus lambda function will also add cost but it's a simple solution. You won't have to upload images to your server atlest.\nyou can add check on frontend if image >2MB then only it will compress otherwise directly upload.","Q_Score":1,"Tags":"python,amazon-web-services","A_Id":62685117,"CreationDate":"2020-07-01T20:42:00.000","Title":"AWS Presigned Url Generation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to Django and trying to create an Application.\nMy scenario is:\nI have a form on which there are many items and user can click on Add to Cart to add those item to Cart. I am validating if the user is logged in then only item should be added to Cart else a message or dialogue box must appear saying please login or sign up first.\nAlthough I was able to verify the authentication but the somehow not able to show the message if user is not logged in.\nFor now I tried the below things:\n\nUsing session messages, but somehow it needs so many places to take care when to delete or when to show the message\nTried using Django Messages Framework, I checked all the configuration in settings.py and everything seems correct but somehow not showing up on HTML form\n\nDoes anyone can help me here?\nI want to know a approach where I can authenticate the user and if user is not logged in a dialogue box or message should appear saying Please login or Signup. It should go when user refreshes the page.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":62686473,"Users Score":0,"Answer":"If you are using render() for views.py you could add a boolean value to the context\ni.e render(request \"template_name.html\", {\"is_auth\": True})\nAssumedly you are doing auth in the serverside so you could tackle it this way.\nNot a great fix but might help.","Q_Score":0,"Tags":"python,django,message","A_Id":62686650,"CreationDate":"2020-07-01T22:53:00.000","Title":"How to show messages in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I uploaded my project folder to GitHub so I can work on it from both my desktop and my laptop.\nI did some work on the project on my laptop and pushed the latest commit to GitHub and hopped on my desktop to see if it worked.\nI accidentally cloned the repository to the wrong location, but when I went to delete it to clone it to the right folder, I got a pop-up saying that I \"need permission to perform this action. [I] require permission from <laptop user account> to make changes to this folder\".\nI'm kind of stumped.\nI tried taking control of the folder through Properties, but that hasn't seemed to change anything.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2247,"Q_Id":62688781,"Users Score":0,"Answer":"It depends on your OS, but:\n\na repository cloned into a wrong folder can simply be moved to the right folder (no need to re-clone)\nif that is not possible (no move or deletion), you can as a workaround leave it there, and re-clone it to the right directory\n\n\nI was able to delete the folder by deleting the files inside and working my way up\n\nIt is possible another process kept an handle on the folder itself, which would prevent its deletion.","Q_Score":1,"Tags":"python,git,permissions,administrator","A_Id":62688827,"CreationDate":"2020-07-02T04:00:00.000","Title":"Can't delete cloned git repo on my 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":1,"Web Development":0},{"Question":"I uploaded my project folder to GitHub so I can work on it from both my desktop and my laptop.\nI did some work on the project on my laptop and pushed the latest commit to GitHub and hopped on my desktop to see if it worked.\nI accidentally cloned the repository to the wrong location, but when I went to delete it to clone it to the right folder, I got a pop-up saying that I \"need permission to perform this action. [I] require permission from <laptop user account> to make changes to this folder\".\nI'm kind of stumped.\nI tried taking control of the folder through Properties, but that hasn't seemed to change anything.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2247,"Q_Id":62688781,"Users Score":0,"Answer":"If you cloned it in the wrong directory, try moving it to the right directory.\nIf you finished working with it and wish to delete it, then:\nGoto properties>security>edit permissions and give full control to your user account and then try deleting it, if that doesn't work, check if that directory is open in any other program(my directory was open in vscode), then try deleting it should work.","Q_Score":1,"Tags":"python,git,permissions,administrator","A_Id":63426381,"CreationDate":"2020-07-02T04:00:00.000","Title":"Can't delete cloned git repo on my 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":1,"Web Development":0},{"Question":"I am using dataflow to read files from GCS bucket and do some transformations on it. I am using beam.io.ReadFromText() method for that.\nWhat is the best way to mark the files that are already read, so that same file will not repeatedly read by dataflow ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":761,"Q_Id":62692416,"Users Score":1,"Answer":"A Dataflow job using beam.io.ReadFromText will read each file that matches the given pattern exactly once.  I assume from your question you're trying to run a pipeline multiple times and only read files that showed up in the GCS bucket since the last run? In that case, you have two options.\n(1) Use apache_beam.io.textio.ReadFromTextWithFilename and then record the set of filenames that you already read somewhere (e.g. write them to a text file) that you consult when constructing the set of files to read on your next run, or\n(2) Use apache_beam.io.textio.ReadAllFromText to read from a PCollection of filenames, which is computed to be the set of things that exist in your bucket (e.g. using apache_beam.io.fileio.MatchFiles) but were not read in any previous run (recorded as in (1) via a separate output file in GCS).\nIt might be worth considering if a streaming pipeline would better meet your needs.","Q_Score":1,"Tags":"python,etl,google-cloud-dataflow,apache-beam,windowing","A_Id":62704294,"CreationDate":"2020-07-02T08:43:00.000","Title":"How to mark read files in dataflow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a multi-threaded application, each thread receives data from a serial\/UART interface.\nI want to print the data in order as they have arrived, however some data is longer, some is shorter and using read_until of pyserial leads to the order being mixed up (by few milliseconds\/nanoseconds)\nI would need something like a Queue but one that removes elements in sequential order to ensure I won't mix them up.\nReceiving thread\n\nUpon receiving a 1st byte of a packet I can \"get a next number\" (some thread-safe operation)\nThen I can wait until all the data arrive\nThen I can push the whole \"packet\" into the queue\n\nConsumer thread  can only consume elements in the queue based on the sequential index, if eg. 1 and 2 were processed and there are 4 and 5 waiting already but I never got 3 I have to wait for it before moving on.\nI do not want to reinvent the wheel - is this a construct I fail to name or does anybody know anything similar?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":62693010,"Users Score":0,"Answer":"As I know there is no such structure (similar to \"ordered priority queue\") in python standard library. And most likely you will have to implement something like a wrapper over PriorityQueue that keeps track priority of items, allows to extract only in an ordered manner, and buffers the rest.","Q_Score":0,"Tags":"python,python-3.x,multithreading,queue","A_Id":62694043,"CreationDate":"2020-07-02T09:18:00.000","Title":"Indexed\/ordered queue?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to know if there is a shortcut keyboard to select an entire row when I m coding and for example my cursor is in the middle of the row. (I use spyder for python)\nThanks !","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":62694072,"Users Score":0,"Answer":"Select the active line by pressing Ctrl+W several times. Ctrl+W selects the current word, and pressing it again will select the active line.","Q_Score":0,"Tags":"python,spyder","A_Id":72422331,"CreationDate":"2020-07-02T10:18:00.000","Title":"select an entire row - shortcut keyboard","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi ive been developing some games in pygame and am looking to put them on a website for my friends to play, Ive been told that flask is the way for setting up a python website and then hosting on python anywhere, but so far I havent seen any guides on using pygame with flask and am unsure if the games will work with flask ie will it be able to display the pygame screen on the website as a normal browser game would","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":302,"Q_Id":62695130,"Users Score":0,"Answer":"No, it won't work like that.\nPygame doesn't have a browser \"backend\", it's purely for desktop games.","Q_Score":0,"Tags":"python,flask,pygame","A_Id":62695144,"CreationDate":"2020-07-02T11:16:00.000","Title":"Is flask compatible with pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been working with ML Studio (classic) and facing a problem with \"Execute Python\" scripts. I have noticed that it takes additional time to perform some internal tasks after which it starts executing the actual Python code in ML Studio. This delay has caused an increased time of 40-60 seconds per module which is aggregating and causing a delay of 400-500 seconds per execution when consumed through Batch Execution System or on running the experiments manually. (I've multiple Modules of \"Execute Python\" scripts)\nFor instance - If I run a code in my local system, suppose it takes 2-3 seconds. The same would consume 50-60 seconds in Azure ML Studio.\nCan you please help understand the reason behind this or any optimization that can be done?\nRegards,\nAnant","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":153,"Q_Id":62696966,"Users Score":2,"Answer":"The known limitations of Machine Learning Studio (classic) are:\nThe Python runtime is sandboxed and does not allow access to the network or to the local file system in a persistent manner.\nAll files saved locally are isolated and deleted once the module finishes. The Python code cannot access most directories on the machine it runs on, the exception being the current directory and its subdirectories.\nWhen you provide a zipped file as a resource, the files are copied from your workspace to the experiment execution space, unpacked, and then used. Copying and unpacking resources can consume memory.\nThe module can output a single data frame. It's not possible to return arbitrary Python objects such as trained models directly back to the Studio (classic) runtime. However, you can write objects to storage or to the workspace. Another option is to use pickle to serialize multiple objects into a byte array and then return the array inside a data frame.\nHope this helps!","Q_Score":2,"Tags":"python-3.x,azure,azure-machine-learning-studio,azure-machine-learning-service","A_Id":62697100,"CreationDate":"2020-07-02T13:00:00.000","Title":"Why does Azure ML Studio (classic) take additional time to execute 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":"In the normal Jupyter notebooks, we can add line numbers by pressing the L key after selecting the cell. All the subsequent cells for that notebook will have line numbers automatically.\nBut this is missing in VSCode. Every time a new cell is created, we need to select the cell and press the L key to enable the numbering for that cell which is very tiresome.\nIs there a way to automatically enable line numbering for all the cells in the VSCode Jupyter notebook instead of manually pressing the L key for each and every cell?\nThank you.","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":15393,"Q_Id":62698920,"Users Score":40,"Answer":"In VS Code Jupyter Notebook, you can toggle line numbers by pressing L. The trick is to select the current cell first.\nYou could select your cell by clicking in the blank area on the left margin of the cell (when it's selected the bar on the left turns blue). Now if you press L on your keyboard, you would be able to turn the line numbers on\/off.","Q_Score":33,"Tags":"python,visual-studio-code,jupyter","A_Id":63540334,"CreationDate":"2020-07-02T14:41:00.000","Title":"Line numbers for every cell in VSCode Jupyter Notebook Cells","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the normal Jupyter notebooks, we can add line numbers by pressing the L key after selecting the cell. All the subsequent cells for that notebook will have line numbers automatically.\nBut this is missing in VSCode. Every time a new cell is created, we need to select the cell and press the L key to enable the numbering for that cell which is very tiresome.\nIs there a way to automatically enable line numbering for all the cells in the VSCode Jupyter notebook instead of manually pressing the L key for each and every cell?\nThank you.","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":15393,"Q_Id":62698920,"Users Score":1,"Answer":"I tried CTRL + A (outside cells): select all cells and right clicked \"show cell line number\". It displayed line number for every cell.","Q_Score":33,"Tags":"python,visual-studio-code,jupyter","A_Id":71479869,"CreationDate":"2020-07-02T14:41:00.000","Title":"Line numbers for every cell in VSCode Jupyter Notebook Cells","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the normal Jupyter notebooks, we can add line numbers by pressing the L key after selecting the cell. All the subsequent cells for that notebook will have line numbers automatically.\nBut this is missing in VSCode. Every time a new cell is created, we need to select the cell and press the L key to enable the numbering for that cell which is very tiresome.\nIs there a way to automatically enable line numbering for all the cells in the VSCode Jupyter notebook instead of manually pressing the L key for each and every cell?\nThank you.","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":15393,"Q_Id":62698920,"Users Score":6,"Answer":"I always try any combination with modifiers keys.\nFound out that pressing Shift + L enables the lines number for all the notebook at once","Q_Score":33,"Tags":"python,visual-studio-code,jupyter","A_Id":68248967,"CreationDate":"2020-07-02T14:41:00.000","Title":"Line numbers for every cell in VSCode Jupyter Notebook Cells","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the normal Jupyter notebooks, we can add line numbers by pressing the L key after selecting the cell. All the subsequent cells for that notebook will have line numbers automatically.\nBut this is missing in VSCode. Every time a new cell is created, we need to select the cell and press the L key to enable the numbering for that cell which is very tiresome.\nIs there a way to automatically enable line numbering for all the cells in the VSCode Jupyter notebook instead of manually pressing the L key for each and every cell?\nThank you.","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":15393,"Q_Id":62698920,"Users Score":20,"Answer":"Click on the blank area (left side of the cell).\nPress Shift + L.","Q_Score":33,"Tags":"python,visual-studio-code,jupyter","A_Id":69022927,"CreationDate":"2020-07-02T14:41:00.000","Title":"Line numbers for every cell in VSCode Jupyter Notebook Cells","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to set up my python web scraper to run at a set time using task scheduler but I am getting this error PermissionError: [Errno 13] Permission denied: 'geckodriver.log' I have no idea why because it works fun when running the python script by using the batch file or just by double-clicking the .py file. Anyone have any ideas about why it only happens with task scheduler.\nFYI: I am using a batch file that calls the python.exe and the .py script and this what task scheduler is using to trigger the script. I am using selenium and firefox.\nMany thanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":481,"Q_Id":62699600,"Users Score":0,"Answer":"I fixed this issue by checking the Run with highest privileges and configure for Windows 10","Q_Score":1,"Tags":"python,python-3.x,selenium,geckodriver","A_Id":62701037,"CreationDate":"2020-07-02T15:14:00.000","Title":"Geckodriver PermissionError: [Errno 13] Permission denied: 'geckodriver.log' only with task scheduler","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"First, sorry if my question is not clear or is too simple, but I'm getting confuse about it. I have an EC2 instance where I want to run some python code previously developed in my computer. I want to automatically install all the packages that the python script use instead of doing pip in my EC2 instance for every package. I don't know if I need to use Docker, create a repository in GitHub and then clone it from my EC2 instance, or there is another alternative.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":417,"Q_Id":62700635,"Users Score":2,"Answer":"You have a few options to go about it.\n\nSetup bootstrap to install your packages when you stand up a new EC2 instance.\ncreate EC2 instance from image, using docker or with aws AMI.\n\nThis will setup an EC2 instance with all the dependency packages ready.","Q_Score":0,"Tags":"python,amazon-web-services,github,amazon-ec2","A_Id":62700715,"CreationDate":"2020-07-02T16:07:00.000","Title":"Automatically install python modules in EC2","Data Science and Machine Learning":0,"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":"AttributeError: Can't get attribute 'DeprecationDict' on \nShowing error in model = pickle.load(open('rf_regression_model.pkl', 'rb')) this line.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1663,"Q_Id":62702362,"Users Score":2,"Answer":"You used a new version of sklearn to load a model which was trained by an old version of sklearn.\nSo, the options are:\n\nRetrain the model with current version of sklearn if you have the\ntraining script and data\nOr fall back to the lower sklearn version\nreported in the warning message","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,pickle","A_Id":63251293,"CreationDate":"2020-07-02T17:55:00.000","Title":"Getting 'AttributeError: Can't get attribute 'DeprecationDict' on <module 'sklearn.utils.deprecation'' this error while executing ML project","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying install the Python Extension for VSCode for all users of a machine, but it is getting installed for only the current user. Can anyone help me on this.\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":156,"Q_Id":62702707,"Users Score":0,"Answer":"Issue has been resolved after saving the path \"C:\\Users<userProfile>.vscode\\extensions\"  using the our Profile management tool. the data related to the extensions is stored in above mentioned path. so after saving the path users were able to add the extensions.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":63701266,"CreationDate":"2020-07-02T18:19:00.000","Title":"How to install Python Extension in VScode for all users of a machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to download several large files from the internet (specifically Reddit monthly submissions from the site PushShift) into an S3 bucket. I am SSHed into an EC2 instance and have a Jupyter notebook running.\nIdeally I want to be able to write a Python script in Jupyter notebook of my EC2 instance that downloads the file from the internet and then pushes it to my S3 bucket. How would I go about doing this?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":200,"Q_Id":62702724,"Users Score":2,"Answer":"It is not possible to \"download data from the Internet into Amazon S3\".\nAmazon S3 is an object storage service. You can upload data to S3 and download data from S3, but it is not possible to tell S3 to download data from some other location and store it.\nYou will need a program running somewhere that obtains the data from the Internet, then uploads it (creates an object) in Amazon S3. Such a program could be clever enough to 'stream' the data to S3 by downloading content in-memory and then sending it to S3, without having to save to disk in between, but you would need to write that code.\nAs to 'where' such a program might run, it would be most efficient to run such code either as an AWS Lambda function or on an Amazon EC2 instance that is in the same region as the Amazon S3 bucket.\nSince you are running a Jupyter notebook on an Amazon EC2 instance, it would be easiest to download the file to local storage, then upload it to S3.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,amazon-ec2,jupyter-notebook","A_Id":62706422,"CreationDate":"2020-07-02T18:20:00.000","Title":"How do I download data from the internet to an S3 bucket via EC2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to link two projects Django. both of them project are run in the same server. What tools or file I need for this goal? when I click on some button in my current project's page I should get a page from the other project.. Can you suggest a way to do?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":72,"Q_Id":62702805,"Users Score":0,"Answer":"Create REST APIs in one project and invoke the API data from the other. The same way you link a python flask project with ReactJS","Q_Score":0,"Tags":"python,django","A_Id":62703321,"CreationDate":"2020-07-02T18:25:00.000","Title":"How to link two projects django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"for my future project i would like my app to be live 24\/7 on a Linode\/UpCloud vps with 1 thread.\nMy app uses threading python library for multiple tasks, what will happen if i run that app on 1 thread?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":150,"Q_Id":62703399,"Users Score":5,"Answer":"Short Answer:\nIt will run fine. E.g.\n\nThread 1 is given CPU\nThread 2 is given CPU\nThread 1 is given CPU\nThread 1 is given CPU\nThread 2 is given CPU\n\nExplanation:\nMultithreading does not necessarily mean that it is also multi-processing. If there is only one CPU with one thread, then the threads in your application will run turn by turn (almost). And this context switch will be so fast that you cannot even feel it.\nEDIT (Thanks Barmar's comment):\nIt's called \"timesharing\", and it's how multiple processes work whenever the computer only has one CPU.","Q_Score":0,"Tags":"python,multithreading,vps","A_Id":62703621,"CreationDate":"2020-07-02T19:06:00.000","Title":"What will happen if i run a 2 threaded application on a vps server with 1 thread?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have successfully installed opencv 4.3.0 on my Mac OS Catalina, python 3.8 is installed also, but when I try to import cv2, I get the Module not found error.\nPlease how do I fix this?\nthanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":436,"Q_Id":62704317,"Users Score":0,"Answer":"I was having issue with installing opencv in my Macbook - python version 3.6 ( i downgraded it for TF 2.0) and MacOs Mojave 10.14. Brew , conda and pip - none of the three seemed to work for me. So i went to [https:\/\/pypi.org\/project\/opencv-python\/#files] and downloaded the .whl that was suitable for my combo of python and MacOs versions. Post this navigated to the folder where it was downloaded and executed pip install .\/opencv_python-4.3.0.36-cp36-cp36m-macosx_10_9_x86_64.whl","Q_Score":2,"Tags":"python,python-3.x","A_Id":63223602,"CreationDate":"2020-07-02T20:11:00.000","Title":"installing Opencv on Mac Catalina","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have successfully installed opencv 4.3.0 on my Mac OS Catalina, python 3.8 is installed also, but when I try to import cv2, I get the Module not found error.\nPlease how do I fix this?\nthanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":436,"Q_Id":62704317,"Users Score":0,"Answer":"Can you try pip install opencv-python?","Q_Score":2,"Tags":"python,python-3.x","A_Id":62707394,"CreationDate":"2020-07-02T20:11:00.000","Title":"installing Opencv on Mac Catalina","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working with two numpy matrixes, U (dimensions Nu x 3) and M (dimensions 3 x Nm)\nA contains Nu users and 3 features\nM contains Nm movies (and the same 3 features)\nFor each user of U, I would like to calculate its euclidian distance to every movie in M (so I need to compute Nu*Nm euclidian distances).\nIs this possible without an explicit double for-loop? I am working with large dimensions matrixes and the double for-loop will probably take too much time.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":62705066,"Users Score":0,"Answer":"I'm afraid not. You need to compute the euclidian distance for every pair of (user, movie), so you'll have a time complexity of numOfUsers * numOfMovies, which would be a double for loop. You can't do less operations than that, unless you're willing to skip some pairs. The best you can do is optimize the euclidian distance calculation, but the number of operations you're going to do will be quadratic one way or the other.","Q_Score":0,"Tags":"python,arrays,numpy,scipy,distance","A_Id":62705220,"CreationDate":"2020-07-02T21:09:00.000","Title":"Euclidian distance between two python matrixes without double for-loop?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Dear smart people of stackoverflow,\nI know this question has been asked a lot here but none of the posted solutions have worked for me as of yet. Any help here would be much appreciated:\nThe Problem: Cannot connect to flask app server from other devices (PCs, mobiles) on the same network. (in other words: localhost works perfectly but I cannot connect from external device)\nWhat I've Tried:\n1) Setting app.run(host='0.0.0.0', port=5000, debug=True, threaded=True) in the app.py so that the server will listen on all available network interfaces.\n2) Enabling TCP traffic for port 5000 in local network in Windows Defender Firewall (with inbound and outbound rules added)\n3) Using my host PC's IPv4 address in the URL bar of my external device's browser in the following format: http:\/\/<host_ipaddress>:<port>\/\n4) Using my host PC's hostname in the URL bar of my external device's browser in the following format: http:\/\/<host_name>:<port>\/\n5) Running the app.py file from Windows Powershell and Python (.py) Executor\nNone of these solutions has worked so far, even after attempting to connect from a few different external devices. Thanks in advance for your help!","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4838,"Q_Id":62705271,"Users Score":0,"Answer":"I did a similar setup with my django project. Your PC network settings are probably all good, but your router ( at least for wlan) is blocking the traffic. I solved this by tampering with needed settings in router manager api, which can be found from 192.168.1.1 in your local network. You can check your device ip addresses etc.","Q_Score":4,"Tags":"python,flask,web-applications,localhost,ip","A_Id":62705377,"CreationDate":"2020-07-02T21:25:00.000","Title":"Connect to Flask Server from other devices on same network","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Dear smart people of stackoverflow,\nI know this question has been asked a lot here but none of the posted solutions have worked for me as of yet. Any help here would be much appreciated:\nThe Problem: Cannot connect to flask app server from other devices (PCs, mobiles) on the same network. (in other words: localhost works perfectly but I cannot connect from external device)\nWhat I've Tried:\n1) Setting app.run(host='0.0.0.0', port=5000, debug=True, threaded=True) in the app.py so that the server will listen on all available network interfaces.\n2) Enabling TCP traffic for port 5000 in local network in Windows Defender Firewall (with inbound and outbound rules added)\n3) Using my host PC's IPv4 address in the URL bar of my external device's browser in the following format: http:\/\/<host_ipaddress>:<port>\/\n4) Using my host PC's hostname in the URL bar of my external device's browser in the following format: http:\/\/<host_name>:<port>\/\n5) Running the app.py file from Windows Powershell and Python (.py) Executor\nNone of these solutions has worked so far, even after attempting to connect from a few different external devices. Thanks in advance for your help!","AnswerCount":6,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4838,"Q_Id":62705271,"Users Score":5,"Answer":"I solved the issue by changing my home network profile to private instead of public, which allows my PC to be discoverable. Completely overlooked that!\nHope this helps someone!","Q_Score":4,"Tags":"python,flask,web-applications,localhost,ip","A_Id":62720199,"CreationDate":"2020-07-02T21:25:00.000","Title":"Connect to Flask Server from other devices on same network","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This is mostly a sanity check, but I'm writing a python program to run in the background on boot and control two motors and two heaters. It determines what to do by checking a settings file every second (using Asyncio). A second program can be run by the user to modify the pickled settings file.\nIf this were to run for a long period of time (12+ hours), is this the best way to do it? I'm well versed in general coding principles, but not specifically Python.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":83,"Q_Id":62705333,"Users Score":1,"Answer":"It's okay for that program that reads the file, but if multiple programs can edit the same file, You might encounter some issues and they might corrupt the file...\nSay both program_1 and program_2 can edit the same file. The problem is that you wouldn't be editing the file directly like its a global variable. You will be reading it into some variables, making changes in the variables, and then overwriting the file with the new settings.\nNow consider the following scenario:\n\nprogram_1 Reads the file.\nprogram_2 Reads the file.\nprogram_1 makes some changes to some data.\nprogram_2 makes some changes to other data.\nprogram_1 rewrites the file with the new content.\nprogram_2 rewrites the file with the new content.\n\nin the above scenario, the changes made by program_1 was accidentally removed by program_2 because they both attempted to make changes at the same time.\nSimple solution\nMake sure each program locks the file before starting to read and edit. And wait for it to be unlocked if it was already locked by the other program.","Q_Score":0,"Tags":"python,io,standards","A_Id":62705435,"CreationDate":"2020-07-02T21:30:00.000","Title":"Is it okay to write to a file and read it in a different program simultaneously","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently migrated my Python \/ Jupyter work from a macbook to a refurbrished Gen 8 HP rackmounted server (192GB DDR3 2 x 8C Xeon E5-2600), which I got off amazon for $400. The extra CPU cores have dramatically improved the speed of fitting my models particularly for decision tree ensembles that I tend to use a lot. I am now thinking of buying additional servers from that era (early-mid 2010s) (either dual or quad-socket intel xeon E5, E7 v1\/v2) and wiring them up as a small HPC cluster in my apartment. Here's what I need help deciding:\n\nIs this a bad idea? Am I better off buying a GPU (like a gtx 1080). The reason I am reluctant to go the GPU route is that I tend to rely on sklearn a lot (that's pretty much the only thing I know and use). And from what I understand model training on gpus is not currently a part of the sklearn ecosystem. All my code is written in numpy\/pandas\/sklearn. So, there will be a steep learning curve and backward compatibility issues. Am I wrong about this?\n\nAssuming (1) is true and CPUs are indeed better for me in the short term. How do I build the cluster and run Jupyter notebooks on it. Is it as simple as buying an additional server. Designating one of the servers as the head node. Connecting the servers through ethernet. Installing Centos \/ Rocks on both machines. And starting the Jupyter server with IPython Parallel (?).\n\nAssuming (2) is true, or at least partly true. What other hardware \/ software do I need to get? Do I need an ethernet switch? Or if I am connecting only two machines, there's no need for it? Or do I need a minimum of three machines to utilize the extra CPU cores and thus need a switch? Do I need to install Centos \/ Rocks? Or are there better, more modern alternatives for the software layer. For context, right now I use openSUSE on the HP server, and I am pretty much a rookie when it comes to operating systems and networking.\n\nHow homogeneous should my hardware be? Can I mix and match different frequency CPUs and memory across the machines? For example, having 1600 MHz DDR3 memory in one machine, 1333 MHz DDR3 in another? Or using 2.9 GHz E5-2600v1 and 2.6 GHz E5-2600v2 CPUs?\n\nShould I be worried about power? I.e. can I safely plug three rackmounted servers in the same power strip in my apartment? There's one outlet that I know if I plug my hairdryer in, the lights go out. So I should probably avoid that one :) Seriously, how do I run 2-3 multi-CPU machines under load and avoid tripping the circuit breaker?\n\n\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":241,"Q_Id":62705985,"Users Score":1,"Answer":"Nvidia's rapids.ai implements a fair bit of sklearn on gpus. Whether that is the part you use, only you can say.\n\nUsing Jupiter notebooks for production is known to be a mistake.\n\nYou don't need a switch unless latency is a serious issue, it rarely is.\n\nCompletely irrelevant.\n\nFor old hardware of the sort you are considering, you will be having VERY high power bills. But worse, since you will have many not-so-new machines, the probability of some component failing at any given time is high, so unless you seek a future in computer maintenance, this is not a great idea. A better idea is: develop your idea on your macbook\/existing cluster, then rent an AWS spot instance (or two or three) for a couple of days. Cheaper, no muss, no fuss. everything just works.","Q_Score":1,"Tags":"python,jupyter-notebook,gpu,cluster-computing,hpc","A_Id":62706162,"CreationDate":"2020-07-02T22:37:00.000","Title":"DIY HPC cluster to run Jupyter\/Python notebooks","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have next line in python\nparser = argparse.ArgumentParser(version = version, description = desc, epilog= \"{}\\n\\n{}\".format(example,credit), formatter_class=argparse.RawTextHelpFormatter)\nWhen I run with python 2.7, there is no problem.\nBut when I run with python 3.6 , I got this error:\nFile \"MY_FILE.py\", line 97, in \nmain()\nFile \"MY_FILE.py\", line 60, in main\nparser = argparse.ArgumentParser(version = version,description = desc, epilog= \"{}\\n\\n{}\".format(example,credit), formatter_class=argparse.RawTextHelpFormatter)\nTypeError: init() got an unexpected keyword argument 'version'\nIs there some update fix I need to do in order to run with python 3.6 ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":62706814,"Users Score":0,"Answer":"the version argument is no longer supported in python 3.6, it can be included as a part of \"help\" now. The Documentation for Python 2 and Python 3 clears it up. The program should work when you remove this parameter.","Q_Score":0,"Tags":"python-3.x,argparse","A_Id":62721112,"CreationDate":"2020-07-03T00:29:00.000","Title":"argparser.ArgumentParser change between python 2.7 and python 3.6?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to read in a list of files (inc path) from either a spreadsheet or a text file for some downstream processing. The list has been generated as a log from another process and the path includes a 2 digit year folder followed by a project number folder as follows:\n\\\\servername\\projects\\19\\1901001\\project files\\filetobeprocessed.abc\nThe problem is as soon as the above string is read in, it is interpreted as\n\\\\servername\\\\projects\\x019\\x01901001\\\\project files\\x0ciletobeprocessed.abc\nWhich then means that I cannot use the path to access the file.\nAssigning the path string to a variable, I have tried:\nthePath = repr(pathreadfromfile)\nAfter assigning the path string I have tried fixing the string using\nthePath.replace('\\x0','\\\\')\nthePath.replace('\\\\x0','\\\\')\nthePath.replace(r'\\x0','\\\\')\nNothing seems to fix the path so that it can be used to open the file.\nI can't find anything in either python or Ironpython that suggests a fix for this programatically. I know that you can fix this is the path is known within the code by using r'' to use raw text to create the path.\nAny help appreciated","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":62707478,"Users Score":0,"Answer":"Obviously, the backslash \\ is interpreted as an escape character.\nFor a really simple solution, hopefully the simplest, I would suggest using forward slash \/ for all your path separators instead of backslash.\nIf you really need the backslash somewhere further down the road, you can replace them back again.","Q_Score":0,"Tags":"path,numbers,ironpython,revit,slash","A_Id":62726488,"CreationDate":"2020-07-03T02:09:00.000","Title":"Revit Ironpython Shell - Parsing a list of filenames with a number after a backslash in the path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know it's possible to disable InsecureRequestWarning but I need the opposite, I want to either catch it or make the request abort and throw an exception if this warning is present.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":139,"Q_Id":62710891,"Users Score":1,"Answer":"I've solved it with warnings.filterwarnings(\"error\"), which turns warnings into errors so they can be caught with try catch.","Q_Score":0,"Tags":"python,python-3.x,python-requests","A_Id":62712580,"CreationDate":"2020-07-03T07:52:00.000","Title":"Is there a way to catch InsecureRequestWarning from python request","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 get the parameter dict of a lightgbm Booster that is loaded from a model file? I have optimized my model and then saved it using this line model.save_model('lgb-opt.txt') and then loaded with this one model = lgb.Booster(model_file='lgb-opt.txt). Now, if I try to get model.params, it returns me an empty dictionary. However, if I manually set the parameters and train again, model.params returns me the right parameter dictionary. So, does the set get lost while saving the model, or there is still a way to obtain it? It would be very time-consuming to optimize again just for the parameter set.\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2435,"Q_Id":62711267,"Users Score":1,"Answer":"Since your tag was lightgbtm is suppose that lgb.Booster is supposed to be \"lightgbm.Booster\"?\nSince this class has different parameters you should specifically define, which of them u are using. Try:\nmodel = lgb.Booster(model_file='lgb-opt.txt')\nMaybe this will help.","Q_Score":2,"Tags":"python,lightgbm","A_Id":62711710,"CreationDate":"2020-07-03T08:15:00.000","Title":"How can I get the parameters of a lightgbm Booster model loaded from a model file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to write Python3 code with Gtk3, in SLES11 linux machine\nI get this error:\n\nD-Bus library appears to be incorrectly set up; failed to read machine\nuuid: Failed to open \"\/etc\/machine-id\"\n\nthe \/etc\/machine-id not present in my machine, but I can't have permissions to generate that using \"dbus-uuidgen\"\nIs there any option to override that in the python code itself or in some env variable ?\nThanks\nOren","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":647,"Q_Id":62711323,"Users Score":1,"Answer":"No, having \/etc\/machine-id set is a requirement of D-Bus being installed. It looks like D-Bus was not installed correctly. You should be able to run dbus-uuidgen --ensure as root (or using sudo). If you don\u2019t have root access, you cannot fix this situation and you should get in touch with your system administrator.","Q_Score":0,"Tags":"python,linux,gtk,gtk3,dbus","A_Id":62715776,"CreationDate":"2020-07-03T08:19:00.000","Title":"Python3 Gtk3 : D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open \"\/etc\/machine-id\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using miniconda on Ubuntu 20.04 with fish shell. I was able to create and activate my specific environment. My problem is with Python version which is related with $PATH.\n\nWhen I start clean fish shell, conda set it up for (base) environment $PATH looks like this:\n\nPATH=\/opt\/conda\/bin:\/opt\/conda\/condabin:\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:\/usr\/games:\/usr\/local\/games:\/opt\/conda\/bin:\/snap\/bin:\/opt\/conda\/bin\nit means, when I start Python it uses \/opt\/conda\/bin\/python version - conda (base) version.\n\nWhen I start my environment conda activate XXX it switch to XXX (more precisely, switch from base to XXX) and my $PATH looks like this:\n\nPATH=\/opt\/conda\/condabin:\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:\/usr\/games:\/usr\/local\/games:\/home\/USER\/.conda\/envs\/XXX\/bin:\/snap\/bin:\/opt\/conda\/bin\nit means, when I start Python it uses \/usr\/bin\/python. It is system version of Python.\n\nWhen I start new fish shell, deactivate (base) environment and and activate created one (XXX), $PATH looks like:\n\nPATH=\/home\/USER\/.conda\/envs\/XXX\/bin:\/opt\/conda\/condabin:\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:\/usr\/games:\/usr\/local\/games:\/snap\/bin:\/opt\/conda\/bin\nit means, when I start Python it uses \/home\/USER\/.conda\/envs\/XXX\/bin\/python\nProblems:\n\nWhenever I use XXX environment I expect to use \/home\/USER\/.conda\/envs\/XXX\/bin\/python which is not true when I switch from (base) to (XXX). To use above python I need to deactivate base and then switch to (XXX). It seams, \/home\/USER\/... should always be at the beginning of $PATH to choose appropriate python version.\n\nI would like to not use (base) as a default when I start new shell. I'v tried config --set auto_activate_base false which add auto_activate_base: false  to .\/condarc but it seams to be ignored.\n\n\nMy conda version is 4.8.3. My ~\/.config\/fish\/config.fish contains: eval \/opt\/conda\/bin\/conda \"shell.fish\" \"hook\" $argv | source.\nWhat I'm do wrong? How can I correct it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":487,"Q_Id":62712180,"Users Score":0,"Answer":"you can do it in one Line and don't bother yourself (MacOS and Linux)\n\/(your conda installation path)\/bin\/conda init fish\nyour condo installation usually in '\/Users\/- your UserName -\/anaconda3'\nif someone want to know about install fish, best way is Homebrew. after brew install fish you must add fish to supportable shells in \/etc\/shells. and then with chsh change default shell to fish.\nif it's not clear ask in comment!","Q_Score":4,"Tags":"python,linux,anaconda,conda,fish","A_Id":72248167,"CreationDate":"2020-07-03T09:11:00.000","Title":"conda - PATH order in fish shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I currently converted a list of roughly 1200 items (1200 rows) and a problem arised when i looked at the date of each individual item and realised that the day and month was before the year which meant that ordering them by date would be useless. Is there any way I can reorder over 1200 dates so that they can be formatted correctly with me having to manually do it. Would I have to use python. I am very new to that and I don't know how to use it really.\nHere's an example of what I get:\nSeptember 9 2016\nAnd this is what i want:\n2016 September 9\nI am also using the microsoft excel if anyone was asking.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":62713065,"Users Score":0,"Answer":"it must be date format.\nyou can split date parts in other cells and re-merge them in preferred format...","Q_Score":0,"Tags":"python,excel,powerquery","A_Id":62713982,"CreationDate":"2020-07-03T10:03:00.000","Title":"How to reformat the date text in each individual box of a column?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have developed a python script and want to put it in a RPM package. The only problem is that this script uses ovirtsdk4 module, which is not one of the builtin python modules. That being said, I would have to install this module within the RPM package. I can think of two ways to approach this:\n1 - Using pip3 in the %post section.\n2 - Putting the python3-ovirt-engine-sdk4 in the \"Requires: package \" section.\nHowever, first way does not seem quite reliable and the second doesn't seem to work properly since this package is not available on the CentOS-XXX repositories. (It belong to the ovirt repo).\nCan you think of a better way to approach this or am I missing anything?\nMany thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":62713985,"Users Score":0,"Answer":"The fact that the package is not in the CentOS repositories should not cause any problem, just make sure that you can download from the ovirt repository, then the update should run normally.\nTest first manually if you can yum install python3-ovirt-engine-sdk4.\nEDIT: don't install using pip3, because then you cannot manage the dependencies with rpm. You had the right intuition trying to use the rpm dependencies.","Q_Score":0,"Tags":"python-3.x,rpmbuild,ovirt","A_Id":62714174,"CreationDate":"2020-07-03T10:56:00.000","Title":"Building RPM package requires packages from outside repositories","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm looking at using plotly-dash however it is still not clear to me whether what I want to do is possible.\nI would like to build a UI that allows the user the upload their data, set some parameters and do some data analysis. Once this is done the user would be able to save the dashboard they've created to file, so they can reopen it as it is and make further changes if required.\nSo once this is done the user can either open the blank UI and start another dashboard or open the dashboard they created previously.\nDoes plotly-dash have this functionality?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":355,"Q_Id":62714503,"Users Score":1,"Answer":"Broadly speaking, yes that is possible with Dash. How easy or difficult it will be depends largely on what sort of analysis you want users to be able to do, and less so on saving\/loading the dashboard.","Q_Score":0,"Tags":"python,dashboard,plotly-dash","A_Id":62715802,"CreationDate":"2020-07-03T11:29:00.000","Title":"Plotly-dash can user edit and save changes to dashboard?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question about flasks session logic. First of all as I know there are two ways to store session data, one is on client side and the second is server side. Flask, as I know, is using the former one (client side) where the session is encrypted and stored on the browser of the client.\nLet's us say we want to make a login on a flask-backend\n\nUser does a login, flask generates a session and through set-cookie the client stores the session\nUser makes another request to the backend and sends its cookies where also the session is stored and flask validates the session with the key which it used to encrypt the session\nWhen the session is valid, flask loads the session, thus that means the user is logged in\n\nAnd JWT works the following as I know. It generates a token and the client stores the token and sends it in each request to the server, where the token is validated.\nAs I know, both flask and JWT uses a secret to encrypt the data.\nSo can we say, that flask-session and JWT are somehow similar?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":549,"Q_Id":62715200,"Users Score":1,"Answer":"Both jwt and flask session work on client, but the key difference is that flask session stores the signed session data at the client cookie, but in jwt you have the independence to store the token anywhere you want, say localstorage, cookie etc.\nAnd jwt will be base64 encoded by default while in flask session it has to be done manually for security. But yes the difference between traditional sessions (say php) and flask-sessions is that the session data is stored in the client rather than as a file at the server (while the client cookie has session id in traditional sessions).","Q_Score":0,"Tags":"python,authentication,session,flask,jwt","A_Id":62718556,"CreationDate":"2020-07-03T12:11:00.000","Title":"Is Flask-Session logic similar to JWT","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've multiple sub-folders and each sub-folder has multiple files. I need to select the sub-folder randomly and then need to select a random file in that sub-folder. Let's say I've five folders A, B, C, D, E, and each folder contains another folder named data and this data folder contains multiple files. I need to pick the folder randomly from the five folders and then open the data folder and finally randomly select a file.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":694,"Q_Id":62716363,"Users Score":1,"Answer":"Keep the folder names in a list.\n\nimport random\nimport os\nfolders = [0,1,2,3,4]\nselected_folder = random.choice(folders)\npath = selected_folder+\"\/data\"\n\nNow to take random file from the path, do random.choice() and pass the list of files in that path.\nUse os.listdir(path) to get the list of files.","Q_Score":2,"Tags":"python,python-3.6","A_Id":62716638,"CreationDate":"2020-07-03T13:22:00.000","Title":"How to select file randomly from multiple sub-folders","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a calculator in Python using Tkinter  module,though I converted it to exe but I am not able to convert it to apk.please tell me how to do so?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1618,"Q_Id":62718170,"Users Score":1,"Answer":"I personally haven't seen anyone do that. I think it would be best to try and re-make you calculator in the Kivy framework if you want to later turn it into an APK using bulldozer.  Tkinter is decent for beginners but if you want to have nice Desktop UI's use PyQT5 and if you're interested in making mobile apps use Kivy. Tkinter is just a way to dip into using GUIs in python.","Q_Score":0,"Tags":"python-3.x,user-interface,tkinter,apk,exe","A_Id":62722246,"CreationDate":"2020-07-03T15:06:00.000","Title":"How to convert py file to apk?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My goal is to build a symptom recommendation system\nI have 3 columns of data in my excel.\n\nPatient id\nSymptoms\nDisease detection\n\nFor each patient id there is one or more than one symptom that leads to a disease detection. My goal is to find the most relevant symptoms given an input symptom.\nI am unable to think of a way to come up with a plan given the data limitation. One idea I have is to transform the data into a matrix with all symptoms as columns and disease as rows. For each disease if there is a symptom mark 1 else put 0 for all other symptoms. Will this approach work? Any idea on how to design this system","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":62718475,"Users Score":0,"Answer":"You could use scikit learn library to build a predictive model where the classifier is made up of the symptoms and the labels as the disease. You can then analyse which symptoms contribute most to the disease.","Q_Score":0,"Tags":"python,architecture,recommendation-engine,relevance,recommender-systems","A_Id":62718544,"CreationDate":"2020-07-03T15:27:00.000","Title":"Architecture design to find the most relevant symptoms given an input symptom","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create something which keeps track of which tenants live in what apartment and does some other things like calculating ROI and keeping track of costs.\nWhat is recommended to do in this case? Use a class which would be called Apartments and then have tenants that live within a certain instance \/ apartment? Or would it be better to keep track of something like that with a database? Or perhaps a combination of those two?\nI don't really know what the possibilities are and I tried googling \/ stackoverflowing it but I couldn't really find an answer to my question.\nPS. the programming language I'll be using is Python.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":295,"Q_Id":62719650,"Users Score":1,"Answer":"The first question you should be asking yourself is whether you want your data to be persistent meaning - do you want your data to be gone once you stop your application or not?\nIf you don't need persistence, then you don't need database.\nIf the question is - yes, I want persistence - then we can dig deeper. Do you need the data to be accessible by different users, possibly doing modifications to the data at the same time? If no, then don't use a database. Store the data in some file in a format that is easy to parse.\nIf - again - we say yes, then databases are one way to solve the issue. Next question would be - which database do you want? Relational, key-value, document, graph? (Usually if you don't know the answer to this question mean you want a relational one...)\nAs Sushant mentioned a minute ago - you will also need some ways to represent the data in your application. You will have some structures (let's call it a model), and you will load the data into your model and store the data from into the database. ORM tools do that for you, but if it is the first time for you to see such things, you might also be good without.\nHaving said that, you are up to a long journey. Remember to have fun.","Q_Score":0,"Tags":"python,database,class","A_Id":62719842,"CreationDate":"2020-07-03T16:50:00.000","Title":"Should I use a database or a class?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using and have been usnig Visual Studio to develop Python code.\nPreviously when I saved a file it would review the code and provide warnings and errors. Now I only get \"No problems have been detected in the workspace so far\"\nI have looked through settings but cannot find anything unchecked that is relevant.\nI have intentional errors in the code but get no error messages.\nNo idea what changed.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2715,"Q_Id":62720400,"Users Score":0,"Answer":"You should open the Visual Studio Code from the Developer Command Prompt. Using a Developer Command Prompt (and not a basic\/classic\/regular console) helps to make sure that all the paths and environment variables are set up correctly.","Q_Score":1,"Tags":"python,visual-studio-code,vscode-settings","A_Id":64592618,"CreationDate":"2020-07-03T17:45:00.000","Title":"No problems have been detected in the workspace so far","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tested a lot of scenarios and in every one of them, df['colName'] has outputted the same thing as df.loc[:,'colName'].\nI'm just wanting to be sure that these really are exactly equivalent.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":506,"Q_Id":62721054,"Users Score":0,"Answer":"Yes, they do the same thing.\ndf['colName'] will return the column specified in the square brackets, and df.loc['rowName'] will return the row specified in the square brackets.\ndf.loc['row1Name':'row2Name','colName'] will return all the elements of the column\nspecified in the brackets, from the first row specified to the last row specified.\ndf.loc[:,'colName'] is basically telling python to return all the elements from the column specied\nfrom all the rows, and so, it returns the whole column.\nNote that the parsing process may differ, one way may be more efficient than the other.","Q_Score":1,"Tags":"python,pandas","A_Id":62721161,"CreationDate":"2020-07-03T18:39:00.000","Title":"Python and pandas: is df[\"colName\"] exactly equivalent to df.loc[:,\"colName\"]?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know it's a very naive question, but please any information is welcome.\nI have a data series containing 0's and 1's in random order.\nIs there any way i can predict the next outcome based on the previous series?\nLet's say, there's a website that gives out a value (0 or 1) at equal time intervals, i collect the data from there and i need to predict what value would be posted next. It surely doesn't need to be 100% accurate.\nP.S Python solution is preferred","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":62721102,"Users Score":0,"Answer":"If it's a completely random series, there is no way of predicting the next outcome. That's why it's called random. However, there might be a way. Please provide more information about your problem, like where did you call the random function or a piece of code.","Q_Score":0,"Tags":"python,data-science,series,prediction,predictive","A_Id":62721398,"CreationDate":"2020-07-03T18:42:00.000","Title":"Predicting outcome based on previous series","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to perform a kmeans in Python using scikit-learn. The thing is my data are complex values and Python doesn't like it.\nIs there any mean to use sklearn with complex values ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":444,"Q_Id":62723117,"Users Score":0,"Answer":"It depends on what those imaginary numbers represent to you.\nIf you want to cluster them in a certain sense you have to define a metric.\nYou can choose to perform a clustering based on theyr real and imaginary coordinates or you can use the absolute value as value for the clustering. Otherwise you can convert the imaginary representation in the polar form and so cluster them based on the modulus and angular argument.","Q_Score":1,"Tags":"python,scikit-learn,complex-numbers","A_Id":62723204,"CreationDate":"2020-07-03T21:55:00.000","Title":"Using sklearn with complex values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to perform a kmeans in Python using scikit-learn. The thing is my data are complex values and Python doesn't like it.\nIs there any mean to use sklearn with complex values ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":444,"Q_Id":62723117,"Users Score":0,"Answer":"Thank you for your answers. Actually the imaginary numbers doesn't represent anything in particular to me. Indeed, I am performing a k-means on the eigenvalues of the laplacian matrix of my dataset. I tried to use the absolute value. The thing is the more the number of clusters is important, the greater the inertia will be. Then, I have an increasing inertia with the elbow method. Is it normal ?","Q_Score":1,"Tags":"python,scikit-learn,complex-numbers","A_Id":62728868,"CreationDate":"2020-07-03T21:55:00.000","Title":"Using sklearn with complex values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python application with flask but I can't connect to the mysql database that is on Azure.\nMy config.py\nSQLALCHEMY_DATABASE_URI = 'mysql:\/\/user@mysqlsvr:pass1234@mysqlsvr.mysql.database.azure.com:3306\/flask_db'\nAny suggestion?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":477,"Q_Id":62723170,"Users Score":1,"Answer":"I downloaded the certificate and it worked\nFollow\nSQLALCHEMY_DATABASE_URI = 'mysql:\/\/user@mysqlsvr:pass1234@mysqlsvr.mysql.database.azure.com:3306\/flask_db?ssl_ca=BaltimoreCyberTrustRoot.crt.pem'","Q_Score":2,"Tags":"python,flask-sqlalchemy,azure-mysql-database","A_Id":62727819,"CreationDate":"2020-07-03T22:02:00.000","Title":"SQLALCHEMY_DATABASE_URI with Azure Mysql","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm running a Python script in an AWS Lambda function. It is triggered by SQS messages that tell the script certain objects to load from an S3 bucket for further processing.\nThe permissions seem to be set up correctly, with a bucket policy that allows the Lambda's execution role to do any action on any object in the bucket. And the Lambda can access everything most of the time. The objects are being loaded via pandas and s3fs: pandas.read_csv(f's3:\/\/{s3_bucket}\/{object_key}').\nHowever, when a new object is uploaded to the S3 bucket, the Lambda can't access it at first. The botocore SDK throws An error occurred (403) when calling the HeadObject operation: Forbidden when trying to access the object. Repeated invocations (even 50+) of the Lambda over several minutes (via SQS) give the same error. However, when invoking the Lambda with a different SQS message (that loads different objects from S3), and then re-invoking with the original message, the Lambda can suddenly access the S3 object (that previously failed every time). All subsequent attempts to access this object from the Lambda then succeed.\nI'm at a loss for what could cause this. This repeatable 3-step process (1) fail on newly-uploaded object, 2) run with other objects 3) succeed on the original objects) can happen all on one Lambda container (they're all in one CloudWatch log stream, which seems to correlate with Lambda containers). So, it doesn't seem to be from needing a fresh Lambda container\/instance.\nThoughts or ideas on how to further debug this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":192,"Q_Id":62725013,"Users Score":2,"Answer":"Amazon S3 is an object storage system, not a filesystem. It is accessible via API calls that perform actions like GetObject, PutObject and ListBucket.\nUtilities like s3fs allow an Amazon S3 bucket to be 'mounted' as a file system. However, behind the scenes s3fs makes normal API calls like any other program would.\nThis can sometimes (often?) lead to problems, especially where files are being quickly created, updated and deleted. It can take some time for s3fs to update S3 to match what is expected from a local filesystem.\nTherefore, it is not recommended to use tools like s3fs to 'mount' S3 as a filesystem, especially for Production use. It is better to call the AWS API directly.","Q_Score":0,"Tags":"python,amazon-s3,aws-lambda,python-s3fs","A_Id":62764794,"CreationDate":"2020-07-04T03:40:00.000","Title":"How to diagnose inconsistent S3 permission errors","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When we want to do anything with our python virtual environment in terminal\/command prompt\/shell, we have to activate it by navigating to the scripts folder. But, what does this activation do?\nI can access the contents of the virtualenv folder in file explorer without activating it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1220,"Q_Id":62729150,"Users Score":4,"Answer":"At its core, the main purpose of Python virtual environments is to create an isolated environment for Python projects. This means that each project can have its own dependencies, regardless of what dependencies every other project has.\nMore interesting are the activate scripts in the bin directory. These scripts are used to set up your shell to use the environment\u2019s Python executable and its site-packages by default.\nAfter activating the environment, we\u2019re now getting a different path for the python executable because, in an active environment, the $PATH environment variable is slightly modified.","Q_Score":1,"Tags":"python,virtualenv","A_Id":62729235,"CreationDate":"2020-07-04T12:31:00.000","Title":"what does activating virtualenv in python exactly mean and what it does?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to extract articles from Wikipedia belonging to a specific category,for example company or person. Is there a good way to do this? Right now, I have a wikipedia data dump from which I can extract the page content, but I can't filter the data based on category. Also, can I get an exact number of articles from the wikipedia dump for the given category?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":766,"Q_Id":62729529,"Users Score":1,"Answer":"If you want an SQL solution, you can find the articles of a category by searching up rows in categorylinks.sql where cl_to=category_title. It gives all the page ids of the subcategories, articles. Then you can count all the rows where cl_type='subcat' to find the number of subcategories. cl_type='page' give the number of pages.\nTo find the corresponding title of the articles or the categories, you can use page.sql.\nAn alternative way is to just get the category.sql dump. It has the number of subcategories and articles of each category.\nThe actual names of the dumps in the latest enwiki dumps would be:\n\nenwiki-latest-categorylinks.sql\nenwiki-latest-page.sql","Q_Score":0,"Tags":"python,database,wikipedia,wikipedia-api","A_Id":63106234,"CreationDate":"2020-07-04T13:08:00.000","Title":"How to extract data from Wikipedia for a specific category like Person?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"According to the official documents from tensorflow:\n\nAbout setting layer.trainable = False on a `BatchNormalization layer:\nThe meaning of setting layer.trainable = False is to freeze the layer, i.e. its internal state will not change during training: its trainable weights will not be updated during fit() or train_on_batch(), and its state updates will not be run.\nUsually, this does not necessarily mean that the layer is run in inference mode (which is normally controlled by the training argument that can be passed when calling a layer). \"Frozen state\" and \"inference mode\" are two separate concepts.\nHowever, in the case of the BatchNormalization layer, setting trainable = False on the layer means that the layer will be subsequently run in inference mode (meaning that it will use the moving mean and the moving variance to normalize the current batch, rather than using the mean and variance of the current batch).\nThis behavior has been introduced in TensorFlow 2.0, in order to enable layer.trainable = False to produce the most commonly expected behavior in the convnet fine-tuning use case.\n\nI don't quite understand the term 'frozen state' and 'inference mode' here in the concept. I tried fine-tuning by setting the trainable to False, and I found that the moving mean and moving variance are not being updated.\nSo I have the following questions:\n\nWhat's the difference between 2 attributes training and trainable?\nIs gamma and beta getting updated in the training process if set trainable to false?\nWhy is it necessary to set trainable to false when fine-tuning?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2245,"Q_Id":62729806,"Users Score":6,"Answer":"What's the difference between 2 attributes training and trainable?\ntrainable:- ( If True ) It basically implies that the \"trainable\" weights of the parameter( of the layer ) will be updated in backpropagation.\ntraining:- Some layers perform differently at training and inference( or testing ) steps. Some examples include Dropout Layer, Batch-Normalization layers. So this attribute tells the layer that in what manner it should perform.\nIs gamma and beta getting updated in the training process if set trainable to false?\nSince gamma and beta are \"trainable\" parameters of the BN Layer, they will NOT be updated in the training process if set trainable is set to \"False\".\nWhy is it necessary to set trainable to false when fine-tuning?\nWhen doing fine-tuning, we first add our own classification FC layer at the top which is randomly initialized but our \"pre-trained\" model is already calibrated( a bit ) for the task.\nAs an analogy, think like this.\nYou have a number line from 0 - 10. On this number line, '0' represents a completely randomized model whereas '10' represents a kind of perfect model. Our pre-trained model is\nsomewhere around 5 or maybe 6 or maybe 7 i.e. most probably better than a random model. The FC Layer we have added at the top is at '0' as it is randomized at the start.\nWe set trainable = False for the pre-trained model so that we can make the FC Layer reach the level of the pre-trained model rapidly i.e. with a higher learning rate. If we don't set trainable = False for the pre-trained model and use a higher learning rate then it will wreak havoc.\nSo initially, we set a higher learning rate and trainable = False for the pre-trained model and train the FC layer. After that, we unfreeze our pre-trained model and use a very low learning rate to serve our purpose.\nDo freely ask for more clarification if required and upvote if you find it helpful.","Q_Score":3,"Tags":"python,tensorflow,keras,tf.keras,batch-normalization","A_Id":65920684,"CreationDate":"2020-07-04T13:34:00.000","Title":"What's the difference between attrubutes 'trainable' and 'training' in BatchNormalization layer in Keras Tensorfolow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python and trying to develop a solution. Here is the scenario where I am currently stuck.\n\nBackground\nI have 2 files both in the same directory.\n\nactualcode.py\nuserInformation.py\n\nThe userInformation.py has some data which the user can manually change.\nThe actualcode.py loads the data from userInformation.py and processes it and gives the output.\nThe execution will be in this way, user enters the data in userInformation.py saves it and then runs actualcode.py and gets the output.\n\nIssue\nI want to create a executable for the actualcode.py, which I am able to do using the command : pyinstaller --onefile actualcode.py\nHowever, while building the exe, pyinstaller also loads the userInformation.py file and bundles it with the executable, so now even if the user makes changes to the userInformation.py file, they are not loaded\/reflected when he runs the actualcode.py as the file is already loaded in the exe.\nI want to know if there any better way to do this.\nWould loading the data in a dotenv file instead of the userInformation.py solve my problem ?\nOr are there any parameters in pyinstaller which will help me build executable on actualcode.py and still load the data from userInformation.py\nAlso is there a way to build a parameterized exe with python? In that case I would just call the exe with the data parameters instead of using a different file?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":783,"Q_Id":62729891,"Users Score":0,"Answer":"You don't have to use JSON if you don't want to. You can just change the userInformation.py script to save all the informations in a .txt file. And change the actualcode.py script to get the information from the .txt file. You will have to make two .exe files. One for the manipulating the user information and the actual file which does something.\nHope that helps!","Q_Score":0,"Tags":"python,python-3.x,python-2.7,pyinstaller","A_Id":62730373,"CreationDate":"2020-07-04T13:42:00.000","Title":"How to load information to a pyinstaller executable file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using google colab sheet.\nBefore a minute this line was working but I don't what happened now.\n----> 3 rang = [num for num in range(100)]\nTypeError: 'list' object is not callable\nThis error is coming every time, I tried refreshing the page.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":724,"Q_Id":62731735,"Users Score":1,"Answer":"Looks like you accidentally defined range somewhere within your code. This overwrote the built-in definition. The line may look something like range = [1, 2, 3].\nYou should find and get rid of that line. Then, refresh your kernel to bring back the regular definition of range.","Q_Score":0,"Tags":"python,list,google-colaboratory","A_Id":62731918,"CreationDate":"2020-07-04T16:37:00.000","Title":"TypeError: 'list' object is not callable (in google colab)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Unable to create virtual environment in windows using this command in command prompt\npython3 -m venv whatsapp-bot-venv\nIt throws an error as below\n'python3' is not recognized as an internal or external command,\noperable program or batch file.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":25,"Q_Id":62731847,"Users Score":1,"Answer":"Use\n\npython -m venv whatsapp-bot-venv","Q_Score":0,"Tags":"python-3.x,virtualenv","A_Id":62731912,"CreationDate":"2020-07-04T16:47:00.000","Title":"Unable to create virtual environment in windows using this command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"In many packages documentation, you can read something like bellow from matplotlib:\nfig.colorbar(mappable, cax=None, ax=None, use_gridspec=True, **kw)\nHow can one know what are the other possibilities with **kw?\nSome documentations describe them others don't.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":50,"Q_Id":62731866,"Users Score":2,"Answer":"There is no way to find them without documentation OR looking at the code.\n**kwargs is a dictionary, so searching for kwargs[ with your editor (Ctrl+F) inside the source code should reveal all used keys, and then you can figure out usage by name and how they are used inside of the code, but most of the time the name alone is self documenting.\nThere is no way to directly find them because the compiler doesnt track them, for the compiler its just a fancy way to pass a dictionary, and the program doesnt fail if you pass any unexpected kwargs","Q_Score":2,"Tags":"python,keyword-argument","A_Id":62731939,"CreationDate":"2020-07-04T16:50:00.000","Title":"Python: Discover acceptable keyword arguments","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used to write many codes (in Python) in different cells in jupyter notebook, and run them once. I use also this command %store to store variables and other data structures, however I noticed that each time I execute them, the memory space of HDD is decreasing, that means that there are something is caching each time.\nI tried unsuccessfully to reset it by %reset -f.\nHow can I remove all the cached data ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1075,"Q_Id":62732893,"Users Score":0,"Answer":"The problem was solved simply by restarting the computer, however I still need to some techniques to totally clear the temporary data upon each execution.","Q_Score":0,"Tags":"python,memory-management,jupyter-notebook,jupyter","A_Id":62753579,"CreationDate":"2020-07-04T18:26:00.000","Title":"Jupyter notebook consumes hard disk memory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm implementing a paper in colab rn with 160000 iterations where each iteration takes about 2-3 seconds which means with normal colab i should be finished in about 5-6 days, but i get timed out most of the time at around 5 hours, probably cause I'm using alot of ressources, then I have to wait 12 hours to train again.\nMy question is, If I'd get colab pro, will i get full 24 hours most of the time or will I get timed out much earlier and is the timeout duration the same as in colab free?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":602,"Q_Id":62733655,"Users Score":0,"Answer":"I would prefer that you train your model for a few epochs first ---> save it ---> reload it and then train again.","Q_Score":0,"Tags":"python,google-cloud-platform,deep-learning,pytorch,google-colaboratory","A_Id":64374018,"CreationDate":"2020-07-04T19:39:00.000","Title":"Colab pro timeouts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it normal for the np.linalg.eig() function to take more than 10 minutes to work on a (15000, 15000) matrix? I'm running this on the colab environment with standard runtime.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1066,"Q_Id":62735482,"Users Score":0,"Answer":"Formaly the algorithm should scale as O(N^3) for an N-by-N matrix. So if N takes T time, then 2N takes 2^3T = 8T time, and 10N takes 10^3T = 1000T time. On my old laptop N=1500 takes 3.7 seconds. N=3000 takes 22 seconds, which is not really 8*3.7, but close enough.\nNow 3000*5 = 15000, and 22*5^3 = 2750 seconds = 46 minutes. So that's the time it should take on my computer. So your computer is faster, but 15 minutes seems ok!","Q_Score":2,"Tags":"python,numpy,eigenvalue,eigenvector","A_Id":62735820,"CreationDate":"2020-07-04T23:37:00.000","Title":"np.linalg.eig() taking a lot time to run","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a doubt regarding basic perceptron. Can basic perceptron classify points in R^2 or R^3? Can someone justify it? Note: R^n refers to n-dimensional Euclidean Space.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":62735725,"Users Score":0,"Answer":"A single layer perceptron can only draw a line (y = ax + b), therefore It would not be able to understand a parabola or other type of curve in order to predict.","Q_Score":0,"Tags":"python,neural-network,artificial-intelligence","A_Id":62735935,"CreationDate":"2020-07-05T00:28:00.000","Title":"Basic Perceptron or Single layer Neural Network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"problem: I can't run \"tensorboard --logdir=summaries\" in my terminal because I get this error\n\nsystem: macbook pro running Catalina\nenvironment: running pyenv with python3 as global\npackage: I have tensorflow 2.2.0 installed via pip\nI have setuptools 49.1.0\n\nTraceback (most recent call last):\nFile \"\/usr\/local\/bin\/tensorboard\", line 10, in \nsys.exit(run_main())\nFile \"\/Library\/Python\/3.7\/site-packages\/tensorboard\/main.py\", line 65, in run_main\ndefault.get_plugins() + default.get_dynamic_plugins(),\nFile \"\/Library\/Python\/3.7\/site-packages\/tensorboard\/default.py\", line 125, in get_dynamic_plugins\n\"tensorboard_plugins\"\nFile \"\/Library\/Python\/3.7\/site-packages\/tensorboard\/default.py\", line 124, in \nfor entry_point in pkg_resources.iter_entry_points(\nFile \"\/Library\/Developer\/CommandLineTools\/Library\/Frameworks\/Python3.framework\/Versions\/3.7\/lib\/python3.7\/site-packages\/pkg_resources\/init.py\", line 2410, in load\nself.require(*args, **kwargs)\nFile \"\/Library\/Developer\/CommandLineTools\/Library\/Frameworks\/Python3.framework\/Versions\/3.7\/lib\/python3.7\/site-packages\/pkg_resources\/init.py\", line 2433, in require\nitems = working_set.resolve(reqs, env, installer, extras=self.extras)\nFile \"\/Library\/Developer\/CommandLineTools\/Library\/Frameworks\/Python3.framework\/Versions\/3.7\/lib\/python3.7\/site-packages\/pkg_resources\/init.py\", line 791, in resolve\nraise VersionConflict(dist, req).with_context(dependent_req)\npkg_resources.VersionConflict: (setuptools 40.8.0 (\/Library\/Developer\/CommandLineTools\/Library\/Frameworks\/Python3.framework\/Versions\/3.7\/lib\/python3.7\/site-packages), Requirement.parse('setuptools>=41.0.0'))","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":441,"Q_Id":62736306,"Users Score":0,"Answer":"As it turns out I was not using Pyenv correctly. Once I used \"pyenv global system\" then I was able to update the pip packages correctly and the right setuptools was installed and TensorBoard ran as expected","Q_Score":0,"Tags":"python,tensorflow,tensorboard","A_Id":62856531,"CreationDate":"2020-07-05T02:46:00.000","Title":"can't launch tensorboard from mac terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to create an installer for my python project, which runs on any Windows PC without directly installing python on that PC.\nBasically what I need is that my python project installs and runs on PC as any other software.\nI've already tried pyinstaller but it converts only a single file. I don't know if it does work for a whole project.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":153,"Q_Id":62737207,"Users Score":0,"Answer":"The single file pyinstaller outputs contains the whole project you told it to generate for you.\nYou can just distribute that file, and anyone can download it and run with double-click.\nTo create an installer, you can use something like NSIS installer.","Q_Score":0,"Tags":"python,exe,pyinstaller","A_Id":62737286,"CreationDate":"2020-07-05T05:34:00.000","Title":"Python: creating exe installer of python project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to tcp\/ip programming and I'm trying to establish a tcp\/ip connection that sends a byte from my python server to a c++ client. Is this possible or does the client and server have to be written in the same programming language?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":72,"Q_Id":62739874,"Users Score":1,"Answer":"Tcp connection does not depend on programming language you could make connection between two processes one of them should be listen for another(server) and the other should send sync packet to request a connection(client). You could  implement  two mentioned components with every language programming.If you need more help let us know.","Q_Score":0,"Tags":"python,c++,sockets,tcp","A_Id":62740048,"CreationDate":"2020-07-05T11:09:00.000","Title":"Can i establish a tcp\/ip socket with a python server but a c++ client?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to devise a python program to communicate with a number, lets say 1000 devices via TCP in parallel. Each connection establishes a client connection and should start to communicate on a stream based way.\nUntil now I successfully employed select.select() to get notified when something arrives for reading or when writing has completed.\nNow I learned a little about Python Async IO using async function definitions. I think it could write code more elegantly using this framework instead of re-using my old pattern.\nHowever, I'm not sure, whether I should invest some time to learn it or just be satisfied with the old fashioned approach.\nFrom a rough view I came to the conclusion that I could actually solve all I need with asyncio too.\nHowever, to convince other people, what would be the real advantage beside using a \"cool\" framework?\nEDIT:\nI will never understand SO's policy regarding closing questions. Is this only a forum for experts on the highest top-level? I know that my question doesn't target a specialized and\/or detailed question, but this is not a reason at all to close it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":62740254,"Users Score":1,"Answer":"Async IO is not a part of python only. It is a programming paradigm, which is universally used across all programming languages. For instance, Async IO is one of the most highlighted feature of NodeJs. Therefore, in order to answer your question, yes, it is a long term investment if you study the Async IO as it is mandatory in most of the communication applications.","Q_Score":0,"Tags":"python,python-3.x,asynchronous,async-await,python-asyncio","A_Id":62740636,"CreationDate":"2020-07-05T11:46:00.000","Title":"What would be the benefit of using Async IO in my Python project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am studying time series data.\nIf you look at the time series data you have run with the examples so far, they all have similarly only two columns. One is a date, and one is any value.\nFor example, in the case of a stock price increase forecast, we predict a 'single' stock.\nIf so, can you predict multiple stocks simultaneously in time series data analysis?\nFor example, after the subjects had taken medicines that affected their liver levels, they got liver count data by date so far. Based on this, I would like to experiment with predicting at which point the liver level rises or falls in the future. At this time, I need to predict several patients at the same time, not one patient. How do I specify the data set in this case?\nIs it possible to label by adding one column? Or am I not really understanding the nature of time series data analysis?\nIf anyone knows anything related, I would be really grateful if you can advise me or give me a reference site.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":62740534,"Users Score":1,"Answer":"You should do the predictions for each patient separately. You probably don't want the prediction on one of the patient to vary because of what happens to the others at the same time.\nMachine Learning is not just about giving data to a model and getting back results, you also have to think the model, what should be its input and output here. For time series, you would probably give as input what was observed on a patient in the previous days, and try to predict what will happen in the next one. For one patient, you do not need the data of the others patients, and if you give it to your model, it will try to use it and capture some noise from the training data, which is not what you want.\nHowever as you could expect similar behaviors in each patient, you can build a model for all the patients, and not one model for each patient. The typical input would be of the form :\n[X(t - k, i), X(t - k + 1, i), ..., X(t - 1, i)]\nwhere X(t, i) is the observation at time t for the patient i, to predict X(t, i). Train your model with the data of all the patients.\nAs you give a medical example, know that if you have some covariates like the weight or the gender of the patients you can include them in your model to capture their individual characteristics. In this case the input of the model to predict X(t, i) would be :\n[X(t - k, i), X(t - k + 1, i), ..., X(t - 1, i), C1(i), ..., Cp(i)]\nwhere C1(i)...Cp(i) are the covariates of the patient. If you do not have theses covariates, it is not a problem, they can just improve the results in some cases. Note that all covariates are not necessarily useful.","Q_Score":0,"Tags":"python,machine-learning,time-series","A_Id":62744429,"CreationDate":"2020-07-05T12:13:00.000","Title":"Time series data prediction with multiple n numbers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to change the color of the borders of the buttons in tkinter.\nI tried : tk.Button.config(highlightbackground=COLOR)\nbut it says TypeError: configure() missing 1 required positional argument: 'self'\nalso, I want to make the border color using hex color codes.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":62742124,"Users Score":0,"Answer":"You can't change the border color of buttons in tkinter. highlightbackground isn't for the border, it's for the highlight ring which lets you know when the widget has keyboard focus.","Q_Score":0,"Tags":"python,tkinter","A_Id":62742258,"CreationDate":"2020-07-05T14:41:00.000","Title":"How to change border color of buttons in tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I am relatively new to programming and used to use Python's own \"IDLE\". After I run a \".py\" file with IDLE, I am used to getting a python shell or a command window, I don't really know the terminological name for it, where I could play around with the objects inside the script.\nFor example, if I had a list A=[1,2,3] inside the program, after I run it I get a command console that says \">>\" and I can say \">>A\" which gives me \"[1,2,3]\" and I can add elements to A etc.\nNow, I want to start using VS Code but I can't seem to find that particular thing. I have a terminal where I can run python code if I give the command \"python\" first, but It doesn't seem to effect anything inside the script.\nI want to use that to see if some objects are working fine and to check their types etc. I add more lines to code after I try from there first, if that makes sense.\nSorry for really bad terminology, I really don't know the names but I can try even more if it's not clear.\nThanks a lot in advance.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":312,"Q_Id":62742410,"Users Score":1,"Answer":"Try using the integrated terminal inside vs code and make sure that python and pip are properly configured. Type python in the command line and make sure the terminal points to the same folder where your program file is located.","Q_Score":0,"Tags":"python,visual-studio-code,python-idle","A_Id":62742468,"CreationDate":"2020-07-05T15:04:00.000","Title":"How to use VS Code - Python Shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Django server running with nginx and gunicorn.\nAll static files are served correctly, only the admin page has no css, js, etc. .\nI already ran collectstatic and restarted nginx and gunicorn.\nNothing changed.\nWhat can I do?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":62743059,"Users Score":0,"Answer":"Make sure to mention the locations of your staticfiles_dirs in settings.py. Also remember to mention the locations of your static files in a dynamic format instead of hard coding them in your html document.And make sure to load static in base.html.","Q_Score":0,"Tags":"python,html,django,nginx,gunicorn","A_Id":62743422,"CreationDate":"2020-07-05T15:57:00.000","Title":"Django server does not serve static files for admin page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to store a non-rectangular array in Python. The array has millions of elements and I will be applying a function to each element in the array, so I am concerned about performance. What data structure should I use? Should I use a Python list or a numpy array of type object? Is there another data structure that would work even better?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":364,"Q_Id":62744462,"Users Score":2,"Answer":"You can use the dictionary data structure to store everything. If you have ample memory, dictionaries is a good option. The hashing process makes them faster.","Q_Score":0,"Tags":"python,multidimensional-array,data-structures","A_Id":62744575,"CreationDate":"2020-07-05T18:02:00.000","Title":"What is the best way to store a non-rectangular 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 am a beginner at Tensorflow Neural Networks, and I am following an online guide to learn how to train Sequential Neural Network models. When computing the mean squared error of my test data, I get very different results every time I compile the model. Sometimes I get a MSE of about 27 to 28, and other times I get a very strange MSE of ~20,000. I am not changing any variables every time I recompile my model. Why is this happening? Thanks for responding.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":117,"Q_Id":62745903,"Users Score":1,"Answer":"If you are not loading pretrained weights, your model will load with different weights every time you recompile your model, thus giving you random values on inference before training. To ensure that weights are the same for each run, set a random seed in tf.random.set_seed(SEED).","Q_Score":2,"Tags":"python,tensorflow","A_Id":62748801,"CreationDate":"2020-07-05T20:19:00.000","Title":"Tensorflow Neural Network MSE large discrepancies","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In our company, all the machines are Linux or windows. But the customer has a Unix system. Can I create a docker container in Linux then use it on Unix. I want the docker file to contain python with cx_oracle and pandas libraries And put them in the UNIX machine. Just want to make sure that the environment is working by using cx_oracle to connect on Oracle DB on the Unix machine.\n\nWhat will be exactly the code or docker file using cx_oracle and\npandas libraries that should be run on Unix and making sure that the\nenvironment is working by using cx_oracle to connect on Oracle DB on\nthe Unix machine?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":100,"Q_Id":62746919,"Users Score":0,"Answer":"It's always edge case differences between OSs that cause app porting problems: signal handling, subtle file system differences, etc.  How cx_Oracle behaves won't differ much between different OSs - except library initialization.  Make sure you test properly on the exact deployment environment. That way you will know exactly how to do the app & Oracle Client install, how the network needs to be configured, how the app needs to be tuned (e.g. best values for arraysize and prefetchrows for queries), etc.\nIn your case, it's the OS that Python will run on that matters, since this can be (and often is) different to the OS that the DB runs on.  I think you should test on the exact customer environment, not in some container (even if that works) or virtualized setup.\nFind the details and update your original question if you need more help.","Q_Score":0,"Tags":"python,linux,docker,unix,cx-oracle","A_Id":62747594,"CreationDate":"2020-07-05T22:17:00.000","Title":"Can I create Docker container in Linux to use it on Unix?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need a TensorFlow version 2> and I installed that on my Ubuntu Server, but it gives me the AVX error. I tried the 1.5 version and it works but doesn't support Keras and the other commands I used. I am using python3.5. There are no errors in the code.\nOS: Ubuntu Server on a Server with 16GB ram\nPip: 19.0\nPython: 3.5.9","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1814,"Q_Id":62747937,"Users Score":3,"Answer":"To fix this, you can install TensorFlow via anaconda and not pip. It work for me by doing this. If anybody knows why, they are welcome to explain.","Q_Score":2,"Tags":"python-3.x,linux,tensorflow,pip,avx","A_Id":62778317,"CreationDate":"2020-07-06T01:13:00.000","Title":"Tensorflow 2.2.0 support on non-AVX systems","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"In my case, I would like to weekly tune\/adjust the model parameters value.\nI have pre-trained the model by using the 100K data rows, Keras, and saved the model.\nThen, as the new data collection (10K data rows), I need to tune the model parameter but don't want to retrain the whole dataset (110K).\nHow can I just partially fit the data on the model? load model -> model.fit(10K_data)?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":260,"Q_Id":62748756,"Users Score":2,"Answer":"Yes, that is correct you will train only on the new dataset (10k) model.fit(10K_data). I will recommend to change the learning rate for the retraining (reducing the learning rate) as you will just want to do a minor update to the parameters while keeping the earlier learning intact (or trying to leavarage the earlier learning).","Q_Score":1,"Tags":"python,tensorflow,keras","A_Id":62749453,"CreationDate":"2020-07-06T03:17:00.000","Title":"How to partial training on the additional data for pre-trained model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I am working on some python code say in foo.py.\nIs it reasonable to have a notebook named foo.ipynb and import foo in that notebook?\nThis seems to work, but is it a good idea?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":62748870,"Users Score":0,"Answer":"Yes, technically you could that do with no issue, as long as yourself is comfortable with having those two files using the same name and different extension.\nHowever, I would like to mention that at some point of time, people might want or need to change a notebook file to a single python script file. When that happens, it might be confusing. Thus, personally, if I have a foo.py, I would name my notebook as foo_notebook.ipynb, even if it seems reductant.","Q_Score":0,"Tags":"python,python-3.x,jupyter-notebook","A_Id":62749907,"CreationDate":"2020-07-06T03:34:00.000","Title":"Is it reasonable to have a python file with the same name as a notebook file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to upload a csv file from my local to an existing project in Watson Studio using python.\nThanks in Advance.","AnswerCount":1,"Available Count":1,"Score":-0.3799489623,"is_accepted":false,"ViewCount":202,"Q_Id":62751319,"Users Score":-2,"Answer":"Go to Resource List > Click on Services > Db2 > Open Console > Click on Hand Burger Icon on right > Click on Load > Open Load Data > Upload your CSV File > using Drag n drop or browser","Q_Score":0,"Tags":"python,python-requests,ibm-watson,watson-studio","A_Id":62814372,"CreationDate":"2020-07-06T07:37:00.000","Title":"Upload asset(csv file) to watson studio project using python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have three mongo nodes which I specify in the url which I use in the MongoClient. It looks something like this \"mongodb:\/\/A,B,C,D\". I need the read preference as Secondary, for which I used SECONDARY_PREFERRED. Everything works as expected, I am able to connect to the secondary node without any problem. I get the connection using -\nmongo_con = MongoClient(db_url, read_Preference=ReadPreference.SECONDARY_PREFERRED)\nI was wondering what the impact is if I don't send the 'replicaSet' optional parameter while getting the connection. What will be the difference in the connection, in case I use the repicaSet and send the correct replica set name, what if I send an incorrect replica set name? How will it impact my connection?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":62751643,"Users Score":0,"Answer":"I was wondering what the impact is if I don't send the 'replicaSet' optional parameter while getting the connection.\n\nThis depends on the driver (pymongo\/node etc.) you are using and how many seeds you specify in the connection string.\nWhen given a single seed, some drivers assume you want a direct connection to that server only and some drivers discover the topology of the deployment and, if it is a replica set, would discover all of the other nodes and \"connect to the replica set\".\nThe behavior is currently being standardized across drivers via the directConnection URI option.\nWhen you provide replicaSet URI option, you are forcing the second behavior of discovering the replica set in all drivers. Providing multiple seeds also works as long as you are not in a single-node replica set.\n\nWhat will be the difference in the connection, in case I use the repicaSet and send the correct replica set name, what if I send an incorrect replica set name? How will it impact my connection?\n\nIf you specify replicaSet and give an incorrect set name, the driver will filter out all servers that have the correct set name (or from the driver's perspective, your instructed replicaSet is the correct one and the one reported by servers would be wrong). Your application will fail to find any usable servers.","Q_Score":0,"Tags":"python,mongodb,pymongo","A_Id":62760451,"CreationDate":"2020-07-06T07:58:00.000","Title":"pymongo MongoClient without replicaSet parameter","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python. Please excuse me if my question seems stupid. I have spent a lot of time before posting this.\nWhen I searched for shipping python interpreter with the applications, I found solutions including installing separate applications, using third party modules, etc...\nI was thinking of more direct approach: I first install python interpreter on my machine (windows). Then I ship the installed python interpreter (copy and paste the folder) with the pyc file of my application. And finally I create a simple batch program that executes the interpreter and running the pyc file. In this case, the user can simply run the application by simply running the batch program. I have tried it and it worked.\nAlthough this solution seems the most obvious and the easiest one, I am in a doubt about it because I cannot find any one mentioning it. Is there anything wrong with my solution? I usually create desktop applications for windows.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":568,"Q_Id":62752218,"Users Score":0,"Answer":"Make a virtual environment for you application and then run run the command python filename.py --onefile --windowed while still being in the virtual env. activated,","Q_Score":1,"Tags":"python,interpreter,shipping","A_Id":62752369,"CreationDate":"2020-07-06T08:37:00.000","Title":"Shipping Interpreter with Python application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Have a flask api, everytime a endpoint is called triggers a job in Spark, open a Session which I close when it's done.\nThe job itself takes less than 2 Minutes.\nI start the session and close it everytime the method is called.\nIs it better to start a single Session and keep it always alive or just open and kill it everytime?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":114,"Q_Id":62753897,"Users Score":1,"Answer":"This will cause issue if you recieve bulk requests then multiple spark session will be created with the same resources.\nBetter keep the spark session running and serve the request using the same","Q_Score":1,"Tags":"python,apache-spark,pyspark","A_Id":62754480,"CreationDate":"2020-07-06T10:15:00.000","Title":"Best practices for Sparkessions Pyspark","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have tried using FFMPEG for audio extraction from video.\nHow to transcribe speech to text and detect the language?\nI have tried using ,\nMyspokenlangauge\nGoogle cloud -speech to text api","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1163,"Q_Id":62755246,"Users Score":0,"Answer":"You can use speech to text to detect the words.\nSend the words to google translate which automatically detects the language.\nThen you can web-scrape the auto detected tag.","Q_Score":2,"Tags":"python-3.x,audio,language-detection","A_Id":62756514,"CreationDate":"2020-07-06T11:38:00.000","Title":"How to detect language from audio in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried using FFMPEG for audio extraction from video.\nHow to transcribe speech to text and detect the language?\nI have tried using ,\nMyspokenlangauge\nGoogle cloud -speech to text api","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1163,"Q_Id":62755246,"Users Score":0,"Answer":"You can take the text from speech to text engine using one of the most used languages for your use case.\nCreate a labelled dataset to train NLP model - for text classification.\nUse this model to detect the text coming out of STT engine.","Q_Score":2,"Tags":"python-3.x,audio,language-detection","A_Id":65613661,"CreationDate":"2020-07-06T11:38:00.000","Title":"How to detect language from audio in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the pyttsx3 module.\nI have the the Microsoft James voice installed and I can hear it when pressing the \"preview voice\" button in the windows speech settings.\nHowever when I try to view all the voices, only \"Microsoft David Desktop - English (United States)\" and \"Microsoft Zira Desktop - English (United States)\" come up.\nWhy doesn't the Microsoft James voice show up ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":652,"Q_Id":62756194,"Users Score":1,"Answer":"First press the \"windows\" key and \"R\" key simultaneously A run window should pop up. Click on the run box and type \"regedit\" and click enter, click \"yes\" and proceed. A registry editor should pop up. Now continue at your own risk(make a registry backup, I don't know what it is just search it) . Double click on \"HKEY_LOCAL_MACHINE\", then \"SOFTWARE \" --> \"MICROSOFT \" sroll down then \"SPEECH SERVER\" --> \"v11.0\" now you should see \"Voices\".\nRight click on \"Voices\" and you should see \"Export\". Then save the file somwhere you know(any filename) Go to the location where you saved it then right click the file Now close the registry editor\nThen click on \"Open with\" --> Notepad After that click \"Ctrl\" + \"H\" A replace window should pop up In \"Find what\" type \"Speech Server\\v11.0\" In \"replace with\" type \"Speech\" Then click replace all Then save and close the file Then open the same file with \"Registry Editor\" Click yes on both pop ups\npress the \"windows\" key and \"R\" key simultaneously A run window should pop up. Click on the run box and type \"regedit\" and click enter, click \"yes\" and proceed. A registry editor should pop up.\nNow you would be seeing \"Voices\" If you look a little higher up you should see \"Speech Server\" And just on top of that is \"Speech\" Open \"Speech \" by double clicking it Under \"Voices\" and \"Tokens\" you should see your newly installed voice.\nNow scroll down until you see \"Wow6432Node\" Open that then, Open MICROSOFT \" sroll down then \"SPEECH SERVER\" --> \"v11.0\" now you should see \"Voices\".\nRight click on \"Voices\" and you should see \"Export\". Then save the file somwhere you know(any filename) Go to the location where you saved it then right click the file Now close the registry editor\nThen click on \"Open with\" --> Notepad After that click \"Ctrl\" + \"H\" A replace window should pop up In \"Find what\" type \"Speech Server\\v11.0\" In \"replace with\" type \"Speech\" Then click replace all Then save and close the file Then open the same file with \"Registry Editor\" Click yes on both pop ups Then click ok Now press the \"windows\" key and \"R\" key simultaneously A run window should pop up. Click on the run box and type \"regedit\" and click enter, click \"yes\" and proceed. A registry editor should pop up.\nNow you would be seeing \"Voices\" If you look a little higher up you should see \"Speech Server\" And just on top of that is \"Speech\" Open \"Speech \" by double clicking it Under \"Voices\" and \"Tokens\" you should see your newly installed voice. Now, you are ready now test your code to check if it works correctly If you have any problems with code please tell here","Q_Score":1,"Tags":"python,python-3.x,windows-10,chatbot,pyttsx","A_Id":63867818,"CreationDate":"2020-07-06T12:33:00.000","Title":"pyttsx3 module is not showing all installed voices","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Due to AWS deprecating Signature Version 3 in Oct 2020 for SES, I want to handle this issue with AWS boto (Python). But I didn't see any doc related to boto supporting signature version 4 for SES.\nIs anyone having similar issue and have solutions?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4142,"Q_Id":62757921,"Users Score":3,"Answer":"My recommendation is that you migrate from boto, which is essentially deprecated, to boto3 because boto3 supports signature v4 by default (with the exception of S3 pre-signed URLs which has to be explicitly configured).","Q_Score":8,"Tags":"python,amazon-web-services,boto,signature","A_Id":62762520,"CreationDate":"2020-07-06T14:12:00.000","Title":"Is AWS boto (python) supporting SES signature version 4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to connect the OLAP Cube through python.\n\n(First)Basically I would like to import data from OLAP Cube.\n(Second)And import columns through DAX is there any way to run DAX formula in Python.\n\nI'm ok if python doesn't have any option for DAX. However at least I would like to import data from OLAP Cube.\nPlease assist me with the code or guide me. Let me know if you need more information.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":244,"Q_Id":62760356,"Users Score":0,"Answer":"You can use Cubes.  Cubes is a light-weight Python framework and set of tools for development of reporting and analytical applications, Online Analytical Processing (OLAP), multidimensional analysis and browsing of aggregated data.","Q_Score":0,"Tags":"python,data-connections","A_Id":62760894,"CreationDate":"2020-07-06T16:24:00.000","Title":"Python data connection OLAP\/Cube","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The app that I'm creating is a single page questionnaire. The questions displayed are changed by the press of a button that also saves the answers given in a django form in my database. Through using ajax and Javascript I made it possible to do this without refreshing the page. However the answers are not coupled to the questions in the database. What is the best way to save these questions in the database as well?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":62761364,"Users Score":0,"Answer":"The best way to go here probably would be to store the questions in a database table (e.g. questions) with question id and question text, then store all possible answers for question in another table (e.g. answers) in which there would be answer id, parent question id and answer text.\nThis would ensure some kind of database structure that would allow us to find questions and answers by some kind of numbers.\nThen in the view we would loop through all questions and in each question loop through each answer, rendering it. In the HTML forms or JS buttons each question and answer would have a unique ID combination. Upon answering the question by selecting a specific answer, instead of sending the actual text of question or answer, we would send the id of answer.\nThe user answer could be saved in a table user_answers where it would store some kind of user id together with the id of answer. Afterwards all user answers could be acquired through a SQL query, actual answers could be joined to them and we could see which user answered to which question with which answer. :)\nHope this helps!","Q_Score":0,"Tags":"javascript,python,django,ajax,database","A_Id":62762183,"CreationDate":"2020-07-06T17:27:00.000","Title":"What is the best way to store javascript generated innerhtml in the database?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to request for the best python package to be able to send SNMP Request(Get,Getbulk..etc)\nI am using pysnmp with multiprocessing and it is working fine for 60 nodes however when i am trying to use it for 100+ nodes with multiprocessing i could not ( I have upgraded my CPU to be sufficient enough)\nmy assumption the issue is either the pysnmp package or the Port itself which is 161 that can't handle to send or establish many session or send many requests at the same time.\nif it is the package, which snmp package which i try to use?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":549,"Q_Id":62763042,"Users Score":1,"Answer":"After long evaluation, it turns out pysnmp is the problem, because it has dependencies on other packages and SNMP MIB within Linux or Windows.\nThe best package is puresnmp, since there are no dependencies.\nI have been using that packages for almost 2 months and it's working very fast for 100+ nodes.","Q_Score":1,"Tags":"python,snmp,pysnmp","A_Id":63976067,"CreationDate":"2020-07-06T19:22:00.000","Title":"What is the best SNMP Package to use with python for over 100 nodes to monitor at the same time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't know for what reasons I am getting this error while installing Numpy in Pycharm. Although I have already installed Numpy in my system which is Windows based with the help of command prompt. But still I am still getting this error and also I have latest version of Pycharm.\nRuntimeError: Broken toolchain: cannot link a simple C program\nCan somebody help me?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":62763104,"Users Score":0,"Answer":"To properly install Numpy in Pycharm, you have to go to File\/Settings\/Project Interpreter click on add and search for numpy in the search bar.\nClick on install package, it should run and install with no problem","Q_Score":0,"Tags":"python,python-3.x,numpy,installation,pycharm","A_Id":62763168,"CreationDate":"2020-07-06T19:26:00.000","Title":"Problems in installing Numpy in Pycharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've updated conda and spyder to the latest versions.\nI want to execute python scripts (using F5 hotkey) in the current console.\nHowever, the new spyder behaves unexpectedly, for example, if I enter in a console a=5 and then run test.py script that only contains a command print(a), there is an error: NameError: name 'a' is not defined.\nIn the configuration options (command+F6) I've checked \"Execute in current console\" option.\nI am wondering why is this happening?\nConda 4.8.2, Spyder 4.0.1","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":546,"Q_Id":62763880,"Users Score":0,"Answer":"In the preferences, run settings, there is a \"General settings\", in which you can (hopefully still) deactivate \"Remove all variables before execution\".\nI even think to remember that this is new, so it makes sense.","Q_Score":0,"Tags":"python,conda,spyder","A_Id":62764652,"CreationDate":"2020-07-06T20:18:00.000","Title":"Spyder - how to execute python script in the current console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've updated conda and spyder to the latest versions.\nI want to execute python scripts (using F5 hotkey) in the current console.\nHowever, the new spyder behaves unexpectedly, for example, if I enter in a console a=5 and then run test.py script that only contains a command print(a), there is an error: NameError: name 'a' is not defined.\nIn the configuration options (command+F6) I've checked \"Execute in current console\" option.\nI am wondering why is this happening?\nConda 4.8.2, Spyder 4.0.1","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":546,"Q_Id":62763880,"Users Score":0,"Answer":"I figured out the answer:\nIn run configuration (command+F6) there is another option that needs to be checked: \"Run in console's namespace instead of empty one\"","Q_Score":0,"Tags":"python,conda,spyder","A_Id":62767082,"CreationDate":"2020-07-06T20:18:00.000","Title":"Spyder - how to execute python script in the current console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python list of force data that was sampled at 1280 Hz, I have to get it do exactly 240 Hz in order to match it exactly with a video that was filmed at 240 Hz. I was thinking about downsampling to 160 Hz and then upsampling through interpolation to 240 Hz. Does anyone have any ideas on how to go about doing this? Exact answers not needed, just an idea of where to look to find out how.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":433,"Q_Id":62764234,"Users Score":0,"Answer":"Don't downsample and that upsample again; that would lead to unnecessary information loss.\nUse np.fft.rfft for a discrete Fourier transform; zero-pad in the frequency domain so that you oversample 3x to a sampling frequency of 3840 Hz. (Keep in mind that rfft will return an odd number of frequencies for an even number of input samples.) You can apply a low-pass filter in the frequency domain, making sure you block everything at or above 120 Hz (the Nyqvist frequency for 240 Hz sampling rate). Now use np.fft.irfft to transform back to a time-domain signal at 3840 Hz sampling rate. Because 240 Hz is exactly 16x lower than 3840 Hz and because the low-pass filter guarantees that there is no content above the Nyqvist frequency, you can safely take every 16th sample.","Q_Score":0,"Tags":"python,numpy,scipy,sample-data,sample-rate","A_Id":62765219,"CreationDate":"2020-07-06T20:45:00.000","Title":"Resampling data from 1280 Hz to 240 Hz in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a sparse-matrix multiplication A^-1@B in Python within scipy.sparse. Both A and B are stored in csc format. The size of A and B is around 1E+6 x 2E+5 and 1E+6 x 1E+6. My intuition tells me I shouldn't invert A but use scipy.sparse.spsolve alternatively. But spsolve(A,B) gives me memory issue. I also try iterative solver like gmres and cg. But since the result from such an iterative solver is usually dense, the memory issue still shows up. Does anybody know if there is an appropriate way to solve this large-scale problem? Many thanks to you guys!","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":324,"Q_Id":62764490,"Users Score":-1,"Answer":"It is possible to multiply large matrices using a deep neural network which is designed to predict the result of essentially a matrix factorization-like model. Piecemeal computation is the benefit, making the memory size not a problem. Your labels for supervised will be computed dynamically because you can predict perfectly the exact result of each dot product.  Maybe no learning per se is needed, not sure, because your problem is actually solved as soon as you compute the labels.  Tensorflow2 is good for this.\nThere is probably something COTS that already does what you need if you look more, so you probably won't need to go through the effort of making the thing I described.","Q_Score":2,"Tags":"python,numerical-methods,scientific-computing","A_Id":62766537,"CreationDate":"2020-07-06T21:03:00.000","Title":"Solving large-scale sparse matrix equation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to zip just a file in Python which present in a folder. I am finding hard to create zip file with the below code snippet. It does create zip file, but it has complete folder structure inside.\nimport zipfile as zip\nroot=r\"C:\\XXXX\\YYYYYY\\ZZZZ\\\"\nfile=\"abc.txt\"\nzipper=zip.ZipFile(file=os.path.join(root,file.replace(\"txt\",\"zip\")),mode=\"w\",compression=zip.ZIP_DEFLATED)\nzipper.write(os.path.join(root,file))\nzipper.close()\nActual output:\n#################\nabc.zip\n|\nXXXX - Folder\n|\nYYYYYY - Folder\n|\nZZZZ - Folder\n|\nabc.txt\nExpected output\n###############\nabc.zip\n|\nabc.txt","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":62764961,"Users Score":0,"Answer":"One way I learnt and working is :\nos.chdir(root)\nTo set the working directory to the folder where the files are present. Then, pass just the filename instead of complete path to create zip.\nNot sure, if it is the correct and best way.","Q_Score":0,"Tags":"python-3.x,zip","A_Id":62765101,"CreationDate":"2020-07-06T21:41:00.000","Title":"zipfile : zip only the files present in 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":0,"Web Development":0},{"Question":"I need to support  Python code, which was written by another person and it contains imports, that are placed not at the top of the module. And I'm a bit afraid to break something, as project is quite complex.\nSo when it can be good to use imports not on the top of the file?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":62765543,"Users Score":1,"Answer":"If you have a python program that has different paths, and only one of the paths use a specific module, you can import the module in that specific path. So you won't be importing many module you won't use.","Q_Score":1,"Tags":"python,python-3.x,import,python-import","A_Id":62765596,"CreationDate":"2020-07-06T22:40:00.000","Title":"In which cases is it acceptable to put imports not on the top in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm fairly new to python, and I am trying to run the code I wrote when I right click the playback range windows in the timeline of maya (where you type your min or max range) . I managed to find ways to run scripts within the attribute editor \/ timeline \/ shelf items, but I cant seem to figure out how to interact with Maya's UI... Even typing a new value in there doesn't update the script editor, so I don't really have a lead on where to go. Any help would be fantastic!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":62765813,"Users Score":0,"Answer":"Everything Maya does when using the UI logs data in the script editor.\nMany items in the log are suppressed though as it would spam the log.\nTo enable it, activate Echo all commands (can be found in script editor under History), then clear the script editor and perform the action you want logged.\nYou will find that Maya executes a lot of mel script functions, which you can all find in the maya install directory under [MAYA_INSTALL_DIR]\/scripts\/startup and [MAYA_INSTALL_DIR]\/scripts\/others\nTo find the essential function you will have to search a little through the log.\nOnce you got a mel function you want to look for, I recommend using a find in files search function like the one in Notepad++, to find the corresponding .mel file in which the global proc is defined.\nAlso note that UI element names that are logged in script editor may have a different name the next time you start maya. So you will have to add functionality to search for the correct UI element name.\nThe Maya mel scripts are a good resource to find out all sorts of things about how the UI works, including contextual marking menus and the commands of tool windows.","Q_Score":1,"Tags":"python,user-interface,maya","A_Id":62950358,"CreationDate":"2020-07-06T23:13:00.000","Title":"Run a script in Maya by right clicking UI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to setup Python 3 on my mac computer and I seem to have many versions of pip on my computer, not sure which I should be using.\nWhen I run  pip --version in the terminal I get pip 19.2.3 from \/Library\/Python\/2.7\/site-packages\/pip-19.2.3-py2.7.egg\/pip (python 2.7) which I am fairly certain is just the version that comes with mac os.\nWhen I run python3 -m pip --version I get pip 20.1.1 from \/Library\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\/site-packages\/pip (python 3.7) \nWhen I run pip3 --version I then get pip 19.0.3 from \/Library\/Developer\/CommandLineTools\/Library\/Frameworks\/Python3.framework\/Versions\/3.7\/lib\/python3.7\/site-packages\/pip (python 3.7) \nI was hoping somebody could explain the differences between","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":549,"Q_Id":62765893,"Users Score":0,"Answer":"The quick and nasty answer is each installation of python can have its own pip, which in turn will have a different pipenv. This is all based off of your path. Most people opt to use virtualenv to create an app specific python environment so as to not impact other python applications which depend on specific conflicting versions.","Q_Score":1,"Tags":"python,python-3.x,pip","A_Id":62765952,"CreationDate":"2020-07-06T23:25:00.000","Title":"Confused by multiple versions of pip on mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I made a new file and I wanted to push it to my remote repo. But I accidentally force push the new file and overwrite it. So, I missed my previous files in my remote repo and now only the new added file is available in my remote repo. Is there any way to recover my missed files?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":294,"Q_Id":62766619,"Users Score":1,"Answer":"git has a big undo stack : git reflog\nYou can probably find the sha1 of the commit you \"overwrote\" in one of the following two places :\n\ngit reflog : the history of all commits that once have been the active commit you were working on\ngit reflog origin\/master (or git reflog origin\/anybranch) : the history of all the places you have seen for origin\/master, updated each time you ran git fetch or git pull\n\nOnce you have this sha1, you can :\n\nrebase on top of it : git rebase sha1\nget the previous content of the file and do something with it : git checkout sha1 -- the\/file\n...","Q_Score":0,"Tags":"python,git,github,gitlab,repository","A_Id":62774095,"CreationDate":"2020-07-07T01:03:00.000","Title":"Lost files after git force push","Data Science and Machine Learning":0,"Database and SQL":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 know if the a person proper noun reffers to a boy or to a girl using spacy or nltk. I tried the wordnet dictionary but I ws not able to find this information.\nExample:\nAlexander => Male\nSophie => Female","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":731,"Q_Id":62766888,"Users Score":3,"Answer":"No. There is no way for spaCy or NLTK to tell the gender of a PERSON entity.\nThere are two ways you can solve this:\n\nUse spaCy PhraseMatcher and feed in male and female name. This would be equivalent of a dictionary lookup.\nTrain a custom spaCy model and teach it what male and female names are (it would still be ideal to start with 1, use it to detect male and female names in your examples texts, use the indices of the start and end of the match to detect to label your example texts and then use that to train a generalized model).","Q_Score":0,"Tags":"python-3.x,nltk,spacy","A_Id":62766957,"CreationDate":"2020-07-07T01:42:00.000","Title":"Is there a simple way to know the gender of a person proper noun in NLTK or spacy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script.py, where I generate some other python-code which I want to build to a exe-file from within my sctipt.py.\nIs that possible? How could I get this managed?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":62767210,"Users Score":0,"Answer":"Depending on which operating system you are using, you could just use the subprocess module and call a commandline tool which ceates an exe file from the code you generated.\n(You should be running windows to compile the exe successfully)","Q_Score":0,"Tags":"python,exe","A_Id":62767236,"CreationDate":"2020-07-07T02:22:00.000","Title":"Python - generate exe-file with a other py-script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a Python gdb script on a program that runs with a Pintool. Specifically, I used the -appdebug_enable switch and created a semantic breakpoint in the Pintool that automatically triggers the breakpoint and runs the Python script that I sourced. The script basically inspects local and global variables and scans the memory that was dynamically allocated by the program. I notice that the gdb script runs orders of magnitude slower than if I run the program and gdb without the Pintool. I also tried with a dummy Pintool to see if my Pintool implementation caused the slowdown but it did not seem to be the case.\nMy conclusion is that Pin slows down my gdb script, but can anyone explain how and why? Is there any tool I can use to profile the performance slowdown from Pin?\n(I understand that gdb performance is not something people usually care too much about, but I am curious about the source of the slowdown.)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":207,"Q_Id":62767550,"Users Score":0,"Answer":"In your case PIN is used as a JIT (just in time) compiler. So it is effectively stopping your program whenever instruction sequence change, and recompile  (main reason for delay) and also add some instructions of its own (additional delays). PIN takes your program executable as argument. From first instruction to next branch instruction (call,jmp,ret) it regenerate sequence of instruction with its additional set of instructions that will transfer control back to PIN framework after executing the generated instruction sequence. While regenerating code PIN allows a user using instrumentation code to inject additional analysis code.","Q_Score":0,"Tags":"gdb,intel-pin,gdb-python","A_Id":63295872,"CreationDate":"2020-07-07T03:08:00.000","Title":"Intel Pin GDB Runtime Overhead","Data 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 can I do if I want to collectstatic again in pythonanywhere? I did it because I remove oneline in my remote repository and when I collectstatic it didn't work (new styles don't apply) so what can I do?\nI'm not an speaker of English.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":30,"Q_Id":62768194,"Users Score":1,"Answer":"You should check whitenoise. It helps in maintaining static files in deployment  in django.","Q_Score":0,"Tags":"javascript,python,html,css,django","A_Id":62789163,"CreationDate":"2020-07-07T04:33:00.000","Title":"About Django and static files in deployment from 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":"In cvxpy, I want to express a perspective of log function, which has the form: x*log(1 + y\/x). This can be easily implemented in cvx by using rel_entr(). But I found that rel_entr() is not supported in cvxpy. Is there any way to write this perspective?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":162,"Q_Id":62768324,"Users Score":0,"Answer":"I have figured it out. We can use kl_div() in cvxpy to transform, i.e., -kl_div(x, x+y) + y.","Q_Score":0,"Tags":"python,cvxpy","A_Id":62768555,"CreationDate":"2020-07-07T04:49:00.000","Title":"How to write a perspective of log function in cvxpy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made 100 .py file, now I want to run them at the same time , they all have a same function , just the argument is changing. Each file can take 20 minutes to run completely so I need them to run simultaneously. How can I do that ?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":62769942,"Users Score":0,"Answer":"You can make a call from first.py to second.py and so on and so forth","Q_Score":0,"Tags":"python","A_Id":62770126,"CreationDate":"2020-07-07T07:17:00.000","Title":"Run multiple .py python file at the same time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use the customvision SDK in python.\nAs it is explained on the customvision website, I run  pip install azure-cognitiveservices-vision-customvision.\nBut I get a missing file error. Does someone could give me an example of :\n\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python38\\site-packages\\azure\\cognitiveservices\\vision\\customvision\\prediction\\models\\pycache\\_custom_vision_prediction_client_enums.cpython-38.pyc'","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":26,"Q_Id":62770707,"Users Score":1,"Answer":"Thank you for trying to help but I fixed this problem yersteday.\nIn order to do that, I reinstalled python 3.8 and pip3, then I installed azure-cognitiveservices-vision-customvision==1.0.0 package.\nHowever it didn't install the training package so I had to download it manually on Pypi.","Q_Score":0,"Tags":"python,azure-cognitive-services,microsoft-custom-vision","A_Id":62790058,"CreationDate":"2020-07-07T08:04:00.000","Title":"CUSTOMVISION - Missing files when installing python packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have my dataset in a TensorFlow Dataset pipeline and I am wondering how can I normalize it, The problem is that in order to normalize you need to load your entire dataset which is the exact opposite of what the TensorFlow Dataset is for.\nSo how exactly does one normalize a TensorFlow Dataset pipeline? And how do I apply it to new data? (I.E. data used to make a new prediction)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1604,"Q_Id":62772571,"Users Score":1,"Answer":"You do not need to normalise the entire dataset at once.\nDepending on the type of data you work with, you can use a .map() function whose sole purpose is to normalise that specific batch of data you are working with (for instance divide by 255.0 each pixel within an image.\nYou can use, for instance, map(preprocess_function_1).map(preprocess_function_2).batch(batch_size), where preprocess_function_1 and preprocess_function_2 are two different functions that preprocess a Tensor. If you use .batch(batch_size) then the preprocessing functions are applied sequentially on batch_size number of elements, you do not need to alter the entire dataset prior to using tf.data.Dataset()","Q_Score":1,"Tags":"python,tensorflow,machine-learning,keras,tensorflow-datasets","A_Id":62772780,"CreationDate":"2020-07-07T09:52:00.000","Title":"how does one normalize a TensorFlow `Dataset` pipeline?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have this Instagram bot that is made using Python and Selenium, It log into Instagram, goes to a profile, select the last post and select the \"other x people liked this photo\" to show the complete list of the people that liked the post(it can be done with the follower of the page too).\nNow I am stuck because I don't know how can i make the bot click only the profiles that have active stories and how to make it scroll down (the problem is that the way that i found to click on the profiles works just with the first one profile because when I click on the profile it opens the stories and closes the post, so when i reopen the post and the list of like on this post it will reclick on the same profile that I have already seen the stories of).\nDoes someone know how to do that or a similar thing maybe something even better that I didn't thinked of?\nI don't think code is needed but if you need I will post it, just let me know.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":462,"Q_Id":62774102,"Users Score":1,"Answer":"Have you tried to use the \"back\" button on your browser window? Or open the page in a new tab, so you have still the old one to go back to.","Q_Score":1,"Tags":"python,selenium,bots,instagram,instagram-story","A_Id":62774176,"CreationDate":"2020-07-07T11:19:00.000","Title":"Python Selenium bot to view Instagram stories | How can i click the profiles of people that have active stories?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wonder what if i had 1 million users, how much time will take it to loop every account to check for the username and email if the registration page to check if they are already used or not, or check if the username and password and correct in the log in page, won't it take ages if i do it in a traditional for loop?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":50,"Q_Id":62775839,"Users Score":1,"Answer":"Rather than give a detailed technical answer, I will try to give a theoretical illustration of how to address your concerns. What you seem to be saying is this:\n\nLinear search might be too slow when logging users in.\n\nI imagine what you have in mind is this: a user types in a username and password, clicks a button, and then you loop through a list of username\/password combinations and see if there is a matching combination. This takes time that is linear in terms of the number of users in the system; if you have a million users in the system, the loop will take about a thousand times as long as when you just had a thousand users... and if you get a billion users, it will take a thousand times longer over again.\nWhether this is a performance problem in practice can only be determined through testing and requirements analysis. However, if it is determined to be a problem, then there is a place for theory to come to the rescue.\nImagine one small improvement to our original scheme: rather than storing the username\/password combinations in arbitrary order and looking through the whole list each time, imagine storing these combinations in alphabetic order by username. This enables us to use binary search, rather than linear search, to determine whether there exists a matching username:\n\ncheck the middle element in the list\nif the target element is equal to the middle element, you found a match\notherwise, if the target element comes before the middle element, repeat binary search on the left half of the list\notherwise, if the target element comes after the middle element, repeat binary search on the right half of the list\nif you run out of list without finding the target, it's not in the list\n\nThe time complexity of this is logarithmic in terms of the number of users in the system: if you go from a thousand users to a million users, the time taken goes up by a factor of roughly ten, rather than one thousand as was the case for linear search. This is already a vast improvement over linear search and for any realistic number of users is probably going to be efficient enough. However, if additional performance testing and requirements analysis determine that it's still too slow, there are other possibilities.\nImagine now creating a large array of username\/password pairs and whenever a pair is added to the collection, a function is used to transform the username into a numeric index. The pair is then inserted at that index in the array. Later, when you want to find whether that entry exists, you use the same function to calculate the index, and then check just that index to see if your element is there. If the function that maps the username to indices (called a hash function; the index is called a hash) is perfect - different strings don't map to the same index - then this unambiguously tells you whether your element exists. Notably, under somewhat reasonable assumptions, the time to make this determination is mostly independent from the number of users currently in the system: you can get (amortized) constant time behavior from this scheme, or something reasonably close to it. That means the performance hit from going from a thousand to a million users might be negligible.\nThis answer does not delve into the ugly real-world minutia of implementing these ideas in a production system. However, real world systems to implement these ideas (and many more) for precisely the kind of situation presented.\nEDIT: comments asked for some pointers on actually implementing a hash table in Python. Here are some thoughts on that.\nSo there is a built-in hash() function that can be made to work if you disable the security feature that causes it to produce different hashes for different executions of the program. Otherwise, you can import hashlib and use some hash function there and convert the output to an integer using e.g. int.from_bytes. Once you get your number, you can take the modulus (or remainder after division, using the % operator) w.r.t. the capacity of your hash table. This gives you the index in the hash table where the item gets put. If you find there's already an item there - i.e. the assumption we made in theory that the hash function is perfect turns out to be incorrect - then you need a strategy. Two strategies for handling collisions like this are:\n\nInstead of putting items at each index in the table, put a linked list of items. Add items to the linked list at the index computed by the hash function, and look for them there when doing the search.\n\nModify the index using some deterministic method (e.g., squaring and taking the modulus) up to some fixed number of times, to see if a backup spot can easily be found. Then, when searching, if you do not find the value you expected at the index computed by the hash method, check the next backup, and so on. Ultimately, you must fall back to something like method 1 in the worst case, though, since this process could fail indefinitely.\n\n\nAs for how large to make the capacity of the table: I'd recommend studying recommendations but intuitively it seems like creating it larger than necessary by some constant multiplicative factor is the best bet generally speaking. Once the hash table begins to fill up, this can be detected and the capacity expanded (all hashes will have to be recomputed and items re-inserted at their new positions - a costly operation, but if you increase capacity in a multiplicative fashion then I imagine this will not be too frequent an issue).","Q_Score":2,"Tags":"python,algorithm,sorting,web,data-structures","A_Id":62777412,"CreationDate":"2020-07-07T12:57:00.000","Title":"what the fastest method to loop through a very large number of account in a log in page","Data Science and Machine Learning":0,"Database and SQL":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 deployed a Django app in namecheap shared hosting. All the page and functions are working fine except file upload. File upload from django-admin(return 404 page) and custom file upload form (render root page view) is not working. I have tried with flask app and file upload is working fine. All settings about media is ok.\nI have contacted with namecheap support. But, they want specific problem which i can't find out.\nI got similar  type  question in stackoverflow and other forum but nobody has replied.\nThank in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":62777863,"Users Score":0,"Answer":"I want to answer of my above question.\nThe issue was about Mod_Security. Need to disable it. I have figured out by talking with namecheap customer care and it's working fine.","Q_Score":0,"Tags":"python,django,apache,shared-hosting,namecheap","A_Id":64548581,"CreationDate":"2020-07-07T14:44:00.000","Title":"django-admin file upload return 404 page in shared hosting (namecheap)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm starting to use Google Cloud Dataflow for batch and streaming processing. The jobs being developed are mostly for ingesting data from different sources (MySQL, Kafka, and file systems), cleansing them, do some streaming and bath aggregation, and writing back to Google Cloud Storage.\nGiven these tasks, are there any recommendations for using the Java SDK or Python SDK for writing the jobs? Any noticeable differences in terms of performance and features between them?\nFor example, I noticed that for the Java SDK, the built-in I\/O PTransform JdbcIO is available. This PTransform reads and writes data on JDBC, and this is not available in the Python SDK (so far). Is it possible to use the Java SDK only to create a pipeline that reads from a MySQL database and writes to Google Cloud Storage, while for the other pipelines use a different SDK (e.g. Python)?\nThanks in advance for your time!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1112,"Q_Id":62778682,"Users Score":2,"Answer":"I would go ahead with java SDK as the features and external connectors are more in java. But python SDK is also catching up.\nAs far as performance considerations are concerned when we submit a beam job to dataflow, the job steps will be sent in an API call to the google cloud dataflow. Hence, I think there's no significant difference in performance as far as dataflow is concerned","Q_Score":0,"Tags":"java,python,google-cloud-platform,google-cloud-dataflow,apache-beam","A_Id":62778787,"CreationDate":"2020-07-07T15:27:00.000","Title":"Google Cloud Dataflow - Java SDK vs Python SDK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a server which continuously sends data block (sample) at a sampling rate of 100Hz. My client receives it and performs some calculation on the sample to visually display a real-time tracking and then receives the next sample and so on. The time taken for it to receive and calculate until the next sample is received is 0.1s.\nThis means that I am missing on the in between samples, if I am not wrong. How can change the code such that I receive 'all samples' and perform the calculation in order to enable a real-time tracking?\nThank you in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":231,"Q_Id":62779087,"Users Score":0,"Answer":"From the comment section:\n\nThe server is a software from where I am receiving the samples. And the manual of the software says the sampling rate of the samples is 100Hz. My client code receives it and checks if the data within the sample is above the threshold value or not and displays an error on the screen when it is. To be able to check for every sample that is being streamed by the software, my receiving and computation must be faster. Could you explain how could I use buffer to better my case? I am sorry if my question is very silly. But this is my first attempt in TCP programming as well as Python\n\nFor a sampling rate of 100 Hz the network latency has to be below 10ms.\nFirst test: Determine the network latency...\nOnly receive the data and log the times (including milliseconds) to a file. If you have gaps of more than 10ms between the datapackets, the network is probably not fast enough.\nIf the gaps are far below the 10ms, data processing is too slow.\nServer-side buffering (high latency):\nIf you can change the server, consider sending multiple packets at once, but at a slower frequency. The client would have more time to process the data instead of waiting for the I\/O.\nClient-side buffering (low latency):\nIf the server sends packets faster than you can process them, consider a FIFO buffer for the client. Incoming data is appended to the buffer, while processing code fetches its packets from the queue, ideally simultaneously.\nLastly, some warm words of warning: You [say you] are new to a programming language and network programming - it's probably too early for a realtime data processing project and I would suggest to start with a simpler projects for training purposes...","Q_Score":0,"Tags":"python,tcp,runtime,client-server,rate","A_Id":62780063,"CreationDate":"2020-07-07T15:48:00.000","Title":"Server sending data at a sampling rate 100 Hz and the client receiving and processing time is around 0.1s using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"there is a way to debug a falcon app on windows? I'm using Pycharm.\nI use waitress to run from the command line, but I have no idea how to debug my source code.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":594,"Q_Id":62779572,"Users Score":0,"Answer":"I have used pycharm 2018 and I have not found any support for debug falcon app(maybe I could be wrong ). What I have done is make a different file on same directory and put all function over there and debug that file as normal python script or. May be you can use print or kind of unit test to test your code.","Q_Score":0,"Tags":"python,windows,pycharm,falcon","A_Id":62780163,"CreationDate":"2020-07-07T16:14:00.000","Title":"How to debug falcon app on windows and pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm looking for a way to scan a website and instantly detect an update, without having to refresh the page. So when a new post is pushed to the webpage, I'd like to be instantly notified. Is there a way to do that without having to refresh the page constantly?\nCheers","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":65,"Q_Id":62780541,"Users Score":1,"Answer":"What browser are you using? Chrome has an auto refresh extension. Try doing a Google search for the extension. It's very easy to set up. It's more of a timed refresh that you can program. But it works for situations like what you are asking.","Q_Score":1,"Tags":"python,html,jquery,google-chrome","A_Id":62780663,"CreationDate":"2020-07-07T17:13:00.000","Title":"How to get notified when new content is pushed to a webpage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm looking for a way to scan a website and instantly detect an update, without having to refresh the page. So when a new post is pushed to the webpage, I'd like to be instantly notified. Is there a way to do that without having to refresh the page constantly?\nCheers","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":65,"Q_Id":62780541,"Users Score":1,"Answer":"Without knowing a bit more about your task, it's hard to give you a clear answer. Typically you would set up some kind of API to determine if data has been updated, rather than scraping the contents of a website directly. See if an API exists, or if you could create one for your purpose.\nUsing an API\nWrite a script that calls the API every minute or so (or more often if necessary). Every time you call the API, save the result. Then compare the previous result to the new result - if they're different then the data has been updated.\nScraping a Website\nIf you do have to scrape a website, this is possible. If you execute an HTTP GET request against a webpage, the response will contain the DOM of the webpage. You can then traverse the DOM to determine the contents of a webpage. Similar to the API example, you can write a script that executes the HTTP request every minute or so, saves the state, and compares it to the previous state. There are numerous libraries out there to help preform HTTP request and traverse the DOM, but without knowing your tech stack I can't really recommend anything.","Q_Score":1,"Tags":"python,html,jquery,google-chrome","A_Id":62780866,"CreationDate":"2020-07-07T17:13:00.000","Title":"How to get notified when new content is pushed to a webpage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"One of my columns currently has an extra space after a colon.\nex: 11-july-2011 11: 30:30\nIs there a way to remove the space without removing the first one as well?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":62780835,"Users Score":0,"Answer":"You can replace the Spaces using .replace(':\\s+', ':') , this piece of code searches for a colon followed by a space and replaces it with a colon , so you basically just remove the space which is behind a colon :)","Q_Score":1,"Tags":"python,python-3.x,pandas,datetime,format","A_Id":62780965,"CreationDate":"2020-07-07T17:33:00.000","Title":"Pandas remove space after regex","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We handle 10-20 payments daily using Paypals IPN system.\nThe past hour or so Paypal has been sending the IPNs in the wrong order.\nOur payments are subscriptions.\nSo generally they send.\nSubscr_signup\n& shortly after that\nsusbcr_payment.\nBut today they've been sending the subscr_payment before the subscr_signup every time. Which messed up our flow since the payment tries to link itself with a subscriber which it can't so it throws an error. This has forced us to manually add all the information which is a headache.\nAny ideas on how I should solve this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":62780899,"Users Score":0,"Answer":"IPN is an asynchronous, best-effort delivery service. The \"Instant\" in its name, can be misleading, since that service was created a long time ago, and it was instant relative to, say, waiting for an email and processing things manually.\nSince payments and subscription profile creations are separate events in separate systems, you may receive notifications of each event in any order.\nYou should be able to create new\/temporary\/placeholder subscriber objects with the first subscr_payment event alone -- and if necessary fill in any missing information (or activate the placeholder) when you do receive a subscr_signup even.","Q_Score":0,"Tags":"python,django,paypal","A_Id":62781905,"CreationDate":"2020-07-07T17:36:00.000","Title":"Paypal IPN sent in the wrong order","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 python3 environments on my Ubuntu 18.04 machine.\n\nThe built-in Python environment at \/usr\/local\/lib\/python3.6\/dist-packages\/ and\nAnaconda python3. Note: Opencv works perfectly in both of them.\n\nThe system I am building need to use sudo python3(\/usr\/local\/lib\/python3.6\/dist-packages\/) and python3(anaconda) at different times, but I want to minimize the dependency size for users. So what I am trying to do is that the dependencies will be installed in the built-in python3 only and when the program is called by normal python3 the script will set the sys.path to the sys.path of sudo python.(I have stored that path in a file at the installation time.)\nBut when I do that import cv2 raises: ModuleNotFoundError: No module named 'cv2.cv2'\nNote: Other libraries works fine. Only Opencv is having this problem.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2280,"Q_Id":62780985,"Users Score":0,"Answer":"The correct way to do it was by installing OpenCV using sudo apt install python3-opencv. OpenCV installed with apt install can be used anywhere in your system whereas pip will only install OpenCV to a particular python environment.","Q_Score":0,"Tags":"python,python-3.x,opencv,ubuntu,opencv-python","A_Id":63925619,"CreationDate":"2020-07-07T17:41:00.000","Title":"ModuleNotFoundError: No module named 'cv2.cv2' after changing `sys.path`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used pyinstaller to turn a python program that scrapes urls from an excel doc into an executable file. One of the user inputs is the name of the excel doc. Do pyinstaller executables work with local files? My excel doc and executable are in the same folder.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":62782335,"Users Score":0,"Answer":"Yes they should, as long as your code is not hard-coded, and finds the current path of the file, you should be able to find the file anywhere in the current directory that you set.","Q_Score":1,"Tags":"python,excel,web-scraping,pyinstaller","A_Id":62782495,"CreationDate":"2020-07-07T19:14:00.000","Title":"Can a program executed with PyInstaller work with local files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm adding a new column to a table of type JSONB and I can not find the formatting necissary to set the default value to anything other than a empty object.\nHow would I accomplish this?\nCurrently my code looks akin to:\nnew_column     = db.Column(JSONB, server_default=db.text(\"'{}'\"), nullable=False)\nI've tried a few ways I thought might be the intuitive way of handeling it. But so far they just cause an error when being run.\nExample 1:\nnew_column     = db.Column(JSONB, server_default=db.text(\"'{'enabled': True}'\"), nullable=False)\nExample 2:\nnew_column     = db.Column(JSONB, server_default=db.text(\"'{enabled: True}'\"), nullable=False)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":515,"Q_Id":62786493,"Users Score":0,"Answer":"Ilja Everil\u00e4's answer was the answer.  In python I had to format the line of code in the style of:\nserver_default=db.text(\"'{\\\"enabled\\\": \\\"true\\\"}'\")\nTripple quotes work too if you don't want escape characters, but this looks nicer to my eyes\nStill unsure how I would pass the booleen value of true instead of a string. But that is another question for another time.","Q_Score":0,"Tags":"python,postgresql,sqlalchemy","A_Id":62835465,"CreationDate":"2020-07-08T02:09:00.000","Title":"How to set a more complex default value for a JSONB column in sqlAlchemy (postgreSQL)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Imagine, that I have a 28 x 28 size grayscale image.. Now if I apply a Keras Convolutional layer with 3 filters and 3X3 size with 1X1 stride, I will get 3 images as output. Now if I again apply a Keras Convolutional layer with only 1 filter and 3X3 size and 1X1 stride, so how will this one 3X3 filter convolute over these 3 images and then how will we get one image..\nWhat I think is that, the one filter will convolute over each of the 3 images resulting in 3 images, then it adds all of the three images to get the one output image.\nI am using tensorflow backend of keras. please excuse my grammar, And Please Help me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":46,"Q_Id":62787503,"Users Score":0,"Answer":"Answering my own question:\nI figured out that the one filter convolutes over 3 images, it results in 3 images, but then these these images pixel values are added together to get one resultant image..\nYou can indeed check by outputting 3 images for 3 filters on 1 image. when you add these 3 images yourself (matrix addition), and plot it, the resultant image makes a lot of sense.","Q_Score":0,"Tags":"python-3.x,tensorflow,keras,conv-neural-network","A_Id":62828300,"CreationDate":"2020-07-08T04:22:00.000","Title":"How do we get the output when 1 filter convolutes over 3 images?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know it is string interpolation, but I can't understand what is the exact meaning. It seems it convert int2 to hexadecimal as a string(I see this behavior in debugging) but what is the int1 role? (I guess it is the size of hexadecimal)\ncan anybody explain in detail?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":126,"Q_Id":62787507,"Users Score":1,"Answer":"* means to get the field width from the corresponding argument, rather than hard-coding it into the format string (e.g. %08x means to print 8 hex digits). So int1 specifies the number of digits to print.\nThe 0 before the field width means to pad the output with zeroes rather than spaces.","Q_Score":0,"Tags":"python,string,string-interpolation","A_Id":62787531,"CreationDate":"2020-07-08T04:23:00.000","Title":"what does '%0*x' % (int1, int2) syntax do in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with some big txt files, (some around 3 Gb), and whenever I have to check the txt files the message \"File size exceeds configured limit (2,56 MB), code insight features not available\" appear in the top of the file, I tried to change the file size by going to help->Edit custom properties and then adding the next line of code in the file that opens\n`` idea.max.content.load.filesize=500000 ```\nthe problem is that even after closing and re-opening PyCharm the same message appears, do I need to do something else? just writing that line of code is enough to change the filesize?, it doesn't need to be run like a normal code? if so how can I run it since the option doesn't appear?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3021,"Q_Id":62787643,"Users Score":2,"Answer":"instead of using the original line of code I used\nidea.max.intellisense.filesize = new size in kb\nalso, I advise rebooting the Pc after adding that line of code in the window that appears after going to help->Edit custom properties","Q_Score":2,"Tags":"python,file,size","A_Id":62788053,"CreationDate":"2020-07-08T04:36:00.000","Title":"PyCharm File size exceeds configured limit (2,56 MB), code insight features not available","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Do I need to install virtualenv for every different django project that I make or should I just go straight to creating a virtualenv after I installed it in the first project?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":58,"Q_Id":62787856,"Users Score":1,"Answer":"The best way is to create a separate virtual environment for each project. So that you can avoid python package dependency issues.","Q_Score":2,"Tags":"python,django,pycharm","A_Id":62787883,"CreationDate":"2020-07-08T04:58:00.000","Title":"Creating a project with Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Do I need to install virtualenv for every different django project that I make or should I just go straight to creating a virtualenv after I installed it in the first project?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":58,"Q_Id":62787856,"Users Score":1,"Answer":"So first try to understand the definition of Virtual environment,\" a self-contained directory tree\". Now you can create different Virtual environments, What I prefer doing is using a virtual environment based on their uses, like if one virtual environment has all the basic requirments, i don't have to create another one.","Q_Score":2,"Tags":"python,django,pycharm","A_Id":62788693,"CreationDate":"2020-07-08T04:58:00.000","Title":"Creating a project with Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to convert a Pyspark dataframe to Python list with 140000 rows. I am doing it using toLocalIterator() but it is taking a lot of time. How do i fasten this process?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":62788966,"Users Score":0,"Answer":"Using toLocalIterator() will eliminate parrallesim . It will work on one partition on driver node one by one. Based on use cases and size of data you can do collect or save file. If you add details can explore more options.","Q_Score":0,"Tags":"python,apache-spark,pyspark,apache-spark-sql,pyspark-dataframes","A_Id":62797531,"CreationDate":"2020-07-08T06:41:00.000","Title":"How to improve performance of toLocalIterator() in Pyspark","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a dataset and the data is provided to us in a .data file. is there any direct function like read_csv or read_excel?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":62791172,"Users Score":0,"Answer":"No. A .data file could be absolutely anything.\nUse the file utility to try to identify the file format, or better yet ask the party you got the data from what it is.","Q_Score":1,"Tags":"python,pandas,numpy,dataframe,machine-learning","A_Id":62791229,"CreationDate":"2020-07-08T09:00:00.000","Title":"Is there a python pandas function to directly read .data file?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After my kivy app is pushed to my android device through buildozer,\nFirst I can see Kivy loading symbol,then screen is blank for 30 seconds. after that my app is getting opened.\nAnd this is happening on first run as well as subsequent runs.\nI have read some answers and got to know that \"we can avoid this problem by starting with minimal GUI\nand loading the rest more lazily\".\nCould any one please let me know,how we can load like this when the app opens?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":62791182,"Users Score":0,"Answer":"For an example, if you used on_pre_enter function and if you give this function to do many things, its normal you to wait much a time. But there is a no any code so i can't analyze your code and give any tip.Your computer's and android's processing time depends on background applications, hardware and many things does that. So try to share your minimal code just like your starting functions or you can create minimal application which has these functions so you can test your codes partly.","Q_Score":0,"Tags":"python,android,kivy","A_Id":62846739,"CreationDate":"2020-07-08T09:00:00.000","Title":"Kivy app takes 30 seconds to open in android device","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Airflow, if I create a custom operator class, and use it in a dag, must it actually return anything?\nCouple of examples, let's say I create sensor operator (inherits from base_sensor_operator) which checks every 5 min for the existence of a file somewhere. Similar to check_for_wildcard_key() and how it returns True or False. Does any method I create have to actually have a return statement with this True\/False value in order to function? Will the scheduler know to retry this task without a return statement?\nAnother example is if I create a custom operator (non sensor) that executes SQL code in a database that isn't as common, so I need to create my own operator to connect to that database. So let's say I am using the method execute_SQL() inside my custom operator class. I need not have a return value, right? Since the operator object itself inside of a dag file will simply just \"run\", I don't need to return anything?\nI understand sometimes we have a use for xcom_push and xcom_pull, so it might be good to have return values in case we need to send\/receive results between tasks. Is it good practice to return something even if it might not be used? Will custom operator classes work without return statements?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":892,"Q_Id":62791606,"Users Score":3,"Answer":"No, an Operator class does not need to return anything. Actually the main function of an operator is the execute method, and most of them does not return anything. Examples: BranchPythonOperator, TriggerDagRunOperator, DatabricksRunNowOperator, etc. They just do the job.\nOn the other hand, the poke method of the sensors need to return True or False since the execute method of the BaseSensorOperator calls self.poke method, and takes action based on the return value.","Q_Score":2,"Tags":"python,airflow","A_Id":62794380,"CreationDate":"2020-07-08T09:24:00.000","Title":"Does an Airflow operator need to return anything in order to function correctly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am pretty new to Tornado. I can't understand the difference between using run_on_executor and defining an async method. Is it the same? Is the one multithreaded and the other not?\nThank you in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":416,"Q_Id":62791646,"Users Score":4,"Answer":"run_on_executor is for interfacing with blocking non-async code.\nYou are correct that async code is only executed in a single thread.\nMaybe an example would illustrate the point.\nLet's say your Tornado web service interfaces with a library that makes use of requests to fetch country info for a given IP address. Since requests is a non-async library, calling this function would block the Tornado event loop.\nSo, you have two options: try to find the replacement for the library that is async-compatible OR run the blocking code in a different thread\/process and have your event loop await its result like for normal async code without blocking the event loop. The latter option is run_on_executor which allows you to run the task in different thread or process, and asyncio would \"await\" its completion.","Q_Score":2,"Tags":"python,python-3.x,asynchronous,tornado,scheduledexecutorservice","A_Id":62911633,"CreationDate":"2020-07-08T09:26:00.000","Title":"Tornado difference between run in executor and defining async methods","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on a neural network to predict scores on how \"good\" the images are. The images are the inputs to another machine learning algorithm, and the app needs to tell the user how good the image they are taking is for that algorithm.\nI have a training dataset, and I need to rank these images so I can have a score for each one for the regression neural network to train.\nI created a program that gives me 2 images from the training set at a time and I will decide which one wins (or ties). I heard that the full rank can be obtained from these comparisons using SVM Ranking. However, I haven't really worked with SVMs before. I only know the very basics of SVMs. I read a few articles on SVM Ranking and it seems like the algorithm turns the ranking problem to a classification problem, but the maths really confuses me.\nCan anyone explain how it works in simple terms and how to implement it in Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":126,"Q_Id":62792094,"Users Score":0,"Answer":"I did some more poking around on the internet, and found the solution.\nThe problem was how to transform this ranking problem to a classification problem. This is actually very simple.\nIf you have images (don't have to be images though, can be anything) A and B, and A is better than B, then we can have (A, B, 1). If B is better, then we have (A, B, -1)\nAnd we just need a normal SVM to take the names of the 2 images in and classify 1 or -1. That's it.\nAfter we train this model, we can give it all the possible pairs of images from the dataset and generating the full rank will be simple.","Q_Score":0,"Tags":"python,svm,ranking","A_Id":62813295,"CreationDate":"2020-07-08T09:52:00.000","Title":"How to rank images based on pairs of comparisons with SVM?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have a list say l = [1, 8, 8, 8, 1, 3, 3, 8] and it's guaranteed that every element occurs an even number of times, how do I make a list with all elements of l now occurring n\/2 times. So since 1 occurred 2 times, it should now occur once. Since 8 occurs 4 times, it should now occur twice. Since 3 occurred twice, it should occur once.\nSo the new list will be something like k=[1,8,8,3]\nWhat is the fastest way to do this?\nI did list.count() for every element but it was very slow.","AnswerCount":12,"Available Count":2,"Score":0.0166651236,"is_accepted":false,"ViewCount":10926,"Q_Id":62793544,"Users Score":1,"Answer":"I like using a trie set, as you need to detect duplicates to remove them, or a big hash set (lots of buckets).  The trie does not go unbalanced and you do not need to know the size of the final set.  An alternative is a very parallel sort -- brute force.","Q_Score":60,"Tags":"python,algorithm","A_Id":63181598,"CreationDate":"2020-07-08T11:14:00.000","Title":"Efficient way to remove half of the duplicate items in a list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have a list say l = [1, 8, 8, 8, 1, 3, 3, 8] and it's guaranteed that every element occurs an even number of times, how do I make a list with all elements of l now occurring n\/2 times. So since 1 occurred 2 times, it should now occur once. Since 8 occurs 4 times, it should now occur twice. Since 3 occurred twice, it should occur once.\nSo the new list will be something like k=[1,8,8,3]\nWhat is the fastest way to do this?\nI did list.count() for every element but it was very slow.","AnswerCount":12,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":10926,"Q_Id":62793544,"Users Score":7,"Answer":"Instead of using a counter, which keeps track of an integer for each possible element of the list, try mapping elements to booleans using a dictionary. Map to true the first time they're seen, and then every time after that flip the bit, and if it's true skip the element.","Q_Score":60,"Tags":"python,algorithm","A_Id":62805348,"CreationDate":"2020-07-08T11:14:00.000","Title":"Efficient way to remove half of the duplicate items in a list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've made a executable of a python code, but everytime I run it, a console window opens. To stop that, I've tried:\n\nRunning --noconsole while packaging\nchanging the the console=True to console=False on the .spec file.\n\nThe first one doesn't work at all, nothing changes. When I do the second one, though, the .exe stops working (when I try to open, it doesn't).\nAny suggestions ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":809,"Q_Id":62795172,"Users Score":1,"Answer":"I believe you are using pyinstaller to create an exe.\nJust add --noconsole flag and the command window wont appear.\ne.g.\npyinstaller --noconsole scriptname.py\nAs pointed out by author this works after changing to debug=True and console=False in spec file.","Q_Score":0,"Tags":"python,python-3.x,packaging","A_Id":62795386,"CreationDate":"2020-07-08T12:47:00.000","Title":"Problem with making a .exe without a console window (PyInstaller)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a jupyter notebook that accepts user-input via the input() python function. It then takes the input and uses it to a run a model and then outputs\/plots the result. Is there a way to create a web-app that does this? Of course, the web-app must also accept user-input and have access to my model.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":525,"Q_Id":62795661,"Users Score":0,"Answer":"It doesn't work like that. If you want to make a web app, you'll make GUI with html\/css for taking input and displaying output. Your python code will work as the backend of the application. You can use a python framework like flask to make things easier.","Q_Score":1,"Tags":"python,machine-learning,web-applications,jupyter-notebook","A_Id":62795723,"CreationDate":"2020-07-08T13:13:00.000","Title":"Is there a way to make a web app from a jupyter notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there any way to generate a unique random number that has 8 bytes size in python language? I used the UUID library but it has 16 bytes which are not aligned with my requirement.\nAny help would be much appreciated.\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":646,"Q_Id":62797012,"Users Score":0,"Answer":"In Python 3.6 and later, this is easy:\n\nImport the secrets module: import secrets.\nGenerate a random byte sequence with secrets.token_bytes(8). Or, if the string should be readable, use the following which produces a 16-character string out of 8 bytes (secrets.token_hex(8)),  or an 8-character string out of 4 bytes (secrets.token_hex(4)).","Q_Score":1,"Tags":"python,random,generator,uuid","A_Id":62797485,"CreationDate":"2020-07-08T14:23:00.000","Title":"How to generate 8 bytes unique random number in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm testing Conv, GRU, LSTM and simple Dense and I don't get 70 to 80%\nMy network converges very fast and overfits in the first seasons, could it be the data?\nLayer (type)                 Output Shape              Param #\nlstm_46 (LSTM)               (None, 65, 32)            6272\n\ndropout_67 (Dropout)         (None, 65, 32)            0\n\nbidirectional_20 (Bidirectio (None, 65, 64)            16640\n\ndropout_68 (Dropout)         (None, 65, 64)            0\n\nlstm_48 (LSTM)               (None, 32)                12416\n\ndropout_69 (Dropout)         (None, 32)                0\n\nflatten_28 (Flatten)         (None, 32)                0\n\ndense_73 (Dense)             (None, 10)                330\n\nactivation_72 (Activation)   (None, 10)                0\n\ndense_74 (Dense)             (None, 1)                 11\n\nactivation_73 (Activation)   (None, 1)                 0\nTotal params: 35,669\nTrainable params: 35,669\nNon-trainable params: 0","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":62797061,"Users Score":0,"Answer":"It's hard to say without knowing more about the data. Some of the possible solutions can be -\n\nUse a shallower network\nGet more training data\nMake sure your training and validation set comes from the same distribution","Q_Score":1,"Tags":"python,machine-learning,deep-learning,nlp,lstm","A_Id":62797185,"CreationDate":"2020-07-08T14:26:00.000","Title":"What to do when overfitting does not improve using regularization and droppout?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to install discord on my raspberry pi, but its saying error code 1 and I need a more updated version of python (3.4.5). However, Thonny Python says it's version is 3.7.3.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3322,"Q_Id":62798274,"Users Score":0,"Answer":"Python on raspberry pi comes preinstalled with version 2 and version 3 of python\nTry using pip3 install discord and see if that fixes it","Q_Score":0,"Tags":"python,discord","A_Id":62805382,"CreationDate":"2020-07-08T15:26:00.000","Title":"Install discord on 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":0},{"Question":"Is there a way to get  a  position of thumb in pixels in vertical scale widget relative to upper right corner of widget? I want a label with scale value to pop up next to thumb when mouse pointer hovering over it, for this I need thumb coordinates.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":62799562,"Users Score":0,"Answer":"The coords method returns the location along the trough corresponding to a particular value.\nThis is from the canonical documentation for the coords method:\n\nReturns a list whose elements are the x and y coordinates of the point along the centerline of the trough that corresponds to value. If value is omitted then the scale's current value is used.\n\nNote: you asked for coordinates relative to upper-right corner. These coordinates are relative to the upper-left. You can get the width of the widget with winfo_width() and do a simple transformation.","Q_Score":0,"Tags":"python,tkinter,scale","A_Id":62799883,"CreationDate":"2020-07-08T16:42:00.000","Title":"how to get position of thumb (in pixels) inside of vertical scale widget relatively upper right corner?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm designing a Flask app that graphs some weather data for several cities. It makes sense to me to use a \"City\" class that handles the fetching and parsing of the data every time the page is loaded. However, what I'm not sure about is how Flask would handle these instances. Is Flask \"smart\" enough to know to release the memory for these instances after the page is served? Or will it just gradually consume more and more memory?\nAlternatively, would I just be able to create a single global class instance for each city OUTSIDE of the \"@app.route\" functions that I could use whenever a page is requested?\nThe deployment server will be Windows IIS using FastCGI, in case that matters at all.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":61,"Q_Id":62801658,"Users Score":1,"Answer":"Flask is \"just\" a framework. It is still executed and managed by the \"normal\" Python interpreter so the question \"how Flask would handle these instances\" is nonexistent.\nDefine classes and use their instances as you would in any other Python project\/snippet, however it might be beneficial to think where to define them.\nIt will not make sense inside a route since the class will be redefined every time a request is received, but the how is exactly the same.","Q_Score":0,"Tags":"python,python-3.x,flask","A_Id":62801944,"CreationDate":"2020-07-08T18:47:00.000","Title":"Can I use python3 classes inside a Flask app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to create an executable using PyInstaller.\nImportant files for my problem are:\nmain.py and dbinterface.py which are both located at the root level.\nIn dbinterface.py I am doing: import mysql.connector which would need to be added as an hidden-import to PyInstaller as I assume.\nI tried this by adding --hidden-import pyinstaller mysql.connector and also by changing the spec-file which I am honestly not sure about whether I did this correctly.\nPyInstaller show in the command line following line in it's output: 4448 ERROR: Hidden import 'mysql.connector' not found","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1739,"Q_Id":62801932,"Users Score":0,"Answer":"The problem was that I had to install mysql-connector-python globally in Python. It's not working if you have them only instaled in your virtual environment.","Q_Score":0,"Tags":"python,exe,pyinstaller,mysql-connector-python","A_Id":62832729,"CreationDate":"2020-07-08T19:04:00.000","Title":"Hidden import in PyInstaller not working?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am using tensorflow 2.2 in virtualenv, i tried to import imread, imresize from from scipy.misc but got this error\nfrom scipy.misc import imread, imresize\nwhen i checked for the reason online, i figured out that scipy.misc is deprecated with the version of scipy required in tf2.2.\nSo i tried using imageio but getting error of PIL\ndon't know what to do, can anyone of you help?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":859,"Q_Id":62801953,"Users Score":0,"Answer":"the answer to my question is quite simple. I needed to install all the required packages of tensorflow2.2 mentioned in the documentation and use python 64bits","Q_Score":0,"Tags":"python,tensorflow,scipy","A_Id":69963753,"CreationDate":"2020-07-08T19:05:00.000","Title":"ImportError: cannot import name 'imread' from 'scipy.misc' with tensorflow 2.2","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running python scripts that do batch data processing on fairly large aws instances (48 or 96 vCPU).  multiprocessing.Pool() works nicely: the workers have minimal communication with the main process (take a file path, return True\/False).  I\/O and memory don't seem to be limiting.\nI've had variable performance where sometimes the best speed comes from pool size = number of vCPU, sometimes number of vCPU\/2, and sometimes vCPU*some multiple around 2-4.  These are for different kinds of jobs, on different instances, so it would be hard to benchmark all of them.\nIs there a rule of thumb for what size pool to use?\nP.S. multiprocessing.cpu_count() returns a number that seems to be equal to the number of vCPU. If that is consistent, I'd like to pick some reasonable multiple of cpu_count and just leave it at that.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1131,"Q_Id":62803255,"Users Score":3,"Answer":"The reason for those numbers:\n\nnumber of vCPU: It is reasonable, we use all the cores.\nnumber of vCPU\/2: It is also reasonable, as sometimes we have double logical cores compares to the physical cores. But logical cores won't actually speed your program up, so we just use vCPU\/2.\nvCPU*some multiple around 2-4: It is reasonable for some IO-intensive tasks. For these kinds of tasks, the process is not occupying the core all the time, so we can schedule some other tasks during IO operations.\n\nSo now let's analyze the situation, I guess you are running on a server which might be a VPS. In this case, there is no difference between logical cores and physical cores, because vCPU is just an abstract computation resource provided by the VPS provider. You cannot really touch the underlying physical cores.\nIf your main process is not computation-intensive, or let's say it is just a simple controller, then you don't need to allocate a whole core for it, which means you don't need to minus one.\nBased on your situation, I would like to suggest the number of vCPU. But you still need to decide based on the real situation you meet. The critical rule is:\nMaximize resource usage(use as many cores as you can), minimize resource competition(Too many processes will compete for the resource, which will slow the whole program down).","Q_Score":2,"Tags":"python,amazon-ec2,python-multiprocessing","A_Id":62803840,"CreationDate":"2020-07-08T20:36:00.000","Title":"Multiprocessing pool size - cpu_count or cpu_count\/2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I try to save a file in a jupyter notebook I get an error saying there is no file or directory.\nError Message ___________________________________________________________\nUnexpected error while saving file: OneDrive%%20-%%20Files\/Desktop\/PythonProjects\/bhp.ipynb [Errno 2] No such file or directory: 'C:\\Users\\username\\OneDrive%%20-%%20Files\\Desktop\\PythonProjects\\bhp.ipynb'\nI began having this problem after a software update where now I can only save things to \"OneDrive - Files\".  Unfortunately, the path to OneDrive contains several spaces - causing this error every time I try to save a new file.  I would use a different directory if I could.  I was hoping for an easy fix like wrapping the path in quotes - but so far this didn't work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":483,"Q_Id":62805814,"Users Score":0,"Answer":"Replacing the %20 characters with a literal space resolved the issue.  I suppose the Jupyter Notebook treats the path the same way as a url and inserts %20 characters for spaces.  But when saving to a directory on a pc - the %20 characters can be replaced with a space - without the need to wrap the path in quotations or to place backslashes before the spaces.","Q_Score":0,"Tags":"python-3.x,jupyter-notebook","A_Id":62813611,"CreationDate":"2020-07-09T01:02:00.000","Title":"How to save python file in jupyter note if path contains spaces %20","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"[W 200709 09:47:12 iostream:887] Write error on <socket.socketobject object at 0x36c2910>: [Errno 113] No route to host\n[I 200709 09:47:12 web:2064] 200 GET \/templates\/js\/system\/sytemlog-control.js?=1594259185262 (10.2.26.57) 8.45ms\n[I 200709 09:47:12 web:2064] 304 GET \/templates\/html\/main.html?u=system\/systemlog (10.12.33.99) 7.92ms\n[W 200709 09:47:13 iostream:887] Write error on <socket._socketobject object at 0x36c2ad0>: [Errno 113] No route to host\n[W 200709 09:47:13 iostream:887] Write error on <socket._socketobject object at 0x36c2c90>: [Errno 113] No route to host\n[W 200709 09:47:13 iostream:887] Write error on <socket._socketobject object at 0x36c2d00>: [Errno 113] No route to host\n[W 200709 09:47:14 iostream:887] Write error on <socket.socketobject object at 0x36c2ec0>: [Errno 113] No route to host\n[I 200709 09:47:14 web:2064] 200 GET \/templates\/js\/system\/sytemlog-control.js?=1594259245749 (10.12.33.99) 1.74ms\n[W 200709 09:47:15 iostream:887] Write error on <socket._socketobject object at 0x36c2fa0>: [Errno 113] No route to host\n[W 200709 09:47:16 iostream:887] Write error on <socket._socketobject object at 0x3610f30>: [Errno 113] No route to host\n[W 200709 09:47:17 iostream:887] Write error on <socket._socketobject object at 0x36108a0>: [Errno 113] No route to host\n[I 200709 09:47:18 web:2064] 200 POST \/auth\/system\/log!list?callback=jQuery2140877480096841464_1594259245751 (10.12.33.99) 242.50ms\n[W 200709 09:47:18 iostream:887] Write error on <socket._socketobject object at 0x3610050>: [Errno 113] No route to host\n[W 200709 09:47:19 iostream:887] Write error on <socket._socketobject object at 0x3610210>: [Errno 113] No route to host\n[W 200709 09:47:20 iostream:887] Write error on <socket._socketobject object at 0x3610130>: [Errno 113] No route to host\n[W 200709 09:47:21 iostream:887] Write error on <socket._socketobject object at 0x3610c90>: [Errno 113] No route to host\n[W 200709 09:47:22 iostream:887] Write error on <socket._socketobject object at 0x36103d0>: [Errno 113] No route to host","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":62806387,"Users Score":0,"Answer":"Without further information it is quite simply that the ability for the Tornado server to connect via this socket has been lost.\nThis assumes there was a connection open between the Tornado server and something else (by the context of what you said): has the network been changed? Have you shut a dependency down that the Tornado server relies on!?! Has a shared socket based filesystem disappeared???\nI hope this helps, but basically somewhere in your Tornado servers world a connection has been broken.\nBest of luck!","Q_Score":0,"Tags":"python,tornado","A_Id":62806436,"CreationDate":"2020-07-09T02:20:00.000","Title":"When I use tornado web server, logs show this error. How can I resolve it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am doing a python project that would use multiple python API (At least 3) to obtain datas from a lot of countries and I am wondering if it is more efficient to for the data using the APIs or to use the APIs once to make a file and access it later, when needed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":62807126,"Users Score":0,"Answer":"It's always better to handle data management in your back end to minimize the performance loss in your front end.","Q_Score":0,"Tags":"python,database,api","A_Id":62807197,"CreationDate":"2020-07-09T03:50:00.000","Title":"Using multiple API vs reading from a file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a program that retrieves image and return the RGB image as 3D np.ndarray. I want to return  np.ndarray([[[]]]) when image is not available.\nCan we do it?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":364,"Q_Id":62807699,"Users Score":0,"Answer":"simply return np.empty((10,10,10),object) because x=np.empty((10,10,10)) returns array with random values already stored in the memory buffer . x=np.empty((10,10,10),object) will return array with none values.\nHere (10,10,10) dimension is just for example. Use the dimensions favourable for you.","Q_Score":0,"Tags":"python,numpy,numpy-ndarray","A_Id":62807935,"CreationDate":"2020-07-09T04:57:00.000","Title":"How to return empty numpy array as np.ndarray([[[]]])","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My python module needs to save some configuration files into a disk, is there a standard convention on where to save your module configuration files? one that you won't run into a permission error.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":26,"Q_Id":62811508,"Users Score":1,"Answer":"You can store these configuration file where ever you want (as long as your python script have the write permission to this directory and no process prevent it from writing to this directory (is not locked by other process)), as long as your module can reach them for parsing or for import if they are a python files.\nwhat are the options:\n\nstore them in the same module directory, and import\/parse them.\nstore them in deferent directory and in your python module change the os.path with os.chdir(path) to this dir for parsing.\nstore them in dir_x and provide the dir_x path to your python script via command line args with sys.argv[1]. or with argparse!","Q_Score":0,"Tags":"python,file,io,settings,python-module","A_Id":62812514,"CreationDate":"2020-07-09T09:17:00.000","Title":"Where is the official place to store settings of a python module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I classify clients by many little xgboost models created from different parts of dataset.\nSince it is hard to support many models manually, I decided to automate hyperparameters tuning via Hyperopt and features selection via Boruta.\nWould you advise me please, what should go first: hyperparameters tuning or features selection? On the other hand, it does not matter.\nAfter features selection, the number of features decreases from 2500 to 100 (actually, I have 50 true features and 5 categorical features turned to 2 400 via OneHotEncoding).\nIf some code is needed, please, let me know. Thank you very much.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":395,"Q_Id":62811696,"Users Score":1,"Answer":"Feature selection (FS) can be considered as a preprocessing activity, wherein, the aim is to identify features having low bias and low variance [1].\nMeanwhile, the primary aim of hyperparameter optimization (HPO) is to automate hyper-parameter tuning process and make it possible for users to apply Machine Learning (ML) models to practical problems effectively [2]. Some important reasons for applying HPO techniques to ML models are as follows [3]:\n\nIt reduces the human effort required, since many ML developers spend considerable time tuning the hyper-parameters, especially for large datasets or complex ML algorithms with a large number of hyper-parameters.\n\nIt improves the performance of ML models. Many ML hyper-parameters have different optimums to achieve best performance in different datasets or problems.\n\nIt makes the models and research more reproducible. Only when the same level of hyper-parameter tuning process is implemented can different ML algorithms be compared fairly; hence, using a same HPO method on different ML algorithms also helps to determine the most suitable ML model for a specific problem.\n\n\nGiven the above difference between the two, I think FS should be first applied followed by HPO for a given algorithm.\nReferences\n[1] Tsai, C.F., Eberle, W. and Chu, C.Y., 2013. Genetic algorithms in feature and instance selection. Knowledge-Based Systems, 39, pp.240-247.\n[2] M. Kuhn, K. Johnson Applied Predictive Modeling Springer (2013) ISBN: 9781461468493.\n[3] F. Hutter, L. Kotthoff, J. Vanschoren (Eds.), Automatic Machine Learning: Methods, Systems, Challenges, 9783030053185, Springer (2019)","Q_Score":2,"Tags":"python-3.x,xgboost,feature-selection,hyperparameters,hyperopt","A_Id":63994784,"CreationDate":"2020-07-09T09:25:00.000","Title":"What should go first: automated xgboost model params tuning (Hyperopt) or features selection (boruta)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have an existing python\/flask app (made by someone else) that has a nav bar, sidebar and different pages. We have built a create-react-app project that we want to sit on one of these pages in the python\/flask app.\nThe question is - how can we integrate our react app into the existing python\/flask codebase?\nAny help gratefully received!\nUpdate: from helpful answer below - could anyone help with explaining this a little more - perhaps with code examples? \"render a container in the same template that react can mount on.\"\nUpdate 2: Someone else suggested \"You can have React run anywhere where you can add a script tag into HTML and a DOM element to attach it to. As long as you have a way to bundle and serve the JS files, you should just be able to include your new app like that.\" - could anybody help with code examples of this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":248,"Q_Id":62812420,"Users Score":0,"Answer":"A rough outline would be:\n\nconfigure the build folder to be the folder where static files are served from by your server (js, css, ...)\ninclude the files from that folder in the template of the page your want your react app to display (via <link> and <script> tags).\nrender a container in the same template that react can mount on.","Q_Score":0,"Tags":"python,reactjs,flask","A_Id":62812631,"CreationDate":"2020-07-09T10:04:00.000","Title":"How to insert create-react-app project into existing python\/flask app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on a question and answer system with django. my problem : I want the app to get a question from an ontology and according the user's answer get the next question. how can I have all the questions and user's answers displayed. i'm new to django, I don't know if I can use session with unauthenticated user and if I need to use websocket with the django channels library.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":85,"Q_Id":62813362,"Users Score":1,"Answer":"Given that you want to work with anonymous users the simplest way to go is to add a hidden field on the page and use it to track the user progress. The field can contain virtual session id that will point at a model record in the backend, or the entire Q\/A session(ugly but fast and easy). Using REST or sockets would require similar approach.\nI can't tell from the top of my mind if you can step on top of the built in session system. It will work for registered users, but I do believe that for anonymous users it gets reset on refresh(may be wrong here).","Q_Score":0,"Tags":"python,django,session,django-channels","A_Id":62817060,"CreationDate":"2020-07-09T10:59:00.000","Title":"user interaction with django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What is the difference between len(list(iterator)) and sum(1 for _ in iterator)?\nSubsequently, which is the best one to use to calculate the length of an iterator?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":62818142,"Users Score":5,"Answer":"The first one uses O(n) space, because it has to build list. The second one uses O(1) space, because it doesn't have to remember an element once the running total has been updated.\nNeither one is terribly useful, as you've discarded every element from the original iterator without looking at any of them. You are left with how long the iterator was. Assuming you are OK with that, O(1) space is better than O(n).","Q_Score":1,"Tags":"python,python-3.x,iterator","A_Id":62818231,"CreationDate":"2020-07-09T15:15:00.000","Title":"Which approach is better to calculate the length of an iterator?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently, I'm working on docplex on python.\nI just found out that result from IBM cplex Ilog and docplex is way different.\nEven though their constraints, objective function, everything are identical, their solution is very different.\nIn some cases, docplex says infeasible even though it is feasible in Ilog.\nI tried to limit integrality and minimum gap in docplex tolerances but the same problem happens.\nIs there anyone have idea why this happens? and how to solve this??","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":339,"Q_Id":62821830,"Users Score":0,"Answer":"Something must be different between the two versions. You can use refine_conflict to know the source of infeasibility","Q_Score":0,"Tags":"python-3.x,cplex,docplex","A_Id":62825481,"CreationDate":"2020-07-09T18:56:00.000","Title":"IBM cplex ilog VS docplex 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":"Currently, I'm working on docplex on python.\nI just found out that result from IBM cplex Ilog and docplex is way different.\nEven though their constraints, objective function, everything are identical, their solution is very different.\nIn some cases, docplex says infeasible even though it is feasible in Ilog.\nI tried to limit integrality and minimum gap in docplex tolerances but the same problem happens.\nIs there anyone have idea why this happens? and how to solve this??","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":339,"Q_Id":62821830,"Users Score":1,"Answer":"To complement Alex's answer: in Docplex, Model.export_as_lp(path'c:\/temp\/mymodel.lp') is the way to generate a LP file from you Docplex model.\nIn Cplex's Python API, you have a Cplex instance, use cpx.write('c:\/temp\/mymodel_cplex.lp') to generate the LP files.\nIf your models are identical, then both LP files should also be identical (except maybe some differences in variable ordering, e.g. x2+x1 instead of x1+x2).\nIf you need to work the same model both APIs, then you must first reach this equality before going further.\nDOcplex has tools to investigate infeasible models, but there is no point until you ensure both models are identical.","Q_Score":0,"Tags":"python-3.x,cplex,docplex","A_Id":62829763,"CreationDate":"2020-07-09T18:56:00.000","Title":"IBM cplex ilog VS docplex 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 string: \"s = string.charAt (0) == 'd'\"\nI want to retrieve a tuple of ('0', 'd')\nI have used: re.search(r \"\\ ((. ?) \\) == '(.?)' && \",\" string.charAt (0) == 'd' \")\nI checked the s variable when printed as \"\\\\ ((.?) \\\\) == '(.?) '&& \"\nHow do I fix it?","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":133,"Q_Id":62822136,"Users Score":-1,"Answer":"Thanks everyone for the very helpful answer. My problem has been solved ^^","Q_Score":1,"Tags":"python,regex,string","A_Id":62829246,"CreationDate":"2020-07-09T19:18:00.000","Title":"The problem of regex strings containing special characters in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"With a program, I am producing an SVG image with dimensions of 400px x 400px. However, I would like to crop the bottom of this SVG image off, based off of a variable that dictates how much of the bottom of the image should be cropped in pixels.\nThis SVG image is being generated with pyCairo with surface = cairo.SVGSurface(\"output.svg\", WIDTH, HEIGHT) and ctx = cairo.Context(surface).\nAlthough the HEIGHT variable is a constant and isn't changed, after I perform some operations on the surface object, I would like to be able to resize it once more. I can use the Pillow Image object to crop PNGs, but it does not support SVGs.\nI have also tried to open the svg file with open(\"output.svg\"). However, if I try to read it, I am unable to and it shows up as blank, thus making it unmodifiable.\nIs there any way in Python to either crop an SVG image or modify its size after it has been modified with pycairo?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":939,"Q_Id":62823182,"Users Score":1,"Answer":"You cannot crop SVG like you crop PNG because in the latter you can just drop pixels, while for the former you have defined paths that can't be easily recomputed.\nIf you're sure there's nothing in the part you are about to \"crop\", you can use set_context_size to make the svg context\/canvas smaller while preserving ratio and size inside.","Q_Score":1,"Tags":"python,svg,python-imaging-library,pycairo","A_Id":62823298,"CreationDate":"2020-07-09T20:27:00.000","Title":"How can you crop an SVG Image in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting the error Recursion Error: maximum recursion depth exceeded while calling a Python object. I have used the sys library and have set the max recursion length to be beyond the default 500 with no success.\nI am using python 3.7 and pyinstaller 3.6, I do use a depreciated function call from a non-pandas library, could this be the issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":62823696,"Users Score":0,"Answer":"I ended up setting the recursion maximum to an extremely high number of around 10,000 and the program was able to be compiled into an executable by pyinstaller. To me this is very alarming and points at some internal problems but I am testing how many pandas commands need to be invoked before the default 500 recursion step max is surpassed.","Q_Score":0,"Tags":"python,pandas,pyinstaller","A_Id":62824088,"CreationDate":"2020-07-09T21:04:00.000","Title":"Error When Running Pyinstaller with a pandas program Limited workspace authority","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to scrape data from a mobile application (Pokemon HOME). The app shows usage statistics and other useful statistics that I want to scrape. I want to scrape this on my computer using python.\nI am having trouble determining how to scrape data from a mobile application. I tried using Fiddler and an Android emulator to intercept server data but I am unfamiliar with the software to be able to understand what exactly to do.\nAny help would be very beneficial. Even just suggestions for resources where I can learn how to do this on my own. Thank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1891,"Q_Id":62824513,"Users Score":0,"Answer":"It's possible but it's really a hard nut to break. There's a huge difference between Mobile app and web app\nWeb app is accessible through WAN ,v.i.z World area network. Scraping is fairly and squarely easier.\nIn Python, you can bs4 to do it.\nBut in Mobile app, essentially and effectively, it's more about LAN.\nIt's installed locally.\nInstall an app to remote control your device from another device (usually required root)\nHowever, whole data might not be available.","Q_Score":0,"Tags":"python,web-scraping,mobile,fiddler,scrape","A_Id":62824677,"CreationDate":"2020-07-09T22:14:00.000","Title":"How do I use external applications to scrape data from a mobile app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I checked multiple sources but couldn't pinpoint this particular problem although it probably has a very easy fix.\nLet's say I have some graph, g.\nI am able to print the vertices using g.vertices.show()\nBut I'm having a lot of trouble figuring out how to load all the vertices into a dataframe of some sort. I want to do a variety of tasks that are well supported on Pandas. Does anyone have a way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":402,"Q_Id":62825021,"Users Score":0,"Answer":"Just like how .show() will display the results of any query, you can do .toPandas() which will convert the output to a pandas DataFrame. As far as I can tell, this command couples any command that you can couple .show() with.\nSo for my specific question:\ng.vertices.toPandas() solves the problem.","Q_Score":1,"Tags":"python,pandas,apache-spark,graphframes","A_Id":62840761,"CreationDate":"2020-07-09T23:07:00.000","Title":"Convert GraphFrame output to a pandas DataFrame","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The most popular python version is CPython, written in C. What i want to know is how is it possible to write a python collection using C when C arrays can only store on type of data at the same time?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":62825204,"Users Score":0,"Answer":"This is not how python does it in C, but I've written a small interpreted language in Java (which also only allows arrays\/lists with 1 data type) and implemented mixed type lists. I had a Value interface and a class for each type of value and those classes implemented the Value interface. I had FunctionValue class, a StringValue class, a BooleanValue class, and a ListValue class, all of which implemented the value interface. The ListValue class has a field of type List<Value> which contains the list's elements. All methods on the Value interface and its implementing classes which do stuff like numeric addition, string appending, list access, function calling, etc. initially take in Value objects and do different things based on which actual kind of Value it is.\nYou could do something similar in C, albeit at a lower level since it doesn't have interfaces and classes to help you manage your types.","Q_Score":0,"Tags":"python,arrays,c","A_Id":62825453,"CreationDate":"2020-07-09T23:28:00.000","Title":"How does python collections accept multiple data types?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a file with a list of UUIDs for Assets (9000+) in my company. Now the basic task is importing that file into a list of UUID so that my program can loop and check if a number of other UUIDS match.\nNow the question is, would using a bloom filter for the initial list allow me to do a quick search with the second list. would a bloom filter introduce any use in this case?\na) Learning bloom filters is something I want to do\nb) would 9000+ Items in an array (list, dict) which I would need to loop through be efficient?\nMany Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":338,"Q_Id":62827441,"Users Score":0,"Answer":"A bloom filter would help you eliminate UUIDs that are not present in your list before searching. This can be useful if your lookup is otherwise very expensive. However a dictionary lookup is very fast due to hashing and using a bloom filter in this case likely won't net you much of an improvement.","Q_Score":0,"Tags":"python,arrays,list,bloom-filter,bloom","A_Id":62827477,"CreationDate":"2020-07-10T04:39:00.000","Title":"Will using a bloom filter be faster than searching a dictionary or list 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":"What are the different ways to automate the AWS Glue workflow, I've data in AWS S3,now I've to automate the AWS Glue workflow (that does the Amazon Forecast and write back the results to AWS S3)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":363,"Q_Id":62827456,"Users Score":1,"Answer":"You can add a trigger in the aws workflow which provides you with three options\n\nUsing Events as a trigger, where events can be any cloudwatch event. So you can setup something like as soon as file arrives in s3 trigger the workflow.\nUsing time based schedule,, this will trigger the job at the desired time on the desired interval.\nOn demand, trigger the workflow whenever required.\n\nAlternatively you can also use step functions to automate your glue jobs.","Q_Score":0,"Tags":"python-3.x,amazon-web-services,amazon-s3,aws-glue,amazon-forecast","A_Id":62828920,"CreationDate":"2020-07-10T04:41:00.000","Title":"Automate the AWS Glue workflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have done my Dialogflow voice conversation chatbot using python, But currently I am running the conversation chatbot using loop. So my conversation is running till the loop end. The cloud is developed by using webhook and dialogflow intent.\nSo how can I end the conversation once the chat is end in cloud to end notification in python application.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":213,"Q_Id":62827534,"Users Score":0,"Answer":"I have added the following print in my python code, so there I have got the end_conversation intent, below I added the end_conversation log.\nprint('Fulfillment text: {} \\n'.format(query_result))\nEnd conversation log:\nintent_detection_confidence: 1.0\ndiagnostic_info {\nfields {\nkey: \"end_conversation\"\nvalue {\nbool_value: true\n}\n}","Q_Score":0,"Tags":"python-requests,dialogflow-es","A_Id":62949215,"CreationDate":"2020-07-10T04:51:00.000","Title":"How the dialogflow voice chatbot end conversation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a good solution to implement a handshake between a python backend server and a react frontend connected through a websocket.\nThe frontend allows the user to upload a file and then send it to the backend for processing. Now it might be possible that the processing encounters some issues and likes the user's confirmation to proceed or cancel - and that's where I'm stuck.\nMy current implementation has different \"endpoints\" in the backend which call then different function implementations and a queue which is continuously processed and content (messages) is sent to the frontend. But these are always complete actions, they either succeed or fail and the returned message is accordingly. I have no system in place to interupt a running task (e.g. file processing), send a request to the frontend and then wait for response before I continue the function.\nIs there a design pattern or common approach for this kind of problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":62828807,"Users Score":0,"Answer":"How long it takes to process? Maybe a good solution is set up a message broker like RabbitMQ and create a queue for this process. In the front-end you have to create a panel to see the state of the process, which is running in an async task, and if it has found some issues, let the user know and ask what to do.","Q_Score":0,"Tags":"python,reactjs,websocket,system-design","A_Id":62829294,"CreationDate":"2020-07-10T06:54:00.000","Title":"Interupt backend function and wait for frontend response","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Edit : My database is now connected I uninstalled and reinstalled the mysql-connector using anaconda prompt\nPreviously it was Bad Handshake\nand then later ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)\ni reinstalled a different version of sql and now it says\nAttributeError: module 'mysql.connector' has no attribute 'connect'","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":62828882,"Users Score":0,"Answer":"Attribute error is coming from an out of date package missing an attribute.\nTry running:\npip install mysql-connector-python","Q_Score":0,"Tags":"python,mysql,database,mysql-python","A_Id":62829050,"CreationDate":"2020-07-10T06:59:00.000","Title":"I'm having different errors while trying to connect python to mysql","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Edit : My database is now connected I uninstalled and reinstalled the mysql-connector using anaconda prompt\nPreviously it was Bad Handshake\nand then later ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)\ni reinstalled a different version of sql and now it says\nAttributeError: module 'mysql.connector' has no attribute 'connect'","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":62828882,"Users Score":0,"Answer":"The firewall of your server may not be turned off\n1.1 If it is CentOS 7, you can use systemctl stop firewalld to temporarily turn off the firewall to solve the problem\nHave you authorized a mysql user who can log in remotely\n2.1 You can also use the authorization statement grant all on . to \"USERNAME\"@\"%\" identified by \"PASSWORD\" in mysql\n\n\u5e0c\u671b\u4f60\u80fd\u770b\u61c2\uff0c\u6211\u4e5f\u4e0d\u77e5\u9053\u8fd9\u4e2a\u7ffb\u8bd1\u51c6\u786e\u4e0d\u51c6\u786e\uff0c\u795d\u4f60\u597d\u8fd0","Q_Score":0,"Tags":"python,mysql,database,mysql-python","A_Id":62829039,"CreationDate":"2020-07-10T06:59:00.000","Title":"I'm having different errors while trying to connect python to mysql","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"SQLalchemy is two packages in to one; Core & ORM. ORM is built on top of SQLalchemy.\nFor example, I\u2019m receiving data from an API and I\u2019m inserting it in to a SQL database via SQLalchemy. Should I use Core or ORM?\nWhen is it best to use one over the other?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":583,"Q_Id":62830345,"Users Score":0,"Answer":"Its mostly preference, but its possible that SQLAlchemy might (or already did?) deprecate Core at some time in the future. (They are deliberately ambiguous about it I guess)\nIf you're mostly using raw sql, it seems that SQLAlchemy is simpler and more straight-forward to implement.\nIf you wanna fiddle around all day with Models, Schemas, Classes, ModelSerializers and abstract everything and never deal with raw query statements again, you should probably go with ORM. But I think its too much busywork, especially if you are proficient at the sql language anyway.","Q_Score":2,"Tags":"python,sql","A_Id":62837453,"CreationDate":"2020-07-10T08:35:00.000","Title":"When to use SQLalchemy core vs SQLalchemy ORM?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made some program by Python 3.7 and generated an exe file using pyinstaller.\nThe exe file worked fine, but the problem occurred when I uploaded it on google drive to distribute to other users.\nWhen I download the program from google drive, the exe file does not work.\nTo be exact, it actually runs only on background. Since I made GUI for this program, it must show window GUI but it doesn't.\nEven I have same problem when I run the program which is downloaded from google drive.\nWhat is the problem? and what should I do?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":360,"Q_Id":62830392,"Users Score":0,"Answer":"You said the file downloaded from Google Drive doesn't work as the one you directly generated. I have a little trouble believing that Google drive modifies your file, you can nevertheless do the test by comparing the checksum. Does the checksum of your file change when you upload it to google drive? If this is the case try to go through another platform.","Q_Score":0,"Tags":"python,pyinstaller","A_Id":62830473,"CreationDate":"2020-07-10T08:37:00.000","Title":"exe file generated by pyinstaller does not work when downloading from google drive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made some program by Python 3.7 and generated an exe file using pyinstaller.\nThe exe file worked fine, but the problem occurred when I uploaded it on google drive to distribute to other users.\nWhen I download the program from google drive, the exe file does not work.\nTo be exact, it actually runs only on background. Since I made GUI for this program, it must show window GUI but it doesn't.\nEven I have same problem when I run the program which is downloaded from google drive.\nWhat is the problem? and what should I do?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":360,"Q_Id":62830392,"Users Score":0,"Answer":"I solved the problem myself.\nThe problem is that uploading exe file itself.\nWhen I made a zip file for exe and uploaded it, the exe file worked fine.","Q_Score":0,"Tags":"python,pyinstaller","A_Id":62830880,"CreationDate":"2020-07-10T08:37:00.000","Title":"exe file generated by pyinstaller does not work when downloading from google drive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the range of numbers which could be assigned to a word while customizing the Vader sentiment package. In customization, I wanted to add more words and assign them the sentiment score.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":62832100,"Users Score":0,"Answer":"The value ranges from -4 to 4. It would be helpful when you would be customizing the package by adding newer words.","Q_Score":0,"Tags":"python,nlp,sentiment-analysis,vader","A_Id":62895965,"CreationDate":"2020-07-10T10:13:00.000","Title":"Range of values for individual words which could be given in Vader while customizing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a .py file saved on my desktop. How do I upload this on Github and also ensure that changes I make to this file on Spyder are saved on Github too?\nPlease can you answer step by step if possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1287,"Q_Id":62832719,"Users Score":0,"Answer":"Place or replace your file in directory witch you got from github.\nOpen whole directory in VScode\nIn terminal type:\n\ngit add *\ngit commit -m \"YOUR COMMENT\"\ngit pull origin master\ngit push origin master\n\n\n\nPS. - Don't forget to download git.\nPSS. - I also recommend use TortoiseGit because it is easier (just right click on file and commit)","Q_Score":0,"Tags":"python,github,spyder","A_Id":62833313,"CreationDate":"2020-07-10T10:50:00.000","Title":"How do I save and edit a .py file in Github","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that scans a stock market for transactions and saves them in the SQL database. The script works on its own if I run it directly python3 fetchTradesLuno24Hours.py and this updates the database. However, if I run it as a service it stops updating the database. If I run systemctl status lunoDatabase.service it shows that service successfully run. The service is triggered by lunoDatabase.timer that runs it every several hours. If I run systemctl status lunoDatabase.timer or systemctl list-timers I see that the timer works and the script is triggered successfully. The service reports that the python script run-time is as expected (around 6 minutes) and the code exited successfully.\nBefore I tried running python script in the infinite loop and that worked fine and the database was updated correctly from the service. When I added timer it stopped updating the database. I would like the service to update the SQL database and to be trigger by the timer. How can I fix that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":134,"Q_Id":62832806,"Users Score":0,"Answer":"The problem was in the python script. Since I address the python file from the root folder, I should have specified the absolute path the database in database.py.\ndb = sqlite3.connect('home\/user\/bot\/transactions.db')\nand not\ndb = sqlite3.connect('transactions.db')\nThank you, everyone!","Q_Score":0,"Tags":"python,sql,linux,sqlite","A_Id":62834647,"CreationDate":"2020-07-10T10:55:00.000","Title":"Linux Service running Python script does not update SQL database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to Python.\nI'm using Spyder 4.0.1, Python 3.7.\nThe Spyder built-in PEP-8 convention code style check returns error E501 (line too long). Although I set the vertical line and wrap lines, it still shows error for the long characters line. Pycharm would wrap lines automatically, but I cannot find any effective solution in Spyder.\nWhat should I do? Do I have to press Enter manually for the long line? Thanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9719,"Q_Id":62836628,"Users Score":0,"Answer":"To turn on the Word Wrap feature, go to View > Toggle Word Wrap or click the Edit Display icon in the Code Editor toolbar (it's the second-to-last one on the right) and select Toggle Word Wrap. You can also set the program preferences to keep this feature on by default.","Q_Score":9,"Tags":"python,spyder,pep8","A_Id":62836755,"CreationDate":"2020-07-10T14:37:00.000","Title":"How to wrap lines automatically in Python Spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to read multiple tab delimited files (.tab) using pandas, and all files contain 250 rows and varying number of columns (more than 1). Some of the resulting data frames have expected number of rows and columns. However, in some of them all columns are recognized as a single column. Those data frames have expected number of rows, but only one column. I checked if the problematic documents have any unexpected line breaks or separators (or absence of thereof) and I wasn't able to find anything different from the 'good' documents. Does anyone have any ideas what could be happening?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":62838552,"Users Score":0,"Answer":"Apparently, there was an extra line on the top of some documents I was trying to open. After checking all data frames and using a skiprow argument while reading files, everything worked fine.","Q_Score":0,"Tags":"python,pandas","A_Id":62962823,"CreationDate":"2020-07-10T16:28:00.000","Title":"Pandas doesn't recognize columns in a document","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a really simple tool in Python.\nI have a list, a very large list (about 5GB) in a .csv, of raffle numbers.\nFor whatever reason I cannot get Pandas or even regular SQL Databases to convert this list to a table and then randomly select a number (trying to select a random winner)\nSo it was suggested that I break up the .csv into chunks with code (so far I have no way to even open the list).\nThe main question is, how random will be effected if I do this? Lets say it breaks it into 5 chunks, and then I am asking it to select a random row of data from ANY of those five chunks. Does the random outcome actually show a 100% random row of data, or is this effected by having to run random on both levels.\nI.E. - Randomly select one of these five chunks, then randomly select a number from within them.\nIf I do it that way, isn't that effecting how truly random it is? Or am I just losing my mind thinking about the statistics around it?\n(Bonus question, I still have not even figured out a clear way to get it to break up the csv into manageable chunks, so any tips there would be extra awesome!)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":62840194,"Users Score":3,"Answer":"The following two scenarios are equivalent:\n\nPick a card from a deck at random\nPick a suit from {clubs,hearts,spades,diamonds} at random and then pick a card from that suit.\n\nBut, the following are not equivalent:\n\nPick a card at random\nPick a category from {face cards, non-face cards} at random and then pick a card from that category at random, since that would over-sample face cards.\n\nMoral of the story: you will be okay as long as the chunks are of equal size. Otherwise, you will over-sample the smaller chunks.","Q_Score":0,"Tags":"python,csv,random,large-files","A_Id":62840360,"CreationDate":"2020-07-10T18:21:00.000","Title":"How random is a random row from random chunks of data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm doing this python basics course and my final project is to create a card game. At the bottom of the instructions I get this\n\nFor extra credit, allow 2 players to play on two different computers that are on the same network. Two people should be able to start identical versions of your program, and enter the internal IP address of the user on the network who they want to play against. The two applications should communicate with each other, across the network using simple HTTP requests. Try this library to send requests:\n\n\nhttp:\/\/docs.python-requests.org\/en\/master\/\n\n\nhttp:\/\/docs.python-requests.org\/en\/master\/user\/quickstart\/\n\n\nAnd try Flask to receive them:\n\n\nhttp:\/\/flask.pocoo.org\/\n\n\nThe 2-player game should only start if one person has challenged the other (by entering their internal IP address), and the 2nd person has accepted the challenge. The exact flow of the challenge mechanism is up to you.\n\nI already investigated how flask works and kind of understand how python-requests works too. I just can't figure out how to make those two work together. If somebody could explain what should I do or tell me what to watch or read I would really appreciate it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":195,"Q_Id":62841949,"Users Score":0,"Answer":"it would be nice to see how far you've come before answer (as hmm suggested you in a comment), but i can tell you something theorical about this.\nWhat you are talking about is a client-server application, where server need to elaborate the result of clients actions.\nWhat i can suggest is to learn about REST API, that you can use to let client and server to communicate in a easy way. Your clients will send http requests to server exposed APIs.\nFrom what you wrote, you have a basically constraints that should be respected during client and server communication, here reasumed:\n\nSomeone search for your ip and send you a challenge request\n\nYou have received a challenge that you refuse or accept; only if you accept the challenge you can start the game\n\n\nAs you can see from the project specifications the entire challenge mechanism is up to you, so you can decide the best for you.\nI would begin start thinking to a possible protocol that make use of REST API to start initial communication between client and server and let you define a basic challenge mechanism.\nEnjoy programming :).","Q_Score":0,"Tags":"python,flask,python-requests,ip","A_Id":62848649,"CreationDate":"2020-07-10T20:37:00.000","Title":"Python same Network Card Game","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need a data structure to store positive (not necessarily integer) values. It must support the following two operations in sublinear time:\n\nAdd an element.\nRemove the largest element.\n\nAlso, the largest key may scale as N^2, N being the number of elements. In principle, having O(N^2) space requirement wouldn't be a big problem, but if a more efficient option exists in terms of store, it would work better.\nI am working in Python, so if such a data structure exists, it would be of help to have an implementation in this language.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":205,"Q_Id":62843016,"Users Score":2,"Answer":"There is no such data structure. For example, if there were, sorting would be worst-case linear time:  add all N elements in O(N) time, then remove the largest element remaining N times, again in total O(N) time.","Q_Score":0,"Tags":"python,algorithm,data-structures","A_Id":62843062,"CreationDate":"2020-07-10T22:15:00.000","Title":"Insert and get max from structure in constant time","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently learning KIVY in Python and trying to figure out how to freely choose position of an element such as label and buttons, like in Tkinter you can use relx and rely to choose excact position. Do anyone know if that is possible in KIVY?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":22,"Q_Id":62843150,"Users Score":1,"Answer":"Just set the pos and size to what you want. If the parent is something like a FloatLayout, also set the size_hint to None, None to avoid the layout automatically resizing it.","Q_Score":0,"Tags":"python,kivy","A_Id":62843168,"CreationDate":"2020-07-10T22:29:00.000","Title":"Python KIVY module how to change positions of buttons, labels etc freely using x axis and y axis instead of grids","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Anaconda installed with 1 environment only base\nI ran conda update -c anaconda --all and I think it's downloading all packages from scratch?!?!\nIt's taking more than 15-20 mins already. Did I do something wrong? I just wanted to update those packages which needed to be updated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":62,"Q_Id":62843640,"Users Score":1,"Answer":"conda update - update packages\n-c - Additional channel to search for packages. If not there, ignores this option\n--update-all, --all   Update all installed packages in the environment.\nWhen you do --all it updates all the packages in the activated environment.\nIf you want to update specific packages then use the following command\nconda update scipy\nIn order to find which all packages are outdated - conda search --outdated","Q_Score":0,"Tags":"python,python-3.x,anaconda,anaconda3","A_Id":62843680,"CreationDate":"2020-07-10T23:36:00.000","Title":"Anaconda update downloads all packages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a website for work and I need to go through a list of numbers and determine if the user associated with the number is still active. The website requires a sign in so I can't use requests. Is there a way I can run it through my chrome browser to get the information I require?\nIf I can get the HTML then I am fine from there onward with the code.\nAny help would be greatly appreciated","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":62844688,"Users Score":0,"Answer":"Can I have the webpage you are trying to access?","Q_Score":0,"Tags":"python,python-3.x,web-scraping","A_Id":63064700,"CreationDate":"2020-07-11T02:49:00.000","Title":"Is there a way to get HTML text through python and a web browser?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Several times when working with a Jupyter Notebook on Visual Studio Code, the cell will get stuck at the [*] reading. It is impossible in this state to save my progress. This is happening in two different windows machines.\nIn both machines I tested, I'm using Python 3.8.2 32-bit on Visual Studio Code 1.46.1, on a Windows 10 PC with a core i5 processor desktop and 8 gb ram.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3653,"Q_Id":62846366,"Users Score":0,"Answer":"It means that your kernel is still running. You can manually stopping the kernel by pressing the stop button above, or Ctrl+Shif+P, Python: Interrupt IPython Kernel.\nIf it doesn't work, try closing and reopening it.\nThe problem may also be the error of your code. See if there is an infinite loop within the kernel.","Q_Score":3,"Tags":"python,visual-studio-code,jupyter-notebook","A_Id":62890004,"CreationDate":"2020-07-11T07:27:00.000","Title":"Visual Studio Code crashes constantly when working with jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When we start a new project, we are provided with a urls.py file. However, when we create apps within our project, Django doesn't provide the urls.py file for us and we are expected to create it manually. What is the exact logic\/reason behind that? Are there even apps that don't necessarily have to have urls.py file?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1119,"Q_Id":62846380,"Users Score":6,"Answer":"First you have your project urls.py. This file is the starting point for django to look up if a certain url path exists.\nWhen you use more than one app you normally tell django to look up their urls.py files after the project urls.py. So in this case creating a app-related urls.py makes sense in order to overview the entire url structure of your project divided into your apps.\nWhen you use only one app it is actually not neccessary to have an app-related urls.py file because you dont have to bother about the entire url structure. You only use one app so the url is related to that app.\nNormally you create a urls.py file even if you only have one app. This can have multiple reasons. But django lets you make this choice. First you dont know if you will add more apps in the future so you better already create a tidied up file structure from the beginning. Second because of the model-view-controller (django actually has a model-view-template structure) built-up you want to keep your views, models and paths together. It is much more cleaner and will help you in case your project grows up.\nHope it gets a little clearer and helps you a little bit.","Q_Score":5,"Tags":"python,django,url","A_Id":62846568,"CreationDate":"2020-07-11T07:29:00.000","Title":"Why Django doesn't provide a urls.py file for apps?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"print('\\f') outputs \u2640 (female symbol) and print('\\v') outputs \u2642 (male symbol). Since these symbols are\nnot part of the ASCII characters, why does python output them?\nBonus question: I get why '\\f' is the female symbol, but why is '\\v' the male?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":515,"Q_Id":62848326,"Users Score":1,"Answer":"\\f stands for Form Feed while \\v stands for Vertical Tabulator.\nThese are included because they are included with your font. There is also \\t, \\r and \\n.","Q_Score":0,"Tags":"python,symbols","A_Id":62848392,"CreationDate":"2020-07-11T11:03:00.000","Title":"what is the purpose of these symbols in Python? \u2640 \u2642","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use PostgreSQL as my database in my Django project(my os is windows). I can't run PostgreSQL's commands in the command prompt while venv is activated and out of venv I have access to those commands because I've added PostgreSQL bin directory path to the PATH environmental variable. How can I do this with virtualenv so I can run those commands inside virtualenv?\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":200,"Q_Id":62849692,"Users Score":0,"Answer":"you can open a second cmd\nand use it for Postgre","Q_Score":0,"Tags":"django,windows,postgresql,python-venv","A_Id":62849993,"CreationDate":"2020-07-11T13:20:00.000","Title":"PostgreSQL commands not working in virtualenv","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Somehow after 10 minutes supervisord stops processing. Processes still on the background but not working anymore. We need to kill the processes first before supervisord starts processing again. Our work around is to add a cron job to kill all supervisord processes every 10 minutes. Is there a way to fix this issue in supervisord so we would not kill processes anymore?\nSupervisord version: 3.4.0\nPython version: 2.7.5\nCentos 7 OS","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":62849717,"Users Score":0,"Answer":"I found the main problem. In our code we added a $messenger->wait(3600) which turns out to be where process hungs because supervisord is waiting for a return or and exit. What we did was to make the wait lower to 500 and added exit(0) after it. Seems like supervisord in Centos 7 will have an issue if scripts does not do a clear exit. On Centos 6 we did not encounter the issue.","Q_Score":0,"Tags":"python,linux,centos,centos7,supervisord","A_Id":62993446,"CreationDate":"2020-07-11T13:23:00.000","Title":"Supervisord Stops Hangs\/Hungs on the Background after 10 minutes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm writing installer for my program with python.\nWhen everything is extracted, how can i make my program .exe file to run with Windows startup?\nI want to make it fully automatic, without any user input.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":195,"Q_Id":62850142,"Users Score":0,"Answer":"You don't need to use Python for this. You can copy your .exe file and paste it in this directory:\n\nC:\\Users\\YourUsername\\AppData\\Roaming\\Microsoft\\Windows\\Start\nMenu\\Programs\\Startup\n\nIt will run automatically when your computer starts.","Q_Score":0,"Tags":"python,windows","A_Id":62850170,"CreationDate":"2020-07-11T14:03:00.000","Title":"Putting .exe file in windows autorun with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How would one check the number of \"active users\", i.e. number of users having the web page open in browser at any given time in a Dash web application?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":487,"Q_Id":62854394,"Users Score":0,"Answer":"There are a number of ways to achieve this.\nFirstly the more robust approach would be to leverage the auth service you probably already setup so that users are correctly permissioned (a request to a token service would identify each user). After this you can record the initial site load by inserting an entry into a backend database.\nYou don't need to use an auth service of course you could just record the users IP address and insert into the database\nIf you wanted to know who is using your web app at any given time then one approach would be to add an interval timer callback which would add these entries to the database along with the access time","Q_Score":3,"Tags":"python,web-applications,plotly-dash","A_Id":62859400,"CreationDate":"2020-07-11T20:44:00.000","Title":"How to check number of active users in Dash app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In python3.8, what's the difference between ImportError and ModuleNotFoundError? I'm just wondering what the difference is and why they matter.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1990,"Q_Id":62854761,"Users Score":4,"Answer":"According to the python docs:\n\nThe ImportError is raised when an import statement has trouble\nsuccessfully importing the specified module. Typically, such a problem\nis due to an invalid or incorrect path, which will raise a\nModuleNotFoundError in Python 3.6 and newer versions.","Q_Score":8,"Tags":"python,python-3.x,python-import","A_Id":62854769,"CreationDate":"2020-07-11T21:25:00.000","Title":"Python3.8: What's the difference between ImportError and ModuleNotFoundError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a python script that generates a list of integers and is supposed to send this list to a concurrently running C++ program that is constantly awaiting input. What is a quick and painless way to design the link between these two languages?\nI have considered possibilities such as:\n\nwriting the python result to a file, while listening for file updates in C++ and loading it as soon as new data is available.\nusing python pexpect package and including a command line interface in the C++ program, so that it receives the data through cin.\n\nBoth above possibilities seem a bit too hacky to me. Are there better options, which would not require to become an expert in C++ library coding for python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":62855721,"Users Score":1,"Answer":"You could set up a Socket and an OutputStream in the python app to send the data, and another Socket and an InputStream in the C++ program to receive the data.","Q_Score":1,"Tags":"python,c++,data-transfer","A_Id":62855860,"CreationDate":"2020-07-11T23:45:00.000","Title":"How to send python list to C++ application awaiting input?","Data 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 error occurred while installing latest Ruby using ruby-install.\nWhat I tried:\nbrew switch openssl <my_version>\nbrew upgrade openssl\nAnd many other solutions that were proposed in SO. None solved my problem.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":62857132,"Users Score":0,"Answer":"So the problem is actually coming that python2 is not supported, but you can solve it by installing just correct openssl via brew, e.g.\nbrew install openssl@1.1","Q_Score":0,"Tags":"python,openssl,homebrew,python-2.x","A_Id":71038397,"CreationDate":"2020-07-12T04:37:00.000","Title":"Python\/OpenSSL issue: ERROR:root:code for hash md5 was not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to build my first website, a little RP game to play in school. It is a hero who plays an adventure and must make the right decisions.\nIn my program I have a model for each component: hero, NPC, trap, obstacle, closure ... all of which have a generic relation with an Interaction class.\nIt would be simpler for me to have only a global interaction class which includes all the necessary attributes. In each instance it would suffice for me to specify what type of interaction it is and to fill in only the attributes concerned.\nBut then I will end up with instances containing most of the time many empty fields.\nIs it a problem? Bad practice?\nThx !","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":62858018,"Users Score":0,"Answer":"Yes it is not a good idea. Because each time you make an instance from your class it reserve that much memory even if you don't fill all the fields and in the long term your app performance will decrease.","Q_Score":0,"Tags":"python,django","A_Id":62858332,"CreationDate":"2020-07-12T06:57:00.000","Title":"Model that combines all the attributes (which will sometimes be useless) or several small models?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've been learning C++ recently and wondering whether it is possible to convert a .py file to .bin file just like we compile C++ to .bin in Linux.\nI found pyInstaller to convert it to exe file but what I need is to export it to a .bin file just like we get when we perform g++ test.cpp -o a.out or a.bin etc.\nAny help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":416,"Q_Id":62862874,"Users Score":2,"Answer":"The shortest answer is no, because python needs it engine in order to interpret your code.\nThe longer answer is yes but not exactly.\nLike you said there are solutions like py to exe or py to elf and many other solutions in order to make your python script run as a native executable.\nMost of these solution pack the parts of python your code need and the code itself so you won't need python installed on the machine running the code.\nYou cannot just compile python like you are doing with C++ because it is an interpreted language.\n(There are other ways to \"compile\" python like R-python, but it's not exactly regular python and are more complex)\nAnd finally about the file extension:\n\nif you are running on linux the extension doesn't matter because the OS checks the type of the file before running it.\nif you are running on windows the extension does matter, but .bin files won't run on your system. If you want to run a program on you system it need to be in PE (portable executable) format- i.e- .exe (programs), .dll (libraries) or .sys (drivers).","Q_Score":0,"Tags":"python,python-3.x","A_Id":62862996,"CreationDate":"2020-07-12T15:18:00.000","Title":"Is there any way to convert a .py file to .bin file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When installing python modules, I seem to have two possible command line commands to do so.\npip install {module}\nand\npy -{version} -m pip install {module}\nI suppose this can be helpful for selecting which version of python has installed which modules? But there's rarely a case where I wouldn't want a module installed for all possible versions.\nAlso the former method seems to have a pesky habit of being out-of-date no matter how many times I call:\npip install pip --upgrade\nSo are these separate? Does the former just call the latest version of the latter?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":334,"Q_Id":62863584,"Users Score":0,"Answer":"So the pip install module is callable if you have already installed the pip. The pip install pip --upgrade upgrades the pip and if you replace the pip into a module name it will upgrade that module to the most recent one. the py -{version} -m pip install {module} is callable if you have installed many versions of python - for example most of the Linux servers got installed python 2, so when you install the Python 3, and you want to install a module to version 3, you will have to call that command.","Q_Score":1,"Tags":"python,python-3.x,pip","A_Id":62863619,"CreationDate":"2020-07-12T16:23:00.000","Title":"What's the difference between calling pip as a command line command, and calling it as a module of the python command?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When installing python modules, I seem to have two possible command line commands to do so.\npip install {module}\nand\npy -{version} -m pip install {module}\nI suppose this can be helpful for selecting which version of python has installed which modules? But there's rarely a case where I wouldn't want a module installed for all possible versions.\nAlso the former method seems to have a pesky habit of being out-of-date no matter how many times I call:\npip install pip --upgrade\nSo are these separate? Does the former just call the latest version of the latter?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":334,"Q_Id":62863584,"Users Score":3,"Answer":"TLDR: Prefer ... -m pip to always install modules for a specific Python version\/environment.\n\nThe pip command executes the equivalent of ... -m pip. However, bare pip does not allow to select which Python version\/environment to install to \u2013 the first match in your executable search path is selected. This may be the most recent Python installation, a virtual environment, or any other Python installation.\nUse the ... -m pip variant in order to select the Python version\/environment for which to install a module.","Q_Score":1,"Tags":"python,python-3.x,pip","A_Id":62864080,"CreationDate":"2020-07-12T16:23:00.000","Title":"What's the difference between calling pip as a command line command, and calling it as a module of the python command?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have raster (.tif) files for every four days interval (e.g. LAI.Day.2015.10.24.tif, LAI.Day.2015.10.28.tif, LAI.Day.2015.11.01.tif, LAI.Day.2015.11.05.tif, LAI.Day.2015.11.09.tif, so on). Is there any way to get daily raster files (e.g. LAI.Day.2015.10.24.tif, LAI.Day.2015.10.25.tif, LAI.Day.2015.10.26.tif, so on) using bilinear interpolations on the raster files having temporal resolution of four days?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":152,"Q_Id":62863807,"Users Score":1,"Answer":"I do not think bilinear interpolation applies to time as it applies to space. But you can interpolate. In R, you could use raster::calc with approx. See the regression example in calc.","Q_Score":1,"Tags":"python,r,raster,gdal","A_Id":62863877,"CreationDate":"2020-07-12T16:44:00.000","Title":"Bilinear Interpolation on rasters to create daily raster files","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"GridSearchCV and RandomizedSearchCV has best_estimator_ that :\n\nReturns only the best estimator\/model\nFind the best estimator via one of the simple scoring methods : accuracy, recall, precision, etc.\nEvaluate based on training sets only\n\nI would like to enrich those limitations with\n\nMy own definition of scoring methods\nEvaluate further on test set rather than training as done by GridSearchCV. Eventually it's the test set performance that counts. Training set tends to give almost perfect accuracy on my Grid Search.\n\nI was thinking of achieving it by :\n\nGet the individual estimators\/models in GridSearchCV and RandomizedSearchCV\nWith every estimator\/model, predict on test set and evaluate with my customized score\n\nMy question is:\n\nIs there a way to get all individual models from GridSearchCV  ?\nIf not, what is your thought to achieve the same thing as what I wanted ? Initially I wanted to exploit existing GridSearchCV because it handles automatically multiple parameter grid, CV and multi-threading. Any other recommendation to achieve the similar result is welcome.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":272,"Q_Id":62864193,"Users Score":1,"Answer":"You can use custom scoring methods already in the XYZSearchCVs: see the scoring parameter and the documentation's links to the User Guide for how to write a custom scorer.\nYou can use a fixed train\/validation split to evaluate the hyperparameters (see the cv parameter), but this will be less robust than a k-fold cross-validation.  The test set should be reserved for scoring only the final model; if you use it to select hyperparameters, then the scores you receive will not be unbiased estimates of future performance.\nThere is no easy way to retrieve all the models built by GridSearchCV.  (It would generally be a lot of models, and saving them all would generally be a waste of memory.)\nThe parallelization and parameter grid parts of GridSearchCV are surprisingly simple; if you need to, you can copy out the relevant parts of the source code to produce your own approach.\n\n\nTraining set tends to give almost perfect accuracy on my Grid Search.\n\nThat's a bit surprising, since the CV part of the searches means the models are being scored on unseen data.  If you get very high best_score_ but low performance on the test set, then I would suspect your training set is not actually a representative sample, and that'll require a much more nuanced understanding of the situation.","Q_Score":0,"Tags":"python,scikit-learn,cross-validation,grid-search,gridsearchcv","A_Id":62938603,"CreationDate":"2020-07-12T17:19:00.000","Title":"Get individual models and customized score in GridSearchCV and RandomizedSearchCV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a loading system in my game, and I need an if statement to decide whether or not the player should be able to load a game. I have decided that I can just read the size of my save file, and if it is not storing anything, stop the player from loading the game. How can I see the size of my file? I am using pickle to read and write the file.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":147,"Q_Id":62865796,"Users Score":3,"Answer":"os.path.getsize('filename') would do the trick","Q_Score":0,"Tags":"python,pickle","A_Id":62865827,"CreationDate":"2020-07-12T19:47:00.000","Title":"Find size in bytes of pickle file python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"why we should openfaas instead of lambda functions in AWS or other serverless functions by cloud service providers?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":76,"Q_Id":62866325,"Users Score":1,"Answer":"The idea is to avoid lock-in to a specific vendor. With Open Faas you can run wherever you want while AWS Lambda is tied to AWS.","Q_Score":0,"Tags":"python,amazon-web-services,azure,google-cloud-functions,openfaas","A_Id":62866524,"CreationDate":"2020-07-12T20:50:00.000","Title":"OpenFaas vs serverless functions provided by cloud service providers","Data Science and Machine Learning":0,"Database and SQL":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 the following OF to minimize the cost of supply chain:\nmdl.minimize(mdl.sum((cs+ch+cf+cv*d[j])*q[j] for j in arcs) + mdl.sum(\u03b1*(eh+et*d[j])*q[j] for j in arcs) + mdl.sum(\u03b2*(gh+gt*d[j])*q[j] for j in arcs) + mdl.sum(X[f]*cjf for f in comb))\nWhere cs, ch, cf, cv, eh, et, gh, gt, cjf, \u03b1 and \u03b2 are a series of constant parameters.\nd[j] is the distance between origin iand destination j that are combined in a list of arcs or tuples.\nq[j] is the flow variable between origin i and destination j in arcs.\nX[f] is a binary variable to open a facility in destination j with capacity f, the possible combinations  of j and f are listed in comb.\nThe first constraint 1 ensures the flow q[i,j] from origin i does not exceed its maximum availability of material dQ in i. D[(i, j)] is a binary parameter that is 1 if the distance between origin i and destination j is less or equal than a treshold value, else the value of D[(i, j)] is 0. (This parameter helps us to limit the transport distance.)\nfor i in I: mdl.add_constraint(mdl.sum(q[(i, j)]*D[(i, j)] for j in J) <= Qi[i])\nThe second constraint 2 ensures the flow q[i,j] to a destination j equals the capacity of the opened facility in destination j with capacity f.\nfor j in J: mdl.add_constraint(mdl.sum(q[(i, j)]for i in I) == mdl.sum(X[(j,f)] for f in F))\nBut then, we want another constraint 3 that ensures the sum of capacities f in the facilities opened at destinations j has to be as close as possible to the total demand of capacities E. Let's say there is an energy demand of 100 MW E = 100, then we want to reduce the cost in OF of the supply but also make sure we reach the demand E. Otherwise minimizing the cost would be 0. This constraint can be formulated like:\nmdl.add_constraint(mdl.sum(X[j,f]for j in J for f in F) == E)\nUnfortunately, this solution is never feasible. If we replace == by <= than it is feasible, but it is at minimal cost and the capacity is nowhere near maximal.\nWe don't need this to be a strict constraint but we do wanna get as close to E as possible, by opening multiple facilities at destinations j with different capacities f. (Eg. we could have one destination with 20 MW, one at 5 MW, two at 30 MW and another at 15 MW to reach 100 MW by opening 5 destinations)\nOne way is to force the model to open N number of locations j, however, we have a set of 128 locations. To find the minimum cost and maximum capacity from a ranges of scenarios from N=1 to N=128 means we need to run this model 128 times.\nOn top of the above-mentioned constraint we have 3 additional constraints:\n\nWe can only select destination j to built a facility and open it at only one capacity f.\nThe sum of destinations j to open is greater than 0.\nThere is no negative flow q between origins i and destinations j\n\nIs there a way to:\n\nMake constraint 3 less binding, but still try to reach E while keeping the cost minimal?\nReformulate the OF to combine the minimized cost with the maximized capacity?\n\nImportantly we do not want to run the model 128 times. We want to model to select the destinations j to open a facility and select the capacity f accordingly, to minimize the overall cost of supply and maximize the installed capacity. In our case,e it would also be very unlikely to open just one destination j to satisfy all demand E. Instead we would have multiple j with smaller f capacity that approach E when summed.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":531,"Q_Id":62867607,"Users Score":0,"Answer":"This is 'multi-objective optimisation'. Two possible ways to achieve this are outlined below.\nFirst approach is to get a combined single objective function. This is easier if both terms are working in the same direction e.g. both are minimising terms. So for your 'constraint 3' try using a term in the objective for the shortfall relative to the demand, so the shortfall is something like:\nShortfall == E - mdl.sum(X[j,f]for j in J for f in F)\nThen add the shortfall into the objective, and use some weighting factors for the two terms, e.g.:\nw * Cost + (1-w) * Shortfall\nThen if w is one, you are just minimising the cost, while if w is zero, you are just minimising the shortfall. Of course, if you use a value for the weighting between zero and one, then you will get a balance of the two objectives. You will need to pay careful attention to the value of the weighting split between your two terms.\nA variation in this approach would be to give a much bigger weight to one term than the other, so that term dominates the objective. Then the solver will try to minimise that more important term (e.g. the shortfall), and the other term will help select the lower cost options for achieving that. In practice this often does NOT work as well as people expect - adding very large and very small terms in the objective can give rise to numerical issues in the solver, and often the real differences in the objective values of different solutions can get lost in the tolerances in the solver anyway. For example we have seen some people use relative weights of 1 million to one, while still using an optimality gap of 1e-6; in this case the second term effectively gets lost in the noise because many (perhaps very different) alternatives look almost the same to the solver and fall within the tolerances and so effectivley get ignored.\nThe second approach is 'lexical multi-objective' solving which is a little more complicated, but doesn't rely on some troublesome weighting factors. Effectively you need to solve your problem twice - once to find the maximum capacity that you can provide, and then fix that with a constraint in your second problem and minimise the cost of delivering that capacity.\nIn practice you might adjust this purist approach, and accept solutions in your second model that are close enough to achieving the maximum capacity. So for example you may fix the total capacity in your second model to be e.g. at least 99% of the calculated maximum capacity achievable from the first model. This reflects the cases where there are maybe only a few (expensive) ways to achieve the absolute maximum capacity, but there may be worthwhile savings if we explore solutions that are close to that maximum.\nNote that there are several solvers that provide ready-built support for multi-objective models using this 'lexical' approach which may avoid you explicitly solving the model twice for each case.","Q_Score":0,"Tags":"python,mathematical-optimization,cplex,docplex,docplexcloud","A_Id":62871035,"CreationDate":"2020-07-13T00:00:00.000","Title":"How to combine 2 constraints to minimise cost and maximise capacity using DOcplex.mp in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on a pre-existing python code-by-zapier zap. The trigger is \"Code By Zapier; Run Python\". I've made some changes to the contained python script, and now when I go to test that step I run into the following error message:\n\nWe couldn\u2019t find a run python\nCreate a new run python in your Code by Zapier account and test your trigger again.\n\nIs there any way of figuring out what went wrong?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":62867738,"Users Score":0,"Answer":"I'm guessing a little bit, but I think this issue stems from repeatedly testing an existing trigger without returning a new ID.\nWhen you run a test (or click the \"load more\" button), then Zapier runs the trigger and looks through the array for any new items it hasn't seen before. It bases \"newness\" on whether it recognizes the id field in each returned object.\nSo if you're testing code that changed, but is returning objects with previously seen ids, then the editor will error saying that it can't find any new objects (the can't find new run pythons is a quirk of the way that text is generated; think of it as \"can't find objects that we haven't seen before).\nThe best way to fix this depends on if you're returning an id and if you need it for something.\n\nYour code can return a random id. This means every returned item will trigger a Zap every time, which may or may not be intended behavior.\nYou can probably copy your code, change the trigger app (to basically anything else), run a successful test (which will overwrite your old test data), and then change it back to Code by Zapier and paste your code. Then you should get a \"fresh\" test. Due to changes in the way sample data is stored, I'm not positive this works now\nDuplicate the zap from the \"My Zaps\" page. The new one won't have any existing sample data, so you should be able to test normally.","Q_Score":0,"Tags":"python-3.x,zapier","A_Id":62905665,"CreationDate":"2020-07-13T00:23:00.000","Title":"How to troubleshoot \"We couldn\u2019t find a run 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 looking to build a system that alerts me when there's a package at my front door. I already have a solution for detecting when there's a package (tflite), but I don't know how to get the array of detected objects from the existing tflite process and then pull out an object's title through the array. Is this even possible, or am I doing this wrong?\nAlso, the tflite model google gives does not know how to detect packages, but I'll train my own for that","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":62868911,"Users Score":0,"Answer":"I've figured out a solution. I can just use the same array that the function that draws labels uses (labels[int(classes[i])) to get the name of the object in place i of the array (dunno if I'm using the correct terminology but whatever). hopefully this will help someone","Q_Score":0,"Tags":"python,python-3.x,tensorflow,object-detection,tensorflow-lite","A_Id":62883062,"CreationDate":"2020-07-13T03:40:00.000","Title":"how to get names of all detected models from existing tensorflow lite instance?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pandas dataframe that effectively contains several different datasets. Between each dataset is a row full of NaN. Can I split the dataframe on the NaN row to make two dataframes? Thanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":680,"Q_Id":62869058,"Users Score":0,"Answer":"Use df[df[COLUMN_NAME].isnull()].index.tolist() to get a list of indices corresponding to the NaN rows. You can then split the dataframe into multiple dataframes by using the indices.","Q_Score":3,"Tags":"python,pandas,numpy,dataframe","A_Id":62869145,"CreationDate":"2020-07-13T03:59:00.000","Title":"Can split pandas dataframe based on row values?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python 3.6 in my venv on PyCharm. However, I want to change that to Python 3.8. I have already installed 3.8, so how do I change my venv python version?\nI am on windows 10.\nChanging the version on the project intepreter settings seems to run using the new venv not my existing venv with all the packages I have installed. Attempting to add a new intepreter also results in the \"OK\" button being greyed out, possibly due to the current venv being not empty.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4857,"Q_Id":62869201,"Users Score":1,"Answer":"In pycharm you can do further steps:\n\nGo in File-->Settings-->Python Interpreter\nSelect different python environment if already available from the drop down, If not click on \"Add\".\nSelect New Environment option, then in Base interpreter you can select 3.8 version","Q_Score":2,"Tags":"python,python-3.x,pycharm,python-venv","A_Id":62869294,"CreationDate":"2020-07-13T04:19:00.000","Title":"Upgrading pycharm venv python version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm not expert. I have installed Anaconda Navigator and nothing more. Now for opening Jupyter Notebook, I simply open Anaconda Navigator and then open it.\nBut it takes a while.\nCould I simply open Jupyter in a more faster way?\nIf not, then could it be possible, if I install something more?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":62870753,"Users Score":1,"Answer":"Yes you can simply go to command prompt \/ anaconda prompt and type jupyter notebook","Q_Score":1,"Tags":"python-3.x,jupyter-notebook,anaconda","A_Id":62870804,"CreationDate":"2020-07-13T07:01:00.000","Title":"Launching jupyter notebook not from anaconda navigator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I Am using Scrapy with scrapySelenium but the scrapy selenium starts with a headless browser but for some purpose i need to start it with head so i can keep seeing what my scrapy does in the browser how to turn off headless arguments passed in settings of scrapy\nthis is what i copied in the settings it is headless as you can see but want to see the browser open up with Scrapy Selenium is there anyway\nfrom shutil import which\nSELENIUM_DRIVER_NAME = 'chrome'\nSELENIUM_DRIVER_EXECUTABLE_PATH = which('chromedriver')\nSELENIUM_DRIVER_ARGUMENTS=['-headles']  # '--headless' if using chrome instead of firefox","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1744,"Q_Id":62870900,"Users Score":2,"Answer":"Delete the SELENIUM_DRIVER_ARGUMENTS = ['--headless'] from the settings.py.\nWith selenium webdriver you can pass arguments and this argument makes sure that it is a headless browser.","Q_Score":1,"Tags":"python,selenium,selenium-webdriver,web-scraping,scrapy","A_Id":62872252,"CreationDate":"2020-07-13T07:13:00.000","Title":"How to use chrome driver with head in Scrapy Selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am creating virtual environment using virtualenv command.\nWhen I am opening a project folder in PyCharm through command line using below command.\npycharm \"project_folder_path\"\nIt opens project folder in PyCharm but not loading interpreter exist in project folder.\nError: No python Interpreter Configured for this project\nIs there any solution to load interpreter exist in project folder and configure automatically through python script.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":339,"Q_Id":62872304,"Users Score":0,"Answer":"You can configure the interpreter by going to File -> Settings -> Project - your_project -> Project Interpreter and choose the virtual environment that you created.","Q_Score":0,"Tags":"python,pycharm","A_Id":62872564,"CreationDate":"2020-07-13T08:46:00.000","Title":"No Python Interpreter Configured: When I open project folder in PyCharm using command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to connect a bluetooth device (ESP32, peripheral) with Web Bluetooth (central). I send an addvertising packet and I can see the device on the web page, but I fail to connect to it. My code for the ESP32 looks like this: (MicroPython)\nble.gap_advertise(interval_us=100, adv_data=bytearray(b'\\x02\\x01\\x06\\x06\\x08\\x45\\x53\\x50\\x33\\x32\\x11\\x07\\x26\\x6c\\x34\\x7f\\xb2\\x38\\x61\\x82\\xbe\\x4d\\x1d\\x64\\xf1\\xf7\\x93\\x16\\x02\\x19\\x80'),resp_data=None, connectable=True)\nIn Web Bluetooth (JavaScript) I just request a device and try to connect to the gatt.\nCan anyone help me out?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":62872924,"Users Score":0,"Answer":"The JavaScript does work with another bluetooth peripheral. (RN4678)\nAnd in JavaScript I can find the peripheral (ESP32) after filtering, but I can't connect to it.\nJavaScirpt:\nserver = await device.gatt.connect()\nThe code stops at that point.\nMicroPython:\nThe GATT is defined using:\nble.gatts.register.services() \nI'm trying to use my own service, not a SIG defined one. So I advertise b'(x...') which contains the flags, the service and the device name. And it works with the nRF Connect App. I can send and recive data. But it doesn't work with the bluetooth enabled web browser.\nThanks for your help!","Q_Score":0,"Tags":"bluetooth,esp32,micropython","A_Id":62876187,"CreationDate":"2020-07-13T09:25:00.000","Title":"Connecting to Web Bluetooth","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am very new to python, and I am trying to create a chatbot with python for a school project.\nI am almost done with creating my chatbot, but I don't know how to create a website to display it, I know how to create a website with Flask but how can I embed the chatbot code into the website?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":293,"Q_Id":62874661,"Users Score":0,"Answer":"In your flask code you can also embed the chatbot predict-functions into specific routes of your flask app. This would require following steps:\nJust before you start the flask server you train the chatbot to ensure its predict function works propperly.\nAfter that you can specifiy some more route-functions to your flask app.\nIn those functions you grab input from the user (from for example route parameters), send it through the chatbots predict function and then send the respons (probably with postprocessing if you wish) back to the requester.\nSending to the requester can be done through many different ways.\nTwo examples just of my head would be via display (render_template) to the webpage (if the request came in over GET-Request via usual browser site-opening request) or by sending a request to the users ip itself.\nAs a first hand experience i coupled the later mechanism to a telegram bot on my home-automation via post-request which itself then sends the response to me via telegram.","Q_Score":0,"Tags":"python,chatbot","A_Id":72057057,"CreationDate":"2020-07-13T11:13:00.000","Title":"How to embed my python chatbot to a website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using the teradatasql python package and i'm unable to find any documentation on how to pass named parameters into the cursor.execute()\nfor example:\nselect ?month_end_dt , ?month_begin_dt\nI'd like to be able to pass variables from a dictionary into the named parameters.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":269,"Q_Id":62875697,"Users Score":0,"Answer":"The teradatasql package does not support named parameters. It only supports unnamed question-mark parameter markers.","Q_Score":0,"Tags":"python,parameters,teradata","A_Id":62880653,"CreationDate":"2020-07-13T12:18:00.000","Title":"Teradatasql Python: Unable to pass Named Parameters into script","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had uninstalled python 3.8 from my system and installed 3.7.x\nBut after running the command where python and where python3 in the cmd I get two different locations.\nI was facing issues regarding having two versions of python. So I would like to know how i can completely remove python3 located files.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":225,"Q_Id":62875732,"Users Score":0,"Answer":"To delete a specific python version, you can use which python and remove the python folder using sudo rm -rf <path returned from the above command>. You might also have to modify the PATH env variable to the location which contains the python executables of the version you want.\nOr you can install Anaconda [https:\/\/www.anaconda.com\/products\/individual] which helps to manage multiple versions of python for you.","Q_Score":0,"Tags":"python,python-3.x","A_Id":62876127,"CreationDate":"2020-07-13T12:20:00.000","Title":"two versions of python installed at two places","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently, I access Jupyter notebook by opening Anocanda Navigator then opening the notebook link.  I have tried to bookmark the webpage but most of the time it doesn't work since it is a local page and I think some of the files are still \"running\" (I am clearly not an expert here and well aware of how stupid this may sound).  Is there any way to have Jupyter Notebook as its own desktop link without having to open it via Anaconda?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5085,"Q_Id":62878573,"Users Score":0,"Answer":"you can launch your jupyter notebook from remote server by trying on cmd prompt:\n\njupyter notebook --no-browser --port=8080\n\nor run the following command to launch with default port:\n\njupyter notebook --no-browser","Q_Score":3,"Tags":"python,jupyter-notebook","A_Id":62878685,"CreationDate":"2020-07-13T14:59:00.000","Title":"Is there a way to make a desktop shortcut for Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently, I access Jupyter notebook by opening Anocanda Navigator then opening the notebook link.  I have tried to bookmark the webpage but most of the time it doesn't work since it is a local page and I think some of the files are still \"running\" (I am clearly not an expert here and well aware of how stupid this may sound).  Is there any way to have Jupyter Notebook as its own desktop link without having to open it via Anaconda?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5085,"Q_Id":62878573,"Users Score":0,"Answer":"If you are on windows, open the search function on your nav bar on the bottom. Type \"Jupyter Notebook\". It should populate with your notebook. Then, right click on it and select \"Open file location\". This will take you to the file explorer. Finally, on the Notebook application that you use to run the Jupyter Notebook, right click \"Copy\". Then go to your desktop, and right click. Select \"Paste shortcut\", and Eureka! You should have the application shortcut on your desktop.","Q_Score":3,"Tags":"python,jupyter-notebook","A_Id":67216103,"CreationDate":"2020-07-13T14:59:00.000","Title":"Is there a way to make a desktop shortcut for Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Below you can find an example of the problem that I'm facing:\n\nproject:\n\npackage:\n\nxml.py\n\n\n\n\nxml.py:\nimport xml.etree.ElementTree as Et\n\nMy module named xml.py is getting confused with the xml package when I import it, now my question is:\nCan I name my module in such a way that won't interfere with the package name, but at the same time would be compliant with the PEP8 styling guide (e.g: xml_.py. I have seen this naming convention for variables but I am not sure it is a good practice to name modules like this).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":535,"Q_Id":62878577,"Users Score":0,"Answer":"modules (filenames) should have short, all-lowercase names, and they can contain underscores;\nPep8 documentation, so yes you can :)","Q_Score":1,"Tags":"python,module,package,naming,pep","A_Id":62878642,"CreationDate":"2020-07-13T14:59:00.000","Title":"Can module names in Python end with an underscore?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am basically working on a NodeJS app that has some buttons and on clicking them I run some python machine learning and deep learning models but the problem is that I cant install basic python libraries like numpy. Also as soon as I add python build pack to my app it stops running. The logs show that there is no web process. I found in docs that we have to insert a Procfile.txt with npm commands but that also didn't solve the problem.\nThe whole setup runs perfectly on the local machine.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":379,"Q_Id":62882871,"Users Score":0,"Answer":"@Vladim Hulevich Thanks for replying. But I ran it like this only and it works like a charm on my local machine but when I run my script on heroku it produces error of numpy not found. But my app is basically nodejs so I only added nodejs buildpack and not python as when I add python buildpack my nodejs app also stops running","Q_Score":2,"Tags":"javascript,python,heroku","A_Id":62883004,"CreationDate":"2020-07-13T19:23:00.000","Title":"How to run python script from nodejs on heroku","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a config file in an S3 bucket that needs to be modified by adding the response from ec2.describe_subnets and sent to an api endpoint. Is there a way to automate this process using Lambda to get the file from S3 without having to save it to a temp directory?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":230,"Q_Id":62883144,"Users Score":0,"Answer":"Is there a way to automate this process using Lambda to get the file from S3 without having to save it to a temp directory?\n\nIf you're asking about modifying the contents of the S3 Object, then the answer is no, it's not possible because S3 doesn't support that kind of operation. The only thing you can do is overwrite the entire object (ie, not just parts of it).\nIf you're asking about overwriting the S3 Object with new contents, then yes, it is possible to do it \"without having to save it to a temp directory\" if you do it in memory, for example.\nDownload the object from S3 without writing it to storage, make the changes in memory, and re-upload it to S3. If the file size is too big to fully store in memory, you can do it in a streaming fashion, too (i.e., initiate the download, for each chunk you download you make the necessary changes, and upload the modified chunk with a multipart upload, clear up the memory, repeat, etc).\nAs a final note, do keep in mind that S3 supports only eventual consistency for updates. This means that after you update the object, subsequent reads may still download the previous version. If whatever is consuming the file cannot properly deal with that, you'll probably need a different approach (i.e., don't overwrite, but write a new object with a new key, and send that new key to the consumer; or just use storage system that does support strong consistency, such as DynamoDB).","Q_Score":0,"Tags":"python-3.x,amazon-web-services,amazon-s3,aws-lambda","A_Id":62884456,"CreationDate":"2020-07-13T19:44:00.000","Title":"How can I edit an xml file that is stored in S3 without using a temp 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":0,"Web Development":0},{"Question":"I installed the pygame module and it works just fine when I try to run it from PyCharm or Sublime Text, but when I  try to run it from console or IDLE it says: \" Error: No module named 'pygame' \".I should mention that my python 3.8 is not installed on it's default location, but rather on other partition in the custom folder. I also had problems with PATH and python when I first installed python.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2149,"Q_Id":62885343,"Users Score":0,"Answer":"Did you do import pygame at the beginning of the script? That may be the problem.","Q_Score":0,"Tags":"python,python-3.x,path,pygame,modulenotfounderror","A_Id":62885402,"CreationDate":"2020-07-13T22:36:00.000","Title":"How to fix error: \" No module named 'pygame' \"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed the pygame module and it works just fine when I try to run it from PyCharm or Sublime Text, but when I  try to run it from console or IDLE it says: \" Error: No module named 'pygame' \".I should mention that my python 3.8 is not installed on it's default location, but rather on other partition in the custom folder. I also had problems with PATH and python when I first installed python.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2149,"Q_Id":62885343,"Users Score":0,"Answer":"Okay so basically I've just added every possible folder associated with python to PYTHONPATH and now it does accept pygame(It doesn't give any errors when I import pygame from console), but now it won't run programs at all and it also doesn't want to open the IDLE. I can still run it normally from Sublime","Q_Score":0,"Tags":"python,python-3.x,path,pygame,modulenotfounderror","A_Id":62895251,"CreationDate":"2020-07-13T22:36:00.000","Title":"How to fix error: \" No module named 'pygame' \"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed the pygame module and it works just fine when I try to run it from PyCharm or Sublime Text, but when I  try to run it from console or IDLE it says: \" Error: No module named 'pygame' \".I should mention that my python 3.8 is not installed on it's default location, but rather on other partition in the custom folder. I also had problems with PATH and python when I first installed python.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2149,"Q_Id":62885343,"Users Score":0,"Answer":"If you want to use it in PyCharm you need to go to settings then Project:\"name of the project\" then Project Interpreter then on the \"plus\" sign and find and install Pygame and\/or other modules. Ofcourse first you need to set the interpreter if it is not already set.","Q_Score":0,"Tags":"python,python-3.x,path,pygame,modulenotfounderror","A_Id":62896719,"CreationDate":"2020-07-13T22:36:00.000","Title":"How to fix error: \" No module named 'pygame' \"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed the pygame module and it works just fine when I try to run it from PyCharm or Sublime Text, but when I  try to run it from console or IDLE it says: \" Error: No module named 'pygame' \".I should mention that my python 3.8 is not installed on it's default location, but rather on other partition in the custom folder. I also had problems with PATH and python when I first installed python.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2149,"Q_Id":62885343,"Users Score":0,"Answer":"I got this error once but all i needed to do was install it from my console too.","Q_Score":0,"Tags":"python,python-3.x,path,pygame,modulenotfounderror","A_Id":63091820,"CreationDate":"2020-07-13T22:36:00.000","Title":"How to fix error: \" No module named 'pygame' \"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"WHAT:  I'm looking for a way to create an f-curve to dynamically retime an arbitrary number of keys in Maya.  Something like an Animation Layer, but for timing on a per-asset basis.\nWHAT NOT:  I've got a great linear retime-from-pivot script already.  Used it for years, love it, not looking for that.\nWHY:  Lets say I've animated several goblins racing toward an enemy.  Maybe they start the shot behind a gate or something because I don't want to change the timing of the start of the shot, and I don't want to change the end of the shot because I've already animated the hero striking them, and I can't change the length of the shot because the shot length is locked.\nThe director wants one of the goblins to get a little ahead while they are running, and then to slow back down into the current overall shot timing.  This director is more of a \"I'll know it when I see it\" kind of guy so I expect several rounds of revisions, and he might throw in a stumble request later for all I know, so I want to be able to mute this retime (so I'm working on whole numbered keys) and have it non-destructive (no baking).\nSUMMARY:  So, I want to scale an arbitrary number of keys on a selected object by a gradient with an arbitrary start and stop for the retime that can be muted, removed, or adjusted non-destructively.\nI'm thinking that setting an f-curve that will affect the timing of selected keys would be perfect.  Exactly like how animation layers work, but for timing.\nBonus points if a single retime curve can affect keys on several animation layers, as well.\nIs this idea possible?  Can you point me in some good direction for getting started, or any tools that have already been written?  I'm very new to learning programming, and am just starting to learn python for maya.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":134,"Q_Id":62885719,"Users Score":0,"Answer":"This should be possible. Have a look how a scene timewarp works. Every animation curve is connected to a time node. Usually you only have one time node which is connected to all anim curves. A scene timewarp is connected to this time node. What you can try is to create a time node for every bunch of animcurves you want control seperately. And then create a animCurveTT and connect it to the corresponding time node. If this precdure works, you can script it to make it easier to control.","Q_Score":0,"Tags":"python,animation,maya","A_Id":62891119,"CreationDate":"2020-07-13T23:14:00.000","Title":"Is there a way to use an f-curve to interactively retime keys in Maya?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to understand how the bind works when using %(variable)s\nIn my case, my query is: engine.execute(\"DELETE FROM testing WHERE test_id in %(ids)s, ids=tuple([1,2,3])))\nIf I remove the (ids) leaving only %s then I get a not all arguments converted during string formatting\nWhy is this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":62885749,"Users Score":0,"Answer":"couple ways of using 'named parameter'. one of them is using dictionary\nengine.execute(\"SELECT * FROM testing WHERE test_id = %(ids)s, {\"ids\": ids_value,})","Q_Score":1,"Tags":"python,mysql,python-3.x,sqlalchemy,mysql-python","A_Id":62886066,"CreationDate":"2020-07-13T23:17:00.000","Title":"python mysql understanding parameter bind","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This sounds counter intuitive, but what would be the pros and cons of updating the airflow database by deploying a job to airflow?\nI am considering this as an option to set up role based accesses by directly making updates to the database, and because Airflow is a scheduler, it would make sense to do schedule this process on Airflow.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":62886697,"Users Score":0,"Answer":"We actually do this to purge down the logs table periodically along with some other general Airflow housekeeping. The downsides aren't too bad assuming you tested your code elsewhere first and you're not running the process on an extremely small schedule.\nI would recommend that you read the airflow.models module and classes, and how they're used, and that you leverage them as examples for your process; it'll help to make sure you're doing things correctly and save you from needless duplication.","Q_Score":0,"Tags":"python-3.x,airflow,rbac","A_Id":63004798,"CreationDate":"2020-07-14T01:25:00.000","Title":"Updating the airflow database by scheduling a job to Airflow","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using monkeyrunner for my test. but the problem is that it is using python 2 instead of version 3. I've installed python3 only on my system. I do not know where is the python 2! is it on the test phone?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":62889386,"Users Score":0,"Answer":"Monkey runner is using the embedded python 2.x implementation and there is no way to change it unless its developers update it.\nI had to use txt file instead of JSON to port my code to python 2.x .","Q_Score":0,"Tags":"python,android,testing,monkeyrunner","A_Id":63558911,"CreationDate":"2020-07-14T06:38:00.000","Title":"Monkeyrunner is using python 2.x instead of 3.x","Data Science and Machine Learning":0,"Database and SQL":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 creating a chatbot with Amazon Lex and the idea is that a user can drop an Excel file into a Slack channel and the bot sends the file to the appropriate Lambda function. What is the best way to achieve this goal?\nIt would also be acceptable if the Lex bot uploads the file somewhere else accessible (s3, EC2, Github, etc.) and then sends the address to the Lambda functions.\nI do not see any SlotTypes that support this type of input.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":482,"Q_Id":62896237,"Users Score":1,"Answer":"Lex PostText or PostContent method doesn't support the upload load files.\n\nwhere as in slack you will get the file url in payload when user uploads a file.\nCreate slot type Eg.- File. keep the enumeration value as uploaded.\nWhen slotToElicit is File check whether url is exists or not in the payload. if exists send the URL to lex using the session attributes and fill the slot value as Uploaded(Default value). If user doesn't upload a file fill the slot value with some random text to elicit the slot again.\nWith the help of Session attributes you can have access to file and upload it to S3.","Q_Score":0,"Tags":"python,amazon-web-services,slack,aws-lex","A_Id":64303167,"CreationDate":"2020-07-14T13:22:00.000","Title":"Uploading a file to Amazon Lex","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 Flask as backend and React as frontend in my application. The application deals with large amounts of data (millions of rows).\nWhen I send the data from backend (stored in a dataframe in python) to frontend, it is in JSON format and is quite fast. But is JSON format stable enough to hold million rows of data?\nAre there any ideal data structures for large data like datatables or dataframes which makes it easier to access rows and columns similar to pandas dataframe in javascript or reactJS?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":62897005,"Users Score":0,"Answer":"try using lazyloading. It helps you get data on scroll","Q_Score":0,"Tags":"javascript,python,reactjs,flask,data-structures","A_Id":62898196,"CreationDate":"2020-07-14T14:03:00.000","Title":"Ideal data structure to hold a large tables in ReactJS","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using Flask as backend and React as frontend in my application. The application deals with large amounts of data (millions of rows).\nWhen I send the data from backend (stored in a dataframe in python) to frontend, it is in JSON format and is quite fast. But is JSON format stable enough to hold million rows of data?\nAre there any ideal data structures for large data like datatables or dataframes which makes it easier to access rows and columns similar to pandas dataframe in javascript or reactJS?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":62897005,"Users Score":0,"Answer":"Sending millions of rows to frontend and doing analysis in the frontend is not very adequate. Instead you can apply your bi logic in the backend and send results to frontend.","Q_Score":0,"Tags":"javascript,python,reactjs,flask,data-structures","A_Id":62899647,"CreationDate":"2020-07-14T14:03:00.000","Title":"Ideal data structure to hold a large tables in ReactJS","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have business objects, that I would like to (de)serialize from and into a .yaml file.\nBecause I want the .yaml to be human readable, I need a certain degree of control over the serialize and deserialize methods.\nWhere should the serialization logic go?\nA) If I teach every object, how to de\/serialize itself, but that probably violates the single-responsibility-principle.\nB) If I put it inside a common serialization module, that might violate the open-closed-principle, since more business objects will be added in the future. Also, changes to objects need now be performed in two places.\nWhat is the SOLID approach to solve this conundrum for tiny-scale applications?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":62897076,"Users Score":0,"Answer":"Usually in this kind of situation, you'll want the business objects to handle their own serialization.  This doesn't necessarily violate the single responsibility principle, which asserts that each object should have one job and one boss.  It just means that the one job includes serializability.  The user owns the business object, and wants to be able to serialize it, so the requirement for serializability comes from the same place as those other requirements -- the user.\nThere are a couple danger areas, though.  Firstly, do you really need to insist that the business object is serializable, or can you leave it up to the user to decide whether they are serializable or not?  If you are imposing a serializability requirement, then there's a good chance that your are violating the SRP that way, because as you evolve the serialization system, you will be imposing your own requirements on the objects.\nSecond, you probably want to think long and hard about the interface the these objects use to serialize themselves.  Does it have to be yaml?  Why?  Does it have to be to a file?  Try not to impose requirements that are subject to change, because they depend on particular implementation decisions that you're making in the rest of the system.  That ends up being a violation of SRP as well, because they those objects have to evolve according to requirements from 2 different sources.  It's better if the objects themselves initiate their own serialization, and can choose the implementation to the greatest extent possible.","Q_Score":1,"Tags":"python-3.x,serialization,design-patterns,solid-principles","A_Id":62946560,"CreationDate":"2020-07-14T14:07:00.000","Title":"Where to put *serialization* in SOLID programming","Data 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 Machine Learning Application using Python. I want to host it online so that it can be used from anywhere. What are my best options?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":45,"Q_Id":62898336,"Users Score":1,"Answer":"Personally, I use pythonanywhere.com, lets you run any python code from anywhere, and even host your websites.","Q_Score":0,"Tags":"python","A_Id":62898372,"CreationDate":"2020-07-14T15:13:00.000","Title":"How to host Python Web application online?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've used random.normal() in the past to generate a single number who, if called multiple times, in aggregate would create a bell curve distribution. What I'm trying to do now is to create the opposite \/ inverse, where the distribution is biased towards the extremes within a range? There are built in functions in excel that seem to do what I want. Is there a way to do it in python? Thank you","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":464,"Q_Id":62899379,"Users Score":0,"Answer":"It sounds like what you are wanting is to shift the distribution the the edge of the range, and wrap around?\nSomething like this could do what you're looking for:\nnum = (random.normal() + 0.5) % 1","Q_Score":0,"Tags":"python,random,normal-distribution,inverse","A_Id":62899580,"CreationDate":"2020-07-14T16:09:00.000","Title":"Inverse normal random number generation in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Previously I used Python 3.6.8 version . I uninstall python removed environment variable, and\nre-installed the same version and set the Environment variable Manually. But now when I run python --version in cmd is not displaying any error and points to a new line as follows.\nC:\\Users\\User>python --version\nC:\\Users\\User>\nWhen I set path it not gives any issue.\nC:\\Users\\User>set path=\"C:\\dir1\\dir\"\nC:\\Users\\User>python --version\nPython 3.6.8\nC:\\Users\\User>\nI need to resolve this by setting environment variable.\nAdditionally pycharm can detect python.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":228,"Q_Id":62900152,"Users Score":0,"Answer":"You can add the directory to the path for all future terminals (including cmd) by:\n\nOpen \"System Properties\" - how you do this depends on your windows version, on Win 10 you click the settings icon and type \"environment\" into the search bar and it'll give you the right option.\nGo to the \"Advanced\" tab\nAt the bottom there is a button for \"Environment Variables\".  Click that.\nIn the \"System Variables\" window, highlight the \"Path\" variable and click the \"Edit\" button.\nNow click \"New\" and add the directory that you've been adding manually.\n\nYou will need to start a new terminal as this does not update the path for currently open terminals.\nAlso note: \"python --version\" isn't looking for an environment variable, it's running the python.exe with the \"--version\" option (which, of course, reports the version).","Q_Score":1,"Tags":"python-3.x,environment-variables","A_Id":62900598,"CreationDate":"2020-07-14T16:54:00.000","Title":"Windows 10 unable detect the Python Environment Variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Previously I used Python 3.6.8 version . I uninstall python removed environment variable, and\nre-installed the same version and set the Environment variable Manually. But now when I run python --version in cmd is not displaying any error and points to a new line as follows.\nC:\\Users\\User>python --version\nC:\\Users\\User>\nWhen I set path it not gives any issue.\nC:\\Users\\User>set path=\"C:\\dir1\\dir\"\nC:\\Users\\User>python --version\nPython 3.6.8\nC:\\Users\\User>\nI need to resolve this by setting environment variable.\nAdditionally pycharm can detect python.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":228,"Q_Id":62900152,"Users Score":0,"Answer":"I resolved this issue. I cleaned the registry using CCleaner and reinstalled the python version as a fresh installation. Now it Works properly.","Q_Score":1,"Tags":"python-3.x,environment-variables","A_Id":63592007,"CreationDate":"2020-07-14T16:54:00.000","Title":"Windows 10 unable detect the Python Environment Variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a flask site. It's specifically a note app. At the moment I am storing the user notes as plaintext. That means that anyone with access to the server which is me has access to the notes. I want to encrypt the data with the user password, so that only the user can access it using their password, but that would require the user to input his\/her password each time they save their notes, retrive the notes or even updates them. I am hashing the password obviously.\nAnyone has any idea how this could be done?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":638,"Q_Id":62903682,"Users Score":-1,"Answer":"Use session to store user information, the Flask-Login extension would be a good choice for you.","Q_Score":1,"Tags":"python-3.x,flask,flask-sqlalchemy","A_Id":62905809,"CreationDate":"2020-07-14T20:41:00.000","Title":"How to encrypt data using the password from User","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can anyone help with best practices for avoiding this type of problem?\nin: np.arrange(1, 2.2, .2)\nout: array([1. , 1.2, 1.4, 1.6, 1.8, 2. , 2.2])\nMust have something to do with binary\/base10 difficulties, as\nin: np.arrange(1, 2.2, .2)[6]\nout: 2.1999999999999997\npython version:  3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46)\n[GCC 4.2.1 Compatible Clang 4.0.1 (tags\/RELEASE_401\/final)]\nnumpy version: :  1.16.3","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":62905568,"Users Score":0,"Answer":"Okay, answered my own question (rly just wanted to post on stackoverflow).\nIt's best to use numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0), and just set num to (start - stop)\/spacing (+1 if endpoint=True).","Q_Score":0,"Tags":"python,numpy","A_Id":62905620,"CreationDate":"2020-07-14T23:45:00.000","Title":"numpy arrange oddly including endpoint when it shouldn't","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a new conda environment and installed turicreate. How can I start anaconda navigator within this new environment? Currently I start navigator from the base environment and then switch to the new environment. When I do this, I can see turicreate is listed as an installed package, but when I import it, I get a modulenotfound error.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":62906612,"Users Score":0,"Answer":"Creating new environment with a version of python (3.7) compatible with Turicreate solved this problem..","Q_Score":0,"Tags":"python,anaconda,conda,turi-create","A_Id":63237891,"CreationDate":"2020-07-15T02:16:00.000","Title":"How to use turicreate in Anaconda navigator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using VS Code on Windows 10. I had no problems until a few hours ago (at the time of post), whenever I want to run a python program, it opens terminals outside of VS Code like Win32 and Git Bash. How do I change it back to the integrated terminal I usually had?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":91,"Q_Id":62906999,"Users Score":1,"Answer":"With your Python file open in VS Code:\n\nGo to Run > Open Configurations, if you get prompted select \"Python File\"\nIn the launch.json file, change the value of \"console\" to \"integratedTerminal\"","Q_Score":0,"Tags":"python,python-3.x,visual-studio-code,vscode-settings","A_Id":62907977,"CreationDate":"2020-07-15T03:10:00.000","Title":"I have a visual studio code terminal problem how do i fix it so that i have the integrated one instead of external?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Recently I went on to clean my python code. I felt tiresome to remove all print statements in the code ony by one.\nIs there any shortcut in editor or RE for removing or commenting print statements in a python program in one go?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":271,"Q_Id":62908688,"Users Score":0,"Answer":"Open Text Editor in Ubuntu\nPress Ctrl + h\nReplace: print\nReplace with: # print","Q_Score":0,"Tags":"python,editor","A_Id":62991581,"CreationDate":"2020-07-15T06:18:00.000","Title":"Remove all print statements in a python program in one go","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large python script. It prints a bunch of output on my terminal console. The problem is the print is not happening altogether. Some print statements print one blob of statements together, then under that some other part of code prints some stuff. It goes on as long as the main loop runs.\nIssue is I get the output as I want but all is getting printed on console as that is where we are running the python main script.\nIt would be very helpful if along with the print happening at console, I can get all the output in console in same format to a text file also for retention.\nAgain, there are bunch of print statements occurring in different parts of the whole script. So not sure how to retain the whole output of console in same format to a final text file.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":855,"Q_Id":62909803,"Users Score":1,"Answer":"I would rather go ahead with bash and use tee command. It redirects the output to a file too.\npython -u my.py | tee my_file.txt","Q_Score":1,"Tags":"python","A_Id":62909845,"CreationDate":"2020-07-15T07:37:00.000","Title":"How to store output printed on terminal console to a text file in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am on a 64-bit Intel Core i3 7th generation machine. I installed python there and after which when I typed python on the command line to make sure that it is properly installed I found that it has installed the 32 bit version of the same. The shell prompt displayed something like this - MSC v.1916 32 bit (Intel)] on win32.\nIs it fine or is there some issue which can be fixed?\nThanks in advance.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":62911792,"Users Score":0,"Answer":"There could be only a single problem that is the performance. Else everything will go good.\nThe speed may be a bit low.\nAnyway you can simply uninstall the 32 bit and install 64 bit if you want.","Q_Score":0,"Tags":"python,python-3.x,windows","A_Id":62911983,"CreationDate":"2020-07-15T09:30:00.000","Title":"Error installing Python on my Windows 64-bit Machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am on a 64-bit Intel Core i3 7th generation machine. I installed python there and after which when I typed python on the command line to make sure that it is properly installed I found that it has installed the 32 bit version of the same. The shell prompt displayed something like this - MSC v.1916 32 bit (Intel)] on win32.\nIs it fine or is there some issue which can be fixed?\nThanks in advance.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":62911792,"Users Score":0,"Answer":"You need to download the 64-bit installation file to install 64-bit Python.\nThe 32-bit and 64-bit installation files are different.\nBe sure to install the 64-bit file.","Q_Score":0,"Tags":"python,python-3.x,windows","A_Id":62912174,"CreationDate":"2020-07-15T09:30:00.000","Title":"Error installing Python on my Windows 64-bit Machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I made a chat streaming function in python using threading which is for a kivy app when I compile the app for iOS the thread updates when the app starts and doesn\u2019t update again when the streaming is updated. It works perfecting when I run it in pycharm but it not updating in IOS simulator. I was wondering maybe it\u2019s because I\u2019m using an IOS simulator to run the code but I\u2019m not sure. Any body with expertise on this area I would appreciate if you assist me. Thank you","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":44,"Q_Id":62912733,"Users Score":1,"Answer":"Deployed it on my phone and it works as expected.","Q_Score":1,"Tags":"python,multithreading,kivy,ios-simulator,python-multithreading","A_Id":62916772,"CreationDate":"2020-07-15T10:22:00.000","Title":"Python threading in IOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Wondering can someone point me in the right direction on how to convert base64 image string to its original image URL.\nMy code is scraping top 5 news from google based on my search string.\nImages are in one big massive base64 string. Images are printing ok on my outlook email (my code extract the news and send out an email in outlook) but when I forward that email on to different email account can't see any image but a message The linked image cannot be displayed. The file may have been moved, renamed or deleted. Just to check that, I copied the image from my outlook email and tried to paste on word document; all I can see is an empty box but no image.\nany advice, please?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":521,"Q_Id":62914205,"Users Score":0,"Answer":"You can't get a URL from those.  Those base64 encoded strings are fully embedded images.  You could base64 decode them and save it to a file or just take the base64 encoded string an attach it to another image tag like in the incoming email.\nIf you have some specific code I could be of more help.","Q_Score":0,"Tags":"python,base64","A_Id":62914260,"CreationDate":"2020-07-15T11:51:00.000","Title":"Get original image url from base64 Image String using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to learn how to remove a virtual environment using the windows command prompt, I know that I can easily remove the folder of the environment. But I want to know if there is a more professional way to do it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6020,"Q_Id":62914820,"Users Score":1,"Answer":"There is no command to remove virtualenv, you can deactivate it or remove the folder but unfortunately virtualenv library doesn't contain any kind of removal functionality.","Q_Score":1,"Tags":"python,cmd,virtualenv,command-prompt","A_Id":62914877,"CreationDate":"2020-07-15T12:26:00.000","Title":"How can I remove\/delete a virtual python environment created with virtualenv in Windows 10?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm dealing with a dataframe of dimension 4 million x 70. Most columns are numeric, and some are categorical, in addition to the occasional missing values. It is essential that the clustering is ran on all data points, and we look to produce around 400,000 clusters (so subsampling the dataset is not an option).\nI have looked at using Gower's distance metric for mixed type data, but this produces a dissimilarity matrix of dimension 4 million x 4 million, which is just not feasible to work with since it has 10^13 elements. So, the method needs to avoid dissimilarity matrices entirely.\nIdeally, we would use an agglomerative clustering method, since we want a large amount of clusters.\nWhat would be a suitable method for this problem? I am struggling to find a method which meets all of these requirements, and I realise it's a big ask.\nPlan B is to use a simple rules-based grouping method based on categorical variables alone, handpicking only a few variables to cluster on since we will suffer from the curse of dimensionality otherwise.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":773,"Q_Id":62917042,"Users Score":1,"Answer":"The first step is going to be turning those categorical values into numbers somehow, and the second step is going to be putting the now all numeric attributes into the same scale.\nClustering is computationally expensive, so you might try a third step of representing this data by the top 10 components of a PCA (or however many components have an eigenvalue > 1) to reduce the columns.\nFor the clustering step, you'll have your choice of algorithms. I would think something hierarchical would be helpful for you, since even though you expect a high number of clusters, it makes intuitive sense that those clusters would fall under larger clusters that continue to make sense all the way down to a small number of \"parent\" clusters. A popular choice might be HDBSCAN, but I tend to prefer trying OPTICS. The implementation in free ELKI seems to be the fastest (it takes some messing around with to figure it out) because it runs in java. The output of ELKI is a little strange, it outputs a file for every cluster so you have to then use python to loop through the files and create your final mapping, unfortunately. But it's all doable (including executing the ELKI command) from python if you're building an automated pipeline.","Q_Score":1,"Tags":"python,r,bigdata,cluster-analysis,mixed","A_Id":62917300,"CreationDate":"2020-07-15T14:18:00.000","Title":"Clustering on large, mixed type data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"tl;dr: Is Spring + Django back-end possible?\nWhen I was new to industry and was still working my way around the office, I got interested in Django and created a very small, basic-level application using the framework. When I got to meet my team after a few weeks, they said to go for Spring framework. After spending half a year on the framework and the main proj, I finally started to get time to start working off-hours. But, I don't want to lose both the skills - My teammate(when we were still in office ;) ) once told me that they worked on a project that started with python code, and then later added features using Java. And I am unable to find any helpful google searches(mostly showing Spring vs Django).\nHow should I go about it? Is it too much to ask for? Is it worthwhile? Will I learn some new concepts of application architecture a noob like me would have missed. Please provide me with some insight.\nAre there resources(docs) I can go through?\nP.S. I'm not a diehard fan of either of the frameworks right now, just another coder testing waters.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1059,"Q_Id":62921213,"Users Score":0,"Answer":"I would say go for 1 framework and stick with it. For example Django if you want to code in python, and spring if you want to code in java. Learning both frameworks however brings a lot of value, because you can compare their benefits (eg. spring forces you to write clean code, django has build-in and simpler database management)\nI like Django's build-in tooling a lot, you only need to know python for it to work. Spring requires a bit more knowledge of eg. hibernate for database management. However I predict Django will outgrow spring at some point, because of cloud valuing fast iteration over code and quick startup time (auto-scaling apps) over large overhead apps and long boot times. Hoever, if you like java, I can recommend JHipster for java\/spring webapp development to get up to speed very fast and learning the ways of REST CRUD api fast.\nTo combine 2 programs: write your main logic in one app, and write a small service in the second language, making sure its independent of the first app (no back and forth communication and complicated logic, but simple independent request\/response, as if the main app was never there). Add a REST api to the second app and use eg. http requests to communicate.\nWhat's possible in terms of combining languages:\n\nconnect different applications with each other: by letting them communicate through their APIs. For example a python api developed with flask or django can send requests to a java api developed with spring, as long as they have a way to communicate (eg over http, or via some queue like rabbitmq)\nconnect a webapp to 2 different backends: by using a shared authentication system: For example a keycloak authentication server to handle tokens, that your backend applications know about.\n\nWhat's not possible (and also not preferable):\n\ncombining java with python code in the same program: there are some hacky ways to get it to work, but its asking for trouble and not readable.","Q_Score":1,"Tags":"java,python,django,spring,backend","A_Id":65790969,"CreationDate":"2020-07-15T18:08:00.000","Title":"Is it possible to use more than one framework at the backend(Spring boot + Django)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am importing a third party module that I don't have control over and can't change the source. It does a logging.basicConfig() which is messing up my own logger configuration. I have tried giving a different 'name' to my logger using self.logger = logging.getLogger('some_random_name') which is resulting in every log message printed twice, once with my format, and once with the format set by the basicConfig in that third party module.\nIs there a way to ignore the basicConfig from the imported module?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":62923514,"Users Score":3,"Answer":"logging.basicConfig() implicitly add handlers to the root logger, so you can just delete those handlers by logging.root.handlers = [].\n\nFurther, the root logger may set to an unwanted level, you can also simply set it by logging.root.setLevel(what_ever_you_want).\n\nEven further, if you call logging.info, logging.error etc. without configuring the root logger first, a basicConfig() is called internally, and so a StreamHandler will be implicitly added to the root logger.","Q_Score":1,"Tags":"python,python-3.x,logging","A_Id":62926347,"CreationDate":"2020-07-15T20:46:00.000","Title":"Ignore logging.basicConfig in third party module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a calculation that may result in very, very large numbers, that won fit into a float64. I thought about using np.longdouble but that may not be large enough either.\nI'm not so interested in precision (just 8 digits would do for me). It's the decimal part that won't fit. And I need to have an array of those.\nIs there a way to represent \/ hold an unlimited size number, say, only limited by the available memory? Or if not, what is the absolute max value I can place in an numpy array?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1833,"Q_Id":62929222,"Users Score":2,"Answer":"Can you rework the calculation so it works with the logarithms of the numbers instead?\nThat's pretty much how the built-in floats work in any case...\nYou would only convert the number back to linear for display, at which point you'd separate the integer and fractional parts; the fractional part gets exponentiated as normal to give the 8 digits of precision, and the integer part goes into the \"\u00d710\u207f\" or \"\u00d7e\u207f\" or \"\u00d72\u207f\" part of the output (depending on what base logarithm you use).","Q_Score":0,"Tags":"python,numpy,python-3.7,numpy-ndarray","A_Id":62929416,"CreationDate":"2020-07-16T07:00:00.000","Title":"In NumPy, how to use a float that is larger than float64's max value?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I copy text from one cell and paste into another cell it double pastes.\nIf I cmd+z to undo it undoes one of the two pastes implying the issue is pasting. In .ipynb files, VSC double pastes.\nI tried pasting in a .py file with no issue. Likewise pasting in the issue reporter has no issue, just in Jupyter Notebook cells.\nI manually restarted VSC and the issue went away. After a while (12 minutes of use) the issue randomly came back when pasting between different notebooks.\nThe issue seems intermittent coming and going seemingly randomly.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":531,"Q_Id":62933098,"Users Score":1,"Answer":"Due to many posts i answer this myself here (for Windows 10)\nFrom Keyboard Shortcuts in VScode.\nsearch for: editor.action.clipboardPasteAction\nremove the CTRL+V keybinding.\nThis works in Windows 10\nVScode version: 1.47.1 (installed in 2020)","Q_Score":1,"Tags":"python-3.x,visual-studio-code,jupyter-notebook","A_Id":62933099,"CreationDate":"2020-07-16T10:52:00.000","Title":"In a notebook (.ipynb file) paste double pastes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I copy text from one cell and paste into another cell it double pastes.\nIf I cmd+z to undo it undoes one of the two pastes implying the issue is pasting. In .ipynb files, VSC double pastes.\nI tried pasting in a .py file with no issue. Likewise pasting in the issue reporter has no issue, just in Jupyter Notebook cells.\nI manually restarted VSC and the issue went away. After a while (12 minutes of use) the issue randomly came back when pasting between different notebooks.\nThe issue seems intermittent coming and going seemingly randomly.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":531,"Q_Id":62933098,"Users Score":0,"Answer":"In my experience, this only happens in markdown cells, not code cells. My own solution is to copy the problem cell, paste the new cell below it, and finally delete the original cell.","Q_Score":1,"Tags":"python-3.x,visual-studio-code,jupyter-notebook","A_Id":68687859,"CreationDate":"2020-07-16T10:52:00.000","Title":"In a notebook (.ipynb file) paste double pastes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need a python module that prints a colored output text for input() and print() functions which works on idle, Powershell, and Linux consols.\nI am just expecting few colors (no extra background features required) and the same functions should work equally on python idle, PowerShell, terminal, and cmd with full flexibility of code.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":242,"Q_Id":62933340,"Users Score":0,"Answer":"clrprint does a good job of printing in color - 'b' for blue, 'g' for green, 'r' for red, 'd' for default (black), 'p' for purple & 'y' for yellow\nTo print a single value in color, use clr=color (specify the color in quotes)\nTo print multiple values in color, use clr=[list of color strings] (specify the colors in quotes, within a list.\n# pip install clrprint as mentioned above\nfrom clrprint import *\nclrprint(\"Big data\", clr='b')            # Print 1 value on a line\nclrprint(\"Big\", \"data\", clr=['y','d']) # Print multiple values on the same line\nx = 5\nclrprint(\"x =\", x, clr=['g', 'p'])  # Print variable value\nname = clrinput('Enter name: ', clr=['p', 'd'])  # input a value","Q_Score":0,"Tags":"python-3.x,powershell,terminal,colors,python-idle","A_Id":68539161,"CreationDate":"2020-07-16T11:05:00.000","Title":"Is there a single python module for colored text output in idle, Powershell and terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After having installed libgdcm-tools (2.6.6-3) on my system (via apt install libgdcm-tools) I am not longer able to import pydicom in Python. When running import pydicom as pdc I got the following error\nAttributeError: module 'gdcm' has no attribute 'DataElement'.\nRemoving libgdcm-tools does not solve the issue.\nI am working with Python 3.7 and pydicom 2.0.0 in Ubuntu 18.04.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":598,"Q_Id":62933483,"Users Score":0,"Answer":"Indeed @scaramallion's comment pointed me in the right direction. I didnt't have a gcdm directory in the working directory, but in my home directory. Removing that directory solved the problem.","Q_Score":2,"Tags":"python,pydicom,gdcm","A_Id":62990094,"CreationDate":"2020-07-16T11:14:00.000","Title":"Why importing pydicom rise AttributeError: module 'gdcm' has no attribute 'DataElement'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 different projects with different dependencies. One requires Tensorflow1.15 and another needs 1.14. I first created an environment env1 and pip installed Tf1.14, ran my code, all went well. Then I created a new environment env2 and pip installed Tf1.15, during which I could see it was uninstalling Tf1.14, I assumed it knew what it was doing. However now when I run my code in env1 it throws errors because tf1.14 is removed and env1 also tries to use tf1.15!\nWhat am I doing wrong? I thought we use Conda to create completely separate environments for specifically this kind of situation but I'm confused.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":62936040,"Users Score":0,"Answer":"You should not have used pip to install the packages. If you have Anaconda you should use conda to install them. conda install numpy will install the numpy module.\nYou need\nconda install your-module","Q_Score":1,"Tags":"python,anaconda,conda","A_Id":62945847,"CreationDate":"2020-07-16T13:37:00.000","Title":"Creating new Conda environment messes with old environments?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently, I am working on creating datasets by using Twitter API. I have some question that you might be able to help me out. For example, the first dataset that I have to create is related to the early hashtag adopters, I mean, by using a specific hashtag as the search word in a certain timeframe, I will retrieve the first 50 users ID who have used the hashtag on their tweets.\nThe problem I'm facing is that it will show me the most recent tweets that match the query, but what I want is the other way round, I mean, in ascending order. So, I am wondering if this is possible to do it.\nPD: I am using searchtweets package in python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":62938338,"Users Score":1,"Answer":"Unfortunately, there isn't a way to make premium api return things in chronological order (it will always return newest first).","Q_Score":1,"Tags":"python,twitter","A_Id":62956049,"CreationDate":"2020-07-16T15:38:00.000","Title":"Retrieve tweets in ascending order with a defined timeframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As mentioned in the question, I build a kivy app and deploy it to my android phone. The app works perfectly on my laptop but after deploying it the font size changes all of a sudden and become very small.\nI can't debug this since everything works fine. The only problem is this design or rather the UI.\nDoes anyone had this issue before? Do you have a suggestion how to deal with it?\nPS: I can't provide a reproducible code here since everything works fine. I assume it is a limitation of the framework but I'm not sure.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":62938507,"Users Score":1,"Answer":"It sounds like you coded everything in terms of pixel sizes (the default units for most things). The difference on the phone is probably just that the pixels are smaller.\nUse the kivy.metrics.dp helper function to apply a rough scaling according to pixel density. You'll probably find that if you currently have e.g. width: 50, on the desktop then width: dp(50) will look the same while on the phone it will be twice as big as before.\n\nPS: I can't provide a reproducible code here since everything works fine.\n\nProviding a minimal runnable example would, in fact, have let the reader verify whether you were attempting to compensate for pixel density.","Q_Score":0,"Tags":"python-3.x,kivy,kivy-language,buildozer","A_Id":62938952,"CreationDate":"2020-07-16T15:46:00.000","Title":"Why does the dimensions of Kivy app changes after deployment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Visual Studio Code, with git extensions installed, how do you add files or complete folders to the .gitignore file so the files do not show up in untracked changes. Specifically, using Python projects, how do you add the pycache folder and its contents to the .gitignore. I have tried right-clicking in the folder in explorer panel but the pop-menu has no git ignore menu option. Thanks in advance.\nEdit: I know how to do it from the command line. Yes, just edit the .gitignore file. I was just asking how it can be done from within VS Code IDE using the git extension for VS Code.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":15622,"Q_Id":62939781,"Users Score":9,"Answer":"So after further investigation, it is possible to add files from the pycache folder to the .gitignore file from within VS Code by using the list of untracked changed files in the 'source control' panel. You right-click a file and select add to .gitignore from the pop-up menu. You can't add folders but just the individual files.","Q_Score":6,"Tags":"python,git,visual-studio-code,gitignore","A_Id":62950050,"CreationDate":"2020-07-16T16:58:00.000","Title":"Adding files to gitignore in Visual Studio Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed\n\nPython 2.7\nVisual Studio Code 1.471.\nPython Extension 2020.6.91350\n\nWhile Go to definitions works within same module, but if we import some other module, Go to definition don't work\nAny idea what can be solution for this ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3981,"Q_Id":62940558,"Users Score":1,"Answer":"TL;DR: Your language server might not be opening up properly because vscode version is not up to date. This goes to all languages\nIf your symptoms include\n\nType >Python: Show output in vscode console\nRestart vscode and open any python file\nIn the output if you see any line saying something close to Error: cant't start language server because vscode version low\n\nYou need your vscode updated to latest version.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":66217282,"CreationDate":"2020-07-16T17:43:00.000","Title":"Go to Definition in Python Microsoft Extension is not working in modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying log to AWS cloud watch and I am getting this error. same code was working all from yesterday without issues.\nI looked into some article and I installed certifi package as well but this also did not help\nI am using Python 3.5 and watchtower to log data to AWS cloud watch.\nI am running my python code in windows 10 OS.\nCan you please help me with this?\n\n\nTraceback (most recent call last):\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\urllib3\\connectionpool.py\", line 677, in urlopen\nchunked=chunked,\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\urllib3\\connectionpool.py\", line 381, in _make_request\nself._validate_conn(conn)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\urllib3\\connectionpool.py\", line 976, in validate_conn\nconn.connect()\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\urllib3\\connection.py\", line 370, in connect\nssl_context=context,\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\urllib3\\util\\ssl.py\", line 377, in ssl_wrap_socket\nreturn context.wrap_socket(sock, server_hostname=server_hostname)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\ssl.py\", line 376, in wrap_socket\n_context=self)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\ssl.py\", line 747, in init\nself.do_handshake()\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\ssl.py\", line 983, in do_handshake\nself._sslobj.do_handshake()\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\ssl.py\", line 628, in do_handshake\nself._sslobj.do_handshake()\nssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\httpsession.py\", line 263, in send\nchunked=self._chunked(request.headers),\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\urllib3\\connectionpool.py\", line 725, in urlopen\nmethod, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\urllib3\\util\\retry.py\", line 379, in increment\nraise six.reraise(type(error), error, _stacktrace)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\urllib3\\packages\\six.py\", line 734, in reraise\nraise value.with_traceback(tb)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\urllib3\\connectionpool.py\", line 677, in urlopen\nchunked=chunked,\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\urllib3\\connectionpool.py\", line 381, in _make_request\nself.validate_conn(conn)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\urllib3\\connectionpool.py\", line 976, in validate_conn\nconn.connect()\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\urllib3\\connection.py\", line 370, in connect\nssl_context=context,\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\urllib3\\util\\ssl.py\", line 377, in ssl_wrap_socket\nreturn context.wrap_socket(sock, server_hostname=server_hostname)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\ssl.py\", line 376, in wrap_socket\ncontext=self)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\ssl.py\", line 747, in init\nself.do_handshake()\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\ssl.py\", line 983, in do_handshake\nself.sslobj.do_handshake()\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\ssl.py\", line 628, in do_handshake\nself.sslobj.do_handshake()\nurllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (ssl.c:646)\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):\nFile \".\\test_main.py\", line 2, in \nimport test_provision_api\nFile \"C:\\Users\\BBB\\Documents\\Drive D\\GIT_Local\\NBNBNN\\Python_Logging\\V2.1\\test_provision_api.py\", line 39, in \nobj_PdAdmin.call_provisionadmin(pv_url1, WssVersion_list[0], master_AffId[0], master_Culture[0])\nFile \"C:\\Users\\BBB\\Documents\\Drive D\\GIT_Local\\NBNBNN\\Python_Logging\\V2.1\\test_provision_api.py\", line 26, in call_provisionadmin\nHttpJsonlogger.info('PD Admin - \/ProductDefinition', extra=pd_admin_extra)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\logging_init.py\", line 1279, in info\nself.log(INFO, msg, args, **kwargs)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\logging_init.py\", line 1415, in log\nself.handle(record)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\logging_init.py\", line 1425, in handle\nself.callHandlers(record)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\logging_init.py\", line 1487, in callHandlers\nhdlr.handle(record)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\logging_init.py\", line 855, in handle\nself.emit(record)\nFile \"C:\\Users\\BBB\\AppData\\Roaming\\Python\\Python35\\site-packages\\watchtower_init.py\", line 174, in emit\nlogStreamName=stream_name)\nFile \"C:\\Users\\BBB\\AppData\\Roaming\\Python\\Python35\\site-packages\\watchtower_init.py\", line 20, in _idempotent_create\n_callable(args, **kwargs)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\client.py\", line 316, in _api_call\nreturn self._make_api_call(operation_name, kwargs)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\client.py\", line 622, in _make_api_call\noperation_model, request_dict, request_context)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\client.py\", line 641, in _make_request\nreturn self._endpoint.make_request(operation_model, request_dict)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\endpoint.py\", line 102, in make_request\nreturn self._send_request(request_dict, operation_model)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\endpoint.py\", line 137, in _send_request\nsuccess_response, exception):\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\endpoint.py\", line 256, in _needs_retry\ncaught_exception=caught_exception, request_dict=request_dict)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\hooks.py\", line 356, in emit\nreturn self._emitter.emit(aliased_event_name, **kwargs)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\hooks.py\", line 228, in emit\nreturn self._emit(event_name, kwargs)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\hooks.py\", line 211, in _emit\nresponse = handler(kwargs)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\retryhandler.py\", line 183, in call\nif self._checker(attempts, response, caught_exception):\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\retryhandler.py\", line 251, in call\ncaught_exception)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\retryhandler.py\", line 277, in _should_retry\nreturn self._checker(attempt_number, response, caught_exception)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\retryhandler.py\", line 317, in call\ncaught_exception)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\retryhandler.py\", line 223, in call\nattempt_number, caught_exception)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\retryhandler.py\", line 359, in _check_caught_exception\nraise caught_exception\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\endpoint.py\", line 200, in _do_get_response\nhttp_response = self._send(request)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\endpoint.py\", line 269, in _send\nreturn self.http_session.send(request)\nFile \"C:\\Users\\BBB\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\botocore\\httpsession.py\", line 281, in send\nraise SSLError(endpoint_url=request.url, error=e)\nbotocore.exceptions.SSLError: SSL validation failed for https:\/\/logs.-**-.amazonaws.com\/ [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":508,"Q_Id":62941750,"Users Score":0,"Answer":"I don't know the specific about your case but certificate validation always end up with the following solutions:\n\nthe certificate is expired\nthe certificate is not trusted because you don't have the public key or the certificate authority in your trust file\/truststore\nthe domain is not covered by the certificate\n\nThe message provided seems to tell the domain https:\/\/logs.-**-.amazonaws.com is not covered by the certificate\nSo download the certificate, get the details and check if:\n\n\"Delivered to\" field cover the domain name\none of \"Subject Alternative Name (SAN)\" cover the domain name\n\nEDIT:\nTo download the certificate either use a browser to load the url and use the \"lock\" icon to download the certificate or use openssl utility to download the certificate from the url. To get the details, save the certificate with the \".cer\" extension and double click on it or use openssl utility to get the details from a certificate file.\nGood luck","Q_Score":0,"Tags":"python-3.x,amazon-cloudwatchlogs","A_Id":62942895,"CreationDate":"2020-07-16T18:56:00.000","Title":"ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My Flask web application runs using nginx and gunicorn. I use supervisor to let my application run in the background. I always updated my files using Windows Power Shell and the command SCP. After i moved the new edited files, which are already existing on my Ubuntu server, to the server, i use the command sudo supervisorctl reload to restart the flask app to see the changes. But this time the flask app did not start and i only get 502 Bad Gateway. It does not matter how many times i reload the supervisor or restart nginx, i only get the error code 502.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":464,"Q_Id":62942378,"Users Score":1,"Answer":"The issue was a not installed module and a typing error in a configuration file.","Q_Score":0,"Tags":"python,ubuntu,nginx,flask,supervisord","A_Id":62943749,"CreationDate":"2020-07-16T19:42:00.000","Title":"502 Bad Gateway after reloading supervisor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Here is some code daily coding problem has stated I should trust how it works.\ndef count(node): return count(node.left) + count(node.right) + 1 if node else 0\nIt's supposed to recursively go through a tree and count the nodes. The part of the code that looks nonsensical to me is where the if statement is part of the return statement, and it says if node else 0. Is if node really going to evaluate as a Boolean expression.\nThey also stated that you don't need to understand the code but just to trust that it works. What does anyone gain by code they can't understand? Understanding the code seems like basic competence. Hard to imagine an employer hire someone who can regurgitate code but doesn't understand how said code works.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":89,"Q_Id":62943906,"Users Score":1,"Answer":"I don't immediately recognise the language, but if we accept that it is some sort of pythonesq backwards if, then it is a reasonable implementation.\nThe idea they are trying to push is that you can understand what recursive code it is doing without getting bogged down in the detail of stepping through some complex example.\nIn this case they are saying \"what if you are on a node?\" the size of the subtree is the side of the two child subtrees plus 1 for the current node.\nThis is fine, until you get to a leaf node. You want a leaf node to return the answer 1 - there are no children, just the 1 leaf node. The way they did it was to say \"what happens if we follow the children on the leaf?\" well then you get a null node.\nIf the null node returns a count of zero, then the calculation on the leaf node gives 0+0+1 => 1 which is the answer we want.\nThis also nicely covers the case where the caller calls with an empty tree - the answer should be zero.\nYou have to do these tests to see if the left and\/or right children are null, and it doesn't do each test more than once, it is reasonably efficient for what it is.","Q_Score":1,"Tags":"python,algorithm,binary-tree,boolean-expression,coding-efficiency","A_Id":62944129,"CreationDate":"2020-07-16T21:41:00.000","Title":"Understanding a \"return something if\" python expression","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here is some code daily coding problem has stated I should trust how it works.\ndef count(node): return count(node.left) + count(node.right) + 1 if node else 0\nIt's supposed to recursively go through a tree and count the nodes. The part of the code that looks nonsensical to me is where the if statement is part of the return statement, and it says if node else 0. Is if node really going to evaluate as a Boolean expression.\nThey also stated that you don't need to understand the code but just to trust that it works. What does anyone gain by code they can't understand? Understanding the code seems like basic competence. Hard to imagine an employer hire someone who can regurgitate code but doesn't understand how said code works.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":62943906,"Users Score":0,"Answer":"I was not a fan when this happened to me in school. If a teacher (or another developer for that matter) is going to imply something like that, it's nice to at least have a reference to why it works the way it should.\nThere is always a chance that's not what they're trying to teach you at the moment and so they're skipping over it for now. But if that is the case, they should have written it differently...","Q_Score":1,"Tags":"python,algorithm,binary-tree,boolean-expression,coding-efficiency","A_Id":62943958,"CreationDate":"2020-07-16T21:41:00.000","Title":"Understanding a \"return something if\" python expression","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Pandas dataframe column that consists of several dictionaries in the format of:\ndf[students] = {u'51': [u'1592', u'1582', u'1272', u'459', u'1254', u'1267'], u'32': [u'1659', u'1322', u'1396', u'1315', u'1342', u'1661']} {u'51': [u'1592', u'1582', u'1272', u'459', u'1254', u'1267'], u'32': [u'1659', u'1322', u'1396', u'1315', u'1342', u'1661']}\n... and so on for several more entries.\nEach dictionary represents one entry in the dataframe. I would like to convert this column into 2 new columns where the keys (51 and 32) are the column headers, and the values go into each column accordingly. I used the df.to_list() and Pd.Series() methods which seemed to work at first, but when I replicated it, it didnt change the data at all. Is there something I'm missing here?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":62944256,"Users Score":0,"Answer":"Turns out that the above methods posted didn't work while the strings in question were in unicode.\nThis finally worked:\ndf['students'] = df['students'].map(eval)\ndf2 = pd.concat([df.drop('students', axis=1), pd.DataFrame(df['students'].tolist())], axis=1)\nI appreciate the answers posted, thanks a bunch everyone.","Q_Score":0,"Tags":"python,pandas,list,dataframe,dictionary","A_Id":62945479,"CreationDate":"2020-07-16T22:11:00.000","Title":"Converting a Dataframe Column of Dictionaries into New Columns based on Keys","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"A pyton set is meant as not ordered, so why enumerate accepts them as input?\nThe same question would apply to dictionary.\nFrom my point of view these are giving the false impression that there is a predictable way of enumerating them, but there is not.\nThis is quite misleading. I would have expected at least a warning from enumerate whens I request the enumerate(set) or enumerate(dict).\nCan anyone explain why this warning is not there? is it \"pythonic\" to allow enumeration which can be not predictable?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":54,"Q_Id":62944300,"Users Score":1,"Answer":"enumerate accepts any iterable which includes set and dict. set might be unordered but its order of iteration is not arbitrary; if you iterate the same set multiple times, it will yield elements in the same order.\nAlso note that as of Python 3.7 dict preserves insertion order. Whether or not this is useful solely depends on your use case.","Q_Score":0,"Tags":"python,dictionary,set,enumerate","A_Id":62944350,"CreationDate":"2020-07-16T22:15:00.000","Title":"Why enumerate should accept a set as an input?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I followed a Django tutorial and the tutor didn't talk about the need for a Virtual Env. He deployed via Digital Ocean.  I am trying to use Heroku but just found out that I ought to have activated a Virtual Env prior to the start of my Django project.\nDo I have to redo the  Django project  with a Vir Env or I can just go ahead to activate the Env and still deploy?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":497,"Q_Id":62945004,"Users Score":0,"Answer":"Yes i think you can, but having a virtual environment is good practise. :) sorry if i wrong i'm new to all this.","Q_Score":0,"Tags":"python,django,heroku","A_Id":62945089,"CreationDate":"2020-07-16T23:34:00.000","Title":"Can I deploy to Heroku without a Virtual Environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to read the pdf and highlight some sub-strings in pdf, and i am able to achieve it using python libraries PYPDF2 and fitz\nbut i wanted to make to highlight\/ change text with different colors and retain the layout of the original pdf,\nplease advice on this, thank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":680,"Q_Id":62947552,"Users Score":-1,"Answer":"We can't change the textcolor of words inside the pdf but we can use the\n\nhighlight annot\n\nwith default color(\"yellow\"),\nif need more colors we need to make the\n\nsquare annot\n\nusing pymupdf lib, this worked for me in python","Q_Score":1,"Tags":"python-3.x,pdf,colors,highlight","A_Id":63137539,"CreationDate":"2020-07-17T05:20:00.000","Title":"change text color or highlight text with multiple colors using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a aggregated data table in bigquery that has millions of rows. This table is growing everyday.\nI need a way to get 1 row from this aggregate table in milliseconds to append data in real time event.\nWhat is the best way to tackle this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":62947589,"Users Score":0,"Answer":"BigQuery is not build to respond in miliseconds, so you need an other solution in between. It is perfectly fine to use BigQuery to do the large aggregration calculation. But you should never serve directly from BQ where response time is an issue of miliseconds.\nAlso be aware, that, if this is an web application for example, many reloads of a page, could cost you lots of money.. as you pay per Query.\nThere are many architectual solution to fix such issues, but what you should use is hard to tell without any project context and objectives.\nFor realtime data we often use PubSub to connect somewhere in between, but that might be an issue if the (near) realtime demand is an aggregrate.\nYou could also use materialized views concept, by exporting the aggregrated data to a sub component. For example cloud storage -> pubsub , or a SQL Instance \/ Memory store.. or any other kind of microservice.","Q_Score":0,"Tags":"python,jenkins,google-bigquery,real-time,data-dump","A_Id":62949198,"CreationDate":"2020-07-17T05:23:00.000","Title":"How to get individual row from bigquery table less then a second?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"if I print the string in command prompt I I'm getting it i proper structure\n\"connectionstring\".\"\".\"OT\".\"ORDERS\".\"SALESMAN_ID\"\nbut when I write it to json, I'm getting it in below format\n\\\"connectionstring\\\".\\\"\\\".\\\"OT\\\".\\\"ORDERS\\\".\\\"SALESMAN_ID\\\"\nhow to remove those escape characters?\nwhen It's happening?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":62948417,"Users Score":0,"Answer":"What is happening?\nJson serialization and de-serialization is happening.\nFrom wikipedia:\nIn the context of data storage, serialization (or serialisation) is the process of translating data structures or object state into a format that can be stored (for example, in a file or memory buffer) or transmitted (for example, across a network connection link) and reconstructed later. [...]\nThe opposite operation, extracting a data structure from a series of bytes, is deserialization.\nIn console, you de-serialize the json but when storing in file, you serialize the json.","Q_Score":0,"Tags":"json,python-3.x,string","A_Id":62948604,"CreationDate":"2020-07-17T06:35:00.000","Title":"how to get proper formatted string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let us say, a gRPC client makes two requests R1 and R2 to gRPC server, one after the other (assume without any significant time gap, i.e R2 is made when R1 is still not served). Also, assume that R1 takes much more time than R2.\nIn this case, should I expect R2's response first as it takes less time or should I expect R1's response first as this request is made prior to R2? What will happen and why?\nAs far as what I have observed, I think requests are served in FCFS fashion, so, R1's response will be received by the client first and then R2's, but I am not sure.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":3160,"Q_Id":62949357,"Users Score":2,"Answer":"Theoretically nothing discourages server and client process gRPC requests in parallel. GRPC connection is made over HTTP\/2 one that can handle multiple requests at once. So yes - if server doesn't use some specific synchronization or limitation mechanisms then requests would be processes with overlapping. If server resources or policy doesn't allow it then they should be processed one by one. Also I can add than request can have a Timeout after which it would be cancelled. So long wait can lead to cancellation and non-processing at all.","Q_Score":0,"Tags":"web,protocol-buffers,grpc,rpc,grpc-python","A_Id":62951845,"CreationDate":"2020-07-17T07:42:00.000","Title":"How does gRPC handle multiple overlapping requests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let us say, a gRPC client makes two requests R1 and R2 to gRPC server, one after the other (assume without any significant time gap, i.e R2 is made when R1 is still not served). Also, assume that R1 takes much more time than R2.\nIn this case, should I expect R2's response first as it takes less time or should I expect R1's response first as this request is made prior to R2? What will happen and why?\nAs far as what I have observed, I think requests are served in FCFS fashion, so, R1's response will be received by the client first and then R2's, but I am not sure.","AnswerCount":2,"Available Count":2,"Score":-0.1973753202,"is_accepted":false,"ViewCount":3160,"Q_Id":62949357,"Users Score":-2,"Answer":"All requests should be processed in parallel. The gRPC architecture for the Java implementation for example, it is divided into 2 \"parts\":\n\nThe event loop runs in a thread work group -  It is similar to what we have to reactive implementations. One thread per core to handle the incoming requests.\n\nThe request processing is done in a dedicated thread which will be created using the CachedThreadPool system by default.\n\n\nFor single-thread languages like Javascript, I am not sure how they are doing it, but I would guess it is done in the same thread and therefore it would end up queuing the requests.","Q_Score":0,"Tags":"web,protocol-buffers,grpc,rpc,grpc-python","A_Id":63014195,"CreationDate":"2020-07-17T07:42:00.000","Title":"How does gRPC handle multiple overlapping requests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"While importing from kerastuner.engine.hyperparameters import Hyperparameters I am getting below error in the Jupyter Notebook. However while running import kerastuner as kt I am not getting any error. I am using tensorflow 2.2.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":328,"Q_Id":62949807,"Users Score":3,"Answer":"Try using this :\nfrom kerastuner.engine.hyperparameters import HyperParameters","Q_Score":0,"Tags":"python,keras,hyperparameters","A_Id":67977779,"CreationDate":"2020-07-17T08:11:00.000","Title":"ImportError: cannot import name 'Hyperparameters' from 'kerastuner.engine.hyperparameters'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to replace any number of substrings within a string, starting with dollar sign $, with a string abc?\nInput-\n\"$xyz\"\nOutput\nabc\nInput-\n'$xyz'\nOutput-\nabc\nInput-\n($xyz)\nOutput\n(abc)\nInput-\n$xyz,\nOutput-\nabc,\nInput-\n$xyz (ends with one of more of whitespaces)\nOutput-\nabc (ends with same number of whitespaces)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":62950731,"Users Score":0,"Answer":"I could actually do it now\ns1 = 'kjhs \"$radsg\" cosid 32hr ($mn) 34h8fh 340h 0 '$s' $e, $io '\nre.sub(r'('?\"?)($[^\\s,)]+)', r'abc', s1)\nHowever if this is the string, I wanted to replace all but not $a. $a will not have any preceding strings but can have preceding whitespaces---\ns1= '$a = kjhs \"$radsg\" cosid 32hr ($mn) 34h8fh 340h 0 '$s' $e, $io '","Q_Score":1,"Tags":"python,string,str-replace","A_Id":62959002,"CreationDate":"2020-07-17T09:05:00.000","Title":"Using Python how to replace any number of substrings within a string, starting with dollar sign ($), with a string \"abc\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My API code is in python. It is hosted and works perfectly when called through postman. But when I try calling the same calls through my frontend react application, most of them respond 400 Bad request. Any idea as to why is this happening?\nMy application uses amazon cognito for authentication.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":162,"Q_Id":62950954,"Users Score":0,"Answer":"My GET requests were not working because I was sending content-type: \"application\/json\" in headers which was not required. Now its working fine.","Q_Score":1,"Tags":"python,reactjs,api,amazon-cognito,http-status-code-400","A_Id":63298179,"CreationDate":"2020-07-17T09:17:00.000","Title":"Most of my APIs are returning 400 bad request error while being called on frontend","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Scenario: An end-user (untrusted) provides a string such as, \"Hello, {name}!\". On a server, I want to do string substitution on that user-provided string in the form of, my_string.format(name=\"Homer\"). There are a great many things you can do with string formatting in Python, so I'm wondering whether it is a security concern to run a format() method on an untrusted string. Is it possible to provide a string value that, when Python's string substitution is used, will alter data outside of the string content itself?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":115,"Q_Id":62952543,"Users Score":2,"Answer":"String formatting is safe in a way that it does not have side effects. It won't change anything outside of that string.\nIt can still be a security issue depending on what you do with that string later on. The most obvious example is using string formatting for SQL statements; That's horrendously unsafe.","Q_Score":4,"Tags":"python,security","A_Id":62952626,"CreationDate":"2020-07-17T10:56:00.000","Title":"Is it safe\/secure to run .format() on user-provided strings in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset (Tiny ImageNet) where the images are 64 x 64 but I want to use the pre-trained model: InceptionResNetV2 since the accuracy on all other models is low.\nCan I double the dimensions in target_size to 128, 128 in the image_gen.flow_from_dataframe function and use the output in the InceptionResNetV2?\nWill doubling the target size influence the training? I mean will it stretch the images or add blank space around them.\nIs this way appropriate or is there a better way to train tiny images using InceptionResNetV2?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":183,"Q_Id":62953272,"Users Score":1,"Answer":"You can either define input image size in ImageDataGenerator (target_size=(224,224)) or in tf.keras.layers.Input( shape=input_shape ) part.","Q_Score":1,"Tags":"python,keras","A_Id":62953368,"CreationDate":"2020-07-17T11:44:00.000","Title":"Target_size image_gen.flow_from_dataframe InceptionResNetV2 (Keras) for smaller images","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a bit idea hovering over my head.\nknn is a lazy eval algorithm, so the data in the backend must be stored with categories.\nI wanted to build a visual feedback where if we modify a point, any new prediction is based on the updated data. Is it possible to modify that information stored in backend?\nIs it possible for knn to reference data from an external database, or do we need to retrain the model from start","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":62953376,"Users Score":1,"Answer":"You will have to re-generate the model if there is an update in the training data since the calculation for kth neighbor will change.","Q_Score":0,"Tags":"python,python-3.x,knn","A_Id":62953517,"CreationDate":"2020-07-17T11:51:00.000","Title":"knn realtime update based on feedback","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"About the data :\nwe have 2 video files which are same and audio of these files is also same but they differ in quality.\nthat is one is in 128kbps and 320kbps respectively.\nwe have used ffmpeg to extract the audio from video, and generated the hash values for both the audio file using the code : ffmpeg -loglevel error -i 320kbps.wav -map 0 -f hash -\nthe output was : SHA256=4c77a4a73f9fa99ee219f0019e99a367c4ab72242623f10d1dc35d12f3be726c\nsimilarly we did it for another audio file to which we have to compare ,\nC:\\FFMPEG>ffmpeg -loglevel error -i 128kbps.wav -map 0 -f hash -\nSHA256=f8ca7622da40473d375765e1d4337bdf035441bbd01187b69e4d059514b2d69a\nNow we know that these audio files and hash values are different but we want to know how much different\/similar they are actually , for eg: like some distance in  a-b is say 3\ncan someone help with this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":807,"Q_Id":62953484,"Users Score":1,"Answer":"You cannot use a SHA256 hash for this. This is intentional. It would weaken the security of the hash if you could. what you suggest is akin to differential cryptoanalysis. SHA256 is a modern cryptographic hash, and designed to be safe against such attacks.","Q_Score":3,"Tags":"python,audio,ffmpeg,computer-vision,similarity","A_Id":62953553,"CreationDate":"2020-07-17T11:57:00.000","Title":"how do we check similarity between hash values of two audio files 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 found that most modern browsers support HSTS and switch over to HTTPS if they find it in the HTTP\/HTTPS headers for the domain. Browsers would implemented appropriate response to teh HSTS header.\n\nWhat about client applications that are making http\/https calls to the web servers?\nDo standard http clients like apache commons library ot python requests already support that inherently? Or some flags have to bee set? How can that be done?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":62955043,"Users Score":0,"Answer":"There's no way to answer for libraries \"like\" A or B. But typically libraries implement the protocol, but don't store any data by themselves (they have no way to persist stuff), so it'll be in the responsibility of the application using the library in question to store the HSTS information somewhere.\nUnless you're using a library that has this separate store. I'm not aware that any does (or doesn't), you'll have to check with the one that you intend to use. But my expectation is: You'll have to do it yourself.","Q_Score":0,"Tags":"python-requests,apache-commons-httpclient,hsts","A_Id":62956347,"CreationDate":"2020-07-17T13:30:00.000","Title":"Do applications have to explicitly implement action to HHTPS HSTS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I created an app successfully from a Tutorial on Web2Py but when I uploaded the application to PythonAnywhere, I received this error:\nError ticket for \"pluralsight\"\nTicket ID\n75.159.30.26.2020-07-17.15-41-34.00821419-8e86-4d99-881d-c2cb400d0e22\n<type 'exceptions.ValueError'> unsupported pickle protocol: 3\nVersion\nweb2py\u2122     Version 2.18.5-stable+timestamp.2019.04.08.04.22.03\nPython  Python 2.7.12: \/usr\/local\/bin\/uwsgi (prefix: \/usr)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":44,"Q_Id":62957442,"Users Score":1,"Answer":"It sounds like you're running web2py on Python 3 locally and with Python 2 on PythonAnywhere.  The best solution would be to upgrade it on PythonAnywhere:\n\nMake sure that you're using the most recent version of web2py itself by upgrading it from the main admin page inside your hosted web2py.\nOnce it's fully upgraded, go to the \"Web\" page inside PythonAnywhere and change the Python version to the version of Python 3 that matches the one that you're using locally (eg. 3.7 or 3.8)\nReload the site using the green button at the top of the \"Web\" page inside PythonAnywhere.\n\nThen you should be able to upload your app.","Q_Score":0,"Tags":"web2py,pythonanywhere","A_Id":62993464,"CreationDate":"2020-07-17T15:46:00.000","Title":"Why would a Web2Py website work locally but give me errors when I upload it to PythonAnywhere? How would I fix an error I don't get locally?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to train a Deep Neural Network (DNN) with labeled data. The labels are encoded in such a way that it only contains values 0 and 1. The shape of the encoded label is 5 x 5 x 232. About 95%  of values in the label is 0and rests are 1. Currently, I am using binary_crossentroy loss function to train the network.\nWhat is the best technique to train the DNN in such a scenario? Is the choice of binary_crossentroy\nas the loss function is appropriate in this case? Any suggestion to improve the performance of the model.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":50,"Q_Id":62957768,"Users Score":1,"Answer":"You can try MSE loss. If you want to stick to binary cross-entropy (used in binary classification), consider using label smoothing.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,conv-neural-network","A_Id":62958032,"CreationDate":"2020-07-17T16:06:00.000","Title":"How to perform supervised training of a deep neural network when the target label has only 0 and 1?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to train a Deep Neural Network (DNN) with labeled data. The labels are encoded in such a way that it only contains values 0 and 1. The shape of the encoded label is 5 x 5 x 232. About 95%  of values in the label is 0and rests are 1. Currently, I am using binary_crossentroy loss function to train the network.\nWhat is the best technique to train the DNN in such a scenario? Is the choice of binary_crossentroy\nas the loss function is appropriate in this case? Any suggestion to improve the performance of the model.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":62957768,"Users Score":0,"Answer":"In such scenarios where you have highly imbalanced data, I would suggest going with Random Forest with up-Sampling. This approach will up-sample the minority class and hence improve the model accuracy.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,conv-neural-network","A_Id":62960030,"CreationDate":"2020-07-17T16:06:00.000","Title":"How to perform supervised training of a deep neural network when the target label has only 0 and 1?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm typing django-admin.py startproject project in my vscode terminal on windows, but when I do it just flashes a screen then closes and the project isn't created. It asked me what to open with and I chose python, but the command doesn't do anything. I'm not getting errors either","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":133,"Q_Id":62958371,"Users Score":0,"Answer":"I was using django-admin.py instead of django-admin, problem is solved","Q_Score":1,"Tags":"python,django,visual-studio-code","A_Id":62958406,"CreationDate":"2020-07-17T16:45:00.000","Title":"django-admin.py does nothing when I execute it in visual studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have query generated by SQLAlchemy that is craeting long aliases. Is there a way to solve \"ORA-00972: identifier is too long\" from Python side?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":302,"Q_Id":62958462,"Users Score":0,"Answer":"What is the Oracle DB that you are using,  can you please send us the sample of the the query that you are using, maybe in the query you can create an alias which is less than the maximum length for the column name.","Q_Score":0,"Tags":"python,oracle,sqlalchemy","A_Id":63005612,"CreationDate":"2020-07-17T16:50:00.000","Title":"SQLAlchemy Oracle: ORA-00972: identifier is too long","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This seems like a basic question, but I can't seem to find a setting\/process for it.\nIn VSCode's Python extension, there is an option to right-click (or keyboard shortcut) in the editor and Run Current File in Python Interactive Window.  This works great.\nIs there a way to Run Main File in Python Interactive Window so to speak? If you are building a package\/module and are making changing in a non-main file, you currently need to switch back to that main file editor tab before running it as described above.\nIt would be nice to link module\/package files to run the main file from anywhere in the package and not have to switch files in the editor.  This would make building\/debugging a separate module file much faster using the Python Interactive Window. Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2069,"Q_Id":62958691,"Users Score":0,"Answer":"Create a launch option that names the main python file instead of the current file and choose it in the debug\/run sidebar.\nYou might need to set the cwd property to the correct value.\nNow when you press F5 the main python file is run.","Q_Score":0,"Tags":"python-3.x,visual-studio-code,vscode-python","A_Id":62960169,"CreationDate":"2020-07-17T17:06:00.000","Title":"Python VSCode: Run Main file in Python Interactive Window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on an application that runs on different platforms like Windows, Ubuntu and Raspberry Pi. Think of it as a webapp served by a Python Flask server. So far I have been running the app on Ubuntu. I want to port the code and make the app run on Windows and Raspberry Pi as well.\nThis is what's common among all platforms - the core part of the app, the flask server remains unchanged along with the UI code\nThis is what's different - the data and the functionalities. If Ubuntu and Windows version of the app has a dozen features, the one for Raspberry Pi will have only half of those. The data that is needed for the functionalities also changes accordingly. Another notable change is utility functions. For ex: I will have to use different Text-to-Speech programs on each of these platforms.\nIt works if I create separate repos for each. I want to know what the development and code management process for such a scenario will be like. Below are the thoughts I have on mind which I feel I could try out:\n\nSeparate repos for supporting each platform\nSingle repo with different folders for each\nSingle repo with common code separated out(I'm not sure if this is doable)\nDifferent branches for each platform support\n\nWould love to know what the standard procedure is for such a development activity and how usual each of the above 4 approaches are(especially 4). Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":62958785,"Users Score":0,"Answer":"Usually what one does is either some sort of feature checking or abstraction, or both.  For example, you can write an interface for text to speech and then provide an implementation for each platform.  Similarly, you can do a feature check for feature foo and then define it as absent or present on each platform.\nThis is the approach most codebases use, and it maintains better compatibility across versions than separate repos.  Using separate branches means you'll likely end up with a lot of conflicts merging features into various branches.\nIt may be that some platform-specific or feature-specific code will live in separate files or folders, and that's necessary and okay.  It may be desirable to isolate that code so it doesn't load dependencies that don't exist, for example.  But you will want to share most of the code as much as possible with uniform interfaces.\nBy making it feature based, you focus on the features available, so if the Raspberry Pi becomes more capable, then you just turn on the feature.  Similarly, if you decide you want to support macOS, you can just find out what features that OS can support and turn those on.  Similarly, you can add an abstraction for the native text-to-speech layer on macOS, and then flip that feature as well.","Q_Score":0,"Tags":"python,version-control,raspberry-pi,repository,cross-platform","A_Id":62986689,"CreationDate":"2020-07-17T17:12:00.000","Title":"Maintain source code of app that runs on different platforms","Data Science and Machine Learning":0,"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":"depth camera: intel realsense D415\nlanguage: python\nI am trying to get the z coordinate of a depth point in the world coordinate system. I am wondering if there's an embedded method or if there is a way to obtain that?\nThank you in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":485,"Q_Id":62959286,"Users Score":0,"Answer":"It sounds like you want to use a separate and fixed object in the scene as a reference, e.g. a table supporting your objects of interest.\nFinding the 3D plane of the table is usually easy: you use some robust fitting algorithm along with reasonable priors (e.g. the largest plane, or the largest plane approximately oriented in a known way with respect to the camera).\nFinding a plane, however, only gives you a \"z\" direction orthogonal to it, plus a translation vector to a point on the plane which may not be a desirable one. So you need a way to identify some desirable \"origin\" point in the point cloud. This is usually done using an object (a.k.a. \"calibration jig\" or \"rig\") of known shape that can easily be identified and precisely fit to a model. For example, a billiard ball (fit a sphere, find the center, offset by the radius to the contact point with the plane), or a cone (find the center of the base), etc. Note that using a conical jig allows to find both plane and point in one shot.","Q_Score":0,"Tags":"python,computer-vision,realsense","A_Id":62987329,"CreationDate":"2020-07-17T17:47:00.000","Title":"How to get the depth coordinate in the world system from the depth camera","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I successfully configured gurobi on centos 7 and it works if I try gurobi_cl on a test.lp file where the test.lp file contains just one line:\nMinimize\nNow i try to import gurobi from a script that is launched from httpd an I get this error:\nFrom gurobi import *\nFile\"\/usr\/lib\/python2.7\/site-packages\/gurobipy\/init.py\" line 1 in \nFrom .gurobi import *\nImportError: libgurobi90.so: cannot open shared object file:\nNo such file or directory\nI am using gurobi9.0.1 and python 3.7 and I don't know why gurobi is calling python 2.7 in the log below.\nCould you please help me?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":62959519,"Users Score":0,"Answer":"Solved the problem. I had to add gurobi_pi.conf under old.so.conf containing the path to my gurobi folder\n\nldconfig","Q_Score":0,"Tags":"python-3.x,httpd.conf,gurobi","A_Id":62959715,"CreationDate":"2020-07-17T18:04:00.000","Title":"Problem when importing gurobi through httpd","Data Science and Machine Learning":0,"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 how could I add dynamically some widgets in my application one by one and not all at once. Those widgets are added in a for loop which contains the add_widget() command, and is triggered by a button.\nSo I would like to know if there is a way for the output to be shown gradually, and not all at once, in the end of the execution. Initially I tried to add a delay inside the for loop, but I'm afraid it has to do with the way the output is built each time.\nEDIT: Well, it seems that I hadn't understood well the use of Clock.schedule_interval and Clock.schedule_once, so what I had tried with them (or with time.sleep) didn't succeed at all. But obviously, this was the solution to my problem.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":62960795,"Users Score":1,"Answer":"Use Clock.schedule_interval or Clock.schedule_once to schedule each iteration of the loop at your desired time spacing.","Q_Score":1,"Tags":"python,kivy","A_Id":62961297,"CreationDate":"2020-07-17T19:42:00.000","Title":"Add Kivy Widgets Gradually","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I load the BERT pretrained model online I get this error OSError: Error no file named ['pytorch_model.bin', 'tf_model.h5', 'model.ckpt.index'] found in directory uncased_L-12_H-768_A-12 or 'from_tf' set to False what should I do?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":4569,"Q_Id":62961627,"Users Score":1,"Answer":"These are the pretrained model files. You can download them from the repository, you have taken the code from if provided. If its HuggingFace you are using, you can get these on their site.","Q_Score":4,"Tags":"python,tensorflow,pytorch,bert-language-model","A_Id":62962289,"CreationDate":"2020-07-17T20:52:00.000","Title":"OSError: Error no file named ['pytorch_model.bin', 'tf_model.h5', 'model.ckpt.index']","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating a like comment and reply feature using Flask. I have two options:\n\nif a user likes comment, variable will increase by 1, Code: like = like + 1, and it will be updated in the database. The total count will be retrieved by something like {{ like }} in jinja template\n\nor\n\nSaving yes for the comment id in the database, then use .count() to retrieve the total likes.\n\nWhich would you recommend and why, thank you!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":81,"Q_Id":62962059,"Users Score":2,"Answer":"I'm not an expert but I think if you have the like and unlike button then you just do\nlike = like + 1 #in case of like \nlike = like - 1 #in case of unliking\nBecause the .count() function works in a Time complexity of O(length of yes's array) but if you always updated you can access the like count in O(1)","Q_Score":1,"Tags":"python,flask,jinja2","A_Id":62962156,"CreationDate":"2020-07-17T21:35:00.000","Title":"count() vs count = count + 1 in Flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Per title. I do not understand why it is not valid. I understand that they mutate the object, but if you call the sort method, after it's done then you'd call the reverse method so it should be fine. Why is it then that I need to type lst.sort() then on the line below, lst.reverse()?\nEdit: Well, when it's pointed out like that, it's a bit embarrassing how I didn't get it before. I literally recognize that it mutated the object and thus returns a None, but I suppose it didn't register that also meant that you can't reverse a None-type object.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":198,"Q_Id":62963707,"Users Score":1,"Answer":"When you call lst.sort(), it does not return anything, it changes the list itself.\nSo the result of lst.sort() is None, thus you try to reverse None which is impossible.","Q_Score":0,"Tags":"python,python-3.x,list,function,methods","A_Id":62963730,"CreationDate":"2020-07-18T01:31:00.000","Title":"Why isn't lst.sort().reverse() valid?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a boolean numpy array which I need to convert it to binary, therefore where there is true it should be 255 and where it is false it should be 0.\nCan someone point me out how to write the code?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1440,"Q_Id":62965151,"Users Score":0,"Answer":"Let x be your data in numpy array Boolean format.\nTry\nnp.where(x,255,0)","Q_Score":0,"Tags":"python,numpy","A_Id":62965290,"CreationDate":"2020-07-18T05:52:00.000","Title":"Converting numpy boolean array to binary array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My mac has python3 and python2 installed by default.\nBefore now, only python3 and pip3 commands were working on the macOS terminal. But when I upgraded my pip pip3 install --upgrade pip, my pip command works as well, and when I type python --version it shows 2.7.16. Although I still have python3 installed, I don't like having python2. Can I uninstall python2 or is it just not possible?\nKeep in mind that the python --version command showed an error before I upgraded pip","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":315,"Q_Id":62966955,"Users Score":0,"Answer":"If Python 2 was installed onto your Mac by default, do NOT try to remove it as it is not possible, and could break your entire operating system.","Q_Score":0,"Tags":"python,python-3.x,macos,terminal","A_Id":62967032,"CreationDate":"2020-07-18T09:36:00.000","Title":"Can I uninstall python2 from macos?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"My mac has python3 and python2 installed by default.\nBefore now, only python3 and pip3 commands were working on the macOS terminal. But when I upgraded my pip pip3 install --upgrade pip, my pip command works as well, and when I type python --version it shows 2.7.16. Although I still have python3 installed, I don't like having python2. Can I uninstall python2 or is it just not possible?\nKeep in mind that the python --version command showed an error before I upgraded pip","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":315,"Q_Id":62966955,"Users Score":0,"Answer":"As @GavinWong said, do not try to remove Python 2 from your Mac. Some of the scripts used by the operating system are written in Python 2 and hence Python 2 must be available for Mac to fubtion properly.","Q_Score":0,"Tags":"python,python-3.x,macos,terminal","A_Id":62971156,"CreationDate":"2020-07-18T09:36:00.000","Title":"Can I uninstall python2 from macos?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"hello I noticed that some of the libraries I use are used for development but also for analysis and sometimes I have to use both is there a way to use a basic virtual environment as in the templates and can I use the two libraries a few times simultaneously","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":62967434,"Users Score":0,"Answer":"Yes of course you can use multiple virtual environments. You need to create virtual envs. If you're already aware of anaconda env, you can create virtual envs with them else you can go in the normal way of creating venvs.\nAfter creating them, have 2 terminals each for each venv. Run your scripts.","Q_Score":0,"Tags":"python-3.x","A_Id":62968057,"CreationDate":"2020-07-18T10:26:00.000","Title":"possibility of using several virtual environments simultaneously","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"hello I noticed that some of the libraries I use are used for development but also for analysis and sometimes I have to use both is there a way to use a basic virtual environment as in the templates and can I use the two libraries a few times simultaneously","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":27,"Q_Id":62967434,"Users Score":0,"Answer":"Yes.\n\nCreate two virtual environments.\n\nCall them v1 and v2\n\nOpen terminal x 2\n\nFirst terminal - activate v1 and install your library 1\n\nSecond terminal - activate v2 and install your library 1","Q_Score":0,"Tags":"python-3.x","A_Id":62967469,"CreationDate":"2020-07-18T10:26:00.000","Title":"possibility of using several virtual environments simultaneously","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to assign NaN to values in a column that can not be changed from str to int. For example, 04 can be changed to int while Or can not be.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":40,"Q_Id":62968414,"Users Score":1,"Answer":"you can use  .isdigit() to check first the value and then convert it to int","Q_Score":1,"Tags":"python,data-wrangling","A_Id":62968484,"CreationDate":"2020-07-18T12:10:00.000","Title":"Turning values that can not be changed from str to int into nan value in a column","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I an new to code and I would like to know whether it is possible to upload multiple excel documents into one dataset using python? If so, what is the code for this? All of the code I have seen is used for uploading one single excel document. Moreover, do I have to convert the data into CSV form first or I can use code to convert it into CSV after uploading it?\nI am using jupyter notebook in anaconda to run my python code.\nYour assistance is greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":35,"Q_Id":62968420,"Users Score":1,"Answer":"By uploading, do you mean reading a file? If so, just create a list or dictionary, open the files and write them 1 by 1 into your list \/ dictionary. Also, it would be really helpful creating CSV files first. If you want to do it manually you can easily by saving the file as CSV in Excel.","Q_Score":0,"Tags":"python,csv","A_Id":62969927,"CreationDate":"2020-07-18T12:11:00.000","Title":"How to upload multiple excel documents into one dataset using python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a tree structure\n\n - My_app    \n   - __init__.py\n   - main.py\n   - Cus_Scripts  \n      - __init__.py\n      - script1.py\n      - script2.py - classA\n\nI am running like this\n\nmain.py has import Cus_Scripts.script1\nscript1.py has from script2 import classA\n\nin script1 I get a ModuleNotFoundError saying it can't find script2.  I am using VSC.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":114,"Q_Id":62968665,"Users Score":1,"Answer":"I fixed this by adding this to every file.\n\n\n#Custom Lib\nsys.path.insert(1, os.getcwd())\n\n\nThis allowed me to access anypart of the program with\n\n\nfrom My_App.script2 import classA\nimport My_App.script1","Q_Score":0,"Tags":"python-3.x,python-module","A_Id":62970579,"CreationDate":"2020-07-18T12:37:00.000","Title":"Getting a ModuleNotFoundError when trying to load a Python Module and all seems ok","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed pip on my windows 10 with python 3.8.3 already there. The command prompt displays the message 'successfully installed pip latest version'.I have checked in the environment variables and done what was needed through tutorials. After that it stopped saying that:\n pip is not recognized as an internal or external program or batch file\nBut then when I entered 'pip --version' in the command prompt, it said invalid syntax.\nI downloaded the get-pip.py file too, ran it and it installed all the dependencies and everything but the command prompt still said invalid syntax.\nWhat should I do? I am a new  self-taught programmer. Help please.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":62968891,"Users Score":0,"Answer":"I would suggest you that you try ensurepip command first and then try to check the version using:\npython -m ensurepip --user\npython -m pip --version\nThe ensurepip should fix your installation problems if any.\nIf ensurepip takes you back to the older installation, use the below command to upgrade it:\npython -m pip install --user --upgrade pip","Q_Score":1,"Tags":"python,windows,pip","A_Id":62969101,"CreationDate":"2020-07-18T13:01:00.000","Title":"I have problems running pip after installing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like more info. on the answer to the following question:\n\ndf[\u2018Name\u2019] and 2. df.loc[:, \u2018Name\u2019], where:\n\ndf = pd.DataFrame(['aa', 'bb', 'xx', 'uu'], [21, 16, 50, 33], columns = ['Name', 'Age'])\nChoose the correct option:\n\n1 is the view of original dataframe and 2 is a copy of original\ndataframe\n2 is the view of original dataframe and 1 is a copy of\noriginal dataframe\nBoth are copies of original dataframe\nBoth are views of original dataframe\n\nI found more than one answer online but not sure. I think the answer is number 2 but when i tried x = df['name'] then x[0] = 'cc' then print(df) I saw that the change appeared in the original dataframe. So how the changed appeared in the original dataframe although I also got this warining:\nA value is trying to be set on a copy of a slice from a DataFrame\nI just want to know more about the difference between the two and weather one is really a copy of the original dataframe or not. Thank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":693,"Q_Id":62970683,"Users Score":0,"Answer":"Both are the views of original dataframe\nOne can be used to add more columns in dataframe and one is used for specifically getting a view of a cell or row or column in dataframe.","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":62970716,"CreationDate":"2020-07-18T16:00:00.000","Title":"df['colimn_name'] vs df.loc[:, 'colimn_name']","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on tensorflow and my dataset is composed only by Black and White images, so I thought that I could make my neural net (currently I am using Resnet50) less heavy and easier to train and test by changing the number of channels from 3 to 1,\nIs there a way to do so?\n(Ik I can treat b\/w images as rgb images but I don't want to do that)\nThanks in advance for the answer","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3133,"Q_Id":62971655,"Users Score":0,"Answer":"The pretrained weights in keras.applications require a 3 channel input. You could one of two things:\n\nUse a different pretrained model that works on grayscale images.\nSet the R, G and B channels to replicate your BW input, then fine-tune the entire neural network on your own dataset. This probably won't work without the fine-tuning step.\n\nOn a side note, I must say this task will not help in your goal of making it 'less heavy and easier to train and test'. If you call model.summary() on keras Resnet50, you see that of the total trainable 23,534,592 parameters, only about 10K of them are in the initial layer. So at best you can reduce the number of parameters by an insignificant few thousand.\nI would instead suggest using a lighter model such as MobileNet that are also available in Keras.","Q_Score":2,"Tags":"python,tensorflow,keras,artificial-intelligence,conv-neural-network","A_Id":62972371,"CreationDate":"2020-07-18T17:33:00.000","Title":"How can I change number of channels on Resnet to make it work only on B\/W images?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"E.g. given the string 'Parallel' I would like to get the set {'P', 'a', 'e', 'l', 'r'}\nI tried this:\ns = set({'Parallel'}) but it does not compute the correct set.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":745,"Q_Id":62972046,"Users Score":2,"Answer":"You don't need curly braces around the word, since that would refer to the unit set {'Mississippi'}. Use set('Mississippi') to get the distinct letters of the string 'Mississippi'.","Q_Score":0,"Tags":"python,set","A_Id":62972079,"CreationDate":"2020-07-18T18:02:00.000","Title":"How can I compute the set of unique characters of a string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"E.g. given the string 'Parallel' I would like to get the set {'P', 'a', 'e', 'l', 'r'}\nI tried this:\ns = set({'Parallel'}) but it does not compute the correct set.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":745,"Q_Id":62972046,"Users Score":1,"Answer":"What you did was wrong. You actually created a set within a set. Do this\nset(\"Missisippi\")","Q_Score":0,"Tags":"python,set","A_Id":62972108,"CreationDate":"2020-07-18T18:02:00.000","Title":"How can I compute the set of unique characters of a string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Not an important question, I know, but just a silly side project a friend asked of me. Is there a way I can read and alter the inputs from a drawing tablet so that I can use it in a First Person Shooter game, using something like Python.\nFrom what I know, the pen will set the mouse position to the location corresponding to the tablet, which causes you to stare at the ground and spin, verses a mouse changing the current location of the mouse, which is what a game is expecting.\nMy plan is to read the location of the pen compared to the last location, have the mouse moved to that location on the screen, instead of set to the location.\nAny tips or guidance is appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":228,"Q_Id":62974164,"Users Score":0,"Answer":"It is already possible, if you change the drawing tablet input mode from absolute to relative","Q_Score":0,"Tags":"python,input","A_Id":66992404,"CreationDate":"2020-07-18T21:52:00.000","Title":"Reading and Altering Drawing Tablet inputs for use in FPS games","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here is the example:\nreview: I love you very much... reviewer:jackson review: I hate you very much... reviewer:madden review: sky is pink and i ... reviewer: tom\ni want extract the string between string review: and ...\nSo above situation's extraction is\nI love you very much\nI hate you very much\nsky is pink and i \ni use this kind of regex but fail\nre.findall(\"review(.*)...\",string)\nit extract this kind of outcome:\nI love you very much... reviewer:jackson review: I hate you very much... reviewer:madden review: sky is pink and i","AnswerCount":5,"Available Count":1,"Score":-0.0399786803,"is_accepted":false,"ViewCount":55,"Q_Id":62975853,"Users Score":-1,"Answer":"Sorry\ni forget to add \\ in front of  .\nand the right one is:\nre.findall(\"review:\\b?(.*)\\.\\.\\.\",string)\nand this time , it counts","Q_Score":1,"Tags":"python,regex","A_Id":62975884,"CreationDate":"2020-07-19T03:13:00.000","Title":"How to get specific string in two subtring in python regex?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a data frame in hand, now i want to add one more column in that data frame. that column will be a set of lists, ie, if the length of the data frame is 10, the column will be set of 10 lists. Each row associate with one list. How can i make this? And initially those lists will be blank list so that i can append objects further.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":62976640,"Users Score":0,"Answer":"I can give the answer of my question i think.\nSuppose i have a dataset called XYZ, It has @ column A,B. Now i want to add one more column C which is a set of lists ie, there are same number of lists as number of rows.\nXYZ = pd.read_csv('untitled.csv', usecols = ['A', 'B']) XYZ['C'] = pd.Series([]*len(XYZ), dtype = object) for i in range(len(XYZ)): XYZ['C'][i] = []","Q_Score":0,"Tags":"python-3.x,list,dataframe","A_Id":63017034,"CreationDate":"2020-07-19T05:28:00.000","Title":"How to make a column of set of lists in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a matrix inside a for loop (one column at a time).\nWhich is the faster way to do it? creating a np.empty() array and using np.hstack() to append the columns, or creating a np.zeros() array of the desired shape and changing the columns of the array.\nTIA","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":178,"Q_Id":62976800,"Users Score":1,"Answer":"np.zeros() be faster when the size is big enough that the array operations are significant.\nThe reason for that is that numpy arrays are stored continuously in one big block of memory. Allocating memory for the array takes time. When using hstack you continuously need to grow the memory for the array, which means re-allocating the memory and copying all the data to the new place, making this essentially an O(n^2) operation. Pre-allocating with np.zeros saves you this time.","Q_Score":2,"Tags":"python,numpy","A_Id":62977201,"CreationDate":"2020-07-19T05:56:00.000","Title":"What is faster for creatin a matrix, using np.hstack (or np.vstack) inside a for loop, or changing the columns of a previously created np.zeros array?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In order to identify smelly code I'd like to run pylint as if there were no # pylint: disable=* instructions (e.g. pylint: disable=broad-except).\nIs it possible to disable disable itself on command line?\nOf course I could create a temporary file with all # pylint: disable instructions removed but maybe pylint is smart enough to have this built in..","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":331,"Q_Id":62978081,"Users Score":1,"Answer":"I believe one of the following could help:\n\npylint --enable=locally-disabled module.py\npylint --enable=suppressed-message module.py\npylint --enable=all module.py","Q_Score":2,"Tags":"python,pylint","A_Id":62978911,"CreationDate":"2020-07-19T08:46:00.000","Title":"Is it possible to run pylint with ignore of \"# pylint: disable=\" instructions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been reading about in-memory databases and how they use RAM instead of disk-storage.\nI'm trying to understand the pros and cons of building an in-memory database with different programming languages, particularly Java and Python. What would each implementation offer in terms of speed, efficiency, memory management and garbage collection?\nI think I could write a program in Python faster, but I'm not sure what additional benefits it would generate.\nI would imagine the language with a faster or more efficient memory management \/ garbage collection algorithm would be a better system to use because that would free up resources for my in-memory database. From my basic understanding I think Java's algorithm might be more efficient that Python's at freeing up memory. Would this be a correct assumption?\nCheers","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":136,"Q_Id":62979966,"Users Score":0,"Answer":"You choose an in-memory database for performance, right? An in-memory database written in C\/C++ and that provides an API for Java and\/or Python won't have GC issues. Many (most?) financial systems are sensitive to latency and 'jitter'. GC exacerbates jitter.","Q_Score":0,"Tags":"java,python,database,in-memory-database","A_Id":63001365,"CreationDate":"2020-07-19T11:57:00.000","Title":"In-memory database and programming language memory management \/ garbage collection","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am writing a rest api in flask to read data from some json files, turn them to pandas dataframes, read and\/or edit data from the data frames. When I turn the jsons into dataframes I want to make sure that any finite number of computers that access the api now has access to the same dataframes, and assuming computer A edits a data frame(maybe deletes a column called \"names\") , then when computers B-Z try to access the names column in tbe data frame it should also be gone for them. How do I achieve this in a flask emvironment. i already tried reading the files and declaring the dataframes at the start of the flask app but when i looked online for a bit i found that it's bad practice to  use global varibles in flask. All the help i found siggested using sessions, but that would mean the changes computer A makes to the dataframe, will be visible to only computer A unless it saves back to the json file and all other computer B-Z re-read from the Json. Thanks for your help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":62980318,"Users Score":0,"Answer":"You should use a database to achieve that, if your project is not big, SQLite should be enough, and Flask-SQLAlchemy would be a good choice to make the persistent work easier.","Q_Score":0,"Tags":"python,session,flask","A_Id":62982003,"CreationDate":"2020-07-19T12:30:00.000","Title":"How to make a variable available accross all open flask sessions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I got this error while I tried to install Xilinx Petalinux on Ubuntu 20.04\n\ndpkg-query: package 'python' is not installed and no information is available\nUse dpkg --info (= dpkg-deb --info) to examine archive files\nERROR: You have tools don't meet the version requirements:\n-Detected python version is less than the expected 2.7.3\n\nI reinstalled python several times, it didn't work out.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":3223,"Q_Id":62980416,"Users Score":3,"Answer":"I installed petalinux on Ubuntu 20.04\nI had the same issue as you describe. The issue is how petalinux installer checks for version of python using dpkg and a renaming of package python to python2.7\nI resolved by ensuring I installed python2 e.g.\nsudo apt-get install python2.7-minimal:i386\nor\nsudo apt-get install python2.7-minimal:amd64\n(I did both by mistake!)\nthen I tricked dpkg into thinking \"python\" was installed by copying the section called Package: python2.7\nand renaming to:-\nPackage: python\nin file \/var\/lib\/dpkg\/status\nThis 'hack' enables dpkg to report the installed python version for installed python2.7\nThe petalinux installer, when querying the version of python, now succeeds and the installation progresses.\nHOWEVER there is a reported issue on how the script uses sed, so the final trick is to use a sed shim as reported on xilinx forum \"PetaLinux 2018.1 Install Fails on Debian Stretch\"\nok. It's a bit of a hack to convince the installer to not prematurely fail.  If there are more elegant solutions I'm interested to learn them.","Q_Score":6,"Tags":"python,xilinx,petalinux","A_Id":63306380,"CreationDate":"2020-07-19T12:39:00.000","Title":"python error when installing Xilinx Petalinux on Ubuntu 20.04","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"i would like to use nested variables inside my wtforms as:\n{{ render_field(form.date, size=32, class=\"form-control\", value=\"{{date}}\", disabled=true) }}\nOf course {{date}} will be seen as a string and just displayed. How can i pass a second variable inside a variable?\nNeed to pass the actual date inside the Input field as a value.\nThanks in advance!\nK3V1N","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":62981453,"Users Score":0,"Answer":"You should write it just like this: ..., value = date, ..., you can put any varibles directly here as it's already in the {{ }} scope.","Q_Score":0,"Tags":"python,flask,wtforms","A_Id":62981751,"CreationDate":"2020-07-19T14:19:00.000","Title":"Flask wtforms nested variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In the main page of my website there is a long list, <ul>. Each list item represents a model object. Within the list there are the objects attributes, for example its name etc, and also buttons to change those attributes. The list is loaded from the sqlite database. The issue is since each button changes data in the database, to display the changed data, the view function reloads the page on each button click. That is fine, except the list is very long, and is necessary to scroll down, and on each button click, the page is reloaded therefore goes to the very top of the list. This makes the webpage almost unusable, or at least very annoying to use.\nCan someone recommend a workaround to this problem. Please let me know if my question is not clear","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":62981982,"Users Score":1,"Answer":"It looks like what you want to achieve is something that should be done with Javascript. It will be the simplest way of doing it! For instance, you can call the corresponding API when the user clicks on one of the buttons, and if the API returns 'OK' then you can just update the item with the changes you made (because if the server returned yes, then you can assume that the local version of the data is the same than the one on the server)","Q_Score":0,"Tags":"python,django,django-models","A_Id":62982274,"CreationDate":"2020-07-19T15:05:00.000","Title":"Refreshing page on database modification","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there any way to use python libraries like pandas etc to Sikuli script? Or can I run Sikuli .py file through any python interpreter?\nI have written a script that runs through SikuliX UI using run button as well as through the command line eg C:\\Users\\*****\\Desktop\\Sikuli2\\sikulixide-2.0.4.jar -r C:\\Users\\*****\\Desktop\\Sikuli2\\Calculator.sikuli.\nI also tried from sikuli import * and from sikuli.Sikuli import * but I'm not able to run the script into any python interpreter say Jupyter.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":62982020,"Users Score":0,"Answer":"You cant use sikuli in python (for now)\nYou can use some python libraries - just try them to see if the work with jython","Q_Score":0,"Tags":"python,sikuli-x","A_Id":66341453,"CreationDate":"2020-07-19T15:08:00.000","Title":"Is there any way to use python libraries like pandas etc to Sikuli script? Or can I run Sikuli .py file through any python interpreter?","Data 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 made a website using Django and hosted on Heroku. Everything was working fine until I try to alter my one of the column in the database. The thing is that I alter the column from max_length=1000 to max_length=60 but I forgot that I have entered value more than 60 so I got django.db.utils.DataError error that value is too long for 60.\nFor this problem solution, I refer one of the solutions available in StackOverflow to remove all the migrated file from its folder except init.py and then do fresh migration. So I tried that and I work with charm and I have changed the value so it could fit the max limit.\nBut now, when I try to create new column in database it says django.db.utils.ProgrammingError django.db.utils.ProgrammingError: column \"column_name\" of relation \"table\" does not exist\nActually, when I try to run my app on the local server it works fine and even it allows me to create a new column in my database but when I try to migrate it to Heroku database it shows django.db.utils.ProgrammingError","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":62983436,"Users Score":0,"Answer":"make a backup from your server data. clean all the data on your database. delete all the migration.py files just as you read and then makemigrations and migrate again.","Q_Score":0,"Tags":"python,django,heroku","A_Id":62983485,"CreationDate":"2020-07-19T17:19:00.000","Title":"Heroku Datsbase Migration Error (django.db.utils.DataError)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Even after installing xlrd module, I am not able to read excel files using pandas, every time it's showing file directory not found. Please help!\nI am using \" import Pandas as pd\"\n\" data=pd.read_excel(\"notebook.xlsx\")\nIt shows error as file not found","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":62988750,"Users Score":0,"Answer":"Pandas is not finding the excel file. Try to put the complete path on the read_excel function like read_excel(\"C:\/documents\/notebook.xlsx\").","Q_Score":0,"Tags":"excel,pandas,python-3.8","A_Id":62989065,"CreationDate":"2020-07-20T04:37:00.000","Title":"Query regarding pandas","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have developed a python script which uses pyautogui to automate some stuff. So is it possible on windows 10 to run this script while using computer simultaneously?\nI mean when script runs, it uses mouse and keyboard so it is not possible to use computer while script is running. so is it possible to do both simultaneously?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":264,"Q_Id":62989156,"Users Score":0,"Answer":"You cannot do that !\nBecause you cannot use the mouse when it is controlled by your program.\nYou can use the keyboard but not the keys that presses by your program","Q_Score":0,"Tags":"python-3.x,pyautogui","A_Id":62989192,"CreationDate":"2020-07-20T05:29:00.000","Title":"How to use computer while running pyautogui script on windows 10?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that runs a discord bot. The bot only works when the script is running, which means that in order to use it I must constantly be running a python script which is something I don't want to do. I've looked into cloud services to deploy it on and I keep getting talk about event loops and other mumbo jumbo. Is there a safe and easy way to deploy a python script over a cloud of some sort.\nAny help is very welcome.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":167,"Q_Id":62989198,"Users Score":1,"Answer":"I personally suggest Heroku, I'm using it for running multiple scripts for free. You can use scheduler addon for scheduling scripts to run at particular time as well. Please refer to heroku documentation & get started!","Q_Score":2,"Tags":"python,python-3.x,cloud,discord.py","A_Id":62989248,"CreationDate":"2020-07-20T05:34:00.000","Title":"Can I deploy python scripts over a cloud instead of running them on my own 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 need track data of app usage using tkinter.\nthe code of the loop is....\n'''while True:\ncurrent_app = get_active_window()\nif 'Google Chrome' in current_app:\ncurrent_app = url_to_name(get_chrome_url())\ntimestamp[current_app] = int(time.time())\ntime.sleep(1)\nif current_app not in process_time.keys():\nprocess_time[current_app] = 0\nprocess_time[current_app] = process_time[current_app] + int(time.time()) - timestamp[current_app]\nprint(process_time)'''\nI need to perform this code using a button,\nbut when i start the window doesn't respond me.\nis there any method for performing while loop along with tkinter window?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":62991190,"Users Score":0,"Answer":"That comes from the mainloop() function that is in the Tkinter. You can not insert a while loop to the Tkinter program, because it will freeze it. If the freeze is not a problem for you, then you can do such a thing, but that is not recommended.","Q_Score":0,"Tags":"python,button,tkinter,while-loop","A_Id":62991206,"CreationDate":"2020-07-20T08:11:00.000","Title":"Performing while loops using a button in tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have one simple question, is there a easy way to know the type of API's response?\nFox example:\nUsing requests post method to send api requests, some apis will return data format as .xml type or .json type,\nhow can i know the response type so i can choose not to convert to .json use json() when response type is .xml?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1648,"Q_Id":62991425,"Users Score":1,"Answer":"Use r.headers.get('content-type') to get the response type","Q_Score":0,"Tags":"python-3.x,python-requests","A_Id":62991684,"CreationDate":"2020-07-20T08:27:00.000","Title":"How to know the response data type of API using requests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can you send an email from a Databricks platform?\nI would like to send an email from a notebook in Databricks with Python. I'm wondering if there's already an SMTP client already configured that I can use. I tried to do it, but didn't succeed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":62992249,"Users Score":1,"Answer":"The answer is \"no\". There's no smtp client included in Databricks.\nBut you can define yours outside and use it through the Databricks platform.","Q_Score":1,"Tags":"python,smtp,databricks","A_Id":66561871,"CreationDate":"2020-07-20T09:16:00.000","Title":"Is there a smtp client included in Databricks platform to be able to send emails?","Data Science and Machine Learning":0,"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 pip install streamlit it fails with the error message:\n\nERROR: \"Could not build wheels for pyarrow which use PEP 517 and cannot be installed directly\"\n\nI tried installing pip install pyarrow directly but still gives the same error message","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":18137,"Q_Id":62994971,"Users Score":3,"Answer":"I also faced this same issue and I noted that pyarrow is a requirement in streamlit version 0.63.0. So you can use pip install streamlit==0.62.0 and it will work just fine","Q_Score":13,"Tags":"python,streamlit","A_Id":65657966,"CreationDate":"2020-07-20T12:03:00.000","Title":"Error Installing streamlit It says \"ERROR: Could not build wheels for pyarrow which use PEP 517 and cannot be installed directly\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try pip install streamlit it fails with the error message:\n\nERROR: \"Could not build wheels for pyarrow which use PEP 517 and cannot be installed directly\"\n\nI tried installing pip install pyarrow directly but still gives the same error message","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":18137,"Q_Id":62994971,"Users Score":1,"Answer":"Streamlit Version 0.62.1 and python version 3.8.5 works fine.","Q_Score":13,"Tags":"python,streamlit","A_Id":66267481,"CreationDate":"2020-07-20T12:03:00.000","Title":"Error Installing streamlit It says \"ERROR: Could not build wheels for pyarrow which use PEP 517 and cannot be installed directly\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with Python and currently trying to figure out the following: If I place an ellipsis of which the semi-axes, the centre's location and the orientation are known, on a pixel map, and the ellipsis is large enough to cover multiple pixels, how do I figure out which pixel covers which percentage of the total area of the ellipsis? As an example, let's take a map of 10*10 pixels (i.e. interval of [0,9]) and an ellipsis with the centre at (6.5, 6.5), semi-axes of (0.5, 1.5) and an orientation angle of 30\u00b0 between the horizontal and the semi-major axis. I have honestly no idea, so any help is appreciated.\nedit: To clarify, the pixels (or cells) have an area. I know the area of the ellipsis, its position and its orientation, and I want to find out how much of its area is located within pixel 1, how much it is within pixel 2 etc.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":62998205,"Users Score":0,"Answer":"This is math problem. Try math.exchange rather than stackoverflow.\nI suggest you to transform the plane: translation to get the center in the middle, rotation to get the ellipsis's axes on the x-y ones and dilatation on x to get a circle. And then work with a circle on rhombus tiles.\nYour problem won't be less or more tractable in the new formulation but the math and code you have to work on will be slightly lighter.","Q_Score":0,"Tags":"python","A_Id":63012863,"CreationDate":"2020-07-20T14:58:00.000","Title":"Calculating how much area of an ellipsis is covered by a certain pixel in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to cache a Pyspark based data frame with 3 columns and 27 rows and this process is taking around 7-10 seconds.\nIs there anyway to accelerate this job?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":70,"Q_Id":62998750,"Users Score":2,"Answer":"You could try any of the below approaches:\n\ncoalesce your dataframe into a single partition for eg. df.coalesce(1) and then cache it\nSince your dataframe is pretty tiny you could load it as a pandas dataframe, which will be in memory. toPandas() could help you in that regards. Don't forget use the arrow spark setting to make it faster.\nspark.conf.set(\"spark.sql.execution.arrow.pyspark.enabled\", \"true\")\nspark.conf.set(\"spark.sql.execution.arrow.enabled\", \"true\")","Q_Score":0,"Tags":"python,pyspark","A_Id":63000410,"CreationDate":"2020-07-20T15:25:00.000","Title":"Is there any way to accelerate the caching process in pyspark?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to convert the following ANTsR line to ANTsPy:\nseggm[seggm < 0.5 & tmp > 0.5] <- 2  (seggm and tmp are both 'ANTsImage's)\nI have tried:\nseggm[seggm.numpy() < 0.5 & tmp.numpy() > 0.5] = 2 but this is too slow.. Is there a faster way to perform this?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13,"Q_Id":63000289,"Users Score":0,"Answer":"Whoops typed it differently in my code.. This works now!","Q_Score":0,"Tags":"python,numpy,numpy-ndarray","A_Id":63000930,"CreationDate":"2020-07-20T16:55:00.000","Title":"How do I convert ANTsR to ANTsPy image querying command?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In a project of mine I need to create an online encyclopedia. In order to do so, I need to create a page for each entry file, which are all written in Markdown, so I have to covert it to HTML before sending them to the website. I didn't want to use external libraries for this so I wrote my own python code that receives a Markdown file and returns a list with all the lines already formatted in HTML. The problem now is that I don't know how to inject this code to the template I have in Django, when I pass the list to it they are just printed like normal text. I know I could make my function write to an .html file but I don't think it's a great solution thinking about scalability.\nIs there a way to dynamically inject HTML in Django? Is there a \"better\" approach to my problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":278,"Q_Id":63000895,"Users Score":2,"Answer":"You could use the safe filter in your template! So it would look like that.\nAssuming you have your html in a string variable called my_html then in your template just write\n{{ my_html | safe }}\nAnd don\u2019t forget to import it!","Q_Score":3,"Tags":"python,html,django","A_Id":63001041,"CreationDate":"2020-07-20T17:32:00.000","Title":"How to dinamically inject HTML code in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to know if I for example wrote 100 function in a class or even without a class and only used one function in each time I call the class, Does these too many uncalled and unused functions influence the performance or count for something negative?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":109,"Q_Id":63001063,"Users Score":3,"Answer":"The answer is practically no. Chunks of code that aren't executed don't influence the performance of the program. This is true for most \/ all programming languages - not just Python.\nThat being said, there are some scenarios where this is not accurate:\n\nIf your program is very large, it may take a while to load. Once it loads, the execution time with or without the redundant code is the same, but there's a difference in load time.\nMore code may impact memory organization, which in turn may impact the OS' ability to cache stuff in an effective manner. It's an indirect impact, and unless you know exactly what you're doing it's mostly theoretical.\nIf you have a very large number of methods in a class, looking up a given method in a class' dictionary may take longer. The average cost of getting an item from a dict is O(1), but worst case can be O(N). You'll have to do a lot of optimization to (maybe) get to a point where you care about this.\nThere might be some other obscure scenarios in which code size impacts performance - but again, it's more theory than practice.","Q_Score":5,"Tags":"python,python-3.x","A_Id":63001178,"CreationDate":"2020-07-20T17:44:00.000","Title":"Do uncalled functions cost performance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When running some code I had written I was surprised to see that a function threw an exception that was not caught and so my code crashed. The thing is, Spyder never informed me that the function could even throw an exception.\nIs there a setting somewhere that I have to turn on to be informed of this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":121,"Q_Id":63002154,"Users Score":1,"Answer":"Python isn't Java. Your IDE will not warn you about uncaught exceptions, because Python's dynamic nature means that exceptions could be raised (or caught) almost anywhere and there's no amount of static analysis that'll work for every -- or even most -- cases. Often when you develop Flask or Django applications, you actually want exceptions to float all the way up to the \"root\" exception handlers.\nBottom line: No Python IDE is going to do this, and it would not be expected or considered generally desirable in Python programming.","Q_Score":1,"Tags":"python,exception,spyder","A_Id":63002535,"CreationDate":"2020-07-20T18:59:00.000","Title":"How can I know if a Python will potentially throw an exception in the Spyder IDE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a way to make n (e.g. 20) groups in a dataframe by a specific column by percentile. (data type is float). I am not sure if the group by quantile function can take care of this, and if it can, how the code should look like.\nThere are 3 rows a, b, c\ni.e. Data are sorted by column 'a', and make 20 groups\n\nGroup 1 = 0 to 5 percentile\nGroup 2 = 5 to 10 percentile\n.\n.\n.\nGroup 20 = 95 to 100 percentile.\n\nwould there also be a way to find the mean a, b, and c of each group, and sort them into another dataframe?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":90,"Q_Id":63004139,"Users Score":1,"Answer":"You can create 20 equal size bins using this.\ndf['newcol'] = pd.qcut(df.a,np.linspace(.05, 1, 19, 0), duplicates='drop')\nThen you can groupby the newcol to find the summary stats of a,b and c columns\ndf.groupby(['newcol']).mean()","Q_Score":0,"Tags":"python,pandas","A_Id":63004943,"CreationDate":"2020-07-20T21:33:00.000","Title":"How to make a fixed number of groups by percentile from a dataframe in pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have pyspark data frame with 3+ million of records and it's necessary to write it to Dynamo db. What is the best way to do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":188,"Q_Id":63004483,"Users Score":1,"Answer":"If you want to do this using python then you can do this as:\n\nsave the spark df with sufficient number of files i.e. if file size is 5 GB, generate 50 files of 100 mb.\nNow write python code with multiprocessing where your process pool will be equal to the number of CPU's available.\nWrite the files using dynamodb's boto3 batch_writer and process all files parallely.\n\nFor this you can use either glue python shell or create your own container and launch it on fargate.","Q_Score":0,"Tags":"python,amazon-web-services,dataframe,pyspark,amazon-dynamodb","A_Id":63012440,"CreationDate":"2020-07-20T22:05:00.000","Title":"How to write large Pyspark DataFrame to DynamoDB","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i just started working with python and with some scripts to automate some tasks. I manage to create a web scraper using selenium that notifies me daily with the latest news via a mail . Now the script works great if i run it manually , but my question is : How can i make the script to run automatically every day , and what option would you recomand . I know that you can use TaskScheduler and program it , but i was wondering if you know any options to run it directly in the cloud ? Also , i found some tutorials where they say to wrap all the code in an infinite loop and add a timer , and once you run the script it will stay active as a background process,\nI just started working with scripts and automation , so i would really like to know your opinion on the best way to run the script automatically . Thanks a lot","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":663,"Q_Id":63005252,"Users Score":0,"Answer":"Im not sure if that is what you are looking for, but (if you are on windows) you could attach your program to your autostart.  Probably your Startup Folder: C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup","Q_Score":1,"Tags":"python-3.x,selenium,web-scraping,automation,background","A_Id":63005523,"CreationDate":"2020-07-20T23:34:00.000","Title":"Python automation project to run in the background","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wanted to convert my Date column (yyyy-mm-dd) into type datetime. I checked its dtype and it was object. On converting it as pd.to_datetime(data['Date']), the dtype changed to dtype('O'). I looked it up online and it had to something with numpy dtypes however I cannot find a concrete answer.\n\nCan someone help me with this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":672,"Q_Id":63008833,"Users Score":0,"Answer":"Although I could not get why this was happening but when I tried data[\"Date\"] = pd.to_datetime(data[\"Date\"], errors='coerce') , the column changed into datetime type as it was required.","Q_Score":0,"Tags":"python,pandas,numpy,types","A_Id":63009103,"CreationDate":"2020-07-21T06:44:00.000","Title":"What is the difference between datatype \"object\" and dtype('O') in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with VSCode on an Ubuntu 18.04 machine. Everything is fine except that I can't get back to the previous command in Python Interactive Window via Arrow Up. It works in the integrated terminal though, integrated shell is \/bin\/bash.\nI have no idea where this is coming from. I changed \"keyboard.dispatch\" to \"keyCode\", but that's not the problem. I also tried different versions of the python-extension.\nDo you have any idea?\nThanks!","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":556,"Q_Id":63010975,"Users Score":-1,"Answer":"In my situation, although I delete all the shortcuts of UpArrow, I still can get the previous command through UpArrow in Python interactive. This means there's no way to configure this shortcut, it was built in the plugin which built in Python extension.\nSo it's some problem with your Python extension, but you said you have tried to install a different version of Python extension but still not work. Make sure you have deleted it completely -> delete the extension folder manually(it's under C:\\Users[UserName].vscode\\extensions\\ms-python.python-xxx).","Q_Score":5,"Tags":"python,visual-studio-code","A_Id":63026075,"CreationDate":"2020-07-21T08:58:00.000","Title":"Arrow up \/ previous command in VSCode Python Interactive not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working with VSCode on an Ubuntu 18.04 machine. Everything is fine except that I can't get back to the previous command in Python Interactive Window via Arrow Up. It works in the integrated terminal though, integrated shell is \/bin\/bash.\nI have no idea where this is coming from. I changed \"keyboard.dispatch\" to \"keyCode\", but that's not the problem. I also tried different versions of the python-extension.\nDo you have any idea?\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":556,"Q_Id":63010975,"Users Score":1,"Answer":"Not sure if this is helpful for you as an Ubuntu user, but I came across the same problem in Windows this week. In my case, the issue cropped up after I installed the Python extension in VS Code (or at least I didn't notice the issue before this). The combination of using the Python extension, Git Bash for terminal, and python virtual environment killed the up arrow feature for me. Using python outside a virtual environment works fine. My solution was to use Command Prompt as the terminal when I wanted to use a virtual environment interactively.","Q_Score":5,"Tags":"python,visual-studio-code","A_Id":71177227,"CreationDate":"2020-07-21T08:58:00.000","Title":"Arrow up \/ previous command in VSCode Python Interactive not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to get python-utils package and utils module work in my anaconda3. However, whenever I open my Anaconda Powershell and try to install the package it fails with the comment\n\nEnvironmentNotWritableError: The current user does not have write permissions to the target environment.\nenvironment location: C:\\ProgramData\\Anaconda3\n\nI searched for solutions and was advised that I update conda.\nHowever, when I ran the comment below\n\nconda update -n base -c defaults conda\n\nit also failed with EnvironmentNotWritableError showing.\nThen I found a comment that says maybe my conda isn't installed at some places, so I tried\n\nconda install conda\n\nwhich got the same error.\nThen I tried\n\nconda install -c conda-forge python-utils\n\nwhich also failed with the same error.\nMaybe it's the problem with setting paths? but I don't know how to set them. All I know about paths is that I can type\n\nsys.path\n\nand get where Anaconda3 is running.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":7521,"Q_Id":63011205,"Users Score":2,"Answer":"I have got the same non writable error in anaconda prompt for downloading pandas,then sorted the the error by running anaconda prompt as administrator. it worked for me since i already had that path variable in environment path","Q_Score":4,"Tags":"python,anaconda,conda","A_Id":68724672,"CreationDate":"2020-07-21T09:12:00.000","Title":"EnvironmentNotWritableError on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get python-utils package and utils module work in my anaconda3. However, whenever I open my Anaconda Powershell and try to install the package it fails with the comment\n\nEnvironmentNotWritableError: The current user does not have write permissions to the target environment.\nenvironment location: C:\\ProgramData\\Anaconda3\n\nI searched for solutions and was advised that I update conda.\nHowever, when I ran the comment below\n\nconda update -n base -c defaults conda\n\nit also failed with EnvironmentNotWritableError showing.\nThen I found a comment that says maybe my conda isn't installed at some places, so I tried\n\nconda install conda\n\nwhich got the same error.\nThen I tried\n\nconda install -c conda-forge python-utils\n\nwhich also failed with the same error.\nMaybe it's the problem with setting paths? but I don't know how to set them. All I know about paths is that I can type\n\nsys.path\n\nand get where Anaconda3 is running.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7521,"Q_Id":63011205,"Users Score":4,"Answer":"Run the PowerShell as Administrator. Right Click on the PowerShell -> Choose to Run as Administrator. Then you'll be able to install the required packages.","Q_Score":4,"Tags":"python,anaconda,conda","A_Id":63011294,"CreationDate":"2020-07-21T09:12:00.000","Title":"EnvironmentNotWritableError on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to get notify whenever the new files added to a directory in FTP server. Is there any method to tell me that new files are added?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":826,"Q_Id":63011667,"Users Score":0,"Answer":"FTP does not support this natively. Hence you do one of the following:\n\nwrite a short script to watch the directory  and send an email\/notification (just a few lines Python)\nuse an existing module, aka pywatch\nuse an orchestration operator such as Airflow sensor, if your files are part of a larger process and you want to trigger jobs when the files arrive","Q_Score":0,"Tags":"python,python-3.x,python-2.7,ftp","A_Id":63011904,"CreationDate":"2020-07-21T09:41:00.000","Title":"How to get notify whenever a new files is added to directory in FTP 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":0,"Web Development":0},{"Question":"I tried to install Rasa, with the command: pip3 install rasa.\nHowever, I came up against an error about tensorflow, which is not automatically installed.\nThen I used command: pip3 install tensorflow, unfortunately, an error appeared:\nERROR: Could not find a version that satisfies the requirement tensorflow-addons<0.8.0,>=0.7.1 (from rasa) (from versions: none).\nSo how could I install Rasa, and Tensorflow as well?\nP\/s: Python --version: 3.8.3;\npip --version: 20.1.1","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":6867,"Q_Id":63011755,"Users Score":1,"Answer":"I've made the same mistake of installing the python version 3.8 when it says on the RASA installation notes that you've got to go for version 3.6 3.7 for now.\nAfter having the right version of Python in my venv (macOS zsh) the installation worked fine. From the python site you can find the right version to prepare for your environment. Also it was advised that you prepare the python version for the venv and not your entire system (which I think is at python 2.x)\nMaking sure that you have all the components you need and the right version was key for RASA to not have issues during the install.","Q_Score":3,"Tags":"python,tensorflow","A_Id":63299303,"CreationDate":"2020-07-21T09:45:00.000","Title":"ERROR: Could not find a version that satisfies the requirement tensorflow-addons<0.8.0,>=0.7.1 (from rasa) (from versions: none)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to install Rasa, with the command: pip3 install rasa.\nHowever, I came up against an error about tensorflow, which is not automatically installed.\nThen I used command: pip3 install tensorflow, unfortunately, an error appeared:\nERROR: Could not find a version that satisfies the requirement tensorflow-addons<0.8.0,>=0.7.1 (from rasa) (from versions: none).\nSo how could I install Rasa, and Tensorflow as well?\nP\/s: Python --version: 3.8.3;\npip --version: 20.1.1","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6867,"Q_Id":63011755,"Users Score":0,"Answer":"I faced same problems and executed following commands:\n\nsudo apt-get update\nsudo apt-get upgrade\nsudo pip3 install --upgrade pip\npip3 install rasa\n\nNow My System is:\n\nUbuntu 18.04.5 LTS\nPython 3.6.9\npip 20.3.3\ntensorflow 2.3.1\ntensorflow_addons 0.12.0\n\nand rasa on my system is working fine.","Q_Score":3,"Tags":"python,tensorflow","A_Id":65488687,"CreationDate":"2020-07-21T09:45:00.000","Title":"ERROR: Could not find a version that satisfies the requirement tensorflow-addons<0.8.0,>=0.7.1 (from rasa) (from versions: none)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to automate downloading using selenium python which in turn carries the link to IDM. However, the thing is I can't get to download using IDM.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":195,"Q_Id":63012062,"Users Score":1,"Answer":"Thisis not good practice in selenium automation\nWhilst it is possible to start a download by clicking a link with a browser under Selenium\u2019s control, the API does not expose download progress, making it less than ideal for testing downloaded files. This is because downloading files is not considered an important aspect of emulating user interaction with the web platform. Instead, find the link using Selenium (and any required cookies) and pass it to a HTTP request library like libcurl.\nPlease refer seleniumhq site","Q_Score":2,"Tags":"python,selenium,automation","A_Id":63012470,"CreationDate":"2020-07-21T10:02:00.000","Title":"How can I automate downloads using IDM?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project where I have to extract the pixels from a thermal image and convert it into temperature to detect the respiratory time, using which I can detect the respiratory rate. I have done upto detecting the object(i.e the nostrils), but I am not sure how to extract and convert the pixel values to temperature.My idea is to create a colourbar, then compare the pixel values from the image to those of the colourbar and get the temperature values.Is this the right way to do this? (I am a newbie to this).Also I am not sure on how to proceed the way I've mentioned over here(like on how to compare the pixels between image and colourbar).Any help will be grateful.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":197,"Q_Id":63013527,"Users Score":2,"Answer":"You don't need to effectively draw the color bar, it suffices to have a representation in an array. Then you can indeed match the colors of the pixels to the colors in the color bar and deduce the \"position\". If your system is correctly calibrated, you should know the corresponding temperatures.\nFor different reasons, it could arise that the colors in the image do not match any in the bar, just consider the closes match.\nNote that a thermal image is in fact a pseudo-colored representation of a scaler field (temperature is a scalar), color being used to please the human eye. But as regards quantitative processing, only the scalar value matters, and it is a kind of waste to have a scalar image mapped to pseudocolors, and then back to grayscale.\nSo if possible, prefer to fetch the original image, before pseudocoloring (but do not confuse with the conversion of the pseudocolors to grayscale intensity).","Q_Score":1,"Tags":"python,python-3.x,image-processing,heatmap,temperature","A_Id":63022297,"CreationDate":"2020-07-21T11:29:00.000","Title":"Comparing pixels between image and colourbar","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can i activate AWS APPFLOW flow by not using AWS Console but by using Rest API or Python or AWS CLI?\nI am not able to find any support from AWS Documentation or any blogs.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":537,"Q_Id":63013662,"Users Score":1,"Answer":"If you use CloudFormation, you can create a Lambda-backed custom resource, which is going to be triggered during CloudFormation create\/update\/delete events. The Lambda function will be called with those events, and you can call AppFlow SDK to activate\/deactivate the flows.","Q_Score":1,"Tags":"python-3.x,amazon-web-services,aws-cli,saas","A_Id":69332449,"CreationDate":"2020-07-21T11:36:00.000","Title":"AWS APPFLOW | Trigger \/ Activate AWS Appflow flow from other than console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I was trying to grasp my head around the difference between .sort() and sorted() and their reverse in python but I don't seem to get any. Any help?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":478,"Q_Id":63014058,"Users Score":0,"Answer":"I think .sort() is a list method which sorts the list and sorted is a builtin function which accpets some iterable object and returns its sorted copy","Q_Score":1,"Tags":"python,sorting,reverse,difference","A_Id":63014258,"CreationDate":"2020-07-21T11:59:00.000","Title":"Difference between sort and sorted and their reverse in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to grasp my head around the difference between .sort() and sorted() and their reverse in python but I don't seem to get any. Any help?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":478,"Q_Id":63014058,"Users Score":0,"Answer":"The difference between sort and sorted is that sorted(list) returns a copy of the list without changing it, while list.sort() changes the list.\nTherefore, sorted is a static method, while sort is a list instance method.","Q_Score":1,"Tags":"python,sorting,reverse,difference","A_Id":63020341,"CreationDate":"2020-07-21T11:59:00.000","Title":"Difference between sort and sorted and their reverse in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having an issue using Python in my Mac Terminal Shell.\nI used Python through Mac Terminal yesterday, but after I worked in Pycharm this morning, there seems to be an issue with my terminal.\nNow when I simply write 'python', I receive this message:\n\nzsh: no such file or directory: \/usr\/local\/bin\/python3.7\n\nAny help, getting me back to using Python in my terminal would be appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1118,"Q_Id":63015974,"Users Score":1,"Answer":"Apparently the PATH of your S.O. It can't find the file to launch Python in your terminal so you could:\n\nreinstall Python from the command line (zsh) and validate the \"python\" command again from the terminal\n\nfind the file associated with Python with commands like \"find\" and then modify the path of the PATH to the path where the Python launcher is","Q_Score":0,"Tags":"python,macos,shell,terminal,command","A_Id":63016373,"CreationDate":"2020-07-21T13:48:00.000","Title":"zsh can't find python home 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've always asked myself, why is there a way to import a certain function from a module,\nexample: from tkinter import ttk\ninstead of just importing the whole module, --> import tkinter\ndoes it make the program run faster ?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":115,"Q_Id":63017089,"Users Score":1,"Answer":"There is no memory or speed difference (the whole module has to be evaluated either way, because the last line could be Y = something_else). It can only matter if you are calling a function a lot of times in a loop (millions or more). Doing the double dictionary lookup will eventually accumulate.\nAlthough import tkinter and from tkinter import ttk both import the entire tkinter module, the latter uses name binding so only ttk is accessible to rest of the code.\nFor some people this would be the preferred style since it only makes accessible the functions you explicitly stated.\nIt does however introduce potential name conflicts. Note you can also explicitly import functions and rename them with from tkinter import ttk as tkinter_ttk, a convention that meets the explicit import and is less likely to gave name space collisions.","Q_Score":0,"Tags":"python,tkinter","A_Id":63017270,"CreationDate":"2020-07-21T14:45:00.000","Title":"what is the difference between importing the whole module or importing a certain function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used import twitter and then tried authenticating using the following command - Twitter(auth=OAuth(access_token, access_token_secret, consumer_key, secret_key))\nOn running the program I get the error: name Twitter not defined. When I use from twitter import *, it works. Why is it so?\nI am asking this because if i use tweepy instead, a simple import tweepyworks. Also, doesn't import twitter work the same as from twitter import *?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":63019030,"Users Score":2,"Answer":"Try twitter.Twitter (auth=OAuth(access_token, access_token_secret, consumer_key, secret_key))","Q_Score":0,"Tags":"python,twitter","A_Id":63019081,"CreationDate":"2020-07-21T16:36:00.000","Title":"error: name Twitter not defined on using import twitter","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":"First time posting so hopefully I can relate what I'm trying to ask.\nI have cpp code that records timestamps down to the nanosecond level from an fpga. It is writing this value to a csv. In the same csv I am calculating the difference between consecutive timestamps.\nWhen I export it to python and do the timestamp difference, I get mostly 1s (its based off a PPS), but also random impulse points. Any idea why I get all 1s in cpp but mostly 1s and occasionally 1 +- 3E-14?\nany info or guidance would be appreciated. From using search, it seems like it could be due to floating points? but shouldnt that happen for both?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":63019871,"Users Score":0,"Answer":"@tdelaney's and user4581301's comments hit the nail on the head. It appears that it was due to the precision of python's floating type. I replaced it with the mentioned decimal.Decimal and it kept the original CSVs precision and calculated the data with no rounding.\nDecimal doesn't rely on binary fractions and the only downside is that it is slower (which in my case is fine).\nThe difference between my cpp and python code was that my cpp code was doing the math as uints and I was calculating it manually vs just A-B.","Q_Score":1,"Tags":"python,c++,precision","A_Id":63035268,"CreationDate":"2020-07-21T17:28:00.000","Title":"CPP and Python csv Precision","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have two datasets d1 and d2, where the d1 columns are:\nd1_columns {X,Y,Z,T}\nand for d2 :\nd2_columns{X,Y,L,P}\nIs there a function f such that:\nf(d1,d2) = {Z,T} or equivalently: f(d1,d2) = {L,P} ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":63021214,"Users Score":0,"Answer":"In this case first add both the dataframes and then subtract the other.\nEg : A = ( a,b,c,d )  , B = ( a,b,e,g ).   Here I mean to say that a,b,c,d,e,f are the column names.\nSo , if you want column ( c,d ) only , then do\n\nC = A + B , then ,\nC = C - B and hence you will be left with columns ( c,d ) only.\n\nLikewise you can do for ( e,g ) columns.","Q_Score":0,"Tags":"python,pandas","A_Id":63021526,"CreationDate":"2020-07-21T18:51:00.000","Title":"Is there a way to get the element that belong only to a dataset d1 and not to another one d2, with pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have two datasets d1 and d2, where the d1 columns are:\nd1_columns {X,Y,Z,T}\nand for d2 :\nd2_columns{X,Y,L,P}\nIs there a function f such that:\nf(d1,d2) = {Z,T} or equivalently: f(d1,d2) = {L,P} ?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":63021214,"Users Score":0,"Answer":"Refer the following Code -\ndf1 = pd.DataFrame({'A':[1,2,3,4,5],'B':[2,5,4,7,8],'C':[4,1,7,5,6],'D':[2,5,4,7,8]}) #First Dataframe\ndf2 = pd.DataFrame({'A':[1,2,3,4,5],'B':[2,5,4,7,8],'E':[5,6,7,4,4],'F':[5,7,8,9,4]}) #Second Dataframe\nnew_df = pd.concat([df1,df2],axis=1) # Concat the dataframes\nnew_df[list(set(new_df.columns).difference(df1.columns))] # Gives us Columns (E,F)\nnew_df[list(set(new_df.columns).difference(df2.columns))] # Gives us Columns (C.D)","Q_Score":0,"Tags":"python,pandas","A_Id":63073867,"CreationDate":"2020-07-21T18:51:00.000","Title":"Is there a way to get the element that belong only to a dataset d1 and not to another one d2, with pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I wait for all the new elements that appear on the screen to load after clicking a specific button? I know that I can use the presence_of_elements_located function to wait for specific elements, but how do I wait until all the new elements have loaded on the page? Note that these elements might not necessarily have one attribute value like class name or id.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":193,"Q_Id":63021972,"Users Score":2,"Answer":"Well in reality you can't, but you can run a script to check for that.\nHowever be wary that this will not work on javascript\/AJAX elements.\nself.driver.execute_script(\"return document.readyState\").equals(\"complete\"))","Q_Score":0,"Tags":"python,selenium,selenium-chromedriver","A_Id":63022098,"CreationDate":"2020-07-21T19:42:00.000","Title":"Selenium(Python): After clicking button, wait until all the new elements (which can have different attributes) are loaded","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question regarding conda environments. Whenever I try to remove an environment in command prompt with \"conda env remove -n envname, the actual folder remains in the environments folder. Thus, if I try to recreate the environment with the same name, command prompt gives me an error saying that a folder already exists there and whether or not I would like to proceed. I'm not sure whether that is safe, so at this point I manually delete the folder. Is this something that is viable? Is leaving the folder there normal conda behavior? Is there a solution to allow conda to just automatically delete the folder?\nThanks so much!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":781,"Q_Id":63022181,"Users Score":0,"Answer":"Ok, I think I figured out the issue. Before you try to remove the env, make sure that:\n\nThe env isn't still attached to any running processes. For example, if you'd used it in VS Code, make sure you close VS Code (that might assume you're using the Anaconda Extension pack, not sure, haven't tried without it).\nMake sure you use conda deactivate to deactivate the env you're about to remove.\n\nIf the env (or maybe more correctly, the folders where it was stored) are still referenced by a running process or you haven't deactivated the env, conda env remove will act like it's removing the env and it won't show up in conda env list, but it will still be possible to activate it and the folders will remain.","Q_Score":2,"Tags":"python,conda,environment","A_Id":63122767,"CreationDate":"2020-07-21T19:58:00.000","Title":"conda env remove -n envname does not delete the actual folder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I work in tech support and currently have to manually keep our manuals for products updated manually by periodically checking to see if it has an update and if it does replacing the current one saved on our network.\nI was wondering if it would be possible to build a small program to quickly download all files on a suppliers website and have them automatically download and be sorted into the given folders for those products, replacing the current PDF's in that file. I must also note that the website is password protected and is sorted into folders.\nIs this possible with Python? I figured a small program I could perhaps run once a week or something to automatically update our manuals would be super useful (and a learning experience).\nApologies if I haven't explained the requirement well, any questions let me know.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":63022562,"Users Score":1,"Answer":"It's certainly possible. As the other answer suggests you will want to use libaries like Requests (Handle HTTP requests) or  Selenium (AUtomated browser activity) to navigate through the login.\nYou'll need to sort through the links on a given page, could be done with beautifulsoup ideally (An HTML parser) but could be done with selenium (Automated Browser activity).You'll need to check out libraries like requests (To handle HTTP requests) for downloading the pdf's, the OS module for sorting the folders out into specific folders and replacing files.\nI strongly urge you to think through the steps, But I hope that gives an idea about the libaries that you'll need to learn abit about. The most challenging thing to learn will be using selenium, so if you can use requests to do the login that is much better.\nIf you've got a basic grasp of python the requests, OS module and beautifulsoup libraries are not difficult things to pick up.","Q_Score":0,"Tags":"python,web-scraping,download","A_Id":63028786,"CreationDate":"2020-07-21T20:26:00.000","Title":"Scraping PDF's from a password protected website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"To preface: my code works as I expect when compiling and running on Linux. However, this library needs to be compiled for use on a Windows machine. I looked in to a couple different options, and decided that using Cygwin to compile for Windows seemed to be the correct choice. I'm using a setup.py file with the distutils.core library and compiling using python setup.py install. When compiling on Windows in Cygwin, it fails to find pthread.h, arpa\/inet.h, netinet\/in.h, and sys\/socket.h. I was under the impression that Cygwin came prepackaged with these headers, which is why I chose to use it. The alternative to Cygwin is putting preprocessor commands everywhere and using Windows specific libraries such as winsock2.h, which I want to avoid if at all possible. Is it possible to compile for Windows using Cygwin? If so, what have I done wrong to cause Cygwin to not recognize these headers?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":481,"Q_Id":63022751,"Users Score":0,"Answer":"Most important, I think, is to follow the instructions in the Python help or on the Python doc web site for \"Extending and Embedding the Python Interpreter\" for the version you are building the extension for. For windows, the build instructions identify the build environment used to create the binary package that you download from python.org, usually something like VS2013 or VS2017. (As an aside, I think the Community editions have everything you need, and I don't think you actually have to use the Visual Studio GUI when you build using nmake from the CMD.EXE terminal.)\nTo build in Cygwin for use in a Windows version of Python, you may need to install and then use the x86_64-w64-mingw32-gcc, etc., cygwin packages to cross-compile non-cygwin (i.e. pure windows) executables and DLLs from Cygwin.\nBinary extensions must be built using the source tree for a specific Python major.minor version, and bitness. For windows, you will need to build multiple versions of the extension, one for each major.minor, bitness version of Python that will import it, e.g. 3.6, 3.7, 3.8, 3.9, 32-bit, 64-bit. The extension code may not require changes between versions, but it still needs to be compiled with the right compiler and linked against exactly the same shared libraries (in this case .DLL files) as used by the Python executable. For instance, it must use exactly the same version of Microsoft's C run time library DLL as the Python executable does. This is a bit more sensitive and restrictive than on Linux, where you can rebuild the python executable and your extension with the same toolchain from your distro more easily.","Q_Score":0,"Tags":"python,c,windows,cygwin","A_Id":63046764,"CreationDate":"2020-07-21T20:38:00.000","Title":"How do I build a C Python Extension for Windows using Cygwin64?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m making a robot car using a Raspberry Pi. I\u2019ve attached a raspberry pi camera on top of the car; the images are clear when the car isn\u2019t moving but when it is moving the images are blurry. Is anyone aware of any solutions (either hardware or software) to stop the blurry images when driving?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":63022756,"Users Score":0,"Answer":"I believe that your issue is that as the car is moving, the camera is vibrating. You need to stabilise the camera or make your car move slower.","Q_Score":1,"Tags":"python,raspberry-pi,picamera","A_Id":63022850,"CreationDate":"2020-07-21T20:38:00.000","Title":"How to stop blurry images on Raspberry Pi Robot car?","Data Science and Machine Learning":0,"Database and SQL":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 python to develop code on my work laptop and then deploy to our server for automation purposes.\nI just recently started using git and github through PyCharm in hopes of making the deployment process smoother.\nMy issue is that I have a config file (YAML) that uses different parameters respective to my build environment (laptop) and production (server). For example, the file path changes.\nIs there a git practice that I could implement that when either pushing from my laptop or pulling from the server it will excluded changes to specific parts of a file?\nI use .gitignore for files such as pyvenv.cfg but is there a way to do this within a file?\nAnother approach I thought of would be to utilize different branches for local and remote specific parameters...\nFor Example:\nLocal branch would contain local parameters and production branch would contain production parameters. In this case I would push 1st from my local to the local branch. Next I would make the necessary changes to the parameters for production, in my situation it is much easier to work on my laptop than through the server, then push to the production branch. However, I have a feeling this is against good practice or simply changes the use of branches.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":273,"Q_Id":63022930,"Users Score":1,"Answer":"Config files are also a common place to store credentials (eg : a login\/pwd for the database, an API key for a web service ...) and it is generally a good idea to not store those in the repository.\nA common practice is to store template files in the repo (eg : config.yml.sample), to not store the actual config file along with the code (even add it in .gitignore, if it is in a versioned directory), and add steps at deployment time to either set up the initial config file or update the existing one - those steps can be manual, or scripted. You can backup and version the config separately, if needed.\nAnother possibility is to take the elements that should be adapted from somewhere else (the environment for instance), and have some user: $APP_DB_USER entries in your config file. You should provision these entries on both your servers - eg : have an env.txt file on your local machine and a different one on your prod server.","Q_Score":0,"Tags":"python,git,github,version-control,pycharm","A_Id":63024055,"CreationDate":"2020-07-21T20:53:00.000","Title":"What is the best way to manage client\/server specific files with 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":0,"Web Development":0},{"Question":"tl;dr: Does Ansible have a variable containing the current Python interpreter?\nAs part of my playbook, I am creating a Python script on the controller (to be run by another command), and I want that script to be run by the Python interpreter being used by Ansible. To do this I am trying to set the interpreter in the shebang of the script.\nIf I were to set the interpreter manually, I could use the ansible_python_interpreter variable (and I have had it working that way). If I don't set the interpreter manually, then Ansible will auto-discover an interpreter, but I can no longer use the ansible_python_interpreter variable because it is not set.\nFrom looking through the documentation I have been unable to find any way to see which interpreter Ansible has auto-detected. Is there something I've missed?\n(Ansible version 2.9.10, Python 3.6)\n\nThe complete situation:\nI am running Ansible on AWX (open-source Ansible Tower), using a custom virtual environment as the runner. I use Hashicorp Vault as a secret management system, rather than keeping secrets in AWX. For access to Vault I use short-lived access tokens, which doesn't work well with AWX's built-in support for pulling secrets from Vault, so instead I do it manually (so that I can supply a Vault token at job launch time). That works well for me, generally.\nIn this particular case, I am running ansible-vault (yes, there are too many things called 'vault') on the controller to decrypt a secret. I am using the --vault-password-file argument to supply the decryption password via a script. Since the virtual env that I am using already has the hvac package installed, I wish to just use a brief Python script to pull the password from Hashicorp Vault. All works fine, except that I can't figure out how to set the shebang on this script to point at the virtual environment that Ansible is using.\nIf I can't get a useable answer to this, I suppose I can change to instead pull the password directly into Ansible and then use the --ask-vault-pass flag to pass the password that way. It just seems to me that the interpreter should really be exposed somewhere by Ansible, so I'm trying that first.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":462,"Q_Id":63023699,"Users Score":0,"Answer":"With gather_facts: yes you should be able to get the active python using the ansible_facts.python variable.","Q_Score":5,"Tags":"python,ansible","A_Id":63025081,"CreationDate":"2020-07-21T21:57:00.000","Title":"Does Ansible expose its auto-discovered Python interpreter?","Data Science and Machine Learning":0,"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 working on data set where there are four predictors. There is good linear relation with one of the predictors but with other three i think polynomial would fit. Is there any method in python where i can predict single variable combining linear regression on one predictors and polynomial or other non-linear regression on other three predictors?\nPlease help.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":366,"Q_Id":63027352,"Users Score":1,"Answer":"You can fit one polynomial expression for all features which should take care of the linear one as well. The only difference is that the coefficient of the linear one will be of order 1.","Q_Score":0,"Tags":"python,machine-learning,regression","A_Id":63027504,"CreationDate":"2020-07-22T05:14:00.000","Title":"linear and nonlinear regression combined in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can i install Tkinter on Windows 10?\nI have tried everything. I use PyCharm. I put my code to repl.it and it worked as it should. But i like PyCharm and i want to use it for my coding. Can it be that it does not support tkinter?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1912,"Q_Id":63029161,"Users Score":0,"Answer":"tkinter is built-in in python so no need to install it. Also, I have Windows 10 and I have just finished doing a massive project with tkinter and pycharm and it as worked fine. Be aware tho, when you are trying to import tkinter watch out for the suggestion that pycharm tries to give you: the right name for the module is tkinter and not _tkinter","Q_Score":1,"Tags":"python,tkinter","A_Id":63029337,"CreationDate":"2020-07-22T07:39:00.000","Title":"How can i install Tkinter on Windows 10?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know how to feed in an initial solution or matrix of initial solutions into the differential evolution function from the Scipy library?\nThe documentation doesn't explain if its possible but I know that initial solution implementation is not unusual. Scipy is so widely used I would expect it to have that type of functionality.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":160,"Q_Id":63031913,"Users Score":0,"Answer":"Ok, after review and testing I believe I now understand it.\nThere are a set of parameters that the scipy.optimize.differential_evolution(...) function can accept, one is the init parameter which allows you to upload an array of solutions. Personally I was looking at a set of coordinates so enumerated them into an array and fed in 99 other variations of it (100 different solutions) and fed this matrix into the inti parameter. I believe it needs to have more than 4 solutions or your are going to get a tuple error.\nI probably didn't need to ask\/answer the question though it may help others that got equally confused.","Q_Score":0,"Tags":"python,scipy,initialization,scipy-optimize,differential-evolution","A_Id":63034841,"CreationDate":"2020-07-22T10:14:00.000","Title":"Scipy Differential Evolution initial solution(s) input","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to automate some manual steps using python, i am opening new command prompt using os.popen and running docker compose up .. its opening new cmd and running the docker command, now i want run the next set of commands after docker command is up ... python script has to wait till that time, i tried with below code but its not working.\nI tried with subprocess.Popen which has wait method but its not opening new cmd,it is running in python script running command prompt only ..\np=os.popen(\"Start cmd  \/K docker-compose up\")\np.wait","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":81,"Q_Id":63033424,"Users Score":0,"Answer":"I think the \"start\" command in windows cmd runs a process that launches a child process with the rest of the line as parameter, then finishes immediately. I guess that is why it does not wait until the docker-compose finishes (or whatever command you write after \"start\").\nExample with Process IDs (PIDs):\nYour python program (PID 1) runs the command \"start cmd \/K docker-compose up\". The start process has PID 2. Start launches the \"cmd \/K docker-compose up\" (a new process with PID 3). Start finishes. Your programs waits until PID 2 ends (it already ended so continues without waiting).\nWhat you really wanted in the example is to wait until PID 3 finishes not PID 2.\nProbably you can get the real PID of the child process with some tricks and then wait until it completes but you should consider if you really need the docker-compose to run in a separate window.","Q_Score":0,"Tags":"python,python-3.x","A_Id":63034034,"CreationDate":"2020-07-22T11:45:00.000","Title":"python os.popen is not working for wait method","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to implement sso for multiple providers in my app.\nCurrently I am using flask-oauthlib for the authentication. For google authentication sso login works like a charm. \nSince I will have multiple sso providers, I was wondering if I could simply have one text field on my landing page, and then redirect the user according to the email domain to the right sso provider while automatically initializing the handshake process. \nThe question is, to whether I can automatize the sso login, without having the user to select their account on Google's Choose an account page; thus saving an additional step?\nI hope this makes sense, thank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":318,"Q_Id":63037498,"Users Score":0,"Answer":"According to OAuth2.0 standards, at the time of authorizing this is not possible to tell SSO provider like Google in advance which user account is going to be used. But still needs to check particularly with OAuth2 implementation of Google. \nAccording to standards, user credentials like user name and password should only be challenged on SSO providers(IDP's) page.","Q_Score":0,"Tags":"python,flask,oauth,single-sign-on,flask-oauthlib","A_Id":63057267,"CreationDate":"2020-07-22T15:10:00.000","Title":"Automatic sso login","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've 2 text files. Writing a Python Program for the following\n1)I need to compare the pairs of sentences in the 1st file, and see if they are in the same or different blocks, and compare that to the 2nd text file.\n2)I need to calculate the percentage of correct classification.\n3) I need to  count:\n% of sentence pairs correctly classified as in the same block, % of sentence pairs correctly classified as in different blocks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":63038123,"Users Score":0,"Answer":"Please provide more information about the structure of the files. Also, I'd like to remind you that StackOverFlow helps you out providing aditional information in order to solve your problem, we are not going to code the solution for you.\nProvide aditional information and your code if possible in order to help you out.\nHave a great day.","Q_Score":0,"Tags":"python,nlp","A_Id":63038259,"CreationDate":"2020-07-22T15:44:00.000","Title":"python code to compare the pairs of sentences, and see if they are in the same or different blocks in text file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a basic Flask app running, with the code in main.py hosting the flask app. I also have an index.html file that will get text input from the user. I can use request.form to access the input, and I can work with it successfully. However, I encountered a problem.\nI need to call a JavaScript function that opens a new tab with a certain website. For example, if the user types in Wikipedia, I need to tell JavaScript to window.open(\"https:\/\/www.wikipedia.org\"). The problem is, I can't find any working way to call a JavaScript function from a Flask application.\nAnd before you mark this question as duplicate, the answer to the one Stack Overflow question on this I found did not even involve flask, and the other answer (using webbrowser.open_new_tab) opened the new tab on the server machine, not on the client machine (the one where the website is actually being accessed).\nI know you can call a Python function from JavaScript, but is it possible to do it the other way?\nThank You in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":170,"Q_Id":63039584,"Users Score":1,"Answer":"One way to do this is by passing the url as a query string to the url containing the javascript. You can acces the query string in javascript and use it in the function that opens the window.","Q_Score":0,"Tags":"javascript,python,flask","A_Id":63041041,"CreationDate":"2020-07-22T17:06:00.000","Title":"Call a JavaScript Function from Flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"so im making a generator (doesn't really matter what one it is)\nand im trying to make the a\/ans appear before nouns correctly.\nfor example:\n\"an apple plays rock paper scissors with a banana\"\nand not:\n\"a apple plays rock paper scissors with an banana\"\nthe default thing for the not-yet determined a\/an is \"<a>\"\nso i need to replace the \"<a>\" with either a or an depending on if the letter after it is a vowel or not.\nhow would i do this?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":169,"Q_Id":63041059,"Users Score":0,"Answer":"Pseudo code\n\nfirst find letter 'a' or 'an' in string and keep track of it\nthen find first word after it\nif word starts with vowel: make it 'an'\nElse: make it 'a'\nthis rules breaks with words like 'hour' or 'university' so also make exception rule(find a list of words if u can)","Q_Score":0,"Tags":"python","A_Id":63041674,"CreationDate":"2020-07-22T18:39:00.000","Title":"How do i check if it should be an or a in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I ran the command pip install discord.py==1.3.4 successfully. However when I ran print(discord.__version__) in PyCharm it displayed 1.3.3. My pip version is 20.1.1 and Python is version 3.7. Does anyone have any idea why the version number is different?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":209,"Q_Id":63043109,"Users Score":0,"Answer":"Make sure you are not using virtual environment. You may have installed the latest version to your system packages. Be sure to also install it in your dev environment.","Q_Score":0,"Tags":"python,discord.py","A_Id":63043229,"CreationDate":"2020-07-22T20:59:00.000","Title":"`pip` installed `discord.py` to `1.3.4` successfully, but `print(discord.__version__)` displays `1.3.3`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been having problems with dask.distributed. Everytime I run it, it always has memory issues and kills my workers, when running on my laptop. I have a laptop with 16GB and run 4 workers, when I try to run a computation it seems to straight away kill workers. Ive tried limiting the ram to 3.5 GB but that doesnt work. My chunk sizes are around 200MB. I am using a zarr file with a 3diim array stored. So I don't understand why I have this issue. I had it working a few months ago and took some time away from it when this problem occurred. I tired a smaller overall data set and the same issue occurs. Any thoughts?\nWhen I run this outside of distributed I don't have the same issue?\nHappy to show error reports and a minimum example if anyone has idea's?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":63044326,"Users Score":0,"Answer":"I recommend looking at logs.  KilledWorker errors can occur for many reasons.  For example you might not have the same version of Dask everywhere or you might be launching workers someplace where they can't connect.","Q_Score":0,"Tags":"python,dask,dask-distributed","A_Id":63310776,"CreationDate":"2020-07-22T22:54:00.000","Title":"Dask.distributed kill workers Everytime I run","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using an API in python and when I make a request to this API, the server must send a audio mensage in a channel.\nIn a text channel I use a webhook, that gives me the context of the channel. I need something like that to be abble to play the audio.\nThere is any way to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":940,"Q_Id":63044586,"Users Score":0,"Answer":"You can not play the audio file after sending it through bot.\nWhat you can do is download the audio file and play it using FFMPEG","Q_Score":0,"Tags":"python,api,discord,discord.py,discord.py-rewrite","A_Id":63314438,"CreationDate":"2020-07-22T23:27:00.000","Title":"How use a API call with 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 a dataframe with the name of all the states in the USA and a few cities for each state. However, I need to change the names of the states to its two letter acronyms (ex: Nevada becomes NV and Wyoming becomes WY).\nA have a dictionary with the name of the states\/territories and its respective acronym, as you can see bellow:\nstates = {'OH': 'Ohio', 'KY': 'Kentucky', 'AS': 'American Samoa', 'NV': 'Nevada', 'WY': 'Wyoming', 'NA': 'National', 'AL': 'Alabama' and on an on an on\nI was thinking about creating a new column, and once it was created, I'd drop the 'States' column. But my code bellow is filling the new column with NaN values\nstate_town_df['acronym'] = state_town_df['State'].map(states)\nIs there any simple way to solve it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":85,"Q_Id":63044687,"Users Score":1,"Answer":"In the dictionary the key is acronym and the value is the state. I assume that State column is not an acronym. You may have to inverse the dictionary such as inv_map = {v: k for k, v in states.items()}","Q_Score":0,"Tags":"python,pandas","A_Id":63044722,"CreationDate":"2020-07-22T23:42:00.000","Title":"Replace the values of a given column in pandas with a dictionary","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can get to the user information using the API but I cannot access course information. Can someone explain what I need to do to make the correct call for course information?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":267,"Q_Id":63046118,"Users Score":0,"Answer":"The easiest way to answer these questions is to try it in Postman. Highly recommended.","Q_Score":1,"Tags":"python,api","A_Id":68505713,"CreationDate":"2020-07-23T02:51:00.000","Title":"Schoology API understanding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a react \/ django app. The django side hosts a sqlite database, and react displays its content as the front end. When I run the command python manage.py runserver it is hosted locally on port 8000. My specific problem is manifest when I make edits to my React code. Even after refreshing the page and restarting the server, my front-end still remains as it was before I had edited the code and saved. I have no errors, or warnings.\nThe only way I seem to be able to make it work is by pushing to GitHub and then cloning the repository on my system again. Would anyone be able to help me understand my dilemma? (Please let me know if my question is not to par with the guidelines of Stack Overflow, this is my first time)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":63046721,"Users Score":0,"Answer":"Apparently I was supposed to be running npm run dev. Started working after that.","Q_Score":0,"Tags":"python,django,reactjs,localhost","A_Id":63417784,"CreationDate":"2020-07-23T04:03:00.000","Title":"Why is my project no longer updating when I write new code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I got stuck in one Place. I have a Tkinter Application and Web Application on Django. I have a login system in both Application. Rather making two distinct User Model, I want to linked My Tkinter Desktop Application with Django user Model so that I can synchronized the User data in both Application but the problem is when I am checking the password in my tkinter Application it is checking it as a plain text but the password in django User Model cannot be decrypt. So, Is there any way that I can synchronized my Desktop Application (Tkinter) and Web Application (Django) with one User Model (Django)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":578,"Q_Id":63048797,"Users Score":0,"Answer":"How to Connect Tkinter Application with Django User Model?-\nStep number0: Put in same directory as django application\nStep number1: Create a basic tkinter app\nStep number2: import the user models","Q_Score":0,"Tags":"python,django,tkinter","A_Id":68990480,"CreationDate":"2020-07-23T07:13:00.000","Title":"How to Connect Tkinter Application with Django User Model?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am creating a Voice Assistant Program using Python and I wanna add a feature to it that shows the last time when the Assistant was used. Is there any method to do that? I am using tkinter for my GUI.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":50,"Q_Id":63048918,"Users Score":2,"Answer":"Often times, the obvious answer is the easiest\/right one.\nIn this case, why not store the previous usages of the voice assistant?\nIt offers you a lot of benefits:\n\nBeing able to tell the user what was recognized previously\nAllowing the user to spot previous (perhaps untowards) usage\nMachine learning opportunities (previous utterances can be used as a reference for popular commands)\nRepeat a command from the 'last x commands' list","Q_Score":1,"Tags":"python,python-3.x,tkinter,artificial-intelligence","A_Id":63049029,"CreationDate":"2020-07-23T07:21:00.000","Title":"How to know the last launch time of a Python Program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm reviewing the concepts of OOP, reading .\nHere the book defines interface as\n\nThe set of all signatures defined by an object\u2019s operations is called the interface to the object. (p.39)\n\nAnd the abstract class as\n\nAn abstract class is one whose main purpose is to define a common interface for its subclasses. An abstract class will defer some or all of its implementation to operations defined in subclasses; hence an abstract class cannot be instantiated. The operations that an abstract class declares but doesn\u2019t implement are called abstract operations. Classes that aren\u2019t abstract are called concrete classes. (p.43)\n\nAnd I wonder, if I define an abstract class without any internal data (variables) and concrete operations, just some abstract operations, isn't it effectively just a set of signatures? Isn't it then just an interface?\nSo this is my first question:\n\nCan I say an abstract class with only abstract functions is \"effectively (or theoretically)\" an interface?\n\nThen I thought, the book also says something about types and classes.\n\nAn object\u2019s class defines how the object is implemented. The class defines the object\u2019s internal state and the implementation of its operations. In contrast, an object\u2019s type only refers to its interface\u2014the set of requests to which it can respond. An object can have many types, and objects of different classes can have the same type. (p.44)\n\nThen I remembered that some languages, like Java, does not allow multiple inheritance while it allows multiple implementation. So I guess for some languages (like Java), abstract class with only abstract operations != interfaces.\nSo this is my second question:\n\nCan I say an abstract class with only abstract functions is \"generally equivalent to\" an interface in languages that support multiple inheritance?\n\nMy first question was like checking definitions, and the second one is about how other languages work. I mainly use Java and Kotlin so I'm not so sure about other languages that support multiple inheritance. I do not expect a general, comprehensive review on current OOP languages, but just a little hint on single language (maybe python?) will be very helpful.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":390,"Q_Id":63050082,"Users Score":2,"Answer":"No.\n\nIn Java, every class is a subclass of Object, so you can't make an abstract class with only abstract methods.  It will always have the method implementations inherited from Object:  hashCode(), equals(), toString(), etc.\n\nYes, pretty much.\n\nIn C++, for example, there is no specific interface keyword, and an interface is just a class with no implementations.  There is no universal base class in C++, so you can really make a class with no implementations.\nMultiple inheritance is not really the deciding feature.  Java has multiple inheritance of a sort, with special classes called \"interfaces\" that can even have default methods.\nIt's really the universal base class Object that makes the difference.  interface is the way you make a class that doesn't inherit from Object.","Q_Score":2,"Tags":"java,python,oop,inheritance,design-patterns","A_Id":63054571,"CreationDate":"2020-07-23T08:31:00.000","Title":"Is an abstract class without any implementation and variables effectively interface?","Data 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":"Currently, using pygame.joystick.init() only works if the controller is on before running the script. I'd like to be able to turn the game on and then turn on the controller while it is running to switch easily between keyboard and joystick.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":115,"Q_Id":63050950,"Users Score":1,"Answer":"Some reading indicates that pygame 1.# does not seem to be able to deal with joysticks being added or removed while running. That is because pygame is based on SDL, and before version 2, SDL does not handle joysticks being added or removed while running.\nSDL vesion 2 apparently does and pygame version 2 is based on SDL 2. You could try upgrading to pygame version 2 and see if that helps.","Q_Score":0,"Tags":"python,pygame","A_Id":63060417,"CreationDate":"2020-07-23T09:20:00.000","Title":"How to detect controllers while the game is running in PyGame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed pandas in my venv. The import statement from pandas import DataFrame is not recognized in Pycharm. DataFrame is underlined with red line. When I run the code, it works fine. Why DataFrame is not recognized.\n\nAlso suddenly, relative paths of local packages stopped working in PyCharm but code runs fine though.\nAbsolute path also works fine.\n\n\nI have tried setting project as \"source code\"  in settings but does not solve the problem.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":63053400,"Users Score":0,"Answer":"You might install the DataFrame on your default python environment.\nTo make sure you have installed on venv environment.\n1- Activate your venveither form terminal or command-prompt by execuitng: source ~\/envs\/venv\/bin\/activate\n2- Install pandas: pip install pandas\nNow If you have installed correctly you will have a warning. Otherwise the package will be installed on your venvenvironment.","Q_Score":0,"Tags":"python,pycharm","A_Id":63119146,"CreationDate":"2020-07-23T11:40:00.000","Title":"Cannot import DataFrame in PyCharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed pandas in my venv. The import statement from pandas import DataFrame is not recognized in Pycharm. DataFrame is underlined with red line. When I run the code, it works fine. Why DataFrame is not recognized.\n\nAlso suddenly, relative paths of local packages stopped working in PyCharm but code runs fine though.\nAbsolute path also works fine.\n\n\nI have tried setting project as \"source code\"  in settings but does not solve the problem.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":51,"Q_Id":63053400,"Users Score":1,"Answer":"File -> invalidate Caches\\Restart (did not work)\nRemoved .idea file and opened project again (did not work)\nPointed project to new venv with all installed dependencies (did not work)\n\nFinally, uninstalled PyCharm and installed again. It solved my problem.","Q_Score":0,"Tags":"python,pycharm","A_Id":63130139,"CreationDate":"2020-07-23T11:40:00.000","Title":"Cannot import DataFrame in PyCharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a web application with Django and I show the graphs in the website. The graphs are obtained from real time websites and is updated daily. I want to know how can I send graphs using matplotlib to template and add refresh option with javascript which will perform the web scraping script which I have written. The main question is which framework should I use? AJAX, Django REST, or what?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":85,"Q_Id":63053644,"Users Score":1,"Answer":"You're better off using a frontend framework and calling the backend for the data via JS. separating the front and backend is a more contemporary approach and has some advantages over doing it all in the backend.\nFrom personal experience, it gets really messy mixing Python and JS in the same system.\nUse Django as a Rest-ful backend, and try not to use AJAX in the frontend, then pick a frontend of your choice to deliver the web app.","Q_Score":1,"Tags":"javascript,python,django,ajax","A_Id":63054092,"CreationDate":"2020-07-23T11:53:00.000","Title":"How to control Django with Javascript?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I try to copy the files in virtual environment I get the above error.The command is cp -r AmritaAura_local\/amrita_aura\/aura  AmritaAura_local\/local_setup\/venv\/lib\/python2.7\/site-packages.\nWhere am I going wrong ? What does the error indicate in python?What does cannot stat means ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":140,"Q_Id":63054547,"Users Score":0,"Answer":"Proper path name should be given in destination directory and also the location of source directory should be opened in terminal.Then cp -r src_directory(only the relative path) destination_directory(full path) should be given.","Q_Score":0,"Tags":"python,file,virtualenv,cp,stat","A_Id":63063812,"CreationDate":"2020-07-23T12:41:00.000","Title":"cp: cannot stat 'AmritaAura_local\/amrita_aura\/aura': 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":0,"Web Development":0},{"Question":"I have a field in mysql which stores the value as \"Gold Area (<90 g\/m\u00b2)\". I wrote a code to get the same using python code. However when I return the data the value is converted to \"Gold Area (<90 g\/m\\u00b2)\".\nI understand we can use the subscript utility while printing. But here my requirement is to send the value as a json response. How can i change the code to not convert the Superscript to \\u00b2 and keep it is from db which is m\u00b2\nany help is greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":63055743,"Users Score":1,"Answer":"if you are using flask then you might look at an option\nJSON_AS_ASCII = False\nin the configuration","Q_Score":1,"Tags":"python,mysql,python-3.x,superscript","A_Id":64459055,"CreationDate":"2020-07-23T13:43:00.000","Title":"Superscript from database converted to \\u00b2","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created an Python Web Scraper app and it works fine on my pc but sadly not for my friend who I sent it to. I used Pyinstaller to create the application and got two folders, \"build\" and \"dist\". I sent the information of both of them to my friend. Still it doesn't work...can anyone help me please?\nStay healty!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":33,"Q_Id":63056522,"Users Score":2,"Answer":"Have you added the webdriver binary to pyinstaller?","Q_Score":0,"Tags":"python,selenium-webdriver,tkinter,pyinstaller","A_Id":63057233,"CreationDate":"2020-07-23T14:22:00.000","Title":"Python (with Tkinter and Selenium Webdriver, created with pyinstaller) app doesn't work on other pc's","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe with two columns, one column is medicine name of dtype object it contains medicine name and few of the medicine name followed by its mg(eg. Avil25 and other row for Avil50) and other column is Price of dtype int . I'm trying to convert medicine name column into a scipy csr_matrix using the following lines of code:\nfrom scipy.sparse import csr_matrix\nsparse_matrix = csr_matrix(medName)\nI am getting the following error message:\n\nTypeError: no supported conversion for types: (dtype('O'),)\n\nas an alternative way I tried to remove the integers using(medName.str.replace('\\d+', '')) from dataframe and tried sparse_matrix = csr_matrix(medName.astype(str)) . Still i am getting the same error.\n\nWhat's going on wrong here?\nWhat is another way to convert this dataframe to csr matrix?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":63056536,"Users Score":0,"Answer":"you will have the encode strings to numeric data types for it to be made sparse. One solution ( probably not the most memory efficient) is to make a networkx graph, where the string-words will be the nodes, using the nodelist of the graph you can keep track of the word to numeric mapping.","Q_Score":0,"Tags":"python-3.x,pandas,scipy,sparse-matrix","A_Id":63061525,"CreationDate":"2020-07-23T14:23:00.000","Title":"converting a Object (containing string and integers) Pandas dataframe to a scipy sparse matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My dataset contains incorrect date of birth entries. How do I resolve this?,since this data is important to my analysis as it will help in segmentation. E.g: a customer has a date of birth entry of 1843-12-21, which is clearly not proper. Similar issues are also present.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":63057658,"Users Score":0,"Answer":"There are different ways to deal with it:\n\nTry to understand the reason of the error. Maybe in some cases people input data in the wrong fields.\n\nMake an educated guess - for example 1843 could be 1943.\n\nConsider these errors to be missing values.","Q_Score":0,"Tags":"python-3.x,data-science,data-cleaning,data-processing","A_Id":63097521,"CreationDate":"2020-07-23T15:21:00.000","Title":"How to resolve improper date of birth data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed\/imported streamlit, numpy, and pandas but I do not know how I can see the charts I have made. How do I deploy it on repl.it?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":230,"Q_Id":63058342,"Users Score":1,"Answer":"You can not deploy streamlit application within repl.it because\n\nIn order to protect against CSRF attacks, we send a cookie with each request.\nTo do so, we must specify allowable origins, which places a restriction on\ncross-origin resource sharing.\n\nOne solution is push your code from repl.it to GitHub. Then deploy from GitHub on share.streamlit.io.","Q_Score":0,"Tags":"python,repl.it,streamlit","A_Id":68072848,"CreationDate":"2020-07-23T15:56:00.000","Title":"How can I deploy a streamlit application in repl.it?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a data scientist use jupyter notebook a lot and also have started to do lot of development work and use Vscode for development. so how can I get Jupyter notebook theme in vscode as well? I know how to open a Jupyter notebook in vscode by installing an extension but I wanted to know how to get Jupyter notebook theme for vs code. so it gets easier to switch between both ide without training eyes","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":8574,"Q_Id":63059592,"Users Score":3,"Answer":"You can edit your VScode's settings by:\n1- Go to your Jupyter extension => Extension settings => and check \"Ignore Vscode Theme\".\n2- Click on File => preference=> color Theme\n3-  Select the theme you need.\nYou can download the theme extension from VSCode's extension store, for example: Markdown Theme Kit; Material Theme Kit.\nNote:\nYou need to restart or reload VSCode to see the changes.","Q_Score":9,"Tags":"python,visual-studio-code,jupyter-notebook","A_Id":69246178,"CreationDate":"2020-07-23T17:07:00.000","Title":"How to get jupyter notebook theme in vscode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install Tensorflow 1.14 for a package that I am trying to use. I tried:\npip3 uninstall tensorflow\nThen I tried to install Tensorflow 1.14 using:\npip3 install tensorflow==1.14\nand I get the following error\nERROR: Could not find a version that satisfies the requirement tensorflow==1.14 (from versions: 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.3.0rc0, 2.3.0rc1, 2.3.0rc2) ERROR: No matching distribution found for tensorflow==1.14\nI also tried making a new virtual env and tried the following commands but it didn't work. Is there any way to install Tensorflow 1?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8604,"Q_Id":63059979,"Users Score":0,"Answer":"I faced the same issue while installing tensorflow version 1.14.0. The best solution i tried is:\nNote that your Python version is 3.7.8\nSteps:\n\nOpen python 3.7.8 script folder C:\\Users\\mypc\\AppData\\Local\\Programs\\Python\\Python37\\Scripts folder and type \"cmd\" in above bar, which opens it in the command prompt.\nTo install tensorflow-1.14.0 type : pip install tensorflow==1.14.0\nTo install keras-2.2.4 type : pip install keras==2.2.4","Q_Score":13,"Tags":"python,tensorflow","A_Id":72236507,"CreationDate":"2020-07-23T17:33:00.000","Title":"Cannot install TensorFlow 1.x","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For context, I'm currently working on a machine learning problem where there exists fairly large imbalances in our dataset, and we've been trying to find ways to work around our data imbalance to extract useful metrics\/measures of performance. One metric we've really wanted to use is a ROC curve plot for each of our classes, but we've found that since a large portion of our data is negative in nature (meaning that most of the time, our images don't contain anything in them), the False Positive Rate is basically getting \"squished\" close to 0 since our number of True Negatives is so large, so our ROC plots look basically perfect when in reality they are being heavily skewed by our high TN count.\nFor example, a given class can have as many as 30,000 Negative cases, but only 2,000 or so positive cases, so 90+% accuracy can be achieved if the model were to simply always predict negatively. Our problem is also a multi-class problem, so it's not feasible to simply remove negative cases from the data since removing a negative case could be inadvertently removing a positive case for another class in a given image. We've done what data thinning\/reduction we can by removing all images where there are no occurrences of any class in a given image, but there still exists a large data imbalance in our data after this thinning process.\nIn the meantime we've switched over to using precision-recall plots, and those have yielded more reasonable results since precision and recall don't depend on the True Negative count, but we've recently wanted to switch back to using ROC curves, and I'm trying to find a solution to address the skewed plots we were seeing prior.\nOne idea I had was simply plotting the #True Positives vs. #False Positives, and since doing this I've seen more reasonable looking curves. By doing this, I am able to avoid the issue of the False Positive Rate getting squished down due to the high TN count, and the plot essentially conveys the same information (the trade-off between True Positives and False Positives). What's wrong with this idea? Is there any other approach I can take to getting better results from my ROC plots?\nOne idea my colleague proposed was as follows:\n\" Do you think you can redo the ROC curves by removing most of these non-events from the statistics? Maybe keep about as much non-events as for the class with the highest number of events? \"\nI wasn't sure exactly what he meant, so I asked him for some clarification and he said this:\n\" You can still re-balance the data for your ROC analysis by randomly excluding most of the \"nothing\" events so that they do not dominate the statistics in your confusion matrix. Assuming your have enough random samples of the \"nothing events\" in your analysis, that smaller subset can be an accurate representation of the true \"nothing\" population \"\nI'm still not sure what exactly he means by this or how I am supposed to implement it, and I've asked him again for clarification, but in the mean time I was hoping I could get some more insight elsewhere.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":170,"Q_Id":63060554,"Users Score":0,"Answer":"No, plotting TP against FP does not make sense, in your case it would make more sense to use the precision\/recall curve. On one axis, you plot the precision (aka positive predictive value) and on the other axis you plot the recall (aka sensitivity).\nThe precision is given by TP\/(TP+FP) and recall is given by TP\/(TP+FN), where TP is true positives, FP is false positives and FN is false negatives.","Q_Score":0,"Tags":"python,roc,confusion-matrix,precision-recall","A_Id":63134949,"CreationDate":"2020-07-23T18:10:00.000","Title":"Could I make a ROC curve using TP vs. FP instead of TPR vs. FPR?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to develop a python script to create topics in MSK using AWS SDK boto3. I don't see any methods to create a topic in Kafka.client. I can use kafka-python but wanted to use AWS SDK or CDK\nPlease suggest.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1175,"Q_Id":63060816,"Users Score":2,"Answer":"Amazon MSK APIs are meant for operations for managing an Amazon MSK cluster. For operations with Apache Zookeeper or Apache Kafka you can use kafka-python or execute Kafka\/Zookeeper APIs from a jumpbox to MSK brokers directly.","Q_Score":1,"Tags":"python-3.x,boto3,aws-msk","A_Id":63061731,"CreationDate":"2020-07-23T18:26:00.000","Title":"Creating MSK topic using python script and boto3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Conda and could not find the information that I was looking for. My team builds Python versions from source and we are now also looking to support Conda-Jupyter scenarios.\nConda creates environments with its own built version of Python but we are interested to know if it is possible to use Conda with the Python versions that we built from source instead.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":45,"Q_Id":63062430,"Users Score":1,"Answer":"Maybe this setting can help you:\nTools -> Preferences -> Python interpreter -> Use the following Python interpreter","Q_Score":1,"Tags":"python,conda","A_Id":63062671,"CreationDate":"2020-07-23T20:12:00.000","Title":"Can I use Conda with a python version that was built from source?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Conda and could not find the information that I was looking for. My team builds Python versions from source and we are now also looking to support Conda-Jupyter scenarios.\nConda creates environments with its own built version of Python but we are interested to know if it is possible to use Conda with the Python versions that we built from source instead.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":63062430,"Users Score":0,"Answer":"After some research on the conda forums and web I came to know that I would need to a build a custom Conda package to package my custom built Python. Since this is not a trivial task to do, I am abandoning this idea.","Q_Score":1,"Tags":"python,conda","A_Id":63175371,"CreationDate":"2020-07-23T20:12:00.000","Title":"Can I use Conda with a python version that was built from source?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Jupyter Notebook starts normally but when I try to start Jupyter Lab (either via cmd or conda prompt) I get the following error:\n\nCannot open C:\\Users\\user\\Miniconda3\\envs\\ds_env\\Scripts\\jupyter-lab-script.py\n\nI checked and the \"jupyter-lab-script.py\" file is actually missing. It was working before but I think this happened after the last update.\nHow can I get it to work?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1564,"Q_Id":63069382,"Users Score":0,"Answer":"The problem got resolved on its own after installing another update.","Q_Score":0,"Tags":"python,conda,jupyter-lab","A_Id":64048573,"CreationDate":"2020-07-24T08:03:00.000","Title":"Jupyter Lab not opening anymore","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Jupyter Notebook starts normally but when I try to start Jupyter Lab (either via cmd or conda prompt) I get the following error:\n\nCannot open C:\\Users\\user\\Miniconda3\\envs\\ds_env\\Scripts\\jupyter-lab-script.py\n\nI checked and the \"jupyter-lab-script.py\" file is actually missing. It was working before but I think this happened after the last update.\nHow can I get it to work?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1564,"Q_Id":63069382,"Users Score":0,"Answer":"open you terminal and type:\n pip install jupyterlab\nTo open jupyter lab type:\njupyter lab\nDo this again to reinstall\/renew it","Q_Score":0,"Tags":"python,conda,jupyter-lab","A_Id":65506993,"CreationDate":"2020-07-24T08:03:00.000","Title":"Jupyter Lab not opening anymore","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Jupyter Notebook starts normally but when I try to start Jupyter Lab (either via cmd or conda prompt) I get the following error:\n\nCannot open C:\\Users\\user\\Miniconda3\\envs\\ds_env\\Scripts\\jupyter-lab-script.py\n\nI checked and the \"jupyter-lab-script.py\" file is actually missing. It was working before but I think this happened after the last update.\nHow can I get it to work?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1564,"Q_Id":63069382,"Users Score":0,"Answer":"Something like that happened to me before with jupyter notebook and I re installed the whole anaconda navigator, seems that it just needed to be updated.","Q_Score":0,"Tags":"python,conda,jupyter-lab","A_Id":63069506,"CreationDate":"2020-07-24T08:03:00.000","Title":"Jupyter Lab not opening anymore","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Note:  this is not asking whether a Python dict keeps its order.\nQuestion:  is Python dict order guaranteed to where I can teach beginners that they can rely on it?\nSometimes my Python students assume that a dict will keep its order, because it does.  But traditionally a dict is considered unordered.\nUsually I teach them not to rely on this order, but I'm wondering whether it is a permanent part of Python and whether I can allow them to rely on it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":63075036,"Users Score":0,"Answer":"You should tell them that practically Python 3.7+ behaves like an OrderedDict (also Python 3.6 but this is not enforced), but that dictionaries don't necessary have this characteristic and is just how the implementation in Python works.","Q_Score":1,"Tags":"python,dictionary","A_Id":63075149,"CreationDate":"2020-07-24T13:54:00.000","Title":"Safe to assume (and teach) that a Python dict will stay ordered?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have a few long running tasks (100 hours+) in a few DAGs. The tasks internally call an http endpoint to kick off a process, and then poll the status + sleep for 30 sec in a loop. After about 40 hours or so, Airflow marks the job as failed, but there is no indication in the log as to why - last item printed for the task run was a  \"Sleeping for 30 sec\" statement\". The triggered http process is also up and running.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":763,"Q_Id":63075796,"Users Score":1,"Answer":"If your objective is to wait until a status change, use sensors with rescheduling(maybe with a larger poll wait time). Your approach might be blocking workers and somehow if the worker lost its communication with the scheduler. Those tasks will get marked as zombies and it might get killed.","Q_Score":0,"Tags":"python,airflow","A_Id":63078092,"CreationDate":"2020-07-24T14:35:00.000","Title":"Airflow marking long running tasks as Failed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I know that for jupyter notebooks and jupyter lab, there are available code formatter extensions such as nb_blackor blackcellmagic. However when I installed them, it doesn't seem to work on google colab.\nDo you know if there are any native option in colab or an extension that formats code (pep8 compliant)?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4691,"Q_Id":63076002,"Users Score":2,"Answer":"I have tried everything, none of the JupyterLab\/Notebook backend hack methods seem to work as of February 2022. However, until later here is a relatively simple workaround:\n[Run only once, at startup]\n\nConnect to your drive\nfrom google.colab import drive\ndrive.mount(\"\/content\/drive\")\n\nInstall black for jupyter\n!pip install black[jupyter]\n\nRestart kernel\n\n\n[Then]\n\nPlace your .ipynb file somewhere on your drive\nAnytime you want format your code run:\n!black \/content\/drive\/MyDrive\/YOUR_PATH\/YOUR_NOTEBOOK.ipynb\nDon't save your notebook, hit F5 to refresh the page\nVoila!\nNow save!","Q_Score":49,"Tags":"google-colaboratory,pep8,python-black","A_Id":71001241,"CreationDate":"2020-07-24T14:47:00.000","Title":"Code formatter like nb_black for google colab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm making this game with Kivy and it's a game where there's a start screen with an MDToolbar, an MDNavigationDrawer, two Images, three MDLabels and a OneLineIconListItem that says 'Start Game' and when you click on it the game is supposed to start.\nThe game screen contains:\n\nViruses\nMasked man\nSoap which you use to hit the viruses\nCurrent score in an MDLabel\nA button to go back to the start screen\n\nIssues:\n\nThe background music for the game starts playing before the game screen is shown (When the start screen is shown) - ScreenManager issue\nWhen I click the button to go back to the start screen, the button doesn't get clicked - MDFlatButton issue\n\nI used on_touch_down, on_touch_move, and on_touch_up for this game and I know that's what's causing the MDFlatButton issue. So does anyone know how I'm supposed to have the on_touch_* methods defined AND have clickable buttons?\nAnd I don't know how to fix the ScreenManager issue either.\nI know I haven't provided any code here, but that's because this post is getting too long. I already got a post deleted because people thought the post was too long and I was providing too much code and too less details. And I don't want that to happen again. If anyone needs to view the code of my project, I will leave a Google Docs link to it.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":267,"Q_Id":63079352,"Users Score":0,"Answer":"I fixed my app.\nJust in case anyone had the same question, I'm gonna post the answer here.\n\nTo get a clickable button, you have to create a new Screen or Widget and add the actual screen as a widget to the new class. Then, you can add buttons to the new class. This works because the button is on top of the actual screen. So when you click anywhere in the button's area, the button gets clicked and the on_touch_* methods of the actual screen don't get called.\n\n\nAnd to fix the ScreenManager issue, you just have to expirement.","Q_Score":0,"Tags":"python,android,button,kivy,game-development","A_Id":63083213,"CreationDate":"2020-07-24T18:18:00.000","Title":"KivyMD MDFlatButton not clickable & Kivy ScreenManager not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with flask(sqlalchemy) and postgres, i already declared a model with a datetime column that defaults to datetime.utcnow() courtesy of the datetime module in python. however i noticed on new row insertions the time never changes, i did a few digging and found i shouldn't be calling the function but rather passing it thus: datetime.utcnow\nSo, i now wish to alter the column to reflect this change without having to drop the table\/column.\nI already tried ALTER TABLE mytable ALTER COLUMN trans_time SET DEFAULT datetime.utcnow and i get the following error: ERROR:  cannot use column reference in DEFAULT expression\nNote: I don't have migrations set up for this project so that would not help for now. i only need to do this via sql commands.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":197,"Q_Id":63079751,"Users Score":0,"Answer":"I would\n\nRename the original table\nCreate a new table with the original table name with the default value as you now want it\nPopulate the new table with data from the original one\nDrop the old table if everything looks OK.\n\nHope that works for you. Good luck!","Q_Score":0,"Tags":"python,sql,postgresql,datetime,flask","A_Id":63080384,"CreationDate":"2020-07-24T18:46:00.000","Title":"How to alter a postgres datetime column to default to datetime.utcnow","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create some Python3 Azure MySQL jobs in azure functions using SQL Alchemy.\nFunction runs locally with func start without a problem.\nIt's in fresh venv, on fresh Linux VM to exclude any possible package dependencies.\nDeploying to Azure via func azure functionapp publish {app_name} --build remote without any problems.\nBut upon calling the function I'm getting:\n\"name '_mysql' is not defined\"\nIt seems like the MySQLdb module is not installed, but my requirements.txt contains\nmysqlclient==2.0.1 and it's installing properly. Even weirder, it works great when I'm running the function locally.\nThis is the full error, sorry for the formatting:\nResult: Failure Exception: NameError: name '_mysql' is not defined Stack: File \"\/azure-functions-host\/workers\/python\/3.8\/LINUX\/X64\/azure_functions_worker\/dispatcher.py\", line 262, in _handle__function_load_request func = loader.load_function( File \"\/azure-functions-host\/workers\/python\/3.8\/LINUX\/X64\/azure_functions_worker\/utils\/wrappers.py\", line 32, in call return func(*args, **kwargs) File \"\/azure-functions-host\/workers\/python\/3.8\/LINUX\/X64\/azure_functions_worker\/loader.py\", line 76, in load_function mod = importlib.import_module(fullmodname) File \"\/usr\/local\/lib\/python3.8\/importlib\/__init__.py\", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File \"<frozen importlib._bootstrap>\", line 1014, in _gcd_import File \"<frozen importlib._bootstrap>\", line 991, in _find_and_load File \"<frozen importlib._bootstrap>\", line 961, in _find_and_load_unlocked File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed File \"<frozen importlib._bootstrap>\", line 1014, in _gcd_import File \"<frozen importlib._bootstrap>\", line 991, in _find_and_load File \"<frozen importlib._bootstrap>\", line 975, in _find_and_load_unlocked File \"<frozen importlib._bootstrap>\", line 671, in _load_unlocked File \"<frozen importlib._bootstrap_external>\", line 783, in exec_module File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed File \"\/home\/site\/wwwroot\/vm\/__init__.py\", line 4, in <module> from __app__.vm.get_vm import insert_vms File \"\/home\/site\/wwwroot\/vm\/get_vm.py\", line 3, in <module> from __app__.shared.db.models import VM File \"\/home\/site\/wwwroot\/shared\/db\/models.py\", line 3, in <module> from __app__.shared.db.base import Base, engine File \"\/home\/site\/wwwroot\/shared\/db\/base.py\", line 12, in <module> if not database_exists(url): File \"\/home\/site\/wwwroot\/.python_packages\/lib\/site-packages\/sqlalchemy_utils\/functions\/database.py\", line 462, in database_exists engine = sa.create_engine(url) File \"\/home\/site\/wwwroot\/.python_packages\/lib\/site-packages\/sqlalchemy\/engine\/__init__.py\", line 500, in create_engine return strategy.create(*args, **kwargs) File \"\/home\/site\/wwwroot\/.python_packages\/lib\/site-packages\/sqlalchemy\/engine\/strategies.py\", line 87, in create dbapi = dialect_cls.dbapi(**dbapi_args) File \"\/home\/site\/wwwroot\/.python_packages\/lib\/site-packages\/sqlalchemy\/dialects\/mysql\/mysqldb.py\", line 118, in dbapi return __import__(\"MySQLdb\") File \"\/home\/site\/wwwroot\/.python_packages\/lib\/site-packages\/MySQLdb\/__init__.py\", line 24, in <module> version_info, _mysql.version_info, _mysql.__file__","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1297,"Q_Id":63083246,"Users Score":1,"Answer":"Ok, this was my error from the beginning - I've forgot to put the driver in the connection string for the DB - ex. mysql+pymysql:\/\/mysqladmin(...)","Q_Score":1,"Tags":"python,python-3.x,sqlalchemy,azure-functions","A_Id":63129640,"CreationDate":"2020-07-25T01:06:00.000","Title":"Python3 SQLAlchemy Azure Function '_mysql' is not defined","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm pretty new to python and scrapy. Right now I'm using a spider that is utilizing selenium to load JS pages. I'm running a windows computer through Bootcamp and I have about 10GB of storage left, however, when I run my scrapy spider, within 30 minutes of running it takes up almost half of that storage and I'm not sure why. I turned HTTP Cache off in settings.py but it still is eating up several GBs of storage.\nI'm using the -o command in my cmd to save the output to a csv, but that's the only thing I can think of that would take up storage. Any advice would be greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":63083380,"Users Score":0,"Answer":"You have a couple of options with your information given. Most notably, run the python script on your mac instead of the Bootcamp windows. If your storage is being eaten up, you can try writing to a .txt instead of .csv. Maybe try giving an example of what you are loading up \/ trying to do so I could replicate","Q_Score":0,"Tags":"python,selenium,web-scraping,scrapy","A_Id":63083404,"CreationDate":"2020-07-25T01:30:00.000","Title":"Scrapy using significant computer storage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm running Python's http.server with this command:\npy -m http.server --bind 0.0.0.0\nI can access the server on the same computer by typing bob:8000 in a browser's address bar (I may or may not have named my computer Bob), but when I try to access the server in the same way from a different computer on the same network, it says\n\nThis site can\u2019t be reached\nbob\u2019s server IP address could not be found.\n\nI was able to access this server previously, but I haven't been able to since upgrading my internet and router.   How can I access this server from another computer?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":572,"Q_Id":63083674,"Users Score":2,"Answer":"hey there you should be using your IPv4 address if you are accessing it from another computer.You can only access the 0.0.0.0:8000 from your computer similarly you can only use the following address from your computer\n\n127.0.0.0:anyport\nlocalhost:anyport\n0.0.0.0:anyport\n\nYou can always find out your IPv4 address by typing ipconfig in cmd the the IPv4 address would be looking like this\n192.168.xxx.xxx,10.0.xxx.xxx\nAfter you try this you should be able to access the page from another computer\nGood luck!","Q_Score":3,"Tags":"python,networking,server","A_Id":63083771,"CreationDate":"2020-07-25T02:25:00.000","Title":"Why can't I access a simple Python server on a different computer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have info on a text file in this format and order, I want to segregate the lines whose starting with VAL from text file, each words and lines can be of variable size:\nVAL_ 603 StW_Lvr_Stat 0 \"NPSD\" 1 \"STW_UP\" 2 \"STW_DOWN\" 3 \"STW_FWD\" 4 \"STW_BACK\" ;\nVAL_ 5555 Node 0 \"Not_active\" 1 \"Active\" ;\nnow, if I want the data to be like:\nStW_Lvr_Stat NPSD 0\nStW_Lvr_Stat STW_UP 1\nStW_Lvr_Stat STW_DOWN 2\nStW_Lvr_Stat STW_FWD 3\nStW_Lvr_Stat STW_BACK 4\nNode Not_active 0\nNode Active 1\nHow can I do that if i need to save the results as the excel file?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":63084436,"Users Score":0,"Answer":"You can achieve this by using Backreferences and Find and Mark functionality in Notepad++.\nFind the matches using regex (say %(.*?)% ) and replace it by \\n%\\1%\\n , after this we will have our target word in separate lines (i.e. no line will have more than one matched word)\nUse the Search-->Find-->Mark functionality to mark each line with regex %(.*?)% and remember to tick 'Bookmark Line' before marking the text\nSelect Search-->Bookmark-->Remove Unmarked Lines\nSave the remaining text. It is the required list.","Q_Score":0,"Tags":"javascript,python,excel,notepad++","A_Id":63084673,"CreationDate":"2020-07-25T04:44:00.000","Title":"How to segregate specific pattern of data from a file Notepad++ using regular expression?Can that be exported to the excel sheet?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The numpy function np.random.choice takes in an optional parameter called 'p' that denotes the probability distribution of the values it is sampling . So , my question is , even though the function generates random values , do values that have higher probability more likely to be sampled ? Meaning , does it randomly choose a value from a subset of \" Most probable values \" ?\nAm I right in perceiving it that way  ? Or can someone please correct my assumption  ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":646,"Q_Id":63086570,"Users Score":0,"Answer":"It is an optional array of probabilities p with which respective elements of sampled array A are sampled. So A and p should have the same number of elements and all elements of p should add up to 1 (as all discrete probabilities should).","Q_Score":1,"Tags":"python,numpy,random,random-seed,probability-distribution","A_Id":63086602,"CreationDate":"2020-07-25T09:18:00.000","Title":"Probability distribution in np.random.choice","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have some data in Django database and i want to select them and copy them to an other external database in use  the structure of tables in Django database and in external database is same\ni hope find any help please for make this logic ,thank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":202,"Q_Id":63086763,"Users Score":0,"Answer":"If you want to start the process via a button, I would recommend that you use Aayush's code within a django view that is called by your button. If the transfer takes too much time to wait for the site to refresh afterwarda, you can call the view via ajax or you can call the script as a parallel process via the view.","Q_Score":0,"Tags":"python,django,database","A_Id":63091540,"CreationDate":"2020-07-25T09:38:00.000","Title":"how to Select data from django tables and insert them to an another external database in use?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have trained model with keras and saved in with the help of pytorch. Will it cause any problems in the future. As far as I know the only difference between them is Keras saves its model's weights as doubles while PyTorch saves its weights as floats.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":190,"Q_Id":63086902,"Users Score":1,"Answer":"You can convert your model to double by doing\n\nmodel.double()\n\nNote that after this, you will need your input to be DoubleTensor.","Q_Score":0,"Tags":"python,machine-learning,keras,pytorch","A_Id":63092605,"CreationDate":"2020-07-25T09:53:00.000","Title":"Saving model in pytorch and keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m using the GoogleCloudStorageToBigQueryOperator to create a small table in BigQuery using a csv file in GCS. I have the airflow in a VirtualBox on my local machine. Every time, this simple operation takes 15 minutes exactly to complete. I\u2019ve tried changing from Local to Celery Executor but it still takes 15 minutes. Any suggestions please to improve the performance?\nThanks a lot,\nSri.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":63088405,"Users Score":0,"Answer":"I've created a VM on the GCP and installed airflow on it. Moved the DAG on to it and the data got loaded within seconds.","Q_Score":0,"Tags":"python,google-cloud-platform,celery,airflow","A_Id":63123131,"CreationDate":"2020-07-25T12:38:00.000","Title":"Airflow - GCP Operator: GoogleCloudStorageToBigQueryOperator - Takes 15 minutes to complete","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I Have an dataset folder of size 690Mo in my google drive, I would to copy the hole dataset on my google colab notebook to train my model, but the process of copying is very long, so how I can download the folder from Google drive with use of python script ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3011,"Q_Id":63088546,"Users Score":0,"Answer":"Maybe, you have too many files on the root directory of Google Drive or in the dataset folder.\n\nIf you have too many files and folders in root directory, then you\nshould clean up and sort it in less folders.\n\n\nIf you have many files in dataset folder, then try the following\nsolutions:\n\nMake a compressed file of your dataset folder and save it to drive. Then while running copy that compressed file (will take less than a\nminute for 690Mb) and extract it in Colab.\n\nUpload your dataset to any other platform (say OneDrive, Mega, etc.), get the link, and download on Colab using that link.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,google-drive-api,google-colaboratory","A_Id":63088659,"CreationDate":"2020-07-25T12:54:00.000","Title":"Download folder from Google drive to colab notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say I have orthogonal vectors of dimension n. I have two questions:\n\nHow to create\/initialize n such orthogonal vectors in python using the existing packages (numpy, scipy, pytorch etc)? Ideally these basis vectors should be as random as possible given the constraints, that is avoiding values such as 1,0,-1 as much as possible.\nHow can I rotate them by an angle alpha so that they remain orthogonal in high dimensional space? Again, I would like to do this in python, preferably using existing implementation in some of the packages.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":665,"Q_Id":63089387,"Users Score":1,"Answer":"You could do a QR decomposition of a random matrix, and set the R-component to zero. This will yield a random orthogonal matrix.\nVary one of the Givens angles in the Q components and you get a random rotation.","Q_Score":1,"Tags":"python,numpy,scipy,rotational-matrices,orthogonal","A_Id":63092682,"CreationDate":"2020-07-25T14:13:00.000","Title":"Rotating high dimensional orthogonal vectors in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Writing my Second tkinter project, I faced a problem.\nThe problem is: I need to make some unclearable text in the field(like you can't clear it with backspace). Is there any way to do it?\nP. S. Don't suggest using Labels, I need unclearable text for TextField","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":63089883,"Users Score":0,"Answer":"You can create a textbox and make its state disabled.\ntb1 = Text(root, state = \"disabled\")\nNow you won't be able to edit the text inside the textbox.","Q_Score":0,"Tags":"python,python-3.x,tkinter,python-3.6","A_Id":63089993,"CreationDate":"2020-07-25T15:04:00.000","Title":"How do I make unclearable text in Tkinter's Text Field?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install Anaconda 3 on windows 7 (64bits).\nDuring the installation there are no error messages. It seems allright. However, I don't get Anaconda Prompt and Navigator.\nI already tried playing with environment variables and uninstall \/reinstall couple of times. Nothing works!\nI noticed that in the folder Anaconda3 there is a file _conda.exe. I also noticed there are no Scripts folder under Anaconda3.\nDespite the fact the installation reported no errors I think there is something wrong in the installation. When I type de command conda info I get:\n'conda' is not recognized as an internal or external command, operable program or batch file.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":278,"Q_Id":63090212,"Users Score":0,"Answer":"Did you try with the underscore?\n_conda.exe install -c conda-forge prompt","Q_Score":2,"Tags":"python,anaconda","A_Id":63090242,"CreationDate":"2020-07-25T15:35:00.000","Title":"Anaconda3 Installation - no error during installation, but anaconda prompt and navigator menus don't appear. And _conda.exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"im trying to read the information from a TM1650 (is working with a 7 segment and 3 digits display) to a raspberry.\nFirstable i was working with an arduino but after too many tryings y found that y cannot read diferents address value there at the same time(i need to read the adress value of 52,53 and 54 possition).\nI have also an raspberry pi 4 and i wanted to know if there ir an code than can helpme to read the display data.\npd: the display is in to another board, that i have no program, thats what i wanna get the data.\nSorry for my bad english","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":63092204,"Users Score":0,"Answer":"if someone needs help with that in the future, the solution is to use threads, i used the library protothreads. Just remind not to use \"delay\" , try to use \"millis\".  (Arduino)","Q_Score":0,"Tags":"python,raspberry-pi,display,i2c","A_Id":63458424,"CreationDate":"2020-07-25T18:45:00.000","Title":"Trying to read multiples address in i2c with raspberry","Data Science and Machine Learning":0,"Database and SQL":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":"VSCode, Python3.8.4 64-bit, first assignment with Jupyter notebooks. I have installed numpy but when I run import numpy as np I receive ModuleNotFoundError: No module named 'numpy'. I'm very new please be gentle.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":109,"Q_Id":63092643,"Users Score":1,"Answer":"Write pip list in anaconda prompt or cmd and search for it if you don t find it then it s a problem of path","Q_Score":1,"Tags":"python-3.x,numpy,jupyter-notebook","A_Id":63093019,"CreationDate":"2020-07-25T19:27:00.000","Title":"Numpy not recognized even though it is installed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"VSCode, Python3.8.4 64-bit, first assignment with Jupyter notebooks. I have installed numpy but when I run import numpy as np I receive ModuleNotFoundError: No module named 'numpy'. I'm very new please be gentle.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":109,"Q_Id":63092643,"Users Score":1,"Answer":"I don't know why this worked but I changed my python interpreter in VSCode to 3.8.5 and now I'm all good.","Q_Score":1,"Tags":"python-3.x,numpy,jupyter-notebook","A_Id":63095482,"CreationDate":"2020-07-25T19:27:00.000","Title":"Numpy not recognized even though it is installed","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"help me please how can I use the pickle save if I have a lot of entry and I want to save all in one file and load form the file for each entry separately?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":63094076,"Users Score":0,"Answer":"You can't pickle tkinter widgets. You will have to extract the data and save just the data. Then, on restart you will have to unpickle the data and insert it back into the widgets.","Q_Score":0,"Tags":"python,tkinter,tkinter-entry","A_Id":63095044,"CreationDate":"2020-07-25T22:12:00.000","Title":"Tkinter pickle save and load","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I trying to feed a keras model tensor with numpy array values. But the tensor is 4D and the array is 3D. How can I to convert this 3D numpy array (128, 128, 3) in a 4D (?, 128, 128, 3) tensor?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":863,"Q_Id":63094152,"Users Score":0,"Answer":"Just use np.expand_dims to extend the first dimension. The 4D tensor means that you are having a batch of some images with 3 channels. Since you have just one image, add into an array and give it to the model or use np.expand_dims(image_ref, axis=0).","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":63094470,"CreationDate":"2020-07-25T22:22:00.000","Title":"How do I feed a tensor in Keras model using a numpy array values?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to install the python chess module and kept getting the same error: ModuleNotFoundError: No module named 'chess'\nI looked at some other code and noticed the same problem of not importing the module even though it worked before (in this case it was from sklearn.model_selection import train_test_split).\nI figured the problem was that I put all my code in a new folder. Once I took out all of my code from this folder it was able to work, but the chess module still didn't. This made me think that it must be an issue with the path.\nSince I use quite a few folders in order to organize my work. How do I fix this? \nI don't want to take out all of my code from every folder I have.  \nI am using VSCode, and I have already installed the chess module, several times, using pip, pip3, python -m install pip, conda, in the command prompt, terminal in VSCode, and miniconda.\nSo it is not an installation problem.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":162,"Q_Id":63096986,"Users Score":1,"Answer":"You can install module manually,\n\npip install python-chess\n\nRun this command in virtual environment, this will install python chess module","Q_Score":0,"Tags":"python","A_Id":63097004,"CreationDate":"2020-07-26T06:46:00.000","Title":"How to fix module installation problems with the python path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a desktop and web app, Just need to know how can i authorize this desktop application with same open web app browser after installed?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":272,"Q_Id":63097491,"Users Score":0,"Answer":"if you mean to authorize your desktop app via the login of user from any web browser, you can use TCP\/UDP socket or also for example , call an api every 2 seconds to check is user is loged in or not. in web browser , if user had be loged in , you can set login state with its ip or other data in database to authorize the user from desktop app.","Q_Score":0,"Tags":"python,c#,node.js,angular,desktop-application","A_Id":63097587,"CreationDate":"2020-07-26T07:50:00.000","Title":"Windows desktop application read session data from browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was able to mount Azure Blob Container to my Databricks DBFS and was able to read the data as well. While writing, I was able to see the files in the mount point from within databricks, however, it does not reflect in the blob storage. Can someone help?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":723,"Q_Id":63098954,"Users Score":0,"Answer":"Chances are that your path is incorrect.\nCheck the mounted path with dbutils.fs.mounts() and ensure it is in your saving path. Also check that your saving path starts with dbfs:\/ and not \/dbfs\/.\nDon\u2019t hesitate to share your script.","Q_Score":1,"Tags":"python,azure,azure-blob-storage,databricks,mount","A_Id":63100309,"CreationDate":"2020-07-26T10:31:00.000","Title":"Writing Data to Azure Blob Storage from Azure Databricks","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a script that does some webscraping for news and then uploads the info I scrape into a PostgreSQL DB in RDS. My question is regarding the preferred method for ensuring that the same news article is not recorded more than once.\nEach time I scrape, the web scraper returns 40 news articles. I have it set so that each article + headline is added to a table where the headline column has a UNIQUE key constraint. So I have 2 options in order to make sure that each article is only recorded once:\n\nUse a simple try and except to try to insert every article + headline into the table -- error is returned if the headline already exists but it is ignored.\nOr, I can query for the 40 most recently added articles in the database, compare their headlines to the ones I pulled, and then only insert those that aren't already in the database.\n\nMy question is: which one would be better performance-wise? My guess is that with a low number of articles number 1 would be better but as the number of articles increases it would be better to use number 2, is that correct?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":63099289,"Users Score":0,"Answer":"Identifying the duplicates locally to the scraper will be faster than making a round-trip to the database to do so, provided it isn't done in a dumb way.  But the difference is very unlikely to be meaningful, compared to the overhead of doing the scraping in the first place.\nBut if the scraper has a limited memory for headlines, you will need to have a catch-and-ignore capability anyway.","Q_Score":0,"Tags":"python,postgresql,psycopg2","A_Id":63101299,"CreationDate":"2020-07-26T11:08:00.000","Title":"PostgreSQL Unique Index performance","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a plot made using Python matplotlib that updates every time new sensor data is acquired. I also have a web GUI using vue. I'd like to incorporate the matplotlib figure into the web GUI and have it update as it does when running it independently. This therefore means not just saving plot and loading it as an image.\nCan anyone advise how to achieve this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":852,"Q_Id":63100695,"Users Score":1,"Answer":"In my opinion it's not reasonable way, There are very good visualizing tools powered by javascript, for example chart.js.\nyou can do your computation with python in back-end and pass data to front-end by API and plot every interactive diagrams you want using javascript.","Q_Score":0,"Tags":"javascript,python,vue.js,matplotlib","A_Id":63100798,"CreationDate":"2020-07-26T13:19:00.000","Title":"How to add a python matplotlib interactive figure to vue.js web app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a Music App using Kivy rather KivyMD in Python.\nI want to make the app to ask for login when the app has been opened for first time in the mobile or opened after a logout.\nPlease help me","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":140,"Q_Id":63100941,"Users Score":0,"Answer":"I don't know how to do it in Kivy and on mobile,\nbut for webpages you save a usertoken encrypted in the localstorage of your browser.\nI would use a file, where I add and delete this token\nand check the file (or Database) every time you start the app","Q_Score":0,"Tags":"python,android,kivy,kivymd","A_Id":63101052,"CreationDate":"2020-07-26T13:42:00.000","Title":"How to make the app ask for login when a user is not logged in. In KivyMD","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I haven't set up my spider as a Scrapy project, so don't have the settings.py file for settings. But I still want to implement as many methods as I can to avoid being blocked\/blacklisted. Is there any way to add these rotations and settings outside of a Scrapy project and only within the CrawlerRunner function???\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":63102923,"Users Score":0,"Answer":"If anyone else is wondering, there isn't a way to do this when using the CrawlerRunner function. I just had to set up a Scrapy project which didn't end up being as hard as I thought it would be. Theres plenty of info and \"hello world\" tutorials to follow online.\nGood luck!","Q_Score":1,"Tags":"scrapy,python-requests,web-crawler","A_Id":63417083,"CreationDate":"2020-07-26T16:38:00.000","Title":"Rotating IPs and user agents using Scrapy CrawlerRunner","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to sort a dictionnary like:\ndic = {\"monday\": 1, \"tuesday\": 1, \"wednesday\": 10, \"thursday\": 5, \"friday\": 10, \"saturday\": 11, \"sunday\": 11}\nand I'm trying to have:\ndic = {\"saturday\": 11, \"sunday\": 11, \"friday\": 10, \"wednesday\": 10, \"thursday\": 5, \"monday\": 1, \"tuesday\": 1}\nSo I tried this:\nsortedPairs = sorted(dic.items(), key=lambda x: (x[1],x[0]), reverse=True)\nand it seems to be working but for some reasons it never sorts the two lasts and I keep having this:\n{\"saturday\": 11, \"sunday\": 11, \"friday\": 10, \"wednesday\": 10, \"thursday\": 5, \"tuesday\": 1, \"monday\": 1}\nIf someone could please help me out It'd be awesome!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":558,"Q_Id":63103496,"Users Score":1,"Answer":"Close. You can try key=lambda x: (-x[1], x[0]) without reverse=True. What's important to note is that one element is being sorted in ascending order, while the other is being sorted in descending order (the latter takes priority in the tuple sort).","Q_Score":0,"Tags":"python,sorting,dictionary,key-value","A_Id":63103548,"CreationDate":"2020-07-26T17:33:00.000","Title":"How to sort a dictionary having string as keys and integer as values in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a text file that has encoded strings.\nI am decoding them using urllib.parse.unquote(string_df.encoded_string) and storing it in a dataframe.\nI want to export this dataframe to a text file.\nHowever, it just adds garbage values.\nFor example:\nEncoded String: %D1%81%D0%BF%D0%B0%D1%81%D0%BE-%D0%BF%D1%80%D0...\nDecoded using urllib.parse.unquote : \u0441\u043f\u0430\u0441\u043e-\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0441\u043a\u0438\u0439 \u0441\u043e\u0431\u043e\u0440\nExported value in text file: ?????-?????????????? ?????\nI have tried exporting in an excel file using to_excel but when I open the excel file, it gives illegal character error.\nAlso tried using numpy.savetxt but it gives the same ?????-?????????????? ?????.\nAnyway I can export it to a flat file and still have the desired \"\u0441\u043f\u0430\u0441\u043e-\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0441\u043a\u0438\u0439 \u0441\u043e\u0431\u043e\u0440\" result?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":81,"Q_Id":63103778,"Users Score":1,"Answer":"This looks like a character-encoding problem, make sure your CSV file is opened as 'UTF-8' or other compatible encoding, not ASCII, as '\u0441\u043f\u0430\u0441\u043e-\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0441\u043a\u0438\u0439 \u0441\u043e\u0431\u043e\u0440' are cyrillic and not latin characters.","Q_Score":0,"Tags":"python,python-3.x,pandas,numpy,decode","A_Id":63103890,"CreationDate":"2020-07-26T17:58:00.000","Title":"Python: to_csv for decoded dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using PyVISA to communicate\/control a Santec TSL-550 tunable laser via GPIB-USB.\nMy setup was working a few days ago and everything is correctly installed (NI-VISA, NI-MAX, NI 488.2, pip installed pyvisa-py, etc.), but I received this error randomly today.\nThe error in the terminal and in PyCharm is the same:\npyvisa.errors.VisaIOError:  VI_ERROR_ALLOC (-1073807300): Insufficient system resources to perform necessary memory allocation\nThere are little resources online and no solution was found on the NI forum.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":722,"Q_Id":63104797,"Users Score":0,"Answer":"The solution was simple, but obscure.\nThe GPIB side of the GPIB-USB adapter was not connected in all the way.  I tightened it and the error was resolved.","Q_Score":0,"Tags":"python,gpib,pyvisa","A_Id":63104798,"CreationDate":"2020-07-26T19:34:00.000","Title":"PyVISA Error: Insufficient system resources to perform necessary memory allocation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making an app to view CAN data from a car using appJar. I have a thread getting the CAN buffer then sending it to the main loop using queueFucntion. the function queued to the main loop iterates threw the buffer and sends the data to the Label with the same address as the data.\nI found that CAN overloads the main loop queue (raise Full). when I time the function sent to the main queue it has a run time of about ~4ms but when I add a label that matches a message it shoots up to ~100ms.\nI think this means the setLabel method takes to long. and I want to know if there is a faster way. Ultimately a faster setLabel won't actually solve my problem but it will help\nupdate\nI use wing personal 7 as an IDE for python and when I ran my program from outside of wing my code ran a lot faster and didn't overflow but my question still stands.\nupdate x2\nI implemented message filtering at the module level by hijacking the module as a parent. this helped a crap tonne but as my app runs it starts developing a delay between the car and the output and I think that means the buffer is filling up.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":63105212,"Users Score":0,"Answer":"I found that gui.addLabel() returns the actual label object.\nWhen you use gui.setLable(title, text) appJar uses a widget manager class to\nSearch a dictionary of created Label objects with a key matching the title\nsetLabel the sets that dict value using .config(text=text)\nSo basically you can bypass the searching by keeping track of the label yourself and using\nyourLabelHere.config(text='Your string here')\nIn theory, this is faster but int practice I don't really know","Q_Score":0,"Tags":"python,performance,user-interface,can-bus,appjar","A_Id":63106459,"CreationDate":"2020-07-26T20:13:00.000","Title":"Is there a faster setLabel method in appJar","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to set a prefix for each cog?\nFor example the Cog with admin commands has the prefix pa! and the cog for some fun commands pf!.\nWithout using on_message.\nEdit:\nI guess I have to go more in detail:\n\nMy cog for serverstats has a command called 'stats', this command should get\ntriggered when I'm using pa!\nMy cog for fun has a 'stats' command too. This should be triggered when I'm\nusing pf!\n\nMy only thought up to now was to set the default prefix to p! and then call the command astats. But I want to have a better way.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":681,"Q_Id":63105582,"Users Score":0,"Answer":"If all of your commands are in the on_message event, you can split the message content with spaces (\" \") and check the first element of the splitted list for the prefix and put the avaibale commands under an if statement. This could work, but will be slighly resource heavy depending on the amount of the commands","Q_Score":3,"Tags":"python,discord.py","A_Id":70622633,"CreationDate":"2020-07-26T20:53:00.000","Title":"Different prefix for each Cog?","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 set a prefix for each cog?\nFor example the Cog with admin commands has the prefix pa! and the cog for some fun commands pf!.\nWithout using on_message.\nEdit:\nI guess I have to go more in detail:\n\nMy cog for serverstats has a command called 'stats', this command should get\ntriggered when I'm using pa!\nMy cog for fun has a 'stats' command too. This should be triggered when I'm\nusing pf!\n\nMy only thought up to now was to set the default prefix to p! and then call the command astats. But I want to have a better way.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":681,"Q_Id":63105582,"Users Score":0,"Answer":"I think this is an interesting question as I have had the same one for some time. I had an idea for implementing this myself although it does use the on_message function but not just that.\nBasically my thought was to override the cog class and add a way for it to denote what prefix it should have. I thought use a custom argument in @commands.command to signify what prefix to use but this was for commands themselves.\nThen in the on_message function you will need to determine there what command to call. Possibly the use of a global dict that correlates what prefix to what command.\nThis was just my own personal brainstorming and you will need to keep in mind if you allow each server to set their own prefixes and how to go about allowing that plus allowing them to set custom prefixes for each command. Good luck I hope this helps","Q_Score":3,"Tags":"python,discord.py","A_Id":63105679,"CreationDate":"2020-07-26T20:53:00.000","Title":"Different prefix for each Cog?","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 run a python program using sudo (e.g. sudo python test.py) but within the python program when I use os.system(<some command>) to invoke other processes, I want to run them as a non-root user.\nIs this doable?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":351,"Q_Id":63106523,"Users Score":0,"Answer":"Another way to do this is to add a prefix sudo -u username in front of the command one wants to run to execute as that specific user. For example, one can use os.system('sudo -u user_a python test.py') to run test.py inside a python script as user_a.","Q_Score":0,"Tags":"python,linux","A_Id":63119588,"CreationDate":"2020-07-26T22:44:00.000","Title":"invoke os.system as a non-root user in a root-user launched python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My git was init in folder  ~\/ryan\/pythonproject\/  and then later on I started using PyCharm and it created a venv for the project after importing. So now I have:\n~\/ryan\/pythonproject\/venv\/\nThe first directory has my original work on the project, and then it appears I have a duplicate of my work under the venv folder.\nWhenever I commit\/add\/push it does the original folder as well as the venv folder.\nWhat I would like to do is have Git stop monitoring the original folder and only have git under the venv folder only. What's the best way to do that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":63108358,"Users Score":0,"Answer":"If you want to stop monitoring a folder you can put it to the .gitignore file. So i.e. you have:\n\nYourProject\/venv\/FolderA\nYourProject\/venv\/FolderB\nYourProject\/FolderA\nYourProject\/FolderB\n\nThen just add the lower two to the .gitignore .\nBut please think about it whether this is really what you want. Usually it is the other way around. Keep your files and ignore the build folder.","Q_Score":0,"Tags":"python-3.x,git","A_Id":63108415,"CreationDate":"2020-07-27T03:39:00.000","Title":"Moving Git to another folder, but I've got a problem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a full website with HTML and need to add an interactive piece that I could easily write with python (or even c\/c++). What can I can use\/do to accomplish this? The script will take user input do some calculations and display the output. I am completely lost on where to start, any help is appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":497,"Q_Id":63108419,"Users Score":0,"Answer":"If you want to embed Python in your HTML page the you will have to use a Python based web server which will have HTML form for data input and execute provided Python code as server side script and return you the desired result.\nYou could start by using Django.","Q_Score":0,"Tags":"html,python-3.x,embed","A_Id":63108494,"CreationDate":"2020-07-27T03:48:00.000","Title":"Python: How to embed my python script into a webpage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the IDE called Spyder for learning Python.\nI would like to know in how to go about in installing Python packages for Spyder?\nThank you","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":47041,"Q_Id":63109860,"Users Score":0,"Answer":"I have not checked if the ways described by people here before me work or not.\nI am running Spyder 5.0.5, and for me below steps worked:\n\nStep 1: Open anaconda prompt (I had my Spyder opened parallelly)\nStep 2: write - \"pip install package-name\"\n\nNote: I got my Spyder 5.0.5 up and running after installing the whole Anaconda Navigator 2.0.3.","Q_Score":9,"Tags":"python,installation,package,spyder","A_Id":69817111,"CreationDate":"2020-07-27T06:36:00.000","Title":"How to instal python packages for Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the IDE called Spyder for learning Python.\nI would like to know in how to go about in installing Python packages for Spyder?\nThank you","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":47041,"Q_Id":63109860,"Users Score":2,"Answer":"Spyder is a package too, you can install packages using pip or conda, and spyder will access them using your python path in environment.\nSpyder is not a package manager like conda,, but an IDE like jupyter notebook and VS Code.","Q_Score":9,"Tags":"python,installation,package,spyder","A_Id":63109934,"CreationDate":"2020-07-27T06:36:00.000","Title":"How to instal python packages for Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Okay, so I recently upgraded Spyder to version 4.1.4 and ever since I have the issue that all plots are extremely slow in showing. I am plotting Outline with Qt5 (v. 5.9.2). I already tried downgrading spyder back to 4.1.3 as well as 4.1.2 but neither helped.\nSo when I plot some simple data the plot in the extra window takes a few seconds to actually show the data and when I want to switch between one plot or the other it takes 5-10 seconds to show me the other plot.\nHas anyone else experienced this issue? I could not find anything online so far. Any suggestions are welcome :)","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":207,"Q_Id":63111318,"Users Score":2,"Answer":"I am experiencing the same thing. All my Qt5 applications became extremely slow after upgrading to Spyder 4.1.4, did not find a solution yet, unfortunately.\n\/e Rolling back my entire Conda environment did 'solve' it for me though.","Q_Score":3,"Tags":"python,pyqt5,spyder","A_Id":63112159,"CreationDate":"2020-07-27T08:20:00.000","Title":"Plotting Outline with PyQt5 extremely slow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 4 python scripts that I've mostly run from command-line. I've been trying to schedule them, but so far I haven't found a good way to do this. I have some requirements on how this all should work.\nMy scripts and what they do:\nscript number 1; Scans big number of records from database and does some processing.\nscript number 2; Does more processing, should run only after script number 1 is finished\nscripts number 3&4; these scripts are not related to 1 or 2, but they should be run hourly.\nAny recommendations what would the best approach for scheduling these scripts in Python?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":245,"Q_Id":63111353,"Users Score":0,"Answer":"I understand that the required job needs to schedule.\nFor scheduling jobs, It's good to use CI tools like Jenkins.\n\nmake a job for script 1 and 2 and run script 2 after completing script 1.\nmake two jobs separately for script 3 & 4 that running every hour.","Q_Score":2,"Tags":"python,python-3.x,scheduled-tasks","A_Id":63111492,"CreationDate":"2020-07-27T08:22:00.000","Title":"scheduling events in Python3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In a project I have to store a sequence of successive rotations of an object in python. I intend to store them using scipy.spatial.transform.Rotation objects.\nI have noticed that two options are available.\n\nI store a multitude of Rotation object in an array, each Rotation object containing a single rotation of my sequence.\n\nI store every rotation in the same Rotation object, effectively stacking them in a single object.\n\n\nI wondered what were the trade offs between the methods in terms of computational speed and data access speed. And ultimately which method should be preferred.\nIn my particular case:\n\nI have a fairly big set of rotations (around 2'000'000).\nI would like to speed up the accessing time for my data as much as possible.\nI am not concerned with memory usage so I am willing to trade space for speed.\nI don't intend to apply my rotations to anything. This is purely for storage use.\nI will have to access my rotations both as quaternions (.as_quat()) and as euler angles (.as_euler())\nI will have to split my data into smaller chunk at some point (And I am aware that if I use a single Rotation object I might have to re-create on per chunk in order to split my data correctly)\n\nWhat I am looking for:\n\nThe method that has the fastest access time\nThe method that is closer to good practice and coding convention in python\n\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":492,"Q_Id":63116277,"Users Score":1,"Answer":"Alright so I'll throw in the first elements I have.\nFor both you end up accessing an iterable and an object (just in a different order). Therefor there should not be any major difference in accessing speed.\nThe list of R is easier to access and manipulate afterwards. Hence if you are suceptible of changing anything in your rotation sequence it is the easier way. There for using a single object requires some extra-code for manipulation and might be slower.\nHowever it really depends on what you do and I have no data to prove that it is significantly slower.\nThe single object should take less memory space since there is only one instance, where as the list of object has nb_rotation times more.\nI already mentionned that this was not critical in my case it is not critical. Again I don't have any data to support this but I expect the difference to be significative since I have about 2'000'000 rotations.\nRegarding those facts I would make the decision as follow:\n\nIf you're just looking to use the object for storage then the single object is probably more efficient. (However that would apply very specific cases since you could also compute the resulting rotation and store a single quaternion or rotation object)\n\nIf you're looking to manipulate your data in any way then the list of object seems more indicated for that. The only real draw back is memory use how ever if you manipulate the data you would also have to unpack the single object at some point, leading to a similar problem, if not worse due to data duplication.\n\n\nIn my case I will be using the list of object.","Q_Score":2,"Tags":"python,performance,scipy,scipy-spatial","A_Id":63243054,"CreationDate":"2020-07-27T13:22:00.000","Title":"scipy.spatial.transform.Rotation Array of rotation vs Stack inside the same object","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to parse a Markdown string to an HTML format and struggle to find a solution to replace every second occurence of ** with <\/b>.\nBasicly, I want to write a function that would get a Makdown string as input and output HMTL string.\ninput: ** Hello!** everyone! **This should be HTML string**\noutput: ** Hello!<\/b> everyone! **This should be HTML string<\/b>\nAt the second step I am planning to use str.replace() function and substitute remaining ** with <b>\nWould be gratefull for any suggestions!","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":538,"Q_Id":63116945,"Users Score":2,"Answer":"I would implement a counter for the \"**\" substring (would make it go through the string and look for * and check if there is one more next to it) , and then if(counter % 2 == 0) replace.\nHope this helps, am new here.","Q_Score":1,"Tags":"python,string","A_Id":63117092,"CreationDate":"2020-07-27T14:00:00.000","Title":"Python. Replace every second \"**\" with  in a string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing a simple game where there is a part in it that needs to erase some text after a certain amount of time. I did some research but i am not able to find any methods or functions on how i would be able to do that. It would be great if it was a method that could only erase the text and not the whole screen.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":85,"Q_Id":63117421,"Users Score":1,"Answer":"You can \"erase\" things in pygame by blitting the part of background that goes into the specific spot.\nIf the background is all just a color, you can draw on that spot with the color.","Q_Score":0,"Tags":"python,text,pygame,erase,pygame-surface","A_Id":63117465,"CreationDate":"2020-07-27T14:25:00.000","Title":"Is there a method where i can erase text in Pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use the compare() function available in Pandas 1.1.0.  I am doing an update in Anaconda to Pandas, but it just takes me to 0.25?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":9042,"Q_Id":63119244,"Users Score":0,"Answer":"Typing conda update pandas should do the job.","Q_Score":1,"Tags":"python,pandas,conda","A_Id":63119285,"CreationDate":"2020-07-27T16:13:00.000","Title":"How to update Pandas in Anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use the compare() function available in Pandas 1.1.0.  I am doing an update in Anaconda to Pandas, but it just takes me to 0.25?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":9042,"Q_Id":63119244,"Users Score":1,"Answer":"Have you tried:\nconda install pandas=1.1.0.\nYou may need to add a channel that contains pandas 1.1.0.\nConda forge contains pandas 1.0.5\nconda config --add channels conda-forge","Q_Score":1,"Tags":"python,pandas,conda","A_Id":63119317,"CreationDate":"2020-07-27T16:13:00.000","Title":"How to update Pandas in Anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just got started with python and Im using PyCharm Build #PC-201.8743.11. I have 2 files in my project and Im using the Pipenv interpreter.\nEach file has its own working Run\/Debug configuration. Whats driving me mad is that if I switch file\/tab I also have to manually switch Run\/Debug configuration.\nIs there no way to use one Run\/Debug configuration per project or alternatively have the configuration locked per file so it switches the Run\/Debug configuration as I change tabs?\nThanks\nSahand","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":129,"Q_Id":63124438,"Users Score":0,"Answer":"The Run\/Debug configuration doesn't follow which file you have open because generally within a project you will only have one (or not many) entry points, while the rest of your files are modules\/libraries\/helpers\/whatever you want to call them.\nIf your two files are unrelated, then it sounds like you should have two different projects for them, in which case each project would have a Run\/Debug configuration. If they are related, but are just two different entry points, then unfortunately you will have to make sure you are running with the correct Configuration each time you want to run. Depending on the complexity of your setup, this can be as simple as right-clicking in the file itself and selecting \"Run <filename>\".","Q_Score":0,"Tags":"python,pycharm,run-configuration","A_Id":63124511,"CreationDate":"2020-07-27T22:20:00.000","Title":"PyCharm Run\/Debug configuration, do I really need one per file\/tab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I built a python script (bot) for a game and I do plan on building a GUI for it to make it more user friendly. However I wanted to add some sort of security along with it, something that would only give access to whoever I want, so maybe adding some kind of encryption key to it, I was thinking something along the lines of an encrypted key to unlock the files and with limited use(a few days for example). I am new when it comes to this specific 'security' topic, so I need help better understanding what my options are and what I can do or search for. Thank you for reading.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":63126414,"Users Score":0,"Answer":"after days of searching and trying I figured the easiest way was to use a web API to check requests, you can use for example cryptolens web api or any other api and your encrypted file will work just fine.","Q_Score":0,"Tags":"python,encryption","A_Id":63198843,"CreationDate":"2020-07-28T03:01:00.000","Title":"Safety\/Encryption for python script (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":"I have a discord bot written in python. It doesn't do much, however if you spam commands while it is in the middle to replying to another command, it freaks out. is there a way to make it refuse other commands until it has finished with the current process?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":63127434,"Users Score":1,"Answer":"Maybe some global variable \"ready\" and just allow to run commands if ready is true?\nAt start of command set ready to false and at the end to true.","Q_Score":1,"Tags":"python,discord,bots","A_Id":63129807,"CreationDate":"2020-07-28T05:13:00.000","Title":"(discord.py) How can I make it so my bot that doesn't reply to other commands until the current command is finished","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":"New to Python and getting errors when importing modules. I have the following structure (not sure if this is a good way to show folder structure):\n\necommerce\n\ncustomer\n\n__init__.py\ncontact.py\n\n\nshopping\n\n__init__.py\nsales.py\n\n\n\n\n__init__.py\n\n\nI want to import contact.py from customer into sales.py in shopping but get presented with: ModuleNotFoundError: No module named 'eccommerce'.\nI'm using this:\nfrom ecommerce.customer import contact at start of the sales.py file.\nAny ideas?\nVSCode, MacOS 10.14.6","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":162,"Q_Id":63129976,"Users Score":0,"Answer":"from ecommerce.customer import contact would work if 'customer' was a class in the ecommerce.py file, but in your case, those are different files so it doesn't work...\nThe correct syntax would be:\nfrom customer import contact\nbut you need to adjust those files.\nAnother way around would be to import os, navigate to that ecommerce folder like so: os.getcwd('insert dir path here'), and then import customer.","Q_Score":0,"Tags":"python,python-3.x,import,directory","A_Id":63130145,"CreationDate":"2020-07-28T08:27:00.000","Title":"ModuleNotFoundError - Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"New to Python and getting errors when importing modules. I have the following structure (not sure if this is a good way to show folder structure):\n\necommerce\n\ncustomer\n\n__init__.py\ncontact.py\n\n\nshopping\n\n__init__.py\nsales.py\n\n\n\n\n__init__.py\n\n\nI want to import contact.py from customer into sales.py in shopping but get presented with: ModuleNotFoundError: No module named 'eccommerce'.\nI'm using this:\nfrom ecommerce.customer import contact at start of the sales.py file.\nAny ideas?\nVSCode, MacOS 10.14.6","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":162,"Q_Id":63129976,"Users Score":0,"Answer":"One thing to pay attention to is where is your current working directory located. If you have the cwd set to be in ecommerce than you should be able to access the contact with the syntax you inputted.\nI ran into this issue several times and in the python documentation this setup should technically work, init files being parsed by the python parser as individual packages which you can then access. It seems though that it won't work with the standard python interpreter and I haven't found the answer why. One way to get around this is to do as @Sory suggests, at the beginning of your package entry, add the path to the environment variable. This is a work around though and can lead to problems later on.\nAnother option is to use a separate python interpreter, i use for example the IPython interpreter from Jupyter which runs with this setup perfectly fine. This will give you another external dependency though.\nBe sure though that the current working directory is set to be the root folder though as that is usually the first problem.","Q_Score":0,"Tags":"python,python-3.x,import,directory","A_Id":63132230,"CreationDate":"2020-07-28T08:27:00.000","Title":"ModuleNotFoundError - Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I should upload a Python program to GitHub and I was wondering about two things:\n\ndoes it make sense to upload an empty requirement.txt (the file was requested)\nwhere should I mention the version of Python I used to code my program?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":63133017,"Users Score":0,"Answer":"If you are not using any external libraries, I dont think you need to add a requirements.txt file.\nYou should mention the version of python that you used in a README file.","Q_Score":0,"Tags":"python,github,styles,coding-style,requirements.txt","A_Id":63133111,"CreationDate":"2020-07-28T11:25:00.000","Title":"Python Version + Requirement","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I built a python weather using tweepy and it works fine but it needs me to run the script with my computer.\nHow can I deploy my python script on a 'server' or something so I don't need to run the script 24\/7 on my laptop ?\nThanks for help !","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":70,"Q_Id":63134050,"Users Score":1,"Answer":"If your internet connection is stable and you don't mind initial cost: Raspberry Pi.\nIf you are a student you can get $50 store credit at Digital Ocean through the GitHub Education Pack.\nIf you have a credit card and don't mind verifying (doesn't cost and has no subscription costs) you can use the free tier in Google's cloud. With a verified CC you can host on Heroku 24\/7 for the entire month. Without a verified CC you can host it 24\/7 for ~2-3 weeks every month. AWS also offers some free tier solution.\nYou can also just outright pay for a VPS every month. I currently use Vultr and pay $2.5 per month.","Q_Score":1,"Tags":"python,hosting,tweepy","A_Id":63134282,"CreationDate":"2020-07-28T12:22:00.000","Title":"Python twtter-bot hosting?","Data Science and Machine Learning":0,"Database and SQL":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 built a python weather using tweepy and it works fine but it needs me to run the script with my computer.\nHow can I deploy my python script on a 'server' or something so I don't need to run the script 24\/7 on my laptop ?\nThanks for help !","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":70,"Q_Id":63134050,"Users Score":2,"Answer":"You could buy a raspberry pi.\nI use it only for such things.\nelectricity: ~2-4W\nIt isn't that expensive and you can host many projects for a low price.","Q_Score":1,"Tags":"python,hosting,tweepy","A_Id":63134151,"CreationDate":"2020-07-28T12:22:00.000","Title":"Python twtter-bot hosting?","Data Science and Machine Learning":0,"Database and SQL":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 project to find similarity among products. The model splits the excel data sheet into 90% training \/ 10% validation. When I check manually for validation the model works pretty well. But I am having trouble with the evaluation process. How should I find accuracy, precision, recall and F1 score to understand how well my model works?\nI am very new to machine learning, still learning, please give me some clues where to start.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":548,"Q_Id":63134913,"Users Score":3,"Answer":"Word2vec is an algorithm that's considered 'unsupervised' \u2013 it's not trained using specified 'correct' answers, but rather learns from the patterns in any data. As a result, there's no native-to-word2vec idea of 'accuracy', 'precision', etcetera \u2013 those concepts only have meaning in relation to a set of desired answers.\nSo to calculate those values, you have to use those word-vectors in some other downstream task, and devise your own evaluation for that downstream task. Then you can calculate accuracy & other values for that whole system (including the word2vec step). This may include applying your judgement, or that of other reviewers, about what the result \"should\" be in certain cases.\nWithout any examples of your data, it's not yet clear what your Word2Vec model is doing, and how products are represented in it. (What's the individual items in the customers_train list you've created? Where do product names\/identifiers come in? What kinds of similarity-questions or end-user operations do you need to be performing?)","Q_Score":0,"Tags":"python,cross-validation,word2vec,evaluation","A_Id":63146519,"CreationDate":"2020-07-28T13:08:00.000","Title":"How to find accuracy, precision, recall, f1 score for my word2vec model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to use pypy to make my python scripts faster.\nI downloaded the zip file form the website and unzipped it in the C drive. I have python 3 (32bit) and Microsoft Visual C++ 2017 Redistributable(x86) installed. I've added the path to the directory containing pypy3.exe to my PATH.\nWhen I try to run a script, for example: pypy app.py I get a message saying \"'pypy' is not recognized as an internal or external command, operable program or batch file.\"\nHow can I fix this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1044,"Q_Id":63136294,"Users Score":2,"Answer":"You should try to use pypy3 instead of pypy if you have downloaded pypy for python 3. This can be confirmed by looking inside the unzipped folder where you can see whether you have pypy3.exe or pypy.exe.\nIf that doesn't solve your issue, you need to ensure that the folder, where you unzipped pypy, is already in windows PATH environment variable. I am assuming you are using windows 10, in command line type the following:\necho $PATH\nIf you can't pypy folder in the PATH, add it using the command line:\nsetx PATH=%PATH%;C:\\location\\of\\pypy\nwhere you need to use the location of pypy folder. For example, if location of your pypy folder is C:\\pypy, type the following command:\nsetx PATH=%PATH%;C:\\pypy\nYou may need to restart your cmd for the changes to take effect.","Q_Score":1,"Tags":"python,pypy","A_Id":63137619,"CreationDate":"2020-07-28T14:20:00.000","Title":"Trying to run file with pypy results in \"'pypy' 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":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"In PyCharm the run button is in grey, not allowing me to click it to run my code. Is there a simple fix to this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":63136655,"Users Score":0,"Answer":"It is happening because your interpreter isn't configured for your current file. You can run your file easily by right clicking on the tab in which your file is open, and then selecting \"run (name of file)\". It will automatically configure that file, so you can use the run button after that to run it. Remember that you'll have to do this for every new file that you open.","Q_Score":0,"Tags":"python,pycharm","A_Id":63136874,"CreationDate":"2020-07-28T14:36:00.000","Title":"Run button isn't working in Pycharm. How do I fix this?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In PyCharm the run button is in grey, not allowing me to click it to run my code. Is there a simple fix to this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":63136655,"Users Score":0,"Answer":"In order to run things, you should configure few things:\n\nyou must select which is the root directory of your code: some people uses directly the root directory (but for test, docs, and eventually also utils (and likes), so also in this case you must select all roots), some people put code in a directory named src or as the package name.  In this case you should select it (left click on project panel [the panels with the file and folder list], Mark directory as... menu item).\n\nyou should have a default python environment for the project (or some available environments). Go to Settings, Project: ..., Project environment\n\nThen you should configure the run option. Usually it is on left from run button. Click it, and add a run setting: at minimum you should select which file should be run (and the environment, if you didn't yet have a default environment for your project). Later you can configure more suffs, as you like.\n\n\nThere are also other possible reasons, e.g. wrong extension, really bad formatted file, etc., which could hit new programmers. But in such case, we must have more information. Try with a very simple example, e.g. just one line: print(\"Hello World\"), to know that the above 3 steps are correct.","Q_Score":0,"Tags":"python,pycharm","A_Id":63147973,"CreationDate":"2020-07-28T14:36:00.000","Title":"Run button isn't working in Pycharm. How do I fix this?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hey I'm looking for a way to develop a windows form application like the one in visual studio, that using c# and has a visual designer option but that using python instead.\nI know that I can use tkinter to create a WFA but I really need that designer option.\nAny suggestions?\n--edit--\nThanks for your replies but does PyQt work with Visual Studio 2019 or do I have to use the Qt designer?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1228,"Q_Id":63136863,"Users Score":0,"Answer":"You can try PyQT. It has a visual Builder named QT Designer and you can generate a python file from it.","Q_Score":0,"Tags":"python,designer","A_Id":63136997,"CreationDate":"2020-07-28T14:46:00.000","Title":"A windows form application framework using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Apologies for the extremely vague question, but I've been wrecking my head trying to reduce the size of an Pyinstaller .exe and I decided to check what more experienced Python developers think about the general file size of such files. I'm working alone so I really don't know who else to ask.\nMy script needs quite a lot of modules, including APscheduler (including SQLAlchemy), sqlite3, tkinter, datetime, patool, shutil, but ultimately it's a relatively simple programme that should run as a Windows background service (ultimate goal). No pandas, numpy, scipy, keras or other big libraries are used. I also include 5 .png images for the GUI (around 350 kB total). This creates a 15.5 MB .exe and when running, the programme takes up 30 MB of the physical memory.\nAll advice online talks about using Python (not Anaconda) to create separate virtual environment for the file(I'm working on doing that now but it has been painful..). Looking at the dist folder Pyinstaller creates, most of the large .dll seem to be essential for the running of the programme (mfc140u.dll, python37.dll, tcl, tk, multiprocessing, sqlite, ..) and there doesn't seem to be pandas or tensorflow or other libraries that are otherwise installed in my conda site packages. I should also mention this is my first running programme, so I imagine the code architecture is not as efficient as it should be.\nParticularly APScheduler has quite a lot of dependencies, so I am not sure isolating it to a single virtual environment would have such a huge effect on the size. However, I was told the file should be a lot smaller so it does not burden the OS - a similar but slightly simpler software created in C# is just 64 KB.\nWould experienced developers say that this file size is normal given all the libraries\/dependencies, and what else can be done apart from creating a separate venv in pure Python?\nEDIT: After 3 days and battling a few thousand errors, I managed to make the script run in system Python (as opposed to Anaconda) with its separate virtual environment, in order to install only the packages I need. The result: the file is only about 2 MB smaller. So definitely was not worth it. But for other people it might be I guess.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1925,"Q_Id":63138311,"Users Score":2,"Answer":"The file size is normal. I don't think you can do much more with it.\nPyinstaller bundles python interpreter and supporting files along with it and the win32 dlls which will most probably take up atleast 12MB. You can check this by making a virtualenv with a hello world script and turn it into a exe.\nAs AKX says it doesn't burden the system much more than running python itself. The large file is not loaded into memory completely. It is unzipped into the %temp% folder with a folder name containing _MEIPASS and only required files are loaded into memory on the target machine. However, there is an overhead as startup to create a folder, unzip the files and delete them after exit.\nAlso don't compare it to C,C# etc because those languages don't need to bundle additional files like python because they would already be included in your system. Also I haven't used it myself but you may try py2exe. It is old but many apps use it and could reduce the file size a bit.","Q_Score":4,"Tags":"python,tkinter,exe,pyinstaller","A_Id":63162504,"CreationDate":"2020-07-28T16:04:00.000","Title":"How big is too big for a Pyinstaller exe file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Specifically, I would like to know how to give input in the case of read(). I tried everywhere but couldn't find the differences anywhere.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":559,"Q_Id":63138368,"Users Score":2,"Answer":">>> help(sys.stdin.read)\nHelp on built-in function read:\n\nread(size=-1, \/) method of _io.TextIOWrapper instance\n    Read at most n characters from stream.\n    \n    Read from underlying buffer until we have n characters or we hit EOF.\n    If n is negative or omitted, read until EOF.\n(END)\n\nSo you need to send EOF when you are done (*nix: Ctrl-D, Windows: Ctrl-Z+Return):\n\n>>> sys.stdin.read()\nasd\n123\n'asd\\n123\\n'\n\nThe readline is obvious. It will read until newline or EOF. So you can just press Enter when you are done.","Q_Score":0,"Tags":"python,python-3.x,stdin,readline,sys","A_Id":63138533,"CreationDate":"2020-07-28T16:08:00.000","Title":"What is the difference between sys.stdin.read() and sys.stdin.readline()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Specifically, I would like to know how to give input in the case of read(). I tried everywhere but couldn't find the differences anywhere.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":559,"Q_Id":63138368,"Users Score":1,"Answer":"read() recognizes each character and prints it.\nBut readline() recognizes the object line by line and prints it out.","Q_Score":0,"Tags":"python,python-3.x,stdin,readline,sys","A_Id":63138520,"CreationDate":"2020-07-28T16:08:00.000","Title":"What is the difference between sys.stdin.read() and sys.stdin.readline()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a generic python way to pass arguments to arbitrary functions based on specified positions? While it would be straightforward to make a wrapper that allows positional argument passing, it would be incredibly tedious for me considering how frequently I find myself needing to pass arguments based on their position.\nSome examples when such would be useful:\n\nwhen using functools.partial, to partially set specific positional arguments\npassing arguments with respect to a bijective argument sorting key, where 2 functions take the same type of arguments, but where their defined argument names are different\n\nAn alternative for me would be if I could have every function in my code automatically wrapped with a wrapper that enables positional argument passing. I know several ways this could be done, such as running my script through another script which modifies it, but before resorting to that I'd like to consider simpler pythonic solutions.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":63139411,"Users Score":0,"Answer":"For key arguments use **kwargs but for positional arguments use *args.","Q_Score":0,"Tags":"python","A_Id":63139466,"CreationDate":"2020-07-28T17:13:00.000","Title":"Is there any simple way to pass arguments based on their position, rather than kwargs. Like a positional version of kwargs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to calculate Kendall's tau for a large matrix of data stored in a Pandas dataframe. Using the corr function, with method='kendall', I am receiving NaN for a row that has only one value (repeated for the length of the array). Is there a way to resolve it? The same issue happened with Spearman's correlation as well, presumably because Python doesn't know how to rank an array that has a single repeated value, which leaves me with Pearson's correlation -- which I am hesitant to use due to its normality and linearity assumptions.\nAny advice is greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":807,"Q_Id":63143659,"Users Score":0,"Answer":"I decided to abandon the complicated mathematics in favor of intuition. Because the NaN values arose only on arrays with constant values, it occurred to me that there is no relationship between it and the other data, so I set its Spearman and Kendall correlations to zero.","Q_Score":1,"Tags":"python,pandas,scipy,statistics,correlation","A_Id":63178640,"CreationDate":"2020-07-28T22:24:00.000","Title":"NaN values with Pandas Spearman and Kendall correlations","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Windows 10 on my computer and when I use the cmd and check python --version, I get python 3.8.2. But when I try to find the path for it, I am unable to find it through searching on my PC in hidden files as well as through start menu. I don't seem to have a python 3.8 folder on my machine. Anybody have any ideas how to find it?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1375,"Q_Id":63144003,"Users Score":1,"Answer":"If you're using cmd (ie Command Prompt), and typing python works, then you can get the path for it by doing where python. It will list all the pythons it finds, but the first one is what it'll be using.","Q_Score":0,"Tags":"python,python-3.x","A_Id":63144189,"CreationDate":"2020-07-28T23:02:00.000","Title":"Cannot find Python 3.8.2 path on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to make a script in pygame where two balls fly towards each other and when they collide they should bounce off from each other but I don't know how to do this so can you help me?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1921,"Q_Id":63145493,"Users Score":0,"Answer":"Its pretty easy you just check if the x coordinate is in the same spot as the other x coordinate. For example if you had one of the x coordinated called x, and another one called i(there are 2 x coordinates for both of the balls) then you could just say if oh and before I say anything esle this example is fi your pygame window is a 500,500. You could say if x == 250: x -= 15. And the other way around for i. If i == 250: i += 15. Ther you go!. Obviously there are a few changes you have to do, but this is the basic code, and I think you would understand this","Q_Score":0,"Tags":"python,pygame,collision-detection,collision","A_Id":63911532,"CreationDate":"2020-07-29T02:33:00.000","Title":"Pygame how to let balls collide","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created an API using AWS Lambda function (using Python). Now my react js code hits this API whenever an event fire. So user can request API as many times the events are fired. Now the problem is we are not getting the response from lambda API sequentially. Sometime we are getting the response of our last request faster than the previous response of previous request.\nSo we need to handle our response in Lambda function sequentially, may be adding some delay between 2 request or may be implementing throttling. So how can I do that.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":363,"Q_Id":63149889,"Users Score":0,"Answer":"You can use SQS FIFO Queue as a trigger on the Lambda function, set Batch size to 1, and the Reserved Concurrency on the Function to 1. The messages will always be processed in order and will not concurrently poll the next message until the previous one is complete.\nSQS triggers do not support Batch Window - which will 'wait' until polling the next message. This is a feature for Stream based Lambda triggers (Kinesis and DynamoDB Streams)\nIf you want to streamlined process, Step Function will let you manage states using state machines and supports automatic retry based off the outputs of individual states.","Q_Score":0,"Tags":"python-3.x,reactjs,amazon-web-services,api,aws-lambda","A_Id":63158828,"CreationDate":"2020-07-29T08:54:00.000","Title":"How to set intervals between multiple requests AWS Lambda API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have created an API using AWS Lambda function (using Python). Now my react js code hits this API whenever an event fire. So user can request API as many times the events are fired. Now the problem is we are not getting the response from lambda API sequentially. Sometime we are getting the response of our last request faster than the previous response of previous request.\nSo we need to handle our response in Lambda function sequentially, may be adding some delay between 2 request or may be implementing throttling. So how can I do that.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":363,"Q_Id":63149889,"Users Score":1,"Answer":"Did you check the concurrency setting on Lambda? You can throttle the lambda there.\nBut if you throttle the lambda and the requests being sent are not being received, the application sending the requests might be receiving an error unless you are storing the requests somewhere on AWS for being processed later.\nI think putting an SQS in front of lambda might help. You will be hitting API gateway, the requests get sent to SQS, lambda polls requests concurrently (you can control the concurrency) and then send the response back.","Q_Score":0,"Tags":"python-3.x,reactjs,amazon-web-services,api,aws-lambda","A_Id":63150857,"CreationDate":"2020-07-29T08:54:00.000","Title":"How to set intervals between multiple requests AWS Lambda API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to install some Python packages using pip install from Windows command prompt. Which directory should I go to for installing the packages? The pip install operation ends quite swiftly, without showing any statements such as 'fetching' or 'in progress' or 'completed' or any such indication, and the Spyder shell I am working in shows the 'No module named xxx' error.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":73,"Q_Id":63150429,"Users Score":1,"Answer":"The correct way of installing packages in in root directory but you can install them anywhere you want. Check your network connection as this can happen because of bad network connections.","Q_Score":1,"Tags":"python,pip,windows-10,spyder","A_Id":63150468,"CreationDate":"2020-07-29T09:23:00.000","Title":"Installing Python packages using pip in Windows command propmt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"From 'import secrets' and 'import random' in Python, what makes those two methods different from each other? I know that randbelow from secrets offer better security, but what makes it so? If I were just making a simple program for myself and I want to generate a random number, would it be unusual to use 'secrets.randbelow()'?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":264,"Q_Id":63150577,"Users Score":1,"Answer":"Simply put, the key difference is in how the modules generate a seed number. Random's seed is decided by pretty much just the current time, so if I knew\/guessed the exact millisecond you ran your program, I would be able to work out all of your outputs. Secrets uses a lot more, and looks at different things depending on what Operating System your computer uses (eg.Windows\/Mac\/Linux), but are practically impossible to guess.","Q_Score":1,"Tags":"python,python-3.x,random","A_Id":63150707,"CreationDate":"2020-07-29T09:31:00.000","Title":"What makes randint different from randbelow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Would it be possible to store an image and a value together in a database? Like in a array?\nSo it would be like [image, value]. I\u2019m just trying to be able to access the image to print that and then access the value later (for example a image if a multi-choice question and its answer is the value).\nAlso how would I implement and access this? I\u2019m using Firebase with the pyrebase wrapper for python but if another database is more suitable I\u2019m open to suggestions.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":63152159,"Users Score":0,"Answer":"you can set your computer as a server and in database you can store like [image_path, value].","Q_Score":0,"Tags":"python,database,firebase,pyrebase","A_Id":63152348,"CreationDate":"2020-07-29T11:03:00.000","Title":"Is it possible to store an image with a value in a way similar to an array, in a database (Firebase or any other)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have created a new Anaconda environnement for Python. I managed to add it has an optional environnement you can choose when you create a new Notebook. Hovewer, I'd like to know how can I change the environnement of an already existing Notebook.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":348,"Q_Id":63152884,"Users Score":1,"Answer":"open your .ipynb file on your browser. On top, there is Kernel tab. You can find your environments under Change Kernel part.","Q_Score":0,"Tags":"python,jupyter-notebook,anaconda","A_Id":63153001,"CreationDate":"2020-07-29T11:45:00.000","Title":"How to change the Anaconda environment of a jupyter notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am translating codes from Stata to R. The same random seed does not generate the same outputs. I am not sure if this is also the case in other languages (Python, Java etc.). How to generate identical random numbers in different languages?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":206,"Q_Id":63153166,"Users Score":3,"Answer":"R uses its own initialization method for the Mersenne-Twister (see help(\"set.seed\")), which differs from what other languages do. The easiest way to ensure the same PRNG is used (and to avoid implementing something subpar yourself), is simply interfacing R and Stata and using the PRNG from either of these.\nHowever, it's worth keeping in mind that achieving true reproducibility is impossible unless you are using exactly the same software on exactly the same hardware and OS. Thus, I wouldn't spent effort on trying to achieve the same PRNG streams with different software. Instead I would generate these numbers, store them and import them as needed.","Q_Score":0,"Tags":"java,python,r,random,stata","A_Id":63153666,"CreationDate":"2020-07-29T12:02:00.000","Title":"How to generate the same random numbers in one language as in another?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created siamese model with triplet loss function.\nI tested it a little bit and notice that when object are small, like 2\/5 of the image space, model is matching images with similar background instead of object.\nSome of pictures were taken on the same background what is causing the issue as I think.\nIs there any way to maybe extract objects? train model to recognize those object, ignore background?\nShape of each image is (150, 150, 3).","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":63153619,"Users Score":1,"Answer":"the siamese  model actually deepened on encoded data simply its match between tow encoded feature representation  so it not know your object of intraset you have    extract object  than do the matching between them\nfor example if the model you built was for face matching\nuse opencv to extract the faces and than do the matching you want to make","Q_Score":0,"Tags":"python,image,tensorflow,image-processing,deep-learning","A_Id":63157792,"CreationDate":"2020-07-29T12:28:00.000","Title":"Model is recognizing background better than objects","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created siamese model with triplet loss function.\nI tested it a little bit and notice that when object are small, like 2\/5 of the image space, model is matching images with similar background instead of object.\nSome of pictures were taken on the same background what is causing the issue as I think.\nIs there any way to maybe extract objects? train model to recognize those object, ignore background?\nShape of each image is (150, 150, 3).","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":63153619,"Users Score":0,"Answer":"You can try to train with masks or do random croppings of the images as a data augmentation strategy or you can change your model for more finer convolutions. The easiest would be to do the random cropping and then, training; that will help the network to disentangle the object from the background.","Q_Score":0,"Tags":"python,image,tensorflow,image-processing,deep-learning","A_Id":63153804,"CreationDate":"2020-07-29T12:28:00.000","Title":"Model is recognizing background better than objects","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can you not just use categorical variables like in R where you can feed factor variables into the model?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":71,"Q_Id":63154361,"Users Score":1,"Answer":"The support is not there in scikit-learn (yet), no.  Other python packages for tree models do support categorical variables though, e.g. H2O's tree models and LightGBM (and in a different way, CatBoost).","Q_Score":0,"Tags":"python,r,machine-learning,scikit-learn","A_Id":63194478,"CreationDate":"2020-07-29T13:08:00.000","Title":"In python, do you have to create dummy variables to train a model such as RandomForests?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know if it is possible to use n_simulation = None in 'MarkovModel' algorithm in 'pychhatr' library in Python?\nIt throws me an error it must be an integer, but in docsting i have information like that:\n'n_simulations : one of {int, None}; default=10000'\nI`d like to do something like nsim = NULL in 'markov_model' in 'ChannelAttribution' package in R, these two algorithms are similarly implemented.\nI don`t know how does it works exactly, how many simulations from a transition matrix I have using NULL.\nCould anyone help with this case?\nRegards,\nSylwia","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":63155356,"Users Score":0,"Answer":"Out of curiosity I spent some minutes staring intensely at the source code of both pychattr module and ChannelAttribution package.\nI'm not really familiar with the model, but are you really able to call this in R with \"nsim=NULL\"? Unless I missed something if you omit this parameter it will use value 100000 as the default and if parameter exists, the R wrapper will complain if it's not a positive number.\nRegards,\nMaciej","Q_Score":0,"Tags":"python,r,markov","A_Id":63160750,"CreationDate":"2020-07-29T13:58:00.000","Title":"'pychattr' library in Python, 'n_simulations' parameter","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know if it is possible to use n_simulation = None in 'MarkovModel' algorithm in 'pychhatr' library in Python?\nIt throws me an error it must be an integer, but in docsting i have information like that:\n'n_simulations : one of {int, None}; default=10000'\nI`d like to do something like nsim = NULL in 'markov_model' in 'ChannelAttribution' package in R, these two algorithms are similarly implemented.\nI don`t know how does it works exactly, how many simulations from a transition matrix I have using NULL.\nCould anyone help with this case?\nRegards,\nSylwia","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":63155356,"Users Score":0,"Answer":"I checked that 'pychattr' (Python) doesn`t support value None but it supports n_simulations = 0 and it sets n_simulations to 1e6 (1 000 000).\n'ChannelAttribution' (R) replaces nsim = NULL and nsim = 0 to nsim = 1e6 (1 000 000) too.\nIn latest version of 'ChannelAttribution' (27.07.2020) we have nsim_start parameter instead of nsim and it doesn`t support 0 or NULL value anymore.\nImportant: default value of nsim_start is 1e5 (100 000) and from my experience it`s not enough in many cases.\nRegards,\nSylwia","Q_Score":0,"Tags":"python,r,markov","A_Id":63175481,"CreationDate":"2020-07-29T13:58:00.000","Title":"'pychattr' library in Python, 'n_simulations' parameter","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run a study, using the optimize function with the default sampler and Median pruner.\nevery run crashes, sometimes after 1 succefull trial sometimes without completing any.\nThe crash message is: Process finished with exit code 137 (interrupted by signal 9: SIGKILL)\nExpected behavior\nrunning a study\nEnvironment\n\nOptuna version:\n2.0.0\nPython version: 3.8\nOS:QubeOS with debian 10 VM\n(Optional) Other libraries and their versions:\nPytorch '1.5.0+cpu'\n\nError messages, stack traces, or logs\nProcess finished with exit code 137 (interrupted by signal 9: SIGKILL)\nwhat cause such an error?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":63155994,"Users Score":0,"Answer":"One likely situation is that your process consumes a lot of memory and gets killed by the operating system's OOM killer. You can monitor the memory consumption of your process using a tool like top and see if it uses a lot of memory.\nYou can also run dmesg in the console and look for messages from the OOM killer in the output. The OOM killer will usually print there which process it killed. Check whether the process ID is the one of your process.\nIn case the process is indeed killed by the OOM killer then the only remedy probably is to reduce the memory consumption of the program (or get a bigger machine).","Q_Score":0,"Tags":"python,pycharm,pytorch,optuna","A_Id":63156511,"CreationDate":"2020-07-29T14:32:00.000","Title":"Getting SIGKILL when running study optimization with Optuna on PyCharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do you decide the critical values(alpha) and analyze with the p value\nexample: stats.ttest_ind(early['assignment1_grade'], late['assignment1_grade'])\n(2 series with score of their assignments)\nI understand the concept that if the p value is greater than the alpha value then the null hypothesis cant be neglected.\nIm doing a course and instructor said that the alpha value here is 0.05 but how do you determine it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":151,"Q_Id":63157884,"Users Score":0,"Answer":"The alpha value cannot be determined in the sense that there were a formula to calculate it. Instead, it is arbitrarily chosen, ideally before the study is conducted.\nThe value alpha = 0.05 is a common choice that goes back to a suggestion by Ronald Fisher in his influential book Statistical Methods for Research Workers (first published in 1925). The only particular reason for this value is that if the test statistic has a normal distribution under the null hypothesis, then for a two-tailed test with alpha = 0.05 the critical values of the test statistic will be its mean plus\/minus 2 (more exactly, 1.96) times its standard deviation.\nIn fact, you don't need alpha when you calculate the p value, because you can just publish the p value and then every reader can decide whether to consider it low enough for any given purpose or not.","Q_Score":0,"Tags":"python-3.x,scipy","A_Id":63160949,"CreationDate":"2020-07-29T16:10:00.000","Title":"How to know the alpha or critical value of your t test analysis?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been experiencing a lot of troubles lately with Anaconda and my environments.\nSo, I would like to a full clean and start over from scratch.\nI wanted to know if deleting environments and uninstalling everything as suggested in the official Anaconda Web site also deletes the notebooks\/py-scripts or any other file in the same folders\nAlso, if you have any recommendation on the best way to achieve this, it would be appreciated.\nThank you","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":525,"Q_Id":63158872,"Users Score":1,"Answer":"Steps\n1. save your ipynb files in one folder\n2. delete anaconda from control panel\n3. reinstall it\n4. download libraries which are required\nThanks","Q_Score":1,"Tags":"python,anaconda,environment","A_Id":63158925,"CreationDate":"2020-07-29T17:08:00.000","Title":"Cleaning Anaconda to start over","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a spider in scrapy. Everytime i try to scrape a specific website, the spider is running quite well at the start. but when i goes down to like 500-600 request, the spider start to crawl very slowly.\nI have checked memory and cpu settings but that is not the problem. Im quite sure that the website is slowing down my requests.\nHow do i adjust scrapy to scrape fast and consistently?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":77,"Q_Id":63161677,"Users Score":1,"Answer":"If the website is slowing down your requests, it's probably best to be more careful with the requests you're sending.\nA couple of things you can try:\n\nSet 'AUTOTHROTTLE_ENABLED' to True: when scrapy sees the server is responding slowly, it will adjust the crawling speed\nLimit the number of concurrent requests yourself (by setting CONCURRENT_REQUESTS_PER_DOMAIN), and change the DOWNLOAD_DELAY to wait a bit between requests\nUse proxies: most likely the target website is limiting you based on the IP. Using proxies will overcome this, but this will not help in case the target server is overloaded by your requests","Q_Score":0,"Tags":"python,scrapy","A_Id":63167234,"CreationDate":"2020-07-29T20:08:00.000","Title":"Scrapy: website is slowing down my requests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm making a discord bot that kicks bots that are invited to the server who were not invited by users with specific roles. I am struggling to find out who invited a bot to the server. I ran a few tests and came to the conclusion that an invite code\/link is not created when someone invites a bot. I know I can see who invited a bot in the AuditLogs but I want to kick a bot automatically if it is invited by an admin who should not be able to invite them.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":63163142,"Users Score":0,"Answer":"One way to solve this issue is to just not allow people other than admins to invite people to the server. However, if you want people to be ale to invite others, just not bots, here is what you can do: When a bot joins the server, you can use your bot to check iterate over the audit logs and check if the action is an invite and the target is the bot they you can check who invited the bot. From there on just check if who invited the bot is an admin, if not, kick the bot.","Q_Score":0,"Tags":"python,discord.py","A_Id":63207891,"CreationDate":"2020-07-29T22:06:00.000","Title":"Discord.py I want to have something in my code that gives me the person who invited 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 have 50 time series, each having at least 500 data points (some series have as much as 2000+ data points). All the time series go from a value of 1.089 to 0.886, so you can see that the resolution for each dataset comes close to 10e-4, i.e. the data is something like:\n1.079299, 1.078809, 1.078479, 1.078389, 1.078362,... and so on in a decreasing fashion from 1.089 to 0.886 for all 50 time-series.\nMy questions hence, are:\n\nCan LSTMs handle such dense data?\nIn order to avoid overfitting, what can be the suggested number of epochs, timesteps per batch, batches, hidden layers and neurons per layer?\n\nI have been struggling with this for more than a week, and no other source that I could find talks about this specific case, so it could also help others.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":63167041,"Users Score":3,"Answer":"A good question and I can understand why you did not find a lot of explanations because there are many tutorials which cover some basic concepts and aspects, not necessarily custom problems.\n\nYou have 50 time series. However, the frequency of your data is not the same for each time series. You have to interpolate in order to reach the same number of samples for each time series if you want to properly construct the dataset.\nLSTMs can handle such dense data. It can be both a classification and a regression problem, neural networks can adapt to such situations.\nIn order to avoid overfitting(LSTMs are very prone to it), the first major aspect to take into consideration is the hidden layers and the number of units per layer. Normally people tend to use 256-512 by default since in Natural Language Processing where you process huge datasets they are suitable. In my experience, for simpler regression\/classification problems you do not need such a big number, it will only lead to overfitting in smaller problems.\n\nTherefore, taking into consideration (1) and (2), start with an LSTM\/GRU with 32 units and then the output layer. If you see that you do not have good results, add another layer (64 first 32 second) and then the output layer.\nAdmittedly, timesteps per batch is of crucial importance. This cannot be determined here, you have to manually iterate through values of it and see what yields you the best results. I assume you create your dataset via sliding window manner; consider this(window size) also a hyperparameter to alter before arriving at the batch and epochs ones.","Q_Score":2,"Tags":"python,keras,deep-learning,time-series,lstm","A_Id":63167865,"CreationDate":"2020-07-30T05:59:00.000","Title":"Can LSTMs handle incredibly dense time-series data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When my colleague's Java(Client) TCP socket program send a package (500KB~1MB) to my Python(Server) TCP socket program, there are cases of subcontracting and sticking. I want to know, is there a universally valid solution to this situation? And what people usually do in this case?\nI think if it is possible to manually refresh the buffer zone requested by socket function recv(buffer_zone).If I can do that, the program will be free from sticking packages at least.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":63169189,"Users Score":0,"Answer":"It's me, and I've solved this problem by Head-Tail Package Mode.\nSpecifically, when send a serial of data to the server, the client may send a head package including stamp information and data length. When the server receive the head package sent from client, it can know the length that client will send to server, and the server can preper the same length cache for incoming data. When the client send the tail (data) package to the server, the server can depend on the length of the data it knows in advance and take out the data. That's my solution for now.","Q_Score":0,"Tags":"java,python,sockets,tcp","A_Id":63408074,"CreationDate":"2020-07-30T08:29:00.000","Title":"Unexpected Subcontract and Stick happened in TCP Socket between Python (Server) and Java (Client)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently developing a program in python and I am converting this into a .exe file so I can share it. However, there have been many virus alerts and I have not been able to do this. I am using PyInstaller to convert my files. I believe this issue may be coming from the actual conversion itself. I have heard that the new version of PyInstaller is generating these issues. Many people have said to downgrade PyInstaller to an earlier version to avoid this issue.\nSo my question is: 'How do you downgrade a python module such as PyInstaller?'\nAnd should I try using other modules to convert my files or should I stick to PyInstaller?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2148,"Q_Id":63169917,"Users Score":0,"Answer":"Have you tried pip install pyinstaller==3.6? In this case, I have chosen the version 3.6. You can choose other versions also.","Q_Score":0,"Tags":"python-3.x,pip,exe,pyinstaller,downgrade","A_Id":69310284,"CreationDate":"2020-07-30T09:12:00.000","Title":"How do you downgrade pyinstaller using pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to share a model that I trained. I am currently trying to use Pyinstaller to make an exe. It's really huge ! 300 MB at least.\nIs there any way to use anything else to make inference out of a saved model ?\nI tried using tensorflow lite but my ops are not supported.\nI am kind of looking for a tensorflow-inference-only package.\nThanks,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":63171077,"Users Score":0,"Answer":"if you want to decrease the size of your exe file\nyou need to minimize the import statements\nfor example you are using random so you import random but you only use random.choice\nso it's better to use from random import choice\ndoing this can decrease your file size !","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":63171290,"CreationDate":"2020-07-30T10:18:00.000","Title":"How to make a minimum size exe for inference of a model","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background :\nIn our project we are doing bulk deployment in that we are having around 10 AWS Lambda functions, Few Scala applications and few configuration files. Currently we are deploying 10 lambdas if there is no change as well.\nProblem :\nLets say we have changed code in Scala class, committed to GIT and from there using Jenkins we are deploying the changes. As we have no differentiation between Lambda and Scala changes we are deploying all the Lambdas, Scala classes and Configuration files as well.\nQuestion :\nMy question here is if we implement SAM on top of our Lambdas and then will separate it out deploying all the lambdas at a time as a separate Jenkins pipeline. If there is a change for 1 Python code in Lambda functions will it allow to deploy only delta Lambdas.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":212,"Q_Id":63173449,"Users Score":0,"Answer":"sam deploy will only deploy resources if they have changed.  Otherwise it noops (no operation).","Q_Score":0,"Tags":"python,scala,amazon-web-services,jenkins,aws-sam","A_Id":63185227,"CreationDate":"2020-07-30T12:44:00.000","Title":"Deploying AWS Lambda using AWS SAM in Jenkins","Data Science and Machine Learning":0,"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":"Background :\nIn our project we are doing bulk deployment in that we are having around 10 AWS Lambda functions, Few Scala applications and few configuration files. Currently we are deploying 10 lambdas if there is no change as well.\nProblem :\nLets say we have changed code in Scala class, committed to GIT and from there using Jenkins we are deploying the changes. As we have no differentiation between Lambda and Scala changes we are deploying all the Lambdas, Scala classes and Configuration files as well.\nQuestion :\nMy question here is if we implement SAM on top of our Lambdas and then will separate it out deploying all the lambdas at a time as a separate Jenkins pipeline. If there is a change for 1 Python code in Lambda functions will it allow to deploy only delta Lambdas.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":212,"Q_Id":63173449,"Users Score":0,"Answer":"You always have to deploy the entire stack using sam deploy. If some of your lambdas don't have changes, then --no-fail-on-empty-changeset will be your new friend.","Q_Score":0,"Tags":"python,scala,amazon-web-services,jenkins,aws-sam","A_Id":65644545,"CreationDate":"2020-07-30T12:44:00.000","Title":"Deploying AWS Lambda using AWS SAM in Jenkins","Data Science and Machine Learning":0,"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 really confused as to when I should apply MinMaxScaler or scaling in general to my dataset, whether is before splitting into train_test_split or after splitting into training and validation split, then fit and transform on X_train and transform on X_test. Really confused about what the general rule of thumb is in applying this...","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":522,"Q_Id":63181857,"Users Score":0,"Answer":"You want to scale before training on the training set. After that, you scale the test and validation using the same mean and variance (i.e. train mean and variance) before inference.","Q_Score":0,"Tags":"python,validation","A_Id":63181913,"CreationDate":"2020-07-30T21:49:00.000","Title":"Is it best to apply MinMaxScaler to your dataset before splitting into training and Validation set or after splitting","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm really confused as to when I should apply MinMaxScaler or scaling in general to my dataset, whether is before splitting into train_test_split or after splitting into training and validation split, then fit and transform on X_train and transform on X_test. Really confused about what the general rule of thumb is in applying this...","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":522,"Q_Id":63181857,"Users Score":1,"Answer":"There is no rule of thumb, but generally, you definitely want to scale before splitting your dataset.\nI will tell you why. Logically, it would be confusing (for the model) while predicting if you have a dataset and split it into three subsets without assuring that the subset are more or less in the same distribution. Now if you are sure that the three subsets have the same distribution and not imbalanced (which is hard to prove) than I see no problem splitting before or after. I would never recommend it though.\nHence, the logical choice is to scale before and then do the splitting. An alternative approach for this is to use the StandardScaler instead of the MinMaxScaler. I find it less sensitive and from my experience, it is in most cases a better choice than the minmax.","Q_Score":0,"Tags":"python,validation","A_Id":63182093,"CreationDate":"2020-07-30T21:49:00.000","Title":"Is it best to apply MinMaxScaler to your dataset before splitting into training and Validation set or after splitting","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to create a git pre-commit hook for my project that runs autopep8 on files modified by the potential commit. I only want to run it on Python files, not the other C++ files, text files, etc. How can I programmatically detect whether a file is a Python file? Not all of the Python files in the repository have the .py extension, so I cannot rely upon that.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":157,"Q_Id":63182584,"Users Score":1,"Answer":"You can't.\nAt least not in such general case and with perfect accuracy. Your best bet is to make sure all your python files in the repo do have .py extension or are disntinguished from other files in some simple, finite amount ways.\nYour next best bet is file command.","Q_Score":7,"Tags":"python","A_Id":63184501,"CreationDate":"2020-07-30T23:02:00.000","Title":"How to Programmatically detect whether a file is 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":"when I was going to link the oofem and yade, i have already linked liboofem to current work directory use follow command\n\nln -s current\/work\/directory\/liboofem.so oofem\/build\/directory\/liboofem.so\n\nhowever, when I was going to make the file, in a python scripts, the command \u201cimport liboofem\u201d, then raise the\n\nImportError: install\/liboofem.so: undefined symbol: gc","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":63184569,"Users Score":0,"Answer":"cmake -DUSE_OOFEG=\"ON\" -DUSE_PYTHON_BINDINGS=\"ON\" -DCKIT_DIR=\"\/home\/shguan\/oofem\/Ckit\" -DELIXIR_DIR=\"\/home\/shguan\/oofem\/Elixir\" ..\/oofem-2.5\nshould be replaced by\ncmake -DUSE_PYTHON_BINDINGS=\"ON\" -DCKIT_DIR=\"\/home\/shguan\/oofem\/Ckit\" -DELIXIR_DIR=\"\/home\/shguan\/oofem\/Elixir\" ..\/oofem-2.5\nthat is to say the oofeg make this error!","Q_Score":0,"Tags":"python,c","A_Id":63185239,"CreationDate":"2020-07-31T01:35:00.000","Title":"ImportError: install\/liboofem.so: undefined symbol: gc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"So here's the exact scenario- consider the list:\nx=['4', '5', '29', '54', '4', '0', '-214', '542', '-64', '1', '-3', '6', '-6'] \nnow max(x) should give '542' instead it gives '6', but if you take out '6' it does give '542' as max. min(x) on the other hand correctly gives '-214' as the answer.\nif you convert x into a list of numbers then obviously max(x) gives the correct output 542. This is an unreliable behavior at least from what I know about Python and I would like to explore if I am missing something here on how max() function works that could explain this behavior.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":87,"Q_Id":63185645,"Users Score":2,"Answer":"As I was writing this question and trying to understand this behavior with max() function, I tried x.sort() and it gave out the answer. So let me paste the sorted list:\n['-214', '-3', '-6', '-64', '0', '1', '29', '4', '4', '5', '54', '542', '6']\nSo basically these are strings and initial character of the string decides its value as string. Meaning, 5kaify will come first than 6kaify .\nFor more clarity, if I add bunch of alphabets into this list as below:\nx=['4', '5', '29', '54', '4', '0','d', '-214', '542', '-64', '1','a', '-3','c', '6', '-6']\nmax(x) will give 'd' as the answer as alphabetically it would come later than all the strings in the list, hence max() checks for alphabetical order as the value for list of strings\/characters and not its integral\/numeric value. Hope this was helpful.","Q_Score":1,"Tags":"python,python-3.x,list,max","A_Id":63185646,"CreationDate":"2020-07-31T04:07:00.000","Title":"Python: max(a list of numbers as characters) gives right and wrong answer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So here's the exact scenario- consider the list:\nx=['4', '5', '29', '54', '4', '0', '-214', '542', '-64', '1', '-3', '6', '-6'] \nnow max(x) should give '542' instead it gives '6', but if you take out '6' it does give '542' as max. min(x) on the other hand correctly gives '-214' as the answer.\nif you convert x into a list of numbers then obviously max(x) gives the correct output 542. This is an unreliable behavior at least from what I know about Python and I would like to explore if I am missing something here on how max() function works that could explain this behavior.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":63185645,"Users Score":0,"Answer":"So essentially max and min when using a string will use alphabetically highest character. Think of the array\n['all','b','c','d']\nmax will list d as the answer as when sorting alphabetically we first rely on the initial character and only with duplicates do we check the next character.\nSo when we try to sort numbers as a string it will use the same logic. Therefore 6 will be higher than 562 since 6 > 5.\nAlphabetically the order is symbols < numbers (in order 0-9) < characters (in order a-z)\nI hope that answers your question.","Q_Score":1,"Tags":"python,python-3.x,list,max","A_Id":63185718,"CreationDate":"2020-07-31T04:07:00.000","Title":"Python: max(a list of numbers as characters) gives right and wrong answer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have selenium installed and chrome driver in a python project, when i create a new project is says it can't recognize the selenium module.\nDoes this mean with each project I'll need to install selenium again?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":671,"Q_Id":63189662,"Users Score":0,"Answer":"You don't need every time , you need use by giving path and locate to folder in your machine","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,module,webdriver","A_Id":63190408,"CreationDate":"2020-07-31T09:58:00.000","Title":"Do we need to install Selenium each time we open and execute a new project using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have selenium installed and chrome driver in a python project, when i create a new project is says it can't recognize the selenium module.\nDoes this mean with each project I'll need to install selenium again?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":671,"Q_Id":63189662,"Users Score":0,"Answer":"yes you need to. In cases where you create virtual environment for  each projects. It is better to have it install into the project virtual environment. This will save you a lot of stress debugging your code later in future.","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,module,webdriver","A_Id":63190588,"CreationDate":"2020-07-31T09:58:00.000","Title":"Do we need to install Selenium each time we open and execute a new project using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to convert my RGB image to Grayscale. While doing it, I came across the code:\nnp.dot(rgbImage[...,:3], [0.299, 0.587, 0.114])\nCan anyone please explain this line and values taken.?\n(Please don't provide any Wikipedia link)\nsearching for a simple explanation.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":34,"Q_Id":63190950,"Users Score":3,"Answer":"It is like converting into Grayscale using weighted or Luminosity method\nLuminosity = 0.299 \u00d7 R + 0.587 \u00d7 G + 0.114 \u00d7 B\nIt means 29.9% for RED, 58.7% for Green, and 11.4% Blue.","Q_Score":0,"Tags":"python,image-processing","A_Id":63191124,"CreationDate":"2020-07-31T11:23:00.000","Title":"Why are these particular values used to convert image to grayscale in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a small code with python. But this part of the code doesn't work when game focused on and it doesnt respond back.\npyautogui.moveRel(-2, 4)\nAlso this part works when my cursor appear in menu or etc. too. But when i switched into game (when my cursor disappear and crosshair appeared) it doesn't work (doesn't matter fullscreen or else). These type of keyboard commands are in my code also but they works fine.\nkeyboard.is_pressed('Alt')\nIt's about mouse or pyautogui ?.. How can i make mouse moves correct ?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":491,"Q_Id":63191480,"Users Score":1,"Answer":"I tried this code below:\nimport win32con\nimport win32api\nwin32api.mouse_event(win32con.MOUSEEVENTF_MOVE, int(10), int(10), 0, 0)\nAnd it worked in game. I think it relative with win32con. Anyway i got it.","Q_Score":1,"Tags":"python,input,mouseevent,pyautogui","A_Id":63214834,"CreationDate":"2020-07-31T12:02:00.000","Title":"\"pyautogui\" doesn't respond","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a small code with python. But this part of the code doesn't work when game focused on and it doesnt respond back.\npyautogui.moveRel(-2, 4)\nAlso this part works when my cursor appear in menu or etc. too. But when i switched into game (when my cursor disappear and crosshair appeared) it doesn't work (doesn't matter fullscreen or else). These type of keyboard commands are in my code also but they works fine.\nkeyboard.is_pressed('Alt')\nIt's about mouse or pyautogui ?.. How can i make mouse moves correct ?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":491,"Q_Id":63191480,"Users Score":1,"Answer":"I was with the same problem in linux. For me it was wayland. After switching to X, it worked. In \/etc\/gdm3\/custom.conf uncomment the line #WaylandEnable=false.","Q_Score":1,"Tags":"python,input,mouseevent,pyautogui","A_Id":72378355,"CreationDate":"2020-07-31T12:02:00.000","Title":"\"pyautogui\" doesn't respond","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need my Python program to do some stuff, and at a certain point give control to the user (like a normal Python shell when you run python3 or whatever) so that he can interact with it via command line. I was thinking of using pwntools's interactive() method but I' m not sure how I would use that for the local program instead of a remote.\nHow would I do that?\nAny idea is accepted, if pwntools is not needed, even better.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":61,"Q_Id":63194172,"Users Score":1,"Answer":"Use IPython\nIf you haven't already, add the package IPython using pip, anaconda, etc.\nAdd to your code:\nfrom IPython import embed\nThen where you want a \"breakpoint\", add:\nembed()\nI find this mode, even while coding to be very efficient.","Q_Score":0,"Tags":"python,python-3.x,pwntools","A_Id":63195407,"CreationDate":"2020-07-31T14:50:00.000","Title":"Giving interactive control of a Python program to the user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"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 wrote my first program with a non built-in module and it works when I run it in pycharm, but when I try to run it in cmd I get an error: app.py, line 1, in <module> from pytube import YouTube ModuleNotFoundError: No module named 'pytube'\nI've tried installing pytube module via cmd once again, but the problem still occurs\nEDIT: The rest of my scripts are working fine (there are using built-in only modules)","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":307,"Q_Id":63197053,"Users Score":0,"Answer":"Ok, so after some research and trying different solutions, I managed to run my script just by copying the missing module to the same directory as my app.py file, I don't know if it's the best solution, but it works.","Q_Score":0,"Tags":"python,python-module,pytube","A_Id":63198189,"CreationDate":"2020-07-31T18:13:00.000","Title":"Python script stops working when run outside of pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Windows 10 with Spyder (Python 3.6). Everything seems fine, I leave my PC on for the training, but when I come back I find Spyder closed. I tried to uninstall and reinstall Tensorflow, updated everything, but it still happens. What should I do? I don't even get a crash message.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":53,"Q_Id":63199388,"Users Score":1,"Answer":"I had a similar problem. When I tried to train for longer than 30 epochs, Spyder stopped responding after some time (you had to close it). In my case the problem was solved by decreasing the (runtime) output.","Q_Score":0,"Tags":"python,neural-network,crash,spyder","A_Id":64059673,"CreationDate":"2020-07-31T21:36:00.000","Title":"Spyder closes while training a neural network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"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 am working with the John Hopkins Covid data for personal use to create charts.  The data shows cumulative deaths by country, I want deaths per day.  Seems to me the easiest way is to create two dataframes and subtract one from the other.  But the file has column names as dates and the code, e.g. df3 = df2 - df1 subtracts the columns with the matching dates.  So I want to rename all the columns with some easy index, for example, 1, 2, 3, ....\nI cannot figure out how to do this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":63205657,"Users Score":0,"Answer":"Thanks for the time and effort but I figured out a simple way.\nfor i, row in enumerate(df):\ndf.rename(columns = { row : str(i)}, inplace = True)\nto change the columns names and then\nfor i, row in enumerate(df):\ndf.rename(columns = { row : str( i + 43853)}, inplace = True)\nto change them back to the dates I want.","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":63208922,"CreationDate":"2020-08-01T13:20:00.000","Title":"Rename hundred or more column names in pandas dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question about logistic regression. For my thesis I have to compare companies using different financial ratios using Python. The financial ratios should be balanced either by logistic regression or probit regression. I have already looked at some tutorials and these have worked with explanatory and dependent variables, but there are no dependent variables in my data set. I only need the regression to balance the different financial ratios and not to explain dependent variables. The goal is to calculate a score (\"Propensity Score\") for each company, from which I can then calculate the distance to the \"nearest\" company and thus get a proxy for comparability with other companies.\nUnfortunately, I completely lack the approach here and I can't find any instructions or examples. Does anyone of you have an idea how I can proceed here? I hope my problem becomes clear.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":63209213,"Users Score":0,"Answer":"It sounds to me like regression models are not the right approach here. If I understand correctly and you want to find companies which are comparable based on different financial ratios you should use clustering algorithm like k-means or just just use a distance metric like euclidean distance to find the closest neighbor for each company.","Q_Score":0,"Tags":"python,regression","A_Id":63209931,"CreationDate":"2020-08-01T19:24:00.000","Title":"Balancing via Logistic Regression","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a web application using Python, ReactJS , AWS lambda.\nI want to force the user to change the password after first time login . How should i do with the backend change?\nAfter resetting the password , it should redirect to normal page .\nAny help would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":63212878,"Users Score":1,"Answer":"In the table where you store Users, you can create a column to check whether the User is logging in the first time or not. This can be done by the following method, when the user is created, the value for the column firstLogin(of Type Date) would be set as NULL, and when the user logs in the first time, you can use a Date function to obtain the date and insert the value there.\nSo, here is the process in brief.\n\nMake a HTTP request to create an account using fetch, axios, request or whatever module you like to create an account. Route: POST \/user, with the body containing the values or data about the User. At backend, set the SQL statement to INSERT INTO User(Firstname, Lastname, Username, Password, FirstLogin) VALUES (\"RAM\", \"KUMAR\", \"ramkumar\", \"iamaverysecurepassword\", NULL);\nNow when the User logs in for the first time using your web application, make a call to the backend, using the following route: PATCH \/user, to execute the following SQL Query UPDATE User SET FirstLogin=\"{Value of Date}\" WHERE Username=\"{Your username here(ramkumar)}\";\nNow, when you have set the Date of the first login of the user, you redirect the User on your web application using document.location.href={URL to normal page}\"\nAnd then comes the condition, that if the user has not logged in the first time, how to redirect him to the password change page? You actually execute a SQL query again, to check whether it is the first time he is logging in or not. So, basically every time an action that requires the user to have logged in before, i.e, the first time. You check whether the FirstLogin column in your SQL has the value or is NULL for the corresponding user. SELECT Firstname FROM User WHERE Username={your username here(ramkumar)}; Now check the value using if statement in your code, the value for the executed SQL Query and that FirstLogin contains a date or is null.","Q_Score":0,"Tags":"python,reactjs,aws-lambda","A_Id":63213037,"CreationDate":"2020-08-02T06:00:00.000","Title":"Force Reset Password after first time login","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"(CPython implementation)\nIn x = 3, I know that the memory for the int object containing the primitive value 3 is allocated on the heap. Is x (as a reference to the int object) allocated on the stack or on the heap?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":63214262,"Users Score":1,"Answer":"Objects in CPython implementation are allocated on the heap and the same happens for \"stack frames\". The \"stack frame\" size is precomputed at compile time.\nHowever for reasons that are not 100% clear to me there is a C stack use for nested function calls (not for arguments or locals, however). This still means that inifinite recursion on CPython will crash because of C stack exhaustion much before than running out of memory. It could have been possible to implement the VM to use a fixed amount of C stack no matter how deep was the call nesting in Python code, but this is not the case.\nNote also that small integers (e.g. 3) are however shared, i.e. a new integer object is not always allocated. Being integers immutable this is hard to notice except when using id, but is an important optimization for speed reasons.","Q_Score":1,"Tags":"python,object,stack,heap-memory,cpython","A_Id":63214358,"CreationDate":"2020-08-02T09:09:00.000","Title":"Is memory allocated to pointers on the stack in CPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to delete files in Sharepoint 2016 from its recycle bin.\nI am able to delete files from my folder using requests.delete. However, not able to do the same from recycle bin.\nCan we achieve that?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1566,"Q_Id":63214420,"Users Score":1,"Answer":"Did you try Powershell script? There is a Sharepoint function for that","Q_Score":1,"Tags":"python,sharepoint,recycle-bin,sharepoint-2016","A_Id":63338021,"CreationDate":"2020-08-02T09:32:00.000","Title":"Delete Sharepoint files using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"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":"I have issue with scraping page and getting json from it.\n<script type=\"text\/x-magento-init\"> inside is json that I'am trying to get but when I try with .find('script',{'type':'text\/x-magento-init'})I recive first json that I don't need. My question is how to find the 8th json with that same name? There is no other name\/id etc.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":63216006,"Users Score":0,"Answer":"you need to use re.findall(), that will return to you a list of matches. Then to get the 8th element you can go by result[7]","Q_Score":0,"Tags":"python,json","A_Id":63216032,"CreationDate":"2020-08-02T12:29:00.000","Title":"Getting json from html with same name","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am reading cpython source code class implementation, I knew the basic process of class define and create.\nclass define:\nload_build_class -> builtin_build_class -> mata -> type_call -> type_new\nclass create:\ntype_call -> type_new\nand I knew the user defined functions are stored in the namespace and finally to the tp_dict of that type.\nMy question: user defined init function is stored in the type->tp_dict, when python initials a type it calls type->tp_init function, I can not find where in cpython source code the user defined init function is called when creating class.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":63219047,"Users Score":0,"Answer":"Find the result by myself, type_new will call PyType_Ready and  fixup_slot_dispatchers, in later function user defined function will be handled in slots.","Q_Score":1,"Tags":"init,cpython","A_Id":63234998,"CreationDate":"2020-08-02T17:24:00.000","Title":"in cpython source code where python call user defined __init__ when creating class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to change the MDToolbar left_action_item icon color. Its defaulting to white, but now i want to change it to red. Whats the simplest way to do this? I've tried almost everything (text_color, bg_color, etc) all to no avail.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":3418,"Q_Id":63220670,"Users Score":1,"Answer":"You cannot change the color of the icons in the toolbar.","Q_Score":3,"Tags":"python,kivy,kivymd","A_Id":63225819,"CreationDate":"2020-08-02T20:23:00.000","Title":"change color of icon in MDToolbar in kivyMD?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to change the MDToolbar left_action_item icon color. Its defaulting to white, but now i want to change it to red. Whats the simplest way to do this? I've tried almost everything (text_color, bg_color, etc) all to no avail.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":3418,"Q_Id":63220670,"Users Score":1,"Answer":"Using specific_text_color: 1,0,1,1 you can change the color of the text inside the toolbar. It changes both the text AND the icon. I have no idea how to change only the icon. Maybe this helps.\nAt the moment iam having trouble changing the icon color of a OneLineIconListItem. I think its the same constraint we are encountering?","Q_Score":3,"Tags":"python,kivy,kivymd","A_Id":63534827,"CreationDate":"2020-08-02T20:23:00.000","Title":"change color of icon in MDToolbar in kivyMD?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to change the MDToolbar left_action_item icon color. Its defaulting to white, but now i want to change it to red. Whats the simplest way to do this? I've tried almost everything (text_color, bg_color, etc) all to no avail.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3418,"Q_Id":63220670,"Users Score":0,"Answer":"Using both md_bg_color: app.theme_cls.primary_color and text_color: rgba('#F0F0F0') allowed me to change the color of icon buttons within MDToolbar.","Q_Score":3,"Tags":"python,kivy,kivymd","A_Id":68547381,"CreationDate":"2020-08-02T20:23:00.000","Title":"change color of icon in MDToolbar in kivyMD?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying my hand at pysimplegui to build my first UI. However, I keep getting an error but in a flash a stack trace appears before the screen, the program ends and unable to read it. Is there anyway to print the stack trace from pysimplegui to the console in PyCharm to use as a way of debugging?\nHad a look at the docs but sadly nothing I can see and the docs are not as simple as the library.\nCheers","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":309,"Q_Id":63220801,"Users Score":0,"Answer":"I manged to get it worked, I ran it in debug mode in the command line and I now see the issue","Q_Score":0,"Tags":"python,stack-trace,pysimplegui","A_Id":63236572,"CreationDate":"2020-08-02T20:39:00.000","Title":"pysimplegui print stack trace to console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have import aiosqlite, but it says this:\nUnable to import 'aiosqlite'\nCan someone help? I'm on Visual Studio Code but I can't find out why I can't import Aiosqlite.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":621,"Q_Id":63221777,"Users Score":0,"Answer":"Try with pip3\npip3 install aiosqlite\nPossible reason -> Async support for Python 3","Q_Score":1,"Tags":"python-3.x,discord.py,discord.py-rewrite","A_Id":70409841,"CreationDate":"2020-08-02T22:54:00.000","Title":"I've installed Aiosqlite, but it won't import","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'll open with saying I'm not a data scientist or statistician so I've been trying to figure out the best way to score a set of given AI moves to help the computer determine which move path to choose. I've come up with the following and am asking if there is a better way to do this or if this will even work in the first place.\nFor any given player:\n\nNormal move +0\nCapture normal piece +1\nCapture king +2\nMove resulting in king +2\nWin game +10 (Should make AI highly prefer this path unless another provides a stronger and safer short term advantage.)\nDraw Game (Disregard path unless it's the only remaining option. Static 1 Goodness Point.)\nLose Game (Disregard path unless it's the only remaining option. Static 0 Goodness Points.)\n\nI'm also toying with the following:\n\nMove that ends against a wall +0.5\nMove that gains center control without threat +0.75\nMove that results in potential capture of multiple AI pieces (per piece) -0.25\nMove that results in piece getting \"stuck\" (within 1 turn) -0.5\n\nThe AI then runs through X levels (Let's say 4) of moves deep in the search tree and tallies points for both the player and opponent for each branch.\nI track the following (per branch):\n\nTotal points for AI\nTotal points for human opponent\nOpponent likelihood of choosing branch (see below)\nBranch \"Goodness\" (see below)\nTotal branches (move combinations)\n\nIn order to choose the best one, here is the algorithm I have developed but haven't determined if it will work well yet:\nBase Opponent Move Probability = 100 \/ Total Branches * (Human Opponent Points Gained + 1)\nPlayer Branch \"Goodness\" = Human Opponent Probability * Total Points for AI Player\nThe AI then chooses the move branch with the highest \"Goodness\" points or picks one at random in event of a tie.\nExample:\n4 Branches Available. In one of them, the human will king once and the AI will capture 2 pieces and king once.\n100 \/ 4 Moves * (1 Opponent Points + 1) = 50 Human Opponent Likelihood Score\n50 Human Opponent Likelihood * 5 AI Player Points Gained = 250 Move \"Goodness\" Points\nThe only other thing I can think to add would be to score the entire board's \"favorability\" at the end of each branch and multiply that by the \"Goodness\" Score. Favorability meaning the total point score for all pieces, kings, center\/wall control as a given end state. Though the more I expand on this the more it seems like I should pick one or the other. Either score as each of the moves in a branch are calculated or score the end board favorability result of each branch, not both.\nMaybe something like: (Board Favorability \/ 2) * Goodness = Final Branch Value\nRegardless, am I on the right track here? Will this approach work (not the favorability part, the general scoring and \"Goodness\" score for a given branch) or am I on the complete wrong track? Thanks for any assistance!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":708,"Q_Id":63223136,"Users Score":1,"Answer":"You're on the right track, and another answer already has lots of details, but one thing I want to highlight is that you should focus on evaluating positions rather than evaluating moves. The value of a move is simply the value of the position it ends up in.\n\nInstead of awarding lots of points to a \"winning move\", you award lots of points to a won position.\nInstead of awarding some points for a capture, and some more points for a king capture, you can score positions according to material. The reason we consider a capture a good move is because it deprives the opponent of pieces. Acquiring a king improves our own material. Evaluating positions on material takes these things into consideration.\nLikewise your rules about control of the center, being against the wall, etc. are much easier to do (and work better) as evaluations of a position, rather than tallying up points for \"moves that result in X\".\n\nWin\/lose\/draw are \"hard\" conditions; if the game is over, it doesn't matter how much material you have left, or where it's placed, or anything else. You wouldn't choose a draw over a win just because the win sacrifices a piece. Evaluation rules for material, mobility, etc. are \"rules of thumb\" for how close a player is to winning, or how much ability they have to win, so you only really care about them when you don't have a forced win\/loss\/draw within your search horizon, and when you do use them, you want them to produce scores that are as similar as possible to the scores you would get if you could search every position until the end of the game.\nYou can start out assigning scores to your different evaluation rules by intuition, but to make them really good, you would simulate lots of games to the finish, and then run statistics on the winning and losing players' positions \u2014 then you would assign higher scores to the rules that most strongly correlate with positions that actually win.","Q_Score":0,"Tags":"python,artificial-intelligence","A_Id":63224987,"CreationDate":"2020-08-03T02:57:00.000","Title":"Will my AI algorithm for a python checkers game work and if not, what others should I consider?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a Simple GUI Tkinter Program. I was going to compile my Program (with Pyinstaller) but Avast is blocking PIP. So I ignored it. When Compile was Finished.\nI run the compiled .exe program and the program are saying:\nfailed to execute the script, Avast is blocking.\nHow to fix this error and What am the issue?\nedit:now Avast is not blocking .exe(but blocking PIP)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1527,"Q_Id":63223306,"Users Score":1,"Answer":"I use avast as well. Avast sandboxes pipenv when installing a new package. Depending on what\/if virtualenv your using.\nYou can whitelist\/exclude python's install directory. For windows the default location is %localappdata%\\Programs\\Python. This is also where pip is installed globally as well as pyinstaller and other packages that are installed globally.\nBe warned this will make it so avast no longer scans anything related to python in those directories. So if you're worried about getting a virus from a python package then you can whitelist\/exclude the pip exe itself which is located specifically...\n32-bit Python 3.8\n%localappdata%\\Programs\\Python\\Python38-32\\Scripts\\pip.exe\n64-bit Python 3.8\n%localappdata%\\Programs\\Python\\Python38\\Scripts\\pip.exe\nIf you use a virtualenv whitelist\/exclude those directories since those virtualenvs use a local copy of pip instead of the global one. That should fix avast messing with pip\/virtualenv\/pipenv","Q_Score":2,"Tags":"python,tkinter,pip,pyinstaller,virus","A_Id":63223446,"CreationDate":"2020-08-03T03:23:00.000","Title":"Avast blocks pip and Pyinstaller","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to extract common data from different websites. Like I want to scrape 100 event websites and extract the same information like event name, price, location etc. Every website has a different layout so I'm writing scraping rules by hand. There are some services like diffbot that can extract this automatically. They are using some sort of AI\/ML model. I was wondering if this can be a Named Entity task or maybe LSTM can be used.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":156,"Q_Id":63228794,"Users Score":1,"Answer":"Without more details on the structure\/format of your targeted websites, it's difficult to go beyond a generic answer.\nIf these are mostly text based (ie natural text not semi structured with table and all), then it seems like a classic information extraction (IE) of named entities. LSTM is an architecture that could be used for this like the ones in spacy. Many other classic NLP libraries like stanfordNLP can also be of use (not always with deep learning).\nHow to make the choice? It will depends on the type of language in these pages. If it's more natural English, then DL models could be better. If this is a domain jargon (small dataset to learn), you might need to investigate more grammar based analysis.","Q_Score":0,"Tags":"python,machine-learning,web-scraping,nlp,named-entity-recognition","A_Id":63229451,"CreationDate":"2020-08-03T11:42:00.000","Title":"Machine Learning model to parse webpage data and extract fields","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to extract common data from different websites. Like I want to scrape 100 event websites and extract the same information like event name, price, location etc. Every website has a different layout so I'm writing scraping rules by hand. There are some services like diffbot that can extract this automatically. They are using some sort of AI\/ML model. I was wondering if this can be a Named Entity task or maybe LSTM can be used.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":156,"Q_Id":63228794,"Users Score":0,"Answer":"To add to the previous response, don't forget to check if the websites you scrape have an API, which could highly reduce time spent coding, and be more reliable if the websites change their layouts.\nYou probably already checked it, but that doesn't hurt to remind this.","Q_Score":0,"Tags":"python,machine-learning,web-scraping,nlp,named-entity-recognition","A_Id":63229525,"CreationDate":"2020-08-03T11:42:00.000","Title":"Machine Learning model to parse webpage data and extract fields","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python script that starts other processes via subprocess.run(...). Usually such a process runs automatically without reading from stdin. However, in the case of an error the processes waits for user input. I want detect such a situation from the calling python script and then e.g. kill that process. How could I achieve this?\n(My idea was to create a file-like object which raises an Exception when its .read() method is called and pass it to subprocess.Popen(...) as a \"bait\" for the stdin kwarg. However this seems somehow ugly because some fileno needed to be faked.)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":63229997,"Users Score":0,"Answer":"You can just pass an empty file, e.g. subprocess.DEVNULL. A process which waits for standard input will get an EOF signalled if it tries reading from such a file.","Q_Score":2,"Tags":"python,subprocess,stdin,popen","A_Id":63231156,"CreationDate":"2020-08-03T13:04:00.000","Title":"Determine if a subprocess reads from stdin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So when developing an app, it's considered good practice to specify the  minimal (least restrictive) needed dependency versions in setup.py's, install_requires. Well, how do I know which versions of my dependencies my project actually depends on?\nIs there any way to automatically determine this? If not, is there maybe a nice way to test the upper and lower bounds of the dependency ranges I specify?\nIdeally, I'd like to focus on actual development more than manually tracking every new version of my dependencies and sifting through release histories to find out when the features I used were first introduced.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":377,"Q_Id":63230836,"Users Score":1,"Answer":"The \"Correct\" way would just be to keep track of what features you use in each dependency, and then the minimum versions for each would be the minimum version that has those features, or has some important update (security, speed, etc).\nThe \"If it works, it works\" way would be to write a script that brute forces the versions for each individual dependency to get a range for each by installing it and seeing if it works. You could probably do this easily using github actions (Although you'd have to pay if your repo is private)","Q_Score":7,"Tags":"python","A_Id":63232150,"CreationDate":"2020-08-03T13:58:00.000","Title":"How do I know which versions of dependencies my application supports?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python virtual environment (conda) where I\u2019ve installed CUDA toolkit 10.1.243 and tensorflow-gpu 2.3.0rc0. My CUDA driver is 11.0.\nIn order to test if tensorflow was installed to GPU correctly, I ran a series of commands from within the venv:\ntf.test.is_built_with_cuda()\nTrue\ntf.config.list_physical_devices(\u2018GPU\u2019)\nFound device 0 with properties:\npciBusID: 0000:01:00.0 name: Quadro M2000M computeCapability: 5.0\n[PhysicalDevice(name=\u2019\/physical_device:GPU:0\u2019, device_type=\u2018GPU\u2019)]\npython -c \"import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000,1000])))\"\ntensorflow.python.framework.errors_impl.InternalError: CUDA runtime implicit initialization on GPU:0 failed. Status: device kernel image is invalid\nI am not sure how to troubleshoot this. I have a feeling that it is related to modifying the compilation such that tensorflow supports the compute capability of my device (5.0), but I am not sure how to proceed. Thank you!!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":6036,"Q_Id":63231021,"Users Score":1,"Answer":"i recommend pip install tensorflow-gpu==2.2","Q_Score":9,"Tags":"python,tensorflow,gpu,nvidia","A_Id":67192770,"CreationDate":"2020-08-03T14:10:00.000","Title":"Tensorflow-gpu issue (CUDA runtime error: device kernel image is invalid)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanna know is it possible Running two server Django and React.js together?\nevery time I should to run Backend with python manage.py run server and then I should go to Frontend and Run npm Start\nactually I have One Fullstack project with Subfolders Backend And Frontend\nmy question is we have any code to rune both servers together or Not?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":616,"Q_Id":63233789,"Users Score":1,"Answer":"As I know,unfortunately,there is no way to run them both with just a line of code.This can be wrong though.","Q_Score":0,"Tags":"javascript,python,django,reactjs","A_Id":63233847,"CreationDate":"2020-08-03T16:59:00.000","Title":"how to Run Django and React server together?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have Qubole connected to Azure data lake, and I can start a spark cluster, and run PySpark on it. However, I can't save any native Python output, like text files or CSVs. I can't save anything other than Spark SQL DataFrames.\nWhat should I do to resolve this?\nThank you in advance!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":254,"Q_Id":63235683,"Users Score":0,"Answer":"If I understand your question correctly,I believe you are unable to download the result of pyspark command output into text or CSVs while you are able to do so for the spark sql command command output in a nice tabular format.\nUnfortunately, there is no direct field separator for the output text for a Python or Shell command outputs. You will need to get your output comma separated so you can download the raw output and save it as a csv.\nIf this is not what you meant, Please share more details as to what exactly are you trying to do along with screenshots details. As that will help us answer your question better.","Q_Score":0,"Tags":"python,azure,qubole","A_Id":63238287,"CreationDate":"2020-08-03T19:21:00.000","Title":"How to get Python in Qubole to save CSV and TXT files to Azure data lake?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"PyCharm was being stupid so I decided to use Atom. Before, I had stupidly downloaded Python from the official website and the Microsoft store, so it caused errors on PyCharm which meant I had to use Atom.\nHowever, recently I managed to fix that issue by uninstalling Python from the Microsoft store and installing the latest version of Python with the PATH properly configured, but it only fixed PyCharm but not Atom.\nHowever, whenever I try to run a script on Atom, I get this error message:\nPython was not found but can be installed from the Microsoft Store: https:\/\/go.microsoft.com\/fwlink?linkID=2082640\nI have Python installed from the website but not the MS store. Any ideas how to fix this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":992,"Q_Id":63236923,"Users Score":0,"Answer":"It should not matter whether you download Python from the Microsoft Store or from python.org. What matters is that Python is installed on your system and that any application using that version of the interpreter can access it. Typically, this means that you have any entry on your PATH environment variable to the directory of your Python interpreter.\nFrom what you've described, it sounds like you may have had more than one version on your system at the same time, and then you removed one and made some modifications to your PATH variable. I would confirm that your PATH variable is correct and that you can run the Python interpreter from a Command Prompt window by invoking it directly. If you can do that, then Atom ought to be able to find your Python interpreter. If it cannot, then I would recommend uninstalling and reinstalling Atom rather than uninstalling and reinstalling Python.\nI would like to help more, but would need more info about your system to provide a more specific steps.","Q_Score":1,"Tags":"python,python-3.x,windows,atom-editor","A_Id":63237165,"CreationDate":"2020-08-03T21:03:00.000","Title":"Atom says I need to install Python through Microsoft Store but I have Python Installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have over 200 tables which need to be migrated to S3 from RDBMS with no transformations So we are planning to migrate using Glue Job. So I want to create AWS Glue Job which can be re-usable and executed using parameter values so that i can run for multiple tables at a time(Multi-threading). Is this possible anyway in AWS Glue.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":562,"Q_Id":63237180,"Users Score":1,"Answer":"The quick answer is yes\n\nYou can reuse a singular glue job that can be resued where you can pass your source location and target database table name as job arguments to the glue job\nYour glue jobs supports concurrency which can be set in your glue job(whcih means you can have multiple invocations of the same job). This would be the easier option than implementing multi-threading in your job. But multi-threading would cretainly be possible as long as we use only default or pure python modules. There are certain account level limits (which can be increased) that you will need to keep in mind.\nYou can pass the arguments to the glue job when you invoke the glue job, by using whatever mechanism you want (eg: step functions\/lambdas...)","Q_Score":1,"Tags":"python,pyspark,aws-glue","A_Id":63238219,"CreationDate":"2020-08-03T21:28:00.000","Title":"Reusable AWS Glue Job","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am running the latest anaconda on ubuntu linux.  Everything was working ok until this week.  I can't import pandas on python3.  I could last week using the same programs.  I've tried it on python  called from the bash and also from spyder  and jupyter, and I get a message that it can't find pandas.  I've tried reinstalling pandas using both pip and conda, and it said that it was correctly installed.\nAny suggestions?\nThank you.\nHoward","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":63238530,"Users Score":0,"Answer":"You can create a new environment on Anaconda and then install pandas in that environment. Otherwise, try re-installing Anaconda.","Q_Score":0,"Tags":"python,pandas,conda","A_Id":63256430,"CreationDate":"2020-08-04T00:06:00.000","Title":"why does import pandas suddenly not work?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement a degree-3 noncausal moving average filter (in Python) to be applied to one of the signals. I do have an idea about moving average but I am new to signal processing. As of now, I know that a smoothing technique like an MA would reduce out the noise in the data but then it would make the sharp transitions in the data increasingly blunt. But then my question is how is this thing taken care of when we go to introduce non-causality in the system.\nFrom what I understand about non-causal system is a system whose output not only depends on past and present inputs but also future inputs. I am trying to understand things in depth here. But i think i am stuck due to knowledge gap. I would be grateful if there are any good references or resources which I could use for a better understanding.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":633,"Q_Id":63239658,"Users Score":0,"Answer":"If you have your dataset in memory, you are free to take make output[100] depend on input[105] if you so please. There's nothing about Python or signal processing that prevents you from mathematically doing that, as long as you recognize that you'll need to either truncate both edges or apply suitable padding.\nMathematically, you simply convolve with your desired impulse response. For example, a length-3 rectangular moving average impulse response centered about 0 (non-causally) would be represented by y[n] = x[n-1]\/3 + x[n]\/3 + x[n+1]\/3. We call the values [1\/3, 1\/3, 1\/3]the coefficients of the non-causal FIR filter we have chosen. Actually designing a filter by choosing the best coefficients is a [mathematically complex and rich problem](https:\/\/en.wikipedia.org\/wiki\/Finite_impulse_response#Filter_design), but you may always obtain a MATLAB license and utilize a tool such asfdatool` to build the filter to your frequency response specifications.\nFor a physical system or realtime sample-by-sample processing (e.g. on a microcontroller running CircuitPython), this cannot be realized of course. Assuming a discrete transformation and an otherwise stable system, the non-causality shows up in the Z-transform as elements of the form z^n for positive n. By adding delays (i.e. multiplying by z-1), you can make your non-causal response causal, at the expense of that added delay. Looking at our prior example, such a delay would correspond to making output[100] still depend on input[105], but making the 100th output sample only available to the following stage after the 105th input sample has been received.\nAs for making your data smoother or not smoother, an LTI smoothing filter will generally always blunt your edges. You can either design a filter with the appropriate characteristics to trade off the blunting of edges with smoothing requirements, or if the data is suitable, use a non-LTI processing approach.","Q_Score":0,"Tags":"python-3.x,signal-processing,smoothing","A_Id":63239683,"CreationDate":"2020-08-04T03:06:00.000","Title":"Why non-causal?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a wrapper script wrapper.py that would time the full execution of benchrun.py.\nLet's say I run the benchrun.py using this command:\npython benchrun.py --host {host} -f {testfile} -t {number of threads} -s {mongo shell path}\nWhat should I put in the wrapper script to run the benchrun.py script and get the execution time?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":63240401,"Users Score":0,"Answer":"Are you using os.system to call the benchrun.py? If so, just set datetime.now() in the begining and after return, and calculate the delta. It should work.","Q_Score":0,"Tags":"python,wrapper,os.system","A_Id":63240459,"CreationDate":"2020-08-04T04:43:00.000","Title":"Wrapper script that would record the execution time of another script with parameters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to drop some columns and uppercase the data in snowflake tables.\nFor which I need to loop through all the catalogs\/ dbs, its respective schemas and then the tables.\nI need this to be in python to list of the catalogs schemas and then the tables after which I will be exicuting the SQL query to do the manipulations.\nHow to proceed with this?\n1.List all the catalog names\n2.List all the schema names\n3.List alll the table names\nI have established a connection using python snowflake connector","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1405,"Q_Id":63242243,"Users Score":0,"Answer":"Your best source for this information is in your SNOWFLAKE.ACCOUNT_USAGE share that Snowflake provides.  You'l need to grant privileges to whatever role you are using to connect with Python.  From there, though, there is are the following views: DATABASES, SCHEMATA, TABLES, and more.","Q_Score":1,"Tags":"python,sql,database,snowflake-cloud-data-platform,snowflake-schema","A_Id":63247222,"CreationDate":"2020-08-04T07:41:00.000","Title":"How to retrieve all the catalog names , schema names and the table names in a database like snowflake or any such database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed snorkel using conda and when I try to run -  from snorkel.labeling import labeling_function it throws the following error - ModuleNotFoundError: No module named 'snorkel.labeling'.\nI tried looking up for a solution on Github, but unfortunately, I couldn't follow through. I have also tried installing nb_conda_kernels, to make all your conda environments available in jupyterbut it didn't help. Also tried creating a separate env, installing snorkel and launching jupyter notebook from the snorkel's environment, and it didn't work either. Any form of help is much appreciated!\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":750,"Q_Id":63243522,"Users Score":-1,"Answer":"Please try the following:\nFor pip users\npip install snorkel\nFor conda users\nconda install snorkel -c conda-forge","Q_Score":0,"Tags":"python,jupyter,snorkel","A_Id":63243641,"CreationDate":"2020-08-04T09:04:00.000","Title":"ModuleNotFoundError: No module named 'snorkel.labeling'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used Pyinstaller to make a standalone portable application for windows from python code, and it works normally.\nI understand that to create an executable for a certain OS it must be done on that specific OS.\nIs there a way to create executables for other platforms directly from windows without running a virtual machine.\nThank you.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2358,"Q_Id":63245946,"Users Score":0,"Answer":"In order to make executable files for Mac and Linux, you need to build it on the same systems\nFor example, in order to make your Linux work, you need to collect the rpm package","Q_Score":3,"Tags":"python,pyinstaller,executable","A_Id":63246388,"CreationDate":"2020-08-04T11:27:00.000","Title":"How to create Linux and MacOS executables using PyInstaller on Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am rewriting python import system in C. I encountered a problem: in Python\/importlib.h, it says it is generated by Lib\/importlib\/_bootstrap.py, but even if I changed some code in Lib\/importlib\/_bootstrap.py, Python\/importlib.h remains unchanged.\nI have 3 questions:\n1: How can I change the bytecode in Python\/importlib.h?\n2: What is the relationship between Lib\/importlib\/_bootstrap.py and Python\/importlib.h?\n3: How does the cpython import system work in total?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":63246403,"Users Score":1,"Answer":"After several weeks of reading the source code of Python-3.6.10, I write an answer here to offer my understanding.\n\nPython\/importlib.h is generated by Programs\/_freeze_import.c. \"make regen-all\" is need to rerun the _freeze_import.c file. _freeze_import.c take the input of Lib\/importlib\/*.py to generate Python\/importlib.h and Python\/importlib_external.h.\nLib\/importlib\/*.py is the source of Python\/importlib.h and Python\/importlib_external.h.\nYou need to dive into the source code.","Q_Score":0,"Tags":"import,cpython","A_Id":63336902,"CreationDate":"2020-08-04T11:58:00.000","Title":"How does importlib.h generated from importlib._bootstrap in Cpython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to save apscheduler scheduler instance I'm working with to remove it later or modify.\nI have django web app. I have notification model in django admin. After creating a new row - I schedule notification to send it later on my email. And that part works perfectly.\nBut what if I need to change the notification or delete it?\nThere is problem..\nWith some \"returns\" I've got the schedule instance in my admin.py. But I can only print it to console and that's all. How and where can I save this instance to work with it later? (after delete row 4 example).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":63248174,"Users Score":0,"Answer":"Ok just add your scheduler to AppConfig","Q_Score":0,"Tags":"python,django,apscheduler","A_Id":63264588,"CreationDate":"2020-08-04T13:40:00.000","Title":"Share one global apscheduler scheduler across all modules Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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":"I have a python selenium script that runs after every 5 minutes inside the windows server and using a chrome driver. It takes 3-4 minutes to complete.\nIs there any possibility that it causes the server to stop working or make it down?\nbecause in my case it was running fine for 4-5 days after that, we found the server stop working and we require to restart it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":63249101,"Users Score":0,"Answer":"Are you closing the browser with driver.quit() at the end of your script? Check if you have one multiple instances of chromedriver.exe running when your script is not actually running.","Q_Score":0,"Tags":"python,windows,selenium,selenium-chromedriver","A_Id":63774016,"CreationDate":"2020-08-04T14:30:00.000","Title":"Can selenium slow down or stop the windows server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"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 <older_commit> the branch to some older commit that contained the branch. Or you can git revert <the_commit_that_deleted_the_file> the commit that deleted that file. Or you can git checkout <some_other_commit> -- test.csv to selectively restore the file from <some_other_commit> 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":"I want to replace the word bacteria in this sentence\n'List all the bacteria whose <http:\/\/bacteria> is bacillus ?'\nWhen I use text.replace('bacteria','<e0>'), it replaces also the bacteria in <http:\/\/bacteria> which I don't want and the string becomes 'List all the <e0> whose <http:\/\/<e0>> is bacillus ?'\nHow to avoid this?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":127,"Q_Id":63250657,"Users Score":1,"Answer":"I would say you have two very easy options here, or if you have more variable needs, use regex:\n\nPython's replace built-in allows you to specify the number of replacements that should be made. ex: text.replace('bacteria', '<e0>', 1) if you know the one you want to replace will come first.\nYou can use text.replace(' bacteria ', ' <e0> ') or something similar if you only want to replace instances surrounded by spaces.","Q_Score":0,"Tags":"python,string","A_Id":63250794,"CreationDate":"2020-08-04T15:57:00.000","Title":"How to replace a word only if it is followed and preceded by a space?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For my project, I have a virtual currency, which you can get by staying on the page. (every 15 minutes you get 0.1 coins) I did some research, and I did not find anything about it in Flask and I have no clue on how to see how long a user has been on a page. Is there anyone who could help me?\nThanks,\nRobert S.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":63251283,"Users Score":1,"Answer":"There is no direct way as http is stateless.\nThat means that once a page is loaded, the connection between browser and server gets disconnected.\nMaybe there are ways to workaround this limitation, eg by regularly send a message to the server via Javascript or with websockets.","Q_Score":0,"Tags":"python,flask","A_Id":63252349,"CreationDate":"2020-08-04T16:34:00.000","Title":"Python Flask detect how long a user has been on the page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to deploy a Flask webapp to Heroku and I have seen conflicting information as to which files I need to include in the git repository.\nMy webapp is built within a virtual environment (venv), so I have a Pipfile and a Pipfile.lock. Do I also need a requirements.txt? Will one supersede the other?\nAnother related question I have is what would occur if a certain package failed to install in the virtual environment: can I manually add it to the requirements.txt or Pipfile? Would this effectively do the same thing as pipenv install ... or is that doing something else beyond adding the package to the list of requirements (considering Heroku is installing the packages upon deployment).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5917,"Q_Id":63252388,"Users Score":11,"Answer":"You do not need requirements.txt.\nThe Pipfile and Pipfile.lock that Pipenv uses are designed to replace requirements.txt. If you include all three files, Heroku will ignore the requirements.txt and just use Pipenv.\nIf you have build issues with a particular library locally I urge you to dig into that and get everything working on your local machine. But this isn't technically required... as long as the Pipfile and Pipfile.lock contain the right information (including hashes), Heroku will try to install your dependencies.","Q_Score":3,"Tags":"heroku,pip,python-venv,requirements.txt,pipfile","A_Id":63252833,"CreationDate":"2020-08-04T17:44:00.000","Title":"requirements.txt vs Pipfile in heroku flask webapp deployment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working with a json API using python requests, the company who issued the API doesn't clarify in its documentation how many requests I can make per day\/hour\/minute.\nSometimes I am getting connection errors with it, is there any way to systematically deal with that? find out what the limits are or some way to test what they are efficiently?\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":63253894,"Users Score":0,"Answer":"I am not an expert in this and your question was pretty vague so I can't really tell in what way you need to systematically deal with the problems that arise.\nIf it is something that is already running and only occasionaly fails due connection errors or request limits then I would suggest programming something that helps you track the requests and answers from the server by writing them into a text file so you can check later what the error message was and why it happened. To make it easier to go over this data you can have it as an object in your code and save it as a json or xml file so that you can open it and have it as an object again in python.\nFor example you could have an object that saves the number of requests you have sent, the number of errors you have gotten, a list of requests you have sent, a list of answers you have gotten from the server and a list with numbers of which requests have failed.\nIf it is something small scale or something that isn't working yet then I would suggest just going over the errors manually and just try to see if you can fix them. You could send alot of requests manually to check the request limit and you could try to find out what happens when a connection error occurrs and try to recognize that in python and send the request again.","Q_Score":0,"Tags":"python,api,python-requests","A_Id":63254238,"CreationDate":"2020-08-04T19:31:00.000","Title":"What's the best way to manage many requests from the same API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Shannon's entropy from information theory measures the uncertainty or disorder in a discrete random variable's empirical distribution, while differential entropy measures it for a continuous r.v. The classical definition of differential entropy was found to be wrong, however, and was corrected with the Limiting density of discrete points (LDDP). Does scipy or other compute the LDDP? How can I estimate LDDP in python?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":429,"Q_Id":63254029,"Users Score":3,"Answer":"Since LDDP is equivalent to the negative KL-divergence from your density function m(x) to your probability distribution p(x), you might be able to use one of the many implementations of KL-divergence, for example from scipy.stats.entropy.\nAn appropriate procedure (assuming you have finite support) is to approximate the continuous distribution with a discrete one by sampling over its support, and calculating the KL divergence.\nIf this is not possible, then your only option that I can think of is probably to use numerical (or possibly analytic?) integration methods, of which you should have plenty. An easy first step would be to try monte-carlo methods.","Q_Score":2,"Tags":"python,entropy,information-theory","A_Id":63254307,"CreationDate":"2020-08-04T19:42:00.000","Title":"Limiting density of discrete points (LDDP) in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a neural net with Keras for predicting the voltage output of a complicated electrical circuit based on known current injections at distinct input nodes. As of right now, the model is a simple ConvLSTM model, which produces fairly good predictions. The problem is that I need to predict several minutes of voltage output on a millisecond timescale based on the initial 50 ms of ground truth voltage and the known current injections, so as I move forward in time, the model starts to rely on it's own predictions, therefore the prediction error compounds. I can measure the behavior of the system to obtain training datasets, but it's really slow, hence the need for a NN.\nIn my current mdoel I can only predict the next voltage value in time as the current input changes every millisecond, therefore long-term forecasting is not feasible. What I want to do is to build a model which takes 50 ms of ground truth training voltage, 60 ms of current input (starting at the same time as the voltage values, but exceeding it by 10 ms), and 10 milliseconds of voltage as a target. This would potentially help me to strenghten the first prediction (51st datapoint).\nUnfortunately no matter how long I searched, I haven't found an architecture which was capable of handling this kind of input. Does anyone have any idea for a basic keras architecture?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":139,"Q_Id":63254704,"Users Score":0,"Answer":"Viktor,\nI suggest to feed LSTM for training with combination of actual current (at t between 11 ms and 50 ms) and voltage from 10 ms ago (from 1 ms to 40 ms) then you have a rectangular input (2 x 40) for each training sample.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,keras","A_Id":63255210,"CreationDate":"2020-08-04T20:36:00.000","Title":"Long-term time series forecasting using Keras with predictions relying on future inputs","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a task to perform classification on a data set in which the feature names are anonymous like var1,var2 etc. There is mixed continuous and one hot encoded features. I am bit stuck how to make new features out of the existing features and perform EDA on it.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":263,"Q_Id":63260282,"Users Score":1,"Answer":"There are many approaches to feature engineering, which could be also used on anonymized data:\n\ntransformation of continuous variables: log, power, normalization;\naggregations: `df.groupby(['cat_column']).agg({'continuous_column': ['min', 'max', 'mean', 'std'])\ninteractions of continuous variables: addition, subtraction, multiplications, division\nAnd so on.","Q_Score":1,"Tags":"python,jupyter-notebook,data-science,feature-selection,feature-engineering","A_Id":63262347,"CreationDate":"2020-08-05T07:23:00.000","Title":"How to do feature engineering on anonymous dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"just wondering how to convert a set of code into comments, without having to go through each individual line of code and put a # at the beginning. Was thinking that maybe there was a quick way to highlight the code and then convert it into comment, atm i'm just cutting it off the code and then re-pasting it in later on.\nMuch appreciated :)\nP.S. i m using Pycharm as my IDE","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":566,"Q_Id":63267329,"Users Score":1,"Answer":"In jupyter notebook, we select lines of code and press ctrl and \/ key simultaneously to convert a set of code into comments. Also same for vice versa.\nYou can try it in Pycharm.","Q_Score":0,"Tags":"python-3.x,comments","A_Id":63267450,"CreationDate":"2020-08-05T14:27:00.000","Title":"How to transform lines of code into a comment in Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"just wondering how to convert a set of code into comments, without having to go through each individual line of code and put a # at the beginning. Was thinking that maybe there was a quick way to highlight the code and then convert it into comment, atm i'm just cutting it off the code and then re-pasting it in later on.\nMuch appreciated :)\nP.S. i m using Pycharm as my IDE","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":566,"Q_Id":63267329,"Users Score":0,"Answer":"You can use the (\"\"\") symbol before and after the text you want to comment out. It is not exactly a comment and more of a text constant, but either way it is often used for documentation, so you can use it for multiline comments except for some cases when it causes unexpected errors\nTo avoid such cases you could simply use multiple single line comments by selecting the desired lines and using ctrl+\/ to comment them out","Q_Score":0,"Tags":"python-3.x,comments","A_Id":63267438,"CreationDate":"2020-08-05T14:27:00.000","Title":"How to transform lines of code into a comment in Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"What I have : Basically I have a dashboard in Python's Dash which has a button called GetData. The callback handler for this button gets data from 3 sources, draws 3 charts and sends back an output Div wrapping all of these charts nicely. I also have a text area on the client's screen which updates after all work is done on the server, serving as a console.\nWhat I want:\nA dedicated area on the client's screen to keep a running log of actions initiated on the server by the client. This would mean that,\na) I would like to update the text in the console by appending status of intermediate steps on the server. Way I see it, I can only update the value in the text area ONCE, right at the end of the button callback handler.\nb) I would also like to bind this console as output to multiple button callbacks so that I can send a log of what's happening on the server with the client's request back to the client.\nThoughts?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":665,"Q_Id":63268276,"Users Score":1,"Answer":"I was able to achieve this by,\na) Writing to a logfile\nb) Using a dcc.Interval component with output bound to a text area that polls the logfile and shows the last 20 rows from it\nSo far there is only one user\/client but once there are more will need to think about filtering and the like.","Q_Score":2,"Tags":"python,callback,dashboard,plotly-dash","A_Id":63271924,"CreationDate":"2020-08-05T15:16:00.000","Title":"Implement a console in Dash which gets updated with status of intermediate steps on the server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What I have : Basically I have a dashboard in Python's Dash which has a button called GetData. The callback handler for this button gets data from 3 sources, draws 3 charts and sends back an output Div wrapping all of these charts nicely. I also have a text area on the client's screen which updates after all work is done on the server, serving as a console.\nWhat I want:\nA dedicated area on the client's screen to keep a running log of actions initiated on the server by the client. This would mean that,\na) I would like to update the text in the console by appending status of intermediate steps on the server. Way I see it, I can only update the value in the text area ONCE, right at the end of the button callback handler.\nb) I would also like to bind this console as output to multiple button callbacks so that I can send a log of what's happening on the server with the client's request back to the client.\nThoughts?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":665,"Q_Id":63268276,"Users Score":1,"Answer":"For this kind of use case, i typically use variations of following approach\n\nGenerate a unique key for each log instance, e.g. if you want all logs for the current user, you could use the session id or a GUID generated on page load\nDuring callback executing on server, logging output is written to a server side resource (a redis cache, a file etc.) identified by the key\nUsing a callback triggered by Interval component and with the key as State (so that the correct log can be identified), the log is read from the server","Q_Score":2,"Tags":"python,callback,dashboard,plotly-dash","A_Id":63276944,"CreationDate":"2020-08-05T15:16:00.000","Title":"Implement a console in Dash which gets updated with status of intermediate steps on the server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"What is the difference between .quit and .destroy on Tkinter, they seem to do the same thing.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":259,"Q_Id":63271131,"Users Score":1,"Answer":".quit() causes mainloop to exit, but doesn't directly cause any widgets to be destroyed. However, if there's no code after calling mainloop then the script exits, and all widgets will be destroyed.\n.destroy() will destroy a widget. If you destroy the root window then all other widgets will be destroyed and mainloop will stop.","Q_Score":0,"Tags":"python,tkinter","A_Id":63271292,"CreationDate":"2020-08-05T18:09:00.000","Title":"Difference between .quit and .destroy on tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Relatively simple question. Looking at the objective documentation for xgboost, I see \"multi:softmax\" and \"multi:softprob\", but both are mutliclass which will only output one class. Is there any way to predict multiple labels using xgboost or would I be better off simply training multiple models for each individual label. For example, on sklearn, multilabel is supported by RandomForestClassifier, where when fitting, your input for the target array can be of the shape n samples x n labels.\nTo clarify: multiclass would be when you want to predict whether a student gets an A,B, or C while multilabel would be something like predicting whether the student got question 1,2,3, or 4 on the test right. (they can only receive one grade but they can correctly answer any combination of those questions correctly)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":840,"Q_Id":63271205,"Users Score":0,"Answer":"I haven't found anything which is supported natively by xgboost. The only solution is to wrap it around sklearn.multioutput.MultiOutputClassifier which does the same thing. But the downside of this method is that you cannot leverage load_model and save_model from xgboost itself and must use something like joblib to dump and load the model (which is not backward compatible in terms of xgboost version).","Q_Score":3,"Tags":"python-3.x,scikit-learn,xgboost,multilabel-classification,multiclass-classification","A_Id":68484221,"CreationDate":"2020-08-05T18:15:00.000","Title":"XGboost objectives: Is there a way to do Multi label (NOT multiclass ) classification?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"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 made a python program for PC remote controlling and when I use the socket.gethost() to get the ip for the server it works fine but if I use 192.168... it does not even connect (the PC's are on the same wifi though).\nI think the code is correct because if I try to connect the same PC as a host and as a client it works normally, so I wanted to know what ip I should use and if I want to use it on different Wi-Fi's what should ip should I use?\nIf you need the code just ask.\nI use Kali.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":34,"Q_Id":63272740,"Users Score":1,"Answer":"for the bind address on the server file use 0.0.0.0 if you want to connect to it from a different device. then use its ip 192.168... to connect from the other device.","Q_Score":1,"Tags":"python,python-3.x,sockets,remote-control","A_Id":63272784,"CreationDate":"2020-08-05T20:03:00.000","Title":"socket not connecting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Pandas and SQLAlchemy to push data from CSVs into a MySQL database. When calling df.to_sql() thousands of lines of logs clutter the command line. Is there a way turn off\/stop the logging?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":264,"Q_Id":63273105,"Users Score":1,"Answer":"Don't think that is the standard behaviour of to_sql() but rather the parameter echo=True set in your sqlalchemy engine. Changing it back to echo=False or removing it since it is false as a default should stop it from printing out the logs.","Q_Score":0,"Tags":"python,pandas,sqlalchemy","A_Id":63273278,"CreationDate":"2020-08-05T20:33:00.000","Title":"Is there a way to turn off df.to_sql logs?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Context:\nI currently have a Python Flask app which when receives a request, it automatically creates a Kubernetes job to run a process. Once the job finishes, it posts back the results to a specific endpoint (never changes). Depending on the specifics of the request, this process can vary greatly in length (time) and in resource requirements. The reason I'm using Jobs for this is due to their ability to restart on failure.\nProblem:\nEven with allowing maximum restarts, there will be times where the process will error. I want to implement something along the lines of:\n\nIf the job finishes successfully, do nothing.\nIf the job fails after reaching max retries, then run foo()\n\nfoo() is a very simple Python function that will send an HTTP request with the parameters of the request that resulted in the job not successfully completing. It does not have to be a Python function, but it is preferred.\nNote: I wrap everything in a broad error exception within the python function that the job needs to perform, however, there might be times that the job will fail due to insufficient memory.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":38,"Q_Id":63277074,"Users Score":-1,"Answer":"why don't implement a serveless solution in your cluster ,\nknative or kubeless or other solution.","Q_Score":0,"Tags":"python-3.x,kubernetes,kubernetes-jobs,kubernetes-python-client","A_Id":63279135,"CreationDate":"2020-08-06T04:54:00.000","Title":"Is there a way to automatically launch a followup (different) job only if a Kubernetes job fails?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am studying from my course book on Data Structures by Seymour Lipschutz and I have come across a point I don\u2019t fully understand..\n\nBinary Search Algorithm assumes that one has direct access to middle element in the list. This means that the list must be stored in some typeof linear array.\n\nI read this and also recognised that in Python you can have access to the middle element at all times. Then the book goes onto say:\n\nUnfortunately, inserting an element in an array requires elements to be moved down the list, and deleting an element from an array requires element to be moved up the list.\n\nHow is this a Drawback ?\nWon\u2019t we still be able to access the middle element by dividing the length of array by 2?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":191,"Q_Id":63277598,"Users Score":0,"Answer":"It seems that author compares array-like structures  and linked list\nThe first (array, Python and Java list, C++ vector) allows fast and simple access to any element by index, but appending, inserting or deletion might cause memory redistribution.\nFor the second we cannot address i-th element directly, we need to traverse list from the beginning, but when we have element -  we can insert or delete quickly.","Q_Score":1,"Tags":"algorithm,python-2.7,data-structures,binary-search","A_Id":63277814,"CreationDate":"2020-08-06T05:51:00.000","Title":"Binary Search-accessing the middle element drawback","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In dnspython you can set the server for queries via dns.resolver.nameservers.\nIs there an equivalent statement to set the dns server for DDNS updates via dnspython?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":63278644,"Users Score":0,"Answer":"Silly me.\nOf course its set when you send it...\nresponse = dns.query.tcp(update, server, timeout = 10)\nApologies.","Q_Score":0,"Tags":"dns,updates,dnspython","A_Id":63309058,"CreationDate":"2020-08-06T07:18:00.000","Title":"dnspython Set the DNS server for DDNS updates?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on my Bachelor Thesis. I want to predict the heartrate of people with video data. I build my network similar to the paper \"RhythmNet: End-to-End Heart Rate Estimation\nFrom Face via Spatial-Temporal Representation\".\nMy problem:\nMy network does not learn to predict the HR properly instead it learns the mean HR. Could you give me some tipps how to improve the variety of my Regression output? Do you have some general tipps how to improve the network performance?\nThx in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":63278659,"Users Score":0,"Answer":"According to Page 8 of the Paper, the output of the network is the mean Heart Rate. The output is computed with a mean pooling layer. Maybe you can get the single values from the single heart rates before the mean pooling layer?","Q_Score":0,"Tags":"python,tensorflow,regression","A_Id":63278785,"CreationDate":"2020-08-06T07:20:00.000","Title":"My Network is rather predicts the mean output instead of individual predictions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"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 am using TPE sampler from optuna to optimize hyperparameters for Deep Learning vision models.\nI was wondering if optuna adapt search depending of the number of trials.\nIf I train for 1000 trials and stop at 500, I can see that many parameters were not tried by the algorithm.\nIf I reduce n_trials, does TPE explore faster (and less precisely) ?\nIn other terms, is interupting optuna at 500 with n_step=1000 the same as using n_trials = 500 and waiting until the end.\nI only have basic understanding of how TPE works.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":247,"Q_Id":63282307,"Users Score":2,"Answer":"If I reduce n_trials, does TPE explore faster (and less precisely)?\n\nNo.\n\n... is interupting optuna at 500 with n_step=1000 the same as using n_trials = 500 and waiting until the end.\n\nYes.\nThis is because TPE (from Optuna) is not aware of the number of remaining (or total) trials.","Q_Score":1,"Tags":"python,hyperparameters,optuna","A_Id":63421727,"CreationDate":"2020-08-06T11:09:00.000","Title":"Does TPE (from Optuna) takes account of the number of trials?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My python version is Python 2.7.17\nI usually use pip to install other modules like shutil and itertool etc. I can't find the package name for os, getopt and sys modules.\nAny help will be appreciated.\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13058,"Q_Id":63282832,"Users Score":0,"Answer":"They are installed with your python as part of the standard library, if they are missing, something is wrong with your Python installation and you should reinstall it","Q_Score":1,"Tags":"python,ubuntu,pip,python-module","A_Id":63282928,"CreationDate":"2020-08-06T11:42:00.000","Title":"how to install python modules sys, os and getopt on unbuntu?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"i am new to python opencv and i want to build a software that verifies if the uploaded image belongs to the same user or not but i in opencv you need to train the faces in order to get precised results, the problem is that the faces are likely random with only 1 photo as described above.\nAny help will be appreciated, thank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":63284327,"Users Score":0,"Answer":"i am using google facenet for the implementation of face recognition system.","Q_Score":0,"Tags":"python,opencv","A_Id":63398253,"CreationDate":"2020-08-06T13:10:00.000","Title":"python-opencv face recogniton and verification without face training","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a sub-string that needs to checked against main-string , I had used FuzzyMatch Partial Ratio algorithm, but somehow, the score seems to be inappropriate\nsub string :\nAspire 1 14\nMain String:\nAcer Aspire 1 14 Inch Celeron 4GB 64GB Cloudbook - Red This sleek HD Acer Aspire 1 delivers an inviting tactile finish, featuring 4GB of RAM and an Intel Celeron Processor complete daily tasks and surf the internet seamlessly. Whilst 64GB of storage gives you enough space to easily store and share your important media and documents. #||#The classy look of the Aspire 1 is matched only by the convenience of its thin, easily portable design. #||#The Precision Touch-pad is more responsive than traditional touch-pads helping you work more effectively. #||#Model number: A114-32. #||#General features:#||#Size H1.79, W34.3, D24.5cm. #||#Weight 1.65kg. #||#Up to 10 hours battery life. #||#CPU, Memory and Operating System:#||#Intel Celeron N4000 processor. #||#Dual core processor. #||#1.1GHz processor speed with a burst speed of 2.6GHz. #||#4GB RAM DDR4. #||#64GB eMMC storage. #||#Microsoft Windows 10 S. #||#Display features:#||#14 inch screen. #||#High definition display. #||#Resolution 1366 x 768 pixels. #||#DVD optical drives:#||#Disc drive not included. #||#Graphics:#||#Intel UHD Graphics 600 graphics card. #||#Shared graphics card. #||#Interfaces and connectivity:#||#SD media card reader. #||#Secure Digital (SD), . #||#2 USB 2.0 ports. #||#1 USB 3.0 port. #||#1 Ethernet port. #||#1 HDMI port. #||#Bluetooth. #||#Wi-Fi enabled. #||#Multimedia features:#||#HD webcam. #||#Built-in mic. #||#Built-in audio sound system. #||#30 days Norton Security. #||#General information:#||#Manufacturer's 1 year guarantee. #||#EAN: 4710180446104.       Size H1.79, W34.3, D24.5cm.#||#Weight 1.65kg.#||#Up to 10 hours battery life.#||#Intel Celeron N4000 processor.#||#Dual core processor.#||#1.1GHz processor speed with a burst speed of 2.6GHz.#||#4GB RAM DDR4.#||#64GB eMMC storage.#||#Microsoft Windows 10 S.#||#14 inch screen.#||#High definition display.#||#Resolution 1366 x 768 pixels.#||#Disc drive not included.#||#Intel UHD Graphics 600 graphics card.#||#Shared graphics card.#||#SD media card reader.#||#Secure Digital (SD), .#||#2 USB 2.0 ports.#||#1 USB 3.0 port.#||#1 Ethernet port.#||#1 HDMI port.#||#Bluetooth.#||#Wi-Fi enabled.#||#HD webcam.#||#Built-in mic.#||#Built-in audio sound system.#||#30 days Norton Security.#||#Manufacturer's 1 year guarantee.#||#EAN: 4710180446104.\nExpected score is 100 but got only 55\nAny suggestions are welcomed! Thanks in advance!\nHeading","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":63286322,"Users Score":0,"Answer":"Figured out that if either of strings length (# of characters) crosses threshold value, partial_ratio sets Sequence Matcher to be false and the scores are not 100% even if there is a partial string match","Q_Score":0,"Tags":"python,string,string-comparison,fuzzywuzzy","A_Id":63450825,"CreationDate":"2020-08-06T14:56:00.000","Title":"FuzzyWuzzy partial_ratio string match","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have two installations of python (3.7 and 3.8) under two different usernames on my machine.\nPython 3.7 is on my PATH and in folder C:\\\\users\\username1\\appdata\\local\\programs\\python\\python37-32\\python.exe\nI also have python 3.8 which came with miniconda and it is in a folder C:\\Users\\username2\\miniconda3\\python.exe\nMiniconda is NOT my path (as recommended).\nBoth users have administrator privileges. What's the best way to switch between these two versions in VS Code?\nPS: Should I consider adding miniconda (or just the destination to python3.8) to my PATH?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":161,"Q_Id":63286515,"Users Score":1,"Answer":"My suggestion is to use conda to create enviornments for each project. Then you can use conda to switch between those enviornments.","Q_Score":0,"Tags":"python,windows,conda,miniconda","A_Id":63286551,"CreationDate":"2020-08-06T15:07:00.000","Title":"Switch between python versions on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created an application in tkinter python and I want it to run automatically when windows boots up for any user who installs it on their computer just like spotify.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":63288168,"Users Score":0,"Answer":"Click on Start Windows, search for Task Scheduler, and open it.\nClick Create Basic Task at the right window.\nGive a name and a description.\nChoose your trigger time.\nSelect the script\nClick finish","Q_Score":1,"Tags":"python,tkinter","A_Id":63288404,"CreationDate":"2020-08-06T16:40:00.000","Title":"Autorun for application stored on computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In sklearn.cross_decomposition.PLSRegression, we can obtain the latent variables scores from the X array using x_scores_.\nI would like to extract the loadings to calculate the latent variables scores for a new array W. Intuitively, what I whould do is: scores = W*loadings  (matrix multiplication). I tried this using either x_loadings_, x_weights_, and x_rotations_ as loadings as I could not figure out which array was the good one (there is little info on the sklearn website). I also tried to standardize W (subtracting the mean and dividing by the standard deviation of X) before multiplying by the loadings. But none of these works (I tried using the X array and I cannot obtain the same scores as in the  x_scores_ array).\nAny help with this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":260,"Q_Id":63288624,"Users Score":0,"Answer":"Actually, I just had to better understand the fit() and transform() methods of Sklearn. I need to use transform(W) to obtain the latent variables scores of the W array:\n1.Fit(): generates learning model parameters from training data\n2.Transform(): uses the parameters generated from fit() method to transform a particular dataset","Q_Score":0,"Tags":"python,scikit-learn,pls","A_Id":63299943,"CreationDate":"2020-08-06T17:12:00.000","Title":"Python PLSRegression : obtaining the latent variables scores using loadings","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In linear algebra, vectors are normalized when they are divided by their norm, that is, the squared sum of their components.\nYet, sklearn.preprocessing.normalize method does not accept vectors, only matrices of at least two columns:\n\"ValueError: Expected 2D array, got 1D array instead\"\nWhy?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":244,"Q_Id":63291969,"Users Score":0,"Answer":"According to the documentation for sklearn.preprocessing.normalize, the parameter x is the data to normalize, element by element, and has the shape [n_samples, n_features]. The function normalize perform this operation on a single array-like dataset, either using the L1 or L2 norms.","Q_Score":1,"Tags":"python,scikit-learn,linear-algebra","A_Id":63292027,"CreationDate":"2020-08-06T21:25:00.000","Title":"Normalize function in Sklearn requires 2D array","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Alembic doesn't support replaceable objects like views so we often have to write a custom function in revision that executes creation of them. Is there a way to share these functions across revisions instead of copy-pasting over and over?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":63292572,"Users Score":0,"Answer":"After looking, you can either reference code in a separate package or use env.py. Creating your own module is probably easier","Q_Score":0,"Tags":"python,sqlalchemy,alembic","A_Id":63309715,"CreationDate":"2020-08-06T22:22:00.000","Title":"alembic - how to share functions across revisions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to create an app and tkinter is really helpful, just want to confirm if Tkinter will successfully lead me to an app for IOS or Android.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":10464,"Q_Id":63292696,"Users Score":1,"Answer":"Tkinter is meant for desktop applications, not mobile apps. You won't be able to make a mobile app with Tkinter. However, I've found that developing in Tkinter has given me a taste of what developing apps is like, and so I figure some of the thought processes I've learned will transfer over to Swift and Java, which are the main languages for developing mobile apps.","Q_Score":0,"Tags":"python,android,ios,tkinter","A_Id":63294290,"CreationDate":"2020-08-06T22:35:00.000","Title":"Is it possible to use Tkinter to create an app for Android or iOS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create an app and tkinter is really helpful, just want to confirm if Tkinter will successfully lead me to an app for IOS or Android.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":10464,"Q_Id":63292696,"Users Score":1,"Answer":"Unfortunately Tkinter won't work for creating mobile apps as it is meant to be used on desktop only. However check out Swift with Xcode that has a really good user interface for building app interfaces where you can drag and drop different items you want onto the screen - you will need a Mac for that.\nAlternatively Android Studio is continually being updated which has a similar interface for creating app screens - available for Windows and Mac.\nThere are loads of tutorials for starting of on Xcode or Android Studio which should help you get started.","Q_Score":0,"Tags":"python,android,ios,tkinter","A_Id":63300700,"CreationDate":"2020-08-06T22:35:00.000","Title":"Is it possible to use Tkinter to create an app for Android or iOS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've compiled an app using python, js, html and css (using eel to link them). It's all working but when I load the exe that is compiled, it opens the app logo, bounces up and down (as apps do on Macs when loading) then the logo disappears, and then the app opens after about 8 seconds from google chrome.\nIs this normal for Pyinstaller executables i.e. opening from chrome, or is there something in my code? If so, leave a comment and I will update this question with relevant snippets of my code!\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":63294222,"Users Score":0,"Answer":"is it possible that while compiling your app with Pyinstaller, you used --onefile? If this is the case, try compiling again without this command and see if the problem still persists.\nfrom the Pyinstaller docs:\n\n... the single executable is a little slower to start up than the\none-folder bundle.\nBefore you attempt to bundle to one file, make sure your app works\ncorrectly when bundled to one folder. It is is much easier to diagnose\nproblems in one-folder mode.","Q_Score":0,"Tags":"javascript,python,html,python-3.x,pyinstaller","A_Id":63315352,"CreationDate":"2020-08-07T02:11:00.000","Title":"Why does Pyinstaller exe open and close then open again?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've compiled an app using python, js, html and css (using eel to link them). It's all working but when I load the exe that is compiled, it opens the app logo, bounces up and down (as apps do on Macs when loading) then the logo disappears, and then the app opens after about 8 seconds from google chrome.\nIs this normal for Pyinstaller executables i.e. opening from chrome, or is there something in my code? If so, leave a comment and I will update this question with relevant snippets of my code!\nThanks","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":127,"Q_Id":63294222,"Users Score":1,"Answer":"I've made a work around and am posting it as the answer to this question incase someone has a similar issue in the future.\nAfter doing research I found that PyInstaller is simply just slow in most cases where there is a larger python file i.e. machine learning. There were also other issues with integrating PyInstaller and JS\/HTML\/CSS, where you have to use Eel to communicate between the documents, and subsequently, every desktop\/web application you make will have to involve google chrome.\nSOLUTION:\nAs an alternative to building the desktop application via PyInstaller, I am building it using Blazor\/Electron. There is no direct link between Blazor\/Electron and Python, as Blazor relies on C#, JS\/HTMLCS. Therefore, I ported in IronPython into my C# file, this allows me to communicate along the following path. C# -> Python -> C# -> JS\/HTML\/CSS. An additional advantage to Blazor\/Electron is that the application can be built as a local desktop application without internet connection, and it boots up much faster. Lastly, C# allows for building Splash Screens (loading screen while the app boots up for the first time) for your application, so even if you're app is huge and it has a long load time, the user can be informed that the desktop app is loading!","Q_Score":0,"Tags":"javascript,python,html,python-3.x,pyinstaller","A_Id":63315595,"CreationDate":"2020-08-07T02:11:00.000","Title":"Why does Pyinstaller exe open and close then open again?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"We can force to execute a destructor with del, and usually just let the garbage collector do its work, but if we define a class destructor in Python, is it guaranteed to execute for every object instantiated?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":298,"Q_Id":63294410,"Users Score":4,"Answer":"Short answer: no.\nLonger answer: __del__ is not really a destructor in the C++ sense and you probably don't want to use it.\nInstead, if you need cleanup, you should probably make the objects into context managers (by writing __enter__ and __exit__ methods) and use them in the with statement, and\/or give them close methods which need to be called explicitly. Most classes in Python and widely-used libraries that need to release external resources do both (often by having __enter__ return self and __exit__ call self.close()).\nWith the garbage collection, there is usually no need to deallocate any memory allocated in __init__ or __new__, as might be done in C++, since it will be collected automatically.\nThere are uses for the __del__ method, but they're rare.","Q_Score":3,"Tags":"python","A_Id":63294577,"CreationDate":"2020-08-07T02:40:00.000","Title":"Are Python class destructors guaranteed to execute before the program ends?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried using Scikit Learn's classification_report() to find other details why I got a certain score but instead I got an error.\n\nValueError: continuous is not supported\n\nI just want to know what it is and how to resolve it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":152,"Q_Id":63294425,"Users Score":1,"Answer":"Probably you are trying to classify a continuous value. When the values are continuous you need to perform a regression. If you want to perform a classification you then perform a classifier in which you assign the features to a class (group).","Q_Score":0,"Tags":"python,scikit-learn","A_Id":63294585,"CreationDate":"2020-08-07T02:43:00.000","Title":"ValueError: continuous is not supported. What is this error?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to find out what width a Label would be for a given text and font, without having to add it to the graphical elements currently being displayed.\nI need to get the information without any effect on the GUI, however momentary that effect may be. And, in any case, packing appears to work in a top-down fashion, meaning that controls may expand to fill others higher in the hierarchy but I can't get them to adjust those higher to allow for their actual size.\nI'm more used to QML where I can just give an off-screen element the text and font details then just read out the bounding box.\nDoes anyone know how to do something similar in Tkinter?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":63295132,"Users Score":2,"Answer":"You can create the Label without calling pack() \/ grid() \/ place(), then call winfo_reqwidth() and winfo_reqheight() on the label to get its size.","Q_Score":0,"Tags":"python,tkinter,width,tkinter-label","A_Id":63299693,"CreationDate":"2020-08-07T04:19:00.000","Title":"TkInter get width of specific text","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to add multiple admins in Django's admin panel and how I will register them(they need to have the same rights)? And also is it possible to add another 2 roles to the panel with different rights?\nI read a lot about it and can't find the answer.\nI will really appreciate your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":286,"Q_Id":63297245,"Users Score":0,"Answer":"You can just create\/modify a user and while creating a user you can select their role if they are admin, staff, etc. You can also customize user's permissions when you create their account or if the accounts are already created you can modify it.\nTo avoid having to assign permission's again and again, i would suggest you create a new group and add the permission that the user in that group should have and then assign the desired user in that group.","Q_Score":0,"Tags":"python,django,django-admin","A_Id":63297341,"CreationDate":"2020-08-07T07:33:00.000","Title":"Multiple admins in Django is it possible","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"A little bit of context:\nI am writing a stock back test program which subscribes to a websocket feed that streams data for over 100 stocks 1 minute candle. Since this is a back test program, it actually get fed by my local data.\nI am trying to utilise Ray for multiprocessing.\nSo it will receive stock data in a loop locally, for example, A, B, C .... A, B, C... continuously until end of time period. Currently my set up with Ray is call handleStock.remote() asynchronously for each of the stock data. For performance reason, each time it process same stock but different time, there should be some cache to help process faster. But due to each of the stock per time is running as a completely new process\/worker in Ray, I can't have a place to share memory and also write to it. I tried Ray put method but it's read only.\nIs there a way to resolve this or a different tool to run this back test?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":766,"Q_Id":63298145,"Users Score":2,"Answer":"Ray object store values are meant to be first-writer-wins. One potential option here is to store the data in an actor instead of in the object store.\nIf you really need to return the object and performance is important, perhaps break the operation up into 2 async operations.\n\nPerform calculation\nReturn result","Q_Score":1,"Tags":"python,multiprocessing,ray","A_Id":63351172,"CreationDate":"2020-08-07T08:31:00.000","Title":"How to make Python library Ray shared memory writeable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm facing a very strange error while deploying a DAG into a Composer Airflow environment.\nI have created a custom operator with the following import:\nfrom exchangelib import DELEGATE, Account, Credentials, Message, FileAttachment, HTMLBody\nThe custom operator is defined in a file named airflow_mail_operator.py and the DAG is defined in a file named test_main.py.\nThe error I get is from the airflow webserver and states ModuleNotFoundError: No module named 'exchangelib' even if the Composer environment already presents this library.\nThe error stops showing if I add the import statement even in the DAG file, and this sounds really strange to me!\nFollowing the full stacktrace:\nTraceback (most recent call last): File \"\/usr\/local\/lib\/airflow\/airflow\/models\/dagbag.py\", line 243, in process_file m = imp.load_source(mod_name, filepath) File \"\/opt\/python3.6\/lib\/python3.6\/imp.py\", line 172, in load_source module = _load(spec) File \"<frozen importlib._bootstrap>\", line 684, in _load File \"<frozen importlib._bootstrap>\", line 665, in _load_unlocked File \"<frozen importlib._bootstrap_external>\", line 678, in exec_module File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed File \"\/home\/airflow\/gcs\/dags\/dg_dags\/test_main.py\", line 5, in <module> from dg_dags.airflow_mail_operator import CustomEmailOperator File \"\/home\/airflow\/gcs\/dags\/dg_dags\/airflow_mail_operator.py\", line 5, in <module> from exchangelib import DELEGATE, Account, Credentials, Message, FileAttachment, HTMLBody ModuleNotFoundError: No module named 'exchangelib'\nHave someone evere faced (and maybe resolved) a similar error?\nMy environment is:\ncomposer-1.10.0-airflow-1.10.6\npython3\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":439,"Q_Id":63300146,"Users Score":0,"Answer":"The solution for me was to force an update on Composer cluster by updating the underlying k8s cluster!","Q_Score":1,"Tags":"python,airflow,directed-acyclic-graphs,google-cloud-composer","A_Id":71763383,"CreationDate":"2020-08-07T10:40:00.000","Title":"Composer Airflow - No module named \"exchangelib\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have just started using Avro and I'm using fastavro library in Python.\n\nI prepared a schema and saved data with this one.\nNow, I need to append new data (JSON response from an API call ) and save it with a non-existent schema to the same avro file.\nHow shall I proceed to add the JSON response with no predefined schema and save it to the same Avro file?\n\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":63301046,"Users Score":0,"Answer":"Avro files, by definition, already have a schema within them.\nYou could read that schema first, then continue to append data, or you can read entire file into memory, then append your data, then overwrite the file.\nEach option require you to convert the JSON into Avro (or at least a Python dict), though.","Q_Score":0,"Tags":"python-3.x,avro,fastavro","A_Id":63349410,"CreationDate":"2020-08-07T11:38:00.000","Title":"Avro append a record with non-existent schema and save as an avro file?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Basically what the title says, since 1-3 days ago randomly when I press ctrl+c to copy a variable or text or whatever from the python interactive component of the VSC it doesn't copy. I have looked through my shortcut preferences for both ctrl+c and for copy to see if something was interfering but there doesn't seem to be anything. And when I use ctrl+c anywhere else I never have had a problem so it cant be with my keyboard.\nI am truly lost and about to go insane from this it is extraordinarily frustrating, so would highly appreciate if anyone more familiar with VSC than me had any thoughts","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":63302630,"Users Score":0,"Answer":"try ctrl + shift + c, maybe that'll work","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":63302669,"CreationDate":"2020-08-07T13:15:00.000","Title":"VSC does not recognize ctrl+c in \"Python interactive\" session randomly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"Given a {{ form  }} in a template for a model with a models.TextField called text, is there a way to access the html text-input field inside the same template directly from the form ?\nI need something like document.getElementById() but don't know what id to pass.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":63303771,"Users Score":0,"Answer":"IDK what really you try to asking, explain more!","Q_Score":0,"Tags":"python,html,django,django-models,django-forms","A_Id":63309982,"CreationDate":"2020-08-07T14:24:00.000","Title":"Get html text-input element from django-form in template","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Given a string  I need to remove the smallest character and return the sum of indices of removed charecter.\nSuppose the string is 'abcab' I need to remove first a at index 1.\nWe are left with 'bcab'. Now remove again a which is smallest in remaining string and is at index 3\nWe are left with 'bcb'.\nIn the same way remove b at index 1,then remove again b from 'cb' at index 2 and finally remove c\nTotal of all indices is 1+3+1+2+1=8\nQuestion is simple but we need to do it in O(n). for that I need to remove kth element in O(1). In python del list[index] has time complexity O(n).\nHow can I delete in constant time using python\nEdit\nThis is the exact question\nYou are given a string S of size N. Assume that count is equal to 0.\nYour task is the remove all the N elements of string S by performing the following operation N times\n\u2022 In a single operation, select an alphabetically smallest character in S, for example, Remove from S and add its index to count. If multiple characters such as c exist, then select that has the smallest index.\nPrint the value of count.\nNote Consider 1-based indexing\nSolve the problem for T test cases\nInput format\nThe first line of the input contains an integer T denoting the number of test cases \u2022 The first line of each test case contains an integer N denoting the size of string S\n\u2022 The second line of each test case contains a string S\nOutput format\nFor each test case print a single line containing one integer denoting the value of count\n1<T, N < 10^5\n\u2022 S contains only lowercase English alphabets\nSum of N over all test cases does not exceed 10\nSample input 1\n5\nabcab\nSample Output1\n8\nExplanation\nThe operations occur in the following order\nCurrent string S= abcab', The alphabetically smallest character of s is 'a As there are 2 occurrences of a, we choose the first occurrence. Its Index 1 will be added to the count and a will be removed. Therefore, S becomes bcab\na will.be removed from 5 (bcab) and 3 will.be added to count\nThe first occurrence of b will be removed from (bcb) and 1 will be added to count.\nb will be removed from s (cb) and 2 will be added to count\nc will be removed from 5 (c) and 1 will be added to count","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":976,"Q_Id":63306205,"Users Score":3,"Answer":"If you follow your procedure of repeatedly removing the first occurrence of the smallest character, then each character's index -- when you remove it -- is the number of preceding larger characters in the original string plus one.\nSo what you really need to do is find, for each character, the number of preceding larger characters, and then add up all those counts.\nThere are only 26 characters, so you can do this as you go with 26 counters.","Q_Score":1,"Tags":"python-3.x,algorithm,data-structures,time-complexity","A_Id":63306565,"CreationDate":"2020-08-07T16:56:00.000","Title":"How to remove kth element in O(1) time complexity","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given a string  I need to remove the smallest character and return the sum of indices of removed charecter.\nSuppose the string is 'abcab' I need to remove first a at index 1.\nWe are left with 'bcab'. Now remove again a which is smallest in remaining string and is at index 3\nWe are left with 'bcb'.\nIn the same way remove b at index 1,then remove again b from 'cb' at index 2 and finally remove c\nTotal of all indices is 1+3+1+2+1=8\nQuestion is simple but we need to do it in O(n). for that I need to remove kth element in O(1). In python del list[index] has time complexity O(n).\nHow can I delete in constant time using python\nEdit\nThis is the exact question\nYou are given a string S of size N. Assume that count is equal to 0.\nYour task is the remove all the N elements of string S by performing the following operation N times\n\u2022 In a single operation, select an alphabetically smallest character in S, for example, Remove from S and add its index to count. If multiple characters such as c exist, then select that has the smallest index.\nPrint the value of count.\nNote Consider 1-based indexing\nSolve the problem for T test cases\nInput format\nThe first line of the input contains an integer T denoting the number of test cases \u2022 The first line of each test case contains an integer N denoting the size of string S\n\u2022 The second line of each test case contains a string S\nOutput format\nFor each test case print a single line containing one integer denoting the value of count\n1<T, N < 10^5\n\u2022 S contains only lowercase English alphabets\nSum of N over all test cases does not exceed 10\nSample input 1\n5\nabcab\nSample Output1\n8\nExplanation\nThe operations occur in the following order\nCurrent string S= abcab', The alphabetically smallest character of s is 'a As there are 2 occurrences of a, we choose the first occurrence. Its Index 1 will be added to the count and a will be removed. Therefore, S becomes bcab\na will.be removed from 5 (bcab) and 3 will.be added to count\nThe first occurrence of b will be removed from (bcb) and 1 will be added to count.\nb will be removed from s (cb) and 2 will be added to count\nc will be removed from 5 (c) and 1 will be added to count","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":976,"Q_Id":63306205,"Users Score":1,"Answer":"Looks like you're only interested in the resulting sum of indices and don't need to simulate this algorithm step by step.\nIn which case you could compute the result in the following way:\nFor each letter from a to z:\n\nHave a counter of already removed letters set to 0\nIterate over the string and if you encounter the current letter add current_index - already_removed_counter to the result.\n2a. If you encounter current or earlier (smaller) letter increase the counter as it already has been removed\n\nThe time complexity is 26 * O{n} which is O{n}.","Q_Score":1,"Tags":"python-3.x,algorithm,data-structures,time-complexity","A_Id":63306703,"CreationDate":"2020-08-07T16:56:00.000","Title":"How to remove kth element in O(1) time complexity","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello StackOverflow community:\nI trained a 4 layer DNN using Tensorflow 2.0. Using a new batch of data, I wish to retrain the model weights starting from layer 2 to the output layer, while keeping the weights from earlier layers, (i.e., those attached to the inputs and layer 1) frozen. I tried to lookup in the documentation of Tensorflow 2.0, but I can't seem to find what I am looking for. What could be the setup for the codes here? Or, if there is a documentation, could please someone link me to?\nThanks.\nPS: I am new to Tensorflow. I am tempted to solve this problem from scratch. But not ensuring first whether the package actually handles the job would be unwise and inefficient.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":63308156,"Users Score":0,"Answer":"Thanks for the response. I am using Tensorflow 2.0. I know that Keras has been embedded in this new version. I was actually able to solve this problem by intuition. Turns out that each layer has an attribute where we can set trainable=False. So what I did is that I collected the layers of the original model, and then set those layers I want frozen as non-trainable, leaving the weights in the later layers for fine-tuning during the retraining step.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,deep-learning,tensorflow2.0","A_Id":63316820,"CreationDate":"2020-08-07T19:33:00.000","Title":"How to retrain a DNN keeping the weights in the hidden layers frozen in Tensorflow 2.0","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe and when I do df.dtypes in shows the column is an object\nI do df[\"column_name\"] = df[\"column_name\"].astype(str)\nand again check df.dtypes it still shows the column type as object. Any idea bow to fix this.\nWhen I do df['column_name'].to_string().dtype\nI get an error\nAttributeError: 'unicode' object has no attribute 'dtype'","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":194,"Q_Id":63308956,"Users Score":1,"Answer":"In Pandas, there are only these datatypes: boolean, integer, float, datetime and  object. Objects are almost always strings but can be any Python object. This is the reason why df.dtypes shows an object.","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":63309089,"CreationDate":"2020-08-07T20:48:00.000","Title":"Pandas change column to string","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"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":"Using Scikit-Learn's RandomizedSearchCV module, how do you guarantee a certain set of hyper-parameter settings will all be tested?\nMy goal is to guarantee that, using a randomized search for optimal estimator hyper-parameters, all available activation functions for sklearn MLPClassifier are tested. Still, I would also like an answer that applies to Python machine learning models\/estimators in general. I believe I could test which activation function was the best by running RandomizedSearchCV or GridSearchCV using 3 different instances of MLPClassifier. The problem is, what if I want to test all available activation functions and all weight \"solvers\" among other parameters such as the number of neurons and layers? Is there any way to do this using a Python library?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":63313134,"Users Score":0,"Answer":"I am only posting this answer since the comment below the question is the best answer for me.\nComment by desertnaut on Aug. 08, 2020:\n\nYou cannot; RandomizedSearchCV provides absolutely no such guarantees. You should revert to GridSearchCV if you want to be sure that certain combinations will be tested.\n\nThe best solution for now is to use a combination of both RandomizedSearchCV and GridSearchCV.","Q_Score":0,"Tags":"python,scikit-learn,hyperparameters","A_Id":63608321,"CreationDate":"2020-08-08T08:06:00.000","Title":"Using Scikit-Learn's RandomizedSearchCV module, how do you guarantee a certain set of hyper-parameter settings will all be tested?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a CNN, but using the SIFT algorithm instead of any pooling layers.\nProblem is I can't seem to find any Python implementation of the algorithm in Tensorflow or PyTorch. The only implementation I have seen of it is with opencv.\nIs it possible to use the opencv SIFT implementation as a layer in a Tensorflow CNN Model?\nIf so, how would you go about creating it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":637,"Q_Id":63313842,"Users Score":2,"Answer":"While this is an interesting idea, I believe it has numerous issues that make it highly impracticable to impossible.\nLayers of a network have to be differentiable with regards to their input to allow any gradients to be calculated, which are then used to update the weights.\nWhile I think it might be possible to write a fully differentiable sift implementation, this alone will be impractical.\nFurther SIFT does not have a constant number of outputs and takes a long time to compute, which would slow down the training a lot.\nThe only practical way to use SIFT with neural networks would be to first run SIFT and then use the top N detected keypoints as input for the first layer. However, I'm not sure this would be successful.","Q_Score":1,"Tags":"python,tensorflow,pytorch,sift","A_Id":63313979,"CreationDate":"2020-08-08T09:33:00.000","Title":"Can you integrate opencv SIFT with a tensorflow model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I mean, how am I supposed to do something like this, when I click a button, a browser opens, on the page it url gives?\nMy guess is that a module is needed here, unless it can be done in the Tkinter module, because that's where I want this button (hyperlink, as in html)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":355,"Q_Id":63314105,"Users Score":1,"Answer":"Try using the webbrowser module. You can have a look at this link for more information-https:\/\/docs.python.org\/2\/library\/webbrowser.html\nThe webbrowser module provides a high-level interface to allow displaying Web-based documents to users. Under most circumstances, simply calling the open() function from this module will do the right thing.\nUnder Unix, graphical browsers are preferred under X11, but text-mode browsers will be used if graphical browsers are not available or an X11 display isn\u2019t available. If text-mode browsers are used, the calling process will block until the user exits the browser.\nIf the environment variable BROWSER exists, it is interpreted to override the platform default list of browsers, as an os.pathsep-separated list of browsers to try in order. When the value of a list part contains the string %s, then it is interpreted as a literal browser command line to be used with the argument URL substituted for %s; if the part does not contain %s, it is simply interpreted as the name of the browser to launch. 1\nFor non-Unix platforms, or when a remote browser is available on Unix, the controlling process will not wait for the user to finish with the browser, but allow the remote browser to maintain its own windows on the display. If remote browsers are not available on Unix, the controlling process will launch a new browser and wait.\nThe script webbrowser can be used as a command-line interface for the module. It accepts a URL as the argument. It accepts the following optional parameters: -n opens the URL in a new browser window, if possible; -t opens the URL in a new browser page (\u201ctab\u201d). The options are, naturally, mutually exclusive.","Q_Score":2,"Tags":"python,hyperlink","A_Id":63314182,"CreationDate":"2020-08-08T10:01:00.000","Title":"What module for opening links in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have seen the term 'monospace' at dozen of places. Can you tell me what does monospace font mean and what monospace fonts are available in Python and Tkinter?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1067,"Q_Id":63318183,"Users Score":3,"Answer":"\"Monospace\" just means that all characters take the same, fixed width for each character.\nThe converse is a \"proportional\" font where narrower letters e.g i take less space and wider letters e.g. m take more space.\nWhich ones are available depend on what you have installed.","Q_Score":0,"Tags":"python,tkinter,fonts,monospace","A_Id":63318256,"CreationDate":"2020-08-08T17:13:00.000","Title":"What monospace fonts are available in Python and Tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I know what recursive functions are, but every time I have a task that seems like recursion is the way to go, I am not sure where to start.  What are some good ways to think about how to approach the problem?  For example, should I start from the last case scenario (the scenario that causes the recursion to stop) or the first case scenario?\nAny references or guides that explain the approach (as opposed to what is recursion itself) would be helpful.  Or maybe it's not that hard and I'm just overthinking it.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":125,"Q_Id":63318827,"Users Score":1,"Answer":"Recursion is generally about solving a problem by dividing it into subproblems, until you reach a base case (or as you said, a \"last\" case). Once you have the base case(s) and the general case, you have solved the recursive problem.\nThe general case is usually the trickier bit. For some problems it can be more obvious, but a good tactic is to start with the simplest input you can think of (which may be your base case), and then work your way up to more complicated inputs.\nFor example, if you want to process a non-empty array in some manner recursively, you first solve the problem for arrays of length 1, then arrays of length 2, etc. until you see the general solution.\nPractice is often most helpful. Look at solutions to example problems (after attempting them yourself) until you get a better feel for it. Good luck!","Q_Score":0,"Tags":"python,python-3.x,recursion,reference","A_Id":63318965,"CreationDate":"2020-08-08T18:19:00.000","Title":"What are general tips for building recursive functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have found that the pycharm debugger will not stop at breakpoints set in work functions of custom python GR blocks.  However, it will stop at breakpoints set in a block's constructor.\nIs there a way to stop at breakpoints in a work function?  I know that the function is being run because when I put print statements in the work function, I see the results of the print when the flowgraph is run.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":75,"Q_Id":63320991,"Users Score":0,"Answer":"That's to be expected: the work() is called from C++ context; your debugger simply doesn't \"control\" the execution.\nI'm sure it's possible to allow attaching breakpoints, but I don't know of a specific way. It would be relatively involved, because you need to instrument python in a GNU Radio-specific way, I guess.","Q_Score":0,"Tags":"python,debugging,pycharm,gnuradio","A_Id":63324897,"CreationDate":"2020-08-08T23:04:00.000","Title":"Using pycharm to debug a custom GNU Radio block work function written in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi I'm trying to read an environment variable in python, if I execute my script from console with:\npython3 myScript.py everything goes ok, but I need to run this script as a service in Ubuntu, in this case, the script can't get the environment variable. Anyone has past for the same issue? I noticed that when i'm trying to read the mongo URI from environment.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":63321231,"Users Score":0,"Answer":"The correct way to achieve that is passing the environment variable or environment file to the service file, in my case I added this line to my service file:\nEnvironmentFile = \/etc\/environment","Q_Score":0,"Tags":"python-3.x,ubuntu,service,environment-variables","A_Id":63321266,"CreationDate":"2020-08-08T23:50:00.000","Title":"Issue tying to read environment variable in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"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 very new to Mongo engine and currently I have mongo query filter that is working in mongo shell but I wanted to achieve the same in Mongoengine , can you please help me\nMongo Shell Query\n{name:{$nin:[\/ja\/,\/ra\/]}}\nbut same is not working with Mongoengine\nnamelist = NameRecord.objects(name__nin=['\/ja\/','\/ra\/'])\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":133,"Q_Id":63325358,"Users Score":2,"Answer":"First of all I would like to thank @tom-slabbaert for pointing me the what was wrong , as he pointed the issue was with regex of python and finally with his input I am able to find the solution, in fact all credits goes to him just I am adding answer so it will be helpful any others in future\nnamelist = NameRecord.objects(name__nin=[re.compile(r\"ja\"), re.compile(r\"ra\")])","Q_Score":1,"Tags":"python,mongodb,flask,mongoengine","A_Id":63327139,"CreationDate":"2020-08-09T10:50:00.000","Title":"Python Mongoengine with $nin with pattern","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Flask URL interpreter recognizes \/api\/hello but not when passed like this \/api\/hello\/\nIs there to have it work both ways?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":63325478,"Users Score":0,"Answer":"Add a \/ after hello so it will redirect to \/api\/hello\/ even if request is done on \/api\/hello\n@app.route('\/app\/hello\/')","Q_Score":0,"Tags":"python,flask,werkzeug","A_Id":63325594,"CreationDate":"2020-08-09T11:03:00.000","Title":"Flask URL works like this \"\/api\/hello\" but not like this \"\/api\/hello\/\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Flask URL interpreter recognizes \/api\/hello but not when passed like this \/api\/hello\/\nIs there to have it work both ways?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":63325478,"Users Score":0,"Answer":"You can do like this\n@app.route(\"\/api\/hello\/\")\nIn this way both url will work","Q_Score":0,"Tags":"python,flask,werkzeug","A_Id":63325562,"CreationDate":"2020-08-09T11:03:00.000","Title":"Flask URL works like this \"\/api\/hello\" but not like this \"\/api\/hello\/\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to set a background image for my html. I have a file system of\nStatic\n\ncss\nimg\n\nThis is what I use to link my css file.\n<link rel=\"stylesheet\" href=\"{{ url_for('static',filename='css\/index.css') }}\">\nIn my css file I defined the background-image\n.bgimg-1 {background-image: url(\"\/static\/img\/background.jpg\");}\nHowever in my flask application I am getting the error of\n127.0.0.1 - - [09\/Aug\/2020 19:10:04] \"[37mGET \/ HTTP\/1.1[0m\" 200 -\n127.0.0.1 - - [09\/Aug\/2020 19:10:04] \"[33mGET \/static\/css\/static\/img\/background.jpg HTTP\/1.1[0m\" 404 -\nIm not sure where does the \/static\/css\/ is coming from\nI defined the class in <header class=\"bgimg-1 w3-display-container w3-grayscale-min\" id=\"home\">","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":322,"Q_Id":63326046,"Users Score":0,"Answer":"I feel, it's because your index.css file is inside \/static\/css\/ folder and from there it is referring to image (\/static\/img\/background.jpg) , so making the complete image url to this - \/static\/css\/static\/img\/background.jpg","Q_Score":0,"Tags":"python,html,css,flask,web-development-server","A_Id":63326257,"CreationDate":"2020-08-09T11:56:00.000","Title":"Set Background image in CSS file using python flask framework render_template","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there a concise way to sort a list by first sorting numbers in ascending order and then sort the characters in descending order?\nHow would you sort the following:\n['2', '4', '1', '6', '7', '4', '2', 'K', 'A', 'Z', 'B', 'W']\nTo:\n['1', '2', '2', '4', '4', '6', '7', 'Z', 'W', 'K', 'B', 'A']","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":277,"Q_Id":63326175,"Users Score":0,"Answer":"You will have to implement your own comparison function and pass it as the key argument for the sorted function. What you are seeking is not a trivial comparison as you \"assign\" custom values to fields so you will have to let Python know how you value each one of them","Q_Score":4,"Tags":"python","A_Id":63326230,"CreationDate":"2020-08-09T12:09:00.000","Title":"How to write complex sort in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have around 200 functions developed in Python deployed in GCP as a Cloud Functions.\nI need to update one library in the for all this functions.\nHow can I update requirements.txt in all this functions massively in one single shot, without go one by one?\nIt's possible?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":66,"Q_Id":63326235,"Users Score":1,"Answer":"If you have source code of 200 cloud functions downloaded, you can write a bash\/python script to update requirements.txt of each of those.","Q_Score":0,"Tags":"python,google-cloud-platform,google-cloud-functions","A_Id":63328461,"CreationDate":"2020-08-09T12:15:00.000","Title":"how to update in bulk the requirements.txt file in Google Cloud Functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to connect Google Colab to a local runtime (Windows 10). As part of that I need to add the jupyter_http_over_ws extension to Jupyter Notebook. py -m pip install jupyter_http_over_ws worked as expected but when I tried to enable it with py -m notebook serverextension enable --py jupyter_http_over_ws, it errored.\n[E 13:43:13.400 NotebookApp] Support for specifying --pylab on the command line has been removed.\n[E 13:43:13.400 NotebookApp] Please use %pylab jupyter_http_over_ws or %matplotlib jupyter_http_over_ws in the notebook itself.\nDoes anyone know how I can get this to work?","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2680,"Q_Id":63326512,"Users Score":-1,"Answer":"Run jupyter-serverextension enable jupyter_http_over_ws","Q_Score":2,"Tags":"python,jupyter-notebook,windows-10,google-colaboratory","A_Id":68699356,"CreationDate":"2020-08-09T12:47:00.000","Title":"How to enable the jupyter_http_over_ws extension","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to connect Google Colab to a local runtime (Windows 10). As part of that I need to add the jupyter_http_over_ws extension to Jupyter Notebook. py -m pip install jupyter_http_over_ws worked as expected but when I tried to enable it with py -m notebook serverextension enable --py jupyter_http_over_ws, it errored.\n[E 13:43:13.400 NotebookApp] Support for specifying --pylab on the command line has been removed.\n[E 13:43:13.400 NotebookApp] Please use %pylab jupyter_http_over_ws or %matplotlib jupyter_http_over_ws in the notebook itself.\nDoes anyone know how I can get this to work?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2680,"Q_Id":63326512,"Users Score":0,"Answer":"Uninstall the extention and try pip3 install install jupyter_http_over_ws. It worked fine for me.","Q_Score":2,"Tags":"python,jupyter-notebook,windows-10,google-colaboratory","A_Id":63326856,"CreationDate":"2020-08-09T12:47:00.000","Title":"How to enable the jupyter_http_over_ws extension","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some math expressions in a list, like [\"2\", \"*\", \"2\"], [\"3\", \"+\", \"pi\"]. Now, I want the list elements that contain ONLY digits to be detected, and be converted to integers. Is there a way to do this?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":52,"Q_Id":63327921,"Users Score":-1,"Answer":"newList = [int(i) for i in oldList if i.isdigit()]","Q_Score":0,"Tags":"python,python-3.x,math","A_Id":63327940,"CreationDate":"2020-08-09T15:08:00.000","Title":"Take list element, check if it contains only digits, and if so, convert to int class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently I have a Scrapy Spider yielding various items on the parse method. Is there any way to get all items that have been yield, regardles of how many times the parse method has been called?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":404,"Q_Id":63329738,"Users Score":1,"Answer":"There are generally two ways to do this.\nFirstly, you can simply save the output in the JSON file using command scrapy crawl my_spider -o my_data.json. Secondly, you can write a pipeline and store the output in any DB to structure you want.","Q_Score":0,"Tags":"python,scrapy","A_Id":63339209,"CreationDate":"2020-08-09T18:12:00.000","Title":"Process all yield items in Scrapy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My output is cluttered with hundreds of lines that look like this:\n'python.exe' (Python): Loaded 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python37_86\\Lib\\struct.py'. Module was built without symbols. 'python.exe' (Python): Loaded 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python37_86\\Lib\\ctypes\\_endian.py'. Module was built without symbols. 'python.exe' (Python): Loaded 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python37_86\\Lib\\glob.py'. Module was built without symbols. 'python.exe' (Python): Loaded 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python37_86\\Lib\\fnmatch.py'. Module was built without symbols. 'python.exe' (Python): Loaded 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python37_86\\Lib\\posixpath.py'. Module was built without symbols.\nand it takes a minute or two to get to my code. It seems to be loading way more than necessary, including niche libraries that are only tangentially related to what I have imported (just pyqtgraph).\nI have tried various solutions, excluding symbols, and trying to specify modules. There doesn't seem to be a clear setting in Options > Debug to fix this. I should note that I believe this happened after enabling native debugging for a C++ extension I am using.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":63330863,"Users Score":0,"Answer":"As of now, there is currently no \"Just My Code\" debug option when debugging native code in PTVS (Python for Visual Studio).","Q_Score":1,"Tags":"python,visual-studio,load,interpreter","A_Id":65547203,"CreationDate":"2020-08-09T20:11:00.000","Title":"Why is Python loading extremely slowly in Visual Studio?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating a deep ensemble, and I need to keep track of which inference results came from which neural network. However, enabling versioning via the Kedro catalog only organizes my inference results by datetime, with each file having an identical name.\nWhat is the best practice for organizing results by model ID? For example, is it possible to customize the versioned folder names, or the versioned file? E.g. data\/07_model_output\/model_predictions.json\/2020-08-09T20.55.57.237Z-Model-04\/model_predictions.json or ...\/2020-08-09T20.55.57.237Z\/model_predictions-Model-04.json","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":63331325,"Users Score":0,"Answer":"Versioning is intended for keeping track of the versions of a single dataset, not to disambiguate between multiple datasets.\nIf I understand your question correctly, I think you can use multiple output datasets to keep track of your predictions, i.e. nn1_predictions.json, nn2_predictions.json, etc.","Q_Score":0,"Tags":"python,machine-learning,devops,inference,kedro","A_Id":63338094,"CreationDate":"2020-08-09T21:06:00.000","Title":"How to organize inference results by model ID that produced it?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Recently I trained my model on google colab and saved weights in google drive automatically by ModelCheckPoint.\nWhen I use these saved weights on google colab the prediction performs great, but when I download the weights and run them locally on my laptop, the prediction is extemely terrible.\nThe GPU of my laptop is GeForce RTX 1060 with Max-Q design 12GB. Could anyone tell me what leads to the different performance between my laptop and google colab?\nBy the way, I tried to save the whole model and then load it, the saving process runs smoothly but when I load model, there is a ValueError says \"There is a cyclic-dependency between functions\", still have no idea how to solve it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":246,"Q_Id":63332507,"Users Score":0,"Answer":"I solved this problem by changing tensorflow-gpu==2.2.0 to tensorflow==2.3.0, which is extactly the same as the version in google colab.","Q_Score":0,"Tags":"python,tensorflow,google-colaboratory","A_Id":63332722,"CreationDate":"2020-08-10T00:02:00.000","Title":"Why model weights trained on google colab cannot perform locally as in colab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to build a react app that can render a JSX file that is added\/modified after npm build.\nMore details below\nI have a single page react app with various data table and chart components, which fetch data from flask backend. All those components are put together in a single JSX file (result.jsx).\nAfter \"npm build\" I might need to change the data contents or layout of the page, (e.g adding additional tables\/charts to the page). By modifying the flask backend, data contents can be updated easily but as for the layout I currently need to modify the result.jsx and npm build again.\nIs there a way to avoid doing npm build whenever result.jsx file is changed?\nI'd like to keep result.jsx outside of the npm build to keep it flexible, and have the react frontend to simply mirror this resuit.jsx","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":63332592,"Users Score":0,"Answer":"In your build output, you don't have a running process that picks up JS files in a directory, it's all concatenated together into one file. JSX is compiled to JS through the build tools and isn't understood by the browser without that step anyway.\nIf you want components that respond to data, you'll have to code them to do that. You may be able to do something with React Router and dynamic routing, but that'll still point to coded component files.","Q_Score":0,"Tags":"javascript,python,reactjs,flask","A_Id":63334695,"CreationDate":"2020-08-10T00:15:00.000","Title":"ReactJS\/Flask app to render a given JSX file that is added after \"npm build\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The code\ntext = pic.image_to_string(image)\nwebbrowser.open('https:\/\/www.google.com\/search?q='(text))\ni need to place the variable test in url so i can look up every image text scanned","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14,"Q_Id":63332928,"Users Score":0,"Answer":"Using f-strings, for Python >= 3.6\nwebbrowser.open(f'https:\/\/www.google.com\/search?q={text}')\nUsing format\nwebbrowser.open('https:\/\/www.google.com\/search?q={}'.format(text))","Q_Score":0,"Tags":"python,python-3.x","A_Id":63333022,"CreationDate":"2020-08-10T01:18:00.000","Title":"need help to place a verable within a python webbrowser.open","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I'm done with automating, the chrome webdriver stays running in the background, is there anyway to automatically close it without the need of doing it via task manager?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":63333628,"Users Score":0,"Answer":"driver.close() => It will shut the focused browser window.\ndriver.quit() => It will shut all opened browser window and terminates the WebDriver session.","Q_Score":1,"Tags":"python,google-chrome,background,webdriver,taskmanager","A_Id":63333644,"CreationDate":"2020-08-10T03:11:00.000","Title":"Chrome webdriver - Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"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'm writing Rasa source code for my chatbot, using Python 3.7.7, pip 20.1.1 and conda 4.5.12.\nI use the command: conda install tensorflow to install this framework, version 2.1.0.\nHowever when trying to execute rasa train to train my chatbot, I came up against an error with process of importing tensorflow.\nThe Error: ImportError: DLL load failed: The specified module could not be found.\nI still find the tensorflow folder, so what I need to do to fix this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":63335258,"Users Score":0,"Answer":"You can Use pip install tensorflow","Q_Score":1,"Tags":"python,tensorflow,rasa","A_Id":63335375,"CreationDate":"2020-08-10T06:37:00.000","Title":"Tensorflow: ImportError: DLL load failed: The specified module could not be found","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Few year ago I created a proxy script with python and Flask. It only run up app and bypass a request to the direction and added \"response.headers['Access-Control-Allow-Origin'] = '*'\" to avoid CORS calls between server.\nWhen I installed ubuntu 18.04, the only way to install python environment with \"flask\" and \"request\" libraries was to create a \"venv\" environment. I can't install directly in ubuntu with pip. So, I did it and I create my virtual environment for flask.\nMy problem is after all already succesfull, I run venv \"source venv\/bin\/activate\" and then launch my scrpipt \"python3 server.py\". Everything went well, but when I close the ssh connection \"venv\" is down also. I tried run with with \"python3 server.py &\" but the same.\nHow can I make \"venv\" virtual environment permanent, not to go down after exit the ssh connection?\nThanks! :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":63336243,"Users Score":0,"Answer":"SOLVED!\nI was installing everything for python2. I installed sudo apt install python3-pip, and then install all needed libraries with python3 and I could run up without venv environment","Q_Score":0,"Tags":"python,python-venv","A_Id":63336332,"CreationDate":"2020-08-10T07:57:00.000","Title":"Make python3 venv permanent after ssh termina close","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"first of all apologies for the vague question, I thought I would clarify it in the body.\nSo basically, I am looking to design a website for my society, as a person with a fair amount of software development know how(or at-least I would like to think so), how can I go about designing a web application that can be edited, from the front end(I know this breaks alot of MVC principles), I want to make it so, that an administrator can login to the administrator account on the web app, and upload\/delete a new blog and make aesthetic changes to the application. Is there any way to build\/design a web applications this way.\nSo basically the program flow would look something like this\n\nAdministrators decides to update the blog\nAdministrator logins into the admin account\nEdits the blog on the website\nSaves the blog, the edited blog now appears on the front end, visible to all visitors.\n\nSecondly, if the first option is not recommended, what frameworks can I use(preferably python) so that I can ensure the website is as maintainable as possible(after I finish university, I will not be maintaining it ).\nWould a common framework such as Django, Flask suffice?\nThis must all be completed within 4-5 weeks, in a three developer team.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":63336366,"Users Score":0,"Answer":"I would go with Flask, you can do almost anything you want with it.\nWhen you say \"edit blog\" you mean \"edit posts of the blog\" like postbody-text, photos, etc?\nThese tasks can be done easily with Flask.\nYou can do the same with Django too, but Django is more heavy and is more suitable for big websites\nIn practice, you will create some routes in the Flask app with the functionality you want (edit posts, replace photos, etc) that will be accessed by the admin account only","Q_Score":0,"Tags":"python,flask,web-applications,architecture","A_Id":63340107,"CreationDate":"2020-08-10T08:07:00.000","Title":"Designing a maintainable\/editable website for a society","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I defined\na=b=c=10 in Shell\nand just typed\na,b,c and got (10, 10, 10).\nBut I when I type\nprint(a,b,c), it returns 10 10 10.\nWhat is the difference between these two?\nI know the former is a tuple and the latter is int.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":85,"Q_Id":63336469,"Users Score":1,"Answer":"In the shell, when you use a,b,c it is actually representing a tuple, and the repr() of that is printed in the shell, but when run as an actual python script it will not be printed. It is separated by a comma because it is tuple, and this is how it\u2019s represented. You could even try print((a,b,c)) and since it\u2019s a tuple, it will print (10,10,10) as is the return value of str().\nOn the other hand print() accepts any number of arguments, in this case you used print(a,b,c) these arguments will be printed (calling the str() method), separated by a space, unless the sep parameter is specified to separate them using another character, a space is the default. Therefore, if variables a, b and c contains 10, the print function will print 10 10 10, which is separated by a space.","Q_Score":0,"Tags":"python,python-3.x,integer,tuples","A_Id":63336695,"CreationDate":"2020-08-10T08:14:00.000","Title":"What is the difference between (10, 10, 10) and 10 10 10 in Shell?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"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'm currently developing a REST API with DRF for a web application. So I decided to use OAuth2 authentication system. After a little research, I understood that OAuth mostly used for authenticating third-party apps and what I want is simply authenticate the user to my website, not with Facebook or Google accounts. So token authentication seems to be the most secure way to do it and with OAuth is being too confusing and not suitable to me which authentication method should I follow? Is django's built-in TokenAuthentication secure to make a web-app? Should I use OpenId connect?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":222,"Q_Id":63341192,"Users Score":0,"Answer":"OAuth2 is a protocol to allow your website to access some API on behalf of the user whose data your trying to access (delegated authorization).\nIf you just want to know who your user is on your site (authentication), OpenID Connect is a protocol built on top of OAuth2 that gives you that information. It will give you a JWT id_token that has claims about the authenticated user.","Q_Score":1,"Tags":"python,authentication,oauth-2.0","A_Id":63345793,"CreationDate":"2020-08-10T13:27:00.000","Title":"Should I use OAuth2 Authentication?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'd like to make a function which converts Google Drive videos into VLC streamable links (e.g. vlc:\/\/https:\/\/WEBSITE.com\/FILE_ID.mkv.\nI've tried methods which were shared on stack overflow, such as modifying the Google Drive link to:\nhttps:\/\/drive.google.com\/uc?export=download&id=FILE_ID\nAll the methods I've tried seem to not work anymore. Any ideas?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1963,"Q_Id":63341586,"Users Score":-1,"Answer":"Just make the file public and copy your ID.\nYou can find it here: \/file\/d\/YOUR ID\/view?usp=sharing.\nCopy your ID and paste it in this:\ndrive.google.com\/uc?export=view&id=YOUR ID","Q_Score":4,"Tags":"python,google-drive-api","A_Id":70487792,"CreationDate":"2020-08-10T13:53:00.000","Title":"How do I get the direct link for a Google Drive video (Google Drive API v3)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running Jupyter Notebook 6.1.0 and Python 3.8.5 on Windows 10. I create a simple Python file in Notebook and attempt to Download it as a .py file from the File Menu. Down in the lower left corner of the browser window, it seems to indicate it has saved it as a .py file. But when I click there on Open File, a window opens and immediately closes. If I look at the directory where the .py file should be saved, there is a not a .py file with the expected name. There is only an .ipynb file with that name.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":258,"Q_Id":63341973,"Users Score":0,"Answer":"a python file is saved as a text file in the directory. And the opening and closing is happening because it's  the given output for that.\nIn Python 3, add the following to the end of your code:\ninput('Press ENTER to exit')\nand open the file in  a pycharm or your IDE edition.","Q_Score":0,"Tags":"python,download","A_Id":63342170,"CreationDate":"2020-08-10T14:15:00.000","Title":"Cannot download .py file from Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using pipenv as the virtual environment in a Django project. I installed the Django third-party package django-allauth-2fa via pipenv install django-allauth-2fa==0.8.\nIn the package's docs regarding its installation it says: note that this will install Django, django-allauth, django-otp, qrcode and all of their requirements.\nAfter successfull installation I wanted to check if this is in fact the case, however my Pipfile did not show any new installation besides django-allauth-2fa. I double checked with  pip freeze from within the virtual environment shell and got a list back, in which all the package's dependencies were indeed listed (qrcode, django-otp, etc.)\nMy question is hence: Do I have a misunderstanding about how the Pipfile works? I assumed that the file shows all the packages that are installed in my virtual environment. Or are only those shown that were installed via the pipenv install <package> command but not those that were installed alongside packages installed via pipenv install <package>?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":768,"Q_Id":63342405,"Users Score":2,"Answer":"pip freeze shows all of the installed packaged. While pipenv shows only the explicitely declared (to be installed) packages. Maybe a better explanation: pipenv shows the packages you want to install, while pip freeze shows every package that need to be installed for your package to work.","Q_Score":0,"Tags":"python,django,pipenv,pipenv-install","A_Id":63342465,"CreationDate":"2020-08-10T14:39:00.000","Title":"Pipfile not showing all installed packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I cannot install PyTorch on python 3.7. This error occurs for others but the suggested fixes did not work. I have tried instaling wheel, and importing tools but neither work.\nGot error: ModuleNotFoundError: No module named 'tools.nnwrap'\nran command pip install --pre torch torchvision -f https:\/\/download.pytorch.org\/whl\/nightly\/cu102\/torch_nightly.html\nfull output: Looking in links: https:\/\/download.pytorch.org\/whl\/nightly\/cu102\/torch_nightly.html Collecting torch Using cached torch-0.1.2.post2.tar.gz (128 kB) Collecting torchvision Using cached torchvision-0.2.2.post3-py2.py3-none-any.whl (64 kB) Requirement already satisfied: pyyaml in c:\\users\\lv7682\\documents\\repos\\security_patch\\spms\\webapp\\securitypatchmanagementsystem\\venv\\venv\\lib\\site-packages (from torch) (5.3.1) Collecting pillow>=4.1.1 Using cached Pillow-7.2.0-cp37-cp37m-win32.whl (1.8 MB) Collecting numpy Using cached numpy-1.19.1-cp37-cp37m-win32.whl (10.9 MB) Collecting six Using cached six-1.15.0-py2.py3-none-any.whl (10 kB) Using legacy 'setup.py install' for torch, since package 'wheel' is not installed. Installing collected packages: torch, pillow, numpy, six, torchvision Running setup.py install for torch ... error ERROR: Command errored out with exit status 1: command: 'c:\\users\\lv7682\\documents\\repos\\security_patch\\spms\\webapp\\securitypatchmanagementsystem\\venv\\venv\\scripts\\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[ 0] = '\"'\"'C:\\\\Users\\\\LV7682\\\\AppData\\\\Local\\\\Temp\\\\pip-install-4b80gt33\\\\torch\\\\setup.py'\"'\"'; __file__='\"'\"'C:\\\\Users\\\\LV7682\\\\AppData\\\\Local\\\\Temp\\\\pip-install-4b80gt33\\\\torch\\\\setup .py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))' install --reco rd 'C:\\Users\\LV7682\\AppData\\Local\\Temp\\pip-record-z5_fy7cc\\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\\users\\lv7682\\documents\\repos\\security _patch\\spms\\webapp\\securitypatchmanagementsystem\\venv\\venv\\include\\site\\python3.7\\torch' cwd: C:\\Users\\LV7682\\AppData\\Local\\Temp\\pip-install-4b80gt33\\torch\\ Complete output (23 lines): running install running build_deps Traceback (most recent call last): File \"<string>\", line 1, in <module> File \"C:\\Users\\LV7682\\AppData\\Local\\Temp\\pip-install-4b80gt33\\torch\\setup.py\", line 265, in <module> description=\"Tensors and Dynamic neural networks in Python with strong GPU acceleration\", File \"c:\\users\\lv7682\\documents\\repos\\security_patch\\spms\\webapp\\securitypatchmanagementsystem\\venv\\venv\\lib\\site-packages\\setuptools\\__init__.py\", line 163, in setup return distutils.core.setup(**attrs) File \"C:\\Users\\LV7682\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\distutils\\core.py\", line 148, in setup dist.run_commands() File \"C:\\Users\\LV7682\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\distutils\\dist.py\", line 966, in run_commands self.run_command(cmd) File \"C:\\Users\\LV7682\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\distutils\\dist.py\", line 985, in run_command cmd_obj.run() File \"C:\\Users\\LV7682\\AppData\\Local\\Temp\\pip-install-4b80gt33\\torch\\setup.py\", line 99, in run self.run_command('build_deps') File \"C:\\Users\\LV7682\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\distutils\\cmd.py\", line 313, in run_command self.distribution.run_command(command) File \"C:\\Users\\LV7682\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\distutils\\dist.py\", line 985, in run_command cmd_obj.run() File \"C:\\Users\\LV7682\\AppData\\Local\\Temp\\pip-install-4b80gt33\\torch\\setup.py\", line 51, in run from tools.nnwrap import generate_wrappers as generate_nn_wrappers ModuleNotFoundError: No module named 'tools.nnwrap' ---------------------------------------- ERROR: Command errored out with exit status 1: 'c:\\users\\lv7682\\documents\\repos\\security_patch\\spms\\webapp\\securitypatchmanagementsystem\\venv\\venv\\scripts\\python.exe' -u -c 'import sys , setuptools, tokenize; sys.argv[0] = '\"'\"'C:\\\\Users\\\\LV7682\\\\AppData\\\\Local\\\\Temp\\\\pip-install-4b80gt33\\\\torch\\\\setup.py'\"'\"'; __file__='\"'\"'C:\\\\Users\\\\LV7682\\\\AppData\\\\Local\\\\Temp\\\\p ip-install-4b80gt33\\\\torch\\\\setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))' install --record 'C:\\Users\\LV7682\\AppData\\Local\\Temp\\pip-record-z5_fy7cc\\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\\user s\\lv7682\\documents\\repos\\security_patch\\spms\\webapp\\securitypatchmanagementsystem\\venv\\venv\\include\\site\\python3.7\\torch' Check the logs for full command output.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2364,"Q_Id":63345212,"Users Score":1,"Answer":"Fixed: needed to use python 64-bit not 32-bit","Q_Score":1,"Tags":"python,python-3.x,installation,pip,pytorch","A_Id":63345384,"CreationDate":"2020-08-10T17:34:00.000","Title":"Cant install pytorch - ModuleNotFoundError: No module named 'tools.nnwrap'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install cython using\nPy setup.py install\nsource. But the pgen executable is not found","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":63345551,"Users Score":0,"Answer":"Solved using\npip install Cython-0.29.21.tar.gz --install-option=\"--no-cython-compile\"","Q_Score":0,"Tags":"python-3.x","A_Id":63357994,"CreationDate":"2020-08-10T17:57:00.000","Title":"Pgen module not found during cython installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've been working with some face detection in OpenCV. I have a couple projects I've done - one does face detection which uses a pre-built model. Some others do different things where I collect my own images and train my own models. When I do the latter, it's generally with much smaller datasets that what you'd use for face training.\nOn my face recognizer - many of the common faces I work with do not get detected properly (due to odd properties like masks, hats, goggles, glasses, etc). So I want to re-train my own model - but grabbing the gigantic \"stock\" datasets, adding my images to it may take a VERY long time.\nSo the question is: is there a way to start with an existing model (XML file) and run the trainer in a way that would just add my images to it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":86,"Q_Id":63347621,"Users Score":0,"Answer":"This is called \"Transfer Learning\". Tenserflow (Keras) has a lot of support for this. It basically consists of taking a pre-existing model with pre-existing weights, \"freezing\" weights on certain layers, adding new layers in or below existing ones, and then retraining only the un-frozen layers.\nit can't be used to readily just \"continue\" learning, but can be used to add additional things into the training -  for newer aspects (like potentially, adding masked people to an already trained model of unmasked people, as in my original question)","Q_Score":0,"Tags":"opencv,machine-learning,computer-vision,face-detection,opencv-python","A_Id":67290842,"CreationDate":"2020-08-10T20:32:00.000","Title":"\"Incremental\" face training in OpenCV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to return various sums of a list of integers? Pythonic or otherwise.\nFor e.g. various sum totals from [1, 2, 3, 4] would produce 1+2=3, 1+3=4, 1+4=5, 2+3=5, 2+4=6, 3+4=7. Integers to be summed could by default be stuck to two integers only or more I guess.\nCan't seem to wrap my head around how to tackle this and can't seem to find an example or explanation on the internet as they all lead to \"Sum even\/odd numbers in list\" and other different problems.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":63348012,"Users Score":0,"Answer":"is this what you are looking for ?\nA=[1,2,3,4] for i in A: for j in A: if i!=j: print(i+j)","Q_Score":1,"Tags":"python,list,sum","A_Id":63348226,"CreationDate":"2020-08-10T21:05:00.000","Title":"Return various sum totals of integer list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Could someone help me?\nHow can I get the closest point on a surface form a locator in Maya using python OpenMaya?\nI was trying to use constraints but it has some snap that is not good for me.\nI would like to get the closest point, not the closest vertex. I want to get the nearest position from a locator even if it is at the center of a polygon. :)\nthanks a lot!!!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1478,"Q_Id":63348283,"Users Score":0,"Answer":"I suppose the simplest way would be to use a \"closestPointOnSurface\" node. Connect your surface to the node and the position of your locator to the \"In Position\", then you can get the result from the node. But that would be without OpenMaya. If you want to use OpenMaya, you could try to use a ray intersect on the mesh.","Q_Score":0,"Tags":"python,maya","A_Id":63354397,"CreationDate":"2020-08-10T21:29:00.000","Title":"Get the closest point on a surface - Maya - Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the following problem:\nI have a folder with files.\nI want to write into those files their respective file path + filename (home\/text.txt) .\nHow can I achieve this in python?\nThanks in advance for your time and help!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1440,"Q_Id":63349411,"Users Score":0,"Answer":"with open('FOLDER_NAME\/FILE_NAME','w+') as f:\nAssuming the python file is in the same path as the folder.\nYou can use:\n..\nto move back a directory.","Q_Score":1,"Tags":"python,file,path","A_Id":63349450,"CreationDate":"2020-08-10T23:27:00.000","Title":"Python Write File Path into Files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am loading 10-15MB numpy arrays saved in .npy format in a loop, and each load takes about 1.5s in Google Colab. Is that an acceptable speed? Its by far the slowest part of my loop. Also, the second time I run the loop its faster (presumably because the loaded files were saved to RAM?) but then eventually it slows back down again (runs out of RAM?).\nHere is the code I am using to load the arrays:\ndata = np.load('\/content\/drive\/My Drive\/Share\/Daily Data\/Processed\/' + str(fileName))\nAny advice to speed this up would be greatly appreciated, right now I have load 1500 arrays per loop so each loop takes around 25 minutes. The arrays must be loaded separately (please don't suggest I append them all and load it all at once, I can't).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":441,"Q_Id":63350586,"Users Score":0,"Answer":"As an approximate test,\nI can load a .npy file with 1_000_000 elements (int64) in 6 milliseconds (from my local disk).\n\nAre your files (\/content\/drive\/...) in a Google data center, or on your own storage?\nIn the latter case, can you copy to files, so they're at Google, along with the compute?","Q_Score":0,"Tags":"python,numpy,load","A_Id":63387495,"CreationDate":"2020-08-11T02:19:00.000","Title":"Using Numpy.Load - is this the fastest method? It seems slow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have text \"Number 2169\/B\/PK\/Pjk\/2019\", \nI want to match the following characters or strings \/Pjk\/ that begins and ends with a forward slash and whose intervening characters are not forward slashes from that text.\n\n\nI already use code \n\nre.search(r\"(\\b\/).*(\/\\b)\", text)\n\nwhich are \\b\/ for search the character start that with \/, \/\\b for search the character that end with \/, and .* as AND operator to combine those both conditions. \n\nBut I still don't know how to add the condition to limit length of characters at least 5 characters {5,} from that code above. \n\nAnyone have an idea?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":63351751,"Users Score":2,"Answer":"To get 3 chars between \/ \/ you can do r\"(\\b\/).{3}(\/\\b)\".\nSimpler can be r\"\/[^\/]{3}\/\" and it will not get \/ between \/ \/\nFor 3 or more chars you can add , (comma) r\"\/[^\/]{3,}\/\"","Q_Score":0,"Tags":"python,regex","A_Id":63353049,"CreationDate":"2020-08-11T04:58:00.000","Title":"Combine AND operator and limit length of characters in Regex Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use spyder(ide) for writing python programs.\nI wrote a program on 'conway checkers' using tkinter(gui library).\nI then compiled this program using pyinstaller into a '.exe' file. However, this '.exe' file does not run on any other computer except mine.\nWhat else is required to make it run on all windows just like any other application does?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":63353686,"Users Score":0,"Answer":"Your question is a bit vague.\nHowever, your problem is probably related to missing libraries on other people's computers.\nYou can either:\n\nUse a \"requirements.txt\" file, in which you specify what libraries is needed to run your program (tkinter in your case it would seem) and explain how to install it using pip in a Readme\nExport an environment and pack it in the .exe file\n\nTo troubleshoot your issue, run your exe file in a windows command prompt, you will get hints of what your issue is.","Q_Score":0,"Tags":"python,windows,pyinstaller","A_Id":63354153,"CreationDate":"2020-08-11T07:43:00.000","Title":"How can I make a program so that it runs on all window versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just Started using Google Drive API using python to download File. I'm seeing it requires authentication for the first time and generates a token.pickle file. From next time onwards we can use this token file for API call.\nNote : The file token.pickle stores the user's access and refresh tokens.\nWhat I needed to know is when this token file will expire ? If it expires then how to extend it's validity ?\nI've gone through many google documentations but couldn't find anything clear regarding this.\nIf anyone can suggest me any info on this, that will be most welcomed.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2220,"Q_Id":63354260,"Users Score":0,"Answer":"If your app's publishing status is in 'Testing', then the token will last for 2 weeks only.\nIf its publishing status is 'in Production' then the token has no expiry. However if any sensitive scopes are there and not verified in your app, then the number of users also limited.\nThese are all tested but seems no official documentation is available yet.","Q_Score":3,"Tags":"python,google-api,google-drive-api,google-oauth","A_Id":68140154,"CreationDate":"2020-08-11T08:21:00.000","Title":"When does Refresh Token expires for Google Drive API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"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":"I was learning when I found using modulo operator on a negative operator gives different output\nI was printing print(-28%10) which gave output 2 and print(28%-10) gave output as -2 what is the logic behind it as print(28%10) gave 8 as a result which is actual remainder. Can someone please help me understand this ??","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":60,"Q_Id":63355251,"Users Score":1,"Answer":"The % operator is in fact not the modulo operator but the remainder operator in python. The docs are not very clear about this but it does not follow the normal modulo logic for negative values instead simply getting the remainder.","Q_Score":0,"Tags":"python,operator-keyword,modulo,modulus","A_Id":63355455,"CreationDate":"2020-08-11T09:19:00.000","Title":"Using modulo operator using negative operand","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to create a virtual environment to let me install NumPy, SciPy and Matplotlib\nI write this: python3.8 -m venv work3.8\nand the result was: Error: Command '['\/home\/mohammed\/work3.8\/bin\/python3.8', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2028,"Q_Id":63355881,"Users Score":0,"Answer":"Please try: python3 -m venv [your directory]\nAfter that, if you want to use your new virtual enviroment type: source [your directory]\/bin\/activate\nThen if you want to leave your venv type: deactivate\n(checked on Debian)\nI hope that this helps you,\nKind regards","Q_Score":0,"Tags":"python,linux,numpy,linux-mint","A_Id":63356209,"CreationDate":"2020-08-11T10:02:00.000","Title":"python returned non-zero exit status 1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have had this problem for ages now with many different projects now, so I really want to find out how to fix it. For example, in one of my projects, I created a level editor for a game. The level editor had the option to save and load different levels from a file using tkinter.filedialog.\nNow after I select the file, the game will still work, but the 'X' close button doesn't work anymore, and I can't move the window.\nThe game itself works as usual, and I can still interact with everything inside of the window, but I can't move or close the window.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":87,"Q_Id":63356374,"Users Score":1,"Answer":"Ok. I figured this one out. The problem went away when I called the tkinter functions from a key press, not a mouse press.","Q_Score":3,"Tags":"python,python-3.x,tkinter,pygame","A_Id":63358523,"CreationDate":"2020-08-11T10:34:00.000","Title":"Pygame window wont move or close after using tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Matplotlib created a temporary config\/cache directory at \/var\/www\/.config\/matplotlib because the default path (\/tmp\/matplotlib-b33qbx_v) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.\nThis is the message I'm getting in error.log file and 504 Gateway Time out error on browser .\nSomeone please help to resolve this issue.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11684,"Q_Id":63356808,"Users Score":0,"Answer":"import os\nos.environ['MPLCONFIGDIR'] = os.getcwd() + \"\/configs\/\"\nbefore\nimport matplotlib\nworks for me","Q_Score":5,"Tags":"python-3.x,django,matplotlib,django-wsgi","A_Id":68589747,"CreationDate":"2020-08-11T11:00:00.000","Title":"Matplotlib created a temporary config\/cache directory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Energy Meter connected through RTU and i am able to get holding registers data through simple RTU Code.\nNow i want to make Convert this RTU to TCP through Forwarder. I want to send data to TCP which forwards the command to RTU and fetches data of RTU connected device for me.\nI have implement the Forwarder code just dont know how to fetch the holding register of RTU through it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":63356967,"Users Score":0,"Answer":"If you are working with real device, make sure you are explicitly initialising the remote slave context with the unit Id.\ncontext = RemoteSlaveContext(serial_client, unit=<unit-id-of-slave>)\nThe default is 0 which works fine with simulated slaves but would be considered as a broadcast address with the real devices generally and no response would be returned back.","Q_Score":0,"Tags":"python,python-3.x,pymodbus,pymodbus3","A_Id":63386969,"CreationDate":"2020-08-11T11:12:00.000","Title":"Read RTU Pymodbus data through TCP\/Forwarder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I save a user's input and ask them if they want to use it again when restarting the program, so they don't have to enter the same thing every time they close the program?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":63358721,"Users Score":0,"Answer":"You should store the data in some DB or JSON file, there is no way to save input data stored in a variable after closing the program.","Q_Score":2,"Tags":"python,python-3.x,authentication,input,passwords","A_Id":63358755,"CreationDate":"2020-08-11T13:01:00.000","Title":"Save input and ask to use it again when restarting program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say I have a string only containing \u201cA\u201d, \u201cB\u201d and \u201cC\u201d.\nFor example, \u201cABBCAABBCABBBCBBA\u201d.\nHow do I find the longest substring such that the substring does not contain \u201cA\u201d?\nI know that itertools.groupby() can be used to find longest consecutive sequence of an element, but how do I adapt this to find the longest sequence such that an element isn\u2019t present?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":53,"Q_Id":63360122,"Users Score":1,"Answer":"The most efficient method would be a single pass, stepping through each element and adding it to the \"current\" substring if it isn't an \"A\" and then just keeping track of the longest substring found.\nAlternatively, you could just .split(\"A\") and get the longest substring in the resulting list.","Q_Score":1,"Tags":"python,python-3.x,string,list","A_Id":63360337,"CreationDate":"2020-08-11T14:19:00.000","Title":"Longest consecutive sequence of an element not appearing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say I have a string only containing \u201cA\u201d, \u201cB\u201d and \u201cC\u201d.\nFor example, \u201cABBCAABBCABBBCBBA\u201d.\nHow do I find the longest substring such that the substring does not contain \u201cA\u201d?\nI know that itertools.groupby() can be used to find longest consecutive sequence of an element, but how do I adapt this to find the longest sequence such that an element isn\u2019t present?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":53,"Q_Id":63360122,"Users Score":1,"Answer":"You can keep using your itertools.groupby solution, by passing it a key function that checks for equality with \"A\".","Q_Score":1,"Tags":"python,python-3.x,string,list","A_Id":63360221,"CreationDate":"2020-08-11T14:19:00.000","Title":"Longest consecutive sequence of an element not appearing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My file location is detecting the \\r in \\reach as a carriage return.\nThere is nothing I could find online about the topic. I need it to list the file location as only a string.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":39,"Q_Id":63360238,"Users Score":1,"Answer":"It looks like you might be using windows as your os which uses '\\' as separators.\nYou could try defining your file path in raw string. Eg.\nf = open(r'dir1\\dir2\\reach')","Q_Score":1,"Tags":"python","A_Id":63360349,"CreationDate":"2020-08-11T14:24:00.000","Title":"I have a file location stored in a reach file. Like \\reach. It thinks it is a carriage return","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My file location is detecting the \\r in \\reach as a carriage return.\nThere is nothing I could find online about the topic. I need it to list the file location as only a string.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":39,"Q_Id":63360238,"Users Score":1,"Answer":"You need to escape slash with another slash in the string: \\\\reach","Q_Score":1,"Tags":"python","A_Id":63360460,"CreationDate":"2020-08-11T14:24:00.000","Title":"I have a file location stored in a reach file. Like \\reach. It thinks it is a carriage return","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For example, How can I know whether there is an argument like args.manual_selection in args (args = parser.parse_args())","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":63360362,"Users Score":2,"Answer":"One way to do it would be just to convert args to a dictionary\nargs = vars(parser.parse_args())\nThen you can check for the existence of the key, e.g.\nargs.get(\"manual_selection\", False)\nIf that returns False, the key does not exist. Of course the default returned for non-existence must not overlap with valid user input.","Q_Score":1,"Tags":"python,argparse,args","A_Id":63360401,"CreationDate":"2020-08-11T14:30:00.000","Title":"How to check if a particular argument is supported in parser.parse_args()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"Using scipy.sparse is very efficient both in storing and doing computations on sparse matrices. What if it is used for non-sparse matrices? More specifically, It is clear that we cannot exploit the sparsity benefits of that data structure, however, is it worse (in storage and computation complexity) than using an ordinary numpy array?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":63361442,"Users Score":1,"Answer":"Yes, it is worse in both storage and performance, let alone cognitive load for whoever reads your code.","Q_Score":0,"Tags":"python,arrays,python-3.x,numpy,scipy","A_Id":63361873,"CreationDate":"2020-08-11T15:29:00.000","Title":"Is it good to use scipy sparse data structure for non-sparse matrices?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Django and channels (for WebSockets).\nEarlier, when I was developing, I created some objects in memory when a user does a request, and then websockets can use these objects.\nAfter, I run the production server with ssl, and for testing, I had to run apps separately: python manage.py startsslserver and daphne ... project.asgi:application.\nAnd now sockets do not have access to objects, which are initialized in django server.\nAnybody knows, how I can solve this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":63361669,"Users Score":0,"Answer":"More information is needed for a clear answer. django websocket problems are usually associated with other causes such as nginx.conf or daphne.service etc..","Q_Score":0,"Tags":"python,django,shared-memory,wss,daphne","A_Id":63370149,"CreationDate":"2020-08-11T15:41:00.000","Title":"Daphne. Access to Django defined objects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have the output from using .dump() on a Text widget which uses formatting and I would like to use this to load it on another text widget. Is this possible or do I have to parse it back manually?\nExample .dump() output: [('mark', 'current', '1.0'), ('text', 'Sample text', '1.0'), ('mark', 'tk::anchor1', '1.11'), ('mark', 'insert', '1.11'), ('text', '\\n', '1.11')]","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":55,"Q_Id":63362081,"Users Score":1,"Answer":"There is no built-in function to load that data in another text widget. You will have to write the code to parse it and reconstruct the data.","Q_Score":0,"Tags":"python-3.x,tkinter","A_Id":63362320,"CreationDate":"2020-08-11T16:05:00.000","Title":"Is there a way to store and load formatted text from a text widget in Tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"while doing many programs in python always i using write a block of code to split a string containing of numbers separated by space into list of integers\nex:\nif we enter 1 2 3 4 5, we should get [1, 2, 3, 4, 5]\nis there any possibility to write the code in a single line\nex: lst=input().split()\nif we use this i am getting list of strings in it.I need integers in it","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":63363633,"Users Score":0,"Answer":"You are looking for some list comprehension.\nlst=[int(x) for x in input().split()]","Q_Score":0,"Tags":"python-3.x,arraylist","A_Id":63363683,"CreationDate":"2020-08-11T17:43:00.000","Title":"How to split a string containing of numbers separated by space into list of integers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install pip install brute but I got an error message:\n\nERROR: Could not install packages due to an EnvironmentError: Failed\nto parse: https:\/\/username:password@proxyserver:proxyport\n\nDoes anyone know about this? Could you help me?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":58,"Q_Id":63368759,"Users Score":1,"Answer":"You could try pip3 install brute","Q_Score":0,"Tags":"python,python-3.x,python-2.7,python-requests","A_Id":64455923,"CreationDate":"2020-08-12T02:11:00.000","Title":"Error when trying to install Python brute","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm performing hyperparameter tuning with grid search and I realized that I was getting overfitting... I tried a lot of ways to reduce it, changing the \"gamma\", \"subsample\", \"max_depth\" parameters to reduce it, but I was still overfitting...\nThen, I increased the \"reg_alpha\" parameters value to > 30....and them my model reduced overfitting drastically. I know that this parameter refers to L1 regularization term on weights, and maybe that's why solved my problem.\nI just want to know if it has any problem using high values for reg_alpha like this?\nI would appreciate your help :D","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3721,"Q_Id":63368841,"Users Score":1,"Answer":"reg_alpha penalizes the features which increase cost function. Meaning it finds the features that doesn't increase accuracy. But this makes prediction line smoother.\nOn some problems I also increase reg_alpha > 30 because it reduces both overfitting and test error.\nBut if it is a regression problem it's prediction will be close to mean on test set and it will maybe not catch anomalies good.\nSo i may say you can increase it as long as your test accuracy doesn't begin to fall down.\nLastly when increasing reg_alpha , keeping max_depth small might be a good practise.","Q_Score":3,"Tags":"python,xgboost","A_Id":65459006,"CreationDate":"2020-08-12T02:22:00.000","Title":"\"reg_alpha\" parameter in XGBoost regressor. Is it bad to use high values?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If you use a hashmap (or dict in python) and add a new key \/increment key count for every letter found O(n) or O(1)? I ask because the max size of the hashmap will be for 26 keys\nthe alternative solution is to initialize an array of zeroes of length 26 and increment the index corresponding to a letter if it occurs (increment arr[0] if a exists for example).  from my understanding, such a solution would require O(1) extra space.\nI guess the overarching question is if an input can only have x unique character input , then is the extra space considered O(1) ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":184,"Q_Id":63369213,"Users Score":1,"Answer":"The N in O(N) is the number of elements in your array. Since your space requirement will be the same whether you pass in 100 elements or 100,000,000, the space requirement is O(1): it doesn't depend on input size.\nTechnically, python integers can grow indefinitely. This means that your space requirement is actually something like O(log(N)) since O(log_base_256(N)) = O(log(N) \/ log(256)) = O(log(N)). Most other languages have a true O(1) requirement because they cap the size of an integer, be it at 32 or 64 bits. For all practical purposes, you can cap the size of an integer at a value large enough to describe all the available memory, and call it O(1).","Q_Score":1,"Tags":"python,list,hashmap,big-o,space-complexity","A_Id":63369251,"CreationDate":"2020-08-12T03:13:00.000","Title":"Is the extra space complexity of a function that counts letter occurrences O(1) for both a hashmap and list implementation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Spyder using pip (after realising that Anaconda gave me issues with my Windows username containing a space).\nPip says it is installed and up to date but if I try to launch it via CMD using \"spyder\" or \"spyder3\", cmd does not recognise the command.\nI also cannot find it anywhere in the python folder.\nThis is bizarre, has anyone got any solution?\nThank you\nPS I'm running Windows 10 with Python 3.8 and currently use PyCharm","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":63369478,"Users Score":0,"Answer":"I had a similar problem with pygame and pyinstaller, did you update your paths? Make sure to add C:\\Users\\YourUsername\\AppData\\Local\\Programs\\Python\\Python38-32\\Scripts\nthat's where my mine are installed","Q_Score":0,"Tags":"python,python-3.x,installation,spyder","A_Id":63369718,"CreationDate":"2020-08-12T03:51:00.000","Title":"Spyder installed via pip but invisible","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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 show\/hide page in the odoo form when button is clicked ?\nThere is a page in my contact form I want to hide or show based on button click.\nI don't want to use attribute method or any xpath.\nJust click button page show up and click that button again it will hide.\nDoes JS can be written in Odoo form for this process?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":270,"Q_Id":63370511,"Users Score":1,"Answer":"It's doable but I don't think it's a good approach, you can make a click event that will trigger toggle to hide\/show the notebook. But in your case, I would recommend that you do it through security if you want to show\/hide the notebook for specific users.","Q_Score":0,"Tags":"javascript,python-3.x,forms,odoo-13","A_Id":63383959,"CreationDate":"2020-08-12T05:45:00.000","Title":"Show or hide notebook page in Odoo?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I had implemented a CNN with 3 Convolutional layers with Maxpooling and dropout after each layer\nI had noticed that when I trained the model for the first time it gave me 88% as testing accuracy but after retraining it for the second time successively, with the same training dataset it gave me 92% as testing accuracy.\nI could not understand this behavior, is it possible that the model had overfitting in the second training process?\nThank you in advance for any help!","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":222,"Q_Id":63371731,"Users Score":2,"Answer":"It is quite possible if you have not provided the seed number set.seed( ) in the R language or tf.random.set_seed(any_no.) in python","Q_Score":1,"Tags":"python,tensorflow,keras,neural-network","A_Id":63371848,"CreationDate":"2020-08-12T07:22:00.000","Title":"Retrain your CNN model successifely with two different datasets","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had implemented a CNN with 3 Convolutional layers with Maxpooling and dropout after each layer\nI had noticed that when I trained the model for the first time it gave me 88% as testing accuracy but after retraining it for the second time successively, with the same training dataset it gave me 92% as testing accuracy.\nI could not understand this behavior, is it possible that the model had overfitting in the second training process?\nThank you in advance for any help!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":222,"Q_Id":63371731,"Users Score":1,"Answer":"Well I am no expert when it comes to machine learning but I do know the math behind it. What you are doing when you train a neural network you basicly find the local minima to the loss function. What this means is that the end result will heavily depend on the initial guess of all of the internal varaibles.\nUsually the variables are randomized as a initial estimation and you could therefore reach quite different results from running the training process multiple times.\nThat being said, from when I studied the subject I was told that you usually reach similar regardless of the initial guess of the parameters. However it is hard to say if 0.88 and 0.92 would be considered similar or not.\nHope this gives a somewhat possible answer to your question.\nAs mentioned in another answer, you could remove the randomization, both in the parameter initialization of the parameters and the randomization of the data used for each epoch of training by introducing a seed. This would insure that when you run it twice, everything will get \"randomized\" in the exact same order. In tensorflow this is done using for example tf.random.set_seed(1), the number 1 can be changed to any number to get a new seed.","Q_Score":1,"Tags":"python,tensorflow,keras,neural-network","A_Id":63371852,"CreationDate":"2020-08-12T07:22:00.000","Title":"Retrain your CNN model successifely with two different datasets","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am generating a large array of random numbers, totaling more than half the available memory on a GPU. I am doing this in a loop.\nWhen I call cupy.random the second time (or third time...), assigning to the same variable name, it does not free the memory for the first array. It tries to allocate more memory, which causes an out of memory error.\nExplicitly freeing the memory before generating a new random array is very slow, and seems inefficient.\nIs there a way to generate a new set of numbers, but in the same memory space?\nEdit: cupy.random.shuffle() is letting me work around the problem, but I wonder if there is a better way?\nEdit 2: on further review, shuffle() does not address the problem, and appears to need even more memory than allocating a second block (before freeing the first) of memory...  I am back to restricting ndarray size to less than half the remaining memory, so two ndarrays can be allocated alternately","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":281,"Q_Id":63371771,"Users Score":0,"Answer":"As user2357112 suggests, cupy.random.random() does not appear to support \u201cre-randomizing\u201c an existing ndarray, even though cuRand does. Writing C to modify an existing cupy array somewhat defeats the point of using python \/ cupy in the first place.\nCuriously, having an array about 1\/3rd the size of available memory, while increasing the number of loops, is faster in total execution time (versus larger arrays\/fewer loops).  I was not able to determine when cupy (or python or cuda?) does garbage collection on the disused array, but it seems to happen asynchronously.\nIf GPU garbage collection uses cuda cores (I presume it does?), it does not appear to materially effect my code execution time. Nvidia-smi reports \u201cP2\u201d GPU usage when my code calculations are running, suggesting there are still cores available for cupy \/ cuda to free memory outside of my code?\nI don\u2019t like answering my own question... just sharing what I found in case it helps someone else","Q_Score":0,"Tags":"python,cupy","A_Id":63437375,"CreationDate":"2020-08-12T07:25:00.000","Title":"CuPy random - how to generate new random set in same memory?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an object from a class of particular python module that quantifies some chemical compounds. I am trying to pickle the output from one its functions, but I always get the error \"TypeError: Cannot serialize '_io.BufferedReader' object. I also tried dill, but it gives me the same error.\nIs there any way I can get this to work?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":198,"Q_Id":63372768,"Users Score":0,"Answer":"You can't pickle a BufferedReader since by itself, it doesn't represent any real amount of data - just where it can read the data from.\nIf you can, I would suggest reading all data and serializing that instead. Note that if this BufferedReader represents a unending stream or large file, that doing this may not be possible and you might need to find a way to solve you problem without serialization (perhaps instead saving an item that instructs other code to make the same method call?)","Q_Score":0,"Tags":"python,pickle","A_Id":63372864,"CreationDate":"2020-08-12T08:31:00.000","Title":"pickle unserializable python objects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the package cvb in Spyder with Python 3.6.\nI got\nimport cvb\non top of my script\nIf i use F5 to run the whole script I get an error (AttributeError: module '_cvb' has no attribute 'NotifyArgs) for this import.\nIf I select import cvb and then run selction with F9 there is no error and I can run the script afterwards with F5 also without error.\nWhat is the difference between the call by F5 and F9?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":90,"Q_Id":63373355,"Users Score":0,"Answer":"I found a solution. I had to adjust PYTHONPATH and now it works.","Q_Score":0,"Tags":"python,import,spyder,attributeerror","A_Id":63403498,"CreationDate":"2020-08-12T09:09:00.000","Title":"Different behavior of package import by F5 and F9 in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use json to store currency and I made a few games where people can earn currency by playing.\nThe problem is if 2 or more user use the command at the same time only one user will win\/lose the currency in json. Is there a way to fix this?\nThis is an example code of the game that I made\nI changed my database to sqlite","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":63375237,"Users Score":0,"Answer":"You need to use await when you read from or write to file, else the bot will wait for the operation to finish.\nThe await wrapper makes your bot jump to another line of code and not wait for I\/O processes.","Q_Score":0,"Tags":"python,discord.py","A_Id":63375271,"CreationDate":"2020-08-12T11:06:00.000","Title":"Using json to store values getting blocked when 2 or more user use the command at the same time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to download .parqeat file from Azure storage and have to analyze the Data.\nSo I started using python codes with azure-storage-blob library and Pandas to store DataFrames and flask to create API on response.\nBut now file size in the Azure storage is getting increased up to 30MB(a day file) and as tested it takes 6min to download 20MB file into my local which I can't afford because I have to analyse files of each days in a month, which will have 20 MB each. That's almost 3020MB size.\nAny suggestion?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":63376871,"Users Score":0,"Answer":"Did you find your answer? Without a code snippet it would be hard to diagnos your problem. Azure Blob Storage supports read in parallel. If you have BatchServiceClient service that would be straightforward. Otherwise, try Multiprocessing module. Kr.","Q_Score":0,"Tags":"python,azure,blob,azure-storage,data-analysis","A_Id":65569711,"CreationDate":"2020-08-12T12:48:00.000","Title":"Python: azure-storage-blob takes 6 min to download a 20MB file to local","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to stream Elasticsearch data into Snowflake. I am testing a python script which ultimately will be deployed as a cloud function\/docker app on AWS. For historical I am using the scroll API to write x amount of objects into a string and the string to a file. I've used Snowflake's PUT file:\/\/file.json.gz @stage but that implies I need to write the file temporary to disk before storing on a stage. I have an insanely large amount of data to pull and am trying to eliminate as many steps as possible. Is there a cheeky way I can write files to the stage directly?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":139,"Q_Id":63378402,"Users Score":1,"Answer":"If you create a Snowflake Stage linked to an S3 when you save to your S3, with whatever you decide to use, it will be automatically on your Snowflake Stage, this way, you can just send a COPY INTO command and save a step or two.\nIn my opinion, it's a simple and handy solution.\nif you need the steps, let me know and I'll be glad to post those here.","Q_Score":0,"Tags":"python,elasticsearch,snowflake-cloud-data-platform","A_Id":63386935,"CreationDate":"2020-08-12T14:12:00.000","Title":"Can you write JSON to Snowflake stage?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to extract Medical Equipment part names from the list of sentences.\nThese sentences are recorded actions taken on a support request which might include replacement of a part or acknowledging a part is in a bad state.\nHere are the sample sentences-\n\nFound [Some equipment part] on both side not working.\nNarrowed problem down to the [Some equipment part].\nNeeded a [Some equipment part] replacement.\nAssisted with troubleshooting, found [Some equipment part] is most likely bad.\n[Some equipment part] won't go down, will order part.\n\nI want to extract \"[Some equipment part]\" from the above sentences.\nThings I've already tried-\nFirst, I've filtered the sentences using Sentiment Analysis. Considering only the ones which have a negative sentiment or have \"replace\" text in them.\n\nUsing NLTK, After POS tagging using RegexpParser on a defined grammer = \"NP : {<VB.><NN.>+<NN.>+|<VB.><NN.>+}\"\nUsing Spacy, After POS tagging and dependency, filtering based on Verb, Noun relationship - token.dep_ in ['dobj'] and token.pos_ == 'NOUN'\n\nThe above approaches gives me a lot of meaningless output.\nPlease, let me know if there is anything which can be of help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":433,"Q_Id":63378487,"Users Score":0,"Answer":"It sounds like you would benefit from looking at Named Entity Recognition (NER). I would be curious if SpaCy would be able to pick these out as PRODUCT entities.","Q_Score":0,"Tags":"python,nlp,nltk,data-science,spacy","A_Id":63379092,"CreationDate":"2020-08-12T14:17:00.000","Title":"How to extract particular word(s) from the list of sentences using Python NLP. These word(s) are Parts of Medical equipments","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to only save celery results on specific parameters, such as a failed task?\nI have been looking but the only way I could manage was to go back through the celery results backend and parse through the data outside of celery.\nIs there a better way?\n(Note: I am using mongodb as a celery result backend.)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":174,"Q_Id":63379799,"Users Score":1,"Answer":"Not that I know of (do not take my words for granted). If you specify result backend, it will be used for all tasks both successful and unsuccessful that do not ignore results.","Q_Score":0,"Tags":"python-3.x,celery,celery-task","A_Id":63393194,"CreationDate":"2020-08-12T15:26:00.000","Title":"Only store results of \"failed\" celery tasks (Celery Result backend)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am about creating a regression model but I wonder what would be the best way to handle nan values for both numerical and categorical data:\nI know that for the numerical columns the next solutions could be useful:\n1- Replace it with 0: df.fillna(0, inplace=True)\n2- Replace it with mean: df.fillna(df.mean(), inplace=True)\n3- Replace it with median df.fillna(df.median(), inplace=True)\n4- delete each row, in my target column, has nan value\nIs it possible to have overfitting after adopting 2 or 3.\nWhat is the best way to handle both categorical and numeric values in columns\nHowever, I wonder what could be the best choice for categorical data is it after using the one hot encoding ?\nAny help could be appreciated !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":755,"Q_Id":63380017,"Users Score":4,"Answer":"For usual practice, it is preferred to use df.fillna(df.mean(), inplace=True) for columns having continuous values and  df.fillna(df.mode()[0], inplace=True) for categorical values.","Q_Score":1,"Tags":"python,pandas,regression,nan,categorical-data","A_Id":63380122,"CreationDate":"2020-08-12T15:38:00.000","Title":"What would the best way to handle NaN values for both numerical and categorical data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sorry for this really vague question but I am just sort of stuck on how to phrase this question so I haven't really been able to find a proper answer just by googling.\nEssentially, I have this python script that alters a csv file in a very specific way. Right now it runs fine on my local machine, but I need this to work with the web. Essentially what I want to be possible is for someone to upload their CSV to my site, it would automatically send to my server, my script would see this, manipulate it in the way necessary, and then send it back once it was finished. Does anyone know any methods of doing this that I should look into?\nAgain, sorry this is so poorly researched sounding but I am just having a lot of trouble properly phrasing it so I haven't been able to find much.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":26,"Q_Id":63380960,"Users Score":1,"Answer":"Multiple ways to make it happen.\nUse synchronous flow\nYou would upload the file from the browser, that would be handled by the Flask handler, the handler would process the file and return the updated file in the response. Here you can also use polling to poll the server to see if the processing is done or not using ajax along with polling you can use a loader.\nProblem: processing large file, slow internet connection\nUse asynchronous flow\n\nYou would upload the file from the browser, that would be processed later using some Celery task, other background processor or crontabs that would manipulate the file in the background.\nPost manipulation of the file, you can either give an option in the user profile to download the file, send an email attachment or provide download a link, etc.","Q_Score":0,"Tags":"python,flask","A_Id":63381411,"CreationDate":"2020-08-12T16:32:00.000","Title":"How would one make it so that I can send a file to a server and then have my python script manipulate it, and then send it back?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have customized the save() method of my Django model to write some data into a file. I want to write the data into a file in STATIC_ROOT so nginx can serve it. When I write data into a file inside Django project root everything is OK but when I try to write to STATIC_ROOT I get \"Database is locked error\".\nWhat is the problem with that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":63383050,"Users Score":0,"Answer":"I found the solution to this problem but I didn't get why this happens!\nTo solve the problem when I was overriding the save method of Django model, I first called the save method of parent model and then saved my file! Do in reverse order caused the error.","Q_Score":0,"Tags":"python-3.x,django,database,sqlite,django-models","A_Id":63398914,"CreationDate":"2020-08-12T18:53:00.000","Title":"Django sqlite \"Database is locked\" when writing to STATIC_ROOT","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I run pip3 install -r requirements.txt on a project I get this error message:\n\npip._vendor.pkg_resources.VersionConflict: (pip 20.2.2\n(\/usr\/local\/lib\/python3.7\/site-packages),\nRequirement.parse('pip==20.1.1'))\n\nWhy is that happening? I am completely blocked on working on new projects.\nMy python version is 3.7.8 and I am working on a MAC.\nHas this something to do with homebrew python version is now 3.8 what is also installed on my machine.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":631,"Q_Id":63384394,"Users Score":3,"Answer":"It looks like pip is mentioned in the requirements.txt file, requiring a specific version of pip. Installation should work when you remove the line which specifies the pip version from requirements.txt.\nrequirements.txt should mention the packages you need for your project, not the tool which you need to install those requirements. That's kind of self-referencing.","Q_Score":0,"Tags":"python,pip","A_Id":63385098,"CreationDate":"2020-08-12T20:36:00.000","Title":"why is my pip installing tool not working anymore with python version 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a .zip file with around 26k image files. I have a list of files that I want to keep in the .zip\nI was wondering if it was possible for me to remove files within that .zip that aren't in my file list without unzipping the actual folder (because it would take up way too much space on my computer) using Python 3.\nI couldn't find anything on this and was wondering if anyone knows a way I can do this\nThank you!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2712,"Q_Id":63386011,"Users Score":0,"Answer":"Python's standard library doesn't support altering an existing zip archive, and I don't see any likely candidates in PyPI.\nThe zip utility can delete files from an archive (-d), so you may be able to script it instead, perhaps using Python.\nAnother option would be to create a new zip archive based on the existing one, and skip the files you don't want.  That would not require extracting any files to disk, but it could be CPU-intensive.","Q_Score":3,"Tags":"python-3.x,file,zip,unzip","A_Id":63386474,"CreationDate":"2020-08-12T23:32:00.000","Title":"Is it possible to delete files in a .zip file without unzipping it Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"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":"I've recently read a couple great SO questions\/answers on the difference between multithreading and multiprocessing. I can't say that I understood everything that I read, but I think I get the gist. I thought a great way to learn more was to choose one or the other and use it for a job I need to do anyway.\nNamely, I've got a bunch of folders each with a bunch of mp3 files. I want to resample all the files in all the folders to be at the same sampling rate and number of channels and then save them as .wav files. I'm thinking I could assign one folder per process until all the folders have been converted.\nI've read that multi-threading often doesn't result in reduced time because threads are hard to run in parallel. This is why I am leaning towards this option.\nWould multiprocessing give faster results for file IO operations than multi-threading?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":64,"Q_Id":63387352,"Users Score":2,"Answer":"It would depend on what dependencies there are in the problem you are trying to solve. If you can assign a task with little to no dependencies (shared data, shared variables, etc.) to run on its own then multi-processing would be great. As long as starting the processes doesn't take longer than it would be to just run it. (Starting new processes is expensive)\nWith that being said I think it would work well to assign one mp3 conversion task per process. Just make sure you have something to monitor which mp3 files have already been resampled and converted to prevent duplicate processes.","Q_Score":0,"Tags":"python,multithreading,io,multiprocessing","A_Id":63387426,"CreationDate":"2020-08-13T02:39:00.000","Title":"multithreading or multiprocessing for general file operations?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset which I transformed to CSV as potential input for a keras auto encoder.\nThe loading of the CSV works flawless with pandas.read_csv() but the data types are not correct.\nThe csv solely contains two colums: label and features whereas the label column contains strings and the features column arrays with signed integers ([-1, 1]). So in general pretty simple structure.\nTo get two different dataframes for further processing I created them via:\nlabels = pd.DataFrame(columns=['label'], data=csv_data, dtype='U')\nand\nfeatures = pd.DataFrame(columns=['features'], data=csv_data)\nin both cases I got wrong datatypes as both are marked as object typed dataframes. What am I doing wrong?\nFor the features it is even harder because the parsing returns me a pandas.sequence that contains the array as string: ['[1, ..., 1]'].\nSo I tried a tedious workaround by parsing the string back to an numpy array via .to_numpy() a python cast for every element and than an np.assarray() - but the type of the dataframe is still incorrect. I think this could not be the general approach how to solve this task. As I am fairly new to pandas I checked some tutorials and the API but in most cases a cell in a dataframe rather contains a single value instead of a complete array. Maybe my overall design of the dataframe ist just not suitable for this task.\nAny help appreacheated!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":63394131,"Users Score":0,"Answer":"The input csv was formatted incorrectly, therefore the parsing was accurate but not what i intended. I expanded the real columns and skipped the header to have a column for every array entry - now panda recognize the types and the correct dimensions.","Q_Score":0,"Tags":"python,pandas,dataframe,csv","A_Id":63399489,"CreationDate":"2020-08-13T11:25:00.000","Title":"Loading CSV with Pandas - Array's not parsed correctly","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"from Queue import queue\nModuleNotFoundError: No module named 'Queue'","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":973,"Q_Id":63394902,"Users Score":0,"Answer":"queue is the name of the module, while Queue is a class name. You can tell so because conventionally, class names start with with a capital letter.\nThe syntax for importing a specific class from a module is from MODULE import CLASS, so in your case, it should be from queue import Queue. From this you can use your queue : q = Queue().","Q_Score":0,"Tags":"queue,python-3.8","A_Id":63397680,"CreationDate":"2020-08-13T12:12:00.000","Title":"How to install Queue(from queue import queue) library in python3.8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For some reason today my Jupyter Notebook has decided it doesn't want to execute the code in cells. However this isn't consistent. I'll restart the kernal, it will work for a while, but then when it runs into an error it then won't execute any code in any other cells after that without a kernal restart.\nI've seen a previous post on this but using  jupyter troubleshoot only printed out all the packages and no useful information and I also don't appear to have nbextensions dubplicated anyway.\nI'm using python 3.7.8 and Jupyter_client 6.1.6\nSorry I don't have much more information, but I'm not really sure what other information to give\/look for.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":63395039,"Users Score":0,"Answer":"What kind of errors do you mean by \"when it runs into an error it then won't execute any code in any other cells after that without a kernal restart\"?\nI know that if you have In [*] instead of the run number of the cell for a long time probably you have an infinite loop in this cell or an open input (an input that waiting to your answer). Is this the situation?","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":63395201,"CreationDate":"2020-08-13T12:19:00.000","Title":"Jupyter Notebook not executing cells\/code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So for a little context. In linux the \"ifconfig\" command is actually executing a \"ifcfg-eth0\" file found \"\/etc\/sysconfig\/network-scripts.\"\nIn windows, do command line (or powershell) commands correspond to a specific file? If so where? If it exists I having a hard time finding it.\nReason:\nI am trying to execute commands from a program I am writing in Python. I know there are other ways to accomplish this ie. \"import os, import subproccess.\" I am trying to brainstorm a simpler way to execute these commands before my program gets to heavy.\nBasically I would like to tell python to execute a file ie. \"ifcfg-eth0\" in linux but in windows. Also, I'm just using \"ipconfig\" as an example There are a lot of commands I want to add.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":169,"Q_Id":63395320,"Users Score":-1,"Answer":"Usually cmd commands are located in system32.\nThere's an executable ipconfig.exe in C:\\Windows\\system32","Q_Score":0,"Tags":"python,linux,windows,powershell,command","A_Id":63395404,"CreationDate":"2020-08-13T12:37:00.000","Title":"Is there a way to reference an \"ipconfig\" file in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have to do some cleanup with my (Mini)conda python packages to free some disk space, and I see people usually resort to the conda clean command to get this job done. Conda documentation says that it it's safe to do that, as it will only erase packages that \"have never been used in any environment\".\nI've never used conda's environments feature, though, and I don't know if I should be doing so. I just install my packages with conda install commands, run Jupyter Notebook and do all my work inside Jupyter. (I'm not a software engineer, just a regular dude using python and pandas to manage data.)\nDo I risk erase my favorite packages if i run conda clean? If I don't do any cleanup, will conda eventually engulf all of my disk space? Is there any command I can use to check how much disk space my python packages are taking.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3649,"Q_Id":63396950,"Users Score":4,"Answer":"At the very least, tarballs can be removed with no risk. Cleaning packages is done based on counting the number of hardlinks for the package. If there is only one hardlink, this implies the package is not referenced by any environment, and therefore can be removed. This will be the case for all packages that were previously in use but were superseded by other versions.\nThe warning mainly applies to people who have environments across different disks but are using softlinks to limit redundancy. Unlike hardlinks, the file system does not keep track of softlink references, so there is no simple way to count the number of softlinks. Hence, when cleaning, those packages that are only connected to envs through softlinks (i.e., only report one hardlink) will be removed and thereby break the softlinking envs.","Q_Score":5,"Tags":"python,pandas,anaconda,conda,miniconda","A_Id":63403861,"CreationDate":"2020-08-13T14:04:00.000","Title":"Will \"conda clean\" erase my favorite packages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently developing a React-Django app and using dj-rest-auth package and JWT for authentication on the backend. It works perfectly fine and when a user loggs in, server responses with a HttpOnly cookie which contains access_token.\nWhat I don't understand is how can I use the access_token that in the response-cookie for requests in my web app if I can't read the token value from my frontend since it is HttpOnly?\nI tried js-cookie package for storing JWT in cookies and since it is written in JS, I can't make it HttpOnly. So I am storing access_token in a cookie but doesn't it break the point of HttpOnly cookies since they both store the same token value?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":63399327,"Users Score":1,"Answer":"you can send the token to your api call on the headers as Authorization Bearer + token","Q_Score":0,"Tags":"python,django,reactjs,authentication,jwt","A_Id":63399761,"CreationDate":"2020-08-13T16:23:00.000","Title":"How to use tokens in frontend for authentication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a csv file encoded in utf-8 (filled with information from website through scraping with a python code, with str(data_scraped.encode('utf-8') in the end for the content)).\nWhen I import it to excel (even if I pick 65001: Unicode UTF8 in the options), it doesn't display the special characters.\nFor example, it would show \\xc3\\xa4 instead of \u00e4\nAny ideas of what is going on?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":63399685,"Users Score":0,"Answer":"I solved the problem.\nThe reason is that in the original code, I removed items such as \\t \\n that were \"polluting\" the output with the replace function. I guess I removed too much and it was not readable for excel after.\nIn the final version, I didn't use\nstr(data_scrapped.encode('utf-8') but\ndata_scrapped.encode('utf-8','ignore').decode('utf-8')\nthen I used split and join to rempove the \"polluting terms\":\nstring_split=data_scrapped.split()\ndata_scrapped=\" \".join(string_split)","Q_Score":0,"Tags":"python,excel,web-scraping,encoding","A_Id":63502540,"CreationDate":"2020-08-13T16:45:00.000","Title":"Cannot read imported csv file with excel in UTF-8 format after python scraping","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I already have python 2.7 and 3.7 installed on my computer. I just don't want to re-download python using pacman.\nIs there a way to link python with MSYS2?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":97,"Q_Id":63401000,"Users Score":1,"Answer":"If you want to use Python in MSYS2, you need to use the one bundled with pacman. Mingw-64 compiles Python using GCC for Windows and it is heavily patched downstream so that it will run. You can't use the normal Windows Python that is compiled against Microsoft Visual C, it isn't compatible.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,msys2","A_Id":63972150,"CreationDate":"2020-08-13T18:14:00.000","Title":"How to link already installed python to MSYS2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background\nI have inherited code that uses multiple event loops to handle read\/writing to\/from multiple objects created using websockets.serve.  These coroutines need to access a common list.\nScenario\n\ncoroutine A in event loop X\ncoroutine B in event loop Y\n\nQuestions\n\nDo I need to protect the access to the common list?\nIf I do need to protect access to the list, will asyncio.Lock() be sufficient?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":628,"Q_Id":63401187,"Users Score":2,"Answer":"I assume the event loops run in parallel, each in its own thread. In that case you would treat shared data exactly as you would data shared between different threads. Specifically:\n\nIt will depend on what you are doing with the lists. If one thread is reading and the other is calling something like append, you don't need synchronization because you're protected by the GIL. But if you are doing something more complex, e.g. deleting the items directed by the reader thread, you will need to lock to ensure you don't lose items due to concurrent modification.\n\nasyncio.Lock is definitely not the correct locking device to use because it is designed for use within one event loop, i.e. it's single-threaded. You can't use a threading.Lock either because it's non-async and would block the whole event loop. You could probably use loop.call_soon_threadsafe to synchronize between event loops, but it's not trivial.\n\n\nThe code you inherited uses asyncio in a way it was not intended to be used and you're likely to run into issues. Since the asyncio event loop is designed to scale to an arbitrary number of tasks, I recommend refactoring the code to use a single event loop. Then you'll need no special synchronization, as any code between awaits will naturally form a critical section, and if you need locking across await, you can use asyncio.Lock, which was created for that use case.","Q_Score":0,"Tags":"python-3.x,synchronization,python-asyncio,event-loop","A_Id":63408209,"CreationDate":"2020-08-13T18:28:00.000","Title":"Do I need to use asyncio.Lock when coroutines in different event loops are accessing common code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i'm new in python, i would like create an executable-installer of my django project, i would like that my client with double-click runs this program and open his browser with my project running on his local server, and that he can access to mysql database, Thanks.\nI've searched on internet about python to exe scripts, PyInstaller, but I can't find how to run the server and connect to the database in an executable.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":357,"Q_Id":63402826,"Users Score":0,"Answer":"First of all, you need to prepare your application and embed a production-ready web server such as uvicorn. Afterward, you must bundle this with a tool such as pyinstaller. This can be quite a hassle due to the large number of dependencies.","Q_Score":0,"Tags":"python,mysql,django","A_Id":63404018,"CreationDate":"2020-08-13T20:34:00.000","Title":"Is it possible to create an executable from my django project with connection to a mysql database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have code on aws ec2. Right now, it accepts input and output files from s3. Its an inefficient process. I have to upload input file to s3, copy s3 to ec2, run program, copy output files from ec2 to s3, then download locally.\nIs there a way to run the code on ec2 and accept a local file as input and then have the output saved on my local machine?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":435,"Q_Id":63403563,"Users Score":0,"Answer":"@John Rotenstein we have solved the problem of loading 60MB+ models into Lambdas by attaching AWS EFS volumes via VPC. Also solves the problem with large libs such as Tensorflow, opencv etc. Basically lambda layers almost become redundant and you can really sit back and relax, this saved us days if not weeks of tweaking, building and cherry picking library components from source allowing us to concentrate on the real problem. Beats loading from S3 everytime too. The EFS approach would require an ec2 instance obviously.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,amazon-ec2","A_Id":63439343,"CreationDate":"2020-08-13T21:37:00.000","Title":"How to run code on aws ec2 with local input and output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In theory, linear interpolation can be done with any triangulation (not just a Delaunay triangulation).\nI am trying to use scipy.interpolate.LinearNDInterpolator with a pre-computed 3D triangulation which is not of class scipy.spatial.Delaunay. However, this won't work because the SciPy code checks the class of the triangulation (if isinstance(points, qhull.Delaunay)...). I tried to create a 'fake' Delaunay triangulation with the correct class by changing the 'points' and 'simplices' attributes of a Delaunay object, but I received the error AttributeError: can't set attribute.\nIs there a way around this, or another library for linear interpolation?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":156,"Q_Id":63404041,"Users Score":0,"Answer":"It looks like matplotlib.tri.LinearTriInterpolator might be a good alternative. I will update this post when I have tested this.\nEdit: This is not a solution to my problem because it is only implemented in 2-D.","Q_Score":1,"Tags":"python,class,scipy,interpolation","A_Id":63404055,"CreationDate":"2020-08-13T22:27:00.000","Title":"3-D linear interpolation in SciPy with non-Delaunay triangulation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to understand what happens under the hood of scikitlearn OneVsRestClassifier when we use LinearRegression as estimator. Does it create one LinearRegressor per class and apply a softmax function to return an output class? Documentation is not clear in this aspect. Even fit() source code seems is clear enough.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":63405239,"Users Score":0,"Answer":"OvR is used for classification not for regression so using LinearRegression would not work at all.\nThe one-versus-the-rest(OvR) strategy is used for multiclass classification with multiple binary classifiers. Take the MNIST digit dataset as an example where you would want to create a system that can classify the digit images into 10 classes (from 0 to 9) using OvR you would train 10 binary classifiers, one for each digit (a 0-detector, a 1-detector, a 2- detector, and so on). Then when you want to classify an image, you get the decision score from each classifier for that image and you select the class whose classifier outputs the highest score.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,classification","A_Id":63405948,"CreationDate":"2020-08-14T01:21:00.000","Title":"What happens if you use LinearRegression with OneVsRestClassifier","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there an easy way to choose bit(s) form a word ?\nI prefer to use with built in library.\nFor example,\nI read the data from binary file (I read 32bit each time because I work with words)\nnum = 128 (1000 0000 )\nI want: num[7:6] = 10 in binary = 2\nI did it with ('shift' and 'and') or int(bin(128)[2:][::-1][6:8][::-1],2)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":61,"Q_Id":63407139,"Users Score":1,"Answer":"You could use bitwise operators. e.g,\n(((1 << 8) - 1) & num) >> 6\nIn general, for bits a to b (higher bits to lower, 0-indexed),\n(((1 << (a+1)) - 1) & num) >> b\nExplanation:\nSay num is 121 = 0111 1001, and we want bit 4 to bit 2 (0-indexed). i.e, 110 or 6. So a = 4, b = 2.\n((1 << (a+1)) - 1) is just 111...a times. Doing & with this helps us pick the last \"a\" bits. e.g, any number & 11 will pick its last 2 bits. A number & 111 will pick the last 3 and so on.\nSo ((1 << (a+1)) - 1) & num is just the last a bits of num.\n >> b drops the last b bits.\nTherefore, together,\n(((1 << (a+1)) - 1) & num) >> b has the effect of picking the last a bits from num, then dropping the last b bits. So together, it will return bits in the a to b range","Q_Score":0,"Tags":"python,python-3.x","A_Id":63407198,"CreationDate":"2020-08-14T05:35:00.000","Title":"an easy way to choose bit(s) form a word","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"We are trying to install a django project in a remote server that is Windows 7. The installer make a virtual environment and install some packages in it, django among them. \nThe virtual environment is created (I can see it typeing workon or lsvirtualenv) but is not activated if I type workon  in a cmd, simply prompts current path after press enter key\nIn which cases happen this? Why can't I activate a virtual environment that exists?\nNote: This process finish successfuly in local machines","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":63409217,"Users Score":0,"Answer":"Have you tried activate? My cmd usually looked like\ntutorial\/scripts\/activate","Q_Score":0,"Tags":"python,django,windows-7,virtualenv","A_Id":63409678,"CreationDate":"2020-08-14T08:27:00.000","Title":"python workon command doesn't activate the virtual environment in cmd windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Django project forked from GitHub. But I don't know which version of Django is used in that project. How can I find the Django version of the project ? I haven't installed Django in my PC.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1753,"Q_Id":63410207,"Users Score":0,"Answer":"Django version or any other package version\nOpen the terminal or command prompt\nType\npip show django","Q_Score":3,"Tags":"python-3.x,django","A_Id":63414634,"CreationDate":"2020-08-14T09:30:00.000","Title":"How To Find Django Version Of A Project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Django project forked from GitHub. But I don't know which version of Django is used in that project. How can I find the Django version of the project ? I haven't installed Django in my PC.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1753,"Q_Id":63410207,"Users Score":0,"Answer":"import django\n\n\n\n\n\n\nprint(django.get_version())\n\n\n\n3.0.7","Q_Score":3,"Tags":"python-3.x,django","A_Id":63849002,"CreationDate":"2020-08-14T09:30:00.000","Title":"How To Find Django Version Of A Project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using the Spyder ide and if I do help(scipy.sparse.coo_matrix) I get a lot of output on the screen. Is it possible to display it page by page? Something like what  | more does on Bash. e.g. ls | more","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":46,"Q_Id":63410673,"Users Score":1,"Answer":"(Spyder maintainer here) To activate a pager inside our consoles, you need to go to the menu\nTools > Preferences > IPython console > Display\nand activate the option called Use a pager to display additional text inside the console.\nHowever, a way more comfortable way to read docs inside Spyder is by simply pressing Ctrl + I (Cmd + I on macOS) in front of an object and see those docs rendered as an html page inside our Help pane.\nNote: Paging is broken as of October 2020. Given that's been the case for years without no one noticing it, we decided to remove it in our next version (4.2.0), to be released in November 2020.","Q_Score":0,"Tags":"python,numpy,scipy,spyder","A_Id":64457203,"CreationDate":"2020-08-14T10:02:00.000","Title":"equivalent of |more for python dir \/ help()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a Python program with two threads. One displays a GUI and the other gets input from a scanner and saves data in an online database. The code works fine on my raspberry pi but if I try it on my MacBook Pro (Catalina 10.15.2), I get the above mentioned warning followed by my code crashing.\nDoes anyone have an idea how to get it working or what causes the problem?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8576,"Q_Id":63412583,"Users Score":4,"Answer":"You likely use different Python versions. Your Python on your Raspberry PI still allows invalidating NSWindow drag regions outside the Main thread, while your Python in your MacBook Pro already stopped supporting this. You will likely need to refactor your code so that NSWindow drag regions will only be invalidated on the Main thread.\nYou need to localize where NSWindow drag regions are invalidated and make sure that those happen in the Main thread.\nEDIT\nThe asker explained that according to his\/her findings, NSWindow drag regions only apply to Mac.","Q_Score":6,"Tags":"python,python-3.x,multithreading,macos,nswindow","A_Id":63412773,"CreationDate":"2020-08-14T12:15:00.000","Title":"NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible + legal to have a website where when people register, a personal google drive is created for them? Trying to create a website where people can upload audio files in a post, which would be displayed for other users. Can the drive be used as a hosting platform for the uploaded files? If yes, then how can this be done?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":547,"Q_Id":63412907,"Users Score":1,"Answer":"Is it possible + legal to have a website where when people register, a personal google drive is created for them?\n\nYou cant programmaticlly create a google account for another user.  You could request access to their google drive account and access things there but the issue will be if you want to share their files with someone else.\n\nTrying to create a website where people can upload audio files in a post, which would be displayed for other users.\n\nYou could use a service account to upload the files to an account that you the developer own and some how associate what was uploaded by each user.  Probably storing each users data in a directory linked to there user id in your system worked be the most logical.\nThe issue being here is you are going to be footing the bill for the storage space.\n\nCan the drive be used as a hosting platform for the uploaded files? If yes, then how can this be done?\n\nThe google drive api is really just a file storage system.  If you want the users to be able to view theses files after they will need to download them to their own machine.  Drive api wasn't really meant to host that will be viewed.","Q_Score":1,"Tags":"python,django,google-drive-api","A_Id":63413074,"CreationDate":"2020-08-14T12:37:00.000","Title":"Connecting django website to Google drive API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I copied a repo containing a Python Django project from my old computer to my new one via git clone. I manage my dependecies in the project via pipenv.\nAfter successfully cloning my repo I wanted to start working on the new computer and tried to select the relevant python interpreter for my project in VS Code . However, the path was not on the list.\nSo first I tried the command pipenv --venv which gave me the feedback: No virtualenv has been created for this project\nSo I thought I might need to activate the virtual environment first, before being able to select it in VS Studio code. So i ran pipenv shell in the root directory of my project.\nHowever this seem to have created a new virtual environment: Creating a virtualenv for this project\u2026 Pipfile: C:\\path\\to\\my\\cloned\\project\\Pipfile\nMy questions:\n1.) Is this the correct way to activate a pipenv virtualenvironment on a new computer after copying the project via git clone? And if not,...\n2.1) Does the way I did it cause any problems, which I should be aware of?\n2.2) What would be the correct procedure to activate my virtual enviroment on a new computer?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1517,"Q_Id":63414493,"Users Score":1,"Answer":"In general an environment image probably shouldn't be copied to github. You'll get a bunch of unneeded files which clogs your repo.\nInstead you should create a requirements.txt from your existing environment pip freeze > requirements.txt and commit that file.\nThen when someone else clones your repo they can set up a new virtual environment using any tool they want and run python -m pip install -r requirements.txt\nThat is, requirements.txt is like a recipe for how to create your environment. By providing the recipe users can use it any way they want.","Q_Score":0,"Tags":"python,django,git-clone,pipenv","A_Id":63414994,"CreationDate":"2020-08-14T14:14:00.000","Title":"Pipenv: Activate virtual environment on new computer after git clone","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am on Windows 10.\nI installed the \"pylint\" package with the command pip install pylint --user and it successfully got installed.\nBut when I try to run the command in command prompt,I am getting the  'pylint' is not recognized as an internal or external command, operable program or batch file.\nI checked the path and it is installed with all the other python packages.How do I solve this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5514,"Q_Id":63417397,"Users Score":0,"Answer":"Found a way to make it work\n\nsearch for \"edit the system environment variables\" in search.\nclick environment variables.\nunder \"system variables\" click \"path\" and click edit.\nclick \"new\".\ngo back and copy the path where python package(pylint) is installed and paste it there.\nclick ok everything.\ncheck now it works...","Q_Score":4,"Tags":"python,pip,command-prompt,pylint","A_Id":64483715,"CreationDate":"2020-08-14T17:24:00.000","Title":"'pylint' 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":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using LassoCV in sklearn. There's always a lot of ConvergenceWarnings. I checked the results and they look good. So I was wondering if it is safe to simply ignore those warnings. A few thoughts I have are:\n\nDoes the warning happens because the magnitude of my response is too big? It will make the loss bigger, too.\nIn most cases, would it be solved when I increase the number of iterations? I'm hesitating to do it because sometimes it takes longer to run but the results didn't improve.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":318,"Q_Id":63419118,"Users Score":0,"Answer":"tl;dr It is fine almost always, to be sure watch learning curve.\nSo, LassoCV implements Lasso regression, which parameters are optimized via some kind of gradient descent (coordinate descent to be more precise, which is even simpler method) and as all gradient methods this approach requires defining:\n\nstep size\nstop criterion\n\nprobably most popular stop criteria are:\na) fixed amount of steps (good choice time-wise, since 1000 steps takes exactly x1000 time compare to 1 step, so it is easy to manage the time spent on training).\nb) fixed delta (difference) between values of a loss function during step n and n-1 (possibly better classification\/regression quality)\nThe warning you observe is because LassoCV uses the the first criterion (fixed amount of steps), but also checks for the second (delta), once number of fixed steps is reached the algorithm stops, default value of delta is too small for most real datasets.\nTo be sure that you train your model long enough you could plot a learning curve: loss value after every 10-20-50 steps of the training, once it goes to a plateau you are good to stop.","Q_Score":0,"Tags":"python,scikit-learn,lasso-regression","A_Id":63419986,"CreationDate":"2020-08-14T19:39:00.000","Title":"Is it safe to ignore the \"ConvergenceWarning\" in sklearn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I run the program, I get this error message.\n\nModuleNotFoundError: No module named 'pynput'\n\nIf I check the pip3 list I can see pynput.\nPlease let me know what I am doing wrong.\nThank you.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":63421319,"Users Score":0,"Answer":"So it works with python file.py and not with python3 file.py","Q_Score":0,"Tags":"python","A_Id":63431664,"CreationDate":"2020-08-14T23:56:00.000","Title":"ModuleNotFoundError: No module named 'pynput' even though it is clearly downloaded","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I run the program, I get this error message.\n\nModuleNotFoundError: No module named 'pynput'\n\nIf I check the pip3 list I can see pynput.\nPlease let me know what I am doing wrong.\nThank you.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":84,"Q_Id":63421319,"Users Score":1,"Answer":"It seems that your pip3 installed pynput to a python installation that you are not using. For example, your pip3 might have installed pynput to python3 while your python refers to python 2.7.","Q_Score":0,"Tags":"python","A_Id":63421481,"CreationDate":"2020-08-14T23:56:00.000","Title":"ModuleNotFoundError: No module named 'pynput' even though it is clearly downloaded","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I tune the parameters for a neural network such as the amount of layers, the types of layers, the width, etc.?  Right now I simply guess for good parameters.  This becomes very expensive and time consuming for me as I will tune a network and then find out that it didn't do any better than the previous model.  Is there better way to tune the model to get a good test and validation score?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":63421907,"Users Score":0,"Answer":"It is totally hit and trail method. You have to play around it. There is no particular method to do that. Try to use GPU instead to CPU to compute fast such as \"Google Colab\". My suggestion is note down all the parameters that can be tunned.\neg:\n\n\nOptimizer: Try to use different optimizer such as Adam,SGD,many more\nlearning rate : This is a very crucial parameter, try to change it from .0001 to 0.001 step by 0.0001.\nNumber of hidden layers : Try to increase no. of hidden layers.\nTry to use Batch Normalization or Drop out or both if required.\nUse correct Loss funtion.\nChange Batch size and Epoch.","Q_Score":0,"Tags":"python-3.x,machine-learning,optimization","A_Id":63422098,"CreationDate":"2020-08-15T02:04:00.000","Title":"How do I properly tune parameters for a neural network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I tune the parameters for a neural network such as the amount of layers, the types of layers, the width, etc.?  Right now I simply guess for good parameters.  This becomes very expensive and time consuming for me as I will tune a network and then find out that it didn't do any better than the previous model.  Is there better way to tune the model to get a good test and validation score?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":63421907,"Users Score":0,"Answer":"Hidden layers, Epochs, batch-size: Try different numbers.\nOptimizers: Adam (gives better results), Rmsprop\nDropout: 0.2 works well in most case\nAlso as a plus, you should also try different activation functions ( like you can use ReLu in the hidden layers and for output layer use sigmoid for binary class classification and softmax for multiclass classification.","Q_Score":0,"Tags":"python-3.x,machine-learning,optimization","A_Id":63422228,"CreationDate":"2020-08-15T02:04:00.000","Title":"How do I properly tune parameters for a neural network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a chatbot with Watson assistant. I would like to add the code here but my question is conceptual.\nLet say a person is chating with my bot. Upon a certain request I want to call the same chat session and set a variable in there ( context variable as said in IBM watson assistant )\nIs this possible ?\nHas anyone one ever done such a thing ?\nPython\nIbm watson assistant python SDK\nIbm cloud functions","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":335,"Q_Id":63423158,"Users Score":0,"Answer":"There is a \"system\" context variable which is used by Watson Assistant to keep track of the chat flow(dialog node) where the user is in at that point in time. You can try using the \"system\" context of the dialog node where you want the user to jump and go back to that previous chat.","Q_Score":1,"Tags":"python,chatbot,ibm-watson,watson-assistant","A_Id":67515201,"CreationDate":"2020-08-15T06:13:00.000","Title":"Ibm watson Assistant setting context variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a chatbot with Watson assistant. I would like to add the code here but my question is conceptual.\nLet say a person is chating with my bot. Upon a certain request I want to call the same chat session and set a variable in there ( context variable as said in IBM watson assistant )\nIs this possible ?\nHas anyone one ever done such a thing ?\nPython\nIbm watson assistant python SDK\nIbm cloud functions","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":335,"Q_Id":63423158,"Users Score":1,"Answer":"There is 2 answer here.\nFirst, if you want to keep going on in your chat session previously opened and still active, you can use the chat session ID to go on where you left it.\nSecond, if you want your bot to remind some data about the user, the sessions are not saved. You need to save data you want to keep in a database. This can be done through Webhooks or through your orchestrator. Then when you start your session, you get all your data from the database for this user and include them in the context. Then your chatbot will react to this context. Of course you need to include this behavior in your skill.","Q_Score":1,"Tags":"python,chatbot,ibm-watson,watson-assistant","A_Id":63616808,"CreationDate":"2020-08-15T06:13:00.000","Title":"Ibm watson Assistant setting context variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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'm making my own chess GUI and am using python chess and stockfish for it. After freezing it into an executable, every time I call chess.engine.SimpleEngine.popen_uci('location\\\\of\\\\stockfish'), it opens the shell for stockfish and if I close the shell, stockfish stops working. What do I do so that the shell is only running in the background and is not visible to the user?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":570,"Q_Id":63424594,"Users Score":1,"Answer":"This is a platform-specific question and I am guessing from 'location\\\\of\\\\stockfish' that Windows is the platform you are interested in.\npopen_uci accepts a ** (extra keywords) parameter and you can use that to pass parameters through to subprocess.Popen(). Use the passthrough parameter startupinfo to provide an instance of subprocess.STARTUPINFO. That in turn can set the win32 flag wShowWindow to do what you want.","Q_Score":1,"Tags":"python,chess,python-chess","A_Id":63424717,"CreationDate":"2020-08-15T09:36:00.000","Title":"Python Chess: How to stop chess.engine.SimpleEngine.popen_uci() from opening the shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to generate a matrix with of shape 10^4 x 10^4 with 100 integer items randomly chosen 1 and 30 and the rest of the elements equals to 0. Can anybody help me? :pray","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":63424797,"Users Score":0,"Answer":"Create the matrix with zeros, and then add the random numbers, or create an empty matrix, add the random numbers, and fill the empty values with 0.","Q_Score":0,"Tags":"python,numpy,matrix,random","A_Id":63424819,"CreationDate":"2020-08-15T10:03:00.000","Title":"How can I generate in Python a matrix with n random elements between 1 and 30 and the rest of the elements equal to zeros?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on building a movie recommendation engine on aws sagemaker environment and i plan to show working demonstration for the same. I am trying to use the streamlit library for running the app.\nAfter running the command: streamlit run app.py, it provides me 2 urls i.e. Network and External urls.\nThe issues is none of the url works. It results in connection timed out, the server does not respond.\nPlease help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":557,"Q_Id":63427965,"Users Score":0,"Answer":"You can try the following url https:\/\/{NOTEBOOK_URL}\/proxy\/8501\/. You may have to change the proxy based on which proxy is used in the Network and External urls","Q_Score":2,"Tags":"python,user-interface,jupyter,amazon-sagemaker,streamlit","A_Id":65145807,"CreationDate":"2020-08-15T15:48:00.000","Title":"Streamlit Browser App does not open from Sagemaker Terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am using Google Cloud Document AI's Form Parser API. After i do the request to the API , I get a response with type google.cloud.documentai.v1beta2.types.document.Document. I tried to write it to JSON using json.dumps()  but it gives JSONDecodeError because JSON.dumps() dont know how to serialize object of type google.cloud.documentai.v1beta2.types.document.Document.\nI am confused how to convert this to JSON\nAny Help Appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":439,"Q_Id":63428499,"Users Score":0,"Answer":"I solved my problem.\nbasically you have to write a function that explores the Document object, and then assemble entire JSON yourself by code.","Q_Score":0,"Tags":"python,json,google-api,google-api-python-client","A_Id":63439205,"CreationDate":"2020-08-15T16:44:00.000","Title":"How do i convert 'google.cloud.documentai.v1beta2.types.document.Document' into JSON?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a discord bot I need to scale.\nThe main features of the bot is to fetch data from a 3rd party website and also keep a database with member info.\nThese 2 operations are quite time consuming and I wanted to have a separate worker\/process for each of them.\nMy constraints:\n\nThere is a limit of GET's per min with the 3rd party website.\nThe database can't be accessed simultaneously for same guild.\n\nI've been researching online for the best way to do this but I come into several libraries\/ways to implement this kind of solution. What are the options I have and their strengths and weaknesses?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":63428663,"Users Score":0,"Answer":"Since there is a limit on the amount of requests from the host, I would first try to run a synchronous program and check whether the limit is reached before the minute ends. If it does then there would be no need to concurrently run other workers. However if the limit is not reached, then I would recommend you use both asyncio and aiohttp to asynchronously get the requests. There's a ton of information out there on how to get started using these libraries.\nThe other option would be to use the good old threading module (or concurrent.futures for a higher level use case). Both options have their pros and cons. What I would do is first try the concurrent.futures (namely, the ThreadPoolExecutor context manager) module since you only have to add like one line of code. If it does not get the job done, then remember: use asyncio if you have to, and threading if you must. Both of these modules are easy to use and understand as well, but they do need to follow a general structure, which means you'll most likely have to change your code.","Q_Score":0,"Tags":"python,discord.py","A_Id":63428890,"CreationDate":"2020-08-15T17:01:00.000","Title":"Python Multiprocessing: worker pool vs process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A little bit of a background about my status:\nI'm currently using OVH Advance 5 Server (AMD Epyc 7451 - 24 c \/ 48 t - 128 GB Memory - 450x2 GB SSD) and I was wondering the specifications I should be using for Postgresql.\nI'll be using multiprocess running 24 Python scripts with 24 different pools (using asynpg to connect), and I usually use up about 40 GB of RAM or so - that means I have around 88 GB to work with.\nBefore I've never really touched any of the settings for Postgres; what kind of values should I be using for:\nShared Memory \/ Max Connections \/ Random Page Cost?\nReading up on it, it says it's recommended that Shared Memory should generally take up about 25% of the free RAM - but other sources say 2 - 4 GB is generally the sweet spot point, so any insight would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":206,"Q_Id":63430833,"Users Score":3,"Answer":"shared_buffers: start with 25% of the available RAM or 8GB, whatever is lower.\nYou can run performance tests to see if other settings work better in your case.\n\nmax_connections: leave the default 100. If you think that you need more than 50 connections, use the connection pooler pgBouncer.\n\nrandom_page_cost: if your storage is as fast with random I\/O as with sequential I\/O, use a setting of 1.1. Otherwise, stick with the default 4.","Q_Score":2,"Tags":"python,postgresql,asyncpg","A_Id":63445765,"CreationDate":"2020-08-15T21:08:00.000","Title":"Shared Memory Buffer Postgresql","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the time complexity of operations in SortedList implementation of sortedcontainers module?\nAs I understand, the underlying data structure is an array list. So does insertion takes O(n) time since the index can be found in O(logn) and then insert the element at the correct location is O(n)?\nSimilarly, popping an element from an index must be O(n) as well.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1479,"Q_Id":63430867,"Users Score":0,"Answer":"Insert, remove, get index, bisect right and left, find element inside list, are all log(n) operations. Its similar to treeset and multiset in java and c++, implemented with AVL tree or red black tree.","Q_Score":1,"Tags":"python,sortedlist,sortedcontainers","A_Id":72413340,"CreationDate":"2020-08-15T21:15:00.000","Title":"Time complexity of operations in SortedList - Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am about to design an app that requires to do some medium level of computation (training some small machine learning model).\nI am thinking about designing the app with django. Was wondering if django can allow that some of these computations can be done in the client\u2018s browser, i.e. using its memory and cpu. Some initial tips of where to start looking at will be much appreciated.\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":109,"Q_Id":63431751,"Users Score":1,"Answer":"That's the reason Django is mostly used for building APIs.  If you want the View (Template in Django) to update, a request would be made to the server's Controller (View in Django) to render a new version of the webpage.  I would highly recommend a front end framework and just use Django for your api if you want to run client side computations.","Q_Score":1,"Tags":"python,django,client-server","A_Id":63431988,"CreationDate":"2020-08-15T23:38:00.000","Title":"Can django do computations in the client?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am about to design an app that requires to do some medium level of computation (training some small machine learning model).\nI am thinking about designing the app with django. Was wondering if django can allow that some of these computations can be done in the client\u2018s browser, i.e. using its memory and cpu. Some initial tips of where to start looking at will be much appreciated.\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":109,"Q_Id":63431751,"Users Score":1,"Answer":"Yes, You would need to use Javascript and call views you made in Django.\nYou can use any javascript library, also Vue if you need a framework.","Q_Score":1,"Tags":"python,django,client-server","A_Id":63434106,"CreationDate":"2020-08-15T23:38:00.000","Title":"Can django do computations in the client?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"As an assignment for one of my classes, the professor had us download a file containing python code as well as a couple of text files that the python code will analyze.\nThe problem is, when I click to open the python file, the command window opens, then immediately closes. I can get it to stop from closing if I click on it fast enough, but that stops the code from loading, and any keystroke causes it to close again.\nIt's the same file every other student downloaded and used with no issue. I've tried re-downloading the file, re-installing python, even trying on a different computer. I've also tried opening it by entering the path file name in the command window with no success. Also no luck trying it in Jupyter Notebook or CodeLab. (And of course, no luck experimenting with the slew of possible solutions on previous Stack Overflow, Reddit, etc. questions).\nAny ideas on the potential cause and\/or solution?\nEdit: cause unknown, but the solution was opening the file with Sypder console.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":670,"Q_Id":63432385,"Users Score":0,"Answer":"the file closes immediately because It ended and returned 0, to stop that from happening you can add at the end of the python code something like that:\nending = input(\"press key to exit\")\nor just import time and use\ntime.sleep(5)\nyou can open your file in the cmd\/terminal window and you will be able to see the results","Q_Score":1,"Tags":"python-3.x,file","A_Id":63515369,"CreationDate":"2020-08-16T01:45:00.000","Title":"Python file immediately closes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"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":"When I try to import geopandas package in \"Google Colaboratory\" I got the error \"ModuleNotFoundError: No module named 'geopandas'\".\nI will appreciate your help. Thanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5719,"Q_Id":63433405,"Users Score":0,"Answer":"Try running !pip install geopandas in a new cell.\nDon't forget the ! Exclamation mark.\nNote:\nThis method works for other libraries too.\nSimply !pip install 'package_name'\nIf you are running Python on your local machine, then open up Command Line and type        pip install 'package_name' to install a package.","Q_Score":1,"Tags":"python,google-colaboratory,geopandas","A_Id":63433559,"CreationDate":"2020-08-16T05:15:00.000","Title":"Colab error : ModuleNotFoundError: No module named 'geopandas'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a module of functions in the form of a separate module.py file. I make updates to the functions in the module as I develop my code. However, when I go back to the run file (main) to call the updated functions, the updates have not been picked up (i.e., the run file calls the old version of the function), and often aren't picked up unless I re-start PyCharm.\nI have tried:\n\nSaving the module.py file, then reimporting it in the run file before calling functions from it\n\nClearing the console using Rerun (green curved arrow in console) before re-running the script\n\nAdding a 'reload(module)' statement in before the function call in the run file\n\n(For the avoidance of doubt, the import statement for the module is in the run file and works the first time I call it. It just doesn't efficiently pull through updates when I reimport it).","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":735,"Q_Id":63435837,"Users Score":1,"Answer":"Note: JetBrains support have since suggested the following as a solution.\n\"First of all, if you're using version 2020.1, I suggest updating to 2020.2, and then check File | Settings | Appearance & Behavior | System Settings | Autosave settings to make sure the changes are saved. If this doesn't help and the issue is still reproduced in PyCharm, please try running your code from the terminal outside of IDE, and check if the behavior is the same.\"\nI can't update to the new version yet to test it (some of my critical plugins are incompatible), but this may be useful for others. In the meantime, clearing the console in between each run using Rerun (curved green arrow) seems to be working now.","Q_Score":9,"Tags":"python,pycharm,libraries","A_Id":63470638,"CreationDate":"2020-08-16T10:37:00.000","Title":"Changes in the module are not importing to the run file (unless PyCharm is restarted)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an LSTM that utilizes binary data, ie the labels are all 0's or 1's.\nThis would lead me to use a sigmoid activation function, but when I do it significantly underperforms the same model with a tanh activation function with the same data.\nWhy would a tanh activation function produce a better accuracy even though the data is not in the (-1,1) range needed for a tanh activation function?\nSigmoid Activation Function Accuracy:\nTraining-Accuracy: 60.32 %\nValidation-Accuracy: 72.98 %\nTanh Activation Function Accuracy:\nTraining-Accuracy: 83.41 %\nValidation-Accuracy: 82.82 %\nAll the rest of the code is the exact same.\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":330,"Q_Id":63438191,"Users Score":1,"Answer":"In the interval of (0, 1] if gradient is diminishing over time t, Then sigmoid gives better result. If gradient is increasing then tanh activation function.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":63438468,"CreationDate":"2020-08-16T14:41:00.000","Title":"Keras Activation Functions Tanh Vs Sigmoid","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have trained a image classification model using keras which gives training acc of 98%, validation acc of 98% testing acc of 90%, but performs very poor on new input images. I don't know the why??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":63439218,"Users Score":0,"Answer":"You write that you trained an image classification model. Let's say that you want to write an app which lets people photograph their dinner and it returns a prediction on which food it is.\nIf you train your model with \"perfect\" images, i.e. high-quality images that are sharp, but now you let your model predict a \"real-life\" which was taken in a dark restaurant, then you have the problem: You let model predict sth it basically didn't learn. That might be the issue.\nI think it would be great if you could provide us with some typical images of your training-dataset and the dataset you are predicting on. Maybe the ones you took for predictions are not typical for the whole training dataset.","Q_Score":0,"Tags":"python,keras,deep-learning,image-classification","A_Id":63441964,"CreationDate":"2020-08-16T16:19:00.000","Title":"Keras model performs well in training, validation and also in evaluating but performs poor when predicting a new image","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large structure of primitive types within nested dict\/list. The structure is quite complicated and doesn't really matter.\nIf I represent it in python's built-in types (dict\/list\/float\/int\/str) it takes 1.1 GB, but if I store it in protobuf and load it to memory it is significantly smaller. ~250 MB total.\nI'm wondering how can this be. Are the built-in types in python inefficient in comparison to some external library?\nEdit: The structure is loaded from json file. So no internal references between objects","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":419,"Q_Id":63439648,"Users Score":0,"Answer":"This is normal and it's all about space vs. time tradeoff. Memory layout depends on the way how a particular data structure is implemented, which in turn depends on how it is going to be used.\nA general-purpose dictionary is typically implemented with a hashtable. It has a fixed-size list of buckets that store key-value pairs. The number of items in a dictionary can be smaller, equal or bigger that number of buckets. If smaller, space is wasted. If bigger, dictionary operations take a long time. A hashtable implementation usually starts with a small initial bucket list, then grow it as new items are added to keep the performance decent. However, resizing also requires rehashing which is computationally very expensive, so whenever you do it, you want to leave some room for growth. General-purpose dictionaries are a trade-off between space and time because they don't \"know\" how many elements they are supposed to contain and because there is no perfect hash function. But in a good-enough case, a general-use hashtable will give you near-O(1) performance.\nWhen data is serialized it's a different story. Data in transit does not change, you are not doing lookups with it, it is not subjected to garbage collection, boundary alignment and so on. This means you can simply pack keys and values one after another for space efficiency. You need virtually no metadata and no control structures as long as the values can be reconstructed. On the downside, manipulating packed data is very slow because all operations take O(n) time.\nFor this reason, you will almost always want to:\n\nconvert data from time-efficient into space-efficient format before sending it\nconvert data from space-efficient into time-efficient format after receiving it.\n\nIf you are using nested dictionaries (or lists, which are in many ways similar), the differences will add up and become even more pronounced. When you know the number of items in advance and the data does not change much, you can probably get some improvement by preallocating the memory for it, such as dict.fromkeys(range(count)).","Q_Score":6,"Tags":"python,json,python-3.x,protocol-buffers","A_Id":63488729,"CreationDate":"2020-08-16T16:58:00.000","Title":"Why protobuf is smaller in memory than normal dict+list in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I intend to have a program detect when a login failure occurs. I intend to use this program on mac, in case that is important. Could this solution detect how many login failures occur, or would I use a variable to determine how many have occurred?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":63439810,"Users Score":0,"Answer":"As mentioned by @JaniniRami, you can scrape the data from the macOS logs located in \/var\/log\/asl.log (except for macOS High Sierra), and see if there were any authentication failures in the log (such as warnings or errors)","Q_Score":0,"Tags":"python,macos,authentication","A_Id":63440166,"CreationDate":"2020-08-16T17:14:00.000","Title":"How to detect a user login failure on a mac?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a class with some simple methods, and I want to create a sub-class of this which builds on these methods and adds some more functionality.\nSo, I inherit from this class, and build on the simple methods in the parent class in my child class.\nNow, how do I ensure that you can't call the (simple) methods in the parent class from an instance of the child class from outside the class? I want the parent class to be used for the simple methods and the child class to be used for the more complex methods.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":126,"Q_Id":63440464,"Users Score":0,"Answer":"Python's philosophy is \"we are all consenting adults\". If a class has a method, then that method can be called on any object of that class, or of a child class of that class. Therefore, what you're asking isn't really possible.\nThere's still something you could do. If you had a method on the parent class, you could override that method on the child class and have it do nothing. In this way, creating an instance of the child class and calling one of the parent class methods will instead call the overridden method you wrote and not actually do anything. Yet, I'd consider the above bad practice; it's definitely not recommended.","Q_Score":0,"Tags":"python,python-3.x,class,oop","A_Id":63440575,"CreationDate":"2020-08-16T18:18:00.000","Title":"How to ensure the child class can't access the parent's class method outside of the class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"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 have some pyspark code that I package as a library so that it can be pip installed and used in other project.  The code loads a parquet file which I include with my library.  This works fine in most environments but it doesn't work on databricks.\nAfter pip installing on databricks I can see the files at file:\/databricks\/python\/lib\/python3.7\/site-package\/my_package\/my_parquet_dir, but the load parquet file call doesn't work.\nIf I just let it try to load from \/databricks\/python\/lib\/python3.7\/site-package\/my_package\/my_parquet_dir it doesn't find the directory at all.\nIf I load from file:\/databricks\/python\/lib\/python3.7\/site-package\/my_package\/my_parquet_dir, it finds the directory but acts like the directory is empty.  It almost seems like the parquet file load is able to recognize the top level directory (as long as I prepend \"file:\" to my path), but that subsequent calls be the loader to load individual files are failing because it's not prepending \"file:\".\n...I'm just hoping someone has experience accessing data from file:\/databricks and knows some sort of trick.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":169,"Q_Id":63444234,"Users Score":1,"Answer":"turns out indeed preprending \"file:\" was the key and the issue I had was that in one spot I had misspelled it as \"File:\"","Q_Score":1,"Tags":"python,file,databricks,os.path","A_Id":63472995,"CreationDate":"2020-08-17T03:37:00.000","Title":"On databricks I can't read from file:\/databricks\/python\/lib\/python3.7\/site-package\/my_package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script using the scapy 2.4.3 sniff() fuction, running in a thread:\nsniff(iface=self.iface, store=0, filter=\"(ip and not src net %s) and (udp dst port %s)\" % (self.ip_src, str(self.dport)), prn=self.handle_someip_packet)\nIt came to my attention that the execution of this sniffing thread is take too much time.\nI would like to set the conf.layers.filter([UDP]), but I get the error:\nAttributeError: 'LayersList' object has no attribute 'filter'\nWhat am I doing wrong?\nAny other ideas to speed the scapy sniffing?\nThanks in advance,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":490,"Q_Id":63447758,"Users Score":0,"Answer":"You are probably using an older version of scapy without realizing. Try using 2.4.4rc2 (pip3 install scapy --pre)\nYou can check the version using scapy.__version__","Q_Score":1,"Tags":"python,multithreading,performance,filter,scapy","A_Id":63449833,"CreationDate":"2020-08-17T09:02:00.000","Title":"Scapy speed up sniff performance","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Out of meterological data with 3 dimensions (lat, lon and time) I selected a subset and aggregated values of two different timespans\/years into monthly means.\nSo at the end I have a DataSet where the dimension are the months (1-12) and there are two variables... Mean Values of timespan 1 and Mean Values of timespan 2.\nNow I just want to plot these two variables on a simple Line chart to compare them. I already spent hours and days to find any advice on this, but it seems, that xarray isn't made for plotting multiple variables over each other? (Can't find anything useful for this)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":524,"Q_Id":63448843,"Users Score":1,"Answer":"So, you have one DataSet with two climatologies? And if you run data.clim1 or data.clim1 in the console, you see the the data sets and your climatologies are different? (Just to make sure, that you do not plot the same thing over each other.)\nYou should be able to plot them with:\n\nimport matplotlib.pyplot as plt \nplt.figure() \ndata.clim1.plot() \ndata.clim2.plot()\n\nHope that works. :)","Q_Score":0,"Tags":"python,plot,python-xarray","A_Id":63486658,"CreationDate":"2020-08-17T10:17:00.000","Title":"Plot multiple variables of a 1-Dimensional xarray DataSet","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a current project, I am planning to merge two very large CSV files with Dask as an alternative to Pandas. I have installed Dask thorough pip install \"dask[dataframe]\".\nWhen running import dask.dataframe as dd, I am however receiving the feedback ModuleNotFoundError: No module named 'dask.dataframe'; 'dask' is not a package.\nSeveral users seem to have had the same problem and were recommneded to install the module via Conda, which has not helped either in my case.\nWhat is the reason for the module not being found?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2058,"Q_Id":63452968,"Users Score":4,"Answer":"As user John Gordon mentioned, the reason for the error notification is that a  file within the same folder was named dask.py. Renaming the file solved the situation within seconds.\nAs a general rule\/conclusion: is as advisable to not use .py file names that directly relate to Python modules.","Q_Score":2,"Tags":"python,pandas,dask,dask-dataframe","A_Id":63456511,"CreationDate":"2020-08-17T14:30:00.000","Title":"ModuleNotFoundError: No module named 'dask.dataframe'; 'dask' is not a package","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For some reason, I cannot get pyinstaller to work.\nI did:\npip install pyinstaller\nand then did:\npyinstaller in terminal\nthis is the error I got\n'pyinstaller' is not recognized as an internal or external command operable program or batch file.\nHow do I fix this?\nI am using:\n\nPython 3.8 (From Microsoft Store)\nPyinstaller 4.0\n\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":253,"Q_Id":63453324,"Users Score":0,"Answer":"I looked at the reviews on python 3.8 in MS store, a reviewer said pyinstaller isn't working for them. So idk if it may be the type of python.exe that I am using or my windows machine is a little restrictive.\nI also heard pyinstaller has errors with 3.5+ and works better with python 2.7","Q_Score":0,"Tags":"python,exe,pyinstaller","A_Id":63475653,"CreationDate":"2020-08-17T14:50:00.000","Title":"How do I get pyinstaller to work correctly to convert my files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was reading a Machine Learning book and came across this in the CNN chapter.\n\nThe weights of a convolutional layer are represented as a 4D tensor of\nshape [fh, fw, fn\u2032, fn]. The bias terms of a convolutional layer are\nsimply represented as a 1D tensor of shape [fn]. Where fh is the heigher of the receptive field and fw is the width of the receptive field. fn' is the number of feature maps in the previous layer and fn is the number of feature maps in the current layer.\n\nI am trying to understand what each number in the given order signifies. Is it creating a rank 4 matrix where each entry represents the weight connecting an output neuron from the previous layer with specified feature map and location in the receptive field to the current ouput neuron?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":388,"Q_Id":63455361,"Users Score":3,"Answer":"fn':\nIt represents number of channels in previous layer which also indirectly specifies depth(or channels) of each kernels in current layer.\nfn:\nIt represents number of feature maps in current layer i.e. number of different kernels in current layer. Because each kernel outputs single channel.\nfw:\nIt represents kernel width.\nfh:\nIt represents kernel height.\nSuppose  [fh, fw, fn\u2032, fn] = [3, 3, 10, 20] then layer(weight) will be of size 20x10x3x3. Each kernel will be of size 10x3x3 (where 3x3 is spacial and 10 is depth) and there will be 20 such kernels. These kernels operate on previous 20 feature maps to output 10 feature maps.\nAnd each entry in this 4d matrix representing weight will be shared. It doesn't connect neurons one to one because of convolution. Convolution's main advantages itself is parameter sharing and receptive field\/local connectivity.","Q_Score":0,"Tags":"python,tensorflow","A_Id":63455927,"CreationDate":"2020-08-17T16:58:00.000","Title":"4D Tensor Shape","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a hard time understanding how to refractor already written python scripts into celery. What needs to be changed in the script? I can't find any tutorials on the subject.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":36,"Q_Id":63455718,"Users Score":1,"Answer":"My advice - use logic. You notice all examples in Celery documentation contain some sort of task, which is typically a Python function (it can be a class too but I see that rarely). So the first thing you should think about is how to wrap your existing code in such a way that it becomes a call to a function with relevant parameters. Once you have that function, decorate it into a Celery task, and you are good to go.","Q_Score":0,"Tags":"python,redis,celery,scheduled-tasks,flower","A_Id":63464764,"CreationDate":"2020-08-17T17:22:00.000","Title":"How to implement already written python scripts into Celery","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"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":"What is the difference between:\npip install --upgrade pip\nand\npython -m pip install --upgrade pip\nand why is python -m pip install --upgrade pip generally favoured?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1810,"Q_Id":63459011,"Users Score":0,"Answer":"If i am correct, pip install --upgrade pip and python -m pip install --upgrade pip are the same unless you specify the pip or python version.\nThe latter is preferred because it attempts to upgrade the pip associated with the specified python version (e.g. python3.7 -m pip install --upgrade pip) even if the main python version is different (python command may refer to any python version).","Q_Score":2,"Tags":"python,pip","A_Id":63459135,"CreationDate":"2020-08-17T21:40:00.000","Title":"`pip install --upgrade pip` vs. `python -m pip install --upgrade pip`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between:\npip install --upgrade pip\nand\npython -m pip install --upgrade pip\nand why is python -m pip install --upgrade pip generally favoured?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1810,"Q_Id":63459011,"Users Score":4,"Answer":"The difference is between pip and python -m pip; the rest of the command doesn't matter. The reason to prefer the latter is that you're ensuring that the python you normally use is the one which will provide the pip module you invoke. Otherwise, there is a risk that the pip executable found in your PATH is from an unrelated or out of date Python installation; it might install packages, but your regular python invocation won't find them (because they're installed for a non-default Python).\nYou can also modify the second command to invoke specific Python executable names (python2.7 vs. python3.8), or even absolute paths if you might have versions with the same name installed in multiple places.","Q_Score":2,"Tags":"python,pip","A_Id":63459139,"CreationDate":"2020-08-17T21:40:00.000","Title":"`pip install --upgrade pip` vs. `python -m pip install --upgrade pip`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python program that reads in a file of names, sorts them alphabetically and then outputs a new sorted text file. I would like to make this into an excuteable so that it works on both Mac and Windows. I tried using pyinstaller\npip install pyinstall\npyinstaller --onefile file_name.py\nIt output an excuteable that worked on my mac. When I put the executeable on my wife's windows, it didn't work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":63459187,"Users Score":0,"Answer":"For python, an executable only works on the OS for which it was made. If you want to use it on Windows, create it in a computer with Windows, for Mac, create it in a Mac computer.","Q_Score":0,"Tags":"python,windows,macos,executable","A_Id":63459261,"CreationDate":"2020-08-17T21:58:00.000","Title":"Create executeable for all platforms","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Why does the following function call not display anything to the console in Python 3?  Does this have something to do with type hinting?\nprint:(\"Hello, world!\")\nI can't for the life of me figure out why the colon causes nothing to display but is not considered a syntax error.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":205,"Q_Id":63460110,"Users Score":1,"Answer":"Everything after the : is a type hint, so your statement is just print, which does nothing.","Q_Score":1,"Tags":"python,python-3.x,printing","A_Id":63460138,"CreationDate":"2020-08-18T00:05:00.000","Title":"Why does this print nothing in Python 3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"So I've been trying to make a python program which can save all my ideas for future projects(I was bored).\nEverything has been going well, its just that I ran into a small problem. To save my ideas, I use input() and then appending the input into a list. I realized that whenever you put something inside the list, whenever you re-run the program, the string you put into the list doesn't save. So I tried pickling but the data inside of it keeps getting overwritten. Could someone help me with this? I don't know where to start. Thanks for the help!\n(Please keep in mind that I'm a beginner)","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":553,"Q_Id":63462448,"Users Score":1,"Answer":"As a fun project for you, you can learn how to connect to a database and insert it as a row there. It is a simple procedure. You can try with SQLite, its easy and will be great learning for you.","Q_Score":0,"Tags":"python,python-3.x,pickle","A_Id":63462503,"CreationDate":"2020-08-18T05:36:00.000","Title":"How to save user input and store for later use in Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to connect ElasticSearch to Superset for visualization. When I checked in Superset in Sources> Databases, it mentioned to use SQLAlchemy URI and Database for testing the connection.\nIn our case, ElasticSearch is connected with Python library and not using SQLAlchemy.\nIs there any way to connect Elastic Search with Superset using Python library and if so could you please help by mentioning the way to connect.\nThanks in advance.\nRegards,\nNaveen.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2033,"Q_Id":63464392,"Users Score":2,"Answer":"you can connect by the way mentioned in the docs.You need to add the dbapi python package mentioned in superset installer document and that will in turn help you connect to the elk using the url elasticsearch+http:\/\/{user}:{password}@{host}:9200\/\npip install elasticsearch-dbapi","Q_Score":1,"Tags":"python,elasticsearch,superset","A_Id":63639134,"CreationDate":"2020-08-18T08:08:00.000","Title":"Connecting ElasticSearch to Superset","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have an Ubuntu server and our team is discussing whether to install a system-wide Python version with PyTorch etc or to create local installations per user (such as Conda). One of the problems is HDD space given to each user, as many local installations with all the dependencies might take some space.\nDid you have similar dilemmas in your cases? Any opinions on this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":40,"Q_Id":63464911,"Users Score":1,"Answer":"The Conda package cache location (pkgs_dirs) can be shared across users while still maintaining separate user-specific envs (envs_dirs). As long as the package cache and environment locations are on the same physical disk, then Conda will use hardlinks to minimize redundancy. See conda config --describe pkgs_dirs.","Q_Score":0,"Tags":"python,ubuntu,conda","A_Id":63477696,"CreationDate":"2020-08-18T08:41:00.000","Title":"Server python installation - local or system wide","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had Anaconda and conda installed on my machine before, but deleted the .bash_profile conda script in my ~\/.bash_profile. Then, I deleted the anaconda navigator, and the entire anaconda3 directory from \/opt\/anaconda3.\nThen installed the anaconda navigator and conda again, but they came with python 3.8 installed. I wanted to downgrade Python to 3.7.4, so I run the following command: (in the base env) conda install python=3.7.4.\nIt has been stuck in Solving Environment for about 10 minutes or so, and I don't know what to do.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7405,"Q_Id":63466861,"Users Score":0,"Answer":"I had similar problem in Anaconda 4.10.3 and was fixed by creating a new environment, as suggested by @Paul H. Thanks.","Q_Score":2,"Tags":"python,anaconda,conda","A_Id":69503704,"CreationDate":"2020-08-18T10:37:00.000","Title":"Conda install taking too long","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"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":"We have Azure Kubernetes clusters running (one per stage on DEV, TST, PRD) where we need several Python scripts to run periodically, which is what we are using APScheduler (3.6.0) for. The default in-memory jobstore is used.\nSome days ago, however, I found out that APScheduler is behaving different than expected. It happens on all three stages:\n\nA specific job, which is set to run at minute 0 and minute 30 every hour, has stopped running between 21:30 and 00:00 since March 27, 2020.\nThis same job runs at weird times, e.g. at ~:15 and :45, frequently.\nJobs are getting skipped whilst they are scheduled to run every 5 minutes. The logging says 'Launching job', but then does not state the following, which it should: Job \"x_job (trigger: cron[month='', day='', day_of_week='', hour='', minute='0,5,10,15,20,25,30,35,40,45,50,55'], next run at: 2020-08-18 10:35:00 UTC)\" executed successfully. It occurs that at some point, two runs are triggered at the same time but not necessarily the next run.\n\nSteps undertaken but not with desired result:\nIncrease the number of process_pool_workers and thread_pool_max_workers and set misfire_grace_time:\nExecutor\nthread_pool_max_workers: 50\nprocess_pool_max_workers: 20\nJob defaults\njob_defaults_coalesce: True\njob_defaults_max_instances: 3\nmisfire_grace_time: 120\n\nSet timezone='UTC' for scheduler and in the add_jobs.\nscheduler = BlockingScheduler(executors=executors, job_defaults=job_defaults, timezone='UTC')\nscheduler.add_job(launch_profile_job, CronTrigger.from_crontab(scheduler_config.profile_job), timezone='UTC')\n\nI also have checked the resources of the cluster, but CPU and memory of the scheduler are not even close to their limits. We also have quite a low avg. active pod count of 25, and even it this would become an issue to our K8s cluster, autoscaling is enabled.\nDoes anyone here have a clue what might be going on?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":498,"Q_Id":63467197,"Users Score":1,"Answer":"Don't use in-memory job store instead go for persistence stores like Redis, mongo etc.,\nIf you need your jobs to persist over scheduler restarts or application crashes, you've to choose the persistence job stores.\nAPscheduler supports the following persistence job stores.\n\nSQLAlchemy\nMongoDB\nRedis\nRethinkDB\nZooKeeper","Q_Score":1,"Tags":"python,azure,docker,kubernetes,apscheduler","A_Id":63871502,"CreationDate":"2020-08-18T10:59:00.000","Title":"APScheduler skips jobs and runs at other times","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Just finished my studies on python 3, build some app and I want to on to my main project. Please how can I build a video chat application using python","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":990,"Q_Id":63467910,"Users Score":1,"Answer":"That is quite an ambition challenge! I would start by writing a GUI interface so that users can start\/end\/pause the video call and mute their camera or microphone. Tkinter, wxPython, and PyQt are a few decent ones. After that, I would do some research on networking and figure out how to send the video to and from each recipient. I would look into RTP (Real-Time Transport Protocol) for that. You could even establish a UDP connection between the two. The number of approaches are endless! I encourage you to do some more in-depth research before you begin.\n**Note that this process would be different if you were to make a video chat website.\nBest of luck!","Q_Score":0,"Tags":"python,videochat,video-conferencing","A_Id":63468377,"CreationDate":"2020-08-18T11:43:00.000","Title":"How do I build a video chat application using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After updating macOS to Catalina, I can no longer import modules like Pandas, Numpy or Scipy--I get a ModuleNotFoundError. Interestingly, import os and import sys do not throw this error.\nDoes anyone know why this is and how to fix it?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":63468915,"Users Score":0,"Answer":"Probably after update you have another default Python interpreter.\nYou either should find where \"the old one\" is located or install again all libraries needed (e.g. pip install pandas)","Q_Score":1,"Tags":"python-3.x,macos,python-import,python-module,macos-catalina","A_Id":63469530,"CreationDate":"2020-08-18T12:44:00.000","Title":"Python modules not working after macOS Catalina update","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to install PySyft via pip on a Jetson TX2.\nUnfortunately, I have a big problem with the dependencies here and the Jetson TX2. As an example, I want to change the dependency torch==1.4.0 to torch>=1.4.0 or torch==1.6.0 because I can't install another torch version for the Jetson.\nI have already tried the following:\npython3 -m pip download -w syft==0.2.3a1 --no-deps\nand get a syft-0.2.3a1-py3-none-any.whl which I can unzip and read out the dependencies via the METADATA.\nCan I change it now as described above and build a *.whl again to install it using pip afterwards?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":282,"Q_Id":63469539,"Users Score":0,"Answer":"Just... modify the extracted METADATA, recompress into a zip and rename to the same name as the original wheel?\nWhile you're at it, you may want to increment or change the version of the modified package.","Q_Score":0,"Tags":"python,installation,pip,pysyft","A_Id":63469698,"CreationDate":"2020-08-18T13:19:00.000","Title":"How can I download a pip whl, change the version of dependencies and build a whl file again to install it with pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Say I have two arrays\n[1, 3 , 5] and\n[2, 4, 6],\nwhat's the best way of merging them to yield [1, 2, 3, 4, 5, 6] without using loops or recursion and just numpy?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":301,"Q_Id":63469749,"Users Score":0,"Answer":"You can do it without numpy:\nJust add them, a = [1,3,5]+[2,4,6] and then sort them sorted(a)","Q_Score":1,"Tags":"python,numpy,concatenation,numpy-ndarray","A_Id":63469780,"CreationDate":"2020-08-18T13:31:00.000","Title":"Merge two arrays in a zipper pattern","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just finished working on a PyCharm project (using python 3.7), which uses libraries downloaded using PyCharm's built in functionality.  I just want to send this project to my boss so that he can simply run it by clicking on it, without having to go through downloading PyCharm and downloading the applicable packages.  Please tell me that there is a way to do this.  Thank you","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":750,"Q_Id":63473594,"Users Score":0,"Answer":"You could solve this issue by converting the .py file to an executable file or .exe file....\nHopefully it helped..thx","Q_Score":0,"Tags":"python,pycharm","A_Id":63473611,"CreationDate":"2020-08-18T17:18:00.000","Title":"Sending a PyCharm project to someone","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just finished working on a PyCharm project (using python 3.7), which uses libraries downloaded using PyCharm's built in functionality.  I just want to send this project to my boss so that he can simply run it by clicking on it, without having to go through downloading PyCharm and downloading the applicable packages.  Please tell me that there is a way to do this.  Thank you","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":750,"Q_Id":63473594,"Users Score":0,"Answer":"A simple way to that would be sharing it on github with a requirements.txt file containing all the dependencies which then can be installed using python -m pip install -r requirements.txt.\nOr You can use pyinstaller --onefile <yourfile.py> to create a .exe file which could be run without any requirements on windows.","Q_Score":0,"Tags":"python,pycharm","A_Id":63473710,"CreationDate":"2020-08-18T17:18:00.000","Title":"Sending a PyCharm project to someone","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"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":"Q: In creating a python distribution using setup.py, how can I define Python code that will be run by pip at installation time (NOT at build time!) and runs on the installation target machine (NOT on the build machine!)\nI have spent the past seek searching the web for answers, reading contradictory documentation pages, and viewing multiple videos about setup.py.  But in all this research can't find even one working example of how install time tasks can be specified.\nCan someone point me at a complete working example?\nBackground: I am writing Python code for an application that is controlling a specialized USB peripheral my company is making, the processor where this will be installed is embedded\/bundled with the peripheral and control software.\nWhat's Needed: During the installation of the controlling application,  I need the installing program (pip?) to write a configuration file on the install target machine. This file needs to include machine specific information about the target machine acquired using calls to functions imported from Lib\/platform.py.\nWhat I tried: Everything I've tried so far either runs at build time on the build machine (when setup.py runs and thus picks up the WRONG information for the target machine), or it merely installs the code I want to run on the target, but does not run it. It thus requires manual intervention by the user after the pip installation  but prior to attempting to run the program they think they just installed, to run the auxiliary program that creates the installation config file.  Only after this 2 step process can the user actually run the installed (and now properly configured) application.\nSource code: Sorry. All my failed attempts to put functions in setup.py (which only run on the build machine, at build time) would only further confuse any readers and encourage more misleading wild goose chases down pointless rat holes.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":144,"Q_Id":63474886,"Users Score":1,"Answer":"If my users were sophisticated python developers who are comfortable with command line error messages, the link that @sinoroc has provided in the previous comment would have been an interesting solution.\nGiven that my users are barely comfortable installing packages from the App Store or Google Play store, the referenced work around is probably not right for me.\nBut given that install time functions are regarded as bad practice, my workaround is to alter the installed program so that its first action is to check for the presence of the necessary configuration file every time the program runs.\nWhile this checking is seemingly unnecessary after the first run, it consumes only minimal CPU resources and would be more robust if the configuration file is ever accidentally deleted.","Q_Score":1,"Tags":"python,installation,build,pycharm,setup.py","A_Id":63498265,"CreationDate":"2020-08-18T18:48:00.000","Title":"In setup.py, how can I code a function that will run at install time (on the installing computer) NOT at build time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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 working with python3 and using flask I tried to install flask_wtf and wtforms but keep getting error from pylint on my imports. I re-installed flask_wtf, checked my path, and closed VsCode code already. Any help is appreciated","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":577,"Q_Id":63477047,"Users Score":-1,"Answer":"The error went away with pip install email_validator","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":63504240,"CreationDate":"2020-08-18T21:43:00.000","Title":"Vscode not able to import flask_wtf and wtforms","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Maybe is my question a little bit weird, but I am looking for an answer since couple days.\nThe only thing what I found were sockets and asyncio(dont really know what it is) , but with sockets you can establish a connection just in your localhost.\nIs there any otherways to creat a connection between two quite different pcs or between a client and server wireless.\nIf you have any ideas just write, maybe it could be helpful. As a beginner in python, I would be happy if you guys could show me some way to find easy tutorials (maybe some websides) and important things to learn. So everything could be helpful, I am just curious. :)","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":63478715,"Users Score":0,"Answer":"what you can do is create two seperate python files: client.py and server.py\nThe client.py will be trying making the connection. the server.py will be trying to receive that connection. You mentioned you weren't familiar with socket. Socket is a low-level networking interface when you import the library socket to a file, you are able to make system calls between different computers to interact with each other.","Q_Score":0,"Tags":"python,sockets,networking,server,client","A_Id":63478833,"CreationDate":"2020-08-19T01:20:00.000","Title":"How to establish a connection between two computers wirelessly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Maybe is my question a little bit weird, but I am looking for an answer since couple days.\nThe only thing what I found were sockets and asyncio(dont really know what it is) , but with sockets you can establish a connection just in your localhost.\nIs there any otherways to creat a connection between two quite different pcs or between a client and server wireless.\nIf you have any ideas just write, maybe it could be helpful. As a beginner in python, I would be happy if you guys could show me some way to find easy tutorials (maybe some websides) and important things to learn. So everything could be helpful, I am just curious. :)","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":63478715,"Users Score":1,"Answer":"You can create a server \/ client pair, through executables running on both PCs. TCP and UDP sockets can be used to communicate outside 'localhost'. You can do this rather easily in many programming languages like C, C#, python amongst others.","Q_Score":0,"Tags":"python,sockets,networking,server,client","A_Id":63483150,"CreationDate":"2020-08-19T01:20:00.000","Title":"How to establish a connection between two computers wirelessly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using pygame and I've been working so far in a large monitor, but now I need to work on a small laptop, whose screen is much smaller than the mentioned monitor. The dimensions I gave to the display surface and the items blitted to it work well on the previous monitor but it is too large on the laptop and therefore I cannot reach all buttons. Since I can't seem to find a way to resize everything proportionaly, is there an easy way to add a vertical and horizontal scroll bar in order to navigate around the display surface?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":342,"Q_Id":63479241,"Users Score":0,"Answer":"I don't think that you can add a scroll bar. What you can do is shift the x or y of everything when you press the corresponding arrow keys. But as said by Ted Klein Bergman, it is better to simply resize everything.","Q_Score":1,"Tags":"python,pygame","A_Id":63479501,"CreationDate":"2020-08-19T02:39:00.000","Title":"Adding a vertical and horizontal scroll bar to the display surface in Pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to design a system in python where my customers can create an order and it will be stored in an array or similar type of structure that will be able to constantly expand to store more orders as they are placed. What is the best way to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":63480318,"Users Score":0,"Answer":"How big would you expect and order to get and how many orders could there be? Also what is stored in an order?\nIf you use numpy arrays you have the problem that increasing the size of an array is a very expensive process, so doing it many times on large arrays would be problematic. Numpy arrays also are for data that is all the same type, so you would not use this for things that are combinations of strings (name, item), integers (item reference), and floats (cost).\nA simple list is likely the easiest and most inclusive choice. You can put whatever you like in a list and increase the size easily since a list is actually just pointers.\nA dictionary could be useful if you are expecting to have to search the list often, or have a clear key-item relationship.\nIt really comes down to your use case. A list is often the choice, but a dictionary could be nice, and numpy arrays are nice if you are doing math with the stored data.","Q_Score":0,"Tags":"python,database","A_Id":63480466,"CreationDate":"2020-08-19T05:06:00.000","Title":"python data structures for storing classes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a web scraping project. In this project, I have written the necessary code to scrape the required information from a website using python and selenium. All of this code resides in multiple methods in a class. This code is saved as scraper.py.\nWhen I execute this code, the program takes sometime between 6 and 10 seconds to extract all the necessary information from the website.\nI wanted to create a UI for this project. I used django to create the UI. In the webapp, there is a form which when submitted opens a new browser window and starts the scraping process.\nI access the scraper.py file in django views, where depending on the form inputs, the scraping occurs. While this works fine, the execution is very slow and takes almost 2 minutes to finish running.\nHow do I make the execution of the code faster using django faster? can you point me some tutorial on how to convert the scraper.py code into an api that django can access? will this help in making the code faster?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":614,"Q_Id":63480479,"Users Score":2,"Answer":"Few tiny tips,\n\nHow is your scraper.py working in the first place? Does it simply print the site links\/details, or store it in a text file, or return them? What exactly happens in it?\nIf you wish to use your scraper.py as an \"API\" write your scraper.py code within a function that returns the details of your scraped site as a dictionary. Django's views.py can easily handle such dictionaries and send it over to your frontend HTML to replace the parts written in Jinja2.\nFurther speed can be achieved (in case your scraper does larger jobs) by using multi-threading and\/or multi-processing. Do explore both :)","Q_Score":0,"Tags":"python,django,selenium,django-views","A_Id":63480617,"CreationDate":"2020-08-19T05:22:00.000","Title":"How to scrape data faster with selenium and django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I'm currently completing my Udacity Nanodegree and there is this one point that i'm not able to understand.\nIn the input layer we're taking 784 because the pixel of MNIST dataset is 28x28, but i don't understand why are they taking 256 hidden layer. Where did this 256 number came from?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":63481752,"Users Score":0,"Answer":"The 256 hidden layer represent the 0 to 255 value given to each pixel to represent saturation of color for that pixel.","Q_Score":0,"Tags":"python,deep-learning","A_Id":63483155,"CreationDate":"2020-08-19T07:11:00.000","Title":"Hidden Layer in a Neural Network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm currently completing my Udacity Nanodegree and there is this one point that i'm not able to understand.\nIn the input layer we're taking 784 because the pixel of MNIST dataset is 28x28, but i don't understand why are they taking 256 hidden layer. Where did this 256 number came from?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":63481752,"Users Score":0,"Answer":"The number of units in hidden layers is an hyperparameter of the network, so just like any other hyperparameter (like the learning rate, regularization factor and so on) it is initially chosen arbitrarily, then its value is \"tuned\" by assessing the model's performances on the validation set.\nSometimes though, especially in small and contrived examples like MNIST, some hyperparameters are fixed once and for all and never tuned, given how simple the task at hand is. So yeah, chances are that the number 256 was chosen arbitrarily.","Q_Score":0,"Tags":"python,deep-learning","A_Id":63483349,"CreationDate":"2020-08-19T07:11:00.000","Title":"Hidden Layer in a Neural Network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to send json collections from a Flask server to remote Perforce depot using P4Python.\nIs there a way to do that through Python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":63482517,"Users Score":0,"Answer":"The strategy for doing this via P4Python is going to be about the same as doing it via the command line or one of the other scripting APIs: you'll need to create a workspace, write the file to the workspace, and use p4 add and p4 submit.\nThere isn't an API that lets you pipe data directly into the server to be converted into a depot file.","Q_Score":0,"Tags":"python,flask,pymongo,perforce,p4python","A_Id":63489549,"CreationDate":"2020-08-19T08:00:00.000","Title":"Sending json collections to Perforce depot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Active contents are JavaScript, PostScript. I want to know for a given PDF file if it contains any active content. How can I check this with Python?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":264,"Q_Id":63483983,"Users Score":2,"Answer":"You need a Python library that gives access to what Adobe (and some other libraries) calls the COS level. That's the level of objects in the file.\nFor JavaScript I'm afraid there is no other way than to go through the PDF specification, and look for all places where JavaScript would be allowed, and then check those.\nFor PostScript I was going to say you don't have to be concerned about that because it's no longer possible, but I have to come back on that view :) You basically need to check for:\n\nPostScript XObjects: I'm a bit surprised that these are still in the specification because I thought they were deprecated, but oh well, at least in 32000-1 they apparently still exist.\nPostScript functions (Type 4 functions). Some PDF objects use functions in their definitions and there is a PostScript function type.\n\nThen it becomes a bit tricky as there are some caveats:\n\nAt one point there was a PostScript operator that could be used in the page stream and that could inject PostScript directly into the page stream. This is deprecated, but depending on your goal you might still have to detect it.\nWhen I said you need a library with COS level access, you might actually need more. You can detect a PostScript XObject on the COS level, but in order to know whether it's actually used on the page, you'll need a library that can also parse the page content for you. Whether you need this or not is up to your purpose.\n\nAnd then, again depending on your purpose, you should realise that PostScript or JavaScript code could be hidden in stream objects just about anywhere in a PDF file. They wouldn't be used because tools wouldn't know it's there, but they would still be there. Whether or not you're concerned about that depends on what you're planning to use this for.","Q_Score":1,"Tags":"python,pdf","A_Id":63494142,"CreationDate":"2020-08-19T09:29:00.000","Title":"How can I check if a PDF has active content with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Scenario: Buildozer packaged python apk works fine on Android Emulator and shows Login screen. On hitting Login button I am getting details of logged in user from Mysql database\nMySql database server is a Ubuntu chromebook. Android Emulator is on Windows machine.\nI can access the database via from Windows machine using HeidiSql - i.e ip address and user name \/ password @ port 3306.\nHowever the app running on the emulator gives a permission denied error\nPlease advise how I can find root cause of the issue and rectify it","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":157,"Q_Id":63486031,"Users Score":0,"Answer":"The issue was happening because the buildozer spec file was missing the option\nandroid.permissions = INTERNET\nAfter putting this the sql queries started working.","Q_Score":0,"Tags":"android,mysql,python-3.x,kivy","A_Id":63639709,"CreationDate":"2020-08-19T11:29:00.000","Title":"Kivy+Python apk Mysql Remote Database access","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are developing REST APIs using python framework called FASTAPI. The code security test failed for html injection. They are sending some html tag code in the post payload, we are inserting that in DB and sending same in GET Response. Is there any way to prevent  this HTML injection while processing request in FASTAPI.","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":1102,"Q_Id":63488278,"Users Score":5,"Answer":"yes.  No framework is going to magically change the content you get without you being explicit about it.   (Imagine if it was a REST API for recording HTML snippets from an internal system to be used in rendering web pages in another endpoint: you'd need the HTML as is)\nIt is just a matter of calling a escape function on your input data, before putting that on the db.\nPython's standard library html.escape function suffices in this case.\nThere is no code in your question, and I don't know FASTAPI by heart - but if it puts the payload in the DB without going through any code you write, then you should either customize that and put in this call to preprocess your data, or add a triggered stage (that is, an event subscriber) that will do that for you.","Q_Score":2,"Tags":"python,fastapi,html-injections","A_Id":63488487,"CreationDate":"2020-08-19T13:39:00.000","Title":"How can we prevent html injection in FASTAPI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am making a program in which I want to use Windows + D combination to navigate to desktop, but I am unable to find a windows key in Key.<Keyname> to do that. How can I do that? If not, is there any other way i should do this instead?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1581,"Q_Id":63489008,"Users Score":0,"Answer":"the Keyname for the Windows Button is cmd_l.\nif you want to press it just use it as:  variable.press(Key.cmd_l)","Q_Score":1,"Tags":"python,python-3.x,pynput","A_Id":68278411,"CreationDate":"2020-08-19T14:17:00.000","Title":"How to press the windows key with pynput?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have seen PyCharm suggest to me to use a function named copyright(). I have never written such function \/ imported anything which means it is a python standard library function. could not find any docs about it neither description in PyCharm itself. The function don't have any arguments which seems odd as I would infer it's goal is to set some part of code to be copyrighted. What is this function for and how to use it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":485,"Q_Id":63490390,"Users Score":1,"Answer":"copyright() is a Python builtin class.\nYou can CTRL + click on the function name in Pycharm so it will lead you to the actual source definition, which should belong to your standard python installation.\nThe function will print the actual Python copyright, which is contained in sys.copyright \nIt's the same as credits function","Q_Score":0,"Tags":"python,copyright-display","A_Id":63490468,"CreationDate":"2020-08-19T15:31:00.000","Title":"What does the copyright() method in python do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"is there a way I can embed videos in a python app using kivy?\nI couldn\u2019t find any module for that and not sure how to proceed","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":63491523,"Users Score":1,"Answer":"Kivy can stream videos from the internet and play them in VideoPlayer. However, YouTube does not provide a streaming URL. Remember that YouTube only gets paid when they show ads, which means they want you on their site and need you to use their video player.\nI can think of two options:\nUse a YouTube downloader app to retrieve the video (or, alternatively, try to hack on one of the downloaders and see if you can figure out what they're doing and how to duplicate it in Kivy).\nUse the Chromium Embedded Framework to display an actual web page. I have no idea whether this will work with Flash or not, but in theory it would work for any HTML5 videos (but not all videos can be watched in HTML5). There is a CEFPython Garden widget available, as well as a non-Garden CEFKivy component which has more recent development.","Q_Score":1,"Tags":"python,video,kivy","A_Id":63491569,"CreationDate":"2020-08-19T16:48:00.000","Title":"Is there a way to embed YouTube vids with kivy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using PyCharm to do some kinds of stuff on ESP32,\nIt's ongoing, but I can't use the terminal correctly. MicroPython REPL doesn't seem to work. I can't do serial commands on the terminal.\nI'm using a venv to do it, and maybe the problem is something related to it.\nIn normal cases, this is the terminal:\nDevice path COM[x]\nQuit: Ctrl+] | stop program: Ctrl+C | Reset: Ctrl+D\n\n\n\n\n\n\n...\nIn my case, it's like this:\nMicrosoft Windows [vers\u00e3o 10.0.18363.1016]\n(c) 2019 Microsoft Corporation. Todos os direitos reservados.\n(venv) C:\\Users\\user\\PycharmProjects\\networktest>\n...\nSo I can't do any command in my terminal, anyone can help?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":63493768,"Users Score":0,"Answer":"Have you tried using a Terminal program like PuTTY, using the com port identified for the ESP32 to establish a REPL?\nCan you see the board\/com port in Device Manager or as a drive in  Windows Explorer?\nThese steps might help isolate the problem to either Pycharm, or the board itself?","Q_Score":0,"Tags":"terminal,pycharm,esp32,micropython,esptool","A_Id":63496872,"CreationDate":"2020-08-19T19:30:00.000","Title":"Terminal issue, MicroPythonREPL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on class-based views on Django. I need to debug the functions line by line in a Class. I have added the breakpoints on various rows but when i debug VS-code reads the class at the startup but later does not stop at breakpoints when i click on controls that i want to debug.\nAny help would be appreciated.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":341,"Q_Id":63494138,"Users Score":1,"Answer":"Just posting so i can close the question.\nI figured that out... I had added breakpoints at def\/function line while breakpoints should be at line of code. Sorry for inconvenience...\nBut this may help other who may stuck on the same...","Q_Score":1,"Tags":"python,django-class-based-views","A_Id":63494747,"CreationDate":"2020-08-19T19:57:00.000","Title":"How to Debug class procedure in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I had the idea to synchronise the equal scripts from a python program\nthat Im running on different computers in parallel, by creating a\nglobal timestamp based of the script that startet first.\nSo for a better explanation, it should work like this:\nThe Script runs on PC 1 and creates a timestamp.\nEverything the script has to do after that will only be executed once\nthe time in the timestamp + 5 minutes is reached.\nFor the script on PC 2 or more, basically the same is happening but without\ncreating a new timestamp, since the starting time wouldnt be the\nsame anymore then.\nNow I already build a Python webserver that creates the timestamp and I am\nalso able to retrieve the time for my script. But I have to make sure that I\ncan reach the webserver without beeing in my own network and\nusing \"localhost:...\" as an adress. So now I wonder how I can make the webserver\npublic in the most easy way possible. The other option would be an\nalready public site, that can create custom timestamps on the basis of my configuration, so that I only create 1 timestamp for the first visitor on the site.\nDo you by chance know any of these sites or can tell me how I can make my HTML web server public?\nThanks","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3943,"Q_Id":63494148,"Users Score":1,"Answer":"You could create a proxy server on the same network with the pc you have the script running on and connect to it from the other pcs","Q_Score":0,"Tags":"python,timestamp,ip,webserver,public","A_Id":63494207,"CreationDate":"2020-08-19T19:58:00.000","Title":"How to make Python Web Server public?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I had the idea to synchronise the equal scripts from a python program\nthat Im running on different computers in parallel, by creating a\nglobal timestamp based of the script that startet first.\nSo for a better explanation, it should work like this:\nThe Script runs on PC 1 and creates a timestamp.\nEverything the script has to do after that will only be executed once\nthe time in the timestamp + 5 minutes is reached.\nFor the script on PC 2 or more, basically the same is happening but without\ncreating a new timestamp, since the starting time wouldnt be the\nsame anymore then.\nNow I already build a Python webserver that creates the timestamp and I am\nalso able to retrieve the time for my script. But I have to make sure that I\ncan reach the webserver without beeing in my own network and\nusing \"localhost:...\" as an adress. So now I wonder how I can make the webserver\npublic in the most easy way possible. The other option would be an\nalready public site, that can create custom timestamps on the basis of my configuration, so that I only create 1 timestamp for the first visitor on the site.\nDo you by chance know any of these sites or can tell me how I can make my HTML web server public?\nThanks","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3943,"Q_Id":63494148,"Users Score":1,"Answer":"You could use an amazon service like elastickbeanstalk its free to some extent and will make your server public","Q_Score":0,"Tags":"python,timestamp,ip,webserver,public","A_Id":63494268,"CreationDate":"2020-08-19T19:58:00.000","Title":"How to make Python Web Server public?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Suppose I have a tabular dataset of fixed dimension (N x M). I receive a stream of updates from Kafka updating entries in this table. Ultimately, I'd like to have a pandas dataframe with a recent version of the table, and I'm considering a few options for doing that:\n\nMaintain it in memory as a table \/ dataframe. My concern here, is I don't know if I can avoid multithreading, since one process will perpetually be in a for loop of receiving messages.\n\nMaintain it in an external structure, and have a separate process independently read from it. Choices of external data stores:\na) SQLite - Might have concurrency issues, and updates for arbitrary rows are probably a bit messy.\nb) Redis - Easy to maintain, but hard to query \/ read the whole table at once (which is how I would generally be accessing the data).\n\n\nI'm a bit of a Kafka beginner, so any advice here would be appreciated. How would you approach this problem? Thanks!\nEDIT: I guess I could also just maintain it in memory and then just push the whole thing to SQLite?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":339,"Q_Id":63495473,"Users Score":1,"Answer":"My initial approach would be to ask: can I create a \"good enough\" solution to start with, and optimize it later if needed?\nUnless you need to worry about very sensitive information (like healthcare or finance data), or data that is going to definitely going to scale up very quickly, then I would suggest trying a simple solution first and then see if you hit any problems. You may not!\nUltimately, I would probably go with the SQLite solution to start with, as it's relatively simple to set up and it's a good fit for the use case (i.e. \"transactional\" situations).\nHere are some considerations I would think about:\nPros\/cons of a single process\nUnless your data is high-velocity \/ high-volume, your suggestion of consuming and processing the data in the same process is probably fine. Processing data locally is much faster than receiving it over the network (assuming your Kafka feed isn't on your local computer), so your data ingest from Kafka would probably be the bottleneck.\nBut, this could be expensive to have a Python process spinning indefinitely, and you would need to make sure to store your data out to a file or database in order to keep it from being lost if your process shut down.\nRelational database (e.g. SQLite)\nUsing a relational database like SQLite is probably your best bet, once again depending on the velocity of the data you're receiving. But relational databases are used all the time for transactional purposes (in fact that's one of their primary intended purposes), meaning high volume and velocity of writes\u2014so it would definitely make sense to persist your data in SQLite and make your updates there as well. You could see about breaking your data into separate tables if it made sense (e.g. third normal form), or you could keep it all in one table if that was a better fit.\nMaintain the table in memory\nYou could also keep the table in memory, like you suggested, as long as you're persisting it to disk in some fashion (CSV, SQLite, etc.) after updates. For example, you could:\n\nHave your copy in memory.\nWhen you get an update, make the update to your in-memory table.\nWrite the table to disk.\nIf your process stops or restarts, read the table from memory to start.\n\nPandas can be slower for accessing and updating individual values in rows, though, so it might actually make more sense to keep your table in memory as a dictionary or something and write it to disk without using pandas. But if you can get away with doing it all in pandas (re: velocity and volume), that could be a fine way to start too.","Q_Score":0,"Tags":"python,apache-kafka,redis,producer-consumer","A_Id":63496093,"CreationDate":"2020-08-19T21:55:00.000","Title":"Best data structure to maintain a table from a stream of Kafka update messages in Python","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"System\n\nmacbook pro\nOSX 10.15.5(Catalina)\nDocker version 19.03.12, build 48a66213fe\n\nLibrary\n\nuvicorn==0.11.8\nfastapi==0.61.0\ntorch==1.6.0\ntransformers==3.0.2\nsentence-transformers==0.3.2\nscikit-learn==0.20.0\nscipy==1.4.1\npandas==0.23.4\njupyter==1.0.0\n\nDetail\nI used Colaboratory to fine-tune Setence BERT and save that model.\nThen I went local and built an environment with Docker that included jupyter and FastAPI, and in that environment I was able to confirm that the model I saved with Jupyter, launched in Docker, returned the same estimation results as in the Collaboratory.\nWhen I used that model, I got different results when I used FastAPI started in the same Docker environment as Jupyter.\nAll the text entered in this flow is the same.\nThe analysis showed that the SentenceTransformer loaded the model and then encoded it, and found that it calculated completely different embedding.\nThanks to your advice.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":63497635,"Users Score":0,"Answer":"sorry, I use Japanese model but I forgat translate default BertTokenizer to BertJapaneseTokenizer.\nChange default Tokenizer fixed this problem.","Q_Score":0,"Tags":"python,docker,jupyter-notebook,bert-language-model,fastapi","A_Id":63498106,"CreationDate":"2020-08-20T02:53:00.000","Title":"Encoding sentences with Setenece BERT's model in FastAPI changes the result from the results with Jupyter and python scripts","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently, I am learning python and somewhere read; that if a line is too long, meaning more than 79 characters, the line should be split into a new line for readability.\nCurrently, I have all_fields variable which contains around 300 other model field variable. So all_fields variable is around 4000 characters long.\nSo If I split it multiple lines there will be too many lines and those lines look disturbing while reading or inspecting code Instead using it in one line looks good and improve readability.\nSo my question is:  \nWhich method should I follow in such a scenario?\nDoes it really recommend to split it in multiple lines because of guidelines?\nA single line with so many characters will affect my code performance or speed?\nThanks,","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":177,"Q_Id":63498647,"Users Score":1,"Answer":"It's  just a best practice so that others need not to scroll to see your code. Just one cool thing I have experinced with PyCharm IDE that this can be done automatically with IDE itself once you are done with code script writting. Probably, it may be a win-win choice. You wouldn't have to put any extra effort from your end to adhere with the best practices and reviewer will also enjoy reviewing it.","Q_Score":2,"Tags":"python,coding-style,pep8","A_Id":63500218,"CreationDate":"2020-08-20T05:08:00.000","Title":"In python, Does using long line without breaking into multiple line will affect speed or performance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a school project which I would like to showcase in a web browser or application.\nI would like the user to control the work with a mouse or keyboard. I want to show a unique image based on where the curser is over a visible grid. An additional feature is the ability to switch to a different \"stack\" of images upon user input from the scroll wheel or in a dialog.\nI have a beginner-intermediate understanding of Python.\nTheoretically, I could write this using Sage, but I would like the feedback to be instant - a change shouldn't require a new calculation, just show a new image.\nAdditionally, I would like to create a feature which takes the user on a \"tour\" based on information attached to an image.\nMy first thought was to use an online website builder (Webflow), though an opportunity to learn a new language or expand upon my knowledge of Python is my first choice.\nWhat language is best suited for this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":63498654,"Users Score":2,"Answer":"This is possible in Python, as nearly everything is (Python is a Genral Purpose Language), so you could certainly implement this in Python.\nThe best language for this, however,IMO, would be JavaScript.\nPython will almost certainly get in your way or at least hinder you slightly in comparison.\nAn 'online website builder' is not likely to provide you with the required amount to control needed to implement you project - most of these are painfully simplistic drag-and-drog tools where any real control only comes from adding your own CSS\/HTML\/JS anyways.\nJS is an incredibly useful language and also very well suited for nearly all web\/browser projects, so use this opportunity to learn it !\nFurther, React Native can let you use JS for mobile apps too, if that's what you meant by 'applications' or you could simply keep it a web app.\nPS. This may also be possible with HTML5, which is perhaps simpler and easier to learn, but I'm no a web dev so that will have to be confirmed by someone else.\nI am sure, though, that this is very efficiently doable in JS.","Q_Score":1,"Tags":"python,user-controls,web-project","A_Id":63499270,"CreationDate":"2020-08-20T05:09:00.000","Title":"Is Python ideal for this web project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Hoping you can help. I\u2019m creating a web app with python and Flask. One of the the things that my web app will do is provide a smart document search. You can enter text and it will fetch results of documents similar to the portion of text you entered.\nI\u2019ve used Flask for the front end to serve the HTML, manage any DB interactions required and display results. It will pass the query through to a Gensim similarity model and query it.\nMy question here is what is the best way to host these? I\u2019ve explored loading the model as part of loading flask but it slows things down quite a lot (it\u2019s c. 6gb in memory) but it works. I can then query the model quite easily as it\u2019s all within the same program scope.\nMy concern is that this would then not be scalable and possibly not best practice and that I may be better to host the model separately and make API calls to it from my Flask web app.\nThoughts and views would be much appreciated.\nThanks,\nPete","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":161,"Q_Id":63499110,"Users Score":1,"Answer":"Your thoughts are definitely on the right track.\nYes, you should separate the hosting of the model from your web app. Your suggestion of an API is a good one. Even if in the beginning it is all hosted on one machine, it is still worth doing this separation.\nOnce you are hosting this separately via an API, then as your web app has more users, it becomes easy to scale the model API.\nWhether by launching more instances and balancing requests. Or, depending on requirements, you could add scalability and robustness via messaging, like Rabbitmq, or a mix of the two.\nFor example, some systems that access extremely large datasets, return a response via email to let you know your answer is ready to download or view. In this case, you may host one instance of the model, and put requests in q queue to answer one by one.\nIf you need very fast responses from your model, then you are likely to scale via more instances and balancing.\nBoth options above can be rolled out yourself, using open source solutions, or you can go straight to managed services in the cloud that will auto scale via either of these methods.\nIf you are just producing this project yourself with no funding, then you most likely do not want to start by using managed services in the cloud, as these will auto scale your bank account in the wrong direction.\nThe above solutions allow you to make changes, update the model, even use a different one, and release it on its own as long as it still conforms to the API.\nSeparation of boundaries in data, and responsibilities in behaviour are important in having a scalable and maintainable architecture.","Q_Score":0,"Tags":"python,flask,gensim","A_Id":63499255,"CreationDate":"2020-08-20T05:56:00.000","Title":"Best practice for deploying machine learning web app with Flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Whenever I am trying to run testcases in Robot framework through cmd, i am getting the below error:\nParsing <filename with path> 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 <filename with path> 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":"I am currently using django==2.2.5, managing my dependencies via pipenv and would like to upgrade to django==2.2.15\nUnfortunately the pipenv documentation does not say anything regarding the option of specifying a certain version when using pipenv update - hence my problem\/question:\nSince the command pipenv update django would update my django to the latest 3.1 version but I only want to update to version 2.2.15 I have to use pipenv install django==2.2.15. True or Not? And if not, what would be the correct way?\nSince I am doing this the first time, I am amfraid to mess things up , so just wanted to be on the safe side, before proceeding....","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":746,"Q_Id":63508029,"Users Score":1,"Answer":"You can use the command pipenv install django=='2.2.15' to make update to a specific version.","Q_Score":1,"Tags":"python,django,pipenv,pipenv-install","A_Id":63508093,"CreationDate":"2020-08-20T15:08:00.000","Title":"Correct way to update django to a specific (but not most recent) version via pipenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i just shifted to VS Code from Pycharm. Now i am doing a very simple json.load action in my script, and a weird thing happens. I keep getting the error  \"FileNotFoundError: [Errno 2] No such file or directory: 'data.json'\". However, when i open the same exact py file in Pycharm, it runs perfectly without any error.\nBoth of them are running on python 3.7 interpreter.\nThe VS Code one is from opt\/local\/bin\/python3.7, while\nthe Pycharm one is from usr\/local\/bin\/python3.7.\nis this the reason for the error?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":5312,"Q_Id":63508254,"Users Score":3,"Answer":"The file or directory you are looking for in the python script depends on the path you run the python script. This is the key of this kind problem.\nWhen you open the cmd and enter into the python script path to run the python script, you can easily understand how to set the file or directory path in your python script which you are running.\nBut when you running the same python script in IDEA, you will be confused with the path you should take to search the file or directory. At this time, you just need to find out which path you will be taken to run the commands. And some times it's different from the python script directory.\nIn VSCode, the default path of the terminal was the root directory of the project. And when you choose 'Run python file in terminal', the command of this action take, does not change the path of the terminal. So the file or directory path in python script should depends on the project directory(terminal path). And you can change this default directory in debug mode through \"cwd\" configuration, then when you debug the python script, you will find the terminal path had been changed to the path of 'cwd' set.\nJust need to remeber, the path in the python script depends on the path which you are running the python script, and it's different from different IDEA.","Q_Score":1,"Tags":"python,json,visual-studio-code,pycharm,interpreter","A_Id":63573188,"CreationDate":"2020-08-20T15:20:00.000","Title":"(FileNotFoundError: [Errno 2] No such file or directory: 'data.json') in VS Code, but no error in Pycharm, why?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the folder \/a\/b\/c\/d\/ and I want to copy d\/ into destination \/dst\/.\nHowever, shutil.copytree(\"\/a\/b\/c\/d\", \"\/dst\") produces \/dst\/a\/b\/c\/d.\nI only want \/dst, or even \/dst\/d would suffice, but I don't want all the intermediate folders.\n[edit]\nAs others have noted, copytree does what I want - I had unintentionally added the full path of the source to my destination!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":66,"Q_Id":63508810,"Users Score":1,"Answer":"that is what shutil.copytree does !\nshutil.copytree recursively copies an entire directory tree rooted at src to a directory named dst\nso the statement in the question :\nshutil.copytree(\"\/a\/b\/c\/d\", \"\/dst\") produces \/dst\/a\/b\/c\/d.\nis just wrong.this will copy the contents of d (and subdirectories) in to \/dst","Q_Score":0,"Tags":"python-3.x,copytree","A_Id":63509261,"CreationDate":"2020-08-20T15:52:00.000","Title":"copy subfolder without parent folders","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I use Centos 7 with OpenSSL 1.0.2k (openssl-1.0.2k-19.el7.x86_64.rpm)\nI've tried to upgrade to OpenSSL 1.1.1c by:\nyum install openssl11\nwhich basically installs: openssl11-1.1.1c-2.el7.x86_64.rpm and openssl11-libs-1.1.1c-2.el7.x86_64.rpm\nIt doesn't upgrade by overrides openssl 1.0.2 with openssl 1.1.1 but install openssl11 and its RPMs along with the existing openssl version.\nwhen I try to uninstall openssl 1.0.2, it causes some dependencies issues, which make perfectly sense since openssl11 provides openssl11 and not openssl:\nopenssl is needed by (installed) python2-cryptography-1.7.2-2.el7.x86_64\nopenssl is needed by (installed) pcs-0.9.162-5.el7.centos.x86_64\nopenssl is needed by (installed) rng-tools-6.3.1-3.el7.x86_64\n\/usr\/bin\/openssl is needed by (installed) authconfig-6.2.8-30.el7.x86_64\nWhat should I do to overcome this?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":23805,"Q_Id":63508872,"Users Score":13,"Answer":"You can't uninstall openssl 1.0.2 CentOS requires it and you cannot upgrade it until they decide to do ( but they won't , you'll have to upgrade to CentOS 8)\nOpenssl11 is for \"spot\" usage with specific environments if you need it.","Q_Score":11,"Tags":"python-2.7,openssl,centos7","A_Id":63525186,"CreationDate":"2020-08-20T15:56:00.000","Title":"Upgrading CentOS 7 to OpenSSL 1.1.1 by yum install openssl11","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Im new in kivy and Im trying to build helloworld in python\/kivy on linux and for some reason I get this error and idk what to do with it\nhere is buildozer.spec https:\/\/drive.google.com\/file\/d\/1kUigxxOkf-HBF4qXwtcmfrVLZtJTkHtK\/view?usp=sharing\nhere is full output from console https:\/\/drive.google.com\/file\/d\/19YCXJ73oEHnl78-R2DoKlFuECkLfO6OW\/view?usp=sharing \n(for some reason stackowerflow says it looks like a spam when i put there just error so i must upload it on googledrive)\nI hope somebody can help me with it","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":63509061,"Users Score":0,"Answer":"ValueError: storage dir path cannot contain spaces, please specify a path with --storage-dir\n\nThis is the error it's printed for you. It seems fairly clear. Try building in a folder without a space in the name.","Q_Score":0,"Tags":"python,android,linux,kivy,buildozer","A_Id":63513592,"CreationDate":"2020-08-20T16:06:00.000","Title":"Problem with building apk on android with buildozer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need a solution for this (I haven't tried it in mobile yet cause the program is in the development stage but I know the question will also get a late response) that if I have multiple modules installed via command prompt and if I use those modules to make an android app then will the app function as it did in the PC or will it say that the modules are missing and keep on crashing, I'm new to app development please help me.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":955,"Q_Id":63511637,"Users Score":0,"Answer":"If you include the module in the compilation process (I don't know what you're using for compiling\/developing so not sure how to help there) the app won't crash. In the worst case it will just not play the audio, but the rest of the app should work (unless some part of it requires the audio to be played).","Q_Score":1,"Tags":"python,android,python-3.x,speech-recognition,pyaudio","A_Id":63512101,"CreationDate":"2020-08-20T19:03:00.000","Title":"does python modules like pyaudio works in a android if an android app is make by using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Python3 natively and some of the 3rd party libs seem to have different approaches in returning either string or bytes. Is there a de facto way of handling these two different types? For me, it seems natural to work only with one of the types in the code as much as possible (keep bytes only at boundaries) but I'm not sure if it makes sense.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":63511867,"Users Score":0,"Answer":"If you want to manipulate text use strings as it is more straight forward, unless you have a specific use case where manipulating binary data is significant like manipuating different encodings, ciphers or row binary files.","Q_Score":0,"Tags":"python,python-3.x","A_Id":63512063,"CreationDate":"2020-08-20T19:19:00.000","Title":"What is the proper way to work with string and bytes types?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to find or create a region growing algorithm which takes in an array of seeds and a sort of \"cost\" array so that when regions are created, they do so in a way which can be controlled by a threshold put on cost.\nFor example, I want to input seed locations and population counts in 2D numpy arrays of the same size. The final result would ideally be a set of regions associated with the seeds which are constrained by the population array so that no one region would have a much higher population count than others.\nI have looked into skimage.segmentation.watershed and have created a basic region segmentation using inverse distance weighting with numpy, but I'm unsure of where to go from here.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":63512671,"Users Score":0,"Answer":"similar to k-mean clustering where the candidate pixel is classified based on the distance that is closest to the mean of the cluster. On the other hand, region growing based segmentation analyzes the neighboring pixels to determine whether or not to add the pixel to the seed region. and similar to the k-means, the process is iterated over all the pixels. First threshold the image and input some seed values usually through mouse clicks and finally iteratively use the 4\/8-neighborhood connectivity.","Q_Score":0,"Tags":"python,numpy","A_Id":63521734,"CreationDate":"2020-08-20T20:25:00.000","Title":"Region Growing Algorithm with threshold or bounds","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"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 have a trading bot that trades multiple pairs (30-40). It uses the previous 5m candle for the price input. Therefore, I get 5m history for ALL pairs one by one. Currently, the full cycle takes about 10 minutes, so the 5m candles get updated once in 10m, which is no good.\nAny ideas on how to speed things up?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":11818,"Q_Id":63515267,"Users Score":1,"Answer":"Just to follow up on that answer. You can see the candle closing as the websocket return data for every tick has a boolean property for if the candle is closed or not i.e. on a 5min timeframe if the candle closed on the 5min mark","Q_Score":12,"Tags":"python,api,algorithmic-trading,trading,binance","A_Id":67761679,"CreationDate":"2020-08-21T01:30:00.000","Title":"How to get ALL (or multiple) pair's historical klines from Binance API in ONE request?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a theoretical question (if these are not allowed please direct me to the right place!) about time complexity.\nSay I have a list sorted lexically, and one that isn't. I know that the linear search and binary search algorithms have vast differences in run-time (binary search being logarithmic so the input is halved each time), but other than that, will there be any significance about the size of the input for the sorted list versus the non-sorted list? Is there any other reason why the sorted list would be better, if the input is very large?\nReally new at this stuff so any clarification would be much appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":171,"Q_Id":63515292,"Users Score":0,"Answer":"I know that the linear search and binary search algorithms have vast differences in run-time (binary search being logarithmic so the input is halved each time)\n\nThis, and other similar algorithms, is the main advantage\n\nwill there be any significance about the size of the input for the sorted list versus the non-sorted list\n\nNo, each element occupies the same amount of space in RAM regardless of order (for a standard list).\n\nIs there any other reason why the sorted list would be better, if the input is very large?\n\nAdvantages:\n\nSome algorithms are faster on sorted input sets\nSorted output can be more pleasing for end users if you are displaying it.\nSorted data is easier to compress, so for storage on disk or specialized RAM storage it could be smaller, but it would make no difference if you just put it in a standard array or list.\n\nThere are probably more, this is what I can come up with offhand.","Q_Score":0,"Tags":"python,algorithm,sorting,time-complexity","A_Id":63515334,"CreationDate":"2020-08-21T01:33:00.000","Title":"Does the input size matter for algorithm time complexity if the input is a sorted database versus non-sorted?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to take the functionality of python and pair it with a nice html\/css interface. whats the best way to make it run in the background without the need for an external server. ideally you wouldn't even need python installed, just an exe. any suggestions would be very helpful.\nThank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":435,"Q_Id":63516950,"Users Score":0,"Answer":"The best way would be to use IIS(10) if you're on Windows 10.","Q_Score":0,"Tags":"python,flask,localhost,webserver,exe","A_Id":63517368,"CreationDate":"2020-08-21T05:22:00.000","Title":"Running a full stack flask app locally as an application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working with features extracted from pre-trained VGG16 and VGG19 models. The features have been extracted from second fully connected layer (FC2) of the above networks.\nThe resulting feature matrix (of dimensions (8000,4096)) has values in the range [0,45]. As a result, when I am using this feature matrix in gradient based optimization algorithms, the value for loss function, gradient,  norms etc. take very high values.\nIn order to do away with such high values, I applied MinMax normalization to this feature matrix and since then the values are manageable. Also, the optimization algorithm is behaving properly. Is my strategy OK i.e. is it fair enough to normalize features that have been extracted from a pre-trained models for further processing.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":63518308,"Users Score":0,"Answer":"From experience, as long as you are aware of the fact that your results are coming from normalized values, it is okay. If normalization helps you show gradients, norms, etc. better then I am for it.\nWhat I would be cautious about though, would be any further analysis on those feature matrices as they are normalized and not the true values. Say, if you were to study the distributions and such, you should be fine, but I am not sure what is your next step, and if this can\/will be harmful.\nCan you share more details around \"further analysis\"?","Q_Score":0,"Tags":"python,feature-extraction,gradient-descent,vgg-net,batch-normalization","A_Id":63518474,"CreationDate":"2020-08-21T07:23:00.000","Title":"Can we normalize features extracted from pre-trained models","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When running a PyTorch training program with num_workers=32 for DataLoader, htop shows 33 python process each with 32 GB  of VIRT and 15 GB of RES.\nDoes this mean that the PyTorch training is using 33 processes X 15 GB = 495 GB of memory? htop shows only about 50 GB of RAM and 20 GB of swap is being used on the entire machine with 128 GB of RAM. So, how do we explain the discrepancy?\nIs there a more accurate way of calculating the total amount of RAM being used by the main PyTorch program and all its child DataLoader worker processes?\nThank you","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1819,"Q_Id":63522955,"Users Score":1,"Answer":"Does this mean that the PyTorch training is using 33 processes X 15 GB = 495 GB of memory?\n\nNot necessary. You have a worker process (with several subprocesses - workers) and the CPU has several cores. One worker usually loads one batch. The next batch can already be loaded and ready to go by the time the main process is ready for another batch. This is the secret for the speeding up.\nI guess, you should use far less num_workers.\nIt would be interesting to know your batch size too, which you can adapt for the training process as well.\n\nIs there a more accurate way of calculating the total amount of RAM being used by the main PyTorch program and all its child DataLoader worker processes?\n\nI was googling but could not find a concrete formula. I think that it is a rough estimation of how many cores has your CPU and Memory and Batch Size.\nTo choose the num_workers  depends on what kind of computer you are using, what kind of dataset you are taking, and how much on-the-fly pre-processing your data requires.\nHTH","Q_Score":18,"Tags":"python,python-3.x,ubuntu,deep-learning,pytorch","A_Id":68578695,"CreationDate":"2020-08-21T12:29:00.000","Title":"Understanding Memory Usage by PyTorch DataLoader Workers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a chat application, and I am wondering what are the benefits of for example using django-channels instead of making the chat in \"raw\" django?\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":154,"Q_Id":63524238,"Users Score":2,"Answer":"django-channels is an abstraction to make building realtime applications easier. Django itself does not come with baked in websocket features so you could use raw Django and your own web sockets but it will be a lot harder and you will be reinventing lot of what django-channels does.","Q_Score":1,"Tags":"python,django,django-channels","A_Id":63524479,"CreationDate":"2020-08-21T13:57:00.000","Title":"Benefits of using django-channels instead of not using it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So right now I'm using keras and training my model works perfectly fine, but I have to pass my data as numpy ndarray. So I have to convert my list of data to numpy ndarray first and then pass it to keras for training. When I try to pass my python list\/array, even tho it's the same shape as numpy array I get back errors. Is there any way to not use numpy for this or am I stuck with it?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":737,"Q_Id":63527536,"Users Score":2,"Answer":"Can you further explain your problem. What is the error message you are getting and are you getting this error during training or predicting?\nAlso if you could post some code samples that would help to","Q_Score":2,"Tags":"python-3.x,tensorflow,keras","A_Id":63527609,"CreationDate":"2020-08-21T17:33:00.000","Title":"Passing a python list to keras model.fit","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install sklearn for Python, however whenever I attempt to install something which has files from it as a requirement (such as scikit-neuralnetwork) or I attempt to import sklearn in a Python file, I get errors. In the first scenario I receive the error message below marked A, and for the second I receive an error saying I have no module named sklearn.utils (I've already commented out the correct install check). I've tried reinstalling the libraries but the issue remains the same.\n\nERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\Charles\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python38\\site-packages\\sklearn\\datasets\\tests\\data\\openml\\292\\api-v1-json-data-list-data_name-australian-limit-2-data_version-1-status-deactivated.json.gz'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":63528167,"Users Score":0,"Answer":"Download Anaconda. It has all the libraries already downloaded.","Q_Score":0,"Tags":"python,import,scikit-learn,libraries","A_Id":63528596,"CreationDate":"2020-08-21T18:19:00.000","Title":"How can I fix an failed install of sklearn for python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I continue work on a django project after I switched off my laptop. I'm using sublime text to edit and my command prompt to runserver. I have created a virtual environment and also activate it at the beginning of my work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":63528366,"Users Score":0,"Answer":"First, CD into the directory in your command prompt where your project is.\nSecond, activate the virtual environment again.\nThird, start the dev server.\nFourth, make changes to the code and make cool projects!","Q_Score":0,"Tags":"python-3.x,django","A_Id":63528565,"CreationDate":"2020-08-21T18:36:00.000","Title":"How do I continue work on a django project I created with cmd and using sublime text?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to change the font size of kivymd List Items.\nIs there a way to change font_size of kivymd List Items. Be it OneLineListItems or any List item.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":701,"Q_Id":63529561,"Users Score":4,"Answer":"text=\"[size=54]Discard draft?[\/size]\"","Q_Score":1,"Tags":"python,kivy,kivymd","A_Id":63529923,"CreationDate":"2020-08-21T20:17:00.000","Title":"Kivymd ListItems text size","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Cannot use df.iplot. The error it generates is Mime type rendering requires nbformat>=4.2.0. Any help?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1922,"Q_Id":63533424,"Users Score":2,"Answer":"Simply update your jupyter notebook version with pip install notebook, restart kernel and you should be fine. Had this issue myself and this solved the problem.","Q_Score":3,"Tags":"python-3.x","A_Id":66232443,"CreationDate":"2020-08-22T06:56:00.000","Title":"Mime type rendering requires nbformat>=4.2.0","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am very new to the Atom editor, I am on mac os and I am using Atom to run python, but when I try to make a game using pygame and then run it, it gives me the \"No module named 'pygame\".\nSome extra information:\n\nPygame version: \"2.0.0.dev6\"\n\nI use 'script' to run python stuff on Atom\n\nI have already installed pygame on my computer\n\n\nI have macOS 10.14 Mojave installed and I still have not updated to catilina.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":63533899,"Users Score":0,"Answer":"First off, double check you definitely have pygame installed, assuming you do, submit a bug report to atom - I don't use atom personally but assuming you are in the python 3 language, I don't think that is a problem with atom.","Q_Score":2,"Tags":"python-3.x,pygame,atom-editor","A_Id":63534532,"CreationDate":"2020-08-22T08:01:00.000","Title":"Atom says \"No module named 'pygame'\" When I try to run it (mac os)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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 see that I have both version of tensorflow in anaconda2\/lib\/python2.7\/site-packages:\n\ntensorflow-1.14.0.dist-info\/\ntensorflow-2.1.0.dist-info\/\n\nBut when I start anaconda2\/bin\/jupyter qtconsole, I always get 1.14. How do I use 2.1?\nThe history may be something like this:\n\n1.14 comes with conda\nI did pip install for 2.1\nI tried to do \"pip install tensorflow-datasets', it didn't work.\nGoogling suggested \"conda install -c anaconda tensorflow-datasets\". It looks this set tensorflow back to 1.14\nI tried different ways of 'pip install' 'conda install' 'conda update', but can't get tensorflow to 2.1.\n\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":63539835,"Users Score":0,"Answer":"anaconda 2 can't install tensorflow 2.x using conda install, I had to re-install anaconda 2, then install tf 2.x using pip install","Q_Score":0,"Tags":"python,tensorflow,anaconda","A_Id":63549256,"CreationDate":"2020-08-22T18:39:00.000","Title":"using different version of package within python anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose I have 3 calculations in the following sequence:\na = 1\nb = a + 1\nc = b + 1\nIs there a way to write a loop that goes through all the calculations in the mixed order below, ignores the erroneous c variable, and comes back to calculate c once b is calculated?\na = 1\nc = b + 1\nb = a + 1","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":51,"Q_Id":63540723,"Users Score":-1,"Answer":"your info is not so good ..... but have you ever tried the random function. you can try it once. random will throw any number from certain range... and you can do some conditioning statement and try different order of calculations.\ncheck documentation once. :)","Q_Score":1,"Tags":"python,python-3.x,loops","A_Id":63540769,"CreationDate":"2020-08-22T20:16:00.000","Title":"Python: Is there a way to loop through several calculations while ignoring error outputs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Anaconda 2019.03 on my 32 bit Windows 7(not updated since ages!!) and it is showing Python 3 failed to start on launching a Jupyter Notebook via Anaconda.. pls help..Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":37,"Q_Id":63540901,"Users Score":1,"Answer":"I use anaconda in windows 10pro and I don't face any problem. So  I think, it don't matching between Windows7 and Anaconda 2019.03.\nYou can use online ternimal and below the link of Cocalc","Q_Score":1,"Tags":"python,python-3.x,jupyter-notebook,anaconda","A_Id":63542855,"CreationDate":"2020-08-22T20:37:00.000","Title":"Python 3 failed error on starting Jupyter Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For example:\n\nSave a variable with message : \"Hello World\"\nGive a date that represents the date that the message can be opened in a message box\nCreate an interface that you press a button and it will output the message if today's time is greater than the date I saved.\n\nI tried using datetime.now() but anyone can manipulate\/fake the system time.\nWhat would you recommend me?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":55,"Q_Id":63542019,"Users Score":1,"Answer":"If you are worried about time-lock security, you will be better served with a more secure data transfer: simply don't write the message until the specified time!  Set up a cron job to run a short message-creation script at the specified time.","Q_Score":0,"Tags":"python","A_Id":63542096,"CreationDate":"2020-08-22T23:25:00.000","Title":"Is there a secure function in python that outputs a message ONLY after a certain time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing a web application in which users can upload excel files. I know I can use the OPENROWSET function to read data from excel into a SQL Server but I am refraining from doing so because this function requires a file path.\nIt seems kind of indirect as I am uploading a file to a directory and then telling SQL Server go look in that directory for the file instead of just giving SQL Server the file.\nThe other option would be to read the Excel file into a pandas dataframe and then use the to_sql function but pandas read_excel function is quite slow and the other method I am sure would be faster.\nWhich of these two methods is \"correct\" when handling file uploads from a web application?\nIf the first method is not frowned upon or \"incorrect\", then I am almost certain it is faster and will use that. I just want an experienced developers thoughts or opinions. The webapp's backend is Python and flask.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":63542212,"Users Score":0,"Answer":"If I am understanding your question correctly, you are trying to load the contents of an xls(s) file into a SQLServer database. This is actually not trivial to do, as depending on what is in the Excel file you might want to have one table, or more probably multiple tables based on the data. So I would step back for a bit and ask three questions:\n\nWhat is the data I need to save and how should that data be structured in my SQL tables. Forget about excel at this point -- maybe just examine the first row of data and see how you need to save it.\nHow do I get the file into my web application? For example, when the user uploads a file you would want to use a POST form and send the file data to your server and your server to save that file (for example, either on S3, or in a \/tmp folder, or into memory for temporary processing).\nNow that you know what your input is (the xls(x) file and its location) and how you need to save your data (the sql schema), now it's time to decide what the best tool for the job is. Pandas is probably not going to be a good tool, unless you literally just want to load the file and dump it as-is with minimal (if any) changes to a single table. At this point I would suggest using something like xlrd if only xls files, or openpyxl for xls and xlsx files. This way you can shape your data any way you want. For example, if the user enters in malformed dates; empty cells (should they default to something?); mismatched types, etc.\n\nIn other words, the task you're describing is not trivial at all. It will take quite a bit of planning and designing, and then quite a good deal of python code once you have your design decided. Feel free to ask more questions here for more specific questions if you need to (for example, how to capture the POST data in a file update or whatever you need help with).","Q_Score":0,"Tags":"python,sql-server,excel,pandas,flask","A_Id":63542301,"CreationDate":"2020-08-23T00:05:00.000","Title":"What is the correct way to upload files to a SQL Server inside my web application?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am finishing up on my first Python project. It is a text-based program converting metric and standard units. What could I use to turn the program into a GUI program. I have looked into tkinter. However, I am not sure if this would be the best solution for my situation. I would appreciate a little guidance as I am really new to programming.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":63542277,"Users Score":0,"Answer":"Tkinker is a simple and easy way to add GUI to your program and you actually can create some good looking interfaces, so If I were you I would use Tkinter.","Q_Score":0,"Tags":"python,tkinter","A_Id":63542407,"CreationDate":"2020-08-23T00:18:00.000","Title":"How to make a text-based program into a GUI? Would tkinter be the key?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a GaussianHMM that I have fitted using hmmlearn.fit function. I also have a bunch of sequences of observations and I want to compute the probability of each sequence happening given my fitted model. I looked into hmmlearn's documentation and I couldn't quite find a method that does what I want. In this case, do I just have to code the forward-backward algorithm? In case I code the forward-backward, I would also need the emission matrix, which is not given by hmmlearn.\nAnyone has an advice regarding this? thank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":285,"Q_Id":63542312,"Users Score":1,"Answer":"I also have a bunch of sequences of observations and I want to compute the probability of each sequence happening given my fitted model\n\n\nWhat you might be looking for is the score function, to evaluate the probability of sequence (ie. model.score(X)). Note that this is the log probability, as hmmlearn adjusts for underflow error.\n\n\nIn case I code the forward-backward, I would also need the emission matrix, which is not given by hmmlearn.\n\n\nWhile the GaussianHMM does not have an emission matrix, you can choose to discretize your emissions and utilize MultinomialHMM, which allows you to specify and also later extract the emission matrix model.emissionprob_.","Q_Score":0,"Tags":"python-3.x,hmmlearn","A_Id":64174760,"CreationDate":"2020-08-23T00:24:00.000","Title":"Is there a function that computes the probability of a sequence T of observations given a hidden Markov model on hmmlearn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know it's important to apply Gaussian blur to an image before using Canny to detect edges. My question is: does cv2.Canny() do Gaussian blur on its own or it is necessary to apply cv2.GaussianBlur() before cv2.Canny()? The documentation isn't clear on this point.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2587,"Q_Id":63543033,"Users Score":0,"Answer":"The aperture argument of Canny controls the size of the Sobel filter (from 1 to 7 ?), which in fact applies a lowpass filter before taking the derivative. Unfortunately, the documentation is not explicit about that lowpass filter, though Gaussian is cited.\nI bet that a binomial filter is in fact used (which is a close approximation to a Gaussian).","Q_Score":2,"Tags":"python,opencv,image-processing,edge-detection,canny-operator","A_Id":63594236,"CreationDate":"2020-08-23T03:15:00.000","Title":"Does cv2.Canny() perform a Gaussian blur?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just started programming through a course offered at my school, so I do not know a lot right now. One of my homework questions requires me to use an accumulator string with a for loop. I have looked through my Python textbook and online for an explanation or example, but I have not found any that help me to understand how to apply it. I would just like an explanation on how to apply an accumulator string to a function.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":63543323,"Users Score":0,"Answer":"Not sure what you're looking to do - I use accumulators sometimes for uri encoding.\nCreate an empty string mystring = \"\" then run a loop let's say for i in range(10): add the string to the accumulator, something like mystring += str(i)","Q_Score":0,"Tags":"python-3.x,for-loop,accumulator","A_Id":63543345,"CreationDate":"2020-08-23T04:17:00.000","Title":"Accumulator Strings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background\nBelow, I detail two different ways of running Python files - I am confused about the difference between them.\n\nRunning the Python file as an executable.\n\nTo run a Python file as an executable, I must first set a shebang in my file (# \/usr\/bin\/env python3), then run $ chmod +x filename.py at the command line, then run $ .\/filename.py at the command line to execute the file.\n\nRunning the Python file through the python3 command line command.\n\nTo run a Python file through the python3 command, I open my command line and run $ python3 filename.py.\nMy Question\nI understand that, when running the Python file as an executable, the shebang directs the computer to launch the (in this case) python3 interpreter which will interpret the subsequent code in the file and therefore run the file. When running the file through the python3 command, I understand that this is just another way of directing the computer to launch python3 to interpret the code in the file. To me, these two techniques therefore seem identical.\nAm I missing something? What's the difference, if any, between these two ways of running a Python file?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1820,"Q_Id":63543484,"Users Score":1,"Answer":"Nope, you have pretty much captured it.\nA practical consequence is that the shebang relieves you from having to remember whether it's python3 frobnicate or python frobnicate or sh frobnicate or bash frobnicate or awk frobnicate or perl frobnicate or...\nThis also makes it easy down the line to change your mind. Many tools of mine have started life as simple shell scripts, then been rewritten in Python or something else; but the calling interface doesn't change.\nBefore Unix, there was an unbridgable gap between system utilities (which you invoke simply by name) and user scripts (which before the introduction of the shebang always had to be called with an explicit interpreter).You still see remnants of this division in lesser systems. An important consequence was that users were able to easily and transparently wrap or replace standard commands with their own versions. This in some sense democratized the system, and empowered users to try out and evaluate improvement ideas for the system on their own. (Figuring out why your brilliant theory wasn't so great in practice is also an excellent way to learn and improve.) I don't think the importance of this versatility and flexibility can be overstated; it's one of those things which converted us from mere users to enthusiasts.","Q_Score":2,"Tags":"python,python-3.x","A_Id":63544153,"CreationDate":"2020-08-23T04:45:00.000","Title":"Difference Between Running Python File as Executable vs. Running from Command Line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Background\nBelow, I detail two different ways of running Python files - I am confused about the difference between them.\n\nRunning the Python file as an executable.\n\nTo run a Python file as an executable, I must first set a shebang in my file (# \/usr\/bin\/env python3), then run $ chmod +x filename.py at the command line, then run $ .\/filename.py at the command line to execute the file.\n\nRunning the Python file through the python3 command line command.\n\nTo run a Python file through the python3 command, I open my command line and run $ python3 filename.py.\nMy Question\nI understand that, when running the Python file as an executable, the shebang directs the computer to launch the (in this case) python3 interpreter which will interpret the subsequent code in the file and therefore run the file. When running the file through the python3 command, I understand that this is just another way of directing the computer to launch python3 to interpret the code in the file. To me, these two techniques therefore seem identical.\nAm I missing something? What's the difference, if any, between these two ways of running a Python file?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1820,"Q_Id":63543484,"Users Score":2,"Answer":"In practice, they're identical.\nThe shebang is just a convention that tells the OS what to do with the script file that you've chmod-ed to be executable -- i.e., executable with what. Without it, the OS just treats the file as a text file and will try to execute it as a shell script.","Q_Score":2,"Tags":"python,python-3.x","A_Id":63543511,"CreationDate":"2020-08-23T04:45:00.000","Title":"Difference Between Running Python File as Executable vs. Running from Command Line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I know variable is just a tag to an object\nexample num=10,\nnum becomes tag\/reference\n10 becomes the object stored in heap memory\nwhere does num get stored?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":282,"Q_Id":63543646,"Users Score":3,"Answer":"Ultimately it's in heap memory too; either:\n\nIt's a global, in which case the name it ends up as a key in the dict containing the module globals, with the value storing the reference to the actual object, or\nIt's a local, in which case the \"name\" is described in the function metadata itself, and the reference to the value ends up in an array of local references stored in the frame object allocated on entering the function (and typically freed when the function returns, though closures and exception-triggered tracebacks can cause the frame to last beyond the lifetime of the function call itself). The actual bytecode doesn't really use the name, it's converted to the index into the array of locals for speed, but the same index can retrieve the name for debugging purposes from the function metadata.\n\nSince dicts, functions, and frames are all heap allocated, the binding to the name is ultimately in heap allocated memory.","Q_Score":0,"Tags":"python-3.x","A_Id":63543685,"CreationDate":"2020-08-23T05:17:00.000","Title":"heap and stack in python variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Powershell I have typed $ python -m pydoc file but I didn't get the python documentation of file. Instead I got the message No Python documentation found for 'file'. What does it mean and how can I deal with it?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":724,"Q_Id":63544735,"Users Score":2,"Answer":"python -m pydoc \"name\" ...\nShow text documentation on something.   may be the name of a\nPython keyword, topic, function, module, or package, or a dotted\nreference to a class or function within a module or module in a\npackage.  If  contains a '\/', it is used as the path to a\nPython source file to document. If name is 'keywords', 'topics',\nor 'modules', a listing of these things is displayed.\npython -m pydoc -k \"keyword\"..\nSearch for a keyword in the synopsis lines of all available modules.","Q_Score":1,"Tags":"python,python-3.x,powershell,pydoc","A_Id":63544759,"CreationDate":"2020-08-23T08:05:00.000","Title":"No Python documentation found for 'file'?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using scrapy to crawl all the links and selenium to scrape all the pages. Selenium scraped most of the pages but left a few pages as the page took time to load.\nI tried with timeout() , but didn't seem to work, then I tried with execute_script\n\ndriver.execute_script(\"return document.readyState==\"complete\";\")\n\nthis also didn't seem to work, then I tried with expected_conditions\n\nWebDriverWait.until(expected_conditions.execute_script(\"return\ndocument.readyState==\"complete\";\"))\n\nbut didn't seem to work\nI m using firefox browser, phantomJs for Headless\nTried using Chrome driver so installed using brew cask install chromedriver but I'm facing this error\n\nraise WebDriverException(\"Can not connect to the Service %s\" %\nself.path) selenium.common.exceptions.WebDriverException: Message: Can\nnot connect to the Service chromedriver\n\nso back to phantomjs.\nThank you!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":63545051,"Users Score":0,"Answer":"Make use of sleep function which will help you in delaying the running of code in that time webpage will be loaded","Q_Score":0,"Tags":"python,selenium,web-scraping,scrapy,macos-catalina","A_Id":63545075,"CreationDate":"2020-08-23T08:45:00.000","Title":"How to make selenium to scrape pages after the page gets loaded","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using scrapy to crawl all the links and selenium to scrape all the pages. Selenium scraped most of the pages but left a few pages as the page took time to load.\nI tried with timeout() , but didn't seem to work, then I tried with execute_script\n\ndriver.execute_script(\"return document.readyState==\"complete\";\")\n\nthis also didn't seem to work, then I tried with expected_conditions\n\nWebDriverWait.until(expected_conditions.execute_script(\"return\ndocument.readyState==\"complete\";\"))\n\nbut didn't seem to work\nI m using firefox browser, phantomJs for Headless\nTried using Chrome driver so installed using brew cask install chromedriver but I'm facing this error\n\nraise WebDriverException(\"Can not connect to the Service %s\" %\nself.path) selenium.common.exceptions.WebDriverException: Message: Can\nnot connect to the Service chromedriver\n\nso back to phantomjs.\nThank you!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":63545051,"Users Score":0,"Answer":"I had this problem before. I used a while loop with try and except in it. Loop will keep trying to finish the work you have completed. If the page is not loaded then it will go into except which will just pass. But when it enters the try block and executes successful then at the end of the try block you can use a break to cone out of the loop. This worked 100% of the time for me.","Q_Score":0,"Tags":"python,selenium,web-scraping,scrapy,macos-catalina","A_Id":63545837,"CreationDate":"2020-08-23T08:45:00.000","Title":"How to make selenium to scrape pages after the page gets loaded","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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":"I once knew the name of python3 module that after importing when gave the name of request file saved by burpsuite, it automatically generated python3 requests headers. What is the module name?\nEdit: I am not searching for bs4, instead i am searching for what sqlmap -r\ndoes. I want to implement functionality similar to sqlmap -r but it was a module rather than what sqlmap is doing, and it made a variable with all the HTTP header set such as cookie, host etc","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":671,"Q_Id":63547162,"Users Score":0,"Answer":"if I understand your question, you are searching the module name  that burp suite is using to display the text from the request. If it's that, bs4 (beautiful soup 4) could be the module.","Q_Score":0,"Tags":"python-3.x,parsing,request,burp","A_Id":63547203,"CreationDate":"2020-08-23T12:51:00.000","Title":"How to parse burp suite request from file in python3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is: Is there a way to extract the flexray singals from Mf4 using dbc\/arxml file and save to MDF format","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":63548369,"Users Score":0,"Answer":"Not until somebody releases a reliable parser for the Fibex and Arxml database formats for Flexray.","Q_Score":0,"Tags":"python-3.x,asammdf","A_Id":63622037,"CreationDate":"2020-08-23T14:52:00.000","Title":"Cannot extract Flexray signals from MF4 using dbc file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an assignment where i need to implement three attacks after socket connection with python. I already did socket connection and implemented ransomware and key logger. I need one more attack implementation. Can anyone suggest me one attack that i can perform on the client's\/ victim's side besides these two?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":63548701,"Users Score":0,"Answer":"Some ideas that I have right now are:\n\nIf you have root access, you can basically have fun with some files and change their permissions. Maybe create a new user to access those files only.\n\nYou can try making a virus that could for instance create multiple processes of itself and slow down the victim's machine.\n\nYou could also create a script that scans for files in a certain directory (ex: Downloads) and send them to your machine.\n\nYou could try to modify some browser settings (called browser hijacking).\n\n\nI might add more ideas later. Good luck","Q_Score":0,"Tags":"python,security,client-side-attacks","A_Id":63550580,"CreationDate":"2020-08-23T15:21:00.000","Title":"What attacks can be performed on victim's machine after socket connection?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to make code text on jupyter notebook on VS code be bold, but no matter how I tweak the settings.json file I can't seem to find a way to make it happen. As I have noticed, usual python code text in .py files is changing when i change settings.json file but .ipynb file is not reacting. For some reason if I use command palette to change themes jupyter notebook's code is changing color as well but the codetext itself is not becomming bold. Is there a way to solve this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1971,"Q_Id":63549629,"Users Score":2,"Answer":"I'm a developer on the VSCode python extension. Currently our notebook editor is implemented as a webview (basically a way for extensions to put a webpage into VS Code's UI). We've tried to match things up as best as we can, but in this scenario we can't support many VS Code editor settings and features. This setting that you are changing is one of the ones that we don't support.\nOn the plus side, VS Code core team is currently in the process of adding build in notebook support. When we move over to this the notebook cells will be full real VS Code editor instances and will support this setting. This feature is currently in early preview (expect plenty of change and issues) if you right click on a ipynb file in VS Code Insiders and pick \"open in preview Notebook Editor.\"","Q_Score":0,"Tags":"python,visual-studio-code,jupyter-notebook","A_Id":63569942,"CreationDate":"2020-08-23T16:50:00.000","Title":"How to make VS code's jupyter notebook's codetext bold?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to open the start menu and open some applications like paint,Ms word etc. Is there any module in python which can do these tasks ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":63549848,"Users Score":0,"Answer":"You can do it directly with the python subprocess module.\nimport subprocess\nsubprocess.Popen(['C:\\Windows\\system32\\mspaint.exe'])\nBut if you want to open start menu and click on the applications then Pyautogui module can be used.","Q_Score":1,"Tags":"python,windows,user-interface,automation","A_Id":63549956,"CreationDate":"2020-08-23T17:11:00.000","Title":"Want to interact with windows applications using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is it possible to remove videos from Plex's \"Recently Added\" section? I'd like to add some old videos to my server for posterity but not have them appears as newly added.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3924,"Q_Id":63551357,"Users Score":0,"Answer":"I was faced to this situation and while gathering documentations to modify the SQL db, I thought about another solution and it did the trick for me. As previously said, all support threads regarding this issue are closed elsewhere so I'm posting it here for others to eventually find it :\n\nStopped Plex Server\nDisabled the server (computer) internal clock automatic sync\nSet the internal clock manually to a year before\nStarted Plex Server\nAdded the movies\nScanned the library\nMovie got added to the library without showing into recently added BUT the metadata from moviedb where not able to be loaded (probably caused by the difference in time and date between my server and moviedb server)\nStopped Plex Server\nRestored the internal clock automatic sync\nStarted Plex server\nUpdated all metadata of the library (actually I did it manually for each as I didn't know if I had some custom metadata somewhere else in the library)\nEnjoyed !","Q_Score":2,"Tags":"python,sqlite,plex","A_Id":67075416,"CreationDate":"2020-08-23T19:50:00.000","Title":"Remove Video From Plex's \"Recently Added\" Section","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What allows Kivy to be cross-platform compatible?\nIn other words, how can the same Kivy source code generate apps on multiple kinds of hardware platforms, such as desktop, iOS, and Android?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":63551976,"Users Score":2,"Answer":"I suppose there are two key extremes of achieving cross-platform compatibility:\n\nBy implementing things in a different way on each platform so that Kivy is running different code on each one, but hiding that difference from the user by making the output appear the same.\nBy using external APIs that are supported by all the different platforms, so that Kivy's own code is basically the same and the platforms themselves take care of making it work.\n\nKivy has a bit of both of these, but in particular all the drawing uses OpenGL ES 2 which is the second type: all of Kivy's drawing logic is just about identical across all supported platforms. Of course there are other types too, e.g. when working out display metrics such as the pixel density Kivy uses a different method on each platform but doesn't expose any of that detail to the user.\nOf course things are much more nuanced when considering things as a whole. For instance, Kivy uses SDL2 as a library for creating a window, setting its size\/pos handling pause\/resume etc., so Kivy's code is of the second type here as it calls SDL2 in the same way on every platform. However, SDL2 is not itself platform-native and is of the first type, implementing its API differently on different platforms but exposing the same API to Kivy on each one.","Q_Score":3,"Tags":"python,python-3.x,user-interface,kivy,cross-platform","A_Id":63553002,"CreationDate":"2020-08-23T21:04:00.000","Title":"How does Kivy achieve cross-platform compatibility?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to install py-radix lib via pip. It was installed successfully, but when I tried to import radix in my python code in jupyter notebook I get the following error:\n\nModuleNotFoundError                       Traceback (most recent call last)\n in \n----> import radix\nModuleNotFoundError: No module named 'radix'\n\nI am currently trying to make this code run on windows and I used Ubuntu to install py-radix. I have this code running on my mac perfectly fine but for some reason I can't seem to make this work in windows. any help?\nAlso I have python3.8 installed.\nI should also note that I have looked at similar posts and tried their solutions but I have run out of ideas and would appreciate any help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":301,"Q_Id":63553833,"Users Score":0,"Answer":"Did you install py-radix in the ubuntu or did you install it in window's. Becuase it if you didn't install it in windows you can open a cmd and type pip install py-radix","Q_Score":0,"Tags":"python,windows,ubuntu,radix","A_Id":63553872,"CreationDate":"2020-08-24T02:03:00.000","Title":"ModuleNotFoundError: No module named 'radix'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a .py file, defining a custom magic, in the \/.ipython\/profile_default\/startup directory, but the intended magic is not being installed.  Is there a way to determine where the fault lies?  Where is execution failing?  Other, very simple .py files in that directory are executing fine.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14,"Q_Id":63553909,"Users Score":0,"Answer":"The short answer appears to be 'no,' there is no way to see what is happening during ipython startup...no log file keeping track of what is happening.\nBut I did solve my problem.\nOpened a jupyter notebook.  With the %load magic, copied the code for the custom magic into a cell.  Copied the code into a code cell and ran it.  Found I needed to install pySerial, and did so.  Voila, custom magic now available.  (Still have to find out if it works as intended.)","Q_Score":0,"Tags":"ipython,startup","A_Id":63565095,"CreationDate":"2020-08-24T02:13:00.000","Title":"How to determine if code for an IPython custom magic is executing on startup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to train a model with Yolo v5 to detect multiple objects on sales flyers. each image in the dataset used in training contains only one object and obviously a single bounding box.\nI'm wondering if that will affect the performance of the model in a bad way? because what I'm trying to do at the end is detecting multiple objects on each sale flyer.\nThank you for your help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":648,"Q_Id":63554029,"Users Score":1,"Answer":"It probably will lower your AP if you work like this, but give it a try. It really depends on your training images and your data augmentations. I dont know about YOLOv5 but YOLOv4 has its Mosaic Data Augmentation which will adress your problem in a way i guess.","Q_Score":1,"Tags":"python,deep-learning,dataset,object-detection,yolov5","A_Id":63558389,"CreationDate":"2020-08-24T02:36:00.000","Title":"Train A Custom Object Detection Model with YOLO v5","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are building a Cloud-based billing software. This software is web-based and should function like desktop software (Atleast). We will have 5000+ users billing at the same time. For now, we only have just 250 users. We are in a need of scaling now. We are using Angular as a Fronten, Python is used for Backend and React Native for Mobile App. PostgreSQL DB is used for Database. I have few doubts, to clarify before we scale.\n\nUsing PostgreSQL for DB will show any issues in the future?\n\nInstead of Integer's primary key, we are using UUID (For easy data migrations, but it uses more space). Is that will introduce any problems in the future?\n\nDo we have to consider any DB methods for this kind of scaling ? (Now, uses a single DB for all users)\n\nWe are planning to use one server with a huge spec (for all users). Is that will be good or do we have to plan for anything else ?\n\nUsing a separate application server and DB server is needed for our this scenario?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":41,"Q_Id":63554864,"Users Score":1,"Answer":"I'll try to answer the questions. Feel free to judge it.\nSo, you are building a cloud-based billing software. Now you have 250+ users and is expected to have at least 5000 users in the future.\nNow answering the questions you asked:\n\nUsing PostgreSQL for DB will show any issues in the future?\n\nans: PostgreSQL is great for production. It is the safe way to go. It shouldn't show any issues in the future, but depends highly on the db design.\n\nInstead of Integer's primary key, we are using UUID (For easy data migrations, but it uses more space). Is that will introduce any problems in the future?\n\nans: Using UUID has its own advantages and disadvantages. If you think scaling is a problem, then you should consider updating your revenue model.\n\nDo we have to consider any DB methods for this kind of scaling ? (Now, uses a single DB for all users)\n\nans: A single DB for a production app is good at the initial stage. When scaling especially in the case of 5000 concurrent users, it is good to think about moving to Microservices.\n\nWe are planning to use one server with a huge spec (for all users). Is that will be good or do we have to plan for anything else ?\n\nans: Like I said, 5k concurrent users will require a mighty server(depends highly on the operations though, I'm assuming moderate-heavy calculations and stuff) therefore, it's recommended to plan for Microservices architecture. Thant way you can scale up heavily used services and scale down the other. But keep in mind that, Microservices may sound great, but in practice, it's a pain to setup. If you have a strong backend team, you can proceed with this idea otherwise just don't.\n\nUsing a separate application server and DB server is needed for our this scenario?\n\nans: Short answer is Yes. Long answer: why do you want to stress your server machine when you have that many users.","Q_Score":1,"Tags":"python,sql,angular,database,postgresql","A_Id":63555334,"CreationDate":"2020-08-24T04:47:00.000","Title":"DB structure for Cloud based billing software, planning issues","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to specify an instrument in an existing MIDI file or during the conversion of this MIDI to WAVE?\nI'm using Python in Windows 10.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":63558497,"Users Score":0,"Answer":"MIDI files contain program numbers. You can change them to get an entirely different instrument.\nMuseScore uses SoundFont files for synthesizing the actual sounds. You can use a different SoundFont file to change the sounds of the instruments.","Q_Score":0,"Tags":"python,python-3.x,midi","A_Id":63566280,"CreationDate":"2020-08-24T09:44:00.000","Title":"Python : Specify an instrument in an existing MIDI file or during the conversion to WAVE file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to loop through the files in a folder with python. I have found different ways to do that such as using os package or glob. But for some reason, they don't maintain the order the files appear in the folder. For example, my folder has img_10, img_20, img_30... But when i loop through them, my code reads the files like: img_30, img_10, img_50... and so on.\nI would like my program to read the files as they appear in the folder, maintaining the sequence they are in.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":63559190,"Users Score":0,"Answer":"My solution would be to use\nmyFiles= os.listdir('directory')\nAnd then use myFiles.sort() to sort them.\nThe sort function would sort them in alphabetical order.","Q_Score":0,"Tags":"python,for-loop","A_Id":63559466,"CreationDate":"2020-08-24T10:24:00.000","Title":"Looping though files in a folder maintaining the order the files are in","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Dask Futures to speed up a Monte Carlo process in python, and am looking to improve the code by displaying a \"time remaining\" feature to the user.  My idea is to somehow grab the time to completion from the previous completed tasks executed by futures to estimate this time remaining value. I see this timing information displayed in the dask scheduler GUI, but is there some way of grabbing this in python code so I can utilize it? Any feedback on this would be greatly appreciated. Thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":63563323,"Users Score":0,"Answer":"If you have a scheduler local to your process (this is commonly the case if you are using LocalCluster at client.cluster.scheduler) then you might want to look at the .total_occupancy attribute.  If you want to go into more detail then check out .task_groups","Q_Score":0,"Tags":"python,time,dask,dask-distributed","A_Id":63784710,"CreationDate":"2020-08-24T14:46:00.000","Title":"Access Time to completion from Dask Task Stream","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to use PandasGui to show intermediate DataFrame results of my app. It works perfectly in Jupyter. However, once I create the executable (using PyInstaller) the app does not work - just cmd shows for a second. Generaly I have no problem with other GUIs after converting to exe (EasyGUI, tkinter, etc.). So this must be something very specific.\nAny ideas how to make it work?\nOr any alternative to PandasGui which works correctly?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":182,"Q_Id":63563714,"Users Score":1,"Answer":"What exactly was the pyinstaller command that you tried for compiling the executable?\nAlso, you may want to consider tkinter or PyQt5 if this problem persists and you're unable to get a solution here since at least the former has worked for you in the past.","Q_Score":0,"Tags":"python,pandas,dataframe,pyinstaller","A_Id":63564100,"CreationDate":"2020-08-24T15:08:00.000","Title":"GUI does not show after creating executable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Am starting learning python, when i want erase all the result in shell, I need to close the shell, can I do this with some command or control keyboard?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":63569746,"Users Score":0,"Answer":"You can use os.system('clear') to talk to the operating system, and ask the system to run the clear command. Of course you have to add import os at the beginning.","Q_Score":0,"Tags":"python,python-3.x,developer-tools","A_Id":63569832,"CreationDate":"2020-08-24T22:58:00.000","Title":"How to clean Python\u00b4s shell?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I plan on uninstalling and reinstalling Python to fix pip. I, however, have a lot of python files which I worked hard on and I really don't want to lose them. Would my Python files be okay if I uninstalled Python?","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":577,"Q_Id":63570453,"Users Score":3,"Answer":"If you are using Linux and a distribution like Ubuntu, you will definitely break the OS. Don't do it.\nMoreover, there is no evidence that your installation is broken because of Python, and you may probably not solve your problem.","Q_Score":1,"Tags":"python","A_Id":63570523,"CreationDate":"2020-08-25T00:38:00.000","Title":"Would it be dangerous to uninstall Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I plan on uninstalling and reinstalling Python to fix pip. I, however, have a lot of python files which I worked hard on and I really don't want to lose them. Would my Python files be okay if I uninstalled Python?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":577,"Q_Id":63570453,"Users Score":0,"Answer":"It depends on whether you installed the Python or it came with the OS.\nIf you installed Python, it\u2019s no problem at all \u2014 your files are safe and uninstalling Python won\u2019t touch them.\nIf you\u2019re planning on uninstalling the Python that came with your OS, I\u2019d advise not do do that \u2014 it could cause a whole lot of trouble. Instead, you could install a new version of Python into your user directory and link to it by adding its location to the PATH variable used by your shell.","Q_Score":1,"Tags":"python","A_Id":63572145,"CreationDate":"2020-08-25T00:38:00.000","Title":"Would it be dangerous to uninstall Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I plan on uninstalling and reinstalling Python to fix pip. I, however, have a lot of python files which I worked hard on and I really don't want to lose them. Would my Python files be okay if I uninstalled Python?","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":577,"Q_Id":63570453,"Users Score":3,"Answer":"Your Python files are not specially managed by Python itself. If you uninstall Python, source code files (files with the .py extension) won't be affected.","Q_Score":1,"Tags":"python","A_Id":63570565,"CreationDate":"2020-08-25T00:38:00.000","Title":"Would it be dangerous to uninstall Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know of the %%writefile .py cell-magic command but it causes the cell to not run. What I want is for the cell to run and create the .py as well.\nEdit 1: I only want the original code in the cell to be saved as a .py file. I don't need the results","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":285,"Q_Id":63570506,"Users Score":1,"Answer":"I would try to:\n\nUse the %%writefile magic in the next cell, referencing the last one\n\nor\n\nUse the %save line magic instead.","Q_Score":1,"Tags":"python,pyspark,jupyter-notebook","A_Id":63571943,"CreationDate":"2020-08-25T00:47:00.000","Title":"Jupyter Notebook - run cell and save as .py file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"I am always getting confused while preprocessing the dataset , whethere to use min max scaler or standard scaler, so basically my question is when to use standard scaler and in which situation can I use MinMax scaler ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":972,"Q_Id":63572758,"Users Score":1,"Answer":"MinMaxScaler say (feature_range = (0, 1)) will transform each value in the column proportionally within the range [0,1]. Use this as the first scaler choice to transform a feature, as it will preserve the shape of the dataset (no distortion).\nStandardScaler() will transform each value in the column to range about the mean 0 and standard deviation 1, ie, each value will be normalised by subtracting the mean and dividing by standard deviation. Use StandardScaler if you know the data distribution is normal.\nIf there are outliers, use RobustScaler(). Alternatively you could remove the outliers and use either of the above 2 scalers (choice depends on whether data is normally distributed)\nAdditional Note: If scaler is used before train_test_split, data leakage will happen. Do use scaler after train_test_split","Q_Score":0,"Tags":"python,machine-learning,dataset,preprocessor","A_Id":63572819,"CreationDate":"2020-08-25T05:51:00.000","Title":"What is the main Difference between Standard Scaler and MinMax Scaler in machine learning while preprocrssing the dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on bayer raw(.raw format) image domain where I need to edit the pixels according to my needs(applying affine matrix) and save them back .raw format.so There are two sub-problems.\n\nI am able to edit pixels but can save them back as .raw\nI am using a robust library called rawpy that allows me to read pixel values as numpy array, while I try to save them back I am unable to persist the value\n\nrawImage = rawpy.imread('Filename.raw')   \/\/ this gives a rawpy object\nrawData = rawImage.raw_image \/\/this gives pixels as numpy array\n.\n.\/\/some manipulations performed on rawData,  still a numpy array\n.\nimageio.imsave('newRaw.raw', rawData)\n\n\n\nThis doesn't work,  throws error unknown file type. Is there a way to save such files in .raw format.\nNote: I have tried this as well:-\n\nrawImageManipulated = rawImage\nrawImageManipulated.raw_image[:] = rawData[:] \/\/this copies the new\ndata onto the rawpy object but does not save or persists the values\nassigned.\n\n\nRotating a bayer image - I know rawpy does not handle this, nor does any other API or Library acc to my knowledge. The existing image rotation Apis of opencv and pillow alter the sub-pixels while rotating. How do I come to know? After a series of small rotations(say,30 degrees of rotation 12 times) when I get back to a 360 degree of rotation the sub-pixels are not the same when compared using a hex editor.\n\nAre there any solutions to these issues? Am I going in the wrong direction? Could you please guide me on this. I am currently using python i am open to solutions in any language or stack. Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":454,"Q_Id":63574377,"Users Score":0,"Answer":"As far as I know, no library is able to rotate an image directly in the Bayer pattern format (if that's what you mean), for good reasons. Instead you need to convert to RGB, and back later. (If you try to process the Bayer pattern image as if it was just a grayscale bitmap, the result of rotation will be a disaster.)\nDue to numerical issues, accumulating rotations spoils the image and you will never get the original after a full turn. To minimize the loss, perform all rotations from the original, with increasing angles.","Q_Score":0,"Tags":"python,image-processing,rotation,edit,raw","A_Id":63574600,"CreationDate":"2020-08-25T07:55:00.000","Title":"Raw image Editing, Rotating and Saving back as Raw","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If you accidentally install a dependency in poetry as a main dependency (i.e. poetry add ...), is there a way to quickly transfer it to dev dependencies (i.e. poetry add --dev ...), or do you have to uninstall it and reinstall with poetry add --dev?","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":2774,"Q_Id":63574469,"Users Score":4,"Answer":"You can also poetry add -D <dep> and poetry remove <dep> in either order. Just be sure to use the same version constraint. Poetry stops\/warns you if you use different constraints as they'd conflict.","Q_Score":19,"Tags":"python-3.x,python-poetry","A_Id":64814045,"CreationDate":"2020-08-25T08:00:00.000","Title":"Transfer dependency to --dev in poetry","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"If you accidentally install a dependency in poetry as a main dependency (i.e. poetry add ...), is there a way to quickly transfer it to dev dependencies (i.e. poetry add --dev ...), or do you have to uninstall it and reinstall with poetry add --dev?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2774,"Q_Id":63574469,"Users Score":24,"Answer":"You can move the corresponding line in the pyproject.toml from the [tool.poetry.dependencies] section to [tool.poetry.dev-dependencies] by hand and run poetry lock --no-update afterwards.","Q_Score":19,"Tags":"python-3.x,python-poetry","A_Id":63578471,"CreationDate":"2020-08-25T08:00:00.000","Title":"Transfer dependency to --dev in poetry","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"To give an example of what I'm trying to do, let's say there is a website that displays results of a lottery every hour. The webpage itself is static with the surrounding text staying the same and only the numbers changing (input by human not updated dynamically).\nSomething like The lucky number is: X where X indicates a different number each hour.\nNow I want to run a python script that parses the number(s) each hour, and then at the end of the day would print out all the numbers in a nice format.\nI know how to get the webpage content and get only the text parts of it without html tags etc by using the BeautifulSoup and requests libraries, however I'm not quite sure how to get the target number.\nI was thinking something like a regex which would find a static word from the text e.g. 'number is:' in this case and then grab the word (number) right after it.\nIs this doable? and if yes, how?\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":63576453,"Users Score":0,"Answer":"It's possible with regex but if you know the string already and if it's static , use simple split on that string.\nLet's say\nvar='The lucky number is: 123'\nOut= int(var.split(':')[1])\nOut will be 123","Q_Score":0,"Tags":"python,web-scraping,beautifulsoup","A_Id":63576713,"CreationDate":"2020-08-25T10:01:00.000","Title":"How can I extract a dynamic number from a webpage content with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If this is true, then is any object in Python just a namespace? Because when we import a module, we use the same dot convention as an object ( example: module.function() & obj.method() ) to access the names in the module. I think accessing an attribute or a method of an object is just specifying the namespace for the attribute\/method you'd like to access. Is this true?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":63579253,"Users Score":0,"Answer":"No, you are also initializing the imported module by running all top-level statements in it (on first import only).\nThe reference you get with the module's name, gives access to the imported module namespace. This namespace is implemented with a dict, and accessing mod.some_attribute is the same as accessing mod.__dict__['some_attribute'].\n\nIs any object just a namespace ?\n\nNo, it is something more (it holds a namespace, it is not one). Every object is an instance of some class. Custom classes happen to implement a namespace in the same way modules do, using an internal __dict__.\nModules are referred in the Python documentation as organizational units for code. You can in fact think of classes much in the same way, as they provide you namespacing capabilities.\nBut there is no inheritance tree to be taken into account when searching for attributes in modules, as there is with classes\/objects.\nIf you want a namespace object just for the namespace benefit itself, use a dict, or an empty class. There is even a types.SimpleNamespace class for that.\n\nI think accessing an attribute or a method of an object is just\nspecifying the namespace for the attribute\/method you'd like to\naccess. Is this true ?\n\nMore or less (that is yes, except the \"just\" word). It uses the object name (a reference) to get to the namespace, and the attribute name as the key for the namespace underlying __dict__ object, but implicit hooks may run code behind the scenes.","Q_Score":0,"Tags":"python,oop,object,module,namespaces","A_Id":65223687,"CreationDate":"2020-08-25T12:51:00.000","Title":"When we import a module, are we just making the namespace of the imported module accessible from the main module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When using cv2.HOGDescriptor().detectMultiScale, what is the starting size of the detection window used? Is it the same size as my training data?\nFor example, if my training data are all 64*128 images then the detection window starts at 64*128?\nand how is the scaling factor used? For example, If I want to detect humans on an image of size 640*512, and I set scale=1.05, how is this 1.05 used?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":63580023,"Users Score":1,"Answer":"The detection window is always 64 x 128 by default.  To accommodate for the multiscale, the image is progressively scaled to create an image pyramid while keeping the detection window of 64 x 128 the same.  This achieves the effect of searching for humans at larger sized search windows in order to keep the search window the same size.  The image pyramid is constructed by progressively decreasing the image size by the scale factor until the 64 x 128 search window can no longer fit inside the rescaled image.  Therefore, if your search images already consist of 64 x 128 images then there will only be one scale.\nThis moves to your next question where if scale=1.05, we produce an image pyramid by progressively resizing the input image rows and columns by rows \/ (scale ** i) and cols \/ (scale ** i) where i = 0, 1, 2, ... to provide an image pyramid.  For each image in the pyramid, we use the 64 x 128 search window to look for the object of interest.","Q_Score":1,"Tags":"python,opencv,image-processing,computer-vision,object-detection","A_Id":63584964,"CreationDate":"2020-08-25T13:32:00.000","Title":"What is the starting size of the detection window?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an array of log values temp= [4,4.05......9]\nThese are actually from 10^4 to 10^9\nfor example, log(10^4)=4 and so on\nI need to take the antilog of temp array to get these numbers from 10^4 to 10^9 but when I calculate np.exp(6.89) it gives me 991\nSo how to take antilog correctly?\nenter code hereEve_gradual_mr24_23=np.exp(np.mean(new_q3[340:350]))","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":390,"Q_Id":63580907,"Users Score":2,"Answer":"np.exp is the exponential in base e. If you want the exponential in base 10, you could use scipy.special.exp10 or simply 10.0**your_array","Q_Score":0,"Tags":"python,numpy,math","A_Id":63582039,"CreationDate":"2020-08-25T14:19:00.000","Title":"calculate antilog in python? np.exp \/ math.exp doesn't work","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The installer always fails in the windows sandbox because it can't install the Visual C++ Redistributable: An error occurred during the installation of assembly 'Microsoft.VC90.CRT,version=\"9.0.30729.1\" I tried to\nUnfortunately I have a piece of software that depends on python2.7. Is there any way to get python2.7 to run in the sandbox?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":339,"Q_Id":63582321,"Users Score":0,"Answer":"More recent versions of the windows sandbox don't expose this behaviour, so it looks like this was a bug inside the sandbox.","Q_Score":2,"Tags":"python-2.7,redistributable,windows-sandbox","A_Id":69781905,"CreationDate":"2020-08-25T15:33:00.000","Title":"How can I install python2.7 in the windows sandbox?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Fairly new 'programmer' here, trying to understand how Python interacts with Windows when multiple unrelated scripts are run simultaneously, for example from Task Manager or just starting them manually from IDLE. The scripts just make http calls and write files to disk, and environment is 3.6.\nIs the interpreter able to draw resources from the OS (processor\/memory\/disk) independently such that the time to complete each script is more or less the same as it would be if it were the only script running (assuming the scripts cumulatively get nowhere near using up all the CPU or memory)? If so, what are the limitations (number of scripts, etc.).\nPardon mistakes in terminology. Note the quotes on 'programmer'.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":571,"Q_Id":63583023,"Users Score":2,"Answer":"how Python interacts with Windows\nPython is an executable, a program. When a program is executed a new process is created.\npython myscript.py starts a new python.exe process where the first argument is your script.\nwhen multiple unrelated scripts are run simultaneously\nThey are multiple processes.\nIs the interpreter able to draw resources from the OS (processor\/memory\/disk) independently?\nYes. Each process may access the OS API however it wishes, to the extend that it is possible.\nWhat are the limitations?\nMost likely RAM. The same limitations as any other process might encounter.","Q_Score":3,"Tags":"python","A_Id":63583166,"CreationDate":"2020-08-25T16:14:00.000","Title":"Performance running multiple Python scripts simultaneously","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How to filter a specific type of image from the rest of the type of image.\nConsider i have a data set consisting of images of dogs only. I need the classifier to differentiate between dogs and all the other types of images in the world that are not dogs.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":16,"Q_Id":63583207,"Users Score":0,"Answer":"I will suggest you use pre trained deep learning models like vgg16, resnet50 which are available in Keras frame work. Train the model on images having only 2 category , i.e with dog and with out dogs. Than run the model on the existing dataset you will definately get your result.","Q_Score":0,"Tags":"python,machine-learning,deep-learning,computer-vision,artificial-intelligence","A_Id":63583320,"CreationDate":"2020-08-25T16:26:00.000","Title":"Cclassification of 1 vs infinite set","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I keep getting messages when I use pip:\n\nPython 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained.\nBlockquote\n\nwhat should I do? Ignore it? I've got python3 installed as well","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":63583401,"Users Score":0,"Answer":"It seems like you have downloaded python 3 but not pip3. The fix to this is very simple. sudo apt-get install python3-pip This command should install pip3 in your system. remember to use pip3 from now on to install packages for python 3. pip is for python 2. Also, don't delete python 2. It is a system requirement.","Q_Score":0,"Tags":"python,linux,pip","A_Id":63590827,"CreationDate":"2020-08-25T16:38:00.000","Title":"Old python version on linux, does it requires upgrade?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've trained my langue model with cmu sphinx and now I want to use it in speech recognition using python script. How to change the default language model or how to use the trained model in recognize_sphinx().","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":530,"Q_Id":63583523,"Users Score":1,"Answer":"c = r.recognize_sphinx(audio, language='zh-cn')","Q_Score":1,"Tags":"python,speech-recognition,cmusphinx,pocketsphinx","A_Id":65210004,"CreationDate":"2020-08-25T16:46:00.000","Title":"use your trained language model in recognize_sphinx() using python with pocketsphinx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a Python GUI using Tkinter, but when I run it directly (double click the file) it opens the black python window but automatically closes by itself in less than half a second. I found a way to make it open the IDLE editor but it just opens the editor and doesn't run it.\nI want it to run the way it runs when you open the IDLE editor and press Run Module. This runs it using Python Shell.\nIs there a way I can make it automatically run using Python Shell?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":487,"Q_Id":63583733,"Users Score":1,"Answer":"Based on Mark Tolonen's comment you should do two things\n\nrename your file to a .pyw from .py to prefer console-less runs\n\nset your system to open .pyw files with pythonw if that's not configured already\n\nLinux: configure xdg-open\nWindows: right click and choose an application from the context menu (you may need to find where Python is installed to select the pythonw.exe executable)","Q_Score":2,"Tags":"python,windows-10,python-idle","A_Id":63583958,"CreationDate":"2020-08-25T16:58:00.000","Title":"How can I make .py files run using Python Shell by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a Python GUI using Tkinter, but when I run it directly (double click the file) it opens the black python window but automatically closes by itself in less than half a second. I found a way to make it open the IDLE editor but it just opens the editor and doesn't run it.\nI want it to run the way it runs when you open the IDLE editor and press Run Module. This runs it using Python Shell.\nIs there a way I can make it automatically run using Python Shell?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":487,"Q_Id":63583733,"Users Score":1,"Answer":"Okay, one of the comments on the original question is correct.\nAs Terry Jan Reedy (user:722804) said,\n\nIt is possible that your mygui.py file is missing 'root.mainloop()' or the equivalent to start the GUI. IDLE lets you omit that during development so that one can interact with tkinter to retrieve values and make changes to widgets.\n\nAdding gui.mainloop() to the end of my program worked.","Q_Score":2,"Tags":"python,windows-10,python-idle","A_Id":63585658,"CreationDate":"2020-08-25T16:58:00.000","Title":"How can I make .py files run using Python Shell by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got the following error message:\nAn HTTP Client raised and unhandled exception: name 'FEATURE_OCSP_MODE' is not defined.\nHowever, I cannot find any reference on the internet about this FEATURE_OCSP_MODE. I was calling describe_addresses() of boto3 using Pythan 3.8. The code was working until yesterday (8\/24\/2020).","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":209,"Q_Id":63583851,"Users Score":2,"Answer":"I rolled back to boto3==1.14.46 and snowflake-connector-python==2.2.10 as I was getting errors in both within Airflow 1.10.10 on Python 3.6.\nThis did the trick.","Q_Score":2,"Tags":"python-3.x,boto3","A_Id":63586825,"CreationDate":"2020-08-25T17:06:00.000","Title":"boto3 refers FEATURE_OCSP_MODE when setting IP address, but cannot find document about it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got the following error message:\nAn HTTP Client raised and unhandled exception: name 'FEATURE_OCSP_MODE' is not defined.\nHowever, I cannot find any reference on the internet about this FEATURE_OCSP_MODE. I was calling describe_addresses() of boto3 using Pythan 3.8. The code was working until yesterday (8\/24\/2020).","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":209,"Q_Id":63583851,"Users Score":3,"Answer":"I have just faced the same problem and the root cause was the snowflake-connector-python version as mentioned by Ben Campbell. In version v2.3.0 they accidentally removed the 'FEATURE_OCSP_MODE' constant but in version v2.3.1 they added it back.\nThe solution is to use snowflake-connector-python==2.3.1 or a newer one.","Q_Score":2,"Tags":"python-3.x,boto3","A_Id":63599231,"CreationDate":"2020-08-25T17:06:00.000","Title":"boto3 refers FEATURE_OCSP_MODE when setting IP address, but cannot find document about it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a MacBook Pro, and I am new to Python and Anaconda.  I am trying to use Spyder as an IDE, and every time I open it, it crashes.  I am running Anaconda from July 2020 with Spyder 4.1.4. I have uninstalled Anaconda, reinstalled it, and rebooted my computer.  Spyder was working fine yesterday, and when I started my computer this morning, it just crashes.  I have tried to downgrade to Spyder 4.1.3, and Anaconda just spins.  Any help would be appreciated.  Thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":369,"Q_Id":63584087,"Users Score":0,"Answer":"I was able to find some documentation online to do \u201cspyder --reset\u201d after rebooting my computer, and it worked.  Thanks!","Q_Score":1,"Tags":"python,anaconda,spyder","A_Id":63585144,"CreationDate":"2020-08-25T17:23:00.000","Title":"Spyder 4.1.4 crashes on MacBook Pro and Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"when I clone a github repository to my pycharm it says that I don't have any python interpreters for that project, but when I open the terminal (pycharm terminal) and type \"python name_of_the_file.py\" it runs the program without problems. Do I have to set up a python interpreter for the project or not?\nps: pycharm doesn't give any kind of error when I import some module for that project (bult-in module and not bult-in modules)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":731,"Q_Id":63585907,"Users Score":0,"Answer":"You just need to tell PyCharm where your Python interpreter is. Go to File -> Project Structure -> Project and select a Project SDK. I suggest creating a new virtual environment for each project.\nOpening the terminal and typing python uses the system's PATH variable to find the executable. PyCharm doesn't use this automatically and you have to set it up.","Q_Score":0,"Tags":"python,python-3.x,git,github,pycharm","A_Id":63585925,"CreationDate":"2020-08-25T19:32:00.000","Title":"I need to set up an python interpreter when i clone a repo on pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to upgrade to the most recent version of python, which is currently 3.8.5.\nWhen I type python3 --version, I get:\nPython 3.7.0\nSo it appears my python is not up-to-date.  I then type brew upgrade python and get a warning:\nWarning: python 3.8.5 already installed\nSo, again, I type python3 --version, and again I get:\nPython 3.7.0\nWhy is python3 --version not returning Python 3.8.5?\n(PS - if I type python --version I get Python 2.7.11 as expected for my Mac)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1728,"Q_Id":63586773,"Users Score":1,"Answer":"You may have multiple python binaries on your system but the system path is finding 3.7.0. The command which python3 will show the path of your current python binary.\nIt might be worthwhile taking a look at the system path with echo $PATH to see where your system is looking for Python\nUpdating your system environment using export as below should enable the system to find python3.8.5\nPATH=\"\/path\/to\/python3.8.5\/bin:${PATH}\"\nexport PATH","Q_Score":0,"Tags":"python,python-3.x,macos,terminal,homebrew","A_Id":63587137,"CreationDate":"2020-08-25T20:41:00.000","Title":"python3 --version command not returning correct version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When trying to update a dictionary with a tuple, I encountered the error:\n>>> dict1.update((\"stat\",10))\nValueError: dictionary update sequence element #0 has length 4; 2 is required\nWhen in reality this shouldn't be happening. From the python docs,\n\nupdate() accepts either another dictionary object or an iterable of key\/value pairs (as tuples or other iterables of length two).\n\nThis makes no sense, since the tuple i supplied clearly has length 2.\n>>> len((\"stat\",10))\n2\nWhat is going on? Is this a bug that isn't resolved yet? Running Python 3.8.0.\nOr was this due to the fact that my dictionary is empty? Tried this with other strings and values, same problem.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2215,"Q_Id":63592741,"Users Score":0,"Answer":"Add a , to the tuple end dict1.update(((\"stat\",10),))\nOr pass a list dict1.update([(\"stat\",10)])","Q_Score":1,"Tags":"python,dictionary","A_Id":63592998,"CreationDate":"2020-08-26T07:37:00.000","Title":"\"dictionary update sequence element #0 has length 4; 2 is required\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am encountering major Python issues with QGIS 3.  I was attempting to install 3rd party libraries from OS4GEO shell. Steps are:\n1- Run shell as admin; 2- py3_env; 3- pip install scikit-learn\nI was getting bugs there so I un-installed QGIS and re-installed it to get a clean slate of python libraries.  When I re-open the newly installed QGIS, I lose python support.  Plugin support is lost and there are no processing options. Uninstalling\/Installing QGIS does not solve the problem.  Oddly enough, it is version specific. If I break 3.4, re-installing it does not fix the problem, but I can install 3.10 and 3.15 and they work.  But then if I try to add Python libraries to 3.10, it breaks and a clean install does not solve the problem.\nHow can I reset the Python for a version, even after using the uninstaller?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":783,"Q_Id":63592980,"Users Score":0,"Answer":"Solved it with a windows system restore and a clean install of any QGIS version. Version 3.10.8 allows external libraries to be installed in the QGIS python 3 environment without more bugs.","Q_Score":0,"Tags":"python,plugins,qgis,pyqgis","A_Id":63599465,"CreationDate":"2020-08-26T07:52:00.000","Title":"QGIS 3 broken\/disabled python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I change an imported python script when running cell by cell imports doesn't work until I restart the whole program VSCode. I tried to kill kernel and restart it, saved changes - nothing works, only restarting is need. But it isn't too quick and appropriate to restart it each time I change the code.\nIs there any way to apply changes in imported scripts? I am on linux lubuntu 20.04.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8683,"Q_Id":63595912,"Users Score":0,"Answer":"When I change an imported python script when running cell by cell imports doesn't work until I restart the whole program VSCode.\n\nIf you are trying to change and save an imported python file, running cell by cell does not work like that. You will have to save all the changes in first go, and then try executing cell by cell; that is because in cell by cell execution in VSCode is handled by a stack and no exclusive information like unchanged data\/status is available to that stack. That's why you'll have to first make all the changes, and then execute.","Q_Score":2,"Tags":"python,visual-studio-code","A_Id":63596008,"CreationDate":"2020-08-26T10:43:00.000","Title":"How to restart kernel in VSCode to completely reload imports?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a problem with all the QPushButton buttons in my PyQt application.\nFor some reason, even if the window has focus, the first click on a button will not register (no 'click affect' or button action occurs). Following this, as though it now has focus, I can click the button, or any other button, on the first go. As soon as the focus changes to another non-button widget, again none of the buttons will click on the first attempt.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":63597208,"Users Score":0,"Answer":"Update:\nThis issue was present for maybe 4 months. After continuing to try everything I could find online and nothing working, I gave up. After about 2 weeks, the issue randomly disappeared.\nI have not made any intentional changes to package versions, but it's possible the issue was fixed in a minor version update of PySide. It has now been good for a few weeks so I am convinced it is solved :)\nThe version of PySide I am currently using is 5.15.1, I'm not sure if this is the same as before but can confirm the issue is not present here","Q_Score":0,"Tags":"python,pyqt,click,focus,qpushbutton","A_Id":64462611,"CreationDate":"2020-08-26T12:01:00.000","Title":"PyQT Buttons do not get focus on first click","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am configuring the Airflow FAB UI to use LDAP authentication. Currently I have this working, but I can only filter by users who are members of one group in LDAP.\nAUTH_LDAP_SEARCH_FILTER = '(memberOf=CN=group1)'\nI would like to authenticate users who are in one of two groups. I have tried multiple variations of the below in the webserver_config.py\nAUTH_LDAP_SEARCH_FILTER = '|(memberOf=CN=group1)(memberOf=CN=group2)'\nbut I am always greeted with this error in the Airflow Webserver logs when trying to log in.\nERROR - {`result`: -7, `desc`: `Bad search filter`, `ctrls`: [] }\nIs filtering by multiple groups possible within the FAB LDAP framework?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":603,"Q_Id":63597222,"Users Score":0,"Answer":"Try adding another set of parentheses inside the quotes to encompass the multiple conditions:\nAUTH_LDAP_SEARCH_FILTER = '(|(memberOf=CN=group1)(memberOf=CN=group2))'","Q_Score":1,"Tags":"airflow,python-ldap,flask-appbuilder","A_Id":68121800,"CreationDate":"2020-08-26T12:02:00.000","Title":"Filter by multiple LDAP groups in Flask App Builder using AUTH_LDAP_SEARCH_FILTER","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"While I\u2019m aware there have been some questions on this, I want to know all my options when it comes to rephrasing statements in python. I tried making synonym fetchers but I got phrases like:\n\nThe spry brown slyboots jumps over the work-shy hound\n\nAnd other things no one would really say. Any specific nltk\/api\/lib recommendations for the best way to approach this? Thanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1307,"Q_Id":63598204,"Users Score":0,"Answer":"The result is meaningless because you don't put the word ambiguity in your mind , each word may have a lot of meanings like (bank ) can be a financial institution  or  the river side\nso you have to solve that - you can solve that by a lot of algorithms like Lesk Algorithms that will solve your problem\nalso you can make paraphrasing using the  translation to a pivot language then re-translate it to English again this will make some differences too","Q_Score":0,"Tags":"python,nlp,artificial-intelligence,nltk","A_Id":63974590,"CreationDate":"2020-08-26T12:57:00.000","Title":"Python rephrasing\/paraphrasing options","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When using Keras recurrent layers, such as an LSTM layer, your input data is supposed to be in the 3-dimensional form of [samples,timesteps,features]. The problem here is that I can't get any reliable information on the order of the timesteps dimension in the input matrices. As a concrete example, would the first element\/row, for a given sample, be the most recent known row of features or the most distant row of features?\nI would suspect that the order would matter since the model is recurrent, and indeed when flipping the order of the timesteps column you end of getting different training results (when you have appropriately set seeds which would yield reproducibility.)\nIf someone would force me to guess, I would assume that the first row (for one sample) would be the most distant features in the sequence, but is there a definite answer here?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":405,"Q_Id":63598509,"Users Score":0,"Answer":"It's easier to picture 3D arrays in Keras as an array of 2D arrays. The first dimension is the samples.\nYour array must be of the shape [samples, timesteps, features]. Picture this as an array of length samples, where each element is itself a 2D array of shape [timesteps, features]. So, to be clear, each element in this array is a 2D array with timesteps number of rows and features number of columns.\nThe first row (index 0) in each of these 2D arrays is the first timestep, i.e., oldest as you say. The last row in each of these 2D arrays is the last timestep, i.e., most recent. For each timestep row, you have features along the columns.\nIt helps to unroll the array as done above to picture it easily and with more clarity.\nHope this helped.","Q_Score":2,"Tags":"python,keras,lstm","A_Id":63599590,"CreationDate":"2020-08-26T13:16:00.000","Title":"Order of timesteps in Keras LSTM training and validation data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have read a data array into pillow via the Image.fromarray method. While I am able to bring it into pillow and successfully paste it onto another image in memory, img.resize((1920,1080)) and img,thumbnail((1920, 1080)) have no effect (and no error).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":91,"Q_Id":63599525,"Users Score":1,"Answer":"That's because this operations create copies affected by the corresponding transformation. Have you tried img = img.resize((1920, 1080))?","Q_Score":0,"Tags":"python,python-imaging-library,image-resizing","A_Id":63600142,"CreationDate":"2020-08-26T14:11:00.000","Title":"Issue using Python PIL\/pillow to resize image","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a newbie in the dev world and I made a big mistake this morning with my 5 database projects made in python. Basically I accidentally deleted the folder with my templates and my code. All of them are deployed on gcloud datastore, but I was wondering if there is any method to rescue or to have a backup folder with all the files. Thank you so much and I hope there is a solution","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":63599695,"Users Score":0,"Answer":"After deletion it is not possible to recover Datastore data unless a backup is available. Usually backups are not necessary as data is replicated across multiple data centers.","Q_Score":0,"Tags":"python,web-deployment,gcloud,datastore","A_Id":63602954,"CreationDate":"2020-08-26T14:20:00.000","Title":"Deleted accidentaly folder with projects deployed on gcloud datastore","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Sorry, I'm a noob in iptables.\nI have a VPN app which binds on local port 1080, while it goes to destination port 1194 (openvpn). The app does not support privileged port binding (which needs root, of which I have). I want the app to bind on local port 25. I have browsed Google and the answer seems to be iptables. I have seen many posts, of which many say the SNAT target is the one I should use.\nI have tried this code:\niptables -I POSTROUTING -o wlan0 -t nat -p tcp --destination 195.123.216.159 -m tcp --dport 1194 -j SNAT --to-source 192.168.43.239:25\nAnd these:\niptables -I FORWARD -p tcp -d 192.168.43.239 -m tcp --dport 25 -j ACCEPT\niptables -I FORWARD -p tcp -s 192.168.43.239 -m tcp --sport 25  -j ACCEPT\niptables -I OUTPUT -o wlan0 -p tcp -m tcp --sport 25 -j ACCEPT\niptables -I INPUT -i wlan0 -p tcp -m tcp --dport 25 -j ACCEPT\nWhat I want is to make the output to be something like this when I run the netstat command:\n\ntcp       0      0 192.168.43.239:25      195.123.216.159:1194      ESTABLISHED\n\nBut instead, after running all the codes, the output to netstat becomes this:\n\ntcp       0      0 192.168.43.239:1080      195.123.216.159:5000      ESTABLISHED\n\nIs it impossible to change binding port using iptables? Please help me to understand the concepts of networking.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":63599735,"Users Score":0,"Answer":"Turns out iptables was just doing its job correctly. Translated packets turn out to not be tracked by netstat. I was lost and completely didnt understand that iptables doesnt alter ip v6 traffic of which the app was using. And the forward rules where not necessary since the chain policy was to accept the packets.","Q_Score":0,"Tags":"sockets,tcp,iptables,python-iptables","A_Id":68606109,"CreationDate":"2020-08-26T14:22:00.000","Title":"Is there a way to change local port bound using iptables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm very confused with python variables. I read several chapters from different books on variables and some explanations are contradictory some just differ slightly but still they differ.\nSome use visual explanations which are not necessarily helpful.\nThe following is my understanding which is basically the intersections of all the chapters facts.\nI'm looking for someone to correct me so I can put this to rest. I can't sleep. Help me!\nUnderstanding:\nEverything in python is an object. Every name of a variable(identifier) is a reference to an object.\nI think for a reference you need at least two memory units like this :\n<address><content>\nThe identifier of a variable is connected to the address of the first memory unit. The content of this unit is a connection to another memory unit's address whose content can now be a value (simple data types) or another even another reference (complex data types).\nSo as of now I think this is how a reference works in general and in python.\nContradictory to that I often see for simple data types that it's displayed in a way that the content of the first unit is already the value itself.\nThis aligns with my understanding of a primitive data type in C.\nSo can somebody please bring order into my mental chaos?\nThanks everyone for taking the time! I really appreciate it.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":53,"Q_Id":63602581,"Users Score":1,"Answer":"In CPython, variables access their value by following a C pointer of type PyObject*. The pointer points to a struct which may contain the value directly, or have other C pointers to it. The first few fields of the struct contain type information, and determine how to interpret the rest.\nAfter a = b, both variables will point to the same struct.","Q_Score":0,"Tags":"python,variables,memory,reference","A_Id":63602772,"CreationDate":"2020-08-26T17:12:00.000","Title":"How are variables in Python actually implemented?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a parquet file which contains list of structs and I cannot seem to read it with any of the available python parquet libraries. Some of them return an error noting that 'list of structs' is not yet supported and the others just make a pandas dataframe with None objects. If anyone has any experience with this it would help a lot. I have been banging my head with this for the last few days. Is there any other way to programmatically read the file somehow or convert that file to some other format and then read it ?\nI want a python native support or c library can be called using Python that does not involving calling or starting other services like Spark.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":446,"Q_Id":63603023,"Users Score":0,"Answer":"Try uninstalling pyarrow and install fastparquet. This worked for me. I was trying to convert it to CSV using pandas.","Q_Score":1,"Tags":"python,parquet,pyarrow,fastparquet","A_Id":63703221,"CreationDate":"2020-08-26T17:42:00.000","Title":"How to read nested struct Parquet files in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 150 GB file in s3,I would like to unzip and upload the each file back to s3.what is the best approach to do with python and EC2 ? I appreciate your response.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":63604509,"Users Score":0,"Answer":"Download it on your system\nUnzip the folder and it will create a normal folder say \"Unzipped_Folder\"\nAssuming you are using Windows, install aws-cli in that.\nCreate an IAM User with S3 write access to that bucket and create a Access and Secret Access Key.\nIn aws-cli add the credentials from command prompt.\n$ aws configure\nNow run the following command to send files to S3 bucket\n$ aws s3 cp your_directory_path s3:\/\/your_bucket_name --recursive","Q_Score":0,"Tags":"python,amazon-s3,amazon-ec2,boto3","A_Id":63795510,"CreationDate":"2020-08-26T19:29:00.000","Title":"how to unzip the file from s3 using EC2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using matplotlib to plot a KDE. The issue with this is I'm using ax.imshow, which only takes in a grid and an extent. Meaning it will linearly space the data from the grid using the minimum value in the extent to the maximum.\nI need to flip the y axes (doable), but then I also need to arbitrarily scale every y point by a function, not just a simple factor. As an example, if the y value is 5, I need it to be mapped to f(5)=13 and 6 should be mapped to f(6)=22. The point is, it's not a simple scale.\nIs there any way of modifying these y values after they have been plotted, or am I forced to modify these values before-hand.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":63608699,"Users Score":1,"Answer":"I couldn't find a way to modify the y values, but I could find a way to modify the labels of the yaxis.\nBy scaling the yaxes with the desired function and its inverse, using the following:\nax.set_yscale('function', **{'functions':[forward, inverse]})\nThen scaling the axes ytick values by the desired function and setting the ytick labels to be the scaled yticks, you effectively scale the y values:\nax.set_yticklabels(forward(ax.get_yticks()))","Q_Score":0,"Tags":"python,matplotlib,kde-plasma","A_Id":63716562,"CreationDate":"2020-08-27T03:23:00.000","Title":"Modify matplotlib y values after plotting","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a image and I want to do HE or CLAHE on specific area of the image.\nI already have a mask for the image.\nIs there any possible way to do so?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":566,"Q_Id":63608938,"Users Score":0,"Answer":"You can simply crop the area that you want to apply CLAHE on it and then process the cropped image","Q_Score":3,"Tags":"python,opencv","A_Id":63609101,"CreationDate":"2020-08-27T03:56:00.000","Title":"How to do Histogram Equalization on specific area","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the following dates in a text file,\n04\/20\/2009;04\/20\/09;4\/20\/09;4\/3\/09;\nMar-20-2009;Mar 20, 2009;March 20, 2009;Mar. 20, 2009;Mar 20 2009;\n20 Mar 2009;20 March 2009;20 Mar. 2009;20 March, 2009;\nMar 20th, 2009;Mar 21st, 2009;Mar 22nd, 2009;\nFeb 2009; Sep 2009; Oct 2010;\n6\/2008;12\/2009;\n2009;2010\nI am trying to match the content inline 5 (Feb 2009; Sep 2009; Oct 2010;) without capturing any of the other dates.\nI have written the following regular expression, but its capturing parts of the other dates as well,\nexpr_5 = re.findall(r'(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]*\\s\\d{4}',date)\nout:\nExpr list 5 : [(11, ['Mar 2009']), (12, ['March 2009']), (20, ['Feb 2009']), (21, ['Sep 2009']), (22, ['Oct 2010'])]\nNote that the number in front of the output is just the index to easily identify the position of the date in the list. How do I get rid of dates index 11 and 12? (They part of the dates from line 3)\nAlternatively,\nThe expression below captures all of the dates on line 3. Is there a way to combine this expression to capture all the dates in line 5 as well (everything from line 3 and line 5)\nexpr_3 = re.findall(r'\\d{2}\\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]*[\\s.,]*[\\s]?\\d{4}',date)\nout:\nExpr list 3 : [(11, ['20 Mar 2009']), (12, ['20 March 2009']), (13, ['20 Mar. 2009']), (14, ['20 March, 2009'])]","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":63609055,"Users Score":0,"Answer":"Do you mean you want to get 3 last item from your regex result? Try this:\nexpr_5 [-3:]\nyou'll get the output like this:\n['Feb 2009', 'Sep 2009', 'Oct 2010']","Q_Score":0,"Tags":"python,python-re","A_Id":63609473,"CreationDate":"2020-08-27T04:11:00.000","Title":"Regular Expressions matching dates (greedy)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use Anaconda with Spyder that was installed in Anaconda to learn python.\nThe problem: when I'm trying to save python scripts by extending the file name to .py, the python script automatically gets saved in the Windows notepad. And when I try to open that again in Spyder it doesn't open.\nIn other words, in Spyder I saved the script by doing \"file - save as - 'filename.py'\"\nand I tried to open the saved script by doing \"file - open - 'filename.py'\" in Spyder.\nHowever, it doesn't work.\nI two questions about this.\n\nIs it normal for python scripts to be saved on windows notepad? If not, what is wrong here and how do you normally save python scripts with Anaconda?\n\nWhy doesn't Spyder open the notepad file, the python script I saved? I added the extention .py when I saved it but it is not opening in Anaconda Spyder regardless.\n\n\nI realize this is a basic question to many and the answer may exist somewhere but I have a very hard time finding it and I'm hoping someone can help me solve this problem. Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":538,"Q_Id":63609209,"Users Score":1,"Answer":"Answer to the First question\nIs it normal for python scripts to be saved on windows notepad? If not, what is wrong here and how do you normally save python scripts with Anaconda?\n\nCheck what default program is set\nfor opening .py file in your system you can change it by\nrightclicking on .py file >expand open with > choose open with another\napp and tick the option 'always use this for .py file'\n\nSecond question\nWhy doesn't Spyder open the notepad file, the python script I saved? I added the extention .py when I saved it but it is not opening in Anaconda Spyder regardless.\n\nCheck type of file your saving \"the field below filename it should be\nallfiles(*)\" probably your script is saving \"filename.py.txt\" which is\nnot a proper format for python file","Q_Score":1,"Tags":"python,anaconda,spyder,notepad","A_Id":63609288,"CreationDate":"2020-08-27T04:29:00.000","Title":"Saving and opening Python Script in Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a windows 10 laptop, and i needed to install anaconda for some project, i used add to path option in the installation but now, i want to use the normal python path instead of the anaconda one, can someone please guide me.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":482,"Q_Id":63610210,"Users Score":2,"Answer":"To edit your environment variable:\nControl Panel > System and Security > System > Advanced system settings > Environment variables\nNow you should see 2 tables one for user variables and the other for system variables. In both tables there is a variable called Path. Try to edit both, if you find some anaconda path in one of them you can remove them. If you don't want to remove them but still want to use another python interpreter you can move the anaconda path under the python path.\nPS: Normally you should only edit user variables, anaconda path will not be set in system variables.","Q_Score":1,"Tags":"python,path,anaconda","A_Id":63612678,"CreationDate":"2020-08-27T06:16:00.000","Title":"Python - Anaconda - How to remove anaconda from Path (I dont want to uninstall anaconda)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am wondering about the complexity of pythons string.encode() function. Is it linear or worse?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":63612358,"Users Score":0,"Answer":"Since string.encode() is just a function that encodes one character to another in different encoding, the worst complexity can be O(n) when all characters need to be replaced. Thus the function is linear.\nEdit: to consider even the lookup phase for the character just for understanding:\nDictionaries are used for translating a character into another character. looking up for an element in a dictionary is considered to be of complexity O(1). Final complexity stays O(n) in worst case.","Q_Score":0,"Tags":"python,string","A_Id":63612483,"CreationDate":"2020-08-27T08:44:00.000","Title":"What is the complexity of string.encode()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I use a class for my tkinter GUI, seems like I don't have to deal with the order of the declaration of variables and the input parameters of functions. However, the main thing is that, when I don't use a class for my tkinter GUI, I cannot use any event handling for my buttons.\nSo, is it necessary to use a class for tkinter GUI event handling?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":63613070,"Users Score":0,"Answer":"No, classes aren't required in order to be able to handle events.","Q_Score":0,"Tags":"python,user-interface,button,tkinter,event-handling","A_Id":63616020,"CreationDate":"2020-08-27T09:29:00.000","Title":"Python tkinter GUI simple noob question: Is it necessary to use a class for tkinter GUI event handling?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been trying to run my code and it throws an Import Error that says  DLL load failed while importing qhull: The specified module could not be found.\nWhat could be wrong, and what can I do to fix this","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4738,"Q_Id":63613167,"Users Score":0,"Answer":"Your question is too generic: there can be many reasons. My easiest and quick way to solve such class of problems (assuming you already checked the environment, and that you have relevant packages):\n\nremove all python cache (.pyc files)\n\nand if this doesn't solve the problem do:\n\ncopy the setting of your virtual environment (or conda environment)\n\ndelete the virtual environment (and then move or remove the remaining files)\n\ncreate again the environment, with the packages you got from first point\n\n\nVery often, with such procedures, you get again a working environment. It seems that on some updates, some files remain in the wrong place, and so the wrong version of a DLL is used, and it confuse python and windows, about inconsistent status.\nSometime you may have segmentation fault in Python program, alternate to failed to load DLL error.","Q_Score":1,"Tags":"python,python-3.x,pycharm,importerror","A_Id":63613415,"CreationDate":"2020-08-27T09:35:00.000","Title":"Pycharm Error: DLL load failed while importing qhull: 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":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a conda env with tensorflow 2.2.0 But now I want to create a new env with tensorflow 1.14.0.\nI used conda create --name tensorflow1_14 tensorflow-gpu==1.14.0 to create a new env.\nBut when I tried checking the tensorflow version in this env it still gives me 2.2.0\nand when I use conda list it shows the tensorflow-gpu version as 1.14.0\nBecause of this I cannot use the tf 1.14.0 Where am I going wrong?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1836,"Q_Id":63616215,"Users Score":0,"Answer":"If someone is wondering what went wrong! here is the solution.\nThere was an overlap of pip and conda install. Steps followed:\n\nconda uninstall tensorflow-gpu==2.2.0\npip uninstall tensorflow-gpu==2.2.0\nconda install tensorflow-gpu==1.14.0","Q_Score":0,"Tags":"python,tensorflow,anaconda,version,conda","A_Id":63632866,"CreationDate":"2020-08-27T12:40:00.000","Title":"Anaconda new environment with tensorflow 1.14 version","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was using virtualenv in terminal when my terminal crashed and all my libraries were working fine. All my packages\/libraries are in  \/Library\/Python\/2.7\/site-packages directory. I am using Python 3.8 I have tried export PYTHONPATH=\/Library\/Python\/2.7\/site-packages but this also does not work when I run my programs. I also get this error on certain programs: ImportError: Missing required dependencies ['numpy']-although Numpy is there in path I mentioned earlier. After the terminal crashed I can no longer create virtualenv's either, something is very wrong.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":63616389,"Users Score":0,"Answer":"use python -m pip install [package] to install all packages.","Q_Score":0,"Tags":"python,macos,terminal,package,libraries","A_Id":65349834,"CreationDate":"2020-08-27T12:51:00.000","Title":"Python Libraries not working in Terminal on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"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":"PRAAT provides a way: \"Process-> Change formants...\", but if I use Parselmouth call:\nsound = call(sound0, \"Change formants...\", f1, f2, f3, f4, 0, 5000)\nI get:\n\"parselmouth.PraatError: Command \"Change formants...\" not available for given objects.\"\nI really like Parselmouth, but I do wish more examples were available.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":200,"Q_Id":63620262,"Users Score":0,"Answer":"Can be using \"parselmouth.praat.run_file(path_to_script, parameters)\".\nPath to script can be obtained from PRAAT's Process->script (in the opened window will be shown path). Doesn't immediately work with some scripts though...\nAs in case of 'Changeformants.praat' had to comment line20 (\"include batch.praat\") and then:\nsound = parselmouth.praat.run_file(sound0, path_to_script, f1, f2, f3, f4,0,5000, True, False)\ndid work.","Q_Score":1,"Tags":"python,praat","A_Id":63629548,"CreationDate":"2020-08-27T16:21:00.000","Title":"Is there a way to change formants using parselmouth (python PRAAT wrapper) or other python libraries?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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 would like to install pip for the default installation of Python on Mac OS.\nPlease don't recommend brew, I already have it and installed Python 3 with it, but it seems that Automator only knows how to use the default version of Python located in \/usr\/bin\/python That's the reason behind my specific request\nI did my homework first, or tried to, before asking the question, but what I found confusing is that the recommended method seems to be using get-pip.py, but the pip documentation says\n\nWarning Be cautious if you are using a Python install that is managed\nby your operating system or another package manager. get-pip.py does\nnot coordinate with those tools, and may leave your system in an\ninconsistent state.\n\nThis threw me off, as I don't want to risk breaking the default Python on Mac OS, as I understood that might mess my system.\nI also didn't want to use the deprecated easy_install.\nAnd I couldn't find an answer to my question, as usually the answers just recommend installing a different version of Python with brew.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":175,"Q_Id":63625520,"Users Score":0,"Answer":"Problem\nSeems like Automator isn\u2019t loading \/usr\/local\/Cellar\/bin into your PATH. You can echo $PATH in Automator to confirm this.\nSolution\nReinstall using brew and ensure that you run brew link python.\nYou can export PATH=... before running your script or move \/usr\/bin\/python to \/usr\/bin\/pythonx.x where x is the default version installed, then symlink \/usr\/bin\/python to your brew installed python in \/usr\/local\/bin\/.","Q_Score":0,"Tags":"python,macos,pip","A_Id":63751388,"CreationDate":"2020-08-27T23:40:00.000","Title":"Installing pip with default python on Mac OS 10.14 Mojave","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"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 believe the tittle itself is sufficient.\nI'm currently learning GUI programming using Tkinter in python.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":107,"Q_Id":63627125,"Users Score":1,"Answer":"I actually wanted to comment this (but seems like i don't have enough reputation), so here is a simple breakdown.\ntkinter is a really nice library (it's beginner friendly - fairly customized), I will highly recommend sticking with tk (because u r already learning it - it will totally comply with your requirement of less resources' consumption ).\nI would suggest you to give a try to kivy - if and only if u wish to target mobile devices - it allows native development. Although it uses fair amount of resources which might -in some cases- overlook your system resources.\nNOTE: Having said that, if you you require apps with powerful GUI experience, PyQT is definitely a better choice but from what I know, PyQt may not be able to fulfill your priority of less resources' consumption.","Q_Score":0,"Tags":"python,user-interface,widget","A_Id":63627627,"CreationDate":"2020-08-28T03:42:00.000","Title":"Which cross platform GUI toolkit to use if less resource consumption is a priority","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"I've worked through all the threads concerning this problem but haven't found anything.\nWhenever I try to download a file from Wasabi S3, I get a 403 forbidden error. The file is uploaded with a pre-signed url that was signed with the same access key as the one I am using for the download request.\nFor the signed url I tried setting the ACL to \"private\" as well as \"public-read\". But that hasn't changed anything. I did also experiment with different access keys with different permissions for signing and downloading. But also no change.\nAny more suggestions would be highly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":435,"Q_Id":63630434,"Users Score":0,"Answer":"Long story short, the endpoint_url parameter is not optional when initializing boto3.client.","Q_Score":0,"Tags":"python,amazon-s3,boto3,pre-signed-url,wasabi","A_Id":63686436,"CreationDate":"2020-08-28T08:46:00.000","Title":"boto3 upload_file() 403 forbidden with Wasabi S3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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":"For Example:\nI have developed a django Application which contains four apps inside called app_1, app_2, app_3 and app_4.\nNow I want to deploy app_1 on server_1, app_2 on sever_2, app_3 on server_3 and app_4 on server_4.\nIs it possible??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":185,"Q_Id":63631242,"Users Score":0,"Answer":"No, i don't think deploying each apps to different server is possible if all the apps are entitled same project.","Q_Score":1,"Tags":"python,django,amazon-web-services,hosting","A_Id":63631710,"CreationDate":"2020-08-28T09:39:00.000","Title":"How to deploy each app of a Django project into different servers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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":"For a data science project I used to calculate the week numbers through this code:\ndf['Week_Nr'] = df['Date'].dt.week\nAs this function is now depreciated I changed to\ndf['Week_Nr'] = df['Date'].dt.isocalendar().week\nYet my output used to be in int64 and now is in UInt32\nAnd this is causing an error in a following calculation: \"ValueError: DataFrame.dtypes for data must be int, float or bool.Did not expect the data types in fields Week_Nr\"\nSo my question is how I can modify the isocalendar().week to give me a int64 output or how to transform the column to int64 as I have not been successful in finding the right code.\nThis code did not work: df['Week_Nr'] = pd.to_numeric(df['Week_Nr'],errors='coerce')","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":422,"Q_Id":63634630,"Users Score":2,"Answer":"try .astype(numpy.int64) or .astype(\"int64\")","Q_Score":0,"Tags":"python,python-3.x,pandas,dataframe,integer","A_Id":63634663,"CreationDate":"2020-08-28T13:22:00.000","Title":"Change UInt32 to int64 for dt.isocalendar().week calculations","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to load a XBGClassifier model with joblib and pickle.\nWhen using joblib loaded_model = joblib.load('trained_model.sav') I'm getting the following error: AttributeError: module 'xgboost.compat' has no attribute 'XGBoostLabelEncoder'\nAnd with pickle loaded_model = pickle.load(open('trained_model.sav', 'rb')) I get AttributeError: Can't get attribute 'XGBoostLabelEncoder' on <module 'xgboost.compat' from 'C:\\Users\\Usuario\\Anaconda3\\lib\\site-packages\\xgboost\\compat.py'>\nI installed xgboost again but it doesn't work, what might be the issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1841,"Q_Id":63634910,"Users Score":0,"Answer":"Make sure that the xgboost versions in the saved and loaded environments are the same. You need to change the version of xgboost in the environment that you try to load model.","Q_Score":5,"Tags":"python,pickle,xgboost,joblib","A_Id":64227604,"CreationDate":"2020-08-28T13:38:00.000","Title":"joblib.load and pickle.load error \"No attribute 'XGBoostLabelEncoder'\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a timer, when the time is up, it shows a notification using the module plyer but when I turn it into an executable with pyinstaller using the command pyinstaller timer.pyw and run it, the notification does not show and the window just crashes. I think it's because that pyinstaller does not support plyer. I've tried using the --hidden-import option but it still does not work. how do I solve this problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":137,"Q_Id":63636533,"Users Score":1,"Answer":"I just went to python's site-packages folder, for me it was c:\\python\\Lib\\site-packages\\ and copied the plyer folder to the PyInstaller directory.","Q_Score":0,"Tags":"python,pyinstaller","A_Id":64448486,"CreationDate":"2020-08-28T15:13:00.000","Title":"problem with plyer when using PyInstaller","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"The app is a canvas-based app. For a certain box on the gui, when the user clicks it, I bring up a checkbutton dialog.  The dialog contains a color coded gif image at the top. Below that are 48 checkbuttons arranged in groups of 4.  Each group of four corresponds to a color in the gif image. So I set the background color of each checkbutton to its corresponding color in the gif image.  This helps the user select the appropriate button.  The colors are just rgb strings like \"#00cc00\", etc.\nMy problem is, when I run on Linux, the background colors of the checkbuttons do not appear unless I mouse over the checkbuttons. Otherwise they just have a gray background. When I run on Windows from MobaXterm, it works like a charm.  The background colors appear immediately.  However, the target platform is Linux.\nI've tried the following: Using ttk and not using ttk.  Forcing a dialog update, forcing a \"do-nothing\" mouse enter event.  None of this has worked though.  The python 3 version is anaconda 3.7.6 with tkinter 8.6.10.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":63637531,"Users Score":0,"Answer":"I found a solution. For each checkbutton, I bind events Enter and Leave to a callback that does nothing, just returns. Then, after the dialog is created, I call event_generate first to Enter then to Leave the checkbutton.\nThis appears to solve the issue, and the dialog works correctly as well.\nThough, if someone has a more elegant solution, I would like to see that as well.","Q_Score":0,"Tags":"python-3.x,tkinter","A_Id":63639042,"CreationDate":"2020-08-28T16:17:00.000","Title":"Python 3 tkinter checkbutton dialog with different background colors","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying an automation project with selenium 3.141.0 and chrome 84 driver. But the code was getting stuck despite adding correct id and details. I would like to know whether its a compatibility issue or something else.\nPlease help me!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1397,"Q_Id":63638862,"Users Score":0,"Answer":"I was making a FB automation project.\nfrom selenium import webdriver\nfrom time import sleep\ndriver=webdriver.Chrome(r'C:\\Users\\samar\\OneDrive\\Desktop\\MAIN\\projects\\Jarvis\\chromedriver.exe')\ndriver.get('https:\/\/www.facebook.com')\nemail=driver.find_element_by_xpath('.\/\/*[@id=\"email\"]')\nemail.send_keys('username')\npassword=driver.find_element_by_xpath('.\/\/*[@id=\"pass\"]')\n'''with open('pass.txt','r') as myfile:\n    password1=myfile.read().replace('\\n','')'''\npassword.send_keys('password')\nlogin=driver.find_element_by_id('u_0_b')\nlogin.click()\nsleep(3)\npostarea=driver.find_element_by_xpath('\/\/*[@id=\"mount_0_0\"]\/div\/div[1]\/div[1]\/div[3]\/div\/div\/div[1]\/div[1]\/div\/div[2]\/div\/div\/div[3]\/div\/div[2]\/div\/div\/div\/div[1]\/div')\npostarea.click()\nsleep(3)\nactivepostarea=driver.switch_to_active_element()\nactivepostarea.send_keys(\"Hello World\")\nBut as it reached the FB homepage after login. A message popped up for asking permission for notification i.e. allow or block. And then the following error came.\nraise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {\"method\":\"xpath\",\"selector\":\"\/\/*[@id=\"mount_0_0\"]\/div\/div[1]\/div[1]\/div[3]\/div\/div\/div[1]\/div[1]\/div\/div[2]\/div\/div\/div[3]\/div\/div[2]\/div\/div\/div\/div[1]\/div\"} (Session info: chrome=84.0.4147.135)","Q_Score":0,"Tags":"python-3.x,selenium,selenium-webdriver,selenium-chromedriver,google-chrome-devtools","A_Id":63642995,"CreationDate":"2020-08-28T18:03:00.000","Title":"Is chrome 84 webdriver compatible with selenium 3.141.0?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a web site using Django and Python as a backend language.\nWe need to integrate part of a Pascal\/Delphi code into our system, the thing is, that this pascal code has more than 4 k lines, and there are some math operations with bytes and binary generation (main idea of the Script) that could slow down the process for people that have not interacted before with this language.\nMy question would be, what would you do in this situation, So far we have received just an idea of translating the code to Python ( this would need to translate the Binary generations and most of the 4k lines of the code)... I would like to know if there is another workaround to approach this situation in your opinion.\nthanks!","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":281,"Q_Id":63641015,"Users Score":3,"Answer":"You can easily convert the Delphi code in a high-performance REST backend and call the endpoints from your web solution in Python. As options for the backend you can consider RAD Server, DataSnap, Delphi MVC Framework, Horse, and many others available out there.","Q_Score":1,"Tags":"python,delphi,binary,pascal","A_Id":63641702,"CreationDate":"2020-08-28T21:23:00.000","Title":"Solution to use Pascal\/Delphi code in a python enviroment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a VS Code (Linux Mint) plug-in for Python that allows me to choose between different interpreters.\nWhen I run my file with Python 3.8, I get an error saying that it can't find pandas I am trying to use, but when I switch the interpreter to Python 3.6 there is no issue finding pandas.\nWhat's going on?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":63641497,"Users Score":0,"Answer":"The module might not be updated for Python 3.8. Search up the module's name from GitHub or where it can be imported from to see what versions they support.","Q_Score":0,"Tags":"python,linux","A_Id":63641558,"CreationDate":"2020-08-28T22:14:00.000","Title":"Module Not Found Error with one version of of Python, but no the other","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a VS Code (Linux Mint) plug-in for Python that allows me to choose between different interpreters.\nWhen I run my file with Python 3.8, I get an error saying that it can't find pandas I am trying to use, but when I switch the interpreter to Python 3.6 there is no issue finding pandas.\nWhat's going on?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":63641497,"Users Score":0,"Answer":"That module isn't installed for Python 3.8, simple as that. Different versions of Python have different libraries (listed under sys.path) on Debian-based distros.\nWithout knowing which module, it's hard to say much else, like whether it even supports 3.8, but to install it, you might be able to use apt or pip.","Q_Score":0,"Tags":"python,linux","A_Id":63641579,"CreationDate":"2020-08-28T22:14:00.000","Title":"Module Not Found Error with one version of of Python, but no the other","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After upgrading my system interpreter to python@3.8 with brew, now everything got out of order. I think brew had symlinks of pip3 through pip which enabled the direct use of pip install <package> instead of using pip3 after the upgrade, this thing stopped existing, whenever I call pip, I get a bad interpreter: No such file or directory <python3.7 old directory> and I wasn't able to install any new packages unless I refer to pip3.8 by full path which is in \/usr\/local\/Cellar\/python@3.8. So I symlinked pip to pip3.8 which is not the best practice ever, and most packages depend on python3.7 are currently crashing ex: jupyter notebook, which when I start using jupyter notebook from the terminal, it opens jupyter in the browser, but as soon as I open a notebook, I get a kernel error because for some reason it depends on python3.7 which is not there. Even when I tried python3.8 -m jupyter notebook I get the same error. Needless to mention most of the packages that are launched from the terminal ex: scrapy are looking for python3.7 interpreter. So I installed python@3.7 using brew which is automatically not installed in \/usr\/local\/bin or \/usr\/bin to avoid clashing with the system.\nSo ... you got the idea, I have a mess and as I do not understand the dynamics of how python structure lives within OSX system I was thinking the best way is wipe all python3.x including packages, pip and various components, break dependencies and let them depend on native python2.7 maybe or I don't know I'm sure there is some clean way to do it and then do a clean install of python3.8. Any suggestions on how to do this without creating more mess and be able to clean everything up and do that clean python3.8 install at the end?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":358,"Q_Id":63642939,"Users Score":1,"Answer":"You might try using which python or which python3.8 to be able to find where they are and remove em if that's what you want to do.\nYou can also try alias python=python3.8 or whatever version you end up needing. To make it so you don't have to type that every time you open a new terminal, you can edit ~\/.bashrc and add it in there that way it's the default.","Q_Score":0,"Tags":"python,macos,homebrew,upgrade,python-3.8","A_Id":63644232,"CreationDate":"2020-08-29T02:46:00.000","Title":"How to wipe the entire python3.x with all installed pip packages and pip on macOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have installed git, github desktop, python 3.7.0 and 3.8.1 and have py.exe in my c:\/\/windows folder. Nevertheless, when I try to type a command in power shell in github desktop for a repo that I have cloned, it says that the \"pip\" is not recognized . Any idea how to fix this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":102,"Q_Id":63646827,"Users Score":0,"Answer":"Executables are searched om your PATH environment variable, which probably doesn't include c:\\windows. You need to edit this environment variable and add c:\\windows to it.","Q_Score":1,"Tags":"python,git,github,github-for-windows,github-desktop","A_Id":63646920,"CreationDate":"2020-08-29T12:13:00.000","Title":"\"pip\" is not recognized in GITHUB desktop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to generate a ndArray to compare it with an existing one, which is structured as follow:\n\nthe first column dtype is 'datetime' (Timestamp('2020-08-29 00:00:00))\nall the other n columns dtype are 'float' (nan)\n\nThe way I found till now is to define the array as:\ndataset = np.array((timestamp_vector, nan_vector, nan_vector, ...), dtype=object)\nI do not want to repeat 'nan_vector' n-time. Do you have some advice?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":69,"Q_Id":63647869,"Users Score":-1,"Answer":"To improve the above ndarray construction, I made a for loop where I used the concatenate function to add a new nan array, previously created with the same length of timestamp vector.","Q_Score":0,"Tags":"python,numpy,timestamp,numpy-ndarray","A_Id":64303183,"CreationDate":"2020-08-29T14:07:00.000","Title":"Python ndArray Generation [Different Data Type Columns]","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a site build in site123 (site123 is a WYSIWYG and it dose not support code export). I use it as a nice designed landing page and product's catalog. so I have:\nhttps:\/\/app.site123.com\/?w=my_site this site has no back-end (not supported by site123). and I have another site build in django for payments and other stuff like this I host it on pythonanywhere, So I also have http:\/\/my_website_with_backed.pythonanywhere.com\/.\nNow, I buy a domain from GoDaddy and I would like to know if there is a way to connect the 2 websites under the same url??. like:\nsite123 website: www.catalog.my_own_url.com\ndjango website: www.payment.my_own_url.com\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":63648415,"Users Score":2,"Answer":"You can do a redirect from the subdomains to your page but in this case you will have the 3rd party URL displayed and not your subdomain.\n\nYou can probably use a simple HTML structure with iFrames to include your page. Like connecting your subdomains with a server and hosting there a HTML page which loads your python or WYSIWYG page.\n\nIf site123 is a static landing page without many changes or dynamic elements, I would think about scraping it with a script and transfer it to a server which also supports python (e.g. Amazon AWS). In this case you can get rid of pythonanymwhere and use your subdomains.\nThen you can either use site123 (and scrape it every night for example) or use another WYSIWYG editor to build a page and deploy it to your server.","Q_Score":0,"Tags":"python,django,url,dns,pythonanywhere","A_Id":63648634,"CreationDate":"2020-08-29T15:00:00.000","Title":"How to host number of websites under similer url","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"There is an external function (another module) that uses Twisted, so in order for it to work I need to call reactor.run()\nHowever I want to call that function multiple times. How can I do it? (I get ReactorNotRestartable error)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":63648935,"Users Score":0,"Answer":"You can run the twisted function in a background thread using [crochet][1], then bring the results into the foreground process when the execution finishes. Just don't execute reactor.stop() because that might mess things up. Also, crochet will take care of stopping the reactor.","Q_Score":0,"Tags":"python,twisted,reactor,twisted.internet","A_Id":63673527,"CreationDate":"2020-08-29T15:52:00.000","Title":"run reactor in a loop (python twisted)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is an external function (another module) that uses Twisted, so in order for it to work I need to call reactor.run()\nHowever I want to call that function multiple times. How can I do it? (I get ReactorNotRestartable error)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":63648935,"Users Score":0,"Answer":"If there's an API you want to call and the implementation of that API calls reactor.run then you cannot call it more than once.\nPerhaps there is an alternate API you can call which does everything except for calling reactor.run.  Then you can manage the reactor.run call in your own code (making sure to only call it once) while calling that alternate API as many times as you like.","Q_Score":0,"Tags":"python,twisted,reactor,twisted.internet","A_Id":63673421,"CreationDate":"2020-08-29T15:52:00.000","Title":"run reactor in a loop (python twisted)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"While this may be pretty straightforward, I want to share a solution to an issue I was having since I did not have a problem with this until now.\nEssentially I was having trouble running splinter in my conda virtual environment. I first activated my environment conda activate PythonData. Then I tried to run conda install splinter which failed, then conda install -c metaperl splinter which also failed.\nI then moved onto using pip, so I went to the documentation and ran pip install splinter.\nThe installation said it was successful, but after restarting the kernel I was still receiving the same error.\nSee below the solution :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":351,"Q_Id":63650117,"Users Score":0,"Answer":"I looked through my anaconda bins and did not find the package. Then I realized when I try to install a second time (after ensuring my environment was indeed activated), I saw it was installed in my usr folder - not my anaconda3 folder.\nTherefore, I had to run pip uninstall splinter to remove it, and then did the following:\nconda install pip to first install pip (which I used previously with no errors so this is puzzling, but such is life)\nconda info to find my active environment path\nAfter copying the active environment path similar to the following \/anaconda\/envs\/venv_name, I was able to run the installation like this:\n\/anaconda\/envs\/venv_name\/bin\/pip install splinter\nAnd then viola! It worked.","Q_Score":0,"Tags":"python,conda,splinter","A_Id":63650118,"CreationDate":"2020-08-29T17:53:00.000","Title":"ModuleNotFoundError or ImportError When Installing Python Packages to Conda Env That Require Pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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 am using ODEINT (python) to solve a system (600x600) of 1st order (complex) differential equations. But I have 600 different initial conditions I want to use. Right now, I am simply using a for-loop and calling ODEINT 600 times, but obviously this takes an incredible amount of time. Is there any quick way of solving the same differential equations with a series of different initial conditions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":141,"Q_Id":63653746,"Users Score":0,"Answer":"If you are trying to get the job done faster, you can try using multiprocessing to split the task to different processes. Pool is a good way to leverage muti-core cpu to solve cpu-bound tasks like this.","Q_Score":1,"Tags":"python,scipy,odeint","A_Id":63654199,"CreationDate":"2020-08-30T03:44:00.000","Title":"Solving the same differential equation with many different initial conditions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was looking at the TensorFlow 2.0 Detection Zoo recently and found the SSD MobileNet V2 FPNLite 320x320 pre-trained model and was wondering what the FPN part in \"FPNLite\" means\/stands for.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5266,"Q_Id":63653903,"Users Score":0,"Answer":"A Feature Pyramid Network, or FPN, is a feature extractor that takes a single-scale image of an arbitrary size as input, and outputs proportionally sized feature maps at multiple levels, in a fully convolutional fashion. This process is independent of the backbone convolutional architectures.","Q_Score":5,"Tags":"python,tensorflow,tensorflow2.0,tensorflow-lite,mobilenet","A_Id":69140926,"CreationDate":"2020-08-30T04:16:00.000","Title":"What does FPN in SSD MobileNet V2 FPNLite 320x320 stand for?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am on a macOS system and I am not able to install PyAudio On a Mac even with using the portaudio and homebrew technique . What should I do ? Please Help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":63655597,"Users Score":0,"Answer":"PyAudio is a python package, so you need to install it with pip. Try running pip install pyaudio or pip3 install pyaudio depending on which version of python you are using.","Q_Score":0,"Tags":"python,macos,pyaudio","A_Id":63655709,"CreationDate":"2020-08-30T08:43:00.000","Title":"Unable To Install PyAudio On A Mac Even With HomeBrew Installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want a python function that halts, say at the 150th number and then when I need the 400th number, it doesn't recalculates the first 150th fibonacci numbers, it starts from 150th number till the 400th number.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":63659087,"Users Score":0,"Answer":"I think you could implement an array that stores all the already calculated numbers, either in a variable, an exported array using numpy or in a database and make it use that last number for example.\nThe function would then have to take startnumber and stopnumber arguments.\nI don't know if you could just calculate a specific fibonacci number, as it is a recursive function.","Q_Score":0,"Tags":"python,fibonacci","A_Id":63659139,"CreationDate":"2020-08-30T15:32:00.000","Title":"Using fibonacci: Python function that halts execution and starts from where it halted","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to save data from an ESP32 in a network database. Therefore I need the module MySQLdb in Micropython on the ESP32. How can I install it there?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1336,"Q_Id":63660769,"Users Score":0,"Answer":"If your server has php in it then u can send your data to php and write a code to store that resived data in MySQL database.\nTry it and let me know.","Q_Score":1,"Tags":"mysql-python,esp32,micropython","A_Id":64249047,"CreationDate":"2020-08-30T18:25:00.000","Title":"How to install Micropython MySQLdb on ESP32","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to save data from an ESP32 in a network database. Therefore I need the module MySQLdb in Micropython on the ESP32. How can I install it there?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1336,"Q_Id":63660769,"Users Score":1,"Answer":"running just about any database client from an ESP32 to a hosted database somewhere would be a challenge (in processing power, security and maintaining state)\nI would suggest using the ESP32 to send data to a mqtt broker, and then have something else, (the server running the database, a serverless function , etc etc ) subscribe to that topic , and write any changes to the database.","Q_Score":1,"Tags":"mysql-python,esp32,micropython","A_Id":64306013,"CreationDate":"2020-08-30T18:25:00.000","Title":"How to install Micropython MySQLdb on ESP32","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can upload files to Azure, but sometimes the files I send to Azure are empty or not even present. I use iothub_client (from azure-iothub-device-client).\nFirst I create a series of csv and json files from an SQL database which I temporarily store on my pc. These files are then processed by the upload client and uploaded asynchronously to a storage blob.\nBasically the structure is:\n-- ID\n---- csv file\n---- csv file\n---- json file\nMost of the time this functions without any problems, however sometimes something doesn't work correctly and one csv file is containing only the header row - but never all of them - and\/or the json file is even missing. The order of uploading is:\n\ncsv file one\njson file\ncsv file two\n\nThe files are however always correctly created and stored on my pc. The code does not give any errors, so the iothub_client seems to be happy with what it's getting as input.\nI can't figure out why this goes wrong, as I have not been able to reproduce the error. Retrying to upload the same files results in a correctly executed upload procedure.\nAny clues about what can be the cause would be very much appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":63661288,"Users Score":0,"Answer":"I run into this a lot. My best guess something has a lock on the file. I team into this with a logic app that scanned a SharePoint directory every five minutes. It would grab an Excel file and move it to blob storage. But I kept getting 0k files. I haven't seen this issue since changing the logic app too check every ten minutes. This increases the odds that a user will not be in the file.","Q_Score":0,"Tags":"python,azure","A_Id":63664736,"CreationDate":"2020-08-30T19:21:00.000","Title":"Uploaded files to azure blob storage are empty or not even present","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have months(Jan, Feb, Mar etc) data in my dataset and I am generating dummy variable using pandas library.\npd.get_dummies(df['month'],drop_first=True)\nI want to understand whether I should use drop_first=True or not in this case?\nWhy is it important to use drop_first and for which type of variables?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11653,"Q_Id":63661560,"Users Score":0,"Answer":"What is drop_first=True\ndrop_first=True drops the first column during dummy variable creation. Suppose, you have a column for gender that contains 4 variables- \"Male\", \"Female\", \"Other\", \"Unknown\". So a person is either \"Male\", or \"Female\", or \"Other\". If they are not either of these 3, their gender is \"Unknown\".\nWe do NOT need another column for \"Uknown\".\nIt can be necessary for some situations, while not applicable for others. The goal is to reduce the number of columns by dropping the column that is not necessary. However, it is not always true. For some situations, we need to keep the first column.\nExample\nSuppose, we have 5 unique values in a column called \"Fav_genre\"- \"Rock\", \"Hip hop\", \"Pop\", \"Metal\", \"Country\" This column contains value\nWhile dummy variable creation, we usually generate 5 columns. In this case,  drop_first=True is not applicable. A person may have more than one favorite genres. So dropping any of the columns would not be right. Hence, drop_first=False is the default parameter.","Q_Score":8,"Tags":"python,linear-regression","A_Id":71984203,"CreationDate":"2020-08-30T19:17:00.000","Title":"drop_First=true during dummy variable creation in pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"there I want to ask why I cant use long() function in python3.6.5? its say long is not defined\nand what should the function should I use? please anybody help me","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":63662978,"Users Score":0,"Answer":"there is no long integer in Python 3, you should just be able to use int()?","Q_Score":0,"Tags":"python-3.5,numerical-methods","A_Id":63663019,"CreationDate":"2020-08-30T23:12:00.000","Title":"I cant use long function in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For an exploratory semester project, I am trying to predict the outcome value of a quality control measurement using various measurements made during production. For the project I was testing different algorithms (LinearRegression, RandomForestRegressor, GradientBoostingRegressor, ...). I generally get rather low r2-values (around 0.3), which is probably due to the scattering of the feature values and not my real problem here.\nInitially, I have around 100 features, which I am trying to reduce using RFE with LinearRegression() as estimator. Cross validation indicates, I should reduce my features to only 60 features. However, when I do so, for some models the R2-value increases. How is that possible? I was under the impression that adding variables to the model always increases R2 and thus reducing the number of variables should lead to lower R2 values.\nCan anyone comment on this or provide an explanation?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":63665684,"Users Score":0,"Answer":"It depends on whether you are using the testing or training data to measure R2. This is a measure of how much of the variance of the data your model captures. So, if you increase the number of predictors then you are correct in that you do a better job predicting exactly where the training data lie and thus your R2 should increase (converse is true for decreasing the number of predictors).\nHowever, if you increase number of predictors too much you can overfit to the training data. This means the variance of the model is actually artificially high and thus your predictions on the test set will begin to suffer. Therefore, by reducing the number of predictors you actually might do a better job of predicting the test set data and thus your R2 should increase.","Q_Score":0,"Tags":"python,regression,feature-selection","A_Id":63665753,"CreationDate":"2020-08-31T06:14:00.000","Title":"Why does R2-value increase after feature-reduction with RFE?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently I am learning django and learning migration related stuff.\nI have found that we can migrate specific app using python manage.py migrate app-name but not found how to migrate specific migration file named python manage.py migrate 0024_auto_20200827_0706.py.\nIf I will do python manage.py migrate 0024_auto_20200827_0706.py, it will revert migration from this point or file but not doing migrate for this specific file.\nMy question : is it possible to do migrate for specific file if yes then How is it possible?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":912,"Q_Id":63665981,"Users Score":1,"Answer":"No, it is not possible to directly run a single migration out of sequence.\nIf the migration is a data migration of some sort that could otherwise be run out of sequence (i.e. it doesn't depend on schema changes, or is dangerous to run), I would recommend refactoring it into\n\na \"migration utility\" function in e.g. myapp\/migration_utils\nthe migration itself that just calls the above function\na management command that calls the above function\n\nThen you can call the management command manually should you need to, but the migration would be run in-sequence otherwise.","Q_Score":3,"Tags":"python,django,database,migrate","A_Id":63666408,"CreationDate":"2020-08-31T06:42:00.000","Title":"In Django , Is it possible to migrate any perticular specific file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Why this is working.\nInput print(9, \"ABC\")\nOutput 9 ABC\nAnd This is not working and showing the error.\nInput print(9 + \"ABC\")\noutput\nTypeError: unsupported operand type(s) for +: 'int' and 'str'","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":63667772,"Users Score":0,"Answer":"The \"+\" symbol is used to concatenate two strings together. In your code 9 is and integer and \"ABC\" is a string, in order for the code to work, both items need to be strings, which means that you need to change print(9+\"ABC\") to print(str(9)+\"ABC\")","Q_Score":0,"Tags":"python","A_Id":63667902,"CreationDate":"2020-08-31T08:58:00.000","Title":"why does this program giving me the error when i am using + in print() function and giving me the output when i am using ','","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why this is working.\nInput print(9, \"ABC\")\nOutput 9 ABC\nAnd This is not working and showing the error.\nInput print(9 + \"ABC\")\noutput\nTypeError: unsupported operand type(s) for +: 'int' and 'str'","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":63667772,"Users Score":0,"Answer":"+ operator can be used with same type of objects. In your case you are trying to add an Integer with a strings, which is a type mismatch.\nIn case you want to concatenate it as strings change 9 to String as in following statement:\nprint(str(9)+\"ABC\")\nTo answer why print(9, \"ABC\") is working ?\nThis is working because print() supports VLA (Variable length argument) and its considering 9 as a integer input where as \"ABC\" as a String Input.","Q_Score":0,"Tags":"python","A_Id":63669553,"CreationDate":"2020-08-31T08:58:00.000","Title":"why does this program giving me the error when i am using + in print() function and giving me the output when i am using ','","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I have a problem with a Django project. When I ran in Pycharm the celery I got this error :\nNo module named 'notifications.signals'; 'notifications' is not a package\nAlthought when I type in Python Console this :\nfrom notifications.signals import notify\nCould you help me please ?\nThank you very much","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":322,"Q_Id":63668377,"Users Score":0,"Answer":"If you configure PyCharm to use the same environment that you used when you executed successfully the import statement, then it will all work as expected.","Q_Score":0,"Tags":"python-3.x,django,notifications,celery","A_Id":63669292,"CreationDate":"2020-08-31T09:40:00.000","Title":"No module names 'notifications.signals'; 'notifications' is not a package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to install a package 'backtesting' in my Anaconda prompt by typing 'pip install backtesting' but getting EnvironmentError......\nERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\users\\james\\appdata\\local\\continuum\\anaconda3\\lib\\site-packages\\~il\\_imaging.cp36-win_amd64.pyd'\nConsider using the --user option or check the permissions.\nHow do I 'Consider using the --user option or check the permissions.'? Many thanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":313,"Q_Id":63669050,"Users Score":0,"Answer":"The above answer is the correct '--user' usage.\nI find when I cannot install with conda or pip keywords, I simply add the module to  the environment variables.\nYou can do this by accessing your search field on your taskbar and type 'Environment variable' (minus the single quotes) which will produce a window allowing you the option to edit environment vars.\nOr you can go directly to 'System Properties' and select the 'Advanced' tab. On the bottom right is a button for environment variables. Clicking on environment variables\nyou are taken to a new window.\nSelecting 'New' from the 'System Variables' field, you want to add the full path of your project solution and once saved your program can 'see' the module. The clincher is you must restart your computer after adding the variable, once the computer is back up the edited 'Environment Variable' becomes effective. You will be able to use the import statement like you always do at the start of program without the error.","Q_Score":0,"Tags":"python-3.x,installation,package","A_Id":64549457,"CreationDate":"2020-08-31T10:27:00.000","Title":"Trouble installing a new package using Anaconda Prompt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have several registered tasks in my app and it's working as expected but i moved my async tasks to another path recently and i realized that my old tasks those were registered by old app where calling the old same path and raising errors because the task were not there any more. now i'm looking for a solution to register tasks independently to location or find a way to update the tasks path.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":63669382,"Users Score":0,"Answer":"I finally found a patch. I left the tasks in the old location and made a copy of them in the new location and imported tasks from new location under the old tasks. this way celery creates new tasks from new location also celery can find tasks in their old location and empty its old tasks. old tasks can be removed after all old tasks are done.","Q_Score":1,"Tags":"python,python-3.x,celery","A_Id":63811142,"CreationDate":"2020-08-31T10:49:00.000","Title":"Celery dependency to tasks location","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"To clarify my question, for example in some IDEs such as PyCharm one can put a breakpoint in the code, run the python script and when the code reaches that breakpoint, the program stops while the user can investigate some of the variables until that breakpoint.\nIs such functionality possible through a terminal, that is executing a python code but while having it stopped at a certain line, a python console would be available for debugging.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":36,"Q_Id":63673837,"Users Score":-1,"Answer":"i think that is not possible if u are running it in just the terminal.\nif u want to investigate variables and stuff at a certain point, maybe u can simply just code lens","Q_Score":0,"Tags":"python","A_Id":63674000,"CreationDate":"2020-08-31T15:36:00.000","Title":"can we access a python console in a terminal via an interruption within the python script for debugging","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"im trying to find a way to make my HTTP request in a exact time for my computer example 13:02:00:00.\nAny recomendation?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":63676253,"Users Score":0,"Answer":"in my opinion, it depends on your network speed. Anyway, I think that's impossible as when you make a GET request, your request will pass through many network devices such as a router, switch, and finally reaches a server where IP address of the site will be sent to you. Even request that is sent will travel with the speed of light you can't get it in exact time, as some switches will make ARP requests to get to know destination address.","Q_Score":0,"Tags":"python,python-3.x,python-requests,clock","A_Id":63676551,"CreationDate":"2020-08-31T18:27:00.000","Title":"Python HTTP Request in exact time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When establishing remote webdriver connection via https:\nself.driver = webdriver.Remote(command_executor='https:\/\/' + settings.BROWSERSTACK_USERNAME + ':' + settings.BROWSERSTACK_KEY + '@hub-cloud.browserstack.com\/wd\/hub', desired_capabilities=desired_cap)\nThis error message pops up:\nMaxRetryError: HTTPSConnectionPool(host='hub-cloud.browserstack.com', port=443): Max retries exceeded with url: \/wd\/hub\/session (Caused by SSLError(SSLError(\"bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)\",),))\nFrom Browserstack's FAQ:\nMy firewall\/IDP\/proxy is rejecting SSL\/HTTPS content from BrowserStack.com\nThis could be because of a missing certificate chain due to which your firewall\/IDP\/proxy may not recognize, or block the SSL\/HTTPS content. This usually happens if your firewall\/IDP\/proxy is not updated regularly. In this case please install the ValiCert Legacy Certificate Chain from the GoDaddy repository and try again.\nAm I on the right track? (Following Browserstack's FAQ)\n*OS: Fedora-30\nThank you in advance for any help....","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":754,"Q_Id":63678321,"Users Score":0,"Answer":"You could try changing the Hub URL from HTTPS to HTTP or whitelist *.browserstack.com over ports 80 and 443 over your network.\n\u200b","Q_Score":0,"Tags":"python,ssl,fedora,browserstack","A_Id":63678616,"CreationDate":"2020-08-31T21:19:00.000","Title":"How to resolve Browserstack Local Testing SSLError(\"bad handshake\")","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to read this article online and something popped and I thought that I want to read it offline after I have successfully extracted it... so here I am after 4 weeks of trials and all the problem is down to is I the crawler can't seem to read the content of the webpages even after all of the ruckus...\nthe initial problem was that all of the info was not present on one page so is used the button to navigate the content of the website itself...\nI've tried BeautifulSoup but it can't seem to parse the page very well. I'm using selenium and chromedriver at the moment.\nThe reason for crawler not being able to read the page seems to be the robot.txt file (the waiting time for crawlers for a single page is 3600 and the article has about 10 pages, which is bearable but what would happen if it were to say 100+)and I don't know how to bypass it or go around it.\nAny help??","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":63678927,"Users Score":1,"Answer":"If robots.txt puts limitations then that's the end of it. You should be web-scraping ethically and this means if the owner of the site wants you to wait 3600 seconds between requests then so be it.\nEven if robots.txt doesn't stipulate wait times you should still be mindful. Small business \/ website owners might not know of this and by you hammering a website constantly it could be costly to them.","Q_Score":0,"Tags":"python,selenium,web-crawler,dynamic-pages","A_Id":63679106,"CreationDate":"2020-08-31T22:22:00.000","Title":"dynamic web page crawler using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"A friend of mine asked me to write him a program, and I used pynput to handle some of the inputs and other features. When I convert the program an executable with pyinstaller, launcing the executable gives me this error:  File \"site-packages\\pynput\\keyboard\\__init__.py\", line 31, in <module> File \"site-packages\\pynput\\_util\\__init__.py\", line 82, in backend ImportError [11492] Failed to execute script friend_project\nI have tried using the pyinstaller command pyinstaller --onefile friend_project.py, and also using auto-py-to-exe to run it.\nUsing pyinstaller with other modules like pygame or pyopengl gives me no error, but this one module does.\nRunning the script by it self with the python inturpeter works fine, but I would perfer to have it be an exe so I can give it to him with out him needing python to run it.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8245,"Q_Id":63681770,"Users Score":24,"Answer":"Please fall back to 1.6.8 version of pynput.\npip install pynput==1.6.8","Q_Score":9,"Tags":"python-3.x,pyinstaller,pynput","A_Id":63721929,"CreationDate":"2020-09-01T05:18:00.000","Title":"Getting error when using pynput with pyinstaller","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using skmultilearn library to solve a multi-label machine learning problem. There are 5 labels with binary data (0 or 1). Sklearn logistic regression is being used as base classifier. But I need to set label specific features for each classifier. The label data of one classifier to be used as feature of another classifier.\nI am not able to figure out on how to do that.\nAny help appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":63683533,"Users Score":0,"Answer":"One-vs-Rest is the method of solving the multi-label problem you are trying to address, it is the transformation type. You just need to generate a different training set for each simple classifier so that you have all the combinations between the original attributes and each of the labels. Pandas can be useful for the manipulation of the data and the generation of the different datasets for each simple classifier. Note that using this strategy in its original form ignores the relationships between the tags.","Q_Score":0,"Tags":"python,multilabel-classification,skmultilearn","A_Id":63690540,"CreationDate":"2020-09-01T07:54:00.000","Title":"How to use skmultilearn to train models on label specific data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"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 have refactored my app and project names, but after that Django doesn't create migrations folder in my app and doesn't actually apply my models migrations.\nEven after migrations (with no warning nor error) I have no tables with my objects.\nDoes anybody know how to force django to do those migrations?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":63683898,"Users Score":0,"Answer":"There can multiple reasons behind it. Please check following if you are missing something.\n\nThe app must have migrations\/__init__.py folder. It automatically creates but if you did code refactoring. You can miss this.\n\nCheck INSTALLED_APPS in settings.py it should have the same app name as in admin.py.","Q_Score":0,"Tags":"python,django","A_Id":63685472,"CreationDate":"2020-09-01T08:20:00.000","Title":"Django - no migrations folder after refactoring projects and apps names","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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, I should port to PY3, but let's say I am unable to.\nHow much longer, apps written in PY2.7 will remain working on GAE, before support is completely removed and existing 2.7 apps won't work any more?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":41,"Q_Id":63686358,"Users Score":1,"Answer":"There is no official statement from Google as of now as to when Python 2 will be deprecated, however, official support for Python 2 has been stopped since January of this year, so it is advised to work with Python 3 as soon as possible, although Google always does give notice in great advance beforehand. So I would advise to start migrating when you can and wait for a communication from Google to have an exact date.","Q_Score":0,"Tags":"python-2.7,google-app-engine","A_Id":63690198,"CreationDate":"2020-09-01T11:00:00.000","Title":"When is GAE standard python 2.7 runtime going away?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I know, I should port to PY3, but let's say I am unable to.\nHow much longer, apps written in PY2.7 will remain working on GAE, before support is completely removed and existing 2.7 apps won't work any more?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":41,"Q_Id":63686358,"Users Score":1,"Answer":"I don't work for Google and only they can say, but from what I've seen, I expect that we have at least a few years.\nMany people are in your position, and Google likely doesn't want to screw us over, so to speak.","Q_Score":0,"Tags":"python-2.7,google-app-engine","A_Id":63686711,"CreationDate":"2020-09-01T11:00:00.000","Title":"When is GAE standard python 2.7 runtime going away?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am relatively new to Machine Learning and Tensorflow, and I want to try and implement mini-batch gradient descent on the MNIST dataset. However, I am not sure how I should implement it.\n(Side note: the training images (28px by 28px) and labels are stored in Numpy arrays)\nAt the moment, I can see 2 different ways to implement it:\n\nMy training images are in a Numpy array of [60000,28,28]. Reshape this into a [25 (num batches), 2400 (num images in batch), 28,28] and then use a for loop to call each batch and pass it the model.compile() method. The only thing that I am worried about with this method is that for loops are inherently slow, and a vectorised implementation would be much quicker.\n\nCombine the images and labels into a tensorflow dataset object, and then call the Dataset.batch() method and Dataset.prefetch() method, and then pass the data to the model.compile() method. The only problem with this is that my data doesn't remain as a Numpy array, which I feel have more flexibility than tensorflow dataset objects.\n\n\nWhich of these 2 methods would be best to implement, or is there a third way that is best that I am not aware of?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1681,"Q_Id":63687295,"Users Score":2,"Answer":"Keras has an inbuilt batch_size argument to its model.fit method (since you tagged this question with keras I assume that you're using it). I believe that this will probably be the best optimised method to achieve what you're looking for.","Q_Score":1,"Tags":"python,numpy,tensorflow,keras,tensorflow-datasets","A_Id":63687640,"CreationDate":"2020-09-01T12:04:00.000","Title":"How to implement mini-batch gradient descent in Tensorflow 2?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm reading spark the definitive guide in which it is said :\n\nPython\/R DataFrames exist on one machine rather than multiple machines... this limits what you can do with a given DataFrame to resources that exist on that specific machine..\n\ntherefore, I wonder why Python's dataFrame can't spand to multiple machines ? and if that means that python's are not distributed ?\nUpdate\ndoes Python\/R have an equivalent distributed DataFrame like Spark scala\/java??DataFrame","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":63690443,"Users Score":0,"Answer":"For example, pandas DataFrame is not distributed.\nThe statements say that the DataFrame is not unique, there were several DataFrame concepts. Even though there are many concepts, the spark DataFrame is the distributed one, but the others, i.e. python and R are not.\nIt does not mean for the pyspark DataFrame.","Q_Score":1,"Tags":"python,dataframe,apache-spark,pyspark,apache-spark-dataset","A_Id":63699596,"CreationDate":"2020-09-01T15:09:00.000","Title":"why does python dataFrames' are localted only in the same machine?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm reading spark the definitive guide in which it is said :\n\nPython\/R DataFrames exist on one machine rather than multiple machines... this limits what you can do with a given DataFrame to resources that exist on that specific machine..\n\ntherefore, I wonder why Python's dataFrame can't spand to multiple machines ? and if that means that python's are not distributed ?\nUpdate\ndoes Python\/R have an equivalent distributed DataFrame like Spark scala\/java??DataFrame","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":71,"Q_Id":63690443,"Users Score":2,"Answer":"Pandas doesnt allow you to distribute the datframe to mulitple machine at it own. It is good to us when you have data that\n\nFit in Memory (RAM)\nFits in Disk\n\nSo, it works well when you can have data that can be handled with single machine. But when the data and processing needs grows, you want to move to libraries that store and handle distributed\/parallel processing of dataframes. The concept of dataframe is common in these libraries, but implementation differs to provide distributed processing power. Two good examples are\n\nDask, it is typically used on a single machine utilising multiple cores\/thread by multiprocessing\/multitasking, but can also runs well on a distributed cluster.\nApache spark is mainly used in cluster mode on multiple node, hence distributed data processing framework. (but it can be used on single standlone machine as well)\n\nUpdate:\nYou asked that\n\nDataFrame CONCEPT is the one that is not distributed, however R and\nPython have other concept to do distributed computation\n\nDataframe don't needs to be non-distributed or distributed, it is a concept , DataFrame is a 2-dimensional data structure with columns that can have different types and it is so easy and efficient to query,summarise and manipulate that it was adopted in many Data-oriented Programming Paradigms and libraries. So, utilising and manipulating these dataframes can be done in distributed manner as well to handle Big data. Spark is just an example of Distributed data processing framework, which can be used with many languages including R and Python","Q_Score":1,"Tags":"python,dataframe,apache-spark,pyspark,apache-spark-dataset","A_Id":63699990,"CreationDate":"2020-09-01T15:09:00.000","Title":"why does python dataFrames' are localted only in the same machine?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Getting CharConversionException in python Jaydebeapi when trying to pull data ? Not sure where how to set db2.jcc.charsetDecoderEncoder property in python to resolve this.\nExact error - com.ibm.db2.jcc.am.SqlException: com.ibm.db2.jcc.am.SqlException: [jcc][t4][1065][12306][4.25.13] Caught java.io.CharConversionException.  See attached Throwable for details. ERRORCODE=-4220, SQLSTATE=null\nPlease help in setting charsetDecoderEncoder property in python. Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":63693218,"Users Score":0,"Answer":"Since you've tagged this with WebSphere, I assume you're trying to use wsadmin to invoke a jython script, if so do something like wsadmin -D<propName>=<propValue> -f myJythonScript.py.","Q_Score":0,"Tags":"python,db2,jpype,jaydebeapi","A_Id":63696179,"CreationDate":"2020-09-01T18:10:00.000","Title":"Jaydebeapi giving error in python for CharConversionException","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"New to running Python in virtual environments, messing with Django, and can't activate a virtual environment.\nSpent the last 4 hrs trying to activate a virtual env (venv) on local terminal\/VS Code with no luck.\nAvoided \"sudo pip install virtualenv\" as I was trying to avoid installing as root and having different directory path, etc.\n\"pip install virtualenv\" output:\nCollecting virtualenv\nUsing cached virtualenv-20.0.31-py2.py3-none-any.whl (4.9 MB)\n\nRequirement already satisfied: six<2,>=1.9.0 in \/Users\/garrettpinto\/Library\/Python\/3.8\/lib\/python\/site-packages (from virtualenv) (1.15.0)\n\nRequirement already satisfied: appdirs<2,>=1.4.3 in \/Users\/garrettpinto\/Library\/Python\/3.8\/lib\/python\/site-packages (from virtualenv) (1.4.4)\n\nRequirement already satisfied: filelock<4,>=3.0.0 in \/Users\/garrettpinto\/Library\/Python\/3.8\/lib\/python\/site-packages (from virtualenv) (3.0.12)\n\nRequirement already satisfied: distlib<1,>=0.3.1 in \/Users\/garrettpinto\/Library\/Python\/3.8\/lib\/python\/site-packages (from virtualenv) (0.3.1)\n\nInstalling collected packages: virtualenv\n\nSuccessfully installed virtualenv-20.0.31\n\"virtualenv venv\" output:\ncreated virtual environment CPython3.8.5.final.0-64 in 416ms\n\ncreator CPython3Posix(dest=\/Users\/garrettpinto\/Desktop\/rp-portfolio\/distribution\/venv, clear=False, global=False)\n\nseeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=\/Users\/garrettpinto\/Library\/Application Support\/virtualenv)\n\nadded seed packages: pip==20.2.2, setuptools==49.6.0, wheel==0.35.1\n\nactivators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator\n\"source venv\/bin\/activate\" returns nothing\n\".\/venv\/bin\/activate\" output:\nzsh: permission denied: .\/venv\/bin\/activate\n\"sudo .\/venv\/bin\/activate\" output:\nsudo: .\/venv\/bin\/activate: command not found\nThoughts?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":13991,"Q_Id":63694874,"Users Score":1,"Answer":"Solution of the problem of virtual environment created but not activated.\n\nto make activate just add a space between .(dot) and your venv path. i,e \n$ . yourvirtualenv\/bin\/activate\nHope this will work. But not use like:\n$ yourvirtualenv\/bin\/activate\nor\n$ \/yourvirtualenv\/bin\/activate\n\nHere is my command and the output:\n\nadmin@osboxes:~\/pysrc$ . my_env\/bin\/activate\n(my_env) admin@osboxes:~\/pysrc$ \n\nOutput of the wrong command:\n\nadmin@osboxes:~\/pysrc$ my_env\/bin\/activate\nbash: my_env\/bin\/activate: Permission denied\nadmin@osboxes:~\/pysrc$ sudo my_env\/bin\/activate\n[sudo] password for admin: \nsudo: my_env\/bin\/activate: command not found\nadmin@osboxes:~\/pysrc$ my_env\/bin\/activate\nbash: my_env\/bin\/activate: Permission denied\nadmin@osboxes:~\/pysrc$","Q_Score":1,"Tags":"python,django,pip,virtualenv,python-venv","A_Id":67117505,"CreationDate":"2020-09-01T20:17:00.000","Title":"Can't \"activate\" virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"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":"Tldr: Is it feasible to create a web tool\/app that relies on server side Selenium automation.\nCreated a local script that automates form filling for car insurance quote websites and returns the cost to insure. Ie fill one form and it auto fills every other providers quote form and returns quotes.\nBut now I want to extend that functionality to others via some sort of webapp [flask\/Django?] that handles a clients requests server side by fetching that information and returning it to the client based on their inputs.\nWhat I\u2019m struggling with is Selenium is limited to 5 web drivers (locally) I believe, and is resource intensive, so to me that means at most you can handle 5 website requests at once?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":63702116,"Users Score":0,"Answer":"The short answer is YES.\nThe idea to solve the problem is as follows:\n\nCreate a web app which can fetch user's inputs and return something back to user. Just like the most common website.\nCreate a service in the web app. The service can handle what you wanted using Selenium, such as, filling form of car insurance and getting the cost to insure.\nCreate a webpage or API in the web app. The webpage\/API calls the service mentioned above. When user use the webpage\/API, Selenium will automate to do something.\n\nSo, it's done.","Q_Score":0,"Tags":"python,selenium,server,client","A_Id":63718920,"CreationDate":"2020-09-02T08:58:00.000","Title":"Feasible? Form automation webapp with selenium - [server side]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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 have a column which has entry like :\n'TURBINE, STEAM ; MAKE: ABB ; MODEL: CF-4GSS ; RATING: OUT PUT 1175 BHP ; SPEED: 2975 MIN -1'\nThere is some modifications I need to do after reading this into python. String MUST be of the form :\nITEM : TURBINE ; COMBUSTION : STEAM ; MAKE : XYZ ; MODEL : XYZ  and so on.\nHow can I format it so that the column is of the specified format ?\n(Also since im reading this with pandas i think this column will be a series object)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":55,"Q_Id":63704203,"Users Score":0,"Answer":"You could use the .split method on your original string:\nnew_string = original_string.split()\nWhich would give you a list of separate objects for each category in your string like this,  ['TURBINE,', 'STEAM', ';', 'MAKE:', 'ABB', ';', 'MODEL:', 'CF-4GSS', ';', 'RATING:', 'OUT', 'PUT', '1175', 'BHP', ';', 'SPEED:', '2975', 'MIN', '-1']\nThen start a new string for your item final_string = \"ITEM :\"\nThen concatenate individual items from your list using indexing, final_string += new_string[0]\nThis would give you final_string == \"ITEM : TURBINE\". For a different item to add to your string you simply use a different index position from 0. Remember that python indexes from 0 onwards, and each individual item in the list is considered an object so the semi colons would be considered an individual object and you'd need to count them in your indexing. You will also want to add punctuation while you're concatenating.\nYou could remove all the semi colons from the string by using those to split the original string by inserting it into the .split method original_string.split(';'), but that would split the items only when it reaches semi colons, which would give you this, ['TURBINE, STEAM ', ' MAKE: ABB ', ' MODEL: CF-4GSS ', ' RATING: OUT PUT 1175 BHP ', ' SPEED: 2975 MIN -1']","Q_Score":0,"Tags":"python,python-3.x,pandas","A_Id":63704786,"CreationDate":"2020-09-02T11:07:00.000","Title":"Python : String Manipulation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to delete older messages from kafka it didnt works as expected. I have configure kafka\nrentension.ms, log.cleanup propery also. But it didnt delete older messages after 5 mins. Here is the configuration and within 5 mins new messages also published eventhough older records present in kafka topic. can you please help me out what im missing in this configuration?. Because it increase storage cost.\n-config retention.bytes=-1 --config cleanup.policy=delete --config retention.ms=300000","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":268,"Q_Id":63704272,"Users Score":0,"Answer":"First, it is important to understand that the LogCleaner will only delete data on old segments of the topic, as described in the configuration description of cleanup.policy:\n\n\"A string that is either \"delete\" or \"compact\" or both. This string designates the retention policy to use on old log segments.\"\n\nIt is likely that all your data is still in one segment, so you need to reduce the segment.bytes configuration for your topic such that you actually get \"old\" segments. This configuration default to 1GB and is described as:\n\n\"This configuration controls the segment file size for the log. Retention and cleaning is always done a file at a time so a larger segment size means fewer files but less granular control over retention.\"\n\nIf you don't want to wait until a segment is being filled up, feel free to also reduce the configuration segment.ms from the default value of 7 days to something more fitting to your case. This config is described as:\n\n\"This configuration controls the period of time after which Kafka will force the log to roll even if the segment file isn't full to ensure that retention can delete or compact old data.\"\n\nIf you have short retention times like 5 minutes you may also want to reduce the broker-wide configuration log.cleaner.delete.retention.ms from its default of 1 day to a lower value. This configuration is described as:\n\n\"How long are delete records retained?\"","Q_Score":1,"Tags":"python,amazon-web-services,apache-kafka","A_Id":63704566,"CreationDate":"2020-09-02T11:11:00.000","Title":"How to delete older message not recent messages from kafka","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was wondering if there was any way I could change the theme of an existing PowerPoint using Python-pptx.\nI realise that the easiest way of inserting a specific theme of a powerpoint, you just open a \"template powerpoint\" with the theme in it. However, I want to automize converting themes of existing PowerPoints, I'm not creating new PowerPoints from scratch.\nYou might say: just copy and paste slides into the PowerPoint with a specific theme. However, copy and pasting slides is extremely error-prone as well, seeing they work with slide indices which seem quite tricky. And I'm not even sure whether the pasted slides automatically assume the theme of the new document.\nTherefore I was wondering if anyone knew of some kind of theme object I could call and change using Python-pptx?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":63708895,"Users Score":0,"Answer":"The short answer is no. Implementing that would be a fairly big deal and there are no current plans to add it.\nIf you wanted to do that to several decks, you might explore using Visual Basic for Applications to do it in a Microsoft Windows environment. You might also explore using the win32com interface to control the PowerPoint application from Python, I think that also requires a Windows environment.","Q_Score":0,"Tags":"themes,powerpoint,python-pptx","A_Id":63712533,"CreationDate":"2020-09-02T15:38:00.000","Title":"Can you change the theme of an existing powerpoint with Python-pptx?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My company recently migrated a large project from TFS to GIT and while the migration is over we have about 40 repos that need the yaml file updated, we broke up the project into a bunch of repos. During the initial migration we had a boilerplate yaml we added in manually but it was very bare bones.\nThrough trial and error we came up with a pipeline that would work for each repo but I was wondering if there was a way to mass update the yaml files in these repos to save time, I'm also pretty sure there will be tweaks made to the pipelines and I don't really want to update each yaml manually every time.\nI looked into the Azure CLI but don't believe that has what I'm looking for. I'm relatively new to Azure DevOps and wanted to know if there was a tool or plugin that already does this and if not has anyone come across an example of a script that did something similar?\nThanks for any help you can give.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":202,"Q_Id":63711873,"Users Score":0,"Answer":"After doing a lot of googling and talking with an SRE from another team I'm going to solve this via templates.\nI'm going to create a central repository for scripts, yaml templates, etc. and then put a very basic pipeline in each repository that basically passes in parameters and that's it. That way any global changes I make I can just make the change to the template.\nNot 100% the way I wanted to solve it but it will fix most of my issues.","Q_Score":0,"Tags":"python,git,azure,azure-devops,yaml","A_Id":63728660,"CreationDate":"2020-09-02T18:49:00.000","Title":"Is there a way to script a mass update of yaml files in Azure Repos","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was just looking into Tensorflow for Python, and they say they support python version 3.5-3.8. What I can't understand is, does \"3.8\" mean strictly 3.8.0 OR 3.8.x(so 3.8.5 works)?\nI know it can vary for different software.\nI just want to make sure that IF 3.8.5 is supported, that I use that since it's a newer version.\nThanks in advance!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":422,"Q_Id":63712637,"Users Score":1,"Answer":"Yes, it does. I'm on Python 3.8.5 and using tensorflow==2.3.0.\nUsually when a version is given as \"3.5-3.8\", it includes the patch versions as well. (Sometimes there could be issues that pop up but it's intended to include all patch version of the 'from' & 'to', inclusive.)","Q_Score":1,"Tags":"python,python-3.x,tensorflow,version,tensorflow2.0","A_Id":63712790,"CreationDate":"2020-09-02T19:48:00.000","Title":"Does Tensorflow support Python 3.8.5?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was just looking into Tensorflow for Python, and they say they support python version 3.5-3.8. What I can't understand is, does \"3.8\" mean strictly 3.8.0 OR 3.8.x(so 3.8.5 works)?\nI know it can vary for different software.\nI just want to make sure that IF 3.8.5 is supported, that I use that since it's a newer version.\nThanks in advance!","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":422,"Q_Id":63712637,"Users Score":-1,"Answer":"I would think it works in 3.8.5, but it would be safer to use 3.8.0.","Q_Score":1,"Tags":"python,python-3.x,tensorflow,version,tensorflow2.0","A_Id":63712671,"CreationDate":"2020-09-02T19:48:00.000","Title":"Does Tensorflow support Python 3.8.5?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"I have written a python program to download YouTube videos. I want to add it as an extension to browser, but I have read that browser doesn't run python scripts. So how can I deploy it? Can I convert it into a software which when installed can be added as a plug-in to the browser? Or is there any other way of doing it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":63716152,"Users Score":0,"Answer":"I assume you are aware of the chrome extension\/plugin development, If not, please go through online tutorials,  Fast forward...\nAdding Python to the Chrome extension\nWe have two options to add Python into a chrome extension:\nMethod 1: Include\n\nBrython\n\nin an iframe (requires server)\nTo run Python in the browser you have several options including Brython and emcascripten.\nMethod 2: Compile Python to Javascript using\n\nRapydscript\n\n(best, serverless, pure extension.)\nThere are several tools to compile Python to Javascript. Rapydscript works fine, Pyjs does not work well with chrome.\nFurther, you can do your research.","Q_Score":0,"Tags":"python-3.x,youtube-api,browser-extension,browser-plugin","A_Id":63720439,"CreationDate":"2020-09-03T03:00:00.000","Title":"How to create a software that can be used as a browser extension in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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":"Let's say I have build an application in tkinter on my personal laptop and I have distributed the .exe of it to my friends in different parts of the world. Now, I want to add some features in that application for which I wrote some extra lines of code on that same .py file whose .exe I sent earlier. How can I push the updates to all my friends who are using that app without having to send them .exe file everytime I update the code?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":183,"Q_Id":63717822,"Users Score":1,"Answer":"Any answers to this questions won't specifically relate to python or tkinter since you are distributing an exe.\nHere is how this might work in high level terms.\n\nYou upload a new version of your exe to a web server\nWhen your friends open their version of the program, it or another smaller program, will\ncheck the website to see if there is a newer version of the program available\nIf there it it will prompt them to update the software if they want\nIf they click yes, your program will close and the updater program will fetch the latest exe from your website and copy it over the top of the existing program\n\nSo for this application, you need a webserver where you can store the exe files of the different versions and will respond to requests to tell the program what the latest version available is\nYou also need another program which will handle the download and copying of the files to the correct locations\nAs you're no doubt aware, there are plenty of examples of this occurring on \"App Stores\"","Q_Score":0,"Tags":"python,tkinter","A_Id":63720993,"CreationDate":"2020-09-03T06:11:00.000","Title":"How to push updates in a tkinter application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing a computerCheck program, it's Python based (for now).\nThe programs basically checks some Windows OS status, e.g. if the correct AV is running, if bitlocker is activated and so on....\nThe result of the check OK or NOT OK is reported into the database. However, since it's about 10 checks...I would like to report in a smart way back to the database. I don't want to have an entry for every check in the record, because this would be a problem when the number of checks change.\nSo I would like to send a \"smart\" kind of checksum...\nThe checksum should give which of the checks are NOT OK (e.g. check nr.1 is false, check nr.4 is false) and preferable a reason...like nr 1. status 2 (2 represents e.g. service not running..)\nNow, the big question is, is it possible to do it that way, so e.g. always sending a x character long code to the database and when reading the code back, you can \"unpack\" it to something human readible again....\nI hope it's clear what I'm looking for...\nThanks in advance!\n\/Jasper","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":21,"Q_Id":63721560,"Users Score":1,"Answer":"You could create a string where every index represents one check. You will have more than enough chars to use as states. For example:\n\"0120\" -> check0 ok, check1 error state 1, check2 error state 2...\nNew checks can simply be appended to the string, removed checks need to be marked as no more existent:\n\"0X200\" -> check1 doesn't exist anymore and one new check appended at the end.","Q_Score":2,"Tags":"python,python-3.x,checksum","A_Id":63721863,"CreationDate":"2020-09-03T10:17:00.000","Title":"Smart way of error reporting into database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a bidirectional seq2seq endcoder-decoder network, which aims at formating different datetypes to a german datetime format as: day_written_out, day.month.year\nSo as an example I have the string 12-27-1992 and I expect the model to predict Sunday, 27.12.1992.\nAfter training, the model reaches a valid_accuracy of 98%. Further investigation showed, that the model nearly always predicted the date itself correct, but the model is not able to extract the correct day. So instead of predicting Sunday, 27.12.1992 it predicts Wednesday, 27.12.1992.\nOnly 5% of the days are predicted correctly.\nI think, that the issues lies in the LSTM I use, even though its bidirectional, but since the day is the first element that is predicted, the model does not have alot of information for predicting the correct day, since at timestep 0 the model hasnt seen any date values yet. Is this correct?\nSo my question is, why is this model not capable of predicting the correct day? And would a tranformer architecture, which is capable of reading the whole sequence at a time, be able to solve this issue?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":63722187,"Users Score":0,"Answer":"I think, that the issues lies in the LSTM I use, even though its bidirectional, but since the day is the first element that is predicted, the model does not have alot of information for predicting the correct day, since at timestep 0 the model hasnt seen any date values yet.\n\nTry generate 27.12.1992 - Wednesday instead to see if that does anything.\nHonestly i don't think any model can predict correctly with that data","Q_Score":0,"Tags":"python,tensorflow,lstm,autoencoder,transformer","A_Id":63723410,"CreationDate":"2020-09-03T10:56:00.000","Title":"Tensorflow: Getting LSTM to 100% in converting date time formats","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a set of python exe that is created using pyinstaller. I want to package these exe in .rpm . How do I do this ? The reason I need to do this is to enable me to install the rpm on a red hat linux server\nPS :  I don't have an option to switch from RPMs","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":63725536,"Users Score":0,"Answer":"I found the answer fortunately after hours of trying , you can wrap all the exe in a tar in %install stage of rpm spec and pass the name of the tar file in %file . If you have a single exe , you do not need to create a tar","Q_Score":0,"Tags":"python,redhat,rpm,packaging","A_Id":63757731,"CreationDate":"2020-09-03T14:17:00.000","Title":"How to create an rpm from a python exe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How do you run your Python code on Kaggle without organizing it into a single notebook or script?\nHere's what I'm trying to achieve: I have several Python scripts containing class definitions as well as the application logic, and I would like to run them as-is on Kaggle and take advantage of their freely-available GPUs and TPUs.\nI'd rather not turn everything into a single .ipynb or .py file as it would get pretty messy due to the several import statements in each script (which would need to be fixed), although it seems to be the only way to do that. Are there any alternatives to run my code on Kaggle while taking advantage of GPUs\/TPUs? If not, are there any other platforms that offer \"free\" GPUs?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":63726634,"Users Score":0,"Answer":"You can import the files into each other. That way, you can run it all on one separate file that imports all the files. If you can only run one file, I'd advise you run them all on one file, or perhaps look into threading to run them all at once through one file.","Q_Score":0,"Tags":"python,kaggle","A_Id":63727209,"CreationDate":"2020-09-03T15:15:00.000","Title":"Taking advantage of Kaggle's free GPUs and TPUs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I just started using tweepy and I want to know, is there a way to get the likes of the tweet that was retweeted? Currently, I am storing the tweets inside of a dataframe, but when tweepy gets a retweet the favorite_count method returns 0 because you are not able to like a retweet. What I am wondering is if there is a way to track the original tweets likes, retweets, etc.?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":63726639,"Users Score":0,"Answer":"TLDR; tweet.retweeted_status.favorite_count\nThe reason you cannot obtain the likes of the tweet that was retweeted is because of the way that the Tweepy API is set up. Consider this from the Tweepy Documentation.\n\nWhen using extended mode with a Retweet, the full_text attribute of the Status object may be truncated with an ellipsis character instead of containing the full text of the Retweet. However, since the retweeted_status attribute (of a Status object that is a Retweet) is itself a Status object, the full_text attribute of the Retweeted Status object can be used instead.","Q_Score":0,"Tags":"python,twitter,tweepy","A_Id":65331960,"CreationDate":"2020-09-03T15:15:00.000","Title":"Get the Likes of a retweet with tweepy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently looking for optimal way how to obtain a random data sample from the table (for instance in HIVE). I know that PRESTO provides either RANDOM() function or TABLESAMPLE BERNOULLI\/SYSTEM. Problem is when querying table with significant number of records, it takes a lot of time, which is not suitable with cooperation with JayDeBeApi which might close the connection waiting too long for the response.\nI would prefer to use TABLESAMPLE BERNOULLI\/SYSTEM which takes as an argument percentage of the records to be fetched. To compare with ORACLE, SAP or MSSQL databases which enable to pass the precise percentage, i.e. 0.003123412%, the PRESTO does not allows you, despite that the function are quite similar, and everything is converted in the range 1-100%.\nDoes anyone know some workaround how to solve this? I would prefer to avoid the limit clause in cooperation with TABLESAMPLE BERNOULLI\/SYSTEM which might not work as expected.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3569,"Q_Id":63726874,"Users Score":0,"Answer":"This can be obtained by passing numbers in scientific notation.","Q_Score":2,"Tags":"python,database,presto","A_Id":63727058,"CreationDate":"2020-09-03T15:27:00.000","Title":"SELECT random sample of data via PRESTO connector","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just started using vscode for Python (ML) development. One thing I am unable to figure out is how to set vscode's intellisense refresh if the conda environment is updates.\ne.g. Created a new workspace with a python interpreter from a conda environment. The environment.yml as conda and pip packages. In the middle of my work, if I update the yml file and update the conda environment with conda env update -f environment.yml I want vscode to update it's intellisense and the workspace as well so that I don't get symbol\/import not found errors from the newly installed package. I know that with PyCharm you could set it such that the symbols would be reloaded.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":480,"Q_Id":63727012,"Users Score":2,"Answer":"I'm not sure if this is the most efficient way, but there is a command to reload the window, which has the effect of reloading the Python extension and rescanning the libraries. Open the command palette with CTRL+SHIFT+P, then start typing \"reload\". The option you want is called \"Developer: Reload Window\"","Q_Score":1,"Tags":"python,visual-studio-code,conda,vscode-settings","A_Id":63728536,"CreationDate":"2020-09-03T15:34:00.000","Title":"Rescan intellisense when conda environment is updated in vscode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In odoo 12,\nHow to keep a wizard open (in background) when I call up on an action button which opens an ir.actions.act_window ? The main wizard keeps getting closed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":63727044,"Users Score":0,"Answer":"This is Odoo default behavior, if you are opening new ir.actions.act_window with 'target' as 'new', what you can do is on the button action return the previous ir.actions.act_window.","Q_Score":0,"Tags":"python,xml,odoo,odoo-12","A_Id":63731330,"CreationDate":"2020-09-03T15:36:00.000","Title":"How to keep wizard open in background when I call up on an action button in odoo 12","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've started learning Python recently and I don't understand why Python behaves like this:\n\n>>> \"OK\"\n'OK'\n>>> \"\"\"OK\"\"\"\n'OK'\n>>> \"not Ok'\n  File \"<stdin>\", line 1\n    \"not Ok'\n           ^\nSyntaxError: EOL while scanning string literal\n>>> \"not OK\"\"\"\n'not OK'\n\nWhy doesn't it give an error for the last statement as the number of quotes does not match?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":5717,"Q_Id":63727290,"Users Score":31,"Answer":"\"not OK\"\"\"\nPython interprets this as \"not OK\"+\"\"\nIf you give \"not Ok\"\"ay\", you will get the output as 'not Okay'","Q_Score":68,"Tags":"python,python-3.x,string,quotes","A_Id":63727372,"CreationDate":"2020-09-03T15:50:00.000","Title":"Why doesn't Python give any error when quotes around a string do not match?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've started learning Python recently and I don't understand why Python behaves like this:\n\n>>> \"OK\"\n'OK'\n>>> \"\"\"OK\"\"\"\n'OK'\n>>> \"not Ok'\n  File \"<stdin>\", line 1\n    \"not Ok'\n           ^\nSyntaxError: EOL while scanning string literal\n>>> \"not OK\"\"\"\n'not OK'\n\nWhy doesn't it give an error for the last statement as the number of quotes does not match?","AnswerCount":4,"Available Count":3,"Score":-0.1488850336,"is_accepted":false,"ViewCount":5717,"Q_Id":63727290,"Users Score":-3,"Answer":"Python uses like a stack implementation to detect quotes opening and closing.\nIf you know whats a stack is, its a datastructure, in which Last element will be removed first.\nAssume your string is A = \"''\"\nWhat it does is, for every single quote or double quote encountered first time, it will add it the stack, and for every second, it will remove from the stack, unless its ofcourse, \"\"\" which will be parsed as single one\nIn our example, A = \"''\", iterating over it, for the first 2 elements, they will be added to stack and for the next 2, they will be removed.\nSo the quotes will be matched, if and only if, the number of elements in the stack in the end must be zero","Q_Score":68,"Tags":"python,python-3.x,string,quotes","A_Id":63822261,"CreationDate":"2020-09-03T15:50:00.000","Title":"Why doesn't Python give any error when quotes around a string do not match?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've started learning Python recently and I don't understand why Python behaves like this:\n\n>>> \"OK\"\n'OK'\n>>> \"\"\"OK\"\"\"\n'OK'\n>>> \"not Ok'\n  File \"<stdin>\", line 1\n    \"not Ok'\n           ^\nSyntaxError: EOL while scanning string literal\n>>> \"not OK\"\"\"\n'not OK'\n\nWhy doesn't it give an error for the last statement as the number of quotes does not match?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":5717,"Q_Id":63727290,"Users Score":9,"Answer":"You would think that there is no difference between \" or ', but in reality, Python uses a greedy method to accept input.\nOnce Python sees a matching quotation, then that ends the statement.\nIt's why you can write something like \"'s\" \"\". Inside the string there is a ' but because you're in a string, python doesn't raise an error. Then after that, there is a \" followed by \" but that's a different (empty) string.\nIf you do something like \"s' then Python is looking for that next \" before if runs your command.","Q_Score":68,"Tags":"python,python-3.x,string,quotes","A_Id":63727424,"CreationDate":"2020-09-03T15:50:00.000","Title":"Why doesn't Python give any error when quotes around a string do not match?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know pandas has weekday() which returns the day of the week as an integer (0 as Monday and 6 Sunday) but I can't think of solution that will return True if the current date today is the 4th day of the month while disregarding Sunday and Monday, considering the schedule runs only from Tuesday to Saturday.\nIs there anyone came across with this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":106,"Q_Id":63727650,"Users Score":1,"Answer":"The typical way to solve problems like these is just to build a table:\nFor each day of the week, ask yourself:  If the first of the month falls on that day of the week, what day of the month\/day of the week do I want my event to happen on.\nWrite a predicate that returns true on precisely those 7 day-of-week\/day-of-month combinations and nothing else.","Q_Score":0,"Tags":"python,date,datetime","A_Id":63727798,"CreationDate":"2020-09-03T16:10:00.000","Title":"How to determine if 4th day of the month (Mon and Sun not included)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"I am building a heat map for my company from a generated csv. After a lot of reading I built it using jupyter notebooks (online) using the gmaps API. I've never done anything like this before and jupyter\/python\/gmaps made it easy to accommodate my requirements (allows for zooming, hovering over a point displays data, easy data cleaning).\nNow I've reached the point where I need to share what I have built (with non-programmers). Right now the user can hit a button and a csv generates, I then take that csv and manually place it in my jupyter notebook folder, my code reads it in via pandas and generates the heatmap. I've seen a lot of resources pointing to github, nbviewer, Colaboratory and others but can't seem to find anything that allows user input. Ideally users would be able to click the button and a heatmap would appear (online or not). Security is also an issue so I am not able to make this project public.\nIs there a way to make jupyter notebooks (with gmaps) into an executable that allows input? Or another way to securely share my project that automates the csv upload? Am I looking at this from completely the wrong angle and need to change my technology?\nThank you very much in advanced! I am new to this kind of project and appreciate any help :)\nMore Info:\nWindows 10,\nGeneral environment: visual studio 2019 C#,\nCurrent project: python 3","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":230,"Q_Id":63730494,"Users Score":2,"Answer":"I decided I was thinking about jupyter notebooks in the wrong way and that that technology is more for research\/data science. I decided to just make a website that launches when the user clicks the button and have the data auto upload. I changed my technology to google maps javascript api and this seems to do everything I need it to do. I changed my data from csv to json but otherwise I think this is the right answer for me.","Q_Score":3,"Tags":"python,jupyter-notebook,exe,heatmap,jupyterhub","A_Id":63766221,"CreationDate":"2020-09-03T19:32:00.000","Title":"How to Share a Jupyter Notebook with a CSV Input","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"here is idea\/workflow:\nI have bunch of network devices that I need to communicate with.\na. client (flask\/python) sends request: \"mac-table sw1\" to Celery.\nb. celery look at available workers\/tasks and if no workers responsible for sw1 exists - it will create one and pass job to it.\nall consequent requests for sw1 will be forwarded to existing worker automatically (thus eliminating establishing sessions for every requests and limiting concurrent sessions to the device)\nc. if worker idle for some time, it close connection to device and exit.\nquestions: is Celery good for this workflow ? do you know any example of similar workflow I can get ideas from.\nThank you!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":494,"Q_Id":63731582,"Users Score":0,"Answer":"If I understood well, what you want to achieve can be accomplished by dynamically creating a queue for particular job, picking one of the available workers, and subscribing it to that queue. It also requres some cleanup task that would remove unused queues (it can be a task that runs every N minutes that inspects queues, checks whether there is anything running there, if not unsubscribe the worker from that queue).","Q_Score":1,"Tags":"python,celery","A_Id":63741578,"CreationDate":"2020-09-03T21:00:00.000","Title":"use celery for dynamic tasks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have the project successfully deployed through AWS. However, I would like to make some changes and experiment on them using localhost:8000\/ first before making the changes to AWS server. I set my settings.py to: ALLOWED_HOSTS = ['IP address', 'www.website.com'] to deploy it. Though, I also want to be able to run the server in my local computer so I can experiment it before showing to public. The url is (r^homepage$') When I go to localhost:8000\/homepage, it gives a Bad Request (400). I tried many permutations of the urls but nothing works.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1097,"Q_Id":63732724,"Users Score":1,"Answer":"you can set Debug=True to see the error message.","Q_Score":0,"Tags":"python,django,server,localhost,bad-request","A_Id":63742098,"CreationDate":"2020-09-03T23:00:00.000","Title":"Bad request (400) on Django Localhost","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I started studying the socket library in Python for the first time, and I realized that there is a constant called AF_UNIX that does the same thing as AF_INET but it is faster and establishes connection only with the same machine and uses the system file instead of internet connection\nbut what I didn't understand is why? why would i establish communication with my own machine? what use would that be and in what situation would it really be useful to use AF_UNIX?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":315,"Q_Id":63733211,"Users Score":3,"Answer":"Your question has many answers, I'll try to answer a few use cases for AF_UNIX:\n\nYou could use it to expose a private channel for other processes to communicate securely using files (since it'll respect the filesystem hierarchy and *nix permission model). PostgreSQL is known to expose a unix socket for it's psql cli to connect securely.\n\nYou could implement exchangeable communications using a socket protocol, as it's easy to move between AF_INET and AF_UNIX and expand it's communication throughout different hosts (redis and docker does this).\n\nYou could create a extendable and fast way for different processes and technologies to communicate without the device overhead AF_INET would include, even if you're using loopback interface.\n\n\nThe possibilities are actually limitless, as it includes a bit of personal preference. But the fact that AF_UNIX uses a similar specification as AF_INET makes it a powerful tool to extend communications between processes without having to rely on heavily different tools (FIFOs, shared mem, internal queues, files, to name a few).","Q_Score":3,"Tags":"python,sockets,python-3.7,local","A_Id":63733290,"CreationDate":"2020-09-04T00:09:00.000","Title":"When and why to use AF_UNIX, why work with the same machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried all possibilities for this issue in Django but it's not resolved at. it will not create 0001_initial.py I tried many ways.\npython manage.py showmigrations\npython manage.py makemigrations \npython manage.py migrate","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":63734734,"Users Score":0,"Answer":"You should first check that you have created your database on settings.py:\nDATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3','NAME': 'mydatabase',}}\nNext make sure that you have created an app using python manage.py startapp appname\nIf that is done you also want to make sure that you actually have a database model made on models.py.\nThen run:\npython manage.py makemigrations appname\npython manage.py migrate","Q_Score":0,"Tags":"python,django,sqlite,django-models","A_Id":63734800,"CreationDate":"2020-09-04T04:11:00.000","Title":"Exception Value:no such table: appname_tablename?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to use the module pyautogui but when I import it,python says no module named pyautogui even though I installed it on command prompt","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":63734793,"Users Score":0,"Answer":"The error you are getting might be because you are installing it on python 2 instead of python 3.\nTry running pip3 install pyautogui","Q_Score":0,"Tags":"python,pyautogui","A_Id":63734832,"CreationDate":"2020-09-04T04:19:00.000","Title":"how Do I solve a problem where modules don\u2019t get imported although I installed it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written an SEM (Scanning electron image)-image analysis program in Python which is capable of calculating all the microstructural properties in an SEM image e.g. Identification of different areas in the image 2) calculate the area of specific regions in microns, diameters, circularity, etc. The final results are in the form of a graph(area in microns vs cumulative frequency vs percentage contribution) plotted with the help of Matplotlibrary in Python. I want to give this program on a server where anyone can use it through an interface without looking at the code. I am confused that what should I use to do so? Will Django be a good choice for this? But I suspect Django cannot perform all the tasks (Not sure). I have also read about Jenkins servers. Please guide me which approach should I use to deploy this image analysis program for any user on a server. Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":63735250,"Users Score":0,"Answer":"Cool stuff!\nIf you want to make a server where other user can interact with your program using a user interface then yes Django (or even better Flask) will work.\nA very basic structure for your program is to have one endpoint which will render a simple html home page with a form input for uploading a file. Once the file is uploaded, the form is shipped to your backend which will accept the file and give it as an input to your python function for SEM file analysis. The function could then generate a figure which the user will be able to download. That would however require setting up a database (which is usually simple with Django). So yes you can go either with Django or Flask and everything should fall into place.\nHowever, be careful with research project aimed towards people that do not want to deal with scripting or code. I've made a few research project like this for brain imaging data (with a GUI and all) and all of these project ended up being a huge time sink. There will be updates to the analysis to do, bugs on the user interface to fix and cryptic compatibility issues. I've come to the realization that it is much better to have the minimal amount of user interface for a project like this and spend more time documenting how to make the code run on the command line using a well crafted README.md. This allows you to focus on what has a lot of value for your research and also helps other people learn valuable skills.\nAnyway, that last paragraph was just my opinion! If you feel like setting up a full-blown website for this project go for it!","Q_Score":1,"Tags":"python,django,user-interface,data-visualization,web-frameworks","A_Id":63736679,"CreationDate":"2020-09-04T05:19:00.000","Title":"What should I use to deploy a python based image analysis program for an end-user on a server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"One of my friends who works on JAVA asked me how do I handle checked and unchecked exceptions in Python. I haven't heard these terms before, so I googled around to find out what is checked and unchecked exception. I didn't find anything related to this kind of exception in Python.\n\nDo we have a concept of checked and unchecked exceptions in Python? If\nno, then by default all the exceptions are checked or unchecked?\n\nThank you in advance!","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1451,"Q_Id":63735271,"Users Score":-1,"Answer":"Java have checked and unchecked exceptions because Java is a complied programming language, checked exception comes in compiling. In python, there is no such exception because Python is an interpreted language.","Q_Score":5,"Tags":"java,python,exception","A_Id":63735526,"CreationDate":"2020-09-04T05:22:00.000","Title":"Do we have a concept of checked and unchecked exceptions in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am reading a book on Tkinter and so far making good progress understanding the concepts for a gui I want to make. One thing unexplained in the book is the concept of focusIn and focusOut. I have looked at the tcl.tk explanation and cannot understand what the events mean from that either.\nIf this is not the correct place to post such a question I apologise but I don't know where else to ask.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":140,"Q_Id":63737483,"Users Score":3,"Answer":"The focusIn event occurs when you select a widget so that your keyboard input goes to that widget. For instance, when you click on an input field so you can type into it.\nThe focusOut event occurs when you leave the widget that previously had focus, by moving keyboard focus to some other widget.","Q_Score":1,"Tags":"python,tkinter,focus,tk,focusin","A_Id":63737547,"CreationDate":"2020-09-04T08:23:00.000","Title":"What do the focusIn and focusOut event types mean?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting the following error in the VS Code output terminal:\n'C:\\Users\\S' is not recognized as an internal or external command,\noperable program or batch file.\nAny help in resolving this would be appreciated...","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":211,"Q_Id":63739354,"Users Score":1,"Answer":"The user \"S\" doesn't exist on your computer. Please change the username settings in VSCode\nReg","Q_Score":0,"Tags":"python,vscode-settings","A_Id":63739380,"CreationDate":"2020-09-04T10:26:00.000","Title":"I am getting an error in output terminal of VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have an existing flask application (having a bunch of REST apis) which is  hosted by Gunicorn. I also have to send and receive messages from AmazonMQ in the same application. I have functions using stomp.py to send\/receive messages from AmazonMQ, but I am not sure where to place them, or how should I use them so as to keep existing flow intact","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":202,"Q_Id":63741450,"Users Score":0,"Answer":"Hey thanks for help @AKX,\nI resolved the issue by triggering the whole process of messaging (Creation of connection, subscription to channel etc) by a method call from\non_starting(server)\nmethod in gunicorn_config.py","Q_Score":0,"Tags":"python,flask,gunicorn,amazon-mq,stomp.py","A_Id":64073682,"CreationDate":"2020-09-04T12:44:00.000","Title":"Placing stomp.py consumer\/producer inside Flask-Gunicorn python application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm making a discord bot using python. When I try to run it to connect my client to discord I get this error:\n\nraise ClientConnectorCertificateError(\naiohttp.client_exceptions.ClientConnectorCertificateError: Cannot\nconnect to host discord.com:443 ssl:True [SSLCertVerificationError:\n(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:\ncertificate has expired (_ssl.c:****)')]\n\nHappens every time I try to run it.\nI saw a plausible fix for this which was:\n\nGo to discord.com with Internet Explorer (Ran as Administrator)\nClick the lock on the top right\nClick view certificates\nInstall one\n\nHowever, when I tried it and then tried to run my bot again I still got the same error.\nDont know if this is relevant but at the start of the error message in the Traceback section it says the first call that started the error is in the last line of my bot's code which is client.run(TOKEN).\nI'm using Python 3.8 on Windows 10.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3719,"Q_Id":63742983,"Users Score":4,"Answer":"TL;DR Your certificate has expired, and you need to download and install the new one to your local machine by downloading it from the website and installing it into your OS.\nThis solution is performed using Google Chrome and Windows 10.\n\nGo to the website you're trying to request\nClick the lock icon to the left of the URL entry field\nIf it says Certificate (Valid), you're in business. Click that\nIn the resulting window, click the Details tab\nClick Copy to File...\nIn the certificate export wizard, select Cryptographic Message Syntax Standard (.P7B)\nCheck the box under it, Include all certificates in the cert path if possible\nClick next, click Browse and choose a folder, create a name for the file and click Save\nNext, Finish\nOpen the file you just exported. If you're on windows, it will open certificate manager\nNavigate deeper into the folders to find the actual certs\nOne by one, double click each cert and choose Install Certificate, for the current user, and automatically select where it goes\n\nOnce you install all the certificates required to validate the HTTPS request, your script shouldn't encounter the certificate expired error anymore, until the new certs expire.\nYou can also check when each cert expires in certmgr.","Q_Score":3,"Tags":"python-3.x,ssl,certificate,discord,discord.py","A_Id":69550170,"CreationDate":"2020-09-04T14:22:00.000","Title":"\"Certificate verify failed: certificate has expired (_ssl.c:****)\" When attempting to connect my bot to discord","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does py linter execute the code for checking it for errors, etc? I surfed the internet and found no information about it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":63745595,"Users Score":3,"Answer":"No, it doesn't.\npylint is a static code analysis tool. This means that the analysis is performed without executing the code.","Q_Score":1,"Tags":"python,pylint","A_Id":63745898,"CreationDate":"2020-09-04T17:25:00.000","Title":"Does py linter execute file for checking?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make a \/subscribe endpoint that will add the client to a list that will be notified with a webhook when an event happens. How can I get the data from flask needed to connect to the client later so I can then send a POST in requests later?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":63746471,"Users Score":0,"Answer":"You can not store the connection details.\n\nThere is nothing called CONNECTION. It is just an HTTP request from one server to the other.\nAll HTTP requests are just messages that you (Browser or a server) sends to another server asking for something like \"Can I view your website?\" or \"Can you send me this data?\" etc.,\n\n\nPossible solution for you:\n\nI have worked on webhooks for one of your products in our company and the best way to give the ability to create a webhook to your client is, asking for their endpoint.\n\n\nWhat I did:\n\n\nI ask the client for their endpoint so that I can call it whenever there is an event.\nAsk them to create and share a secret_key so that no one else can call that endpoint other than you.\nCall that endpoint using their secret_key whenever there is an event.\n\nAbove is just an outline of how it is done (Or at least how I did it).","Q_Score":0,"Tags":"python,flask,python-requests","A_Id":63747062,"CreationDate":"2020-09-04T18:38:00.000","Title":"Flask: How can I store the connection details of clients [Inside NAT], so I can POST them a webhook later?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am on a windows machine, and I am attempting to set up plaidml after installing using the \"plaidml-setup\" command, but it does not work. I keep getting the \"'plaidml-setup' is not recognized as an internal or external command, operable program or batch file.\" error. I have already installed plaidml using the \"pip install -U plaidml-keras\" command, and have tried uninstalling and reinstalling it.\nI've searched online to solve the issue but cannot find why the command will not work and allow me to chose my AMD gpu. The only information I was able to find were people repeating the \"pip install -U plaidml-keras\" and \"plaidml-setup\" commands.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":271,"Q_Id":63748356,"Users Score":0,"Answer":"The console doesn't recognize the command, because you are trying to call a program which does not exist in the location you are in. You are either in the wrong location (go to the correct one by typing cd [path]) or call the program with the correct name.","Q_Score":2,"Tags":"python,plaidml","A_Id":65267175,"CreationDate":"2020-09-04T21:44:00.000","Title":"Plaidml wont setup: 'plaidml-setup' is not recognized as an internal or external command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"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 develop a web service with RESTful API on Django. I would be grateful if someone could clarify a few questions and point me in the right direction.\nIt has to connect to a remote database and perform long queries and then return the rows to a user (I plan on returning csv files)\nI chose Django as a framework, but I am a bit lost with all the things I read\n\nSince queries take a long time to finish , the service should somehow work in async. The async concept in regards to web services especially in connection to Django is really complicated to grasp.\nWould using new Django 3.x async features be enough for this task?\nI've read about Celery the queue manager that is supposed to provide some degree of parallelisation (am I correct on this?)\nI've also read about nginx + wsgi + Django. Should I go with that?\n\nIn regards to nginx and other web servers. Am I correct in understanding that Django in itself can function as a web server, but nginx can be used to somehow better the performance of a Django application?\n\nShould I use \"django rest framework\" for the task?\n\n\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":93,"Q_Id":63749658,"Users Score":1,"Answer":"Your question: \"Django in itself can function as a web server?\":\nDjango's http server service is for developer's convenience and needs only. The developer can test the application in easy way. In no circumstances is Django's http server service appropriate to be used in production environment, not just  because of performance.\nFurther:\nYour questions regarding concept:\nthere are \"hundred options\" how you can  meet the project requirements. If this is a serious project (not just for exercise purpose), in the light of your questions, the only answer is: use a technology you are best familiar with.","Q_Score":0,"Tags":"python,django,nginx,asynchronous,server","A_Id":63759093,"CreationDate":"2020-09-05T01:25:00.000","Title":"Django web service stack and concepts questions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"There is a game where rectangles falls and we have to avoid them, if we collide once speed decreases by 1 , second time speed decreases by 2 and so on\nHow to find out how many times we collided","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":63,"Q_Id":63750182,"Users Score":2,"Answer":"You can create a variable which gets added to every time you collide and another variable which is set to true once it collides then you can make it false and send the rectangle somewhere else.","Q_Score":1,"Tags":"python,pygame,rect","A_Id":63750800,"CreationDate":"2020-09-05T03:33:00.000","Title":"How to know how many times my rectangle has collided with other rectangles in pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a website where user come and login, after login user publish articles with admin approval . I do not know how to do it. I made a user authentication system where user can login. But i do not know how to make him post data with admin approval.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1284,"Q_Id":63752589,"Users Score":0,"Answer":"That's a Good one. You can enable this with adding a new column to your database like onapproval Set it as an boolean variable like 0 or 1 either true or false. Then check for it. If it's true you can set the status as approved and if it is not set it as not approved. The same process will also takes place in admin panel too.","Q_Score":0,"Tags":"python,django,view,admin","A_Id":63752633,"CreationDate":"2020-09-05T09:50:00.000","Title":"how to implement an admin approval system for posting blogs in pythondjango","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have two files - one contains a load of Syslog entries for different network devices (syslog.txt).  The other contains the hostname and IP's of the network devices (hosts.txt).\nI want to be able to write a code that outputs any Syslog entries that are from network devices contained in the hosts.txt file.\nNB: The hosts.txt file just contains a hostname and IP.  The Syslog entry will contain the hostname\/IP + other wording.  I need the whole line outputted from the Syslog file.\nHope that makes sense!\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":63755287,"Users Score":0,"Answer":"Dependent on how the syslog is formed you could run a regex over all lines and then output matching lines.","Q_Score":0,"Tags":"python","A_Id":63755320,"CreationDate":"2020-09-05T14:57:00.000","Title":"Python - How to match contents of one text file in another text file and output the result","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have trained my model (.fit()) and satisfied with the performance on test split making prediction (.predict()). So I save my model to the disk (.save('model.h5')).\nNow I'm given new unseen dataset and asked to evaluate my already saved model on this dataset for performance. I am required to not only report accuracy but stuff line precision\/recall, confusion matrix etc...\nI then loaded my saved model (.load_model('model.h5')).\nQuestion:\nWhat the appropriate function that I should use to prepare report of the model performance on this new dataset. I should I use .predict() function or .evaluate().","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":319,"Q_Id":63755812,"Users Score":1,"Answer":"If you want to get loss\/accuracy or whatever other metrics you had during training - you need  .evaluate() method. If all you need is actual probabilities or regression values - you need .predict() method.","Q_Score":2,"Tags":"python,python-3.x,machine-learning,keras,deep-learning","A_Id":63755900,"CreationDate":"2020-09-05T15:52:00.000","Title":"Evaluating my model in new unseen dataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a Python program that I do NOT want to turn into .exe or anything else.\nHowever since the program needs python.exe to run, it runs python.exe openly.\nI want to know if I can add a piece of code to the program I made so that it runs in the background.\nBTW, I do not want to run through cmd.I want it to be a background process automatically.\nBasically, I want to add some code into my program so that as soon as it is clicked upon, it runs in background.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":289,"Q_Id":63756319,"Users Score":0,"Answer":"I found out the way to do this easily: I just renamed my file.py into file.pyw\nNow, it runs without a console. Basically I typed this in the cmd:\nren file.py file.pyw","Q_Score":0,"Tags":"python,windows,background-process","A_Id":63770595,"CreationDate":"2020-09-05T16:48:00.000","Title":"How to make a python file run in the background when minimized?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"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'm trying to train an object detection model from tensorflow 1 detection model zoo using python, version 3.7, and when I'm executing it throws all these errors. I'm still learning about this so I haven't any idea about how to solve this problem. Have anyone had the same issue about the different dimensions?\nI have checked different questions from this web, like looking for 0 height or width into my csv files and things like that, but It seems like that is not the problem.\n\ntensorflow.python.framework.errors_impl.InvalidArgumentError: Shape\nmismatch in tuple component 16. Expected [1,?,?,3], got\n[1,1,242,640,3]","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":102,"Q_Id":63756857,"Users Score":0,"Answer":"Finally I checked my dataset and my csv file. The problem was almost all of the images had the same shape, but 3 of them not. So I changed those images and regenerate the csv files and the tfrecord files and now is running. The thing with the shape mismatch threw me off, but finally that was the problem","Q_Score":0,"Tags":"python-3.x,tensorflow","A_Id":64283197,"CreationDate":"2020-09-05T17:44:00.000","Title":"Shape mismatch in tuple component 16. Expected [1,?,?,3], got [1,1,242,640,3]","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Every time i change something in .ui file from qt designer, then i compile with pyuic5 command.\nThen i put MainWindow.showMaximized() instead of MainWindow.show() command.\nIs there any way to do it from Qt Designer?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":63757425,"Users Score":1,"Answer":"TL;DR; No, it is not possible.\n\nQt Designer is used to:\n\nConfigure the qproperties of QWidgets.\nMake connections between widgets.\nEdit some properties of the QActions.\nCreate and modify qresource.\n\nAnd in none of these possibilities does it involve method showMaximized.","Q_Score":1,"Tags":"python,pyqt,pyqt5,qt-designer","A_Id":63757509,"CreationDate":"2020-09-05T18:47:00.000","Title":"Maximaze window from qt designer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python functionality in Jupyter notebook\/ Google Colab which checks current stock prices and other computations. I'm planning to set up some alerts based on some triggers. So for being able to be running throughout the business day, how and where do I run the code?\ni. How do I run the python code 24x7? Do I need to have a designated server that runs 24\/7?\nii. Should I be changing my code to python scripts rather than using notebooks?\niii. Is there a good reference for the python project structure?\niv. Any suggestions on python libraries for setting up email\/sms\/Whatsapp alerts?\nv. I'm planning to add ML features in the future. Should I be using cloud functions vs local GPU?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":233,"Q_Id":63758021,"Users Score":2,"Answer":"One design solution would be to use a cloud provider like google cloud platform or amazon web services to schedule the execution of a python script. The involved gcp services would be Pub\/Sub, Cloud Scheduler, Cloud Functions, Storage and Cloud Source Repositories.\n\nPub\/Sub := an asynchronous messaging service\nCloud Scheduler := a cronjob scheduler\nCloud Functions := Functions-as-a-Service, deploys automatically a Compute Engine and Storage to execute the python script and deletes the Compute Engine and Storage afterwards.\nCloud Repository := private Git repository\n\n\nYou create a topic\/channel with Pub\/Sub.\nYou set up a cronjob via Cloud Scheduler to send a message periodically to the previously created pub\/sub topic.\nYou connect your GitHub repository which consists the python script with the Cloud Source Repository (Cloud Source Repository will from now on sync automatically with your GitHub Repository)\nYou create a function with Cloud Functions and use your Cloud Source Repository as the source code for the function. As a trigger for this function you set any message which is send to the previously created Pub\/Sub topic.\nThe python script could include the yfinance library to request the stock data, the google cloud libraries to handle the data storage via GCP Storage and then you could potentially extend it with other google cloud libraries to include ML services.","Q_Score":1,"Tags":"python,machine-learning,server,stock","A_Id":63758317,"CreationDate":"2020-09-05T20:04:00.000","Title":"Running a Python Application 24x7 - Design question","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"I am using Open CV2 face detection in Python.      It works very well, but often finds faces that, although they really are faces, are so blurry as to be useless.      It succeeds in finding faces that can't be recognized as male or female, adult or child, but still clearly human faces.\nDetecting a face that can't be recognized is not a useful result, but I don't know how to programmatically block these results, or determine that they should be ignored.\nThe only approach I currently have is to ignore any face smaller than a certain threshold, but I still get some large blurry faces.\nAny suggestions?       I am using the haarcascade_frontalface_alt_tree.xml for detection.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":313,"Q_Id":63761605,"Users Score":0,"Answer":"If your problem is to detect faces of Male , female or child you need to feed the images of the genders and train your program . It involves a lot of programming , but can be solved easily with opencv. You need to train your model(project) with thousands of images for accuracy.\nIf you want to detect certain faces only, you need to do the same but train your model with the images of faces you want to detect.....","Q_Score":0,"Tags":"python,cv2,facial-identification","A_Id":63762542,"CreationDate":"2020-09-06T07:06:00.000","Title":"Blurry faces in open CV2 face detection","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using an RPyC Service to make some calculations on a remote machine and then want to return the result, which is a numpy array to the user - the rpyc client.\nThe return value of the service method is Netref to a numpy array, and therefore, when it returns to the client, he can not use operations such as np.mean(return_arr) on the returned array (even after using 'allow_all_attr':True).\nI am aware that I can obtain the return_arr using the rpyc obtain method on the client side, but I want to leave the client code (almost) empty for internal project reasons.\nSo, is there a way to configure the Service\/ method to return the numpy arrays by value instead of netref?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":321,"Q_Id":63762335,"Users Score":0,"Answer":"Possible solution:\nSend the client's numpy library to the service and save it as self.client_np.\nThen, whenever you want to return numpy array from a servive method to the client just use:\nreturn self.client_np.array(return_arr)","Q_Score":0,"Tags":"python,rpyc","A_Id":63765906,"CreationDate":"2020-09-06T08:48:00.000","Title":"Return object by value (not as Netref) from RPyC service exposed method","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm getting a strange error \"Process finished with exit code -1073741819 (0xC0000005)\" running python 3.7 on a windows machine. The process just crashes. The error comes in random time.  It seems to appear inside a thread.\nIs there someway to get more information where exactly the error comes from? Right now my only solution is to add logging, but that is really time consuming.\nThanks a lot for any hint.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3196,"Q_Id":63762702,"Users Score":0,"Answer":"I had the same issue, not long time ago and I have solved this with the following solution:\nreinstall python \u2013 you don't have python33.dll in c:\\WINDOWS\\system32\\\nMaybe you have different python versions \u2013 look at folders in root of c:\nIf yes, then point to your version of python.exe in pyCharm > Settings > Project Interpreter","Q_Score":2,"Tags":"python,crash,python-3.7","A_Id":65817279,"CreationDate":"2020-09-06T09:36:00.000","Title":"Python: Process finished with exit code -1073741819 (0xC0000005). How to Debug?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I use Pycharm 2020.1.4 and Python 3.8.5. Everytime I open a new project and want to use openpyxl, I have to go to the preferences (I use Mac), then interpreter, click +, then select openpyxl to be installed. Is this normal? Since I have already installed it via pip3 from Terminal, shouldn't it always be available so that I can just use import openpyxl as xl ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":63763265,"Users Score":0,"Answer":"If you have installed it on the base Python 3.8.5 on your Mac then when you add a new virtual environment you can select the 'Inherit Global Packages' in Pycharm and you will have whatever packages you installed in the base or global install.\nGenerally, it is better to have environments that are purpose specific because you may have unintended fallout from doing everything globally. Another way to do this would be to create one environment, name it something like 'data_science_env, and check the 'Make available to all projects' in Pycharm. Then you can reuse it across projects with the same package requirements.","Q_Score":0,"Tags":"macos,pycharm,openpyxl,python-3.8","A_Id":63797403,"CreationDate":"2020-09-06T10:48:00.000","Title":"Repeatedly install openpyxl for every Python3 project in Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Case I: In some cases, I use the library name to call some set of function i.e, np.median(). \nCase II: And in some cases, I use the variable name and library name to call another set of function i.e, np.mean(heights) or heights.mean().\nIn case II, I am able to use both library name and variable name. In case I, only library name works.\nMy doubt is how to differentiate these tow sets of functions.\nIf I am wrong in anyway, please clear my thoughts.\n(here i am referring to python language)\nthank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":192,"Q_Id":63764180,"Users Score":0,"Answer":"In the first case you\u2019re calling a method (function) of the library. Libraries are usually class instances or collections of functions within a module.\nIn the second example instead, you\u2019re again calling a function from the module but in this case it returns a ndarray (a numpy list basically) which itself has some methods that can be called on it.","Q_Score":0,"Tags":"python,pandas,function,numpy,libraries","A_Id":63764228,"CreationDate":"2020-09-06T12:31:00.000","Title":"Calling library functions in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My independent variable is a datetime object and my dependent variable is an float. Currently, I have a keras model that predicts accurately, but I found out that model.predict() only returns predictions for the values that are already known. Is there a method I can call to tell the program to use the model to predict unknown values? If there isn't please give me instructions about how to predict these unknown values.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":181,"Q_Id":63768722,"Users Score":1,"Answer":"Currently, I have a Keras model that predicts accurately, but I found out that model.predict() only returns predictions for the values that are already known\n\nThat is incorrect. A predict statement doesn't just 'search and return' results from training data. That's not how machine learning works at all. The whole reason that you build models and have a train and test dataset is to ensure you have a model that is generalizable (i.e. can be used to make predictions on unseen data, assuming the observation is coming from the same underlying distribution that the model is trained on)\nIn your specific case, you are using a DateTime variable an independent, which means you should refrain from using variable such as year, which are non-recurring since you can use it to make predictions about the future (model learns patterns in 2019 but 2020 may be out of its vocabulary and thus years after that are not feasible to use for predictions.)\nInstead, you should engineer some features from your DateTime variable and use recurring variables which may show reveal some patterns in the dependent variable. These variables are like days of the week, months, seasons, hours of the day. Depending on what your dependent variable is, you can surely find some patterns in these.\nAll of this totally depends on what you are trying to model and what is the goal of the model.predict() w.r.t your problem statement. Please elaborate if possible so that people can give you more specific answers.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":63768797,"CreationDate":"2020-09-06T20:41:00.000","Title":"How do I predict data using a trained keras model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm defining an update procedure on the air-gapped standalone RedHat7 server with the preinstalled python3 and\nbasic packages.\nThe python3 applications are developed on a host with an Internet access, and are delivered to this standalone\nserver using DOK.\nAdditional packages can't be installed using pip, but must be trasfered from development host to the local user's home directory.\nI'm looking for a proper way to update and activate python3 applications on this standalone server, without appending a new package path using sys.path.append(\"\/home\/user\/packages\/pack_N\") before importing it.\nThanks\nZeev","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":63768729,"Users Score":0,"Answer":"I'm assuming you meant without using \"PyPi\".\nDownloading the packages can be done with pip wheel <package> after installing the wheel package.\nInstalling them locally without using pip's servers (PyPi) can be done like so:\npip install <package> --no-index --find-links=<directory containing wheels>","Q_Score":0,"Tags":"python-3.x","A_Id":63768807,"CreationDate":"2020-09-06T20:42:00.000","Title":"Using user's dir to store copied python3 packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there any way to disable auto clearing console in Pycharm? right now each time  that we run the pycharm it clears up the console (run tool window) automatically! I need to have the history of my results","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":88,"Q_Id":63769310,"Users Score":-1,"Answer":"If you want to keep the history of the results, consider writing the output to a file instead of the console.\nIf you prefer writing to the console (perhaps that's the aim of the application), you can also change the Run Configuration for your script.\nIn the Run menu, under Edit Configurations..., select the run configuration for your script and select the Logs tab (it shows the Configuration tab by default). On there, you'll find a checkbox to Save console output to file; set a file name in the field next to it.\nCurrently, PyCharm doesn't have an option to add a timestamp to a filename like this (although the feature has been requested by users, so it may in the future). So, you could add a few lines of code to the start of your program that only runs when debugging, moving the previous output file out of the way of for the new output.","Q_Score":0,"Tags":"python,pycharm,console","A_Id":63769370,"CreationDate":"2020-09-06T22:07:00.000","Title":"Disable Auto-clearing console (run window) in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Question: I want to log the warning in odoo logs if any warning or error comes up.\nIs there any way out of it?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":453,"Q_Id":63769570,"Users Score":2,"Answer":"Please user logger to print the logs in terminal\nTry\n\nimport logging\n\n\nlogger = logging.getLogger(__name__)\n\nUse like this:-\n\n_logger.debug(\" my log in terminal\")","Q_Score":0,"Tags":"python,python-3.x,logging,printing,odoo","A_Id":63771551,"CreationDate":"2020-09-06T22:53:00.000","Title":"How to log warning, error and other info in Odoo development?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When i type 'python \u2212\u2212version' on CMD; it does not show me the version of python i am using instead it displays:python: can't open file '\u0393\u00ea\u00c6\u0393\u00ea\u00c6version': [Errno 2] No such file or directory","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":63769573,"Users Score":0,"Answer":"There are multiple ways to find the python version which you can try:\n\nIn the CMD: python -V\nIn a python document you can import sys and print out sys.version\nIn a python document you can import platform and print out platform.python_version()\n\nHope that helps. If you have an issue with your python installation, you could try reinstalling it from scratch as well. If there is no issue with your python installation then check if it is in your path and accessible from your command line, if not then either add it to your path or open your command line into the folder with the python.exe file and run your commands directly in there.","Q_Score":0,"Tags":"python,django","A_Id":63769612,"CreationDate":"2020-09-06T22:55:00.000","Title":"I can't see the version of python in cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've set up a virtualenv folder via python -m venv virtualenv, alongside my backend folder containing flask code.\nHowever, when I run the flask code, it can't find the flask module. I installed it while the virtualenv was active, and if I try running it while the virtualenv is active, then it works correctly and finds flask. But if I deactivate the virtualenv, no dice. It can't find the dependencies.\nIs that how this is supposed to work, or have I misconfigured something? Do I need to always be working with the virtualenv active? Seems wrong to me.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":63770655,"Users Score":2,"Answer":"Yes that is the intended behavior. But...\nYou don't need to \"activate\" any virtual environment. The important point is to make sure to use the interpreter that is located in the virtual environment.\nSay you run python -m venv \/path\/to\/venv. The virtual environment is created at \/path\/to\/venv and you will find a Python interpreter executable (or a symbolic link) at \/path\/to\/venv\/bin\/python.\nYou can then call \/path\/to\/venv\/bin\/python -m pip install flask. And also \/path\/to\/venv\/bin\/python \/path\/to\/some_script.py. These will all take advantage of the virtual environment isolation.\n\nAnd when you activate the virtual environment, the \/path\/to\/venv\/bin directory is placed at the top of the PATH environment variable, so that when you type python, the first python executable found is automatically \/path\/to\/venv\/bin\/python.","Q_Score":1,"Tags":"python,virtualenv,python-venv","A_Id":63774780,"CreationDate":"2020-09-07T02:33:00.000","Title":"Are you supposed to need to be in the virtualenv whenever running code in order to access the installed dependencies?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've set up a virtualenv folder via python -m venv virtualenv, alongside my backend folder containing flask code.\nHowever, when I run the flask code, it can't find the flask module. I installed it while the virtualenv was active, and if I try running it while the virtualenv is active, then it works correctly and finds flask. But if I deactivate the virtualenv, no dice. It can't find the dependencies.\nIs that how this is supposed to work, or have I misconfigured something? Do I need to always be working with the virtualenv active? Seems wrong to me.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":47,"Q_Id":63770655,"Users Score":1,"Answer":"Actually when you install dependencies in a virtual env then u must activate it before running the project, But u can also install dependencies directly to the system through the terminal (outside of virtual env) and can run the project.\nIt is preferred to have a virtual environment in order to keep your project dependencies and extra dependencies separate. As for big projects, you can easily collect the necessary dependencies without taking count of which are not used.","Q_Score":1,"Tags":"python,virtualenv,python-venv","A_Id":63770699,"CreationDate":"2020-09-07T02:33:00.000","Title":"Are you supposed to need to be in the virtualenv whenever running code in order to access the installed dependencies?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am running a flask web server on raspberry pi 3 B+. I am able to access the page 192.168.4.1:5000 on the berry(chromium).\nThe same raspberry pi is also acting as a wireless LAN router. I am able to connect my other devices like ipad and phone to this wifi network. So there is no additional router in this network where I might need to do port forwarding.\nIssue is, I am not able to access 192.168.4.1:5000 from any other device on this local network.\nPlease note that I am not using the ethernet port on the raspberry pi.\nPlease help!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1459,"Q_Id":63774624,"Users Score":0,"Answer":"Okay so the solution was to add a route.\nI did\nsudo ip route add 192.168.4.0\/24 via 192.168.4.1 dev wlan0\nNow I am trying to figure out how to make this route persistent.","Q_Score":1,"Tags":"python,flask,raspberry-pi,webserver,hotspot","A_Id":63777385,"CreationDate":"2020-09-07T09:12:00.000","Title":"Not able to access web server on Raspberry pi on local network","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"After a lot of research, it seems like there is no good way to properly stop and resume training using a Tensorflow 2 \/ Keras model. This is true whether you are using model.fit() or using a custom training loop.\nThere seem to be 2 supported ways to save a model while training:\n\nSave just the weights of the model, using model.save_weights() or save_weights_only=True with tf.keras.callbacks.ModelCheckpoint. This seems to be preferred by most of the examples I've seen, however it has a number of major issues:\n\nThe optimizer state is not saved, meaning training resumption will not be correct.\nLearning rate schedule is reset - this can be catastrophic for some models.\nTensorboard logs go back to step 0 - making logging essentually useless unless complex workarounds are implemented.\n\n\nSave the entire model, optimizer, etc. using model.save() or save_weights_only=False. The optimizer state is saved (good) but the following issues remain:\n\nTensorboard logs still go back to step 0\nLearning rate schedule is still reset (!!!)\nIt is impossible to use custom metrics.\nThis doesn't work at all when using a custom training loop - custom training loops use a non-compiled model, and saving\/loading a non-compiled model doesn't seem to be supported.\n\n\n\nThe best workaround I've found is to use a custom training loop, manually saving the step. This fixes the tensorboard logging, and the learning rate schedule can be fixed by doing something like keras.backend.set_value(model.optimizer.iterations, step). However, since a full model save is off the table, the optimizer state is not preserved. I can see no way to save the state of the optimizer independently, at least without a lot of work. And messing with the LR schedule as I've done feels messy as well.\nAm I missing something? How are people out there saving\/resuming using this API?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1495,"Q_Id":63775936,"Users Score":1,"Answer":"tf.keras.callbacks.BackupAndRestore can take care of this.","Q_Score":8,"Tags":"python,tensorflow,keras,tensorflow2.0,tf.keras","A_Id":72065560,"CreationDate":"2020-09-07T10:39:00.000","Title":"Keras - no good way to stop and resume training?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Cant seem to find any documentation, i assumed adding .To or the like would do it but im at a loss. Anyone familiar with yfinance?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":63781451,"Users Score":0,"Answer":"Turns out it was an error pulling \"Fundamentals\" when getting certain stock info. Another post advised me to add an exception in yfinance's base.py file. All works well after that.","Q_Score":1,"Tags":"python,yfinance","A_Id":63781994,"CreationDate":"2020-09-07T16:48:00.000","Title":"How do i use Canadian tickers in yfinance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do relatively modern languages such as ruby\/python\/js etc may store multiple data types in arrays and are still able to access any element from the array using its index in O(1) time?\nAs far as I understand, we do simple mathematics to determine the memory address pointing to any element, and we do so by the index multiplied by the size of each element of the array.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":166,"Q_Id":63781604,"Users Score":3,"Answer":"Firstly, neither the Ruby Language Specification nor the Python Language Specification nor the ECMAScript Language Specification prescribe any particular implementation strategy for arrays (or lists as they are called in Python). Every implementor is free to implement them however they wish.\nSecondly, lumping them all together doesn't make much sense. For example, in ECMAScript, arrays are really just objects with numeric properties, and actually, those numeric properties aren't even really numeric, they are strings.\nThird, they don't really store multiple data types. E.g. Ruby only has one data type: objects. Since everything is an object, everything has the same type, so there is no problem storing objects in arrays.\nFourth, at least the Ruby Language Specification does not actually guarantee that array access is O(1). It is highly likely that a Ruby Implementation which does not provide O(1) access would be rejected by the community, but it would not violate any spec.\nNow, of course, any implementor is allowed to be as clever as they want to be. E.g. V8 detects when all values of an array are numbers and then stores the array differently. But that is a private internal implementation detail of V8.","Q_Score":3,"Tags":"javascript,python,ruby,algorithm,big-o","A_Id":63782273,"CreationDate":"2020-09-07T17:01:00.000","Title":"Constant time to access array element while storing items of multiple data types","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do relatively modern languages such as ruby\/python\/js etc may store multiple data types in arrays and are still able to access any element from the array using its index in O(1) time?\nAs far as I understand, we do simple mathematics to determine the memory address pointing to any element, and we do so by the index multiplied by the size of each element of the array.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":166,"Q_Id":63781604,"Users Score":1,"Answer":"In memory, a heterogeneous array is an array of pointers.   Every array element stores the memory address of the item at that position in the array.\nSince memory addresses are all the same size, you can find the address of each address by multiplying the array index by the address size, and adding it to the base address of the array.","Q_Score":3,"Tags":"javascript,python,ruby,algorithm,big-o","A_Id":63783261,"CreationDate":"2020-09-07T17:01:00.000","Title":"Constant time to access array element while storing items of multiple data types","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a Python script (using Google Colab) and stored it on my Google Drive.\nWhen the Python script runs it automatically reads a Google Sheet in the same location and generates a PDF report.\nI would like to create a button in the Google Sheet which triggers this script and generates the report.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3767,"Q_Id":63782562,"Users Score":5,"Answer":"Answer\nYou can't run scripts from Drive even using Apps Script.\nApps Script runs on the server side and you have a Python script stored on Drive. It does not matter if you have both (Google Sheet and Python script) on the same location, since you are not allowed to run scripts from there, that would be a big security issue. When it comes to executing scripts such as Python, Ruby, etc, the only option to do it is on Google Cloud Platform by using Cloud Build or Compute Engine for instance. As a workaround, you could re-write your python script in Apps Script. Remember - you can't run apps script code directly from Drive either, only open it and run it from the editor.","Q_Score":2,"Tags":"python,google-sheets,google-colaboratory","A_Id":63789664,"CreationDate":"2020-09-07T18:25:00.000","Title":"Trigger Python script located in Google Drive using Google Sheets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am the beginner to tornado(python based web server). I have to create an application which will have public chat rooms and private messaging between two users.so, I have been looking for a good tutorial about tornado to implement the same but what i found is we can just create the websockets and once we have connected to socket we can send message to server and we can open multiple tabs of browser to replicate multiple users. So all users can send messages to server and every other user and can see all those messages but i need to create private message chat between two users like whatsapp. So can i do the same with tornado ? Please help me out. Any help would be appreciable.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":96,"Q_Id":63783183,"Users Score":1,"Answer":"If you can form sockets, from client to the server then yes!\nSockets are just data streams.  You will have to add chat room request data and authentication to the sockets so the server can direct each client to the appropriate chat 'room' (or drop the connection if authentication fails).\nafter that it's the same as what you have implemented already.\nFor secure chat, you'll need some form of encryption on top of all this - at least so that clients know they are talking to the correct server.  From there it's adding encryption for clients to know they are talking to the right clients.\nThe final step would be to implement peer to peer capabilities after authenticating at the server.","Q_Score":0,"Tags":"python,websocket,tornado,django-channels,sockjs-tornado","A_Id":63783494,"CreationDate":"2020-09-07T19:22:00.000","Title":"Private messaging in tornado","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My goal is to install a package to a specific directory on my machine so I can package it up to be used with AWS Lambda.\nHere is what I have tried:\npip install snowflake-connector-python -t .\npip install --system --target=C:\\Users\\path2folder --install-option=--install-scripts=C:\\Users\\path2folder --upgrade snowflake-connector-python\nBoth of these options have returned the following error message:\nERROR: Can not combine '--user' and '--target'\nIn order for the AWS Lambda function to work, I need to have my dependencies installed in a specific directory to create a .zip file for deployment. I have searched through Google and StackOverflow, but have not seen a thread that has answered this issue.\nUpdate: This does not seem to be a problem on Mac. The issue described is on Windows 10.","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":11156,"Q_Id":63783587,"Users Score":8,"Answer":"We had the same issue just in a Python course: The error comes up if Python is installed as an app from the Microsoft app store. In our case it was resolved after re-installing Python by downloading and using the installation package directly from the Python website.","Q_Score":11,"Tags":"python,pip,command-line-interface","A_Id":63812237,"CreationDate":"2020-09-07T20:03:00.000","Title":"PIP Install: Cannot combine --user and --target","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"My goal is to install a package to a specific directory on my machine so I can package it up to be used with AWS Lambda.\nHere is what I have tried:\npip install snowflake-connector-python -t .\npip install --system --target=C:\\Users\\path2folder --install-option=--install-scripts=C:\\Users\\path2folder --upgrade snowflake-connector-python\nBoth of these options have returned the following error message:\nERROR: Can not combine '--user' and '--target'\nIn order for the AWS Lambda function to work, I need to have my dependencies installed in a specific directory to create a .zip file for deployment. I have searched through Google and StackOverflow, but have not seen a thread that has answered this issue.\nUpdate: This does not seem to be a problem on Mac. The issue described is on Windows 10.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":11156,"Q_Id":63783587,"Users Score":0,"Answer":"I got a similar error recently. Adding my solution so that it might help someone facing the error due to the same reason.\nI was facing an issue where all my pip installed packages were going to an older python brew installation folder.\nAs part of debugging, I was trying to install awscli-local package to user site-package using:\npip install --user awscli-local\nThen I got:\nERROR: cannot combine --user and --target\nIn my case, it was due to the changes in pip config I had set some time back for some other reason.\nI had set the 'target' config globally - removing which removed this error and my actual issue I was debugging for.\n\nCheck the following if solutions given above doesn't resolve your issue:\ntry the command:\npip config edit --editor <your_text_editor>\nFor me:\npip config edit --editor sublime\nThis will open the current config file where you can check if there's any conflicting configuration like the 'target' set in my case.","Q_Score":11,"Tags":"python,pip,command-line-interface","A_Id":69517869,"CreationDate":"2020-09-07T20:03:00.000","Title":"PIP Install: Cannot combine --user and --target","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"My goal is to install a package to a specific directory on my machine so I can package it up to be used with AWS Lambda.\nHere is what I have tried:\npip install snowflake-connector-python -t .\npip install --system --target=C:\\Users\\path2folder --install-option=--install-scripts=C:\\Users\\path2folder --upgrade snowflake-connector-python\nBoth of these options have returned the following error message:\nERROR: Can not combine '--user' and '--target'\nIn order for the AWS Lambda function to work, I need to have my dependencies installed in a specific directory to create a .zip file for deployment. I have searched through Google and StackOverflow, but have not seen a thread that has answered this issue.\nUpdate: This does not seem to be a problem on Mac. The issue described is on Windows 10.","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":11156,"Q_Id":63783587,"Users Score":18,"Answer":"We encountered the same issue when running pip install --target .\/py_pkg -r requirements.txt --upgrade with Microsoft store version of Python 3.9.\nAdding --no-user to the end of it seems solves the issue. Maybe you can try that in your command and let us know if this solution works?\npip install --target .\/py_pkg -r requirements.txt --upgrade --no-user","Q_Score":11,"Tags":"python,pip,command-line-interface","A_Id":67259534,"CreationDate":"2020-09-07T20:03:00.000","Title":"PIP Install: Cannot combine --user and --target","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am using the django framework. I'll do the messaging part. I will do this with the socket. However, I always come across a channel library. Is there no other solution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":63784910,"Users Score":1,"Answer":"Without writing your own socket library, Channels is as close as you're going to get to official support. You could use Tornado (a different framework) for lower-level handling of simpler cases, but as far as Django goes, Channels is the normal pathway.\nIs there a reason you didn't want to use Channels?","Q_Score":0,"Tags":"python,django,sockets,channels","A_Id":63785043,"CreationDate":"2020-09-07T22:18:00.000","Title":"Is channels required to use socket with django? Is there any other alternative or way?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to web scraping and am not very familiar with requests and BeautifulSoup.\nI am trying to scrape an aspx website with BeautifulSoup. But to get the values I want to scrape, I first need to select a drop down value, input an ID, and then press submit.\nIs this even possible?\nAny help would be much appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":63785020,"Users Score":0,"Answer":"Maybe try to input the url that you get after you have made all the selections from dropdowns. Otherwise.. using Selenium is best bet.","Q_Score":0,"Tags":"python,web-scraping,beautifulsoup,python-requests","A_Id":63785808,"CreationDate":"2020-09-07T22:34:00.000","Title":"Scraping with BeautifulSoup, but first have to input values?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to download an ipynb file and so I am trying to set colaboratory as the default app to open (because when I try it says \"Please install an app, or if one is already installed, create an association in the default app setting page\". But when I go in control panel\/Programs\/Default Programs\/Associate a file type or protocol with a program\/Choose default apps by file type , I can't find .ipynd files. What should I do ?\n( I am on windows 10)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4133,"Q_Id":63785425,"Users Score":0,"Answer":"Go to Control Panel by pressing the Windows Button + R and typing cmd followed by Enter, and type pip install IPython.\nThis should allow you to open .ipynb files.\nTo set the default app for opening specific files, right-click the file (in this case any .ipynb file), press Open With, hover the cursor over Show More, press Choose Another App, press Show More (if the desired app isn't there), select your app, press Always use this app to open .ipynb files, and press OK. This should set the app you want as the default app.","Q_Score":1,"Tags":"python,file","A_Id":63785530,"CreationDate":"2020-09-07T23:41:00.000","Title":"Can't download ipynb file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"I am trying to make a jupyter notebook in visual studio code but I keep getting this:\n\n''Unable to start session for kernel Python 3.8.3 64-bit ('Lenovo':\nvirtualenv). Select another kernel to launch with.''\n\nI have anaconda installed and the jupyter notebook works fine in the anaconda navigator. I also tried to use python 3.8.3 base:'conda' but it didnt work. I'm using windows 10","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1618,"Q_Id":63789185,"Users Score":1,"Answer":"I had the exact same problem. Fix it by uninstalling the Python extension that is linked to that error message.","Q_Score":2,"Tags":"python,visual-studio-code,jupyter-notebook,ipython","A_Id":63858113,"CreationDate":"2020-09-08T07:35:00.000","Title":"Unable to start jupyter notebook in visual studio code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to pass SSEKMSKeyId and ServerSideEncryption to scrapy FilesPipeline using AWS S3 or do I need to write a separate pipeline?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":134,"Q_Id":63790967,"Users Score":0,"Answer":"Subclass scrapy.pipelines.files.S3FilesStore, and extend its HEADERS class attribute in your subclass to define the headers you want with the values you want.\nIn your case, the corresponding headers are: X-Amz-Server-Side-Encryption, X-Amz-Server-Side-Encryption-Aws-Kms-Key-Id (you can see the header-to-key mapping in the source code of the class, for additional header names).\n\nSubclass FilesPipeline, and edit the STORE_SCHEMES class attribute in your subclass to point s3 to your S3FilesStore subclass.\n\nUpdate your ITEM_PIPELINES setting to use your FilesPipeline subclass.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,scrapy","A_Id":63917828,"CreationDate":"2020-09-08T09:25:00.000","Title":"Is there a way to pass SSEKMSKeyId and ServerSideEncryption to scrapy FilesPipeline using AWS S3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a topic from which I need to consume and process data and I am using kafka-python package to do so.\nI am facing a lot of issues related to rebalancing, slow data consumption across a few partitions, and want to confirm if it because of any compatibility issues.\nSo, how can I check what is the underlying Kafka version used in kafka-python so that I can eliminate the possibility\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":63791469,"Users Score":0,"Answer":"kafka-python is a native Python library, so there is no \"Kafka version\" such as the native Java library it depends on.\nThe native binary Kafka TCP protocol has no discernible version\nIf you were to use confluent kafka Python library, then that would depend on a version of librdkafka C bindings","Q_Score":0,"Tags":"python,apache-kafka,kafka-python","A_Id":63797142,"CreationDate":"2020-09-08T09:56:00.000","Title":"Underlying kafka version in kafka-python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"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":"I'm trying to compile a Django (3) applications that uses pymongo and channels. I followed steps in a ticket in stackoverflow, I got the .exe file but when I try tu run it using app.exe runserver I got this error :\n\\AppData\\Local\\Temp\\_MEI149762\\Test_Project\\settings.pyc'\nFailed to execute script manage\nI've found nothing on the net discussing this issues.\nHELP PLEASE.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":63793921,"Users Score":0,"Answer":"Did you try to add --onefile parameter ?","Q_Score":0,"Tags":"python,django,mongodb,pymongo,pyinstaller","A_Id":63794033,"CreationDate":"2020-09-08T12:25:00.000","Title":"DJANGO PYINSTALLER ISSUE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was using Django-python framework for my web app. When I build a strategy in the UI it gets converted into a .py script file and every 5 mins (can be variable based on my candle interval) the file gets executed. I was using celery beat to invoke the file execution and the execution happens on the same machine using celery.\nHere the problem is actually with scalability, if I have more strategies my CPU and memory usage were going more than 90%. How do I design the server architecture so that it can scale. Thank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":123,"Q_Id":63793935,"Users Score":1,"Answer":"When one Celery worker is no longer enough, you create more. This is quite easy if you are on a cloud platform where you can easily create more virtual machines.\nIf you can't create more, than you have to live with the current situation and try to spread the execution of your strategies across a longer period of time (throughout the day I suppose).","Q_Score":0,"Tags":"python,server,architecture,celery,algorithmic-trading","A_Id":63794819,"CreationDate":"2020-09-08T12:26:00.000","Title":"How to design architecture for scalable algo trading application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I tried this way but it still does not work.\nControl Panel >> System and Security >> System >> Advanced System Settings >> Advanced >> Environment variables.\nAdd MongoDB's bin folder path to path variable in Environment variables\nError message:\n'mongorestore' is not recognized as an internal or external command, operable program or batch file.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3178,"Q_Id":63794153,"Users Score":0,"Answer":"make sure your using the msi version not the rpm or tgz if your using windows. Also, add the directory of the files you want to restore to your path. The mongorestore command was not being recognized there until I added it, it was only being recognized in the directory I had it installed.","Q_Score":1,"Tags":"python,mongodb","A_Id":67964062,"CreationDate":"2020-09-08T12:40:00.000","Title":"'mongorestore' 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":0,"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 have a database using PostgreSQL but the published site is Vercel and when deploying for production is gives the error below. The error doesn't happen for Heroku\ndjango.db.utils.OperationalError: FATAL:  no pg_hba.conf entry for host \"123.456.789.102\", user \"example_user\", database \"example_db\", SSL off\nHow do I solve this error, thank you. I have checked Google results aren't really helpful","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":206,"Q_Id":63797999,"Users Score":0,"Answer":"I found the answer out. It was just not to use Heroku but instead I used a service called ElephantSQL and used the details and it worked perfectly well","Q_Score":0,"Tags":"python,django,postgresql","A_Id":65493860,"CreationDate":"2020-09-08T16:27:00.000","Title":"How to solve error with syncing PostgreSQL with Vercel","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using the Cassandra python driver working containing a table with 38500000 rows. I'm benchmarking various databases with a product I'm we're developing. To benchmark selection I use a filter that should return around half the rows with 3 selection columns (then I vary the selection columns to see which perform best). However when working with Cassandra I only get 57016 results each time per query (which must be some cap). I've tried using SimpleStatement and setting fetch_size = 38500000 but this didn't work. I was wondering if there's some parameter I should be changing as I can't find anything in the documentation apart from how Cassandra breaks down pages that go beyond the fetch_size.\n[EDIT]\nTo add some more information the query returns:\ncassandra.ReadFailure: Error from server: code=1300 [Replica(s) failed to execute read] message=\"Operation failed - received 0 responses and 1 failures\" info={'consistency': 'LOCAL_ONE', 'required_responses': 1, 'received_responses': 0, 'failures': 1}\nafter I used session.default_fetch_size = None. Then after increasing tombstones to tombstone_failure_threshold: 10000000 and letting gc_grace_seconds = 0 I still get the same error. I've also gone into Cluster.py and set the _default_timeout = 1000 but that didn't lead to anything.\n[EDIT 2]\nGoing through the debug console the error is:\n<SELECT * FROM mydb.facttable WHERE int64 > 0 LIMIT 38500000>, total time 5007 msec, timeout 5000 msec, so again where can I modify the timeout 5000msec parameter?","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":376,"Q_Id":63800192,"Users Score":5,"Answer":"Hy there.\nGood news is I think I can explain your situation and problems but the bad news is I don't think there is an easy fix.\nTo give you the short answer and solution:\nThe read fails because Cassandra has safeguards in place to prevent \"malfunctioning\" or \"rogue\" queries from compromising the performance of the whole cluster. For this reason there is a read timeout (as you discovered yourself in EDIT2) that defaults to 5000ms.\nIf you need to increase that value, you need to modify read_request_timeout_in_ms in cassandra.yaml.\nThis however is not a real solution.\nNow, for the long answer:\nFrom what I understand you are targeting with your query 38M rows that you want Cassandra to filter and then return approximately 19M rows. I could see this value achieved on production hardware with well designed tables and a lot of fine-tuning.\nGiven the info in EDIT1, it looks like you are using a one node cluster so I imagine this is a small development node maybe even hosted on your laptop\/pc. While sharing the table schema and query could have provided more info and lead to more advice, overall the problem remains that you are trying to run a task on a clearly under-powered cluster(node actually).\nFrom you data, the node was able to process just over 20k rows per second(and return 10k) before timing out. From my experience this seems consistent with a low resource devel node. Extrapolating from this, it would take your node around half an hour to go trough 38M records assuming it will have the memory to do so and no other configuration will pose problems (if I didn't messe up the calculations). That is a very long time for a query, even for an administrative one.\nWhen trying to work with so many rows you should not only try to have proportional HW to run the queries against but also:\n\nAvoid full scans (you should always try and hit a single partition, if that is not the case you should probably rethink the DB model);\nMost partitions should be under 10MB and all should be under 100MB;\nPartitions while hard-capped at 2 billion cells((no. of rows) * (avg. no. of cells per row)) should usually remain under 100k cells.\n\nGiven the 3 \"best practices\" generally accepted as such, and the data you provided, I am inclined to believe that you are not implementing at least 2 of the 3. That and combined with under-powered HW leads to a lack of a simple solution (like just increasing the timeout value).\nMy suggestion to really resolve the problem is:\n\nIf you are only doing this to test your code or different approaches, then use a proportional amount of data with the power of the devel \"server\" compared to your production one. You should still make sure the model you are using cold be effectively run in production given that the large amount of required rows make me think there might be a problem with the DB model.\nOpen another question with information about your situation, current schema and desired outcome and you could receive help on modeling your use-case. While Cassandra can be very powerful when used right, it can be extremely inefficient when badly used.\n\nHope this helped,\nCheers.","Q_Score":2,"Tags":"python,database,cassandra","A_Id":63897622,"CreationDate":"2020-09-08T19:11:00.000","Title":"Cassandra unlimited row response","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am experimenting with different methods of binning a continuous variable. two methods that I used - qcut and entropy_based_binning method bin_sequence. For testing I created a data with 100 values. I made the data skewed by putting value = 1 for first 50 records, 2 for next few records, 5, 12 for few records and then randomly few numbers.\nWhen I tried to run it with number of bins = 6 it created only 3 bins with qcut method. from pandas documentation it is not clear how it behaves with skewed data. Also, there is very limited information available on entropy based binning. Would appreciate if someone can share details. Pros and cons of each method\nage\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n12\n12\n12\n12\n12\n12\n12\n12\n12\n5\n5\n5\n5\n5\n5\n5\n5\n20\n20\n20\n20\n20\n20\n20\n25\n26\n27\n93\n50\n54","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":147,"Q_Id":63803037,"Users Score":0,"Answer":"When using qcut(), it will sort the array, and create bin boundaries based on the values at positions data[(len(data)*index \/ bin].\nIn your case, a lot of those values are equal. You should have gotten a warning about that, unless you explicitly told it to \"drop\" duplicate values by calling pd.qcut(age, q=6, duplicates='drop').\nFor entropy-based binning, you need a class label. You get bins with boundaries based on age, such that the class in each bin is (ideally) as uniform as possible. In your example, we only have age, so we can't use entropy-based binning.\nFor your particular setting, I would use qcut(), set the number of bins high enough, tell it to drop duplicates, and see what bins come out of it. One of the bins will have a lot of data in it (the first one), but that can't be helped, since our data is so highly skewed.","Q_Score":0,"Tags":"python-3.x,binning","A_Id":63803169,"CreationDate":"2020-09-09T00:06:00.000","Title":"Panda.qcut inside logic of binning","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently installed Python 3.8 onto my computer. I now have Python 3.7 and 3.8. I would like to delete 3.7 but I don't want to mess anything up.\nWhen I type 'python --version' in the Anaconda Prompt,\n\nPython 3.7.9\n\nI fear that if I uninstall 3.7, all the libraries in Anaconda will not work. How do I uninstall 3.7 and make sure that Anaconda \"links up\" with 3.8?\nUPDATE:\nI've since figured this out... I originally tried to install with 'conda update python' ... this does not achieve the update. I then downloaded 3.8 from Python's website. This seemed to mess up things. I then uninstalled all of Anaconda and then reinstalled it. By re-installing, Python 3.8 was installed and is working. For future updates, I am still not sure what the best way to update from 3.x to 3.y is as suggestions on other message boards did not seem to work.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4891,"Q_Id":63803973,"Users Score":1,"Answer":"Thank you for sharing this. I literally just spent a day trying to update python version using conda but it goes into a seemingly endless loop of resolving conflicts. I also tried to install 3.8 directly but that did not work. The solution really was to just download and install the latest version of Anaconda.","Q_Score":2,"Tags":"python,anaconda,conda","A_Id":63908759,"CreationDate":"2020-09-09T02:31:00.000","Title":"How do I upgrade to Python 3.8 with Anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"It seems that many projects provide only an indication of the minor python version (e.g. python 3.6), whereas requirements.txt may require a specific version of a package (e.g. torch==0.4).\nThis specific version of a package is not available for any minor python version (e.g. torch==0.4 can be installed only with python 3.5 ou 3.6).\nBut what happens with maintenance Python versions? (e.g. python 3.6.9). Can we assume that torch==0.4 will always be distributed?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":26,"Q_Id":63807627,"Users Score":0,"Answer":"Python project distributions (libraries, packages, applications) are meant to be compatible with all maintenance releases of the same minor version of the Python interpreter (in 3.6.9: 3 stands for the major, 6 for the minor, and 9 for the maintenance or bugfix). In other words if a library is advertised as compatible with Python 3.6, it means it is compatible with all Python 3.6.* versions (3.6.0, 3.6.1, 3.6.9, etc.). On the other hand there is no guarantee it is compatible with 3.7.*, 3.5.*, or even less so with 2.* or 4.*.","Q_Score":1,"Tags":"python,pip","A_Id":63807829,"CreationDate":"2020-09-09T08:24:00.000","Title":"Does pip share the same versions of a package given a maintenance version of Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"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 create a django project called Polls and i have one project called registration but anytime i run my polls server it always go to the registration server and display things there also my migrations doesnt go to the polls server","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":102,"Q_Id":63813074,"Users Score":0,"Answer":"When you start the server, The default port is 8000(127.0.0.1:8000)\nif you want to run multiple django projects try using different ports.\nFor example:\n1.) python manage.py runserver 127.0.0.1:8004\n2.) python manage.py runserver 127.0.0.1:8008\nand etc...","Q_Score":0,"Tags":"python,django","A_Id":63813632,"CreationDate":"2020-09-09T13:47:00.000","Title":"How can i create multiple django project on pycharm without one conflicting with other port","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to run my Python application (through Bamboo) using a Script task which runs the application.\nI tried (as a task) with\n\nPython myprogram.py\n\nBut it blocks the process of deployment and its status remains InProgress.\nHow to run the Python application from within Bamboo (deployment phase) successfully ?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":271,"Q_Id":63814424,"Users Score":0,"Answer":"I think there is no problem with the way you are trying to run your python script from within your deployment. Can you confirm that you are not using inline with script task to run your python script ? Also the other thing, have you run your python script locally, just to be sure there is no issue within your code ?","Q_Score":0,"Tags":"python,python-3.x,python-2.7,deployment,bamboo","A_Id":63822696,"CreationDate":"2020-09-09T15:02:00.000","Title":"Writing a script task to run my Python application within Bamboo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a Python project with multiple source packages\/files which also uses packages such as numpy,scipy, pandas. \nAlso I am using Pyinstaller onefile mode to package the project in to a single executable and I am trying to reduce the time consumed by Pyinstaller to generate the executable. \nFirstly Pyinstaller took ~20 minutes to bundle, and most of the time was taken by hook of \"gevent\" module. I excluded gevent module (since it wasn't a truly used module) which bought the time to 8-10 minutes. I also notice that by first generating and saving the \"Analysis.toc\" file in build directory can reduce the time taken in Analysis stage in consecutive runs (given that no additional sources were added after first run). \nWhat are the systematic ways to reduce the pyinstaller's packaging time ? Is saving once generated Analysis.tc file and re-use it is safe enough ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":235,"Q_Id":63817191,"Users Score":0,"Answer":"First create a venv using python -m venv <env_name> it is especially required for pyinstaller projects that it doesn't bundle the addtional optional modules which you may not need but are installed on your system. This will reduce you file size along with the time required to bundle your app. This is an important step for your purpose.\nSecond create the spec file using the command pyi-makespec options name.py. Take a look at the specfile which is generated which will be named name.spec and ensure all required modules are added and unwanted modules are not included and save it.\nOnce you have your specfile as required, you can make your app as many times are required using the command pyinstaller options name.spec","Q_Score":1,"Tags":"python,pyinstaller","A_Id":63817405,"CreationDate":"2020-09-09T18:04:00.000","Title":"How can I reduce Pyinstaller build time of a Python project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"socketio.emit('text', 'text') not working inside dash callback where we write something back to the database.\nThese same emit is working inside other callbacks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":63817272,"Users Score":0,"Answer":"Flask socket io stalls when there are long polling processes. We need to emit before the start of such processes otherwise there is no impact of the emit statement. Just emitting before writing to the db fixed the issue.","Q_Score":0,"Tags":"python,flask,socket.io","A_Id":63817273,"CreationDate":"2020-09-09T18:10:00.000","Title":"Flask socketio not emitting event in dash callback","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just updated my python3 using homebrew and my python3 was messed up badly. I followed the instructions on other threads and was able to cleanly install python3 but some linking still exists that I am unable to figure out.\nProblem:\npython3 -version\ndyld: Library not loaded: \/usr\/local\/Cellar\/python\/3.6.5_1\/Frameworks\/Python.framework\/Versions\/3.6\/Python\nReferenced from: \/Users\/abcd\/.ansible\/py3\/bin\/python3\nReason: image not found\nzsh: abort      python3 -version\nPython paths:\nabcd@abcd-ltm Cellar % which python\n\/Users\/abcd\/.ansible\/py3\/bin\/python\nabcd@abcd-ltm Cellar % which python3\n\/Users\/abcd\/.ansible\/py3\/bin\/python3\necho $PATH:\n\/Users\/abcd\/.ansible:\/Users\/abcd\/.ansible\/py3\/bin:\/Users\/abcd\/.ansible\/bin:\/Users\/abcd\/bin:\/usr\/local\/bin:\/usr\/bin:\/bin:\/usr\/sbin:\/sbin:\/Users\/abcd\/.ansible:\/Library\/Apple\/usr\/bin\nI dont know from where it is still refering and getting this error at any python3 command\ndyld: Library not loaded: \/usr\/local\/Cellar\/python\/3.6.5_1\/Frameworks\/Python.framework\/Versions\/3.6\/Python\nI can confirm there is no folder named python inside \/usr\/local\/Cellar\/. There is one newly created python@3.8 though which should be correct. Any pointers how I can find where is it picking up the incorrect python path and how I can fix it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":159,"Q_Id":63817793,"Users Score":1,"Answer":"It appears you have an ansible installation that built a virtualenv associated with the Python that was upgraded in Homebrew. You should rebuild those virtualenvs or remove them from your PATH if you don't need them.","Q_Score":0,"Tags":"python,python-3.x,macos,homebrew","A_Id":63818009,"CreationDate":"2020-09-09T18:46:00.000","Title":"python3 issues after homebrew based upgrade","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a bit of a oddity going on I can't figure out why it's happening. I've installed the latest version of Python for Windows (3.8.5 64-bit), after removing the previous version, and the version which comes with Visual Studio as part of the Python development package in that IDE. Python installed fine, and also added the Environment variables which I activated in the installer. Now I opened the PowerShell to start the Python interpreter as I've done so often before, typed in python, and Windows 10 opened up the Windows store to suggest to install Python from the store... so, I made sure another time that Python installed the environment variables which it did.\nI uninstalled and re-installed Python several times then, also rebooting the computer a few times inbetween, to make sure it could read the changed environment variables. No luck. After browsing the net for some times, I came across a post here which suggested to start the interpreter via the \"py\" command. Et voil\u00e1, it works...\nDid they change something in one of the latest versions of Python in regards of the command to start the interpreter? I frankly have no idea what is going on here... starting it via \"python\" ALWAYS worked, with every former version of Python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":63818964,"Users Score":0,"Answer":"You said you uninstall your previous version of Python, but in your environment variables, are you sure you just have 1 link to python.exe ? Maybe you've got an other path that doesn't work and your command can't execute well.","Q_Score":0,"Tags":"python,powershell,path","A_Id":63819019,"CreationDate":"2020-09-09T20:16:00.000","Title":"Can't start the Python interpreter in PowerShell or Console anymore using \"python\", need to type \"py\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it correct to use a uuid as a sales order transaction? for example, in an ecommerce website when someones orders any product or products is it ok to use the uuid as a unique identifier for the order transaction?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":224,"Q_Id":63820233,"Users Score":1,"Answer":"Yes. It is universally unique, so you can use it as a unique ID for a transaction, or whatever you want to be able to identify maybe cross systems and for storage etc.\nYou can consider alternatives also - sometimes perhaps also just a sequence number works, if they all come from one place and in order, and it's useful to know the order. With UUIDs you don't have it, unless store the sequence somewhere of course.","Q_Score":0,"Tags":"python,django,e-commerce","A_Id":63820461,"CreationDate":"2020-09-09T22:12:00.000","Title":"Django Is it correct to use uuid for a sales transaction","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"After updating Spyder to 4.1.5 my script is covered with a whole bunch of taste-specific alerts like:\n\nCode analysis: \nE261 at least two spaces before inline comment (pycodestyle E261)\n\nor\n\nCode analysis: \nE266 too many leading '#' for block comment (pycodestyle E266)\n\nWhile many of the warnings improve my code, I would like to disable the ones that I disagree with (like for example the two listed above).\nHow can I do it?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":279,"Q_Id":63821188,"Users Score":2,"Answer":"OK, I have found it\nTools -> Preferences -> Completion and linting -> Code Style then mark the checkbox Enable code style linting and then list all the unwanted warnings, separate them with commas.","Q_Score":1,"Tags":"python,spyder,pycodestyle","A_Id":63909099,"CreationDate":"2020-09-10T00:21:00.000","Title":"Spyder 4.1.5 disable selected pycodestyle warnings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've installed matplotlib through pip, and it runs perfectly when I use it in PyCharm. However, when I run my Python file through cmd, I get the following error message:\n\nModuleNotFoundError: No module named 'matplotlib'\n\nI have installed other modules the same way, and those have no problems running in PyCharm or in cmd.\nMatplotlib is installed under:\n\nC:\\Users\\David\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\n\nSomething I noticed - perhaps the root of the problem - Is that Python seems to be installed in 2 places:\n\nC:\\Users\\David\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe\n\nThe path above is also the path to my Python Interpreter on PyCharm.\nand\n\nC: \\Users\\David\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe\n\n\nPython version 3.8.5\nWindows 10\n\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":63822177,"Users Score":0,"Answer":"try running the command pip install matplotlib in your cmd. It works for me.","Q_Score":0,"Tags":"python,matplotlib,cmd,pycharm","A_Id":63823096,"CreationDate":"2020-09-10T02:58:00.000","Title":"Matplotlib works in my IDE, but not through cmd?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using beautifulsoup it's easy to fetch URLs that follow a certain numeric order. However how do I fetch URL links when it's organized otherwise such as https:\/\/mongolia.mid.ru\/en_US\/novosti where it has articles like\nhttps:\/\/mongolia.mid.ru\/en_US\/novosti\/-\/asset_publisher\/hfCjAfLBKGW0\/content\/24-avgusta-sostoalas-vstreca-crezvycajnogo-i-polnomocnogo-posla-rossijskoj-federacii-v-mongolii-i-k-azizova-s-ministrom-energetiki-mongolii-n-tavinbeh?inheritRedirect=false&redirect=https%3A%2F%2Fmongolia.mid.ru%3A443%2Fen_US%2Fnovosti%3Fp_p_id%3D101_INSTANCE_hfCjAfLBKGW0%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1?\nWebsites such as these are weird because once you first open the link, you have \u00bb \u0411\u0443\u0441\u0430\u0434 \u043c\u044d\u0434\u044d\u044d  button to go to the next page of articles. But once you click there, now you have Previous or Next button which is so unorganized.\nHow do I fetch all the news articles from websites like these (https:\/\/mongolia.mid.ru\/en_US\/novosti or https:\/\/mongolia.mid.ru\/ru_RU\/)?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":22,"Q_Id":63822647,"Users Score":1,"Answer":"It seems that the \u00bb \u0411\u0443\u0441\u0430\u0434 \u043c\u044d\u0434\u044d\u044d  button from https:\/\/mongolia.mid.ru\/ru_RU\/ just redirects to https:\/\/mongolia.mid.ru\/en_US\/novosti. So why not start from the latter?\nTo scrape all the news just go page through page using the link from the Next button.\nIf you want it to be more programatic, just check the differences in the query parameters and you'll see that _101_INSTANCE_hfCjAfLBKGW0_cur is set to the actual page's number (starting from 1).","Q_Score":0,"Tags":"python-3.x,beautifulsoup,scrapy","A_Id":63823640,"CreationDate":"2020-09-10T04:01:00.000","Title":"How to fetch website links when they're not numerically ordered","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I installed pip3 using sudo apt-get install python3-pip after that when I run the following command to install django sudo pip3 install django I get this error:\n\nTraceback (most recent call last):\nFile \"\/usr\/bin\/pip3\", line 9, in \nfrom pip import main\nFile \"\/usr\/lib\/python3\/dist-packages\/pip\/init.py\", line 14, in \nfrom pip.utils import get_installed_distributions, get_prog\nFile \"\/usr\/lib\/python3\/dist-packages\/pip\/utils\/init.py\", line 23, in \nfrom pip.locations import (\nFile \"\/usr\/lib\/python3\/dist-packages\/pip\/locations.py\", line 9, in \nfrom distutils import sysconfig\nImportError: cannot import name 'sysconfig' from 'distutils' (\/usr\/lib\/python3.8\/distutils\/init.py)\n\nHow do I fix this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":25786,"Q_Id":63823964,"Users Score":70,"Answer":"I have tried recently manually installing python3.9 version in my Ubuntu from 3.6 version using apt install python3.9. Then pip3 was broken. The issue is because distutils were not build for the 3.9 version.\nSo in my case I ran apt install python3.9-distutils to resolve my issue.\nIn your case make sure to modify 3.x version in distutils command.","Q_Score":29,"Tags":"python,python-3.x,django,pip,python-3.8","A_Id":64771661,"CreationDate":"2020-09-10T06:31:00.000","Title":"ImportError: cannot import name 'sysconfig' from 'distutils' (\/usr\/lib\/python3.8\/distutils\/__init__.py)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"If i change one value of a column in csv file then whole column values are changed for example i have a column type int64 and i change one item from any integer to string then whole items types are changed to string by default when we read file like df = pandas.read_csv(filename). Actually i have to find item\/items in a df column who have different datatypes from others like if i have column type int64 and there is one value of datatype object or float64 types in that column then i have to fetch that value as well as the row number of that value.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":63827084,"Users Score":0,"Answer":"Column inside any data frame can only have one data type for all the cells of those columns. You can see it using:\ndf.describe() or df.info()","Q_Score":0,"Tags":"python,pandas,csv","A_Id":63827373,"CreationDate":"2020-09-10T09:48:00.000","Title":"Can a column in dataframe contains different datatypes items?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Based on input data, I have to generate the plots using python scripting and it was run successfully with plots displayed. Later, unfortunately, after conversion from .py to .exe file, the outputs plots are not generated when clicked on .exe file, What may be the problem with .exe? Does anyone face a similar issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":230,"Q_Id":63828017,"Users Score":0,"Answer":"it could be number of things,\ndependencies are not included with the .exe file,\nor your program reads from input files that are not in the same directory as the .exe file\nrun the .exe in the same directory as .py and see if the problem persists.","Q_Score":1,"Tags":"python-3.x,matplotlib","A_Id":63828170,"CreationDate":"2020-09-10T10:45:00.000","Title":"Converted from .py to .exe but output plots are not displayed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using a transfert-style based deep learning approach that use VGG (neural network). The latter works well with images of small size (512x512pixels), however it provides distorted results when input images are large (size > 1500px). The author of the approach suggested to divide the input large image to portions and perform style-transfert to portion1 and then to portion2 and finally concatenate the two portions to have a final large result image, because VGG was made for small images...  The problem with this approach is that the resulting image will have some inconsistent regions at the level of areas where the portions were \"glued\".\nHow can I correct these areas ?\nIs the an alternative approach to this dividing method ?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":809,"Q_Id":63829340,"Users Score":4,"Answer":"Welcome to SO, jeanluc. Great first question.\nWhen you say VGG, I expect you're referring to VGG-16. This architecture uses fully connected layers in the end which means you can only use it with images of a certain size. I believe the ImageNet default is 224x224 pixels.\nIf you want to use VGG-16 without modifications, you MUST use images of this size. However, many people remove the fully connected layers in the end (especially in the context of style transfer) in order to feed in any size they want.\nAny size? Well, you probably want to make sure that the images are multiples of 32 because VGG-16 comes with 5 MaxPooling operations that half the dimensions every time.\nBut just because the network can now digest images of any size doesn't mean the predictions will be meaningful. VGG-16 learned what 1000 different objects look like on a scale of 224px. Using a 1500px of a cat might not activate the cat related neurons. Is that a problem?\nIt depends on your use case. I wouldn't trust VGG-16 to classify these high resolution images in the context of ImageNet but that is not what you're after. You want to use a pretrained VGG-16 because it should have learned some abilities that may come in handy in the context of style transfer. And this is usually true no matter the size of your input. It's almost always preferred to start out with a pretrained model in comparison to starting from scratch. You probably want to think about finetuning this model for your task because A) style transfer is quite different from classification and B) you're using a completely different scale of images.\nI've never found this recommended patch based approach to help because of precisely the same problems you're experiencing. While CNN learn to recognize local pattern in an images, they will also learn global distributions which is why this doesn't work nicely. You can always try to merge patches using interpolation techniques but personally I wouldn't waste time on that.\nInstead just feed in the full image like you mentioned which should work after you removed the fully connected layers. The scale will be off but there's little you can do if you really want high resolution inputs. Finetune VGG-16 so it can learn to adapt to your use case at hand.\nIn case you don't want to finetune, I don't think there's anything else you can do. Use the transformation\/scale the network was trained on or accept less than optimal performance when you change the resolution.","Q_Score":5,"Tags":"python,deep-learning,vgg-net","A_Id":63832438,"CreationDate":"2020-09-10T12:06:00.000","Title":"Strategy to put and get large images in VGG neural networks","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Flask application that allows users to query a ~small database (2.4M rows) using SQL. It's similar to a HackerRank but more limited in scope. It's deployed on Heroku.\nI've noticed during testing that I can predictably hit an R14 error (memory quota exceeded) or R15 (memory quota greatly exceeded) by running large queries. The queries that typically cause this are outside what a normal user might do, such as SELECT * FROM some_huge_table. That said, I am concerned that these errors will become a regular occurrence for even small queries when 5, 10, 100 users are querying at the same time.\nI'm looking for some advice on how to manage memory quotas for this type of interactive site.  Here's what I've explored so far:\n\nChanging the # of gunicorn workers. This has had some effect but I still hit R14 and R15 errors consistently.\nForced limits on user queries, based on either text or the EXPLAIN output. This does work to reduce memory usage, but I'm afraid it won't scale to even a very modest # of users.\nMoving to a higher Heroku tier. The plan I use currently provides ~512MB RAM. The largest plan is around 14GB. Again, this would help but won't even moderately scale, to say nothing of the associated costs.\nReducing the size of the database significantly. I would like to avoid this if possible. Doing the napkin math on a table with 1.9M rows going to 10k or 50k, the application would have greatly reduced memory needs and will scale better, but will still have some moderate max usage limit.\n\nAs you can see, I'm a novice at best when it comes to memory management. I'm looking for some strategies\/ideas on how to solve this general problem, and if it's the case that I need to either drastically cut the data size or throw tons of $ at this, that's OK too.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":176,"Q_Id":63829513,"Users Score":1,"Answer":"Coming from my personal experience, I see two approaches:\n1. plan for it\nComing from your example, this means you try to calculate the maximum memory that the request would use, multiply it by the number of gunicorn workers, and use dynos big enough.\nWith a different example this could be valid, I don't think it is for you.\n2. reduce memory usage, solution 1\nThe fact that too much application memory is used makes me think that likely in your code you are loading the whole result-set into memory (probably even multiple times in multiple formats) before returning it to the client.\nIn the end, your application is only getting the data from the database and converting it to some output format (JSON\/CSV?).\nWhat you are probably searching for is streaming responses.\nYour Flask-view will work on a record-by-record base. It will read a single record, convert it to your output format, and return a single record.\nBoth your database client library and Flask will support this (on most databases it is called cursors \/ iterators).\n2. reduce memory usage, solution 2\nother services often go for simple pagination or limiting resultsets to manage server-side memory.\nsecurity sidenote\nit sounds like the users can actually define the SQL statement in their API requests. This is a security and application risk. Apart from doing INSERT, UPDATE, or DELETE statements, the user could create a SQL statement that will not only blow your application memory, but also break your database.","Q_Score":0,"Tags":"python,postgresql,heroku,memory,ram","A_Id":63841715,"CreationDate":"2020-09-10T12:17:00.000","Title":"Managing Heroku RAM for Unique Application","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We all know that lists in Python are reference types i.e a variable holding a list doesn't hold the list directly, but rather holds a reference to it.\nAnd we all know even the fact that everything in Python is an object.\nSo the question that comes in my mind is that integers are also objects in Python and so variables holding integers would also contain references to the integers; then why are only lists classified as reference types?\nAren't integers in Python also reference types following from the fact that everything is an object in Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":402,"Q_Id":63830852,"Users Score":1,"Answer":"These concepts don't really apply in Python. In my experience \"reference type\" and \"value type\" are mostly used in .NET languages such as C#, where they have specific meanings - variables of a reference type store a reference to an object, while variables of a value type store the value of the object directly. You can't obtain a reference to that object stored in the variable (although you may be able to create a \"boxed\" copy of that value and obtain references to the box). The terms may be used by analogy in other languages - but for example in Java all classes would be what .NET considers \"reference types\" and only primitives behave as \"value types\" do in .NET, so there the terms aren't really as necessary. So let's return to Python.\nIf we use the .NET meaning, then yes, all Python types are effectively \"reference\" types, in that every variable is a reference* to an object and doing a = b will make a refer to the same object as b. However, the thing about \"reference types\" and \"value types\" is that when an object is immutable it no longer really matters whether it's of a reference type or a value type. You can't do the one big thing where the distinction matters - you can't have two references to the same object, modify the object through one of them and then be surprised when the other changes!\nThis is a long-winded way to say that when people call integers \"value types\" in Python they are probably thinking about them in terms of C# or maybe Java, and observing that they behave much the same as value types do in C# or primitives do in Java, because they do! But that's really because they're immutable more than anything else.\n\n* Here I'm using \"reference\" in a more general sense than the specific one found in C#. The general sense is of some kind of handle, address or identifier that specifies a particular object, such that we can have many of these \"references\" to a single object. Both \"reference\" and \"pointer\" are general terms that may have more specific meanings in certain languages. For example a C# reference is a very similar concept to a Java reference, but rather different from a C++ reference. In some languages a \"pointer\" is specifically a numeric memory address that you can manipulate with arithmetic, in other languages it is indistinguishable from the general sense I described for \"reference\". I find the term \"reference\" to be the most neutral and most useful to describe what we have in Python, but be careful with all these terms when comparing one language to another.","Q_Score":0,"Tags":"python,types,reference,integer","A_Id":63831405,"CreationDate":"2020-09-10T13:34:00.000","Title":"Are Python integers reference types?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have my Django application running with python manage.py runserver 0.0.0.0:8000\nIt is accessible within same network in every device with <your LAN ipv4 address>:8000\nHowever. I want to access this outside my network with <your public address>:8000\nWhat is the way to do this?\n\nDjango app is running on windows 10.\nI have already written ALLOWED HOSTS : [\"*\"]\n\nMaybe there's some issue with DNS or firewall.\n0.0.0.0 should let me access with  <your public address>:8000 but it is not giving access.\nPlease help..","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":452,"Q_Id":63834783,"Users Score":0,"Answer":"I have resolved my issue. Everything was good, i just allowed incoming connection on port 8000 in AWS ec2 console. Now it's working. Thank you.\n\nNow i can access it with <your public address>:8000","Q_Score":2,"Tags":"python,django,server,localhost,ip","A_Id":63893485,"CreationDate":"2020-09-10T17:25:00.000","Title":"How to access django server from different network?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python dataframe with a column populated with strings of the same length like 0302000C0AABGBG , 0407020B0AAAGAG, 040702040BGAAAC\nI want to filter to identify all values that contain 'AA' but it must be at position _________AA ____ i.e. do not include 040702040BGAAAC in results.\nHow do I achieve that?\nCurrent searches yield str.contains but I can't find how to specify the position of the substring.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":63835528,"Users Score":0,"Answer":"Append to your regex \\w{4}$ (requiring that four word characters occur at end of line) in str.contains call","Q_Score":0,"Tags":"python,pandas,string","A_Id":63835560,"CreationDate":"2020-09-10T18:18:00.000","Title":"Filter a list of strings but the filter must appear at a certain place","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"as I use the holoviews library in conjunction with the bokeh backend, I would like to create a 3D surface plot, too. In the documentation I only found matplotlib and plotly backends.\nCan somebody share a code snippet how to use holoviews\/bokeh for 3D surface plots?\nThank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":412,"Q_Id":63837347,"Users Score":0,"Answer":"Bokeh is a 2d plotting library, there is no built-in support for 3d plots. It's possible to wrap third-party 3d JS plotting tools as Bokeh custom extensions, but AFAIK Holoviews has not done this.","Q_Score":0,"Tags":"python,3d,bokeh,surface,holoviews","A_Id":63837495,"CreationDate":"2020-09-10T20:36:00.000","Title":"3d surface plot with holoviews and \"bokeh\"","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been looking through examples of AuthnRequest messages and have yet to determine where the user and password data that I want to authenticate (with my installed, configured and tested SimpleSAMLphp IDP) is located in the actual request.\nI'm building a python-based SP which I want to talk to the IDP.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":52,"Q_Id":63837480,"Users Score":2,"Answer":"The password is never in the authn request. It's possible to include the user name but not all identity provider support receiving the user name. The password is only input at the identity provider site.","Q_Score":0,"Tags":"python,saml,simplesamlphp","A_Id":63838959,"CreationDate":"2020-09-10T20:47:00.000","Title":"In SAML, when an user\/password pair is to be authenticated, where is the user\/passwd pair located in an AuthnRequest?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"With PRAW, I know you can do\nsubs = reddit.subreddit(\"Pics+Funny\")\nto get the streams of both r\/Pics and r\/Funny, and I know you can do this\nuser = reddit.redditor(\"spez\")\nto get one user, but is there a way to get multiple users at once? Like so:\nusers = reddit.redditor(\"spez+kn0wthing\")?\nI'm trying to read the comments of a large group of users, and I would like to know if something like this is possible. When I tried what I put right above this, it returned a 404 error. Could anyone help me out?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":422,"Q_Id":63837953,"Users Score":0,"Answer":"I don't believe there's a built-in way to do this. Either you'll need to loop through the users one at a time or create separate threads and merge the data.","Q_Score":1,"Tags":"python,reddit,praw","A_Id":63853475,"CreationDate":"2020-09-10T21:31:00.000","Title":"In PRAW, is there a way to get the comment streams for multiple users?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a program which merges data from several sources into a spreadsheet. If the data for a cell is different from different sources, a human needs to choose the best one, so I want it to be obvious which cells need to be reviewed.\nNot displaying the arrow when the data for the Combobox.set() has 0 or one item seems a good way, but I don't understand ttk styles and layouts well enough to do it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":63838221,"Users Score":0,"Answer":"I found a way to get the effect I want. I create both a Label and a Combobox at the same location and use .lift() to put the one I want on top.","Q_Score":1,"Tags":"python,tkinter,ttk","A_Id":63947807,"CreationDate":"2020-09-10T21:59:00.000","Title":"How to create a custom tkinter Combobox with no arrow if there are 0 or 1 items?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"1\/2 is actually 0 as expected in both languages since it's integer division.\nOne would expect the result to be 0 for -1\/2 too. But it's -1!\nIn other languages like Java, Scala or C++ it's 0 as it should be.\nWhat happens in Ruby and Python and why?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":63839029,"Users Score":4,"Answer":"This is to preserve the identity that (x \/ y) * y + (x % y) == x for all integers x and y != 0; this is what it means for x % y to be the remainder when x is divided by y.\nIn Java, integer division rounds towards zero, but this means the remainder operator % can give negative results, and this is inconvenient for most purposes. For example, the expression arr[i % arr.length] doesn't guarantee a valid array index when i is negative.\nIn Python, if y is positive then x % y always gives a non-negative result (in the range from 0 to y - 1 inclusive), so to preserve the \"remainder\" property, integer division has to always round down, not necessarily towards zero.","Q_Score":0,"Tags":"python,ruby,integer-division","A_Id":63839088,"CreationDate":"2020-09-10T23:49:00.000","Title":"Why is -1 \/ 2 == -1 in Ruby and Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a datetime variable date_var=datetime(2020,09,11,0,0,0 ) and i am trying to populate a dataframe column for each row with this value. So i did something like df['Time']=date_var first this show 'Time' field datatype as datetime64 [ns] and not datetime and this populates Time field with value 2020-09-11 instead of 2020-09-11 00:00:00. Am i doing something incorrect ?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":357,"Q_Id":63846064,"Users Score":1,"Answer":"You've done nothing wrong.  The fact that it prints as the date without time is just a convention in Pandas for simpler output.  You can use df['Time'].dt.strftime('%F %T') if you want the column printed with the time part as well.\nStoring datetimes as the Pandas type (datetime64[ns]) is better than storing them as the Python type, because it is more efficient to manipulate (e.g. to add offsets to all of them).","Q_Score":0,"Tags":"python,pandas,dataframe,datetime","A_Id":63846217,"CreationDate":"2020-09-11T11:20:00.000","Title":"Assigning datetime variable to a pandas dataframe column","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using in one of my views request.data instead of serialzer to get json data and work on it, my question is this ok or lets say \"a good practice\" to use request.data or should i create serializer class for that view?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":63846383,"Users Score":0,"Answer":"The reason to use a serializer in the first place is to transform native python data types to valid JSON and vice-versa. Consequently, the serializer adds a layer of validation to make sure that this transformation process runs correctly in accordance with your serializer definition.\nIf you decide to omit the serializer in the views, you would have to handle data validation there yourself and you end up implementing a feature which already exists in practice and has been \"battle-tested\" and worked on by multiple accomplished developers. There are cases where you don't strictly need a serializer in your views, for example when you simply display data from another source and only allow GET requests, but whenever you deal with data input I would consider it bad practice to not use serializers.","Q_Score":0,"Tags":"python,django,django-rest-framework,python-requests","A_Id":63846728,"CreationDate":"2020-09-11T11:41:00.000","Title":"using request.data instead of serializer class in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Hello i want to make a chat between two different computer.\nComputer Number 1 is server and connected to the Wi-Fi Number 1.\nComputer Number 2 is client and connected to the Wi-Fi Number 2.\nBut my problems is: Computer Number 2 can't connect to the Computer Number 1 it actually for that the Computer Number 2 can't find the server IP.\nWhat should i do?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":63848326,"Users Score":0,"Answer":"You could use the broadcast adress to send first message to the server. Then the server would respond to client and establish a connection.","Q_Score":1,"Tags":"python,server,connection,client,chat","A_Id":63863406,"CreationDate":"2020-09-11T13:43:00.000","Title":"make a chat between computer with socket in the Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to make my python file open on the \"Windows Terminal\" program instead of the python application that is opened by default. Is there a way to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":166,"Q_Id":63848471,"Users Score":0,"Answer":"use the windows start command ie:\nc:>start python","Q_Score":0,"Tags":"python,windows,terminal,windows-terminal","A_Id":63848533,"CreationDate":"2020-09-11T13:53:00.000","Title":"Make a python file run on the new \"windows terminal\" by default (Windows)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to install a library that only works on python 3.7 but i also have python 3.8. I can do between 2.x and 3.x but not between 3.x verisons. Any help is appriciated thank you!","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":31,"Q_Id":63849083,"Users Score":-2,"Answer":"pip install SomePackage\nEg.\npip install numpy\npip install flask","Q_Score":0,"Tags":"python-3.x,python-2.7,pip","A_Id":63849139,"CreationDate":"2020-09-11T14:30:00.000","Title":"How to install modules for different python version of 3.x windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been moving my flask apps from replit to my server, and things have been going smoothly, but I am moving my first app with SQL in it over to the server, and there keeps being errors when I open the database in the code. In the Apache error log, it says:\nsqlite3.OperationalError: unable to open database file\nThe app works well on replit, the database is in the same folder, but it doesn't work. Does anybody know why? I am using Ubuntu Server 20.04","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":185,"Q_Id":63849759,"Users Score":0,"Answer":"I have figured out why it's not working! The database was in the same dir as init.py, but wsgi calls it as a module in a different dir, so it wasn't calling the db. Adding an absolute path eg. \/var\/www\/theapp\/theapp\/database.db works.","Q_Score":0,"Tags":"python,sql,apache,flask,ubuntu-server","A_Id":63870957,"CreationDate":"2020-09-11T15:10:00.000","Title":"Flask not opening SQLite Database on apache2","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Recently i came across a requirement where i tried to change python re with pyspark regexp_extract, the reason behind change re to pyspark regexp_extract is spark is more faster. by comparing the process speed with pyspark  and re process I concluded like re is faster than pyspark regexp_extract. Is there any specific reason that cause pyspark regexp_extract is slow.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":239,"Q_Id":63850472,"Users Score":0,"Answer":"Probably more context is needed to give an specific answer, but what I can infer from what you said is the following:\nI would think that it depends on the size of the data and how are the partitions in spark. As spark is parallelizing, probably in not huge amounts of data, regular python functions will work faster, but not in huge amounts of data were parallelization is more handy.","Q_Score":0,"Tags":"python-3.x,pyspark,apache-spark-sql,python-re","A_Id":63850526,"CreationDate":"2020-09-11T15:57:00.000","Title":"Why spark regexp_extract too slow when we compare with python re","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to both Python and Django. I am following a tutorial where the teacher is using Jinja in Visual Studio. I tried to download it from plug-ins in PyCharm, but there is nothing called Jinja.\nIs there any way I can use Jinja in PyCharm? Is there any alternative?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":859,"Q_Id":63856121,"Users Score":1,"Answer":"Just to be clear, the free version of Pycharm does actually execute Flask apps with Jinja templates and such. It's just that it can't do Jinja syntax highlighting.\nLike, you'll see all your Jinja text as if it was plain HTML text when you're editing it, but then it will run it as Jinja anyways (I've used Jinja stuff such as block, extends, include, the default filter, loop.index... everything fine).","Q_Score":2,"Tags":"python,django,pycharm,jinja2","A_Id":69333091,"CreationDate":"2020-09-12T01:47:00.000","Title":"Jinja2 for PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm building a text analysis program that extract dates from a text document. The dates are in several formats so I have written several extract lines like below.\ndf_new_1 = dfnew['text'].str.extract(r'(?P\\d{1,2})\/-\/-')\ndf_new_7 = dfnew['text'].str.extract(r'(?P\\d{1,2})\/-')\ndf_new_8 = dfnew['text'].str.extract(r'(?P\\d{4})')\nWhen running these lines in PyCharm, they work as expected. But, when running these in Jupyter Notebook, the last line (df_new_8) doesn't show the Grouped Name.\nOutput PyCharm of df_new_8.tail():\nYear\n495  1979\n496  2006\n497  2008\n498  2005\n499  1980\nOutput Jupyter Notebook of df_new_8.tail() No column title!!:\nOut[1]\n495    1979\n496    2006\n497    2008\n498    2005\n499    1980\nName: Year, dtype: object\nTo illustrate, when running df_new_1.head() in Jupyter it outputs (as expected):\nOut[3]\nMonth   Day Year\n0   03  25  93\n1   6   18  85\n2   7   8   71\n3   9   27  75\n4   2   6   96\nAt the end of the program I 'concatenate' all df_new* dataframes together using fillna.\ndf_out = df_new_1.fillna(df_new_2).fillna(df_new_3).fillna(df_new_4).fillna(df_new_5).fillna(df_new_6).fillna(df_new_7).fillna(df_new_8).fillna(1)\nThat's when the real problem appears in Jupyter Notebook. Obviously df_new_8 wasn't processed, probably because of the missing Named Group. Again, this works fine in PyCharm. So, instinctly I say there's a problem with the line:\ndf_new_8 = dfnew['text'].str.extract(r'(?P\\d{4})')\nCan't figure out what though.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":63858716,"Users Score":0,"Answer":"Turns out that Pycharm returns df_new_8 = dfnew['text'].str.extract(r'(?P\\d{4})') as a DataFrame, where Jupyter notebook returns it as a Series.","Q_Score":0,"Tags":"python,jupyter-notebook,regex-group","A_Id":63858908,"CreationDate":"2020-09-12T09:12:00.000","Title":"Jupyter Notebook Named Groups issue on extract() function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"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":"My data set has datetime data, I want to iterate over each day and run some function on one of the attributes for each day.\nHow do i iterate over each day in datetime series?\nSo, I am iterating using groupby(Date)\nIndex    Date         Time\n1       2-12-2018     13:22:27 \\n\nI need a way to tell if the time is between 12am to 6 am or other time intervals.\nTime is an object here. I am new to python and pandas\nThanks,","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":63863409,"Users Score":0,"Answer":"I used,\nset_index('DateTime').between_time('00:00', '06:00', include_end=False).reset_index()\nto further classify my dataframe into required data frame.","Q_Score":0,"Tags":"python,pandas,datetime","A_Id":63892119,"CreationDate":"2020-09-12T18:06:00.000","Title":"Python pandas datetime attribute extraction","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a game in python turtle. I have a function which spawns an extra turtle but I also want it to disappear after some time, but I can find a way to fully delete it.\ni have tried blanking the variable and using del but it doesn't work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":960,"Q_Id":63866474,"Users Score":0,"Answer":"Python turtles are global entities that are never reclaimed while the turtle screen is active.  To disable a turtle, simply use hideturtle().  My recommendation, if you're creating turtles dynamically, is to add disabled (hidden) turtles to a list of turtles to reuse when you need one -- you can reset() a turtle.  Only create a new turtle if that list is empty.","Q_Score":0,"Tags":"python,python-turtle","A_Id":63866820,"CreationDate":"2020-09-13T01:57:00.000","Title":"How to remove a python turtle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way in vscode to find files that use with a particular variable name ?  for ex: say all python files that use a variable named source_string .  Not sure if this could be a simple vscode setting or maybe a python code itself. Any help would be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":959,"Q_Id":63867117,"Users Score":0,"Answer":"Click the magnifying glass on the upper left or press Control + Shift + F all at the same time. Then enter your search term and it will list all matches throughout the solution.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":63867211,"CreationDate":"2020-09-13T04:20:00.000","Title":"Searching a variable name or code snippet in all vscode files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"With arbitrary string s, s[::-1] inverts the string and is equivalent to s[-1:-len(s)-1:-1].\nFor example: with s = \"abc\" , s[::-1] and s[-1:-len(s)-1:-1] produce \"cba\".\nI am wondering if anyone can explain the stop position of the latter expression  -len(s)-1. I found nothing in the Python docs which elaborate on string slicing stop position syntax besides provided integer values and colons as default s[len(s)].","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":84,"Q_Id":63867260,"Users Score":1,"Answer":"Negative indices are essentially operating on principles of modular arithmetic.\nThey wrap around to the end of the list. So s[-1] is the last character in the string, s[-2] is the second-to-last character in the string, ... all the way to s[-len(s)] is therefore the first character in the string.\nBecause we want to include the first character and slices don't include the \"upper\" bound, we use -len(s)-1 as the stopping point for the reversal. That is, the slice starts at -1 and increments by a further -1 each time, with the last index it includes being -len(s) which corresponds to the first character of the string.","Q_Score":0,"Tags":"python,string,slice","A_Id":63867290,"CreationDate":"2020-09-13T04:46:00.000","Title":"Python String Slicing: What is the semantic logic of the expression s[-1:-len(s)-1:-1] with arbitrary string s?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install TensorFlow via pip in the command line. I have satisfied all the requirements but all I get when executing pip install tensorflow is\nERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)\nERROR: No matching distribution found for tensorflow\nI also tried to install manylinux2010 but I get the same output. I'm running Windows 10 on a laptop with Python v. 3.8.5 installed. Pip version is 20.2.3 If you could help me that'd be great. Thanks!","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":647,"Q_Id":63867489,"Users Score":0,"Answer":"Tensorflow as of Aug-13-2018 supports, Python 3.6.x, and only the 64 bit version.","Q_Score":2,"Tags":"python,tensorflow","A_Id":63867517,"CreationDate":"2020-09-13T05:28:00.000","Title":"Can't Install TensorFlow Via Pip","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use Lasso regression in order learn a coefficient matrix, B. The problem I'm trying to solve is:\n\nmin{||y-xB|| +lambda{P X B}_1}\n\nWhere P is some penalty matrix: P_ij gives B_ij penalty p (the bigger P_ij the smaller B_ij)\nHow can I do this using python (didn't find anything useful in sklearn)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":63868994,"Users Score":0,"Answer":"Your problem is very specific, people usually don't train models like this, that's why there's nothing like that in sklearn. It's even incorrect to call lasso regression, but that's a question of terminology. But you can actually write the subdifferential of this loss and write subgradient descent yourself in python.","Q_Score":0,"Tags":"python,machine-learning,regression,lasso-regression","A_Id":63872979,"CreationDate":"2020-09-13T09:05:00.000","Title":"Lasso regression in python with differential penalties","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm testing an algorithm on a model of a robot on gazebo, for an experiment i need to perform some blind trials so i need to control a robot without seen it and after a timeout make it visible again via code in real time. i'm coding with python and ros.\nis it possible ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":261,"Q_Id":63871815,"Users Score":1,"Answer":"I suppose that you mean you need your robot invisible to some vision-related algorithms running at the same time.\nThen I'm afraid once a model is \"spawned\" into the gazebo world, some feature like transparency can not be changed.\nSo in my opinion, when you need to change the visibility, maybe you can store the latest states of your robot, like position\\velocity etc, remove the invisible model, and then spawn a new visible model in the same states.\nJust a quick thought.","Q_Score":2,"Tags":"python,simulation,ros,gazebo-simu","A_Id":63878838,"CreationDate":"2020-09-13T14:17:00.000","Title":"Is it possible to make a model in gazebo invisible via ros\/python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Currently making a Discord bot, and the function to send messages has to be \"await\"ed, and i wanted to bind it to a keyboard shortcut, how would i go about doing that.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":63873666,"Users Score":0,"Answer":"This is not possible in the way you would expect it, bc the discord api is not able to view your keystrokes.\nHowever, you can make a Discord api even trigger when another \"software\" detects your keystroke. however the script would have to run in the background whenever you want to use the shortcut.\nI suggest using Pynput to detect \/ simulate keystrokes.","Q_Score":1,"Tags":"python,discord","A_Id":64515197,"CreationDate":"2020-09-13T17:31:00.000","Title":"How would I create a keyboard shortcut that runs an async function in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"When I read in a file (whether it'd be in .csv or .txt format) I tend to use the pandas.read_csv() method to read them. I was wondering if there is any difference with using this method and using with open(file). And if so, is there any advantages using one over another?\nAny insights on this will be greatful. :)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":63876479,"Users Score":0,"Answer":"If you are going use pandas methods, then you need to read it in as a pandas dataframe.\nOtherwise, you can read in data with open(file) if you are not using pandas methods.\nAdvantages to doing this would be case specific, but for example one advantage could be that you don't need to use an additional library. For example, if you were to later automate a python script by building an executable that runs daily, you could avoid using pandas and build an executable file that is much smaller, since the pandas library uses a lot of space for building executables.","Q_Score":0,"Tags":"python,pandas","A_Id":63876523,"CreationDate":"2020-09-13T23:29:00.000","Title":"Reading in data into jupyter notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I read in a file (whether it'd be in .csv or .txt format) I tend to use the pandas.read_csv() method to read them. I was wondering if there is any difference with using this method and using with open(file). And if so, is there any advantages using one over another?\nAny insights on this will be greatful. :)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":63876479,"Users Score":0,"Answer":"The advantage of using pandas, is that you have to write minimal\ncode, but also you probably load alot of stuff that you dont need.\n\nThe advantage of using open() is that you have more control, and\nyou program is gonna be significantly more minimalistic","Q_Score":0,"Tags":"python,pandas","A_Id":63876514,"CreationDate":"2020-09-13T23:29:00.000","Title":"Reading in data into jupyter notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on automating commands for a Docker container with a Python script on the host machine. This Python script for now, builds and runs a docker-compose file, with the commands for the containers written into the docker-compose file and the Dockerfile itself.\nWhat I want to do is have the Python script action all commands to run within the container, so if I have different scripts I want to run, I am not changing the container. I have tried 2 ways.\nFirst was to run os.system() command within the Python script, however, this works only as far as opening the shell for the container, the os.system() command does not execute code in the Docker container itself.\nThe second way uses CMD within the Dockerfile, however, this is limited and is hard coded to the container. If I have multiple scripts I have to change the Dockerfile, I don't want this. What I want is to build a default container with all services running, then run Python scripts on the host to run a sequence of commands on the container.\nI am fairly new to Docker and think there must be something I am overlooking to run scripted commands on the container. One possible solution I have come across is nsenter. Is this a reliable solve and how does it work?  Or is there a much simpler way? I have also used docker-volume to copy the python files into the container to be run on build, however, I can still not find a solve to automate the accessing and running these python scripts from the host machine.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4651,"Q_Id":63877747,"Users Score":1,"Answer":"If the scripts need to be copied into a running container, you can do this via the docker cp command.  e.g. docker cp myscript.sh mycontiainer:\/working\/dir.\nOnce the scripts are in the container, you can run them via a docker exec command.  e.g docker exec -it mycontainer \/working\/dir\/myscript.sh.\nNote, this isn't a common practice. Typically the script(s) you need would be built (not copied) into container image(s).  Then when you want to execute the script(s), within a container, you would run the container via a docker run command.  e.g. docker run -it mycontainerimage \/working\/dir\/myscript.sh","Q_Score":0,"Tags":"python-3.x,docker,docker-compose,nsenter","A_Id":63879306,"CreationDate":"2020-09-14T03:34:00.000","Title":"Python Script to run commands in a Docker container","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"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":"CMD:\nC:>pip list\nPackage        Version\n\nbeautifulsoup4 4.0.0b4\nimgkit         1.0.2\npip            19.2.3\nsetuptools     41.2.0\nwheel          0.34.2\nBut how can I use this packages like imgkit and beautifulsoup4 in Pycharm?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":95,"Q_Id":63879392,"Users Score":1,"Answer":"You can write the command \"pip install <PACKAGE_NAME>\" in the command line or just import it and Pycharm will ask you if you like to install this package.\nMake sure that the python interpreter of your Pycharm project is the same running on your command line, if not it will not sync its kind of a headache, from experience.","Q_Score":0,"Tags":"python,pycharm","A_Id":63879456,"CreationDate":"2020-09-14T06:53:00.000","Title":"How can I use installed python packages in Pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm exporting data from MySQL to an CSV file in python .while i'm trying to open the file in notepad the format of the text is getting changed.\nsample:\nIn CSV :  \"Hi, Thanks for downloading the application\"\nIn Notepad : \"\"\" Hi, Thanks for downloading the application \"\"\"\nif i have Double quotes in the string i'm getting like this :\nIn CSV:  \"Hi \"User\", Thanks for downloading the application\"\nIn Notepad : \"\"\" Hi \"\"User\"\", Thanks for downloading the application \"\"\"\ncan anyone help me out with the solution.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":63880898,"Users Score":0,"Answer":"In every programming language the strings with multiple quotes is kind of a problem.\nTo treat this as single string you can use different the inside quotes.\nex:  \"Hi 'User', Thanks for downloading the application\" or escape them with backslash .\nex: \"Hi \\\"User\\\", Thanks for downloading the application\"\nIf it's important to repeat often that process (\"exporting data from MySQL to an CSV file in python\") you need to address your code to fix that.\nIf you want just to do some operations on notepad, then I suggest you copy and paste the file. In the copy find\/replace \"\"\" with \"\" and \"\" with \". Make sure to match case exactly.\nLet me know if it helps.\nPS> I believe there are options, to wrap or not the cells in \"\".","Q_Score":0,"Tags":"mysql,python-3.x,excel,notepad","A_Id":63883062,"CreationDate":"2020-09-14T08:40:00.000","Title":"Format changing when opening excel file in Notepad","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Okay, so pardon me if I don't make much sense. I face this 'ObjectId' object is not iterable whenever I run the collections.find() functions. Going through the answers here, I'm not sure where to start. I'm new to programming, please bear with me.\nEvery time I hit the route which is supposed to fetch me data from Mongodb, I getValueError: [TypeError(\"'ObjectId' object is not iterable\"), TypeError('vars() argument must have __dict__ attribute')].\nHelp","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":8873,"Q_Id":63881516,"Users Score":6,"Answer":"I was having a similar problem to this myself. Not having seen your code I am guessing the traceback similarly traces the error to FastAPI\/Starlette not being able to process the \"_id\" field - what you will therefore need to do is change the \"_id\" field in the results from an ObjectId to a string type and rename the field to \"id\" (without the underscore) on return to avoid incurring issues with Pydantic.","Q_Score":10,"Tags":"python,mongodb,api,objectid","A_Id":65433351,"CreationDate":"2020-09-14T09:21:00.000","Title":"\"ObjectId' object is not iterable\" error, while fetching data from MongoDB Atlas","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Okay, so pardon me if I don't make much sense. I face this 'ObjectId' object is not iterable whenever I run the collections.find() functions. Going through the answers here, I'm not sure where to start. I'm new to programming, please bear with me.\nEvery time I hit the route which is supposed to fetch me data from Mongodb, I getValueError: [TypeError(\"'ObjectId' object is not iterable\"), TypeError('vars() argument must have __dict__ attribute')].\nHelp","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":8873,"Q_Id":63881516,"Users Score":1,"Answer":"use db.collection.find(ObjectId:\"12348901384918\")\nhere db.collection is database name and use double quotes for the string .","Q_Score":10,"Tags":"python,mongodb,api,objectid","A_Id":63881583,"CreationDate":"2020-09-14T09:21:00.000","Title":"\"ObjectId' object is not iterable\" error, while fetching data from MongoDB Atlas","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"%reload_ext sql\n%sql sqlite:\/\/\nThe second line can't be compiled and the report says: UsageError: Line magic function %sql not found. With Python3.8, jupyter notebook.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":8115,"Q_Id":63882681,"Users Score":1,"Answer":"The issue was solved for me using conda to install \"ipython-sql\", NOT using PIP.\nconda install -c conda-forge ipython-sql","Q_Score":6,"Tags":"python,sqlite","A_Id":70186725,"CreationDate":"2020-09-14T10:40:00.000","Title":"UsageError: Line magic function `%sql` not found","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a controller with an SQLFORM.grid that shows only what the user submitted.\nI have two tables: one for teachers(users) and another for students. The teachers submit the student's info. How can I use the grid to show the students submitted per user?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":63882828,"Users Score":0,"Answer":"use smart grid i.e SQLFORM.smartgrid() instead of normal grid and for teacher table add data filed students as list:string so that you can add multiple student names who submitted to a teacher id.","Q_Score":1,"Tags":"python,web2py","A_Id":64620715,"CreationDate":"2020-09-14T10:51:00.000","Title":"Web2py SmartGrid display data per user","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm getting False when I try to check if 7 is there in the dictionary:\n\n\n\nspam = {'name': 'Zophie', 'age': 7}\n'age' in spam\nTrue\n'name' in spam\nTrue\n7 in spam\nFalse\n\n\n\nCan anybody advise what's wrong with code as it worked for other keys and values?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13,"Q_Id":63884018,"Users Score":0,"Answer":"As you have noticed,  the in checks only in the keys. Do 'Zophie' in spam.values() or\n7 in spam.values().","Q_Score":0,"Tags":"dictionary,python-3.7","A_Id":63884205,"CreationDate":"2020-09-14T12:08:00.000","Title":"Unable to verify dictionary integer value using 'in' operator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 tables - customers and purchases\nI've used faker to create 100 entries for the customer table with various details of which one is customer_numbers that are unique 5 digits.\nI now want to create a table of 100 purchases that reuses the list of customer_numbers but to ensure that there is at least 25% duplicate records.\nI am not sure the best way to do this to ensure the 25% requirement.\nI initially created a custom function that resamples my original list (using faker.random_elements()) and just takes the first 100 records in the new list but that doesn't ensure a minimum of 25% overlap.\nIs there a built in function I can use? If not, what would be the math behind recreating a list with 25% overlaps from an existing list.\nCode seems less relevant here but let me know if you need samples.\nSolution I went with(not the only one to the problem):\n\nCalculated the number of samples to drop list_size-(list-size\/(1*repeat rate))\nDropped the no of samples from the customer list and resampled from the reduced list the number of samples I dropped (with replacement)\nMerged the shortened and resampled list\n\nThis solution ensures that len(original list) = len(set((new list)))*1.25","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":121,"Q_Id":63885052,"Users Score":0,"Answer":"A solution I can think of is as follows:\n\nRandomly selecting a number for your 'guarantee' overlapping between 25 and 100\nRandomly picking the 'guarantee' number of records from the existing list\nRandomly picking the rest of the required records (without considering the existence of the existing list)\n\nThis is because your customer_numbers consist of 5 digits, therefore picking these 5 digits randomly for 100 times will generally not create any duplicates with the existing list which has only 100 items. So I think using a way to 'guarantee' the overlapping percentage would work reasonably well. Also, I think it would not be difficult to implement the above steps in Python.","Q_Score":0,"Tags":"python,faker","A_Id":63888018,"CreationDate":"2020-09-14T13:11:00.000","Title":"Creating sample data (with faker) that has a % overlap in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have tried importing pandas from local pkg , which has 1.1.12 version ,\nBut I have another path where it has lower version 1.0.1 ,\nWhen i import pandas in python script , as a default it is picking up 1.1.12 version which i do't want to happen. I have tried removing that path from sys.remove.path('.local\/lib\/python3.7\/site-packages\/') as first line in my code , still it is picking the same one than 1.0.1 ?\nany suggesting to only import modules\/pkgs other than .local ones ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":63887489,"Users Score":0,"Answer":"To fix this why not try to do this in a virtual enviorment? as it will be forced to take your specific file only\nHope it helped! :D","Q_Score":0,"Tags":"python,python-3.x,pandas,python-2.7,amazon-ec2","A_Id":63887550,"CreationDate":"2020-09-14T15:36:00.000","Title":"How to ignore .local\/lib\/python3.7\/site-packages\/ when importing a module to python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"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 use subprocess.getstatus() to get output of bash command running inside python script, in my case top linux command:\noutput = subprocess.getoutput(\"top -bc -n 1 | grep some_process_name\")\nUnfortunately, output string of the function is limited to 80 chars. If the string is longer, I just get the first 80 chars.\nAny other alternate way to get long outputs in shell commands, in full?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":48,"Q_Id":63888639,"Users Score":1,"Answer":"You could pipe the output to a text file, and then display the text file.","Q_Score":0,"Tags":"python,linux,subprocess","A_Id":63888729,"CreationDate":"2020-09-14T16:49:00.000","Title":"subprocess.getstatus() return limited-length string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to create a column that identifies English and Spanish tweets from a dataframe with several rows of tweets. Ideally tweets in English would be categorized as a 1 and those in Spanish would be marked as 0.\nThe end goal is to be able to filter out Spanish tweets from my dataframe to save English tweets in a new CSV. I looked at using Textblob, langdetect, and also fastText, but everything I've found gives instructions for just running the code on 1 string of text at a time.\nIs there an easy way to categorize by language (English\/Spanish) for a whole dataframe using Python?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":63889664,"Users Score":0,"Answer":"I think there are two ways.\ni) to train a model to determine the text is Spanish or English using\n(NLP).\nii) just trow the sentences to a list and use if condition with\nSpanish Character to give 1 or 0 on the bases of conditions.\nHope it is helpful.","Q_Score":1,"Tags":"python,twitter,nlp","A_Id":63889990,"CreationDate":"2020-09-14T18:09:00.000","Title":"How to identify Spanish vs. English Text from a csv of tweets?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For background, I work mostly in the terminal and edit code using vim. For long-term python projects I manage venvs and lock files in source control using poetry.\nThere are some modules I like to have installed in almost every venv I work in, such as ipython\/ptpython, (pytest-)icdiff, and other \"quality of life\" extensions that I need not foist on project collaborators who don't use my workflow. I can install ptpython in the global scope using my distro's package manager (or pipx), but then when I run it, it does not run inside the local venv and local dependencies are not accessible. This gets obnoxious since I'm periodically recreating venvs as the lock files change. Right now I have a shell script that installs the things, but that feels like a hack.\nAn ideal solution might be a way to create something like a venv template, similar to the git templatedir option. Is there anything of such for Python?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":63889768,"Users Score":0,"Answer":"Solution\nThis problem isn\u2019t specific to Python venv, it\u2019s present in rvm and nvm also. Just install the package under the global Python namespace and add it to your PYTHONPATH so that if the package isn\u2019t installed in the local repository Python falls back to your global Python namespace without modifying the repository lockfile.","Q_Score":0,"Tags":"python,python-3.x,python-venv,ptpython","A_Id":63890080,"CreationDate":"2020-09-14T18:14:00.000","Title":"Persisting module installation across new python virtual environments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Looking to extract only 7 digit numbers from this list that starts with the distance matrix, nothing after the underscore\nThe list:\n['data_train_3366094.dump','agile_234444.pkl','distanceMatrix_1517144.dump', 'distanceMatrix_3366094_1.dump']\nexpecting output: 1517144 , 3366094","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":63892907,"Users Score":0,"Answer":"My guess is to explode(), separating with _ and .\nThen match for numeric value","Q_Score":0,"Tags":"python,python-3.x,regex,list","A_Id":63893029,"CreationDate":"2020-09-14T23:09:00.000","Title":"Python regular expression (matching in list)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I'm in the Python IDLE editor and the shell is not open, is there some way to open the shell without running a program? I expect it's something simple that I just can't find.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":272,"Q_Id":63894130,"Users Score":2,"Answer":"For windows:\n\nWin+R to open run window\ncmd to open, well, the command line\npython to run python. Make sure you've added the python.exe file to PATH","Q_Score":2,"Tags":"python,python-idle","A_Id":63895712,"CreationDate":"2020-09-15T02:19:00.000","Title":"Python IDLE how do I get from editor to shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"This is my homework question. Why can't I perform arithmetic operations on a set. For example:\n{a+b} * c returns an error. Why?\nWhen we try to do [a+b]*c, it returns a list. For instance: [4+5]*6 returns [9, 9, 9, 9, 9, 9]. But the same is not the result for the set. Why?\nSorry I am quite new to Python.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":560,"Q_Id":63895352,"Users Score":1,"Answer":"[a+b]*c returns a list, not a set. Because elements in a set is unique, so you cannot use '*' to initial a set.","Q_Score":0,"Tags":"python,python-3.x","A_Id":63895374,"CreationDate":"2020-09-15T04:56:00.000","Title":"Python: Why can't I do arithmetic operations on a set","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I deleted Python's directory, now I can't reinstall it, it tries to upgrade.\nI deleted HKEY_CURRENT_USER\/Software\/Python\nI looked at HKEY_LOCAL_MACHINE\/SOFTWARE but there was no Python.\nplatform: Windows 7 64 bit","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":273,"Q_Id":63896763,"Users Score":1,"Answer":"Under Windows OS You should go to Your Control Panel and chose Uninstall a Program. Then You should find Your current Python installation and remove it with all dependencies.\nUnder Ubuntu You have to go to the terminal and execute command sudo apt-get remove python3* for Python 3.n versions.","Q_Score":1,"Tags":"python,python-3.x","A_Id":63896902,"CreationDate":"2020-09-15T07:07:00.000","Title":"Can't reinstall Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Was just wondering what is the pygetwindow module used for? Are there other modules that are similar to pygetwindow? Where could i read up on pygetwindow, i can find no tutorials on it on youtube or anything.","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1293,"Q_Id":63897653,"Users Score":-2,"Answer":"I test the sample on the Win10\ny.active() return the erroe code below:\nPyGetWindowException: Error code from Windows: 0","Q_Score":2,"Tags":"python","A_Id":69976619,"CreationDate":"2020-09-15T08:07:00.000","Title":"What is the pygetwindow module used for?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an array of 2k elements and i am trying to sort it.\nWhen i call sorted(arr) it takes very less time, i.e 3-4 sec to sort an array.\nbut when i am building my own sorting function(merge sort) with time complaxity nlogn it is taking more then a min to sort it.\nI also tried with quick sort and bubble sort but none of the algo is able to reduce the time to this extent.\nI am not able to understand that how builtin function works and how it is taking so less time. what is the logic behind it?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":640,"Q_Id":63897845,"Users Score":2,"Answer":"Python's sorted () is written in C and compiled to native code. When you write your own sort, it's run entirely in the python interpreter, which is at least an order of magnitude slower - nearly two. It's hard to say without seeing your code, but there's also a chance that your Python sort is doing a bunch of allocation behind the scenes...","Q_Score":0,"Tags":"python-3.x,sorting","A_Id":63898488,"CreationDate":"2020-09-15T08:19:00.000","Title":"logic behind sorted() function in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a coordinate system where North has the angle value 1. East +0.707 and West -0.707. South has the angle 0.\nIt's very annoying to calculate angle deltas in this angle system. Is there a nice way to convert it to a standard 0 to 360 degree coordinate system?\nPython solution preferred but I'm more interested in the operations instead of ready to use implementation.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":110,"Q_Id":63898614,"Users Score":1,"Answer":"0.707 is the cosine of 45\u00b0. So your current system shows you the cosine of your angle divided by 2, as I would expect a 90\u00b0 value for West. If you apply the transformation 180\/pi * arccos(x) * 2, where x is your current value, you will get a 0\u00b0 to 360\u00b0 value, where 0\u00b0 or 360\u00b0 will be North, and 180\u00b0 will be South.\nThe 180\/pi factor is there to convert from the radians output of the arccos function.","Q_Score":2,"Tags":"python,coordinates,angle","A_Id":63898805,"CreationDate":"2020-09-15T09:08:00.000","Title":"Map N,S,E,W Angle system System to 360\u00b0 Angle System","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to update in realtime one or more labels on my HTML webpage, im using some .css and .js for the animations on the webpage.\nActually im using flask for manage the calls.\nI need to update the values of the html page everytime that i receive a GET on my flask webserver.\nHow could I do?\nIm not so familiar with webapps, i need some help about technologies and techinques.\nThank you all","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":63899213,"Users Score":0,"Answer":"One of the simplest ways to do so would be by using vue.js\nThere you can assign the content in your DOM (more exactly your vue-component) to a variable which you can update on every request.\nAlternatively you can use your standart js and update each label with the content on your label-update...","Q_Score":0,"Tags":"javascript,python,html,ajax,flask","A_Id":63899285,"CreationDate":"2020-09-15T09:44:00.000","Title":"Autoupdate labels on HTML page every Get request","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have to create a 50 X 50 matrix in python at runtime using NumPy. The entries of the matrix will be a result of a data query from a website. The query return Pandas. So, how can I create a matrix using data from pandas at runtime?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":467,"Q_Id":63900843,"Users Score":0,"Answer":"Almost everything you do in Python is on runtime. If your response is a pandas.DataFrame you can just access it's values attribute to get the underlying numpy array. No need to create it by hand.","Q_Score":0,"Tags":"python,pandas,numpy,matrix,numpy-ndarray","A_Id":63900911,"CreationDate":"2020-09-15T11:27:00.000","Title":"How to create a 50 X 50 matrix in Python at runtime?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I'm trying to read a feather file I got this Error:\n\nArrowInvalid: Column 0: In chunk 0: Invalid: Buffer #1 too small in array of type int64 and length 14712: expected at least 117696 byte(s), got 3450","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1059,"Q_Id":63901347,"Users Score":4,"Answer":"This file was created with another pyarrow version. I had version 0.17.0 and file was created by version 1.0.0. So updating my pyarrow to new version solved the problem.","Q_Score":0,"Tags":"python,pandas,feather","A_Id":63901348,"CreationDate":"2020-09-15T11:57:00.000","Title":"pandas read feather ArrowInvalid","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"when i try to import tensorflow from jupyter notebooks. I'm facing a error No module named 'tensorflow' .\nBut i have installed tensorflow using pip command, and it available in this path c:\\program files\\python38\\lib\\site-packages.\nplease tell me how to access packages installed via pip from jupyter notebooks?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":82,"Q_Id":63902090,"Users Score":1,"Answer":"When you installed tensorflow you had a specific environment active and that is where tensorflow was installed. If you are using Anaconda and did not specify which environment to make active it installed it in the base environment. If you want to install tensorflow to a specific environment (lets call it tf) then start the anaconda prompt and enter the text conda activate tf. Then install tensorflow with pip in the same window. My recommendation is to install tensorflow with conda versus pip. conda installs tensorflow and also installs the cuda toolkit and the proper version of cuDNN. pip does not do that. If you install tensorflow with conda I believe it installs version 2.1, cuda toolkit version 10.1.243 and cuDNN version 7.6.5.","Q_Score":1,"Tags":"python,tensorflow,pip,jupyter-notebook,anaconda","A_Id":63904722,"CreationDate":"2020-09-15T12:42:00.000","Title":"Unable to access pip installed packages from anaconda jupyter notebooks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written some scrip in python using windows and want to run it in my raspberry with Ubuntu.\nI am reading a csv file with line separator new line. When I load the df I use the following code:\ndfaux = pd.read_csv(r'\/home\/ubuntu\/Downloads\/data.csv', sep=';') \nwhich loads a df with just one row. I have also tried including the argument  lineterminator = '\\n\\t' which throws this error message:\nValueError: Only length-1 line terminators supported\nIn windows I see the line breaks in the csv file, whereas when I open it with mousepad in ubuntu I don't see the line breakers, but I see the columns color coded.\nHow could I read properly the csv?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1073,"Q_Id":63904101,"Users Score":1,"Answer":"Well, at then end I solved it by changing the explorer I was using to download the csv file with webdriver from Firefox to Chrome, not sure what\u00b4s the reason behind but maybe this will help if you have the same issue in the future","Q_Score":1,"Tags":"python,pandas,dataframe,csv,raspberry-pi4","A_Id":63916205,"CreationDate":"2020-09-15T14:31:00.000","Title":"Reading a CSV file to pandas works in windows, not in ubuntu","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed a Python package using pip from git. In order to achieve this, I added the command\n-e git+<link>#<egg> to my requirements.txt. Pip installs this package, but not in the way I would like to have it.\nFirst problem: I use a virtual environment. Usually, packages end up in <env>\/Lib\/site-packages. This one does not, it ends up in <env>\/src. This makes it more to difficult to import.\nSecond problem: The src folder also gets created within my actual project, the one I am working on.\nBoth things are different to installing packages from other sources like PyPI. Is there a way to install my own packages via git in the same way? I actual built a wheel and a tar.gz, but I don't know how to install them ...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":63904632,"Users Score":0,"Answer":"@AnthonySottile's comment pointed me into the right direction: The -e option makes the installed package editable, which is not what I wanted. It actually works without it!\nSo if you want to avoid having src folders appearing everywhere - download from git without the -e option:\ngit+<link>#<egg>\nUnfortunately, I didn't find any documentation for this ... so feel free to post a more profound answer or add to this one.","Q_Score":0,"Tags":"python,git,pip,python-import","A_Id":63917959,"CreationDate":"2020-09-15T15:02:00.000","Title":"Install package using pip from git into site-packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having trouble installing pip. I downloaded the latest version of python (3.8.5) and then i got the get-pip.py file and saved it in my documents folder. After that I went into the command prompt to the documents folder and type \"python get-pip.py\" as well as \"py get-pip.py\" and nothing happened. According to the tutorials that I watched, I should've seen a progress bar and some other technical information. I installed this on my Mac machine a while back and was able to do this easily.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":261,"Q_Id":63904988,"Users Score":0,"Answer":"So to solve this, all I did was install python in an easy to access location. Before ot was under users\\appdata..... and a bunch of other useless locations. Then I made sure pip was clicked in the installation wizard. I also had to add it to the path myself. For that I went to control panel -> System and Security -> System -> advanced system settings (left hand menu) ->environment variables (button at bottom of first screen) -> under system variables scroll until you find path then double click or select and click edit -> click new -> type in path to file","Q_Score":0,"Tags":"python,windows,installation,pip","A_Id":63930477,"CreationDate":"2020-09-15T15:20:00.000","Title":"Pip not installing windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am having trouble installing pip. I downloaded the latest version of python (3.8.5) and then i got the get-pip.py file and saved it in my documents folder. After that I went into the command prompt to the documents folder and type \"python get-pip.py\" as well as \"py get-pip.py\" and nothing happened. According to the tutorials that I watched, I should've seen a progress bar and some other technical information. I installed this on my Mac machine a while back and was able to do this easily.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":261,"Q_Id":63904988,"Users Score":0,"Answer":"You need to add the path of the pip install to your PATH system variable via Control Panel or by using the setx command\nGenerally it is installed to C:\\Python38\\Scripts\\pip by default.\nIf you are unsure of whether or not it is in your path you can type  echo %path%  into a CMD prompt.","Q_Score":0,"Tags":"python,windows,installation,pip","A_Id":63906392,"CreationDate":"2020-09-15T15:20:00.000","Title":"Pip not installing windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is it possible to get rid of the bluish tint in the dark interface theme of Spyder 4.1?\nHow can I do it, if that's possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":63906028,"Users Score":1,"Answer":"(Spyder maintainer here) Sorry, that's not possible.","Q_Score":0,"Tags":"python,ide,spyder","A_Id":64363790,"CreationDate":"2020-09-15T16:19:00.000","Title":"Is it possible to edit dark UI theme colours in Spyder IDE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Website is fine when debug is true, but when set to false it gives me a server error 500 evertime on every page.\nWhen i go into heroku logs --tail\nit tells me there is a status 500 issue.\nI have set up my allowed host so that is not an issue.\nDoes anyone have any suggestions on what the root of the issue could be?\nWould appreciate any advice, thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":63907323,"Users Score":0,"Answer":"Try adding DEBUG_PROPAGATE_EXCEPTIONS = True in your setting.py. with this, you can see the errors in the log.\nSecondly, the major cause to this error is usually the static files serving via whitenoise.\nRun heroku run python manage.py collectstatic, but before that make sure your STATIC_ROOT is correct.","Q_Score":0,"Tags":"python,django,heroku,collectstatic","A_Id":63907434,"CreationDate":"2020-09-15T17:49:00.000","Title":"Server error 500 on Django when deployed on Heroku when debug is set to False","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to get the value from a text box on an html page.\nIncrease this value . Clear the existing value from the textbox and insert the incremented value.\nEg. The text box for add to cart. Has the value 2 for chocolates. I want to clear this value and enter the new value of 2+ 1 = 3\nI am using robot framework and python .\nI tried clear element keyword but this seems to be adding the 3 after the inserted value    ie.\n2 initial value\n3 updated value\nThe textbox reads 23 instead of 3\nYour help will be greatly  affected.  Thank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":126,"Q_Id":63909495,"Users Score":0,"Answer":"The Input TextCommand should clear the Textfield from alone.\nClear Element Text is the only other Keyword I know to modify textfields.","Q_Score":0,"Tags":"python,robotframework","A_Id":63918686,"CreationDate":"2020-09-15T20:35:00.000","Title":"Robotframework- increment text box value","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"pip._vendor.pkg_resources.DistributionNotFound: The 'pip==20.1.1' distribution was not found and is required by the application\n-this is the error message that I keep getting.I have the latest version of pip and I have no idea why its not being found when I have pip version 20 installed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":63909562,"Users Score":0,"Answer":"after uninstalling python and reinstalling using brew the problem began to solve itself.","Q_Score":0,"Tags":"mysql,python-3.x,mysql-connector","A_Id":63910336,"CreationDate":"2020-09-15T20:40:00.000","Title":"mysql connector not downloading","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm try to plot a decision trees of Xgboost models from different datasets.\nWhich worked fine for most of them, but for one dataset the plot_tree just shows only one leaf.\nIt's weird for me, once the max_depth of that model is 5.\nCould anyone give me a tip?\nThanks for considering my question. :) !","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":392,"Q_Id":63910030,"Users Score":0,"Answer":"I am glad to share that I figured out the reason for my problem :)\nXGBoost is a technique which works on the principle of ensemble, so XGBClassifier creates multiple trees and some trees can ended in only one leaf. I realised that the functions used to plot export_graphviz or plot_tree plotted the first tree of my model as default and not the best interaction. To do that I must set the parameter \"num_trees\":\n\n\"num_trees (int, default 0) \u2013 Specify the ordinal number of target\ntree\"\n\nSo, I have to find the ordinal number of the target tree.\nFortunately, there are two functions that set it for us .get_booster () and .best_iteration.\nSee below the code to plot the tree with the best interaction.\nplot_tree (model, ax = ax, num_trees = model.get_booster().best_iteration)","Q_Score":0,"Tags":"python,decision-tree,xgboost,xgbclassifier","A_Id":64353741,"CreationDate":"2020-09-15T21:22:00.000","Title":"Xgboost - Decision Tree - Only one leaf","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a bot that randomly selects elements and generally browses around looks 'human'.\nI want to simply select any element that has an h3 tag at random, but I only seem to be able to select specific id strings for the bot to find and click on, but I haven't seen anyone just select something by just an h3 tag. Is this even possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":63910055,"Users Score":1,"Answer":"You can get all h3 elements with driver.find_elements_by_tag_name(\"h3\") in a list and use the random module's 'sample' method to get one of them at random.","Q_Score":0,"Tags":"python,python-3.x,selenium,google-chrome","A_Id":63910386,"CreationDate":"2020-09-15T21:24:00.000","Title":"Python: Is there a way to randomly select an element that has an h3 tag in selenium chromedriver?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a long item to write to a DynamoDB table.\nIf the size of the item exceeds the 400KB limit, I want to split the item into multiple chucks and store it as multiple items in the same table with different range keys. Range key here can be monotonically increasing number. How do I do this? Im using boto3","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":263,"Q_Id":63910646,"Users Score":1,"Answer":"There is no way to have boto library or the DynamoDB API automatically \u2018split\u2019 your items.\nYou will have to split up the data yourself and essentially put multiple items that logically make up your original item.\nDepending on the actual structure of your item you will have to decide on a split schema that makes sense for your use case.\nIf your system can tolerate eventual consistency, you can use the PutItem api to write each of the splits. Otherwise, you can use the new transactions API to put all splits in a transaction with the caveat that it costs more and that each transaction is limited to 25 requests and up to 4 MB of data.","Q_Score":0,"Tags":"python,json,amazon-dynamodb,boto3","A_Id":63925941,"CreationDate":"2020-09-15T22:26:00.000","Title":"Split a DynamoDB item that exceeds the size limit","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to create the exe of a program in python that uses a bunch of modules. Running it from cmd, everything works fine. But when I try to run the exe (created using pyinstaller 4.0), it does not work. I got the error:\nNo module named 'vtk.numpy_interface\nI've tried all the following changes on main.spec and in all of them I got the same error:\n\nvtk.numpy_interface in 'hiddenimports' tag\n('C:\\Python\\Python37\\Lib\\site-packages\\vtkmodules', '.\/numpy_interface\/') in 'datas' tag\n'C:\\Python\\Python37\\Lib\\site-packages\\vtkmodule pathex' in 'pathex' tag\n\nMy program does not use vtk.numpy_interface. But i found that it is imported by pyvista.core.datasetattributes (in my program I import pyvista).\nI'm using python 3.7.6 and vtk 9.0. When I was using vtk 8.9.0 i didnt got this error.\nAnyone could helpe me with any idea?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":293,"Q_Id":63911651,"Users Score":1,"Answer":"I've also had issues with VTK 9.0 in regards to pyinstaller, and I'd recommend keeping with vtk==8.1.2 (available on PyPI) until this is resolved with the next vtk release.","Q_Score":1,"Tags":"python,pyinstaller,vtk","A_Id":64092592,"CreationDate":"2020-09-16T00:50:00.000","Title":"Pyinstaller import error: module not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why is the bracket present here in this code after b in if sum([x,y]) <=b \"]\" +[-1])\nreturn max([sum([x,y]) for x in keyboards for y in drives if sum([x,y]) <= b]+[-1])\nsomeone please explain the code","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":63912835,"Users Score":0,"Answer":"What you've got there is: [list comprehension] + [-1]. That creates a new list with the two lists combined.\nFor whatever reason, the author of that code wanted the max to at least be -1.","Q_Score":0,"Tags":"python,loops,one-liner","A_Id":63912851,"CreationDate":"2020-09-16T03:49:00.000","Title":"why there is a bracket python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I asked our data support team to share data for 12 months, they sent me 12 different files with 3 sheets in each file. I need to combine all of that data into another datasheet, I have the following questions?\n\nWould excel be able to cram in all the data into one large file, limitations?\nIs R a good solution, can one share any easy code and libraries needed for such operation, seen multiple videos on youtube but all are not working.\nI heard that in Python Pandas is helpful but my past experience is bad that Python being very slow.\nI have no idea of VB codes\n\nPlease could anyone help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":63912986,"Users Score":0,"Answer":"may my answer can help you:\n\nExcel has limit 1.048.576 rows\nYou just need package to import excel file (readxl...). You can use for loop to import all file, and merge all file to dataframe and export to excel.\nIn VBA, i think logic is same in R","Q_Score":0,"Tags":"python,r,excel,pandas","A_Id":63914326,"CreationDate":"2020-09-16T04:09:00.000","Title":"Data Merging in R for 12 excel workbooks (each containing 3 worksheets)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m trying to modify Yolo v1 to work with my task which each object has only 1 class. (e.g: an obj cannot be both cat and dog)\nDue to the architecture (other outputs like localization prediction must be used regression) so sigmoid was applied to the last output of the model (f.sigmoid(nearly_last_output)). And for classification, yolo 1 also use MSE as loss. But as far as I know that MSE sometimes not going well compared to cross entropy for one-hot like what I want.\nAnd specific: GT like this: 0 0 0 0 1 (let say we have only 5 classes in total, each only has 1 class so only one number 1 in them, of course this is class 5th in this example)\nand output model at classification part: 0.1 0.1 0.9 0.2 0.1\nI found some suggestion use nn.BCE \/ nn.BCEWithLogitsLoss but I think I should ask here for more correct since I\u2019m not good at math and maybe I\u2019m wrong somewhere so just ask to learn more and for sure what should I use correctly?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":965,"Q_Id":63914849,"Users Score":3,"Answer":"MSE loss is usually used for regression problem.\n\nFor binary classification, you can either use BCE or BCEWithLogitsLoss. BCEWithLogitsLoss combines sigmoid with BCE loss, thus if there is sigmoid applied on the last layer, you can directly use BCE.\n\nThe GT mentioned in your case refers to 'multi-class' classification problem, and the output shown doesn't really correspond to multi-class classification. So, in this case, you can apply a CrossEntropyLoss, which combines softmax and log loss and suitable for 'multi-class' classification problem.","Q_Score":2,"Tags":"python,pytorch,loss-function,cross-entropy","A_Id":65332656,"CreationDate":"2020-09-16T07:07:00.000","Title":"Using sigmoid output for cross entropy loss on Pytorch","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to subset anndata on basis of clusters, but i am not able to understand how to do it.\nI am running scVelo pipeline, and in that i ran tl.louvain function to cluster cells on basis of louvain. I got around 32 clusters, of which cluster 2 and 4 is of my interest, and i have to run the pipeline further on these clusters only. (Initially i had the loom file which i read in scVelo, so i have now the anndata.)\nI tried using adata.obs[\"louvain\"] which gave me the cluster information, but i need to write a new anndata with only 2 clusters and process further.\nPlease help on how to subset anndata. Any help is highly appreciated. (Being very new to it, i am finding it difficult to get)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1582,"Q_Id":63916137,"Users Score":3,"Answer":"If your adata.obs has a \"louvain\" column that I'd expect after running tl.louvain, you could do the subsetting as\nadata[adata.obs[\"louvain\"] == \"2\"]\nif you want to obtain one cluster and\nadata[adata.obs['louvain'].isin(['2', '4'])]\nfor obtaining cluster 2 & 4.","Q_Score":2,"Tags":"python,rna-seq,scanpy","A_Id":64331620,"CreationDate":"2020-09-16T08:31:00.000","Title":"subsetting anndata on basis of louvain clusters","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am facing this error while using Cx_Oracle package in python environment. I upgraded to oracle 12c from 11g but it still gets me this error. Also, I am using ojdbc6.jar.\nDatabaseError: ORA-28040: No matching authentication protocol","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":984,"Q_Id":63918389,"Users Score":0,"Answer":"ojdbc6.jar is driver for JVM\/Java\nCx_Oracle is C\/C++ library depending on libclnth.so library.\nThe errors states that your client is either to old (or too new) and you can not authenticate to the database. There is no auth protocol that both sides implement\/accept.\nEither you should upgrade your client or change\nsqlnet.ora set SQLNET.ALLOWED_LOGON_VERSION to version of your client library.","Q_Score":1,"Tags":"python,oracle12c,cx-oracle","A_Id":63918525,"CreationDate":"2020-09-16T10:47:00.000","Title":"Cx_Oracle : DatabaseError: ORA-28040: No matching authentication protocol","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to DITA. I would like to create the DITA xml for my PDF publishing\nWHAT I WANT TO DO IS :\nfirst i want to have the template based table which can be used in number of DITA xmls\nand in hat table template I can populate the data according to my need.\nIn this way I can use same table schema multiple times and populate different data into that table present in different DITA xmls.\ncan it be possible through python?\nIs it possible to do so?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":63919310,"Users Score":0,"Answer":"It sounds like you could use the DITA conref capability. For the template table, you can have that in a DITA XML file that you store separately. Then in each DITA file that you want to use that table in, you use a conref to pull in your template table.\nYou could use Python for this, but it would be simpler to just use the free DITA Open Toolkit, which supports the conref feature by default.","Q_Score":0,"Tags":"python,dita","A_Id":63932761,"CreationDate":"2020-09-16T11:41:00.000","Title":"how to create a template based table and use it in multiple DITA xml and populate the data through it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python Package that requires another package to be installed. That package can be downloaded from someone else's github page. I need to turn my package into a .deb file. I am currently doing this using stdeb. Is it possible to make it so when my deb file is installing, it will also download the files from the git and do a \"pip install .\" on their setup.py?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":93,"Q_Id":63919995,"Users Score":0,"Answer":"Debian packages are supposed to be self contained.  You don't know that when the package is installed that the remote Git server will exist and that it will contain the contents that you want (e.g., they could have been deleted or replaced with malicious contents).  You don't even necessarily know that you'll have a network connection at that time.\nEven if, in your environment, you do know that, Debian packages don't expect that, so the files you download via Git and generate by using pip won't be removed by your package, leaving cruft on the user's system.  That means that future package installs might break due to this leftover cruft, leading to hard-to-debug errors.\nIt is possible to do by using a postinst script, but definitely not a good idea.  You'll want to package your dependency in another Debian package or use the existing package from the developer's page instead.","Q_Score":0,"Tags":"python,git,debian,packaging,debian-packaging","A_Id":63928844,"CreationDate":"2020-09-16T12:22:00.000","Title":"Debian package install Dependency from Git?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using AWS for work with Anaconda in it. I don't have permission to install any python library (I mean, I requested it and it's taking ages) so I'm trying to see if there's a way around it.\nI'm trying to install xgboost, is it possible to do so without actually installing it? I thought maybe copying and pasting the base code, but it's a bit messy I guess?\nAny better recommendations?\nI tried using a virtual environment (venv) and it doesn't seem to work... it's not allowing me to create a virtual env, I guess it's because of the permits I said before.\nEdit: I basically cannot install anything (I can't even access google actually, just the company approved websites). The first idea, of pasting the base code, I will have to send it over from my personal email to my work email so I can get it there, but it's not very simple either.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":63924617,"Users Score":0,"Answer":"Download Package which you want to install\nunzip and cd into folder\nrun python setup.py with --user flag","Q_Score":1,"Tags":"python,amazon-web-services,package,python-venv","A_Id":63924708,"CreationDate":"2020-09-16T16:48:00.000","Title":"How to use python library without installing it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using AWS for work with Anaconda in it. I don't have permission to install any python library (I mean, I requested it and it's taking ages) so I'm trying to see if there's a way around it.\nI'm trying to install xgboost, is it possible to do so without actually installing it? I thought maybe copying and pasting the base code, but it's a bit messy I guess?\nAny better recommendations?\nI tried using a virtual environment (venv) and it doesn't seem to work... it's not allowing me to create a virtual env, I guess it's because of the permits I said before.\nEdit: I basically cannot install anything (I can't even access google actually, just the company approved websites). The first idea, of pasting the base code, I will have to send it over from my personal email to my work email so I can get it there, but it's not very simple either.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":63924617,"Users Score":0,"Answer":"If you have access to the site-packages directory, you can copy the package directly into there, as you suggested.  I guess installing from a wheel also wouldn't work?\nYou could also just redownload python into a directory you have access to and start from there.\nAlso, does Anaconda use venv?  I've always used conda create to make an anaconda virtual environment.","Q_Score":1,"Tags":"python,amazon-web-services,package,python-venv","A_Id":63924757,"CreationDate":"2020-09-16T16:48:00.000","Title":"How to use python library without installing it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using AWS for work with Anaconda in it. I don't have permission to install any python library (I mean, I requested it and it's taking ages) so I'm trying to see if there's a way around it.\nI'm trying to install xgboost, is it possible to do so without actually installing it? I thought maybe copying and pasting the base code, but it's a bit messy I guess?\nAny better recommendations?\nI tried using a virtual environment (venv) and it doesn't seem to work... it's not allowing me to create a virtual env, I guess it's because of the permits I said before.\nEdit: I basically cannot install anything (I can't even access google actually, just the company approved websites). The first idea, of pasting the base code, I will have to send it over from my personal email to my work email so I can get it there, but it's not very simple either.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":63924617,"Users Score":0,"Answer":"I have used some modules in python (pexpect) without actually installing the module, but instead having the module file within the same folder where I have the project.\nAnd just calling the import (module) in the code.\ni'm not sure if it can work for you, but you should give it a try.","Q_Score":1,"Tags":"python,amazon-web-services,package,python-venv","A_Id":63924763,"CreationDate":"2020-09-16T16:48:00.000","Title":"How to use python library without installing it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am generating dotplots using scanpy and unable to change the font size. Is there a way to do so?\nFor example, how would I edit this line of code?\nsc.pl.dotplot(df,  [\"gene\"], 'CellType', dendrogram=True,  save = name)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1124,"Q_Id":63925267,"Users Score":0,"Answer":"Turns out you can do this directly using scanpy with the following:\nsc.set_figure_params(scanpy=True, fontsize=14)\nHowever, I am still unsure how to change the y axis specifically...","Q_Score":0,"Tags":"python,python-3.x,matplotlib,scanpy","A_Id":63944122,"CreationDate":"2020-09-16T17:36:00.000","Title":"How to change font size in scanpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Visual Studio Code and have Anaconda downloaded so i selected it as my path interpreter.\nI am able to download virtualenv using pip install virtualenv and then  instantiate it using virtualenv env.\nThe issue occurs when I try to activate the environment using activate env or conda activate env.\nError message returned: Could not find conda environment: env. I then proceeded to look into my directory and I see that the environment is included as a folder so I'm confused on why I cannot activate it. For reference I am using Windows.\nEdit: Originally the environment was not appearing in my users\/.conda\/environments file but using conda create --name venv I was able to create a new environment here. However, it doesn't instantiate in my current directory. Thoughts?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":63925640,"Users Score":1,"Answer":"conda virtual environments are not interchangeable with virtualenv virtual environments. If you have created a virtual environment in your current dir. The ps command would be .\\Scripts\\activate","Q_Score":0,"Tags":"python,path","A_Id":63926009,"CreationDate":"2020-09-16T18:06:00.000","Title":"Cannot activate virtual environment on virtual studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been playing around with automatic gradients in tensorflow and I had a question. If we are updating an optimizer, say ADAM, when is the momentum algorithm applied to the gradient? Is it applied when we call tape.gradient(loss,model.trainable_variables) or when we call  model.optimizer.apply_gradients(zip(dtf_network,model.trainable_variables))?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":63926218,"Users Score":0,"Answer":"tape.gradient computes the gradients straightforwardly without reference to an optimizer. Since momentum is part of the optimizer, the tape does not include it. AFAIK momentum is usually implemented by adding extra variables in the optimizer that store the running average. All of this is handled in optimizer.apply_gradients.","Q_Score":0,"Tags":"python,tensorflow,adam","A_Id":63935102,"CreationDate":"2020-09-16T18:47:00.000","Title":"When is Momentum Applied in Tensorflow Gradient Tape?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install package inside a docker container(python:rc-slim).\nAs of now I see that most recent azureml-core wheel uploaded to PyPI is:\n\nazureml_core-1.13.0-py3-none-any.whl\n\nbut when I run pip install azureml-core==1.13.0 I get following error:\n\nERROR: Could not find a version that satisfies the requirement\nazureml-core==1.13.0 (from versions: 0.1.50, 0.1.57, 0.1.58, 0.1.59,\n0.1.65, 0.1.68, 0.1.74, 0.1.80, 1.0rc83, 1.0rc85, 1.0.2, 1.0.6, 1.0.8, 1.0.10, 1.0.15, 1.0.17, 1.0.17.1, 1.0.18, 1.0.21, 1.0.23, 1.0.30, 1.0.33, 1.0.33.1, 1.0.39, 1.0.41, 1.0.41.1, 1.0.43, 1.0.43.1, 1.0.45, 1.0.48, 1.0.53, 1.0.55, 1.0.57, 1.0.57.1, 1.0.60, 1.0.62, 1.0.62.1, 1.0.65, 1.0.65.1, 1.0.69, 1.0.72, 1.0.74, 1.0.76, 1.0.76.1, 1.0.79, 1.0.81, 1.0.81.1, 1.0.83, 1.0.85, 1.0.85.1, 1.0.85.2, 1.0.85.3, 1.0.85.4, 1.0.85.5, 1.0.85.6, 1.1.0rc0, 1.1.1rc0, 1.1.1.1rc0, 1.1.1.2rc0, 1.1.2rc0, 1.1.5, 1.1.5.1, 1.1.5.2, 1.1.5.3, 1.1.5.4, 1.1.5.5, 1.1.5.6, 1.1.5.7)\n\nWhen installing packages from 'apt-get' I usually have to update the index first but I can't find a comparable command to do that with pip.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":166,"Q_Id":63927086,"Users Score":-1,"Answer":"Two possibilities:\n\nthe package needs you to use an underscore (since hyphens don't behave) so pip can download it: so run pip install azureml_core==1.13.0\nRun with the --no-cache-dir argument, so pip install --no-cache-dir azureml_core==1.13.0. This argument forces pip to refresh it's package cache.","Q_Score":0,"Tags":"python,docker,pip","A_Id":63927228,"CreationDate":"2020-09-16T19:51:00.000","Title":"pip using out of date package index","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to use pandas.read_excel to read data from the Excel workbook. However, if the workbook is stored in the OneDrive folder and synced to OneDrive, it cannot be read when it is already open. It reports an error message\n\n[Errno 13] Permission denied: 'C:\\Users\\Name\\OneDrive\\Test\\Test.xlsx'\n\nseems failed when trying to open the file\n\nwith open(filename, \"rb\") as f:\n\nBut when I closed the workbook, pandas.read_excel succeeded fetching data from it. And files not in the OneDrive folder can always be accessed no matter open or not. Please see below cases:\npd.read_excel(r'C:\\Users\\Name\\Test\\Book1.xlsx')  # successful when book is open\npd.read_excel(r'C:\\Users\\Name\\Test\\Book1.xlsx')  # successful when book is closed\npd.read_excel(r'C:\\Users\\Name\\OneDrive\\Book1.xlsx')  # failed when book is open\npd.read_excel(r'C:\\Users\\Name\\OneDrive\\Book1.xlsx')  # successful when book is closed\nI was wondering if it is something related to OneDrive? And is there any way I can read data from an opened workbook stored in the OneDrive folder? Since I want to read data from the closed workbook as well, xlwings should not be a good idea, is there a general technique I can use to read data from all excel workbooks no matter open or not, and no matter in OneDrive or not?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1217,"Q_Id":63929606,"Users Score":0,"Answer":"I have had success with this by simply turning off the autosave feature in excel.\nedit: This seems to only work with an older .xls file and not .xlsx","Q_Score":1,"Tags":"python,excel,pandas,onedrive","A_Id":64122004,"CreationDate":"2020-09-17T00:26:00.000","Title":"Open excel workbook in OneDrive folder using Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"We're using the DocuSign SDK (version 3.3.0) and utilizing webhooks to receive the various envelope and recipient events.\nSimilar to DocuSign, we have given a option to delete an envelope in our application. Since there is no webhook notification once a envelope is moved to deleted bin. And also there is a field called deleted_date_time in get_envelope method (which provides the envelope details) and there is no status change, which are not updated once the envelope is being removed from the deleted bin.\nCan anyone please help me in how to make sure the envelope has been removed from the deleted bin?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":197,"Q_Id":63931911,"Users Score":1,"Answer":"There's no means to permanently delete and envelope or remove it from the recycle bin folder. You cannot do that from the DocuSign Web App either as far as I can tell.\nVoiding an envelope is and deleting it is as good as it gets. There's no need to worry about it anymore.","Q_Score":0,"Tags":"python-3.x,docusignapi,webhooks","A_Id":63946598,"CreationDate":"2020-09-17T05:43:00.000","Title":"DocuSign - Delete Envelope","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to clone my existing venv to another PC but simply copy paste is not working. When I copy the venv and paste to the second machine and run\n\npip list\n\nIt only list pip and setup_tools as the installed dependencies.\nI tried another way to clone the packages.\nI created a new venv in the second machine and copied all the file of first venv to that new venv with skipping the existing files with the same name in new venv. Now, when I run\n\npip list\n\nIt shows all the dependencies but, when I try to launch the jupyter notebook as\n\njupyter notebook\n\nIt gives the following error.\n\nFatal error in launcher: Unable to create process using '\"f:\\path\\to\\first_venv\\on_first_machine\\scripts\\python.exe\"\n\"C:\\path\\to\\new_venv\\on_the_second_machine\\Scripts\\jupyter.exe\" notebook': The system cannot find the file specified.\n\nI don't know to make things working. Please help!\nEdit\nThe problem is I don't have internet connection on the second machine. Actually it's a remote machine with some security protocols applied and having no internet connection is part of security ! My bad :'(","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2265,"Q_Id":63932002,"Users Score":10,"Answer":"You can't copy-paste venvs from one machine to another since scripts in them may refer to system locations. (The same stands for attempting to move venvs within a machine.)\nInstead, recreate the environment on the new machine:\n\nOn the old machine, run pip freeze -l > packages.txt in the virtualenv.\nMove packages.txt over to the new machine.\nCreate a new virtualenv on the new machine and enter it.\nInstall the packages from the txt file: pip install -r packages.txt.\n\nEDIT: If you don't have internet access on the second machine, you can continue from step 2 with:\n\nRun pip wheel -w wheels -r packages.txt in the venv on the first machine. This will download and build *.whl packages for all the packages you require. Note that this assumes both machines are similar in OS and architecture!\nCopy the wheel files over to the new machine.\nCreate a new virtualenv on the new machine and enter it.\nInstall the packages from wheels in the new virtualenv: pip install *.whl.","Q_Score":4,"Tags":"python,jupyter-notebook,python-venv","A_Id":63932038,"CreationDate":"2020-09-17T05:52:00.000","Title":"Unable to clone Python venv to another PC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"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":"It gives that memory error but memory capacity is never reached. I have 60 GB of ram on the SSH and the full dataset process consumes 30\nI am trying to train an autoendcoder with k-fold. Without k-fold the training works fine. The raw dataset contains 250,000 data in hdf5.\nWith K-fold it works if I use less than 100000 of total data.\nI have converted it to float32 but still does not work.\nI have tried echo 1 as well but that kill the python program automatically","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":15477,"Q_Id":63932913,"Users Score":2,"Answer":"Taking into account the dimensions of the dataset you provided (725000 x 277 x 76) and its data type (float64 - 8 bytes), it seems that you need (at minimum) around 114 GB to have the dataset loaded\/stored in RAM.\nA solution to overcome this limitation is to: 1) read a certain amount of the dataset (e.g. a chunk of 1 GB at the time) through a hyperslab selection and load\/store it in memory, 2) process it, and 3) repeat the process (i.e. go to step 1) until the dataset is completely processed. This way, you will not run out of RAM memory.","Q_Score":5,"Tags":"python-3.x,memory-management,out-of-memory,hdf5,k-fold","A_Id":63978734,"CreationDate":"2020-09-17T07:06:00.000","Title":"MemoryError: Unable to allocate 30.4 GiB for an array with shape (725000, 277, 76) and data type float64","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am trying to find anomalies in my dataset of 1000+ documents. I'm using LIME ML Interpreter to be able to explain the model (Isolation Forest) predictions. In one parameter \"mode\" i am able to choose between Classification and Regression. I do not have a set of documents with a known anomaly.\nSince Isolation Forest is a unsupervised learning method and classifcation is a type of supervised learning which is used to clasify observations into two or more classses i ended up using regression. On the other side i have the outcome anomaly or no anomaly.\nWhat is right to use here?\nBest Regards,\nElle","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":508,"Q_Id":63933188,"Users Score":0,"Answer":"The other option I see to this is to hold out 10-20% of the data set during IsoForest tree building. On this holdout to score the model and get the anomaly score (or avg tree depth) and build the explainer on this. Then in scoring new data, LIME will treat it as a regression problem...I am not sure how well this will work though...","Q_Score":0,"Tags":"python,regression,classification,anomaly-detection,lime","A_Id":64208801,"CreationDate":"2020-09-17T07:27:00.000","Title":"LIME ML Interpreter mode Classification or Regression for Isolation Forest (Anomaly Detection)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am trying to find anomalies in my dataset of 1000+ documents. I'm using LIME ML Interpreter to be able to explain the model (Isolation Forest) predictions. In one parameter \"mode\" i am able to choose between Classification and Regression. I do not have a set of documents with a known anomaly.\nSince Isolation Forest is a unsupervised learning method and classifcation is a type of supervised learning which is used to clasify observations into two or more classses i ended up using regression. On the other side i have the outcome anomaly or no anomaly.\nWhat is right to use here?\nBest Regards,\nElle","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":508,"Q_Id":63933188,"Users Score":1,"Answer":"For us, what we have done is as follows:\n\nUse Isolation Forest to get anomalies.\nTreat 1 and -1 returned by Isolation Forest as class labels and build a Random Forest classifier.\nPass this Random Forest classifier to LIME to get explanation of anomalous points.\n\nWe are also trying to find a better option instead of building second level Random Forest classifier.","Q_Score":0,"Tags":"python,regression,classification,anomaly-detection,lime","A_Id":63933865,"CreationDate":"2020-09-17T07:27:00.000","Title":"LIME ML Interpreter mode Classification or Regression for Isolation Forest (Anomaly Detection)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"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'm doing a song guessing game and all the songs are in a file and are randomly outputted after being processed to only show the first letter, however is there a way to ensure that no songs are repeated, due to it being random, and to make an end message if all of them have been outputted to the user. I couldn't really show the whole code or isolate the issue concisely so sorry for no examples, but I hope this is enough to go off. Feel free to ask any more questions! Thanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":63937769,"Users Score":0,"Answer":"If you want to pick random unique items from a list you can use random.sample(list, size). This returns a new list with all the unique elements.","Q_Score":0,"Tags":"python,random","A_Id":63937861,"CreationDate":"2020-09-17T12:10:00.000","Title":"Is there a way to ensure no items are repeated from a random list and output something if they all have been outputted?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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 am learning python 3 and programming in general for the first time, but I can't seem to distinguish a parameter and a variable?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3926,"Q_Id":63941547,"Users Score":2,"Answer":"A parameter is a type of variable that serves as the input to a method.","Q_Score":2,"Tags":"python,python-3.x,variables,parameters","A_Id":63941585,"CreationDate":"2020-09-17T15:38:00.000","Title":"What is the difference between a variable and a parameter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have kali linux, amd64, last python3.8 version, and when i am trying to install pyaudio i get just this                                                                                                                                                         ERROR: Failed building wheel for PyAudio Running setup.py clean for PyAudio Failed to build PyAudio Installing collected packages: PyAudio Running setup.py install for PyAudio ... error ERROR: Command errored out with exit status 1: command: \/usr\/bin\/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '\"'\"'\/tmp\/pip-install-l87_4qp_\/PyAudio\/setup.py'\"'\"'; __file__='\"'\"'\/tmp\/pip-install-l87_4qp_\/PyAudio\/setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))' install --record \/tmp\/pip-record-2u86ewfj\/install-record.txt --single-version-externally-managed --compile --install-headers \/usr\/local\/include\/python3.8\/PyAudio                                                                                                     cwd: \/tmp\/pip-install-l87_4qp_\/PyAudio\/                                                                                                                                                                 Complete output (16 lines):                                                                                                                                                                                  running install                                                                                                                                                                                              running build                                                                                                                                                                                                running build_py                                                                                                                                                                                             creating build                                                                                                                                                                                               creating build\/lib.linux-x86_64-3.8                                                                                                                                                                          copying src\/pyaudio.py -> build\/lib.linux-x86_64-3.8                                                                                                                                                         running build_ext                                                                                                                                                                                            building '_portaudio' extension                                                                                                                                                                              creating build\/temp.linux-x86_64-3.8                                                                                                                                                                         creating build\/temp.linux-x86_64-3.8\/src                                                                                                                                                                     x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I\/usr\/include\/python3.8 -c src\/_portaudiomodule.c -o build\/temp.linux-x86_64-3.8\/src\/_portaudiomodule.o                                        src\/_portaudiomodule.c:29:10: fatal error: portaudio.h: \u041d\u0435\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0438\u043b\u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430                                                                                                                        29 | #include \"portaudio.h\"                                                                                                                                                                               |          ^~~~~~~~~~~~~                                                                                                                                                                               compilation terminated.                                                                                                                                                                                      error: command 'x86_64-linux-gnu-gcc' failed with exit status 1                                                                                                                                              ----------------------------------------                                                                                                                                                                     ERROR: Command errored out with exit status 1: \/usr\/bin\/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '\"'\"'\/tmp\/pip-install-l87_4qp_\/PyAudio\/setup.py'\"'\"'; __file__='\"'\"'\/tmp\/pip-install-l87_4qp_\/PyAudio\/setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))' install --record \/tmp\/pip-record-2u86ewfj\/install-record.txt --single-version-externally-managed --compile --install-headers \/usr\/local\/include\/python3.8\/PyAudio Check the logs for full command output\nIdk what to do with that","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":211,"Q_Id":63941593,"Users Score":0,"Answer":"I solved it by installing portaudio19-dev","Q_Score":1,"Tags":"python,pyaudio","A_Id":63941767,"CreationDate":"2020-09-17T15:41:00.000","Title":"Cant install PyAudio python3.8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Now i am trying to rename the contents of a folder that contains txt files using python:\nThe original files naming starts from 0.txt to 100.txt\nand i want to change their name to start from 10 instead of 0 (so the files would be 10.txt to 110.txt for example)\nI have 2 lists, one contains the original names path and another one with the new names path,and i am trying to use os.rename() or shutil.move() to rename the files.\nHowever, when i try using os.rename(), i get the error that i cannot create a file that already exists.\nWhen i try to use shutil.move(), it deletes every single repeated folder, giving me only the last 9 folders(101 to 110).\nIs there a way around this ??","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1664,"Q_Id":63942474,"Users Score":0,"Answer":"It sounds like you need to start at the end of your list. Try moving 100->110 first, then 99->109, etc. Since 11 is going to already exist when you try moving 1->11 if you start at the beginning of your lists.\nEDIT: I'd actually recommend Tarranoth's answer above","Q_Score":2,"Tags":"python,rename,shutil","A_Id":63942560,"CreationDate":"2020-09-17T16:33:00.000","Title":"os.rename cannot create a file that already exists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Now i am trying to rename the contents of a folder that contains txt files using python:\nThe original files naming starts from 0.txt to 100.txt\nand i want to change their name to start from 10 instead of 0 (so the files would be 10.txt to 110.txt for example)\nI have 2 lists, one contains the original names path and another one with the new names path,and i am trying to use os.rename() or shutil.move() to rename the files.\nHowever, when i try using os.rename(), i get the error that i cannot create a file that already exists.\nWhen i try to use shutil.move(), it deletes every single repeated folder, giving me only the last 9 folders(101 to 110).\nIs there a way around this ??","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":1664,"Q_Id":63942474,"Users Score":2,"Answer":"use os.replace() to replace a file that already exists. To check if file exists, use os.path.isfile('file path')","Q_Score":2,"Tags":"python,rename,shutil","A_Id":63942561,"CreationDate":"2020-09-17T16:33:00.000","Title":"os.rename cannot create a file that already exists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Now i am trying to rename the contents of a folder that contains txt files using python:\nThe original files naming starts from 0.txt to 100.txt\nand i want to change their name to start from 10 instead of 0 (so the files would be 10.txt to 110.txt for example)\nI have 2 lists, one contains the original names path and another one with the new names path,and i am trying to use os.rename() or shutil.move() to rename the files.\nHowever, when i try using os.rename(), i get the error that i cannot create a file that already exists.\nWhen i try to use shutil.move(), it deletes every single repeated folder, giving me only the last 9 folders(101 to 110).\nIs there a way around this ??","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":1664,"Q_Id":63942474,"Users Score":1,"Answer":"You accurately defined the problem.  For instance, when you deal with 02.txt, you rename it to 12.txt.  Ten iterations later, you rename the same file to 22.txt, then 23.txt, ... until you finish with 102.txt.  You do this with the first ten files, systematically wiping out your other 90 files.\nYou have to start at the end of the name space where you have expansion room.  Work from 100.txt downward.  Rename 100.txt to 110.txt, then 99.txt to 109.txt, etc.  This way, you always have an interval of 10 unused file names for your movements.\nCoding is left as an exercise for the reader.  :-)","Q_Score":2,"Tags":"python,rename,shutil","A_Id":63942617,"CreationDate":"2020-09-17T16:33:00.000","Title":"os.rename cannot create a file that already exists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Now i am trying to rename the contents of a folder that contains txt files using python:\nThe original files naming starts from 0.txt to 100.txt\nand i want to change their name to start from 10 instead of 0 (so the files would be 10.txt to 110.txt for example)\nI have 2 lists, one contains the original names path and another one with the new names path,and i am trying to use os.rename() or shutil.move() to rename the files.\nHowever, when i try using os.rename(), i get the error that i cannot create a file that already exists.\nWhen i try to use shutil.move(), it deletes every single repeated folder, giving me only the last 9 folders(101 to 110).\nIs there a way around this ??","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":1664,"Q_Id":63942474,"Users Score":2,"Answer":"I'd advise to move the files and rename them in a temporary directory, delete the original files and move the files back from the temporary directory. And then you can optionally delete the temporary directory you created.","Q_Score":2,"Tags":"python,rename,shutil","A_Id":63942546,"CreationDate":"2020-09-17T16:33:00.000","Title":"os.rename cannot create a file that already exists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"as below:\nMicrosoft Windows [Version XXXXX]\n(c) 2019 Microsoft Corporation. All rights reserved.\nC:\\Users\\XXX\\Desktop\\Projects and Learning>\"C:\/Users\/XXX\/AppData\/Local\/Programs\/Python\/Python38-32\/python.exe\" \"c:\/Users\/XXXX\/Desktop\/Projects and Learning\/Project1.py\"\nWelcome XXX!\nC:\\Users\\XXXX\\Desktop\\Projects and Learning>","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":63943486,"Users Score":0,"Answer":"You can type clear or if you are looking for a fresh new terminal you can click on terminal up on the menu bar and select new terminal or use the Mac shortcut ^[shift] and `","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":63943825,"CreationDate":"2020-09-17T17:41:00.000","Title":"How to clear Terminal of command prompt after installing VSCode for python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"as below:\nMicrosoft Windows [Version XXXXX]\n(c) 2019 Microsoft Corporation. All rights reserved.\nC:\\Users\\XXX\\Desktop\\Projects and Learning>\"C:\/Users\/XXX\/AppData\/Local\/Programs\/Python\/Python38-32\/python.exe\" \"c:\/Users\/XXXX\/Desktop\/Projects and Learning\/Project1.py\"\nWelcome XXX!\nC:\\Users\\XXXX\\Desktop\\Projects and Learning>","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":63943486,"Users Score":0,"Answer":"If I\u2019m understanding correctly you are just trying to clear what\u2019s currently displayed in the terminal\nctrl + l clears the terminal\nOr just type clear and press enter to clear the window","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":63943686,"CreationDate":"2020-09-17T17:41:00.000","Title":"How to clear Terminal of command prompt after installing VSCode for python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried using the max fuction with a couple of int vars and a couple of float vars and i got a warning that int was expected as the correct type but the program is running fine. Did i do something wrong?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":246,"Q_Id":63947025,"Users Score":1,"Answer":"The definition of max() assumes that all of the inputs will have the same type, which is okay but it causes pycharm to show a warning because you're mixing types. You can either\n\nUse an iterable instead (e.g. max((1.4, 11, 17))\n\nor\n\nSuppress the warning, because it's pretty inconsequential. You can do this in the pycharm GUI","Q_Score":4,"Tags":"python,pycharm","A_Id":63947067,"CreationDate":"2020-09-17T22:42:00.000","Title":"Why is Pycharm giving me a warning when using the max function with ints and floats vars as arguments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know if a string is a collection of, by example, numbers ([0-9]).\nI this case, i'm using the regular expression [0-9](,[0-9])* to find one or more numbers separated by commas (A collection of numbers).\nIs there a better way to do it? I mean a shorter expression perhaps.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":63948537,"Users Score":0,"Answer":"\\d*(,\\d*)* will catch the situation where you have multiple digits before and after a comma e.g. 100,000. This regex will only grab 0,0 from that same number.","Q_Score":0,"Tags":"python,python-3.x,regex,python-re","A_Id":63948596,"CreationDate":"2020-09-18T02:33:00.000","Title":"Regex: Another way to match structure separated by commas","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Facing issues when trying to downgrade python version from 3.7.3 to 3.6.5_1. I have did lot of research before reaching to stackoverflow family and all of them were suggesting the same resolution steps that i have tried as below, but found no luck. I looking for the python 3.6.5_1 version because Python 3.7 is unsupported by Keras\/TensorFlow and thus are not a good choice for OpenCV either:\nOption 1:\nbrew unlink python\nbrew install --ignore-dependencies https:\/\/raw.githubusercontent.com\/Homebrew\/homebrew-core\/f2a764ef944b1080be64bd88dca9a1d80130c558\/Formula\/python.rb\nError: Calling Installation of python from a GitHub commit URL is disabled! Use 'brew extract python' to stable tap on GitHub instead.\nOption 2:\nbrew switch python 3.6.5\nError: python does not have a version \"3.6.5\" in the Cellar.\nafter couple of tries I realized that it is problem with the git url that homebrew has it to get python 3.6.5_1 version and that would have changed or the commit url might not be the latest.\nmacOS version : Catalina 10.15.6\nSo seeking your guidance and suggestions on how to solve this problem. Also please let me know if missed any info that is required to post here(which could've helped in solving the problem)\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2982,"Q_Id":63948556,"Users Score":10,"Answer":"using brew install sashkab\/python\/python@3.6 works. credit to @Jean-Pierre Matsumoto.","Q_Score":1,"Tags":"python,python-3.x,macos,opencv,homebrew","A_Id":65308770,"CreationDate":"2020-09-18T02:35:00.000","Title":"Unable to downgrade python version in macos using Homebrew","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"While Anaconda is nice, my experience trying to use Visual Studio through Anaconda is a mess. I have just ended up using Spyder which is great but I'd preferably use visual studio.\nCouple of issues:\nI select base conda interpreter in visual studio and proceed to try to import pandas or numpy. This results in an error (AttributeError: module 'tokenize' has no attribute 'Name').\nA couple of days ago it randomly worked and now it's not. running print('hello') works just fine.\nI have no issues with any imports in Spyder but I've started using Flask and it'd be much easier to have it all in one workspace.\nAny understanding why I cannot import pandas.\nEdit: Did a clean reinstall of both and now am able to install numpy. However, I get the error when trying to install pandas. Using 3.8.3. Pandas works in Spyder, not in VS Code.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":63951291,"Users Score":0,"Answer":"Ok so it started working for no apparent reason. I just restarted VS Code through Anaconda and this time it had no issues. As I said, I feel like VS Code is all over the place through Anaconda and not very reliable.","Q_Score":0,"Tags":"python,import,anaconda","A_Id":63952091,"CreationDate":"2020-09-18T07:40:00.000","Title":"Problems using Visual Studio through Anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem, I use the cx_oracle + aiohttp + threadpollexecutor bundle to call a function in the database that checks parameters and insert data into Oracle tables. I noticed a strange feature: the very first request after midnight runs for more than 17 seconds, but all subsequent requests run for 20 milliseconds. The connection pool is not broken and is used as a global variable via a function. What could be the problem and why only the first request behaves like this??","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":64,"Q_Id":63953275,"Users Score":0,"Answer":"Christopher Jones gave you a suggestion. The easiest way to find out for sure is to set the environment variable DPI_DEBUG_LEVEL to the value 4 prior to running your application and redirecting stderr to a log file. Then you can see which ODPI-C function was run immediately after midnight and how long it took. If Chris' suggestion is correct, the likely call will be dpiConn_create().","Q_Score":0,"Tags":"python,oracle,cx-oracle,aiohttp","A_Id":63971393,"CreationDate":"2020-09-18T09:43:00.000","Title":"cx_oracle + threadpool first insert call function slow","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed 'matplotlib' using Anaconda (today).\nI am using 'PyCharm' from the Anaconda interface itself.\nWhen I try to import a package from 'matplotlib', I see other namespaces getting listed. But I do not see 'pyplot'.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":63954250,"Users Score":0,"Answer":"I have been able to get around this by pasting the files in the file system after downloading it from the Github.","Q_Score":1,"Tags":"python-3.x,matplotlib,anaconda","A_Id":63957764,"CreationDate":"2020-09-18T10:44:00.000","Title":"Installed 'matplotlib' using Anaconda. Not finding 'pyplot' in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to integrate external data into a Django app. Let's say, for example, I want to work with GitHub issues as if they were formulated as normal models within Django. So underneath these objects, I use the GitHub API to retrieve and store data.\nIn particular, I also want to be able to reference the GitHub issues from models but not the other way around. I.e., I don't intend to modify or extend the external data directly.\nThe views would use this abstraction to fetch data, but also to follow the references from \"normal objects\" to properties of the external data. Simple joins would also be nice to have, but clearly there would be limitations.\nAre there any examples of how to achieve this in an idiomatic way?\nIdeally, this would be would also be split in a general part that describes the API in general, and a descriptive part of the classes similar to how normal ORM classes are described.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":214,"Q_Id":63955581,"Users Score":0,"Answer":"I would suggest to just use normal OOP principles, Polymorphism, Association etc. to get a similar feel to real models.\nBut I'm not sure I would try to simulate behavior as close as I could, because the ORM is specifically designed for database interaction. I would just write my custom methods.","Q_Score":8,"Tags":"python,django","A_Id":63956356,"CreationDate":"2020-09-18T12:13:00.000","Title":"Building object models around external data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"t-test between two numbers (0.85,0.18) getting p-value as Nan along with the following error:\n\nGetting this error also\n_,p_value=stats.ttest_ind(a=Max,b=Max_1,equal_var=False)\nC:\\Users\\NehaBhakat\\Anaconda31\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3584: RuntimeWarning: Degrees of freedom <= 0 for slice\n**kwargs)\nC:\\Users\\NehaBhakat\\Anaconda31\\lib\\site-packages\\scipy\\stats_distn_infrastructure.py:903: RuntimeWarning: invalid value encountered in greater\nreturn (a < x) & (x < b)\nC:\\Users\\NehaBhakat\\Anaconda31\\lib\\site-packages\\scipy\\stats_distn_infrastructure.py:903: RuntimeWarning: invalid value encountered in less\nreturn (a < x) & (x < b)\nC:\\Users\\NehaBhakat\\Anaconda31\\lib\\site-packages\\scipy\\stats_distn_infrastructure.py:1912: RuntimeWarning: invalid value encountered in less_equal\ncond2 = cond0 & (x <= _a)","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":353,"Q_Id":63957849,"Users Score":2,"Answer":"A t-test is for finding out whether two distributions are in fact coming from the same population. You cannot test for two single values. Hence, getting NaN is correct.\nA distribution means, that you have a vector with values that you measured. To have a meaningful t-test, you should usually have at least 30 values.","Q_Score":0,"Tags":"python,statistics,t-test","A_Id":63957952,"CreationDate":"2020-09-18T14:40:00.000","Title":"T test between two numbers(0.85,0.18) getting p value as Nan","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got the below error when I ran KEYS * on a highly usable Redis server.\nFile \"\/usr\/local\/lib\/python3.7\/site-packages\/redis\/client.py\", line 1394, in set\nreturn self.execute_command('SET', *pieces)\nFile \"\/usr\/local\/lib\/python3.7\/site-packages\/elasticapm\/instrumentation\/packages\/base.py\", line 210, in call_if_sampling\nreturn self.call(module, method, wrapped, instance, args, kwargs)\nFile \"\/usr\/local\/lib\/python3.7\/site-packages\/elasticapm\/instrumentation\/packages\/redis.py\", line 66, in call\nreturn wrapped(*args, **kwargs)\nFile \"\/usr\/local\/lib\/python3.7\/site-packages\/redis\/client.py\", line 755, in execute_command\nreturn self.parse_response(connection, command_name, **options)\nFile \"\/usr\/local\/lib\/python3.7\/site-packages\/redis\/client.py\", line 768, in parse_response\nresponse = connection.read_response()\nFile \"\/usr\/local\/lib\/python3.7\/site-packages\/redis\/connection.py\", line 638, in read_response\nraise response\nredis.exceptions.ResponseError: OOM command not allowed when used memory > 'maxmemory'.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":181,"Q_Id":63958602,"Users Score":1,"Answer":"keys * will scan all keys in Redis database, put all the keys into a in-memory list, and then build the response for the command.\nIf you have a huge amount of keys, it will impact the memory usage significantly, which may cause OOM exception.","Q_Score":0,"Tags":"python-3.x,redis,redis-cluster","A_Id":63961790,"CreationDate":"2020-09-18T15:27:00.000","Title":"How does command 'KEYS *' impact redis memory management?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two machines, a PC and a laptop both using pycharm, running the same script trying to load the same pickle file. On one machine, I can run the script with no problems. On the other computer, I end up with the following error:\nRecursionError: maximum recursion depth exceeded while calling a Python object\nBelow are the versions I'm using:\nDesktop:\npycharm build: #PY-202.6397.98\nPycharm: 2020.2\nInterpreter: Anaconda3: 3.8\nLaptop:\npycharm build: #PY-101.7319.64\nPycharm: 2020.2.2\nInterpreter: Anaconda3: 3.8\nFile Size: 93 KB\nData structure: Dictionary of lists\nBoth devices have more than enough memory, and the file itself isn't even that large. If I increase the recursionlimit, I end up with a stackoverflow memory error, however my available memory is quite high.\nDoes anyone here have any information on why or how this might be happening? I haven't updated anything recently and nothing should have changed. I really am kind of perplexed on this one.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":63960457,"Users Score":0,"Answer":"After some time digging around, I did find an answer to this. It seemed the problem lied between how the file was created and loaded, specifically with the interpreter. Even more specifically, if I used a pickle file created by a virtual environment it would not work with my base Anaconda3 version. By instead having all my machines use virtual environments I was able to correctly consume my pickle files.","Q_Score":0,"Tags":"python,pycharm,pickle","A_Id":64065373,"CreationDate":"2020-09-18T17:39:00.000","Title":"Inconsistencies Loading Pickle File Between Machines","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to understand the following Python line:\nresult = {'key_A': [*dict_A.keys()], 'key_B': \"dummy_string\"}\nResult is dictionary that holds a list in Result['key_A'] and string in Result['key_b']. But I'm not sure why the dict_A.keys() has to be unpacked, only to be put into a list again. Is there a reason for this extra unpacking operation?","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":83,"Q_Id":63961398,"Users Score":-1,"Answer":"The unpacking operator can be used to unpack generators\/objects, so instead of having to do [key for key in dict_A.keys()], a user can use [*dict_A.keys()], as it will get each item of the generator and pack it back into a list. This is also similar to using list(dict_A.keys()).","Q_Score":1,"Tags":"python,list,packing","A_Id":63961485,"CreationDate":"2020-09-18T18:58:00.000","Title":"Is there a reason for unpacking a list then putting it back into a list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to understand the following Python line:\nresult = {'key_A': [*dict_A.keys()], 'key_B': \"dummy_string\"}\nResult is dictionary that holds a list in Result['key_A'] and string in Result['key_b']. But I'm not sure why the dict_A.keys() has to be unpacked, only to be put into a list again. Is there a reason for this extra unpacking operation?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":63961398,"Users Score":4,"Answer":"In Python 3 .keys does not return a list, but a dict_keys object, so if list is required it must be converted.\n[*dict_A.keys()] is equivalent to list(dict_A.keys())","Q_Score":1,"Tags":"python,list,packing","A_Id":63961418,"CreationDate":"2020-09-18T18:58:00.000","Title":"Is there a reason for unpacking a list then putting it back into a list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently installed the Spinnaker SDK and the PySpin library for use with Flir cameras (I followed the instructions on the website). However, when I tried to run the supplied Acquisition.py example file, I got the error \"module 'pyspin' has no attribute 'System'\"\nA few other notes:\n\nFor some reason, when I used pip to install PySpin, the module was installed with the name \"pyspin\" rather than \"PySpin\", even though it was written in the script as PySpin (e.g. import PySpin). Initially the script wasn't even able to find the module until I changed all the library names in the script to the lowercase version.\nI had an unrelated library, also called PySpin, on my computer from before. I used pip to uninstall the old PySpin (python -m pip uninstall PySpin) when I realized this and then reinstalled the \"proper\" library.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1988,"Q_Id":63962448,"Users Score":1,"Answer":"This problem seems to continue to exist: a library called 'pyspin' can be installed via pip, but that's not the correct library for spinnaker-operated hardware: \"PySpin\" - i.e. there seems to be a naming conflict.\nThe 'pyspin' - lowercase, seems to be a library that only generates a spinning text graphic, and nothing else - it has nothing at all to do with FLIR - and that's why you cant access the system etc. calls.\nTypically, the advice to install the FLIR PySpin library seems to be \"go and get the entire spinnaker package from FLIR and install it\", though having done that process upwards of six times, I've still not managed to obtain the correct 'PySpin' library, and as far as I can find out, it's not available anywhere else.\nIf anyone at all can point to a github repo, FLIR repository or anything at all that has the correct 'PySpin' library, please post it here.","Q_Score":0,"Tags":"python-3.x,flir","A_Id":66591355,"CreationDate":"2020-09-18T20:28:00.000","Title":"Running PySpin (FLIR) Example gives Error \"module 'pyspin' has no attribute 'System'\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I managed to install PyQt4 but it install under Python 2.6. How do I get it installed under Python 2.7?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":63966438,"Users Score":0,"Answer":"Try to do it via python2.7 pip install pyqt4","Q_Score":2,"Tags":"python,pyqt4,centos6","A_Id":63966574,"CreationDate":"2020-09-19T07:40:00.000","Title":"How to install PyQt4 to Python 2.7 in Centos 6?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to train my model with 2 GPU(id 5, 6), so I run my code with CUDA_VISIBLE_DEVICES=5,6 train.py. However, when I printed torch.cuda.current_device I still got the id 0 rather than 5,6. But torch.cuda.device_count is 2, which semms right. How can I use GPU5,6 correctly?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":552,"Q_Id":63967302,"Users Score":0,"Answer":"you can check the device name to verify whether that is the correct name of that GPU. However, I think when you set the Cuda_Visible outside, you have forced torch to look only at that 2 gpu. So torch will manually set index for  them as 0 and 1. Because of this, when you check the current_device, it will output 0","Q_Score":0,"Tags":"python,pytorch,gpu,multi-gpu","A_Id":63969178,"CreationDate":"2020-09-19T09:36:00.000","Title":"Pytorch Multi-GPU Issue","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have an NI USB Data Logger. when i plug-in the device, device sends same 10 byte data every 100 ms before opening the software. i captured this data using an USB packet sniffer software.(assume this data is device id). my question is how the device can send data without its software being open? and how can i find out with which endpoint this packets are sending?\nthank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":63969316,"Users Score":0,"Answer":"I can't answer your first question (why a particular device could be sending 10-byte packets before its accompanying application software is launched). There are numerous possibilities that are in line with the USB spec.\nTo your 2nd question, you may use a tracing software like WireShark or Microsoft Event Analyzer (the latter has recently reached EOL, though) to find out what endpoints do the transfers belong to and even decode the content to produce an easily-readable outputs (for devices belonging to standard classes).","Q_Score":1,"Tags":"python,c#,c,usb,libusb","A_Id":64883324,"CreationDate":"2020-09-19T13:24:00.000","Title":"is there a way to send a USB data packet without host permission?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Say if I have a df with columns A,B,C,D.\nI wanted to copy df to df1 columns A and B only based on a condition column C = 1.\nThanks for your help!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":194,"Q_Id":63970543,"Users Score":0,"Answer":"Thanks Scott for your reply.\nThe first option worked!!!\nThe second option is giving error 'expr must be a string to be evaluated, <class 'pandas.core.series.Series'> given\nCode : temp1 = df[['Music', 'Pop', 'Rock']].query(df.Rock == '1.0')","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":63970708,"CreationDate":"2020-09-19T15:42:00.000","Title":"How to copy selected columns from a dataframe to another based on a column condition","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"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":"I recently updated Anaconda (Spyder (Python 3.6), Windows 10). Several of my libaries disappeared and had to be re-installed. However, I have been unable to reinstall scipy. When I run \"conda install scipy -f\" from the Windows PowerShell, scipy seems to be reinstalled. However even if I close Spyder and restat Windows, I continue to get the error: ModuleNotFoundError: No module named 'scipy'.\nI know that problems similar to this one have been posted previously, but I have been unable to find anything that seems to fix  the problems.\nThanks in advance for any advice (and apologies if this question was posted yesterday as well).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":383,"Q_Id":63970885,"Users Score":0,"Answer":"I battled with this same issue. The reason is most likely because you already have a file in the current directory called scipy.py. For example, when I first started with scipy, i made a file literally called scipy.py to practice in. Then, when I tried to import scipy from a different file, the first instance of 'scipy.py' was my practice folder, rather than the actual package which was further into the directory.\nI advise you check for folders that you may have named scipy.py that aren't the actual scipy package. I could be wrong, but it seems likely that python will first search the folder it saves your files to, and then trundle over to the packages folder saved elsewhere.\nHopefully this helps some other folks who are stumped by the same issue!","Q_Score":0,"Tags":"python,installation,scipy,anaconda","A_Id":66583092,"CreationDate":"2020-09-19T16:16:00.000","Title":"Anacaonda\/Windows 10 - ModuleNotFoundError: No module named 'scipy'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Basically I know in Python axis = 0 means row, and axis = 1 means the column.\ndf.isnull().sum(axis = 0) summarize the number of missing values in a column, but\ndf.drop(column, axis = 1) means to drop out a column.\nSo I am quite confused that when does axis = 0 means the rows and why does the second code not using axis = 0?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":647,"Q_Id":63971263,"Users Score":0,"Answer":".sum() is applied along an axis whereas .drop() is applied to an axis.\ndf.isnull().sum(axis = 0) returns the sum of all null cells along axis 0 (rows\/indices), meaning one value per column.\ndf.drop(column, axis = 1) drops column belonging to axis 1.","Q_Score":0,"Tags":"python,pandas","A_Id":63971589,"CreationDate":"2020-09-19T16:54:00.000","Title":"Pandas Question about axis = 0 and axis = 1","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use a python package (openpyxl) to write Excel spreadsheet with formulas. Most functions work, but Excel adds an @ operator before STDEV.S, which resulted in a #NAME? error when the xlsx file is opened. I think it has something to do with backwards compatibility with STDEV. How do I avoid this problem? Thanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":35,"Q_Id":63974499,"Users Score":1,"Answer":"Using \"=_xlfn.STDEV.S()\" seems to work well.","Q_Score":0,"Tags":"python,excel,openpyxl","A_Id":63979538,"CreationDate":"2020-09-20T00:24:00.000","Title":"Excel adds @ operator and gives a #NAME? error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was writing some code in IDLE for Python 3.8 on Mac OSX when it became non-responsive. Unfortunately it had been some time since my last save and I'd like to not lose my data.\nBefore I force quit IDLE, I'm wondering if the file I was working on can be found in some kind of temporary folder? I don't think there is an autosave feature (or if there is I didn't know about it). But I'm hoping that it's still writing the contents of my unsaved work to disk somewhere.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":93,"Q_Id":63974715,"Users Score":1,"Answer":"Short answer. No.  Unless you have a program that can access the memory of other programs, it is likely gone.\nWhen I start a new file, I immediately save it under a new name.  I usually run it after any significant editing to check for SyntaxErrors and runtime NameErrors.  My fingers are too twitchy to want to run a hundred new lines at a time.  If I already have tests, then I save and run them often to check the progress in passing the tests.","Q_Score":0,"Tags":"python,python-3.x,macos,python-idle","A_Id":63977715,"CreationDate":"2020-09-20T01:12:00.000","Title":"Does IDLE have a location for temporarily saving works in progress?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Will python automatically parallelize sorting across all cores?\nSorting a list of objects based on an integer property, which sorts a list of size 2M in ~1.7s. My machine has 16 logical cores and 4 GPUs which I would like to leverage to speedup the sort. I found a couple parallel merge sort implementations online but none seemed popular which is surprising given the parallel hardware available today. Would these implementations be better on machines with 8-16 cores?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":232,"Q_Id":63975543,"Users Score":0,"Answer":"Will python automatically parallelize sorting across all cores?\n\nThere is nothing in the Python Language Specification (or more precisely, the Python Standard Library Specification) that would prevent an implementor from parallelizing either list.sort() or sorted(). There is, however, also nothing in the Python Language Specification or the Python Standard Library Specification that would force an implementor to parallelize either list.sort() or sorted().\nTherefore, it is completely up to each implementation whether they implement them serial, parallel, or print out the list, fax it to Malaysia, and have it hand-sorted in a sweat shop. Also, an implementation is free to change the implementation strategy at any time without warning, as long as it does not violate the invariants guaranteed by the Library Specification. (Which is basically only that the result must be sorted and that the sort must be stable.)\nOr, to answer the question succinctly:\n\nWill python automatically parallelize sorting across all cores?\n\nYou can't know.","Q_Score":0,"Tags":"python,sorting","A_Id":63975955,"CreationDate":"2020-09-20T04:36:00.000","Title":"Is python's builtin sort parallelized?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to export HMM model because training it every time takes time. My method is to save all matrices in file. I want to know is there any tensorflow way I can do it? Also is it possible to export it with api to other languages like C++.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":276,"Q_Id":63975768,"Users Score":1,"Answer":"you can iterate over and save the weights from the model variables by calling variables attribute of tfp.distributions.HiddenMarkovModel()","Q_Score":0,"Tags":"python,tensorflow,tensorflow-probability","A_Id":63984048,"CreationDate":"2020-09-20T05:20:00.000","Title":"Exporting Tensorflow probability's Hidden Markov Model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In a terminal emulator with readline support, I can use key binding Ctrl-X Ctrl-E to bring up $EDITOR to edit a command.\nHow do I do that in iPython to bring up $EDITOR to edit half-finished code?\nP.S. My $EDITOR is set to \"vim -u \".","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":62,"Q_Id":63976712,"Users Score":1,"Answer":"shortcuts used:\n'g' to launch gvim with the content of current cell (you can replace gvim with whatever text editor you like).\nso, when you want to edit the cell with your preferred editor, hit 'g', make the changes you want to the cell, save the file in your editor (and then quit), then press 'u'.","Q_Score":0,"Tags":"ipython,editor","A_Id":63976963,"CreationDate":"2020-09-20T07:49:00.000","Title":"iPython shell - how to use $EDITOR to edit commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have already trained 85 models using ExtraTreeClassifiers and saved them (TO be honest, I cannot remember the python version or Sci-kit version or Anaconda version I was using while training the models). Due to some disk issues I had to replace  hard disk and  install OS(Windows10) again and installed Anaconda3 2020.07(Python 3.8.3 64 bit) now.\nBut now when I try to use this models for prediction purpose I am getting the following warning:\n\nquote\nC:\\Users\\DELL\\anaconda3\\lib\\site-packages\\sklearn\\base.py:313: UserWarning: Trying to unpickle estimator ExtraTreesClassifier from version 0.22.2.post1 when using version 0.23. This might lead to breaking code or invalid results. Use at your own risk.\n\nSo I uninstalled sklearn version 0.23 and installed version 0.22.2. If I do this I get the following warning\n\nquote\nC:\\Users\\DELL\\anaconda3\\lib\\site-packages\\sklearn\\base.py:313: UserWarning: Trying to unpickle estimator ExtraTreesClassifier from version 0.22 post1 when using version 0.22.2. This might lead to breaking code or invalid results. Use at your own risk.\n\nSo I uninstalled sklearn version 0.22.2 and installed version 0.22. If I do this I get the following error:\n\nquote\nERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'C:\\Users\\DELL\\anaconda3\\Lib\\site-packages\\~-learn\\.libs\\vcomp140.dll'\nConsider using the --user option or check the permissions.\n\nBut still it gives me the needed output without any error. If I check the version of sklearn it shows me 0.22 even if there was error installing it.\n\nquote\nC:\\Users\\DELL\\anaconda3\\lib\\site-packages\\sklearn\\base.py:313: UserWarning: Trying to unpickle estimator ExtraTreesClassifier from version 0.22.2 post1 when using version 0.22. This might lead to breaking code or invalid results. Use at your own risk.\n\nAnd this process is going on vice-versa(0.22.2 to 0.22 and 0.22 to 0.22.2) if I install or uninstall accordingly.\nThough that I have seen various answers regarding this warning on Stackoverflow and worked upon as above, somehow I am unable to fix it and keep on getting this warning again and again or may be I am missing something. Even if I install Anaconda 2019.10 (Python 3.7.4 64 bit) this incompatibility issue still persist. I get the required output but at the back of my mind I am doubtful what if the output generated is not correct because of such warnings and incompatible versions. It is not possible to train all these models again due to time constraints or should I forget about warnings and go ahead and do the predictions with the trained models that I have. Please help. Thanks a lot.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":4713,"Q_Id":63976719,"Users Score":3,"Answer":"pip install scikit-learn==0.22.2.post1 resolved a similar issue for me.","Q_Score":4,"Tags":"python,scikit-learn,anaconda,warnings,prediction","A_Id":66484196,"CreationDate":"2020-09-20T07:49:00.000","Title":"UserWarning: Trying to unpickle estimator ExtraTreesClassifier from version 0.22.2.post1 when using version 0.22","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to plot ROC curve for my problem which has 4 classes. I created True and Predicted class lists after training and prediction. Here are my lists.\ntrue_class list :\n[0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 2, 3, 1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 2, 2, 0, 0, 0, 3, 3, 3, 3, 3, 2]\npredicted_class list :\n[0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,\n1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 2, 3, 1, 0, 1, 2, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,\n2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 2, 2, 0, 0, 0, 3, 3, 3, 3, 3, 2]","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":243,"Q_Id":63977453,"Users Score":0,"Answer":"ROC curves are normally plotted with non-thresholded data, see the sklearn implementation for a binary roc curve. There are also some extensions to multi-class roc curves (which also are normally used with non-thresholded predictions) but there are better metrics out there than that.","Q_Score":0,"Tags":"python,python-3.x,keras,scikit-learn,roc","A_Id":63977740,"CreationDate":"2020-09-20T09:31:00.000","Title":"How To Plot Multi Class Roc Curve From True and Predicted Classes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to plot ROC curve for my problem which has 4 classes. I created True and Predicted class lists after training and prediction. Here are my lists.\ntrue_class list :\n[0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 2, 3, 1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 2, 2, 0, 0, 0, 3, 3, 3, 3, 3, 2]\npredicted_class list :\n[0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,\n1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 2, 3, 1, 0, 1, 2, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,\n2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 2, 2, 0, 0, 0, 3, 3, 3, 3, 3, 2]","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":243,"Q_Id":63977453,"Users Score":0,"Answer":"Maybe use a different metric than ROC curves as they don't fit well with the use case.","Q_Score":0,"Tags":"python,python-3.x,keras,scikit-learn,roc","A_Id":63978600,"CreationDate":"2020-09-20T09:31:00.000","Title":"How To Plot Multi Class Roc Curve From True and Predicted Classes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a program that works with selenium, and it automates for posting comment to the some blogs' contents. I'm not familiar with the requests module of python. (working on it for just a week) The thing that I'm wondering is, my program with selenium is a bit slow for page loading, and it loads everything from ads to the images\/videos. If I'd made my program with requests module, would it save data and a bit faster according to the selenium module?\nI searched this issue at some forum-sites, generally they say request modules a bit faster, but not all. Also I couldn't find any info about saving data by comparing this modules?\nPlz don't give me directly the thumbs down. I need this answer with details.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":697,"Q_Id":63977623,"Users Score":0,"Answer":"If you are proficient with HTTP requests and verb (know how to make a POST request to a server with requests library), then choose requests. If you want to test your script, use selenium or BeautifulSoup.","Q_Score":1,"Tags":"python,selenium,python-requests","A_Id":63977703,"CreationDate":"2020-09-20T09:52:00.000","Title":"Comparing request module vs selenium in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a program that works with selenium, and it automates for posting comment to the some blogs' contents. I'm not familiar with the requests module of python. (working on it for just a week) The thing that I'm wondering is, my program with selenium is a bit slow for page loading, and it loads everything from ads to the images\/videos. If I'd made my program with requests module, would it save data and a bit faster according to the selenium module?\nI searched this issue at some forum-sites, generally they say request modules a bit faster, but not all. Also I couldn't find any info about saving data by comparing this modules?\nPlz don't give me directly the thumbs down. I need this answer with details.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":697,"Q_Id":63977623,"Users Score":0,"Answer":"Selenium allows you to control a browser and execute actions on a webpage.\nrequests library is for making HTTP requests.\nSo, if you know how to write your program for posting comments with just using HTTP API then I\u2019d go with requests, Selenium would be an overhead in this case","Q_Score":1,"Tags":"python,selenium,python-requests","A_Id":63977682,"CreationDate":"2020-09-20T09:52:00.000","Title":"Comparing request module vs selenium in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python and I read online that pip is a good tool to install. I searched online on how to install pip and the first step listed was to check if python was installed properly by opening cmd in admin mode and typing python and it took me to the Microsoft store. I searched online about this and I followed some guide to editing PATH  but it did not work. Some other posts said to try typing py and it worked. Then I followed the guide to install a file called get-pip.py. I downloaded it, went into cmd and into the directory where it was downloaded, and typed python get-pip.py and the command prompt just skipped one line. Now I tried pip -V and cmd did not recognize it. So I tried moved the get-pip.py file into where my python.exe file existed and tried py get-pip.exe and got the error C:\\Users\\[*myname*]\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe: can't open file 'get-pip.py': [Errno 2] No such file or directory. Any help would be appreciated and sorry if this has already been asked I couldn't find good solutions.\nThanks in advance","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":63978266,"Users Score":0,"Answer":"The easiest way to install pip is with modifying the python installation.\nStep 1 - Open Apps & Features\nStep 2 - Find Python and click on it\nStep 3 - Press Modify\nStep 4 - Select pip\nStep 5 - Select Add Python to environment variables and install everything\nThat will install pip and add it to your environment variables so you can run pip task in command prompt or powershell from anywhere.","Q_Score":0,"Tags":"python,python-3.x,pip","A_Id":64043279,"CreationDate":"2020-09-20T11:03:00.000","Title":"Trouble with installing pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am new to python and I read online that pip is a good tool to install. I searched online on how to install pip and the first step listed was to check if python was installed properly by opening cmd in admin mode and typing python and it took me to the Microsoft store. I searched online about this and I followed some guide to editing PATH  but it did not work. Some other posts said to try typing py and it worked. Then I followed the guide to install a file called get-pip.py. I downloaded it, went into cmd and into the directory where it was downloaded, and typed python get-pip.py and the command prompt just skipped one line. Now I tried pip -V and cmd did not recognize it. So I tried moved the get-pip.py file into where my python.exe file existed and tried py get-pip.exe and got the error C:\\Users\\[*myname*]\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe: can't open file 'get-pip.py': [Errno 2] No such file or directory. Any help would be appreciated and sorry if this has already been asked I couldn't find good solutions.\nThanks in advance","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":63978266,"Users Score":0,"Answer":"if you are new start using Google Colab first to learn how to code in python most of the packages are already installed and no need to install the basic packages","Q_Score":0,"Tags":"python,python-3.x,pip","A_Id":63978527,"CreationDate":"2020-09-20T11:03:00.000","Title":"Trouble with installing pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am new to python and I read online that pip is a good tool to install. I searched online on how to install pip and the first step listed was to check if python was installed properly by opening cmd in admin mode and typing python and it took me to the Microsoft store. I searched online about this and I followed some guide to editing PATH  but it did not work. Some other posts said to try typing py and it worked. Then I followed the guide to install a file called get-pip.py. I downloaded it, went into cmd and into the directory where it was downloaded, and typed python get-pip.py and the command prompt just skipped one line. Now I tried pip -V and cmd did not recognize it. So I tried moved the get-pip.py file into where my python.exe file existed and tried py get-pip.exe and got the error C:\\Users\\[*myname*]\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe: can't open file 'get-pip.py': [Errno 2] No such file or directory. Any help would be appreciated and sorry if this has already been asked I couldn't find good solutions.\nThanks in advance","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":63978266,"Users Score":0,"Answer":"you may either:\n\ninclude your pip location (\\Python37\\Scripts) into PATH; or\ncall pip by typing whole path, like \\Python37\\Scripts\\pip -v","Q_Score":0,"Tags":"python,python-3.x,pip","A_Id":63984084,"CreationDate":"2020-09-20T11:03:00.000","Title":"Trouble with installing pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"i just installed python on my mac and i had also installed VS code with it. Later i tried installing pygame but it didn't work so i found another version that installed the version that is not stable, or pygame2.0.0.dev6 - i think that is have you type it. So that went succesfull, but after i found out why i was not being able to install the stable version, so now i want to get rid of  pygame2.0.0.dev6 and install the stable version because in my VS code editor it keeps saying that it is using pygame2.0.0.dev6 even when i have the stable version installed.\nPlease all i want is to uninstall pygame2.0.0.dev6. I tried going to the documentation and i tried uninstalling from the terminal itself but i still cannot uninstall it. Help would me much appreciated. Thank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":211,"Q_Id":63979096,"Users Score":1,"Answer":"pip3 uninstall pygame==2.0.0.dev6\nWindows users should use pip instead of pip3\nAlways use virtual environments. This version problem will be mitigated.","Q_Score":0,"Tags":"python,python-3.x,visual-studio-code,pygame,python-3.8","A_Id":63979133,"CreationDate":"2020-09-20T12:43:00.000","Title":"How to get rid of pygame 2.0.0.dev6?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I  try to install gensim through cmd prompt, it gives me following error:\n\n\"ERROR: Could not install packages due to an EnvironmentError:\n[WinError 5] Access is denied:\n'c:\\programdata\\anaconda3\\lib\\site-packages\\pycache\\cython.cpython-38.pyc'\nConsider using the --user option or check the permissions. \"\n\nI'm unable to sort this issue, please help me out!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":181,"Q_Id":63979393,"Users Score":0,"Answer":"Open windows command prompt with administrative permissions (Right-click on cmd and choose Run as administrator option).\n\nor\nTry using the --user flag\nExample :\npip install gensim --user","Q_Score":0,"Tags":"python-3.x,gensim","A_Id":63979448,"CreationDate":"2020-09-20T13:16:00.000","Title":"Unable to install 'gensim'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have about 60 billion records recorded. It has an average size of 980 GB and all in text file. (lines similar to md5 code)\nIs it possible to transfer them to database?\nI wonder if I run into a problem!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":695,"Q_Id":63979585,"Users Score":1,"Answer":"Of course it's possible. You will need to write a script to load the data from whatever format it is in inside your text file into SQL that can be executed against the database server.\nThe problems you are likely to run into:\n\nIf you are using auto-increment, make sure you make it a bigint.\n\nIt will take a long time to load.\n\n\nTo achieve reasonable performance, your loading program should use a prepared statement with bound parameters and commit in batches of 1000-10000.\nOn a modern server with high clock speed and NVMe storage, you might see 10,000 INSERTs per second. At that speed it will take you about 70 days to load your data set.\nTo mitigate failures, you should probably look into creating the table partitioned and splitting the loading into batches in such a way that each batch goes into a different partition. That way if a batch fails, you can truncate that one partition and re-run the failed batch.\nIf you are not familiar with databases and working with data at this scale, you should probably seriously consider hiring a professional with such experience to help you out with this for the ~3 months (or possibly as little as a few weeks, depending on how well stocked their bag of tricks is) it'll take to parse and load all of that data.","Q_Score":0,"Tags":"mysql,mysql-python","A_Id":63979917,"CreationDate":"2020-09-20T13:40:00.000","Title":"MySQL Billion records","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to import another class into python?\nI just started learning python and I don't understand importing. there are two files in one folder. How to import?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":63980485,"Users Score":0,"Answer":"Its really easy.\nIf you want to import a class from another file just write at the start of the file.\nfrom name of the file import name of the class\nRemember to put the two files in the folder. :3","Q_Score":0,"Tags":"python,windows,class,oop,import","A_Id":63980712,"CreationDate":"2020-09-20T15:12:00.000","Title":"How to import another class in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know how to stop lightgbm logging.\nWhat kind of settings should I use to stop the log?\nAlso, is there a way to output only your own log with the lightgbm log stopped?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2542,"Q_Id":63980647,"Users Score":0,"Answer":"Follow these points.\n\nUse \"verbose= False\" in \"fit\" method.\nUse \"verbose= -100\" when  you call the classifier.\nKeep \"silent = True\" (default).","Q_Score":3,"Tags":"python,python-3.x,logging,lightgbm","A_Id":68380380,"CreationDate":"2020-09-20T15:29:00.000","Title":"How can I stop the log output of lightgbm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2018m new to tensorflow have a general question:\nI have a certain amount of training data and want to do a time series prediction.\nThe intervals on my training data is one minute and I want to do a prediction for the following minutes based on the new input data which is provided via a REST API\nWhat I don\u2018t understand is this:\nLet\u2018s say I train the model with all the data till yesterday and this means I can predict the first values of today by a certain amount. But the new values of today have not been observed by the model that has been build yesterday.\nHow would you solve this problem?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":63981716,"Users Score":0,"Answer":"Djboblo,\nI assume that you need to predict whole next day values on per minute basis.\nIn that case your options are:\n\nrecursive prediction, i.e. using predicted data as input for the next prediction\nstructuring the model to provide you with prediction for the whole next day\n\nIf it is just a matter of predicting for a single minute forward and your model is trained on reasonably large amount of data - don't worry, just feed it with the values up to the prediction minute. Periodically you may re-train the model using new data.","Q_Score":1,"Tags":"python,tensorflow,time-series,training-data","A_Id":63984134,"CreationDate":"2020-09-20T17:20:00.000","Title":"Tensorflow continous training from input data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can we interact with temenos t24 TCServer on TCP port using Python libraries like telnet or socket? Has anyone worked on this area?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":231,"Q_Id":63981734,"Users Score":0,"Answer":"You can connect by telnet and then post \"tRun tSS [ofs source]\"\nwhere ofs source is an id from OFS.SOURCE T24 application (in older T24 command: \"tSS [ofs source]\" without \"tRun\"). It allows you to send OFS messages. With OFS you can do almost everything you want in T24 ;)","Q_Score":1,"Tags":"python,jboss,tcserver","A_Id":71040999,"CreationDate":"2020-09-20T17:21:00.000","Title":"T24 Telnet Connection on TCP Port Using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can we interact with temenos t24 TCServer on TCP port using Python libraries like telnet or socket? Has anyone worked on this area?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":231,"Q_Id":63981734,"Users Score":0,"Answer":"Easy to connect with Java. Temenos gives standard java libraries to all clients with examples","Q_Score":1,"Tags":"python,jboss,tcserver","A_Id":64936964,"CreationDate":"2020-09-20T17:21:00.000","Title":"T24 Telnet Connection on TCP Port Using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My goal is to apply GA to find optimum locations to place a number of circles (equal dia) in a 2D plane such that no two circles are closer than a certain distance. I account for the proximity constrain by setting the fitness function to -1 if the constraint is broken but the problem is none of the initial population randomly generated follows the proximity constraint thus making the fitness of all the members -1.\nBy googling, I found that if the plane is separated in to grids with the size of clearance I won't have this problem, but I'm afraid it will miss a lot of potential solution. Is there a method to incorporate the proximity constraint or should I go with the grid?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":194,"Q_Id":63982198,"Users Score":1,"Answer":"Instead of just random, start with a random solution with constraints. Generate one circle, then find the feasible space for next circle, create second circle and continue until you generate entire generation.","Q_Score":1,"Tags":"python,optimization,genetic-algorithm","A_Id":63988925,"CreationDate":"2020-09-20T18:12:00.000","Title":"How to deal with a constraint in Genetic Algorithm when none of the population members obeys it?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make an app that launches different exe's but I have a problem, one app requires to run as admin, so my question is how can I run that app as admin from a python script?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":178,"Q_Id":63983579,"Users Score":1,"Answer":"I used the elevate module in python! That worked! Thanks anyway!","Q_Score":0,"Tags":"python,windows,admin,launcher,python-os","A_Id":64042751,"CreationDate":"2020-09-20T20:56:00.000","Title":"How to run an exe as admin using os module (Windows)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am wondering how to make an entry point to call a python script, similar to black.\ne.g.:\nblack my_script.py\nSay I have a python file called fix_newline.py.\nInstead of calling python fix_newline.py path\/to\/my_script.py in the directory of fix_newline.py, I'd like to assign the name fix_newline to python path\/to\/fix_newline.py.\nThe ultimate goal is to call fix_newline from anywhere in my directory tree, as long as I am in the same environment (e.g. ~\/.bash_profile).","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":63983596,"Users Score":0,"Answer":"Add path\/to to your PATH variable .bash_profile. (If you have a lot of scripts, consider installing them in a fixed location like ~\/bin\/, so that you don't add a lot of unnecessary directories to your PATH.\n\nMake sure you script is executable and has an appropriate shebang.\n\nDrop the .py from the script name.","Q_Score":0,"Tags":"python,python-3.x,alias,argv","A_Id":63983639,"CreationDate":"2020-09-20T20:58:00.000","Title":"How to make alias for python script, similar to black?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I recently did a factory reset on my pc, I installed python and visual studio code, installed some libraries and when I tried to use them visual studio code didn't found those libraries and also, sometimes visual studio code notifies me that I don't have installed pylint but when I click on install it says that there is no Pip installer in the selected environment. I added the python folder and the scripts folder to path and I've searched for the same error I have everywhere and nothing seemed to work. I don't know what to do.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":610,"Q_Id":63983663,"Users Score":0,"Answer":"Okay so the problem was not related mainly to visual studio code, I had one program installed called inkscape that installs python in another path, visual studio code detected that path before the path of where I had python installed. The solution was to uninstall inkscape if someone has a similar problem, I guess I could tell inkscape to not install python or tell visual studio code to not search on another paths but when I tried to do so it didn't work so the easiest solution was uninstalling Inkscape. I also appreciate the help of @JillCheng to isolate the source of the error.","Q_Score":0,"Tags":"python,visual-studio-code,pip","A_Id":63996865,"CreationDate":"2020-09-20T21:04:00.000","Title":"Python Libraries In Visual Studio Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm learning Python through a youtube tutorial and took a break of over a month to deal with life. When I returned and tried to run a program I created along with the instructor in Pycharm (Community 2020.2.1) it gives me this error in the console:\n\nError:Cannot run program\n\"\/home\/user\/PycharmProjects\/HelloWorld\/venv\/bin\/python\" (in directory\n\"\/home\/user\/PycharmProjects\/HelloWorld\"): error=2, No such file or\ndirectory\n\nExcept I can browse to \/home\/user\/PycharmProjects\/HelloWorld\/venv\/bin\/, and see the \"python\" file. Running the file by double-clicking on it returns the following error in Pycharm:\n\nCannot find file\n'\/home\/user\/PycharmProjects\/HelloWorld\/venv\/bin\/python'\n\nWhen I go to create a new project, the New Project window does not list any interpreter. Is that my issue?\nI've tried reinstalling Pycharm and multiple solutions from Stack and other resources without success. I had no issues with Pycharm at all in July. If it matters; this is the Pycharm that's available in the Linux Mint 19.3 Software Manager.\nHow can I fix this? Why would taking a break cause this issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1835,"Q_Id":63984722,"Users Score":0,"Answer":"I've just faced the same issue after I upgraded my macOS to Catalina. In a nutshell, you need to restore broken links in venv and the simplest way to do this is to recreate the Python virtual environment for your project.\nHere's my step-by-step solution:\n\nIn PyCharm go to PyCharm > Preferences... > Project  > Python Interpreter\n\nClick on the settings icon on the right upper corner then select \"Show All...\" in the dropdown menu. \"Python Interpreters\" window should appear.\n\nClick on the \"-\" button on the bottom (it shows \"Remove\" as a hint). Click OK.\n\nNow you should see <No interpreter> on the right side of \"Python Interpreter\".\n\nOpen a terminal. Go to your project folder, find and remove venv subfolder.\n\nReturn to PyCharm. Open the same window (PyCharm > Preferences... > Project  > Python Interpreter).\n\nClick on the settings icon on the right upper corner then select \"Add..\" in the dropdown menu. \"Add Python Interpreter\" window should appear.\n\nSelect \"New environment\", select the correct location (where the removed venv folder was located), select the correct Base interpreter and check \"Inherit global site-packages\" if your project requires it.\n\nProfit!\n\n\nWorked for me with PyCharm 2020.2.2 Community Edition.","Q_Score":1,"Tags":"python,pycharm","A_Id":64362435,"CreationDate":"2020-09-20T23:59:00.000","Title":"Pycharm won't run program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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 have looked all over the internet including here. I have tried all the suggested solutions, but none of them worked.\nHere is the error message I get _mysql.c:44:10: fatal error: 'my_config.h' file not found \nCould the problem come from the fact that my MySQL and Python versions are not compatible?\nMySql version:Ver 8.0.21 for osx10.15 on x86_64 (Homebrew)\nPython version:Python 2.7.16\nCould that simply be it?\nThanks!","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":721,"Q_Id":63990900,"Users Score":1,"Answer":"This solution is for macOS users\nAfter struggling a while on this issue I finally solved it, and it was pretty simple in the end.\nMaybe this will help others too, because I have seen this issue around a lot during my research. There are plenty of solutions out there, that worked for some and not for others. None of them worked for me.\nBefore you go into a copy\/paste of commands rampage in your terminal, you might want to check your MySQL version. Because apparently MySQL only supports the MySQL-python dependency until version 5.7. So I just had to downgrade my MySQL 8 to 5.7, and then I could finally run the pip install MySQL-python command, and it worked!\nSo if you have a MySQL version higher than 5.7, you might want to downgrade.\nTo that, type in these commands in your terminal:\nbrew unlink mysql\nbrew install mysql@5.7\nThen, try mysql --version If mysql is still red, run this command:\nexport PATH=${PATH}:\/usr\/local\/mysql\/bin \nAnd you should finally be able to run:\npip install MySQL-python\nThis worked for me, hope it will for you!","Q_Score":0,"Tags":"python,mysql-python,mysql-connector","A_Id":63994390,"CreationDate":"2020-09-21T10:58:00.000","Title":"MacOS: \"pip install MySQL-python\" returning an error: \"_mysql.c:44:10: fatal error: 'my_config.h' file not found\"","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to build Kivy application in which I need to have a text input field with multiple languages. I have a ComboBox or the kivy drop down to select the language and set the appropriate .ttf file. But the text appearing is not the correct transliteration of the English text input.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":164,"Q_Id":63996371,"Users Score":0,"Answer":"Perhaps try using a codec library. It will convert text of different character sets to be compatible with others.","Q_Score":0,"Tags":"python,python-3.x,kivy,kivy-language","A_Id":64000809,"CreationDate":"2020-09-21T16:28:00.000","Title":"How to use multi-language in text input Kivy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to invoke a docker instance from python subprocess (windows \/ wsl).\nLet's just assume that the docker I need to run is a simple docker run -it busybox (it's not going to be that, but it's a shell for experimenting) but once loaded I need to insert programmatically (asynchronous or blocked, either way is fine) some commands for git to pull some sources and then compile them and deploy them (before invoking docker, I am asking the user to choose a tag from a set of repos).\nSo far using the normal subprocess.Popen I was able to tap in to docker, but I need to have this persistent until I leave docker interactive shell (from busybox).\nIs this possible to be done, or once I get the subprocess done it stops at the next command (as it happens now)?\n(PS I can post some of my code, but I need to clean up some bits first)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":63997490,"Users Score":0,"Answer":"Can you possibly do a simple while loop?  My other thoughts would be if all the commands are the same each time they are called, put them in a batch file and call the batch from python.  All I can come up with without code.","Q_Score":0,"Tags":"python,docker,subprocess","A_Id":63997645,"CreationDate":"2020-09-21T17:46:00.000","Title":"Invoking multiple docker commands via python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I was making a python test file called \".py\" and I tried typing some code. Then, there was no syntax highlighting. Why does that happen? Also, when I changed the name to \"test.py\" there was highlighting. I use idle on windows 10 and I also tried on my dad's computer and naming the file \".py\" didn't have any highlighting.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":63997984,"Users Score":0,"Answer":"naming a file starting with period does some weird things. in linux it is a hidden file and in windows 10 it is a configuration file so it is most likely not recommended.try not to name a file starting with a literal '.' . it makes some weird system calls. so your file is not being syntax highlighted","Q_Score":1,"Tags":"python,python-idle","A_Id":63998158,"CreationDate":"2020-09-21T18:26:00.000","Title":"why does naming a python file \".py\" have no highlighting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So basically I'm being asked in class to solve an inequality -1<(7-x)\/3<=4, and the teacher wants the answer of what will become two sets of code on the same line using solveset.\nSo this ends up being solveset(-1<((7-x)\/3),x,domain=S.Reals) and solveset (((7-x)\/3)<=4,x,domain=S.Reals)\nBut whenever I end up putting & or and in between them to get them on that same line output, I get either the answer to the first OR the answer to the second, which is the complete opposite of what I want. How should I be inputting this?\nI'm using Jupyter Python stuff. Specifically we've imported sympy stuff.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":64000031,"Users Score":0,"Answer":"abc has answered!\n\"solveset(-1<((7-x)\/3), x, domain=S.Reals) & solveset (((7-x)\/3)<=4, x, domain=S.Reals) will correctly give you the solution, i.e., Interval.Ropen(-5, 10) which means [-5, 10)\"","Q_Score":0,"Tags":"python,jupyter,inequalities","A_Id":64000238,"CreationDate":"2020-09-21T21:10:00.000","Title":"How to combine two inequality answers into the same line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't seem to get the requests package to install correctly. Regardless of what I use to actually run my program, I get the same error:\nTraceback (most recent call last): File \"\/Users\/garce\/Desktop\/songlyrics\/getlyrics.py\", line 2, in <module> import requests ModuleNotFoundError: No module named 'requests'\nHowever, I've used pip to install requests. When I run pip show requests in a terminal window, it comes up with this:\nName: requests Version: 2.24.0 Summary: Python HTTP for Humans. Home-page: https:\/\/requests.readthedocs.io Author: Kenneth Reitz Author-email: me@kennethreitz.org License: Apache 2.0 Location: \/Users\/garce\/opt\/anaconda3\/lib\/python3.8\/site-packages Requires: urllib3, idna, certifi, chardet Required-by: Sphinx, jupyterlab-server, conda, conda-build, anaconda-project, anaconda-client\nI assume this is a path issue of some sort, but I can't figure out what's going wrong here. Any idea?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":64,"Q_Id":64001564,"Users Score":1,"Answer":"Are you installing the package globally, or within a pipenv environment? If globally, have you tried pipenv? Not only is it considered best practices, but I find that using pipenv or Anaconda environments often resolves path issues I experience.","Q_Score":0,"Tags":"python,path,pip,python-requests,package","A_Id":64001836,"CreationDate":"2020-09-22T00:36:00.000","Title":"How do I get python requests package to work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have 2 python processes, the first a script that runs an asyncio eventloop forever, and the second that is an HTTP API server, is there a way to access the event loop of the first process to add tasks to it from endpoints of the API server?\nLike a user accesses \/api\/example, and it would add a task, like using loop.call_soon() to the event loop.\nIs this possible when the 2 processes are executed completely separately?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":64001929,"Users Score":0,"Answer":"This is not possible.\nI could imagine (depending on what you want exactly and what these tasks are exactly) some kacks \/ work arounds:\nOne solution, that you could try is, that there is a connection between the two processes (e.g. a TCP  connection, the asyncio process acting as TCP server, the HTTP server acting as client) where the HTTP server sends enough information over to the asyncio server to create the task and add it to its event loop.\nAnother option could be, that the http server creates a python file with the code to execute, notifies the asyncio server via a TCP connection or via a signal (e.g. signal HUP) to check in a given directory for a new file, import it and add it to its loop.\nSecurity wise both solutions are a little tricky, as anybody being able to write a file in the specific directory or anybody being able to connect to the TCP socket might trigger an action.\nBut all depends on your context.\nOr you could try to start the HTTP API server as a thread in the same process as your asyncio process?","Q_Score":0,"Tags":"python","A_Id":64556123,"CreationDate":"2020-09-22T01:37:00.000","Title":"Access Event Loop In Different Process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to install a python package from pypi\nWhich are the differences between installing it directly in the conda enviroment using conda pip install,  and using conda skeleton to build a conda package from the pypi package, and then add install it to the conda enviroment.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":64002450,"Users Score":0,"Answer":"The difference is similar to using Software installer to install packages and apt-get install to install packages in Ubuntu. conda pip transfers whole control to pip for installing the required package whereas, conda skeleton uses functionality of conda itself to do all the necessary work step by step.","Q_Score":2,"Tags":"python,pip,conda","A_Id":64006536,"CreationDate":"2020-09-22T02:56:00.000","Title":"What is the difference between using conda pip install and conda skeleton?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pre-requisites\n\nOS - Centos 7\nPython 3.6.4\nDjango 3.0 (or 3.1.1)\nDjango Rest framework 3.11.1\ndjango-rest-framework-datatables 0.5.0\nApache 2.4\nORACLE 19.1\n\nI have a simple Rest API - which fetches all data from a table in Oracle database. This Django Framework is hosted on Apache webserver. This data is fed into a datatable using the django-rest-framework-datatables.\n\nWhen I fetch data from the API using djangorest framework it works well.\nWhen I fetch data using the template with ?format=datatables as the query parameter the URL is changed and it becomes a very long URL since my table consists of 50-60 columns.\nThus throws a 414 error.\n\nDid anybody else face this error ?\nIt works well with the django's inherent webserver but when used using Django fails.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":64002781,"Users Score":0,"Answer":"Yes, I faced such issue and reconfigured the code to shorten the URI.","Q_Score":0,"Tags":"python,django,apache,django-rest-framework,datatables","A_Id":64185430,"CreationDate":"2020-09-22T03:41:00.000","Title":"django-rest-framework-datatables with Apache shows 414 URI too long error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In a pymongo project I'm working on, in a particular collection, I have to keep uploading name and age of people who will be entering them. I have to identify them with unique ids.\nWhat I as planning to do is start the first id from 1. When inserting data, I first read the whole collection, find the number of records and then save my record with the next id. (eg.  I read, and I find that  there are 10 records, then the id of my new record will be 11).\nBut is there any better way to do it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":28,"Q_Id":64004540,"Users Score":1,"Answer":"MongoDB already assigns unique id to each document which can be sorted in ascending order. If you don't wanna use that then you can create a separate collection which should just contain 1 document with totalRecordsCount. And increment it every time you add new record and get latest number before adding new record. This is not a best way but you will be able to avoid reading whole collection.","Q_Score":0,"Tags":"python,mongodb,pymongo","A_Id":64004645,"CreationDate":"2020-09-22T06:58:00.000","Title":"Pymongo : keep creating new ids","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Environment\nI am running code I found online and it uses the logging library to create logs. I am using python3.6.9 on Ubuntu 18.04. The code is a neural network Tensorflow code, in case that is somehow relevant.\nThe Problem + More Info\nWhen I use vim to open the log files produced it looks like they are in binary.\nUsing the file command in Ubuntu I see that the type of the file is \"data\".\nIn the code the logger is initiated using logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)\nthe file is being saved as a .0 and .1 files, i.e events.out.tfevents.1600700600.mycomputername.21941.1.\nPlease let me know any other information you need me to provide.\nThank you in advance for any help available.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1534,"Q_Id":64004709,"Users Score":1,"Answer":"Most probably the file you open is not one generated by the python logging module because the configuration shown: logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) is just logging stuff to stdout not to a file","Q_Score":0,"Tags":"python-3.x,ubuntu-18.04,python-logging","A_Id":64004794,"CreationDate":"2020-09-22T07:10:00.000","Title":"Read Python Logging Log File in Ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When writing a Python package, I know how to specify other required Python packages in the setup.py file thanks to the field install_requires from setuptools.setup.\nHowever, I do not know how to specify external system dependencies that are NOT Python packages, i.e. a commands such as git or cmake (examples) that my package could call via subprocess.call or subprocess.Popen?\nDo I have to manually check the availability of the commands in my setup.py file, or is there a fancy way to specify system requirements?\nEdit: I just want to be able to check if the external tools are available, and if not invite the user to install them (by themself). I do not want to manage the installation of external tools when installing the package.\nSummary of contributions: it seems that setuptools has no support for this, and it would be safer to do the check at runtime (c.f. comments and answers).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":549,"Q_Id":64005822,"Users Score":4,"Answer":"My recommendation would be to check for the presence of those external dependencies not at install-time but at run-time. Either at the start of each run, or maybe at the first run.\nIt's true that you could add this to your setup.py, but the setup.py is not always executed at install-time: for example if your project is packaged as a wheel then it doesn't even contain the setup.py file at all. And even if you do not distribute your project as a wheel, if I am not mistaken pip tends to build a wheel locally anyway and reuse it for the subsequent installations.\nSo although it would be possible to do such checks as part of the setup script at install time (provided that you can guarantee the presence and execution of setup.py), I would say run-time is a safer bet.","Q_Score":6,"Tags":"python,python-3.x,setuptools,setup.py,python-packaging","A_Id":64028598,"CreationDate":"2020-09-22T08:25:00.000","Title":"How to specify external system dependencies to a Python package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I just installed python (3.8) on my new laptop (windows 10) (including install to PATH).\nOf course I made a test.py script to test whether everything works properly. After opening this file with IDLE and typing print('test') I tried to save and then run. However, when trying to run a pop up opens saying that the file needs to be saved. After clicking ok the pop up closes and nothing happens. I have tried this numerous times to no effect.\nWhen closing the script a pop up opens asking if I want to save before closing. Clicking 'yes' makes the pop up disappear and reappear immediately, which keeps happening until I select 'no'. If I open the file again it is empty.\nI think maybe it could be blocked by my security provider (F-secure), but I can't find where the problem would be. I couldn't find anyone who has had the same problem so I am kind of at a loss of what to do, any help would be appreciated immensely.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":136,"Q_Id":64006210,"Users Score":0,"Answer":"Update:\nI was not able to fix the problem with IDLE, however using the spyder IDE I can save and run .py files.\nIf anyone happens to know a fix I'm still happy to hear it!","Q_Score":0,"Tags":"python-3.x,windows,save","A_Id":64036055,"CreationDate":"2020-09-22T08:51:00.000","Title":"Windows 10 python files don't save","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hey people I built caffe module for nvidia jetson tx2 succesfully. But when I import caffe python throws  no module named caffe error. I have libcaffe.a libcaffe.so libcaffe.so.1.0.0 under the build directory. Where should I copy these files to make sure that python is able to import module.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":64009534,"Users Score":0,"Answer":"When I have compiled from source, after running \"cmake\" I had to:\n\ncd into \"python\" folder (you shloud see the folder in the path you ran the \"cmake\") and run \"pip install -e .\"\nor, you will need to run make install.","Q_Score":0,"Tags":"python,caffe","A_Id":64013576,"CreationDate":"2020-09-22T12:15:00.000","Title":"Location of the built python module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been attempting to install the Pillow (PIL) module into my python(3.8.2) using Windows 10 to no success.\nI have tried executing pip install Pillow as mentioned by the website in my cmd but both pip and python are 'not recognised as an internal or external command, operable program or batch file'\nWhat I have tried:\nReinstalled both pip and python and tried again, with the same problem.\nUsing powershell instead of command prompt (not sure if that makes any difference).\nAlso I understand you can download the Pillow module package in .whl, but I couldn't work out how to install it that way.\nI have also installed pygame using the cmd before which baffles me as to why this is happening.\nAny and all help is appreciated, Thank you!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":292,"Q_Id":64010812,"Users Score":1,"Answer":"If you're sure that you've successfully installed python, but it's not working on your commandline, it may not be in your PATH. Open the search in the windows start menu, and type \"env\" and click on \"Edit Environmental Variables for your system (or choose account if you don't have admin on the system). If you chose system, click on the environmental variables button. You will then be greeted by one window split into two menus, User Variables and System Variables. Scroll down in the User variables and double click on Path.\nGo find the location of your python install with the python.exe file in it (you could search for it in your C:\\ if you're willing to wait). Add that path to the Path variable list.\nIf you can't find the python.exe or just don't want to wait, reinstall your python installation and look for a checkbox with \"Add to Path\" or something along those lines.\nIn addition to the python.exe being in your path, make sure to add the \"Scripts\" folder in your path. It should be a subfolder in the same folder as python.exe.","Q_Score":2,"Tags":"python,python-imaging-library","A_Id":64011044,"CreationDate":"2020-09-22T13:29:00.000","Title":"PIL (Pillow) module install issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a set of co-ordinates(latitudes and longitudes) of different buildings of a city. The sample size is around 16,000. I plan to use these co-ordinates as the central point of their locality\/neighbourhood, and do some analysis on the different neighbourhoods of the city. The \"radius\/size\" for each neighbourhood is still undecided as of now.\nHowever, a lot of these co-ordinates are too close to each other. So, many of them actually represent the same locality\/neighbourhood.\nAs a result, I want to select a smaller sample(say, 3-6k) of co-ordinates that will be more evenly spread out.\nExample:- If two of the co-ordinates are representing two neighbouring buildings, I don't want to include both as they pretty much represent the same area. So we must select only one of them.\nThis way, I was hoping to reduce the population to a smaller size, while at the same time being able to cover most of the city through the remaining co-ordinates.\nOne way I was imagining the solution is to plot these co-ordinates on a 2D graph(for visualisation). Then, we can select different values of \"radius\" to see how many co-ordinates would remain. But I do not know how to implement such a \"graph\".\nI am doing this analysis in Python. Is there a way I can obtain such a sample of these co-ordinates that are evenly distributed with minimal overlap?\nThanks for your help,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":64012695,"Users Score":0,"Answer":"It seems like for your use case, you might need clustering instead of sampling to reduce your analysis set.\nGiven that you'd want to reduce your \"houses\" data to \"neighborhoods\" data, I'd suggest exploring geospatial clustering to cluster houses that are closer together and then take your ~3-4K clusters as your data set to begin with.\nThat being said, if your objective still is to remove houses that are closer together, you can obviously create an N*N matrix of the geospatial distance between each house vs. others and remove pairs that are within (0, X] where X is your threshold.","Q_Score":0,"Tags":"python,analytics,sample","A_Id":64181614,"CreationDate":"2020-09-22T15:16:00.000","Title":"Select a smaller sample of \"uniformly\" distributed co-ordinates, out of a larger population of co-ordinates","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"while building a debug toolbar in Django I am getting an error in file toolbar.js ie.\ns.map: HTTP error: status code 404, net:: ERR_UNKNOWN_URL_SCHEME\ntoolbar.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of \"text\/plain\". Strict MIME type checking is enforced for module scripts per HTML spec.\ncan anyone tell me the possible fix for that?","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":4225,"Q_Id":64013643,"Users Score":3,"Answer":"I have faced the problem and it was fixed after edit the Windows registry. I just Set HKEY_CLASSES_ROOT.js\\Content Type from text\/plain to text\/javascript.\nNow the problem is solved!","Q_Score":11,"Tags":"javascript,python,django","A_Id":67098927,"CreationDate":"2020-09-22T16:10:00.000","Title":"Failed to load module script: The server responded with a non-JavaScript MIME type of \"text\/plain\". Strict MIME type checking i","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"while building a debug toolbar in Django I am getting an error in file toolbar.js ie.\ns.map: HTTP error: status code 404, net:: ERR_UNKNOWN_URL_SCHEME\ntoolbar.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of \"text\/plain\". Strict MIME type checking is enforced for module scripts per HTML spec.\ncan anyone tell me the possible fix for that?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":4225,"Q_Id":64013643,"Users Score":1,"Answer":"I faced the same error. It was resolved once I updated the  HKEY_CLASSES_ROOT.js\\Content Type from text\/plain to text\/javascript in my Windows using RegistryEditor.\nAfter that I had to refresh my browser cache to be able to see the toolbar","Q_Score":11,"Tags":"javascript,python,django","A_Id":68785224,"CreationDate":"2020-09-22T16:10:00.000","Title":"Failed to load module script: The server responded with a non-JavaScript MIME type of \"text\/plain\". Strict MIME type checking i","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have code written in Python3 with dot version of 4 (3.4).\nI want to install latest Python3 onto Windows 10. The latest version is 3.8.\n\nWhen it installs IDLE will also install.\nIs it possible to force Idle to \"use\" specific version? Similar to Java compile for specific\nversion.\n\nI do not want functions to be shown that are not available in 3.4.\nAs an aside, it does not matter what machine is used for IDE and development. Python 3.x behaves the same on Windows as it does on CentOs as it does on Mac?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":64014525,"Users Score":0,"Answer":"Short answer 'No'.\nReason 1a is that if you have, in this instance, 3.4, you also have or can get the 3.4 version of IDLE and can use that.  Admittedly the old version is not as nice as the current version.  But IDLE is currently the same in all 'current' versions, which is now 3.8 to 3.10.  And IDLE for 3.7 is not much different.\nOr 1b, you can edit a file with current IDLE (leaving aside the issues you raised), save it, and run it with 3.4 from (on Windows) Command Prompt.\nThe above assume that 3.4 still exits and runs an on a particular machine.  So 1c, you can try running your 3.4 code with 3.8.  Because we mostly try to not break backward compatibility, it might work as it, or with little change.  This should be especially true of code written by beginners.\nReason 2 is that the IDLE that comes with Python 3.x must be written to run in Python 3.x.  (Actually, the IDLE code is kept almost the same across current versions, so IDLE is currently limited to what runs on 3.8.)  To run your code, Python 3.x is started in a subprocess.  The first code it runs is the 3.x version of idlelib.run, which provides the connection to IDLE in the IDLE process.  For IDLE Shell, it also simulates interactive mode.\nReason 3 is that any attempt to work around reason 2 would be expensive, as it would require paid work and separate test machines.","Q_Score":0,"Tags":"python,python-3.x,python-idle","A_Id":64051091,"CreationDate":"2020-09-22T17:08:00.000","Title":"If I have code in Python3.4 and I install latest Python3, am I able to force IDLE to use specific version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"I am relatively new to python and have been working on pycharm. Recently I began using jupyter notebook and established new PATHS in terminal so I could lunch jupyter from the command line. Ever since then, for some reason I cannot use my already installed modules, such as pandas, numpy or folium on pycharm.\nWhen I run the \"import numpy\" command I get the following error message, please help!:\n\"C:\\Users\\paulov\\PycharmProjects\\The Basics\\venv\\Scripts\\python.exe\" \"C:\/Users\/paulov\/PycharmProjects\/The Basics\/venv\/Notes\/Getting started with folium.py\"\nError processing line 1 of C:\\Users\\paulov\\PycharmProjects\\The Basics\\venv\\lib\\site-packages\\protobuf-3.13.0-nspkg.pth:\nTraceback (most recent call last):\nFile \"C:\\Users\\paulov\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site.py\", line 169, in addpackage\nexec(line)\nFile \"\", line 1, in \nFile \"\", line 553, in module_from_spec\nAttributeError: 'NoneType' object has no attribute 'loader'\nRemainder of file ignored\nError processing line 1 of C:\\Users\\paulov\\PycharmProjects\\The Basics\\venv\\lib\\site-packages\\protobuf-3.13.0-nspkg.pth:\nTraceback (most recent call last):\nFile \"C:\\Users\\paulov\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site.py\", line 169, in addpackage\nexec(line)\nFile \"\", line 1, in \nFile \"\", line 553, in module_from_spec\nAttributeError: 'NoneType' object has no attribute 'loader'\nRemainder of file ignored","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":64014994,"Users Score":0,"Answer":"You might want to check if the python scripts folder are on your Environment Variables.\n\nWinkey + R, to launch run\nType control and hit Enter\nDouble click System\nClick on Advanced system settings\nClick Environment Variables\nOn the system variables, select Path and click Edit.\n\nCheck to see if your scripts location is there\nC:\\Users<username>\\AppData\\Local\\Programs\\Python<PythonVersion>\\Scripts\nC:\\Users<username>\\AppData\\Roaming\\Python<PythonVersion>\\Scripts\nAlso, from what I know, if you are using virtual environments, you would need to install the packages you need for the specific script\/program you are building.","Q_Score":0,"Tags":"python,pycharm","A_Id":64015303,"CreationDate":"2020-09-22T17:37:00.000","Title":"I am having trouble importing modules in pycharm after setting paths for jupyter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"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 want to create datapoints which form non overlapping circle shapes; so far I was able to generate randomly distributed circles but without considering the non-overlapping feature.\nHow can I implement that these circles do not overlap while creating for example 2 (number_circles = 2) of them?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":455,"Q_Id":64018272,"Users Score":1,"Answer":"Draw N centers randomly. For every center compute the distance to the nearest neighbor and assign half that distance as the radius (or a little less). This will ensure no overlap.\n\nNote that you said nothing about the desired distribution of radii and this answer only fulfills the non-overlap constraint.","Q_Score":0,"Tags":"python,image,numpy,geometry","A_Id":64022738,"CreationDate":"2020-09-22T22:03:00.000","Title":"Random circles without overlap in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I understand how gradient descent works and that a user can manually define a gradient descent function to minimize some cost function. My question is very general that where does GD appear in scikitlearn codes when we train and test machine learning models such as linear regression or random forest? Is GD simply embedded in the .fit() function? Or do we need to include it as a parameter to the model?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":62,"Q_Id":64020722,"Users Score":1,"Answer":"Short answer: most of the sklearn models use the stochastic gradient descent for optimization\/fitting. And you never need to specify that. Some functions allow you to specify optimizer (booster in plain language) like adam.","Q_Score":1,"Tags":"python,gradient-descent","A_Id":64020844,"CreationDate":"2020-09-23T03:42:00.000","Title":"Where does gradient descent appear in machine learning libraries (e.g. scikitlearn)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"I have kind a of weird problem where I have a .mat file that comes in a a 10x10 array where each index is a 20x20 array representing a gray image. So I have 10 trials and each trial are a time series with 10 intervals and each interval is tracked as a 20x20 image. In order to run tensor regression on this using tensorly this needs to be formatted as a (trails, time series, x-dim, y-dim) tensor. Is there a clean way to do this? I tried np.reshape on the mat file but that won't work cause the mat file dimensions are 10x10, cause like I said each cell of the array is the 20x20.\nSo for example let's say the mat file is variable name 'mat_var.' Then mat_var[0,0] will be a 20x20 array and mat_var will be a 10x10 array\nGoal is to reshape a 10x10 array where each index is a 20x20 array into a 10x10x20x20 array.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":64023391,"Users Score":0,"Answer":"so apparent if you do tensor = np.full((10,10,20,20),0) then you can set each cell accordingly like\ntensor[x,y] = mat[x,y]\nand it'll just fill the 20x20 if the size of the array is also 20x20","Q_Score":0,"Tags":"python,numpy,tensorly","A_Id":64024496,"CreationDate":"2020-09-23T07:52:00.000","Title":"Python & Numpy - reshape 10x10 array where each cell is 20x20 array into a 10x10x20x20","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am interested in trying to make a machine translation for language accents and is curious for methods avaialable to collect data or how to make your own corpus with unlimited resource. Any good reference i could refer to or ideas?","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":54,"Q_Id":64023394,"Users Score":-2,"Answer":"What kind of realization you need? if it just shell programm, it is easy? if you want GUI(Tkinter) or WEB (Djano) app?","Q_Score":0,"Tags":"python,corpus,machine-translation","A_Id":64023504,"CreationDate":"2020-09-23T07:52:00.000","Title":"Collecting data for machine translation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My deep learning topic is classifying images into 5 different categories. I used the ImageDataGenerator library to split my dataset into train and test.  I've successfully developed a model architecture following the CNN method and evaluated the performance of my model on a test dataset, which gave me an accuracy of 83%.\nIs it possible to apply sklearn evaluation metrics such as precision, recall, f1_score, etc. to evaluate my test results? If yes, how can I do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":64025656,"Users Score":1,"Answer":"Yes you can do it as long as your model is giving out either the class labels or probabilities as it predictions.\nIf your model is predicting the encoded (integer) labels then you can use\nsklearn.metrics.precision_score(y_true, model.predict(test_x))\nOn the other hand if the  model is predictiong the probabilies which is norammly the case then you have to fist convert them into class labels using argmax. So if you have a batch of test_x data then you can use\nsklearn.metrics.precision_score(y_true, np.argmax(model.predict(test_x), axis=1))","Q_Score":0,"Tags":"python,scikit-learn,image-classification","A_Id":64025740,"CreationDate":"2020-09-23T10:11:00.000","Title":"Is it possible to apply sklearn evaluation metrics such as precision, recall, f1_score on my problem?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried deploying my Django website using heroku and used a library called Django-Heroku. When setting my settings.py for deployment, it returns Server Error (500) when setting\nDEBUG = False, importing import django_heroku  and writing django_heroku.settings(locals()) at the last line of my settings.py file. How can I check the settings set by django_heroku that disables my django website for production?\nNote: it does not show any error when setting DEBUG=True and the django app works fine.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":64026191,"Users Score":0,"Answer":"i had this problem too, and it will return you that error for specific template, if you try another template you should see that works, so btw, you need check your template for that specific url, maybe you forget some html element to close your tags! check it, fix it and push it again, it will work!","Q_Score":0,"Tags":"python,django,heroku","A_Id":64027953,"CreationDate":"2020-09-23T10:43:00.000","Title":"Django app does not work when DEBUG=False and using django_heroku","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to make an exe file from several python scripts.\nI have main python file that calls 2 other python scripts. In addition The scripts need few images that present in the same folder.\nHow do i make this whole to a single exe file?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":64026246,"Users Score":0,"Answer":"You can use auto-py-to-exe module of python...","Q_Score":0,"Tags":"python,exe","A_Id":64029214,"CreationDate":"2020-09-23T10:45:00.000","Title":"Convert python scripts with images to exe file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using bokeh server to plot the result from my streaming frames of a video. I see Bokeh provide add_periodic_callback as an auto-update on the server, but I don't know how to pause it. Any suggestion?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":85,"Q_Id":64026596,"Users Score":0,"Answer":"I have solved by passing some global value to track the result of each update. If the global values don't change, then I will pause the update","Q_Score":0,"Tags":"python,bokeh,pandas-bokeh","A_Id":64040027,"CreationDate":"2020-09-23T11:07:00.000","Title":"How to pause bokeh server updating plot based on some condition","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here is the problem:\njson.loads('{\"reg\": \"\\\\\\\\d\"}') yeilds {'reg': '\\\\d'}\nbut:\njson.dumps({'reg': '\\d'}) yeilds '{\"reg\": \"\\\\\\\\d\"}'\nMy question is which input string in json.loads() can I get {'reg': '\\d'}?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":26,"Q_Id":64027388,"Users Score":2,"Answer":"The two values {'reg': '\\\\d'} and {'reg': '\\d'} are actually the same thing. The Python REPL print stage will automatically replace special characters with there escaped equivalent, meaning that a single stored \\ will get printed as \\\\. Also, since \\d isn't a valid string escape sequence, it gets automatically replaced with \\\\d when the string is parsed.\nA recommendation that I have for working with Python regular expression strings is to prefix the string with r, meaning that the \\ character will be treated as a literal for everything except for escaping a quote. For example, using r'\\d' will guarantee that the Python string parser will never interpret \\d as an escape sequence before the Python regular expression parser gets to it. JSON doesn't support raw strings, so you will still have to escape any backslashes found in that file if you are manually editing it.","Q_Score":0,"Tags":"python,json","A_Id":64027618,"CreationDate":"2020-09-23T11:54:00.000","Title":"How do I the valid regex from JSON in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating a database in flask-sqlalchemy. I'd like one of the rows to have an automatically generated integer in increments of one, which I can change dynamically externally. I would like this to not be a primary_key, as the integer will be changed regularly. This number will be used for a queue system. Are there any practical methods I can use for this issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":64028910,"Users Score":0,"Answer":"U can use a global variable to store and update the integer value (or) u can also store the integer in a text file and read and update the integer value from the text file.","Q_Score":0,"Tags":"python,python-3.x,flask,sqlalchemy,flask-sqlalchemy","A_Id":64030560,"CreationDate":"2020-09-23T13:19:00.000","Title":"Generating an automatically incrementing integer in flask-sqlalchemy which is not a primary_key","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I was selecting the port number for a Python backdoor. When I kept a large number like 5979543, it said it was invalid.\nSo... anyway to bypass that restriction?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":20,"Q_Id":64030552,"Users Score":3,"Answer":"So... anyway to bypass that restriction?\n\nNo. The port number in the TCP and UDP header is 16 bit which allows for a maximum port number of 65535. No way to assign a higher port number since it cannot be represented in the communication packets.","Q_Score":0,"Tags":"python,sockets","A_Id":64031878,"CreationDate":"2020-09-23T14:48:00.000","Title":"Can I bypass number-limit while specifying the port for socket library in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had a DataFrame whose memory usage was 159.7 MB. When I used .to_csv method to write it in storage the written file was about 400 MB. And when I loaded this file its memory usage was 159.7 MB. Is there an explanation for this difference in sizes and how to write it so that it takes less space in the hard drive ? Thank you for your help","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":460,"Q_Id":64030576,"Users Score":0,"Answer":"The easiest way to reduce the size of the csv is to compress it when writing, using the compression parameter in to_csv. For example df.to_csv(compression='gzip').\nThere are a variety of reasons the memory usage could be so different from the size of the csv on disk, it's a little hard to say without knowing any specifics about the data you're working with.\nOne generic recommendation is to check the precision of any floating point values in your dataframe, if you're writing a bunch of numbers with 15 decimal points of precision or something that will take up a lot of space. Try truncating these values to the precision you need.","Q_Score":0,"Tags":"python,pandas,dataframe,csv","A_Id":64031232,"CreationDate":"2020-09-23T14:49:00.000","Title":"Pandas .to_csv takes more space than memory usage","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im making a webserver from scratch in python by simply supplying HTML content through a tcp socket. I want to be able to run gwt projects, is this possible by just echoing the contents of the generated index.html to a browser?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":64030792,"Users Score":3,"Answer":"If it is a client-side GWT application, then yes, you could serve it with a basic HTTP webserver that receives HTTP GET requests from a browser and serves files like HTML, JavaScript, images, etc.\nIf the GWT application includes server-side servlets then it wouldn't work when the client sent requests to the server part of the application.","Q_Score":0,"Tags":"python,gwt","A_Id":64056309,"CreationDate":"2020-09-23T15:00:00.000","Title":"Can i run a gwt project without using a webserver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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":"so I am currently trying to automate a windows programm using pywinauto. Unfortunately, the programm is limited to this coorporate (meaning that I cannnot disclose its name or any code that I am writing). My problem, though, is very simple. The programm invovles a communication with a server and getting data from it. When I run the .exe normally the application behaves normally without any errors or problems. Meanwhile, when I try to use pywinauto the moment I try to get any data from the sever I have connection issues and I get no data from the server. As I have little to no information about the inner programming of the application, my question is whether there is any way for a .exe to know it is being run from pywinauto. The app itself looks old (maybe first run for WinXP and barely updated). I have yet to try change my backend when I am trying to automate and also I should try to run it on Python 32-bit insted of Python 64-bit as the app is a 32-bit app. Any info or advice would be avaliable.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":64032362,"Users Score":0,"Answer":"For \u201cwin32\u201d backend 32-bit Python may really help. For \u201cuia\u201d backend it doesn\u2019t matter usually. Other thing could be some lazy initialization that you can\u2019t skip manually because manual action is slower. You can try app.wait_cpu_usage_lower() for such case. For DB-connected apps this is pretty normal situation.","Q_Score":1,"Tags":"python,automation,pywinauto","A_Id":64406658,"CreationDate":"2020-09-23T16:27:00.000","Title":"Pywinauto Windows 10 application behaviour","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I run TPOT to give me suggestions on what algorithm to use for a multi-label text classification? My data is already cleaned and divided into training and testing sets.","AnswerCount":1,"Available Count":1,"Score":-0.3799489623,"is_accepted":false,"ViewCount":154,"Q_Id":64034340,"Users Score":-2,"Answer":"Yes, you can use TPOT for multi-label text classification.","Q_Score":1,"Tags":"python,machine-learning,artificial-intelligence,automl,tpot","A_Id":67609475,"CreationDate":"2020-09-23T18:38:00.000","Title":"Does TPOT support multi-label text classification?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got two DataFrames, count, and percentage with the same columns. count has a multi-level index. I want to use percentage.set_index(....) to make the index of percentage match the index of count. How do I do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":64034517,"Users Score":1,"Answer":"You can use\npercentage.set_index(['col1', 'col2'])\nto make the same columns be the index, but the two tables won't nessecarily have the same index values or sorting. If you if you want to make sure percentage has exactly the same index as count, then after that you can also do\npercentage.reindex(count.index)\nbut note that you'll end up with null values in your data for any index values that are in count but not percentage, and you'll throw away any rows of percentage where the index value doesn't show up in `count.\nEdit:\nIf you want to do this but don't already know the names of the index columns, you can get them with count.index.names.","Q_Score":0,"Tags":"python,pandas","A_Id":64034714,"CreationDate":"2020-09-23T18:51:00.000","Title":"Match multi-index in parallel dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to python GUI and I'm writing a simple game that involves moving an image from one grid cell to another and I don't have to stack an image on top of another image. Therefore to place an image I have to check whether the new location is empty. In addition the image can only be moved either vertically or horizontally. The user clicks the image to be moved and then the location into which to place the image.  I placed each image in a label on an 8x8 board. To check if the move is horizontal or vertical, I check if the row numbers or column numbers of the source and destination are the same respectively. If row number is the same, for instance from position (row=2,column=1) to (row =2, column =4), I want to loop through positions from column =2 to column = 4 and check if there an image or not. If there is an image in any of those cells i.e. (2,2,), (2,3) or (2,4),  then the move is cancelled. But all the functions about grid only show how to get the column and row numbers but don't give any information on how to get the value if I already know the row and column numbers. Can anyone help on how to go about problem?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":64036657,"Users Score":0,"Answer":"I believe the grid method you're looking for is grid_slaves(row, column).\n\nw.grid_slaves(row=None, column=None)\nReturns a list of the widgets managed by widget w. If no arguments are provided, you will get a\nlist of all the managed widgets. Use the row= argument to select only the widgets in one row, or\nthe column= argument to select only the widgets in one column.\n\nNote that although the documentation states to use row= or column=,\nin practice, you can specify both and get the widget(s) in a single grid cell.\nBeing frame the container widget (where the grid is located), calling frame.grid_slaves(row=3, column=2) will give you a list of widgets in that grid cell (or a list with a single item, in case there is only one widget there) or an empty list, if there is none.","Q_Score":0,"Tags":"python,tkinter,grid","A_Id":66271966,"CreationDate":"2020-09-23T21:42:00.000","Title":"how can I retrieve an image from a given grid location if I know the grid row and column in Tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"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 am trying to install a package which uses PEP 517. The newest version of Pip won't allow me to install due to an error involving wheel building for 517.\nIn the past, I've solved this issue by downgrading Pip, installing the package and Upgrading Pip back to the latest version. However, after I downgrade pip in my virtualenv, if I try to run 'Pip install black' I get the No module named 'pip._internal.cli.main' error.\nHow can I solve this?","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":79808,"Q_Id":64038673,"Users Score":0,"Answer":"anyone with Python 3.10 should try to downgrade.\nWas facing the same issue with numpy and pandas installation via pip.\nLast thing that worked was downgrading to Python 3.8.x. (Haven't tried with Python 3.9.)","Q_Score":19,"Tags":"python,python-3.x,pip,virtualenv,pep517","A_Id":69503822,"CreationDate":"2020-09-24T02:22:00.000","Title":"Could not build wheels for _ which use PEP 517 and cannot be installed directly - Easy Solution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install a package which uses PEP 517. The newest version of Pip won't allow me to install due to an error involving wheel building for 517.\nIn the past, I've solved this issue by downgrading Pip, installing the package and Upgrading Pip back to the latest version. However, after I downgrade pip in my virtualenv, if I try to run 'Pip install black' I get the No module named 'pip._internal.cli.main' error.\nHow can I solve this?","AnswerCount":8,"Available Count":5,"Score":-0.0748596907,"is_accepted":false,"ViewCount":79808,"Q_Id":64038673,"Users Score":-3,"Answer":"I have also encountered the same issue when uninstalling and reinstalling miniconda.\nI have no idea why, but in my registry key Computer\\HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Command Processor AutoRun has been set to if exist. I deleted the value then it worked fine just as before.","Q_Score":19,"Tags":"python,python-3.x,pip,virtualenv,pep517","A_Id":69111596,"CreationDate":"2020-09-24T02:22:00.000","Title":"Could not build wheels for _ which use PEP 517 and cannot be installed directly - Easy Solution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install a package which uses PEP 517. The newest version of Pip won't allow me to install due to an error involving wheel building for 517.\nIn the past, I've solved this issue by downgrading Pip, installing the package and Upgrading Pip back to the latest version. However, after I downgrade pip in my virtualenv, if I try to run 'Pip install black' I get the No module named 'pip._internal.cli.main' error.\nHow can I solve this?","AnswerCount":8,"Available Count":5,"Score":0.0748596907,"is_accepted":false,"ViewCount":79808,"Q_Id":64038673,"Users Score":3,"Answer":"When I ran into this error, the problem was that the package I was pulling had its metadata configured incorrectly, which caused building the wheels to fail.\nTo find that error I ran, pip --verbose install <my_package> Which let me see what about the wheel build was failing, and fix it upstream.","Q_Score":19,"Tags":"python,python-3.x,pip,virtualenv,pep517","A_Id":68479910,"CreationDate":"2020-09-24T02:22:00.000","Title":"Could not build wheels for _ which use PEP 517 and cannot be installed directly - Easy Solution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install a package which uses PEP 517. The newest version of Pip won't allow me to install due to an error involving wheel building for 517.\nIn the past, I've solved this issue by downgrading Pip, installing the package and Upgrading Pip back to the latest version. However, after I downgrade pip in my virtualenv, if I try to run 'Pip install black' I get the No module named 'pip._internal.cli.main' error.\nHow can I solve this?","AnswerCount":8,"Available Count":5,"Score":0.1243530018,"is_accepted":false,"ViewCount":79808,"Q_Id":64038673,"Users Score":5,"Answer":"Sometimes this can be due to a cache issue and the no-binary flag won't work. In which case try pip install <insert package names> --no-cache-dir.\nThis seems to be a frequent issue when installing packages with python. First, check to ensure you have activated the virtualenv you think you're supposed to be in, then check to see if you have wheels pkg (pip install wheel if not). If those fail then the --no-cache-dir or --no-binary flags come into play. Reading the pypi documentation on each package could help as well. Best of luck!","Q_Score":19,"Tags":"python,python-3.x,pip,virtualenv,pep517","A_Id":67441295,"CreationDate":"2020-09-24T02:22:00.000","Title":"Could not build wheels for _ which use PEP 517 and cannot be installed directly - Easy Solution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install a package which uses PEP 517. The newest version of Pip won't allow me to install due to an error involving wheel building for 517.\nIn the past, I've solved this issue by downgrading Pip, installing the package and Upgrading Pip back to the latest version. However, after I downgrade pip in my virtualenv, if I try to run 'Pip install black' I get the No module named 'pip._internal.cli.main' error.\nHow can I solve this?","AnswerCount":8,"Available Count":5,"Score":0.0748596907,"is_accepted":false,"ViewCount":79808,"Q_Id":64038673,"Users Score":3,"Answer":"Posting an answer as reference for future searchers here.\nI tried installing Pillow and got this error. Tried many different approaches, none of them worked.\nThen i downgraded Python (From 3.9) to 3.8 and just tried installing by pip again, then it worked.\nIf it fails for you, try downgrading Python, and it may work.","Q_Score":19,"Tags":"python,python-3.x,pip,virtualenv,pep517","A_Id":65219079,"CreationDate":"2020-09-24T02:22:00.000","Title":"Could not build wheels for _ which use PEP 517 and cannot be installed directly - Easy Solution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run many spiders with my scrapy. Does that make the crawling process slower or is there any limit for spiders to run? Is running many unlimited spiders makes the process slow ?\nIs there anyone who is experienced with Scrapy?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":62,"Q_Id":64039937,"Users Score":1,"Answer":"You can run multiple spiders concurrently and no, it will not make the process slower.","Q_Score":0,"Tags":"python,django,scrapy","A_Id":64040064,"CreationDate":"2020-09-24T05:13:00.000","Title":"Is there any limits for running multiple spiders with scrapy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm getting an error: twilio.base.exceptions.TwilioRestException: HTTP 401 error: Unable to create record: Authenticate.\n\nif anybody could help me then would be much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2331,"Q_Id":64040084,"Users Score":0,"Answer":"I also faced the same problem while trying their tutorial, what seemed to be the error was that the value of auth_token  was given under square brackets as  ['*******************']. Removing the square brackets and keep it as a string solved it for me.","Q_Score":1,"Tags":"python,django-rest-framework,twilio,twilio-api","A_Id":64725394,"CreationDate":"2020-09-24T05:29:00.000","Title":"TwilioRestException: HTTP 401 error: Unable to create record : Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using drf-yasg to generate open API, what I want is once I have added the token for authentication it should be persistent and should not expire when user refreshes the page. Currently if user refreshes the page the token gets lost and user again needs to enter the token again and again after any single change.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":438,"Q_Id":64040385,"Users Score":2,"Answer":"When using drf-yasg, you can configure settings in SWAGGER_SETTINGS in your settings.py.\nadd 'PERSIST_AUTH': True into SWAGGER_SETTINGS would work.","Q_Score":1,"Tags":"python-3.x,django,django-rest-framework,swagger,swagger-ui","A_Id":70461306,"CreationDate":"2020-09-24T06:03:00.000","Title":"drf-yasg - How to customize persistent auth token?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For example, ClamWin.exe is installed in the \"ClamWin\" folder, which contains a lib and bin folder, however just using \"Path\".parent returns me the bin folder,  I will to go all the way up to the ClamWin folder and ensure that it will work for the other applications\neg Minecraft.exe in Minecraft folder\navp.exe in the kaspersky folder\nUsing python","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":64040836,"Users Score":0,"Answer":"If it is only used on windows, I think you can consider using the registry to obtain the path: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Bandizip.exe\nIf you get the parent folder recursively until you reach 'Program Files', this may not be universal","Q_Score":0,"Tags":"python,python-3.x","A_Id":64040926,"CreationDate":"2020-09-24T06:42:00.000","Title":"How do I get the base parent folder of an installed application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"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 am still getting used to PVLIB and figuring out how to use the methods associated with it. I'd like to be able to model the growth of localised hotspots in a PV module due to current mismatch that results from partial shading.\nI'd be surprised if I was the first person to do this, so I'm wondering what other solutions exist to do this in a straightforward way from PVLIB.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":92,"Q_Id":64044030,"Users Score":1,"Answer":"You can use the single-diode model functions from pvlib to build up the electrical simulation for this scenario, and thereby determine how much electrical power the affected cell absorbs.\nThere isn't a thermal model in pvlib to tell you how hot it would get, but as a first approximation you could adapt one of the existing module\/cell temperature functions quite easily.  There is a local variable called heat_input to which you can add the electrical power.","Q_Score":1,"Tags":"python,pvlib","A_Id":64059837,"CreationDate":"2020-09-24T09:57:00.000","Title":"Can PVLIB be used for hotspot modelling?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"I have a list of 30 data frames (each of length 53x3) named arr. Now I have to bind all these dataframes into 1 dataframe along row. So the new length of Data frame will be (53x30=1590).\nHow to do it in Python?\nIn R, I use rbind function.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":64046655,"Users Score":0,"Answer":"Only thing was concat\nA = pd.concat(arr)","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":64058144,"CreationDate":"2020-09-24T12:40:00.000","Title":"Bind a list of some dataframe into 1 dataframe in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a column in a dataframe that has some blanks (which appear as 'nan'). How do I replace those blanks with the string 'none'?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":64047421,"Users Score":2,"Answer":"You should use fillna: df[col].fillna('none')","Q_Score":0,"Tags":"python,dataframe","A_Id":64047500,"CreationDate":"2020-09-24T13:23:00.000","Title":"How to replace the blanks in a column of a dataframe with another value?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I have:\n\nPackage A that we will call BaseObjects in what follows\nProject B that installs BaseObjects as a dependency and defines subclasses for some classes defined in BaseOjects\nProject C that installs BaseObjects as a dependency but does not have access in any way to Project B\n\nLet's call one of the classes defined in BaseObjects: Point. Another class is called Line that takes as attributes 2 Point instances p1 and p2.\nPackage B implements a class PointB(Point). The objects PointB are therefore also instances of BaseObjects.Point.\nWhile in an environment related to Project B, I create an object Line that uses 2 PointB objects. I do all sort of operations with the special methods that PointB implements.\nI now want to pickle this Line object so that it can be loaded in Project C. To that purpose, I cannot keep the PointB instances. I therefore need to \"reclass\" them to be of the type of the superclass only. I do p1.__class__ = Point and p2.__class__ = Point. I check that: isinstance(p1, PointB) evaluates to False, same for p2.\nTherefore, I thought that the object pickled this way will be readable from Project C as it has the dependency to BaseObjects which defines the class Point.\nIt isn't the case. When I load the pickle file in Project C, it looks for the folder in which I defined the subclasses in Project B. However, as I dig through the object, I do not find any link. All the objects are said to be of type BaseObjects.<class_name>\nWhat's wrong in my process of getting rid of this object's dependency to Project B? Is there a way to see all the dependencies of an object?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":64054251,"Users Score":0,"Answer":"After a few extra hours digging through this problem, what I describe in the question works perfectly. My issue appeared in a much more complex object with many attributes referring to many other classes. One of those attributes had kept a dependency. This was a non-problem, but learnt a lot on the way!\nA good way of finding if the problem comes from a remaining dependency is to implement what is described in the question. Some extremely simple objects that relate to each other in the simplest way possible. If that simple example does not work the problem comes from somewhere else. If it works, it means that there is a dependency left in the object you are trying to load.","Q_Score":2,"Tags":"python,oop,object,dependencies","A_Id":64056090,"CreationDate":"2020-09-24T20:53:00.000","Title":"Object dependency remains although seemingly independent","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In PyCharm, I know that you can use the 'split pane' option to open one file in two panes.\nBut how do you concurrently open two files side by side?  E.g. stack.py and test_stack.py?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1724,"Q_Id":64055932,"Users Score":3,"Answer":"First, use split panel. After that, you can move any open files from one panel to the other by dragging and\/or you can put the cursor in one panel and open a file as usual. The file will be opened in that panel.\nIf you split using either \"split vertically\" or \"split horizontally\" the file will be in both panels (you can close one of them) but there is also \"split and move down\" and \"split and move right\" actions.\nGood shortcuts to know for this is Ctrl+Shift+A for actions (then write \"split\" and choose what you want) and Ctrl+Shift+N for easily opening files.","Q_Score":0,"Tags":"python,pycharm","A_Id":64056034,"CreationDate":"2020-09-24T23:56:00.000","Title":"In PyCharm, how to open two files side by side","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In PyCharm, I know that you can use the 'split pane' option to open one file in two panes.\nBut how do you concurrently open two files side by side?  E.g. stack.py and test_stack.py?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1724,"Q_Id":64055932,"Users Score":1,"Answer":"In PyCharm:\n\nOpen two files, say stack.py, and test_stack.py.  They will open in two tabs.\nLet's say we want to open test_stack.py in the right pane.  Right-click on the test_stack.py tab, and choose \"Split and Move Right\".","Q_Score":0,"Tags":"python,pycharm","A_Id":64056099,"CreationDate":"2020-09-24T23:56:00.000","Title":"In PyCharm, how to open two files side by side","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am completing a task involving NLP and transformers. I would like to identify relevant features in a corpus of text. If i was to extract the relevant features from job description for instance the tools that would be used at the job (powerpoint, excel, java, etc..) and the level of proficiency required would this task be better suited for a Named Entity Recognition model or a Question Answering model.\nIf I was to approach it like a NER task I would attach a label to all the relevant tools in the training data and hope it would generalize well. I could approach the problem simialrly as a QA model and ask things like \"what tools does this job require\" and supply a description as context.\nI plan to use the transformers library unless I am missing a better tool for this task. There are many features I am looking to extract so not all may be as simple as grabbing keywords from a list (programming languages, microsoft office etc...).\nWould one of these approaches be a better fit or am I missing a better way to approach the proble.\nAny help appreciated. Thank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":716,"Q_Id":64057111,"Users Score":3,"Answer":"From what you say, it seems it an entity recognition task. However, the questions you should ask and answer yourself are:\n\nHow will your user interact with the model?\n\nStructured information \u2192 Entity recognition.\nChatbot \u2192 QA.\n\n\nIs there a predefined set of entities that you are going to extract from the text?\n\nYes \u2192 entity recognition.\nNo \u2192 QA.\n\n\nHow do the training data you have for finetuning look like?\n\nOnly a few of them \u2192 Entity recognition.\nPlenty of data, question-answer pair \u2192 QA.","Q_Score":1,"Tags":"python,nlp,extract,named-entity-recognition,transformer","A_Id":64133467,"CreationDate":"2020-09-25T02:51:00.000","Title":"How to decide between NER and QA Model?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a pandas dataframe which has a column called filenames which contains the names which will be used to save certain objects into csv files. However, many of them contain illegal characters like \u201c?\u201d Or \u201c\/\u201c, is there a quick way to remove all of them ?\nI tried dataframe['filenames'] = dataframe['filenames'].str.strip('?\/')  but nothing happens. The characters are still there, what\u2019s the more efficient and safe way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":275,"Q_Id":64059429,"Users Score":2,"Answer":"I will do this. You can add as many characters as you want.\ndataframe['filenames'] = dataframe['filenames'].str.replace('?|\/', '', regex=True)\nYou need to separate characters you want to remove by '|'.","Q_Score":1,"Tags":"python,regex,pandas,dataframe,strip","A_Id":64059593,"CreationDate":"2020-09-25T07:08:00.000","Title":"Remove illegal file name characters from pandas dataframe column using python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a remote kernel on a cluster, which I connect to using Spyder. For this, I start my kernel on the cluster with python -m spyder_kernels.console &. Then I copy transfer the *.json file that is created in the runtime directory of jupyter to my local computer, then connect through Spyder using the .json file to the kernel on my cluster. This works very well.\nWhen wanting to shut it down again, I issue exit in the console in spyder, which appears to shut down the kernel (at least in my local Spyder window). However, when I check for processes running on the cluster, multiple processes keep on running on the cluster. So far, I issued SIGTERM to them through htop to stop them.\nHow do I cleanly shut down the remote kernel so that no processes keep running?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":364,"Q_Id":64059606,"Users Score":0,"Answer":"(Spyder maintainer here) Unfortunately, it's not possible to shutdown nor interrupt remote kernels at the moment (October 2020).\nThat has to do with some tricky issues with the Jupyter architecture (we use the same architecture as Jupyter to run code) that we've been unable to sort out, sorry.","Q_Score":1,"Tags":"python,kernel,spyder","A_Id":64312007,"CreationDate":"2020-09-25T07:20:00.000","Title":"Shutting down a remote kernel from Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Python 3.6.9 followed by Torch (version 1.5.1+cpu) and PyProj (version 1.9.5.1), but I cannot install PyProb. If I try\npip install pyprob\nI get the error\nComplete output from command python setup.py egg_info:\nPython 3.5+ is required.\nCommand \"python setup.py egg_info\" failed with error code 1 in \/tmp\/pip-build-Teq5Q6\/pyprob\/\nWhy do I get the message \"Python 3.5+ is required\" when I have Python 3.6.9?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19,"Q_Id":64062356,"Users Score":0,"Answer":"Try this pip install pyprob==1.0.0\ni use python3.6.0 and pip install pyprob works for me.","Q_Score":0,"Tags":"python,installation","A_Id":64062438,"CreationDate":"2020-09-25T10:30:00.000","Title":"Cannot install PyProb","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying out the TensorFlow 2.0 Object Detection API, while I am trying to export the inference graph I get an error stating tensorflow.python.framework.errors_impl.NotFoundError: Failed to create a NewWriteableFile: .\\exported-models\\my_mobilenet_model\\checkpoint\\ckpt-0_temp_8cca890901704d9b9c1a0c5e959235fc\/part-00000-of-00001.data-00000-of-00001.tempstate144711528486123721 : The system cannot find the path specified. ; No such process [Op:SaveV2] \nI run the command: python .\\exporter_main_v2.py --input_type image_tensor --pipeline_config_path .\\models\\my_ssd_mobilenet_v2_fpnlite\\pipeline.config --trained_checkpoint_dir .\\models\\my_ssd_mobilenet_v2_fpnlite\\ --output_directory .\\exported-models\\my_mobilenet_model\nI do have a folder name exported-models in the directory I am running the command","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1242,"Q_Id":64065110,"Users Score":5,"Answer":"There is a limitation on the whole path length (<260). Pls. check your path to save the model, and you can manually try if you can create a folder as shown above, if not, pls. try to change the output_directory to another short path.","Q_Score":3,"Tags":"python,tensorflow,deep-learning,object-detection","A_Id":65030911,"CreationDate":"2020-09-25T13:29:00.000","Title":"Python Failed to create a NewWriteableFile (tensorflow.python.framework.errors_impl.NotFoundError: Failed to create a NewWriteableFile: )","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a script for my company that randomly selects employees for random drug tests. It works wonderfully, except when I gave it to the person who would use the program. She clicked on it and a message popped up asking if she trusts the program. AFter clicking run anyways, AVG flagged it two more times before it would finally load. I read someone else's comment saying to make an exception for it on the antivirus. The problem is, I wrote another program that reads other scripts and reads\/writes txt files, generates excel spreadsheets and many other things. I'm really close to releasing the final product to a few select companies as a trial, and this certificate thing is going to be an issue. I code for fun, so there's a lot of lingo that goes right by me. Can someone point me in the right direction where I can get some information on creating a trusted program?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1221,"Q_Id":64071408,"Users Score":1,"Answer":"If anyone else is having this problem, I stumbled on a solution that works for me.\nI created an Install Wizard using Inno Setup. Before I could install the software (My drug test program), it got flagged, asking me if I trust the software. I clicked \"run anyway\" and my antivirus flagged it two more times. After the program was installed. it never flagged me again. Since my main program will probably be used by 100-200 people, I'm completely fine having to do that procedure once. However, for a more \"professional\" result, it's probably work investing in certificates.","Q_Score":6,"Tags":"python,certificate,pyinstaller","A_Id":64108083,"CreationDate":"2020-09-25T21:15:00.000","Title":"Generate a certificate for .exe created by pyinstaller","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So a bit of a broad question here.\nBasically, I have designed and built a program that runs on my machine, using Python. The problem is when I turn it into an exe and try to run it on another windows 10 machine, it doesn't work.\nThe reason is because on my machine, I have python installed, python VLC installed and also the VLC player. Is the issue that I somehow need to package these programs (dependencies? Yes, I'm a noob) into the installation wizard or?\nWould love some advice on what to do here as I'm working on a sentimental project for someone and it's really frustrating that I can't get it to work lol","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":64072175,"Users Score":0,"Answer":"You should not bundle VLC for many reasons even if that technically doable. The cleanest solution would be to check if VLC or the VLC player is installed and tell user to install it first if it's missing.","Q_Score":1,"Tags":"python,windows","A_Id":64072326,"CreationDate":"2020-09-25T22:47:00.000","Title":"Trying to make my program deliverable to a windows 10 environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to selenium and while I was going through the docs and saw the below passage.\n\n5.2. Implicit Waits\n\n\nAn implicit wait tells WebDriver to poll the DOM for a certain amount of time when trying to find any element (or elements) not immediately available. The default setting is 0 (zero). Once set, the implicit wait is set for the life of the WebDriver object.\n\nDoes this mean that you cannot have multiple different implicit wait times in a program? Can you use implicit wait multiple times without it messing with the program?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":64073645,"Users Score":1,"Answer":"You can have multiple driver.implicitly_wait() in your program with varying waits.","Q_Score":1,"Tags":"python,selenium","A_Id":64073738,"CreationDate":"2020-09-26T03:43:00.000","Title":"Are Selenium Implicit Wait times immutable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here is my code:\ndriver.find_element_by_xpath(\"\/\/*[text()='Supreme\u00ae\/Vanson Leathers\u00ae Worn Leather Jacket']\", \"\/\/*[text()='Dark Purple']\") .click()\nBasically, I'm trying to use two two pieces of text to click on one object. However, I'm getting the error below:\nTypeError: find_element_by_xpath() takes 2 positional arguments but 3 were given\nHere's the HTML content of the website for reference:\n<a class=\"name-link\" href=\"\/shop\/jackets\/hfxyzecg4\/e6ap8ojhd\">Supreme\u00ae\/Vanson Leathers\u00ae Worn Leather Jacket<\/a>\n<a class=\"name-link\" href=\"\/shop\/jackets\/hfxyzecg4\/e6ap8ojhd\">Dark Purple<\/a>\nAny way to get around this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":64073959,"Users Score":0,"Answer":"Each <a> anchor tag in HTML refers to a link. You can click on any one anchor tag at any point of time.\nIn Selenium any find_element method like find_element_by_id or find_element_by_xpath will allow to accept only one argument i.e., that elements value.\nUse the appropriate link you want click according to your flow and use that xpath in the find_element_by_xpath","Q_Score":0,"Tags":"python,selenium,xpath","A_Id":64076781,"CreationDate":"2020-09-26T04:38:00.000","Title":"I'm trying to get Selenium to click on one object using XPath on two different pieces of text, but there's an error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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":"My dataset contains columns describing abilities of certain characters, filled with True\/False values. There are no empty values. My ultimate goal is to make groups of characters with similar abilities. And here's the question:\n\nShould i change True\/False values to 1 and 0? Or there's no need for that?\nWhat clustering model should i use? Is KMeans okay for that?\nHow do i interpret the results (output)? Can i visualize it?\n\nThe thing is i always see people perform clustering on numeric datasets that you can visualize and it looks much easier to do. With True\/False i just don't even know how to approach it.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1359,"Q_Id":64077136,"Users Score":2,"Answer":"In general there is no need to change True\/False to 0\/1. This is only necessary if you want to apply a specific algorithm for clustering that cannot deal with boolean inputs, like K-means.\nK-means is not a preferred option. K-means requires continuous features as input, as it is based on computing distances, like many clustering algorithms. So no boolean inputs. And although binary input (0-1) works, it does not compute distances in a very meaningful way (many points will have the same distance to each other). In case of 0-1 data only, I would not use clustering, but would recommend tabulating the data and see what cells occur frequently. If you have a large data set you might use the Apriori algorithm to find cells that occur frequently.\nIn general, a clustering algorithm typically returns a cluster number for each observation. In low-dimensions, this number is frequently used to give a color to an observation in a scatter plot. However, in your case of boolean values, I would just list the most frequently occurring cells.","Q_Score":2,"Tags":"python,dataset,data-science,cluster-analysis","A_Id":64153006,"CreationDate":"2020-09-26T11:28:00.000","Title":"How to perform clustering on a dataset containing TRUE\/FALSE values in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get the terminal size using the function shutil.get_terminal_size().\nThis works well in a Python console or an Ipython console, but not in the Ipython console inside the Spyder editor, and I don't understand why.\nAny ideas ?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":64080939,"Users Score":0,"Answer":"(Spyder maintainer here) Spyder consoles are not \"real\" consoles, i.e. they are not based on the same technologies as those used in terminal-based consoles (such as cmd.exe or Terminal.app). Therefore, shutil.get_terminal_size() doesn't work as expected.\nActually, our console's width is fixed at 80 characters and right now (October 2020) that limit can't be changed.","Q_Score":1,"Tags":"python-3.x,terminal,size,spyder,shutil","A_Id":64308497,"CreationDate":"2020-09-26T18:00:00.000","Title":"How to get terminal size in Spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project where we would like to export data from a set of complex multi sheet Excel files in Sharepoint. There are multiple tables as well as single kpi values to be extracted from each other Excel file.\nThe data will fit into the data model (of another database) we already have in SQL Server using an ID value present in the Excel file and SQL Server tables. All data is then consumed in a PowerBI report.\nI have considered using powerapps, power automate or Azure Functions to achieve this. I have experience with Azure Functions but not the other two. I am proficient in Python and SQL so I would prefer using those languages if possible.\nOther database types than SQL Server are also fine so long as the ID value is present it will be easy to join the data to the tables existing in the SQL Server database inside PowerBI.\nMy question is what would be the easiest, most user friendly way of achieving this? As much should be automated as possible but the issue with using Excel as an initial data source is that one small change in the Excel file, or data type may cause the automated process to fail. The inherent, breakable nature of excel files means that all it would take would be for one person to change something and the whole system is down, requiring additional work and money to fix it.\nDoes anyone have experience if a similar project?\nI thought a power app would be easy to make and include in PowerBI. The main KPIs could be manually entered but this would be an annoying and boring task for the user.\nUsing functions could pick up a a change or addition of a file in Sharepoint, extract the data using python and dump the data into SQL or any other database. But this is open to being broken by changes in the Excel file.\nCheers","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":64082139,"Users Score":0,"Answer":"One trick I've done in such situations is to build INSERT SQL statements per row as a formula in the excel file itself using Excel string functions. You can hide the column from users. If the user adds columns, the formula will still work as Excel will handle rewriting it. It's easier to extract a single column from each tab you care about, as you can find it by the header name you choose.\nThis also works for quick-and-dirty one time manual data loads.","Q_Score":0,"Tags":"python,sql-server,excel,azure,powerbi","A_Id":64082353,"CreationDate":"2020-09-26T20:17:00.000","Title":"Export data from Excel to SQL Server and report","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"ok, I'm really confused...\nThere seems to be a fair few posts on this, but are all outdated as I have tried about 15 different python bots and code sections and cant get them to work.\nIt seems that the API's have changed in the past year and thus every developer who had a working bot is now left unable to.\nI'm confused at to why, as there are services like Later .com and others that allow people to post to their instagram account. So there has to be a programmable way to do this.\nI had a look at the API docs for their API but I can only seen to find 2 and none of them allow posting to your profile:\n\nInstagram Graph API\n\n\nThe API can be used to get their media, manage and reply to comments on their media, identify media where they have been @mentioned by other Instagram users, find hashtagged media, and get basic metadata and metrics about other Instagram Businesses and Creators.\n\nThis only says get their media, not publish.\n\nInstagram Basic Display API\n\n\nThe API can be used to access any type of Instagram account but only provides read-access to basic data. If you are building an app that will allow Instagram Businesses or Creators to publish media, moderate comments, identify @mentioned and hashtagged media, or get data about other Instagram users, use the Instagram Graph API instead.\n\nThis one says should I want to publish media then I should go to the Instagram Graph API, again which doesnt say I can publish.\nLet's say for the sake of this convo that the one I should use is the Instagram Graph API. The requirements for this are:\n\nBefore you can switch your app to Live Mode you must complete the App Review process. You can begin the process in the App Review > Permissions and Features tab within the App Dashboard. All Instagram Graph API permissions except for pages_show_list require App Review approval.\n\n\nOnce you complete App Review you will be asked to complete Business Verification. You must complete verification before your app will be able to use Advanced Access Levels.\n\nAll I want to do is automate the posting of my personal instagram account so I can bulk edit photos and do all that in one day without having to create a full working live app that people can use or a business.\nPlease, for the love of all that is automation, please point me in the right direction to do this..","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":439,"Q_Id":64084202,"Users Score":0,"Answer":"With the new Facebook Graph API, you can make an Instagram post. But this API, hence the post functionality, works only with the Instagram Businesses and Creators users.\nIn your case, just switch to the Creators account.","Q_Score":2,"Tags":"python,automation,instagram,instagram-api","A_Id":65346143,"CreationDate":"2020-09-27T02:25:00.000","Title":"How to programatically post to instagram","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"ok, I'm really confused...\nThere seems to be a fair few posts on this, but are all outdated as I have tried about 15 different python bots and code sections and cant get them to work.\nIt seems that the API's have changed in the past year and thus every developer who had a working bot is now left unable to.\nI'm confused at to why, as there are services like Later .com and others that allow people to post to their instagram account. So there has to be a programmable way to do this.\nI had a look at the API docs for their API but I can only seen to find 2 and none of them allow posting to your profile:\n\nInstagram Graph API\n\n\nThe API can be used to get their media, manage and reply to comments on their media, identify media where they have been @mentioned by other Instagram users, find hashtagged media, and get basic metadata and metrics about other Instagram Businesses and Creators.\n\nThis only says get their media, not publish.\n\nInstagram Basic Display API\n\n\nThe API can be used to access any type of Instagram account but only provides read-access to basic data. If you are building an app that will allow Instagram Businesses or Creators to publish media, moderate comments, identify @mentioned and hashtagged media, or get data about other Instagram users, use the Instagram Graph API instead.\n\nThis one says should I want to publish media then I should go to the Instagram Graph API, again which doesnt say I can publish.\nLet's say for the sake of this convo that the one I should use is the Instagram Graph API. The requirements for this are:\n\nBefore you can switch your app to Live Mode you must complete the App Review process. You can begin the process in the App Review > Permissions and Features tab within the App Dashboard. All Instagram Graph API permissions except for pages_show_list require App Review approval.\n\n\nOnce you complete App Review you will be asked to complete Business Verification. You must complete verification before your app will be able to use Advanced Access Levels.\n\nAll I want to do is automate the posting of my personal instagram account so I can bulk edit photos and do all that in one day without having to create a full working live app that people can use or a business.\nPlease, for the love of all that is automation, please point me in the right direction to do this..","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":439,"Q_Id":64084202,"Users Score":0,"Answer":"The instagram API does not support uploading images.\nI too was frustrated with how much effort one has to invest to discover this.  After all, posting an image seems like a fundamental use case for an API.  I wish there was a FAQ page, or bold disclaimer that makes it clear.\nThere are projects on github that support posting to Instagram in unsupported ways (e.g. using a \"private\" api, or simulating the Instagram app).  I haven't personally used any of these solutions, but wanted to mention they exist.","Q_Score":2,"Tags":"python,automation,instagram,instagram-api","A_Id":64091366,"CreationDate":"2020-09-27T02:25:00.000","Title":"How to programatically post to instagram","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This is a simple data visualization task that I am trying to accomplish: seeing data in real time using my web browser.\nMy idea is to take an HTML template and change only a few key values inside of it once a second using Python. I need it to be HTML and not something else like pygtk because CSS formatting is very practical for my application.\nIs that possible? What would be the easiest way?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":142,"Q_Id":64085042,"Users Score":0,"Answer":"the Flask module should solve your problems","Q_Score":0,"Tags":"python,html,user-interface","A_Id":64085070,"CreationDate":"2020-09-27T05:12:00.000","Title":"How to create an HTML page that refreshes in real time using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to execute a shell command, for e.g \"ls\" in a different directory from my python script. I am having issues changing the directory directly from the python code from subprocess.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":627,"Q_Id":64086194,"Users Score":1,"Answer":"To add to tripleees excellent answer, you can solve this in 3 ways:\n\nUse subprocess' cwd argument\nChange dir before, using os.chdir\nRun the shell command to the exact dir you want, e.g. ls \/path\/to\/dir OR cd \/path\/to\/dir; ls, but note that some shell directives (e.g. &&, ;) cannot be used without adding shell=True to the method call\n\nPS as tripleee commented, using shell=True is not encouraged and there are a lot of things that should be taken into consideration when using it","Q_Score":0,"Tags":"python,subprocess","A_Id":64086862,"CreationDate":"2020-09-27T08:00:00.000","Title":"How to run shell commands in different directory using python subprocess command?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"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":"I am trying to upload a video using the youtube data api but for some reason am getting the error down below, the keywords I'm using are:\n\n['ski mask the slump god x blueface type beat', 'ski mask the slump\ngod x tyga type beat', 'ski mask the slump god x jasiah type beat',\n'ski mask the slump god x bbno type beat', 'ski mask the slump god x\njid type beat', 'ski mask the slump god x type beat', 'ski mask the\nslump god x splurge type beat', 'ski mask the slump god x zotiyac type\nbeat', 'ski mask the slump god x smokepurpp type beat', 'ski mask the\nslump god x comethazine type beat', 'ski mask the slump god x gunna\ntype beat', 'free type beat 2020', 'free dreamy beat']\n\nThe error is:\n\nb'{\\n  \"error\": {\\n    \"code\": 400,\\n    \"message\": \"The request\nmetadata specifies invalid video keywords.\",\\n    \"errors\": [\\n\n{\\n        \"message\": \"The request metadata specifies invalid video\nkeywords.\",\\n        \"domain\": \"youtube.video\",\\n        \"reason\":\n\"invalidTags\",\\n        \"location\": \"body.snippet.tags\",\\n\n\"locationType\": \"other\"\\n      }\\n    ]\\n  }\\n}\\n'\n\nUnless I am bling my keywords do not appear to contain any special characters, any double whitespaces, neither are they over 500 characters long. I have not found any documentation on what are classified as invalid keywords either, so I am kinda stumped here as to what is causing the problem.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":166,"Q_Id":64087393,"Users Score":0,"Answer":"Having more than three words in a \"keyword\" also appears to throw this error.","Q_Score":3,"Tags":"python,youtube,youtube-data-api","A_Id":72167379,"CreationDate":"2020-09-27T10:26:00.000","Title":"What does the youtube data api classify as invalid keywords?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to upload a video using the youtube data api but for some reason am getting the error down below, the keywords I'm using are:\n\n['ski mask the slump god x blueface type beat', 'ski mask the slump\ngod x tyga type beat', 'ski mask the slump god x jasiah type beat',\n'ski mask the slump god x bbno type beat', 'ski mask the slump god x\njid type beat', 'ski mask the slump god x type beat', 'ski mask the\nslump god x splurge type beat', 'ski mask the slump god x zotiyac type\nbeat', 'ski mask the slump god x smokepurpp type beat', 'ski mask the\nslump god x comethazine type beat', 'ski mask the slump god x gunna\ntype beat', 'free type beat 2020', 'free dreamy beat']\n\nThe error is:\n\nb'{\\n  \"error\": {\\n    \"code\": 400,\\n    \"message\": \"The request\nmetadata specifies invalid video keywords.\",\\n    \"errors\": [\\n\n{\\n        \"message\": \"The request metadata specifies invalid video\nkeywords.\",\\n        \"domain\": \"youtube.video\",\\n        \"reason\":\n\"invalidTags\",\\n        \"location\": \"body.snippet.tags\",\\n\n\"locationType\": \"other\"\\n      }\\n    ]\\n  }\\n}\\n'\n\nUnless I am bling my keywords do not appear to contain any special characters, any double whitespaces, neither are they over 500 characters long. I have not found any documentation on what are classified as invalid keywords either, so I am kinda stumped here as to what is causing the problem.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":166,"Q_Id":64087393,"Users Score":1,"Answer":"I believe YouTube requires the total keywords characters length to be less than 400 (approx). Seems like you have 484 characters in total here, try to reduce the number of keywords you specify","Q_Score":3,"Tags":"python,youtube,youtube-data-api","A_Id":64088513,"CreationDate":"2020-09-27T10:26:00.000","Title":"What does the youtube data api classify as invalid keywords?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to figure out if there is any way to get the class name of some element when the user clicks on the element with selenium.\nThe way this would work is\n\nThe user opens a webpage with selenium\nThe user clicks on an element in the opened browser\nthe respective class name of the element is returned to the user\n\nI know we can search for elements in a webpage with their ids or classes using driver.find_element_by_id or driver.find_element_by_xpath but can we do the reverse with selenium?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":178,"Q_Id":64087956,"Users Score":0,"Answer":"you mentioned user clicks on an element using selenium.\nIn that case, I would assume you already know the element to click on.\nAnd therefore can use element.getAttribute(\"class\") to get the class Name of the object.","Q_Score":0,"Tags":"python,selenium,markup,classname","A_Id":64088759,"CreationDate":"2020-09-27T11:30:00.000","Title":"Is there any way to get the class name of an element on click with selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create my training, validation and testset from one dataframe with\na proportion of 6:2:2.\nBut additionally within each set, I'd like to have a proportion\nof 6:4 between the 2 labels. Among the original dataframe this 6:4 proportion is\nnot given, one label is massively overrepresented.\nMaybe I should adjust that in advance?\nI think sklearns train_test_split() might be an option but to be honest\nits documentation did not make me any wiser...\nAre there any best practices for this kind of problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":64090601,"Users Score":0,"Answer":"When you have an imbalanced dataset, you can use the parameter 'stratify' in the train_test_split(). This will make the dataset be split into training and test sets in such a way that the ratio of the class labels in the variable specified is constant i.e. both train and test set will have the same ratio of class labels.","Q_Score":0,"Tags":"python,pandas,dataframe,scikit-learn,dataset","A_Id":64099220,"CreationDate":"2020-09-27T16:12:00.000","Title":"Splitting dataframe into multiple ones according to proportion of samplesize and labels","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to understand the behavior of cache in pyspark\n\nIs df.cache() anyway different that df = df.cache() ?\n\nIs it absolutely necessary to unpersist the cached dataframe at the end of program execution, I understand its cleared by spark based on (Least Recently used mechanism),and what can be negative impacts if I don't unpersist a dataframe, I can think of out of memory issues but need inputs\n\nIs it possible that when I use df = df.cache(), the re-execution of the program uses the old cached data, rather than recalculating and overriding the cached dataframe ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":141,"Q_Id":64092149,"Users Score":1,"Answer":"No need to unpersist at the end. stopping spark will clear the cached dataframes.\nYou cannot persist from one spark execution to another one. If you want to \"persist\" from one Spark to another, the only solution is to physically save your data (write) and read them again at the next execution.","Q_Score":1,"Tags":"python,apache-spark,pyspark","A_Id":64120980,"CreationDate":"2020-09-27T18:53:00.000","Title":"Pyspark:Need to understand the behaviour of cache in pyspark","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python.\nI created a simple Selenium bot that basically runs on a while loop.\nHowever, it runs on an external machine that I do not have access at all times.\nIt runs into unexpected crashes sometimes, and it takes hours and sometimes days until I check it again only to find a crashed bot. With that said, I'd like to know if a monitoring module or program I can implement into my bot, so I can easily check if the program is running or not.\nSome have suggested a WebSocket heartbeat, however, I do not know, after extensive research, how I would go about implementing such an intricate system. Thank you for taking the time to read my question.\nAny answers appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":64092971,"Users Score":0,"Answer":"You can just put a few lines of code at the appropriate point in your script (after the Selenium bot completes its work successfully) to write the current date and time into a file.\nA second script can be scheduled just to read that file and ring an alarm bell (e.g. send you an email) if it is X hours since the timestamp was last updated.\nAlternatively you could write a timestamp to a database table or use whatever other shared systems you have.","Q_Score":2,"Tags":"python,selenium,web-scraping,monitoring","A_Id":64109028,"CreationDate":"2020-09-27T20:24:00.000","Title":"Is there a python module to indicate if the .py is running?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a guitar amp simulator.\nI want to be able to read audio as input, and simultaneously play it, like a real guitar amp.\nCouldn't find a lead on how to do this.\nWhat python library is able to do that?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":64093119,"Users Score":0,"Answer":"Have you tried the Mido or a similar MIDI library?","Q_Score":0,"Tags":"python,audio,audio-streaming","A_Id":64093165,"CreationDate":"2020-09-27T20:39:00.000","Title":"Python - Reading audio input and playing it simultaneously in real time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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 have a fully functioning jupyter notebook (.ipynb) file that can find and import both pandas and numpy.  I also have that same exact code saved as a .py file in the same exact folder.\nWhen I try to run the .py file with VSCode or Python Shell, I get an error message saying that numpy and pandas can't be found and aren't on path.\nNot sure how the .ipynb file right next to it can find these modules but the .py file can't.\nAny help would be much appreciated.  (The .ipynb file runs through anaconda)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":64095062,"Users Score":0,"Answer":"Since you are hosting jupyter notebook from conda it can easily use the same environment and able to find the pandas and numpy. Try import the same py file in jupyter notebook you will be able to execute the code. You need to specify python path to environment variables which is pointing towards the one which jupyter is pointing.","Q_Score":0,"Tags":"python,python-3.x,pandas,numpy,path","A_Id":64095221,"CreationDate":"2020-09-28T02:02:00.000","Title":"Pandas and Numpy missing from path - Python\/Pyinstaller","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here is the error below that keeps appearing after I run the python script:\n\nThe MATPLOTLIBDATA environment variable was deprecated in Matplotlib 3.1 and will be removed in 3.3.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":64098145,"Users Score":0,"Answer":"That's not an error.  It's just a warning message.","Q_Score":0,"Tags":"python","A_Id":64098505,"CreationDate":"2020-09-28T08:00:00.000","Title":"MATPLOTLIBDATA environment variable was deprecated","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to read a file in pandas where the longitude column is of the format like this- 10559E53 (105 degrees 59 minutes East 53 seconds).\nWhen I print this data frame, python converts this to an exponent, something like 1.0559e+57. How can I stop this conversion?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":64100246,"Users Score":1,"Answer":"The dtype parameter to read_csv should be useful. Probably something like dtype={'longitude': str} (not tested).","Q_Score":0,"Tags":"python,pandas","A_Id":64100847,"CreationDate":"2020-09-28T10:17:00.000","Title":"Stop conversion of Longitude column to exponent while reading a file with pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using sklearnIntentClassifier in Rasa for intent classification. I want to check how this classifier has built the boundaries for different classes(here intents) using matplotlib with my training data.\nI could not see any inbuilt functionality for such task in Rasa.\nPlease help!\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":64100317,"Users Score":0,"Answer":"great idea, however calculating the decision boundaries are not always simple. Enabling this is something we're currently working on. Unfortunately, I cannot give a timeline when this feature will become available.","Q_Score":0,"Tags":"python,machine-learning,multiclass-classification,rasa-nlu,rasa","A_Id":64116439,"CreationDate":"2020-09-28T10:22:00.000","Title":"How to visualise boundaries created by sklearnIntentClassifier using matplotlib in Rasa","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is the uses_after keyword in a pod tells me, what should happen as an aggregation method on all the results of shards defined in uses, that ran in parallel? So it should have access to all the results, that were given by the pods defined under uses?\nSo the tail_pea should get all the results of the parallel peas as for example in the ReduceAllDriver in the hello-world example, right?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":64102738,"Users Score":0,"Answer":"First, let me clarify three uses here. uses is defined at Pea level; uses-after and uses-before are defined at Pod level.\nSo when you define uses-after, uses-before and uses at Pod level, the assignment would be:\n\nhead_pea gets uses_before,\ntail_pea gets uses_after\nall replicas (aka parallel peas) get uses\n\nIn the current ReduceDriver implementation, __call__ is called 4 times but reduce is called only one time.","Q_Score":2,"Tags":"python,microservices","A_Id":64102739,"CreationDate":"2020-09-28T13:02:00.000","Title":"In Jina, when is `uses_after` in `Pod` applied?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have suddenly started getting this error in my SQL client, and I really do not understand what's going on.\n\n[08001] Could not create connection to database server. Index 5 out of\nbounds for length 5\n\nThe app that I am working on is using Laravel 6, running on Homestead. I can still connect to server DBs, however I now cannot connect to any local DBs. My OS is Ubuntu 20.04 My DB client is Datagrip.\nIt was working fine until this started, and I haven't changed anything on my OS - I did install the mysql-connector-python package, but in a virtual env. I have uninstalled that and deactivated the venv, but still having the issue.\nI am wondering if I've done my virutal env wrong, and the mysql-connector-python package has made an OS change which I'm now unable to fix.\nAny help on the matter would be of great help, as I can't find much info about this specific error anywhere.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":384,"Q_Id":64104154,"Users Score":0,"Answer":"I was able to connect to the Homestead box using the box's IP Address, default MYSQL port, and the default Homestead DB username and password.\n192.168.10.10:3306\nusername: homestead\npassword: secret\nIt should work the same with you as well. I'm also on Ubuntu and using Datagrip.","Q_Score":1,"Tags":"python,mysql,database,homestead,datagrip","A_Id":65267418,"CreationDate":"2020-09-28T14:26:00.000","Title":"08001] Could not create connection to database server. Index 5 out of bounds for length 5 - SQL error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am going to try to keep this as specific as possible but it is kind of a general question as well. I have a heavily skewed dataset in the order of { 'Class 0': 0.987, 'Class 1':0.012 }\nI would like to have a set of classifiers that work well on such datasets and then create an ensemble learner of those models. I do not think I want to oversample or undersample. I definitely dont want to SMOTE because they don't scale well for high dimensional data\/ or result in a very large number of data points. I want to use a cost sensitive approach to creating my classifiers and hence came across the class_weight=balanced parameter in the scikit-learn library. However, it doesn't seem to be helping me much because my F1 scores are still very terrible (in the range of 0.02 etc.) I have also tried using sklearn.utils.class_weight.compute_class_weight to manually calculate the weights, store them in a dictionary and pass it as a parameter to the class_weight parameter, however I see no improvement in F1 score and my False Positives are still very high(around 5k) and everything else quite low(less than 50). I don't understand what I am missing. Am I implementing something wrong? What else can I do to tackle my problem? When I change my evaluation metric from f1_score(average='binary') to f1_score(average='weighted') the F1 score increases from ~0.02 to ~98.66, which I think is probably wrong. Any kind of help including references to how I could tackle this problem will be very helpful.\nI am trying to implement XGBOOST, CATBoost, LightGBM, Logistic Regression,SVC('linear'),Random Forest Classifiers","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":371,"Q_Id":64104692,"Users Score":0,"Answer":"I realized that this question arose due to pure naivete. I resolved my problem by using the imbalanced-learn Python library. Algorithms like imblearn.ensemble.EasyEnsembleClassifier are a godsend when it comes to heavy imbalanced classification where the minority class is more important than the majority class. For anyone having troubles like this I suggest trying to find a different algorithm other than your usual favorites that will help you solve your problem.","Q_Score":0,"Tags":"python,scikit-learn,classification,data-science,imbalanced-data","A_Id":64209326,"CreationDate":"2020-09-28T14:59:00.000","Title":"Cost Sensitive Classifier fails for heavily imbalanced datasets","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"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\u2019m trying to deploy my dash app on EBS. I currently reference a local directory (on my machine) as \u2018C:\\users\\me\\projects\\superstar\\assets\\database.db\u2019\nMy dash app.py is in the superstar folder. I\u2019ve tried changing this to \u2018\/assets\/database.db\u2019, but the code is unable to find the file.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":64108819,"Users Score":0,"Answer":"My problem was that the app.py file was not in the root directory.  Once I moved it there, accessing '\/assets\/database.db' worked fine.","Q_Score":0,"Tags":"python,plotly-dash,amazon-ebs","A_Id":64252301,"CreationDate":"2020-09-28T19:57:00.000","Title":"How do I reference a local file when moving to a remote server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Let say that we have around 3M document of one page each. I want to import all the text in a MySQL database. For what I'm reading, I can add it in as a text field (65535 characters).\nMy challenge is this, we are receiving documents on a daily basis that is slightly or identical to one of the 3M documents we have. Is there a way or structure that can search a block of text in MySQL text when the input text is not identical? I need to know if we have one or multiple documents that are closely matching the one received. In a perfect world, I would like to have a result of the one that is closer in match to the search text...\nThe resulting mechanism to do this could include MySQL and Python as a solution. I can't find anywhere what could be the best approach to do this and that doesn't take forever to search.\n[Edited 2020-09-29]\nFrom what I have found for the moment, it looks like a good direction for that type of problem could be to use Elasticsearch as sabik pointed out.\n[Edited 2020-12-14]\nWe finally have given a try to ElasticSearch and it's definitely a good solution.\nOne thing that we found not perfect is the fact that we want to search in the documents but if no document is close enough we wanted to have a similar score and it looks like this is not how it work. It always returns a document and the score is irrelevant. We will probably compare manually the best match to the searched document to have our own similarity score.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":64112212,"Users Score":0,"Answer":"Some time ago I tried to do something like this with MySQL and then I found SQL SERVER FILESTREAM.\nI save the document in a field of binary type varbinary(max), which takes up less space and the search is very fast.\nMaybe now you can see if MySQL has something similar to FILESTREAM, I haven't researched it recently.","Q_Score":0,"Tags":"python,mysql,elasticsearch","A_Id":64113747,"CreationDate":"2020-09-29T02:56:00.000","Title":"MySQL storing and searching for text","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using ubuntu 20.04 and the default version of the python is 3.8. I installed python 3.5 and gcc-5 myself as they were needed for building a project.\nWhen I use python3.5 setup.py build develop it gives a silly error (i.e., ImportError: No module named 'numpy').","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":51,"Q_Id":64118444,"Users Score":1,"Answer":"When you're using 2 versions of Python, you have to be careful where the packages are installed. In this case, I would make sure numpy is installed on Python 3.5. You should be using the pip that comes with 3.5 NOT 3.8 otherwise numpy will be installed on python 3.8. Something like pip3.5 install numpy might fix your issue (if pip is labeled that way, if not find the install folder and directly reference the pip executable like path\/to\/pip3.5 install numpy).","Q_Score":0,"Tags":"python-3.x","A_Id":64118502,"CreationDate":"2020-09-29T11:13:00.000","Title":"build a project with python 3.5 while system python is 3.8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"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 am doing a simple binary text classification, and my label data are already in the format 0 and 1. I am wondering if I still need to perform a one-hot encoding so that they're in a [0,1] and [1,0] format?\nWhen I feed the labels into my Keras Sequential() model as  <class 'numpy.ndarray'> , it works for the model and I get decent accuracy. But I still wonder if I should one-hot encode them beforehand?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":175,"Q_Id":64118767,"Users Score":3,"Answer":"It should not be helpful for binary cases because a binary column already has two values. If you encode a binary to two columns, you will add one more extra binary column to columns that is not informative.\nTherefore, it is not meaningful to hot-encode a binary column and causes a not useful redundancy in your context.","Q_Score":0,"Tags":"python,machine-learning,keras,nlp,one-hot-encoding","A_Id":64120117,"CreationDate":"2020-09-29T11:34:00.000","Title":"One-hot encoding labels for binary text classification that are already 0s and 1s?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So basically I am creating an app with BeeWare(Python). And I wanted to know whether it is possible to change the default icon of beeware and toga and use my own icons. If it is possible, then please someone provide a solution for it.\nThanks.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":414,"Q_Id":64119895,"Users Score":-1,"Answer":"If you have made an android app and it is in your PC then to do so you will need winrar application just right click on it and choose open with and select winrar (or whatever unzipping tool you have) and browse to the resources folder and there are many folders there, there in the last 4 to 5 folders there is an image you have to replace them with an image of same format and resolution, if you replace then with some other format or resolution your application would not work..\nThanks","Q_Score":1,"Tags":"python-3.x,beeware","A_Id":64461831,"CreationDate":"2020-09-29T12:43:00.000","Title":"how to change the application icon of an app in beeware, python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing a hierarchical cluster-analysis of a dataframe with python Scipy, and was wondering if the clustering is column-wise-oriented or row-wise-oriented? I get different results depending on whether I transpose the dataframe or not before calculating the distance matrix.\nI read somewhere that the \"standard\" for clustering is to do it column-wise, however I can't seem to find anything about this in the scipy-documentation.\nAnyone who knows?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":64120443,"Users Score":0,"Answer":"For anyone who's wondering the same thing; basic testing with a simple dataframe showed that it is row-wise","Q_Score":0,"Tags":"python,scipy,hierarchical-clustering","A_Id":64126386,"CreationDate":"2020-09-29T13:17:00.000","Title":"Column- or row-wise hierarchical clustering using Scipy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to delete python executable file after it finishes? I have tried the following:\n\nos.remove() - deleting the python exe file\nos.chmod() - removing the readOnly\nos.getcwd - combined with os.remove()\nshutile.rmtree - combined with os.getcwd()\nsys.argv[0]\n\nAll of these works when I still use .py extension, but when I convert it to exe it gives me permission error. How do I remove it?\nI want to delete the main.exe because I'm going to distribute it to my friends. I don't want the program to stay inside their system permanently that's why I decided to create an auto-delete script.\nThe code I'm running revolves under pyqt5.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":686,"Q_Id":64121273,"Users Score":0,"Answer":"I would start with ensuring that what you are trying to do is what you actually need. If you provide more details about your real purpose, probably we could find a better solution without using strange workarounds and\/or crutches to solve your problem\nIn Windows 10 it is not possible to remove an executable when it is running (no matter whether you are trying to remove the file from the inside or the outside of the executable), this is why you are getting permission error with the .exe file. Probably there is some workaround which would use some special Windows-only features (because as far as I'm concerned it's not possible to do what you are asking about with libraries such as threading\/multiprocessing), but if you really want to do this, the easiest way I see is using another executable intended specifically to delete the executable which calls it after the original executable finishes.\n\nBut, again, this is not a good solution and to be honest, I don't think there is a perfect one, because your goal seems an anti-pattern to me","Q_Score":0,"Tags":"python,python-3.x","A_Id":64121802,"CreationDate":"2020-09-29T14:03:00.000","Title":"How can I delete the application after it upon closing it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"We are using a combination of django, rabbitmq, celery and ffmpeg to read camera streams and break them into images to be stored into filesystem. This setup works 24x7. Now, for each camera stream we are creating a separate task and each will theoretically run for indefinite period.\nIf a stream goes down, we wait for n number of frames, create an exception and in the exception handler, after creating a delay of 1 min using time.sleep we rerun the ffmpeg process.\nMy questions are,\nIs this a right approach?\nShould we use celery for reading streams?\nIs celery the right tool to use for this task?\nCan we create delay in celery task using time.sleep ? Will it affect the other tasks?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":888,"Q_Id":64123114,"Users Score":1,"Answer":"We have relatively big Celery cluster and many of our tasks run for hours, some even run over 24 hours, so I would say yes, Celery is a good choice for long-running tasks. I know very little about audio\/video processing, so I do not think there should be any problems doing it inside a Celery task. The only thing I would perhaps change in the original idea is the following: I would not sleep (yes, you can call sleep in Celery task) and continue processing, but run a new task instead. Other tasks should not be affected at all.","Q_Score":1,"Tags":"python-3.x,ffmpeg,rabbitmq,celery,django-celery","A_Id":64137486,"CreationDate":"2020-09-29T15:46:00.000","Title":"Is celery a good choice for long running tasks?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a dag in puckel\/docker-airflow container and in dag script I imported a custom module from another script:\nfrom app_store_reviews.app_store_reviews.spiders.list_ids import ListIdsSpider \nWhere:\nListIdsSpider is a class from list_ids.py. that's in this path = 'usr\/local\/airflow\/dags\/app_store_reviews\/app_store_reviews\/spiders'\nBut I'm getting this kind of error from airflow:\nBroken DAG: [\/usr\/local\/airflow\/dags\/reviews_analysis_dag.py] No module named 'app_store_reviews.app_store_reviews.spiders.list_ids'\nHow I can solve this? Maybe add this path to PYTHONPATH? if so, How I can do this in a runing container?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":499,"Q_Id":64123610,"Users Score":1,"Answer":"Looks like you see an error in Airflow Web UI.\nThat error is thrown by airflow-scheduler when it scans your dag files.\nYou need to make sure your custom module is installed inside the airflow-scheduler environment.","Q_Score":0,"Tags":"python,docker,airflow","A_Id":64354409,"CreationDate":"2020-09-29T16:16:00.000","Title":"Cannot import custom module to a dag script in Airflow Docker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"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":"I know stock['long_entry'] is creating a new column and stock.Close and stock.high are existing columns but I don't understand how the 'greater than' is being used here","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":64125198,"Users Score":0,"Answer":"The boolean from evaluation of stock.Close > stock.high is stored in stock['long_entry']","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":64125247,"CreationDate":"2020-09-29T18:05:00.000","Title":"What does this mean from pandas in python: stock['long_entry'] = stock.Close > stock.high","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a Django project where I have to take a Product name from the search bar & pass the name through a python script where the script will scrape some data from a website & store it in a list. Then it will go to the result.html page & show the data. How should I take the product name from the search box & where should I place the python script? How can I loop over the list data & show it in the result.html ?","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":113,"Q_Id":64126222,"Users Score":-2,"Answer":"You can use ajax to communicate between the back and front ends ...","Q_Score":0,"Tags":"python,django,web-deployment","A_Id":64126249,"CreationDate":"2020-09-29T19:18:00.000","Title":"How to take a string as input in django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a try\/except block with multiple except blocks. I want to be able to execute a piece of code only if any of the exceptions are raised. Kind of like the finally statement, but finally execute regardless of if an exception was raised or not. Do I just have to add that code to each except block?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":64126776,"Users Score":0,"Answer":"Instead of copy+pasting the code into each except block, i would declare a boolean execute_code = False and set it to True in each of the except blocks. After the whole try\/except, add if execute_code:, then implement the code to execute if an exception occurred once inside the if block.","Q_Score":0,"Tags":"python,exception","A_Id":64126897,"CreationDate":"2020-09-29T19:58:00.000","Title":"Is there a way in python to execute a piece of code only if any exception is raised in a try\/except block?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I am creating a regex to recognize commands for a basic IRC and have come to one command that is giving me some trouble and has made me think about my previous commands a bit and possibly might allow me to correct some mistakes.\nEssentially a JOIN message in this sense will allow a user to be added to a channel for chat with others, and for the purpose of this project a JOIN will also create the channel and add the user as its first member.  The user is already assumed to be logged in before this point so the only information needed is the channel or channels they intend to join.  This is where the problem comes where the RFC manual on IRC doesn't really have a hard limit so I think I will have to set some sort of soft limit of channels for them to join which.\nJOIN #foobar                    ; Command to join channel #foobar.\nJOIN #foo,#bar                  ; Command to join channels #foo and #bar.\nThese are two examples of possible basic commands.  Each must have no spaces, channels are delimited by a \",\" and a channel must begin with a special character being '&', '#', '+' or '!'.\nI don't know if it would be something along the lines of the following would be what im looking for\n\"JOIN\\s[(&|#|+|!)\\w+][,(&|#|+|!)\\w+]{0-4}\"\nThe way I understand this setup if I did it correctly is there should be one channel followed 0 to 4 other, separated channels which I feel like would be easy to parse and work with due to the commas.  Can someone let me know if this is on the right track?\nAlso as an additional note, in previous commands I've tested for an exact correct command in terms of parameters but as long as there is a space is after the JOIN it should recognize it as a command but may just have incorrect parameters.  I would assume if the above regex was correct that something like this might be the correct way to deal with that.\n\"JOIN?[\\s[(&|#|+|!)\\w+][,(&|#|+|!)\\w+]{0-4}]\"\nI could be way off but alot of these special symbols get fairly confusing.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":64128945,"Users Score":0,"Answer":"I think you're looking for something like JOIN\\s[&#+!]\\w+(,[&#+!]\\w+){0,4}\nThere were a couple of issues in your original.  [] don't quite do what you think they do, and the separator in {} syntax is a comma, not a hyphen.\nIs there a reason you're limiting yourself to only five channels?","Q_Score":0,"Tags":"python,regex,validation,irc","A_Id":64131810,"CreationDate":"2020-09-29T23:25:00.000","Title":"Can someone help me better understand zero or one in regex and possibly with nesting another within the same regex statement","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently installed pynini using \"conda install -c conda-forge pynini\". It seems to have been installed since I checked with conda list and it was there. However, when I tried it out through PyCharm or Spyder (both with Python Interpreter to be Anaconda3), I kept getting:\n\nModuleNotFoundError: No module named 'pynini'\n\ndespite having installed it. I don't know where I went wrong here so any insights or help would be much appreciated! Thanks in advance!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":183,"Q_Id":64130392,"Users Score":1,"Answer":"Which conda environment did you install?\nconda install -c conda-forge pynini will install on the current active environment.\nOn PyCharm, check which conda environment you are on.","Q_Score":0,"Tags":"python,pycharm,conda,spyder,pynini","A_Id":64132089,"CreationDate":"2020-09-30T03:24:00.000","Title":"Keep getting ModuleNotFoundError: No module named 'pynini' in Pycharm and Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently installed pynini using \"conda install -c conda-forge pynini\". It seems to have been installed since I checked with conda list and it was there. However, when I tried it out through PyCharm or Spyder (both with Python Interpreter to be Anaconda3), I kept getting:\n\nModuleNotFoundError: No module named 'pynini'\n\ndespite having installed it. I don't know where I went wrong here so any insights or help would be much appreciated! Thanks in advance!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":64130392,"Users Score":0,"Answer":"I think it might be \"PATH\" problem. You should check PATH or env.\nOR... remove and install conda environment.","Q_Score":0,"Tags":"python,pycharm,conda,spyder,pynini","A_Id":65684492,"CreationDate":"2020-09-30T03:24:00.000","Title":"Keep getting ModuleNotFoundError: No module named 'pynini' in Pycharm and Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently trying to run a program with Scipy, and I want to use the load_npz module.\nWhenever I tried to run it, the compiler would say that that module doesn't exist.\nI ran scipy.__version__ and got 0.13.0b1, which makes sense as to why it couldn't find the module as it doesn't exist in that version, but I am confused as I have 1.5.2 installed in both pip and brew yet it keeps defaulting to the oldest version which is very frustrating.\nDoes anybody know how to get rid of this version? I have tried uninstalling from pip and brew, along with finding the path of the imported scipy with the outdated version yet it still is causing issues.\nI do have a lot of packages installed (numpy, matplotlib, etc.) so could it be a dependency that keeps reinstalling an old version?\nStrangely, even if I delete scipy from both brew and pip, it will still show the old version but throw an error on a different local file that also uses scipy saying the module does not exist (which is expected as I deleted it).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":64130416,"Users Score":0,"Answer":"I figured it out, I just deleted all my possible scipy locations and then just downloaded Anaconda and I'm using that as my python interpreter.","Q_Score":0,"Tags":"python,visual-studio-code,scipy","A_Id":64148403,"CreationDate":"2020-09-30T03:28:00.000","Title":"How to remove hidden utdated scipy file so it won't import with python in VS Code OSX","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"All the time that I've worked with python and anaconda, I have never wondered how actually virtual envs are useful except for version controlling. When I looked it up, I found a lot of articles on how to create and use custom envs, but not exactly why they are so awesome. Why is it dangerous to install new libraries into the original installation? Are virtual envs useful for anything other than versioning?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":64131348,"Users Score":3,"Answer":"PROS:\n\nYou can use any version of python you want for a specific environment without having to worry about collisions.\nYour main python package directory does not get flooded with unnecessary python packages.\nYou can organize your packages much better and know exactly the packages you need to run.\nAnyone can run your code on their machine.\nYour project is easier to deploy.\nYour application runs faster.\nEase of maintenance.\n\nCONS:\n\nstorage space?","Q_Score":0,"Tags":"python,virtualenv,conda","A_Id":64131493,"CreationDate":"2020-09-30T05:19:00.000","Title":"Why should I create virtual environments for python projects?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install whirlpool package with pip but it gives Microsoft Visual C++ 14.0 is required errorI tried pip install whirlpool --only-binary=:all: but gives same error.I also searched for whirlpool unofficial binary file but I don't find anythingCan I install it without installing c++ build tools? because I haven't enough size for that.\nPython 3.8.3 - Pip 20.1.1","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":64132165,"Users Score":1,"Answer":"Wheels on pypi for whirlpool only go up to python 3.6, so you will either have to downgrade your python version or make some space on your hard drive","Q_Score":0,"Tags":"python,pip,whirlpool","A_Id":64136724,"CreationDate":"2020-09-30T06:40:00.000","Title":"Python installing whirlpool without C++ BuildTools","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking to upgrade from Pymongo 3.7 to 3.11 and ran into problems replacing the deprecated function cursor.count(). I need to know the number of documents returned from a query.\n\ncollection.count_documents({query}) is not the same as cursor.count(). First it's called on a collection, not a cursor. Second it the function parameters are different.\n-Speedwise this function is acceptable.\n-But in my current application layer there is no knowledge of the query. Hence, there is no knowing the argument to pass into cursor.collection.count_documents()\n\ncollection.estimated_document_count() gives the total of documents in a collection, not the amount of documents in the returned query.\n\nlen(list(cursor)) is too slow for my needs.\n\n\nIs there another way of counting the number of documents returned from a query?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":64132630,"Users Score":0,"Answer":"count_documents is implemented via the driver constructing an aggregation pipeline and using the $count stage. There isn't a way to \"attach\" this count to a cursor, or to a find query.\nYou might need to rearchitect your application to pass the conditions to count_documents.","Q_Score":0,"Tags":"python,pymongo,deprecated","A_Id":64218271,"CreationDate":"2020-09-30T07:14:00.000","Title":"Q: Is there an equivalent replacement to Pymongo `cursor.count()`? (3.7 -> 3.11)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a beginner, I downloaded the model and tried studying it. But whenever I convert a sentence to speech, The model stops at 35 seconds or around 440 characters giving max_decoder_steps warning. I want to convert a story to speech which would be around 1000 characters. Is there any way to bypass this limit?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":241,"Q_Id":64133284,"Users Score":1,"Answer":"No, as the model is trained on shorter inputs. You can either train a model yourself (very time consuming) or you split your input into smaller sequences like sentences.","Q_Score":0,"Tags":"python,mozilla-deepspeech","A_Id":64676896,"CreationDate":"2020-09-30T07:58:00.000","Title":"Increasing speak limit of mozilla tts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a beginner, I downloaded the model and tried studying it. But whenever I convert a sentence to speech, The model stops at 35 seconds or around 440 characters giving max_decoder_steps warning. I want to convert a story to speech which would be around 1000 characters. Is there any way to bypass this limit?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":241,"Q_Id":64133284,"Users Score":1,"Answer":"Of course you can. I just opened tacotron2.py, looked for max_decoder_steps and put the value 5000 as a test, and now it creates longer wav files.","Q_Score":0,"Tags":"python,mozilla-deepspeech","A_Id":68875399,"CreationDate":"2020-09-30T07:58:00.000","Title":"Increasing speak limit of mozilla tts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to set up a Node-RED GUI with multiple inputs and outputs etc. and some nodes containing python functions. The partner who will use this wants to input some own custom processors to work with the data and should be able to access my python functions, but I don't want to expose all the code I used. Is that possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":64133760,"Users Score":0,"Answer":"Not really.\nThe best you could do is to create a fork of the Python Function node that loads the python from a file rather than present a edit area in the Node-RED editor.\nThe python code would still be available on the disk of the machine running Node-RED but wouldn't be accessible via  the editor. This works if the partner is only accessing Node-RED via the web, but if they have access to the machine it's running on then they will have access to everything.","Q_Score":0,"Tags":"python,node-red","A_Id":64135238,"CreationDate":"2020-09-30T08:29:00.000","Title":"Using Python nodes in Node-RED without exposing code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to train neural network to indentify the colors. But issue is that when i use keras.utils.to_categorical for OneHotEncoding of color names, the colab is crashing and restarting. I tried this around 20 to 25 times but same problem persist.\nPlease help me","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":328,"Q_Id":64135978,"Users Score":1,"Answer":"May the data is not stored in a matrix or ma ythe numebr of categories is very high","Q_Score":2,"Tags":"python,keras,deep-learning,google-colaboratory,conv-neural-network","A_Id":64136020,"CreationDate":"2020-09-30T10:47:00.000","Title":"colab is crashing while using keras.utils.to_categorical","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 120 txt files, all are around 150mb in size and have thousands of columns.  Overall theres definitely more than 1million columns.\nWhen I try to concatenate using pandas I get this error: \" Unable to allocate 36.4 MiB for an array with shape (57, 83626) and data type object\"... I've tried Jupyter notebook and Spyder, neither work\nHow can I join the data? Or is this data not suitable for Pandas.\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":64139668,"Users Score":0,"Answer":"Saying you want to concat in pandas implies that you just want to merge all 150 files together into one file? If so you can iterate through all the files in a directory and read them in as lists of tuples or something like that and just combine them all into one list. Lists and tuples are magnitudes less memory than dataframes, but you won't be able to perform calculations and stuff unless you throw them in as a numpy array or dataframe.\nAt a certain point, when there is too much data it is appropriate to shift from pandas to spark since spark can use the power and memory from a cluster instead of being restricted to your local machine or servers resources.","Q_Score":0,"Tags":"python,sql,pandas,bigdata","A_Id":64141398,"CreationDate":"2020-09-30T14:24:00.000","Title":"Is Panda appropriate for joining 120 large txt files?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Thank you for taking the time to check this question.\nI am interested in creating a profile for customers buying pattern.\nOnce I created a profile for everyone, we take unseen data and check with the profile to see if the customers followed their profile if not raise a flag. In this manner we do not create a set alert for all buyers but we can detect anomaly based on individual buyers to benchmark against their profile.\nAny thoughts or inputs to how to approach this problem.\nIf you have a course or tutorial on this matter please feel free to suggest it.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":120,"Q_Id":64140562,"Users Score":1,"Answer":"You can either go by supervised learning method, basically machine learning. Also, buying pattern, I would suggest to explore more about RFM rule i.e. recency, frequency and monetary value. This will help you in creating features for model or profile customers.","Q_Score":0,"Tags":"python,pandas,classification,profiling,profile","A_Id":64140842,"CreationDate":"2020-09-30T15:10:00.000","Title":"Customer profiling and Anomaly detection -Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to train a model which takes a mixture of numerical, categorical and text features.\nMy question is which one of the following should I do for vectorizing my text and categorical features?\n\nI split my data into train,cv and test for purpose of features vectorization i.e using vectorizor.fit(train)  and vectorizor.transform(cv),vectorizor.transform(test)\nUse vectorizor.fit transform on entire data\n\nMy goal is to hstack( all above features) and apply NaiveBayes. I think I should split my data into train_test before this point, inorder to find optimal hyperparameter for NB.\nPlease share some thought on this. I am new to data-science.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":64142447,"Users Score":0,"Answer":"If you are going to fit anything like an imputer or a Standard Scaler to the data, I recommend doing that after the split, since this way you avoid any of the test dataset leaking into your training set. However, things like formatting and simple transformations of the data, one-hot encoding should be able to be done safely on the entire dataset without issue, and avoids some extra work.","Q_Score":0,"Tags":"python,machine-learning,data-science,countvectorizer,train-test-split","A_Id":64142504,"CreationDate":"2020-09-30T17:04:00.000","Title":"What is right time to perform train_test_split when building a model with text and categorical features?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to train a model which takes a mixture of numerical, categorical and text features.\nMy question is which one of the following should I do for vectorizing my text and categorical features?\n\nI split my data into train,cv and test for purpose of features vectorization i.e using vectorizor.fit(train)  and vectorizor.transform(cv),vectorizor.transform(test)\nUse vectorizor.fit transform on entire data\n\nMy goal is to hstack( all above features) and apply NaiveBayes. I think I should split my data into train_test before this point, inorder to find optimal hyperparameter for NB.\nPlease share some thought on this. I am new to data-science.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":64142447,"Users Score":0,"Answer":"I think you should go with the 2nd option i.e vectorizer.fit_transform on entire data because if you split the data before, it may happen that some of the data which is in test may not be in train so in that case some classes may remain unrecognised","Q_Score":0,"Tags":"python,machine-learning,data-science,countvectorizer,train-test-split","A_Id":64143264,"CreationDate":"2020-09-30T17:04:00.000","Title":"What is right time to perform train_test_split when building a model with text and categorical features?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am applying sklearn.preprocessing.MinMaxScaler() to a DataFrame and using the DataFrame for machine learning. After training I have a separate code and DataFrame to do a prediction. In the prediction code I do a MinMaxScaler() on the DataFrame I want to use to predict. The Training DataFrame and Prediction DataFrame will have different Min and Max values. My question is should the Training DataFrame and Prediction DataFrame use the same Min and Max values in order to get an accurate prediction?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":25,"Q_Id":64143779,"Users Score":1,"Answer":"Yes, you should use the same MinMaxScaler() on the train and test.\nExplanation: Assume your training dataset has some features with min=10 and max=20 and your test dataset has features with min=1 and max=10. If a separate scaler is trained on test, the test data values will be lower in comparison to the training dataset.","Q_Score":0,"Tags":"python,dataframe,tensorflow,scikit-learn,sklearn-pandas","A_Id":64143866,"CreationDate":"2020-09-30T18:36:00.000","Title":"Should the same Min and Max be applied for Training and Prediction on a DataFrame?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The healpy.query_disc() function takes an argument vec which is a three-component unit vector defining the center of the disc. What coordinate system is being used here - why is there a third dimension for a 2-d projection? What point is the \"tail\" of this vector llocated at?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":142,"Q_Id":64144487,"Users Score":0,"Answer":"Solved. Used the output of ang2vec() to give the vector.","Q_Score":1,"Tags":"python,physics,astronomy,healpy","A_Id":64976754,"CreationDate":"2020-09-30T19:28:00.000","Title":"Coordinate system used for healpy.query_disc()","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Documentation for QAbstractItemModel.setData, which I've reproduced below, says that the method should return true if successful or false otherwise.  My question is the following: How can this method not be successful?\n\nbool QAbstractItemModel::setData(const QModelIndex &index, const\nQVariant &value, int role = Qt::EditRole)\nSets the role data for the item at index to value.\nReturns true if successful; otherwise returns false.\nThe dataChanged() signal should be emitted if the data was\nsuccessfully set.\nThe base class implementation returns false. This function and data()\nmust be reimplemented for editable models.\nNote: This function can be invoked via the meta-object system and from\nQML. See Q_INVOKABLE.\nSee also Qt::ItemDataRole, data(), and itemData().","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":64145912,"Users Score":2,"Answer":"The objective of the return value of setData() is to indicate whether or not the information associated with the role and the QModelIndex was edited, and it will depend on the developer if it returns true or false.\nSome examples that illustrate the above:\n\nIf you want your model to be non-editable (which by default is any model) then always return false.\n\nIf you want only some items to be editable or not so you will return true or false depending on the item.\n\nIf you want the new value to meet certain restrictions. A practical example could be if the items to edit must be ages, so for negative values it must return false, and for the other cases true.","Q_Score":2,"Tags":"python,pyqt5","A_Id":64146044,"CreationDate":"2020-09-30T21:22:00.000","Title":"how can `setData` method fail?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Documentation for QAbstractItemModel.setData, which I've reproduced below, says that the method should return true if successful or false otherwise.  My question is the following: How can this method not be successful?\n\nbool QAbstractItemModel::setData(const QModelIndex &index, const\nQVariant &value, int role = Qt::EditRole)\nSets the role data for the item at index to value.\nReturns true if successful; otherwise returns false.\nThe dataChanged() signal should be emitted if the data was\nsuccessfully set.\nThe base class implementation returns false. This function and data()\nmust be reimplemented for editable models.\nNote: This function can be invoked via the meta-object system and from\nQML. See Q_INVOKABLE.\nSee also Qt::ItemDataRole, data(), and itemData().","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":83,"Q_Id":64145912,"Users Score":1,"Answer":"The method is in an abstract class and can be overridden.  If it is overwritten, anything can happen in that new implementation, right?\n\nThe base class implementation returns false. This function and data()\nmust be reimplemented for editable models.\n\nSo it's not only possible it will be overridden, it's even necessary in some cases.  What \"successful\" means is up to the implementer of the overriding method, and it can return either true or false.","Q_Score":2,"Tags":"python,pyqt5","A_Id":64146052,"CreationDate":"2020-09-30T21:22:00.000","Title":"how can `setData` method fail?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an ANN (artificial neural network) that I have to train with many parameters in python. I heard of a cheap\/ quick way to \"multi_thread\" in python. I realize this isn't the cleanest way to do this (there are libraries dedicated to this, but It's to quickly test and develop networks). However, I wanted to check the validity of this trick with Stack Overflow\nI open 4 CMDs (I have a 4 core processor) and run the same program on each of the CMDs as python my_program.py param1 param2. The only difference is that in each of the CMDs, I change the parameters so they are training differently. They then save their trained networks to the disk.\nIs this method of opening 4 CMDs really using the 4 cores I have on my computer and in a sense Multi-Threading?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":64146018,"Users Score":1,"Answer":"It should work as you think, and is a perfectly valid way of making full use of a multi-core machine.\nAssuming the mention of \"CMD\"s means you're on Windows: check the Windows Task Manager's view of CPU usage.  It should show all 4 cores fully in use when you have 4 processes running, assuming those processes are compute bound (rather than waiting on disk or network IO).","Q_Score":1,"Tags":"python-3.x,multithreading,cmd,neural-network","A_Id":64146211,"CreationDate":"2020-09-30T21:30:00.000","Title":"Cheap Multi-Threading Trick in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was watching a tkinter tutorial in which the instructor used the grid_forget method to remove a label containing an image before adding a new one. He explained that this was to prevent the new image from overlapping the old one. However, later in the tutorial, he updated a button's functionality by creating a new button and adding it to the same cell in the grid, without ever calling grid_forget. He never explained why grid_forget wasn't needed here.\nIt seemed to me that, if the new image would overlap the old one without grid_forget, then the new button would overlap the old one too, which could cause a memory leak if this kept being called. But apparently this isn't the case. Why is this situation different?\nMore generally, when does a widget need to be explicitly cleared with grid_forget, and when will it be implicitly cleared simply by adding to the same cell?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":64146645,"Users Score":1,"Answer":"That is a terrible tutorial. You should never update a widget by recreating it, you should use the config method to update the already existing one.\nBut to answer your question: He should have removed the old Button, but presumably didn't because the new Button was guaranteed to be the same size or bigger than the old one, therefore covering it completely. The old Button will still be in memory though, and as you build a stack of them they will slow down your program, so again it's a very bad idea to do this. It will never be implicitly cleared, only covered.","Q_Score":0,"Tags":"python,tkinter","A_Id":64146747,"CreationDate":"2020-09-30T22:33:00.000","Title":"When do you *not* need to use grid_forget when updating a widget?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am following a tutorial on Neural_Networks and it uses python2.7 and the line of code I am confused with is the if statement  '''\nif test_data: n_test = len(test_data)\n''' and I ever came across this syntax in python 3.8 and please explain me what does test_data: n_test means. Thank You","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":196,"Q_Id":64148247,"Users Score":2,"Answer":"This is a if statement in python, it checks if test_data exists and if exists then sets the value of the variable n_data to the string length of test_data variable.","Q_Score":1,"Tags":"python,if-statement","A_Id":64148274,"CreationDate":"2020-10-01T02:26:00.000","Title":"Meaning of \"test_data: n_test\" in python 3.8","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Do you anchor all versions in requirements.txt to a spesific number? Is it the right way? Is there any way to get latest version that does not break my app? To not missing security updates etc.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":64151506,"Users Score":0,"Answer":"Installing latest dependency may break your app if the new code syntax is not backwards compatible. Here's how I approach to maintain the requirements.txt file.\n\nCreate a new virtual environment every time I develop for a new project\nInstall all the dependencies in the virtual env\nRun pip freeze > requirements.txt from that virtual env to generate the file\nAdd Python version in a Readme file\n\nThis way I can always know for sure the Python version and version of the dependencies with which the app was built. This of course does not solve other issues related to OS type\/version compatibility that might occur.\nTools like Docker are created to solve all such dependency and cross-platform compatibility problems so that is worth exploring.\nEDIT\nIf you still want to always have the latest version of the package, simply remove the version numbers and keep the package name.\nE.g. Instead of mysql-connector==2.2.9 use mysql-connector","Q_Score":1,"Tags":"python,dependency-management,requirements.txt,requirements-management","A_Id":64151717,"CreationDate":"2020-10-01T08:19:00.000","Title":"How to install highest version of a Python package which doesn't break my App?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a file called \"Notebook.ipynb\". I want to import my own module into it patterns.py. Let's say in patterns.py I have a variable a=1. If I print it in Jupyter after importing it, I expect to get 1. But if I change the value of the variable to patterns.py Jupyter will continue to think that the variable a is equal to one. At the same time, of course, I restart the cell in which the variable is imported from patterns.py\nWhat do I need to do to make Jupyter understand that the value of the variable has changed?","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1291,"Q_Id":64158622,"Users Score":4,"Answer":"This has happened to me.\nYou need to restart the python kernel so jupyter can read the new state of the python scripts located in the working directory.\nThen the variable a should print the new assigned value.","Q_Score":3,"Tags":"python-3.x,jupyter-notebook","A_Id":64158748,"CreationDate":"2020-10-01T15:34:00.000","Title":"Jupyter does not see changes in the imported module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make my python cmd output colorful!\nI have color-codes like this:\n\\033[91m\nNow the output in cmd isn't colorful. I get a \"\u2190\". How can I change this?\nDid anybody have the same problem? :D\nEdit\nIs there an alternative to cmd? Is it hard to programm a cmd window in e.g. C#?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":277,"Q_Id":64159164,"Users Score":0,"Answer":"You should use third party \"cmds\" for example, because they often come with more options. Microsoft also publishes many, check out the MS Store :) I use Fluent Terminal. This is graphically also very appealing","Q_Score":0,"Tags":"python","A_Id":66477356,"CreationDate":"2020-10-01T16:05:00.000","Title":"CMD color problems","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"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":"I have my app.py function that's using pip libraries like SQLAlchemy, etc... I am deploying this to AWS Lambda, so I am packaging app.py and all other dependencies into a zip.\n\nIs there a better way to deal this? (What if pip libraries go out of date)\nI have a custom code that I want to use in many programs. How do I create my own module and package it along with pip libraries?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1978,"Q_Id":64161352,"Users Score":0,"Answer":"Regarding 1 - AWS SAM will work out your requirements.txt and bundle what's needed with your code. This works fine for small projects, but for larger ones I'd suggest going the same way as for library code - put all your deps in separate layer. It may be installed with pip install -U --target dirname and then packaged into a layer.","Q_Score":3,"Tags":"python,aws-lambda,pip,python-module","A_Id":64163213,"CreationDate":"2020-10-01T18:36:00.000","Title":"How to work with Python custom packages in AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a DataFrame with 57 columns. Columns 1 through 21 are dimensions. 22 through 57 are metrics. Column 1 is a date column. Column 21 is a bad column that is causing me to have duplicative data.\nWhat I am looking to do is remove column 21 and then take the min of 22 to 57 when 1 through 20 are the same.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":813,"Q_Id":64162721,"Users Score":0,"Answer":"Just needed to drop the column and then drop duplicates. Sorry all.\ndf.drop(columns=\"lineItemBudget\", inplace=True)\ndf.drop_duplicates(inplace=True)","Q_Score":0,"Tags":"python,pandas","A_Id":64162928,"CreationDate":"2020-10-01T20:26:00.000","Title":"Pandas DataFrame: How to remove column and perform calculations on select columns","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Quick questions here:\nI have an azure VM set up with Anaconda and Spyder as an IDE.  The code that I would like to run with a higher virtual RAM on my local machine is currently NOT using the multiprocesssing library and is still a slave to the specter of GIL on my laptop.   I would obviously have to include multi-processing to get the code to use more than one core on my own machine.\nThe question is do you have to do the same to get the advantage of multiple virtual cores on MS Azure, or will the interface simply batch whatever you run out as if GIL never existed in the VM World?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":64163981,"Users Score":0,"Answer":"Yes. It would be the same. While Virtual, to the underlying OS, they are still separate cores for you to leverage.","Q_Score":0,"Tags":"python,azure,multiprocessing,virtual-machine,gil","A_Id":64680353,"CreationDate":"2020-10-01T22:28:00.000","Title":"Do you have to include multi-processing in python code that you run on an MS Azure VM?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I have a multivariable function such as\nF= lambda x,y: x**2+y**2\nand if I need to use the input x0=np.array([1,1])\nMay I know how I should use x0 to get the value from F?\nI understand that I could use something like F(x0[0],x0[1])\nBut I would like to know whether there is a way that I can directly use x0 rather than calling each cordinate manually\nAppreciate your help","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":64165261,"Users Score":4,"Answer":"Python lets you do this by doing F(*x0), which expands the array into the parameters. In other languages this is sometimes called \"splatting\".","Q_Score":2,"Tags":"python,numpy","A_Id":64165360,"CreationDate":"2020-10-02T01:47:00.000","Title":"Using an array as an input for a multivariable function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a consumer polling from subscribed topic. It consumes each message and does some processing (within seconds), pushes to different topic and commits offset.\nThere are totally 5000 messages,\nbefore restart - consumed 2900 messages and committed offset\nafter restart - started consuming from offset 0.\nEven though consumer is created with same consumer group, it started processing messages from offset 0.\nkafka version (strimzi) > 2.0.0\nkafka-python == 2.0.1","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1313,"Q_Id":64165265,"Users Score":1,"Answer":"We don't know how many partitions you have in your topic but when consumers are created within a same consumer group, they will consume records from different partitions ( We can't have two consumers in a consumer group that consume from the same partition and If you add a consumer the group coordinator will execute the process of Re-balancing to reassign each consumer to a specific partition).\nI think the offset 0 comes from the property auto.offset.reset which can be :\n\nlatest: Start at the latest offset in log\nearliest: Start with the earliest record.\nnone: Throw an exception when there is no existing offset data.\n\nBut this property kicks in only if your consumer group doesn't have a valid offset committed.\nN.B: Records in a topic have a retention period log.retention.ms property so your latest messages could be deleted when your are processing the first records in the log.\nQuestions: While you want to consume message from one topic and process data and write them to another topic why you didn't use Kafka Streaming ?","Q_Score":1,"Tags":"apache-kafka,kafka-consumer-api,kafka-python,strimzi,confluent-kafka-python","A_Id":64167542,"CreationDate":"2020-10-02T01:48:00.000","Title":"Kafka Consumer not consuming from last commited offset after restart","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a python server application that handles a git repository. It creates commits and switches branches to apply changes locally and then pushes them to the remote repo.\nFor some reason, users that run the server on Mac see their repository ending up in a detached HEAD state. This has never happen for users running the server on Windows machines.\nThe tool uses GitPython, and there is no service that does a checkout to a specific commit SHA, it only switches to branch names. It does perform git pull --rebase and git push.\nIs there a way to end up in the detached HEAD state by performing pulls with rebase, fetches or pushes, or any other way that is not a checkout to a commit SHA?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":99,"Q_Id":64165595,"Users Score":1,"Answer":"Looks like the error was caused by git-lfs not installed by default in the macOS from the work machines. The plug-in failed somehow and ended in detached HEAD state","Q_Score":0,"Tags":"windows,git,macos,python-2.7,gitpython","A_Id":65662633,"CreationDate":"2020-10-02T02:46:00.000","Title":"Is it possible to end in git detached head from pull, push, fetch or rebase?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"If there are 10 features and 1 output class (sigmoid activation) with a regression objective:\nIf I use only 5 neurons in my first dense hidden layer: will the first error be calculated solely based on half of the training feature set? Isn't it imperative to match the # of features with the neurons in hidden layer #1 so that the model can see all the features at once? Otherwise it's not getting the whole picture? The first fwd propagation iteration would use 5 out of 10 features, and get the error value (and train during backprop, assume batch grad descent). Then the 2nd fwd propagation iteration would see the remaining 5 out of 10 features with updated weights and hopefully arrive at a smaller error. BUT its only seeing half the features at a time!\nConversely, if I have a convolutional 2D layer of 64 neurons. And my training shape is: (100, 28,28,1) (pictures of cats and dogs in greyscale), will each of the 64 neurons see a different 28x28 vector? No right, because it can only send one example through the forward propagation at a time? So then only a single picture (cat or dog) should be spanned across the 64 neurons? Why would you want that since each neuron in that layer has the same filter, stride, padding and activation function? When you define a Conv2D layer...the parameters of each neuron are the same. So is only a part of the training example going into each neuron? Why have 64 neurons, for example? Just have one neuron, use a filter on it and pass it along to a second hidden layer with another filter with different parameters!\nPlease explain the flaws in my logic. Thanks so much.\nEDIT: I just realized for Conv2D, you flatten the training data sets so it becomes a 1D vector and so a 28x28 image would mean having an input conv2d layer of 724 neurons. But I am still confused for the dense neural network (paragraph #1 above)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":64166258,"Users Score":1,"Answer":"What is your \"first\" layer?\nNormally you have an input layer as first layer, which does not contain any weights.\nThe shape of the input layer must match the shape of your feature data.\nSo basically when you train a model with 10 features, but only have a input layer of shape (None,5) (where none stands for the batch_size), tensorflow will raise an exception, because it needs data for all inputs in the correct shape.\nSo what you said is just not going to happen. If you only have 5 features, the next 5 features wont be fit into the net in the next iteration but, the next sample will be send to the model instead. (Lets say no exception is thrown) So of the next sample also only the first 5 features would be used.\nWhat you can do instead, use a input_layer as first layer with the correct shape of your features. Then as secodn layer, you can use any shape you like, 1,10,100 dense neurons, its up to you (and what works well of course). The shape of the output again must match (this time) the shape of your label data.\nI hope this makes it more clear","Q_Score":2,"Tags":"python,tensorflow,machine-learning,deep-learning,neural-network","A_Id":64168073,"CreationDate":"2020-10-02T04:43:00.000","Title":"Neural network hidden layer vs. Convolutional hidden layer intuition","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created an environment in Anaconda by running:\n\nconda create --name myenv\n\nswitched to that environment after creation and added conda-forge to the anaconda channels.\nThen I ran\n\nconda install pycotools\n\nInstallation seem to be successful.\nWhen I try to import pycotools in Python\n\nfrom pycotools import models\n\nI get the error message:\n\nModuleNotFoundError: No module named 'pycotools'\n\nTo verify installation of pycotools, I run\n\nconda list pycotools\n\nBut this gives nothing back\nHowever, when I run\n\nconda list\n\nI find pycotools in the list.\nHow can I verify that I have pycotools installed?\nAnd if no, how do I properly install pycotools in my conda environment?\nby","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":140,"Q_Id":64169006,"Users Score":0,"Answer":"Try to execute pip install pycotools.","Q_Score":2,"Tags":"python,anaconda","A_Id":69347836,"CreationDate":"2020-10-02T09:12:00.000","Title":"ModuleNotFoundError: No module named 'pycotools'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to do a two-fold task. The input is an image and based on the input I want to pick another image from a set of images (classification task) and then use both the images to obtain an output tensor. Clearly, I can train both the models separately if I know the ground truth of which image I should pick from that set. But, I only have the output tensor ground truth.\nThe problem, as it appears to me, is that if we employ a classification layer, the gradients will not be differentiable anymore. How do I deal with this problem? Is there literature which uses this kind of architecture for any application? TIA\nMore details: I have multiple images of an object\/scene and I want to use two of those images for some kind of reconstruction problem. To maximize the performance of reconstruction, I want to smartly choose the second image if I am given the first image. For eg., I have three images A, B, C and using AC gives the best result. I need a model which given A predicts C and then using AC I can achieve the reconstruction. Is the task clear now? I do not have ground truth which says AC is better than AB. Is the task clear now?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":64169569,"Users Score":1,"Answer":"So basically, you want to do a classification task followed by a reconstruction task.\nHere is what I suggest (I do not pretend this the absolute best solution, but it's how I would approach this problem) :\nYou can create a single task that does Classification--> Reconstruction with a single loss. Let's still separate this network in two and call net_class the part that does classification , and net_reconstruct the part performing reconstruction.\nLet's say your classification network predicts {'B': 0.1, 'C': 0.9). Instead of using only image 'C' for reconstruction, I would feed both pairs (A-B and A-C) to the second network and compute a reconstruction loss L (I'm not an expert in reconstruction, but I guess there are some classical losses in this).\nTherefore, you would compute two losses L(A-B) and L(A-C).\nMy total loss would be 0.1 * L(A-B) + 0.9 L(A-C). This way, you would train net_class to choose the pairing that minimizes the reconstruction loss and you would still train net_reconstruct to minimize both losses, and the loss is continuous (and therefore, differentiable according to AI experts ;) ).\nThe idea behind this loss is three-fold :\n1 - Improving the reconstructor makes the loss go down (since both L(A-B) and L(A-C) would decrease. therefore, this loss should make your reconstructor converge towards something you want.\n2 - Let's imagine your reconstructor is pretty much trained (L(A-B) and L(A-C) are relatively low). Then, your classifier has an incentive to predict the class which has the lowest reconstruction loss.\n3 - Now, your reconstructor and your classifier will train at the same time. You can expect, at the end of the training, to have a classifier that would output pretty much binary results (like 0.998 vs 0.002). AAt that point, your reconstructor will almost only train on the scene associated with the 0.998 ouput. This should not be a problem, since, if I understood correctly your problem, you want to perform the reconstruction part only for the top classified scene.\nNote that this method also works if you're not performing deep learning for the reconstruction part.\nIf you want some inspiration on this kind of topic, I recommend you read some blog posts about GANs (Generative Adversarial Networks). They use the same two stage - one loss trick (with some slight differences of course, but the ideas are very close).\nGood luck !","Q_Score":1,"Tags":"python,tensorflow,machine-learning,computer-vision,data-science","A_Id":64173696,"CreationDate":"2020-10-02T09:51:00.000","Title":"Train a cascaded network with a classifier in between","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with Carla 0.9.9 in Unreal 4.24 (Windows10\/RTX2080) right now in order to get some basic autonomous driving functions going. So far it seems to be working fine, but I have a weird problem and I'm quite confident that it's not caused by my code. I've googled around and this problem seems to be quite unique, but maybe one of you guys can point me in the right direction:\nI am displaying a few steps of my lane detection algorithm in different windows (e.g. ROI, detected lines...), and every few seconds, depending on the current framerate, the image will randomly flip to being upside down in some of the windows (only one at a time and only for a single\/few frames), except for the main window where I am controlling the car (manually for now). I've tried setting the Unreal Editor to different framerates, and there is definitely a connection between the output framerate (server side) and the amount of these \"flips\" happening, to the point where it's almost never happening if I run it at 15-20fps. There is also some \"tearing\" going on (e.g. only roughly the upper half of the image is flipped, like Vsynch is switched off) sometimes, which leads me to believe that the root cause is somewhere in the rendering part and not the python scripts. The point is: when the image is upside down, my lane detection is seeing the \"lane\" in the wrong place, which could lead to all sorts of trouble down the line.\nTo be honest I'm not that familiar with the whole Unreal Engine\/DirectX(?)-rendering pipeline, so I am a little lost what might be causing this issue. I'm grateful for any ideas on how to fix this, thanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":64169887,"Users Score":0,"Answer":"Okay, in case anybody ever has the same problem, here's what I found out:\nthe client was running too fast in relation to the server. I limited the client side to 30fps now and that fixed it. This issue will only occur if the tick rate of the client is so high that it has trouble keeping up while running the calculations in the background.\nI still can't figure out why the image is upside down in that case, but hey...","Q_Score":0,"Tags":"python,image-processing,unreal-engine4,carla","A_Id":64222796,"CreationDate":"2020-10-02T10:14:00.000","Title":"Random image flipping in CARLA\/UE4","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I created a virtual environment and tried to import selenium inside one of the python files I have inside that venv and it's throwing me this error.\nBoth my python3 and pip3 have the same source.\nI tried pip3 install selenium and python3 -m pip install -U selenium, both didn't work.\nI can import the selenium package from the command line without any problem. Will this be any problem with my text editor? I'm using vscode.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":507,"Q_Id":64170612,"Users Score":1,"Answer":"My python interpreter inside vscode was pointing to another version of python. I changed that to pyton3 and it worked. To change the python3 interpreter, open command palette(ctrl+shift+p) and search for,\nPython : Select Interpreter. Now change that to the correct path and you're good to go.","Q_Score":1,"Tags":"python-3.x,selenium,selenium-webdriver,visual-studio-code,pip","A_Id":64180221,"CreationDate":"2020-10-02T11:16:00.000","Title":"Unable to import 'selenium' : pylint(import-error)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"While working with the Enterprise Architect API I have noticed that when you export an EA project to XMI, several different kinds of elements get an attribute called ea_localid. That means in the XMI you'll find a tag that has the ea_localid as an attribute. This attribute seems to be used to reference source and target of connecting elements (at least this is valid for 'transitions', as we are working with State Machine diagrams).\nSo far, so good. Now the problem for my intended usage is that these values seem to be newly distributed every time you do an import and an export. EDIT: it is not quite clear to me when exactly during this process. EDIT #2 It seems to happen on import.\nThat means after having exported your project, reimporting it, changing nothing and then exporting it again gives the generated XMI document a set of different ea_localid values. Moreover, it seems that some values that used to belong to one element can now be used for an entirely different one.\nDoes anybody know anything about the distribution mechanism? Or, even better, a way of emulating it? Or a way to reset all counters?\nAs far as I've seen, generally there seem to be different classes of elements and within these classes a new ea_localid for the next element is generated by counting +1. So the first one has the value 1, then the next one 2 and so on.\nMy goal here is doing 'roundtrips' (XMI --> project --> XMI ...) and always getting the same ea_localid values, possibly by editing the XMI document after export. Any help or suggestions would be highly appreciated. Cheers","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":64170768,"Users Score":0,"Answer":"So, after some testing I have found out that regarding the aforementioned goal of doing a roundtrip (xmi --> import to EA --> xmi) and always getting the exact same document, the easiest solution is ...\nrunning a filter over the xmi that just deletes all nodes containing ea_localid, ea_sourceID (sic!) and ea_targetID values.\nOn reimport EA will just assign them new values. The information regarding source and target of 'transitions' and other connecting elements is also stored with the GUID, so there is no loss of information.","Q_Score":1,"Tags":"python,xml,enterprise-architect","A_Id":64242391,"CreationDate":"2020-10-02T11:29:00.000","Title":"How are 'ea_localid' values distributed in Enterprise Architect API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a problem with Tensorflow after import tensorflow\nTwo errors backwards I get :\n\n2020-10-02 15:13:07.794919: W\ntensorflow\/stream_executor\/platform\/default\/dso_loader.cc:59] Could\nnot load dynamic library 'libcudart.so.10.1'; dlerror:\nlibcudart.so.10.1: cannot open shared object file: No such file or\ndirectory 2020-10-02 15:13:07.794937: I\ntensorflow\/stream_executor\/cuda\/cudart_stub.cc:29] Ignore above cudart\ndlerror if you do not have a GPU set up on your machine.\n\nMy System:\n\nOS: Debian 10.6 AMD Ryzen 3 3300X Radeon XFX RX 590\npython 3.7\ntensorfolow 2.3.1\nIDE PyChram 2020.2\n\nI read that the GPU and CPU version of Tensorflow are together? Can I use this with my graphics card?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":272,"Q_Id":64172834,"Users Score":1,"Answer":"You say \"I get two errors\". But the second message says \"Ignore above cudart dlerror\". You only get a single error, and the second part says that the error really should have been a warning.\nThis is just a bad warning message. The real warning is that your GPU won't work with Tensorflow, but the CPU code will.","Q_Score":2,"Tags":"python","A_Id":64173300,"CreationDate":"2020-10-02T13:58:00.000","Title":"Problems with Tensorflow module","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for recommendations on a python logging framework python within a microservice. There's the built in logging system provided by python, there's structlogger. Currently I use structlogger with an ELK stack with filebeat instead of logstash. Please let me know what you would recommend and why? My usual criterial is popularity on stackoverflow (I'm not kidding), as it makes it a lot easier to get over technical issues or bugs.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":112,"Q_Id":64180362,"Users Score":2,"Answer":"Use the builtin logging module.\nIt does pretty much anything you need. structlogger isn't really a different framework and more of a default configuration for the builtin logging module. Also if you need something other than just logging to files or stdout the builtin module has a lot of handlers, and there exist a lot of third party handlers that work with the builtin module. (e.g. graylog)","Q_Score":0,"Tags":"python,logging,microservices,filebeat,elk","A_Id":64182761,"CreationDate":"2020-10-03T03:16:00.000","Title":"Python logging framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to make a GUI(using tkinter) for checking the code using test cases. Just like you see in Competitive Programming Websites like Hackerrank , SPOJ , CodeForces etc.\nNow I have somehow managed to print in the terminal for what test cases the code failed and for what the code passed.\nBut the catch is , I want to do the same in tkinter messageboxes.\nMy code runs in loop , so it checks each and every test cases and then prints out the result immediately rather than storing all the result in a list and checking them in the end.\nSo I want my Messagebox to also do the same i.e update everytime a test cases has been evaluated and show whether the test case was passed or not?\nIs it possible to implement?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":85,"Q_Id":64181744,"Users Score":3,"Answer":"If you mean the messagebox module that comes with tkinter, then no. But you can easily make your own message boxes with the Toplevel widget, and those can do anything you want.","Q_Score":2,"Tags":"python-3.x,tkinter","A_Id":64181905,"CreationDate":"2020-10-03T07:23:00.000","Title":"Is there a way to update the tkinter messageboxes live?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to import math on a new pc with Pycharm, I get the message \"unused import statement 'import math'\", Python 3.8 is the interpreter.\nSorry I am pretty new to Python and I know this is fairly basic","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1675,"Q_Id":64183439,"Users Score":0,"Answer":"In Pycharm this appears due to import inspection and if you have imported a module and have not used that module in your code, it will show a warning like this to avoid unnecessary imports.","Q_Score":0,"Tags":"python,pycharm,python-import","A_Id":64183528,"CreationDate":"2020-10-03T10:54:00.000","Title":"Import Math shows unused import statement","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"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 got two versions of Python on Windows, and try to set Python 3.6 as default. Does anyone know how can I set it? Many thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2675,"Q_Id":64186251,"Users Score":0,"Answer":"This is most likely due to the path variable. You can see this in a command window by typing\nPath\nat your prompt.\nTo update the settings,\nOpen the 'System' properties.\nSystem Properties\nOpen Environment Variables\nPath Variables\nHighlight the 'Path' Variable and click edit.\nEdit Path Variable\nEdit the values for the Python entries, to point to the desired python version.\nenter image description here\nOK on all boxes, close any CMD windows open, and open new one. Python command should now reference the correct location.","Q_Score":0,"Tags":"python,windows,version","A_Id":64187068,"CreationDate":"2020-10-03T16:06:00.000","Title":"How can I switch Python 3.8 to Python 3.6 as default on windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Tensorboard fails to launch. I get the following error messages. Can somebody guide. I have reinstalled conda and Tensorflow multiple times. I also looked online for similar issues, have not found anything.\nPython 3.7.4 and Tensforflow version 2.1\nERROR: Failed to launch TensorBoard (exited with 1).\nContents of stderr:\nTraceback (most recent call last):\nFile \"C:\\ProgramData\\Anaconda3\\Scripts\\tensorboard-script.py\", line 9, in \nsys.exit(run_main())\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorboard\\main.py\", line 65, in run_main\ndefault.get_plugins() + default.get_dynamic_plugins(),\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorboard\\default.py\", line 125, in get_dynamic_plugins\n\"tensorboard_plugins\"\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\tensorboard\\default.py\", line 124, in \nfor entry_point in pkg_resources.iter_entry_points(\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\pkg_resources_init_.py\", line 2442, in load\nself.require(*args, **kwargs)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\pkg_resources_init_.py\", line 2465, in require\nitems = working_set.resolve(reqs, env, installer, extras=self.extras)\nFile \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\pkg_resources_init_.py\", line 786, in resolve\nraise DistributionNotFound(req, requirers)\npkg_resources.DistributionNotFound: The 'typing-extensions>=3.7.4; python_version < \"3.8\"' distribution was not found and is required by yarl","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":317,"Q_Id":64186811,"Users Score":0,"Answer":"You need to install typing-extensions.","Q_Score":0,"Tags":"python,tensorflow,anaconda3,tensorflow2.x","A_Id":64191514,"CreationDate":"2020-10-03T17:01:00.000","Title":"Tensorboard fails to Launch","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"As I have started learning Python recently, I came across this boolean concept and I execute this expression bool(\"0\"), but I got a confusing result as True of this expression, can anybody tell me why this happens.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":642,"Q_Id":64187869,"Users Score":1,"Answer":"It is because it will return True for every non-empty strings,lists,etc.","Q_Score":1,"Tags":"python,boolean","A_Id":64187919,"CreationDate":"2020-10-03T18:54:00.000","Title":"Why bool(\"0\") is true in python? why does this happen?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like for the Jinja2 package's syntax support to be provided automatically to files with the .html extension, given that the appropriate delimiters ({% .. %}, {{ .. }}) are detected.\nI understand this would work for files with the .j2 extension. I am asking if it could be applied to plain HTML files that include Jinja2 syntax, without having to add the entire .html file type (which would then apply it to any HTML file)?\nFor now, I have been selecting the HTML (Jinja2) option from the syntax definition dropdown menu for each file, obviously not an ideal solution.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":218,"Q_Id":64188410,"Users Score":2,"Answer":"The easiest way to do this is to open a .html file, then select View \u2192 Syntax \u2192 Open all with current extension as\u2026 \u2192 HTML (Jinja2). This should do the trick. If not, there's a different way that involves writing a plugin, but this should be sufficient.\nThis still works based on the file's extension. However, highlighting of non-template content should be exactly the same as if you were using the regular HTML syntax.","Q_Score":1,"Tags":"python,jinja2,sublimetext3","A_Id":64188685,"CreationDate":"2020-10-03T19:53:00.000","Title":"In Sublime Text, is there a way to get the Jinja2 package to automatically provide syntax support for files with the .html extension?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've been using QT Designer to design simple GUI and save as .ui file and then convert it to Python 3 code, But now I've found QT Design Studio which seems so much easier and better. But as I've seen it just create .qml files and it's a little bit harder to work with than .py UI file. Can I export .ui file with QT Design Studio and then convert it to Python 3 code?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1024,"Q_Id":64188695,"Users Score":0,"Answer":"At the first, you must save your file designed as .qml file in QT Design Studio, then open .qml file with QT creator and save as .ui\nAt the end, you can convert ui file to py file with the below syntax\npyuic5 -o ui_form.py form.ui","Q_Score":0,"Tags":"python,qt,pyqt5,qt-designer,qt-design-studio","A_Id":68583052,"CreationDate":"2020-10-03T20:29:00.000","Title":"Can I export .ui file from QT Design Studio?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"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'm trying to write a report on my Computer Vision project that uses OpenCV's (Python) boundingRect function. However, I am not allowed to say that I used this function, but rather the algorithm\/equation that this function uses. I have tried to find this online, but am not particularly good at identifying what it is I'm looking for. Would someone be able to suggest which algorithm the boundingRect equation uses? Thanks\nUtilised by: cv2.boundingRect(contour).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":339,"Q_Id":64189496,"Users Score":2,"Answer":"In Python\/OpenCV, the axes aligned bounding rectangle is defined as X,Y,W,H, where X,Y are the coordinates of the minimum X,Y corner and W,H are the width and height of the box. Those values are found by testing every point (x,y) on the contour to find (the minimum and maximum of x and y each) minX, maxX, minY, maxY. The bounding rectangle values are then X=minX, Y=minY, W=(maxX-minX), H=(maxY-minY). You find the min and max values by looping over each x (or y) and testing it against the previous min or max value. If the current value is lower or higher, respectively, replace the old min or max with the current value.\nIn other systems, the bounding box is defined by the minimum and maximum diagonally opposite corners (minX,minY) and (maxX,maxY)","Q_Score":0,"Tags":"python,opencv","A_Id":64189992,"CreationDate":"2020-10-03T22:13:00.000","Title":"OpenCV Bounding Rectangle (Python)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a project on recommender systems written by python using the Bayesian Personalized Ranking optimization. I am pretty confident my model learns the data I provided well enough, but now it's time I found out the exact model hyperparameters and try to avoid overfitting. Since the movielens dataset only provided me with 5-fold train-test datasets without validation sets, I want to split the original dataset by myself to validate my model.\nSince the movielens dataset holds 943 user data with each user guaranteed to have ranked at least 20 movies, I'm thinking of splitting the data so that both TRAIN and TEST datasets contain the same number of users(e.g. 943), and distributing 80% of the implicit feedback data to TRAIN, and the other to TEST. After training validation will take place using the mean value of Recall at k precision through all 943 users.\nIs this the right way to split the dataset? I am curious because the original movielens test dataset doesn't seem to contain test data for all 943 users. If a certain user doesn't have any test data to predict, how do I evaluate using recall@k -- when doing so would cause a zero division? Should I just skip that user and calculate the mean value with the rest of the users?\nThanks for the lengthy read, I hope you're not as confused as I am.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":630,"Q_Id":64189820,"Users Score":1,"Answer":"How I would split it is the whole data set on 80% (train)- 10% (validation) - 10% (test). It should work out :)","Q_Score":0,"Tags":"python,bayesian,precision-recall,recommender-systems","A_Id":64190100,"CreationDate":"2020-10-03T23:17:00.000","Title":"Splitting movielens data into train-validation-test datasets","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to perform a sam deployment and upon running the command:\nsam build --template template.yaml --build-dir .\/build --use-container\nI see that the image \"amazon\/aws-sam-cli-build-image-python3.6\" is successfully pulled but then I obtain the following error:\nBuild Failed Error: PythonPipBuilder:ResolveDependencies - pip executable not found in your python environment at \/var\/lang\/bin\/python3.6\nI really have no clue why this is happening since I would expect that once the python image was pulled, pip and its dependencies would be installed.\nAppreciate any help, thanks in advance!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2785,"Q_Id":64189929,"Users Score":0,"Answer":"I encountered this issue after installing the sam-cli with pipx (I also use pyenv). My global python version from pyenv was 3.6 and the sam-cli was somehow finding python at \/usr\/bin\/python3.8 instead of the pyenv shim. After setting the local python version to 3.8.6 with pyenv's .python-version file in the root of the project, the error message went away.","Q_Score":1,"Tags":"python,amazon-web-services,docker,aws-lambda","A_Id":65267643,"CreationDate":"2020-10-03T23:37:00.000","Title":"aws sam deployment failed due to pip executable not found - python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I want to replace a Noun in a sentence with its pronoun. I will be using this to create a dataset for a NLP task. for example if my sentences are -->\n\n\"Jack and Ryan are friends. Jack is also friends with Michelle.\"\n\nThen I want to replace the second Jack(in italics and bold ) with \"He\".\nI have done the POS tagging to find the Nouns in my sentences. But I do not know how to proceed from here.\nIf I have a list of all possible pronouns that can be used, Is there a corpus or system that can tell me the most appropriate pronoun for the word?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":376,"Q_Id":64190127,"Users Score":2,"Answer":"You can almost do this with tools in Stanford CoreNLP. If you run the \"coref\" annotator, then it will attempt to determine the reference of a pronoun to other entity mentions in the text. There is also a \"gender\" annotator, which can assign a  (binary) gender to an English name (based just on overall frequency statistics). (This gender annotator can at present only be accessed programmatically; its output doesn't appear in our standard output formats.)\nHowever, both coreference resolution and automated gender assignment are tasks with mediocre accuracy, and the second has further assumptions that make it generally questionable. I find it hard to believe that doing this automatically will be a useful strategy to automatically produce data for an NLP task.","Q_Score":5,"Tags":"python,python-3.x,nlp,stanford-nlp,coreference-resolution","A_Id":64199169,"CreationDate":"2020-10-04T00:21:00.000","Title":"Changing a Noun to its Pronoun in a sentence","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to define a number of learnable parameters in my model that are multiplied by the feature map in feedforward  and updated when backpropagation.\nHow can i implement this in the chainer framework?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":64192930,"Users Score":0,"Answer":"I read a little and found my answer.\nIf you need to define a number of parameters in chainer that need to be learned, you should use chainer.links.Scale() function.\nfor example chainer.links.Scale(axis=1,W_shape=(8,8))\nW are the same parameters that are learnable in the network. If the feature map is x, W is multiplied by x and its updated in backpropagation.","Q_Score":0,"Tags":"python,deep-learning,implementation,backpropagation,chainer","A_Id":64193805,"CreationDate":"2020-10-04T09:18:00.000","Title":"Define a number of learnable parameters in Chainer","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am tryin to do a project that requires cv2 module. I downloaded the library through windows command prompt. pip install cv2module it installed successfully. but, when i try to import it on pycharm or python IDLE it throws an error like ImportError: DLL load failed while importing cv2: The specified module could not be found.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4660,"Q_Id":64193163,"Users Score":0,"Answer":"I was facing missing DLL issue.\n\nI deleted cv2 and openCV folder from the Python\\Python38\\Lib\\site-packages\\ folder in my system.\n2.Installed Media feature pack on windows 10 from Optional features settings.\n3.Then ran pip install opencv-python again.\nRebooted my system and import cv2 worked like a charm.","Q_Score":0,"Tags":"python,opencv,cv2","A_Id":65193898,"CreationDate":"2020-10-04T09:49:00.000","Title":"How can i import cv2 on python 3.8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been trying to unpack this like a dictionary or json in python pandas but it's not giving me an output into a dataframe. Can anyone point me in the right direction?\n0      [{'JournalLineID': 'XXX', 'AccountID': 'XXX', 'AccountCode': '200', 'AccountType': 'XXX', 'AccountName': 'XXX', 'Description': '', 'NetAmount': -428.0, 'GrossAmount': -428.0, 'TaxAmount': 0.0, 'TrackingCategories': [{'Name': 'Location', 'Option': 'SG', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}, {'Name': 'Sales Rep\/Dept', 'Option': 'HQ', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}]}, {'JournalLineID': 'XXX2', 'AccountID': 'XXX', 'AccountCode': 'XXX', 'AccountType': 'EXPENSE', 'AccountName': 'Subscriptions - Software', 'Description': 'XXXX', 'NetAmount': 400.0, 'GrossAmount': 428.0, 'TaxAmount': 28.0, 'TaxType': 'INPUT', 'TaxName': 'Purchases 7%', 'TrackingCategories': [{'Name': 'Location', 'Option': 'SG', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}, {'Name': 'Sales Rep\/Dept', 'Option': 'HQ', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}]}]\nWhen i try pd.DataFrame.from_records(df), it gives me an output that splits by the letter\n0    [   {   '   J   o   u   r   n   a   l   ... s   '   :       [   ]   }   ]   }   ]\nWhen i try pd.DataFrame(df),\nthis is the output:\n0    [{'JournalLineID': 'XXX', 'AccountID': 'XXX', 'AccountCode': '200', 'AccountType': 'XXX', 'AccountName': 'XXX', 'Description': '', 'NetAmount': -428.0, 'GrossAmount': -428.0, 'TaxAmount': 0.0, 'TrackingCategories': [{'Name': 'Location', 'Option': 'SG', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}, {'Name': 'Sales Rep\/Dept', 'Option': 'HQ', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}]}, {'JournalLineID': 'XXX2', 'AccountID': 'XXX', 'AccountCode': 'XXX', 'AccountType': 'EXPENSE', 'AccountName': 'Subscriptions - Software', 'Description': 'XXXX', 'NetAmount': 400.0, 'GrossAmount': 428.0, 'TaxAmount': 28.0, 'TaxType': 'INPUT', 'TaxName': 'Purchases 7%', 'TrackingCategories': [{'Name': 'Location', 'Option': 'SG', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}, {'Name': 'Sales Rep\/Dept', 'Option': 'HQ', 'TrackingCategoryID': 'XXX', 'TrackingOptionID': 'XXX', 'Options': []}]}]","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":143,"Q_Id":64193825,"Users Score":1,"Answer":"Remove the leading 0 and call pd.DataFrame() on the remaining part.","Q_Score":0,"Tags":"python,json,pandas","A_Id":64193880,"CreationDate":"2020-10-04T11:05:00.000","Title":"Unpack list of dictionary into Pandas dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a long ODE-integration in Python using scipy.integrate.solve_ivp. Is it possible to access the status of the integration or check at which integration step the routine is, while it is running? My integration is taking longer than expected and I would like to know whether the integrator is stuck at some step or whether the individual steps just take really long.\nFor future tasks; if I split the integration with solve_ivp into sub-intervals to print status messages in between, could this mess with the step-size adaptivity of certain solvers?\nThanks for any feedback!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":299,"Q_Id":64194348,"Users Score":4,"Answer":"There was a GitHub pull request to add a verbose option to solve_ivp, but this has not yet been done. You can either implement it yourself by modifying scipy's solve_ivp function (should be easy), or just print the time t that is given by the solver to your ODE function. That's what I do. If your system is not too small, then you don't loose much time because of the printing.\nSplitting the integration the way you suggest can work, however if you split every few time steps, you will lose time as the solver restarts each tile. The impact is related with implicit algorithms, as they compute the Jacobian of your system anew at each start.","Q_Score":1,"Tags":"python,scipy","A_Id":64943101,"CreationDate":"2020-10-04T12:01:00.000","Title":"SciPy: status of solve_ivp during integration","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question about Apache Kafka. I have a scenario where I want to find information in a large 6GB .xml file, which is the latest dump of wikipedia. As such, it contains logical collections of information, generally spanning 20-25 lines. My goal is to have names of 2 football players as input, and search through this document additional information (which is present there) and compare them. Since I will need to parse through the document every time new names are entered, I am considering a sequential search and regex pattern matching. Later maybe experiment with indexing and inverse indexing. For a start my input file will contain about 100 000 lines.\nI know the general concept of how Kafka works. There are servers which work as storage and other servers that are in charge of exporting and importing information. Then there are clients that can access this data and process it. My question is since this is just a school project, is there a point in me using kafka to process the input 6GB file? I have a simple demo running where I open and read a file in python and send it using a kafka producer and then \"receive\" it using a kafka consumer, but I am confused if it is not simpler to just read lines of the file as I go and look for the information I want.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":64197687,"Users Score":1,"Answer":"Kafka supports parallell processing by virtue of enabling topics to be split into partitions. In your case, I would consider creating a topic and splitting it into, say 50 partitions to begin with. You can then write records to the topic in quick succession from a single threaded process processing the xml.\nCreate a consumer that reads from the topic and performs the search; consider maybe outputting matching records to a final topic that your client can read from.\nInstead of multi-threading the consumer (using in-process threading), you can just start multiple isolated instances of it, as long as you configure them to all join the same consumer group. Have your producer round robin records (this is done automatically as long as each record has a unique key -- you could use a uuid if you have no natural key). As you bring up more instances of the consumer, the kafka brokers will ensure that each picks up a roughly equal subset of the partitions and so you get a sensible load balancing effect. You should find that performance increase as you increase the number of consumer processes up to the number of cores you have available to perform the search.\nBy having the process which produces records to the input topic in the first place also await a result on the final output topic, you can easily write the result to the same tty as that which you use to launch to initial processing.\nStarting multiple separate processes in the consumer group mimics the pattern of horizontal scaling in a distributed system. For example, in kubernetes, you can increase the number of replicas of a deployment (\/replicaset) and if you are using kafka in the above manner, you will see a similar load balancing behaviour.","Q_Score":0,"Tags":"python,apache-kafka","A_Id":64198535,"CreationDate":"2020-10-04T17:23:00.000","Title":"Using kafka as a framework to search for information","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on a small Python script that is running on my local server. I want to create a Ui for it with Qt because i work a lot with qml. Is it possible to make a PyQt web application that i can access through my browser inside my network?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":4484,"Q_Id":64198588,"Users Score":2,"Answer":"No.\nWeb apps and GUI programs are completely different beasts.\nUsually,\n\nGUI apps require just Python interpreter, your scripts, and proper GUI libraries. You access then from within your machine's operating system.\n\n(Python) Web apps require Python interpreter, running Web server software  and making of HTML\/Python web pages instead of  GUI components. Web page access happens (typically) from a browser environment, which might be local or remote.\n\n\nWhile it is not impossible that somebody could have made libraries for showing Python GUI interfaces over the Web,  it wouldn't make much sense, because it is usually much easier to just use some remote desktop software to access your machine and use native GUI.","Q_Score":3,"Tags":"python,qt,pyqt,qml","A_Id":64198803,"CreationDate":"2020-10-04T18:47:00.000","Title":"Is it possible to create a PyQt web application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I write a Python function that can takes n dimensional vectors and return boolean if vectors are linearly dependent? Can it be done using dot or do I need to write a full calculation?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1337,"Q_Id":64201090,"Users Score":1,"Answer":"You can check for the determinant of the matrix , if the determinant is zero then it's linearly dependent.\nYou can use the function np.linalg.det(Mat)","Q_Score":1,"Tags":"python,numpy","A_Id":64211143,"CreationDate":"2020-10-05T00:20:00.000","Title":"Python linear independence using numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning ML and I am stuck with this following line of code\ncan anyone help me yo know what does this line of does\nand the parameters required to give for it are??\ngzip.open('..\/data\/mnist.pkl.gz', 'rb')","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":81,"Q_Id":64201731,"Users Score":1,"Answer":"It starts to upload to memory the file you adressed in binary mode(fast way of reading), mostly you have to use rb argument.\nNext step is modifying this data and writing it back with 'wb' command.","Q_Score":0,"Tags":"python,gzip","A_Id":64202268,"CreationDate":"2020-10-05T02:23:00.000","Title":"gzip.open() function in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a DataFrame with 1M+ rows. I'm trying to run pivot table using pivot_table method from pandas on Anaconda. However, it has been running over 15+ min without result.\nI've tried to install modin, and vaex on Anaconda with no luck as both libraries are not accepted by Anaconda.\nNot sure if this matters, I'm using vs code to run Anaconda.\nAnyone has suggestions? Thank you,","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":260,"Q_Id":64201815,"Users Score":1,"Answer":"I don't have the issue by following the steps:\n\nconvert data type from 'str' to 'float' for the column I meant to sum through pivot_table; this is the calculation that I had problem with.\nconvert DataFrame to numpy array\ncalculate sum of the sliced numpy array (column). It tool less than 5 sec to return the total.\n\nAll good.","Q_Score":0,"Tags":"python,pandas,visual-studio-code,anaconda","A_Id":64202151,"CreationDate":"2020-10-05T02:37:00.000","Title":"Slow to run a pivot table of a DataFrame with over 1,000,000 rows by using pandas on Anaconda. Any suggestions to improve efficiency?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a huge data source with 500+ fields, and would like to rename them based on a mapping table I have (in Excel). Is it possible to do this programmatically (e.g. via Python) on my Tableau Desktop?\nTableau offers a couple of Python packages like\nTableau Server Client (TSC); tabcmd;\nBut they are meant for the server, and provide limited capabilities.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":302,"Q_Id":64202440,"Users Score":1,"Answer":"it can be done with an excel that has a mapping (previous name - new name)\nbut first, you need to convert your Tableau XML to a dataframe (a table of sorts basically) with the fields you need to change, you can do it through:\nthe ElementTree package, you will need to loop through the xml and search what you need (inside the xml: caption = name in tableau).\nAfter you have your fields in the df you can join it with the excel file and reassign names, specifically the \"caption\" is what you're looking for.\nIf you need any clarifications let me know.","Q_Score":1,"Tags":"python,automation,tableau-api","A_Id":68396834,"CreationDate":"2020-10-05T04:22:00.000","Title":"How to programmatically rename fields in Tableau Desktop (e.g. Python)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Have been trying to access Cuda within Tensorflow 2.3.1 (through PyCharm) to access my compatible GPU for object detection. TensorFlow was working previously, but when I installed Cuda I realised that it was 11.1 - where TensorFlow has a pre-requisite of Cuda 10.1. I had both versions on my computer, and tried to uninstall all the 11.1 toolkit using the Windows add\/remove tool (which is recommended). This seemed to work in removing 11.1, however, when I try to re-install the TensorFlow package into the Project Interpreter Setting (within PyCharm) it comes up with the following error:\n\n\nUnsatisfiableError: The following specifications were found to be incompatible with the existing python installation in your\nenvironment:\nSpecifications:\ntensorflow -> python[version='3.5.|3.6.|3.7.*']\nYour python: python=3.8\nIf python is on the left-most side of the chain, that's the version you've asked for. When python appears to the right, that indicates\nthat the thing on the left is somehow not available for the python\nversion you are constrained to. Note that conda will not change your\npython version to a different minor version unless you explicitly\nspecify that.\nThe following specifications were found to be incompatible with your system:\nfeature:\/win-64::__cuda==11.1=0\nYour installed version is: 11.1\n\n\nEDIT - this the the same when I try to install into the Conda Environment through Anaconda.\nSystem setup:\nWindows 10 (64bit)\nTensorflow 2.3.1\nCuda 10.1 (previously 11.1 installed - but I thought uninstalled)\ncdnn 64_7\nPython 3.8\nGraphics: 2070Super (driver:456.55)\nI understand that PyCharm is unable to install TensorFlow because this has a pre-requisite of Cuda 10.1, but I can't find any references to where it's still pointing to the older (newer 11.1) version. All my path environment variables point to the 10.1 directory. I wonder if there isn't a text\/init file somewhere that hard-sets the Cuda version, but haven't found anything on the NVidia site.\nSorry for the noob question, but I am hoping someone can point out where this reference to the newer 11.1 version might be lingering.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":377,"Q_Id":64203247,"Users Score":0,"Answer":"So I feel somewhat embarrassed - it turns out despite the Tensorflow website indicating that TensorFlow2.0 was compatible with Python3.8, once I reverted back to an earlier 3.7 it seems to have at least resolved that problem. I was fixated on the fact that it was falsely reporting Cuda v11.1. I think this is now resolved.","Q_Score":0,"Tags":"python,tensorflow,pycharm","A_Id":64218556,"CreationDate":"2020-10-05T06:10:00.000","Title":"Problem reverting to older Cuda version for TensorFlow in PyCharm (Windows 10)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am trying to install opencv .i downloaded  \"opencv3-3.1.0-py35_0.tar\" and extracted it after that copy the file in a system that hv no internet . i run the conda install PATH_TO_FILE\/opencv3-3.1.0-py35_0.tar through conda prompt....\nbut it is not helping & showing \"http error\"\nhow to import libraries offline?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":64205955,"Users Score":0,"Answer":"Try unzipping  the file, then open a terminal on that directory, run- pip install your-unzipped-folder\/filename.\nyou can also use wheel- before the previous command- run - pip install wheel- first.","Q_Score":0,"Tags":"python,opencv,anaconda,shared-libraries","A_Id":64207219,"CreationDate":"2020-10-05T09:29:00.000","Title":"how to install python and machine learning libraries offline in windows 10?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently started learning Django and when I am writing templates, I have to switch between HTML and Django HTML extensions to use the tab for autocompletion.\nWith the HTML extension, I can autocomplete the tags using the tab but when Django HTML is in use, it does not work anymore and have to write all the tags manually. Switching between the two is also frustrating, and sticking with the HTML extension means writing the Django syntax (eg. loops, if, and so on) manually also.\nIs there any extension that provides this? Or is there any way to use both at the same time? If not, even a quick shortcut for switching between the two would help.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":64208292,"Users Score":0,"Answer":"you can install the django template extension. that will enable the autocomplete functionalities for the django template language.","Q_Score":1,"Tags":"python,django,visual-studio-code","A_Id":64208369,"CreationDate":"2020-10-05T12:04:00.000","Title":"Can I use Django and HTML extensions at the same time in VSCcode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wrote a code with python that uses clustering to detect colours in an image, is there any API's or techniques that I can use the code in my ios application that I want to publish?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":24,"Q_Id":64208417,"Users Score":0,"Answer":"If the algorithm uses a library such as OpenCV, you can keep using that (but from C++). Otherwise, you have to rewrite the algorithm in Swift, Objective-C, or C\/C++.","Q_Score":0,"Tags":"python,ios,cluster-analysis,coreml","A_Id":64215766,"CreationDate":"2020-10-05T12:14:00.000","Title":"can I use a clustering model written in python in an iOS application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with a dataframe that was 20 columns. When I try to display output using .show() after manipulations, due to the large number of columns its not very easy to read. What's the best way to get a compact view of all columns?\nThanks\nSS","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":187,"Q_Id":64208484,"Users Score":0,"Answer":"the display() function is what you want.\nIf your dataframe is named df, you'll call the function as such:\ndisplay(df) .","Q_Score":0,"Tags":"python,pyspark","A_Id":64234981,"CreationDate":"2020-10-05T12:18:00.000","Title":"show() for large number of columns in pyspark","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a multiclass classifier to identify topics of Facebook posts from a group of parliament members.\nI'm using SimpleTransformers to put together an XML-RoBERTa-based classification model. Is there any way to add an embedding layer with metadata to improve the classifier? (For example, adding the political party to each Facebook post, together with the text itself.)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":394,"Q_Id":64209118,"Users Score":1,"Answer":"If you have a lot of training data, I would suggest adding the meta data to the input string (probably separated with [SEP] as another sentence) and just train the classification. The model is certainly strong enough to learn how the metadata interract with the input sentence, given you have enough training examples (my guess is tens of thousands might be enough).\nIf you do not have enough data, I would suggest running the XLM-RoBERTa only to get the features, independently embed your metadata, concatenate the features, and classify using a multi-layer perceptron. This is proably not doable SimpleTransformers, but it should be quite easy with Huggingface's Transformers if you write the classification code directly in PyTorch.","Q_Score":1,"Tags":"python,deep-learning,nlp,text-classification,bert-language-model","A_Id":64221614,"CreationDate":"2020-10-05T13:00:00.000","Title":"Can I add a layer of meta data in a text classification model?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im Trying To Buy A Laptop Automatically But When I Try To Put In The Credit Card Number It Gives The Error selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate Im Using Xpath btw.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":686,"Q_Id":64211415,"Users Score":0,"Answer":"If u try to locate it by id. It is false. I'd will be keep changing for everytime. Try to identify with name \"addCreditCardaNumber\"\nIt will work for u.","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,webdriver","A_Id":66450741,"CreationDate":"2020-10-05T15:14:00.000","Title":"Im Trying To Automate Buying Something on Amazon With Selenium Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to connect to my MongoDB and updating a document.\nWe're using a replica server as a seed and then we want to write a collection (specifically, update a document).\nNo matter what I do, every time I try to update the given document, I get the following error: NotMasterError: not master, full error: {'ok': 0.0, 'errmsg': 'not master', 'code': 10107, 'codeName': 'NotMaster'}.\nI've tried changing the read pereference to Primary, changing the write concern to w: 1 but nothing seems to work.\nWhen I debug, I can see that the client discovered all the machines in the network, including the actual master.\nWith a Mongo library in another language (Reactivemongo in Scala), this is done automatically but seems that with PyMongo I'm struggling. How can I ensure that the update gets forwarded to a Primary node?\nIf anybody can help,  that'd be great :)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":717,"Q_Id":64212449,"Users Score":0,"Answer":"Read preference applies to reads. It has no effect on writes. All writes must be sent to the primary.\nYou should be connecting to replica set (also known as \"discovering the topology\") instead of using a direct connection, and then specifying read preference for secondary reads.","Q_Score":0,"Tags":"python,mongodb,pymongo,pymongo-3.x","A_Id":64214697,"CreationDate":"2020-10-05T16:17:00.000","Title":"PyMongo - Write to Primary when using Secondary as seed","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"I have a like function in views.py and whenever the function executes I want my user to be returned to the same page he\/she was before the funcion executed.\nWhat should I write in return of my function?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":64212612,"Users Score":0,"Answer":"You could simply return using the same HTML template to the user","Q_Score":0,"Tags":"python,django","A_Id":64213237,"CreationDate":"2020-10-05T16:28:00.000","Title":"How can i redirect to the same page when a function executed Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Seaborn will not update to the latest version (0.11.0) in Anaconda. When doing a conda search seaborn, the 0.10.0, 0.10.1, and 0.11.0 versions are listed, but the associated build is listed as py_0 for each. When attempting to update in Anaconda, version 0.9.0 remains.\nHow can I go about getting the latest version? I've tried installing via pip and conda-forge to no avail (conda-forge fails when solving environment).\nThank you!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":5959,"Q_Id":64213633,"Users Score":1,"Answer":"Try to use this:\npip install --upgrade seaborn","Q_Score":3,"Tags":"python,python-3.x,anaconda,seaborn","A_Id":67133584,"CreationDate":"2020-10-05T17:41:00.000","Title":"Seaborn will not update to latest version in Conda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Seaborn will not update to the latest version (0.11.0) in Anaconda. When doing a conda search seaborn, the 0.10.0, 0.10.1, and 0.11.0 versions are listed, but the associated build is listed as py_0 for each. When attempting to update in Anaconda, version 0.9.0 remains.\nHow can I go about getting the latest version? I've tried installing via pip and conda-forge to no avail (conda-forge fails when solving environment).\nThank you!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5959,"Q_Id":64213633,"Users Score":3,"Answer":"Try to use this:\nconda install seaborn=0.11.0\nIf that doesn't work, create a new environment and do the same thing.","Q_Score":3,"Tags":"python,python-3.x,anaconda,seaborn","A_Id":64213662,"CreationDate":"2020-10-05T17:41:00.000","Title":"Seaborn will not update to latest version in Conda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are migrating data from a Firebird database using Python FDB to Azure SQL using pyodbc. There are many tables, and we could generate a Polybase workflow for each one, that is more work with many benefits.\nHowever, I would like to see if we can write the data to the Azure SQL in 20MB segments through pyodbc.\nIs there a way to detect the result set that comes back from FDB to make sure it is below 20MB?\nOther than writing each result set (guess at the number of records that would be 20mb) to a file and measuring that, could I do it on the allocated memory instead somehow and then refetch till I get the right size?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":64214222,"Users Score":0,"Answer":"Congratulations you find a solution in the end:\n\n\"We decided to generate a Polybase workflow for each table we will\nmigrate since that will be faster and reusable for later.\"","Q_Score":0,"Tags":"python,azure-sql-database,prepared-statement,pyodbc,firebird-3.0","A_Id":64586326,"CreationDate":"2020-10-05T18:28:00.000","Title":"How to measure prepared statements memory size in Python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a CNN with a similar architecture as VGG16. I know in VGG16 u do rescale u also center around 0. Now I train mine from scratch, does it make a difference and should I do it or no? Anyone who can help?\ndatagen = ImageDataGenerator(rescale=1. \/ 255)\nThanks a lot guys! <3","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1092,"Q_Id":64215709,"Users Score":2,"Answer":"Rescaling to 0-1 in general is always a good choice when training neural networks, so yes go for it. The reason behind this is that neural networks tend to yield better results when the inputs are normalised. You could run the same exact experiment with pixel rescaling and without pixel rescaling and see for yourself the results!","Q_Score":0,"Tags":"python,tensorflow,keras,conv-neural-network,image-classification","A_Id":64216427,"CreationDate":"2020-10-05T20:24:00.000","Title":"do I use \"rescale=1. \/ 255\" or not? Building VGG-like CNN","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"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":"python version is displayed as Python 2.7.14 when checked in cmd (strange because I have always installed python 3.6 onward). But python shell in IDLE shows Python 3.7.6. I was notified of this when using f'' strings got errors.\nAlso python path in environment variables is set to python37. I was wondering why this was happening and how to change it.\nP.S: I have not tried reinstalling python yet.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":64221098,"Users Score":0,"Answer":"Check if your environment variable is set to the correct Python executable path.\nYou can find your active executable with where python on windows and with which python on Linux. I guess you have an old executable active on your machine.\nhappy coding,\nbreadberry","Q_Score":0,"Tags":"python,python-3.x,version","A_Id":64221280,"CreationDate":"2020-10-06T07:24:00.000","Title":"Python version displayed different than installed version [WINDOWS]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"After installing tensorflow when i import tensorflow getting this error\nImportError: DLL load failed while importing _pywrap_tensorflow_internal:A dynamic link library (DLL) initialization routine failed.\nDetails -----\ntf-cpu version 2.2.0\npython version 3.8.3","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1773,"Q_Id":64224572,"Users Score":2,"Answer":"Are you using conda (or any other package management system)? If so, did you install your tensorflow using conda install tensorFlow or pip install tensorflow?\nif you installed it with pip, I recommend you to uninstall it and then install tensroflow from conda. This should solve this.","Q_Score":0,"Tags":"python,tensorflow","A_Id":64393096,"CreationDate":"2020-10-06T11:08:00.000","Title":"ImportError: DLL load failed while importing _pywrap_tensorflow_internal:A dynamic link library (DLL) initialization routine failed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a solution at the following problem:\nI have my neural network with 8 features and 6 outputs.\nThe network predicts some info on a graph, where a record is related to a node in the graph.\nIt works perfectly when I have all the examples (nodes) with the same degree of neighbours.\nNow I would need it to work also for nodes with less neighbours, but on a general form, meaning that I do not know a priori how many they are.\nThus I tried putting a zero when the the neighbour does not exist, but the predictions where all strange, not correct at all.\nSo my questions is: is there a way such that during training I can switch off some input neurons looking at how many effective features I have on that example?\nTo be more precise: the first example taken by the NN has the full neighbour, thus I have 8 values; the second has 6 values, so I would like to switch off 2 input neurons and so on.\nAny ideas ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":77,"Q_Id":64225655,"Users Score":1,"Answer":"A simple solution which might work would be to declare a feature as non relevant. So you simply specify a value, which makes the model learn that it should not be used in this iteration. So when you set the values to zero, the model wll just think that its a zero, so the meaning is ambiguus. However if you set it to -1 e.G. but -1 does not occur in your data at all, the model might be able to learn that -1 represents a non existent feature and puts more attention on the others.","Q_Score":1,"Tags":"python,tensorflow,deep-learning,neural-network,feature-selection","A_Id":64227403,"CreationDate":"2020-10-06T12:17:00.000","Title":"turn off features during training in deep network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to develop a React Client that consumes the Frappe REST API but on each request I am getting a CORS error. according to the community forum, I have to edit the Nginx conf to allow CORS requests but I am facing this error on my machine (localhost) and the dev server is not Nginx so how can I allow CORS requests on localhost?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":591,"Q_Id":64229353,"Users Score":0,"Answer":"I don't think you need to configure CORS, especially during local development.\nLet's say your React client is running the port 8080 and Frappe server is on 8000. You can proxy all your requests from localhost:8080 to localhost:8000.\nIn production, you can generate the static assets and put them in the www folder of the Frappe app.","Q_Score":0,"Tags":"python-3.x,erpnext,frappe","A_Id":64578766,"CreationDate":"2020-10-06T15:47:00.000","Title":"Frappe Framework ERPNEXT: How to enable CORS on localhost","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to develop a React Client that consumes the Frappe REST API but on each request I am getting a CORS error. according to the community forum, I have to edit the Nginx conf to allow CORS requests but I am facing this error on my machine (localhost) and the dev server is not Nginx so how can I allow CORS requests on localhost?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":591,"Q_Id":64229353,"Users Score":0,"Answer":"Add \"allow_cors\": \"*\" to common_site_config.json and restart bench","Q_Score":0,"Tags":"python-3.x,erpnext,frappe","A_Id":69908944,"CreationDate":"2020-10-06T15:47:00.000","Title":"Frappe Framework ERPNEXT: How to enable CORS on localhost","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Dataframe of which one column contains several missing values, which are printed as NaN. I want to replace the missing values with the number 0. How can I do that with the fillna() function?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":64229976,"Users Score":0,"Answer":"does using data.fillna(0) work for you?","Q_Score":0,"Tags":"python,pandas","A_Id":64230053,"CreationDate":"2020-10-06T16:24:00.000","Title":"How can I fill in missing values (NaN) at a particular column in a data frame?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to sort my query set by a \"ranking value\" which I have as a decimal field in my django model, however it seems the \"order_by\" function doesn't seem to work? my query set is always the same, with no ordering.\nI have tried the google but come up short, am I missing something here?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":275,"Q_Id":64233816,"Users Score":-1,"Answer":"I need to see your code, but without looking i can ask you to use the \"round(x)\" function (where x is a float) on all your values, it will not change the ranking (mathematically sure about this), and order_by will work\nWould love to see your code indeed !\nTip : Use a for loop to round all the numbers or make a function","Q_Score":2,"Tags":"python,django,web,web-applications","A_Id":64233939,"CreationDate":"2020-10-06T21:08:00.000","Title":"How to order a filtered django query set by a decimal field","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using a Jupyter Notebook connected to an AWS EMR Cluster. The subnets and security groups attached to all nodes of the cluster are able to connect to the internet.\nHowever, when I attempt to pip install <package> from the Notebook attached to the EMR cluster, I get the following error:\nWARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f6b4c6bd710>: Failed to establish a new connection: [Errno 101] Network is unreachable')': .....\nI have also tried to make a GET request to the internet r = requests.get('https:\/\/www.google.com'), which was also unsuccessful. I'm unable to figure out what is preventing my connectivity to the internet from my Jupyter Notebook on AWS EMR.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":952,"Q_Id":64234516,"Users Score":0,"Answer":"In my case it turned out to be a problem with the sg ElasticMapReduceEditors-Livy & ElasticMapReduceEditors-Editor\nI had created, I just added a rule in both sg that would allow all outbound traffic to test if that solved it, luckily it solved it, then I removed both rules and mysteriously my notebooks kept working as usual,\nI think it was bad behavior from aws.","Q_Score":2,"Tags":"python,amazon-web-services,pip,jupyter-notebook,amazon-emr","A_Id":69194527,"CreationDate":"2020-10-06T22:12:00.000","Title":"Unable to install package through pip on AWS EMR Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Recently I switched computers and re-downloaded my python and pycharm, I tried activating my saved projects on the new computer, but I ran into problem, pycharm doesn't recognize the parent folder of some of the files, and mistakes it for a module.\nThe folder is called: \"Enrichment_extra_stuff\", and when I try to import file in that folder, from another file in that folder, it seems like pycharm recognize it, because it shows me all of the files inside it, but when I run the code, I get the error ModuleNotFoundError: No module named 'Enrichment_extra_stuff'.\nAlso weirdly, when I try doing explict import and just write import fr to import the file fr, then pycharm shows an error but when I run it, it works like it should.\nI tried digging a bit on pycharm, but got confused and didn't found anything, my python interpreter version is 3.8 and I program on windows if that helps.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":64235859,"Users Score":0,"Answer":"A folder (or better a directory) is not seen as a module, unless you put __init__.py file in it. This could be empty, or it should be the module content. This is Python: a module is either a file, or a directory with __init__.py\nThe second part is only for Pycharm: PyCharm is created to handle large projects, and often your program is not in the base (root) directory of your project, but in one (or more) subdirectories (e.g. src). So you should explicitly tell PyCharm which are the root directories. So, go to the project structure panel (the panel with the files, usually on left side), go to your \"root\" directory, and set with right mouse click on your base source directory: on the pop-up menu select Mark directory as, and then select Source Root.","Q_Score":0,"Tags":"python,pycharm","A_Id":64239504,"CreationDate":"2020-10-07T01:17:00.000","Title":"Pycharm mistakes folder for module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing animations in manim ...\nI know if you write:\n\nself.add_sound(\"name_file.mp3\")\n\nthe name_file.mp3 will play but if at some point of the animation I'd like to pause the music or remove it\nHow can I do it?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":262,"Q_Id":64236768,"Users Score":2,"Answer":"Short Answer: At this time, Manim doesn't support pausing or stopping the sound file.\nManim only supports adding a complete sound file to the animation.  If you need the sound file edited in any way other than a simple adjustment of the gain (which is a single setting that is applied to the entire sound clip), then you will have to do so outside of Manim.","Q_Score":2,"Tags":"python,manim","A_Id":66111332,"CreationDate":"2020-10-07T03:27:00.000","Title":"How to pause or remove sounds in manim?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am confused about tsfresh input format. Can I give a dataframe with missing values for different ids? For example, timeseries 1 {t0: 1, t2: 4, t5: 1} and timeseries 2 {t1: 5, t2: 2}. Should I fill missing values(t1, t3 etc.) with 0?\nthanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":175,"Q_Id":64238345,"Users Score":2,"Answer":"tsfresh does not \"care\" about the time entries of your data. Most of its feature calculators do not need to have fixed time intervals (e.g. the mean of a timeseries is still the same, no matter which time stamps we are talking about). So yes, technically it is possible to have different times for different ids.\nThat being said, some feature calculators do rely on the time stamp and having proper time intervals (e.g. Fourier transformation). However, there exist many different ways on how to fill these missing values which need a lot of domain knowledge. That is why tsfresh does not do this \"automatically\". However, many libraries (e.g. pandas), give many possibilities for this, e.g. using resampling methods.","Q_Score":1,"Tags":"python,time-series,tsfresh","A_Id":65476168,"CreationDate":"2020-10-07T06:25:00.000","Title":"tsfresh timeseries missing values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"PyCharm offers to synchronize imported packages (eg openpyxl) with repositories.\nIs it good practice to synch these (even though they are imported standard packages)?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":11,"Q_Id":64238725,"Users Score":0,"Answer":"The answer is no.\nA virtual environment need not be replicated as the packages and their version can be listed with the pop freeze command into a text file called requirements.txt that should be shared.\nOthers can use this file to build up the libraries.","Q_Score":0,"Tags":"python-3.x,github,pycharm","A_Id":65384529,"CreationDate":"2020-10-07T06:52:00.000","Title":"Should libraries be synchronized with a repository (eg GitHub)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using xlsxwriter to export pandas dataframe to excel file. I need format a range of cells without using worksheet.write function as the data is already present in cells.\nIf I am using set_row or set_column, it is adding the format to entire row or column.\nPlease help me find a solution.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":408,"Q_Id":64239147,"Users Score":1,"Answer":"I need format a range of cells without using worksheet.write function as the data is already present in cells.\n\nIn general that isn't possible with XlsxWriter. If you want to specify formatting for cells then you need to do it when you write the data to the cells.\nThere are some options which may or may not suit your needs:\n\nRow and Column formatting. However that formats the rest of the row or column and not just the cells with data.\nAdd a table format via add_table().\nAdd a conditional format via conditional_format().\n\nHowever, these are just workarounds. If you really need to format the cells then you will need to do it when using write().","Q_Score":0,"Tags":"python,python-3.x,pandas,xlsxwriter","A_Id":64239595,"CreationDate":"2020-10-07T07:21:00.000","Title":"Cell Format for a range of cells using xlsxwriter","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Jenkins. I installed python plugin which is available from Jenkins UI. But seems like it install python 2. I want to have python 3 on Jenkins. I haven't find anything on internet relevant. There are couple of question on similar lines but none of them have proper answers.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3156,"Q_Id":64241539,"Users Score":0,"Answer":"In my experience, the best way to do it is to write a shell script for what you need to do and then call this shell script from Jenkins as a \"shell command\" step.\nIt's simple, it puts you in control and it gives you everything you need. You are not limited by what Jenkins provides, it works great with virtualenv and your developers can run the same script on their computers which is also extremely helpful.\nYou can commit this script as part of the project in your repository.","Q_Score":0,"Tags":"python,python-3.x,jenkins,jenkins-plugins","A_Id":64241693,"CreationDate":"2020-10-07T09:52:00.000","Title":"How to get python3 on jenkins?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just installed 3.9 to replace a 3.6 installation on my laptop.\nBecause Windows file association only works with .exe files, not .bat, files, there is no way to click on a file .py and get it to open with IDLE.  But it did with 3.8 on my desktop.\nThe 3.8 programs (including idle.exe pip etc) were installed into the default folder C:\\Users{..}\\AppData\\Local\\Microsoft\\WindowsApps\nThe 3.9 (without  idle.exe pip etc) was installed on C:\\Program Files\\Python39\nWhat has changed, and why?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":677,"Q_Id":64244612,"Users Score":0,"Answer":"Anything installed in C:\\Users\\Someuser\\AppData is installed for Someuser only.  Anything installed in ...\\Local\\Microsoft\\WindowsApps comes from Microsoft.  So I presume your 3.8 comes from the Microsoft store.  I believe it will be upgraded to 3.8.6 soon if not yet.  3.8 installed for one user with the python.org installer will, I believe, go by default in the location indicated by superb rain.\nYour 3.9 is installed for all users with, I presume, the 64-bit installer from Python.org.  The Windows installer predates the Microsoft store version by maybe 2 decades and does not do exactly the same thing.\nEDIT: If you can use arguments in a file association, and if 3.9 is indeed from python.org and if you checked the box to install py.exe, then py -3.9 -m idlelib should work if Windows simply appends the file path to the string given.","Q_Score":1,"Tags":"python,default,python-idle","A_Id":64250165,"CreationDate":"2020-10-07T13:04:00.000","Title":"Python IDLE.bat, not IDLE.exe, installed on Win10 with Python 3.9","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I type python --version in python 3.9 shell, I get python not defined.\nThe same command does not work when run from saved file or from shell.\nWhen I type pip install jupyter I get invalid syntax.\nAm I doing something wrong?\nI just installed python and am just beginning with it and not sure why I can't get these to work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":108,"Q_Id":64246555,"Users Score":0,"Answer":"Ok, found issue. You cannot get \"python --version\" by typing it into the python shell, I typed it into the command prompt for windows and it worked fine. Maybe I will have the jupyter thing figured out by tommorow.","Q_Score":0,"Tags":"python,shell,pip,jupyter-notebook,version","A_Id":64263940,"CreationDate":"2020-10-07T14:45:00.000","Title":"Can't get jupyter notebook to run when I put in python shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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 have dataframe with columns(issue_id,summary, source_id). The source_id has values ranging from 1 to 3.\nI want to create multiple dataframes having name df_1, df_2,df_3  as per the values in source_id.\nI tried groupby and it gave a dict. but converting dict to dataframe is giving only 1 dataframe.\ndata_dict={'df'+str(i): grp for i , grp in df.groupby('Source_sys')}\npd.DataFrame.from_dict(data_dict,orient = 'index')\noutput:\n0\ndf1     Issue ...\ndf2     Issue ...\ndf3     Issue ...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":64247027,"Users Score":0,"Answer":"The simple way is delete other columns and assign different name. @krishna","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":64247086,"CreationDate":"2020-10-07T15:11:00.000","Title":"create multiple dataframes from unique values of a cloumn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Problem:\nSometimes it is nice to be able to remove or apply a try statement temporarily.  Is there a convenient way to disable the try statement without re-indenting?\nFor example, if there was a python block statement equivalent called \"goForIt:\"  one could edit the word \"try:\" to \"goForIt:\" and it would just execute the block as though it were not wrapped in a \"try\" and ignore the \"except\" line too.\nThe problem I'm trying to solve is that while I want the try statement in production I want to be able to remove it temporarily while debugging to see the error traceback rather than have it trap and process the exception.\nCurrently I work around this by commenting out the \"try\" then re-indent the code in the block.  Then comment out the entire \"except\" block.   This seems clumsy.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":64247484,"Users Score":0,"Answer":"If you want a none code solution you need to use an IDE or a good text editor.\nI am using Visual Studio code where I can indent with a keyboard shortcut (Ctrl + ` in my case)","Q_Score":1,"Tags":"python,exception","A_Id":64247647,"CreationDate":"2020-10-07T15:37:00.000","Title":"Is there a simple way to comment out or diable a python try statement without re-indenting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to execute fastapi in shell.\nfor example, we can do it with below code in django:\npython manage.py shell\nhow can I do this in fastapi?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1545,"Q_Id":64247596,"Users Score":1,"Answer":"Simple answer, You can not.\nmanage.py does the same thing as django-admin but also sets the DJANGO_SETTINGS_MODULE environment variable so that it points to your project\u2019s settings.py file. In FastAPI we don't have admin utility, because there is no out-of-box config, environment management etc. That's the main difference between a microframework and a high-level framework.\nFastAPI does not have any administration utilities out-of-box.","Q_Score":3,"Tags":"python,shell,fastapi","A_Id":64251509,"CreationDate":"2020-10-07T15:42:00.000","Title":"How to run FastAPI from terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"As said in the title, i want to get a number of record in my topic and i can't find a solution using kafka-python library.\nDoes anyone have any idea ?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":3943,"Q_Id":64247670,"Users Score":2,"Answer":"There is no specific API to count the number of records from a topic. You need to consume and count the number of records that you received from kafka consumer.","Q_Score":4,"Tags":"python,apache-kafka,kafka-python","A_Id":64247791,"CreationDate":"2020-10-07T15:46:00.000","Title":"How to count number of records (message) in the topic using kafka-python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As said in the title, i want to get a number of record in my topic and i can't find a solution using kafka-python library.\nDoes anyone have any idea ?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3943,"Q_Id":64247670,"Users Score":1,"Answer":"One solution is you can add one message each to all the partition and get the last offset. From offsets you can calculate the number of total message sent till now to the topic.\nBut this is not the right approach. You are not aware about how many messages consumers have already consumed and how many messages have been deleted by kafka. The only way is you can consume messages and count the number.","Q_Score":4,"Tags":"python,apache-kafka,kafka-python","A_Id":64247902,"CreationDate":"2020-10-07T15:46:00.000","Title":"How to count number of records (message) in the topic using kafka-python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python library in a folder which is not recognised by Anaconda Jupyter Notebook, so if I import <module name> I get No module named '<module name>'.\nHow can I add the folder to the path? Spyder has the pythonpath manager in which I can just add a folder, but I cannot see how to do it in Jupyter Notebook.\nFollowup question: is there a way to add a folder to the python path, such that all Anaconda applications, Spyder, Jupyter, etc., recognise it? Or dies it have to be done for each application separately?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1675,"Q_Id":64247753,"Users Score":1,"Answer":"PYTHONPATH is an environment variable that you can set to add additional directories where python will look for modules and packages. The how to depends on your OS. In Windows just search for environment variables.\nThe only reason to set PYTHONPATH is to access directories with custom libraries that you do not want to install in the default location, i.e. the site-packages directory.","Q_Score":0,"Tags":"python,python-3.x,jupyter-notebook,anaconda,jupyter","A_Id":64249010,"CreationDate":"2020-10-07T15:51:00.000","Title":"How to add folder to PYTHONPATH in Anaconda Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to generate a Dataframe which involves three industries, 100 investors, and 2000 firms in 50000 different deals. So, I have 50000 rows and four columns, including deal's date.\nI randomly assigned 100 investors and 2000 firm in this dataset for all deals.\nMy problem is that I need to determine the industry for each deal by considering a couple of conditions that should hold for this process. 1) If a firm randomly assigned to an industry, this firm should hold in the same industry in the whole dataset. 2) All investors invest at least in one industry, 15 investors invest at least in two industries, and four investors invest in all three industries. I don't know how I can do this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":64247853,"Users Score":0,"Answer":"This seems like 2 separate questions\nFor 1, one idea is to just hash the firm name and then that will give you a deterministic way of setting which firm goes to which industry.\nFor 2, one idea is to use a permutation function. For example, you can use numpy.shuffle where the first 4 belong to all 3, then the next 15 belong to a random subset of 2... etc, etc.\nYou could then generate tables off of all this information and use joins to concatenate your final table, where you initially start off with just trade dates, firms, and deal info.\n(This is just a starting idea)","Q_Score":1,"Tags":"python,python-3.x,dataframe","A_Id":64258036,"CreationDate":"2020-10-07T15:57:00.000","Title":"Adding random values between one to three to a column of a DataFrame conditional on some conditions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to copy image from my local disk to resource folder in pycharm, I could see there is no resource folder in 'src' or 'test'. As we get the 'resource' folder in IntelliJ by default, I would like to have a resource folder in pycharm for python programming, please let me know, is there any possibility\/way ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":64249893,"Users Score":0,"Answer":"I have created Resource directory manually, and tried using the root path in my project. It was successful.","Q_Score":0,"Tags":"python,image,resources","A_Id":64533104,"CreationDate":"2020-10-07T18:07:00.000","Title":"How to get resource folder in pycharm for python programming","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to transmit data with a slow web-service; but all the same I want to avoid busy waiting.\nIs there a way that I can do asyncio.sleep in the ETL graph? do other async\/await commands can be used in bonobo?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":64252120,"Users Score":0,"Answer":"Currently there is no active work on bonobo library, and the async features of it does not actually work. So, there is no way of using asyncio.sleep in current bonobo version.","Q_Score":0,"Tags":"python,bonobo-etl","A_Id":65639623,"CreationDate":"2020-10-07T20:50:00.000","Title":"How can I use asyncio.sleep in python-bonobo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"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 have an instance of ElasticSearch running on a server. When I try to index a huge corpus using multiprocessing, I get a lot of timeout errors. It seems that the EasticSearch can handle only a few numbers of requests. I've followed the configuration suggested in the ElasticSearch website. Are there any suggestions on what should I do to increase its indexing performance for a multiprocessing setting? The index that I'm adding documents to has one shard.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1065,"Q_Id":64255263,"Users Score":1,"Answer":"There are plenty of works that you can do.\n\nFirst, you need to set refresh_interval. Refresh interval is the time that the added document will become available for search. If you can tolerate set it to at least 30 seconds or -1. I have read that this will increase the indexing performance by about 70%.\n\nThe second thing that you can try is to use bulk index API instead of a single document indexing.\n\nDisabling swap can make an upper performance for you in some special cases.\n\nOne of the other options that you can try is to increase the RAM size that you have assigned to your elasticsearch;\n\nFinally, increasing the size of HEAP to be used for indexing can increase the writing performance. the default size is 10 percent of all heap size.\n\n\nI hope these points could help you.","Q_Score":1,"Tags":"python,elasticsearch,multiprocessing","A_Id":64278646,"CreationDate":"2020-10-08T03:15:00.000","Title":"ElasticSearch Timeout Error: ReadTimeoutError(HTTPConnectionPool(host='localhost', port=9200): Read timed out. (read timeout=60))","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"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":"Using DynamoDB.\nAn online store where you see a snapshot of the data for 20 items on the first screen, including price, picture, product name.\nWhen you click on the product it reveals more data, such as description, any deals, more images, etc.\nWould you make another call to the database for the second view or just get all the data on the first call?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":18,"Q_Id":64262361,"Users Score":1,"Answer":"When considering \"best practices\", I wouldn't consider one approach a clear winner over another.  Which approach works best for you will depend on the specifics of your application.  For example, are you in a high latency\/low bandwidth environment?  Are you on a mobile device? How often is this query run?  Etc.\nI would recommend starting by pulling back all the data you need in a single request because it's simpler.  If you run into performance issues along the way, you can circle back and try fetching additional data on an as-needed basis.\nIf there is a \"best practice\" here, it's to avoid pre-optimizing your code.  Now if only I could take my own advice :)","Q_Score":0,"Tags":"python,database,amazon-dynamodb,dynamodb-queries","A_Id":64266772,"CreationDate":"2020-10-08T12:18:00.000","Title":"Read entire item from database to begin with or make a second call when needed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How do I get logs from different workers in a single file in Celery.\nI have 3 workers running python tasks and a master node which runs the broker. I want to consolidate logs from these worker machines and store it in the master machine. How can I do that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":64263702,"Users Score":0,"Answer":"We have all our Celery workers on AWS EC2 instances configured to upload Celery logs to CloudWatch. This is one way to achieve what you want. It is not difficult to implement this kind of system even if you are not on AWS - all you need is an agent running on each worker machine that periodically uploads Celery logs to central place. It can even be a cron-job running a script that does the job for you.","Q_Score":1,"Tags":"python,flask,celery,python-logging,celery-log","A_Id":64264246,"CreationDate":"2020-10-08T13:35:00.000","Title":"How to consolidate celery logs from different computers. CELERY","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working to calculate similarities of labels of materials. Where each label might have 1-10 words in it. I am using gensim word2vec to find cosine similarities.\nMy approach is simply to treat each label as a 'sentence' and tokenize each word.\nexample:\nlabels = ['wooden desk cherry', 'long sleeve shirt cotton',..]\nsentences = [['wooden', 'desk', 'cherry'], ['long', 'sleeve', 'shirt', 'cotton'],..]\nMy question is does word2vec take neighboring sentences into its context. for example if i am using a window = 2, when looking at words around 'long', will 'cherry' be included or only 'sleeve'.\nIf neighboring sentences are considered is there a way to only consider words within the target words sentence.\nThanks for any help. I have read the Word2Vec documentation and couldn't find any information about this.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":97,"Q_Id":64267811,"Users Score":2,"Answer":"Gensim's Word2Vec works on whatever chunks of text you provide to it. So, when you supply ['wooden', 'desk', 'cherry'] and ['long', 'sleeve', 'shirt', 'cotton'] as separate items in the training corpus, no training windows will blend them together.\n(Separately: in sufficiently-large training sets, it'd be unlikely for such 'bleed-over' to make much difference, even if it did happen. It'd be a little bit of random-interference, since the source data doesn't truly imply those words appeared together. But the curve-balls it throws the training should be swamped out by the 'real signal' in true co-occurrences.)","Q_Score":1,"Tags":"python,machine-learning,nlp,gensim,word2vec","A_Id":64269938,"CreationDate":"2020-10-08T17:32:00.000","Title":"does gensim Word2Vec include neighboring sentences in context?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset that contains many binary columns. In the first half, each row has at least a 1; on the second half, each row has all zeros across all columns.\nIs there a function to randomize rows so that they are not grouped by rows that have at least one 1 and rows that have all zeros?\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":194,"Q_Id":64269183,"Users Score":0,"Answer":"You can use .sample(n) on your pandas dataframe to view a random sample of n items if that is all you need...","Q_Score":0,"Tags":"python,pandas,dataframe,data-cleaning","A_Id":64269244,"CreationDate":"2020-10-08T19:11:00.000","Title":"How mix rows around in a Pandas DataFrame?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Tried installing requests-html through pip and pip3 in many different ways (recommendations from other StackOverflow threads) and I keep on getting the same error ImportError: No module named requests_html.\nChecked pip and pip3 list, both of them have requests and requests-html. Also my python is updated, its 3.7.6.\nAlso weirdly I started writing the code on jupyter notebook, and everything worked, however when I switched to sublime text that's where the problem occurred.\nPlease help.\nP.s. I am on a mac, and I am a beginer.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2034,"Q_Id":64270822,"Users Score":0,"Answer":"I am no Mac expert but.. I know Mac has its own python2 and 3 inner versions which is critical for the OS to operate, so you maybe installed pip into those ones instead of the ones you are operating via PATH.","Q_Score":0,"Tags":"python,pip,python-requests,python-requests-html","A_Id":64270932,"CreationDate":"2020-10-08T21:24:00.000","Title":"\"ImportError: No module named requests_html\" after installing requests-html to pip and pip3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Suppose I have a camera that captures images in real time and store them in a folder called \".\/static\".\nEach processed image should be displayed on a local web page using Flask python. That is, the results will be presented to the system user by displaying each processed image on the web page along with the image\u2019s gps data (which can be clicked to view image location on google maps) .\nAny help guys ?? thanks but I am new to Flask","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":147,"Q_Id":64277333,"Users Score":3,"Answer":"You need to break down your problem into several, more manageable problems.\n\nmake sure your camera stores the pictures in the correct folder\ncreate a basic Flask app\ncreate a view for viewing one image\nextract the GPS data from one image\ncreate a link to Google Maps for that one image\ncreate a function which reads the whole directory of images\neither randomly choose a picture, or create an image gallery for all pictures\n\nThat is how I would proceed. Each bullet point is one unit of work.\nAnswering all of them here, ie create a complete application for you, is not the intended scope of StackOverflow.\nIf you have any more specific questions about a single bullet point, please create a new question.","Q_Score":0,"Tags":"python,html,flask,web","A_Id":64278589,"CreationDate":"2020-10-09T09:28:00.000","Title":"display dynamically images using flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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 want to use spaCy for Entity Linking (EL). I already trained a spaCy Named Entity Recognition (NER) model with custom labels on my domain-specific corpus. However my following example will be using the regular entity labels PERSON and LOCATION.\nSetting aliases in the Knowledge Base (KB), the KB returns candidates for occurences of recognized entities, e.g. candidates for \"Paris\" can be the Wikidata entry Q47899 (Paris Hilton), Q7137357 (Paris Themmen), Q5214166 (Dan Paris), Q90 (Paris, capital of France), or Q830149 (Paris, county seat of Lamar County, Texas, United States).\nMy question concerns the recognized entity label. If the NER recognizes \"Paris\" as PERSON, this excludes Q90 (Paris, capital of France) and Q830149 (Paris, county seat of Lamar County, Texas, United States) from the candidates, leaving 3 candidates. Whereas if \"Paris\" was recognized as LOCATION, there are only the other 2 candidates.\nIs it possible to advise the KB or EL model somehow from which set of entities to chose the candidates, given the detected NER label? Before or after training the EL model?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":465,"Q_Id":64278426,"Users Score":0,"Answer":"I just had an idea myself. I guess it would be possible to have 2 pipes and train a seperate NER-model for each entity type. Then have a seperate KB and EL-model in each pipe. Then combine the results of the pipes.","Q_Score":2,"Tags":"python,spacy,named-entity-recognition,entity-linking","A_Id":64333216,"CreationDate":"2020-10-09T10:41:00.000","Title":"Is it possible to use NER-Label in Entity Linking candidate generation in spaCy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use spaCy for Entity Linking (EL). I already trained a spaCy Named Entity Recognition (NER) model with custom labels on my domain-specific corpus. However my following example will be using the regular entity labels PERSON and LOCATION.\nSetting aliases in the Knowledge Base (KB), the KB returns candidates for occurences of recognized entities, e.g. candidates for \"Paris\" can be the Wikidata entry Q47899 (Paris Hilton), Q7137357 (Paris Themmen), Q5214166 (Dan Paris), Q90 (Paris, capital of France), or Q830149 (Paris, county seat of Lamar County, Texas, United States).\nMy question concerns the recognized entity label. If the NER recognizes \"Paris\" as PERSON, this excludes Q90 (Paris, capital of France) and Q830149 (Paris, county seat of Lamar County, Texas, United States) from the candidates, leaving 3 candidates. Whereas if \"Paris\" was recognized as LOCATION, there are only the other 2 candidates.\nIs it possible to advise the KB or EL model somehow from which set of entities to chose the candidates, given the detected NER label? Before or after training the EL model?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":465,"Q_Id":64278426,"Users Score":1,"Answer":"This is currently not implemented in spaCy. Generally speaking, these would be the steps needed to get to the functionality you want:\n\nCreate some sort of mapping between your KB entities (Wikidata identifiers) and your NER Labels. This won't be exactly trivial. You need to either parse the wikidata \"instance of\" meta information, or use the Wikipedia classification system which has its pitfalls. Either way, you need to end up with an automated way of defining that Q830149 is-a \"LOCATION\" etc.\nStore the \"NER labels\" for each entity. This could be done in the KB, but then the Cython structures need to be edited.\nReimplement the candidate generation (currently part of the KB: get_candidates method) to take a textual mention + its NER label, and only output relevant candidates for that specific label.\n\nOne caveat I'd like to point out, is that this approach may amplify errors from the NER step. Imagine that you're talking about Paris, the capital, but your NER gets it wrong and tags it as a \"PERSON\". With the approach described here, the NEL won't be able to recover from that, and will output the most likely person it can find, though none of them are correct.\nAnother approach would be to not change the candidate generator, but take the NER label into account as part of the scoring mechanism in the entity_linker pipe. Currently, it already combines two scores: one from the prior probability (using stats from a large training corpus), and one from the context (using ML and sentence similarity). The aspect of matching NER label could be included into that score, and then there will still be a chance of recognizing \"PARIS\" as the correct entity, even when its NER label is wrong. But it depends on how strict you'd want to enforce that.","Q_Score":2,"Tags":"python,spacy,named-entity-recognition,entity-linking","A_Id":64314408,"CreationDate":"2020-10-09T10:41:00.000","Title":"Is it possible to use NER-Label in Entity Linking candidate generation in spaCy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm studying and practicing Python right now. I'm kinda scared by the concept of classes in it and I'm stuck wondering how to implement data structures like Linked Lists, Graphs and Trees.\nI've heard from many that these are the most important data structures asked in interviews and coding competitions.\nSo my question is, Is there a way to implement all the said data structures without using classes and just by using predefined data structures like lists, dictionaries etc?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":196,"Q_Id":64285130,"Users Score":1,"Answer":"If we are being pedantic, everything in python is a class, so you can't avoid them. If you are concerned about everything that goes into creating your own class, like which methods should be defined where, that's something we can focus on. In fact, there is no general consensus on the boundaries to any given class and popular programs like C and Go don't even have them.\nAn alternative is to just use a dict to hold key\/value pairs. Roughly, a class is just a dictionary with associated methods anyway. Dictionary keys can hold a wide variety of objects (as long as they are hashable) whereas class attributes must be strings and are further restricted to fit lexicographically in a program. A linked list for instance could be { \"next object\":obj, \"previous object\":obj, \"item\":obj } or even a list [obj, obj, obj] and your code remembers what those indexes are.\nBut classes are very convenient, especially when implementing other data structures. It makes sense that methods manipulating a linked list node would be on the node itself. There isn't much to gain avoiding classes when they are reasonable data structures to use.\nThere are plenty of modules out there that implemente linked lists, trees and graphs. Unless this is an exercise in learning data structures, some time spent with your favorite search engine is the best option of all.","Q_Score":0,"Tags":"python,class,data-structures,graph,binary-tree","A_Id":64285493,"CreationDate":"2020-10-09T18:03:00.000","Title":"How do I implement data structures without using classes in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a PYTHON script that uses multiprocessing to extract the data from DB2\/Oracle database to CSV and ingest to Snowflake. When I run this script, performance is good (extracts the source table that is large dataset in 75 seconds).  So I made a copy of this python script and changed the input parameters (basically different source tables). When I run all these python scripts together, performance gets an impact (for the same table, it extracts in 100 seconds) and sometimes i see an error 'Cannot allocate memory'.\nI am using Jupyter Nootebook and all these different python scripts extracts different source tables to CSV files and saves it in same server location.\nI am also checking on my own. But any help will be appreciated.\nThanks\nBala","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":64286754,"Users Score":0,"Answer":"If you are running multiple scripts that use multiprocessing and write to the same disk at the same time, you will eventually hit a bottleneck somewhere.\nIt could be concurrent access to the database, writing speed of the disk, amount of memory used or CPU cycles. What specifically is the problem here is impossible to say without doing measurments.\nBut e.g. writing things to a HDD is very slow compared to current CPU speeds.\nAlso, when you are running multiple scripts that use multiprocessing you could have more worker processes than the CPU has cores. In which case there will be some worker processes waiting for CPU time all the time.","Q_Score":0,"Tags":"python-3.x,multiprocessing,subprocess,pool","A_Id":64287348,"CreationDate":"2020-10-09T20:17:00.000","Title":"Python - Running multiple python scripts that uses multiprocessing affects performance and errors out sometimes","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Large Sparse Matrix Data Saved To \/ Loaded From SQL vs. Numpy File Data\nI am using a large sparse matrix (~20k x 100k) and vector(s) (~20K x 1) in my python application with great speed and success.\nOver time, my large sparse matrix will grow. Growth management is easy and fast while the matrix is in memory.\nI am wanting to find the fastest method to save and load my matrix when my app closes and opens, respectively.\nI had planned to save and load using numpy save and load functions. SQL Server through pyodbc is lightning fast, but I have not ever thought to use SQL to manage and maintain sparse matrices before.\nIs it crazy to think of managing long term storage of sparse matrices in a SQL Server DataBase table? I would store each column of the sparse matrix as a column in the sparse matrix SQL table, and each row would represent a shared aspect amongst the columns. I do believe that updating the SQL table would be faster than storing the whole sparse matrix as a numpy data object to file. I am more worried about loading the matrix into memory when the app starts. Would numpy always be faster at this?\nLoading the matrix would be as simple as\nSELECT * FROM SPARSE_MATRIX.\nThose query results would then need to be formatted correctly and converted to a numpy sparse matrix. I am also open to some other SQL storage approach, but I cannot conceive of one yet.\nMotivation for asking this? Management of my sparse matrix for my particular app would be VERY elegant in SQL with regard to saving, growing and maintaining the matrix.\nIF I do not get an answer, I will likely do a speed test comparison and answer this question myself for members in the greater community that might have this same question, BUT I am hoping someone has had some experience with this.\nThis might all be more practical if I run things through pandas or dask between python and SQL. Eager to find an answer to this one way or another.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":211,"Q_Id":64287189,"Users Score":2,"Answer":"Use Parquet\nHave you considered using the parquet file format? It stores tabular data really efficient and is very fast on reads and decently fast on writes. With Apache Drill or Spark you can directly use it with the SQL language. Dask and all major data processing frameworks support it, too.\nTo update a parquet file you would need to overwrite the whole file.\nDon\u2019t use a SQL server\nI would not recommend using an SQL server database as they have different goals:\n\nlow latency\noperation on just a subset of the data\n\nIn your case these don\u2019t apply.","Q_Score":1,"Tags":"python,sql-server,pandas,dask,pyodbc","A_Id":64289256,"CreationDate":"2020-10-09T20:54:00.000","Title":"Large Sparse Matrix Data Saved To \/ Loaded From SQL vs. Numpy File Data","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given a 2D plane and N points (n1=(x1,y1), n2=(x2,y2)..., nN=(xN,yN)), what is a fast (O(n) or better) algorithm that will find the closest neighbor of any point (e.g. n1 closest neighbor is n3, n2 closest neighbor is n4). I was thinking about storing it in a dictionary where the keys are the points, and the values are the neighbors.\nThere seem to be quite a lot of similar questions on SO, but I couldn't find any code in Python or answers that are not in other languages.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":554,"Q_Id":64287756,"Users Score":0,"Answer":"For a given a point P, simple solution:\n\nCalculate P's distance from all other points, this is done with O(n) time complexity.\nSave them as list of tuples (or similar data structure), the tuples of (point, distance from P).\nOne walk over the list can yield you the top K closest points, in O(n) time complexity.\n\nA second solution that will cost more in space complexity (O(n^2)) and maintenance over time, but will  shorten finding the K nearest neighbors:\n\nKeeping a dictionary from each point to a ordered list (or similar data structure) of points by their distance - building this table once is O(n^2 * log(n)).\nFinding K closest points is O(k) - dictionary access + copying k elements from ordered list.\nOverhead in time complexity would be in adding a new point or removing an old one in a manner that will keep this data structure valid - O(n*log(n)) in both.\n\nThe solution you choose should be on what you want to optimize","Q_Score":0,"Tags":"python,distance,nearest-neighbor","A_Id":64288054,"CreationDate":"2020-10-09T21:52:00.000","Title":"Closest neighbor to any point (other than itself) in a 2D plane","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given a 2D plane and N points (n1=(x1,y1), n2=(x2,y2)..., nN=(xN,yN)), what is a fast (O(n) or better) algorithm that will find the closest neighbor of any point (e.g. n1 closest neighbor is n3, n2 closest neighbor is n4). I was thinking about storing it in a dictionary where the keys are the points, and the values are the neighbors.\nThere seem to be quite a lot of similar questions on SO, but I couldn't find any code in Python or answers that are not in other languages.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":554,"Q_Id":64287756,"Users Score":0,"Answer":"A simple solution that can yield better results than O(n) on average is using a k-d tree for storing the points. building the tree has a worst case complexity O(nlogn). after that searching is on average O(logn) and worst case O(n) (usually for points away from all the other data).\nAlso you might be interested in LSH or locality sensitive hashing while it is an approximation approach meaning you won't always get the right answer, for high dimensional data it provides an important speedup with complexity being closely related to the parameters chosen.","Q_Score":0,"Tags":"python,distance,nearest-neighbor","A_Id":64288117,"CreationDate":"2020-10-09T21:52:00.000","Title":"Closest neighbor to any point (other than itself) in a 2D plane","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just started python tkinter today, and i am not able to differentiate between what the 'width' function does and what 'padx' does, could you please explain each of them to me.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":903,"Q_Id":64291360,"Users Score":2,"Answer":"The padx is nothing but padding inside the layout, X indicates the x axis. The elements inside the layout tells that it needs more space inside the layout than what is allocated.\nwidth which you already know is distance from one side to another side.","Q_Score":3,"Tags":"python,tkinter","A_Id":64291387,"CreationDate":"2020-10-10T08:12:00.000","Title":"What is the difference between 'width' and 'padx' in tkinter in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If the dependent variable has both positive and negative values, the model.score of any regression models are not accurate when train and test score are compared. I tried converting the target column into log but since there are negative values as well, it seems this is not right. Please advise","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":355,"Q_Id":64292762,"Users Score":0,"Answer":"I can't think of any machine learning algorithms that can't handle both positive and negative values. The scoring should still be accurate. If you would like to take the log transform of a column with negative values, then you can add some large constant to the column that makes all values positive and then take the log.","Q_Score":0,"Tags":"python,regression,artificial-intelligence","A_Id":64292943,"CreationDate":"2020-10-10T11:12:00.000","Title":"If the dependent variable has both positive and negative values, how to approach any machine learning algorithm?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"normally when you make a window in tkinter using Tk(), the standard shape of the window would be a square. Is there any way we can make the shape anything else?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":609,"Q_Id":64294866,"Users Score":0,"Answer":"No, you cannot create windows of any shape other than a rectangle.","Q_Score":1,"Tags":"python,tkinter,tkinter-layout","A_Id":64295116,"CreationDate":"2020-10-10T15:04:00.000","Title":"Different shapes of windows in tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"It is .sh for mac os\nIt is .bat for windows\nBut what is it for linux\nThanks\n:)\nLinux","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":77,"Q_Id":64295322,"Users Score":1,"Answer":"It is .sh just like in macOS. These operating systems are similar if you are familiar with one it will be easy to learn the other one","Q_Score":0,"Tags":"python,python-3.x,linux","A_Id":64295413,"CreationDate":"2020-10-10T15:50:00.000","Title":"How to execute linux commands using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"It is .sh for mac os\nIt is .bat for windows\nBut what is it for linux\nThanks\n:)\nLinux","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":64295322,"Users Score":0,"Answer":"For bash .sh like Mac os, These operating systems are similar if you are familiar with one it will be easy to learn the other one","Q_Score":0,"Tags":"python,python-3.x,linux","A_Id":64295659,"CreationDate":"2020-10-10T15:50:00.000","Title":"How to execute linux commands using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am making a sneaker bot\nIt's Client based!\nSo I want to open multiple Web drivers in selenium\nwhat I got:\ntasks = input(\"How many Drivers you want to open?\")  Then it should open the Number of drivers you have entered!\nLike I enter 4:\nThen it should open 4 drivers\nalso, these drivers should do something with the XPath search. I also want this amount of drivers to do the same thing but the most important thing is to open the amount of entered web drivers.\nThank u!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":56,"Q_Id":64296110,"Users Score":1,"Answer":"I have no idea where is the question ...\nPlease read how to ask a question ...\nBut I am going to try to do it anyways (will not provide the code, cuz you did not eighter and at a same time i can bet you did not even tried).\nafter you get the number of tasks in integer form, I would recommend you to create an array, where you will put the tasks amount of browser references (for example, if you want 4 browsers, you will just put it in a forloop and append them to the array) and after that you will you can itterate through the array everyime you will be performing any action (its like making it for 1 browser instace, just everything will be wrapped in a forloop that will itterate the array).\nI recommend you to edit the question and provide a code you have tried and describe the specific problem.","Q_Score":0,"Tags":"python,selenium,webdriver,bots","A_Id":64299905,"CreationDate":"2020-10-10T17:07:00.000","Title":"Open mutliple selenium webdrivers (tasks) with a command in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"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":"In most cases using list\/dict comprehensions gives a noticeable performance boost when timing the code, but does it affect the asymptotic complexity of the algorithm?\nAs I understand, the difference is due to the way comprehensions are evaluated compared to explicit cycles, but this difference should be a constant factor and in that case asymptotic complexity doesn't change and then with the increase in the size of the problem, there should eventually come a point when both versions should perform at the same speed. Is my thinking correct?\nAt the same time, when I tried to test it, comprehensions have been outperforming explicit cycles all the way until I got to sizes where I as running out of memory.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":64300828,"Users Score":3,"Answer":"Great question, but that's not how asymptotic complexity works. It's not that they will converge to the same amount of time, it's that they would both grow in the same way. For instance, algorithms that take 2*n and n are of the same asymptotic complexity, but the former will always take two times as long. I can't see any reason why the comprehensions would not have the same complexity, but you can test this empirically with timing tests.","Q_Score":0,"Tags":"python,list-comprehension,complexity-theory","A_Id":64300913,"CreationDate":"2020-10-11T05:16:00.000","Title":"Do comprehensions have the same asymptotic complexity as explicit for cycles?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"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":"When I lauch buildozer -v android debug or buildozer android debug\nBuildozer returns: Cython (cython) not found, please install it.\nSo I try to install Cython with sudo pip3 install Cython but it returns that Requirement already satisfied: Cython in \/usr\/lib\/python3\/dist-packages (0.29.21)\nWhat I have to do ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":667,"Q_Id":64303050,"Users Score":2,"Answer":"I had to create an environment to do this","Q_Score":2,"Tags":"python-3.x,kivy,cython,buildozer,kali-linux","A_Id":64341326,"CreationDate":"2020-10-11T10:36:00.000","Title":"Buildozer can't find Cython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to extract Folium map to pgn\/img.\nI've tried a lot of path, via selenium, converting to pdf and reconvert to png, pdfkit, imgkit but nothing worked...\nSome help?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":171,"Q_Id":64303759,"Users Score":0,"Answer":"You can do it like this with Selenium :\n\nYou create your map with folium as an HTML file\nYou open your Selenium browser at the url file:\/\/{your_folder_path}\/{your_HTML_map_file}\nYou wait for a few seconds in order to use the method save_screenshot() from your Selenium browser","Q_Score":0,"Tags":"python,extract,folium,file-conversion,html-to-pdf","A_Id":64338111,"CreationDate":"2020-10-11T11:59:00.000","Title":"Python Folium export map error via pdfkit and selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I create a Qweb Report that prints All products and their Movements during a specific period of time. i have checked  that all code and all functions,  everything is working very well.\nThe problem is that  odoo opens res.company form view unstead of printing the pdf report\nThanks for help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":103,"Q_Id":64304048,"Users Score":1,"Answer":"MOHAMED\n=>. The problem is that odoo opens res.company from view instead of printing the pdf report\nSolution - you need to set the company the logo.if pop is raised and then try to print it will work.","Q_Score":0,"Tags":"python-3.x,odoo-12,qweb","A_Id":64311920,"CreationDate":"2020-10-11T12:31:00.000","Title":"Odoo 12 opens res.company form view instead of Qweb Report?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In my scenario the function which does some backend updates is called when request is submitted takes a lot of time to return the value and as a result the session times out.\nSo my doubt is\n\nWhat happens in backend when session times out?\nDoes the function that was running stops running immediately as session timesout?\nWill the data from django session table be removed?\n\nI don't know much about django sessions and reading online didn't gave much clarity on doubts.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":18,"Q_Id":64304746,"Users Score":0,"Answer":"Yes, your code on backend that handles HTTP request continues to run when the request times out.","Q_Score":0,"Tags":"python,django","A_Id":64305024,"CreationDate":"2020-10-11T13:52:00.000","Title":"What happens when Django Session timesout?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"im using django for a face recogntion app and i need to save face descriptor in djangomodel and then retreive them and compare with the vectors of a new image and get the model in the database that have the nearest distance with the new vectore.\nso in short\n\ni have a model of persons\neach model have a textfield that represent a vector\ni have a function compare(vec1,vec2) that take two vectors as\nstrings and return the distance between them\ni have a new vector (not in the database)\ni need to apply the compare  function on the model and retrieve the\nperson that his vector field have the minimum distance with the new\nvector","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":348,"Q_Id":64306630,"Users Score":0,"Answer":"RDBMS is not for storing the vectors, you need to use either elastic search or opensearch to store the vectors and perform the similarity checks.","Q_Score":0,"Tags":"python,django,django-models","A_Id":68935121,"CreationDate":"2020-10-11T16:49:00.000","Title":"searching in a django models of vectors with a custom function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a structure, looking a lot like a graph but I can 'sort' it. Therefore I can have two graphs, that are equivalent, but one is sorted and not the other. My goal is to compute a minimal dominant set (with a custom algorithm that fits my specific problem, so please do not link to other 'efficient' algorithms).\nThe thing is, I search for dominant sets of size one, then two, etc until I find one. If there isn't a dominant set of size i, using the sorted graph is a lot more efficient. If there is one, using the unsorted graph is much better.\nI thought about using threads\/multiprocessing, so that both graphs are explored at the same time and once one finds an answer (no solution or a specific solution), the other one stops and we go to the next step or end the algorithm. This didn't work, it just makes the process much slower (even though I would expect it to just double the time required for each step, compared to using the optimal graph without threads\/multiprocessing).\nI don't know why this didn't work and wonder if there is a better way, that maybe doesn't even required the use of threads\/multiprocessing, any clue?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":64308739,"Users Score":0,"Answer":"Sounds like you're not doing what you describe. Possibly you're waiting for BOTH to finish somehow? Try doing that, and seeing if the time changes.","Q_Score":0,"Tags":"python,multithreading,recursion,graph,multiprocessing","A_Id":64312566,"CreationDate":"2020-10-11T20:33:00.000","Title":"Simultaneous recursion on equivalent graphs using Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a structure, looking a lot like a graph but I can 'sort' it. Therefore I can have two graphs, that are equivalent, but one is sorted and not the other. My goal is to compute a minimal dominant set (with a custom algorithm that fits my specific problem, so please do not link to other 'efficient' algorithms).\nThe thing is, I search for dominant sets of size one, then two, etc until I find one. If there isn't a dominant set of size i, using the sorted graph is a lot more efficient. If there is one, using the unsorted graph is much better.\nI thought about using threads\/multiprocessing, so that both graphs are explored at the same time and once one finds an answer (no solution or a specific solution), the other one stops and we go to the next step or end the algorithm. This didn't work, it just makes the process much slower (even though I would expect it to just double the time required for each step, compared to using the optimal graph without threads\/multiprocessing).\nI don't know why this didn't work and wonder if there is a better way, that maybe doesn't even required the use of threads\/multiprocessing, any clue?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":64308739,"Users Score":0,"Answer":"If you don't want an algorithm suggestion, then lazy evaluation seems like the way to go.\nSetup the two in a data structure such that with a class_instance.next_step(work_to_do_this_step) where a class instance is a solver for one graph type. You'll need two of them. You can have each graph move one \"step\" (whatever you define a step to be) forward. By careful selection (possibly dynamically based on how things are going) of what a step is, you can efficiently alternate between how much work\/time is being spent on the sorted vs unsorted graph approaches. Of course this is only useful if there is at least a chance that either algorithm may finish before the other.\nIn theory if you can independently define what those steps are, then you could split up the work to run them in parallel, but it's important that each process\/thread is doing roughly the same amount of \"work\" so they all finish about the same time. Though writing parallel algorithms for these kinds of things can be a bit tricky.","Q_Score":0,"Tags":"python,multithreading,recursion,graph,multiprocessing","A_Id":64312443,"CreationDate":"2020-10-11T20:33:00.000","Title":"Simultaneous recursion on equivalent graphs using Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"C:\\Users\\utkarsh>pip install django\nFatal error in launcher: Unable to create process using '\"c:\\users\\utkarsh\\appdata\\local\\programs\\python\\python38-32\\python.exe\"  \"C:\\Users\\utkarsh\\AppData\\Local\\Programs\\Python\\Python38-32\\Scripts\\pip.exe\" install django': The system cannot find the file specified.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":235,"Q_Id":64309274,"Users Score":0,"Answer":"in your cmd type \"python -m pip install django\"","Q_Score":0,"Tags":"python,django,cmd","A_Id":64310451,"CreationDate":"2020-10-11T21:38:00.000","Title":"I am unable to install django from command prompt. I am attaching the error. please show the path to me","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This area is still very new to me, so forgive me if I am asking dumb questions. I'm utilizing MCTS to run a model-based reinforcement learning task. Basically I have an agent foraging in a discrete environment, where the agent can see out some number of spaces around it (I'm assuming perfect knowledge of its observation space for simplicity, so the observation is the same as the state). The agent has an internal transition model of the world represented by an MLP (I'm using tf.keras). Basically, for each step in the tree, I use the model to predict the next state given the action, and I let the agent calculate how much reward it would receive based on the predicted change in state. From there it's the familiar MCTS algorithm, with selection, expansion, rollout, and backprop.\nEssentially, the problem is that this all runs prohibitively slowly. From profiling my code, I notice that a lot of time is spent doing the rollout, likely I imagine because the NN needs to be consulted many times and takes some nontrivial amount of time for each prediction. Of course, I can probably stand to clean up my code to make it run faster (e.g. better vectorization), but I was wondering:\n\nAre there ways to speed up\/work around the traditional random walk done for rollout in MCTS?\nAre there generally other ways to speed up MCTS? Does it just not mix well with using an NN in terms of runtime?\n\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":600,"Q_Id":64309511,"Users Score":0,"Answer":"I am working on a similar problem and so far the following have helped me:\n\nMake sure you are running tensorflow on you GPU (You will have to install CUDA)\nEstimate how many steps into the future your agent needs to calculate to still get good results\n(The one I am currently working on) parallelize","Q_Score":0,"Tags":"python,tensorflow,monte-carlo-tree-search","A_Id":68473168,"CreationDate":"2020-10-11T22:13:00.000","Title":"Ways to speed up Monte Carlo Tree Search in a model-based RL task","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've seen many options online, but none of them seem to support Python 3.8. Is there any way to convert a python project to a .exe anymore? If so, how can I do that?\nEDIT:\nI've tried PyInstaller multiple times, both before it was recommended here and afterwards, but I keep getting huge error messages that I don't know how to make sense of.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":131,"Q_Id":64310116,"Users Score":1,"Answer":"Use pyinstaller.\nExample: pyinstaller yourfile.py -F --onefile\nThis will turn your code into a .exe file on Windows.\nTo install PyInstaller, you simply use pip, thus pip install PyInstaller or pip3 install PyInstaller.\nYou can also make sure you have the latest development version of pyinstaller: pip install https:\/\/github.com\/pyinstaller\/pyinstaller\/archive\/develop.tar.gz","Q_Score":0,"Tags":"python,python-3.x,exe","A_Id":64310147,"CreationDate":"2020-10-11T23:51:00.000","Title":"How can I convert a Python file to a .exe file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a string string = \"radios label=\"Does the command\/question above meet the Rules to the left?\" name=\"tq_utt_test\" validates=\"required\" gold=\"true\" aggregation=\"agg\"\" and I want to be able to extract the substring within the \"name\". So in this case I want to extract \"tq_utt_test\" because it is the substring inside name.\nI've tried regex re.findall('name=(.*)\\s', string) which I thought would extract everything after the substring name= and before the first space. But after running that regex, it actually returned \"tq_utt_test\" validates=\"required\" gold=\"true\". So seems like it's returning everything between name= and the last space, instead of everything between name= and first space.\nIs there a way to twist this regex so that it returns everything after name= and before the first space?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":94,"Q_Id":64310445,"Users Score":1,"Answer":"I will just do re.findall('name=([^ ]*)\\s', string)","Q_Score":1,"Tags":"python,regex","A_Id":64310477,"CreationDate":"2020-10-12T01:05:00.000","Title":"Python regex find everything between substring and first space","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"mac os Catalina, python3.8.2\nHey All,\nI know there are similar questions about this, but they didn't seem to help me.  I installed a module (quandl) using pip3.8 install. Then I try to import quandl in a .py file and get a ModuleNotFoundError.  I do have multiple versions of python installed, can't figure out how to get rid of them safely, hence why I used pip3.8 install to make sure it points to the write place.  Still no dice.  I am not using a venv.\nFrom the terminal, this is the pip3.8 install path: \/usr\/local\/lib\/python3.8\/site-packages\nFrom the .py file via VScode, I am interpreting using: \/usr\/local\/bin\/python3.8\nCan someone educate me on what I am doing wrong?\nI was previously interpreting from \/Library\/Frameworks\/Python.framework\/Versions\/3.8\/bin\/python3, but I noticed pip was not installing there.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":64310833,"Users Score":0,"Answer":"At the bottom of your VSCode window, there's an orange status bar.  Starting at the far left, you'll see your git repo info, the git status, and then the Python environment you're using.  If you click that, VSCode will slide in a modal dialog window that'll let you choose your python environment -- my VSCode defaulted to \/usr\/bin\/python3, but my pip3 (and python3) are in \/usr\/local\/bin.  Once I picked the correct interpreter, I stopped getting the ModuleNotFoundError","Q_Score":0,"Tags":"macos,module,python-3.8,modulenotfounderror","A_Id":64370885,"CreationDate":"2020-10-12T02:13:00.000","Title":"ModuleNotFoundError Despite Installing with pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background:\n\nOne process using python code.interact() that created an interactive shell\nHave something running in the interactive shell, a job generating a list of credentials and saved to a variable.\n\nIssue:\nFor some reason, the shell hang and cannot finish\nQuestion:\nIs it possible to retrieve the variable that saved in the interactive shell?\nCtrl+Z and Kill the process usually will fix the hang issue but I have to rerun it again and lost some already generated information.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":64311575,"Users Score":0,"Answer":"Define a dict data={} before starting the interactive session, then pass it as a local code.interact(local={'data':data}). Save your data in that dict, and all changes will be available after exiting the interactive session.\nThis works because interact doesn't actually start a new process\/interpreter.","Q_Score":0,"Tags":"python","A_Id":64311736,"CreationDate":"2020-10-12T04:10:00.000","Title":"Is it possible to load python variable from another already running process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"I am using Python 3.8.5 working on an instance in a virtual environment. My scripts write a log using the standard logging module, and I am also getting the time using arrow through arrow.utcnow().format(\"m\"). I am also having some sleep(x) statements in loops running constantly. This is running on Ubuntu 20.04 with the most recent updates installed.\nFor some reason, the logged and showed time starts lagging compared to the system time on the instance (around 5 min in an hour). This behaviour is only happening on this particular instance and not on a local machine. This is a first time ever I encounter this kind of issue and I am not sure how to troubleshoot. Would appreciate any suggestions on why this is happening and how to resolve.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":64313337,"Users Score":0,"Answer":"I was not able to identify the root cause of the issue, but it simply went away after updating the system with sudo apt update && upgrade and rebooting it, then restarting the scripts.","Q_Score":0,"Tags":"python,datetime,time,lag","A_Id":64317203,"CreationDate":"2020-10-12T07:24:00.000","Title":"Python time lagging compared to system time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a huge distance matrix.\nExample: (10000 * 10000)..\nIs there an effective way to find a inverse matrix?\nI've tried numpy's Inv() but it's too slow.\nIs there a more effective way?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":153,"Q_Id":64315047,"Users Score":0,"Answer":"You probably don't actually need the inverse matrix.\nThere are a lot of numeric techniques that let people solve matrix problems without computing the inverse.  Unfortunately, you have not described what your problem is, so there is no way to know which of those techniques might be useful to you.\nFor such a large matrix (10k x 10k), you probably want to look for some kind of iterative technique.  Alternately, it might be better to look for some way to avoid constructing such a large matrix in the first place -- e.g., try using the source data in some other way.","Q_Score":0,"Tags":"python,math,matrix,3d,distance","A_Id":64322480,"CreationDate":"2020-10-12T09:22:00.000","Title":"how to get the inverse of distance matrix?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Would require a single ansible regex for below three outputs:\ninput1: aa::bb::cc\noutput1: aa::cc\ninput2: bb::aa::cc\noutput2: aa::cc\ninput3: aa::cc::bb\noutput3: aa::cc\nI have written the below reg exp. But the extra double colons are still there.\nexample:\n{{ aa::bb::cc | regexx_replace('bb') }}  --> gives output as:  aa::::cc","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":685,"Q_Id":64315094,"Users Score":0,"Answer":"This is your regexp: (::b+|b+::)\nIt will match :: followed by one or more bs or one or more bs followed by :: so it will take the double colons with it, no matter if they are in front of the bs or after. When it sees ::bb:: as in aa::bb::cc only one of them will match and the result will be aa::cc (so the second pair of colons persists).","Q_Score":1,"Tags":"python,regex,ansible","A_Id":64317152,"CreationDate":"2020-10-12T09:25:00.000","Title":"Ansible regular expression to remove an item from string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to find eigenvalues and eigenvector in python without Numpy but I don't know how to calculate det(A-lemda*I) for finding eigenvalue.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":850,"Q_Id":64316637,"Users Score":0,"Answer":"If you really want to avoid using numpy.linalg (why? This must be some sort of a learning problem, surely), you can e.g.  implement a variant of a qr algorithm: factorize A into the product of Q@R, multiply R@Q, repeat until convergence.\nHowever, if it's indeed a learning exercise, your best bet is to pick a textbook on numerical linear algebra.\nAnd if it is not, then keep in mind that you are very unlikely to outperform (in any definition of performance) the tried-and-tested lapack routines that numpy.linalg wraps.","Q_Score":0,"Tags":"python,numpy,matrix,scipy,linear-algebra","A_Id":64326240,"CreationDate":"2020-10-12T11:06:00.000","Title":"How to find eigenvalues and eigenvector in python without Numpy library?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to generate 50 random coordinates in an unit square such that each point has minimum Euclidian  distance of 0.1 from other points. How can I generate such in python? Actually I need to know how to put condition in random number. But I could not find any way. One way I was using if command with that condition in it. But I need to generate 50 such points. Thanks for any help.","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":531,"Q_Id":64319946,"Users Score":4,"Answer":"A cheap solution would be to keep generating random points in the square. If the generated point is not too close to the other points, then keep it, otherwise throw it away. Once you've reached 50 points, you can stop generating random points.","Q_Score":1,"Tags":"python","A_Id":64320161,"CreationDate":"2020-10-12T14:35:00.000","Title":"generate 50 points with minimum distance between them is 0.1","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to generate 50 random coordinates in an unit square such that each point has minimum Euclidian  distance of 0.1 from other points. How can I generate such in python? Actually I need to know how to put condition in random number. But I could not find any way. One way I was using if command with that condition in it. But I need to generate 50 such points. Thanks for any help.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":531,"Q_Id":64319946,"Users Score":2,"Answer":"you could pick 50 points from the regular grid (0.1*i, 0.1*j) for i=0..10 and j=0..10","Q_Score":1,"Tags":"python","A_Id":64320254,"CreationDate":"2020-10-12T14:35:00.000","Title":"generate 50 points with minimum distance between them is 0.1","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a .exe out of .py by using the PyInstaller on Windows. Can this .exe run on Mac, Linux, or other platforms?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":145,"Q_Id":64321073,"Users Score":2,"Answer":"Nope. Executable formats for Windows are completely different from those used on other OSes. You might be able to run them in Linux under WINE, but they're not natively compatible with any other OS.","Q_Score":0,"Tags":"python,windows","A_Id":64321112,"CreationDate":"2020-10-12T15:47:00.000","Title":"Can the .exe run on Mac, Linux, or other platforms?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"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":"In OpenCV with Python, when the fps of the webcam and a video file in the directory are same, why does the video file play in fast forward whereas the webcam continues to show the frames at a normal rate? What role does the cv2.waitKey() function play here","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":87,"Q_Id":64322569,"Users Score":2,"Answer":"The fps of a video file means how it was encrypted, how many frames contain within a second as the name reveals. For example, if extracted 1 second of this video will produce only that number of frames (images).\nThe corresponding fps of the web camera means how many frames that camera can capture in a second. If saved to a video file that would mean how many frames are contained within each 1-second span.\nThere is a third (probably hidden to you) concept here though. How fast the opencv can read a video file. Normally, and for typical resolutions on a modern computer this fps is larger than the actual video. So, your computer seem to playback the video in fast forward mode because it reads (and displays) frames in a faster pace than the video file's fps.\nTheoretically, you can calculate the delay you should import to the video playback to force it to displayed with normal pace. I am not sure how easily you can accomplish that (in a scientific way and not trial and error mode).\nHope this clarifies the issue.","Q_Score":0,"Tags":"python,opencv,webcam,frame-rate","A_Id":64323662,"CreationDate":"2020-10-12T17:26:00.000","Title":"Why opencv video reading fps is not same with video encrypted fps?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"It seems that non-python resources are included in python distribution packages one of 4 ways:\n\nManifest.in file (I'm not sure when this is preferred over package_data or data_files)\npackage_data in setup.py (for including resources within python import packages)\ndata_files in setup.py (for including resources outside python import packages)\nsomething called setuptools-scm (which I believe uses your version control system to find resources instead of manifest.in or something)\n\n\nWhich of these are accessible from importlib.resources?\n(It is my understanding that importlib.resources is the preferred way to access such resources.) If any of these are not accessible via importlib.resources, then how could\/should one access such resources?\n\nOther people online have been scolded for the suggestion of using __file__ to find the path to a resource because installed wheel distributions may be stored as zip files and therefore there won't even be a proper path to your resources. When are wheels extracted into site-packages and when do they remain zipped?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":525,"Q_Id":64322707,"Users Score":2,"Answer":"All of (1)-(3) will put files into your package (don't know about (4)).\nAt runtime, importlib.resources will then be able to access any data in your package.\nAt least with Python 3.9, which can access resources in subdirectories.\nBefore, you had to make each subdirectory a package by adding a __init__.\nAs for why not use __file__: Pythons import system has some weird ways to resolve packages. For example it can look them up in a zip file if you use Zipapp.\nYou may even have a custom loader for a package you are asked to load some resources from.\nWho knows where those resources are located? Ans: importlib.resources.\nAfaik, wheels are not a contender as those are unpacked.","Q_Score":4,"Tags":"python,resources,setuptools,python-importlib","A_Id":64325551,"CreationDate":"2020-10-12T17:36:00.000","Title":"Packaging python resources (Manifest.in vs package_data vs data_files)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed alpha_vantage using pip and tried it on IDLE but I'm more used to working on Spyder so when I tried importing it there, I got the No module named 'alpha_vantage'.\nI thought the problem was that i used pip instead of conda but when I tried 'conda install alpha_vantage' I got a PackagesNotFoundError: The following packages are not available from current channels: alpha_vantage","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":634,"Q_Id":64324018,"Users Score":0,"Answer":"First all, to use conda you need: conda activate .\nTo know conda env name: conda env list\nWhen you stay in env conda : pip install alpha_vantage","Q_Score":0,"Tags":"python,pip,anaconda,spyder","A_Id":64324098,"CreationDate":"2020-10-12T19:12:00.000","Title":"I get a 'No module named 'alpha_vantage'' error when i try importing alpha_vantage on Spyder","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"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 downloaded and installed Python 3.9 using the Original Installer from python.org, and also tried it with Homebrew after that, which also installed 3.9. However, python3 --version still tells me I have 3.5.1?\nMy work computer does not have this issue, so something seems to be pointing the wrong way on my personal machine. 3.5 has reached the end of its life, as Python keeps telling me, so any suggestions are appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1564,"Q_Id":64327599,"Users Score":0,"Answer":"I tried to just restart the terminal but which python3 still pointed to 3.5. After changing the PATH with echo 'export PATH=\"\/usr\/local\/opt\/python@3.9\/bin:$PATH\"' >> ~\/.zshrc and then also restarting the terminal it worked.","Q_Score":0,"Tags":"python,macos,installation,python-3.5,python-3.9","A_Id":64337315,"CreationDate":"2020-10-13T02:25:00.000","Title":"terminal still showing python version 3.5 even though 3.9 was installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I installed Anaconda 3.7 on Windows 10.\nWhen I try to run pip install xxx\nI get the following message:\nTypeError: 'module' object is not callable\nAny advice on how to solve this will be much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":64330946,"Users Score":0,"Answer":"'module' object is not callable points to what xxx is as pointed out by @Lescurel.\nYou may be trying to access a class inside of the module (which wasn't added to their __init__) and need to change your import statement.\nTry: import xxx.class\nor\nfrom xxx import class","Q_Score":0,"Tags":"python,pip,anaconda","A_Id":64331137,"CreationDate":"2020-10-13T07:54:00.000","Title":"Why doesn't \"pip install\" work in Anaconda 3.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new in the NLP community and need more light on something.\nI saw that Keras has an Embedding layer that is generally used before the LSTM layer. But what algorithm hides behind it? Is it Word2Vec, Glove or something else?\nMy task is a supervised text classification problem.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":128,"Q_Id":64331013,"Users Score":1,"Answer":"The embedding layer is a randomly initialized matrix, with the dimension of (number_of_words_in_vocab * embedding_dimension). The embedding_dimension is custom defined dimension, and an hyper-parmeter that we will have to choose.\nHere, the embeddings are updated during back-propagation, and are learnt from your task and task-specific corpus.\nHowever, pre-trained embeddings such as word2vec, glove are learnt in an unsupervised manner on huge corpus. Pre-trianed embeddings provides a good initialization for this embedding layer. Thus, you can use the pre-trained embeddings to initialize this embedding layer, and also choose if you want to freeze these emebeddings or update these embeddings during the back-propagation.","Q_Score":0,"Tags":"python,keras,nlp,embedding","A_Id":64331286,"CreationDate":"2020-10-13T07:58:00.000","Title":"Word Embedding for text classification","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a spreadsheet which is having following columns:\nTestID  TestData ExpectedOutput ActualOutput Result\nI have separate python scripts for each test-id. I need to read the row corresponding to that particular test-id and after execution, need to update result in same spreadsheet. I am not able to update that result value. can someone please help?\nI read the spreadsheet using Pandas.\ne.g.\na row in spread sheet:\nTestID      TestData              ExpectedOutput    ActualOutput        Result\nTestid-1    Min_freq=5,Max_freq=60, Drive started    Drive started      Pass\nMy script would search for this testid and read the test data. after execution, it would compare the output with expected output and accordingly would update the value of cell Result. I am not getting how to update result value.\nPlease help me.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":895,"Q_Id":64331800,"Users Score":2,"Answer":"The only package that can modify\/edit an existing excel is openpyxl\nYou can read it by xlrd, but cannot modify it by xlwt or xlsxwriter, which can create and flash new xls and xlsx.\nHowever, if you are using another source to edit the existing excel, they are not editing the same ones but two template mirror files, be sure to save it before letting python to read it, and vise versa.","Q_Score":0,"Tags":"python,excel,pandas","A_Id":64400051,"CreationDate":"2020-10-13T08:49:00.000","Title":"How to update a cell value in excel in Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to set some values in one column (col_2) coming from another column (col_3) when values in col_1 fulfill a condition.\nI'm doing that with the .loc operator as after all my research looking for alternatives it looks as the best practice.\ndata.loc[data.col_1.isin(['A','B']),col_2]=data[col_3]\nNevertheless this stills trigger the 'SettingWithCopyWarning:'.\nIs there any other way to do this operation without raising that warning?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19,"Q_Id":64331870,"Users Score":0,"Answer":"Following the advice of Cameron,the line of code was part of a function, where data was passed as argument.\nStarting the function with data = data.copy() solves the issue","Q_Score":0,"Tags":"python,pandas","A_Id":64332146,"CreationDate":"2020-10-13T08:53:00.000","Title":"Avoid 'SettingWithCopyWarning:' when setting values with loc and conditions (inside a function)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to specify rpc queue size when use wait_for_ready in grpc-python","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":138,"Q_Id":64332873,"Users Score":0,"Answer":"gRPC Python doesn't really have a buffer queue layer. Only gRPC Java has similar concept. The wait-for-ready applies to individual RPC but doesn't restrict other RPCs' behavior.","Q_Score":0,"Tags":"grpc,grpc-python","A_Id":64358881,"CreationDate":"2020-10-13T09:54:00.000","Title":"How to specify rpc queue size when use wait_for_ready","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"New to python - I need some help figuring out how to write a tokenizer method in python without using any libraries like Nltk. How would I start? Thank you!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2672,"Q_Id":64333028,"Users Score":0,"Answer":"use gensim instead.\ntokenized_word = gensim.utils.simple_preprocess(str(sentences ), deacc=True) # deacc=True removes punctuations","Q_Score":0,"Tags":"python,nlp,nltk,tokenize","A_Id":67116362,"CreationDate":"2020-10-13T10:02:00.000","Title":"Tokenizer method in python without using NLTK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 2 instances of JIRA . I have written a script where tickets from one instance are read and a replicas of same are created in another instance.\nNow the problem is , whenever I run the script it is generating duplicate tickets again and again.\nHow do I prevent this duplication of tickets? Please help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":133,"Q_Id":64334229,"Users Score":0,"Answer":"Ideas:\n\nCreate a link field in each Jira issue and populate it. If the field is populated the script should not create a new issue\nUse a \"last synced\" field in the source Jira and only create a new issue if the source issue has not been synced\n\nYou don't say but I assumed that this is a one way sync","Q_Score":0,"Tags":"jira,jira-rest-api,jira-plugin,jira-rest-java-api,python-jira","A_Id":64340234,"CreationDate":"2020-10-13T11:18:00.000","Title":"How to prevent duplication of JIRA Tickets in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just built a price prediction model with LSTM and the RMSE was approximately 0.12. The price range is from 0 to 3. Does it mean the model is accurate? Are there any other ways to measure LSTM's accuracy?\nThank you!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3211,"Q_Id":64334704,"Users Score":0,"Answer":"It would be easier if you measure MAE instead of RMSE, as it is the L1 is a more \"natural metric\".\nIf you want to estimate how good is your model, you need to build baselines. You could check for example how does the error change it you predicted always the average, or if you predicted always the last available data point.\nThat said, once you compute that, you could calculate relative metrics, for example the MAE of your model divided by the MAE of one of those Benchmarks. This builds upon the idea of the MASE metric from Rob Hyndman. I recommend you to have a look at it.","Q_Score":0,"Tags":"python,lstm,metrics","A_Id":64335026,"CreationDate":"2020-10-13T11:51:00.000","Title":"About accuracy of LSTM","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just built a price prediction model with LSTM and the RMSE was approximately 0.12. The price range is from 0 to 3. Does it mean the model is accurate? Are there any other ways to measure LSTM's accuracy?\nThank you!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3211,"Q_Id":64334704,"Users Score":0,"Answer":"One 'easy' way to test whether this performance is good, is to calculate the RMSE of a naive forecast. A naive forecast is forecasting the value from the previous step.\nSo if your series has the values [0, .2, .8, 2.2, 1.1], then the next predicted value would be '1.1'.\nThe RMSE from your LSTM should be smaller than the RMSE from your naive forecast, but even a smaller RMSE is no guarantee that your model is good.","Q_Score":0,"Tags":"python,lstm,metrics","A_Id":64335094,"CreationDate":"2020-10-13T11:51:00.000","Title":"About accuracy of LSTM","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to ask the user to write a list as an input such as [1,2,'a','2'] with different data types without the use of any libraries?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":64334977,"Users Score":0,"Answer":"You can use eval but you should understand the caveats. What if the user types in os.system(\"rm -rf .\")?\nIn Python 2, input worked like this (and the \"sane\" input function was called raw_input).","Q_Score":0,"Tags":"python","A_Id":64335025,"CreationDate":"2020-10-13T12:08:00.000","Title":"How to input list filled with int and strings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"I am new to OpenCV and I do not understand how to traverse and change all the pixels of black with colour code exact RGB(0,0,0) to white colour RGB(255,255,255).\nIs there any function or way to check all the pixel and if RGB(0,0,0) the make it to RGB(255,255,255).","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6288,"Q_Id":64336516,"Users Score":0,"Answer":"Subtract 255 from each Pixel and get the positive values only\nFor grayscale and black and white images\nsub_array = 255*np.ones(28, dtype = int)\nimg_Invert = np.abs(np.subtract(img,sub_array))","Q_Score":1,"Tags":"python,opencv,colors,rgb","A_Id":71540957,"CreationDate":"2020-10-13T13:50:00.000","Title":"How to change all the black pixels to white (OpenCV)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For my current web (reactJS) app, i need to implement a push notification system. Backend APIs are written in  Python on Django Framework. So how should i  implement socket, should I write in python, or may I write in node or node for the client-side and python for the server-side?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":321,"Q_Id":64337145,"Users Score":1,"Answer":"Are you looking for Web push or mobile app? The term push is really synonymous with 'push notifications' meaning the client will get them even if the app \/ website is open or not.\nIf that is what you are looking for then you need to be looking at service workers and push notification servers.\nIf you want to simply send alerts to users on your page you can for sure use a simple websocket or long poll done in JS with a node server to emit to.","Q_Score":1,"Tags":"socket.io,serversocket,python-sockets","A_Id":64362885,"CreationDate":"2020-10-13T14:25:00.000","Title":"Socket for push notification","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to read back ciphertext in a file, for example, \\t\"\\x87]\\xb6^,\\xa7G\\xf7\\x99<\\xb2-\\x06\\xc8 however when I make it a bytearray for CBC decryption, I get b'\\\\t\"\\\\x87]\\\\xb6^,\\\\xa7G\\\\xf7\\\\x99<\\\\xb2-\\\\x06\\\\xc8' which ultimately fails as this is not a 16 byte multiple for CBC to decrypt. I have tried decoding with unicode escape, however it doesn't retain it's data type as a byte. I cannot seem to work out how to get this to decrypt normally again?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":64338055,"Users Score":0,"Answer":"For everyone with this issue:\nIf you are writing ciphertext to a file that contains a \\, instead of reading it as a string and converting to bytes (which adds an extra \\ escape character), use the \"b\" modifier in the open() statement.\nExample: with open(\"test.txt\",\"rb\") - notice the b? That means everything from the file is automatically read as a byte. Don't write or deal with strings. Write and read bytes directly and then your encrypt\/decrypt functions will now work. No extra \\.","Q_Score":0,"Tags":"python-3.x,unicode,byte,aes,cbc-mode","A_Id":64341515,"CreationDate":"2020-10-13T15:16:00.000","Title":"Python 3 CBC fail because of double backslash byte","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to understand how complex numbers get multiplied. when I multiply two numbers it always seems to give me an arbitrary amount. for example,\ncomplex(10,9)*complex(11,13) equals complex(-7,229)and complex(10,1)*complex(10,2) equals complex(98,30). is there a mathematical way to figure out 2 complex numbers multiplied and if so, what is is it?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":64339300,"Users Score":0,"Answer":"Another way to understand complex number multiplication is geometrically. We can think of complex numbers as two dimensional vectors, things with a length and direction. Then when multiplying a complex number with length r and direction a by another with length s and direction b, you get a complex number with length r*s and direction a+b, i.e. a complex number with length r and direction a acts on others by multiplication by scaling them by r and rotating them through a.\nIf you work out the lengths and directions of your (10,9) and (11,13) and combine them as above, you will get the length and direction of (-7,229)","Q_Score":0,"Tags":"python,complex-numbers","A_Id":64351567,"CreationDate":"2020-10-13T16:25:00.000","Title":"Seemingly arbitrary result when multiplying complex numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a training dataset on GCP's Natural Language AutoML Entity Extraction service. I have a fraction of my documents labeled and I want to export them to do some preliminary exploratory data analysis. I can add a filter to display \"Labeled\" docs, but if I try to export, it exports all my docs.\nIs there any way to export only those that fit the filter criteria? Via Python API would be fine too.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":64340904,"Users Score":0,"Answer":"Indeed, the Export Data link in the AutoML console will always export the complete dataset. There is no option to export selected items only, however, there is an option to Delete selected items.\nA workaround that I suggest in order to achieve your task is to delete the \u2018unwanted\u2019 items. Let me explain.\nI suggest you perform the following steps.\n\nExport the complete dataset (so you don't delete anything from your production dataset).\nCreate a New Dataset in your AutoML project, by importing the complete dataset from Step 1.\nFilter the unlabeled documents.\nSelect all and delete (by doing this you delete the unlabeled data in your copy dataset).\n\nThis way, your new dataset will contain only the labeled documents and you can do Export Data and use the resulting set for your EDA.\nBest regards!","Q_Score":0,"Tags":"google-cloud-platform,google-cloud-storage,google-cloud-automl,google-cloud-python","A_Id":64649742,"CreationDate":"2020-10-13T18:17:00.000","Title":"Exporting a filtered subset of GCP Natural Language annotator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am creating a line chart on superset which is being plotted against some aggregates function and time column. I am getting null when at that specific time no event is there due to this I am getting broken charts. Is there a way to replace these nulls with 0?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1051,"Q_Id":64347576,"Users Score":1,"Answer":"If you are on the chart explore, click on the 3 dots next to dataset name, and click on \"Edit Dataset\". Go into \"Calculated columns\" tab and in there click on \"Add item\". In the SQL field you can then define your condition that will be applied to the column. So you can write SQL like IF(my_column IS NULL, 0, my_column) and label for this calculated column. On your chart, use this calculated column then. You can use any SQL statement you need in the box (format transformation, CASE WHEN, IF, etc.)","Q_Score":0,"Tags":"python,apache-superset","A_Id":64449173,"CreationDate":"2020-10-14T06:12:00.000","Title":"Replace null with zero in superset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"so, I installed a python module using pip install using the administrator mode by cmd prompt. When I tried to import it in a program in IDLE 3.8 it gives the error \"module not found\". What could be the reason behind this and what's the solution?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":64349175,"Users Score":0,"Answer":"Maybe you should use pip3 for python3. Does that solve your problem? Or your IDLE uses a different interpreter or virtual environment than the one in which you have installed your modules.","Q_Score":0,"Tags":"python-3.x","A_Id":64349246,"CreationDate":"2020-10-14T08:11:00.000","Title":"python module installed but not opening in IDLE 3.8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Very Comman issue might looks easy.I have Pushed my Django project on Live Digital Ocean server.I have done all the Configuration using Putty terminal.My project is Working Fine but when i close my Terminal,Project stopped working.I am using Digital Ocean Server.my Question is How to Keep Project Running after closing terminal? i will be Thankful if anyone can Help me with this issue.","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":515,"Q_Id":64351181,"Users Score":-1,"Answer":"Im using Tmux - multisession terminal processor.","Q_Score":0,"Tags":"python,django,digital-ocean","A_Id":64351249,"CreationDate":"2020-10-14T10:17:00.000","Title":"How to Keep Django Project Running after Closing terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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'm a beginner at Python, and I would like to read multiple csv file and when i encode them with  encoding = \"ISO-8859-1\",I get this kind of characters in my csv file : \"D\u00c2\u00b0faut\". So I tried to encode in utf-8, I get this error : 'utf-8' codec can't decode byte 0xb0 in position 14: invalid start byte'.\nCan someone help me please ?\nThank you !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2112,"Q_Id":64355933,"Users Score":2,"Answer":"If you decode with utf-8 you should also encode with utf-8.\nDepending on the unicode character you want to display (basically everything except for basic latin letters, digits and the usual symbols) utf-8 needs multiple bytes to store it. Since the file is read byte by byte you need to know if the next character needs more than a byte. This is indicated by the most significant bit of the byte. 0xb0 translates to 1011 0000 in binary and as you can see, the first bit is a 1 and that tells the utf-8 decoder that it needs more bytes for the character to be read. Since you encoded with iso-8859-1 the following byte will be part of the current character and encoding fails.\nIf you want to encode the degree symbol (\u00b0), it would be encoded as 0xC2 0xB0.\nIn any case: Always encode with the same encoding as you want to decode. If you need characters outside the code page, use utf-8. In general using any of the utf encodings is a good advice.","Q_Score":0,"Tags":"python,python-3.x,utf-8,character-encoding,encode","A_Id":64356118,"CreationDate":"2020-10-14T14:49:00.000","Title":"Error : 'utf-8' codec can't decode byte 0xb0 in position 14: invalid start byte","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've developed a model which uses several large, 3-dimensional datasets on the order of (1e7, 10, 1e5), and makes millions of read (and thousands of write) calls on slices of those datasets. So far the best tool I've found for making these calls is numpy.memmap, which allows for minimal data to be held in RAM and allows for clean indexing and very fast recall of data directly on the hard drive.\nThe downside of numpy.memmmap seems to be that performance is pretty uneven - the time to read a slice of the array may vary by 2 orders of magnitude between calls. Furthermore, I'm using Dask to parallelize many of the model functions in the script.\nHow is the performance of Dask DataFrames for making millions of calls to a large dataset? Would swapping out memmaps for DataFrames substantially increase processing times?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":150,"Q_Id":64356376,"Users Score":1,"Answer":"You would need to use Dask Array not Dask Dataframe. The performance is generally the same as Numpy, because Numpy does the actual computation.\nOptimizations can speed up the calculation depending on the use case.\nThe overhead of the scheduler decreases performance. This is only applicable if you split the data into many partition and can usually be neglected.","Q_Score":0,"Tags":"python,numpy,dask","A_Id":64389636,"CreationDate":"2020-10-14T15:12:00.000","Title":"Dask DataFrames vs numpy.memmap performance","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"is it possible to close an active instance of connection ? like how we are connecting to an active instance using app = Application(backend=\"uia\").connect(path=r'D:\\Asem\\bin64\\AUT.exe') like this I want to close the instance via code and again connect whenever I required to validate the UI element , something like \"Application(backend=\"uia\").disconnectOrClose(path=r'D:\\Asem\\bin64\\AUT.exe')\"\nNote:iam not talking about closing the application(AUT) here, just the connection which we established via Application.connect","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":733,"Q_Id":64358242,"Users Score":0,"Answer":"If you want to keep the application running, just do del app for app object. If you want to kill\/close the app, use app.kill(soft=False). With soft=True it will try to close the app gracefully otherwise it is hard kill.","Q_Score":0,"Tags":"python,testing,automation,pywinauto","A_Id":64371082,"CreationDate":"2020-10-14T17:05:00.000","Title":"Python Pywinauto is it possible to Close a instance of Application connection ? I dont see any attribute as close or Disconnect with Application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"GCP re-uses cloud function instances and as such global vars (class instances) become persistent for the re-used instance.\nHow to re-init certain global var on each call? (while other global vars could be re-used)\nI'm using global vars to pass around params within the code, yet each cloudfunc instance has it's own set of params\nObvious solution: assign those vars to None at the top of the function before assigning to a class instance. Is there a better way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":125,"Q_Id":64358871,"Users Score":1,"Answer":"Just assign it the initial value you want at the very start of your function.","Q_Score":0,"Tags":"python,google-cloud-functions","A_Id":64358941,"CreationDate":"2020-10-14T17:49:00.000","Title":"Reset\/re-init global variable of a Cloud Function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a package written in Python 2.7 ( not updated). This package has Vpython 2.7 - 5.74 as one of the dependencies. I couldn't find this version either with pip or conda. I found a .exe file of this version (2.7-5.74) of Vpython. How do I configure the .exe file on my conda environment?\nI am using anaconda2 on windows.\nHigher versions of Vpython doesn't work with the package.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":196,"Q_Id":64359479,"Users Score":0,"Answer":"Support of VPython 6 ended in Jan. 2016. See vpython.org for up-to-date information.","Q_Score":0,"Tags":"python,python-2.7,conda,vpython","A_Id":64686183,"CreationDate":"2020-10-14T18:32:00.000","Title":"Configuring a package executable (.exe) in conda environment on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used the function screensize() and it told me that my window was (400, 300). I need to get to the top left hand corner to draw some stuff, but when I put in (-400, 300), my turtle goes way off the window. Is there any other function I can use to get the size of my turtle window?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":382,"Q_Id":64361192,"Users Score":0,"Answer":"The point 0, 0 is in the center of the screen, so if you want to go to the top left corner, you need to use turtle.goto(200, 150). A problem also could be that if you used setup() to create the window, screensize() will return the default, which is (400, 300), even if you screen is bigger.","Q_Score":0,"Tags":"python,window,turtle-graphics,python-turtle","A_Id":64466835,"CreationDate":"2020-10-14T20:40:00.000","Title":"What is the size of the Python Turtle window in pixels?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to be able to, from the command line or in a Python script\/program, execute the action that you can do manually in the iTunes application: File->Library->Export Library. So that I can have a copy of an up to date xml file of my iTunes library. Is this possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":64364784,"Users Score":0,"Answer":"I have searched for a solution to this problem for quite a lot of time. And I still have not found anything.\nHowever, as I needed the XML only for the \"played count\" and \"name\" variable of each track I instead created an AppleScript which is then directly called in the python script in which I used to import the XML file.\nNote that the AppleScript directly asks the Music app for up-to-date data but it does need the Music app to be running.\nMaybe this can be adapted to work for your problem, too.\nHope this helps, Alex.","Q_Score":1,"Tags":"python,xml,bash,command-line,ituneslibrary","A_Id":64487115,"CreationDate":"2020-10-15T04:15:00.000","Title":"Mac Terminal Command Line command to perform the iTunes File->Library->Export Library action?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When running mkvirtualenv --python=python3.8 test on my Mac terminal I get this permissions error:\n\ncreated virtual environment CPython3.8.2.final.0-64 in 545ms   creator\nCPython3Posix(dest=\/Users\/blake\/.virtualenvs\/test, clear=False,\nglobal=False)   seeder FromAppData(download=False, pip=latest,\nsetuptools=latest, wheel=latest, via=copy,\napp_data_dir=\/Users\/blake\/Library\/Application\nSupport\/virtualenv\/seed-app-data\/v1.0.1)   activators\nBashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator\nvirtualenvwrapper_run_hook:12: permission denied:\n\/Users\/blake\/Library\/Python\/3.8\/\n\nI'm able to import the virtualenvwrapper module directly in Python 3.8 so I know I have it installed correctly, it just doesn't allow me to create the virtualenv.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":378,"Q_Id":64364932,"Users Score":2,"Answer":"Seems like reinstalling virtualenvwrapper and putting export VIRTUALENVWRAPPER_PYTHON=\/usr\/local\/bin\/python3 in .bash_profile resolved the issue.","Q_Score":0,"Tags":"python,python-3.x,virtualenvwrapper","A_Id":64365189,"CreationDate":"2020-10-15T04:34:00.000","Title":"mkvirtualenv giving permission error for virtualenvwrapper_run_hook:12","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using Python version 3.8 with pip version 19.2.3. I tried to install a package but they said I needed to use the latest version of pip to install. The only way to get the latest version of pip, I have to install Python 3.9.0. My OS doesn't support Python 3.9.0 so is there any other way to install packages?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":113,"Q_Id":64365578,"Users Score":0,"Answer":"try pip3 command\npip3 install package_name","Q_Score":0,"Tags":"python,pip","A_Id":64365723,"CreationDate":"2020-10-15T05:49:00.000","Title":"I cannot install any packages using pip version 19.2.3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"does anyone know how a program can find dead pixels on a phone screen?\nI found a lot of dead pixel finding tools and all of their implementations looks similar. It's showing a single-color screen, such as red, green, blue, white and black. Then, we need to check if there's any dots with different color (which is dead pixels) manually.\nIs it possible to find the dead pixels automatically?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":250,"Q_Id":64365986,"Users Score":2,"Answer":"No, it isn't.  Rendering the pixels is a \"write-only\" process, much like sending a message to the console.  There is no feedback from the physical pixels to indicate whether they turned on as expected.  Think of it like a TV screen: the broadcast studio has no way to tell whether you got the program.  They simply send out the signal; you pick it up or ignore it, depending on how you set your hardware state.","Q_Score":0,"Tags":"java,python,opencv,screen,pixel","A_Id":64366088,"CreationDate":"2020-10-15T06:28:00.000","Title":"Does anyone know how to find dead pixels on a phone screen automatically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use Selenium in Python and I want to scrape a lot of websites from one company (many hundreds). But that shouldn't burden the system under any circumstances and because this is a very large website anyway, it shouldn't be a problem for them.\nNow my question is if the company can somehow discover that I'm doing web scraping if I'm acting like a human. That means I stay on a website for an extra long time and allow extra time to pass.\nI don't think you can recognize me by my IP, because the period of time is very long while I do this and I think it looks like normal traffic.\nAre there any other ways that websites can see that I am doing webscraping or generally running a script?\nMany Thanks\n(P.S.:I know that a similar question has already been asked, but the answer was simply that he doesn't behave like a human and visits the website too quickly. But it's different for me ...)","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":782,"Q_Id":64366381,"Users Score":1,"Answer":"One way they can tell is from your browser headers","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,web-scraping","A_Id":64407049,"CreationDate":"2020-10-15T07:00:00.000","Title":"Can websites detect web scraping if I act like a human (Selenium, Python)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use Selenium in Python and I want to scrape a lot of websites from one company (many hundreds). But that shouldn't burden the system under any circumstances and because this is a very large website anyway, it shouldn't be a problem for them.\nNow my question is if the company can somehow discover that I'm doing web scraping if I'm acting like a human. That means I stay on a website for an extra long time and allow extra time to pass.\nI don't think you can recognize me by my IP, because the period of time is very long while I do this and I think it looks like normal traffic.\nAre there any other ways that websites can see that I am doing webscraping or generally running a script?\nMany Thanks\n(P.S.:I know that a similar question has already been asked, but the answer was simply that he doesn't behave like a human and visits the website too quickly. But it's different for me ...)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":782,"Q_Id":64366381,"Users Score":1,"Answer":"When you scraping make sure that you respect the robots.txt file which is based at the root of the website. It set the rules of crawling: which parts of the website should not be scraped, how frequently it can be scraped.\nUser navigation patterns are monitored by large companies to detect bots and scraping attempts. There are many anti scraping tools available in market which are using AI to monitor the various patterns to differentiate between a human and a bot.\nSome of the main techniques used to prevent scraping apart from software are\nCaptcha,\nHoney traps,\nUA monitoring,\nIP monitoring,\nJavascript encryption, etc..\nThere are many more, so what i am saying is that yes it can be detected.","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,web-scraping","A_Id":64407609,"CreationDate":"2020-10-15T07:00:00.000","Title":"Can websites detect web scraping if I act like a human (Selenium, Python)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an application that sends some data to a backend on a webserver where that data is being analysed and put through a neural network to come back with some other data that is being displayed on the client front-end.\nNow, when a lot of clients are connecting simultaneously, we have to scale up, and then down again + there is network latency and you always need an Internet connection.\nBecause the backend isn't doing that much, besides just analysing and putting data through a neural network... it would be ideal to put this backend functionality in each client... no more need to scale up (every client has his own backend on board) + no more network latency.\nThe problem is of course that the most valuable thing is the trained neural network data, that in this case should also be present on each client... and of course I don't want it to be stolen as it costed a lot of money to buy training data for our neural network + then we had to train it as well...\nSo my question is:\nIs there any way to run the backend neural network on the client side in a secure way, preventing our valuable trained neural network from being stolen?\nThank you for any advice!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":64366950,"Users Score":0,"Answer":"In short, there is no absolute way to prevent that, no.\nIf you give give a binary to be executed to a client, there will be ways for your client to copy it in some shape or form and execute it again.","Q_Score":2,"Tags":"python,neural-network,artificial-intelligence,backend","A_Id":64367350,"CreationDate":"2020-10-15T07:41:00.000","Title":"Secure ways of running backend functionality on client side","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to run two pip packages that require separate version requirements. They would run well in separate virtual environments but not in the same.\nI want to use these pip packages in the same app - a flask app. Any idea on how to go about this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":64369756,"Users Score":0,"Answer":"This is not possible.\nQuite often some libraries have overly specific restrictions on dependencies.\nI recommend to open an issue at their issue tracker and ask for less restrictive permissions.","Q_Score":0,"Tags":"python,flask,virtualenv,python-venv","A_Id":64375793,"CreationDate":"2020-10-15T10:38:00.000","Title":"Run multiple virtual enviroments in a single Flask or Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Database with 13 columns(both categorical and numerical). The 13th column is a categorical variable SalStat which classifies weather the person is below 50k or above 50k. I am using Logical Regression for this case and want to know which columns (numerical and categorical) are redundant that is, dont affect SalStat, so that I can remove them. What function should I use for this purpose?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":64375681,"Users Score":0,"Answer":"In my opinion you can study the correlation between your variables and remove the ones that have high correlation since they in a way give the same amount of information to your model\nyou can start with something like DataFrame.corr() then draw a heatmap using seaborn for better visualization  seaborn.heatmap() or a more simple one with plt.imshow(data.corr()) plt.colorbar();","Q_Score":0,"Tags":"python,classification,logistic-regression","A_Id":64375987,"CreationDate":"2020-10-15T16:15:00.000","Title":"Identification of redundant columns\/variables in a classification case study","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been working on a python 3 app that downloads data from a Node.js server. The json file is updated regularly (this is a chat app), but my current code compares the already downloaded data to the complete data on the server. Is there a way to only download the text that is not in a variable, so as to not waste bandwidth?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":64376060,"Users Score":0,"Answer":"With an API that just returns JSON, no, there is no way to only download just the changed data, as that isn't how JSON works. The server you're downloading from has no way of knowing what your local state is. If this is a JSON file of, say, events, and they have an ID or timestamp, the NodeJS server could be written to accept a ?timestamp=last_event_you_have or ?since=id_of_last_message and only return objects since that time or ID, but that requires changes on the NodeJS server side of things.","Q_Score":1,"Tags":"node.js,json,python-3.x,http","A_Id":64380032,"CreationDate":"2020-10-15T16:35:00.000","Title":"Downlad parts of JSON file from Node.js server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can we uninstall a python package without PIP on Unix and Windows?\nVersion: Python3.x and above.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1025,"Q_Id":64376144,"Users Score":1,"Answer":"You have two options:\n\nUse another package manager such as conda. This will only work if the package was originally installed with that package manager.\n\nDelete the package manually with File Explorer or the command-line.","Q_Score":0,"Tags":"python,python-3.x","A_Id":64376177,"CreationDate":"2020-10-15T16:41:00.000","Title":"How to Uninstall a Python package without pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can we uninstall a python package without PIP on Unix and Windows?\nVersion: Python3.x and above.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1025,"Q_Id":64376144,"Users Score":0,"Answer":"Delete the package files manually using Windows explorer, or any Linux file manager, or through command line. In Linux packages are in \/lib\/site-packages\/ and in Windows get them in installation directiory somewhere.","Q_Score":0,"Tags":"python,python-3.x","A_Id":64376203,"CreationDate":"2020-10-15T16:41:00.000","Title":"How to Uninstall a Python package without pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a dictionaryin python, but facing an Unresolved reference 'count' error.\ndict = {\"timestamp\": 0.1, counter: 1}\ni have noticed that when Im creating a variable name counter with any numeric value the error disappears.\nI am using Pycharm 2020.2.2.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":761,"Q_Id":64381597,"Users Score":2,"Answer":"counter would need to be \"counter\"\ndict = {\"timestamp\": 0.1, \"counter\": 1}","Q_Score":0,"Tags":"python,dictionary,reference","A_Id":64381618,"CreationDate":"2020-10-16T01:05:00.000","Title":"Unresolved reference - Python dictionary","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm toying with a problem modelled by a linear system, which can be written as a square block-tridiagonal matrix. These blocks are of size b = 4n+8, and the full matrix is of size Nb; N could be arbitrarily large (reasonably, of course) while n is kept rather small (typically less than 10).\nThe blocks themselves are sparse, the first diagonal being only identity matrices, and the second diagonals having only n+1 non-zero columns (so 3n+7 columns of zeroes) per block. These columns are contiguous, either zeroes then non-zeroes or the other way around.\nBuilding all these blocks in memory results in a 3N-2 x b x b array that can be turned into a sparse matrix with scipy.sparse.bsr_matrix, then cast to CSR format and trimmed of the excess zeroes. It works nicely but I'd rather skip this temporary large and sparse array (for N = 1e4, n = 5 it's 5.6 zeros for every relevant entry!) altogether.\n\nI had a look at scipy.sparse.dok_matrix, recommended for slicing and incremental building. Creating my entries fits in a tidy loop but the process is ~10 times longer than using bsr_matrix with my unnecessary dense array, which will be detrimental to the future use cases.\nIt doesn't seem like bsr_matrix can be used directly with scipy sparse matrices as input.\nUsing bsr_matrix without including the diagonal blocks, then adding a sparse eye greatly reduces the number of zeros (3.5 per relevant entry in my test configuration) and speeds up the process by a third compared to the original solution. Score!\n\nAny clue on things that I could do to further reduce the original imprint of this matrix? The obvious goal being to give me more freedom with the choice of N.\nEDIT\nI managed to improved things a tad more by constructing the three block-diagonals separately. By doing so, I need less padding for my 2nd diagonals (n+3 instead of 3n+7; 1.3 zeroes per relevant entry), dividing my original blocks into two vertical blocks (one full of zeroes) and I only need it one diagonal at a time, cutting the memory cost in half on top of that. The main diagonal remains constructed with the eye method. The icing on the cake: a speed up of 25% compared to my 3rd bullet point, probably because separating the two 2nd diagonals saves some array reshaping operations needed before using bsr_matrix. Compared to the original method, for my (N, n) = (1e4, 5) test case it's ~20M zeroes saved when comparing matrices before trimming. At 128 bits each, it's a decent gain already!\nThe only possible improvement that I can picture now is building these diagonals separately, without any padding, then inserting columns of zeros (probably via  products with block-matrices of identities) and finally adding everything together.\nI also read something about using a dict to update an empty dok_matrix, but in my case I think I would need to expand lists of indices, take their Cartesian product to construct the keys and each element of my blocks would need to be an individual value as one apparently cannot use slices as dictionary keys.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":87,"Q_Id":64382589,"Users Score":0,"Answer":"I ended up implementing the solution I proposed in my last paragraph.\nFor each 2nd diagonal, I construct a block sparse matrix without any padding, then I transform it into a matrix of the proper shape by a right-hand side product with a block matrix whose blocks are identity. I do need to store zeroes here to use bsr_matrix (I first gave a try to the method scipy.sparse.block_diag, but it was extremely slow), but less of them compared to my semi-padding solution: (4n+7)(n+1) vs (4n+8)(n+3); and they can be represented with 8 bits instead of 128. Execution time is increased by ~40% but I can live with that (and it's still a decrease of 20% compared to the first solution).\nI might be missing something here, but for now I'm pretty satisfied with this solution.\nEDIT\nWhen trimming the zeroes of the RHS matrices before effecting the product, the execution time is reduced by 30% compared to the previously most efficient solution; all's well that ends well.","Q_Score":0,"Tags":"python,scipy,linear-algebra","A_Id":64436772,"CreationDate":"2020-10-16T03:37:00.000","Title":"How to avoid inserting unnecessary zeroes in a scipy sparse matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using enlighten progress bars to keep track of some threads I've running. Each thread consists of a repeating for-loop, but I need the progress bar to reset between each for loop. So far the only way I have found to do this is by doing an update with a negative incr, this however messes with the time measurements. Is there any way of resetting or replacing a progress bar?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":343,"Q_Id":64389106,"Users Score":1,"Answer":"I've looked around in the source code a bit and found that you can reset everything by setting .count = 0 and .start = time.time()","Q_Score":0,"Tags":"python","A_Id":64390456,"CreationDate":"2020-10-16T12:21:00.000","Title":"Resetting enlighten progress bar","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently have python versions 2.7, 3.8, and 3.9 on my Mac and it just causes problems in package installing, etc. I do not know how to remove all of them and reinstall python from the beginning in a clean way this time. What should I delete?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":407,"Q_Id":64389830,"Users Score":-1,"Answer":"First, delete the folder \/Library\/Frameworks\/Python.framework\/ using this command:\nsudo rm -r \/Library\/Frameworks\/Python.framework\/\n\nSecond, remove everything related to python (python2.7, python3.8, etc.) in this dir: \/usr\/local\/bin\/\n\nNOTE: You need admin permissions to do this on your computer.","Q_Score":1,"Tags":"python,macos,duplicates","A_Id":64390338,"CreationDate":"2020-10-16T13:09:00.000","Title":"How to remove multiple versions of python from MacOS Catalina 10.15.4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to make a program that gets detected by almost all antiviruses, but the program shouldn't do anything to the computer. I am attempting to get a trogan\/rat\/worm false positive, but if I put rats I made into the system, it doesn't alert the AV. I know they detect on a list and not on the fly, can I change the programs fingerprint to one that is commonly used as a virus?\nHow do I make anti-viruses detect a false positive?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":242,"Q_Id":64390912,"Users Score":0,"Answer":"So I tried to make an PUP(Potentially Unwanted Program) and was successful too.\nIt was flagged by windows defender\nWhat I did was make a python script which will automatically run in background, download a Video, and then it changes the program's Directory too..","Q_Score":0,"Tags":"python,windows,malware,antivirus,malware-detection","A_Id":69353959,"CreationDate":"2020-10-16T14:15:00.000","Title":"How do I make installed antiviruses detect a program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a square region of size [a, a] containing real number coordinates. I want to fill it with with N random points. The conditions is that the distance between any two points has to be greater than a minimum distance D.\nThe brute force way is to keep generating a random point until it meets the condition. But, to check the condition with all other points is kinda expensive. Is there a better algorithm to do this?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":166,"Q_Id":64394133,"Users Score":3,"Answer":"If you had some grid overlay on top of the points, you could generate a circle whose radius is the minimum distance around each point, and flag each grid cell that's in those circles. Then, randomly pick a non-flagged grid cell to generate a point at, then repeat until there's no spaces left.","Q_Score":0,"Tags":"python,2d,coordinates","A_Id":64394236,"CreationDate":"2020-10-16T17:56:00.000","Title":"put random points in a square region while maintaining a minimum distance (Python)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using pygame 2.0.0.dev15 to develop games with Python. Everything works great so far, but I'm surprised that pygame.font.SysFont() takes a lot of time to process.\nWhenever I use fonts in my game, the startup takes about 5 seconds more than without them. The number of fonts I use doesn't seem to slow it down - it's just that first pygame.font.SysFont() call doing that. Something is definitely wrong. I'm on macOS Catalina, using Python 3.8.6.\nThe problem is gone when I use pygame.font.Font() instead.\nWhy does pygame.font.SysFont() take so much time?","AnswerCount":1,"Available Count":1,"Score":-0.3799489623,"is_accepted":false,"ViewCount":261,"Q_Id":64394397,"Users Score":-2,"Answer":"It is because different operating systems have different speeds.","Q_Score":3,"Tags":"python,fonts,pygame,pygame2","A_Id":67665775,"CreationDate":"2020-10-16T18:16:00.000","Title":"pygame.font.SysFont() takes about 5 seconds on macOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a python script on MACOSX 10.15.7(Catalina). In my Bash Profile, I have the following line:\nexport PIP_REQUIRE_VIRTUALENV=false\nHowever, everytime I am trying to run any python script it shows the following error:\nERROR: Could not find an activated virtualenv (required).\nI apreciate if anyone can help me to figure this problem out. I tried multiple solutions discussed in the stackoverflow but none of them worked for me.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":120,"Q_Id":64394916,"Users Score":2,"Answer":"In my Bash Profile, I have the following line: export PIP_REQUIRE_VIRTUALENV=false\n\nOK, so that is a little strange.  Because setting PIP_REQUIRE_VIRTUALENV to false or an empty string, or unsetting it should turn off that warning.  (I just checked.)\nSo I think you must be running in a context where that environment variable setting hasn't taken effect.\n\nDid you \"source\" the profile after adding that to the profile?  Or restart the shell?  Type echo $PIP_REQUIRE_VIRTUALENV to see what the variable is set to in the shell.\n\nAre you (perchance) using sudo?  By default, environment variable settings are NOT passed through to the environment in which sudo runs the command.\n\n\nI also think it can't be running \"any python script\".  I think it must be some script that entails running pip.","Q_Score":0,"Tags":"python,bash,virtualenv","A_Id":64401581,"CreationDate":"2020-10-16T18:56:00.000","Title":"Virtual Environment Requirement for PIP on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"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 still quite new to Python and I would like to create a program which would draw geometry objects of given size. For example how would I create the triangle with the sides of 7cm, 6 cm and 5 cm? Any hint would be very appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":64400174,"Users Score":0,"Answer":"do you want the sizes to be user inputted?\nif you do, in my experience I created a loop with the colour and amount of rectangles they wanted by using x=int(number) then for i in range(x): this allowed the user to choose how many rectangles. Before hand I put in an input code to get the answer print(\"how many rectangles do you want?\") and number = input(\"I want this many rectangles:\")\nAlthough it isn't the exact same, if you know what numbers equals what distance you want, then you could redo the x=int(number) for each side and instead move the x from the code i mentioned before to the moving codes. eg,forward(x)\nI hope that helped, let me know if you don't understand","Q_Score":0,"Tags":"geometry,python-turtle","A_Id":64547502,"CreationDate":"2020-10-17T07:49:00.000","Title":"Triangle of particular size with Python turtle graphics","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can we open a fdb file with pandas or numpy without invoking the database authentications? Or can we just use fdb to connect and then read the file?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":446,"Q_Id":64401270,"Users Score":0,"Answer":"Firebird is a full-fledged database management system, and requires authentication to access the database. On Windows (any Firebird version) and Linux (Firebird 3 or higher) this can be circumvented by using Firebird Embedded instead of Firebird Server. You will still need to specify a user name, but the password is then ignored.\nHowever, doing this may require additional configuration to ensure that the client library doesn't try to connect through a Firebird Server running on the same system. Unless you have a good reason, I would recommend just to accept that you have to authenticate.","Q_Score":0,"Tags":"python,pandas,firebird","A_Id":64401707,"CreationDate":"2020-10-17T10:07:00.000","Title":"Reading a FDB file without invoking database authentication with pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have string of unknown length where tagged words are separated by comma's .I want to get those individual words or strings. I already know that we could use first python.replace(',',' ') to replace , with space and then use python.split() to separate words but this will fail in the case where tagged word consist of multiple words, for eg.  \"algebra , theory of computation , operating system , cars\"\nHow to handle this case in python.\nIt is not given that words will always be separated by \" . \" (space+comma+space)\nOutput I am expecting is [\"algebra\",\"theory of computation\",\"operating system\",\"cars\"]","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":45,"Q_Id":64402086,"Users Score":1,"Answer":"You can use custom separator in split() function by providing it as an argument. In your case: .split(' , ')","Q_Score":0,"Tags":"python","A_Id":64402122,"CreationDate":"2020-10-17T11:47:00.000","Title":"Separate tagged word from larger string in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know the mathematical logic and formula behind calculating the fuzzy matching score between two strings.\nLet's say I have two strings s1 and s2 and I want to use fuzzy matching in python. I am aware of the fact that python libraries like fuzzywuzzy can do the trick. But I would like to know the exact mathematics and logic behind the fuzzy matching approach and the ratio calculation.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2895,"Q_Id":64404211,"Users Score":0,"Answer":"The above answers have given an in-depth explanation of two commonly used algorithms for fuzzy string matching namely the Levenshtein distance and the Soundex algorithm. I will try and explain the use of Cosine Similarity in fuzzy string matching.\nCosine similarity between two non-zero vectors is simply the cosine of the angle between these vectors. The core idea is to find the corresponding vector representation of each string. This can be done by using either the Bag-of-words feature extractor or the TF-IDF feature extractor. The similarity between your strings is proportional to the cosine similarity metric.\nFor example: Consider the following names:\nName1 : athaarv\nName2: atharv\nStep 1) 2gram representation of these strings is\nName1_2gram = [\"at\",\"th\",\"ha\",\"aa\",\"ar\",\"rv\"]\nName2_2gram = [\"at\",\"th\",\"ha\",\"ar\",\"rv\"]\nStep2) Bag of Words Representation:\nName1_BOW = [1,1,1,1,1,1]\nName2_BOW = [1,1,1,0,1,1]\nStep3) Compute the Cosine Similarity:\nCosine similarity = ([1 1 1 1 1 1].[1 1 1 0 1 1])\/(sqrt(5)*sqrt(6)) = 0.91\nNOTE: String representations using TF-IDF are usually better than BOW.Also the Nanonets blog has several resources on this particular topic which might be helpful.","Q_Score":0,"Tags":"python,fuzzy","A_Id":67070171,"CreationDate":"2020-10-17T15:34:00.000","Title":"How to calculate score in fuzzy string matching?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had some strings in my dataframe (female x male, region and so on) and I wanted to fit a decision tree. Therefore, I applied one hot encoder in all these categorical features - which returned a bunch of new columns with 0 and 1.\nHowever, the the default of features' threshold in decision tree are 0.5. That doesn't make sense for these categorical columns.\nDoes someone know how I can change the threshold for lots of columns at once (without having to input the name of each column) in python?\nI want something like: column female split in 0 and 1. I want to do all these before calculating statistics (AUC, ROC, ACC, etc).\nps: I also have some numerical data (income, for example), so I can't change the threshold for all the columns\nps2: The categorical 1 and 0 are in columns 6 to 30.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":184,"Q_Id":64404487,"Users Score":0,"Answer":"Well, a threshold of 0.5 for a binary feature does make sense.\nIt just means that when the feature takes a value > 0.5 (which is thus 1) then the split is made to (say) the right, and of the feature takes a value < 0.5 (i.e. 0) the decision tree takes the other path (left).\nThere is no sense in changing the threshold value: any value between 0 and 1 has the same effect as 0.5 and values lower than 0 or larger than 1 mean that no split is done and all observations go to the same child node.","Q_Score":0,"Tags":"python,python-3.x,data-science,decision-tree","A_Id":64452578,"CreationDate":"2020-10-17T16:05:00.000","Title":"How to change features threshold of decision trees after applying one hot encoder?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently had a problem with Tensorflow installing but I solved it by creating a virtual environment in anaconda navigator. I get a warning saying\n\n2020-10-17 13:44:04.120482: W tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found\n2020-10-17 13:44:04.120745: I tensorflow\/stream_executor\/cuda\/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.\n\nThe thing is that I have a GPU on my laptop(T2000). How do I fix this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":547,"Q_Id":64405547,"Users Score":0,"Answer":"did you install tensorflow with pip? If you did uninstall it and install  tensorflow using conda. Conda automatically installs cudnn 7.6.5 and CUDA Toolkit 10.1.243 and tensorflow 2.1.0. If you want tensorflow 2.2 first install 2.1.0 as described. Then use pip to install 2.2 with pip install tensorflow ==2.2.0. 2.2 is compatible with the toolkit and cudnn versions installed with 2.1. Conda can only install tensorflow up to version 2.1.0. Install whatever other packages you need using either pip or conda.","Q_Score":0,"Tags":"python,tensorflow,pycharm","A_Id":64407212,"CreationDate":"2020-10-17T17:49:00.000","Title":"Warning for GPU in tensorflow pycharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are doing Salesforce (old instance) to Salesforce (new instance) migration. We have Standard and custom objects in our old which are need to be migrated to the new Salesforce instance. We are doing this in the following steps:-\n1: Using salesforce describe rest api create tables in MySQL with similar mapping of salesforce object. Tables are created with referential integrity using \"referenceTo\" field of describe call. Example: services\/data\/v49.0\/sobjects\/User\/describe\/.\n2: Get data from salesforce using query rest api and put into MySQL tables. Example: \/services\/data\/v39.0\/query\/?q=.\n3: In this part, we have some confusion like which api we should use so that we can push records to destination org.\nWe are using Python for this task.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":202,"Q_Id":64406180,"Users Score":2,"Answer":"Although your approach is not exactly best practice, to answer your question, you should use the Bulk API to push the record data into new org (assuming you have lots of data). There are also lots of backup\/restore vendors out there that you could have just used like Ownbackup, Odaseva, Backupify, Grax","Q_Score":0,"Tags":"python,migration,salesforce","A_Id":64772134,"CreationDate":"2020-10-17T18:54:00.000","Title":"Salesforce to Salesforce MIgration","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are doing Salesforce (old instance) to Salesforce (new instance) migration. We have Standard and custom objects in our old which are need to be migrated to the new Salesforce instance. We are doing this in the following steps:-\n1: Using salesforce describe rest api create tables in MySQL with similar mapping of salesforce object. Tables are created with referential integrity using \"referenceTo\" field of describe call. Example: services\/data\/v49.0\/sobjects\/User\/describe\/.\n2: Get data from salesforce using query rest api and put into MySQL tables. Example: \/services\/data\/v39.0\/query\/?q=.\n3: In this part, we have some confusion like which api we should use so that we can push records to destination org.\nWe are using Python for this task.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":202,"Q_Id":64406180,"Users Score":1,"Answer":"If it's a one-time process (only migration), then go with the any of the data management tool:\n\nData Import wizard\nData Loader\nDataLoader.io\nworkbench\n\nAll the above-mentioned tool are free and has a variety of features.\nSteps to import:\n\nExport all the data from the old org.\nNow determine the order of insertion based on the object\nrelationship field:\n\n\nif objects have relation in between, start with Importing the parent\nrecords first.\nif there are child records, map the new id of the parent by applying\nv-lookup between the parent success sheet and child record sheet.\nrepeat step 2, until you end up with migration of all records.\n\nFYI: If the records for the objects are less than 50k, then go with the inbuild import wizard it can give you more control on controlling workflows and process triggering which other tools would not.","Q_Score":0,"Tags":"python,migration,salesforce","A_Id":65623302,"CreationDate":"2020-10-17T18:54:00.000","Title":"Salesforce to Salesforce MIgration","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"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've been trying to use speech recognition. I know pyaudio is detecting my microphone, but when I record a wave file through pyaudio, there's no audio in the recording. My mic isn't muted.\nIm on mac and working in Visual Studio. Do I need to give microphone permission to VS?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":64406933,"Users Score":0,"Answer":"I think it can be that VS doesen't have the permissions for your microphone, because your script is running directly from VS. Try enabling microphone permissions for VisualStudio following those steps:\n\nGo to Apple logo > Sistem Preferences > Security & Privacy > Privacy\nSearch for VisualStudio\nCheck the tickbox next to it.\n\nYou can try to running your script from Python directly.\nHope that this works for you.","Q_Score":0,"Tags":"python,macos,speech-recognition,pyaudio","A_Id":64407271,"CreationDate":"2020-10-17T20:19:00.000","Title":"Pyaudio detecting Microphone but not reviving audio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I keep getting the below error when trying to import numpy in kivy on an android device.\nNo module named 'numpy.core._multiarray_umath'\nWhy am I getting this error if I already installed numpy where the main.py file is located and I also\nmade sure the file it is trying to import (_multiarray_umath) is located in the numpy library before building with buildozer, that is ->\n_multiarray_umath.cpython-36m-x86_64-linux-gnu.so located in numpy\/core?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":236,"Q_Id":64408261,"Users Score":1,"Answer":"The file you talk about is a desktop linux binary, not compatible with your android device. That is why it didn't work on android and (per the comments) the fix was to put numpy in the requirements so that an android version was built and included by buildozer.\n\nListing numpy in the buildozer.spec file fixed the error, but I can't seem to get tensorflow to compile in kivy for android. Does tensorflow not work in kivy on android?\n\nTensorflow is not currently supported. Apparently tensorflow lite works, but you need to include it via gradle and write some java wrapper code to access it.","Q_Score":0,"Tags":"python,numpy,kivy","A_Id":64412950,"CreationDate":"2020-10-17T23:19:00.000","Title":"No module named 'numpy.core._multiarray_umath' in kivy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When trying to run a program on JupyterLab within an OpenVino environment on my Raspberry Pi 4, I get the following error when I try to import Tensorflow:\n\nImportError: cannot import name 'context' from 'tensorflow.python.eager' (unknown location)\n\nThis program was having no issue importing anything just the other day, so I don't know what went wrong, nor how to remedy this issue.\nOther pertinent information is that I'm running Python 3.7 and Tensorflow 2.3\nAny help with this is appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":342,"Q_Id":64408396,"Users Score":0,"Answer":"Well I ended up resolving this issue. Turns out it was due to an issue in the cloning process. Created a new backup and restored from this new backup and the error went away.\nThanks for the help everyone.","Q_Score":2,"Tags":"python,tensorflow,raspberry-pi,jupyter-lab,openvino","A_Id":64419292,"CreationDate":"2020-10-17T23:46:00.000","Title":"Tensorflow ImportError (Unknown Location)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been searching everywhere for this but somehow I can't seem to find it.\nIf you download code from Jupyter notebook and download it as python (.py),\nthen does the computer create a windows notepad for the .py file? (Yes I'm using windows not mac)\nThis is a pretty simple question but I really wish to know if this is a normal thing for windows...\nWhen I download code in Jupyter notebook as python (.py), it is downloaded as a notepad.\nIs this what it's supposed to do??","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":108,"Q_Id":64409572,"Users Score":2,"Answer":"The problem is your default application for files is set as Notepad in windows. That's why it shows to open with Notepad. Since the file comes with *.py extension it will also consider to open in notepad because ultimately *.py is a file type. You can try open with option to open your favorite python editor to work on the file.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":64409617,"CreationDate":"2020-10-18T03:54:00.000","Title":"Jupyter notebook \"download as python\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Numpy array for 3d points in the format (n, 3), where n is the number of points, and column 1 is the x coordinate, column 2, is the y coordinate, and column 3 is the z coordinate. How do I get all the point in the outer bounding box, but not in a inner bounding box?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":334,"Q_Id":64409900,"Users Score":0,"Answer":"How are the orientations of both boxes? Are the axis parallel to x, y, z?\nIn this case it is not so difficult.\n\nFind out if the point is in the x, y, z range of the outher box\nif yes: do the same test for the inner box\n\nJust let me know when you need the code","Q_Score":0,"Tags":"python,python-3.x,numpy,point-clouds,bounding-box","A_Id":64410315,"CreationDate":"2020-10-18T05:03:00.000","Title":"How do I get all 3d points in a numpy array that are not within a inner bounding box, but between the outer bounding box?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are all the built-in modules loaded into the memory when we run the program?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":22,"Q_Id":64410138,"Users Score":0,"Answer":"no, they are only loaded when you import them by yourself\nExample:\n\nimport turtle\nimport math\nimport JSON\nimport sqlite3","Q_Score":0,"Tags":"python,module","A_Id":64410851,"CreationDate":"2020-10-18T05:49:00.000","Title":"Are the built-in modules loaded into the memory when we run the program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given many patches that are taken from an image, the task is creating a single image that is composed of the patches.\nI have tried the naive solution:\n\nfor every 2 images, go over many patches and compare.\nIf they are similar above some confidence threshold, create a new image of the 2.\nAdd the new image to the pool and remove the other 2.\nrepeat until the pool is of size 1.\n\nThe problem is that this solution is very slow, and the main bottleneck is the patch comparing.\nIs there a better way of doing that which is faster?\nMaybe a better patch selection and comparison method?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":302,"Q_Id":64410913,"Users Score":1,"Answer":"I would try:\n\nmake ordered list of all feature points from all images once.\nso create a list where hash of feature or the feature alone is stored, and also info from which image it was taken and maybe even position. Then sort this list by the hash (or on the fly).\nas a feature select what ever you use for comparing images now. As you have no scaling or rotation you do not need scale and rotation invariant features however if you use those it would not hurt. I usually chose pixels which are local maximum or minimum of intensity. And then compute histogram of pixels up to some constant distance from it (which is invariant on rotation) Then hash the histogram...\n\ngo through the list\n\ncheck if one hash is in the list more than once but from different images\nin ordered list they would be grouped together\n\nif yes compare\/merge those images to which the features belong\nalso update feature list so just change image id in the list to the new merged one.\n\n\nIf I see it right You current approach is O(m*n^2) and this would be O((n*m)*log(n*m)) where n is number of images and m is avg number of features per image.","Q_Score":3,"Tags":"python,algorithm,opencv,image-processing,processing-efficiency","A_Id":64423059,"CreationDate":"2020-10-18T07:44:00.000","Title":"Merging overlapping images into a single image by correctly positioning the patches one on the other","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have extracted few rows from a dataframe to a new dataframe. In this new dataframe old indices remain. However, when i want to specify range from this new dataframe i used it like new indices, starting from zero. Why did it work? Whenever I try to use the old indices it gives an error.\ngermany_cases = virus_df_2[virus_df_2['location'] == 'Germany']\ngermany_cases = germany_cases.iloc[:190]\nThis is the code. The rows that I extracted from the dataframe virus_df_2 have indices between 16100 and 16590. I wanted to take the first 190 rows. in the second line of code i used iloc[:190] and it worked. However, when i tried to use iloc[16100:16290] it gave an error. What could be the reason?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":64411400,"Users Score":0,"Answer":"In pandas there are two attributes, loc and iloc.\nThe iloc is, as you have noticed, an indexing based on the order of the rows in memory, so there you can reference the nth line using iloc[n].\nIn order to reference rows using the pandas indexing, which can be manually altered  and can not only be integers but also strings or other objects that are hashable (have the __hash__ method defined), you should use loc attribute.\nIn your case, iloc raises an error because you are trying to access a range that is outside the region defined by your dataframe. You can try loc instead and it will be ok.\nAt first it will be hard to grasp the indexing notation, but it can be very helpful in some circumstances, like for example sorting or performing grouping operations.","Q_Score":0,"Tags":"python,matplotlib","A_Id":64411551,"CreationDate":"2020-10-18T08:48:00.000","Title":"Does iloc use the indices or the place of the row","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Building a Django app, I am trying to figure out what would be the best way to automate log file deletion.\nMy try so far is to build a admin command that delete old logs. From this I can setup a scheduler in python or at server's level but I am not very satisfied with this option because it makes more configuration steps to do during deployment.\nI was wondering if sub-classing log module to trigger a delete-log function on a log write would be a good idea. The pros would be that there is not setup to do a deployment, the cons would be to rely on log write to clean log directory could be useless if there is no log records for a long time. On the other hand it could be resource consuming if there is too many log records.\nSo first of all, is a log-delete triggered by any action could be a good idea and what would be the best action to choose (a daily one)?\nIf not, what would be the best option to perform this in a beautiful way?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":766,"Q_Id":64412211,"Users Score":0,"Answer":"Main purpose of web frameworks is handling of web requests. And here logging is a kind of subsystem for creating breadcrumbs to getting a picture of what was done and what was not. Best match for subsystem is a separate log service i.e system log. Have you tried writing the logs to the system and rotate them using log rotation mechanics provided by your system?","Q_Score":0,"Tags":"python,django,logging","A_Id":64412396,"CreationDate":"2020-10-18T10:24:00.000","Title":"Automatically delete logs in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to utilize the command line in Windows for Python as much as possible, and obviously have a fundamental misunderstanding of how to enter commands.\n\nWindows Key + R\nType \"CMD\"\nType \"python\" at C:\\Users\\Owner prompt\nType \"import matplotlib.pyplot as plt\"\n\nERROR MESSAGE:\nTraceback (most recent call last):\nFile \"\", kube 1m ub \nModuleNotFound: No module named 'matplotlib'","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":64412618,"Users Score":0,"Answer":"you should first activate the environment that has matplotlib. For example, you installed it at the default environment of anaconda which is base. Then do the following:\n\ntype python\ntype import matplotlib.pyplot as plt","Q_Score":0,"Tags":"python,import,command-line","A_Id":64412656,"CreationDate":"2020-10-18T11:13:00.000","Title":"Command Line Python versus Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm currently making a program which fetches the prices and discounts etc. off the Steam sales search page, however all the prices are in $ and I need them to be in \u00a3. I'm relatively new to Python and Selenium, and have been unable to fix the issue myself, and I haven't seen anyone else with a similar problem.\nI'm using the Selenium webdriver, and don't know how to configure its region, but I'm assuming that it'll probably need to be something inputted into Chrome Options, but I don't know.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":483,"Q_Id":64413000,"Users Score":0,"Answer":"Add &cc=US or &currency=1 to url. I can't tell which will work if you dont give specific url.\nCan you give an example url?","Q_Score":0,"Tags":"python,selenium,discord.py,steam,regional-settings","A_Id":64515957,"CreationDate":"2020-10-18T11:56:00.000","Title":"Setting the region in the Python Selenium Webdriver?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am processing a signal in real-time. I need to detect whether the signal is periodic or not (not only by visualizing graphs). So I tought of autocorrelation function.\nHere's my approach but I am not sure :\nI calculate the autocorrelation of the signal, if the autocorrelation has a certain number of peaks it means that it's periodic, otherwise it's not.\nCan someon tell me if my approach is right ?\nThank you!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":142,"Q_Id":64413987,"Users Score":0,"Answer":"For the extraction of periodic signals you use Fourier transformation, which gives you exactly the moments in the frequency (k-)space.","Q_Score":0,"Tags":"python,signals,period,autocorrelation,periodicity","A_Id":64414179,"CreationDate":"2020-10-18T13:36:00.000","Title":"autocorrelation to detect periodicity","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to play a video using python-vlc. I have gotten everything to work, and the video plays without any technical issues. There is this one aesthetic issue, though. I only want to play part of the video. As in, I want to crop out a fair bit on the bottom and a good bit on the right. I know I can do this with a call to MediaPlayer.video_set_crop_geometry(), and I've done so semi-successfully. However, the actual window that opens is the one that is adjusted for the entire video, with the part that I want centered in the middle with black bars around it. (If I call MediaPlayer.video_set_scale(), then the cropped-out bit the same size as it would be if I didn't crop. If I don't call video_set_scale(), the cropped-out bit is stretched, maintaining aspect ratio, until it reaches the edge of the window. Regardless, there are black bars).\nCan I get the window to adjust to this new, smaller video? Preferably automatically, but if I have to pass in the size I want, that's fine too.\nI have tried shuffling around the order between the different calls to no avail. Clearly python-vlc has the capacity somewhere to adjust the window it's playing in, as it can open a window the correct size for the regular video to play, and it adjusts automaticallty after calling video_set_scale(), but only to fit the original video, not the cropped one.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":336,"Q_Id":64414324,"Users Score":1,"Answer":"You should probably share more details, such as your full code and platform used.\nThat being said, libvlc doesn't offer an API to resize the native Window it draws on, but you can easily do it yourself (with win32 APIs for HWND, on Windows, for example).","Q_Score":0,"Tags":"python,vlc,python-vlc","A_Id":64422579,"CreationDate":"2020-10-18T14:15:00.000","Title":"Is there a way to make the python-vlc window acknowledge cropping?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The question is just like normal counting inversion question, but instead of a list of single numbers, now the input is a list of (x,y) pair.\nFor a list of pairs [(x1,y1),(x2,y2),(x3,y3),...,(xn,yn)], a pair (i,j) is a inversion iff i < j and xi>xj, yi>yj. Is it possible to write the algorithm in O(nlognlogn)? I tried several ways but during the merge step, each element from the right half of list has to compare with all elements in the left one, resulting in a time complexity of n square.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":64414421,"Users Score":0,"Answer":"Split the list into two halves, left and right based on the x coordinate. Then, compare the lowest point of the two halves (based on their y coordinate). There are two cases:\n\nThe left point is lower than the right point, then the left point has xi<xj and yi<yj for all the points on its right.\nThe right point is lower than left, so the yi>yj condition hold true for any point to its left.\nAfter updating you answer according to these 2 cases, you can remove one of these two points and continue working on the remaining sorted lists (by recursively solving for left and right as well). This should work in O(nlog^2n)","Q_Score":0,"Tags":"python,inversion","A_Id":64421460,"CreationDate":"2020-10-18T14:24:00.000","Title":"Counting inversions of 2D pair (x,y) in a list","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Problem: Not able to find\/click\/send.keys to any of elements on a specific webpage.\nWebDriver Chrome\nI can interact with that webpage until I click a certain link where a new tab is opened and from that page I'm unable to do anything.\nWhat I've tried so far after extensive research here:\n1- Since a new tab was opened, I've \"forced\" the code looking into the new tab using driver.switch_to.window and to be sure I've printed the current page title and it's the correct one.\n2- I've tried both implicit\/explicit waiting (even time.sleep) in order to wait for the page to load.\n3- Research pointed me to iframe.. I don't have any iframe but nevertheless I've searched for the number of frames (2) and switched between both and tried to find elements using xpath (full xpath) and none were find.\n4- Maximize window.\nSo I tried \"everything\" in the books. Inspecting the elements that I needed to interact I've found that every single one was pointing to a JS with some arguments.\n href=\"JavaScript:SWESubmitForm(document.SWEForm2_0,s_10,\"s_2_1_96_0\",\"VRId-0\")\" tabindex=\"2997\" id=\"s_2_1_96_0\">Track Faults \nLooking further found that s_10 is a variable within the script which have different options from s_0 to s_14.\n\nvar s_0 = {action:\"\/esales_enu\/start.swe\",target:\"_sweview\",SWECmd:\"GotoView\",SWEMethod:\"GotoView\",SWEView:\"L2C Track Channel Reference View BT\",SWEApplet:\"L2C New CZ Home Page Applet BT\",SWEReqRowId:\"0\",SWESP:\"false\",SWENeedContext:\"true\",SWEKeepContext:\"0\",SWEDIC:\"false\"};\n\nvar s_10 = {action:\"\/esales_enu\/start.swe\",target:\"_sweview\",SWECmd:\"GotoView\",SWEMethod:\"GotoView\",SWEView:\"New Portal Fault Search View ORH BT\",SWEApplet:\"L2C New CZ Home Page Applet BT\",SWEReqRowId:\"0\",SWESP:\"false\",SWENeedContext:\"true\",SWEKeepContext:\"0\",SWEDIC:\"false\"};\nSo I started searching and found driver.execute_script() and I've wrote:\ndriver.execute_script(\"SWESubmitForm(document.SWEForm2_0,s_10,'s_2_1_96_0','VRId-0')\")\nBut this occurs:\nselenium.common.exceptions.JavascriptException: Message: javascript error: SWESubmitForm is not defined \nWhat I'm missing here? Syntax? If someone can shed some light on which direction should I go, it will be really appreciated.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":64415512,"Users Score":0,"Answer":"I was able to fix this and learn a few things. The JS \"theory\" I was taking didn't made any sense since the driver.execute_script() isn't used the way I was thinking but rather injecting code or finding elements as well.\nSecond, the solution was actually frames :)\nI was so focused in switching between the two frames I had found initially that for not one moment I thought that INSIDE those two frames could had been more frames!\nAnd basically that was it, after switching to the main frame, I've switched again to the 2nd frame inside that main one and was able to find through xpath.","Q_Score":0,"Tags":"javascript,python-3.x,selenium,selenium-webdriver","A_Id":64449627,"CreationDate":"2020-10-18T16:13:00.000","Title":"Selenium + Python - Not able to interact\/click with JavaScript","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it correct to use client.loop_start(), do some things, then client.loop_stop(), and finally client.loop_forever()?\nContext: I have a bootloader.py on my Raspberry device. The bootloader is to be launched automatically when the device boots. The bootloaders connects to the application server (via dedicated IP and topic), checks the expected sofware installed at the device, downloads the newer software if it is not available locally, starts the wanted application, and then the bootloader should become a subscriber that listens to the \"service messages\" from outside. (For example: \"send me your status\", \"check for the new software, and if there is something new, download it and reboot the device\".\nCurrent implementation: I have already implemented the loading process and launching the wanted application. The implementation uses the client.loop_start() (that is processing the communication using separathe thread). After downloading the wanted files, the bootloader calls subprocess.Popen(cmd), and becomes the proces of the launched application.\nWhat I want: Now I want to separate the process of the launched application. The bootloader should became a client that listens forever. My idea was to client.loops_stop() after the communication with the application server was finished, launch the application, and then client.loop_forever() as the last action of the script to make it listening forever. Is such approach correct?\nIs the described situation usual? Is it a well known pattern? If yes, could you point me to the related documentation? If no, can you see any flaw in the approach?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":229,"Q_Id":64415819,"Users Score":1,"Answer":"It's not really a pattern I've seen elsewhere, but if it meets your needs.\nThe only problem would be if the time between calling loop_stop() and loop_forever() is longer than the Keep Alive period which will result in the broker disconnecting the client.\nYou may also get a burst of messages when you restart the event loop.","Q_Score":0,"Tags":"python,mqtt,paho","A_Id":64415959,"CreationDate":"2020-10-18T16:45:00.000","Title":"Combining loop_start(), loop_stop(), and loop_forever(); launching the separate application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Until yesterday we works with python 2.7.5 and wheels packages was installed for python 2.7.5 by pip ( pip that is related to python 2.7.5 )\nNow we install the latest python version from redhat \u2013 3.8\nWe also installed the pip3  , when we installed python 3.8 the additional rpm was also pip3\nSo until now everything is ok\nWhat we want to understand is about the current wheels packages that was installed with pip (pip2)\nSince now we have python 3 , I guess we need to install with pip3 the new wheels for python 3 , I assume python 3 cant use the wheels for python 2\nPlease let me if I correct , and I will happy to get corrections","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":147,"Q_Id":64416314,"Users Score":3,"Answer":"Yes you will need to install new wheels and new packages as well. (Most of the time if you install the packages with PIP3 it will install the wheels automatically.)","Q_Score":3,"Tags":"python-3.x,python-2.7,pip,rhel7,python-wheel","A_Id":64416624,"CreationDate":"2020-10-18T17:33:00.000","Title":"Python3 and pip3 + dose the wheels that installed for python2 can used also for python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"So i know that in pymongo we create dictionaries to represent documents.\nHere is the data I need to store into mongodb\n\"Dog Snails Zebra Horse Fox\".split()\nPet    = [Dog,        Snails,   Fox,          Horse,       Zebra     ]\n^^ How would I go about converting either of these into a dictionary so I can store the data in mongoDB?\nAs I know you have to have the format\nemp_rec1 = {\n\"_id\": 1\n\"name\":\"Mr.Geek\",\n\"eid\":24,\n}\nBut as I only have one key (pets) and many values (dogs, cats, snails, Fox, Horse, Zebra) how would I do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":91,"Q_Id":64417081,"Users Score":0,"Answer":"In MongoDB, data is stored as documents. These documents are stored in MongoDB in JSON (JavaScript Object Notation) format. So you can insert as {\n\"pet\":[\n\"Dog\",\n\"Snails\",\n\"Fox\",\n\"Horse\",\n\"Zebra\"\n]\n}","Q_Score":0,"Tags":"python,database,mongodb,dictionary,pymongo","A_Id":64417916,"CreationDate":"2020-10-18T18:49:00.000","Title":"How to insert data into MongoDB (Python, Pymongo)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem I'm not sure how to tackle.\nI currently am trying to run a program with JupyterLab on my Raspberry Pi 4, but when trying to load a Tensorflow Model, I get the following warning in the terminal:\n\nAllocation of 360087552 exceeds 10% of free system memory\n\nNow, this is confounding to me. The model it's trying to load is only about 900mb. The Raspberry Pi model I have has 8gb of RAM, same as my laptop. It's using a 64gb SD card with 42.8gb free space (more than my laptop). Yet, despite having the same amount of RAM and more free space than my laptop (which runs everything without issue), it is unable to load the model, and the kernel crashes.\nI've already done everything I could think of to free up memory, including Expanding the Filesystem and increasing the Memory Split to 256 in the raspi-config, and increasing the CONF_SWAPSIZE to 1024.\nSo, is there anything further I can do to try to resolve this issue, or is this merely a limitation of the Raspberry Pi 4, and should I look into alternative and more powerful single board computers?\nThanks for the help,\nSam","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":255,"Q_Id":64419381,"Users Score":0,"Answer":"My suspicion is that you're using the 32 bit os with pae, that only allows 3gb per process.  The allocation given would exceed that. Did you try with the 64 bit os?","Q_Score":0,"Tags":"python,tensorflow,memory,jupyter-notebook,raspberry-pi","A_Id":65441844,"CreationDate":"2020-10-18T23:38:00.000","Title":"Raspberry Pi 4 - 8gb RAM, 64gb SD Card Running Out of Memory Trying to Load Tensorflow Model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm just starting with Python - but have over 60 years experience in other programming languages, which may be part of the problem. Clearly there's something fundamental about Python that I don't seem to be getting.\nUsing Numpy and Pandas. I just read in a 2 x 4 CSV file. Now I want to iterate through the array modifying the first column of every row. I checked the size with size=np.shape(InputArray)\nwhen I try to access the 1st element of \"size\" with n=size(0) I get an error 'tuple\" object is not callable\nSimilarly if I try to access the input array by indexing into it ie x=InputArray(1,m)\n. Clearly I'm missing something very basic here.\nBy the way, the 2 x 4 array is just a test. The actual array I need to process is vastly bigger\nThanks much ie x=InputArray(0,1)","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":141,"Q_Id":64419958,"Users Score":1,"Answer":"[] bracket is used to access element of an array in python. But here you are using (), that's why you are getting error as 'tuple' object is not collable.\nTo access 1st element of array named size, you should use size[0].","Q_Score":0,"Tags":"python,pandas,numpy","A_Id":64420071,"CreationDate":"2020-10-19T01:21:00.000","Title":"How do I index through an array I've read from a .csv file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm just starting with Python - but have over 60 years experience in other programming languages, which may be part of the problem. Clearly there's something fundamental about Python that I don't seem to be getting.\nUsing Numpy and Pandas. I just read in a 2 x 4 CSV file. Now I want to iterate through the array modifying the first column of every row. I checked the size with size=np.shape(InputArray)\nwhen I try to access the 1st element of \"size\" with n=size(0) I get an error 'tuple\" object is not callable\nSimilarly if I try to access the input array by indexing into it ie x=InputArray(1,m)\n. Clearly I'm missing something very basic here.\nBy the way, the 2 x 4 array is just a test. The actual array I need to process is vastly bigger\nThanks much ie x=InputArray(0,1)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":64419958,"Users Score":0,"Answer":"Thanks for the response. I think I finally found the solution to the problem I was having accessing the actual array (the suggested answer worked for \"Size\" but not to index the array proper.) I found that instead of trying to index (for example) ABC, the variable into which I read the file I have to access it as ABC.iloc(index1, index 2) which I think is how I pass the indices to what is effectively a function (iloc) that maps the indices to the physical structure of the actual object.\nMy experience was with ancient languages like Fortran and PL\/1 as well as machine language - not to mention plugboard wiring. It was a long time ago. Things have changed.","Q_Score":0,"Tags":"python,pandas,numpy","A_Id":64437641,"CreationDate":"2020-10-19T01:21:00.000","Title":"How do I index through an array I've read from a .csv file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with Gensim to extract keywords from HTML or text.\nMy environment is Centos 7 \/ Python 3.6 \/ Pip3.\nAfter checking Gensim source code, I found that Gensim Keywords API in Summarization module depends on pattern.\nKeywords.py:\ndef keywords(text, ratio=0.2, words=None, split=False, scores=False, pos_filter=('NN', 'JJ'),lemmatize=False, deacc=True):\nThe pos_filter and lemmatize feature depend on pattern.\nIf no pattern module avaiable, pos_filter is set to None, no filtering.\ntextcleaner.py:\nHAS_PATTERN is set by pattern.en module.\nIn my system, only pattern3 is available, pattern is only available for python2.7.\nHow to fix this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":301,"Q_Id":64421012,"Users Score":0,"Answer":"The summarization functionality in Gensim is sufficiently ornery & idiosyncratic in its dependencies & behavior that it is being removed from the next (4.0.0) Gensim release.\nYou may want to seek alternate means of identifying keywords, depending on your exact needs. What's your ultimate goal?\nIf you have reason to believe the specific algorithms in the gensim-3.8.3 summarization module are beneficial for your needs, you might want to extract their key analyses into your own code without the same dependencies. (For example, if you think part-of-speech tagging is a crucial step for your application, you might choose to use POS-tagging from NLTK or SpaCy instead.)","Q_Score":0,"Tags":"python,design-patterns,gensim","A_Id":64436476,"CreationDate":"2020-10-19T04:03:00.000","Title":"How to fix the problem that Gensim not working with pattern3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have installed Python 3.8.2 and Windows 10 on my computer. Whenever I use any command with pip like \"pip --version\" I get the following error message:\nConfiguration file could not be loaded.\nFile contains no section headers.\nfile: 'C:\\ProgramData\\pip\\pip.ini', line: 1\nThis path doesn't even exist on my computer. This happens regardless of the (virtual) environment I'm in. I've searched for quite a while now and couldn't a solution find this specific problem. I'm fairly new to programming, so it's entirely possible that I'm doing something obvious wrong. Can anyone help here?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1414,"Q_Id":64421481,"Users Score":0,"Answer":"I encountered almost the same problem. But there is a pip.ini in that path on my computer, and the problem was solved after I deleted it. Maybe this can provide you with a little information.","Q_Score":1,"Tags":"python,pip","A_Id":67427528,"CreationDate":"2020-10-19T05:10:00.000","Title":"PIP Configuration file could not be loaded - File contains no section headers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Python 3.8.2 and Windows 10 on my computer. Whenever I use any command with pip like \"pip --version\" I get the following error message:\nConfiguration file could not be loaded.\nFile contains no section headers.\nfile: 'C:\\ProgramData\\pip\\pip.ini', line: 1\nThis path doesn't even exist on my computer. This happens regardless of the (virtual) environment I'm in. I've searched for quite a while now and couldn't a solution find this specific problem. I'm fairly new to programming, so it's entirely possible that I'm doing something obvious wrong. Can anyone help here?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1414,"Q_Id":64421481,"Users Score":1,"Answer":"I got this error because my file was stored in a RTF format, had to make it plain text and then it worked!","Q_Score":1,"Tags":"python,pip","A_Id":70192637,"CreationDate":"2020-10-19T05:10:00.000","Title":"PIP Configuration file could not be loaded - File contains no section headers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I kindly need your help to make django error reports by email.\nI use service account with Gmail API to authorize and send emails.\nHow can this work with default django error reporting send_email.\nI know I have to add the below to the settings and debug must be false:\nADMINS, MANAGERS, SERVER_EMAIL","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":257,"Q_Id":64422269,"Users Score":0,"Answer":"I finally managed to send without setting up backend email.\n\nI setup the handlers in settings.\nCreated CustomAdminHandler.py and override send_mail with my own sending email function.\n\nNever thought its that simple.","Q_Score":0,"Tags":"python,django,django-settings,error-reporting,django-errors","A_Id":64581431,"CreationDate":"2020-10-19T06:37:00.000","Title":"Django Error reporting with Custom send_email","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new to Python. I am a very old R programmer. One of my PhD courses is performed via Python.\nSo, I installed Jupyter Notebook; I wrote simple \"Hello World\" in Jupyter Notebook. I wonder whether I must install Anaconda or not?\nI ask this because: I looked at Anaconda's IDE in youtube, and it shows RStudio, Jupyter Notebook, etc. in a bundled manner. In RStudio, one can perform all the package handlings within RStudio.\nSo, I wondered is there a way to install python packages within Jupyter Notebook, or should I really install Anaconda? What is the benefit of installing Anaconda (besides Jupyter Notebook)?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1198,"Q_Id":64426680,"Users Score":1,"Answer":"Like Virtualenv, Anaconda also uses the concept of creating environments so as to isolate different libraries and versions. Anaconda also introduces its own package manager, called conda, from where you can install libraries.\nAdditionally, Anaconda still has the useful interaction with pip that allows you to install any additional libraries which are not available in the Anaconda package manager.\nIt is a good option for setting up of a better environment for working with jupyter.","Q_Score":0,"Tags":"python,jupyter-notebook,anaconda","A_Id":64426758,"CreationDate":"2020-10-19T11:45:00.000","Title":"Is Anaconda necessary to be installed to PC besides Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python. I am a very old R programmer. One of my PhD courses is performed via Python.\nSo, I installed Jupyter Notebook; I wrote simple \"Hello World\" in Jupyter Notebook. I wonder whether I must install Anaconda or not?\nI ask this because: I looked at Anaconda's IDE in youtube, and it shows RStudio, Jupyter Notebook, etc. in a bundled manner. In RStudio, one can perform all the package handlings within RStudio.\nSo, I wondered is there a way to install python packages within Jupyter Notebook, or should I really install Anaconda? What is the benefit of installing Anaconda (besides Jupyter Notebook)?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1198,"Q_Id":64426680,"Users Score":1,"Answer":"Python packages are not installed with python functions, like it would be the case in R with install.packages(\"package name\"). Instead, an external package manager usually is used to install and possibly compile the package files to a directory where python can import it from.\nAnaconda offers (among others) the package manager conda. Most popular is pip. Some Linux distributions also offer python packages via their package manager (e.g. apt on Debian\/Ubuntu). All these package managers download packages from their own repositories, so conda install numpy, pip install numpy and apt install python3-numpy all install a package numpy, but from different sources and in possibly different versions.\nJupyter Notebook is a programming environment, where you can execute shell commands with !command, so depending on the system where the Jupyter server is running, you can use !pip install numpy, !conda install numpy or other commands as cells in the Jupyter Notebook you are working in. This will run the command in a shell.\nThat graphical menu with Jupyter, RStudio etc. you describe is the program \"Anaconda Navigator\", which is installed with Anaconda. Jupyter is just a Python library, which is pre-installed with Anaconda, but can also be installed via pip, apt and other package managers.","Q_Score":0,"Tags":"python,jupyter-notebook,anaconda","A_Id":64426901,"CreationDate":"2020-10-19T11:45:00.000","Title":"Is Anaconda necessary to be installed to PC besides Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently installed ubuntu focal on my laptop and running ipython based on the python3 (3.8.5) provided by the system produces the following warning:\nUserWarning: IPython History requires SQLite, your history will not be saved\nDigging further I found that the problem came from the import of sqlite3 in python which produces the following error:\nImportError: \/usr\/lib\/python3.8\/lib-dynload\/_sqlite3.cpython-38-x86_64-linux-gnu.so: undefined symbol: sqlite3_errstr\nI read some posts related to this kind of error but all were about python that the user installed on their own. Here I am dealing with a python provided by the system and I do not want to install a python from scratch. Would you know what is wrong ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1285,"Q_Id":64428140,"Users Score":0,"Answer":"My experience maybe helpful:\n\ncheck the dynamic library linked by sqlite3\nldd \/usr\/lib\/python3.8\/lib-dynload\/_sqlite3.cpython-38-x86_64-linux-gnu.so\nI found that it linked wrong .so library.\n\nreset LD_LIBRARY_PATH and reinstall sqlite3","Q_Score":0,"Tags":"python-3.x,ubuntu","A_Id":64797803,"CreationDate":"2020-10-19T13:16:00.000","Title":"native python3 fails to import sqlite3 on ubuntu focal","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I started coding in python - Django just few days ago .I am using windows 10 .\nI installed Django project with pip and virtual env.\nbut when I give this command :  django-admin startproject xxxxxx\nthe console is showing : Command not found: django-admin.py\nPlease help me to solve the issue.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":64430083,"Users Score":0,"Answer":"Your commands are looking fine .\nSo do these things :\n\nCheck if django and virtual env  is installed correctly.\nIf not , then , remove virtual environment , reinstall it , then install django .\nRun the command again.\n\nIf you till facing the issue , let me know by comment.","Q_Score":0,"Tags":"python,django,pip,virtualenv","A_Id":64430131,"CreationDate":"2020-10-19T15:06:00.000","Title":"Django project setup issue with the command : django-admin startproject xxxxxx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm currently using renpy and I want to access some features of the native NSWindow API (and eventually the win32 equivalent but I'm starting with the machine I'm using.) However PyObjC doesn't seem to be compatible, presumably because renpy's python implementation is not CPython, but I don't truly know. I asked in the discord and basically got a shrug so as a hail mary I'm gonna throw this question out to the people of stackoverflow:\nIs there a way to access native APIs, like cocoa and win32, from renpy?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":94,"Q_Id":64430926,"Users Score":1,"Answer":"Ren'Py is only compatible with libraries written in pure Python, so it's not possible at this point. PyObjC uses more than  just Python.","Q_Score":0,"Tags":"python,pyobjc,renpy","A_Id":64797229,"CreationDate":"2020-10-19T15:54:00.000","Title":"Is there a way to access native APIs from renpy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"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":"Trying to do something that should be simple. XLSXWriter has a function set_column that lets me format multiple columns at the same time:\nworksheet.set_column('B:D', 30, align)\nHowever, there is no such row function, as\nworksheet.set_row(5,None, percentage)\noperates on but one row at a time.\nI've tried doing the following to no avail:\nworksheet.conditional_format('C27:W27', {'format': percentage})\nHow can I simply set cells C27:W27 to be percentage format?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":151,"Q_Id":64436089,"Users Score":0,"Answer":"Unfortunately, a method such as worksheet.set_row(5,None, percentage) does not exist. I ended up scrapping this project.","Q_Score":0,"Tags":"python,pandas,dataframe,xlsxwriter","A_Id":65257148,"CreationDate":"2020-10-19T22:50:00.000","Title":"XLSXWriter Format multiple rows","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"Before I buy my first setup. I'll launch my deep-learning-pipline on sth like vast.ai.\nI never did it before, but How can I protect my script from being \"stolen\"?\nThis should be a serious launch and take around 7 days to finish training.\ngoogle colab doesn allow enough memory & ram for what i need ( need around 64GB ram)\nis there a way to run a python script encrypted? (note: it makes use of libaries)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":64438169,"Users Score":0,"Answer":"It is hard to run python encrypted. However, you could try to store the code into encrypted disk space.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,cloud,hpc","A_Id":64438425,"CreationDate":"2020-10-20T03:44:00.000","Title":"How to protect your code during cloud-computing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to multithread programming, I put my media_player and server in two threads, the server is to receive the data which is the operation to media_player from another client program. But the valueof \"operation\" i get from server isn't updata to my main thread, so the output of operation in media_player is always none, I hope it will change as the server receives data.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":15,"Q_Id":64438381,"Users Score":0,"Answer":"global operation shall be added into the function, otherwise it would just make a local copy of it and start from here.","Q_Score":0,"Tags":"python-multithreading","A_Id":64438402,"CreationDate":"2020-10-20T04:13:00.000","Title":"two threads cannot share data in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working on a GUI application using PyQt5 and QtDesigner. As I have to make it multi-platform (at least Ubuntu and W10) I will use the \"Fusion\" style to make it look similar on both platforms.\nI was wondering if one could simply set the QApplication style directly in QtDesigner ? I know that a simple <<.setStyle(\"Fusion\")>> will do the trick in the code, but does it exist within QtDesigner so the lines can be automatically generated ?\nI'm trying to learn QtDesigner and how much it can be pushed before going into the code.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":94,"Q_Id":64440849,"Users Score":0,"Answer":"No, it is not possible to set the style through Qt Designer.\nWhat Qt Designer does allow is to display the GUI with different styles if you select Form-> Preview -> ...","Q_Score":0,"Tags":"python,pyqt5","A_Id":64447518,"CreationDate":"2020-10-20T07:57:00.000","Title":"Is it possible to set QApplication style in QtDesigner?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to upload a .exe file to a python Flask application as an URL parameter, preferably using cURL. If there is a better way, please tell me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":25,"Q_Id":64447340,"Users Score":1,"Answer":"The HTTP protocol does not support uploading files using a GET request. You have  to use a POST request.","Q_Score":0,"Tags":"python,flask,curl","A_Id":64447380,"CreationDate":"2020-10-20T14:31:00.000","Title":"How to use cURL to upload a file as a GET request","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"2 Versions of Python 3.9 and 3.8.6 are installed on Win 10. I Also want Tensorflow installed. But Pip recognises only Py 3.9 and hence does not installs tf locally. Is there a way out for this.","AnswerCount":8,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":49602,"Q_Id":64447565,"Users Score":0,"Answer":"I did two things to make it work.\n\nAfter pip install tensorflow, restarted my VS Code\nChange the interpreter from 3.9 to 3.7, so it started installing ipython relevant packages and then changed it back to 3.9.\n\nNot sure it works for you.","Q_Score":2,"Tags":"python,tensorflow,pip","A_Id":71372454,"CreationDate":"2020-10-20T14:43:00.000","Title":"Installing Tensorflow when Python 3.9 is installed on Path?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"2 Versions of Python 3.9 and 3.8.6 are installed on Win 10. I Also want Tensorflow installed. But Pip recognises only Py 3.9 and hence does not installs tf locally. Is there a way out for this.","AnswerCount":8,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":49602,"Q_Id":64447565,"Users Score":0,"Answer":"Your system is defaulting to python 3.9 because it is higher up in the system path list, so it is seen first.\nsearch for environment variable in windows then click on environment variable. Then under system variable, search for path and then move the python3.8 higher up than python3.9.\nYour system will now see 3.8 as default.","Q_Score":2,"Tags":"python,tensorflow,pip","A_Id":66773422,"CreationDate":"2020-10-20T14:43:00.000","Title":"Installing Tensorflow when Python 3.9 is installed on Path?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"2 Versions of Python 3.9 and 3.8.6 are installed on Win 10. I Also want Tensorflow installed. But Pip recognises only Py 3.9 and hence does not installs tf locally. Is there a way out for this.","AnswerCount":8,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":49602,"Q_Id":64447565,"Users Score":11,"Answer":"Try this command\npython -m pip install --upgrade https:\/\/storage.googleapis.com\/tensorflow\/mac\/cpu\/tensorflow-1.12.0-py3-none-any.whl","Q_Score":2,"Tags":"python,tensorflow,pip","A_Id":64923461,"CreationDate":"2020-10-20T14:43:00.000","Title":"Installing Tensorflow when Python 3.9 is installed on Path?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used to use Tensorflow a lot before, but moved over to Pytorch because it was just a lot easier to debug. The nice thing I found with PyTorch is that I have to write my own training loop, so I can step through the code and find errors. I can fire up pdb and check the tensor shapes and transformations, etc., without difficulty.\nIn Tensorflow I was using the model.fit() function all the time, and so any error message I got was like 6 pages of C code where the error message did not give me any indication was in the python code. User's can't step through the model.fit() function since it is a static graph, so that really slowed down my development process. BUT, I was thinking about using Tensorflow again and I was wondering whether a user can step through a custom training loop and look at tensor shapes, etc., or whether even a custom training loop is compiled to a static graph and hence users cannot step through it?\nI did google this question, but all of the tutorials for custom training loops in Tensorflow focus on custom loops being for advanced users, such as if you want to apply some exotic callback while training or if you want to apply some conditional logic. So the simple question of whether it is easy to step through a custom training loop is not answered.\nAny help is appreciated. Thanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":655,"Q_Id":64448607,"Users Score":0,"Answer":"Tensorflow uses eager execution, it means your graph is connected dynamically. Offcourse it\u2019s not as dynamic as PyTorch. But, google is trying its best and incorporated a lot of features in 2.0 and beyond.\nFor writing a custom loop in Tensorflow you need to use tf.GradientTape. I would say it involves the same steps as in pytorch. Compute gradients and then update using optimizer.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,keras,deep-learning","A_Id":64451282,"CreationDate":"2020-10-20T15:39:00.000","Title":"Tensorflow 2.0: How can I fully customize a Tensorflow training loop like I can with PyTorch?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using python selenium to automate user login for a website. However, this specific website uses a 2-step authentication when logging in: After clicking login, it then sends a code to your email address, which you have to enter into the website in order to authenticate. Any ideas what I should do or how I can access that code using python selenium?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":317,"Q_Id":64448819,"Users Score":0,"Answer":"You should log in to the website in the traditional way with selenium.\nNow the site will ask for the verification -> So you need to read your mails somehow.\n\nI see 2 good ways to solve this:\n\nLogin to the email service with selenium in other window or tab -> Open emails-> Select the right email -> Read out the verification code with a regex argument from the email content.\n\nOR\n\nYou can read your emails with IMAP -> Select the correct email with IMAP -> Once again: Read out the verification code with a regex argument from the email content.\n\n\nNow you got the verification code simply write it in and log in.","Q_Score":2,"Tags":"python,selenium,authentication","A_Id":64449076,"CreationDate":"2020-10-20T15:51:00.000","Title":"How to automate website login that uses 2-step verification using python selenium?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The Root page of the site is:  amaze2020.herokuapp.com\nI need to save a verification .txt file into the root directory of amaze2020.herokuapp.com.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":39,"Q_Id":64450693,"Users Score":1,"Answer":"For Herkou, unless specified otherwise, it should always be \"\/app\".","Q_Score":1,"Tags":"python,django","A_Id":64450881,"CreationDate":"2020-10-20T17:46:00.000","Title":"What is the root directory of a site deployed on heroku?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using a macOS.\nWhen I open a new terminal, I am able to install python packages. However, as soon as I open a Jupiter notebook from the terminal, when I run pip install, brew install or other installation methods, nothing happens.  No error message, it just no longer runs.\nI don't know what other information would be helpful, but I would appreciate any suggestions!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":23,"Q_Id":64451676,"Users Score":0,"Answer":"Notebook server runs in foreground (as in a persistent process), so you're probably typing commands to the server application (which doesn't take any command line input) instead of to the shell. You should try entering your commands into a new shell.","Q_Score":0,"Tags":"python,terminal,jupyter","A_Id":64451749,"CreationDate":"2020-10-20T18:57:00.000","Title":"Can't install python packages in terminal after opening Jupiter notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm having trouble using the pygame module in my code. I installed pygame using the command py -3 -m pip install pygame --user and it said it was successful. However, when running my code, I get this error No module named 'pygame' in the Python idle 3.9.0.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":353,"Q_Id":64451868,"Users Score":0,"Answer":"pip install pygame -U\nThis should upgrade your pygame to the newest version.","Q_Score":2,"Tags":"python,pygame","A_Id":64451979,"CreationDate":"2020-10-20T19:11:00.000","Title":"How do I properly install the latest version of pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having trouble using the pygame module in my code. I installed pygame using the command py -3 -m pip install pygame --user and it said it was successful. However, when running my code, I get this error No module named 'pygame' in the Python idle 3.9.0.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":353,"Q_Id":64451868,"Users Score":1,"Answer":"just a simple command\npython -m pip install pygame\nor\npython3 -m pip install pygame","Q_Score":2,"Tags":"python,pygame","A_Id":64452359,"CreationDate":"2020-10-20T19:11:00.000","Title":"How do I properly install the latest version of pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working through a Udemy course. I am a Python beginner.\nI am trying to change the directory in the Python terminal (in both Python 3.8 and PyCharm, same result). My current directory is C:\\Users\\*username*\\PycharmProjects\\Woops\\venv\\Python For Beginners and when I try to change directory using the following command:\ncd C:\\Users\\*username*\\PycharmProjects\\Woops\\venv\\Python For Beginners>python myparser.py\nI receive the message:\n\n\"Access is denied.\"\n\nI've gone into every folder and sub folder containing this item, and clicked on properties,  general and security and ensured that I have full permission. I've done the same for Python and PyCharm. I've gone into advanced security settings and the auditing and effective access headers and made sure my username has full access.\nFinally, I've even opened PyCharm as an Administrator, and no matter what, when I enter the command:\ncd C:\\Users\\*username*\\PycharmProjects\\Woops\\venv\\Python For Beginners>python myparser.py\nit returns \"Access is denied.\"\nAnyone have an idea what is happening here, and how to execute the cd command?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":360,"Q_Id":64452909,"Users Score":0,"Answer":"The problem is that you can't change the directory into a python file you can only change directories to a folder like for example\nExample: cd C:\\Users\\username\\PycharmProjects\\Woops\\venv\\Python For Beginners\nTo run the code write python3 or python myparser.py","Q_Score":0,"Tags":"python,directory,pycharm,permission-denied,access-denied","A_Id":64487256,"CreationDate":"2020-10-20T20:31:00.000","Title":"Change directory in terminal - Access Denied","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I installed a new version of IDLE, and I'm trying to install Pygame. I tried to use the pygame module, but when I did, the error message\nTraceback (most recent call last):\nFile \"C:\\Users\\Kids\\Desktop\\Pygame Space Invaders\\assets\\Pygame_Space_Invaders.py\", line 2, in \nimport pygame\nModuleNotFoundError: No module named 'pygame'\nshowed up. I'm fairly sure this is because pygame isn't installed with my current version of IDLE. I've tried numerous different pip commands trying to install it, but none of them seem to work.\n\n'python3 -m pip install -U pygame --user', I've even tryed upgrading it with 'sudo pip3 install --upgrade pip', and 'sudo pip3 install pygame==2.0.0.dev6', and 'pip3.9 install pygame'.\n\nJust for clarification, I already have it on my older version of IDLE, but I'm trying to get it on the newer version (3.9).","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":648,"Q_Id":64453752,"Users Score":0,"Answer":"Try installing a development version of pygame. The latest version is 2.0.0.dev16, get it with pip install pygame==2.0.0.dev16.","Q_Score":0,"Tags":"python,pygame","A_Id":64454548,"CreationDate":"2020-10-20T21:44:00.000","Title":"How do I install pygame for a new version of idle? (Windows)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to add virtual environment in the python shell node in node-red window? Actually me already specify my virtual environment path to the node then when tried to run the python script it return exit code: -4058 error.. but when remove the virtual environment path it can run perfectly. Need help because really need to run the python script within my virtual environment ..","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":383,"Q_Id":64455333,"Users Score":0,"Answer":"You will need to enable the virtual environment in the shell before starting node-red, so all the required environment variables are updated.","Q_Score":0,"Tags":"python,node.js,node-red","A_Id":64469229,"CreationDate":"2020-10-21T01:18:00.000","Title":"Add virtual environment path in node-red python shell node windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"For example I want to convert \"2pL11H10K\" into [2, p, L, 11, H, 10, K]","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":42,"Q_Id":64456243,"Users Score":1,"Answer":"Regular expressions are necessary and there have already been some quality answers given, but you will also need to convert the numbers from str() to int(). This can also be achieved using regular expressions, for example with [0-9]+ to identify one or more digits.","Q_Score":0,"Tags":"python,string,string-parsing","A_Id":64456378,"CreationDate":"2020-10-21T03:28:00.000","Title":"How to split a string between all chars and int in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an image loaded on-page and it's loaded from the database and I want to remove that object from the database when the tab is close how can I do that?\nframework- Django","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":71,"Q_Id":64458142,"Users Score":2,"Answer":"I don't think it's doable with Django, but to fulfil your requirement you can rather store that image in session instead of a database.","Q_Score":1,"Tags":"python,django,django-models","A_Id":64459176,"CreationDate":"2020-10-21T06:55:00.000","Title":"How to remove object from database on tab close django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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 am trying to find a way to bulk load a csv file into postgresql. However, the data has datetime column with the format of \"YYYY-MM-DD HH24:MI:SS\". I couldn't find any documentation on how to bulk load date column using psycopg2 package in python 3.x. Can I get some help on this? Thanks in advance.\nI am able to load the data using the below code:\ncur.copy_from(dataIterator,'cmodm.patient_visit',sep=chr(31),size=8192,null='') conn.commit()\nHowever, only the date part got loaded in the table. The time part was initialized:\n2017-04-13 00:00:00 2017-04-13 00:00:00 2017-04-12 00:00:00","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":485,"Q_Id":64461078,"Users Score":1,"Answer":"After discussing with @Belayer, it was concluded that copy_from takes the timestamp input value in the format 'YYYY-MM-DD HH:MI:SS'. If the source has some other format, then that needs to be converted to the desired format mentioned before in this response before feeding it into copy_from.","Q_Score":1,"Tags":"python-3.x,postgresql","A_Id":64595337,"CreationDate":"2020-10-21T09:56:00.000","Title":"How to load csv with datetime into postgresql using copy_from","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is my first question on this site. Let's cut right to it:\nI'm trying to create Voronoi diagrams with scipy in Python 3.8 on Kubuntu 20.04, however the problem seems to be that I cannot access the Voronoi class in scipy.spatial because it does not contain a reference to qhull. Other classes like ConvexHull which are also dependent on qhull are inaccessible as well. Trying to open qhull produces Cannot find reference to qhull in __init__.py in PyCharm, and I cannot navigate to it. Looking at the SciPy-Documentation, it would seem as though qhull is expected to be delivered alongside scipy, as there is no further information on how to install it.\nSo far I have tried:\n\nUpgrading scipy to the latest version 1.5.3\nFresh install of scipy - I ran pip install with verbose, but no errors or warnings (which should be color-coded afaik) appeared\nInstalling qhull-bin via console\nBuilding qhull manually\n\nNone of these approaches seems to have changed anything, except I can run qhull in the console now, but that's not really what I'm looking for.\nI would appreciate any kind of advice you might have for me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":282,"Q_Id":64464722,"Users Score":0,"Answer":"Guess I should have tried to actually run my code. Turns out it was installed all along, just that PyCharm didn't, and still doesn't, have access to any qhull files or references, meaning the error within PyCharm hasn't disappeard, but the code works.","Q_Score":2,"Tags":"python,scipy,voronoi,qhull","A_Id":64478891,"CreationDate":"2020-10-21T13:35:00.000","Title":"Scipy.spatial does not contain 'qhull'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python when I import json this error come that \"no module named json\" , after I try to install it from pip but it didn't work and give error that \"no matching distribution found for json\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":820,"Q_Id":64464927,"Users Score":0,"Answer":"Try deleting the package for json and forcingly installing again by adding a \"-f\" at the end of the command e.g. pip install \"your package\" -f","Q_Score":2,"Tags":"python,json,import,module","A_Id":64465255,"CreationDate":"2020-10-21T13:45:00.000","Title":"In python modulenotfounderror : no module named 'json'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to build a docker container with python and the tensorflow-gpu package for a ppc64le machine. I installed miniconda3 in the docker container and used the IBM repository to install all the necessary packages. To my surprise the resulting docker container was twice as big (7GB) as its amd64 counterpart (3.8GB).\nI think the reason is, that the packages from the IBM repository are bloating the installation. I did some research and found two files libtensorflow.so and libtensorflow_cc.so in the tensorflow_core directory. Both of theses files are about 900MB in size and they are not installed in the amd64 container.\nIt seems these two files are the API-files for programming with C and C++. So my question is: If I am planning on only using python in this container, can I just delete these two files or do they serve another purpose in the ppc64le installation of tensorflow?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":256,"Q_Id":64465852,"Users Score":2,"Answer":"Yes. Those are added as there were many requests for it and it's a pain to cobble together the libraries and headers yourself for an already built TF .whl.\nThey can be removed if you'd rather have the disk space.\nWhat is the content of your \"amd64 container\"? Just a pip install tensorflow?","Q_Score":1,"Tags":"python,docker,tensorflow,conda,powerpc","A_Id":64482752,"CreationDate":"2020-10-21T14:31:00.000","Title":"Tensorflow on IBM Power9 ppc64le - Can libtensorflow.so be deleted?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have an existing django 3.0 project that I've integrated Wagtail 2.10.2 into. Wagtail seems to be working ok but the wagtail admin is super slow. The user facing pages themselves are fine.\nDjango debug toolbar shows that the delay is due to the browser request taking 5 - 8 seconds for each page load. The time panel shows 74601 involuntary context switches (5 voluntary.)\nThis is happening on a localserver. I have only a handful of wagtail page objects and the database size is small.\nI've run collectstatic and all the GET requests are either 200 or 304.\nCan anyone help?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":402,"Q_Id":64467822,"Users Score":4,"Answer":"Following tomd's suggestion, I disabled django debug toolbar and the problem is resolved. See the links in his comments.","Q_Score":1,"Tags":"python-requests,wagtail,django-3.0","A_Id":64480408,"CreationDate":"2020-10-21T16:22:00.000","Title":"wagtail admin super slow page loads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Although my csv wasn't that large, it gave this error when i tried to read it:\nCParserError: Error tokenizing data. C error: Buffer overflow caught - possible malformed input file.\nIt gave this error when i used df = pd.read_csv(path).\nThen I changed the code into  df = pd.read_csv(path,engine='python'), and it perfectly worked.\nWhat could be the reason for that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":64468818,"Users Score":0,"Answer":"As far as i know the cause was that there were some carriage returns in the data and pandas was using as a line terminator as if it was a newline. You can try with also lineterminator='\\n' keyword.","Q_Score":0,"Tags":"python,pandas,data-science","A_Id":64468878,"CreationDate":"2020-10-21T17:34:00.000","Title":"Errorin reading a CSV file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My Anaconda Navigator (v1.9.12) has been prompting me to upgrade to 1.10.0. Only problem is, when I click \"yes\" on the update prompt (which should close the navigator and update it), nothing happens.\nNo problem, I thought. I ran\n\nconda update anaconda-navigator\n\nin the terminal. To no avail (and yes, I read the doc online and ran \"conda deactivate\" beforehand), same with\n\nconda install anaconda-navigator=1.10\n\nBoth ran for a while, but the desktop navigator is still on the old version. One thing to note: the Looking for incompatible packages line was taking way too long (hours with no notable progress), so I ctrl-c'ed out. But I ran these commands again they managed to finish running.\nNow I'm out of ideas, would anyone know what I can do to go through with the update? Thanks a lot!","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":14031,"Q_Id":64468858,"Users Score":2,"Answer":"How I fixed this problem is by the following steps!\n\nOpen the anaconda navigator in admin mode.\n\nTry to click the update notice again.\n\n\nThen I updated my anaconda navigator successfully.","Q_Score":23,"Tags":"python,anaconda","A_Id":67397539,"CreationDate":"2020-10-21T17:37:00.000","Title":"Trouble updating to Anaconda Navigator 1.10.0 (MacOS)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"My Anaconda Navigator (v1.9.12) has been prompting me to upgrade to 1.10.0. Only problem is, when I click \"yes\" on the update prompt (which should close the navigator and update it), nothing happens.\nNo problem, I thought. I ran\n\nconda update anaconda-navigator\n\nin the terminal. To no avail (and yes, I read the doc online and ran \"conda deactivate\" beforehand), same with\n\nconda install anaconda-navigator=1.10\n\nBoth ran for a while, but the desktop navigator is still on the old version. One thing to note: the Looking for incompatible packages line was taking way too long (hours with no notable progress), so I ctrl-c'ed out. But I ran these commands again they managed to finish running.\nNow I'm out of ideas, would anyone know what I can do to go through with the update? Thanks a lot!","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":14031,"Q_Id":64468858,"Users Score":12,"Answer":"If you prefer, you may update Navigator manually.\nOpen the Anaconda prompt (terminal on Linux or macOS):\nRun this command to deactivate conda:\n\nconda deactivate\n\nThen run this command to update Navigator:\n\nconda update anaconda-navigator\n\nHad the same problem, worked on me.","Q_Score":23,"Tags":"python,anaconda","A_Id":64469274,"CreationDate":"2020-10-21T17:37:00.000","Title":"Trouble updating to Anaconda Navigator 1.10.0 (MacOS)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to know if the order of features on array interferes on training model and validation scores.\nFor exemple if I had this list of features to train my model:\n[\"close\", \"close_returns\", \"log_returns\", \"open\", \"open_returns\", \"open_log_returns\"]\nIf I invert de order like:\n[\"close\", \"open\",\"log_returns\", \"close_returns\", \"open_log_returns\", \"open_returns\"]\nThis make any difference on predicted model? Or the sort order dosent interfere?\nIf the order interfere. How I can know what the beast order?\nAnd how I can know if determinate feature is relevant or not for my lstm model on Keras?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":352,"Q_Id":64469283,"Users Score":0,"Answer":"The order of the features does not make much of a difference as you will have a separate output node for each feature.\nWhat matters is the order of the events (the rows). This is the sequence you will be modelling and predicting with the model. To determine which features to use you must know what you are modelling. Putting all of them in will give you predictions for all the columns but will also probably make the model harder to train and optimize.\nSo you should think about which of the features you actually need to include in the model. For example, can you infer feature A from feature B? If so, feature A does not need to be included as its easy to calculate.\nWhat about features that do not add much information such as columns that do not change very often. Are they necessary?","Q_Score":0,"Tags":"python,tensorflow,keras,lstm,predict","A_Id":64557838,"CreationDate":"2020-10-21T18:05:00.000","Title":"Python Keras LSTM Features order relevance","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know how can i use tesseract on Windows without using the .exe\nI want to use pytesseract for a Proof of concept on my company's system where i don't have access to install the executable.\nPlease suggest any alternative here ?\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":653,"Q_Id":64474678,"Users Score":0,"Answer":"You can use the tesseract-ocr-data python package,\ntho it is quite big.","Q_Score":0,"Tags":"ocr,tesseract,python-tesseract","A_Id":68657801,"CreationDate":"2020-10-22T03:08:00.000","Title":"How to use tesseract on Windows without using the executable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am new to dask,\nCan anyone help me how to embed Dask's dashboard plots,Dask Graph directly into JupyterLab panes. without\nDask JupyterLab Extension ??","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":50,"Q_Id":64475766,"Users Score":1,"Answer":"I strongly recommend using the Dask JupyterLab extension.\nIf you want to make it yourself then you will need to make new iframes in JLab panes, and use the \/individual-* pages hosted by the Dask scheduler dashboard.","Q_Score":1,"Tags":"python,python-3.x,dask,dask-distributed","A_Id":64669945,"CreationDate":"2020-10-22T05:21:00.000","Title":"How to embed Dask's dashboard plots directly into JupyterLab panes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement py-abac for ABAC, Even if correct policies are getting retrieved from the storage, while the policy evaluation part is always giving \"Deny\" case. I tried to check the issue and found that even for matching rules also somehow it is giving none and always return deny. There is no resources or documentation available other than official documentation. If anybody tried py-abac please provide some lead. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":64476486,"Users Score":0,"Answer":"The issue was with the format. In py-abac, PDP only gives correct output if the format is correct (following a specific format). If the format is different it causes a problem as mentioned in the question.","Q_Score":0,"Tags":"python,abac","A_Id":64642223,"CreationDate":"2020-10-22T06:28:00.000","Title":"py-abac pdp implementation failing for correct \"rules\" match also","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to host the django 3.1(python3.8) app on window 10 with WAMP64 and mod_wsgi API.\nAm able to preform the following command sucessfully.\n1- set \"MOD_WSGI_APACHE_ROOTDIR=C:\\wamp64\\bin\\apache\\apache2.4.46\"\n2- pip install mod_wsgi\nAnd the next command which is \"mod_wsgi-express module-config\" is throwing below error.\n'mod_wsgi-express' is not recognized as an internal or external command, operable program or batch file.\nPlease help me with, what am doing wrong.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":996,"Q_Id":64476554,"Users Score":0,"Answer":"Try with this one : pip install mod_wsgi-standalone\nfrom doc :\n\nWhen installing mod_wsgi-standalone, it will also install a version of\nApache into your Python distribution. You can only use\nmod_wsgi-express when using this variant of the package. The\nmod_wsgi-standalone package follows the same version numbering as the\nmod_wsgi package on PyPi.","Q_Score":1,"Tags":"python,django,mod-wsgi","A_Id":64479963,"CreationDate":"2020-10-22T06:34:00.000","Title":"mod_wsgi-express module-config issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have deeplabv3 frozen graph. There are some tensors in this graph. for example\nImageTensor  =>  (<tf.Tensor 'ImageTensor:0' shape=(1, ?, ?, 3) dtype=uint8>,)\nSqueeze  =>  (<tf.Tensor 'Squeeze:0' shape=(?, ?, 3) dtype=uint8>,)\nI want to change the dtype from uit8 to float32 and save the modified graph. How I can do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":64478142,"Users Score":0,"Answer":"I do not know exactly how your deeplabv3 graph works, but if you just want to convert a tensor to a different type, you can use tf.cast().","Q_Score":0,"Tags":"python,tensorflow,machine-learning,deep-learning","A_Id":64482324,"CreationDate":"2020-10-22T08:22:00.000","Title":"Change datatype of tensors from checkpoint or frozen graph","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am very new to Python, it`s about 6 months, I have a very basic question.\nWhere is the source of \"driver.page_source\", dose it retrieve and read from the local content of the website, I mean whatever server has already sent to the local page, or every time it will send a request or call directly to the website server.\nI want to scrape live data so I need to do \"driver.page_source\" every minute, while I don't want to disturb the website server by sending too many requests to the server.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":550,"Q_Id":64482921,"Users Score":0,"Answer":"driver.page_source retrieves the HTML of the url you passed on driver.get(url).\nIt gets the same code as seen on your browser when you click Inspect Element.\nIf you want specific elements and not the whole page though, you should loop up Xpaths and use driver.find_elements_by_xpath(xpath_expression).","Q_Score":0,"Tags":"python,selenium,webdriver,scrape","A_Id":64483335,"CreationDate":"2020-10-22T13:06:00.000","Title":"Python Selenium \"driver.page_source\" call from website server or local content","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The rest of the apps do not seem relevant enough to make use one of their views as the main homepage.\nIs it a bad practice to create an app only for the homepage?\nWhat is the best practice for the homepage when developing in Django? Or at least the most common?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":64483704,"Users Score":0,"Answer":"Can't really if it's a bad practice or not since as you said other functionality is not relevant but for sure it's a lot of work for just showing homepage, but you can do  tho if it's just rendering Html template with just js and CSS you can use .as_view() function that Django provides (if it does not get any data from your backend)","Q_Score":0,"Tags":"python,django","A_Id":64483998,"CreationDate":"2020-10-22T13:49:00.000","Title":"Create an app only for the homepage in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wish to write a producer that can retain the messages in Kafka per 16 seconds and after flush all messages to topic. Is possible do it? I am using the Kafka python.\nThe idea is:\nI have 100 messages, in normal behavior the producer will do:\nProducer:\nmessage 1\nmessage 2\nmessage 3\n...\nmessage 100\nConsumer:\nmessage 1\nmessage 2\nmessage 3\n...\nmessage 100\nI want do it:\nProducer:\nmessage 1\nmessage 2\nmessage 3\n...\nmessage 100\nConsumer:\nmessage 1 message 2 message 3...\n[after 16s]\n...message N-1 message N\n[after 16s]\nmessage 100\nIs possible do it only use Kafka?\nTkz","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":297,"Q_Id":64484041,"Users Score":0,"Answer":"You can pause your consumer(partitions) at the required time and continue to keep polling(or the broker with kick your consumer out as @OneCricketeer suggested) during which it will return no records on the paused partitions and then resume the consumer(partitions) after the time interval.","Q_Score":2,"Tags":"python,apache-kafka","A_Id":64951987,"CreationDate":"2020-10-22T14:07:00.000","Title":"Retain kafka message in buffer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I wish to write a producer that can retain the messages in Kafka per 16 seconds and after flush all messages to topic. Is possible do it? I am using the Kafka python.\nThe idea is:\nI have 100 messages, in normal behavior the producer will do:\nProducer:\nmessage 1\nmessage 2\nmessage 3\n...\nmessage 100\nConsumer:\nmessage 1\nmessage 2\nmessage 3\n...\nmessage 100\nI want do it:\nProducer:\nmessage 1\nmessage 2\nmessage 3\n...\nmessage 100\nConsumer:\nmessage 1 message 2 message 3...\n[after 16s]\n...message N-1 message N\n[after 16s]\nmessage 100\nIs possible do it only use Kafka?\nTkz","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":297,"Q_Id":64484041,"Users Score":1,"Answer":"A Kafka topic already is somewhat of a buffer, and producers send messages in batches as well, not one by one.\nYou can increase size of that batch, depending on the kafka library you're using, and manually flush it, but it appears you want the consumer to be halted for a period of time, which can be done, but it'll also cause the consumer group to rebalance as it expects a continuous heartbeat from active consumers (another timeout setting that can be modified)\nOther solution would be use a dequeue in your consumer code with a timer that is continuously added to, but only emptied on a schedule\nAnd if you want messages N-1 and N, then resume back to some earlier event, you need to seek the consumer group to (near) end of the topic","Q_Score":2,"Tags":"python,apache-kafka","A_Id":64484277,"CreationDate":"2020-10-22T14:07:00.000","Title":"Retain kafka message in buffer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"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 <app-name> <command>. 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 <app-name> will show you the result. Using cf logs <app-name> --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":"Bottom-line up front: Is there a way to support non-Java discovery client made instances in Zookeeper, while providing custom metadata.\nI'm building a Spring Cloud API Gateway. We're using Zookeeper discovery for most of our routes and Spring Cloud Load Balancer. It works well for Java micro-services. In addition to normal discovery and load balancing, I want to use metadata to specify customization attributes; like security and rate limiting parameters.\nI'm needing to introduce some non-Java services written in Python, so I'm wanting to use discovery for those since they're hosted in a dynamic cluster. In this case, continuing to use Zookeeper makes a lot of since for us if I can get it to do what I need.\nI've inspected the contents of Zookeeper \/services node to see what's going on and I'm able to replicate most of it and actually get discovery and load balancing to work, but the metadata is a level deeper and I can't get that to work, as it's embedded in the Curator\/Zookeeper-specific object.\nI think I know enough to write my own implementation of DiscoveryClient and return my own ServiceInstances, but that seems like a lot of work if I can almost use what I already have. I'll also have to write the Python client for this as well.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":211,"Q_Id":64489391,"Users Score":0,"Answer":"I got around this by re-implementing the InstanceSerializer to manually build the ZookeeperInstance if the ObjectMapper doesn't recognize the ZookeeperInstance automatically.","Q_Score":0,"Tags":"python,service-discovery,spring-cloud-gateway,spring-cloud-zookeeper","A_Id":64611829,"CreationDate":"2020-10-22T19:39:00.000","Title":"Non-Java discovery registration for Spring Cloud Gateway\/Zookeeper","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"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'm trying to use manager in Multiprocessing in Python to share a list (amongst other things) across processes. It would appear that the only way to change values in the list is to do it explicitly, i.e. list1[2] = list2[2]. This is a bit of a pain if the lists are long or complicated. I would like to just be able to say list1 = list2, where list1 is the shared object controlled by manager and list2 is a list in a worker process. It will let me append to list1 (so it doesn't have to be fixed length) but it won't let me clear list1 so\nlist1.clear()\nlist1.append(list2)\nwon't work. Does anybody have a simple solution to this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":64491747,"Users Score":0,"Answer":"Sorry if this should be a comment - comments seem to be very limited in length.\nSo I have tried Array (what I am currently using) and sllcing didn't work. I still had to put things together entry by entry. Also, the input comes as a list of lists (i.e. a 2D array) and it isn't obvious to me how I can get Array to work with a 2D array, at least trivially.\nI had thought of queues but the producer creates data far faster than the consumer takes it and the consumer only ever wants the latest data so I had gone with Arrays because that way I am overwriting the old data. However, I guess I could make the consumer pop off the latest data and then clear the queue (?). That would be a possibility.\nI was unaware of concurrent.futures so will have to take a look at that","Q_Score":1,"Tags":"python,multiprocessing","A_Id":64513949,"CreationDate":"2020-10-22T23:11:00.000","Title":"Sharing data across processes in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"They used to save before, but all of a sudden they do not. I even have DEBUG = True and I have django.contrib.staticfiles in my installed apps. I'm not really what code I should provide, so if anyone needs any, please ask, and I'll send you the code. Thank You!\nEdit: So I've somewhat realized that the two times this has happened, was when I turned debug to false and back to true again.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":173,"Q_Id":64493951,"Users Score":0,"Answer":"So I reached out to someone else, and realized that all I had to do was hard refresh the page. Cmd+Shift+R on a mac and Ctrl+F5 on a windows machine.","Q_Score":0,"Tags":"python,css,django,server,django-staticfiles","A_Id":64507513,"CreationDate":"2020-10-23T04:39:00.000","Title":"Why do my changes not save in static css files in django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been trying to import a large scale data from csv to Postgres after every 10mins.\nWith the help of celery I have scheduled few jobs parallelly.\nNo. of rows in csv are not matching after import into postgres.\nI've been writing CSVs into db with df.to_sql() method and it is not throwing any error but still some rows are missing in DB.\nAccording to my observance the increasing size of table is leading to missing rows.\nIs it Postgres limit?\nor is it the overlapping schedule of jobs which is causing locks or anything?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":64495324,"Users Score":0,"Answer":"In one of the columns of my CSV file I had data in this format:\n\n\"abc, xyz\"\n\nSo, using quotechar='\"' helped me to fix my issue.\nThank you all for your ideas and suggestions.","Q_Score":0,"Tags":"python-3.x,postgresql,import,django-celery","A_Id":65558585,"CreationDate":"2020-10-23T06:58:00.000","Title":"import from CSV to Postgres is missing some rows in python","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have trained a model for image segmentation task on 320x240x3 resolution images using tensorflow 2.x. I am wondering if there is a way to use the same model or tweak the model to make it work on different resolutions?\nI have to use a model trained on a 320x240 resolution for Full HD (1920x1080) and SD(1280x720) images but as the GPU Memory is not sufficient to train the model at the specified resolutions with my architecture, I have trained it on 320x240 images.\nI am looking for a scalable solution that works at all the resolutions. Any Suggestions?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":236,"Q_Id":64495805,"Users Score":2,"Answer":"The answer to your question is no: you cannot use a model trained at a particular resolution to be used at different resolution; in essence, this is why we train the models at different resolutions, to check the performance and possibly improve it.\nThe suggestion below omits one crucial aspect: that, depending on the task at hand, increasing the resolution can considerably improve the results in object detection and image segmentation, particularly if you have small objects.\nThe only solution for your problem, considering the GPU memory constraint, is to try to split the initial image into smaller parts (or maybe tiles) and train per part(say 320x240) and then reconstruct the initial image; otherwise, there is no other solution than to increase the GPU memory in order to train at higher resolutions.\nPS: I understood your question after reading it a couple of times; I suggest that you modify a little bit the details w.r.t the resolution.","Q_Score":0,"Tags":"python-3.x,tensorflow,deep-learning","A_Id":64497096,"CreationDate":"2020-10-23T07:34:00.000","Title":"How to use a trained deeplearning model at different resolutions?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have trained a model for image segmentation task on 320x240x3 resolution images using tensorflow 2.x. I am wondering if there is a way to use the same model or tweak the model to make it work on different resolutions?\nI have to use a model trained on a 320x240 resolution for Full HD (1920x1080) and SD(1280x720) images but as the GPU Memory is not sufficient to train the model at the specified resolutions with my architecture, I have trained it on 320x240 images.\nI am looking for a scalable solution that works at all the resolutions. Any Suggestions?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":236,"Q_Id":64495805,"Users Score":0,"Answer":"YEAH, you can do it in high resolution image. But the small resolution is easy to train and it is easy for the model to find the features of the image. Training in small resolution models saves your time and makes your model faster since it has the less number of parameters. HD images contains large amount of pixels, so if you train your model in higher resolution images, it makes your training and model slower as it contains large number of parameters due to the presence of higher number of pixels and it makes difficult for your model to find features in the high resolution image. So, mostly your are advisable to use lower resolution instead of higher resolution.","Q_Score":0,"Tags":"python-3.x,tensorflow,deep-learning","A_Id":64496798,"CreationDate":"2020-10-23T07:34:00.000","Title":"How to use a trained deeplearning model at different resolutions?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question concerning the access of the shared memory within the Ray Framework.\nImagine the following setup on 1 machine:\n\nStart Ray cluster\nStart a process\/worker python script w1.py, which puts an object O1 into the shared memory via ray.put(O1)\nStart a process\/worker python script w2.py, which tries to get O1 from the shared memory via ray.get(...)\n\nIs there a way to access the object O1 (put into shared memory from w1.py process) from another worker process w2.py?\nWhen I execute ray.objects() from w2.py, I get the obejct reference string, but how could I retrieve the object from the shared memory then? I can not init a ObjectRef object in w2.py","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":577,"Q_Id":64499456,"Users Score":1,"Answer":"This is not natively supported. The reason is ray\u2019s objects have various metadata that is for various features (ex, perf optimization or automatic memory management using reference counting).\nIf you\u2019d like to achieve this, I think there are 2 solutions.\n\nUse a detached actor api. Detached actors are actors whose lifetime is not fare-sharing with drivers. Once you create a detached actor, you can obtain the actor handle using ray.get_actor API. This way, you can put an object inside a detached actor and access from multiple drivers.\n\nThere\u2019s another way which uses cloudpickle, but I am not so familiar with this solution, so I won\u2019t write about it. Please go to Ray\u2019s discussion page in its Github repo to ask more details about it.","Q_Score":1,"Tags":"python,redis,multiprocessing,shared-memory,ray","A_Id":64502561,"CreationDate":"2020-10-23T11:50:00.000","Title":"Python Ray shared memory access","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am fairly new to kivy and am currently writing a simple fitness app for my A-level computing project.\nI originally used simple instructions I found from different websites and this means I have now coded the majority of my app in only kivy language instead of having a .py file too (sorry if that makes little sense, I'm struggling to understand the concept of both the .py file and the .kv file)\nIs it okay to just code in a 'kv.' type of file where I am mostly just using kivy language? Or do I need to learn how to create a .py file too for my app to work completely (as I have run into some issues such as using the scrolling widget and am wondering if this is to do with me not having a .py file as most solutions seem to be using a .py file.\nThanks for any help","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":64499657,"Users Score":0,"Answer":"There is no fundamental problem with using mostly or entirely kv files, if they do what you want.\nI suggest asking a separate question about the specific issues you're hitting.","Q_Score":0,"Tags":"python,kivy,kivy-language","A_Id":64505908,"CreationDate":"2020-10-23T12:04:00.000","Title":"what is the need for .py and .kv files with kivy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new in this domain. I am looking for codes for late fusion. I have text features but I don't know how to implement late fusion. I read articles on this but a working code will help me to understand the implementation properly.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":153,"Q_Id":64502460,"Users Score":1,"Answer":"I solved this problem. I am not expecting an answer to this question. If any of you face a similar situation for them I am explaining here. Let you have texture features of two classes. Classify those features based on two\/multiple different classifiers, for example, SVM, KNN, RF, Adaboost, etc. Compute probability scores using each classifier. Now, concatenate the probability scores of all classifiers and finally again classify the using any classifiers. In this step, you may use previously used classifiers.","Q_Score":1,"Tags":"python,fusion","A_Id":64563460,"CreationDate":"2020-10-23T14:59:00.000","Title":"Late Fusion of text features","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"if I execute my py script with 'import psutil' I get the error \"ImportError: No module named psutil\". I realized if I use pip3 install psutil it installs it to \/lib64\/ and my other modules to \/lib\/ so I used --target and put in the path the other modules were in and removed it from \/lib64\/ but it still does not work. I am working on Linux.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":19,"Q_Id":64504518,"Users Score":0,"Answer":"Problem was that I executed my script with 'python ...' and not 'python3 ...'\nIt works now","Q_Score":0,"Tags":"python,linux,psutil","A_Id":64504770,"CreationDate":"2020-10-23T17:14:00.000","Title":"ImportError with psutil eventhough 'pip3 show psutil' shows it is installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to convert a frequency value into a note like an input of 400 hz printing \"A4\", but I don't want to write a complete frequency table in my code. Is there any way to accomplish this?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":2059,"Q_Id":64505024,"Users Score":2,"Answer":"This is all the musical information you need in order to be able to derive a formula that tells you how many halftones away from A4 a given frequency is:\n\nA4 is 440 Hz (not 400).\nThe ratio between the frequencies of any two adjacent halftones is constant (e.g. A\/Ab and Bb\/A give the same number).\nThe ratio between the frequencies of two tones that are an octave apart is 2.\nThere are twelve halftones in an octave.\n\n(The last two points will let you figure out what the constant ratio in the second point is.)\nAlternatively, you could use this to write a program that simply \"steps\" up or down from A4 until it reaches (or passes) the given frequency.","Q_Score":1,"Tags":"python,frequency","A_Id":64505154,"CreationDate":"2020-10-23T17:51:00.000","Title":"Turning frequencies into notes in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've just installed Anaconda by using Package Control; and, after installing it, the terminal show me this message:\n\nanacondaST3: ERROR - Anaconda worker could not start because:\nconnection to localhost:50462 timed out after 0.2s. tried to connect 7\ntimes during 2.0 seconds\ncheck that there is Python process executing the anaconda\njsonserver.py script running in your system. If there is, check that\nyou can connect to your localhost writing the following script in your\nSublime Text 3 console:\nimport socket; socket.socket(socket.AF_INET,\nsocket.SOCK_STREAM).connect((\"localhost\", 50462))\nIf anaconda works just fine after you received this error and the\ncommand above worked you can make anaconda to do not show you this\nerror anymore setting the 'swallow_startup_errors' to 'true' in your\nconfiguration file.\n\nAnd, the Anaconda autocompletation just doesn't work, the only reason I installed Anaconda for.\nWhat should I do?\nI'm practically a beginner in all of this programming stuff, so, be nice:(","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":3876,"Q_Id":64505028,"Users Score":3,"Answer":"I come cross this problem When I use sublime3\uff0c\nI fix it When I change the python_interpreter\nI think you could change the default Anaconda Python interpreter from python to python3.\nIn the preference  > Package Settings > Anaconda > \"Settings - Default\"\nyou could  see and change this,from python to python3:\n\"python_interpreter\": \"python3\", which is in line 100.","Q_Score":3,"Tags":"python,anaconda,sublimetext3","A_Id":71389887,"CreationDate":"2020-10-23T17:52:00.000","Title":"Anaconda worker could not start because: connection to localhost timed out after 0.2s. tried to connect 7 > times during 2.0 seconds","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to create a python virtual environment in a Windows network folder, and then activate and use this venv on another computer. My question is, do I need to have python installed on all these machines that i want to use this virtual environment?\nIf so, why do I need to install python everywhere if it's already inside this venv i will create, along with all the necessary packages?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":178,"Q_Id":64506037,"Users Score":2,"Answer":"Virtual environments are not designed to be portable. For instance, if you have entry points installed then moving them to another machine would break their shebang lines. And even if you do it on your local machine there's no guarantee something else wasn't structured to be directory-specific such as your username! Take in consideration that when creating Python venv, it will be pointed to your python path where your username is part of the path, so its not a good idea. Although why not upload py files to the cloud, share via Bluetooth to phone or copy-paste to a usb stick.","Q_Score":2,"Tags":"python,windows,virtualenv","A_Id":64506679,"CreationDate":"2020-10-23T19:13:00.000","Title":"Do I need to have Python installed on my machine to run a code in a virtual environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning how to use python.\nFor the project I am working on, I have hundreds of datasheets containing a City, Species, and Time (speciesname.csv).\nI also have a single datasheet that has all cities in the world with their latitude and longitude point (cities.csv).\nMy goal is to have 2 more columns for latitude and longitude (from cities.csv) in every (speciesname.csv) datasheet, corresponding to the location of each species.\nI am guessing my workflow will look something like this:\nGo into speciesname.csv file and find the location on each line\nGo into cities.csv and search for the location from speciesname.csv\nCopy the corresponding latitude and longitude into new columns in speciesname.csv.\nI have been unsuccessful in my search for a blog post or someone else with a similar question.  I don't know where to start so anyone with a starting point would be very helpful.\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":64507660,"Users Score":0,"Answer":"You can achieve it in many ways.\nThe simplest way I can think of to approach this problem is:\n\ncollect all cities.csv data inside a dictionary {\"cityname\":(lat,lon), ...}\nread line by line your speciesname.csv and for each line search by key (key == speciesname_cityname) in the dictionary.\nwhen you find a correspondence add all data from the line and the lat & lon separated by comma to a buffer string that has to end with a \"\\n\" char\nwhen the foreach line is ended your buffer string will contains all the data and can be used as input to the write to file function","Q_Score":0,"Tags":"python,csv,parsing","A_Id":64507904,"CreationDate":"2020-10-23T21:44:00.000","Title":"How do I pull specific data from one file and add it to another file in a specific spot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed python3 and required module with root access. But, When I try to run the scrip as non-root user. I am getting following error:\n\nNo module found Error.\n\nWhat is the right way to run the python3 script as non-root user. virtualenv works fine If interactively runs it. But, I need to run it from nifi. So, I should be able to execute it without virtualenv.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":474,"Q_Id":64509638,"Users Score":1,"Answer":"You would need to install the module as non-root, or more specifically, the user account that runs NiFi.\nYou shouldn't be using sudo with pip anyway","Q_Score":1,"Tags":"python,python-3.x,apache-nifi","A_Id":64509697,"CreationDate":"2020-10-24T03:19:00.000","Title":"Run python script as non-root user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I installed python3 and required module with root access. But, When I try to run the scrip as non-root user. I am getting following error:\n\nNo module found Error.\n\nWhat is the right way to run the python3 script as non-root user. virtualenv works fine If interactively runs it. But, I need to run it from nifi. So, I should be able to execute it without virtualenv.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":474,"Q_Id":64509638,"Users Score":0,"Answer":"The easiest way to do this would be to install Anaconda (big Python distribution with a nice installer) in a location accessible to NiFi and chown the Anaconda folder to the NiFi service account user.","Q_Score":1,"Tags":"python,python-3.x,apache-nifi","A_Id":64536932,"CreationDate":"2020-10-24T03:19:00.000","Title":"Run python script as non-root user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have tried to install a private Github repo package into Pycharm, and ran into a ModuleNotFoundError. I replaced actual package name with generic package_name for convenience of the reader.\nI've gotten it to work on my Travis with a Pipfile and an environment variable of CI_USER_TOKEN.\nHowever, here's what I've tried to make it work locally, and I haven't gotten progress in the last couple of hours of working on this:\n\nI put that CI_USER_TOKEN into an .env file locally, and created a .netrc file in the home directory with the GitHub credentials, and still no luck. (Error: ModuleNotFoundError: No module named 'package_name')\n\nI also set the CI_USER_TOKEN as an environmental variable in the edit configurations section of the open 'edit run\/debug run configurations' dialog. (Error: ModuleNotFoundError: No module named 'package_name')\n\nI also added my Github account on the preferences > Version Control > GitHub using the CI_USER_TOKEN key. (Error: ModuleNotFoundError: No module named 'package_name')\n\nLastly, I tried to set it as an installable from in the preferences > project interpreter > Install (plus sign) > Manage Repositories > Enter Repository URL (Error: \"Error loading package list: Request failed with status code 404\")\n\n\nSo I'm stumped on why Pycharm is so much harder to configure with installing a private repo than Travis\/Pipfile is for the same repo. Hopefully someone can point me in the right direction because I feel like I'm spinning my wheels.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":459,"Q_Id":64510144,"Users Score":0,"Answer":"Go to Pycharm settings and choose \"Project: <your_project> -> Python Interpreter\". Make sure the selected python interpreter is the one where you actually installed your package and you will be able to import it in pycharm. If you can activate that environment (with virtualenv, conda, etc) and import your module from the python terminal outside pycharm, then it will work in pycharm as long as the selected interpreter is correct.","Q_Score":0,"Tags":"python,github,pycharm,modulenotfounderror","A_Id":64514961,"CreationDate":"2020-10-24T04:59:00.000","Title":"Pycharm Install Github Private Repo Package ModuleNotFoundError: No module named 'package_name'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to detect if someone has charles proxy or a network tracking app, tracking your program's requests\/apis. And if so is there a way to prevent such a thing.\nJust wanted a bit of insight into this, any information is much appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":211,"Q_Id":64510362,"Users Score":0,"Answer":"It's possible to achieve it: Here are two solutions I could think of\n\nAfter the SSL finish, you can get the certificate and check whether or not it's a self-signed certificate. Then, you might reject the Request connection.\n\nUse the SSL-Pinning technique that only accepts the certificate from your own and rejects others. It will prevent the app is intercepted from Charles Proxy or other Proxy tools like Proxyman, Fiddler, and Wireshark.","Q_Score":0,"Tags":"python-requests,charles-proxy","A_Id":64569777,"CreationDate":"2020-10-24T05:42:00.000","Title":"Is there a way to detect if someone has charles proxy or a network tracking app, tracking your program's requests\/apis","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just installed  Spyder (Python 3.8) and in the Anaconda Prompt, i installed OpenCV, however while running the following statements:\nimport cv2\nface_cascade = cv2.CascadeClassifier('haarcascade_frontalcatface.xml') \nI receive as error: module 'cv2' has no attribute 'CascadeClassifier'.\nLet me tell you that i've already downloaded 'haarcascade_frontalcatface.xml' file.\nPlease help me to fix this problem.\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":510,"Q_Id":64513148,"Users Score":0,"Answer":"Strange. Did you install the latest version of OpenCV or the version which actually contains the implementation of this CascadeClassifier?\nMaybe, you could try running conda update opencv and see if it resolves the problem or not.","Q_Score":2,"Tags":"python,opencv,deep-learning,anaconda,spyder","A_Id":64513263,"CreationDate":"2020-10-24T12:06:00.000","Title":"How to fix 'cv2' has no attribute 'CascadeClassifier'?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm training a DL model in Tensorflow 2.1. I prepared a training set of several greyscale (1-channel) images.\nI have seen that it is recommended to normalize the training set by dividing it by 255.0, so that the values are inside the range [0-1]. So I have some questions regarding it:\n\nWhy is this normalization recomended?\nMy target masks contain values from 0-1 and are float 64. Is it valid to use this data type?\nFinally, Should I normalize the images that I use for future predictions as well, or can I just leave them as 8-bit images (0-255).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":64513779,"Users Score":1,"Answer":"The normalization is recommended as it was empirically observed that\nthe network converges faster and to better global optima when all\nthe pixel values lie between (0 and 1) rather than 0 and 255.0. You\ncan try to see how the network behaves when you train with the\nvalues between 0 and 1.0 and 0 and 255.0.\n\nThe mask value does not need to be converted, leave it as it is(presuming you are doing image segmentation), just ensure the labels are correct.\n\nYes, the same preprocessing that is applied during the training must be applied during the testing scenario\/future predictions, otherwise your model will not work.","Q_Score":0,"Tags":"python,tensorflow,deep-learning","A_Id":64513912,"CreationDate":"2020-10-24T13:25:00.000","Title":"Re-Scale Training Set","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cant import anything I have tried everything; using pip in cmd, importing in python(of course) and done every pip command, it always says done and complete. but then in python and pycharm I cant import it. the cmd also says after i download an importation ( ;) ) that I am running an older version of pip; does this have to do with anything? please answer. I am also very new to python so excuse me if I said anything strange or completely wrong.\n-Joep","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":64515242,"Users Score":0,"Answer":"Uninstall Python and Install it again but select the  \"Add To The PATH\" option to make pip and python example.py commands or other commands Installed to the System PATH\nPyCharm recognizes it automatically when it's installed in the System Path.\nI Hope Its Works :)\n~Derin O. Eren","Q_Score":1,"Tags":"python,python-3.x,import,python-import","A_Id":64515400,"CreationDate":"2020-10-24T15:50:00.000","Title":"unable to import basically anything","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the wheel file called ssh2_python-0.23.0-cp38-cp38-win_amd64.whl downloaded, and from my understanding the cp38 part means that it has to be installed with python 3.8 and that the win_amd64 part means that its for windows with an 64 bit architechture(which i have).\nBut if i try to install it with python -m pip install ssh2_python-0.23.0-cp38-cp38-win_amd64.whl i get the following error message:\nERROR: ssh2_python-0.23.0-cp38-cp38-win_amd64.whl is not a supported wheel on this platform.\nOutput of python -V: Python 3.8.5\nI'm running the commands in a conda enviroment, does this make a difference?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":97,"Q_Id":64516333,"Users Score":2,"Answer":"ssh2_python-0.23.0-cp38-cp38-win_amd64.whl is a wheel for 64-bit Python. It seems you have 32-bit Python. Either install 64-bit Python or use a 32-bit wheel.","Q_Score":0,"Tags":"python,python-wheel","A_Id":64516549,"CreationDate":"2020-10-24T17:45:00.000","Title":"Can't install ssh2-python wheel file with python 3.8 although it's for python3.8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Suppose I have the list my_list = list(range(10)). In using map(), what is the equivalence of [K(x, fix_elem) for x in my_list]? At the beginning, I thought map(K, my_list) was fine, but I have a fixed element fix_elem which is incompatible with my demand.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":64519297,"Users Score":0,"Answer":"You need to use map and lambda: list(map(lambda x: K(x, fix_elem), list(range(10))))","Q_Score":0,"Tags":"python,mapping,list-comprehension","A_Id":64519315,"CreationDate":"2020-10-25T00:32:00.000","Title":"The equivalence of [K(x, fix_elem) for x in my_list] using map()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Python 3.9.0 recently, and I am using virtualenv package.\nWhile creating a new environment with specifying a lesser python version, say 3.6\nI am getting this error:\nRuntimeError: failed to find interpreter for Builtin discover of python_spec='python3.6'\nI suppose I don't need to download 3.6 specifically to create an environment for that python version.\nCan I get around it using just virtualenv package?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1006,"Q_Id":64520647,"Users Score":1,"Answer":"you need to download Python 3.6 in order to use it you could store in an environment but you can't get python 3.6 by creating an environment for it.","Q_Score":1,"Tags":"python,virtualenv,sys.path","A_Id":64520708,"CreationDate":"2020-10-25T05:28:00.000","Title":"Not able to create Python virtual env with lesser version than installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to upload a txt file which contains data as below . I have around 1M records in the file .\nData consist of different fields (which is to be columns ) in which I have manually added a comma as a delimiter.\nThe challenge is all the records does not have the same set of fields.\nThe columns should be \"Time\" , \"ENTER\" , \"TRANSID\" , \"SUPERCODE\" ,\"ID\", \"MRP\",\"VOLUME\",\"VALUE\",\"PRODUCTtype\",\"BUILDING\",\"TAXNUM\", \"TAGFIELDS\"\n\n00:00:00.000:, ENTER, transId=1, Supercode=BD3G, id=1, MRP=0.12s9,\nvolume=110333, value=20942463.27, productype=se IA CF, building=11430,\ntaxnumber=110F1, tagFields={B=C C=NZd3\/1 D=\"20170514 07:41:53.616\"\nF=:00000017PouM H=LMT O=6521B841:00023662-A-15.1sd01.200.0.50dsd03.0.0\nR=\"Order not Added\" a=A c=FIRST3eNZA j=N}\n00:00:00.000:, ENTER,transId=2,Supercode=BYG, id=2, MRP=0.195,\nvolume=223000, value=43485,> productype=se IA CF, building=110,\ntaxnumber=110I1, tagFields={B=C> C=NZ3 D=\"20170514 07:41:25.161\"\nF=:00000017PouK H=LMT> O=6521B841:00023625-A-15.101.200.0.5003.0.0\nR=\"Ordernot Added\" a=A> c=FIRSTNZA j=N}\n\n\n#For this record, there is no taxnumber , so the TAXnumber column field should be blank\/Nan for this record\n00:00:00.000:, ENTER,  transId=3, Supercode=TBC, id=3,MRP=2.71,\nvolume=3750, value=10162.5, productype=It CF UeCP,> building=110,\ntagFields={B=C C=4331K D=\"20170514 > 13:59:51.288\"\nH=LMT K=12345O=6521B841:0027d59B6-B-15.101.200.0.5009.0.0 R=\"Order\nnotAdded\" a=P c=4sd33E> j=N}\n\n#For this record, there is no building number , so the building number column field should be blank\/Nan for this record\n\n00:00:00.000:, ENTER, transId=4, Supercode=ABT, id=4, MRP=2.73,>\nvolume=357, value=974.61, productype=se IrA CtF,\ntaxnumber=110B1, tagFields={B=C C=ZBJF D=\"20170929 16:10:01.321\" H=LT\nO=6521B5841:003A98565-A-15.101.2050.0.5009.0.0 R=\"Order not  Added\" a=A\nc=BNPLLCOLO j=Y}\n\nI have tried the below steps:\n\ndata = pd.read_csv(\"path.txt\",delimiter=\",\",header=None)\n\nI have got the output\n\nParserError: Error tokenizing data. C error: Expected 10 fields in\nline 66017, saw 11","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":139,"Q_Id":64520774,"Users Score":0,"Answer":"try using engine='python' and error_bad_lines=False in your pd.read_csv()","Q_Score":0,"Tags":"python,pandas,dataframe,text,python-import","A_Id":64521013,"CreationDate":"2020-10-25T05:54:00.000","Title":"How to upload a .txt file in python dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering How can I stop python from installing modules in specific virtual environment and install them globally;or probably virtaulenv won't let me do that!?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":647,"Q_Id":64521350,"Users Score":0,"Answer":"I believe I've found some sort of solution ,by just typing \"pip install -target C:\\Users\\YOURNAME\\AppData\\Roaming\\Python\\Python37\\site-packages\"\nit's kind of a lame solution but I think it's better than nothing!\nBy the way there was no pip.exe in my python folder!!!","Q_Score":2,"Tags":"python,pip,virtualenv","A_Id":64538420,"CreationDate":"2020-10-25T07:27:00.000","Title":"How to stop python from installing modules in specific virtual environment and install them globally?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering How can I stop python from installing modules in specific virtual environment and install them globally;or probably virtaulenv won't let me do that!?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":647,"Q_Id":64521350,"Users Score":1,"Answer":"You simply install the package without activating your virtual environment. Once you install your package that way, it would be installed globally instead of inside a global environment.\nAlso, to confirm this, you can activate your virtual environment and run the command pip list , this will show all the packages in that virtual environment, and also try deactivating the virtual environment and run the command pip list, this would show all packages in the system.\nI hope this answers your question","Q_Score":2,"Tags":"python,pip,virtualenv","A_Id":64525022,"CreationDate":"2020-10-25T07:27:00.000","Title":"How to stop python from installing modules in specific virtual environment and install them globally?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"Hey guys I'm trying to use the nstaPy bot written by python\nand I tried to install the requirements using pip but unfortunately I came across with an error that I'm unable to\nhandle. the error is with installing \"clarifai\" library  and I'm Getting These two: ERROR: Command errored out with exit status 1\nand\nerror: [WinError 2] The system cannot find the file specified\nPlease Help Me Handle This","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":64524613,"Users Score":0,"Answer":"You are probably using the wrong python and pip version.\nUse    python3 -m pip or pip3 install to install clarifai.\nLet me know.","Q_Score":0,"Tags":"python,clarifai,instapy","A_Id":64534459,"CreationDate":"2020-10-25T14:08:00.000","Title":"Failed to install clarifai for \"instapy\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to escape all html tags except for the  tag somehow?\nI am sending a user entered string from a view to an html template where I have manually added  tags to the string in the view. I would like to allow for that to be shown, but of course omit all html tags entered by the user.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":125,"Q_Id":64525541,"Users Score":1,"Answer":"The short answer to your question is that you could write your own filter to do this.\nA better solution IMHO would be to remove any tags from your user input, then add whatever tags you want, and then use the \"safe\" filter to display your modified text.","Q_Score":0,"Tags":"python,html,django","A_Id":64525619,"CreationDate":"2020-10-25T15:37:00.000","Title":"Django escape only certain HTML tags","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to use the autogui module to do something in Python. When I run the script, it says that it can't find the autogui module so I installed it with\npip install autogui.\nBut when I run the script again it still says me this module doesn't exist.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":404,"Q_Id":64526562,"Users Score":0,"Answer":"Method 1:\nYou're probably having trouble setting up your correct Python Interpreter and working within it,try the following in VSCode.\n\nCtrl + Shift + p\n\nAnd enter the following in the field.\n\npython: select interpreter\n\nSelect the desired environment and reinstall PyAutoGui\nMethod 2:\nCreating a virtual environment for your project where all your packages will be installed and will be isolated from others, and will have no import errors since it's an environment specifically for the project that you're working on.\nI assume you use Windows, so open the command line in your working directory, or open your working directory in VSCode and enter the following in the command-line tool that is provided within VSCode.\nThe Python installers for Windows include pip. You should be able to access pip using:\n\npy -m pip --version\n\nYou can make sure that pip is up-to-date by running the following\n\npy -m pip install --upgrade pip\n\nInstalling virtual environment\n\npy -m pip install --user virtualenv\n\nCreating a virtual environment\n\npy -m venv env\n\nThe second argument is the location to create the virtual environment. Generally, you can just create this in your project and call it env.\nvenv will create a virtual Python installation in the env folder.\nFinally, to activate the environment run the following command\n\n.\\env\\Scripts\\activate\n\nThat will activate your environment.\n\npip install pyautogui\n\nMake sure to change your interpreter to the one that you just created in the env\/bin folder and run your code, or you could just enter the path to the *python file located in the env\/bin folder.","Q_Score":0,"Tags":"python,pip,python-module","A_Id":64528833,"CreationDate":"2020-10-25T17:12:00.000","Title":"Installed modules not found by Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can you name situations in which one really needs to use os.fork() instead of multiprocessing?\nFULL DISCLOSURE:\nWhen one mentions os.fork(), tipically gets buried in \"you don't need to fork, just use multiprocessing\" or affine answers or comments. I created this question so it can be linked in response. In fact, I'll share my own answer. But if you know a better way to tackle my example scenario, feel free to drop a line - it'd be very useful!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":64526688,"Users Score":0,"Answer":"Let's say that you have a class Simulator. Its purpose is to do a very complicated simulation that you can advance by \"chunks\" (step by step, or for a certain amount of simulation time) with method Simulator.advance(n). Furthermore, you can change parameters in the simulation between calls to Simulator.advance(n) with method Simulator.change(parameters): they might be, e.g., wind speed, available resources, etc.\nThe two following statements, as it may very well happen, are also true:\n\nThe simulation is computationally costly;\nFor whatever reason, you have no chance in heaven to serialize an instance of Simulator mid-flight.\n\nNow, say that you need to simulate N different scenarios with identical initial conditions that share a common first call to Simulator.advance(n), before some parameter is changed in a different way in each scenario, and then the simulation is resumed for a brief, differentiated final part.\nSince the computation is very costly, you would really like not to run the exact same first part N times. So what you do is run the first part, and then (leveraging the raw copy of the process memory by os.fork() in order not to have to serialize anything) you fork N times, pick a different parameter change in every child process, and then collect the final result from each.","Q_Score":0,"Tags":"python,python-multiprocessing","A_Id":64526689,"CreationDate":"2020-10-25T17:28:00.000","Title":"What are good reasons to do naked os.fork() calls in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am not sure why we need to create a different environment in anaconda? To do that, we have to download some python libraries like matplotlib etc. again in that environment which will consume more drive space? My pc is running out of space. Anyone can help me understand it? Also, how to run the python script file directly under the created anaconda environment in the anaconda terminal? Thanks","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":366,"Q_Id":64526934,"Users Score":2,"Answer":"Anaconda is used to manage different environments which means you can have different versions of python installed on the same computer without having to mix up. For example, if your computer has python 3.8.5 running you can't use a module called TensorFlow. So to use TensorFlow I installed anaconda to manage different versions of python. It depends on you and the reason why you need different versions of python.\nAnyways to run a python script using anaconda environment, the steps are below.\n\nOpen up your terminal window. Create an environment by typing in conda create -n Stackoverflow python=3.6 You can use any name for your environment instead of Stackoverflow Change 3.6 to your desired version of python.\n\nAfter the setup is done. Type in conda activate TensorFlow Replace TensorFlow to your environment name.\n\nNow navigate to your directory where you have your python file. For example if it is in the desktop, type cd Desktop\n\nTo run the python file simply type python filename.py in your terminal.","Q_Score":0,"Tags":"python","A_Id":64527637,"CreationDate":"2020-10-25T17:53:00.000","Title":"why we different environments in Anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am not sure why we need to create a different environment in anaconda? To do that, we have to download some python libraries like matplotlib etc. again in that environment which will consume more drive space? My pc is running out of space. Anyone can help me understand it? Also, how to run the python script file directly under the created anaconda environment in the anaconda terminal? Thanks","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":366,"Q_Id":64526934,"Users Score":1,"Answer":"I'd like to add my opinion after deep diving into python.\nI have some programming knowledge for the web (HTML, PHP, WordPress, light javascript), and I've only started working with python about a week ago. It was a mess the first few hours\u2014trying installs, things not compatible with OS version, $PATH not always being set correctly, messing with .bash_profile, fighting with pyenv and homebrew. It was maddening. Luckily I stumbled onto Anaconda searching for a replacement to pyenv, which removed 99% of my headaches. Now, I honestly wouldn't want to work with python without Anaconda or something like it to manage envs because of how my productivity skyrocketed.\nAfter an hour or so setting up environments, I had it down. I tested some projects from Github and using anaconda made the entire process fast and easy. Within a minute or two I can download a repo, setup the correct python version, install the dependencies and start using the software. Anaconda makes it fast to set things up so you can get to work. I was able to spend my time learning python and dissecting opensource code instead of battling with pyenv and homebrew and my OS.\nBesides that, you don't have to worry about system conflicts as everything is being stored away from your global installs and can easily be copied or shared as yaml files. I've been messing with machine learning, image and audio manipulation, etc. and I really wouldn't want all that stuff globally loaded in my system\u2014not to mention, I'd probably run into tons of problems. This way, it's all quarantined. The only system-wide stuff I install are mandatory things only available through homebrew or manually building them.\nAnd if hard drive space is a problem, invest in more hard drives, especially if you want to get into machine learning or work with graphics and audio. Some of the libraries are large, the data piles up, models can be in the GBs each. You'll have lots of data flying around and you'll need the space. I amassed almost 100GB in the past week, but some I can trash. It's worth it though, because I'm learning and working and getting things accomplished.\nLastly, there was some software not even supposed to work on macOS that I was trying to make work. It worked with Anaconda though. Not sure if it was luck or I just did things right, but there you go.\nSo what I've found is so great about Anaconda summed up:\n\nSpeed of setting up and toggling on and off environments\nSeparation of installs from the system while still having access to it\nAbility to have many specific python versions installed\nNo conflicts or path problems with python version bundled with OS (like mac)\nSimplicity\/flexibilty of installing with conda or pip\nShorter pip commands (you don't need to use python -m or --user\nIf an env goes awry, you can dump it with one command and start fresh\nThe ease of setup allows you to focus on learning and coding instead of troubleshooting\n\nThe last point is why I really like it. I'm learning python instead of fighting with installations. It's made the experience way more fun and I've learned way more than I could have without it.\nYMMV, but I can't see why anyone wouldn't want to use an env management system.","Q_Score":0,"Tags":"python","A_Id":70013182,"CreationDate":"2020-10-25T17:53:00.000","Title":"why we different environments in Anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I refer to frameworks such as aiohttp, tornado, gevent, quart, fastapi, among others.\nIf you look for tutorials on how to use celery with django and flask to do things like background and periodic tasks, for example, to send an email when a user registers to confirm their account, you'll find a lot of content about it. But not with the ones above, or they are very few and talk about other topics than perform background or periodic tasks. Does this mean that with these frameworks I don't need celery because since they are asynchronous I can do the same?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":252,"Q_Id":64527328,"Users Score":2,"Answer":"Celery (and similar like Huey or RQ) has different purpose than the frameworks you have listed. No matter which framework you pick, in order to distribute execution of tasks among (potentially hundreds) nodes you would need to implement the whole system yourself. Things would get even more complicated if you want to implement something like Celery workflow...\nSo the answer ca be both YES and NO.\nNO: you do not need Celery if you want to implement all the functionality that Celery provides out-of-box by yourself.\nYES: more pragmatic - you use your async framework to implement your (web) service(s), but whenever you need to distribute execution of some either CPU intensive or long-running tasks, you use Celery, as that is what it is made for.","Q_Score":2,"Tags":"python,asynchronous,celery,web-frameworks","A_Id":64539115,"CreationDate":"2020-10-25T18:30:00.000","Title":"Do I need celery with asynchronous web frameworks?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a file of around 16mb in size and am using python boto3 upload_file api to upload this file into the S3 bucket. However, I believe the API is internally choosing multipart upload and gives me an \"Anonymous users cannot initiate multipart upload\" error.\nIn some of the runs of the application, the file generated may be smaller (few KBs) in size.\nWhat's the best way to handle this scenario in general or fix the error I mentioned above?\nI currently have a Django application that generates a file when run and uploads this file directly into an S3 bucket.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":266,"Q_Id":64528274,"Users Score":2,"Answer":"Ok, so unless you've opened your S3 bucket up for the world to upload to (which is very much NOT recommended), it sounds like you need to setup the permissions for access to your S3 bucket correctly.\nHow to do that will vary a little depending on how you're running this application - so let's cover off a few options - in all cases you will need to do two things:\n\nAssociate your script with an IAM Principal (an IAM User or an IAM Role depending on where \/ how this script is being run).\nAdd permissions for that principal to access the bucket (this can be accomplished either through an IAM Policy, or via the S3 Bucket Policy)\n\nLambda Function - You'll need to create an IAM Role for your application and associate it with your Lambda function. Boto3 should be able to assume this role transparently for you once configured.\nEC2 Instance or ECS Task - You'll need to create an IAM Role for your application and associate it with your EC2 instance\/ECS Task. Boto3 will be able to access the credentials for the role via instance metadata and should automatically assume the role.\nLocal Workstation Script - If you're running this script from your local workstation, then boto3 should be able to find and use the credentials you've setup for the AWS CLI. If those aren't the credentials you want to use you'll need to generate an access key and secret access key (be careful how you secure these if you go this route, and definitely follow least privilege).\nNow, once you've got your principal you can either attach an IAM policy that grants Allow permissions to upload to the bucket to the IAM User or Role, or you can add a clause to the Bucket Policy that grants that IAM User or Role access. You only need to do one of these.\nMulti-part uploads are performed via the same S3:PutObject call as single part uploads (though if your files are small I'd be surprised it was using multi-part for them). If you're using KMS one small trick to be aware of is that you need permission to use the KMS key for both Encrypt and Decrypt permissions if encrypting a multi-part upload.","Q_Score":0,"Tags":"python-3.x,amazon-web-services,amazon-s3,boto3","A_Id":64529021,"CreationDate":"2020-10-25T20:10:00.000","Title":"Uploading a file through boto3 upload_file api to AWS S3 bucket gives \"Anonymous users cannot initiate multipart uploads. Please authenticate.\" error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This will be more of an open question, but I'm hoping someone may know how to solve my problem.\nI have C++ library compiled with pybind11, allowing me to call some functions from python. The C++ library uses CUDA to perform some operations on the device.\nI need to allow the user (who only has access to python, and cannot go into the C++ or CUDA code) to define an operation (typically, a lambda) that will run in one of the CUDA kernels.\nIf you have any pointers as to where I could learn the proper way of doing this, I'd be very grateful!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":191,"Q_Id":64530634,"Users Score":2,"Answer":"I can't think any way to do this. Barriers to making something like this work\n\nPyBind style bindings won't work with CUDA device functions\nWhile CUDA supports passing of C++ lambda functions to kernels, it is a static compiler generated support. There is no way I am aware of to get a lambda function into a kernel call without compiler invocation (and probably nvcc and not nvrtc, which would imply a lot of messing around with compilers at runtime, or hacking extensions to PyCUDA). All of that would violate your \"cannot go into the C++ or CUDA code\" criteria.\nSimilarly, you would require CUDA runtime linking support in your application. I'm also pretty certain that the linker can't link naked lambda functions, only device functions with a generic interface (nvstd::function), so you would need to emit kernels, wrappers, and CUDA C++ device lambdas, compile them, and link them. That requires the CUDA driver API which I am sure you are not using.\n\nThe best hope you have would be to try Numba, which allows runtime compiling of Python device functions. However it lacks any ability to deal with lambda functions and can't interact with C++ code statically or JIT compiled with the CUDA toolchain. You might be forced to reimplement a lot of your CUDA C++ code in Python to make that work, and the Numba kernel dialect lacks a lot of modern CUDA features, which might make that extremely difficult depending on how sophisticated your existing CUDA code is.","Q_Score":0,"Tags":"python,c++,lambda,cuda","A_Id":64530815,"CreationDate":"2020-10-26T02:03:00.000","Title":"Best way to pass a lambda to a CUDA kernel from python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have  a python program which 1) Reads from a very large  file from Disk(~95% time) and then 2) Process and Provide a relatively small output (~5% time). This Program is to be run on TeraBytes of files .\nNow i am looking to Optimize this Program by utilizing Multi Processing and Multi Threading . The platform I am running is a Virtual Machine with 4 Processors on a virtual Machine .\nI plan to have  a scheduler Process which will execute 4 Processes (same as processors) and then Each Process should have some threads as most part is I\/O . Each Thread will process 1 file & will  report result to the Main Thread  which in turn will report it back to scheduler Process via IPC . Scheduler can queue these and eventually write them to disk in ordered manner\nSo wondering  How does one decide number of Processes and Threads to create for such scenario ? Is there a Mathematical way to figure out whats the best mix .\nThankyou","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1322,"Q_Id":64532146,"Users Score":0,"Answer":"One idea can be to have a thread only reading the file (If I understood well, there is only one file) and pushing the independent parts (for ex. rows) into queue with messages. \nThe messages can be processed by 4 threads. In this way, you can optimize the load between the processors.","Q_Score":3,"Tags":"python,multitasking","A_Id":64653854,"CreationDate":"2020-10-26T05:57:00.000","Title":"Multiprocessing and multithreading in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to push code review +1 using 'on_behalf_of' in the Body long with Label field. but i am getting response code 403, it giving below response message\nResponse:\n'not permitted to modify label \"Code-Review\" on behalf of \"\"\nbelow is my post body\nURL:- 'http:\/\/\/base-url\/changes\/\/revisions\/current\/review'\ndata: {'on_behalf_of': 'user-name@mail.com', 'labels': {'Code-Review': 1}}\nUser-name is Service account or faceless ID, I don't have credential of it.\nCan anyone suggest  how to push code-review using Group\/Service-account id? where do we get the permission for this post?\nRegards","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":64537301,"Users Score":0,"Answer":"To isolate all permission issues:\nApart from the command executer is having \"Label Code-Review (On Behalf Of)\" permission, the user in the context of 'on_behalf_of' should have permission to vote for Code-Review.","Q_Score":0,"Tags":"python,rest,gerrit","A_Id":69994840,"CreationDate":"2020-10-26T12:40:00.000","Title":"How to push code-review label on Gerrit onbehalf of other User","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Having learned SQL before learning any Python, I have a fairly lengthy program\/query that I wrote in SQL server which heavily transforms and calculates the data (Basically taking forecast, inventory, and Bill of Materials, and efficiency data and then automatically generating a production plan. While I am sure there are things I could optimize, the query\/program itself is aorund 3,000 lines).\nWhile I have figured out how to update the data in SQL Server using a combination of pandas, pyodbc, and fast_to_sql, I have not been able to find a simple method for running a SQL Server script through Python.\nI am sure that I could achieve the same thing by just having the data manipulation occur in python rather than SQL Server, it would be fairly time intensive to translate everything.\nIf there is anything I can do to clarify please let me know. For reference I am using the 2017 version of Microsoft SQL Server python version 3.8.3.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":255,"Q_Id":64540074,"Users Score":1,"Answer":"Try to combine all of your MSSQL scripts into Stored Procedures and then call it from Python.","Q_Score":1,"Tags":"python,sql,sql-server","A_Id":64540432,"CreationDate":"2020-10-26T15:26:00.000","Title":"How to run a SQL Server Script from Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a game written in Pygame and was trying to debug it. I am new to debuggers so I am not even sure which one to use but I downloaded Pycharm. Anyway, my game starts up and shows the game screen along with a \"Play\" button in the middle of the screen. When you click on the Play button, the Play button is supposed to disappear and three other buttons are supposed to appear so that you can choose your skill level: Easy, Medium and Hard. When you choose your skill level, the game is supposed to begin.\nThe game is beginning when I click the Play button. The other three buttons are not showing. I want to use a debugger to see what is happening in the code when the Play button is clicked.\nThe problem that I am having is that when I try and debug the code, the game starts and takes up the full screen. I cannot see the debugger. When I click the Play button, I get the same bug as already mentioned earlier but I am unable to see the debugger to know what is happening in the code.\nI need some advice. Which of the following paths should I head down?:\nPath A: Try and figure out how to get the game to open in a window different from and next to the debugger window.\nPath B: Try and figure out how to simulate clicking on the Play button, in the debugger, without actually running the game.\nPath C: Follow a different path that I have not even thought of but someone on Stack Overflow is about to explain to me. :)\nPS: I am not asking for help with the code. I can probably figure out the problem without a debugger. I am asking for help with how to use a debugger so that I can debug in the future and not have to ask so many questions.\nclipovich","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":64540462,"Users Score":1,"Answer":"I think path A would be the best. On windows and some linux distros, you can try pressing flag+left or right arrow. Then click the debugger and press flag+left or right arrow (opposite of pygame window side). This will allow you to see both windows at once","Q_Score":1,"Tags":"python,debugging","A_Id":64540730,"CreationDate":"2020-10-26T15:46:00.000","Title":"How do I debug a video game that requires me to play the game in order to re-create the bug?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to merge two data frames using the merge function in pandas. When I want to do so on a common column, jupyter notebook gives me the following error \"The kernel appears to have died. It will restart automatically.\" each data frame is about 50k rows. But when I try the same thing with only 50 rows from each data frame it works fine. I was wondering if anyone has a suggestion.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":699,"Q_Id":64543392,"Users Score":1,"Answer":"This is most likely a ram\/memory issue with your machine. check the ram that you have and monitor it while you do the merge operation.","Q_Score":0,"Tags":"python,pandas,dataframe,merge,jupyter-notebook","A_Id":64544268,"CreationDate":"2020-10-26T18:59:00.000","Title":"Merge two data frames in pandas giving \"The kernel appears to have died. It will restart automatically.\" using Jupyter notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting the following error message while trying to do a pip install pandas:\nERROR: Could not install packages due to an EnvironmentError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '\"C:'\nI've tried all the other solutions I've found but nothing is working for me. Any help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":64543424,"Users Score":0,"Answer":"ryan's computer is actually your user name? This is asking for trouble. Change it, and you'll be able to install any package w\/o any problems.","Q_Score":1,"Tags":"python,pandas","A_Id":64544505,"CreationDate":"2020-10-26T19:02:00.000","Title":"EnvironmentError: [WinError 123] during pandas installation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"So I'm trying to do the following:\nself.cashflows[\"Balance\"] * self.assumptions[\"Default Rates\"][current_period - 1]\nwhere cashflows is a list with python floats and assumptions is a list with numpy floats.\nI used numpy to fill the assumption vector and I am getting the following error when I try to multiply the two:\ncan't multiply sequence by non-int of type 'numpy.float64\nI get the error but what would be my best course of action here?\nthx","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":505,"Q_Id":64543865,"Users Score":1,"Answer":"Depends on what you want to do. Do you want to multiply every item in the list self.cashflow[\"Balance\"] with self.assumptions[\"Default Rates\"][current_period - 1]? Then you can use some list comprehension:\nresult = [q * self.assumptions[\"Default Rates\"][current_period - 1] for q in self.cashflow[\"Balance\"]]\nor convert your second argument to np.float:\nresult = self.assumptions[\"Default Rates\"][current_period - 1]* np.asarray(self.cashflow[\"Balance\"])\nOtherwise, multiplying a whole list by N repeats that list N times. If thats what you want, cast your np.float64 to int.\nEDIT: Added missing multiplication sign","Q_Score":0,"Tags":"python,numpy","A_Id":64544038,"CreationDate":"2020-10-26T19:36:00.000","Title":"python multiplying python float with numpy float","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"how can we extract massively huge data from zipped json file on s3 bucket?\nGiven a zipped json file in s3 bucket.\nneed to extract the file and unzip it","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":93,"Q_Id":64543974,"Users Score":2,"Answer":"As the file(s) is (are) on S3, your only option is to copy the file(s) to a filesystem, then unzip the file(s).\nS3 is an object store, and it's not possible to directly unzip files directly in that location.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda,bucket","A_Id":64544105,"CreationDate":"2020-10-26T19:44:00.000","Title":"how can we extract massively huge data from zipped json file on s3 bucket?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Pandas. I try to find a way to iterate over two columns (output from value_counts method). For the last hour I copy the values separately from the output which is of course pretty time consuming. I thought maybe Stackoverflow has a hint for me. Thanks.\nBachelor\u2019s degree (B.A., B.S., B.Eng., etc.)--5786\nMaster\u2019s degree (M.A., M.S., M.Eng., MBA, etc.) --1980\nSome college\/university study without earning a degree -- 1219\nAssociate degree (A.A., A.S., etc.)  -- 497\nOther doctoral degree (Ph.D., Ed.D., etc.) -- 389\nSecondary school (e.g. American high school, German Realschule or Gymnasium, etc.) --    269\nProfessional degree (JD, MD, etc.)   -- 54\nI never completed any formal education  -- 49\nPrimary\/elementary school  -- 41","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":58,"Q_Id":64544058,"Users Score":-1,"Answer":"Try putting it back into a dataframe","Q_Score":0,"Tags":"python,pandas","A_Id":64544706,"CreationDate":"2020-10-26T19:50:00.000","Title":"How can I iterate over value_counts output that consist of two columns?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm teaching a discrete math course in which I've incorporated a programming component.  We have been using Python Notebooks through Jupyter.\nWe're coming up on a section in probability theory, and I would like to provide them with a \"mystery random variable:\" I want students to be able to sample the random variable without knowing how it is defined.\nI don't know the best way to implement this, and was hoping someone could provide a suggestion.  Here are the features that I want:\n\nI define one or several random variables (preferably in Python),\nThe students should be able to sample from the random variable in a Python notebook (so they can do experimentation with it), but\nthe students should not be able to see the code that defines the random variable.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":239,"Q_Id":64545044,"Users Score":0,"Answer":"If this system support modules, you could define a function returning several random values (for instance giving an index) or several functions returning each a random value and put these functions in one module that your students don't have access to. They could import the .pyc module and use it but not seen the codes inside it.","Q_Score":2,"Tags":"python,random,jupyter-notebook,source-code-protection","A_Id":64545507,"CreationDate":"2020-10-26T21:12:00.000","Title":"How to provide students with a mystery function in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to programming and am trying to install virtualenv to set up my Python packages properly in one. I can see Python39\\scripts is in my path, but cmd still says pip is not recognized.\nAs far as I can see I do not have any copies of Python installed, and have only moved the main file from appdata into a document folder titled Programming Languages for convenience. Any help or tips on this subject would be appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":64546546,"Users Score":0,"Answer":"You have to recongiure the PATH because you moved it from appdata, and when you type pip it is looking for Python39\\scripts in appdata. You have to paste the full new path in PATH in order for it to work.","Q_Score":0,"Tags":"python,windows,path,pip,virtualenv","A_Id":64546589,"CreationDate":"2020-10-26T23:54:00.000","Title":"Trying to Make a Virtualenv on Windows 8 for Python but 'pip' is Not Recognized","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"\"abcde\"[0:5:1] gives abcde. So I expected \"abcde\"[4:-1:-1] to return edcba but it gives nothing.\nIs there no way to get same result as \"abcde\"[4::-1] while explicitly giving middle parameter?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":64547983,"Users Score":0,"Answer":"Python list syntax is:\n\nlist[start:stop:step]\n\nIn the first example: start=0, stop=5, step=1. This is equivalent to the C style for loop:\n\nfor (i=0; i<5; i++)\n\nIn your second example, start=4, stop=-1=4, step = -1. This is equivalent to the C style for loop:\n\nfor (i=4; i>4; i--)\n\nSince the start and stop conditions are the same, your result is empty.\nSince -1 is a negative number, which as a start\/stop is a special case in python list slicing that means \"len(list)-1\", you can't actually do the operation you want:\n\nfor (i=4; i>-1; i--)\n\nSo instead your best bet is \"abcde\"[::-1] which will correctly infer the end, and the start, from the direction.","Q_Score":1,"Tags":"python,slice","A_Id":64548047,"CreationDate":"2020-10-27T03:36:00.000","Title":"Why does slicing in python stop at -1?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to train mymodel from anaconda virtual environment.I installed all the packages required. I tried to run the command tox from the folder where there are 3 files. requirements.txt which includes the numpy,pandas librarieswith versions,tox, and  regression model. But I am getting the error ,python.exe not found in venv. But anaconda comes with python. How to correct this error?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":258,"Q_Id":64554121,"Users Score":1,"Answer":"Open anaconda prompt in virtual environment. Install tox-conda with\npip install tox-conda.\nAfter installing go to the folder where you have all these files. Now execute the tox command or tox -r It will take sometime when you run for the first time.","Q_Score":1,"Tags":"python-3.x,tox,anaconda3","A_Id":64555749,"CreationDate":"2020-10-27T12:06:00.000","Title":"Executing tox in anaconda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to get text features for stylometry task in identifying the author of the given text.\nI check for :\n\ntext length by word\ntext length by character\npunctuation count\nunique word count\netc...\nbut in classifying this feature give unreasonable results, so:\ni want to check more features...\nI have two questions:\n\n\nIs there any good feature that I forget to extract from text to help classifying result\nI have a data frame like this:\ntext ,                  author ,    pos\ni go to school   ,        x  ,       [N,V,...]\n..\nwe are good   ,     y      ,    [N,V,ADj]\n\nmy question is that how can I get good feature from pos column? for example the ratio of \"N\" to other? or some thing like this...\nhow to improve this multi_input single_lable multi_class classification result? with which feature? is there any good source?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":62,"Q_Id":64554731,"Users Score":1,"Answer":"Many studies have shown that the frequency and distribution of FUNCTION WORDS is significant and indicative of individual style. FUNCTION WORDS are those with little or no LEXICAL MEANING: articles THE, AN, A, conjunctions, personal pronouns, auxiliary verbs. etc.","Q_Score":0,"Tags":"python,nlp,multiclass-classification","A_Id":64562422,"CreationDate":"2020-10-27T12:45:00.000","Title":"how to get stylometric feature from text( for task of author attribution)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to install PyQt pip install pyqt5, and it fails at the very end:\nERROR: Could not install packages due to an EnvironmentError: [WinError 2] Cannot find file: 'C:\\\\Python38\\\\Scripts\\\\pylupdate5.exe' -> 'C:\\\\Python38\\\\Scripts\\\\pylupdate5.exe.deleteme'\nAny ideas? PyQt documentation says nothing about this error, this one command should install it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":572,"Q_Id":64555127,"Users Score":1,"Answer":"Must be the anti-virus or firewall. Disable it and try again.","Q_Score":3,"Tags":"python,pip","A_Id":64555361,"CreationDate":"2020-10-27T13:07:00.000","Title":"Unable to install python packages due to enviroment error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using pytesseract to create searchable pdfs. Since it is important to keep the original look of the images, I want to create the PDF using the original image. However, to improve the OCR result I need to apply some preprocess to the images (deskew, binarization, etc..).\nhere is how I get a pdf using the processed image.\npdf = pytesseract.image_to_pdf_or_hocr(adaptive_threshold, lang=\"frk+deu\", config=config)\nSo, how could I apply an alto_xml output, for exemple:\nalto= pytesseract.image_to_alto_xml(adaptive_threshold, lang=\"frk+deu\", config=config)\nto the original image and convert it to pdf? Like:\noriginal_image + alto -> convert to a searchable pdf.\nThank you!","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":473,"Q_Id":64555910,"Users Score":-1,"Answer":"There could not be a way to this directly in pyhton because pytesseract is just a python wrapper for the command line version of Tesseract OCR","Q_Score":0,"Tags":"python,opencv,image-processing,ocr,tesseract","A_Id":64823105,"CreationDate":"2020-10-27T13:49:00.000","Title":"How to add results from pytesseract alto_xml to the original image","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an imblearn (not sklearn) pipeline consisting of the following steps:\n\nColumn selector\nPreprocessing pipeline (ColumnTransformer with OneHotEncoders and CountVectorizers on different columns)\nimblearn's SMOTE\nXGBClassifier\n\nI have a tabular dataset and I'm trying to explain my predictions.\nI managed to work out feature importance plots with some work, but can't get either\neli5 or lime to work.\nLime requires that I transform the data to the state of before the last transformation (because the transformers in the Pipeline like custom vectorizers create new columns).\nIn principle, I can slice my Pipeline like this: pipeline[:-1].predict(instance). However, I get the following error: {AttributeError}'SMOTE' object has no attribute 'predict'.\nI also tried an eli5 explainer, since it supposedly works with Sklearn Pipelines.\nHowever, after running eli5.sklearn.explain_prediction.explain_prediction_sklearn_not_supported(pipeline, instance_to_explain) I get the message that the classifier is not supported.\nWill appreciate any ideas on how to proceed with this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":397,"Q_Id":64558402,"Users Score":1,"Answer":"Imblearn's samplers are effectively no-op (ie. identity) transformers during prediction. Therefore, it should be safe to delete them after the pipeline has been fitted.\nTry the following workflow:\n\nConstruct an Imblearn pipeline, and fit it.\nExtract the steps of the fitted Imblearn pipeline to a new Scikit-Learn pipeline.\nDelete the SMOTE step.\nExplain your predictions using standard Scikit-Learn pipeline explanation tools.","Q_Score":0,"Tags":"python,machine-learning,imblearn,smote","A_Id":64559304,"CreationDate":"2020-10-27T16:06:00.000","Title":"How can I explain predictions of an imblearn pipeline?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"my question is rather simple: if I have a code that has a for cycle that iterates 150 times. Is it faster to split this into 3 files where each for cycle iterates 50 times? If so do I run the 3 codes at the same time or one at a time?\nAnother option could be to use python multiprocessing in these 3 files, but the same question arises, do I run them all at once or one at a time?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":64559796,"Users Score":1,"Answer":"TL;DR - It depends.\nIn cpython, the Global Interpreter Lock (GIL) ensures that only 1 thread in a given process can run python code at a time. If your loop is CPU bound, adding threads in a single process doesn't speed it up. If your loop sleeps for some reason like reading data from disk, threads can speed it up. Using multiprocessing, since the GIL is per-process, you may speed up processing.\nThere is overhead to multithreading and multiprocessing, including the cost of starting the thread \/ process, getting data to the thread \/ process and returning the result. Depending on what you are doing, this may be more expensive than the loop itself.\nSo, there is no general answer to this question. It is highly task dependent.","Q_Score":0,"Tags":"python,multiprocessing","A_Id":64559929,"CreationDate":"2020-10-27T17:27:00.000","Title":"Is running multiple codes faster than running just one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a django app which is based on consuming an external ZeroMQ message queue - it listens to the queue all the time, processing the messages and saving the outcome in the database. The data will be in the future made accessible to the users by API.\nCurrently I'm running it by a custom management command listen, which runs an infinite loop and it works fine. However, whenever some kind of error appears (and they will sometimes appear, it's an external data source) the command dies.\nWhat's the best approach to handle such errors? Things I'm considering:\n\nBash script which will restart the command on failure\nBig Try... except Exception in the main command function (but this seems extremely wrong)\nSome custom exception handler - the problem is that the recommended handlers only handle errors in views\/requests, and my command is not a view\/request, it just runs.\n\nAny advice would be useful, maybe it's a misuse of the management command?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":223,"Q_Id":64563577,"Users Score":1,"Answer":"I have a command that is a crawler and I am wrapping my handle method's code with a try\/except clause to avoid stopping on errors. But I noticed that when Django triggers a database exception the command will stop, ignoring the try\/except blocks. I didn't find out why yet.\nI think that is the best option for commands that should run \"forever\" (on run for a long period of time).","Q_Score":1,"Tags":"python,django,exception,message-queue,django-management-command","A_Id":68999029,"CreationDate":"2020-10-27T22:08:00.000","Title":"How to handle management command exception in django app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In my django app I have a main page which shows the numbers of books for each genre in a table and it also has a search bar that allows filtering of the books by Genre, title or author which then posts the data to a search page and allows viewing of the book entries in a table.\nOn the search results page I want to then be able to additionally filter the same set of data further using an extended set of search bars - including the original filters, plus filters such as publish date and rating.\nIn the extended search I would not want to lose the original search - so for example if I search for horror genre on the main page and then wish to filter that further to only include highly rated books on the sesrch page I dont want to lose the horror filter if I don't add the filter again.\nIs this possible? Essentially I'm wondering if you can apply different filters to a single view?\nThank you in advance","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":64563760,"Users Score":0,"Answer":"I'm not sure if you want the select of genres in the extended filter, or not?\nBecause if yes, I don't see the problem...?\nIf not, why not use a hidden input to pass genre along?\nforms.CharField(widget=forms.HiddenInput())","Q_Score":0,"Tags":"python,django","A_Id":64563965,"CreationDate":"2020-10-27T22:26:00.000","Title":"Djangon 2.2 filtering a single data set across pages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Have not found anyone complaining about this yet, but:\nHave a flask app, normal static folder with js, css, and and image folder under it.\nThe css, js go to the web page normally from the static folder, but the images:\nsky1.jpg    works.\nsky_1.jpg  does not work. Get a 404 in chrome.\nworks:\nimg class=\"img-thumbnail\" src=\"{{ url_for('static', filename='imagesUI\/sky1.jpg') }}\"\ndoes not work:\nimg class=\"img-thumbnail\" src=\"{{ url_for('static', filename='imagesUI\/sky_1.jpg') }}\"\nIs there a file naming convention in flask that precludes any other character than alphabetic and numeric?\nI want to put date info in the filename and it is not allowing it.\nubuntu 18.04\ndebugging under VSC\nflask dev server\nDebug on\nThx","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":64565115,"Users Score":0,"Answer":"Instead of src=\"{{ url_for('static', filename='imagesUI\/sky_1.jpg') }}\nuse src='\/static\/imagesUI\/sky_1.jpg'","Q_Score":0,"Tags":"html,python-3.x,flask","A_Id":64567973,"CreationDate":"2020-10-28T01:15:00.000","Title":"flask static image filenames with non-alphabet characters not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Have not found anyone complaining about this yet, but:\nHave a flask app, normal static folder with js, css, and and image folder under it.\nThe css, js go to the web page normally from the static folder, but the images:\nsky1.jpg    works.\nsky_1.jpg  does not work. Get a 404 in chrome.\nworks:\nimg class=\"img-thumbnail\" src=\"{{ url_for('static', filename='imagesUI\/sky1.jpg') }}\"\ndoes not work:\nimg class=\"img-thumbnail\" src=\"{{ url_for('static', filename='imagesUI\/sky_1.jpg') }}\"\nIs there a file naming convention in flask that precludes any other character than alphabetic and numeric?\nI want to put date info in the filename and it is not allowing it.\nubuntu 18.04\ndebugging under VSC\nflask dev server\nDebug on\nThx","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":64565115,"Users Score":0,"Answer":"use src='\/static\/imagesUI\/sky_1.jpg' in img tag that might do it","Q_Score":0,"Tags":"html,python-3.x,flask","A_Id":64567989,"CreationDate":"2020-10-28T01:15:00.000","Title":"flask static image filenames with non-alphabet characters not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Kind of a noob question. Sorry for that.\nI have a string path\nW:\\documents\\files\nIs it possible to create an hyperlink from that and store it in a csv so that when a click it in Excel it opens the file ?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":477,"Q_Id":64565508,"Users Score":0,"Answer":"I don't know exactly what you said.\nI think  maybe you want to write hyperlink path in csv.\nThat is just use \"\".\nlike this.\nfunction(\"W:\\documents\\files\")","Q_Score":0,"Tags":"python,csv,hyperlink","A_Id":64565598,"CreationDate":"2020-10-28T02:08:00.000","Title":"Create hyperlink from path in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using python 3.7.4.\nI can't figure out why\n2 > 3 > -1 == False\nwhile\n(2 > 3) > -1 == True\nand\n2 > (3 > -1) == True\n??","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":64568911,"Users Score":0,"Answer":"This is related to chaining comparison a op b op c is equivalent to (a op b) and (b op c)\n\n2 > 3 > -1 --> (2 > 3) and (3 > -1) which results in False and True which gives False\n(2 > 3) > -1 --> Python will compute the brackets first (2 > 3) = 0 or False then (0 > -1) = True or 1\n2 > (3 > -1) --> (3 > -1) = True or 1 then (2 > 1) = True or 1","Q_Score":0,"Tags":"python,python-3.x","A_Id":64569089,"CreationDate":"2020-10-28T08:20:00.000","Title":"Expression valued differently and unexpectedly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Keras from tensorflow 2.2.0. I have a model with several UpSampling2D layers with bilinear interpolations. When trying to convert the model using CoreML 4.0, I get the following error:\n\nValueError: \"ResizeBilinear\" op: the second input, which is the output size, must have elements of type int32\n\nWhen the UpSampling2D interpolation is nearest the export works. Still I want the interpolation to be 'bilinear'\nIs there a fix for this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":64569649,"Users Score":0,"Answer":"Looks like a bug in coremltools. In situations like these, I would (temporarily) change the model to use \"nearest\" just so that you can do the conversion, then patch up the mlmodel file afterwards to change the type of this layer to \"bilinear\". You can do this with coremltools and the protobuf API (see my book).","Q_Score":0,"Tags":"python,tensorflow,keras,coreml","A_Id":64571057,"CreationDate":"2020-10-28T09:10:00.000","Title":"ValueError: \"ResizeBilinear\" op: the second input, which is the output size, must have elements of type int32","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a 2 files that I want to put in a .exe file.\nOne of those files is a .py and another is a .txt\nI couldn't find how to take more than one file and turn it into an executable.\nPlease help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":263,"Q_Id":64570098,"Users Score":2,"Answer":"You should put the .txt file in a folder and then put the name of the folder in the < folder > tags:\npyinstaller --onefile --windowed --add-data \"<folder>;<folder>\" <filename.py>","Q_Score":2,"Tags":"python,pyinstaller,executable","A_Id":64570444,"CreationDate":"2020-10-28T09:38:00.000","Title":"Encapsulate .py and .txt file into .exe file using PyInstaller","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"According to this page running print \"Hello\\fworld\"  should give hello and page printed on different lines and with different indentations (something of a page break which is the purpose of the form feed character). However when I do print(\"Hello\\fworld\") in Python 3, what I get is the female sign: Hello\u2640world, which is what I also get when I run print(u\"Hello\\u2640world\"). How is that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":188,"Q_Id":64570229,"Users Score":0,"Answer":"Windows console and IDLE or whatever stdout you are using dosen't support form feed characters, so you can't print them to stdout.","Q_Score":0,"Tags":"python,python-3.x,printing,ascii,page-break","A_Id":64570290,"CreationDate":"2020-10-28T09:46:00.000","Title":"Printing form feed character in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"!cat datasets\/Admission_Predict.csv\nERROR:\n'cat' is not recognized as an internal or external command,\noperable program or batch file.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":64571305,"Users Score":0,"Answer":"Try !more datasets\/Admission_Predict.csv","Q_Score":0,"Tags":"python,pandas","A_Id":64571541,"CreationDate":"2020-10-28T10:51:00.000","Title":"How to resolve the error of this Shell Commands in JupyterNotebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I run several Google Colab Notebooks (runtimes) at the same time, is the perfomance shared?\nI have a big dataframe to operate on so I decided to split it and let the code run on each part on a different notebook. However it seems to take as long as it would take on the whole thing in one.\nIs there any information on that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":960,"Q_Id":64573058,"Users Score":0,"Answer":"Each Colab notebook uses a distinct virtual machine backend in order to perform computations. From a performance perspective, each notebook will be isolated from the activity of distinct notebooks.\nIn order to offer more useful guidance, please share a self-contained example that shows, with code, what you are doing and the performance bottleneck you observe.","Q_Score":1,"Tags":"python,jupyter-notebook,google-colaboratory","A_Id":64575813,"CreationDate":"2020-10-28T12:39:00.000","Title":"Running several Google Colab Notebooks at the same time","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"I have a dataset with a lot of fields, so I don't want to load all of it into a pd.DataFrame, but just the basic ones.\nSometimes, I would like to do some filtering upon loading and I would like to apply the filter via the query or eval methods, which means that I need a query string in the form of, i.e. \"PROBABILITY > 10 and DISTANCE <= 50\", but these columns need to be loaded in the dataframe.\nIs is possible to extract the column names from the query string in order to load them from the dataset?\nI know some magic using regex is possible, but I'm sure that it would break sooner or later, as the conditions get complicated.\nSo, I'm asking if there is a native pandas way to extract the column names from the query string.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":64576913,"Users Score":0,"Answer":"I think you can use when you load your dataframe the term use cols I use it when I load a csv I dont know that is possible when you use a SQL or other format.\nColumns_to use=['Column1','Column3']\npd.read_csv(use_cols=Columns_to_use,...)\nThank you","Q_Score":0,"Tags":"python,pandas,string,extract","A_Id":64577103,"CreationDate":"2020-10-28T16:13:00.000","Title":"Extract pandas dataframe column names from query string","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working in a gradient notebook in Paperspace. I am using the PETS dataset in the fastai library to save and deploy the Classifying breeds. When I use the learn.export() command, I am getting the error OSError: [Errno 30] Read-only file system: \u2018\/storage\/data\/oxford-iiit-pet\/export.pkl\u2019.\nI read some of the problems of the same topics in the forum, but still, I have a problem.\nAny advice is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":64577088,"Users Score":0,"Answer":"I would guess the file system is read-only ?\nMaybe you opened the file as read and not write. Would be my only guess other than that it is read-only","Q_Score":0,"Tags":"python,deployment,deep-learning,dataset,fast-ai","A_Id":64577205,"CreationDate":"2020-10-28T16:23:00.000","Title":"OSError: [Errno 30] Read-only file system: \u2018\/storage\/data\/oxford-iiit-pet\/export.pkl\u2019 (using fastai library)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created an exe file using PyInstaller and it works on my PC with Windows 8.1 and laptop with Windows 10, but on computers with Windows 7 it has error\n\"error loading python37 dll \"\nand something about dynamic linked libraries.\nEDIT:\nError loading Python DLL 'C:\\Users\\Dell\\Appdata\\Local|Temp|_MEI16442\\python37.dll'. LoadLibrary: Procedure of initialize dynamic linked library (DLL) failed.\nIt is translated from Polish\nDo you know maybe how can I fix it?\nI was reading about static linked dll but I dont know how to do it. I am working on Windows only, I dont know Linux\/Mac.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2389,"Q_Id":64580820,"Users Score":0,"Answer":"I had this same issue while compiling the executable with a Pyinstaller command. To fix it, I added the --noupx option and everything worked fine.","Q_Score":2,"Tags":"python,dll,static,pyinstaller","A_Id":67610907,"CreationDate":"2020-10-28T20:28:00.000","Title":"Error loading python37 dll on Windows 7 after Pyinstaller created exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I created an exe file using PyInstaller and it works on my PC with Windows 8.1 and laptop with Windows 10, but on computers with Windows 7 it has error\n\"error loading python37 dll \"\nand something about dynamic linked libraries.\nEDIT:\nError loading Python DLL 'C:\\Users\\Dell\\Appdata\\Local|Temp|_MEI16442\\python37.dll'. LoadLibrary: Procedure of initialize dynamic linked library (DLL) failed.\nIt is translated from Polish\nDo you know maybe how can I fix it?\nI was reading about static linked dll but I dont know how to do it. I am working on Windows only, I dont know Linux\/Mac.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2389,"Q_Id":64580820,"Users Score":0,"Answer":"This used to happen to me all the time, and it was always because I tried to run the executable file from the build folder while the one that works is in the dist folder.","Q_Score":2,"Tags":"python,dll,static,pyinstaller","A_Id":64581007,"CreationDate":"2020-10-28T20:28:00.000","Title":"Error loading python37 dll on Windows 7 after Pyinstaller created exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been trying to wrap my head around pyarrow for a while, reading their documentation but I still feel like I have not been able to grasp it in it's entirety. I saw their depcrecated method of serialization for arbitrary python objects, but since it's deprecated I was wondering what the correct way is to save for example a list of objects or an arbitrary python object in general?\nWhen do you want to bother using pyarrow as well?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":505,"Q_Id":64583567,"Users Score":0,"Answer":"PyArrow is python binding for (Apache) Arrow.  Arrow is a cross-language specification that describes how to store columnar data in memory.  It serves as the internals of data processing applications & libraries, allowing them to efficiently work with large tabular datasets.\nWhen do you want to bother using pyarrow as well?\nOne simple use case for PyArrow is to convert between Pandas\/Numpy\/dict and the Parquet file format.  So for example, if you had columnar data (eg DataFrames) that you need to share between programs written in different languages, or even programs using different versions of python, a nice way to do this is to save your Pandas\/Numpy\/dict to a Parquet file (serialisation).  This is a much more portable format that, for example, pickle.    It also allows you to embed custom metadata in a portable fashion.","Q_Score":2,"Tags":"python,python-3.x,serialization,pyarrow","A_Id":64672270,"CreationDate":"2020-10-29T01:16:00.000","Title":"pyarrow saving python objects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a producer that sends messages in the form of a list of dictionaries. The consumer reads messages but I am not able to fetch the messages that arrive in the last 'n' minutes. Any help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":64586038,"Users Score":0,"Answer":"There is provision to rewind particular timestamp. In order to do that you need to manually assign partitions for topic in the consumer and then use seek method.","Q_Score":0,"Tags":"python,apache-kafka,kafka-python","A_Id":65124161,"CreationDate":"2020-10-29T06:27:00.000","Title":"How do I get the data(messags) coming in the last 'n' mins on the consumer side for Kafka-python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python What does it mean if the name of the list is used follwoed by an if clause\ne.g. in the code that I am looking at\nif listname: listname.pop()\nhere what does if listname do?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":64588572,"Users Score":0,"Answer":"This is simply checking is list is not empty (listname should refer only to the name) and then if it is not empty, it pop's the last element from it.","Q_Score":0,"Tags":"python","A_Id":64588593,"CreationDate":"2020-10-29T09:47:00.000","Title":"What does the use of a list name with an if clause mean in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got this code which does something with the first 10 charakters of a string:\nf_binary = f.encode(encoding='utf_8')[0:10]\nbut I want to do it with the 19th charakter as well.  I tried like this:\nf_binary = f.encode(encoding='utf_8')[0:10],[19]\nand this:\nf_binary = f.encode(encoding='utf_8')[0:10,19] but it doesn't work.\nPython's list comprehension doesn't help me either because it doesn't show how to deal with a larger and a small part of a list or string at the same time.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":64589104,"Users Score":0,"Answer":"turn it to a string and then select using\nfirst_n_chars_and_last = (f[0:n], f[-1])\nand turn it THEN into a bytes object","Q_Score":0,"Tags":"python,string,slice,encode","A_Id":64589211,"CreationDate":"2020-10-29T10:18:00.000","Title":"How to get first n charakters of a string AND the last one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to programmatically add a header to an already existing CSV file using Python. The problem is that I do not want to overwrite the first row of the file, I would like to push all data downwards by one row and add the header on the first row without overwriting anything. Can this be done? Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":64589190,"Users Score":1,"Answer":"Is not possible to add data at the beginning of a file, you can only replace content or add data at the end of a file.\nThe solution would be to write a new file with your header and all the content of your original file.","Q_Score":0,"Tags":"python,csv","A_Id":64589258,"CreationDate":"2020-10-29T10:24:00.000","Title":"Add Header to CSV file using Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two meshes (call them A and B) which I am interacting within python using the open3d library (happy to use import trimesh or something else if it works better). Mesh A is a curved structure and mesh B approximates to a flatter surface.\nI need to rotate the meshes so that the surface I am interested in is facing the camera.\nTo identify the surfaces that I need I have written functions to turn the meshes into point clouds and create the best fit sphere for mesh A and a best-fit plane for mesh B. These work really well and match the objects nicely.\nI need to rotate the meshes and have gotten stuck with how to perform the rotation.\nThe input data that I have:\nfor mesh A:\ncentroid of mesh A coords and coords of its best fit sphere (+ its radius) - I want to rotate the mesh so that is perpendicular to the vector described by the above data?\nfor mesh B:\ncentroid of mesh B coords and vector of the normal of the best fit plane - I want to rotate the mesh so that is perpendicular to the vector described by the above data","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1934,"Q_Id":64590271,"Users Score":0,"Answer":"I don't know that library, but maybe you could try to rotate your objects throughout Affine2D() class, of Matplotlib.\nSpecifically, try with this function:\nmtransforms.Affine2D().rotate()\nFirst, you will have to import it: matplotlib.transforms as mtransforms","Q_Score":0,"Tags":"python,open3d,trimesh","A_Id":64590392,"CreationDate":"2020-10-29T11:31:00.000","Title":"rotate a mesh in python to be parallel to a vector","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm deleting an object of a model using DeleteView and redirecting to homePage after successful deletion, works fine. But the problem is when I try to get back to the previous page after deletion(using the left arrow button in the browser). I get \"page not found\" error which makes total sense because I'm trying to get back to the deletion page of an object which no longer exist. How do I prevent this from happening?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":64591584,"Users Score":0,"Answer":"If you are using class-based (generic) views to delete, you can use reverse_lazy to redirect after delete. In case you are using functional views, you can redirect after the successful deletion of the object from the Database.","Q_Score":0,"Tags":"python,django,web","A_Id":64599984,"CreationDate":"2020-10-29T12:58:00.000","Title":"Getting \"page not found\" error while trying to go back to the previous page after successful deletion using DeleteView in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am currently working on my master thesis. My topic is the development of a duplicate checking system in ABAP for a customer in the SAP environment. Up to now, the whole thing works in such a way that if the checking system does not know exactly whether an incoming data record is a duplicate or not, a clerk intervenes and makes the final decision. The clerk is to be \"replaced by a machine learning model\", which is to be located on a Python server, so that the clerk intervenes less in the process and becomes more and more of an \"AI trainer\". The communication between the duplicate checking system and the ML model is done by a REST API. The ML-model should decide whether incoming data records are duplicates or not.\nMy first problem is that I don't have any training data to create an ML model. The second problem is that I still do not know exactly what my training data might look like from the structure. It is possible to get client data records from the client, but for various reasons this is quite unlikely. Is there a way to generate \"synthetic data\" to create an ML model? What could it look like for my application? Which tools could I use to make my work a little easier?\nMany greetings","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":111,"Q_Id":64593429,"Users Score":2,"Answer":"You can't.\nWhen you don't have any real-world data and how humans classified it, then you can not train a ML system to classify real-world data.\nWhat you can do is train a system with data you generated and classified in a way you believe to be similar to what the program might encounter in the wild. This would allow you to try your methodology and see if it works at all. But if you want to create an ML model which is actually useful in the real world, you need to repeat the training process with real-world data.","Q_Score":0,"Tags":"python,machine-learning,duplicates,abap","A_Id":64595482,"CreationDate":"2020-10-29T14:45:00.000","Title":"How to train a ML Model for detecting duplicates without having data sets","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to figure out what is the best way for logging in a multiservice environment in python.\nI am using the python logging package and use the FileRotateHandler. I am holding a folder that rotated every day at midnight (log -> log_date). The problem here is race conditions, many processes are trying to rotate the folder at the same time so I must use a lock that hurts the performance.\nI was thinking about using MongoDB for logging.\ncan you suggest a better way for the logging?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":64594003,"Users Score":0,"Answer":"Rotate files, not directories. In Unix-derived operating systems log rotation using files is guaranteed to not lose data and not block.\nOnce the files are rotated, the old file can be moved to a different place including a directory structure you like.","Q_Score":0,"Tags":"python,mongodb,logging,multiprocessing","A_Id":64601068,"CreationDate":"2020-10-29T15:14:00.000","Title":"What is the best practice for using logs in a multi-services system in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using Spyder as my Python IDE instead of Pycharm. Its editor provides predictions quite fast but it needs at least 3 characters for them to be shown.\nCan I change this? My problem is I have similar variables with long names, so having faster completions would be great.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":64,"Q_Id":64595215,"Users Score":1,"Answer":"(Spyder maintainer here) To decrease or increase the number of characters needed to get completions, please go to the menu:\nTools > Preferences > Completion and linting > Code completion\nand change the number in Show automatic completions after characters entered.","Q_Score":1,"Tags":"python,python-3.x,spyder","A_Id":64598677,"CreationDate":"2020-10-29T16:23:00.000","Title":"Spyder type auto prediction requires 3 characters minimum","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So my issue is that I build ETL pipelines in Airflow, but really develop and test the Extract, Transform and Load functions in Jupyter notebooks first. So I end up copy-pasting back and forth all the time, between my Airflow Python operator code and Jupyter notebooks, pretty inefficient! My gut tells me that all of this can be automated.\nBasically, I would like to write my Extract, Transform and Load functions in Jupyter and have them stay there, while still running the pipeline in Airflow and having the extract, transform and load tasks show up, with retries and all the good stuff that Airflow provides out of the box.\nPapermill is able to parameterize notebooks, but I really can't think of how that would help in my case. Can someone please help me connect the dots?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":2804,"Q_Id":64595804,"Users Score":2,"Answer":"Why do you want the ETL jobs as jupyter notebook. What advantage do you see? The Notebooks are generally meant for building a nice document with live data. The ETL jobs are supposed to be scripts running in the background and automated.\nWhy can't these jobs be plain python code instead of notebook?\nAlso when you run the notebook using PapermillOperator the output of the run will be another notebook saved somewhere. It is not that friendly to keep checking these output files.\nI would recommend writing the ETL job in plain python and run it with PythonOperator. This is much more simpler and easier to maintain.\nIf you want to use the notebook for it's fancy features, that is a different thing.","Q_Score":3,"Tags":"python,jupyter-notebook,airflow,papermill","A_Id":67671965,"CreationDate":"2020-10-29T16:58:00.000","Title":"ETL in Airflow aided by Jupyter Notebooks and Papermill","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using macOS and installed pillow in the terminal with code pip3 install pillow and I got the version 8.0.1.\nBut I cannot import it in Pycharm. I typed from PIL import Image and an error message show ModuleNotFoundError: No module named 'PIL' . then I changed PIL to pillow from pillow import Image, it works but cannot find Image class.\nHow can I fix it?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1599,"Q_Id":64596851,"Users Score":0,"Answer":"Is very likely that your Pycharm has created a virtual environment for the project and is not using the same library as the python on the system.\nIf that is the case, go to Settings > Project > Python Interpreter, press on the plus sign (+), write Pillow on the search bar, select the right package, and add it to your interpreter running on PyCharm.\nI recommend the use of the pipenv tool to manage your project dependencies for each project. It helps you to maintain the project dependencies separated from the system or other projects.","Q_Score":1,"Tags":"python,macos,image,pycharm,python-imaging-library","A_Id":64598599,"CreationDate":"2020-10-29T18:06:00.000","Title":"cannot import Image from PIL in Python 3.8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using macOS and installed pillow in the terminal with code pip3 install pillow and I got the version 8.0.1.\nBut I cannot import it in Pycharm. I typed from PIL import Image and an error message show ModuleNotFoundError: No module named 'PIL' . then I changed PIL to pillow from pillow import Image, it works but cannot find Image class.\nHow can I fix it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1599,"Q_Id":64596851,"Users Score":0,"Answer":"Pillow not pillow.\nrun pip uninstall pillow then run pip install Pillow.","Q_Score":1,"Tags":"python,macos,image,pycharm,python-imaging-library","A_Id":64597028,"CreationDate":"2020-10-29T18:06:00.000","Title":"cannot import Image from PIL in Python 3.8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to create a matrix MxN where every element of the matrix is a list of integers. I need a list so that I can append new elements as I go, therefore a 3D matrix would not work here.\nI'm not sure if what I need here would actually be a list of lists.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":257,"Q_Id":64598762,"Users Score":1,"Answer":"In numpy, you can create a matrix with dtype=object (instead of the usual int or float). This can be used to store empty lists, to which you can then append.","Q_Score":1,"Tags":"python,python-3.x","A_Id":64598957,"CreationDate":"2020-10-29T20:26:00.000","Title":"How to create a matrix of lists?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently am working on a bioinformatics project that currently involves a dictionary corresponding to about 10million unique keys, which each return a subset of categorical strings.\nI currently use unpickle a dictionary object, but my main issue is that unpickling takes a very long time. I also need to iterate through a file, generating a set of keys(~200) for each row, lookup the keys, appending the list to a list-of-lists, and then subsequently flattening the list to generate a counter object of value frequencies for each row, and I have heard that a SQL database like structure would end up trading load times for lookup times.\nThe file that has keys typically contain about 100k rows and so this was my best solution, however it seems like even on faster pcs with increased ram, num of cores, and NVME storage that the time spent on loading the database is extremely slow.\nI was wondering what direction (different database structure, alternatives to pickle such as shelves or mashall, parallelizing the code with multiprocess) would provide an overall speed up (either through faster loading times, faster lookup, or both) to my code?\nSpecifically: Need a create databases of the format key -> (DNA sub-sequence) : value ->[A,B,C,Y,Z] on the order of 1e6\/1e7 entries.\nWhen used, this database is loaded, and then given a query file (1e6 DNA sequences to query), perform a lookup of all the sub sequences in each sequence do the following.\nFor each query:\n\nslice the sequence into subsequences.\nLookup each subsequence and return the list of categoricals for each subsequence\nAggregate lists using collections.Counter\n\nI was wondering how to either:\n\nSpeed up the loading time of the database, either through a better data structure, or some optimization\nGenerally improve the speed of the run itself (querying subsequences)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":64598968,"Users Score":0,"Answer":"I'm not sure there is a right answer here since there are some tradeoff, BUT.\ntwo options come to mind:\n1st. consider using panads.DataFrame for the data-stucture.\nIt will allow serialization\/deserialization to many formats (I believe CSV should be the fastest but would give SQL a try). as for query time, it should be much faster than a dict for the complex queries.\n2nd.\nkey value store, such as MongoDB that has map-reduce and other fancy query capilites, in this case the data is always available without loading times.","Q_Score":1,"Tags":"python-3.x,database,optimization,data-structures","A_Id":64837712,"CreationDate":"2020-10-29T20:43:00.000","Title":"Speeding up python load times for read only dictionary?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm hosting a web server with Django framework .\nThen , I'm using Notepad++ NppFTP to modify and upload those files .\nI can modify the html files and upload to ftp server instantly with Notepad++ NppFTP  .But for updating view.py , I found that even though it says  view.py 100% upload success , the web seems to be unchanged regarding to the new view.py file .\nIs that the way to modify the view.py file different to modifying HTML files ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":64601300,"Users Score":0,"Answer":"You shouldn't have any issues modifying a views.py file.  Check your permissions on the file and double check the directory you're uploading it to.\nIf you're on Linux,  in a terminal type ll (the letter L) and see who owns the file and directory.","Q_Score":0,"Tags":"python,django,server,webserver,notepad++","A_Id":64601343,"CreationDate":"2020-10-30T00:53:00.000","Title":"Unable to make any changes to view.py file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We have a module that help us in reporting taxes. It is currently installed with version number 12.0.2. Now the newest version is 12.0.3. and we are about to update it manually.\nSince we are using on-premise Odoo, my approach is to transfer the files using FTP to our server's custom add-on folder and upgrade it via odoo's apps menu. I did my first attempt update by making a backup of current module's folder and transfer the newest version with the same folder name, but it didn't worked.\nShould i just paste the recent version files to the old folder instead and restart the service\/server? or is there any proper way to update the current module to newest version?\nThank you","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":279,"Q_Id":64601656,"Users Score":2,"Answer":"Try:\n\nselect + delete your module from (apps list) UI\nbackup old module version anywhere\nupload last version\nrestart service odoo\ngo back to apps list with debug mode (update list modules)\nsearch + install your module\n\nwish that help you ;)","Q_Score":2,"Tags":"python,xml,odoo,erp","A_Id":64628651,"CreationDate":"2020-10-30T01:46:00.000","Title":"Update Existing Module To Newest Version in Odoo 12","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We have a module that help us in reporting taxes. It is currently installed with version number 12.0.2. Now the newest version is 12.0.3. and we are about to update it manually.\nSince we are using on-premise Odoo, my approach is to transfer the files using FTP to our server's custom add-on folder and upgrade it via odoo's apps menu. I did my first attempt update by making a backup of current module's folder and transfer the newest version with the same folder name, but it didn't worked.\nShould i just paste the recent version files to the old folder instead and restart the service\/server? or is there any proper way to update the current module to newest version?\nThank you","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":279,"Q_Id":64601656,"Users Score":2,"Answer":"Itss two step process.\n\nUpdate module files in the add-ons folder\nGive Odoo the upgrade command\n\nFrom the Apps\nOr from the command line using -u <module_name>\n\n\n\nYou may need restart the Odoo server.\nIn the Apps Application There is Upgrade Apps list button that may needs pressing.\nIf you have updated module files in the add-ons folder the you need to give the upgrade command to. otherwise unexpected errors may happen. (Odoo loads new code but does not upgrade database and views)","Q_Score":2,"Tags":"python,xml,odoo,erp","A_Id":64604291,"CreationDate":"2020-10-30T01:46:00.000","Title":"Update Existing Module To Newest Version in Odoo 12","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We have a module that help us in reporting taxes. It is currently installed with version number 12.0.2. Now the newest version is 12.0.3. and we are about to update it manually.\nSince we are using on-premise Odoo, my approach is to transfer the files using FTP to our server's custom add-on folder and upgrade it via odoo's apps menu. I did my first attempt update by making a backup of current module's folder and transfer the newest version with the same folder name, but it didn't worked.\nShould i just paste the recent version files to the old folder instead and restart the service\/server? or is there any proper way to update the current module to newest version?\nThank you","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":279,"Q_Id":64601656,"Users Score":2,"Answer":"In case of module updates, don't forget a few points:\n\nyou should use the same folder for your addons upgrades, the best way is to use git or any similar tool\nif your upgrade concerns XML-based stuff, just upgrade the module from Odoo's application list, but if it's code, you must restart Odoo. In rare circumstances, I have even seen older python-compiled files remain in place instead of being replaced. So most of the time I delete them\nif you would like to test the new version before replacing the existing one, don't forget to check the order of the addons folders list: the one containing the new version must be placed before. I know this is obvious but it may happen...","Q_Score":2,"Tags":"python,xml,odoo,erp","A_Id":64660459,"CreationDate":"2020-10-30T01:46:00.000","Title":"Update Existing Module To Newest Version in Odoo 12","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So, I'm in this situation on Odoo v13:\nI have a bunch of portal user, and on some condition I want to add them to an internal group (this group is result of my code, not others). But on adding process, Odoo return an error of: User can have only one user type. And I know that's caused by I want to add a portal user to an internal group.\nMy question is: How can I change an internal group to a portal group with the same access rights and record rules?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":431,"Q_Id":64602772,"Users Score":0,"Answer":"you just add all access rights and record rules to group base.group_portal, that's how it works!","Q_Score":0,"Tags":"python-3.x,security,web,odoo-13,access-rights","A_Id":64797359,"CreationDate":"2020-10-30T04:32:00.000","Title":"How to set group access rights to portal users","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know that I can run a background process in python using subprocess. But the problem is that when I make a gui and then use subprocess with close_fds=True parameter, the window changes to not responding.\nSo, what I want is that I need to create a background process but it should run separately along with the main process and when that process is done, it should again combine with the main process.\nBTW, I am using PySide2 as the gui framework\nAny help would be appreciated","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":64603990,"Users Score":2,"Answer":"I think what would be more beneficial to you would be threading, you are able to start a process in another thread without blocking the main thread which runs your gui. Once the other thread has completed its task it will join the main thread","Q_Score":1,"Tags":"python,python-3.6,pyside2","A_Id":64604025,"CreationDate":"2020-10-30T07:07:00.000","Title":"Run Background Process in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"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":"Hi am trying to calculate a vector of the major axis through a 3d mesh in python (using open3d library to interact with the mesh).\nI have turned the mesh into a pointcloud using a poisson distribution (1000 points in a numpy array) and have thought about using scikit learn and its PCA functionality to try and get the value of this vector.\nFrom googling around I think I'm on the right tract but have little idea about how to use the PCA function to get what I want.\nI think I need to extract the largest eigenvalue from the pointcloud and its accompanying eigenvector - which should hopefully be what I'm looking for.\nHave little idea how to do this as I am completely unfamiliar with scikit learn.\nAny help please?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":666,"Q_Id":64609820,"Users Score":0,"Answer":"Have found a solution using trimesh library:\nused the principal_inertia_vectors function to find the 3 largest eigenvalues and corresponding eigenvectors. The eigen vectors correspond to the 3 axes of the mesh.\nThis functions runs straight off the mesh therefore not requiring conversion to a point cloud.","Q_Score":0,"Tags":"python,scikit-learn,pca","A_Id":64622542,"CreationDate":"2020-10-30T14:00:00.000","Title":"using PCA to find the major axis of a 3d pointcloud of a mesh","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been learning vpython, and I am making a lunar lander copy for a school project. I was wondering if there is any way to embed a vpython canvas or window on a webpage. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":261,"Q_Id":64615705,"Users Score":1,"Answer":"At glowscript.org you can export your program to JavaScript and embed it in a web page. On the page where you edit your GlowScript VPython progrm, click \"Shae or export this program\". However, because at glowscript.org your Python code is transpiled to JavaScript, you can't import arbitrary Python modules.","Q_Score":1,"Tags":"html,embed,vpython","A_Id":64686030,"CreationDate":"2020-10-30T20:59:00.000","Title":"Can I embed a vpython on an html page?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm currently running a script in Jupyter Notebook which loops over a Dataframe and manipulates the data of the current row. As my Dataframe has thousands of rows and each loop takes a while to run, I am wondering whether it's safe to interrupt the script without losing all of my progress?\nI am keeping track of rows that have already been processed so I could just start where I left off in the case that the manipulations on the Dataframe don't get lost. I don't want to take the risk of trying it out right now so advice would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":204,"Q_Id":64615785,"Users Score":0,"Answer":"Unless you are storing progress in external files, interrupting Jupyter will lose you data. I highly do not recommend on counting on the variables inside of Jupyter on being in some state if you are mid-way through a calculation, just save intermediate steps in files to track progress, chunking as you go.","Q_Score":0,"Tags":"python,jupyter-notebook","A_Id":64615840,"CreationDate":"2020-10-30T21:07:00.000","Title":"Will interrupting the script delete the progress in Jupyter Notebook?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to login to site: 'https:\/\/portal.librus.pl\/rodzina\/synergia\/loguj' with requests in python, unfortunately if you inspect and go to network settings it shows main method without 'form data', in addition it has csrftoken placed in script like this:\nscript type=\"text\/javascript\">\nvar csrfTokenName = \"requestkey\";\nvar csrfTokenValue = \"MC44MDU4NjQwMCAxdjA0MDk5NtjdKdm32NdksMkfmuMTU0NzZjMTNi1WE1ZmJdfmUdfOpNIlhMDQx\";\n<\/script\nSo i don't really know how to get the content out of this regard you got hundreds of script tags in html file\nSo the question is how to login to this site?\n(i've watched all tutorials on internet, and non of them work)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":64616982,"Users Score":0,"Answer":"I've found the request inside network tab and this is the things that I saw (I might have missed some information cause I got error for not having account).\n\n\nIn network tab if you try to login with non empty values you will have a POST request with name 'action'.\nInside this request you will find the URL you want \"https:\/\/portal.librus.pl\/rodzina\/login\/action\"\nAnd last part is the form data in the bottom","Q_Score":0,"Tags":"authentication,web-scraping,python-requests,csrf-token","A_Id":64630295,"CreationDate":"2020-10-30T23:30:00.000","Title":"Loging with python without form data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a app written in python\/kivy that i have signed and installed on my android phone. The filemanager , an instance of the MDFileManager opens the root dir (\/) and displays the file system. But i am not able to open any directory in internal or external storage, so that i can select a file. Most of the directories have a small lock icon on them and those dirs wont open. The directories without lock icon do not have any files or the type of files i want. I browsed the directory using a terminal app and found that the ls command on a locked directory returns a permission denied error. This happens only with this app. I am able to open directories and chose files with other 3rd party apps as well as my own app, written in react native. So not sure if this is an issue with MDFIleManager or something else. Any advise\/workaround is highly appreciated","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":90,"Q_Id":64618642,"Users Score":1,"Answer":"Viewing folders without accessing them is most likely due to not setting permissions. Add the following permissions in your manifest according to level of access:\n\nREAD_EXTERNAL_STORAGE\nWRITE_EXTERNAL_STORAGE\nMANAGE_EXTERNAL_STORAGE.","Q_Score":0,"Tags":"python,android,kivy,kivymd","A_Id":64625019,"CreationDate":"2020-10-31T05:12:00.000","Title":"My android app not able to open directories to read files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Let\u2019s say one saves a Tensorflow model created using large data and GPUs. If one wanted to then use the saved model to do a single prediction with one small piece of data, does one still need the huge computers that created the model?\nI\u2019m wondering more generally how the size and computing resources needed to generate a deep learning model relate to using the model to make predictions.\nThis is relevant because if one is using Google Cloud Compute it costs more money if one has to use the huge computers all the time. If one could just use the huge computers to train the model and then more modest ones to run their app that make predictions it would save a lot of money.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":175,"Q_Id":64626121,"Users Score":4,"Answer":"Resources needed for prediction depend on the model size - not on the training device.\nIf the model has 200 bln variables - you will not be able to run it on workstation (because you have not enough memory).\nBut you can use model with 10 mln variables with no problems even if it was trained on GPU or TPU.\nEvery variable takes 4 to 8 bytes. If you have 8 GB of memory - you will probably be able to run a model with hundreds million variables.\nPrediction is fast (assuming you have enough memory). Resources needed to train model quickly. It is efficient to train on GPU\/TPU even if your model is small.","Q_Score":1,"Tags":"python,tensorflow,machine-learning,deep-learning,gpu","A_Id":64626316,"CreationDate":"2020-10-31T20:31:00.000","Title":"Can a Tensorflow saved model created on a large GPU be used to make predictions on a small CPU?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have started learning coding recently... and I often have to import modules like import random, import os, import turtle etc(in python). Why does this process have to me manual? Why aren't all these modules pre imported?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":64626292,"Users Score":0,"Answer":"They aren't all preimported because it would need much memory and it's more efficient if you just load what you really need","Q_Score":1,"Tags":"python-3.x,import,module,automation,manual","A_Id":64838610,"CreationDate":"2020-10-31T20:53:00.000","Title":"Why aren't all modules pre-imported?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"UnsatisfiableError: The following specifications were found\nto be incompatible with the existing python installation in your environment:\nSpecifications:\n\ntensorflow -> python[version='3.5.*|3.6.*|3.7.*']\n\nYour python: python=3.8\n\nIf python is on the left-most side of the chain, that's the version you've asked for.\nWhen python appears to the right, that indicates that the thing on the left is somehow not available for the python version you are constrained to. Note that conda will not change your python version to a different minor version unless you explicitly specify that.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":234,"Q_Id":64629624,"Users Score":-1,"Answer":"open cmd and write  pip install tensorflow\nor in anaconda prompt write conda install tenorflow","Q_Score":0,"Tags":"python","A_Id":64630256,"CreationDate":"2020-11-01T07:32:00.000","Title":"My anaconda version is 1.9.12 and Python is 3.8.3 but when I want to install tensorflow I get a problem","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to do inner anti join in pyspark. For example i have a common key in both df, now what i need is to extract all the row which are not common in both df. That is id of one should not match with id of another.\ndf1=df1.join(df2,how='inner',df1.id !=df2.id) \nBut with this code,I am getting rows those ids are same in both df.\nThanks in advance for help.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1620,"Q_Id":64632926,"Users Score":-1,"Answer":"Spark allows you to handle such use cases in multiple ways\n1. Use except : will return a new DataFrame containing rows in dataFrame1 but not in dataframe2.\ndf1.except(df2)\n2. Use subtract, Return a new DataFrame containing rows in this DataFrame but not in another DataFrame.\ndf1.subtract(df2)\n3. Use exceptAll() : Return a new DataFrame containing rows in this DataFrame but not in another DataFrame while preserving duplicates.\ndf1.exceptAll(df2)\n4. Use left_anti join : Key present which is part of DF1 and as well as DF2, should not be part of the resulted dataset\ndf = df1.join(df2, df1.key == df2.key, \"left_anti\")","Q_Score":1,"Tags":"python-3.x,join,pyspark","A_Id":64639618,"CreationDate":"2020-11-01T14:22:00.000","Title":"Inner anti join in pyspark","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Unfortunately anaconda has been corrupted and I need to uninstall and reinstall anaconda to fix the issue (Anconda navigator application was not opening so i have to uninstall it). I unistalled the anconda. When i have reinstalled it, it didn't installed properly.It is showing error in command prompt when i try to run conda. It is showing error message 'conda is not recognized as internal or external command'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":697,"Q_Id":64633440,"Users Score":3,"Answer":"Simple Answer : Anaconda is not installed proprly due to presence of already present application.\nDetail Answer :I have found the solution to  this. If your anaconda navigator application or other anaconda features has stoped working and you have already uninstalled it to fix it by reinstalling please don't do that you will going to have a lot of difficulty in that, try to fix that only rather than uninstalling and again installing. But if you have already uninstalled it and want to install it again make sure that you manually delete condas aplication which you will find in c->Users->admin->appdata. try to delete all the anaconda aplication by searching it.And again install it. If finds errors after installing also, so you haven't deleted (manually) properly. (there are pip files(aprox 700MB),conda files which you have to delete manually)","Q_Score":2,"Tags":"python,anaconda,data-science,anaconda3","A_Id":64640533,"CreationDate":"2020-11-01T15:13:00.000","Title":"How to uninstall and reinstall anaconda naviator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have both python 32bit and 64bit installed but when I use pip install I'm installing into the 32bit directory. Instead, I want to install to the 64bit directory because I want to access those packages in PyCharm when 64bit python.exe is set as the project interpreter. How can I do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18,"Q_Id":64634805,"Users Score":0,"Answer":"You can explicitly run path\/to\/64bit\/python.exe -m pip install <package>.","Q_Score":0,"Tags":"python,python-3.x,path,pycharm","A_Id":72472884,"CreationDate":"2020-11-01T17:28:00.000","Title":"How to get pip install to install packages into the 64bit version ,not 32bit one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a custom gnu readline completer and I found a strange quirk in handling the minus sign.\nIf my input is 'har' then the completer is called with the text 'har', however if my input is 'hard-r' the completer is called with text 'r'.\nI am wondering what I am doing wrong?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13,"Q_Id":64634839,"Users Score":0,"Answer":"I have to use set_completer_delims() to modify word delimiters.","Q_Score":0,"Tags":"python-3.x,gnu,libreadline","A_Id":64634871,"CreationDate":"2020-11-01T17:33:00.000","Title":"python3 gnu redline minus-sign handling","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've made a python application the relies on a mysql database. Is there anyway I could somehow save the mysql database into a file format along with the code to be distributed to my teacher? He needs to be able to view the code and run it, so I am not able to export it to a .exe file. I'm currently using MYSQL workbench to run my database on mac. Where as my teacher uses a PC and uses Microsoft access\nBasically, I want it where I have a folder that container my program saved as a .py file, and the mysql file in the same folder, and my teacher will simply open my code and run it, and the program fully works and runs with the database fully integrated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":64636787,"Users Score":0,"Answer":"I think you have 2 options.\nOption A would be to export a so called MySQL dump, send it with the files and use Python to import it into the MySQL database. This option requires that your teacher has MySQL installed.\nOption B would be to not use a database application and work with a CSV file instead. With this option you can just send the CSV file with your code. This option obviously requires to change your Python code so it uses the CSV file instead of the database.\nFrom my point of view (I may miss something) you should not have a database installer in your files which installs a DB on your teachers\u2018 computer","Q_Score":0,"Tags":"python,mysql","A_Id":64636924,"CreationDate":"2020-11-01T20:43:00.000","Title":"Saving mysql database in file, to be distributed to teacher along with python application","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For example, if I was to have it search and find a file named ex.exe, it should then prompt whether you'd like to open the file. Thank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":64638512,"Users Score":0,"Answer":"You can import os\nthen with the help of\nos.system(\"pass any windows cmd here\")\nlike regular file search make it happen","Q_Score":0,"Tags":"python,search","A_Id":64638559,"CreationDate":"2020-11-02T00:53:00.000","Title":"Locate & Open File - Using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Bokeh HTML file. I want to load it into a python program and overlay another shape, say a circle on it.\nHow can I do it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":64638518,"Users Score":0,"Answer":"There is not any good way to do this.\nOnce you have exported Bokeh to HTML, it's not in a form that can be further manipulated. If you extract the Bokeh JSON payload in side the HTML you could in principal do \"surgery\" on it to insert new JSON for additional glyphs. But this would be incredibly fragile, highly dependent on matched version and probably hacked object IDs to avoid ID collisions.","Q_Score":0,"Tags":"python-3.x,bokeh","A_Id":64638760,"CreationDate":"2020-11-02T00:54:00.000","Title":"Load from Bokeh HTML file and overlay other shapes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wonder if there's anyways to upload a dataframe and create a new table in Exasol? import_from_pandas assumes the table already exists. Do we need to run a SQL separately to create the table? for other databases, to_sql can just create the table if it doesn't exist.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":301,"Q_Id":64639010,"Users Score":0,"Answer":"Yes, As you mentioned import_from_pandas requires a table. So, you need to create a table before writing to it. You can run a SQL create table ... script by connection.execute before using import_from_pandas. Also to_sql needs a table since based on the documentation it will be translated to a SQL insert command.","Q_Score":0,"Tags":"python,pandas,dataframe,exasolution,exasol","A_Id":64639787,"CreationDate":"2020-11-02T02:16:00.000","Title":"Upload data to Exasol from python Dataframe","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question regarding RMSE and RMSLE:\nto create my model, I first scaled all my feature and target data between 0 and 1 and then converted their distribution to normal distribution using gauss rank scaler.\nafter I fitted a XGBoost model and made prediction on my test sets I used RMSE and RMSLE to evaluate my model.\nmy question is this:\ndo I have to convert my data (both predicted and original target values) back to its original form and then calculate RMSE and RMSLE?\nor the data scaling and converting mentioned above do not affect the RMSE and RMSLE of the model?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":64640258,"Users Score":0,"Answer":"First of all you might not even require to transform the target, depends on use case.\nHowever if you have transformed ( here scaled 0-1), you lose the unit of measurement and then using any evaluation metric for comparison e.g. rmse (or any other in case of regression), it (rmse) here is standard deviation of the residuals calculated on scaled target not on actual values. Thus we must not report this value, however it can be used to comparing across experiments when all experiments uses same underlying data.\nFor example, based on some features you are predicting age ( say, 0 to 125 yrs). If you scaled age and used as target. Resulting rmse would be over (0-1) scaled target not (0-125 yr).","Q_Score":2,"Tags":"python,machine-learning,statistics,regression,xgboost","A_Id":71615084,"CreationDate":"2020-11-02T05:31:00.000","Title":"do scaling data between 0 and 1, and converting their distribution to a normal distribution changes model's RMSLE","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python script running from SSIS package.\nI am running python script in \".bat\" file.\nIf I Execute SSIS package, it is running fine. Same package if I deploy and run\/scheduled run it is failing with below error:\nerror: In Executing \"D:\/SSIS\/PYTHON_SCRIPT\/task.bat \"D:\/SSIS\/PYTHON_SCRIPT\/\". The process exit code was \"1\" while the expected was \"0\"\nAny one have similar issue. Help me to solve this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":193,"Q_Id":64642203,"Users Score":0,"Answer":"Make sure your Python Libraries are correctly configured and check Environment Variables as well","Q_Score":0,"Tags":"python,ssis","A_Id":67786301,"CreationDate":"2020-11-02T08:37:00.000","Title":"Python script not running in SSIS package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I know my question is similar to others out there, but its also kind of not.\nI have python 3.5.2 which is installed under SQL 2017 CU16 Machine Learning Services ( MLS ).\nWhen trying to upgrade scikit-learn from its vendor-installed level of 0.18 up to 0.22 I get the message\n\" It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.\"\nI could just hunt for all instances of scikit-learn in the windows directories and delete them, but I think this is a bad idea, and I have no real concept of how python packages are installed in windows, so I suspect my package is registered somewhere deep inside windows somewhere but I'm not sure where.\nThe problem is our data scientists now want to go up in scikit-learn package values and of course they cant unless I can work out how to cleanly de-install scikit-learn and install a new package using pip.\nI even did a clean install and was running pip 9.x  and tried to remove the package via pip and got this message :\n\"DEPRECATION: Uninstalling a distutils installed project (scikit-learn) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.\nOne option is we have python 3.7.1 recently installed side by side with the existing python 3.5.2 due to applying SQL 2017 CU22, but could have the same issue later when I want to upgrade packages that are installed by the initial install process. This seems to be a  significant shortcoming with SQL 2017 MLS in that youre locked down in terms of what python software you can run, which is not very flexible.\nI'm wondering if there is there a way to stop certain packages being installed as part of  the initial SQL 2017 MLS install process, like scikit-learn, so they can be installed later.\nAny help is greatly appreciated...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":121,"Q_Id":64643494,"Users Score":0,"Answer":"When SQL 2017 MLS does the initial installation, it functions as the package manager. So when Pip comes along and tries to update the distutil packages, the packages dont recognize Pip as having authority to update the packages.\nThis also effectively means that MLS has a hard limitation with any packages that are \"distutils locked\" and these specific packages are 100% non-updatable. This may affect your application if it needs to update these packages.\nPossibly this means a separate non-MS python stack that can be 100% updated would be the go if you need to update any package as required.","Q_Score":1,"Tags":"sql-server,python-3.x","A_Id":65407718,"CreationDate":"2020-11-02T10:11:00.000","Title":"SQL Server 2017 MLS and pip - cannot uninstall : \u201cIt is a distutils installed project\u201d","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a research project where the data is stored in a remote Windows desktop. The desktop does not have Python, it only has Rstudio, but  most of the research conducted in this topic was in Python. I want to benchmark already existing implementations, but I can't run the code on the data because there's no Python and this will not change. As far as I understand, tools like reticulate still need an underlying Python interpreter in the system to work and I am not allowed to do that.\nHas anyone come up with a smart solution that does not involve me manually translating the python code to R? Any R packages that can read python? Any other out-of-the-box ideas on how to get that code to run on the data?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":186,"Q_Id":64645563,"Users Score":0,"Answer":"Say you have (1) the remote Windows Desktop that does not have Python and (2) the local computer you work on.\nUse the remote Windows Desktop (1) as a git repository, clone that repository on your local machine, make changes to it and run locally using Python, then submit the code to the remote repository again.","Q_Score":0,"Tags":"python,r,rstudio,translate","A_Id":68750468,"CreationDate":"2020-11-02T12:23:00.000","Title":"How do I get Python code to run in RStudio? No Python installed in the system","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use pytractor.\nWhen I write import statement from pytractor.webdriver import Firefox\nFirefox is not referenced-not found. Neither Chrome.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":64646287,"Users Score":0,"Answer":"I think this is because, since Python 3.5, async is a protected keyword but is used in the mixins.py script. I renamed the variable and it fixed the problem","Q_Score":0,"Tags":"python-3.x,selenium-webdriver","A_Id":69111208,"CreationDate":"2020-11-02T13:14:00.000","Title":"How to use pytractor with selenium?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that this is probably easy to find, but as someone who just started learning, I'm kind of unsure of how to even ask this question, to be honest. I looked it up on google several times, but I don't think I am phrasing this optimally.\nI want to write an if statement that basically says: if VALUE decreases: do something. Is this the way to go about this? Or should I try to make a list that updates itself with the values and then compare it afterwards?","AnswerCount":2,"Available Count":1,"Score":-0.2913126125,"is_accepted":false,"ViewCount":367,"Q_Id":64647009,"Users Score":-3,"Answer":"If u want it to print something do\nIf (number) <(number) print(\u201ccurrent\u201d)\nOr whatever","Q_Score":0,"Tags":"python","A_Id":64647035,"CreationDate":"2020-11-02T14:02:00.000","Title":"How would I say: \"If VALUE decreases:\" in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ubuntu 20.04 LTS\nConda is my python pkg manager. I have both python 3.8.3 and python 3.6.9 installed in conda. I want to remove both of them and install a newer version, say python3.8.5. How do I do that?\nI have searched the internet but all I got was new installation than removal of old.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":454,"Q_Id":64647164,"Users Score":0,"Answer":"I uses conda prompt to handle python version.\n\nturn your conda prompt and activate your environment(ex) 'activate (YOUR ENVIRONMENT NAME)'\nput 'conda search python' and you'll get versions you can download\nif you checked 3.8.5 there, type 'install conda python=3.8.5'\n\nhope this would help you.","Q_Score":1,"Tags":"python,conda","A_Id":64647462,"CreationDate":"2020-11-02T14:12:00.000","Title":"Conda upgrade python version and remove older version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Imagine that you have 100+ columns, about 90% of features have about 20% missing values. The total dataset is about 10000+ rows. Will you impute missing values for categorical by most frequent values or just simply delete the missing values? As I found the PCA plot after imputation is two vertical lines, probably because of the imputation. After delete these features the plot seems normal (scatters around). Do you have any suggestions? Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":64649933,"Users Score":0,"Answer":"It realy depends on the data, one good possible solution is to fill the missing values with the average of each feature (or the median). If your data is cleaned for obvious outliers and scaled it should not affect them much.\nAnother possible solution here with promising results would be to determine the k closest neighbors to each element and use their average or median value to fill the missing columns in the row. keep in mind the dimensionality curse will negatively affect this method","Q_Score":0,"Tags":"python,cluster-analysis,pca","A_Id":64650217,"CreationDate":"2020-11-02T16:59:00.000","Title":"Will you drop features or values for missing value handling in clustering project?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to using python with data sets and am trying to exclude a column (\"id\") from being shown in the output. Wondering how to go about this using the describe() and exclude functions.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1537,"Q_Id":64650710,"Users Score":-1,"Answer":"Use output.describe(exclude=['id'])","Q_Score":0,"Tags":"python,dataframe,qtconsole","A_Id":64650759,"CreationDate":"2020-11-02T17:51:00.000","Title":"Using describe() method to exclude a column","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on OS X\nIve looked at many different threads and haven't found a solution. Maybe I haven't been installing things properly from the start either. I want to import the module pyautogui into my project but it is saying it can't find it. I did a pip install in terminal and in the pycharmterminal as well. I have found the file directory and verified that it is available. But yet I am still not able to access it in my project. On some of the threads I read something about init.py, do I need to put that in my project. If so is there code in that py file or do I just create a python file named init.py","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":64650901,"Users Score":0,"Answer":"On Mac OS and some Linux distros, you may need to type pip3 install package-name.","Q_Score":0,"Tags":"python,python-3.x,installation,pip","A_Id":64651312,"CreationDate":"2020-11-02T18:05:00.000","Title":"unable to import module pyautogui","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed pyarrow using this command \"conda install pyarrow\".\nI am running a sagemaker notebook and I am getting the error no module named pyarrow.\nI have python 3.8.3 installed on mac.\nI have numpy  1.18.5 , pandas 1.0.5 and pyarrow  0.15.1\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":463,"Q_Id":64651724,"Users Score":0,"Answer":"I have not yet used AWS Sagemaker notebooks, but they may be similar to GCP 'AI Platform notebooks', which I have used quite extensively. Additionally, if you're experiencing additional problems, could you describe how you're launching the notebooks (whether from command line or from GUI)?\nIn GCP, I defaulted to using pip install for my packages, as the conda environments were a bit finicky and didn't provide much support when creating notebooks sourced from my own created conda environments.\nAssuming you're installing conda into your base directory, when you launch jupyter notebooks, this should be the default conda environment, else if you installed to a separate conda environment, you should be able to change this within jupyter notebooks using the CONDA tab and selecting which notebook uses which conda environment.\n-Spencer","Q_Score":0,"Tags":"python,anaconda,amazon-sagemaker,pyarrow","A_Id":64651933,"CreationDate":"2020-11-02T19:03:00.000","Title":"No Module named pyarrow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In python 3 I am getting errors when I use input() and I want to take user input and do something with it.\nI am executing the python script in BBEdit, Sublime or IDLE.\nCode results in errors unless I remove the Input() Syntax:\n\n\ninput(\"Hi I'm new to python\")\n\n\nuserInput = input(\"Enter a string\")\nprint(f\"You entered {userInput}\")\n\nIn the console it displays the string from input(\"String\") but any user keystrokes are instead typed in the code editor, not interactively.\nI read that Python could not be interactive via those apps but I don't understand how to execute a syntactically correct \"input(\"enter your favorite sushi roll\") and interact with it  (on pc and Mac)\nFrom Console:\n\nEnter a string \nTraceback (most recent call last):\nFile \"\/Users\/michaelking\/Desktop\/BBEditRunTemp-hellowWorld.py\", line 1, in \nuserInput = input(\"Enter a string\") \nEOFError: EOF when reading a line \n================================================================================\nNov 2, 2020 at 9:53:07 PM\n~\/Desktop\/hellowWorld.py\nTraceback (most recent call last):\nFile \"\/Users\/michaelking\/Desktop\/BBEditRunTemp-hellowWorld.py\", line 1, in \nuserInput = input()\nEOFError: EOF when reading a line","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":173,"Q_Id":64657598,"Users Score":0,"Answer":"When you're running a script that requires interactive input, you'll have to run it in Terminal (or an equivalent such as iTerm).\nI can't speak to other products :-) but when using BBEdit, the \"Run in Terminal\" command on the #! menu will do this for you.","Q_Score":0,"Tags":"python,input,printing,traceback","A_Id":64810517,"CreationDate":"2020-11-03T06:10:00.000","Title":"How to get User Input in Python 3 when input() returns errors","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have two categories of images segmented using MaskRCNN. First category contains dent images on car.\nSecond category contains images of reflection\/shadows fallen on car that the Mask RCNN detects as dent.\nIs there any methods in image processing that can distinguish between the same? I tried Canny, Gaussian, LBP, SIFT, watershed etc. Can anyone suggest a suitable approach for the same.\nThanks in advance!!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":80,"Q_Id":64657814,"Users Score":1,"Answer":"If the image of shadows generally are darker than the dents, you can convert the images to HSV, and compare the average V values of the pixels. V value contains the brightness of the pixel.\nYou can use hsv_img = cv2.cvtColor(img, cv2.BGR2HSV).","Q_Score":0,"Tags":"python,image-processing,deep-learning,canny-operator","A_Id":64657890,"CreationDate":"2020-11-03T06:34:00.000","Title":"How to differentiate between two types of images using image processing?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a scraper that crawls about 25 domains with in total about 100k pages. The speed in the beginning is about 500 pages per minute, but it slows down considerably afterwards to about one hundred pages per minute. My reasoning was that this could be due to the throttling that I enabled in the settings.py file. Yet, after running the spider for five hours, I noticed that the speed went even down to about 5 pages per minute.\nMy initial understanding was that the spider would probably be stuck at one domain that was slow in responding. However, this understanding didn't make sense anymore when I spotted some huge fluctuations in the scraping speed. After being stuck for hours in the range 0-20 pages per minute, occasionally there is a speed up to 100-500 pages per minute(mosttimes for only one or two minutes). How could the latter speedups be explained considering that a domain would be slowing down in its responses to me?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":64659107,"Users Score":0,"Answer":"Your initial understanding is probably correct - sound like you are getting temporarily throttled which results in fluctuating speeds.","Q_Score":0,"Tags":"python,web-scraping,scrapy,throttling","A_Id":64659274,"CreationDate":"2020-11-03T08:21:00.000","Title":"How do unexpected speed fluctuations in Scrapy relate to throttling?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Since many years I have been using a Python script, to add a \"virtual printer\" to my macOS printing dialogue and print on a PDF stationery from any application.\nThe script is placed within ~\/Library\/PDF Services, took sys.argv[3] as an input file, merged the input file with a given PDF stationery and saved it in ~\/Downloads.\nI was happy until I updated to macOS Catalina and always got this message from Console:\nSandbox: Python(30225) System Policy: deny(1) file-read-data \/Users\/me\/Documents\/stationery.pdf\nIt seems that, due to the new permissions in macOS Catalina, the script cannot access the stationery file anymore. Python however has full hard disk access.\nIf I run the same script from the Terminal, everything works fine.\nHow can I grant the script access to the required document (\/Users\/me\/Documents\/stationery.pdf) when executed from withing the printing dialogue?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":62,"Q_Id":64662338,"Users Score":1,"Answer":"EDIT:\nThis problem seems to have been fixed in Monterey: python scripts will now correctly run as PDF Services.\n(Of course, they're removing python, so you'll have to install your own. Swings and Roundabouts.)","Q_Score":0,"Tags":"python,macos,pdf","A_Id":65738829,"CreationDate":"2020-11-03T11:52:00.000","Title":"macOS python PDF service denied access in macOS Catalina","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"while working with CNNs I was wondering which of my Input Channels gives the most information to the neural network for the prediction.\nFor example: The is a image of a frog. The CNN is suppose to predict which kind of animal is in the image.\nSo because frogs are green most of the time, the CNN uses the channel G from RGB the most for prediction.\nIs there a way of finding out which channel is the most important for a specific neural network?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":64663363,"Users Score":0,"Answer":"IF a color channel is the most important, you can check manually by getting the weights of the input convolution layer. They will be in (filtersizex x filtersizey x 3) X the number of filters. you then need to add the weights so you get (1 x 3) X the number of filters. So you have for each filter the most important channel, if you need this for the whole network add them all together and you end with an (1 x 3) array, the max of this is the most important channel.","Q_Score":0,"Tags":"python,tensorflow2.0,prediction,conv-neural-network","A_Id":64664028,"CreationDate":"2020-11-03T13:02:00.000","Title":"CNN: Which channel gives the most informations?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a data frame in which the target value is not in normal distribution. I want to choose only a sample of the data that represent a normal distribution of this target. How can I do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":64663570,"Users Score":0,"Answer":"With the given information, this is a sampling question. I am not sure whether this is an acceptable practise to choose a targeted sample. Instead, choose samples randomly and make sure they follow normal distribution. If the sample is not normally distributed, try normalizing your target value using transformation procedures. For example, a square root transformation might make your target value normal. More information on the problem will help address this comprehensively.","Q_Score":0,"Tags":"python,pandas,dataframe,normal-distribution","A_Id":64663653,"CreationDate":"2020-11-03T13:15:00.000","Title":"How to choose a sample from the data points that represent normal distribution?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a physical model with one independent variable X and three parameters A, B and C. The dependent variable is Y=F(X,A,B,C) where F is the model's function which is smooth and continuous.\nI have many files with data points (X,Y) that I want to fit (each file) with the model to study how the parameters change. The model is non-linear with respect to the independent variable and all the parameters.\nTo fit the model, I use scipy.optimize curve_fit in Python inside a for loop throughout the files with the data points. For each file, I get the best fitting parameters (A,B,C) and the model fits great to all the files. However, when I check the parameter errors after the fittings, I notice that the errors in A are really large, even two orders of magnitude higher than the corresponding values.\nThe experience tells me that these large variances might be due to the fact that the parameter A could be correlated to any of the others. To check this assumption, I plotted the obtained values of A against the values of B and C. I see that, in fact, a power-law relation of the form A=a*B^b arises, which is physically acceptable.\nIs there a way to tell curve_fit to take care of this correlation without having to introduce new parameters (say a and b) in order to fit the model with the lowest variance possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":195,"Q_Id":64665533,"Users Score":0,"Answer":"Try to use method = 'trf' as a parameter for your fit. This avoids using least squares and works with pseudoinverse of the Jacobian. I believe a Jacobian with a zero eigenvalue then should not be a problem.","Q_Score":0,"Tags":"python,scipy,correlation,curve-fitting,model-fitting","A_Id":64689608,"CreationDate":"2020-11-03T15:12:00.000","Title":"Correlated variables and scipy curve_fit","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"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 <password> | 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":"Given the start node and goal node in a graph, I want to find one simple path between these two nodes. I do not want the shortest path, but need any random simple path.\nI tried using all_simple_paths from networkx, but this module seems to calculate all the simple paths before returning anything. This takes a long time to run.\nIs there a way to find just one simple path?\nAlso, I would ideally like to make sure this path does not cross any \"obstacles\". These obstacles are a predefined set of nodes from the same graph. Is there a way to add in this constraint?\nPS: I don't necessarily need to use networkx. The code I am writing is in Python.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":64669751,"Users Score":0,"Answer":"You could treat this as a min cost network flow problem where your start node wants to send a unit of flow (demand = -1) to your goal node (demand = 1). You can set the edge capacities to 1 and you can set all the edge weights to 0 except for those around \"obstacle\" nodes. For those obstacle nodes you can set all the edges either coming into or going out of them to have a weight of 1. The algorithm will try to find any arbitrary path using only edges with weight 0, but will use weight 1 edges if no path exists with only weight 0 edges.\nSee the nx.min_cost_flow function. This function requires you to make your graph a directed graph nx.DiGraph if it's not already.","Q_Score":1,"Tags":"python-3.x,networkx","A_Id":64683145,"CreationDate":"2020-11-03T19:57:00.000","Title":"Getting a random simple path between two nodes in a graph","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given the start node and goal node in a graph, I want to find one simple path between these two nodes. I do not want the shortest path, but need any random simple path.\nI tried using all_simple_paths from networkx, but this module seems to calculate all the simple paths before returning anything. This takes a long time to run.\nIs there a way to find just one simple path?\nAlso, I would ideally like to make sure this path does not cross any \"obstacles\". These obstacles are a predefined set of nodes from the same graph. Is there a way to add in this constraint?\nPS: I don't necessarily need to use networkx. The code I am writing is in Python.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":64669751,"Users Score":0,"Answer":"I managed to solve this problem by using the RRT algorithm. It gives a random path between the source and destination nodes and also avoids obstacles.","Q_Score":1,"Tags":"python-3.x,networkx","A_Id":65011907,"CreationDate":"2020-11-03T19:57:00.000","Title":"Getting a random simple path between two nodes in a graph","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can a Jupyter notebook cell be split in VSCode?  I.e., how to split a single cell with multiple lines into two cells with the top lines (above the cursor) in one cell and the bottom lines (below the cursor) in another cell?\nI've tried Cntrl Shift - using the Daily Insiders Python Extension, but it doesn't seem to do anything.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5244,"Q_Id":64673038,"Users Score":0,"Answer":"ctrl shift - works for VSCode (version 1.66.2) on Mac (Monterey 12.3.1)","Q_Score":8,"Tags":"python,visual-studio-code,jupyter-notebook","A_Id":71904759,"CreationDate":"2020-11-04T01:19:00.000","Title":"How to split cell in VSCode Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using prefect workflow for business applications.\nI have a question about logs stored in postgresql.\nIf daily logs are kept stored on the postgresql server, the amount of data will be enormous.\nIs there a mechanism to rotate this log and write it to a text file?\nAlso, is it okay to delete the corresponding record after writing the data from the postgresql table to a text file, etc.?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":488,"Q_Id":64673822,"Users Score":3,"Answer":"Since you're running an instance of Prefect Server, it would make sense to write a Flow that connects to the postgres container and archives the logs to some sort of cloud storage (GCS, S3, etc) for you. I'd probably think about it like this:\n\nUse the Prefect Client to gather all the IDs of Flow Runs older than a certain date.\nConnect to postgres and select the logs from the logs table for logs with those Flow Run IDs\nWrite those logs to CSV\/SQL\/Text as preferred\nDelete those logs from postgres","Q_Score":2,"Tags":"python,postgresql,airflow,workflow,prefect","A_Id":64806809,"CreationDate":"2020-11-04T03:18:00.000","Title":"About managing logs of prefect workflow","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Doesn't a list require O(n) time to increase its size? How, then, could heap.heappush be O(log n)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":64674032,"Users Score":2,"Answer":"A list has amortized O(1) appends; every once in a long while, it needs to expand the underlying capacity, but usually an append just needs to claim already allocated capacity.\nSo yes, every once in a while, heapq.heappush will incur O(n) work to reallocate the underlying list's storage, but the vast majority of the time, adding the extra item (done via append internally) is O(1), which is followed by a O(log n) sift down operation to move it to the correct position in the heap (reestablishing the heap invariant); the sift down operation is implemented with element swaps, which are all O(1), not insertions and deletions (which would be O(n) each)","Q_Score":0,"Tags":"python,time-complexity,heapq","A_Id":64674068,"CreationDate":"2020-11-04T03:54:00.000","Title":"How can heapq's push operation be O(log n) time if the underlying data structure is a list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I ran the following code in python shell:\n\nfrom main.models import ToDoList\nls = ToDoList.objects.all()\nls\noutput: <QuerySet [<ToDoList: First List>, <ToDoList: Second List>]>\n\nbut when I use:\n\nls = ToDoList.objects.get(id=1)\n\nit says:\n\nmain.models.ToDoList.DoesNotExist: ToDoList matching query does not exist.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":64676186,"Users Score":0,"Answer":"You can use: ToDoList.objects.first() to get the first item.\nor use ToDoList.objects.get(pk=1) to get item based on PK","Q_Score":0,"Tags":"python-3.x,django","A_Id":64676255,"CreationDate":"2020-11-04T08:06:00.000","Title":"How to access Django's single set item?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using odeint in scipy to integrate a function. The function is basically the velocities in x,y,z directions which I need to integrate to find the corresponding x,y,z position coordinates. Odeint in python asks for a list of timesteps and return values for those number of timesteps only. But, I require all values of x,y,z coordinate positions calculated at each internally defined timestep and not just at the timesteps I send as a parameter. So, is there a way to just send the min and max timestep and get all the values calculated at each internally defined timestep between the given min and max timestep?\nThe reason I need this is that when I plot the x,y,z coordinates returned, I am getting sharp turns and not smooth paths. So, in order to plot a smooth path, I will require all the coordinates calculated at each internally defined timestep.\nIf I am not wrong, the ODE45 function in Matlab returns all values calculated at every automatically defined internal timestep. Is there a way to get this to work in python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":64676414,"Users Score":0,"Answer":"You get this functionality with scipy.integrate.solve_ivp or by fashioning your own time loop using the stepper classes, the old ode class or the new RK45, Radau, LSODA etc.\nNote that in Matlab the option parameter 'Refine' is set to the default value 4, so that for every internal step there are 3 interpolated points added so that the output looks curved despite large time steps due to the step size control. This trick is not present in the python routines, you would have to enrich the output yourself.","Q_Score":0,"Tags":"python,integration,ode,odeint","A_Id":64711686,"CreationDate":"2020-11-04T08:24:00.000","Title":"How to return values for all internally defined time steps by odeint in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to put a Label and an Entry widgets on the same line and center them.\nI saw on multiple posts that to center, pack() method was easier. But, to put on the same line, it's grid().\nWith grid(), I suppose I have to build all the layout, then center it. Is there a way to do it on the go? With pack(), I don't have any idea.\nBut, I want to do both at the same time. I didn't find any answer :\/\nIf someone can help me, I will be very grateful!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":223,"Q_Id":64677560,"Users Score":2,"Answer":"I have to put everything in a frame and pack() the frame.\nThanks to @acw1668","Q_Score":0,"Tags":"python-3.x,user-interface,tkinter,tkinter-layout","A_Id":64677656,"CreationDate":"2020-11-04T09:42:00.000","Title":"Center and put multiple items on the same line using Tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed pygame using pip install pygame and when that didn't work I found a solution online and tried pip install pygame==2.0.0.dev14.\nStill the same problem: \"pygame\" shows up when I do pip list, and pygame folders are there in the file locations. However, when I run the code import pygame, the shell shows the error ModuleNotFoundError: No module named 'pygame'.\nHow can I fix this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":367,"Q_Id":64680121,"Users Score":0,"Answer":"You should do pip3 install pygame sometimes this happens, when you are on a mac and have 2 versions of python in your computer, MAC OS takes the python 2.7 by default, if you want a newer version, you have to specify by saying python3 or pip3","Q_Score":0,"Tags":"python,pygame","A_Id":64680178,"CreationDate":"2020-11-04T12:29:00.000","Title":"I have a problem running pygame 2.0 with python 3.9","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed pygame using pip install pygame and when that didn't work I found a solution online and tried pip install pygame==2.0.0.dev14.\nStill the same problem: \"pygame\" shows up when I do pip list, and pygame folders are there in the file locations. However, when I run the code import pygame, the shell shows the error ModuleNotFoundError: No module named 'pygame'.\nHow can I fix this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":367,"Q_Id":64680121,"Users Score":0,"Answer":"For python 3.9, you can use: python -m pip install pygame --pre --user. This happens because python 3.9 isn't fully adapted to pygame yet.","Q_Score":0,"Tags":"python,pygame","A_Id":64789467,"CreationDate":"2020-11-04T12:29:00.000","Title":"I have a problem running pygame 2.0 with python 3.9","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm facing this error AttributeError: module 'cv2' has no attribute 'face' when testing on Android. I've got opencv and opencv_extras included in requirements. This error won't show up when running on desktop but it shows up when tested on Android.\nAny advice ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":64681167,"Users Score":0,"Answer":"Hey mate I also faced the same error today.....\nWell the solution is uninstalling your current version of python and installing new version, that is downgrading your current version of opencv\nopencv-contrib-python==3.4.6.27\nAlso this can be verified by typing\nhelp(cv2.face) in the IDE\nif it shows the path the version opencv would work...\nWell the above version of opencv I mentioned does have cv2.face\nSo to install it you type\npip install opencv-contrib-python==3.4.6.27 in the cmd or whatever depending upon your environment","Q_Score":0,"Tags":"opencv,kivy,buildozer,opencv-python","A_Id":64681308,"CreationDate":"2020-11-04T13:38:00.000","Title":"AttributeError: module 'cv2' has no attribute 'face' despite using \"opencv_extras\" recipe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"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":"My dataset contains 1000 sets which I'm using it for the classification problem. I used LR and SVM as a machine learning algorithm. I was wondering if I should use Bootstrapping from training set and then apply LR & SVM or use Bootstrapping from original dataset? When I look at the accuracy score, I shouldn't use bootstrapping from original dataset.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":298,"Q_Id":64687774,"Users Score":0,"Answer":"Bootstrapping from the original dataset defeats the purpose of having the two different datasets (train\/test). You always train the model on the training dataset and calculate the accuracy or another score on the test dataset.\nIf you bootstrap from the original dataset, you'll be training your model on (a subset of) the whole dataset, which will include a part of the test dataset, so your resulting metrics (that you'll calculate based on the test dataset) will be biased because you trained the model on part of the test dataset.","Q_Score":0,"Tags":"python,resampling","A_Id":64687830,"CreationDate":"2020-11-04T21:09:00.000","Title":"Bootstrapping after training_test split or original dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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 was wondering why this hex:\nbytes.fromhex(\"34 FF FA A3 A5\")\ngives an output: b'4\\xff\\xfa\\xa3\\xa5'.  Why \\x disappeared, shouldn't it be \\x34?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":293,"Q_Id":64688226,"Users Score":1,"Answer":"Python tries to print a good looking equivalent.\nIn your case we have: '0x34'= hex(ord(\"4\")) , which means Unicode integer representing of 4 in hex equals '0x34'.\nTry this one in your console: print (\"\\x09\") . That's because \\x09 in hex format represents \\t.","Q_Score":1,"Tags":"python","A_Id":64688507,"CreationDate":"2020-11-04T21:51:00.000","Title":"Why does bytes.fromhex() produce the output shown?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering why this hex:\nbytes.fromhex(\"34 FF FA A3 A5\")\ngives an output: b'4\\xff\\xfa\\xa3\\xa5'.  Why \\x disappeared, shouldn't it be \\x34?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":293,"Q_Id":64688226,"Users Score":3,"Answer":"That's how bytes reprs work; when a byte has an ordinal value corresponding to a printable ASCII character, it's represented as the ASCII character, rather than the \\x escape code. You can create the bytes with either form (b'4' == b'\\x34' is True; they produce the exact same bytes value), but it chooses the ASCII display to make byte strings that happen to be ASCII more readable (and make many reprs shorter).","Q_Score":1,"Tags":"python","A_Id":64688269,"CreationDate":"2020-11-04T21:51:00.000","Title":"Why does bytes.fromhex() produce the output shown?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm still new to python but I'm trying to get keyboard installed through the command prompt and having some difficultly. So I've added the path location but when I run it I get...\nC:\\Users\\john>C:\\Users\\john\\AppData\\Local\\Programs\\Python\\Python38\\Scripts pip install keyboard\n'C:\\Users\\john\\AppData\\Local\\Programs\\Python\\Python38\\Scripts' is not recognized as an internal or external command, operable program or batch file.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":64688735,"Users Score":0,"Answer":"Just get rid of the path in your command and only run pip install keyboard.","Q_Score":0,"Tags":"python,python-module","A_Id":64688794,"CreationDate":"2020-11-04T22:40:00.000","Title":"Trying to install keyboard in command prompt \"is not recognized as an internal or external command, operable program or batch file\" error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I annotate a type that can be anything but None? In other words, this type is Any but is not None.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":467,"Q_Id":64689030,"Users Score":0,"Answer":"You can do Union[int, str, ...] but exclude None from that union.","Q_Score":6,"Tags":"python,mypy","A_Id":64689085,"CreationDate":"2020-11-04T23:15:00.000","Title":"Mypy annotation for any type but None","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Built-in types and functions could be used without importing, like 'list, dict, print' .\nBut built-in moudles still need importing before using, like  'time, sys, gc, math, mmap'.\nSo they are just different conceptions, or built-in moudles include built-in types\/functions?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":64690486,"Users Score":0,"Answer":"Those other modules aren't built-in (well, most of them anyway). They are just part of the standard library and are expected to be available in most installations. \"built-in\" just means everything that you don't have to import - they are available in all module namespaces.\nSome modules like sys are implemented in C and may in fact be part of the python executable. But since their implementation is not generally expected to be needed by all scripts, they are still namespace encapsulated. There is no need to have sys.version be a built-in.","Q_Score":1,"Tags":"python,built-in","A_Id":64690637,"CreationDate":"2020-11-05T02:44:00.000","Title":"What is the relationship between Python built-in modules and built-in types\/functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have used Pycharm to connect my remote server and it worked well. But after I added a second connection to another server. It reports errors: Couldn't upload helpers for remote interpreter: Authentication failed: Exhausted available authentication methods, and the previous connection failed as well.\nHere are some measures that I took but not valid.\n\nDelete the new connection.\nDelete all connection and remote interpreter, then reconnect to the remote server\nRestart my laptop.\n\nThe last thing I did and worked for me is\ngo to Deployment -> connection -> Authentication, choose Key pair openssh or PuTTY, select the private key path. Test Connection and it worked.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2030,"Q_Id":64691078,"Users Score":1,"Answer":"go to Deployment -> connection -> Authentication, choose Key pair openssh or PuTTY, select the private key path. Test Connection and it worked.","Q_Score":0,"Tags":"python,pycharm,remote-server","A_Id":64691081,"CreationDate":"2020-11-05T04:08:00.000","Title":"Pycharm: Couldn't upload helpers for remote interpreter: Authentication failed: Exhausted available authentication methods","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have used Pycharm to connect my remote server and it worked well. But after I added a second connection to another server. It reports errors: Couldn't upload helpers for remote interpreter: Authentication failed: Exhausted available authentication methods, and the previous connection failed as well.\nHere are some measures that I took but not valid.\n\nDelete the new connection.\nDelete all connection and remote interpreter, then reconnect to the remote server\nRestart my laptop.\n\nThe last thing I did and worked for me is\ngo to Deployment -> connection -> Authentication, choose Key pair openssh or PuTTY, select the private key path. Test Connection and it worked.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2030,"Q_Id":64691078,"Users Score":0,"Answer":"If you face problem in Pycharm, there are high chances you are not able to SSH using Putty \/ Terminal (Mac). Please try ssh'ing into host via Putty \/ Terminal first. If you fix the issue with your Putty \/ Terminal (Mac), you'll automatically fix Pycharm's Authentication Failed Error too. That's how, I fixed mine.","Q_Score":0,"Tags":"python,pycharm,remote-server","A_Id":67093275,"CreationDate":"2020-11-05T04:08:00.000","Title":"Pycharm: Couldn't upload helpers for remote interpreter: Authentication failed: Exhausted available authentication methods","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some source codes that an old predecessor made with python2.\nNow I have to fix it to run it in python3.\nMy questions are two.\n\nWhat does mean if a in b in c and d:?\n\nIs it possible in the specific case if (list) in (str) in (list) ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":64691328,"Users Score":4,"Answer":"a in b in c is a chained comparison\nit is similar to this chained expression a < b < c which evaluates as (a < b) and (b < c)\nputting all that together you get (a in b) and (b in c) and d\nI'll note that that's very unlikely to be true though one example I can think of is a = 'a'; b = 'ab'; c = 'abc'\nas for your second part it would be a type error always if a is a list","Q_Score":0,"Tags":"python,python-3.x","A_Id":64691387,"CreationDate":"2020-11-05T04:42:00.000","Title":"how to interpret \"if a in b in c and d\" in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried following the instructions on pytorch.org and ran the command provided by them for my configuration, but I get the following error\nERROR: Could not find a version that satisfies the requirement torch===1.7.0+cu110 (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)\nERROR: No matching distribution found for torch===1.7.0+cu110\nA  similar error is being thrown for any other installation methods that I try, e.g. earlier cuda versions, CPU only etc. My Python version is 3.9 and was installed using the .exe installer provided at python.org, if that's relevant.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1396,"Q_Id":64691517,"Users Score":0,"Answer":"Well, I installed a new Operating System and did a fresh install of Python and CUDA. After that the commands given on pytorch.org worked just fine. For immediate reference, the command is\npip install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio===0.7.0 -f https:\/\/download.pytorch.org\/whl\/torch_stable.html\nI had to resort to this because I had messed up my python installation by tinkering around with pip, conda and anaconda all at once. The process of removing anaconda completely didn't quite work as intended and everything was just a wee bit broken.\nSo, I'm guessing that if anyone else is facing the same error and other documented solutions do not work, then a fresh installation of python might become necessary. In my case, it was in the form of a completely new operating system.","Q_Score":0,"Tags":"python,pip,pytorch","A_Id":64693626,"CreationDate":"2020-11-05T05:07:00.000","Title":"Unable to install PyTorch on Windows 10 (x86_64) with Cuda 11.0 using pip","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a matrix with the following shape (20, 17) with rows being the time and columns the number of variables.\nWhen i compute the correlation matrix using data.corr() naturally i get a (17 , 17) matrix.\nMy questions:\nIs there a way to normalise the variables directly within the .corr() function? (i know i can do that before hand and then apply the function)\nMy correlation matrix is large and I have trouble viewing everything in one go (i have to scroll down to do the necessary comparison). Is there a way to present the results in a concise way (like a heat map) where i can easily spot the highest from the lowest correlation?\nMany Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":183,"Q_Id":64693985,"Users Score":1,"Answer":"You could use matplotlib's imshow() to see a heatmap of any matrix.\nAlso, consider using pandas dataframes, this way you could sort by correlation strength and keep the labels of each row and col.","Q_Score":1,"Tags":"python-3.x,cross-correlation,pearson-correlation","A_Id":64694075,"CreationDate":"2020-11-05T08:57:00.000","Title":"Pearson correlation in python data.corr()","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever we perform any operations with the images, we convert them into Arrays, what's the specific reason?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":179,"Q_Id":64694273,"Users Score":2,"Answer":"OpenCV images are stored as three-dimensional Numpy arrays. When you read in images using the library, they are represented as Numpy arrays.\nWith Numpy you can make blazing fast operations on numerical arrays, no matter which dimension, shape they are.","Q_Score":0,"Tags":"python,arrays,image,image-processing,multidimensional-array","A_Id":64694309,"CreationDate":"2020-11-05T09:18:00.000","Title":"Why do we convert image in arrays for image processing?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a test account for snowflake. I can able to a fetch data from Python but unable to fetch it from Pyspark. Error is showing like unable to create a stage for shared DB. How the stage is creating in Python-snowflake connector?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":33,"Q_Id":64694314,"Users Score":1,"Answer":"i think the python connector creates a temp stage for the results in S3\nyou can see that when you run the connector in debug mode","Q_Score":0,"Tags":"python-3.x,pyspark,snowflake-cloud-data-platform,snowflake-schema","A_Id":64698264,"CreationDate":"2020-11-05T09:21:00.000","Title":"Unable to fetch value from SNOWFLAKE_SAMPLE_DATA database in spark","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Unable to create venv using python 3x;\npython -m venv myclub\nError: Command '['C:\\Users\\Sibasankar Panigrahi\\myclub\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 101.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":96,"Q_Id":64698872,"Users Score":1,"Answer":"This looks to be caused by how you installed Python.\nUninstall and reinstall, using the 'all users' option in the custom \/ advanced menu options of the installer. Don't forget to tick add to path!.","Q_Score":2,"Tags":"python-3.x,django,python-venv","A_Id":65751477,"CreationDate":"2020-11-05T14:06:00.000","Title":"Failed to create virtual environment directory in cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with a team. We each have our own Windows system.  We have shared drives and a shared git repository. We want to have a shared virtual environment (in Python).\nMy understanding (from previous questions from myself and others) is that virtual environments do not include all files necessary for running python, in particular, the shared VE does not include the Python interpreter.\nI can see how we can create a shared VE and it seems we could just copy that around, or put it on the shared drive, or put it in a git repository.  But my understanding of this is that it does not eliminate the need for individuals to install their own local versions of python.  Is that correct?\nOne of my colleagues has heard (or read) that \"there is a package that allows teams to share their virtual environment configuration through a git-like interface.  That way you can \u201cpull\u201d the updated configuration and it will install the new packages automatically.  This allows each person to change the configuration and test it before releasing it to the team.\"\nSo is there a special package to enable this?  Or is it just a regular venv that is included in the git repository with the other files?   If we do this, then we must all put the venvs in the same place in on our file systems OR we have to go in and manually change the VIRTUAL_ENV variable in activate.bat. Is that correct?\nIn any case, we do all have to install our own local versions of python anyway.  Is that correct?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":870,"Q_Id":64699540,"Users Score":5,"Answer":"containerization aims to solve the \"from where comes python?\" problem.  My developers' teams usually use a Dockerfile that installs their requirements within a docker-compose that spins ups a development environment for their applications . Unlike a virtual environment, containers offer a complete userspace solution that works pretty well in windows and osx.","Q_Score":3,"Tags":"python,git,package,virtualenv","A_Id":64699608,"CreationDate":"2020-11-05T14:45:00.000","Title":"Is there a python package that allows teams to share venvs through a git-like interface?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just created a pipenv environment using pipenv --python 3.9. I then did pipenv shell and started installing packages with pip install. It turns out this doesn't seem to be the usual way of doing things with pipenv. Is there any command I can run to update the Pipfile with all the packages I installed with pip install? I searched but couldn't find anything.","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":3622,"Q_Id":64699781,"Users Score":5,"Answer":"When you have multiple packages you'd like to install, you usually have whats called a requirements.txt file, that contains all the packages you'd like to use for your project.\nYou can run\n$ pipenv run pip freeze > requirements.txt\nTo generate the requirements file to the current directory you're in, while the virtual environment is active.\nInitially you're going to have to install all your packages manually. But after you can run\n$ pipenv install -r path\/to\/requirements.txt\nto import all the packages in requirements.txt from the shell\/virtual environment.","Q_Score":3,"Tags":"python,pip,pipenv,virtual-environment","A_Id":64700408,"CreationDate":"2020-11-05T15:00:00.000","Title":"Is it possible to update Pipfile after installing packages using pip install?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been successfully using a virtual environment created by pipenv for months, located at ~\/.virtualenvs. However, today when I tried to activate it using \"pipenv shell\" (while in the proper directory) pipenv creates a new .venv file in the current directory instead of loading the environment from ~\/.virtualenvs. My main concern is: how do I redirect pipenv to the existing virtual environment? Out of curiosity, any ideas about what could suddenly cause this behavior?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":360,"Q_Id":64703208,"Users Score":0,"Answer":"just go to that project\/venv bin folder and then do source activate it will as activate as it is just a wrapper around virtualenv","Q_Score":0,"Tags":"python,pipenv","A_Id":64703321,"CreationDate":"2020-11-05T18:24:00.000","Title":"Pipenv shell command creates new venv instead of loading existing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Im having an image as input, and need to resize it. I have earlier used pillow to do this but the library wasnt available where i needed it.  np.resize(image, (50,50)) returns a different array then cv2.resize(image, (50,50)) and (pillow) Image.fromarray(image), image_from_array.resize((50, 50)).\nWondering whats the difference between these methods.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":64703798,"Users Score":1,"Answer":"np.resize doesn't 'resize' images, instead it interprets the data that's already there in a different way. E.g. say you have four integers [1, 2, 3, 4], then .resize((2, 2)) will give you [[1, 2], [3, 4]].\nUse cv2.resize if you actually want to resize an image.","Q_Score":0,"Tags":"python,numpy,opencv,image-processing,python-imaging-library","A_Id":64704157,"CreationDate":"2020-11-05T19:06:00.000","Title":"Whats the diffrence between numpy.resize() and cv2.resize()?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When i convert a pandas data frame to spark, spark automatically strips the String columns\/ deletes leading and trailing spaces. How can this be stopped?\nsparkframe = spark.createDataFrame(pandas_df)\nExample '  ' -> '' or 'ab ' -> 'ab'","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":15,"Q_Id":64704555,"Users Score":1,"Answer":".option(\"ignoreTrailingWhiteSpace\",False).option(\"ignoreLeadingWhiteSpace\",False)\nwhen saving is the the solution. Why its default True is a mystery","Q_Score":1,"Tags":"python,pandas,pyspark","A_Id":64704861,"CreationDate":"2020-11-05T20:04:00.000","Title":"stop spark createdataframe(pandas.df) from stripping \/ trimming strings","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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'm building a mobile app using kivy and python, and I want to understand what parts in my code I could explain to someone else being my frontend and backend part. I have one kv file plus one py file where my code is. My question is now, is all the code I'm having in the kv file, for example a button with a text and an on_press function, my frontend? Can I call my entire py file for a backend file, even though it sometimes does such simple functions as changing a text on a button in my kv code?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":187,"Q_Id":64705260,"Users Score":0,"Answer":"Frontend is what the user see and the way he interacts with your application.\nThe backend is every logical part, work on database, mathematic processing...","Q_Score":1,"Tags":"python,kivy","A_Id":64705482,"CreationDate":"2020-11-05T21:04:00.000","Title":"What parts in my Kivy application corresponds to the backend and their frontend","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a mobile app using kivy and python, and I want to understand what parts in my code I could explain to someone else being my frontend and backend part. I have one kv file plus one py file where my code is. My question is now, is all the code I'm having in the kv file, for example a button with a text and an on_press function, my frontend? Can I call my entire py file for a backend file, even though it sometimes does such simple functions as changing a text on a button in my kv code?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":187,"Q_Id":64705260,"Users Score":0,"Answer":"I would say that all the code dealing with manipulating the gui is the frontend, and all the code that deals with other state is the backend. In general it is good architecture to separate these, but it's possible to mix in what could\/should be backend state so that it's strongly coupled to the gui, in which case there might not be a clear separation to point to.\nI don't think it's useful to present the .py\/.kv disinction into the definition of frontend vs backend - it's tempting since on the surface it's sort of right, but it doesn't really hold up to scrutiny. As you note, the .kv file isn't really different to parts of the .py file that directly manipulate the gui.","Q_Score":1,"Tags":"python,kivy","A_Id":64706583,"CreationDate":"2020-11-05T21:04:00.000","Title":"What parts in my Kivy application corresponds to the backend and their frontend","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm relatively new to working with server instances so please excuse my limited knowledge. I have a python script that I run for 5 different people. Each person who I run it for, has a slightly different file (Ie: some names in the script are changed to work with their branding and name), and right now when I get a new client, I have to copy the script, and change each part that needs to be changed by hand, and then run that in my server (I'm running all 5 scripts on the same server). If I make any changes to my codebase, I need to change the script for each of my clients, go to the server and swap out the old versions by hands.\nI'm expecting to have this grow to a couple hundred clients so this is just not a feasible method. Are there any products or methods I can use to fix this product, or atleast make it easier to update all the files at once?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":316,"Q_Id":64705463,"Users Score":0,"Answer":"Without looking at the specifics of the script it's really hard to say, but here are a couple of solutions that might work:\n\nPass the values that change as arguments to the script - Use something like argparse to capture the arguments into variables\n\nModify the script to run on a list of arguments - This is pretty easy to do - literally just add a for-loop around your entire script and iterate over the values for each of your clients.","Q_Score":0,"Tags":"python,server","A_Id":64705518,"CreationDate":"2020-11-05T21:20:00.000","Title":"How to update code on multiple servers at once","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been running GDAL through python on anaconda for years with no problem. Today when I tried to import gdal I got this error code:\n\nOn Windows, with Python >= 3.8, DLLs are no longer imported from the\nPATH. If gdalXXX.dll is in the PATH, then set the\nUSE_PATH_FOR_GDAL_PYTHON=YES environment variable to feed the PATH\ninto os.add_dll_directory().\n\nI've been looking for a solution to this but can't seem to figure out how to fix this. Anybody has a solution?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1321,"Q_Id":64707915,"Users Score":0,"Answer":"use:\nfrom osgeo import gdal\ninstead of:\nimport gdal","Q_Score":4,"Tags":"python,gdal","A_Id":72133539,"CreationDate":"2020-11-06T02:10:00.000","Title":"how to set the USE_PATH_FOR_GDAL_PYTHON=YES environment variable to feed the PATH into os.add_dll_directory()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using kafka-python-2.0.1 for consuming data from kafka brokers. As of now I am running a single consumer instance. We receive 2M records every 5 minutes. I noticed that kafka-python is not able to read data that faster to consume all the messages in a timely manner. I am new to kafka-python and not sure how can I put the implementation in place to read data faster. Should I run more than one consumer?\nconsumer = KafkaConsumer(bootstrap_servers='<broker>',security_protocol='SASL_SSL', sasl_mechanism = 'GSSAPI', auto_offset_reset = 'latest', sasl_kerberos_service_name = 'kafka',ssl_cafile='<ca_file>',   ssl_check_hostname=False,api_version=(0,10))\nThanks,","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":369,"Q_Id":64708194,"Users Score":0,"Answer":"Kafka scales with the number of partition within a topic.\nIf you want to increase your throughput you could increase the number of partitions of the topic. Then note, each partition can be consumed by at most one consumer within the same consumer group. So you should have the number of consumers within a consumer group match the numbers of partitions of the topic.\nThe consumer group can be set in the KafkaConsumer through the configuration group_id.","Q_Score":1,"Tags":"python-3.x,apache-kafka,kafka-consumer-api,kafka-python","A_Id":64725179,"CreationDate":"2020-11-06T02:53:00.000","Title":"kafka-python-2.0.1 performance with large data set","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"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 have been able to successfully detect an object(face and eye) using haar cascade classifier in python using opencv. When the object is detected, a rectangle is shown around the object. I want to get coordinates of mid point of the two eyes. and want to store them in a array. Can any one help me? how can i do this. any guide","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":236,"Q_Id":64708800,"Users Score":0,"Answer":"So you already detected the eye? You also have a bounding box around the eye?\nSo your question comes down to calculatiing the distance between 2 bounding boxes and then dividing it by 2?\nOr do I misunderstand?\nIf you need exact the center between the two eyes a good way to go about that would be to take the center of the 2 boxes bounding the 2 eyes.\nCalculate the distance between those two points and divide it by 2.\nIf you're willing to post your code I'm willing to help more with writing code.","Q_Score":1,"Tags":"python,opencv,coordinates","A_Id":64710334,"CreationDate":"2020-11-06T04:17:00.000","Title":"How to Get coordinates of detected area in opencv using python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been able to successfully detect an object(face and eye) using haar cascade classifier in python using opencv. When the object is detected, a rectangle is shown around the object. I want to get coordinates of mid point of the two eyes. and want to store them in a array. Can any one help me? how can i do this. any guide","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":236,"Q_Id":64708800,"Users Score":0,"Answer":"I suppose you have the coordinates for the bounding boxes of both eyes.\nSomething like X1:X2 Y1:Y2 for both boxes.\nYou just have to find the center of these boxes: (X2-X1)\/2+X1 and (Y2-Y1)\/2+Y1\nYou'll get two XY coordinates from this, basically just do the above again with these coordinates, and you'll get the center point","Q_Score":1,"Tags":"python,opencv,coordinates","A_Id":64711514,"CreationDate":"2020-11-06T04:17:00.000","Title":"How to Get coordinates of detected area in opencv using python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to introduce data quality testing (empty fields\/max-min values\/regex\/etc...) into my pipeline which will essentially consume kafta topics testing the data before it is logged into the DB.\nI am having a hard time choosing between the Deequ and Great Expectations frameworks. Deequ lacks clear documentation but has \"anomaly detection\" which can compare previous scans to current ones. Great expectations has very nice and clear documentation and thus less overhead. I think neither of these frameworks is made for data streaming specifically.\nCan anyone offer some advice\/other framework suggestions?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2871,"Q_Id":64711388,"Users Score":6,"Answer":"As Philipp observed, in most cases batches of some sort are a good way to apply tests to streaming data (even Spark Streaming is effectively using a \"mini-batch\" system).\nThat said: if you need to use a streaming algorithm to compute a metric required for your validation (e.g. to maintain running counts over observed data), it is possible to decompose your target metric into a \"state\" and \"update\" portion, which can be properties of the \"last\" and \"current\" batches (even if those are only one record each). Improved support for that kind of cross-batch metric is actually the area we're most actively working on in Great Expectations now!\nIn that way, I think of the concept of the Batch as both baked deeply into the core concepts of what gets validated, but also sufficiently flexible to work in a streaming system.\nDisclaimer: I am one of the authors of Great Expectations. (Stack Overflow alerts! :))","Q_Score":3,"Tags":"python,great-expectations,amazon-deequ","A_Id":64715840,"CreationDate":"2020-11-06T08:45:00.000","Title":"Data testing framework for data streaming (deequ vs Great Expectations)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a project and it works well when I run the project in pycharm\nBut when I deploy this project on the server, it has a problem\nThe problem is using pandas toolkits\nIt works well when I remove \"import pandas as pd\" from the files on the server, but when I use this toolkit, the project does not work\nIt should be noted that after Deploy, when this package is used in one of the files, the whole project does not work\nI use Apache\nThe version of packages on the server and local is the same\nPandas version is 1.1.2","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":64712258,"Users Score":0,"Answer":"1: Make sure Pandas is installed in your deployment environment.\n2: If you are using shared hosting than perhaps they have some restrictions.","Q_Score":0,"Tags":"python,django,pandas,deployment","A_Id":64712493,"CreationDate":"2020-11-06T09:46:00.000","Title":"Django app does not work after Deploy when I used Pandas","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm really new to web scraping. Is there anyone that could tell me how to search on google.com with Selenium in Python?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":97,"Q_Id":64715022,"Users Score":1,"Answer":"Selenium probably isn't the best. other libraries\/tools would work better. BeautifulSoup is the first one that comes to mind","Q_Score":1,"Tags":"python,selenium","A_Id":64715127,"CreationDate":"2020-11-06T12:51:00.000","Title":"How to search on Google with Selenium in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm preparing a data analysis program with pandas. Users transfer data from the excel file to the program. Column names taken from the Excel file are constantly changing. Therefore, I do not know the column names and data types that I will record in the database. How can I save unfamiliar types of data in the database.The database I use is postqresql. Only if I understand the logic I can move forward. very thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":123,"Q_Id":64717281,"Users Score":2,"Answer":"Relational database are not well suited for storing data do not adhere to a fixed schema.\nI see two options:\n\nAnalyze the data you have and create a new table that fits the data before you insert them into the database.\nThe question is what to do with all these tables in PostgreSQL.\n\nUse a table with a jsonb column (not only this column of course; you need at least a primary key) and format the data you have as JSON.\nThe question is what to do with all these random data.","Q_Score":1,"Tags":"python,sql,pandas,postgresql,dataframe","A_Id":64717565,"CreationDate":"2020-11-06T15:21:00.000","Title":"How can I save unknown data types to the database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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 am trying to get the first(oldest) n rows of data from a table in Azure Table Storage - but am unable to find any documentation that allows doing so via Python. I use an integer-based hash value as my PartitionKey and by default, the table is sorted by PartitionKey. However, I need to fetch the oldest n rows. Is there any way or feasible hack I can use to do this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":235,"Q_Id":64720181,"Users Score":1,"Answer":"Unfortunately there is no solution. Server side sorting is not supported in table storage. If you want to sort by timestamp, you have to set the PartitionKey's value to the timestamp, and then the query result will be sorted by timestamp in the reverse order.","Q_Score":0,"Tags":"python,azure-storage,azure-table-storage","A_Id":64762448,"CreationDate":"2020-11-06T18:54:00.000","Title":"Get oldest n rows from Table in Azure Table Storage using Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having issues installing anaconda silently on some machines.  I am running Anaconda3-2020_07-Windows-x86_64.exe \/InstallationType=AllUsers \/RegisterPython=1 \/AddToPath=1 \/S.  It runs for a bit and creates the Anaconda3 directory in program data but the only files that show up are _conda.exe and uninstall_Anaconda3.exe and the pkgs,Lib,Conda-meta directories, with sub folders and files in them but no python and don't see the rest of the files in the main directory I normally would see on complete install. It also never adds the path environment variables but it registers as installed with windows.  My biggest issue here is there is nothing to go on as to what it is doing.  I have looked everywhere but this thing does not create a logfile.  Am I missing it or is that just an oversight of whoever made this?  If I had a logfile I could troubleshoot this better.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":794,"Q_Id":64722377,"Users Score":0,"Answer":"I'm having the same problem with 2021.05 via SCCM silent install, I had no problem with 2019.03.\nEarly testing suggests that the SCCM option 'Run installation and uninstall program as 32-bit process on 64-bit clients' helps.","Q_Score":0,"Tags":"python,anaconda,logfile,silent","A_Id":69092170,"CreationDate":"2020-11-06T22:24:00.000","Title":"Cannot find Anaconda install logging","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to use curve fit to fit some temperature that looks like a sinusoid function added to a linear function. My initial predictions are way off and I believe it is because I need to adjust p0, however I was wondering if there was a good way to get an initial guess for p0 or if its just an endless game of guess and check. Alternatively, if there is a better way to get the regression line please let me know!\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":487,"Q_Id":64723823,"Users Score":1,"Answer":"This is not algorithmic. It all depends on the model and data. E.g., if there's a sinusoid, a rough guess for the period (e.g. from the distance between maxima) goes a long way etc","Q_Score":0,"Tags":"python,scipy,model,regression,curve-fitting","A_Id":64727388,"CreationDate":"2020-11-07T02:20:00.000","Title":"Is there a good way to optimize p0 in scipy.optimize.curve_fit?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I read through the documentation, but something wasn't clear for me: if I coded a custom layer and then used it in a model, can I just save the model as SavedModel and the custom layer automatically goes within it or do I have to save the custom layer too?\nI tried saving just the model in H5 format and not the custom layer. When I tried to load the model, I had an error on the custom layer not being recognized or something like this. Reading through the documentation, I saw that saving to custom objects to H5 format is a bit more involved. But how does it work with SavedModels?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":64723898,"Users Score":0,"Answer":"If I understand your question, you should simply use tf.keras.models.save_model(<model_object>,'file_name',save_format='tf').\nMy understanding is that the 'tf' format automatically saves the custom layers, so loading doesn't require all libraries be present. This doesn't extend to all custom objects, but I don't know where that distinction lies. If you want to load a model that uses non-layer custom objects you have to use the custom_objects parameter in tf.keras.models.load_model(). This is only necessary if you want to train immediately after loading. If you don't intend to train the model immediately, you should be able to forego custom_objects and just set compile=False in load_model.\nIf you want to use the 'h5' format, you supposedly have to have all libraries\/modules\/packages that the custom object utilizes present and loaded in order for the 'h5' load to work. I know I've done this with an intializer before. This might not matter for layers, but I assume that it does.\nYou also need to implement get_config() and save_config() functions in the custom object definition in order for 'h5' to save and load properly.","Q_Score":0,"Tags":"python,tensorflow,model,save","A_Id":68923767,"CreationDate":"2020-11-07T02:37:00.000","Title":"Saving Tensorflow models with custom layers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I get this error every time I type:\nfrom matplotlib.pyplot import close, figure, plot, axis, grid\nThe error reads:\ndouble free or corruption (top)\nWhat does this mean? How might I address it? This happens even if it is the first thing I type, with no previous commands.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":508,"Q_Id":64723939,"Users Score":1,"Answer":"It sounds like a C-level problem, something with the (malloc) heap.\nI'd try a newer CPython (up to but not including 3.9), or try removing matplotlib and reinstalling it with your current version of CPython.\nBTW, I tried your import with CPython 3.8, and did not get the quoted error; it seemed to import fine.  I did this with a freshly-installed matplotlib.","Q_Score":0,"Tags":"python,matplotlib","A_Id":64724936,"CreationDate":"2020-11-07T02:44:00.000","Title":"What does \"double free or corruption (top)\" mean in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have started learning about lambda functions in python and find them somewhat confusing. are they just shortcuts or are there things you need to program that cannot be accomplished without them  ?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":64724470,"Users Score":0,"Answer":"Lambdas are single-line, unnamed functions.\nThey are rarely useful, and ISTR they were almost removed from Python in the transition from Python 2.x to Python 3.x.\nThey violate Python's design principle \"There should be one-- and preferably only one --obvious way to do it.\"\nIt's almost always better to use a list comprehension, generator expression, or something from the operator module.\nIn many languages that have lambdas, lambdas are allowed to be multiline.  IMO, this gives rise to the software equivalent of a runon sentence.  Fortunately, in Python, lambdas are restricted to a single line.","Q_Score":0,"Tags":"python,lambda","A_Id":64724814,"CreationDate":"2020-11-07T04:37:00.000","Title":"are lambda functions in python necessary or just option shortcuts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can one surelly tell that function retuns an iterable object, which calculates results on demand, and not an iterator, which returns already calculated results?\nFor e.g. function filter() from python's documentation says:\n\nConstruct an iterator from those elements of iterable for which function returns true\n\nReading that I cat tell that this function returns an object which implements iterable protocol but I can't be sure it won't eat up all my memory if use it with generator which reads values from 16gb file untill I read further and see the Note:\n\nNote that filter(function, iterable) is equivalent to the generator expression (item for item in iterable if function(item))\n\nSo, how does one can tell that function calculates returned results on demand and not just iterating over temporary lists which holds already calculated values? I have to inspect sources?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":64725034,"Users Score":1,"Answer":"If the doc says that a function returns an iterator, it's pretty safe to assume it calculates items on the fly to save memory. If it did calculate all its items at once, it would almost certainly return a list.","Q_Score":0,"Tags":"python","A_Id":64725087,"CreationDate":"2020-11-07T06:19:00.000","Title":"How to determine whether function returns an iterable object which calculates results on demand?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to submit a .apk file for a competition. I used tkinter module of python for the same. I am unable to convert my.py with tkinter code to .apk\nI have tried making setup files and exe to apk tools as I converter my file to .exe and I still have my.py\nPlease help!\nNote: Can i convert it into web app and then make .apk","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4837,"Q_Id":64725435,"Users Score":1,"Answer":"Tkinter does not support mobile; it's only for desktop apps. I suggest you use kivy because it's the best for mobile development, and the same code can be used for all platforms.\nYou don't need to modify the code for desktop, mobile, etc. one piece of code is enough.","Q_Score":0,"Tags":"python,android,user-interface,tkinter,web-applications","A_Id":71282985,"CreationDate":"2020-11-07T07:27:00.000","Title":"Python Tkinter to .apk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm getting this error whenever I try to install PyRO:\n\nERROR: Command errored out with exit status 1:\ncommand: 'c:\\users\\singh\\appdata\\local\\programs\\python\\python38-32\\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '\"'\"'C:\\Users\\singh\\AppData\\Local\\Temp\\pip-install-lxpur7nd\\pyro\\setup.py'\"'\"'; file='\"'\"'C:\\Users\\singh\\AppData\\Local\\Temp\\pip-install-lxpur7nd\\pyro\\setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(file);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, file, '\"'\"'exec'\"'\"'))' egg_info --egg-base 'C:\\Users\\singh\\AppData\\Local\\Temp\\pip-pip-egg-info-f9isu850'\ncwd: C:\\Users\\singh\\AppData\\Local\\Temp\\pip-install-lxpur7nd\\pyro\\\nComplete output (6 lines):\nTraceback (most recent call last):\nFile \"\", line 1, in \nFile \"C:\\Users\\singh\\AppData\\Local\\Temp\\pip-install-lxpur7nd\\pyro\\setup.py\", line 23\nexec code in constants\n^\nSyntaxError: Missing parentheses in call to 'exec'\nERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output\n\nI'm installing it using pip install method.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":381,"Q_Id":64726486,"Users Score":0,"Answer":"python 3.9 has a lot of bugs, i tried to install opencv for python and couldn't do so. You can do either of this:\n\nuse the older version of python like python 3.8\/7 or something\nwait till python fixes the bugs, that will be by mid december","Q_Score":0,"Tags":"python,python-3.x,pyro","A_Id":64727842,"CreationDate":"2020-11-07T10:02:00.000","Title":"Getting error while trying to install Pyro Library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a method which prints a pdf report and downloads it to the OS in Odoo 13 upon clicking a button. Now, I need to get (access) the path (where it is downloaded) of this report (file) and store it in ir_attachment table of Odoo. After storing the file (report) path then I want to have a button which fetch this report from it's the path stored in database and shows it in browser for a portal user in website module. I searched a lot but could not find anyway to do it. Can anyone help me if is it possible and if yes how?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":482,"Q_Id":64727272,"Users Score":0,"Answer":"Have you check with this method get_portal_url(report_type='pdf', download=True)?","Q_Score":0,"Tags":"javascript,python,odoo,odoo-12,odoo-13","A_Id":64731033,"CreationDate":"2020-11-07T11:39:00.000","Title":"How to get the path of a pdf report downloaded in a browser in Odoo 13?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i'm building a CNN to identify facial keypoints. i want to make the net more robust, so i thought about applying some zoom-out transforms because most pictures have about the same location of keypoints, so the net doesn't learn much.\nmy approach:\ni want augmented images to keep the original image size so apply MaxPool2d and then random (not equal) padding until the original size is reached.\nfirst question\nis it going to work with simple average padding or zero padding? i'm sure it would be even better if i made the padding appear more like a background but is there a simple way to do that?\nsecond question\nthe keypoints are the target vector, they come as a row vector of 30. i'm getting confused with the logic needed to transform them to the smaller space.\ngenerally if an original point was at (x=5,y=7) it transforms to (x=2,y=3)- i'm not sure about it but so far manually checked and it's correct. but what to do if to keypoints are in the same new pixel? i can't feed the network with less target values.\nthat's it. would be happy to hear your thoughts","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1511,"Q_Id":64727718,"Users Score":2,"Answer":"I suggest to use torchvision.transforms.RandomResizedCrop as a part of your Compose statement. which will give you random zooms AND resize the resulting the images to some standard size. This avoids issues in both your questions.","Q_Score":0,"Tags":"python,neural-network,pytorch,conv-neural-network,data-augmentation","A_Id":64728540,"CreationDate":"2020-11-07T12:38:00.000","Title":"clever image augmentation - random zoom out","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"how do you get only the whole number of a non-integer value without the use of rounding-off? I have searched for it and I seem to be having a hard time.\nFor example:\n\nw = 2.20\nw = 2.00\n\nx = 2.50\nx = 2.00\n\ny = 3.70\ny = 3.00\n\nz = 4.50\nz = 4.00\n\nIs it as simple as this or that might get wrong in some values?\nx = 2.6 or x = 2.5 or x = 2.4\nx = int(x)\nx = 2\n\nIs it really simple as that? Thanks for answering this stewpid question.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":67,"Q_Id":64727741,"Users Score":2,"Answer":"you can   just divided it into (1)\nbut use (\/\/) like this:\nx = x \/\/ 1","Q_Score":1,"Tags":"python,integer","A_Id":64727798,"CreationDate":"2020-11-07T12:40:00.000","Title":"How to get only the whole number without rounding-off?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am preprocessing ImageNet data so all the data is the same shape, (256, 256, 3). My idea was to crop the data to (256, 256). However, I am running into issues because the images are of variable size and some are smaller than 256 in width\/height, or both. Some example dimensions include (194, 150, 3) and (200, 300, 3). Do I just resize all the images to (256, 256)? This would potentially throw off aspect ratio and cause distortions. How do I best approach this? Any examples of this in tensorflow would also be helpful.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":64736281,"Users Score":0,"Answer":"Padding then cropping is probably the good solution.","Q_Score":1,"Tags":"python,tensorflow,reshape,image-preprocessing,imagenet","A_Id":64736402,"CreationDate":"2020-11-08T08:50:00.000","Title":"How to preprocess ImageNet data that is smaller than 256 x 256?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Problem\nWe have a FloatLayout that gets some widgets and loses some (using add_widget and remove_widget) inside a function.The problem is the window gets updated when the function reaches its end. Then Kivy updates the window and user only sees the last results.\nHow to update the window when we are inside a function so user can see results ???\nWhat i tried\nI tried do_layout and _trigger_layout (read that somewhere on SO). None of them did the job (no traceback, no warning, literally no change)\nAlso read Kivy documentation but nothing was helpful there","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":64738133,"Users Score":0,"Answer":"Instead of making all your changes while blocking the gui, use Clock.schedule_interval or Clock.schedule_once to let Kivy go back to rendering in between each change.\nEdit: Also to be clear, your problem is not that you have failed to update the layout, but that you haven't given Kivy any opportunity to render the changes.","Q_Score":1,"Tags":"python,python-3.x,user-interface,kivy,user-experience","A_Id":64738234,"CreationDate":"2020-11-08T12:37:00.000","Title":"How to update the layout inside a function in kivy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to index the 2nd axis of a BxNxM array (the N axis) with B indices and get a BxM array as the result.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":18,"Q_Id":64739112,"Users Score":1,"Answer":"Figured it out. Say the BxNxM array is called A, then the desired output is A[(np.arange(B), indices)].","Q_Score":0,"Tags":"python,numpy,scipy","A_Id":64739316,"CreationDate":"2020-11-08T14:17:00.000","Title":"In Numpy, how can I index an B x N x M array with a size B array of indices to yield a B x M array?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am slightly confused about the scaling concept in Machine learning models.\nIn Classification, if the variables are having a different scale, I usually perform scaling on independent variable and label encoding on Target variable and inverse transform the predicted results to get the actual labels\nIn Regression, if my variables are in different, I know we have to scale the independent variables, should I also scale my Target variable?\nCould someone please help me if my understanding is correct in the above scenario and should I scale my Target variable in Regression models?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":64739128,"Users Score":0,"Answer":"Scaling should only be applied on features since it has an effect on the training procedure, so when all the features (independent variables) are on the same(or similar) scales, generally training goes faster and it converges to a good solution especially if you're using a gradient-based training algorithm like SGD or Adam, but for the target (dependant) variable you don't need scaling since you would just add extra computation that won't affect the quality of the classifier (regressor) you'll get.","Q_Score":0,"Tags":"python,machine-learning,regression,classification","A_Id":64740996,"CreationDate":"2020-11-08T14:18:00.000","Title":"Scaling on Machine Learning Models","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to install OpenCV in a docker container (CentOS).\nI tried installing python first and then tried yum install opencv-contrib but it doesn't work.\nCan someone help me out as to how to install OpenCV in Docker (CentOS)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":225,"Q_Id":64739928,"Users Score":0,"Answer":"To install OpenCV use the command: sudo yum install opencv opencv-devel opencv-python\nAnd when the installation is completed use the command to verify: pkg-config --modversion opencv","Q_Score":2,"Tags":"python,linux,docker,opencv,anaconda","A_Id":64748740,"CreationDate":"2020-11-08T15:39:00.000","Title":"How to install OpenCV in Docker (CentOs)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I had python installed on my device, everything was running perfectly, when I save a 'file.py' it shows the default python icon (the blue and yellow snakes) and it is clear that this is a python file.\nI made a factory reset of the device for many reasons, then i reinstalled python and pip, everything working fine and I'm now running python 3.9.0, except that now the 'file.py' has a blank icon (the white, empty one) and I cannot run it on cmd.\nI don't know what is wrong with it","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":196,"Q_Id":64742874,"Users Score":1,"Answer":"What won't run on cmd? Python command or the .py file?\nIf the python command isn't recognized on cmd then probably Python is not set in your device's env variable PATH;\nI think once you choose Python as default application to open .py files, the python icon will appear on .py files.","Q_Score":0,"Tags":"python","A_Id":64742977,"CreationDate":"2020-11-08T20:47:00.000","Title":"python: .py file icon problem in version 3.9.0","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pyenv generates env in user's home folder, which is a problem for sharing environment\n\nI do not want to install NLP and ML packages for each user\nI do not want to have more than single point of truth when running a project\n\nI am familiar of separate virtualenv package (and that would be my last resort) but wondering if there is a well-known pyenv strategy on that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":163,"Q_Id":64744311,"Users Score":2,"Answer":"Just set PYENV_ROOT for each user:\nexport PYENV_ROOT=\"\/usr\/bin\/.pyenv\"\nThis will make pyenv store environments in \/usr\/bin\/.pyenv and look for existing environments there.\nIf then user needs to restore default pyenv root they can just unset PYENV_ROOT.","Q_Score":0,"Tags":"python,virtualenv,pyenv","A_Id":70217284,"CreationDate":"2020-11-09T00:04:00.000","Title":"share pyenv environent for any user using the project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"I am going to use Kafka as a message broker in my application. This application is written entirely using Python. For a part of this application (Login and Authentication), I need to implement a request-reply messaging system. In other words, the producer needs to get the response of the produced message from the consumer, synchronously.\nIs it feasible using Kafka and its Python libraries (kafka-python, ...) ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1322,"Q_Id":64748185,"Users Score":1,"Answer":"I'm facing the same issue (request-reply for an HTTP hit in my case)\nMy first bet was (100% python):\n\nstart a consumer thread,\npublish the request message (including a request_id)\njoin the consumer thread\nget the answer from the consumer thread\nThe consumer thread subscribe to the reply topic (seeked to end) and deals with received messages until finding the request_id (modulus  timeout)\n\nIf it works for a basic testing, unfortunatly, creating a KafkaConsumer object is a slow process (~300ms) so it's not an option for a system with massive traffic.\nIn addition, if your system deals with parallel request-reply (for example, multi-threaded like a web server is) you'll need to create a KafkaConsumer dedicated to request_id (basically by using request_id as consumer_group) to avoid to have reply to request published by thread-A consumed (and ignored) by thread-B.\nSo you can't here reclycle your KafkaConsumer and have to pay the creation time for each request (in addition to processing time on backend).\nIf your request-reply processing is not parallelizable you can try to keep the KafkaConsuser object available for threads started to get answer\nThe only solution I can see at this point is to use a DB (relational\/noSQL):\n\nrequestor store request_id in DB (as local as possible) aznd publish request in kafka\nrequestor poll DB until finding answer to request_id\nIn parallel, a consumer process receiving messages from reply topic and storing result in DB\n\nBut I don't like polling..... It wil generate heavy load on DB in a massive traffic system\nMy 2CTS","Q_Score":7,"Tags":"python,apache-kafka,synchronous,kafka-python","A_Id":66068833,"CreationDate":"2020-11-09T08:35:00.000","Title":"How to implement request-reply (synchronous) messaging paradigm in Kafka?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on a monitor with python to detect new products on websites. I would like to run multiple instances to increase the chance of detecting something.\nMy goal is to decrease the workload for the CPU to be able to run more instances. A function like time.sleep is not a real option since it decreases the likelihood to detect a product.\nI have already brought the script down to a minimum. Are there any other options to minimize the workload?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":64753256,"Users Score":0,"Answer":"It's hard to answer without more details on how the monitor works and what is consuming the CPU. I would suggest you use a profiling tool (There is one in PyCharm for example) that will monitor your function calls and the time they took. This way you can focus on what takes too long or consumes to much resources and improve those parts accordingly.","Q_Score":0,"Tags":"python,request,cpu,monitor","A_Id":64753341,"CreationDate":"2020-11-09T14:12:00.000","Title":"Decrease the workload used by python monitor task for the cpu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a linux console application which behaves in a similar way to bash in that it receives commands while it's running in the same way and I want to use it via Python (use python to send inputs and receive outputs to\/from the application while it\u2019s running).\nThe application in question is custom Minecraft server software, it does not appear to have a useable API\/SDK for my needs\nHow would I be able to run it, capture its output and interact with it (Enter commands into the program) using Python code.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":204,"Q_Id":64754327,"Users Score":0,"Answer":"You can use os.sytem(command) to just run a command, or if you want the output then try subprocess.check_output(commands), which returns whatever is returned by bash. Pass a list of commands to this, for example, to run node index.js, you'd pass [\"node\", \"index.js\"]","Q_Score":0,"Tags":"python-3.x,linux,console,console-application","A_Id":64755783,"CreationDate":"2020-11-09T15:17:00.000","Title":"How to interact with console application using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So, I've googled prior to asking this, obviously, however, there doesn't seem to be much mention on these modes directly. Tensorflow documentation mentions \"test\" mode in passing which, upon further reading, didn't make very much sense to me.\nFrom what I've gathered, my best shot at this is that to reduce ram, when your model is in prediction mode, you just use a pretrained model to make some predictions based on your input?\nIf someone could help with this and help me understand, I would be extremely grateful.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":26,"Q_Id":64755952,"Users Score":0,"Answer":"Training refers to the part where your neural network learns. By learning I mean how your model changes it's weights to improve it's performance on a task given a dataset. This is achieved using the backpropogation algorithm.\nPredicting, on the other hand, does not involve any learning. It is only to see how well your model performs after it has been trained. There are no changes made to the model when it is in prediction mode.","Q_Score":0,"Tags":"python,tensorflow,deep-learning,neural-network","A_Id":64756216,"CreationDate":"2020-11-09T17:00:00.000","Title":"Tensorflow - What does Training and Prediction mode mean when making a model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm coding this for my class but I cannot figure out how to split using range.\nfind spell_list length\nuse range() to iterate each half of spell_list\nlabel & print the first and second halves\nspell_list = [\"Tuesday\", \"Wednesday\", \"February\", \"November\", \"Annual\", \"Calendar\", \"Solstice\"]","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":596,"Q_Id":64756944,"Users Score":1,"Answer":"if you want to iterate over the half of the list you can use range(len(list)\/\/2) where len(list)\/\/2 is half of the items in list","Q_Score":0,"Tags":"python,range","A_Id":64757008,"CreationDate":"2020-11-09T18:06:00.000","Title":"How do I split lists in python using range?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having troubles trying to understand why VSCode uses a different pip version.\nI have two python versions installed in Windows, python38 and python39, if I open the win 10 terminal I got pip version 20.2.4 when running pip3 --version, but if i run the same command inside the VSCode terminal i got pip 20.2.2 from c:\\python38\\lib\\site-packages\\pip (python 3.8).\nBoth terminals are running PowerShell 7.0.3 on the same profile.\nAlso removing python38 from the global PATH variable gives command not found error only in vscode, in windows terminal keeps working as i described before.\nCould not fix this so I deleted all temporary and profile data of vscode and can now run pip from within its terminal.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1918,"Q_Id":64756977,"Users Score":0,"Answer":"Try changing your interpreter: ctrl+shift+p->select python interpreter and choose the one you want because  pip is part of the python environment, and therefore the version of pip you are using is tied to the active python interpreter (cc @DragonBobZ)","Q_Score":0,"Tags":"python,visual-studio-code,pip","A_Id":64757083,"CreationDate":"2020-11-09T18:08:00.000","Title":"PIP version VSCode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having troubles trying to understand why VSCode uses a different pip version.\nI have two python versions installed in Windows, python38 and python39, if I open the win 10 terminal I got pip version 20.2.4 when running pip3 --version, but if i run the same command inside the VSCode terminal i got pip 20.2.2 from c:\\python38\\lib\\site-packages\\pip (python 3.8).\nBoth terminals are running PowerShell 7.0.3 on the same profile.\nAlso removing python38 from the global PATH variable gives command not found error only in vscode, in windows terminal keeps working as i described before.\nCould not fix this so I deleted all temporary and profile data of vscode and can now run pip from within its terminal.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1918,"Q_Id":64756977,"Users Score":0,"Answer":"It's all about the Process PATH. Check $Env:PATH in both. Starting from the left, the first folder with pip3.exe is used. You have probably selected a python interpreter for VS Code, which then adds it in the PATH.\nYou can also check the location of the used pip3.exe with Get-Command pip3. (might be helpful in debugging)","Q_Score":0,"Tags":"python,visual-studio-code,pip","A_Id":64757159,"CreationDate":"2020-11-09T18:08:00.000","Title":"PIP version VSCode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having troubles trying to understand why VSCode uses a different pip version.\nI have two python versions installed in Windows, python38 and python39, if I open the win 10 terminal I got pip version 20.2.4 when running pip3 --version, but if i run the same command inside the VSCode terminal i got pip 20.2.2 from c:\\python38\\lib\\site-packages\\pip (python 3.8).\nBoth terminals are running PowerShell 7.0.3 on the same profile.\nAlso removing python38 from the global PATH variable gives command not found error only in vscode, in windows terminal keeps working as i described before.\nCould not fix this so I deleted all temporary and profile data of vscode and can now run pip from within its terminal.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1918,"Q_Id":64756977,"Users Score":0,"Answer":"It appears something got fixed after deleting all profile and settings data from visual studio code, it runs pip now form the terminal inside vscode.","Q_Score":0,"Tags":"python,visual-studio-code,pip","A_Id":64762592,"CreationDate":"2020-11-09T18:08:00.000","Title":"PIP version VSCode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to build a neural network accepting data from a particular .csv file where most columns' type is object, i.e. they are neither numerical nor string. My question is: can a neural network accept such an input? If not, how should I overcome such adversity?, and, if so, where could I learn more about it? I am working with Python.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":99,"Q_Id":64758511,"Users Score":0,"Answer":"Simple answer is no.\nTwo key components in neural networks are matrix multiplications and activation functions, both are operate for numbers, integer (rarely) or floating point. In case of strings, you need to encode them into vectors of numbers first before you can use them in neural networks. Same for objects.\nTake pictures as example, the convolutional neural network will treat pictures as pixels in 2D and then present them as matrix of numbers. So same in your case, you need to present your \"object\" (for whatever it is) as tensors (i.e. n-dimensional arrays of floats) first.","Q_Score":0,"Tags":"python,keras,neural-network","A_Id":64758583,"CreationDate":"2020-11-09T20:03:00.000","Title":"Can a neural network accept an object (i.e. not numerical nor string) as an input?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I install modules on my mac and then I install with pip again and it says requirement satisfied e.g pip install pygame.\nI go into pycharm and it comes up with saying Error-Module not found, I install in the pycharm terminal and it shows requirement satisfied and it still says Module cannot be found and its really annoying me. If anyone can help that would be greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":64758837,"Users Score":0,"Answer":"the problem is probably is that your IDE is using a different python interpreter from that you're installing your modules on.\ntry the following:\nin your terminal, where you install modules using pip, go with python --version and see what it shows. then go to Pycharm > preferences > project > project interpreter. and make sure it's the same or change to desired one.","Q_Score":0,"Tags":"python","A_Id":64758910,"CreationDate":"2020-11-09T20:29:00.000","Title":"How to install modules on a mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on an automated ML (Regression) algorithm where the flow of process is:\nUser uploads a data -- Data Cleaning --  Encoding(Target Encoder) -- Fitting model -- results.\nI am completely fine until this point, my confusion is when the user wants to test this in an unseen data without target variable, then I need to again perform Data cleaning -- Encoding and encoding technique I have used while fitting the model can work only if there is a target variable (unseen data will not have a target variable) and I cannot change the Encoding technique on unseen data as the testing data needs to go through the same procedure as the data used while fitting the model as per my knowledge.\nCould someone please help me in finding a way to overcome this issue or any suggestions would be of great help.\nThanks in advace.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":880,"Q_Id":64759579,"Users Score":1,"Answer":"What you have outlined above is the training pipeline. In a test (inference) scenario, the pipeline would be slightly modified.  Data upload and data cleaning should be performed identically as in the training scenario, but as you acknowledge there is no need (or even possibility) for performing target encoding since the target is what we are trying to predict using the model during testing. In this case encoding is not performed, and the model is used to predict the target based on the cleaned data.\nIn short, the model pipeline should be nearly identical for train\/test, with the exceptions that target encoding is not performed in the test scenario, and the final step will be a fit in the train scenario and a predict in the testing scenario.","Q_Score":4,"Tags":"python,machine-learning,encoding,prediction,test-data","A_Id":65062709,"CreationDate":"2020-11-09T21:34:00.000","Title":"Predicting unseen data on Target variable based Encoding Technique","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on an automated ML (Regression) algorithm where the flow of process is:\nUser uploads a data -- Data Cleaning --  Encoding(Target Encoder) -- Fitting model -- results.\nI am completely fine until this point, my confusion is when the user wants to test this in an unseen data without target variable, then I need to again perform Data cleaning -- Encoding and encoding technique I have used while fitting the model can work only if there is a target variable (unseen data will not have a target variable) and I cannot change the Encoding technique on unseen data as the testing data needs to go through the same procedure as the data used while fitting the model as per my knowledge.\nCould someone please help me in finding a way to overcome this issue or any suggestions would be of great help.\nThanks in advace.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":880,"Q_Id":64759579,"Users Score":0,"Answer":"For predictions on unseen data, you should simply omit the target encoding from your pipeline. You can therefore implement two versions of the pipeline.\nThis would be your training\/testing\/cross-validation pipeline:\nUser uploads training data -- Data Cleaning -- Encoding(Target Encoder) -- Training the model -- result\nNote: use fit_transform on the encoding when running training data, and transform when running test or validation data to avoid data leakage\nAnd this would be your prediction pipeline:\nUser uploads testing data -- Data Cleaning -- predictions using trained models","Q_Score":4,"Tags":"python,machine-learning,encoding,prediction,test-data","A_Id":65062860,"CreationDate":"2020-11-09T21:34:00.000","Title":"Predicting unseen data on Target variable based Encoding Technique","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently working with someone on a Windows 10 that is unable to install Pip for Python on their machine due to an SSL Certificate Error.\nWe run this command successfully through the command prompt, and we do see the get-pip.py on the machine after running it.\ncurl https:\/\/bootstrap.pypa.io\/get-pip.py -o get-pip.py\nWhen we try to run the file with python get-pip.py we get a bunch of errors regarding SSL Certificate. It appears that something may be blocking the connection, but we're unsure how to proceed. It seems that all the answers we're finding are regarding pip unable to install other packages.\nDoes anyone have an idea what may be preventing us from installing pip successfully on Windows 10?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":64759797,"Users Score":0,"Answer":"Not sure why there is an issue on your certificates, but all python 3 installations for Windows include pip by default, you just need to call it this way:\npython -m pip","Q_Score":0,"Tags":"python,windows,pip,windows-10","A_Id":64759894,"CreationDate":"2020-11-09T21:54:00.000","Title":"Windows 10 Unable to Install Pip due to SSL Certificate Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"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've been searching for a long time and still couldn't find an answer...\nI can find the element by literally searching through every single divs in the website\nbut that's obviously very stupid, is there a way to trace back xpath so next time\nI can use the xpath it got earlier when I rerun the program?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":64763149,"Users Score":0,"Answer":"To locate the full Xpath of an element, you can simply use the Google Chrome console and inspect the element that you want, do\nRight Click -> Copy -> Copy Xpath\/Copy Full Xpath\nor in code, walk up the tree from your element to root and compile a full Xpath.\nIf you are talking a partial Xpath locator such as \/\/input[@id='hello'], there is no implemented feature for that yet. However, you can write your own function that takes in an element and analyzes it to get its attribute, such as its element type and id, and return a complied Xpath.","Q_Score":0,"Tags":"python","A_Id":64763354,"CreationDate":"2020-11-10T05:01:00.000","Title":"After locating an element with selenium, can you trace back\/report back the xpath of the element?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run a .exe file with required dll's in same folder with os.system or subprocess.call(), which is woriking perfectly fine in local machine but after deployment even os.system('date') is resulting in 0. Is there anything I can do to solve this issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":64763280,"Users Score":0,"Answer":"use the check param of the subprocess.call to check the error code.\ncheck if your application needs vcredist to be installed.\nUsed dependency walker to see what are dependencies of your application and make sure all the dependencies are available in your target environment.","Q_Score":0,"Tags":"python-3.x,azure-function-app","A_Id":64763750,"CreationDate":"2020-11-10T05:17:00.000","Title":"os.system or subprocess.call() not working in azure function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Ive got some import problems in python. When I want to import the PyQt5 library I just get the error \"No module named 'PyQt5'\". The folder is in the path C:\\Python\\Python37\\Lib\\PyQt5. I can import tkinter and the folder is in the same path as PyQt5\nCode: from PyQt5 import QtCore, QtGui, QtWidgets\nError:ModuleNotFoundError: No module named 'PyQt5'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":103,"Q_Id":64764086,"Users Score":0,"Answer":"if you are using a virtual environment, the modules available in a normal machine can't be imported unless you grant permission.\n\nif you are using pycharm, every project is a virtual wrapper. so do install again or change interpreter preference in pycharm (if you installed locally).\nDo install again through:\n1. terminal: Type\npip install PyQt5\n2. if you are using pycharm, install from the interpreter preferences.","Q_Score":0,"Tags":"python,pycharm","A_Id":64764271,"CreationDate":"2020-11-10T06:47:00.000","Title":"Import problems python\/pyqt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using python with anaconda.\nAttributeError: module 'pydub' has no attribute 'playback'\nI get the error above when I try to run the following statement:\nspeech = pydub.AudioSegment.from_mp3(\"temp_speak.mp3\")\npydub.playback.play(speech)\nthe problem is , I can see there is a module called playback in the auto completition of visual studio code , besides that , when I get to the\n~\/anaconda3\/envs\/env_name\/lib\/python3.7\/site-packages\/pydub\nI can see that there is a file named playback and its not corrupted.\nhere is the output of ls :\naudio_segment.py  generators.py     playback.py   scipy_effects.py\neffects.py        __init__.py       pyaudioop.py  silence.py\nexceptions.py     logging_utils.py  __pycache__   utils.py\nAnd I'm sure that I'm activating the environment before I run my script.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":64764576,"Users Score":0,"Answer":"I solved the problem by importing the playback module serperately. Still can not understand why the interpreter thinks playback module is an attribute.","Q_Score":0,"Tags":"python-3.x,ubuntu,anaconda,conda,pydub","A_Id":64780817,"CreationDate":"2020-11-10T07:33:00.000","Title":"Python can not find an installed module in the conda env","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python files (named in same way) in different folders. I want to run all python files at the same time with one script, any of the terminals (of the executed files) should not to be closed when the new terminal is opened. Which means, I want them to run simultaneously, each in a new\/different terminal. What kind of script could do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":129,"Q_Id":64766611,"Users Score":0,"Answer":"SOLVED\nI just had to use:\n\nsubprocess.Popen(\"python pathtoeachfile\/\/file.py\", creationflags=subprocess.CREATE_NEW_CONSOLE)\n\nand loop over my files.","Q_Score":1,"Tags":"python,terminal","A_Id":64775873,"CreationDate":"2020-11-10T09:56:00.000","Title":"How to run multiple python files simultaneously?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have many categorical variables which exist in my test set but don't in my train set. They are important so I can't drop them. Should I combine train and test set or what other solution should I make?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":527,"Q_Id":64768676,"Users Score":0,"Answer":"How did you end up in this situation? Normally you take a dataset and divide it into two subsets.  The first subset is used to fit the model and is referred to as the training dataset. The second subset is not used to train the model; instead, the input element of the dataset is provided to the model, then predictions are made and compared to the expected values. This second dataset is referred to as the test dataset.\nBut it is clear that, because they originate from the same original dataset, that they both have the same categorical variables.","Q_Score":0,"Tags":"python,machine-learning,artificial-intelligence","A_Id":64768749,"CreationDate":"2020-11-10T12:09:00.000","Title":"How to solve mismatch in train and test set after categorical encoding?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i'm solliciting you today because i've a problem with selenium.\nmy goal is to make a full automated bot that create an account with parsed details (mail, pass, birth date...) So far, i've managed to almost create the bot (i just need to access to gmail and get the confirmation code).\nMy problem is here, because i've tried a lot of things, i have a Failed to load resource: the server responded with a status of 429 ()\nSo, i guess, instagram is blocking me.\nhow could i bypass this ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8428,"Q_Id":64769138,"Users Score":0,"Answer":"The answer is in the description of the HTTP error code. You are being blocked because you made too many requests in a short time.\nReduce the rate at which your bot makes requests and see if that helps. As far as I know there's no way to \"bypass\" this check by the server.\nCheck if the response header has a Retry-After value to tell you when you can try again.","Q_Score":1,"Tags":"python,selenium,instagram,http-status-code-429","A_Id":64769229,"CreationDate":"2020-11-10T12:41:00.000","Title":"How can I bypass the 429-error from www.instagram.com?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i'm solliciting you today because i've a problem with selenium.\nmy goal is to make a full automated bot that create an account with parsed details (mail, pass, birth date...) So far, i've managed to almost create the bot (i just need to access to gmail and get the confirmation code).\nMy problem is here, because i've tried a lot of things, i have a Failed to load resource: the server responded with a status of 429 ()\nSo, i guess, instagram is blocking me.\nhow could i bypass this ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8428,"Q_Id":64769138,"Users Score":0,"Answer":"Status code of 429 means that you've bombarded Instagram's server too many times ,and that is why Instagram has blocked your ip.\nThis is done mainly to prevent from DDOS attacks.\nBest thing would be to try after some time ( there might be a Retry-After header in the response).\nAlso, increase the time interval between each request and set the specific count of  number of requests made within a specified time (let's say 1 hr).","Q_Score":1,"Tags":"python,selenium,instagram,http-status-code-429","A_Id":64769319,"CreationDate":"2020-11-10T12:41:00.000","Title":"How can I bypass the 429-error from www.instagram.com?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to find a way to cancel Airflow dag run while it is being executed. (whichever task it is at that moment). I wonder if I can set the status to \"failed\" while dag is running?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":64770232,"Users Score":0,"Answer":"yes , you can just click on task that is running and mark as failed. This will fail all downstream tasks and then DAG eventually","Q_Score":0,"Tags":"python,airflow","A_Id":64777700,"CreationDate":"2020-11-10T13:52:00.000","Title":"Is there a way to cancel Airflow dag run while it is being executed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I read in a few places that if you're using etags you might run into issues if your app is horizontally scaled. Does Django's ConditionalGetMiddleware work out of the box if you run multiple app servers behind a load balancer?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":64772860,"Users Score":0,"Answer":"I didn't end up using etags, instead I used the Last-Modified header.","Q_Score":0,"Tags":"python,django,wagtail","A_Id":64794580,"CreationDate":"2020-11-10T16:31:00.000","Title":"Does Django's ConditionalGetMiddleware play nicely with multiple servers behind a load balancer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using scrapy to collect data. Running spiders using scrapyd. The file with the results is added by default to\n\n\/data\/scrapyd\/items\/ {spider_name }\/ {job_id }.jl\n\njob_id - Installs scrapyd. Please tell me if it is possible to manually specify the title instead of job_id?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":64773379,"Users Score":0,"Answer":"curl http:\/\/localhost:6800\/schedule.json -d project=project_name -d spider=spider_name -d jobid=custom_jobid","Q_Score":0,"Tags":"python,scrapy,scrapyd","A_Id":64775985,"CreationDate":"2020-11-10T17:02:00.000","Title":"set the format of the scrapyd output file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How do you get a Ruby, Python and Node.js development environments running on Apple Silicon architecture. What about virtualization software e.g. Docker?","AnswerCount":4,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":18717,"Q_Id":64774787,"Users Score":-15,"Answer":"Seems everything will work as is...\nFrom the event presentation they said \"Existing Mac apps that have not been updated to Universal will run seamlessly with Apple\u2019s Rosetta 2 technology.\"","Q_Score":32,"Tags":"python,node.js,ruby,docker,apple-silicon","A_Id":64775397,"CreationDate":"2020-11-10T18:37:00.000","Title":"Running Ruby, Node, Python and Docker on the new Apple Silicon architecture?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm using selenium, and I want to get that 20. Is there any way to do it?\n<div _ngcontent-c12=\"\" class=\"percentage\"><p _ngcontent-c12=\"\">20<\/p><\/div>","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":76,"Q_Id":64777902,"Users Score":1,"Answer":"The getText() applies to any element found with Selenium and retrieves its innerText. You could locate the element via whatever way you want, and then apply the method getText().\nExample: driver.find_element_by_xpath(\"Insert\/Element\/XPath\/Here\").getText()","Q_Score":0,"Tags":"python,python-3.x,python-2.7,selenium,selenium-chromedriver","A_Id":64777968,"CreationDate":"2020-11-10T22:46:00.000","Title":"Get this element attribute via selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a problem with running my Python programs after installing a new package. The error message that I am getting states:\n\nRuntimeError: The current Numpy installation (\"[Location of file]\") fails to pass a sanity check  due to a bug in the windows\nruntime.See this issue for more information: [URL]\n\nI use VS code.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7919,"Q_Id":64778222,"Users Score":9,"Answer":"Open the command prompt.\nType pip install --upgrade numpy==1.19.3\n\nThe current numpy version is having some bugs.\nYou can use --upgrade to upgrade and downgrade packages","Q_Score":4,"Tags":"python,python-3.x,numpy","A_Id":64778223,"CreationDate":"2020-11-10T23:20:00.000","Title":"How to fix \"RuntimeError: The current Numpy installation fails to pass a sanity check due to a bug in the windows runtime.\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a problem with running my Python programs after installing a new package. The error message that I am getting states:\n\nRuntimeError: The current Numpy installation (\"[Location of file]\") fails to pass a sanity check  due to a bug in the windows\nruntime.See this issue for more information: [URL]\n\nI use VS code.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":7919,"Q_Id":64778222,"Users Score":3,"Answer":"This error occurs when using some Numpy versions. So uninstalling your current version and installing 1.19.3 will work.\n\nsudo pip uninstall numpy\n\npip install --upgrade numpy==1.19.3","Q_Score":4,"Tags":"python,python-3.x,numpy","A_Id":64778275,"CreationDate":"2020-11-10T23:20:00.000","Title":"How to fix \"RuntimeError: The current Numpy installation fails to pass a sanity check due to a bug in the windows runtime.\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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 want to use the new positional only arguments syntax defined in PEP570, but I also want to maintain compatibility with python 3.7 (directly running the script with def f(a, \/, b): directly results in a syntax error). Is there anyway to do this?\nIf there isn't, for package maintainers, do they have to refrain from using the new feature until python 3.7 support is dropped?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":64779370,"Users Score":2,"Answer":"Short answer: No, there is no way to do this.\nI suppose technically you might be able to rig up a hack in your setup.py to programmatically remove the positional-only syntax when installed on an older version of Python. But that's getting into extreme kludge territory; in practice, your choices are:\n\nDon't use positional-only parameters until 3.7 is out of support\nMaintain separate code bases for 3.7 and earlier vs. 3.8+\nDon't support 3.7 and earlier in your own project even though it's still a supported version of Python; require users to update (the effort involved in updating from 3.x to 3.x+1 is not extreme; this isn't like dropping support for Python 2 ten years ago or anything)","Q_Score":1,"Tags":"python,python-3.x,python-3.7,python-3.8,pep570","A_Id":64779425,"CreationDate":"2020-11-11T01:55:00.000","Title":"Positional only parameters compatibility with python 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"My company offers a financial product (on-prem) built in C#, SQL Server (back end) and Angular (front end) with Microsoft IIS as web server. The back end is mostly done in the database layer, using a bunch of dynamic SQL\/stored procedures, where the C# part mostly handles communication with the front end.\nNow we want to introduce a machine learning product into the same front end. However, the issue is that the data science team codes in Python. Instead of having C# execute Python scripts, we've talked about making a Python micro service. This would allow the data science team to work independently.\nThe service would be a ML app that's build into a Python web framework (such as Django, FastAPI, etc) and then containerized using Docker. The app will also handle authentication. Communication to and from the app is through RESTful API's and a DB connection to a on-prem database. We assume that the primary product and the microservice is running on the same server (\"next\" to each other).\nWe want the front end to communicate with both back ends (the primary product and the microservice). Can this be done? Or more importantly, should this be done?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":518,"Q_Id":64781359,"Users Score":3,"Answer":"Yes it can be done as i can understand your backends are REST services as long as they are REST nothing is gonna change also Angular has good HttpClient wrappers which will handle all the REST call easily and nicely","Q_Score":0,"Tags":"python,c#,angular,docker,iis","A_Id":64781772,"CreationDate":"2020-11-11T06:12:00.000","Title":"Can a frontend (in Angular) handle multiple backends?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My company offers a financial product (on-prem) built in C#, SQL Server (back end) and Angular (front end) with Microsoft IIS as web server. The back end is mostly done in the database layer, using a bunch of dynamic SQL\/stored procedures, where the C# part mostly handles communication with the front end.\nNow we want to introduce a machine learning product into the same front end. However, the issue is that the data science team codes in Python. Instead of having C# execute Python scripts, we've talked about making a Python micro service. This would allow the data science team to work independently.\nThe service would be a ML app that's build into a Python web framework (such as Django, FastAPI, etc) and then containerized using Docker. The app will also handle authentication. Communication to and from the app is through RESTful API's and a DB connection to a on-prem database. We assume that the primary product and the microservice is running on the same server (\"next\" to each other).\nWe want the front end to communicate with both back ends (the primary product and the microservice). Can this be done? Or more importantly, should this be done?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":518,"Q_Id":64781359,"Users Score":3,"Answer":"Yes, Angular is a front-end which is a client so it is not care about the language of REST APIs so it can deal with different APIs on different hosts with different languages.","Q_Score":0,"Tags":"python,c#,angular,docker,iis","A_Id":64781446,"CreationDate":"2020-11-11T06:12:00.000","Title":"Can a frontend (in Angular) handle multiple backends?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can you please help me i figuring this out.\nWhile reading a .docx file from python-docx (docx.Document(file_name)), how can I detect if the docx file is correct or corrupt.\nI've got some cases where these input docx files are either empty or corrupt.\nHow can I flag these cases using this library","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":398,"Q_Id":64784422,"Users Score":1,"Answer":"There is no such feature in python-docx. Part of the reason is that while a file could be determined to be valid or invalid according to the schema in the ISO specification, many small discrepancies are permitted by each client. What is permitted varies between clients; some things that LibreOffice will accept produce a repair error in Microsoft Word, for example.\nThe only reliable way to determine this is to attempt to open the file with the target client, perhaps using automation like VBA in the case of Microsoft Word.","Q_Score":0,"Tags":"python,python-docx","A_Id":64792695,"CreationDate":"2020-11-11T10:12:00.000","Title":"Detecting corrupt document files with python-docx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"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 currently have a script that automates sending Whatsapp messages. It takes an excel file full of contacts, receives a message argument and then sends the message to each contact. It's purpose is to help automate sending the same message about different services being offered to a bunch of groups.\nI am making the program for a family member who is computer illiterate and am hoping to make some simple UI for them so they never have to interact with the code.\nI have already been playing around in tkinter, and have figured out how to open a dialog to select the Excel file that needs to be used. I am confused about how the rest of the program would functionally work and if this is feasible for someone who has never used Tkinter before and is on a short deadline.\nI was thinking it would look something like a button, to open up the dialog to choose the Excel file. A text box, to fill in the message. And, another button to open up a dialog to choose a photo to be sent along the message. Then once all that was done the program would run.\nIs this functionally possible, and is Tkinter the best option to pursue? Also is this feasible first project for a novice Tkinter user?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":64,"Q_Id":64792366,"Users Score":1,"Answer":"Python is best for backend\n\nHey, so I think Python isn't the best language for UI at all.\nIn my opinion it is quite difficult to make a real good looking program with tkinter, but as I said before, Python is more for backend programming. But tkinter is not a bad choice for a simple program - if not the best. Also, the advantage of a tkinter program is that you can write your code and the GUI code in one file, which makes the program a bit more compact\nBut if you want a simple GUI program tkinter is you first choice","Q_Score":0,"Tags":"python,user-interface,tkinter","A_Id":64792441,"CreationDate":"2020-11-11T18:45:00.000","Title":"Making a python UI - is Tkinter the best option?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"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":"How can I read a csv file from s3 without few values.\nEg: list [a,b]\nExcept the values a and b. I need to read all the other values in the csv. I know how to read the whole csv from s3. sqlContext.read.csv(s3_path, header=True)  but how do I exclude these 2 values from the file and read the rest of the file.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":120,"Q_Id":64795124,"Users Score":1,"Answer":"You don't.  A file is a sequential storage medium.  A CSV file is a form of text file: it's character-indexed.  Therefore, to exclude columns, you have to first read and process the characters to find the column boundaries.\nEven if you could magically find those boundaries, you would have to seek past those locations; this would likely cost you more time than simply reading and ignoring the characters, since you would be interrupting the usual, smooth block-transfer instructions that drive most file buffering.\nAs the comments tell you, simply read the file as is and discard the unwanted data as part of your data cleansing.  If you need the file repeatedly, then cleanse it once, and use that version for your program.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3","A_Id":64795271,"CreationDate":"2020-11-11T22:28:00.000","Title":"Read a csv file from s3 excluding some values","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have one virtual environment. How can I set the virtual python interpreter for my python file which is there in the virtual env file??? I cant find any solution.\nExample: I want to set this file to work with the Python interpreter in the virtual env.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":64798556,"Users Score":0,"Answer":"You need to give the exact path of the python which is present in the Virtual enviroment.\nFor Example:\nYour Virtual Environment path: \/home\/user\/myEnv\/\nYour python bin location will be: \/home\/user\/myEnv\/bin\/python\nYou need to run  \/home\/user\/myEnv\/bin\/python <filename>.py","Q_Score":0,"Tags":"python,virtualenv,interpreter","A_Id":64798703,"CreationDate":"2020-11-12T05:48:00.000","Title":"Set interpreter for Python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had Anaconda installed as well as Python3 and this was causing some conflicts. I removed Anaconda and ensured my PATH variables all point to the Python3 install at C:\\Users\\me\\AppData\\Local\\Programs\\Python\\Python38-32\nI have opened a project in PyCharm and set the python interpreter to that very path: no venv in case it was causing problems.\nHowever, when CTRL+SHIFT+F10 to run it states No Python at 'C:\\Users\\me\\Anaconda3\\python.exe'\nI have googled this for the past two hours and all I'm finding is \"you haven't installed Python\" or \"set up the PyCharm interpreter to point to the python executable\" which I have done.\nI have even reinstalled Pycharm.\nPlease can someone suggest what I am doing wrong? There is no sign of Anaconda in the system or in the PyCharm terminal interpreter\/project interpreter Thanks.\nEdit:\nForgot to mention, in the Project > Python Interpreter settings I can see the interpreter and all the packages just fine. On the face of it: Everything is working fine. But run-time is giving me the anaconda install dir error.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":64803026,"Users Score":0,"Answer":"I don't know what caused this problem but it resolved itself. Sorry I cannot offer any insights.","Q_Score":0,"Tags":"python,pycharm,interpreter","A_Id":65648832,"CreationDate":"2020-11-12T11:26:00.000","Title":"Pycharm runtime: No Python at dir\\that\\doesnt\\exist","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had Anaconda installed as well as Python3 and this was causing some conflicts. I removed Anaconda and ensured my PATH variables all point to the Python3 install at C:\\Users\\me\\AppData\\Local\\Programs\\Python\\Python38-32\nI have opened a project in PyCharm and set the python interpreter to that very path: no venv in case it was causing problems.\nHowever, when CTRL+SHIFT+F10 to run it states No Python at 'C:\\Users\\me\\Anaconda3\\python.exe'\nI have googled this for the past two hours and all I'm finding is \"you haven't installed Python\" or \"set up the PyCharm interpreter to point to the python executable\" which I have done.\nI have even reinstalled Pycharm.\nPlease can someone suggest what I am doing wrong? There is no sign of Anaconda in the system or in the PyCharm terminal interpreter\/project interpreter Thanks.\nEdit:\nForgot to mention, in the Project > Python Interpreter settings I can see the interpreter and all the packages just fine. On the face of it: Everything is working fine. But run-time is giving me the anaconda install dir error.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":64803026,"Users Score":0,"Answer":"Try restarting pycharm once...if not your System..Comment here if it doesn't solve the issue.","Q_Score":0,"Tags":"python,pycharm,interpreter","A_Id":64803921,"CreationDate":"2020-11-12T11:26:00.000","Title":"Pycharm runtime: No Python at dir\\that\\doesnt\\exist","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to link SPSS's python (Edit\/Options\/File Locations\/Python installation) to an Anaconda user-created environment. The only thing I could figure out was to point SPSS to Anaconda install folder, and SPSS then uses the base environment.\nIs there a way to make SPSS use another (user-created) environment ? I tried pointing SPSS to the new env's folder, but all I got was 'python installation not found'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":160,"Q_Id":64803069,"Users Score":0,"Answer":"IBM SPSS Statistics has the ability to use an external python besides the one installed by default with the program.\nOnce you've installed that external Python, you should be able to point to it in the Statistics UI under \"Edit -> Options -> File Locations\".\nMake sure you have the correct path to the python executable specified here.","Q_Score":3,"Tags":"python,anaconda,spss","A_Id":65226174,"CreationDate":"2020-11-12T11:30:00.000","Title":"Setting SPSS 26 python to an Anaconda user-created environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to let users connect their domains to my site.\nFor example, a user has bought example.com (the domain) and wants that when someone types example.com in the browser, what the browser shows is my app. I have everything configured and working except for the ALLOWED_HOSTS setting. If I add manually the domain to my ALLOWED_HOSTS it works. But, in production server, users will be creating this connections at anytime, I can't be adding this lines manually and restarting the server.\nIs there a different way of achievings this without making\nALLOWED_HOSTS = ['*',]\nIf there is no other way, I'm not sure which is the safest way to check request.get_host() in a middleware. If someone could guide me, I'd be eternally thankfull.\nI hope I explained myself good enough.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":115,"Q_Id":64803199,"Users Score":0,"Answer":"At the end the best way was allowing everything on django ALLOWED_HOSTS, and then configuring correctly the server in production, in my case Nginx and gunicorn to only allow what I want.","Q_Score":0,"Tags":"python,django,dns,middleware","A_Id":65305030,"CreationDate":"2020-11-12T11:37:00.000","Title":"Is the a way to make ALLOWED_HOSTS accept new domains dynamically in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python script that uses Selenium Webdriver. I want to run this on a server remotely.\nWhen running my script directly on the server through command window, everything works fine.\nBut when I'm trying to trigger this remotely through a program on my local PC to the server, it doesn't work. It seems to stop at driver = webdriver.Chrome(webdriverlink). It doesn't fail, it just won't continue. So it seems like it doesn't actually opens a browser. Isn't this possible when you're not logged in on the server and not running it directly from there?\n\nI've saved my script in a py-file, and is triggering it in both ways throuh the command line python <myFileName>.py","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":154,"Q_Id":64804603,"Users Score":1,"Answer":"I found a solution from another forum after a lot of searching. So for all of you struggling with the same problem, this worked for me:\nI've added the following code:\noptions = webdriver.ChromeOptions()\noptions.add_experimental_option('excludeSwitches', ['enable-logging'])\nand changed from: driver = webdriver.Chrome(webdriverlink) to driver = webdriver.Chrome(executable_path=webdriverlink,options=options)","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,webdriver","A_Id":64857847,"CreationDate":"2020-11-12T13:14:00.000","Title":"Calling Python script with Selenium Webdriver from PC on a server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does the learning rate reset when I stop training in jupyter? I said during training to lower it by * 0.1 when my model starts to stagnate.\nIf I stop training and then restart it right after, does that reset the learning rate?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":64805202,"Users Score":1,"Answer":"Yes, ideally it will restart again if you are not initializing with new value.\nThis of this as a function which is stopped and rerun again. If you don't write the custom logic to restart again from the old LR it will continue from its initialized value which is the begging again.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":64807189,"CreationDate":"2020-11-12T13:51:00.000","Title":"Does the learning rate reset when I stop training in jupyter? Tensorflow.Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an organized point cloud file of an assembly generated using FreeCAD. I am using open3d python library to visualize this point cloud file. I just wonder whether there's a method to resize (cut down) this point cloud to a smaller size (shrink in size), but keeping this cloud organized in its original shape. That means I want to reduce the spacing between the points so that they become closer and the point cloud compresses while maintaining the shape of the point cloud.\nI think this shouldn't be the same as down sampling. What I want to do next is that I want to combine the 2 point clouds together so that the shrinker point cloud object appears to be within the bigger point cloud object\nI am working on python using the approach of storing these point clouds in lists etc. and visualizing using open3D python library.\nAny advice is welcome, thanks first!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":438,"Q_Id":64805510,"Users Score":0,"Answer":"Have you tried scaling it?\nFor example, converting the units from meters to millimeters - multiply\/divide each coordinate by the same constant (for example - 1000 for m<->mm conversion).\nThen, center each point cloud (subtract the mean from each point) and merge them. You can adjust their centroid and the scaling for better output.","Q_Score":0,"Tags":"python,point-clouds","A_Id":65287100,"CreationDate":"2020-11-12T14:10:00.000","Title":"Point Cloud Shrink in size","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hellow, i'm working with network programing and it's been so hard to create a logic that allows to stream a video from a single server to multiple clients with no delay.\nwhich means that i have to implement a parallel execution during the stream to all connected clients in order to display the images at the same time.\nand why is that important for my project it's because i'm intending to have large number of clients (from 200 to approximately 700), now with 10 clients that delay is nothing but with 700 clients could significantly increase the delay to several minutes (not sure but possible).\nfor those who don't know what's the cause of the dely, it's from the for loop that i'm using which contain the send function for each frame, and that is a serial execution.\ni tried threading and multiprocessing and even function schedule but every thing got messy, previously i was using socket & opencv, but for some reason it caused issues during the streaming, now i switched to Netgear & Vidgear but i'm still struggling.\nHope someone can help.\nPS: multicast is just not right for the job, after i tried it i was receiving errors because of the length of the transmitted images, UDP protocol will NOT accept more then 65535 byte.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":280,"Q_Id":64805512,"Users Score":1,"Answer":"Per your comment, everything is in the same network, and we have multicast for exactly your problem. Rather than sending the same data over and over to multiple hosts, you can send a single stream of traffic to many receivers.\nYou set up the clients to subscribe to a multicast group, normally a group in the 239.0.0.0\/8 Organization-Local scope. Your server then sends its traffic to the same multicast group to which the clients have subscribed. The single traffic stream will be received and processed by every client subscribed to the multicast group.\nBecause multicast sends to multiple clients, you must use a connectionless transport protocol, e.g. UDP. Connection-oriented transport protocols, e.g. TCP, create connections between two hosts, so they cannot be used with multicast, which is one-to-many.\nBy default, multicast only works in the same network. We do have multicast routing to send traffic to other networks, but it is very different than the usual unicast routing. Also, you cannot multicast on the public Internet because the ISPs do not have multicast routing. You can multicast to a different site across the Internet by using a tunnel that supports multicast, e.g. GRE. Both the source and destination routers need to be configured for multicast routing, as well as any routers in the path of the multicast packets (the Internet routers on see the unicast tunnel packets, not the multicast packets, so you can send the multicast across the Internet).","Q_Score":1,"Tags":"python-3.x,sockets,opencv,networking,network-programming","A_Id":64806863,"CreationDate":"2020-11-12T14:10:00.000","Title":"Send data over network to multiple recipient parallely","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know why Pandas can open in chunks a gzip-compressed file while Dask has to load to memory the whole file before processing it.\nConcretely, I have a gzip-compressed csv file of size ~10GB (and ~50GB when not compressed). My computer has 16GB of RAM.\nI thought gzip files cannot be operated in chunks because they need to be decompressed before they can be partitioned. However, I am able to use the chunk method of Pandas to process the gzip file with no issue.\nAdditionaly, since I want to use Dask in the future, can you recommend me any compressed format that can easily be read in chunks by Dask ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":155,"Q_Id":64806692,"Users Score":1,"Answer":"Specifically, you cannot random access a gzipped file: to get to a particular point in the decompressed data, you need to read through the whole file to that point. Thus, you can load chunk-by-chunk sequentially, maintaining the file position.\nHowever, dask wants to be able to access some arbitrary offset in the file, so that each partition can be loaded independently and in parallel. For gzip, this would mean each task spooling through the file to the offset they need, which is a really bad idea.","Q_Score":0,"Tags":"python,pandas,parallel-processing,gzip,dask","A_Id":64807653,"CreationDate":"2020-11-12T15:18:00.000","Title":"Why Pandas can load a gzip file in chunks while Dask cannot?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a beginner with django and I accidentally deleted the db.sqlite3 file in my django project.\nI made a new django project but the db.sqlite3 file was not in it. I also uninstalled and reinstalled django and project but the db.sqlite3 file still wasn't there in the project. What do I do.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":369,"Q_Id":64808378,"Users Score":0,"Answer":"I am a beginner with django and I accidentally deleted the db.sqlite3 file in my django project. I made a new django project but the db.sqlite3 file was not in it. I also uninstalled and reinstalled django and project but the db.sqlite3 file still wasn't there in the project. What do I do. Thank you.\n\n\nDelete everything except init.py file from migration folder in all django apps\nMake changes in your models (models.py).\nRun the command python manage.py makemigrations or python3 manage.py makemigrations\nThen run the command python manage.py migrate.","Q_Score":1,"Tags":"python,django","A_Id":64808467,"CreationDate":"2020-11-12T17:02:00.000","Title":"How do I reinstall the db.sqlite3 file in django","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am wondering if keeping __pycache__ folders and .pyc files in built containers is good or bad practice.\nOn one side you want to minimize the size of the containers but on the other side you do not want to slowdown the container executions either.\nConsidering that python interpreter is static these files can also be considered static.\nDid anyone made some performance tests and came to a conclusion?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1585,"Q_Id":64808915,"Users Score":6,"Answer":"Personally, I don't use __pycache__\/.pyc files in containers if at all possible. More specifically, I try to build and run my containers such that they never generate the .pyc files (setting the environment variable PYTHONDONTWRITEBYTECODE=1 and passing --no-compile --no-cache-dir to all pip invocations, explicitly, or via pip.conf or equivalent environment variables), either during build or at runtime.\nThe advantage of cached bytecode is in startup time, not execution speed; import takes longer, but actual execution is just as fast (the bytecode is still there in memory, just not on disk). But in the case of containers, making the container larger means it takes longer to cache and launch, so you're wasting disk space and any gains in Python launch time are typically offset by delays pulling and launching the container in the first place. And writing out bytecode at runtime is pointless; it'll be lost when the container shuts down, so it's adding expense to startup for no benefit.\nHaving the .pyc files for the base install of Python itself isn't so bad (though as noted in the comments, the official Dockerfiles expunge them); with many containers depending on them, the odds of the base Python image already being cached is high, and many pre-built Python images already have them (so deleting them after the fact wouldn't help), and it does reduce start up time a little for programs running in containers built on them. But for per-container third party installs, you're just getting bloat with no compensating benefit.","Q_Score":6,"Tags":"python,containers,pyc","A_Id":64808984,"CreationDate":"2020-11-12T17:36:00.000","Title":"Should __pycache__ folders be included in production containers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an external drive from my old PC and I would like to continue working on some projects there, I have set up python but on my VSCode I keep getting \"workspace contains pipfile but pipenv was not found\". What's the solution to this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":64809751,"Users Score":0,"Answer":"Create a virtual env in the folder you'll be working in. Install Django together with other dependencies you'll be using. Wallah you're ready to start working.","Q_Score":2,"Tags":"python,django,visual-studio-code,pip,pipenv","A_Id":64809854,"CreationDate":"2020-11-12T18:32:00.000","Title":"How can I work on a django project in my external harddrive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I has been forced to develop python scripts on Windows 10, which I have never been doing before.\nI have installed python 3.9 using windows installer package into C:\\Program Files\\Python directory.\nThis directory is write protected against regular user and I don't want to elevate to admin, so when using pip globally  I use --user switch and python installs modules to C:\\Users<user>\\AppData\\Roaming\\Python\\Python39\\site-packages and scripts to C:\\Users<user>\\AppData\\Roaming\\Python\\Python39\\Scripts directory.\nI don't know how he sets this weird path, but at least it is working. I have added this path to %Path% variable for my user.\nProblems start, when I'm trying to use virtual environment and upgrade pip:\n\nI have created new project on local machine in C:\\Users<user>\\Projects<project> and entered the path in terminal.\npython -m venv venv\nsource venv\\Scrips\\activate\npip install --upgrade pip\n\nBut then I get error:\nERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access denied: 'C:\\Users\\\\AppData\\Local\\Temp\\pip-uninstall-7jcd65xy\\pip.exe'\nConsider using the --user option or check the permissions.\nSo when I try to use --user flag I get:\nERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.\nSo my questions are:\n\nwhy it is not trying to install everything inside virtual enviroment (venv\\Scripts\\pip.exe)?\nhow I get access denied, when this folder suppose to be owned by my user?\n\nWhen using deprecated easy_install --upgrade pip everything works fine.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":81,"Q_Id":64810229,"Users Score":1,"Answer":"I recently had the same issue for some other modules. My solution was simply downgrade from python 3.9 to 3.7. Or make an virtual environment for 3.7 and use that and see how it works.","Q_Score":1,"Tags":"python,windows,pip,virtualenv","A_Id":64811453,"CreationDate":"2020-11-12T19:06:00.000","Title":"python on windows 10 cannot upgrade modules in virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Hello everybody I'm trying to run the simplest code of tutorial about telepot in python but I keep getting this message\nModuleNotFoundError: No module named 'telepot'\nMy code is very basic\nimport telepot\nbot = telepot.Bot('1446317719:AAGZy_WVMMv8NG6g_E_fQCyx9ItdIprk7oA')\nbot.getMe()\nMy python version is Python 2.7.16\nMy python3 version is Python 3.9.0\nand my OS is Catalina 10.15.7\nI have repeatedly installed telepot with pip install telepot and uninstalled and installed again. It has always completed with no error so I don't understand what's wrong","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":826,"Q_Id":64811941,"Users Score":0,"Answer":"I solved it. I installed it using pip3 install telepot and now it works","Q_Score":0,"Tags":"python,macos,telepot","A_Id":64812051,"CreationDate":"2020-11-12T21:24:00.000","Title":"How to solve \"No module named 'telepot\"' error in Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to create a presentation from a presentation that already exists.\nI have to update the text by adding graphics or tables and keeping the format of a slide present in the template.\nBut there is no possibility to clone slides.\nHas anyone found a solution?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":584,"Q_Id":64812094,"Users Score":1,"Answer":"This is not readily accomplished with python-pptx. You might be better off pursuing a Visual Basic for Applications (VBA) solution. That needs to run in a Windows environment, but gives broad control the the PowerPoint application.","Q_Score":0,"Tags":"python,duplicates,powerpoint,slide","A_Id":64815183,"CreationDate":"2020-11-12T21:35:00.000","Title":"How to duplicate PowerPoint slide with python pptx?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So the problem I'm facing is that I cannot figure out how to apply textures to a model in a way that texture would be different on each side. For example I wanted to create Minecraft like grass blocks with bottom being brown, sides - green and brown and top - green. I already searched up this issue and found that it is possible to use UVs but I cannot figure out how. I already tried creating UV map in Blender then exported it and put it both as a texture and model and other combinations however it did not change the model so I let it be built-in 'cube' and changed just texture but it literally just put the UV's .png file on all sides. So any help would be appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1504,"Q_Id":64812291,"Users Score":1,"Answer":"Also, you can use Microsoft's 3D Builder to build models and Paint 3D to paint it. Re-import it to 3D Builder to save as a .obj with a .mtl file and a  .png texture map. It works for Ursina as I've tried.","Q_Score":0,"Tags":"python,python-3.x,game-engine","A_Id":66943392,"CreationDate":"2020-11-12T21:50:00.000","Title":"Ursina engine texture mapping","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I worked on a dataset in Kaggle and I see that in some python notebooks, they have used ! before pip command for installing packages.\nFor example: !pip install rank_bm25 nltk\nIs there any reason behind it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":648,"Q_Id":64814047,"Users Score":3,"Answer":"In some python interactive shells like ipython or kaggle ! is prefixed to run external shell command.","Q_Score":0,"Tags":"python,installation,pip,package,kaggle","A_Id":64814086,"CreationDate":"2020-11-13T01:06:00.000","Title":"Why ! is used before pip command?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"I am attempting to use python to pull down a zone file. After going through hoards of documentation, I am still stuck on one line of code:\ndns.zone.from_xfr(dns.query.xfr('3.211.54.86','megacorpone.com'))\nI get the following error:\nsocket.error: [Errno 111] Connection refused\nI've hardcoded ns2.megacorpone.com's IP to isolate any problems. For some reason this connection continues to refuse. Is anyone able to shed some light on this problem?\nThanks all","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":392,"Q_Id":64816473,"Users Score":0,"Answer":"Running the same command with the domain name instead of IP worked.","Q_Score":0,"Tags":"python,python-2.7,dns","A_Id":64837670,"CreationDate":"2020-11-13T06:33:00.000","Title":"Issues transferring zone file with dnspython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I coded to open webcam video on a new window using OpenCV cv2.VideoCapture(0).\nYou can display text on webcam video using cv2.putText() command. But it displays string values only.\nHow to put varying values in the webcam video that is being displayed on a new window?\nFor example, if value of variable p is changing all the time, you can easily display it on the command window by writing print(p).\nBut how can we display values of p over the webcam video?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":669,"Q_Id":64816985,"Users Score":0,"Answer":"You can also show changing variables using cv2.putText() method. Just need to convert the variable into string using str() method. Suppose you want to show variable x that is for example an integer and it is  always changing. You can use cv2.putText(frame, str(x), org, font, fontScale, color, thickness, cv2.LINE_AA)  to do it (You should fill org,font, etc.).","Q_Score":0,"Tags":"python,opencv,webcam,opencv-python","A_Id":64819052,"CreationDate":"2020-11-13T07:25:00.000","Title":"How to show a variable value on the webcam video stream? (python OpenCV)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im using python with the selenium package and the chromedriver to scrape a webpage. The page is automatically reloading itself (probably via java-script) every 30 min, which destroyes my scraping-progress.\nThe webscraping is done with a script and the javascript ist needed for further interaction with the page.\nIs it possible to stop the page from reloading itself, maybe with a flag for the chromedriver?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1247,"Q_Id":64817185,"Users Score":0,"Answer":"You can just open the DevTools and pause the Debugger. Works in Firefox and Chrome (tested)!","Q_Score":0,"Tags":"python,selenium,selenium-chromedriver","A_Id":64817219,"CreationDate":"2020-11-13T07:45:00.000","Title":"Stop webpage from auto-reload with selenium\/chromedriver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Im using python with the selenium package and the chromedriver to scrape a webpage. The page is automatically reloading itself (probably via java-script) every 30 min, which destroyes my scraping-progress.\nThe webscraping is done with a script and the javascript ist needed for further interaction with the page.\nIs it possible to stop the page from reloading itself, maybe with a flag for the chromedriver?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1247,"Q_Id":64817185,"Users Score":0,"Answer":"Found a Solution myself. I had to execute the following dev-tools command with the webdriver:\ndriver.execute_cdp_cmd('Emulation.setScriptExecutionDisabled', {'value': True})","Q_Score":0,"Tags":"python,selenium,selenium-chromedriver","A_Id":64919208,"CreationDate":"2020-11-13T07:45:00.000","Title":"Stop webpage from auto-reload with selenium\/chromedriver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've done some project using PyQt library for my class assignmnet.\nAnd I need to check my application working before I submit it.\nToday, 3 hours ago I updated my Mac book OS to Big Sur.\nAnd I found out that PyQt library doesn't work. It doesn't show any GUI.\nAre there someone know how to fix it?","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":4835,"Q_Id":64818879,"Users Score":6,"Answer":"Rolling back to PyQt5==5.13.0 fixed the issue for me!\nyou should uninstall PyQt5 and then install it using\npip install PyQt5==5.13.0","Q_Score":12,"Tags":"python,pyqt","A_Id":64832627,"CreationDate":"2020-11-13T09:59:00.000","Title":"Is there any solution regarding to PyQt library doesn't work in Mac OS Big Sur?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've done some project using PyQt library for my class assignmnet.\nAnd I need to check my application working before I submit it.\nToday, 3 hours ago I updated my Mac book OS to Big Sur.\nAnd I found out that PyQt library doesn't work. It doesn't show any GUI.\nAre there someone know how to fix it?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4835,"Q_Id":64818879,"Users Score":0,"Answer":"Related to this, after upgrading to BigSur my app stopped launching its window...I am using the official Qt supported binding PySide2\/shiboken2\nUpgrading from PySide2 5.12 to 5.15 fixed the issue.\nSteps:\n\nRemove PySide2\/shiboken2\npip3 uninstall PySide2\npip3 uninstall shiboken2\n\nReinstall\npip3 install PySide2","Q_Score":12,"Tags":"python,pyqt","A_Id":65077512,"CreationDate":"2020-11-13T09:59:00.000","Title":"Is there any solution regarding to PyQt library doesn't work in Mac OS Big Sur?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently working on an AI to predict the winner of a 1v1 match on a video game. The thing is that I do not know in what form I need to have the data (inputs and labels).\nFor now I have the following data :\n\nthe day of the match (there is a day 0)\nname of player 1\ncountry of player 1\nname of player 2\ncountry of player 2\nwinner\n\nI can also get the score of the match but sometimes it is in best of 3 and sometimes in best of 5 so I do not know if it could be reliable or not.\nBased on the data I have, my two main questions are :\n\nIs is possible that the AI predict two different results if I just reverse the player columns ?\nIf yes, how can I avoid it ?\nHow am I saying to the AI that the prediction I want is only one of the two players I present to it and not other players ?\n\nThanks in advance, I really appreiciate","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":64820841,"Users Score":2,"Answer":"It seems that your data is categorical even though I do not exactly understand what you mean by player1 and player2. Do you have the names of the players or some skill set?\nNeural networks or any AI algorithm work with numbers. They do not know anything about the real world such as day name(Monday, Tuesday etc.) or Country names. What you have to do is you have to create a mapping between these real-world issues and numbers.\nThey are something categorical(it can not take a continuous value) you can map the days from 0 to N. For the countries you can do the same, every country can have a unique ID. You have to be careful tough if, during inference the model receives a day or country that was not extant in the training, it will be unknown to the model. So either adds all the countries that are relevant or if you can not know this in prior, you can add a label -1 for the case of unknown country and day.\nFor each feature, you will have a column and each row represents a match. In the column, you will have to correspondings IDs for that particular feature and match and you can pass this data to AI. By the way, it is okay that you use the same IDs\/numbers for different features. (So you can you 1 for Tuesday and in the other Column 1 can be Switzerland)\nAnswers to your questions:\n\nYes, in theory, this can happen. If you have enough samples and a good model the model itself might learn it.\n\nIf you can do, you can input relative values to the model instead of absolute values. So for example, if you have some skill set attributes\/scores with respect to players, instead of feeding both scores to the system, you can create your data based on the difference of these score. E.g shooting for player1 is 80 and for player2 78. You have a column for shooting and there you put the value 80-78, then the modal knows the player1 is better by 2 or if vice versa you could put -2 and thne th emodel knows the player2 is better by 2 in that category. Another approach would be to have each match 2 times in the training data. The second one with player orders reversed. The model might also learn this from the data.\n\nThat is easy to do, your model will output not players IDs or anything related to the player. Your problem is a binary classification problem. Your model should output in any case either 0 or 1. 0 meaning player1 wins, 1 meaning player2 wins and then you can convert this output to the players by yourself.","Q_Score":1,"Tags":"python,machine-learning","A_Id":64821189,"CreationDate":"2020-11-13T12:22:00.000","Title":"In what form should I have my data for 1v1 match prediction?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So basically i am making an auto clicker that needs pip3 modules to work eg.pyautogui,keyboard,mouse\nwould it be possible to make these modules install themselves when  a file is run, like a install.py thing that installs these modules so any computer can run my clicker.\nthanks for the help in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":64822020,"Users Score":0,"Answer":"You could create a python environment for your python file and install the required packages in it, so when you export your clicker along with its environment, you can run it anywhere.","Q_Score":0,"Tags":"python,pip","A_Id":64822109,"CreationDate":"2020-11-13T13:46:00.000","Title":"is it possible to import pip modules from a file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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'm making a Pygame library to easily create UI elements and I want to implement multicolored text. I know that I can do this by having multiple text objects but that's pretty unoptimized and I want to know if there's a better way i can do this?\nEdit: To make it clearer, i mean something like [RED]this text has to be red[\/RED]","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":64825207,"Users Score":0,"Answer":"For anyone looking this up:\nThere sadly is no way to have multi-colored text in pygame as stated by @Rabbid76. You'll have to make it yourself","Q_Score":2,"Tags":"python,python-3.x,user-interface,pygame","A_Id":64825519,"CreationDate":"2020-11-13T17:17:00.000","Title":"Multi-Colored text in pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I successfully installed pyrasterframes with pip in cmd, but when I try to import it in jupyter notebook I get the following error: \"No module named 'pyrasterframes'\". Could you help me please?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":64825612,"Users Score":0,"Answer":"This issue solved by removing your specific environment from jupyter by the following instruction:\n\"jupyter kernelspec uninstall envname\"\nand then installing ipykernel and readding the environment to jupyter notebooks as following:\n\"conda install -c anaconda ipykernel\"\n\"ipython kernel install --user --name=envname\"\nnotice that I should open jupyter notebooks after activating my env in cmd.\nI think you can use this solution to solve similar installation problems with any other modules.","Q_Score":0,"Tags":"python,apache-spark","A_Id":65144106,"CreationDate":"2020-11-13T17:46:00.000","Title":"About installing rasterframes module in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello Everyone,\nI have an issue I have to immediately deal with it. I installed mlxtend and used the library for apriori(market research). In my first attempt it worked then next day I tried to update it with new data but it gives exactly this error ModuleNotFoundError: No module named 'mlxtend'. And I read everywhere to find where my mistake is? Sadly, I couldn't find it. I updated my mlxtend to current version however, again I faced with the exact, same problem. When I try to install mlxtend I got this as it is expected \"Requirement already satisfied\". I would appreciate and be glad if you have any suggestions? By the way, thanks to everyone who read this.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":1202,"Q_Id":64828540,"Users Score":3,"Answer":"Are you installing it in the Conda shell or somewhere else? To ensure it gets installed in the correct environment type\n%pip install mlxtend\nfrom within the Jupyter notebook (in a cell at the top) that you are working in and execute that cell.\nIf it installs successfully you can comment out that cell or remove it.","Q_Score":3,"Tags":"python,python-3.x,jupyter-notebook,mlxtend","A_Id":64828695,"CreationDate":"2020-11-13T21:57:00.000","Title":"ModuleNotFoundError: No module named 'mlxtend'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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: \/\/<User>@<Ip Server>\/home\/<user>\/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":"I have a flask application that uses flask-socketio and python-socketio to facilitate communication between a socketio server in the cloud and a display device via a hardware device.\nI have a display namespace which exposes the display facing events, and also uses a separate client class which connects and talks to the server in the cloud. This works well as designed, but now I want to trigger the connection method in my client class from a different namespace. So far I have not been able to get this to work.\nWhat I have tried is adding the display namespace class to the flask context, then passing that into the socketio.on_namespace() method. Then from the other namespace I am grabbing it from current_app and trying to trigger the connection to the cloud server. This returns a 'RuntimeError: working outside of application context' error.\nSo at this point I'm still researching how to do this correctly, but I was hoping someone has dealt with something like this before, and knows how to access methods on one namespace from a different one.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":64829415,"Users Score":0,"Answer":"I found a solution. Instead of instantiating my client class from the display namespace, I instantiate it before I add the namespaces to socketio. Then I pass the client object into both namespaces when I call the socketio.on_namespace() method.","Q_Score":0,"Tags":"python,flask-socketio,python-socketio","A_Id":64836959,"CreationDate":"2020-11-13T23:42:00.000","Title":"access methods on one socketio namespace from a different one","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"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 <Python.h>\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":"UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.\nwarnings.warn(\nTraceback (most recent call last):\nFile \"c:\\users\\user\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\jupyterlab_server\\server.py\", line 20, in \nfrom notebook.notebookapp import aliases, flags, NotebookApp as ServerApp\nFile \"c:\\users\\user\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\notebook\\notebookapp.py\", line 51, in \nfrom zmq.eventloop import ioloop\nFile \"c:\\users\\user\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\zmq_init_.py\", line 50, in \nfrom zmq import backend\nFile \"c:\\users\\user\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\zmq\\backend_init_.py\", line 40, in \nreraise(*exc_info)\nFile \"c:\\users\\user\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\zmq\\utils\\sixcerpt.py\", line 34, in reraise\nraise value\nFile \"c:\\users\\user\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\zmq\\backend_init_.py\", line 27, in \nns = select_backend(first)\nFile \"c:\\users\\user\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\zmq\\backend\\select.py\", line 28, in select_backend\nmod = import(name, fromlist=public_api)\nFile \"c:\\users\\user\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\zmq\\backend\\cython_init.py\", line 6, in \nfrom . import (constants, error, message, context,\nImportError: DLL load failed while importing error: The specified module could not be found.\nDuring handling of the above exception, another exception occurred:\nTraceback (most recent call last):\nFile \"c:\\users\\user\\appdata\\local\\programs\\python\\python39\\lib\\runpy.py\", line 197, in _run_module_as_main\nreturn run_code(code, main_globals, None,\nFile \"c:\\users\\user\\appdata\\local\\programs\\python\\python39\\lib\\runpy.py\", line 87, in run_code\nexec(code, run_globals)\nFile \"C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\site-packages\\jupyter-lab.exe_main.py\", line 4, in \nFile \"c:\\users\\user\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\jupyterlab\\labapp.py\", line 14, in \nfrom jupyterlab_server import slugify, WORKSPACE_EXTENSION\nFile \"c:\\users\\user\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\jupyterlab_server_init.py\", line 4, in \nfrom .app import LabServerApp\nFile \"c:\\users\\user\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\jupyterlab_server\\app.py\", line 9, in \nfrom .server import ServerApp\nFile \"c:\\users\\user\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\jupyterlab_server\\server.py\", line 29, in \nfrom jupyter_server.extensions import (                             # noqa\nModuleNotFoundError: No module named 'jupyter_server.extensions","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":301,"Q_Id":64832178,"Users Score":0,"Answer":"It feels like you have not installed some required modules e.g. jupyter_server.extensions and or setuptools. I guess you need to pip install them. Worth checking also whether you have more than one versions of python installed as this may cause issues some times.","Q_Score":0,"Tags":"python,jupyter-lab","A_Id":64832855,"CreationDate":"2020-11-14T08:38:00.000","Title":"Is there any solution to error being recieved while loading jupyter-lab from cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"$ pip install pygame\nCollecting pygame\nWARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1123)'))': \/packages\/00\/86\/63b1967d59c3424992f0f822b012bcf24d8d013f8d65b40db20fae01be70\/pygame-2.0.0-cp38-cp38-win_amd64.whl\nWARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1123)'))': \/packages\/00\/86\/63b1967d59c3424992f0f822b012bcf24d8d013f8d65b40db20fae01be70\/pygame-2.0.0-cp38-cp38-win_amd64.whl\nWARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1123)'))': \/packages\/00\/86\/63b1967d59c3424992f0f822b012bcf24d8d013f8d65b40db20fae01be70\/pygame-2.0.0-cp38-cp38-win_amd64.whl\nWARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1123)'))': \/packages\/00\/86\/63b1967d59c3424992f0f822b012bcf24d8d013f8d65b40db20fae01be70\/pygame-2.0.0-cp38-cp38-win_amd64.whl\nWARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1123)'))': \/packages\/00\/86\/63b1967d59c3424992f0f822b012bcf24d8d013f8d65b40db20fae01be70\/pygame-2.0.0-cp38-cp38-win_amd64.whl\nERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: \/packages\/00\/86\/63b1967d59c3424992f0f822b012bcf24d8d013f8d65b40db20fae01be70\/pygame-2.0.0-cp38-cp38-win_amd64.whl (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1123)')))","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1775,"Q_Id":64833049,"Users Score":0,"Answer":"Just uninstall all stuff of python 1st. Then delete that file from pc. Then uninstall python interpreter and download python form its official page again and install it and also install python interpreter again then\nCheck it in your cmd or powershell is it running perfectly or not.\nIt will definitely run.\nI am getting the same problem but it was resolved now.","Q_Score":0,"Tags":"python-3.8","A_Id":68407302,"CreationDate":"2020-11-14T10:46:00.000","Title":"python 3.8 and pip gives this error[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1123)')))","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I decided to build a large dataset with augmented images in order to save time during the training, which takes too long due to every image being augmented on the fly, thus reducing performance and GPU usage.\nI was wondering if it is possible for every epoch to train on a subset of the dataset in order to save time (train on 4000 images instead of 40000). This is somehow similar to cross validation, but my aim is simply to reduce the portion of dataset on which the model is being trained every epoch, and alternating these small portions randomly. In cross validation of course I would not reduce my training dataset size, just alternate the validation set.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":506,"Q_Id":64833692,"Users Score":1,"Answer":"By definition an epoch means that the entire dataset is passed trought the model for training. However you can use mini-batch training, divide the entire dataset into batches and train one batch at the time using .next_batch() function or by iterating over the dataset.\nWhen you define your dataset you can use .shuffle() if you want the data in your bacthes to be randomly selected at each epoch and .batch(batch_size) to define how many samples to use for each batch.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,deep-learning,training-data","A_Id":64834322,"CreationDate":"2020-11-14T12:04:00.000","Title":"Tensorflow training on different subset of dataset each epoch","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training several agents with PPO algorithms in a multi-agent environment using rllib\/ray. I am using the ray.tune() command to train the agents and then loading the training data from ~\/ray_results. This data contains the actions chosen by the agents in each training episode, but I also need the corresponding agent rewards. I've looked at the documentation, but there doesn't seem to be configuration argument that allows for saving episode rewards. Does anyone have a workaround for this?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":374,"Q_Id":64833781,"Users Score":0,"Answer":"Did you check progress.csv and result.json? The details of the reward for each agent in every episode can be found there.","Q_Score":2,"Tags":"python,reinforcement-learning,ray,rllib,ray-tune","A_Id":68217425,"CreationDate":"2020-11-14T12:15:00.000","Title":"Save episode rewards in ray.tune","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am training several agents with PPO algorithms in a multi-agent environment using rllib\/ray. I am using the ray.tune() command to train the agents and then loading the training data from ~\/ray_results. This data contains the actions chosen by the agents in each training episode, but I also need the corresponding agent rewards. I've looked at the documentation, but there doesn't seem to be configuration argument that allows for saving episode rewards. Does anyone have a workaround for this?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":374,"Q_Id":64833781,"Users Score":1,"Answer":"You need to add these values into the info dict, then it will get collected by ray tune.","Q_Score":2,"Tags":"python,reinforcement-learning,ray,rllib,ray-tune","A_Id":68344747,"CreationDate":"2020-11-14T12:15:00.000","Title":"Save episode rewards in ray.tune","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"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 new to programming, this being my first post, but I was wondering if there was a way to make selenium run while my computer is turned off? I made an instagram bot with selenium webdriver python but it only runs when I run it from my computer and turns off when I turn off my computer. I have seen post saying to host it in PythonAnywhere which I tried but selenium requires a webdriver (im using firefox so gekodriver). Is there a way of fixing this or is there another way of making an insagram bot without selenium webdriver?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":230,"Q_Id":64840650,"Users Score":0,"Answer":"You can use virtual machine and host a server and then through DevOps pipelines (Azure Pipelines\/ Jenkins) can make your scripts run without manual intervention.","Q_Score":0,"Tags":"python,selenium,selenium-webdriver,bots,instagram","A_Id":64840829,"CreationDate":"2020-11-15T02:24:00.000","Title":"How can I have a python selenium webdriver script run 24\/7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make a script in python that interacts with a webpage that has quite a lot of javascript in it (it's a webpage that computes a bunch of physics stuff).\nI don't want my code to break if the page formatting changes and I want it to run offline so I would prefer my script to run on a local html copy of the page I got (all the JS code is accessible in the HTML source, there is no call to an external server). I wanted to use the requests library to do it, but it only works with URLs. Is there any library to do this? Note that I want to interact with the HTML (input values and look at the outputs etc..), I know that I can parse the file but that's not what I'm asking. I'm also totally new to web bots or anything related.\nRight now I can open my .html version of the page offline with chrome and interact with it, so there has to be a way to automate this somehow. I'm also not against using something else than python if there is a better library for this in another language.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":320,"Q_Id":64841002,"Users Score":0,"Answer":"interesting question, best way I can think to do that is use a web framework and then just scrape the data using requests. I am familiar with flask and its simple to use but im sure there are other options as well","Q_Score":3,"Tags":"python,html,web,web-scraping,python-requests","A_Id":64841338,"CreationDate":"2020-11-15T03:43:00.000","Title":"Interact with local HTML file with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Introduction\nI have written code to give me a set of numbers in '36 by q' format ( 1<= q <= 36), subject to following conditions:\n\nEach row must use numbers from 1 to 36.\nNo number must repeat itself in a column.\n\nMethod\nThe first row is generated randomly. Each number in the coming row is checked for the above conditions. If a number fails to satisfy one of the given conditions, it doesn't get picked again fot that specific place in that specific row. If it runs out of acceptable values, it starts over again.\nProblem\nUnlike for low q values (say 15 which takes less than a second to compute), the main objective is q=36. It has been more than 24hrs since it started to run for q=36 on my PC.\nQuestions\n\nCan I predict the time required by it using the data I have from lower q values? How?\n\nIs there any better algorithm to perform this in less time?\n\nHow can I calculate the average number of cycles it requires? (using combinatorics or otherwise).","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":48,"Q_Id":64841034,"Users Score":1,"Answer":"Graph q vs time\nFit a curve,\nExtrapolate to q = 36.\n\nYou might want to also graph q vs log(time) as that may give an easier fitted curve.","Q_Score":0,"Tags":"python-3.x,algorithm,time,computation","A_Id":64853811,"CreationDate":"2020-11-15T03:48:00.000","Title":"Question(s) regarding computational intensity, prediction of time required to produce a result","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After pip install package_name from my recently uploaded pypi package\nIt imports python filename directly after installing,\nI wanted to use like below\nimport package_name or from package_name import python_file\nbut this doesnt work instead this works\nimport python_file even package is installed name is package_name\npypi package name package_name and\nMy directory structure is below\n\npackage_name\n\nsetup.py\n\nfolder1\n\npython_file\n\n\n\n\n\nIn setup.py , i've used package_dir={'': 'folder_1'}\nbut even import folder_1 or from folder_1 import python_file  didnt worked.\nI tried if adding __init__.py inside folder_1, it didnt solved.\nI've been following Mark Smith - Publish a (Perfect) Python Package on PyPI,\nwhich told this way , but any idea what is happening, how can i solve it??","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":64842198,"Users Score":1,"Answer":"So what you actual did is to tell python that the root folder is folder_1.\nThis is not what you want.\nYou just need to tell that folder_1 (or actually replace it by package_name, see below) is a package and to declare it using:\npackages = {'folder1'}.\nUsually, people don't do it but let the function find_packages() to do the work for them by packages=find_packages()\nIn addition package folder should contain a __init__.py.\nto conclude you need a folder structure like below and use find_packages().\nIt is OK and even popular choice that the project name and it single main package have the same name.\n\nproject_name\n\nsetup.py\npackage_name\n\n__init__.py\npython_file.py","Q_Score":0,"Tags":"python,pip,pypi","A_Id":64862872,"CreationDate":"2020-11-15T07:45:00.000","Title":"pypi package imports python file instead of package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have got a dataframe looks like this:\n\n12000 pa\n13000 per annum\n25000 pa\n34000 per annum\n\nI need to update all four cells into int only, so:\n\n12000\n13000\n25000\n34000\n\nWhat is the quickest method for doing this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17,"Q_Id":64843082,"Users Score":0,"Answer":"One of the possible solutions:\ndf[\"price_int\"] = df[\"price\"].apply(lambda value: int(value.split(\" \")[0]))\nOr you can use Regex (more robust):\ndf[\"price_int\"] = df[\"price\"].str.extract(r'(^[0-9]+)').astype(int)","Q_Score":0,"Tags":"python","A_Id":64843127,"CreationDate":"2020-11-15T09:56:00.000","Title":"Update column under dataframe by regex","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What it is the best way to make a chessboard for checkers using Kivy framework?\nI have board.png, white.png, black.png, white_q.png, black_q.png files already. I wonder how to assign to each black tile on my board.png its own coordinate. Should I create  32 transparent widgets placed on black tiles of board.png or it is impossible? And what widget to use for 24 checkers? Any ideas or it is too complicated using Kivy and I should use tkinter?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":87,"Q_Id":64843966,"Users Score":1,"Answer":"There are many ways you could do this. It isn't complicated, it's very easy. The best way depends more on how you want to structure your app than anything else.\n\nI wonder how to assign to each black tile on my board.png its own coordinate\n\nSet the pos attribute of a widget to control its position, or better in this case use a layout that does what you want. For instance, adding your squares to a GridLayout with the right number of columns will have the right effect without you needing to worry more about positioning them.\n\nShould I create 32 transparent widgets placed on black tiles of board.png or it is impossible?\n\nI don't understand what you're asking here. You can make transparent widgets if you want but I don't know why you'd want to.\n\nAnd what widget to use for 24 checkers?\n\nThe real question is, what do you want the widget to do? e.g. if you want it to display an image then inherit from Image.\nOverall this answer is very generic because your question is very generic. I suggest that if you're stuck, try to ask a more specific question about a task you're struggling with, and give a code example showing where you are now.","Q_Score":0,"Tags":"python,kivy","A_Id":64844090,"CreationDate":"2020-11-15T11:43:00.000","Title":"Checkers board in kivy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to python and Anaconda\nI have python 3.8 in my (base) env, and i need pybrain, so since it's not compatible with my current version of python, i created a new env(first i tried all of it with python 3.5, didn't work, so i tried 2.7, same result):\nconda create --name py27 python=2.7\nthen activated it:\nconda activate py27\nand installed pybrain there:\nconda install -c mq pybrain\nI checked that it has been installed successfully with:\nconda list\npybrain                   0.3.3                    py27_0    mq   \nafter launching jupyter notebook from same terminal, with (py27) as the 'header'?? of my command line, it opened successfully, i even checked that currently it's opened in expected environment, by typing in a cell:\n!conda info\nand as i expected,  saw the line\nactive environment : py27\nbut also, which i guess is importnant:\npython version : 3.8.3.final.0\nthough i am confused with ouput of:\n!python --version\ncause it's:\nPython 2.7.18 :: Anaconda, Inc.\nSo when i open my notebook i type\nimport pybrain\nand i get:\nNo module named 'pybrain'\nPlease point me in direction: what i'm doing wrong? Also it is my first virtual env(distinct from the (base) one), so i probably missing some important concepts.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":197,"Q_Id":64844283,"Users Score":1,"Answer":"Fortunately i've found a solution to use pybrain with python3 - i just downloaded it from source !pip install https:\/\/github.com\/pybrain\/pybrain\/archive\/0.3.3.zip and it works in python 3.8","Q_Score":0,"Tags":"python,anaconda,virtualenv,conda,pybrain","A_Id":64888897,"CreationDate":"2020-11-15T12:16:00.000","Title":"pybrain install in env but No module named 'pybrain'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When splitting the data into the test and training data what split size should I choose?\nI was told that set by default is 80 % for training data,and 20 % for test data, can somebody ensure me?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":391,"Q_Id":64847418,"Users Score":0,"Answer":"The default split size in   sklearn.model_selection.train_test_split are 75% training and 25% testing data split. Data splits should depend on the task at hand.\nThe rule of thumb is that you have enough represent  data that represent your problem to train a model and a enough representative data to validate your trained model.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":64847609,"CreationDate":"2020-11-15T17:15:00.000","Title":"What is a default split_size in model training?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python. I have created a Django project and I am running it locally.\nMy python project keeps runs fine until I run a function from my main.py file. The function runs fine but then python crashes:\nAssertion failed: (NSViewIsCurrentlyBuildingLayerTreeForDisplay() != currentlyBuildingLayerTree), function NSViewSetCurrentlyBuildingLayerTreeForDisplay, file \/AppleInternal\/BuildRoot\/Library\/Caches\/com.apple.xbs\/Sources\/AppKit\/AppKit-1894.50.103\/AppKit.subproj\/NSView.m, line 13568.\nHowever I am unsure why this error is appearing. Anyone have experience in this type of error?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":231,"Q_Id":64848826,"Users Score":0,"Answer":"thank you, adding plt.close() to close off my plot stopped this problem.","Q_Score":0,"Tags":"python,django","A_Id":64849621,"CreationDate":"2020-11-15T19:22:00.000","Title":"Assertion failure on django project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a local computer A and remote computer B. Computer A has script client.py Computer B has server.py Script client.py has a variable port. Let's say port = 5535.\nI am running client.py on Computer A, which is using the port number for socket communication. I need to change the port number to another port number while the client.py is running so it will switch to another server at runtime after notifying the client to change the port number. I am using pyzmq to send data from the client to the server sending a continuous stream of data.\nIs this scenario possible and how can I do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":64849655,"Users Score":1,"Answer":"Yes, it's possible. You may design \/ modify the (so far unseen) code so as to PUSH any such need to change a port# on-the-fly to the PULL-side, to release the 5535 and use another one.\nThe PULL-side shall then call .disconnect() and .close() methods, so as to release the said port 5535 ( plus notify that it has done so, perhaps by another PUSH\/PULL to the .bind()-locked party, that it can now unbind and close the .bind()-locked port# 5535 too) and next setup a new connection to an announced \"new_port#\", received from the initial notification ( which ought have been already .bind()-locked on the PUSH-side, ought it not? :o) ).\nThat easy.","Q_Score":1,"Tags":"python,serialization,rabbitmq,zeromq,simplexmlrpcserver","A_Id":64920442,"CreationDate":"2020-11-15T20:51:00.000","Title":"How to change the value of a variable at run time from another script at remote machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello I am trying to click on a button within python selenium that has no ID. The button has the text Submit an application within it. However there are multiple phrases of \"Submit an application\" on the website. The attributes of the website are:\n<a class= \"button\" href = \"(a link)\" analytics-on=\"click\" analytics-category=\"Body\" analytics-event=\"(a link)\" analytics-label=\"Submit an application||(a link)\">","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":64851471,"Users Score":0,"Answer":"you can try with css_selector.\ndriver.find_element_by_css_selector('[analytics-on=\"click\"]').click()\ndriver.find_element_by_css_selector('[analytics-category=\"Body\"]').click()\nor link_text method  is also a good choice in locating an a tag,\ndriver.find_element_by_link_text(\"Submit an application\").click()","Q_Score":0,"Tags":"python,python-3.x,selenium,selenium-webdriver,selenium-chromedriver","A_Id":64852151,"CreationDate":"2020-11-16T01:05:00.000","Title":"clicking on button no ID in Selenium python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm looking to build a test with 4000 browser sessions using a Locust\/Selenium approach. I tried using the same approach using JMeter\/Selenium using headless browsers and for many reasons I've come to the conclusion that it's not possible. I'm familiar with running Browser-based load testing tools and with TrueClient I can reach around 45 Browsers\/users per\/Slave\/agent (loaded servers, 64RAM and 16CPU's). Silk Performer BDLT suggests around 15 or 20 sessions. I've looked at 'realbrowserlocusts' and it's really peaked my interest because I used locust as part of some Covid-19 application testing I ran back in February. Are there any metrics of how many browsers a slave can handle using selenium and any metrics of how many slaves Locust can handle?\nShould I be looking at PhantomJS instead? My org is looking to do away with all commercial tools and going to opensource and need to add a browser-based load testing solution. JMeter\/Gatling\/Locust work great for the protocol level applications\nAny suggestions would be great.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":462,"Q_Id":64852055,"Users Score":0,"Answer":"The only real answer is \"it depends\".\nI've been able to run some 30 clients & a total of maybe 2-3 clicks\/s on a moderately advanced site (plenty of javascript, but nothing crazy) on 2018 macbook pro (6-core i7, 16GB RAM). The problem is that you can't really know before hand how much resources you will need, and you may start to get intermittent errors as you run out of resources.\nWhen running Selenium, the browser will be the heavy part so expect similar performance with Locust+Selenium as you would get with Jmeter+Selenium.\nPhantomJS is in most cases slower than headless Chrome so I wouldnt bother with that.","Q_Score":0,"Tags":"python,selenium-chromedriver,phantomjs,locust","A_Id":64854425,"CreationDate":"2020-11-16T02:45:00.000","Title":"Guidelines with Locust\/Selenium and the number of browser sessions per\/slave","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm facing a problem with ANFIS model if the number of columns used in X range exceeds two I will receive an error as below. Is there any way to increase the number of Inputs ? Thanks In advance\nimport anfis\nimport membershipfunction\nimport mfDerivs\nimport pandas as pd\nimport numpy as np\nts = pd.read_csv(\"ANFIS training sets.csv\")\nX = ts.iloc[:,0:3].values\nY = ts.iloc[:,-1].values\nError:\nNumber of variables does not match number of rule sets\nTraceback (most recent call last):\nFile \"D:\/UTAR\/ANFIS monthly Inflow.py\", line 16, in \nanf.trainHybridJangOffLine(epochs=5)\nFile \"D:\\UTAR\\anfis.py\", line 66, in trainHybridJangOffLine\n[layerFour, wSum, w,] = forwardHalfPass(self, self.X)\nFile \"D:\\UTAR\\anfis.py\", line 178, in forwardHalfPass\nlayerOne = ANFISObj.memClass.evaluateMF(Xs[pattern,:])\nFile \"D:\\UTAR\\membershipfunction.py\", line 22, in evaluateMF\nreturn [[self.funcDictself.MFList[i][k][0] for k in range(len(self.MFList[i]))] for i in range(len(rowInput))]\nFile \"D:\\UTAR\\membershipfunction.py\", line 22, in \nreturn [[self.funcDictself.MFList[i][k][0] for k in range(len(self.MFList[i]))] for i in range(len(rowInput))]\nIndexError: list index out of range","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":185,"Q_Id":64852604,"Users Score":0,"Answer":"Anyway after reading through python libraries it just accept 2 inputs so my advice is do use MATLAB as it is a lot more easier as ANFIS is already built in it","Q_Score":0,"Tags":"python,pycharm,artificial-intelligence,indexoutofrangeexception","A_Id":64869476,"CreationDate":"2020-11-16T04:08:00.000","Title":"Is there any way to have more than 2 inputs in ANFIS?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using the 3.8.6 version of Python. I wanted to change to 3.9. I went to the official website\nand have downloaded it. But, I can't change my Interpreter in the IDE I use(PyCharm). Please help.\nThanks\nPS: I am new to programming and don't know much. Please be easy.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":545,"Q_Id":64853212,"Users Score":-1,"Answer":"Open a new file and it automatically will ask u to select the existing interpreters and it will show the location of each while choosing ex. Virtualenv, pipenv, conda etc","Q_Score":0,"Tags":"python,interpreter","A_Id":64853270,"CreationDate":"2020-11-16T05:49:00.000","Title":"Changing Python Interpreter in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just installed the latest Termux on my Android device and Python 3.9 is the default Python installation. I need to run Python 3.8.x due to some package incompatibilities.\nMy searching tells me there is no way to downgrade Python within Termux - is this correct?\nIf I install a previous version of Termux, will this in turn install an earlier version of Python or will it just collect the same default version?\nIs there another way for me to make this change?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":11692,"Q_Id":64853742,"Users Score":2,"Answer":"It doesn't depends upon the Version of termux. It depends upon the repository. And it always update it's packages . So i think there is no way","Q_Score":2,"Tags":"python,android,downgrade,termux","A_Id":64853866,"CreationDate":"2020-11-16T06:50:00.000","Title":"Need to run Python 3.8.x on Termux on Android, currently installed with Python 3.9","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"is there any way to sum odd numbers from 1 to n but without any loops and if there isn't a way how can i create this by fast algorithm to do this task in less than n loops.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":479,"Q_Id":64855745,"Users Score":0,"Answer":"You can try the one below, which loop through from 1 to n, stepping 2\nsum(range(1,n,2))","Q_Score":0,"Tags":"python,algorithm,performance,optimization","A_Id":64861609,"CreationDate":"2020-11-16T09:47:00.000","Title":"without Loops to Sum Range of odd numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I have a problem and 2 hours of research haven't helped.\nI want to write a method that will return me a Boolean if a web-domain(e.g. \"google.com\", without http\/s) has an ssl-certificate.\nI have a big csv of domain names, which I need to process and check if the domains have a ssl-certificate, is there a method maybe in pythons ssl module?\nThank you for your help, TomiiPomii.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":576,"Q_Id":64856092,"Users Score":1,"Answer":"By using module ssl you can call ssl.get_server_certificate((host, port)) to retrieve SSL of specified host in PEM format. You will then have to parse the PEM file to actually retrieve the certificate values, but if you only care about the website having or not having it, simply check the return value.","Q_Score":1,"Tags":"python,ssl,web,dns,certificate","A_Id":64856235,"CreationDate":"2020-11-16T10:11:00.000","Title":"How to check if a domain has a ssl certificate in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are running a Cloud Composer setup on GCP and want to run a remote ETL job in a secured environment on premises.\nCloud Composer uses Redis which is running on the K8S cluster.\nWe can not connect to it via VPN.\nHow can we use our master node on GCP to allow the remote worker to interact with it?\nCan we safely expose our Redis?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":504,"Q_Id":64861286,"Users Score":0,"Answer":"You can configure a password that Airflow will provide Redis to access it. You can also set cloud permissions so that only your Airflow machines will have access to the Redis machine or access to the Redis ports on the machine that it's posted on.\nYou will add significant latency by having it connect to an on premises machine though.","Q_Score":0,"Tags":"python,celery,airflow,google-cloud-composer","A_Id":64867928,"CreationDate":"2020-11-16T15:56:00.000","Title":"Use Cloud Composer with Celery Executor to run job on remote worker in secured network","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Each worker runs a long CPU-bound computation. The computation depends on parameters that can change anytime, even while the computation is in progress. Should that happen, the eventual result of the computation will become useless. We do not control the computation code, so we cannot signal it to stop. What can we do?\n\nNothing: Let the worker complete its task and somehow recognize afterwards that the result is incorrect and must be recomputed. That would means continuing using a processor for a useless result, possibly for a long time.\nDon't use Pool: Create and join the processes as needed. We can then terminate the useless process and create another one. We can even keep bounds on the number of processes existing simultaneously. Unfortunately, we will not be reusing processes.\nFind a way to terminate and replace a Pool worker: Is terminating a Pool worker even possible? Will Pool create replace the terminated one? If not, is there an external way of creating a new worker in a pool?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":64864109,"Users Score":1,"Answer":"Given the strict \"can't change computation code\" limitation (which prevents checking for invalidation intermittently), your best option is probably #2.\nIn this case, the downside you mention for #2 (\"Unfortunately, we will not be reusing processes.\") isn't a huge deal. Reusing processes is an issue when the work done by a process is small relative to the overhead of launching the process. But it sounds like you're talking about processes that run over the course of seconds or longer; the cost of forking a new process (default on most UNIX-likes) is a trivial fraction of that, and spawning a process (default behavior on MacOS and Windows) is typically still measured in small fractions of a second.\nFor comparison:\nOption #1 is wasteful; if you're anywhere close to using up your cores, and invalidation occurs with any frequency at all, you don't want to leave a core chugging on garbage indefinitely.\nOption #3, even if it worked, would work only by coincidence, and might break in a new release of Python, since the behavior of killing workers explicitly is not a documented feature.","Q_Score":0,"Tags":"python,python-multiprocessing,pool","A_Id":64864274,"CreationDate":"2020-11-16T19:02:00.000","Title":"Can one terminate a python process which is a worker in a pool?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script which basically take the minute wise electrical load data, solar production data and does some energy flow analyses. It's fairly complex algorithm which involves a lot of loops and huge DataFrame, matrices, and arrays. When I work on the script for sometime it takes, on an average 35s to execute. All the fans of my machine start to blow.\nBut suppose I leave my PC for 3-4 hours and come back, the same code takes more than 120s to execute.\nWhy is this so and is there a way I could avoid this?\nAny help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":184,"Q_Id":64866463,"Users Score":1,"Answer":"This is happening because of Caching.\nWhen you load data from the same place for the first time the data is stored in an easier accessible place (cache) because of the belief that you will soon use that data again.\nWhen you leave your computer that space is filled with other data that other processes use.\nThis is a fundamental part of how a computer is built and the various optimization chip designers add in order to make a computer (CPU) faster.\nThis phenomenon is also known as \"cold run\".\nEdit:\nLoading data includes loading the actual code segments (heap, stack, etc) into memory","Q_Score":1,"Tags":"python,pandas,performance,numpy","A_Id":64866530,"CreationDate":"2020-11-16T22:09:00.000","Title":"Python program takes too long to execute for the first time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So am working in a group project, we are using python and of the code is on GitHub. My question is how do I activate the virtual environment? Do I make one on my own using the \"python virtual -m venv env\" or the one that's on the repo, if there is such a thing. Thanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":559,"Q_Id":64869171,"Users Score":0,"Answer":"Yes, you'll want to create your own with something like: python -m venv venv. The final argument specifies where your environment will live; you could put it anywhere you like. I often have a venv folder in Python projects, and just .gitignore it.\nAfter you have the environment, you can activate it. On Linux: source venv\/bin\/activate. Once activated, any packages you install will go into it; you can run pip install -r requirements.txt for instance.","Q_Score":1,"Tags":"python,django","A_Id":64869266,"CreationDate":"2020-11-17T04:00:00.000","Title":"How do I activate python virtual environment from a different repo?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So am working in a group project, we are using python and of the code is on GitHub. My question is how do I activate the virtual environment? Do I make one on my own using the \"python virtual -m venv env\" or the one that's on the repo, if there is such a thing. Thanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":559,"Q_Id":64869171,"Users Score":1,"Answer":"virtual env is used to make your original env clean. you can pip install virtualenv and then create a virtual env like virtualenv \/path\/to\/folder then use source \/path\/to\/folder\/bin\/activate to activate the env. then you can do pip install -r requirements.txt to install dependencies into the env. then everything will be installed into \/path\/to\/folder\/lib\nalteratively, you can use \/path\/to\/folder\/bin\/pip install or \/path\/to\/folder\/bin\/python without activating the env.","Q_Score":1,"Tags":"python,django","A_Id":64869263,"CreationDate":"2020-11-17T04:00:00.000","Title":"How do I activate python virtual environment from a different repo?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to use Tensorflow.net and Keras.net nuget packages for my project, but I have an error.\nUnable to load DLL 'python38' or one of its dependencies. \nI managed to remove this error by adding the python38.dll file to the bin folder. But I would like to use python 3.6 rather than version 3.8.\nHow can I set the version of python in my .net core project ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":190,"Q_Id":64872480,"Users Score":0,"Answer":"I found the solution by lowering the version of Keras.net and taking a version 3.6.XX.","Q_Score":0,"Tags":"python,.net-core,python.net","A_Id":64876865,"CreationDate":"2020-11-17T09:24:00.000","Title":"How to change the python version in a .net project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried everything but i don't find a working code for my discord.py bot to ask for a picture, wait for the user to send it, and then reply. I hope you can help me out.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":493,"Q_Id":64873399,"Users Score":0,"Answer":"I do not know about discord.py but are there not events for pictures sent by users? If so what about replying when the event is triggered?","Q_Score":0,"Tags":"python,discord,discord.py","A_Id":64873551,"CreationDate":"2020-11-17T10:25:00.000","Title":"How do i make a bot wait for a picture?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know how to use scikit-learn and pandas to encode my categorical data. I've been using the category codes in pandas for now which I later will transform into an OneHot encoded format for ML.\nMy issues is that I need to create a pre-processing pipeline for multiple files with the same data format. I've discovered that using the pandas category codes encoding is not consistent, even if the categories (strings) in the data are identical across multiple files.\nIs there a way to do this encoding lexicographically so that it's done the same way across all files or is there any specific method that can be used which would result in the same encoding when applied on multiple files?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":64875297,"Users Score":0,"Answer":"The LabelEncoder like all other Sklearn-Transformers has three certain methods:\n\nfit(): Creates the labels given some input data\ntransform(): Transforms data to the labels of the encoder instance. It must have called fit() before or will throw an error\nfit_transform(): That's a convenience-method that will create the labels and transform the data directly.\n\nI'm guessing you are calling fit_transform everywhere. To fix this, just call the fit-method once (on a superset of all your data because it will throw an error if it encounters a label that was not present in the data you called fit on) and than use the transform method.","Q_Score":0,"Tags":"python,pandas,scikit-learn","A_Id":64875397,"CreationDate":"2020-11-17T12:28:00.000","Title":"Maintaining label encoding across different files in pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use conda commands to export env to a file on my pc and create new env on other pc using creating file.\nconda env create --prefix .\/envs -f myenv.yml\nbut after this command take so time and long and infinite time displaying Installing pip dependencies: \\\nWhy? and How solve it this problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":346,"Q_Id":64878633,"Users Score":0,"Answer":"Conda sometimes gets hung up for no reason. If stuck for \"infinite time\", try hitting the ENTER key or Ctrl+c one time. This helps the console catch up to the actual processes are doing.\nIf it is actually a problem with pip, try to verify your connection to pip by running pip commands. You could also try removing those dependencies from the yml and see if the env creation still gets hung up (you can always add them manually afterwards).","Q_Score":2,"Tags":"python,virtualenv,conda","A_Id":64879174,"CreationDate":"2020-11-17T15:52:00.000","Title":"Conda create frome file take so long","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a Conda Environment on my Manjaro Linux system.\nAs I develop a Kivy App and run it, it runs fine.\nThen when I go to compile it into an APK to run on my Android Tablet that's when I run into a strange problem.  I can successfully create an APK and install it on my Tablet.\nBut...\nPython-For-Android downloads packages, that I aleady have installed, when building my APK.  Sometimes it downloads versions I'm not using. and Sometimes it can't find a package that I already have installed.\nMy Question is this: How can I override (maybe in my Buildozer Spec file) P4A downloading packages (I guess it's called recipes) and to JUST USE the packages I already have downloaded and installed in my Conda Environment. (this way my compiled APK will be exactly identical to the Kivy App I'm running on my Linux machine.)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":473,"Q_Id":64881147,"Users Score":0,"Answer":"I run into a strange problem. I can successfully create an APK and install it on my Tablet. But... Python-For-Android downloads packages, that I aleady have installed, when building my APK. Sometimes it downloads versions I'm not using\n\nThis isn't a strange problem, it's just how python-for-android works. It needs to install packages for the android environment, which isn't necessarily possible using what you have locally, and even if it was it's still a simpler way for python-for-android to operate.\n\nMy Question is this: How can I override (maybe in my Buildozer Spec file) P4A downloading packages (I guess it's called recipes) and to JUST USE the packages I already have downloaded and installed in my Conda Environment\n\nYou can't. There are options in the buildozer.spec file to specify the source directory for a given recipe, but this needs to be pointed at the source directory of the project (i.e. for a python module the root directory with a setup.py), not the installed package in another python environment.\nDepending on how conda caches packages, you might be able to point it at what it's pulled, but this won't work for e.g. wheels.\n\nthis way my compiled APK will be exactly identical to the Kivy App I'm running on my Linux machine.\n\nIf this is your goal, you can specify versions for things using requirements=package==version, e.g. requirements=colorama==0.4.4. However, for packages installed using recipes not all versions may be supported, it's normally a good idea to use the defaults. For instance, only certain python3 minor versions are supported.","Q_Score":0,"Tags":"python,kivy,buildozer,p4a,python-for-android","A_Id":64882743,"CreationDate":"2020-11-17T18:27:00.000","Title":"Buildozer and Python-for-Android","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to test how a package that I've created installs on a machine with a base Python 3 install, meaning no additional packages have been installed via pip, easy_install, etc.\nHow do I setup a virtual environment that acts like a clean install of Python 3? If I create a pipenv or virtualenv, then list all my installed packages, the 30 or so that I have are all still there. How can I make a Python environment that behaves like a brand new install of Python and has no extra packages?\nThis is in Raspberry Pi OS which has only one user, so using the --user flag in pip install --user might as well be a global install. I considered creating a new pipenv then pip uninstalling everything, but am worried that will break something.\nThanks for your help.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":95,"Q_Id":64881285,"Users Score":1,"Answer":"I am sorry I am not a virtualenv user, however here is what I could suggest if you have conda installed:\nconda create -n myenv python=3.6\nWhere myenv is the name of your environment and 3.6 the python version.\nYou can then enable the environment by doing:\nconda activate myenv","Q_Score":0,"Tags":"python,python-3.x,virtualenv,pipenv","A_Id":64881551,"CreationDate":"2020-11-17T18:36:00.000","Title":"How to create a Python 3 environment that has only standard lib, no extra packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"New to marketo so forgive me if there's an easy answer here.\nFor my use case, I need to pull all marketo leads from the database as well as all activities. From a daily quota perspective, leads aren't a huge issue but file size on activities is a problem. On first run, I'd need to retrieve all activities and leads from inception of Marketo db but one month of activities can be in excess of the 500mb limit. Is there a better\/more efficient way to pull all the data I need or is the answer here just creating a process that pulls activities in 500mb increments and waits until the quota reset time to go again after exceeding 500mb?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":64883071,"Users Score":0,"Answer":"Short answer: yes, just wait and go through as many days as you need.\nLong answer: depends. You can contact Marketo about increasing the 500MB API export limit if needed\u2014I believe this comes with an additional charge if needed on an ongoing basis, but I'm less clear on temporary increases to get historical data. Additionally, if you already have 500MB' worth of data in a month, the other options I'd recommend, such as specifically targeting activities and writing them on a one-off basis, probably aren't going to make sense.\nYou could also tweak what you're downloading in your bulk export\u2014there's often repeated data that doesn't make sense to capture twice. Two examples I can think of immediately are around score changes (which produce both a unique score activity and a unique data value change activity) and lifecycle model changes (which also both produce a unique stage change activity and a data value change activity). Trimming these down may get you further along faster; in both cases, I'd recommend discarding the data value change.","Q_Score":0,"Tags":"python,marketo","A_Id":65148829,"CreationDate":"2020-11-17T20:47:00.000","Title":"How to efficiently pull all activities from Marketo and deal with 500mb daily quota","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Since today tensorflow seems to output the entire model per epoch for some reason. I am breaking my head over this problem and have no idea what to do.\nEpoch 1\/12\niterator: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\niterator_1: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential_conv2d_conv2d_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential_conv2d_biasadd_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential_conv2d_1_conv2d_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential_conv2d_1_biasadd_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential_conv2d_2_conv2d_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential_conv2d_2_biasadd_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential_dense_matmul_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential_dense_biasadd_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential_dense_1_matmul_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential_dense_1_biasadd_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential_dense_2_matmul_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential_dense_2_biasadd_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nassignaddvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nassignaddvariableop_1_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_cast_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_cast_2_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_cast_3_readvariableop_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_resourceapplyadam_m: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_resourceapplyadam_v: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_1_resourceapplyadam_m: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_1_resourceapplyadam_v: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_2_resourceapplyadam_m: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_2_resourceapplyadam_v: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_3_resourceapplyadam_m: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_3_resourceapplyadam_v: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_4_resourceapplyadam_m: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_4_resourceapplyadam_v: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_5_resourceapplyadam_m: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_5_resourceapplyadam_v: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_6_resourceapplyadam_m: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_6_resourceapplyadam_v: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_7_resourceapplyadam_m: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_7_resourceapplyadam_v: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_8_resourceapplyadam_m: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_8_resourceapplyadam_v: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_9_resourceapplyadam_m: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_9_resourceapplyadam_v: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_10_resourceapplyadam_m: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_10_resourceapplyadam_v: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_11_resourceapplyadam_m: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nadam_adam_update_11_resourceapplyadam_v: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nassignaddvariableop_2_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nassignaddvariableop_3_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nassignaddvariableop_4_resource: (_Arg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nIteratorGetNext: (IteratorGetNext): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nExpandDims: (ExpandDims): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d\/Conv2D\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d\/Conv2D: (Conv2D): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d\/BiasAdd\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d\/BiasAdd: (BiasAdd): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d\/Relu: (Relu): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/max_pooling2d\/MaxPool: (MaxPool): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d_1\/Conv2D\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d_1\/Conv2D: (Conv2D): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d_1\/BiasAdd\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d_1\/BiasAdd: (BiasAdd): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d_1\/Relu: (Relu): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/max_pooling2d_1\/MaxPool: (MaxPool): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d_2\/Conv2D\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d_2\/Conv2D: (Conv2D): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d_2\/BiasAdd\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d_2\/BiasAdd: (BiasAdd): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/conv2d_2\/Relu: (Relu): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/max_pooling2d_2\/MaxPool: (MaxPool): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/flatten\/Reshape: (Reshape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/dense\/MatMul\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/dense\/MatMul: (MatMul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/dense\/BiasAdd\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/dense\/BiasAdd: (BiasAdd): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/dense\/Sigmoid: (Sigmoid): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/dense_1\/MatMul\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/dense_1\/MatMul: (MatMul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/dense_1\/BiasAdd\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/dense_1\/BiasAdd: (BiasAdd): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/dense_1\/Tanh: (Tanh): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/dense_2\/MatMul\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/dense_2\/MatMul: (MatMul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/dense_2\/BiasAdd\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/dense_2\/BiasAdd: (BiasAdd): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/Cast: (Cast): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/sub: (Sub): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/clip_by_value\/Minimum: (Minimum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/clip_by_value: (Maximum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/add: (AddV2): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/Log: (Log): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/mul: (Mul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/sub_1: (Sub): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/sub_2: (Sub): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/add_1: (AddV2): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/Log_1: (Log): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/mul_1: (Mul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/add_2: (AddV2): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/Neg: (Neg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/Mean: (Mean): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/weighted_loss\/Mul: (Mul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/weighted_loss\/Sum: (Sum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/weighted_loss\/num_elements: (Size): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/weighted_loss\/num_elements\/Cast: (Cast): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/weighted_loss\/Sum_1: (Sum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/weighted_loss\/value: (DivNoNan): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nShape: (Shape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nstrided_slice: (StridedSlice): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nCast: (Cast): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nMul: (Mul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nSum: (Sum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAssignAddVariableOp: (AssignAddVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nSum_1: (Sum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAssignAddVariableOp_1: (AssignAddVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/value\/BroadcastGradientArgs: (BroadcastGradientArgs): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/value\/div_no_nan: (DivNoNan): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/value\/Sum: (Sum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/value\/Reshape: (Reshape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/value\/Neg: (Neg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/value\/div_no_nan_1: (DivNoNan): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/value\/div_no_nan_2: (DivNoNan): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/value\/mul: (Mul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/value\/Sum_1: (Sum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/value\/Reshape_1: (Reshape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/Reshape: (Reshape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/Tile: (Tile): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/Reshape_1: (Reshape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/Shape: (Shape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/Tile_1: (Tile): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/Mul: (Mul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Shape: (Shape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/add: (AddV2): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mod: (FloorMod): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/range: (Range): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Fill: (Fill): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/DynamicStitch: (DynamicStitch): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Reshape: (Reshape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/BroadcastTo: (BroadcastTo): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Shape_2: (Shape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Shape_3: (Shape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Prod: (Prod): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Prod_1: (Prod): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Maximum: (Maximum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/floordiv: (FloorDiv): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Cast: (Cast): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/truediv: (RealDiv): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Neg: (Neg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/add_2\/Shape: (Shape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/add_2\/Shape_1: (Shape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/add_2\/BroadcastGradientArgs: (BroadcastGradientArgs): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/add_2\/Sum: (Sum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/add_2\/Reshape: (Reshape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/add_2\/Sum_1: (Sum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/add_2\/Reshape_1: (Reshape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mul\/Shape: (Shape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mul\/Shape_1: (Shape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mul\/BroadcastGradientArgs: (BroadcastGradientArgs): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mul\/Mul: (Mul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mul\/Sum: (Sum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mul\/Reshape: (Reshape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mul_1\/Shape: (Shape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mul_1\/Shape_1: (Shape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mul_1\/BroadcastGradientArgs: (BroadcastGradientArgs): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mul_1\/Mul: (Mul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mul_1\/Sum: (Sum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mul_1\/Reshape: (Reshape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Reciprocal: (Reciprocal): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mul: (Mul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Reciprocal_1: (Reciprocal): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/mul_1: (Mul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/sub_2\/Shape: (Shape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/sub_2\/Shape_1: (Shape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/sub_2\/BroadcastGradientArgs: (BroadcastGradientArgs): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/sub_2\/Neg: (Neg): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/sub_2\/Sum: (Sum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/sub_2\/Reshape: (Reshape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAddN: (AddN): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/clip_by_value\/zeros_like: (ZerosLike): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/clip_by_value\/GreaterEqual: (GreaterEqual): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/clip_by_value\/SelectV2: (SelectV2): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/clip_by_value\/zeros_like_1: (ZerosLike): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/clip_by_value\/LessEqual: (LessEqual): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/clip_by_value\/SelectV2_1: (SelectV2): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/dense_2\/BiasAdd\/BiasAddGrad: (BiasAddGrad): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/dense_2\/MatMul: (MatMul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/dense_2\/MatMul_1: (MatMul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/dense_1\/TanhGrad: (TanhGrad): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/dense_1\/BiasAdd\/BiasAddGrad: (BiasAddGrad): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/dense_1\/MatMul: (MatMul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/dense_1\/MatMul_1: (MatMul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/dense\/Sigmoid\/SigmoidGrad: (SigmoidGrad): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/dense\/BiasAdd\/BiasAddGrad: (BiasAddGrad): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/dense\/MatMul: (MatMul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/dense\/MatMul_1: (MatMul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/flatten\/Shape: (Shape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/flatten\/Reshape: (Reshape): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/max_pooling2d_2\/MaxPool\/MaxPoolGrad: (MaxPoolGrad): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d_2\/ReluGrad: (ReluGrad): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d_2\/BiasAdd\/BiasAddGrad: (BiasAddGrad): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d_2\/Conv2D\/ShapeN: (ShapeN): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d_2\/Conv2D\/Conv2DBackpropInput: (Conv2DBackpropInput): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d_2\/Conv2D\/Conv2DBackpropFilter: (Conv2DBackpropFilter): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/max_pooling2d_1\/MaxPool\/MaxPoolGrad: (MaxPoolGrad): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d_1\/ReluGrad: (ReluGrad): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d_1\/BiasAdd\/BiasAddGrad: (BiasAddGrad): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d_1\/Conv2D\/ShapeN: (ShapeN): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d_1\/Conv2D\/Conv2DBackpropInput: (Conv2DBackpropInput): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d_1\/Conv2D\/Conv2DBackpropFilter: (Conv2DBackpropFilter): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/max_pooling2d\/MaxPool\/MaxPoolGrad: (MaxPoolGrad): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d\/ReluGrad: (ReluGrad): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d\/BiasAdd\/BiasAddGrad: (BiasAddGrad): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d\/Conv2D\/ShapeN: (ShapeN): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d\/Conv2D\/Conv2DBackpropInput: (Conv2DBackpropInput): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/sequential\/conv2d\/Conv2D\/Conv2DBackpropFilter: (Conv2DBackpropFilter): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Cast\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Identity: (Identity): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/add: (AddV2): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Cast_1: (Cast): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Cast_2\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Identity_1: (Identity): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Cast_3\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Identity_2: (Identity): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Pow: (Pow): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Pow_1: (Pow): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/sub: (Sub): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Sqrt: (Sqrt): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/sub_1: (Sub): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/truediv: (RealDiv): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/mul: (Mul): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/sub_2: (Sub): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/sub_3: (Sub): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Adam\/update\/ResourceApplyAdam: (ResourceApplyAdam): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Adam\/update_1\/ResourceApplyAdam: (ResourceApplyAdam): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Adam\/update_2\/ResourceApplyAdam: (ResourceApplyAdam): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Adam\/update_3\/ResourceApplyAdam: (ResourceApplyAdam): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Adam\/update_4\/ResourceApplyAdam: (ResourceApplyAdam): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Adam\/update_5\/ResourceApplyAdam: (ResourceApplyAdam): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Adam\/update_6\/ResourceApplyAdam: (ResourceApplyAdam): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Adam\/update_7\/ResourceApplyAdam: (ResourceApplyAdam): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Adam\/update_8\/ResourceApplyAdam: (ResourceApplyAdam): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Adam\/update_9\/ResourceApplyAdam: (ResourceApplyAdam): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Adam\/update_10\/ResourceApplyAdam: (ResourceApplyAdam): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Adam\/update_11\/ResourceApplyAdam: (ResourceApplyAdam): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Adam\/AssignAddVariableOp: (AssignAddVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nCast_1: (Cast): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nGreater: (Greater): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nCast_3: (Cast): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nEqual: (Equal): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nCast_4: (Cast): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nMean: (Mean): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nSum_2: (Sum): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAssignAddVariableOp_2: (AssignAddVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nSize: (Size): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nCast_5: (Cast): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAssignAddVariableOp_3: (AssignAddVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ndiv_no_nan\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ndiv_no_nan\/ReadVariableOp_1: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ndiv_no_nan: (DivNoNan): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nIdentity: (Identity): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ndiv_no_nan_1\/ReadVariableOp: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ndiv_no_nan_1\/ReadVariableOp_1: (ReadVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ndiv_no_nan_1: (DivNoNan): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nIdentity_1: (Identity): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAssignAddVariableOp_4: (AssignAddVariableOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nNoOp: (NoOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nNoOp_1: (NoOp): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nIdentity_2: (Identity): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nIdentity_3: (Identity): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nidentity_2_RetVal: (_Retval): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nidentity_3_RetVal: (_Retval): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nConst: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nExpandDims\/dim: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nsequential\/flatten\/Const: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/Const: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/Const_1: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/sub\/x: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/add\/y: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/sub_1\/x: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/sub_2\/x: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/add_1\/y: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/Mean\/reduction_indices: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/weighted_loss\/Const: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/weighted_loss\/Const_1: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nbinary_crossentropy\/weighted_loss\/Const_2: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nstrided_slice\/stack: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nstrided_slice\/stack_1: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nstrided_slice\/stack_2: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nConst_1: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nConst_2: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nones: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/value\/Shape: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/value\/Shape_1: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/Reshape\/shape: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/Const: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/weighted_loss\/Reshape_1\/shape: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Size: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Shape_1: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/range\/start: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/range\/delta: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Fill\/value: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Const: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Const_1: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\ngradient_tape\/binary_crossentropy\/Maximum\/y: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/add\/y: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/sub\/x: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/sub_1\/x: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Const: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/sub_2\/x: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/sub_3\/x: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nAdam\/Adam\/Const: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nCast_2\/x: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nMean\/reduction_indices: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nConst_3: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\nConst_4: (Const): \/job:localhost\/replica:0\/task:0\/device:CPU:0\n7\/15 [=============>................] - ETA: 1:12 - loss: 0.0874 - accuracy: 0.9498","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":73,"Q_Id":64883800,"Users Score":1,"Answer":"Figured out why I get this output all of a sudden...\nI have a piece of code at the start of training to prepare my environment, also where I can force use GPU or CPU usage. For over two years now I had been using:\ntf.debugging.set_log_device_placement(True)\nwith no logging happening at all.\nNow all of a sudden tensorflow decided it was a nice idea to start logging all of it. Set it to False and all is good now!","Q_Score":0,"Tags":"python,tensorflow","A_Id":64891750,"CreationDate":"2020-11-17T21:45:00.000","Title":"Tensorflow gives different console output, and is slower for some reason","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have one Kafka topic with one group and one partition\nI have 15 Kafka consumers subscribed to the topic\nI want to all of the consumers to receive a message when I publish it.\nI am using pythonkafka library.\nIs it possible in Kafka?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":64883830,"Users Score":0,"Answer":"Give all consumers a unique consumer group id, then they each have individually tracked offsets and receive the same messages","Q_Score":0,"Tags":"python,apache-kafka","A_Id":64885934,"CreationDate":"2020-11-17T21:47:00.000","Title":"How do I send the same message to all consumers of a kafka topic?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to make a python script that I can turn into an .exe file and give to others in my company. How can I do this without requiring them to download the Anaconda Distribution, conda installing the correct libraries, etc? Does turning a file into an .exe file take care of this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":64885227,"Users Score":0,"Answer":"The existing tools I'm aware of (PyInstaller, py2exe, py2app and cx_Freeze) are all designed to encapsulate all dependencies into a single executable, with no external dependencies, so you should be able to distribute the (possibly quite large) executable without worrying about dependencies.\nTo be clear, there is nothing intrinsic to the .exe conversion that causes it to avoid dependencies. .exe files can depend on .dll library files, external data files, etc. It's just that most people who want to make such an executable are trying to remove dependencies on the installed Python entirely, not just third-party library dependencies, so the tooling tends to support this use case by avoiding any dependencies at all.","Q_Score":0,"Tags":"python","A_Id":64885305,"CreationDate":"2020-11-18T00:13:00.000","Title":"Will python .exe files work for others in my company?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm getting files into a S3 location on a weekly basis and I need to move these files after processing to another S3 location to archive the files. I have cloudera NiFi hosted on AWS. I can't use putS3Object+DeleteS3Object processors at the end of the flow because in this NiFi process because I'm decompressing the file and adding additional column (compressing file and dropping column hits performance). I need a python\/groovy script to move files from S3 loaction. is there any other way to do this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":495,"Q_Id":64889762,"Users Score":1,"Answer":"I need a python\/groovy script to move files from S3 loaction. is there any other way to do this?\n\nNo, you don't. You can use the record processors or a script to update the files and push them to S3. We pull, mutate and reupload data like this all the time without having to control the upload with a script.","Q_Score":0,"Tags":"python,amazon-s3,groovy,apache-nifi","A_Id":64892931,"CreationDate":"2020-11-18T08:48:00.000","Title":"move files from aws s3 loaction to another aws s3 location using NiFi execute script processor","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have simultaneous equations(with many equations), which are no solution, and I need to find a best solutions. Each element of solution must>0 (no 0 or negative).\nnp.linalg.lstsq could get the best solution, but may also appear negative elements.\nscipy.optimize.nnls could get best solution without negative elements, but may also appear 0.\nHow can I restrict to get the best solution with each element>0 or is there any other function can use to solve the problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":64890254,"Users Score":0,"Answer":"For each parameter p, define p_ = p - eps for very small eps.\nSolve for {p_}, then assign p = p_ + eps and you get all parameters above zero.\nIn practice, just add epsilon to the solution.\nIf that doesn't suffice, please explain why.","Q_Score":0,"Tags":"python,numpy,scipy,linear-algebra","A_Id":64890515,"CreationDate":"2020-11-18T09:24:00.000","Title":"python solve the simultaneous equations with solutions > 0","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I created a class in Odoo I used _name = '...' and _inherit = ['mail.thread', 'mail.activity.mixin', 'ir.attachment'].\nWith it I also created a customized view for my new module Documents. Unfortunately I only have access to the documents with admin rights. If I give a user the following rights,\nonly then he \/ she has access to the documents.\nAdministration: Settings\nWhich rights and where would I have to set in order to give all users the right to read and create documents in my new module with inherited \"ir.attachment\"?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":293,"Q_Id":64891086,"Users Score":0,"Answer":"Its under the Technical Settings, Record Rules. Just search the model that you have problems with.","Q_Score":0,"Tags":"python,odoo","A_Id":64892835,"CreationDate":"2020-11-18T10:18:00.000","Title":"Odoo _inherit = 'ir.attachment' access rights","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm making a python program which I would like to distribute. I would also like to have a MySQL database which would store usernames and hashed and salted passwords for each person that registers.\nHow would I go about connecting to the database without anyone being able to open the source code and look at the credentials to connect to the database?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":64891613,"Users Score":0,"Answer":"If you are using git, you can store the credentials in a json file, using json python packpage and put the file name in .gitignore. So, whoever clones your repository will need to create the json file for the script to work, you can also create a README.md explaining how to do it","Q_Score":0,"Tags":"python,mysql-python","A_Id":64898796,"CreationDate":"2020-11-18T10:51:00.000","Title":"Is there a good way to connect to a database without exposing credentials in Python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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 an embedded system that monitors many sensors (GPS, Motor Speed, Temperature..)\nI set up a client-server using sockets in python and I can send from the client(the embedded system) to the server(a Laptop) a string message like \" Hello from client \".\nBut for me it would be great to send data with predifined categories so the server knows the type of the message. Upon reception the server knows it has recieved for example a GPS coordinate or motor speed.\nIs there a way to do it in TCP or using any library or framework?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":64894636,"Users Score":0,"Answer":"I can think of three ways\n\nPut the message kind in the header (next to the message size, probably)\nUse different sockets for each message kind (ugly and complicated but works)\nUse some sort of pub-sub e.g. Kafka, ZeroMQ or RabbitMQ to convey topics","Q_Score":0,"Tags":"python,sockets,tcp,embedded","A_Id":64913137,"CreationDate":"2020-11-18T14:04:00.000","Title":"send data with categories from client to a server using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My requirement is to pass the list of all column names as a parameter in dataframe.select(columns)\n\nFirst of all I am using dataframe.columns to get me the list of\nall the columns. Which I am storing as list1=(dataframe.columns)\n\nSecondly I am using .join to convert my\nlist of columns in strings like - (strList1 = \"','\".join(list1)) which gives me the following output\n\ncol1','col2','col3','col4\n\nAs you see there is some missing single quotes at the start & end of the string\n\nTo rectify strList1 i use f-string formatting as follows -\nstrList2 = f\"{strList1}'\"which gives me the following output\n\n'col1','col2','col3','col4'\n\n\n\nThe main problem:\nWhen you pass strList2 as a parameter in dataframe.select(strList2) gives me the following error\n\nPy4JJavaError: An error occurred while calling o5813.select. :\norg.apache.spark.sql.AnalysisException: cannot resolve\n'backquotecol1','col2','col3','col4'backquote'\ngiven input columns: [\ncol1, col2, db.table.col4,\ndb.table.col3];; 'Project\n['col1','col2','col3','col4']\n\nNote - There is a backquote before col1 and after col4\nI don't understand why the select function isn't taking a proper string value \/ variable (strList2)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":275,"Q_Id":64894644,"Users Score":1,"Answer":"You are passing a string \"'col1','col2','col3','col4'\" to df.select. There is no such column called \"'col1','col2','col3','col4'\", therefore df.select(\"'col1','col2','col3','col4'\") will result in an error.\nInstead of passing that string, what you need to do is to pass in a list of strings of column names to df.select. df.columns is already that list (e.g. ['col1', 'col2']), so you can simply do df.select(df.columns).\nIn fact, if you simply want to show all columns, you can do df.select('*').","Q_Score":1,"Tags":"python,list,apache-spark,pyspark","A_Id":64894990,"CreationDate":"2020-11-18T14:04:00.000","Title":"How to convert all the contents of a list to individual strings to pass as a parameter in dataframe.select()?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"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 a jupyter notebook and use the splitcell extension to have two cells next to each other.\nI now need to share the notebook with non-python colleagues and would like to do that using HTML. When I download the notebook as HTML though, all splitcells are removed and the cells are unrolled and appear after each other.\nIs there a way to keep the split cells next to each other in the final HTML?\nThanks for your help!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":56,"Q_Id":64897370,"Users Score":1,"Answer":"The splitcell extension does not have an nbtconvert support, that is, it works just in your browser.\nOther exensions in the jupyter_contrib_nbextensions (like toc2) have it; but splitcell does not. Sorry.\nSome javascript extensions (that ejecute javascript that makes the output) work with the --to webpdf but you must install some software packages and it still might not work.","Q_Score":0,"Tags":"python,jupyter-notebook,jupyter","A_Id":64897588,"CreationDate":"2020-11-18T16:37:00.000","Title":"Jupyter Notebooks: How to export a notebook to HTML including the splitcell extension?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Generally to create a Virtual Camera we need to create a C++ application and include DirectShow API to achieve this. But with the modules such as\nwin32 modules and other modules we can use win32 api which lets us use these apis in python.\nCan anyone Help sharing a good documentation or some Sample codes for doing this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":194,"Q_Id":64898643,"Users Score":1,"Answer":"There is no reliable way to emulate a webcam on Windows otherwise than supplying a driver. Many applications take simpler path with DirectShow, and emulate a webcam for a subset of DirectShow based applications (in particular, modern apps will be excluded since they don't use DirectShow), but even in this case you have to develop C++ camera enumation code and connect your python code with it.","Q_Score":0,"Tags":"python,windows,directshow,pywin32,win32com","A_Id":64898755,"CreationDate":"2020-11-18T17:55:00.000","Title":"Using Python to access DirectShow to create and use Virtual Camera(Software Only Camera)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use Python on my Mac Catalina to communicate with my Arduino and keep getting \"no such file or directory\" when I input the Mac serial port \/dev\/cu.usbmodem1433301 (Arduino Uno) as indicated in the Arduino Tools\/Port list and I run the script.  If I can't get a workable port for Python, I might as well not use it.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":171,"Q_Id":64898725,"Users Score":1,"Answer":"I just discovered that the usb port on the opposite end of my mac's keyboard is the one that python can communicate with arduino through.  The port I was using was 143301 and the one that works (on the caps lock end) is 143101.  Made all the difference in the world.  Problem solved.  Life is good again.","Q_Score":1,"Tags":"python,macos,arduino,port","A_Id":64921597,"CreationDate":"2020-11-18T18:00:00.000","Title":"What is workable serial port name for MacOS of \/dev\/cu.usbmodem143301 that can be accepted by Python's Pyserial?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have an array of y-values which are evenly spaced along the x-axis and I need to programmatically find the \"troughs\". I think either Octave or Python3 are good language choices for this problem as I know both have strong math capabilities.\nI thought to interpolate the function and look for where the derivatives are 0, but that would require my human eyes to first analyze the resulting graph to know where the maxima and minima already were, but I need this entire thing to be automatic; as to work with an arbitrary dataset.\nIt dawned on me that this problem likely had an existing solution in a Python3 or Octave function or library, but I could not find one. Does there exist a library to automatically report local maximas and minimas within a dataset?\nMore Info\nMy current planned approach is to implement a sort of \"n-day moving average\" with a threshold. After initializing the first day moving average, I'll watch for the next moving average to move above or below it by a threshold. If it moves higher then I'll consider myself in a \"rising\" period. If it moves lower then I'm in a \"falling\" period. While I'm in a rising period, I'll update the maximum observed moving average until the current moving average is sufficiently below the previous maximum.\nAt this point, I'll consider myself in a \"falling\" period. I'll lock in the point where the moving average was previously highest, and then repeat except using inverse logic for the \"falling\" period.\nIt seemed to me that this is probably a pretty common problem though, so I'm sure there's an existing solution.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":53,"Q_Id":64899840,"Users Score":1,"Answer":"Octave answer:\nI believe immaximas and imregionalmax do exactly what you are looking for (depending on which of the two it is exactly that you are looking for - have a look at their documentation to see the difference).\nThese are part of the image package, but will obviously work on 1D signals too.\nFor more 'functional' zero-finding functions, there is also fzero etc.","Q_Score":1,"Tags":"python,python-3.x,math,octave,analytics","A_Id":64910826,"CreationDate":"2020-11-18T19:14:00.000","Title":"How to programatically report reasonable local maximas and minimas in a data set?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a Word2Vec model using gensim but I don't understand what Workers mean.\nThis is an examples from radimrehurek.com with workers = 4 but there is no explanation for that.\nWord2Vec(sentences=common_texts, vector_size=100, window=5, min_count=1, workers=4)\nI would be very thankful of anyone can help me.Thxx","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":314,"Q_Id":64901436,"Users Score":1,"Answer":"It's the number of Python worker threads that will be used during the training phase.\nIf you're using the traditional iterable-of-texts (like your sentences parameter) to supply your corpus, and you're on a machine with at least 4 CPU cores, you'll usually get the best throughput with a workers value of at least 3, and perhaps as high as 8-12 (but never higher than the number of CPU cores minus one).\nIf your input is a plain text file, with tokens already whitespace-delimited, and individual newline-delimited texts of no more than 10000-tokens each, you can use the more-recently introduced corpus_file option to specify the corpus. In that case, you are likely to achieve maximum training throughput with workers equal to the number of available CPU cores.\n(You can get the number of cores with import multiprocessing then multiprocessing.cpu_count().)","Q_Score":0,"Tags":"python,nlp,gensim,word2vec","A_Id":64901759,"CreationDate":"2020-11-18T21:10:00.000","Title":"what does workers means in gensim Word2Vec?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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 <test_store> -keystorescope <test_scope>')\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 want to replace the default Django Admin templates with my own completely custom Django admin. The data in the Dashboard should be populated from the DB. How do I work with templated files? Which files should be overridden ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":57,"Q_Id":64906494,"Users Score":1,"Answer":"you can override the django admin template by creating a a new template folder in your base app and inside that folder create another admin folder, and then create a base_site.html and at top {% extends \"admin\/base.html\" %}","Q_Score":0,"Tags":"python,django-admin","A_Id":64945183,"CreationDate":"2020-11-19T06:32:00.000","Title":"How to create a custom Django admin to replace the existing Django admin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am designing an application where I create 10000 tasks.\nI have a coroutine (async function that queried webservice) and I do asyncio create_task on the coroutine 10000 times with different parameters.\nIs there an upper limit of tasks that can be run concurrently?","AnswerCount":1,"Available Count":1,"Score":-0.3799489623,"is_accepted":false,"ViewCount":1007,"Q_Id":64908523,"Users Score":-2,"Answer":"There is no fixed upper limit, It depends on hardware as you're (probably) not using a theoretical computer but a physical hardware one, so you have limited resources.\nTypically, the number of threads the run truly concurrently is determined by the number of CPUs and CPU cores (including hyper threading) you have. That is to say that at any given time the number of threads running (in the operating system) is equal to the number of \"cores\".","Q_Score":1,"Tags":"python,python-asyncio","A_Id":64908562,"CreationDate":"2020-11-19T09:10:00.000","Title":"What is the Maximum number of python asyncio tasks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I automate clicking on non-browser interactive interfaces (eg. Exe software) without image recognization? (For example, Microsoft's onenote, or some niche software)\nI want to learn related technologies, but I don't know which direction I should go, I hope someone can give me some guidance.\n(Now I can only use Python's image recognition and click technology for these non-browser software, but this efficiency is very low. I hope that I can skip the image recognition & click directly, and can directly manipulate the underlying data processing like manipulating HTTP request or CSS selenium )","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":64908810,"Users Score":0,"Answer":"Free tools are - Autoit, AutoHotkey, Winium etc\nFree tools cannot recognise most of the windows so might need to consider paid tools.\nPaid options are - Testcomplete, UFT(QTP),  Automation anywhere, UI path, Ranorex, Squish\nMy personal recommendation is Test complete. Because I never found a blocker in windows automation, user friendly and economically viable.","Q_Score":0,"Tags":"python,selenium,automation,exe","A_Id":64915073,"CreationDate":"2020-11-19T09:28:00.000","Title":"How to automate Exe software like automate Chrome in Selenium?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to cross-compile Python 2.7.18 for an x86,uclibc machine using a crosstool-ng example toolchain. The commands used are the following:\nCONFIG_SITE=config.site CC=\/home\/msainz\/x-tools\/x86_64-unknown-linux-uclibc\/bin\/x86_64-unknown-linux-uclibc-gcc CXX=\/home\/msainz\/x-tools\/x86_64-unknown-linux-uclibc\/bin\/x86_64-unknown-linux-uclibc-g++ AR=\/home\/msainz\/x-tools\/x86_64-unknown-linux-uclibc\/bin\/x86_64-unknown-linux-uclibc-ar RANLIB=\/home\/msainz\/x-tools\/x86_64-unknown-linux-uclibc\/bin\/x86_64-unknown-linux-uclibc-ranlib READELF=\/home\/msainz\/x-tools\/x86_64-unknown-linux-uclibc\/bin\/x86_64-unknown-linux-uclibc-readelf LDFLAGS=\"-L\/home\/msainz\/Projects\/Selene\/WP3\/local\/uclibc\/base_rootfs\/lib -L\/home\/msainz\/Projects\/Selene\/WP3\/local\/uclibc\/base_rootfs\/usr\/lib\" CFLAGS=\"-I\/home\/msainz\/Projects\/Selene\/WP3\/local\/uclibc\/base_rootfs\/usr\/include -I\/home\/msainz\/Projects\/Selene\/WP3\/local\/uclibc\/base_rootfs\/include\" CPPFLAGS=\"-I\/home\/msainz\/Projects\/Selene\/WP3\/local\/uclibc\/base_rootfs\/usr\/include -I\/home\/msainz\/Projects\/Selene\/WP3\/local\/uclibc\/base_rootfs\/include\" .\/configure --enable-shared --host=x86_64-unknown-linux-uclibc --build=x86_64 --disable-ipv6 --prefix=\/home\/msainz\/Projects\/python2_top_uclibc\/\nfollowed by\nPATH=$PATH:\/home\/msainz\/Projects\/python2_top_glibc\/bin\/ make\nand\nPATH=$PATH:\/home\/msainz\/Projects\/python2_top_glibc\/bin\/ make install\nExecution ends with the following error:\nfi \/home\/msainz\/x-tools\/x86_64-unknown-linux-uclibc\/bin\/x86_64-unknown-linux-uclibc-gcc -L\/home\/msainz\/Projects\/Selene\/WP3\/local\/uclibc\/base_rootfs\/lib -L\/home\/msainz\/Projects\/Selene\/WP3\/local\/uclibc\/base_rootfs\/usr\/lib -Xlinker -export-dynamic -o python \\ Modules\/python.o \\ -L. -lpython2.7 -ldl  -lpthread   -lm   _PYTHON_PROJECT_BASE=\/home\/msainz\/Projects\/Python-2.7.18 _PYTHON_HOST_PLATFORM=linux2-x86_64 PYTHONPATH=.\/Lib:.\/Lib\/plat-linux2 python -S -m sysconfig --generate-posix-vars ;\\ if test $? -ne 0 ; then \\ echo \"generate-posix-vars failed\" ; \\ rm -f .\/pybuilddir.txt ; \\ exit 1 ; \\ fi python: error while loading shared libraries: libc.so.0: cannot open shared object file: No such file or directory generate-posix-vars failed make: *** [Makefile:523: pybuilddir.txt] Error 1 \npython2_top_glibc dir contains a previous Python-2.7.18 installation but for native glibc which was compiled perfectly. libc.so.0 is in fact in the base_rootfs of target system, which is being linked in .\/configure stage. I'm stuck at this at the moment. Any clue will be appreciated. Any additional info will be supplied on demand.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":191,"Q_Id":64909671,"Users Score":0,"Answer":"python: cannot open shared object file: No such file or directory\n\nThis is a run-time loader error. You are trying to run a python executable that is linked against that libc.so.0.\nIf this executable can actually run in your host environment, you can enable it by adding your base_rootfs library to LD_LIBRARY_PATH. Otherwise, you need to use your host python executable in this step of the build process, or disable it altogether.","Q_Score":0,"Tags":"python,linux,cross-compiling,libc,uclibc","A_Id":64909996,"CreationDate":"2020-11-19T10:21:00.000","Title":"Unable to cross-compile Python-2.7.18 for x86,uclibc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have Azure Kinect and I am currently using PyK4a wrapper for python and Azure Kinect SDK for C++ application. I want to use feed from my Kinect in two applications at the same time. Is it possible to do this in parallel?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":94,"Q_Id":64912248,"Users Score":1,"Answer":"One alternative is to create a new application that reads the feed from the Kinect. This new application would then forward the feed to your two applications.","Q_Score":0,"Tags":"python,c++,azure,kinect-sdk,azurekinect","A_Id":64919892,"CreationDate":"2020-11-19T13:02:00.000","Title":"How to use a feed from Azure Kinect in multiple applications?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"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":"I'm trying to install PyQt5 on my Raspberry Pi 4. I work in a virtual env with Python 3.7 installed using source env\/bin\/activate\nI've updated my pip version to 20.2.4.\nIf I use the command:pip install pyqt5, the installation takes too long, it continues displaying for hours:\ncollecting pyqt5\nUsing cached PyQt5-5.15.1.tar.gz (3.3 MB)\ninstalling build dependencies ... done\nGetting requirements to build wheel ... done\nPreparing wheel metadata ...\/\nI've tried to write sudo apt-get install pyqt5 but I found out that the package is installed for Python 2.7 version which was installed as default version on my Raspberry.\nHow can I install PyQt5 correctly? I want to use it in Python3.7.\nI previosly installed pyqtgraph with the command pip and I did not get errors.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1297,"Q_Id":64914367,"Users Score":0,"Answer":"You can use this command sudo apt-get install python3-pyqt5. There is only one question that the pyqt5 by that command doesn't work in the venv of PyCharm.\nFine I found that if the selected python interpreter is system interpreter, it also worked in PyCharm.","Q_Score":0,"Tags":"python-3.x,installation,pyqt5,raspberry-pi4","A_Id":66426572,"CreationDate":"2020-11-19T15:04:00.000","Title":"PyQt5 on Raspberry Pi 4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wandering if there was a way I could easily use Windows Task Scheduler in order to run multiple scripts at the same time. I am wanting to host multiple discord bots on a spare PC that would each have their own bot key for different discord servers; my current understanding is that you cannot easily run multiple node.js bots like this (currently I have 1 in the scheduler and the other I have to run manually) but I was wandering if this is something that can be done in Python or if I can make it happen with node.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":64914853,"Users Score":0,"Answer":"I am not really into Python, don't fall for the name hehe\nAnyway, logically speaking this is a threading problem, did you try enabling multiple threading in the program you are using? or dynamically allow the program\/code to create multiple threads to handle multiple tasks related to the Node.js file you are using!?\nBest Regards","Q_Score":0,"Tags":"python,node.js,discord,autostart","A_Id":64914968,"CreationDate":"2020-11-19T15:32:00.000","Title":"Running multiple Node.js or Python scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Anaconda somehow behaves quite strangely. When I install an application like RStudio and quite Anaconda and restart Anaconda again, I have to reinstall it again. So there is no \"Launch\" icon but at \"Install\" icon. I tried it 5 times and it did not change.\nFurther, when starting Anaconda I get the message that a new version of Anaconda Navigator is available and I am asked to update it. When clicking on \"Yes\" literally nothing happen except that the Dialog window disappears.\nI ran Anaconda both as an Admin and not Admin but the behaviour is always the same. I even unistalled Anaconda and re-installed it but this also did not change anything.\nDoes someone have an idea what the problem is with my Anaconda (my OS is Win 10). I'd appreciate every comment.\nWhat would you advice me to do because it is really inconvenient to install an Application every time I use Anaconda. It this behaviour even usual for Anaconda? I can't imagine that.\nReminder: Does anyone have an idea? What would you suggest me to do. I'd appreciate every comment, even if you are unsure.\nI tried a lot and still could not find a solution. Does really nobody of the Anaconda users have an idea?\nUpdate: I installed 5 different versions of Anaconda and all of them seem to be buggy. They all have the problem of updating the navigator and in some you can't even install R Studio (I waited 2 hours but the 'installation' was still in 'progress'). On some you could install R Studio but when starting Anaconda again you had to re-install it every time.  I tried many different versions (x_86 and x_86_64) from different years. I tried it with and without Admin privileges. The problem with R Studio and updating the Navigatior exist in every version. What could be the problem and what else can I do? I'd highly appreciate any further comment and idea and would be quite thankful for your help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":428,"Q_Id":64916929,"Users Score":0,"Answer":"When you install R Studio in Anaconda, it creates a new environment called rstudio. When you close and open Anaconda, it generally goes to the root environment. You need to select the rstudio environment in order to see R-Studio installed.","Q_Score":0,"Tags":"python,anaconda,rstudio","A_Id":69378790,"CreationDate":"2020-11-19T17:30:00.000","Title":"Applications in Anaconda have to be installed after every start","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"The python API code,\nclient.get_buy_price(currency_pair = 'XRP-EUR')\ngives me the XRP amount as  only \"0.25\".\nHow can I see more decimal, like 0.25126453?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":606,"Q_Id":64917923,"Users Score":1,"Answer":"For some reason in the python API, get_buy_price(...) and get_sell_price(...) only give 2 decimals, but if you use get_spot_price(...) you will get more decimals","Q_Score":0,"Tags":"python,decimal,coinbase-api","A_Id":66049444,"CreationDate":"2020-11-19T18:34:00.000","Title":"How can I get more decimal from Coinbase API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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":"I\u2019ve done the step of installing opencv-python through pip I\u2019ve also pip3 installed opencv-python, my pycharm continues to read no cv2 information available. Any help?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":59,"Q_Id":64921239,"Users Score":2,"Answer":"First thing I would check is the interpreter being used by pycharm. If, for example, your pycharm is set up to use a virtual environment but you manually installed opencv-python through the command line they may not be sharing those libraries.","Q_Score":0,"Tags":"python,pip,pycharm,cv2","A_Id":64921316,"CreationDate":"2020-11-19T22:53:00.000","Title":"Importing cv2 on pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This happens when I do flask db migrate on my production PostgreSQL database.\nLocally, migrate works fine (also PostgreSQL). I'm not sure what's wrong.\nSome info: f1942fde9843 is not in my migrations\/versions. I'm not sure why it's looking for that. But I assume it must be important.\nWhat do I do?\nI'd rather not delete anything in production if I don't have to","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1195,"Q_Id":64922993,"Users Score":0,"Answer":"when you do a migration in a different branch than your original, you'll have missing migrations. to fix, you need to change alembic_version.version_num in the database.","Q_Score":0,"Tags":"python,sqlalchemy,alembic","A_Id":64940234,"CreationDate":"2020-11-20T02:38:00.000","Title":"alembic.util.exc.CommandError: Can't locate revision identified by 'f1942fde9843'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on a game which is written in Python\/Kivy and would like to implement a global leaderboard. Does anyone have any suggestions or more preferably a working example which I can use?  I've stumbled across Redis but struggling to get my head around it for implementation and am not sure this is the right way to go. Any help would be appreciated. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":64923833,"Users Score":0,"Answer":"Okay, I am trying firebase realtime database. There is a YouTube video on how to do this.","Q_Score":0,"Tags":"python,kivy,leaderboard","A_Id":65320482,"CreationDate":"2020-11-20T04:36:00.000","Title":"How can I implement a global high score or leaderboard in Python\/Kivy for android?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to code a script in Python that will take a time input from the user and then open a web page every day at that time. For example: I run the program and say, \"open [page] at [time]\" ideally it would store this in a document in the directory so the program could be closed when not needed and maintain times. The program would then wait until the specified time and then open a web page that was specified earlier at that time.\nI know this is probably super easy but I fully acknowledge I'm a noob. Thanks for not rubbing it in.\nAny help would be great! Thanks!\n-Meteor","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":64924016,"Users Score":0,"Answer":"Just write a script to open a webpage using python. Then you can schedule it to run at a specific time using crontab.","Q_Score":0,"Tags":"python,time,automation","A_Id":64924048,"CreationDate":"2020-11-20T04:57:00.000","Title":"Python Script that opens a web window at a specific time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The size of my jupyter notebook at this moment is 417 MB. I am analyzing 7 huge csv files at the same time and plotting figures using plotly. I am fairly new to coding. Is it normal to create such huge notebooks?\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":595,"Q_Id":64925423,"Users Score":2,"Answer":"Select the Cell -> then select All Outputs -> There you will find Clear option select that. And then save the file. This will reduce the size of your file (From MBs to kbs). It will also reduce the time to load the notebook next time you open it in your browser.","Q_Score":3,"Tags":"python,optimization,jupyter-notebook,plotly","A_Id":64925487,"CreationDate":"2020-11-20T07:30:00.000","Title":"How can i reduce the size of my Jupyter Notebook where i am analyzing a huge dataset and plotting using plotly?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Tensorflow 2.3 introduced new preprocessing layers, such as tf.keras.layers.experimental.preprocessing.Resizing.\nHowever, the typical flow to train on images with Keras uses tf.keras.preprocessing.image.ImageDataGenerator, which can only take a fixed target_size parameter. As far as I understand, the root cause is that keras is handling images as a numpy array in the background, where all images have to be the same size (is that true?).\nWhile I could then use a model with a resizing layer that was trained on a fixed size to then predict images of arbitrary size, this seems to be risky since the training data and inference data would have systematic differences. One workaround could be to use ImageDataGenerator with a target_size and interpolation method that match the ones of the resizing layer, so that during training the resizing layer basically does nothing, but then it seems that the resizing layer is not really of any benefit.\nSo the question is, is there a way to train directly on mixed size images to fully take advantage of the resizing layer?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":489,"Q_Id":64925719,"Users Score":-1,"Answer":"models needs to operate on images of a FIXED size. If you train a model with a fixed size for example (224 X 224) then if you want to use the trained model to make predictions on images you need to resize those images to 224 X 224. Specifically whatever pre-processing you did on the training images you should also do on the images that you wish to predict. For example if your model was trained on RGB images but the images you want to predict are say BGR images (like reading in images with CV2) the results will be incorrect. You would need to convert them to RGB . Similarly if you rescaled you training images by dividing by 255 you should also rescale the images you want to predict.","Q_Score":0,"Tags":"python,tensorflow,keras","A_Id":64932709,"CreationDate":"2020-11-20T07:55:00.000","Title":"Correct way to take advantage of Resizing layer in Tensorflow 2.3?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating calendar events with Python in a shared Google calendar. Up to a few days ago, everything worked fine, but suddendly I am not seeing the events created through Google Calendar API on mobile devices anymore.\nThe events are still showing up in the web interface and I can access the events through API.\nI assumed that there are syncinc issues between the app and, but whenever I create an event manually in the calendar (web interface), it automatically pops up on the mobile app. The issue occurs with two Android phones.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":246,"Q_Id":64926707,"Users Score":4,"Answer":"If you problem is for allday events, then I just encountered the same problem: via the API I generate allday events, with start date = end date. It was working last fall, and as in your case now they appear on the Web interface, and not on the mobile app.\nI dragged one such event to another date on the Web interface, and then it appeared on the mobile. Then, I examined the event under debugger from my code(php in my case), and I observed that dragging the event to another date resulted in having the end date being start date + 1 day. So I changed my code to generate all day events with end date being start date + 1 day, which fixed the problem: now they appear on both the Web interface and the mobile app.\nI guess something changed on the mobile app during a recent update.","Q_Score":1,"Tags":"python,android,google-calendar-api","A_Id":65671801,"CreationDate":"2020-11-20T09:13:00.000","Title":"Event Created Through API not Visible on Google Calendar App","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"django.db.utils.OperationalError: could not connect to server: Connection refused\nIs the server running on host \"localhost\" (::1) and accepting\nTCP\/IP connections on port 5432?\ncould not connect to server: Connection refused\nIs the server running on host \"localhost\" (127.0.0.1) and accepting\nTCP\/IP connections on port 5432?\ncould not connect to server: Connection refused\nIs the server running on host \"localhost\" (127.0.0.1) and accepting\nTCP\/IP connections on port 5432?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":119,"Q_Id":64927284,"Users Score":0,"Answer":"This error occurs when you have set your DB to some external DB like PostgreSQL, which is not running right now. Please make sure ur DB is running.","Q_Score":0,"Tags":"python,django,pythonanywhere","A_Id":64940400,"CreationDate":"2020-11-20T09:54:00.000","Title":"django.db.utils.OperationalError: while deploying to pythonanywhere","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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'm \u062en windows 10 and using pyhcarm community edition 2020\nwhen i install a package using pip  it works and put the package into the directory \"C:\\Users\\HP\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\site-packages\"\nnow trying to import the package get error \"ModuleNotFoundError: No module named <package name>\"\nI tried to install the package I want from the setting > project > project interpreter\nand it works but only for the projects that I'm working on\nalso tried to copy the package from the directory that I mentioned before to the directory \"C:\\Users\\HP\\AppData\\Local\\Programs\\Python\\Python39\\Lib\"\nand seems to be working in every projects just as I hope\nbut don't want to have to copy every package I install by this way so I think I need to change the default directory of installing packages from pip\nnote : I tried getting to the environment variables and change the path but didn't word and I'm not sure what I should change it to","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":483,"Q_Id":64931175,"Users Score":0,"Answer":"You should provide target path to pip by \"-t\" tag just like\npip install package_name -t C:\\Users\\HP\\AppData\\Local\\Programs\\Python\\Python39\\Lib","Q_Score":0,"Tags":"python,python-3.x,pycharm","A_Id":64931397,"CreationDate":"2020-11-20T14:24:00.000","Title":"pip install packages in wrong directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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'm trying to use mypy with a package that I've written, but it can't find my stub file.\nI have a workspace which looks like this:\n\/common\n\/other_dir\n\/another_dir\nI have used a script to add all of these directories to my sys.path.\nInside each directory is a src\/ directory, which contains python packages, and is itself a top-level package (has an init.py).\nin \/common\/src\/test1 I have a module called components.py, and I've written another file next to it, components.pyi.\nThis should work as the stub file for components.py.\nIn \/another\/src\/example.py, I import like this:\nfrom common.src.test1.components.py import x\nx is detected and I can use it, but when I run mypy .\/another\/src\/example.py, it says 'Cannot find implementation or library stub for module named 'common.src.test1.components'.\nIt would be great if anyone who has experience with mypy could help with this.\nMany thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2895,"Q_Id":64934627,"Users Score":0,"Answer":"try\nfrom common.src.test1.components import x  # type: ignore","Q_Score":2,"Tags":"python,import,mypy","A_Id":68568649,"CreationDate":"2020-11-20T18:06:00.000","Title":"Mypy, python paths, \"cannot find implementation or library stub\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Process:               Python [1593]\nPath:                  \/Library\/Frameworks\/Python.framework\/Versions\/3.5\/Resources\/Python.app\/Contents\/MacOS\/Python\nIdentifier:            Python\nVersion:               3.5.1 (3.5.1)\nCode Type:             X86-64 (Native)\nParent Process:        zsh [1569]\nResponsible:           iTerm2 [1562]\nUser ID:               501\nDate\/Time:             2020-11-21 08:15:58.865 +0800\nOS Version:            macOS 11.0.1 (20B29)\nReport Version:        12\nBridge OS Version:     5.0.1 (18P2561)\nAnonymous UUID:        E76F7C18-1C08-D433-A979-D43ED08102AF\nSleep\/Wake UUID:       E8807548-2D08-4BC7-840E-21E0138FEC36\nTime Awake Since Boot: 1400 seconds\nTime Since Wake:       210 seconds\nSystem Integrity Protection: enabled\nCrashed Thread:        0\nException Type:        EXC_CRASH (SIGABRT)\nException Codes:       0x0000000000000000, 0x0000000000000000\nException Note:        EXC_CORPSE_NOTIFY\nTermination Reason:    DYLD, [0x1] Library missing\nApplication Specific Information:\ndyld: launch, loading dependent libraries\nDyld Error Message:\ndyld: No shared cache present\nLibrary not loaded: \/System\/Library\/Frameworks\/CoreFoundation.framework\/Versions\/A\/CoreFoundation\nReferenced from: \/Library\/Frameworks\/Python.framework\/Versions\/3.5\/Resources\/Python.app\/Contents\/MacOS\/Python\nReason: image not found\nBinary Images:\n0x100000000 -        0x100000fff +org.python.python (3.5.1 - 3.5.1) <16087962-95EF-B9B7-A634-47CA97FED0B7> \/Library\/Frameworks\/Python.framework\/Versions\/3.5\/Resources\/Python.app\/Contents\/MacOS\/Python\n0x7fff624d8000 -     0x7fff62573fff  dyld (832.7.1) <2705F0D8-C104-3DE9-BEB5-B1EF6E28656D> \/usr\/lib\/dyld\nModel: MacBookPro15,2, BootROM 1554.50.3.0.0 (iBridge: 18.16.12561.0.0,0), 4 processors, Quad-Core Intel Core i5, 2.4 GHz, 16 GB, SMC\nGraphics: kHW_IntelIrisGraphics655Item, Intel Iris Plus Graphics 655, spdisplays_builtin\nMemory Module: BANK 0\/ChannelA-DIMM0, 8 GB, LPDDR3, 2133 MHz, SK Hynix, -\nMemory Module: BANK 2\/ChannelB-DIMM0, 8 GB, LPDDR3, 2133 MHz, SK Hynix, -\nAirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x7BF), wl0: Sep 11 2020 16:57:49 version 9.30.440.2.32.5.61 FWID 01-129bddb\nBluetooth: Version 8.0.1f5, 3 services, 18 devices, 1 incoming serial ports\nNetwork Service: Wi-Fi, AirPort, en0\nUSB Device: USB 3.1 Bus\nUSB Device: Apple T2 Bus\nUSB Device: Touch Bar Backlight\nUSB Device: Touch Bar Display\nUSB Device: Apple Internal Keyboard \/ Trackpad\nUSB Device: Headset\nUSB Device: Ambient Light Sensor\nUSB Device: FaceTime HD Camera (Built-in)\nUSB Device: Apple T2 Controller\nThunderbolt Bus: MacBook Pro, Apple Inc., 47.4\nThunderbolt Bus: MacBook Pro, Apple Inc., 47.4","AnswerCount":4,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":12935,"Q_Id":64938572,"Users Score":-6,"Answer":"This also happened to me when I was trying to run python3 from iTerm (replacement of terminal). This problem was not occurring with the MacBook's default terminal. After I updated iTerm, this error was not occurring anymore. Please try to update the application on which you are trying to run python3(in my case it was iTerm) instead of updating the python version.","Q_Score":10,"Tags":"python,macos","A_Id":65018254,"CreationDate":"2020-11-21T00:18:00.000","Title":"python3.5 error 'dyld library not loaded: CoreFoundation' after macOS Big Sur update","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I type in which python I get ~\/opt\/anaconda3\/bin\/python, and that's where all packages are going. I clearly didn't know what I was doing when I installed it.\nShould I try to uninstall everything and start over? I'm kind of a beginner and I feel like I've made life more difficult for myself.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":64938702,"Users Score":0,"Answer":"Short answer is No, ~\/opt\/anaconda3\/bin\/python is the default location for python 3.6 or higher to exist when you install anaconda. Python 2.7 comes with Mac which you will most probably will not use for development and when you download anaconda it comes with python 3.9.","Q_Score":0,"Tags":"python,macos,installation","A_Id":64939028,"CreationDate":"2020-11-21T00:44:00.000","Title":"I think I've messed up my Python environment on my Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"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":"Can we import any particular python package from one environment to other in miniconda.\nAnd, how to install a python package in python 2 environment when it needs python 3.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":64940176,"Users Score":0,"Answer":"No, packages are installed for a specific virtual environment, and are not shared. You will need to re-install the packages for other environments.\nConda (and pip) may cache the downloaded materials though, and re-use the zip files.","Q_Score":2,"Tags":"python,anaconda,miniconda","A_Id":64942610,"CreationDate":"2020-11-21T05:36:00.000","Title":"Can we import a python package from one environment to other","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Unfortunately when I make an exe file in windows 10, it never runs in windows 8. Pyinstaller after running in cmd using \"pyinstaller.exe --onefile myfile.py\" gives me an successful exe file in dist folder which runs in my windows 10 successully but never runs in earlier versions like windows 8.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1514,"Q_Id":64941111,"Users Score":1,"Answer":"The problem is most likely that you're missing DLLs on the machine that won't run the executable.\nThis is due to the fact that some where, some time you've installed either a .NET environment, a Visual Runtime environment or a runtime containing a particular set of DLL's for the application to function.\nYou can use the --add-data argument to Add DLLs.","Q_Score":0,"Tags":"python,windows,exe,pyinstaller","A_Id":64941130,"CreationDate":"2020-11-21T08:25:00.000","Title":"exe file created using pyinstaller in windows 10 does not run in windows 8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"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 am new to server sent event please guide me. How can i send data from server to perticular client\/user when change happen in database without reloading page. Also guid me if it is good to use server sent event or i should use websocket for this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":64942337,"Users Score":0,"Answer":"Yes, Server Sent Events is a good alternative for this problem.\n\nHow can i send data from server to perticular client\/user when change happen in database without reloading page.\n\nThe server need to keep an \"handle\" for all connected clients and it should use these connections to send data when a change in the database happens. This can be implemented in many ways, and you may start with how you can detect a \"change\" in the database.","Q_Score":0,"Tags":"python,django,websocket,server-sent-events","A_Id":64976677,"CreationDate":"2020-11-21T11:05:00.000","Title":"How to send data to perticular user using server sent events on django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have an existing tree and I would like to add anytree functionality by adding NodeMixin. The problem is that NodeMixin wants a fixed name 'children' for its sub-elements and I already have a list with a different name.\nAnother problem (I am using mypy) is that the exiting sub-elements list is not optional - terminal nodes have empty lists and NodeMixin wants 'None' as 'children' of terminal objects.\nIt will create a lot of changes if I have to rename the object and  to deal with the optional nature of the children.\nIs it possible to define children as @property or as a reference of the existing sub-elements?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":91,"Q_Id":64943630,"Users Score":0,"Answer":"(a) it is possible to use properties for parent and children, (b) it was easy to write custom iterable class for children to account for differences between anytree and my tree iterations.\nUpdate: is_leaf property has to be overridden  too - otherwise it will be true for every node.","Q_Score":0,"Tags":"python-3.x,anytree","A_Id":64956235,"CreationDate":"2020-11-21T13:31:00.000","Title":"anytree nodemixin using property or reference","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a camera in a fixed position looking at a target and I want to detect whether someone walks in front of the target. The lighting in the scene can change so subtracting the new changed frame from the previous frame would therefore detect motion even though none has actually occurred. I have thought to compare the number of contours (obtained by using findContours() on a binary edge image obtained with canny and then getting size() of this) between the two frames as a big change here could denote movement while also being less sensitive to lighting changes, I am quite new to OpenCV and my implementations have not been successful so far. Is there a way I could make this work or will I have to just subtract the frames. I don't need to track the person, just detect whether they are in the scene.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":490,"Q_Id":64943957,"Users Score":0,"Answer":"There are a handful of ways you could do this.\nThe first that comes to mind is doing a 2D FFT on the incoming images. Color shouldn't affect the FFT too much, but an object moving, entering\/exiting a frame will.\nThe second is to use SIFT or SURF to generate a list of features in an image, you can insert these points into a map, sorted however you like, then do a set_difference between the last image you took, and the current image that you have. You could also use the FLANN functionality to compare the generated features.","Q_Score":1,"Tags":"python,c++,opencv,image-processing","A_Id":64944021,"CreationDate":"2020-11-21T14:08:00.000","Title":"How do you detect if there is motion between frames using opencv without simply subtracting the frames?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a camera in a fixed position looking at a target and I want to detect whether someone walks in front of the target. The lighting in the scene can change so subtracting the new changed frame from the previous frame would therefore detect motion even though none has actually occurred. I have thought to compare the number of contours (obtained by using findContours() on a binary edge image obtained with canny and then getting size() of this) between the two frames as a big change here could denote movement while also being less sensitive to lighting changes, I am quite new to OpenCV and my implementations have not been successful so far. Is there a way I could make this work or will I have to just subtract the frames. I don't need to track the person, just detect whether they are in the scene.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":490,"Q_Id":64943957,"Users Score":2,"Answer":"I am a bit rusty but there are various ways to do this.\nSIFT and SURF are very expensive operations, so I don't think you would want to use them.\nThere are a couple of 'background removal' methods.\n\nAverage removal: in this one you get the average of N frames, and consider it as BG. This is vulnerable to many things, light changes, shadow, moving object staying at a location for long time etc.\n\nGaussian Mixture Model: a bit more advanced than 1. Still vulnerable to a lot of things.\n\nIncPCP (incremental principal component pursuit): I can't remember the algorithm totally but basic idea was they convert each frame to a sparse form, then extract the moving objects from sparse matrix.\n\nOptical flow: you find the change across the temporal domain of a video. For example, you compare frame2 with frame1 block by block and tell the direction of change.\n\nCNN based methods: I know there are a bunch of them, but I didn't really follow them. You might have to do some research. As far as I know, they often are better than the methods above.\n\n\nNotice that, for a @30Fps, your code should complete in 33ms per frame, so it could be real time. You can find a lot of code available for this task.","Q_Score":1,"Tags":"python,c++,opencv,image-processing","A_Id":64944752,"CreationDate":"2020-11-21T14:08:00.000","Title":"How do you detect if there is motion between frames using opencv without simply subtracting the frames?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Detail about question:\nI use following step to connect oracle from local machine.\n\nconnect to remote desktop by ip(xx.xx.xxx.xxx) and username-password\nopen sql developer and connect to database using hostname, port, SID\/service name and username-password.\n\nCan I do this task from local machine itself using python?\nNote: I am able to connect to databases that are accessible from local machine using cx_oracle.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":64944062,"Users Score":0,"Answer":"The firewall on the DB machine maybe set to allow Remote Desktop Protocol only.  Please check the firewall setting on the DB machine.","Q_Score":1,"Tags":"python,database,remote-desktop,cx-oracle","A_Id":64977146,"CreationDate":"2020-11-21T14:18:00.000","Title":"How to connect oracle database that is accessible from remote desktop in local machine using python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Whenever I paste text into a QTextEdit widget, it pastes without changing the font or color. Is there a flag I can set to prevent this? Couldn't find anything on here.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":64945204,"Users Score":0,"Answer":"Instead of using the normal Ctrl+v\/Cmd+v to paste text in, try holding shift while you paste it in.","Q_Score":1,"Tags":"python,pyqt,pyqt5,qtextedit","A_Id":64945248,"CreationDate":"2020-11-21T16:08:00.000","Title":"Paste without changing font","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Been searching for a while in order to understand how to do this basic task without any success which is very strange.\nI have a dataset where some of the rows contain '-', I have no clue under which columns these values lie.\nHow do I search in the whole dataset (including all columns) for '-' and drop the rows containing this value?\nthank you!","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":142,"Q_Id":64949099,"Users Score":0,"Answer":"This is a bit more robust than wwnde's answer, as it will work if some of the columns aren't originally strings:\ndf.loc[~df.apply(lambda x: any('-' in str(col) for col in x), axis = 1)]\nIf you have data that's stored as datetime, it will display as having -, but will return an error if you check for inclusion without converting to str first. Negative numbers will also return True once converted to str. If you want different behavior, you'll have to do something more complicated, such as\ndf.loc[~df.apply(lambda x: any('-' in col if isinstance(col, str) else False for col in x), axis = 1)]","Q_Score":2,"Tags":"python,pandas","A_Id":64949307,"CreationDate":"2020-11-21T23:14:00.000","Title":"Pandas, find and delete rows","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to the MacOS and I have recently downloaded PyCharm on it. I was able to successfully install some packages like numpy, matplotlib, sympy, etc. However, Pytorch won't get installed; not through PyCharm nor through the Terminal. These are the commands I tried in the Terminal (other than attempting to install them directly from PyCharm):\n\npip install torch\npip install torch torchvision torchaudio\n\nI could post the error messages but some are quite lengthy :(\nI'm using Python 3.9 interpreter with pip on the latest version (20.2.4) (everything else is also up to date). Running this on the new Mac Mini (running the M1 chip).\nAny ideas on what I should do? Thanks!!!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1930,"Q_Id":64949501,"Users Score":3,"Answer":"Try building from the source code, run these commands\n\ngit clone https:\/\/github.com\/pytorch\/pytorch.git\ncd pytorch\ngit submodule update --init --recursive\npython3 setup.py build\npython3 setup.py install","Q_Score":1,"Tags":"python,python-3.x,macos,pip,pycharm","A_Id":65528845,"CreationDate":"2020-11-22T00:18:00.000","Title":"Pytorch won't install in PyCharm on MacOS","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to the MacOS and I have recently downloaded PyCharm on it. I was able to successfully install some packages like numpy, matplotlib, sympy, etc. However, Pytorch won't get installed; not through PyCharm nor through the Terminal. These are the commands I tried in the Terminal (other than attempting to install them directly from PyCharm):\n\npip install torch\npip install torch torchvision torchaudio\n\nI could post the error messages but some are quite lengthy :(\nI'm using Python 3.9 interpreter with pip on the latest version (20.2.4) (everything else is also up to date). Running this on the new Mac Mini (running the M1 chip).\nAny ideas on what I should do? Thanks!!!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1930,"Q_Id":64949501,"Users Score":0,"Answer":"Are you using a venv? If so you could try checking the box \"install to user's site packages directory\" in the Project Interpreter settings when you add a package.","Q_Score":1,"Tags":"python,python-3.x,macos,pip,pycharm","A_Id":64950507,"CreationDate":"2020-11-22T00:18:00.000","Title":"Pytorch won't install in PyCharm on MacOS","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im trying to get a good gui for python and tkinter is working fine but I cant put any custom fonts on it\nCan I import any custom fonts from either a ttf or maybe google font if not do you know any other guis that do, do that. (btw it needs to work with linux windows and osX)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":173,"Q_Id":64950357,"Users Score":1,"Answer":"Tkinter provides no cross-platform way to install custom fonts. The only support tkinter has built-in is to use the fonts provided by the OS.","Q_Score":0,"Tags":"python-3.x,macos,user-interface,tkinter,fonts","A_Id":64950405,"CreationDate":"2020-11-22T03:21:00.000","Title":"How to use custom fonts on TKINTER","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Say I had a csv file with 3 columns, 'name', 'price' and 'color'.\nHow could I go about getting the variable of the name of say, the most expensive blue item, the most expensive red, and the most expensive yellow?\nWould really appreciate any help :)","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":64950686,"Users Score":0,"Answer":"Example:\nif your data is like this:\ndata={\"name\":['A-Blue','B-Blue','C-Blue','A-Red','B-Red','C-Red','A-Yellow','B-Yellow','C-Yellow'],\n\"price\":[100,200,300,200,100,300,300,300,100],\n\"color\":['Blue','Blue','Blue','Red','Red','Red','Yellow','Yellow','Yellow']}\nthen create pandas dataframe first with the below command:\npdf=pd.DataFrame(data,columns=['name','price','color'])\nNow get the index of the records with the below command:\npdf.groupby(\"color\")[\"price\"].idxmax()\n[ remember to use argmax instead of idxmax for the pandas older versions]\nNow apply PDF[] around to get the complete row of max value of each color:\npdf.iloc[pdf.groupby(\"color\")[\"price\"].idxmax()]\nTo reset the index  add reset_index to the command:\nSo the final answer is:\npdf.iloc[pdf.groupby(\"color\")[\"price\"].idxmax()].reset_index(drop=True)\nFinal output:\nindex name  price   color\n0   C-Blue  300 Blue\n1   C-Red   300 Red\n2   A-Yellow    300 Yellow\n( even you have duplicate higher price - first record will appear like A-yellow]","Q_Score":0,"Tags":"python,csv,opencsv","A_Id":64951102,"CreationDate":"2020-11-22T04:31:00.000","Title":"Is it possible to find the name of something in a csv given 2 parameters? Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to create Python 3.4.3 virtual environment using venv when running Python 3.9 in my windows? I have tried with Anaconda also but the options available are only 3.8, 3.7, 3.6, 3.5 & 2.7\nIf I download and install Python 3.4.3 from python website, will it be ok? Can it run alongside Python 3.9?\nP.S. Python 3.4.3 is very old but one of our servers is still using it without the possibility of an update. I would like to first test my web app locally whether it works with Python 3.4.3 before deploying.\n(or)\nIs it possible to create a Python 3.9 inside Python 3.4.3 venv? that would also solve my problem if it's possible :)\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":494,"Q_Id":64951264,"Users Score":1,"Answer":"Yes you can install both, but i would advice to store one in user folder and the other on program files. This is to not confuse which python to run on the variable environment unless you set them to two different variable names","Q_Score":0,"Tags":"python-3.x,python-venv","A_Id":64951358,"CreationDate":"2020-11-22T06:25:00.000","Title":"Can we have specific version of python created using venv - Python 3.4.3 venv using Python 3.9","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a depth map image which was obtained using a kinect camera.\nIn that image I have selected a region of size [400,400] and stored it as another image.\nNow, I would like to know how to resize this image into a size of [x,y] in python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1044,"Q_Id":64952495,"Users Score":0,"Answer":"I don't recommend to reduce resolution of depth map the same way like it is done for images. Imagine a scene with a small object 5 m before the wall:\n\nUsing bicubic\/bilinear algorithms you will get depth of something between the object and the wall. In reality there is just a free space in between.\nUsing nearest-neighbor interpolation is better but you are ignoring a lot of information and in some cases it may happed that the object just disappears.\n\nThe best approach is to use the Mode function. Divide the original depth map into windows. Each window will represent one pixel in the downsized map. For each of them calculate the most frequent depth value. You can use Python's statistics.mode() function.","Q_Score":2,"Tags":"python,image-processing,computer-vision,kinect,opencv-python","A_Id":71402433,"CreationDate":"2020-11-22T09:23:00.000","Title":"How to resize a depth map from size [400,400] into size [60,60]?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Please tell me whether or not a from module import * statement affects the execution time of the program. The reason I am asking is because it imports all the functions available in the module.","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":126,"Q_Id":64955468,"Users Score":-1,"Answer":"Yes it does. Each function loaded into the interpreter needs resources. It is normally discouraged to use the import * when programming modules. It is also a little bit faster to directly call a function together with the module (e.g numpy.cos instead of importing cos). You could make just some tests with timeit or cProfile if you want to see for yourself.","Q_Score":0,"Tags":"python,import,module","A_Id":64955557,"CreationDate":"2020-11-22T14:41:00.000","Title":"Does \"from module import *\" affect the execution time of the program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Please tell me whether or not a from module import * statement affects the execution time of the program. The reason I am asking is because it imports all the functions available in the module.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":126,"Q_Id":64955468,"Users Score":0,"Answer":"It doesn't save any time. I just tested it with the time module. Makes no difference whether you import the whole module or you import something from it. It is pretty convenient not having to write the module name for every function you want to use tho.","Q_Score":0,"Tags":"python,import,module","A_Id":64956726,"CreationDate":"2020-11-22T14:41:00.000","Title":"Does \"from module import *\" affect the execution time of the program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i want to code indicator in my tradingview pine editor, for that, I need the current price of a stock or any other scrip to my coding keyword to do operations and generate new output on chart,","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4778,"Q_Id":64955494,"Users Score":2,"Answer":"This seems to work.\n\ncurrentPrice = security(syminfo.tickerid, \"\", ema(close, 1), barmerge.gaps_on, barmerge.lookahead_off)\n\nYou could probably use something other than ema(). If you're writing a strategy, make sure your call to strategy includes calc_on_every_tick=true.\n\nstrategy(\"DCA Bot\", overlay=true, calc_on_every_tick=true)","Q_Score":1,"Tags":"python,editor,indicator,tradingview-api","A_Id":66593608,"CreationDate":"2020-11-22T14:44:00.000","Title":"How to Access data of current price of stocks in Pine Editor Tradingview using ticker id","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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 have a final for school that requires me to make a Django project. I installed python 3.9 on my Mac fine but when I try to run virtualenv venv, I get this error virtualenv: error: argument dest: the destination . is not write-able at \/Users\/BUS\nI am not sure where else I would be able to write in the virtual env. I'm new to this so I don't really know where to go from here? Any help would be very much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1091,"Q_Id":64956535,"Users Score":0,"Answer":"you can give your project directory write and execute permission by running this command chmod u+x \/YOUR\/PATH\/TO\/PROJECT\/SCRIPT and if it doesn't help try sudo, also i'm no expert but learnt a thing that if you run python in any 'ix' systems to have passwords of root setup as then if you run scripts on your workstation chances are the command chmod with sudo gonna break privileges sooner or later, hope this helps, lmk.","Q_Score":1,"Tags":"python,python-3.x,terminal,virtualenv,python-3.9","A_Id":70230875,"CreationDate":"2020-11-22T16:22:00.000","Title":"Trying to create a virtual environment in python 3.9","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've created a Matlab program which resolve some linear program and i've translate the code in python.\nThe two solvers return a different results.\nI've used:\nPYTHON:\nres=linprog(f,A,b,A_eq=None,b_eq=None,bounds=(None,None),options={\"maxiter\":200, \"tol\":1e-6})\nMATLAB\noptions = optimoptions('linprog','Algorithm','interior-point');\n[res,fval]=linprog(f,A,b,[],[],[],[],options);\nDoes anyone know why i get different results?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":96,"Q_Id":64958268,"Users Score":0,"Answer":"Please, note that you compare different implementations of the same idea, but not the same method in different environments, so results may be different.\nIn general, the optimal solution is not stable, even for simple linear problems. If methods are slightly different or data are slightly different, solutions may vary a lot.\nIf I understand correctly modern Matlab interior-point uses a crossover process (after interior-point it locates the closest basis solution), so it is much different from the classical interior-point which scipy implementation is closer to. But even if you try interior-point-legacy in Matlab it probably still will be different from the opensource interior-point used in scipy.\nBut the optimal objective value is stable. So, look at the objective value. If it is closer than your tolerance (1e-6) then you just got numerically different solutions.\nIf the objective value diverges then it may be the result of slightly different data. If you generate data in Matlab write down to file and then read it in Python you may lose accuracy.\nIf data absolutely the same then it means that one of the solvers fails to find a solution. Again, it is different solvers.","Q_Score":0,"Tags":"python,matlab","A_Id":64959071,"CreationDate":"2020-11-22T19:01:00.000","Title":"LINPROG DIFFERENCES MATLAB AND PYTHON","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm parsing pdf documents using various python libraries and can convert it to a list of pages (list of strings). I would like to automatically remove headers and footers, which are substrings that are repeated on almost every page (not necessary on every page). I don't want to rely too much on geometry (such as looking at fixed positions). Assume no metadata is available.\nI'm aware of difflib.SequenceMatcher class and similar tools, but that mostly works on a pair of strings. But I want to leverage the fact that the document has many pages, not just do pair-wise comparisons.\nI'm interested both in an efficient algorithm as well as in possible python tools, if there are any. Thanks for any hint.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":219,"Q_Id":64958301,"Users Score":1,"Answer":"There is a python library PyMuPDF which might help you with your problem. First of all it does not knows anything about headers and footers, but you can extract a lot of metadata dictionary from it and analyze it. I had same problem where I wanted to extract only headers of the pdf file for every page. I used this metadata which contained information about text like font size and font name. In my case, every header title had font size bigger compared to other texts on the same page, so I used that information for extraction.","Q_Score":1,"Tags":"python,algorithm","A_Id":64972605,"CreationDate":"2020-11-22T19:03:00.000","Title":"Extracting headers and footers (text repeated on every page) from documents","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am completely new to Dash, and am attempting to create a Dash app for hosting some visualizations I made with Plotly. I have only ever written code in Jupyter notebooks, and have tried JupyterDash, but get connection errors when I try to run the code for any example\/tutorial apps. What should I be using instead of a Jupyter notebook to create a Dash app? Any suggestions for resources for complete beginners would be greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":64958955,"Users Score":0,"Answer":"It depends on how you want to have this app set up. If running it locally, accessible from your own machine only, is fine, then you can run it from the command line with something like:\npython \/path\/to\/my\/app.py\nIf you want it to be available on the internet, then you're getting into much different territory. Perhaps the simplest way would be to run your app with something like Github and Heroku, although I haven't done that myself so you'd need to search for a tutorial. Beyond that is some heavy lifting with things like purchasing a domain, hosting setup, and more.","Q_Score":0,"Tags":"python,plotly-dash","A_Id":64960261,"CreationDate":"2020-11-22T20:05:00.000","Title":"Where should the code for creating Dash apps be run?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python, what is the actual difference between awaiting a coroutine and using asyncio.run()? They both seem to run a coroutine, the only difference that I can see being that await can only be used in a coroutine.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1163,"Q_Id":64959714,"Users Score":9,"Answer":"That is the exact difference. There should be exactly one call to asyncio.run() in your code, which will block until all coroutines have finished.\nInside any coroutine, you can use await to suspend the current function, and asyncio will resume the function at some future time. All of this happens inside the asyncio.run() function, which schedules what functions can run when.","Q_Score":9,"Tags":"python,async-await,coroutine","A_Id":64959780,"CreationDate":"2020-11-22T21:24:00.000","Title":"await vs asyncio.run() in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I succesfully set up a virtual enviroment in Conda using conda create -n tensor python=3.7 then I installed tensorflow and keras. Now when I try to use the python interpreter by going to add python interpreter then I click on conda.Then I click on Existing enviroment but when I go to select the actuall enterpreter (pythonw.exe) I cant find it where it should be.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":64960849,"Users Score":0,"Answer":"If you activate the tensor environment you created, then typing python will use the Python 3.7 version that was defined in your statement. If you wish to use another version, just create a new virtual environment and use another version of python.","Q_Score":0,"Tags":"python,tensorflow,pycharm,anaconda","A_Id":64990638,"CreationDate":"2020-11-22T23:44:00.000","Title":"Setting up pycharm python interpreter with a conda Enviroment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is simple and divided in two sub-questions :\n\nI have two LabelEncoders with the exact same parameter .classes_ . But when I compare then with ==, they seems different. How can I check they are equal ?\n\nI also want to check two sklearn model (RandomForest already fitted) are equals ? The == check does not seems to work.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":385,"Q_Id":64964765,"Users Score":1,"Answer":"If you compare two objects with ==, it will return False because they have different id.\nYou'd better override __eq__ function of class.","Q_Score":1,"Tags":"python,scikit-learn","A_Id":64965082,"CreationDate":"2020-11-23T08:22:00.000","Title":"Assert two sklearn object are equal","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a project about text files I\u2018m working on. We have several different exercises to complete. However, one we have to create ourselves. I\u2018m kinda stuck since I don\u2018t really have any ideas on what do really do.\nWhat are some interesting tasks we could do? (The txt file is around 10\u2018000 lines long)\nWe already have tasks to: split words and order them by length, amount of occurences for each word, input a word and then output all the sentences they occur in. And also some plotting of most used words. Is there an interesting task that is suitable for beginners?\nThanks in advance for your help!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":26,"Q_Id":64964811,"Users Score":1,"Answer":"An easy one could be:\n\nAsk as input at least 3 separate char and find out all the words which contain those letters\n\nA difficult one could be:\n\nFind out the longest character sequence (so even more than one word) which appears more than once in the text (maybe at least 3 times?)","Q_Score":0,"Tags":"python,text","A_Id":64964932,"CreationDate":"2020-11-23T08:24:00.000","Title":"Python 3 - Ideas for tasks involving .txt files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to start with web development with python, django, react,  javascript and when I download node.js at the windows PowerShell it showed me that its downloading python again and now when I want to run a code at PyCharm it is showing me this error:\nError running 'some new sobject': Cannot run program \"C:\\Users####\\AppData\\Local\\Programs\\Python\\Python39\\python.exe\" (in directory \"\"): CreateProcess error=2, The system cannot find the file specified\nor when I'm typing pip at the cmd it is showing me this error:\nFatal error in launcher: Unable to create process using '\"c:\\users????\\appdata\\local\\programs\\python\\python39\\python.exe\"  \"C:\\Users????\\AppData\\Local\\Programs\\Python\\Python39\\Scripts\\pip.exe\" ': The system cannot find the file specified.\nI searched for some answers and nothing works should I redownload python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":238,"Q_Id":64967390,"Users Score":0,"Answer":"as @Ruli said, it can be due to some special character in the File Name or a Folder, or it can be anything.\nMy suggestion is to move that whole folder that is default created by PyCharm, and move it somewhere like C:\\ , so it is easier to locate the file and run it.\nor if you have any other drive like D:\\ or E:\\ , move it there and try to run the program from the Command Line.","Q_Score":0,"Tags":"python,node.js,pip","A_Id":64968240,"CreationDate":"2020-11-23T11:16:00.000","Title":"error when trying to run a code at pycharm and when typing pip at the cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Flask-based app that is used as a front (HTTP API only) for an image processing task (face detection along with some clustering). The app is deployed to Kubernetes clusters and, unfortunately during load testing it dies.\nThe problem is that all Flask threads are reserved for request processing and the application can't reply to Kubernetes liveness probe (\/health endpoint) via HTTP - so the whole pod gets restarted.\nHow can I resolve it? I thought about a grep-based liveness problem however it doesn't solve the problem. Another idea is to use celery, however, if Flask doesn't support async-processing I'll need to call wait() on a celery task which gives me exactly to the same place.\nFor now I don't consider returning 202 response along with URL for process monitoring.\nAny other ideas?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":242,"Q_Id":64967504,"Users Score":2,"Answer":"How did you deploy Gunicorn etc?\nFastAPI might be better suited for your use case, but migration might be prohibitive. It has built in async support which would should help you to scale better. I like tiangolo's docker containers for this.\nHow long does your image recognition take (seconds, milliseconds)?\nIf you must stick to your current design:\n\nincrease timeout, but be aware that your customers have the same problem - they might time out.\nIncrease resources: More pods so that no pod has no resources left.\n\nIf you're using Flask, be aware that the dev server is not meant for production deployment. Although it is multithreaded, it's not particularly performant, stable, or secure. Use a production WSGI server to serve the Flask application, such as Gunicorn, mod_wsgi, or something else.","Q_Score":0,"Tags":"python,flask,kubernetes","A_Id":64967781,"CreationDate":"2020-11-23T11:24:00.000","Title":"Flask thread pool exhausted","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm a python developer.we use GCS (Google cloud storage) to store our images for past we months which is good but for android it requires to import all the buckets to Firebase Cloud Storage(FCS) for accessing it. We dont want any manual integration. we heard that if we create a bucket on FCS which automatically reflect on GCS which is good and there is no import required.\nWe trying to create bucket directly on firebase cloud storage. may i know is that posstible by programmtically?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":625,"Q_Id":64968685,"Users Score":2,"Answer":"You can't create a new bucket if you are using Spark Plan in FCS, but you access the default bucket to do an operation like Upload\/Download.\ndefault bucket will end in terms of (.appspot.com)","Q_Score":3,"Tags":"python,firebase,google-cloud-storage,firebase-storage","A_Id":68118759,"CreationDate":"2020-11-23T12:43:00.000","Title":"How can i create bucket on Firebase Cloud Storage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"While I'm using Django as my backend and flutter as my front end. I want only the flutter app to access the data from django server. Is there any way to do this thing?\nLike we use allowed host can we do something with that?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":83,"Q_Id":64970938,"Users Score":1,"Answer":"You can use an authentication method for it. Only allow for the users authenticated from your flutter app to use your backend.","Q_Score":0,"Tags":"python,django,flutter,dart","A_Id":65345072,"CreationDate":"2020-11-23T15:05:00.000","Title":"how to authorize only flutter app in djano server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Let there be an pattern that is known at certain points, but has an unknown functional form. Let there also be a data set. Both, as far as the computer can be concerned, are just a set of (x,y) values.\nHowever, I still want to fit my pattern to the data with a simple relation, a*P+b, and I want to find the best values for the parameters a,b with an actual fitting routine. How can I do this with something akin to optimize.curve_fit(), or do I have to invent my own method?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":202,"Q_Id":64971409,"Users Score":0,"Answer":"What you are trying to achieve has a name. It is a regression problem. You want to find a relation between data points and how they are linked.\nHaving said that, you can look into LinearRegression() from sci-kit learn. It would be useful for your case.\nNote: It might be possible that maybe linear regression can't capture whatever relation your data holds then try other models like SVM with a non linear kernel or maybe NN. (duh).","Q_Score":0,"Tags":"python,data-analysis,curve-fitting","A_Id":64971528,"CreationDate":"2020-11-23T15:32:00.000","Title":"Fitting one data pattern to another in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python, a function has access to all variables in-scope at the time of its creation. What is this feature called?\nJavaScript has this same behavior, and we say that functions are lexical-scoped in it. Will the same apply to Python?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":89,"Q_Id":64972872,"Users Score":1,"Answer":"In Python, a function has access to all variables in-scope at the time of its creation. What is this feature called?\n\nA Python function actually has access to all the variable in the scope of its creation, even those defined after the function is closed.\nThe property that a function can access content from its definition environment is called closing over, that function defines (or colloquially is) a closure.\n\nJavaScript has this same behavior, and we say that functions are lexical-scoped in it. Will the same apply to Python?\n\nLexical scoping does apply to function, but it mostly has to do with the chain taken to resolve names: lexical scoping means the names are resolved at the point of definition, dynamic scoping is the other big one and means the names are resolved as the point of use.\nLexical or dynamic scoping applies to all scopes, so in most languages it will also (or only) apply to blocks (e.g. Python only has function-level scoping, C only has block-level scoping, Go has both).","Q_Score":0,"Tags":"python,function,variables","A_Id":64972979,"CreationDate":"2020-11-23T17:02:00.000","Title":"What is this feature of functions in Python formally known as?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"in my mongodb, i have a collection where the docs are created not using ObjectId, how can I get the timestamp (generation_time in pymongo) of those docs? Thank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":62,"Q_Id":64973067,"Users Score":0,"Answer":"If you don't store timestamps in documents, they wouldn't have any timestamps to retrieve.\nIf you store timestamps in some other way than via ObjectId, you would retrieve them based on how they are stored.","Q_Score":0,"Tags":"python,mongodb,pymongo","A_Id":65030060,"CreationDate":"2020-11-23T17:14:00.000","Title":"pymongo getTimestamp without ObjectId","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"Let's say I have a CNN model to classify the handwritten numbers 1 to 10. I am using a dataset with 20,000 samples and I make a train test split of 50:50.\nThat leaves me with 10,000 for training and testing. Will, it automatically pick 1000 images from each class for testing\/training, or will it approximate it?\nI am trying a similar problem, (with different numbers of samples and classes) but I noticed that the testing data is not evenly split. For example, it has 1010 number ones being tested but only 990 number twos.\nIs this normal? I couldn't find any documentation verifying this. My dataset is large enough that the small discrepancy is irrelevant, but I still would like to confirm.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":64978918,"Users Score":0,"Answer":"The test train loader will approximate the split, since it uses sampling with replacement each epoch to generate a test batch.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,testing,training-data","A_Id":64978937,"CreationDate":"2020-11-24T01:18:00.000","Title":"When picking a train test split for model training, does it choose an even number of samples from all class?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hey i wanted to know that if there is a way to make a python output print and disappear like in the case of comparing a user entered word with a world in a list,while quickly printing all the words it has traversed ,quite like a animation?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":791,"Q_Id":64980298,"Users Score":0,"Answer":"One thing you could try to do is clear the console. There are multiple resources on how to do it so I won't explain it here, but it's easy to find on the internet. If you have a bunch of text in the console and there's a specific piece of text that you want to delete, then you can get all of the text in the console as a string and filter out the part that you want to delete, so that way, when you clear the console, you can re-print that back into the console, so that way it disappears but all of the other text elements do not. If that makes sense lol.","Q_Score":0,"Tags":"python","A_Id":64980384,"CreationDate":"2020-11-24T04:33:00.000","Title":"Making python output print and disappear?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe created from an excel sheet (the source).\nThe excel sheet will not have a header row.\nI have a table in mysql that is already created (the target). It will always be the exact same layout as the excel sheet.\nsource_data = pd.read_excel(full_path, sheet_name=sheet_name, skiprows=ignore_rows, header=None)\ndb_engine = [function the returns my mysql engine]\nsource_data.to_sql(name=table_name, con=db_engine, schema=schema_name, if_exists='append', index=False)\nThis fails with an error due to pandas using numbers as column names in the insert statement..\n[SQL: INSERT INTO [tablename] (0, 1) VALUES (%(0)s, %(1)s)]\nerror=(pymysql.err.OperationalError) (1054, \"Unknown column '0' in 'field list'\nhow can i get around this? Is there a different insert method i can use? do i really have to load up the dataframe with the proper column names from the table?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":440,"Q_Id":64980947,"Users Score":0,"Answer":"Maybe after importing the data into Pandas, you can rename the columns to something that is not a number, e.g. \"First\", \"Second\", etc. or [str(i) for i in range(len(source_data))]\nThis would resolve the issue of SQL being confused by the numerical labels.","Q_Score":0,"Tags":"python,mysql,pandas,dataframe,sqlalchemy","A_Id":64981061,"CreationDate":"2020-11-24T05:55:00.000","Title":"using a pandas dataframe without headers to write to mysql with to_sql","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataframe created from an excel sheet (the source).\nThe excel sheet will not have a header row.\nI have a table in mysql that is already created (the target). It will always be the exact same layout as the excel sheet.\nsource_data = pd.read_excel(full_path, sheet_name=sheet_name, skiprows=ignore_rows, header=None)\ndb_engine = [function the returns my mysql engine]\nsource_data.to_sql(name=table_name, con=db_engine, schema=schema_name, if_exists='append', index=False)\nThis fails with an error due to pandas using numbers as column names in the insert statement..\n[SQL: INSERT INTO [tablename] (0, 1) VALUES (%(0)s, %(1)s)]\nerror=(pymysql.err.OperationalError) (1054, \"Unknown column '0' in 'field list'\nhow can i get around this? Is there a different insert method i can use? do i really have to load up the dataframe with the proper column names from the table?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":440,"Q_Id":64980947,"Users Score":0,"Answer":"Found no alternatives.. went with adding the column names to the data frame during the read..\nSo first i constructed the list of column names\nsql = (\"select [column_name] from [table i get my metadata from];\")\ndb_connection = [my connection for sqlalchemy]\nresult = db_connection.execute(sql)\ncolumn_names = []\nfor column in result:\n    column_names.append(column[0])\nAnd then i use that column listing in the read command:\nsource_data = pd.read_excel(full_path, sheet_name=sheet_name, skiprows=ignore_rows,header=None, names=column_names) \nthe to_sql statement then runs without error.","Q_Score":0,"Tags":"python,mysql,pandas,dataframe,sqlalchemy","A_Id":64993227,"CreationDate":"2020-11-24T05:55:00.000","Title":"using a pandas dataframe without headers to write to mysql with to_sql","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a use case to get data from a specific site which needs to have requests via session every time. I have created the session in python and also cookies are set which contain my logged in details.\nI am currently hosting my script on a data center but the account is getting blocked. I am thinking of requesting the data via proxy but still feel that if my session is created from a different machine and proxy is used to get data via session then what are the chances that the proxy ip is going to be black-listed?\nWhat are the possible solutions here to cater this kind of problem.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":64981885,"Users Score":0,"Answer":"Scenarios in Python Requests Session differs according to different regions,\nLike in some countries some headers are not permitted in the request due to country laws.\n\nSince you are already making logged in session that means your user-agent and other headers are being set according to the response from login request.\n\nOne of the solution might be using a proxy of a country which doesnot have strict rules of data extraction from that platfrom.","Q_Score":2,"Tags":"python,session,proxy,web-crawler","A_Id":64985958,"CreationDate":"2020-11-24T07:23:00.000","Title":"python requests via session proxy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have dropbox filepicker in my project, once user select file i am receiving URL of the dropbox, now i want a content of that file using that URL in python.\nhere is the link which i received from dropbox picker : https:\/\/www.dropbox.com\/s\/ocissavtfvvdh2g\/images.png?dl=0\nI have checked this link https:\/\/sodocumentation.net\/dropbox-api\/topic\/408\/downloading-a-file, but it will ask for the path, but i don't have path of the file, i just have URL of the file","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":178,"Q_Id":64983177,"Users Score":1,"Answer":"I just have to use 1 in dl querystring.\nhttps:\/\/www.dropbox.com\/s\/ocissavtfvvdh2g\/images.png?dl=1 like this","Q_Score":1,"Tags":"python,dropbox","A_Id":65005272,"CreationDate":"2020-11-24T08:59:00.000","Title":"get dropbox file content using dropbox URL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to validate bearer tokens in an API, which are passed from a browser application. The API will validate the tokens against Keycloak by calling the ..\/userinfo endpoint and respond with the desired content if the check runs ok. Problem is that If I pass a bearer token from the browser, or any other app for that matter (e.g. postman), to the api and try to validate it - I get \"401 Token verification failed\".\nThe following works:\n\nFetch token from Keycloak through Postman by using username and password.\nFetch userinfo from Keycloak through Postman using the resulting bearer token.\n\nOR\n\nFetch token from Keycloak directly from the API by using username and password.\nFetch userinfo from Keycloak from the API using the resulting bearer token.\n\nThe following does NOT work:\n\nFetch token from Keycloak through Postman by using username and password.\nSend request to API, running in a docker container, containing the bearer token.\nAPI tries to fetch userinfo using the token = \"401 Token verification failed\"\n\nUsing same client_id and client_secret in all scenarios.\nIs this a docker networking thing? Or is some Keycloak configuration necessary in order for the API to validate token \"on behalf\" of the client? Quite new to authorization flows.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":726,"Q_Id":64988971,"Users Score":1,"Answer":"Figured it out: I was calling Keycloak at different urls, localhost:8080 from postman and host.docker.internal:8080 from the api running in Docker. Turns out you have to call Keycloak at same URL from both ends. I switched to using my machines' ip in both cases and voila!","Q_Score":3,"Tags":"python,django,docker,oauth,keycloak","A_Id":65009835,"CreationDate":"2020-11-24T14:52:00.000","Title":"Validating keycloak bearer token on behalf of client","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried downloading the 'PyPortfolioOpt' package on my MacBook Pro (iOS 11.0.1) but it always shows an error.\nI've downloaded the Xcode developer tools and already upgraded the latest pip3 setup-tools. I am using python 3.9.\nThe error:\n1 error generated.\nerror: command '\/usr\/bin\/gcc' failed with exit code 1\nERROR: Failed building wheel for cvxopt\nRunning setup.py clean for cvxopt\nFailed to build cvxopt\nInstalling collected packages: cvxopt, PyPortfolioOpt\nRunning setup.py install for cvxopt ... error\nERROR: Command errored out with exit status 1:","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":448,"Q_Id":64992838,"Users Score":0,"Answer":"For some reason, probably something to do with how new python 3.9 is and how little bug fixes have come out so far, python 3.9 didn't work for me at all. I have upgraded a few times before, but never did it result in as many bugs as when I tried installing python 3.9. I recommend firstly trying $ python3 -m pip install PyPortfolioOpt, and if that doesn't work go back to python 3.8 or 3.7, that's what I'm on now and everything works fine now for me.","Q_Score":0,"Tags":"python,python-3.x","A_Id":64995288,"CreationDate":"2020-11-24T18:40:00.000","Title":"Problem Python 3.9: trying to install package 'PyPortfolioOpt'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having trouble finding any sort of documentation or instruction for pykinect, specifically for the xbox 360 version of the kinect. how do I get skeletal data or where do I find the docs?? if I wasn't clear here please let me know!","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":138,"Q_Id":64992920,"Users Score":-1,"Answer":"To use python with the kinect 360 you need the follwing:\npython 2.7\nwindows kinect sdk 1.8\npykinect   - NOT pykinect2","Q_Score":0,"Tags":"python,kinect,pykinect","A_Id":67292038,"CreationDate":"2020-11-24T18:45:00.000","Title":"Getting skeletal data in pykinect (xbox 360 version)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to get info from API via Python, which has infinite info updating (it is live - for example live video or live monitoring). So I want to stop this GET request after interval (for example 1 second), then process these information and then repeat this cycle.\nAny ideas? (now I am using requests module, but I do not know, how to stop receiving data and then get them)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":350,"Q_Id":64993141,"Users Score":1,"Answer":"I might be off here, but if you hit an endpoint at a specific time, it should return the JSON at that particular moment. You could then store it and use it in whatever process you have created.\nIf you want to hit it again, you would just use requests to hit the endpoint.","Q_Score":1,"Tags":"python,python-3.x,get,python-requests","A_Id":64993189,"CreationDate":"2020-11-24T19:00:00.000","Title":"Python GET request from live\/infinite API endpoint","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"SO,\nI am hoping for some clarity on how the Python API works when you are not logged in. I have a Bberg Anywhere account and have some scripts I'd like to run in the morning before I start my day. Do I need to be logged in? If not, do I need to input any username\/password credentials to a Sessions object?\nLooking for any assistance on this... it would be greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":512,"Q_Id":64996052,"Users Score":2,"Answer":"BLPAPI does work for a few days after the last login to Bloomberg anywhere. This is specifically so that you can run scripts after your Terminal login expires. I think it's 3 days to cover the case of scripts running over the weekend when you leave for the week on Friday.\nLogging into Bloomberg anywhere on another PC or even enabling real time data on a mobile device will cause your scripts to stop working.","Q_Score":1,"Tags":"python,bloomberg,blpapi,pdblp","A_Id":65054043,"CreationDate":"2020-11-24T22:53:00.000","Title":"Bloomberg Anywhere + pdblp or xbbg + not logged in","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a data set that consists of two columns as coordinates. I would like to import them to python under one header list called \"coordinates\". Does anyone have any solution?. Thanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":46,"Q_Id":64997349,"Users Score":1,"Answer":"You can use: df.values.tolist().\nFirst select the columns from the name of your dataframe:\ndf = pd.DataFrame(name_of_dataframe, columns= ['col1', 'col2'])\nNext change it to a list: list = df.values.tolist().\nThen flatten the list with a loop appending each smaller list into one bigger list.","Q_Score":0,"Tags":"python,numpy","A_Id":64997439,"CreationDate":"2020-11-25T01:36:00.000","Title":"Import two columns from csv into python under one header numpy list","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with a MaxOS High Sierra and have python 3.7 I'm running it on my console but it bounces back with an error message reading\nERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '\/Library\/Python\/2.7\/site-packages\/idna'\nConsider using the --user option or check the permissions.\nI do not know what it means by this and gave permissions to that folder and made it available to everyone.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":329,"Q_Id":64998492,"Users Score":0,"Answer":"Based on the command output, I would try running pip3 instead of pip since it appears there are multiple versions of pip\/python installed in the environment. This would theoretically cause pip to reference python 3.7 for the installation instead of python 2.7 which is indicated by the output of the error message.","Q_Score":0,"Tags":"python,google-sheets,pip,python-3.7,gspread","A_Id":64998546,"CreationDate":"2020-11-25T04:21:00.000","Title":"How to install gspread with pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Looking to create a GUI based 25-key keyboard using PYQT5, which can support MIDI controller keyboards. However, I don\u2019t know where to start (What libraries should I use and how do I go about finding a universal method to supporting all MIDI controller keyboards). I plan to potentially use the Mido Library, or PyUSB but I am still confused as to how to make this all function. Any starting guides would be much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":319,"Q_Id":65002198,"Users Score":2,"Answer":"MIDI is a universal standard shared by all manufacturers, so you don't have to worry about \"supporting all MIDI controller keyboards\", you just have to worry about supporting the MIDI studio of your system.\nYou'll have to scan your environment to get the existing MIDI ports. With the list of existing ports you can let the user choose to which port he wants to send the events generated by your keyboard and\/or from which port he wants to receive events that will animate the keyboard (for instance from a physical MIDI keyboard connected to your computer), possibly all available input ports.\nTo support input events, you'll need a kind of callback prepared to receive the incoming notes on and off (which are the main relevant messages for a keyboard) at any time. That also means that you have to filter the received events that are not of those types because, in MIDI, a stream of events is subject to contain many kinds of other events mixed with the notes (pitch bend, controllers, program change, and so on).\nFinally notice that MIDI doesn't produce any sound by itself. So if you plane to hear something when you play on your keyboard, the produced MIDI events should be send to a device subject to produce the sound (for instance a synthesizer or virtual instrument) via a port that this device receives.\nFor the library, Mido seems to be a pretty good choice : it has all the features needed for such a project.","Q_Score":0,"Tags":"python,pyqt5,midi,libusb,piano","A_Id":65004991,"CreationDate":"2020-11-25T09:51:00.000","Title":"How to implement a MIDI keyboard into python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a very basic Web Application (built using flask and flask_restful) with unrelated views split into different blueprints.\nDifferent blueprints deal with a different instance of a class.\nNow I want to design a page with status(properties and value) of all the classes these blueprints are dealing with. The page is a kind of a control panel of sorts.\nFor this I want to call all the status routes (defined by me) in different blueprints from a single route(status page route) in a different blueprint. I have been searching for a while on how to make internal calls in Flask \/ Flask_restful, but haven't found anything specifically for this. So....\n\nI would love to find out how to make these internal calls.\nAlso, is there any problem or convention against making internal calls.\nI also thought of making use of the requests calls using Requests module, but that feels more like a hack. Is this the only option I got??? If yes, is there a way I dont have to hard code the url in them like using something close to url_for() in flask??\n\nThanks..  :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":108,"Q_Id":65004040,"Users Score":0,"Answer":"I would love to find out how to make these internal calls.\n\n\nAns: use url_for() or Requests module, as u do for any other post or get method.\n\n\nAlso, is there any problem or convention against making internal calls ?\n\n\nAns: I didn't find any even after intensive searching.\n\n\nI also thought of making use of the requests calls using Requests module, but that feels more like a hack. Is this the only option I\ngot??? If yes, is there a way I don't have to hard code the url in\nthem like using something close to url_for() in flask??\n\n\nAns: If you don't wanna use Requests module, url_for() is the simplest and cleanest option there is. Hard coded path is the only option.","Q_Score":0,"Tags":"python,flask,flask-restful","A_Id":68876749,"CreationDate":"2020-11-25T11:44:00.000","Title":"flask \/ flask_restful : calling routes in one blueprint from another route in a different blueprint","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Please, may anyone have solved this problem.\nI have two classes in my masks but do not work.\nInvalidArgumentError: labels out of bound\nCondition x < y did not hold.\nFirst 3 elements of x:\n[0 0 0]\nFirst 1 elements of y:\n[2]","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":65008064,"Users Score":0,"Answer":"Thank you,\nI solved it by\ny_true = y_true\/255","Q_Score":0,"Tags":"python,tensorflow","A_Id":65058659,"CreationDate":"2020-11-25T15:46:00.000","Title":"Testing the model tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using pyinstaller v4.0 to create a --onefile for execution on Win 7 and Win 10 machines. Win 7 machines can be either 32 or 64 bit. The ONLY version of python installed on the machine I'm using to build the .exe (run pyinstaller on) is Python v3.7.9 32 bit.\nTo create the .exe I'm simply using:\npyinstaller --onefile scriptname.py\nI copy the resulting .exe from the pyinstaller dist folder to both Win 7 and Win 10 machines and, in most cases, it runs just fine; but on 3 separate machines when I try to run the .exe it throws this error:\n\"Error loading Python DLL 'C:\\Users\\username\\AppData\\Local\\Temp_MEI3dddd\\python37.dll'.\nLoadLibrary: The specified module could not be found.\"\nNote that 'dddd' referenced above can be differing 4 digits on different machines.\nI have confirmed that the directory from the path, \"_MEI3dddd\", DOES get unpacked to the Temp directory, I've even been able to open the the \"_MEI3dddd\" directory long enough to see that python37.dll is in there.\nI have confirmed permissions on the folders in the path are correct to allow the executing user full access.\nCan anyone suggest what I am missing?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":510,"Q_Id":65010527,"Users Score":0,"Answer":"I found my fix. To resolve the issue, I spun up a VM with a Win 7 SP1 32 bit OS, installed Python 3.7.9 32 bit and pyinstaller.\nFrom there it was just a matter of building the --onefile on that VM and copying the resulting .exe from the pyinstaller dist folder to the other target machines.","Q_Score":0,"Tags":"python-3.x,pyinstaller","A_Id":65043441,"CreationDate":"2020-11-25T18:15:00.000","Title":"Pyinstaller .exe unpacks to ...\\local\\Temp but then cannot find python37.dll","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Every time I do a: python manage.py runserver\nAnd I load the site, python gets data and puts this in my database.\nEven when I already filled some info in the database. Enough to get a view of what I am working on.\nNow it is not loading the information I want and instead putting in new information to add to the database so it can work with some data.\nWhat is the reason my data in the database is not being processed?\nAnd how do I stop new data being loaded into the database.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":65011273,"Users Score":0,"Answer":"May be it is happening due to migration file first sometimes when you migrate models into database query language with same number\npython manage.py makemigrations 0001\nThis \"0001\" has to be changed everytime\nTo solve your problem once delete the migrations file and then again migrate all models and then try\nTell if this work","Q_Score":0,"Tags":"python,django,django-templates,django-settings","A_Id":65015259,"CreationDate":"2020-11-25T19:10:00.000","Title":"When doing runserver, keep getting new data loaded in my database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"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":"The csv created using dataframe.to_csv() contains 1.6135E+14 instead of 161349731180627. In the dataframe, it was confirmed that 161349731180627 is displayed correctly. How do I get 161349734480627 in csv properly? (in python)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":65015632,"Users Score":0,"Answer":"While using df.to_csv(), add the argument float_format='{:f}'.format","Q_Score":0,"Tags":"python,pandas,dataframe,csv,export-to-csv","A_Id":65015661,"CreationDate":"2020-11-26T03:15:00.000","Title":"How to make csv appear as numbers instead of E(python)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"Specific Questions:\n\nWhat is the best design pattern or strategy for this particular problem?\nHow can I prevent potential cascading effects & re-writing the code?\n\nDetails:\nI am developing a program in which I have three data sources (A, B, C).\nIn order to grab data from B, I need information from A.\nIn order to pull data from C, I need information from B.\nCurrent Approach:\nDescription:\nI used four classes. A mediator class that handles the passing of data from A, B, & C. Then, a separate class for A, B, & C that handles extracting, formatting, sub-setting, etc.\nProcess Flow:\n\nInside the mediator class I instantiate classes A, B, & C.\nI run a function inside the mediator class called create_A_files().\nThe data from A that B needs is then passed as an argument to B's create_B_files(A_necessary_data) function.\nFinally, the same is done from B to C through a create_C_files(B_necessary_data) function.\n\nProblems with Current Approach:\nI am fighting cascading effects. Any changes I make in A propagate and cause errors & bugs in B & C.\nTherefore, I have to go back and rewrite B & C to accommodate the changes from A.\nThank you in advance for your help!\nNarnia649","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":116,"Q_Id":65017249,"Users Score":0,"Answer":"First of all, make sure your 3 parts are well isolated and covered by tests. Having a good test suite is the best tool you can use to prevent issues when updating the code.\nThen, think about this: each piece is actually independent:\n\nA is producing some output but doesn't really care where it goes.\nB is manipulating some data but doesn't really care where it comes from.\nC is the same as B\n\nnow, I can't really say how to do this in python, but in .NET I would start by identifying the right interface for all the parts and then build an orchestrator that would take care of the global workflow.\nAnd of course tons of tests :)","Q_Score":0,"Tags":"python,oop,design-patterns,mediator","A_Id":65031155,"CreationDate":"2020-11-26T06:48:00.000","Title":"What design pattern should I use to combine three data sources that communicate in a chain?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There are four such view :\nPasswordResetView sends the mail # - PasswordResetDoneView shows a success message for the above # - PasswordResetConfirmView checks the link the user clicked and # prompts for a new password # - PasswordResetCompleteView shows a success message for the above. I want to use placeholders for them but there doesn't seem to be an option. Overwriting the class seems kinda overkill.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":65018325,"Users Score":0,"Answer":"You can us Javascript to handle that in your front end.\nOR\nYou can call the get_form method and manipulate the password input.\nLIKE:\nform.fields['email'].widget.attrs['placeholder']=\"New placeholder\"","Q_Score":0,"Tags":"python,django,django-views","A_Id":65020604,"CreationDate":"2020-11-26T08:20:00.000","Title":"How do I use placeholders with Class-based password reset views?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've developed some python standalone apps that now I want to integrate into a web environment in order to make them more user friendly for my workmates, whom aren't used to CLI and the command shell. I've thought in remaking those apps as Django apps, using the Django REST framework, but I'm not sure if that way is the theoretically correct given the REST API meaning. For giving some examples, one of my apps takes some geometries from a geopackage, which is a kind of compact format for transferring geospatial information that could acts as a database for itself, and does some QA processes in order to ensure the geometries and data quality. Another of my apps takes some more geometries from the same geopackage and converts them into shapefiles or CAD files.\nIn brief, my question is that it is theoretically correct to remake those apps as Django apps, using the Django REST framework, or maybe exists another options or framework that are more suitable to what I want to approach.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":65022798,"Users Score":1,"Answer":"From my personal experience, Django is everything you need and more. Best part of Django I feel is the db access. Its flawless when it comes to accessing database in Django. So you have nothing to worry about Django.\nAnother option is Flask. Flask is very simple and handy. Flask is more like a module rather than framework. You can make it in few lines of code. But simplicity comes with some down sides. The database access have no structure of its own.\nBottom line is that pick Django if you need to access database with complex queries. Without the requirement for a database, i would go for Flask.","Q_Score":0,"Tags":"python,django,api,rest,geopackage","A_Id":65023067,"CreationDate":"2020-11-26T13:14:00.000","Title":"Best theorically way to integrate some standalone apps into a web environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I find many examples of passing a list of images, and returning a stitched image, but not much information about how these images have beeen stitched together.\nIn a project, we have a camera fixed still, pointing down, and coveyers pass underneath. The program detects objects and start recording images. However some objects do not enter completely in the image, so we need to capture multiple images and stich then together, but we need to know the position of the stitched image because there are other sensors synchronized with the captured image, and we need to also synchronize their readings within the stitched image (i.e. we know where the reading is within each single capture, but not if captures are stitched together).\nIn short, given a list of images, how can we find the coordinates of each images relative to each other?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":201,"Q_Id":65023161,"Users Score":0,"Answer":"Basically while stiching correspondence between two (or more) images are setup. This is done with some constant key points. After finding those key points the images are warped or transformed & put together, i.e. stitched.\nNow those key points could be set\/ noted as per a global coordinate system (containing all images). Then one can get the position after stitching too.","Q_Score":0,"Tags":"python,opencv","A_Id":65025179,"CreationDate":"2020-11-26T13:38:00.000","Title":"How to find the stitch (seam) position between two images with OpenCV?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to logout from all devices where I have logged in as admin in Django admin panel?\nThe site has already been deployed to heroku server","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":65026129,"Users Score":0,"Answer":"There is no such option, one idea is to delete that user and recreate super user.\nChange superuser password.","Q_Score":1,"Tags":"python,django,admin","A_Id":65027274,"CreationDate":"2020-11-26T16:43:00.000","Title":"Django admin panel logout functionality","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"First, I want to explain my task. I have a dataset of 300k documents with an average of 560 words (no stop word removal yet) 75% in German, 15% in English and the rest in different languages. The goal is to recommend similar documents based on an existing one. At the beginning I want to focus on the German and English documents. \u00a0\nTo achieve this goal I looked into several methods on feature extraction for document similarity, especially the word embedding methods have impressed me because they are context aware in contrast to simple TF-IDF feature extraction and the calculation of cosine similarity.\u00a0\nI'm overwhelmed by the amount of methods I could use and I haven't found a proper evaluation of those methods yet. I know for sure that the size of my documents are too big for BERT, but there is FastText, Sent2Vec, Doc2Vec and the Universal Sentence Encoder from Google. My favorite method based on my research is Doc2Vec even though there aren't any or old pre-trained models which means I have to do the training on my own.\nNow that you know my task and goal, I have the following questions:\n\nWhich method should I use for feature extraction based on the rough overview of my data?\nMy dataset is too small to train Doc2Vec on it. Do I achieve good results if I train the model on English \/ German Wikipedia?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":241,"Q_Id":65027694,"Users Score":1,"Answer":"You really have to try the different methods on your data, with your specific user tasks, with your time\/resources budget to know which makes sense.\nYou 225K German documents and 45k English documents are each plausibly large enough to use Doc2Vec - as they match or exceed some published results. So you wouldn't necessarily need to add training on something else (like Wikipedia) instead, and whether adding that to your data would help or hurt is another thing you'd need to determine experimentally.\n(There might be special challenges in German given compound words using common-enough roots but being individually rare, I'm not sure. FastText-based approaches that use word-fragments might be helpful, but I don't know a Doc2Vec-like algorithm that necessarily uses that same char-ngrams trick. The closest that might be possible is to use Facebook FastText's supervised mode, with a rich set of meaningful known-labels to bootstrap better text vectors - but that's highly speculative and that mode isn't supported in Gensim.)","Q_Score":0,"Tags":"python,gensim,word-embedding,doc2vec,fasttext","A_Id":65028926,"CreationDate":"2020-11-26T18:45:00.000","Title":"Which document embedding model for document similarity","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dataset with non-ordinal categorical features. What is the best way to transform them (encoding + scaling) before training the machine learning model (Linear SVC)?\nThings I tried:\n\nLabel Encoding - This works. But scaling doesn't make sense as different categories in a feature don't have any specific order.\n\nOne-Hot encoding - There are thousand's of unique categories in a features, which is making the ML model complex by creating thousands of columns.\n\nCount encoding - My train-test split didn't have all unique categories of a feature in the training set, which introduces NaN's in test set when I count-encode those features.\n\n\nAppreciate your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":65028379,"Users Score":0,"Answer":"To tackle your problem of having some unique values in the test set that are not in the training set, you can try to do the following :\n\nMerge the training dataset using df = train.append(test)\nApply the encodings that you have used earlier\nSplit the datasets back into train and test using :\n\n\ntrain = df.head(len(train))\n\ntest = df.tail(len(test))\n\n\nBased on my experience I can say that LabelEncoding and OneHotEncoding are some of the best techniques to encode non-ordinal features.\nHope this was helpful :)","Q_Score":0,"Tags":"python,encoding,scikit-learn","A_Id":65028768,"CreationDate":"2020-11-26T19:45:00.000","Title":"Dataset features Encoding and Scaling","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've installed most popular Python extensions in vscode. So I can do shift+enter to execute some selected code into a python terminal.\nThis uses \/usr\/bin\/python3 as default. I would like to use IPython3 instead. However, I don't find such settings in settings.json.\nHow can I configure the default Python terminal in vscode?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":595,"Q_Id":65028853,"Users Score":-1,"Answer":"Open a file with the suffix .ipynb and vs code will do the rest","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":65028894,"CreationDate":"2020-11-26T20:29:00.000","Title":"Set IPython terminal as default in vscode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I import an Excel file with pandas and when I try to convert all columns to float64 for further manipulation. I have several columns that have a type like:\n0\ncolumn_name_1 float64\ncolumn_name_1 float64\ndtype: object\nand it is unable to do any calculations. May I ask how I could change this column type to float64?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":65031692,"Users Score":0,"Answer":"I just solved it yesterday and it is because I have two same columns in the Data frame and it causes that when I try to access pd['something'] it automatically combine two columns together and then it becomes an object instead of float64","Q_Score":1,"Tags":"python,excel,pandas","A_Id":65046305,"CreationDate":"2020-11-27T03:21:00.000","Title":"Unable to change data types of certain columns read from xslx and by Pandas","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a tensor with shape [1, 2, 96, 96] and would like two tensors with the shape [1, 1, 96, 96], is there a quick way of doing this? Thanks in advance","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":914,"Q_Id":65033693,"Users Score":1,"Answer":"a, b = tensor.split(1, dim=1) should do the job. By specifying 1 you specify how many elements should be in each split e.g. [1,2,3,4,5,6].split(2) -> [1,2] [3,4] [5,6]. Then dim just specifies which dimension to split over which in your case would be one.\nEDIT:\nif you wanted to cut it in half more generally use tensor.split(n) where n is half the size of the tensor. So in your specific case if you had shape [1,10,96,96] you would use tensor.split(5,dim=1)","Q_Score":1,"Tags":"python,pytorch","A_Id":65052602,"CreationDate":"2020-11-27T07:49:00.000","Title":"How to \"cut\" a tensor into half in Pytorch?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to install\n(env_py) PS D:\\github\\env_py\\Scripts> pip install pySFML\nAfter that I have:\nERROR: Could not find a version that satisfies the requirement pySFML (from versions: none)\nERROR: No matching distribution found for pySFML\nI am using python 3.9 and 3.7  on windows\nAnd there is the same problem\nTHANKS!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":662,"Q_Id":65035874,"Users Score":0,"Answer":"Another way, on linux\nsudo aptitude install python3-sfml\nIt is work\nI can\nimport sfml\nbut on windows I still can not install","Q_Score":0,"Tags":"python","A_Id":65036766,"CreationDate":"2020-11-27T10:36:00.000","Title":"problem with install pySFML pip install pySFML windows python 3.9, 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm just wondering if there is a way to put a python Tkinter canvas onto a web page with HTML. It's OK if there isn't. If there is not, is there a way to run python code from IDLE with HTML?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":261,"Q_Id":65042076,"Users Score":0,"Answer":"Essentially 'no'.  Tkinter is Python's interface to the tcl\/tk GUI framework.  The 'tkinter canvas' is actually the tk Canvas.  A web page could only have a tk Canvas if the browser were somehow running tcl\/tk.\nAs for running Python code in a browser, there are some browser add-ins that will allow that.  I do not know how good they are not.  You should search the web for 'run python in browser' or add a separate question here.  It is irrelevant how you edit the python code, whether with IDLE or another editor.","Q_Score":0,"Tags":"python,html,tkinter-canvas","A_Id":65050433,"CreationDate":"2020-11-27T18:18:00.000","Title":"Is there a way to embed a tkinter canvas into an HTML web page?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python-selenium-bot that takes a screenshot of an image and saves it in an assets folder which my frontend flutter-app then accesses.\nHowever I think there is a better way to do this. Is it possible to not save the picture on the disk but rather in a variable or something like that so that I can send it via my rest api. This would be a lot cleaner and not so error prone.\nIs there any way to save a svg without taking a screenshot of it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":65043258,"Users Score":0,"Answer":"Update:\nMy solution now is calling driver.get_screenshot_as_bas64 this allows me to save the screenshot as base64 in a variable and then pass that through my API. My Frontend can then decoded that screenshot again.","Q_Score":1,"Tags":"python,api,selenium,flutter,web-scraping","A_Id":65050437,"CreationDate":"2020-11-27T20:01:00.000","Title":"How to save an svg-element using selenium not locally?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using Win32com.client to read email content from Outlook, but one of the emails contains a table. When I read the table using msg.body() The table is stored in a string format and does not look like a table. The whole email body is stored like a string including the table. Is there a way that I can recognize this table while parsing through the email body using Win32com and what good way can be used to read this table and store it in a variable to look like an actual table.\nNote: I am using python to do so\nThank you in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":232,"Q_Id":65044608,"Users Score":0,"Answer":"Read the HTMLBody property instead and parse out the <table> elements.","Q_Score":0,"Tags":"python,outlook,win32com","A_Id":65044723,"CreationDate":"2020-11-27T22:42:00.000","Title":"How to copy a table from an outlook email and store it in a variable","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm noticing that I have now installed Python 3.9 (it happened in the last 2 weeks, though I'm not exactly sure how) and now I can't run packages like Jupyter or Flask, which I used to be able to. I still have Python 3.7 installed as well. When I try to run them I get:\n-bash: \/usr\/local\/bin\/jupyter: \/usr\/local\/opt\/python\/bin\/python3.7: bad interpreter: No such file or directory\nI also tried reinstalling it but I still get the same error as above. Anybody know what's going on here?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1747,"Q_Id":65045434,"Users Score":0,"Answer":"I would honestly suggest you to use a virtual environment and install packages in there. Please stop installing packages in your system's python.\nMy recommendation would be using a package manager like miniconda, but you can simply use virtualenv and pip install your packages in there.","Q_Score":0,"Tags":"python,jupyter-notebook,jupyter,python-3.9","A_Id":65045888,"CreationDate":"2020-11-28T00:55:00.000","Title":"Newly installed Python 3.9 can't find Jupyter notebook or other modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I have 10 company names.\nHow to find their \"nearly-exact\" linkedin url?\nex.\nA company is named \"ABC Corp\", its' linkedin url might be \"https:\/\/www.linkedin.com\/company\/abc-corp\"\nbut it's not accurate.\nThere's a way to improve the precision by use google to search linkedin+company name to find the result, but the error rate is still high.\nis there any better solution?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":557,"Q_Id":65045681,"Users Score":0,"Answer":"The link you'd fetch would be https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=COMPANY_NAME_HERE which searches for the company name.\nThen, you can use beautiful soup to scrape the first result which is usually the company you are looking for","Q_Score":0,"Tags":"javascript,python,google-api,linkedin,linkedin-api","A_Id":65045706,"CreationDate":"2020-11-28T01:50:00.000","Title":"Use company name to find exact linkedin url","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We given a network with K vertexes and give a and b. capacity of all edges is infinite. for a flow from a to b, the edge that pass max flow through it, called bottleneck edge and capacity of transferred flow through that edge is called bottleneck of flow. an integer M is given. we want transfer flow with size M with lowest bottleneck from a to b. how many times we should used ford-Fulkerson to calculate this flow?\nO(1) runs is the answer, but how?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":202,"Q_Id":65046000,"Users Score":0,"Answer":"Say you assign each edge a capacity 1, run FF a single time, and get the resulting graph. Moreover, let the max flow be M'. Intuitively, we find that the min cut is $M'$, meaning that there are M' edge-disjoint paths from a to b in this case. This tells us how to get to a solution of \u2308 M \/ M' \u2309, by scaling the flows appropriately. For example, suppose that $M=5$, and when setting the capacities to 1, we get $M' = 2$. Then we know that the min-cut is 2. If we increase the capacity to 5 \/ 2 = 2.5, then we would get exactly the flow of 5 to begin with. Since this is a non-integer, we would increase the capacity of some edges (forming a path from a to b) to 3, and some to 2.\nYou cannot get anything lower than what was just found. If you could get something lower, say M'' < \u2308 M \/ M' \u2309, then if you would set the capacity of all edges to M'', the flow would not change. By the max-flow \/ min-cut theorem, this means that there is a min-cut of M \/ M'' > M' edges. This contradicts the min cut being only M'.","Q_Score":1,"Tags":"python,algorithm,data-structures,graph,shortest-path","A_Id":65048187,"CreationDate":"2020-11-28T03:02:00.000","Title":"how many times we should used ford-Fulkerson?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a game and there is this part of the code I don't understand.tk.wm_attributes(\"-topmost\", 1)\nWhat does the number after \"-topmost\" mean? I changed the number to 0 and 255, yet there is no difference. Why is that?\n\nI also checked the tkinter documentation and I can't find the function.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":789,"Q_Id":65046290,"Users Score":0,"Answer":"Yeah, the function's quite well hidden and (I think) only works on Python.\ntk.wm_attributes() sets settings for tkinter to use for drawing the app. -topmost is an option to make the window always be on top of all the other windows, and zero is considered false while all other numbers are true.\nSo in other words, tk.wm_attributes('-topmost', 1) means \"Yes, do draw the window on top of all the others.\"","Q_Score":1,"Tags":"python,tkinter","A_Id":65046389,"CreationDate":"2020-11-28T04:01:00.000","Title":"What does the one in 'tk.wm_attributes(\"-topmost\", 1) mean?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a game and there is this part of the code I don't understand.tk.wm_attributes(\"-topmost\", 1)\nWhat does the number after \"-topmost\" mean? I changed the number to 0 and 255, yet there is no difference. Why is that?\n\nI also checked the tkinter documentation and I can't find the function.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":789,"Q_Id":65046290,"Users Score":0,"Answer":"The topmost attribute requires a value that can be converted to True or False in the tcl language. 1 or any other number greater than zero evaluates to True. 0 will evaluate to False.\nSo, tk.wm_attributes(\"-topmost\", 1) sets the topmost option on, and a value of 0 turns it off.","Q_Score":1,"Tags":"python,tkinter","A_Id":65046594,"CreationDate":"2020-11-28T04:01:00.000","Title":"What does the one in 'tk.wm_attributes(\"-topmost\", 1) mean?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to deploy a webpage to github pages where the index.html file is not in the root directory, but in the templates folder. As a result, I keep getting a 404 error page whenever I try to access the url. how can I upload a webpage where the html file is not in the root of the project?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":257,"Q_Id":65046654,"Users Score":1,"Answer":"GitHub Pages is a fairly limited hosting service, although nice for what it does. Is there a particular reason why you can't simply move index.html to the root directory? I know these things can be a pain, but I believe the parser that GHP uses is pretty strict about this.","Q_Score":2,"Tags":"python,flask,github,github-pages","A_Id":65046739,"CreationDate":"2020-11-28T05:18:00.000","Title":"deploying webpage to github where html file is in templates folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What I mean is that I have a py file which I have converted to an exe file. So I wanted to know in case I decide to update the py file then how do I make it if I have sent it to someone the same changes occur in his file as well whether the exe or py file.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":606,"Q_Id":65047333,"Users Score":0,"Answer":"Put your version of the program on a file share, or make it otherwise available in the internet and build in an update check in the program. So that it checks the URL for a new version everytime it is started.\nI guess this is the most common way to do something like that.","Q_Score":3,"Tags":"python,tkinter,server,pyinstaller,pygame-surface","A_Id":65048905,"CreationDate":"2020-11-28T07:18:00.000","Title":"How to update an py made exe file from my pc to people I have sent it to?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"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":"I want to slowly draw a circle in pygame so the act of drawing is actually visible to the naked eye. I got a function on stackoverflow to draw a straight line by incrementing the end point and keeping the starting point same but couldn't figure out how to slowly draw a circle in the pygame screen.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":371,"Q_Id":65049152,"Users Score":0,"Answer":"I recommend using the turtle library because it contains a circle function. For example circle(40) would draw a circle with a radius of 40 units. When you run the program the circle will be drawn in front of you","Q_Score":3,"Tags":"python,pygame,geometry","A_Id":65049240,"CreationDate":"2020-11-28T11:38:00.000","Title":"How to slowly draw a circle in Pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to pass a matrix as initial condition for scipy.integrate.solve_ivp.\nWith odeInt this was possible by flattening the matrix as:\nResult = odeint(myfunction, myMatrix.ravel(),myTimeVector )\nInside the function myFunction, the matrix is reshaped into a 3x3 matrix for some calculations.\nIf I try to use solve_ivp(myfunction, myTimeVector,myMatrix.ravel() ), I get the following error:\nValueError: cannot reshape array of size 1 into shape (3,3)\nbecause it only passes the first element of the array, instead of the whole array. Is it possible pass the matrix as initial condition as was withodeint?\nBest Regards","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":249,"Q_Id":65049163,"Users Score":1,"Answer":"Well... Solved it in the following manner:\nChanged the entries in myFunction(y,t) to  myFunction(t,y)\nResult=solve_ivp(myfunction, (myTimeVector[0], myTimeVector[-1]), myMatrix.ravel(), t_eval=myTimeVector)","Q_Score":0,"Tags":"python,scipy,ode","A_Id":65049793,"CreationDate":"2020-11-28T11:39:00.000","Title":"Using a matrix as initial condition in scipy.integrate.solve_ivp","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get get the  time delta i minutes from two different time values.\ntime1 = 2020-11-28T10:31:12Z\ntime2 = 2020-11-28T09:10:23.203+0000\nThen i will make i condition: if time difference is bigger then x minutes, run code...\nAnyone have a solution for that.\nI have tried using datetime.datetime.strptime() but cant get them on same format.\nThanks","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":65049694,"Users Score":0,"Answer":"DARRYL, JOHNNY and MARCIN, thanks for your solutions, problem solved!!\nAndy","Q_Score":0,"Tags":"python,time","A_Id":65061452,"CreationDate":"2020-11-28T12:43:00.000","Title":"Python comparing to different time values to get time delta in minutes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"working on pyCharm, I'm activating a virtual environment using git bash, but when I want to select that specific interpreter for my python file. I can't find it in the list or may find it but still invalid.\nI'm sure the venv is activated and I don't want to use the base interpreter\n\nwhat is the approach? starting a virtual environment using pycharm?.. or hardcoded? in my case using git bash\nedit: I've added the interpreter into my interpreter's list somehow and installed some libraries- when I try to import then I get an error stating that the module isn't found","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":65051385,"Users Score":0,"Answer":"Check the bottom right corner. There you can find the options for interpreter setting. In setting by \"show all\" interpreters would show you all the list.\nThere you can also find the git tracker.\nIn general, if you can not find something, Right top corner you can see the search icon where you can search what you are looking and you will be directed there.","Q_Score":0,"Tags":"python,bash,pycharm","A_Id":65051501,"CreationDate":"2020-11-28T15:43:00.000","Title":"activating virtual environment using cmd but can't find the interpreter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a .exe file containing a skeletonization funtion.\nWhat i have to do is running the command and giving the inputs (the input image + some parameters) and getting the skeleton like this :\n\nsystem Skel_current.exe input-image 'outputimage.png' 'param1' 'param2'\n\nThe problem is that my jupyter notebook can't point the .exe file. After several trials, I get a first solution by installing wine and I was able to execute the command in the script Shell. But could'nt execute it in the jupyter notebook. When running this command in the jupyter notebook:\n\nwine Skel_current.exe class1 'image.png' '4.00000' '0.01000'\n\nI got this error :\n\n=002b:fixme:msvcrt:type_info_name_internal_method type_info_node parameter ignored\nwine: Unhandled page fault on read access to 0000000000000000 at address 00000001400293D3 (thread 002b), starting debugger...\n002d:fixme:dbghelp:elf_search_auxv can't find symbol in module\n...002d:fixme:dbghelp:interpret_function_table_entry PUSH_MACHFRAME 6","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":65051528,"Users Score":0,"Answer":"I found the correct command finally !!\n\nsubprocess.run([\"wine\",\"Skel_current.exe\", 'image.png','skel.png' ,'param1' ,'param2'])","Q_Score":0,"Tags":"python,linux,windows","A_Id":65052658,"CreationDate":"2020-11-28T15:55:00.000","Title":"How to run .exe file (created in Windows) in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there any difference between using pip install in CMD, using it in the Pycharm project terminal or installing packages through the interpreter settings of the Pycharm interface?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":65053951,"Users Score":0,"Answer":"No, there is no difference, as long as your IDE is using the same installation. If that is the case, choose the option, that is the easiest for you.","Q_Score":0,"Tags":"python,pip,pycharm","A_Id":65054105,"CreationDate":"2020-11-28T20:04:00.000","Title":"Is there any difference between using pip in CMD, Pycharm project terminal or installing packages through Pycharm interface?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any difference between using pip install in CMD, using it in the Pycharm project terminal or installing packages through the interpreter settings of the Pycharm interface?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":65053951,"Users Score":0,"Answer":"As long as you're using the same environment \/ interpreter there should be no difference","Q_Score":0,"Tags":"python,pip,pycharm","A_Id":65054106,"CreationDate":"2020-11-28T20:04:00.000","Title":"Is there any difference between using pip in CMD, Pycharm project terminal or installing packages through Pycharm interface?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any difference between using pip install in CMD, using it in the Pycharm project terminal or installing packages through the interpreter settings of the Pycharm interface?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":65053951,"Users Score":0,"Answer":"There should be no difference assuming that you're talking about PyCharm using pip underneath, which it does by default.  The other big thing is to make sure that you're working on the same Python installation in each case.  You could certainly have things set up such that, by default, these different options are each addressing a different installation of Python if you have multiple versions of Python installed.","Q_Score":0,"Tags":"python,pip,pycharm","A_Id":65054074,"CreationDate":"2020-11-28T20:04:00.000","Title":"Is there any difference between using pip in CMD, Pycharm project terminal or installing packages through Pycharm interface?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that python is interpreter language and that it means it converts script to machine code when you run it, but can someone clarify to me why can't it be pre converted to machine code (compiled).\nI'm asking this because I have been making these simple programs with GUI using tkinter and I am using pyInstaller to create executable file. The problem is that sometimes I get this simple program (only a few lines of code) as big as 10s of MBs.\nAs I understand, PyInstaller packs all libraries and interpreter with script in exe which results in these sizes, but is there a way I can get this to somewhat rational size? Because I know same programs made in C++ much smaller (less than MB).\nI don't know any of C or C++ so that isn't an option as I don't have time to learn it. Size really isn't that big to be much of a problem, but still, it's nice to have smaller file.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":218,"Q_Id":65055823,"Users Score":0,"Answer":"Check if the virtual environment that you are using does not have site-packages that you don't need. Usually it's these packages that are large. Create a new venv and only install the libraries you need and try.","Q_Score":2,"Tags":"python,compilation,size","A_Id":65055895,"CreationDate":"2020-11-29T00:29:00.000","Title":"Compiling python to a small exe file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a matching game where there are several cards faced upside down and the user has to match the right pairs. The cards faced upside down are all turtle objects.\nFor eg. if there are 8 faced down cards, there are 8 turtle objects.\nI'm having some trouble figuring out how to select the cards since I don't know which turtle is associated with the particular card selected by the user. I do have a nested list containing all turtles and those with similar images are grouped together. Is there any way to return the turtle object selected by the user?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":259,"Q_Id":65057381,"Users Score":0,"Answer":"If i got your question, one way to do so is that you should provide some id attribute to each turtle which will identify it. Then you can check easily which turtle was selected by the user.","Q_Score":1,"Tags":"python,python-3.x,return,turtle-graphics,python-turtle","A_Id":65057437,"CreationDate":"2020-11-29T05:47:00.000","Title":"Is there any way to return the turtle object that is clicked?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed Nativescript successfully and it works when running ns run android.\nHowever, when I try to use ns run ios I get the ominous WARNING: The Python 'six' package not found.-error\nSame happens, when I try to use ns doctor.\nI tried EVERYTHING that I found on the web. Setting PATH, PYTHONPATH, re-install python, six and everything - nothing helped.\nRe-install of six tells me Requirement already satisfied.\nAny ideas how to make this work???\nI'm on MacOS Catalina.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":326,"Q_Id":65058990,"Users Score":0,"Answer":"It seems I have a total mess with paths and python installations on my Mac.\nI found like 6 different pip-paths and like 4 different python paths.\nSince I have no idea which ones I can delete, I tried installing six with all pip-versions I found and that helped.\nHow to clean up this mess is likely a subject for another thread :)","Q_Score":0,"Tags":"python,nativescript,six","A_Id":65064070,"CreationDate":"2020-11-29T10:11:00.000","Title":"Nativescript can't find six","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to reference the primary key in another field in a Django model?\nFor example, let's say I want to have a field looking like BUG0001 corresponding to the entry with pk=1. What is the best way to achieve this?\nI think it is best to keep the primary key as an integer as it is easier to deal with, and I guess formatting the primary key every time is not very effective.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":235,"Q_Id":65061789,"Users Score":1,"Answer":"Yes it possible and easy to do. Just do this\nFirst make primary key\nfrom django.db import models class Fruit(models.Model): name = models.CharField(max_length=100,primary_key=True)\nAnd then call it where you want as foreign key\nforeign= models.ForeignKey(Reporter, on_delete=models.CASCADE)","Q_Score":0,"Tags":"python,django","A_Id":65062026,"CreationDate":"2020-11-29T15:28:00.000","Title":"Reuse Primary Key in another Django model field","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"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 have successfully installed pyobjc-core, but when I try to install pyobjc, I get an error:\n(the first part)\nERROR: Command errored out with exit status 1:\ncommand: \/Library\/Frameworks\/Python.framework\/Versions\/3.9\/bin\/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '\"'\"'\/private\/var\/folders\/b6\/22gqf0jd6252c93x8pbxr5nw0000gn\/T\/pip-install-nnn7ftk2\/pyobjc-framework-cocoa\/setup.py'\"'\"'; file='\"'\"'\/private\/var\/folders\/b6\/22gqf0jd6252c93x8pbxr5nw0000gn\/T\/pip-install-nnn7ftk2\/pyobjc-framework-cocoa\/setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(file);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, file, '\"'\"'exec'\"'\"'))' install --record \/private\/var\/folders\/b6\/22gqf0jd6252c93x8pbxr5nw0000gn\/T\/pip-record-2nxnxwsn\/install-record.txt --single-version-externally-managed --compile --install-headers \/Library\/Frameworks\/Python.framework\/Versions\/3.9\/include\/python3.9\/pyobjc-framework-Cocoa\ncwd: \/private\/var\/folders\/b6\/22gqf0jd6252c93x8pbxr5nw0000gn\/T\/pip-install-nnn7ftk2\/pyobjc-framework-cocoa\/\n(the last part)\nERROR: Command errored out with exit status 1: \/Library\/Frameworks\/Python.framework\/Versions\/3.9\/bin\/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '\"'\"'\/private\/var\/folders\/b6\/22gqf0jd6252c93x8pbxr5nw0000gn\/T\/pip-install-nnn7ftk2\/pyobjc-framework-cocoa\/setup.py'\"'\"'; file='\"'\"'\/private\/var\/folders\/b6\/22gqf0jd6252c93x8pbxr5nw0000gn\/T\/pip-install-nnn7ftk2\/pyobjc-framework-cocoa\/setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(file);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, file, '\"'\"'exec'\"'\"'))' install --record \/private\/var\/folders\/b6\/22gqf0jd6252c93x8pbxr5nw0000gn\/T\/pip-record-2nxnxwsn\/install-record.txt --single-version-externally-managed --compile --install-headers \/Library\/Frameworks\/Python.framework\/Versions\/3.9\/include\/python3.9\/pyobjc-framework-Cocoa Check the logs for full command output.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":273,"Q_Id":65064442,"Users Score":1,"Answer":"Try to use different Python version, right now not all libraries have wheels for 3.9 .","Q_Score":0,"Tags":"python,pip,pyobjc","A_Id":65064611,"CreationDate":"2020-11-29T19:48:00.000","Title":"I get an error when I install pyobjc on my mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working with several ongoing datasets of assets with one or more user applied tag(s) (str) which need to be mapped to one catalog-class (str), each, before importing into a database. Naively I call this 'mapping'.\nLookup Table? Mapping?\nThe term 'lookup table' has offered more accurate search results, if not a solution. Other terms like mapping, classification, matching are easily confused with other popular problems. My knowledge of LUTs extends to simple Python dictionaries and as the concept in general. Lookup table is what I've used to try to make this a more concrete programming question, but taxonomy mapping is the goal.\nIf you accept my use of the term mapping in taxonomy mapping, What idioms of mapping, or some other domain solutions can I use for:\n\nmany-to-one mapping\ndecision trees, or weights, or something else to resolve conflicts\nvalidation\/audit for mapping rules after updates\n\nI've implemented simpler mapping problems using CSV for storage and management of one-to-one relationships, and simple dict\/Pandas DataFrame idioms to get the results I need. I thought for a minute I might do a graphy-like thing, because who doesn't like graphs...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":65064860,"Users Score":0,"Answer":"I was focused on the effectiveness of my simple solution using CSV files, I didn't consider the obvious-- SQLLite with SQLAlchemy.","Q_Score":0,"Tags":"python,mapping","A_Id":65874331,"CreationDate":"2020-11-29T20:31:00.000","Title":"Many-to-One Lookup Table for taxonomy mapping","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Though I would imagine that append mode is \"smart\" enough to only insert the new bytes being appended, I want to make absolutely sure that Python doesn't handle it by re-writing the entire file along with the new bytes.\nI am attempting to keep a running backup of a program log, and it could reach several thousand records in a CSV format.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":65067610,"Users Score":2,"Answer":"Python file operations are convenience wrappers over operating system file operations. The operating system either implements this file system operations internally,  forwards them to a loadable module (plugin) or an external server (NFS,SMB).  Most of the operating systems since very 1971 are capable to perform appending data to the existing file.  At least all the ones that claim to be even remotely POSIX compliant.\nThe POSIX append mode simply opens the file for writing and moves the file pointer to the end of the file.  This means that all the write operations will just write past the end of the file.\nThere might be a few exceptions to that,  for example some routine might use low level system calls to move the file pointer backwards.  Or the underlying file system might be not POSIX compliant and use some form of object transactional storage like AWS S3.   But for any standard scenario I wouldn't worry about such cases.\nHowever since you mentioned backup as your use case you need to be extra careful.  Backups are not as easy as they seem on the surface.  Things to worry about,  various caches that might hold data in memory before if it is written to disk.  What will happen if the power goes out just right after you appended new records.  Also,  what will happen if somebody starts several copies of your program?\nAnd the last thing.  Unless you are running on a 1980s 8bit computer a few thousand CSV lines is nothing to the modern hardware.  Even if the files are loaded and written back you wouldn't notice any difference","Q_Score":2,"Tags":"python,file-access","A_Id":65067764,"CreationDate":"2020-11-30T03:03:00.000","Title":"Does Python's \"append\" file write mode only write new bytes, or does it re-write the entire file as well?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having an issue with calling 'hello'.\nIn first example, no problem:\nd = {'k1':{'k2':'hello'}}\nGrab 'hello'\nd['k1']['k2']\nOutput: 'hello'\nBut the second example, I cannot get my head around nested dictionary in list.\nd = {'k1':[{'nest_key':['this is deep',['hello']]}]}\n#Grab hello\nd['k1'][0]\nOutput:\n{'nest_key': ['this is deep', ['hello']]}\nI tried d['k1']['nest_key'] but it gets me error. I tried to look it up in docs but it didn't help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":106,"Q_Id":65069033,"Users Score":2,"Answer":"d[k1] is a list with 1 element which is a dict.\nso d[k1][0] accesses the 2nd dict.\nd[k1][0][nest_key] accesses the inner lis which is [\"this is deep'',[hallo]]\nso d[k1][0][nest_key][1][0] gives you the \"hallo\"\nIt is all about the square brackets defining lists within the dict","Q_Score":1,"Tags":"python,list,dictionary","A_Id":65069124,"CreationDate":"2020-11-30T06:35:00.000","Title":"Calling value in n-level nested list in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Not really a coding question, but one for understanding the python language. The apply_async function (from multiprocessing library) has one pass arguments to the function with something that looks like this:\nresult = pool.apply_async(some_func, (argument1,))\nWhy does the function require passing arguments with (argument1, ), requiring a comma before an empty argument? I understand tuples, but what's with the empty argument?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":49,"Q_Id":65069859,"Users Score":1,"Answer":"That is a tuple with only one element. You could also pass more arguments inside this tuple so the method requires a tuple. If you only have one argument, you need a single element tuple","Q_Score":1,"Tags":"python,multiprocessing","A_Id":65069999,"CreationDate":"2020-11-30T08:01:00.000","Title":"Multiprocessing apply_async odd argument-passing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"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":"Developing a DLP client and Setting GOOGLE_APPLICATION_CREDENTIALS using win shell.\nAPI is failing with following signature:\ngoogle.auth.exceptions.DefaultCredentialsError: File \"XXXXX.json\" was not found.\nWhen set in code using\nos.environ[\"GOOGLE_APPLICATION_CREDENTIALS\"] = \"XXXXX.json\" it works fine.\nOS used windows 10.\nCan any one explain the reason?\nUpdates\n\nI did set environment variable from pycharm terminal.\nI am running the code from pycharm terminal: python my_code.py\nWhen i print(os.environ[\"GOOGLE_APPLICATION_CREDENTIALS\"]) i get the value i did set.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":65074318,"Users Score":1,"Answer":"Issue Found:\nEnvironmental variable was set using quotes.\nIt should be without quotes.\nset GOOGLE_APPLICATION_CREDENTIALS=\"path\\to\\secret\\key\"\nConfusing debug message\ngoogle.auth.exceptions.DefaultCredentialsError: File \"path\\to\\secret\\key\" was not found.\nResolution:\nset GOOGLE_APPLICATION_CREDENTIALS=path\\to\\secret\\key","Q_Score":1,"Tags":"python,google-cloud-platform,google-cloud-dlp","A_Id":65103547,"CreationDate":"2020-11-30T13:16:00.000","Title":"Python GCP API not able to read environmental values","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to generate dynamic workflow in airflow based on user input. I know there is option to have it based on data from file and database but in all these cases, workflow will not directly be dependent on user input and in case where multiple users are using same dag then in that case also issue may come. To avoid all these, i am thinking of passing user input to sub dag and generate the workflow. But subdag does not have option of passing user input from ui.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":893,"Q_Id":65076689,"Users Score":0,"Answer":"There are many tricks for getting the same done, but the actual solution should come from airflow by way of dynamic task which is missing at present. Hopefully we will see that in future version of airflow.","Q_Score":3,"Tags":"python,airflow","A_Id":68923547,"CreationDate":"2020-11-30T15:46:00.000","Title":"Is it possible to pass user input from dag to sub dag in airflow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I installed fasttext manually and also installing it using pip install. But\nwhen I use this code\nmodel = fastText.train_supervised(input=training_data_path, **hyper_params)\noutput: No module named 'fastText'\nAlso this code:\nmodel = fasttext.train_supervised(input=training_data_path, **hyper_params)\noutput: fasttext' has no attribute 'train_supervised'\nI already installed and follow the documentation still no fix","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":464,"Q_Id":65076865,"Users Score":1,"Answer":"Copied the folder named fasttext in anaconda site-packages dir and paste it in site-packages of Python dir and renaming it by:\norig name: \"fasttext\"\nchanges: \"fastText\"","Q_Score":0,"Tags":"python,fasttext","A_Id":65089579,"CreationDate":"2020-11-30T15:56:00.000","Title":"fasttext' has no attribute 'train_supervised' on Windows 10","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create one time links in Django but I have no idea where to start. The idea is to send a onetime registration link. The payload should contain information such as an email address and company name, so that when the customer clicks the link and registers the company name and email will automatically be send with the post.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":352,"Q_Id":65077208,"Users Score":0,"Answer":"One way to achieve that is to create a link with query parameters in the URL.\nURLtoRegisterTheCompany?email=company@email.com&company=companyName\nThen when the user clicks the link you would open a new page, using Javascript you can then listen to the onload event of the page read both email and company query parameters and send a POST request to your backend. If the POST request succeeds you can tell the user something like your company was successfully registered and it fails and your return for instance a HTTP code 422 \"Entity already exists\", show your company was already registered.","Q_Score":0,"Tags":"python-3.x,django-rest-framework,token,registration","A_Id":65095525,"CreationDate":"2020-11-30T16:18:00.000","Title":"Create one time links in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have different excel files in the same folder, in each of them there are the same sheets. I need to select the last sheet of each file and join them all by the columns (that is, form a single table). The columns of all files are named the same. I think it is to identify the dataframe of each file and then paste them. But I do not know how","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":65084238,"Users Score":0,"Answer":"Just do what Recessive said and use a for loop to read the excel file one by one and do the following:\n\nexcel_files = os.listdir(filepath)\n\n\nfor file in excel_files:\n\nread excel file sheet\n\n\n\n\nsave specific column to variable\n\n\n\n\nend of loop\n\n\n\nconcatenate each column from different variables to one dataframe","Q_Score":0,"Tags":"python,dataframe,file","A_Id":65084562,"CreationDate":"2020-12-01T03:18:00.000","Title":"I have different excel files in the same folder","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing a fresh install on a new Windows 10 laptop. I installed Python 3.9 and PyCharm Community 2020.2, then started a new project. In the project settings, I created a new project interpreter in a venv, inside the \/venv folder. Everything looks to get set up correctly, but I can't install anything to the project interpreter. When I try to do so, e.g. when I try to install pandas or anything else, I get None-zero exit code (2) with the following message:\n\nUsage:      D:\\MyProject\\project\\venv\\Scripts\\python.exe -m pip install\n[options]  [package-index-options] ...\nD:\\MyProject\\project\\venv\\Scripts\\python.exe -m pip install [options] -r\n [package-index-options] ...\nD:\\MyProject\\project\\venv\\Scripts\\python.exe -m pip install [options]\n[-e]  ...\nD:\\MyProject\\project\\venv\\Scripts\\python.exe -m pip install [options]\n[-e]  ...\nD:\\MyProject\\project\\venv\\Scripts\\python.exe -m pip install [options]\n<archive url\/path> ...\nno such option: --build-dir\n\nWhen I go to the Terminal and just 'pip install pandas' per PyCharm's 'proposed solution', it installs fine, and pandas and its dependencies appear as usual in the list of installed modules in the interpreter. I've not encountered this before, and don't see anywhere in the settings where I can specify how exactly PyCharm will invoke pip in this situation.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":14039,"Q_Id":65085956,"Users Score":2,"Answer":"Pycharm 2020.3 released and it seems like the issue solved by upgrading to this version.","Q_Score":42,"Tags":"python,pip,pycharm,python-venv","A_Id":65168785,"CreationDate":"2020-12-01T06:54:00.000","Title":"PyCharm venv failed: 'no such option: --build-dir'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"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 have few large pandas data frames in python and would like to improve the speed of join operations by adding index. In the similar lines of adding index to a database table.\nWhat i see when searched is only multi-index options. which it looks like a composite index\/multi column index in databases.\nWhat i need is independent indexes on few columns,(Independent because the columns are not related) so that the joins would hopefully work faster.\nIs it possible to define few columns as independent index in pandas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":65094838,"Users Score":0,"Answer":"Well, As you looked, You can use multilevel index in df but if you want independent indexes on specific column, you can apply a trick by setting and resetting index as before joining operation.","Q_Score":1,"Tags":"python,pandas","A_Id":65094935,"CreationDate":"2020-12-01T16:49:00.000","Title":"pandas multiple independent indexes(not multi index)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I Have converted a Python Selenium file into .exe using pyinstaller. However when I open the file the CMD screen flashes and Thats It, The GUI screen to run the executable file is not observed. My Code uses inputs from An Excel\nPre - Condition which I followed\n\nWeb Driver path is updated to the path where the Exe file is located\nChanged the Excel path to the folder where EXE file is located\n\nCould you help me with this option?\nIntent: Trying to Distribute my automation script to my Peers for Testing purpose","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":65095619,"Users Score":0,"Answer":"You probably cant specify the webdriver path like this, since the path differs from computer to computer. try to input it in the same folder all together and then let the path field for the path of the webdriver free. might or might not work","Q_Score":2,"Tags":"python,selenium,browser-automation","A_Id":65096283,"CreationDate":"2020-12-01T17:39:00.000","Title":"Unable to Open an Python Selenium exe file in Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My goal is to feed an object that supports the buffer protocol into hashlib's sha2 generator such that sha2 hashes generated from the same underlying data in different execution environments are consistent, and so can be used for equality tests.\nI would like this to work for arbitrary data types without having to write a bunch of boilerplate wrappers around bytes() or bytearray(), ie, one function I can pass strings (with encoding), numerics, and bools. Extra points if I can get the memory layout for a complex type like a dict or list.\nI am looking at struct, as well as doing something like loading the data into a pandas DataFrame and then using Apache Arrow to access the memory layout directly.\nLooking for guidance as to the most \"pythonic\" way to accomplish this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":65096561,"Users Score":0,"Answer":"hashlib.sha256(bytes(struct.pack('!f', 12.3))).hexdigest())\nRepeat for all native types.","Q_Score":2,"Tags":"python,pandas,memory,hash,apache-arrow","A_Id":65114471,"CreationDate":"2020-12-01T18:40:00.000","Title":"Converting Arbitrary Objects into Bytes in Python3","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to delete\/tab several lines of code at the same time in Jupiter notebook. how could i do that? Is there hot keys for that?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":60,"Q_Id":65100579,"Users Score":1,"Answer":"While in the notebook, click to the left of the grey input box where it says In []: (You'll see the highlight color go from green to blue)\nWhile it's blue, hold down shift and use your up arrow key to select the rows above or below\nPress D twice\nClick back into the cell and the highlight will turn back to green.","Q_Score":0,"Tags":"python,python-3.x,jupyter-notebook","A_Id":65100952,"CreationDate":"2020-12-02T00:32:00.000","Title":"How could i delete several lines of code at the same time in Jupiter notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For the numpy,\npip install numpy==? is not working. It just shows an error message without available package versions.\nThis happens after I got pip upgraded to 20.3.","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":1149,"Q_Id":65100949,"Users Score":-1,"Answer":"This does not answer the question as you (and I) want it to be answered, but I just looked through the documentation on 20.3 as well as the change log and found zilch. I'm not going to waste any more time on this, so my work around is reverting.\npip install pip==20.2.4\nIt is not ideal. I can suffer through the warnings that I should upgrade pip until they make that list or a suitable alternative available again.\nIf you really need the functionality, this will at least let you solve the underlying question about package X (in this case, numpy) until someone in the know comes by.","Q_Score":1,"Tags":"python,pip","A_Id":65112525,"CreationDate":"2020-12-02T01:28:00.000","Title":"How to see available pypi package versions with pip 20.3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the Spotify API (with the Spotipy Wrapper) on a small personal project. This is the call that I am using\nsp.search(q=band,limit=10)\nWhen I use a name like \"Beck\" I also get results from \"Becky G\". Is there a way to limit artists to a particular band or to search for an artist ID by name?\nI tried the artist tag but that wasn't quite working.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":65101111,"Users Score":0,"Answer":"I've just submitted a very similar question before I found this, I don't have a direct answer I'm afraid but in my case I discovered I was getting false matches on in particular Artists in particular with names of 5 characters or less.\nMy workaround was to do a lookup on the artist, do a string match on the named returned from the Spotipy API using the fuzzywuzzy module. If that didn't give me an exact match, I pulled back ten and again used the fuzzywuzzy module to find the closest string match from all 10.","Q_Score":0,"Tags":"python,spotify,spotipy","A_Id":65264740,"CreationDate":"2020-12-02T01:50:00.000","Title":"Spotipy: Wrong\/Several artist coming up when I use sp.search()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using the Spotify API (with the Spotipy Wrapper) on a small personal project. This is the call that I am using\nsp.search(q=band,limit=10)\nWhen I use a name like \"Beck\" I also get results from \"Becky G\". Is there a way to limit artists to a particular band or to search for an artist ID by name?\nI tried the artist tag but that wasn't quite working.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":65101111,"Users Score":0,"Answer":"You can use type to limit your query. For example, try: sp.search(q='Beck', type='artist', limit=10)","Q_Score":0,"Tags":"python,spotify,spotipy","A_Id":65115509,"CreationDate":"2020-12-02T01:50:00.000","Title":"Spotipy: Wrong\/Several artist coming up when I use sp.search()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to make a new column by calculating existing columns.\nFor example df\ndf\nno    data1    data2\n1      10        15\n2      51        46\n3      36        20\n......\ni want to make this\nnew_df\nno    data1    data2    data1\/-2    data1\/2    data2\/-2    data2\/2\n1      10       15         -5          5         -7.5        7.5\n2      51       46        -25.5      25.5        -23         23\n3      36       20         -18        18          -9         9\nbut i don't know how to make this as efficient as possible","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19,"Q_Id":65101780,"Users Score":0,"Answer":"To create a new df column based on the calculations of two or more other columns, you would have to define a new column and set it equal to your equation. For example:\ndf['new_col'] = df['col_1'] * df['col_2']","Q_Score":0,"Tags":"python,dataframe","A_Id":65101842,"CreationDate":"2020-12-02T03:27:00.000","Title":"python : Compute columns of data frames and add them to new columns","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to VS Code and am setting up Python (which I'm also learning). I set up everything you need for python and opened a previous python file I was working on and everything went smoothly. I tried creating a new file in vscode and it opened as a txt file so I switched it to a python file however, to get it to run without f5 I need to manually add '.py' to the end of the file name. Is there any way I can default it to whenever I make a new file it'll be a python file?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2045,"Q_Id":65101822,"Users Score":0,"Answer":"Like the others said, all you need to is create a file with the .py extension in Visual Studio Code, since it's just a fancy version of TextEdit. There are also Python IDEs that have more features.","Q_Score":0,"Tags":"python,visual-studio-code","A_Id":65102008,"CreationDate":"2020-12-02T03:33:00.000","Title":"Creating python files inside VS Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need user_password plaintext using Django. I tried many ways to get plaintext in user_password. but It's not working. So, I analyzed how the Django user password is generated. it's using the make_password method in the Django core model. In this method generating the hashed code using( pbkdf2_sha256) algorthm. If any possible to decrypt the password.\nExample:\npbkdf2_sha256$150000$O9hNDLwzBc7r$RzJPG76Vki36xEflUPKn37jYI3xRbbf6MTPrWbjFrgQ=","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2194,"Q_Id":65104609,"Users Score":1,"Answer":"As you have already seen, Django uses hashing method like SHA256 in this case. Hashing mechanisms basically use lossy compression method, so there is no way to decrypt hashed messages as they are irreversible. Because it is not encryption and there is no backward method like decryption. It is safe to store password in the hashed form, as only creator of the password should know the original password and the backend system just compares the hashes.\nThis is normal situation for most backend frameworks. Because this is made for security reasons so far. Passwords are hashed and saved in the database so that even if the malicious user gets access to the database, he can't find usefull information there or it will be really hard to crack the hashes with some huge words dictionary.","Q_Score":0,"Tags":"python,django,django-authentication,sha,pbkdf2","A_Id":65104756,"CreationDate":"2020-12-02T08:33:00.000","Title":"How to decrypt django pbkdf2_sha256 algorthim password?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I parse pcap file with scapy python , and there is TCP packet in that pcap that I want to know what is the answer of this pcaket, How can I do that?\nFor example : client and server TCP stream\nclient-> server : \"hi\"\nserver-> client : \"how are you\"\nWhen I get \"hi\" packet (with scapy) how can I get \"how are you\" ?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":524,"Q_Id":65105876,"Users Score":2,"Answer":"Look at the TCP sequence number of the message from the client.  Call this SeqC.\nThen look for the first message from the client whose TCP acknowledgement sequence is higher than SeqC (usually it will be equal to SeqC plus the size of the client's TCP payload).  Call this PacketS1.\nStarting with PacketS1, collect the TCP payloads from all packets until you see a packet sent by the server with the TCP PSH (push) flag set.  This suggests the end of the application-layer message.  Call these payloads PayloadS1 to PayloadSN.\nConcatenate PayloadS1 to PayloadSN.  This is the likely application-layer response to the client message.","Q_Score":5,"Tags":"python,tcp,scapy,pcap","A_Id":65165995,"CreationDate":"2020-12-02T10:02:00.000","Title":"Find answer to tcp packet in PCAP with scapy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using os.startfile(excel file) to open excel application. After running task kill, when I try to open excel again it gives me recovery options.\nIs there any way to open the excel application and close it properly without giving recovery option when I open it again?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1382,"Q_Id":65107046,"Users Score":1,"Answer":"with the argument \/F you force kill the program, not giving it time to save things or clear memory etc.\nwhat os.system('taskkill \/T \/IM EXCEL.exe) does is it sends the same singnal as the program gets when you press the close program button","Q_Score":1,"Tags":"python,xls","A_Id":65107210,"CreationDate":"2020-12-02T11:19:00.000","Title":"os.system('TASKKILL \/F \/IM EXCEL.exe') in python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I plot a circle like for example:\nmyPlot.circle(0, 0, line_width=0.5, size=6, line_color=\"green\", fill_color=None)\nthe size of 6 is not fixed. When I zoom out or in it stays the same. How can I bind the size to the x and y axis? So if my x and y axis is Meter my circle has a radius of 6 meter.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":141,"Q_Id":65109855,"Users Score":1,"Answer":"size is always in screen (pixel) units. You need to set a radius which is in \"data-space\" units. Note you will probably also want to set match_aspect=True and use default auto-ranges on the figure, to make sure the radius has the same length in data-space on both axes.","Q_Score":0,"Tags":"python,bokeh","A_Id":65131711,"CreationDate":"2020-12-02T14:16:00.000","Title":"How to make the size of a glyph \"fixed\" in Bokeh?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get the error text from the below using XPath\n<p id=\"username-error\" class=\"error-msg\" role=\"alert\" data-error=\"messages.INVALID_USERNAME\">Sorry, we don't recognize this&nbsp;email.<\/p>\nhere is my code:\nmessage = driver.find_element_by_xpath('\/\/*[@id=\"username-error\"]').text\nThis piece of code is not returning anything. Kindly help me to get the error text such as \"Sorry, we don't recognize this email.\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":366,"Q_Id":65110228,"Users Score":0,"Answer":"A minor change in the XPath has fixed the problem.\nmessage = driver.find_element_by_xpath('\/\/*[@data-error=\"messages.INVALID_USERNAME\"]').text","Q_Score":0,"Tags":"python,selenium-webdriver,xpath,gettext,webautomation","A_Id":65125130,"CreationDate":"2020-12-02T14:37:00.000","Title":"How to get Error message text using xpath in selenium python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For, example If a button click turns the background blue, or changes the button's text, how do I make sure that change stays even after i go to other frames?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":65110308,"Users Score":0,"Answer":"One way to go is to create a configuration file (e.g. conf.ini) where you store your changes or apply them to other dialogs. It will allow you to keep changes after an app restarted.","Q_Score":0,"Tags":"python,user-interface,interactive","A_Id":65110363,"CreationDate":"2020-12-02T14:42:00.000","Title":"How do I keep changes made within a python GUI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"It is possible to build a project in Django without models ? I have a views, templates(html), css and urls. That site is looking very good in a browser. It is a hairdressing salon website.\nGreetings","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":815,"Q_Id":65112705,"Users Score":2,"Answer":"It is completely possible to create a Django project without any models. You only really need models if your website contains objects, like posts or users.\nFor one example, I created a recreation of Wikipedia using Django using exactly 0 models; since each entry was just a Markdown file, there was no need for any models.","Q_Score":1,"Tags":"python,html,css,django,model","A_Id":65112776,"CreationDate":"2020-12-02T17:01:00.000","Title":"Django project without models and data base","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1}]